summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbiao716.wang <biao716.wang@samsung.com>2020-03-19 01:04:30 +0900
committerbiao716.wang <biao716.wang@samsung.com>2020-03-19 01:04:30 +0900
commit1d6613f4446f69f63beddf2d97c201154fb35e33 (patch)
treef32eae75900a0df14ab8fa1e2bd436af159ef91d
parentaabcd8e66e3268a232efe2e416635d5b6bf84ad5 (diff)
downloadcmake-1d6613f4446f69f63beddf2d97c201154fb35e33.tar.gz
cmake-1d6613f4446f69f63beddf2d97c201154fb35e33.tar.bz2
cmake-1d6613f4446f69f63beddf2d97c201154fb35e33.zip
Imported Upstream version 3.16.4upstream/3.16.4
Change-Id: Ic5262ea6c0872b353ea2dc35fe1e944063ae8409 Signed-off-by: biao716.wang <biao716.wang@samsung.com>
-rw-r--r--Auxiliary/bash-completion/cmake9
-rw-r--r--Auxiliary/cmake-mode.el14
-rw-r--r--Auxiliary/cmake.m42
-rw-r--r--Auxiliary/vim/cmake.vim.in59
-rwxr-xr-xAuxiliary/vim/extract-upper-case.pl65
-rw-r--r--Auxiliary/vim/indent/cmake.vim20
-rw-r--r--Auxiliary/vim/syntax/cmake.vim3112
-rw-r--r--CMakeCPack.cmake23
-rw-r--r--CMakeCPackOptions.cmake.in16
-rw-r--r--CMakeLists.txt294
-rw-r--r--CONTRIBUTING.rst37
-rw-r--r--CTestCustom.cmake.in20
-rw-r--r--CompileFlags.cmake74
-rw-r--r--Copyright.txt10
-rw-r--r--Help/command/FIND_XXX.txt54
-rw-r--r--Help/command/LINK_OPTIONS_LINKER.txt22
-rw-r--r--Help/command/OPTIONS_SHELL.txt9
-rw-r--r--Help/command/add_compile_definitions.rst23
-rw-r--r--Help/command/add_compile_options.rst45
-rw-r--r--Help/command/add_custom_command.rst89
-rw-r--r--Help/command/add_custom_target.rst49
-rw-r--r--Help/command/add_definitions.rst18
-rw-r--r--Help/command/add_dependencies.rst4
-rw-r--r--Help/command/add_executable.rst24
-rw-r--r--Help/command/add_library.rst59
-rw-r--r--Help/command/add_link_options.rst31
-rw-r--r--Help/command/add_subdirectory.rst9
-rw-r--r--Help/command/add_test.rst26
-rw-r--r--Help/command/aux_source_directory.rst6
-rw-r--r--Help/command/break.rst4
-rw-r--r--Help/command/build_command.rst2
-rw-r--r--Help/command/build_name.rst2
-rw-r--r--Help/command/cmake_host_system_information.rst45
-rw-r--r--Help/command/cmake_minimum_required.rst50
-rw-r--r--Help/command/cmake_parse_arguments.rst69
-rw-r--r--Help/command/cmake_policy.rst40
-rw-r--r--Help/command/configure_file.rst32
-rw-r--r--Help/command/continue.rst6
-rw-r--r--Help/command/create_test_sourcelist.rst2
-rw-r--r--Help/command/ctest_build.rst4
-rw-r--r--Help/command/ctest_coverage.rst2
-rw-r--r--Help/command/ctest_start.rst90
-rw-r--r--Help/command/ctest_submit.rst35
-rw-r--r--Help/command/ctest_test.rst6
-rw-r--r--Help/command/ctest_update.rst12
-rw-r--r--Help/command/define_property.rst26
-rw-r--r--Help/command/else.rst4
-rw-r--r--Help/command/elseif.rst9
-rw-r--r--Help/command/enable_language.rst17
-rw-r--r--Help/command/enable_testing.rst17
-rw-r--r--Help/command/endforeach.rst8
-rw-r--r--Help/command/endfunction.rst8
-rw-r--r--Help/command/endif.rst8
-rw-r--r--Help/command/endmacro.rst8
-rw-r--r--Help/command/endwhile.rst8
-rw-r--r--Help/command/exec_program.rst4
-rw-r--r--Help/command/execute_process.rst35
-rw-r--r--Help/command/export.rst36
-rw-r--r--Help/command/export_library_dependencies.rst2
-rw-r--r--Help/command/file.rst723
-rw-r--r--Help/command/find_file.rst12
-rw-r--r--Help/command/find_library.rst12
-rw-r--r--Help/command/find_package.rst290
-rw-r--r--Help/command/find_path.rst12
-rw-r--r--Help/command/find_program.rst5
-rw-r--r--Help/command/fltk_wrap_ui.rst2
-rw-r--r--Help/command/foreach.rst99
-rw-r--r--Help/command/function.rst88
-rw-r--r--Help/command/get_cmake_property.rst12
-rw-r--r--Help/command/get_directory_property.rst19
-rw-r--r--Help/command/get_filename_component.rst39
-rw-r--r--Help/command/get_property.rst25
-rw-r--r--Help/command/get_source_file_property.rst18
-rw-r--r--Help/command/get_target_property.rst15
-rw-r--r--Help/command/get_test_property.rst14
-rw-r--r--Help/command/if.rst150
-rw-r--r--Help/command/include.rst10
-rw-r--r--Help/command/include_directories.rst8
-rw-r--r--Help/command/include_external_msproject.rst6
-rw-r--r--Help/command/include_guard.rst46
-rw-r--r--Help/command/include_regular_expression.rst4
-rw-r--r--Help/command/install.rst503
-rw-r--r--Help/command/install_files.rst6
-rw-r--r--Help/command/install_programs.rst4
-rw-r--r--Help/command/install_targets.rst4
-rw-r--r--Help/command/link_directories.rst52
-rw-r--r--Help/command/link_libraries.rst2
-rw-r--r--Help/command/list.rst343
-rw-r--r--Help/command/load_cache.rst13
-rw-r--r--Help/command/load_command.rst2
-rw-r--r--Help/command/macro.rst138
-rw-r--r--Help/command/make_directory.rst4
-rw-r--r--Help/command/mark_as_advanced.rst27
-rw-r--r--Help/command/math.rst37
-rw-r--r--Help/command/message.rst75
-rw-r--r--Help/command/option.rst13
-rw-r--r--Help/command/output_required_files.rst8
-rw-r--r--Help/command/project.rst155
-rw-r--r--Help/command/qt_wrap_cpp.rst21
-rw-r--r--Help/command/qt_wrap_ui.rst18
-rw-r--r--Help/command/remove.rst4
-rw-r--r--Help/command/remove_definitions.rst4
-rw-r--r--Help/command/return.rst7
-rw-r--r--Help/command/separate_arguments.rst46
-rw-r--r--Help/command/set.rst29
-rw-r--r--Help/command/set_directory_properties.rst15
-rw-r--r--Help/command/set_property.rst56
-rw-r--r--Help/command/set_source_files_properties.rst12
-rw-r--r--Help/command/set_target_properties.rst8
-rw-r--r--Help/command/set_tests_properties.rst11
-rw-r--r--Help/command/site_name.rst2
-rw-r--r--Help/command/source_group.rst2
-rw-r--r--Help/command/string.rst356
-rw-r--r--Help/command/subdir_depends.rst2
-rw-r--r--Help/command/subdirs.rst4
-rw-r--r--Help/command/target_compile_definitions.rst21
-rw-r--r--Help/command/target_compile_features.rst13
-rw-r--r--Help/command/target_compile_options.rst41
-rw-r--r--Help/command/target_include_directories.rst12
-rw-r--r--Help/command/target_link_directories.rst55
-rw-r--r--Help/command/target_link_libraries.rst127
-rw-r--r--Help/command/target_link_options.rst48
-rw-r--r--Help/command/target_precompile_headers.rst124
-rw-r--r--Help/command/target_sources.rst16
-rw-r--r--Help/command/try_compile.rst72
-rw-r--r--Help/command/try_run.rst23
-rw-r--r--Help/command/unset.rst34
-rw-r--r--Help/command/use_mangled_mesa.rst4
-rw-r--r--Help/command/utility_source.rst2
-rw-r--r--Help/command/variable_requires.rst4
-rw-r--r--Help/command/variable_watch.rst14
-rw-r--r--Help/command/while.rst24
-rw-r--r--Help/command/write_file.rst4
-rw-r--r--Help/cpack_gen/archive.rst36
-rw-r--r--Help/cpack_gen/bundle.rst66
-rw-r--r--Help/cpack_gen/cygwin.rst23
-rw-r--r--Help/cpack_gen/deb.rst565
-rw-r--r--Help/cpack_gen/dmg.rst101
-rw-r--r--Help/cpack_gen/external.rst283
-rw-r--r--Help/cpack_gen/freebsd.rst138
-rw-r--r--Help/cpack_gen/ifw.rst339
-rw-r--r--Help/cpack_gen/nsis.rst130
-rw-r--r--Help/cpack_gen/nuget.rst189
-rw-r--r--Help/cpack_gen/packagemaker.rst23
-rw-r--r--Help/cpack_gen/productbuild.rst68
-rw-r--r--Help/cpack_gen/rpm.rst955
-rw-r--r--Help/cpack_gen/wix.rst288
-rw-r--r--Help/dev/README.rst2
-rw-r--r--Help/dev/documentation.rst530
-rw-r--r--Help/dev/maint.rst148
-rw-r--r--Help/dev/review.rst176
-rw-r--r--Help/dev/source.rst77
-rw-r--r--Help/dev/testing.rst5
-rw-r--r--Help/envvar/ASM_DIALECT.rst14
-rw-r--r--Help/envvar/ASM_DIALECTFLAGS.rst13
-rw-r--r--Help/envvar/CC.rst11
-rw-r--r--Help/envvar/CFLAGS.rst11
-rw-r--r--Help/envvar/CMAKE_BUILD_PARALLEL_LEVEL.rst11
-rw-r--r--Help/envvar/CMAKE_CONFIG_TYPE.rst7
-rw-r--r--Help/envvar/CMAKE_GENERATOR.rst16
-rw-r--r--Help/envvar/CMAKE_GENERATOR_INSTANCE.rst7
-rw-r--r--Help/envvar/CMAKE_GENERATOR_PLATFORM.rst8
-rw-r--r--Help/envvar/CMAKE_GENERATOR_TOOLSET.rst8
-rw-r--r--Help/envvar/CMAKE_MSVCIDE_RUN_PATH.rst10
-rw-r--r--Help/envvar/CMAKE_NO_VERBOSE.rst8
-rw-r--r--Help/envvar/CMAKE_OSX_ARCHITECTURES.rst10
-rw-r--r--Help/envvar/CSFLAGS.rst11
-rw-r--r--Help/envvar/CTEST_INTERACTIVE_DEBUG_MODE.rst7
-rw-r--r--Help/envvar/CTEST_OUTPUT_ON_FAILURE.rst9
-rw-r--r--Help/envvar/CTEST_PARALLEL_LEVEL.rst7
-rw-r--r--Help/envvar/CTEST_PROGRESS_OUTPUT.rst16
-rw-r--r--Help/envvar/CTEST_USE_LAUNCHERS_DEFAULT.rst6
-rw-r--r--Help/envvar/CUDACXX.rst11
-rw-r--r--Help/envvar/CUDAFLAGS.rst11
-rw-r--r--Help/envvar/CUDAHOSTCXX.rst15
-rw-r--r--Help/envvar/CXX.rst11
-rw-r--r--Help/envvar/CXXFLAGS.rst11
-rw-r--r--Help/envvar/DASHBOARD_TEST_FROM_CTEST.rst8
-rw-r--r--Help/envvar/DESTDIR.rst21
-rw-r--r--Help/envvar/ENV_VAR.txt3
-rw-r--r--Help/envvar/FC.rst12
-rw-r--r--Help/envvar/FFLAGS.rst11
-rw-r--r--Help/envvar/LDFLAGS.rst12
-rw-r--r--Help/envvar/MACOSX_DEPLOYMENT_TARGET.rst10
-rw-r--r--Help/envvar/PackageName_ROOT.rst17
-rw-r--r--Help/envvar/RC.rst11
-rw-r--r--Help/envvar/RCFLAGS.rst11
-rw-r--r--Help/envvar/SWIFTC.rst11
-rw-r--r--Help/envvar/VERBOSE.rst10
-rw-r--r--Help/generator/CodeBlocks.rst12
-rw-r--r--Help/generator/CodeLite.rst6
-rw-r--r--Help/generator/Eclipse CDT4.rst2
-rw-r--r--Help/generator/Green Hills MULTI.rst57
-rw-r--r--Help/generator/KDevelop3.rst25
-rw-r--r--Help/generator/Kate.rst8
-rw-r--r--Help/generator/MSYS Makefiles.rst3
-rw-r--r--Help/generator/MinGW Makefiles.rst3
-rw-r--r--Help/generator/Ninja.rst13
-rw-r--r--Help/generator/Sublime Text 2.rst10
-rw-r--r--Help/generator/Unix Makefiles.rst29
-rw-r--r--Help/generator/VS_TOOLSET_HOST_ARCH.txt9
-rw-r--r--Help/generator/Visual Studio 10 2010.rst29
-rw-r--r--Help/generator/Visual Studio 11 2012.rst31
-rw-r--r--Help/generator/Visual Studio 12 2013.rst32
-rw-r--r--Help/generator/Visual Studio 14 2015.rst26
-rw-r--r--Help/generator/Visual Studio 15 2017.rst55
-rw-r--r--Help/generator/Visual Studio 16 2019.rst54
-rw-r--r--Help/generator/Visual Studio 8 2005.rst23
-rw-r--r--Help/generator/Visual Studio 9 2008.rst19
-rw-r--r--Help/generator/Xcode.rst2
-rw-r--r--Help/guide/tutorial/Complete/CMakeLists.txt120
-rw-r--r--Help/guide/tutorial/Complete/CTestConfig.cmake7
-rw-r--r--Help/guide/tutorial/Complete/Config.cmake.in4
-rw-r--r--Help/guide/tutorial/Complete/License.txt2
-rw-r--r--Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt63
-rw-r--r--Help/guide/tutorial/Complete/MathFunctions/MakeTable.cxx25
-rw-r--r--Help/guide/tutorial/Complete/MathFunctions/MathFunctions.cxx19
-rw-r--r--Help/guide/tutorial/Complete/MathFunctions/MathFunctions.h14
-rw-r--r--Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx37
-rw-r--r--Help/guide/tutorial/Complete/MathFunctions/mysqrt.h6
-rw-r--r--Help/guide/tutorial/Complete/TutorialConfig.h.in3
-rw-r--r--Help/guide/tutorial/Complete/tutorial.cxx26
-rw-r--r--Help/guide/tutorial/Consumer/CMakeLists.txt51
-rw-r--r--Help/guide/tutorial/Consumer/Config.cmake.in14
-rw-r--r--Help/guide/tutorial/Consumer/consumer.cxx11
-rw-r--r--Help/guide/tutorial/MultiPackage/CMakeLists.txt112
-rw-r--r--Help/guide/tutorial/MultiPackage/Config.cmake.in4
-rw-r--r--Help/guide/tutorial/MultiPackage/License.txt2
-rw-r--r--Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt59
-rw-r--r--Help/guide/tutorial/MultiPackage/MathFunctions/MakeTable.cxx25
-rw-r--r--Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.cxx19
-rw-r--r--Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.h14
-rw-r--r--Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx38
-rw-r--r--Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.h6
-rw-r--r--Help/guide/tutorial/MultiPackage/MultiCPackConfig.cmake7
-rw-r--r--Help/guide/tutorial/MultiPackage/TutorialConfig.h.in3
-rw-r--r--Help/guide/tutorial/MultiPackage/tutorial.cxx25
-rw-r--r--Help/guide/tutorial/Step1/tutorial.cxx22
-rw-r--r--Help/guide/tutorial/Step10/CMakeLists.txt73
-rw-r--r--Help/guide/tutorial/Step10/CTestConfig.cmake7
-rw-r--r--Help/guide/tutorial/Step10/License.txt2
-rw-r--r--Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt51
-rw-r--r--Help/guide/tutorial/Step10/MathFunctions/MakeTable.cxx25
-rw-r--r--Help/guide/tutorial/Step10/MathFunctions/MathFunctions.cxx19
-rw-r--r--Help/guide/tutorial/Step10/MathFunctions/MathFunctions.h14
-rw-r--r--Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx37
-rw-r--r--Help/guide/tutorial/Step10/MathFunctions/mysqrt.h6
-rw-r--r--Help/guide/tutorial/Step10/TutorialConfig.h.in3
-rw-r--r--Help/guide/tutorial/Step10/tutorial.cxx27
-rw-r--r--Help/guide/tutorial/Step11/CMakeLists.txt81
-rw-r--r--Help/guide/tutorial/Step11/CTestConfig.cmake7
-rw-r--r--Help/guide/tutorial/Step11/License.txt2
-rw-r--r--Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt55
-rw-r--r--Help/guide/tutorial/Step11/MathFunctions/MakeTable.cxx25
-rw-r--r--Help/guide/tutorial/Step11/MathFunctions/MathFunctions.cxx19
-rw-r--r--Help/guide/tutorial/Step11/MathFunctions/MathFunctions.h14
-rw-r--r--Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx37
-rw-r--r--Help/guide/tutorial/Step11/MathFunctions/mysqrt.h6
-rw-r--r--Help/guide/tutorial/Step11/TutorialConfig.h.in3
-rw-r--r--Help/guide/tutorial/Step11/tutorial.cxx26
-rw-r--r--Help/guide/tutorial/Step2/CMakeLists.txt21
-rw-r--r--Help/guide/tutorial/Step2/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step2/MathFunctions/MathFunctions.h)0
-rw-r--r--Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx22
-rw-r--r--Help/guide/tutorial/Step2/TutorialConfig.h.in3
-rw-r--r--Help/guide/tutorial/Step2/tutorial.cxx26
-rw-r--r--Help/guide/tutorial/Step3/CMakeLists.txt34
-rw-r--r--Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt (renamed from Tests/Tutorial/Step2/MathFunctions/CMakeLists.txt)0
-rw-r--r--Help/guide/tutorial/Step3/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step3/MathFunctions/MathFunctions.h)0
-rw-r--r--Help/guide/tutorial/Step3/MathFunctions/mysqrt.cxx24
-rw-r--r--Help/guide/tutorial/Step3/TutorialConfig.h.in4
-rw-r--r--Help/guide/tutorial/Step3/tutorial.cxx36
-rw-r--r--Help/guide/tutorial/Step4/CMakeLists.txt32
-rw-r--r--Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt7
-rw-r--r--Help/guide/tutorial/Step4/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step4/MathFunctions/MathFunctions.h)0
-rw-r--r--Help/guide/tutorial/Step4/MathFunctions/mysqrt.cxx24
-rw-r--r--Help/guide/tutorial/Step4/TutorialConfig.h.in4
-rw-r--r--Help/guide/tutorial/Step4/tutorial.cxx36
-rw-r--r--Help/guide/tutorial/Step5/CMakeLists.txt66
-rw-r--r--Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt11
-rw-r--r--Help/guide/tutorial/Step5/MathFunctions/MakeTable.cxx25
-rw-r--r--Help/guide/tutorial/Step5/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step5/MathFunctions/MathFunctions.h)0
-rw-r--r--Help/guide/tutorial/Step5/MathFunctions/mysqrt.cxx24
-rw-r--r--Help/guide/tutorial/Step5/TutorialConfig.h.in4
-rw-r--r--Help/guide/tutorial/Step5/tutorial.cxx36
-rw-r--r--Help/guide/tutorial/Step6/CMakeLists.txt66
-rw-r--r--Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt22
-rw-r--r--Help/guide/tutorial/Step6/MathFunctions/MakeTable.cxx25
-rw-r--r--Help/guide/tutorial/Step6/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step6/MathFunctions/MathFunctions.h)0
-rw-r--r--Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx32
-rw-r--r--Help/guide/tutorial/Step6/TutorialConfig.h.in4
-rw-r--r--Help/guide/tutorial/Step6/tutorial.cxx36
-rw-r--r--Help/guide/tutorial/Step7/CMakeLists.txt66
-rw-r--r--Help/guide/tutorial/Step7/License.txt2
-rw-r--r--Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt29
-rw-r--r--Help/guide/tutorial/Step7/MathFunctions/MakeTable.cxx25
-rw-r--r--Help/guide/tutorial/Step7/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step7/MathFunctions/MathFunctions.h)0
-rw-r--r--Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx33
-rw-r--r--Help/guide/tutorial/Step7/TutorialConfig.h.in4
-rw-r--r--Help/guide/tutorial/Step7/tutorial.cxx36
-rw-r--r--Help/guide/tutorial/Step8/CMakeLists.txt73
-rw-r--r--Help/guide/tutorial/Step8/License.txt2
-rw-r--r--Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt29
-rw-r--r--Help/guide/tutorial/Step8/MathFunctions/MakeTable.cxx25
-rw-r--r--Help/guide/tutorial/Step8/MathFunctions/MathFunctions.h1
-rw-r--r--Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx33
-rw-r--r--Help/guide/tutorial/Step8/TutorialConfig.h.in4
-rw-r--r--Help/guide/tutorial/Step8/tutorial.cxx36
-rw-r--r--Help/guide/tutorial/Step9/CMakeLists.txt72
-rw-r--r--Help/guide/tutorial/Step9/CTestConfig.cmake7
-rw-r--r--Help/guide/tutorial/Step9/License.txt2
-rw-r--r--Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt27
-rw-r--r--Help/guide/tutorial/Step9/MathFunctions/MakeTable.cxx25
-rw-r--r--Help/guide/tutorial/Step9/MathFunctions/MathFunctions.cxx19
-rw-r--r--Help/guide/tutorial/Step9/MathFunctions/MathFunctions.h1
-rw-r--r--Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx33
-rw-r--r--Help/guide/tutorial/Step9/MathFunctions/mysqrt.h6
-rw-r--r--Help/guide/tutorial/Step9/TutorialConfig.h.in4
-rw-r--r--Help/guide/tutorial/Step9/tutorial.cxx36
-rw-r--r--Help/guide/tutorial/index.rst902
-rw-r--r--Help/index.rst15
-rw-r--r--Help/manual/LINKS.txt20
-rw-r--r--Help/manual/OPTIONS_BUILD.txt54
-rw-r--r--Help/manual/ccmake.1.rst6
-rw-r--r--Help/manual/cmake-buildsystem.7.rst90
-rw-r--r--Help/manual/cmake-commands.7.rst20
-rw-r--r--Help/manual/cmake-compile-features.7.rst44
-rw-r--r--Help/manual/cmake-developer.7.rst682
-rw-r--r--Help/manual/cmake-env-variables.7.rst73
-rw-r--r--Help/manual/cmake-file-api.7.rst1113
-rw-r--r--Help/manual/cmake-generator-expressions.7.rst630
-rw-r--r--Help/manual/cmake-generators.7.rst6
-rw-r--r--Help/manual/cmake-gui.1.rst15
-rw-r--r--Help/manual/cmake-language.7.rst111
-rw-r--r--Help/manual/cmake-modules.7.rst154
-rw-r--r--Help/manual/cmake-packages.7.rst74
-rw-r--r--Help/manual/cmake-policies.7.rst78
-rw-r--r--Help/manual/cmake-properties.7.rst100
-rw-r--r--Help/manual/cmake-qt.7.rst52
-rw-r--r--Help/manual/cmake-server.7.rst86
-rw-r--r--Help/manual/cmake-toolchains.7.rst151
-rw-r--r--Help/manual/cmake-variables.7.rst168
-rw-r--r--Help/manual/cmake.1.rst493
-rw-r--r--Help/manual/cpack-generators.7.rst29
-rw-r--r--Help/manual/cpack.1.rst144
-rw-r--r--Help/manual/ctest.1.rst800
-rw-r--r--Help/module/CPackArchive.rst5
-rw-r--r--Help/module/CPackBundle.rst5
-rw-r--r--Help/module/CPackCygwin.rst5
-rw-r--r--Help/module/CPackDMG.rst5
-rw-r--r--Help/module/CPackDeb.rst5
-rw-r--r--Help/module/CPackFreeBSD.rst4
-rw-r--r--Help/module/CPackNSIS.rst5
-rw-r--r--Help/module/CPackNuGet.rst4
-rw-r--r--Help/module/CPackPackageMaker.rst5
-rw-r--r--Help/module/CPackProductBuild.rst5
-rw-r--r--Help/module/CPackRPM.rst5
-rw-r--r--Help/module/CPackWIX.rst6
-rw-r--r--Help/module/CheckFortranSourceRuns.rst1
-rw-r--r--Help/module/CheckOBJCCompilerFlag.rst1
-rw-r--r--Help/module/CheckOBJCSourceCompiles.rst1
-rw-r--r--Help/module/CheckOBJCSourceRuns.rst1
-rw-r--r--Help/module/CheckOBJCXXCompilerFlag.rst1
-rw-r--r--Help/module/CheckOBJCXXSourceCompiles.rst1
-rw-r--r--Help/module/CheckOBJCXXSourceRuns.rst1
-rw-r--r--Help/module/CheckPIESupported.rst1
-rw-r--r--Help/module/FetchContent.rst1
-rw-r--r--Help/module/FindEnvModules.rst1
-rw-r--r--Help/module/FindFontconfig.rst1
-rw-r--r--Help/module/FindIconv.rst1
-rw-r--r--Help/module/FindLibinput.rst1
-rw-r--r--Help/module/FindODBC.rst1
-rw-r--r--Help/module/FindOpenACC.rst1
-rw-r--r--Help/module/FindPatch.rst1
-rw-r--r--Help/module/FindPython.rst1
-rw-r--r--Help/module/FindPython2.rst1
-rw-r--r--Help/module/FindPython3.rst1
-rw-r--r--Help/module/FindSQLite3.rst1
-rw-r--r--Help/policy/CMP0000.rst24
-rw-r--r--Help/policy/CMP0001.rst16
-rw-r--r--Help/policy/CMP0002.rst12
-rw-r--r--Help/policy/CMP0003.rst10
-rw-r--r--Help/policy/CMP0004.rst11
-rw-r--r--Help/policy/CMP0005.rst10
-rw-r--r--Help/policy/CMP0006.rst26
-rw-r--r--Help/policy/CMP0007.rst10
-rw-r--r--Help/policy/CMP0008.rst19
-rw-r--r--Help/policy/CMP0009.rst16
-rw-r--r--Help/policy/CMP0010.rst10
-rw-r--r--Help/policy/CMP0011.rst31
-rw-r--r--Help/policy/CMP0012.rst27
-rw-r--r--Help/policy/CMP0013.rst6
-rw-r--r--Help/policy/CMP0014.rst16
-rw-r--r--Help/policy/CMP0015.rst20
-rw-r--r--Help/policy/CMP0016.rst9
-rw-r--r--Help/policy/CMP0017.rst16
-rw-r--r--Help/policy/CMP0018.rst35
-rw-r--r--Help/policy/CMP0019.rst8
-rw-r--r--Help/policy/CMP0020.rst22
-rw-r--r--Help/policy/CMP0021.rst19
-rw-r--r--Help/policy/CMP0022.rst30
-rw-r--r--Help/policy/CMP0023.rst22
-rw-r--r--Help/policy/CMP0024.rst19
-rw-r--r--Help/policy/CMP0025.rst10
-rw-r--r--Help/policy/CMP0026.rst23
-rw-r--r--Help/policy/CMP0027.rst28
-rw-r--r--Help/policy/CMP0028.rst26
-rw-r--r--Help/policy/CMP0037.rst20
-rw-r--r--Help/policy/CMP0038.rst8
-rw-r--r--Help/policy/CMP0039.rst8
-rw-r--r--Help/policy/CMP0040.rst2
-rw-r--r--Help/policy/CMP0041.rst8
-rw-r--r--Help/policy/CMP0042.rst4
-rw-r--r--Help/policy/CMP0043.rst8
-rw-r--r--Help/policy/CMP0044.rst8
-rw-r--r--Help/policy/CMP0045.rst8
-rw-r--r--Help/policy/CMP0046.rst8
-rw-r--r--Help/policy/CMP0047.rst10
-rw-r--r--Help/policy/CMP0048.rst14
-rw-r--r--Help/policy/CMP0049.rst16
-rw-r--r--Help/policy/CMP0050.rst8
-rw-r--r--Help/policy/CMP0052.rst7
-rw-r--r--Help/policy/CMP0053.rst4
-rw-r--r--Help/policy/CMP0055.rst8
-rw-r--r--Help/policy/CMP0056.rst6
-rw-r--r--Help/policy/CMP0060.rst6
-rw-r--r--Help/policy/CMP0061.rst2
-rw-r--r--Help/policy/CMP0062.rst2
-rw-r--r--Help/policy/CMP0065.rst2
-rw-r--r--Help/policy/CMP0066.rst2
-rw-r--r--Help/policy/CMP0067.rst2
-rw-r--r--Help/policy/CMP0070.rst25
-rw-r--r--Help/policy/CMP0071.rst42
-rw-r--r--Help/policy/CMP0072.rst26
-rw-r--r--Help/policy/CMP0073.rst25
-rw-r--r--Help/policy/CMP0074.rst23
-rw-r--r--Help/policy/CMP0075.rst26
-rw-r--r--Help/policy/CMP0076.rst26
-rw-r--r--Help/policy/CMP0077.rst52
-rw-r--r--Help/policy/CMP0078.rst24
-rw-r--r--Help/policy/CMP0079.rst40
-rw-r--r--Help/policy/CMP0080.rst25
-rw-r--r--Help/policy/CMP0081.rst22
-rw-r--r--Help/policy/CMP0082.rst26
-rw-r--r--Help/policy/CMP0083.rst69
-rw-r--r--Help/policy/CMP0084.rst26
-rw-r--r--Help/policy/CMP0085.rst21
-rw-r--r--Help/policy/CMP0086.rst20
-rw-r--r--Help/policy/CMP0087.rst29
-rw-r--r--Help/policy/CMP0088.rst29
-rw-r--r--Help/policy/CMP0089.rst30
-rw-r--r--Help/policy/CMP0090.rst27
-rw-r--r--Help/policy/CMP0091.rst49
-rw-r--r--Help/policy/CMP0092.rst38
-rw-r--r--Help/policy/CMP0093.rst24
-rw-r--r--Help/policy/CMP0094.rst22
-rw-r--r--Help/policy/CMP0095.rst30
-rw-r--r--Help/policy/CMP0096.rst25
-rw-r--r--Help/policy/CMP0097.rst23
-rw-r--r--Help/policy/DISALLOWED_COMMAND.txt8
-rw-r--r--Help/prop_cache/ADVANCED.rst2
-rw-r--r--Help/prop_cache/STRINGS.rst4
-rw-r--r--Help/prop_cache/TYPE.rst6
-rw-r--r--Help/prop_dir/ADDITIONAL_CLEAN_FILES.rst21
-rw-r--r--Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst16
-rw-r--r--Help/prop_dir/BUILDSYSTEM_TARGETS.rst2
-rw-r--r--Help/prop_dir/COMPILE_DEFINITIONS.rst2
-rw-r--r--Help/prop_dir/COMPILE_OPTIONS.rst2
-rw-r--r--Help/prop_dir/EXCLUDE_FROM_ALL.rst14
-rw-r--r--Help/prop_dir/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM.rst10
-rw-r--r--Help/prop_dir/INCLUDE_DIRECTORIES.rst12
-rw-r--r--Help/prop_dir/INTERPROCEDURAL_OPTIMIZATION_CONFIG.rst2
-rw-r--r--Help/prop_dir/LABELS.rst13
-rw-r--r--Help/prop_dir/LINK_DIRECTORIES.rst15
-rw-r--r--Help/prop_dir/LINK_OPTIONS.rst17
-rw-r--r--Help/prop_dir/MACROS.rst2
-rw-r--r--Help/prop_dir/SUBDIRECTORIES.rst2
-rw-r--r--Help/prop_dir/TESTS.rst8
-rw-r--r--Help/prop_dir/TEST_INCLUDE_FILE.rst4
-rw-r--r--Help/prop_dir/TEST_INCLUDE_FILES.rst7
-rw-r--r--Help/prop_dir/VS_GLOBAL_SECTION_POST_section.rst14
-rw-r--r--Help/prop_dir/VS_GLOBAL_SECTION_PRE_section.rst6
-rw-r--r--Help/prop_dir/VS_STARTUP_PROJECT.rst2
-rw-r--r--Help/prop_gbl/ALLOW_DUPLICATE_CUSTOM_TARGETS.rst16
-rw-r--r--Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst11
-rw-r--r--Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst6
-rw-r--r--Help/prop_gbl/CMAKE_ROLE.rst20
-rw-r--r--Help/prop_gbl/DEBUG_CONFIGURATIONS.rst7
-rw-r--r--Help/prop_gbl/DISABLED_FEATURES.rst6
-rw-r--r--Help/prop_gbl/ECLIPSE_EXTRA_CPROJECT_CONTENTS.rst12
-rw-r--r--Help/prop_gbl/ECLIPSE_EXTRA_NATURES.rst2
-rw-r--r--Help/prop_gbl/ENABLED_FEATURES.rst6
-rw-r--r--Help/prop_gbl/JOB_POOLS.rst8
-rw-r--r--Help/prop_gbl/RULE_MESSAGES.rst2
-rw-r--r--Help/prop_gbl/USE_FOLDERS.rst4
-rw-r--r--Help/prop_gbl/XCODE_EMIT_EFFECTIVE_PLATFORM_NAME.rst7
-rw-r--r--Help/prop_inst/CPACK_DESKTOP_SHORTCUTS.rst4
-rw-r--r--Help/prop_inst/CPACK_NEVER_OVERWRITE.rst2
-rw-r--r--Help/prop_inst/CPACK_PERMANENT.rst2
-rw-r--r--Help/prop_inst/CPACK_STARTUP_SHORTCUTS.rst4
-rw-r--r--Help/prop_inst/CPACK_START_MENU_SHORTCUTS.rst4
-rw-r--r--Help/prop_inst/CPACK_WIX_ACL.rst2
-rw-r--r--Help/prop_sf/AUTORCC_OPTIONS.rst13
-rw-r--r--Help/prop_sf/AUTOUIC_OPTIONS.rst19
-rw-r--r--Help/prop_sf/COMPILE_DEFINITIONS.rst18
-rw-r--r--Help/prop_sf/COMPILE_DEFINITIONS_CONFIG.rst6
-rw-r--r--Help/prop_sf/COMPILE_FLAGS.rst8
-rw-r--r--Help/prop_sf/COMPILE_OPTIONS.rst21
-rw-r--r--Help/prop_sf/EXTERNAL_OBJECT.rst2
-rw-r--r--Help/prop_sf/Fortran_FORMAT.rst7
-rw-r--r--Help/prop_sf/GENERATED.rst23
-rw-r--r--Help/prop_sf/INCLUDE_DIRECTORIES.rst18
-rw-r--r--Help/prop_sf/KEEP_EXTENSION.rst2
-rw-r--r--Help/prop_sf/LABELS.rst2
-rw-r--r--Help/prop_sf/LANGUAGE.rst3
-rw-r--r--Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst14
-rw-r--r--Help/prop_sf/OBJECT_DEPENDS.rst2
-rw-r--r--Help/prop_sf/OBJECT_OUTPUTS.rst6
-rw-r--r--Help/prop_sf/SKIP_AUTOGEN.rst13
-rw-r--r--Help/prop_sf/SKIP_AUTOMOC.rst11
-rw-r--r--Help/prop_sf/SKIP_AUTORCC.rst11
-rw-r--r--Help/prop_sf/SKIP_AUTOUIC.rst16
-rw-r--r--Help/prop_sf/SKIP_PRECOMPILE_HEADERS.rst13
-rw-r--r--Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst11
-rw-r--r--Help/prop_sf/SYMBOLIC.rst2
-rw-r--r--Help/prop_sf/Swift_DEPENDENCIES_FILE.rst5
-rw-r--r--Help/prop_sf/Swift_DIAGNOSTICS_FILE.rst4
-rw-r--r--Help/prop_sf/VS_CSHARP_tagname.rst5
-rw-r--r--Help/prop_sf/VS_DEPLOYMENT_CONTENT.rst3
-rw-r--r--Help/prop_sf/VS_DEPLOYMENT_LOCATION.rst3
-rw-r--r--Help/prop_sf/VS_INCLUDE_IN_VSIX.rst6
-rw-r--r--Help/prop_sf/VS_SHADER_DISABLE_OPTIMIZATIONS.rst6
-rw-r--r--Help/prop_sf/VS_SHADER_ENABLE_DEBUG.rst6
-rw-r--r--Help/prop_sf/VS_SHADER_FLAGS.rst2
-rw-r--r--Help/prop_sf/VS_SHADER_OBJECT_FILE_NAME.rst6
-rw-r--r--Help/prop_sf/VS_SHADER_OUTPUT_HEADER_FILE.rst5
-rw-r--r--Help/prop_sf/VS_SHADER_TYPE.rst2
-rw-r--r--Help/prop_sf/VS_SHADER_VARIABLE_NAME.rst5
-rw-r--r--Help/prop_sf/VS_XAML_TYPE.rst7
-rw-r--r--Help/prop_sf/WRAP_EXCLUDE.rst9
-rw-r--r--Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst2
-rw-r--r--Help/prop_sf/XCODE_FILE_ATTRIBUTES.rst4
-rw-r--r--Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst4
-rw-r--r--Help/prop_test/COST.rst13
-rw-r--r--Help/prop_test/DISABLED.rst14
-rw-r--r--Help/prop_test/ENVIRONMENT.rst2
-rw-r--r--Help/prop_test/FIXTURES_CLEANUP.rst3
-rw-r--r--Help/prop_test/FIXTURES_REQUIRED.rst6
-rw-r--r--Help/prop_test/FIXTURES_SETUP.rst5
-rw-r--r--Help/prop_test/MEASUREMENT.rst8
-rw-r--r--Help/prop_test/PROCESSORS.rst12
-rw-r--r--Help/prop_test/PROCESSOR_AFFINITY.rst11
-rw-r--r--Help/prop_test/RESOURCE_GROUPS.rst70
-rw-r--r--Help/prop_test/RESOURCE_LOCK.rst8
-rw-r--r--Help/prop_test/RUN_SERIAL.rst2
-rw-r--r--Help/prop_test/SKIP_REGULAR_EXPRESSION.rst17
-rw-r--r--Help/prop_test/SKIP_RETURN_CODE.rst5
-rw-r--r--Help/prop_test/WORKING_DIRECTORY.rst6
-rw-r--r--Help/prop_tgt/ADDITIONAL_CLEAN_FILES.rst23
-rw-r--r--Help/prop_tgt/ANDROID_NATIVE_LIB_DIRECTORIES.rst4
-rw-r--r--Help/prop_tgt/AUTOGEN_BUILD_DIR.rst2
-rw-r--r--Help/prop_tgt/AUTOGEN_ORIGIN_DEPENDS.rst38
-rw-r--r--Help/prop_tgt/AUTOGEN_PARALLEL.rst21
-rw-r--r--Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst37
-rw-r--r--Help/prop_tgt/AUTOMOC.rst273
-rw-r--r--Help/prop_tgt/AUTOMOC_COMPILER_PREDEFINES.rst24
-rw-r--r--Help/prop_tgt/AUTOMOC_DEPEND_FILTERS.rst95
-rw-r--r--Help/prop_tgt/AUTOMOC_EXECUTABLE.rst15
-rw-r--r--Help/prop_tgt/AUTOMOC_MACRO_NAMES.rst32
-rw-r--r--Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst32
-rw-r--r--Help/prop_tgt/AUTORCC.rst55
-rw-r--r--Help/prop_tgt/AUTORCC_EXECUTABLE.rst15
-rw-r--r--Help/prop_tgt/AUTORCC_OPTIONS.rst9
-rw-r--r--Help/prop_tgt/AUTOUIC.rst86
-rw-r--r--Help/prop_tgt/AUTOUIC_EXECUTABLE.rst15
-rw-r--r--Help/prop_tgt/AUTOUIC_OPTIONS.rst9
-rw-r--r--Help/prop_tgt/BUILD_RPATH.rst5
-rw-r--r--Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst24
-rw-r--r--Help/prop_tgt/BUNDLE.rst2
-rw-r--r--Help/prop_tgt/BUNDLE_EXTENSION.rst2
-rw-r--r--Help/prop_tgt/COMMON_LANGUAGE_RUNTIME.rst22
-rw-r--r--Help/prop_tgt/COMPILE_FLAGS.rst2
-rw-r--r--Help/prop_tgt/COMPILE_OPTIONS.rst2
-rw-r--r--Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst2
-rw-r--r--Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst4
-rw-r--r--Help/prop_tgt/CUDA_RESOLVE_DEVICE_SYMBOLS.rst20
-rw-r--r--Help/prop_tgt/CUDA_SEPARABLE_COMPILATION.rst4
-rw-r--r--Help/prop_tgt/CUDA_STANDARD.rst2
-rw-r--r--Help/prop_tgt/CXX_STANDARD.rst5
-rw-r--r--Help/prop_tgt/C_STANDARD.rst3
-rw-r--r--Help/prop_tgt/DEBUG_POSTFIX.rst6
-rw-r--r--Help/prop_tgt/DEFINE_SYMBOL.rst4
-rw-r--r--Help/prop_tgt/DEPLOYMENT_ADDITIONAL_FILES.rst18
-rw-r--r--Help/prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY.rst4
-rw-r--r--Help/prop_tgt/DISABLE_PRECOMPILE_HEADERS.rst8
-rw-r--r--Help/prop_tgt/DOTNET_TARGET_FRAMEWORK_VERSION.rst13
-rw-r--r--Help/prop_tgt/ENABLE_EXPORTS.rst27
-rw-r--r--Help/prop_tgt/EXCLUDE_FROM_ALL.rst23
-rw-r--r--Help/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD.rst6
-rw-r--r--Help/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD_CONFIG.rst7
-rw-r--r--Help/prop_tgt/EXPORT_NAME.rst6
-rw-r--r--Help/prop_tgt/EXPORT_PROPERTIES.rst14
-rw-r--r--Help/prop_tgt/EchoString.rst4
-rw-r--r--Help/prop_tgt/FOLDER.rst9
-rw-r--r--Help/prop_tgt/FRAMEWORK.rst10
-rw-r--r--Help/prop_tgt/FRAMEWORK_VERSION.rst2
-rw-r--r--Help/prop_tgt/Fortran_FORMAT.rst6
-rw-r--r--Help/prop_tgt/Fortran_MODULE_DIRECTORY.rst4
-rw-r--r--Help/prop_tgt/GENERATOR_FILE_NAME.rst2
-rw-r--r--Help/prop_tgt/GHS_INTEGRITY_APP.rst10
-rw-r--r--Help/prop_tgt/GHS_NO_SOURCE_GROUP_FILE.rst13
-rw-r--r--Help/prop_tgt/GNUtoMS.rst16
-rw-r--r--Help/prop_tgt/HAS_CXX.rst4
-rw-r--r--Help/prop_tgt/IMPORTED.rst4
-rw-r--r--Help/prop_tgt/IMPORTED_COMMON_LANGUAGE_RUNTIME.rst8
-rw-r--r--Help/prop_tgt/IMPORTED_GLOBAL.rst22
-rw-r--r--Help/prop_tgt/IMPORTED_IMPLIB.rst8
-rw-r--r--Help/prop_tgt/IMPORTED_IMPLIB_CONFIG.rst2
-rw-r--r--Help/prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES.rst2
-rw-r--r--Help/prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES_CONFIG.rst2
-rw-r--r--Help/prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES.rst6
-rw-r--r--Help/prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES_CONFIG.rst2
-rw-r--r--Help/prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES.rst12
-rw-r--r--Help/prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES_CONFIG.rst6
-rw-r--r--Help/prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY.rst4
-rw-r--r--Help/prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY_CONFIG.rst2
-rw-r--r--Help/prop_tgt/IMPORTED_LOCATION.rst32
-rw-r--r--Help/prop_tgt/IMPORTED_LOCATION_CONFIG.rst2
-rw-r--r--Help/prop_tgt/IMPORTED_NO_SONAME.rst6
-rw-r--r--Help/prop_tgt/IMPORTED_NO_SONAME_CONFIG.rst2
-rw-r--r--Help/prop_tgt/IMPORTED_OBJECTS.rst2
-rw-r--r--Help/prop_tgt/IMPORTED_SONAME.rst4
-rw-r--r--Help/prop_tgt/IMPORTED_SONAME_CONFIG.rst2
-rw-r--r--Help/prop_tgt/IMPORT_PREFIX.rst6
-rw-r--r--Help/prop_tgt/IMPORT_SUFFIX.rst8
-rw-r--r--Help/prop_tgt/INCLUDE_DIRECTORIES.rst2
-rw-r--r--Help/prop_tgt/INSTALL_NAME_DIR.rst10
-rw-r--r--Help/prop_tgt/INSTALL_REMOVE_ENVIRONMENT_RPATH.rst16
-rw-r--r--Help/prop_tgt/INSTALL_RPATH.rst7
-rw-r--r--Help/prop_tgt/INSTALL_RPATH_USE_LINK_PATH.rst6
-rw-r--r--Help/prop_tgt/INTERFACE_LINK_DEPENDS.rst32
-rw-r--r--Help/prop_tgt/INTERFACE_LINK_DIRECTORIES.rst9
-rw-r--r--Help/prop_tgt/INTERFACE_LINK_LIBRARIES.rst2
-rw-r--r--Help/prop_tgt/INTERFACE_LINK_OPTIONS.rst9
-rw-r--r--Help/prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE.rst6
-rw-r--r--Help/prop_tgt/INTERFACE_PRECOMPILE_HEADERS.rst16
-rw-r--r--Help/prop_tgt/INTERPROCEDURAL_OPTIMIZATION.rst4
-rw-r--r--Help/prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG.rst2
-rw-r--r--Help/prop_tgt/LANG_CLANG_TIDY.rst2
-rw-r--r--Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst5
-rw-r--r--Help/prop_tgt/LANG_CPPCHECK.rst15
-rw-r--r--Help/prop_tgt/LANG_CPPLINT.rst2
-rw-r--r--Help/prop_tgt/LANG_INCLUDE_WHAT_YOU_USE.rst2
-rw-r--r--Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst3
-rw-r--r--Help/prop_tgt/LINKER_LANGUAGE.rst2
-rw-r--r--Help/prop_tgt/LINK_DEPENDS.rst10
-rw-r--r--Help/prop_tgt/LINK_DIRECTORIES.rst18
-rw-r--r--Help/prop_tgt/LINK_FLAGS.rst16
-rw-r--r--Help/prop_tgt/LINK_FLAGS_CONFIG.rst9
-rw-r--r--Help/prop_tgt/LINK_INTERFACE_MULTIPLICITY.rst4
-rw-r--r--Help/prop_tgt/LINK_INTERFACE_MULTIPLICITY_CONFIG.rst4
-rw-r--r--Help/prop_tgt/LINK_LIBRARIES.rst2
-rw-r--r--Help/prop_tgt/LINK_LIBRARIES_INDIRECTION.txt10
-rw-r--r--Help/prop_tgt/LINK_OPTIONS.rst24
-rw-r--r--Help/prop_tgt/LINK_SEARCH_END_STATIC.rst11
-rw-r--r--Help/prop_tgt/LINK_SEARCH_START_STATIC.rst15
-rw-r--r--Help/prop_tgt/LOCATION.rst19
-rw-r--r--Help/prop_tgt/LOCATION_CONFIG.rst14
-rw-r--r--Help/prop_tgt/MACOSX_BUNDLE.rst6
-rw-r--r--Help/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.rst4
-rw-r--r--Help/prop_tgt/MACOSX_FRAMEWORK_INFO_PLIST.rst4
-rw-r--r--Help/prop_tgt/MACOSX_RPATH.rst2
-rw-r--r--Help/prop_tgt/MSVC_RUNTIME_LIBRARY-VALUES.txt20
-rw-r--r--Help/prop_tgt/MSVC_RUNTIME_LIBRARY.rst29
-rw-r--r--Help/prop_tgt/NO_SONAME.rst6
-rw-r--r--Help/prop_tgt/NO_SYSTEM_FROM_IMPORTED.rst18
-rw-r--r--Help/prop_tgt/OBJCXX_EXTENSIONS.rst20
-rw-r--r--Help/prop_tgt/OBJCXX_STANDARD.rst35
-rw-r--r--Help/prop_tgt/OBJCXX_STANDARD_REQUIRED.rst20
-rw-r--r--Help/prop_tgt/OBJC_EXTENSIONS.rst20
-rw-r--r--Help/prop_tgt/OBJC_STANDARD.rst35
-rw-r--r--Help/prop_tgt/OBJC_STANDARD_REQUIRED.rst20
-rw-r--r--Help/prop_tgt/OSX_ARCHITECTURES.rst4
-rw-r--r--Help/prop_tgt/OSX_ARCHITECTURES_CONFIG.rst2
-rw-r--r--Help/prop_tgt/OUTPUT_NAME.rst3
-rw-r--r--Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst10
-rw-r--r--Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst6
-rw-r--r--Help/prop_tgt/POSITION_INDEPENDENT_CODE.rst5
-rw-r--r--Help/prop_tgt/POST_INSTALL_SCRIPT.rst8
-rw-r--r--Help/prop_tgt/PRECOMPILE_HEADERS.rst12
-rw-r--r--Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst7
-rw-r--r--Help/prop_tgt/PREFIX.rst2
-rw-r--r--Help/prop_tgt/PRE_INSTALL_SCRIPT.rst8
-rw-r--r--Help/prop_tgt/PRIVATE_HEADER.rst4
-rw-r--r--Help/prop_tgt/PUBLIC_HEADER.rst4
-rw-r--r--Help/prop_tgt/RESOURCE.rst19
-rw-r--r--Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst3
-rw-r--r--Help/prop_tgt/SKIP_BUILD_RPATH.rst4
-rw-r--r--Help/prop_tgt/SOVERSION.rst2
-rw-r--r--Help/prop_tgt/STATIC_LIBRARY_FLAGS.rst15
-rw-r--r--Help/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG.rst10
-rw-r--r--Help/prop_tgt/STATIC_LIBRARY_OPTIONS.rst20
-rw-r--r--Help/prop_tgt/SUFFIX.rst2
-rw-r--r--Help/prop_tgt/Swift_DEPENDENCIES_FILE.rst5
-rw-r--r--Help/prop_tgt/Swift_LANGUAGE_VERSION.rst6
-rw-r--r--Help/prop_tgt/Swift_MODULE_DIRECTORY.rst10
-rw-r--r--Help/prop_tgt/Swift_MODULE_NAME.rst5
-rw-r--r--Help/prop_tgt/TYPE.rst6
-rw-r--r--Help/prop_tgt/UNITY_BUILD.rst60
-rw-r--r--Help/prop_tgt/UNITY_BUILD_BATCH_SIZE.rst23
-rw-r--r--Help/prop_tgt/UNITY_BUILD_CODE_AFTER_INCLUDE.rst19
-rw-r--r--Help/prop_tgt/UNITY_BUILD_CODE_BEFORE_INCLUDE.rst19
-rw-r--r--Help/prop_tgt/VERSION.rst2
-rw-r--r--Help/prop_tgt/VS_CONFIGURATION_TYPE.rst2
-rw-r--r--Help/prop_tgt/VS_DEBUGGER_COMMAND.rst11
-rw-r--r--Help/prop_tgt/VS_DEBUGGER_COMMAND_ARGUMENTS.rst11
-rw-r--r--Help/prop_tgt/VS_DEBUGGER_ENVIRONMENT.rst11
-rw-r--r--Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst5
-rw-r--r--Help/prop_tgt/VS_DOTNET_REFERENCEPROP_refname_TAG_tagname.rst14
-rw-r--r--Help/prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION.rst3
-rw-r--r--Help/prop_tgt/VS_DPI_AWARE.rst14
-rw-r--r--Help/prop_tgt/VS_JUST_MY_CODE_DEBUGGING.rst10
-rw-r--r--Help/prop_tgt/VS_NO_SOLUTION_DEPLOY.rst46
-rw-r--r--Help/prop_tgt/VS_PACKAGE_REFERENCES.rst13
-rw-r--r--Help/prop_tgt/VS_PROJECT_IMPORT.rst8
-rw-r--r--Help/prop_tgt/VS_SDK_REFERENCES.rst2
-rw-r--r--Help/prop_tgt/WIN32_EXECUTABLE.rst11
-rw-r--r--Help/prop_tgt/XCODE_ATTRIBUTE_an-attribute.rst4
-rw-r--r--Help/prop_tgt/XCODE_GENERATE_SCHEME.rst40
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_ADDRESS_SANITIZER.rst12
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN.rst12
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_ARGUMENTS.rst10
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_DEBUG_AS_ROOT.rst7
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING.rst13
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER.rst12
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS.rst12
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE.rst12
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_ENVIRONMENT.rst12
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_EXECUTABLE.rst9
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_GUARD_MALLOC.rst12
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP.rst13
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_MALLOC_GUARD_EDGES.rst12
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_MALLOC_SCRIBBLE.rst12
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_MALLOC_STACK.rst12
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_THREAD_SANITIZER.rst12
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_THREAD_SANITIZER_STOP.rst12
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER.rst12
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP.rst13
-rw-r--r--Help/prop_tgt/XCODE_SCHEME_ZOMBIE_OBJECTS.rst12
-rw-r--r--Help/release/3.0.rst2
-rw-r--r--Help/release/3.1.rst6
-rw-r--r--Help/release/3.10.rst282
-rw-r--r--Help/release/3.11.rst307
-rw-r--r--Help/release/3.12.rst305
-rw-r--r--Help/release/3.13.rst289
-rw-r--r--Help/release/3.14.rst438
-rw-r--r--Help/release/3.15.rst387
-rw-r--r--Help/release/3.16.rst279
-rw-r--r--Help/release/3.2.rst10
-rw-r--r--Help/release/3.3.rst14
-rw-r--r--Help/release/3.4.rst12
-rw-r--r--Help/release/3.5.rst22
-rw-r--r--Help/release/3.6.rst64
-rw-r--r--Help/release/3.7.rst23
-rw-r--r--Help/release/3.8.rst22
-rw-r--r--Help/release/3.9.rst23
-rw-r--r--Help/release/index.rst7
-rw-r--r--Help/variable/APPLE.rst5
-rw-r--r--Help/variable/CACHE.rst18
-rw-r--r--Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION.rst6
-rw-r--r--Help/variable/CMAKE_ANDROID_STL_TYPE.rst3
-rw-r--r--Help/variable/CMAKE_APPBUNDLE_PATH.rst4
-rw-r--r--Help/variable/CMAKE_ARGC.rst6
-rw-r--r--Help/variable/CMAKE_ARGV0.rst4
-rw-r--r--Help/variable/CMAKE_AUTOGEN_ORIGIN_DEPENDS.rst11
-rw-r--r--Help/variable/CMAKE_AUTOGEN_PARALLEL.rst10
-rw-r--r--Help/variable/CMAKE_AUTOGEN_VERBOSE.rst13
-rw-r--r--Help/variable/CMAKE_AUTOMOC_COMPILER_PREDEFINES.rst8
-rw-r--r--Help/variable/CMAKE_AUTOMOC_MACRO_NAMES.rst20
-rw-r--r--Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst11
-rw-r--r--Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst2
-rw-r--r--Help/variable/CMAKE_AUTORCC_OPTIONS.rst11
-rw-r--r--Help/variable/CMAKE_AUTOUIC_OPTIONS.rst11
-rw-r--r--Help/variable/CMAKE_BUILD_RPATH.rst2
-rw-r--r--Help/variable/CMAKE_BUILD_RPATH_USE_ORIGIN.rst7
-rw-r--r--Help/variable/CMAKE_BUILD_TYPE.rst4
-rw-r--r--Help/variable/CMAKE_CFG_INTDIR.rst2
-rw-r--r--Help/variable/CMAKE_CODEBLOCKS_COMPILER_ID.rst13
-rw-r--r--Help/variable/CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES.rst7
-rw-r--r--Help/variable/CMAKE_CPACK_COMMAND.rst8
-rw-r--r--Help/variable/CMAKE_CROSSCOMPILING.rst27
-rw-r--r--Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst6
-rw-r--r--Help/variable/CMAKE_CUDA_HOST_COMPILER.rst8
-rw-r--r--Help/variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst6
-rw-r--r--Help/variable/CMAKE_CUDA_SEPARABLE_COMPILATION.rst6
-rw-r--r--Help/variable/CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES.rst2
-rw-r--r--Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst23
-rw-r--r--Help/variable/CMAKE_DIRECTORY_LABELS.rst6
-rw-r--r--Help/variable/CMAKE_DISABLE_PRECOMPILE_HEADERS.rst6
-rw-r--r--Help/variable/CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION.rst16
-rw-r--r--Help/variable/CMAKE_ECLIPSE_RESOURCE_ENCODING.rst6
-rw-r--r--Help/variable/CMAKE_ENABLE_EXPORTS.rst22
-rw-r--r--Help/variable/CMAKE_EXECUTE_PROCESS_COMMAND_ECHO.rst6
-rw-r--r--Help/variable/CMAKE_EXPORT_COMPILE_COMMANDS.rst4
-rw-r--r--Help/variable/CMAKE_EXPORT_NO_PACKAGE_REGISTRY.rst9
-rw-r--r--Help/variable/CMAKE_EXPORT_PACKAGE_REGISTRY.rst15
-rw-r--r--Help/variable/CMAKE_EXTRA_GENERATOR.rst2
-rw-r--r--Help/variable/CMAKE_FIND_APPBUNDLE.rst4
-rw-r--r--Help/variable/CMAKE_FIND_FRAMEWORK.rst4
-rw-r--r--Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst24
-rw-r--r--Help/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY.rst15
-rw-r--r--Help/variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY.rst15
-rw-r--r--Help/variable/CMAKE_FIND_PACKAGE_PREFER_CONFIG.rst27
-rw-r--r--Help/variable/CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS.rst10
-rw-r--r--Help/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst3
-rw-r--r--Help/variable/CMAKE_FIND_ROOT_PATH.rst2
-rw-r--r--Help/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH.rst24
-rw-r--r--Help/variable/CMAKE_FIND_USE_CMAKE_PATH.rst24
-rw-r--r--Help/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.rst24
-rw-r--r--Help/variable/CMAKE_FIND_USE_PACKAGE_REGISTRY.rst30
-rw-r--r--Help/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH.rst22
-rw-r--r--Help/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH.rst24
-rw-r--r--Help/variable/CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY.rst31
-rw-r--r--Help/variable/CMAKE_FOLDER.rst7
-rw-r--r--Help/variable/CMAKE_FRAMEWORK.rst7
-rw-r--r--Help/variable/CMAKE_FRAMEWORK_PATH.rst4
-rw-r--r--Help/variable/CMAKE_GENERATOR.rst5
-rw-r--r--Help/variable/CMAKE_GENERATOR_INSTANCE.rst25
-rw-r--r--Help/variable/CMAKE_GENERATOR_PLATFORM.rst5
-rw-r--r--Help/variable/CMAKE_GENERATOR_TOOLSET.rst24
-rw-r--r--Help/variable/CMAKE_GHS_NO_SOURCE_GROUP_FILE.rst6
-rw-r--r--Help/variable/CMAKE_GLOBAL_AUTOGEN_TARGET.rst26
-rw-r--r--Help/variable/CMAKE_GLOBAL_AUTOGEN_TARGET_NAME.rst13
-rw-r--r--Help/variable/CMAKE_GLOBAL_AUTORCC_TARGET.rst18
-rw-r--r--Help/variable/CMAKE_GLOBAL_AUTORCC_TARGET_NAME.rst13
-rw-r--r--Help/variable/CMAKE_HOME_DIRECTORY.rst7
-rw-r--r--Help/variable/CMAKE_HOST_APPLE.rst4
-rw-r--r--Help/variable/CMAKE_HOST_SYSTEM.rst2
-rw-r--r--Help/variable/CMAKE_HOST_SYSTEM_NAME.rst2
-rw-r--r--Help/variable/CMAKE_IGNORE_PATH.rst2
-rw-r--r--Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst2
-rw-r--r--Help/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst2
-rw-r--r--Help/variable/CMAKE_INCLUDE_PATH.rst2
-rw-r--r--Help/variable/CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS.rst29
-rw-r--r--Help/variable/CMAKE_INSTALL_NAME_DIR.rst2
-rw-r--r--Help/variable/CMAKE_INSTALL_PREFIX.rst16
-rw-r--r--Help/variable/CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH.rst9
-rw-r--r--Help/variable/CMAKE_JOB_POOLS.rst6
-rw-r--r--Help/variable/CMAKE_JOB_POOL_LINK.rst2
-rw-r--r--Help/variable/CMAKE_LANG_CLANG_TIDY.rst11
-rw-r--r--Help/variable/CMAKE_LANG_COMPILER_ARCHITECTURE_ID.rst8
-rw-r--r--Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst2
-rw-r--r--Help/variable/CMAKE_LANG_COMPILER_ID.rst6
-rw-r--r--Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst3
-rw-r--r--Help/variable/CMAKE_LANG_COMPILER_PREDEFINES_COMMAND.rst8
-rw-r--r--Help/variable/CMAKE_LANG_COMPILER_VERSION_INTERNAL.rst8
-rw-r--r--Help/variable/CMAKE_LANG_CPPCHECK.rst6
-rw-r--r--Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst3
-rw-r--r--Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst3
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS.rst11
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst4
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_CONFIG_INIT.rst10
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst5
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_DEBUG_INIT.rst9
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_INIT.rst8
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst6
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL_INIT.rst9
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst5
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_RELEASE_INIT.rst9
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst6
-rw-r--r--Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO_INIT.rst9
-rw-r--r--Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst6
-rw-r--r--Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst7
-rw-r--r--Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst6
-rw-r--r--Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst7
-rw-r--r--Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst7
-rw-r--r--Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst15
-rw-r--r--Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst39
-rw-r--r--Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG_SEP.rst9
-rw-r--r--Help/variable/CMAKE_LANG_LINK_LIBRARY_FILE_FLAG.rst8
-rw-r--r--Help/variable/CMAKE_LANG_LINK_LIBRARY_FLAG.rst7
-rw-r--r--Help/variable/CMAKE_LANG_LINK_LIBRARY_SUFFIX.rst6
-rw-r--r--Help/variable/CMAKE_LIBRARY_PATH.rst2
-rw-r--r--Help/variable/CMAKE_LINK_DIRECTORIES_BEFORE.rst9
-rw-r--r--Help/variable/CMAKE_MACOSX_BUNDLE.rst3
-rw-r--r--Help/variable/CMAKE_MACOSX_RPATH.rst2
-rw-r--r--Help/variable/CMAKE_MAKE_PROGRAM.rst17
-rw-r--r--Help/variable/CMAKE_MAXIMUM_RECURSION_DEPTH.rst33
-rw-r--r--Help/variable/CMAKE_MESSAGE_INDENT.rst32
-rw-r--r--Help/variable/CMAKE_MFC_FLAG.rst15
-rw-r--r--Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst6
-rw-r--r--Help/variable/CMAKE_MODULE_PATH.rst4
-rw-r--r--Help/variable/CMAKE_MSVCIDE_RUN_PATH.rst10
-rw-r--r--Help/variable/CMAKE_MSVC_RUNTIME_LIBRARY.rst32
-rw-r--r--Help/variable/CMAKE_NETRC.rst9
-rw-r--r--Help/variable/CMAKE_NETRC_FILE.rst9
-rw-r--r--Help/variable/CMAKE_OBJCXX_EXTENSIONS.rst11
-rw-r--r--Help/variable/CMAKE_OBJCXX_STANDARD.rst11
-rw-r--r--Help/variable/CMAKE_OBJCXX_STANDARD_REQUIRED.rst11
-rw-r--r--Help/variable/CMAKE_OBJC_EXTENSIONS.rst11
-rw-r--r--Help/variable/CMAKE_OBJC_STANDARD.rst11
-rw-r--r--Help/variable/CMAKE_OBJC_STANDARD_REQUIRED.rst11
-rw-r--r--Help/variable/CMAKE_OSX_ARCHITECTURES.rst4
-rw-r--r--Help/variable/CMAKE_OSX_DEPLOYMENT_TARGET.rst10
-rw-r--r--Help/variable/CMAKE_OSX_SYSROOT.rst2
-rw-r--r--Help/variable/CMAKE_OSX_VARIABLE.txt7
-rw-r--r--Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst4
-rw-r--r--Help/variable/CMAKE_PREFIX_PATH.rst2
-rw-r--r--Help/variable/CMAKE_PROGRAM_PATH.rst2
-rw-r--r--Help/variable/CMAKE_PROJECT_DESCRIPTION.rst34
-rw-r--r--Help/variable/CMAKE_PROJECT_HOMEPAGE_URL.rst35
-rw-r--r--Help/variable/CMAKE_PROJECT_INCLUDE.rst9
-rw-r--r--Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst9
-rw-r--r--Help/variable/CMAKE_PROJECT_NAME.rst34
-rw-r--r--Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst10
-rw-r--r--Help/variable/CMAKE_PROJECT_VERSION.rst35
-rw-r--r--Help/variable/CMAKE_PROJECT_VERSION_MAJOR.rst9
-rw-r--r--Help/variable/CMAKE_PROJECT_VERSION_MINOR.rst9
-rw-r--r--Help/variable/CMAKE_PROJECT_VERSION_PATCH.rst9
-rw-r--r--Help/variable/CMAKE_PROJECT_VERSION_TWEAK.rst9
-rw-r--r--Help/variable/CMAKE_RULE_MESSAGES.rst8
-rw-r--r--Help/variable/CMAKE_SKIP_INSTALL_RULES.rst2
-rw-r--r--Help/variable/CMAKE_SOURCE_DIR.rst2
-rw-r--r--Help/variable/CMAKE_STAGING_PREFIX.rst10
-rw-r--r--Help/variable/CMAKE_STATIC_LINKER_FLAGS.rst10
-rw-r--r--Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst12
-rw-r--r--Help/variable/CMAKE_SUPPRESS_REGENERATION.rst11
-rw-r--r--Help/variable/CMAKE_SYSROOT.rst4
-rw-r--r--Help/variable/CMAKE_SYSTEM_APPBUNDLE_PATH.rst2
-rw-r--r--Help/variable/CMAKE_SYSTEM_FRAMEWORK_PATH.rst2
-rw-r--r--Help/variable/CMAKE_SYSTEM_IGNORE_PATH.rst2
-rw-r--r--Help/variable/CMAKE_SYSTEM_INCLUDE_PATH.rst2
-rw-r--r--Help/variable/CMAKE_SYSTEM_LIBRARY_PATH.rst2
-rw-r--r--Help/variable/CMAKE_SYSTEM_NAME.rst3
-rw-r--r--Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst9
-rw-r--r--Help/variable/CMAKE_SYSTEM_PROCESSOR.rst2
-rw-r--r--Help/variable/CMAKE_SYSTEM_PROGRAM_PATH.rst2
-rw-r--r--Help/variable/CMAKE_Swift_LANGUAGE_VERSION.rst8
-rw-r--r--Help/variable/CMAKE_Swift_MODULE_DIRECTORY.rst8
-rw-r--r--Help/variable/CMAKE_Swift_NUM_THREADS.rst8
-rw-r--r--Help/variable/CMAKE_UNITY_BUILD.rst20
-rw-r--r--Help/variable/CMAKE_UNITY_BUILD_BATCH_SIZE.rst7
-rw-r--r--Help/variable/CMAKE_VS_DEVENV_COMMAND.rst2
-rw-r--r--Help/variable/CMAKE_VS_GLOBALS.rst21
-rw-r--r--Help/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst2
-rw-r--r--Help/variable/CMAKE_VS_JUST_MY_CODE_DEBUGGING.rst8
-rw-r--r--Help/variable/CMAKE_VS_PLATFORM_NAME.rst4
-rw-r--r--Help/variable/CMAKE_VS_PLATFORM_NAME_DEFAULT.rst9
-rw-r--r--Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA.rst6
-rw-r--r--Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst16
-rw-r--r--Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst10
-rw-r--r--Help/variable/CMAKE_VS_PLATFORM_TOOLSET_VERSION.rst11
-rw-r--r--Help/variable/CMAKE_VS_SDK_EXCLUDE_DIRECTORIES.rst4
-rw-r--r--Help/variable/CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES.rst4
-rw-r--r--Help/variable/CMAKE_VS_SDK_INCLUDE_DIRECTORIES.rst4
-rw-r--r--Help/variable/CMAKE_VS_SDK_LIBRARY_DIRECTORIES.rst4
-rw-r--r--Help/variable/CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES.rst5
-rw-r--r--Help/variable/CMAKE_VS_SDK_REFERENCE_DIRECTORIES.rst4
-rw-r--r--Help/variable/CMAKE_VS_SDK_SOURCE_DIRECTORIES.rst4
-rw-r--r--Help/variable/CMAKE_VS_WINRT_BY_DEFAULT.rst8
-rw-r--r--Help/variable/CMAKE_XCODE_GENERATE_SCHEME.rst9
-rw-r--r--Help/variable/CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY.rst9
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER.rst12
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN.rst12
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING.rst13
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER.rst12
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS.rst12
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE.rst12
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_GUARD_MALLOC.rst12
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP.rst13
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_MALLOC_GUARD_EDGES.rst12
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_MALLOC_SCRIBBLE.rst12
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_MALLOC_STACK.rst12
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_THREAD_SANITIZER.rst12
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_THREAD_SANITIZER_STOP.rst12
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER.rst12
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP.rst13
-rw-r--r--Help/variable/CMAKE_XCODE_SCHEME_ZOMBIE_OBJECTS.rst12
-rw-r--r--Help/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst2
-rw-r--r--Help/variable/CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS.rst11
-rw-r--r--Help/variable/CPACK_INSTALL_SCRIPT.rst8
-rw-r--r--Help/variable/CTEST_CUSTOM_TESTS_IGNORE.rst7
-rw-r--r--Help/variable/CTEST_CUSTOM_TEST_IGNORE.rst7
-rw-r--r--Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst2
-rw-r--r--Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst2
-rw-r--r--Help/variable/CTEST_LABELS_FOR_SUBPROJECTS.rst5
-rw-r--r--Help/variable/CTEST_RUN_CURRENT_SCRIPT.rst5
-rw-r--r--Help/variable/CTEST_SCP_COMMAND.rst3
-rw-r--r--Help/variable/CTEST_SUBMIT_URL.rst5
-rw-r--r--Help/variable/CTEST_TRIGGER_SITE.rst3
-rw-r--r--Help/variable/CTEST_UPDATE_VERSION_ONLY.rst2
-rw-r--r--Help/variable/CTEST_UPDATE_VERSION_OVERRIDE.rst5
-rw-r--r--Help/variable/ENV.rst11
-rw-r--r--Help/variable/GHS-MULTI.rst2
-rw-r--r--Help/variable/IOS.rst4
-rw-r--r--Help/variable/LIBRARY_OUTPUT_PATH.rst2
-rw-r--r--Help/variable/MSVC.rst6
-rw-r--r--Help/variable/MSVC_TOOLSET_VERSION.rst22
-rw-r--r--Help/variable/MSVC_VERSION.rst27
-rw-r--r--Help/variable/MSYS.rst4
-rw-r--r--Help/variable/PROJECT-NAME_DESCRIPTION.rst5
-rw-r--r--Help/variable/PROJECT-NAME_HOMEPAGE_URL.rst5
-rw-r--r--Help/variable/PROJECT_DESCRIPTION.rst5
-rw-r--r--Help/variable/PROJECT_HOMEPAGE_URL.rst9
-rw-r--r--Help/variable/PROJECT_NAME.rst4
-rw-r--r--Help/variable/PackageName_ROOT.rst14
-rw-r--r--Help/variable/UNIX.rst8
-rw-r--r--Help/variable/WIN32.rst4
-rw-r--r--Help/variable/XCODE_VERSION.rst4
-rw-r--r--Modules/AddFileDependencies.cmake33
-rw-r--r--Modules/AndroidTestUtilities.cmake2
-rw-r--r--Modules/AndroidTestUtilities/PushToAndroidDevice.cmake2
-rw-r--r--Modules/AutogenInfo.cmake.in33
-rw-r--r--Modules/BasicConfigVersion-AnyNewerVersion.cmake.in14
-rw-r--r--Modules/BasicConfigVersion-ExactVersion.cmake.in7
-rw-r--r--Modules/BasicConfigVersion-SameMajorVersion.cmake.in7
-rw-r--r--Modules/BasicConfigVersion-SameMinorVersion.cmake.in55
-rw-r--r--Modules/BundleUtilities.cmake535
-rw-r--r--Modules/CMakeASMCompiler.cmake.in4
-rw-r--r--Modules/CMakeASMInformation.cmake41
-rw-r--r--Modules/CMakeASM_MASMInformation.cmake6
-rw-r--r--Modules/CMakeASM_NASMInformation.cmake4
-rw-r--r--Modules/CMakeAddFortranSubdirectory.cmake81
-rw-r--r--Modules/CMakeAddNewLanguage.txt22
-rw-r--r--Modules/CMakeBackwardCompatibilityC.cmake4
-rw-r--r--Modules/CMakeBackwardCompatibilityCXX.cmake32
-rw-r--r--Modules/CMakeCCompiler.cmake.in7
-rw-r--r--Modules/CMakeCCompilerABI.c4
-rw-r--r--Modules/CMakeCCompilerId.c.in6
-rw-r--r--Modules/CMakeCInformation.cmake40
-rw-r--r--Modules/CMakeCSharpCompiler.cmake.in1
-rw-r--r--Modules/CMakeCSharpInformation.cmake60
-rw-r--r--Modules/CMakeCUDACompiler.cmake.in5
-rw-r--r--Modules/CMakeCUDACompilerABI.cu2
-rw-r--r--Modules/CMakeCUDACompilerId.cu.in4
-rw-r--r--Modules/CMakeCUDAInformation.cmake53
-rw-r--r--Modules/CMakeCXXCompiler.cmake.in19
-rw-r--r--Modules/CMakeCXXCompilerABI.cpp2
-rw-r--r--Modules/CMakeCXXCompilerId.cpp.in27
-rw-r--r--Modules/CMakeCXXInformation.cmake44
-rw-r--r--Modules/CMakeCheckCompilerFlagCommonPatterns.cmake49
-rw-r--r--Modules/CMakeCommonLanguageInclude.cmake114
-rw-r--r--Modules/CMakeCompilerABI.h21
-rw-r--r--Modules/CMakeCompilerIdDetection.cmake12
-rw-r--r--Modules/CMakeDependentOption.cmake44
-rw-r--r--Modules/CMakeDetermineASMCompiler.cmake106
-rw-r--r--Modules/CMakeDetermineASM_MASMCompiler.cmake6
-rw-r--r--Modules/CMakeDetermineCCompiler.cmake44
-rw-r--r--Modules/CMakeDetermineCSharpCompiler.cmake7
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake41
-rw-r--r--Modules/CMakeDetermineCXXCompiler.cmake47
-rw-r--r--Modules/CMakeDetermineCompileFeatures.cmake6
-rw-r--r--Modules/CMakeDetermineCompilerABI.cmake47
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake296
-rw-r--r--Modules/CMakeDetermineFortranCompiler.cmake33
-rw-r--r--Modules/CMakeDetermineOBJCCompiler.cmake189
-rw-r--r--Modules/CMakeDetermineOBJCXXCompiler.cmake197
-rw-r--r--Modules/CMakeDetermineSwiftCompiler.cmake51
-rw-r--r--Modules/CMakeDetermineSystem.cmake3
-rw-r--r--Modules/CMakeDetermineVSServicePack.cmake116
-rw-r--r--Modules/CMakeExpandImportedTargets.cmake260
-rw-r--r--Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake7
-rw-r--r--Modules/CMakeFindBinUtils.cmake114
-rw-r--r--Modules/CMakeFindCodeBlocks.cmake5
-rw-r--r--Modules/CMakeFindDependencyMacro.cmake102
-rw-r--r--Modules/CMakeFindFrameworks.cmake19
-rw-r--r--Modules/CMakeFindKDevelop3.cmake13
-rw-r--r--Modules/CMakeFindPackageMode.cmake57
-rw-r--r--Modules/CMakeFindSublimeText2.cmake23
-rw-r--r--Modules/CMakeForceCompiler.cmake132
-rw-r--r--Modules/CMakeFortranCompiler.cmake.in4
-rw-r--r--Modules/CMakeFortranCompilerABI.F8
-rw-r--r--Modules/CMakeFortranCompilerId.F.in71
-rw-r--r--Modules/CMakeFortranInformation.cmake45
-rw-r--r--Modules/CMakeGenericSystem.cmake9
-rw-r--r--Modules/CMakeGraphVizOptions.cmake236
-rw-r--r--Modules/CMakeIOSInstallCombined.cmake9
-rw-r--r--Modules/CMakeInitializeConfigs.cmake39
-rw-r--r--Modules/CMakeJavaInformation.cmake6
-rw-r--r--Modules/CMakeLanguageInformation.cmake4
-rw-r--r--Modules/CMakeNinjaFindMake.cmake2
-rw-r--r--Modules/CMakeOBJCCompiler.cmake.in69
-rw-r--r--Modules/CMakeOBJCCompilerABI.m20
-rw-r--r--Modules/CMakeOBJCCompilerId.m.in63
-rw-r--r--Modules/CMakeOBJCInformation.cmake188
-rw-r--r--Modules/CMakeOBJCXXCompiler.cmake.in79
-rw-r--r--Modules/CMakeOBJCXXCompilerABI.mm20
-rw-r--r--Modules/CMakeOBJCXXCompilerId.mm.in68
-rw-r--r--Modules/CMakeOBJCXXInformation.cmake273
-rw-r--r--Modules/CMakePackageConfigHelpers.cmake416
-rw-r--r--Modules/CMakeParseArguments.cmake17
-rw-r--r--Modules/CMakeParseImplicitIncludeInfo.cmake247
-rw-r--r--Modules/CMakeParseImplicitLinkInfo.cmake19
-rw-r--r--Modules/CMakePlatformId.h.in74
-rw-r--r--Modules/CMakePrintHelpers.cmake98
-rw-r--r--Modules/CMakePrintSystemInformation.cmake17
-rw-r--r--Modules/CMakePushCheckState.cmake129
-rw-r--r--Modules/CMakeRCInformation.cmake38
-rw-r--r--Modules/CMakeSwiftCompiler.cmake.in9
-rw-r--r--Modules/CMakeSwiftInformation.cmake98
-rw-r--r--Modules/CMakeSystemSpecificInformation.cmake9
-rw-r--r--Modules/CMakeSystemSpecificInitialize.cmake13
-rw-r--r--Modules/CMakeTestCCompiler.cmake15
-rw-r--r--Modules/CMakeTestCSharpCompiler.cmake7
-rw-r--r--Modules/CMakeTestCUDACompiler.cmake7
-rw-r--r--Modules/CMakeTestCXXCompiler.cmake17
-rw-r--r--Modules/CMakeTestCompilerCommon.cmake20
-rw-r--r--Modules/CMakeTestFortranCompiler.cmake7
-rw-r--r--Modules/CMakeTestJavaCompiler.cmake2
-rw-r--r--Modules/CMakeTestOBJCCompiler.cmake94
-rw-r--r--Modules/CMakeTestOBJCXXCompiler.cmake93
-rw-r--r--Modules/CMakeTestRCCompiler.cmake2
-rw-r--r--Modules/CMakeTestSwiftCompiler.cmake14
-rw-r--r--Modules/CMakeVerifyManifest.cmake33
-rwxr-xr-xModules/CPack.STGZ_Header.sh.in144
-rw-r--r--Modules/CPack.background.png.inbin47076 -> 0 bytes
-rw-r--r--Modules/CPack.cmake733
-rw-r--r--Modules/CPackArchive.cmake39
-rw-r--r--Modules/CPackBundle.cmake70
-rw-r--r--Modules/CPackComponent.cmake605
-rw-r--r--Modules/CPackCygwin.cmake27
-rw-r--r--Modules/CPackDMG.cmake105
-rw-r--r--Modules/CPackDeb.cmake1049
-rw-r--r--Modules/CPackIFW.cmake971
-rw-r--r--Modules/CPackIFWConfigureFile.cmake53
-rw-r--r--Modules/CPackNSIS.cmake138
-rw-r--r--Modules/CPackPackageMaker.cmake27
-rw-r--r--Modules/CPackProductBuild.cmake56
-rw-r--r--Modules/CPackRPM.cmake2745
-rw-r--r--Modules/CPackWIX.cmake307
-rw-r--r--Modules/CPackZIP.cmake31
-rw-r--r--Modules/CSharpUtilities.cmake5
-rw-r--r--Modules/CTest.cmake26
-rw-r--r--Modules/CTestCoverageCollectGCOV.cmake165
-rw-r--r--Modules/CTestScriptMode.cmake15
-rw-r--r--Modules/CTestTargets.cmake5
-rw-r--r--Modules/CTestUseLaunchers.cmake53
-rw-r--r--Modules/CheckCCompilerFlag.cmake93
-rw-r--r--Modules/CheckCSourceCompiles.cmake98
-rw-r--r--Modules/CheckCSourceRuns.cmake108
-rw-r--r--Modules/CheckCXXCompilerFlag.cmake97
-rw-r--r--Modules/CheckCXXSourceCompiles.cmake98
-rw-r--r--Modules/CheckCXXSourceRuns.cmake104
-rw-r--r--Modules/CheckCXXSymbolExists.cmake99
-rw-r--r--Modules/CheckForPthreads.c40
-rw-r--r--Modules/CheckFortranCompilerFlag.cmake52
-rw-r--r--Modules/CheckFortranFunctionExists.cmake63
-rw-r--r--Modules/CheckFortranSourceCompiles.cmake120
-rw-r--r--Modules/CheckFortranSourceRuns.cmake175
-rw-r--r--Modules/CheckFunctionExists.c12
-rw-r--r--Modules/CheckFunctionExists.cmake93
-rw-r--r--Modules/CheckIPOSupported.cmake21
-rw-r--r--Modules/CheckIncludeFile.cmake105
-rw-r--r--Modules/CheckIncludeFileCXX.cmake103
-rw-r--r--Modules/CheckIncludeFiles.cmake139
-rw-r--r--Modules/CheckLanguage.cmake92
-rw-r--r--Modules/CheckLibraryExists.cmake68
-rw-r--r--Modules/CheckOBJCCompilerFlag.cmake64
-rw-r--r--Modules/CheckOBJCSourceCompiles.cmake145
-rw-r--r--Modules/CheckOBJCSourceRuns.cmake145
-rw-r--r--Modules/CheckOBJCXXCompilerFlag.cmake64
-rw-r--r--Modules/CheckOBJCXXSourceCompiles.cmake146
-rw-r--r--Modules/CheckOBJCXXSourceRuns.cmake145
-rw-r--r--Modules/CheckPIESupported.cmake134
-rw-r--r--Modules/CheckPrototypeDefinition.cmake91
-rw-r--r--Modules/CheckStructHasMember.cmake126
-rw-r--r--Modules/CheckSymbolExists.cmake72
-rw-r--r--Modules/CheckTypeSize.c.in8
-rw-r--r--Modules/CheckTypeSize.cmake143
-rw-r--r--Modules/CheckVariableExists.c8
-rw-r--r--Modules/CheckVariableExists.cmake72
-rw-r--r--Modules/Compiler/ARMCC-ASM.cmake2
-rw-r--r--Modules/Compiler/ARMCC-DetermineCompiler.cmake2
-rw-r--r--Modules/Compiler/ARMCC.cmake2
-rw-r--r--Modules/Compiler/ARMClang-ASM.cmake9
-rw-r--r--Modules/Compiler/ARMClang-C-FeatureTests.cmake1
-rw-r--r--Modules/Compiler/ARMClang-C.cmake15
-rw-r--r--Modules/Compiler/ARMClang-CXX-FeatureTests.cmake1
-rw-r--r--Modules/Compiler/ARMClang-CXX.cmake3
-rw-r--r--Modules/Compiler/ARMClang-DetermineCompiler.cmake10
-rw-r--r--Modules/Compiler/ARMClang.cmake71
-rw-r--r--Modules/Compiler/Absoft-Fortran.cmake1
-rw-r--r--Modules/Compiler/AppleClang-C.cmake3
-rw-r--r--Modules/Compiler/AppleClang-CXX.cmake12
-rw-r--r--Modules/Compiler/AppleClang-OBJC.cmake17
-rw-r--r--Modules/Compiler/AppleClang-OBJCXX.cmake39
-rw-r--r--Modules/Compiler/Bruce-C.cmake2
-rw-r--r--Modules/Compiler/CMakeCommonCompilerMacros.cmake57
-rw-r--r--Modules/Compiler/Clang-C.cmake38
-rw-r--r--Modules/Compiler/Clang-CXX.cmake139
-rw-r--r--Modules/Compiler/Clang-OBJC.cmake18
-rw-r--r--Modules/Compiler/Clang-OBJCXX.cmake70
-rw-r--r--Modules/Compiler/Clang.cmake32
-rw-r--r--Modules/Compiler/Cray-C.cmake6
-rw-r--r--Modules/Compiler/Cray-CXX.cmake10
-rw-r--r--Modules/Compiler/Cray-Fortran.cmake9
-rw-r--r--Modules/Compiler/Cray.cmake7
-rw-r--r--Modules/Compiler/CrayPrgEnv-C.cmake6
-rw-r--r--Modules/Compiler/CrayPrgEnv-CXX.cmake6
-rw-r--r--Modules/Compiler/CrayPrgEnv-Cray-C.cmake7
-rw-r--r--Modules/Compiler/CrayPrgEnv-Cray-CXX.cmake7
-rw-r--r--Modules/Compiler/CrayPrgEnv-Cray-Fortran.cmake7
-rw-r--r--Modules/Compiler/CrayPrgEnv-Fortran.cmake6
-rw-r--r--Modules/Compiler/CrayPrgEnv-GNU-C.cmake7
-rw-r--r--Modules/Compiler/CrayPrgEnv-GNU-CXX.cmake7
-rw-r--r--Modules/Compiler/CrayPrgEnv-GNU-Fortran.cmake7
-rw-r--r--Modules/Compiler/CrayPrgEnv-Intel-C.cmake7
-rw-r--r--Modules/Compiler/CrayPrgEnv-Intel-CXX.cmake7
-rw-r--r--Modules/Compiler/CrayPrgEnv-Intel-Fortran.cmake7
-rw-r--r--Modules/Compiler/CrayPrgEnv-PGI-C.cmake7
-rw-r--r--Modules/Compiler/CrayPrgEnv-PGI-CXX.cmake7
-rw-r--r--Modules/Compiler/CrayPrgEnv-PGI-Fortran.cmake7
-rw-r--r--Modules/Compiler/CrayPrgEnv.cmake167
-rw-r--r--Modules/Compiler/Flang-FindBinUtils.cmake1
-rw-r--r--Modules/Compiler/Flang-Fortran.cmake13
-rw-r--r--Modules/Compiler/G95-Fortran.cmake2
-rw-r--r--Modules/Compiler/GHS-C.cmake20
-rw-r--r--Modules/Compiler/GHS-CXX.cmake24
-rw-r--r--Modules/Compiler/GHS-DetermineCompiler.cmake11
-rw-r--r--Modules/Compiler/GHS.cmake6
-rw-r--r--Modules/Compiler/GNU-C.cmake3
-rw-r--r--Modules/Compiler/GNU-CXX-FeatureTests.cmake4
-rw-r--r--Modules/Compiler/GNU-CXX.cmake19
-rw-r--r--Modules/Compiler/GNU-FindBinUtils.cmake4
-rw-r--r--Modules/Compiler/GNU-Fortran.cmake5
-rw-r--r--Modules/Compiler/GNU-OBJC.cmake2
-rw-r--r--Modules/Compiler/GNU-OBJCXX.cmake10
-rw-r--r--Modules/Compiler/GNU.cmake36
-rw-r--r--Modules/Compiler/HP-C.cmake3
-rw-r--r--Modules/Compiler/HP-CXX.cmake3
-rw-r--r--Modules/Compiler/HP-Fortran.cmake3
-rw-r--r--Modules/Compiler/IAR-ASM.cmake46
-rw-r--r--Modules/Compiler/IAR-C.cmake82
-rw-r--r--Modules/Compiler/IAR-CXX.cmake90
-rw-r--r--Modules/Compiler/IAR-DetermineCompiler.cmake41
-rw-r--r--Modules/Compiler/IAR-FindBinUtils.cmake63
-rw-r--r--Modules/Compiler/IAR.cmake123
-rw-r--r--Modules/Compiler/Intel-C.cmake6
-rw-r--r--Modules/Compiler/Intel-CXX-FeatureTests.cmake6
-rw-r--r--Modules/Compiler/Intel-CXX.cmake32
-rw-r--r--Modules/Compiler/Intel-DetermineCompiler.cmake14
-rw-r--r--Modules/Compiler/Intel-Fortran.cmake5
-rw-r--r--Modules/Compiler/Intel.cmake15
-rw-r--r--Modules/Compiler/MIPSpro-C.cmake1
-rw-r--r--Modules/Compiler/MIPSpro-CXX.cmake1
-rw-r--r--Modules/Compiler/MIPSpro-DetermineCompiler.cmake15
-rw-r--r--Modules/Compiler/MIPSpro-Fortran.cmake3
-rw-r--r--Modules/Compiler/MSVC-ASM.cmake1
-rw-r--r--Modules/Compiler/MSVC-C-FeatureTests.cmake8
-rw-r--r--Modules/Compiler/MSVC-C.cmake38
-rw-r--r--Modules/Compiler/MSVC-CXX-FeatureTests.cmake34
-rw-r--r--Modules/Compiler/MSVC-CXX.cmake53
-rw-r--r--Modules/Compiler/NAG-Fortran.cmake3
-rw-r--r--Modules/Compiler/NVIDIA-CUDA.cmake15
-rw-r--r--Modules/Compiler/NVIDIA-DetermineCompiler.cmake8
-rw-r--r--Modules/Compiler/PGI-C.cmake3
-rw-r--r--Modules/Compiler/PGI-CXX.cmake4
-rw-r--r--Modules/Compiler/PGI-Fortran.cmake4
-rw-r--r--Modules/Compiler/PGI.cmake15
-rw-r--r--Modules/Compiler/QCC-ASM.cmake2
-rw-r--r--Modules/Compiler/QCC-C-FeatureTests.cmake1
-rw-r--r--Modules/Compiler/QCC-C.cmake3
-rw-r--r--Modules/Compiler/QCC-CXX-FeatureTests.cmake1
-rw-r--r--Modules/Compiler/QCC-CXX.cmake3
-rw-r--r--Modules/Compiler/QCC.cmake13
-rw-r--r--Modules/Compiler/SCO.cmake3
-rw-r--r--Modules/Compiler/SunPro-C.cmake12
-rw-r--r--Modules/Compiler/SunPro-CXX-FeatureTests.cmake14
-rw-r--r--Modules/Compiler/SunPro-CXX.cmake15
-rw-r--r--Modules/Compiler/SunPro-Fortran.cmake7
-rw-r--r--Modules/Compiler/TI-C.cmake8
-rw-r--r--Modules/Compiler/TI-CXX.cmake2
-rw-r--r--Modules/Compiler/TinyCC-C.cmake3
-rw-r--r--Modules/Compiler/XL-C.cmake40
-rw-r--r--Modules/Compiler/XL-CXX.cmake46
-rw-r--r--Modules/Compiler/XL-Fortran.cmake3
-rw-r--r--Modules/Compiler/XL.cmake30
-rw-r--r--Modules/Compiler/XLClang-C-DetermineCompiler.cmake8
-rw-r--r--Modules/Compiler/XLClang-C.cmake20
-rw-r--r--Modules/Compiler/XLClang-CXX-DetermineCompiler.cmake8
-rw-r--r--Modules/Compiler/XLClang-CXX.cmake27
-rw-r--r--Modules/Compiler/XLClang.cmake22
-rw-r--r--Modules/CompilerId/GHS_default.gpj.in8
-rw-r--r--Modules/CompilerId/GHS_lib.gpj.in3
-rw-r--r--Modules/CompilerId/VS-10.vcxproj.in2
-rw-r--r--Modules/CompilerId/Xcode-3.pbxproj.in4
-rw-r--r--Modules/Dart.cmake43
-rw-r--r--Modules/DartConfiguration.tcl.in15
-rw-r--r--Modules/DeployQt4.cmake728
-rw-r--r--Modules/Documentation.cmake17
-rw-r--r--Modules/ExternalData.cmake2
-rw-r--r--Modules/ExternalProject-download.cmake.in2
-rw-r--r--Modules/ExternalProject.cmake1657
-rw-r--r--Modules/FeatureSummary.cmake4
-rw-r--r--Modules/FetchContent.cmake1061
-rw-r--r--Modules/FetchContent/CMakeLists.cmake.in23
-rw-r--r--Modules/FindALSA.cmake66
-rw-r--r--Modules/FindASPELL.cmake31
-rw-r--r--Modules/FindAVIFile.cmake45
-rw-r--r--Modules/FindArmadillo.cmake58
-rw-r--r--Modules/FindBISON.cmake224
-rw-r--r--Modules/FindBLAS.cmake1284
-rw-r--r--Modules/FindBZip2.cmake129
-rw-r--r--Modules/FindBacktrace.cmake73
-rw-r--r--Modules/FindBoost.cmake1688
-rw-r--r--Modules/FindBullet.cmake79
-rw-r--r--Modules/FindCABLE.cmake43
-rw-r--r--Modules/FindCUDA.cmake864
-rw-r--r--Modules/FindCUDA/make2cmake.cmake2
-rw-r--r--Modules/FindCUDA/run_nvcc.cmake20
-rw-r--r--Modules/FindCUDA/select_compute_arch.cmake101
-rw-r--r--Modules/FindCURL.cmake182
-rw-r--r--Modules/FindCVS.cmake43
-rw-r--r--Modules/FindCoin3D.cmake33
-rw-r--r--Modules/FindCups.cmake63
-rw-r--r--Modules/FindCurses.cmake211
-rw-r--r--Modules/FindCxxTest.cmake345
-rw-r--r--Modules/FindCygwin.cmake22
-rw-r--r--Modules/FindDCMTK.cmake168
-rw-r--r--Modules/FindDart.cmake17
-rw-r--r--Modules/FindDevIL.cmake61
-rw-r--r--Modules/FindDoxygen.cmake176
-rw-r--r--Modules/FindEXPAT.cmake51
-rw-r--r--Modules/FindEnvModules.cmake333
-rw-r--r--Modules/FindFLEX.cmake191
-rw-r--r--Modules/FindFLTK.cmake433
-rw-r--r--Modules/FindFLTK2.cmake77
-rw-r--r--Modules/FindFontconfig.cmake101
-rw-r--r--Modules/FindFreetype.cmake99
-rw-r--r--Modules/FindGCCXML.cmake27
-rw-r--r--Modules/FindGDAL.cmake150
-rw-r--r--Modules/FindGIF.cmake91
-rw-r--r--Modules/FindGLEW.cmake369
-rw-r--r--Modules/FindGLU.cmake1
-rw-r--r--Modules/FindGLUT.cmake107
-rw-r--r--Modules/FindGSL.cmake109
-rw-r--r--Modules/FindGTK.cmake35
-rw-r--r--Modules/FindGTK2.cmake211
-rw-r--r--Modules/FindGTest.cmake292
-rw-r--r--Modules/FindGettext.cmake351
-rw-r--r--Modules/FindGit.cmake55
-rw-r--r--Modules/FindGnuTLS.cmake91
-rw-r--r--Modules/FindGnuplot.cmake39
-rw-r--r--Modules/FindHDF5.cmake423
-rw-r--r--Modules/FindHSPELL.cmake45
-rw-r--r--Modules/FindHTMLHelp.cmake55
-rw-r--r--Modules/FindHg.cmake79
-rw-r--r--Modules/FindICU.cmake292
-rw-r--r--Modules/FindIce.cmake565
-rw-r--r--Modules/FindIconv.cmake133
-rw-r--r--Modules/FindIcotool.cmake29
-rw-r--r--Modules/FindImageMagick.cmake179
-rw-r--r--Modules/FindIntl.cmake55
-rw-r--r--Modules/FindJNI.cmake251
-rw-r--r--Modules/FindJPEG.cmake150
-rw-r--r--Modules/FindJasper.cmake31
-rw-r--r--Modules/FindJava.cmake293
-rw-r--r--Modules/FindKDE3.cmake485
-rw-r--r--Modules/FindKDE4.cmake105
-rw-r--r--Modules/FindLAPACK.cmake380
-rw-r--r--Modules/FindLATEX.cmake103
-rw-r--r--Modules/FindLTTngUST.cmake64
-rw-r--r--Modules/FindLibArchive.cmake30
-rw-r--r--Modules/FindLibLZMA.cmake122
-rw-r--r--Modules/FindLibXml2.cmake80
-rw-r--r--Modules/FindLibXslt.cmake48
-rw-r--r--Modules/FindLibinput.cmake82
-rw-r--r--Modules/FindLua.cmake302
-rw-r--r--Modules/FindLua50.cmake76
-rw-r--r--Modules/FindLua51.cmake71
-rw-r--r--Modules/FindMFC.cmake40
-rw-r--r--Modules/FindMPEG.cmake67
-rw-r--r--Modules/FindMPEG2.cmake61
-rw-r--r--Modules/FindMPI.cmake2157
-rw-r--r--Modules/FindMPI/fortranparam_mpi.f90.in4
-rw-r--r--Modules/FindMPI/libver_mpi.c20
-rw-r--r--Modules/FindMPI/libver_mpi.f90.in7
-rw-r--r--Modules/FindMPI/mpiver.f90.in10
-rw-r--r--Modules/FindMPI/test_mpi.c38
-rw-r--r--Modules/FindMPI/test_mpi.f90.in6
-rw-r--r--Modules/FindMatlab.cmake1691
-rw-r--r--Modules/FindMotif.cmake27
-rw-r--r--Modules/FindODBC.cmake231
-rw-r--r--Modules/FindOpenACC.cmake283
-rw-r--r--Modules/FindOpenAL.cmake39
-rw-r--r--Modules/FindOpenCL.cmake92
-rw-r--r--Modules/FindOpenGL.cmake480
-rw-r--r--Modules/FindOpenMP.cmake349
-rw-r--r--Modules/FindOpenSSL.cmake192
-rw-r--r--Modules/FindOpenSceneGraph.cmake195
-rw-r--r--Modules/FindOpenThreads.cmake79
-rw-r--r--Modules/FindPHP4.cmake29
-rw-r--r--Modules/FindPNG.cmake100
-rw-r--r--Modules/FindPackageHandleStandardArgs.cmake94
-rw-r--r--Modules/FindPackageMessage.cmake59
-rw-r--r--Modules/FindPatch.cmake69
-rw-r--r--Modules/FindPerl.cmake28
-rw-r--r--Modules/FindPerlLibs.cmake277
-rw-r--r--Modules/FindPhysFS.cmake35
-rw-r--r--Modules/FindPike.cmake38
-rw-r--r--Modules/FindPkgConfig.cmake604
-rw-r--r--Modules/FindPostgreSQL.cmake163
-rw-r--r--Modules/FindProducer.cmake71
-rw-r--r--Modules/FindProtobuf.cmake529
-rw-r--r--Modules/FindPython.cmake359
-rw-r--r--Modules/FindPython/Support.cmake2384
-rw-r--r--Modules/FindPython2.cmake267
-rw-r--r--Modules/FindPython3.cmake308
-rw-r--r--Modules/FindPythonInterp.cmake101
-rw-r--r--Modules/FindPythonLibs.cmake134
-rw-r--r--Modules/FindQt.cmake83
-rw-r--r--Modules/FindQt3.cmake96
-rw-r--r--Modules/FindQt4.cmake670
-rw-r--r--Modules/FindQuickTime.cmake29
-rw-r--r--Modules/FindRTI.cmake63
-rw-r--r--Modules/FindRuby.cmake364
-rw-r--r--Modules/FindSDL.cmake142
-rw-r--r--Modules/FindSDL_image.cmake69
-rw-r--r--Modules/FindSDL_mixer.cmake69
-rw-r--r--Modules/FindSDL_net.cmake67
-rw-r--r--Modules/FindSDL_sound.cmake568
-rw-r--r--Modules/FindSDL_ttf.cmake67
-rw-r--r--Modules/FindSQLite3.cmake66
-rw-r--r--Modules/FindSWIG.cmake51
-rw-r--r--Modules/FindSelfPackers.cmake35
-rw-r--r--Modules/FindSquish.cmake238
-rw-r--r--Modules/FindSubversion.cmake138
-rw-r--r--Modules/FindTCL.cmake142
-rw-r--r--Modules/FindTIFF.cmake75
-rw-r--r--Modules/FindTclStub.cmake87
-rw-r--r--Modules/FindTclsh.cmake46
-rw-r--r--Modules/FindThreads.cmake202
-rw-r--r--Modules/FindUnixCommands.cmake42
-rw-r--r--Modules/FindVulkan.cmake56
-rw-r--r--Modules/FindWget.cmake25
-rw-r--r--Modules/FindWish.cmake35
-rw-r--r--Modules/FindX11.cmake513
-rw-r--r--Modules/FindXCTest.cmake23
-rw-r--r--Modules/FindXMLRPC.cmake102
-rw-r--r--Modules/FindXalanC.cmake81
-rw-r--r--Modules/FindXercesC.cmake92
-rw-r--r--Modules/FindZLIB.cmake111
-rw-r--r--Modules/Findosg.cmake71
-rw-r--r--Modules/FindosgAnimation.cmake61
-rw-r--r--Modules/FindosgDB.cmake69
-rw-r--r--Modules/FindosgFX.cmake61
-rw-r--r--Modules/FindosgGA.cmake61
-rw-r--r--Modules/FindosgIntrospection.cmake63
-rw-r--r--Modules/FindosgManipulator.cmake63
-rw-r--r--Modules/FindosgParticle.cmake61
-rw-r--r--Modules/FindosgPresentation.cmake65
-rw-r--r--Modules/FindosgProducer.cmake61
-rw-r--r--Modules/FindosgQt.cmake61
-rw-r--r--Modules/FindosgShadow.cmake61
-rw-r--r--Modules/FindosgSim.cmake61
-rw-r--r--Modules/FindosgTerrain.cmake61
-rw-r--r--Modules/FindosgText.cmake61
-rw-r--r--Modules/FindosgUtil.cmake61
-rw-r--r--Modules/FindosgViewer.cmake61
-rw-r--r--Modules/FindosgVolume.cmake61
-rw-r--r--Modules/FindosgWidget.cmake63
-rw-r--r--Modules/Findosg_functions.cmake147
-rw-r--r--Modules/FindwxWidgets.cmake410
-rw-r--r--Modules/FindwxWindows.cmake166
-rw-r--r--Modules/FortranCInterface/CMakeLists.txt5
-rw-r--r--Modules/GNUInstallDirs.cmake263
-rw-r--r--Modules/GenerateExportHeader.cmake421
-rw-r--r--Modules/GetPrerequisites.cmake408
-rw-r--r--Modules/GoogleTest.cmake271
-rw-r--r--Modules/GoogleTestAddTests.cmake106
-rw-r--r--Modules/ITKCompatibility.cmake2
-rw-r--r--Modules/InstallRequiredSystemLibraries.cmake448
-rw-r--r--Modules/Internal/CMakeCheckCompilerFlag.cmake158
-rw-r--r--Modules/Internal/CPack/CPack.DS_Store.in (renamed from Modules/CPack.DS_Store.in)bin12292 -> 12292 bytes
-rw-r--r--Modules/Internal/CPack/CPack.Description.plist.in (renamed from Modules/CPack.Description.plist.in)0
-rw-r--r--Modules/Internal/CPack/CPack.Info.plist.in (renamed from Modules/CPack.Info.plist.in)0
-rw-r--r--Modules/Internal/CPack/CPack.NuGet.nuspec.in24
-rw-r--r--[-rwxr-xr-x]Modules/Internal/CPack/CPack.OSXScriptLauncher.in (renamed from Modules/CPack.OSXScriptLauncher.in)bin29592 -> 29592 bytes
-rw-r--r--Modules/Internal/CPack/CPack.OSXScriptLauncher.rsrc.in (renamed from Modules/CPack.OSXScriptLauncher.rsrc.in)bin362 -> 362 bytes
-rw-r--r--Modules/Internal/CPack/CPack.OSXX11.Info.plist.in (renamed from Modules/CPack.OSXX11.Info.plist.in)0
-rw-r--r--Modules/Internal/CPack/CPack.OSXX11.main.scpt.in (renamed from Modules/CPack.OSXX11.main.scpt.in)bin1870 -> 1870 bytes
-rwxr-xr-xModules/Internal/CPack/CPack.RuntimeScript.in (renamed from Modules/CPack.RuntimeScript.in)0
-rwxr-xr-xModules/Internal/CPack/CPack.STGZ_Header.sh.in149
-rw-r--r--Modules/Internal/CPack/CPack.VolumeIcon.icns.in (renamed from Modules/CPack.VolumeIcon.icns.in)bin45739 -> 45739 bytes
-rw-r--r--Modules/Internal/CPack/CPack.background.png.inbin0 -> 44108 bytes
-rw-r--r--Modules/Internal/CPack/CPack.distribution.dist.in (renamed from Modules/CPack.distribution.dist.in)0
-rw-r--r--Modules/Internal/CPack/CPackDeb.cmake766
-rw-r--r--Modules/Internal/CPack/CPackExternal.cmake53
-rw-r--r--Modules/Internal/CPack/CPackFreeBSD.cmake107
-rw-r--r--Modules/Internal/CPack/CPackNuGet.cmake363
-rw-r--r--Modules/Internal/CPack/CPackRPM.cmake1881
-rw-r--r--Modules/Internal/CPack/CPackWIX.cmake20
-rw-r--r--Modules/Internal/CPack/CPackZIP.cmake30
-rw-r--r--Modules/Internal/CPack/NSIS.InstallOptions.ini.in (renamed from Modules/NSIS.InstallOptions.ini.in)0
-rw-r--r--Modules/Internal/CPack/NSIS.template.in972
-rw-r--r--Modules/Internal/CPack/WIX.template.in (renamed from Modules/WIX.template.in)0
-rw-r--r--Modules/Internal/FeatureTesting.cmake29
-rw-r--r--Modules/KDE3Macros.cmake453
-rw-r--r--Modules/MacroAddFileDependencies.cmake41
-rw-r--r--Modules/MatlabTestsRedirect.cmake5
-rw-r--r--Modules/NSIS.template.in972
-rw-r--r--Modules/Platform/AIX-GNU.cmake27
-rw-r--r--Modules/Platform/AIX-XL.cmake33
-rw-r--r--Modules/Platform/AIX-XLClang-C.cmake2
-rw-r--r--Modules/Platform/AIX-XLClang-CXX.cmake2
-rw-r--r--Modules/Platform/AIX-XLClang.cmake15
-rw-r--r--Modules/Platform/AIX.cmake2
-rwxr-xr-xModules/Platform/AIX/ExportImportList53
-rw-r--r--Modules/Platform/Android-Clang-CXX.cmake7
-rw-r--r--Modules/Platform/Android-Clang.cmake4
-rw-r--r--Modules/Platform/Android-Common.cmake48
-rw-r--r--Modules/Platform/Android-Determine.cmake98
-rw-r--r--Modules/Platform/Android-GNU-CXX.cmake3
-rw-r--r--Modules/Platform/Android-Initialize.cmake9
-rw-r--r--Modules/Platform/Android.cmake8
-rw-r--r--Modules/Platform/Android/Determine-Compiler-NDK.cmake72
-rw-r--r--Modules/Platform/Android/Determine-Compiler-Standalone.cmake1
-rw-r--r--Modules/Platform/Android/Determine-Compiler.cmake2
-rw-r--r--Modules/Platform/Android/abi-common.cmake22
-rw-r--r--Modules/Platform/Android/ndk-stl-c++.cmake1
-rw-r--r--Modules/Platform/Android/ndk-stl-gabi++.cmake1
-rw-r--r--Modules/Platform/Android/ndk-stl-gnustl.cmake1
-rw-r--r--Modules/Platform/Android/ndk-stl-none.cmake1
-rw-r--r--Modules/Platform/Android/ndk-stl-stlport.cmake1
-rw-r--r--Modules/Platform/Android/ndk-stl-system.cmake1
-rw-r--r--Modules/Platform/Apple-Absoft-Fortran.cmake (renamed from Modules/Platform/Darwin-Absoft-Fortran.cmake)0
-rw-r--r--Modules/Platform/Apple-Apple-Swift.cmake1
-rw-r--r--Modules/Platform/Apple-AppleClang-C.cmake6
-rw-r--r--Modules/Platform/Apple-AppleClang-CXX.cmake6
-rw-r--r--Modules/Platform/Apple-AppleClang-OBJC.cmake6
-rw-r--r--Modules/Platform/Apple-AppleClang-OBJCXX.cmake6
-rw-r--r--Modules/Platform/Apple-Clang-ASM.cmake2
-rw-r--r--Modules/Platform/Apple-Clang-C.cmake2
-rw-r--r--Modules/Platform/Apple-Clang-CXX.cmake2
-rw-r--r--Modules/Platform/Apple-Clang-OBJC.cmake2
-rw-r--r--Modules/Platform/Apple-Clang-OBJCXX.cmake2
-rw-r--r--Modules/Platform/Apple-Clang.cmake32
-rw-r--r--Modules/Platform/Apple-GNU-C.cmake4
-rw-r--r--Modules/Platform/Apple-GNU-CXX.cmake4
-rw-r--r--Modules/Platform/Apple-GNU-Fortran.cmake10
-rw-r--r--Modules/Platform/Apple-GNU-OBJC.cmake4
-rw-r--r--Modules/Platform/Apple-GNU-OBJCXX.cmake4
-rw-r--r--Modules/Platform/Apple-GNU.cmake57
-rw-r--r--Modules/Platform/Apple-Intel-C.cmake2
-rw-r--r--Modules/Platform/Apple-Intel-CXX.cmake2
-rw-r--r--Modules/Platform/Apple-Intel-Fortran.cmake8
-rw-r--r--Modules/Platform/Apple-Intel.cmake19
-rw-r--r--Modules/Platform/Apple-NAG-Fortran.cmake (renamed from Modules/Platform/Darwin-NAG-Fortran.cmake)0
-rw-r--r--Modules/Platform/Apple-NVIDIA-CUDA.cmake19
-rw-r--r--Modules/Platform/Apple-PGI-C.cmake2
-rw-r--r--Modules/Platform/Apple-PGI-CXX.cmake2
-rw-r--r--Modules/Platform/Apple-PGI-Fortran.cmake2
-rw-r--r--Modules/Platform/Apple-PGI.cmake11
-rw-r--r--Modules/Platform/Apple-VisualAge-C.cmake1
-rw-r--r--Modules/Platform/Apple-VisualAge-CXX.cmake1
-rw-r--r--Modules/Platform/Apple-XL-C.cmake7
-rw-r--r--Modules/Platform/Apple-XL-CXX.cmake7
-rw-r--r--Modules/Platform/CYGWIN-GNU.cmake3
-rw-r--r--Modules/Platform/CrayLinuxEnvironment.cmake72
-rw-r--r--Modules/Platform/Darwin-AppleClang-C.cmake6
-rw-r--r--Modules/Platform/Darwin-AppleClang-CXX.cmake6
-rw-r--r--Modules/Platform/Darwin-Clang-C.cmake2
-rw-r--r--Modules/Platform/Darwin-Clang-CXX.cmake2
-rw-r--r--Modules/Platform/Darwin-Clang.cmake20
-rw-r--r--Modules/Platform/Darwin-GNU-C.cmake4
-rw-r--r--Modules/Platform/Darwin-GNU-CXX.cmake4
-rw-r--r--Modules/Platform/Darwin-GNU-Fortran.cmake10
-rw-r--r--Modules/Platform/Darwin-GNU.cmake60
-rw-r--r--Modules/Platform/Darwin-Initialize.cmake12
-rw-r--r--Modules/Platform/Darwin-Intel-C.cmake2
-rw-r--r--Modules/Platform/Darwin-Intel-CXX.cmake2
-rw-r--r--Modules/Platform/Darwin-Intel-Fortran.cmake8
-rw-r--r--Modules/Platform/Darwin-Intel.cmake19
-rw-r--r--Modules/Platform/Darwin-PGI-C.cmake2
-rw-r--r--Modules/Platform/Darwin-PGI-CXX.cmake2
-rw-r--r--Modules/Platform/Darwin-PGI-Fortran.cmake2
-rw-r--r--Modules/Platform/Darwin-PGI.cmake14
-rw-r--r--Modules/Platform/Darwin-VisualAge-C.cmake1
-rw-r--r--Modules/Platform/Darwin-VisualAge-CXX.cmake1
-rw-r--r--Modules/Platform/Darwin-XL-C.cmake8
-rw-r--r--Modules/Platform/Darwin-XL-CXX.cmake8
-rw-r--r--Modules/Platform/Darwin.cmake93
-rw-r--r--Modules/Platform/DragonFly.cmake4
-rw-r--r--Modules/Platform/FreeBSD-Determine-CXX.cmake3
-rw-r--r--Modules/Platform/FreeBSD.cmake3
-rw-r--r--Modules/Platform/Fuchsia.cmake3
-rw-r--r--Modules/Platform/GHS-MULTI-Determine.cmake56
-rw-r--r--Modules/Platform/GHS-MULTI-Initialize.cmake41
-rw-r--r--Modules/Platform/GNU.cmake27
-rw-r--r--Modules/Platform/GNUtoMS_lib.bat.in1
-rw-r--r--Modules/Platform/Generic-ADSP-C.cmake4
-rw-r--r--Modules/Platform/Generic-ADSP-CXX.cmake4
-rw-r--r--Modules/Platform/Generic-SDCC-C.cmake5
-rw-r--r--Modules/Platform/Haiku.cmake1
-rw-r--r--Modules/Platform/IRIX.cmake53
-rw-r--r--Modules/Platform/IRIX64.cmake73
-rw-r--r--Modules/Platform/Linux-GNU.cmake1
-rw-r--r--Modules/Platform/Linux-Intel.cmake9
-rw-r--r--Modules/Platform/Linux-PGI.cmake3
-rw-r--r--Modules/Platform/Linux-XL-C.cmake1
-rw-r--r--Modules/Platform/Linux-XL-CXX.cmake1
-rw-r--r--Modules/Platform/Linux-XL-Fortran.cmake1
-rw-r--r--Modules/Platform/Linux.cmake1
-rw-r--r--Modules/Platform/Midipix.cmake1
-rw-r--r--Modules/Platform/NetBSD.cmake2
-rw-r--r--Modules/Platform/OpenBSD.cmake4
-rw-r--r--Modules/Platform/SINIX.cmake3
-rw-r--r--Modules/Platform/SunOS-Clang-C.cmake1
-rw-r--r--Modules/Platform/SunOS-Clang-CXX.cmake1
-rw-r--r--Modules/Platform/SunOS-GNU.cmake1
-rw-r--r--Modules/Platform/SunOS.cmake12
-rw-r--r--Modules/Platform/UNIX_SV.cmake3
-rw-r--r--Modules/Platform/UnixPaths.cmake24
-rw-r--r--Modules/Platform/UnixWare.cmake3
-rw-r--r--Modules/Platform/Windows-Clang-CXX.cmake1
-rw-r--r--Modules/Platform/Windows-Clang.cmake143
-rw-r--r--Modules/Platform/Windows-Embarcadero.cmake9
-rw-r--r--Modules/Platform/Windows-Flang-Fortran.cmake8
-rw-r--r--Modules/Platform/Windows-GNU.cmake5
-rw-r--r--Modules/Platform/Windows-Intel-C.cmake2
-rw-r--r--Modules/Platform/Windows-Intel-CXX.cmake2
-rw-r--r--Modules/Platform/Windows-Intel-Fortran.cmake37
-rw-r--r--Modules/Platform/Windows-Intel.cmake2
-rw-r--r--Modules/Platform/Windows-MSVC.cmake168
-rw-r--r--Modules/Platform/Windows-NMcl.cmake4
-rw-r--r--Modules/Platform/Windows-NVIDIA-CUDA.cmake63
-rw-r--r--Modules/Platform/Windows-OpenWatcom.cmake2
-rw-r--r--Modules/Platform/Windows-df.cmake3
-rw-r--r--Modules/Platform/WindowsPhone-Clang-C.cmake1
-rw-r--r--Modules/Platform/WindowsPhone-Clang-CXX.cmake1
-rw-r--r--Modules/Platform/WindowsPhone-GNU-C.cmake1
-rw-r--r--Modules/Platform/WindowsPhone-GNU-CXX.cmake1
-rw-r--r--Modules/Platform/WindowsStore-Clang-C.cmake1
-rw-r--r--Modules/Platform/WindowsStore-Clang-CXX.cmake1
-rw-r--r--Modules/Platform/WindowsStore-GNU-C.cmake1
-rw-r--r--Modules/Platform/WindowsStore-GNU-CXX.cmake1
-rw-r--r--Modules/Platform/iOS-Determine-CXX.cmake1
-rw-r--r--Modules/Platform/iOS-Initialize.cmake9
-rw-r--r--Modules/Platform/iOS.cmake1
-rw-r--r--Modules/Platform/tvOS-Determine-CXX.cmake1
-rw-r--r--Modules/Platform/tvOS-Initialize.cmake7
-rw-r--r--Modules/Platform/tvOS.cmake1
-rw-r--r--Modules/Platform/watchOS-Determine-CXX.cmake1
-rw-r--r--Modules/Platform/watchOS-Initialize.cmake7
-rw-r--r--Modules/Platform/watchOS.cmake1
-rw-r--r--Modules/ProcessorCount.cmake117
-rw-r--r--Modules/Qt4ConfigDependentSettings.cmake16
-rw-r--r--Modules/Qt4Macros.cmake144
-rw-r--r--Modules/SelectLibraryConfigurations.cmake68
-rwxr-xr-xModules/Squish4RunTestCase.bat48
-rw-r--r--Modules/SquishTestScript.cmake33
-rw-r--r--Modules/TestBigEndian.cmake29
-rw-r--r--Modules/TestCXXAcceptsFlag.cmake35
-rw-r--r--Modules/TestForANSIForScope.cmake25
-rw-r--r--Modules/TestForANSIStreamHeaders.cmake25
-rw-r--r--Modules/TestForSSTREAM.cmake23
-rw-r--r--Modules/TestForSTDNamespace.cmake23
-rw-r--r--Modules/UseEcos.cmake267
-rw-r--r--Modules/UseJava.cmake1119
-rw-r--r--Modules/UseJavaClassFilelist.cmake23
-rw-r--r--Modules/UseJavaSymlinks.cmake19
-rw-r--r--Modules/UsePkgConfig.cmake37
-rw-r--r--Modules/UseQt4.cmake20
-rw-r--r--Modules/UseSWIG.cmake859
-rw-r--r--Modules/UseSWIG/ManageSupportFiles.cmake31
-rw-r--r--Modules/Use_wxWindows.cmake61
-rw-r--r--Modules/UsewxWidgets.cmake71
-rw-r--r--Modules/WriteBasicConfigVersionFile.cmake37
-rw-r--r--Modules/WriteCompilerDetectionHeader.cmake539
-rw-r--r--Modules/ecos_clean.cmake12
-rw-r--r--Modules/exportheader.cmake.in2
-rw-r--r--Modules/readme.txt2
-rw-r--r--README.rst61
-rw-r--r--Source/.gitattributes4
-rw-r--r--Source/CMakeInstallDestinations.cmake7
-rw-r--r--Source/CMakeInstallSignTool.cmake.in51
-rw-r--r--Source/CMakeLists.txt318
-rw-r--r--Source/CMakeVersion.cmake81
-rw-r--r--Source/CMakeVersion.rc.in28
-rw-r--r--Source/CMakeVersionCompute.cmake29
-rw-r--r--Source/CMakeVersionSource.cmake30
-rw-r--r--Source/CPack/IFW/cmCPackIFWCommon.cxx20
-rw-r--r--Source/CPack/IFW/cmCPackIFWGenerator.cxx296
-rw-r--r--Source/CPack/IFW/cmCPackIFWGenerator.h56
-rw-r--r--Source/CPack/IFW/cmCPackIFWInstaller.cxx84
-rw-r--r--Source/CPack/IFW/cmCPackIFWInstaller.h15
-rw-r--r--Source/CPack/IFW/cmCPackIFWPackage.cxx192
-rw-r--r--Source/CPack/IFW/cmCPackIFWPackage.h10
-rw-r--r--Source/CPack/IFW/cmCPackIFWRepository.cxx35
-rw-r--r--Source/CPack/IFW/cmCPackIFWRepository.h6
-rw-r--r--Source/CPack/OSXScriptLauncher.cxx22
-rw-r--r--Source/CPack/WiX/cmCMakeToWixPath.cxx39
-rw-r--r--Source/CPack/WiX/cmCMakeToWixPath.h12
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx238
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.h34
-rw-r--r--Source/CPack/WiX/cmWIXAccessControlList.cxx19
-rw-r--r--Source/CPack/WiX/cmWIXAccessControlList.h3
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx10
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h5
-rw-r--r--Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx12
-rw-r--r--Source/CPack/WiX/cmWIXFeaturesSourceWriter.h3
-rw-r--r--Source/CPack/WiX/cmWIXFilesSourceWriter.cxx9
-rw-r--r--Source/CPack/WiX/cmWIXFilesSourceWriter.h6
-rw-r--r--Source/CPack/WiX/cmWIXPatch.cxx28
-rw-r--r--Source/CPack/WiX/cmWIXPatch.h4
-rw-r--r--Source/CPack/WiX/cmWIXPatchParser.cxx12
-rw-r--r--Source/CPack/WiX/cmWIXPatchParser.h13
-rw-r--r--Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx2
-rw-r--r--Source/CPack/WiX/cmWIXRichTextFormatWriter.h5
-rw-r--r--Source/CPack/WiX/cmWIXShortcut.cxx16
-rw-r--r--Source/CPack/WiX/cmWIXShortcut.h10
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.cxx15
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.h6
-rw-r--r--Source/CPack/bills-comments.txt68
-rw-r--r--Source/CPack/cmCPack7zGenerator.cxx15
-rw-r--r--Source/CPack/cmCPack7zGenerator.h29
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.cxx183
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.h41
-rw-r--r--Source/CPack/cmCPackBundleGenerator.cxx56
-rw-r--r--Source/CPack/cmCPackBundleGenerator.h12
-rw-r--r--Source/CPack/cmCPackComponentGroup.cxx13
-rw-r--r--Source/CPack/cmCPackComponentGroup.h31
-rw-r--r--Source/CPack/cmCPackCygwinBinaryGenerator.cxx20
-rw-r--r--Source/CPack/cmCPackCygwinBinaryGenerator.h8
-rw-r--r--Source/CPack/cmCPackCygwinSourceGenerator.cxx63
-rw-r--r--Source/CPack/cmCPackCygwinSourceGenerator.h8
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx1254
-rw-r--r--Source/CPack/cmCPackDebGenerator.h20
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.cxx197
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.h23
-rw-r--r--Source/CPack/cmCPackExternalGenerator.cxx322
-rw-r--r--Source/CPack/cmCPackExternalGenerator.h90
-rw-r--r--Source/CPack/cmCPackFreeBSDGenerator.cxx337
-rw-r--r--Source/CPack/cmCPackFreeBSDGenerator.h37
-rw-r--r--Source/CPack/cmCPackGenerator.cxx1124
-rw-r--r--Source/CPack/cmCPackGenerator.h47
-rw-r--r--Source/CPack/cmCPackGeneratorFactory.cxx118
-rw-r--r--Source/CPack/cmCPackGeneratorFactory.h15
-rw-r--r--Source/CPack/cmCPackLog.cxx19
-rw-r--r--Source/CPack/cmCPackLog.h8
-rw-r--r--Source/CPack/cmCPackNSISGenerator.cxx446
-rw-r--r--Source/CPack/cmCPackNSISGenerator.h24
-rw-r--r--Source/CPack/cmCPackNuGetGenerator.cxx141
-rw-r--r--Source/CPack/cmCPackNuGetGenerator.h37
-rw-r--r--Source/CPack/cmCPackOSXX11Generator.cxx111
-rw-r--r--Source/CPack/cmCPackOSXX11Generator.h12
-rw-r--r--Source/CPack/cmCPackPKGGenerator.cxx154
-rw-r--r--Source/CPack/cmCPackPKGGenerator.h10
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.cxx146
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.h12
-rw-r--r--Source/CPack/cmCPackProductBuildGenerator.cxx63
-rw-r--r--Source/CPack/cmCPackProductBuildGenerator.h10
-rw-r--r--Source/CPack/cmCPackRPMGenerator.cxx76
-rw-r--r--Source/CPack/cmCPackRPMGenerator.h18
-rw-r--r--Source/CPack/cmCPackSTGZGenerator.cxx25
-rw-r--r--Source/CPack/cmCPackSTGZGenerator.h21
-rw-r--r--Source/CPack/cmCPackTGZGenerator.cxx15
-rw-r--r--Source/CPack/cmCPackTGZGenerator.h29
-rw-r--r--Source/CPack/cmCPackTXZGenerator.cxx15
-rw-r--r--Source/CPack/cmCPackTXZGenerator.h29
-rw-r--r--Source/CPack/cmCPackTarBZip2Generator.cxx15
-rw-r--r--Source/CPack/cmCPackTarBZip2Generator.h28
-rw-r--r--Source/CPack/cmCPackTarCompressGenerator.cxx15
-rw-r--r--Source/CPack/cmCPackTarCompressGenerator.h28
-rw-r--r--Source/CPack/cmCPackZIPGenerator.cxx15
-rw-r--r--Source/CPack/cmCPackZIPGenerator.h29
-rw-r--r--Source/CPack/cpack.cxx226
-rw-r--r--Source/CTest/cmCTestBZR.cxx92
-rw-r--r--Source/CTest/cmCTestBZR.h18
-rw-r--r--Source/CTest/cmCTestBatchTestHandler.cxx125
-rw-r--r--Source/CTest/cmCTestBatchTestHandler.h33
-rw-r--r--Source/CTest/cmCTestBinPacker.cxx203
-rw-r--r--Source/CTest/cmCTestBinPacker.h31
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx199
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.h26
-rw-r--r--Source/CTest/cmCTestBuildCommand.cxx110
-rw-r--r--Source/CTest/cmCTestBuildCommand.h46
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx417
-rw-r--r--Source/CTest/cmCTestBuildHandler.h42
-rw-r--r--Source/CTest/cmCTestCVS.cxx64
-rw-r--r--Source/CTest/cmCTestCVS.h12
-rw-r--r--Source/CTest/cmCTestCommand.h4
-rw-r--r--Source/CTest/cmCTestConfigureCommand.cxx63
-rw-r--r--Source/CTest/cmCTestConfigureCommand.h31
-rw-r--r--Source/CTest/cmCTestConfigureHandler.cxx39
-rw-r--r--Source/CTest/cmCTestConfigureHandler.h8
-rw-r--r--Source/CTest/cmCTestCoverageCommand.cxx53
-rw-r--r--Source/CTest/cmCTestCoverageCommand.h40
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx590
-rw-r--r--Source/CTest/cmCTestCoverageHandler.h29
-rw-r--r--Source/CTest/cmCTestCurl.cxx77
-rw-r--r--Source/CTest/cmCTestCurl.h7
-rw-r--r--Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx4
-rw-r--r--Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h20
-rw-r--r--Source/CTest/cmCTestGIT.cxx147
-rw-r--r--Source/CTest/cmCTestGIT.h18
-rw-r--r--Source/CTest/cmCTestGenericHandler.cxx29
-rw-r--r--Source/CTest/cmCTestGenericHandler.h7
-rw-r--r--Source/CTest/cmCTestGlobalVC.cxx34
-rw-r--r--Source/CTest/cmCTestGlobalVC.h12
-rw-r--r--Source/CTest/cmCTestHG.cxx96
-rw-r--r--Source/CTest/cmCTestHG.h18
-rw-r--r--Source/CTest/cmCTestHandlerCommand.cxx221
-rw-r--r--Source/CTest/cmCTestHandlerCommand.h56
-rw-r--r--Source/CTest/cmCTestLaunch.cxx214
-rw-r--r--Source/CTest/cmCTestLaunch.h18
-rw-r--r--Source/CTest/cmCTestMemCheckCommand.cxx26
-rw-r--r--Source/CTest/cmCTestMemCheckCommand.h29
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx254
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.h29
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx1010
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.h61
-rw-r--r--Source/CTest/cmCTestP4.cxx105
-rw-r--r--Source/CTest/cmCTestP4.h18
-rw-r--r--Source/CTest/cmCTestReadCustomFilesCommand.cxx5
-rw-r--r--Source/CTest/cmCTestReadCustomFilesCommand.h19
-rw-r--r--Source/CTest/cmCTestResourceAllocator.cxx86
-rw-r--r--Source/CTest/cmCTestResourceAllocator.h39
-rw-r--r--Source/CTest/cmCTestResourceGroupsLexerHelper.cxx55
-rw-r--r--Source/CTest/cmCTestResourceGroupsLexerHelper.h44
-rw-r--r--Source/CTest/cmCTestResourceSpec.cxx198
-rw-r--r--Source/CTest/cmCTestResourceSpec.h55
-rw-r--r--Source/CTest/cmCTestRunScriptCommand.cxx9
-rw-r--r--Source/CTest/cmCTestRunScriptCommand.h19
-rw-r--r--Source/CTest/cmCTestRunTest.cxx789
-rw-r--r--Source/CTest/cmCTestRunTest.h91
-rw-r--r--Source/CTest/cmCTestSVN.cxx123
-rw-r--r--Source/CTest/cmCTestSVN.h28
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx425
-rw-r--r--Source/CTest/cmCTestScriptHandler.h36
-rw-r--r--Source/CTest/cmCTestSleepCommand.cxx4
-rw-r--r--Source/CTest/cmCTestSleepCommand.h19
-rw-r--r--Source/CTest/cmCTestStartCommand.cxx101
-rw-r--r--Source/CTest/cmCTestStartCommand.h19
-rw-r--r--Source/CTest/cmCTestSubmitCommand.cxx273
-rw-r--r--Source/CTest/cmCTestSubmitCommand.h75
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx1177
-rw-r--r--Source/CTest/cmCTestSubmitHandler.h49
-rw-r--r--Source/CTest/cmCTestTestCommand.cxx147
-rw-r--r--Source/CTest/cmCTestTestCommand.h59
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx1325
-rw-r--r--Source/CTest/cmCTestTestHandler.h111
-rw-r--r--Source/CTest/cmCTestUpdateCommand.cxx22
-rw-r--r--Source/CTest/cmCTestUpdateCommand.h23
-rw-r--r--Source/CTest/cmCTestUpdateHandler.cxx108
-rw-r--r--Source/CTest/cmCTestUpdateHandler.h12
-rw-r--r--Source/CTest/cmCTestUploadCommand.cxx73
-rw-r--r--Source/CTest/cmCTestUploadCommand.h41
-rw-r--r--Source/CTest/cmCTestUploadHandler.cxx28
-rw-r--r--Source/CTest/cmCTestUploadHandler.h17
-rw-r--r--Source/CTest/cmCTestVC.cxx55
-rw-r--r--Source/CTest/cmCTestVC.h11
-rw-r--r--Source/CTest/cmParseBlanketJSCoverage.cxx26
-rw-r--r--Source/CTest/cmParseBlanketJSCoverage.h2
-rw-r--r--Source/CTest/cmParseCacheCoverage.cxx54
-rw-r--r--Source/CTest/cmParseCacheCoverage.h8
-rw-r--r--Source/CTest/cmParseCoberturaCoverage.cxx56
-rw-r--r--Source/CTest/cmParseDelphiCoverage.cxx27
-rw-r--r--Source/CTest/cmParseGTMCoverage.cxx58
-rw-r--r--Source/CTest/cmParseGTMCoverage.h8
-rw-r--r--Source/CTest/cmParseJacocoCoverage.cxx48
-rw-r--r--Source/CTest/cmParseMumpsCoverage.cxx41
-rw-r--r--Source/CTest/cmParsePHPCoverage.cxx23
-rw-r--r--Source/CTest/cmProcess.cxx743
-rw-r--r--Source/CTest/cmProcess.h106
-rw-r--r--Source/Checks/Curses.cmake41
-rw-r--r--Source/Checks/Curses/CMakeLists.txt25
-rw-r--r--Source/Checks/Curses/CheckCurses.c15
-rw-r--r--Source/Checks/cm_cxx14_check.cmake36
-rw-r--r--Source/Checks/cm_cxx14_check.cpp15
-rw-r--r--Source/Checks/cm_cxx14_cstdio.cmake33
-rw-r--r--Source/Checks/cm_cxx14_cstdio.cpp5
-rw-r--r--Source/Checks/cm_cxx17_check.cmake36
-rw-r--r--Source/Checks/cm_cxx17_check.cpp34
-rw-r--r--Source/Checks/cm_cxx_attribute_fallthrough.cxx11
-rw-r--r--Source/Checks/cm_cxx_auto_ptr.cxx18
-rw-r--r--Source/Checks/cm_cxx_eq_delete.cxx14
-rw-r--r--Source/Checks/cm_cxx_fallthrough.cxx11
-rw-r--r--Source/Checks/cm_cxx_features.cmake27
-rw-r--r--Source/Checks/cm_cxx_gnu_fallthrough.cxx11
-rw-r--r--Source/Checks/cm_cxx_nullptr.cxx14
-rw-r--r--Source/Checks/cm_cxx_override.cxx24
-rw-r--r--Source/Checks/cm_cxx_unordered_map.cxx7
-rw-r--r--Source/Checks/cm_cxx_unordered_set.cxx7
-rw-r--r--Source/CursesDialog/CMakeLists.txt44
-rw-r--r--Source/CursesDialog/ccmake.cxx76
-rw-r--r--Source/CursesDialog/cmCursesBoolWidget.cxx4
-rw-r--r--Source/CursesDialog/cmCursesBoolWidget.h9
-rw-r--r--Source/CursesDialog/cmCursesCacheEntryComposite.cxx96
-rw-r--r--Source/CursesDialog/cmCursesCacheEntryComposite.h26
-rw-r--r--Source/CursesDialog/cmCursesDummyWidget.h9
-rw-r--r--Source/CursesDialog/cmCursesFilePathWidget.h7
-rw-r--r--Source/CursesDialog/cmCursesForm.cxx4
-rw-r--r--Source/CursesDialog/cmCursesForm.h13
-rw-r--r--Source/CursesDialog/cmCursesLabelWidget.cxx4
-rw-r--r--Source/CursesDialog/cmCursesLabelWidget.h15
-rw-r--r--Source/CursesDialog/cmCursesLongMessageForm.cxx30
-rw-r--r--Source/CursesDialog/cmCursesLongMessageForm.h21
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx384
-rw-r--r--Source/CursesDialog/cmCursesMainForm.h45
-rw-r--r--Source/CursesDialog/cmCursesOptionsWidget.cxx8
-rw-r--r--Source/CursesDialog/cmCursesOptionsWidget.h15
-rw-r--r--Source/CursesDialog/cmCursesPathWidget.cxx4
-rw-r--r--Source/CursesDialog/cmCursesPathWidget.h17
-rw-r--r--Source/CursesDialog/cmCursesStandardIncludes.h19
-rw-r--r--Source/CursesDialog/cmCursesStringWidget.cxx44
-rw-r--r--Source/CursesDialog/cmCursesStringWidget.h16
-rw-r--r--Source/CursesDialog/cmCursesWidget.cxx2
-rw-r--r--Source/CursesDialog/cmCursesWidget.h11
-rw-r--r--Source/CursesDialog/form/.gitattributes2
-rw-r--r--Source/CursesDialog/form/CMakeLists.txt17
-rw-r--r--Source/CursesDialog/form/frm_post.c2
-rw-r--r--Source/LexerParser/.gitattributes2
-rw-r--r--Source/LexerParser/cmCTestResourceGroupsLexer.cxx2224
-rw-r--r--Source/LexerParser/cmCTestResourceGroupsLexer.h692
-rw-r--r--Source/LexerParser/cmCTestResourceGroupsLexer.in.l102
-rw-r--r--Source/LexerParser/cmCommandArgumentLexer.cxx698
-rw-r--r--Source/LexerParser/cmCommandArgumentLexer.h441
-rw-r--r--Source/LexerParser/cmCommandArgumentLexer.in.l38
-rw-r--r--Source/LexerParser/cmCommandArgumentParser.cxx309
-rw-r--r--Source/LexerParser/cmCommandArgumentParser.y3
-rw-r--r--Source/LexerParser/cmCommandArgumentParserTokens.h8
-rw-r--r--Source/LexerParser/cmDependsJavaLexer.cxx773
-rw-r--r--Source/LexerParser/cmDependsJavaLexer.h441
-rw-r--r--Source/LexerParser/cmDependsJavaLexer.in.l19
-rw-r--r--Source/LexerParser/cmDependsJavaParser.cxx1637
-rw-r--r--Source/LexerParser/cmDependsJavaParser.y5
-rw-r--r--Source/LexerParser/cmDependsJavaParserTokens.h8
-rw-r--r--Source/LexerParser/cmExprLexer.cxx790
-rw-r--r--Source/LexerParser/cmExprLexer.h441
-rw-r--r--Source/LexerParser/cmExprLexer.in.l26
-rw-r--r--Source/LexerParser/cmExprParser.cxx382
-rw-r--r--Source/LexerParser/cmExprParser.y10
-rw-r--r--Source/LexerParser/cmExprParserTokens.h8
-rw-r--r--Source/LexerParser/cmFortranLexer.cxx973
-rw-r--r--Source/LexerParser/cmFortranLexer.h441
-rw-r--r--Source/LexerParser/cmFortranLexer.in.l19
-rw-r--r--Source/LexerParser/cmFortranParser.cxx325
-rw-r--r--Source/LexerParser/cmFortranParser.y7
-rw-r--r--Source/LexerParser/cmFortranParserTokens.h12
-rw-r--r--Source/LexerParser/cmListFileLexer.c887
-rw-r--r--Source/LexerParser/cmListFileLexer.in.l36
-rw-r--r--Source/Modules/CheckCXXLinkerFlag.cmake29
-rw-r--r--Source/Modules/FindLibUUID.cmake85
-rw-r--r--Source/Modules/FindLibUV.cmake2
-rw-r--r--Source/Modules/OverrideC.cmake3
-rw-r--r--Source/Modules/OverrideCXX.cmake3
-rw-r--r--Source/QtDialog/AddCacheEntry.cxx16
-rw-r--r--Source/QtDialog/AddCacheEntry.h5
-rw-r--r--Source/QtDialog/CMakeLists.txt28
-rw-r--r--Source/QtDialog/CMakeSetup.cxx140
-rw-r--r--Source/QtDialog/CMakeSetup.icnsbin138205 -> 195235 bytes
-rw-r--r--Source/QtDialog/CMakeSetup.icobin24542 -> 159613 bytes
-rw-r--r--Source/QtDialog/CMakeSetup128.pngbin13269 -> 7981 bytes
-rw-r--r--Source/QtDialog/CMakeSetup32.pngbin358 -> 1632 bytes
-rw-r--r--Source/QtDialog/CMakeSetup64.pngbin7213 -> 3566 bytes
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx87
-rw-r--r--Source/QtDialog/CMakeSetupDialog.h19
-rw-r--r--Source/QtDialog/CMakeSetupDialog.ui3
-rw-r--r--Source/QtDialog/Compilers.h12
-rw-r--r--Source/QtDialog/Delete16.pngbin731 -> 538 bytes
-rw-r--r--Source/QtDialog/FirstConfigure.cxx111
-rw-r--r--Source/QtDialog/FirstConfigure.h17
-rw-r--r--Source/QtDialog/Plus16.pngbin358 -> 207 bytes
-rw-r--r--Source/QtDialog/QCMake.cxx157
-rw-r--r--Source/QtDialog/QCMake.h35
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx24
-rw-r--r--Source/QtDialog/QCMakeCacheView.h1
-rw-r--r--Source/QtDialog/QCMakeWidgets.cxx12
-rw-r--r--Source/QtDialog/QCMakeWidgets.h9
-rw-r--r--Source/QtDialog/RegexExplorer.cxx6
-rw-r--r--Source/QtDialog/RegexExplorer.h10
-rw-r--r--Source/QtDialog/WarningMessagesDialog.h6
-rw-r--r--Source/bindexplib.cxx269
-rw-r--r--Source/bindexplib.h10
-rw-r--r--Source/cmAddCompileDefinitionsCommand.cxx16
-rw-r--r--Source/cmAddCompileDefinitionsCommand.h16
-rw-r--r--Source/cmAddCompileOptionsCommand.cxx17
-rw-r--r--Source/cmAddCompileOptionsCommand.h21
-rw-r--r--Source/cmAddCustomCommandCommand.cxx330
-rw-r--r--Source/cmAddCustomCommandCommand.h30
-rw-r--r--Source/cmAddCustomTargetCommand.cxx132
-rw-r--r--Source/cmAddCustomTargetCommand.h28
-rw-r--r--Source/cmAddDefinitionsCommand.cxx19
-rw-r--r--Source/cmAddDefinitionsCommand.h27
-rw-r--r--Source/cmAddDependenciesCommand.cxx56
-rw-r--r--Source/cmAddDependenciesCommand.h26
-rw-r--r--Source/cmAddExecutableCommand.cxx136
-rw-r--r--Source/cmAddExecutableCommand.h27
-rw-r--r--Source/cmAddLibraryCommand.cxx245
-rw-r--r--Source/cmAddLibraryCommand.h27
-rw-r--r--Source/cmAddLinkOptionsCommand.cxx16
-rw-r--r--Source/cmAddLinkOptionsCommand.h16
-rw-r--r--Source/cmAddSubDirectoryCommand.cxx81
-rw-r--r--Source/cmAddSubDirectoryCommand.h28
-rw-r--r--Source/cmAddTestCommand.cxx72
-rw-r--r--Source/cmAddTestCommand.h29
-rw-r--r--Source/cmAffinity.cxx65
-rw-r--r--Source/cmAffinity.h12
-rw-r--r--Source/cmAlgorithms.h320
-rw-r--r--Source/cmArchiveWrite.cxx152
-rw-r--r--Source/cmArchiveWrite.h22
-rw-r--r--Source/cmArgumentParser.cxx97
-rw-r--r--Source/cmArgumentParser.h151
-rw-r--r--Source/cmAuxSourceDirectoryCommand.cxx43
-rw-r--r--Source/cmAuxSourceDirectoryCommand.h30
-rw-r--r--Source/cmBase32.cxx8
-rw-r--r--Source/cmBase32.h2
-rw-r--r--Source/cmBinUtilsLinker.cxx16
-rw-r--r--Source/cmBinUtilsLinker.h30
-rw-r--r--Source/cmBinUtilsLinuxELFGetRuntimeDependenciesTool.cxx19
-rw-r--r--Source/cmBinUtilsLinuxELFGetRuntimeDependenciesTool.h30
-rw-r--r--Source/cmBinUtilsLinuxELFLinker.cxx179
-rw-r--r--Source/cmBinUtilsLinuxELFLinker.h44
-rw-r--r--Source/cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.cxx85
-rw-r--r--Source/cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.h26
-rw-r--r--Source/cmBinUtilsMacOSMachOGetRuntimeDependenciesTool.cxx19
-rw-r--r--Source/cmBinUtilsMacOSMachOGetRuntimeDependenciesTool.h29
-rw-r--r--Source/cmBinUtilsMacOSMachOLinker.cxx231
-rw-r--r--Source/cmBinUtilsMacOSMachOLinker.h59
-rw-r--r--Source/cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.cxx100
-rw-r--r--Source/cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.h25
-rw-r--r--Source/cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.cxx68
-rw-r--r--Source/cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.h25
-rw-r--r--Source/cmBinUtilsWindowsPEGetRuntimeDependenciesTool.cxx19
-rw-r--r--Source/cmBinUtilsWindowsPEGetRuntimeDependenciesTool.h28
-rw-r--r--Source/cmBinUtilsWindowsPELinker.cxx123
-rw-r--r--Source/cmBinUtilsWindowsPELinker.h33
-rw-r--r--Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx68
-rw-r--r--Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h25
-rw-r--r--Source/cmBreakCommand.cxx28
-rw-r--r--Source/cmBreakCommand.h23
-rw-r--r--Source/cmBuildCommand.cxx77
-rw-r--r--Source/cmBuildCommand.h39
-rw-r--r--Source/cmBuildNameCommand.cxx34
-rw-r--r--Source/cmBuildNameCommand.h13
-rw-r--r--Source/cmCLocaleEnvironmentScope.cxx9
-rw-r--r--Source/cmCLocaleEnvironmentScope.h10
-rw-r--r--Source/cmCMakeHostSystemInformationCommand.cxx151
-rw-r--r--Source/cmCMakeHostSystemInformationCommand.h40
-rw-r--r--Source/cmCMakeMinimumRequired.cxx115
-rw-r--r--Source/cmCMakeMinimumRequired.h27
-rw-r--r--Source/cmCMakePolicyCommand.cxx170
-rw-r--r--Source/cmCMakePolicyCommand.h28
-rw-r--r--Source/cmCPackPropertiesGenerator.cxx21
-rw-r--r--Source/cmCPackPropertiesGenerator.h14
-rw-r--r--Source/cmCPluginAPI.cxx193
-rw-r--r--Source/cmCPluginAPI.h19
-rw-r--r--Source/cmCTest.cxx2046
-rw-r--r--Source/cmCTest.h365
-rw-r--r--Source/cmCacheManager.cxx267
-rw-r--r--Source/cmCacheManager.h64
-rw-r--r--Source/cmCallVisualStudioMacro.cxx104
-rw-r--r--Source/cmCallVisualStudioMacro.h14
-rw-r--r--Source/cmCheckCustomOutputs.cxx36
-rw-r--r--Source/cmCheckCustomOutputs.h18
-rw-r--r--Source/cmCommand.cxx42
-rw-r--r--Source/cmCommand.h65
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx107
-rw-r--r--Source/cmCommandArgumentParserHelper.h29
-rw-r--r--Source/cmCommandArgumentsHelper.cxx245
-rw-r--r--Source/cmCommandArgumentsHelper.h196
-rw-r--r--Source/cmCommands.cxx350
-rw-r--r--Source/cmCommonTargetGenerator.cxx83
-rw-r--r--Source/cmCommonTargetGenerator.h6
-rw-r--r--Source/cmComputeComponentGraph.cxx21
-rw-r--r--Source/cmComputeComponentGraph.h10
-rw-r--r--Source/cmComputeLinkDepends.cxx217
-rw-r--r--Source/cmComputeLinkDepends.h57
-rw-r--r--Source/cmComputeLinkInformation.cxx557
-rw-r--r--Source/cmComputeLinkInformation.h65
-rw-r--r--Source/cmComputeTargetDepends.cxx231
-rw-r--r--Source/cmComputeTargetDepends.h17
-rw-r--r--Source/cmConditionEvaluator.cxx117
-rw-r--r--Source/cmConditionEvaluator.h23
-rw-r--r--Source/cmConfigure.cmake.h.in44
-rw-r--r--Source/cmConfigureFileCommand.cxx94
-rw-r--r--Source/cmConfigureFileCommand.h31
-rw-r--r--Source/cmConnection.cxx164
-rw-r--r--Source/cmConnection.h137
-rw-r--r--Source/cmContinueCommand.cxx22
-rw-r--r--Source/cmContinueCommand.h23
-rw-r--r--Source/cmConvertMSBuildXMLToJSON.py21
-rw-r--r--Source/cmCoreTryCompile.cxx536
-rw-r--r--Source/cmCoreTryCompile.h4
-rw-r--r--Source/cmCreateTestSourceList.cxx54
-rw-r--r--Source/cmCreateTestSourceList.h26
-rw-r--r--Source/cmCryptoHash.cxx70
-rw-r--r--Source/cmCryptoHash.h20
-rw-r--r--Source/cmCurl.cxx71
-rw-r--r--Source/cmCurl.h9
-rw-r--r--Source/cmCustomCommand.cxx64
-rw-r--r--Source/cmCustomCommand.h52
-rw-r--r--Source/cmCustomCommandGenerator.cxx182
-rw-r--r--Source/cmCustomCommandGenerator.h23
-rw-r--r--Source/cmCustomCommandLines.cxx22
-rw-r--r--Source/cmCustomCommandLines.h19
-rw-r--r--Source/cmCustomCommandTypes.h39
-rw-r--r--Source/cmDefinePropertyCommand.cxx51
-rw-r--r--Source/cmDefinePropertyCommand.h23
-rw-r--r--Source/cmDefinitions.cxx96
-rw-r--r--Source/cmDefinitions.h63
-rw-r--r--Source/cmDepends.cxx252
-rw-r--r--Source/cmDepends.h51
-rw-r--r--Source/cmDependsC.cxx231
-rw-r--r--Source/cmDependsC.h40
-rw-r--r--Source/cmDependsFortran.cxx350
-rw-r--r--Source/cmDependsFortran.h36
-rw-r--r--Source/cmDependsJava.cxx12
-rw-r--r--Source/cmDependsJava.h22
-rw-r--r--Source/cmDependsJavaParserHelper.cxx90
-rw-r--r--Source/cmDependsJavaParserHelper.h4
-rw-r--r--Source/cmDisallowedCommand.cxx31
-rw-r--r--Source/cmDisallowedCommand.h51
-rw-r--r--Source/cmDocumentation.cxx204
-rw-r--r--Source/cmDocumentation.h25
-rw-r--r--Source/cmDocumentationEntry.h3
-rw-r--r--Source/cmDocumentationFormatter.cxx36
-rw-r--r--Source/cmDocumentationFormatter.h4
-rw-r--r--Source/cmDocumentationSection.cxx6
-rw-r--r--Source/cmDocumentationSection.h9
-rw-r--r--Source/cmDuration.cxx27
-rw-r--r--Source/cmDuration.h24
-rw-r--r--Source/cmDynamicLoader.cxx20
-rw-r--r--Source/cmDynamicLoader.h8
-rw-r--r--Source/cmELF.cxx209
-rw-r--r--Source/cmELF.h14
-rw-r--r--Source/cmEnableLanguageCommand.cxx24
-rw-r--r--Source/cmEnableLanguageCommand.h29
-rw-r--r--Source/cmEnableTestingCommand.cxx11
-rw-r--r--Source/cmEnableTestingCommand.h23
-rw-r--r--Source/cmExecProgramCommand.cxx106
-rw-r--r--Source/cmExecProgramCommand.h31
-rw-r--r--Source/cmExecuteProcessCommand.cxx416
-rw-r--r--Source/cmExecuteProcessCommand.h23
-rw-r--r--Source/cmExecutionStatus.h35
-rw-r--r--Source/cmExpandedCommandArgument.cxx16
-rw-r--r--Source/cmExpandedCommandArgument.h5
-rw-r--r--Source/cmExportBuildAndroidMKGenerator.cxx92
-rw-r--r--Source/cmExportBuildAndroidMKGenerator.h31
-rw-r--r--Source/cmExportBuildFileGenerator.cxx184
-rw-r--r--Source/cmExportBuildFileGenerator.h27
-rw-r--r--Source/cmExportCommand.cxx288
-rw-r--r--Source/cmExportCommand.h54
-rw-r--r--Source/cmExportFileGenerator.cxx391
-rw-r--r--Source/cmExportFileGenerator.h36
-rw-r--r--Source/cmExportInstallAndroidMKGenerator.cxx16
-rw-r--r--Source/cmExportInstallAndroidMKGenerator.h47
-rw-r--r--Source/cmExportInstallFileGenerator.cxx198
-rw-r--r--Source/cmExportInstallFileGenerator.h29
-rw-r--r--Source/cmExportLibraryDependenciesCommand.cxx121
-rw-r--r--Source/cmExportLibraryDependenciesCommand.h24
-rw-r--r--Source/cmExportSet.cxx30
-rw-r--r--Source/cmExportSet.h30
-rw-r--r--Source/cmExportSetMap.cxx29
-rw-r--r--Source/cmExportSetMap.h32
-rw-r--r--Source/cmExportTryCompileFileGenerator.cxx60
-rw-r--r--Source/cmExportTryCompileFileGenerator.h20
-rw-r--r--Source/cmExprParserHelper.cxx64
-rw-r--r--Source/cmExprParserHelper.h17
-rw-r--r--Source/cmExternalMakefileProjectGenerator.cxx23
-rw-r--r--Source/cmExternalMakefileProjectGenerator.h24
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx328
-rw-r--r--Source/cmExtraCodeBlocksGenerator.h15
-rw-r--r--Source/cmExtraCodeLiteGenerator.cxx207
-rw-r--r--Source/cmExtraCodeLiteGenerator.h10
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx417
-rw-r--r--Source/cmExtraEclipseCDT4Generator.h15
-rw-r--r--Source/cmExtraKateGenerator.cxx129
-rw-r--r--Source/cmExtraKateGenerator.h11
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx207
-rw-r--r--Source/cmExtraSublimeTextGenerator.h16
-rw-r--r--Source/cmFLTKWrapUICommand.cxx137
-rw-r--r--Source/cmFLTKWrapUICommand.h49
-rw-r--r--Source/cmFSPermissions.cxx34
-rw-r--r--Source/cmFSPermissions.h45
-rw-r--r--Source/cmFileAPI.cxx832
-rw-r--r--Source/cmFileAPI.h209
-rw-r--r--Source/cmFileAPICMakeFiles.cxx114
-rw-r--r--Source/cmFileAPICMakeFiles.h15
-rw-r--r--Source/cmFileAPICache.cxx106
-rw-r--r--Source/cmFileAPICache.h15
-rw-r--r--Source/cmFileAPICodemodel.cxx1424
-rw-r--r--Source/cmFileAPICodemodel.h15
-rw-r--r--Source/cmFileCommand.cxx3041
-rw-r--r--Source/cmFileCommand.h58
-rw-r--r--Source/cmFileCopier.cxx711
-rw-r--r--Source/cmFileCopier.h124
-rw-r--r--Source/cmFileInstaller.cxx351
-rw-r--r--Source/cmFileInstaller.h54
-rw-r--r--Source/cmFileLock.cxx9
-rw-r--r--Source/cmFileLock.h42
-rw-r--r--Source/cmFileLockPool.cxx38
-rw-r--r--Source/cmFileLockPool.h42
-rw-r--r--Source/cmFileLockResult.cxx35
-rw-r--r--Source/cmFileLockResult.h36
-rw-r--r--Source/cmFileLockUnix.cxx14
-rw-r--r--Source/cmFileLockWin32.cxx5
-rw-r--r--Source/cmFileMonitor.cxx55
-rw-r--r--Source/cmFileMonitor.h6
-rw-r--r--Source/cmFilePathChecksum.cxx59
-rw-r--r--Source/cmFilePathChecksum.h31
-rw-r--r--Source/cmFileTime.cxx50
-rw-r--r--Source/cmFileTime.h130
-rw-r--r--Source/cmFileTimeCache.cxx64
-rw-r--r--Source/cmFileTimeCache.h57
-rw-r--r--Source/cmFileTimeComparison.cxx227
-rw-r--r--Source/cmFileTimeComparison.h39
-rw-r--r--Source/cmFileTimes.cxx129
-rw-r--r--Source/cmFileTimes.h40
-rw-r--r--Source/cmFindBase.cxx69
-rw-r--r--Source/cmFindBase.h6
-rw-r--r--Source/cmFindCommon.cxx113
-rw-r--r--Source/cmFindCommon.h24
-rw-r--r--Source/cmFindFileCommand.cxx11
-rw-r--r--Source/cmFindFileCommand.h16
-rw-r--r--Source/cmFindLibraryCommand.cxx126
-rw-r--r--Source/cmFindLibraryCommand.h21
-rw-r--r--Source/cmFindPackageCommand.cxx834
-rw-r--r--Source/cmFindPackageCommand.h72
-rw-r--r--Source/cmFindPathCommand.cxx52
-rw-r--r--Source/cmFindPathCommand.h21
-rw-r--r--Source/cmFindProgramCommand.cxx92
-rw-r--r--Source/cmFindProgramCommand.h21
-rw-r--r--Source/cmForEachCommand.cxx208
-rw-r--r--Source/cmForEachCommand.h45
-rw-r--r--Source/cmFortranParser.h69
-rw-r--r--Source/cmFortranParserImpl.cxx134
-rw-r--r--Source/cmFunctionBlocker.cxx46
-rw-r--r--Source/cmFunctionBlocker.h33
-rw-r--r--Source/cmFunctionCommand.cxx180
-rw-r--r--Source/cmFunctionCommand.h38
-rw-r--r--Source/cmGeneratedFileStream.cxx72
-rw-r--r--Source/cmGeneratedFileStream.h46
-rw-r--r--Source/cmGeneratorExpression.cxx148
-rw-r--r--Source/cmGeneratorExpression.h115
-rw-r--r--Source/cmGeneratorExpressionContext.cxx14
-rw-r--r--Source/cmGeneratorExpressionContext.h12
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.cxx67
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.h33
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx148
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.h26
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx81
-rw-r--r--Source/cmGeneratorExpressionEvaluator.h42
-rw-r--r--Source/cmGeneratorExpressionLexer.cxx28
-rw-r--r--Source/cmGeneratorExpressionLexer.h6
-rw-r--r--Source/cmGeneratorExpressionNode.cxx2146
-rw-r--r--Source/cmGeneratorExpressionNode.h10
-rw-r--r--Source/cmGeneratorExpressionParser.cxx49
-rw-r--r--Source/cmGeneratorExpressionParser.h3
-rw-r--r--Source/cmGeneratorTarget.cxx3574
-rw-r--r--Source/cmGeneratorTarget.h305
-rw-r--r--Source/cmGetCMakePropertyCommand.cxx23
-rw-r--r--Source/cmGetCMakePropertyCommand.h18
-rw-r--r--Source/cmGetDirectoryPropertyCommand.cxx64
-rw-r--r--Source/cmGetDirectoryPropertyCommand.h21
-rw-r--r--Source/cmGetFilenameComponentCommand.cxx63
-rw-r--r--Source/cmGetFilenameComponentCommand.h23
-rw-r--r--Source/cmGetPipes.cxx49
-rw-r--r--Source/cmGetPipes.h8
-rw-r--r--Source/cmGetPropertyCommand.cxx323
-rw-r--r--Source/cmGetPropertyCommand.h47
-rw-r--r--Source/cmGetSourceFilePropertyCommand.cxx25
-rw-r--r--Source/cmGetSourceFilePropertyCommand.h18
-rw-r--r--Source/cmGetTargetPropertyCommand.cxx36
-rw-r--r--Source/cmGetTargetPropertyCommand.h18
-rw-r--r--Source/cmGetTestPropertyCommand.cxx19
-rw-r--r--Source/cmGetTestPropertyCommand.h18
-rw-r--r--Source/cmGhsMultiGpj.cxx35
-rw-r--r--Source/cmGhsMultiGpj.h12
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx1088
-rw-r--r--Source/cmGhsMultiTargetGenerator.h126
-rw-r--r--Source/cmGlobVerificationManager.cxx179
-rw-r--r--Source/cmGlobVerificationManager.h85
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.cxx33
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.h28
-rw-r--r--Source/cmGlobalCommonGenerator.cxx66
-rw-r--r--Source/cmGlobalCommonGenerator.h28
-rw-r--r--Source/cmGlobalGenerator.cxx1737
-rw-r--r--Source/cmGlobalGenerator.h244
-rw-r--r--Source/cmGlobalGeneratorFactory.h40
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx954
-rw-r--r--Source/cmGlobalGhsMultiGenerator.h191
-rw-r--r--Source/cmGlobalJOMMakefileGenerator.cxx27
-rw-r--r--Source/cmGlobalJOMMakefileGenerator.h20
-rw-r--r--Source/cmGlobalKdevelopGenerator.cxx606
-rw-r--r--Source/cmGlobalKdevelopGenerator.h81
-rw-r--r--Source/cmGlobalMSYSMakefileGenerator.cxx22
-rw-r--r--Source/cmGlobalMSYSMakefileGenerator.h2
-rw-r--r--Source/cmGlobalMinGWMakefileGenerator.cxx10
-rw-r--r--Source/cmGlobalMinGWMakefileGenerator.h2
-rw-r--r--Source/cmGlobalNMakeMakefileGenerator.cxx38
-rw-r--r--Source/cmGlobalNMakeMakefileGenerator.h24
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx1640
-rw-r--r--Source/cmGlobalNinjaGenerator.h227
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx642
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.h91
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx890
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h103
-rw-r--r--Source/cmGlobalVisualStudio11Generator.cxx101
-rw-r--r--Source/cmGlobalVisualStudio11Generator.h26
-rw-r--r--Source/cmGlobalVisualStudio12Generator.cxx80
-rw-r--r--Source/cmGlobalVisualStudio12Generator.h30
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx155
-rw-r--r--Source/cmGlobalVisualStudio14Generator.h29
-rw-r--r--Source/cmGlobalVisualStudio15Generator.cxx206
-rw-r--r--Source/cmGlobalVisualStudio15Generator.h54
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx58
-rw-r--r--Source/cmGlobalVisualStudio71Generator.h28
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx335
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h71
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx334
-rw-r--r--Source/cmGlobalVisualStudio8Generator.h80
-rw-r--r--Source/cmGlobalVisualStudio9Generator.cxx55
-rw-r--r--Source/cmGlobalVisualStudio9Generator.h16
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx454
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h80
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.cxx522
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.h65
-rw-r--r--Source/cmGlobalWatcomWMakeGenerator.cxx32
-rw-r--r--Source/cmGlobalWatcomWMakeGenerator.h29
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx2122
-rw-r--r--Source/cmGlobalXCodeGenerator.h122
-rw-r--r--Source/cmGraphAdjacencyList.h10
-rw-r--r--Source/cmGraphVizWriter.cxx344
-rw-r--r--Source/cmGraphVizWriter.h22
-rw-r--r--Source/cmHexFileConverter.cxx33
-rw-r--r--Source/cmHexFileConverter.h9
-rw-r--r--Source/cmIDEFlagTable.h13
-rw-r--r--Source/cmIDEOptions.cxx105
-rw-r--r--Source/cmIDEOptions.h47
-rw-r--r--Source/cmIfCommand.cxx304
-rw-r--r--Source/cmIfCommand.h63
-rw-r--r--Source/cmIncludeCommand.cxx81
-rw-r--r--Source/cmIncludeCommand.h23
-rw-r--r--Source/cmIncludeDirectoryCommand.cxx72
-rw-r--r--Source/cmIncludeDirectoryCommand.h32
-rw-r--r--Source/cmIncludeExternalMSProjectCommand.cxx47
-rw-r--r--Source/cmIncludeExternalMSProjectCommand.h31
-rw-r--r--Source/cmIncludeGuardCommand.cxx108
-rw-r--r--Source/cmIncludeGuardCommand.h22
-rw-r--r--Source/cmIncludeRegularExpressionCommand.cxx18
-rw-r--r--Source/cmIncludeRegularExpressionCommand.h30
-rw-r--r--Source/cmInstallCommand.cxx1408
-rw-r--r--Source/cmInstallCommand.h41
-rw-r--r--Source/cmInstallCommandArguments.cxx134
-rw-r--r--Source/cmInstallCommandArguments.h39
-rw-r--r--Source/cmInstallDirectoryGenerator.cxx45
-rw-r--r--Source/cmInstallDirectoryGenerator.h16
-rw-r--r--Source/cmInstallExportAndroidMKGenerator.cxx140
-rw-r--r--Source/cmInstallExportAndroidMKGenerator.h37
-rw-r--r--Source/cmInstallExportGenerator.cxx74
-rw-r--r--Source/cmInstallExportGenerator.h21
-rw-r--r--Source/cmInstallFilesCommand.cxx104
-rw-r--r--Source/cmInstallFilesCommand.h46
-rw-r--r--Source/cmInstallFilesGenerator.cxx41
-rw-r--r--Source/cmInstallFilesGenerator.h16
-rw-r--r--Source/cmInstallGenerator.cxx39
-rw-r--r--Source/cmInstallGenerator.h29
-rw-r--r--Source/cmInstallProgramsCommand.cxx79
-rw-r--r--Source/cmInstallProgramsCommand.h45
-rw-r--r--Source/cmInstallScriptGenerator.cxx74
-rw-r--r--Source/cmInstallScriptGenerator.h22
-rw-r--r--Source/cmInstallSubdirectoryGenerator.cxx76
-rw-r--r--Source/cmInstallSubdirectoryGenerator.h41
-rw-r--r--Source/cmInstallTargetGenerator.cxx371
-rw-r--r--Source/cmInstallTargetGenerator.h37
-rw-r--r--Source/cmInstallTargetsCommand.cxx36
-rw-r--r--Source/cmInstallTargetsCommand.h28
-rw-r--r--Source/cmInstalledFile.cxx33
-rw-r--r--Source/cmInstalledFile.h21
-rw-r--r--Source/cmJsonObjectDictionary.h45
-rw-r--r--Source/cmJsonObjects.cxx692
-rw-r--r--Source/cmJsonObjects.h27
-rw-r--r--Source/cmLDConfigLDConfigTool.cxx71
-rw-r--r--Source/cmLDConfigLDConfigTool.h22
-rw-r--r--Source/cmLDConfigTool.cxx9
-rw-r--r--Source/cmLDConfigTool.h24
-rw-r--r--Source/cmLinkDirectoriesCommand.cxx54
-rw-r--r--Source/cmLinkDirectoriesCommand.h32
-rw-r--r--Source/cmLinkItem.cxx64
-rw-r--r--Source/cmLinkItem.h92
-rw-r--r--Source/cmLinkLibrariesCommand.cxx28
-rw-r--r--Source/cmLinkLibrariesCommand.h28
-rw-r--r--Source/cmLinkLineComputer.cxx151
-rw-r--r--Source/cmLinkLineComputer.h25
-rw-r--r--Source/cmLinkLineDeviceComputer.cxx220
-rw-r--r--Source/cmLinkLineDeviceComputer.h42
-rw-r--r--Source/cmLinkedTree.h21
-rw-r--r--Source/cmListCommand.cxx1348
-rw-r--r--Source/cmListCommand.h42
-rw-r--r--Source/cmListFileCache.cxx239
-rw-r--r--Source/cmListFileCache.h103
-rw-r--r--Source/cmListFileLexer.h16
-rw-r--r--Source/cmLoadCacheCommand.cxx78
-rw-r--r--Source/cmLoadCacheCommand.h34
-rw-r--r--Source/cmLoadCommandCommand.cxx262
-rw-r--r--Source/cmLoadCommandCommand.h13
-rw-r--r--Source/cmLocalCommonGenerator.cxx50
-rw-r--r--Source/cmLocalCommonGenerator.h16
-rw-r--r--Source/cmLocalGenerator.cxx2142
-rw-r--r--Source/cmLocalGenerator.h203
-rw-r--r--Source/cmLocalGhsMultiGenerator.cxx87
-rw-r--r--Source/cmLocalGhsMultiGenerator.h24
-rw-r--r--Source/cmLocalNinjaGenerator.cxx292
-rw-r--r--Source/cmLocalNinjaGenerator.h35
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx846
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h114
-rw-r--r--Source/cmLocalVisualStudio10Generator.cxx70
-rw-r--r--Source/cmLocalVisualStudio10Generator.h23
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx870
-rw-r--r--Source/cmLocalVisualStudio7Generator.h37
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx50
-rw-r--r--Source/cmLocalVisualStudioGenerator.h14
-rw-r--r--Source/cmLocalXCodeGenerator.cxx35
-rw-r--r--Source/cmLocalXCodeGenerator.h18
-rw-r--r--Source/cmLocale.h12
-rw-r--r--Source/cmMSVC60LinkLineComputer.cxx2
-rw-r--r--Source/cmMSVC60LinkLineComputer.h11
-rw-r--r--Source/cmMachO.cxx43
-rw-r--r--Source/cmMachO.h8
-rw-r--r--Source/cmMacroCommand.cxx192
-rw-r--r--Source/cmMacroCommand.h38
-rw-r--r--Source/cmMakeDirectoryCommand.cxx15
-rw-r--r--Source/cmMakeDirectoryCommand.h23
-rw-r--r--Source/cmMakefile.cxx2656
-rw-r--r--Source/cmMakefile.h614
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx265
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.h6
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx420
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.h13
-rw-r--r--Source/cmMakefileTargetGenerator.cxx1019
-rw-r--r--Source/cmMakefileTargetGenerator.h42
-rw-r--r--Source/cmMakefileUtilityTargetGenerator.cxx23
-rw-r--r--Source/cmMakefileUtilityTargetGenerator.h6
-rw-r--r--Source/cmMarkAsAdvancedCommand.cxx15
-rw-r--r--Source/cmMarkAsAdvancedCommand.h23
-rw-r--r--Source/cmMathCommand.cxx99
-rw-r--r--Source/cmMathCommand.h24
-rw-r--r--Source/cmMessageCommand.cxx136
-rw-r--r--Source/cmMessageCommand.h23
-rw-r--r--Source/cmMessageType.h21
-rw-r--r--Source/cmMessenger.cxx117
-rw-r--r--Source/cmMessenger.h52
-rw-r--r--Source/cmNewLineStyle.cxx9
-rw-r--r--Source/cmNewLineStyle.h4
-rw-r--r--Source/cmNinjaLinkLineComputer.h10
-rw-r--r--Source/cmNinjaLinkLineDeviceComputer.cxx20
-rw-r--r--Source/cmNinjaLinkLineDeviceComputer.h34
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx840
-rw-r--r--Source/cmNinjaNormalTargetGenerator.h17
-rw-r--r--Source/cmNinjaTargetGenerator.cxx1142
-rw-r--r--Source/cmNinjaTargetGenerator.h47
-rw-r--r--Source/cmNinjaTypes.h47
-rw-r--r--Source/cmNinjaUtilityTargetGenerator.cxx162
-rw-r--r--Source/cmNinjaUtilityTargetGenerator.h6
-rw-r--r--Source/cmOSXBundleGenerator.cxx114
-rw-r--r--Source/cmOSXBundleGenerator.h5
-rw-r--r--Source/cmOptionCommand.cxx99
-rw-r--r--Source/cmOptionCommand.h24
-rw-r--r--Source/cmOrderDirectories.cxx125
-rw-r--r--Source/cmOrderDirectories.h11
-rw-r--r--Source/cmOutputConverter.cxx373
-rw-r--r--Source/cmOutputConverter.h52
-rw-r--r--Source/cmOutputRequiredFilesCommand.cxx220
-rw-r--r--Source/cmOutputRequiredFilesCommand.h23
-rw-r--r--Source/cmParseArgumentsCommand.cxx283
-rw-r--r--Source/cmParseArgumentsCommand.h24
-rw-r--r--Source/cmPathLabel.cxx10
-rw-r--r--Source/cmPathLabel.h2
-rw-r--r--Source/cmPipeConnection.cxx71
-rw-r--r--Source/cmPipeConnection.h29
-rw-r--r--Source/cmPolicies.cxx193
-rw-r--r--Source/cmPolicies.h122
-rw-r--r--Source/cmProcessOutput.cxx8
-rw-r--r--Source/cmProcessOutput.h10
-rw-r--r--Source/cmProcessTools.cxx27
-rw-r--r--Source/cmProcessTools.h26
-rw-r--r--Source/cmProjectCommand.cxx381
-rw-r--r--Source/cmProjectCommand.h29
-rw-r--r--Source/cmProperty.cxx28
-rw-r--r--Source/cmProperty.h18
-rw-r--r--Source/cmPropertyDefinition.h4
-rw-r--r--Source/cmPropertyDefinitionMap.cxx4
-rw-r--r--Source/cmPropertyDefinitionMap.h6
-rw-r--r--Source/cmPropertyMap.cxx79
-rw-r--r--Source/cmPropertyMap.h34
-rw-r--r--Source/cmQTWrapCPPCommand.cxx67
-rw-r--r--Source/cmQTWrapCPPCommand.h27
-rw-r--r--Source/cmQTWrapUICommand.cxx116
-rw-r--r--Source/cmQTWrapUICommand.h26
-rw-r--r--Source/cmQtAutoGen.cxx385
-rw-r--r--Source/cmQtAutoGen.h145
-rw-r--r--Source/cmQtAutoGenGlobalInitializer.cxx289
-rw-r--r--Source/cmQtAutoGenGlobalInitializer.h86
-rw-r--r--Source/cmQtAutoGenInitializer.cxx1735
-rw-r--r--Source/cmQtAutoGenInitializer.h248
-rw-r--r--Source/cmQtAutoGenerator.cxx492
-rw-r--r--Source/cmQtAutoGenerator.h181
-rw-r--r--Source/cmQtAutoGeneratorCommon.cxx216
-rw-r--r--Source/cmQtAutoGeneratorCommon.h39
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx1131
-rw-r--r--Source/cmQtAutoGeneratorInitializer.h20
-rw-r--r--Source/cmQtAutoGenerators.cxx2066
-rw-r--r--Source/cmQtAutoGenerators.h222
-rw-r--r--Source/cmQtAutoMocUic.cxx2688
-rw-r--r--Source/cmQtAutoMocUic.h16
-rw-r--r--Source/cmQtAutoRcc.cxx503
-rw-r--r--Source/cmQtAutoRcc.h16
-rw-r--r--Source/cmRST.cxx140
-rw-r--r--Source/cmRST.h7
-rw-r--r--Source/cmRange.h239
-rw-r--r--Source/cmRemoveCommand.cxx30
-rw-r--r--Source/cmRemoveCommand.h23
-rw-r--r--Source/cmRemoveDefinitionsCommand.cxx19
-rw-r--r--Source/cmRemoveDefinitionsCommand.h28
-rw-r--r--Source/cmReturnCommand.cxx4
-rw-r--r--Source/cmReturnCommand.h27
-rw-r--r--Source/cmRulePlaceholderExpander.cxx53
-rw-r--r--Source/cmRulePlaceholderExpander.h13
-rw-r--r--Source/cmRuntimeDependencyArchive.cxx378
-rw-r--r--Source/cmRuntimeDependencyArchive.h70
-rw-r--r--Source/cmScriptGenerator.cxx54
-rw-r--r--Source/cmScriptGenerator.h22
-rw-r--r--Source/cmSearchPath.cxx82
-rw-r--r--Source/cmSearchPath.h10
-rw-r--r--Source/cmSeparateArgumentsCommand.cxx43
-rw-r--r--Source/cmSeparateArgumentsCommand.h23
-rw-r--r--Source/cmServer.cxx329
-rw-r--r--Source/cmServer.h144
-rw-r--r--Source/cmServerConnection.cxx418
-rw-r--r--Source/cmServerConnection.h106
-rw-r--r--Source/cmServerDictionary.h31
-rw-r--r--Source/cmServerProtocol.cxx697
-rw-r--r--Source/cmServerProtocol.h37
-rw-r--r--Source/cmSetCommand.cxx73
-rw-r--r--Source/cmSetCommand.h23
-rw-r--r--Source/cmSetDirectoryPropertiesCommand.cxx29
-rw-r--r--Source/cmSetDirectoryPropertiesCommand.h30
-rw-r--r--Source/cmSetPropertyCommand.cxx480
-rw-r--r--Source/cmSetPropertyCommand.h47
-rw-r--r--Source/cmSetSourceFilesPropertiesCommand.cxx55
-rw-r--r--Source/cmSetSourceFilesPropertiesCommand.h29
-rw-r--r--Source/cmSetTargetPropertiesCommand.cxx48
-rw-r--r--Source/cmSetTargetPropertiesCommand.h26
-rw-r--r--Source/cmSetTestsPropertiesCommand.cxx38
-rw-r--r--Source/cmSetTestsPropertiesCommand.h23
-rw-r--r--Source/cmSiteNameCommand.cxx35
-rw-r--r--Source/cmSiteNameCommand.h23
-rw-r--r--Source/cmSourceFile.cxx307
-rw-r--r--Source/cmSourceFile.h94
-rw-r--r--Source/cmSourceFileLocation.cxx91
-rw-r--r--Source/cmSourceFileLocation.h25
-rw-r--r--Source/cmSourceFileLocationKind.h15
-rw-r--r--Source/cmSourceGroup.cxx72
-rw-r--r--Source/cmSourceGroup.h23
-rw-r--r--Source/cmSourceGroupCommand.cxx346
-rw-r--r--Source/cmSourceGroupCommand.h33
-rw-r--r--Source/cmStandardLexer.h48
-rw-r--r--Source/cmState.cxx371
-rw-r--r--Source/cmState.h96
-rw-r--r--Source/cmStateDirectory.cxx250
-rw-r--r--Source/cmStateDirectory.h32
-rw-r--r--Source/cmStatePrivate.h13
-rw-r--r--Source/cmStateSnapshot.cxx110
-rw-r--r--Source/cmStateSnapshot.h12
-rw-r--r--Source/cmStateTypes.h2
-rw-r--r--Source/cmString.cxx152
-rw-r--r--Source/cmString.hxx817
-rw-r--r--Source/cmStringAlgorithms.cxx325
-rw-r--r--Source/cmStringAlgorithms.h294
-rw-r--r--Source/cmStringCommand.cxx662
-rw-r--r--Source/cmStringCommand.h70
-rw-r--r--Source/cmStringReplaceHelper.cxx121
-rw-r--r--Source/cmStringReplaceHelper.h68
-rw-r--r--Source/cmSubcommandTable.cxx31
-rw-r--r--Source/cmSubcommandTable.h37
-rw-r--r--Source/cmSubdirCommand.cxx41
-rw-r--r--Source/cmSubdirCommand.h28
-rw-r--r--Source/cmSubdirDependsCommand.cxx4
-rw-r--r--Source/cmSubdirDependsCommand.h13
-rw-r--r--Source/cmSystemTools.cxx1569
-rw-r--r--Source/cmSystemTools.h307
-rw-r--r--Source/cmTarget.cxx1629
-rw-r--r--Source/cmTarget.h289
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.cxx87
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.h35
-rw-r--r--Source/cmTargetCompileFeaturesCommand.cxx82
-rw-r--r--Source/cmTargetCompileFeaturesCommand.h24
-rw-r--r--Source/cmTargetCompileOptionsCommand.cxx77
-rw-r--r--Source/cmTargetCompileOptionsCommand.h32
-rw-r--r--Source/cmTargetDepend.h10
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx99
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.h39
-rw-r--r--Source/cmTargetLinkDirectoriesCommand.cxx70
-rw-r--r--Source/cmTargetLinkDirectoriesCommand.h16
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx519
-rw-r--r--Source/cmTargetLinkLibrariesCommand.h50
-rw-r--r--Source/cmTargetLinkOptionsCommand.cxx50
-rw-r--r--Source/cmTargetLinkOptionsCommand.h16
-rw-r--r--Source/cmTargetPrecompileHeadersCommand.cxx87
-rw-r--r--Source/cmTargetPrecompileHeadersCommand.h16
-rw-r--r--Source/cmTargetPropCommandBase.cxx62
-rw-r--r--Source/cmTargetPropCommandBase.h24
-rw-r--r--Source/cmTargetPropertyComputer.cxx55
-rw-r--r--Source/cmTargetPropertyComputer.h16
-rw-r--r--Source/cmTargetSourcesCommand.cxx144
-rw-r--r--Source/cmTargetSourcesCommand.h33
-rw-r--r--Source/cmTest.cxx21
-rw-r--r--Source/cmTest.h15
-rw-r--r--Source/cmTestGenerator.cxx138
-rw-r--r--Source/cmTestGenerator.h35
-rw-r--r--Source/cmTimestamp.cxx40
-rw-r--r--Source/cmTimestamp.h10
-rw-r--r--Source/cmTryCompileCommand.cxx5
-rw-r--r--Source/cmTryCompileCommand.h15
-rw-r--r--Source/cmTryRunCommand.cxx145
-rw-r--r--Source/cmTryRunCommand.h15
-rw-r--r--Source/cmUVHandlePtr.cxx267
-rw-r--r--Source/cmUVHandlePtr.h271
-rw-r--r--Source/cmUVProcessChain.cxx396
-rw-r--r--Source/cmUVProcessChain.h100
-rw-r--r--Source/cmUVSignalHackRAII.h45
-rw-r--r--Source/cmUVStreambuf.h219
-rw-r--r--Source/cmUnexpectedCommand.cxx22
-rw-r--r--Source/cmUnexpectedCommand.h37
-rw-r--r--Source/cmUnsetCommand.cxx34
-rw-r--r--Source/cmUnsetCommand.h23
-rw-r--r--Source/cmUseMangledMesaCommand.cxx79
-rw-r--r--Source/cmUseMangledMesaCommand.h16
-rw-r--r--Source/cmUtilitySourceCommand.cxx80
-rw-r--r--Source/cmUtilitySourceCommand.h13
-rw-r--r--Source/cmUtils.hxx2
-rw-r--r--Source/cmUuid.cxx30
-rw-r--r--Source/cmUuid.h4
-rw-r--r--Source/cmVS10CLFlagTable.h204
-rw-r--r--Source/cmVS10CSharpFlagTable.h120
-rw-r--r--Source/cmVS10CudaFlagTable.h51
-rw-r--r--Source/cmVS10CudaHostFlagTable.h35
-rw-r--r--Source/cmVS10LibFlagTable.h76
-rw-r--r--Source/cmVS10LinkFlagTable.h244
-rw-r--r--Source/cmVS10MASMFlagTable.h76
-rw-r--r--Source/cmVS10NASMFlagTable.h50
-rw-r--r--Source/cmVS10RCFlagTable.h7
-rw-r--r--Source/cmVS11CLFlagTable.h219
-rw-r--r--Source/cmVS11CSharpFlagTable.h120
-rw-r--r--Source/cmVS11LibFlagTable.h76
-rw-r--r--Source/cmVS11LinkFlagTable.h269
-rw-r--r--Source/cmVS11MASMFlagTable.h76
-rw-r--r--Source/cmVS11RCFlagTable.h7
-rw-r--r--Source/cmVS12CLFlagTable.h221
-rw-r--r--Source/cmVS12CSharpFlagTable.h120
-rw-r--r--Source/cmVS12LibFlagTable.h76
-rw-r--r--Source/cmVS12LinkFlagTable.h269
-rw-r--r--Source/cmVS12MASMFlagTable.h76
-rw-r--r--Source/cmVS12RCFlagTable.h7
-rw-r--r--Source/cmVS140CLFlagTable.h239
-rw-r--r--Source/cmVS140CSharpFlagTable.h120
-rw-r--r--Source/cmVS140LinkFlagTable.h282
-rw-r--r--Source/cmVS141CLFlagTable.h250
-rw-r--r--Source/cmVS141CSharpFlagTable.h120
-rw-r--r--Source/cmVS141LinkFlagTable.h283
-rw-r--r--Source/cmVS14LibFlagTable.h76
-rw-r--r--Source/cmVS14MASMFlagTable.h76
-rw-r--r--Source/cmVS14RCFlagTable.h7
-rw-r--r--Source/cmVSSetupHelper.cxx171
-rw-r--r--Source/cmVSSetupHelper.h58
-rw-r--r--Source/cmVariableRequiresCommand.cxx35
-rw-r--r--Source/cmVariableRequiresCommand.h13
-rw-r--r--Source/cmVariableWatch.cxx51
-rw-r--r--Source/cmVariableWatch.h32
-rw-r--r--Source/cmVariableWatchCommand.cxx101
-rw-r--r--Source/cmVariableWatchCommand.h37
-rw-r--r--Source/cmVersionMacros.h2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx4359
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h214
-rw-r--r--Source/cmVisualStudio10ToolsetOptions.cxx127
-rw-r--r--Source/cmVisualStudio10ToolsetOptions.h30
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx328
-rw-r--r--Source/cmVisualStudioGeneratorOptions.h35
-rw-r--r--Source/cmVisualStudioSlnData.h6
-rw-r--r--Source/cmVisualStudioSlnParser.cxx39
-rw-r--r--Source/cmVisualStudioSlnParser.h7
-rw-r--r--Source/cmVisualStudioWCEPlatformParser.cxx8
-rw-r--r--Source/cmVisualStudioWCEPlatformParser.h5
-rw-r--r--Source/cmWhileCommand.cxx210
-rw-r--r--Source/cmWhileCommand.h53
-rw-r--r--Source/cmWorkerPool.cxx763
-rw-r--r--Source/cmWorkerPool.h225
-rw-r--r--Source/cmWorkingDirectory.cxx16
-rw-r--r--Source/cmWorkingDirectory.h20
-rw-r--r--Source/cmWriteFileCommand.cxx43
-rw-r--r--Source/cmWriteFileCommand.h23
-rw-r--r--Source/cmXCode21Object.cxx8
-rw-r--r--Source/cmXCode21Object.h2
-rw-r--r--Source/cmXCodeObject.cxx50
-rw-r--r--Source/cmXCodeObject.h28
-rw-r--r--Source/cmXCodeScheme.cxx278
-rw-r--r--Source/cmXCodeScheme.h40
-rw-r--r--Source/cmXMLParser.cxx28
-rw-r--r--Source/cmXMLParser.h2
-rw-r--r--Source/cmXMLSafe.cxx8
-rw-r--r--Source/cmXMLWriter.cxx34
-rw-r--r--Source/cmXMLWriter.h106
-rw-r--r--Source/cm_auto_ptr.hxx220
-rw-r--r--Source/cm_codecvt.cxx23
-rw-r--r--Source/cm_codecvt.hxx22
-rw-r--r--Source/cm_get_date.h2
-rw-r--r--Source/cm_static_string_view.hxx41
-rw-r--r--Source/cm_sys_stat.h4
-rw-r--r--Source/cm_unordered_map.hxx25
-rw-r--r--Source/cm_unordered_set.hxx25
-rw-r--r--Source/cm_utf8.c29
-rw-r--r--Source/cm_utf8.h4
-rw-r--r--Source/cmake.cxx1529
-rw-r--r--Source/cmake.h410
-rw-r--r--Source/cmakemain.cxx607
-rw-r--r--Source/cmakexbuild.cxx77
-rw-r--r--Source/cmcldeps.cxx12
-rw-r--r--Source/cmcmd.cxx1272
-rw-r--r--Source/cmcmd.h17
-rwxr-xr-xSource/cmparseMSBuildXML.py341
-rw-r--r--Source/ctest.cxx142
-rw-r--r--Source/kwsys/Base64.c2
-rw-r--r--Source/kwsys/Base64.h.in40
-rw-r--r--Source/kwsys/CMakeLists.txt380
-rw-r--r--Source/kwsys/CONTRIBUTING.rst2
-rw-r--r--Source/kwsys/CommandLineArguments.cxx65
-rw-r--r--Source/kwsys/CommandLineArguments.hxx.in3
-rw-r--r--Source/kwsys/Configure.h.in134
-rw-r--r--Source/kwsys/Configure.hxx.in52
-rw-r--r--Source/kwsys/ConsoleBuf.hxx.in34
-rw-r--r--Source/kwsys/Directory.cxx82
-rw-r--r--Source/kwsys/DynamicLoader.cxx185
-rw-r--r--Source/kwsys/DynamicLoader.hxx.in39
-rw-r--r--Source/kwsys/Encoding.h.in32
-rw-r--r--Source/kwsys/Encoding.hxx.in10
-rw-r--r--Source/kwsys/EncodingC.c4
-rw-r--r--Source/kwsys/EncodingCXX.cxx59
-rw-r--r--Source/kwsys/FStream.cxx2
-rw-r--r--Source/kwsys/FStream.hxx.in60
-rw-r--r--Source/kwsys/Glob.cxx33
-rw-r--r--Source/kwsys/Glob.hxx.in16
-rw-r--r--Source/kwsys/IOStream.cxx38
-rw-r--r--Source/kwsys/IOStream.hxx.in76
-rw-r--r--Source/kwsys/MD5.c20
-rw-r--r--Source/kwsys/MD5.h.in48
-rw-r--r--Source/kwsys/Process.h.in338
-rw-r--r--Source/kwsys/ProcessUNIX.c122
-rw-r--r--Source/kwsys/ProcessWin32.c109
-rw-r--r--Source/kwsys/RegularExpression.cxx358
-rw-r--r--Source/kwsys/RegularExpression.hxx.in269
-rw-r--r--Source/kwsys/SharedForward.h.in453
-rw-r--r--Source/kwsys/String.c42
-rw-r--r--Source/kwsys/String.h.in20
-rw-r--r--Source/kwsys/System.c2
-rw-r--r--Source/kwsys/System.h.in17
-rw-r--r--Source/kwsys/SystemInformation.cxx839
-rw-r--r--Source/kwsys/SystemInformation.hxx.in21
-rw-r--r--Source/kwsys/SystemTools.cxx1733
-rw-r--r--Source/kwsys/SystemTools.hxx.in144
-rw-r--r--Source/kwsys/Terminal.c80
-rw-r--r--Source/kwsys/Terminal.h.in158
-rw-r--r--Source/kwsys/hash_map.hxx.in18
-rw-r--r--Source/kwsys/hash_set.hxx.in18
-rw-r--r--Source/kwsys/hashtable.hxx.in114
-rw-r--r--Source/kwsys/kwsysPlatformTests.cmake5
-rw-r--r--Source/kwsys/kwsysPlatformTestsC.c65
-rw-r--r--Source/kwsys/kwsysPlatformTestsCXX.cxx142
-rw-r--r--Source/kwsys/kwsysPrivate.h16
-rw-r--r--Source/kwsys/testCommandLineArguments.cxx45
-rw-r--r--Source/kwsys/testCommandLineArguments1.cxx8
-rw-r--r--Source/kwsys/testConfigure.cxx30
-rw-r--r--Source/kwsys/testConsoleBuf.cxx133
-rw-r--r--Source/kwsys/testConsoleBufChild.cxx4
-rw-r--r--Source/kwsys/testDirectory.cxx110
-rw-r--r--Source/kwsys/testDynamicLoader.cxx32
-rw-r--r--Source/kwsys/testDynload.c4
-rw-r--r--Source/kwsys/testDynloadImpl.c10
-rw-r--r--Source/kwsys/testDynloadImpl.h15
-rw-r--r--Source/kwsys/testDynloadUse.c15
-rw-r--r--Source/kwsys/testEncode.c2
-rw-r--r--Source/kwsys/testEncoding.cxx15
-rw-r--r--Source/kwsys/testFStream.cxx6
-rw-r--r--Source/kwsys/testHashSTL.cxx9
-rw-r--r--Source/kwsys/testIOS.cxx139
-rw-r--r--Source/kwsys/testProcess.c65
-rw-r--r--Source/kwsys/testSharedForward.c.in10
-rw-r--r--Source/kwsys/testSystemInformation.cxx26
-rw-r--r--Source/kwsys/testSystemTools.cxx343
-rw-r--r--Source/kwsys/testTerminal.c2
-rw-r--r--Templates/MSBuild/FlagTables/v10_CL.json981
-rw-r--r--Templates/MSBuild/FlagTables/v10_CSharp.json574
-rw-r--r--Templates/MSBuild/FlagTables/v10_Cuda.json224
-rw-r--r--Templates/MSBuild/FlagTables/v10_CudaHost.json149
-rw-r--r--Templates/MSBuild/FlagTables/v10_LIB.json297
-rw-r--r--Templates/MSBuild/FlagTables/v10_Link.json1137
-rw-r--r--Templates/MSBuild/FlagTables/v10_MASM.json295
-rw-r--r--Templates/MSBuild/FlagTables/v10_NASM.json201
-rw-r--r--Templates/MSBuild/FlagTables/v10_RC.json69
-rw-r--r--Templates/MSBuild/FlagTables/v11_CL.json1063
-rw-r--r--Templates/MSBuild/FlagTables/v11_CSharp.json574
-rw-r--r--Templates/MSBuild/FlagTables/v11_LIB.json297
-rw-r--r--Templates/MSBuild/FlagTables/v11_Link.json1272
-rw-r--r--Templates/MSBuild/FlagTables/v11_MASM.json295
-rw-r--r--Templates/MSBuild/FlagTables/v11_RC.json69
-rw-r--r--Templates/MSBuild/FlagTables/v12_CL.json1077
-rw-r--r--Templates/MSBuild/FlagTables/v12_CSharp.json574
-rw-r--r--Templates/MSBuild/FlagTables/v12_LIB.json297
-rw-r--r--Templates/MSBuild/FlagTables/v12_Link.json1272
-rw-r--r--Templates/MSBuild/FlagTables/v12_MASM.json295
-rw-r--r--Templates/MSBuild/FlagTables/v12_RC.json69
-rw-r--r--Templates/MSBuild/FlagTables/v140_CL.json1184
-rw-r--r--Templates/MSBuild/FlagTables/v140_CSharp.json574
-rw-r--r--Templates/MSBuild/FlagTables/v140_Link.json1316
-rw-r--r--Templates/MSBuild/FlagTables/v141_CL.json1268
-rw-r--r--Templates/MSBuild/FlagTables/v141_CSharp.json574
-rw-r--r--Templates/MSBuild/FlagTables/v141_Link.json1323
-rw-r--r--Templates/MSBuild/FlagTables/v142_CL.json1212
-rw-r--r--Templates/MSBuild/FlagTables/v142_CSharp.json574
-rw-r--r--Templates/MSBuild/FlagTables/v142_Link.json1323
-rw-r--r--Templates/MSBuild/FlagTables/v14_LIB.json304
-rw-r--r--Templates/MSBuild/FlagTables/v14_MASM.json295
-rw-r--r--Templates/MSBuild/FlagTables/v14_RC.json69
-rw-r--r--Templates/MSBuild/nasm.xml6
-rw-r--r--Templates/TestDriver.cxx.in30
-rw-r--r--Templates/Windows/ApplicationIcon.pngbin3392 -> 2335 bytes
-rw-r--r--Templates/Windows/Logo.pngbin801 -> 488 bytes
-rw-r--r--Templates/Windows/SmallLogo.pngbin329 -> 167 bytes
-rw-r--r--Templates/Windows/SmallLogo44x44.pngbin554 -> 265 bytes
-rw-r--r--Templates/Windows/SplashScreen.pngbin2146 -> 909 bytes
-rw-r--r--Templates/Windows/StoreLogo.pngbin429 -> 227 bytes
-rw-r--r--Tests/AliasTarget/CMakeLists.txt7
-rw-r--r--Tests/AliasTarget/bat.cpp8
-rw-r--r--Tests/Assembler/CMakeLists.txt5
-rw-r--r--Tests/BuildDepends/CMakeLists.txt29
-rw-r--r--Tests/BuildDepends/Project/CMakeLists.txt47
-rw-r--r--Tests/BuildDepends/Project/ninjadep.cpp3
-rw-r--r--Tests/BuildDepends/Project/zot.cxx5
-rw-r--r--Tests/BuildDepends/Project/zot_pch.cxx6
-rw-r--r--Tests/BundleTest/BundleLib.cxx5
-rw-r--r--Tests/BundleTest/BundleSubDir/CMakeLists.txt13
-rw-r--r--Tests/BundleTest/BundleTest.cxx3
-rw-r--r--Tests/BundleTest/CMakeLists.txt6
-rw-r--r--Tests/BundleUtilities/framework.cpp1
-rw-r--r--Tests/BundleUtilities/framework.h12
-rw-r--r--Tests/BundleUtilities/module.cpp1
-rw-r--r--Tests/BundleUtilities/shared.cpp1
-rw-r--r--Tests/BundleUtilities/shared.h12
-rw-r--r--Tests/BundleUtilities/shared2.cpp1
-rw-r--r--Tests/BundleUtilities/shared2.h12
-rw-r--r--Tests/BundleUtilities/testbundleutils1.cpp4
-rw-r--r--Tests/BundleUtilities/testbundleutils2.cpp4
-rw-r--r--Tests/BundleUtilities/testbundleutils3.cpp4
-rw-r--r--Tests/CFBundleTest/CMakeLists.txt2
-rw-r--r--Tests/CFBundleTest/np_macmain.cpp2
-rw-r--r--Tests/CMakeBuildTest.cmake.in9
-rw-r--r--Tests/CMakeCommands/add_compile_definitions/CMakeLists.txt15
-rw-r--r--Tests/CMakeCommands/add_compile_definitions/main.cpp17
-rw-r--r--Tests/CMakeCommands/add_compile_options/main.cpp6
-rw-r--r--Tests/CMakeCommands/add_link_options/CMakeLists.txt20
-rw-r--r--Tests/CMakeCommands/add_link_options/LinkOptionsExe.c4
-rw-r--r--Tests/CMakeCommands/link_directories/CMakeLists.txt30
-rw-r--r--Tests/CMakeCommands/link_directories/LinkDirectoriesExe.c4
-rw-r--r--Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt23
-rw-r--r--Tests/CMakeCommands/target_compile_definitions/consumer.c46
-rw-r--r--Tests/CMakeCommands/target_compile_definitions/consumer.cpp18
-rw-r--r--Tests/CMakeCommands/target_compile_definitions/main.cpp6
-rw-r--r--Tests/CMakeCommands/target_compile_features/CMakeLists.txt6
-rw-r--r--Tests/CMakeCommands/target_compile_options/CMakeLists.txt41
-rw-r--r--Tests/CMakeCommands/target_compile_options/consumer.c44
-rw-r--r--Tests/CMakeCommands/target_compile_options/consumer.cpp50
-rw-r--r--Tests/CMakeCommands/target_compile_options/main.cpp36
-rw-r--r--Tests/CMakeCommands/target_include_directories/CMakeLists.txt20
-rw-r--r--Tests/CMakeCommands/target_include_directories/consumer.c18
-rw-r--r--Tests/CMakeCommands/target_include_directories/consumer.cpp21
-rw-r--r--Tests/CMakeCommands/target_include_directories/main.cpp8
-rw-r--r--Tests/CMakeCommands/target_link_directories/CMakeLists.txt40
-rw-r--r--Tests/CMakeCommands/target_link_directories/LinkDirectoriesLib.c7
-rw-r--r--Tests/CMakeCommands/target_link_directories/subdir/CMakeLists.txt2
-rw-r--r--Tests/CMakeCommands/target_link_libraries/CMakeLists.txt16
-rw-r--r--Tests/CMakeCommands/target_link_libraries/SubDirA/CMakeLists.txt15
-rw-r--r--Tests/CMakeCommands/target_link_libraries/SubDirA/SubDirA.c14
-rw-r--r--Tests/CMakeCommands/target_link_libraries/SubDirB/CMakeLists.txt15
-rw-r--r--Tests/CMakeCommands/target_link_libraries/SubDirB/SubDirB.c14
-rw-r--r--Tests/CMakeCommands/target_link_libraries/SubDirC/CMakeLists.txt9
-rw-r--r--Tests/CMakeCommands/target_link_libraries/SubDirC/SubDirC.c11
-rw-r--r--Tests/CMakeCommands/target_link_libraries/TopDir.c20
-rw-r--r--Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022lib.h3
-rw-r--r--Tests/CMakeCommands/target_link_libraries/depB.cpp1
-rw-r--r--Tests/CMakeCommands/target_link_libraries/depC.h3
-rw-r--r--Tests/CMakeCommands/target_link_libraries/depD.h3
-rw-r--r--Tests/CMakeCommands/target_link_libraries/libgenex.h2
-rw-r--r--Tests/CMakeCommands/target_link_libraries/newsignature1.cpp1
-rw-r--r--Tests/CMakeCommands/target_link_libraries/targetA.cpp1
-rw-r--r--Tests/CMakeCommands/target_link_libraries/targetC.cpp5
-rw-r--r--Tests/CMakeCommands/target_link_options/CMakeLists.txt34
-rw-r--r--Tests/CMakeCommands/target_link_options/LinkOptionsLib.c7
-rw-r--r--Tests/CMakeCommands/target_sources/CMakeLists.txt36
-rw-r--r--Tests/CMakeCommands/target_sources/empty_1.cpp21
-rw-r--r--Tests/CMakeCommands/target_sources/empty_2.cpp7
-rw-r--r--Tests/CMakeCommands/target_sources/empty_3.cpp7
-rw-r--r--Tests/CMakeCommands/target_sources/main.cpp16
-rw-r--r--Tests/CMakeCommands/target_sources/subdir/CMakeLists.txt6
-rw-r--r--Tests/CMakeCommands/target_sources/subdir/subdir_empty_1.cpp21
-rw-r--r--Tests/CMakeCommands/target_sources/subdir/subdir_empty_2.cpp21
-rw-r--r--Tests/CMakeInstall.cmake13
-rw-r--r--Tests/CMakeLib/CMakeLists.txt47
-rw-r--r--Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in6
-rw-r--r--Tests/CMakeLib/run_compile_commands.cxx23
-rw-r--r--Tests/CMakeLib/testAffinity.cxx18
-rw-r--r--Tests/CMakeLib/testArgumentParser.cxx149
-rw-r--r--Tests/CMakeLib/testCTestBinPacker.cxx300
-rw-r--r--Tests/CMakeLib/testCTestResourceAllocator.cxx426
-rw-r--r--Tests/CMakeLib/testCTestResourceGroups.cxx141
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec.cxx119
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec1.json27
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec10.json15
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec11.json16
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec12.json1
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec13.json1
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec14.json12
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec15.json12
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec16.json12
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec17.json15
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec18.json15
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec19.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec2.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec20.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec21.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec22.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec23.json7
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec24.json7
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec25.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec26.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec27.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec28.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec29.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec3.json12
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec30.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec31.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec32.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec33.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec34.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec35.json5
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec36.json4
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec4.json8
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec5.json6
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec6.json9
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec7.json12
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec8.json13
-rw-r--r--Tests/CMakeLib/testCTestResourceSpec_data/spec9.json14
-rw-r--r--Tests/CMakeLib/testEncoding.cxx7
-rw-r--r--Tests/CMakeLib/testGeneratedFileStream.cxx6
-rw-r--r--Tests/CMakeLib/testOptional.cxx701
-rw-r--r--Tests/CMakeLib/testRST.cxx9
-rw-r--r--Tests/CMakeLib/testRST.expect11
-rw-r--r--Tests/CMakeLib/testRST.rst11
-rw-r--r--Tests/CMakeLib/testRange.cxx45
-rw-r--r--Tests/CMakeLib/testString.cxx1349
-rw-r--r--Tests/CMakeLib/testStringAlgorithms.cxx230
-rw-r--r--Tests/CMakeLib/testSystemTools.cxx18
-rw-r--r--Tests/CMakeLib/testUTF8.cxx112
-rw-r--r--Tests/CMakeLib/testUVProcessChain.cxx334
-rw-r--r--Tests/CMakeLib/testUVProcessChainHelper.cxx72
-rw-r--r--Tests/CMakeLib/testUVRAII.cxx230
-rw-r--r--Tests/CMakeLib/testUVStreambuf.cxx455
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser.cxx64
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/.gitattributes2
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/bom.sln-file4
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-data.sln-file12
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-global.sln-file18
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-header.sln-file8
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectArgs.sln-file8
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectContents.sln-file12
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectSection.sln-file22
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayParen.sln-file8
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote.sln-file8
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote2.sln-file8
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-topLevel.sln-file8
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-unclosed.sln-file10
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/nobom.sln-file4
-rw-r--r--Tests/CMakeLib/testVisualStudioSlnParser_data/valid.sln-file1360
-rw-r--r--Tests/CMakeLib/testXMLParser.cxx4
-rw-r--r--Tests/CMakeLib/testXMLSafe.cxx7
-rw-r--r--Tests/CMakeLists.txt1150
-rw-r--r--Tests/CMakeOnly/AllFindModules/CMakeLists.txt2
-rw-r--r--Tests/CMakeOnly/CMakeLists.txt29
-rw-r--r--Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt2
-rw-r--r--Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt14
-rw-r--r--Tests/CMakeOnly/CheckLanguage/CMakeLists.txt13
-rw-r--r--Tests/CMakeOnly/CheckOBJCCompilerFlag/CMakeLists.txt17
-rw-r--r--Tests/CMakeOnly/CheckOBJCXXCompilerFlag/CMakeLists.txt17
-rw-r--r--Tests/CMakeOnly/CompilerIdOBJC/CMakeLists.txt14
-rw-r--r--Tests/CMakeOnly/CompilerIdOBJCXX/CMakeLists.txt14
-rw-r--r--Tests/CMakeOnly/ProjectInclude/CMakeLists.txt2
-rw-r--r--Tests/CMakeOnly/ProjectIncludeAny/CMakeLists.txt4
-rw-r--r--Tests/CMakeOnly/ProjectIncludeBefore/CMakeLists.txt5
-rw-r--r--Tests/CMakeOnly/ProjectIncludeBefore/include.cmake9
-rw-r--r--Tests/CMakeOnly/SelectLibraryConfigurations/CMakeLists.txt5
-rw-r--r--Tests/CMakeServerLib/CMakeLists.txt21
-rw-r--r--Tests/CMakeServerLib/testServerBuffering.cpp87
-rw-r--r--Tests/CMakeTests/.gitattributes2
-rw-r--r--Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in19
-rw-r--r--Tests/CMakeTests/CheckSourceTreeTest.cmake.in4
-rw-r--r--Tests/CMakeTests/ELFTest.cmake.in29
-rw-r--r--Tests/CMakeTests/FileDownloadInput.pngbin358 -> 194 bytes
-rw-r--r--Tests/CMakeTests/FileDownloadTest.cmake.in16
-rw-r--r--Tests/CMakeTests/FileUploadTest.cmake.in4
-rw-r--r--Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in100
-rw-r--r--Tests/CMakeTests/ListTest.cmake.in4
-rw-r--r--Tests/CMakeTests/PushCheckStateTest.cmake.in22
-rw-r--r--Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake6
-rw-r--r--Tests/CMakeTests/StringTest.cmake.in4
-rw-r--r--Tests/CMakeTests/StringTestScript.cmake25
-rw-r--r--Tests/COnly/CMakeLists.txt8
-rw-r--r--Tests/COnly/conly.c5
-rw-r--r--Tests/COnly/libc2.h12
-rw-r--r--Tests/COnly/testCModule.c4
-rw-r--r--Tests/CPackComponents/mylib.cpp1
-rw-r--r--Tests/CPackComponentsDEB/CMakeLists.txt8
-rw-r--r--Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in7
-rw-r--r--Tests/CPackComponentsDEB/MyLibCPackConfig-components-description2.cmake.in10
-rw-r--r--Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake32
-rw-r--r--Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake36
-rw-r--r--Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake29
-rw-r--r--Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake27
-rw-r--r--Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake10
-rw-r--r--Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake12
-rw-r--r--Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake19
-rw-r--r--Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake14
-rw-r--r--Tests/CPackComponentsDEB/RunCPackVerifyResult.cmake31
-rw-r--r--Tests/CPackComponentsDEB/mylib.cpp1
-rw-r--r--Tests/CPackComponentsForAll/CMakeLists.txt12
-rw-r--r--Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in4
-rw-r--r--Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in4
-rw-r--r--Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in4
-rw-r--r--Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake62
-rw-r--r--Tests/CPackComponentsForAll/mylib.cpp1
-rw-r--r--Tests/CPackUseDefaultVersion/CMakeLists.txt6
-rw-r--r--Tests/CPackUseProjectVersion/CMakeLists.txt6
-rw-r--r--Tests/CPackUseShortProjectVersion/CMakeLists.txt6
-rw-r--r--Tests/CPackWiXGenerator/mylib.cpp1
-rw-r--r--Tests/CSharpLinkFromCxx/.gitattributes1
-rw-r--r--Tests/CSharpLinkFromCxx/CMakeLists.txt19
-rw-r--r--Tests/CSharpLinkFromCxx/CSharpLinkFromCxx.cs16
-rw-r--r--Tests/CSharpLinkFromCxx/UsefulCSharpClass.cs12
-rw-r--r--Tests/CSharpLinkFromCxx/UsefulManagedCppClass.cpp15
-rw-r--r--Tests/CSharpLinkFromCxx/UsefulManagedCppClass.hpp16
-rw-r--r--Tests/CSharpLinkToCxx/CMakeLists.txt6
-rw-r--r--Tests/CSharpLinkToCxx/cpp_static.cpp3
-rw-r--r--Tests/CSharpOnly/CMakeLists.txt3
-rw-r--r--Tests/CSharpOnly/empty.cs (renamed from Tests/RunCMake/CommandLine/DeprecateVS8-WARN-OFF.cmake)0
-rw-r--r--Tests/CSharpOnly/empty.txt (renamed from Tests/RunCMake/CommandLine/DeprecateVS8-WARN-ON.cmake)0
-rw-r--r--Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in1
-rw-r--r--Tests/CTestConfig/CMakeLists.txt35
-rw-r--r--Tests/CTestConfig/dashboard.cmake.in4
-rw-r--r--Tests/CTestConfig/script.cmake.in1
-rw-r--r--Tests/CTestCoverageCollectGCOV/fakegcov.cmake21
-rw-r--r--Tests/CTestCoverageCollectGCOV/test.cmake.in1
-rw-r--r--Tests/CTestTest/test.cmake.in2
-rw-r--r--Tests/CTestTest2/test.cmake.in1
-rw-r--r--Tests/CTestTestBadExe/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestBadGenerator/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestCostSerial/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestCostSerial/sleep.c4
-rw-r--r--Tests/CTestTestCrash/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestCycle/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestDepends/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestFailure/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestFdSetSize/CTestConfig.cmake1
-rw-r--r--Tests/CTestTestFdSetSize/sleep.c4
-rw-r--r--Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestParallel/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestResourceLock/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestScheduler/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestScheduler/sleep.c4
-rw-r--r--Tests/CTestTestSkipReturnCode/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestStopTime/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestStopTime/GetDate.cmake2
-rw-r--r--Tests/CTestTestStopTime/sleep.c4
-rw-r--r--Tests/CTestTestSubdir/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestTimeout/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestTimeout/sleep.c4
-rw-r--r--Tests/CTestTestTimeout/timeout.cmake2
-rw-r--r--Tests/CTestTestUpload/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestUpload/sleep.c4
-rw-r--r--Tests/CTestTestVerboseOutput/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestZeroTimeout/CTestConfig.cmake3
-rw-r--r--Tests/CTestTestZeroTimeout/sleep.c4
-rw-r--r--Tests/CTestUpdateCommon.cmake1
-rw-r--r--Tests/CheckFortran.cmake7
-rw-r--r--Tests/CheckSwift.cmake61
-rw-r--r--Tests/CommandLength/CMakeLists.txt17
-rw-r--r--Tests/CommandLength/test.c4
-rw-r--r--Tests/CompatibleInterface/main.cpp12
-rw-r--r--Tests/CompileCommandOutput/relative.h12
-rw-r--r--Tests/CompileDefinitions/compiletest.c10
-rw-r--r--Tests/CompileDefinitions/compiletest.cpp102
-rw-r--r--Tests/CompileDefinitions/compiletest_mixed_c.c10
-rw-r--r--Tests/CompileDefinitions/compiletest_mixed_cxx.cpp10
-rw-r--r--Tests/CompileDefinitions/runtest.c2
-rw-r--r--Tests/CompileDefinitions/target_prop/usetgt.c6
-rw-r--r--Tests/CompileFeatures/.gitattributes2
-rw-r--r--Tests/CompileFeatures/CMakeLists.txt253
-rw-r--r--Tests/CompileFeatures/cxx_attribute_deprecated.cpp5
-rw-r--r--Tests/CompileFeatures/cxx_contextual_conversions.cpp1
-rw-r--r--Tests/CompileFeatures/cxx_digit_separators.cpp3
-rw-r--r--Tests/CompileFeatures/cxx_generalized_initializers.cpp8
-rw-r--r--Tests/CompileFeatures/cxx_lambda_init_captures.cpp3
-rw-r--r--Tests/CompileFeatures/cxx_raw_string_literals.cpp2
-rw-r--r--Tests/CompileFeatures/cxx_relaxed_constexpr.cpp3
-rw-r--r--Tests/CompileFeatures/cxx_variadic_templates.cpp20
-rw-r--r--Tests/CompileFeatures/default_dialect.c26
-rw-r--r--Tests/CompileFeatures/default_dialect.cpp52
-rw-r--r--Tests/CompileFeatures/genex_test.c44
-rw-r--r--Tests/CompileFeatures/genex_test.cpp81
-rw-r--r--Tests/CompileOptions/CMakeLists.txt32
-rw-r--r--Tests/CompileOptions/main.cpp51
-rw-r--r--Tests/Complex/CMakeLists.txt9
-rw-r--r--Tests/Complex/Cache/CMakeCache.txt2
-rw-r--r--Tests/Complex/Executable/complex.cxx82
-rw-r--r--Tests/Complex/Executable/complex.file.cxx2
-rw-r--r--Tests/Complex/Executable/notInAllExe.cxx2
-rw-r--r--Tests/Complex/Library/CMakeLists.txt2
-rw-r--r--Tests/Complex/Library/notInAllLib.cxx2
-rw-r--r--Tests/Complex/Library/sharedFile.h12
-rw-r--r--Tests/Complex/Library/testConly.c1
-rw-r--r--Tests/Complex/Library/testConly.h12
-rw-r--r--Tests/Complex/VarTests.cmake2
-rw-r--r--Tests/Complex/cmTestConfigure.h.in4
-rw-r--r--Tests/ComplexOneConfig/CMakeLists.txt9
-rw-r--r--Tests/ComplexOneConfig/Cache/CMakeCache.txt2
-rw-r--r--Tests/ComplexOneConfig/Executable/complex.cxx82
-rw-r--r--Tests/ComplexOneConfig/Executable/complex.file.cxx2
-rw-r--r--Tests/ComplexOneConfig/Executable/notInAllExe.cxx2
-rw-r--r--Tests/ComplexOneConfig/Library/CMakeLists.txt2
-rw-r--r--Tests/ComplexOneConfig/Library/notInAllLib.cxx2
-rw-r--r--Tests/ComplexOneConfig/Library/sharedFile.h12
-rw-r--r--Tests/ComplexOneConfig/Library/testConly.c1
-rw-r--r--Tests/ComplexOneConfig/Library/testConly.h12
-rw-r--r--Tests/ComplexOneConfig/VarTests.cmake2
-rw-r--r--Tests/ComplexOneConfig/cmTestConfigure.h.in4
-rw-r--r--Tests/ConfigSources/CMakeLists.txt22
-rw-r--r--Tests/ConfigSources/iface.h10
-rw-r--r--Tests/ConfigSources/iface_debug.h4
-rw-r--r--Tests/ConfigSources/iface_debug_src.cpp8
-rw-r--r--Tests/ConfigSources/iface_other_src.cpp13
-rw-r--r--Tests/ConfigSources/main.cpp7
-rw-r--r--Tests/ConfigSources/main_debug.cpp13
-rw-r--r--Tests/ConfigSources/main_other.cpp13
-rw-r--r--Tests/Contracts/Home.cmake19
-rw-r--r--Tests/Contracts/PLplot/CMakeLists.txt18
-rw-r--r--Tests/Contracts/PLplot/Configure.cmake4
-rw-r--r--Tests/Contracts/Trilinos/CMakeLists.txt19
-rw-r--r--Tests/Contracts/Trilinos/Configure.cmake7
-rw-r--r--Tests/Contracts/Trilinos/EnvScript.cmake32
-rw-r--r--Tests/Contracts/Trilinos/RunTest.cmake7
-rw-r--r--Tests/Contracts/VTK/CMakeLists.txt19
-rw-r--r--Tests/Contracts/VTK/Configure.cmake3
-rw-r--r--Tests/Contracts/VTK/RunTest.cmake3
-rw-r--r--Tests/Contracts/cse-snapshot/CMakeLists.txt114
-rw-r--r--Tests/Contracts/cse-snapshot/Dashboard.cmake.in76
-rw-r--r--Tests/Contracts/cse-snapshot/RunTest.cmake3
-rw-r--r--Tests/Cuda/.clang-format9
-rw-r--r--Tests/Cuda/CMakeLists.txt4
-rw-r--r--Tests/Cuda/Complex/CMakeLists.txt9
-rw-r--r--Tests/Cuda/Complex/dynamic.cpp4
-rw-r--r--Tests/Cuda/Complex/dynamic.cu7
-rw-r--r--Tests/Cuda/Complex/main.cpp4
-rw-r--r--Tests/Cuda/Complex/mixed.cpp8
-rw-r--r--Tests/Cuda/Complex/mixed.cu8
-rw-r--r--Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt2
-rw-r--r--Tests/Cuda/MixedStandardLevels/CMakeLists.txt14
-rw-r--r--Tests/Cuda/MixedStandardLevels/main.cu10
-rw-r--r--Tests/Cuda/NotEnabled/CMakeLists.txt14
-rw-r--r--Tests/Cuda/NotEnabled/lib.cxx5
-rw-r--r--Tests/Cuda/NotEnabled/main.cxx9
-rw-r--r--Tests/Cuda/ObjectLibrary/CMakeLists.txt19
-rw-r--r--Tests/Cuda/ObjectLibrary/Conflicts/CMakeLists.txt2
-rw-r--r--Tests/Cuda/ObjectLibrary/Conflicts/static.cu18
-rw-r--r--Tests/Cuda/ObjectLibrary/main.cpp20
-rw-r--r--Tests/Cuda/ObjectLibrary/static.cpp4
-rw-r--r--Tests/Cuda/ObjectLibrary/static.cu9
-rw-r--r--Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt45
-rw-r--r--Tests/Cuda/ProperDeviceLibraries/main.cu93
-rw-r--r--Tests/Cuda/ProperDeviceLibraries/use_pthreads.cu9
-rw-r--r--Tests/Cuda/ProperDeviceLibraries/use_pthreads.cxx9
-rw-r--r--Tests/Cuda/SeparableCompCXXOnly/CMakeLists.txt3
-rw-r--r--Tests/Cuda/SeparableCompCXXOnly/main.cpp5
-rw-r--r--Tests/Cuda/WithC/CMakeLists.txt7
-rw-r--r--Tests/Cuda/WithC/cuda.cu4
-rw-r--r--Tests/Cuda/WithC/main.c2
-rw-r--r--Tests/CudaOnly/.clang-format9
-rw-r--r--Tests/CudaOnly/CMakeLists.txt19
-rw-r--r--Tests/CudaOnly/CircularLinkLine/CMakeLists.txt34
-rw-r--r--Tests/CudaOnly/CircularLinkLine/file1.cu6
-rw-r--r--Tests/CudaOnly/CircularLinkLine/file2.cu6
-rw-r--r--Tests/CudaOnly/CircularLinkLine/file3.cu8
-rw-r--r--Tests/CudaOnly/CircularLinkLine/main.cu5
-rw-r--r--Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt50
-rw-r--r--Tests/CudaOnly/DontResolveDeviceSymbols/file1.cu69
-rw-r--r--Tests/CudaOnly/DontResolveDeviceSymbols/main.cu7
-rw-r--r--Tests/CudaOnly/DontResolveDeviceSymbols/verify.cmake14
-rw-r--r--Tests/CudaOnly/EnableStandard/CMakeLists.txt2
-rw-r--r--Tests/CudaOnly/EnableStandard/main.cu4
-rw-r--r--Tests/CudaOnly/EnableStandard/shared.cu4
-rw-r--r--Tests/CudaOnly/ExportPTX/CMakeLists.txt7
-rw-r--r--Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt23
-rw-r--r--Tests/CudaOnly/GPUDebugFlag/main.cu72
-rw-r--r--Tests/CudaOnly/PDB/CMakeLists.txt19
-rw-r--r--Tests/CudaOnly/PDB/check_pdbs.cmake10
-rw-r--r--Tests/CudaOnly/PDB/main.cu4
-rw-r--r--Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt34
-rw-r--r--Tests/CudaOnly/ResolveDeviceSymbols/file1.h3
-rw-r--r--Tests/CudaOnly/ResolveDeviceSymbols/file2.cu16
-rw-r--r--Tests/CudaOnly/ResolveDeviceSymbols/file2.h2
-rw-r--r--Tests/CudaOnly/ResolveDeviceSymbols/file2_launch.cu18
-rw-r--r--Tests/CudaOnly/ResolveDeviceSymbols/main.cu33
-rw-r--r--Tests/CudaOnly/SeparateCompilation/CMakeLists.txt18
-rw-r--r--Tests/CudaOnly/WithDefs/CMakeLists.txt36
-rw-r--r--Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h1
-rw-r--r--Tests/CudaOnly/WithDefs/main.notcu53
-rw-r--r--Tests/CudaOnly/WithDefs/main_for_vs.cu1
-rw-r--r--Tests/CustComDepend/bar.h12
-rw-r--r--Tests/CustomCommand/wrapper.cxx7
-rw-r--r--Tests/CustomCommandByproducts/CMakeLists.txt57
-rw-r--r--Tests/CustomCommandByproducts/CustomCommandByproducts.c3
-rw-r--r--Tests/CustomCommandByproducts/byproduct9.c.in1
-rw-r--r--Tests/CustomCommandWorkingDirectory/CMakeLists.txt28
-rw-r--r--Tests/CxxOnly/libcxx2.h12
-rw-r--r--Tests/CxxOnly/testCxxModule.cxx4
-rw-r--r--Tests/EnforceConfig.cmake.in13
-rw-r--r--Tests/ExportImport/CMakeLists.txt5
-rw-r--r--Tests/ExportImport/Export/CMakeLists.txt98
-rw-r--r--Tests/ExportImport/Export/Interface/CMakeLists.txt14
-rw-r--r--Tests/ExportImport/Export/Interface/pch/pch.h1
-rw-r--r--Tests/ExportImport/Export/Interface/source_target.cpp4
-rw-r--r--Tests/ExportImport/Export/Interface/source_target_for_install.cpp4
-rw-r--r--Tests/ExportImport/Export/SubDirLinkA/CMakeLists.txt6
-rw-r--r--Tests/ExportImport/Export/SubDirLinkA/SubDirLinkA.c11
-rw-r--r--Tests/ExportImport/Export/SubDirLinkB/CMakeLists.txt4
-rw-r--r--Tests/ExportImport/Export/systemlib.h4
-rw-r--r--Tests/ExportImport/Export/testExe2.c4
-rw-r--r--Tests/ExportImport/Export/testExe2lib.c8
-rw-r--r--Tests/ExportImport/Export/testExe2libImp.c4
-rw-r--r--Tests/ExportImport/Export/testLib3.c8
-rw-r--r--Tests/ExportImport/Export/testLib3Imp.c8
-rw-r--r--Tests/ExportImport/Export/testLib3ImpDep.c4
-rw-r--r--Tests/ExportImport/Export/testLib4.c4
-rw-r--r--Tests/ExportImport/Export/testLib5.c4
-rw-r--r--Tests/ExportImport/Export/testLib9.c15
-rw-r--r--Tests/ExportImport/Export/testLib9ObjIface.c11
-rw-r--r--Tests/ExportImport/Export/testLib9ObjPriv.c4
-rw-r--r--Tests/ExportImport/Export/testLib9ObjPub.c4
-rw-r--r--Tests/ExportImport/Export/testLibDepends.c6
-rw-r--r--Tests/ExportImport/Export/testLibNoSONAME.c4
-rw-r--r--Tests/ExportImport/Export/testSharedLibDepends.h3
-rw-r--r--Tests/ExportImport/Export/testSharedLibRequiredUser2.h3
-rw-r--r--Tests/ExportImport/Export/testTopDirLib.c11
-rw-r--r--Tests/ExportImport/Import/A/CMakeLists.txt82
-rw-r--r--Tests/ExportImport/Import/A/SubDirLink.c14
-rw-r--r--Tests/ExportImport/Import/A/cmp0022NEW_test.cpp4
-rw-r--r--Tests/ExportImport/Import/A/cmp0022OLD_test.cpp4
-rw-r--r--Tests/ExportImport/Import/A/deps_iface.c15
-rw-r--r--Tests/ExportImport/Import/A/deps_shared_iface.cpp22
-rw-r--r--Tests/ExportImport/Import/A/framework_interface/framework_test.cpp2
-rw-r--r--Tests/ExportImport/Import/A/iface_test.cpp2
-rw-r--r--Tests/ExportImport/Import/A/imp_mod1.c4
-rw-r--r--Tests/ExportImport/Import/A/imp_testExe1.c4
-rw-r--r--Tests/ExportImport/Import/A/imp_testExeAbs1.c4
-rw-r--r--Tests/ExportImport/Import/A/imp_testLib9.c16
-rw-r--r--Tests/ExportImport/Import/A/imp_testLinkOptions.cpp8
-rw-r--r--Tests/ExportImport/Import/Interface/CMakeLists.txt19
-rw-r--r--Tests/ExportImport/Import/Interface/headeronlytest.cpp4
-rw-r--r--Tests/ExportImport/Import/Interface/interfacetest.cpp6
-rw-r--r--Tests/ExportImport/Import/Interface/pch_iface_test.cpp16
-rw-r--r--Tests/ExternalOBJ/CMakeLists.txt2
-rw-r--r--Tests/ExternalProject/CMakeLists.txt39
-rw-r--r--Tests/ExternalProjectLocal/CMakeLists.txt130
-rw-r--r--Tests/ExternalProjectLocal/Step5/CMakeLists.txt71
-rw-r--r--Tests/ExternalProjectLocal/Step5/MathFunctions/CMakeLists.txt (renamed from Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt)0
-rw-r--r--Tests/ExternalProjectLocal/Step5/MathFunctions/MakeTable.cxx (renamed from Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx)0
-rw-r--r--Tests/ExternalProjectLocal/Step5/MathFunctions/MathFunctions.h1
-rw-r--r--Tests/ExternalProjectLocal/Step5/MathFunctions/mysqrt.cxx41
-rw-r--r--Tests/ExternalProjectLocal/Step5/TutorialConfig.h.in8
-rw-r--r--Tests/ExternalProjectLocal/Step5/tutorial.cxx34
-rw-r--r--Tests/ExternalProjectSourceSubdirNotCMake/CMakeLists.txt20
-rw-r--r--Tests/ExternalProjectSourceSubdirNotCMake/Example/subdir/Makefile2
-rw-r--r--Tests/FindALSA/CMakeLists.txt10
-rw-r--r--Tests/FindALSA/Test/CMakeLists.txt16
-rw-r--r--Tests/FindALSA/Test/main.c10
-rw-r--r--Tests/FindBoost/CMakeLists.txt28
-rw-r--r--Tests/FindBoost/Test/CMakeLists.txt15
-rw-r--r--Tests/FindBoost/Test/main.cxx17
-rw-r--r--Tests/FindBoost/TestFail/CMakeLists.txt18
-rw-r--r--Tests/FindBoost/TestFail/main.cxx24
-rw-r--r--Tests/FindBoost/TestPython/CMakeLists.txt17
-rw-r--r--Tests/FindCURL/CMakeLists.txt10
-rw-r--r--Tests/FindCURL/Test/CMakeLists.txt16
-rw-r--r--Tests/FindCURL/Test/main.c17
-rw-r--r--Tests/FindCups/CMakeLists.txt10
-rw-r--r--Tests/FindCups/Test/CMakeLists.txt16
-rw-r--r--Tests/FindCups/Test/main.c12
-rw-r--r--Tests/FindDoxygen/AllTarget/CMakeLists.txt42
-rw-r--r--Tests/FindDoxygen/CMakeLists.txt30
-rw-r--r--Tests/FindDoxygen/QuotingTest/CMakeLists.txt34
-rw-r--r--Tests/FindDoxygen/StampFile/CMakeLists.txt24
-rw-r--r--Tests/FindDoxygen/StampFile/main.cpp4
-rw-r--r--Tests/FindDoxygen/StampFile/main2.cpp4
-rw-r--r--Tests/FindEXPAT/CMakeLists.txt10
-rw-r--r--Tests/FindEXPAT/Test/CMakeLists.txt16
-rw-r--r--Tests/FindEXPAT/Test/main.c21
-rw-r--r--Tests/FindEnvModules/CMakeLists.txt3
-rw-r--r--Tests/FindEnvModules/EnvModules.cmake33
-rw-r--r--Tests/FindFontconfig/CMakeLists.txt10
-rw-r--r--Tests/FindFontconfig/Test/CMakeLists.txt16
-rw-r--r--Tests/FindFontconfig/Test/main.c17
-rw-r--r--Tests/FindFreetype/CMakeLists.txt10
-rw-r--r--Tests/FindFreetype/Test/CMakeLists.txt16
-rw-r--r--Tests/FindFreetype/Test/main.c34
-rw-r--r--Tests/FindGDAL/CMakeLists.txt10
-rw-r--r--Tests/FindGDAL/Test/CMakeLists.txt16
-rw-r--r--Tests/FindGDAL/Test/main.c11
-rw-r--r--Tests/FindGIF/CMakeLists.txt10
-rw-r--r--Tests/FindGIF/Test/CMakeLists.txt16
-rw-r--r--Tests/FindGIF/Test/main.c34
-rw-r--r--Tests/FindGLEW/CMakeLists.txt10
-rw-r--r--Tests/FindGLEW/Test/CMakeLists.txt18
-rw-r--r--Tests/FindGLEW/Test/main.cpp8
-rw-r--r--Tests/FindGSL/rng/main.cc3
-rw-r--r--Tests/FindGTK2/cairomm/main.cpp10
-rw-r--r--Tests/FindGTK2/gtkmm/helloworld.cpp1
-rw-r--r--Tests/FindGTK2/gtkmm/main.cpp3
-rw-r--r--Tests/FindGTK2/sigc++/main.cpp1
-rw-r--r--Tests/FindGTest/Test/main.cxx2
-rw-r--r--Tests/FindGit/CMakeLists.txt10
-rw-r--r--Tests/FindGit/Test/CMakeLists.txt13
-rw-r--r--Tests/FindGit/Test/RunGit.cmake20
-rw-r--r--Tests/FindGnuTLS/CMakeLists.txt10
-rw-r--r--Tests/FindGnuTLS/Test/CMakeLists.txt17
-rw-r--r--Tests/FindGnuTLS/Test/main.c21
-rw-r--r--Tests/FindICU/Test/main.cpp7
-rw-r--r--Tests/FindIconv/CMakeLists.txt10
-rw-r--r--Tests/FindIconv/Test/CMakeLists.txt16
-rw-r--r--Tests/FindIconv/Test/main.cxx52
-rw-r--r--Tests/FindJPEG/CMakeLists.txt10
-rw-r--r--Tests/FindJPEG/Test/CMakeLists.txt16
-rw-r--r--Tests/FindJPEG/Test/main.c17
-rw-r--r--Tests/FindLTTngUST/Test/main.c4
-rw-r--r--Tests/FindLibLZMA/CMakeLists.txt10
-rw-r--r--Tests/FindLibLZMA/Test/CMakeLists.txt14
-rw-r--r--Tests/FindLibLZMA/Test/main.c15
-rw-r--r--Tests/FindLibXml2/CMakeLists.txt10
-rw-r--r--Tests/FindLibXml2/Test/CMakeLists.txt16
-rw-r--r--Tests/FindLibXml2/Test/main.c19
-rw-r--r--Tests/FindLibinput/CMakeLists.txt10
-rw-r--r--Tests/FindLibinput/Test/CMakeLists.txt14
-rw-r--r--Tests/FindLibinput/Test/main.c13
-rw-r--r--Tests/FindMPI/Test/CMakeLists.txt5
-rw-r--r--Tests/FindMatlab/basic_checks/CMakeLists.txt88
-rw-r--r--Tests/FindMatlab/cmake_matlab_unit_tests4.m28
-rw-r--r--Tests/FindMatlab/cmake_matlab_unit_tests5.m20
-rw-r--r--Tests/FindMatlab/components_checks/CMakeLists.txt12
-rw-r--r--Tests/FindMatlab/failure_reports/CMakeLists.txt55
-rw-r--r--Tests/FindMatlab/matlab_wrapper2.cpp22
-rw-r--r--Tests/FindMatlab/matlab_wrapper3.cpp29
-rw-r--r--Tests/FindMatlab/matlab_wrapper_failure.cpp13
-rw-r--r--Tests/FindMatlab/r2018a_check/CMakeLists.txt84
-rw-r--r--Tests/FindMatlab/versions_checks/CMakeLists.txt7
-rw-r--r--Tests/FindODBC/CMakeLists.txt10
-rw-r--r--Tests/FindODBC/Test/CMakeLists.txt14
-rw-r--r--Tests/FindODBC/Test/main.c12
-rw-r--r--Tests/FindOpenACC/CMakeLists.txt20
-rw-r--r--Tests/FindOpenACC/CTest/CMakeLists.txt13
-rw-r--r--Tests/FindOpenACC/CTest/main.c44
-rw-r--r--Tests/FindOpenACC/CXXTest/CMakeLists.txt13
-rw-r--r--Tests/FindOpenACC/CXXTest/main.cxx43
-rw-r--r--Tests/FindOpenACC/FortranTest/CMakeLists.txt11
-rw-r--r--Tests/FindOpenACC/FortranTest/main.f909
-rw-r--r--Tests/FindOpenCL/Test/main.c4
-rw-r--r--Tests/FindOpenGL/CMakeLists.txt7
-rw-r--r--Tests/FindOpenGL/Test/CMakeLists.txt59
-rw-r--r--Tests/FindOpenGL/Test/main.c6
-rw-r--r--Tests/FindOpenMP/Test/CMakeLists.txt1
-rw-r--r--Tests/FindOpenMP/Test/scaltest.c4
-rw-r--r--Tests/FindOpenSSL/rand/main.cc2
-rw-r--r--Tests/FindPackageModeMakefileTest/foo.cpp2
-rw-r--r--Tests/FindPackageModeMakefileTest/foo.h8
-rw-r--r--Tests/FindPackageTest/.gitignore1
-rw-r--r--Tests/FindPackageTest/CMakeLists.txt334
-rw-r--r--Tests/FindPackageTest/PreferConfig/ABCConfig.cmake1
-rw-r--r--Tests/FindPackageTest/PreferConfig/FindABC.cmake1
-rw-r--r--Tests/FindPackageTest/PreferConfigOnlyModule/FindACME.cmake1
-rw-r--r--Tests/FindPackageTest/PreferConfigRecurse/ACMEConfig.cmake1
-rw-r--r--Tests/FindPackageTest/PreferConfigRecurse/FindACME.cmake1
-rw-r--r--Tests/FindPackageTest/cmake/SetFoundResolvedConfig.cmake1
-rw-r--r--Tests/FindPatch/CMakeLists.txt8
-rw-r--r--Tests/FindPatch/Test/CMakeLists.txt77
-rw-r--r--Tests/FindPostgreSQL/CMakeLists.txt10
-rw-r--r--Tests/FindPostgreSQL/Test/CMakeLists.txt16
-rw-r--r--Tests/FindPostgreSQL/Test/main.c24
-rw-r--r--Tests/FindProtobuf/Test/CMakeLists.txt24
-rw-r--r--Tests/FindProtobuf/Test/main-desc.cxx58
-rw-r--r--Tests/FindProtobuf/Test/main-generate.cxx8
-rw-r--r--Tests/FindProtobuf/Test/msgs/example.proto6
-rw-r--r--Tests/FindProtobuf/Test/msgs/example_desc.proto10
-rw-r--r--Tests/FindPython/CMakeLists.txt160
-rw-r--r--Tests/FindPython/FindPythonScript.cmake9
-rw-r--r--Tests/FindPython/MultiplePackages/CMakeLists.txt33
-rw-r--r--Tests/FindPython/NumPy/CMakeLists.txt22
-rw-r--r--Tests/FindPython/NumPy/arraytest.c58
-rw-r--r--Tests/FindPython/NumPyOnly/CMakeLists.txt14
-rw-r--r--Tests/FindPython/Python/CMakeLists.txt32
-rw-r--r--Tests/FindPython/Python2/CMakeLists.txt38
-rw-r--r--Tests/FindPython/Python2Embedded/CMakeLists.txt29
-rw-r--r--Tests/FindPython/Python2Fail/CMakeLists.txt14
-rw-r--r--Tests/FindPython/Python3/CMakeLists.txt90
-rw-r--r--Tests/FindPython/Python3Embedded/CMakeLists.txt29
-rw-r--r--Tests/FindPython/Python3Fail/CMakeLists.txt14
-rw-r--r--Tests/FindPython/RequiredArtifacts/CMakeLists.txt110
-rw-r--r--Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt41
-rw-r--r--Tests/FindPython/VirtualEnv/CMakeLists.txt42
-rw-r--r--Tests/FindPython/VirtualEnv/VirtualEnvDefault.cmake6
-rw-r--r--Tests/FindPython/VirtualEnv/VirtualEnvOnly.cmake16
-rw-r--r--Tests/FindPython/VirtualEnv/VirtualEnvStandard.cmake7
-rw-r--r--Tests/FindPython/display_time.c36
-rw-r--r--Tests/FindPython/display_time.h2
-rw-r--r--Tests/FindPython/main.c7
-rw-r--r--Tests/FindPython/spam.c41
-rw-r--r--Tests/FindSQLite3/CMakeLists.txt10
-rw-r--r--Tests/FindSQLite3/Test/CMakeLists.txt16
-rw-r--r--Tests/FindSQLite3/Test/main.c9
-rw-r--r--Tests/FindThreads/C-only/CMakeLists.txt1
-rw-r--r--Tests/FindThreads/CXX-only/CMakeLists.txt1
-rw-r--r--Tests/FindX11/CMakeLists.txt10
-rw-r--r--Tests/FindX11/Test/CMakeLists.txt89
-rw-r--r--Tests/FindX11/Test/main.c404
-rw-r--r--Tests/ForceInclude/foo.c4
-rw-r--r--Tests/Fortran/CMakeLists.txt9
-rw-r--r--Tests/FortranModules/CMakeLists.txt5
-rw-r--r--Tests/FortranModules/Library/a.f903
-rw-r--r--Tests/FortranModules/Library/b.f903
-rw-r--r--Tests/FortranModules/Subdir/subdir.f903
-rw-r--r--Tests/FortranModules/Submodules/CMakeLists.txt24
-rw-r--r--Tests/FortranModules/Submodules/child.f9010
-rw-r--r--Tests/FortranModules/Submodules/grandchild.f908
-rw-r--r--Tests/FortranModules/Submodules/greatgrandchild.f908
-rw-r--r--Tests/FortranModules/Submodules/main.f902
-rw-r--r--Tests/FortranModules/Submodules/parent.f9022
-rw-r--r--Tests/FortranModules/Submodules/provide.f9057
-rw-r--r--Tests/FortranModules/Submodules/sibling.f909
-rw-r--r--Tests/FortranModules/test_preprocess.F902
-rw-r--r--Tests/FortranModules/test_preprocess_module.F902
-rw-r--r--Tests/FortranOnly/CMakeLists.txt31
-rw-r--r--Tests/FortranOnly/IntelIfDef.f3
-rw-r--r--Tests/FortranOnly/IntelIfDef.inc3
-rw-r--r--Tests/FortranOnly/testRC.rc0
-rw-r--r--Tests/Framework/foo.cxx4
-rw-r--r--Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp20
-rw-r--r--Tests/GeneratorExpression/CMakeLists.txt157
-rw-r--r--Tests/GeneratorExpression/check-part1.cmake5
-rw-r--r--Tests/GeneratorExpression/check-part3.cmake5
-rw-r--r--Tests/GeneratorExpression/check-part4.cmake15
-rw-r--r--Tests/GeneratorExpression/check-part5.cmake1
-rw-r--r--Tests/GeneratorExpression/echo.c3
-rw-r--r--Tests/GeneratorExpression/pwd.c8
-rw-r--r--Tests/GeneratorExpression/srcgenex.c.in12
-rw-r--r--Tests/GeneratorExpression/srcgenex_includes.c.in12
-rw-r--r--Tests/GeneratorExpression/srcgenex_includes.h.in7
-rw-r--r--Tests/GhsMulti/CMakeLists.txt4
-rw-r--r--Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt92
-rw-r--r--Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in32
-rw-r--r--Tests/GhsMulti/GhsMultiCompilerOptions/test.c4
-rw-r--r--Tests/GhsMulti/GhsMultiCopyFile/CMakeLists.txt30
-rw-r--r--Tests/GhsMulti/GhsMultiCopyFile/test.c4
-rw-r--r--Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt110
-rw-r--r--Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt.in108
-rw-r--r--Tests/GhsMulti/GhsMultiCustomTarget/exe1.c5
-rw-r--r--Tests/GhsMulti/GhsMultiCustomTarget/lib1.c4
-rw-r--r--Tests/GhsMulti/GhsMultiDepOrder/CMakeLists.txt12
-rw-r--r--Tests/GhsMulti/GhsMultiDepOrder/exec/CMakeLists.txt11
-rw-r--r--Tests/GhsMulti/GhsMultiDepOrder/exec/exe1.c8
-rw-r--r--Tests/GhsMulti/GhsMultiDepOrder/lib/CMakeLists.txt17
-rw-r--r--Tests/GhsMulti/GhsMultiDepOrder/lib/func1.c17
-rw-r--r--Tests/GhsMulti/GhsMultiDepOrder/lib/lib1.h3
-rw-r--r--Tests/GhsMulti/GhsMultiDepOrder/protolib/CMakeLists.txt28
-rw-r--r--Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.c.in16
-rw-r--r--Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.h.in7
-rw-r--r--Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/CMakeLists.txt17
-rw-r--r--Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/main.c17
-rw-r--r--Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder/test.c4
-rw-r--r--Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder/testcase.c4
-rw-r--r--Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder_test.c4
-rw-r--r--Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c4
-rw-r--r--Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/test.c4
-rw-r--r--Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/testCase.c4
-rw-r--r--Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt17
-rw-r--r--Tests/GhsMulti/GhsMultiExclude/exe1.c4
-rw-r--r--Tests/GhsMulti/GhsMultiExclude/lib1.c4
-rw-r--r--Tests/GhsMulti/GhsMultiExclude/verify.cmake54
-rw-r--r--Tests/GhsMulti/GhsMultiExternalProject/CMakeLists.txt14
-rw-r--r--Tests/GhsMulti/GhsMultiExternalProject/empty/CMakeLists.txt8
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/CMakeLists.txt19
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/exe.c5
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/func.c4
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/CMakeLists.txt3
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/Main.c (renamed from Tests/GhsMulti/ReturnNum/App/Main.c)0
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/CMakeLists.txt6
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/AppDD.int12
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/CMakeLists.txt1
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/CMakeLists.txt2
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/HelperFun.c (renamed from Tests/GhsMulti/ReturnNum/Lib/HelperFun.c)0
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/HelperFun.h (renamed from Tests/GhsMulti/ReturnNum/Lib/HelperFun.h)0
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt21
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/exe.c5
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/func.c5
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/kernel.c15
-rw-r--r--Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/test.int8
-rw-r--r--Tests/GhsMulti/GhsMultiInterface/CMakeLists.txt8
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt92
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in43
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTest/exe1.c6
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTest/exe1.h6
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTest/func2.c4
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTest/func3.c4
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTest/func4.c4
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTest/func5.c4
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTest/func6.c4
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTest/func7.c4
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTestSub/CMakeLists.txt9
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/CMakeLists.txt12
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.c6
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.h6
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/CMakeLists.txt7
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func2.c4
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func3.c4
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func4.c4
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func5.c4
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func6.c4
-rw-r--r--Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func7.c4
-rw-r--r--Tests/GhsMulti/GhsMultiMultipleProjects/CMakeLists.txt17
-rw-r--r--Tests/GhsMulti/GhsMultiMultipleProjects/exe1.c5
-rw-r--r--Tests/GhsMulti/GhsMultiMultipleProjects/lib1.c4
-rw-r--r--Tests/GhsMulti/GhsMultiMultipleProjects/sub/CMakeLists.txt10
-rw-r--r--Tests/GhsMulti/GhsMultiMultipleProjects/sub/exe2.c6
-rw-r--r--Tests/GhsMulti/GhsMultiMultipleProjects/sub/lib2.c4
-rw-r--r--Tests/GhsMulti/GhsMultiMultipleProjects/sub2/CMakeLists.txt10
-rw-r--r--Tests/GhsMulti/GhsMultiMultipleProjects/sub2/exe3.c6
-rw-r--r--Tests/GhsMulti/GhsMultiMultipleProjects/sub2/lib3.c4
-rw-r--r--Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake58
-rw-r--r--Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt13
-rw-r--r--Tests/GhsMulti/GhsMultiObjectLibrary/exe.c8
-rw-r--r--Tests/GhsMulti/GhsMultiObjectLibrary/sub/testOBJ.c4
-rw-r--r--Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.c4
-rw-r--r--Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.h1
-rw-r--r--Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ2.c4
-rw-r--r--Tests/GhsMulti/GhsMultiPlatform/CMakeLists.txt34
-rw-r--r--Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt42
-rw-r--r--Tests/GhsMulti/GhsMultiRenameInstall/exe.c4
-rw-r--r--Tests/GhsMulti/GhsMultiRenameInstall/exe1.c5
-rw-r--r--Tests/GhsMulti/GhsMultiRenameInstall/lib1.c4
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/Atest3.c4
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/CMakeLists.txt45
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/cmake.rule1
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/object.o1
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/resource.pdf0
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/s2.h6
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/s4.h6
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/s5.h6
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/standard.h1
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.c6
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.h6
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/test1.c6
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/test1.h6
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/test2a.c4
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/test3.c4
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/test3.h1
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/test4.c4
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/test5.c4
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/test6.c4
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/test7.c4
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.c11
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.h6
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/textfile.txt1
-rw-r--r--Tests/GhsMulti/GhsMultiSrcGroups/textfile2.txt1
-rw-r--r--Tests/GhsMulti/GhsMultiUnsupportedTargets/CMakeLists.txt10
-rw-r--r--Tests/GhsMulti/GhsMultiUnsupportedTargets/file.c4
-rw-r--r--Tests/GhsMulti/ReturnNum/App/CMakeLists.txt4
-rw-r--r--Tests/GhsMulti/ReturnNum/CMakeLists.txt3
-rw-r--r--Tests/GhsMulti/ReturnNum/Int/AppDD.int12
-rw-r--r--Tests/GhsMulti/ReturnNum/Int/CMakeLists.txt1
-rw-r--r--Tests/GhsMulti/ReturnNum/Int/Default.bsp35
-rw-r--r--Tests/GhsMulti/ReturnNum/Lib/CMakeLists.txt1
-rw-r--r--Tests/GhsMultiDuplicateSourceFilenames/CMakeLists.txt15
-rw-r--r--Tests/GhsMultiDuplicateSourceFilenames/main.c13
-rw-r--r--Tests/GhsMultiDuplicateSourceFilenames/subfolder/test.c5
-rw-r--r--Tests/GhsMultiDuplicateSourceFilenames/subfolder_test.c5
-rw-r--r--Tests/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c5
-rw-r--r--Tests/GhsMultiDuplicateSourceFilenames/test.c5
-rw-r--r--Tests/GoogleTest/Test/CMakeLists.txt7
-rw-r--r--Tests/GoogleTest/Test/empty.cxx0
-rw-r--r--Tests/GoogleTest/Test/main1.cxx4
-rw-r--r--Tests/IPO/CMakeLists.txt7
-rw-r--r--Tests/ImportedSameName/A/CMakeLists.txt8
-rw-r--r--Tests/ImportedSameName/A/a.c3
-rw-r--r--Tests/ImportedSameName/B/CMakeLists.txt8
-rw-r--r--Tests/ImportedSameName/B/b.c3
-rw-r--r--Tests/ImportedSameName/CMakeLists.txt8
-rw-r--r--Tests/ImportedSameName/main.c16
-rw-r--r--Tests/IncludeDirectories/CMP0021/main.cpp2
-rw-r--r--Tests/IncludeDirectories/CMakeLists.txt6
-rw-r--r--Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt4
-rw-r--r--Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp3
-rw-r--r--Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/ordertest.h1
-rw-r--r--Tests/IncludeDirectories/SystemIncludeDirectories/userlib/ordertest.h1
-rw-r--r--Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt16
-rw-r--r--Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp3
-rw-r--r--Tests/IncludeDirectories/ordertest.cpp1
-rw-r--r--Tests/IncludeDirectoriesCPATH/CMakeLists.txt22
-rw-r--r--Tests/IncludeDirectoriesCPATH/consumer.cpp6
-rw-r--r--Tests/IncludeDirectoriesCPATH/viacpath/systemlib.h15
-rw-r--r--Tests/InterfaceLibrary/CMakeLists.txt3
-rw-r--r--Tests/InterfaceLibrary/definetestexe.cpp6
-rw-r--r--Tests/InterfaceLibrary/excluded/CMakeLists.txt1
-rw-r--r--Tests/InterfaceLibrary/libsdir/sharedlib/sharedlib.h3
-rw-r--r--Tests/InterfaceLibrary/map_config.cpp12
-rw-r--r--Tests/InterfaceLibrary/sharedlibtestexe.cpp6
-rw-r--r--Tests/InterfaceLinkLibraries/bang.cpp4
-rw-r--r--Tests/InterfaceLinkLibraries/bar.cpp16
-rw-r--r--Tests/InterfaceLinkLibraries/foo.cpp4
-rw-r--r--Tests/InterfaceLinkLibraries/main.cpp8
-rw-r--r--Tests/Java/CMakeLists.txt12
-rw-r--r--Tests/JavaExportImport/CMakeLists.txt5
-rw-r--r--Tests/JavaJavah/B.cpp4
-rw-r--r--Tests/JavaJavah/C.cpp4
-rw-r--r--Tests/JavaJavah/CMakeLists.txt5
-rw-r--r--Tests/JavaNativeHeaders/CMakeLists.txt24
-rw-r--r--Tests/JavaNativeHeaders/D.cpp10
-rw-r--r--Tests/JavaNativeHeaders/D.java19
-rw-r--r--Tests/JavaNativeHeaders/E.cpp10
-rw-r--r--Tests/JavaNativeHeaders/E.java19
-rw-r--r--Tests/JavaNativeHeaders/HelloWorld3.java15
-rw-r--r--Tests/Jump/Executable/jumpExecutable.cxx4
-rw-r--r--Tests/Jump/Library/Shared/jumpShared.cxx4
-rw-r--r--Tests/LinkDirectory/External/CMakeLists.txt14
-rw-r--r--Tests/LinkFlags/LinkFlagsExe.c2
-rw-r--r--Tests/LinkFlags/LinkFlagsLib.c2
-rw-r--r--Tests/LoadCommand/CMakeCommands/cmTestCommand.c3
-rw-r--r--Tests/LoadCommand/CMakeLists.txt7
-rw-r--r--Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c3
-rw-r--r--Tests/LoadCommandOneConfig/CMakeLists.txt7
-rw-r--r--Tests/MFC/CMakeLists.txt.in5
-rw-r--r--Tests/MFC/mfc1/.gitattributes6
-rw-r--r--Tests/MFC/mfc1/ChildFrm.cpp4
-rw-r--r--Tests/MFC/mfc1/MainFrm.cpp15
-rw-r--r--Tests/MFC/mfc1/Resource.h12
-rw-r--r--Tests/MFC/mfc1/mfc1.cpp4
-rw-r--r--Tests/MFC/mfc1/mfc1.h2
-rw-r--r--Tests/MFC/mfc1/mfc1Doc.cpp4
-rw-r--r--Tests/MFC/mfc1/mfc1View.cpp4
-rw-r--r--Tests/MFC/mfc1/stdafx.h59
-rw-r--r--Tests/MSVCRuntimeLibrary/CMakeLists.txt71
-rw-r--r--Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt58
-rw-r--r--Tests/MSVCRuntimeLibrary/Fortran/verify.F901
-rw-r--r--Tests/MSVCRuntimeLibrary/verify.c1
-rw-r--r--Tests/MSVCRuntimeLibrary/verify.cu1
-rw-r--r--Tests/MSVCRuntimeLibrary/verify.cxx1
-rw-r--r--Tests/MSVCRuntimeLibrary/verify.h29
-rw-r--r--Tests/MacRuntimePath/A/framework.cpp1
-rw-r--r--Tests/MacRuntimePath/A/framework.h12
-rw-r--r--Tests/MacRuntimePath/A/framework2.cpp1
-rw-r--r--Tests/MacRuntimePath/A/framework2.h12
-rw-r--r--Tests/MacRuntimePath/A/shared.cpp1
-rw-r--r--Tests/MacRuntimePath/A/shared.h12
-rw-r--r--Tests/MacRuntimePath/CMakeLists.txt5
-rw-r--r--Tests/MakeClean/ToClean/CMakeLists.txt140
-rw-r--r--Tests/MakeClean/ToClean/EmptySubDir/CMakeLists.txt17
-rw-r--r--Tests/MakeClean/check_clean.c.in2
-rw-r--r--Tests/MathTest/CMakeLists.txt35
-rw-r--r--Tests/MathTest/MathTestExec.cxx40
-rw-r--r--Tests/MissingInstall/CMakeLists.txt8
-rw-r--r--Tests/Module/CheckIPOSupported-C/CMakeLists.txt17
-rw-r--r--Tests/Module/CheckIPOSupported-C/bar.c4
-rw-r--r--Tests/Module/CheckIPOSupported-C/main.c3
-rw-r--r--Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt20
-rw-r--r--Tests/Module/CheckIPOSupported-CXX/bar.cpp4
-rw-r--r--Tests/Module/CheckIPOSupported-CXX/main.cpp3
-rw-r--r--Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt5
-rw-r--r--Tests/Module/CheckTypeSize/CheckTypeSize.c30
-rw-r--r--Tests/Module/CheckTypeSize/CheckTypeSize.cxx34
-rw-r--r--Tests/Module/ExternalData/.gitattributes5
-rw-r--r--Tests/Module/ExternalData/Data5/CMakeLists.txt6
-rw-r--r--Tests/Module/ExternalData/Data5/Data5.dat.md51
-rw-r--r--Tests/Module/ExternalData/MD5/.gitattributes1
-rw-r--r--Tests/Module/ExternalData/SHA1/.gitattributes1
-rw-r--r--Tests/Module/ExternalData/SHA224/.gitattributes1
-rw-r--r--Tests/Module/ExternalData/SHA256/.gitattributes1
-rw-r--r--Tests/Module/ExternalData/SHA3_256/.gitattributes1
-rw-r--r--Tests/Module/FindDependency/CMakeLists.txt4
-rw-r--r--Tests/Module/FindDependency/main.cpp24
-rw-r--r--Tests/Module/FindDependency/packages/Pack7/Pack7Config.cmake14
-rw-r--r--Tests/Module/FindDependency/packages/Pack8/Pack8Config.cmake7
-rw-r--r--Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt34
-rw-r--r--Tests/Module/WriteCompilerDetectionHeader/compile_tests.h10
-rw-r--r--Tests/Module/WriteCompilerDetectionHeader/main.c18
-rw-r--r--Tests/Module/WriteCompilerDetectionHeader/main.cpp2
-rw-r--r--Tests/Module/WriteCompilerDetectionHeader/main_bare.cpp23
-rw-r--r--Tests/Module/WriteCompilerDetectionHeader/main_multi.c18
-rw-r--r--Tests/Module/WriteCompilerDetectionHeader/multi_files.cpp2
-rw-r--r--Tests/ModuleDefinition/example_mod_1.c4
-rw-r--r--Tests/MumpsCoverage/.gitattributes3
-rw-r--r--Tests/MumpsCoverage/VistA-FOIA/Packages/Uncategorized/ZZCOVTST.m3
-rw-r--r--Tests/MumpsCoverage/ZZCOVTST.cmcov93
-rw-r--r--Tests/MumpsCoverage/ZZCOVTST.mcov3
-rw-r--r--Tests/NewlineArgs/cxxonly.cxx4
-rw-r--r--Tests/NewlineArgs/libcxx1.cxx4
-rw-r--r--Tests/NewlineArgs/libcxx1.h4
-rw-r--r--Tests/ObjC++/CMakeLists.txt6
-rw-r--r--Tests/ObjC/CMakeLists.txt4
-rw-r--r--Tests/ObjC/c-file-extension-test/CMakeLists.txt5
-rw-r--r--Tests/ObjC/c-file-extension-test/main.m8
-rw-r--r--Tests/ObjC/cxx-file-extension-test/CMakeLists.txt8
-rw-r--r--Tests/ObjC/cxx-file-extension-test/main.m8
-rw-r--r--Tests/ObjC/objc-file-extension-test/CMakeLists.txt6
-rw-r--r--Tests/ObjC/objc-file-extension-test/main.m12
-rw-r--r--Tests/ObjC/simple-build-test/CMakeLists.txt11
-rw-r--r--Tests/ObjC/simple-build-test/foo.h9
-rw-r--r--Tests/ObjC/simple-build-test/foo.m7
-rw-r--r--Tests/ObjC/simple-build-test/main.m12
-rw-r--r--Tests/ObjCXX/CMakeLists.txt4
-rw-r--r--Tests/ObjCXX/ObjC++/CMakeLists.txt5
-rw-r--r--Tests/ObjCXX/ObjC++/objc++.mm (renamed from Tests/ObjC++/objc++.mm)0
-rw-r--r--Tests/ObjCXX/cxx-file-extension-test/CMakeLists.txt5
-rw-r--r--Tests/ObjCXX/cxx-file-extension-test/main.mm8
-rw-r--r--Tests/ObjCXX/objcxx-file-extension-test/CMakeLists.txt6
-rw-r--r--Tests/ObjCXX/objcxx-file-extension-test/main.mm14
-rw-r--r--Tests/ObjCXX/simple-build-test/CMakeLists.txt11
-rw-r--r--Tests/ObjCXX/simple-build-test/foo.h9
-rw-r--r--Tests/ObjCXX/simple-build-test/foo.mm7
-rw-r--r--Tests/ObjCXX/simple-build-test/main.mm14
-rw-r--r--Tests/ObjectLibrary/A/a.h4
-rw-r--r--Tests/ObjectLibrary/B/b.h12
-rw-r--r--Tests/ObjectLibrary/CMakeLists.txt10
-rw-r--r--Tests/ObjectLibrary/c.c4
-rw-r--r--Tests/ObjectLibrary/main.c4
-rw-r--r--Tests/OutDir/CMakeLists.txt5
-rw-r--r--Tests/OutName/CMakeLists.txt6
-rw-r--r--Tests/OutName/main.c4
-rw-r--r--Tests/OutOfSource/CMakeLists.txt2
-rw-r--r--Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt4
-rw-r--r--Tests/OutOfSource/OutOfSourceSubdir/testlib.h12
-rw-r--r--Tests/PDBDirectoryAndName/CMakeLists.txt14
-rw-r--r--Tests/PerConfig/pcShared.h12
-rw-r--r--Tests/Plugin/CMakeLists.txt18
-rw-r--r--Tests/Plugin/include/DynamicLoader.hxx49
-rw-r--r--Tests/Plugin/include/example.h12
-rw-r--r--Tests/Plugin/src/DynamicLoader.cxx263
-rw-r--r--Tests/Plugin/src/example_exe.cxx29
-rw-r--r--Tests/Plugin/src/example_exe.h.in2
-rw-r--r--Tests/Plugin/src/example_mod_1.c9
-rw-r--r--Tests/PolicyScope/CMakeLists.txt8
-rw-r--r--Tests/PositionIndependentTargets/.gitattributes2
-rw-r--r--Tests/PrecompiledHeader/CMakeLists.txt5
-rw-r--r--Tests/PrecompiledHeader/foo1.c2
-rw-r--r--Tests/PrecompiledHeader/foo2.c4
-rw-r--r--Tests/Preprocess/CMakeLists.txt17
-rw-r--r--Tests/Preprocess/preprocess.c83
-rw-r--r--Tests/Preprocess/preprocess.cxx80
-rw-r--r--Tests/Properties/CMakeLists.txt2
-rw-r--r--Tests/Properties/subdirtest.cxx2
-rw-r--r--Tests/Qt4Autogen/CMakeLists.txt9
-rw-r--r--Tests/Qt4Deploy/CMakeLists.txt7
-rw-r--r--Tests/Qt4Targets/CMakeLists.txt10
-rw-r--r--Tests/Qt4Targets/activeqtexe.cpp2
-rw-r--r--Tests/Qt4Targets/main.cpp7
-rw-r--r--Tests/Qt4Targets/main_gen_test.cpp4
-rw-r--r--Tests/Qt4Targets/mywrapobject.h4
-rw-r--r--Tests/Qt5Autogen/CMakeLists.txt6
-rw-r--r--Tests/QtAutoUicInterface/CMakeLists.txt75
-rw-r--r--Tests/QtAutoUicInterface/libwidget.h25
-rw-r--r--Tests/QtAutoUicInterface/mywidget.h25
-rw-r--r--Tests/QtAutogen/AutogenCoreTest.cmake55
-rw-r--r--Tests/QtAutogen/AutogenGuiTest.cmake55
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt71
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOff/a_mc.hpp.in9
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOff/a_qt.cpp29
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOff/a_qt.hpp27
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOff/b_mc.cpp.in9
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOff/b_mc.hpp9
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOff/b_qt.cpp29
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOff/b_qt.hpp27
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOff/config.hpp.in8
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOff/configure_content.cmake10
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOff/main.cpp16
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOn/CMakeLists.txt91
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOn/object_invalid.hpp.in (renamed from Tests/QtAutogen/mocDepends/object_invalid.hpp.in)0
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOn/object_valid.hpp.in (renamed from Tests/QtAutogen/mocDepends/object_valid.hpp.in)0
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOn/simpleLib.cpp.in (renamed from Tests/QtAutogen/mocDepends/simpleLib.cpp.in)0
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOn/simpleLib.hpp.in (renamed from Tests/QtAutogen/mocDepends/simpleLib.hpp.in)0
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOn/testGenFile.cpp (renamed from Tests/QtAutogen/mocDepends/testGenFile.cpp)0
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOn/testGenLib.cpp (renamed from Tests/QtAutogen/mocDepends/testGenLib.cpp)0
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOn/testGenLib.hpp17
-rw-r--r--Tests/QtAutogen/AutogenOriginDependsOn/testGenTarget.cpp (renamed from Tests/QtAutogen/mocDepends/testGenTarget.cpp)0
-rw-r--r--Tests/QtAutogen/AutogenTargetDepends/CMakeLists.txt54
-rw-r--r--Tests/QtAutogen/AutogenTargetDepends/object_invalid.hpp.in1
-rw-r--r--Tests/QtAutogen/AutogenTargetDepends/object_valid.hpp.in14
-rw-r--r--Tests/QtAutogen/AutogenTargetDepends/testATDFile.cpp (renamed from Tests/QtAutogen/mocDepends/testATDFile.cpp)0
-rw-r--r--Tests/QtAutogen/AutogenTargetDepends/testATDTarget.cpp (renamed from Tests/QtAutogen/mocDepends/testATDTarget.cpp)0
-rw-r--r--Tests/QtAutogen/CMakeLists.txt365
-rw-r--r--Tests/QtAutogen/Complex/Adir/CMakeLists.txt (renamed from Tests/QtAutogen/complex/Adir/CMakeLists.txt)0
-rw-r--r--Tests/QtAutogen/Complex/Adir/libA.cpp (renamed from Tests/QtAutogen/complex/Adir/libA.cpp)0
-rw-r--r--Tests/QtAutogen/Complex/Adir/libA.h18
-rw-r--r--Tests/QtAutogen/Complex/Bdir/CMakeLists.txt (renamed from Tests/QtAutogen/complex/Bdir/CMakeLists.txt)0
-rw-r--r--Tests/QtAutogen/Complex/Bdir/libB.cpp (renamed from Tests/QtAutogen/complex/Bdir/libB.cpp)0
-rw-r--r--Tests/QtAutogen/Complex/Bdir/libB.h22
-rw-r--r--Tests/QtAutogen/Complex/CMakeLists.txt85
-rw-r--r--Tests/QtAutogen/Complex/abc.cpp40
-rw-r--r--Tests/QtAutogen/Complex/abc.h (renamed from Tests/QtAutogen/complex/abc.h)0
-rw-r--r--Tests/QtAutogen/Complex/abc_p.h19
-rw-r--r--Tests/QtAutogen/Complex/bar.cpp (renamed from Tests/QtAutogen/complex/bar.cpp)0
-rw-r--r--Tests/QtAutogen/Complex/blub.cpp (renamed from Tests/QtAutogen/complex/blub.cpp)0
-rw-r--r--Tests/QtAutogen/Complex/blub.h (renamed from Tests/QtAutogen/complex/blub.h)0
-rw-r--r--Tests/QtAutogen/Complex/calwidget.cpp436
-rw-r--r--Tests/QtAutogen/Complex/calwidget.h (renamed from Tests/QtAutogen/complex/calwidget.h)0
-rw-r--r--Tests/QtAutogen/Complex/calwidget.ui (renamed from Tests/QtAutogen/complex/calwidget.ui)0
-rw-r--r--Tests/QtAutogen/Complex/codeeditor.cpp146
-rw-r--r--Tests/QtAutogen/Complex/codeeditor.h (renamed from Tests/QtAutogen/complex/codeeditor.h)0
-rw-r--r--Tests/QtAutogen/Complex/debug_class.cpp11
-rw-r--r--Tests/QtAutogen/Complex/debug_class.h (renamed from Tests/QtAutogen/complex/debug_class.h)0
-rw-r--r--Tests/QtAutogen/Complex/debug_class.ui (renamed from Tests/QtAutogen/complex/debug_class.ui)0
-rw-r--r--Tests/QtAutogen/Complex/debug_resource.qrc (renamed from Tests/QtAutogen/complex/debug_resource.qrc)0
-rw-r--r--Tests/QtAutogen/Complex/foo.cpp (renamed from Tests/QtAutogen/complex/foo.cpp)0
-rw-r--r--Tests/QtAutogen/Complex/foo.h (renamed from Tests/QtAutogen/complex/foo.h)0
-rw-r--r--Tests/QtAutogen/Complex/gadget.cpp (renamed from Tests/QtAutogen/complex/gadget.cpp)0
-rw-r--r--Tests/QtAutogen/Complex/gadget.h (renamed from Tests/QtAutogen/complex/gadget.h)0
-rw-r--r--Tests/QtAutogen/Complex/generated.cpp (renamed from Tests/QtAutogen/complex/generated.cpp)0
-rw-r--r--Tests/QtAutogen/Complex/generated.h21
-rw-r--r--Tests/QtAutogen/Complex/generated.txt.in (renamed from Tests/QtAutogen/complex/generated.txt.in)0
-rw-r--r--Tests/QtAutogen/Complex/generated_resource.qrc.in (renamed from Tests/QtAutogen/complex/generated_resource.qrc.in)0
-rw-r--r--Tests/QtAutogen/Complex/libC.cpp (renamed from Tests/QtAutogen/complex/libC.cpp)0
-rw-r--r--Tests/QtAutogen/Complex/libC.h22
-rw-r--r--Tests/QtAutogen/Complex/main.cpp94
-rw-r--r--Tests/QtAutogen/Complex/multiplewidgets.cpp (renamed from Tests/QtAutogen/complex/multiplewidgets.cpp)0
-rw-r--r--Tests/QtAutogen/Complex/multiplewidgets.h (renamed from Tests/QtAutogen/complex/multiplewidgets.h)0
-rw-r--r--Tests/QtAutogen/Complex/myinterface.h.in (renamed from Tests/QtAutogen/complex/myinterface.h.in)0
-rw-r--r--Tests/QtAutogen/Complex/myotherinterface.h.in (renamed from Tests/QtAutogen/complex/myotherinterface.h.in)0
-rw-r--r--Tests/QtAutogen/Complex/private_slot.cpp (renamed from Tests/QtAutogen/complex/private_slot.cpp)0
-rw-r--r--Tests/QtAutogen/Complex/private_slot.h (renamed from Tests/QtAutogen/complex/private_slot.h)0
-rw-r--r--Tests/QtAutogen/Complex/resourcetester.cpp (renamed from Tests/QtAutogen/complex/resourcetester.cpp)0
-rw-r--r--Tests/QtAutogen/Complex/resourcetester.h (renamed from Tests/QtAutogen/complex/resourcetester.h)0
-rw-r--r--Tests/QtAutogen/Complex/second_resource.qrc (renamed from Tests/QtAutogen/complex/second_resource.qrc)0
-rw-r--r--Tests/QtAutogen/Complex/second_widget.cpp16
-rw-r--r--Tests/QtAutogen/Complex/second_widget.h (renamed from Tests/QtAutogen/complex/second_widget.h)0
-rw-r--r--Tests/QtAutogen/Complex/second_widget.ui (renamed from Tests/QtAutogen/complex/second_widget.ui)0
-rw-r--r--Tests/QtAutogen/Complex/sub/bar.h (renamed from Tests/QtAutogen/complex/sub/bar.h)0
-rw-r--r--Tests/QtAutogen/Complex/targetObjectsTest.cpp (renamed from Tests/QtAutogen/complex/targetObjectsTest.cpp)0
-rw-r--r--Tests/QtAutogen/Complex/test.qrc (renamed from Tests/QtAutogen/complex/test.qrc)0
-rw-r--r--Tests/QtAutogen/Complex/widget1.ui (renamed from Tests/QtAutogen/complex/widget1.ui)0
-rw-r--r--Tests/QtAutogen/Complex/widget2.ui (renamed from Tests/QtAutogen/complex/widget2.ui)0
-rw-r--r--Tests/QtAutogen/Complex/xyz.cpp (renamed from Tests/QtAutogen/complex/xyz.cpp)0
-rw-r--r--Tests/QtAutogen/Complex/xyz.h (renamed from Tests/QtAutogen/complex/xyz.h)0
-rw-r--r--Tests/QtAutogen/Complex/yaf.cpp20
-rw-r--r--Tests/QtAutogen/Complex/yaf.h (renamed from Tests/QtAutogen/complex/yaf.h)0
-rw-r--r--Tests/QtAutogen/Complex/yaf_p.h19
-rw-r--r--Tests/QtAutogen/DefinesTest/CMakeLists.txt13
-rw-r--r--Tests/QtAutogen/DefinesTest/defines_test.cpp38
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt126
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/CMakeLists.txt28
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/data.qrc5
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/item.cpp20
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/item.hpp15
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/main.cpp15
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/CMakeLists.txt2
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.cpp6
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.hpp6
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/CMakeLists.txt5
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.cpp6
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.hpp6
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/CMakeLists.txt5
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.cpp6
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.hpp6
-rw-r--r--Tests/QtAutogen/GlobalAutogenTarget/GAT/view.ui24
-rw-r--r--Tests/QtAutogen/LowMinimumVersion/CMakeLists.txt16
-rw-r--r--Tests/QtAutogen/LowMinimumVersion/example.qrc5
-rw-r--r--Tests/QtAutogen/LowMinimumVersion/item.cpp20
-rw-r--r--Tests/QtAutogen/LowMinimumVersion/item.hpp15
-rw-r--r--Tests/QtAutogen/LowMinimumVersion/main.cpp10
-rw-r--r--Tests/QtAutogen/LowMinimumVersion/someText.txt1
-rw-r--r--Tests/QtAutogen/LowMinimumVersion/view.ui24
-rw-r--r--Tests/QtAutogen/MacOsFW/CMakeLists.txt21
-rw-r--r--Tests/QtAutogen/MacOsFW/src/CMakeLists.txt33
-rw-r--r--Tests/QtAutogen/MacOsFW/src/macos_fw_lib.cpp17
-rw-r--r--Tests/QtAutogen/MacOsFW/src/macos_fw_lib.h18
-rw-r--r--Tests/QtAutogen/MacOsFW/test/CMakeLists.txt19
-rw-r--r--Tests/QtAutogen/MacOsFW/test/testMacosFWLib.cpp43
-rw-r--r--Tests/QtAutogen/MacOsFW/test/testMacosFWLib.h7
-rw-r--r--Tests/QtAutogen/ManySources/CMakeLists.txt35
-rw-r--r--Tests/QtAutogen/ManySources/data.qrc.in7
-rw-r--r--Tests/QtAutogen/ManySources/item.cpp.in27
-rw-r--r--Tests/QtAutogen/ManySources/item.h.in15
-rw-r--r--Tests/QtAutogen/ManySources/main.cpp.in7
-rw-r--r--Tests/QtAutogen/ManySources/object.h.in15
-rw-r--r--Tests/QtAutogen/ManySources/view.ui.in24
-rw-r--r--Tests/QtAutogen/MocCMP0071/CMakeLists.txt6
-rw-r--r--Tests/QtAutogen/MocCMP0071/NEW/CMakeLists.txt16
-rw-r--r--Tests/QtAutogen/MocCMP0071/OLD/CMakeLists.txt18
-rw-r--r--Tests/QtAutogen/MocCMP0071/Obj.cpp21
-rw-r--r--Tests/QtAutogen/MocCMP0071/Obj.hpp19
-rw-r--r--Tests/QtAutogen/MocCMP0071/Obj_p.h14
-rw-r--r--Tests/QtAutogen/MocCMP0071/main.cpp7
-rw-r--r--Tests/QtAutogen/MocInclude/CMakeLists.txt112
-rw-r--r--Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp11
-rw-r--r--Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp9
-rw-r--r--Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp15
-rw-r--r--Tests/QtAutogen/MocInclude/Common/ExternDot.cpp11
-rw-r--r--Tests/QtAutogen/MocInclude/Common/ExternDot.hpp15
-rw-r--r--Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in11
-rw-r--r--Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in15
-rw-r--r--Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp44
-rw-r--r--Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp17
-rw-r--r--Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp18
-rw-r--r--Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp4
-rw-r--r--Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp32
-rw-r--r--Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp20
-rw-r--r--Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp40
-rw-r--r--Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp17
-rw-r--r--Tests/QtAutogen/MocInclude/Common/None.cpp21
-rw-r--r--Tests/QtAutogen/MocInclude/Common/None.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/Common/None_p.h14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp45
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp21
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp18
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp46
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp21
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp18
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnDot.cpp40
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnDot.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp41
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnDot_p.h14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp23
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/common.cpp.in32
-rw-r--r--Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in5
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt17
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjA.cpp12
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjA.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjB.cpp23
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjB.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjBExtra.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjC.cpp31
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjC.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp21
-rw-r--r--Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt14
-rw-r--r--Tests/QtAutogen/MocInclude/Strict/strict.cpp7
-rw-r--r--Tests/QtAutogen/MocInclude/main.cpp9
-rw-r--r--Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt80
-rw-r--r--Tests/QtAutogen/MocMacroName/CMakeLists.txt17
-rw-r--r--Tests/QtAutogen/MocMacroName/CustomMacros.hpp8
-rw-r--r--Tests/QtAutogen/MocMacroName/Gadget.cpp6
-rw-r--r--Tests/QtAutogen/MocMacroName/Gadget.hpp19
-rw-r--r--Tests/QtAutogen/MocMacroName/Object.cpp10
-rw-r--r--Tests/QtAutogen/MocMacroName/Object.hpp22
-rw-r--r--Tests/QtAutogen/MocMacroName/Object1Aliased.cpp9
-rw-r--r--Tests/QtAutogen/MocMacroName/Object1Aliased.hpp20
-rw-r--r--Tests/QtAutogen/MocMacroName/Object2Aliased.cpp9
-rw-r--r--Tests/QtAutogen/MocMacroName/Object2Aliased.hpp20
-rw-r--r--Tests/QtAutogen/MocMacroName/main.cpp13
-rw-r--r--Tests/QtAutogen/MocOnly/CMakeLists.txt17
-rw-r--r--Tests/QtAutogen/MocOnly/IncA.cpp19
-rw-r--r--Tests/QtAutogen/MocOnly/IncA.hpp15
-rw-r--r--Tests/QtAutogen/MocOnly/IncB.cpp19
-rw-r--r--Tests/QtAutogen/MocOnly/IncB.hpp15
-rw-r--r--Tests/QtAutogen/MocOnly/StyleA.cpp5
-rw-r--r--Tests/QtAutogen/MocOnly/StyleA.hpp17
-rw-r--r--Tests/QtAutogen/MocOnly/StyleB.cpp5
-rw-r--r--Tests/QtAutogen/MocOnly/StyleB.hpp16
-rw-r--r--Tests/QtAutogen/MocOnly/main.cpp19
-rw-r--r--Tests/QtAutogen/MocOptions/CMakeLists.txt9
-rw-r--r--Tests/QtAutogen/MocOptions/Object.cpp5
-rw-r--r--Tests/QtAutogen/MocOptions/Object.hpp13
-rw-r--r--Tests/QtAutogen/MocOptions/main.cpp7
-rw-r--r--Tests/QtAutogen/MocOsMacros/CMakeLists.txt32
-rw-r--r--Tests/QtAutogen/MocOsMacros/TestClass.cpp83
-rw-r--r--Tests/QtAutogen/MocOsMacros/TestClass.hpp57
-rw-r--r--Tests/QtAutogen/MocOsMacros/main.cpp33
-rw-r--r--Tests/QtAutogen/MocSkipSource/CMakeLists.txt36
-rw-r--r--Tests/QtAutogen/MocSkipSource/qItemA.cpp (renamed from Tests/QtAutogen/skipSource/qItemA.cpp)0
-rw-r--r--Tests/QtAutogen/MocSkipSource/qItemA.hpp (renamed from Tests/QtAutogen/skipSource/qItemA.hpp)0
-rw-r--r--Tests/QtAutogen/MocSkipSource/qItemB.cpp (renamed from Tests/QtAutogen/skipSource/qItemB.cpp)0
-rw-r--r--Tests/QtAutogen/MocSkipSource/qItemB.hpp (renamed from Tests/QtAutogen/skipSource/qItemB.hpp)0
-rw-r--r--Tests/QtAutogen/MocSkipSource/qItemC.cpp17
-rw-r--r--Tests/QtAutogen/MocSkipSource/qItemC.hpp (renamed from Tests/QtAutogen/skipSource/qItemC.hpp)0
-rw-r--r--Tests/QtAutogen/MocSkipSource/qItemD.cpp17
-rw-r--r--Tests/QtAutogen/MocSkipSource/qItemD.hpp13
-rw-r--r--Tests/QtAutogen/MocSkipSource/skipMoc.cpp16
-rw-r--r--Tests/QtAutogen/ObjectLibrary/CMakeLists.txt18
-rw-r--r--Tests/QtAutogen/ObjectLibrary/a/CMakeLists.txt2
-rw-r--r--Tests/QtAutogen/ObjectLibrary/a/classa.cpp8
-rw-r--r--Tests/QtAutogen/ObjectLibrary/a/classa.h23
-rw-r--r--Tests/QtAutogen/ObjectLibrary/b/classb.cpp8
-rw-r--r--Tests/QtAutogen/ObjectLibrary/b/classb.h23
-rw-r--r--Tests/QtAutogen/ObjectLibrary/main.cpp13
-rw-r--r--Tests/QtAutogen/Parallel/CMakeLists.txt10
-rw-r--r--Tests/QtAutogen/Parallel/aaa/bbb/data.qrc (renamed from Tests/QtAutogen/sameName/aaa/bbb/data.qrc)0
-rw-r--r--Tests/QtAutogen/Parallel/aaa/bbb/item.cpp22
-rw-r--r--Tests/QtAutogen/Parallel/aaa/bbb/item.hpp (renamed from Tests/QtAutogen/sameName/aaa/bbb/item.hpp)0
-rw-r--r--Tests/QtAutogen/Parallel/aaa/data.qrc (renamed from Tests/QtAutogen/sameName/aaa/data.qrc)0
-rw-r--r--Tests/QtAutogen/Parallel/aaa/item.cpp22
-rw-r--r--Tests/QtAutogen/Parallel/aaa/item.hpp18
-rw-r--r--Tests/QtAutogen/Parallel/aaa/view.ui24
-rw-r--r--Tests/QtAutogen/Parallel/bbb/aaa/data.qrc (renamed from Tests/QtAutogen/sameName/bbb/aaa/data.qrc)0
-rw-r--r--Tests/QtAutogen/Parallel/bbb/aaa/item.cpp22
-rw-r--r--Tests/QtAutogen/Parallel/bbb/aaa/item.hpp (renamed from Tests/QtAutogen/sameName/bbb/aaa/item.hpp)0
-rw-r--r--Tests/QtAutogen/Parallel/bbb/data.qrc (renamed from Tests/QtAutogen/sameName/bbb/data.qrc)0
-rw-r--r--Tests/QtAutogen/Parallel/bbb/item.cpp23
-rw-r--r--Tests/QtAutogen/Parallel/bbb/item.hpp17
-rw-r--r--Tests/QtAutogen/Parallel/bbb/view.ui24
-rw-r--r--Tests/QtAutogen/Parallel/ccc/data.qrc (renamed from Tests/QtAutogen/sameName/ccc/data.qrc)0
-rw-r--r--Tests/QtAutogen/Parallel/ccc/item.cpp25
-rw-r--r--Tests/QtAutogen/Parallel/ccc/item.hpp18
-rw-r--r--Tests/QtAutogen/Parallel/ccc/view.ui24
-rw-r--r--Tests/QtAutogen/Parallel/data.qrc (renamed from Tests/QtAutogen/sameName/data.qrc)0
-rw-r--r--Tests/QtAutogen/Parallel/item.cpp20
-rw-r--r--Tests/QtAutogen/Parallel/item.hpp15
-rw-r--r--Tests/QtAutogen/Parallel/main.cpp (renamed from Tests/QtAutogen/sameName/main.cpp)0
-rw-r--r--Tests/QtAutogen/Parallel/parallel.cmake24
-rw-r--r--Tests/QtAutogen/Parallel/view.ui24
-rw-r--r--Tests/QtAutogen/Parallel1/CMakeLists.txt10
-rw-r--r--Tests/QtAutogen/Parallel2/CMakeLists.txt10
-rw-r--r--Tests/QtAutogen/Parallel3/CMakeLists.txt10
-rw-r--r--Tests/QtAutogen/Parallel4/CMakeLists.txt10
-rw-r--r--Tests/QtAutogen/ParallelAUTO/CMakeLists.txt10
-rw-r--r--Tests/QtAutogen/RccEmpty/CMakeLists.txt8
-rw-r--r--Tests/QtAutogen/RccEmpty/rccEmpty.cpp (renamed from Tests/QtAutogen/rccEmpty.cpp)0
-rw-r--r--Tests/QtAutogen/RccEmpty/rccEmptyRes.qrc (renamed from Tests/QtAutogen/rccEmptyRes.qrc)0
-rw-r--r--Tests/QtAutogen/RccOffMocLibrary/CMakeLists.txt17
-rw-r--r--Tests/QtAutogen/RccOffMocLibrary/empty.cpp (renamed from Tests/QtAutogen/empty.cpp)0
-rw-r--r--Tests/QtAutogen/RccOffMocLibrary/empty.h (renamed from Tests/QtAutogen/empty.h)0
-rw-r--r--Tests/QtAutogen/RccOffMocLibrary/not_generated_file.qrc (renamed from Tests/QtAutogen/not_generated_file.qrc)0
-rw-r--r--Tests/QtAutogen/RccOnly/CMakeLists.txt8
-rw-r--r--Tests/QtAutogen/RccOnly/rccOnly.cpp (renamed from Tests/QtAutogen/rccOnly.cpp)0
-rw-r--r--Tests/QtAutogen/RccOnly/rccOnlyRes.qrc (renamed from Tests/QtAutogen/rccOnlyRes.qrc)0
-rw-r--r--Tests/QtAutogen/RccSkipSource/CMakeLists.txt23
-rw-r--r--Tests/QtAutogen/RccSkipSource/skipRcc.cpp (renamed from Tests/QtAutogen/skipRcc.cpp)0
-rw-r--r--Tests/QtAutogen/RccSkipSource/skipRccBad1.qrc (renamed from Tests/QtAutogen/skipSource/skipRccBad1.qrc)0
-rw-r--r--Tests/QtAutogen/RccSkipSource/skipRccBad2.qrc (renamed from Tests/QtAutogen/skipSource/skipRccBad2.qrc)0
-rw-r--r--Tests/QtAutogen/RccSkipSource/skipRccGood.qrc (renamed from Tests/QtAutogen/skipSource/skipRccGood.qrc)0
-rw-r--r--Tests/QtAutogen/RerunMocBasic/CMakeLists.txt102
-rw-r--r--Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt24
-rw-r--r--Tests/QtAutogen/RerunMocBasic/MocBasic/input.txt (renamed from Tests/QtAutogen/mocRerun/input.txt)0
-rw-r--r--Tests/QtAutogen/RerunMocBasic/MocBasic/main.cpp.in23
-rw-r--r--Tests/QtAutogen/RerunMocBasic/MocBasic/res1.qrc (renamed from Tests/QtAutogen/mocRerun/res1.qrc)0
-rw-r--r--Tests/QtAutogen/RerunMocBasic/MocBasic/test1a.h.in (renamed from Tests/QtAutogen/mocRerun/test1a.h.in)0
-rw-r--r--Tests/QtAutogen/RerunMocBasic/MocBasic/test1b.h.in (renamed from Tests/QtAutogen/mocRerun/test1b.h.in)0
-rw-r--r--Tests/QtAutogen/RerunMocBasic/dummy.cpp5
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt134
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt31
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.cpp (renamed from Tests/QtAutogen/mocPlugin/StyleA.cpp)0
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.hpp18
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.json (renamed from Tests/QtAutogen/mocPlugin/StyleA.json)0
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA_Custom.json (renamed from Tests/QtAutogen/mocPlugin/StyleA_Custom.json)0
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.cpp (renamed from Tests/QtAutogen/mocPlugin/StyleB.cpp)0
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.hpp18
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.cpp (renamed from Tests/QtAutogen/mocPlugin/StyleC.cpp)0
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.hpp18
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.cpp (renamed from Tests/QtAutogen/mocPlugin/StyleD.cpp)0
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.hpp18
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleE.cpp9
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleE.hpp10
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleEInclude.hpp18
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/UtilityMacros.hpp7
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleB.json1
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleB_Custom.json (renamed from Tests/QtAutogen/mocPlugin/jsonIn/StyleB_Custom.json)0
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleC.json (renamed from Tests/QtAutogen/mocPlugin/jsonIn/StyleC.json)0
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleD.json (renamed from Tests/QtAutogen/mocPlugin/jsonIn/StyleD.json)0
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleE.json1
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/MocPlugin/main.cpp (renamed from Tests/QtAutogen/mocPlugin/main.cpp)0
-rw-r--r--Tests/QtAutogen/RerunMocPlugin/dummy.cpp5
-rw-r--r--Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt47
-rw-r--r--Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt26
-rw-r--r--Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/main.cpp (renamed from Tests/QtAutogen/rccDepends/main.cpp)0
-rw-r--r--Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen.qrc.in6
-rw-r--r--Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input1.txt.in1
-rw-r--r--Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input2.txt.in1
-rw-r--r--Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain.qrc6
-rw-r--r--Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input1.txt1
-rw-r--r--Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input2.txt1
-rw-r--r--Tests/QtAutogen/RerunRccConfigChange/dummy.cpp5
-rw-r--r--Tests/QtAutogen/RerunRccDepends/CMakeLists.txt153
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt33
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/main.cpp (renamed from Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp)0
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/input.txt.in1
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/inputAdded.txt.in1
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resGenA.qrc.in5
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resGenB.qrc.in6
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/input.txt.in1
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/inputAdded.txt.in1
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainA.qrc.in5
-rw-r--r--Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainB.qrc.in6
-rw-r--r--Tests/QtAutogen/RerunRccDepends/dummy.cpp5
-rw-r--r--Tests/QtAutogen/SameName/CMakeLists.txt44
-rw-r--r--Tests/QtAutogen/SameName/aaa/bbb/data.qrc6
-rw-r--r--Tests/QtAutogen/SameName/aaa/bbb/item.cpp22
-rw-r--r--Tests/QtAutogen/SameName/aaa/bbb/item.hpp18
-rw-r--r--Tests/QtAutogen/SameName/aaa/data.qrc6
-rw-r--r--Tests/QtAutogen/SameName/aaa/item.cpp22
-rw-r--r--Tests/QtAutogen/SameName/aaa/item.hpp18
-rw-r--r--Tests/QtAutogen/SameName/aaa/view.ui24
-rw-r--r--Tests/QtAutogen/SameName/bbb/aaa/data.qrc6
-rw-r--r--Tests/QtAutogen/SameName/bbb/aaa/item.cpp22
-rw-r--r--Tests/QtAutogen/SameName/bbb/aaa/item.hpp18
-rw-r--r--Tests/QtAutogen/SameName/bbb/data.qrc6
-rw-r--r--Tests/QtAutogen/SameName/bbb/item.cpp23
-rw-r--r--Tests/QtAutogen/SameName/bbb/item.hpp17
-rw-r--r--Tests/QtAutogen/SameName/bbb/view.ui24
-rw-r--r--Tests/QtAutogen/SameName/ccc/data.qrc6
-rw-r--r--Tests/QtAutogen/SameName/ccc/item.cpp25
-rw-r--r--Tests/QtAutogen/SameName/ccc/item.hpp18
-rw-r--r--Tests/QtAutogen/SameName/ccc/view.ui24
-rw-r--r--Tests/QtAutogen/SameName/data.qrc5
-rw-r--r--Tests/QtAutogen/SameName/item.cpp20
-rw-r--r--Tests/QtAutogen/SameName/item.hpp15
-rw-r--r--Tests/QtAutogen/SameName/main.cpp29
-rw-r--r--Tests/QtAutogen/SameName/object.h13
-rw-r--r--Tests/QtAutogen/SameName/object.h++13
-rw-r--r--Tests/QtAutogen/SameName/object.hpp13
-rw-r--r--Tests/QtAutogen/SameName/object.hxx13
-rw-r--r--Tests/QtAutogen/SameName/object_upper_ext.H13
-rw-r--r--Tests/QtAutogen/SameName/view.ui24
-rw-r--r--Tests/QtAutogen/StaticLibraryCycle/CMakeLists.txt20
-rw-r--r--Tests/QtAutogen/StaticLibraryCycle/a.cpp13
-rw-r--r--Tests/QtAutogen/StaticLibraryCycle/a.h15
-rw-r--r--Tests/QtAutogen/StaticLibraryCycle/b.cpp8
-rw-r--r--Tests/QtAutogen/StaticLibraryCycle/b.h13
-rw-r--r--Tests/QtAutogen/StaticLibraryCycle/c.cpp8
-rw-r--r--Tests/QtAutogen/StaticLibraryCycle/c.h13
-rw-r--r--Tests/QtAutogen/StaticLibraryCycle/main.cpp8
-rw-r--r--Tests/QtAutogen/TestMacros.cmake61
-rw-r--r--Tests/QtAutogen/Tests.cmake48
-rw-r--r--Tests/QtAutogen/UicInclude/CMakeLists.txt11
-rw-r--r--Tests/QtAutogen/UicInclude/PageC.ui (renamed from Tests/QtAutogen/uicInclude/PageC.ui)0
-rw-r--r--Tests/QtAutogen/UicInclude/PageC2.ui (renamed from Tests/QtAutogen/uicInclude/PageC2.ui)0
-rw-r--r--Tests/QtAutogen/UicInclude/dirA/PageA.ui (renamed from Tests/QtAutogen/uicInclude/dirA/PageA.ui)0
-rw-r--r--Tests/QtAutogen/UicInclude/dirB/PageB.ui (renamed from Tests/QtAutogen/uicInclude/dirB/PageB.ui)0
-rw-r--r--Tests/QtAutogen/UicInclude/dirB/PageB2.ui (renamed from Tests/QtAutogen/uicInclude/dirB/PageB2.ui)0
-rw-r--r--Tests/QtAutogen/UicInclude/dirB/subB/PageBsub.ui (renamed from Tests/QtAutogen/uicInclude/dirB/subB/PageBsub.ui)0
-rw-r--r--Tests/QtAutogen/UicInclude/main.cpp (renamed from Tests/QtAutogen/uicInclude/main.cpp)0
-rw-r--r--Tests/QtAutogen/UicInclude/main.hpp (renamed from Tests/QtAutogen/uicInclude/main.hpp)0
-rw-r--r--Tests/QtAutogen/UicInclude/subC/PageCsub.ui (renamed from Tests/QtAutogen/uicInclude/subC/PageCsub.ui)0
-rw-r--r--Tests/QtAutogen/UicInterface/CMakeLists.txt58
-rw-r--r--Tests/QtAutogen/UicInterface/klocalizedstring.cpp (renamed from Tests/QtAutoUicInterface/klocalizedstring.cpp)0
-rw-r--r--Tests/QtAutogen/UicInterface/klocalizedstring.h (renamed from Tests/QtAutoUicInterface/klocalizedstring.h)0
-rw-r--r--Tests/QtAutogen/UicInterface/libwidget.cpp (renamed from Tests/QtAutoUicInterface/libwidget.cpp)0
-rw-r--r--Tests/QtAutogen/UicInterface/libwidget.h26
-rw-r--r--Tests/QtAutogen/UicInterface/libwidget.ui (renamed from Tests/QtAutoUicInterface/libwidget.ui)0
-rw-r--r--Tests/QtAutogen/UicInterface/main.cpp (renamed from Tests/QtAutoUicInterface/main.cpp)0
-rw-r--r--Tests/QtAutogen/UicInterface/mywidget.cpp (renamed from Tests/QtAutoUicInterface/mywidget.cpp)0
-rw-r--r--Tests/QtAutogen/UicInterface/mywidget.h26
-rw-r--r--Tests/QtAutogen/UicInterface/mywidget.ui (renamed from Tests/QtAutoUicInterface/mywidget.ui)0
-rw-r--r--Tests/QtAutogen/UicNoGui/CMakeLists.txt16
-rw-r--r--Tests/QtAutogen/UicNoGui/MocOnly/CMakeLists.txt3
-rw-r--r--Tests/QtAutogen/UicNoGui/MocOnly/main.cpp15
-rw-r--r--Tests/QtAutogen/UicNoGui/NoQt/CMakeLists.txt2
-rw-r--r--Tests/QtAutogen/UicNoGui/NoQt/main.cpp4
-rw-r--r--Tests/QtAutogen/UicNoGui/main.cpp9
-rw-r--r--Tests/QtAutogen/UicOnly/CMakeLists.txt8
-rw-r--r--Tests/QtAutogen/UicOnly/UicOnly.cpp18
-rw-r--r--Tests/QtAutogen/UicOnly/UicOnly.hpp15
-rw-r--r--Tests/QtAutogen/UicOnly/main.cpp7
-rw-r--r--Tests/QtAutogen/UicOnly/uiA.ui24
-rw-r--r--Tests/QtAutogen/UicOnly/uiB.ui24
-rw-r--r--Tests/QtAutogen/UicOnly/uiC.ui24
-rw-r--r--Tests/QtAutogen/UicOnly/uiD.ui24
-rw-r--r--Tests/QtAutogen/UicSkipSource/CMakeLists.txt22
-rw-r--r--Tests/QtAutogen/UicSkipSource/skipUic.cpp22
-rw-r--r--Tests/QtAutogen/UicSkipSource/skipUicGen.cpp8
-rw-r--r--Tests/QtAutogen/UicSkipSource/skipUicGen.hpp (renamed from Tests/QtAutogen/skipSource/skipUicGen.hpp)0
-rw-r--r--Tests/QtAutogen/UicSkipSource/skipUicNoGen1.cpp8
-rw-r--r--Tests/QtAutogen/UicSkipSource/skipUicNoGen1.hpp (renamed from Tests/QtAutogen/skipSource/skipUicNoGen1.hpp)0
-rw-r--r--Tests/QtAutogen/UicSkipSource/skipUicNoGen2.cpp8
-rw-r--r--Tests/QtAutogen/UicSkipSource/skipUicNoGen2.hpp (renamed from Tests/QtAutogen/skipSource/skipUicNoGen2.hpp)0
-rw-r--r--Tests/QtAutogen/UicSkipSource/ui_nogen1.h (renamed from Tests/QtAutogen/skipSource/ui_nogen1.h)0
-rw-r--r--Tests/QtAutogen/UicSkipSource/ui_nogen2.h6
-rw-r--r--Tests/QtAutogen/UicSkipSource/uigen1.ui (renamed from Tests/QtAutogen/skipSource/uigen1.ui)0
-rw-r--r--Tests/QtAutogen/UicSkipSource/uigen2.ui (renamed from Tests/QtAutogen/skipSource/uigen2.ui)0
-rw-r--r--Tests/QtAutogen/complex/Adir/libA.h18
-rw-r--r--Tests/QtAutogen/complex/Bdir/libB.h22
-rw-r--r--Tests/QtAutogen/complex/CMakeLists.txt82
-rw-r--r--Tests/QtAutogen/complex/abc.cpp39
-rw-r--r--Tests/QtAutogen/complex/abc_p.h19
-rw-r--r--Tests/QtAutogen/complex/calwidget.cpp436
-rw-r--r--Tests/QtAutogen/complex/codeeditor.cpp146
-rw-r--r--Tests/QtAutogen/complex/debug_class.cpp10
-rw-r--r--Tests/QtAutogen/complex/generated.h18
-rw-r--r--Tests/QtAutogen/complex/libC.h22
-rw-r--r--Tests/QtAutogen/complex/main.cpp93
-rw-r--r--Tests/QtAutogen/complex/second_widget.cpp15
-rw-r--r--Tests/QtAutogen/complex/yaf.cpp19
-rw-r--r--Tests/QtAutogen/complex/yaf_p.h19
-rw-r--r--Tests/QtAutogen/defines_test/CMakeLists.txt4
-rw-r--r--Tests/QtAutogen/defines_test/defines_test.cpp38
-rw-r--r--Tests/QtAutogen/mocDepends/CMakeLists.txt151
-rw-r--r--Tests/QtAutogen/mocDepends/testGenLib.hpp16
-rw-r--r--Tests/QtAutogen/mocInclude/ObjA.cpp24
-rw-r--r--Tests/QtAutogen/mocInclude/ObjA.hpp13
-rw-r--r--Tests/QtAutogen/mocInclude/ObjB.cpp25
-rw-r--r--Tests/QtAutogen/mocInclude/ObjB.hpp13
-rw-r--r--Tests/QtAutogen/mocInclude/ObjC.cpp26
-rw-r--r--Tests/QtAutogen/mocInclude/ObjC.hpp13
-rw-r--r--Tests/QtAutogen/mocInclude/ObjD.cpp26
-rw-r--r--Tests/QtAutogen/mocInclude/ObjD.hpp13
-rw-r--r--Tests/QtAutogen/mocInclude/subA/SubObjA.cpp27
-rw-r--r--Tests/QtAutogen/mocInclude/subA/SubObjA.hpp16
-rw-r--r--Tests/QtAutogen/mocInclude/subB/SubObjB.cpp27
-rw-r--r--Tests/QtAutogen/mocInclude/subB/SubObjB.hpp16
-rw-r--r--Tests/QtAutogen/mocInclude/subC/SubObjC.cpp27
-rw-r--r--Tests/QtAutogen/mocInclude/subC/SubObjC.hpp16
-rw-r--r--Tests/QtAutogen/mocIncludeRelaxed/CMakeLists.txt18
-rw-r--r--Tests/QtAutogen/mocIncludeRelaxed/main.cpp14
-rw-r--r--Tests/QtAutogen/mocIncludeStrict/CMakeLists.txt18
-rw-r--r--Tests/QtAutogen/mocIncludeStrict/main.cpp14
-rw-r--r--Tests/QtAutogen/mocPlugin/CMakeLists.txt33
-rw-r--r--Tests/QtAutogen/mocPlugin/StyleA.hpp17
-rw-r--r--Tests/QtAutogen/mocPlugin/StyleB.hpp17
-rw-r--r--Tests/QtAutogen/mocPlugin/StyleC.hpp17
-rw-r--r--Tests/QtAutogen/mocPlugin/StyleCommon.hpp7
-rw-r--r--Tests/QtAutogen/mocPlugin/StyleD.hpp17
-rw-r--r--Tests/QtAutogen/mocPlugin/StyleE.cpp6
-rw-r--r--Tests/QtAutogen/mocPlugin/StyleE.hpp17
-rw-r--r--Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json1
-rw-r--r--Tests/QtAutogen/mocRerun/CMakeLists.txt35
-rw-r--r--Tests/QtAutogen/mocRerun/main.cpp.in18
-rw-r--r--Tests/QtAutogen/rccDepends/CMakeLists.txt35
-rw-r--r--Tests/QtAutogen/rccDepends/res/input1.txt.in1
-rw-r--r--Tests/QtAutogen/rccDepends/res/input2.txt.in1
-rw-r--r--Tests/QtAutogen/rccDepends/res1a.qrc.in5
-rw-r--r--Tests/QtAutogen/rccDepends/res1b.qrc.in6
-rw-r--r--Tests/QtAutogen/rccDepends/res2a.qrc.in5
-rw-r--r--Tests/QtAutogen/rccDepends/res2b.qrc.in6
-rw-r--r--Tests/QtAutogen/sameName/CMakeLists.txt31
-rw-r--r--Tests/QtAutogen/sameName/aaa/bbb/item.cpp10
-rw-r--r--Tests/QtAutogen/sameName/aaa/item.cpp8
-rw-r--r--Tests/QtAutogen/sameName/aaa/item.hpp16
-rw-r--r--Tests/QtAutogen/sameName/bbb/aaa/item.cpp10
-rw-r--r--Tests/QtAutogen/sameName/bbb/item.cpp8
-rw-r--r--Tests/QtAutogen/sameName/bbb/item.hpp16
-rw-r--r--Tests/QtAutogen/sameName/ccc/item.cpp23
-rw-r--r--Tests/QtAutogen/sameName/ccc/item.hpp16
-rw-r--r--Tests/QtAutogen/sameName/item.cpp5
-rw-r--r--Tests/QtAutogen/sameName/item.hpp13
-rw-r--r--Tests/QtAutogen/skipMoc.cpp14
-rw-r--r--Tests/QtAutogen/skipSource/qItemC.cpp5
-rw-r--r--Tests/QtAutogen/skipSource/skipUicGen.cpp7
-rw-r--r--Tests/QtAutogen/skipSource/skipUicNoGen1.cpp7
-rw-r--r--Tests/QtAutogen/skipSource/skipUicNoGen2.cpp7
-rw-r--r--Tests/QtAutogen/skipSource/ui_nogen2.h6
-rw-r--r--Tests/QtAutogen/skipUic.cpp22
-rw-r--r--Tests/QtAutogen/uicInclude/CMakeLists.txt8
-rw-r--r--Tests/QtAutogen/uicOnlySource/uiconly.cpp18
-rw-r--r--Tests/QtAutogen/uicOnlySource/uiconly.h20
-rw-r--r--Tests/QtAutogen/uicOnlySource/uiconly.ui24
-rw-r--r--Tests/README39
-rw-r--r--Tests/README.rst31
-rw-r--r--Tests/RunCMake/Android/RunCMakeTest.cmake25
-rw-r--r--Tests/RunCMake/Android/android.cxx38
-rw-r--r--Tests/RunCMake/Android/android.h120
-rw-r--r--Tests/RunCMake/Android/android_lib.cxx4
-rw-r--r--Tests/RunCMake/Android/android_sysinc.c2
-rw-r--r--Tests/RunCMake/Android/android_sysinc.cxx2
-rw-r--r--Tests/RunCMake/Android/check_binary.cmake8
-rw-r--r--Tests/RunCMake/Android/common.cmake53
-rw-r--r--Tests/RunCMake/Android/ndk-arm64-v8a-stdout.txt2
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-arm-stdout.txt2
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stdout.txt2
-rw-r--r--Tests/RunCMake/Android/ndk-armeabi-v7a-stdout.txt2
-rw-r--r--Tests/RunCMake/Android/ndk-badver-stderr.txt5
-rw-r--r--Tests/RunCMake/Android/ndk-badvernum-stderr.txt8
-rw-r--r--Tests/RunCMake/Android/ndk-mips-stdout.txt2
-rw-r--r--Tests/RunCMake/Android/ndk-mips64-stdout.txt2
-rw-r--r--Tests/RunCMake/Android/ndk-x86-stdout.txt2
-rw-r--r--Tests/RunCMake/Android/ndk-x86_64-stdout.txt2
-rw-r--r--Tests/RunCMake/AndroidMK/AndroidMK.cmake8
-rw-r--r--Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt8
-rw-r--r--Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt8
-rw-r--r--Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake37
-rw-r--r--Tests/RunCMake/AutoExportDll/foo.c4
-rw-r--r--Tests/RunCMake/AutoExportDll/hello.cxx1
-rw-r--r--Tests/RunCMake/AutoExportDll/hello.h12
-rw-r--r--Tests/RunCMake/AutoExportDll/say.cxx7
-rw-r--r--Tests/RunCMake/Autogen/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/Autogen/NoQt-stderr.txt8
-rw-r--r--Tests/RunCMake/Autogen/NoQt.cmake6
-rw-r--r--Tests/RunCMake/Autogen/QtInFunction.cmake13
-rw-r--r--Tests/RunCMake/Autogen/QtInFunctionNested-stderr.txt8
-rw-r--r--Tests/RunCMake/Autogen/QtInFunctionNested.cmake17
-rw-r--r--Tests/RunCMake/Autogen/QtInFunctionProperty.cmake21
-rw-r--r--Tests/RunCMake/Autogen/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/Autogen/empty.cpp0
-rw-r--r--Tests/RunCMake/BuildDepends/BuildUnderSource.c5
-rw-r--r--Tests/RunCMake/BuildDepends/BuildUnderSource.cmake9
-rw-r--r--Tests/RunCMake/BuildDepends/BuildUnderSource.step1.cmake3
-rw-r--r--Tests/RunCMake/BuildDepends/BuildUnderSource.step2.cmake3
-rw-r--r--Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake2
-rw-r--r--Tests/RunCMake/BuildDepends/C-Exe.cmake2
-rw-r--r--Tests/RunCMake/BuildDepends/Custom-Always.cmake2
-rw-r--r--Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake2
-rw-r--r--Tests/RunCMake/BuildDepends/MakeCustomIncludes.cmake2
-rw-r--r--Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake2
-rw-r--r--Tests/RunCMake/BuildDepends/RunCMakeTest.cmake21
-rw-r--r--Tests/RunCMake/BundleUtilities/CMP0080-COMMAND.cmake5
-rw-r--r--Tests/RunCMake/BundleUtilities/CMP0080-NEW-result.txt (renamed from Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-result.txt)0
-rw-r--r--Tests/RunCMake/BundleUtilities/CMP0080-NEW-stderr.txt2
-rw-r--r--Tests/RunCMake/BundleUtilities/CMP0080-NEW.cmake2
-rw-r--r--Tests/RunCMake/BundleUtilities/CMP0080-OLD.cmake2
-rw-r--r--Tests/RunCMake/BundleUtilities/CMP0080-WARN-stderr.txt10
-rw-r--r--Tests/RunCMake/BundleUtilities/CMP0080-WARN.cmake1
-rw-r--r--Tests/RunCMake/BundleUtilities/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/BundleUtilities/RunCMakeTest.cmake11
-rw-r--r--Tests/RunCMake/Byproducts/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/Byproducts/CleanByproducts.cmake93
-rw-r--r--Tests/RunCMake/Byproducts/RunCMakeTest.cmake58
-rw-r--r--Tests/RunCMake/Byproducts/files.cmake.in2
-rw-r--r--Tests/RunCMake/Byproducts/foo.cpp14
-rw-r--r--Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-stderr.txt2
-rw-r--r--Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-stderr.txt2
-rw-r--r--Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-stderr.txt2
-rw-r--r--Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-stderr.txt2
-rw-r--r--Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-stderr.txt2
-rw-r--r--Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-stderr.txt2
-rw-r--r--Tests/RunCMake/CMP0026/CMP0026-NEW-stderr.txt2
-rw-r--r--Tests/RunCMake/CMP0026/CMP0026-OLD-stderr.txt2
-rw-r--r--Tests/RunCMake/CMP0026/CMP0026-WARN-stderr.txt4
-rw-r--r--Tests/RunCMake/CMP0026/LOCATION-and-TARGET_OBJECTS-stderr.txt2
-rw-r--r--Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt2
-rw-r--r--Tests/RunCMake/CMP0026/clear-cached-information-stderr.txt2
-rw-r--r--Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake2
-rw-r--r--Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake2
-rw-r--r--Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake2
-rw-r--r--Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake2
-rw-r--r--Tests/RunCMake/CMP0037/CMP0037-OLD-space-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake2
-rw-r--r--Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake2
-rw-r--r--Tests/RunCMake/CMP0037/CMP0037-WARN-reserved-stderr.txt36
-rw-r--r--Tests/RunCMake/CMP0037/CMP0037-WARN-reserved.cmake4
-rw-r--r--Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake2
-rw-r--r--Tests/RunCMake/CMP0037/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/CMP0037/NEW-cond-package-result.txt (renamed from Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileOptions-result.txt)0
-rw-r--r--Tests/RunCMake/CMP0037/NEW-cond-package-stderr.txt4
-rw-r--r--Tests/RunCMake/CMP0037/NEW-cond-package.cmake5
-rw-r--r--Tests/RunCMake/CMP0037/NEW-cond-package_source-result.txt (renamed from Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-result.txt)0
-rw-r--r--Tests/RunCMake/CMP0037/NEW-cond-package_source-stderr.txt5
-rw-r--r--Tests/RunCMake/CMP0037/NEW-cond-package_source.cmake5
-rw-r--r--Tests/RunCMake/CMP0037/NEW-cond-test-result.txt (renamed from Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-result.txt)0
-rw-r--r--Tests/RunCMake/CMP0037/NEW-cond-test-stderr.txt4
-rw-r--r--Tests/RunCMake/CMP0037/NEW-cond-test.cmake5
-rw-r--r--Tests/RunCMake/CMP0037/NEW-cond.cmake4
-rw-r--r--Tests/RunCMake/CMP0037/OLD-cond-package-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0037/OLD-cond-package.cmake5
-rw-r--r--Tests/RunCMake/CMP0037/OLD-cond-package_source-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0037/OLD-cond-package_source.cmake5
-rw-r--r--Tests/RunCMake/CMP0037/OLD-cond-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0037/OLD-cond-test-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0037/OLD-cond-test.cmake5
-rw-r--r--Tests/RunCMake/CMP0037/OLD-cond.cmake5
-rw-r--r--Tests/RunCMake/CMP0037/RunCMakeTest.cmake17
-rw-r--r--Tests/RunCMake/CMP0037/WARN-cond-package-stderr.txt11
-rw-r--r--Tests/RunCMake/CMP0037/WARN-cond-package.cmake5
-rw-r--r--Tests/RunCMake/CMP0037/WARN-cond-package_source-stderr.txt11
-rw-r--r--Tests/RunCMake/CMP0037/WARN-cond-package_source.cmake5
-rw-r--r--Tests/RunCMake/CMP0037/WARN-cond-test-stderr.txt11
-rw-r--r--Tests/RunCMake/CMP0037/WARN-cond-test.cmake5
-rw-r--r--Tests/RunCMake/CMP0037/WARN-cond.cmake4
-rw-r--r--Tests/RunCMake/CMP0038/CMP0038-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0039/CMP0039-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt6
-rw-r--r--Tests/RunCMake/CMP0041/CMP0041-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0041/CMP0041-tid-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0042/CMP0042-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0043/CMP0043-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0045/CMP0045-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0046/CMP0046-OLD-existing-dependency-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0046/CMP0046-OLD-missing-dependency-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0049/CMP0049-OLD-result.txt1
-rw-r--r--Tests/RunCMake/CMP0049/CMP0049-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0050/CMP0050-OLD-result.txt1
-rw-r--r--Tests/RunCMake/CMP0050/CMP0050-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt1
-rw-r--r--Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt13
-rw-r--r--Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt4
-rw-r--r--Tests/RunCMake/CMP0053/CMP0053-OLD-stderr.txt13
-rw-r--r--Tests/RunCMake/CMP0054/CMP0054-OLD-stderr.txt11
-rw-r--r--Tests/RunCMake/CMP0054/CMP0054-keywords-OLD-stderr.txt11
-rw-r--r--Tests/RunCMake/CMP0054/CMP0054-policy-command-scope-stderr.txt11
-rw-r--r--Tests/RunCMake/CMP0054/CMP0054-policy-foreach-scope-stderr.txt55
-rw-r--r--Tests/RunCMake/CMP0054/CMP0054-policy-nested-if-stderr.txt11
-rw-r--r--Tests/RunCMake/CMP0054/CMP0054-policy-while-scope-stderr.txt55
-rw-r--r--Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0060/CMP0060-Common.cmake3
-rw-r--r--Tests/RunCMake/CMP0060/CMP0060-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt2
-rw-r--r--Tests/RunCMake/CMP0060/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CMP0064/CMP0064-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0065/RunCMakeTest.cmake7
-rw-r--r--Tests/RunCMake/CMP0069/CMP0069-NEW-cmake-stderr.txt4
-rw-r--r--Tests/RunCMake/CMP0069/CMP0069-NEW-compiler-stderr.txt4
-rw-r--r--Tests/RunCMake/CMP0069/CMP0069-NEW-generator-stderr.txt4
-rw-r--r--Tests/RunCMake/CMP0069/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/CMP0081/CMP0081-Common.cmake5
-rw-r--r--Tests/RunCMake/CMP0081/CMP0081-NEW-result.txt (renamed from Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-result.txt)0
-rw-r--r--Tests/RunCMake/CMP0081/CMP0081-NEW-stderr.txt4
-rw-r--r--Tests/RunCMake/CMP0081/CMP0081-NEW.cmake4
-rw-r--r--Tests/RunCMake/CMP0081/CMP0081-OLD-result.txt (renamed from Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-result.txt)0
-rw-r--r--Tests/RunCMake/CMP0081/CMP0081-OLD.cmake4
-rw-r--r--Tests/RunCMake/CMP0081/CMP0081-WARN-result.txt (renamed from Tests/RunCMake/CMP0037/CMP0037-OLD-space-result.txt)0
-rw-r--r--Tests/RunCMake/CMP0081/CMP0081-WARN-stderr.txt10
-rw-r--r--Tests/RunCMake/CMP0081/CMP0081-WARN.cmake2
-rw-r--r--Tests/RunCMake/CMP0081/CMakeLists.txt (renamed from Tests/RunCMake/COMPILE_LANGUAGE-genex/CMakeLists.txt)0
-rw-r--r--Tests/RunCMake/CMP0081/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/CMP0081/empty.cpp7
-rw-r--r--Tests/RunCMake/CMakeLists.txt328
-rw-r--r--Tests/RunCMake/CMakeRoleGlobalProperty/BuildAndTest/CMakeLists.txt10
-rw-r--r--Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in4
-rw-r--r--Tests/RunCMake/CMakeRoleGlobalProperty/FindDummyPackage.cmake8
-rw-r--r--Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake10
-rw-r--r--Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake17
-rw-r--r--Tests/RunCMake/CMakeRoleGlobalProperty/Script.cmake6
-rw-r--r--Tests/RunCMake/CMakeRoleGlobalProperty/sub/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/CMakeRoleGlobalProperty/test.cmake.in7
-rw-r--r--Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-VS.txt8
-rw-r--r--Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-Xcode.txt9
-rw-r--r--Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions.cmake5
-rw-r--r--Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileOptions-stderr-VS.txt8
-rw-r--r--Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileOptions.cmake5
-rw-r--r--Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt8
-rw-r--r--Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt9
-rw-r--r--Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories.cmake5
-rw-r--r--Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake20
-rw-r--r--Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake17
-rw-r--r--Tests/RunCMake/CPack/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/CPack/CPackTestHelpers.cmake90
-rw-r--r--Tests/RunCMake/CPack/DEB/Helpers.cmake21
-rw-r--r--Tests/RunCMake/CPack/External/Helpers.cmake31
-rw-r--r--Tests/RunCMake/CPack/External/Prerequirements.cmake0
-rw-r--r--Tests/RunCMake/CPack/README.txt28
-rw-r--r--Tests/RunCMake/CPack/RPM/Helpers.cmake26
-rw-r--r--Tests/RunCMake/CPack/RPM/default_expected_stderr.txt2
-rw-r--r--Tests/RunCMake/CPack/RunCMakeTest.cmake60
-rw-r--r--Tests/RunCMake/CPack/STGZ/Helpers.cmake29
-rw-r--r--Tests/RunCMake/CPack/VerifyResult.cmake14
-rw-r--r--Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/ExpectedFiles.cmake3
-rw-r--r--Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/both-stderr.txt1
-rw-r--r--Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/test.cmake26
-rw-r--r--Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake4
-rw-r--r--Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt2
-rw-r--r--Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake6
-rw-r--r--Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake45
-rw-r--r--Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake8
-rw-r--r--Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/ExpectedFiles.cmake16
-rw-r--r--Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake69
-rw-r--r--Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/test.cmake55
-rw-r--r--Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/ExpectedFiles.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/VerifyResult.cmake11
-rw-r--r--Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/test.cmake7
-rw-r--r--Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/ExpectedFiles.cmake6
-rw-r--r--Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/VerifyResult.cmake39
-rw-r--r--Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CMAKE_var-stderr.txt1
-rw-r--r--Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CPACK_var-stderr.txt1
-rw-r--r--Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/test.cmake34
-rw-r--r--Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake10
-rw-r--r--Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake5
-rw-r--r--Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/EXTERNAL/ExpectedFiles.cmake7
-rw-r--r--Tests/RunCMake/CPack/tests/EXTERNAL/VerifyResult.cmake3
-rw-r--r--Tests/RunCMake/CPack/tests/EXTERNAL/bad_major-stderr.txt6
-rw-r--r--Tests/RunCMake/CPack/tests/EXTERNAL/bad_minor-stderr.txt6
-rw-r--r--Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake31
-rw-r--r--Tests/RunCMake/CPack/tests/EXTERNAL/expected-json-1.0.txt176
-rw-r--r--Tests/RunCMake/CPack/tests/EXTERNAL/invalid_bad-stderr.txt6
-rw-r--r--Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stderr.txt1
-rw-r--r--Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stdout.txt1
-rw-r--r--Tests/RunCMake/CPack/tests/EXTERNAL/test.cmake86
-rw-r--r--Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake6
-rw-r--r--Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/ExpectedFiles.cmake5
-rw-r--r--Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/test.cmake4
-rw-r--r--Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/VerifyResult.cmake7
-rw-r--r--Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/test.cmake7
-rw-r--r--Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake4
-rw-r--r--Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake6
-rw-r--r--Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake5
-rw-r--r--Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake6
-rw-r--r--Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake14
-rw-r--r--Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake7
-rw-r--r--Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake16
-rw-r--r--Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake1
-rw-r--r--Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt2
-rw-r--r--Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/SYMLINKS/ExpectedFiles.cmake11
-rw-r--r--Tests/RunCMake/CPack/tests/TIMESTAMPS/ExpectedFiles.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/TIMESTAMPS/VerifyResult.cmake58
-rw-r--r--Tests/RunCMake/CPack/tests/TIMESTAMPS/test.cmake3
-rw-r--r--Tests/RunCMake/CPack/tests/USER_FILELIST/ExpectedFiles.cmake2
-rw-r--r--Tests/RunCMake/CPack/tests/VERSION/ExpectedFiles.cmake3
-rw-r--r--Tests/RunCMake/CPack/tests/VERSION/VerifyResult.cmake17
-rw-r--r--Tests/RunCMake/CPack/tests/VERSION/test.cmake14
-rw-r--r--Tests/RunCMake/CPackCommandLine/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CPackCommandLine/MultiConfig-check-stdout.txt4
-rw-r--r--Tests/RunCMake/CPackCommandLine/MultiConfig-package-stdout.txt8
-rw-r--r--Tests/RunCMake/CPackCommandLine/MultiConfig.cmake9
-rw-r--r--Tests/RunCMake/CPackCommandLine/NotAGenerator-result.txt (renamed from Tests/RunCMake/CommandLine/E___run_iwyu-no----result.txt)0
-rw-r--r--Tests/RunCMake/CPackCommandLine/NotAGenerator-stderr.txt1
-rw-r--r--Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake33
-rw-r--r--Tests/RunCMake/CPackCommandLine/foo.c4
-rw-r--r--Tests/RunCMake/CPackConfig/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/CPackConfig/Version1-check.cmake6
-rw-r--r--Tests/RunCMake/CPackConfig/Version1.cmake1
-rw-r--r--Tests/RunCMake/CPackConfig/Version2-check.cmake6
-rw-r--r--Tests/RunCMake/CPackConfig/Version2.cmake1
-rw-r--r--Tests/RunCMake/CPackConfig/Version3-check.cmake6
-rw-r--r--Tests/RunCMake/CPackConfig/Version3.cmake1
-rw-r--r--Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake2
-rw-r--r--Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake2
-rw-r--r--Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake2
-rw-r--r--Tests/RunCMake/CSharpCustomCommand/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CSharpCustomCommand/CommandWithOutput-check.cmake21
-rw-r--r--Tests/RunCMake/CSharpCustomCommand/CommandWithOutput.cmake13
-rw-r--r--Tests/RunCMake/CSharpCustomCommand/RunCMakeTest.cmake42
-rw-r--r--Tests/RunCMake/CSharpCustomCommand/TargetWithCommand-build-stdout.txt1
-rw-r--r--Tests/RunCMake/CSharpCustomCommand/TargetWithCommand.cmake4
-rw-r--r--Tests/RunCMake/CSharpCustomCommand/dummy.cs0
-rw-r--r--Tests/RunCMake/CSharpCustomCommand/test.cs.in8
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ImportLib.cmake45
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ImportLib.cs8
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ImportLibMixed.cxx8
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ImportLibMixedNative.cxx8
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ImportLibMixedNative.h13
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ImportLibNative.cxx8
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ImportLibNative.h13
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ImportLibPure.cxx8
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ImportLibSafe.cxx8
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ReferenceImport.cmake88
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ReferenceImport.cs13
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ReferenceImportMixed.cxx20
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ReferenceImportNative.cxx13
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ReferenceImportPure.cxx17
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/ReferenceImportSafe.cxx17
-rw-r--r--Tests/RunCMake/CSharpReferenceImport/RunCMakeTest.cmake41
-rw-r--r--Tests/RunCMake/CTest/CTestTestfile.cmake.in1
-rw-r--r--Tests/RunCMake/CTest/NotOn-check.cmake8
-rw-r--r--Tests/RunCMake/CTest/NotOn.cmake3
-rw-r--r--Tests/RunCMake/CTest/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt.in3
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/compare_options.cmake14
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-result.txt (renamed from Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-result.txt)0
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stderr.txt1
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stdout.txt13
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand.cmake10
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-result.txt (renamed from Tests/RunCMake/CMP0038/CMP0038-OLD-result.txt)0
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-stdout.txt7
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult.cmake19
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-result.txt (renamed from Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-result.txt)0
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stderr.txt2
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stdout.txt2
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions.cmake8
-rw-r--r--Tests/RunCMake/CTestCommandExpandLists/test.cmake.in15
-rw-r--r--Tests/RunCMake/CTestCommandLine/FailRegexFound-check.cmake13
-rw-r--r--Tests/RunCMake/CTestCommandLine/LabelCount-stdout.txt4
-rw-r--r--Tests/RunCMake/CTestCommandLine/RequiredRegexFound-check.cmake13
-rw-r--r--Tests/RunCMake/CTestCommandLine/RequiredRegexNotFound-check.cmake16
-rw-r--r--Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake134
-rw-r--r--Tests/RunCMake/CTestCommandLine/SkipRegexFound-check.cmake13
-rw-r--r--Tests/RunCMake/CTestCommandLine/TestAffinity-stdout.txt1
-rw-r--r--Tests/RunCMake/CTestCommandLine/TestStdin-stdin.txt1
-rw-r--r--Tests/RunCMake/CTestCommandLine/TestStdin-stdout.txt1
-rw-r--r--Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt (renamed from Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-result.txt)0
-rw-r--r--Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt1
-rw-r--r--Tests/RunCMake/CTestCommandLine/show-only_human-stdout.txt1
-rw-r--r--Tests/RunCMake/CTestCommandLine/show-only_json-v1-check.cmake1
-rw-r--r--Tests/RunCMake/CTestCommandLine/show-only_json-v1_check.py173
-rw-r--r--Tests/RunCMake/CTestCommandLine/show_only_json_check.py24
-rw-r--r--Tests/RunCMake/CTestCommandLine/test-load-fail-stderr.txt1
-rw-r--r--Tests/RunCMake/CTestCommandLine/test-load-fail-stdout.txt2
-rw-r--r--Tests/RunCMake/CTestCommandLine/test-load-wait-stdout.txt8
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/CMakeLists.txt.in9
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake23
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake169
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/checkfree1-ctest-s-res-check.cmake1
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/checkfree1.cmake7
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/checkfree2-ctest-s-res-check.cmake1
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/checkfree2.cmake8
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/combine.cmake5
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-baddealloc-result.txt (renamed from Tests/RunCMake/CommandLine/E_make_directory-three-directories-and-file-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-baddealloc.log2
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest1-result.txt (renamed from Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest1.log1
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest2-result.txt (renamed from Tests/RunCMake/ObjectLibrary/BadObjSource2-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest2.log2
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest3-result.txt (renamed from Tests/RunCMake/ObjectLibrary/ExportNotSupported-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest3.log3
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest4-result.txt (renamed from Tests/RunCMake/ObjectLibrary/LinkObjLHS-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest4.log3
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest5-result.txt (renamed from Tests/RunCMake/ObjectLibrary/LinkObjRHS1-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest5.log1
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-good1.log14
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-good2.log0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-leak-result.txt (renamed from Tests/RunCMake/ObjectLibrary/LinkObjRHS2-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-leak.log1
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nobegin-result.txt (renamed from Tests/RunCMake/ObjectLibrary/ObjWithObj-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nobegin.log0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noend-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noend.log1
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noid-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noid.log2
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nolog-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nores-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nores.log2
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-notenough-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-notenough.log2
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-noproc-count-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badcount-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badres-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets1-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets2-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets3-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets4-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets5-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets6-result.txt (renamed from Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets7-result.txt (renamed from Tests/RunCMake/TargetSources/RelativePathInInterface-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-good1-check.cmake20
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-good2-check.cmake6
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-nocount-result.txt (renamed from Tests/RunCMake/list/FILTER-NotList-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-nores-result.txt (renamed from Tests/RunCMake/list/REMOVE_DUPLICATES-NotList-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-nowidgets-result.txt (renamed from Tests/RunCMake/list/REMOVE_ITEM-NotList-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx400
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ensure_parallel-ctest-s-res-check.cmake16
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ensure_parallel.cmake11
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/lotsoftests-ctest-s-res-check.cmake1
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/lotsoftests.cmake16
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-check.cmake3
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-result.txt (renamed from Tests/RunCMake/ctest_memcheck/DummyAddressSanitizer-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-stderr.txt4
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/notenough1.cmake5
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-check.cmake3
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-result.txt (renamed from Tests/RunCMake/ctest_memcheck/DummyLeakSanitizer-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-stderr.txt4
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/notenough2.cmake5
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-check.cmake3
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-result.txt (renamed from Tests/RunCMake/ctest_memcheck/DummyLeakSanitizerPrintDefects-result.txt)0
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt4
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/notenough3.cmake5
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/process_count-ctest-s-res-check.cmake1
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/process_count.cmake5
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/resspec.json59
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/test.cmake.in23
-rw-r--r--Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in1
-rw-r--r--Tests/RunCMake/CacheNewline/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CacheNewline/CacheNewline-check.cmake16
-rw-r--r--Tests/RunCMake/CacheNewline/CacheNewline-stderr.txt2
-rw-r--r--Tests/RunCMake/CacheNewline/CacheNewline.cmake5
-rw-r--r--Tests/RunCMake/CacheNewline/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/CacheNewline/cache-regex.txt6
-rw-r--r--Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/CheckModules/CMP0075-stderr.txt50
-rw-r--r--Tests/RunCMake/CheckModules/CMP0075.cmake124
-rw-r--r--Tests/RunCMake/CheckModules/CheckIncludeFilesMissingLanguage-result.txt (renamed from Tests/RunCMake/list/REVERSE-NotList-result.txt)0
-rw-r--r--Tests/RunCMake/CheckModules/CheckIncludeFilesMissingLanguage-stderr.txt8
-rw-r--r--Tests/RunCMake/CheckModules/CheckIncludeFilesMissingLanguage.cmake3
-rw-r--r--Tests/RunCMake/CheckModules/CheckIncludeFilesOk.cmake6
-rw-r--r--Tests/RunCMake/CheckModules/CheckIncludeFilesOkNoC.cmake4
-rw-r--r--Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownArgument-result.txt (renamed from Tests/RunCMake/list/SORT-NotList-result.txt)0
-rw-r--r--Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownArgument-stderr.txt8
-rw-r--r--Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownArgument.cmake3
-rw-r--r--Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownLanguage-result.txt (renamed from Tests/RunCMake/list/SORT-TooManyArguments-result.txt)0
-rw-r--r--Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownLanguage-stderr.txt10
-rw-r--r--Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownLanguage.cmake3
-rw-r--r--Tests/RunCMake/CheckModules/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/CommandLine/B-no-arg-result.txt (renamed from Tests/RunCMake/target_link_libraries/SubDirTarget-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/B-no-arg-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/B-no-arg2-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/B-no-arg2-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-stderr.txt3
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-trailing--target-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-large-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-large-stderr.txt3
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-trailing--target-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-stderr.txt3
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-good-number-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-good-number-trailing--target-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-zero-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build--parallel-zero-stderr.txt3
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-stderr.txt3
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-trailing--target-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-stderr.txt3
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-trailing--target-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-stderr.txt3
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-good-number-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-good-number-trailing--target-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-stderr.txt3
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-jobs-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-stderr.txt3
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/C-no-file-stderr.txt4
-rw-r--r--Tests/RunCMake/CommandLine/C_basic-stderr.txt4
-rw-r--r--Tests/RunCMake/CommandLine/C_basic-stdout.txt1
-rw-r--r--Tests/RunCMake/CommandLine/C_basic.cmake2
-rw-r--r--Tests/RunCMake/CommandLine/C_basic_fullpath-stderr.txt4
-rw-r--r--Tests/RunCMake/CommandLine/C_basic_fullpath-stdout.txt1
-rw-r--r--Tests/RunCMake/CommandLine/C_basic_fullpath.cmake2
-rw-r--r--Tests/RunCMake/CommandLine/C_basic_initial-cache.txt5
-rw-r--r--Tests/RunCMake/CommandLine/C_buildsrcdir-stderr.txt8
-rw-r--r--Tests/RunCMake/CommandLine/C_buildsrcdir-stdout.txt2
-rw-r--r--Tests/RunCMake/CommandLine/C_buildsrcdir.cmake0
-rw-r--r--Tests/RunCMake/CommandLine/C_buildsrcdir/initial-cache.txt6
-rw-r--r--Tests/RunCMake/CommandLine/C_buildsrcdir/src/CMakeLists.txt6
-rw-r--r--Tests/RunCMake/CommandLine/C_buildsrcdir/src/PreLoad.cmake6
-rw-r--r--Tests/RunCMake/CommandLine/Cno-file-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Cno-file-stderr.txt3
-rw-r--r--Tests/RunCMake/CommandLine/D-no-src-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/D-no-src-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/DeprecateVS8-WARN-ON-stderr.txt5
-rw-r--r--Tests/RunCMake/CommandLine/Dno-src-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Dno-src-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-stderr.txt (renamed from Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-stderr.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-no----result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-no----stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-stderr.txt6
-rw-r--r--Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_capabilities-stdout.txt2
-rw-r--r--Tests/RunCMake/CommandLine/E_compare_files-different-eol-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_compare_files-different-eol-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake14
-rw-r--r--Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake8
-rw-r--r--Tests/RunCMake/CommandLine/E_false-extraargs-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_false-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_make_directory-directory-with-parent-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_make_directory-three-directories-check.cmake6
-rw-r--r--Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-stderr.txt (renamed from Tests/RunCMake/CommandLine/E_make_directory-three-directories-and-file-stderr.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/E_md5sum-dir-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_md5sum-dir-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_md5sum-mixed-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_md5sum-mixed-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/E_md5sum-mixed-stdout.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_md5sum-no-file-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_md5sum-no-file-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_md5sum-result.txt (renamed from Tests/RunCMake/CMP0039/CMP0039-OLD-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/E_md5sum-stdout.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-stderr.txt0
-rw-r--r--Tests/RunCMake/CommandLine/E_remove_directory-symlink-dir-check.cmake6
-rw-r--r--Tests/RunCMake/CommandLine/E_remove_directory-symlink-dir-stderr.txt0
-rw-r--r--Tests/RunCMake/CommandLine/E_remove_directory-symlink-file-check.cmake6
-rw-r--r--Tests/RunCMake/CommandLine/E_remove_directory-symlink-file-stderr.txt0
-rw-r--r--Tests/RunCMake/CommandLine/E_remove_directory-three-directories-check.cmake6
-rw-r--r--Tests/RunCMake/CommandLine/E_remove_directory-three-directories-stderr.txt0
-rw-r--r--Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-stderr.txt0
-rw-r--r--Tests/RunCMake/CommandLine/E_sha1sum-dir-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha1sum-dir-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha1sum-no-file-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha1sum-no-file-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha1sum-result.txt (renamed from Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/E_sha1sum-stdout.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha224sum-dir-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha224sum-dir-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha224sum-no-file-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha224sum-no-file-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha224sum-result.txt (renamed from Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/E_sha224sum-stdout.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha256sum-dir-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha256sum-dir-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha256sum-no-file-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha256sum-no-file-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha256sum-result.txt (renamed from Tests/RunCMake/CMP0041/CMP0041-OLD-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/E_sha256sum-stdout.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha384sum-dir-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha384sum-dir-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha384sum-no-file-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha384sum-no-file-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha384sum-result.txt (renamed from Tests/RunCMake/CMP0041/CMP0041-tid-OLD-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/E_sha384sum-stdout.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha512sum-dir-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha512sum-dir-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha512sum-no-file-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha512sum-no-file-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_sha512sum-result.txt (renamed from Tests/RunCMake/CMP0042/CMP0042-OLD-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/E_sha512sum-stdout.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_touch-nonexistent-dir-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_touch-nonexistent-dir-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt10
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-bad-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt5
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-ninja-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt4
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-unset-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt4
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-warnings-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt7
-rw-r--r--Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt9
-rw-r--r--Tests/RunCMake/CommandLine/NoArgs-stdout.txt1
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake349
-rw-r--r--Tests/RunCMake/CommandLine/S-no-arg-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/S-no-arg-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/S-no-arg2-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/S-no-arg2-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/U-no-src-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/U-no-src-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Uno-src-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Uno-src-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Wdev-stderr.txt4
-rw-r--r--Tests/RunCMake/CommandLine/Werror_deprecated-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Werror_dev-stderr.txt4
-rw-r--r--Tests/RunCMake/CommandLine/Wizard-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Wizard-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/Wno-error_deprecated-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/Wno-error_dev-stderr.txt4
-rw-r--r--Tests/RunCMake/CommandLine/cmake_depends/.gitattributes2
-rw-r--r--Tests/RunCMake/CommandLine/compare_files/.gitattributes2
-rw-r--r--Tests/RunCMake/CommandLine/compare_files/crlf1
-rw-r--r--Tests/RunCMake/CommandLine/compare_files/empty10
-rw-r--r--Tests/RunCMake/CommandLine/compare_files/empty20
-rw-r--r--Tests/RunCMake/CommandLine/compare_files/lf1
-rw-r--r--Tests/RunCMake/CommandLine/dir-install-options-to-vars/cmake_install.cmake15
-rw-r--r--Tests/RunCMake/CommandLine/install-bad-dir-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/install-no-dir-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/install-no-dir-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/install-options-to-vars-result.txt (renamed from Tests/RunCMake/CMP0043/CMP0043-OLD-result.txt)0
-rw-r--r--Tests/RunCMake/CommandLine/install-options-to-vars-stderr.txt4
-rw-r--r--Tests/RunCMake/CommandLine/no-S-B-stderr.txt4
-rw-r--r--Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized.cmake4
-rw-r--r--Tests/RunCMake/CommandLine/trace-redirect-check.cmake13
-rw-r--r--Tests/RunCMake/CommandLine/trace-redirect-nofile-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/trace-redirect-nofile-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/trace-redirect-nofile.cmake0
-rw-r--r--Tests/RunCMake/CommandLine/trace-redirect-stdout.txt1
-rw-r--r--Tests/RunCMake/CommandLine/trace-redirect.cmake0
-rw-r--r--Tests/RunCMake/CommandLine/warn-uninitialized-stderr.txt53
-rw-r--r--Tests/RunCMake/CommandLine/warn-uninitialized.cmake18
-rw-r--r--Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake34
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-file-result.txt1
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-file-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-without-action-result.txt1
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-without-action-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLineTar/bad-wrong-flag-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLineTar/end-opt2-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLineTar/gnutar-gz.cmake4
-rw-r--r--Tests/RunCMake/CommandLineTar/pax-zstd.cmake10
-rw-r--r--Tests/RunCMake/CommandLineTar/pax.cmake4
-rw-r--r--Tests/RunCMake/CommandLineTar/roundtrip.cmake14
-rw-r--r--Tests/RunCMake/CommandLineTar/test-file.txt0
-rw-r--r--Tests/RunCMake/CommandLineTar/without-files-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLineTar/zip-filtered.cmake28
-rw-r--r--Tests/RunCMake/CompilerLauncher/CUDA-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerLauncher/CUDA-launch-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerLauncher/CUDA-launch.cmake3
-rw-r--r--Tests/RunCMake/CompilerLauncher/CUDA.cmake4
-rw-r--r--Tests/RunCMake/CompilerLauncher/Fortran-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerLauncher/Fortran-launch-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerLauncher/Fortran-launch.cmake3
-rw-r--r--Tests/RunCMake/CompilerLauncher/Fortran.cmake4
-rw-r--r--Tests/RunCMake/CompilerLauncher/OBJC-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerLauncher/OBJC-launch-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerLauncher/OBJC-launch.cmake3
-rw-r--r--Tests/RunCMake/CompilerLauncher/OBJC.cmake4
-rw-r--r--Tests/RunCMake/CompilerLauncher/OBJCXX-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerLauncher/OBJCXX-launch-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/CompilerLauncher/OBJCXX-launch.cmake3
-rw-r--r--Tests/RunCMake/CompilerLauncher/OBJCXX.cmake4
-rw-r--r--Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake21
-rw-r--r--Tests/RunCMake/CompilerLauncher/main.F2
-rw-r--r--Tests/RunCMake/CompilerLauncher/main.cu4
-rw-r--r--Tests/RunCMake/CompilerLauncher/main.m4
-rw-r--r--Tests/RunCMake/CompilerLauncher/main.mm4
-rw-r--r--Tests/RunCMake/Configure/RerunCMake-build3-result.txt1
-rw-r--r--Tests/RunCMake/Configure/RerunCMake-build3-stdout.txt1
-rw-r--r--Tests/RunCMake/Configure/RerunCMake-build4-result.txt1
-rw-r--r--Tests/RunCMake/Configure/RerunCMake-build4-stdout.txt1
-rw-r--r--Tests/RunCMake/Configure/RerunCMake.cmake6
-rw-r--r--Tests/RunCMake/Configure/RunCMakeTest.cmake17
-rw-r--r--Tests/RunCMake/Cppcheck/C-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/Cppcheck/C-bad-Build-result.txt1
-rw-r--r--Tests/RunCMake/Cppcheck/C-bad-Build-stdout.txt2
-rw-r--r--Tests/RunCMake/Cppcheck/C-bad.cmake3
-rw-r--r--Tests/RunCMake/Cppcheck/C-error-Build-result.txt1
-rw-r--r--Tests/RunCMake/Cppcheck/C-error-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/Cppcheck/C-error.cmake3
-rw-r--r--Tests/RunCMake/Cppcheck/C-launch-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/Cppcheck/C-launch.cmake3
-rw-r--r--Tests/RunCMake/Cppcheck/C.cmake4
-rw-r--r--Tests/RunCMake/Cppcheck/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/Cppcheck/CXX-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/Cppcheck/CXX-launch-Build-stdout.txt1
-rw-r--r--Tests/RunCMake/Cppcheck/CXX-launch.cmake3
-rw-r--r--Tests/RunCMake/Cppcheck/CXX.cmake3
-rw-r--r--Tests/RunCMake/Cppcheck/RunCMakeTest.cmake24
-rw-r--r--Tests/RunCMake/Cppcheck/main.c4
-rw-r--r--Tests/RunCMake/Cppcheck/main.cxx4
-rw-r--r--Tests/RunCMake/Cpplint/C-error-Build-result.txt2
-rw-r--r--Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt2
-rw-r--r--Tests/RunCMake/Cpplint/CXX-error-Build-result.txt2
-rw-r--r--Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt2
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake3
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg-build-check.cmake3
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg.cmake14
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg-build-check.cmake1
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg.cmake9
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake6
-rw-r--r--Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake9
-rw-r--r--Tests/RunCMake/ExternalData/BadAlgoMap1-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/BadAlgoMap2-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/BadOption1-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/BadOption2-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/BadRecurse1-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/BadRecurse2-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/BadRecurse3-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/BadSeries1-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/BadSeries2-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/BadSeries3-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/Directory1-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/Directory2-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/Directory3-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/Directory4-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/Directory5-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/MissingData-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake18
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake7
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake18
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake7
-rw-r--r--Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake3
-rw-r--r--Tests/RunCMake/ExternalProject/IncludeScope-Add-result.txt1
-rw-r--r--Tests/RunCMake/ExternalProject/IncludeScope-Add-stderr.txt7
-rw-r--r--Tests/RunCMake/ExternalProject/IncludeScope-Add.cmake12
-rw-r--r--Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-result.txt1
-rw-r--r--Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-stderr.txt7
-rw-r--r--Tests/RunCMake/ExternalProject/IncludeScope-Add_Step.cmake13
-rw-r--r--Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-result.txt1
-rw-r--r--Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stderr.txt1
-rw-r--r--Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stdout.txt8
-rw-r--r--Tests/RunCMake/ExternalProject/LogOutputOnFailure.cmake20
-rw-r--r--Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-result.txt1
-rw-r--r--Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stderr.txt1
-rw-r--r--Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stdout.txt7
-rw-r--r--Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged.cmake21
-rw-r--r--Tests/RunCMake/ExternalProject/MultiCommand-build-stdout.txt15
-rw-r--r--Tests/RunCMake/ExternalProject/MultiCommand.cmake30
-rw-r--r--Tests/RunCMake/ExternalProject/NoOptions-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalProject/RunCMakeTest.cmake40
-rw-r--r--Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt4
-rw-r--r--Tests/RunCMake/ExternalProject/Substitutions-build-stdout.txt7
-rw-r--r--Tests/RunCMake/ExternalProject/Substitutions.cmake25
-rw-r--r--Tests/RunCMake/ExternalProject/UsesTerminal.cmake3
-rw-r--r--Tests/RunCMake/FPHSA/CustomMessageConfig.cmake1
-rw-r--r--Tests/RunCMake/FPHSA/CustomMessageConfigVersion.cmake4
-rw-r--r--Tests/RunCMake/FPHSA/FindCustomMessage.cmake17
-rw-r--r--Tests/RunCMake/FPHSA/FindPseudoNoVersionVar.cmake6
-rw-r--r--Tests/RunCMake/FPHSA/RunCMakeTest.cmake20
-rw-r--r--Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable-stdout.txt2
-rw-r--r--Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable.cmake1
-rw-r--r--Tests/RunCMake/FPHSA/any_version_find_0-stdout.txt2
-rw-r--r--Tests/RunCMake/FPHSA/any_version_find_0.cmake1
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_1-result.txt1
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_1-stderr.txt7
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_1.cmake4
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_2-result.txt1
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_2-stderr.txt8
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_2.cmake5
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_3-result.txt1
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_3-stderr.txt9
-rw-r--r--Tests/RunCMake/FPHSA/custom_message_3.cmake5
-rw-r--r--Tests/RunCMake/FetchContent/CMakeLists.txt7
-rw-r--r--Tests/RunCMake/FetchContent/DirOverrides.cmake46
-rw-r--r--Tests/RunCMake/FetchContent/DirectIgnoresDetails-stdout.txt1
-rw-r--r--Tests/RunCMake/FetchContent/DirectIgnoresDetails.cmake12
-rw-r--r--Tests/RunCMake/FetchContent/DownloadTwice-result.txt1
-rw-r--r--Tests/RunCMake/FetchContent/DownloadTwice-stderr.txt1
-rw-r--r--Tests/RunCMake/FetchContent/DownloadTwice.cmake9
-rw-r--r--Tests/RunCMake/FetchContent/FirstDetailsWin-stdout.txt1
-rw-r--r--Tests/RunCMake/FetchContent/FirstDetailsWin.cmake16
-rw-r--r--Tests/RunCMake/FetchContent/GetProperties.cmake67
-rw-r--r--Tests/RunCMake/FetchContent/MakeAvailable-stdout.txt2
-rw-r--r--Tests/RunCMake/FetchContent/MakeAvailable.cmake20
-rw-r--r--Tests/RunCMake/FetchContent/MakeAvailableTwice-stdout.txt4
-rw-r--r--Tests/RunCMake/FetchContent/MakeAvailableTwice.cmake12
-rw-r--r--Tests/RunCMake/FetchContent/MakeAvailableUndeclared-result.txt1
-rw-r--r--Tests/RunCMake/FetchContent/MakeAvailableUndeclared-stderr.txt1
-rw-r--r--Tests/RunCMake/FetchContent/MakeAvailableUndeclared.cmake3
-rw-r--r--Tests/RunCMake/FetchContent/MissingDetails-result.txt1
-rw-r--r--Tests/RunCMake/FetchContent/MissingDetails-stderr.txt1
-rw-r--r--Tests/RunCMake/FetchContent/MissingDetails.cmake3
-rw-r--r--Tests/RunCMake/FetchContent/RunCMakeTest.cmake32
-rw-r--r--Tests/RunCMake/FetchContent/SameGenerator.cmake17
-rw-r--r--Tests/RunCMake/FetchContent/ScriptMode.cmake35
-rw-r--r--Tests/RunCMake/FetchContent/UsesTerminalOverride-stdout.txt2
-rw-r--r--Tests/RunCMake/FetchContent/UsesTerminalOverride.cmake17
-rw-r--r--Tests/RunCMake/FetchContent/VarDefinitions.cmake75
-rw-r--r--Tests/RunCMake/FetchContent/WithProject/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/FetchContent/WithoutProject/confirmMessage.cmake1
-rw-r--r--Tests/RunCMake/FileAPI/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/FileAPI/ClientStateful-check.cmake68
-rw-r--r--Tests/RunCMake/FileAPI/ClientStateful-check.py258
-rw-r--r--Tests/RunCMake/FileAPI/ClientStateful-prep.cmake73
-rw-r--r--Tests/RunCMake/FileAPI/ClientStateful.cmake0
-rw-r--r--Tests/RunCMake/FileAPI/ClientStateless-check.cmake15
-rw-r--r--Tests/RunCMake/FileAPI/ClientStateless-check.py26
-rw-r--r--Tests/RunCMake/FileAPI/ClientStateless-prep.cmake5
-rw-r--r--Tests/RunCMake/FileAPI/ClientStateless.cmake0
-rw-r--r--Tests/RunCMake/FileAPI/DuplicateStateless-check.cmake20
-rw-r--r--Tests/RunCMake/FileAPI/DuplicateStateless-check.py31
-rw-r--r--Tests/RunCMake/FileAPI/DuplicateStateless-prep.cmake10
-rw-r--r--Tests/RunCMake/FileAPI/DuplicateStateless.cmake0
-rw-r--r--Tests/RunCMake/FileAPI/Empty-check.cmake8
-rw-r--r--Tests/RunCMake/FileAPI/Empty-check.py15
-rw-r--r--Tests/RunCMake/FileAPI/Empty-prep.cmake1
-rw-r--r--Tests/RunCMake/FileAPI/Empty.cmake0
-rw-r--r--Tests/RunCMake/FileAPI/EmptyClient-check.cmake9
-rw-r--r--Tests/RunCMake/FileAPI/EmptyClient-check.py20
-rw-r--r--Tests/RunCMake/FileAPI/EmptyClient-prep.cmake2
-rw-r--r--Tests/RunCMake/FileAPI/EmptyClient.cmake0
-rw-r--r--Tests/RunCMake/FileAPI/MixedStateless-check.cmake16
-rw-r--r--Tests/RunCMake/FileAPI/MixedStateless-check.py27
-rw-r--r--Tests/RunCMake/FileAPI/MixedStateless-prep.cmake6
-rw-r--r--Tests/RunCMake/FileAPI/MixedStateless.cmake0
-rw-r--r--Tests/RunCMake/FileAPI/Nothing-check.cmake1
-rw-r--r--Tests/RunCMake/FileAPI/Nothing-prep.cmake1
-rw-r--r--Tests/RunCMake/FileAPI/Nothing.cmake0
-rw-r--r--Tests/RunCMake/FileAPI/RunCMakeTest.cmake58
-rw-r--r--Tests/RunCMake/FileAPI/SharedStateless-check.cmake15
-rw-r--r--Tests/RunCMake/FileAPI/SharedStateless-check.py22
-rw-r--r--Tests/RunCMake/FileAPI/SharedStateless-prep.cmake6
-rw-r--r--Tests/RunCMake/FileAPI/SharedStateless.cmake0
-rw-r--r--Tests/RunCMake/FileAPI/Stale-check.cmake4
-rw-r--r--Tests/RunCMake/FileAPI/Stale-prep.cmake1
-rw-r--r--Tests/RunCMake/FileAPI/Stale.cmake0
-rw-r--r--Tests/RunCMake/FileAPI/alias/CMakeLists.txt10
-rw-r--r--Tests/RunCMake/FileAPI/cache-v2-ClientStateful-check.cmake11
-rw-r--r--Tests/RunCMake/FileAPI/cache-v2-ClientStateful-prep.cmake4
-rw-r--r--Tests/RunCMake/FileAPI/cache-v2-ClientStateless-check.cmake11
-rw-r--r--Tests/RunCMake/FileAPI/cache-v2-ClientStateless-prep.cmake2
-rw-r--r--Tests/RunCMake/FileAPI/cache-v2-SharedStateless-check.cmake10
-rw-r--r--Tests/RunCMake/FileAPI/cache-v2-SharedStateless-prep.cmake2
-rw-r--r--Tests/RunCMake/FileAPI/cache-v2-check.py134
-rw-r--r--Tests/RunCMake/FileAPI/cache-v2.cmake14
-rw-r--r--Tests/RunCMake/FileAPI/check_index.py163
-rw-r--r--Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateful-check.cmake11
-rw-r--r--Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateful-prep.cmake4
-rw-r--r--Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateless-check.cmake11
-rw-r--r--Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateless-prep.cmake2
-rw-r--r--Tests/RunCMake/FileAPI/cmakeFiles-v1-SharedStateless-check.cmake10
-rw-r--r--Tests/RunCMake/FileAPI/cmakeFiles-v1-SharedStateless-prep.cmake2
-rw-r--r--Tests/RunCMake/FileAPI/cmakeFiles-v1-check.py94
-rw-r--r--Tests/RunCMake/FileAPI/cmakeFiles-v1.cmake8
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-check.cmake12
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-prep.cmake4
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-check.cmake12
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-prep.cmake2
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-check.cmake11
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-prep.cmake2
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2-check.py5342
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2.cmake37
-rw-r--r--Tests/RunCMake/FileAPI/custom/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/FileAPI/cxx/CMakeLists.txt19
-rw-r--r--Tests/RunCMake/FileAPI/dir/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/FileAPI/dir/dir/CMakeLists.txt0
-rw-r--r--Tests/RunCMake/FileAPI/dir/dirtest.cmake0
-rw-r--r--Tests/RunCMake/FileAPI/empty.c0
-rw-r--r--Tests/RunCMake/FileAPI/empty.cxx0
-rw-r--r--Tests/RunCMake/FileAPI/imported/CMakeLists.txt24
-rw-r--r--Tests/RunCMake/FileAPI/include_test.cmake9
-rw-r--r--Tests/RunCMake/FileAPI/object/CMakeLists.txt13
-rw-r--r--Tests/RunCMake/FileAPIDummyFile.cmake0
-rw-r--r--Tests/RunCMake/FileAPIExternalSource/CMakeLists.txt13
-rw-r--r--Tests/RunCMake/FileAPIExternalSource/empty.c0
-rw-r--r--Tests/RunCMake/File_Generate/CMP0070-NEW-check.cmake13
-rw-r--r--Tests/RunCMake/File_Generate/CMP0070-NEW.cmake2
-rw-r--r--Tests/RunCMake/File_Generate/CMP0070-OLD-check.cmake13
-rw-r--r--Tests/RunCMake/File_Generate/CMP0070-OLD.cmake3
-rw-r--r--Tests/RunCMake/File_Generate/CMP0070-WARN-check.cmake13
-rw-r--r--Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt27
-rw-r--r--Tests/RunCMake/File_Generate/CMP0070-WARN.cmake2
-rw-r--r--Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex-result.txt1
-rw-r--r--Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex.cmake10
-rw-r--r--Tests/RunCMake/File_Generate/CarryPermissions-result.txt1
-rw-r--r--Tests/RunCMake/File_Generate/GenerateSource-result.txt1
-rw-r--r--Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt3
-rw-r--r--Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake7
-rw-r--r--Tests/RunCMake/File_Generate/OutputNameMatchesOtherSources-result.txt1
-rw-r--r--Tests/RunCMake/File_Generate/ReRunCMake-result.txt1
-rw-r--r--Tests/RunCMake/File_Generate/ReRunCMake.cmake2
-rw-r--r--Tests/RunCMake/File_Generate/RunCMakeTest.cmake22
-rw-r--r--Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt1
-rw-r--r--Tests/RunCMake/File_Generate/WriteIfDifferent.cmake2
-rw-r--r--Tests/RunCMake/File_Generate/relative-input-NEW.txt1
-rw-r--r--Tests/RunCMake/FindBoost/CMP0093-NEW-stdout.txt1
-rw-r--r--Tests/RunCMake/FindBoost/CMP0093-NEW.cmake2
-rw-r--r--Tests/RunCMake/FindBoost/CMP0093-OLD-stdout.txt1
-rw-r--r--Tests/RunCMake/FindBoost/CMP0093-OLD.cmake2
-rw-r--r--Tests/RunCMake/FindBoost/CMP0093-UNSET-stdout.txt1
-rw-r--r--Tests/RunCMake/FindBoost/CMP0093-UNSET.cmake1
-rw-r--r--Tests/RunCMake/FindBoost/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage-stdout.txt2
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage.cmake2
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage/BoostConfig.cmake4
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage/BoostConfigVersion.cmake7
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfig.cmake140
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfigVersion.cmake12
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/BoostDetectToolset-1.70.0.cmake1
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config-version.cmake12
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config.cmake98
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-shared.cmake62
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-static.cmake58
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config-version.cmake12
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config.cmake20
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config-version.cmake12
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config.cmake98
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-shared.cmake62
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-static.cmake58
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config-version.cmake12
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config.cmake98
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-shared.cmake62
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-static.cmake58
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfig.cmake26
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfigVersion.cmake7
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/include/boost/version.hpp34
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfig.cmake7
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfigVersion.cmake7
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/include/boost/version.hpp34
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfig.cmake29
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfigVersion.cmake7
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_New/include/boost/version.hpp34
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_date_time.a0
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_mpi_python.a0
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python.a0
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python_release.a0
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfig.cmake25
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfigVersion.cmake7
-rw-r--r--Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/include/boost/version.hpp34
-rw-r--r--Tests/RunCMake/FindBoost/CommonNotFound-stderr.txt1
-rw-r--r--Tests/RunCMake/FindBoost/CommonNotFound-stdout.txt1
-rw-r--r--Tests/RunCMake/FindBoost/CommonNotFound.cmake2
-rw-r--r--Tests/RunCMake/FindBoost/CommonResults-stdout.txt13
-rw-r--r--Tests/RunCMake/FindBoost/CommonResults.cmake25
-rw-r--r--Tests/RunCMake/FindBoost/ConfigMode.cmake2
-rw-r--r--Tests/RunCMake/FindBoost/ConfigModeNotFound.cmake2
-rw-r--r--Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix-stdout.txt34
-rw-r--r--Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix.cmake6
-rw-r--r--Tests/RunCMake/FindBoost/LegacyVars-NoHeaderTarget.cmake6
-rw-r--r--Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined-stdout.txt34
-rw-r--r--Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined.cmake6
-rw-r--r--Tests/RunCMake/FindBoost/LegacyVars.cmake28
-rw-r--r--Tests/RunCMake/FindBoost/MissingTarget-stdout.txt22
-rw-r--r--Tests/RunCMake/FindBoost/MissingTarget.cmake25
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/chrono.hpp0
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/config.hpp0
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/system/config.hpp0
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/timer.hpp0
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/version.hpp34
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_chrono-mt-1_70.lib0
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_system-mt-1_70.lib0
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_timer-mt-1_70.lib0
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono-mt-1_70.lib0
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.a0
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.so.1.70.00
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system-mt-1_70.lib0
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.a0
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.so.1.70.00
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer-mt-1_70.lib0
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.a0
-rw-r--r--Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.so.1.70.00
-rw-r--r--Tests/RunCMake/FindBoost/ModuleMode.cmake4
-rw-r--r--Tests/RunCMake/FindBoost/ModuleModeNotFound.cmake4
-rw-r--r--Tests/RunCMake/FindBoost/NoCXX-stderr.txt1
-rw-r--r--Tests/RunCMake/FindBoost/NoCXX.cmake1
-rw-r--r--Tests/RunCMake/FindBoost/RunCMakeTest.cmake28
-rw-r--r--Tests/RunCMake/FindLua/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/FindLua/FindLuaTest.cmake87
-rw-r--r--Tests/RunCMake/FindLua/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/FindLua/prefix1/include/lua.h8
-rw-r--r--Tests/RunCMake/FindLua/prefix2/include/lua5.1/lua.h8
-rw-r--r--Tests/RunCMake/FindLua/prefix2/include/lua5.2/lua.h8
-rw-r--r--Tests/RunCMake/FindLua/prefix2/include/lua5.3/lua.h8
-rw-r--r--Tests/RunCMake/FindLua/prefix2/include/lua5.9/lua.h8
-rw-r--r--Tests/RunCMake/FindMatlab/MatlabTest1.cmake3
-rw-r--r--Tests/RunCMake/FindMatlab/MatlabTest2.cmake4
-rw-r--r--Tests/RunCMake/FindMatlab/RunCMakeTest.cmake11
-rw-r--r--Tests/RunCMake/FindOpenGL/CMP0072-NEW-stdout.txt3
-rw-r--r--Tests/RunCMake/FindOpenGL/CMP0072-NEW.cmake2
-rw-r--r--Tests/RunCMake/FindOpenGL/CMP0072-OLD-stdout.txt3
-rw-r--r--Tests/RunCMake/FindOpenGL/CMP0072-OLD.cmake2
-rw-r--r--Tests/RunCMake/FindOpenGL/CMP0072-WARN-stderr.txt21
-rw-r--r--Tests/RunCMake/FindOpenGL/CMP0072-WARN-stdout.txt3
-rw-r--r--Tests/RunCMake/FindOpenGL/CMP0072-WARN.cmake1
-rw-r--r--Tests/RunCMake/FindOpenGL/CMP0072-common.cmake13
-rw-r--r--Tests/RunCMake/FindOpenGL/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/FindOpenGL/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_MODULE_NAME.cmake28
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH.cmake21
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PREFIX_PATH.cmake21
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake91
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake2
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_VERSION_OPERATORS.cmake83
-rw-r--r--Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake4
-rwxr-xr-xTests/RunCMake/FindPkgConfig/dummy-pkg-config.bat54
-rw-r--r--Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch.pc12
-rw-r--r--Tests/RunCMake/FindPkgConfig/target_subdir/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/Framework/FrameworkLayout.cmake7
-rw-r--r--Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt3
-rw-r--r--Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt3
-rw-r--r--Tests/RunCMake/Framework/InstallBeforeFramework-stderr.txt7
-rw-r--r--Tests/RunCMake/Framework/InstallBeforeFramework.cmake5
-rw-r--r--Tests/RunCMake/Framework/RunCMakeTest.cmake20
-rw-r--r--Tests/RunCMake/Framework/ios.cmake12
-rw-r--r--Tests/RunCMake/GNUInstallDirs/Opt-FreeBSD-stderr.txt30
-rw-r--r--Tests/RunCMake/GNUInstallDirs/Root-FreeBSD-stderr.txt30
-rw-r--r--Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake12
-rw-r--r--Tests/RunCMake/GNUInstallDirs/Usr-FreeBSD-stderr.txt30
-rw-r--r--Tests/RunCMake/GNUInstallDirs/UsrLocal-FreeBSD-stderr.txt30
-rw-r--r--Tests/RunCMake/GenerateExportHeader/GEH.cmake19
-rw-r--r--Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp10
-rw-r--r--Tests/RunCMake/GenerateExportHeader/includeguard/CMakeLists.txt19
-rw-r--r--Tests/RunCMake/GenerateExportHeader/includeguard/libincludeguard.cpp0
-rw-r--r--Tests/RunCMake/GenerateExportHeader/includeguard/main.cpp.in10
-rw-r--r--Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/.gitattributes2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h2
-rw-r--r--Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h2
-rw-r--r--Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt4
-rw-r--r--Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt4
-rw-r--r--Tests/RunCMake/GeneratorExpression/BadNOT-stderr.txt4
-rw-r--r--Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt4
-rw-r--r--Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt9
-rw-r--r--Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake1
-rw-r--r--Tests/RunCMake/GeneratorExpression/BadStrEqual-stderr.txt4
-rw-r--r--Tests/RunCMake/GeneratorExpression/BadTargetName-stderr.txt4
-rw-r--r--Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt6
-rw-r--r--Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/CMP0085-NEW-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/CMP0085-NEW.cmake4
-rw-r--r--Tests/RunCMake/GeneratorExpression/CMP0085-OLD-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/CMP0085-OLD.cmake4
-rw-r--r--Tests/RunCMake/GeneratorExpression/CMP0085-WARN-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/CMP0085-WARN-stderr.txt33
-rw-r--r--Tests/RunCMake/GeneratorExpression/CMP0085-WARN.cmake4
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command-stderr.txt6
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command.cmake8
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target-stderr.txt6
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target.cmake5
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable-stderr.txt6
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library-stderr.txt6
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_test-stderr.txt4
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-install-stderr.txt4
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources-stderr.txt6
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources.cmake5
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command.cmake4
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-stderr.txt11
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target.cmake4
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-stderr.txt11
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable.cmake5
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-stderr.txt11
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-stderr.txt11
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test.cmake5
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-stderr.txt9
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install.cmake5
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-unknown-lang.cmake4
-rw-r--r--Tests/RunCMake/GeneratorExpression/FILTER-Exclude-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/FILTER-Exclude.cmake4
-rw-r--r--Tests/RunCMake/GeneratorExpression/FILTER-Include-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/FILTER-Include.cmake4
-rw-r--r--Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/FILTER-empty-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/FILTER-empty.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/GENEX_EVAL-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion1-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion1-stderr.txt26
-rw-r--r--Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion1.cmake9
-rw-r--r--Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-stderr.txt26
-rw-r--r--Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2.cmake10
-rw-r--r--Tests/RunCMake/GeneratorExpression/GENEX_EVAL.cmake12
-rw-r--r--Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME.cmake9
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-stderr.txt2
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-stderr.txt2
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-stderr.txt2
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID.cmake10
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-stderr.txt2
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION.cmake10
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-stderr.txt9
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID.cmake4
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-stderr.txt9
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION.cmake4
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt9
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake9
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-stderr.txt2
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-stderr.txt2
-rw-r--r--Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/ResultValidator.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake63
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_EXISTS.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-check.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target-check.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target.cmake106
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-stderr.txt6
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target.cmake7
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME.cmake135
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-check.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target-check.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target.cmake49
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-stderr.txt6
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target.cmake7
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX.cmake49
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-check.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target-check.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target.cmake49
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-stderr.txt6
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target.cmake7
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX.cmake49
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-arg-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-arg-stderr.txt9
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-arg.cmake7
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-target-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-target-stderr.txt9
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-target.cmake5
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-non-valid-target-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-non-valid-target-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-non-valid-target.cmake5
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion1-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion1-stderr.txt9
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion1.cmake9
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion2-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion2-stderr.txt26
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion2.cmake12
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL.cmake10
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-stderr.txt6
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target.cmake7
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-stderr.txt6
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target.cmake7
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-stderr.txt6
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target.cmake7
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-check.cmake6
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-stderr.txt9
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target-check.cmake5
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target.cmake2
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake18
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake4
-rw-r--r--Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE.cmake3
-rw-r--r--Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME-check.cmake7
-rw-r--r--Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake16
-rw-r--r--Tests/RunCMake/GeneratorInstance/BadInstance-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorInstance/BadInstance-stderr.txt10
-rw-r--r--Tests/RunCMake/GeneratorInstance/BadInstance-toolchain.cmake1
-rw-r--r--Tests/RunCMake/GeneratorInstance/BadInstance.cmake1
-rw-r--r--Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-stderr.txt10
-rw-r--r--Tests/RunCMake/GeneratorInstance/BadInstanceToolchain.cmake1
-rw-r--r--Tests/RunCMake/GeneratorInstance/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/GeneratorInstance/DefaultInstance.cmake13
-rw-r--r--Tests/RunCMake/GeneratorInstance/MissingInstance-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorInstance/MissingInstance-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorInstance/MissingInstance-toolchain.cmake1
-rw-r--r--Tests/RunCMake/GeneratorInstance/MissingInstance.cmake1
-rw-r--r--Tests/RunCMake/GeneratorInstance/MissingInstanceToolchain-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorInstance/MissingInstanceToolchain-stderr.txt8
-rw-r--r--Tests/RunCMake/GeneratorInstance/MissingInstanceToolchain.cmake1
-rw-r--r--Tests/RunCMake/GeneratorInstance/NoInstance-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorInstance/NoInstance-stderr.txt4
-rw-r--r--Tests/RunCMake/GeneratorInstance/NoInstance.cmake7
-rw-r--r--Tests/RunCMake/GeneratorInstance/RunCMakeTest.cmake22
-rw-r--r--Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake1
-rw-r--r--Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt1
-rw-r--r--Tests/RunCMake/GeneratorToolset/BadToolsetHostArchTwice-stderr.txt2
-rw-r--r--Tests/RunCMake/GeneratorToolset/BadToolsetVersion-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorToolset/BadToolsetVersion-stderr.txt10
-rw-r--r--Tests/RunCMake/GeneratorToolset/BadToolsetVersion.cmake1
-rw-r--r--Tests/RunCMake/GeneratorToolset/BadToolsetVersionTwice-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorToolset/BadToolsetVersionTwice-stderr.txt10
-rw-r--r--Tests/RunCMake/GeneratorToolset/BadToolsetVersionTwice.cmake1
-rw-r--r--Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake38
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetCudaBoth-stdout.txt2
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetCudaOnly-stdout.txt2
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-result.txt1
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt12
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly.cmake1
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetCudaVersionOnly-stdout.txt2
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetCudaVersionOnly.cmake (renamed from Tests/RunCMake/GeneratorToolset/TestToolsetCudaOnly.cmake)0
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt2
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake13
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x64-stdout.txt (renamed from Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly-stdout.txt)0
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x64.cmake (renamed from Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly.cmake)0
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86-stdout.txt2
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86.cmake2
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetVersionBoth-stdout.txt2
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetVersionBoth.cmake2
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetVersionOnly-stdout.txt2
-rw-r--r--Tests/RunCMake/GeneratorToolset/TestToolsetVersionOnly.cmake2
-rw-r--r--Tests/RunCMake/GetPrerequisites/ExecutableScripts-stdout.txt3
-rw-r--r--Tests/RunCMake/GetPrerequisites/ExecutableScripts.cmake19
-rw-r--r--Tests/RunCMake/GetPrerequisites/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/GetPrerequisites/TargetMissing-stderr.txt3
-rw-r--r--Tests/RunCMake/GetPrerequisites/TargetMissing.cmake4
-rwxr-xr-xTests/RunCMake/GetPrerequisites/script3
-rwxr-xr-xTests/RunCMake/GetPrerequisites/script.bat3
-rwxr-xr-xTests/RunCMake/GetPrerequisites/script.sh3
-rw-r--r--Tests/RunCMake/GoogleTest/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-result.txt1
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-stdout.txt7
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-result.txt1
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stderr.txt1
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stdout.txt10
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-result.txt1
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stderr.txt1
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stdout.txt10
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-test-missing-result.txt1
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt2
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt25
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt25
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest.cmake59
-rw-r--r--Tests/RunCMake/GoogleTest/RunCMakeTest.cmake74
-rw-r--r--Tests/RunCMake/GoogleTest/fake_gtest.cpp41
-rw-r--r--Tests/RunCMake/GoogleTest/no_tests_defined.cpp4
-rw-r--r--Tests/RunCMake/GoogleTest/timeout_test.cpp39
-rw-r--r--Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt2
-rw-r--r--Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt8
-rw-r--r--Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt6
-rw-r--r--Tests/RunCMake/IfacePaths/BinaryDirectoryInInterface-stderr_INCLUDE_DIRECTORIES.txt2
-rw-r--r--Tests/RunCMake/IfacePaths/InstallInBinDir-stderr_INCLUDE_DIRECTORIES.txt2
-rw-r--r--Tests/RunCMake/IfacePaths/InstallInSrcDir-stderr_INCLUDE_DIRECTORIES.txt2
-rw-r--r--Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt2
-rw-r--r--Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt8
-rw-r--r--Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt6
-rw-r--r--Tests/RunCMake/Languages/ExternalCUDA.cmake8
-rw-r--r--Tests/RunCMake/Languages/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/Languages/empty.c0
-rw-r--r--Tests/RunCMake/LinkStatic/LinkOptionsLib.c7
-rw-r--r--Tests/RunCMake/LinkStatic/RunCMakeTest.cmake27
-rw-r--r--Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-check.cmake4
-rw-r--r--Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-result.txt1
-rw-r--r--Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-check.cmake7
-rw-r--r--Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-result.txt1
-rw-r--r--Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-check.cmake4
-rw-r--r--Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-result.txt1
-rw-r--r--Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS.cmake21
-rw-r--r--Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-result.txt1
-rw-r--r--Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-stderr.txt4
-rw-r--r--Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW.cmake2
-rw-r--r--Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-OLD.cmake2
-rw-r--r--Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-WARN.cmake2
-rw-r--r--Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-common.cmake37
-rw-r--r--Tests/RunCMake/MSVCRuntimeLibrary/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/MSVCRuntimeLibrary/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/MSVCRuntimeLibrary/empty.c0
-rw-r--r--Tests/RunCMake/MSVCWarningFlags/CMP0092-NEW.cmake2
-rw-r--r--Tests/RunCMake/MSVCWarningFlags/CMP0092-OLD.cmake2
-rw-r--r--Tests/RunCMake/MSVCWarningFlags/CMP0092-WARN.cmake2
-rw-r--r--Tests/RunCMake/MSVCWarningFlags/CMP0092-common.cmake12
-rw-r--r--Tests/RunCMake/MSVCWarningFlags/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/MSVCWarningFlags/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/Make/IncludeRegexSubdir-check.cmake4
-rw-r--r--Tests/RunCMake/Make/IncludeRegexSubdir.cmake3
-rw-r--r--Tests/RunCMake/Make/IncludeRegexSubdir/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/Make/RunCMakeTest.cmake18
-rw-r--r--Tests/RunCMake/Make/VerboseBuild-build-stdout.txt1
-rw-r--r--Tests/RunCMake/Make/VerboseBuild-build-watcom-stdout.txt1
-rw-r--r--Tests/RunCMake/Make/VerboseBuild-nowork-gnu-stdout.txt1
-rw-r--r--Tests/RunCMake/Make/VerboseBuild.cmake8
-rw-r--r--Tests/RunCMake/Make/hello.c7
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt.in2
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/CTestCustom.cmake3
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/FindRecursivePackage.cmake3
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/RunCMakeTest.cmake49
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-stderr.txt10
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/add_subdirectory.cmake2
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/add_subdirectory/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-result.txt (renamed from Tests/RunCMake/ctest_memcheck/DummyMemorySanitizer-result.txt)0
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-result.txt (renamed from Tests/RunCMake/ctest_memcheck/DummyPurifyNoLogFile-result.txt)0
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-result.txt (renamed from Tests/RunCMake/ctest_memcheck/DummyThreadSanitizer-result.txt)0
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-stderr.txt34
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-result.txt (renamed from Tests/RunCMake/ctest_memcheck/DummyUndefinedBehaviorSanitizer-result.txt)0
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-stderr.txt51
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/ctest_run_script.cmake.in14
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/find_package-default-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/find_package-default-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/find_package-default-script-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/find_package-default-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/find_package-var-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/find_package-var-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/find_package-var-script-stderr.txt21
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/find_package-var-stderr.txt21
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/find_package.cmake2
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/function-default-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/function-default-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/function-default-script-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/function-default-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/function-invalid-var-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/function-invalid-var-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/function-var-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/function-var-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/function-var-script-stderr.txt21
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/function-var-stderr.txt21
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/function.cmake7
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include-default-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include-default-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include-default-script-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include-default-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include-invalid-var-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include-invalid-var-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include-var-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include-var-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include-var-script-stderr.txt21
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include-var-stderr.txt21
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include.cmake2
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/include_recursive.cmake3
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/macro-default-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/macro-default-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/macro-default-script-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/macro-default-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-stderr.txt5
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/macro-var-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/macro-var-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/macro-var-script-stderr.txt21
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/macro-var-stderr.txt21
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/macro.cmake7
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/test.cmake.in21
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/try_compile-var-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/try_compile-var-stderr.txt48
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/try_compile.cmake6
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists.txt13
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/variable_watch-default-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt6
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt6
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt6
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt6
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/variable_watch-var-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-result.txt1
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt22
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt22
-rw-r--r--Tests/RunCMake/MaxRecursionDepth/variable_watch.cmake9
-rw-r--r--Tests/RunCMake/MetaCompileFeatures/C.cmake27
-rw-r--r--Tests/RunCMake/MetaCompileFeatures/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/MetaCompileFeatures/CXX.cmake27
-rw-r--r--Tests/RunCMake/MetaCompileFeatures/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/MetaCompileFeatures/a.c0
-rw-r--r--Tests/RunCMake/MetaCompileFeatures/a.cxx0
-rw-r--r--Tests/RunCMake/MultiLint/C-Build-stdout.txt8
-rw-r--r--Tests/RunCMake/MultiLint/C-launch-Build-stdout.txt8
-rw-r--r--Tests/RunCMake/MultiLint/C-launch.cmake3
-rw-r--r--Tests/RunCMake/MultiLint/C.cmake6
-rw-r--r--Tests/RunCMake/MultiLint/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/MultiLint/CXX-Build-stdout.txt8
-rw-r--r--Tests/RunCMake/MultiLint/CXX-launch-Build-stdout.txt8
-rw-r--r--Tests/RunCMake/MultiLint/CXX-launch.cmake3
-rw-r--r--Tests/RunCMake/MultiLint/CXX.cmake6
-rw-r--r--Tests/RunCMake/MultiLint/RunCMakeTest.cmake27
-rw-r--r--Tests/RunCMake/MultiLint/main.c4
-rw-r--r--Tests/RunCMake/MultiLint/main.cxx4
-rw-r--r--Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt10
-rw-r--r--Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt10
-rw-r--r--Tests/RunCMake/Ninja/CustomCommandJobPool-check.cmake8
-rw-r--r--Tests/RunCMake/Ninja/CustomCommandJobPool.cmake17
-rw-r--r--Tests/RunCMake/Ninja/JobPoolUsesTerminal-result.txt1
-rw-r--r--Tests/RunCMake/Ninja/JobPoolUsesTerminal-stderr.txt9
-rw-r--r--Tests/RunCMake/Ninja/JobPoolUsesTerminal.cmake2
-rw-r--r--Tests/RunCMake/Ninja/NoWorkToDo-nowork-stdout.txt1
-rw-r--r--Tests/RunCMake/Ninja/NoWorkToDo.cmake2
-rw-r--r--Tests/RunCMake/Ninja/PreventConfigureFileDupBuildRule.cmake5
-rw-r--r--Tests/RunCMake/Ninja/PreventTargetAliasesDupBuildRule.cmake41
-rw-r--r--Tests/RunCMake/Ninja/RspFileC.cmake2
-rw-r--r--Tests/RunCMake/Ninja/RspFileCXX.cmake2
-rw-r--r--Tests/RunCMake/Ninja/RspFileFortran.cmake2
-rw-r--r--Tests/RunCMake/Ninja/RunCMakeTest.cmake49
-rw-r--r--Tests/RunCMake/Ninja/SubDirConfigureFileDup/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/Ninja/VerboseBuild-build-stdout.txt1
-rw-r--r--Tests/RunCMake/Ninja/VerboseBuild-nowork-stdout.txt1
-rw-r--r--Tests/RunCMake/Ninja/VerboseBuild.cmake3
-rw-r--r--Tests/RunCMake/Ninja/greeting.c1
-rw-r--r--Tests/RunCMake/Ninja/greeting2.c1
-rw-r--r--Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt9
-rw-r--r--Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt5
-rw-r--r--Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake2
-rw-r--r--Tests/RunCMake/ObjectLibrary/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/ObjectLibrary/CheckTargetObjects.cmake32
-rw-r--r--Tests/RunCMake/ObjectLibrary/ExportNotSupported-stderr.txt5
-rw-r--r--Tests/RunCMake/ObjectLibrary/ExportNotSupported.cmake2
-rw-r--r--Tests/RunCMake/ObjectLibrary/InstallLinkedObj1-result.txt1
-rw-r--r--Tests/RunCMake/ObjectLibrary/InstallLinkedObj1-stderr.txt1
-rw-r--r--Tests/RunCMake/ObjectLibrary/InstallLinkedObj1.cmake6
-rw-r--r--Tests/RunCMake/ObjectLibrary/InstallLinkedObj2.cmake6
-rw-r--r--Tests/RunCMake/ObjectLibrary/InstallNotSupported-stderr.txt4
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt4
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake2
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.c17
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake15
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjLHSStatic.cmake7
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt6
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake3
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt6
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake3
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-result.txt1
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-stdout.txt1
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjRHSObject.cmake12
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2-build-result.txt1
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2.cmake12
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjRHSShared.cmake13
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjRHSShared2.cmake14
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic.cmake10
-rw-r--r--Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic2.cmake11
-rw-r--r--Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt4
-rw-r--r--Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt10
-rw-r--r--Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake45
-rw-r--r--Tests/RunCMake/ObjectLibrary/TransitiveDependencies.cmake7
-rw-r--r--Tests/RunCMake/ObjectLibrary/a.c8
-rw-r--r--Tests/RunCMake/ObjectLibrary/b.c14
-rw-r--r--Tests/RunCMake/ObjectLibrary/check_object_files.cmake17
-rw-r--r--Tests/RunCMake/ObjectLibrary/exe.c14
-rw-r--r--Tests/RunCMake/ObjectLibrary/exe2.c6
-rw-r--r--Tests/RunCMake/ObjectLibrary/requires.c8
-rw-r--r--Tests/RunCMake/ParseImplicitData/CMakeLists.txt91
-rw-r--r--Tests/RunCMake/ParseImplicitData/README26
-rw-r--r--Tests/RunCMake/ParseImplicitData/aix-C-XL-13.1.3.input40
-rw-r--r--Tests/RunCMake/ParseImplicitData/aix-C-XLClang-16.1.0.1.input40
-rw-r--r--Tests/RunCMake/ParseImplicitData/aix-CXX-XL-13.1.3.input44
-rw-r--r--Tests/RunCMake/ParseImplicitData/aix-CXX-XLClang-16.1.0.1.input44
-rw-r--r--Tests/RunCMake/ParseImplicitData/craype-C-Cray-8.7.input53
-rw-r--r--Tests/RunCMake/ParseImplicitData/craype-C-Cray-9.0-hlist-ad.input54
-rw-r--r--Tests/RunCMake/ParseImplicitData/craype-C-GNU-7.3.0.input79
-rw-r--r--Tests/RunCMake/ParseImplicitData/craype-C-Intel-18.0.2.20180210.input40
-rw-r--r--Tests/RunCMake/ParseImplicitData/craype-CXX-Cray-8.7.input53
-rw-r--r--Tests/RunCMake/ParseImplicitData/craype-CXX-Cray-9.0-hlist-ad.input54
-rw-r--r--Tests/RunCMake/ParseImplicitData/craype-CXX-GNU-7.3.0.input82
-rw-r--r--Tests/RunCMake/ParseImplicitData/craype-CXX-Intel-18.0.2.20180210.input43
-rw-r--r--Tests/RunCMake/ParseImplicitData/craype-Fortran-Cray-8.7.input52
-rw-r--r--Tests/RunCMake/ParseImplicitData/craype-Fortran-Cray-9.0-hlist-ad.input53
-rw-r--r--Tests/RunCMake/ParseImplicitData/craype-Fortran-GNU-7.3.0.input83
-rw-r--r--Tests/RunCMake/ParseImplicitData/craype-Fortran-Intel-18.0.2.20180210.input80
-rw-r--r--Tests/RunCMake/ParseImplicitData/darwin-C-AppleClang-8.0.0.8000042.input50
-rw-r--r--Tests/RunCMake/ParseImplicitData/darwin-CXX-AppleClang-8.0.0.8000042.input52
-rw-r--r--Tests/RunCMake/ParseImplicitData/darwin_nostdinc-C-AppleClang-8.0.0.8000042.input44
-rw-r--r--Tests/RunCMake/ParseImplicitData/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.input44
-rw-r--r--Tests/RunCMake/ParseImplicitData/freebsd-C-Clang-3.3.0.input38
-rw-r--r--Tests/RunCMake/ParseImplicitData/freebsd-CXX-Clang-3.3.0.input45
-rw-r--r--Tests/RunCMake/ParseImplicitData/freebsd-Fortran-GNU-4.6.4.input78
-rw-r--r--Tests/RunCMake/ParseImplicitData/hand-C-empty.input14
-rw-r--r--Tests/RunCMake/ParseImplicitData/hand-C-relative.input23
-rw-r--r--Tests/RunCMake/ParseImplicitData/hand-CXX-empty.input14
-rw-r--r--Tests/RunCMake/ParseImplicitData/hand-CXX-relative.input23
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-C-GNU-7.3.0.input72
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-C-Intel-18.0.0.20170811.input43
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-C-PGI-18.10.1.input36
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-C-XL-12.1.0.input42
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-C-XL-16.1.0.0.input40
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-CUDA-NVIDIA-10.1.168-CLANG.input242
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-CUDA-NVIDIA-10.1.168-XLClang-v.input51
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-CUDA-NVIDIA-9.2.148-GCC.input125
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-CXX-GNU-7.3.0.input76
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-CXX-Intel-18.0.0.20170811.input46
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-CXX-PGI-18.10.1.input40
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-CXX-XL-12.1.0.input42
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-CXX-XL-16.1.0.0.input40
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-Fortran-GNU-7.3.0.input76
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-Fortran-PGI-18.10.1.input47
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux-Fortran-XL-14.1.0.input50
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux_nostdinc-C-PGI-18.10.1.input36
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux_nostdinc-C-XL-12.1.0.input42
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux_nostdinc-CXX-PGI-18.10.1.input40
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux_nostdinc-CXX-XL-12.1.0.input42
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux_nostdinc-Fortran-PGI-18.10.1.input47
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux_nostdinc_i-C-XL-12.1.0.input42
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux_nostdinc_i-CXX-XL-12.1.0.input42
-rw-r--r--Tests/RunCMake/ParseImplicitData/linux_pgf77-Fortran-PGI-18.10.1.input35
-rw-r--r--Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input70
-rw-r--r--Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input76
-rw-r--r--Tests/RunCMake/ParseImplicitData/netbsd-C-GNU-4.8.5.input60
-rw-r--r--Tests/RunCMake/ParseImplicitData/netbsd-CXX-GNU-4.8.5.input62
-rw-r--r--Tests/RunCMake/ParseImplicitData/netbsd_nostdinc-C-GNU-4.8.5.input58
-rw-r--r--Tests/RunCMake/ParseImplicitData/netbsd_nostdinc-CXX-GNU-4.8.5.input58
-rw-r--r--Tests/RunCMake/ParseImplicitData/openbsd-C-Clang-5.0.1.input37
-rw-r--r--Tests/RunCMake/ParseImplicitData/openbsd-CXX-Clang-5.0.1.input38
-rw-r--r--Tests/RunCMake/ParseImplicitData/sunos-C-SunPro-5.13.0.input35
-rw-r--r--Tests/RunCMake/ParseImplicitData/sunos-CXX-SunPro-5.13.0.input38
-rw-r--r--Tests/RunCMake/ParseImplicitData/sunos-Fortran-SunPro-8.8.0.input40
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake127
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-C-XL-13.1.3.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-C-XLClang-16.1.0.1.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-CXX-XL-13.1.3.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-CXX-XLClang-16.1.0.1.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-Cray-8.7.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-Cray-9.0-hlist-ad.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-GNU-7.3.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-Intel-18.0.2.20180210.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-Cray-8.7.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-Cray-9.0-hlist-ad.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-GNU-7.3.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-Intel-18.0.2.20180210.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-Cray-8.7.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-Cray-9.0-hlist-ad.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-GNU-7.3.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-Intel-18.0.2.20180210.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin-C-AppleClang-8.0.0.8000042.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin-CXX-AppleClang-8.0.0.8000042.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin_nostdinc-C-AppleClang-8.0.0.8000042.output0
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output0
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/freebsd-C-Clang-3.3.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/freebsd-CXX-Clang-3.3.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/freebsd-Fortran-GNU-4.6.4.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-C-empty.output0
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-C-relative.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-CXX-empty.output0
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-CXX-relative.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-GNU-7.3.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-Intel-18.0.0.20170811.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-PGI-18.10.1.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-XL-12.1.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-XL-16.1.0.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CUDA-NVIDIA-10.1.168-CLANG.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CUDA-NVIDIA-10.1.168-XLClang-v-empty.output0
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CUDA-NVIDIA-9.2.148-GCC.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-GNU-7.3.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-Intel-18.0.0.20170811.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-PGI-18.10.1.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-XL-12.1.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-XL-16.1.0.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-GNU-7.3.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-PGI-18.10.1.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-XL-14.1.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-C-PGI-18.10.1.output0
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-C-XL-12.1.0.output0
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-CXX-PGI-18.10.1.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-CXX-XL-12.1.0.output0
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-Fortran-PGI-18.10.1.output0
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc_i-C-XL-12.1.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc_i-CXX-XL-12.1.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_pgf77-Fortran-PGI-18.10.1.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/mingw.org-C-GNU-4.9.3.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/mingw.org-CXX-GNU-4.9.3.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd-C-GNU-4.8.5.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd-CXX-GNU-4.8.5.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd_nostdinc-C-GNU-4.8.5.output0
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd_nostdinc-CXX-GNU-4.8.5.output0
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/openbsd-C-Clang-5.0.1.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/openbsd-CXX-Clang-5.0.1.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/sunos-C-SunPro-5.13.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/sunos-CXX-SunPro-5.13.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitIncludeInfo/results/sunos-Fortran-SunPro-8.8.0.output1
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake146
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/aix-C-XL-13.1.3.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/aix-C-XLClang-16.1.0.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/aix-CXX-XL-13.1.3.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/aix-CXX-XLClang-16.1.0.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-8.7.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-9.0-hlist-ad.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-GNU-7.3.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Intel-18.0.2.20180210.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-8.7.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-9.0-hlist-ad.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-GNU-7.3.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Intel-18.0.2.20180210.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-8.7.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-9.0-hlist-ad.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-GNU-7.3.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Intel-18.0.2.20180210.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/darwin-C-AppleClang-8.0.0.8000042.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/darwin-CXX-AppleClang-8.0.0.8000042.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/darwin_nostdinc-C-AppleClang-8.0.0.8000042.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-C-Clang-3.3.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-CXX-Clang-3.3.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-Fortran-GNU-4.6.4.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/hand-C-empty.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/hand-C-relative.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/hand-CXX-empty.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/hand-CXX-relative.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-GNU-7.3.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-Intel-18.0.0.20170811.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-PGI-18.10.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-XL-12.1.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-XL-16.1.0.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-CLANG.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-XLClang-v.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-9.2.148-GCC.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-GNU-7.3.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-Intel-18.0.0.20170811.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-PGI-18.10.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-12.1.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-16.1.0.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-GNU-7.3.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-PGI-18.10.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-XL-14.1.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-C-PGI-18.10.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-C-XL-12.1.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-PGI-18.10.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-XL-12.1.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-Fortran-PGI-18.10.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc_i-C-XL-12.1.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/linux_pgf77-Fortran-PGI-18.10.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/mingw.org-C-GNU-4.9.3.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/mingw.org-CXX-GNU-4.9.3.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd-C-GNU-4.8.5.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd-CXX-GNU-4.8.5.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd_nostdinc-C-GNU-4.8.5.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd_nostdinc-CXX-GNU-4.8.5.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/openbsd-C-Clang-5.0.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/openbsd-CXX-Clang-5.0.1.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/sunos-C-SunPro-5.13.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/sunos-CXX-SunPro-5.13.0.output2
-rw-r--r--Tests/RunCMake/ParseImplicitLinkInfo/results/sunos-Fortran-SunPro-8.8.0.output2
-rw-r--r--Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_new-check.cmake22
-rw-r--r--Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_old-check.cmake20
-rw-r--r--Tests/RunCMake/PositionIndependentCode/CMP0083.cmake47
-rw-r--r--Tests/RunCMake/PositionIndependentCode/CheckPIESupported.cmake18
-rw-r--r--Tests/RunCMake/PositionIndependentCode/Genex1-result.txt1
-rw-r--r--Tests/RunCMake/PositionIndependentCode/Genex1-stderr.txt3
-rw-r--r--Tests/RunCMake/PositionIndependentCode/Genex1.cmake9
-rw-r--r--Tests/RunCMake/PositionIndependentCode/Genex2-result.txt1
-rw-r--r--Tests/RunCMake/PositionIndependentCode/Genex2-stderr.txt3
-rw-r--r--Tests/RunCMake/PositionIndependentCode/Genex2.cmake9
-rw-r--r--Tests/RunCMake/PositionIndependentCode/PIE-pie_off-check.cmake7
-rw-r--r--Tests/RunCMake/PositionIndependentCode/PIE-pie_on-check.cmake7
-rw-r--r--Tests/RunCMake/PositionIndependentCode/PIE.cmake22
-rw-r--r--Tests/RunCMake/PositionIndependentCode/PIE_validator.cmake32
-rw-r--r--Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake64
-rw-r--r--Tests/RunCMake/PrecompileHeaders/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake12
-rw-r--r--Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake14
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake26
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchInterface.cmake21
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake26
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchMultilanguage.cmake12
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake8
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue.cmake11
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake27
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed-build-stderr.txt2
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed.cmake29
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt2
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake18
-rw-r--r--Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake22
-rw-r--r--Tests/RunCMake/PrecompileHeaders/SkipPrecompileHeaders.cmake13
-rw-r--r--Tests/RunCMake/PrecompileHeaders/empty.c3
-rw-r--r--Tests/RunCMake/PrecompileHeaders/foo.c13
-rw-r--r--Tests/RunCMake/PrecompileHeaders/foobar.c14
-rw-r--r--Tests/RunCMake/PrecompileHeaders/include/bar.h9
-rw-r--r--Tests/RunCMake/PrecompileHeaders/include/foo.h6
-rw-r--r--Tests/RunCMake/PrecompileHeaders/include/foo2.h6
-rw-r--r--Tests/RunCMake/PrecompileHeaders/main.cpp4
-rw-r--r--Tests/RunCMake/PrecompileHeaders/non-pch.cpp3
-rw-r--r--Tests/RunCMake/PrecompileHeaders/pch.h3
-rw-r--r--Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/README.rst21
-rw-r--r--Tests/RunCMake/RunCMake.cmake70
-rw-r--r--Tests/RunCMake/RunCTest.cmake8
-rw-r--r--Tests/RunCMake/RuntimePath/Genex.cmake29
-rw-r--r--Tests/RunCMake/RuntimePath/GenexCheck.cmake7
-rw-r--r--Tests/RunCMake/RuntimePath/Relative.cmake69
-rw-r--r--Tests/RunCMake/RuntimePath/RelativeCheck.cmake4
-rw-r--r--Tests/RunCMake/RuntimePath/RunCMakeTest.cmake24
-rw-r--r--Tests/RunCMake/RuntimePath/main.c4
-rw-r--r--Tests/RunCMake/ScriptMode/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/ScriptMode/set_directory_properties.cmake1
-rw-r--r--Tests/RunCMake/SourceProperties/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/SourceProperties/RelativeIncludeDir-result.txt1
-rw-r--r--Tests/RunCMake/SourceProperties/RelativeIncludeDir-stderr.txt4
-rw-r--r--Tests/RunCMake/SourceProperties/RelativeIncludeDir.cmake4
-rw-r--r--Tests/RunCMake/SourceProperties/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/SourceProperties/empty.c5
-rw-r--r--Tests/RunCMake/Swift/E.swift2
-rw-r--r--Tests/RunCMake/Swift/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/Swift/Win32ExecutableDisallowed-result.txt1
-rw-r--r--Tests/RunCMake/Swift/Win32ExecutableDisallowed-stderr.txt4
-rw-r--r--Tests/RunCMake/Swift/Win32ExecutableDisallowed.cmake4
-rw-r--r--Tests/RunCMake/Syntax/.gitattributes4
-rw-r--r--Tests/RunCMake/Syntax/BracketCRLF.cmake16
-rw-r--r--Tests/RunCMake/Syntax/CMP0053-At-OLD-stderr.txt13
-rw-r--r--Tests/RunCMake/Syntax/CMP0053-Dollar-NEW-stderr.txt2
-rw-r--r--Tests/RunCMake/Syntax/CMP0053-Dollar-NEW.cmake6
-rw-r--r--Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-result.txt1
-rw-r--r--Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-stderr.txt24
-rw-r--r--Tests/RunCMake/Syntax/CMP0053-Dollar-OLD.cmake6
-rw-r--r--Tests/RunCMake/Syntax/NullAfterBackslash-result.txt1
-rw-r--r--Tests/RunCMake/Syntax/NullAfterBackslash-stderr.txt5
-rw-r--r--Tests/RunCMake/Syntax/NullAfterBackslash.cmakebin0 -> 113 bytes
-rw-r--r--Tests/RunCMake/Syntax/NullTerminatedArgument-result.txt1
-rw-r--r--Tests/RunCMake/Syntax/NullTerminatedArgument-stderr.txt5
-rw-r--r--Tests/RunCMake/Syntax/NullTerminatedArgument.cmakebin0 -> 106 bytes
-rw-r--r--Tests/RunCMake/Syntax/QueryCache-stderr.txt2
-rw-r--r--Tests/RunCMake/Syntax/QueryCache.cmake6
-rw-r--r--Tests/RunCMake/Syntax/RunCMakeTest.cmake7
-rw-r--r--Tests/RunCMake/Syntax/StringCRLF.cmake12
-rw-r--r--Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt2
-rw-r--r--Tests/RunCMake/Syntax/UnterminatedCall1.cmake3
-rw-r--r--Tests/RunCMake/Syntax/UnterminatedCall2-stderr.txt2
-rw-r--r--Tests/RunCMake/Syntax/UnterminatedCall2.cmake3
-rw-r--r--Tests/RunCMake/TargetObjects/NoTarget.cmake4
-rw-r--r--Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt9
-rw-r--r--Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake4
-rw-r--r--Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt6
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName-result.txt1
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName-stderr.txt52
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName.cmake8
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1-stderr.txt8
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1.cmake7
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2-stderr.txt8
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2.cmake7
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3-stderr.txt8
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3.cmake7
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4-stderr.txt8
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4.cmake9
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5-stderr.txt9
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5.cmake7
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6-stderr.txt8
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6.cmake7
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7-stderr.txt8
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7.cmake9
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8-stderr.txt8
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8.cmake7
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt4
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference-result.txt1
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference-stderr.txt39
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference.cmake6
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1-stderr.txt6
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1.cmake7
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2-stderr.txt6
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2.cmake9
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3-stderr.txt6
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3.cmake8
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4-stderr.txt6
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4.cmake10
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5-stderr.txt6
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5.cmake10
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6-stderr.txt6
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6.cmake10
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle1-stderr.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle2-stderr.txt2
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake16
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/main.cpp4
-rw-r--r--Tests/RunCMake/TargetSources/CMP0076-OLD-result.txt1
-rw-r--r--Tests/RunCMake/TargetSources/CMP0076-OLD-stderr.txt (renamed from Tests/RunCMake/TargetSources/RelativePathInInterface-stderr.txt)0
-rw-r--r--Tests/RunCMake/TargetSources/CMP0076-OLD.cmake10
-rw-r--r--Tests/RunCMake/TargetSources/CMP0076-WARN-result.txt1
-rw-r--r--Tests/RunCMake/TargetSources/CMP0076-WARN-stderr.txt21
-rw-r--r--Tests/RunCMake/TargetSources/CMP0076-WARN.cmake8
-rw-r--r--Tests/RunCMake/TargetSources/CMP0076-WARN/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/TargetSources/CMP0076-WARN/subdir_empty_1.cpp7
-rw-r--r--Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt2
-rw-r--r--Tests/RunCMake/TargetSources/OriginDebug-stderr.txt8
-rw-r--r--Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt1
-rw-r--r--Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt40
-rw-r--r--Tests/RunCMake/TargetSources/OriginDebugIDE.cmake4
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInInterface-stdout.txt1
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInInterface.cmake4
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx-stdout.txt1
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx.cmake10
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/subdir_empty_1.cpp7
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirInclude-stdout.txt1
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirInclude.cmake8
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/subdir_empty_1.cpp7
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirInterface-stdout.txt1
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirInterface.cmake11
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_1.cpp7
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_2.cpp7
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate-stdout.txt1
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate.cmake8
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_1.cpp7
-rw-r--r--Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_2.cpp7
-rw-r--r--Tests/RunCMake/TargetSources/RunCMakeTest.cmake10
-rw-r--r--Tests/RunCMake/ToolchainFile/IncludeDirectories-toolchain.cmake1
-rw-r--r--Tests/RunCMake/ToolchainFile/IncludeDirectories.c5
-rw-r--r--Tests/RunCMake/ToolchainFile/IncludeDirectories.cmake2
-rw-r--r--Tests/RunCMake/ToolchainFile/IncludeDirectories/IncDir.h1
-rw-r--r--Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/UnityBuild/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/UnityBuild/RunCMakeTest.cmake24
-rw-r--r--Tests/RunCMake/UnityBuild/func.c6
-rw-r--r--Tests/RunCMake/UnityBuild/func.h6
-rw-r--r--Tests/RunCMake/UnityBuild/main.c6
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_batchsize-check.cmake11
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_batchsize.cmake16
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_c-check.cmake5
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_c.cmake12
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx-check.cmake11
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx.cmake17
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build-check.cmake5
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build.cmake10
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include-check.cmake7
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include.cmake13
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_cxx-check.cmake5
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_cxx.cmake12
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_default_batchsize-check.cmake7
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_default_batchsize.cmake15
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_object_library.cmake13
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake7
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_order.cmake12
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_runtest.cmake9
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake14
-rw-r--r--Tests/RunCMake/UnityBuild/unitybuild_skip.cmake30
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0078-NEW-stdout.txt2
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0078-NEW.cmake2
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0078-OLD-stdout.txt2
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0078-OLD.cmake2
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0078-WARN-stderr.txt10
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0078-WARN-stdout.txt2
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0078-WARN.cmake1
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0078-common.cmake12
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0086-NEW-nuild-check.cmake4
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0086-NEW.cmake2
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0086-OLD-build-check.cmake4
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0086-OLD.cmake2
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0086-WARN-stderr.txt11
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0086-WARN.cmake1
-rw-r--r--Tests/RunCMake/UseSWIG/CMP0086-common.cmake11
-rw-r--r--Tests/RunCMake/UseSWIG/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/UseSWIG/RunCMakeTest.cmake25
-rw-r--r--Tests/RunCMake/UseSWIG/example.i2
-rw-r--r--Tests/RunCMake/VS10Project/Dir/DirNested/foo_nested.cpp3
-rw-r--r--Tests/RunCMake/VS10Project/Dir/foo.cpp3
-rw-r--r--Tests/RunCMake/VS10Project/ExplicitCMakeLists-check.cmake25
-rw-r--r--Tests/RunCMake/VS10Project/ExplicitCMakeLists.cmake3
-rw-r--r--Tests/RunCMake/VS10Project/Prefixed/PrefixedNested/bar_nested.cpp3
-rw-r--r--Tests/RunCMake/VS10Project/Prefixed/bar.cpp3
-rw-r--r--Tests/RunCMake/VS10Project/RunCMakeTest.cmake40
-rw-r--r--Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake36
-rw-r--r--Tests/RunCMake/VS10Project/RuntimeLibrary.cmake20
-rw-r--r--Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake11
-rw-r--r--Tests/RunCMake/VS10Project/SourceGroupCMakeLists.cmake3
-rw-r--r--Tests/RunCMake/VS10Project/SourceGroupHelpers.cmake35
-rw-r--r--Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists-check.cmake26
-rw-r--r--Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists.cmake45
-rw-r--r--Tests/RunCMake/VS10Project/UnityBuildNative-check.cmake45
-rw-r--r--Tests/RunCMake/VS10Project/UnityBuildNative.cmake12
-rw-r--r--Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake48
-rw-r--r--Tests/RunCMake/VS10Project/UnityBuildPre2017.cmake12
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake64
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpCompilerOpts.cmake14
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake31
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpCustomTags-stderr.txt3
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake25
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake64
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpDefines.cmake18
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpDeployFiles-check.cmake67
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpDeployFiles.cmake27
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpReferenceProps-check.cmake49
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpReferenceProps-stderr.txt8
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpReferenceProps.cmake19
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpWithoutSources-check.cmake5
-rw-r--r--Tests/RunCMake/VS10Project/VsCSharpWithoutSources.cmake7
-rw-r--r--Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake2
-rw-r--r--Tests/RunCMake/VS10Project/VsConfigurationType.cmake2
-rw-r--r--Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake24
-rw-r--r--Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake6
-rw-r--r--Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake24
-rw-r--r--Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake6
-rw-r--r--Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake24
-rw-r--r--Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake6
-rw-r--r--Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake36
-rw-r--r--Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake5
-rw-r--r--Tests/RunCMake/VS10Project/VsDpiAware-check.cmake41
-rw-r--r--Tests/RunCMake/VS10Project/VsDpiAware.cmake19
-rw-r--r--Tests/RunCMake/VS10Project/VsDpiAwareBadParam-result.txt1
-rw-r--r--Tests/RunCMake/VS10Project/VsDpiAwareBadParam-stderr.txt3
-rw-r--r--Tests/RunCMake/VS10Project/VsDpiAwareBadParam.cmake8
-rw-r--r--Tests/RunCMake/VS10Project/VsGlobals-check.cmake44
-rw-r--r--Tests/RunCMake/VS10Project/VsGlobals.cmake8
-rw-r--r--Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake38
-rw-r--r--Tests/RunCMake/VS10Project/VsJustMyCode.cmake24
-rw-r--r--Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake39
-rw-r--r--Tests/RunCMake/VS10Project/VsPackageReferences.cmake4
-rw-r--r--Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake66
-rw-r--r--Tests/RunCMake/VS10Project/VsPrecompileHeaders.cmake4
-rw-r--r--Tests/RunCMake/VS10Project/VsPrecompileHeadersReuseFromCompilePDBName-result.txt1
-rw-r--r--Tests/RunCMake/VS10Project/VsPrecompileHeadersReuseFromCompilePDBName-stderr.txt7
-rw-r--r--Tests/RunCMake/VS10Project/VsPrecompileHeadersReuseFromCompilePDBName.cmake9
-rw-r--r--Tests/RunCMake/VS10Project/VsProjectImport-check.cmake28
-rw-r--r--Tests/RunCMake/VS10Project/VsProjectImport.cmake11
-rw-r--r--Tests/RunCMake/VS10Project/VsSdkDirectories-check.cmake88
-rw-r--r--Tests/RunCMake/VS10Project/VsSdkDirectories.cmake11
-rw-r--r--Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake30
-rw-r--r--Tests/RunCMake/VS10Project/VsSpectreMitigation.cmake8
-rw-r--r--Tests/RunCMake/VS10Project/empty.c0
-rw-r--r--Tests/RunCMake/VS10Project/empty.cxx0
-rw-r--r--Tests/RunCMake/VS10ProjectWinCE/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/VS10ProjectWinCE/RunCMakeTest.cmake9
-rw-r--r--Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy-check.cmake118
-rw-r--r--Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy.cmake14
-rw-r--r--Tests/RunCMake/VS10ProjectWinCE/VsCSharpCFProject-check.cmake54
-rw-r--r--Tests/RunCMake/VS10ProjectWinCE/VsCSharpCFProject.cmake8
-rw-r--r--Tests/RunCMake/VS10ProjectWinCE/foo.cpp3
-rw-r--r--Tests/RunCMake/VS10ProjectWinCE/foo.cs3
-rw-r--r--Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt2
-rw-r--r--Tests/RunCMake/WorkingDirectory/CMakeLists.txt.in3
-rw-r--r--Tests/RunCMake/WorkingDirectory/RunCMakeTest.cmake9
-rw-r--r--Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-check.cmake3
-rw-r--r--Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-result.txt1
-rw-r--r--Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-stdout.txt1
-rw-r--r--Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir.cmake7
-rw-r--r--Tests/RunCMake/WorkingDirectory/dirNotExist-result.txt (renamed from Tests/RunCMake/ctest_memcheck/DummyValgrindCustomOptions-result.txt)0
-rw-r--r--Tests/RunCMake/WorkingDirectory/dirNotExist-stderr.txt1
-rw-r--r--Tests/RunCMake/WorkingDirectory/dirNotExist-stdout.txt10
-rw-r--r--Tests/RunCMake/WorkingDirectory/dirNotExist.cmake6
-rw-r--r--Tests/RunCMake/WorkingDirectory/test.cmake.in15
-rw-r--r--Tests/RunCMake/WriteBasicConfigVersionFile/All.cmake884
-rw-r--r--Tests/RunCMake/WriteBasicConfigVersionFile/ArchIndependent.cmake63
-rw-r--r--Tests/RunCMake/WriteBasicConfigVersionFile/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/WriteBasicConfigVersionFile/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt1
-rw-r--r--Tests/RunCMake/XcodeProject/DeploymentTarget.c26
-rw-r--r--Tests/RunCMake/XcodeProject/DeploymentTarget.cmake25
-rw-r--r--Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake20
-rw-r--r--Tests/RunCMake/XcodeProject/ExplicitCMakeLists.cmake2
-rw-r--r--Tests/RunCMake/XcodeProject/ImplicitCMakeLists-check.cmake20
-rw-r--r--Tests/RunCMake/XcodeProject/ImplicitCMakeLists.cmake0
-rw-r--r--Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-result.txt1
-rw-r--r--Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt10
-rw-r--r--Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions.cmake3
-rw-r--r--Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt4
-rw-r--r--Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-result.txt1
-rw-r--r--Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-stderr.txt10
-rw-r--r--Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs.cmake3
-rw-r--r--Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-result.txt1
-rw-r--r--Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-stderr.txt10
-rw-r--r--Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions.cmake3
-rw-r--r--Tests/RunCMake/XcodeProject/RunCMakeTest.cmake129
-rw-r--r--Tests/RunCMake/XcodeProject/XCTestLookup.cmake3
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeBundles.cmake21
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck-build-stdout.txt1
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck.cmake4
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeGenerateTopLevelProjectOnly-check.cmake3
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeGenerateTopLevelProjectOnly.cmake3
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake10
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake6
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake6
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake3
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeObjcFlags.cmake12
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeObjcxxFlags.cmake12
-rw-r--r--Tests/RunCMake/XcodeProject/XcodePrecompileHeaders-check.cmake35
-rw-r--r--Tests/RunCMake/XcodeProject/XcodePrecompileHeaders.cmake4
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake52
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake42
-rw-r--r--Tests/RunCMake/XcodeProject/myfuncs.m3
-rw-r--r--Tests/RunCMake/XcodeProject/myfuncs.mm3
-rw-r--r--Tests/RunCMake/XcodeProject/subproject/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/XcodeProject/zerocheck/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/add_custom_command/AppendLiteralQuotes-result.txt1
-rw-r--r--Tests/RunCMake/add_custom_command/AppendLiteralQuotes-stderr.txt7
-rw-r--r--Tests/RunCMake/add_custom_command/AppendLiteralQuotes.cmake2
-rw-r--r--Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt2
-rw-r--r--Tests/RunCMake/add_custom_command/AssigningMultipleTargets.cmake13
-rw-r--r--Tests/RunCMake/add_custom_command/BadByproduct-result.txt1
-rw-r--r--Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt36
-rw-r--r--Tests/RunCMake/add_custom_command/BadByproduct.cmake6
-rw-r--r--Tests/RunCMake/add_custom_command/BadOutput-result.txt1
-rw-r--r--Tests/RunCMake/add_custom_command/BadOutput-stderr.txt36
-rw-r--r--Tests/RunCMake/add_custom_command/BadOutput.cmake6
-rw-r--r--Tests/RunCMake/add_custom_command/GeneratedProperty.cmake10
-rw-r--r--Tests/RunCMake/add_custom_command/LiteralQuotes-result.txt1
-rw-r--r--Tests/RunCMake/add_custom_command/LiteralQuotes-stderr.txt7
-rw-r--r--Tests/RunCMake/add_custom_command/LiteralQuotes.cmake1
-rw-r--r--Tests/RunCMake/add_custom_command/RemoveEmptyCommands-check.cmake63
-rw-r--r--Tests/RunCMake/add_custom_command/RemoveEmptyCommands.cmake22
-rw-r--r--Tests/RunCMake/add_custom_command/RunCMakeTest.cmake17
-rw-r--r--Tests/RunCMake/add_custom_command/TargetLiteralQuotes-result.txt1
-rw-r--r--Tests/RunCMake/add_custom_command/TargetLiteralQuotes-stderr.txt7
-rw-r--r--Tests/RunCMake/add_custom_command/TargetLiteralQuotes.cmake2
-rw-r--r--Tests/RunCMake/add_custom_command/a.c3
-rw-r--r--Tests/RunCMake/add_custom_command/generate-once.cmake8
-rw-r--r--Tests/RunCMake/add_custom_target/BadByproduct-result.txt1
-rw-r--r--Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt36
-rw-r--r--Tests/RunCMake/add_custom_target/BadByproduct.cmake6
-rw-r--r--Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake1
-rw-r--r--Tests/RunCMake/add_custom_target/GeneratedProperty.cmake14
-rw-r--r--Tests/RunCMake/add_custom_target/LiteralQuotes-result.txt1
-rw-r--r--Tests/RunCMake/add_custom_target/LiteralQuotes-stderr.txt7
-rw-r--r--Tests/RunCMake/add_custom_target/LiteralQuotes.cmake1
-rw-r--r--Tests/RunCMake/add_custom_target/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/add_executable/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/add_executable/NoSources-result.txt1
-rw-r--r--Tests/RunCMake/add_executable/NoSources-stderr.txt6
-rw-r--r--Tests/RunCMake/add_executable/NoSources.cmake1
-rw-r--r--Tests/RunCMake/add_executable/NoSourcesButLinkObjects-result.txt1
-rw-r--r--Tests/RunCMake/add_executable/NoSourcesButLinkObjects-stderr.txt6
-rw-r--r--Tests/RunCMake/add_executable/NoSourcesButLinkObjects.cmake5
-rw-r--r--Tests/RunCMake/add_executable/OnlyObjectSources.cmake5
-rw-r--r--Tests/RunCMake/add_executable/RunCMakeTest.cmake7
-rw-r--r--Tests/RunCMake/add_executable/test.cpp0
-rw-r--r--Tests/RunCMake/add_library/CMP0073-stdout.txt3
-rw-r--r--Tests/RunCMake/add_library/CMP0073.cmake18
-rw-r--r--Tests/RunCMake/add_library/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/add_library/INTERFACEwithNoSources.cmake1
-rw-r--r--Tests/RunCMake/add_library/INTERFACEwithNoSourcesButLinkObjects.cmake5
-rw-r--r--Tests/RunCMake/add_library/INTERFACEwithOnlyObjectSources.cmake5
-rw-r--r--Tests/RunCMake/add_library/MODULEwithNoSources-result.txt1
-rw-r--r--Tests/RunCMake/add_library/MODULEwithNoSources-stderr.txt6
-rw-r--r--Tests/RunCMake/add_library/MODULEwithNoSources.cmake1
-rw-r--r--Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-result.txt1
-rw-r--r--Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-stderr.txt6
-rw-r--r--Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects.cmake5
-rw-r--r--Tests/RunCMake/add_library/MODULEwithOnlyObjectSources.cmake5
-rw-r--r--Tests/RunCMake/add_library/OBJECTwithNoSources-result.txt1
-rw-r--r--Tests/RunCMake/add_library/OBJECTwithNoSources-stderr.txt6
-rw-r--r--Tests/RunCMake/add_library/OBJECTwithNoSources.cmake1
-rw-r--r--Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-result.txt1
-rw-r--r--Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt6
-rw-r--r--Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects.cmake5
-rw-r--r--Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources.cmake5
-rw-r--r--Tests/RunCMake/add_library/RunCMakeTest.cmake26
-rw-r--r--Tests/RunCMake/add_library/SHAREDwithNoSources-result.txt1
-rw-r--r--Tests/RunCMake/add_library/SHAREDwithNoSources-stderr.txt6
-rw-r--r--Tests/RunCMake/add_library/SHAREDwithNoSources.cmake1
-rw-r--r--Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-result.txt1
-rw-r--r--Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-stderr.txt6
-rw-r--r--Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects.cmake5
-rw-r--r--Tests/RunCMake/add_library/SHAREDwithOnlyObjectSources.cmake5
-rw-r--r--Tests/RunCMake/add_library/STATICwithNoSources-result.txt1
-rw-r--r--Tests/RunCMake/add_library/STATICwithNoSources-stderr.txt6
-rw-r--r--Tests/RunCMake/add_library/STATICwithNoSources.cmake1
-rw-r--r--Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-result.txt1
-rw-r--r--Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-stderr.txt6
-rw-r--r--Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects.cmake5
-rw-r--r--Tests/RunCMake/add_library/STATICwithOnlyObjectSources.cmake5
-rw-r--r--Tests/RunCMake/add_library/UNKNOWNwithNoSources.cmake1
-rw-r--r--Tests/RunCMake/add_library/UNKNOWNwithNoSourcesButLinkObjects.cmake5
-rw-r--r--Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-result.txt1
-rw-r--r--Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-stderr.txt4
-rw-r--r--Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources.cmake5
-rw-r--r--Tests/RunCMake/add_library/empty.c0
-rw-r--r--Tests/RunCMake/add_library/test.cpp0
-rw-r--r--Tests/RunCMake/add_link_options/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/add_link_options/LINKER_SHELL_expansion-build-check.cmake2
-rw-r--r--Tests/RunCMake/add_link_options/LINKER_SHELL_expansion.cmake4
-rw-r--r--Tests/RunCMake/add_link_options/LINKER_expansion-build-check.cmake2
-rw-r--r--Tests/RunCMake/add_link_options/LINKER_expansion-list.cmake36
-rw-r--r--Tests/RunCMake/add_link_options/LINKER_expansion-validation.cmake15
-rw-r--r--Tests/RunCMake/add_link_options/LINKER_expansion.cmake4
-rw-r--r--Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-check.cmake7
-rw-r--r--Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-result.txt1
-rw-r--r--Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-check.cmake7
-rw-r--r--Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-result.txt1
-rw-r--r--Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-check.cmake7
-rw-r--r--Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-result.txt1
-rw-r--r--Tests/RunCMake/add_link_options/LINK_OPTIONS.cmake17
-rw-r--r--Tests/RunCMake/add_link_options/LinkOptionsExe.c4
-rw-r--r--Tests/RunCMake/add_link_options/LinkOptionsLib.c7
-rw-r--r--Tests/RunCMake/add_link_options/RunCMakeTest.cmake38
-rw-r--r--Tests/RunCMake/add_link_options/bad_SHELL_usage-result.txt1
-rw-r--r--Tests/RunCMake/add_link_options/bad_SHELL_usage-stderr.txt4
-rw-r--r--Tests/RunCMake/add_link_options/bad_SHELL_usage.cmake6
-rw-r--r--Tests/RunCMake/add_link_options/dump.c13
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-ExcludeFromAll/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-NEW-install-component-stdout.txt4
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-NEW-install-stdout.txt3
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-NEW.cmake3
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-Nested/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-Nested/sub/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-NestedSub/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-NestedSub/sub/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-None/CMakeLists.txt0
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-OLD-install-component-stdout.txt4
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-OLD-install-stdout.txt3
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-OLD.cmake3
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested-install-component-stdout.txt4
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested-install-stdout.txt3
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested-stderr.txt7
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested.cmake2
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub-install-component-stdout.txt4
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub-install-stdout.txt3
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub-stderr.txt7
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub.cmake1
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-NoTopInstall-install-component-stdout.txt3
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-NoTopInstall-install-stdout.txt2
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-NoTopInstall.cmake1
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-None-install-component-stdout.txt3
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-None-install-stdout.txt2
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-None.cmake2
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-install-component-stdout.txt4
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-install-stdout.txt3
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN-stderr.txt7
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082-WARN.cmake3
-rw-r--r--Tests/RunCMake/add_subdirectory/CMP0082/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/add_subdirectory/CMakeLists.txt7
-rw-r--r--Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt2
-rw-r--r--Tests/RunCMake/add_subdirectory/ExcludeFromAll-build-sub-stderr.txt1
-rw-r--r--Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake10
-rw-r--r--Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt11
-rw-r--r--Tests/RunCMake/add_subdirectory/ExcludeFromAll/SubSub/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/add_subdirectory/ExcludeFromAll/SubSub/subsub.cpp4
-rw-r--r--Tests/RunCMake/add_subdirectory/ExcludeFromAll/check-sub.cmake34
-rw-r--r--Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake37
-rw-r--r--Tests/RunCMake/add_subdirectory/ExcludeFromAll/subinc.cpp4
-rw-r--r--Tests/RunCMake/add_subdirectory/ExcludeFromAll/zot.cpp4
-rw-r--r--Tests/RunCMake/add_subdirectory/Missing-stderr.txt2
-rw-r--r--Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake57
-rw-r--r--Tests/RunCMake/alias_targets/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/alias_targets/imported-global-target-stderr.txt2
-rw-r--r--Tests/RunCMake/alias_targets/imported-global-target.cmake46
-rw-r--r--Tests/RunCMake/alias_targets/imported-target-stderr.txt18
-rw-r--r--Tests/RunCMake/alias_targets/imported-target.cmake44
-rw-r--r--Tests/RunCMake/build_command/CMP0061-OLD-make-stderr.txt13
-rw-r--r--Tests/RunCMake/build_command/CMP0061-OLD-other-stderr.txt13
-rw-r--r--Tests/RunCMake/cmake_minimum_required/Future.cmake1
-rw-r--r--Tests/RunCMake/cmake_minimum_required/Range-stderr.txt4
-rw-r--r--Tests/RunCMake/cmake_minimum_required/Range.cmake6
-rw-r--r--Tests/RunCMake/cmake_minimum_required/RangeBad-result.txt1
-rw-r--r--Tests/RunCMake/cmake_minimum_required/RangeBad-stderr.txt56
-rw-r--r--Tests/RunCMake/cmake_minimum_required/RangeBad.cmake10
-rw-r--r--Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/cmake_minimum_required/Unknown-result.txt1
-rw-r--r--Tests/RunCMake/cmake_minimum_required/Unknown-stderr.txt4
-rw-r--r--Tests/RunCMake/cmake_minimum_required/Unknown.cmake1
-rw-r--r--Tests/RunCMake/cmake_parse_arguments/KeyWordsMissingValues.cmake133
-rw-r--r--Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/color_warning.c7
-rw-r--r--Tests/RunCMake/configure_file/DirInput-stderr.txt2
-rw-r--r--Tests/RunCMake/ctest_build/BuildQuiet-stdout.txt1
-rw-r--r--Tests/RunCMake/ctest_build/CTestConfig.cmake.in1
-rw-r--r--Tests/RunCMake/ctest_build/IgnoreColor-stdout.txt2
-rw-r--r--Tests/RunCMake/ctest_build/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/ctest_build/test.cmake.in5
-rw-r--r--Tests/RunCMake/ctest_cmake_error/CTestConfig.cmake.in1
-rw-r--r--Tests/RunCMake/ctest_configure/CTestConfig.cmake.in1
-rw-r--r--Tests/RunCMake/ctest_configure/ConfigureQuiet-stdout.txt1
-rw-r--r--Tests/RunCMake/ctest_coverage/CTestConfig.cmake.in1
-rw-r--r--Tests/RunCMake/ctest_disabled_test/CTestConfig.cmake.in1
-rw-r--r--Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in6
-rw-r--r--Tests/RunCMake/ctest_fixtures/CTestConfig.cmake.in1
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/CMakeLists.txt.in5
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/CTestConfig.cmake.in1
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-check.cmake36
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-stdout.txt10
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-check.cmake36
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-stdout.txt10
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-check.cmake34
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-result.txt (renamed from Tests/RunCMake/ctest_memcheck/DummyValgrindNoLogFile-result.txt)0
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stdout.txt9
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-result.txt1
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stdout.txt6
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-result.txt1
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stdout.txt9
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-result.txt1
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stdout.txt6
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-result.txt1
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stdout.txt6
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/CMakeLists.txt33
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/experimental.c16
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/CMakeLists.txt12
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/production.c16
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/CMakeLists.txt7
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/CMakeLists.txt10
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/thirdparty.c14
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/RunCMakeTest.cmake185
-rw-r--r--Tests/RunCMake/ctest_labels_for_subprojects/test.cmake.in21
-rw-r--r--Tests/RunCMake/ctest_memcheck/CTestConfig.cmake.in3
-rw-r--r--Tests/RunCMake/ctest_skipped_test/CTestConfig.cmake.in1
-rwxr-xr-xTests/RunCMake/ctest_skipped_test/skip.bat2
-rw-r--r--Tests/RunCMake/ctest_start/AppendDifferentGroup-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_start/AppendDifferentGroup-stdout.txt8
-rw-r--r--Tests/RunCMake/ctest_start/AppendDifferentModel-check.cmake1
-rw-r--r--Tests/RunCMake/ctest_start/AppendDifferentModel-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_start/AppendDifferentModel-stdout.txt7
-rw-r--r--Tests/RunCMake/ctest_start/AppendDifferentTrack-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_start/AppendDifferentTrack-stdout.txt8
-rw-r--r--Tests/RunCMake/ctest_start/AppendNoMatchingTrack-stdout.txt7
-rw-r--r--Tests/RunCMake/ctest_start/AppendNoModel-check.cmake1
-rw-r--r--Tests/RunCMake/ctest_start/AppendNoModel-stdout.txt7
-rw-r--r--Tests/RunCMake/ctest_start/AppendOldContinuous-stdout.txt7
-rw-r--r--Tests/RunCMake/ctest_start/AppendOldNoModel-result.txt (renamed from Tests/RunCMake/ctest_submit/FailDrop-cp-result.txt)0
-rw-r--r--Tests/RunCMake/ctest_start/AppendOldNoModel-stderr.txt3
-rw-r--r--Tests/RunCMake/ctest_start/AppendOldNoModel-stdout.txt5
-rw-r--r--Tests/RunCMake/ctest_start/AppendSameModel-check.cmake1
-rw-r--r--Tests/RunCMake/ctest_start/AppendSameModel-stdout.txt7
-rw-r--r--Tests/RunCMake/ctest_start/CTestConfig.cmake.in1
-rw-r--r--Tests/RunCMake/ctest_start/ConfigInBuild-stdout.txt1
-rw-r--r--Tests/RunCMake/ctest_start/ConfigInSource-stdout.txt1
-rw-r--r--Tests/RunCMake/ctest_start/FunctionScope-stdout.txt (renamed from Tests/RunCMake/CTestCommandLine/test-load-pass-stderr.txt)0
-rw-r--r--Tests/RunCMake/ctest_start/MissingGroupArg-result.txt (renamed from Tests/RunCMake/ctest_submit/FailDrop-ftp-result.txt)0
-rw-r--r--Tests/RunCMake/ctest_start/MissingGroupArg-stderr.txt2
-rw-r--r--Tests/RunCMake/ctest_start/MissingGroupArgAppend-result.txt (renamed from Tests/RunCMake/ctest_submit/FailDrop-scp-result.txt)0
-rw-r--r--Tests/RunCMake/ctest_start/MissingGroupArgAppend-stderr.txt2
-rw-r--r--Tests/RunCMake/ctest_start/MissingGroupArgQuiet-result.txt (renamed from Tests/RunCMake/ctest_submit/FailDrop-xmlrpc-result.txt)0
-rw-r--r--Tests/RunCMake/ctest_start/MissingGroupArgQuiet-stderr.txt2
-rw-r--r--Tests/RunCMake/ctest_start/MissingTrackArg-result.txt (renamed from Tests/RunCMake/ctest_test/CTestTestLoadFail-result.txt)0
-rw-r--r--Tests/RunCMake/ctest_start/MissingTrackArg-stderr.txt2
-rw-r--r--Tests/RunCMake/ctest_start/MissingTrackArgAppend-result.txt (renamed from Tests/RunCMake/ctest_test/TestLoadFail-result.txt)0
-rw-r--r--Tests/RunCMake/ctest_start/MissingTrackArgAppend-stderr.txt2
-rw-r--r--Tests/RunCMake/ctest_start/MissingTrackArgQuiet-result.txt1
-rw-r--r--Tests/RunCMake/ctest_start/MissingTrackArgQuiet-stderr.txt2
-rw-r--r--Tests/RunCMake/ctest_start/NoAppendDifferentGroup-stdout.txt7
-rw-r--r--Tests/RunCMake/ctest_start/NoAppendDifferentTrack-stdout.txt7
-rw-r--r--Tests/RunCMake/ctest_start/NoModel-result.txt1
-rw-r--r--Tests/RunCMake/ctest_start/NoModel-stderr.txt3
-rw-r--r--Tests/RunCMake/ctest_start/RunCMakeTest.cmake42
-rw-r--r--Tests/RunCMake/ctest_start/TooManyArgs-result.txt1
-rw-r--r--Tests/RunCMake/ctest_start/TooManyArgs-stderr.txt2
-rw-r--r--Tests/RunCMake/ctest_start/WriteModelToTagContinuous-check.cmake1
-rw-r--r--Tests/RunCMake/ctest_start/WriteModelToTagExperimental-check.cmake1
-rw-r--r--Tests/RunCMake/ctest_start/WriteModelToTagNightly-check.cmake1
-rw-r--r--Tests/RunCMake/ctest_start/WriteModelToTagNoMatchingGroup-check.cmake1
-rw-r--r--Tests/RunCMake/ctest_start/WriteModelToTagNoMatchingTrack-check.cmake1
-rw-r--r--Tests/RunCMake/ctest_start/test.cmake.in22
-rw-r--r--Tests/RunCMake/ctest_submit/CDashSubmitHeaders-stderr.txt2
-rw-r--r--Tests/RunCMake/ctest_submit/CDashSubmitVerbose-result.txt1
-rw-r--r--Tests/RunCMake/ctest_submit/CDashSubmitVerbose-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_submit/CDashSubmitVerbose-stdout.txt1
-rw-r--r--Tests/RunCMake/ctest_submit/CTestConfig.cmake.in1
-rw-r--r--Tests/RunCMake/ctest_submit/FILESNoBuildId-result.txt1
-rw-r--r--Tests/RunCMake/ctest_submit/FILESNoBuildId-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_submit/FILESNoBuildId-stdout.txt1
-rw-r--r--Tests/RunCMake/ctest_submit/FailDrop-cp-stderr.txt3
-rw-r--r--Tests/RunCMake/ctest_submit/FailDrop-cp-stdout.txt1
-rw-r--r--Tests/RunCMake/ctest_submit/FailDrop-ftp-stderr.txt2
-rw-r--r--Tests/RunCMake/ctest_submit/FailDrop-ftp-stdout.txt3
-rw-r--r--Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt5
-rw-r--r--Tests/RunCMake/ctest_submit/FailDrop-https-stdout.txt5
-rw-r--r--Tests/RunCMake/ctest_submit/FailDrop-scp-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_submit/FailDrop-scp-stdout.txt1
-rw-r--r--Tests/RunCMake/ctest_submit/FailDrop-xmlrpc-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_submit/FailDrop-xmlrpc-stdout.txt1
-rw-r--r--Tests/RunCMake/ctest_submit/PARTSDone-result.txt1
-rw-r--r--Tests/RunCMake/ctest_submit/PARTSDone-stderr.txt3
-rw-r--r--Tests/RunCMake/ctest_submit/RunCMakeTest.cmake20
-rw-r--r--Tests/RunCMake/ctest_submit/test.cmake.in1
-rw-r--r--Tests/RunCMake/ctest_test/CTestConfig.cmake.in1
-rw-r--r--Tests/RunCMake/ctest_test/CTestTestLoadFail-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_test/CTestTestLoadFail-stdout.txt2
-rw-r--r--Tests/RunCMake/ctest_test/CTestTestLoadWait-stdout.txt8
-rw-r--r--Tests/RunCMake/ctest_test/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/ctest_test/TestLoadFail-stderr.txt1
-rw-r--r--Tests/RunCMake/ctest_test/TestLoadFail-stdout.txt2
-rw-r--r--Tests/RunCMake/ctest_test/TestLoadWait-stdout.txt8
-rw-r--r--Tests/RunCMake/ctest_update/CMakeLists.txt.in4
-rw-r--r--Tests/RunCMake/ctest_update/RunCMakeTest.cmake25
-rw-r--r--Tests/RunCMake/ctest_update/UpdateActualVersion-check.cmake12
-rw-r--r--Tests/RunCMake/ctest_update/UpdateChangeId-check.cmake12
-rw-r--r--Tests/RunCMake/ctest_update/test.cmake.in18
-rw-r--r--Tests/RunCMake/ctest_upload/CTestConfig.cmake.in1
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand-result.txt1
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand-stderr.txt5
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand-stdout.txt12
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand.cmake41
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand2-result.txt1
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand2-stderr.txt5
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand2-stdout.txt12
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand3-result.txt1
-rw-r--r--Tests/RunCMake/execute_process/EchoCommand3-stderr.txt2
-rw-r--r--Tests/RunCMake/execute_process/EncodingUTF-8-stderr.txt1
-rw-r--r--Tests/RunCMake/execute_process/ExitValues-stdout.txt14
-rw-r--r--Tests/RunCMake/execute_process/ExitValues.cmake120
-rw-r--r--Tests/RunCMake/execute_process/RunCMakeTest.cmake13
-rw-r--r--Tests/RunCMake/exit_code.c30
-rw-r--r--Tests/RunCMake/export/AppendExport-stderr.txt2
-rw-r--r--Tests/RunCMake/export/DependOnDoubleExport-result.txt1
-rw-r--r--Tests/RunCMake/export/DependOnDoubleExport-stderr.txt13
-rw-r--r--Tests/RunCMake/export/DependOnDoubleExport.cmake7
-rw-r--r--Tests/RunCMake/export/DependOnNotExport-result.txt1
-rw-r--r--Tests/RunCMake/export/DependOnNotExport-stderr.txt6
-rw-r--r--Tests/RunCMake/export/DependOnNotExport.cmake4
-rw-r--r--Tests/RunCMake/export/Empty.cmake1
-rw-r--r--Tests/RunCMake/export/ExportPropertiesUndefined.cmake11
-rw-r--r--Tests/RunCMake/export/ForbiddenToExportImportedProperties-result.txt1
-rw-r--r--Tests/RunCMake/export/ForbiddenToExportImportedProperties-stderr.txt3
-rw-r--r--Tests/RunCMake/export/ForbiddenToExportImportedProperties.cmake12
-rw-r--r--Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-result.txt1
-rw-r--r--Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-stderr.txt3
-rw-r--r--Tests/RunCMake/export/ForbiddenToExportInterfaceProperties.cmake12
-rw-r--r--Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-result.txt1
-rw-r--r--Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-stderr.txt3
-rw-r--r--Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp.cmake12
-rw-r--r--Tests/RunCMake/export/OldIface-stderr.txt3
-rw-r--r--Tests/RunCMake/export/RunCMakeTest.cmake7
-rw-r--r--Tests/RunCMake/export/empty.cpp7
-rw-r--r--Tests/RunCMake/file/CREATE_LINK-COPY_ON_ERROR.cmake11
-rw-r--r--Tests/RunCMake/file/CREATE_LINK-SYMBOLIC-noexist.cmake4
-rw-r--r--Tests/RunCMake/file/CREATE_LINK-SYMBOLIC.cmake4
-rw-r--r--Tests/RunCMake/file/CREATE_LINK-noarg-result.txt1
-rw-r--r--Tests/RunCMake/file/CREATE_LINK-noarg-stderr.txt4
-rw-r--r--Tests/RunCMake/file/CREATE_LINK-noarg.cmake1
-rw-r--r--Tests/RunCMake/file/CREATE_LINK-noexist-stderr.txt1
-rw-r--r--Tests/RunCMake/file/CREATE_LINK-noexist.cmake4
-rw-r--r--Tests/RunCMake/file/CREATE_LINK.cmake11
-rw-r--r--Tests/RunCMake/file/DOWNLOAD-netrc-bad-result.txt1
-rw-r--r--Tests/RunCMake/file/DOWNLOAD-netrc-bad-stderr.txt19
-rw-r--r--Tests/RunCMake/file/DOWNLOAD-netrc-bad.cmake15
-rw-r--r--Tests/RunCMake/file/DOWNLOAD-netrc-bad.txt0
-rw-r--r--Tests/RunCMake/file/FileOpenFailRead-stderr.txt2
-rw-r--r--Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-build-stdout.txt1
-rw-r--r--Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_first-stdout.txt2
-rw-r--r--Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_second-stdout.txt2
-rw-r--r--Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-stdout.txt1
-rw-r--r--Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake.cmake10
-rw-r--r--Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-result.txt1
-rw-r--r--Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-stderr.txt1
-rw-r--r--Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE.cmake1
-rw-r--r--Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-result.txt1
-rw-r--r--Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-stderr.txt7
-rw-r--r--Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified.cmake21
-rw-r--r--Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-result.txt1
-rw-r--r--Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-stderr.txt4
-rw-r--r--Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg.cmake1
-rw-r--r--Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-result.txt1
-rw-r--r--Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-stderr.txt4
-rw-r--r--Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS.cmake1
-rw-r--r--Tests/RunCMake/file/GLOB-noexp-FOLLOW_SYMLINKS.cmake1
-rw-r--r--Tests/RunCMake/file/GLOB-noexp-RELATIVE-result.txt1
-rw-r--r--Tests/RunCMake/file/GLOB-noexp-RELATIVE-stderr.txt4
-rw-r--r--Tests/RunCMake/file/GLOB-noexp-RELATIVE.cmake1
-rw-r--r--Tests/RunCMake/file/GLOB-sort-dedup-stderr.txt2
-rw-r--r--Tests/RunCMake/file/GLOB-sort-dedup.cmake21
-rw-r--r--Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late-stderr.txt6
-rw-r--r--Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late.cmake11
-rw-r--r--Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-result.txt1
-rw-r--r--Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-stderr.txt4
-rw-r--r--Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS.cmake1
-rw-r--r--Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version-stderr.txt13
-rw-r--r--Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version.cmake6
-rw-r--r--Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN.cmake168
-rw-r--r--Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt12
-rw-r--r--Tests/RunCMake/file/READ_SYMLINK-noexist-result.txt1
-rw-r--r--Tests/RunCMake/file/READ_SYMLINK-noexist-stderr.txt6
-rw-r--r--Tests/RunCMake/file/READ_SYMLINK-noexist.cmake1
-rw-r--r--Tests/RunCMake/file/READ_SYMLINK-notsymlink-result.txt1
-rw-r--r--Tests/RunCMake/file/READ_SYMLINK-notsymlink-stderr.txt6
-rw-r--r--Tests/RunCMake/file/READ_SYMLINK-notsymlink.cmake2
-rw-r--r--Tests/RunCMake/file/READ_SYMLINK.cmake13
-rw-r--r--Tests/RunCMake/file/REMOVE-empty-stderr.txt11
-rw-r--r--Tests/RunCMake/file/REMOVE-empty.cmake2
-rw-r--r--Tests/RunCMake/file/RunCMakeTest.cmake97
-rw-r--r--Tests/RunCMake/file/SIZE-error-does-not-exist-result.txt1
-rw-r--r--Tests/RunCMake/file/SIZE-error-does-not-exist-stderr.txt6
-rw-r--r--Tests/RunCMake/file/SIZE-error-does-not-exist.cmake3
-rw-r--r--Tests/RunCMake/file/SIZE.cmake9
-rw-r--r--Tests/RunCMake/file/TOUCH-error-in-source-directory-result.txt1
-rw-r--r--Tests/RunCMake/file/TOUCH-error-in-source-directory-stderr.txt1
-rw-r--r--Tests/RunCMake/file/TOUCH-error-in-source-directory.cmake2
-rw-r--r--Tests/RunCMake/file/TOUCH-error-missing-directory-result.txt1
-rw-r--r--Tests/RunCMake/file/TOUCH-error-missing-directory-stderr.txt1
-rw-r--r--Tests/RunCMake/file/TOUCH-error-missing-directory.cmake1
-rw-r--r--Tests/RunCMake/file/TOUCH-result.txt1
-rw-r--r--Tests/RunCMake/file/TOUCH-stderr.txt9
-rw-r--r--Tests/RunCMake/file/TOUCH.cmake16
-rw-r--r--Tests/RunCMake/file/UPLOAD-netrc-bad-result.txt1
-rw-r--r--Tests/RunCMake/file/UPLOAD-netrc-bad-stderr.txt19
-rw-r--r--Tests/RunCMake/file/UPLOAD-netrc-bad.cmake15
-rw-r--r--Tests/RunCMake/file/UPLOAD-netrc-bad.txt0
-rw-r--r--Tests/RunCMake/find_file/FromPATHEnv-stdout-cygwin.txt9
-rw-r--r--Tests/RunCMake/find_file/FromPATHEnv-stdout-windows.txt9
-rw-r--r--Tests/RunCMake/find_file/FromPATHEnv-stdout.txt9
-rw-r--r--Tests/RunCMake/find_file/FromPATHEnv.cmake24
-rw-r--r--Tests/RunCMake/find_file/FromPrefixPath-stdout.txt6
-rw-r--r--Tests/RunCMake/find_file/FromPrefixPath.cmake19
-rw-r--r--Tests/RunCMake/find_file/PrefixInPATH-stdout-cygwin.txt4
-rw-r--r--Tests/RunCMake/find_file/PrefixInPATH-stdout-windows.txt4
-rw-r--r--Tests/RunCMake/find_file/PrefixInPATH-stdout.txt6
-rw-r--r--Tests/RunCMake/find_file/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/find_library/FromPATHEnv-stdout-cygwin.txt6
-rw-r--r--Tests/RunCMake/find_library/FromPATHEnv-stdout-windows.txt6
-rw-r--r--Tests/RunCMake/find_library/FromPATHEnv-stdout.txt6
-rw-r--r--Tests/RunCMake/find_library/FromPATHEnv.cmake22
-rw-r--r--Tests/RunCMake/find_library/FromPrefixPath-stdout.txt6
-rw-r--r--Tests/RunCMake/find_library/FromPrefixPath.cmake24
-rw-r--r--Tests/RunCMake/find_library/PrefixInPATH-stdout-cygwin.txt4
-rw-r--r--Tests/RunCMake/find_library/PrefixInPATH-stdout-windows.txt4
-rw-r--r--Tests/RunCMake/find_library/PrefixInPATH-stdout.txt6
-rw-r--r--Tests/RunCMake/find_library/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/find_package/CMP0074-OLD-stderr.txt12
-rw-r--r--Tests/RunCMake/find_package/CMP0074-OLD.cmake2
-rw-r--r--Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt32
-rw-r--r--Tests/RunCMake/find_package/CMP0074-WARN.cmake2
-rw-r--r--Tests/RunCMake/find_package/CMP0074-common.cmake46
-rw-r--r--Tests/RunCMake/find_package/CMP0084-NEW-stderr.txt20
-rw-r--r--Tests/RunCMake/find_package/CMP0084-NEW.cmake7
-rw-r--r--Tests/RunCMake/find_package/CMP0084-OLD.cmake7
-rw-r--r--Tests/RunCMake/find_package/CMP0084-WARN-stderr.txt8
-rw-r--r--Tests/RunCMake/find_package/CMP0084-WARN.cmake6
-rw-r--r--Tests/RunCMake/find_package/FromPATHEnv-stdout.txt9
-rw-r--r--Tests/RunCMake/find_package/FromPATHEnv.cmake27
-rw-r--r--Tests/RunCMake/find_package/FromPrefixPath-stdout.txt9
-rw-r--r--Tests/RunCMake/find_package/FromPrefixPath.cmake29
-rw-r--r--Tests/RunCMake/find_package/PackageRoot.cmake2
-rw-r--r--Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake1
-rw-r--r--Tests/RunCMake/find_package/PackageRootNestedConfig.cmake2
-rw-r--r--Tests/RunCMake/find_package/PackageRootNestedModule.cmake2
-rw-r--r--Tests/RunCMake/find_package/RunCMakeTest.cmake10
-rw-r--r--Tests/RunCMake/find_package/SetFoundResolved-stderr.txt10
-rw-r--r--Tests/RunCMake/find_package/SetFoundResolved.cmake17
-rw-r--r--Tests/RunCMake/find_path/EmptyOldStyle-stdout.txt1
-rw-r--r--Tests/RunCMake/find_path/EmptyOldStyle.cmake2
-rw-r--r--Tests/RunCMake/find_path/FromPATHEnv-stdout-cygwin.txt9
-rw-r--r--Tests/RunCMake/find_path/FromPATHEnv-stdout-windows.txt9
-rw-r--r--Tests/RunCMake/find_path/FromPATHEnv-stdout.txt9
-rw-r--r--Tests/RunCMake/find_path/FromPATHEnv.cmake25
-rw-r--r--Tests/RunCMake/find_path/PrefixInPATH-stdout-cygwin.txt4
-rw-r--r--Tests/RunCMake/find_path/PrefixInPATH-stdout-windows.txt4
-rw-r--r--Tests/RunCMake/find_path/PrefixInPATH-stdout.txt6
-rw-r--r--Tests/RunCMake/find_path/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/find_program/EnvAndHints-stdout.txt3
-rw-r--r--Tests/RunCMake/find_program/EnvAndHints.cmake23
-rw-r--r--Tests/RunCMake/find_program/RelAndAbsPath-stdout.txt8
-rw-r--r--Tests/RunCMake/find_program/RelAndAbsPath.cmake84
-rw-r--r--Tests/RunCMake/find_program/RunCMakeTest.cmake1
-rwxr-xr-xTests/RunCMake/find_program/testCWD1
-rw-r--r--Tests/RunCMake/foreach/BadRangeInFunction-result.txt1
-rw-r--r--Tests/RunCMake/foreach/BadRangeInFunction-stderr.txt5
-rw-r--r--Tests/RunCMake/foreach/BadRangeInFunction.cmake5
-rw-r--r--Tests/RunCMake/foreach/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/foreach/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/get_filename_component/KnownComponents.cmake15
-rw-r--r--Tests/RunCMake/get_property/BadArgument-stderr.txt2
-rw-r--r--Tests/RunCMake/get_property/BadDirectory-stderr.txt2
-rw-r--r--Tests/RunCMake/get_property/BadScope-stderr.txt2
-rw-r--r--Tests/RunCMake/get_property/BadTarget-stderr.txt2
-rw-r--r--Tests/RunCMake/get_property/BadTest-stderr.txt2
-rw-r--r--Tests/RunCMake/get_property/GlobalName-stderr.txt2
-rw-r--r--Tests/RunCMake/get_property/MissingArgument-stderr.txt2
-rw-r--r--Tests/RunCMake/get_property/NoCache-stderr.txt2
-rw-r--r--Tests/RunCMake/get_property/NoProperty-stderr.txt2
-rw-r--r--Tests/RunCMake/get_property/NoSource-stderr.txt2
-rw-r--r--Tests/RunCMake/get_property/NoTarget-stderr.txt2
-rw-r--r--Tests/RunCMake/get_property/NoTest-stderr.txt2
-rw-r--r--Tests/RunCMake/get_property/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/get_property/VariableName-stderr.txt2
-rw-r--r--Tests/RunCMake/get_property/directory_properties-stderr.txt10
-rw-r--r--Tests/RunCMake/get_property/directory_properties.cmake9
-rw-r--r--Tests/RunCMake/get_property/directory_properties/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/get_property/source_properties-stderr.txt8
-rw-r--r--Tests/RunCMake/get_property/source_properties.cmake10
-rw-r--r--Tests/RunCMake/get_property/target_properties-stderr.txt8
-rw-r--r--Tests/RunCMake/get_property/target_properties.cmake7
-rw-r--r--Tests/RunCMake/include_external_msproject/check_utils.cmake2
-rw-r--r--Tests/RunCMake/include_guard/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/include_guard/DirectoryScope.cmake19
-rw-r--r--Tests/RunCMake/include_guard/GlobalScope.cmake11
-rw-r--r--Tests/RunCMake/include_guard/InvalidArgumentsNumber-result.txt1
-rw-r--r--Tests/RunCMake/include_guard/InvalidArgumentsNumber-stderr.txt5
-rw-r--r--Tests/RunCMake/include_guard/InvalidArgumentsNumber.cmake1
-rw-r--r--Tests/RunCMake/include_guard/InvalidScope-result.txt1
-rw-r--r--Tests/RunCMake/include_guard/InvalidScope-stderr.txt4
-rw-r--r--Tests/RunCMake/include_guard/InvalidScope.cmake1
-rw-r--r--Tests/RunCMake/include_guard/RunCMakeTest.cmake7
-rw-r--r--Tests/RunCMake/include_guard/Scripts/DirScript.cmake12
-rw-r--r--Tests/RunCMake/include_guard/Scripts/GlobScript.cmake12
-rw-r--r--Tests/RunCMake/include_guard/Scripts/VarScript.cmake12
-rw-r--r--Tests/RunCMake/include_guard/VariableScope.cmake24
-rw-r--r--Tests/RunCMake/include_guard/global_script_dir/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/include_guard/sub_dir_script1/CMakeLists.txt9
-rw-r--r--Tests/RunCMake/include_guard/sub_dir_script1/sub_dir_script3/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/include_guard/sub_dir_script2/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/install/CMP0062-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/install/CMP0087-NEW-check.cmake7
-rw-r--r--Tests/RunCMake/install/CMP0087-NEW.cmake3
-rw-r--r--Tests/RunCMake/install/CMP0087-NEW/CMakeLists.txt7
-rw-r--r--Tests/RunCMake/install/CMP0087-OLD-check.cmake8
-rw-r--r--Tests/RunCMake/install/CMP0087-OLD.cmake3
-rw-r--r--Tests/RunCMake/install/CMP0087-OLD/CMakeLists.txt6
-rw-r--r--Tests/RunCMake/install/CMP0087-WARN-stderr.txt5
-rw-r--r--Tests/RunCMake/install/CMP0087-WARN.cmake2
-rw-r--r--Tests/RunCMake/install/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/install/DIRECTORY-DESTINATION-TYPE-result.txt1
-rw-r--r--Tests/RunCMake/install/DIRECTORY-DESTINATION-TYPE-stderr.txt5
-rw-r--r--Tests/RunCMake/install/DIRECTORY-DESTINATION-TYPE.cmake1
-rw-r--r--Tests/RunCMake/install/DIRECTORY-OPTIONAL-all-check.cmake1
-rw-r--r--Tests/RunCMake/install/DIRECTORY-OPTIONAL.cmake1
-rw-r--r--Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt2
-rw-r--r--Tests/RunCMake/install/DIRECTORY-PATTERN-all-check.cmake1
-rw-r--r--Tests/RunCMake/install/DIRECTORY-PATTERN.cmake36
-rw-r--r--Tests/RunCMake/install/DIRECTORY-TYPE-Cache-all-check.cmake42
-rw-r--r--Tests/RunCMake/install/DIRECTORY-TYPE-Cache.cmake13
-rw-r--r--Tests/RunCMake/install/DIRECTORY-TYPE-CacheDependent-all-check.cmake24
-rw-r--r--Tests/RunCMake/install/DIRECTORY-TYPE-CacheDependent.cmake7
-rw-r--r--Tests/RunCMake/install/DIRECTORY-TYPE-all-check.cmake42
-rw-r--r--Tests/RunCMake/install/DIRECTORY-TYPE.cmake13
-rw-r--r--Tests/RunCMake/install/Deprecated-all-check.cmake1
-rw-r--r--Tests/RunCMake/install/Deprecated.cmake13
-rw-r--r--Tests/RunCMake/install/FILES-DESTINATION-TYPE-result.txt1
-rw-r--r--Tests/RunCMake/install/FILES-DESTINATION-TYPE-stderr.txt5
-rw-r--r--Tests/RunCMake/install/FILES-DESTINATION-TYPE.cmake1
-rw-r--r--Tests/RunCMake/install/FILES-OPTIONAL-all-check.cmake1
-rw-r--r--Tests/RunCMake/install/FILES-OPTIONAL.cmake1
-rw-r--r--Tests/RunCMake/install/FILES-PERMISSIONS-all-check.cmake1
-rw-r--r--Tests/RunCMake/install/FILES-PERMISSIONS.cmake5
-rw-r--r--Tests/RunCMake/install/FILES-TYPE-Cache-all-check.cmake29
-rw-r--r--Tests/RunCMake/install/FILES-TYPE-Cache.cmake13
-rw-r--r--Tests/RunCMake/install/FILES-TYPE-CacheDependent-all-check.cmake17
-rw-r--r--Tests/RunCMake/install/FILES-TYPE-CacheDependent.cmake7
-rw-r--r--Tests/RunCMake/install/FILES-TYPE-all-check.cmake29
-rw-r--r--Tests/RunCMake/install/FILES-TYPE.cmake13
-rw-r--r--Tests/RunCMake/install/InstallRequiredSystemLibraries-stderr.txt1
-rw-r--r--Tests/RunCMake/install/InstallRequiredSystemLibraries.cmake10
-rw-r--r--Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT-all-check.cmake1
-rw-r--r--Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT.cmake7
-rw-r--r--Tests/RunCMake/install/RunCMakeTest.cmake123
-rw-r--r--Tests/RunCMake/install/SCRIPT-COMPONENT-all-check.cmake1
-rw-r--r--Tests/RunCMake/install/SCRIPT-COMPONENT-dev-check.cmake1
-rw-r--r--Tests/RunCMake/install/SCRIPT-COMPONENT-uns-check.cmake1
-rw-r--r--Tests/RunCMake/install/SCRIPT-COMPONENT.cmake5
-rw-r--r--Tests/RunCMake/install/SCRIPT-all-check.cmake1
-rw-r--r--Tests/RunCMake/install/SCRIPT.cmake4
-rw-r--r--Tests/RunCMake/install/TARGETS-Apple-Defaults-result.txt1
-rw-r--r--Tests/RunCMake/install/TARGETS-Apple-Defaults-stderr.txt12
-rw-r--r--Tests/RunCMake/install/TARGETS-Apple-Defaults.cmake8
-rw-r--r--Tests/RunCMake/install/TARGETS-CONFIGURATIONS-all-check.cmake1
-rw-r--r--Tests/RunCMake/install/TARGETS-CONFIGURATIONS.cmake2
-rw-r--r--Tests/RunCMake/install/TARGETS-Defaults-Cache-all-check.cmake49
-rw-r--r--Tests/RunCMake/install/TARGETS-Defaults-Cache.cmake19
-rw-r--r--Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake55
-rw-r--r--Tests/RunCMake/install/TARGETS-Defaults.cmake27
-rw-r--r--Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-check-common.cmake30
-rw-r--r--Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-check.cmake63
-rw-r--r--Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt23
-rw-r--r--Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath.cmake72
-rw-r--r--Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-old_rpath-check.cmake15
-rw-r--r--Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-old_rpath.cmake18
-rw-r--r--Tests/RunCMake/install/TARGETS-ImportedGlobal-result.txt1
-rw-r--r--Tests/RunCMake/install/TARGETS-ImportedGlobal-stderr.txt4
-rw-r--r--Tests/RunCMake/install/TARGETS-ImportedGlobal.cmake3
-rw-r--r--Tests/RunCMake/install/TARGETS-InstallFromSubDir-all-check.cmake1
-rw-r--r--Tests/RunCMake/install/TARGETS-InstallFromSubDir.cmake4
-rw-r--r--Tests/RunCMake/install/TARGETS-InstallFromSubDir/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-all-check.cmake73
-rw-r--r--Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-all-result.txt1
-rw-r--r--Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-all-stderr.txt5
-rw-r--r--Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-all.cmake9
-rw-r--r--Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-exc-result.txt1
-rw-r--r--Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-exc-stderr.txt5
-rw-r--r--Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-exc.cmake10
-rw-r--r--Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-dev-check.cmake11
-rw-r--r--Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-lib-check.cmake50
-rw-r--r--Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-uns-check.cmake38
-rw-r--r--Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT.cmake68
-rw-r--r--Tests/RunCMake/install/TARGETS-OPTIONAL-all-check.cmake1
-rw-r--r--Tests/RunCMake/install/TARGETS-OPTIONAL.cmake4
-rw-r--r--Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake13
-rw-r--r--Tests/RunCMake/install/TARGETS-OUTPUT_NAME.cmake27
-rw-r--r--Tests/RunCMake/install/TARGETS-Parts-all-check.cmake1
-rw-r--r--Tests/RunCMake/install/TARGETS-Parts.cmake7
-rw-r--r--Tests/RunCMake/install/TARGETS-RPATH-all-check.cmake14
-rw-r--r--Tests/RunCMake/install/TARGETS-RPATH.cmake14
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs1-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs1-stderr.txt18
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs1.cmake2
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs2-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs2-stderr.txt23
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs2.cmake15
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-all-check.cmake44
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-all-stderr.txt119
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-stderr.txt7
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict.cmake54
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-stderr.txt5
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-notfile.cmake30
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-stderr.txt2
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved.cmake18
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux.cmake169
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux/topexe.c9
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux/toplib.c8
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-all-check.cmake157
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-stderr.txt7
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict.cmake55
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-stderr.txt5
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-notfile.cmake30
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-stderr.txt2
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved.cmake18
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos.cmake216
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos/topexe.c7
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos/toplib.c6
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-project-stderr.txt13
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-project.cmake1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-unsupported-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-unsupported-stderr.txt5
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-unsupported.cmake2
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-all-check.cmake38
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-stderr.txt7
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict.cmake47
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-stderr.txt5
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-notfile.cmake28
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-result.txt1
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-stderr.txt2
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved.cmake18
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows.cmake114
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows/topexe.c7
-rw-r--r--Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows/toplib.c6
-rw-r--r--Tests/RunCMake/install/install_script.cmake5
-rw-r--r--Tests/RunCMake/install/obj1.c5
-rw-r--r--Tests/RunCMake/install/obj1.h6
-rw-r--r--Tests/RunCMake/install/obj2.h6
-rw-r--r--Tests/RunCMake/install/obj3.c7
-rw-r--r--Tests/RunCMake/install/obj3.h6
-rw-r--r--Tests/RunCMake/install/obj4.c7
-rw-r--r--Tests/RunCMake/install/obj4.h6
-rw-r--r--Tests/RunCMake/install/obj5.c7
-rw-r--r--Tests/RunCMake/install/obj5.h6
-rw-r--r--Tests/RunCMake/install/pattern/empty.c0
-rw-r--r--Tests/RunCMake/install/pattern/empty.h0
-rw-r--r--Tests/RunCMake/install/pattern/empty.txt0
-rw-r--r--Tests/RunCMake/install/postinstall.cmake1
-rw-r--r--Tests/RunCMake/install/preinstall.cmake1
-rwxr-xr-xTests/RunCMake/install/script (renamed from Tests/SimpleInstall/scripts/sample_script)0
-rwxr-xr-xTests/RunCMake/install/script.bat (renamed from Tests/SimpleInstall/scripts/sample_script.bat)0
-rw-r--r--Tests/RunCMake/install/testobj1.c9
-rw-r--r--Tests/RunCMake/interface_library/global-interface-stderr.txt4
-rw-r--r--Tests/RunCMake/interface_library/target_commands-stderr.txt16
-rw-r--r--Tests/RunCMake/interface_library/whitelist.cmake19
-rw-r--r--Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt2
-rw-r--r--Tests/RunCMake/list/FILTER-NotList-stderr.txt4
-rw-r--r--Tests/RunCMake/list/FILTER-NotList.cmake4
-rw-r--r--Tests/RunCMake/list/INSERT-InvalidIndex-stderr.txt2
-rw-r--r--Tests/RunCMake/list/INSERT-InvalidIndex.cmake2
-rw-r--r--Tests/RunCMake/list/JOIN-NoArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/JOIN-NoArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/JOIN-NoArguments.cmake1
-rw-r--r--Tests/RunCMake/list/JOIN-NoVariable-result.txt1
-rw-r--r--Tests/RunCMake/list/JOIN-NoVariable-stderr.txt4
-rw-r--r--Tests/RunCMake/list/JOIN-NoVariable.cmake1
-rw-r--r--Tests/RunCMake/list/JOIN-TooManyArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/JOIN-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/JOIN-TooManyArguments.cmake1
-rw-r--r--Tests/RunCMake/list/JOIN.cmake18
-rw-r--r--Tests/RunCMake/list/POP_BACK-NoArgs-result.txt1
-rw-r--r--Tests/RunCMake/list/POP_BACK-NoArgs-stderr.txt1
-rw-r--r--Tests/RunCMake/list/POP_BACK-NoArgs.cmake1
-rw-r--r--Tests/RunCMake/list/POP_BACK.cmake79
-rw-r--r--Tests/RunCMake/list/POP_FRONT-NoArgs-result.txt1
-rw-r--r--Tests/RunCMake/list/POP_FRONT-NoArgs-stderr.txt1
-rw-r--r--Tests/RunCMake/list/POP_FRONT-NoArgs.cmake1
-rw-r--r--Tests/RunCMake/list/POP_FRONT.cmake92
-rw-r--r--Tests/RunCMake/list/PREPEND-NoArgs-result.txt1
-rw-r--r--Tests/RunCMake/list/PREPEND-NoArgs-stderr.txt1
-rw-r--r--Tests/RunCMake/list/PREPEND-NoArgs.cmake1
-rw-r--r--Tests/RunCMake/list/PREPEND.cmake33
-rw-r--r--Tests/RunCMake/list/REMOVE_AT-EmptyList-result.txt1
-rw-r--r--Tests/RunCMake/list/REMOVE_AT-EmptyList-stderr.txt4
-rw-r--r--Tests/RunCMake/list/REMOVE_AT-EmptyList.cmake6
-rw-r--r--Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt2
-rw-r--r--Tests/RunCMake/list/REMOVE_AT-NotList.cmake4
-rw-r--r--Tests/RunCMake/list/REMOVE_DUPLICATES-NotList-stderr.txt4
-rw-r--r--Tests/RunCMake/list/REMOVE_DUPLICATES-NotList.cmake4
-rw-r--r--Tests/RunCMake/list/REMOVE_DUPLICATES-PreserveOrder.cmake5
-rw-r--r--Tests/RunCMake/list/REMOVE_ITEM-NotList-stderr.txt4
-rw-r--r--Tests/RunCMake/list/REMOVE_ITEM-NotList.cmake4
-rw-r--r--Tests/RunCMake/list/REVERSE-NotList-stderr.txt4
-rw-r--r--Tests/RunCMake/list/REVERSE-NotList.cmake4
-rw-r--r--Tests/RunCMake/list/RunCMakeTest.cmake83
-rw-r--r--Tests/RunCMake/list/SORT-BadCaseOption-result.txt1
-rw-r--r--Tests/RunCMake/list/SORT-BadCaseOption-stderr.txt4
-rw-r--r--Tests/RunCMake/list/SORT-BadCaseOption.cmake1
-rw-r--r--Tests/RunCMake/list/SORT-BadCompareOption-result.txt1
-rw-r--r--Tests/RunCMake/list/SORT-BadCompareOption-stderr.txt5
-rw-r--r--Tests/RunCMake/list/SORT-BadCompareOption.cmake1
-rw-r--r--Tests/RunCMake/list/SORT-BadOrderOption-result.txt1
-rw-r--r--Tests/RunCMake/list/SORT-BadOrderOption-stderr.txt5
-rw-r--r--Tests/RunCMake/list/SORT-BadOrderOption.cmake1
-rw-r--r--Tests/RunCMake/list/SORT-DuplicateCaseOption-result.txt1
-rw-r--r--Tests/RunCMake/list/SORT-DuplicateCaseOption-stderr.txt4
-rw-r--r--Tests/RunCMake/list/SORT-DuplicateCaseOption.cmake2
-rw-r--r--Tests/RunCMake/list/SORT-DuplicateCompareOption-result.txt1
-rw-r--r--Tests/RunCMake/list/SORT-DuplicateCompareOption-stderr.txt4
-rw-r--r--Tests/RunCMake/list/SORT-DuplicateCompareOption.cmake2
-rw-r--r--Tests/RunCMake/list/SORT-DuplicateOrderOption-result.txt1
-rw-r--r--Tests/RunCMake/list/SORT-DuplicateOrderOption-stderr.txt4
-rw-r--r--Tests/RunCMake/list/SORT-DuplicateOrderOption.cmake2
-rw-r--r--Tests/RunCMake/list/SORT-NoCaseOption-result.txt1
-rw-r--r--Tests/RunCMake/list/SORT-NoCaseOption-stderr.txt4
-rw-r--r--Tests/RunCMake/list/SORT-NoCaseOption.cmake1
-rw-r--r--Tests/RunCMake/list/SORT-NotList-stderr.txt4
-rw-r--r--Tests/RunCMake/list/SORT-NotList.cmake4
-rw-r--r--Tests/RunCMake/list/SORT-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/SORT-WrongOption-result.txt1
-rw-r--r--Tests/RunCMake/list/SORT-WrongOption-stderr.txt4
-rw-r--r--Tests/RunCMake/list/SORT-WrongOption.cmake (renamed from Tests/RunCMake/list/SORT-TooManyArguments.cmake)0
-rw-r--r--Tests/RunCMake/list/SORT.cmake114
-rw-r--r--Tests/RunCMake/list/SUBLIST-InvalidIndex-result.txt1
-rw-r--r--Tests/RunCMake/list/SUBLIST-InvalidIndex-stderr.txt4
-rw-r--r--Tests/RunCMake/list/SUBLIST-InvalidIndex.cmake2
-rw-r--r--Tests/RunCMake/list/SUBLIST-InvalidLength-result.txt1
-rw-r--r--Tests/RunCMake/list/SUBLIST-InvalidLength-stderr.txt4
-rw-r--r--Tests/RunCMake/list/SUBLIST-InvalidLength.cmake2
-rw-r--r--Tests/RunCMake/list/SUBLIST-NoArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/SUBLIST-NoArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/SUBLIST-NoArguments.cmake1
-rw-r--r--Tests/RunCMake/list/SUBLIST-NoVariable-result.txt1
-rw-r--r--Tests/RunCMake/list/SUBLIST-NoVariable-stderr.txt4
-rw-r--r--Tests/RunCMake/list/SUBLIST-NoVariable.cmake2
-rw-r--r--Tests/RunCMake/list/SUBLIST-TooManyArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/SUBLIST-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/SUBLIST-TooManyArguments.cmake1
-rw-r--r--Tests/RunCMake/list/SUBLIST.cmake46
-rw-r--r--Tests/RunCMake/list/TRANSFORM-APPEND-NoArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-APPEND-NoArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-APPEND-NoArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-APPEND-TooManyArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-APPEND-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-APPEND-TooManyArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-APPEND.cmake48
-rw-r--r--Tests/RunCMake/list/TRANSFORM-GENEX_STRIP-TooManyArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-GENEX_STRIP-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-GENEX_STRIP-TooManyArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-GENEX_STRIP.cmake49
-rw-r--r--Tests/RunCMake/list/TRANSFORM-InvalidAction-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-InvalidAction-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-InvalidAction.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-NoAction-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-NoAction-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-NoAction.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-PREPEND-NoArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-PREPEND-NoArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-PREPEND-NoArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-PREPEND-TooManyArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-PREPEND-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-PREPEND-TooManyArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-PREPEND.cmake48
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidRegex-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidRegex-stderr.txt5
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidRegex.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace1-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace1-stderr.txt5
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace1.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace2-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace2-stderr.txt5
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace2.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-NoArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-NoArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-NoArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-NoEnoughArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-NoEnoughArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-NoEnoughArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-TooManyArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE-TooManyArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-REPLACE.cmake48
-rw-r--r--Tests/RunCMake/list/TRANSFORM-STRIP-TooManyArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-STRIP-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-STRIP-TooManyArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-STRIP.cmake49
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-AT-BadArgument-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-AT-BadArgument-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-AT-BadArgument.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-AT-InvalidIndex-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-AT-InvalidIndex-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-AT-InvalidIndex.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-AT-NoArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-AT-NoArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-AT-NoArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-BadArgument-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-BadArgument-stderr.txt5
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-BadArgument.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-InvalidIndex-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-InvalidIndex-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-InvalidIndex.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoEnoughArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoEnoughArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoEnoughArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-TooManyArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-FOR-TooManyArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-REGEX-InvalidRegex-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-REGEX-InvalidRegex-stderr.txt5
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-REGEX-InvalidRegex.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-REGEX-NoArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-REGEX-NoArguments-stderr.txt5
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-REGEX-NoArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-REGEX-TooManyArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-REGEX-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-Selector-REGEX-TooManyArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-TOLOWER-TooManyArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-TOLOWER-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-TOLOWER-TooManyArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-TOLOWER.cmake48
-rw-r--r--Tests/RunCMake/list/TRANSFORM-TOUPPER-TooManyArguments-result.txt1
-rw-r--r--Tests/RunCMake/list/TRANSFORM-TOUPPER-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/list/TRANSFORM-TOUPPER-TooManyArguments.cmake2
-rw-r--r--Tests/RunCMake/list/TRANSFORM-TOUPPER.cmake48
-rw-r--r--Tests/RunCMake/math/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/math/MATH-DivideByZero-result.txt1
-rw-r--r--Tests/RunCMake/math/MATH-DivideByZero-stderr.txt4
-rw-r--r--Tests/RunCMake/math/MATH-DivideByZero.cmake1
-rw-r--r--Tests/RunCMake/math/MATH-DoubleOption-result.txt1
-rw-r--r--Tests/RunCMake/math/MATH-DoubleOption-stderr.txt4
-rw-r--r--Tests/RunCMake/math/MATH-DoubleOption.cmake1
-rw-r--r--Tests/RunCMake/math/MATH-InvalidExpression-result.txt1
-rw-r--r--Tests/RunCMake/math/MATH-InvalidExpression-stderr.txt5
-rw-r--r--Tests/RunCMake/math/MATH-InvalidExpression.cmake1
-rw-r--r--Tests/RunCMake/math/MATH-ToleratedExpression-stderr.txt8
-rw-r--r--Tests/RunCMake/math/MATH-ToleratedExpression.cmake4
-rw-r--r--Tests/RunCMake/math/MATH-TooManyArguments-result.txt1
-rw-r--r--Tests/RunCMake/math/MATH-TooManyArguments-stderr.txt4
-rw-r--r--Tests/RunCMake/math/MATH-TooManyArguments.cmake1
-rw-r--r--Tests/RunCMake/math/MATH-WrongArgument-result.txt1
-rw-r--r--Tests/RunCMake/math/MATH-WrongArgument-stderr.txt4
-rw-r--r--Tests/RunCMake/math/MATH-WrongArgument.cmake1
-rw-r--r--Tests/RunCMake/math/MATH.cmake12
-rw-r--r--Tests/RunCMake/math/RunCMakeTest.cmake9
-rw-r--r--Tests/RunCMake/message/RunCMakeTest.cmake64
-rw-r--r--Tests/RunCMake/message/message-all-loglevels.cmake10
-rw-r--r--Tests/RunCMake/message/message-indent-multiline-stderr.txt3
-rw-r--r--Tests/RunCMake/message/message-indent-multiline-stdout.txt8
-rw-r--r--Tests/RunCMake/message/message-indent-multiline.cmake13
-rw-r--r--Tests/RunCMake/message/message-indent-stdout.txt13
-rw-r--r--Tests/RunCMake/message/message-indent.cmake19
-rw-r--r--Tests/RunCMake/message/message-log-level-debug-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-log-level-debug-stdout.txt3
-rw-r--r--Tests/RunCMake/message/message-log-level-default-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-log-level-default-stdout.txt1
-rw-r--r--Tests/RunCMake/message/message-log-level-invalid-result.txt1
-rw-r--r--Tests/RunCMake/message/message-log-level-invalid-stderr.txt1
-rw-r--r--Tests/RunCMake/message/message-log-level-notice-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-log-level-status-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-log-level-status-stdout.txt1
-rw-r--r--Tests/RunCMake/message/message-log-level-trace-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-log-level-trace-stdout.txt4
-rw-r--r--Tests/RunCMake/message/message-log-level-verbose-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-log-level-verbose-stdout.txt2
-rw-r--r--Tests/RunCMake/message/message-log-level-warning-stderr.txt9
-rw-r--r--Tests/RunCMake/message/message-loglevel-debug-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-loglevel-debug-stdout.txt3
-rw-r--r--Tests/RunCMake/message/message-loglevel-default-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-loglevel-default-stdout.txt1
-rw-r--r--Tests/RunCMake/message/message-loglevel-invalid-result.txt1
-rw-r--r--Tests/RunCMake/message/message-loglevel-invalid-stderr.txt1
-rw-r--r--Tests/RunCMake/message/message-loglevel-notice-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-loglevel-status-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-loglevel-status-stdout.txt1
-rw-r--r--Tests/RunCMake/message/message-loglevel-trace-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-loglevel-trace-stdout.txt4
-rw-r--r--Tests/RunCMake/message/message-loglevel-verbose-stderr.txt12
-rw-r--r--Tests/RunCMake/message/message-loglevel-verbose-stdout.txt2
-rw-r--r--Tests/RunCMake/message/message-loglevel-warning-stderr.txt9
-rw-r--r--Tests/RunCMake/message/warnmessage-rootdir-stderr.txt1
-rw-r--r--Tests/RunCMake/message/warnmessage-rootdir.cmake5
-rw-r--r--Tests/RunCMake/option/CMP0077-NEW.cmake14
-rw-r--r--Tests/RunCMake/option/CMP0077-OLD.cmake9
-rw-r--r--Tests/RunCMake/option/CMP0077-SECOND-PASS.cmake14
-rw-r--r--Tests/RunCMake/option/CMP0077-WARN-stderr.txt7
-rw-r--r--Tests/RunCMake/option/CMP0077-WARN.cmake5
-rw-r--r--Tests/RunCMake/option/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/option/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/print_stdin.c18
-rw-r--r--Tests/RunCMake/project/CMP0048-NEW.cmake7
-rw-r--r--Tests/RunCMake/project/CMP0048-OLD-stderr.txt10
-rw-r--r--Tests/RunCMake/project/CMP0096-NEW-stdout.txt30
-rw-r--r--Tests/RunCMake/project/CMP0096-NEW.cmake6
-rw-r--r--Tests/RunCMake/project/CMP0096-OLD-stdout.txt20
-rw-r--r--Tests/RunCMake/project/CMP0096-OLD.cmake3
-rw-r--r--Tests/RunCMake/project/CMP0096-WARN-stdout.txt20
-rw-r--r--Tests/RunCMake/project/CMP0096-WARN.cmake3
-rw-r--r--Tests/RunCMake/project/CMP0096-common.cmake9
-rw-r--r--Tests/RunCMake/project/LanguagesUnordered-stderr.txt1
-rw-r--r--Tests/RunCMake/project/LanguagesUnordered.cmake1
-rw-r--r--Tests/RunCMake/project/PrintVersions.cmake6
-rw-r--r--Tests/RunCMake/project/ProjectDescription2-stderr.txt2
-rw-r--r--Tests/RunCMake/project/ProjectDescriptionNoArg-stderr.txt2
-rw-r--r--Tests/RunCMake/project/ProjectDescriptionNoArg.cmake2
-rw-r--r--Tests/RunCMake/project/ProjectDescriptionNoArg2-stderr.txt2
-rw-r--r--Tests/RunCMake/project/ProjectDescriptionNoArg2.cmake2
-rw-r--r--Tests/RunCMake/project/ProjectHomepage-stdout.txt3
-rw-r--r--Tests/RunCMake/project/ProjectHomepage.cmake14
-rw-r--r--Tests/RunCMake/project/ProjectHomepage2-result.txt1
-rw-r--r--Tests/RunCMake/project/ProjectHomepage2-stderr.txt4
-rw-r--r--Tests/RunCMake/project/ProjectHomepage2.cmake2
-rw-r--r--Tests/RunCMake/project/ProjectHomepageNoArg-stderr.txt5
-rw-r--r--Tests/RunCMake/project/ProjectHomepageNoArg.cmake2
-rw-r--r--Tests/RunCMake/project/ProjectTwice.cmake26
-rw-r--r--Tests/RunCMake/project/RunCMakeTest.cmake12
-rw-r--r--Tests/RunCMake/project/VersionMax.cmake32
-rw-r--r--Tests/RunCMake/project/VersionMissingLanguages-stderr.txt3
-rw-r--r--Tests/RunCMake/project/VersionMissingValueOkay-stderr.txt2
-rw-r--r--Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt12
-rw-r--r--Tests/RunCMake/project_injected/CMP0048-WARN.cmake0
-rw-r--r--Tests/RunCMake/project_injected/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/project_injected/RunCMakeTest.cmake12
-rw-r--r--Tests/RunCMake/pseudo_cppcheck.c39
-rw-r--r--Tests/RunCMake/pseudo_emulator_custom_command_arg.c30
-rw-r--r--Tests/RunCMake/set/ExtraEnvValue-stderr.txt6
-rw-r--r--Tests/RunCMake/set/ExtraEnvValue.cmake1
-rw-r--r--Tests/RunCMake/set/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/set/UnknownCacheType-stderr.txt5
-rw-r--r--Tests/RunCMake/set/UnknownCacheType.cmake1
-rw-r--r--Tests/RunCMake/set_property/IMPORTED_GLOBAL-result.txt1
-rw-r--r--Tests/RunCMake/set_property/IMPORTED_GLOBAL-stderr.txt61
-rw-r--r--Tests/RunCMake/set_property/IMPORTED_GLOBAL-stdout.txt17
-rw-r--r--Tests/RunCMake/set_property/IMPORTED_GLOBAL.cmake53
-rw-r--r--Tests/RunCMake/set_property/IMPORTED_GLOBAL/CMakeLists.txt8
-rw-r--r--Tests/RunCMake/set_property/LINK_DIRECTORIES-stdout.txt2
-rw-r--r--Tests/RunCMake/set_property/LINK_DIRECTORIES.cmake3
-rw-r--r--Tests/RunCMake/set_property/LINK_OPTIONS-stdout.txt2
-rw-r--r--Tests/RunCMake/set_property/LINK_OPTIONS.cmake3
-rw-r--r--Tests/RunCMake/set_property/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/set_property/USER_PROP_INHERITED-stdout.txt29
-rw-r--r--Tests/RunCMake/set_property/USER_PROP_INHERITED.cmake83
-rw-r--r--Tests/RunCMake/set_property/USER_PROP_INHERITED/CMakeLists.txt21
-rw-r--r--Tests/RunCMake/set_property/test.cpp0
-rw-r--r--Tests/RunCMake/string/AppendNoArgs-stderr.txt2
-rw-r--r--Tests/RunCMake/string/ConcatNoArgs-stderr.txt2
-rw-r--r--Tests/RunCMake/string/Join.cmake16
-rw-r--r--Tests/RunCMake/string/JoinNoArgs-result.txt1
-rw-r--r--Tests/RunCMake/string/JoinNoArgs-stderr.txt4
-rw-r--r--Tests/RunCMake/string/JoinNoArgs.cmake1
-rw-r--r--Tests/RunCMake/string/JoinNoVar-result.txt1
-rw-r--r--Tests/RunCMake/string/JoinNoVar-stderr.txt4
-rw-r--r--Tests/RunCMake/string/JoinNoVar.cmake1
-rw-r--r--Tests/RunCMake/string/Prepend.cmake58
-rw-r--r--Tests/RunCMake/string/PrependNoArgs-result.txt1
-rw-r--r--Tests/RunCMake/string/PrependNoArgs-stderr.txt4
-rw-r--r--Tests/RunCMake/string/PrependNoArgs.cmake1
-rw-r--r--Tests/RunCMake/string/RegexMultiMatchClear-stderr.txt12
-rw-r--r--Tests/RunCMake/string/RegexMultiMatchClear.cmake20
-rw-r--r--Tests/RunCMake/string/Repeat.cmake45
-rw-r--r--Tests/RunCMake/string/RepeatNegativeCount-result.txt1
-rw-r--r--Tests/RunCMake/string/RepeatNegativeCount-stderr.txt4
-rw-r--r--Tests/RunCMake/string/RepeatNegativeCount.cmake1
-rw-r--r--Tests/RunCMake/string/RepeatNoArgs-result.txt1
-rw-r--r--Tests/RunCMake/string/RepeatNoArgs-stderr.txt4
-rw-r--r--Tests/RunCMake/string/RepeatNoArgs.cmake1
-rw-r--r--Tests/RunCMake/string/RunCMakeTest.cmake12
-rw-r--r--Tests/RunCMake/string/Timestamp-stderr.txt2
-rw-r--r--Tests/RunCMake/string/Timestamp.cmake2
-rw-r--r--Tests/RunCMake/string/UuidBadNamespace-stderr.txt2
-rw-r--r--Tests/RunCMake/string/UuidBadType-stderr.txt2
-rw-r--r--Tests/RunCMake/string/UuidMissingNameValue-stderr.txt2
-rw-r--r--Tests/RunCMake/string/UuidMissingNamespace-stderr.txt2
-rw-r--r--Tests/RunCMake/string/UuidMissingNamespaceValue-stderr.txt2
-rw-r--r--Tests/RunCMake/string/UuidMissingTypeValue-stderr.txt2
-rw-r--r--Tests/RunCMake/target_compile_definitions/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/target_compile_definitions/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/target_compile_definitions/empty_keyword_args.cmake5
-rw-r--r--Tests/RunCMake/target_compile_definitions/unknown_imported_target.cmake11
-rw-r--r--Tests/RunCMake/target_compile_features/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/target_compile_features/alias_target-stderr.txt2
-rw-r--r--Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt2
-rw-r--r--Tests/RunCMake/target_compile_features/empty_keyword_args.cmake5
-rw-r--r--Tests/RunCMake/target_compile_features/imported_target-stderr.txt7
-rw-r--r--Tests/RunCMake/target_compile_features/imported_target.cmake10
-rw-r--r--Tests/RunCMake/target_compile_features/invalid_args-stderr.txt2
-rw-r--r--Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt4
-rw-r--r--Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt2
-rw-r--r--Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt2
-rw-r--r--Tests/RunCMake/target_compile_features/no_target-stderr.txt2
-rw-r--r--Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt2
-rw-r--r--Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt2
-rw-r--r--Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt2
-rw-r--r--Tests/RunCMake/target_compile_features/utility_target-stderr.txt2
-rw-r--r--Tests/RunCMake/target_compile_options/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/target_compile_options/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/target_compile_options/empty_keyword_args.cmake5
-rw-r--r--Tests/RunCMake/target_include_directories/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/target_include_directories/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/target_include_directories/empty_keyword_args.cmake5
-rw-r--r--Tests/RunCMake/target_link_directories/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/target_link_directories/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/target_link_directories/empty_keyword_args.cmake5
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt2
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt2
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt2
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt2
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-iface-NEW-stdout.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-iface-NEW.cmake2
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-iface-OLD-stdout.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-iface-OLD.cmake2
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stderr.txt17
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stdout.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN.cmake1
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-iface-common.cmake6
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-iface/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt6
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus.cmake6
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-stdout.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-NEW.cmake2
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-OLD-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-OLD-stderr.txt5
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-OLD.cmake2
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-WARN-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-WARN-stderr.txt5
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-WARN.cmake1
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-common.cmake6
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/target_link_libraries/ImportedTarget.cmake2
-rw-r--r--Tests/RunCMake/target_link_libraries/ImportedTargetFailure-result.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries/ImportedTargetFailure-stderr.txt5
-rw-r--r--Tests/RunCMake/target_link_libraries/ImportedTargetFailure.cmake2
-rw-r--r--Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt6
-rw-r--r--Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake12
-rw-r--r--Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-stderr.txt2
-rw-r--r--Tests/RunCMake/target_link_libraries/SubDirTarget-stderr.txt5
-rw-r--r--Tests/RunCMake/target_link_libraries/SubDirTarget.cmake3
-rw-r--r--Tests/RunCMake/target_link_libraries/SubDirTarget/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake4
-rw-r--r--Tests/RunCMake/target_link_libraries/empty_keyword_args.cmake4
-rw-r--r--Tests/RunCMake/target_link_options/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/target_link_options/LINKER_expansion-LINKER-check.cmake2
-rw-r--r--Tests/RunCMake/target_link_options/LINKER_expansion-LINKER_SHELL-check.cmake2
-rw-r--r--Tests/RunCMake/target_link_options/LINKER_expansion-validation.cmake15
-rw-r--r--Tests/RunCMake/target_link_options/LINKER_expansion.cmake49
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-check.cmake7
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-result.txt1
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-check.cmake7
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-result.txt1
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-result.txt1
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-static-check.cmake4
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-static-result.txt1
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-check.cmake7
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-result.txt1
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-check.cmake7
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-result.txt1
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-static-check.cmake7
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS-static-result.txt (renamed from Tests/RunCMake/CMP0045/CMP0045-OLD-result.txt)0
-rw-r--r--Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake55
-rw-r--r--Tests/RunCMake/target_link_options/LinkOptionsExe.c4
-rw-r--r--Tests/RunCMake/target_link_options/LinkOptionsLib.c7
-rw-r--r--Tests/RunCMake/target_link_options/RunCMakeTest.cmake43
-rw-r--r--Tests/RunCMake/target_link_options/bad_SHELL_usage-result.txt1
-rw-r--r--Tests/RunCMake/target_link_options/bad_SHELL_usage-stderr.txt4
-rw-r--r--Tests/RunCMake/target_link_options/bad_SHELL_usage.cmake5
-rw-r--r--Tests/RunCMake/target_link_options/dump.c13
-rw-r--r--Tests/RunCMake/target_link_options/empty_keyword_args.cmake5
-rw-r--r--Tests/RunCMake/target_sources/CMakeLists.txt5
-rw-r--r--Tests/RunCMake/target_sources/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/target_sources/empty_keyword_args.cmake5
-rw-r--r--Tests/RunCMake/test_include_dirs/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake17
-rw-r--r--Tests/RunCMake/test_include_dirs/TID-test-stdout.txt17
-rw-r--r--Tests/RunCMake/test_include_dirs/TID.cmake29
-rw-r--r--Tests/RunCMake/test_include_dirs/add-tests.cmake8
-rw-r--r--Tests/RunCMake/test_include_dirs/dummy.cpp4
-rw-r--r--Tests/RunCMake/try_compile/CMP0056-stderr.txt13
-rw-r--r--Tests/RunCMake/try_compile/CMP0066-stderr.txt13
-rw-r--r--Tests/RunCMake/try_compile/CMP0067-stderr.txt11
-rw-r--r--Tests/RunCMake/try_compile/CStandardGNU.c4
-rw-r--r--Tests/RunCMake/try_compile/CxxStandardGNU.cxx4
-rw-r--r--Tests/RunCMake/try_compile/LinkOptions.cmake40
-rw-r--r--Tests/RunCMake/try_compile/ObjCStandard-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/ObjCStandard-stderr.txt7
-rw-r--r--Tests/RunCMake/try_compile/ObjCStandard.cmake7
-rw-r--r--Tests/RunCMake/try_compile/ObjCxxStandard-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/ObjCxxStandard-stderr.txt7
-rw-r--r--Tests/RunCMake/try_compile/ObjCxxStandard.cmake7
-rw-r--r--Tests/RunCMake/try_compile/RunCMakeTest.cmake13
-rw-r--r--Tests/RunCMake/try_compile/lib.c4
-rw-r--r--Tests/RunCMake/try_compile/main.c8
-rw-r--r--Tests/RunCMake/try_compile/src.c2
-rw-r--r--Tests/RunCMake/try_compile/src.m4
-rw-r--r--Tests/RunCMake/try_compile/src.mm4
-rw-r--r--Tests/RunCMake/try_run/LinkOptions.cmake44
-rw-r--r--Tests/RunCMake/try_run/RunCMakeTest.cmake7
-rw-r--r--Tests/RunCMake/try_run/lib.c4
-rw-r--r--Tests/RunCMake/try_run/main.c8
-rw-r--r--Tests/RunCMake/variable_watch/ModifyWatchInCallback.cmake17
-rw-r--r--Tests/RunCMake/variable_watch/RaiseInParentScope-stderr.txt2
-rw-r--r--Tests/RunCMake/variable_watch/RaiseInParentScope.cmake15
-rw-r--r--Tests/RunCMake/variable_watch/RunCMakeTest.cmake2
-rw-r--r--Tests/RuntimePath/CMakeLists.txt13
-rw-r--r--Tests/SameName/CMakeLists.txt7
-rw-r--r--Tests/SameName/Exe1/CMakeLists.txt11
-rw-r--r--Tests/SameName/Exe1/conly.c11
-rw-r--r--Tests/SameName/Lib1/CMakeLists.txt1
-rw-r--r--Tests/SameName/Lib1/libc1.c4
-rw-r--r--Tests/SameName/Lib1/libc1.h1
-rw-r--r--Tests/Server/CMakeLists.txt17
-rw-r--r--Tests/Server/cmakelib.py231
-rw-r--r--Tests/Server/server-test.py177
-rw-r--r--Tests/Server/tc_cache.json24
-rw-r--r--Tests/Server/tc_handshake.json4
-rw-r--r--Tests/SimpleExclude/CMakeLists.txt11
-rw-r--r--Tests/SimpleExclude/dirC/CMakeLists.txt3
-rw-r--r--Tests/SimpleExclude/dirC/dirA/CMakeLists.txt10
-rw-r--r--Tests/SimpleExclude/dirC/dirA/t1.c8
-rw-r--r--Tests/SimpleExclude/dirC/dirA/t2.c7
-rw-r--r--Tests/SimpleExclude/dirC/dirA/t3.c7
-rw-r--r--Tests/SimpleExclude/dirC/dirA/t4.c17
-rw-r--r--Tests/SimpleExclude/dirC/dirA/t5.c7
-rw-r--r--Tests/SimpleExclude/dirC/dirB/CMakeLists.txt5
-rw-r--r--Tests/SimpleExclude/dirC/dirB/t6.c8
-rw-r--r--Tests/SimpleExclude/dirC/dirB/t7.c15
-rw-r--r--Tests/SimpleExclude/dirD/CMakeLists.txt7
-rw-r--r--Tests/SimpleExclude/dirD/t8.c7
-rw-r--r--Tests/SimpleExclude/dirD/t9.c24
-rw-r--r--Tests/SimpleExclude/run.cmake.in13
-rw-r--r--Tests/SimpleInstall/CMakeLists.txt397
-rw-r--r--Tests/SimpleInstall/InstallScript1.cmake5
-rw-r--r--Tests/SimpleInstall/InstallScript2.cmake14
-rw-r--r--Tests/SimpleInstall/InstallScript3.cmake12
-rw-r--r--Tests/SimpleInstall/InstallScript4.cmake22
-rw-r--r--Tests/SimpleInstall/PackageScript.cmake10
-rw-r--r--Tests/SimpleInstall/PostInstall.cmake6
-rw-r--r--Tests/SimpleInstall/PreInstall.cmake2
-rw-r--r--Tests/SimpleInstall/TestSubDir/CMakeLists.txt3
-rw-r--r--Tests/SimpleInstall/TestSubDir/TSD.cxx10
-rw-r--r--Tests/SimpleInstall/TestSubDir/TSD.h1
-rw-r--r--Tests/SimpleInstall/TestSubDir/TSD_utils.cxx9
-rw-r--r--Tests/SimpleInstall/foo.c6
-rw-r--r--Tests/SimpleInstall/foo.h10
-rw-r--r--Tests/SimpleInstall/inst.cxx34
-rw-r--r--Tests/SimpleInstall/inst2.cxx2
-rw-r--r--Tests/SimpleInstall/lib1.cxx6
-rw-r--r--Tests/SimpleInstall/lib1.h1
-rw-r--r--Tests/SimpleInstall/lib2.cxx6
-rw-r--r--Tests/SimpleInstall/lib2.h11
-rw-r--r--Tests/SimpleInstall/lib3.cxx6
-rw-r--r--Tests/SimpleInstall/lib3.h11
-rw-r--r--Tests/SimpleInstall/lib4.cxx6
-rw-r--r--Tests/SimpleInstall/lib4.h11
-rw-r--r--Tests/SimpleInstall/scripts/.gitattributes1
-rw-r--r--Tests/SimpleInstall/scripts/CMakeLists.txt1
-rw-r--r--Tests/SimpleInstallS2/CMakeLists.txt396
-rw-r--r--Tests/SimpleInstallS2/InstallScript1.cmake5
-rw-r--r--Tests/SimpleInstallS2/InstallScript2.cmake14
-rw-r--r--Tests/SimpleInstallS2/InstallScript3.cmake12
-rw-r--r--Tests/SimpleInstallS2/InstallScript4.cmake22
-rw-r--r--Tests/SimpleInstallS2/PackageScript.cmake10
-rw-r--r--Tests/SimpleInstallS2/PostInstall.cmake6
-rw-r--r--Tests/SimpleInstallS2/PreInstall.cmake2
-rw-r--r--Tests/SimpleInstallS2/TestSubDir/CMakeLists.txt3
-rw-r--r--Tests/SimpleInstallS2/TestSubDir/TSD.cxx10
-rw-r--r--Tests/SimpleInstallS2/TestSubDir/TSD.h1
-rw-r--r--Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx9
-rw-r--r--Tests/SimpleInstallS2/foo.c6
-rw-r--r--Tests/SimpleInstallS2/foo.h10
-rw-r--r--Tests/SimpleInstallS2/inst.cxx34
-rw-r--r--Tests/SimpleInstallS2/inst2.cxx2
-rw-r--r--Tests/SimpleInstallS2/lib1.cxx6
-rw-r--r--Tests/SimpleInstallS2/lib1.h1
-rw-r--r--Tests/SimpleInstallS2/lib2.cxx6
-rw-r--r--Tests/SimpleInstallS2/lib2.h11
-rw-r--r--Tests/SimpleInstallS2/lib3.cxx6
-rw-r--r--Tests/SimpleInstallS2/lib3.h11
-rw-r--r--Tests/SimpleInstallS2/lib4.cxx6
-rw-r--r--Tests/SimpleInstallS2/lib4.h11
-rw-r--r--Tests/SimpleInstallS2/scripts/.gitattributes1
-rw-r--r--Tests/SimpleInstallS2/scripts/CMakeLists.txt1
-rwxr-xr-xTests/SimpleInstallS2/scripts/sample_script2
-rwxr-xr-xTests/SimpleInstallS2/scripts/sample_script.bat1
-rw-r--r--Tests/SourceFileIncludeDirProperty/CMakeLists.txt15
-rw-r--r--Tests/SourceFileIncludeDirProperty/main.c7
-rw-r--r--Tests/SourceFileIncludeDirProperty/source/header.h2
-rw-r--r--Tests/SourceFileIncludeDirProperty/target/header.h2
-rw-r--r--Tests/SourceFileProperty/CMakeLists.txt22
-rw-r--r--Tests/SourceGroups/CMakeLists.txt18
-rw-r--r--Tests/SourceGroups/main.c7
-rw-r--r--Tests/SourceGroups/tree_empty_prefix_bar.c4
-rw-r--r--Tests/SourceGroups/tree_empty_prefix_foo.c4
-rw-r--r--Tests/StagingPrefix/CMakeLists.txt16
-rw-r--r--Tests/SubDir/Executable/test.cxx8
-rw-r--r--Tests/SubDirSpaces/CMakeLists.txt2
-rw-r--r--Tests/SubDirSpaces/Executable Sources/test.cxx8
-rw-r--r--Tests/SubDirSpaces/Executable/test.cxx8
-rw-r--r--Tests/SwiftMix/CMain.c6
-rw-r--r--Tests/SwiftMix/CMakeLists.txt1
-rw-r--r--Tests/SwiftMix/ObjCMain.m2
-rw-r--r--Tests/SwiftMix/SwiftMain.swift2
-rw-r--r--Tests/SwiftOnly/CMakeLists.txt7
-rw-r--r--Tests/SwigTest/CMakeLists.txt59
-rw-r--r--Tests/SwigTest/example.i10
-rw-r--r--Tests/SwigTest/runme.pl57
-rw-r--r--Tests/SwigTest/runme.py51
-rw-r--r--Tests/SwigTest/runme.tcl50
-rw-r--r--Tests/SwigTest/runme2.tcl70
-rw-r--r--Tests/SystemInformation/DumpInformation.cxx2
-rw-r--r--Tests/TestsWorkingDirectory/main.c24
-rw-r--r--Tests/TryCompile/CMakeLists.txt106
-rw-r--r--Tests/TryCompile/check_a_b.c10
-rw-r--r--Tests/TryCompile/fail.m1
-rw-r--r--Tests/TryCompile/pass.m4
-rw-r--r--Tests/TryCompile/testdef.c2
-rw-r--r--Tests/Tutorial/Step1/CMakeLists.txt20
-rw-r--r--Tests/Tutorial/Step1/TutorialConfig.h.in4
-rw-r--r--Tests/Tutorial/Step1/tutorial.cxx19
-rw-r--r--Tests/Tutorial/Step2/CMakeLists.txt31
-rw-r--r--Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx26
-rw-r--r--Tests/Tutorial/Step2/TutorialConfig.h.in5
-rw-r--r--Tests/Tutorial/Step2/tutorial.cxx33
-rw-r--r--Tests/Tutorial/Step3/CMakeLists.txt68
-rw-r--r--Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt4
-rw-r--r--Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx26
-rw-r--r--Tests/Tutorial/Step3/TutorialConfig.h.in5
-rw-r--r--Tests/Tutorial/Step3/tutorial.cxx33
-rw-r--r--Tests/Tutorial/Step4/CMakeLists.txt68
-rw-r--r--Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt4
-rw-r--r--Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx36
-rw-r--r--Tests/Tutorial/Step4/TutorialConfig.h.in9
-rw-r--r--Tests/Tutorial/Step4/tutorial.cxx33
-rw-r--r--Tests/Tutorial/Step5/CMakeLists.txt72
-rw-r--r--Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx40
-rw-r--r--Tests/Tutorial/Step5/TutorialConfig.h.in9
-rw-r--r--Tests/Tutorial/Step5/tutorial.cxx33
-rw-r--r--Tests/Tutorial/Step6/CMakeLists.txt78
-rw-r--r--Tests/Tutorial/Step6/License.txt2
-rw-r--r--Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt24
-rw-r--r--Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx32
-rw-r--r--Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx40
-rw-r--r--Tests/Tutorial/Step6/TutorialConfig.h.in9
-rw-r--r--Tests/Tutorial/Step6/tutorial.cxx33
-rw-r--r--Tests/Tutorial/Step7/CMakeLists.txt82
-rw-r--r--Tests/Tutorial/Step7/CTestConfig.cmake1
-rw-r--r--Tests/Tutorial/Step7/License.txt2
-rw-r--r--Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt24
-rw-r--r--Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx32
-rw-r--r--Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx40
-rw-r--r--Tests/Tutorial/Step7/TutorialConfig.h.in9
-rw-r--r--Tests/Tutorial/Step7/build1.cmake5
-rw-r--r--Tests/Tutorial/Step7/build2.cmake9
-rw-r--r--Tests/Tutorial/Step7/tutorial.cxx33
-rw-r--r--Tests/Unset/CMakeLists.txt9
-rw-r--r--Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt35
-rw-r--r--Tests/UseSWIG/BasicConfiguration.cmake83
-rw-r--r--Tests/UseSWIG/BasicCsharp/CMakeLists.txt21
-rw-r--r--Tests/UseSWIG/BasicPerl/CMakeLists.txt14
-rw-r--r--Tests/UseSWIG/BasicPython/CMakeLists.txt13
-rw-r--r--Tests/UseSWIG/CMakeLists.txt137
-rw-r--r--Tests/UseSWIG/LegacyConfiguration.cmake68
-rw-r--r--Tests/UseSWIG/LegacyPerl/CMakeLists.txt14
-rw-r--r--Tests/UseSWIG/LegacyPython/CMakeLists.txt13
-rw-r--r--Tests/UseSWIG/ModuleName/CMakeLists.txt42
-rw-r--r--Tests/UseSWIG/ModuleName/example.i9
-rw-r--r--Tests/UseSWIG/ModuleName/runme.py52
-rw-r--r--Tests/UseSWIG/ModuleVersion2/CMakeLists.txt56
-rw-r--r--Tests/UseSWIG/MultipleModules/CMakeLists.txt68
-rw-r--r--Tests/UseSWIG/MultiplePython/CMakeLists.txt59
-rw-r--r--Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt28
-rw-r--r--Tests/UseSWIG/SwigSrcFileExtension/my_add.i9
-rw-r--r--Tests/UseSWIG/SwigSrcFileExtension/my_sub.swg9
-rwxr-xr-xTests/UseSWIG/SwigSrcFileExtension/runme.py24
-rw-r--r--Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt45
-rw-r--r--Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i9
-rw-r--r--Tests/UseSWIG/example.cxx (renamed from Tests/SwigTest/example.cxx)0
-rw-r--r--Tests/UseSWIG/example.h (renamed from Tests/SwigTest/example.h)0
-rw-r--r--Tests/UseSWIG/example.i9
-rw-r--r--Tests/UseSWIG/runme.cs54
-rw-r--r--Tests/UseSWIG/runme.php4 (renamed from Tests/SwigTest/runme.php4)0
-rw-r--r--[-rwxr-xr-x]Tests/UseSWIG/runme.pike (renamed from Tests/SwigTest/runme.pike)0
-rw-r--r--Tests/UseSWIG/runme.pl56
-rw-r--r--Tests/UseSWIG/runme.py52
-rw-r--r--Tests/UseSWIG/runme.rb (renamed from Tests/SwigTest/runme.rb)0
-rw-r--r--Tests/UseSWIG/runme.tcl49
-rw-r--r--Tests/UseSWIG/runme2.tcl69
-rw-r--r--Tests/VSExternalInclude/CMakeLists.txt4
-rw-r--r--Tests/VSExternalInclude/Lib2/lib2.cpp1
-rw-r--r--Tests/VSGNUFortran/CMakeLists.txt5
-rw-r--r--Tests/VSGNUFortran/runtest.cmake.in2
-rw-r--r--Tests/VSMidl/src/main.cpp3
-rw-r--r--Tests/VSNASM/CMakeLists.txt12
-rw-r--r--Tests/VSNASM/bar.asm13
-rw-r--r--Tests/VSNASM/include/foo-proc.asm2
-rw-r--r--Tests/VSNASM/main.c3
-rw-r--r--Tests/VSNsightTegra/jni/second.c3
-rw-r--r--Tests/VSResource/CMakeLists.txt7
-rw-r--r--Tests/VSResource/main.cpp3
-rw-r--r--Tests/VSWinStorePhone/CMakeLists.txt18
-rw-r--r--Tests/VSWinStorePhone/CxxDLL/CMakeLists.txt3
-rw-r--r--Tests/VSWinStorePhone/CxxDLL/cxxdll.cpp8
-rw-r--r--Tests/VSWinStorePhone/CxxDLL/cxxdll.h5
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/.gitattributes1
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.pngbin3392 -> 2335 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.pngbin801 -> 488 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.pngbin329 -> 167 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.pngbin554 -> 265 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.pngbin2146 -> 909 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.pngbin429 -> 227 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.pngbin9930 -> 2953 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.pngbin9070 -> 2767 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.pngbin3674 -> 1397 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.pngbin4937 -> 893 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.pngbin3724 -> 516 bytes
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp6
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h2
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp8
-rw-r--r--Tests/VSWinStorePhone/Direct3DApp1/pch.h3
-rw-r--r--Tests/VSWinStorePhone/VerifyAppPackage.cmake34
-rw-r--r--Tests/VSWinStorePhone/WinRT/Batman.cpp14
-rw-r--r--Tests/VSWinStorePhone/WinRT/Batman.h12
-rw-r--r--Tests/VSWinStorePhone/WinRT/CMakeLists.txt13
-rw-r--r--Tests/VSXaml/App.xaml.cpp3
-rw-r--r--Tests/VSXaml/Assets/Logo.scale-100.pngbin801 -> 488 bytes
-rw-r--r--Tests/VSXaml/Assets/SmallLogo.scale-100.pngbin329 -> 167 bytes
-rw-r--r--Tests/VSXaml/Assets/SplashScreen.scale-100.pngbin2146 -> 909 bytes
-rw-r--r--Tests/VSXaml/Assets/StoreLogo.scale-100.pngbin429 -> 227 bytes
-rw-r--r--Tests/VSXaml/MainPage.xaml.cpp4
-rw-r--r--Tests/WarnUnusedCliUnused/CMakeLists.txt8
-rw-r--r--Tests/Wrapping/fakefluid.cxx7
-rw-r--r--Tests/Wrapping/qtwrappingmain.cxx4
-rw-r--r--Tests/X11/HelloWorldX11.cxx13
-rw-r--r--Tests/X11/X11.c4
-rw-r--r--Tests/XCTest/CMakeLists.txt2
-rw-r--r--Tests/bootstrap.bat.in4
-rw-r--r--Utilities/.gitattributes5
-rw-r--r--Utilities/Doxygen/CMakeLists.txt4
-rw-r--r--Utilities/GitSetup/config.sample32
-rwxr-xr-xUtilities/GitSetup/git-gerrit-push74
-rwxr-xr-xUtilities/GitSetup/git-gitlab-push177
-rwxr-xr-xUtilities/GitSetup/setup-gerrit147
-rwxr-xr-xUtilities/GitSetup/setup-gitlab140
-rwxr-xr-xUtilities/GitSetup/setup-hooks4
-rwxr-xr-xUtilities/GitSetup/setup-ssh111
-rwxr-xr-xUtilities/GitSetup/setup-stage82
-rwxr-xr-xUtilities/GitSetup/setup-upstream104
-rwxr-xr-xUtilities/GitSetup/tips4
-rw-r--r--Utilities/IWYU/mapping.imp67
-rw-r--r--Utilities/KWIML/Copyright.txt2
-rw-r--r--Utilities/KWIML/include/kwiml/abi.h19
-rw-r--r--Utilities/KWIML/include/kwiml/int.h15
-rw-r--r--Utilities/KWIML/src/version.h.in2
-rw-r--r--Utilities/KWIML/test/test_int_format.h9
-rw-r--r--Utilities/Release/CMakeLogo.icobin24542 -> 17542 bytes
-rw-r--r--Utilities/Release/README18
-rw-r--r--Utilities/Release/README.rst84
-rw-r--r--Utilities/Release/WiX/CustomAction/CMakeLists.txt18
-rw-r--r--Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp9
-rw-r--r--Utilities/Release/WiX/WIX.template.in2
-rw-r--r--Utilities/Release/create-cmake-release.cmake44
-rw-r--r--Utilities/Release/linux/x86_64/Dockerfile36
-rw-r--r--Utilities/Release/linux/x86_64/base/Dockerfile30
-rw-r--r--Utilities/Release/linux/x86_64/cache.txt44
-rw-r--r--Utilities/Release/linux/x86_64/deps/Dockerfile142
-rw-r--r--Utilities/Release/linux/x86_64/deps/openssl-source.patch12
-rw-r--r--Utilities/Release/linux/x86_64/deps/qt-install.patch24
-rw-r--r--Utilities/Release/linux/x86_64/test/Dockerfile26
-rw-r--r--Utilities/Release/linux/x86_64/test/cache-ninja.txt4
-rw-r--r--Utilities/Release/linux/x86_64/test/test-make.bash17
-rw-r--r--Utilities/Release/linux/x86_64/test/test-ninja.bash17
-rw-r--r--Utilities/Release/linux64_release.cmake50
-rw-r--r--Utilities/Release/osx_release.cmake5
-rwxr-xr-xUtilities/Release/push.bash70
-rwxr-xr-xUtilities/Release/release_cmake.sh.in2
-rw-r--r--Utilities/Release/upload_release.cmake39
-rw-r--r--Utilities/Release/win32_release.cmake43
-rw-r--r--Utilities/Release/win64_release.cmake38
-rw-r--r--Utilities/Scripts/BoostScanDeps.cmake41
-rwxr-xr-xUtilities/Scripts/clang-format.bash17
-rwxr-xr-xUtilities/Scripts/regenerate-lexers.bash53
-rwxr-xr-xUtilities/Scripts/regenerate-parsers.bash37
-rwxr-xr-xUtilities/Scripts/update-curl.bash12
-rwxr-xr-xUtilities/Scripts/update-expat.bash3
-rwxr-xr-xUtilities/Scripts/update-gitsetup.bash7
-rwxr-xr-xUtilities/Scripts/update-jsoncpp.bash33
-rwxr-xr-xUtilities/Scripts/update-libarchive.bash2
-rwxr-xr-xUtilities/Scripts/update-liblzma.bash8
-rwxr-xr-xUtilities/Scripts/update-libuv.bash2
-rw-r--r--Utilities/Scripts/update-third-party.bash24
-rwxr-xr-xUtilities/Scripts/update-zstd.bash36
-rw-r--r--Utilities/Sphinx/CMakeLists.txt36
-rw-r--r--Utilities/Sphinx/cmake.py65
-rw-r--r--Utilities/Sphinx/colors.py29
-rw-r--r--Utilities/Sphinx/conf.py.in4
-rwxr-xr-xUtilities/Sphinx/create_identifiers.py3
-rw-r--r--Utilities/Sphinx/fixup_qthelp_names.cmake9
-rw-r--r--Utilities/Sphinx/static/cmake-favicon.icobin1150 -> 1150 bytes
-rw-r--r--Utilities/Sphinx/static/cmake-logo-16.pngbin761 -> 692 bytes
-rw-r--r--Utilities/Sphinx/static/cmake.css10
-rw-r--r--Utilities/cmThirdParty.h.in2
-rw-r--r--Utilities/cm_bzlib.h4
-rw-r--r--Utilities/cm_curl.h4
-rw-r--r--Utilities/cm_expat.h4
-rw-r--r--Utilities/cm_jsoncpp_reader.h4
-rw-r--r--Utilities/cm_jsoncpp_value.h4
-rw-r--r--Utilities/cm_jsoncpp_writer.h4
-rw-r--r--Utilities/cm_kwiml.h8
-rw-r--r--Utilities/cm_libarchive.h8
-rw-r--r--Utilities/cm_lzma.h4
-rw-r--r--Utilities/cm_rhash.h4
-rw-r--r--Utilities/cm_uv.h4
-rw-r--r--Utilities/cm_xmlrpc.h13
-rw-r--r--Utilities/cm_zlib.h4
-rw-r--r--Utilities/cm_zstd.h14
-rw-r--r--Utilities/cmbzip2/dlltest.dsp93
-rw-r--r--Utilities/cmbzip2/libbz2.dsp130
-rw-r--r--Utilities/cmcompress/CMakeLists.txt5
-rw-r--r--Utilities/cmcompress/Copyright.txt34
-rw-r--r--Utilities/cmcompress/cmcompress.c551
-rw-r--r--Utilities/cmcompress/cmcompress.h195
-rw-r--r--Utilities/cmcompress/compress.c.original1308
-rw-r--r--Utilities/cmcurl/CMake/CMakeConfigurableFile.in1
-rw-r--r--Utilities/cmcurl/CMake/CurlSymbolHiding.cmake92
-rw-r--r--Utilities/cmcurl/CMake/CurlTests.c94
-rw-r--r--Utilities/cmcurl/CMake/FindBrotli.cmake20
-rw-r--r--Utilities/cmcurl/CMake/FindCARES.cmake38
-rw-r--r--Utilities/cmcurl/CMake/FindGSS.cmake410
-rw-r--r--Utilities/cmcurl/CMake/FindLibSSH2.cmake14
-rw-r--r--Utilities/cmcurl/CMake/FindNGHTTP2.cmake2
-rw-r--r--Utilities/cmcurl/CMake/Macros.cmake83
-rw-r--r--Utilities/cmcurl/CMake/OtherTests.cmake136
-rw-r--r--Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake7
-rw-r--r--Utilities/cmcurl/CMake/Utilities.cmake41
-rw-r--r--Utilities/cmcurl/CMake/cmake_uninstall.cmake.in26
-rw-r--r--Utilities/cmcurl/CMake/curl-config.cmake.in12
-rw-r--r--Utilities/cmcurl/CMakeLists.txt613
-rw-r--r--Utilities/cmcurl/COPYING2
-rw-r--r--Utilities/cmcurl/curltest.c184
-rw-r--r--Utilities/cmcurl/include/curl/curl.h400
-rw-r--r--Utilities/cmcurl/include/curl/curlbuild.h.cmake218
-rw-r--r--Utilities/cmcurl/include/curl/curlrules.h239
-rw-r--r--Utilities/cmcurl/include/curl/curlver.h14
-rw-r--r--Utilities/cmcurl/include/curl/easy.h10
-rw-r--r--Utilities/cmcurl/include/curl/multi.h8
-rw-r--r--Utilities/cmcurl/include/curl/system.h639
-rw-r--r--Utilities/cmcurl/include/curl/typecheck-gcc.h54
-rw-r--r--Utilities/cmcurl/include/curl/urlapi.h123
-rw-r--r--Utilities/cmcurl/lib/CMakeLists.txt47
-rw-r--r--Utilities/cmcurl/lib/Makefile.inc28
-rw-r--r--Utilities/cmcurl/lib/altsvc.c569
-rw-r--r--Utilities/cmcurl/lib/altsvc.h77
-rw-r--r--Utilities/cmcurl/lib/amigaos.c32
-rw-r--r--Utilities/cmcurl/lib/amigaos.h9
-rw-r--r--Utilities/cmcurl/lib/arpa_telnet.h6
-rw-r--r--Utilities/cmcurl/lib/asyn-ares.c222
-rw-r--r--Utilities/cmcurl/lib/asyn-thread.c197
-rw-r--r--Utilities/cmcurl/lib/asyn.h36
-rw-r--r--Utilities/cmcurl/lib/base64.c36
-rw-r--r--Utilities/cmcurl/lib/conncache.c363
-rw-r--r--Utilities/cmcurl/lib/conncache.h40
-rw-r--r--Utilities/cmcurl/lib/connect.c316
-rw-r--r--Utilities/cmcurl/lib/connect.h13
-rw-r--r--Utilities/cmcurl/lib/content_encoding.c857
-rw-r--r--Utilities/cmcurl/lib/content_encoding.h45
-rw-r--r--Utilities/cmcurl/lib/cookie.c658
-rw-r--r--Utilities/cmcurl/lib/cookie.h34
-rw-r--r--Utilities/cmcurl/lib/curl_addrinfo.c52
-rw-r--r--Utilities/cmcurl/lib/curl_addrinfo.h13
-rw-r--r--Utilities/cmcurl/lib/curl_config.h.cmake44
-rw-r--r--Utilities/cmcurl/lib/curl_ctype.c133
-rw-r--r--Utilities/cmcurl/lib/curl_ctype.h81
-rw-r--r--Utilities/cmcurl/lib/curl_endian.c10
-rw-r--r--Utilities/cmcurl/lib/curl_fnmatch.c373
-rw-r--r--Utilities/cmcurl/lib/curl_get_line.c55
-rw-r--r--Utilities/cmcurl/lib/curl_get_line.h29
-rw-r--r--Utilities/cmcurl/lib/curl_gssapi.c13
-rw-r--r--Utilities/cmcurl/lib/curl_gssapi.h16
-rw-r--r--Utilities/cmcurl/lib/curl_ldap.h1
-rw-r--r--Utilities/cmcurl/lib/curl_md4.h4
-rw-r--r--Utilities/cmcurl/lib/curl_md5.h10
-rw-r--r--Utilities/cmcurl/lib/curl_memory.h4
-rw-r--r--Utilities/cmcurl/lib/curl_memrchr.c19
-rw-r--r--Utilities/cmcurl/lib/curl_multibyte.c12
-rw-r--r--Utilities/cmcurl/lib/curl_ntlm_core.c176
-rw-r--r--Utilities/cmcurl/lib/curl_ntlm_core.h18
-rw-r--r--Utilities/cmcurl/lib/curl_ntlm_wb.c114
-rw-r--r--Utilities/cmcurl/lib/curl_ntlm_wb.h11
-rw-r--r--Utilities/cmcurl/lib/curl_path.c199
-rw-r--r--Utilities/cmcurl/lib/curl_path.h47
-rw-r--r--Utilities/cmcurl/lib/curl_printf.h16
-rw-r--r--Utilities/cmcurl/lib/curl_range.c95
-rw-r--r--Utilities/cmcurl/lib/curl_range.h30
-rw-r--r--Utilities/cmcurl/lib/curl_rtmp.c21
-rw-r--r--Utilities/cmcurl/lib/curl_sasl.c77
-rw-r--r--Utilities/cmcurl/lib/curl_setup.h146
-rw-r--r--Utilities/cmcurl/lib/curl_setup_once.h38
-rw-r--r--Utilities/cmcurl/lib/curl_sha256.h32
-rw-r--r--Utilities/cmcurl/lib/curl_sspi.c7
-rw-r--r--Utilities/cmcurl/lib/curl_threads.c24
-rw-r--r--Utilities/cmcurl/lib/curl_threads.h3
-rw-r--r--Utilities/cmcurl/lib/curlx.h22
-rw-r--r--Utilities/cmcurl/lib/dict.c32
-rw-r--r--Utilities/cmcurl/lib/doh.c967
-rw-r--r--Utilities/cmcurl/lib/doh.h113
-rw-r--r--Utilities/cmcurl/lib/dotdot.c32
-rw-r--r--Utilities/cmcurl/lib/dotdot.h2
-rw-r--r--Utilities/cmcurl/lib/easy.c326
-rw-r--r--Utilities/cmcurl/lib/easyif.h1
-rw-r--r--Utilities/cmcurl/lib/escape.c50
-rw-r--r--Utilities/cmcurl/lib/escape.h4
-rw-r--r--Utilities/cmcurl/lib/file.c142
-rw-r--r--Utilities/cmcurl/lib/file.h1
-rw-r--r--Utilities/cmcurl/lib/fileinfo.c10
-rw-r--r--Utilities/cmcurl/lib/fileinfo.h5
-rw-r--r--Utilities/cmcurl/lib/formdata.c967
-rw-r--r--Utilities/cmcurl/lib/formdata.h57
-rw-r--r--Utilities/cmcurl/lib/ftp.c631
-rw-r--r--Utilities/cmcurl/lib/ftp.h9
-rw-r--r--Utilities/cmcurl/lib/ftplistparser.c249
-rw-r--r--Utilities/cmcurl/lib/getinfo.c126
-rw-r--r--Utilities/cmcurl/lib/gopher.c46
-rw-r--r--Utilities/cmcurl/lib/hash.c21
-rw-r--r--Utilities/cmcurl/lib/hmac.c4
-rw-r--r--Utilities/cmcurl/lib/hostasyn.c43
-rw-r--r--Utilities/cmcurl/lib/hostcheck.c28
-rw-r--r--Utilities/cmcurl/lib/hostcheck.h1
-rw-r--r--Utilities/cmcurl/lib/hostip.c464
-rw-r--r--Utilities/cmcurl/lib/hostip.h23
-rw-r--r--Utilities/cmcurl/lib/hostip4.c15
-rw-r--r--Utilities/cmcurl/lib/hostip6.c59
-rw-r--r--Utilities/cmcurl/lib/hostsyn.c10
-rw-r--r--Utilities/cmcurl/lib/http.c1575
-rw-r--r--Utilities/cmcurl/lib/http.h56
-rw-r--r--Utilities/cmcurl/lib/http2.c723
-rw-r--r--Utilities/cmcurl/lib/http2.h15
-rw-r--r--Utilities/cmcurl/lib/http_chunks.c86
-rw-r--r--Utilities/cmcurl/lib/http_chunks.h1
-rw-r--r--Utilities/cmcurl/lib/http_digest.c5
-rw-r--r--Utilities/cmcurl/lib/http_digest.h12
-rw-r--r--Utilities/cmcurl/lib/http_negotiate.c134
-rw-r--r--Utilities/cmcurl/lib/http_negotiate.h8
-rw-r--r--Utilities/cmcurl/lib/http_ntlm.c63
-rw-r--r--Utilities/cmcurl/lib/http_ntlm.h10
-rw-r--r--Utilities/cmcurl/lib/http_proxy.c321
-rw-r--r--Utilities/cmcurl/lib/http_proxy.h10
-rw-r--r--Utilities/cmcurl/lib/if2ip.c69
-rw-r--r--Utilities/cmcurl/lib/if2ip.h9
-rw-r--r--Utilities/cmcurl/lib/imap.c394
-rw-r--r--Utilities/cmcurl/lib/imap.h4
-rw-r--r--Utilities/cmcurl/lib/inet_ntop.c28
-rw-r--r--Utilities/cmcurl/lib/inet_ntop.h1
-rw-r--r--Utilities/cmcurl/lib/inet_pton.c9
-rw-r--r--Utilities/cmcurl/lib/inet_pton.h6
-rw-r--r--Utilities/cmcurl/lib/krb5.c17
-rw-r--r--Utilities/cmcurl/lib/ldap.c56
-rw-r--r--Utilities/cmcurl/lib/libcurl.rc12
-rw-r--r--Utilities/cmcurl/lib/llist.c6
-rw-r--r--Utilities/cmcurl/lib/llist.h1
-rw-r--r--Utilities/cmcurl/lib/md4.c116
-rw-r--r--Utilities/cmcurl/lib/md5.c211
-rw-r--r--Utilities/cmcurl/lib/memdebug.c185
-rw-r--r--Utilities/cmcurl/lib/memdebug.h121
-rw-r--r--Utilities/cmcurl/lib/mime.c1904
-rw-r--r--Utilities/cmcurl/lib/mime.h164
-rw-r--r--Utilities/cmcurl/lib/mprintf.c40
-rw-r--r--Utilities/cmcurl/lib/multi.c1547
-rw-r--r--Utilities/cmcurl/lib/multihandle.h61
-rw-r--r--Utilities/cmcurl/lib/multiif.h38
-rw-r--r--Utilities/cmcurl/lib/netrc.c108
-rw-r--r--Utilities/cmcurl/lib/netrc.h11
-rw-r--r--Utilities/cmcurl/lib/non-ascii.c124
-rw-r--r--Utilities/cmcurl/lib/non-ascii.h4
-rw-r--r--Utilities/cmcurl/lib/nonblock.c3
-rw-r--r--Utilities/cmcurl/lib/nonblock.h1
-rw-r--r--Utilities/cmcurl/lib/nwlib.c11
-rw-r--r--Utilities/cmcurl/lib/openldap.c117
-rw-r--r--Utilities/cmcurl/lib/parsedate.c214
-rw-r--r--Utilities/cmcurl/lib/parsedate.h1
-rw-r--r--Utilities/cmcurl/lib/pingpong.c73
-rw-r--r--Utilities/cmcurl/lib/pingpong.h11
-rw-r--r--Utilities/cmcurl/lib/pipeline.c410
-rw-r--r--Utilities/cmcurl/lib/pipeline.h56
-rw-r--r--Utilities/cmcurl/lib/pop3.c155
-rw-r--r--Utilities/cmcurl/lib/progress.c406
-rw-r--r--Utilities/cmcurl/lib/progress.h29
-rw-r--r--Utilities/cmcurl/lib/psl.c111
-rw-r--r--Utilities/cmcurl/lib/psl.h47
-rw-r--r--Utilities/cmcurl/lib/rand.c12
-rw-r--r--Utilities/cmcurl/lib/rand.h7
-rw-r--r--Utilities/cmcurl/lib/rtsp.c132
-rw-r--r--Utilities/cmcurl/lib/rtsp.h3
-rw-r--r--Utilities/cmcurl/lib/security.c35
-rw-r--r--Utilities/cmcurl/lib/select.c30
-rw-r--r--Utilities/cmcurl/lib/select.h6
-rw-r--r--Utilities/cmcurl/lib/sendf.c230
-rw-r--r--Utilities/cmcurl/lib/sendf.h11
-rw-r--r--Utilities/cmcurl/lib/setopt.c2777
-rw-r--r--Utilities/cmcurl/lib/setopt.h29
-rw-r--r--Utilities/cmcurl/lib/sha256.c267
-rw-r--r--Utilities/cmcurl/lib/share.c15
-rw-r--r--Utilities/cmcurl/lib/share.h9
-rw-r--r--Utilities/cmcurl/lib/sigpipe.h5
-rw-r--r--Utilities/cmcurl/lib/slist.c1
-rw-r--r--Utilities/cmcurl/lib/slist.h1
-rw-r--r--Utilities/cmcurl/lib/smb.c160
-rw-r--r--Utilities/cmcurl/lib/smb.h34
-rw-r--r--Utilities/cmcurl/lib/smtp.c209
-rw-r--r--Utilities/cmcurl/lib/sockaddr.h1
-rw-r--r--Utilities/cmcurl/lib/socks.c127
-rw-r--r--Utilities/cmcurl/lib/socks.h1
-rw-r--r--Utilities/cmcurl/lib/socks_gssapi.c61
-rw-r--r--Utilities/cmcurl/lib/socks_sspi.c31
-rw-r--r--Utilities/cmcurl/lib/speedcheck.c6
-rw-r--r--Utilities/cmcurl/lib/speedcheck.h4
-rw-r--r--Utilities/cmcurl/lib/splay.c32
-rw-r--r--Utilities/cmcurl/lib/splay.h17
-rw-r--r--Utilities/cmcurl/lib/ssh-libssh.c2740
-rw-r--r--Utilities/cmcurl/lib/ssh.c494
-rw-r--r--Utilities/cmcurl/lib/ssh.h73
-rw-r--r--Utilities/cmcurl/lib/strcase.c11
-rw-r--r--Utilities/cmcurl/lib/strcase.h1
-rw-r--r--Utilities/cmcurl/lib/strdup.c8
-rw-r--r--Utilities/cmcurl/lib/strerror.c114
-rw-r--r--Utilities/cmcurl/lib/strerror.h11
-rw-r--r--Utilities/cmcurl/lib/strtoofft.c68
-rw-r--r--Utilities/cmcurl/lib/strtoofft.h39
-rw-r--r--Utilities/cmcurl/lib/system_win32.c97
-rw-r--r--Utilities/cmcurl/lib/system_win32.h6
-rw-r--r--Utilities/cmcurl/lib/telnet.c151
-rw-r--r--Utilities/cmcurl/lib/telnet.h1
-rw-r--r--Utilities/cmcurl/lib/tftp.c146
-rw-r--r--Utilities/cmcurl/lib/tftp.h1
-rw-r--r--Utilities/cmcurl/lib/timeval.c174
-rw-r--r--Utilities/cmcurl/lib/timeval.h38
-rw-r--r--Utilities/cmcurl/lib/transfer.c906
-rw-r--r--Utilities/cmcurl/lib/transfer.h29
-rw-r--r--Utilities/cmcurl/lib/url.c4870
-rw-r--r--Utilities/cmcurl/lib/url.h52
-rw-r--r--Utilities/cmcurl/lib/urlapi-int.h37
-rw-r--r--Utilities/cmcurl/lib/urlapi.c1440
-rw-r--r--Utilities/cmcurl/lib/urldata.h1065
-rw-r--r--Utilities/cmcurl/lib/vauth/cleartext.c48
-rw-r--r--Utilities/cmcurl/lib/vauth/cram.c2
-rw-r--r--Utilities/cmcurl/lib/vauth/digest.c217
-rw-r--r--Utilities/cmcurl/lib/vauth/digest.h6
-rw-r--r--Utilities/cmcurl/lib/vauth/digest_sspi.c53
-rw-r--r--Utilities/cmcurl/lib/vauth/krb5_gssapi.c8
-rw-r--r--Utilities/cmcurl/lib/vauth/krb5_sspi.c18
-rw-r--r--Utilities/cmcurl/lib/vauth/ntlm.c295
-rw-r--r--Utilities/cmcurl/lib/vauth/ntlm.h8
-rw-r--r--Utilities/cmcurl/lib/vauth/ntlm_sspi.c82
-rw-r--r--Utilities/cmcurl/lib/vauth/oauth2.c56
-rw-r--r--Utilities/cmcurl/lib/vauth/spnego_gssapi.c20
-rw-r--r--Utilities/cmcurl/lib/vauth/spnego_sspi.c70
-rw-r--r--Utilities/cmcurl/lib/vauth/vauth.c44
-rw-r--r--Utilities/cmcurl/lib/vauth/vauth.h25
-rw-r--r--Utilities/cmcurl/lib/version.c114
-rw-r--r--Utilities/cmcurl/lib/vtls/axtls.c706
-rw-r--r--Utilities/cmcurl/lib/vtls/axtls.h71
-rw-r--r--Utilities/cmcurl/lib/vtls/cyassl.c274
-rw-r--r--Utilities/cmcurl/lib/vtls/cyassl.h63
-rw-r--r--Utilities/cmcurl/lib/vtls/darwinssl.c2847
-rw-r--r--Utilities/cmcurl/lib/vtls/darwinssl.h100
-rw-r--r--Utilities/cmcurl/lib/vtls/gskit.c244
-rw-r--r--Utilities/cmcurl/lib/vtls/gskit.h38
-rw-r--r--Utilities/cmcurl/lib/vtls/gtls.c403
-rw-r--r--Utilities/cmcurl/lib/vtls/gtls.h64
-rw-r--r--Utilities/cmcurl/lib/vtls/mbedtls.c286
-rw-r--r--Utilities/cmcurl/lib/vtls/mbedtls.h52
-rw-r--r--Utilities/cmcurl/lib/vtls/mesalink.c627
-rw-r--r--Utilities/cmcurl/lib/vtls/mesalink.h32
-rw-r--r--Utilities/cmcurl/lib/vtls/nss.c368
-rw-r--r--Utilities/cmcurl/lib/vtls/nssg.h71
-rw-r--r--Utilities/cmcurl/lib/vtls/openssl.c1270
-rw-r--r--Utilities/cmcurl/lib/vtls/openssl.h91
-rw-r--r--Utilities/cmcurl/lib/vtls/polarssl.c212
-rw-r--r--Utilities/cmcurl/lib/vtls/polarssl.h52
-rw-r--r--Utilities/cmcurl/lib/vtls/polarssl_threadlock.c63
-rw-r--r--Utilities/cmcurl/lib/vtls/polarssl_threadlock.h9
-rw-r--r--Utilities/cmcurl/lib/vtls/schannel.c1474
-rw-r--r--Utilities/cmcurl/lib/vtls/schannel.h145
-rw-r--r--Utilities/cmcurl/lib/vtls/schannel_verify.c572
-rw-r--r--Utilities/cmcurl/lib/vtls/sectransp.c3264
-rw-r--r--Utilities/cmcurl/lib/vtls/sectransp.h32
-rw-r--r--Utilities/cmcurl/lib/vtls/vtls.c564
-rw-r--r--Utilities/cmcurl/lib/vtls/vtls.h92
-rw-r--r--Utilities/cmcurl/lib/warnless.c70
-rw-r--r--Utilities/cmcurl/lib/warnless.h9
-rw-r--r--Utilities/cmcurl/lib/wildcard.c24
-rw-r--r--Utilities/cmcurl/lib/wildcard.h16
-rw-r--r--Utilities/cmcurl/lib/x509asn1.c515
-rw-r--r--Utilities/cmexpat/CMakeLists.txt3
-rw-r--r--Utilities/cmexpat/ConfigureChecks.cmake36
-rw-r--r--Utilities/cmexpat/README.md116
-rw-r--r--Utilities/cmexpat/expat_config.h.cmake30
-rw-r--r--Utilities/cmexpat/lib/ascii.h32
-rw-r--r--Utilities/cmexpat/lib/asciitab.h94
-rw-r--r--Utilities/cmexpat/lib/expat.h309
-rw-r--r--Utilities/cmexpat/lib/expat_external.h117
-rw-r--r--Utilities/cmexpat/lib/iasciitab.h94
-rw-r--r--Utilities/cmexpat/lib/internal.h76
-rw-r--r--Utilities/cmexpat/lib/latin1tab.h94
-rw-r--r--Utilities/cmexpat/lib/loadlibrary.c141
-rw-r--r--Utilities/cmexpat/lib/nametab.h274
-rw-r--r--Utilities/cmexpat/lib/siphash.h430
-rw-r--r--Utilities/cmexpat/lib/utf8tab.h95
-rw-r--r--Utilities/cmexpat/lib/winconfig.h57
-rw-r--r--Utilities/cmexpat/lib/xmlparse.c5688
-rw-r--r--Utilities/cmexpat/lib/xmlrole.c779
-rw-r--r--Utilities/cmexpat/lib/xmlrole.h45
-rw-r--r--Utilities/cmexpat/lib/xmltok.c1446
-rw-r--r--Utilities/cmexpat/lib/xmltok.h249
-rw-r--r--Utilities/cmexpat/lib/xmltok_impl.c1098
-rw-r--r--Utilities/cmexpat/lib/xmltok_impl.h103
-rw-r--r--Utilities/cmexpat/lib/xmltok_ns.c117
-rw-r--r--Utilities/cmjsoncpp/CMakeLists.txt4
-rw-r--r--Utilities/cmjsoncpp/LICENSE8
-rw-r--r--Utilities/cmjsoncpp/include/json/allocator.h102
-rw-r--r--Utilities/cmjsoncpp/include/json/assertions.h41
-rw-r--r--Utilities/cmjsoncpp/include/json/config.h135
-rw-r--r--Utilities/cmjsoncpp/include/json/features.h10
-rw-r--r--Utilities/cmjsoncpp/include/json/forwards.h8
-rw-r--r--Utilities/cmjsoncpp/include/json/json.h2
-rw-r--r--Utilities/cmjsoncpp/include/json/reader.h181
-rw-r--r--Utilities/cmjsoncpp/include/json/value.h723
-rw-r--r--Utilities/cmjsoncpp/include/json/version.h16
-rw-r--r--Utilities/cmjsoncpp/include/json/writer.h205
-rw-r--r--Utilities/cmjsoncpp/src/lib_json/json_batchallocator.h121
-rw-r--r--Utilities/cmjsoncpp/src/lib_json/json_internalarray.inl360
-rw-r--r--Utilities/cmjsoncpp/src/lib_json/json_internalmap.inl473
-rw-r--r--Utilities/cmjsoncpp/src/lib_json/json_reader.cpp1436
-rw-r--r--Utilities/cmjsoncpp/src/lib_json/json_tool.h44
-rw-r--r--Utilities/cmjsoncpp/src/lib_json/json_value.cpp892
-rw-r--r--Utilities/cmjsoncpp/src/lib_json/json_valueiterator.inl138
-rw-r--r--Utilities/cmjsoncpp/src/lib_json/json_writer.cpp826
-rw-r--r--Utilities/cmlibarchive/CMakeLists.txt458
-rw-r--r--Utilities/cmlibarchive/build/cmake/config.h.in102
-rw-r--r--Utilities/cmlibarchive/build/pkgconfig/libarchive.pc.in1
-rw-r--r--Utilities/cmlibarchive/build/version2
-rw-r--r--Utilities/cmlibarchive/libarchive/CMakeLists.txt17
-rw-r--r--Utilities/cmlibarchive/libarchive/archive.h8
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_acl.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_check_magic.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_cmdline.c6
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_cryptor.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_cryptor_private.h2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_disk_acl_darwin.c559
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_disk_acl_freebsd.c702
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_disk_acl_linux.c743
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_disk_acl_sunos.c821
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_entry.32
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_entry.c35
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_entry.h3
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_entry_acl.310
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_entry_paths.312
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_entry_perms.34
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_entry_sparse.c4
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_getdate.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_match.c4
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h3
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_pack_dev.c5
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_platform.h43
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_platform_acl.h49
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_platform_xattr.h41
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_ppmd7.c10
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_ppmd7_private.h4
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_ppmd_private.h7
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_random.c3
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read.c15
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_append_filter.c4
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_disk.372
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c1285
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c8
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_disk_private.h9
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c19
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_filter.36
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_format.36
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_open.34
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_filter_all.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c6
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_filter_zstd.c292
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c21
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c156
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c9
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c34
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c8
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c289
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c32
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c28
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_warc.c9
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c32
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c71
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_string.c6
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_string_sprintf.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_util.c92
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_version_details.c151
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_virtual.c11
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write.32
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_add_filter.c3
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_add_filter_b64encode.c10
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_add_filter_by_name.c3
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_add_filter_gzip.c7
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_add_filter_lz4.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_add_filter_program.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_add_filter_zstd.c335
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_data.324
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_disk.3185
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_disk_acl.c654
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c308
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_disk_private.h6
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c19
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_filter.36
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_finish_entry.35
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_format.31
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c17
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format_ar.c17
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format_filter_by_ext.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c17
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format_warc.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/config_freebsd.h351
-rw-r--r--Utilities/cmlibarchive/libarchive/libarchive_changes.31
-rw-r--r--Utilities/cmlibarchive/libarchive/mtree.52
-rw-r--r--Utilities/cmlibarchive/libarchive/xxhash.c12
-rw-r--r--Utilities/cmliblzma/CMakeLists.txt20
-rw-r--r--Utilities/cmliblzma/COPYING2
-rw-r--r--Utilities/cmliblzma/common/common_w32res.rc2
-rw-r--r--Utilities/cmliblzma/common/sysdefs.h15
-rw-r--r--Utilities/cmliblzma/common/tuklib_integer.h35
-rw-r--r--Utilities/cmliblzma/config.h.in28
-rw-r--r--Utilities/cmliblzma/liblzma/api/lzma.h26
-rw-r--r--Utilities/cmliblzma/liblzma/api/lzma/base.h88
-rw-r--r--Utilities/cmliblzma/liblzma/api/lzma/block.h74
-rw-r--r--Utilities/cmliblzma/liblzma/api/lzma/container.h222
-rw-r--r--Utilities/cmliblzma/liblzma/api/lzma/filter.h13
-rw-r--r--Utilities/cmliblzma/liblzma/api/lzma/hardware.h14
-rw-r--r--Utilities/cmliblzma/liblzma/api/lzma/index.h34
-rw-r--r--Utilities/cmliblzma/liblzma/api/lzma/index_hash.h4
-rw-r--r--Utilities/cmliblzma/liblzma/api/lzma/lzma.h420
-rw-r--r--Utilities/cmliblzma/liblzma/api/lzma/lzma12.h420
-rw-r--r--Utilities/cmliblzma/liblzma/api/lzma/version.h4
-rw-r--r--Utilities/cmliblzma/liblzma/check/check.c12
-rw-r--r--Utilities/cmliblzma/liblzma/check/check.h93
-rw-r--r--Utilities/cmliblzma/liblzma/check/crc32_fast.c8
-rw-r--r--Utilities/cmliblzma/liblzma/check/crc64_fast.c4
-rw-r--r--Utilities/cmliblzma/liblzma/check/sha256.c68
-rw-r--r--Utilities/cmliblzma/liblzma/common/alone_decoder.c73
-rw-r--r--Utilities/cmliblzma/liblzma/common/alone_decoder.h2
-rw-r--r--Utilities/cmliblzma/liblzma/common/alone_encoder.c68
-rw-r--r--Utilities/cmliblzma/liblzma/common/auto_decoder.c51
-rw-r--r--Utilities/cmliblzma/liblzma/common/block_buffer_decoder.c10
-rw-r--r--Utilities/cmliblzma/liblzma/common/block_buffer_encoder.c134
-rw-r--r--Utilities/cmliblzma/liblzma/common/block_buffer_encoder.h24
-rw-r--r--Utilities/cmliblzma/liblzma/common/block_decoder.c67
-rw-r--r--Utilities/cmliblzma/liblzma/common/block_decoder.h2
-rw-r--r--Utilities/cmliblzma/liblzma/common/block_encoder.c52
-rw-r--r--Utilities/cmliblzma/liblzma/common/block_encoder.h2
-rw-r--r--Utilities/cmliblzma/liblzma/common/block_header_decoder.c37
-rw-r--r--Utilities/cmliblzma/liblzma/common/block_header_encoder.c19
-rw-r--r--Utilities/cmliblzma/liblzma/common/block_util.c13
-rw-r--r--Utilities/cmliblzma/liblzma/common/common.c103
-rw-r--r--Utilities/cmliblzma/liblzma/common/common.h138
-rw-r--r--Utilities/cmliblzma/liblzma/common/easy_buffer_encoder.c4
-rw-r--r--Utilities/cmliblzma/liblzma/common/easy_encoder.c1
-rw-r--r--Utilities/cmliblzma/liblzma/common/filter_buffer_decoder.c15
-rw-r--r--Utilities/cmliblzma/liblzma/common/filter_buffer_encoder.c18
-rw-r--r--Utilities/cmliblzma/liblzma/common/filter_common.c129
-rw-r--r--Utilities/cmliblzma/liblzma/common/filter_common.h2
-rw-r--r--Utilities/cmliblzma/liblzma/common/filter_decoder.c87
-rw-r--r--Utilities/cmliblzma/liblzma/common/filter_decoder.h2
-rw-r--r--Utilities/cmliblzma/liblzma/common/filter_encoder.c163
-rw-r--r--Utilities/cmliblzma/liblzma/common/filter_encoder.h6
-rw-r--r--Utilities/cmliblzma/liblzma/common/filter_flags_decoder.c8
-rw-r--r--Utilities/cmliblzma/liblzma/common/filter_flags_encoder.c3
-rw-r--r--Utilities/cmliblzma/liblzma/common/hardware_cputhreads.c22
-rw-r--r--Utilities/cmliblzma/liblzma/common/index.c166
-rw-r--r--Utilities/cmliblzma/liblzma/common/index_decoder.c63
-rw-r--r--Utilities/cmliblzma/liblzma/common/index_encoder.c35
-rw-r--r--Utilities/cmliblzma/liblzma/common/index_encoder.h2
-rw-r--r--Utilities/cmliblzma/liblzma/common/index_hash.c16
-rw-r--r--Utilities/cmliblzma/liblzma/common/memcmplen.h175
-rw-r--r--Utilities/cmliblzma/liblzma/common/outqueue.c184
-rw-r--r--Utilities/cmliblzma/liblzma/common/outqueue.h156
-rw-r--r--Utilities/cmliblzma/liblzma/common/stream_buffer_decoder.c8
-rw-r--r--Utilities/cmliblzma/liblzma/common/stream_buffer_encoder.c25
-rw-r--r--Utilities/cmliblzma/liblzma/common/stream_decoder.c102
-rw-r--r--Utilities/cmliblzma/liblzma/common/stream_decoder.h5
-rw-r--r--Utilities/cmliblzma/liblzma/common/stream_encoder.c108
-rw-r--r--Utilities/cmliblzma/liblzma/common/stream_encoder.h23
-rw-r--r--Utilities/cmliblzma/liblzma/common/stream_encoder_mt.c1143
-rw-r--r--Utilities/cmliblzma/liblzma/common/stream_flags_decoder.c8
-rw-r--r--Utilities/cmliblzma/liblzma/common/stream_flags_encoder.c8
-rw-r--r--Utilities/cmliblzma/liblzma/common/vli_decoder.c4
-rw-r--r--Utilities/cmliblzma/liblzma/common/vli_encoder.c2
-rw-r--r--Utilities/cmliblzma/liblzma/common/vli_size.c3
-rw-r--r--Utilities/cmliblzma/liblzma/delta/delta_common.c31
-rw-r--r--Utilities/cmliblzma/liblzma/delta/delta_decoder.c29
-rw-r--r--Utilities/cmliblzma/liblzma/delta/delta_decoder.h5
-rw-r--r--Utilities/cmliblzma/liblzma/delta/delta_encoder.c31
-rw-r--r--Utilities/cmliblzma/liblzma/delta/delta_encoder.h3
-rw-r--r--Utilities/cmliblzma/liblzma/delta/delta_private.h6
-rw-r--r--Utilities/cmliblzma/liblzma/liblzma.pc.in2
-rw-r--r--Utilities/cmliblzma/liblzma/lz/lz_decoder.c97
-rw-r--r--Utilities/cmliblzma/liblzma/lz/lz_decoder.h52
-rw-r--r--Utilities/cmliblzma/liblzma/lz/lz_encoder.c224
-rw-r--r--Utilities/cmliblzma/liblzma/lz/lz_encoder.h21
-rw-r--r--Utilities/cmliblzma/liblzma/lz/lz_encoder_hash.h21
-rw-r--r--Utilities/cmliblzma/liblzma/lz/lz_encoder_mf.c230
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/fastpos.h57
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/lzma2_decoder.c49
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/lzma2_decoder.h5
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/lzma2_encoder.c85
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/lzma2_encoder.h4
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/lzma_common.h54
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/lzma_decoder.c253
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/lzma_decoder.h7
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/lzma_encoder.c150
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/lzma_encoder.h16
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_fast.c49
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_normal.c340
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/lzma_encoder_presets.c8
-rw-r--r--Utilities/cmliblzma/liblzma/lzma/lzma_encoder_private.h28
-rw-r--r--Utilities/cmliblzma/liblzma/rangecoder/range_common.h7
-rw-r--r--Utilities/cmliblzma/liblzma/rangecoder/range_decoder.h16
-rw-r--r--Utilities/cmliblzma/liblzma/rangecoder/range_encoder.h3
-rw-r--r--Utilities/cmliblzma/liblzma/simple/arm.c12
-rw-r--r--Utilities/cmliblzma/liblzma/simple/armthumb.c12
-rw-r--r--Utilities/cmliblzma/liblzma/simple/ia64.c32
-rw-r--r--Utilities/cmliblzma/liblzma/simple/powerpc.c10
-rw-r--r--Utilities/cmliblzma/liblzma/simple/simple_coder.c91
-rw-r--r--Utilities/cmliblzma/liblzma/simple/simple_coder.h36
-rw-r--r--Utilities/cmliblzma/liblzma/simple/simple_decoder.c7
-rw-r--r--Utilities/cmliblzma/liblzma/simple/simple_decoder.h2
-rw-r--r--Utilities/cmliblzma/liblzma/simple/simple_private.h15
-rw-r--r--Utilities/cmliblzma/liblzma/simple/sparc.c13
-rw-r--r--Utilities/cmliblzma/liblzma/simple/x86.c44
-rw-r--r--Utilities/cmlibrhash/CMakeLists.txt2
-rw-r--r--Utilities/cmlibrhash/librhash/rhash.c2
-rw-r--r--Utilities/cmlibuv/CMakeLists.txt77
-rw-r--r--Utilities/cmlibuv/LICENSE4
-rw-r--r--Utilities/cmlibuv/include/pthread-barrier.h68
-rw-r--r--Utilities/cmlibuv/include/uv-errno.h419
-rw-r--r--Utilities/cmlibuv/include/uv-os390.h30
-rw-r--r--Utilities/cmlibuv/include/uv-unix.h368
-rw-r--r--Utilities/cmlibuv/include/uv-version.h43
-rw-r--r--Utilities/cmlibuv/include/uv-win.h661
-rw-r--r--Utilities/cmlibuv/include/uv.h246
-rw-r--r--Utilities/cmlibuv/include/uv/aix.h (renamed from Utilities/cmlibuv/include/uv-aix.h)0
-rw-r--r--Utilities/cmlibuv/include/uv/android-ifaddrs.h (renamed from Utilities/cmlibuv/include/android-ifaddrs.h)0
-rw-r--r--Utilities/cmlibuv/include/uv/bsd.h (renamed from Utilities/cmlibuv/include/uv-bsd.h)0
-rw-r--r--Utilities/cmlibuv/include/uv/darwin.h (renamed from Utilities/cmlibuv/include/uv-darwin.h)0
-rw-r--r--Utilities/cmlibuv/include/uv/errno.h443
-rw-r--r--Utilities/cmlibuv/include/uv/linux.h (renamed from Utilities/cmlibuv/include/uv-linux.h)0
-rw-r--r--Utilities/cmlibuv/include/uv/os390.h33
-rw-r--r--Utilities/cmlibuv/include/uv/posix.h (renamed from Utilities/cmlibuv/include/uv-posix.h)0
-rw-r--r--Utilities/cmlibuv/include/uv/stdint-msvc2008.h (renamed from Utilities/cmlibuv/include/stdint-msvc2008.h)0
-rw-r--r--Utilities/cmlibuv/include/uv/sunos.h (renamed from Utilities/cmlibuv/include/uv-sunos.h)0
-rw-r--r--Utilities/cmlibuv/include/uv/threadpool.h (renamed from Utilities/cmlibuv/include/uv-threadpool.h)0
-rw-r--r--Utilities/cmlibuv/include/uv/tree.h (renamed from Utilities/cmlibuv/include/tree.h)0
-rw-r--r--Utilities/cmlibuv/include/uv/unix.h506
-rw-r--r--Utilities/cmlibuv/include/uv/version.h43
-rw-r--r--Utilities/cmlibuv/include/uv/win.h701
-rw-r--r--Utilities/cmlibuv/src/fs-poll.c67
-rw-r--r--Utilities/cmlibuv/src/idna.c291
-rw-r--r--Utilities/cmlibuv/src/idna.h31
-rw-r--r--Utilities/cmlibuv/src/inet.c13
-rw-r--r--Utilities/cmlibuv/src/strscpy.c17
-rw-r--r--Utilities/cmlibuv/src/strscpy.h18
-rw-r--r--Utilities/cmlibuv/src/threadpool.c116
-rw-r--r--Utilities/cmlibuv/src/timer.c181
-rw-r--r--Utilities/cmlibuv/src/unix/aix-common.c298
-rw-r--r--Utilities/cmlibuv/src/unix/aix.c355
-rw-r--r--Utilities/cmlibuv/src/unix/android-ifaddrs.c51
-rw-r--r--Utilities/cmlibuv/src/unix/async.c45
-rw-r--r--Utilities/cmlibuv/src/unix/atomic-ops.h40
-rw-r--r--Utilities/cmlibuv/src/unix/bsd-ifaddrs.c50
-rw-r--r--Utilities/cmlibuv/src/unix/bsd-proctitle.c93
-rw-r--r--Utilities/cmlibuv/src/unix/cmake-bootstrap.c149
-rw-r--r--Utilities/cmlibuv/src/unix/core.c396
-rw-r--r--Utilities/cmlibuv/src/unix/cygwin.c4
-rw-r--r--Utilities/cmlibuv/src/unix/darwin-proctitle.c150
-rw-r--r--Utilities/cmlibuv/src/unix/darwin.c29
-rw-r--r--Utilities/cmlibuv/src/unix/freebsd.c139
-rw-r--r--Utilities/cmlibuv/src/unix/fs.c779
-rw-r--r--Utilities/cmlibuv/src/unix/fsevents.c95
-rw-r--r--Utilities/cmlibuv/src/unix/getaddrinfo.c61
-rw-r--r--Utilities/cmlibuv/src/unix/getnameinfo.c3
-rw-r--r--Utilities/cmlibuv/src/unix/haiku.c176
-rw-r--r--Utilities/cmlibuv/src/unix/hpux.c30
-rw-r--r--Utilities/cmlibuv/src/unix/ibmi.c250
-rw-r--r--Utilities/cmlibuv/src/unix/internal.h98
-rw-r--r--Utilities/cmlibuv/src/unix/kqueue.c137
-rw-r--r--Utilities/cmlibuv/src/unix/linux-core.c317
-rw-r--r--Utilities/cmlibuv/src/unix/linux-inotify.c18
-rw-r--r--Utilities/cmlibuv/src/unix/linux-syscalls.c164
-rw-r--r--Utilities/cmlibuv/src/unix/linux-syscalls.h65
-rw-r--r--Utilities/cmlibuv/src/unix/loop-watcher.c2
-rw-r--r--Utilities/cmlibuv/src/unix/loop.c11
-rw-r--r--Utilities/cmlibuv/src/unix/netbsd.c87
-rw-r--r--Utilities/cmlibuv/src/unix/no-fsevents.c6
-rw-r--r--Utilities/cmlibuv/src/unix/no-proctitle.c2
-rw-r--r--Utilities/cmlibuv/src/unix/openbsd.c65
-rw-r--r--Utilities/cmlibuv/src/unix/os390-syscalls.c246
-rw-r--r--Utilities/cmlibuv/src/unix/os390-syscalls.h7
-rw-r--r--Utilities/cmlibuv/src/unix/os390.c241
-rw-r--r--Utilities/cmlibuv/src/unix/pipe.c123
-rw-r--r--Utilities/cmlibuv/src/unix/poll.c32
-rw-r--r--Utilities/cmlibuv/src/unix/posix-hrtime.c39
-rw-r--r--Utilities/cmlibuv/src/unix/posix-poll.c20
-rw-r--r--Utilities/cmlibuv/src/unix/process.c159
-rw-r--r--Utilities/cmlibuv/src/unix/procfs-exepath.c4
-rw-r--r--Utilities/cmlibuv/src/unix/proctitle.c43
-rw-r--r--Utilities/cmlibuv/src/unix/pthread-barrier.c121
-rw-r--r--Utilities/cmlibuv/src/unix/signal.c70
-rw-r--r--Utilities/cmlibuv/src/unix/stream.c379
-rw-r--r--Utilities/cmlibuv/src/unix/sunos.c85
-rw-r--r--Utilities/cmlibuv/src/unix/tcp.c202
-rw-r--r--Utilities/cmlibuv/src/unix/thread.c503
-rw-r--r--Utilities/cmlibuv/src/unix/timer.c172
-rw-r--r--Utilities/cmlibuv/src/unix/tty.c97
-rw-r--r--Utilities/cmlibuv/src/unix/udp.c247
-rw-r--r--Utilities/cmlibuv/src/uv-common.c194
-rw-r--r--Utilities/cmlibuv/src/uv-common.h150
-rw-r--r--Utilities/cmlibuv/src/uv-data-getter-setters.c98
-rw-r--r--Utilities/cmlibuv/src/win/async.c10
-rw-r--r--Utilities/cmlibuv/src/win/atomicops-inl.h8
-rw-r--r--Utilities/cmlibuv/src/win/core.c91
-rw-r--r--Utilities/cmlibuv/src/win/dl.c64
-rw-r--r--Utilities/cmlibuv/src/win/error.c6
-rw-r--r--Utilities/cmlibuv/src/win/fs-event.c46
-rw-r--r--Utilities/cmlibuv/src/win/fs.c923
-rw-r--r--Utilities/cmlibuv/src/win/getaddrinfo.c101
-rw-r--r--Utilities/cmlibuv/src/win/getnameinfo.c50
-rw-r--r--Utilities/cmlibuv/src/win/handle-inl.h25
-rw-r--r--Utilities/cmlibuv/src/win/handle.c18
-rw-r--r--Utilities/cmlibuv/src/win/internal.h133
-rw-r--r--Utilities/cmlibuv/src/win/loop-watcher.c2
-rw-r--r--Utilities/cmlibuv/src/win/pipe.c1197
-rw-r--r--Utilities/cmlibuv/src/win/poll.c55
-rw-r--r--Utilities/cmlibuv/src/win/process-stdio.c59
-rw-r--r--Utilities/cmlibuv/src/win/process.c160
-rw-r--r--Utilities/cmlibuv/src/win/req.c25
-rw-r--r--Utilities/cmlibuv/src/win/signal.c52
-rw-r--r--Utilities/cmlibuv/src/win/stream-inl.h11
-rw-r--r--Utilities/cmlibuv/src/win/stream.c36
-rw-r--r--Utilities/cmlibuv/src/win/tcp.c298
-rw-r--r--Utilities/cmlibuv/src/win/thread.c279
-rw-r--r--Utilities/cmlibuv/src/win/timer.c195
-rw-r--r--Utilities/cmlibuv/src/win/tty.c306
-rw-r--r--Utilities/cmlibuv/src/win/udp.c243
-rw-r--r--Utilities/cmlibuv/src/win/util.c496
-rw-r--r--Utilities/cmlibuv/src/win/winapi.c59
-rw-r--r--Utilities/cmlibuv/src/win/winapi.h91
-rw-r--r--Utilities/cmlibuv/src/win/winsock.c53
-rw-r--r--Utilities/cmlibuv/src/win/winsock.h3
-rw-r--r--Utilities/cmzlib/CMakeLists.txt2
-rw-r--r--Utilities/cmzstd/.gitattributes1
-rw-r--r--Utilities/cmzstd/CMakeLists.txt47
-rw-r--r--Utilities/cmzstd/LICENSE30
-rw-r--r--Utilities/cmzstd/README.md167
-rw-r--r--Utilities/cmzstd/lib/common/bitstream.h455
-rw-r--r--Utilities/cmzstd/lib/common/compiler.h140
-rw-r--r--Utilities/cmzstd/lib/common/cpu.h215
-rw-r--r--Utilities/cmzstd/lib/common/debug.c44
-rw-r--r--Utilities/cmzstd/lib/common/debug.h134
-rw-r--r--Utilities/cmzstd/lib/common/entropy_common.c236
-rw-r--r--Utilities/cmzstd/lib/common/error_private.c54
-rw-r--r--Utilities/cmzstd/lib/common/error_private.h76
-rw-r--r--Utilities/cmzstd/lib/common/fse.h708
-rw-r--r--Utilities/cmzstd/lib/common/fse_decompress.c309
-rw-r--r--Utilities/cmzstd/lib/common/huf.h358
-rw-r--r--Utilities/cmzstd/lib/common/mem.h380
-rw-r--r--Utilities/cmzstd/lib/common/pool.c340
-rw-r--r--Utilities/cmzstd/lib/common/pool.h84
-rw-r--r--Utilities/cmzstd/lib/common/threading.c75
-rw-r--r--Utilities/cmzstd/lib/common/threading.h123
-rw-r--r--Utilities/cmzstd/lib/common/xxhash.c876
-rw-r--r--Utilities/cmzstd/lib/common/xxhash.h305
-rw-r--r--Utilities/cmzstd/lib/common/zstd_common.c83
-rw-r--r--Utilities/cmzstd/lib/common/zstd_errors.h93
-rw-r--r--Utilities/cmzstd/lib/common/zstd_internal.h266
-rw-r--r--Utilities/cmzstd/lib/compress/fse_compress.c721
-rw-r--r--Utilities/cmzstd/lib/compress/hist.c203
-rw-r--r--Utilities/cmzstd/lib/compress/hist.h95
-rw-r--r--Utilities/cmzstd/lib/compress/huf_compress.c798
-rw-r--r--Utilities/cmzstd/lib/compress/zstd_compress.c4290
-rw-r--r--Utilities/cmzstd/lib/compress/zstd_compress_internal.h860
-rw-r--r--Utilities/cmzstd/lib/compress/zstd_double_fast.c499
-rw-r--r--Utilities/cmzstd/lib/compress/zstd_double_fast.h38
-rw-r--r--Utilities/cmzstd/lib/compress/zstd_fast.c391
-rw-r--r--Utilities/cmzstd/lib/compress/zstd_fast.h37
-rw-r--r--Utilities/cmzstd/lib/compress/zstd_lazy.c1106
-rw-r--r--Utilities/cmzstd/lib/compress/zstd_lazy.h67
-rw-r--r--Utilities/cmzstd/lib/compress/zstd_ldm.c597
-rw-r--r--Utilities/cmzstd/lib/compress/zstd_ldm.h105
-rw-r--r--Utilities/cmzstd/lib/compress/zstd_opt.c1217
-rw-r--r--Utilities/cmzstd/lib/compress/zstd_opt.h56
-rw-r--r--Utilities/cmzstd/lib/compress/zstdmt_compress.c2107
-rw-r--r--Utilities/cmzstd/lib/compress/zstdmt_compress.h174
-rw-r--r--Utilities/cmzstd/lib/decompress/huf_decompress.c1232
-rw-r--r--Utilities/cmzstd/lib/decompress/zstd_ddict.c240
-rw-r--r--Utilities/cmzstd/lib/decompress/zstd_ddict.h44
-rw-r--r--Utilities/cmzstd/lib/decompress/zstd_decompress.c1672
-rw-r--r--Utilities/cmzstd/lib/decompress/zstd_decompress_block.c1307
-rw-r--r--Utilities/cmzstd/lib/decompress/zstd_decompress_block.h59
-rw-r--r--Utilities/cmzstd/lib/decompress/zstd_decompress_internal.h168
-rw-r--r--Utilities/cmzstd/lib/deprecated/zbuff.h213
-rw-r--r--Utilities/cmzstd/lib/deprecated/zbuff_common.c26
-rw-r--r--Utilities/cmzstd/lib/deprecated/zbuff_compress.c147
-rw-r--r--Utilities/cmzstd/lib/deprecated/zbuff_decompress.c75
-rw-r--r--Utilities/cmzstd/lib/dictBuilder/cover.c1081
-rw-r--r--Utilities/cmzstd/lib/dictBuilder/cover.h83
-rw-r--r--Utilities/cmzstd/lib/dictBuilder/divsufsort.c1913
-rw-r--r--Utilities/cmzstd/lib/dictBuilder/divsufsort.h67
-rw-r--r--Utilities/cmzstd/lib/dictBuilder/fastcover.c728
-rw-r--r--Utilities/cmzstd/lib/dictBuilder/zdict.c1111
-rw-r--r--Utilities/cmzstd/lib/dictBuilder/zdict.h267
-rw-r--r--Utilities/cmzstd/lib/zstd.h1766
-rw-r--r--Utilities/std/.gitattributes1
-rw-r--r--Utilities/std/CMakeLists.txt10
-rw-r--r--Utilities/std/cm/algorithm38
-rw-r--r--Utilities/std/cm/bits/string_view.cxx301
-rw-r--r--Utilities/std/cm/iterator216
-rw-r--r--Utilities/std/cm/memory32
-rw-r--r--Utilities/std/cm/optional344
-rw-r--r--Utilities/std/cm/shared_mutex76
-rw-r--r--Utilities/std/cm/string_view218
-rw-r--r--Utilities/std/cm/utility34
-rwxr-xr-xbootstrap545
-rw-r--r--packaging/cmake.spec4
8489 files changed, 345539 insertions, 151645 deletions
diff --git a/Auxiliary/bash-completion/cmake b/Auxiliary/bash-completion/cmake
index 0a862fa07..d8d2c86b0 100644
--- a/Auxiliary/bash-completion/cmake
+++ b/Auxiliary/bash-completion/cmake
@@ -76,8 +76,8 @@ _cmake()
compopt -o nospace
else
# complete variable names
- COMPREPLY=( $( compgen -W '$( cmake -LA -N | tail -n +2 |
- cut -f1 -d: )' -P "$prefix" -- "$cur" ) )
+ COMPREPLY=( $( compgen -W '$( cmake -LA -N 2>/dev/null |
+ tail -n +2 | cut -f1 -d: )' -P "$prefix" -- "$cur" ) )
compopt -o nospace
fi
return
@@ -96,7 +96,7 @@ _cmake()
_filedir
return
;;
- --build)
+ --build|--install|--open)
_filedir -d
return
;;
@@ -116,6 +116,9 @@ _cmake()
2>/dev/null )' -- "$quoted" ) )
return
;;
+ --loglevel)
+ COMPREPLY=( $(compgen -W 'error warning notice status verbose debug trace' -- $cur ) )
+ ;;
--help-command)
COMPREPLY=( $( compgen -W '$( cmake --help-command-list 2>/dev/null|
grep -v "^cmake version " )' -- "$cur" ) )
diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el
index a1b43c5b6..caaf0d52f 100644
--- a/Auxiliary/cmake-mode.el
+++ b/Auxiliary/cmake-mode.el
@@ -1,5 +1,7 @@
;;; cmake-mode.el --- major-mode for editing CMake sources
+;; Package-Requires: ((emacs "24.1"))
+
; Distributed under the OSI-approved BSD 3-Clause License. See accompanying
; file Copyright.txt or https://cmake.org/licensing for details.
@@ -55,7 +57,7 @@ set the path with these commands:
(* (or (not (any space "()#\\\n")) (and ?\\ nonl)))))
(defconst cmake-regex-token
(rx-to-string `(group (or (regexp ,cmake-regex-comment)
- ?( ?)
+ ?\( ?\)
(regexp ,cmake-regex-argument-unquoted)
(regexp ,cmake-regex-argument-quoted)))))
(defconst cmake-regex-indented
@@ -224,17 +226,11 @@ the indentation. Otherwise it retains the same position on the line"
;;
(defvar cmake-mode-hook nil)
-;------------------------------------------------------------------------------
-
-;; For compatibility with Emacs < 24
-(defalias 'cmake--parent-mode
- (if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode))
-
;;------------------------------------------------------------------------------
;; Mode definition.
;;
;;;###autoload
-(define-derived-mode cmake-mode cmake--parent-mode "CMake"
+(define-derived-mode cmake-mode prog-mode "CMake"
"Major mode for editing CMake source files."
; Setup font-lock mode.
@@ -352,7 +348,7 @@ and store the result as a list in LISTVAR."
;;;###autoload
(defun cmake-help ()
- "Queries for any of the four available help topics and prints out the approriate page."
+ "Queries for any of the four available help topics and prints out the appropriate page."
(interactive)
(let* ((default-entry (cmake-symbol-at-point))
(command-list (cmake-get-list "command"))
diff --git a/Auxiliary/cmake.m4 b/Auxiliary/cmake.m4
index 7beff41a8..a40c0ae97 100644
--- a/Auxiliary/cmake.m4
+++ b/Auxiliary/cmake.m4
@@ -13,7 +13,7 @@ fi
# $2: language (e.g. C/CXX/Fortran)
# $3: The compiler ID, defaults to GNU.
# Possible values are: GNU, Intel, Clang, SunPro, HP, XL, VisualAge, PGI,
-# PathScale, Cray, SCO, MIPSpro, MSVC
+# PathScale, Cray, SCO, MSVC
# $4: optional extra arguments to cmake, e.g. "-DCMAKE_SIZEOF_VOID_P=8"
# $5: optional path to cmake binary
AC_DEFUN([CMAKE_FIND_PACKAGE], [
diff --git a/Auxiliary/vim/cmake.vim.in b/Auxiliary/vim/cmake.vim.in
index 389d9e46e..3471b5455 100644
--- a/Auxiliary/vim/cmake.vim.in
+++ b/Auxiliary/vim/cmake.vim.in
@@ -1,10 +1,13 @@
-" vim: set nowrap:
" Vim syntax file
+" Program: CMake - Cross-Platform Makefile Generator
+" Version: @VERSION@
" Language: CMake
-" Author: Andy Cedilnik <andy.cedilnik@kitware.com>, Nicholas Hutchinson <nshutchinson@gmail.com>, Patrick Boettcher <patrick.boettcher@posteo.de>
-" Maintainer: Karthik Krishnan <karthik.krishnan@kitware.com>
-" Last Change: $Date$
-" Version: $Revision$
+" Author: Andy Cedilnik <andy.cedilnik@kitware.com>,
+" Nicholas Hutchinson <nshutchinson@gmail.com>,
+" Patrick Boettcher <patrick.boettcher@posteo.de>
+" Maintainer: Dimitri Merejkowsky <d.merej@gmail.com>
+" Former Maintainer: Karthik Krishnan <karthik.krishnan@kitware.com>
+" Last Change: @DATE@
"
" Licence: The CMake license applies to this file. See
" https://cmake.org/licensing
@@ -13,27 +16,31 @@
if exists("b:current_syntax")
finish
endif
+let s:keepcpo= &cpo
+set cpo&vim
+
+syn region cmakeBracketArgument start="\[\z(=\?\|=[0-9]*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
syn region cmakeComment start="#" end="$" contains=cmakeTodo,@Spell
-syn region cmakeLuaComment start="\[\z(=*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
+syn region cmakeBracketComment start="#\[\z(=\?\|=[0-9]*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
syn match cmakeEscaped /\(\\\\\|\\"\|\\n\|\\t\)/ contained
syn region cmakeRegistry start="\[" end="]" contained oneline contains=cmakeTodo,cmakeEscaped
syn region cmakeGeneratorExpression start="$<" end=">" contained oneline contains=cmakeVariableValue,cmakeProperty,cmakeGeneratorExpressions,cmakeTodo
-syn region cmakeString start='"' end='"' contained contains=cmakeTodo,cmakeVariableValue
+syn region cmakeString start='"' end='"' contained contains=cmakeTodo,cmakeVariableValue,cmakeEscaped
-syn region cmakeVariableValue start="${" end="}" contained oneline contains=cmakeVariable,cmakeTodo
+syn region cmakeVariableValue start="${" end="}" contained oneline contains=cmakeVariable,cmakeTodo,cmakeVariableValue
syn region cmakeEnvironment start="$ENV{" end="}" contained oneline contains=cmakeTodo
-syn region cmakeArguments start="(" end=")" contains=ALLBUT,cmakeArguments,cmakeTodo
+syn region cmakeArguments start="(" end=")" contains=ALLBUT,cmakeGeneratorExpressions,cmakeCommand,cmakeCommandConditional,cmakeCommandRepeat,cmakeCommandDeprecated,cmakeCommandManuallyAdded,cmakeArguments,cmakeTodo
syn case match
syn keyword cmakeProperty contained
- \ ABSTRACT ADDITIONAL_MAKE_CLEAN_FILES ADVANCED ALIASED_TARGET ALLOW_DUPLICATE_CUSTOM_TARGETS ANDROID_ANT_ADDITIONAL_OPTIONS ANDROID_API ANDROID_API_MIN ANDROID_ARCH ANDROID_ASSETS_DIRECTORIES ANDROID_GUI ANDROID_JAR_DEPENDENCIES ANDROID_JAR_DIRECTORIES ANDROID_JAVA_SOURCE_DIR ANDROID_NATIVE_LIB_DEPENDENCIES ANDROID_NATIVE_LIB_DIRECTORIES ANDROID_PROCESS_MAX ANDROID_PROGUARD ANDROID_PROGUARD_CONFIG_PATH ANDROID_SECURE_PROPS_PATH ANDROID_SKIP_ANT_STEP ANDROID_STL_TYPE ARCHIVE_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_DIRECTORY_DEBUG ARCHIVE_OUTPUT_DIRECTORY_RELEASE ARCHIVE_OUTPUT_NAME ARCHIVE_OUTPUT_NAME_DEBUG ARCHIVE_OUTPUT_NAME_RELEASE ATTACHED_FILES ATTACHED_FILES_ON_FAIL AUTOGEN_TARGETS_FOLDER AUTOGEN_TARGET_DEPENDS AUTOMOC AUTOMOC_MOC_OPTIONS AUTOMOC_TARGETS_FOLDER AUTORCC AUTORCC_OPTIONS AUTOUIC AUTOUIC_OPTIONS BINARY_DIR BUILD_WITH_INSTALL_RPATH BUNDLE BUNDLE_EXTENSION CACHE_VARIABLES CLEAN_NO_CUSTOM CMAKE_CONFIGURE_DEPENDS CMAKE_CXX_KNOWN_FEATURES CMAKE_C_KNOWN_FEATURES COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_NUMBER_MAX COMPATIBLE_INTERFACE_NUMBER_MIN COMPATIBLE_INTERFACE_STRING COMPILE_DEFINITIONS COMPILE_DEFINITIONS_DEBUG COMPILE_DEFINITIONS_RELEASE COMPILE_FEATURES COMPILE_FLAGS COMPILE_OPTIONS COMPILE_PDB_NAME COMPILE_PDB_NAME_DEBUG COMPILE_PDB_NAME_RELEASE COMPILE_PDB_OUTPUT_DIRECTORY COMPILE_PDB_OUTPUT_DIRECTORY_DEBUG COMPILE_PDB_OUTPUT_DIRECTORY_RELEASE COST CPACK_DESKTOP_SHORTCUTS CPACK_NEVER_OVERWRITE CPACK_PERMANENT CPACK_STARTUP_SHORTCUTS CPACK_START_MENU_SHORTCUTS CPACK_WIX_ACL CROSSCOMPILING_EMULATOR CXX_EXTENSIONS CXX_STANDARD CXX_STANDARD_REQUIRED C_EXTENSIONS C_STANDARD C_STANDARD_REQUIRED DEBUG_CONFIGURATIONS DEBUG_POSTFIX DEFINE_SYMBOL DEFINITIONS DEPENDS DISABLED_FEATURES ECLIPSE_EXTRA_NATURES ENABLED_FEATURES ENABLED_LANGUAGES ENABLE_EXPORTS ENVIRONMENT EXCLUDE_FROM_ALL EXCLUDE_FROM_DEFAULT_BUILD EXCLUDE_FROM_DEFAULT_BUILD_DEBUG EXCLUDE_FROM_DEFAULT_BUILD_RELEASE EXPORT_NAME EXTERNAL_OBJECT EchoString FAIL_REGULAR_EXPRESSION FIND_LIBRARY_USE_LIB64_PATHS FIND_LIBRARY_USE_OPENBSD_VERSIONING FOLDER FRAMEWORK FRAMEWORK_VERSION Fortran_FORMAT Fortran_MODULE_DIRECTORY GENERATED GENERATOR_FILE_NAME GLOBAL_DEPENDS_DEBUG_MODE GLOBAL_DEPENDS_NO_CYCLES GNUtoMS HAS_CXX HEADER_FILE_ONLY HELPSTRING IMPLICIT_DEPENDS_INCLUDE_TRANSFORM IMPORTED IMPORTED_CONFIGURATIONS IMPORTED_IMPLIB IMPORTED_IMPLIB_DEBUG IMPORTED_IMPLIB_RELEASE IMPORTED_LINK_DEPENDENT_LIBRARIES IMPORTED_LINK_DEPENDENT_LIBRARIES_DEBUG IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE IMPORTED_LINK_INTERFACE_LANGUAGES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE IMPORTED_LINK_INTERFACE_LIBRARIES IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE IMPORTED_LINK_INTERFACE_MULTIPLICITY IMPORTED_LINK_INTERFACE_MULTIPLICITY_DEBUG IMPORTED_LINK_INTERFACE_MULTIPLICITY_RELEASE IMPORTED_LOCATION IMPORTED_LOCATION_DEBUG IMPORTED_LOCATION_RELEASE IMPORTED_NO_SONAME IMPORTED_NO_SONAME_DEBUG IMPORTED_NO_SONAME_RELEASE IMPORTED_SONAME IMPORTED_SONAME_DEBUG IMPORTED_SONAME_RELEASE IMPORT_PREFIX IMPORT_SUFFIX INCLUDE_DIRECTORIES INCLUDE_REGULAR_EXPRESSION INSTALL_NAME_DIR INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH INTERFACE_AUTOUIC_OPTIONS INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_FEATURES INTERFACE_COMPILE_OPTIONS INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_LIBRARIES INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SOURCES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES INTERPROCEDURAL_OPTIMIZATION INTERPROCEDURAL_OPTIMIZATION_DEBUG INTERPROCEDURAL_OPTIMIZATION_RELEASE IN_TRY_COMPILE JOB_POOLS JOB_POOL_COMPILE JOB_POOL_LINK KEEP_EXTENSION LABELS LANGUAGE LIBRARY_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY_DEBUG LIBRARY_OUTPUT_DIRECTORY_RELEASE LIBRARY_OUTPUT_NAME LIBRARY_OUTPUT_NAME_DEBUG LIBRARY_OUTPUT_NAME_RELEASE LINKER_LANGUAGE LINK_DEPENDS LINK_DEPENDS_NO_SHARED LINK_DIRECTORIES LINK_FLAGS LINK_FLAGS_DEBUG LINK_FLAGS_RELEASE LINK_INTERFACE_LIBRARIES LINK_INTERFACE_LIBRARIES_DEBUG LINK_INTERFACE_LIBRARIES_RELEASE LINK_INTERFACE_MULTIPLICITY LINK_INTERFACE_MULTIPLICITY_DEBUG LINK_INTERFACE_MULTIPLICITY_RELEASE LINK_LIBRARIES LINK_SEARCH_END_STATIC LINK_SEARCH_START_STATIC LISTFILE_STACK LOCATION LOCATION_DEBUG LOCATION_RELEASE MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST MACOSX_PACKAGE_LOCATION MACOSX_RPATH MACROS MAP_IMPORTED_CONFIG_DEBUG MAP_IMPORTED_CONFIG_RELEASE MEASUREMENT MODIFIED NAME NO_SONAME NO_SYSTEM_FROM_IMPORTED OBJECT_DEPENDS OBJECT_OUTPUTS OSX_ARCHITECTURES OSX_ARCHITECTURES_DEBUG OSX_ARCHITECTURES_RELEASE OUTPUT_NAME OUTPUT_NAME_DEBUG OUTPUT_NAME_RELEASE PACKAGES_FOUND PACKAGES_NOT_FOUND PARENT_DIRECTORY PASS_REGULAR_EXPRESSION PDB_NAME PDB_NAME_DEBUG PDB_NAME_RELEASE PDB_OUTPUT_DIRECTORY PDB_OUTPUT_DIRECTORY_DEBUG PDB_OUTPUT_DIRECTORY_RELEASE POSITION_INDEPENDENT_CODE POST_INSTALL_SCRIPT PREDEFINED_TARGETS_FOLDER PREFIX PRE_INSTALL_SCRIPT PRIVATE_HEADER PROCESSORS PROJECT_LABEL PUBLIC_HEADER REPORT_UNDEFINED_PROPERTIES REQUIRED_FILES RESOURCE RESOURCE_LOCK RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK RULE_MESSAGES RUNTIME_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY_DEBUG RUNTIME_OUTPUT_DIRECTORY_RELEASE RUNTIME_OUTPUT_NAME RUNTIME_OUTPUT_NAME_DEBUG RUNTIME_OUTPUT_NAME_RELEASE RUN_SERIAL SKIP_BUILD_RPATH SKIP_RETURN_CODE SOURCES SOURCE_DIR SOVERSION STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_DEBUG STATIC_LIBRARY_FLAGS_RELEASE STRINGS SUFFIX SYMBOLIC TARGET_ARCHIVES_MAY_BE_SHARED_LIBS TARGET_MESSAGES TARGET_SUPPORTS_SHARED_LIBS TEST_INCLUDE_FILE TIMEOUT TYPE USE_FOLDERS VALUE VARIABLES VERSION VISIBILITY_INLINES_HIDDEN VS_DEPLOYMENT_CONTENT VS_DEPLOYMENT_LOCATION VS_DESKTOP_EXTENSIONS_VERSION VS_DOTNET_REFERENCES VS_DOTNET_TARGET_FRAMEWORK_VERSION VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_GLOBAL_ROOTNAMESPACE VS_IOT_EXTENSIONS_VERSION VS_IOT_STARTUP_TASK VS_KEYWORD VS_MOBILE_EXTENSIONS_VERSION VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER VS_SHADER_ENTRYPOINT VS_SHADER_FLAGS VS_SHADER_MODEL VS_SHADER_TYPE VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION VS_WINRT_COMPONENT VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES VS_XAML_TYPE WILL_FAIL WIN32_EXECUTABLE WINDOWS_EXPORT_ALL_SYMBOLS WORKING_DIRECTORY WRAP_EXCLUDE XCODE_EXPLICIT_FILE_TYPE XCODE_LAST_KNOWN_FILE_TYPE XCTEST
+@PROPERTIES@
syn keyword cmakeVariable contained
@VARIABLE_LIST@
@@ -70,6 +77,8 @@ syn keyword cmakeTodo
\ TODO FIXME XXX
\ contained
+hi def link cmakeBracketArgument String
+hi def link cmakeBracketComment Comment
hi def link cmakeCommand Function
hi def link cmakeCommandConditional Conditional
hi def link cmakeCommandDeprecated WarningMsg
@@ -79,7 +88,6 @@ hi def link cmakeEnvironment Special
hi def link cmakeEscaped Special
hi def link cmakeGeneratorExpression WarningMsg
hi def link cmakeGeneratorExpressions Constant
-hi def link cmakeLuaComment Comment
hi def link cmakeModule Include
hi def link cmakeProperty Constant
hi def link cmakeRegistry Underlined
@@ -90,4 +98,33 @@ hi def link cmakeVariable Identifier
@KEYWORDS_HIGHLIGHT@
+" Manually added - difficult to parse out of documentation
+syn case ignore
+
+syn keyword cmakeCommandManuallyAdded
+ \ configure_package_config_file write_basic_package_version_file
+ \ nextgroup=cmakeArguments
+
+syn case match
+
+syn keyword cmakeKWconfigure_package_config_file contained
+ \ INSTALL_DESTINATION PATH_VARS NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO INSTALL_PREFIX
+
+syn keyword cmakeKWconfigure_package_config_file_constants contained
+ \ AnyNewerVersion SameMajorVersion SameMinorVersion ExactVersion
+
+syn keyword cmakeKWwrite_basic_package_version_file contained
+ \ VERSION COMPATIBILITY
+
+hi def link cmakeCommandManuallyAdded Function
+
+hi def link cmakeKWconfigure_package_config_file ModeMsg
+hi def link cmakeKWwrite_basic_package_version_file ModeMsg
+hi def link cmakeKWconfigure_package_config_file_constants Constant
+
let b:current_syntax = "cmake"
+
+let &cpo = s:keepcpo
+unlet s:keepcpo
+
+" vim: set nowrap:
diff --git a/Auxiliary/vim/extract-upper-case.pl b/Auxiliary/vim/extract-upper-case.pl
index ea77cbb5c..204b49662 100755
--- a/Auxiliary/vim/extract-upper-case.pl
+++ b/Auxiliary/vim/extract-upper-case.pl
@@ -2,6 +2,7 @@
use strict;
use warnings;
+use POSIX qw(strftime);
#my $cmake = "/home/pboettch/devel/upstream/cmake/build/bin/cmake";
my $cmake = "cmake";
@@ -12,6 +13,9 @@ my @properties;
my @modules;
my %keywords; # command => keyword-list
+# find cmake/Modules/ | sed -rn 's/.*CMakeDetermine(.+)Compiler.cmake/\1/p' | sort
+my @languages = qw(ASM ASM_MASM ASM_NASM C CSharp CUDA CXX Fortran Java RC Swift);
+
# unwanted upper-cases
my %unwanted = map { $_ => 1 } qw(VS CXX IDE NOTFOUND NO_ DFOO DBAR NEW);
# cannot remove ALL - exists for add_custom_command
@@ -30,7 +34,20 @@ push @modules, "ExternalProject";
open(CMAKE, "$cmake --help-variable-list|") or die "could not run cmake";
while (<CMAKE>) {
chomp;
- next if /\</; # skip VARIABLES which contained <>-"templates"
+
+ if (/<(.*?)>/) {
+ if ($1 eq 'LANG') {
+ foreach my $lang (@languages) {
+ (my $V = $_) =~ s/<.*>/$lang/;
+ push @variables, $V;
+ }
+
+ next
+ } else {
+ next; # skip if containing < or >
+ }
+ }
+
push @variables, $_;
}
close(CMAKE);
@@ -70,11 +87,24 @@ my @generator_expr = extract_upper("$cmake --help-manual cmake-generator-express
# properties
open(CMAKE, "$cmake --help-property-list|");
while (<CMAKE>) {
+ next if /\</; # skip if containing < or >
chomp;
push @properties, $_;
}
close(CMAKE);
+# transform all properties in a hash
+my %properties = map { $_ => 1 } @properties;
+
+# version
+open(CMAKE, "$cmake --version|");
+my $version = 'unknown';
+while (<CMAKE>) {
+ chomp;
+ $version = $_ if /cmake version/;
+}
+close(CMAKE);
+
# generate cmake.vim
open(IN, "<cmake.vim.in") or die "could not read cmake.vim.in";
open(OUT, ">syntax/cmake.vim") or die "could not write to syntax/cmake.vim";
@@ -89,28 +119,37 @@ while(<IN>)
my @tmp = grep { ! exists $conditional{$_} and
! exists $loop{$_} and
! exists $deprecated{$_} } @commands;
- print OUT " " x 12 , "\\ ", join(" ", @tmp), "\n";
+ print_list(\*OUT, @tmp);
} elsif ($1 eq "VARIABLE_LIST") {
- print OUT " " x 12 , "\\ ", join(" ", sort keys %variables), "\n";
+ print_list(\*OUT, keys %variables);
} elsif ($1 eq "MODULES") {
- print OUT " " x 12 , "\\ ", join("\n", @modules), "\n";
+ print_list(\*OUT, @modules);
} elsif ($1 eq "GENERATOR_EXPRESSIONS") {
- print OUT " " x 12 , "\\ ", join(" ", @generator_expr), "\n";
+ print_list(\*OUT, @generator_expr);
} elsif ($1 eq "CONDITIONALS") {
- print OUT " " x 12 , "\\ ", join(" ", sort keys %conditional), "\n";
+ print_list(\*OUT, keys %conditional);
} elsif ($1 eq "LOOPS") {
- print OUT " " x 12 , "\\ ", join(" ", sort keys %loop), "\n";
+ print_list(\*OUT, keys %loop);
} elsif ($1 eq "DEPRECATED") {
- print OUT " " x 12 , "\\ ", join(" ", sort keys %deprecated), "\n";
+ print_list(\*OUT, keys %deprecated);
+ } elsif ($1 eq "PROPERTIES") {
+ print_list(\*OUT, keys %properties);
} elsif ($1 eq "KEYWORDS") {
foreach my $k (sort keys %keywords) {
print OUT "syn keyword cmakeKW$k contained\n";
- print OUT " " x 12, "\\ ", join(" ", @{$keywords{$k}}), "\n";
+ print_list(\*OUT, @{$keywords{$k}});
print OUT "\n";
push @keyword_hi, "hi def link cmakeKW$k ModeMsg";
}
} elsif ($1 eq "KEYWORDS_HIGHLIGHT") {
print OUT join("\n", @keyword_hi), "\n";
+ } elsif ($1 eq "VERSION") {
+ $_ =~ s/\@VERSION\@/$version/;
+ print OUT $_;
+ } elsif ($1 eq "DATE") {
+ my $date = strftime "%Y %b %d", localtime;
+ $_ =~ s/\@DATE\@/$date/;
+ print OUT $_;
} else {
print "ERROR do not know how to replace $1\n";
}
@@ -128,7 +167,6 @@ sub extract_upper
open(KW, $input);
while (<KW>) {
-
foreach my $w (m/\b([A-Z_]{2,})\b/g) {
next
if exists $variables{$w} or # skip if it is a variable
@@ -142,3 +180,10 @@ sub extract_upper
return @word;
}
+
+sub print_list
+{
+ my $O = shift;
+ my $indent = " " x 12 . "\\ ";
+ print $O $indent, join("\n" . $indent, sort @_), "\n";
+}
diff --git a/Auxiliary/vim/indent/cmake.vim b/Auxiliary/vim/indent/cmake.vim
index 76aff64a6..33e583d62 100644
--- a/Auxiliary/vim/indent/cmake.vim
+++ b/Auxiliary/vim/indent/cmake.vim
@@ -1,9 +1,9 @@
" Vim indent file
" Language: CMake (ft=cmake)
" Author: Andy Cedilnik <andy.cedilnik@kitware.com>
-" Maintainer: Karthik Krishnan <karthik.krishnan@kitware.com>
-" Last Change: $Date$
-" Version: $Revision$
+" Maintainer: Dimitri Merejkowsky <d.merej@gmail.com>
+" Former Maintainer: Karthik Krishnan <karthik.krishnan@kitware.com>
+" Last Change: 2017 Aug 30
"
" Licence: The CMake license applies to this file. See
" https://cmake.org/licensing
@@ -14,6 +14,9 @@ if exists("b:did_indent")
endif
let b:did_indent = 1
+let s:keepcpo= &cpo
+set cpo&vim
+
setlocal indentexpr=CMakeGetIndent(v:lnum)
setlocal indentkeys+==ENDIF(,ENDFOREACH(,ENDMACRO(,ELSE(,ELSEIF(,ENDWHILE(
@@ -64,20 +67,23 @@ fun! CMakeGetIndent(lnum)
let ind = ind
else
if previous_line =~? cmake_indent_begin_regex
- let ind = ind + &sw
+ let ind = ind + shiftwidth()
endif
if previous_line =~? cmake_indent_open_regex
- let ind = ind + &sw
+ let ind = ind + shiftwidth()
endif
endif
" Subtract
if this_line =~? cmake_indent_end_regex
- let ind = ind - &sw
+ let ind = ind - shiftwidth()
endif
if previous_line =~? cmake_indent_close_regex
- let ind = ind - &sw
+ let ind = ind - shiftwidth()
endif
return ind
endfun
+
+let &cpo = s:keepcpo
+unlet s:keepcpo
diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim
index a191c1872..5de117b82 100644
--- a/Auxiliary/vim/syntax/cmake.vim
+++ b/Auxiliary/vim/syntax/cmake.vim
@@ -1,10 +1,13 @@
-" vim: set nowrap:
" Vim syntax file
+" Program: CMake - Cross-Platform Makefile Generator
+" Version: cmake version 3.14.20190529-g067a4f
" Language: CMake
-" Author: Andy Cedilnik <andy.cedilnik@kitware.com>, Nicholas Hutchinson <nshutchinson@gmail.com>, Patrick Boettcher <patrick.boettcher@posteo.de>
-" Maintainer: Karthik Krishnan <karthik.krishnan@kitware.com>
-" Last Change: $Date$
-" Version: $Revision$
+" Author: Andy Cedilnik <andy.cedilnik@kitware.com>,
+" Nicholas Hutchinson <nshutchinson@gmail.com>,
+" Patrick Boettcher <patrick.boettcher@posteo.de>
+" Maintainer: Dimitri Merejkowsky <d.merej@gmail.com>
+" Former Maintainer: Karthik Krishnan <karthik.krishnan@kitware.com>
+" Last Change: 2019 May 29
"
" Licence: The CMake license applies to this file. See
" https://cmake.org/licensing
@@ -13,333 +16,3194 @@
if exists("b:current_syntax")
finish
endif
+let s:keepcpo= &cpo
+set cpo&vim
+
+syn region cmakeBracketArgument start="\[\z(=\?\|=[0-9]*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
syn region cmakeComment start="#" end="$" contains=cmakeTodo,@Spell
-syn region cmakeLuaComment start="\[\z(=*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
+syn region cmakeBracketComment start="#\[\z(=\?\|=[0-9]*\)\[" end="\]\z1\]" contains=cmakeTodo,@Spell
syn match cmakeEscaped /\(\\\\\|\\"\|\\n\|\\t\)/ contained
syn region cmakeRegistry start="\[" end="]" contained oneline contains=cmakeTodo,cmakeEscaped
syn region cmakeGeneratorExpression start="$<" end=">" contained oneline contains=cmakeVariableValue,cmakeProperty,cmakeGeneratorExpressions,cmakeTodo
-syn region cmakeString start='"' end='"' contained contains=cmakeTodo,cmakeVariableValue
+syn region cmakeString start='"' end='"' contained contains=cmakeTodo,cmakeVariableValue,cmakeEscaped
-syn region cmakeVariableValue start="${" end="}" contained oneline contains=cmakeVariable,cmakeTodo
+syn region cmakeVariableValue start="${" end="}" contained oneline contains=cmakeVariable,cmakeTodo,cmakeVariableValue
syn region cmakeEnvironment start="$ENV{" end="}" contained oneline contains=cmakeTodo
-syn region cmakeArguments start="(" end=")" contains=ALLBUT,cmakeArguments,cmakeTodo
+syn region cmakeArguments start="(" end=")" contains=ALLBUT,cmakeGeneratorExpressions,cmakeCommand,cmakeCommandConditional,cmakeCommandRepeat,cmakeCommandDeprecated,cmakeCommandManuallyAdded,cmakeArguments,cmakeTodo
syn case match
syn keyword cmakeProperty contained
- \ ABSTRACT ADDITIONAL_MAKE_CLEAN_FILES ADVANCED ALIASED_TARGET ALLOW_DUPLICATE_CUSTOM_TARGETS ANDROID_ANT_ADDITIONAL_OPTIONS ANDROID_API ANDROID_API_MIN ANDROID_ARCH ANDROID_ASSETS_DIRECTORIES ANDROID_GUI ANDROID_JAR_DEPENDENCIES ANDROID_JAR_DIRECTORIES ANDROID_JAVA_SOURCE_DIR ANDROID_NATIVE_LIB_DEPENDENCIES ANDROID_NATIVE_LIB_DIRECTORIES ANDROID_PROCESS_MAX ANDROID_PROGUARD ANDROID_PROGUARD_CONFIG_PATH ANDROID_SECURE_PROPS_PATH ANDROID_SKIP_ANT_STEP ANDROID_STL_TYPE ARCHIVE_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_DIRECTORY_DEBUG ARCHIVE_OUTPUT_DIRECTORY_RELEASE ARCHIVE_OUTPUT_NAME ARCHIVE_OUTPUT_NAME_DEBUG ARCHIVE_OUTPUT_NAME_RELEASE ATTACHED_FILES ATTACHED_FILES_ON_FAIL AUTOGEN_TARGETS_FOLDER AUTOGEN_TARGET_DEPENDS AUTOMOC AUTOMOC_MOC_OPTIONS AUTOMOC_TARGETS_FOLDER AUTORCC AUTORCC_OPTIONS AUTOUIC AUTOUIC_OPTIONS BINARY_DIR BUILD_WITH_INSTALL_RPATH BUNDLE BUNDLE_EXTENSION CACHE_VARIABLES CLEAN_NO_CUSTOM CMAKE_CONFIGURE_DEPENDS CMAKE_CXX_KNOWN_FEATURES CMAKE_C_KNOWN_FEATURES COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_NUMBER_MAX COMPATIBLE_INTERFACE_NUMBER_MIN COMPATIBLE_INTERFACE_STRING COMPILE_DEFINITIONS COMPILE_DEFINITIONS_DEBUG COMPILE_DEFINITIONS_RELEASE COMPILE_FEATURES COMPILE_FLAGS COMPILE_OPTIONS COMPILE_PDB_NAME COMPILE_PDB_NAME_DEBUG COMPILE_PDB_NAME_RELEASE COMPILE_PDB_OUTPUT_DIRECTORY COMPILE_PDB_OUTPUT_DIRECTORY_DEBUG COMPILE_PDB_OUTPUT_DIRECTORY_RELEASE COST CPACK_DESKTOP_SHORTCUTS CPACK_NEVER_OVERWRITE CPACK_PERMANENT CPACK_STARTUP_SHORTCUTS CPACK_START_MENU_SHORTCUTS CPACK_WIX_ACL CROSSCOMPILING_EMULATOR CXX_EXTENSIONS CXX_STANDARD CXX_STANDARD_REQUIRED C_EXTENSIONS C_STANDARD C_STANDARD_REQUIRED DEBUG_CONFIGURATIONS DEBUG_POSTFIX DEFINE_SYMBOL DEFINITIONS DEPENDS DISABLED_FEATURES ECLIPSE_EXTRA_NATURES ENABLED_FEATURES ENABLED_LANGUAGES ENABLE_EXPORTS ENVIRONMENT EXCLUDE_FROM_ALL EXCLUDE_FROM_DEFAULT_BUILD EXCLUDE_FROM_DEFAULT_BUILD_DEBUG EXCLUDE_FROM_DEFAULT_BUILD_RELEASE EXPORT_NAME EXTERNAL_OBJECT EchoString FAIL_REGULAR_EXPRESSION FIND_LIBRARY_USE_LIB64_PATHS FIND_LIBRARY_USE_OPENBSD_VERSIONING FOLDER FRAMEWORK FRAMEWORK_VERSION Fortran_FORMAT Fortran_MODULE_DIRECTORY GENERATED GENERATOR_FILE_NAME GLOBAL_DEPENDS_DEBUG_MODE GLOBAL_DEPENDS_NO_CYCLES GNUtoMS HAS_CXX HEADER_FILE_ONLY HELPSTRING IMPLICIT_DEPENDS_INCLUDE_TRANSFORM IMPORTED IMPORTED_CONFIGURATIONS IMPORTED_IMPLIB IMPORTED_IMPLIB_DEBUG IMPORTED_IMPLIB_RELEASE IMPORTED_LINK_DEPENDENT_LIBRARIES IMPORTED_LINK_DEPENDENT_LIBRARIES_DEBUG IMPORTED_LINK_DEPENDENT_LIBRARIES_RELEASE IMPORTED_LINK_INTERFACE_LANGUAGES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE IMPORTED_LINK_INTERFACE_LIBRARIES IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE IMPORTED_LINK_INTERFACE_MULTIPLICITY IMPORTED_LINK_INTERFACE_MULTIPLICITY_DEBUG IMPORTED_LINK_INTERFACE_MULTIPLICITY_RELEASE IMPORTED_LOCATION IMPORTED_LOCATION_DEBUG IMPORTED_LOCATION_RELEASE IMPORTED_NO_SONAME IMPORTED_NO_SONAME_DEBUG IMPORTED_NO_SONAME_RELEASE IMPORTED_SONAME IMPORTED_SONAME_DEBUG IMPORTED_SONAME_RELEASE IMPORT_PREFIX IMPORT_SUFFIX INCLUDE_DIRECTORIES INCLUDE_REGULAR_EXPRESSION INSTALL_NAME_DIR INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH INTERFACE_AUTOUIC_OPTIONS INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_FEATURES INTERFACE_COMPILE_OPTIONS INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_LIBRARIES INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SOURCES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES INTERPROCEDURAL_OPTIMIZATION INTERPROCEDURAL_OPTIMIZATION_DEBUG INTERPROCEDURAL_OPTIMIZATION_RELEASE IN_TRY_COMPILE JOB_POOLS JOB_POOL_COMPILE JOB_POOL_LINK KEEP_EXTENSION LABELS LANGUAGE LIBRARY_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY_DEBUG LIBRARY_OUTPUT_DIRECTORY_RELEASE LIBRARY_OUTPUT_NAME LIBRARY_OUTPUT_NAME_DEBUG LIBRARY_OUTPUT_NAME_RELEASE LINKER_LANGUAGE LINK_DEPENDS LINK_DEPENDS_NO_SHARED LINK_DIRECTORIES LINK_FLAGS LINK_FLAGS_DEBUG LINK_FLAGS_RELEASE LINK_INTERFACE_LIBRARIES LINK_INTERFACE_LIBRARIES_DEBUG LINK_INTERFACE_LIBRARIES_RELEASE LINK_INTERFACE_MULTIPLICITY LINK_INTERFACE_MULTIPLICITY_DEBUG LINK_INTERFACE_MULTIPLICITY_RELEASE LINK_LIBRARIES LINK_SEARCH_END_STATIC LINK_SEARCH_START_STATIC LISTFILE_STACK LOCATION LOCATION_DEBUG LOCATION_RELEASE MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST MACOSX_PACKAGE_LOCATION MACOSX_RPATH MACROS MAP_IMPORTED_CONFIG_DEBUG MAP_IMPORTED_CONFIG_RELEASE MEASUREMENT MODIFIED NAME NO_SONAME NO_SYSTEM_FROM_IMPORTED OBJECT_DEPENDS OBJECT_OUTPUTS OSX_ARCHITECTURES OSX_ARCHITECTURES_DEBUG OSX_ARCHITECTURES_RELEASE OUTPUT_NAME OUTPUT_NAME_DEBUG OUTPUT_NAME_RELEASE PACKAGES_FOUND PACKAGES_NOT_FOUND PARENT_DIRECTORY PASS_REGULAR_EXPRESSION PDB_NAME PDB_NAME_DEBUG PDB_NAME_RELEASE PDB_OUTPUT_DIRECTORY PDB_OUTPUT_DIRECTORY_DEBUG PDB_OUTPUT_DIRECTORY_RELEASE POSITION_INDEPENDENT_CODE POST_INSTALL_SCRIPT PREDEFINED_TARGETS_FOLDER PREFIX PRE_INSTALL_SCRIPT PRIVATE_HEADER PROCESSORS PROJECT_LABEL PUBLIC_HEADER REPORT_UNDEFINED_PROPERTIES REQUIRED_FILES RESOURCE RESOURCE_LOCK RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK RULE_MESSAGES RUNTIME_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY_DEBUG RUNTIME_OUTPUT_DIRECTORY_RELEASE RUNTIME_OUTPUT_NAME RUNTIME_OUTPUT_NAME_DEBUG RUNTIME_OUTPUT_NAME_RELEASE RUN_SERIAL SKIP_BUILD_RPATH SKIP_RETURN_CODE SOURCES SOURCE_DIR SOVERSION STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_DEBUG STATIC_LIBRARY_FLAGS_RELEASE STRINGS SUFFIX SYMBOLIC TARGET_ARCHIVES_MAY_BE_SHARED_LIBS TARGET_MESSAGES TARGET_SUPPORTS_SHARED_LIBS TEST_INCLUDE_FILE TIMEOUT TYPE USE_FOLDERS VALUE VARIABLES VERSION VISIBILITY_INLINES_HIDDEN VS_DEPLOYMENT_CONTENT VS_DEPLOYMENT_LOCATION VS_DESKTOP_EXTENSIONS_VERSION VS_DOTNET_REFERENCES VS_DOTNET_TARGET_FRAMEWORK_VERSION VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_GLOBAL_ROOTNAMESPACE VS_IOT_EXTENSIONS_VERSION VS_IOT_STARTUP_TASK VS_KEYWORD VS_MOBILE_EXTENSIONS_VERSION VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER VS_SHADER_ENTRYPOINT VS_SHADER_FLAGS VS_SHADER_MODEL VS_SHADER_TYPE VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION VS_WINRT_COMPONENT VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES VS_XAML_TYPE WILL_FAIL WIN32_EXECUTABLE WINDOWS_EXPORT_ALL_SYMBOLS WORKING_DIRECTORY WRAP_EXCLUDE XCODE_EXPLICIT_FILE_TYPE XCODE_LAST_KNOWN_FILE_TYPE XCTEST
+ \ ABSTRACT
+ \ ADDITIONAL_CLEAN_FILES
+ \ ADDITIONAL_MAKE_CLEAN_FILES
+ \ ADVANCED
+ \ ALIASED_TARGET
+ \ ALLOW_DUPLICATE_CUSTOM_TARGETS
+ \ ANDROID_ANT_ADDITIONAL_OPTIONS
+ \ ANDROID_API
+ \ ANDROID_API_MIN
+ \ ANDROID_ARCH
+ \ ANDROID_ASSETS_DIRECTORIES
+ \ ANDROID_GUI
+ \ ANDROID_JAR_DEPENDENCIES
+ \ ANDROID_JAR_DIRECTORIES
+ \ ANDROID_JAVA_SOURCE_DIR
+ \ ANDROID_NATIVE_LIB_DEPENDENCIES
+ \ ANDROID_NATIVE_LIB_DIRECTORIES
+ \ ANDROID_PROCESS_MAX
+ \ ANDROID_PROGUARD
+ \ ANDROID_PROGUARD_CONFIG_PATH
+ \ ANDROID_SECURE_PROPS_PATH
+ \ ANDROID_SKIP_ANT_STEP
+ \ ANDROID_STL_TYPE
+ \ ARCHIVE_OUTPUT_DIRECTORY
+ \ ARCHIVE_OUTPUT_NAME
+ \ ATTACHED_FILES
+ \ ATTACHED_FILES_ON_FAIL
+ \ AUTOGEN_BUILD_DIR
+ \ AUTOGEN_ORIGIN_DEPENDS
+ \ AUTOGEN_PARALLEL
+ \ AUTOGEN_SOURCE_GROUP
+ \ AUTOGEN_TARGETS_FOLDER
+ \ AUTOGEN_TARGET_DEPENDS
+ \ AUTOMOC
+ \ AUTOMOC_COMPILER_PREDEFINES
+ \ AUTOMOC_DEPEND_FILTERS
+ \ AUTOMOC_EXECUTABLE
+ \ AUTOMOC_MACRO_NAMES
+ \ AUTOMOC_MOC_OPTIONS
+ \ AUTOMOC_SOURCE_GROUP
+ \ AUTOMOC_TARGETS_FOLDER
+ \ AUTORCC
+ \ AUTORCC_EXECUTABLE
+ \ AUTORCC_OPTIONS
+ \ AUTORCC_SOURCE_GROUP
+ \ AUTOUIC
+ \ AUTOUIC_EXECUTABLE
+ \ AUTOUIC_OPTIONS
+ \ AUTOUIC_SEARCH_PATHS
+ \ BINARY_DIR
+ \ BUILDSYSTEM_TARGETS
+ \ BUILD_RPATH
+ \ BUILD_RPATH_USE_ORIGIN
+ \ BUILD_WITH_INSTALL_NAME_DIR
+ \ BUILD_WITH_INSTALL_RPATH
+ \ BUNDLE
+ \ BUNDLE_EXTENSION
+ \ CACHE_VARIABLES
+ \ CLEAN_NO_CUSTOM
+ \ CMAKE_CONFIGURE_DEPENDS
+ \ CMAKE_CXX_KNOWN_FEATURES
+ \ CMAKE_C_KNOWN_FEATURES
+ \ CMAKE_ROLE
+ \ COMMON_LANGUAGE_RUNTIME
+ \ COMPATIBLE_INTERFACE_BOOL
+ \ COMPATIBLE_INTERFACE_NUMBER_MAX
+ \ COMPATIBLE_INTERFACE_NUMBER_MIN
+ \ COMPATIBLE_INTERFACE_STRING
+ \ COMPILE_DEFINITIONS
+ \ COMPILE_FEATURES
+ \ COMPILE_FLAGS
+ \ COMPILE_OPTIONS
+ \ COMPILE_PDB_NAME
+ \ COMPILE_PDB_OUTPUT_DIRECTORY
+ \ COST
+ \ CPACK_DESKTOP_SHORTCUTS
+ \ CPACK_NEVER_OVERWRITE
+ \ CPACK_PERMANENT
+ \ CPACK_STARTUP_SHORTCUTS
+ \ CPACK_START_MENU_SHORTCUTS
+ \ CPACK_WIX_ACL
+ \ CROSSCOMPILING_EMULATOR
+ \ CUDA_EXTENSIONS
+ \ CUDA_PTX_COMPILATION
+ \ CUDA_RESOLVE_DEVICE_SYMBOLS
+ \ CUDA_SEPARABLE_COMPILATION
+ \ CUDA_STANDARD
+ \ CUDA_STANDARD_REQUIRED
+ \ CXX_EXTENSIONS
+ \ CXX_STANDARD
+ \ CXX_STANDARD_REQUIRED
+ \ C_EXTENSIONS
+ \ C_STANDARD
+ \ C_STANDARD_REQUIRED
+ \ DEBUG_CONFIGURATIONS
+ \ DEBUG_POSTFIX
+ \ DEFINE_SYMBOL
+ \ DEFINITIONS
+ \ DEPENDS
+ \ DEPLOYMENT_ADDITIONAL_FILES
+ \ DEPLOYMENT_REMOTE_DIRECTORY
+ \ DISABLED
+ \ DISABLED_FEATURES
+ \ DOTNET_TARGET_FRAMEWORK_VERSION
+ \ ECLIPSE_EXTRA_CPROJECT_CONTENTS
+ \ ECLIPSE_EXTRA_NATURES
+ \ ENABLED_FEATURES
+ \ ENABLED_LANGUAGES
+ \ ENABLE_EXPORTS
+ \ ENVIRONMENT
+ \ EXCLUDE_FROM_ALL
+ \ EXCLUDE_FROM_DEFAULT_BUILD
+ \ EXPORT_NAME
+ \ EXPORT_PROPERTIES
+ \ EXTERNAL_OBJECT
+ \ EchoString
+ \ FAIL_REGULAR_EXPRESSION
+ \ FIND_LIBRARY_USE_LIB32_PATHS
+ \ FIND_LIBRARY_USE_LIB64_PATHS
+ \ FIND_LIBRARY_USE_LIBX32_PATHS
+ \ FIND_LIBRARY_USE_OPENBSD_VERSIONING
+ \ FIXTURES_CLEANUP
+ \ FIXTURES_REQUIRED
+ \ FIXTURES_SETUP
+ \ FOLDER
+ \ FRAMEWORK
+ \ FRAMEWORK_VERSION
+ \ Fortran_FORMAT
+ \ Fortran_MODULE_DIRECTORY
+ \ GENERATED
+ \ GENERATOR_FILE_NAME
+ \ GENERATOR_IS_MULTI_CONFIG
+ \ GHS_INTEGRITY_APP
+ \ GHS_NO_SOURCE_GROUP_FILE
+ \ GLOBAL_DEPENDS_DEBUG_MODE
+ \ GLOBAL_DEPENDS_NO_CYCLES
+ \ GNUtoMS
+ \ HAS_CXX
+ \ HEADER_FILE_ONLY
+ \ HELPSTRING
+ \ IMPLICIT_DEPENDS_INCLUDE_TRANSFORM
+ \ IMPORTED
+ \ IMPORTED_COMMON_LANGUAGE_RUNTIME
+ \ IMPORTED_CONFIGURATIONS
+ \ IMPORTED_GLOBAL
+ \ IMPORTED_IMPLIB
+ \ IMPORTED_LIBNAME
+ \ IMPORTED_LINK_DEPENDENT_LIBRARIES
+ \ IMPORTED_LINK_INTERFACE_LANGUAGES
+ \ IMPORTED_LINK_INTERFACE_LIBRARIES
+ \ IMPORTED_LINK_INTERFACE_MULTIPLICITY
+ \ IMPORTED_LOCATION
+ \ IMPORTED_NO_SONAME
+ \ IMPORTED_OBJECTS
+ \ IMPORTED_SONAME
+ \ IMPORT_PREFIX
+ \ IMPORT_SUFFIX
+ \ INCLUDE_DIRECTORIES
+ \ INCLUDE_REGULAR_EXPRESSION
+ \ INSTALL_NAME_DIR
+ \ INSTALL_RPATH
+ \ INSTALL_RPATH_USE_LINK_PATH
+ \ INTERFACE_AUTOUIC_OPTIONS
+ \ INTERFACE_COMPILE_DEFINITIONS
+ \ INTERFACE_COMPILE_FEATURES
+ \ INTERFACE_COMPILE_OPTIONS
+ \ INTERFACE_INCLUDE_DIRECTORIES
+ \ INTERFACE_LINK_DEPENDS
+ \ INTERFACE_LINK_DIRECTORIES
+ \ INTERFACE_LINK_LIBRARIES
+ \ INTERFACE_LINK_OPTIONS
+ \ INTERFACE_POSITION_INDEPENDENT_CODE
+ \ INTERFACE_SOURCES
+ \ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
+ \ INTERPROCEDURAL_OPTIMIZATION
+ \ IN_TRY_COMPILE
+ \ IOS_INSTALL_COMBINED
+ \ JOB_POOLS
+ \ JOB_POOL_COMPILE
+ \ JOB_POOL_LINK
+ \ KEEP_EXTENSION
+ \ LABELS
+ \ LANGUAGE
+ \ LIBRARY_OUTPUT_DIRECTORY
+ \ LIBRARY_OUTPUT_NAME
+ \ LINKER_LANGUAGE
+ \ LINK_DEPENDS
+ \ LINK_DEPENDS_NO_SHARED
+ \ LINK_DIRECTORIES
+ \ LINK_FLAGS
+ \ LINK_INTERFACE_LIBRARIES
+ \ LINK_INTERFACE_MULTIPLICITY
+ \ LINK_LIBRARIES
+ \ LINK_OPTIONS
+ \ LINK_SEARCH_END_STATIC
+ \ LINK_SEARCH_START_STATIC
+ \ LINK_WHAT_YOU_USE
+ \ LISTFILE_STACK
+ \ LOCATION
+ \ MACOSX_BUNDLE
+ \ MACOSX_BUNDLE_INFO_PLIST
+ \ MACOSX_FRAMEWORK_INFO_PLIST
+ \ MACOSX_PACKAGE_LOCATION
+ \ MACOSX_RPATH
+ \ MACROS
+ \ MANUALLY_ADDED_DEPENDENCIES
+ \ MEASUREMENT
+ \ MODIFIED
+ \ MSVC_RUNTIME_LIBRARY
+ \ NAME
+ \ NO_SONAME
+ \ NO_SYSTEM_FROM_IMPORTED
+ \ OBJECT_DEPENDS
+ \ OBJECT_OUTPUTS
+ \ OSX_ARCHITECTURES
+ \ OUTPUT_NAME
+ \ PACKAGES_FOUND
+ \ PACKAGES_NOT_FOUND
+ \ PARENT_DIRECTORY
+ \ PASS_REGULAR_EXPRESSION
+ \ PDB_NAME
+ \ PDB_OUTPUT_DIRECTORY
+ \ POSITION_INDEPENDENT_CODE
+ \ POST_INSTALL_SCRIPT
+ \ PREDEFINED_TARGETS_FOLDER
+ \ PREFIX
+ \ PRE_INSTALL_SCRIPT
+ \ PRIVATE_HEADER
+ \ PROCESSORS
+ \ PROCESSOR_AFFINITY
+ \ PROJECT_LABEL
+ \ PUBLIC_HEADER
+ \ REPORT_UNDEFINED_PROPERTIES
+ \ REQUIRED_FILES
+ \ RESOURCE
+ \ RESOURCE_LOCK
+ \ RULE_LAUNCH_COMPILE
+ \ RULE_LAUNCH_CUSTOM
+ \ RULE_LAUNCH_LINK
+ \ RULE_MESSAGES
+ \ RUNTIME_OUTPUT_DIRECTORY
+ \ RUNTIME_OUTPUT_NAME
+ \ RUN_SERIAL
+ \ SKIP_AUTOGEN
+ \ SKIP_AUTOMOC
+ \ SKIP_AUTORCC
+ \ SKIP_AUTOUIC
+ \ SKIP_BUILD_RPATH
+ \ SKIP_REGULAR_EXPRESSION
+ \ SKIP_RETURN_CODE
+ \ SOURCES
+ \ SOURCE_DIR
+ \ SOVERSION
+ \ STATIC_LIBRARY_FLAGS
+ \ STATIC_LIBRARY_OPTIONS
+ \ STRINGS
+ \ SUBDIRECTORIES
+ \ SUFFIX
+ \ SYMBOLIC
+ \ Swift_DEPENDENCIES_FILE
+ \ Swift_DIAGNOSTICS_FILE
+ \ Swift_MODULE_DIRECTORY
+ \ Swift_MODULE_NAME
+ \ TARGET_ARCHIVES_MAY_BE_SHARED_LIBS
+ \ TARGET_MESSAGES
+ \ TARGET_SUPPORTS_SHARED_LIBS
+ \ TESTS
+ \ TEST_INCLUDE_FILE
+ \ TEST_INCLUDE_FILES
+ \ TIMEOUT
+ \ TIMEOUT_AFTER_MATCH
+ \ TYPE
+ \ USE_FOLDERS
+ \ VALUE
+ \ VARIABLES
+ \ VERSION
+ \ VISIBILITY_INLINES_HIDDEN
+ \ VS_CONFIGURATION_TYPE
+ \ VS_COPY_TO_OUT_DIR
+ \ VS_DEBUGGER_COMMAND
+ \ VS_DEBUGGER_COMMAND_ARGUMENTS
+ \ VS_DEBUGGER_ENVIRONMENT
+ \ VS_DEBUGGER_WORKING_DIRECTORY
+ \ VS_DEPLOYMENT_CONTENT
+ \ VS_DEPLOYMENT_LOCATION
+ \ VS_DESKTOP_EXTENSIONS_VERSION
+ \ VS_DOTNET_REFERENCES
+ \ VS_DOTNET_REFERENCES_COPY_LOCAL
+ \ VS_DOTNET_TARGET_FRAMEWORK_VERSION
+ \ VS_GLOBAL_KEYWORD
+ \ VS_GLOBAL_PROJECT_TYPES
+ \ VS_GLOBAL_ROOTNAMESPACE
+ \ VS_INCLUDE_IN_VSIX
+ \ VS_IOT_EXTENSIONS_VERSION
+ \ VS_IOT_STARTUP_TASK
+ \ VS_JUST_MY_CODE_DEBUGGING
+ \ VS_KEYWORD
+ \ VS_MOBILE_EXTENSIONS_VERSION
+ \ VS_NO_SOLUTION_DEPLOY
+ \ VS_PROJECT_IMPORT
+ \ VS_RESOURCE_GENERATOR
+ \ VS_SCC_AUXPATH
+ \ VS_SCC_LOCALPATH
+ \ VS_SCC_PROJECTNAME
+ \ VS_SCC_PROVIDER
+ \ VS_SDK_REFERENCES
+ \ VS_SHADER_DISABLE_OPTIMIZATIONS
+ \ VS_SHADER_ENABLE_DEBUG
+ \ VS_SHADER_ENTRYPOINT
+ \ VS_SHADER_FLAGS
+ \ VS_SHADER_MODEL
+ \ VS_SHADER_OBJECT_FILE_NAME
+ \ VS_SHADER_OUTPUT_HEADER_FILE
+ \ VS_SHADER_TYPE
+ \ VS_SHADER_VARIABLE_NAME
+ \ VS_STARTUP_PROJECT
+ \ VS_TOOL_OVERRIDE
+ \ VS_USER_PROPS
+ \ VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION
+ \ VS_WINRT_COMPONENT
+ \ VS_WINRT_EXTENSIONS
+ \ VS_WINRT_REFERENCES
+ \ VS_XAML_TYPE
+ \ WILL_FAIL
+ \ WIN32_EXECUTABLE
+ \ WINDOWS_EXPORT_ALL_SYMBOLS
+ \ WORKING_DIRECTORY
+ \ WRAP_EXCLUDE
+ \ XCODE_EMIT_EFFECTIVE_PLATFORM_NAME
+ \ XCODE_EXPLICIT_FILE_TYPE
+ \ XCODE_FILE_ATTRIBUTES
+ \ XCODE_GENERATE_SCHEME
+ \ XCODE_LAST_KNOWN_FILE_TYPE
+ \ XCODE_PRODUCT_TYPE
+ \ XCODE_SCHEME_ADDRESS_SANITIZER
+ \ XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN
+ \ XCODE_SCHEME_ARGUMENTS
+ \ XCODE_SCHEME_DEBUG_AS_ROOT
+ \ XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER
+ \ XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS
+ \ XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE
+ \ XCODE_SCHEME_ENVIRONMENT
+ \ XCODE_SCHEME_EXECUTABLE
+ \ XCODE_SCHEME_GUARD_MALLOC
+ \ XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP
+ \ XCODE_SCHEME_MALLOC_GUARD_EDGES
+ \ XCODE_SCHEME_MALLOC_SCRIBBLE
+ \ XCODE_SCHEME_MALLOC_STACK
+ \ XCODE_SCHEME_THREAD_SANITIZER
+ \ XCODE_SCHEME_THREAD_SANITIZER_STOP
+ \ XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER
+ \ XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP
+ \ XCODE_SCHEME_ZOMBIE_OBJECTS
+ \ XCTEST
syn keyword cmakeVariable contained
- \ ANDROID APPLE BORLAND BUILD_SHARED_LIBS CMAKE_ABSOLUTE_DESTINATION_FILES CMAKE_ANDROID_ANT_ADDITIONAL_OPTIONS CMAKE_ANDROID_API CMAKE_ANDROID_API_MIN CMAKE_ANDROID_ARCH CMAKE_ANDROID_ARCH_ABI CMAKE_ANDROID_ARM_MODE CMAKE_ANDROID_ARM_NEON CMAKE_ANDROID_ASSETS_DIRECTORIES CMAKE_ANDROID_GUI CMAKE_ANDROID_JAR_DEPENDENCIES CMAKE_ANDROID_JAR_DIRECTORIES CMAKE_ANDROID_JAVA_SOURCE_DIR CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES CMAKE_ANDROID_NDK CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION CMAKE_ANDROID_PROCESS_MAX CMAKE_ANDROID_PROGUARD CMAKE_ANDROID_PROGUARD_CONFIG_PATH CMAKE_ANDROID_SECURE_PROPS_PATH CMAKE_ANDROID_SKIP_ANT_STEP CMAKE_ANDROID_STANDALONE_TOOLCHAIN CMAKE_ANDROID_STL_TYPE CMAKE_APPBUNDLE_PATH CMAKE_AR CMAKE_ARCHIVE_OUTPUT_DIRECTORY CMAKE_ARGC CMAKE_ARGV0 CMAKE_AUTOMOC CMAKE_AUTOMOC_DEPEND_FILTERS CMAKE_AUTOMOC_MOC_OPTIONS CMAKE_AUTOMOC_RELAXED_MODE CMAKE_AUTORCC CMAKE_AUTORCC_OPTIONS CMAKE_AUTOUIC CMAKE_AUTOUIC_OPTIONS CMAKE_AUTOUIC_SEARCH_PATHS CMAKE_BACKWARDS_COMPATIBILITY CMAKE_BINARY_DIR CMAKE_BUILD_RPATH CMAKE_BUILD_TOOL CMAKE_BUILD_TYPE CMAKE_BUILD_WITH_INSTALL_NAME_DIR CMAKE_BUILD_WITH_INSTALL_RPATH CMAKE_CACHEFILE_DIR CMAKE_CACHE_MAJOR_VERSION CMAKE_CACHE_MINOR_VERSION CMAKE_CACHE_PATCH_VERSION CMAKE_CFG_INTDIR CMAKE_CL_64 CMAKE_CODELITE_USE_TARGETS CMAKE_COLOR_MAKEFILE CMAKE_COMMAND CMAKE_COMPILER_2005 CMAKE_COMPILER_IS_GNUCC CMAKE_COMPILER_IS_GNUCXX CMAKE_COMPILER_IS_GNUG77 CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY CMAKE_CONFIGURATION_TYPES CMAKE_CROSSCOMPILING CMAKE_CROSSCOMPILING_EMULATOR CMAKE_CTEST_COMMAND CMAKE_CUDA_EXTENSIONS CMAKE_CUDA_STANDARD CMAKE_CUDA_STANDARD_REQUIRED CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES CMAKE_CURRENT_BINARY_DIR CMAKE_CURRENT_LIST_DIR CMAKE_CURRENT_LIST_FILE CMAKE_CURRENT_LIST_LINE CMAKE_CURRENT_SOURCE_DIR CMAKE_CXX_COMPILE_FEATURES CMAKE_CXX_EXTENSIONS CMAKE_CXX_STANDARD CMAKE_CXX_STANDARD_REQUIRED CMAKE_C_COMPILE_FEATURES CMAKE_C_EXTENSIONS CMAKE_C_STANDARD CMAKE_C_STANDARD_REQUIRED CMAKE_DEBUG_POSTFIX CMAKE_DEBUG_TARGET_PROPERTIES CMAKE_DEPENDS_IN_PROJECT_ONLY CMAKE_DL_LIBS CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT CMAKE_ECLIPSE_MAKE_ARGUMENTS CMAKE_ECLIPSE_VERSION CMAKE_EDIT_COMMAND CMAKE_ENABLE_EXPORTS CMAKE_ERROR_DEPRECATED CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION CMAKE_EXECUTABLE_SUFFIX CMAKE_EXE_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS_INIT CMAKE_EXPORT_COMPILE_COMMANDS CMAKE_EXPORT_NO_PACKAGE_REGISTRY CMAKE_EXTRA_GENERATOR CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES CMAKE_FIND_APPBUNDLE CMAKE_FIND_FRAMEWORK CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX CMAKE_FIND_LIBRARY_PREFIXES CMAKE_FIND_LIBRARY_SUFFIXES CMAKE_FIND_NO_INSTALL_PREFIX CMAKE_FIND_PACKAGE_NAME CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY CMAKE_FIND_PACKAGE_SORT_DIRECTION CMAKE_FIND_PACKAGE_SORT_ORDER CMAKE_FIND_PACKAGE_WARN_NO_MODULE CMAKE_FIND_ROOT_PATH CMAKE_FIND_ROOT_PATH_MODE_INCLUDE CMAKE_FIND_ROOT_PATH_MODE_LIBRARY CMAKE_FIND_ROOT_PATH_MODE_PACKAGE CMAKE_FIND_ROOT_PATH_MODE_PROGRAM CMAKE_FRAMEWORK_PATH CMAKE_Fortran_FORMAT CMAKE_Fortran_MODDIR_DEFAULT CMAKE_Fortran_MODDIR_FLAG CMAKE_Fortran_MODOUT_FLAG CMAKE_Fortran_MODULE_DIRECTORY CMAKE_GENERATOR CMAKE_GENERATOR_PLATFORM CMAKE_GENERATOR_TOOLSET CMAKE_GNUtoMS CMAKE_HOME_DIRECTORY CMAKE_HOST_APPLE CMAKE_HOST_SOLARIS CMAKE_HOST_SYSTEM CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_PROCESSOR CMAKE_HOST_SYSTEM_VERSION CMAKE_HOST_UNIX CMAKE_HOST_WIN32 CMAKE_IGNORE_PATH CMAKE_IMPORT_LIBRARY_PREFIX CMAKE_IMPORT_LIBRARY_SUFFIX CMAKE_INCLUDE_CURRENT_DIR CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE CMAKE_INCLUDE_DIRECTORIES_BEFORE CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE CMAKE_INCLUDE_PATH CMAKE_INSTALL_DEFAULT_COMPONENT_NAME CMAKE_INSTALL_MESSAGE CMAKE_INSTALL_NAME_DIR CMAKE_INSTALL_PREFIX CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT CMAKE_INSTALL_RPATH CMAKE_INSTALL_RPATH_USE_LINK_PATH CMAKE_INTERNAL_PLATFORM_ABI CMAKE_INTERPROCEDURAL_OPTIMIZATION CMAKE_IOS_INSTALL_COMBINED CMAKE_JOB_POOL_COMPILE CMAKE_JOB_POOL_LINK CMAKE_LIBRARY_ARCHITECTURE CMAKE_LIBRARY_ARCHITECTURE_REGEX CMAKE_LIBRARY_OUTPUT_DIRECTORY CMAKE_LIBRARY_PATH CMAKE_LIBRARY_PATH_FLAG CMAKE_LINK_DEF_FILE_FLAG CMAKE_LINK_DEPENDS_NO_SHARED CMAKE_LINK_INTERFACE_LIBRARIES CMAKE_LINK_LIBRARY_FILE_FLAG CMAKE_LINK_LIBRARY_FLAG CMAKE_LINK_LIBRARY_SUFFIX CMAKE_LINK_SEARCH_END_STATIC CMAKE_LINK_SEARCH_START_STATIC CMAKE_LINK_WHAT_YOU_USE CMAKE_MACOSX_BUNDLE CMAKE_MACOSX_RPATH CMAKE_MAJOR_VERSION CMAKE_MAKE_PROGRAM CMAKE_MATCH_COUNT CMAKE_MFC_FLAG CMAKE_MINIMUM_REQUIRED_VERSION CMAKE_MINOR_VERSION CMAKE_MODULE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS_INIT CMAKE_MODULE_PATH CMAKE_NINJA_OUTPUT_PATH_PREFIX CMAKE_NOT_USING_CONFIG_FLAGS CMAKE_NO_BUILTIN_CHRPATH CMAKE_NO_SYSTEM_FROM_IMPORTED CMAKE_OBJECT_PATH_MAX CMAKE_OSX_ARCHITECTURES CMAKE_OSX_DEPLOYMENT_TARGET CMAKE_OSX_SYSROOT CMAKE_PARENT_LIST_FILE CMAKE_PATCH_VERSION CMAKE_PDB_OUTPUT_DIRECTORY CMAKE_POSITION_INDEPENDENT_CODE CMAKE_PREFIX_PATH CMAKE_PROGRAM_PATH CMAKE_PROJECT_DESCRIPTION CMAKE_PROJECT_NAME CMAKE_RANLIB CMAKE_ROOT CMAKE_RUNTIME_OUTPUT_DIRECTORY CMAKE_SCRIPT_MODE_FILE CMAKE_SHARED_LIBRARY_PREFIX CMAKE_SHARED_LIBRARY_SUFFIX CMAKE_SHARED_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS_INIT CMAKE_SHARED_MODULE_PREFIX CMAKE_SHARED_MODULE_SUFFIX CMAKE_SIZEOF_VOID_P CMAKE_SKIP_BUILD_RPATH CMAKE_SKIP_INSTALL_ALL_DEPENDENCY CMAKE_SKIP_INSTALL_RPATH CMAKE_SKIP_INSTALL_RULES CMAKE_SKIP_RPATH CMAKE_SOURCE_DIR CMAKE_STAGING_PREFIX CMAKE_STATIC_LIBRARY_PREFIX CMAKE_STATIC_LIBRARY_SUFFIX CMAKE_STATIC_LINKER_FLAGS CMAKE_STATIC_LINKER_FLAGS_INIT CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE CMAKE_SYSROOT CMAKE_SYSTEM CMAKE_SYSTEM_APPBUNDLE_PATH CMAKE_SYSTEM_FRAMEWORK_PATH CMAKE_SYSTEM_IGNORE_PATH CMAKE_SYSTEM_INCLUDE_PATH CMAKE_SYSTEM_LIBRARY_PATH CMAKE_SYSTEM_NAME CMAKE_SYSTEM_PREFIX_PATH CMAKE_SYSTEM_PROCESSOR CMAKE_SYSTEM_PROGRAM_PATH CMAKE_SYSTEM_VERSION CMAKE_Swift_LANGUAGE_VERSION CMAKE_TOOLCHAIN_FILE CMAKE_TRY_COMPILE_CONFIGURATION CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_TRY_COMPILE_TARGET_TYPE CMAKE_TWEAK_VERSION CMAKE_USER_MAKE_RULES_OVERRIDE CMAKE_USE_RELATIVE_PATHS CMAKE_VERBOSE_MAKEFILE CMAKE_VERSION CMAKE_VISIBILITY_INLINES_HIDDEN CMAKE_VS_DEVENV_COMMAND CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD CMAKE_VS_INTEL_Fortran_PROJECT_VERSION CMAKE_VS_MSBUILD_COMMAND CMAKE_VS_NsightTegra_VERSION CMAKE_VS_PLATFORM_NAME CMAKE_VS_PLATFORM_TOOLSET CMAKE_VS_PLATFORM_TOOLSET_CUDA CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION CMAKE_WARN_DEPRECATED CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION CMAKE_WIN32_EXECUTABLE CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS CMAKE_XCODE_GENERATE_SCHEME CMAKE_XCODE_PLATFORM_TOOLSET CPACK_ABSOLUTE_DESTINATION_FILES CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION CPACK_INCLUDE_TOPLEVEL_DIRECTORY CPACK_INSTALL_SCRIPT CPACK_PACKAGING_INSTALL_PREFIX CPACK_SET_DESTDIR CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION CTEST_BINARY_DIRECTORY CTEST_BUILD_COMMAND CTEST_BUILD_NAME CTEST_BZR_COMMAND CTEST_BZR_UPDATE_OPTIONS CTEST_CHANGE_ID CTEST_CHECKOUT_COMMAND CTEST_CONFIGURATION_TYPE CTEST_CONFIGURE_COMMAND CTEST_COVERAGE_COMMAND CTEST_COVERAGE_EXTRA_FLAGS CTEST_CURL_OPTIONS CTEST_CUSTOM_COVERAGE_EXCLUDE CTEST_CUSTOM_ERROR_EXCEPTION CTEST_CUSTOM_ERROR_MATCH CTEST_CUSTOM_ERROR_POST_CONTEXT CTEST_CUSTOM_ERROR_PRE_CONTEXT CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE CTEST_CUSTOM_MEMCHECK_IGNORE CTEST_CUSTOM_POST_MEMCHECK CTEST_CUSTOM_POST_TEST CTEST_CUSTOM_PRE_MEMCHECK CTEST_CUSTOM_PRE_TEST CTEST_CUSTOM_TEST_IGNORE CTEST_CUSTOM_WARNING_EXCEPTION CTEST_CUSTOM_WARNING_MATCH CTEST_CVS_CHECKOUT CTEST_CVS_COMMAND CTEST_CVS_UPDATE_OPTIONS CTEST_DROP_LOCATION CTEST_DROP_METHOD CTEST_DROP_SITE CTEST_DROP_SITE_CDASH CTEST_DROP_SITE_PASSWORD CTEST_DROP_SITE_USER CTEST_EXTRA_COVERAGE_GLOB CTEST_GIT_COMMAND CTEST_GIT_INIT_SUBMODULES CTEST_GIT_UPDATE_CUSTOM CTEST_GIT_UPDATE_OPTIONS CTEST_HG_COMMAND CTEST_HG_UPDATE_OPTIONS CTEST_MEMORYCHECK_COMMAND CTEST_MEMORYCHECK_COMMAND_OPTIONS CTEST_MEMORYCHECK_SANITIZER_OPTIONS CTEST_MEMORYCHECK_SUPPRESSIONS_FILE CTEST_MEMORYCHECK_TYPE CTEST_NIGHTLY_START_TIME CTEST_P4_CLIENT CTEST_P4_COMMAND CTEST_P4_OPTIONS CTEST_P4_UPDATE_OPTIONS CTEST_SCP_COMMAND CTEST_SITE CTEST_SOURCE_DIRECTORY CTEST_SVN_COMMAND CTEST_SVN_OPTIONS CTEST_SVN_UPDATE_OPTIONS CTEST_TEST_LOAD CTEST_TEST_TIMEOUT CTEST_TRIGGER_SITE CTEST_UPDATE_COMMAND CTEST_UPDATE_OPTIONS CTEST_UPDATE_VERSION_ONLY CTEST_USE_LAUNCHERS CYGWIN ENV EXECUTABLE_OUTPUT_PATH GHS-MULTI LIBRARY_OUTPUT_PATH MINGW MSVC MSVC10 MSVC11 MSVC12 MSVC14 MSVC60 MSVC70 MSVC71 MSVC80 MSVC90 MSVC_IDE MSVC_VERSION PROJECT_BINARY_DIR PROJECT_DESCRIPTION PROJECT_NAME PROJECT_SOURCE_DIR PROJECT_VERSION PROJECT_VERSION_MAJOR PROJECT_VERSION_MINOR PROJECT_VERSION_PATCH PROJECT_VERSION_TWEAK UNIX WIN32 WINCE WINDOWS_PHONE WINDOWS_STORE XCODE XCODE_VERSION
+ \ ANDROID
+ \ APPLE
+ \ BORLAND
+ \ BUILD_SHARED_LIBS
+ \ CACHE
+ \ CMAKE_ABSOLUTE_DESTINATION_FILES
+ \ CMAKE_ANDROID_ANT_ADDITIONAL_OPTIONS
+ \ CMAKE_ANDROID_API
+ \ CMAKE_ANDROID_API_MIN
+ \ CMAKE_ANDROID_ARCH
+ \ CMAKE_ANDROID_ARCH_ABI
+ \ CMAKE_ANDROID_ARM_MODE
+ \ CMAKE_ANDROID_ARM_NEON
+ \ CMAKE_ANDROID_ASSETS_DIRECTORIES
+ \ CMAKE_ANDROID_GUI
+ \ CMAKE_ANDROID_JAR_DEPENDENCIES
+ \ CMAKE_ANDROID_JAR_DIRECTORIES
+ \ CMAKE_ANDROID_JAVA_SOURCE_DIR
+ \ CMAKE_ANDROID_NATIVE_LIB_DEPENDENCIES
+ \ CMAKE_ANDROID_NATIVE_LIB_DIRECTORIES
+ \ CMAKE_ANDROID_NDK
+ \ CMAKE_ANDROID_NDK_DEPRECATED_HEADERS
+ \ CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG
+ \ CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION
+ \ CMAKE_ANDROID_PROCESS_MAX
+ \ CMAKE_ANDROID_PROGUARD
+ \ CMAKE_ANDROID_PROGUARD_CONFIG_PATH
+ \ CMAKE_ANDROID_SECURE_PROPS_PATH
+ \ CMAKE_ANDROID_SKIP_ANT_STEP
+ \ CMAKE_ANDROID_STANDALONE_TOOLCHAIN
+ \ CMAKE_ANDROID_STL_TYPE
+ \ CMAKE_APPBUNDLE_PATH
+ \ CMAKE_AR
+ \ CMAKE_ARCHIVE_OUTPUT_DIRECTORY
+ \ CMAKE_ARGC
+ \ CMAKE_ARGV0
+ \ CMAKE_ASM
+ \ CMAKE_ASM_ANDROID_TOOLCHAIN_MACHINE
+ \ CMAKE_ASM_ANDROID_TOOLCHAIN_PREFIX
+ \ CMAKE_ASM_ANDROID_TOOLCHAIN_SUFFIX
+ \ CMAKE_ASM_ARCHIVE_APPEND
+ \ CMAKE_ASM_ARCHIVE_CREATE
+ \ CMAKE_ASM_ARCHIVE_FINISH
+ \ CMAKE_ASM_CLANG_TIDY
+ \ CMAKE_ASM_COMPILER
+ \ CMAKE_ASM_COMPILER_ABI
+ \ CMAKE_ASM_COMPILER_AR
+ \ CMAKE_ASM_COMPILER_ARCHITECTURE_ID
+ \ CMAKE_ASM_COMPILER_EXTERNAL_TOOLCHAIN
+ \ CMAKE_ASM_COMPILER_ID
+ \ CMAKE_ASM_COMPILER_LAUNCHER
+ \ CMAKE_ASM_COMPILER_LOADED
+ \ CMAKE_ASM_COMPILER_PREDEFINES_COMMAND
+ \ CMAKE_ASM_COMPILER_RANLIB
+ \ CMAKE_ASM_COMPILER_TARGET
+ \ CMAKE_ASM_COMPILER_VERSION
+ \ CMAKE_ASM_COMPILER_VERSION_INTERNAL
+ \ CMAKE_ASM_COMPILE_OBJECT
+ \ CMAKE_ASM_CPPCHECK
+ \ CMAKE_ASM_CPPLINT
+ \ CMAKE_ASM_CREATE_SHARED_LIBRARY
+ \ CMAKE_ASM_CREATE_SHARED_MODULE
+ \ CMAKE_ASM_CREATE_STATIC_LIBRARY
+ \ CMAKE_ASM_FLAGS
+ \ CMAKE_ASM_FLAGS_DEBUG
+ \ CMAKE_ASM_FLAGS_DEBUG_INIT
+ \ CMAKE_ASM_FLAGS_INIT
+ \ CMAKE_ASM_FLAGS_MINSIZEREL
+ \ CMAKE_ASM_FLAGS_MINSIZEREL_INIT
+ \ CMAKE_ASM_FLAGS_RELEASE
+ \ CMAKE_ASM_FLAGS_RELEASE_INIT
+ \ CMAKE_ASM_FLAGS_RELWITHDEBINFO
+ \ CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT
+ \ CMAKE_ASM_IGNORE_EXTENSIONS
+ \ CMAKE_ASM_IMPLICIT_INCLUDE_DIRECTORIES
+ \ CMAKE_ASM_IMPLICIT_LINK_DIRECTORIES
+ \ CMAKE_ASM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
+ \ CMAKE_ASM_IMPLICIT_LINK_LIBRARIES
+ \ CMAKE_ASM_INCLUDE_WHAT_YOU_USE
+ \ CMAKE_ASM_INIT
+ \ CMAKE_ASM_LIBRARY_ARCHITECTURE
+ \ CMAKE_ASM_LINKER_PREFERENCE
+ \ CMAKE_ASM_LINKER_PREFERENCE_PROPAGATES
+ \ CMAKE_ASM_LINKER_WRAPPER_FLAG
+ \ CMAKE_ASM_LINKER_WRAPPER_FLAG_SEP
+ \ CMAKE_ASM_LINK_EXECUTABLE
+ \ CMAKE_ASM_MASM
+ \ CMAKE_ASM_MASM_ANDROID_TOOLCHAIN_MACHINE
+ \ CMAKE_ASM_MASM_ANDROID_TOOLCHAIN_PREFIX
+ \ CMAKE_ASM_MASM_ANDROID_TOOLCHAIN_SUFFIX
+ \ CMAKE_ASM_MASM_ARCHIVE_APPEND
+ \ CMAKE_ASM_MASM_ARCHIVE_CREATE
+ \ CMAKE_ASM_MASM_ARCHIVE_FINISH
+ \ CMAKE_ASM_MASM_CLANG_TIDY
+ \ CMAKE_ASM_MASM_COMPILER
+ \ CMAKE_ASM_MASM_COMPILER_ABI
+ \ CMAKE_ASM_MASM_COMPILER_AR
+ \ CMAKE_ASM_MASM_COMPILER_ARCHITECTURE_ID
+ \ CMAKE_ASM_MASM_COMPILER_EXTERNAL_TOOLCHAIN
+ \ CMAKE_ASM_MASM_COMPILER_ID
+ \ CMAKE_ASM_MASM_COMPILER_LAUNCHER
+ \ CMAKE_ASM_MASM_COMPILER_LOADED
+ \ CMAKE_ASM_MASM_COMPILER_PREDEFINES_COMMAND
+ \ CMAKE_ASM_MASM_COMPILER_RANLIB
+ \ CMAKE_ASM_MASM_COMPILER_TARGET
+ \ CMAKE_ASM_MASM_COMPILER_VERSION
+ \ CMAKE_ASM_MASM_COMPILER_VERSION_INTERNAL
+ \ CMAKE_ASM_MASM_COMPILE_OBJECT
+ \ CMAKE_ASM_MASM_CPPCHECK
+ \ CMAKE_ASM_MASM_CPPLINT
+ \ CMAKE_ASM_MASM_CREATE_SHARED_LIBRARY
+ \ CMAKE_ASM_MASM_CREATE_SHARED_MODULE
+ \ CMAKE_ASM_MASM_CREATE_STATIC_LIBRARY
+ \ CMAKE_ASM_MASM_FLAGS
+ \ CMAKE_ASM_MASM_FLAGS_DEBUG
+ \ CMAKE_ASM_MASM_FLAGS_DEBUG_INIT
+ \ CMAKE_ASM_MASM_FLAGS_INIT
+ \ CMAKE_ASM_MASM_FLAGS_MINSIZEREL
+ \ CMAKE_ASM_MASM_FLAGS_MINSIZEREL_INIT
+ \ CMAKE_ASM_MASM_FLAGS_RELEASE
+ \ CMAKE_ASM_MASM_FLAGS_RELEASE_INIT
+ \ CMAKE_ASM_MASM_FLAGS_RELWITHDEBINFO
+ \ CMAKE_ASM_MASM_FLAGS_RELWITHDEBINFO_INIT
+ \ CMAKE_ASM_MASM_IGNORE_EXTENSIONS
+ \ CMAKE_ASM_MASM_IMPLICIT_INCLUDE_DIRECTORIES
+ \ CMAKE_ASM_MASM_IMPLICIT_LINK_DIRECTORIES
+ \ CMAKE_ASM_MASM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
+ \ CMAKE_ASM_MASM_IMPLICIT_LINK_LIBRARIES
+ \ CMAKE_ASM_MASM_INCLUDE_WHAT_YOU_USE
+ \ CMAKE_ASM_MASM_INIT
+ \ CMAKE_ASM_MASM_LIBRARY_ARCHITECTURE
+ \ CMAKE_ASM_MASM_LINKER_PREFERENCE
+ \ CMAKE_ASM_MASM_LINKER_PREFERENCE_PROPAGATES
+ \ CMAKE_ASM_MASM_LINKER_WRAPPER_FLAG
+ \ CMAKE_ASM_MASM_LINKER_WRAPPER_FLAG_SEP
+ \ CMAKE_ASM_MASM_LINK_EXECUTABLE
+ \ CMAKE_ASM_MASM_OUTPUT_EXTENSION
+ \ CMAKE_ASM_MASM_PLATFORM_ID
+ \ CMAKE_ASM_MASM_SIMULATE_ID
+ \ CMAKE_ASM_MASM_SIMULATE_VERSION
+ \ CMAKE_ASM_MASM_SIZEOF_DATA_PTR
+ \ CMAKE_ASM_MASM_SOURCE_FILE_EXTENSIONS
+ \ CMAKE_ASM_MASM_STANDARD_INCLUDE_DIRECTORIES
+ \ CMAKE_ASM_MASM_STANDARD_LIBRARIES
+ \ CMAKE_ASM_MASM_VISIBILITY_PRESET
+ \ CMAKE_ASM_NASM
+ \ CMAKE_ASM_NASM_ANDROID_TOOLCHAIN_MACHINE
+ \ CMAKE_ASM_NASM_ANDROID_TOOLCHAIN_PREFIX
+ \ CMAKE_ASM_NASM_ANDROID_TOOLCHAIN_SUFFIX
+ \ CMAKE_ASM_NASM_ARCHIVE_APPEND
+ \ CMAKE_ASM_NASM_ARCHIVE_CREATE
+ \ CMAKE_ASM_NASM_ARCHIVE_FINISH
+ \ CMAKE_ASM_NASM_CLANG_TIDY
+ \ CMAKE_ASM_NASM_COMPILER
+ \ CMAKE_ASM_NASM_COMPILER_ABI
+ \ CMAKE_ASM_NASM_COMPILER_AR
+ \ CMAKE_ASM_NASM_COMPILER_ARCHITECTURE_ID
+ \ CMAKE_ASM_NASM_COMPILER_EXTERNAL_TOOLCHAIN
+ \ CMAKE_ASM_NASM_COMPILER_ID
+ \ CMAKE_ASM_NASM_COMPILER_LAUNCHER
+ \ CMAKE_ASM_NASM_COMPILER_LOADED
+ \ CMAKE_ASM_NASM_COMPILER_PREDEFINES_COMMAND
+ \ CMAKE_ASM_NASM_COMPILER_RANLIB
+ \ CMAKE_ASM_NASM_COMPILER_TARGET
+ \ CMAKE_ASM_NASM_COMPILER_VERSION
+ \ CMAKE_ASM_NASM_COMPILER_VERSION_INTERNAL
+ \ CMAKE_ASM_NASM_COMPILE_OBJECT
+ \ CMAKE_ASM_NASM_CPPCHECK
+ \ CMAKE_ASM_NASM_CPPLINT
+ \ CMAKE_ASM_NASM_CREATE_SHARED_LIBRARY
+ \ CMAKE_ASM_NASM_CREATE_SHARED_MODULE
+ \ CMAKE_ASM_NASM_CREATE_STATIC_LIBRARY
+ \ CMAKE_ASM_NASM_FLAGS
+ \ CMAKE_ASM_NASM_FLAGS_DEBUG
+ \ CMAKE_ASM_NASM_FLAGS_DEBUG_INIT
+ \ CMAKE_ASM_NASM_FLAGS_INIT
+ \ CMAKE_ASM_NASM_FLAGS_MINSIZEREL
+ \ CMAKE_ASM_NASM_FLAGS_MINSIZEREL_INIT
+ \ CMAKE_ASM_NASM_FLAGS_RELEASE
+ \ CMAKE_ASM_NASM_FLAGS_RELEASE_INIT
+ \ CMAKE_ASM_NASM_FLAGS_RELWITHDEBINFO
+ \ CMAKE_ASM_NASM_FLAGS_RELWITHDEBINFO_INIT
+ \ CMAKE_ASM_NASM_IGNORE_EXTENSIONS
+ \ CMAKE_ASM_NASM_IMPLICIT_INCLUDE_DIRECTORIES
+ \ CMAKE_ASM_NASM_IMPLICIT_LINK_DIRECTORIES
+ \ CMAKE_ASM_NASM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
+ \ CMAKE_ASM_NASM_IMPLICIT_LINK_LIBRARIES
+ \ CMAKE_ASM_NASM_INCLUDE_WHAT_YOU_USE
+ \ CMAKE_ASM_NASM_INIT
+ \ CMAKE_ASM_NASM_LIBRARY_ARCHITECTURE
+ \ CMAKE_ASM_NASM_LINKER_PREFERENCE
+ \ CMAKE_ASM_NASM_LINKER_PREFERENCE_PROPAGATES
+ \ CMAKE_ASM_NASM_LINKER_WRAPPER_FLAG
+ \ CMAKE_ASM_NASM_LINKER_WRAPPER_FLAG_SEP
+ \ CMAKE_ASM_NASM_LINK_EXECUTABLE
+ \ CMAKE_ASM_NASM_OUTPUT_EXTENSION
+ \ CMAKE_ASM_NASM_PLATFORM_ID
+ \ CMAKE_ASM_NASM_SIMULATE_ID
+ \ CMAKE_ASM_NASM_SIMULATE_VERSION
+ \ CMAKE_ASM_NASM_SIZEOF_DATA_PTR
+ \ CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS
+ \ CMAKE_ASM_NASM_STANDARD_INCLUDE_DIRECTORIES
+ \ CMAKE_ASM_NASM_STANDARD_LIBRARIES
+ \ CMAKE_ASM_NASM_VISIBILITY_PRESET
+ \ CMAKE_ASM_OUTPUT_EXTENSION
+ \ CMAKE_ASM_PLATFORM_ID
+ \ CMAKE_ASM_SIMULATE_ID
+ \ CMAKE_ASM_SIMULATE_VERSION
+ \ CMAKE_ASM_SIZEOF_DATA_PTR
+ \ CMAKE_ASM_SOURCE_FILE_EXTENSIONS
+ \ CMAKE_ASM_STANDARD_INCLUDE_DIRECTORIES
+ \ CMAKE_ASM_STANDARD_LIBRARIES
+ \ CMAKE_ASM_VISIBILITY_PRESET
+ \ CMAKE_AUTOGEN_ORIGIN_DEPENDS
+ \ CMAKE_AUTOGEN_PARALLEL
+ \ CMAKE_AUTOGEN_VERBOSE
+ \ CMAKE_AUTOMOC
+ \ CMAKE_AUTOMOC_COMPILER_PREDEFINES
+ \ CMAKE_AUTOMOC_DEPEND_FILTERS
+ \ CMAKE_AUTOMOC_MACRO_NAMES
+ \ CMAKE_AUTOMOC_MOC_OPTIONS
+ \ CMAKE_AUTOMOC_RELAXED_MODE
+ \ CMAKE_AUTORCC
+ \ CMAKE_AUTORCC_OPTIONS
+ \ CMAKE_AUTOUIC
+ \ CMAKE_AUTOUIC_OPTIONS
+ \ CMAKE_AUTOUIC_SEARCH_PATHS
+ \ CMAKE_BACKWARDS_COMPATIBILITY
+ \ CMAKE_BINARY_DIR
+ \ CMAKE_BUILD_RPATH
+ \ CMAKE_BUILD_RPATH_USE_ORIGIN
+ \ CMAKE_BUILD_TOOL
+ \ CMAKE_BUILD_TYPE
+ \ CMAKE_BUILD_WITH_INSTALL_NAME_DIR
+ \ CMAKE_BUILD_WITH_INSTALL_RPATH
+ \ CMAKE_C
+ \ CMAKE_CACHEFILE_DIR
+ \ CMAKE_CACHE_MAJOR_VERSION
+ \ CMAKE_CACHE_MINOR_VERSION
+ \ CMAKE_CACHE_PATCH_VERSION
+ \ CMAKE_CFG_INTDIR
+ \ CMAKE_CL_64
+ \ CMAKE_CODEBLOCKS_COMPILER_ID
+ \ CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES
+ \ CMAKE_CODELITE_USE_TARGETS
+ \ CMAKE_COLOR_MAKEFILE
+ \ CMAKE_COMMAND
+ \ CMAKE_COMPILER_2005
+ \ CMAKE_COMPILER_IS_GNUCC
+ \ CMAKE_COMPILER_IS_GNUCXX
+ \ CMAKE_COMPILER_IS_GNUG77
+ \ CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
+ \ CMAKE_CONFIGURATION_TYPES
+ \ CMAKE_CPACK_COMMAND
+ \ CMAKE_CROSSCOMPILING
+ \ CMAKE_CROSSCOMPILING_EMULATOR
+ \ CMAKE_CSharp
+ \ CMAKE_CSharp_ANDROID_TOOLCHAIN_MACHINE
+ \ CMAKE_CSharp_ANDROID_TOOLCHAIN_PREFIX
+ \ CMAKE_CSharp_ANDROID_TOOLCHAIN_SUFFIX
+ \ CMAKE_CSharp_ARCHIVE_APPEND
+ \ CMAKE_CSharp_ARCHIVE_CREATE
+ \ CMAKE_CSharp_ARCHIVE_FINISH
+ \ CMAKE_CSharp_CLANG_TIDY
+ \ CMAKE_CSharp_COMPILER
+ \ CMAKE_CSharp_COMPILER_ABI
+ \ CMAKE_CSharp_COMPILER_AR
+ \ CMAKE_CSharp_COMPILER_ARCHITECTURE_ID
+ \ CMAKE_CSharp_COMPILER_EXTERNAL_TOOLCHAIN
+ \ CMAKE_CSharp_COMPILER_ID
+ \ CMAKE_CSharp_COMPILER_LAUNCHER
+ \ CMAKE_CSharp_COMPILER_LOADED
+ \ CMAKE_CSharp_COMPILER_PREDEFINES_COMMAND
+ \ CMAKE_CSharp_COMPILER_RANLIB
+ \ CMAKE_CSharp_COMPILER_TARGET
+ \ CMAKE_CSharp_COMPILER_VERSION
+ \ CMAKE_CSharp_COMPILER_VERSION_INTERNAL
+ \ CMAKE_CSharp_COMPILE_OBJECT
+ \ CMAKE_CSharp_CPPCHECK
+ \ CMAKE_CSharp_CPPLINT
+ \ CMAKE_CSharp_CREATE_SHARED_LIBRARY
+ \ CMAKE_CSharp_CREATE_SHARED_MODULE
+ \ CMAKE_CSharp_CREATE_STATIC_LIBRARY
+ \ CMAKE_CSharp_FLAGS
+ \ CMAKE_CSharp_FLAGS_DEBUG
+ \ CMAKE_CSharp_FLAGS_DEBUG_INIT
+ \ CMAKE_CSharp_FLAGS_INIT
+ \ CMAKE_CSharp_FLAGS_MINSIZEREL
+ \ CMAKE_CSharp_FLAGS_MINSIZEREL_INIT
+ \ CMAKE_CSharp_FLAGS_RELEASE
+ \ CMAKE_CSharp_FLAGS_RELEASE_INIT
+ \ CMAKE_CSharp_FLAGS_RELWITHDEBINFO
+ \ CMAKE_CSharp_FLAGS_RELWITHDEBINFO_INIT
+ \ CMAKE_CSharp_IGNORE_EXTENSIONS
+ \ CMAKE_CSharp_IMPLICIT_INCLUDE_DIRECTORIES
+ \ CMAKE_CSharp_IMPLICIT_LINK_DIRECTORIES
+ \ CMAKE_CSharp_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
+ \ CMAKE_CSharp_IMPLICIT_LINK_LIBRARIES
+ \ CMAKE_CSharp_INCLUDE_WHAT_YOU_USE
+ \ CMAKE_CSharp_INIT
+ \ CMAKE_CSharp_LIBRARY_ARCHITECTURE
+ \ CMAKE_CSharp_LINKER_PREFERENCE
+ \ CMAKE_CSharp_LINKER_PREFERENCE_PROPAGATES
+ \ CMAKE_CSharp_LINKER_WRAPPER_FLAG
+ \ CMAKE_CSharp_LINKER_WRAPPER_FLAG_SEP
+ \ CMAKE_CSharp_LINK_EXECUTABLE
+ \ CMAKE_CSharp_OUTPUT_EXTENSION
+ \ CMAKE_CSharp_PLATFORM_ID
+ \ CMAKE_CSharp_SIMULATE_ID
+ \ CMAKE_CSharp_SIMULATE_VERSION
+ \ CMAKE_CSharp_SIZEOF_DATA_PTR
+ \ CMAKE_CSharp_SOURCE_FILE_EXTENSIONS
+ \ CMAKE_CSharp_STANDARD_INCLUDE_DIRECTORIES
+ \ CMAKE_CSharp_STANDARD_LIBRARIES
+ \ CMAKE_CSharp_VISIBILITY_PRESET
+ \ CMAKE_CTEST_COMMAND
+ \ CMAKE_CUDA
+ \ CMAKE_CUDA_ANDROID_TOOLCHAIN_MACHINE
+ \ CMAKE_CUDA_ANDROID_TOOLCHAIN_PREFIX
+ \ CMAKE_CUDA_ANDROID_TOOLCHAIN_SUFFIX
+ \ CMAKE_CUDA_ARCHIVE_APPEND
+ \ CMAKE_CUDA_ARCHIVE_CREATE
+ \ CMAKE_CUDA_ARCHIVE_FINISH
+ \ CMAKE_CUDA_CLANG_TIDY
+ \ CMAKE_CUDA_COMPILER
+ \ CMAKE_CUDA_COMPILER_ABI
+ \ CMAKE_CUDA_COMPILER_AR
+ \ CMAKE_CUDA_COMPILER_ARCHITECTURE_ID
+ \ CMAKE_CUDA_COMPILER_EXTERNAL_TOOLCHAIN
+ \ CMAKE_CUDA_COMPILER_ID
+ \ CMAKE_CUDA_COMPILER_LAUNCHER
+ \ CMAKE_CUDA_COMPILER_LOADED
+ \ CMAKE_CUDA_COMPILER_PREDEFINES_COMMAND
+ \ CMAKE_CUDA_COMPILER_RANLIB
+ \ CMAKE_CUDA_COMPILER_TARGET
+ \ CMAKE_CUDA_COMPILER_VERSION
+ \ CMAKE_CUDA_COMPILER_VERSION_INTERNAL
+ \ CMAKE_CUDA_COMPILE_OBJECT
+ \ CMAKE_CUDA_CPPCHECK
+ \ CMAKE_CUDA_CPPLINT
+ \ CMAKE_CUDA_CREATE_SHARED_LIBRARY
+ \ CMAKE_CUDA_CREATE_SHARED_MODULE
+ \ CMAKE_CUDA_CREATE_STATIC_LIBRARY
+ \ CMAKE_CUDA_EXTENSIONS
+ \ CMAKE_CUDA_FLAGS
+ \ CMAKE_CUDA_FLAGS_DEBUG
+ \ CMAKE_CUDA_FLAGS_DEBUG_INIT
+ \ CMAKE_CUDA_FLAGS_INIT
+ \ CMAKE_CUDA_FLAGS_MINSIZEREL
+ \ CMAKE_CUDA_FLAGS_MINSIZEREL_INIT
+ \ CMAKE_CUDA_FLAGS_RELEASE
+ \ CMAKE_CUDA_FLAGS_RELEASE_INIT
+ \ CMAKE_CUDA_FLAGS_RELWITHDEBINFO
+ \ CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT
+ \ CMAKE_CUDA_HOST_COMPILER
+ \ CMAKE_CUDA_IGNORE_EXTENSIONS
+ \ CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES
+ \ CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES
+ \ CMAKE_CUDA_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
+ \ CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES
+ \ CMAKE_CUDA_INCLUDE_WHAT_YOU_USE
+ \ CMAKE_CUDA_INIT
+ \ CMAKE_CUDA_LIBRARY_ARCHITECTURE
+ \ CMAKE_CUDA_LINKER_PREFERENCE
+ \ CMAKE_CUDA_LINKER_PREFERENCE_PROPAGATES
+ \ CMAKE_CUDA_LINKER_WRAPPER_FLAG
+ \ CMAKE_CUDA_LINKER_WRAPPER_FLAG_SEP
+ \ CMAKE_CUDA_LINK_EXECUTABLE
+ \ CMAKE_CUDA_OUTPUT_EXTENSION
+ \ CMAKE_CUDA_PLATFORM_ID
+ \ CMAKE_CUDA_SEPARABLE_COMPILATION
+ \ CMAKE_CUDA_SIMULATE_ID
+ \ CMAKE_CUDA_SIMULATE_VERSION
+ \ CMAKE_CUDA_SIZEOF_DATA_PTR
+ \ CMAKE_CUDA_SOURCE_FILE_EXTENSIONS
+ \ CMAKE_CUDA_STANDARD
+ \ CMAKE_CUDA_STANDARD_INCLUDE_DIRECTORIES
+ \ CMAKE_CUDA_STANDARD_LIBRARIES
+ \ CMAKE_CUDA_STANDARD_REQUIRED
+ \ CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES
+ \ CMAKE_CUDA_VISIBILITY_PRESET
+ \ CMAKE_CURRENT_BINARY_DIR
+ \ CMAKE_CURRENT_LIST_DIR
+ \ CMAKE_CURRENT_LIST_FILE
+ \ CMAKE_CURRENT_LIST_LINE
+ \ CMAKE_CURRENT_SOURCE_DIR
+ \ CMAKE_CXX
+ \ CMAKE_CXX_ANDROID_TOOLCHAIN_MACHINE
+ \ CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX
+ \ CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX
+ \ CMAKE_CXX_ARCHIVE_APPEND
+ \ CMAKE_CXX_ARCHIVE_CREATE
+ \ CMAKE_CXX_ARCHIVE_FINISH
+ \ CMAKE_CXX_CLANG_TIDY
+ \ CMAKE_CXX_COMPILER
+ \ CMAKE_CXX_COMPILER_ABI
+ \ CMAKE_CXX_COMPILER_AR
+ \ CMAKE_CXX_COMPILER_ARCHITECTURE_ID
+ \ CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN
+ \ CMAKE_CXX_COMPILER_ID
+ \ CMAKE_CXX_COMPILER_LAUNCHER
+ \ CMAKE_CXX_COMPILER_LOADED
+ \ CMAKE_CXX_COMPILER_PREDEFINES_COMMAND
+ \ CMAKE_CXX_COMPILER_RANLIB
+ \ CMAKE_CXX_COMPILER_TARGET
+ \ CMAKE_CXX_COMPILER_VERSION
+ \ CMAKE_CXX_COMPILER_VERSION_INTERNAL
+ \ CMAKE_CXX_COMPILE_FEATURES
+ \ CMAKE_CXX_COMPILE_OBJECT
+ \ CMAKE_CXX_CPPCHECK
+ \ CMAKE_CXX_CPPLINT
+ \ CMAKE_CXX_CREATE_SHARED_LIBRARY
+ \ CMAKE_CXX_CREATE_SHARED_MODULE
+ \ CMAKE_CXX_CREATE_STATIC_LIBRARY
+ \ CMAKE_CXX_EXTENSIONS
+ \ CMAKE_CXX_FLAGS
+ \ CMAKE_CXX_FLAGS_DEBUG
+ \ CMAKE_CXX_FLAGS_DEBUG_INIT
+ \ CMAKE_CXX_FLAGS_INIT
+ \ CMAKE_CXX_FLAGS_MINSIZEREL
+ \ CMAKE_CXX_FLAGS_MINSIZEREL_INIT
+ \ CMAKE_CXX_FLAGS_RELEASE
+ \ CMAKE_CXX_FLAGS_RELEASE_INIT
+ \ CMAKE_CXX_FLAGS_RELWITHDEBINFO
+ \ CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT
+ \ CMAKE_CXX_IGNORE_EXTENSIONS
+ \ CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
+ \ CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES
+ \ CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
+ \ CMAKE_CXX_IMPLICIT_LINK_LIBRARIES
+ \ CMAKE_CXX_INCLUDE_WHAT_YOU_USE
+ \ CMAKE_CXX_INIT
+ \ CMAKE_CXX_LIBRARY_ARCHITECTURE
+ \ CMAKE_CXX_LINKER_PREFERENCE
+ \ CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES
+ \ CMAKE_CXX_LINKER_WRAPPER_FLAG
+ \ CMAKE_CXX_LINKER_WRAPPER_FLAG_SEP
+ \ CMAKE_CXX_LINK_EXECUTABLE
+ \ CMAKE_CXX_OUTPUT_EXTENSION
+ \ CMAKE_CXX_PLATFORM_ID
+ \ CMAKE_CXX_SIMULATE_ID
+ \ CMAKE_CXX_SIMULATE_VERSION
+ \ CMAKE_CXX_SIZEOF_DATA_PTR
+ \ CMAKE_CXX_SOURCE_FILE_EXTENSIONS
+ \ CMAKE_CXX_STANDARD
+ \ CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
+ \ CMAKE_CXX_STANDARD_LIBRARIES
+ \ CMAKE_CXX_STANDARD_REQUIRED
+ \ CMAKE_CXX_VISIBILITY_PRESET
+ \ CMAKE_C_ANDROID_TOOLCHAIN_MACHINE
+ \ CMAKE_C_ANDROID_TOOLCHAIN_PREFIX
+ \ CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX
+ \ CMAKE_C_ARCHIVE_APPEND
+ \ CMAKE_C_ARCHIVE_CREATE
+ \ CMAKE_C_ARCHIVE_FINISH
+ \ CMAKE_C_CLANG_TIDY
+ \ CMAKE_C_COMPILER
+ \ CMAKE_C_COMPILER_ABI
+ \ CMAKE_C_COMPILER_AR
+ \ CMAKE_C_COMPILER_ARCHITECTURE_ID
+ \ CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN
+ \ CMAKE_C_COMPILER_ID
+ \ CMAKE_C_COMPILER_LAUNCHER
+ \ CMAKE_C_COMPILER_LOADED
+ \ CMAKE_C_COMPILER_PREDEFINES_COMMAND
+ \ CMAKE_C_COMPILER_RANLIB
+ \ CMAKE_C_COMPILER_TARGET
+ \ CMAKE_C_COMPILER_VERSION
+ \ CMAKE_C_COMPILER_VERSION_INTERNAL
+ \ CMAKE_C_COMPILE_FEATURES
+ \ CMAKE_C_COMPILE_OBJECT
+ \ CMAKE_C_CPPCHECK
+ \ CMAKE_C_CPPLINT
+ \ CMAKE_C_CREATE_SHARED_LIBRARY
+ \ CMAKE_C_CREATE_SHARED_MODULE
+ \ CMAKE_C_CREATE_STATIC_LIBRARY
+ \ CMAKE_C_EXTENSIONS
+ \ CMAKE_C_FLAGS
+ \ CMAKE_C_FLAGS_DEBUG
+ \ CMAKE_C_FLAGS_DEBUG_INIT
+ \ CMAKE_C_FLAGS_INIT
+ \ CMAKE_C_FLAGS_MINSIZEREL
+ \ CMAKE_C_FLAGS_MINSIZEREL_INIT
+ \ CMAKE_C_FLAGS_RELEASE
+ \ CMAKE_C_FLAGS_RELEASE_INIT
+ \ CMAKE_C_FLAGS_RELWITHDEBINFO
+ \ CMAKE_C_FLAGS_RELWITHDEBINFO_INIT
+ \ CMAKE_C_IGNORE_EXTENSIONS
+ \ CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES
+ \ CMAKE_C_IMPLICIT_LINK_DIRECTORIES
+ \ CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
+ \ CMAKE_C_IMPLICIT_LINK_LIBRARIES
+ \ CMAKE_C_INCLUDE_WHAT_YOU_USE
+ \ CMAKE_C_INIT
+ \ CMAKE_C_LIBRARY_ARCHITECTURE
+ \ CMAKE_C_LINKER_PREFERENCE
+ \ CMAKE_C_LINKER_PREFERENCE_PROPAGATES
+ \ CMAKE_C_LINKER_WRAPPER_FLAG
+ \ CMAKE_C_LINKER_WRAPPER_FLAG_SEP
+ \ CMAKE_C_LINK_EXECUTABLE
+ \ CMAKE_C_OUTPUT_EXTENSION
+ \ CMAKE_C_PLATFORM_ID
+ \ CMAKE_C_SIMULATE_ID
+ \ CMAKE_C_SIMULATE_VERSION
+ \ CMAKE_C_SIZEOF_DATA_PTR
+ \ CMAKE_C_SOURCE_FILE_EXTENSIONS
+ \ CMAKE_C_STANDARD
+ \ CMAKE_C_STANDARD_INCLUDE_DIRECTORIES
+ \ CMAKE_C_STANDARD_LIBRARIES
+ \ CMAKE_C_STANDARD_REQUIRED
+ \ CMAKE_C_VISIBILITY_PRESET
+ \ CMAKE_DEBUG_POSTFIX
+ \ CMAKE_DEBUG_TARGET_PROPERTIES
+ \ CMAKE_DEPENDS_IN_PROJECT_ONLY
+ \ CMAKE_DIRECTORY_LABELS
+ \ CMAKE_DL_LIBS
+ \ CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION
+ \ CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES
+ \ CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT
+ \ CMAKE_ECLIPSE_MAKE_ARGUMENTS
+ \ CMAKE_ECLIPSE_RESOURCE_ENCODING
+ \ CMAKE_ECLIPSE_VERSION
+ \ CMAKE_EDIT_COMMAND
+ \ CMAKE_ENABLE_EXPORTS
+ \ CMAKE_ERROR_DEPRECATED
+ \ CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
+ \ CMAKE_EXECUTABLE_SUFFIX
+ \ CMAKE_EXECUTE_PROCESS_COMMAND_ECHO
+ \ CMAKE_EXE_LINKER_FLAGS
+ \ CMAKE_EXE_LINKER_FLAGS_INIT
+ \ CMAKE_EXPORT_COMPILE_COMMANDS
+ \ CMAKE_EXPORT_NO_PACKAGE_REGISTRY
+ \ CMAKE_EXPORT_PACKAGE_REGISTRY
+ \ CMAKE_EXTRA_GENERATOR
+ \ CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES
+ \ CMAKE_FIND_APPBUNDLE
+ \ CMAKE_FIND_FRAMEWORK
+ \ CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX
+ \ CMAKE_FIND_LIBRARY_PREFIXES
+ \ CMAKE_FIND_LIBRARY_SUFFIXES
+ \ CMAKE_FIND_NO_INSTALL_PREFIX
+ \ CMAKE_FIND_PACKAGE_NAME
+ \ CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
+ \ CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
+ \ CMAKE_FIND_PACKAGE_PREFER_CONFIG
+ \ CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS
+ \ CMAKE_FIND_PACKAGE_SORT_DIRECTION
+ \ CMAKE_FIND_PACKAGE_SORT_ORDER
+ \ CMAKE_FIND_PACKAGE_WARN_NO_MODULE
+ \ CMAKE_FIND_ROOT_PATH
+ \ CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
+ \ CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
+ \ CMAKE_FIND_ROOT_PATH_MODE_PACKAGE
+ \ CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
+ \ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH
+ \ CMAKE_FIND_USE_CMAKE_PATH
+ \ CMAKE_FIND_USE_CMAKE_SYSTEM_PATH
+ \ CMAKE_FIND_USE_PACKAGE_REGISTRY
+ \ CMAKE_FIND_USE_PACKAGE_ROOT_PATH
+ \ CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH
+ \ CMAKE_FOLDER
+ \ CMAKE_FRAMEWORK
+ \ CMAKE_FRAMEWORK_PATH
+ \ CMAKE_Fortran
+ \ CMAKE_Fortran_ANDROID_TOOLCHAIN_MACHINE
+ \ CMAKE_Fortran_ANDROID_TOOLCHAIN_PREFIX
+ \ CMAKE_Fortran_ANDROID_TOOLCHAIN_SUFFIX
+ \ CMAKE_Fortran_ARCHIVE_APPEND
+ \ CMAKE_Fortran_ARCHIVE_CREATE
+ \ CMAKE_Fortran_ARCHIVE_FINISH
+ \ CMAKE_Fortran_CLANG_TIDY
+ \ CMAKE_Fortran_COMPILER
+ \ CMAKE_Fortran_COMPILER_ABI
+ \ CMAKE_Fortran_COMPILER_AR
+ \ CMAKE_Fortran_COMPILER_ARCHITECTURE_ID
+ \ CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN
+ \ CMAKE_Fortran_COMPILER_ID
+ \ CMAKE_Fortran_COMPILER_LAUNCHER
+ \ CMAKE_Fortran_COMPILER_LOADED
+ \ CMAKE_Fortran_COMPILER_PREDEFINES_COMMAND
+ \ CMAKE_Fortran_COMPILER_RANLIB
+ \ CMAKE_Fortran_COMPILER_TARGET
+ \ CMAKE_Fortran_COMPILER_VERSION
+ \ CMAKE_Fortran_COMPILER_VERSION_INTERNAL
+ \ CMAKE_Fortran_COMPILE_OBJECT
+ \ CMAKE_Fortran_CPPCHECK
+ \ CMAKE_Fortran_CPPLINT
+ \ CMAKE_Fortran_CREATE_SHARED_LIBRARY
+ \ CMAKE_Fortran_CREATE_SHARED_MODULE
+ \ CMAKE_Fortran_CREATE_STATIC_LIBRARY
+ \ CMAKE_Fortran_FLAGS
+ \ CMAKE_Fortran_FLAGS_DEBUG
+ \ CMAKE_Fortran_FLAGS_DEBUG_INIT
+ \ CMAKE_Fortran_FLAGS_INIT
+ \ CMAKE_Fortran_FLAGS_MINSIZEREL
+ \ CMAKE_Fortran_FLAGS_MINSIZEREL_INIT
+ \ CMAKE_Fortran_FLAGS_RELEASE
+ \ CMAKE_Fortran_FLAGS_RELEASE_INIT
+ \ CMAKE_Fortran_FLAGS_RELWITHDEBINFO
+ \ CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT
+ \ CMAKE_Fortran_FORMAT
+ \ CMAKE_Fortran_IGNORE_EXTENSIONS
+ \ CMAKE_Fortran_IMPLICIT_INCLUDE_DIRECTORIES
+ \ CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES
+ \ CMAKE_Fortran_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
+ \ CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES
+ \ CMAKE_Fortran_INCLUDE_WHAT_YOU_USE
+ \ CMAKE_Fortran_INIT
+ \ CMAKE_Fortran_LIBRARY_ARCHITECTURE
+ \ CMAKE_Fortran_LINKER_PREFERENCE
+ \ CMAKE_Fortran_LINKER_PREFERENCE_PROPAGATES
+ \ CMAKE_Fortran_LINKER_WRAPPER_FLAG
+ \ CMAKE_Fortran_LINKER_WRAPPER_FLAG_SEP
+ \ CMAKE_Fortran_LINK_EXECUTABLE
+ \ CMAKE_Fortran_MODDIR_DEFAULT
+ \ CMAKE_Fortran_MODDIR_FLAG
+ \ CMAKE_Fortran_MODOUT_FLAG
+ \ CMAKE_Fortran_MODULE_DIRECTORY
+ \ CMAKE_Fortran_OUTPUT_EXTENSION
+ \ CMAKE_Fortran_PLATFORM_ID
+ \ CMAKE_Fortran_SIMULATE_ID
+ \ CMAKE_Fortran_SIMULATE_VERSION
+ \ CMAKE_Fortran_SIZEOF_DATA_PTR
+ \ CMAKE_Fortran_SOURCE_FILE_EXTENSIONS
+ \ CMAKE_Fortran_STANDARD_INCLUDE_DIRECTORIES
+ \ CMAKE_Fortran_STANDARD_LIBRARIES
+ \ CMAKE_Fortran_VISIBILITY_PRESET
+ \ CMAKE_GENERATOR
+ \ CMAKE_GENERATOR_INSTANCE
+ \ CMAKE_GENERATOR_PLATFORM
+ \ CMAKE_GENERATOR_TOOLSET
+ \ CMAKE_GHS_NO_SOURCE_GROUP_FILE
+ \ CMAKE_GLOBAL_AUTOGEN_TARGET
+ \ CMAKE_GLOBAL_AUTOGEN_TARGET_NAME
+ \ CMAKE_GLOBAL_AUTORCC_TARGET
+ \ CMAKE_GLOBAL_AUTORCC_TARGET_NAME
+ \ CMAKE_GNUtoMS
+ \ CMAKE_HOME_DIRECTORY
+ \ CMAKE_HOST_APPLE
+ \ CMAKE_HOST_SOLARIS
+ \ CMAKE_HOST_SYSTEM
+ \ CMAKE_HOST_SYSTEM_NAME
+ \ CMAKE_HOST_SYSTEM_PROCESSOR
+ \ CMAKE_HOST_SYSTEM_VERSION
+ \ CMAKE_HOST_UNIX
+ \ CMAKE_HOST_WIN32
+ \ CMAKE_IGNORE_PATH
+ \ CMAKE_IMPORT_LIBRARY_PREFIX
+ \ CMAKE_IMPORT_LIBRARY_SUFFIX
+ \ CMAKE_INCLUDE_CURRENT_DIR
+ \ CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE
+ \ CMAKE_INCLUDE_DIRECTORIES_BEFORE
+ \ CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE
+ \ CMAKE_INCLUDE_PATH
+ \ CMAKE_INSTALL_DEFAULT_COMPONENT_NAME
+ \ CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
+ \ CMAKE_INSTALL_MESSAGE
+ \ CMAKE_INSTALL_NAME_DIR
+ \ CMAKE_INSTALL_PREFIX
+ \ CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
+ \ CMAKE_INSTALL_RPATH
+ \ CMAKE_INSTALL_RPATH_USE_LINK_PATH
+ \ CMAKE_INTERNAL_PLATFORM_ABI
+ \ CMAKE_INTERPROCEDURAL_OPTIMIZATION
+ \ CMAKE_IOS_INSTALL_COMBINED
+ \ CMAKE_JOB_POOLS
+ \ CMAKE_JOB_POOL_COMPILE
+ \ CMAKE_JOB_POOL_LINK
+ \ CMAKE_Java
+ \ CMAKE_Java_ANDROID_TOOLCHAIN_MACHINE
+ \ CMAKE_Java_ANDROID_TOOLCHAIN_PREFIX
+ \ CMAKE_Java_ANDROID_TOOLCHAIN_SUFFIX
+ \ CMAKE_Java_ARCHIVE_APPEND
+ \ CMAKE_Java_ARCHIVE_CREATE
+ \ CMAKE_Java_ARCHIVE_FINISH
+ \ CMAKE_Java_CLANG_TIDY
+ \ CMAKE_Java_COMPILER
+ \ CMAKE_Java_COMPILER_ABI
+ \ CMAKE_Java_COMPILER_AR
+ \ CMAKE_Java_COMPILER_ARCHITECTURE_ID
+ \ CMAKE_Java_COMPILER_EXTERNAL_TOOLCHAIN
+ \ CMAKE_Java_COMPILER_ID
+ \ CMAKE_Java_COMPILER_LAUNCHER
+ \ CMAKE_Java_COMPILER_LOADED
+ \ CMAKE_Java_COMPILER_PREDEFINES_COMMAND
+ \ CMAKE_Java_COMPILER_RANLIB
+ \ CMAKE_Java_COMPILER_TARGET
+ \ CMAKE_Java_COMPILER_VERSION
+ \ CMAKE_Java_COMPILER_VERSION_INTERNAL
+ \ CMAKE_Java_COMPILE_OBJECT
+ \ CMAKE_Java_CPPCHECK
+ \ CMAKE_Java_CPPLINT
+ \ CMAKE_Java_CREATE_SHARED_LIBRARY
+ \ CMAKE_Java_CREATE_SHARED_MODULE
+ \ CMAKE_Java_CREATE_STATIC_LIBRARY
+ \ CMAKE_Java_FLAGS
+ \ CMAKE_Java_FLAGS_DEBUG
+ \ CMAKE_Java_FLAGS_DEBUG_INIT
+ \ CMAKE_Java_FLAGS_INIT
+ \ CMAKE_Java_FLAGS_MINSIZEREL
+ \ CMAKE_Java_FLAGS_MINSIZEREL_INIT
+ \ CMAKE_Java_FLAGS_RELEASE
+ \ CMAKE_Java_FLAGS_RELEASE_INIT
+ \ CMAKE_Java_FLAGS_RELWITHDEBINFO
+ \ CMAKE_Java_FLAGS_RELWITHDEBINFO_INIT
+ \ CMAKE_Java_IGNORE_EXTENSIONS
+ \ CMAKE_Java_IMPLICIT_INCLUDE_DIRECTORIES
+ \ CMAKE_Java_IMPLICIT_LINK_DIRECTORIES
+ \ CMAKE_Java_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
+ \ CMAKE_Java_IMPLICIT_LINK_LIBRARIES
+ \ CMAKE_Java_INCLUDE_WHAT_YOU_USE
+ \ CMAKE_Java_INIT
+ \ CMAKE_Java_LIBRARY_ARCHITECTURE
+ \ CMAKE_Java_LINKER_PREFERENCE
+ \ CMAKE_Java_LINKER_PREFERENCE_PROPAGATES
+ \ CMAKE_Java_LINKER_WRAPPER_FLAG
+ \ CMAKE_Java_LINKER_WRAPPER_FLAG_SEP
+ \ CMAKE_Java_LINK_EXECUTABLE
+ \ CMAKE_Java_OUTPUT_EXTENSION
+ \ CMAKE_Java_PLATFORM_ID
+ \ CMAKE_Java_SIMULATE_ID
+ \ CMAKE_Java_SIMULATE_VERSION
+ \ CMAKE_Java_SIZEOF_DATA_PTR
+ \ CMAKE_Java_SOURCE_FILE_EXTENSIONS
+ \ CMAKE_Java_STANDARD_INCLUDE_DIRECTORIES
+ \ CMAKE_Java_STANDARD_LIBRARIES
+ \ CMAKE_Java_VISIBILITY_PRESET
+ \ CMAKE_LIBRARY_ARCHITECTURE
+ \ CMAKE_LIBRARY_ARCHITECTURE_REGEX
+ \ CMAKE_LIBRARY_OUTPUT_DIRECTORY
+ \ CMAKE_LIBRARY_PATH
+ \ CMAKE_LIBRARY_PATH_FLAG
+ \ CMAKE_LINK_DEF_FILE_FLAG
+ \ CMAKE_LINK_DEPENDS_NO_SHARED
+ \ CMAKE_LINK_DIRECTORIES_BEFORE
+ \ CMAKE_LINK_INTERFACE_LIBRARIES
+ \ CMAKE_LINK_LIBRARY_FILE_FLAG
+ \ CMAKE_LINK_LIBRARY_FLAG
+ \ CMAKE_LINK_LIBRARY_SUFFIX
+ \ CMAKE_LINK_SEARCH_END_STATIC
+ \ CMAKE_LINK_SEARCH_START_STATIC
+ \ CMAKE_LINK_WHAT_YOU_USE
+ \ CMAKE_MACOSX_BUNDLE
+ \ CMAKE_MACOSX_RPATH
+ \ CMAKE_MAJOR_VERSION
+ \ CMAKE_MAKE_PROGRAM
+ \ CMAKE_MATCH_COUNT
+ \ CMAKE_MAXIMUM_RECURSION_DEPTH
+ \ CMAKE_MFC_FLAG
+ \ CMAKE_MINIMUM_REQUIRED_VERSION
+ \ CMAKE_MINOR_VERSION
+ \ CMAKE_MODULE_LINKER_FLAGS
+ \ CMAKE_MODULE_LINKER_FLAGS_INIT
+ \ CMAKE_MODULE_PATH
+ \ CMAKE_MSVCIDE_RUN_PATH
+ \ CMAKE_MSVC_RUNTIME_LIBRARY
+ \ CMAKE_NETRC
+ \ CMAKE_NETRC_FILE
+ \ CMAKE_NINJA_OUTPUT_PATH_PREFIX
+ \ CMAKE_NOT_USING_CONFIG_FLAGS
+ \ CMAKE_NO_BUILTIN_CHRPATH
+ \ CMAKE_NO_SYSTEM_FROM_IMPORTED
+ \ CMAKE_OBJECT_PATH_MAX
+ \ CMAKE_OSX_ARCHITECTURES
+ \ CMAKE_OSX_DEPLOYMENT_TARGET
+ \ CMAKE_OSX_SYSROOT
+ \ CMAKE_PARENT_LIST_FILE
+ \ CMAKE_PATCH_VERSION
+ \ CMAKE_PDB_OUTPUT_DIRECTORY
+ \ CMAKE_POSITION_INDEPENDENT_CODE
+ \ CMAKE_PREFIX_PATH
+ \ CMAKE_PROGRAM_PATH
+ \ CMAKE_PROJECT_DESCRIPTION
+ \ CMAKE_PROJECT_HOMEPAGE_URL
+ \ CMAKE_PROJECT_INCLUDE
+ \ CMAKE_PROJECT_INCLUDE_BEFORE
+ \ CMAKE_PROJECT_NAME
+ \ CMAKE_PROJECT_VERSION
+ \ CMAKE_PROJECT_VERSION_MAJOR
+ \ CMAKE_PROJECT_VERSION_MINOR
+ \ CMAKE_PROJECT_VERSION_PATCH
+ \ CMAKE_PROJECT_VERSION_TWEAK
+ \ CMAKE_RANLIB
+ \ CMAKE_RC
+ \ CMAKE_RC_ANDROID_TOOLCHAIN_MACHINE
+ \ CMAKE_RC_ANDROID_TOOLCHAIN_PREFIX
+ \ CMAKE_RC_ANDROID_TOOLCHAIN_SUFFIX
+ \ CMAKE_RC_ARCHIVE_APPEND
+ \ CMAKE_RC_ARCHIVE_CREATE
+ \ CMAKE_RC_ARCHIVE_FINISH
+ \ CMAKE_RC_CLANG_TIDY
+ \ CMAKE_RC_COMPILER
+ \ CMAKE_RC_COMPILER_ABI
+ \ CMAKE_RC_COMPILER_AR
+ \ CMAKE_RC_COMPILER_ARCHITECTURE_ID
+ \ CMAKE_RC_COMPILER_EXTERNAL_TOOLCHAIN
+ \ CMAKE_RC_COMPILER_ID
+ \ CMAKE_RC_COMPILER_LAUNCHER
+ \ CMAKE_RC_COMPILER_LOADED
+ \ CMAKE_RC_COMPILER_PREDEFINES_COMMAND
+ \ CMAKE_RC_COMPILER_RANLIB
+ \ CMAKE_RC_COMPILER_TARGET
+ \ CMAKE_RC_COMPILER_VERSION
+ \ CMAKE_RC_COMPILER_VERSION_INTERNAL
+ \ CMAKE_RC_COMPILE_OBJECT
+ \ CMAKE_RC_CPPCHECK
+ \ CMAKE_RC_CPPLINT
+ \ CMAKE_RC_CREATE_SHARED_LIBRARY
+ \ CMAKE_RC_CREATE_SHARED_MODULE
+ \ CMAKE_RC_CREATE_STATIC_LIBRARY
+ \ CMAKE_RC_FLAGS
+ \ CMAKE_RC_FLAGS_DEBUG
+ \ CMAKE_RC_FLAGS_DEBUG_INIT
+ \ CMAKE_RC_FLAGS_INIT
+ \ CMAKE_RC_FLAGS_MINSIZEREL
+ \ CMAKE_RC_FLAGS_MINSIZEREL_INIT
+ \ CMAKE_RC_FLAGS_RELEASE
+ \ CMAKE_RC_FLAGS_RELEASE_INIT
+ \ CMAKE_RC_FLAGS_RELWITHDEBINFO
+ \ CMAKE_RC_FLAGS_RELWITHDEBINFO_INIT
+ \ CMAKE_RC_IGNORE_EXTENSIONS
+ \ CMAKE_RC_IMPLICIT_INCLUDE_DIRECTORIES
+ \ CMAKE_RC_IMPLICIT_LINK_DIRECTORIES
+ \ CMAKE_RC_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
+ \ CMAKE_RC_IMPLICIT_LINK_LIBRARIES
+ \ CMAKE_RC_INCLUDE_WHAT_YOU_USE
+ \ CMAKE_RC_INIT
+ \ CMAKE_RC_LIBRARY_ARCHITECTURE
+ \ CMAKE_RC_LINKER_PREFERENCE
+ \ CMAKE_RC_LINKER_PREFERENCE_PROPAGATES
+ \ CMAKE_RC_LINKER_WRAPPER_FLAG
+ \ CMAKE_RC_LINKER_WRAPPER_FLAG_SEP
+ \ CMAKE_RC_LINK_EXECUTABLE
+ \ CMAKE_RC_OUTPUT_EXTENSION
+ \ CMAKE_RC_PLATFORM_ID
+ \ CMAKE_RC_SIMULATE_ID
+ \ CMAKE_RC_SIMULATE_VERSION
+ \ CMAKE_RC_SIZEOF_DATA_PTR
+ \ CMAKE_RC_SOURCE_FILE_EXTENSIONS
+ \ CMAKE_RC_STANDARD_INCLUDE_DIRECTORIES
+ \ CMAKE_RC_STANDARD_LIBRARIES
+ \ CMAKE_RC_VISIBILITY_PRESET
+ \ CMAKE_ROOT
+ \ CMAKE_RULE_MESSAGES
+ \ CMAKE_RUNTIME_OUTPUT_DIRECTORY
+ \ CMAKE_SCRIPT_MODE_FILE
+ \ CMAKE_SHARED_LIBRARY_PREFIX
+ \ CMAKE_SHARED_LIBRARY_SUFFIX
+ \ CMAKE_SHARED_LINKER_FLAGS
+ \ CMAKE_SHARED_LINKER_FLAGS_INIT
+ \ CMAKE_SHARED_MODULE_PREFIX
+ \ CMAKE_SHARED_MODULE_SUFFIX
+ \ CMAKE_SIZEOF_VOID_P
+ \ CMAKE_SKIP_BUILD_RPATH
+ \ CMAKE_SKIP_INSTALL_ALL_DEPENDENCY
+ \ CMAKE_SKIP_INSTALL_RPATH
+ \ CMAKE_SKIP_INSTALL_RULES
+ \ CMAKE_SKIP_RPATH
+ \ CMAKE_SOURCE_DIR
+ \ CMAKE_STAGING_PREFIX
+ \ CMAKE_STATIC_LIBRARY_PREFIX
+ \ CMAKE_STATIC_LIBRARY_SUFFIX
+ \ CMAKE_STATIC_LINKER_FLAGS
+ \ CMAKE_STATIC_LINKER_FLAGS_INIT
+ \ CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS
+ \ CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE
+ \ CMAKE_SUPPRESS_REGENERATION
+ \ CMAKE_SYSROOT
+ \ CMAKE_SYSROOT_COMPILE
+ \ CMAKE_SYSROOT_LINK
+ \ CMAKE_SYSTEM
+ \ CMAKE_SYSTEM_APPBUNDLE_PATH
+ \ CMAKE_SYSTEM_FRAMEWORK_PATH
+ \ CMAKE_SYSTEM_IGNORE_PATH
+ \ CMAKE_SYSTEM_INCLUDE_PATH
+ \ CMAKE_SYSTEM_LIBRARY_PATH
+ \ CMAKE_SYSTEM_NAME
+ \ CMAKE_SYSTEM_PREFIX_PATH
+ \ CMAKE_SYSTEM_PROCESSOR
+ \ CMAKE_SYSTEM_PROGRAM_PATH
+ \ CMAKE_SYSTEM_VERSION
+ \ CMAKE_Swift
+ \ CMAKE_Swift_ANDROID_TOOLCHAIN_MACHINE
+ \ CMAKE_Swift_ANDROID_TOOLCHAIN_PREFIX
+ \ CMAKE_Swift_ANDROID_TOOLCHAIN_SUFFIX
+ \ CMAKE_Swift_ARCHIVE_APPEND
+ \ CMAKE_Swift_ARCHIVE_CREATE
+ \ CMAKE_Swift_ARCHIVE_FINISH
+ \ CMAKE_Swift_CLANG_TIDY
+ \ CMAKE_Swift_COMPILER
+ \ CMAKE_Swift_COMPILER_ABI
+ \ CMAKE_Swift_COMPILER_AR
+ \ CMAKE_Swift_COMPILER_ARCHITECTURE_ID
+ \ CMAKE_Swift_COMPILER_EXTERNAL_TOOLCHAIN
+ \ CMAKE_Swift_COMPILER_ID
+ \ CMAKE_Swift_COMPILER_LAUNCHER
+ \ CMAKE_Swift_COMPILER_LOADED
+ \ CMAKE_Swift_COMPILER_PREDEFINES_COMMAND
+ \ CMAKE_Swift_COMPILER_RANLIB
+ \ CMAKE_Swift_COMPILER_TARGET
+ \ CMAKE_Swift_COMPILER_VERSION
+ \ CMAKE_Swift_COMPILER_VERSION_INTERNAL
+ \ CMAKE_Swift_COMPILE_OBJECT
+ \ CMAKE_Swift_CPPCHECK
+ \ CMAKE_Swift_CPPLINT
+ \ CMAKE_Swift_CREATE_SHARED_LIBRARY
+ \ CMAKE_Swift_CREATE_SHARED_MODULE
+ \ CMAKE_Swift_CREATE_STATIC_LIBRARY
+ \ CMAKE_Swift_FLAGS
+ \ CMAKE_Swift_FLAGS_DEBUG
+ \ CMAKE_Swift_FLAGS_DEBUG_INIT
+ \ CMAKE_Swift_FLAGS_INIT
+ \ CMAKE_Swift_FLAGS_MINSIZEREL
+ \ CMAKE_Swift_FLAGS_MINSIZEREL_INIT
+ \ CMAKE_Swift_FLAGS_RELEASE
+ \ CMAKE_Swift_FLAGS_RELEASE_INIT
+ \ CMAKE_Swift_FLAGS_RELWITHDEBINFO
+ \ CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT
+ \ CMAKE_Swift_IGNORE_EXTENSIONS
+ \ CMAKE_Swift_IMPLICIT_INCLUDE_DIRECTORIES
+ \ CMAKE_Swift_IMPLICIT_LINK_DIRECTORIES
+ \ CMAKE_Swift_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES
+ \ CMAKE_Swift_IMPLICIT_LINK_LIBRARIES
+ \ CMAKE_Swift_INCLUDE_WHAT_YOU_USE
+ \ CMAKE_Swift_INIT
+ \ CMAKE_Swift_LANGUAGE_VERSION
+ \ CMAKE_Swift_LIBRARY_ARCHITECTURE
+ \ CMAKE_Swift_LINKER_PREFERENCE
+ \ CMAKE_Swift_LINKER_PREFERENCE_PROPAGATES
+ \ CMAKE_Swift_LINKER_WRAPPER_FLAG
+ \ CMAKE_Swift_LINKER_WRAPPER_FLAG_SEP
+ \ CMAKE_Swift_LINK_EXECUTABLE
+ \ CMAKE_Swift_MODULE_DIRECTORY
+ \ CMAKE_Swift_OUTPUT_EXTENSION
+ \ CMAKE_Swift_PLATFORM_ID
+ \ CMAKE_Swift_SIMULATE_ID
+ \ CMAKE_Swift_SIMULATE_VERSION
+ \ CMAKE_Swift_SIZEOF_DATA_PTR
+ \ CMAKE_Swift_SOURCE_FILE_EXTENSIONS
+ \ CMAKE_Swift_STANDARD_INCLUDE_DIRECTORIES
+ \ CMAKE_Swift_STANDARD_LIBRARIES
+ \ CMAKE_Swift_VISIBILITY_PRESET
+ \ CMAKE_TOOLCHAIN_FILE
+ \ CMAKE_TRY_COMPILE_CONFIGURATION
+ \ CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
+ \ CMAKE_TRY_COMPILE_TARGET_TYPE
+ \ CMAKE_TWEAK_VERSION
+ \ CMAKE_USER_MAKE_RULES_OVERRIDE
+ \ CMAKE_USER_MAKE_RULES_OVERRIDE_ASM
+ \ CMAKE_USER_MAKE_RULES_OVERRIDE_ASM_MASM
+ \ CMAKE_USER_MAKE_RULES_OVERRIDE_ASM_NASM
+ \ CMAKE_USER_MAKE_RULES_OVERRIDE_C
+ \ CMAKE_USER_MAKE_RULES_OVERRIDE_CSharp
+ \ CMAKE_USER_MAKE_RULES_OVERRIDE_CUDA
+ \ CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
+ \ CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran
+ \ CMAKE_USER_MAKE_RULES_OVERRIDE_Java
+ \ CMAKE_USER_MAKE_RULES_OVERRIDE_RC
+ \ CMAKE_USER_MAKE_RULES_OVERRIDE_Swift
+ \ CMAKE_USE_RELATIVE_PATHS
+ \ CMAKE_VERBOSE_MAKEFILE
+ \ CMAKE_VERSION
+ \ CMAKE_VISIBILITY_INLINES_HIDDEN
+ \ CMAKE_VS_DEVENV_COMMAND
+ \ CMAKE_VS_GLOBALS
+ \ CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD
+ \ CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD
+ \ CMAKE_VS_INTEL_Fortran_PROJECT_VERSION
+ \ CMAKE_VS_JUST_MY_CODE_DEBUGGING
+ \ CMAKE_VS_MSBUILD_COMMAND
+ \ CMAKE_VS_NsightTegra_VERSION
+ \ CMAKE_VS_PLATFORM_NAME
+ \ CMAKE_VS_PLATFORM_NAME_DEFAULT
+ \ CMAKE_VS_PLATFORM_TOOLSET
+ \ CMAKE_VS_PLATFORM_TOOLSET_CUDA
+ \ CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE
+ \ CMAKE_VS_PLATFORM_TOOLSET_VERSION
+ \ CMAKE_VS_SDK_EXCLUDE_DIRECTORIES
+ \ CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES
+ \ CMAKE_VS_SDK_INCLUDE_DIRECTORIES
+ \ CMAKE_VS_SDK_LIBRARY_DIRECTORIES
+ \ CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES
+ \ CMAKE_VS_SDK_REFERENCE_DIRECTORIES
+ \ CMAKE_VS_SDK_SOURCE_DIRECTORIES
+ \ CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION
+ \ CMAKE_VS_WINRT_BY_DEFAULT
+ \ CMAKE_WARN_DEPRECATED
+ \ CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION
+ \ CMAKE_WIN32_EXECUTABLE
+ \ CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
+ \ CMAKE_XCODE_GENERATE_SCHEME
+ \ CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY
+ \ CMAKE_XCODE_PLATFORM_TOOLSET
+ \ CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER
+ \ CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN
+ \ CMAKE_XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER
+ \ CMAKE_XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS
+ \ CMAKE_XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE
+ \ CMAKE_XCODE_SCHEME_GUARD_MALLOC
+ \ CMAKE_XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP
+ \ CMAKE_XCODE_SCHEME_MALLOC_GUARD_EDGES
+ \ CMAKE_XCODE_SCHEME_MALLOC_SCRIBBLE
+ \ CMAKE_XCODE_SCHEME_MALLOC_STACK
+ \ CMAKE_XCODE_SCHEME_THREAD_SANITIZER
+ \ CMAKE_XCODE_SCHEME_THREAD_SANITIZER_STOP
+ \ CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER
+ \ CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP
+ \ CMAKE_XCODE_SCHEME_ZOMBIE_OBJECTS
+ \ CPACK_ABSOLUTE_DESTINATION_FILES
+ \ CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY
+ \ CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
+ \ CPACK_INCLUDE_TOPLEVEL_DIRECTORY
+ \ CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
+ \ CPACK_INSTALL_SCRIPT
+ \ CPACK_PACKAGING_INSTALL_PREFIX
+ \ CPACK_SET_DESTDIR
+ \ CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION
+ \ CTEST_BINARY_DIRECTORY
+ \ CTEST_BUILD_COMMAND
+ \ CTEST_BUILD_NAME
+ \ CTEST_BZR_COMMAND
+ \ CTEST_BZR_UPDATE_OPTIONS
+ \ CTEST_CHANGE_ID
+ \ CTEST_CHECKOUT_COMMAND
+ \ CTEST_CONFIGURATION_TYPE
+ \ CTEST_CONFIGURE_COMMAND
+ \ CTEST_COVERAGE_COMMAND
+ \ CTEST_COVERAGE_EXTRA_FLAGS
+ \ CTEST_CURL_OPTIONS
+ \ CTEST_CUSTOM_COVERAGE_EXCLUDE
+ \ CTEST_CUSTOM_ERROR_EXCEPTION
+ \ CTEST_CUSTOM_ERROR_MATCH
+ \ CTEST_CUSTOM_ERROR_POST_CONTEXT
+ \ CTEST_CUSTOM_ERROR_PRE_CONTEXT
+ \ CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE
+ \ CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS
+ \ CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS
+ \ CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE
+ \ CTEST_CUSTOM_MEMCHECK_IGNORE
+ \ CTEST_CUSTOM_POST_MEMCHECK
+ \ CTEST_CUSTOM_POST_TEST
+ \ CTEST_CUSTOM_PRE_MEMCHECK
+ \ CTEST_CUSTOM_PRE_TEST
+ \ CTEST_CUSTOM_TESTS_IGNORE
+ \ CTEST_CUSTOM_WARNING_EXCEPTION
+ \ CTEST_CUSTOM_WARNING_MATCH
+ \ CTEST_CVS_CHECKOUT
+ \ CTEST_CVS_COMMAND
+ \ CTEST_CVS_UPDATE_OPTIONS
+ \ CTEST_DROP_LOCATION
+ \ CTEST_DROP_METHOD
+ \ CTEST_DROP_SITE
+ \ CTEST_DROP_SITE_CDASH
+ \ CTEST_DROP_SITE_PASSWORD
+ \ CTEST_DROP_SITE_USER
+ \ CTEST_EXTRA_COVERAGE_GLOB
+ \ CTEST_GIT_COMMAND
+ \ CTEST_GIT_INIT_SUBMODULES
+ \ CTEST_GIT_UPDATE_CUSTOM
+ \ CTEST_GIT_UPDATE_OPTIONS
+ \ CTEST_HG_COMMAND
+ \ CTEST_HG_UPDATE_OPTIONS
+ \ CTEST_LABELS_FOR_SUBPROJECTS
+ \ CTEST_MEMORYCHECK_COMMAND
+ \ CTEST_MEMORYCHECK_COMMAND_OPTIONS
+ \ CTEST_MEMORYCHECK_SANITIZER_OPTIONS
+ \ CTEST_MEMORYCHECK_SUPPRESSIONS_FILE
+ \ CTEST_MEMORYCHECK_TYPE
+ \ CTEST_NIGHTLY_START_TIME
+ \ CTEST_P4_CLIENT
+ \ CTEST_P4_COMMAND
+ \ CTEST_P4_OPTIONS
+ \ CTEST_P4_UPDATE_OPTIONS
+ \ CTEST_RUN_CURRENT_SCRIPT
+ \ CTEST_SCP_COMMAND
+ \ CTEST_SITE
+ \ CTEST_SOURCE_DIRECTORY
+ \ CTEST_SUBMIT_URL
+ \ CTEST_SVN_COMMAND
+ \ CTEST_SVN_OPTIONS
+ \ CTEST_SVN_UPDATE_OPTIONS
+ \ CTEST_TEST_LOAD
+ \ CTEST_TEST_TIMEOUT
+ \ CTEST_TRIGGER_SITE
+ \ CTEST_UPDATE_COMMAND
+ \ CTEST_UPDATE_OPTIONS
+ \ CTEST_UPDATE_VERSION_ONLY
+ \ CTEST_UPDATE_VERSION_OVERRIDE
+ \ CTEST_USE_LAUNCHERS
+ \ CYGWIN
+ \ ENV
+ \ EXECUTABLE_OUTPUT_PATH
+ \ GHS-MULTI
+ \ IOS
+ \ LIBRARY_OUTPUT_PATH
+ \ MINGW
+ \ MSVC
+ \ MSVC10
+ \ MSVC11
+ \ MSVC12
+ \ MSVC14
+ \ MSVC60
+ \ MSVC70
+ \ MSVC71
+ \ MSVC80
+ \ MSVC90
+ \ MSVC_IDE
+ \ MSVC_TOOLSET_VERSION
+ \ MSVC_VERSION
+ \ MSYS
+ \ PROJECT_BINARY_DIR
+ \ PROJECT_DESCRIPTION
+ \ PROJECT_HOMEPAGE_URL
+ \ PROJECT_NAME
+ \ PROJECT_SOURCE_DIR
+ \ PROJECT_VERSION
+ \ PROJECT_VERSION_MAJOR
+ \ PROJECT_VERSION_MINOR
+ \ PROJECT_VERSION_PATCH
+ \ PROJECT_VERSION_TWEAK
+ \ UNIX
+ \ WIN32
+ \ WINCE
+ \ WINDOWS_PHONE
+ \ WINDOWS_STORE
+ \ XCODE
+ \ XCODE_VERSION
syn keyword cmakeModule contained
\ ExternalProject
syn keyword cmakeKWExternalProject contained
- \ ALGO BINARY_DIR BUILD_ALWAYS BUILD_BYPRODUCTS BUILD_COMMAND BUILD_IN_SOURCE CMAKE_ARGS CMAKE_CACHE_ARGS CMAKE_CACHE_DEFAULT_ARGS COMMENT CONFIGURE_COMMAND CVSROOT CVS_MODULE CVS_REPOSITORY CVS_TAG DEPENDEES DEPENDERS DEPENDS DOWNLOADED_FILE DOWNLOAD_COMMAND DOWNLOAD_DIR DOWNLOAD_NAME DOWNLOAD_NO_EXTRACT DOWNLOAD_NO_PROGRESS EP_BASE EP_INDEPENDENT_STEP_TARGETS EP_PREFIX EP_STEP_TARGETS EP_UPDATE_DISCONNECTED EXCLUDE_FROM_ALL FORCE GIT_CONFIG GIT_PROGRESS GIT_REMOTE_NAME GIT_REPOSITORY GIT_SHALLOW GIT_SUBMODULES GIT_TAG HG_REPOSITORY HG_TAG HTTP_HEADER HTTP_PASSWORD HTTP_USERNAME INDEPENDENT_STEP_TARGETS INSTALL_COMMAND INSTALL_DIR JOB_POOLS LIST_SEPARATOR LOG_BUILD LOG_CONFIGURE LOG_DOWNLOAD LOG_INSTALL LOG_TEST LOG_UPDATE NO_DEPENDS PATCH_COMMAND PREFIX PROPERTY SOURCE_DIR SOURCE_SUBDIR STAMP_DIR STEP_TARGETS SVN_PASSWORD SVN_REPOSITORY SVN_REVISION SVN_TRUST_CERT SVN_USERNAME TEST_AFTER_INSTALL TEST_BEFORE_INSTALL TEST_COMMAND TEST_EXCLUDE_FROM_MAIN TIMEOUT TLS_CAINFO TLS_VERIFY TMP_DIR UPDATE_COMMAND UPDATE_DISCONNECTED URL URL_HASH USES_TERMINAL_BUILD USES_TERMINAL_CONFIGURE USES_TERMINAL_DOWNLOAD USES_TERMINAL_INSTALL USES_TERMINAL_TEST USES_TERMINAL_UPDATE WORKING_DIRECTORY
+ \ AWS
+ \ BINARY_DIR
+ \ BUILD_ALWAYS
+ \ BUILD_BYPRODUCTS
+ \ BUILD_COMMAND
+ \ BUILD_IN_SOURCE
+ \ CMAKE_ARGS
+ \ CMAKE_CACHE_ARGS
+ \ CMAKE_CACHE_DEFAULT_ARGS
+ \ CMAKE_TLS_CAINFO
+ \ CMAKE_TLS_VERIFY
+ \ COMMENT
+ \ CONFIGURE_COMMAND
+ \ CVS
+ \ CVSROOT
+ \ CVS_MODULE
+ \ CVS_REPOSITORY
+ \ CVS_TAG
+ \ DEPENDEES
+ \ DEPENDERS
+ \ DEPENDS
+ \ DOWNLOADED_FILE
+ \ DOWNLOAD_COMMAND
+ \ DOWNLOAD_DIR
+ \ DOWNLOAD_NAME
+ \ DOWNLOAD_NO_EXTRACT
+ \ DOWNLOAD_NO_PROGRESS
+ \ EP_BASE
+ \ EP_INDEPENDENT_STEP_TARGETS
+ \ EP_PREFIX
+ \ EP_STEP_TARGETS
+ \ EP_UPDATE_DISCONNECTED
+ \ EXCLUDE_FROM_ALL
+ \ FORCE
+ \ GHS
+ \ GIT_CONFIG
+ \ GIT_PROGRESS
+ \ GIT_REMOTE_NAME
+ \ GIT_REPOSITORY
+ \ GIT_SHALLOW
+ \ GIT_SUBMODULES
+ \ GIT_TAG
+ \ HG_REPOSITORY
+ \ HG_TAG
+ \ HTTP_HEADER
+ \ HTTP_PASSWORD
+ \ HTTP_USERNAME
+ \ IGNORED
+ \ INDEPENDENT_STEP_TARGETS
+ \ INSTALL_COMMAND
+ \ INSTALL_DIR
+ \ JOB_POOLS
+ \ LIST_SEPARATOR
+ \ LOG_BUILD
+ \ LOG_CONFIGURE
+ \ LOG_DIR
+ \ LOG_DOWNLOAD
+ \ LOG_INSTALL
+ \ LOG_MERGED_STDOUTERR
+ \ LOG_OUTPUT_ON_FAILURE
+ \ LOG_PATCH
+ \ LOG_TEST
+ \ LOG_UPDATE
+ \ MAKE_EXE
+ \ MULTI
+ \ NAMES
+ \ NETRC
+ \ NETRC_FILE
+ \ NOTE
+ \ NO_DEPENDS
+ \ OPTIONAL
+ \ PATCH_COMMAND
+ \ PREFIX
+ \ PROPERTY
+ \ REQUIRED
+ \ SOURCE_DIR
+ \ SOURCE_SUBDIR
+ \ STAMP_DIR
+ \ STEP_TARGETS
+ \ STRING
+ \ SVN_PASSWORD
+ \ SVN_REPOSITORY
+ \ SVN_REVISION
+ \ SVN_TRUST_CERT
+ \ SVN_USERNAME
+ \ TEST_AFTER_INSTALL
+ \ TEST_BEFORE_INSTALL
+ \ TEST_COMMAND
+ \ TEST_EXCLUDE_FROM_MAIN
+ \ TIMEOUT
+ \ TLS_CAINFO
+ \ TLS_VERIFY
+ \ TMP_DIR
+ \ TRUE
+ \ UPDATE_COMMAND
+ \ UPDATE_DISCONNECTED
+ \ URL
+ \ URL_HASH
+ \ USES_TERMINAL_BUILD
+ \ USES_TERMINAL_CONFIGURE
+ \ USES_TERMINAL_DOWNLOAD
+ \ USES_TERMINAL_INSTALL
+ \ USES_TERMINAL_TEST
+ \ USES_TERMINAL_UPDATE
+ \ WORKING_DIRECTORY
+
+syn keyword cmakeKWadd_compile_definitions contained
+ \ COMPILE_DEFINITIONS
+ \ VAR
syn keyword cmakeKWadd_compile_options contained
\ COMPILE_OPTIONS
+ \ SHELL
+ \ UNIX_COMMAND
+ \ WX
syn keyword cmakeKWadd_custom_command contained
- \ APPEND ARGS BYPRODUCTS CC COMMAND COMMAND_EXPAND_LISTS COMMENT CROSSCOMPILING_EMULATOR DEPENDS DEPFILE GENERATED IMPLICIT_DEPENDS INCLUDE_DIRECTORIES JOIN MAIN_DEPENDENCY NOT OUTPUT POST_BUILD PRE_BUILD PRE_LINK SYMBOLIC TARGET_FILE TARGET_PROPERTY USES_TERMINAL VERBATIM WORKING_DIRECTORY
+ \ APPEND
+ \ ARGS
+ \ BYPRODUCTS
+ \ CC
+ \ COMMAND
+ \ COMMAND_EXPAND_LISTS
+ \ COMMENT
+ \ CROSSCOMPILING_EMULATOR
+ \ DEPENDS
+ \ DEPFILE
+ \ GENERATED
+ \ IMPLICIT_DEPENDS
+ \ INCLUDE_DIRECTORIES
+ \ JOB_POOL
+ \ JOB_POOLS
+ \ JOIN
+ \ MAIN_DEPENDENCY
+ \ NOT
+ \ OUTPUT
+ \ POST_BUILD
+ \ PRE_BUILD
+ \ PRE_LINK
+ \ SYMBOLIC
+ \ TARGET_FILE
+ \ TARGET_PROPERTY
+ \ USES_TERMINAL
+ \ VERBATIM
+ \ WORKING_DIRECTORY
syn keyword cmakeKWadd_custom_target contained
- \ ALL BYPRODUCTS CC COMMAND COMMAND_EXPAND_LISTS COMMENT CROSSCOMPILING_EMULATOR DEPENDS GENERATED INCLUDE_DIRECTORIES JOIN SOURCES TARGET_PROPERTY USES_TERMINAL VERBATIM WORKING_DIRECTORY
+ \ ALL
+ \ BYPRODUCTS
+ \ CC
+ \ COMMAND
+ \ COMMAND_EXPAND_LISTS
+ \ COMMENT
+ \ CROSSCOMPILING_EMULATOR
+ \ DEPENDS
+ \ GENERATED
+ \ INCLUDE_DIRECTORIES
+ \ JOB_POOL
+ \ JOB_POOLS
+ \ JOIN
+ \ SOURCES
+ \ TARGET_PROPERTY
+ \ USES_TERMINAL
+ \ VERBATIM
+ \ WORKING_DIRECTORY
syn keyword cmakeKWadd_definitions contained
\ COMPILE_DEFINITIONS
syn keyword cmakeKWadd_dependencies contained
- \ DEPENDS OBJECT_DEPENDS
+ \ DEPENDS
+ \ OBJECT_DEPENDS
syn keyword cmakeKWadd_executable contained
- \ ALIAS CONFIG EXCLUDE_FROM_ALL GLOBAL IMPORTED IMPORTED_ IMPORTED_LOCATION IMPORTED_LOCATION_ MACOSX_BUNDLE OUTPUT_NAME RUNTIME_OUTPUT_DIRECTORY TARGET
+ \ ALIAS
+ \ CONFIG
+ \ EXCLUDE_FROM_ALL
+ \ GLOBAL
+ \ HEADER_FILE_ONLY
+ \ IMPORTED
+ \ IMPORTED_
+ \ IMPORTED_LOCATION
+ \ IMPORTED_LOCATION_
+ \ MACOSX_BUNDLE
+ \ OUTPUT_NAME
+ \ RUNTIME_OUTPUT_DIRECTORY
+ \ TARGET
syn keyword cmakeKWadd_library contained
- \ ALIAS ARCHIVE_OUTPUT_DIRECTORY CLI CONFIG DLL EXCLUDE_FROM_ALL FRAMEWORK GLOBAL IMPORTED IMPORTED_ IMPORTED_LOCATION IMPORTED_LOCATION_ INTERFACE_ LIBRARY_OUTPUT_DIRECTORY MODULE OBJECT ON OUTPUT_NAME POSITION_INDEPENDENT_CODE POST_BUILD PRE_BUILD PRE_LINK RUNTIME_OUTPUT_DIRECTORY SHARED STATIC TARGET_OBJECTS UNKNOWN
+ \ ALIAS
+ \ ARCHIVE_OUTPUT_DIRECTORY
+ \ CLI
+ \ CONFIG
+ \ DLL
+ \ EXCLUDE_FROM_ALL
+ \ FRAMEWORK
+ \ GLOBAL
+ \ HEADER_FILE_ONLY
+ \ IMPORTED
+ \ IMPORTED_
+ \ IMPORTED_LOCATION
+ \ IMPORTED_LOCATION_
+ \ IMPORTED_OBJECTS
+ \ IMPORTED_OBJECTS_
+ \ INTERFACE_
+ \ LIBRARY_OUTPUT_DIRECTORY
+ \ MODULE
+ \ OBJECT
+ \ ON
+ \ OUTPUT_NAME
+ \ POSITION_INDEPENDENT_CODE
+ \ POST_BUILD
+ \ PRE_BUILD
+ \ PRE_LINK
+ \ PUBLIC_HEADER
+ \ RUNTIME_OUTPUT_DIRECTORY
+ \ SHARED
+ \ STATIC
+ \ TARGET_OBJECTS
+ \ UNKNOWN
+
+syn keyword cmakeKWadd_link_options contained
+ \ CMAKE_
+ \ GCC
+ \ GNU
+ \ LANG
+ \ LINKER
+ \ LINK_OPTIONS
+ \ SHELL
+ \ STATIC_LIBRARY_OPTIONS
+ \ UNIX_COMMAND
+ \ _LINKER_WRAPPER_FLAG
+ \ _LINKER_WRAPPER_FLAG_SEP
syn keyword cmakeKWadd_subdirectory contained
\ EXCLUDE_FROM_ALL
syn keyword cmakeKWadd_test contained
- \ BUILD_TESTING COMMAND CONFIGURATIONS FAIL_REGULAR_EXPRESSION NAME PASS_REGULAR_EXPRESSION TARGET_FILE WILL_FAIL WORKING_DIRECTORY
+ \ BUILD_TESTING
+ \ COMMAND
+ \ CONFIGURATIONS
+ \ FAIL_REGULAR_EXPRESSION
+ \ NAME
+ \ OFF
+ \ PASS_REGULAR_EXPRESSION
+ \ SKIP_REGULAR_EXPRESSION
+ \ TARGET_FILE
+ \ WILL_FAIL
+ \ WORKING_DIRECTORY
syn keyword cmakeKWbuild_command contained
- \ CONFIGURATION TARGET
-
-syn keyword cmakeKWbuild_name contained
- \ CMAKE_CXX_COMPILER
+ \ CONFIGURATION
+ \ TARGET
syn keyword cmakeKWcmake_host_system_information contained
- \ AVAILABLE_PHYSICAL_MEMORY AVAILABLE_VIRTUAL_MEMORY FQDN HOSTNAME NUMBER_OF_LOGICAL_CORES NUMBER_OF_PHYSICAL_CORES QUERY RESULT TOTAL_PHYSICAL_MEMORY TOTAL_VIRTUAL_MEMORY
+ \ AVAILABLE_PHYSICAL_MEMORY
+ \ AVAILABLE_VIRTUAL_MEMORY
+ \ FQDN
+ \ HAS_FPU
+ \ HAS_MMX
+ \ HAS_MMX_PLUS
+ \ HAS_SERIAL_NUMBER
+ \ HAS_SSE
+ \ HAS_SSE_FP
+ \ HAS_SSE_MMX
+ \ HOSTNAME
+ \ ID
+ \ NUMBER_OF_LOGICAL_CORES
+ \ NUMBER_OF_PHYSICAL_CORES
+ \ OS_NAME
+ \ OS_PLATFORM
+ \ OS_RELEASE
+ \ OS_VERSION
+ \ PROCESSOR_DESCRIPTION
+ \ PROCESSOR_NAME
+ \ PROCESSOR_SERIAL_NUMBER
+ \ QUERY
+ \ RESULT
+ \ TOTAL_PHYSICAL_MEMORY
+ \ TOTAL_VIRTUAL_MEMORY
syn keyword cmakeKWcmake_minimum_required contained
- \ FATAL_ERROR VERSION
+ \ FATAL_ERROR
+ \ VERSION
syn keyword cmakeKWcmake_parse_arguments contained
- \ ARGN CONFIGURATIONS DESTINATION FALSE FAST FILES MY_INSTALL MY_INSTALL_CONFIGURATIONS MY_INSTALL_DESTINATION MY_INSTALL_FAST MY_INSTALL_OPTIONAL MY_INSTALL_RENAME MY_INSTALL_TARGETS MY_INSTALL_UNPARSED_ARGUMENTS OPTIONAL PARSE_ARGV RENAME TARGETS TRUE _UNPARSED_ARGUMENTS
+ \ ARGN
+ \ CONFIGURATIONS
+ \ DESTINATION
+ \ FALSE
+ \ FAST
+ \ FILES
+ \ MY_INSTALL
+ \ MY_INSTALL_CONFIGURATIONS
+ \ MY_INSTALL_DESTINATION
+ \ MY_INSTALL_FAST
+ \ MY_INSTALL_KEYWORDS_MISSING_VALUES
+ \ MY_INSTALL_OPTIONAL
+ \ MY_INSTALL_RENAME
+ \ MY_INSTALL_TARGETS
+ \ MY_INSTALL_UNPARSED_ARGUMENTS
+ \ OPTIONAL
+ \ PARSE_ARGV
+ \ RENAME
+ \ TARGETS
+ \ TRUE
+ \ UNDEFINED
+ \ _KEYWORDS_MISSING_VALUES
+ \ _UNPARSED_ARGUMENTS
syn keyword cmakeKWcmake_policy contained
- \ CMAKE_POLICY_DEFAULT_CMP CMP GET NNNN NO_POLICY_SCOPE OLD POP PUSH SET VERSION
+ \ CMAKE_POLICY_DEFAULT_CMP
+ \ CMP
+ \ GET
+ \ NNNN
+ \ NO_POLICY_SCOPE
+ \ OLD
+ \ POP
+ \ PUSH
+ \ SET
+ \ VERSION
syn keyword cmakeKWconfigure_file contained
- \ COPYONLY CRLF DOS ESCAPE_QUOTES FOO_ENABLE FOO_STRING LF NEWLINE_STYLE VAR
+ \ COPYONLY
+ \ CRLF
+ \ DOS
+ \ ESCAPE_QUOTES
+ \ FOO_ENABLE
+ \ FOO_STRING
+ \ LF
+ \ NEWLINE_STYLE
+ \ VAR
syn keyword cmakeKWcreate_test_sourcelist contained
- \ CMAKE_TESTDRIVER_AFTER_TESTMAIN CMAKE_TESTDRIVER_BEFORE_TESTMAIN EXTRA_INCLUDE FUNCTION
+ \ CMAKE_TESTDRIVER_AFTER_TESTMAIN
+ \ CMAKE_TESTDRIVER_BEFORE_TESTMAIN
+ \ EXTRA_INCLUDE
+ \ FUNCTION
syn keyword cmakeKWctest_build contained
- \ ALL_BUILD APPEND BUILD CAPTURE_CMAKE_ERROR CONFIGURATION CTEST_BUILD_CONFIGURATION CTEST_BUILD_FLAGS CTEST_BUILD_TARGET CTEST_PROJECT_NAME FLAGS NUMBER_ERRORS NUMBER_WARNINGS QUIET RETURN_VALUE TARGET
+ \ ALL_BUILD
+ \ APPEND
+ \ BUILD
+ \ CAPTURE_CMAKE_ERROR
+ \ CONFIGURATION
+ \ CTEST_BUILD_CONFIGURATION
+ \ CTEST_BUILD_FLAGS
+ \ CTEST_BUILD_TARGET
+ \ FLAGS
+ \ NUMBER_ERRORS
+ \ NUMBER_WARNINGS
+ \ QUIET
+ \ RETURN_VALUE
+ \ TARGET
syn keyword cmakeKWctest_configure contained
- \ APPEND BUILD CAPTURE_CMAKE_ERROR OPTIONS QUIET RETURN_VALUE SOURCE
+ \ APPEND
+ \ BUILD
+ \ CAPTURE_CMAKE_ERROR
+ \ OPTIONS
+ \ QUIET
+ \ RETURN_VALUE
+ \ SOURCE
syn keyword cmakeKWctest_coverage contained
- \ APPEND BUILD CAPTURE_CMAKE_ERROR LABELS QUIET RETURN_VALUE
+ \ APPEND
+ \ BUILD
+ \ CAPTURE_CMAKE_ERROR
+ \ LABELS
+ \ QUIET
+ \ RETURN_VALUE
syn keyword cmakeKWctest_memcheck contained
- \ APPEND BUILD DEFECT_COUNT EXCLUDE EXCLUDE_LABEL INCLUDE INCLUDE_LABEL OFF ON PARALLEL_LEVEL QUIET RETURN_VALUE SCHEDULE_RANDOM START STOP_TIME STRIDE TEST_LOAD
+ \ APPEND
+ \ BUILD
+ \ DEFECT_COUNT
+ \ EXCLUDE
+ \ EXCLUDE_FIXTURE
+ \ EXCLUDE_FIXTURE_CLEANUP
+ \ EXCLUDE_FIXTURE_SETUP
+ \ EXCLUDE_LABEL
+ \ INCLUDE
+ \ INCLUDE_LABEL
+ \ OFF
+ \ ON
+ \ PARALLEL_LEVEL
+ \ QUIET
+ \ RETURN_VALUE
+ \ SCHEDULE_RANDOM
+ \ START
+ \ STOP_TIME
+ \ STRIDE
+ \ TEST_LOAD
syn keyword cmakeKWctest_run_script contained
- \ NEW_PROCESS RETURN_VALUE
+ \ NEW_PROCESS
+ \ RETURN_VALUE
syn keyword cmakeKWctest_start contained
- \ APPEND QUIET TAG TRACK
+ \ APPEND
+ \ QUIET
+ \ TAG
+ \ TRACK
syn keyword cmakeKWctest_submit contained
- \ API CDASH_UPLOAD CDASH_UPLOAD_TYPE CTEST_EXTRA_SUBMIT_FILES CTEST_NOTES_FILES FILES PARTS QUIET RETRY_COUNT RETRY_DELAY RETURN_VALUE
+ \ API
+ \ BUILD_ID
+ \ CAPTURE_CMAKE_ERROR
+ \ CDASH_UPLOAD
+ \ CDASH_UPLOAD_TYPE
+ \ CTEST_EXTRA_SUBMIT_FILES
+ \ CTEST_NOTES_FILES
+ \ FILES
+ \ HTTPHEADER
+ \ PARTS
+ \ QUIET
+ \ RETRY_COUNT
+ \ RETRY_DELAY
+ \ RETURN_VALUE
+ \ SUBMIT_URL
syn keyword cmakeKWctest_test contained
- \ APPEND BUILD CAPTURE_CMAKE_ERROR CPU EXCLUDE EXCLUDE_LABEL INCLUDE INCLUDE_LABEL OFF ON PARALLEL_LEVEL QUIET RETURN_VALUE SCHEDULE_RANDOM START STOP_TIME STRIDE TEST_LOAD
+ \ APPEND
+ \ BUILD
+ \ CAPTURE_CMAKE_ERROR
+ \ CPU
+ \ EXCLUDE
+ \ EXCLUDE_FIXTURE
+ \ EXCLUDE_FIXTURE_CLEANUP
+ \ EXCLUDE_FIXTURE_SETUP
+ \ EXCLUDE_LABEL
+ \ INCLUDE
+ \ INCLUDE_LABEL
+ \ OFF
+ \ ON
+ \ PARALLEL_LEVEL
+ \ QUIET
+ \ RETURN_VALUE
+ \ SCHEDULE_RANDOM
+ \ START
+ \ STOP_TIME
+ \ STRIDE
+ \ TEST_LOAD
syn keyword cmakeKWctest_update contained
- \ QUIET RETURN_VALUE SOURCE
+ \ CAPTURE_CMAKE_ERROR
+ \ QUIET
+ \ RETURN_VALUE
+ \ SOURCE
syn keyword cmakeKWctest_upload contained
- \ CAPTURE_CMAKE_ERROR FILES QUIET
+ \ CAPTURE_CMAKE_ERROR
+ \ FILES
+ \ QUIET
syn keyword cmakeKWdefine_property contained
- \ BRIEF_DOCS CACHED_VARIABLE DIRECTORY FULL_DOCS GLOBAL INHERITED PROPERTY SOURCE TARGET TEST VARIABLE
+ \ APPEND
+ \ APPEND_STRING
+ \ BRIEF_DOCS
+ \ CACHED_VARIABLE
+ \ DIRECTORY
+ \ FULL_DOCS
+ \ GLOBAL
+ \ INHERITED
+ \ PROPERTY
+ \ SOURCE
+ \ TARGET
+ \ TEST
+ \ VARIABLE
syn keyword cmakeKWenable_language contained
+ \ ASM
+ \ CUDA
\ OPTIONAL
+syn keyword cmakeKWenable_testing contained
+ \ BUILD_TESTING
+
syn keyword cmakeKWexec_program contained
- \ ARGS OUTPUT_VARIABLE RETURN_VALUE
+ \ ARGS
+ \ OUTPUT_VARIABLE
+ \ RETURN_VALUE
syn keyword cmakeKWexecute_process contained
- \ ANSI AUTO COMMAND ENCODING ERROR_FILE ERROR_QUIET ERROR_STRIP_TRAILING_WHITESPACE ERROR_VARIABLE INPUT_FILE NONE OEM OUTPUT_FILE OUTPUT_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE RESULT_VARIABLE TIMEOUT UTF VERBATIM WORKING_DIRECTORY
+ \ ANSI
+ \ AUTO
+ \ COMMAND
+ \ COMMAND_ECHO
+ \ ENCODING
+ \ ERROR_FILE
+ \ ERROR_QUIET
+ \ ERROR_STRIP_TRAILING_WHITESPACE
+ \ ERROR_VARIABLE
+ \ INPUT_FILE
+ \ NONE
+ \ OEM
+ \ OUTPUT_FILE
+ \ OUTPUT_QUIET
+ \ OUTPUT_STRIP_TRAILING_WHITESPACE
+ \ OUTPUT_VARIABLE
+ \ RESULTS_VARIABLE
+ \ RESULT_VARIABLE
+ \ RFC
+ \ STDERR
+ \ STDOUT
+ \ TIMEOUT
+ \ UTF
+ \ VERBATIM
+ \ WORKING_DIRECTORY
syn keyword cmakeKWexport contained
- \ ANDROID_MK APPEND CONFIG EXPORT EXPORT_LINK_INTERFACE_LIBRARIES FILE IMPORTED IMPORTED_ NAMESPACE NDK OLD PACKAGE TARGETS
+ \ ANDROID_MK
+ \ APPEND
+ \ CONFIG
+ \ EXPORT
+ \ EXPORT_LINK_INTERFACE_LIBRARIES
+ \ FILE
+ \ IMPORTED
+ \ IMPORTED_
+ \ NAMESPACE
+ \ NDK
+ \ OLD
+ \ PACKAGE
+ \ TARGETS
syn keyword cmakeKWexport_library_dependencies contained
- \ APPEND EXPORT INCLUDE LINK_INTERFACE_LIBRARIES SET
+ \ APPEND
+ \ EXPORT
+ \ INCLUDE
+ \ LINK_INTERFACE_LIBRARIES
+ \ SET
syn keyword cmakeKWfile contained
- \ ALGO APPEND ASCII CMAKE_TLS_CAINFO CMAKE_TLS_VERIFY CONDITION CONFIG CONTENT COPY CR DESTINATION DIRECTORY_PERMISSIONS DOWNLOAD ENCODING EXCLUDE EXPECTED_HASH FILES_MATCHING FILE_PERMISSIONS FOLLOW_SYMLINKS FUNCTION GENERATE GLOB GLOB_RECURSE GUARD HASH HEX HTTPHEADER INACTIVITY_TIMEOUT INSTALL LENGTH_MAXIMUM LENGTH_MINIMUM LF LIMIT LIMIT_COUNT LIMIT_INPUT LIMIT_OUTPUT LIST_DIRECTORIES LOCK LOG MAKE_DIRECTORY NEWLINE_CONSUME NO_HEX_CONVERSION NO_SOURCE_PERMISSIONS OFFSET OLD PATTERN PROCESS READ REGEX RELATIVE RELATIVE_PATH RELEASE REMOVE REMOVE_RECURSE RENAME RESULT_VARIABLE SHOW_PROGRESS SORT SSL STATUS STRINGS TIMESTAMP TLS_CAINFO TLS_VERIFY TO_CMAKE_PATH TO_NATIVE_PATH UPLOAD USERPWD USE_SOURCE_PERMISSIONS UTC UTF WRITE
+ \ ALGO
+ \ APPEND
+ \ ASCII
+ \ CMAKE_TLS_CAINFO
+ \ CMAKE_TLS_VERIFY
+ \ CONDITION
+ \ CONFIG
+ \ CONFIGURE_DEPENDS
+ \ CONTENT
+ \ COPY
+ \ COPY_ON_ERROR
+ \ CREATE_LINK
+ \ DESTINATION
+ \ DIRECTORY_PERMISSIONS
+ \ DOWNLOAD
+ \ ENCODING
+ \ EXCLUDE
+ \ EXPECTED_HASH
+ \ FILES_MATCHING
+ \ FILE_PERMISSIONS
+ \ FOLLOW_SYMLINKS
+ \ FOLLOW_SYMLINK_CHAIN
+ \ FUNCTION
+ \ GENERATE
+ \ GLOB
+ \ GLOB_RECURSE
+ \ GUARD
+ \ HASH
+ \ HEX
+ \ HTTPHEADER
+ \ IGNORED
+ \ INACTIVITY_TIMEOUT
+ \ INSTALL
+ \ IS_ABSOLUTE
+ \ LENGTH_MAXIMUM
+ \ LENGTH_MINIMUM
+ \ LF
+ \ LIMIT
+ \ LIMIT_COUNT
+ \ LIMIT_INPUT
+ \ LIMIT_OUTPUT
+ \ LIST_DIRECTORIES
+ \ LOCK
+ \ LOG
+ \ MAKE_DIRECTORY
+ \ NETRC
+ \ NETRC_FILE
+ \ NEWLINE_CONSUME
+ \ NOT
+ \ NO_HEX_CONVERSION
+ \ NO_SOURCE_PERMISSIONS
+ \ OFFSET
+ \ OLD
+ \ OPTIONAL
+ \ OUTPUT
+ \ PATTERN
+ \ PROCESS
+ \ READ
+ \ READ_SYMLINK
+ \ REGEX
+ \ RELATIVE_PATH
+ \ RELEASE
+ \ REMOVE
+ \ REMOVE_RECURSE
+ \ RENAME
+ \ REQUIRED
+ \ RESULT
+ \ RESULT_VARIABLE
+ \ SHOW_PROGRESS
+ \ SIZE
+ \ SSL
+ \ STATUS
+ \ STRINGS
+ \ SYMBOLIC
+ \ TIMESTAMP
+ \ TLS_CAINFO
+ \ TLS_VERIFY
+ \ TOUCH
+ \ TOUCH_NOCREATE
+ \ TO_CMAKE_PATH
+ \ TO_NATIVE_PATH
+ \ UPLOAD
+ \ URL
+ \ USERPWD
+ \ USE_SOURCE_PERMISSIONS
+ \ UTC
+ \ UTF
+ \ WRITE
syn keyword cmakeKWfind_file contained
- \ CMAKE_FIND_ROOT_PATH_BOTH DOC DVAR HINTS INCLUDE NAMES NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_SYSTEM_PATH NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH ONLY_CMAKE_FIND_ROOT_PATH OS PATHS PATH_SUFFIXES VAR
+ \ CMAKE_FIND_ROOT_PATH_BOTH
+ \ DOC
+ \ DVAR
+ \ HINTS
+ \ INCLUDE
+ \ NAMES
+ \ NO_CMAKE_ENVIRONMENT_PATH
+ \ NO_CMAKE_FIND_ROOT_PATH
+ \ NO_CMAKE_PATH
+ \ NO_CMAKE_SYSTEM_PATH
+ \ NO_DEFAULT_PATH
+ \ NO_PACKAGE_ROOT_PATH
+ \ NO_SYSTEM_ENVIRONMENT_PATH
+ \ ONLY_CMAKE_FIND_ROOT_PATH
+ \ PATHS
+ \ PATH_SUFFIXES
+ \ VAR
syn keyword cmakeKWfind_library contained
- \ CMAKE_FIND_ROOT_PATH_BOTH DOC DVAR HINTS LIB NAMES NAMES_PER_DIR NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_SYSTEM_PATH NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH ONLY_CMAKE_FIND_ROOT_PATH OS PATHS PATH_SUFFIXES VAR
+ \ CMAKE_FIND_ROOT_PATH_BOTH
+ \ DOC
+ \ DVAR
+ \ HINTS
+ \ LIB
+ \ NAMES
+ \ NAMES_PER_DIR
+ \ NO_CMAKE_ENVIRONMENT_PATH
+ \ NO_CMAKE_FIND_ROOT_PATH
+ \ NO_CMAKE_PATH
+ \ NO_CMAKE_SYSTEM_PATH
+ \ NO_DEFAULT_PATH
+ \ NO_PACKAGE_ROOT_PATH
+ \ NO_SYSTEM_ENVIRONMENT_PATH
+ \ ONLY_CMAKE_FIND_ROOT_PATH
+ \ PATHS
+ \ PATH_SUFFIXES
+ \ VAR
syn keyword cmakeKWfind_package contained
- \ CMAKE_DISABLE_FIND_PACKAGE_ CMAKE_FIND_ROOT_PATH_BOTH COMPONENTS CONFIG CONFIGS DEC DVAR EXACT HINTS MODULE NAMES NATURAL NO_CMAKE_BUILDS_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_PATH NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH NO_DEFAULT_PATH NO_MODULE NO_POLICY_SCOPE NO_SYSTEM_ENVIRONMENT_PATH ONLY_CMAKE_FIND_ROOT_PATH OPTIONAL_COMPONENTS OS PACKAGE_FIND_NAME PACKAGE_FIND_VERSION PACKAGE_FIND_VERSION_COUNT PACKAGE_FIND_VERSION_MAJOR PACKAGE_FIND_VERSION_MINOR PACKAGE_FIND_VERSION_PATCH PACKAGE_FIND_VERSION_TWEAK PACKAGE_VERSION PACKAGE_VERSION_COMPATIBLE PACKAGE_VERSION_EXACT PACKAGE_VERSION_UNSUITABLE PATHS PATH_SUFFIXES QUIET REQUIRED SET TRUE _CONFIG _CONSIDERED_CONFIGS _CONSIDERED_VERSIONS _DIR _FIND_COMPONENTS _FIND_QUIETLY _FIND_REQUIRED _FIND_REQUIRED_ _FIND_VERSION_EXACT _FOUND
+ \ ABI
+ \ BUNDLE
+ \ CMAKE_DISABLE_FIND_PACKAGE_
+ \ CMAKE_FIND_ROOT_PATH_BOTH
+ \ COMPONENTS
+ \ CONFIG
+ \ CONFIGS
+ \ DEC
+ \ DVAR
+ \ EXACT
+ \ FRAMEWORK
+ \ HINTS
+ \ MODULE
+ \ NAMES
+ \ NATURAL
+ \ NO_CMAKE_BUILDS_PATH
+ \ NO_CMAKE_ENVIRONMENT_PATH
+ \ NO_CMAKE_FIND_ROOT_PATH
+ \ NO_CMAKE_PACKAGE_REGISTRY
+ \ NO_CMAKE_PATH
+ \ NO_CMAKE_SYSTEM_PACKAGE_REGISTRY
+ \ NO_CMAKE_SYSTEM_PATH
+ \ NO_DEFAULT_PATH
+ \ NO_MODULE
+ \ NO_PACKAGE_ROOT_PATH
+ \ NO_POLICY_SCOPE
+ \ NO_SYSTEM_ENVIRONMENT_PATH
+ \ ONLY_CMAKE_FIND_ROOT_PATH
+ \ OPTIONAL_COMPONENTS
+ \ PACKAGE_FIND_NAME
+ \ PACKAGE_FIND_VERSION
+ \ PACKAGE_FIND_VERSION_COUNT
+ \ PACKAGE_FIND_VERSION_MAJOR
+ \ PACKAGE_FIND_VERSION_MINOR
+ \ PACKAGE_FIND_VERSION_PATCH
+ \ PACKAGE_FIND_VERSION_TWEAK
+ \ PACKAGE_VERSION
+ \ PACKAGE_VERSION_COMPATIBLE
+ \ PACKAGE_VERSION_EXACT
+ \ PACKAGE_VERSION_UNSUITABLE
+ \ PATHS
+ \ PATH_SUFFIXES
+ \ QUIET
+ \ REQUIRED
+ \ SET
+ \ TRUE
+ \ _CONFIG
+ \ _CONSIDERED_CONFIGS
+ \ _CONSIDERED_VERSIONS
+ \ _DIR
+ \ _FIND_COMPONENTS
+ \ _FIND_QUIETLY
+ \ _FIND_REQUIRED
+ \ _FIND_REQUIRED_
+ \ _FIND_VERSION_EXACT
+ \ _FOUND
syn keyword cmakeKWfind_path contained
- \ CMAKE_FIND_ROOT_PATH_BOTH DOC DVAR HINTS INCLUDE NAMES NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_SYSTEM_PATH NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH ONLY_CMAKE_FIND_ROOT_PATH OS PATHS PATH_SUFFIXES VAR
+ \ CMAKE_FIND_ROOT_PATH_BOTH
+ \ DOC
+ \ DVAR
+ \ HINTS
+ \ INCLUDE
+ \ NAMES
+ \ NO_CMAKE_ENVIRONMENT_PATH
+ \ NO_CMAKE_FIND_ROOT_PATH
+ \ NO_CMAKE_PATH
+ \ NO_CMAKE_SYSTEM_PATH
+ \ NO_DEFAULT_PATH
+ \ NO_PACKAGE_ROOT_PATH
+ \ NO_SYSTEM_ENVIRONMENT_PATH
+ \ ONLY_CMAKE_FIND_ROOT_PATH
+ \ PATHS
+ \ PATH_SUFFIXES
+ \ VAR
syn keyword cmakeKWfind_program contained
- \ CMAKE_FIND_ROOT_PATH_BOTH DOC DVAR HINTS NAMES NAMES_PER_DIR NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_FIND_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_SYSTEM_PATH NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH ONLY_CMAKE_FIND_ROOT_PATH OS PATHS PATH_SUFFIXES VAR
+ \ CMAKE_FIND_ROOT_PATH_BOTH
+ \ DOC
+ \ DVAR
+ \ HINTS
+ \ NAMES
+ \ NAMES_PER_DIR
+ \ NO_CMAKE_ENVIRONMENT_PATH
+ \ NO_CMAKE_FIND_ROOT_PATH
+ \ NO_CMAKE_PATH
+ \ NO_CMAKE_SYSTEM_PATH
+ \ NO_DEFAULT_PATH
+ \ NO_PACKAGE_ROOT_PATH
+ \ NO_SYSTEM_ENVIRONMENT_PATH
+ \ ONLY_CMAKE_FIND_ROOT_PATH
+ \ PATHS
+ \ PATH_SUFFIXES
+ \ VAR
syn keyword cmakeKWfltk_wrap_ui contained
\ FLTK
syn keyword cmakeKWforeach contained
- \ ARGS IN ITEMS LISTS RANGE
+ \ IN
+ \ ITEMS
+ \ LISTS
+ \ RANGE
+ \ STATUS
syn keyword cmakeKWfunction contained
- \ ARGC ARGN ARGS ARGV PARENT_SCOPE
+ \ ARGC
+ \ ARGN
+ \ ARGV
+ \ FOO
+ \ PARENT_SCOPE
syn keyword cmakeKWget_cmake_property contained
- \ COMPONENTS GLOBAL MACROS VAR VARIABLES
+ \ COMPONENTS
+ \ GLOBAL
+ \ MACROS
+ \ VARIABLES
syn keyword cmakeKWget_directory_property contained
- \ DEFINITION DIRECTORY
+ \ DEFINITION
+ \ DIRECTORY
+ \ INHERITED
syn keyword cmakeKWget_filename_component contained
- \ ABSOLUTE ARG_VAR BASE_DIR CACHE COMP DIRECTORY EXT NAME NAME_WE PATH PROGRAM PROGRAM_ARGS REALPATH VAR
+ \ ABSOLUTE
+ \ BASE_DIR
+ \ DIRECTORY
+ \ EXT
+ \ LAST_EXT
+ \ NAME
+ \ NAME_WE
+ \ NAME_WLE
+ \ PATH
+ \ PROGRAM
+ \ PROGRAM_ARGS
+ \ REALPATH
syn keyword cmakeKWget_property contained
- \ BRIEF_DOCS CACHE DEFINED DIRECTORY FULL_DOCS GLOBAL INSTALL PROPERTY SET SOURCE TARGET TEST VARIABLE
+ \ BRIEF_DOCS
+ \ DEFINED
+ \ DIRECTORY
+ \ FULL_DOCS
+ \ GLOBAL
+ \ INSTALL
+ \ PROPERTY
+ \ SET
+ \ SOURCE
+ \ TARGET
+ \ TEST
+ \ VARIABLE
syn keyword cmakeKWget_source_file_property contained
- \ LOCATION VAR
+ \ INHERITED
+ \ LOCATION
+ \ VAR
syn keyword cmakeKWget_target_property contained
+ \ INHERITED
\ VAR
syn keyword cmakeKWget_test_property contained
+ \ INHERITED
\ VAR
syn keyword cmakeKWif contained
- \ ARGS CMAKE_MATCH_ CMP COMMAND DEFINED EQUAL EXISTS FALSE GREATER GREATER_EQUAL IGNORE IN_LIST IS_ABSOLUTE IS_DIRECTORY IS_NEWER_THAN IS_SYMLINK LESS LESS_EQUAL MATCHES NNNN NOT OFF OR POLICY STREQUAL STRGREATER STRGREATER_EQUAL STRLESS STRLESS_EQUAL TARGET TEST THEN TRUE VERSION_EQUAL VERSION_GREATER VERSION_GREATER_EQUAL VERSION_LESS VERSION_LESS_EQUAL YES
+ \ CMAKE_MATCH_
+ \ CMP
+ \ COMMAND
+ \ DEFINED
+ \ EQUAL
+ \ EXISTS
+ \ FALSE
+ \ GREATER
+ \ GREATER_EQUAL
+ \ IGNORE
+ \ IN_LIST
+ \ IS_ABSOLUTE
+ \ IS_DIRECTORY
+ \ IS_NEWER_THAN
+ \ IS_SYMLINK
+ \ LESS
+ \ LESS_EQUAL
+ \ MATCHES
+ \ NNNN
+ \ NOT
+ \ OFF
+ \ OR
+ \ POLICY
+ \ STREQUAL
+ \ STRGREATER
+ \ STRGREATER_EQUAL
+ \ STRLESS
+ \ STRLESS_EQUAL
+ \ TARGET
+ \ TEST
+ \ TRUE
+ \ VERSION_EQUAL
+ \ VERSION_GREATER
+ \ VERSION_GREATER_EQUAL
+ \ VERSION_LESS
+ \ VERSION_LESS_EQUAL
+ \ YES
syn keyword cmakeKWinclude contained
- \ NO_POLICY_SCOPE OPTIONAL RESULT_VARIABLE
+ \ NO_POLICY_SCOPE
+ \ OPTIONAL
+ \ RESULT_VARIABLE
syn keyword cmakeKWinclude_directories contained
- \ AFTER BEFORE INCLUDE_DIRECTORIES ON SYSTEM
+ \ AFTER
+ \ BEFORE
+ \ INCLUDE_DIRECTORIES
+ \ ON
+ \ SYSTEM
syn keyword cmakeKWinclude_external_msproject contained
- \ GUID MAP_IMPORTED_CONFIG_ PLATFORM TYPE WIX
+ \ GUID
+ \ MAP_IMPORTED_CONFIG_
+ \ PLATFORM
+ \ TYPE
+ \ WIX
+
+syn keyword cmakeKWinclude_guard contained
+ \ DIRECTORY
+ \ GLOBAL
+ \ TRUE
+ \ __CURRENT_FILE_VAR__
syn keyword cmakeKWinstall contained
- \ ARCHIVE BUNDLE CODE COMPONENT CONFIGURATIONS CVS DESTDIR DESTINATION DIRECTORY DIRECTORY_PERMISSIONS DLL EXCLUDE_FROM_ALL EXPORT EXPORT_ANDROID_MK EXPORT_LINK_INTERFACE_LIBRARIES FILES FILES_MATCHING FILE_PERMISSIONS FRAMEWORK GROUP_EXECUTE GROUP_READ GROUP_WRITE IMPORTED_ INCLUDES INSTALL_PREFIX INTERFACE_INCLUDE_DIRECTORIES LIBRARY MACOSX_BUNDLE MESSAGE_NEVER NAMELINK_ONLY NAMELINK_SKIP NAMESPACE NDK OBJECTS OPTIONAL OWNER_EXECUTE OWNER_READ OWNER_WRITE PATTERN PERMISSIONS POST_INSTALL_SCRIPT PRE_INSTALL_SCRIPT PRIVATE_HEADER PROGRAMS PUBLIC_HEADER REGEX RENAME RESOURCE RUNTIME SCRIPT SETGID SETUID SOVERSION TARGETS TRUE USE_SOURCE_PERMISSIONS VERSION WORLD_EXECUTE WORLD_READ WORLD_WRITE
+ \ AFTER
+ \ APT
+ \ ARCHIVE
+ \ BEFORE
+ \ BUILD_TYPE
+ \ BUNDLE
+ \ CMAKE_INSTALL_BINDIR
+ \ CMAKE_INSTALL_DATADIR
+ \ CMAKE_INSTALL_DATAROOTDIR
+ \ CMAKE_INSTALL_DOCDIR
+ \ CMAKE_INSTALL_INCLUDEDIR
+ \ CMAKE_INSTALL_INFODIR
+ \ CMAKE_INSTALL_LIBDIR
+ \ CMAKE_INSTALL_LOCALEDIR
+ \ CMAKE_INSTALL_LOCALSTATEDIR
+ \ CMAKE_INSTALL_MANDIR
+ \ CMAKE_INSTALL_RUNSTATEDIR
+ \ CMAKE_INSTALL_SBINDIR
+ \ CMAKE_INSTALL_SHARESTATEDIR
+ \ CMAKE_INSTALL_SYSCONFDIR
+ \ CODE
+ \ COMPONENT
+ \ CONFIGURATIONS
+ \ CVS
+ \ DATA
+ \ DATAROOT
+ \ DBUILD_TYPE
+ \ DCOMPONENT
+ \ DESTDIR
+ \ DESTINATION
+ \ DIRECTORY
+ \ DIRECTORY_PERMISSIONS
+ \ DLL
+ \ DOC
+ \ EXCLUDE_FROM_ALL
+ \ EXPORT
+ \ EXPORT_ANDROID_MK
+ \ EXPORT_LINK_INTERFACE_LIBRARIES
+ \ EXPORT_NAME
+ \ FILES
+ \ FILES_MATCHING
+ \ FILE_PERMISSIONS
+ \ FRAMEWORK
+ \ GROUP_EXECUTE
+ \ GROUP_READ
+ \ GROUP_WRITE
+ \ IMPORTED_
+ \ INCLUDES
+ \ INFO
+ \ INSTALL_PREFIX
+ \ INTERFACE_INCLUDE_DIRECTORIES
+ \ LIBRARY
+ \ LOCALE
+ \ LOCALSTATE
+ \ MACOSX_BUNDLE
+ \ MAN
+ \ MESSAGE_NEVER
+ \ NAMELINK_COMPONENT
+ \ NAMELINK_ONLY
+ \ NAMELINK_SKIP
+ \ NAMESPACE
+ \ NDK
+ \ OBJECTS
+ \ OPTIONAL
+ \ OWNER_EXECUTE
+ \ OWNER_READ
+ \ OWNER_WRITE
+ \ PATTERN
+ \ PERMISSIONS
+ \ POST_INSTALL_SCRIPT
+ \ PRE_INSTALL_SCRIPT
+ \ PRIVATE_HEADER
+ \ PROGRAMS
+ \ PROPERTIES
+ \ PUBLIC_HEADER
+ \ REGEX
+ \ RENAME
+ \ RESOURCE
+ \ RPM
+ \ RUNSTATE
+ \ RUNTIME
+ \ SBIN
+ \ SCRIPT
+ \ SETGID
+ \ SETUID
+ \ SHAREDSTATE
+ \ SOVERSION
+ \ STATIC
+ \ SYSCONF
+ \ TARGETS
+ \ TRUE
+ \ TYPE
+ \ USE_SOURCE_PERMISSIONS
+ \ VERSION
+ \ WORLD_EXECUTE
+ \ WORLD_READ
+ \ WORLD_WRITE
syn keyword cmakeKWinstall_files contained
- \ FILES GLOB
+ \ FILES
+ \ GLOB
syn keyword cmakeKWinstall_programs contained
- \ FILES GLOB PROGRAMS TARGETS
+ \ FILES
+ \ GLOB
+ \ PROGRAMS
+ \ TARGETS
syn keyword cmakeKWinstall_targets contained
- \ DLL RUNTIME_DIRECTORY TARGETS
+ \ DLL
+ \ RUNTIME_DIRECTORY
+
+syn keyword cmakeKWlink_directories contained
+ \ AFTER
+ \ BEFORE
+ \ LINK_DIRECTORIES
+ \ ON
+ \ ORIGIN
+ \ RPATH
syn keyword cmakeKWlist contained
- \ APPEND CACHE EXCLUDE FILTER FIND GET INCLUDE INSERT INTERNAL LENGTH LIST NOTES PARENT_SCOPE REGEX REMOVE_AT REMOVE_DUPLICATES REMOVE_ITEM REVERSE SORT
+ \ ACTION
+ \ APPEND
+ \ ASCENDING
+ \ CASE
+ \ COMPARE
+ \ DESCENDING
+ \ EXCLUDE
+ \ FILE_BASENAME
+ \ FILTER
+ \ FIND
+ \ GENEX_STRIP
+ \ GET
+ \ INCLUDE
+ \ INSENSITIVE
+ \ INSERT
+ \ INTERNAL
+ \ JOIN
+ \ LENGTH
+ \ ORDER
+ \ OUTPUT_VARIABLE
+ \ PARENT_SCOPE
+ \ POP_BACK
+ \ POP_FRONT
+ \ PREPEND
+ \ REGEX
+ \ REMOVE_AT
+ \ REMOVE_DUPLICATES
+ \ REMOVE_ITEM
+ \ REPLACE
+ \ REVERSE
+ \ SELECTOR
+ \ SENSITIVE
+ \ SORT
+ \ STRING
+ \ STRIP
+ \ SUBLIST
+ \ TOLOWER
+ \ TOUPPER
+ \ TRANSFORM
syn keyword cmakeKWload_cache contained
- \ EXCLUDE INCLUDE_INTERNALS READ_WITH_PREFIX
+ \ EXCLUDE
+ \ INCLUDE_INTERNALS
+ \ READ_WITH_PREFIX
syn keyword cmakeKWload_command contained
- \ CMAKE_LOADED_COMMAND_ COMMAND_NAME
+ \ CMAKE_LOADED_COMMAND_
+ \ COMMAND_NAME
syn keyword cmakeKWmacro contained
- \ ARGC ARGN ARGS ARGV DEFINED GREATER LISTS NOT _BAR _FOO
-
-syn keyword cmakeKWmake_directory contained
- \ MAKE_DIRECTORY
+ \ ARGC
+ \ ARGN
+ \ ARGV
+ \ DEFINED
+ \ FOO
+ \ GREATER
+ \ LISTS
+ \ NOT
syn keyword cmakeKWmark_as_advanced contained
- \ CLEAR FORCE VAR
+ \ CLEAR
+ \ FORCE
syn keyword cmakeKWmath contained
\ EXPR
+ \ HEXADECIMAL
+ \ OUTPUT_FORMAT
syn keyword cmakeKWmessage contained
- \ AUTHOR_WARNING DEPRECATION FATAL_ERROR GUI SEND_ERROR STATUS WARNING
+ \ AUTHOR_WARNING
+ \ DEBUG
+ \ DEPRECATION
+ \ FATAL_ERROR
+ \ GUI
+ \ NOTICE
+ \ SEND_ERROR
+ \ STATUS
+ \ TRACE
+ \ VERBOSE
+ \ WARNING
syn keyword cmakeKWoption contained
- \ OFF ON
+ \ OFF
+ \ ON
syn keyword cmakeKWproject contained
- \ CMAKE_PROJECT_ DESCRIPTION LANGUAGES NAME NONE PROJECT VERSION _BINARY_DIR _INCLUDE _SOURCE_DIR _VERSION _VERSION_MAJOR _VERSION_MINOR _VERSION_PATCH _VERSION_TWEAK
+ \ ASM
+ \ CMAKE_PROJECT_
+ \ CUDA
+ \ DESCRIPTION
+ \ HOMEPAGE_URL
+ \ LANGUAGES
+ \ NAME
+ \ NONE
+ \ PROJECT
+ \ VERSION
+ \ _BINARY_DIR
+ \ _DESCRIPTION
+ \ _HOMEPAGE_URL
+ \ _INCLUDE
+ \ _SOURCE_DIR
+ \ _VERSION
+ \ _VERSION_MAJOR
+ \ _VERSION_MINOR
+ \ _VERSION_PATCH
+ \ _VERSION_TWEAK
+
+syn keyword cmakeKWqt_wrap_cpp contained
+ \ AUTOMOC
+
+syn keyword cmakeKWqt_wrap_ui contained
+ \ AUTOUIC
syn keyword cmakeKWremove contained
- \ REMOVE_ITEM VALUE VAR
+ \ VALUE
+ \ VAR
syn keyword cmakeKWseparate_arguments contained
- \ MSDN NATIVE NATIVE_COMMAND UNIX_COMMAND WINDOWS WINDOWS_COMMAND _COMMAND
+ \ MSDN
+ \ NATIVE_COMMAND
+ \ UNIX_COMMAND
+ \ WINDOWS_COMMAND
syn keyword cmakeKWset contained
- \ BOOL CACHE FILEPATH FORCE INTERNAL OFF ON PARENT_SCOPE STRING STRINGS
+ \ BOOL
+ \ FILEPATH
+ \ FORCE
+ \ INTERNAL
+ \ OFF
+ \ ON
+ \ PARENT_SCOPE
+ \ STRING
+ \ STRINGS
syn keyword cmakeKWset_directory_properties contained
+ \ DIRECTORY
\ PROPERTIES
syn keyword cmakeKWset_property contained
- \ APPEND APPEND_STRING CACHE DIRECTORY GLOBAL INSTALL PROPERTY SOURCE TARGET TEST WIX
+ \ APPEND
+ \ APPEND_STRING
+ \ DIRECTORY
+ \ GLOBAL
+ \ INHERITED
+ \ INSTALL
+ \ PROPERTY
+ \ SOURCE
+ \ TARGET
+ \ TEST
+ \ WIX
syn keyword cmakeKWset_source_files_properties contained
\ PROPERTIES
+ \ SOURCE
syn keyword cmakeKWset_target_properties contained
\ PROPERTIES
+ \ TARGET
syn keyword cmakeKWset_tests_properties contained
\ PROPERTIES
+ \ TEST
syn keyword cmakeKWsource_group contained
- \ FILES PREFIX REGULAR_EXPRESSION TREE
+ \ FILES
+ \ PREFIX
+ \ REGULAR_EXPRESSION
+ \ TREE
syn keyword cmakeKWstring contained
- \ ALPHABET APPEND ASCII CMAKE_MATCH_ COMPARE CONCAT CONFIGURE EQUAL ESCAPE_QUOTES FIND GENEX_STRIP GREATER GREATER_EQUAL GUID HASH LENGTH LESS LESS_EQUAL MAKE_C_IDENTIFIER MATCH MATCHALL MATCHES NAMESPACE NOTEQUAL ONLY RANDOM RANDOM_SEED REGEX REPLACE REVERSE RFC SHA SOURCE_DATE_EPOCH STRIP SUBSTRING SZ TIMESTAMP TOLOWER TOUPPER TYPE US UTC UUID
+ \ ALPHABET
+ \ APPEND
+ \ ASCII
+ \ CMAKE_MATCH_
+ \ COMPARE
+ \ CONCAT
+ \ CONFIGURE
+ \ EQUAL
+ \ ESCAPE_QUOTES
+ \ FIND
+ \ GENEX_STRIP
+ \ GREATER
+ \ GREATER_EQUAL
+ \ GUID
+ \ HASH
+ \ JOIN
+ \ LENGTH
+ \ LESS
+ \ LESS_EQUAL
+ \ MAKE_C_IDENTIFIER
+ \ MATCH
+ \ MATCHALL
+ \ MATCHES
+ \ NAMESPACE
+ \ NOTEQUAL
+ \ ONLY
+ \ PREPEND
+ \ RANDOM
+ \ RANDOM_SEED
+ \ REGEX
+ \ REPEAT
+ \ REPLACE
+ \ REVERSE
+ \ RFC
+ \ SHA
+ \ SOURCE_DATE_EPOCH
+ \ STRIP
+ \ SUBSTRING
+ \ SZ
+ \ TIMESTAMP
+ \ TOLOWER
+ \ TOUPPER
+ \ TYPE
+ \ US
+ \ UTC
+ \ UUID
syn keyword cmakeKWsubdirs contained
- \ EXCLUDE_FROM_ALL PREORDER
+ \ EXCLUDE_FROM_ALL
+ \ PREORDER
syn keyword cmakeKWtarget_compile_definitions contained
- \ COMPILE_DEFINITIONS INTERFACE INTERFACE_COMPILE_DEFINITIONS PRIVATE PUBLIC
+ \ ALIAS
+ \ COMPILE_DEFINITIONS
+ \ FOO
+ \ IMPORTED
+ \ INTERFACE
+ \ INTERFACE_COMPILE_DEFINITIONS
+ \ PRIVATE
+ \ PUBLIC
syn keyword cmakeKWtarget_compile_features contained
- \ COMPILE_FEATURES IMPORTED INTERFACE INTERFACE_COMPILE_FEATURES PRIVATE PUBLIC
+ \ ALIAS
+ \ COMPILE_FEATURES
+ \ IMPORTED
+ \ INTERFACE
+ \ INTERFACE_COMPILE_FEATURES
+ \ PRIVATE
+ \ PUBLIC
syn keyword cmakeKWtarget_compile_options contained
- \ BEFORE COMPILE_OPTIONS IMPORTED INTERFACE INTERFACE_COMPILE_OPTIONS PRIVATE PUBLIC
+ \ ALIAS
+ \ BEFORE
+ \ COMPILE_OPTIONS
+ \ IMPORTED
+ \ INTERFACE
+ \ INTERFACE_COMPILE_OPTIONS
+ \ PRIVATE
+ \ PUBLIC
+ \ SHELL
+ \ UNIX_COMMAND
syn keyword cmakeKWtarget_include_directories contained
- \ BEFORE BUILD_INTERFACE IMPORTED INCLUDE_DIRECTORIES INSTALL_INTERFACE INTERFACE INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_LIBRARIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES PRIVATE PUBLIC SYSTEM
+ \ ALIAS
+ \ BEFORE
+ \ BUILD_INTERFACE
+ \ IMPORTED
+ \ INCLUDE_DIRECTORIES
+ \ INSTALL_INTERFACE
+ \ INTERFACE
+ \ INTERFACE_INCLUDE_DIRECTORIES
+ \ INTERFACE_LINK_LIBRARIES
+ \ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
+ \ PRIVATE
+ \ PUBLIC
+ \ SYSTEM
+
+syn keyword cmakeKWtarget_link_directories contained
+ \ ALIAS
+ \ BEFORE
+ \ IMPORTED
+ \ INTERFACE
+ \ INTERFACE_LINK_DIRECTORIES
+ \ LINK_DIRECTORIES
+ \ ORIGIN
+ \ PRIVATE
+ \ PUBLIC
+ \ RPATH
syn keyword cmakeKWtarget_link_libraries contained
- \ ALIAS DAG DEBUG_CONFIGURATIONS IMPORTED IMPORTED_NO_SONAME INTERFACE INTERFACE_LINK_LIBRARIES LINK_FLAGS LINK_INTERFACE_LIBRARIES LINK_INTERFACE_LIBRARIES_DEBUG LINK_INTERFACE_MULTIPLICITY LINK_PRIVATE LINK_PUBLIC OLD OSX PRIVATE PUBLIC STATIC
+ \ ALIAS
+ \ DA
+ \ DAG
+ \ DEBUG_CONFIGURATIONS
+ \ DOBJ
+ \ IMPORTED
+ \ IMPORTED_NO_SONAME
+ \ INTERFACE
+ \ INTERFACE_LINK_LIBRARIES
+ \ LINK_INTERFACE_LIBRARIES
+ \ LINK_INTERFACE_LIBRARIES_DEBUG
+ \ LINK_INTERFACE_MULTIPLICITY
+ \ LINK_OPTIONS
+ \ LINK_PRIVATE
+ \ LINK_PUBLIC
+ \ OBJECT
+ \ OLD
+ \ PRIVATE
+ \ PUBLIC
+ \ SHARED
+ \ STATIC
+
+syn keyword cmakeKWtarget_link_options contained
+ \ ALIAS
+ \ BEFORE
+ \ CMAKE_
+ \ GCC
+ \ GNU
+ \ IMPORTED
+ \ INTERFACE
+ \ INTERFACE_LINK_OPTIONS
+ \ LANG
+ \ LINKER
+ \ LINK_OPTIONS
+ \ PRIVATE
+ \ PUBLIC
+ \ SHELL
+ \ STATIC_LIBRARY_OPTIONS
+ \ UNIX_COMMAND
+ \ _LINKER_WRAPPER_FLAG
+ \ _LINKER_WRAPPER_FLAG_SEP
syn keyword cmakeKWtarget_sources contained
- \ IMPORTED INTERFACE INTERFACE_SOURCES PRIVATE PUBLIC SOURCES
+ \ ALIAS
+ \ IMPORTED
+ \ INTERFACE
+ \ INTERFACE_SOURCES
+ \ PRIVATE
+ \ PUBLIC
+ \ SOURCES
syn keyword cmakeKWtry_compile contained
- \ ALL_BUILD CMAKE_FLAGS COMPILE_DEFINITIONS COPY_FILE COPY_FILE_ERROR CUDA_EXTENSIONS CUDA_STANDARD CUDA_STANDARD_REQUIRED CXX_EXTENSIONS CXX_STANDARD CXX_STANDARD_REQUIRED C_EXTENSIONS C_STANDARD C_STANDARD_REQUIRED DEFINED DLINK_LIBRARIES DVAR FALSE INCLUDE_DIRECTORIES LANG LINK_DIRECTORIES LINK_LIBRARIES NOT OUTPUT_VARIABLE RESULT_VAR SOURCES TRUE TYPE VALUE _EXTENSIONS _STANDARD _STANDARD_REQUIRED
+ \ ALL_BUILD
+ \ CMAKE_FLAGS
+ \ COMPILE_DEFINITIONS
+ \ COPY_FILE
+ \ COPY_FILE_ERROR
+ \ CUDA_EXTENSIONS
+ \ CUDA_STANDARD
+ \ CUDA_STANDARD_REQUIRED
+ \ CXX_EXTENSIONS
+ \ CXX_STANDARD
+ \ CXX_STANDARD_REQUIRED
+ \ C_EXTENSIONS
+ \ C_STANDARD
+ \ C_STANDARD_REQUIRED
+ \ DEFINED
+ \ DLINK_LIBRARIES
+ \ DVAR
+ \ EXECUTABLE
+ \ FALSE
+ \ GHS
+ \ INCLUDE_DIRECTORIES
+ \ LANG
+ \ LINK_DIRECTORIES
+ \ LINK_LIBRARIES
+ \ LINK_OPTIONS
+ \ MULTI
+ \ NOT
+ \ OUTPUT_VARIABLE
+ \ PRIVATE
+ \ SOURCES
+ \ STATIC_LIBRARY
+ \ STATIC_LIBRARY_OPTIONS
+ \ TRUE
+ \ TYPE
+ \ VALUE
+ \ _EXTENSIONS
+ \ _STANDARD
+ \ _STANDARD_REQUIRED
syn keyword cmakeKWtry_run contained
- \ ARGS CMAKE_FLAGS COMPILE_DEFINITIONS COMPILE_OUTPUT_VARIABLE COMPILE_RESULT_VAR DLINK_LIBRARIES DVAR FAILED_TO_RUN FALSE INCLUDE_DIRECTORIES LINK_DIRECTORIES LINK_LIBRARIES RUN_OUTPUT_VARIABLE RUN_RESULT_VAR TRUE TYPE VALUE __TRYRUN_OUTPUT
+ \ ARGS
+ \ CMAKE_FLAGS
+ \ COMPILE_DEFINITIONS
+ \ COMPILE_OUTPUT_VARIABLE
+ \ DLINK_LIBRARIES
+ \ DVAR
+ \ FAILED_TO_RUN
+ \ FALSE
+ \ INCLUDE_DIRECTORIES
+ \ LINK_DIRECTORIES
+ \ LINK_LIBRARIES
+ \ LINK_OPTIONS
+ \ RUN_OUTPUT_VARIABLE
+ \ TRUE
+ \ TYPE
+ \ VALUE
+ \ __TRYRUN_OUTPUT
syn keyword cmakeKWunset contained
- \ CACHE LD_LIBRARY_PATH PARENT_SCOPE
+ \ PARENT_SCOPE
+ \ VAR
syn keyword cmakeKWuse_mangled_mesa contained
- \ GL OUTPUT_DIRECTORY PATH_TO_MESA
+ \ GL
+ \ OUTPUT_DIRECTORY
+ \ PATH_TO_MESA
syn keyword cmakeKWvariable_requires contained
- \ RESULT_VARIABLE TEST_VARIABLE
+ \ RESULT_VARIABLE
+ \ TEST_VARIABLE
syn keyword cmakeKWvariable_watch contained
\ COMMAND
-syn keyword cmakeKWwhile contained
- \ ARGS
-
syn keyword cmakeKWwrite_file contained
- \ APPEND CONFIGURE_FILE NOTE WRITE
+ \ APPEND
+ \ CONFIGURE_FILE
+ \ NOTE
+ \ WRITE
syn keyword cmakeGeneratorExpressions contained
- \ LINK_LIBRARIES INCLUDE_DIRECTORIES COMPILE_DEFINITIONS CONFIG DEBUG_MODE BOOL AND NOT IF STREQUAL MAP_IMPORTED_CONFIG_ PLATFORM_ID C_COMPILER_ID CXX_COMPILER_ID VERSION_LESS VERSION_GREATER VERSION_EQUAL VERSION_LESS_EQUAL VERSION_GREATER_EQUAL C_COMPILER_VERSION CXX_COMPILER_VERSION TARGET_POLICY COMPILE_FEATURES C_STANDARD CXX_STANDARD COMPILE_LANGUAGE PRIVATE PUBLIC COMPILING_CXX GNU OLD_COMPILER CMAKE_CXX_COMPILER_VERSION CONFIGURATION TARGET_FILE TARGET_FILE_NAME TARGET_FILE_DIR TARGET_LINKER_FILE TARGET_LINKER_FILE_NAME TARGET_LINKER_FILE_DIR TARGET_SONAME_FILE TARGET_SONAME_FILE_NAME TARGET_SONAME_FILE_DIR TARGET_PDB_FILE PDB_NAME PDB_OUTPUT_DIRECTORY PDB_NAME_ PDB_OUTPUT_DIRECTORY_ TARGET_PDB_FILE_NAME TARGET_PDB_FILE_DIR TARGET_BUNDLE_DIR TARGET_BUNDLE_CONTENT_DIR SDK TARGET_PROPERTY INSTALL_PREFIX EXPORT JOIN ANGLE COMMA SEMICOLON TARGET_NAME LINK_ONLY INTERFACE_LINK_LIBRARIES INSTALL_INTERFACE BUILD_INTERFACE LOWER_CASE UPPER_CASE MAKE_C_IDENTIFIER TARGET_OBJECTS OBJECT_LIBRARY SHELL_PATH MSYS
+ \ AND
+ \ ANGLE
+ \ ARCHIVE_OUTPUT_NAME
+ \ ARCHIVE_OUTPUT_NAME_
+ \ BAR
+ \ BOOL
+ \ BUILD_INTERFACE
+ \ CMAKE_
+ \ COMMA
+ \ COMMAND
+ \ COMPILE_DEFINITIONS
+ \ COMPILE_FEATURES
+ \ COMPILE_LANGUAGE
+ \ COMPILE_LANG_AND_ID
+ \ COMPILING_CUDA
+ \ COMPILING_CXX_WITH_CLANG
+ \ COMPILING_CXX_WITH_INTEL
+ \ COMPILING_C_WITH_CLANG
+ \ CONFIG
+ \ CONFIGURATION
+ \ CUDA_COMPILER_ID
+ \ CUDA_COMPILER_VERSION
+ \ CUSTOM_KEYS
+ \ CXX_COMPILER_ID
+ \ CXX_COMPILER_VERSION
+ \ CXX_STANDARD
+ \ C_COMPILER_ID
+ \ C_COMPILER_VERSION
+ \ C_STANDARD
+ \ DEBUG_MODE
+ \ DEBUG_POSTFIX
+ \ EXCLUDE
+ \ EXPORT
+ \ FALSE
+ \ FILTER
+ \ FOO_EXTRA_THINGS
+ \ Fortran_COMPILER_ID
+ \ Fortran_COMPILER_VERSION
+ \ GENERATE
+ \ GENEX_EVAL
+ \ GNU
+ \ IF
+ \ IGNORE
+ \ IMPORT_PREFIX
+ \ IMPORT_SUFFIX
+ \ INCLUDE_DIRECTORIES
+ \ INSTALL_INTERFACE
+ \ INSTALL_PREFIX
+ \ INTERFACE_LINK_LIBRARIES
+ \ IN_LIST
+ \ JOIN
+ \ LANG
+ \ LANG_COMPILER_ID
+ \ LIBRARY_OUTPUT_NAME
+ \ LIBRARY_OUTPUT_NAME_
+ \ LINK_LIBRARIES
+ \ LINK_ONLY
+ \ LOWER_CASE
+ \ MAKE_C_IDENTIFIER
+ \ MAP_IMPORTED_CONFIG_
+ \ NO
+ \ NOT
+ \ OFF
+ \ OLD_COMPILER
+ \ OUTPUT_NAME
+ \ OUTPUT_NAME_
+ \ PDB_NAME
+ \ PDB_NAME_
+ \ PDB_OUTPUT_DIRECTORY
+ \ PDB_OUTPUT_DIRECTORY_
+ \ PLATFORM_ID
+ \ POSIX
+ \ PRIVATE
+ \ PUBLIC
+ \ REMOVE_DUPLICATES
+ \ RUNTIME_OUTPUT_NAME
+ \ RUNTIME_OUTPUT_NAME_
+ \ SDK
+ \ SEMICOLON
+ \ SHELL_PATH
+ \ STREQUAL
+ \ TARGET_BUNDLE_CONTENT_DIR
+ \ TARGET_BUNDLE_DIR
+ \ TARGET_EXISTS
+ \ TARGET_FILE
+ \ TARGET_FILE_BASE_NAME
+ \ TARGET_FILE_DIR
+ \ TARGET_FILE_NAME
+ \ TARGET_FILE_PREFIX
+ \ TARGET_FILE_SUFFIX
+ \ TARGET_GENEX_EVAL
+ \ TARGET_LINKER_FILE
+ \ TARGET_LINKER_FILE_BASE_NAME
+ \ TARGET_LINKER_FILE_DIR
+ \ TARGET_LINKER_FILE_NAME
+ \ TARGET_LINKER_FILE_PREFIX
+ \ TARGET_LINKER_FILE_SUFFIX
+ \ TARGET_NAME_IF_EXISTS
+ \ TARGET_OBJECTS
+ \ TARGET_PDB_FILE
+ \ TARGET_PDB_FILE_BASE_NAME
+ \ TARGET_PDB_FILE_DIR
+ \ TARGET_PDB_FILE_NAME
+ \ TARGET_POLICY
+ \ TARGET_PROPERTY
+ \ TARGET_SONAME_FILE
+ \ TARGET_SONAME_FILE_DIR
+ \ TARGET_SONAME_FILE_NAME
+ \ UPPER_CASE
+ \ VERSION_EQUAL
+ \ VERSION_GREATER
+ \ VERSION_GREATER_EQUAL
+ \ VERSION_LESS
+ \ VERSION_LESS_EQUAL
+ \ _POSTFIX
syn case ignore
syn keyword cmakeCommand
- \ add_compile_options add_custom_command add_custom_target add_definitions add_dependencies add_executable add_library add_subdirectory add_test aux_source_directory break build_command cmake_host_system_information cmake_minimum_required cmake_parse_arguments cmake_policy configure_file continue create_test_sourcelist ctest_build ctest_configure ctest_coverage ctest_empty_binary_directory ctest_memcheck ctest_read_custom_files ctest_run_script ctest_sleep ctest_start ctest_submit ctest_test ctest_update ctest_upload define_property enable_language enable_testing endfunction endmacro execute_process export file find_file find_library find_package find_path find_program fltk_wrap_ui function get_cmake_property get_directory_property get_filename_component get_property get_source_file_property get_target_property get_test_property include include_directories include_external_msproject include_regular_expression install link_directories list load_cache load_command macro mark_as_advanced math message option project qt_wrap_cpp qt_wrap_ui remove_definitions return separate_arguments set set_directory_properties set_property set_source_files_properties set_target_properties set_tests_properties site_name source_group string target_compile_definitions target_compile_features target_compile_options target_include_directories target_link_libraries target_sources try_compile try_run unset variable_watch
+ \ add_compile_definitions
+ \ add_compile_options
+ \ add_custom_command
+ \ add_custom_target
+ \ add_definitions
+ \ add_dependencies
+ \ add_executable
+ \ add_library
+ \ add_link_options
+ \ add_subdirectory
+ \ add_test
+ \ aux_source_directory
+ \ break
+ \ build_command
+ \ cmake_host_system_information
+ \ cmake_minimum_required
+ \ cmake_parse_arguments
+ \ cmake_policy
+ \ configure_file
+ \ continue
+ \ create_test_sourcelist
+ \ ctest_build
+ \ ctest_configure
+ \ ctest_coverage
+ \ ctest_empty_binary_directory
+ \ ctest_memcheck
+ \ ctest_read_custom_files
+ \ ctest_run_script
+ \ ctest_sleep
+ \ ctest_start
+ \ ctest_submit
+ \ ctest_test
+ \ ctest_update
+ \ ctest_upload
+ \ define_property
+ \ enable_language
+ \ enable_testing
+ \ endfunction
+ \ endmacro
+ \ execute_process
+ \ export
+ \ file
+ \ find_file
+ \ find_library
+ \ find_package
+ \ find_path
+ \ find_program
+ \ fltk_wrap_ui
+ \ function
+ \ get_cmake_property
+ \ get_directory_property
+ \ get_filename_component
+ \ get_property
+ \ get_source_file_property
+ \ get_target_property
+ \ get_test_property
+ \ include
+ \ include_directories
+ \ include_external_msproject
+ \ include_guard
+ \ include_regular_expression
+ \ install
+ \ link_directories
+ \ list
+ \ load_cache
+ \ load_command
+ \ macro
+ \ mark_as_advanced
+ \ math
+ \ message
+ \ option
+ \ project
+ \ qt_wrap_cpp
+ \ qt_wrap_ui
+ \ remove_definitions
+ \ return
+ \ separate_arguments
+ \ set
+ \ set_directory_properties
+ \ set_property
+ \ set_source_files_properties
+ \ set_target_properties
+ \ set_tests_properties
+ \ site_name
+ \ source_group
+ \ string
+ \ target_compile_definitions
+ \ target_compile_features
+ \ target_compile_options
+ \ target_include_directories
+ \ target_link_directories
+ \ target_link_libraries
+ \ target_link_options
+ \ target_sources
+ \ try_compile
+ \ try_run
+ \ unset
+ \ variable_watch
\ nextgroup=cmakeArguments
syn keyword cmakeCommandConditional
- \ else elseif endif if
+ \ else
+ \ elseif
+ \ endif
+ \ if
\ nextgroup=cmakeArguments
syn keyword cmakeCommandRepeat
- \ endforeach endwhile foreach while
+ \ endforeach
+ \ endwhile
+ \ foreach
+ \ while
\ nextgroup=cmakeArguments
syn keyword cmakeCommandDeprecated
- \ build_name exec_program export_library_dependencies install_files install_programs install_targets link_libraries make_directory output_required_files remove subdir_depends subdirs use_mangled_mesa utility_source variable_requires write_file
+ \ build_name
+ \ exec_program
+ \ export_library_dependencies
+ \ install_files
+ \ install_programs
+ \ install_targets
+ \ link_libraries
+ \ make_directory
+ \ output_required_files
+ \ remove
+ \ subdir_depends
+ \ subdirs
+ \ use_mangled_mesa
+ \ utility_source
+ \ variable_requires
+ \ write_file
\ nextgroup=cmakeArguments
syn case match
@@ -348,6 +3212,8 @@ syn keyword cmakeTodo
\ TODO FIXME XXX
\ contained
+hi def link cmakeBracketArgument String
+hi def link cmakeBracketComment Comment
hi def link cmakeCommand Function
hi def link cmakeCommandConditional Conditional
hi def link cmakeCommandDeprecated WarningMsg
@@ -357,7 +3223,6 @@ hi def link cmakeEnvironment Special
hi def link cmakeEscaped Special
hi def link cmakeGeneratorExpression WarningMsg
hi def link cmakeGeneratorExpressions Constant
-hi def link cmakeLuaComment Comment
hi def link cmakeModule Include
hi def link cmakeProperty Constant
hi def link cmakeRegistry Underlined
@@ -367,6 +3232,7 @@ hi def link cmakeVariableValue Type
hi def link cmakeVariable Identifier
hi def link cmakeKWExternalProject ModeMsg
+hi def link cmakeKWadd_compile_definitions ModeMsg
hi def link cmakeKWadd_compile_options ModeMsg
hi def link cmakeKWadd_custom_command ModeMsg
hi def link cmakeKWadd_custom_target ModeMsg
@@ -374,10 +3240,10 @@ hi def link cmakeKWadd_definitions ModeMsg
hi def link cmakeKWadd_dependencies ModeMsg
hi def link cmakeKWadd_executable ModeMsg
hi def link cmakeKWadd_library ModeMsg
+hi def link cmakeKWadd_link_options ModeMsg
hi def link cmakeKWadd_subdirectory ModeMsg
hi def link cmakeKWadd_test ModeMsg
hi def link cmakeKWbuild_command ModeMsg
-hi def link cmakeKWbuild_name ModeMsg
hi def link cmakeKWcmake_host_system_information ModeMsg
hi def link cmakeKWcmake_minimum_required ModeMsg
hi def link cmakeKWcmake_parse_arguments ModeMsg
@@ -396,6 +3262,7 @@ hi def link cmakeKWctest_update ModeMsg
hi def link cmakeKWctest_upload ModeMsg
hi def link cmakeKWdefine_property ModeMsg
hi def link cmakeKWenable_language ModeMsg
+hi def link cmakeKWenable_testing ModeMsg
hi def link cmakeKWexec_program ModeMsg
hi def link cmakeKWexecute_process ModeMsg
hi def link cmakeKWexport ModeMsg
@@ -420,20 +3287,23 @@ hi def link cmakeKWif ModeMsg
hi def link cmakeKWinclude ModeMsg
hi def link cmakeKWinclude_directories ModeMsg
hi def link cmakeKWinclude_external_msproject ModeMsg
+hi def link cmakeKWinclude_guard ModeMsg
hi def link cmakeKWinstall ModeMsg
hi def link cmakeKWinstall_files ModeMsg
hi def link cmakeKWinstall_programs ModeMsg
hi def link cmakeKWinstall_targets ModeMsg
+hi def link cmakeKWlink_directories ModeMsg
hi def link cmakeKWlist ModeMsg
hi def link cmakeKWload_cache ModeMsg
hi def link cmakeKWload_command ModeMsg
hi def link cmakeKWmacro ModeMsg
-hi def link cmakeKWmake_directory ModeMsg
hi def link cmakeKWmark_as_advanced ModeMsg
hi def link cmakeKWmath ModeMsg
hi def link cmakeKWmessage ModeMsg
hi def link cmakeKWoption ModeMsg
hi def link cmakeKWproject ModeMsg
+hi def link cmakeKWqt_wrap_cpp ModeMsg
+hi def link cmakeKWqt_wrap_ui ModeMsg
hi def link cmakeKWremove ModeMsg
hi def link cmakeKWseparate_arguments ModeMsg
hi def link cmakeKWset ModeMsg
@@ -449,7 +3319,9 @@ hi def link cmakeKWtarget_compile_definitions ModeMsg
hi def link cmakeKWtarget_compile_features ModeMsg
hi def link cmakeKWtarget_compile_options ModeMsg
hi def link cmakeKWtarget_include_directories ModeMsg
+hi def link cmakeKWtarget_link_directories ModeMsg
hi def link cmakeKWtarget_link_libraries ModeMsg
+hi def link cmakeKWtarget_link_options ModeMsg
hi def link cmakeKWtarget_sources ModeMsg
hi def link cmakeKWtry_compile ModeMsg
hi def link cmakeKWtry_run ModeMsg
@@ -457,7 +3329,35 @@ hi def link cmakeKWunset ModeMsg
hi def link cmakeKWuse_mangled_mesa ModeMsg
hi def link cmakeKWvariable_requires ModeMsg
hi def link cmakeKWvariable_watch ModeMsg
-hi def link cmakeKWwhile ModeMsg
hi def link cmakeKWwrite_file ModeMsg
+" Manually added - difficult to parse out of documentation
+syn case ignore
+
+syn keyword cmakeCommandManuallyAdded
+ \ configure_package_config_file write_basic_package_version_file
+ \ nextgroup=cmakeArguments
+
+syn case match
+
+syn keyword cmakeKWconfigure_package_config_file contained
+ \ INSTALL_DESTINATION PATH_VARS NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO INSTALL_PREFIX
+
+syn keyword cmakeKWconfigure_package_config_file_constants contained
+ \ AnyNewerVersion SameMajorVersion SameMinorVersion ExactVersion
+
+syn keyword cmakeKWwrite_basic_package_version_file contained
+ \ VERSION COMPATIBILITY
+
+hi def link cmakeCommandManuallyAdded Function
+
+hi def link cmakeKWconfigure_package_config_file ModeMsg
+hi def link cmakeKWwrite_basic_package_version_file ModeMsg
+hi def link cmakeKWconfigure_package_config_file_constants Constant
+
let b:current_syntax = "cmake"
+
+let &cpo = s:keepcpo
+unlet s:keepcpo
+
+" vim: set nowrap:
diff --git a/CMakeCPack.cmake b/CMakeCPack.cmake
index a0aacb465..31c2fe456 100644
--- a/CMakeCPack.cmake
+++ b/CMakeCPack.cmake
@@ -102,9 +102,6 @@ if(CMake_INSTALL_COMPONENTS)
if(WIN32 AND NOT CYGWIN)
list(APPEND _CPACK_IFW_COMPONENTS_ALL cmcldeps)
endif()
- if(APPLE)
- list(APPEND _CPACK_IFW_COMPONENTS_ALL cmakexbuild)
- endif()
if(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME)
set(_CPACK_IFW_COMPONENT_UNSPECIFIED_NAME
${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
@@ -218,7 +215,7 @@ if(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
endif()
endif()
-set(CPACK_PACKAGE_CONTACT "cmake@cmake.org")
+set(CPACK_PACKAGE_CONTACT "cmake+development@discourse.cmake.org")
if(UNIX)
set(CPACK_STRIP_FILES "${CMAKE_BIN_DIR}/ccmake;${CMAKE_BIN_DIR}/cmake;${CMAKE_BIN_DIR}/cpack;${CMAKE_BIN_DIR}/ctest")
@@ -245,5 +242,23 @@ configure_file("${CMake_SOURCE_DIR}/CMakeCPackOptions.cmake.in"
"${CMake_BINARY_DIR}/CMakeCPackOptions.cmake" @ONLY)
set(CPACK_PROJECT_CONFIG_FILE "${CMake_BINARY_DIR}/CMakeCPackOptions.cmake")
+set(CPACK_SOURCE_IGNORE_FILES
+ # Files specific to version control.
+ "/\\\\.git/"
+ "/\\\\.gitattributes$"
+ "/\\\\.github/"
+ "/\\\\.gitignore$"
+ "/\\\\.hooks-config$"
+
+ # Cygwin package build.
+ "/\\\\.build/"
+
+ # Temporary files.
+ "\\\\.swp$"
+ "\\\\.#"
+ "/#"
+ "~$"
+ )
+
# include CPack model once all variables are set
include(CPack)
diff --git a/CMakeCPackOptions.cmake.in b/CMakeCPackOptions.cmake.in
index ad0c24586..2a4bcc589 100644
--- a/CMakeCPackOptions.cmake.in
+++ b/CMakeCPackOptions.cmake.in
@@ -109,16 +109,6 @@ if(CPACK_GENERATOR MATCHES "IFW")
set(CPACK_IFW_COMPONENT_CMCLDEPS_VERSION
"@CMake_IFW_ROOT_COMPONENT_VERSION@")
- set(CPACK_COMPONENT_CMAKEXBUILD_DISPLAY_NAME "cmakexbuild")
- set(CPACK_COMPONENT_CMAKEXBUILD_DESCRIPTION
- "The \"cmakexbuild\" executable is a wrapper program for \"xcodebuild\"")
- set(CPACK_COMPONENT_CMAKEXBUILD_REQUIRED TRUE)
- set(CPACK_COMPONENT_CMAKEXBUILD_GROUP Tools)
- set(CPACK_IFW_COMPONENT_CMAKEXBUILD_NAME "CMakeXBuild")
- set(CPACK_IFW_COMPONENT_CMAKEXBUILD_PRIORITY 85)
- set(CPACK_IFW_COMPONENT_CMAKEXBUILD_VERSION
- "@CMake_IFW_ROOT_COMPONENT_VERSION@")
-
# Dialogs
set(CPACK_COMPONENT_GROUP_DIALOGS_DISPLAY_NAME "Interactive Dialogs")
set(CPACK_COMPONENT_GROUP_DIALOGS_DESCRIPTION
@@ -208,12 +198,6 @@ if(CPACK_GENERATOR MATCHES "IFW")
endif()
-if(CPACK_GENERATOR MATCHES "CygwinSource")
- # when packaging source make sure the .build directory is not included
- set(CPACK_SOURCE_IGNORE_FILES
- "/CVS/" "/\\.build/" "/\\.svn/" "\\.swp$" "\\.#" "/#" "~$")
-endif()
-
if("${CPACK_GENERATOR}" STREQUAL "PackageMaker")
if(CMAKE_PACKAGE_QTGUI)
set(CPACK_PACKAGE_DEFAULT_LOCATION "/Applications")
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ed924eb4e..da99a6ee8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,14 +1,23 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-cmake_minimum_required(VERSION 2.8.12.2 FATAL_ERROR)
-if(POLICY CMP0025)
- cmake_policy(SET CMP0025 NEW)
-endif()
-if(POLICY CMP0053)
- cmake_policy(SET CMP0053 NEW)
-endif()
+cmake_minimum_required(VERSION 3.1...3.15 FATAL_ERROR)
+set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideC.cmake)
+set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideCXX.cmake)
project(CMake)
+unset(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX)
+unset(CMAKE_USER_MAKE_RULES_OVERRIDE_C)
+
+# FIXME: This block should go away after a transition period.
+if(MSVC AND NOT CMAKE_VERSION VERSION_LESS 3.15)
+ # Filter out MSVC runtime library flags that may have come from
+ # the cache of an existing build tree or from scripts.
+ foreach(l C CXX)
+ foreach(c DEBUG MINSIZEREL RELEASE RELWITHDEBINFO)
+ string(REGEX REPLACE "[-/]M[DT]d?( |$)" "" "CMAKE_${l}_FLAGS_${c}" "${CMAKE_${l}_FLAGS_${c}}")
+ endforeach()
+ endforeach()
+endif()
# Make sure we can find internal find_package modules only used for
# building CMake and not for shipping externally
@@ -20,7 +29,19 @@ if(CMAKE_BOOTSTRAP)
unset(CMAKE_BOOTSTRAP CACHE)
endif()
+if(CMake_TEST_HOST_CMAKE)
+ get_filename_component(CMake_TEST_EXTERNAL_CMAKE "${CMAKE_COMMAND}" DIRECTORY)
+endif()
+
if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ if(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
+ message(FATAL_ERROR
+ "CMake no longer compiles on HP-UX. See\n"
+ " https://gitlab.kitware.com/cmake/cmake/issues/17137\n"
+ "Use CMake 3.9 or lower instead."
+ )
+ endif()
+
set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin)
endif()
@@ -58,11 +79,20 @@ if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD)
if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.14)
set(CMAKE_CXX_STANDARD 98)
else()
- include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx14_cstdio.cmake)
- if(NOT CMake_CXX14_CSTDIO_BROKEN)
- set(CMAKE_CXX_STANDARD 14)
+ if(NOT CMAKE_VERSION VERSION_LESS 3.8)
+ include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx17_check.cmake)
else()
- set(CMAKE_CXX_STANDARD 11)
+ set(CMake_CXX17_BROKEN 1)
+ endif()
+ if(NOT CMake_CXX17_BROKEN)
+ set(CMAKE_CXX_STANDARD 17)
+ else()
+ include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx14_check.cmake)
+ if(NOT CMake_CXX14_BROKEN)
+ set(CMAKE_CXX_STANDARD 14)
+ else()
+ set(CMAKE_CXX_STANDARD 11)
+ endif()
endif()
endif()
endif()
@@ -72,6 +102,10 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE)
# check for available C++ features
include(${CMake_SOURCE_DIR}/Source/Checks/cm_cxx_features.cmake)
+
+ if(NOT CMake_HAVE_CXX_UNIQUE_PTR)
+ message(FATAL_ERROR "The C++ compiler does not support C++11 (e.g. std::unique_ptr).")
+ endif()
endif()
# set the internal encoding of CMake to UTF-8
@@ -98,6 +132,18 @@ option(CMake_BUILD_DEVELOPER_REFERENCE
"Build CMake Developer Reference" OFF)
mark_as_advanced(CMake_BUILD_DEVELOPER_REFERENCE)
+# option to build using interprocedural optimizations (IPO/LTO)
+if (NOT CMAKE_VERSION VERSION_LESS 3.12.2)
+ option(CMake_BUILD_LTO "Compile CMake with link-time optimization if supported" OFF)
+ if(CMake_BUILD_LTO)
+ include(CheckIPOSupported)
+ check_ipo_supported(RESULT HAVE_IPO)
+ if(HAVE_IPO)
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
+ endif()
+ endif()
+endif()
+
#-----------------------------------------------------------------------
# a macro to deal with system libraries, implemented as a macro
# simply to improve readability of the main script
@@ -106,13 +152,9 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
# Options have dependencies.
include(CMakeDependentOption)
- # Optionally use system xmlrpc. We no longer build or use it by default.
- option(CTEST_USE_XMLRPC "Enable xmlrpc submission method in CTest." OFF)
- mark_as_advanced(CTEST_USE_XMLRPC)
-
# Allow the user to enable/disable all system utility library options by
# defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}.
- set(UTILITIES BZIP2 CURL EXPAT FORM JSONCPP LIBARCHIVE LIBLZMA LIBRHASH LIBUV ZLIB)
+ set(UTILITIES BZIP2 CURL EXPAT FORM JSONCPP LIBARCHIVE LIBLZMA LIBRHASH LIBUV ZLIB ZSTD)
foreach(util ${UTILITIES})
if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util}
AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES)
@@ -140,14 +182,14 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
# Optionally use system utility libraries.
option(CMAKE_USE_SYSTEM_LIBARCHIVE "Use system-installed libarchive" "${CMAKE_USE_SYSTEM_LIBRARY_LIBARCHIVE}")
- CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_CURL "Use system-installed curl"
- "${CMAKE_USE_SYSTEM_LIBRARY_CURL}" "NOT CTEST_USE_XMLRPC" ON)
- CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_EXPAT "Use system-installed expat"
- "${CMAKE_USE_SYSTEM_LIBRARY_EXPAT}" "NOT CTEST_USE_XMLRPC" ON)
+ option(CMAKE_USE_SYSTEM_CURL "Use system-installed curl" "${CMAKE_USE_SYSTEM_LIBRARY_CURL}")
+ option(CMAKE_USE_SYSTEM_EXPAT "Use system-installed expat" "${CMAKE_USE_SYSTEM_LIBRARY_EXPAT}")
CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_ZLIB "Use system-installed zlib"
"${CMAKE_USE_SYSTEM_LIBRARY_ZLIB}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE;NOT CMAKE_USE_SYSTEM_CURL" ON)
CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_BZIP2 "Use system-installed bzip2"
"${CMAKE_USE_SYSTEM_LIBRARY_BZIP2}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON)
+ CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_ZSTD "Use system-installed zstd"
+ "${CMAKE_USE_SYSTEM_LIBRARY_ZSTD}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON)
CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_LIBLZMA "Use system-installed liblzma"
"${CMAKE_USE_SYSTEM_LIBRARY_LIBLZMA}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON)
option(CMAKE_USE_SYSTEM_FORM "Use system-installed libform" "${CMAKE_USE_SYSTEM_LIBRARY_FORM}")
@@ -181,7 +223,7 @@ endmacro()
macro(CMAKE_SETUP_TESTING)
if(BUILD_TESTING)
set(CMAKE_TEST_SYSTEM_LIBRARIES 0)
- foreach(util CURL EXPAT XMLRPC ZLIB)
+ foreach(util CURL EXPAT ZLIB)
if(CMAKE_USE_SYSTEM_${util})
set(CMAKE_TEST_SYSTEM_LIBRARIES 1)
endif()
@@ -244,6 +286,17 @@ if(CMake_RUN_CLANG_TIDY)
message(FATAL_ERROR "CMake_RUN_CLANG_TIDY is ON but clang-tidy is not found!")
endif()
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
+
+ # Create a preprocessor definition that depends on .clang-tidy content so
+ # the compile command will change when .clang-tidy changes. This ensures
+ # that a subsequent build re-runs clang-tidy on all sources even if they
+ # do not otherwise need to be recompiled. Nothing actually uses this
+ # definition. We add it to targets on which we run clang-tidy just to
+ # get the build dependency on the .clang-tidy file.
+ file(SHA1 ${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy clang_tidy_sha1)
+ set(CLANG_TIDY_DEFINITIONS "CLANG_TIDY_SHA1=${clang_tidy_sha1}")
+ unset(clang_tidy_sha1)
+
endif()
configure_file(.clang-tidy .clang-tidy COPYONLY)
@@ -255,7 +308,8 @@ if(CMake_RUN_IWYU)
message(FATAL_ERROR "CMake_RUN_IWYU is ON but include-what-you-use is not found!")
endif()
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE
- "${IWYU_COMMAND};-Xiwyu;--mapping_file=${CMake_SOURCE_DIR}/Utilities/IWYU/mapping.imp")
+ "${IWYU_COMMAND};-Xiwyu;--mapping_file=${CMake_SOURCE_DIR}/Utilities/IWYU/mapping.imp;-w")
+ list(APPEND CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${CMake_IWYU_OPTIONS})
endif()
@@ -280,6 +334,8 @@ endmacro()
# Simply to improve readability of the main script.
#-----------------------------------------------------------------------
macro (CMAKE_BUILD_UTILITIES)
+ find_package(Threads)
+
#---------------------------------------------------------------------
# Create the kwsys library for CMake.
set(KWSYS_NAMESPACE cmsys)
@@ -293,6 +349,9 @@ macro (CMAKE_BUILD_UTILITIES)
set(KWSYS_USE_ConsoleBuf 1)
set(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source)
set(KWSYS_INSTALL_DOC_DIR "${CMAKE_DOC_DIR}")
+ if(CMake_NO_CXX_STANDARD)
+ set(KWSYS_CXX_STANDARD "")
+ endif()
add_subdirectory(Source/kwsys)
set(kwsys_folder "Utilities/KWSys")
CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE} "${kwsys_folder}")
@@ -309,11 +368,24 @@ macro (CMAKE_BUILD_UTILITIES)
# Setup third-party libraries.
# Everything in the tree should be able to include files from the
# Utilities directory.
+ if (CMAKE_SYSTEM_NAME STREQUAL "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ # using -isystem option generate error "template with C linkage"
+ include_directories("${CMake_SOURCE_DIR}/Utilities/std")
+ else()
+ include_directories(SYSTEM "${CMake_SOURCE_DIR}/Utilities/std")
+ endif()
+
include_directories(
${CMake_BINARY_DIR}/Utilities
${CMake_SOURCE_DIR}/Utilities
)
+ #---------------------------------------------------------------------
+ # Build CMake std library for CMake and CTest.
+ set(CMAKE_STD_LIBRARY cmstd)
+ add_subdirectory(Utilities/std)
+ CMAKE_SET_TARGET_FOLDER(cmstd "Utilities/std")
+
# check for the use of system libraries versus builtin ones
# (a macro defined in this file)
CMAKE_HANDLE_SYSTEM_LIBRARIES()
@@ -333,11 +405,7 @@ macro (CMAKE_BUILD_UTILITIES)
endif()
if(CMAKE_USE_SYSTEM_LIBRHASH)
- if(NOT CMAKE_VERSION VERSION_LESS 3.0)
- find_package(LibRHash)
- else()
- message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBRHASH requires CMake >= 3.0")
- endif()
+ find_package(LibRHash)
if(NOT LibRHash_FOUND)
message(FATAL_ERROR
"CMAKE_USE_SYSTEM_LIBRHASH is ON but LibRHash is not found!")
@@ -381,7 +449,6 @@ macro (CMAKE_BUILD_UTILITIES)
set(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER})
set(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES})
set(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES})
- add_definitions(-DCURL_STATICLIB)
set(CMAKE_CURL_INCLUDES)
set(CMAKE_CURL_LIBRARIES cmcurl)
if(CMAKE_TESTS_CDASH_SERVER)
@@ -390,10 +457,7 @@ macro (CMAKE_BUILD_UTILITIES)
set(_CMAKE_USE_OPENSSL_DEFAULT OFF)
if(NOT DEFINED CMAKE_USE_OPENSSL AND NOT WIN32 AND NOT APPLE
AND CMAKE_SYSTEM_NAME MATCHES "(Linux|FreeBSD)")
- find_package(OpenSSL QUIET)
- if(OPENSSL_FOUND)
- set(_CMAKE_USE_OPENSSL_DEFAULT ON)
- endif()
+ set(_CMAKE_USE_OPENSSL_DEFAULT ON)
endif()
option(CMAKE_USE_OPENSSL "Use OpenSSL." ${_CMAKE_USE_OPENSSL_DEFAULT})
mark_as_advanced(CMAKE_USE_OPENSSL)
@@ -408,14 +472,6 @@ macro (CMAKE_BUILD_UTILITIES)
endif()
#---------------------------------------------------------------------
- # Build Compress library for CTest.
- set(CMAKE_COMPRESS_INCLUDES
- "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmcompress")
- set(CMAKE_COMPRESS_LIBRARIES "cmcompress")
- add_subdirectory(Utilities/cmcompress)
- CMAKE_SET_TARGET_FOLDER(cmcompress "Utilities/3rdParty")
-
- #---------------------------------------------------------------------
# Build expat library for CMake, CTest, and libarchive.
if(CMAKE_USE_SYSTEM_EXPAT)
find_package(EXPAT)
@@ -447,6 +503,17 @@ macro (CMAKE_BUILD_UTILITIES)
endif()
#---------------------------------------------------------------------
+ # Build or use system zstd for libarchive.
+ if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE)
+ if(NOT CMAKE_USE_SYSTEM_ZSTD)
+ set(ZSTD_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmzstd")
+ set(ZSTD_LIBRARY cmzstd)
+ add_subdirectory(Utilities/cmzstd)
+ CMAKE_SET_TARGET_FOLDER(cmzstd "Utilities/3rdParty")
+ endif()
+ endif()
+
+ #---------------------------------------------------------------------
# Build or use system liblzma for libarchive.
if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE)
if(CMAKE_USE_SYSTEM_LIBLZMA)
@@ -469,7 +536,7 @@ macro (CMAKE_BUILD_UTILITIES)
#---------------------------------------------------------------------
# Build or use system libarchive for CMake and CTest.
if(CMAKE_USE_SYSTEM_LIBARCHIVE)
- find_package(LibArchive 3.0.0)
+ find_package(LibArchive 3.3.3)
if(NOT LibArchive_FOUND)
message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!")
endif()
@@ -484,6 +551,7 @@ macro (CMAKE_BUILD_UTILITIES)
set(ENABLE_NETTLE OFF CACHE INTERNAL "Enable use of Nettle")
set(ENABLE_OPENSSL ${CMAKE_USE_OPENSSL} CACHE INTERNAL "Enable use of OpenSSL")
set(ENABLE_LZMA ON CACHE INTERNAL "Enable the use of the system LZMA library if found")
+ set(ENABLE_LZ4 OFF CACHE INTERNAL "Enable the use of the system LZ4 library if found")
set(ENABLE_LZO OFF CACHE INTERNAL "Enable the use of the system LZO library if found")
set(ENABLE_ZLIB ON CACHE INTERNAL "Enable the use of the system ZLIB library if found")
set(ENABLE_BZip2 ON CACHE INTERNAL "Enable the use of the system BZip2 library if found")
@@ -503,15 +571,15 @@ macro (CMAKE_BUILD_UTILITIES)
#---------------------------------------------------------------------
# Build jsoncpp library.
if(CMAKE_USE_SYSTEM_JSONCPP)
- if(NOT CMAKE_VERSION VERSION_LESS 3.0)
- find_package(JsonCpp)
- else()
- message(FATAL_ERROR "CMAKE_USE_SYSTEM_JSONCPP requires CMake >= 3.0")
- endif()
+ find_package(JsonCpp 1.4.1)
if(NOT JsonCpp_FOUND)
message(FATAL_ERROR
"CMAKE_USE_SYSTEM_JSONCPP is ON but a JsonCpp is not found!")
endif()
+ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+ set_property(TARGET JsonCpp::JsonCpp APPEND PROPERTY
+ INTERFACE_COMPILE_OPTIONS -Wno-deprecated-declarations)
+ endif()
set(CMAKE_JSONCPP_LIBRARIES JsonCpp::JsonCpp)
else()
set(CMAKE_JSONCPP_LIBRARIES cmjsoncpp)
@@ -521,79 +589,41 @@ macro (CMAKE_BUILD_UTILITIES)
#---------------------------------------------------------------------
# Build libuv library.
- if(NOT DEFINED CMAKE_USE_LIBUV)
- set(CMAKE_USE_LIBUV 1)
- if(APPLE)
- include(CheckCSourceCompiles)
- check_c_source_compiles("
-#include <CoreServices/CoreServices.h>
-#include <AvailabilityMacros.h>
-#ifndef MAC_OS_X_VERSION_10_5
-#error \"MAC_OS_X_VERSION_10_5 is not defined\"
-#endif
-int main(void) { return 0; }
-" HAVE_CoreServices_OS_X_10_5)
- if(NOT HAVE_CoreServices_OS_X_10_5)
- set(CMAKE_USE_LIBUV 0)
- endif()
- elseif(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
- # Disable until it can be ported.
- set(CMAKE_USE_LIBUV 0)
- endif()
- endif()
- if(CMAKE_USE_LIBUV)
- if(CMAKE_USE_SYSTEM_LIBUV)
- if(NOT CMAKE_VERSION VERSION_LESS 3.0)
- find_package(LibUV 1.0.0)
- else()
- message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBUV requires CMake >= 3.0")
- endif()
- if(NOT LIBUV_FOUND)
- message(FATAL_ERROR
- "CMAKE_USE_SYSTEM_LIBUV is ON but a libuv is not found!")
- endif()
- set(CMAKE_LIBUV_LIBRARIES LibUV::LibUV)
- else()
- set(CMAKE_LIBUV_LIBRARIES cmlibuv)
- add_subdirectory(Utilities/cmlibuv)
- CMAKE_SET_TARGET_FOLDER(cmlibuv "Utilities/3rdParty")
- endif()
- else()
- set(CMAKE_LIBUV_LIBRARIES)
- endif()
-
- #---------------------------------------------------------------------
- # Build XMLRPC library for CMake and CTest.
- if(CTEST_USE_XMLRPC)
- find_package(XMLRPC QUIET REQUIRED libwww-client)
- if(NOT XMLRPC_FOUND)
+ if(CMAKE_USE_SYSTEM_LIBUV)
+ find_package(LibUV 1.10.0)
+ if(NOT LIBUV_FOUND)
message(FATAL_ERROR
- "CTEST_USE_XMLRPC is ON but xmlrpc is not found!")
+ "CMAKE_USE_SYSTEM_LIBUV is ON but a libuv is not found!")
endif()
- set(CMAKE_XMLRPC_INCLUDES ${XMLRPC_INCLUDE_DIRS})
- set(CMAKE_XMLRPC_LIBRARIES ${XMLRPC_LIBRARIES})
+ set(CMAKE_LIBUV_LIBRARIES LibUV::LibUV)
+ else()
+ set(CMAKE_LIBUV_LIBRARIES cmlibuv)
+ add_subdirectory(Utilities/cmlibuv)
+ CMAKE_SET_TARGET_FOLDER(cmlibuv "Utilities/3rdParty")
endif()
#---------------------------------------------------------------------
# Use curses?
if (UNIX)
- # there is a bug in the Syllable libraries which makes linking ccmake fail, Alex
- if(NOT CMAKE_SYSTEM_NAME MATCHES syllable)
- set(CURSES_NEED_NCURSES TRUE)
- find_package(Curses QUIET)
- if (CURSES_LIBRARY)
- option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" ON)
- else ()
- message("Curses libraries were not found. Curses GUI for CMake will not be built.")
- set(BUILD_CursesDialog 0)
- endif ()
- else()
- set(BUILD_CursesDialog 0)
+ if(NOT DEFINED BUILD_CursesDialog)
+ include(${CMake_SOURCE_DIR}/Source/Checks/Curses.cmake)
+ option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" "${CMakeCheckCurses_COMPILED}")
endif()
else ()
set(BUILD_CursesDialog 0)
endif ()
if(BUILD_CursesDialog)
+ set(CURSES_NEED_NCURSES TRUE)
+ find_package(Curses)
+ if(NOT CURSES_FOUND)
+ message(WARNING
+ "'ccmake' will not be built because Curses was not found.\n"
+ "Turn off BUILD_CursesDialog to suppress this message."
+ )
+ set(BUILD_CursesDialog 0)
+ endif()
+ endif()
+ if(BUILD_CursesDialog)
if(NOT CMAKE_USE_SYSTEM_FORM)
add_subdirectory(Source/CursesDialog/form)
elseif(NOT CURSES_FORM_LIBRARY)
@@ -624,8 +654,7 @@ endif()
# The main section of the CMakeLists file
#
#-----------------------------------------------------------------------
-# Compute CMake_VERSION, etc.
-include(Source/CMakeVersionCompute.cmake)
+include(Source/CMakeVersion.cmake)
# Include the standard Dart testing module
enable_testing()
@@ -672,7 +701,7 @@ endif()
# to a cdash4simpletest database. In these cases, the CDash dashboards
# should be run first.
#
-if("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x")
+if("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x" AND NOT CMake_TEST_NO_NETWORK)
set(CMAKE_TESTS_CDASH_SERVER "http://open.cdash.org")
endif()
@@ -725,7 +754,7 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE)
# the build tree, which is both the build and the install RPATH.
if (UNIX)
if( CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB
- OR CMAKE_USE_SYSTEM_EXPAT OR CTEST_USE_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH)
+ OR CMAKE_USE_SYSTEM_EXPAT OR CURSES_NEED_RPATH OR QT_NEED_RPATH)
set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
@@ -748,31 +777,6 @@ endif()
# setup some Testing support (a macro defined in this file)
CMAKE_SETUP_TESTING()
-# Check whether to build server mode or not:
-if(NOT CMake_TEST_EXTERNAL_CMAKE)
- if(NOT DEFINED CMake_ENABLE_SERVER_MODE)
- list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_auto_type CMake_HAVE_CXX_AUTO_TYPE)
- list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_range_for CMake_HAVE_CXX_RANGE_FOR)
- if(CMAKE_USE_LIBUV
- AND CMake_HAVE_CXX_AUTO_TYPE
- AND CMake_HAVE_CXX_MAKE_UNIQUE
- AND CMake_HAVE_CXX_RANGE_FOR
- )
- set(CMake_ENABLE_SERVER_MODE 1)
- else()
- set(CMake_ENABLE_SERVER_MODE 0)
- endif()
- endif()
- if(CMake_ENABLE_SERVER_MODE AND NOT CMAKE_USE_LIBUV)
- message(FATAL_ERROR "The server mode requires libuv!")
- endif()
-else()
- set(CMake_ENABLE_SERVER_MODE 0)
-endif()
-if(NOT DEFINED CMake_TEST_SERVER_MODE)
- set(CMake_TEST_SERVER_MODE ${CMake_ENABLE_SERVER_MODE})
-endif()
-
if(NOT CMake_TEST_EXTERNAL_CMAKE)
if(NOT CMake_VERSION_IS_RELEASE)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
@@ -808,15 +812,19 @@ add_subdirectory(Tests)
if(NOT CMake_TEST_EXTERNAL_CMAKE)
if(BUILD_TESTING)
CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests")
+ IF(TARGET CMakeServerLibTests)
+ CMAKE_SET_TARGET_FOLDER(CMakeServerLibTests "Tests")
+ ENDIF()
endif()
if(TARGET documentation)
CMAKE_SET_TARGET_FOLDER(documentation "Documentation")
endif()
endif()
-# add a test
-add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
- --system-information -G "${CMAKE_GENERATOR}" )
+if(BUILD_TESTING)
+ add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
+ --system-information -G "${CMAKE_GENERATOR}" )
+endif()
if(NOT CMake_TEST_EXTERNAL_CMAKE)
# Install license file as it requires.
@@ -833,9 +841,15 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE)
PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
- REGEX "Help/dev($|/)" EXCLUDE
+ REGEX "Help/(dev|guide)($|/)" EXCLUDE
)
# Install auxiliary files integrating with other tools.
add_subdirectory(Auxiliary)
+
+ # Optionally sign installed binaries.
+ if(CMake_INSTALL_SIGNTOOL)
+ configure_file(Source/CMakeInstallSignTool.cmake.in Source/CMakeInstallSignTool.cmake @ONLY)
+ install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/Source/CMakeInstallSignTool.cmake)
+ endif()
endif()
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index e2197632a..7983be16b 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -24,21 +24,48 @@ CMake uses `Kitware's GitLab Instance`_ to manage development and code review.
To contribute patches:
#. Fork the upstream `CMake Repository`_ into a personal account.
-#. Run `Utilities/SetupForDevelopment.sh`_ for local configuration.
+#. Run `Utilities/SetupForDevelopment.sh`_ for local git configuration.
+#. See `Building CMake`_ for building CMake locally.
#. See the `CMake Source Code Guide`_ for coding guidelines.
-#. Base all new work on the upstream ``master`` branch.
-#. Create commits making incremental, distinct, logically complete changes.
-#. Push a topic branch to a personal repository fork on GitLab.
-#. Create a GitLab Merge Request targeting the upstream ``master`` branch.
+#. Create a topic branch named suitably for your work.
+ Base all new work on the upstream ``master`` branch.
+ Base work on the upstream ``release`` branch only if it fixes a
+ regression or bug in a feature new to that release.
+ If in doubt, prefer ``master``. Reviewers may simply ask for
+ a rebase if deemed appropriate in particular cases.
+#. Create commits making incremental, distinct, logically complete changes
+ with appropriate `commit messages`_.
+#. Push the topic branch to a personal repository fork on GitLab.
+#. Create a GitLab Merge Request targeting the upstream ``master`` branch
+ (even if the change is intended for merge to the ``release`` branch).
+ Check the box labelled "Allow commits from members who can merge to the
+ target branch". This will allow maintainers to make minor edits on your
+ behalf.
The merge request will enter the `CMake Review Process`_ for consideration.
.. _`Kitware's GitLab Instance`: https://gitlab.kitware.com
.. _`CMake Repository`: https://gitlab.kitware.com/cmake/cmake
.. _`Utilities/SetupForDevelopment.sh`: Utilities/SetupForDevelopment.sh
+.. _`Building CMake`: README.rst#building-cmake
.. _`CMake Source Code Guide`: Help/dev/source.rst
+.. _`commit messages`: Help/dev/review.rst#commit-messages
.. _`CMake Review Process`: Help/dev/review.rst
+CMake Dashboard Client
+======================
+
+The *integration testing* step of the `CMake Review Process`_ uses a set of
+testing machines that follow an integration branch on their own schedule to
+drive testing and submit results to the `CMake CDash Page`_. Anyone is
+welcome to provide testing machines in order to help keep support for their
+platforms working.
+
+See documentation on `CMake Testing Process`_ for more information.
+
+.. _`CMake CDash Page`: https://open.cdash.org/index.php?project=CMake
+.. _`CMake Testing Process`: Help/dev/testing.rst
+
License
=======
diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in
index fa2fbe35c..d3ab9d3ef 100644
--- a/CTestCustom.cmake.in
+++ b/CTestCustom.cmake.in
@@ -2,6 +2,7 @@ list(APPEND CTEST_CUSTOM_ERROR_MATCH
"ERROR:")
list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
+ "warning: cast from 'char\\*' to 'cmCursesWidget\\*' increases required alignment of target type" # Occurs when using Solaris's system libform
"xtree.[0-9]+. : warning C4702: unreachable code"
"warning LNK4221"
"warning LNK4204" # Occurs by race condition with objects in small libs
@@ -44,11 +45,15 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
"Warning: LINN32: Last line.*is less.*"
"Warning: Olimit was exceeded on function.*"
"Warning: To override Olimit for all functions in file.*"
+ "Warning: Function .* can throw only the exceptions thrown by the function .* it overrides\\."
+ "WarningMessagesDialog\\.cxx"
"warning.*directory name.*CMake-Xcode.*/bin/.*does not exist.*"
"stl_deque.h:1051"
+ "Tests/CMakeLib/testCTestResourceSpec.cxx:.*warning: missing initializer for member.*cmCTestResourceSpec::.*" # GCC 4.8 disagrees with later compilers on C++11 initializer list conversion
"(Lexer|Parser).*warning.*conversion.*may (alter its value|change the sign)"
"(Lexer|Parser).*warning.*(statement is unreachable|will never be executed)"
"(Lexer|Parser).*warning.*variable.*was set but never used"
+ "LexerParser.*warning.*empty expression statement has no effect; remove unnecessary"
"PGC-W-0095-Type cast required for this conversion.*ProcessUNIX.c"
"[Qq]t([Cc]ore|[Gg]ui|[Ww]idgets).*warning.*conversion.*may alter its value"
"warning:.*is.*very unsafe.*consider using.*"
@@ -68,11 +73,11 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
"cm(StringCommand|CTestTestHandler)\\.cxx.*warning.*srand.*seed choices are.*poor" # we do not do crypto
"IPA warning: function.*multiply defined in"
- # Ignore clang's summary warning, assuming prior text has matched some
+ # Ignore compiler summary warning, assuming prior text has matched some
# other warning expression:
- "[0-9,]+ warnings? generated."
- # similarly for PGI
- "compilation completed with warnings"
+ "[0-9,]+ warnings? generated." # Clang
+ "compilation completed with warnings" # PGI
+ "[0-9]+ Warning\\(s\\) detected" # SunPro
# scanbuild exceptions
"char_traits.h:.*: warning: Null pointer argument in call to string length function"
@@ -90,6 +95,7 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
"cmFortranLexer.cxx:[0-9]+:[0-9]+: warning: Call to 'realloc' has an allocation size of 0 bytes"
"testProcess.*warning: Dereference of null pointer .loaded from variable .invalidAddress.."
"liblzma/simple/x86.c:[0-9]+:[0-9]+: warning: The result of the '<<' expression is undefined"
+ "liblzma/common/index_encoder.c:[0-9]+:[0-9]+: warning: Value stored to .* during its initialization is never read"
"libuv/src/.*:[0-9]+:[0-9]+: warning: Dereference of null pointer"
"libuv/src/.*:[0-9]+:[0-9]+: warning: The left operand of '==' is a garbage value"
)
@@ -100,12 +106,6 @@ if(NOT "@CMAKE_GENERATOR@" MATCHES "Xcode")
)
endif ()
-if(NOT "@CMAKE_GENERATOR@" MATCHES "KDevelop")
- list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE
- "Kdevelop"
- )
-endif ()
-
list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE
# Exclude kwsys files from coverage results. They are reported
# (with better coverage results) on kwsys dashboards...
diff --git a/CompileFlags.cmake b/CompileFlags.cmake
index 7a9d4cdf3..053259f47 100644
--- a/CompileFlags.cmake
+++ b/CompileFlags.cmake
@@ -8,15 +8,28 @@ if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel")
set(_INTEL_WINDOWS 1)
endif()
+if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Clang"
+ AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+ set(_CLANG_MSVC_WINDOWS 1)
+endif()
+
# Disable deprecation warnings for standard C functions.
# really only needed for newer versions of VS, but should
# not hurt other versions, and this will work into the
# future
-if(MSVC OR _INTEL_WINDOWS)
+if(MSVC OR _INTEL_WINDOWS OR _CLANG_MSVC_WINDOWS)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
else()
endif()
+if(MSVC)
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stack:10000000")
+endif()
+
+if(_CLANG_MSVC_WINDOWS AND "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker -stack:20000000")
+endif()
+
#silence duplicate symbol warnings on AIX
if(CMAKE_SYSTEM_NAME MATCHES "AIX")
if(NOT CMAKE_COMPILER_IS_GNUCXX)
@@ -24,31 +37,12 @@ if(CMAKE_SYSTEM_NAME MATCHES "AIX")
endif()
endif()
-if(CMAKE_SYSTEM_NAME MATCHES "IRIX")
- if(NOT CMAKE_COMPILER_IS_GNUCXX)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-woff84 -no_auto_include")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-woff15")
- endif()
-endif()
-
if(CMAKE_SYSTEM MATCHES "OSF1-V")
if(NOT CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ")
endif()
endif()
-if(CMAKE_SYSTEM_NAME MATCHES "HP-UX" AND CMAKE_CXX_COMPILER_ID MATCHES "HP")
- # HP aCC since version 3.80 supports the flag +hpxstd98 to get ANSI C++98
- # template support. It is known that version 6.25 doesn't need that flag.
- # Versions prior to 3.80 will not be able to build CMake. Current assumption:
- # it is needed for every version from 3.80 to 4 to get it working.
- if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4 AND
- NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.80)
- # use new C++ library and improved template support
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98")
- endif()
-endif()
-
# Workaround for short jump tables on PA-RISC
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^parisc")
if(CMAKE_COMPILER_IS_GNUCC)
@@ -59,6 +53,23 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "^parisc")
endif()
endif()
+# Workaround for TOC Overflow on ppc64
+set(bigTocFlag "")
+if(CMAKE_SYSTEM_NAME STREQUAL "AIX" AND
+ CMAKE_SYSTEM_PROCESSOR MATCHES "powerpc")
+ set(bigTocFlag "-Wl,-bbigtoc")
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
+ CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64")
+ set(bigTocFlag "-Wl,--no-multi-toc")
+endif()
+if(bigTocFlag)
+ include(CheckCXXLinkerFlag)
+ check_cxx_linker_flag(${bigTocFlag} BIG_TOC_FLAG_SUPPORTED)
+ if(BIG_TOC_FLAG_SUPPORTED)
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${bigTocFlag}")
+ endif()
+endif()
+
if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND
NOT DEFINED CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION)
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
@@ -90,3 +101,26 @@ endif ()
if (CMAKE_ANSI_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
endif ()
+
+# Allow per-translation-unit parallel builds when using MSVC
+if(CMAKE_GENERATOR MATCHES "Visual Studio" AND
+ (CMAKE_C_COMPILER_ID MATCHES "MSVC|Intel" OR
+ CMAKE_CXX_COMPILER_ID MATCHES "MSVC|Intel"))
+
+ set(CMake_MSVC_PARALLEL ON CACHE STRING "\
+Enables /MP flag for parallel builds using MSVC. Specify an \
+integer value to control the number of threads used (Only \
+works on some older versions of Visual Studio). Setting to \
+ON lets the toolchain decide how many threads to use. Set to \
+OFF to disable /MP completely." )
+
+ if(CMake_MSVC_PARALLEL)
+ if(CMake_MSVC_PARALLEL GREATER 0)
+ string(APPEND CMAKE_C_FLAGS " /MP${CMake_MSVC_PARALLEL}")
+ string(APPEND CMAKE_CXX_FLAGS " /MP${CMake_MSVC_PARALLEL}")
+ else()
+ string(APPEND CMAKE_C_FLAGS " /MP")
+ string(APPEND CMAKE_CXX_FLAGS " /MP")
+ endif()
+ endif()
+endif()
diff --git a/Copyright.txt b/Copyright.txt
index 33201080d..f2362144a 100644
--- a/Copyright.txt
+++ b/Copyright.txt
@@ -1,5 +1,5 @@
CMake - Cross Platform Makefile Generator
-Copyright 2000-2017 Kitware, Inc. and Contributors
+Copyright 2000-2019 Kitware, Inc. and Contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -34,10 +34,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The following individuals and institutions are among the Contributors:
* Aaron C. Meadows <cmake@shadowguarddev.com>
+* Adriaan de Groot <groot@kde.org>
* Aleksey Avdeev <solo@altlinux.ru>
* Alexander Neundorf <neundorf@kde.org>
* Alexander Smorkalov <alexander.smorkalov@itseez.com>
* Alexey Sokolov <sokolov@google.com>
+* Alex Merry <alex.merry@kde.org>
* Alex Turbov <i.zaufi@gmail.com>
* Andreas Pakulat <apaku@gmx.de>
* Andreas Schneider <asn@cryptomilk.org>
@@ -61,13 +63,17 @@ The following individuals and institutions are among the Contributors:
* Ilya Lavrenov <ilya.lavrenov@itseez.com>
* Insight Software Consortium <insightsoftwareconsortium.org>
* Jan Woetzel
+* Julien Schueller
* Kelly Thompson <kgt@lanl.gov>
+* Laurent Montel <montel@kde.org>
* Konstantin Podsvirov <konstantin@podsvirov.pro>
* Mario Bensi <mbensi@ipsquad.net>
+* Martin Gräßlin <mgraesslin@kde.org>
* Mathieu Malaterre <mathieu.malaterre@gmail.com>
* Matthaeus G. Chajdas
* Matthias Kretz <kretz@kde.org>
* Matthias Maennich <matthias@maennich.net>
+* Michael Hirsch, Ph.D. <www.scivision.co>
* Michael Stürmer
* Miguel A. Figueroa-Villanueva
* Mike Jackson
@@ -75,7 +81,9 @@ The following individuals and institutions are among the Contributors:
* Nicolas Bock <nicolasbock@gmail.com>
* Nicolas Despres <nicolas.despres@gmail.com>
* Nikita Krupen'ko <krnekit@gmail.com>
+* NVIDIA Corporation <www.nvidia.com>
* OpenGamma Ltd. <opengamma.com>
+* Patrick Stotko <stotko@cs.uni-bonn.de>
* Per Øyvind Karlsen <peroyvind@mandriva.org>
* Peter Collingbourne <peter@pcc.me.uk>
* Petr Gotthard <gotthard@honeywell.com>
diff --git a/Help/command/FIND_XXX.txt b/Help/command/FIND_XXX.txt
index 7db221cb8..42bf52b08 100644
--- a/Help/command/FIND_XXX.txt
+++ b/Help/command/FIND_XXX.txt
@@ -16,6 +16,7 @@ The general signature is:
[PATH_SUFFIXES suffix1 [suffix2 ...]]
[DOC "cache documentation string"]
[NO_DEFAULT_PATH]
+ [NO_PACKAGE_ROOT_PATH]
[NO_CMAKE_PATH]
[NO_CMAKE_ENVIRONMENT_PATH]
[NO_SYSTEM_ENVIRONMENT_PATH]
@@ -60,6 +61,13 @@ If ``NO_DEFAULT_PATH`` is specified, then no additional paths are
added to the search.
If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows:
+.. |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX_SUBDIR| replace::
+ |prefix_XXX_SUBDIR| for each ``<prefix>`` in the
+ :variable:`<PackageName>_ROOT` CMake variable and the
+ :envvar:`<PackageName>_ROOT` environment variable if
+ called from within a find module loaded by
+ :command:`find_package(<PackageName>)`
+
.. |CMAKE_PREFIX_PATH_XXX_SUBDIR| replace::
|prefix_XXX_SUBDIR| for each ``<prefix>`` in :variable:`CMAKE_PREFIX_PATH`
@@ -71,50 +79,72 @@ If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows:
|prefix_XXX_SUBDIR| for each ``<prefix>`` in
:variable:`CMAKE_SYSTEM_PREFIX_PATH`
-1. Search paths specified in cmake-specific cache variables.
+1. If called from within a find module or any other script loaded by a call to
+ :command:`find_package(<PackageName>)`, search prefixes unique to the
+ current package being found. Specifically, look in the
+ :variable:`<PackageName>_ROOT` CMake variable and the
+ :envvar:`<PackageName>_ROOT` environment variable.
+ The package root variables are maintained as a stack, so if called from
+ nested find modules or config packages, root paths from the parent's find
+ module or config package will be searched after paths from the current
+ module or package. In other words, the search order would be
+ ``<CurrentPackage>_ROOT``, ``ENV{<CurrentPackage>_ROOT}``,
+ ``<ParentPackage>_ROOT``, ``ENV{<ParentPackage>_ROOT}``, etc.
+ This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
+ the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
+ See policy :policy:`CMP0074`.
+
+ * |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX|
+
+2. Search paths specified in cmake-specific cache variables.
These are intended to be used on the command line with a ``-DVAR=value``.
- The values are interpreted as :ref:`;-lists <CMake Language Lists>`.
- This can be skipped if ``NO_CMAKE_PATH`` is passed.
+ The values are interpreted as :ref:`semicolon-separated lists <CMake Language Lists>`.
+ This can be skipped if ``NO_CMAKE_PATH`` is passed or by setting the
+ :variable:`CMAKE_FIND_USE_CMAKE_PATH` to ``FALSE``.
* |CMAKE_PREFIX_PATH_XXX|
* |CMAKE_XXX_PATH|
* |CMAKE_XXX_MAC_PATH|
-2. Search paths specified in cmake-specific environment variables.
+3. Search paths specified in cmake-specific environment variables.
These are intended to be set in the user's shell configuration,
and therefore use the host's native path separator
(``;`` on Windows and ``:`` on UNIX).
- This can be skipped if ``NO_CMAKE_ENVIRONMENT_PATH`` is passed.
+ 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|
-3. Search the paths specified by the ``HINTS`` option.
+4. Search the paths specified by the ``HINTS`` option.
These should be paths computed by system introspection, such as a
hint provided by the location of another item already found.
Hard-coded guesses should be specified with the ``PATHS`` option.
-4. Search the standard system environment variables.
- This can be skipped if ``NO_SYSTEM_ENVIRONMENT_PATH`` is an argument.
+5. Search the standard system environment variables.
+ This can be skipped if ``NO_SYSTEM_ENVIRONMENT_PATH`` is passed or by
+ setting the :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` to ``FALSE``.
* |SYSTEM_ENVIRONMENT_PATH_XXX|
+ * |SYSTEM_ENVIRONMENT_PATH_WINDOWS_XXX|
-5. Search cmake variables defined in the Platform files
+6. Search cmake variables defined in the Platform files
for the current system. This can be skipped if ``NO_CMAKE_SYSTEM_PATH``
- is passed.
+ is passed or by setting the :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`
+ to ``FALSE``.
* |CMAKE_SYSTEM_PREFIX_PATH_XXX|
* |CMAKE_SYSTEM_XXX_PATH|
* |CMAKE_SYSTEM_XXX_MAC_PATH|
-6. Search the paths specified by the PATHS option
+7. Search the paths specified by the PATHS option
or in the short-hand version of the command.
These are typically hard-coded guesses.
.. |FIND_ARGS_XXX| replace:: <VAR> NAMES name
-On OS X the :variable:`CMAKE_FIND_FRAMEWORK` and
+On macOS the :variable:`CMAKE_FIND_FRAMEWORK` and
:variable:`CMAKE_FIND_APPBUNDLE` variables determine the order of
preference between Apple-style and unix-style package components.
diff --git a/Help/command/LINK_OPTIONS_LINKER.txt b/Help/command/LINK_OPTIONS_LINKER.txt
new file mode 100644
index 000000000..3f66181be
--- /dev/null
+++ b/Help/command/LINK_OPTIONS_LINKER.txt
@@ -0,0 +1,22 @@
+To pass options to the linker tool, each compiler driver has its own syntax.
+The ``LINKER:`` prefix and ``,`` separator can be used to specify, in a portable
+way, options to pass to the linker tool. ``LINKER:`` is replaced by the
+appropriate driver option and ``,`` by the appropriate driver separator.
+The driver prefix and driver separator are given by the values of the
+:variable:`CMAKE_<LANG>_LINKER_WRAPPER_FLAG` and
+:variable:`CMAKE_<LANG>_LINKER_WRAPPER_FLAG_SEP` variables.
+
+For example, ``"LINKER:-z,defs"`` becomes ``-Xlinker -z -Xlinker defs`` for
+``Clang`` and ``-Wl,-z,defs`` for ``GNU GCC``.
+
+The ``LINKER:`` prefix can be specified as part of a ``SHELL:`` prefix
+expression.
+
+The ``LINKER:`` prefix supports, as an alternative syntax, specification of
+arguments using the ``SHELL:`` prefix and space as separator. The previous
+example then becomes ``"LINKER:SHELL:-z defs"``.
+
+.. note::
+
+ Specifying the ``SHELL:`` prefix anywhere other than at the beginning of the
+ ``LINKER:`` prefix is not supported.
diff --git a/Help/command/OPTIONS_SHELL.txt b/Help/command/OPTIONS_SHELL.txt
new file mode 100644
index 000000000..0f8ec323c
--- /dev/null
+++ b/Help/command/OPTIONS_SHELL.txt
@@ -0,0 +1,9 @@
+The final set of compile or link options used for a target is constructed by
+accumulating options from the current target and the usage requirements of
+its dependencies. The set of options is de-duplicated to avoid repetition.
+While beneficial for individual options, the de-duplication step can break
+up option groups. For example, ``-D A -D B`` becomes ``-D A B``. One may
+specify a group of options using shell-like quoting along with a ``SHELL:``
+prefix. The ``SHELL:`` prefix is dropped, and the rest of the option string
+is parsed using the :command:`separate_arguments` ``UNIX_COMMAND`` mode.
+For example, ``"SHELL:-D A" "SHELL:-D B"`` becomes ``-D A -D B``.
diff --git a/Help/command/add_compile_definitions.rst b/Help/command/add_compile_definitions.rst
new file mode 100644
index 000000000..8225da783
--- /dev/null
+++ b/Help/command/add_compile_definitions.rst
@@ -0,0 +1,23 @@
+add_compile_definitions
+-----------------------
+
+Add preprocessor definitions to the compilation of source files.
+
+.. code-block:: cmake
+
+ add_compile_definitions(<definition> ...)
+
+Adds preprocessor definitions to the compiler command line for targets in the
+current directory and below (whether added before or after this command is
+invoked). See documentation of the :prop_dir:`directory <COMPILE_DEFINITIONS>`
+and :prop_tgt:`target <COMPILE_DEFINITIONS>` ``COMPILE_DEFINITIONS`` properties.
+
+Definitions are specified using the syntax ``VAR`` or ``VAR=value``.
+Function-style definitions are not supported. CMake will automatically
+escape the value correctly for the native build system (note that CMake
+language syntax may require escapes to specify some values).
+
+Arguments to ``add_compile_definitions`` may use "generator expressions" with
+the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
diff --git a/Help/command/add_compile_options.rst b/Help/command/add_compile_options.rst
index 3fe2a3330..43805c3a9 100644
--- a/Help/command/add_compile_options.rst
+++ b/Help/command/add_compile_options.rst
@@ -1,23 +1,48 @@
add_compile_options
-------------------
-Adds options to the compilation of source files.
+Add options to the compilation of source files.
-::
+.. code-block:: cmake
add_compile_options(<option> ...)
-Adds options to the compiler command line for targets in the current
-directory and below that are added after this command is invoked.
-See documentation of the :prop_dir:`directory <COMPILE_OPTIONS>` and
-:prop_tgt:`target <COMPILE_OPTIONS>` ``COMPILE_OPTIONS`` properties.
+Adds options to the :prop_dir:`COMPILE_OPTIONS` directory property.
+These options are used when compiling targets from the current
+directory and below.
-This command can be used to add any options, but alternative commands
-exist to add preprocessor definitions (:command:`target_compile_definitions`
-and :command:`add_definitions`) or include directories
-(:command:`target_include_directories` and :command:`include_directories`).
+Arguments
+^^^^^^^^^
Arguments to ``add_compile_options`` may use "generator expressions" with
the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
+
+.. include:: OPTIONS_SHELL.txt
+
+Example
+^^^^^^^
+
+Since different compilers support different options, a typical use of
+this command is in a compiler-specific conditional clause:
+
+.. code-block:: cmake
+
+ if (MSVC)
+ # warning level 4 and all warnings as errors
+ add_compile_options(/W4 /WX)
+ else()
+ # lots of warnings and all warnings as errors
+ add_compile_options(-Wall -Wextra -pedantic -Werror)
+ endif()
+
+See Also
+^^^^^^^^
+
+This command can be used to add any options. However, for
+adding preprocessor definitions and include directories it is recommended
+to use the more specific commands :command:`add_compile_definitions`
+and :command:`include_directories`.
+
+The command :command:`target_compile_options` adds target-specific options.
diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst
index d03840633..aba374261 100644
--- a/Help/command/add_custom_command.rst
+++ b/Help/command/add_custom_command.rst
@@ -8,7 +8,9 @@ There are two main signatures for ``add_custom_command``.
Generating Files
^^^^^^^^^^^^^^^^
-The first signature is for adding a custom command to produce an output::
+The first signature is for adding a custom command to produce an output:
+
+.. code-block:: cmake
add_custom_command(OUTPUT output1 [output2 ...]
COMMAND command1 [ARGS] [args1...]
@@ -21,6 +23,7 @@ The first signature is for adding a custom command to produce an output::
[WORKING_DIRECTORY dir]
[COMMENT comment]
[DEPFILE depfile]
+ [JOB_POOL job_pool]
[VERBATIM] [APPEND] [USES_TERMINAL]
[COMMAND_EXPAND_LISTS])
@@ -65,9 +68,6 @@ The options are:
order-only dependencies to ensure the byproducts will be
available before their dependents build.
- The ``BYPRODUCTS`` option is ignored on non-Ninja generators
- except to mark byproducts ``GENERATED``.
-
``COMMAND``
Specify the command-line(s) to execute at build time.
If more than one ``COMMAND`` is specified they will be executed in order,
@@ -79,25 +79,33 @@ The options are:
will be ignored.
If ``COMMAND`` specifies an executable target name (created by the
- :command:`add_executable` command) it will automatically be replaced
- by the location of the executable created at build time. If set, the
- :prop_tgt:`CROSSCOMPILING_EMULATOR` executable target property will
- also be prepended to the command to allow the executable to run on
- the host.
- (Use the ``TARGET_FILE``
- :manual:`generator expression <cmake-generator-expressions(7)>` to
- reference an executable later in the command line.)
- Additionally a target-level dependency will be added so that the
- executable target will be built before any target using this custom
- command. However this does NOT add a file-level dependency that
- would cause the custom command to re-run whenever the executable is
- recompiled.
+ :command:`add_executable` command), it will automatically be replaced
+ by the location of the executable created at build time if either of
+ the following is true:
+
+ * The target is not being cross-compiled (i.e. the
+ :variable:`CMAKE_CROSSCOMPILING` variable is not set to true).
+ * The target is being cross-compiled and an emulator is provided (i.e.
+ its :prop_tgt:`CROSSCOMPILING_EMULATOR` target property is set).
+ In this case, the contents of :prop_tgt:`CROSSCOMPILING_EMULATOR` will be
+ prepended to the command before the location of the target executable.
+
+ If neither of the above conditions are met, it is assumed that the
+ command name is a program to be found on the ``PATH`` at build time.
Arguments to ``COMMAND`` may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
- References to target names in generator expressions imply target-level
- dependencies, but NOT file-level dependencies. List target names with
- the ``DEPENDS`` option to add file-level dependencies.
+ Use the ``TARGET_FILE`` generator expression to refer to the location of
+ a target later in the command line (i.e. as a command argument rather
+ than as the command to execute).
+
+ Whenever a target is used as a command to execute or is mentioned in a
+ generator expression as a command argument, a target-level dependency
+ will be added automatically so that the mentioned target will be built
+ before any target using this custom command. However this does NOT add
+ a file-level dependency that would cause the custom command to re-run
+ whenever the executable is recompiled. List target names with
+ the ``DEPENDS`` option to add such file-level dependencies.
``COMMENT``
Display the given message before the commands are executed at
@@ -108,6 +116,9 @@ The options are:
an ``OUTPUT`` of another custom command in the same directory
(``CMakeLists.txt`` file) CMake automatically brings the other
custom command into the target in which this command is built.
+ A target-level dependency is added if any dependency is listed as
+ ``BYPRODUCTS`` of a target or any of its build events in the same
+ directory to ensure the byproducts will be available.
If ``DEPENDS`` is not specified the command will run whenever
the ``OUTPUT`` is missing; if the command does not actually
create the ``OUTPUT`` then the rule will always run.
@@ -142,12 +153,21 @@ The options are:
Note that the ``IMPLICIT_DEPENDS`` option is currently supported
only for Makefile generators and will be ignored by other generators.
+``JOB_POOL``
+ Specify a :prop_gbl:`pool <JOB_POOLS>` for the :generator:`Ninja`
+ generator. Incompatible with ``USES_TERMINAL``, which implies
+ the ``console`` pool.
+ Using a pool that is not defined by :prop_gbl:`JOB_POOLS` causes
+ an error by ninja at build time.
+
``MAIN_DEPENDENCY``
Specify the primary input source file to the command. This is
treated just like any value given to the ``DEPENDS`` option
but also suggests to Visual Studio generators where to hang
- the custom command. At most one custom command may specify a
- given source file as its main dependency.
+ the custom command. Each source file may have at most one command
+ specifying it as its main dependency. A compile command (i.e. for a
+ library or an executable) counts as an implicit main dependency which
+ gets silently overwritten by a custom command specification.
``OUTPUT``
Specify the output files the command is expected to produce.
@@ -180,6 +200,9 @@ The options are:
If it is a relative path it will be interpreted relative to the
build tree directory corresponding to the current source directory.
+ Arguments to ``WORKING_DIRECTORY`` may use
+ :manual:`generator expressions <cmake-generator-expressions(7)>`.
+
``DEPFILE``
Specify a ``.d`` depfile for the :generator:`Ninja` generator.
A ``.d`` file holds dependencies usually emitted by the custom
@@ -195,7 +218,7 @@ before or after building the target. The command becomes part of the
target and will only execute when the target itself is built. If the
target is already built, the command will not execute.
-::
+.. code-block:: cmake
add_custom_command(TARGET <target>
PRE_BUILD | PRE_LINK | POST_BUILD
@@ -204,7 +227,8 @@ target is already built, the command will not execute.
[BYPRODUCTS [files...]]
[WORKING_DIRECTORY dir]
[COMMENT comment]
- [VERBATIM] [USES_TERMINAL])
+ [VERBATIM] [USES_TERMINAL]
+ [COMMAND_EXPAND_LISTS])
This defines a new command that will be associated with building the
specified ``<target>``. The ``<target>`` must be defined in the current
@@ -214,10 +238,9 @@ When the command will happen is determined by which
of the following is specified:
``PRE_BUILD``
- Run before any other rules are executed within the target.
- This is supported only on Visual Studio 8 or later.
- For all other generators ``PRE_BUILD`` will be treated as
- ``PRE_LINK``.
+ On :ref:`Visual Studio Generators`, run before any other rules are
+ executed within the target.
+ On other generators, run just before ``PRE_LINK`` commands.
``PRE_LINK``
Run after sources have been compiled but before linking the binary
or running the librarian or archiver tool of a static library.
@@ -225,3 +248,13 @@ of the following is specified:
:command:`add_custom_target` command.
``POST_BUILD``
Run after all other rules within the target have been executed.
+
+.. note::
+ Because generator expressions can be used in custom commands,
+ it is possible to define ``COMMAND`` lines or whole custom commands
+ which evaluate to empty strings for certain configurations.
+ For **Visual Studio 2010 (and newer)** generators these command
+ lines or custom commands will be omitted for the specific
+ configuration and no "empty-string-command" will be added.
+
+ This allows to add individual build events for every configuration.
diff --git a/Help/command/add_custom_target.rst b/Help/command/add_custom_target.rst
index bd61c8b96..2d5f5f081 100644
--- a/Help/command/add_custom_target.rst
+++ b/Help/command/add_custom_target.rst
@@ -3,7 +3,7 @@ add_custom_target
Add a target with no output so it will always be built.
-::
+.. code-block:: cmake
add_custom_target(Name [ALL] [command1 [args1...]]
[COMMAND command2 [args2...] ...]
@@ -11,6 +11,7 @@ Add a target with no output so it will always be built.
[BYPRODUCTS [files...]]
[WORKING_DIRECTORY dir]
[COMMENT comment]
+ [JOB_POOL job_pool]
[VERBATIM] [USES_TERMINAL]
[COMMAND_EXPAND_LISTS]
[SOURCES src1 [src2...]])
@@ -48,9 +49,6 @@ The options are:
order-only dependencies to ensure the byproducts will be
available before their dependents build.
- The ``BYPRODUCTS`` option is ignored on non-Ninja generators
- except to mark byproducts ``GENERATED``.
-
``COMMAND``
Specify the command-line(s) to execute at build time.
If more than one ``COMMAND`` is specified they will be executed in order,
@@ -60,18 +58,30 @@ The options are:
a ``COMMAND`` to launch it.)
If ``COMMAND`` specifies an executable target name (created by the
- :command:`add_executable` command) it will automatically be replaced
- by the location of the executable created at build time. If set, the
- :prop_tgt:`CROSSCOMPILING_EMULATOR` executable target property will
- also be prepended to the command to allow the executable to run on
- the host.
- Additionally a target-level dependency will be added so that the
- executable target will be built before this custom target.
+ :command:`add_executable` command), it will automatically be replaced
+ by the location of the executable created at build time if either of
+ the following is true:
+
+ * The target is not being cross-compiled (i.e. the
+ :variable:`CMAKE_CROSSCOMPILING` variable is not set to true).
+ * The target is being cross-compiled and an emulator is provided (i.e.
+ its :prop_tgt:`CROSSCOMPILING_EMULATOR` target property is set).
+ In this case, the contents of :prop_tgt:`CROSSCOMPILING_EMULATOR` will be
+ prepended to the command before the location of the target executable.
+
+ If neither of the above conditions are met, it is assumed that the
+ command name is a program to be found on the ``PATH`` at build time.
Arguments to ``COMMAND`` may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
- References to target names in generator expressions imply target-level
- dependencies.
+ Use the ``TARGET_FILE`` generator expression to refer to the location of
+ a target later in the command line (i.e. as a command argument rather
+ than as the command to execute).
+
+ Whenever a target is used as a command to execute or is mentioned in a
+ generator expression as a command argument, a target-level dependency
+ will be added automatically so that the mentioned target will be built
+ before this custom target.
The command and arguments are optional and if not specified an empty
target will be created.
@@ -85,6 +95,9 @@ The options are:
:command:`add_custom_command` command calls in the same directory
(``CMakeLists.txt`` file). They will be brought up to date when
the target is built.
+ A target-level dependency is added if any dependency is a byproduct
+ of a target or any of its build events in the same directory to ensure
+ the byproducts will be available before this target is built.
Use the :command:`add_dependencies` command to add dependencies
on other targets.
@@ -97,6 +110,13 @@ The options are:
``${CC} "-I$<JOIN:$<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES>,;-I>" foo.cc``
to be properly expanded.
+``JOB_POOL``
+ Specify a :prop_gbl:`pool <JOB_POOLS>` for the :generator:`Ninja`
+ generator. Incompatible with ``USES_TERMINAL``, which implies
+ the ``console`` pool.
+ Using a pool that is not defined by :prop_gbl:`JOB_POOLS` causes
+ an error by ninja at build time.
+
``SOURCES``
Specify additional source files to be included in the custom target.
Specified source files will be added to IDE project files for
@@ -121,3 +141,6 @@ The options are:
Execute the command with the given current working directory.
If it is a relative path it will be interpreted relative to the
build tree directory corresponding to the current source directory.
+
+ Arguments to ``WORKING_DIRECTORY`` may use
+ :manual:`generator expressions <cmake-generator-expressions(7)>`.
diff --git a/Help/command/add_definitions.rst b/Help/command/add_definitions.rst
index a04faf591..d06b01c9a 100644
--- a/Help/command/add_definitions.rst
+++ b/Help/command/add_definitions.rst
@@ -1,18 +1,26 @@
add_definitions
---------------
-Adds -D define flags to the compilation of source files.
+Add -D define flags to the compilation of source files.
-::
+.. code-block:: cmake
add_definitions(-DFOO -DBAR ...)
Adds definitions to the compiler command line for targets in the current
directory and below (whether added before or after this command is invoked).
This command can be used to add any flags, but it is intended to add
-preprocessor definitions (see the :command:`add_compile_options` command
-to add other flags).
-Flags beginning in -D or /D that look like preprocessor definitions are
+preprocessor definitions.
+
+.. note::
+
+ This command has been superseded by alternatives:
+
+ * Use :command:`add_compile_definitions` to add preprocessor definitions.
+ * Use :command:`include_directories` to add include directories.
+ * Use :command:`add_compile_options` to add other options.
+
+Flags beginning in ``-D`` or ``/D`` that look like preprocessor definitions are
automatically added to the :prop_dir:`COMPILE_DEFINITIONS` directory
property for the current directory. Definitions with non-trivial values
may be left in the set of flags instead of being converted for reasons of
diff --git a/Help/command/add_dependencies.rst b/Help/command/add_dependencies.rst
index 7a6614328..de219a508 100644
--- a/Help/command/add_dependencies.rst
+++ b/Help/command/add_dependencies.rst
@@ -3,11 +3,11 @@ add_dependencies
Add a dependency between top-level targets.
-::
+.. code-block:: cmake
add_dependencies(<target> [<target-dependency>]...)
-Make a top-level ``<target>`` depend on other top-level targets to
+Makes a top-level ``<target>`` depend on other top-level targets to
ensure that they build before ``<target>`` does. A top-level target
is one created by one of the :command:`add_executable`,
:command:`add_library`, or :command:`add_custom_target` commands
diff --git a/Help/command/add_executable.rst b/Help/command/add_executable.rst
index c088796e4..0a7d7e151 100644
--- a/Help/command/add_executable.rst
+++ b/Help/command/add_executable.rst
@@ -3,18 +3,19 @@ add_executable
Add an executable to the project using the specified source files.
-::
+.. code-block:: cmake
add_executable(<name> [WIN32] [MACOSX_BUNDLE]
[EXCLUDE_FROM_ALL]
- source1 [source2 ...])
+ [source1] [source2 ...])
Adds an executable target called ``<name>`` to be built from the source
-files listed in the command invocation. The ``<name>`` corresponds to the
-logical target name and must be globally unique within a project. The
-actual file name of the executable built is constructed based on
-conventions of the native platform (such as ``<name>.exe`` or just
-``<name>``).
+files listed in the command invocation. (The source files can be omitted
+here if they are added later using :command:`target_sources`.) The
+``<name>`` corresponds to the logical target name and must be globally
+unique within a project. The actual file name of the executable built is
+constructed based on conventions of the native platform (such as
+``<name>.exe`` or just ``<name>``).
By default the executable file will be created in the build tree
directory corresponding to the source tree directory in which the
@@ -46,7 +47,7 @@ within IDE.
--------------------------------------------------------------------------
-::
+.. code-block:: cmake
add_executable(<name> IMPORTED [GLOBAL])
@@ -66,15 +67,16 @@ properties for more information.
--------------------------------------------------------------------------
-::
+.. code-block:: cmake
add_executable(<name> ALIAS <target>)
Creates an :ref:`Alias Target <Alias Targets>`, such that ``<name>`` can
be used to refer to ``<target>`` in subsequent commands. The ``<name>``
does not appear in the generated buildsystem as a make target. The
-``<target>`` may not be an :ref:`Imported Target <Imported Targets>` or an
-``ALIAS``. ``ALIAS`` targets can be used as targets to read properties
+``<target>`` may not be a non-``GLOBAL``
+:ref:`Imported Target <Imported Targets>` or an ``ALIAS``.
+``ALIAS`` targets can be used as targets to read properties
from, executables for custom commands and custom targets. They can also be
tested for existence with the regular :command:`if(TARGET)` subcommand.
The ``<name>`` may not be used to modify properties of ``<target>``, that
diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst
index de5335eff..7274e4474 100644
--- a/Help/command/add_library.rst
+++ b/Help/command/add_library.rst
@@ -10,17 +10,18 @@ Add a library to the project using the specified source files.
Normal Libraries
^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
add_library(<name> [STATIC | SHARED | MODULE]
[EXCLUDE_FROM_ALL]
- source1 [source2 ...])
+ [source1] [source2 ...])
Adds a library target called ``<name>`` to be built from the source files
-listed in the command invocation. The ``<name>`` corresponds to the
-logical target name and must be globally unique within a project. The
-actual file name of the library built is constructed based on
-conventions of the native platform (such as ``lib<name>.a`` or
+listed in the command invocation. (The source files can be omitted here
+if they are added later using :command:`target_sources`.) The ``<name>``
+corresponds to the logical target name and must be globally unique within
+a project. The actual file name of the library built is constructed based
+on conventions of the native platform (such as ``lib<name>.a`` or
``<name>.lib``).
``STATIC``, ``SHARED``, or ``MODULE`` may be given to specify the type of
@@ -34,7 +35,7 @@ variable :variable:`BUILD_SHARED_LIBS` is ``ON``. For ``SHARED`` and
``MODULE`` libraries the :prop_tgt:`POSITION_INDEPENDENT_CODE` target
property is set to ``ON`` automatically.
A ``SHARED`` or ``STATIC`` library may be marked with the :prop_tgt:`FRAMEWORK`
-target property to create an OS X Framework.
+target property to create an macOS Framework.
If a library does not export any symbols, it must not be declared as a
``SHARED`` library. For example, a Windows resource DLL or a managed C++/CLI
@@ -66,7 +67,7 @@ within IDE.
Imported Libraries
^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
add_library(<name> <SHARED|STATIC|MODULE|OBJECT|UNKNOWN> IMPORTED
[GLOBAL])
@@ -79,16 +80,30 @@ option extends visibility. It may be referenced like any target built
within the project. ``IMPORTED`` libraries are useful for convenient
reference from commands like :command:`target_link_libraries`. Details
about the imported library are specified by setting properties whose names
-begin in ``IMPORTED_`` and ``INTERFACE_``. The most important such
-property is :prop_tgt:`IMPORTED_LOCATION` (and its per-configuration
-variant :prop_tgt:`IMPORTED_LOCATION_<CONFIG>`) which specifies the
-location of the main library file on disk. See documentation of the
-``IMPORTED_*`` and ``INTERFACE_*`` properties for more information.
+begin in ``IMPORTED_`` and ``INTERFACE_``.
+
+The most important properties are:
+
+* :prop_tgt:`IMPORTED_LOCATION` (and its per-configuration
+ variant :prop_tgt:`IMPORTED_LOCATION_<CONFIG>`) which specifies the
+ location of the main library file on disk.
+* :prop_tgt:`IMPORTED_OBJECTS` (and :prop_tgt:`IMPORTED_OBJECTS_<CONFIG>`)
+ for object libraries, specifies the locations of object files on disk.
+* :prop_tgt:`PUBLIC_HEADER` files to be installed during :command:`install` invocation
+
+See documentation of the ``IMPORTED_*`` and ``INTERFACE_*`` properties
+for more information.
+
+An ``UNKNOWN`` library type is typically only used in the implementation of
+:ref:`Find Modules`. It allows the path to an imported library (often found
+using the :command:`find_library` command) to be used without having to know
+what type of library it is. This is especially useful on Windows where a
+static library and a DLL's import library both have the same file extension.
Object Libraries
^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
add_library(<name> OBJECT <src>...)
@@ -109,22 +124,23 @@ along with those compiled from their own sources. Object libraries
may contain only sources that compile, header files, and other files
that would not affect linking of a normal library (e.g. ``.txt``).
They may contain custom commands generating such sources, but not
-``PRE_BUILD``, ``PRE_LINK``, or ``POST_BUILD`` commands. Object libraries
-cannot be linked. Some native build systems may not like targets that
-have only object files, so consider adding at least one real source file
-to any target that references ``$<TARGET_OBJECTS:objlib>``.
+``PRE_BUILD``, ``PRE_LINK``, or ``POST_BUILD`` commands. Some native build
+systems (such as Xcode) may not like targets that have only object files, so
+consider adding at least one real source file to any target that references
+``$<TARGET_OBJECTS:objlib>``.
Alias Libraries
^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
add_library(<name> ALIAS <target>)
Creates an :ref:`Alias Target <Alias Targets>`, such that ``<name>`` can be
used to refer to ``<target>`` in subsequent commands. The ``<name>`` does
not appear in the generated buildsystem as a make target. The ``<target>``
-may not be an :ref:`Imported Target <Imported Targets>` or an ``ALIAS``.
+may not be a non-``GLOBAL`` :ref:`Imported Target <Imported Targets>` or an
+``ALIAS``.
``ALIAS`` targets can be used as linkable targets and as targets to
read properties from. They can also be tested for existence with the
regular :command:`if(TARGET)` subcommand. The ``<name>`` may not be used
@@ -136,7 +152,7 @@ installed or exported.
Interface Libraries
^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
add_library(<name> INTERFACE [IMPORTED [GLOBAL]])
@@ -148,6 +164,7 @@ the interface target using the commands:
* :command:`set_property`,
* :command:`target_link_libraries(INTERFACE)`,
+* :command:`target_link_options(INTERFACE)`,
* :command:`target_include_directories(INTERFACE)`,
* :command:`target_compile_options(INTERFACE)`,
* :command:`target_compile_definitions(INTERFACE)`, and
diff --git a/Help/command/add_link_options.rst b/Help/command/add_link_options.rst
new file mode 100644
index 000000000..a83005b06
--- /dev/null
+++ b/Help/command/add_link_options.rst
@@ -0,0 +1,31 @@
+add_link_options
+----------------
+
+Add options to the link step for executable, shared library or module
+library targets in the current directory and below that are added after
+this command is invoked.
+
+.. code-block:: cmake
+
+ add_link_options(<option> ...)
+
+This command can be used to add any link options, but alternative commands
+exist to add libraries (:command:`target_link_libraries` or
+:command:`link_libraries`). See documentation of the
+:prop_dir:`directory <LINK_OPTIONS>` and
+:prop_tgt:`target <LINK_OPTIONS>` ``LINK_OPTIONS`` properties.
+
+.. note::
+
+ This command cannot be used to add options for static library targets,
+ since they do not use a linker. To add archiver or MSVC librarian flags,
+ see the :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property.
+
+Arguments to ``add_link_options`` may use "generator expressions" with
+the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
+
+.. include:: OPTIONS_SHELL.txt
+
+.. include:: LINK_OPTIONS_LINKER.txt
diff --git a/Help/command/add_subdirectory.rst b/Help/command/add_subdirectory.rst
index e97925302..8dba986ba 100644
--- a/Help/command/add_subdirectory.rst
+++ b/Help/command/add_subdirectory.rst
@@ -3,12 +3,11 @@ add_subdirectory
Add a subdirectory to the build.
-::
+.. code-block:: cmake
- add_subdirectory(source_dir [binary_dir]
- [EXCLUDE_FROM_ALL])
+ add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL])
-Add a subdirectory to the build. The source_dir specifies the
+Adds a subdirectory to the build. The source_dir specifies the
directory in which the source CMakeLists.txt and code files are
located. If it is a relative path it will be evaluated with respect
to the current directory (the typical usage), but it may also be an
@@ -30,7 +29,7 @@ project that is useful but not necessary, such as a set of examples.
Typically the subdirectory should contain its own :command:`project`
command invocation so that a full build system will be generated in the
subdirectory (such as a VS IDE solution file). Note that inter-target
-dependencies supercede this exclusion. If a target built by the
+dependencies supersede this exclusion. If a target built by the
parent project depends on a target in the subdirectory, the dependee
target will be included in the parent project build system to satisfy
the dependency.
diff --git a/Help/command/add_test.rst b/Help/command/add_test.rst
index d8a96e9b9..a77ba37cc 100644
--- a/Help/command/add_test.rst
+++ b/Help/command/add_test.rst
@@ -3,13 +3,14 @@ add_test
Add a test to the project to be run by :manual:`ctest(1)`.
-::
+.. code-block:: cmake
add_test(NAME <name> COMMAND <command> [<arg>...]
[CONFIGURATIONS <config>...]
- [WORKING_DIRECTORY <dir>])
+ [WORKING_DIRECTORY <dir>]
+ [COMMAND_EXPAND_LISTS])
-Add a test called ``<name>``. The test name may not contain spaces,
+Adds a test called ``<name>``. The test name may not contain spaces,
quotes, or other characters special in CMake syntax. The options are:
``COMMAND``
@@ -28,18 +29,26 @@ quotes, or other characters special in CMake syntax. The options are:
directory set to the build directory corresponding to the
current source directory.
+``COMMAND_EXPAND_LISTS``
+ Lists in ``COMMAND`` arguments will be expanded, including those
+ created with
+ :manual:`generator expressions <cmake-generator-expressions(7)>`.
+
The given test command is expected to exit with code ``0`` to pass and
non-zero to fail, or vice-versa if the :prop_test:`WILL_FAIL` test
property is set. Any output written to stdout or stderr will be
captured by :manual:`ctest(1)` but does not affect the pass/fail status
-unless the :prop_test:`PASS_REGULAR_EXPRESSION` or
-:prop_test:`FAIL_REGULAR_EXPRESSION` test property is used.
+unless the :prop_test:`PASS_REGULAR_EXPRESSION`,
+:prop_test:`FAIL_REGULAR_EXPRESSION` or
+:prop_test:`SKIP_REGULAR_EXPRESSION` test property is used.
The ``COMMAND`` and ``WORKING_DIRECTORY`` options may use "generator
expressions" with the syntax ``$<...>``. See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
-Example usage::
+Example usage:
+
+.. code-block:: cmake
add_test(NAME mytest
COMMAND testDriver --config $<CONFIGURATION>
@@ -53,11 +62,12 @@ file produced by target ``myexe``.
CMake will generate tests only if the :command:`enable_testing`
command has been invoked. The :module:`CTest` module invokes the
- command automatically when the ``BUILD_TESTING`` option is ``ON``.
+ command automatically unless the ``BUILD_TESTING`` option is turned
+ ``OFF``.
---------------------------------------------------------------------
-::
+.. code-block:: cmake
add_test(<name> <command> [<arg>...])
diff --git a/Help/command/aux_source_directory.rst b/Help/command/aux_source_directory.rst
index dcd1cdfc3..9619f357f 100644
--- a/Help/command/aux_source_directory.rst
+++ b/Help/command/aux_source_directory.rst
@@ -3,7 +3,7 @@ aux_source_directory
Find all source files in a directory.
-::
+.. code-block:: cmake
aux_source_directory(<dir> <variable>)
@@ -11,14 +11,14 @@ Collects the names of all the source files in the specified directory
and stores the list in the ``<variable>`` provided. This command is
intended to be used by projects that use explicit template
instantiation. Template instantiation files can be stored in a
-"Templates" subdirectory and collected automatically using this
+``Templates`` subdirectory and collected automatically using this
command to avoid manually listing all instantiations.
It is tempting to use this command to avoid writing the list of source
files for a library or executable target. While this seems to work,
there is no way for CMake to generate a build system that knows when a
new source file has been added. Normally the generated build system
-knows when it needs to rerun CMake because the CMakeLists.txt file is
+knows when it needs to rerun CMake because the ``CMakeLists.txt`` file is
modified to add a new source. When the source is just added to the
directory without modifying this file, one would have to manually
rerun CMake to generate a build system incorporating the new file.
diff --git a/Help/command/break.rst b/Help/command/break.rst
index fc2cd3c7b..4875a2bf2 100644
--- a/Help/command/break.rst
+++ b/Help/command/break.rst
@@ -3,10 +3,10 @@ break
Break from an enclosing foreach or while loop.
-::
+.. code-block:: cmake
break()
-Breaks from an enclosing foreach loop or while loop
+Breaks from an enclosing :command:`foreach` or :command:`while` loop.
See also the :command:`continue` command.
diff --git a/Help/command/build_command.rst b/Help/command/build_command.rst
index b83edaf57..6659005be 100644
--- a/Help/command/build_command.rst
+++ b/Help/command/build_command.rst
@@ -14,7 +14,7 @@ This is mainly intended for internal use by the :module:`CTest` module.
Sets the given ``<variable>`` to a command-line string of the form::
- <cmake> --build . [--config <config>] [--target <target>] [-- -i]
+ <cmake> --build . [--config <config>] [--target <target>...] [-- -i]
where ``<cmake>`` is the location of the :manual:`cmake(1)` command-line
tool, and ``<config>`` and ``<target>`` are the values provided to the
diff --git a/Help/command/build_name.rst b/Help/command/build_name.rst
index f717db1dd..2a1fbae62 100644
--- a/Help/command/build_name.rst
+++ b/Help/command/build_name.rst
@@ -1,7 +1,7 @@
build_name
----------
-Disallowed. See CMake Policy :policy:`CMP0036`.
+Disallowed since version 3.0. See CMake Policy :policy:`CMP0036`.
Use ``${CMAKE_SYSTEM}`` and ``${CMAKE_CXX_COMPILER}`` instead.
diff --git a/Help/command/cmake_host_system_information.rst b/Help/command/cmake_host_system_information.rst
index 9402d57e9..2e9563aab 100644
--- a/Help/command/cmake_host_system_information.rst
+++ b/Help/command/cmake_host_system_information.rst
@@ -3,7 +3,7 @@ cmake_host_system_information
Query host system specific information.
-::
+.. code-block:: cmake
cmake_host_system_information(RESULT <variable> QUERY <key> ...)
@@ -13,13 +13,38 @@ queried. The list of queried values is stored in ``<variable>``.
``<key>`` can be one of the following values:
-::
+============================= ================================================
+Key Description
+============================= ================================================
+``NUMBER_OF_LOGICAL_CORES`` Number of logical cores
+``NUMBER_OF_PHYSICAL_CORES`` Number of physical cores
+``HOSTNAME`` Hostname
+``FQDN`` Fully qualified domain name
+``TOTAL_VIRTUAL_MEMORY`` Total virtual memory in MiB [#mebibytes]_
+``AVAILABLE_VIRTUAL_MEMORY`` Available virtual memory in MiB [#mebibytes]_
+``TOTAL_PHYSICAL_MEMORY`` Total physical memory in MiB [#mebibytes]_
+``AVAILABLE_PHYSICAL_MEMORY`` Available physical memory in MiB [#mebibytes]_
+``IS_64BIT`` One if processor is 64Bit
+``HAS_FPU`` One if processor has floating point unit
+``HAS_MMX`` One if processor supports MMX instructions
+``HAS_MMX_PLUS`` One if processor supports Ext. MMX instructions
+``HAS_SSE`` One if processor supports SSE instructions
+``HAS_SSE2`` One if processor supports SSE2 instructions
+``HAS_SSE_FP`` One if processor supports SSE FP instructions
+``HAS_SSE_MMX`` One if processor supports SSE MMX instructions
+``HAS_AMD_3DNOW`` One if processor supports 3DNow instructions
+``HAS_AMD_3DNOW_PLUS`` One if processor supports 3DNow+ instructions
+``HAS_IA64`` One if IA64 processor emulating x86
+``HAS_SERIAL_NUMBER`` One if processor has serial number
+``PROCESSOR_SERIAL_NUMBER`` Processor serial number
+``PROCESSOR_NAME`` Human readable processor name
+``PROCESSOR_DESCRIPTION`` Human readable full processor description
+``OS_NAME`` See :variable:`CMAKE_HOST_SYSTEM_NAME`
+``OS_RELEASE`` The OS sub-type e.g. on Windows ``Professional``
+``OS_VERSION`` The OS build ID
+``OS_PLATFORM`` See :variable:`CMAKE_HOST_SYSTEM_PROCESSOR`
+============================= ================================================
- NUMBER_OF_LOGICAL_CORES = Number of logical cores.
- NUMBER_OF_PHYSICAL_CORES = Number of physical cores.
- HOSTNAME = Hostname.
- FQDN = Fully qualified domain name.
- TOTAL_VIRTUAL_MEMORY = Total virtual memory in megabytes.
- AVAILABLE_VIRTUAL_MEMORY = Available virtual memory in megabytes.
- TOTAL_PHYSICAL_MEMORY = Total physical memory in megabytes.
- AVAILABLE_PHYSICAL_MEMORY = Available physical memory in megabytes.
+.. rubric:: Footnotes
+
+.. [#mebibytes] One MiB (mebibyte) is equal to 1024x1024 bytes.
diff --git a/Help/command/cmake_minimum_required.rst b/Help/command/cmake_minimum_required.rst
index 9535bf34f..e6ebcf0db 100644
--- a/Help/command/cmake_minimum_required.rst
+++ b/Help/command/cmake_minimum_required.rst
@@ -1,14 +1,26 @@
cmake_minimum_required
----------------------
-Set the minimum required version of cmake for a project and
-update `Policy Settings`_ to match the version given::
+Require a minimum version of cmake.
- cmake_minimum_required(VERSION major.minor[.patch[.tweak]]
- [FATAL_ERROR])
+.. code-block:: cmake
-If the current version of CMake is lower than that required it will
-stop processing the project and report an error.
+ cmake_minimum_required(VERSION <min>[...<max>] [FATAL_ERROR])
+
+Sets the minimum required version of cmake for a project.
+Also updates the policy settings as explained below.
+
+``<min>`` and the optional ``<max>`` are each CMake versions of the form
+``major.minor[.patch[.tweak]]``, and the ``...`` is literal.
+
+If the running version of CMake is lower than the ``<min>`` required
+version it will stop processing the project and report an error.
+The optional ``<max>`` version, if specified, must be at least the
+``<min>`` version and affects policy settings as described below.
+If the running version of CMake is older than 3.12, the extra ``...``
+dots will be seen as version component separators, resulting in the
+``...<max>`` part being ignored and preserving the pre-3.12 behavior
+of basing policies on ``<min>``.
The ``FATAL_ERROR`` option is accepted but ignored by CMake 2.6 and
higher. It should be specified so CMake versions 2.4 and lower fail
@@ -30,21 +42,27 @@ Policy Settings
The ``cmake_minimum_required(VERSION)`` command implicitly invokes the
:command:`cmake_policy(VERSION)` command to specify that the current
-project code is written for the given version of CMake.
-All policies introduced in the specified version or earlier will be
-set to use NEW behavior. All policies introduced after the specified
-version will be unset. This effectively requests behavior preferred
+project code is written for the given range of CMake versions.
+All policies known to the running version of CMake and introduced
+in the ``<min>`` (or ``<max>``, if specified) version or earlier will
+be set to use ``NEW`` behavior. All policies introduced in later
+versions will be unset. This effectively requests behavior preferred
as of a given CMake version and tells newer CMake versions to warn
about their new policies.
-When a version higher than 2.4 is specified the command implicitly
-invokes::
+When a ``<min>`` version higher than 2.4 is specified the command
+implicitly invokes
+
+.. code-block:: cmake
+
+ cmake_policy(VERSION <min>[...<max>])
- cmake_policy(VERSION major[.minor[.patch[.tweak]]])
+which sets CMake policies based on the range of versions specified.
+When a ``<min>`` version 2.4 or lower is given the command implicitly
+invokes
-which sets the cmake policy version level to the version specified.
-When version 2.4 or lower is given the command implicitly invokes::
+.. code-block:: cmake
- cmake_policy(VERSION 2.4)
+ cmake_policy(VERSION 2.4[...<max>])
which enables compatibility features for CMake 2.4 and lower.
diff --git a/Help/command/cmake_parse_arguments.rst b/Help/command/cmake_parse_arguments.rst
index ec4ffed3a..fcd36d0a3 100644
--- a/Help/command/cmake_parse_arguments.rst
+++ b/Help/command/cmake_parse_arguments.rst
@@ -1,26 +1,28 @@
cmake_parse_arguments
---------------------
-``cmake_parse_arguments`` is intended to be used in macros or functions for
-parsing the arguments given to that macro or function. It processes the
-arguments and defines a set of variables which hold the values of the
-respective options.
+Parse function or macro arguments.
-::
+.. code-block:: cmake
cmake_parse_arguments(<prefix> <options> <one_value_keywords>
- <multi_value_keywords> args...)
+ <multi_value_keywords> <args>...)
- cmake_parse_arguments(PARSE_ARGV N <prefix> <options> <one_value_keywords>
- <multi_value_keywords>)
+ cmake_parse_arguments(PARSE_ARGV <N> <prefix> <options>
+ <one_value_keywords> <multi_value_keywords>)
-The first signature reads processes arguments passed in the ``args...``.
+This command is for use in macros or functions.
+It processes the arguments given to that macro or function,
+and defines a set of variables which hold the values of the
+respective options.
+
+The first signature reads processes arguments passed in the ``<args>...``.
This may be used in either a :command:`macro` or a :command:`function`.
The ``PARSE_ARGV`` signature is only for use in a :command:`function`
body. In this case the arguments that are parsed come from the
``ARGV#`` variables of the calling function. The parsing starts with
-the Nth argument, where ``N`` is an unsigned integer. This allows for
+the ``<N>``-th argument, where ``<N>`` is an unsigned integer. This allows for
the values to have special characters like ``;`` in them.
The ``<options>`` argument contains all options for the respective macro,
@@ -43,23 +45,31 @@ macro which can be followed by more than one value, like e.g. the
``<multi_value_keywords>``. A warning will be emitted if uniqueness is
violated.
-When done, ``cmake_parse_arguments`` will have defined for each of the
+When done, ``cmake_parse_arguments`` will consider for each of the
keywords listed in ``<options>``, ``<one_value_keywords>`` and
``<multi_value_keywords>`` a variable composed of the given ``<prefix>``
followed by ``"_"`` and the name of the respective keyword. These
-variables will then hold the respective value from the argument list.
-For the ``<options>`` keywords this will be ``TRUE`` or ``FALSE``.
+variables will then hold the respective value from the argument list
+or be undefined if the associated option could not be found.
+For the ``<options>`` keywords, these will always be defined,
+to ``TRUE`` or ``FALSE``, whether the option is in the argument list or not.
All remaining arguments are collected in a variable
-``<prefix>_UNPARSED_ARGUMENTS``, this can be checked afterwards to see
+``<prefix>_UNPARSED_ARGUMENTS`` that will be undefined if all arguments
+were recognized. This can be checked afterwards to see
whether your macro was called with unrecognized parameters.
-As an example here a ``my_install()`` macro, which takes similar arguments
-as the real :command:`install` command:
+``<one_value_keywords>`` and ``<multi_value_keywords>`` that were given no
+values at all are collected in a variable ``<prefix>_KEYWORDS_MISSING_VALUES``
+that will be undefined if all keywords received values. This can be checked
+to see if there were keywords without any values given.
+
+Consider the following example macro, ``my_install()``, which takes similar
+arguments to the real :command:`install` command:
.. code-block:: cmake
- function(MY_INSTALL)
+ macro(my_install)
set(options OPTIONAL FAST)
set(oneValueArgs DESTINATION RENAME)
set(multiValueArgs TARGETS CONFIGURATIONS)
@@ -72,25 +82,28 @@ Assume ``my_install()`` has been called like this:
.. code-block:: cmake
- my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
+ my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub CONFIGURATIONS)
-After the ``cmake_parse_arguments`` call the macro will have set the
-following variables::
+After the ``cmake_parse_arguments`` call the macro will have set or undefined
+the following variables::
MY_INSTALL_OPTIONAL = TRUE
- MY_INSTALL_FAST = FALSE (was not used in call to my_install)
+ MY_INSTALL_FAST = FALSE # was not used in call to my_install
MY_INSTALL_DESTINATION = "bin"
- MY_INSTALL_RENAME = "" (was not used)
+ MY_INSTALL_RENAME <UNDEFINED> # was not used
MY_INSTALL_TARGETS = "foo;bar"
- MY_INSTALL_CONFIGURATIONS = "" (was not used)
- MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (nothing expected after "OPTIONAL")
+ MY_INSTALL_CONFIGURATIONS <UNDEFINED> # was not used
+ MY_INSTALL_UNPARSED_ARGUMENTS = "blub" # nothing expected after "OPTIONAL"
+ MY_INSTALL_KEYWORDS_MISSING_VALUES = "CONFIGURATIONS"
+ # No value for "CONFIGURATIONS" given
You can then continue and process these variables.
-Keywords terminate lists of values, e.g. if directly after a
-one_value_keyword another recognized keyword follows, this is
+Keywords terminate lists of values, e.g. if directly after a
+``one_value_keyword`` another recognized keyword follows, this is
interpreted as the beginning of the new option. E.g.
``my_install(TARGETS foo DESTINATION OPTIONAL)`` would result in
``MY_INSTALL_DESTINATION`` set to ``"OPTIONAL"``, but as ``OPTIONAL``
-is a keyword itself ``MY_INSTALL_DESTINATION`` will be empty and
-``MY_INSTALL_OPTIONAL`` will therefore be set to ``TRUE``.
+is a keyword itself ``MY_INSTALL_DESTINATION`` will be empty (but added
+to ``MY_INSTALL_KEYWORDS_MISSING_VALUES``) and ``MY_INSTALL_OPTIONAL`` will
+therefore be set to ``TRUE``.
diff --git a/Help/command/cmake_policy.rst b/Help/command/cmake_policy.rst
index b51b9512c..4bc7807bb 100644
--- a/Help/command/cmake_policy.rst
+++ b/Help/command/cmake_policy.rst
@@ -22,19 +22,29 @@ Setting Policies by CMake Version
The ``cmake_policy`` command is used to set policies to ``OLD`` or ``NEW``
behavior. While setting policies individually is supported, we
-encourage projects to set policies based on CMake versions::
-
- cmake_policy(VERSION major.minor[.patch[.tweak]])
-
-Specify that the current CMake code is written for the given
-version of CMake. All policies introduced in the specified version or
-earlier will be set to use ``NEW`` behavior. All policies introduced
-after the specified version will be unset (unless the
+encourage projects to set policies based on CMake versions:
+
+.. code-block:: cmake
+
+ cmake_policy(VERSION <min>[...<max>])
+
+``<min>`` and the optional ``<max>`` are each CMake versions of the form
+``major.minor[.patch[.tweak]]``, and the ``...`` is literal. The ``<min>``
+version must be at least ``2.4`` and at most the running version of CMake.
+The ``<max>`` version, if specified, must be at least the ``<min>`` version
+but may exceed the running version of CMake. If the running version of
+CMake is older than 3.12, the extra ``...`` dots will be seen as version
+component separators, resulting in the ``...<max>`` part being ignored and
+preserving the pre-3.12 behavior of basing policies on ``<min>``.
+
+This specifies that the current CMake code is written for the given
+range of CMake versions. All policies known to the running version of CMake
+and introduced in the ``<min>`` (or ``<max>``, if specified) version
+or earlier will be set to use ``NEW`` behavior. All policies
+introduced in later versions will be unset (unless the
:variable:`CMAKE_POLICY_DEFAULT_CMP<NNNN>` variable sets a default).
This effectively requests behavior preferred as of a given CMake
version and tells newer CMake versions to warn about their new policies.
-The policy version specified must be at least 2.4 or the command will
-report an error.
Note that the :command:`cmake_minimum_required(VERSION)`
command implicitly calls ``cmake_policy(VERSION)`` too.
@@ -42,7 +52,7 @@ command implicitly calls ``cmake_policy(VERSION)`` too.
Setting Policies Explicitly
^^^^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
cmake_policy(SET CMP<NNNN> NEW)
cmake_policy(SET CMP<NNNN> OLD)
@@ -58,7 +68,7 @@ policy state to ``NEW``.
Checking Policy Settings
^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
cmake_policy(GET CMP<NNNN> <variable>)
@@ -70,14 +80,16 @@ CMake Policy Stack
^^^^^^^^^^^^^^^^^^
CMake keeps policy settings on a stack, so changes made by the
-cmake_policy command affect only the top of the stack. A new entry on
+``cmake_policy`` command affect only the top of the stack. A new entry on
the policy stack is managed automatically for each subdirectory to
protect its parents and siblings. CMake also manages a new entry for
scripts loaded by :command:`include` and :command:`find_package` commands
except when invoked with the ``NO_POLICY_SCOPE`` option
(see also policy :policy:`CMP0011`).
The ``cmake_policy`` command provides an interface to manage custom
-entries on the policy stack::
+entries on the policy stack:
+
+.. code-block:: cmake
cmake_policy(PUSH)
cmake_policy(POP)
diff --git a/Help/command/configure_file.rst b/Help/command/configure_file.rst
index 4304f095b..29e85bd16 100644
--- a/Help/command/configure_file.rst
+++ b/Help/command/configure_file.rst
@@ -3,7 +3,7 @@ configure_file
Copy a file to another location and modify its contents.
-::
+.. code-block:: cmake
configure_file(<input> <output>
[COPYONLY] [ESCAPE_QUOTES] [@ONLY]
@@ -13,15 +13,21 @@ Copies an ``<input>`` file to an ``<output>`` file and substitutes
variable values referenced as ``@VAR@`` or ``${VAR}`` in the input
file content. Each variable reference will be replaced with the
current value of the variable, or the empty string if the variable
-is not defined. Furthermore, input lines of the form::
+is not defined. Furthermore, input lines of the form
+
+.. code-block:: c
#cmakedefine VAR ...
-will be replaced with either::
+will be replaced with either
+
+.. code-block:: c
#define VAR ...
-or::
+or
+
+.. code-block:: c
/* #undef VAR */
@@ -30,9 +36,27 @@ a false constant by the :command:`if` command. The "..." content on the
line after the variable name, if any, is processed as above.
Input file lines of the form ``#cmakedefine01 VAR`` will be replaced with
either ``#define VAR 1`` or ``#define VAR 0`` similarly.
+The result lines (with the exception of the ``#undef`` comments) can be
+indented using spaces and/or tabs between the ``#`` character
+and the ``cmakedefine`` or ``cmakedefine01`` words. This whitespace
+indentation will be preserved in the output lines:
+
+.. code-block:: c
+
+ # cmakedefine VAR
+ # cmakedefine01 VAR
+
+will be replaced, if ``VAR`` is defined, with
+
+.. code-block:: c
+
+ # define VAR
+ # define VAR 1
If the input file is modified the build system will re-run CMake to
re-configure the file and generate the build system again.
+The generated file is modified and its timestamp updated on subsequent
+cmake runs only if its content is changed.
The arguments are:
diff --git a/Help/command/continue.rst b/Help/command/continue.rst
index 1c7d6730c..31c7089a1 100644
--- a/Help/command/continue.rst
+++ b/Help/command/continue.rst
@@ -3,10 +3,12 @@ continue
Continue to the top of enclosing foreach or while loop.
-::
+.. code-block:: cmake
continue()
The ``continue`` command allows a cmake script to abort the rest of a block
in a :command:`foreach` or :command:`while` loop, and start at the top of
-the next iteration. See also the :command:`break` command.
+the next iteration.
+
+See also the :command:`break` command.
diff --git a/Help/command/create_test_sourcelist.rst b/Help/command/create_test_sourcelist.rst
index dde6812e1..77e37c50f 100644
--- a/Help/command/create_test_sourcelist.rst
+++ b/Help/command/create_test_sourcelist.rst
@@ -3,7 +3,7 @@ create_test_sourcelist
Create a test driver and source list for building test programs.
-::
+.. code-block:: cmake
create_test_sourcelist(sourceListName driverName
test1 test2 test3
diff --git a/Help/command/ctest_build.rst b/Help/command/ctest_build.rst
index 55bb4a317..66e1844e9 100644
--- a/Help/command/ctest_build.rst
+++ b/Help/command/ctest_build.rst
@@ -50,9 +50,7 @@ The options are:
for an example.
``PROJECT_NAME <project-name>``
- Set the name of the project to build. This should correspond
- to the top-level call to the :command:`project` command.
- If not specified the ``CTEST_PROJECT_NAME`` variable will be checked.
+ Ignored. This was once used but is no longer needed.
``TARGET <target-name>``
Specify the name of a target to build. If not specified the
diff --git a/Help/command/ctest_coverage.rst b/Help/command/ctest_coverage.rst
index 8d27b9c1b..d50f63498 100644
--- a/Help/command/ctest_coverage.rst
+++ b/Help/command/ctest_coverage.rst
@@ -8,7 +8,7 @@ Perform the :ref:`CTest Coverage Step` as a :ref:`Dashboard Client`.
ctest_coverage([BUILD <build-dir>] [APPEND]
[LABELS <label>...]
[RETURN_VALUE <result-var>]
- [CAPTURE_CMAKE_ERROR <result-var]
+ [CAPTURE_CMAKE_ERROR <result-var>]
[QUIET]
)
diff --git a/Help/command/ctest_start.rst b/Help/command/ctest_start.rst
index 63db32f4e..f0704aca5 100644
--- a/Help/command/ctest_start.rst
+++ b/Help/command/ctest_start.rst
@@ -5,21 +5,79 @@ Starts the testing for a given model
::
- ctest_start(Model [TRACK <track>] [APPEND] [source [binary]] [QUIET])
+ ctest_start(<model> [<source> [<binary>]] [GROUP <group>] [QUIET])
+
+ ctest_start([<model> [<source> [<binary>]]] [GROUP <group>] APPEND [QUIET])
Starts the testing for a given model. The command should be called
-after the binary directory is initialized. If the 'source' and
-'binary' directory are not specified, it reads the
-:variable:`CTEST_SOURCE_DIRECTORY` and :variable:`CTEST_BINARY_DIRECTORY`.
-If the track is
-specified, the submissions will go to the specified track. If APPEND
-is used, the existing TAG is used rather than creating a new one based
-on the current time stamp. If ``QUIET`` is used, CTest will suppress any
-non-error messages that it otherwise would have printed to the console.
-
-If the :variable:`CTEST_CHECKOUT_COMMAND` variable
-(or the :variable:`CTEST_CVS_CHECKOUT` variable)
-is set, its content is treated as command-line. The command is
-invoked with the current working directory set to the parent of the source
-directory, even if the source directory already exists. This can be used
-to create the source tree from a version control repository.
+after the binary directory is initialized.
+
+The parameters are as follows:
+
+``<model>``
+ Set the dashboard model. Must be one of ``Experimental``, ``Continuous``, or
+ ``Nightly``. This parameter is required unless ``APPEND`` is specified.
+
+``<source>``
+ Set the source directory. If not specified, the value of
+ :variable:`CTEST_SOURCE_DIRECTORY` is used instead.
+
+``<binary>``
+ Set the binary directory. If not specified, the value of
+ :variable:`CTEST_BINARY_DIRECTORY` is used instead.
+
+``GROUP <group>``
+ If ``GROUP`` is used, the submissions will go to the specified group on the
+ CDash server. If no ``GROUP`` is specified, the name of the model is used by
+ default. This replaces the deprecated option ``TRACK``. Despite the name
+ change its behavior is unchanged.
+
+``APPEND``
+ If ``APPEND`` is used, the existing ``TAG`` is used rather than creating a new
+ one based on the current time stamp. If you use ``APPEND``, you can omit the
+ ``<model>`` and ``GROUP <group>`` parameters, because they will be read from
+ the generated ``TAG`` file. For example:
+
+ .. code-block:: cmake
+
+ ctest_start(Experimental GROUP GroupExperimental)
+
+ Later, in another ``ctest -S`` script:
+
+ .. code-block:: cmake
+
+ ctest_start(APPEND)
+
+ When the second script runs ``ctest_start(APPEND)``, it will read the
+ ``Experimental`` model and ``GroupExperimental`` group from the ``TAG`` file
+ generated by the first ``ctest_start()`` command. Please note that if you
+ call ``ctest_start(APPEND)`` and specify a different model or group than
+ in the first ``ctest_start()`` command, a warning will be issued, and the
+ new model and group will be used.
+
+``QUIET``
+ If ``QUIET`` is used, CTest will suppress any non-error messages that it
+ otherwise would have printed to the console.
+
+The parameters for ``ctest_start()`` can be issued in any order, with the
+exception that ``<model>``, ``<source>``, and ``<binary>`` have to appear
+in that order with respect to each other. The following are all valid and
+equivalent:
+
+.. code-block:: cmake
+
+ ctest_start(Experimental path/to/source path/to/binary GROUP SomeGroup QUIET APPEND)
+
+ ctest_start(GROUP SomeGroup Experimental QUIET path/to/source APPEND path/to/binary)
+
+ ctest_start(APPEND QUIET Experimental path/to/source GROUP SomeGroup path/to/binary)
+
+However, for the sake of readability, it is recommended that you order your
+parameters in the order listed at the top of this page.
+
+If the :variable:`CTEST_CHECKOUT_COMMAND` variable (or the
+:variable:`CTEST_CVS_CHECKOUT` variable) is set, its content is treated as
+command-line. The command is invoked with the current working directory set
+to the parent of the source directory, even if the source directory already
+exists. This can be used to create the source tree from a version control
+repository.
diff --git a/Help/command/ctest_submit.rst b/Help/command/ctest_submit.rst
index 6b49da392..983fc20ce 100644
--- a/Help/command/ctest_submit.rst
+++ b/Help/command/ctest_submit.rst
@@ -6,10 +6,13 @@ Perform the :ref:`CTest Submit Step` as a :ref:`Dashboard Client`.
::
ctest_submit([PARTS <part>...] [FILES <file>...]
+ [SUBMIT_URL <url>]
+ [BUILD_ID <result-var>]
[HTTPHEADER <header>]
[RETRY_COUNT <count>]
[RETRY_DELAY <delay>]
[RETURN_VALUE <result-var>]
+ [CAPTURE_CMAKE_ERROR <result-var>]
[QUIET]
)
@@ -32,14 +35,31 @@ The options are:
ExtraFiles = Files listed by CTEST_EXTRA_SUBMIT_FILES
Upload = Files prepared for upload by ctest_upload(), in Upload.xml
Submit = nothing
+ Done = Build is complete, in Done.xml
``FILES <file>...``
Specify an explicit list of specific files to be submitted.
Each individual file must exist at the time of the call.
+``SUBMIT_URL <url>``
+ The ``http`` or ``https`` URL of the dashboard server to send the submission
+ to. If not given, the :variable:`CTEST_SUBMIT_URL` variable is used.
+
+``BUILD_ID <result-var>``
+ Store in the ``<result-var>`` variable the ID assigned to this build by
+ CDash.
+
``HTTPHEADER <HTTP-header>``
Specify HTTP header to be included in the request to CDash during submission.
- This suboption can be repeated several times.
+ For example, CDash can be configured to only accept submissions from
+ authenticated clients. In this case, you should provide a bearer token in your
+ header:
+
+ .. code-block:: cmake
+
+ ctest_submit(HTTPHEADER "Authorization: Bearer <auth-token>")
+
+ This suboption can be repeated several times for multiple headers.
``RETRY_COUNT <count>``
Specify how many times to retry a timed-out submission.
@@ -52,6 +72,10 @@ The options are:
Store in the ``<result-var>`` variable ``0`` for success and
non-zero on failure.
+``CAPTURE_CMAKE_ERROR <result-var>``
+ Store in the ``<result-var>`` variable -1 if there are any errors running
+ the command and prevent ctest from returning non-zero if an error occurs.
+
``QUIET``
Suppress all non-error messages that would have otherwise been
printed to the console.
@@ -62,16 +86,19 @@ Submit to CDash Upload API
::
ctest_submit(CDASH_UPLOAD <file> [CDASH_UPLOAD_TYPE <type>]
+ [SUBMIT_URL <url>]
[HTTPHEADER <header>]
[RETRY_COUNT <count>]
[RETRY_DELAY <delay>]
+ [RETURN_VALUE <result-var>]
[QUIET])
This second signature is used to upload files to CDash via the CDash
-file upload API. The api first sends a request to upload to CDash along
+file upload API. The API first sends a request to upload to CDash along
with a content hash of the file. If CDash does not already have the file,
then it is uploaded. Along with the file, a CDash type string is specified
to tell CDash which handler to use to process the data.
-This signature accepts the ``HTTPHEADER``, ``RETRY_COUNT``, ``RETRY_DELAY``, and
-``QUIET`` options as described above.
+This signature accepts the ``SUBMIT_URL``, ``BUILD_ID``, ``HTTPHEADER``,
+``RETRY_COUNT``, ``RETRY_DELAY``, ``RETURN_VALUE`` and ``QUIET`` options
+as described above.
diff --git a/Help/command/ctest_test.rst b/Help/command/ctest_test.rst
index 4a69491d5..7a3393b4d 100644
--- a/Help/command/ctest_test.rst
+++ b/Help/command/ctest_test.rst
@@ -17,6 +17,7 @@ Perform the :ref:`CTest Test Step` as a :ref:`Dashboard Client`.
[EXCLUDE_FIXTURE_SETUP <regex>]
[EXCLUDE_FIXTURE_CLEANUP <regex>]
[PARALLEL_LEVEL <level>]
+ [RESOURCE_SPEC_FILE <file>]
[TEST_LOAD <threshold>]
[SCHEDULE_RANDOM <ON|OFF>]
[STOP_TIME <time-of-day>]
@@ -82,6 +83,11 @@ The options are:
Specify a positive number representing the number of tests to
be run in parallel.
+``RESOURCE_SPEC_FILE <file>``
+ Specify a
+ :ref:`resource specification file <ctest-resource-specification-file>`. See
+ :ref:`ctest-resource-allocation` for more information.
+
``TEST_LOAD <threshold>``
While running tests in parallel, try not to start tests when they
may cause the CPU load to pass above a given threshold. If not
diff --git a/Help/command/ctest_update.rst b/Help/command/ctest_update.rst
index b205bca93..96a11c913 100644
--- a/Help/command/ctest_update.rst
+++ b/Help/command/ctest_update.rst
@@ -5,7 +5,10 @@ Perform the :ref:`CTest Update Step` as a :ref:`Dashboard Client`.
::
- ctest_update([SOURCE <source-dir>] [RETURN_VALUE <result-var>] [QUIET])
+ ctest_update([SOURCE <source-dir>]
+ [RETURN_VALUE <result-var>]
+ [CAPTURE_CMAKE_ERROR <result-var>]
+ [QUIET])
Update the source tree from version control and record results in
``Update.xml`` for submission with the :command:`ctest_submit` command.
@@ -20,6 +23,10 @@ The options are:
Store in the ``<result-var>`` variable the number of files
updated or ``-1`` on error.
+``CAPTURE_CMAKE_ERROR <result-var>``
+ Store in the ``<result-var>`` variable -1 if there are any errors running
+ the command and prevent ctest from returning non-zero if an error occurs.
+
``QUIET``
Tell CTest to suppress most non-error messages that it would
have otherwise printed to the console. CTest will still report
@@ -28,4 +35,5 @@ The options are:
The update always follows the version control branch currently checked
out in the source directory. See the :ref:`CTest Update Step`
-documentation for more information.
+documentation for information about variables that change the behavior
+of ``ctest_update()``.
diff --git a/Help/command/define_property.rst b/Help/command/define_property.rst
index 873c6cabb..8f7439bbe 100644
--- a/Help/command/define_property.rst
+++ b/Help/command/define_property.rst
@@ -3,7 +3,7 @@ define_property
Define and document custom properties.
-::
+.. code-block:: cmake
define_property(<GLOBAL | DIRECTORY | TARGET | SOURCE |
TEST | VARIABLE | CACHED_VARIABLE>
@@ -11,7 +11,7 @@ Define and document custom properties.
BRIEF_DOCS <brief-doc> [docs...]
FULL_DOCS <full-doc> [docs...])
-Define one property in a scope for use with the :command:`set_property` and
+Defines one property in a scope for use with the :command:`set_property` and
:command:`get_property` commands. This is primarily useful to associate
documentation with property names that may be retrieved with the
:command:`get_property` command. The first argument determines the kind of
@@ -34,10 +34,24 @@ actual scope needs to be given; only the kind of scope is important.
The required ``PROPERTY`` option is immediately followed by the name of
the property being defined.
-If the ``INHERITED`` option then the :command:`get_property` command will
-chain up to the next higher scope when the requested property is not set
-in the scope given to the command. ``DIRECTORY`` scope chains to
-``GLOBAL``. ``TARGET``, ``SOURCE``, and ``TEST`` chain to ``DIRECTORY``.
+If the ``INHERITED`` option is given, then the :command:`get_property` command
+will chain up to the next higher scope when the requested property is not set
+in the scope given to the command.
+
+* ``DIRECTORY`` scope chains to its parent directory's scope, continuing the
+ walk up parent directories until a directory has the property set or there
+ are no more parents. If still not found at the top level directory, it
+ chains to the ``GLOBAL`` scope.
+* ``TARGET``, ``SOURCE`` and ``TEST`` properties chain to ``DIRECTORY`` scope,
+ including further chaining up the directories, etc. as needed.
+
+Note that this scope chaining behavior only applies to calls to
+:command:`get_property`, :command:`get_directory_property`,
+:command:`get_target_property`, :command:`get_source_file_property` and
+:command:`get_test_property`. There is no inheriting behavior when *setting*
+properties, so using ``APPEND`` or ``APPEND_STRING`` with the
+:command:`set_property` command will not consider inherited values when working
+out the contents to append to.
The ``BRIEF_DOCS`` and ``FULL_DOCS`` options are followed by strings to be
associated with the property as its brief and full documentation.
diff --git a/Help/command/else.rst b/Help/command/else.rst
index 0e5a19810..a98fcd88e 100644
--- a/Help/command/else.rst
+++ b/Help/command/else.rst
@@ -3,8 +3,8 @@ else
Starts the else portion of an if block.
-::
+.. code-block:: cmake
- else(expression)
+ else([<condition>])
See the :command:`if` command.
diff --git a/Help/command/elseif.rst b/Help/command/elseif.rst
index 9a8dfed1d..6bf8646fb 100644
--- a/Help/command/elseif.rst
+++ b/Help/command/elseif.rst
@@ -1,10 +1,11 @@
elseif
------
-Starts the elseif portion of an if block.
+Starts an elseif portion of an if block.
-::
+.. code-block:: cmake
- elseif(expression)
+ elseif(<condition>)
-See the :command:`if` command.
+See the :command:`if` command, especially for the syntax and logic
+of the ``<condition>``.
diff --git a/Help/command/enable_language.rst b/Help/command/enable_language.rst
index 444556151..fdc44f2bc 100644
--- a/Help/command/enable_language.rst
+++ b/Help/command/enable_language.rst
@@ -1,16 +1,18 @@
enable_language
---------------
+Enable a language (CXX/C/OBJC/OBJCXX/Fortran/etc)
-Enable a language (CXX/C/Fortran/etc)
-
-::
+.. code-block:: cmake
enable_language(<lang> [OPTIONAL] )
-This command enables support for the named language in CMake. This is
-the same as the project command but does not create any of the extra
+Enables support for the named language in CMake. This is
+the same as the :command:`project` command but does not create any of the extra
variables that are created by the project command. Example languages
-are CXX, C, Fortran.
+are ``CXX``, ``C``, ``CUDA``, ``OBJC``, ``OBJCXX``, ``Fortran``, and ``ASM``.
+
+If enabling ``ASM``, enable it last so that CMake can check whether
+compilers for other languages like ``C`` work for assembly too.
This command must be called in file scope, not in a function call.
Furthermore, it must be called in the highest directory common to all
@@ -19,4 +21,5 @@ indirectly through link dependencies. It is simplest to enable all
needed languages in the top-level directory of a project.
The ``OPTIONAL`` keyword is a placeholder for future implementation and
-does not currently work.
+does not currently work. Instead you can use the :module:`CheckLanguage`
+module to verify support before enabling.
diff --git a/Help/command/enable_testing.rst b/Help/command/enable_testing.rst
index 1e3e2799c..3ac1a198a 100644
--- a/Help/command/enable_testing.rst
+++ b/Help/command/enable_testing.rst
@@ -3,11 +3,18 @@ enable_testing
Enable testing for current directory and below.
-::
+.. code-block:: cmake
enable_testing()
-Enables testing for this directory and below. See also the
-:command:`add_test` command. Note that ctest expects to find a test file
-in the build directory root. Therefore, this command should be in the
-source directory root.
+Enables testing for this directory and below.
+
+This command should be in the source directory root
+because ctest expects to find a test file in the build
+directory root.
+
+This command is automatically invoked when the :module:`CTest`
+module is included, except if the ``BUILD_TESTING`` option is
+turned off.
+
+See also the :command:`add_test` command.
diff --git a/Help/command/endforeach.rst b/Help/command/endforeach.rst
index 9af972bee..fd923d56a 100644
--- a/Help/command/endforeach.rst
+++ b/Help/command/endforeach.rst
@@ -3,8 +3,12 @@ endforeach
Ends a list of commands in a foreach block.
-::
+.. code-block:: cmake
- endforeach(expression)
+ endforeach([<loop_var>])
See the :command:`foreach` command.
+
+The optional ``<loop_var>`` argument is supported for backward compatibility
+only. If used it must be a verbatim repeat of the ``<loop_var>`` argument of
+the opening ``foreach`` clause.
diff --git a/Help/command/endfunction.rst b/Help/command/endfunction.rst
index 6cc196cde..e27129d8a 100644
--- a/Help/command/endfunction.rst
+++ b/Help/command/endfunction.rst
@@ -3,8 +3,12 @@ endfunction
Ends a list of commands in a function block.
-::
+.. code-block:: cmake
- endfunction(expression)
+ endfunction([<name>])
See the :command:`function` command.
+
+The optional ``<name>`` argument is supported for backward compatibility
+only. If used it must be a verbatim repeat of the ``<name>`` argument
+of the opening ``function`` command.
diff --git a/Help/command/endif.rst b/Help/command/endif.rst
index a0163bf33..fc4f03822 100644
--- a/Help/command/endif.rst
+++ b/Help/command/endif.rst
@@ -3,8 +3,12 @@ endif
Ends a list of commands in an if block.
-::
+.. code-block:: cmake
- endif(expression)
+ endif([<condition>])
See the :command:`if` command.
+
+The optional ``<condition>`` argument is supported for backward compatibility
+only. If used it must be a verbatim repeat of the argument of the opening
+``if`` clause.
diff --git a/Help/command/endmacro.rst b/Help/command/endmacro.rst
index 47327a783..4290ba748 100644
--- a/Help/command/endmacro.rst
+++ b/Help/command/endmacro.rst
@@ -3,8 +3,12 @@ endmacro
Ends a list of commands in a macro block.
-::
+.. code-block:: cmake
- endmacro(expression)
+ endmacro([<name>])
See the :command:`macro` command.
+
+The optional ``<name>`` argument is supported for backward compatibility
+only. If used it must be a verbatim repeat of the ``<name>`` argument
+of the opening ``macro`` command.
diff --git a/Help/command/endwhile.rst b/Help/command/endwhile.rst
index 798c20e71..5ef585bdc 100644
--- a/Help/command/endwhile.rst
+++ b/Help/command/endwhile.rst
@@ -3,8 +3,12 @@ endwhile
Ends a list of commands in a while block.
-::
+.. code-block:: cmake
- endwhile(expression)
+ endwhile([<condition>])
See the :command:`while` command.
+
+The optional ``<condition>`` argument is supported for backward compatibility
+only. If used it must be a verbatim repeat of the argument of the opening
+``while`` clause.
diff --git a/Help/command/exec_program.rst b/Help/command/exec_program.rst
index 6dfdad394..bc9b06916 100644
--- a/Help/command/exec_program.rst
+++ b/Help/command/exec_program.rst
@@ -1,7 +1,9 @@
exec_program
------------
-Deprecated. Use the :command:`execute_process` command instead.
+.. deprecated:: 3.0
+
+ Use the :command:`execute_process` command instead.
Run an executable program during the processing of the CMakeList.txt
file.
diff --git a/Help/command/execute_process.rst b/Help/command/execute_process.rst
index d617243d1..14f879d03 100644
--- a/Help/command/execute_process.rst
+++ b/Help/command/execute_process.rst
@@ -5,11 +5,12 @@ Execute one or more child processes.
.. code-block:: cmake
- execute_process(COMMAND <cmd1> [args1...]]
- [COMMAND <cmd2> [args2...] [...]]
+ execute_process(COMMAND <cmd1> [<arguments>]
+ [COMMAND <cmd2> [<arguments>]]...
[WORKING_DIRECTORY <directory>]
[TIMEOUT <seconds>]
[RESULT_VARIABLE <variable>]
+ [RESULTS_VARIABLE <variable>]
[OUTPUT_VARIABLE <variable>]
[ERROR_VARIABLE <variable>]
[INPUT_FILE <file>]
@@ -17,11 +18,14 @@ Execute one or more child processes.
[ERROR_FILE <file>]
[OUTPUT_QUIET]
[ERROR_QUIET]
+ [COMMAND_ECHO <where>]
[OUTPUT_STRIP_TRAILING_WHITESPACE]
[ERROR_STRIP_TRAILING_WHITESPACE]
[ENCODING <name>])
-Runs the given sequence of one or more commands in parallel with the standard
+Runs the given sequence of one or more commands.
+
+Commands are executed concurrently as a pipeline, with the standard
output of each process piped to the standard input of the next.
A single standard error pipe is used for all processes.
@@ -45,14 +49,21 @@ Options:
the child processes.
``TIMEOUT``
- The child processes will be terminated if they do not finish in the
- specified number of seconds (fractions are allowed).
+ After the specified number of seconds (fractions allowed), all unfinished
+ child processes will be terminated, and the ``RESULT_VARIABLE`` will be
+ set to a string mentioning the "timeout".
``RESULT_VARIABLE``
- The variable will be set to contain the result of running the processes.
+ The variable will be set to contain the result of last child process.
This will be an integer return code from the last child or a string
describing an error condition.
+``RESULTS_VARIABLE <variable>``
+ The variable will be set to contain the result of all processes as a
+ :ref:`semicolon-separated list <CMake Language Lists>`, in order of the
+ given ``COMMAND`` arguments. Each entry will be an integer return code
+ from the corresponding child or a string describing an error condition.
+
``OUTPUT_VARIABLE``, ``ERROR_VARIABLE``
The variable named will be set with the contents of the standard output
and standard error pipes, respectively. If the same variable is named
@@ -67,6 +78,12 @@ Options:
``OUTPUT_QUIET``, ``ERROR_QUIET``
The standard output or standard error results will be quietly ignored.
+``COMMAND_ECHO <where>``
+ The command being run will be echo'ed to ``<where>`` with ``<where>``
+ being set to one of ``STDERR``, ``STDOUT`` or ``NONE``.
+ See the :variable:`CMAKE_EXECUTE_PROCESS_COMMAND_ECHO` variable for a way
+ to control the default behavior when this option is not present.
+
``ENCODING <name>``
On Windows, the encoding that is used to decode output from the process.
Ignored on other platforms.
@@ -83,8 +100,10 @@ Options:
Use the ANSI codepage.
``OEM``
Use the original equipment manufacturer (OEM) code page.
- ``UTF8``
- Use the UTF-8 codepage.
+ ``UTF8`` or ``UTF-8``
+ Use the UTF-8 codepage. Prior to CMake 3.11.0, only ``UTF8`` was accepted
+ for this encoding. In CMake 3.11.0, ``UTF-8`` was added for consistency with
+ the `UTF-8 RFC <https://www.ietf.org/rfc/rfc3629>`_ naming convention.
If more than one ``OUTPUT_*`` or ``ERROR_*`` option is given for the
same pipe the precedence is not specified.
diff --git a/Help/command/export.rst b/Help/command/export.rst
index 53675a756..2ca705616 100644
--- a/Help/command/export.rst
+++ b/Help/command/export.rst
@@ -3,11 +3,11 @@ export
Export targets from the build tree for use by outside projects.
-::
+.. code-block:: cmake
export(EXPORT <export-name> [NAMESPACE <namespace>] [FILE <filename>])
-Create a file ``<filename>`` that may be included by outside projects to
+Creates a file ``<filename>`` that may be included by outside projects to
import targets from the current project's build tree. This is useful
during cross-compiling to build utility executables that can run on
the host platform in one project and then import them into another
@@ -25,7 +25,7 @@ export targets from an installation tree.
The properties set on the generated IMPORTED targets will have the
same values as the final values of the input TARGETS.
-::
+.. code-block:: cmake
export(TARGETS [target1 [target2 [...]]] [NAMESPACE <namespace>]
[APPEND] FILE <filename> [EXPORT_LINK_INTERFACE_LIBRARIES])
@@ -40,23 +40,37 @@ policy CMP0022 is NEW. If a library target is included in the export
but a target to which it links is not included the behavior is
unspecified.
-::
+.. note::
- export(PACKAGE <name>)
+ :ref:`Object Libraries` under :generator:`Xcode` have special handling if
+ multiple architectures are listed in :variable:`CMAKE_OSX_ARCHITECTURES`.
+ In this case they will be exported as :ref:`Interface Libraries` with
+ no object files available to clients. This is sufficient to satisfy
+ transitive usage requirements of other targets that link to the
+ object libraries in their implementation.
+
+.. code-block:: cmake
+
+ export(PACKAGE <PackageName>)
Store the current build directory in the CMake user package registry
-for package ``<name>``. The find_package command may consider the
-directory while searching for package ``<name>``. This helps dependent
+for package ``<PackageName>``. The :command:`find_package` command may consider the
+directory while searching for package ``<PackageName>``. This helps dependent
projects find and use a package from the current project's build tree
without help from the user. Note that the entry in the package
registry that this command creates works only in conjunction with a
-package configuration file (``<name>Config.cmake``) that works with the
+package configuration file (``<PackageName>Config.cmake``) that works with the
build tree. In some cases, for example for packaging and for system
wide installations, it is not desirable to write the user package
-registry. If the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable
-is enabled, the ``export(PACKAGE)`` command will do nothing.
+registry.
+
+By default the ``export(PACKAGE)`` command does nothing (see policy
+:policy:`CMP0090`) because populating the user package registry has effects
+outside the source and build trees. Set the
+:variable:`CMAKE_EXPORT_PACKAGE_REGISTRY` variable to add build directories to
+the CMake user package registry.
-::
+.. code-block:: cmake
export(TARGETS [target1 [target2 [...]]] [ANDROID_MK <filename>])
diff --git a/Help/command/export_library_dependencies.rst b/Help/command/export_library_dependencies.rst
index 2cb437e77..9753abf54 100644
--- a/Help/command/export_library_dependencies.rst
+++ b/Help/command/export_library_dependencies.rst
@@ -1,7 +1,7 @@
export_library_dependencies
---------------------------
-Disallowed. See CMake Policy :policy:`CMP0033`.
+Disallowed since version 3.0. See CMake Policy :policy:`CMP0033`.
Use :command:`install(EXPORT)` or :command:`export` command.
diff --git a/Help/command/file.rst b/Help/command/file.rst
index b2e4eea44..b186177eb 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -3,22 +3,50 @@ file
File manipulation command.
-------------------------------------------------------------------------------
+Synopsis
+^^^^^^^^
-::
+.. parsed-literal::
- file(WRITE <filename> <content>...)
- file(APPEND <filename> <content>...)
+ `Reading`_
+ file(`READ`_ <filename> <out-var> [...])
+ file(`STRINGS`_ <filename> <out-var> [...])
+ file(`\<HASH\> <HASH_>`_ <filename> <out-var>)
+ file(`TIMESTAMP`_ <filename> <out-var> [...])
+ file(`GET_RUNTIME_DEPENDENCIES`_ [...])
-Write ``<content>`` into a file called ``<filename>``. If the file does
-not exist, it will be created. If the file already exists, ``WRITE``
-mode will overwrite it and ``APPEND`` mode will append to the end.
-(If the file is a build input, use the :command:`configure_file` command
-to update the file only when its content changes.)
+ `Writing`_
+ file({`WRITE`_ | `APPEND`_} <filename> <content>...)
+ file({`TOUCH`_ | `TOUCH_NOCREATE`_} [<file>...])
+ file(`GENERATE`_ OUTPUT <output-file> [...])
+
+ `Filesystem`_
+ file({`GLOB`_ | `GLOB_RECURSE`_} <out-var> [...] [<globbing-expr>...])
+ file(`RENAME`_ <oldname> <newname>)
+ file({`REMOVE`_ | `REMOVE_RECURSE`_ } [<files>...])
+ file(`MAKE_DIRECTORY`_ [<dir>...])
+ file({`COPY`_ | `INSTALL`_} <file>... DESTINATION <dir> [...])
+ file(`SIZE`_ <filename> <out-var>)
+ file(`READ_SYMLINK`_ <linkname> <out-var>)
+ file(`CREATE_LINK`_ <original> <linkname> [...])
+
+ `Path Conversion`_
+ file(`RELATIVE_PATH`_ <out-var> <directory> <file>)
+ file({`TO_CMAKE_PATH`_ | `TO_NATIVE_PATH`_} <path> <out-var>)
+
+ `Transfer`_
+ file(`DOWNLOAD`_ <url> <file> [...])
+ file(`UPLOAD`_ <file> <url> [...])
-------------------------------------------------------------------------------
+ `Locking`_
+ file(`LOCK`_ <path> [...])
-::
+Reading
+^^^^^^^
+
+.. _READ:
+
+.. code-block:: cmake
file(READ <filename> <variable>
[OFFSET <offset>] [LIMIT <max-in>] [HEX])
@@ -28,9 +56,9 @@ Read content from a file called ``<filename>`` and store it in a
read at most ``<max-in>`` bytes. The ``HEX`` option causes data to
be converted to a hexadecimal representation (useful for binary data).
-------------------------------------------------------------------------------
+.. _STRINGS:
-::
+.. code-block:: cmake
file(STRINGS <filename> <variable> [<options>...])
@@ -79,9 +107,9 @@ For example, the code
stores a list in the variable ``myfile`` in which each item is a line
from the input file.
-------------------------------------------------------------------------------
+.. _HASH:
-::
+.. code-block:: cmake
file(<HASH> <filename> <variable>)
@@ -90,26 +118,402 @@ store it in a ``<variable>``. The supported ``<HASH>`` algorithm names
are those listed by the :ref:`string(\<HASH\>) <Supported Hash Algorithms>`
command.
-------------------------------------------------------------------------------
+.. _TIMESTAMP:
+
+.. code-block:: cmake
+
+ file(TIMESTAMP <filename> <variable> [<format>] [UTC])
+
+Compute a string representation of the modification time of ``<filename>``
+and store it in ``<variable>``. Should the command be unable to obtain a
+timestamp variable will be set to the empty string ("").
+
+See the :command:`string(TIMESTAMP)` command for documentation of
+the ``<format>`` and ``UTC`` options.
+
+.. _GET_RUNTIME_DEPENDENCIES:
+
+.. code-block:: cmake
+
+ file(GET_RUNTIME_DEPENDENCIES
+ [RESOLVED_DEPENDENCIES_VAR <deps_var>]
+ [UNRESOLVED_DEPENDENCIES_VAR <unresolved_deps_var>]
+ [CONFLICTING_DEPENDENCIES_PREFIX <conflicting_deps_prefix>]
+ [EXECUTABLES [<executable_files>...]]
+ [LIBRARIES [<library_files>...]]
+ [MODULES [<module_files>...]]
+ [DIRECTORIES [<directories>...]]
+ [BUNDLE_EXECUTABLE <bundle_executable_file>]
+ [PRE_INCLUDE_REGEXES [<regexes>...]]
+ [PRE_EXCLUDE_REGEXES [<regexes>...]]
+ [POST_INCLUDE_REGEXES [<regexes>...]]
+ [POST_EXCLUDE_REGEXES [<regexes>...]]
+ )
+
+Recursively get the list of libraries depended on by the given files.
+
+Please note that this sub-command is not intended to be used in project mode.
+Instead, use it in an :command:`install(CODE)` or :command:`install(SCRIPT)`
+block. For example:
+
+.. code-block:: cmake
+
+ install(CODE [[
+ file(GET_RUNTIME_DEPENDENCIES
+ # ...
+ )
+ ]])
+
+The arguments are as follows:
+
+``RESOLVED_DEPENDENCIES_VAR <deps_var>``
+ Name of the variable in which to store the list of resolved dependencies.
+
+``UNRESOLVED_DEPENDENCIES_VAR <unresolved_deps_var>``
+ Name of the variable in which to store the list of unresolved dependencies.
+ If this variable is not specified, and there are any unresolved dependencies,
+ an error is issued.
+
+``CONFLICTING_DEPENDENCIES_PREFIX <conflicting_deps_prefix>``
+ Variable prefix in which to store conflicting dependency information.
+ Dependencies are conflicting if two files with the same name are found in
+ two different directories. The list of filenames that conflict are stored in
+ ``<conflicting_deps_prefix>_FILENAMES``. For each filename, the list of paths
+ that were found for that filename are stored in
+ ``<conflicting_deps_prefix>_<filename>``.
+
+``EXECUTABLES <executable_files>``
+ List of executable files to read for dependencies. These are executables that
+ are typically created with :command:`add_executable`, but they do not have to
+ be created by CMake. On Apple platforms, the paths to these files determine
+ the value of ``@executable_path`` when recursively resolving the libraries.
+ Specifying any kind of library (``STATIC``, ``MODULE``, or ``SHARED``) here
+ will result in undefined behavior.
+
+``LIBRARIES <library_files>``
+ List of library files to read for dependencies. These are libraries that are
+ typically created with :command:`add_library(SHARED)`, but they do not have
+ to be created by CMake. Specifying ``STATIC`` libraries, ``MODULE``
+ libraries, or executables here will result in undefined behavior.
+
+``MODULES <module_files>``
+ List of loadable module files to read for dependencies. These are modules
+ that are typically created with :command:`add_library(MODULE)`, but they do
+ not have to be created by CMake. They are typically used by calling
+ ``dlopen()`` at runtime rather than linked at link time with ``ld -l``.
+ Specifying ``STATIC`` libraries, ``SHARED`` libraries, or executables here
+ will result in undefined behavior.
+
+``DIRECTORIES <directories>``
+ List of additional directories to search for dependencies. On Linux
+ platforms, these directories are searched if the dependency is not found in
+ any of the other usual paths. If it is found in such a directory, a warning
+ is issued, because it means that the file is incomplete (it does not list all
+ of the directories that contain its dependencies). On Windows platforms,
+ these directories are searched if the dependency is not found in any of the
+ other search paths, but no warning is issued, because searching other paths
+ is a normal part of Windows dependency resolution. On Apple platforms, this
+ argument has no effect.
+
+``BUNDLE_EXECUTABLE <bundle_executable_file>``
+ Executable to treat as the "bundle executable" when resolving libraries. On
+ Apple platforms, this argument determines the value of ``@executable_path``
+ when recursively resolving libraries for ``LIBRARIES`` and ``MODULES`` files.
+ It has no effect on ``EXECUTABLES`` files. On other platforms, it has no
+ effect. This is typically (but not always) one of the executables in the
+ ``EXECUTABLES`` argument which designates the "main" executable of the
+ package.
+
+The following arguments specify filters for including or excluding libraries to
+be resolved. See below for a full description of how they work.
+
+``PRE_INCLUDE_REGEXES <regexes>``
+ List of pre-include regexes through which to filter the names of
+ not-yet-resolved dependencies.
+
+``PRE_EXCLUDE_REGEXES <regexes>``
+ List of pre-exclude regexes through which to filter the names of
+ not-yet-resolved dependencies.
+
+``POST_INCLUDE_REGEXES <regexes>``
+ List of post-include regexes through which to filter the names of resolved
+ dependencies.
+
+``POST_EXCLUDE_REGEXES <regexes>``
+ List of post-exclude regexes through which to filter the names of resolved
+ dependencies.
+
+These arguments can be used to blacklist unwanted system libraries when
+resolving the dependencies, or to whitelist libraries from a specific
+directory. The filtering works as follows:
+
+1. If the not-yet-resolved dependency matches any of the
+ ``PRE_INCLUDE_REGEXES``, steps 2 and 3 are skipped, and the dependency
+ resolution proceeds to step 4.
+2. If the not-yet-resolved dependency matches any of the
+ ``PRE_EXCLUDE_REGEXES``, dependency resolution stops for that dependency.
+3. Otherwise, dependency resolution proceeds.
+4. ``file(GET_RUNTIME_DEPENDENCIES)`` searches for the dependency according to
+ the linking rules of the platform (see below).
+5. If the dependency is found, and its full path matches one of the
+ ``POST_INCLUDE_REGEXES``, the full path is added to the resolved
+ dependencies, and ``file(GET_RUNTIME_DEPENDENCIES)`` recursively resolves
+ that library's own dependencies. Otherwise, resolution proceeds to step 6.
+6. If the dependency is found, but its full path matches one of the
+ ``POST_EXCLUDE_REGEXES``, it is not added to the resolved dependencies, and
+ dependency resolution stops for that dependency.
+7. If the dependency is found, and its full path does not match either
+ ``POST_INCLUDE_REGEXES`` or ``POST_EXCLUDE_REGEXES``, the full path is added
+ to the resolved dependencies, and ``file(GET_RUNTIME_DEPENDENCIES)``
+ recursively resolves that library's own dependencies.
+
+Different platforms have different rules for how dependencies are resolved.
+These specifics are described here.
+
+On Linux platforms, library resolution works as follows:
+
+1. If the depending file does not have any ``RUNPATH`` entries, and the library
+ exists in one of the depending file's ``RPATH`` entries, or its parents', in
+ that order, the dependency is resolved to that file.
+2. Otherwise, if the depending file has any ``RUNPATH`` entries, and the
+ library exists in one of those entries, the dependency is resolved to that
+ file.
+3. Otherwise, if the library exists in one of the directories listed by
+ ``ldconfig``, the dependency is resolved to that file.
+4. Otherwise, if the library exists in one of the ``DIRECTORIES`` entries, the
+ dependency is resolved to that file. In this case, a warning is issued,
+ because finding a file in one of the ``DIRECTORIES`` means that the
+ depending file is not complete (it does not list all the directories from
+ which it pulls dependencies).
+5. Otherwise, the dependency is unresolved.
+
+On Windows platforms, library resolution works as follows:
+
+1. The dependent DLL name is converted to lowercase. Windows DLL names are
+ case-insensitive, and some linkers mangle the case of the DLL dependency
+ names. However, this makes it more difficult for ``PRE_INCLUDE_REGEXES``,
+ ``PRE_EXCLUDE_REGEXES``, ``POST_INCLUDE_REGEXES``, and
+ ``POST_EXCLUDE_REGEXES`` to properly filter DLL names - every regex would
+ have to check for both uppercase and lowercase letters. For example:
+
+ .. code-block:: cmake
+
+ file(GET_RUNTIME_DEPENDENCIES
+ # ...
+ PRE_INCLUDE_REGEXES "^[Mm][Yy][Ll][Ii][Bb][Rr][Aa][Rr][Yy]\\.[Dd][Ll][Ll]$"
+ )
+
+ Converting the DLL name to lowercase allows the regexes to only match
+ lowercase names, thus simplifying the regex. For example:
+
+ .. code-block:: cmake
+
+ file(GET_RUNTIME_DEPENDENCIES
+ # ...
+ PRE_INCLUDE_REGEXES "^mylibrary\\.dll$"
+ )
+
+ This regex will match ``mylibrary.dll`` regardless of how it is cased,
+ either on disk or in the depending file. (For example, it will match
+ ``mylibrary.dll``, ``MyLibrary.dll``, and ``MYLIBRARY.DLL``.)
+
+ Please note that the directory portion of any resolved DLLs retains its
+ casing and is not converted to lowercase. Only the filename portion is
+ converted.
+
+2. (**Not yet implemented**) If the depending file is a Windows Store app, and
+ the dependency is listed as a dependency in the application's package
+ manifest, the dependency is resolved to that file.
+3. Otherwise, if the library exists in the same directory as the depending
+ file, the dependency is resolved to that file.
+4. Otherwise, if the library exists in either the operating system's
+ ``system32`` directory or the ``Windows`` directory, in that order, the
+ dependency is resolved to that file.
+5. Otherwise, if the library exists in one of the directories specified by
+ ``DIRECTORIES``, in the order they are listed, the dependency is resolved to
+ that file. In this case, a warning is not issued, because searching other
+ directories is a normal part of Windows library resolution.
+6. Otherwise, the dependency is unresolved.
+
+On Apple platforms, library resolution works as follows:
+
+1. If the dependency starts with ``@executable_path/``, and an ``EXECUTABLES``
+ argument is in the process of being resolved, and replacing
+ ``@executable_path/`` with the directory of the executable yields an
+ existing file, the dependency is resolved to that file.
+2. Otherwise, if the dependency starts with ``@executable_path/``, and there is
+ a ``BUNDLE_EXECUTABLE`` argument, and replacing ``@executable_path/`` with
+ the directory of the bundle executable yields an existing file, the
+ dependency is resolved to that file.
+3. Otherwise, if the dependency starts with ``@loader_path/``, and replacing
+ ``@loader_path/`` with the directory of the depending file yields an
+ existing file, the dependency is resolved to that file.
+4. Otherwise, if the dependency starts with ``@rpath/``, and replacing
+ ``@rpath/`` with one of the ``RPATH`` entries of the depending file yields
+ an existing file, the dependency is resolved to that file. Note that
+ ``RPATH`` entries that start with ``@executable_path/`` or ``@loader_path/``
+ also have these items replaced with the appropriate path.
+5. Otherwise, if the dependency is an absolute file that exists, the dependency
+ is resolved to that file.
+6. Otherwise, the dependency is unresolved.
+
+This function accepts several variables that determine which tool is used for
+dependency resolution:
+
+.. variable:: CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM
+
+ Determines which operating system and executable format the files are built
+ for. This could be one of several values:
+
+ * ``linux+elf``
+ * ``windows+pe``
+ * ``macos+macho``
+
+ If this variable is not specified, it is determined automatically by system
+ introspection.
+
+.. variable:: CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL
+
+ Determines the tool to use for dependency resolution. It could be one of
+ several values, depending on the value of
+ :variable:`CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM`:
+
+ ================================================= =============================================
+ ``CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM`` ``CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL``
+ ================================================= =============================================
+ ``linux+elf`` ``objdump``
+ ``windows+pe`` ``dumpbin``
+ ``windows+pe`` ``objdump``
+ ``macos+macho`` ``otool``
+ ================================================= =============================================
+
+ If this variable is not specified, it is determined automatically by system
+ introspection.
+
+.. variable:: CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND
+
+ Determines the path to the tool to use for dependency resolution. This is the
+ actual path to ``objdump``, ``dumpbin``, or ``otool``.
+
+ If this variable is not specified, it is determined automatically by system
+ introspection.
+
+Writing
+^^^^^^^
+
+.. _WRITE:
+.. _APPEND:
+
+.. code-block:: cmake
+
+ file(WRITE <filename> <content>...)
+ file(APPEND <filename> <content>...)
+
+Write ``<content>`` into a file called ``<filename>``. If the file does
+not exist, it will be created. If the file already exists, ``WRITE``
+mode will overwrite it and ``APPEND`` mode will append to the end.
+Any directories in the path specified by ``<filename>`` that do not
+exist will be created.
+
+If the file is a build input, use the :command:`configure_file` command
+to update the file only when its content changes.
+
+.. _TOUCH:
+.. _TOUCH_NOCREATE:
+
+.. code-block:: cmake
+
+ file(TOUCH [<files>...])
+ file(TOUCH_NOCREATE [<files>...])
-::
+Create a file with no content if it does not yet exist. If the file already
+exists, its access and/or modification will be updated to the time when the
+function call is executed.
+
+Use TOUCH_NOCREATE to touch a file if it exists but not create it. If a file
+does not exist it will be silently ignored.
+
+With TOUCH and TOUCH_NOCREATE the contents of an existing file will not be
+modified.
+
+.. _GENERATE:
+
+.. code-block:: cmake
+
+ file(GENERATE OUTPUT output-file
+ <INPUT input-file|CONTENT content>
+ [CONDITION expression])
+
+Generate an output file for each build configuration supported by the current
+:manual:`CMake Generator <cmake-generators(7)>`. Evaluate
+:manual:`generator expressions <cmake-generator-expressions(7)>`
+from the input content to produce the output content. The options are:
+
+``CONDITION <condition>``
+ Generate the output file for a particular configuration only if
+ the condition is true. The condition must be either ``0`` or ``1``
+ after evaluating generator expressions.
+
+``CONTENT <content>``
+ Use the content given explicitly as input.
+
+``INPUT <input-file>``
+ Use the content from a given file as input.
+ A relative path is treated with respect to the value of
+ :variable:`CMAKE_CURRENT_SOURCE_DIR`. See policy :policy:`CMP0070`.
+
+``OUTPUT <output-file>``
+ Specify the output file name to generate. Use generator expressions
+ such as ``$<CONFIG>`` to specify a configuration-specific output file
+ name. Multiple configurations may generate the same output file only
+ if the generated content is identical. Otherwise, the ``<output-file>``
+ must evaluate to an unique name for each configuration.
+ A relative path (after evaluating generator expressions) is treated
+ with respect to the value of :variable:`CMAKE_CURRENT_BINARY_DIR`.
+ See policy :policy:`CMP0070`.
+
+Exactly one ``CONTENT`` or ``INPUT`` option must be given. A specific
+``OUTPUT`` file may be named by at most one invocation of ``file(GENERATE)``.
+Generated files are modified and their timestamp updated on subsequent cmake
+runs only if their content is changed.
+
+Note also that ``file(GENERATE)`` does not create the output file until the
+generation phase. The output file will not yet have been written when the
+``file(GENERATE)`` command returns, it is written only after processing all
+of a project's ``CMakeLists.txt`` files.
+
+Filesystem
+^^^^^^^^^^
+
+.. _GLOB:
+.. _GLOB_RECURSE:
+
+.. code-block:: cmake
file(GLOB <variable>
- [LIST_DIRECTORIES true|false] [RELATIVE <path>]
+ [LIST_DIRECTORIES true|false] [RELATIVE <path>] [CONFIGURE_DEPENDS]
[<globbing-expressions>...])
file(GLOB_RECURSE <variable> [FOLLOW_SYMLINKS]
- [LIST_DIRECTORIES true|false] [RELATIVE <path>]
+ [LIST_DIRECTORIES true|false] [RELATIVE <path>] [CONFIGURE_DEPENDS]
[<globbing-expressions>...])
Generate a list of files that match the ``<globbing-expressions>`` and
store it into the ``<variable>``. Globbing expressions are similar to
regular expressions, but much simpler. If ``RELATIVE`` flag is
specified, the results will be returned as relative paths to the given
-path. No specific order of results is defined other than that it is
-deterministic. If order is important then sort the list explicitly
-(e.g. using the :command:`list(SORT)` command).
+path. The results will be ordered lexicographically.
+
+On Windows and macOS, globbing is case-insensitive even if the underlying
+filesystem is case-sensitive (both filenames and globbing expressions are
+converted to lowercase before matching). On other platforms, globbing is
+case-sensitive.
-By default ``GLOB`` lists directories - directories are omited in result if
+If the ``CONFIGURE_DEPENDS`` flag is specified, CMake will add logic
+to the main build system check target to rerun the flagged ``GLOB`` commands
+at build time. If any of the outputs change, CMake will regenerate the build
+system.
+
+By default ``GLOB`` lists directories - directories are omitted in result if
``LIST_DIRECTORIES`` is set to false.
.. note::
@@ -117,6 +521,10 @@ By default ``GLOB`` lists directories - directories are omited in result if
your source tree. If no CMakeLists.txt file changes when a source is
added or removed then the generated build system cannot know when to
ask CMake to regenerate.
+ The ``CONFIGURE_DEPENDS`` flag may not work reliably on all generators, or if
+ a new generator is added in the future that cannot support it, projects using
+ it will be stuck. Even if ``CONFIGURE_DEPENDS`` works reliably, there is
+ still a cost to perform the check on every rebuild.
Examples of globbing expressions include::
@@ -138,46 +546,168 @@ Examples of recursive globbing include::
/dir/*.py - match all python files in /dir and subdirectories
-------------------------------------------------------------------------------
+.. _RENAME:
-::
+.. code-block:: cmake
file(RENAME <oldname> <newname>)
Move a file or directory within a filesystem from ``<oldname>`` to
``<newname>``, replacing the destination atomically.
-------------------------------------------------------------------------------
+.. _REMOVE:
+.. _REMOVE_RECURSE:
-::
+.. code-block:: cmake
file(REMOVE [<files>...])
file(REMOVE_RECURSE [<files>...])
Remove the given files. The ``REMOVE_RECURSE`` mode will remove the given
files and directories, also non-empty directories. No error is emitted if a
-given file does not exist.
+given file does not exist. Relative input paths are evaluated with respect
+to the current source directory. Empty input paths are ignored with a warning.
-------------------------------------------------------------------------------
+.. _MAKE_DIRECTORY:
-::
+.. code-block:: cmake
file(MAKE_DIRECTORY [<directories>...])
Create the given directories and their parents as needed.
-------------------------------------------------------------------------------
+.. _COPY:
+.. _INSTALL:
-::
+.. code-block:: cmake
+
+ file(<COPY|INSTALL> <files>... DESTINATION <dir>
+ [FILE_PERMISSIONS <permissions>...]
+ [DIRECTORY_PERMISSIONS <permissions>...]
+ [NO_SOURCE_PERMISSIONS] [USE_SOURCE_PERMISSIONS]
+ [FOLLOW_SYMLINK_CHAIN]
+ [FILES_MATCHING]
+ [[PATTERN <pattern> | REGEX <regex>]
+ [EXCLUDE] [PERMISSIONS <permissions>...]] [...])
+
+The ``COPY`` signature copies files, directories, and symlinks to a
+destination folder. Relative input paths are evaluated with respect
+to the current source directory, and a relative destination is
+evaluated with respect to the current build directory. Copying
+preserves input file timestamps, and optimizes out a file if it exists
+at the destination with the same timestamp. Copying preserves input
+permissions unless explicit permissions or ``NO_SOURCE_PERMISSIONS``
+are given (default is ``USE_SOURCE_PERMISSIONS``).
+
+If ``FOLLOW_SYMLINK_CHAIN`` is specified, ``COPY`` will recursively resolve
+the symlinks at the paths given until a real file is found, and install
+a corresponding symlink in the destination for each symlink encountered. For
+each symlink that is installed, the resolution is stripped of the directory,
+leaving only the filename, meaning that the new symlink points to a file in
+the same directory as the symlink. This feature is useful on some Unix systems,
+where libraries are installed as a chain of symlinks with version numbers, with
+less specific versions pointing to more specific versions.
+``FOLLOW_SYMLINK_CHAIN`` will install all of these symlinks and the library
+itself into the destination directory. For example, if you have the following
+directory structure:
+
+* ``/opt/foo/lib/libfoo.so.1.2.3``
+* ``/opt/foo/lib/libfoo.so.1.2 -> libfoo.so.1.2.3``
+* ``/opt/foo/lib/libfoo.so.1 -> libfoo.so.1.2``
+* ``/opt/foo/lib/libfoo.so -> libfoo.so.1``
+
+and you do:
+
+.. code-block:: cmake
+
+ file(COPY /opt/foo/lib/libfoo.so DESTINATION lib FOLLOW_SYMLINK_CHAIN)
+
+This will install all of the symlinks and ``libfoo.so.1.2.3`` itself into
+``lib``.
+
+See the :command:`install(DIRECTORY)` command for documentation of
+permissions, ``FILES_MATCHING``, ``PATTERN``, ``REGEX``, and
+``EXCLUDE`` options. Copying directories preserves the structure
+of their content even if options are used to select a subset of
+files.
+
+The ``INSTALL`` signature differs slightly from ``COPY``: it prints
+status messages (subject to the :variable:`CMAKE_INSTALL_MESSAGE` variable),
+and ``NO_SOURCE_PERMISSIONS`` is default.
+Installation scripts generated by the :command:`install` command
+use this signature (with some undocumented options for internal use).
+
+.. _SIZE:
+
+.. code-block:: cmake
+
+ file(SIZE <filename> <variable>)
+
+Determine the file size of the ``<filename>`` and put the result in
+``<variable>`` variable. Requires that ``<filename>`` is a valid path
+pointing to a file and is readable.
+
+.. _READ_SYMLINK:
+
+.. code-block:: cmake
+
+ file(READ_SYMLINK <linkname> <variable>)
+
+This subcommand queries the symlink ``<linkname>`` and stores the path it
+points to in the result ``<variable>``. If ``<linkname>`` does not exist or
+is not a symlink, CMake issues a fatal error.
+
+Note that this command returns the raw symlink path and does not resolve
+a relative path. The following is an example of how to ensure that an
+absolute path is obtained:
+
+.. code-block:: cmake
+
+ set(linkname "/path/to/foo.sym")
+ file(READ_SYMLINK "${linkname}" result)
+ if(NOT IS_ABSOLUTE "${result}")
+ get_filename_component(dir "${linkname}" DIRECTORY)
+ set(result "${dir}/${result}")
+ endif()
+
+.. _CREATE_LINK:
+
+.. code-block:: cmake
+
+ file(CREATE_LINK <original> <linkname>
+ [RESULT <result>] [COPY_ON_ERROR] [SYMBOLIC])
+
+Create a link ``<linkname>`` that points to ``<original>``.
+It will be a hard link by default, but providing the ``SYMBOLIC`` option
+results in a symbolic link instead. Hard links require that ``original``
+exists and is a file, not a directory. If ``<linkname>`` already exists,
+it will be overwritten.
+
+The ``<result>`` variable, if specified, receives the status of the operation.
+It is set to ``0`` upon success or an error message otherwise. If ``RESULT``
+is not specified and the operation fails, a fatal error is emitted.
+
+Specifying ``COPY_ON_ERROR`` enables copying the file as a fallback if
+creating the link fails. It can be useful for handling situations such as
+``<original>`` and ``<linkname>`` being on different drives or mount points,
+which would make them unable to support a hard link.
+
+Path Conversion
+^^^^^^^^^^^^^^^
+
+.. _RELATIVE_PATH:
+
+.. code-block:: cmake
file(RELATIVE_PATH <variable> <directory> <file>)
Compute the relative path from a ``<directory>`` to a ``<file>`` and
store it in the ``<variable>``.
-------------------------------------------------------------------------------
+.. _TO_CMAKE_PATH:
+.. _TO_NATIVE_PATH:
-::
+.. code-block:: cmake
file(TO_CMAKE_PATH "<path>" <variable>)
file(TO_NATIVE_PATH "<path>" <variable>)
@@ -193,9 +723,13 @@ path with platform-specific slashes (``\`` on Windows and ``/`` elsewhere).
Always use double quotes around the ``<path>`` to be sure it is treated
as a single argument to this command.
-------------------------------------------------------------------------------
+Transfer
+^^^^^^^^
-::
+.. _DOWNLOAD:
+.. _UPLOAD:
+
+.. code-block:: cmake
file(DOWNLOAD <url> <file> [<options>...])
file(UPLOAD <file> <url> [<options>...])
@@ -231,6 +765,31 @@ Options to both ``DOWNLOAD`` and ``UPLOAD`` are:
``HTTPHEADER <HTTP-header>``
HTTP header for operation. Suboption can be repeated several times.
+``NETRC <level>``
+ Specify whether the .netrc file is to be used for operation. If this
+ option is not specified, the value of the ``CMAKE_NETRC`` variable
+ will be used instead.
+ Valid levels are:
+
+ ``IGNORED``
+ The .netrc file is ignored.
+ This is the default.
+ ``OPTIONAL``
+ The .netrc file is optional, and information in the URL is preferred.
+ The file will be scanned to find which ever information is not specified
+ in the URL.
+ ``REQUIRED``
+ The .netrc file is required, and information in the URL is ignored.
+
+``NETRC_FILE <file>``
+ Specify an alternative .netrc file to the one in your home directory,
+ if the ``NETRC`` level is ``OPTIONAL`` or ``REQUIRED``. If this option
+ is not specified, the value of the ``CMAKE_NETRC_FILE`` variable will
+ be used instead.
+
+If neither ``NETRC`` option is given CMake will check variables
+``CMAKE_NETRC`` and ``CMAKE_NETRC_FILE``, respectively.
+
Additional options to ``DOWNLOAD`` are:
``EXPECTED_HASH ALGO=<value>``
@@ -255,96 +814,12 @@ check certificates and/or use ``EXPECTED_HASH`` to verify downloaded content.
If neither ``TLS`` option is given CMake will check variables
``CMAKE_TLS_VERIFY`` and ``CMAKE_TLS_CAINFO``, respectively.
-------------------------------------------------------------------------------
-
-::
-
- file(TIMESTAMP <filename> <variable> [<format>] [UTC])
-
-Compute a string representation of the modification time of ``<filename>``
-and store it in ``<variable>``. Should the command be unable to obtain a
-timestamp variable will be set to the empty string ("").
-
-See the :command:`string(TIMESTAMP)` command for documentation of
-the ``<format>`` and ``UTC`` options.
-
-------------------------------------------------------------------------------
-
-::
-
- file(GENERATE OUTPUT output-file
- <INPUT input-file|CONTENT content>
- [CONDITION expression])
-
-Generate an output file for each build configuration supported by the current
-:manual:`CMake Generator <cmake-generators(7)>`. Evaluate
-:manual:`generator expressions <cmake-generator-expressions(7)>`
-from the input content to produce the output content. The options are:
-
-``CONDITION <condition>``
- Generate the output file for a particular configuration only if
- the condition is true. The condition must be either ``0`` or ``1``
- after evaluating generator expressions.
-
-``CONTENT <content>``
- Use the content given explicitly as input.
-
-``INPUT <input-file>``
- Use the content from a given file as input.
-
-``OUTPUT <output-file>``
- Specify the output file name to generate. Use generator expressions
- such as ``$<CONFIG>`` to specify a configuration-specific output file
- name. Multiple configurations may generate the same output file only
- if the generated content is identical. Otherwise, the ``<output-file>``
- must evaluate to an unique name for each configuration.
-
-Exactly one ``CONTENT`` or ``INPUT`` option must be given. A specific
-``OUTPUT`` file may be named by at most one invocation of ``file(GENERATE)``.
-Generated files are modified on subsequent cmake runs only if their content
-is changed.
+Locking
+^^^^^^^
-Note also that ``file(GENERATE)`` does not create the output file until the
-generation phase. The output file will not yet have been written when the
-``file(GENERATE)`` command returns, it is written only after processing all
-of a project's ``CMakeLists.txt`` files.
-
-------------------------------------------------------------------------------
+.. _LOCK:
-::
-
- file(<COPY|INSTALL> <files>... DESTINATION <dir>
- [FILE_PERMISSIONS <permissions>...]
- [DIRECTORY_PERMISSIONS <permissions>...]
- [NO_SOURCE_PERMISSIONS] [USE_SOURCE_PERMISSIONS]
- [FILES_MATCHING]
- [[PATTERN <pattern> | REGEX <regex>]
- [EXCLUDE] [PERMISSIONS <permissions>...]] [...])
-
-The ``COPY`` signature copies files, directories, and symlinks to a
-destination folder. Relative input paths are evaluated with respect
-to the current source directory, and a relative destination is
-evaluated with respect to the current build directory. Copying
-preserves input file timestamps, and optimizes out a file if it exists
-at the destination with the same timestamp. Copying preserves input
-permissions unless explicit permissions or ``NO_SOURCE_PERMISSIONS``
-are given (default is ``USE_SOURCE_PERMISSIONS``).
-
-See the :command:`install(DIRECTORY)` command for documentation of
-permissions, ``FILES_MATCHING``, ``PATTERN``, ``REGEX``, and
-``EXCLUDE`` options. Copying directories preserves the structure
-of their content even if options are used to select a subset of
-files.
-
-The ``INSTALL`` signature differs slightly from ``COPY``: it prints
-status messages (subject to the :variable:`CMAKE_INSTALL_MESSAGE` variable),
-and ``NO_SOURCE_PERMISSIONS`` is default.
-Installation scripts generated by the :command:`install` command
-use this signature (with some undocumented options for internal use).
-
-------------------------------------------------------------------------------
-
-::
+.. code-block:: cmake
file(LOCK <path> [DIRECTORY] [RELEASE]
[GUARD <FUNCTION|FILE|PROCESS>]
diff --git a/Help/command/find_file.rst b/Help/command/find_file.rst
index e56097bea..3f03f37e3 100644
--- a/Help/command/find_file.rst
+++ b/Help/command/find_file.rst
@@ -8,17 +8,19 @@ find_file
.. |prefix_XXX_SUBDIR| replace:: ``<prefix>/include``
.. |entry_XXX_SUBDIR| replace:: ``<entry>/include``
+.. |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX| replace::
+ ``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE`
+ is set, and |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX_SUBDIR|
.. |CMAKE_PREFIX_PATH_XXX| replace::
``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE`
is set, and |CMAKE_PREFIX_PATH_XXX_SUBDIR|
.. |CMAKE_XXX_PATH| replace:: :variable:`CMAKE_INCLUDE_PATH`
.. |CMAKE_XXX_MAC_PATH| replace:: :variable:`CMAKE_FRAMEWORK_PATH`
-.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: Directories in ``INCLUDE``.
- On Windows hosts:
- ``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE`
- is set, and |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR|, and the
- directories in ``PATH`` itself.
+.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: The directories in ``PATH`` and ``INCLUDE``.
+.. |SYSTEM_ENVIRONMENT_PATH_WINDOWS_XXX| replace:: On Windows hosts:
+ ``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE`
+ is set, and |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR|.
.. |CMAKE_SYSTEM_PREFIX_PATH_XXX| replace::
``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE`
diff --git a/Help/command/find_library.rst b/Help/command/find_library.rst
index f774f17ec..8a55aca3d 100644
--- a/Help/command/find_library.rst
+++ b/Help/command/find_library.rst
@@ -8,17 +8,19 @@ find_library
.. |prefix_XXX_SUBDIR| replace:: ``<prefix>/lib``
.. |entry_XXX_SUBDIR| replace:: ``<entry>/lib``
+.. |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX| replace::
+ ``<prefix>/lib/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE` is set,
+ and |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX_SUBDIR|
.. |CMAKE_PREFIX_PATH_XXX| replace::
``<prefix>/lib/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE` is set,
and |CMAKE_PREFIX_PATH_XXX_SUBDIR|
.. |CMAKE_XXX_PATH| replace:: :variable:`CMAKE_LIBRARY_PATH`
.. |CMAKE_XXX_MAC_PATH| replace:: :variable:`CMAKE_FRAMEWORK_PATH`
-.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: Directories in ``LIB``.
- On Windows hosts:
- ``<prefix>/lib/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE` is set,
- and |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR|,
- and the directories in ``PATH`` itself.
+.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: The directories in ``PATH`` and ``INCLUDE``.
+.. |SYSTEM_ENVIRONMENT_PATH_WINDOWS_XXX| replace:: On Windows hosts:
+ ``<prefix>/lib/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE`
+ is set, and |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR|.
.. |CMAKE_SYSTEM_PREFIX_PATH_XXX| replace::
``<prefix>/lib/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE` is set,
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst
index 83f471619..64a16f321 100644
--- a/Help/command/find_package.rst
+++ b/Help/command/find_package.rst
@@ -1,23 +1,31 @@
find_package
------------
-Load settings for an external project.
+.. only:: html
-::
+ .. contents::
- find_package(<package> [version] [EXACT] [QUIET] [MODULE]
+Find an external project, and load its settings.
+
+.. _`basic signature`:
+
+Basic Signature and Module Mode
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: cmake
+
+ find_package(<PackageName> [version] [EXACT] [QUIET] [MODULE]
[REQUIRED] [[COMPONENTS] [components...]]
[OPTIONAL_COMPONENTS components...]
[NO_POLICY_SCOPE])
-Finds and loads settings from an external project. ``<package>_FOUND``
+Finds and loads settings from an external project. ``<PackageName>_FOUND``
will be set to indicate whether the package was found. When the
package is found package-specific information is provided through
variables and :ref:`Imported Targets` documented by the package itself. The
-``QUIET`` option disables messages if the package cannot be found. The
-``MODULE`` option disables the second signature documented below. The
-``REQUIRED`` option stops processing with an error message if the package
-cannot be found.
+``QUIET`` option disables informational messages, including those indicating
+that the package cannot be found if it is not ``REQUIRED``. The ``REQUIRED``
+option stops processing with an error message if the package cannot be found.
A package-specific list of required components may be listed after the
``COMPONENTS`` option (or after the ``REQUIRED`` option if present).
@@ -33,29 +41,47 @@ should be compatible (format is ``major[.minor[.patch[.tweak]]]``). The
inside a find-module, the corresponding arguments are forwarded
automatically from the outer call (including the ``EXACT`` flag for
``[version]``). Version support is currently provided only on a
-package-by-package basis (details below).
+package-by-package basis (see the `Version Selection`_ section below).
+
+See the :command:`cmake_policy` command documentation for discussion
+of the ``NO_POLICY_SCOPE`` option.
-User code should generally look for packages using the above simple
-signature. The remainder of this command documentation specifies the
+The command has two modes by which it searches for packages: "Module"
+mode and "Config" mode. The above signature selects Module mode.
+If no module is found the command falls back to Config mode, described
+below. This fall back is disabled if the ``MODULE`` option is given.
+
+In Module mode, CMake searches for a file called ``Find<PackageName>.cmake``.
+The file is first searched in the :variable:`CMAKE_MODULE_PATH`,
+then among the :ref:`Find Modules` provided by the CMake installation.
+If the file is found, it is read and processed by CMake. It is responsible
+for finding the package, checking the version, and producing any needed
+messages. Some find-modules provide limited or no support for versioning;
+check the module documentation.
+
+If the ``MODULE`` option is not specfied in the above signature,
+CMake first searches for the package using Module mode. Then, if the
+package is not found, it searches again using Config mode. A user
+may set the variable :variable:`CMAKE_FIND_PACKAGE_PREFER_CONFIG` to
+``TRUE`` to direct CMake first search using Config mode before falling
+back to Module mode.
+
+Full Signature and Config Mode
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+User code should generally look for packages using the above `basic
+signature`_. The remainder of this command documentation specifies the
full command signature and details of the search process. Project
maintainers wishing to provide a package to be found by this command
are encouraged to read on.
-The command has two modes by which it searches for packages: "Module"
-mode and "Config" mode. Module mode is available when the command is
-invoked with the above reduced signature. CMake searches for a file
-called ``Find<package>.cmake`` in the :variable:`CMAKE_MODULE_PATH`
-followed by the CMake installation. If the file is found, it is read
-and processed by CMake. It is responsible for finding the package,
-checking the version, and producing any needed messages. Many
-find-modules provide limited or no support for versioning; check
-the module documentation. If no module is found and the ``MODULE``
-option is not given the command proceeds to Config mode.
-
-The complete Config mode command signature is::
-
- find_package(<package> [version] [EXACT] [QUIET]
+The complete Config mode command signature is
+
+.. code-block:: cmake
+
+ find_package(<PackageName> [version] [EXACT] [QUIET]
[REQUIRED] [[COMPONENTS] [components...]]
+ [OPTIONAL_COMPONENTS components...]
[CONFIG|NO_MODULE]
[NO_POLICY_SCOPE]
[NAMES name1 [name2 ...]]
@@ -64,6 +90,7 @@ The complete Config mode command signature is::
[PATHS path1 [path2 ... ]]
[PATH_SUFFIXES suffix1 [suffix2 ...]]
[NO_DEFAULT_PATH]
+ [NO_PACKAGE_ROOT_PATH]
[NO_CMAKE_PATH]
[NO_CMAKE_ENVIRONMENT_PATH]
[NO_SYSTEM_ENVIRONMENT_PATH]
@@ -75,37 +102,44 @@ The complete Config mode command signature is::
ONLY_CMAKE_FIND_ROOT_PATH |
NO_CMAKE_FIND_ROOT_PATH])
-The ``CONFIG`` option may be used to skip Module mode explicitly and
-switch to Config mode. It is synonymous to using ``NO_MODULE``. Config
-mode is also implied by use of options not specified in the reduced
-signature.
+The ``CONFIG`` option, the synonymous ``NO_MODULE`` option, or the use
+of options not specified in the `basic signature`_ all enforce pure Config
+mode. In pure Config mode, the command skips Module mode search and
+proceeds at once with Config mode search.
-Config mode attempts to locate a configuration file provided by the
-package to be found. A cache entry called ``<package>_DIR`` is created to
+Config mode search attempts to locate a configuration file provided by the
+package to be found. A cache entry called ``<PackageName>_DIR`` is created to
hold the directory containing the file. By default the command
-searches for a package with the name ``<package>``. If the ``NAMES`` option
-is given the names following it are used instead of ``<package>``. The
-command searches for a file called ``<name>Config.cmake`` or
-``<lower-case-name>-config.cmake`` for each name specified. A
-replacement set of possible configuration file names may be given
+searches for a package with the name ``<PackageName>``. If the ``NAMES`` option
+is given the names following it are used instead of ``<PackageName>``.
+The command searches for a file called ``<PackageName>Config.cmake`` or
+``<lower-case-package-name>-config.cmake`` for each name specified.
+A replacement set of possible configuration file names may be given
using the ``CONFIGS`` option. The search procedure is specified below.
Once found, the configuration file is read and processed by CMake.
Since the file is provided by the package it already knows the
location of package contents. The full path to the configuration file
-is stored in the cmake variable ``<package>_CONFIG``.
+is stored in the cmake variable ``<PackageName>_CONFIG``.
All configuration files which have been considered by CMake while
searching for an installation of the package with an appropriate
-version are stored in the cmake variable ``<package>_CONSIDERED_CONFIGS``,
-the associated versions in ``<package>_CONSIDERED_VERSIONS``.
+version are stored in the cmake variable ``<PackageName>_CONSIDERED_CONFIGS``,
+the associated versions in ``<PackageName>_CONSIDERED_VERSIONS``.
If the package configuration file cannot be found CMake will generate
an error describing the problem unless the ``QUIET`` argument is
specified. If ``REQUIRED`` is specified and the package is not found a
fatal error is generated and the configure step stops executing. If
-``<package>_DIR`` has been set to a directory not containing a
+``<PackageName>_DIR`` has been set to a directory not containing a
configuration file CMake will ignore it and search from scratch.
+Package maintainers providing CMake package configuration files are
+encouraged to name and install them such that the `Search Procedure`_
+outlined below will find them without requiring use of additional options.
+
+Version Selection
+^^^^^^^^^^^^^^^^^
+
When the ``[version]`` argument is given Config mode will only find a
version of the package that claims compatibility with the requested
version (format is ``major[.minor[.patch[.tweak]]]``). If the ``EXACT``
@@ -126,7 +160,7 @@ version file is loaded in a nested scope in which the following
variables have been defined:
``PACKAGE_FIND_NAME``
- the ``<package>`` name
+ the ``<PackageName>``
``PACKAGE_FIND_VERSION``
full requested version string
``PACKAGE_FIND_VERSION_MAJOR``
@@ -154,20 +188,20 @@ sets these variables:
These variables are checked by the ``find_package`` command to determine
whether the configuration file provides an acceptable version. They
-are not available after the find_package call returns. If the version
+are not available after the ``find_package`` call returns. If the version
is acceptable the following variables are set:
-``<package>_VERSION``
+``<PackageName>_VERSION``
full provided version string
-``<package>_VERSION_MAJOR``
+``<PackageName>_VERSION_MAJOR``
major version if provided, else 0
-``<package>_VERSION_MINOR``
+``<PackageName>_VERSION_MINOR``
minor version if provided, else 0
-``<package>_VERSION_PATCH``
+``<PackageName>_VERSION_PATCH``
patch version if provided, else 0
-``<package>_VERSION_TWEAK``
+``<PackageName>_VERSION_TWEAK``
tweak version if provided, else 0
-``<package>_VERSION_COUNT``
+``<PackageName>_VERSION_COUNT``
number of version components, 0 to 4
and the corresponding package configuration file is loaded.
@@ -176,47 +210,40 @@ claim compatibility with the version requested it is unspecified which
one is chosen: unless the variable :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER`
is set no attempt is made to choose a highest or closest version number.
-To control the order in which ``find_package`` checks for compatibiliy use
+To control the order in which ``find_package`` checks for compatibility use
the two variables :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER` and
:variable:`CMAKE_FIND_PACKAGE_SORT_DIRECTION`.
-For instance in order to select the highest version one can set::
+For instance in order to select the highest version one can set
+
+.. code-block:: cmake
SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
before calling ``find_package``.
-Config mode provides an elaborate interface and search procedure.
-Much of the interface is provided for completeness and for use
-internally by find-modules loaded by Module mode. Most user code
-should simply call::
-
- find_package(<package> [major[.minor]] [EXACT] [REQUIRED|QUIET])
-
-in order to find a package. Package maintainers providing CMake
-package configuration files are encouraged to name and install them
-such that the procedure outlined below will find them without
-requiring use of additional options.
+Search Procedure
+^^^^^^^^^^^^^^^^
CMake constructs a set of possible installation prefixes for the
package. Under each prefix several directories are searched for a
configuration file. The tables below show the directories searched.
-Each entry is meant for installation trees following Windows (W), UNIX
-(U), or Apple (A) conventions::
+Each entry is meant for installation trees following Windows (``W``), UNIX
+(``U``), or Apple (``A``) conventions::
<prefix>/ (W)
<prefix>/(cmake|CMake)/ (W)
<prefix>/<name>*/ (W)
<prefix>/<name>*/(cmake|CMake)/ (W)
- <prefix>/(lib/<arch>|lib|share)/cmake/<name>*/ (U)
- <prefix>/(lib/<arch>|lib|share)/<name>*/ (U)
- <prefix>/(lib/<arch>|lib|share)/<name>*/(cmake|CMake)/ (U)
- <prefix>/<name>*/(lib/<arch>|lib|share)/cmake/<name>*/ (W/U)
- <prefix>/<name>*/(lib/<arch>|lib|share)/<name>*/ (W/U)
- <prefix>/<name>*/(lib/<arch>|lib|share)/<name>*/(cmake|CMake)/ (W/U)
-
-On systems supporting OS X Frameworks and Application Bundles the
-following directories are searched for frameworks or bundles
+ <prefix>/(lib/<arch>|lib*|share)/cmake/<name>*/ (U)
+ <prefix>/(lib/<arch>|lib*|share)/<name>*/ (U)
+ <prefix>/(lib/<arch>|lib*|share)/<name>*/(cmake|CMake)/ (U)
+ <prefix>/<name>*/(lib/<arch>|lib*|share)/cmake/<name>*/ (W/U)
+ <prefix>/<name>*/(lib/<arch>|lib*|share)/<name>*/ (W/U)
+ <prefix>/<name>*/(lib/<arch>|lib*|share)/<name>*/(cmake|CMake)/ (W/U)
+
+On systems supporting macOS :prop_tgt:`FRAMEWORK` and :prop_tgt:`BUNDLE`, the
+following directories are searched for Frameworks or Application Bundles
containing a configuration file::
<prefix>/<name>.framework/Resources/ (A)
@@ -227,20 +254,32 @@ containing a configuration file::
<prefix>/<name>.app/Contents/Resources/CMake/ (A)
In all cases the ``<name>`` is treated as case-insensitive and corresponds
-to any of the names specified (``<package>`` or names given by ``NAMES``).
+to any of the names specified (``<PackageName>`` or names given by ``NAMES``).
+
Paths with ``lib/<arch>`` are enabled if the
-:variable:`CMAKE_LIBRARY_ARCHITECTURE` variable is set. If ``PATH_SUFFIXES``
-is specified the suffixes are appended to each (W) or (U) directory entry
-one-by-one.
+:variable:`CMAKE_LIBRARY_ARCHITECTURE` variable is set. ``lib*`` includes one
+or more of the values ``lib64``, ``lib32``, ``libx32`` or ``lib`` (searched in
+that order).
+
+* Paths with ``lib64`` are searched on 64 bit platforms if the
+ :prop_gbl:`FIND_LIBRARY_USE_LIB64_PATHS` property is set to ``TRUE``.
+* Paths with ``lib32`` are searched on 32 bit platforms if the
+ :prop_gbl:`FIND_LIBRARY_USE_LIB32_PATHS` property is set to ``TRUE``.
+* Paths with ``libx32`` are searched on platforms using the x32 ABI
+ if the :prop_gbl:`FIND_LIBRARY_USE_LIBX32_PATHS` property is set to ``TRUE``.
+* The ``lib`` path is always searched.
+
+If ``PATH_SUFFIXES`` is specified, the suffixes are appended to each
+(``W``) or (``U``) directory entry one-by-one.
This set of directories is intended to work in cooperation with
projects that provide configuration files in their installation trees.
-Directories above marked with (W) are intended for installations on
+Directories above marked with (``W``) are intended for installations on
Windows where the prefix may point at the top of an application's
-installation directory. Those marked with (U) are intended for
+installation directory. Those marked with (``U``) are intended for
installations on UNIX platforms where the prefix is shared by multiple
-packages. This is merely a convention, so all (W) and (U) directories
-are still searched on all platforms. Directories marked with (A) are
+packages. This is merely a convention, so all (``W``) and (``U``) directories
+are still searched on all platforms. Directories marked with (``A``) are
intended for installations on Apple platforms. The
:variable:`CMAKE_FIND_FRAMEWORK` and :variable:`CMAKE_FIND_APPBUNDLE`
variables determine the order of preference.
@@ -249,101 +288,127 @@ The set of installation prefixes is constructed using the following
steps. If ``NO_DEFAULT_PATH`` is specified all ``NO_*`` options are
enabled.
-1. Search paths specified in cmake-specific cache variables. These
+1. Search paths specified in the :variable:`<PackageName>_ROOT` CMake
+ variable and the :envvar:`<PackageName>_ROOT` environment variable,
+ where ``<PackageName>`` is the package to be found.
+ The package root variables are maintained as a stack so if
+ called from within a find module, root paths from the parent's find
+ module will also be searched after paths for the current package.
+ This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
+ the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
+ See policy :policy:`CMP0074`.
+
+2. Search paths specified in cmake-specific cache variables. These
are intended to be used on the command line with a ``-DVAR=value``.
- The values are interpreted as :ref:`;-lists <CMake Language Lists>`.
- This can be skipped if ``NO_CMAKE_PATH`` is passed::
+ The values are interpreted as :ref:`semicolon-separated lists <CMake Language Lists>`.
+ This can be skipped if ``NO_CMAKE_PATH`` is passed or by setting the
+ :variable:`CMAKE_FIND_USE_CMAKE_PATH` to ``FALSE``::
CMAKE_PREFIX_PATH
CMAKE_FRAMEWORK_PATH
CMAKE_APPBUNDLE_PATH
-2. Search paths specified in cmake-specific environment variables.
+3. Search paths specified in cmake-specific environment variables.
These are intended to be set in the user's shell configuration,
and therefore use the host's native path separator
(``;`` on Windows and ``:`` on UNIX).
- This can be skipped if ``NO_CMAKE_ENVIRONMENT_PATH`` is passed::
+ This can be skipped if ``NO_CMAKE_ENVIRONMENT_PATH`` is passed or by setting
+ the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` to ``FALSE``::
- <package>_DIR
+ <PackageName>_DIR
CMAKE_PREFIX_PATH
CMAKE_FRAMEWORK_PATH
CMAKE_APPBUNDLE_PATH
-3. Search paths specified by the ``HINTS`` option. These should be paths
+4. Search paths specified by the ``HINTS`` option. These should be paths
computed by system introspection, such as a hint provided by the
location of another item already found. Hard-coded guesses should
be specified with the ``PATHS`` option.
-4. Search the standard system environment variables. This can be
- skipped if ``NO_SYSTEM_ENVIRONMENT_PATH`` is passed. Path entries
+5. Search the standard system environment variables. This can be
+ skipped if ``NO_SYSTEM_ENVIRONMENT_PATH`` is passed or by setting the
+ :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` to ``FALSE``. Path entries
ending in ``/bin`` or ``/sbin`` are automatically converted to their
parent directories::
PATH
-5. Search paths stored in the CMake :ref:`User Package Registry`.
+6. Search paths stored in the CMake :ref:`User Package Registry`.
This can be skipped if ``NO_CMAKE_PACKAGE_REGISTRY`` is passed or by
- setting the :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`
- to ``TRUE``.
+ setting the variable :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`
+ to ``FALSE`` or the deprecated variable
+ :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` to ``TRUE``.
+
See the :manual:`cmake-packages(7)` manual for details on the user
package registry.
-6. Search cmake variables defined in the Platform files for the
+7. Search cmake variables defined in the Platform files for the
current system. This can be skipped if ``NO_CMAKE_SYSTEM_PATH`` is
- passed::
+ passed or by setting the :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`
+ to ``FALSE``::
CMAKE_SYSTEM_PREFIX_PATH
CMAKE_SYSTEM_FRAMEWORK_PATH
CMAKE_SYSTEM_APPBUNDLE_PATH
-7. Search paths stored in the CMake :ref:`System Package Registry`.
+8. Search paths stored in the CMake :ref:`System Package Registry`.
This can be skipped if ``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` is passed
- or by setting the
+ or by setting the :variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY`
+ variable to ``FALSE`` or the deprecated variable
:variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` to ``TRUE``.
+
See the :manual:`cmake-packages(7)` manual for details on the system
package registry.
-8. Search paths specified by the ``PATHS`` option. These are typically
+9. Search paths specified by the ``PATHS`` option. These are typically
hard-coded guesses.
.. |FIND_XXX| replace:: find_package
-.. |FIND_ARGS_XXX| replace:: <package>
+.. |FIND_ARGS_XXX| replace:: <PackageName>
.. |CMAKE_FIND_ROOT_PATH_MODE_XXX| replace::
:variable:`CMAKE_FIND_ROOT_PATH_MODE_PACKAGE`
.. include:: FIND_XXX_ROOT.txt
.. include:: FIND_XXX_ORDER.txt
+By default the value stored in the result variable will be the path at
+which the file is found. The :variable:`CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS`
+variable may be set to ``TRUE`` before calling ``find_package`` in order
+to resolve symbolic links and store the real path to the file.
+
Every non-REQUIRED ``find_package`` call can be disabled by setting the
:variable:`CMAKE_DISABLE_FIND_PACKAGE_<PackageName>` variable to ``TRUE``.
+Package File Interface Variables
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
When loading a find module or package configuration file ``find_package``
defines variables to provide information about the call arguments (and
restores their original state before returning):
``CMAKE_FIND_PACKAGE_NAME``
- the ``<package>`` name which is searched for
-``<package>_FIND_REQUIRED``
+ the ``<PackageName>`` which is searched for
+``<PackageName>_FIND_REQUIRED``
true if ``REQUIRED`` option was given
-``<package>_FIND_QUIETLY``
+``<PackageName>_FIND_QUIETLY``
true if ``QUIET`` option was given
-``<package>_FIND_VERSION``
+``<PackageName>_FIND_VERSION``
full requested version string
-``<package>_FIND_VERSION_MAJOR``
+``<PackageName>_FIND_VERSION_MAJOR``
major version if requested, else 0
-``<package>_FIND_VERSION_MINOR``
+``<PackageName>_FIND_VERSION_MINOR``
minor version if requested, else 0
-``<package>_FIND_VERSION_PATCH``
+``<PackageName>_FIND_VERSION_PATCH``
patch version if requested, else 0
-``<package>_FIND_VERSION_TWEAK``
+``<PackageName>_FIND_VERSION_TWEAK``
tweak version if requested, else 0
-``<package>_FIND_VERSION_COUNT``
+``<PackageName>_FIND_VERSION_COUNT``
number of version components, 0 to 4
-``<package>_FIND_VERSION_EXACT``
+``<PackageName>_FIND_VERSION_EXACT``
true if ``EXACT`` option was given
-``<package>_FIND_COMPONENTS``
+``<PackageName>_FIND_COMPONENTS``
list of requested components
-``<package>_FIND_REQUIRED_<c>``
+``<PackageName>_FIND_REQUIRED_<c>``
true if component ``<c>`` is required,
false if component ``<c>`` is optional
@@ -353,8 +418,5 @@ In Config mode ``find_package`` handles ``REQUIRED``, ``QUIET``, and
``[version]`` options automatically but leaves it to the package
configuration file to handle components in a way that makes sense
for the package. The package configuration file may set
-``<package>_FOUND`` to false to tell ``find_package`` that component
+``<PackageName>_FOUND`` to false to tell ``find_package`` that component
requirements are not satisfied.
-
-See the :command:`cmake_policy` command documentation for discussion
-of the ``NO_POLICY_SCOPE`` option.
diff --git a/Help/command/find_path.rst b/Help/command/find_path.rst
index 76342d020..52ffe3c79 100644
--- a/Help/command/find_path.rst
+++ b/Help/command/find_path.rst
@@ -8,17 +8,19 @@ find_path
.. |prefix_XXX_SUBDIR| replace:: ``<prefix>/include``
.. |entry_XXX_SUBDIR| replace:: ``<entry>/include``
+.. |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX| replace::
+ ``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE`
+ is set, and |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX_SUBDIR|
.. |CMAKE_PREFIX_PATH_XXX| replace::
``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE`
is set, and |CMAKE_PREFIX_PATH_XXX_SUBDIR|
.. |CMAKE_XXX_PATH| replace:: :variable:`CMAKE_INCLUDE_PATH`
.. |CMAKE_XXX_MAC_PATH| replace:: :variable:`CMAKE_FRAMEWORK_PATH`
-.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: Directories in ``INCLUDE``.
- On Windows hosts:
- ``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE`
- is set, and |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR|, and the
- directories in ``PATH`` itself.
+.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: The directories in ``PATH`` and ``INCLUDE``.
+.. |SYSTEM_ENVIRONMENT_PATH_WINDOWS_XXX| replace:: On Windows hosts:
+ ``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE`
+ is set, and |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR|.
.. |CMAKE_SYSTEM_PREFIX_PATH_XXX| replace::
``<prefix>/include/<arch>`` if :variable:`CMAKE_LIBRARY_ARCHITECTURE`
diff --git a/Help/command/find_program.rst b/Help/command/find_program.rst
index d3430c054..e2ff69342 100644
--- a/Help/command/find_program.rst
+++ b/Help/command/find_program.rst
@@ -8,12 +8,15 @@ find_program
.. |prefix_XXX_SUBDIR| replace:: ``<prefix>/[s]bin``
.. |entry_XXX_SUBDIR| replace:: ``<entry>/[s]bin``
+.. |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX| replace::
+ |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX_SUBDIR|
.. |CMAKE_PREFIX_PATH_XXX| replace::
|CMAKE_PREFIX_PATH_XXX_SUBDIR|
.. |CMAKE_XXX_PATH| replace:: :variable:`CMAKE_PROGRAM_PATH`
.. |CMAKE_XXX_MAC_PATH| replace:: :variable:`CMAKE_APPBUNDLE_PATH`
-.. |SYSTEM_ENVIRONMENT_PATH_XXX| replace:: ``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
.. |CMAKE_SYSTEM_PREFIX_PATH_XXX| replace::
|CMAKE_SYSTEM_PREFIX_PATH_XXX_SUBDIR|
diff --git a/Help/command/fltk_wrap_ui.rst b/Help/command/fltk_wrap_ui.rst
index 041e5a7e3..66752729d 100644
--- a/Help/command/fltk_wrap_ui.rst
+++ b/Help/command/fltk_wrap_ui.rst
@@ -3,7 +3,7 @@ fltk_wrap_ui
Create FLTK user interfaces Wrappers.
-::
+.. code-block:: cmake
fltk_wrap_ui(resultingLibraryName source1
source2 ... sourceN )
diff --git a/Help/command/foreach.rst b/Help/command/foreach.rst
index c0f3679d9..ae2afb290 100644
--- a/Help/command/foreach.rst
+++ b/Help/command/foreach.rst
@@ -3,45 +3,82 @@ foreach
Evaluate a group of commands for each value in a list.
-::
+.. code-block:: cmake
- foreach(loop_var arg1 arg2 ...)
- COMMAND1(ARGS ...)
- COMMAND2(ARGS ...)
- ...
- endforeach(loop_var)
+ foreach(<loop_var> <items>)
+ <commands>
+ endforeach()
-All commands between foreach and the matching endforeach are recorded
-without being invoked. Once the endforeach is evaluated, the recorded
-list of commands is invoked once for each argument listed in the
-original foreach command. Before each iteration of the loop
-``${loop_var}`` will be set as a variable with the current value in the
-list.
+where ``<items>`` is a list of items that are separated by
+semicolon or whitespace.
+All commands between ``foreach`` and the matching ``endforeach`` are recorded
+without being invoked. Once the ``endforeach`` is evaluated, the recorded
+list of commands is invoked once for each item in ``<items>``.
+At the beginning of each iteration the variable ``loop_var`` will be set
+to the value of the current item.
-::
+The commands :command:`break` and :command:`continue` provide means to
+escape from the normal control flow.
- foreach(loop_var RANGE total)
- foreach(loop_var RANGE start stop [step])
+Per legacy, the :command:`endforeach` command admits
+an optional ``<loop_var>`` argument.
+If used, it must be a verbatim
+repeat of the argument of the opening
+``foreach`` command.
-Foreach can also iterate over a generated range of numbers. There are
-three types of this iteration:
+.. code-block:: cmake
-* When specifying single number, the range will have elements 0 to
- "total".
+ foreach(<loop_var> RANGE <stop>)
-* When specifying two numbers, the range will have elements from the
- first number to the second number.
+In this variant, ``foreach`` iterates over the numbers
+0, 1, ... up to (and including) the nonnegative integer ``<stop>``.
-* The third optional number is the increment used to iterate from the
- first number to the second number.
+.. code-block:: cmake
-::
+ foreach(<loop_var> RANGE <start> <stop> [<step>])
+
+In this variant, ``foreach`` iterates over the numbers from
+``<start>`` up to at most ``<stop>`` in steps of ``<step>``.
+If ``<step>`` is not specified, then the step size is 1.
+The three arguments ``<start>`` ``<stop>`` ``<step>`` must
+all be nonnegative integers, and ``<stop>`` must not be
+smaller than ``<start>``; otherwise you enter the danger zone
+of undocumented behavior that may change in future releases.
+
+.. code-block:: cmake
+
+ foreach(loop_var IN [LISTS [<lists>]] [ITEMS [<items>]])
- foreach(loop_var IN [LISTS [list1 [...]]]
- [ITEMS [item1 [...]]])
+In this variant, ``<lists>`` is a whitespace or semicolon
+separated list of list-valued variables. The ``foreach``
+command iterates over each item in each given list.
+The ``<items>`` following the ``ITEMS`` keyword are processed
+as in the first variant of the ``foreach`` command.
+The forms ``LISTS A`` and ``ITEMS ${A}`` are
+equivalent.
+
+The following example shows how the ``LISTS`` option is
+processed:
+
+.. code-block:: cmake
+
+ set(A 0;1)
+ set(B 2 3)
+ set(C "4 5")
+ set(D 6;7 8)
+ set(E "")
+ foreach(X IN LISTS A B C D E)
+ message(STATUS "X=${X}")
+ endforeach()
+
+yields
+::
-Iterates over a precise list of items. The ``LISTS`` option names
-list-valued variables to be traversed, including empty elements (an
-empty string is a zero-length list). (Note macro
-arguments are not variables.) The ``ITEMS`` option ends argument
-parsing and includes all arguments following it in the iteration.
+ -- X=0
+ -- X=1
+ -- X=2
+ -- X=3
+ -- X=4 5
+ -- X=6
+ -- X=7
+ -- X=8
diff --git a/Help/command/function.rst b/Help/command/function.rst
index 7ffdfee65..53ba75481 100644
--- a/Help/command/function.rst
+++ b/Help/command/function.rst
@@ -1,36 +1,70 @@
function
--------
-Start recording a function for later invocation as a command::
-
- function(<name> [arg1 [arg2 [arg3 ...]]])
- COMMAND1(ARGS ...)
- COMMAND2(ARGS ...)
- ...
- endfunction(<name>)
-
-Define a function named ``<name>`` that takes arguments named ``arg1``,
-``arg2``, ``arg3``, (...).
-Commands listed after function, but before the matching
-:command:`endfunction()`, are not invoked until the function is invoked.
-When it is invoked, the commands recorded in the function are first
-modified by replacing formal parameters (``${arg1}``) with the arguments
-passed, and then invoked as normal commands.
-In addition to referencing the formal parameters you can reference the
-``ARGC`` variable which will be set to the number of arguments passed
-into the function as well as ``ARGV0``, ``ARGV1``, ``ARGV2``, ... which
-will have the actual values of the arguments passed in.
-This facilitates creating functions with optional arguments.
-Additionally ``ARGV`` holds the list of all arguments given to the
-function and ``ARGN`` holds the list of arguments past the last expected
-argument.
-Referencing to ``ARGV#`` arguments beyond ``ARGC`` have undefined
-behavior. Checking that ``ARGC`` is greater than ``#`` is the only way
-to ensure that ``ARGV#`` was passed to the function as an extra
-argument.
+Start recording a function for later invocation as a command.
+
+.. code-block:: cmake
+
+ function(<name> [<arg1> ...])
+ <commands>
+ endfunction()
+
+Defines a function named ``<name>`` that takes arguments named
+``<arg1>``, ... The ``<commands>`` in the function definition
+are recorded; they are not executed until the function is invoked.
+
+Per legacy, the :command:`endfunction` command admits an optional
+``<name>`` argument. If used, it must be a verbatim repeat of the
+argument of the opening ``function`` command.
A function opens a new scope: see :command:`set(var PARENT_SCOPE)` for
details.
See the :command:`cmake_policy()` command documentation for the behavior
of policies inside functions.
+
+See the :command:`macro()` command documentation for differences
+between CMake functions and macros.
+
+Invocation
+^^^^^^^^^^
+
+The function invocation is case-insensitive. A function defined as
+
+.. code-block:: cmake
+
+ function(foo)
+ <commands>
+ endfunction()
+
+can be invoked through any of
+
+.. code-block:: cmake
+
+ foo()
+ Foo()
+ FOO()
+
+and so on. However, it is strongly recommended to stay with the
+case chosen in the function definition. Typically functions use
+all-lowercase names.
+
+Arguments
+^^^^^^^^^
+
+When the function is invoked, the recorded ``<commands>`` are first
+modified by replacing formal parameters (``${arg1}``, ...) with the
+arguments passed, and then invoked as normal commands.
+
+In addition to referencing the formal parameters you can reference the
+``ARGC`` variable which will be set to the number of arguments passed
+into the function as well as ``ARGV0``, ``ARGV1``, ``ARGV2``, ... which
+will have the actual values of the arguments passed in. This facilitates
+creating functions with optional arguments.
+
+Furthermore, ``ARGV`` holds the list of all arguments given to the
+function and ``ARGN`` holds the list of arguments past the last expected
+argument. Referencing to ``ARGV#`` arguments beyond ``ARGC`` have
+undefined behavior. Checking that ``ARGC`` is greater than ``#`` is
+the only way to ensure that ``ARGV#`` was passed to the function as an
+extra argument.
diff --git a/Help/command/get_cmake_property.rst b/Help/command/get_cmake_property.rst
index 497ab4eeb..96764a3b9 100644
--- a/Help/command/get_cmake_property.rst
+++ b/Help/command/get_cmake_property.rst
@@ -3,14 +3,14 @@ get_cmake_property
Get a global property of the CMake instance.
-::
+.. code-block:: cmake
- get_cmake_property(VAR property)
+ get_cmake_property(<var> <property>)
-Get a global property from the CMake instance. The value of the property is
-stored in the variable ``VAR``. If the property is not found, ``VAR``
-will be set to "NOTFOUND". See the :manual:`cmake-properties(7)` manual
-for available properties.
+Gets a global property from the CMake instance. The value of
+the ``<property>`` is stored in the variable ``<var>``.
+If the property is not found, ``<var>`` will be set to ``NOTFOUND``.
+See the :manual:`cmake-properties(7)` manual for available properties.
See also the :command:`get_property` command ``GLOBAL`` option.
diff --git a/Help/command/get_directory_property.rst b/Help/command/get_directory_property.rst
index e50abe0e9..218efa9d3 100644
--- a/Help/command/get_directory_property.rst
+++ b/Help/command/get_directory_property.rst
@@ -3,17 +3,22 @@ get_directory_property
Get a property of ``DIRECTORY`` scope.
-::
+.. code-block:: cmake
get_directory_property(<variable> [DIRECTORY <dir>] <prop-name>)
-Store a property of directory scope in the named variable. If the
-property is not defined the empty-string is returned. The ``DIRECTORY``
-argument specifies another directory from which to retrieve the
-property value. The specified directory must have already been
-traversed by CMake.
+Stores a property of directory scope in the named ``<variable>``.
+The ``DIRECTORY`` argument specifies another directory from which
+to retrieve the property value instead of the current directory.
+The specified directory must have already been traversed by CMake.
-::
+If the property is not defined for the nominated directory scope,
+an empty string is returned. In the case of ``INHERITED`` properties,
+if the property is not found for the nominated directory scope,
+the search will chain to a parent scope as described for the
+:command:`define_property` command.
+
+.. code-block:: cmake
get_directory_property(<variable> [DIRECTORY <dir>]
DEFINITION <var-name>)
diff --git a/Help/command/get_filename_component.rst b/Help/command/get_filename_component.rst
index 14c8cf279..9bbf87714 100644
--- a/Help/command/get_filename_component.rst
+++ b/Help/command/get_filename_component.rst
@@ -3,13 +3,11 @@ get_filename_component
Get a specific component of a full filename.
-------------------------------------------------------------------------------
+.. code-block:: cmake
-::
-
- get_filename_component(<VAR> <FileName> <COMP> [CACHE])
+ get_filename_component(<var> <FileName> <mode> [CACHE])
-Set ``<VAR>`` to a component of ``<FileName>``, where ``<COMP>`` is one of:
+Sets ``<var>`` to a component of ``<FileName>``, where ``<mode>`` is one of:
::
@@ -17,22 +15,19 @@ Set ``<VAR>`` to a component of ``<FileName>``, where ``<COMP>`` is one of:
NAME = File name without directory
EXT = File name longest extension (.b.c from d/a.b.c)
NAME_WE = File name without directory or longest extension
+ LAST_EXT = File name last extension (.c from d/a.b.c)
+ NAME_WLE = File name without directory or last extension
PATH = Legacy alias for DIRECTORY (use for CMake <= 2.8.11)
Paths are returned with forward slashes and have no trailing slashes.
-The longest file extension is always considered. If the optional
-``CACHE`` argument is specified, the result variable is added to the
-cache.
+If the optional ``CACHE`` argument is specified, the result variable is
+added to the cache.
-------------------------------------------------------------------------------
+.. code-block:: cmake
-::
+ get_filename_component(<var> <FileName> <mode> [BASE_DIR <dir>] [CACHE])
- get_filename_component(<VAR> <FileName>
- <COMP> [BASE_DIR <BASE_DIR>]
- [CACHE])
-
-Set ``<VAR>`` to the absolute path of ``<FileName>``, where ``<COMP>`` is one
+Sets ``<var>`` to the absolute path of ``<FileName>``, where ``<mode>`` is one
of:
::
@@ -41,24 +36,20 @@ of:
REALPATH = Full path to existing file with symlinks resolved
If the provided ``<FileName>`` is a relative path, it is evaluated relative
-to the given base directory ``<BASE_DIR>``. If no base directory is
+to the given base directory ``<dir>``. If no base directory is
provided, the default base directory will be
:variable:`CMAKE_CURRENT_SOURCE_DIR`.
-Paths are returned with forward slashes and have no trailing slahes. If the
+Paths are returned with forward slashes and have no trailing slashes. If the
optional ``CACHE`` argument is specified, the result variable is added to the
cache.
-------------------------------------------------------------------------------
-
-::
+.. code-block:: cmake
- get_filename_component(<VAR> <FileName>
- PROGRAM [PROGRAM_ARGS <ARG_VAR>]
- [CACHE])
+ get_filename_component(<var> <FileName> PROGRAM [PROGRAM_ARGS <arg_var>] [CACHE])
The program in ``<FileName>`` will be found in the system search path or
left as a full path. If ``PROGRAM_ARGS`` is present with ``PROGRAM``, then
any command-line arguments present in the ``<FileName>`` string are split
-from the program name and stored in ``<ARG_VAR>``. This is used to
+from the program name and stored in ``<arg_var>``. This is used to
separate a program name from its arguments in a command line string.
diff --git a/Help/command/get_property.rst b/Help/command/get_property.rst
index 632ece65c..c0f9b460a 100644
--- a/Help/command/get_property.rst
+++ b/Help/command/get_property.rst
@@ -3,32 +3,33 @@ get_property
Get a property.
-::
+.. code-block:: cmake
get_property(<variable>
<GLOBAL |
- DIRECTORY [dir] |
+ DIRECTORY [<dir>] |
TARGET <target> |
SOURCE <source> |
INSTALL <file> |
TEST <test> |
CACHE <entry> |
- VARIABLE>
+ VARIABLE >
PROPERTY <name>
[SET | DEFINED | BRIEF_DOCS | FULL_DOCS])
-Get one property from one object in a scope. The first argument
-specifies the variable in which to store the result. The second
-argument determines the scope from which to get the property. It must
-be one of the following:
+Gets one property from one object in a scope.
+
+The first argument specifies the variable in which to store the result.
+The second argument determines the scope from which to get the property.
+It must be one of the following:
``GLOBAL``
Scope is unique and does not accept a name.
``DIRECTORY``
Scope defaults to the current directory but another
- directory (already processed by CMake) may be named by full or
- relative path.
+ directory (already processed by CMake) may be named by the
+ full or relative path ``<dir>``.
``TARGET``
Scope must name one existing target.
@@ -50,11 +51,15 @@ be one of the following:
The required ``PROPERTY`` option is immediately followed by the name of
the property to get. If the property is not set an empty value is
-returned. If the ``SET`` option is given the variable is set to a boolean
+returned, although some properties support inheriting from a parent scope
+if defined to behave that way (see :command:`define_property`).
+
+If the ``SET`` option is given the variable is set to a boolean
value indicating whether the property has been set. If the ``DEFINED``
option is given the variable is set to a boolean value indicating
whether the property has been defined such as with the
:command:`define_property` command.
+
If ``BRIEF_DOCS`` or ``FULL_DOCS`` is given then the variable is set to a
string containing documentation for the requested property. If
documentation is requested for a property that has not been defined
diff --git a/Help/command/get_source_file_property.rst b/Help/command/get_source_file_property.rst
index 3e975c2f9..decec1916 100644
--- a/Help/command/get_source_file_property.rst
+++ b/Help/command/get_source_file_property.rst
@@ -3,14 +3,20 @@ get_source_file_property
Get a property for a source file.
-::
+.. code-block:: cmake
get_source_file_property(VAR file property)
-Get a property from a source file. The value of the property is
-stored in the variable ``VAR``. If the property is not found, ``VAR``
-will be set to "NOTFOUND". Use :command:`set_source_files_properties`
-to set property values. Source file properties usually control how the
-file is built. One property that is always there is :prop_sf:`LOCATION`
+Gets a property from a source file. The value of the property is
+stored in the variable ``VAR``. If the source property is not found, the
+behavior depends on whether it has been defined to be an ``INHERITED`` property
+or not (see :command:`define_property`). Non-inherited properties will set
+``VAR`` to "NOTFOUND", whereas inherited properties will search the relevant
+parent scope as described for the :command:`define_property` command and
+if still unable to find the property, ``VAR`` will be set to an empty string.
+
+Use :command:`set_source_files_properties` to set property values. Source
+file properties usually control how the file is built. One property that is
+always there is :prop_sf:`LOCATION`.
See also the more general :command:`get_property` command.
diff --git a/Help/command/get_target_property.rst b/Help/command/get_target_property.rst
index 2a72c3af7..11e07eabe 100644
--- a/Help/command/get_target_property.rst
+++ b/Help/command/get_target_property.rst
@@ -3,16 +3,25 @@ get_target_property
Get a property from a target.
-::
+.. code-block:: cmake
get_target_property(VAR target property)
Get a property from a target. The value of the property is stored in
-the variable ``VAR``. If the property is not found, ``VAR`` will be set to
-"NOTFOUND". Use :command:`set_target_properties` to set property values.
+the variable ``VAR``. If the target property is not found, the behavior
+depends on whether it has been defined to be an ``INHERITED`` property
+or not (see :command:`define_property`). Non-inherited properties will
+set ``VAR`` to ``NOTFOUND``, whereas inherited properties will search the
+relevant parent scope as described for the :command:`define_property`
+command and if still unable to find the property, ``VAR`` will be set to
+an empty string.
+
+Use :command:`set_target_properties` to set target property values.
Properties are usually used to control how a target is built, but some
query the target instead. This command can get properties for any
target so far created. The targets do not need to be in the current
``CMakeLists.txt`` file.
See also the more general :command:`get_property` command.
+
+See :ref:`Target Properties` for the list of properties known to CMake.
diff --git a/Help/command/get_test_property.rst b/Help/command/get_test_property.rst
index e359f4b3d..e02b9bc77 100644
--- a/Help/command/get_test_property.rst
+++ b/Help/command/get_test_property.rst
@@ -3,13 +3,19 @@ get_test_property
Get a property of the test.
-::
+.. code-block:: cmake
get_test_property(test property VAR)
Get a property from the test. The value of the property is stored in
-the variable ``VAR``. If the test or property is not found, ``VAR`` will
-be set to "NOTFOUND". For a list of standard properties you can type
-``cmake --help-property-list``.
+the variable ``VAR``. If the test property is not found, the behavior
+depends on whether it has been defined to be an ``INHERITED`` property
+or not (see :command:`define_property`). Non-inherited properties will
+set ``VAR`` to "NOTFOUND", whereas inherited properties will search the
+relevant parent scope as described for the :command:`define_property`
+command and if still unable to find the property, ``VAR`` will be set to
+an empty string.
+
+For a list of standard properties you can type ``cmake --help-property-list``.
See also the more general :command:`get_property` command.
diff --git a/Help/command/if.rst b/Help/command/if.rst
index edd343de2..be992df15 100644
--- a/Help/command/if.rst
+++ b/Help/command/if.rst
@@ -3,41 +3,51 @@ if
Conditionally execute a group of commands.
+Synopsis
+^^^^^^^^
+
.. code-block:: cmake
- if(expression)
- # then section.
- COMMAND1(ARGS ...)
- COMMAND2(ARGS ...)
- #...
- elseif(expression2)
- # elseif section.
- COMMAND1(ARGS ...)
- COMMAND2(ARGS ...)
- #...
- else(expression)
- # else section.
- COMMAND1(ARGS ...)
- COMMAND2(ARGS ...)
- #...
- endif(expression)
-
-Evaluates the given expression. If the result is true, the commands
-in the THEN section are invoked. Otherwise, the commands in the else
-section are invoked. The elseif and else sections are optional. You
-may have multiple elseif clauses. Note that the expression in the
-else and endif clause is optional. Long expressions can be used and
-there is a traditional order of precedence. Parenthetical expressions
-are evaluated first followed by unary tests such as ``EXISTS``,
-``COMMAND``, and ``DEFINED``. Then any binary tests such as
-``EQUAL``, ``LESS``, ``LESS_EQUAL, ``GREATER``, ``GREATER_EQUAL``,
+ if(<condition>)
+ <commands>
+ elseif(<condition>) # optional block, can be repeated
+ <commands>
+ else() # optional block
+ <commands>
+ endif()
+
+Evaluates the ``condition`` argument of the ``if`` clause according to the
+`Condition syntax`_ described below. If the result is true, then the
+``commands`` in the ``if`` block are executed.
+Otherwise, optional ``elseif`` blocks are processed in the same way.
+Finally, if no ``condition`` is true, ``commands`` in the optional ``else``
+block are executed.
+
+Per legacy, the :command:`else` and :command:`endif` commands admit
+an optional ``<condition>`` argument.
+If used, it must be a verbatim
+repeat of the argument of the opening
+``if`` command.
+
+.. _`Condition Syntax`:
+
+Condition Syntax
+^^^^^^^^^^^^^^^^
+
+The following syntax applies to the ``condition`` argument of
+the ``if``, ``elseif`` and :command:`while` clauses.
+
+Compound conditions are evaluated in the following order of precedence:
+Innermost parentheses are evaluated first. Next come unary tests such
+as ``EXISTS``, ``COMMAND``, and ``DEFINED``. Then binary tests such as
+``EQUAL``, ``LESS``, ``LESS_EQUAL``, ``GREATER``, ``GREATER_EQUAL``,
``STREQUAL``, ``STRLESS``, ``STRLESS_EQUAL``, ``STRGREATER``,
``STRGREATER_EQUAL``, ``VERSION_EQUAL``, ``VERSION_LESS``,
``VERSION_LESS_EQUAL``, ``VERSION_GREATER``, ``VERSION_GREATER_EQUAL``,
-and ``MATCHES`` will be evaluated. Then boolean ``NOT`` operators and
-finally boolean ``AND`` and then ``OR`` operators will be evaluated.
+and ``MATCHES``. Then the boolean operators in the order ``NOT``, ``AND``,
+and finally ``OR``.
-Possible expressions are:
+Possible conditions are:
``if(<constant>)``
True if the constant is ``1``, ``ON``, ``YES``, ``TRUE``, ``Y``,
@@ -52,14 +62,14 @@ Possible expressions are:
True if given a variable that is defined to a value that is not a false
constant. False otherwise. (Note macro arguments are not variables.)
-``if(NOT <expression>)``
- True if the expression is not true.
+``if(NOT <condition>)``
+ True if the condition is not true.
-``if(<expr1> AND <expr2>)``
- True if both expressions would be considered true individually.
+``if(<cond1> AND <cond2>)``
+ True if both conditions would be considered true individually.
-``if(<expr1> OR <expr2>)``
- True if either expression would be considered true individually.
+``if(<cond1> OR <cond2>)``
+ True if either condition would be considered true individually.
``if(COMMAND command-name)``
True if the given name is a command, macro or function that can be
@@ -80,7 +90,9 @@ Possible expressions are:
``if(EXISTS path-to-file-or-directory)``
True if the named file or directory exists. Behavior is well-defined
- only for full paths.
+ only for full paths. Resolves symbolic links, i.e. if the named file or
+ directory is a symbolic link, returns true if the target of the
+ symbolic link exists.
``if(file1 IS_NEWER_THAN file2)``
True if ``file1`` is newer than ``file2`` or if one of the two files doesn't
@@ -103,7 +115,7 @@ Possible expressions are:
``if(<variable|string> MATCHES regex)``
True if the given string or variable's value matches the given regular
- expression. See :ref:`Regex Specification` for regex format.
+ condition. See :ref:`Regex Specification` for regex format.
``()`` groups are captured in :variable:`CMAKE_MATCH_<n>` variables.
``if(<variable|string> LESS <variable|string>)``
@@ -148,63 +160,82 @@ Possible expressions are:
``if(<variable|string> VERSION_LESS <variable|string>)``
Component-wise integer version number comparison (version format is
- ``major[.minor[.patch[.tweak]]]``).
+ ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
+ Any non-integer version component or non-integer trailing part of a version
+ component effectively truncates the string at that point.
``if(<variable|string> VERSION_GREATER <variable|string>)``
Component-wise integer version number comparison (version format is
- ``major[.minor[.patch[.tweak]]]``).
+ ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
+ Any non-integer version component or non-integer trailing part of a version
+ component effectively truncates the string at that point.
``if(<variable|string> VERSION_EQUAL <variable|string>)``
Component-wise integer version number comparison (version format is
- ``major[.minor[.patch[.tweak]]]``).
+ ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
+ Any non-integer version component or non-integer trailing part of a version
+ component effectively truncates the string at that point.
``if(<variable|string> VERSION_LESS_EQUAL <variable|string>)``
Component-wise integer version number comparison (version format is
- ``major[.minor[.patch[.tweak]]]``).
+ ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
+ Any non-integer version component or non-integer trailing part of a version
+ component effectively truncates the string at that point.
``if(<variable|string> VERSION_GREATER_EQUAL <variable|string>)``
Component-wise integer version number comparison (version format is
- ``major[.minor[.patch[.tweak]]]``).
+ ``major[.minor[.patch[.tweak]]]``, omitted components are treated as zero).
+ Any non-integer version component or non-integer trailing part of a version
+ component effectively truncates the string at that point.
``if(<variable|string> IN_LIST <variable>)``
True if the given element is contained in the named list variable.
-``if(DEFINED <variable>)``
- True if the given variable is defined. It does not matter if the
- variable is true or false just if it has been set. (Note macro
- arguments are not variables.)
+``if(DEFINED <name>|CACHE{<name>}|ENV{<name>})``
+ True if a variable, cache variable or environment variable
+ with given ``<name>`` is defined. The value of the variable
+ does not matter. Note that macro arguments are not variables.
-``if((expression) AND (expression OR (expression)))``
- The expressions inside the parenthesis are evaluated first and then
- the remaining expression is evaluated as in the previous examples.
+``if((condition) AND (condition OR (condition)))``
+ The conditions inside the parenthesis are evaluated first and then
+ the remaining condition is evaluated as in the previous examples.
Where there are nested parenthesis the innermost are evaluated as part
- of evaluating the expression that contains them.
+ of evaluating the condition that contains them.
+
+Variable Expansion
+^^^^^^^^^^^^^^^^^^
The if command was written very early in CMake's history, predating
the ``${}`` variable evaluation syntax, and for convenience evaluates
variables named by its arguments as shown in the above signatures.
Note that normal variable evaluation with ``${}`` applies before the if
-command even receives the arguments. Therefore code like::
+command even receives the arguments. Therefore code like
+
+.. code-block:: cmake
set(var1 OFF)
set(var2 "var1")
if(${var2})
-appears to the if command as::
+appears to the if command as
- if(var1)
+.. code-block:: cmake
+
+ if(var1)
and is evaluated according to the ``if(<variable>)`` case documented
above. The result is ``OFF`` which is false. However, if we remove the
-``${}`` from the example then the command sees::
+``${}`` from the example then the command sees
- if(var2)
+.. code-block:: cmake
-which is true because ``var2`` is defined to "var1" which is not a false
+ if(var2)
+
+which is true because ``var2`` is defined to ``var1`` which is not a false
constant.
Automatic evaluation applies in the other cases whenever the
-above-documented signature accepts ``<variable|string>``:
+above-documented condition syntax accepts ``<variable|string>``:
* The left hand argument to ``MATCHES`` is first checked to see if it is
a defined variable, if so the variable's value is used, otherwise the
@@ -242,3 +273,8 @@ specified in a :ref:`Quoted Argument` or a :ref:`Bracket Argument`.
A quoted or bracketed variable or keyword will be interpreted as a
string and not dereferenced or interpreted.
See policy :policy:`CMP0054`.
+
+There is no automatic evaluation for environment or cache
+:ref:`Variable References`. Their values must be referenced as
+``$ENV{<name>}`` or ``$CACHE{<name>}`` wherever the above-documented
+condition syntax accepts ``<variable|string>``.
diff --git a/Help/command/include.rst b/Help/command/include.rst
index eeca4c6e3..80968da7b 100644
--- a/Help/command/include.rst
+++ b/Help/command/include.rst
@@ -3,16 +3,16 @@ include
Load and run CMake code from a file or module.
-::
+.. code-block:: cmake
- include(<file|module> [OPTIONAL] [RESULT_VARIABLE <VAR>]
+ include(<file|module> [OPTIONAL] [RESULT_VARIABLE <var>]
[NO_POLICY_SCOPE])
-Load and run CMake code from the file given. Variable reads and
+Loads and runs CMake code from the file given. Variable reads and
writes access the scope of the caller (dynamic scoping). If ``OPTIONAL``
is present, then no error is raised if the file does not exist. If
-``RESULT_VARIABLE`` is given the variable will be set to the full filename
-which has been included or NOTFOUND if it failed.
+``RESULT_VARIABLE`` is given the variable ``<var>`` will be set to the
+full filename which has been included or ``NOTFOUND`` if it failed.
If a module is specified instead of a file, the file with name
``<modulename>.cmake`` is searched first in :variable:`CMAKE_MODULE_PATH`,
diff --git a/Help/command/include_directories.rst b/Help/command/include_directories.rst
index f69493460..fe281c3c8 100644
--- a/Help/command/include_directories.rst
+++ b/Help/command/include_directories.rst
@@ -3,7 +3,7 @@ include_directories
Add include directories to the build.
-::
+.. code-block:: cmake
include_directories([AFTER|BEFORE] [SYSTEM] dir1 [dir2 ...])
@@ -33,3 +33,9 @@ Arguments to ``include_directories`` may use "generator expressions" with
the syntax "$<...>". See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
+
+.. note::
+
+ Prefer the :command:`target_include_directories` command to add include
+ directories to individual targets and optionally propagate/export them
+ to dependents.
diff --git a/Help/command/include_external_msproject.rst b/Help/command/include_external_msproject.rst
index 335282a30..540a13af8 100644
--- a/Help/command/include_external_msproject.rst
+++ b/Help/command/include_external_msproject.rst
@@ -3,7 +3,7 @@ include_external_msproject
Include an external Microsoft project file in a workspace.
-::
+.. code-block:: cmake
include_external_msproject(projectname location
[TYPE projectTypeGUID]
@@ -13,11 +13,11 @@ Include an external Microsoft project file in a workspace.
Includes an external Microsoft project in the generated workspace
file. Currently does nothing on UNIX. This will create a target
-named [projectname]. This can be used in the :command:`add_dependencies`
+named ``[projectname]``. This can be used in the :command:`add_dependencies`
command to make things depend on the external project.
``TYPE``, ``GUID`` and ``PLATFORM`` are optional parameters that allow one to
-specify the type of project, id (GUID) of the project and the name of
+specify the type of project, id (``GUID``) of the project and the name of
the target platform. This is useful for projects requiring values
other than the default (e.g. WIX projects).
diff --git a/Help/command/include_guard.rst b/Help/command/include_guard.rst
new file mode 100644
index 000000000..877aa86d9
--- /dev/null
+++ b/Help/command/include_guard.rst
@@ -0,0 +1,46 @@
+include_guard
+-------------
+
+Provides an include guard for the file currently being processed by CMake.
+
+.. code-block:: cmake
+
+ include_guard([DIRECTORY|GLOBAL])
+
+Sets up an include guard for the current CMake file (see the
+:variable:`CMAKE_CURRENT_LIST_FILE` variable documentation).
+
+CMake will end its processing of the current file at the location of the
+:command:`include_guard` command if the current file has already been
+processed for the applicable scope (see below). This provides functionality
+similar to the include guards commonly used in source headers or to the
+``#pragma once`` directive. If the current file has been processed previously
+for the applicable scope, the effect is as though :command:`return` had been
+called. Do not call this command from inside a function being defined within
+the current file.
+
+An optional argument specifying the scope of the guard may be provided.
+Possible values for the option are:
+
+``DIRECTORY``
+ The include guard applies within the current directory and below. The file
+ will only be included once within this directory scope, but may be included
+ again by other files outside of this directory (i.e. a parent directory or
+ another directory not pulled in by :command:`add_subdirectory` or
+ :command:`include` from the current file or its children).
+
+``GLOBAL``
+ The include guard applies globally to the whole build. The current file
+ will only be included once regardless of the scope.
+
+If no arguments given, ``include_guard`` has the same scope as a variable,
+meaning that the include guard effect is isolated by the most recent
+function scope or current directory if no inner function scopes exist.
+In this case the command behavior is the same as:
+
+.. code-block:: cmake
+
+ if(__CURRENT_FILE_VAR__)
+ return()
+ endif()
+ set(__CURRENT_FILE_VAR__ TRUE)
diff --git a/Help/command/include_regular_expression.rst b/Help/command/include_regular_expression.rst
index ab5a56325..dde837892 100644
--- a/Help/command/include_regular_expression.rst
+++ b/Help/command/include_regular_expression.rst
@@ -3,11 +3,11 @@ include_regular_expression
Set the regular expression used for dependency checking.
-::
+.. code-block:: cmake
include_regular_expression(regex_match [regex_complain])
-Set the regular expressions used in dependency checking. Only files
+Sets the regular expressions used in dependency checking. Only files
matching ``regex_match`` will be traced as dependencies. Only files
matching ``regex_complain`` will generate warnings if they cannot be found
(standard header paths are not searched). The defaults are:
diff --git a/Help/command/install.rst b/Help/command/install.rst
index 58438b763..5affc5b99 100644
--- a/Help/command/install.rst
+++ b/Help/command/install.rst
@@ -1,11 +1,19 @@
install
-------
-.. only:: html
+Specify rules to run at install time.
- .. contents::
+Synopsis
+^^^^^^^^
-Specify rules to run at install time.
+.. parsed-literal::
+
+ install(`TARGETS`_ <target>... [...])
+ install({`FILES`_ | `PROGRAMS`_} <file>... [...])
+ install(`DIRECTORY`_ <dir>... [...])
+ install(`SCRIPT`_ <file> [...])
+ install(`CODE`_ <code> [...])
+ install(`EXPORT`_ <export-name> [...])
Introduction
^^^^^^^^^^^^
@@ -38,7 +46,21 @@ signatures that specify them. The common options are:
``CONFIGURATIONS``
Specify a list of build configurations for which the install rule
- applies (Debug, Release, etc.).
+ applies (Debug, Release, etc.). Note that the values specified for
+ this option only apply to options listed AFTER the ``CONFIGURATIONS``
+ option. For example, to set separate install paths for the Debug and
+ Release configurations, do the following:
+
+ .. code-block:: cmake
+
+ install(TARGETS target
+ CONFIGURATIONS Debug
+ RUNTIME DESTINATION Debug/bin)
+ install(TARGETS target
+ CONFIGURATIONS Release
+ RUNTIME DESTINATION Release/bin)
+
+ Note that ``CONFIGURATIONS`` appears BEFORE ``RUNTIME DESTINATION``.
``COMPONENT``
Specify an installation component name with which the install rule
@@ -67,10 +89,20 @@ Command signatures that install files may print messages during
installation. Use the :variable:`CMAKE_INSTALL_MESSAGE` variable
to control which messages are printed.
+Many of the ``install()`` variants implicitly create the directories
+containing the installed files. If
+:variable:`CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS` is set, these
+directories will be created with the permissions specified. Otherwise,
+they will be created according to the uname rules on Unix-like platforms.
+Windows platforms are unaffected.
+
Installing Targets
^^^^^^^^^^^^^^^^^^
-::
+.. _`install(TARGETS)`:
+.. _TARGETS:
+
+.. code-block:: cmake
install(TARGETS targets... [EXPORT <export-name>]
[[ARCHIVE|LIBRARY|RUNTIME|OBJECTS|FRAMEWORK|BUNDLE|
@@ -79,6 +111,7 @@ Installing Targets
[PERMISSIONS permissions...]
[CONFIGURATIONS [Debug|Release|...]]
[COMPONENT <component>]
+ [NAMELINK_COMPONENT <component>]
[OPTIONAL] [EXCLUDE_FROM_ALL]
[NAMELINK_ONLY|NAMELINK_SKIP]
] [...]
@@ -86,63 +119,194 @@ Installing Targets
)
The ``TARGETS`` form specifies rules for installing targets from a
-project. There are six kinds of target files that may be installed:
-``ARCHIVE``, ``LIBRARY``, ``RUNTIME``, ``OBJECTS``, ``FRAMEWORK``, and
-``BUNDLE``. Executables are treated as ``RUNTIME`` targets, except that
-those marked with the ``MACOSX_BUNDLE`` property are treated as ``BUNDLE``
-targets on OS X. Static libraries are treated as ``ARCHIVE`` targets,
-except that those marked with the ``FRAMEWORK`` property are treated
-as ``FRAMEWORK`` targets on OS X.
-Module libraries are always treated as ``LIBRARY`` targets.
-For non-DLL platforms shared libraries are treated as ``LIBRARY``
-targets, except that those marked with the ``FRAMEWORK`` property are
-treated as ``FRAMEWORK`` targets on OS X. For DLL platforms the DLL
-part of a shared library is treated as a ``RUNTIME`` target and the
-corresponding import library is treated as an ``ARCHIVE`` target.
-All Windows-based systems including Cygwin are DLL platforms. Object
-libraries are always treated as ``OBJECTS`` targets.
-The ``ARCHIVE``, ``LIBRARY``, ``RUNTIME``, ``OBJECTS``, and ``FRAMEWORK``
-arguments change the type of target to which the subsequent properties
-apply. If none is given the installation properties apply to all target
-types. If only one is given then only targets of that type will be
-installed (which can be used to install just a DLL or just an import
-library).
-
-The ``PRIVATE_HEADER``, ``PUBLIC_HEADER``, and ``RESOURCE`` arguments
-cause subsequent properties to be applied to installing a ``FRAMEWORK``
-shared library target's associated files on non-Apple platforms. Rules
-defined by these arguments are ignored on Apple platforms because the
-associated files are installed into the appropriate locations inside
-the framework folder. See documentation of the
-:prop_tgt:`PRIVATE_HEADER`, :prop_tgt:`PUBLIC_HEADER`, and
-:prop_tgt:`RESOURCE` target properties for details.
-
-Either ``NAMELINK_ONLY`` or ``NAMELINK_SKIP`` may be specified as a
-``LIBRARY`` option. On some platforms a versioned shared library
-has a symbolic link such as::
-
- lib<name>.so -> lib<name>.so.1
-
-where ``lib<name>.so.1`` is the soname of the library and ``lib<name>.so``
-is a "namelink" allowing linkers to find the library when given
-``-l<name>``. The ``NAMELINK_ONLY`` option causes installation of only the
-namelink when a library target is installed. The ``NAMELINK_SKIP`` option
-causes installation of library files other than the namelink when a
-library target is installed. When neither option is given both
-portions are installed. On platforms where versioned shared libraries
-do not have namelinks or when a library is not versioned the
-``NAMELINK_SKIP`` option installs the library and the ``NAMELINK_ONLY``
-option installs nothing. See the :prop_tgt:`VERSION` and
-:prop_tgt:`SOVERSION` target properties for details on creating versioned
-shared libraries.
-
-The ``INCLUDES DESTINATION`` specifies a list of directories
-which will be added to the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES`
-target property of the ``<targets>`` when exported by the
-:command:`install(EXPORT)` command. If a relative path is
-specified, it is treated as relative to the ``$<INSTALL_PREFIX>``.
-This is independent of the rest of the argument groups and does
-not actually install anything.
+project. There are several kinds of target files that may be installed:
+
+``ARCHIVE``
+ Static libraries are treated as ``ARCHIVE`` targets, except those
+ marked with the ``FRAMEWORK`` property on macOS (see ``FRAMEWORK``
+ below.) For DLL platforms (all Windows-based systems including
+ Cygwin), the DLL import library is treated as an ``ARCHIVE`` target.
+ On AIX, the linker import file created for executables with
+ :prop_tgt:`ENABLE_EXPORTS` is treated as an ``ARCHIVE`` target.
+
+``LIBRARY``
+ Module libraries are always treated as ``LIBRARY`` targets. For non-
+ DLL platforms shared libraries are treated as ``LIBRARY`` targets,
+ except those marked with the ``FRAMEWORK`` property on macOS (see
+ ``FRAMEWORK`` below.)
+
+``RUNTIME``
+ Executables are treated as ``RUNTIME`` objects, except those marked
+ with the ``MACOSX_BUNDLE`` property on macOS (see ``BUNDLE`` below.)
+ For DLL platforms (all Windows-based systems including Cygwin), the
+ DLL part of a shared library is treated as a ``RUNTIME`` target.
+
+``OBJECTS``
+ Object libraries (a simple group of object files) are always treated
+ as ``OBJECTS`` targets.
+
+``FRAMEWORK``
+ Both static and shared libraries marked with the ``FRAMEWORK``
+ property are treated as ``FRAMEWORK`` targets on macOS.
+
+``BUNDLE``
+ Executables marked with the :prop_tgt:`MACOSX_BUNDLE` property are treated as
+ ``BUNDLE`` targets on macOS.
+
+``PUBLIC_HEADER``
+ Any :prop_tgt:`PUBLIC_HEADER` files associated with a library are installed in
+ the destination specified by the ``PUBLIC_HEADER`` argument on non-Apple
+ platforms. Rules defined by this argument are ignored for :prop_tgt:`FRAMEWORK`
+ libraries on Apple platforms because the associated files are installed
+ into the appropriate locations inside the framework folder. See
+ :prop_tgt:`PUBLIC_HEADER` for details.
+
+``PRIVATE_HEADER``
+ Similar to ``PUBLIC_HEADER``, but for ``PRIVATE_HEADER`` files. See
+ :prop_tgt:`PRIVATE_HEADER` for details.
+
+``RESOURCE``
+ Similar to ``PUBLIC_HEADER`` and ``PRIVATE_HEADER``, but for
+ ``RESOURCE`` files. See :prop_tgt:`RESOURCE` for details.
+
+For each of these arguments given, the arguments following them only apply
+to the target or file type specified in the argument. If none is given, the
+installation properties apply to all target types. If only one is given then
+only targets of that type will be installed (which can be used to install
+just a DLL or just an import library.)
+
+For regular executables, static libraries and shared libraries, the
+``DESTINATION`` argument is not required. For these target types, when
+``DESTINATION`` is omitted, a default destination will be taken from the
+appropriate variable from :module:`GNUInstallDirs`, or set to a built-in
+default value if that variable is not defined. The same is true for the
+public and private headers associated with the installed targets through the
+:prop_tgt:`PUBLIC_HEADER` and :prop_tgt:`PRIVATE_HEADER` target properties.
+A destination must always be provided for module libraries, Apple bundles and
+frameworks. A destination can be omitted for interface and object libraries,
+but they are handled differently (see the discussion of this topic toward the
+end of this section).
+
+The following table shows the target types with their associated variables and
+built-in defaults that apply when no destination is given:
+
+================== =============================== ======================
+ Target Type GNUInstallDirs Variable Built-In Default
+================== =============================== ======================
+``RUNTIME`` ``${CMAKE_INSTALL_BINDIR}`` ``bin``
+``LIBRARY`` ``${CMAKE_INSTALL_LIBDIR}`` ``lib``
+``ARCHIVE`` ``${CMAKE_INSTALL_LIBDIR}`` ``lib``
+``PRIVATE_HEADER`` ``${CMAKE_INSTALL_INCLUDEDIR}`` ``include``
+``PUBLIC_HEADER`` ``${CMAKE_INSTALL_INCLUDEDIR}`` ``include``
+================== =============================== ======================
+
+Projects wishing to follow the common practice of installing headers into a
+project-specific subdirectory will need to provide a destination rather than
+rely on the above.
+
+To make packages compliant with distribution filesystem layout policies, if
+projects must specify a ``DESTINATION``, it is recommended that they use a
+path that begins with the appropriate :module:`GNUInstallDirs` variable.
+This allows package maintainers to control the install destination by setting
+the appropriate cache variables. The following example shows a static library
+being installed to the default destination provided by
+:module:`GNUInstallDirs`, but with its headers installed to a project-specific
+subdirectory that follows the above recommendation:
+
+.. code-block:: cmake
+
+ add_library(mylib STATIC ...)
+ set_target_properties(mylib PROPERTIES PUBLIC_HEADER mylib.h)
+ include(GNUInstallDirs)
+ install(TARGETS mylib
+ PUBLIC_HEADER
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/myproj
+ )
+
+In addition to the common options listed above, each target can accept
+the following additional arguments:
+
+``NAMELINK_COMPONENT``
+ On some platforms a versioned shared library has a symbolic link such
+ as::
+
+ lib<name>.so -> lib<name>.so.1
+
+ where ``lib<name>.so.1`` is the soname of the library and ``lib<name>.so``
+ is a "namelink" allowing linkers to find the library when given
+ ``-l<name>``. The ``NAMELINK_COMPONENT`` option is similar to the
+ ``COMPONENT`` option, but it changes the installation component of a shared
+ library namelink if one is generated. If not specified, this defaults to the
+ value of ``COMPONENT``. It is an error to use this parameter outside of a
+ ``LIBRARY`` block.
+
+ Consider the following example:
+
+ .. code-block:: cmake
+
+ install(TARGETS mylib
+ LIBRARY
+ COMPONENT Libraries
+ NAMELINK_COMPONENT Development
+ PUBLIC_HEADER
+ COMPONENT Development
+ )
+
+ In this scenario, if you choose to install only the ``Development``
+ component, both the headers and namelink will be installed without the
+ library. (If you don't also install the ``Libraries`` component, the
+ namelink will be a dangling symlink, and projects that link to the library
+ will have build errors.) If you install only the ``Libraries`` component,
+ only the library will be installed, without the headers and namelink.
+
+ This option is typically used for package managers that have separate
+ runtime and development packages. For example, on Debian systems, the
+ library is expected to be in the runtime package, and the headers and
+ namelink are expected to be in the development package.
+
+ See the :prop_tgt:`VERSION` and :prop_tgt:`SOVERSION` target properties for
+ details on creating versioned shared libraries.
+
+``NAMELINK_ONLY``
+ This option causes the installation of only the namelink when a library
+ target is installed. On platforms where versioned shared libraries do not
+ have namelinks or when a library is not versioned, the ``NAMELINK_ONLY``
+ option installs nothing. It is an error to use this parameter outside of a
+ ``LIBRARY`` block.
+
+ When ``NAMELINK_ONLY`` is given, either ``NAMELINK_COMPONENT`` or
+ ``COMPONENT`` may be used to specify the installation component of the
+ namelink, but ``COMPONENT`` should generally be preferred.
+
+``NAMELINK_SKIP``
+ Similar to ``NAMELINK_ONLY``, but it has the opposite effect: it causes the
+ installation of library files other than the namelink when a library target
+ is installed. When neither ``NAMELINK_ONLY`` or ``NAMELINK_SKIP`` are given,
+ both portions are installed. On platforms where versioned shared libraries
+ do not have symlinks or when a library is not versioned, ``NAMELINK_SKIP``
+ installs the library. It is an error to use this parameter outside of a
+ ``LIBRARY`` block.
+
+ If ``NAMELINK_SKIP`` is specified, ``NAMELINK_COMPONENT`` has no effect. It
+ is not recommended to use ``NAMELINK_SKIP`` in conjunction with
+ ``NAMELINK_COMPONENT``.
+
+The `install(TARGETS)`_ command can also accept the following options at the
+top level:
+
+``EXPORT``
+ This option associates the installed target files with an export called
+ ``<export-name>``. It must appear before any target options. To actually
+ install the export file itself, call `install(EXPORT)`_, documented below.
+ See documentation of the :prop_tgt:`EXPORT_NAME` target property to change
+ the name of the exported target.
+
+``INCLUDES DESTINATION``
+ This option specifies a list of directories which will be added to the
+ :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target property of the
+ ``<targets>`` when exported by the `install(EXPORT)`_ command. If a
+ relative path is specified, it is treated as relative to the
+ ``$<INSTALL_PREFIX>``.
One or more groups of properties may be specified in a single call to
the ``TARGETS`` form of this command. A target may be installed more than
@@ -164,24 +328,40 @@ the ``mySharedLib`` DLL will be installed to ``<prefix>/bin`` and
``/some/full/path`` and its import library will be installed to
``<prefix>/lib/static`` and ``/some/full/path``.
-The ``EXPORT`` option associates the installed target files with an
-export called ``<export-name>``. It must appear before any ``RUNTIME``,
-``LIBRARY``, ``ARCHIVE``, or ``OBJECTS`` options. To actually install the
-export file itself, call ``install(EXPORT)``, documented below.
+:ref:`Interface Libraries` may be listed among the targets to install.
+They install no artifacts but will be included in an associated ``EXPORT``.
+If :ref:`Object Libraries` are listed but given no destination for their
+object files, they will be exported as :ref:`Interface Libraries`.
+This is sufficient to satisfy transitive usage requirements of other
+targets that link to the object libraries in their implementation.
Installing a target with the :prop_tgt:`EXCLUDE_FROM_ALL` target property
set to ``TRUE`` has undefined behavior.
-The install destination given to the target install ``DESTINATION`` may
+`install(TARGETS)`_ can install targets that were created in
+other directories. When using such cross-directory install rules, running
+``make install`` (or similar) from a subdirectory will not guarantee that
+targets from other directories are up-to-date. You can use
+:command:`target_link_libraries` or :command:`add_dependencies`
+to ensure that such out-of-directory targets are built before the
+subdirectory-specific install rules are run.
+
+An install destination given as a ``DESTINATION`` argument may
use "generator expressions" with the syntax ``$<...>``. See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
Installing Files
^^^^^^^^^^^^^^^^
-::
+.. _`install(FILES)`:
+.. _`install(PROGRAMS)`:
+.. _FILES:
+.. _PROGRAMS:
+
+.. code-block:: cmake
- install(<FILES|PROGRAMS> files... DESTINATION <dir>
+ install(<FILES|PROGRAMS> files...
+ TYPE <type> | DESTINATION <dir>
[PERMISSIONS permissions...]
[CONFIGURATIONS [Debug|Release|...]]
[COMPONENT <component>]
@@ -205,16 +385,71 @@ The list of ``files...`` given to ``FILES`` or ``PROGRAMS`` may use
However, if any item begins in a generator expression it must evaluate
to a full path.
-The install destination given to the files install ``DESTINATION`` may
+Either a ``TYPE`` or a ``DESTINATION`` must be provided, but not both.
+A ``TYPE`` argument specifies the generic file type of the files being
+installed. A destination will then be set automatically by taking the
+corresponding variable from :module:`GNUInstallDirs`, or by using a
+built-in default if that variable is not defined. See the table below for
+the supported file types and their corresponding variables and built-in
+defaults. Projects can provide a ``DESTINATION`` argument instead of a
+file type if they wish to explicitly define the install destination.
+
+======================= ================================== =========================
+ ``TYPE`` Argument GNUInstallDirs Variable Built-In Default
+======================= ================================== =========================
+``BIN`` ``${CMAKE_INSTALL_BINDIR}`` ``bin``
+``SBIN`` ``${CMAKE_INSTALL_SBINDIR}`` ``sbin``
+``LIB`` ``${CMAKE_INSTALL_LIBDIR}`` ``lib``
+``INCLUDE`` ``${CMAKE_INSTALL_INCLUDEDIR}`` ``include``
+``SYSCONF`` ``${CMAKE_INSTALL_SYSCONFDIR}`` ``etc``
+``SHAREDSTATE`` ``${CMAKE_INSTALL_SHARESTATEDIR}`` ``com``
+``LOCALSTATE`` ``${CMAKE_INSTALL_LOCALSTATEDIR}`` ``var``
+``RUNSTATE`` ``${CMAKE_INSTALL_RUNSTATEDIR}`` ``<LOCALSTATE dir>/run``
+``DATA`` ``${CMAKE_INSTALL_DATADIR}`` ``<DATAROOT dir>``
+``INFO`` ``${CMAKE_INSTALL_INFODIR}`` ``<DATAROOT dir>/info``
+``LOCALE`` ``${CMAKE_INSTALL_LOCALEDIR}`` ``<DATAROOT dir>/locale``
+``MAN`` ``${CMAKE_INSTALL_MANDIR}`` ``<DATAROOT dir>/man``
+``DOC`` ``${CMAKE_INSTALL_DOCDIR}`` ``<DATAROOT dir>/doc``
+======================= ================================== =========================
+
+Projects wishing to follow the common practice of installing headers into a
+project-specific subdirectory will need to provide a destination rather than
+rely on the above.
+
+Note that some of the types' built-in defaults use the ``DATAROOT`` directory as
+a prefix. The ``DATAROOT`` prefix is calculated similarly to the types, with
+``CMAKE_INSTALL_DATAROOTDIR`` as the variable and ``share`` as the built-in
+default. You cannot use ``DATAROOT`` as a ``TYPE`` parameter; please use
+``DATA`` instead.
+
+To make packages compliant with distribution filesystem layout policies, if
+projects must specify a ``DESTINATION``, it is recommended that they use a
+path that begins with the appropriate :module:`GNUInstallDirs` variable.
+This allows package maintainers to control the install destination by setting
+the appropriate cache variables. The following example shows how to follow
+this advice while installing headers to a project-specific subdirectory:
+
+.. code-block:: cmake
+
+ include(GNUInstallDirs)
+ install(FILES mylib.h
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/myproj
+ )
+
+An install destination given as a ``DESTINATION`` argument may
use "generator expressions" with the syntax ``$<...>``. See the
:manual:`cmake-generator-expressions(7)` manual for available expressions.
Installing Directories
^^^^^^^^^^^^^^^^^^^^^^
-::
+.. _`install(DIRECTORY)`:
+.. _DIRECTORY:
+
+.. code-block:: cmake
- install(DIRECTORY dirs... DESTINATION <dir>
+ install(DIRECTORY dirs...
+ TYPE <type> | DESTINATION <dir>
[FILE_PERMISSIONS permissions...]
[DIRECTORY_PERMISSIONS permissions...]
[USE_SOURCE_PERMISSIONS] [OPTIONAL] [MESSAGE_NEVER]
@@ -285,15 +520,60 @@ will install the ``icons`` directory to ``share/myproj/icons`` and the
file permissions, the scripts will be given specific permissions, and any
``CVS`` directories will be excluded.
-The list of ``dirs...`` given to ``DIRECTORY`` and the install destination
-given to the directory install ``DESTINATION`` may use "generator expressions"
+Either a ``TYPE`` or a ``DESTINATION`` must be provided, but not both.
+A ``TYPE`` argument specifies the generic file type of the files within the
+listed directories being installed. A destination will then be set
+automatically by taking the corresponding variable from
+:module:`GNUInstallDirs`, or by using a built-in default if that variable
+is not defined. See the table below for the supported file types and their
+corresponding variables and built-in defaults. Projects can provide a
+``DESTINATION`` argument instead of a file type if they wish to explicitly
+define the install destination.
+
+======================= ================================== =========================
+ ``TYPE`` Argument GNUInstallDirs Variable Built-In Default
+======================= ================================== =========================
+``BIN`` ``${CMAKE_INSTALL_BINDIR}`` ``bin``
+``SBIN`` ``${CMAKE_INSTALL_SBINDIR}`` ``sbin``
+``LIB`` ``${CMAKE_INSTALL_LIBDIR}`` ``lib``
+``INCLUDE`` ``${CMAKE_INSTALL_INCLUDEDIR}`` ``include``
+``SYSCONF`` ``${CMAKE_INSTALL_SYSCONFDIR}`` ``etc``
+``SHAREDSTATE`` ``${CMAKE_INSTALL_SHARESTATEDIR}`` ``com``
+``LOCALSTATE`` ``${CMAKE_INSTALL_LOCALSTATEDIR}`` ``var``
+``RUNSTATE`` ``${CMAKE_INSTALL_RUNSTATEDIR}`` ``<LOCALSTATE dir>/run``
+``DATA`` ``${CMAKE_INSTALL_DATADIR}`` ``<DATAROOT dir>``
+``INFO`` ``${CMAKE_INSTALL_INFODIR}`` ``<DATAROOT dir>/info``
+``LOCALE`` ``${CMAKE_INSTALL_LOCALEDIR}`` ``<DATAROOT dir>/locale``
+``MAN`` ``${CMAKE_INSTALL_MANDIR}`` ``<DATAROOT dir>/man``
+``DOC`` ``${CMAKE_INSTALL_DOCDIR}`` ``<DATAROOT dir>/doc``
+======================= ================================== =========================
+
+Note that some of the types' built-in defaults use the ``DATAROOT`` directory as
+a prefix. The ``DATAROOT`` prefix is calculated similarly to the types, with
+``CMAKE_INSTALL_DATAROOTDIR`` as the variable and ``share`` as the built-in
+default. You cannot use ``DATAROOT`` as a ``TYPE`` parameter; please use
+``DATA`` instead.
+
+To make packages compliant with distribution filesystem layout policies, if
+projects must specify a ``DESTINATION``, it is recommended that they use a
+path that begins with the appropriate :module:`GNUInstallDirs` variable.
+This allows package maintainers to control the install destination by setting
+the appropriate cache variables.
+
+The list of ``dirs...`` given to ``DIRECTORY`` and an install destination
+given as a ``DESTINATION`` argument may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions.
Custom Installation Logic
^^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. _`install(CODE)`:
+.. _`install(SCRIPT)`:
+.. _CODE:
+.. _SCRIPT:
+
+.. code-block:: cmake
install([[SCRIPT <file>] [CODE <code>]]
[COMPONENT <component>] [EXCLUDE_FROM_ALL] [...])
@@ -311,24 +591,32 @@ example, the code
will print a message during installation.
+``<file>`` or ``<code>`` may use "generator expressions" with the syntax
+``$<...>`` (in the case of ``<file>``, this refers to their use in the file
+name, not the file's contents). See the
+:manual:`cmake-generator-expressions(7)` manual for available expressions.
+
Installing Exports
^^^^^^^^^^^^^^^^^^
-::
+.. _`install(EXPORT)`:
+.. _EXPORT:
+
+.. code-block:: cmake
install(EXPORT <export-name> DESTINATION <dir>
[NAMESPACE <namespace>] [[FILE <name>.cmake]|
- [EXPORT_ANDROID_MK <name>.mk]]
[PERMISSIONS permissions...]
[CONFIGURATIONS [Debug|Release|...]]
[EXPORT_LINK_INTERFACE_LIBRARIES]
[COMPONENT <component>]
[EXCLUDE_FROM_ALL])
+ install(EXPORT_ANDROID_MK <export-name> DESTINATION <dir> [...])
The ``EXPORT`` form generates and installs a CMake file containing code to
import targets from the installation tree into another project.
Target installations are associated with the export ``<export-name>``
-using the ``EXPORT`` option of the ``install(TARGETS)`` signature
+using the ``EXPORT`` option of the `install(TARGETS)`_ signature
documented above. The ``NAMESPACE`` option will prepend ``<namespace>`` to
the target names as they are written to the import file. By default
the generated file will be called ``<export-name>.cmake`` but the ``FILE``
@@ -340,14 +628,28 @@ generated import file will reference only the matching target
configurations. The ``EXPORT_LINK_INTERFACE_LIBRARIES`` keyword, if
present, causes the contents of the properties matching
``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?`` to be exported, when
-policy :policy:`CMP0022` is ``NEW``. If a ``COMPONENT`` option is
-specified that does not match that given to the targets associated with
-``<export-name>`` the behavior is undefined. If a library target is
-included in the export but a target to which it links is not included
-the behavior is unspecified.
-
-In additon to cmake language files, the ``EXPORT_ANDROID_MK`` option maybe
-used to specifiy an export to the android ndk build system. The Android
+policy :policy:`CMP0022` is ``NEW``.
+
+When a ``COMPONENT`` option is given, the listed ``<component>`` implicitly
+depends on all components mentioned in the export set. The exported
+``<name>.cmake`` file will require each of the exported components to be
+present in order for dependent projects to build properly. For example, a
+project may define components ``Runtime`` and ``Development``, with shared
+libraries going into the ``Runtime`` component and static libraries and
+headers going into the ``Development`` component. The export set would also
+typically be part of the ``Development`` component, but it would export
+targets from both the ``Runtime`` and ``Development`` components. Therefore,
+the ``Runtime`` component would need to be installed if the ``Development``
+component was installed, but not vice versa. If the ``Development`` component
+was installed without the ``Runtime`` component, dependent projects that try
+to link against it would have build errors. Package managers, such as APT and
+RPM, typically handle this by listing the ``Runtime`` component as a dependency
+of the ``Development`` component in the package metadata, ensuring that the
+library is always installed if the headers and CMake export file are present.
+
+In addition to cmake language files, the ``EXPORT_ANDROID_MK`` mode maybe
+used to specify an export to the android ndk build system. This mode
+accepts the same options as the normal export mode. The Android
NDK supports the use of prebuilt libraries, both static and shared. This
allows cmake to build the libraries of a project and make them available
to an ndk build system complete with transitive dependencies, include flags
@@ -360,11 +662,11 @@ and installed by the current project. For example, the code
install(TARGETS myexe EXPORT myproj DESTINATION bin)
install(EXPORT myproj NAMESPACE mp_ DESTINATION lib/myproj)
- install(EXPORT_ANDROID_MK myexp DESTINATION share/ndk-modules)
+ install(EXPORT_ANDROID_MK myproj DESTINATION share/ndk-modules)
-will install the executable myexe to ``<prefix>/bin`` and code to import
+will install the executable ``myexe`` to ``<prefix>/bin`` and code to import
it in the file ``<prefix>/lib/myproj/myproj.cmake`` and
-``<prefix>/lib/share/ndk-modules/Android.mk``. An outside project
+``<prefix>/share/ndk-modules/Android.mk``. An outside project
may load this file with the include command and reference the ``myexe``
executable from the installation tree using the imported target name
``mp_myexe`` as if the target were built in its own tree.
@@ -378,3 +680,26 @@ executable from the installation tree using the imported target name
those generated by :command:`install_targets`,
:command:`install_files`, and :command:`install_programs` commands
is not defined.
+
+Generated Installation Script
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The ``install()`` command generates a file, ``cmake_install.cmake``, inside
+the build directory, which is used internally by the generated install target
+and by CPack. You can also invoke this script manually with ``cmake -P``. This
+script accepts several variables:
+
+``COMPONENT``
+ Set this variable to install only a single CPack component as opposed to all
+ of them. For example, if you only want to install the ``Development``
+ component, run ``cmake -DCOMPONENT=Development -P cmake_install.cmake``.
+
+``BUILD_TYPE``
+ Set this variable to change the build type if you are using a multi-config
+ generator. For example, to install with the ``Debug`` configuration, run
+ ``cmake -DBUILD_TYPE=Debug -P cmake_install.cmake``.
+
+``DESTDIR``
+ This is an environment variable rather than a CMake variable. It allows you
+ to change the installation prefix on UNIX systems. See :envvar:`DESTDIR` for
+ details.
diff --git a/Help/command/install_files.rst b/Help/command/install_files.rst
index 1850be6e1..ff074a8a7 100644
--- a/Help/command/install_files.rst
+++ b/Help/command/install_files.rst
@@ -1,7 +1,9 @@
install_files
-------------
-Deprecated. Use the :command:`install(FILES)` command instead.
+.. deprecated:: 3.0
+
+ Use the :command:`install(FILES)` command instead.
This command has been superceded by the :command:`install` command. It is
provided for compatibility with older CMake code. The ``FILES`` form is
@@ -19,7 +21,7 @@ or its corresponding location in the binary tree may be listed. If a
file specified already has an extension, that extension will be
removed first. This is useful for providing lists of source files
such as foo.cxx when you want the corresponding foo.h to be installed.
-A typical extension is '.h'.
+A typical extension is ``.h``.
::
diff --git a/Help/command/install_programs.rst b/Help/command/install_programs.rst
index 79aa486a3..fab64820d 100644
--- a/Help/command/install_programs.rst
+++ b/Help/command/install_programs.rst
@@ -1,7 +1,9 @@
install_programs
----------------
-Deprecated. Use the :command:`install(PROGRAMS)` command instead.
+.. deprecated:: 3.0
+
+ Use the :command:`install(PROGRAMS)` command instead.
This command has been superceded by the :command:`install` command. It is
provided for compatibility with older CMake code. The ``FILES`` form is
diff --git a/Help/command/install_targets.rst b/Help/command/install_targets.rst
index 49ca69694..c9efdce67 100644
--- a/Help/command/install_targets.rst
+++ b/Help/command/install_targets.rst
@@ -1,7 +1,9 @@
install_targets
---------------
-Deprecated. Use the :command:`install(TARGETS)` command instead.
+.. deprecated:: 3.0
+
+ Use the :command:`install(TARGETS)` command instead.
This command has been superceded by the :command:`install` command. It is
provided for compatibility with older CMake code.
diff --git a/Help/command/link_directories.rst b/Help/command/link_directories.rst
index 5c64bc609..9cb8faa74 100644
--- a/Help/command/link_directories.rst
+++ b/Help/command/link_directories.rst
@@ -1,19 +1,51 @@
link_directories
----------------
-Specify directories in which the linker will look for libraries.
+Add directories in which the linker will look for libraries.
-::
+.. code-block:: cmake
- link_directories(directory1 directory2 ...)
+ link_directories([AFTER|BEFORE] directory1 [directory2 ...])
-Specify the paths in which the linker should search for libraries.
-The command will apply only to targets created after it is called.
+Adds the paths in which the linker should search for libraries.
Relative paths given to this command are interpreted as relative to
the current source directory, see :policy:`CMP0015`.
-Note that this command is rarely necessary. Library locations
-returned by :command:`find_package` and :command:`find_library` are
-absolute paths. Pass these absolute library file paths directly to the
-:command:`target_link_libraries` command. CMake will ensure the linker finds
-them.
+The directories are added to the :prop_dir:`LINK_DIRECTORIES` directory
+property for the current ``CMakeLists.txt`` file, converting relative
+paths to absolute as needed.
+The command will apply only to targets created after it is called.
+
+By default the directories specified are appended onto the current list of
+directories. This default behavior can be changed by setting
+:variable:`CMAKE_LINK_DIRECTORIES_BEFORE` to ``ON``. By using
+``AFTER`` or ``BEFORE`` explicitly, you can select between appending and
+prepending, independent of the default.
+
+Arguments to ``link_directories`` may use "generator expressions" with
+the syntax "$<...>". See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
+
+.. note::
+
+ This command is rarely necessary and should be avoided where there are
+ other choices. Prefer to pass full absolute paths to libraries where
+ possible, since this ensures the correct library will always be linked.
+ The :command:`find_library` command provides the full path, which can
+ generally be used directly in calls to :command:`target_link_libraries`.
+ Situations where a library search path may be needed include:
+
+ - Project generators like Xcode where the user can switch target
+ architecture at build time, but a full path to a library cannot
+ be used because it only provides one architecture (i.e. it is not
+ a universal binary).
+ - Libraries may themselves have other private library dependencies
+ that expect to be found via ``RPATH`` mechanisms, but some linkers
+ are not able to fully decode those paths (e.g. due to the presence
+ of things like ``$ORIGIN``).
+
+ If a library search path must be provided, prefer to localize the effect
+ where possible by using the :command:`target_link_directories` command
+ rather than ``link_directories()``. The target-specific command can also
+ control how the search directories propagate to other dependent targets.
diff --git a/Help/command/link_libraries.rst b/Help/command/link_libraries.rst
index fd5dc3723..8665cb789 100644
--- a/Help/command/link_libraries.rst
+++ b/Help/command/link_libraries.rst
@@ -3,7 +3,7 @@ link_libraries
Link libraries to all targets added later.
-::
+.. code-block:: cmake
link_libraries([item1 [item2 [...]]]
[[debug|optimized|general] <item>] ...)
diff --git a/Help/command/list.rst b/Help/command/list.rst
index f6b75bc19..50bf417bf 100644
--- a/Help/command/list.rst
+++ b/Help/command/list.rst
@@ -3,66 +3,323 @@ list
List operations.
-::
+Synopsis
+^^^^^^^^
+
+.. parsed-literal::
+
+ `Reading`_
+ list(`LENGTH`_ <list> <out-var>)
+ list(`GET`_ <list> <element index> [<index> ...] <out-var>)
+ list(`JOIN`_ <list> <glue> <out-var>)
+ list(`SUBLIST`_ <list> <begin> <length> <out-var>)
+
+ `Search`_
+ list(`FIND`_ <list> <value> <out-var>)
+
+ `Modification`_
+ list(`APPEND`_ <list> [<element>...])
+ list(`FILTER`_ <list> {INCLUDE | EXCLUDE} REGEX <regex>)
+ list(`INSERT`_ <list> <index> [<element>...])
+ list(`POP_BACK`_ <list> [<out-var>...])
+ list(`POP_FRONT`_ <list> [<out-var>...])
+ list(`PREPEND`_ <list> [<element>...])
+ list(`REMOVE_ITEM`_ <list> <value>...)
+ list(`REMOVE_AT`_ <list> <index>...)
+ list(`REMOVE_DUPLICATES`_ <list>)
+ list(`TRANSFORM`_ <list> <ACTION> [...])
+
+ `Ordering`_
+ list(`REVERSE`_ <list>)
+ list(`SORT`_ <list> [...])
+
+Introduction
+^^^^^^^^^^^^
+
+The list subcommands ``APPEND``, ``INSERT``, ``FILTER``, ``PREPEND``,
+``POP_BACK``, ``POP_FRONT``, ``REMOVE_AT``, ``REMOVE_ITEM``,
+``REMOVE_DUPLICATES``, ``REVERSE`` and ``SORT`` may create
+new values for the list within the current CMake variable scope. Similar to
+the :command:`set` command, the LIST command creates new variable values in
+the current scope, even if the list itself is actually defined in a parent
+scope. To propagate the results of these operations upwards, use
+:command:`set` with ``PARENT_SCOPE``, :command:`set` with
+``CACHE INTERNAL``, or some other means of value propagation.
+
+.. note::
+
+ A list in cmake is a ``;`` separated group of strings. To create a
+ list the set command can be used. For example, ``set(var a b c d e)``
+ creates a list with ``a;b;c;d;e``, and ``set(var "a b c d e")`` creates a
+ string or a list with one item in it. (Note macro arguments are not
+ variables, and therefore cannot be used in LIST commands.)
+
+.. note::
+
+ When specifying index values, if ``<element index>`` is 0 or greater, it
+ is indexed from the beginning of the list, with 0 representing the
+ first list element. If ``<element index>`` is -1 or lesser, it is indexed
+ from the end of the list, with -1 representing the last list element.
+ Be careful when counting with negative indices: they do not start from
+ 0. -0 is equivalent to 0, the first list element.
+
+Reading
+^^^^^^^
+
+.. _LENGTH:
+
+.. code-block:: cmake
list(LENGTH <list> <output variable>)
- list(GET <list> <element index> [<element index> ...]
- <output variable>)
+
+Returns the list's length.
+
+.. _GET:
+
+.. code-block:: cmake
+
+ list(GET <list> <element index> [<element index> ...] <output variable>)
+
+Returns the list of elements specified by indices from the list.
+
+.. _JOIN:
+
+.. code-block:: cmake
+
+ list(JOIN <list> <glue> <output variable>)
+
+Returns a string joining all list's elements using the glue string.
+To join multiple strings, which are not part of a list, use ``JOIN`` operator
+from :command:`string` command.
+
+.. _SUBLIST:
+
+.. code-block:: cmake
+
+ list(SUBLIST <list> <begin> <length> <output variable>)
+
+Returns a sublist of the given list.
+If ``<length>`` is 0, an empty list will be returned.
+If ``<length>`` is -1 or the list is smaller than ``<begin>+<length>`` then
+the remaining elements of the list starting at ``<begin>`` will be returned.
+
+Search
+^^^^^^
+
+.. _FIND:
+
+.. code-block:: cmake
+
+ list(FIND <list> <value> <output variable>)
+
+Returns the index of the element specified in the list or -1
+if it wasn't found.
+
+Modification
+^^^^^^^^^^^^
+
+.. _APPEND:
+
+.. code-block:: cmake
+
list(APPEND <list> [<element> ...])
+
+Appends elements to the list.
+
+.. _FILTER:
+
+.. code-block:: cmake
+
list(FILTER <list> <INCLUDE|EXCLUDE> REGEX <regular_expression>)
- list(FIND <list> <value> <output variable>)
+
+Includes or removes items from the list that match the mode's pattern.
+In ``REGEX`` mode, items will be matched against the given regular expression.
+
+For more information on regular expressions see also the
+:command:`string` command.
+
+.. _INSERT:
+
+.. code-block:: cmake
+
list(INSERT <list> <element_index> <element> [<element> ...])
+
+Inserts elements to the list to the specified location.
+
+.. _POP_BACK:
+
+.. code-block:: cmake
+
+ list(POP_BACK <list> [<out-var>...])
+
+If no variable name is given, removes exactly one element. Otherwise,
+assign the last element's value to the given variable and removes it,
+up to the last variable name given.
+
+.. _POP_FRONT:
+
+.. code-block:: cmake
+
+ list(POP_FRONT <list> [<out-var>...])
+
+If no variable name is given, removes exactly one element. Otherwise,
+assign the first element's value to the given variable and removes it,
+up to the last variable name given.
+
+.. _PREPEND:
+
+.. code-block:: cmake
+
+ list(PREPEND <list> [<element> ...])
+
+Insert elements to the 0th position in the list.
+
+.. _REMOVE_ITEM:
+
+.. code-block:: cmake
+
list(REMOVE_ITEM <list> <value> [<value> ...])
+
+Removes all instances of the given items from the list.
+
+.. _REMOVE_AT:
+
+.. code-block:: cmake
+
list(REMOVE_AT <list> <index> [<index> ...])
+
+Removes items at given indices from the list.
+
+.. _REMOVE_DUPLICATES:
+
+.. code-block:: cmake
+
list(REMOVE_DUPLICATES <list>)
- list(REVERSE <list>)
- list(SORT <list>)
-``LENGTH`` will return a given list's length.
+Removes duplicated items in the list. The relative order of items is preserved,
+but if duplicates are encountered, only the first instance is preserved.
-``GET`` will return list of elements specified by indices from the list.
+.. _TRANSFORM:
-``APPEND`` will append elements to the list.
+.. code-block:: cmake
-``FILTER`` will include or remove items from the list that match the
-mode's pattern.
-In ``REGEX`` mode, items will be matched against the given regular expression.
-For more information on regular expressions see also the :command:`string`
-command.
+ list(TRANSFORM <list> <ACTION> [<SELECTOR>]
+ [OUTPUT_VARIABLE <output variable>])
-``FIND`` will return the index of the element specified in the list or -1
-if it wasn't found.
+Transforms the list by applying an action to all or, by specifying a
+``<SELECTOR>``, to the selected elements of the list, storing the result
+in-place or in the specified output variable.
-``INSERT`` will insert elements to the list to the specified location.
+.. note::
-``REMOVE_AT`` and ``REMOVE_ITEM`` will remove items from the list. The
-difference is that ``REMOVE_ITEM`` will remove the given items, while
-``REMOVE_AT`` will remove the items at the given indices.
+ The ``TRANSFORM`` sub-command does not change the number of elements in the
+ list. If a ``<SELECTOR>`` is specified, only some elements will be changed,
+ the other ones will remain the same as before the transformation.
-``REMOVE_DUPLICATES`` will remove duplicated items in the list.
+``<ACTION>`` specifies the action to apply to the elements of the list.
+The actions have exactly the same semantics as sub-commands of the
+:command:`string` command. ``<ACTION>`` must be one of the following:
-``REVERSE`` reverses the contents of the list in-place.
+``APPEND``, ``PREPEND``: Append, prepend specified value to each element of
+the list.
-``SORT`` sorts the list in-place alphabetically.
+ .. code-block:: cmake
-The list subcommands ``APPEND``, ``INSERT``, ``FILTER``, ``REMOVE_AT``,
-``REMOVE_ITEM``, ``REMOVE_DUPLICATES``, ``REVERSE`` and ``SORT`` may create new
-values for the list within the current CMake variable scope. Similar to the
-:command:`set` command, the LIST command creates new variable values in the
-current scope, even if the list itself is actually defined in a parent
-scope. To propagate the results of these operations upwards, use
-:command:`set` with ``PARENT_SCOPE``, :command:`set` with
-``CACHE INTERNAL``, or some other means of value propagation.
+ list(TRANSFORM <list> <APPEND|PREPEND> <value> ...)
+
+``TOUPPER``, ``TOLOWER``: Convert each element of the list to upper, lower
+characters.
+
+ .. code-block:: cmake
+
+ list(TRANSFORM <list> <TOLOWER|TOUPPER> ...)
+
+``STRIP``: Remove leading and trailing spaces from each element of the
+list.
+
+ .. code-block:: cmake
+
+ list(TRANSFORM <list> STRIP ...)
+
+``GENEX_STRIP``: Strip any
+:manual:`generator expressions <cmake-generator-expressions(7)>` from each
+element of the list.
+
+ .. code-block:: cmake
+
+ list(TRANSFORM <list> GENEX_STRIP ...)
+
+``REPLACE``: Match the regular expression as many times as possible and
+substitute the replacement expression for the match for each element
+of the list
+(Same semantic as ``REGEX REPLACE`` from :command:`string` command).
+
+ .. code-block:: cmake
+
+ list(TRANSFORM <list> REPLACE <regular_expression>
+ <replace_expression> ...)
+
+``<SELECTOR>`` determines which elements of the list will be transformed.
+Only one type of selector can be specified at a time. When given,
+``<SELECTOR>`` must be one of the following:
+
+``AT``: Specify a list of indexes.
+
+ .. code-block:: cmake
+
+ list(TRANSFORM <list> <ACTION> AT <index> [<index> ...] ...)
+
+``FOR``: Specify a range with, optionally, an increment used to iterate over
+the range.
+
+ .. code-block:: cmake
+
+ list(TRANSFORM <list> <ACTION> FOR <start> <stop> [<step>] ...)
+
+``REGEX``: Specify a regular expression. Only elements matching the regular
+expression will be transformed.
+
+ .. code-block:: cmake
+
+ list(TRANSFORM <list> <ACTION> REGEX <regular_expression> ...)
+
+
+Ordering
+^^^^^^^^
+
+.. _REVERSE:
+
+.. code-block:: cmake
+
+ list(REVERSE <list>)
+
+Reverses the contents of the list in-place.
+
+.. _SORT:
+
+.. code-block:: cmake
+
+ list(SORT <list> [COMPARE <compare>] [CASE <case>] [ORDER <order>])
+
+Sorts the list in-place alphabetically.
+Use the ``COMPARE`` keyword to select the comparison method for sorting.
+The ``<compare>`` option should be one of:
+
+* ``STRING``: Sorts a list of strings alphabetically. This is the
+ default behavior if the ``COMPARE`` option is not given.
+* ``FILE_BASENAME``: Sorts a list of pathnames of files by their basenames.
+
+Use the ``CASE`` keyword to select a case sensitive or case insensitive
+sort mode. The ``<case>`` option should be one of:
+
+* ``SENSITIVE``: List items are sorted in a case-sensitive manner. This is
+ the default behavior if the ``CASE`` option is not given.
+* ``INSENSITIVE``: List items are sorted case insensitively. The order of
+ items which differ only by upper/lowercase is not specified.
+
+To control the sort order, the ``ORDER`` keyword can be given.
+The ``<order>`` option should be one of:
-NOTES: A list in cmake is a ``;`` separated group of strings. To create a
-list the set command can be used. For example, ``set(var a b c d e)``
-creates a list with ``a;b;c;d;e``, and ``set(var "a b c d e")`` creates a
-string or a list with one item in it. (Note macro arguments are not
-variables, and therefore cannot be used in LIST commands.)
-
-When specifying index values, if ``<element index>`` is 0 or greater, it
-is indexed from the beginning of the list, with 0 representing the
-first list element. If ``<element index>`` is -1 or lesser, it is indexed
-from the end of the list, with -1 representing the last list element.
-Be careful when counting with negative indices: they do not start from
-0. -0 is equivalent to 0, the first list element.
+* ``ASCENDING``: Sorts the list in ascending order. This is the default
+ behavior when the ``ORDER`` option is not given.
+* ``DESCENDING``: Sorts the list in descending order.
diff --git a/Help/command/load_cache.rst b/Help/command/load_cache.rst
index f1134472d..b89eb6177 100644
--- a/Help/command/load_cache.rst
+++ b/Help/command/load_cache.rst
@@ -3,21 +3,20 @@ load_cache
Load in the values from another project's CMake cache.
-::
+.. code-block:: cmake
- load_cache(pathToCacheFile READ_WITH_PREFIX
- prefix entry1...)
+ load_cache(pathToBuildDirectory READ_WITH_PREFIX prefix entry1...)
-Read the cache and store the requested entries in variables with their
+Reads the cache and store the requested entries in variables with their
name prefixed with the given prefix. This only reads the values, and
does not create entries in the local project's cache.
-::
+.. code-block:: cmake
- load_cache(pathToCacheFile [EXCLUDE entry1...]
+ load_cache(pathToBuildDirectory [EXCLUDE entry1...]
[INCLUDE_INTERNALS entry1...])
-Load in the values from another cache and store them in the local
+Loads in the values from another cache and store them in the local
project's cache as internal entries. This is useful for a project
that depends on another project built in a different tree. ``EXCLUDE``
option can be used to provide a list of entries to be excluded.
diff --git a/Help/command/load_command.rst b/Help/command/load_command.rst
index a1576e8b5..dc235994c 100644
--- a/Help/command/load_command.rst
+++ b/Help/command/load_command.rst
@@ -1,7 +1,7 @@
load_command
------------
-Disallowed. See CMake Policy :policy:`CMP0031`.
+Disallowed since version 3.0. See CMake Policy :policy:`CMP0031`.
Load a command into a running CMake.
diff --git a/Help/command/macro.rst b/Help/command/macro.rst
index 6bee69c73..05e5d79ac 100644
--- a/Help/command/macro.rst
+++ b/Help/command/macro.rst
@@ -1,27 +1,66 @@
macro
-----
-Start recording a macro for later invocation as a command::
-
- macro(<name> [arg1 [arg2 [arg3 ...]]])
- COMMAND1(ARGS ...)
- COMMAND2(ARGS ...)
- ...
- endmacro(<name>)
-
-Define a macro named ``<name>`` that takes arguments named ``arg1``,
-``arg2``, ``arg3``, (...).
-Commands listed after macro, but before the matching
-:command:`endmacro()`, are not invoked until the macro is invoked.
-When it is invoked, the commands recorded in the macro are first
-modified by replacing formal parameters (``${arg1}``) with the arguments
-passed, and then invoked as normal commands.
+Start recording a macro for later invocation as a command
+
+.. code-block:: cmake
+
+ macro(<name> [<arg1> ...])
+ <commands>
+ endmacro()
+
+Defines a macro named ``<name>`` that takes arguments named
+``<arg1>``, ... Commands listed after macro, but before the
+matching :command:`endmacro()`, are not executed until the macro
+is invoked.
+
+Per legacy, the :command:`endmacro` command admits an optional
+``<name>`` argument. If used, it must be a verbatim repeat of the
+argument of the opening ``macro`` command.
+
+See the :command:`cmake_policy()` command documentation for the behavior
+of policies inside macros.
+
+See the :ref:`Macro vs Function` section below for differences
+between CMake macros and :command:`functions <function>`.
+
+Invocation
+^^^^^^^^^^
+
+The macro invocation is case-insensitive. A macro defined as
+
+.. code-block:: cmake
+
+ macro(foo)
+ <commands>
+ endmacro()
+
+can be invoked through any of
+
+.. code-block:: cmake
+
+ foo()
+ Foo()
+ FOO()
+
+and so on. However, it is strongly recommended to stay with the
+case chosen in the macro definition. Typically macros use
+all-lowercase names.
+
+Arguments
+^^^^^^^^^
+
+When a macro is invoked, the commands recorded in the macro are
+first modified by replacing formal parameters (``${arg1}``, ...)
+with the arguments passed, and then invoked as normal commands.
+
In addition to referencing the formal parameters you can reference the
values ``${ARGC}`` which will be set to the number of arguments passed
into the function as well as ``${ARGV0}``, ``${ARGV1}``, ``${ARGV2}``,
... which will have the actual values of the arguments passed in.
This facilitates creating macros with optional arguments.
-Additionally ``${ARGV}`` holds the list of all arguments given to the
+
+Furthermore, ``${ARGV}`` holds the list of all arguments given to the
macro and ``${ARGN}`` holds the list of arguments past the last expected
argument.
Referencing to ``${ARGV#}`` arguments beyond ``${ARGC}`` have undefined
@@ -29,48 +68,73 @@ behavior. Checking that ``${ARGC}`` is greater than ``#`` is the only
way to ensure that ``${ARGV#}`` was passed to the function as an extra
argument.
-See the :command:`cmake_policy()` command documentation for the behavior
-of policies inside macros.
+.. _`Macro vs Function`:
+
+Macro vs Function
+^^^^^^^^^^^^^^^^^
-Macro Argument Caveats
-^^^^^^^^^^^^^^^^^^^^^^
+The ``macro`` command is very similar to the :command:`function` command.
+Nonetheless, there are a few important differences.
-Note that the parameters to a macro and values such as ``ARGN`` are
-not variables in the usual CMake sense. They are string
-replacements much like the C preprocessor would do with a macro.
-Therefore you will NOT be able to use commands like::
+In a function, ``ARGN``, ``ARGC``, ``ARGV`` and ``ARGV0``, ``ARGV1``, ...
+are true variables in the usual CMake sense. In a macro, they are not,
+they are string replacements much like the C preprocessor would do
+with a macro. This has a number of consequences, as explained in
+the :ref:`Argument Caveats` section below.
+
+Another difference between macros and functions is the control flow.
+A function is executed by transferring control from the calling
+statement to the function body. A macro is executed as if the macro
+body were pasted in place of the calling statement. This has the
+consequence that a :command:`return()` in a macro body does not
+just terminate execution of the macro; rather, control is returned
+from the scope of the macro call. To avoid confusion, it is recommended
+to avoid :command:`return()` in macros altogether.
+
+.. _`Argument Caveats`:
+
+Argument Caveats
+^^^^^^^^^^^^^^^^
+
+Since ``ARGN``, ``ARGC``, ``ARGV``, ``ARGV0`` etc. are not variables,
+you will NOT be able to use commands like
+
+.. code-block:: cmake
if(ARGV1) # ARGV1 is not a variable
if(DEFINED ARGV2) # ARGV2 is not a variable
if(ARGC GREATER 2) # ARGC is not a variable
foreach(loop_var IN LISTS ARGN) # ARGN is not a variable
-In the first case, you can use ``if(${ARGV1})``.
-In the second and third case, the proper way to check if an optional
-variable was passed to the macro is to use ``if(${ARGC} GREATER 2)``.
-In the last case, you can use ``foreach(loop_var ${ARGN})`` but this
-will skip empty arguments.
-If you need to include them, you can use::
+In the first case, you can use ``if(${ARGV1})``. In the second and
+third case, the proper way to check if an optional variable was
+passed to the macro is to use ``if(${ARGC} GREATER 2)``. In the
+last case, you can use ``foreach(loop_var ${ARGN})`` but this will
+skip empty arguments. If you need to include them, you can use
+
+.. code-block:: cmake
set(list_var "${ARGN}")
foreach(loop_var IN LISTS list_var)
Note that if you have a variable with the same name in the scope from
which the macro is called, using unreferenced names will use the
-existing variable instead of the arguments. For example::
+existing variable instead of the arguments. For example:
+
+.. code-block:: cmake
- macro(_BAR)
+ macro(bar)
foreach(arg IN LISTS ARGN)
- [...]
+ <commands>
endforeach()
endmacro()
- function(_FOO)
- _bar(x y z)
+ function(foo)
+ bar(x y z)
endfunction()
- _foo(a b c)
+ foo(a b c)
-Will loop over ``a;b;c`` and not over ``x;y;z`` as one might be expecting.
+Will loop over ``a;b;c`` and not over ``x;y;z`` as one might have expected.
If you want true CMake variables and/or better CMake scope control you
should look at the function command.
diff --git a/Help/command/make_directory.rst b/Help/command/make_directory.rst
index 27ecf5194..8469b0a96 100644
--- a/Help/command/make_directory.rst
+++ b/Help/command/make_directory.rst
@@ -1,7 +1,9 @@
make_directory
--------------
-Deprecated. Use the :command:`file(MAKE_DIRECTORY)` command instead.
+.. deprecated:: 3.0
+
+ Use the :command:`file(MAKE_DIRECTORY)` command instead.
::
diff --git a/Help/command/mark_as_advanced.rst b/Help/command/mark_as_advanced.rst
index c3f94fc48..5712fb420 100644
--- a/Help/command/mark_as_advanced.rst
+++ b/Help/command/mark_as_advanced.rst
@@ -3,17 +3,22 @@ mark_as_advanced
Mark cmake cached variables as advanced.
-::
+.. code-block:: cmake
- mark_as_advanced([CLEAR|FORCE] VAR [VAR2 ...])
+ mark_as_advanced([CLEAR|FORCE] <var1> ...)
-Mark the named cached variables as advanced. An advanced variable
-will not be displayed in any of the cmake GUIs unless the show
-advanced option is on. If ``CLEAR`` is the first argument advanced
-variables are changed back to unadvanced. If ``FORCE`` is the first
-argument, then the variable is made advanced. If neither ``FORCE`` nor
-``CLEAR`` is specified, new values will be marked as advanced, but if the
-variable already has an advanced/non-advanced state, it will not be
-changed.
+Sets the advanced/non-advanced state of the named
+cached variables.
-It does nothing in script mode.
+An advanced variable will not be displayed in any
+of the cmake GUIs unless the ``show advanced`` option is on.
+In script mode, the advanced/non-advanced state has no effect.
+
+If the keyword ``CLEAR`` is given
+then advanced variables are changed back to unadvanced.
+If the keyword ``FORCE`` is given
+then the variables are made advanced.
+If neither ``FORCE`` nor ``CLEAR`` is specified,
+new values will be marked as advanced, but if a
+variable already has an advanced/non-advanced state,
+it will not be changed.
diff --git a/Help/command/math.rst b/Help/command/math.rst
index f99dc3db3..ddb1ec63c 100644
--- a/Help/command/math.rst
+++ b/Help/command/math.rst
@@ -1,14 +1,37 @@
math
----
-Mathematical expressions.
+Evaluate a mathematical expression.
-::
+.. code-block:: cmake
- math(EXPR <output-variable> <math-expression>)
+ math(EXPR <variable> "<expression>" [OUTPUT_FORMAT <format>])
-``EXPR`` evaluates mathematical expression and returns result in the
-output variable. Example mathematical expression is ``5 * (10 + 13)``.
+Evaluates a mathematical ``<expression>`` and sets ``<variable>`` to the
+resulting value. The result of the expression must be representable as a
+64-bit signed integer.
+
+The mathematical expression must be given as a string (i.e. enclosed in
+double quotation marks). An example is ``"5 * (10 + 13)"``.
Supported operators are ``+``, ``-``, ``*``, ``/``, ``%``, ``|``, ``&``,
-``^``, ``~``, ``<<``, ``>>``, and ``(...)``. They have the same meaning
-as they do in C code.
+``^``, ``~``, ``<<``, ``>>``, and ``(...)``; they have the same meaning
+as in C code.
+
+Hexadecimal numbers are recognized when prefixed with ``0x``, as in C code.
+
+The result is formatted according to the option ``OUTPUT_FORMAT``,
+where ``<format>`` is one of
+
+``HEXADECIMAL``
+ Hexadecimal notation as in C code, i. e. starting with "0x".
+``DECIMAL``
+ Decimal notation. Which is also used if no ``OUTPUT_FORMAT`` option
+ is specified.
+
+
+For example
+
+.. code-block:: cmake
+
+ math(EXPR value "100 * 0xA" OUTPUT_FORMAT DECIMAL) # value is set to "1000"
+ math(EXPR value "100 * 0xA" OUTPUT_FORMAT HEXADECIMAL) # value is set to "0x3e8"
diff --git a/Help/command/message.rst b/Help/command/message.rst
index 04c62fdff..c614286c1 100644
--- a/Help/command/message.rst
+++ b/Help/command/message.rst
@@ -3,30 +3,67 @@ message
Display a message to the user.
-::
+.. code-block:: cmake
message([<mode>] "message to display" ...)
The optional ``<mode>`` keyword determines the type of message:
-::
-
- (none) = Important information
- STATUS = Incidental information
- WARNING = CMake Warning, continue processing
- AUTHOR_WARNING = CMake Warning (dev), continue processing
- SEND_ERROR = CMake Error, continue processing,
- but skip generation
- FATAL_ERROR = CMake Error, stop processing and generation
- DEPRECATION = CMake Deprecation Error or Warning if variable
- CMAKE_ERROR_DEPRECATED or CMAKE_WARN_DEPRECATED
- is enabled, respectively, else no message.
-
-The CMake command-line tool displays STATUS messages on stdout and all
-other message types on stderr. The CMake GUI displays all messages in
-its log area. The interactive dialogs (ccmake and CMakeSetup) show
-STATUS messages one at a time on a status line and other messages in
-interactive pop-up boxes.
+``FATAL_ERROR``
+ CMake Error, stop processing and generation.
+
+``SEND_ERROR``
+ CMake Error, continue processing, but skip generation.
+
+``WARNING``
+ CMake Warning, continue processing.
+
+``AUTHOR_WARNING``
+ CMake Warning (dev), continue processing.
+
+``DEPRECATION``
+ CMake Deprecation Error or Warning if variable
+ :variable:`CMAKE_ERROR_DEPRECATED` or :variable:`CMAKE_WARN_DEPRECATED`
+ is enabled, respectively, else no message.
+
+(none) or ``NOTICE``
+ Important message printed to stderr to attract user's attention.
+
+``STATUS``
+ The main interesting messages that project users might be interested in.
+ Ideally these should be concise, no more than a single line, but still
+ informative.
+
+``VERBOSE``
+ Detailed informational messages intended for project users. These messages
+ should provide additional details that won't be of interest in most cases,
+ but which may be useful to those building the project when they want deeper
+ insight into what's happening.
+
+``DEBUG``
+ Detailed informational messages intended for developers working on the
+ project itself as opposed to users who just want to build it. These messages
+ will not typically be of interest to other users building the project and
+ will often be closely related to internal implementation details.
+
+``TRACE``
+ Fine-grained messages with very low-level implementation details. Messages
+ using this log level would normally only be temporary and would expect to be
+ removed before releasing the project, packaging up the files, etc.
+
+The CMake command-line tool displays ``STATUS`` to ``TRACE`` messages on stdout
+with the message preceded by two hyphens and a space. All other message types
+are sent to stderr and are not prefixed with hyphens. The
+:manual:`CMake GUI <cmake-gui(1)>` displays all messages in its log area.
+The :manual:`curses interface <ccmake(1)>` shows ``STATUS`` to ``TRACE``
+messages one at a time on a status line and other messages in an
+interactive pop-up box. The ``--log-level`` command-line option to each of
+these tools can be used to control which messages will be shown.
+
+Messages of log levels ``NOTICE`` and below will also have each line preceded
+by the content of the :variable:`CMAKE_MESSAGE_INDENT` variable (converted to
+a single string by concatenating its list items). For ``STATUS`` to ``TRACE``
+messages, this indenting content will be inserted after the hyphens.
CMake Warning and Error message text displays using a simple markup
language. Non-indented text is formatted in line-wrapped paragraphs
diff --git a/Help/command/option.rst b/Help/command/option.rst
index 91cd0a778..8956307c5 100644
--- a/Help/command/option.rst
+++ b/Help/command/option.rst
@@ -1,15 +1,16 @@
option
------
-Provides an option that the user can optionally select.
+Provide an option that the user can optionally select.
-::
+.. code-block:: cmake
- option(<option_variable> "help string describing option"
- [initial value])
+ option(<variable> "<help_text>" [value])
-Provide an option for the user to select as ``ON`` or ``OFF``. If no
-initial value is provided, ``OFF`` is used.
+Provides an option for the user to select as ``ON`` or ``OFF``.
+If no initial ``<value>`` is provided, ``OFF`` is used.
+If ``<variable>`` is already set as a normal variable
+then the command does nothing (see policy :policy:`CMP0077`).
If you have options that depend on the values of other options, see
the module help for :module:`CMakeDependentOption`.
diff --git a/Help/command/output_required_files.rst b/Help/command/output_required_files.rst
index 5e1355763..b3a6e8653 100644
--- a/Help/command/output_required_files.rst
+++ b/Help/command/output_required_files.rst
@@ -1,7 +1,7 @@
output_required_files
---------------------
-Disallowed. See CMake Policy :policy:`CMP0032`.
+Disallowed since version 3.0. See CMake Policy :policy:`CMP0032`.
Approximate C preprocessor dependency scanning.
@@ -14,6 +14,6 @@ more advanced scanner.
output_required_files(srcfile outputfile)
Outputs a list of all the source files that are required by the
-specified srcfile. This list is written into outputfile. This is
-similar to writing out the dependencies for srcfile except that it
-jumps from .h files into .cxx, .c and .cpp files if possible.
+specified ``srcfile``. This list is written into ``outputfile``. This is
+similar to writing out the dependencies for ``srcfile`` except that it
+jumps from ``.h`` files into ``.cxx``, ``.c`` and ``.cpp`` files if possible.
diff --git a/Help/command/project.rst b/Help/command/project.rst
index 139f69c9b..395145619 100644
--- a/Help/command/project.rst
+++ b/Help/command/project.rst
@@ -1,69 +1,130 @@
project
-------
-Set a name, version, and enable languages for the entire project.
+Set the name of the project.
+
+Synopsis
+^^^^^^^^
.. code-block:: cmake
- project(<PROJECT-NAME> [LANGUAGES] [<language-name>...])
+ project(<PROJECT-NAME> [<language-name>...])
project(<PROJECT-NAME>
[VERSION <major>[.<minor>[.<patch>[.<tweak>]]]]
[DESCRIPTION <project-description-string>]
+ [HOMEPAGE_URL <url-string>]
[LANGUAGES <language-name>...])
-Sets the name of the project and stores the name in the
-:variable:`PROJECT_NAME` variable. Additionally this sets variables
+Sets the name of the project, and stores it in the variable
+:variable:`PROJECT_NAME`. When called from the top-level
+``CMakeLists.txt`` also stores the project name in the
+variable :variable:`CMAKE_PROJECT_NAME`.
+
+Also sets the variables
* :variable:`PROJECT_SOURCE_DIR`,
:variable:`<PROJECT-NAME>_SOURCE_DIR`
* :variable:`PROJECT_BINARY_DIR`,
:variable:`<PROJECT-NAME>_BINARY_DIR`
-If ``VERSION`` is specified, given components must be non-negative integers.
-If ``VERSION`` is not specified, the default version is the empty string.
-The ``VERSION`` option may not be used unless policy :policy:`CMP0048` is
-set to ``NEW``.
-
-The :command:`project()` command stores the version number and its components
-in variables
-
-* :variable:`PROJECT_VERSION`,
- :variable:`<PROJECT-NAME>_VERSION`
-* :variable:`PROJECT_VERSION_MAJOR`,
- :variable:`<PROJECT-NAME>_VERSION_MAJOR`
-* :variable:`PROJECT_VERSION_MINOR`,
- :variable:`<PROJECT-NAME>_VERSION_MINOR`
-* :variable:`PROJECT_VERSION_PATCH`,
- :variable:`<PROJECT-NAME>_VERSION_PATCH`
-* :variable:`PROJECT_VERSION_TWEAK`,
- :variable:`<PROJECT-NAME>_VERSION_TWEAK`
-
-Variables corresponding to unspecified versions are set to the empty string
-(if policy :policy:`CMP0048` is set to ``NEW``).
-
-If optional ``DESCRIPTION`` is given, then additional :variable:`PROJECT_DESCRIPTION`
-variable will be set to its argument. The argument must be a string with short
-description of the project (only a few words).
-
-Optionally you can specify which languages your project supports.
-Example languages are ``C``, ``CXX`` (i.e. C++), ``Fortran``, etc.
-By default ``C`` and ``CXX`` are enabled if no language options are
-given. Specify language ``NONE``, or use the ``LANGUAGES`` keyword
-and list no languages, to skip enabling any languages.
-
-If a variable exists called :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`,
-the file pointed to by that variable will be included as the last step of the
-project command.
+Further variables are set by the optional arguments described in the following.
+If any of these arguments is not used, then the corresponding variables are
+set to the empty string.
+
+Options
+^^^^^^^
+
+The options are:
+
+``VERSION <version>``
+ Optional; may not be used unless policy :policy:`CMP0048` is
+ set to ``NEW``.
+
+ Takes a ``<version>`` argument composed of non-negative integer components,
+ i.e. ``<major>[.<minor>[.<patch>[.<tweak>]]]``,
+ and sets the variables
+
+ * :variable:`PROJECT_VERSION`,
+ :variable:`<PROJECT-NAME>_VERSION`
+ * :variable:`PROJECT_VERSION_MAJOR`,
+ :variable:`<PROJECT-NAME>_VERSION_MAJOR`
+ * :variable:`PROJECT_VERSION_MINOR`,
+ :variable:`<PROJECT-NAME>_VERSION_MINOR`
+ * :variable:`PROJECT_VERSION_PATCH`,
+ :variable:`<PROJECT-NAME>_VERSION_PATCH`
+ * :variable:`PROJECT_VERSION_TWEAK`,
+ :variable:`<PROJECT-NAME>_VERSION_TWEAK`.
+
+ When the ``project()`` command is called from the top-level ``CMakeLists.txt``,
+ then the version is also stored in the variable :variable:`CMAKE_PROJECT_VERSION`.
+
+``DESCRIPTION <project-description-string>``
+ Optional.
+ Sets the variables
+
+ * :variable:`PROJECT_DESCRIPTION`, :variable:`<PROJECT-NAME>_DESCRIPTION`
+
+ to ``<project-description-string>``.
+ It is recommended that this description is a relatively short string,
+ usually no more than a few words.
+
+ When the ``project()`` command is called from the top-level ``CMakeLists.txt``,
+ then the description is also stored in the variable :variable:`CMAKE_PROJECT_DESCRIPTION`.
+
+``HOMEPAGE_URL <url-string>``
+ Optional.
+ Sets the variables
+
+ * :variable:`PROJECT_HOMEPAGE_URL`, :variable:`<PROJECT-NAME>_HOMEPAGE_URL`
+
+ to ``<url-string>``, which should be the canonical home URL for the project.
+
+ When the ``project()`` command is called from the top-level ``CMakeLists.txt``,
+ then the URL also is stored in the variable :variable:`CMAKE_PROJECT_HOMEPAGE_URL`.
+
+``LANGUAGES <language-name>...``
+ Optional.
+ Can also be specified without ``LANGUAGES`` keyword per the first, short signature.
+
+ Selects which programming languages are needed to build the project.
+ Supported languages include ``C``, ``CXX`` (i.e. C++), ``CUDA``,
+ ``OBJC`` (i.e. Objective-C), ``OBJCXX``, ``Fortran``, and ``ASM``.
+ By default ``C`` and ``CXX`` are enabled if no language options are given.
+ Specify language ``NONE``, or use the ``LANGUAGES`` keyword and list no languages,
+ to skip enabling any languages.
+
+ If enabling ``ASM``, list it last so that CMake can check whether
+ compilers for other languages like ``C`` work for assembly too.
+
+The variables set through the ``VERSION``, ``DESCRIPTION`` and ``HOMEPAGE_URL``
+options are intended for use as default values in package metadata and documentation.
+
+Code Injection
+^^^^^^^^^^^^^^
+
+If the :variable:`CMAKE_PROJECT_INCLUDE_BEFORE` variable is set, the file
+pointed to by that variable will be included as the first step of the
+``project()`` command.
+
+If the :variable:`CMAKE_PROJECT_INCLUDE` or
+:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE` variables are set, the files
+they point to will be included as the last step of the ``project()`` command.
+If both are set, then :variable:`CMAKE_PROJECT_INCLUDE` will be included before
+:variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`.
+
+Usage
+^^^^^
The top-level ``CMakeLists.txt`` file for a project must contain a
-literal, direct call to the :command:`project` command; loading one
+literal, direct call to the ``project()`` command; loading one
through the :command:`include` command is not sufficient. If no such
-call exists CMake will implicitly add one to the top that enables the
-default languages (``C`` and ``CXX``).
+call exists, CMake will issue a warning and pretend there is a
+``project(Project)`` at the top to enable the default languages
+(``C`` and ``CXX``).
.. note::
- Call the :command:`cmake_minimum_required` command at the beginning
- of the top-level ``CMakeLists.txt`` file even before calling the
- ``project()`` command. It is important to establish version and
- policy settings before invoking other commands whose behavior they
- may affect. See also policy :policy:`CMP0000`.
+ Call the ``project()`` command near the top of the top-level
+ ``CMakeLists.txt``, but *after* calling :command:`cmake_minimum_required`.
+ It is important to establish version and policy settings before invoking
+ other commands whose behavior they may affect.
+ See also policy :policy:`CMP0000`.
diff --git a/Help/command/qt_wrap_cpp.rst b/Help/command/qt_wrap_cpp.rst
index 3843bf5e9..ce11c2d09 100644
--- a/Help/command/qt_wrap_cpp.rst
+++ b/Help/command/qt_wrap_cpp.rst
@@ -1,12 +1,23 @@
qt_wrap_cpp
-----------
-Create Qt Wrappers.
+.. deprecated:: 3.14
-::
+ This command was originally added to support Qt 3 before the
+ :command:`add_custom_command()` command was sufficiently mature. The
+ :module:`FindQt4` module provides the ``qt4_wrap_cpp()`` macro, which
+ should be used instead for Qt 4 projects. For projects using Qt 5 or
+ later, use the equivalent macro provided by Qt itself (e.g. Qt 5 provides
+ ``qt5_wrap_cpp()``).
- qt_wrap_cpp(resultingLibraryName DestName
- SourceLists ...)
+Manually create Qt Wrappers.
-Produce moc files for all the .h files listed in the SourceLists. The
+.. code-block:: cmake
+
+ qt_wrap_cpp(resultingLibraryName DestName SourceLists ...)
+
+Produces moc files for all the .h files listed in the SourceLists. The
moc files will be added to the library using the ``DestName`` source list.
+
+Consider updating the project to use the :prop_tgt:`AUTOMOC` target property
+instead for a more automated way of invoking the ``moc`` tool.
diff --git a/Help/command/qt_wrap_ui.rst b/Help/command/qt_wrap_ui.rst
index f731ed9a8..efbbc5472 100644
--- a/Help/command/qt_wrap_ui.rst
+++ b/Help/command/qt_wrap_ui.rst
@@ -1,14 +1,26 @@
qt_wrap_ui
----------
-Create Qt user interfaces Wrappers.
+.. deprecated:: 3.14
-::
+ This command was originally added to support Qt 3 before the
+ :command:`add_custom_command()` command was sufficiently mature. The
+ :module:`FindQt4` module provides the ``qt4_wrap_ui()`` macro, which
+ should be used instead for Qt 4 projects. For projects using Qt 5 or
+ later, use the equivalent macro provided by Qt itself (e.g. Qt 5 provides
+ ``qt5_wrap_ui()``).
+
+Manually create Qt user interfaces Wrappers.
+
+.. code-block:: cmake
qt_wrap_ui(resultingLibraryName HeadersDestName
SourcesDestName SourceLists ...)
-Produce .h and .cxx files for all the .ui files listed in the
+Produces .h and .cxx files for all the .ui files listed in the
``SourceLists``. The .h files will be added to the library using the
``HeadersDestNamesource`` list. The .cxx files will be added to the
library using the ``SourcesDestNamesource`` list.
+
+Consider updating the project to use the :prop_tgt:`AUTOUIC` target property
+instead for a more automated way of invoking the ``uic`` tool.
diff --git a/Help/command/remove.rst b/Help/command/remove.rst
index 462827796..543d01671 100644
--- a/Help/command/remove.rst
+++ b/Help/command/remove.rst
@@ -1,7 +1,9 @@
remove
------
-Deprecated. Use the :command:`list(REMOVE_ITEM)` command instead.
+.. deprecated:: 3.0
+
+ Use the :command:`list(REMOVE_ITEM)` command instead.
::
diff --git a/Help/command/remove_definitions.rst b/Help/command/remove_definitions.rst
index ea189181c..faad16dcb 100644
--- a/Help/command/remove_definitions.rst
+++ b/Help/command/remove_definitions.rst
@@ -1,9 +1,9 @@
remove_definitions
------------------
-Removes -D define flags added by :command:`add_definitions`.
+Remove -D define flags added by :command:`add_definitions`.
-::
+.. code-block:: cmake
remove_definitions(-DFOO -DBAR ...)
diff --git a/Help/command/return.rst b/Help/command/return.rst
index e49fb3c8d..830992c25 100644
--- a/Help/command/return.rst
+++ b/Help/command/return.rst
@@ -3,7 +3,7 @@ return
Return from a file, directory or function.
-::
+.. code-block:: cmake
return()
@@ -14,5 +14,6 @@ and control is returned to the including file. If it is encountered in a
file which is not included by another file, e.g. a ``CMakeLists.txt``,
control is returned to the parent directory if there is one. If return is
called in a function, control is returned to the caller of the function.
-Note that a macro is not a function and does not handle return like a
-function does.
+
+Note that a :command:`macro <macro>`, unlike a :command:`function <function>`,
+is expanded in place and therefore cannot handle ``return()``.
diff --git a/Help/command/separate_arguments.rst b/Help/command/separate_arguments.rst
index 47982a503..fbca859f2 100644
--- a/Help/command/separate_arguments.rst
+++ b/Help/command/separate_arguments.rst
@@ -1,33 +1,43 @@
separate_arguments
------------------
-Parse space-separated arguments into a semicolon-separated list.
+Parse command-line arguments into a semicolon-separated list.
-::
+.. code-block:: cmake
- separate_arguments(<var> <NATIVE|UNIX|WINDOWS>_COMMAND "<args>")
+ separate_arguments(<variable> <mode> <args>)
-Parses a UNIX- or Windows-style command-line string "<args>" and
-stores a semicolon-separated list of the arguments in ``<var>``. The
-entire command line must be given in one "<args>" argument.
+Parses a space-separated string ``<args>`` into a list of items,
+and stores this list in semicolon-separated standard form in ``<variable>``.
-The ``UNIX_COMMAND`` mode separates arguments by unquoted whitespace. It
-recognizes both single-quote and double-quote pairs. A backslash
-escapes the next literal character (``\"`` is ``"``); there are no special
-escapes (``\n`` is just ``n``).
+This function is intended for parsing command-line arguments.
+The entire command line must be passed as one string in the
+argument ``<args>``.
-The ``WINDOWS_COMMAND`` mode parses a Windows command-line using the same
-syntax the runtime library uses to construct argv at startup. It
-separates arguments by whitespace that is not double-quoted.
-Backslashes are literal unless they precede double-quotes. See the
-MSDN article `Parsing C Command-Line Arguments`_ for details.
+The exact parsing rules depend on the operating system.
+They are specified by the ``<mode>`` argument which must
+be one of the following keywords:
-The ``NATIVE_COMMAND`` mode parses a Windows command-line if the host
-system is Windows, and a UNIX command-line otherwise.
+``UNIX_COMMAND``
+ Arguments are separated by by unquoted whitespace.
+ Both single-quote and double-quote pairs are respected.
+ A backslash escapes the next literal character (``\"`` is ``"``);
+ there are no special escapes (``\n`` is just ``n``).
+
+``WINDOWS_COMMAND``
+ A Windows command-line is parsed using the same
+ syntax the runtime library uses to construct argv at startup. It
+ separates arguments by whitespace that is not double-quoted.
+ Backslashes are literal unless they precede double-quotes. See the
+ MSDN article `Parsing C Command-Line Arguments`_ for details.
+
+``NATIVE_COMMAND``
+ Proceeds as in ``WINDOWS_COMMAND`` mode if the host system is Windows.
+ Otherwise proceeds as in ``UNIX_COMMAND`` mode.
.. _`Parsing C Command-Line Arguments`: https://msdn.microsoft.com/library/a1y7w461.aspx
-::
+.. code-block:: cmake
separate_arguments(<var>)
diff --git a/Help/command/set.rst b/Help/command/set.rst
index b24ebefeb..c0e02e246 100644
--- a/Help/command/set.rst
+++ b/Help/command/set.rst
@@ -8,18 +8,18 @@ and cache entries.
Signatures of this command that specify a ``<value>...`` placeholder
expect zero or more arguments. Multiple arguments will be joined as
-a :ref:`;-list <CMake Language Lists>` to form the actual variable
+a :ref:`semicolon-separated list <CMake Language Lists>` to form the actual variable
value to be set. Zero arguments will cause normal variables to be
unset. See the :command:`unset` command to unset variables explicitly.
Set Normal Variable
^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
set(<variable> <value>... [PARENT_SCOPE])
-Set the given ``<variable>`` in the current function or directory scope.
+Sets the given ``<variable>`` in the current function or directory scope.
If the ``PARENT_SCOPE`` option is given the variable will be set in
the scope above the current scope. Each new directory or function
@@ -32,11 +32,11 @@ undefined and if it had a value, it is still that value).
Set Cache Entry
^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
set(<variable> <value>... CACHE <type> <docstring> [FORCE])
-Set the given cache ``<variable>`` (cache entry). Since cache entries
+Sets the given cache ``<variable>`` (cache entry). Since cache entries
are meant to provide user-settable values this does not overwrite
existing cache entries by default. Use the ``FORCE`` option to
overwrite existing entries.
@@ -84,8 +84,21 @@ current working directory and convert it to an absolute path.
Set Environment Variable
^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
- set(ENV{<variable>} <value>...)
+ set(ENV{<variable>} [<value>])
-Set the current process environment ``<variable>`` to the given value.
+Sets an :manual:`Environment Variable <cmake-env-variables(7)>`
+to the given value.
+Subsequent calls of ``$ENV{<variable>}`` will return this new value.
+
+This command affects only the current CMake process, not the process
+from which CMake was called, nor the system environment at large,
+nor the environment of subsequent build or test processes.
+
+If no argument is given after ``ENV{<variable>}`` or if ``<value>`` is
+an empty string, then this command will clear any existing value of the
+environment variable.
+
+Arguments after ``<value>`` are ignored. If extra arguments are found,
+then an author warning is issued.
diff --git a/Help/command/set_directory_properties.rst b/Help/command/set_directory_properties.rst
index e485fce0a..f02a8e6c7 100644
--- a/Help/command/set_directory_properties.rst
+++ b/Help/command/set_directory_properties.rst
@@ -1,12 +1,15 @@
set_directory_properties
------------------------
-Set a property of the directory.
+Set properties of the current directory and subdirectories.
-::
+.. code-block:: cmake
- set_directory_properties(PROPERTIES prop1 value1 prop2 value2)
+ set_directory_properties(PROPERTIES prop1 value1 [prop2 value2] ...)
-Set a property for the current directory and subdirectories. See
-:ref:`Directory Properties` for the list of properties known
-to CMake.
+Sets properties of the current directory and its subdirectories in key-value pairs.
+
+See also the :command:`set_property(DIRECTORY)` command.
+
+See :ref:`Directory Properties` for the list of properties known to CMake
+and their individual documentation for the behavior of each property.
diff --git a/Help/command/set_property.rst b/Help/command/set_property.rst
index 5ed788e4a..ec08c8f99 100644
--- a/Help/command/set_property.rst
+++ b/Help/command/set_property.rst
@@ -3,37 +3,40 @@ set_property
Set a named property in a given scope.
-::
-
- set_property(<GLOBAL |
- DIRECTORY [dir] |
- TARGET [target1 [target2 ...]] |
- SOURCE [src1 [src2 ...]] |
- INSTALL [file1 [file2 ...]] |
- TEST [test1 [test2 ...]] |
- CACHE [entry1 [entry2 ...]]>
+.. code-block:: cmake
+
+ set_property(<GLOBAL |
+ DIRECTORY [<dir>] |
+ TARGET [<target1> ...] |
+ SOURCE [<src1> ...] |
+ INSTALL [<file1> ...] |
+ TEST [<test1> ...] |
+ CACHE [<entry1> ...] >
[APPEND] [APPEND_STRING]
- PROPERTY <name> [value1 [value2 ...]])
+ PROPERTY <name> [value1 ...])
-Set one property on zero or more objects of a scope. The first
-argument determines the scope in which the property is set. It must
-be one of the following:
+Sets one property on zero or more objects of a scope.
+
+The first argument determines the scope in which the property is set.
+It must be one of the following:
``GLOBAL``
Scope is unique and does not accept a name.
``DIRECTORY``
- Scope defaults to the current directory but another
- directory (already processed by CMake) may be named by full or
- relative path.
+ Scope defaults to the current directory but another directory
+ (already processed by CMake) may be named by full or relative path.
+ See also the :command:`set_directory_properties` command.
``TARGET``
Scope may name zero or more existing targets.
+ See also the :command:`set_target_properties` command.
``SOURCE``
Scope may name zero or more source files. Note that source
file properties are visible only to targets added in the same
- directory (CMakeLists.txt).
+ directory (``CMakeLists.txt``).
+ See also the :command:`set_source_files_properties` command.
``INSTALL``
Scope may name zero or more installed file paths.
@@ -45,7 +48,7 @@ be one of the following:
Path components have to be separated by forward slashes,
must be normalized and are case sensitive.
- To reference the installation prefix itself with a relative path use ".".
+ To reference the installation prefix itself with a relative path use ``.``.
Currently installed file properties are only defined for
the WIX generator where the given paths are relative
@@ -53,17 +56,24 @@ be one of the following:
``TEST``
Scope may name zero or more existing tests.
+ See also the :command:`set_tests_properties` command.
``CACHE``
Scope must name zero or more cache existing entries.
The required ``PROPERTY`` option is immediately followed by the name of
the property to set. Remaining arguments are used to compose the
-property value in the form of a semicolon-separated list. If the
-``APPEND`` option is given the list is appended to any existing property
-value. If the ``APPEND_STRING`` option is given the string is append to any
-existing property value as string, i.e. it results in a longer string
-and not a list of strings.
+property value in the form of a semicolon-separated list.
+
+If the ``APPEND`` option is given the list is appended to any existing
+property value. If the ``APPEND_STRING`` option is given the string is
+appended to any existing property value as string, i.e. it results in a
+longer string and not a list of strings. When using ``APPEND`` or
+``APPEND_STRING`` with a property defined to support ``INHERITED``
+behavior (see :command:`define_property`), no inheriting occurs when
+finding the initial value to append to. If the property is not already
+directly set in the nominated scope, the command will behave as though
+``APPEND`` or ``APPEND_STRING`` had not been given.
See the :manual:`cmake-properties(7)` manual for a list of properties
in each scope.
diff --git a/Help/command/set_source_files_properties.rst b/Help/command/set_source_files_properties.rst
index b4904e8d0..ab95d7094 100644
--- a/Help/command/set_source_files_properties.rst
+++ b/Help/command/set_source_files_properties.rst
@@ -3,13 +3,17 @@ set_source_files_properties
Source files can have properties that affect how they are built.
-::
+.. code-block:: cmake
set_source_files_properties([file1 [file2 [...]]]
PROPERTIES prop1 value1
[prop2 value2 [...]])
-Set properties associated with source files using a key/value paired
-list. See :ref:`Source File Properties` for the list of properties known
+Sets properties associated with source files using a key/value paired
+list.
+
+See also the :command:`set_property(SOURCE)` command.
+
+See :ref:`Source File Properties` for the list of properties known
to CMake. Source file properties are visible only to targets added
-in the same directory (CMakeLists.txt).
+in the same directory (``CMakeLists.txt``).
diff --git a/Help/command/set_target_properties.rst b/Help/command/set_target_properties.rst
index b894eace3..597be231a 100644
--- a/Help/command/set_target_properties.rst
+++ b/Help/command/set_target_properties.rst
@@ -3,16 +3,18 @@ set_target_properties
Targets can have properties that affect how they are built.
-::
+.. code-block:: cmake
set_target_properties(target1 target2 ...
PROPERTIES prop1 value1
prop2 value2 ...)
-Set properties on a target. The syntax for the command is to list all
-the files you want to change, and then provide the values you want to
+Sets properties on targets. The syntax for the command is to list all
+the targets you want to change, and then provide the values you want to
set next. You can use any prop value pair you want and extract it
later with the :command:`get_property` or :command:`get_target_property`
command.
+See also the :command:`set_property(TARGET)` command.
+
See :ref:`Target Properties` for the list of properties known to CMake.
diff --git a/Help/command/set_tests_properties.rst b/Help/command/set_tests_properties.rst
index 3efb1653e..9bc94ae38 100644
--- a/Help/command/set_tests_properties.rst
+++ b/Help/command/set_tests_properties.rst
@@ -3,12 +3,15 @@ set_tests_properties
Set a property of the tests.
-::
+.. code-block:: cmake
set_tests_properties(test1 [test2...] PROPERTIES prop1 value1 prop2 value2)
-Set a property for the tests. If the test is not found, CMake
+Sets a property for the tests. If the test is not found, CMake
will report an error.
:manual:`Generator expressions <cmake-generator-expressions(7)>` will be
-expanded the same as supported by the test's :command:`add_test` call. See
-:ref:`Test Properties` for the list of properties known to CMake.
+expanded the same as supported by the test's :command:`add_test` call.
+
+See also the :command:`set_property(TEST)` command.
+
+See :ref:`Test Properties` for the list of properties known to CMake.
diff --git a/Help/command/site_name.rst b/Help/command/site_name.rst
index e17c1ee68..1bcaeada0 100644
--- a/Help/command/site_name.rst
+++ b/Help/command/site_name.rst
@@ -3,6 +3,6 @@ site_name
Set the given variable to the name of the computer.
-::
+.. code-block:: cmake
site_name(variable)
diff --git a/Help/command/source_group.rst b/Help/command/source_group.rst
index 938ca40f2..6623c9837 100644
--- a/Help/command/source_group.rst
+++ b/Help/command/source_group.rst
@@ -4,7 +4,7 @@ source_group
Define a grouping for source files in IDE project generation.
There are two different signatures to create source groups.
-::
+.. code-block:: cmake
source_group(<name> [FILES <src>...] [REGULAR_EXPRESSION <regex>])
source_group(TREE <root> [PREFIX <prefix>] [FILES <src>...])
diff --git a/Help/command/string.rst b/Help/command/string.rst
index 4f0c45c29..81a206112 100644
--- a/Help/command/string.rst
+++ b/Help/command/string.rst
@@ -1,81 +1,120 @@
string
------
-.. only:: html
-
- .. contents::
-
String operations.
+Synopsis
+^^^^^^^^
+
+.. parsed-literal::
+
+ `Search and Replace`_
+ string(`FIND`_ <string> <substring> <out-var> [...])
+ string(`REPLACE`_ <match-string> <replace-string> <out-var> <input>...)
+
+ `Regular Expressions`_
+ string(`REGEX MATCH`_ <match-regex> <out-var> <input>...)
+ string(`REGEX MATCHALL`_ <match-regex> <out-var> <input>...)
+ string(`REGEX REPLACE`_ <match-regex> <replace-expr> <out-var> <input>...)
+
+ `Manipulation`_
+ string(`APPEND`_ <string-var> [<input>...])
+ string(`PREPEND`_ <string-var> [<input>...])
+ string(`CONCAT`_ <out-var> [<input>...])
+ string(`JOIN`_ <glue> <out-var> [<input>...])
+ string(`TOLOWER`_ <string> <out-var>)
+ string(`TOUPPER`_ <string> <out-var>)
+ string(`LENGTH`_ <string> <out-var>)
+ string(`SUBSTRING`_ <string> <begin> <length> <out-var>)
+ string(`STRIP`_ <string> <out-var>)
+ string(`GENEX_STRIP`_ <string> <out-var>)
+ string(`REPEAT`_ <string> <count> <out-var>)
+
+ `Comparison`_
+ string(`COMPARE`_ <op> <string1> <string2> <out-var>)
+
+ `Hashing`_
+ string(`\<HASH\> <HASH_>`_ <out-var> <input>)
+
+ `Generation`_
+ string(`ASCII`_ <number>... <out-var>)
+ string(`CONFIGURE`_ <string> <out-var> [...])
+ string(`MAKE_C_IDENTIFIER`_ <string> <out-var>)
+ string(`RANDOM`_ [<option>...] <out-var>)
+ string(`TIMESTAMP`_ <out-var> [<format string>] [UTC])
+ string(`UUID`_ <out-var> ...)
+
Search and Replace
^^^^^^^^^^^^^^^^^^
-FIND
-""""
+.. _FIND:
-::
+.. code-block:: cmake
- string(FIND <string> <substring> <output variable> [REVERSE])
+ string(FIND <string> <substring> <output_variable> [REVERSE])
-Return the position where the given substring was found in
-the supplied string. If the ``REVERSE`` flag was used, the command will
+Return the position where the given ``<substring>`` was found in
+the supplied ``<string>``. If the ``REVERSE`` flag was used, the command will
search for the position of the last occurrence of the specified
-substring. If the substring is not found, a position of -1 is returned.
+``<substring>``. If the ``<substring>`` is not found, a position of -1 is
+returned.
-REPLACE
-"""""""
+The ``string(FIND)`` subcommand treats all strings as ASCII-only characters.
+The index stored in ``<output_variable>`` will also be counted in bytes,
+so strings containing multi-byte characters may lead to unexpected results.
-::
+.. _REPLACE:
+
+.. code-block:: cmake
string(REPLACE <match_string>
- <replace_string> <output variable>
+ <replace_string> <output_variable>
<input> [<input>...])
-Replace all occurrences of ``match_string`` in the input
-with ``replace_string`` and store the result in the output.
+Replace all occurrences of ``<match_string>`` in the ``<input>``
+with ``<replace_string>`` and store the result in the ``<output_variable>``.
Regular Expressions
^^^^^^^^^^^^^^^^^^^
-REGEX MATCH
-"""""""""""
+.. _`REGEX MATCH`:
-::
+.. code-block:: cmake
string(REGEX MATCH <regular_expression>
- <output variable> <input> [<input>...])
+ <output_variable> <input> [<input>...])
-Match the regular expression once and store the match in the output variable.
+Match the ``<regular_expression>`` once and store the match in the
+``<output_variable>``.
All ``<input>`` arguments are concatenated before matching.
-REGEX MATCHALL
-""""""""""""""
+.. _`REGEX MATCHALL`:
-::
+.. code-block:: cmake
string(REGEX MATCHALL <regular_expression>
- <output variable> <input> [<input>...])
+ <output_variable> <input> [<input>...])
-Match the regular expression as many times as possible and store the matches
-in the output variable as a list.
+Match the ``<regular_expression>`` as many times as possible and store the
+matches in the ``<output_variable>`` as a list.
All ``<input>`` arguments are concatenated before matching.
-REGEX REPLACE
-"""""""""""""
+.. _`REGEX REPLACE`:
-::
+.. code-block:: cmake
string(REGEX REPLACE <regular_expression>
- <replace_expression> <output variable>
+ <replacement_expression> <output_variable>
<input> [<input>...])
-Match the regular expression as many times as possible and substitute the
-replacement expression for the match in the output.
+Match the ``<regular_expression>`` as many times as possible and substitute
+the ``<replacement_expression>`` for the match in the output.
All ``<input>`` arguments are concatenated before matching.
-The replace expression may refer to paren-delimited subexpressions of the
-match using ``\1``, ``\2``, ..., ``\9``. Note that two backslashes (``\\1``)
-are required in CMake code to get a backslash through argument parsing.
+The ``<replacement_expression>`` may refer to parenthesis-delimited
+subexpressions of the match using ``\1``, ``\2``, ..., ``\9``. Note that
+two backslashes (``\\1``) are required in CMake code to get a backslash
+through argument parsing.
.. _`Regex Specification`:
@@ -90,6 +129,11 @@ The following characters have special meaning in regular expressions:
Matches at end of input
``.``
Matches any single character
+``\<char>``
+ Matches the single character specified by ``<char>``. Use this to
+ match special regex characters, e.g. ``\.`` for a literal ``.``
+ or ``\\`` for a literal backslash ``\``. Escaping a non-special
+ character is unnecessary but allowed, e.g. ``\a`` matches ``a``.
``[ ]``
Matches any character(s) inside the brackets
``[^ ]``
@@ -120,114 +164,161 @@ has lower precedence than concatenation. This means that the regular
expression ``^ab+d$`` matches ``abbd`` but not ``ababd``, and the regular
expression ``^(ab|cd)$`` matches ``ab`` but not ``abd``.
+CMake language :ref:`Escape Sequences` such as ``\t``, ``\r``, ``\n``,
+and ``\\`` may be used to construct literal tabs, carriage returns,
+newlines, and backslashes (respectively) to pass in a regex. For example:
+
+* The quoted argument ``"[ \t\r\n]"`` specifies a regex that matches
+ any single whitespace character.
+* The quoted argument ``"[/\\]"`` specifies a regex that matches
+ a single forward slash ``/`` or backslash ``\``.
+* The quoted argument ``"[A-Za-z0-9_]"`` specifies a regex that matches
+ any single "word" character in the C locale.
+* The quoted argument ``"\\(\\a\\+b\\)"`` specifies a regex that matches
+ the exact string ``(a+b)``. Each ``\\`` is parsed in a quoted argument
+ as just ``\``, so the regex itself is actually ``\(\a\+\b\)``. This
+ can alternatively be specified in a :ref:`bracket argument` without
+ having to escape the backslashes, e.g. ``[[\(\a\+\b\)]]``.
+
Manipulation
^^^^^^^^^^^^
-APPEND
-""""""
+.. _APPEND:
-::
+.. code-block:: cmake
- string(APPEND <string variable> [<input>...])
+ string(APPEND <string_variable> [<input>...])
-Append all the input arguments to the string.
+Append all the ``<input>`` arguments to the string.
-CONCAT
-""""""
+.. _PREPEND:
-::
+.. code-block:: cmake
- string(CONCAT <output variable> [<input>...])
+ string(PREPEND <string_variable> [<input>...])
-Concatenate all the input arguments together and store
-the result in the named output variable.
+Prepend all the ``<input>`` arguments to the string.
-TOLOWER
-"""""""
+.. _CONCAT:
-::
+.. code-block:: cmake
- string(TOLOWER <string1> <output variable>)
+ string(CONCAT <output_variable> [<input>...])
-Convert string to lower characters.
+Concatenate all the ``<input>`` arguments together and store
+the result in the named ``<output_variable>``.
-TOUPPER
-"""""""
+.. _JOIN:
-::
+.. code-block:: cmake
- string(TOUPPER <string1> <output variable>)
+ string(JOIN <glue> <output_variable> [<input>...])
-Convert string to upper characters.
+Join all the ``<input>`` arguments together using the ``<glue>``
+string and store the result in the named ``<output_variable>``.
-LENGTH
-""""""
+To join a list's elements, prefer to use the ``JOIN`` operator
+from the :command:`list` command. This allows for the elements to have
+special characters like ``;`` in them.
-::
+.. _TOLOWER:
- string(LENGTH <string> <output variable>)
+.. code-block:: cmake
-Store in an output variable a given string's length.
+ string(TOLOWER <string> <output_variable>)
-SUBSTRING
-"""""""""
+Convert ``<string>`` to lower characters.
-::
+.. _TOUPPER:
+
+.. code-block:: cmake
+
+ string(TOUPPER <string> <output_variable>)
+
+Convert ``<string>`` to upper characters.
+
+.. _LENGTH:
+
+.. code-block:: cmake
+
+ string(LENGTH <string> <output_variable>)
+
+Store in an ``<output_variable>`` a given string's length in bytes.
+Note that this means if ``<string>`` contains multi-byte characters, the
+result stored in ``<output_variable>`` will *not* be the number of characters.
+
+.. _SUBSTRING:
+
+.. code-block:: cmake
- string(SUBSTRING <string> <begin> <length> <output variable>)
+ string(SUBSTRING <string> <begin> <length> <output_variable>)
-Store in an output variable a substring of a given string. If length is
-``-1`` the remainder of the string starting at begin will be returned.
-If string is shorter than length then end of string is used instead.
+Store in an ``<output_variable>`` a substring of a given ``<string>``. If
+``<length>`` is ``-1`` the remainder of the string starting at ``<begin>``
+will be returned. If ``<string>`` is shorter than ``<length>`` then the
+end of the string is used instead.
+
+Both ``<begin>`` and ``<length>`` are counted in bytes, so care must
+be exercised if ``<string>`` could contain multi-byte characters.
.. note::
- CMake 3.1 and below reported an error if length pointed past
- the end of string.
+ CMake 3.1 and below reported an error if ``<length>`` pointed past
+ the end of ``<string>``.
-STRIP
-"""""
+.. _STRIP:
-::
+.. code-block:: cmake
- string(STRIP <string> <output variable>)
+ string(STRIP <string> <output_variable>)
-Store in an output variable a substring of a given string with leading and
-trailing spaces removed.
+Store in an ``<output_variable>`` a substring of a given ``<string>`` with
+leading and trailing spaces removed.
-GENEX_STRIP
-"""""""""""
+.. _GENEX_STRIP:
-::
+.. code-block:: cmake
- string(GENEX_STRIP <input string> <output variable>)
+ string(GENEX_STRIP <string> <output_variable>)
Strip any :manual:`generator expressions <cmake-generator-expressions(7)>`
-from the ``input string`` and store the result in the ``output variable``.
+from the input ``<string>`` and store the result in the ``<output_variable>``.
+
+.. _REPEAT:
+
+.. code-block:: cmake
+
+ string(REPEAT <string> <count> <output_variable>)
+
+Produce the output string as the input ``<string>`` repeated ``<count>`` times.
Comparison
^^^^^^^^^^
-::
+.. _COMPARE:
+
+.. code-block:: cmake
- string(COMPARE LESS <string1> <string2> <output variable>)
- string(COMPARE GREATER <string1> <string2> <output variable>)
- string(COMPARE EQUAL <string1> <string2> <output variable>)
- string(COMPARE NOTEQUAL <string1> <string2> <output variable>)
- string(COMPARE LESS_EQUAL <string1> <string2> <output variable>)
- string(COMPARE GREATER_EQUAL <string1> <string2> <output variable>)
+ string(COMPARE LESS <string1> <string2> <output_variable>)
+ string(COMPARE GREATER <string1> <string2> <output_variable>)
+ string(COMPARE EQUAL <string1> <string2> <output_variable>)
+ string(COMPARE NOTEQUAL <string1> <string2> <output_variable>)
+ string(COMPARE LESS_EQUAL <string1> <string2> <output_variable>)
+ string(COMPARE GREATER_EQUAL <string1> <string2> <output_variable>)
-Compare the strings and store true or false in the output variable.
+Compare the strings and store true or false in the ``<output_variable>``.
.. _`Supported Hash Algorithms`:
Hashing
^^^^^^^
-::
+.. _`HASH`:
- string(<HASH> <output variable> <input>)
+.. code-block:: cmake
-Compute a cryptographic hash of the input string.
+ string(<HASH> <output_variable> <input>)
+
+Compute a cryptographic hash of the ``<input>`` string.
The supported ``<HASH>`` algorithm names are:
``MD5``
@@ -254,56 +345,63 @@ The supported ``<HASH>`` algorithm names are:
Generation
^^^^^^^^^^
-ASCII
-"""""
+.. _ASCII:
-::
+.. code-block:: cmake
- string(ASCII <number> [<number> ...] <output variable>)
+ string(ASCII <number> [<number> ...] <output_variable>)
Convert all numbers into corresponding ASCII characters.
-CONFIGURE
-"""""""""
+.. _CONFIGURE:
-::
+.. code-block:: cmake
- string(CONFIGURE <string1> <output variable>
+ string(CONFIGURE <string> <output_variable>
[@ONLY] [ESCAPE_QUOTES])
-Transform a string like :command:`configure_file` transforms a file.
+Transform a ``<string>`` like :command:`configure_file` transforms a file.
-RANDOM
-""""""
+.. _MAKE_C_IDENTIFIER:
-::
+.. code-block:: cmake
+
+ string(MAKE_C_IDENTIFIER <string> <output_variable>)
+
+Convert each non-alphanumeric character in the input ``<string>`` to an
+underscore and store the result in the ``<output_variable>``. If the first
+character of the ``<string>`` is a digit, an underscore will also be prepended
+to the result.
+
+.. _RANDOM:
+
+.. code-block:: cmake
string(RANDOM [LENGTH <length>] [ALPHABET <alphabet>]
- [RANDOM_SEED <seed>] <output variable>)
+ [RANDOM_SEED <seed>] <output_variable>)
-Return a random string of given length consisting of
-characters from the given alphabet. Default length is 5 characters
+Return a random string of given ``<length>`` consisting of
+characters from the given ``<alphabet>``. Default length is 5 characters
and default alphabet is all numbers and upper and lower case letters.
If an integer ``RANDOM_SEED`` is given, its value will be used to seed the
random number generator.
-TIMESTAMP
-"""""""""
+.. _TIMESTAMP:
-::
+.. code-block:: cmake
- string(TIMESTAMP <output variable> [<format string>] [UTC])
+ string(TIMESTAMP <output_variable> [<format_string>] [UTC])
Write a string representation of the current date
-and/or time to the output variable.
+and/or time to the ``<output_variable>``.
-Should the command be unable to obtain a timestamp the output variable
-will be set to the empty string "".
+If the command is unable to obtain a timestamp, the ``<output_variable>``
+will be set to the empty string ``""``.
The optional ``UTC`` flag requests the current date/time representation to
be in Coordinated Universal Time (UTC) rather than local time.
-The optional ``<format string>`` may contain the following format
+The optional ``<format_string>`` may contain the following format
specifiers:
::
@@ -315,6 +413,7 @@ specifiers:
%j The day of the current year (001-366).
%m The month of the current year (01-12).
%b Abbreviated month name (e.g. Oct).
+ %B Full month name (e.g. October).
%M The minute of the current hour (00-59).
%s Seconds since midnight (UTC) 1-Jan-1970 (UNIX time).
%S The second of the current minute.
@@ -322,46 +421,39 @@ specifiers:
%U The week number of the current year (00-53).
%w The day of the current week. 0 is Sunday. (0-6)
%a Abbreviated weekday name (e.g. Fri).
+ %A Full weekday name (e.g. Friday).
%y The last two digits of the current year (00-99)
%Y The current year.
Unknown format specifiers will be ignored and copied to the output
as-is.
-If no explicit ``<format string>`` is given it will default to:
+If no explicit ``<format_string>`` is given, it will default to:
::
%Y-%m-%dT%H:%M:%S for local time.
%Y-%m-%dT%H:%M:%SZ for UTC.
-
-::
-
- string(MAKE_C_IDENTIFIER <input string> <output variable>)
-
-Write a string which can be used as an identifier in C.
-
.. note::
If the ``SOURCE_DATE_EPOCH`` environment variable is set,
its value will be used instead of the current time.
See https://reproducible-builds.org/specs/source-date-epoch/ for details.
-UUID
-""""
+.. _UUID:
-::
+.. code-block:: cmake
- string(UUID <output variable> NAMESPACE <namespace> NAME <name>
+ string(UUID <output_variable> NAMESPACE <namespace> NAME <name>
TYPE <MD5|SHA1> [UPPER])
-Create a univerally unique identifier (aka GUID) as per RFC4122
+Create a universally unique identifier (aka GUID) as per RFC4122
based on the hash of the combined values of ``<namespace>``
(which itself has to be a valid UUID) and ``<name>``.
The hash algorithm can be either ``MD5`` (Version 3 UUID) or
``SHA1`` (Version 5 UUID).
A UUID has the format ``xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx``
-where each `x` represents a lower case hexadecimal character.
-Where required an uppercase representation can be requested
+where each ``x`` represents a lower case hexadecimal character.
+Where required, an uppercase representation can be requested
with the optional ``UPPER`` flag.
diff --git a/Help/command/subdir_depends.rst b/Help/command/subdir_depends.rst
index 5676c8f40..0c1b3c1ce 100644
--- a/Help/command/subdir_depends.rst
+++ b/Help/command/subdir_depends.rst
@@ -1,7 +1,7 @@
subdir_depends
--------------
-Disallowed. See CMake Policy :policy:`CMP0029`.
+Disallowed since version 3.0. See CMake Policy :policy:`CMP0029`.
Does nothing.
diff --git a/Help/command/subdirs.rst b/Help/command/subdirs.rst
index 43b87d4d7..530951bd1 100644
--- a/Help/command/subdirs.rst
+++ b/Help/command/subdirs.rst
@@ -1,7 +1,9 @@
subdirs
-------
-Deprecated. Use the :command:`add_subdirectory` command instead.
+.. deprecated:: 3.0
+
+ Use the :command:`add_subdirectory` command instead.
Add a list of subdirectories to the build.
diff --git a/Help/command/target_compile_definitions.rst b/Help/command/target_compile_definitions.rst
index 8bd323375..9e9c69093 100644
--- a/Help/command/target_compile_definitions.rst
+++ b/Help/command/target_compile_definitions.rst
@@ -3,26 +3,37 @@ target_compile_definitions
Add compile definitions to a target.
-::
+.. code-block:: cmake
target_compile_definitions(<target>
<INTERFACE|PUBLIC|PRIVATE> [items1...]
[<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
-Specify compile definitions to use when compiling a given ``<target>``. The
+Specifies compile definitions to use when compiling a given ``<target>``. The
named ``<target>`` must have been created by a command such as
:command:`add_executable` or :command:`add_library` and must not be an
-:ref:`Imported Target <Imported Targets>`.
+:ref:`ALIAS target <Alias Targets>`.
The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC``
items will populate the :prop_tgt:`COMPILE_DEFINITIONS` property of
``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
-:prop_tgt:`INTERFACE_COMPILE_DEFINITIONS` property of ``<target>``. The
-following arguments specify compile definitions. Repeated calls for the
+:prop_tgt:`INTERFACE_COMPILE_DEFINITIONS` property of ``<target>``.
+(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
+The following arguments specify compile definitions. Repeated calls for the
same ``<target>`` append items in the order called.
Arguments to ``target_compile_definitions`` may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
+
+Any leading ``-D`` on an item will be removed. Empty items are ignored.
+For example, the following are all equivalent:
+
+.. code-block:: cmake
+
+ target_compile_definitions(foo PUBLIC FOO)
+ target_compile_definitions(foo PUBLIC -DFOO) # -D removed
+ target_compile_definitions(foo PUBLIC "" FOO) # "" ignored
+ target_compile_definitions(foo PUBLIC -D FOO) # -D becomes "", then ignored
diff --git a/Help/command/target_compile_features.rst b/Help/command/target_compile_features.rst
index b66a4ec16..9271cd56c 100644
--- a/Help/command/target_compile_features.rst
+++ b/Help/command/target_compile_features.rst
@@ -3,11 +3,11 @@ target_compile_features
Add expected compiler features to a target.
-::
+.. code-block:: cmake
target_compile_features(<target> <PRIVATE|PUBLIC|INTERFACE> <feature> [...])
-Specify compiler features required when compiling a given target. If the
+Specifies compiler features required when compiling a given target. If the
feature is not listed in the :variable:`CMAKE_C_COMPILE_FEATURES` variable
or :variable:`CMAKE_CXX_COMPILE_FEATURES` variable,
then an error will be reported by CMake. If the use of the feature requires
@@ -18,12 +18,13 @@ The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
specify the scope of the features. ``PRIVATE`` and ``PUBLIC`` items will
populate the :prop_tgt:`COMPILE_FEATURES` property of ``<target>``.
``PUBLIC`` and ``INTERFACE`` items will populate the
-:prop_tgt:`INTERFACE_COMPILE_FEATURES` property of ``<target>``. Repeated
-calls for the same ``<target>`` append items.
+:prop_tgt:`INTERFACE_COMPILE_FEATURES` property of ``<target>``.
+(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
+Repeated calls for the same ``<target>`` append items.
The named ``<target>`` must have been created by a command such as
-:command:`add_executable` or :command:`add_library` and must not be
-an ``IMPORTED`` target.
+:command:`add_executable` or :command:`add_library` and must not be an
+:ref:`ALIAS target <Alias Targets>`.
Arguments to ``target_compile_features`` may use "generator expressions"
with the syntax ``$<...>``.
diff --git a/Help/command/target_compile_options.rst b/Help/command/target_compile_options.rst
index 73e01e7f8..47e7d86f8 100644
--- a/Help/command/target_compile_options.rst
+++ b/Help/command/target_compile_options.rst
@@ -3,35 +3,46 @@ target_compile_options
Add compile options to a target.
-::
+.. code-block:: cmake
target_compile_options(<target> [BEFORE]
<INTERFACE|PUBLIC|PRIVATE> [items1...]
[<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
-Specify compile options to use when compiling a given target. The
-named ``<target>`` must have been created by a command such as
-:command:`add_executable` or :command:`add_library` and must not be an
-:ref:`IMPORTED Target <Imported Targets>`. If ``BEFORE`` is specified,
-the content will be prepended to the property instead of being appended.
+Adds options to the :prop_tgt:`COMPILE_OPTIONS` or
+:prop_tgt:`INTERFACE_COMPILE_OPTIONS` target properties. These options
+are used when compiling the given ``<target>``, which must have been
+created by a command such as :command:`add_executable` or
+:command:`add_library` and must not be an :ref:`ALIAS target <Alias Targets>`.
-This command can be used to add any options, but
-alternative commands exist to add preprocessor definitions
-(:command:`target_compile_definitions` and :command:`add_definitions`) or
-include directories (:command:`target_include_directories` and
-:command:`include_directories`). See documentation of the
-:prop_dir:`directory <COMPILE_OPTIONS>` and
-:prop_tgt:`target <COMPILE_OPTIONS>` ``COMPILE_OPTIONS`` properties.
+Arguments
+^^^^^^^^^
+
+If ``BEFORE`` is specified, the content will be prepended to the property
+instead of being appended.
The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC``
items will populate the :prop_tgt:`COMPILE_OPTIONS` property of
``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
-:prop_tgt:`INTERFACE_COMPILE_OPTIONS` property of ``<target>``. The
-following arguments specify compile options. Repeated calls for the same
+:prop_tgt:`INTERFACE_COMPILE_OPTIONS` property of ``<target>``.
+(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
+The following arguments specify compile options. Repeated calls for the same
``<target>`` append items in the order called.
Arguments to ``target_compile_options`` may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
+
+.. include:: OPTIONS_SHELL.txt
+
+See Also
+^^^^^^^^
+
+This command can be used to add any options. However, for adding
+preprocessor definitions and include directories it is recommended
+to use the more specific commands :command:`target_compile_definitions`
+and :command:`target_include_directories`.
+
+For directory-wide settings, there is the command :command:`add_compile_options`.
diff --git a/Help/command/target_include_directories.rst b/Help/command/target_include_directories.rst
index 30ec2cb27..660e15c9b 100644
--- a/Help/command/target_include_directories.rst
+++ b/Help/command/target_include_directories.rst
@@ -3,16 +3,16 @@ target_include_directories
Add include directories to a target.
-::
+.. code-block:: cmake
target_include_directories(<target> [SYSTEM] [BEFORE]
<INTERFACE|PUBLIC|PRIVATE> [items1...]
[<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
-Specify include directories to use when compiling a given target.
+Specifies include directories to use when compiling a given target.
The named ``<target>`` must have been created by a command such
as :command:`add_executable` or :command:`add_library` and must not be an
-:prop_tgt:`IMPORTED` target.
+:ref:`ALIAS target <Alias Targets>`.
If ``BEFORE`` is specified, the content will be prepended to the property
instead of being appended.
@@ -21,9 +21,9 @@ The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to specify
the scope of the following arguments. ``PRIVATE`` and ``PUBLIC`` items will
populate the :prop_tgt:`INCLUDE_DIRECTORIES` property of ``<target>``.
``PUBLIC`` and ``INTERFACE`` items will populate the
-:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES`
-property of ``<target>``. The following arguments specify include
-directories.
+:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` property of ``<target>``.
+(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
+The following arguments specify include directories.
Specified include directories may be absolute paths or relative paths.
Repeated calls for the same <target> append items in the order called. If
diff --git a/Help/command/target_link_directories.rst b/Help/command/target_link_directories.rst
new file mode 100644
index 000000000..76da94dc1
--- /dev/null
+++ b/Help/command/target_link_directories.rst
@@ -0,0 +1,55 @@
+target_link_directories
+-----------------------
+
+Add link directories to a target.
+
+.. code-block:: cmake
+
+ target_link_directories(<target> [BEFORE]
+ <INTERFACE|PUBLIC|PRIVATE> [items1...]
+ [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
+
+Specifies the paths in which the linker should search for libraries when
+linking a given target. Each item can be an absolute or relative path,
+with the latter being interpreted as relative to the current source
+directory. These items will be added to the link command.
+
+The named ``<target>`` must have been created by a command such as
+:command:`add_executable` or :command:`add_library` and must not be an
+:ref:`ALIAS target <Alias Targets>`.
+
+The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
+specify the scope of the items that follow them. ``PRIVATE`` and
+``PUBLIC`` items will populate the :prop_tgt:`LINK_DIRECTORIES` property
+of ``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
+:prop_tgt:`INTERFACE_LINK_DIRECTORIES` property of ``<target>``
+(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items).
+Each item specifies a link directory and will be converted to an absolute
+path if necessary before adding it to the relevant property. Repeated
+calls for the same ``<target>`` append items in the order called.
+
+If ``BEFORE`` is specified, the content will be prepended to the relevant
+property instead of being appended.
+
+Arguments to ``target_link_directories`` may use "generator expressions"
+with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
+
+.. note::
+
+ This command is rarely necessary and should be avoided where there are
+ other choices. Prefer to pass full absolute paths to libraries where
+ possible, since this ensures the correct library will always be linked.
+ The :command:`find_library` command provides the full path, which can
+ generally be used directly in calls to :command:`target_link_libraries`.
+ Situations where a library search path may be needed include:
+
+ - Project generators like Xcode where the user can switch target
+ architecture at build time, but a full path to a library cannot
+ be used because it only provides one architecture (i.e. it is not
+ a universal binary).
+ - Libraries may themselves have other private library dependencies
+ that expect to be found via ``RPATH`` mechanisms, but some linkers
+ are not able to fully decode those paths (e.g. due to the presence
+ of things like ``$ORIGIN``).
diff --git a/Help/command/target_link_libraries.rst b/Help/command/target_link_libraries.rst
index 30d69f266..c2e7e8ac9 100644
--- a/Help/command/target_link_libraries.rst
+++ b/Help/command/target_link_libraries.rst
@@ -14,13 +14,19 @@ Overview
^^^^^^^^
This command has several signatures as detailed in subsections below.
-All of them have the general form::
+All of them have the general form
+
+.. code-block:: cmake
target_link_libraries(<target> ... <item>... ...)
-The named ``<target>`` must have been created in the current directory by
-a command such as :command:`add_executable` or :command:`add_library`.
-Repeated calls for the same ``<target>`` append items in the order called.
+The named ``<target>`` must have been created by a command such as
+:command:`add_executable` or :command:`add_library` and must not be an
+:ref:`ALIAS target <Alias Targets>`. If policy :policy:`CMP0079` is not
+set to ``NEW`` then the target must have been created in the current
+directory. Repeated calls for the same ``<target>`` append items in
+the order called.
+
Each ``<item>`` may be:
* **A library target name**: The generated link line will have the
@@ -39,6 +45,9 @@ Each ``<item>`` may be:
the library instead of using the full path
(e.g. ``/usr/lib/libfoo.so`` becomes ``-lfoo``).
+ The full path to the target's artifact will be quoted/escaped for
+ the shell automatically.
+
* **A full path to a library file**: The generated link line will
normally preserve the full path to the file. The buildsystem will
have a dependency to re-link ``<target>`` if the library file changes.
@@ -48,7 +57,7 @@ Each ``<item>`` may be:
as when a shared library is detected to have no ``SONAME`` field.
See policy :policy:`CMP0060` for discussion of another case.
- If the library file is in a Mac OSX framework, the ``Headers`` directory
+ If the library file is in a macOS framework, the ``Headers`` directory
of the framework will also be processed as a
:ref:`usage requirement <Target Usage Requirements>`. This has the same
effect as passing the framework directory as an include directory.
@@ -58,9 +67,15 @@ Each ``<item>`` may be:
imported into generated project files. This is not supported by other
generators.
+ The full path to the library file will be quoted/escaped for
+ the shell automatically.
+
* **A plain library name**: The generated link line will ask the linker
to search for the library (e.g. ``foo`` becomes ``-lfoo`` or ``foo.lib``).
+ The library name/flag is treated as a command-line string fragment and
+ will be used with no extra quoting or escaping.
+
* **A link flag**: Item names starting with ``-``, but not ``-l`` or
``-framework``, are treated as linker flags. Note that such flags will
be treated like any other library link item for purposes of transitive
@@ -69,10 +84,28 @@ Each ``<item>`` may be:
Link flags specified here are inserted into the link command in the same
place as the link libraries. This might not be correct, depending on
- the linker. Use the :prop_tgt:`LINK_FLAGS` target property to add link
+ the linker. Use the :prop_tgt:`LINK_OPTIONS` target property or
+ :command:`target_link_options` command to add link
flags explicitly. The flags will then be placed at the toolchain-defined
flag position in the link command.
+ The link flag is treated as a command-line string fragment and
+ will be used with no extra quoting or escaping.
+
+* **A generator expression**: A ``$<...>`` :manual:`generator expression
+ <cmake-generator-expressions(7)>` may evaluate to any of the above
+ items or to a :ref:`semicolon-separated list <CMake Language Lists>` of them.
+ If the ``...`` contains any ``;`` characters, e.g. after evaluation
+ of a ``${list}`` variable, be sure to use an explicitly quoted
+ argument ``"$<...>"`` so that this command receives it as a
+ single ``<item>``.
+
+ Additionally, a generator expression may be used as a fragment of
+ any of the above items, e.g. ``foo$<1:_d>``.
+
+ Note that generator expressions will not be used in OLD handling of
+ policy :policy:`CMP0003` or policy :policy:`CMP0004`.
+
* A ``debug``, ``optimized``, or ``general`` keyword immediately followed
by another ``<item>``. The item following such a keyword will be used
only for the corresponding build configuration. The ``debug`` keyword
@@ -83,23 +116,21 @@ Each ``<item>`` may be:
optional. Higher granularity may be achieved for per-configuration
rules by creating and linking to
:ref:`IMPORTED library targets <Imported Targets>`.
+ These keywords are interpreted immediately by this command and therefore
+ have no special meaning when produced by a generator expression.
Items containing ``::``, such as ``Foo::Bar``, are assumed to be
:ref:`IMPORTED <Imported Targets>` or :ref:`ALIAS <Alias Targets>` library
target names and will cause an error if no such target exists.
See policy :policy:`CMP0028`.
-Arguments to ``target_link_libraries`` may use "generator expressions"
-with the syntax ``$<...>``. Note however, that generator expressions
-will not be used in OLD handling of :policy:`CMP0003` or :policy:`CMP0004`.
-See the :manual:`cmake-generator-expressions(7)` manual for available
-expressions. See the :manual:`cmake-buildsystem(7)` manual for more on
-defining buildsystem properties.
+See the :manual:`cmake-buildsystem(7)` manual for more on defining
+buildsystem properties.
Libraries for a Target and/or its Dependents
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
target_link_libraries(<target>
<PRIVATE|PUBLIC|INTERFACE> <item>...
@@ -116,7 +147,7 @@ used for linking ``<target>``.
Libraries for both a Target and its Dependents
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
target_link_libraries(<target> <item>...)
@@ -134,7 +165,7 @@ exclusively by this signature private.
Libraries for a Target and/or its Dependents (Legacy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
target_link_libraries(<target>
<LINK_PRIVATE|LINK_PUBLIC> <lib>...
@@ -156,7 +187,7 @@ made part of the :prop_tgt:`INTERFACE_LINK_LIBRARIES`. If policy
Libraries for Dependents Only (Legacy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
target_link_libraries(<target> LINK_INTERFACE_LIBRARIES <item>...)
@@ -182,6 +213,70 @@ is not ``NEW``, they are also appended to the
``general`` (or without any keyword) are treated as if specified for both
``debug`` and ``optimized``.
+Linking Object Libraries
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+:ref:`Object Libraries` may be used as the ``<target>`` (first) argument
+of ``target_link_libraries`` to specify dependencies of their sources
+on other libraries. For example, the code
+
+.. code-block:: cmake
+
+ add_library(A SHARED a.c)
+ target_compile_definitions(A PUBLIC A)
+
+ add_library(obj OBJECT obj.c)
+ target_compile_definitions(obj PUBLIC OBJ)
+ target_link_libraries(obj PUBLIC A)
+
+compiles ``obj.c`` with ``-DA -DOBJ`` and establishes usage requirements
+for ``obj`` that propagate to its dependents.
+
+Normal libraries and executables may link to :ref:`Object Libraries`
+to get their objects and usage requirements. Continuing the above
+example, the code
+
+.. code-block:: cmake
+
+ add_library(B SHARED b.c)
+ target_link_libraries(B PUBLIC obj)
+
+compiles ``b.c`` with ``-DA -DOBJ``, creates shared library ``B``
+with object files from ``b.c`` and ``obj.c``, and links ``B`` to ``A``.
+Furthermore, the code
+
+.. code-block:: cmake
+
+ add_executable(main main.c)
+ target_link_libraries(main B)
+
+compiles ``main.c`` with ``-DA -DOBJ`` and links executable ``main``
+to ``B`` and ``A``. The object library's usage requirements are
+propagated transitively through ``B``, but its object files are not.
+
+:ref:`Object Libraries` may "link" to other object libraries to get
+usage requirements, but since they do not have a link step nothing
+is done with their object files. Continuing from the above example,
+the code:
+
+.. code-block:: cmake
+
+ add_library(obj2 OBJECT obj2.c)
+ target_link_libraries(obj2 PUBLIC obj)
+
+ add_executable(main2 main2.c)
+ target_link_libraries(main2 obj2)
+
+compiles ``obj2.c`` with ``-DA -DOBJ``, creates executable ``main2``
+with object files from ``main2.c`` and ``obj2.c``, and links ``main2``
+to ``A``.
+
+In other words, when :ref:`Object Libraries` appear in a target's
+:prop_tgt:`INTERFACE_LINK_LIBRARIES` property they will be
+treated as :ref:`Interface Libraries`, but when they appear in
+a target's :prop_tgt:`LINK_LIBRARIES` property their object files
+will be included in the link too.
+
Cyclic Dependencies of Static Libraries
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Help/command/target_link_options.rst b/Help/command/target_link_options.rst
new file mode 100644
index 000000000..b5abbc476
--- /dev/null
+++ b/Help/command/target_link_options.rst
@@ -0,0 +1,48 @@
+target_link_options
+-------------------
+
+Add options to the link step for an executable, shared library or module
+library target.
+
+.. code-block:: cmake
+
+ target_link_options(<target> [BEFORE]
+ <INTERFACE|PUBLIC|PRIVATE> [items1...]
+ [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
+
+The named ``<target>`` must have been created by a command such as
+:command:`add_executable` or :command:`add_library` and must not be an
+:ref:`ALIAS target <Alias Targets>`.
+
+This command can be used to add any link options, but alternative commands
+exist to add libraries (:command:`target_link_libraries` or
+:command:`link_libraries`). See documentation of the
+:prop_dir:`directory <LINK_OPTIONS>` and
+:prop_tgt:`target <LINK_OPTIONS>` ``LINK_OPTIONS`` properties.
+
+.. note::
+
+ This command cannot be used to add options for static library targets,
+ since they do not use a linker. To add archiver or MSVC librarian flags,
+ see the :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property.
+
+If ``BEFORE`` is specified, the content will be prepended to the property
+instead of being appended.
+
+The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
+specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC``
+items will populate the :prop_tgt:`LINK_OPTIONS` property of
+``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
+:prop_tgt:`INTERFACE_LINK_OPTIONS` property of ``<target>``.
+(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
+The following arguments specify link options. Repeated calls for the same
+``<target>`` append items in the order called.
+
+Arguments to ``target_link_options`` may use "generator expressions"
+with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
+
+.. include:: OPTIONS_SHELL.txt
+
+.. include:: LINK_OPTIONS_LINKER.txt
diff --git a/Help/command/target_precompile_headers.rst b/Help/command/target_precompile_headers.rst
new file mode 100644
index 000000000..569c7eb11
--- /dev/null
+++ b/Help/command/target_precompile_headers.rst
@@ -0,0 +1,124 @@
+target_precompile_headers
+-------------------------
+
+Add a list of header files to precompile.
+
+Precompiling header files can speed up compilation by creating a partially
+processed version of some header files, and then using that version during
+compilations rather than repeatedly parsing the original headers.
+
+Main Form
+^^^^^^^^^
+
+.. code-block:: cmake
+
+ target_precompile_headers(<target>
+ <INTERFACE|PUBLIC|PRIVATE> [header1...]
+ [<INTERFACE|PUBLIC|PRIVATE> [header2...] ...])
+
+The command adds header files to the :prop_tgt:`PRECOMPILE_HEADERS` and/or
+:prop_tgt:`INTERFACE_PRECOMPILE_HEADERS` target properties of ``<target>``.
+The named ``<target>`` must have been created by a command such as
+:command:`add_executable` or :command:`add_library` and must not be an
+:ref:`ALIAS target <Alias Targets>`.
+
+The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
+specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC``
+items will populate the :prop_tgt:`PRECOMPILE_HEADERS` property of
+``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
+:prop_tgt:`INTERFACE_PRECOMPILE_HEADERS` property of ``<target>``
+(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items).
+Repeated calls for the same ``<target>`` will append items in the order called.
+
+Projects should generally avoid using ``PUBLIC`` or ``INTERFACE`` for targets
+that will be :ref:`exported <install(EXPORT)>`, or they should at least use
+the ``$<BUILD_INTERFACE:...>`` generator expression to prevent precompile
+headers from appearing in an installed exported target. Consumers of a target
+should typically be in control of what precompile headers they use, not have
+precompile headers forced on them by the targets being consumed (since
+precompile headers are not typically usage requirements). A notable exception
+to this is where an :ref:`interface library <Interface Libraries>` is created
+to define a commonly used set of precompile headers in one place and then other
+targets link to that interface library privately. In this case, the interface
+library exists specifically to propagate the precompile headers to its
+consumers and the consumer is effectively still in control, since it decides
+whether to link to the interface library or not.
+
+The list of header files is used to generate a header file named
+``cmake_pch.h|xx`` which is used to generate the precompiled header file
+(``.pch``, ``.gch``, ``.pchi``) artifact. The ``cmake_pch.h|xx`` header
+file will be force included (``-include`` for GCC, ``/FI`` for MSVC) to
+all source files, so sources do not need to have ``#include "pch.h"``.
+
+Header file names specified with angle brackets (e.g. ``<unordered_map>``) or
+explicit double quotes (escaped for the :manual:`cmake-language(7)`,
+e.g. ``[["other_header.h"]]``) will be treated as is, and include directories
+must be available for the compiler to find them. Other header file names
+(e.g. ``project_header.h``) are interpreted as being relative to the current
+source directory (e.g. :variable:`CMAKE_CURRENT_SOURCE_DIR`) and will be
+included by absolute path.
+
+Arguments to ``target_precompile_headers()`` may use "generator expressions"
+with the syntax ``$<...>``.
+See the :manual:`cmake-generator-expressions(7)` manual for available
+expressions. See the :manual:`cmake-compile-features(7)` manual for
+information on compile features and a list of supported compilers.
+The ``$<COMPILE_LANGUAGE:...>`` generator expression is particularly
+useful for specifying a language-specific header to precompile for
+only one language (e.g. ``CXX`` and not ``C``). For example:
+
+.. code-block:: cmake
+
+ target_precompile_headers(myTarget
+ PUBLIC
+ project_header.h
+ "$<$<COMPILE_LANGUAGE:CXX>:cxx_only.h>"
+ PRIVATE
+ [["other_header.h"]]
+ <unordered_map>
+ )
+
+When specifying angle brackets inside a :manual:`generator expression
+<cmake-generator-expressions(7)>`, be sure to encode the closing ``>``
+as ``$<ANGLE-R>``. For example:
+
+.. code-block:: cmake
+
+ target_precompile_headers(mylib PRIVATE
+ "$<$<COMPILE_LANGUAGE:C>:<stddef.h$<ANGLE-R>>"
+ "$<$<COMPILE_LANGUAGE:CXX>:<cstddef$<ANGLE-R>>"
+ )
+
+
+Reusing Precompile Headers
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The command also supports a second signature which can be used to specify that
+one target re-uses a precompiled header file artefact from another target
+instead of generating its own:
+
+.. code-block:: cmake
+
+ target_precompile_headers(<target> REUSE_FROM <other_target>)
+
+This form sets the :prop_tgt:`PRECOMPILE_HEADERS_REUSE_FROM` property to
+``<other_target>`` and adds a dependency such that ``<target>`` will depend
+on ``<other_target>``. CMake will halt with an error if the
+:prop_tgt:`PRECOMPILE_HEADERS` property of ``<target>`` is already set when
+the ``REUSE_FROM`` form is used.
+
+.. note::
+
+ The ``REUSE_FROM`` form requires the same set of compiler options,
+ compiler flags and compiler definitions for both ``<target>`` and
+ ``<other_target>``. Some compilers (e.g. GCC) may issue a warning if the
+ precompiled header file cannot be used (``-Winvalid-pch``).
+
+See Also
+^^^^^^^^
+
+To disable precompile headers for specific targets, see the
+:prop_tgt:`DISABLE_PRECOMPILE_HEADERS` target property.
+
+To prevent precompile headers from being used when compiling a specific
+source file, see the :prop_sf:`SKIP_PRECOMPILE_HEADERS` source file property.
diff --git a/Help/command/target_sources.rst b/Help/command/target_sources.rst
index d6f148d23..27e737bf0 100644
--- a/Help/command/target_sources.rst
+++ b/Help/command/target_sources.rst
@@ -3,26 +3,32 @@ target_sources
Add sources to a target.
-::
+.. code-block:: cmake
target_sources(<target>
<INTERFACE|PUBLIC|PRIVATE> [items1...]
[<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
-Specify sources to use when compiling a given target. The
+Specifies sources to use when compiling a given target. Relative
+source file paths are interpreted as being relative to the current
+source directory (i.e. :variable:`CMAKE_CURRENT_SOURCE_DIR`). The
named ``<target>`` must have been created by a command such as
:command:`add_executable` or :command:`add_library` and must not be an
-:ref:`IMPORTED Target <Imported Targets>`.
+:ref:`ALIAS target <Alias Targets>`.
The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC``
items will populate the :prop_tgt:`SOURCES` property of
``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
-:prop_tgt:`INTERFACE_SOURCES` property of ``<target>``. The
-following arguments specify sources. Repeated calls for the same
+:prop_tgt:`INTERFACE_SOURCES` property of ``<target>``.
+(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items.)
+The following arguments specify sources. Repeated calls for the same
``<target>`` append items in the order called.
Arguments to ``target_sources`` may use "generator expressions"
with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
+
+See also the :policy:`CMP0076` policy for older behavior related to the
+handling of relative source file paths.
diff --git a/Help/command/try_compile.rst b/Help/command/try_compile.rst
index 66ea3d7f2..edbf92ce6 100644
--- a/Help/command/try_compile.rst
+++ b/Help/command/try_compile.rst
@@ -10,14 +10,14 @@ Try building some code.
Try Compiling Whole Projects
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
- try_compile(RESULT_VAR <bindir> <srcdir>
+ try_compile(<resultVar> <bindir> <srcdir>
<projectName> [<targetName>] [CMAKE_FLAGS <flags>...]
[OUTPUT_VARIABLE <var>])
Try building a project. The success or failure of the ``try_compile``,
-i.e. ``TRUE`` or ``FALSE`` respectively, is returned in ``RESULT_VAR``.
+i.e. ``TRUE`` or ``FALSE`` respectively, is returned in ``<resultVar>``.
In this form, ``<srcdir>`` should contain a complete CMake project with a
``CMakeLists.txt`` file and all sources. The ``<bindir>`` and ``<srcdir>``
@@ -28,11 +28,12 @@ below for the meaning of other options.
Try Compiling Source Files
^^^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
- try_compile(RESULT_VAR <bindir> <srcfile|SOURCES srcfile...>
+ try_compile(<resultVar> <bindir> <srcfile|SOURCES srcfile...>
[CMAKE_FLAGS <flags>...]
[COMPILE_DEFINITIONS <defs>...]
+ [LINK_OPTIONS <options>...]
[LINK_LIBRARIES <libs>...]
[OUTPUT_VARIABLE <var>]
[COPY_FILE <fileName> [COPY_FILE_ERROR <var>]]
@@ -41,18 +42,27 @@ Try Compiling Source Files
[<LANG>_EXTENSIONS <bool>]
)
-Try building an executable from one or more source files. The success or
-failure of the ``try_compile``, i.e. ``TRUE`` or ``FALSE`` respectively, is
-returned in ``RESULT_VAR``.
+Try building an executable or static library from one or more source files
+(which one is determined by the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE`
+variable). The success or failure of the ``try_compile``, i.e. ``TRUE`` or
+``FALSE`` respectively, is returned in ``<resultVar>``.
-In this form the user need only supply one or more source files that include a
-definition for ``main``. CMake will create a ``CMakeLists.txt`` file to build
-the source(s) as an executable that looks something like this::
+In this form, one or more source files must be provided. If
+:variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` is unset or is set to ``EXECUTABLE``,
+the sources must include a definition for ``main`` and CMake will create a
+``CMakeLists.txt`` file to build the source(s) as an executable.
+If :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` is set to ``STATIC_LIBRARY``,
+a static library will be built instead and no definition for ``main`` is
+required. For an executable, the generated ``CMakeLists.txt`` file would
+contain something like the following:
+
+.. code-block:: cmake
add_definitions(<expanded COMPILE_DEFINITIONS from caller>)
include_directories(${INCLUDE_DIRECTORIES})
link_directories(${LINK_DIRECTORIES})
add_executable(cmTryCompileExec <srcfile>...)
+ target_link_options(cmTryCompileExec PRIVATE <LINK_OPTIONS from caller>)
target_link_libraries(cmTryCompileExec ${LINK_LIBRARIES})
The options are:
@@ -65,11 +75,11 @@ The options are:
are used.
``COMPILE_DEFINITIONS <defs>...``
- Specify ``-Ddefinition`` arguments to pass to ``add_definitions``
+ Specify ``-Ddefinition`` arguments to pass to :command:`add_definitions`
in the generated test project.
``COPY_FILE <fileName>``
- Copy the linked executable to the given ``<fileName>``.
+ Copy the built executable or static library to the given ``<fileName>``.
``COPY_FILE_ERROR <var>``
Use after ``COPY_FILE`` to capture into variable ``<var>`` any error
@@ -83,20 +93,28 @@ The options are:
If this option is specified, any ``-DLINK_LIBRARIES=...`` value
given to the ``CMAKE_FLAGS`` option will be ignored.
+``LINK_OPTIONS <options>...``
+ Specify link step options to pass to :command:`target_link_options` or to
+ set the :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property in the generated
+ project, depending on the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable.
+
``OUTPUT_VARIABLE <var>``
- Store the output from the build process the given variable.
+ Store the output from the build process in the given variable.
``<LANG>_STANDARD <std>``
Specify the :prop_tgt:`C_STANDARD`, :prop_tgt:`CXX_STANDARD`,
+ :prop_tgt:`OBJC_STANDARD`, :prop_tgt:`OBJCXX_STANDARD`,
or :prop_tgt:`CUDA_STANDARD` target property of the generated project.
``<LANG>_STANDARD_REQUIRED <bool>``
Specify the :prop_tgt:`C_STANDARD_REQUIRED`,
- :prop_tgt:`CXX_STANDARD_REQUIRED`, or :prop_tgt:`CUDA_STANDARD_REQUIRED`
+ :prop_tgt:`CXX_STANDARD_REQUIRED`, :prop_tgt:`OBJC_STANDARD_REQUIRED`,
+ :prop_tgt:`OBJCXX_STANDARD_REQUIRED`,or :prop_tgt:`CUDA_STANDARD_REQUIRED`
target property of the generated project.
``<LANG>_EXTENSIONS <bool>``
Specify the :prop_tgt:`C_EXTENSIONS`, :prop_tgt:`CXX_EXTENSIONS`,
+ :prop_tgt:`OBJC_EXTENSIONS`, :prop_tgt:`OBJCXX_EXTENSIONS`,
or :prop_tgt:`CUDA_EXTENSIONS` target property of the generated project.
In this version all files in ``<bindir>/CMakeFiles/CMakeTmp`` will be
@@ -105,7 +123,7 @@ passed to ``cmake`` to avoid this clean. However, multiple sequential
``try_compile`` operations reuse this single output directory. If you use
``--debug-trycompile``, you can only debug one ``try_compile`` call at a time.
The recommended procedure is to protect all ``try_compile`` calls in your
-project by ``if(NOT DEFINED RESULT_VAR)`` logic, configure with cmake
+project by ``if(NOT DEFINED <resultVar>)`` logic, configure with cmake
all the way through once, then delete the cache entry associated with
the try_compile call of interest, and then re-run cmake again with
``--debug-trycompile``.
@@ -120,12 +138,19 @@ default values:
* :variable:`CMAKE_ENABLE_EXPORTS`
* :variable:`CMAKE_LINK_SEARCH_START_STATIC`
* :variable:`CMAKE_LINK_SEARCH_END_STATIC`
+* :variable:`CMAKE_MSVC_RUNTIME_LIBRARY`
* :variable:`CMAKE_POSITION_INDEPENDENT_CODE`
If :policy:`CMP0056` is set to ``NEW``, then
:variable:`CMAKE_EXE_LINKER_FLAGS` is passed in as well.
-The current setting of :policy:`CMP0065` is set in the generated project.
+If :policy:`CMP0083` is set to ``NEW``, then in order to obtain correct
+behavior at link time, the ``check_pie_supported()`` command from the
+:module:`CheckPIESupported` module must be called before using the
+:command:`try_compile` command.
+
+The current settings of :policy:`CMP0065` and :policy:`CMP0083` are propagated
+through to the generated test project.
Set the :variable:`CMAKE_TRY_COMPILE_CONFIGURATION` variable to choose
a build configuration.
@@ -135,7 +160,9 @@ the type of target used for the source file signature.
Set the :variable:`CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` variable to specify
variables that must be propagated into the test project. This variable is
-meant for use only in toolchain files.
+meant for use only in toolchain files and is only honored by the
+``try_compile()`` command for the source files form, not when given a whole
+project.
If :policy:`CMP0067` is set to ``NEW``, or any of the ``<LANG>_STANDARD``,
``<LANG>_STANDARD_REQUIRED``, or ``<LANG>_EXTENSIONS`` options are used,
@@ -147,9 +174,18 @@ then the language standard variables are honored:
* :variable:`CMAKE_CXX_STANDARD`
* :variable:`CMAKE_CXX_STANDARD_REQUIRED`
* :variable:`CMAKE_CXX_EXTENSIONS`
+* :variable:`CMAKE_OBJC_STANDARD`
+* :variable:`CMAKE_OBJC_STANDARD_REQUIRED`
+* :variable:`CMAKE_OBJC_EXTENSIONS`
+* :variable:`CMAKE_OBJCXX_STANDARD`
+* :variable:`CMAKE_OBJCXX_STANDARD_REQUIRED`
+* :variable:`CMAKE_OBJCXX_EXTENSIONS`
* :variable:`CMAKE_CUDA_STANDARD`
* :variable:`CMAKE_CUDA_STANDARD_REQUIRED`
* :variable:`CMAKE_CUDA_EXTENSIONS`
Their values are used to set the corresponding target properties in
the generated project (unless overridden by an explicit option).
+
+For the :generator:`Green Hills MULTI` generator the GHS toolset and target
+system customization cache variables are also propagated into the test project.
diff --git a/Help/command/try_run.rst b/Help/command/try_run.rst
index e3bd57d50..d401ebe92 100644
--- a/Help/command/try_run.rst
+++ b/Help/command/try_run.rst
@@ -10,11 +10,12 @@ Try compiling and then running some code.
Try Compiling and Running Source Files
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: cmake
- try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR
- bindir srcfile [CMAKE_FLAGS <flags>...]
+ try_run(<runResultVar> <compileResultVar>
+ <bindir> <srcfile> [CMAKE_FLAGS <flags>...]
[COMPILE_DEFINITIONS <defs>...]
+ [LINK_OPTIONS <options>...]
[LINK_LIBRARIES <libs>...]
[COMPILE_OUTPUT_VARIABLE <var>]
[RUN_OUTPUT_VARIABLE <var>]
@@ -22,9 +23,9 @@ Try Compiling and Running Source Files
[ARGS <args>...])
Try compiling a ``<srcfile>``. Returns ``TRUE`` or ``FALSE`` for success
-or failure in ``COMPILE_RESULT_VAR``. If the compile succeeded, runs the
-executable and returns its exit code in ``RUN_RESULT_VAR``. If the
-executable was built, but failed to run, then ``RUN_RESULT_VAR`` will be
+or failure in ``<compileResultVar>``. If the compile succeeded, runs the
+executable and returns its exit code in ``<runResultVar>``. If the
+executable was built, but failed to run, then ``<runResultVar>`` will be
set to ``FAILED_TO_RUN``. See the :command:`try_compile` command for
information on how the test project is constructed to build the source file.
@@ -38,7 +39,7 @@ The options are:
are used.
``COMPILE_DEFINITIONS <defs>...``
- Specify ``-Ddefinition`` arguments to pass to ``add_definitions``
+ Specify ``-Ddefinition`` arguments to pass to :command:`add_definitions`
in the generated test project.
``COMPILE_OUTPUT_VARIABLE <var>``
@@ -52,6 +53,10 @@ The options are:
If this option is specified, any ``-DLINK_LIBRARIES=...`` value
given to the ``CMAKE_FLAGS`` option will be ignored.
+``LINK_OPTIONS <options>...``
+ Specify link step options to pass to :command:`target_link_options` in the
+ generated project.
+
``OUTPUT_VARIABLE <var>``
Report the compile build output and the output from running the executable
in the given variable. This option exists for legacy reasons. Prefer
@@ -80,10 +85,10 @@ presetting them in some CMake script file to the values the executable
would have produced if it had been run on its actual target platform.
These cache entries are:
-``<RUN_RESULT_VAR>``
+``<runResultVar>``
Exit code if the executable were to be run on the target platform.
-``<RUN_RESULT_VAR>__TRYRUN_OUTPUT``
+``<runResultVar>__TRYRUN_OUTPUT``
Output from stdout and stderr if the executable were to be run on
the target platform. This is created only if the
``RUN_OUTPUT_VARIABLE`` or ``OUTPUT_VARIABLE`` option was used.
diff --git a/Help/command/unset.rst b/Help/command/unset.rst
index a1fc95cc6..75210521e 100644
--- a/Help/command/unset.rst
+++ b/Help/command/unset.rst
@@ -3,23 +3,39 @@ unset
Unset a variable, cache variable, or environment variable.
-::
+Unset Normal Variable or Cache Entry
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: cmake
unset(<variable> [CACHE | PARENT_SCOPE])
-Removes the specified variable causing it to become undefined. If
-``CACHE`` is present then the variable is removed from the cache instead
-of the current scope.
+Removes a normal variable from the current scope, causing it
+to become undefined. If ``CACHE`` is present, then a cache variable
+is removed instead of a normal variable. Note that when evaluating
+:ref:`Variable References` of the form ``${VAR}``, CMake first searches
+for a normal variable with that name. If no such normal variable exists,
+CMake will then search for a cache entry with that name. Because of this
+unsetting a normal variable can expose a cache variable that was previously
+hidden. To force a variable reference of the form ``${VAR}`` to return an
+empty string, use ``set(<variable> "")``, which clears the normal variable
+but leaves it defined.
If ``PARENT_SCOPE`` is present then the variable is removed from the scope
above the current scope. See the same option in the :command:`set` command
for further details.
-``<variable>`` can be an environment variable such as:
+Unset Environment Variable
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: cmake
-::
+ unset(ENV{<variable>})
- unset(ENV{LD_LIBRARY_PATH})
+Removes ``<variable>`` from the currently available
+:manual:`Environment Variables <cmake-env-variables(7)>`.
+Subsequent calls of ``$ENV{<variable>}`` will return the empty string.
-in which case the variable will be removed from the current
-environment.
+This command affects only the current CMake process, not the process
+from which CMake was called, nor the system environment at large,
+nor the environment of subsequent build or test processes.
diff --git a/Help/command/use_mangled_mesa.rst b/Help/command/use_mangled_mesa.rst
index 6f4d7aca6..5b0e2ee06 100644
--- a/Help/command/use_mangled_mesa.rst
+++ b/Help/command/use_mangled_mesa.rst
@@ -1,7 +1,7 @@
use_mangled_mesa
----------------
-Disallowed. See CMake Policy :policy:`CMP0030`.
+Disallowed since version 3.0. See CMake Policy :policy:`CMP0030`.
Copy mesa headers for use in combination with system GL.
@@ -9,7 +9,7 @@ Copy mesa headers for use in combination with system GL.
use_mangled_mesa(PATH_TO_MESA OUTPUT_DIRECTORY)
-The path to mesa includes, should contain gl_mangle.h. The mesa
+The path to mesa includes, should contain ``gl_mangle.h``. The mesa
headers are copied to the specified output directory. This allows
mangled mesa headers to override other GL headers by being added to
the include directory path earlier.
diff --git a/Help/command/utility_source.rst b/Help/command/utility_source.rst
index ee34492c3..94d6a4e64 100644
--- a/Help/command/utility_source.rst
+++ b/Help/command/utility_source.rst
@@ -1,7 +1,7 @@
utility_source
--------------
-Disallowed. See CMake Policy :policy:`CMP0034`.
+Disallowed since version 3.0. See CMake Policy :policy:`CMP0034`.
Specify the source tree of a third-party utility.
diff --git a/Help/command/variable_requires.rst b/Help/command/variable_requires.rst
index 9cf9f3ffd..322b15459 100644
--- a/Help/command/variable_requires.rst
+++ b/Help/command/variable_requires.rst
@@ -1,7 +1,7 @@
variable_requires
-----------------
-Disallowed. See CMake Policy :policy:`CMP0035`.
+Disallowed since version 3.0. See CMake Policy :policy:`CMP0035`.
Use the :command:`if` command instead.
@@ -18,5 +18,5 @@ tested, if that variable is false nothing else is done. If
``TEST_VARIABLE`` is true, then the next argument (``RESULT_VARIABLE``)
is a variable that is set to true if all the required variables are set.
The rest of the arguments are variables that must be true or not set
-to NOTFOUND to avoid an error. If any are not true, an error is
+to ``NOTFOUND`` to avoid an error. If any are not true, an error is
reported.
diff --git a/Help/command/variable_watch.rst b/Help/command/variable_watch.rst
index a2df058eb..ce69bcfcd 100644
--- a/Help/command/variable_watch.rst
+++ b/Help/command/variable_watch.rst
@@ -3,11 +3,13 @@ variable_watch
Watch the CMake variable for change.
-::
+.. code-block:: cmake
- variable_watch(<variable name> [<command to execute>])
+ variable_watch(<variable> [<command>])
-If the specified variable changes, the message will be printed about
-the variable being changed. If the command is specified, the command
-will be executed. The command will receive the following arguments:
-COMMAND(<variable> <access> <value> <current list file> <stack>)
+If the specified ``<variable>`` changes, a message will be printed
+to inform about the change.
+
+Additionally, if ``<command>`` is given, this command will be executed.
+The command will receive the following arguments:
+``COMMAND(<variable> <access> <value> <current_list_file> <stack>)``
diff --git a/Help/command/while.rst b/Help/command/while.rst
index 7509da309..a4957c1db 100644
--- a/Help/command/while.rst
+++ b/Help/command/while.rst
@@ -3,15 +3,23 @@ while
Evaluate a group of commands while a condition is true
-::
+.. code-block:: cmake
- while(condition)
- COMMAND1(ARGS ...)
- COMMAND2(ARGS ...)
- ...
- endwhile(condition)
+ while(<condition>)
+ <commands>
+ endwhile()
All commands between while and the matching :command:`endwhile` are recorded
without being invoked. Once the :command:`endwhile` is evaluated, the
-recorded list of commands is invoked as long as the condition is true. The
-condition is evaluated using the same logic as the :command:`if` command.
+recorded list of commands is invoked as long as the ``<condition>`` is true.
+
+The ``<condition>`` has the same syntax and is evaluated using the same logic
+as described at length for the :command:`if` command.
+
+The commands :command:`break` and :command:`continue` provide means to
+escape from the normal control flow.
+
+Per legacy, the :command:`endwhile` command admits
+an optional ``<condition>`` argument.
+If used, it must be a verbatim repeat of the argument of the opening
+``while`` command.
diff --git a/Help/command/write_file.rst b/Help/command/write_file.rst
index 40e755763..4d476bd5a 100644
--- a/Help/command/write_file.rst
+++ b/Help/command/write_file.rst
@@ -1,7 +1,9 @@
write_file
----------
-Deprecated. Use the :command:`file(WRITE)` command instead.
+.. deprecated:: 3.0
+
+ Use the :command:`file(WRITE)` command instead.
::
diff --git a/Help/cpack_gen/archive.rst b/Help/cpack_gen/archive.rst
new file mode 100644
index 000000000..d455f4b45
--- /dev/null
+++ b/Help/cpack_gen/archive.rst
@@ -0,0 +1,36 @@
+CPack Archive Generator
+-----------------------
+
+Archive CPack generator that supports packaging of sources and binaries in
+different formats:
+
+ - 7Z - 7zip - (.7z)
+ - TBZ2 (.tar.bz2)
+ - TGZ (.tar.gz)
+ - TXZ (.tar.xz)
+ - TZ (.tar.Z)
+ - TZST (.tar.zst)
+ - ZIP (.zip)
+
+Variables specific to CPack Archive generator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. variable:: CPACK_ARCHIVE_FILE_NAME
+ CPACK_ARCHIVE_<component>_FILE_NAME
+
+ Package file name without extension which is added automatically depending
+ on the archive format.
+
+ * Mandatory : YES
+ * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].<extension>`` with
+ spaces replaced by '-'
+
+.. variable:: CPACK_ARCHIVE_COMPONENT_INSTALL
+
+ Enable component packaging for CPackArchive
+
+ * Mandatory : NO
+ * Default : OFF
+
+ If enabled (ON) multiple packages are generated. By default a single package
+ containing files of all components is generated.
diff --git a/Help/cpack_gen/bundle.rst b/Help/cpack_gen/bundle.rst
new file mode 100644
index 000000000..b16dbda03
--- /dev/null
+++ b/Help/cpack_gen/bundle.rst
@@ -0,0 +1,66 @@
+CPack Bundle Generator
+----------------------
+
+CPack Bundle generator (macOS) specific options
+
+Variables specific to CPack Bundle generator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Installers built on macOS using the Bundle generator use the
+aforementioned DragNDrop (``CPACK_DMG_xxx``) variables, plus the following
+Bundle-specific parameters (``CPACK_BUNDLE_xxx``).
+
+.. variable:: CPACK_BUNDLE_NAME
+
+ The name of the generated bundle. This appears in the macOS Finder as the
+ bundle name. Required.
+
+.. variable:: CPACK_BUNDLE_PLIST
+
+ Path to an macOS Property List (``.plist``) file that will be used
+ for the generated bundle. This
+ assumes that the caller has generated or specified their own ``Info.plist``
+ file. Required.
+
+.. variable:: CPACK_BUNDLE_ICON
+
+ Path to an macOS icon file that will be used as the icon for the generated
+ bundle. This is the icon that appears in the macOS Finder for the bundle, and
+ in the macOS dock when the bundle is opened. Required.
+
+.. variable:: CPACK_BUNDLE_STARTUP_COMMAND
+
+ Path to a startup script. This is a path to an executable or script that
+ will be run whenever an end-user double-clicks the generated bundle in the
+ macOS Finder. Optional.
+
+.. variable:: CPACK_BUNDLE_APPLE_CERT_APP
+
+ The name of your Apple supplied code signing certificate for the application.
+ The name usually takes the form ``Developer ID Application: [Name]`` or
+ ``3rd Party Mac Developer Application: [Name]``. If this variable is not set
+ the application will not be signed.
+
+.. variable:: CPACK_BUNDLE_APPLE_ENTITLEMENTS
+
+ The name of the Property List (``.plist``) file that contains your Apple
+ entitlements for sandboxing your application. This file is required
+ for submission to the macOS App Store.
+
+.. variable:: CPACK_BUNDLE_APPLE_CODESIGN_FILES
+
+ A list of additional files that you wish to be signed. You do not need to
+ list the main application folder, or the main executable. You should
+ list any frameworks and plugins that are included in your app bundle.
+
+.. variable:: CPACK_BUNDLE_APPLE_CODESIGN_PARAMETER
+
+ Additional parameter that will passed to ``codesign``.
+ Default value: ``--deep -f``
+
+.. variable:: CPACK_COMMAND_CODESIGN
+
+ Path to the ``codesign(1)`` command used to sign applications with an
+ Apple cert. This variable can be used to override the automatically
+ detected command (or specify its location if the auto-detection fails
+ to find it).
diff --git a/Help/cpack_gen/cygwin.rst b/Help/cpack_gen/cygwin.rst
new file mode 100644
index 000000000..1c5f7af91
--- /dev/null
+++ b/Help/cpack_gen/cygwin.rst
@@ -0,0 +1,23 @@
+CPack Cygwin Generator
+----------------------
+
+Cygwin CPack generator (Cygwin).
+
+Variables specific to CPack Cygwin generator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The
+following variable is specific to installers build on and/or for
+Cygwin:
+
+.. variable:: CPACK_CYGWIN_PATCH_NUMBER
+
+ The Cygwin patch number. FIXME: This documentation is incomplete.
+
+.. variable:: CPACK_CYGWIN_PATCH_FILE
+
+ The Cygwin patch file. FIXME: This documentation is incomplete.
+
+.. variable:: CPACK_CYGWIN_BUILD_SCRIPT
+
+ The Cygwin build script. FIXME: This documentation is incomplete.
diff --git a/Help/cpack_gen/deb.rst b/Help/cpack_gen/deb.rst
new file mode 100644
index 000000000..db71c87e7
--- /dev/null
+++ b/Help/cpack_gen/deb.rst
@@ -0,0 +1,565 @@
+CPack DEB Generator
+-------------------
+
+The built in (binary) CPack DEB generator (Unix only)
+
+Variables specific to CPack Debian (DEB) generator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The CPack DEB generator may be used to create DEB package using :module:`CPack`.
+The CPack DEB generator is a :module:`CPack` generator thus it uses the
+``CPACK_XXX`` variables used by :module:`CPack`.
+
+The CPack DEB generator should work on any Linux host but it will produce
+better deb package when Debian specific tools ``dpkg-xxx`` are usable on
+the build system.
+
+The CPack DEB generator has specific features which are controlled by the
+specifics ``CPACK_DEBIAN_XXX`` variables.
+
+``CPACK_DEBIAN_<COMPONENT>_XXXX`` variables may be used in order to have
+**component** specific values. Note however that ``<COMPONENT>`` refers to
+the **grouping name** written in upper case. It may be either a component name
+or a component GROUP name.
+
+Here are some CPack DEB generator wiki resources that are here for historic
+reasons and are no longer maintained but may still prove useful:
+
+ - https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/Configuration
+ - https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/PackageGenerators#deb-unix-only
+
+List of CPack DEB generator specific variables:
+
+.. variable:: CPACK_DEB_COMPONENT_INSTALL
+
+ Enable component packaging for CPackDEB
+
+ * Mandatory : NO
+ * Default : OFF
+
+ If enabled (ON) multiple packages are generated. By default a single package
+ containing files of all components is generated.
+
+.. variable:: CPACK_DEBIAN_PACKAGE_NAME
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAME
+
+ Set Package control field (variable is automatically transformed to lower
+ case).
+
+ * Mandatory : YES
+ * Default :
+
+ - :variable:`CPACK_PACKAGE_NAME` for non-component based
+ installations
+ - :variable:`CPACK_DEBIAN_PACKAGE_NAME` suffixed with -<COMPONENT>
+ for component-based installations.
+
+ See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
+
+.. variable:: CPACK_DEBIAN_FILE_NAME
+ CPACK_DEBIAN_<COMPONENT>_FILE_NAME
+
+ Package file name.
+
+ * Mandatory : YES
+ * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].deb``
+
+ This may be set to ``DEB-DEFAULT`` to allow the CPack DEB generator to generate
+ package file name by itself in deb format::
+
+ <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
+
+ Alternatively provided package file name must end
+ with either ``.deb`` or ``.ipk`` suffix.
+
+ .. note::
+
+ Preferred setting of this variable is ``DEB-DEFAULT`` but for backward
+ compatibility with the CPack DEB generator in CMake prior to version 3.6 this
+ feature is disabled by default.
+
+ .. note::
+
+ By using non default filenames duplicate names may occur. Duplicate files
+ get overwritten and it is up to the packager to set the variables in a
+ manner that will prevent such errors.
+
+.. variable:: CPACK_DEBIAN_PACKAGE_EPOCH
+
+ The Debian package epoch
+
+ * Mandatory : No
+ * Default : -
+
+ Optional number that should be incremented when changing versioning schemas
+ or fixing mistakes in the version numbers of older packages.
+
+.. variable:: CPACK_DEBIAN_PACKAGE_VERSION
+
+ The Debian package version
+
+ * Mandatory : YES
+ * Default : :variable:`CPACK_PACKAGE_VERSION`
+
+ This variable may contain only alphanumerics (A-Za-z0-9) and the characters
+ . + - ~ (full stop, plus, hyphen, tilde) and should start with a digit. If
+ :variable:`CPACK_DEBIAN_PACKAGE_RELEASE` is not set then hyphens are not
+ allowed.
+
+ .. note::
+
+ For backward compatibility with CMake 3.9 and lower a failed test of this
+ variable's content is not a hard error when both
+ :variable:`CPACK_DEBIAN_PACKAGE_RELEASE` and
+ :variable:`CPACK_DEBIAN_PACKAGE_EPOCH` variables are not set. An author
+ warning is reported instead.
+
+.. variable:: CPACK_DEBIAN_PACKAGE_RELEASE
+
+ The Debian package release - Debian revision number.
+
+ * Mandatory : No
+ * Default : -
+
+ This is the numbering of the DEB package itself, i.e. the version of the
+ packaging and not the version of the content (see
+ :variable:`CPACK_DEBIAN_PACKAGE_VERSION`). One may change the default value
+ if the previous packaging was buggy and/or you want to put here a fancy Linux
+ distro specific numbering.
+
+.. variable:: CPACK_DEBIAN_PACKAGE_ARCHITECTURE
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE
+
+ The Debian package architecture
+
+ * Mandatory : YES
+ * Default : Output of ``dpkg --print-architecture`` (or ``i386``
+ if ``dpkg`` is not found)
+
+.. variable:: CPACK_DEBIAN_PACKAGE_DEPENDS
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS
+
+ Sets the Debian dependencies of this package.
+
+ * Mandatory : NO
+ * Default :
+
+ - An empty string for non-component based installations
+ - :variable:`CPACK_DEBIAN_PACKAGE_DEPENDS` for component-based
+ installations.
+
+ .. note::
+
+ If :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` or
+ more specifically :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS`
+ is set for this component, the discovered dependencies will be appended
+ to :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS` instead of
+ :variable:`CPACK_DEBIAN_PACKAGE_DEPENDS`. If
+ :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS` is an empty string,
+ only the automatically discovered dependencies will be set for this
+ component.
+
+ Example::
+
+ set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libc6 (< 2.4)")
+
+.. variable:: CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS
+
+ Sets inter component dependencies if listed with
+ :variable:`CPACK_COMPONENT_<compName>_DEPENDS` variables.
+
+ * Mandatory : NO
+ * Default : -
+
+.. variable:: CPACK_DEBIAN_PACKAGE_MAINTAINER
+
+ The Debian package maintainer
+
+ * Mandatory : YES
+ * Default : ``CPACK_PACKAGE_CONTACT``
+
+.. variable:: CPACK_DEBIAN_PACKAGE_DESCRIPTION
+ CPACK_DEBIAN_<COMPONENT>_DESCRIPTION
+
+ The Debian package description
+
+ * Mandatory : YES
+ * Default :
+
+ - :variable:`CPACK_DEBIAN_<COMPONENT>_DESCRIPTION` (component
+ based installers only) if set, or :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` if set, or
+ - :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION` (component
+ based installers only) if set, or :variable:`CPACK_PACKAGE_DESCRIPTION` if set, or
+ - content of the file specified in :variable:`CPACK_PACKAGE_DESCRIPTION_FILE` if set
+
+ If after that description is not set, :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` going to be
+ used if set. Otherwise, :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` will be added as the first
+ line of description as defined in `Debian Policy Manual`_.
+
+.. _Debian Policy Manual: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description
+
+.. variable:: CPACK_DEBIAN_PACKAGE_SECTION
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION
+
+ Set Section control field e.g. admin, devel, doc, ...
+
+ * Mandatory : YES
+ * Default : "devel"
+
+ See https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
+
+.. variable:: CPACK_DEBIAN_ARCHIVE_TYPE
+
+ The archive format used for creating the Debian package.
+
+ * Mandatory : YES
+ * Default : "gnutar"
+
+ Possible value is:
+
+ - gnutar
+
+ .. note::
+
+ This variable previously defaulted to the ``paxr`` value, but ``dpkg``
+ has never supported that tar format. For backwards compatibility the
+ ``paxr`` value will be mapped to ``gnutar`` and a deprecation message
+ will be emitted.
+
+.. variable:: CPACK_DEBIAN_COMPRESSION_TYPE
+
+ The compression used for creating the Debian package.
+
+ * Mandatory : YES
+ * Default : "gzip"
+
+ Possible values are:
+
+ - lzma
+ - xz
+ - bzip2
+ - gzip
+
+.. variable:: CPACK_DEBIAN_PACKAGE_PRIORITY
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY
+
+ Set Priority control field e.g. required, important, standard, optional,
+ extra
+
+ * Mandatory : YES
+ * Default : "optional"
+
+ See https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
+
+.. variable:: CPACK_DEBIAN_PACKAGE_HOMEPAGE
+
+ The URL of the web site for this package, preferably (when applicable) the
+ site from which the original source can be obtained and any additional
+ upstream documentation or information may be found.
+
+ * Mandatory : NO
+ * Default : :variable:`CMAKE_PROJECT_HOMEPAGE_URL`
+
+ .. note::
+
+ The content of this field is a simple URL without any surrounding
+ characters such as <>.
+
+.. variable:: CPACK_DEBIAN_PACKAGE_SHLIBDEPS
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS
+
+ May be set to ON in order to use ``dpkg-shlibdeps`` to generate
+ better package dependency list.
+
+ * Mandatory : NO
+ * Default :
+
+ - :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` if set or
+ - OFF
+
+ .. note::
+
+ You may need set :variable:`CMAKE_INSTALL_RPATH` to an appropriate value
+ if you use this feature, because if you don't ``dpkg-shlibdeps``
+ may fail to find your own shared libs.
+ See https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
+
+.. variable:: CPACK_DEBIAN_PACKAGE_DEBUG
+
+ May be set when invoking cpack in order to trace debug information
+ during the CPack DEB generator run.
+
+ * Mandatory : NO
+ * Default : -
+
+.. variable:: CPACK_DEBIAN_PACKAGE_PREDEPENDS
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_PREDEPENDS
+
+ Sets the `Pre-Depends` field of the Debian package.
+ Like :variable:`Depends <CPACK_DEBIAN_PACKAGE_DEPENDS>`, except that it
+ also forces ``dpkg`` to complete installation of the packages named
+ before even starting the installation of the package which declares the
+ pre-dependency.
+
+ * Mandatory : NO
+ * Default :
+
+ - An empty string for non-component based installations
+ - :variable:`CPACK_DEBIAN_PACKAGE_PREDEPENDS` for component-based
+ installations.
+
+ See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
+
+.. variable:: CPACK_DEBIAN_PACKAGE_ENHANCES
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_ENHANCES
+
+ Sets the `Enhances` field of the Debian package.
+ Similar to :variable:`Suggests <CPACK_DEBIAN_PACKAGE_SUGGESTS>` but works
+ in the opposite direction: declares that a package can enhance the
+ functionality of another package.
+
+ * Mandatory : NO
+ * Default :
+
+ - An empty string for non-component based installations
+ - :variable:`CPACK_DEBIAN_PACKAGE_ENHANCES` for component-based
+ installations.
+
+ See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
+
+.. variable:: CPACK_DEBIAN_PACKAGE_BREAKS
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_BREAKS
+
+ Sets the `Breaks` field of the Debian package.
+ When a binary package (P) declares that it breaks other packages (B),
+ ``dpkg`` will not allow the package (P) which declares `Breaks` be
+ **unpacked** unless the packages that will be broken (B) are deconfigured
+ first.
+ As long as the package (P) is configured, the previously deconfigured
+ packages (B) cannot be reconfigured again.
+
+ * Mandatory : NO
+ * Default :
+
+ - An empty string for non-component based installations
+ - :variable:`CPACK_DEBIAN_PACKAGE_BREAKS` for component-based
+ installations.
+
+ See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-breaks
+
+.. variable:: CPACK_DEBIAN_PACKAGE_CONFLICTS
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONFLICTS
+
+ Sets the `Conflicts` field of the Debian package.
+ When one binary package declares a conflict with another using a `Conflicts`
+ field, ``dpkg`` will not allow them to be unpacked on the system at
+ the same time.
+
+ * Mandatory : NO
+ * Default :
+
+ - An empty string for non-component based installations
+ - :variable:`CPACK_DEBIAN_PACKAGE_CONFLICTS` for component-based
+ installations.
+
+ See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-conflicts
+
+ .. note::
+
+ This is a stronger restriction than
+ :variable:`Breaks <CPACK_DEBIAN_PACKAGE_BREAKS>`, which prevents the
+ broken package from being configured while the breaking package is in
+ the "Unpacked" state but allows both packages to be unpacked at the same
+ time.
+
+.. variable:: CPACK_DEBIAN_PACKAGE_PROVIDES
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_PROVIDES
+
+ Sets the `Provides` field of the Debian package.
+ A virtual package is one which appears in the `Provides` control field of
+ another package.
+
+ * Mandatory : NO
+ * Default :
+
+ - An empty string for non-component based installations
+ - :variable:`CPACK_DEBIAN_PACKAGE_PROVIDES` for component-based
+ installations.
+
+ See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-virtual
+
+.. variable:: CPACK_DEBIAN_PACKAGE_REPLACES
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_REPLACES
+
+ Sets the `Replaces` field of the Debian package.
+ Packages can declare in their control file that they should overwrite
+ files in certain other packages, or completely replace other packages.
+
+ * Mandatory : NO
+ * Default :
+
+ - An empty string for non-component based installations
+ - :variable:`CPACK_DEBIAN_PACKAGE_REPLACES` for component-based
+ installations.
+
+ See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
+
+.. variable:: CPACK_DEBIAN_PACKAGE_RECOMMENDS
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_RECOMMENDS
+
+ Sets the `Recommends` field of the Debian package.
+ Allows packages to declare a strong, but not absolute, dependency on other
+ packages.
+
+ * Mandatory : NO
+ * Default :
+
+ - An empty string for non-component based installations
+ - :variable:`CPACK_DEBIAN_PACKAGE_RECOMMENDS` for component-based
+ installations.
+
+ See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
+
+.. variable:: CPACK_DEBIAN_PACKAGE_SUGGESTS
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_SUGGESTS
+
+ Sets the `Suggests` field of the Debian package.
+ Allows packages to declare a suggested package install grouping.
+
+ * Mandatory : NO
+ * Default :
+
+ - An empty string for non-component based installations
+ - :variable:`CPACK_DEBIAN_PACKAGE_SUGGESTS` for component-based
+ installations.
+
+ See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
+
+.. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS
+
+ * Mandatory : NO
+ * Default : OFF
+
+ Allows to generate shlibs control file automatically. Compatibility is defined by
+ :variable:`CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY` variable value.
+
+ .. note::
+
+ Libraries are only considered if they have both library name and version
+ set. This can be done by setting SOVERSION property with
+ :command:`set_target_properties` command.
+
+.. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY
+
+ Compatibility policy for auto-generated shlibs control file.
+
+ * Mandatory : NO
+ * Default : "="
+
+ Defines compatibility policy for auto-generated shlibs control file.
+ Possible values: "=", ">="
+
+ See https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-shlibdeps
+
+.. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRA
+
+ This variable allow advanced user to add custom script to the
+ control.tar.gz.
+ Typical usage is for conffiles, postinst, postrm, prerm.
+
+ * Mandatory : NO
+ * Default : -
+
+ Usage::
+
+ set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
+ "${CMAKE_CURRENT_SOURCE_DIR}/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
+
+ .. note::
+
+ The original permissions of the files will be used in the final
+ package unless the variable
+ :variable:`CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION` is set.
+ In particular, the scripts should have the proper executable
+ flag prior to the generation of the package.
+
+.. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_STRICT_PERMISSION
+
+ This variable indicates if the Debian policy on control files should be
+ strictly followed.
+
+ * Mandatory : NO
+ * Default : FALSE
+
+ Usage::
+
+ set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
+
+ .. note::
+
+ This overrides the permissions on the original files, following the rules
+ set by Debian policy
+ https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
+
+.. variable:: CPACK_DEBIAN_PACKAGE_SOURCE
+ CPACK_DEBIAN_<COMPONENT>_PACKAGE_SOURCE
+
+ Sets the ``Source`` field of the binary Debian package.
+ When the binary package name is not the same as the source package name
+ (in particular when several components/binaries are generated from one
+ source) the source from which the binary has been generated should be
+ indicated with the field ``Source``.
+
+ * Mandatory : NO
+ * Default :
+
+ - An empty string for non-component based installations
+ - :variable:`CPACK_DEBIAN_PACKAGE_SOURCE` for component-based
+ installations.
+
+ See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
+
+ .. note::
+
+ This value is not interpreted. It is possible to pass an optional
+ revision number of the referenced source package as well.
+
+Packaging of debug information
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Dbgsym packages contain debug symbols for debugging packaged binaries.
+
+Dbgsym packaging has its own set of variables:
+
+.. variable:: CPACK_DEBIAN_DEBUGINFO_PACKAGE
+ CPACK_DEBIAN_<component>_DEBUGINFO_PACKAGE
+
+ Enable generation of dbgsym .ddeb package(s).
+
+ * Mandatory : NO
+ * Default : OFF
+
+.. note::
+
+ Binaries must contain debug symbols before packaging so use either ``Debug``
+ or ``RelWithDebInfo`` for :variable:`CMAKE_BUILD_TYPE` variable value.
+
+Building Debian packages on Windows
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+To communicate UNIX file permissions from the install stage
+to the CPack DEB generator the "cmake_mode_t" NTFS
+alternate data stream (ADT) is used.
+
+When a filesystem without ADT support is used only owner read/write
+permissions can be preserved.
+
+Reproducible packages
+^^^^^^^^^^^^^^^^^^^^^
+
+The environment variable ``SOURCE_DATE_EPOCH`` may be set to a UNIX
+timestamp, defined as the number of seconds, excluding leap seconds,
+since 01 Jan 1970 00:00:00 UTC. If set, the CPack DEB generator will
+use its value for timestamps in the package.
diff --git a/Help/cpack_gen/dmg.rst b/Help/cpack_gen/dmg.rst
new file mode 100644
index 000000000..1e3788933
--- /dev/null
+++ b/Help/cpack_gen/dmg.rst
@@ -0,0 +1,101 @@
+CPack DragNDrop Generator
+-------------------------
+
+The DragNDrop CPack generator (macOS) creates a DMG image.
+
+Variables specific to CPack DragNDrop generator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The following variables are specific to the DragNDrop installers built
+on macOS:
+
+.. variable:: CPACK_DMG_VOLUME_NAME
+
+ The volume name of the generated disk image. Defaults to
+ CPACK_PACKAGE_FILE_NAME.
+
+.. variable:: CPACK_DMG_FORMAT
+
+ The disk image format. Common values are ``UDRO`` (UDIF read-only), ``UDZO`` (UDIF
+ zlib-compressed) or ``UDBZ`` (UDIF bzip2-compressed). Refer to ``hdiutil(1)`` for
+ more information on other available formats. Defaults to ``UDZO``.
+
+.. variable:: CPACK_DMG_DS_STORE
+
+ Path to a custom ``.DS_Store`` file. This ``.DS_Store`` file can be used to
+ specify the Finder window position/geometry and layout (such as hidden
+ toolbars, placement of the icons etc.). This file has to be generated by
+ the Finder (either manually or through AppleScript) using a normal folder
+ from which the ``.DS_Store`` file can then be extracted.
+
+.. variable:: CPACK_DMG_DS_STORE_SETUP_SCRIPT
+
+ Path to a custom AppleScript file. This AppleScript is used to generate
+ a ``.DS_Store`` file which specifies the Finder window position/geometry and
+ layout (such as hidden toolbars, placement of the icons etc.).
+ By specifying a custom AppleScript there is no need to use
+ ``CPACK_DMG_DS_STORE``, as the ``.DS_Store`` that is generated by the AppleScript
+ will be packaged.
+
+.. variable:: CPACK_DMG_BACKGROUND_IMAGE
+
+ Path to an image file to be used as the background. This file will be
+ copied to ``.background``/``background.<ext>``, where ``<ext>`` is the original image file
+ extension. The background image is installed into the image before
+ ``CPACK_DMG_DS_STORE_SETUP_SCRIPT`` is executed or ``CPACK_DMG_DS_STORE`` is
+ installed. By default no background image is set.
+
+.. variable:: CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK
+
+ Default behaviour is to include a symlink to ``/Applications`` in the DMG.
+ Set this option to ``ON`` to avoid adding the symlink.
+
+.. variable:: CPACK_DMG_SLA_DIR
+
+ Directory where license and menu files for different languages are stored.
+ Setting this causes CPack to look for a ``<language>.menu.txt`` and
+ ``<language>.license.txt`` file for every language defined in
+ ``CPACK_DMG_SLA_LANGUAGES``. If both this variable and
+ ``CPACK_RESOURCE_FILE_LICENSE`` are set, CPack will only look for the menu
+ files and use the same license file for all languages.
+
+.. variable:: CPACK_DMG_SLA_LANGUAGES
+
+ Languages for which a license agreement is provided when mounting the
+ generated DMG. A menu file consists of 9 lines of text. The first line is
+ is the name of the language itself, uppercase, in English (e.g. German).
+ The other lines are translations of the following strings:
+
+ - Agree
+ - Disagree
+ - Print
+ - Save...
+ - You agree to the terms of the License Agreement when you click the
+ "Agree" button.
+ - Software License Agreement
+ - This text cannot be saved. The disk may be full or locked, or the file
+ may be locked.
+ - Unable to print. Make sure you have selected a printer.
+
+ For every language in this list, CPack will try to find files
+ ``<language>.menu.txt`` and ``<language>.license.txt`` in the directory
+ specified by the :variable:`CPACK_DMG_SLA_DIR` variable.
+
+.. variable:: CPACK_COMMAND_HDIUTIL
+
+ Path to the ``hdiutil(1)`` command used to operate on disk image files on
+ macOS. This variable can be used to override the automatically detected
+ command (or specify its location if the auto-detection fails to find it).
+
+.. variable:: CPACK_COMMAND_SETFILE
+
+ Path to the ``SetFile(1)`` command used to set extended attributes on files and
+ directories on macOS. This variable can be used to override the
+ automatically detected command (or specify its location if the
+ auto-detection fails to find it).
+
+.. variable:: CPACK_COMMAND_REZ
+
+ Path to the ``Rez(1)`` command used to compile resources on macOS. This
+ variable can be used to override the automatically detected command (or
+ specify its location if the auto-detection fails to find it).
diff --git a/Help/cpack_gen/external.rst b/Help/cpack_gen/external.rst
new file mode 100644
index 000000000..406f6be1a
--- /dev/null
+++ b/Help/cpack_gen/external.rst
@@ -0,0 +1,283 @@
+CPack External Generator
+------------------------
+
+CPack provides many generators to create packages for a variety of platforms
+and packaging systems. The intention is for CMake/CPack to be a complete
+end-to-end solution for building and packaging a software project. However, it
+may not always be possible to use CPack for the entire packaging process, due
+to either technical limitations or policies that require the use of certain
+tools. For this reason, CPack provides the "External" generator, which allows
+external packaging software to take advantage of some of the functionality
+provided by CPack, such as component installation and the dependency graph.
+
+Integration with External Packaging Tools
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The CPack External generator generates a ``.json`` file containing the
+CPack internal metadata, which gives external software information
+on how to package the software. External packaging software may itself
+invoke CPack, consume the generated metadata,
+install and package files as required.
+
+Alternatively CPack can invoke an external packaging software
+through an optional custom CMake script in
+:variable:`CPACK_EXTERNAL_PACKAGE_SCRIPT` instead.
+
+Staging of installation files may also optionally be
+taken care of by the generator when enabled through the
+:variable:`CPACK_EXTERNAL_ENABLE_STAGING` variable.
+
+JSON Format
+^^^^^^^^^^^
+
+The JSON metadata file contains a list of CPack components and component groups,
+the various options passed to :command:`cpack_add_component` and
+:command:`cpack_add_component_group`, the dependencies between the components
+and component groups, and various other options passed to CPack.
+
+The JSON's root object will always provide two fields:
+``formatVersionMajor`` and ``formatVersionMinor``, which are always integers
+that describe the output format of the generator. Backwards-compatible changes
+to the output format (for example, adding a new field that didn't exist before)
+cause the minor version to be incremented, and backwards-incompatible changes
+(for example, deleting a field or changing its meaning) cause the major version
+to be incremented and the minor version reset to 0. The format version is
+always of the format ``major.minor``. In other words, it always has exactly two
+parts, separated by a period.
+
+You can request one or more specific versions of the output format as described
+below with :variable:`CPACK_EXTERNAL_REQUESTED_VERSIONS`. The output format will
+have a major version that exactly matches the requested major version, and a
+minor version that is greater than or equal to the requested minor version. If
+no version is requested with :variable:`CPACK_EXTERNAL_REQUESTED_VERSIONS`, the
+latest known major version is used by default. Currently, the only supported
+format is 1.0, which is described below.
+
+Version 1.0
+***********
+
+In addition to the standard format fields, format version 1.0 provides the
+following fields in the root:
+
+``components``
+ The ``components`` field is an object with component names as the keys and
+ objects describing the components as the values. The component objects have
+ the following fields:
+
+ ``name``
+ The name of the component. This is always the same as the key in the
+ ``components`` object.
+
+ ``displayName``
+ The value of the ``DISPLAY_NAME`` field passed to
+ :command:`cpack_add_component`.
+
+ ``description``
+ The value of the ``DESCRIPTION`` field passed to
+ :command:`cpack_add_component`.
+
+ ``isHidden``
+ True if ``HIDDEN`` was passed to :command:`cpack_add_component`, false if
+ it was not.
+
+ ``isRequired``
+ True if ``REQUIRED`` was passed to :command:`cpack_add_component`, false if
+ it was not.
+
+ ``isDisabledByDefault``
+ True if ``DISABLED`` was passed to :command:`cpack_add_component`, false if
+ it was not.
+
+ ``group``
+ Only present if ``GROUP`` was passed to :command:`cpack_add_component`. If
+ so, this field is a string value containing the component's group.
+
+ ``dependencies``
+ An array of components the component depends on. This contains the values
+ in the ``DEPENDS`` argument passed to :command:`cpack_add_component`. If no
+ ``DEPENDS`` argument was passed, this is an empty list.
+
+ ``installationTypes``
+ An array of installation types the component is part of. This contains the
+ values in the ``INSTALL_TYPES`` argument passed to
+ :command:`cpack_add_component`. If no ``INSTALL_TYPES`` argument was
+ passed, this is an empty list.
+
+ ``isDownloaded``
+ True if ``DOWNLOADED`` was passed to :command:`cpack_add_component`, false
+ if it was not.
+
+ ``archiveFile``
+ The name of the archive file passed with the ``ARCHIVE_FILE`` argument to
+ :command:`cpack_add_component`. If no ``ARCHIVE_FILE`` argument was passed,
+ this is an empty string.
+
+``componentGroups``
+ The ``componentGroups`` field is an object with component group names as the
+ keys and objects describing the component groups as the values. The component
+ group objects have the following fields:
+
+ ``name``
+ The name of the component group. This is always the same as the key in the
+ ``componentGroups`` object.
+
+ ``displayName``
+ The value of the ``DISPLAY_NAME`` field passed to
+ :command:`cpack_add_component_group`.
+
+ ``description``
+ The value of the ``DESCRIPTION`` field passed to
+ :command:`cpack_add_component_group`.
+
+ ``parentGroup``
+ Only present if ``PARENT_GROUP`` was passed to
+ :command:`cpack_add_component_group`. If so, this field is a string value
+ containing the component group's parent group.
+
+ ``isExpandedByDefault``
+ True if ``EXPANDED`` was passed to :command:`cpack_add_component_group`,
+ false if it was not.
+
+ ``isBold``
+ True if ``BOLD_TITLE`` was passed to :command:`cpack_add_component_group`,
+ false if it was not.
+
+ ``components``
+ An array of names of components that are direct members of the group
+ (components that have this group as their ``GROUP``). Components of
+ subgroups are not included.
+
+ ``subgroups``
+ An array of names of component groups that are subgroups of the group
+ (groups that have this group as their ``PARENT_GROUP``).
+
+``installationTypes``
+ The ``installationTypes`` field is an object with installation type names as
+ the keys and objects describing the installation types as the values. The
+ installation type objects have the following fields:
+
+ ``name``
+ The name of the installation type. This is always the same as the key in
+ the ``installationTypes`` object.
+
+ ``displayName``
+ The value of the ``DISPLAY_NAME`` field passed to
+ :command:`cpack_add_install_type`.
+
+ ``index``
+ The integer index of the installation type in the list.
+
+``projects``
+ The ``projects`` field is an array of objects describing CMake projects which
+ comprise the CPack project. The values in this field are derived from
+ :variable:`CPACK_INSTALL_CMAKE_PROJECTS`. In most cases, this will be only a
+ single project. The project objects have the following fields:
+
+ ``projectName``
+ The project name passed to :variable:`CPACK_INSTALL_CMAKE_PROJECTS`.
+
+ ``component``
+ The name of the component or component set which comprises the project.
+
+ ``directory``
+ The build directory of the CMake project. This is the directory which
+ contains the ``cmake_install.cmake`` script.
+
+ ``subDirectory``
+ The subdirectory to install the project into inside the CPack package.
+
+``packageName``
+ The package name given in :variable:`CPACK_PACKAGE_NAME`. Only present if
+ this option is set.
+
+``packageVersion``
+ The package version given in :variable:`CPACK_PACKAGE_VERSION`. Only present
+ if this option is set.
+
+``packageDescriptionFile``
+ The package description file given in
+ :variable:`CPACK_PACKAGE_DESCRIPTION_FILE`. Only present if this option is
+ set.
+
+``packageDescriptionSummary``
+ The package description summary given in
+ :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`. Only present if this option is
+ set.
+
+``buildConfig``
+ The build configuration given to CPack with the ``-C`` option. Only present
+ if this option is set.
+
+``defaultDirectoryPermissions``
+ The default directory permissions given in
+ :variable:`CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS`. Only present if this
+ option is set.
+
+``setDestdir``
+ True if :variable:`CPACK_SET_DESTDIR` is true, false if it is not.
+
+``packagingInstallPrefix``
+ The install prefix given in :variable:`CPACK_PACKAGING_INSTALL_PREFIX`. Only
+ present if :variable:`CPACK_SET_DESTDIR` is true.
+
+``stripFiles``
+ True if :variable:`CPACK_STRIP_FILES` is true, false if it is not.
+
+``warnOnAbsoluteInstallDestination``
+ True if :variable:`CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION` is true, false
+ if it is not.
+
+``errorOnAbsoluteInstallDestination``
+ True if :variable:`CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION` is true,
+ false if it is not.
+
+Variables specific to CPack External generator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. variable:: CPACK_EXTERNAL_REQUESTED_VERSIONS
+
+ This variable is used to request a specific version of the CPack External
+ generator. It is a list of ``major.minor`` values, separated by semicolons.
+
+ If this variable is set to a non-empty value, the CPack External generator
+ will iterate through each item in the list to search for a version that it
+ knows how to generate. Requested versions should be listed in order of
+ descending preference by the client software, as the first matching version
+ in the list will be generated.
+
+ The generator knows how to generate the version if it has a versioned
+ generator whose major version exactly matches the requested major version,
+ and whose minor version is greater than or equal to the requested minor
+ version. For example, if ``CPACK_EXTERNAL_REQUESTED_VERSIONS`` contains 1.0, and
+ the CPack External generator knows how to generate 1.1, it will generate 1.1.
+ If the generator doesn't know how to generate a version in the list, it skips
+ the version and looks at the next one. If it doesn't know how to generate any
+ of the requested versions, an error is thrown.
+
+ If this variable is not set, or is empty, the CPack External generator will
+ generate the highest major and minor version that it knows how to generate.
+
+ If an invalid version is encountered in ``CPACK_EXTERNAL_REQUESTED_VERSIONS`` (one
+ that doesn't match ``major.minor``, where ``major`` and ``minor`` are
+ integers), it is ignored.
+
+.. variable:: CPACK_EXTERNAL_ENABLE_STAGING
+
+ This variable can be set to true to enable optional installation
+ into a temporary staging area which can then be picked up
+ and packaged by an external packaging tool.
+ The top level directory used by CPack for the current packaging
+ task is contained in ``CPACK_TOPLEVEL_DIRECTORY``.
+ It is automatically cleaned up on each run before packaging is initiated
+ and can be used for custom temporary files required by
+ the external packaging tool.
+ It also contains the staging area ``CPACK_TEMPORARY_DIRECTORY``
+ into which CPack performs the installation when staging is enabled.
+
+.. variable:: CPACK_EXTERNAL_PACKAGE_SCRIPT
+
+ This variable can optionally specify the full path to
+ a CMake script file to be run as part of the CPack invocation.
+ It is invoked after (optional) staging took place and may
+ run an external packaging tool. The script has access to
+ the variables defined by the CPack config file.
diff --git a/Help/cpack_gen/freebsd.rst b/Help/cpack_gen/freebsd.rst
new file mode 100644
index 000000000..a8dd32050
--- /dev/null
+++ b/Help/cpack_gen/freebsd.rst
@@ -0,0 +1,138 @@
+CPack FreeBSD Generator
+-----------------------
+
+The built in (binary) CPack FreeBSD (pkg) generator (Unix only)
+
+Variables specific to CPack FreeBSD (pkg) generator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The CPack FreeBSD generator may be used to create pkg(8) packages -- these may
+be used on FreeBSD, DragonflyBSD, NetBSD, OpenBSD, but also on Linux or OSX,
+depending on the installed package-management tools -- using :module:`CPack`.
+
+The CPack FreeBSD generator is a :module:`CPack` generator and uses the
+``CPACK_XXX`` variables used by :module:`CPack`. It tries to re-use packaging
+information that may already be specified for Debian packages for the
+:cpack_gen:`CPack DEB Generator`. It also tries to re-use RPM packaging
+information when Debian does not specify.
+
+The CPack FreeBSD generator should work on any host with libpkg installed. The
+packages it produces are specific to the host architecture and ABI.
+
+The CPack FreeBSD generator sets package-metadata through
+``CPACK_FREEBSD_XXX`` variables. The CPack FreeBSD generator, unlike the
+CPack Deb generator, does not specially support componentized packages; a
+single package is created from all the software artifacts created through
+CMake.
+
+All of the variables can be set specifically for FreeBSD packaging in
+the CPackConfig file or in CMakeLists.txt, but most of them have defaults
+that use general settings (e.g. CMAKE_PROJECT_NAME) or Debian-specific
+variables when those make sense (e.g. the homepage of an upstream project
+is usually unchanged by the flavor of packaging). When there is no Debian
+information to fall back on, but the RPM packaging has it, fall back to
+the RPM information (e.g. package license).
+
+.. variable:: CPACK_FREEBSD_PACKAGE_NAME
+
+ Sets the package name (in the package manifest, but also affects the
+ output filename).
+
+ * Mandatory: YES
+ * Default:
+
+ - :variable:`CPACK_PACKAGE_NAME` (this is always set by CPack itself,
+ based on CMAKE_PROJECT_NAME).
+
+.. variable:: CPACK_FREEBSD_PACKAGE_COMMENT
+
+ Sets the package comment. This is the short description displayed by
+ pkg(8) in standard "pkg info" output.
+
+ * Mandatory: YES
+ * Default:
+
+ - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY` (this is always set
+ by CPack itself, if nothing else sets it explicitly).
+ - :variable:`PROJECT_DESCRIPTION` (this can be set with the DESCRIPTION
+ parameter for :command:`project`).
+
+.. variable:: CPACK_FREEBSD_PACKAGE_DESCRIPTION
+
+ Sets the package description. This is the long description of the package,
+ given by "pkg info" with a specific package as argument.
+
+ * Mandatory: YES
+ * Default:
+
+ - :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` (this may be set already
+ for Debian packaging, so we may as well re-use it).
+
+.. variable:: CPACK_FREEBSD_PACKAGE_WWW
+
+ The URL of the web site for this package, preferably (when applicable) the
+ site from which the original source can be obtained and any additional
+ upstream documentation or information may be found.
+
+ * Mandatory: YES
+ * Default:
+
+ - :variable:`CMAKE_PROJECT_HOMEPAGE_URL`, or if that is not set,
+ :variable:`CPACK_DEBIAN_PACKAGE_HOMEPAGE` (this may be set already
+ for Debian packaging, so we may as well re-use it).
+
+.. variable:: CPACK_FREEBSD_PACKAGE_LICENSE
+
+ The license, or licenses, which apply to this software package. This must
+ be one or more license-identifiers that pkg recognizes as acceptable license
+ identifiers (e.g. "GPLv2").
+
+ * Mandatory: YES
+ * Default:
+
+ - :variable:`CPACK_RPM_PACKAGE_LICENSE`
+
+.. variable:: CPACK_FREEBSD_PACKAGE_LICENSE_LOGIC
+
+ This variable is only of importance if there is more than one license.
+ The default is "single", which is only applicable to a single license.
+ Other acceptable values are determined by pkg -- those are "dual" or "multi" --
+ meaning choice (OR) or simultaneous (AND) application of the licenses.
+
+ * Mandatory: NO
+ * Default: single
+
+.. variable:: CPACK_FREEBSD_PACKAGE_MAINTAINER
+
+ The FreeBSD maintainer (e.g. kde@freebsd.org) of this package.
+
+ * Mandatory: YES
+ * Default: none
+
+.. variable:: CPACK_FREEBSD_PACKAGE_ORIGIN
+
+ The origin (ports label) of this package; for packages built by CPack
+ outside of the ports system this is of less importance. The default
+ puts the package somewhere under misc/, as a stopgap.
+
+ * Mandatory: YES
+ * Default: misc/<package name>
+
+.. variable:: CPACK_FREEBSD_PACKAGE_CATEGORIES
+
+ The ports categories where this package lives (if it were to be built
+ from ports). If none is set a single category is determined based on
+ the package origin.
+
+ * Mandatory: YES
+ * Default: derived from ORIGIN
+
+.. variable:: CPACK_FREEBSD_PACKAGE_DEPS
+
+ A list of package origins that should be added as package dependencies.
+ These are in the form <category>/<packagename>, e.g. x11/libkonq.
+ No version information needs to be provided (this is not included
+ in the manifest).
+
+ * Mandatory: NO
+ * Default: empty
diff --git a/Help/cpack_gen/ifw.rst b/Help/cpack_gen/ifw.rst
new file mode 100644
index 000000000..feccd3db0
--- /dev/null
+++ b/Help/cpack_gen/ifw.rst
@@ -0,0 +1,339 @@
+CPack IFW Generator
+-------------------
+
+See :module:`CPackIFW` for details on the CPackIFW module.
+
+.. _QtIFW: http://doc.qt.io/qtinstallerframework/index.html
+
+
+Overview
+^^^^^^^^
+
+CPack ``IFW`` generator helps you to create online and offline
+binary cross-platform installers with a graphical user interface.
+
+CPack IFW generator prepares project installation and generates configuration
+and meta information for QtIFW_ tools.
+
+The QtIFW_ provides a set of tools and utilities to create
+installers for the supported desktop Qt platforms: Linux, Microsoft Windows,
+and macOS.
+
+You should also install QtIFW_ to use CPack ``IFW`` generator.
+
+Hints
+^^^^^
+
+Generally, the CPack ``IFW`` generator automatically finds QtIFW_ tools,
+but if you don't use a default path for installation of the QtIFW_ tools,
+the path may be specified in either a CMake or an environment variable:
+
+.. variable:: CPACK_IFW_ROOT
+
+ An CMake variable which specifies the location of the QtIFW_ tool suite.
+
+ The variable will be cached in the ``CPackConfig.cmake`` file and used at
+ CPack runtime.
+
+.. variable:: QTIFWDIR
+
+ An environment variable which specifies the location of the QtIFW_ tool
+ suite.
+
+.. note::
+ The specified path should not contain "bin" at the end
+ (for example: "D:\\DevTools\\QtIFW2.0.5").
+
+The :variable:`CPACK_IFW_ROOT` variable has a higher priority and overrides
+the value of the :variable:`QTIFWDIR` variable.
+
+Internationalization
+^^^^^^^^^^^^^^^^^^^^
+
+Some variables and command arguments support internationalization via
+CMake script. This is an optional feature.
+
+Installers created by QtIFW_ tools have built-in support for
+internationalization and many phrases are localized to many languages,
+but this does not apply to the description of the your components and groups
+that will be distributed.
+
+Localization of the description of your components and groups is useful for
+users of your installers.
+
+A localized variable or argument can contain a single default value, and a
+set of pairs the name of the locale and the localized value.
+
+For example:
+
+.. code-block:: cmake
+
+ set(LOCALIZABLE_VARIABLE "Default value"
+ en "English value"
+ en_US "American value"
+ en_GB "Great Britain value"
+ )
+
+Variables
+^^^^^^^^^
+
+You can use the following variables to change behavior of CPack ``IFW``
+generator.
+
+Debug
+"""""
+
+.. variable:: CPACK_IFW_VERBOSE
+
+ Set to ``ON`` to enable addition debug output.
+ By default is ``OFF``.
+
+Package
+"""""""
+
+.. variable:: CPACK_IFW_PACKAGE_TITLE
+
+ Name of the installer as displayed on the title bar.
+ By default used :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`.
+
+.. variable:: CPACK_IFW_PACKAGE_PUBLISHER
+
+ Publisher of the software (as shown in the Windows Control Panel).
+ By default used :variable:`CPACK_PACKAGE_VENDOR`.
+
+.. variable:: CPACK_IFW_PRODUCT_URL
+
+ URL to a page that contains product information on your web site.
+
+.. variable:: CPACK_IFW_PACKAGE_ICON
+
+ Filename for a custom installer icon. The actual file is '.icns' (macOS),
+ '.ico' (Windows). No functionality on Unix.
+
+.. variable:: CPACK_IFW_PACKAGE_WINDOW_ICON
+
+ Filename for a custom window icon in PNG format for the Installer
+ application.
+
+.. variable:: CPACK_IFW_PACKAGE_LOGO
+
+ Filename for a logo is used as QWizard::LogoPixmap.
+
+.. variable:: CPACK_IFW_PACKAGE_WATERMARK
+
+ Filename for a watermark is used as QWizard::WatermarkPixmap.
+
+.. variable:: CPACK_IFW_PACKAGE_BANNER
+
+ Filename for a banner is used as QWizard::BannerPixmap.
+
+.. variable:: CPACK_IFW_PACKAGE_BACKGROUND
+
+ Filename for an image used as QWizard::BackgroundPixmap (only used by MacStyle).
+
+.. variable:: CPACK_IFW_PACKAGE_WIZARD_STYLE
+
+ Wizard style to be used ("Modern", "Mac", "Aero" or "Classic").
+
+.. variable:: CPACK_IFW_PACKAGE_STYLE_SHEET
+
+ Filename for a stylesheet.
+
+.. variable:: CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH
+
+ Default width of the wizard in pixels. Setting a banner image will override this.
+
+.. variable:: CPACK_IFW_PACKAGE_WIZARD_DEFAULT_HEIGHT
+
+ Default height of the wizard in pixels. Setting a watermark image will override this.
+
+.. variable:: CPACK_IFW_PACKAGE_TITLE_COLOR
+
+ Color of the titles and subtitles (takes an HTML color code, such as "#88FF33").
+
+.. variable:: CPACK_IFW_PACKAGE_START_MENU_DIRECTORY
+
+ Name of the default program group for the product in the Windows Start menu.
+
+ By default used :variable:`CPACK_IFW_PACKAGE_NAME`.
+
+.. variable:: CPACK_IFW_TARGET_DIRECTORY
+
+ Default target directory for installation.
+ By default used
+ "@ApplicationsDir@/:variable:`CPACK_PACKAGE_INSTALL_DIRECTORY`"
+
+ You can use predefined variables.
+
+.. variable:: CPACK_IFW_ADMIN_TARGET_DIRECTORY
+
+ Default target directory for installation with administrator rights.
+
+ You can use predefined variables.
+
+.. variable:: CPACK_IFW_PACKAGE_GROUP
+
+ The group, which will be used to configure the root package
+
+.. variable:: CPACK_IFW_PACKAGE_NAME
+
+ The root package name, which will be used if configuration group is not
+ specified
+
+.. variable:: CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME
+
+ Filename of the generated maintenance tool.
+ The platform-specific executable file extension is appended.
+
+ By default used QtIFW_ defaults (``maintenancetool``).
+
+.. variable:: CPACK_IFW_PACKAGE_REMOVE_TARGET_DIR
+
+ Set to ``OFF`` if the target directory should not be deleted when uninstalling.
+
+ Is ``ON`` by default
+
+.. variable:: CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE
+
+ Filename for the configuration of the generated maintenance tool.
+
+ By default used QtIFW_ defaults (``maintenancetool.ini``).
+
+.. variable:: CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS
+
+ Set to ``ON`` if the installation path can contain non-ASCII characters.
+
+ Is ``ON`` for QtIFW_ less 2.0 tools.
+
+.. variable:: CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH
+
+ Set to ``OFF`` if the installation path cannot contain space characters.
+
+ Is ``ON`` for QtIFW_ less 2.0 tools.
+
+.. variable:: CPACK_IFW_PACKAGE_CONTROL_SCRIPT
+
+ Filename for a custom installer control script.
+
+.. variable:: CPACK_IFW_PACKAGE_RESOURCES
+
+ List of additional resources ('.qrc' files) to include in the installer
+ binary.
+
+ You can use :command:`cpack_ifw_add_package_resources` command to resolve
+ relative paths.
+
+.. variable:: CPACK_IFW_PACKAGE_FILE_EXTENSION
+
+ The target binary extension.
+
+ On Linux, the name of the target binary is automatically extended with
+ '.run', if you do not specify the extension.
+
+ On Windows, the target is created as an application with the extension
+ '.exe', which is automatically added, if not supplied.
+
+ On Mac, the target is created as an DMG disk image with the extension
+ '.dmg', which is automatically added, if not supplied.
+
+.. variable:: CPACK_IFW_REPOSITORIES_ALL
+
+ The list of remote repositories.
+
+ The default value of this variable is computed by CPack and contains
+ all repositories added with command :command:`cpack_ifw_add_repository`
+ or updated with command :command:`cpack_ifw_update_repository`.
+
+.. variable:: CPACK_IFW_DOWNLOAD_ALL
+
+ If this is ``ON`` all components will be downloaded.
+ By default is ``OFF`` or used value
+ from ``CPACK_DOWNLOAD_ALL`` if set
+
+Components
+""""""""""
+
+.. variable:: CPACK_IFW_RESOLVE_DUPLICATE_NAMES
+
+ Resolve duplicate names when installing components with groups.
+
+.. variable:: CPACK_IFW_PACKAGES_DIRECTORIES
+
+ Additional prepared packages dirs that will be used to resolve
+ dependent components.
+
+.. variable:: CPACK_IFW_REPOSITORIES_DIRECTORIES
+
+ Additional prepared repository dirs that will be used to resolve and
+ repack dependent components. This feature available only
+ since QtIFW_ 3.1.
+
+Tools
+"""""
+
+.. variable:: CPACK_IFW_FRAMEWORK_VERSION
+
+ The version of used QtIFW_ tools.
+
+.. variable:: CPACK_IFW_BINARYCREATOR_EXECUTABLE
+
+ The path to "binarycreator" command line client.
+
+ This variable is cached and may be configured if needed.
+
+.. variable:: CPACK_IFW_REPOGEN_EXECUTABLE
+
+ The path to "repogen" command line client.
+
+ This variable is cached and may be configured if needed.
+
+.. variable:: CPACK_IFW_INSTALLERBASE_EXECUTABLE
+
+ The path to "installerbase" installer executable base.
+
+ This variable is cached and may be configured if needed.
+
+.. variable:: CPACK_IFW_DEVTOOL_EXECUTABLE
+
+ The path to "devtool" command line client.
+
+ This variable is cached and may be configured if needed.
+
+
+Online installer
+^^^^^^^^^^^^^^^^
+
+By default CPack IFW generator makes offline installer. This means that all
+components will be packaged into a binary file.
+
+To make a component downloaded, you must set the ``DOWNLOADED`` option in
+:command:`cpack_add_component`.
+
+Then you would use the command :command:`cpack_configure_downloads`.
+If you set ``ALL`` option all components will be downloaded.
+
+You also can use command :command:`cpack_ifw_add_repository` and
+variable :variable:`CPACK_IFW_DOWNLOAD_ALL` for more specific configuration.
+
+CPack IFW generator creates "repository" dir in current binary dir. You
+would copy content of this dir to specified ``site`` (``url``).
+
+See Also
+^^^^^^^^
+
+Qt Installer Framework Manual:
+
+* Index page:
+ http://doc.qt.io/qtinstallerframework/index.html
+
+* Component Scripting:
+ http://doc.qt.io/qtinstallerframework/scripting.html
+
+* Predefined Variables:
+ http://doc.qt.io/qtinstallerframework/scripting.html#predefined-variables
+
+* Promoting Updates:
+ http://doc.qt.io/qtinstallerframework/ifw-updates.html
+
+Download Qt Installer Framework for you platform from Qt site:
+ http://download.qt.io/official_releases/qt-installer-framework
diff --git a/Help/cpack_gen/nsis.rst b/Help/cpack_gen/nsis.rst
new file mode 100644
index 000000000..cd2aea682
--- /dev/null
+++ b/Help/cpack_gen/nsis.rst
@@ -0,0 +1,130 @@
+CPack NSIS Generator
+--------------------
+
+CPack Nullsoft Scriptable Install System (NSIS) generator specific options
+
+Variables specific to CPack NSIS generator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The following variables are specific to the graphical installers built
+on Windows Nullsoft Scriptable Install System.
+
+.. variable:: CPACK_NSIS_INSTALL_ROOT
+
+ The default installation directory presented to the end user by the NSIS
+ installer is under this root dir. The full directory presented to the end
+ user is: ``${CPACK_NSIS_INSTALL_ROOT}/${CPACK_PACKAGE_INSTALL_DIRECTORY}``
+
+.. variable:: CPACK_NSIS_MUI_ICON
+
+ An icon filename. The name of a ``*.ico`` file used as the main icon for the
+ generated install program.
+
+.. variable:: CPACK_NSIS_MUI_UNIICON
+
+ An icon filename. The name of a ``*.ico`` file used as the main icon for the
+ generated uninstall program.
+
+.. variable:: CPACK_NSIS_INSTALLER_MUI_ICON_CODE
+
+ undocumented.
+
+.. variable:: CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP
+
+ The filename of a bitmap to use as the NSIS ``MUI_WELCOMEFINISHPAGE_BITMAP``.
+
+.. variable:: CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP
+
+ The filename of a bitmap to use as the NSIS ``MUI_UNWELCOMEFINISHPAGE_BITMAP``.
+
+.. variable:: CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS
+
+ Extra NSIS commands that will be added to the beginning of the install
+ Section, before your install tree is available on the target system.
+
+.. variable:: CPACK_NSIS_EXTRA_INSTALL_COMMANDS
+
+ Extra NSIS commands that will be added to the end of the install Section,
+ after your install tree is available on the target system.
+
+.. variable:: CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
+
+ Extra NSIS commands that will be added to the uninstall Section, before
+ your install tree is removed from the target system.
+
+.. variable:: CPACK_NSIS_COMPRESSOR
+
+ The arguments that will be passed to the NSIS `SetCompressor` command.
+
+.. variable:: CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL
+
+ Ask about uninstalling previous versions first. If this is set to ``ON``,
+ then an installer will look for previous installed versions and if one is
+ found, ask the user whether to uninstall it before proceeding with the
+ install.
+
+.. variable:: CPACK_NSIS_MODIFY_PATH
+
+ Modify ``PATH`` toggle. If this is set to ``ON``, then an extra page will appear
+ in the installer that will allow the user to choose whether the program
+ directory should be added to the system ``PATH`` variable.
+
+.. variable:: CPACK_NSIS_DISPLAY_NAME
+
+ The display name string that appears in the Windows `Apps & features`
+ in `Control Panel`
+
+.. variable:: CPACK_NSIS_PACKAGE_NAME
+
+ The title displayed at the top of the installer.
+
+.. variable:: CPACK_NSIS_INSTALLED_ICON_NAME
+
+ A path to the executable that contains the installer icon.
+
+.. variable:: CPACK_NSIS_HELP_LINK
+
+ URL to a web site providing assistance in installing your application.
+
+.. variable:: CPACK_NSIS_URL_INFO_ABOUT
+
+ URL to a web site providing more information about your application.
+
+.. variable:: CPACK_NSIS_CONTACT
+
+ Contact information for questions and comments about the installation
+ process.
+
+.. variable:: CPACK_NSIS_<compName>_INSTALL_DIRECTORY
+
+ Custom install directory for the specified component ``<compName>`` instead
+ of ``$INSTDIR``.
+
+.. variable:: CPACK_NSIS_CREATE_ICONS_EXTRA
+
+ Additional NSIS commands for creating `Start Menu` shortcuts.
+
+.. variable:: CPACK_NSIS_DELETE_ICONS_EXTRA
+
+ Additional NSIS commands to uninstall `Start Menu` shortcuts.
+
+.. variable:: CPACK_NSIS_EXECUTABLES_DIRECTORY
+
+ Creating NSIS `Start Menu` links assumes that they are in ``bin`` unless this
+ variable is set. For example, you would set this to ``exec`` if your
+ executables are in an exec directory.
+
+.. variable:: CPACK_NSIS_MUI_FINISHPAGE_RUN
+
+ Specify an executable to add an option to run on the finish page of the
+ NSIS installer.
+
+.. variable:: CPACK_NSIS_MENU_LINKS
+
+ Specify links in ``[application]`` menu. This should contain a list of pair
+ ``link`` ``link name``. The link may be a URL or a path relative to
+ installation prefix. Like::
+
+ set(CPACK_NSIS_MENU_LINKS
+ "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake.html"
+ "CMake Help" "https://cmake.org" "CMake Web Site")
diff --git a/Help/cpack_gen/nuget.rst b/Help/cpack_gen/nuget.rst
new file mode 100644
index 000000000..f8aa6266b
--- /dev/null
+++ b/Help/cpack_gen/nuget.rst
@@ -0,0 +1,189 @@
+CPack NuGet Generator
+---------------------
+
+When build a NuGet package there is no direct way to control an output
+filename due a lack of the corresponding CLI option of NuGet, so there
+is no ``CPACK_NUGET_PACKAGE_FILENAME`` variable. To form the output filename
+NuGet uses the package name and the version according to its built-in rules.
+
+Also, be aware that including a top level directory
+(``CPACK_INCLUDE_TOPLEVEL_DIRECTORY``) is ignored by this generator.
+
+
+Variables specific to CPack NuGet generator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The CPack NuGet generator may be used to create NuGet packages using
+:module:`CPack`. The CPack NuGet generator is a :module:`CPack` generator thus
+it uses the ``CPACK_XXX`` variables used by :module:`CPack`.
+
+The CPack NuGet generator has specific features which are controlled by the
+specifics ``CPACK_NUGET_XXX`` variables. In the "one per group" mode
+(see :variable:`CPACK_COMPONENTS_GROUPING`), ``<compName>`` placeholder
+in the variables below would contain a group name (uppercased and turned into
+a "C" identifier).
+
+List of CPack NuGet generator specific variables:
+
+.. variable:: CPACK_NUGET_COMPONENT_INSTALL
+
+ Enable component packaging for CPack NuGet generator
+
+ * Mandatory : NO
+ * Default : OFF
+
+.. variable:: CPACK_NUGET_PACKAGE_NAME
+ CPACK_NUGET_<compName>_PACKAGE_NAME
+
+ The NUGET package name.
+
+ * Mandatory : YES
+ * Default : :variable:`CPACK_PACKAGE_NAME`
+
+.. variable:: CPACK_NUGET_PACKAGE_VERSION
+ CPACK_NUGET_<compName>_PACKAGE_VERSION
+
+ The NuGet package version.
+
+ * Mandatory : YES
+ * Default : :variable:`CPACK_PACKAGE_VERSION`
+
+.. variable:: CPACK_NUGET_PACKAGE_DESCRIPTION
+ CPACK_NUGET_<compName>_PACKAGE_DESCRIPTION
+
+ A long description of the package for UI display.
+
+ * Mandatory : YES
+ * Default :
+ - :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION`,
+ - ``CPACK_COMPONENT_GROUP_<groupName>_DESCRIPTION``,
+ - :variable:`CPACK_PACKAGE_DESCRIPTION`
+
+.. variable:: CPACK_NUGET_PACKAGE_AUTHORS
+ CPACK_NUGET_<compName>_PACKAGE_AUTHORS
+
+ A comma-separated list of packages authors, matching the profile names
+ on nuget.org_. These are displayed in the NuGet Gallery on
+ nuget.org_ and are used to cross-reference packages by the same
+ authors.
+
+ * Mandatory : YES
+ * Default : :variable:`CPACK_PACKAGE_VENDOR`
+
+.. variable:: CPACK_NUGET_PACKAGE_TITLE
+ CPACK_NUGET_<compName>_PACKAGE_TITLE
+
+ A human-friendly title of the package, typically used in UI displays
+ as on nuget.org_ and the Package Manager in Visual Studio. If not
+ specified, the package ID is used.
+
+ * Mandatory : NO
+ * Default :
+ - :variable:`CPACK_COMPONENT_<compName>_DISPLAY_NAME`,
+ - ``CPACK_COMPONENT_GROUP_<groupName>_DISPLAY_NAME``
+
+.. variable:: CPACK_NUGET_PACKAGE_OWNERS
+ CPACK_NUGET_<compName>_PACKAGE_OWNERS
+
+ A comma-separated list of the package creators using profile names
+ on nuget.org_. This is often the same list as in authors,
+ and is ignored when uploading the package to nuget.org_.
+
+ * Mandatory : NO
+ * Default : -
+
+.. variable:: CPACK_NUGET_PACKAGE_HOMEPAGE_URL
+ CPACK_NUGET_<compName>_PACKAGE_HOMEPAGE_URL
+
+ A URL for the package's home page, often shown in UI displays as well
+ as nuget.org_.
+
+ * Mandatory : NO
+ * Default : :variable:`CPACK_PACKAGE_HOMEPAGE_URL`
+
+.. variable:: CPACK_NUGET_PACKAGE_LICENSEURL
+ CPACK_NUGET_<compName>_PACKAGE_LICENSEURL
+
+ A URL for the package's license, often shown in UI displays as well
+ as nuget.org_.
+
+ * Mandatory : NO
+ * Default : -
+
+.. variable:: CPACK_NUGET_PACKAGE_ICONURL
+ CPACK_NUGET_<compName>_PACKAGE_ICONURL
+
+ A URL for a 64x64 image with transparency background to use as the
+ icon for the package in UI display.
+
+ * Mandatory : NO
+ * Default : -
+
+.. variable:: CPACK_NUGET_PACKAGE_DESCRIPTION_SUMMARY
+ CPACK_NUGET_<compName>_PACKAGE_DESCRIPTION_SUMMARY
+
+ A short description of the package for UI display. If omitted, a
+ truncated version of description is used.
+
+ * Mandatory : NO
+ * Default : :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`
+
+.. variable:: CPACK_NUGET_PACKAGE_RELEASE_NOTES
+ CPACK_NUGET_<compName>_PACKAGE_RELEASE_NOTES
+
+ A description of the changes made in this release of the package,
+ often used in UI like the Updates tab of the Visual Studio Package
+ Manager in place of the package description.
+
+ * Mandatory : NO
+ * Default : -
+
+.. variable:: CPACK_NUGET_PACKAGE_COPYRIGHT
+ CPACK_NUGET_<compName>_PACKAGE_COPYRIGHT
+
+ Copyright details for the package.
+
+ * Mandatory : NO
+ * Default : -
+
+.. variable:: CPACK_NUGET_PACKAGE_TAGS
+ CPACK_NUGET_<compName>_PACKAGE_TAGS
+
+ A space-delimited list of tags and keywords that describe the
+ package and aid discoverability of packages through search and
+ filtering.
+
+ * Mandatory : NO
+ * Default : -
+
+.. variable:: CPACK_NUGET_PACKAGE_DEPENDENCIES
+ CPACK_NUGET_<compName>_PACKAGE_DEPENDENCIES
+
+ A list of package dependencies.
+
+ * Mandatory : NO
+ * Default : -
+
+.. variable:: CPACK_NUGET_PACKAGE_DEPENDENCIES_<dependency>_VERSION
+ CPACK_NUGET_<compName>_PACKAGE_DEPENDENCIES_<dependency>_VERSION
+
+ A `version specification`_ for the particular dependency, where
+ ``<dependency>`` is an item of the dependency list (see above)
+ transformed with ``MAKE_C_IDENTIFIER`` function of :command:`string`
+ command.
+
+ * Mandatory : NO
+ * Default : -
+
+.. variable:: CPACK_NUGET_PACKAGE_DEBUG
+
+ Enable debug messages while executing CPack NuGet generator.
+
+ * Mandatory : NO
+ * Default : OFF
+
+
+.. _nuget.org: http://nuget.org
+.. _version specification: https://docs.microsoft.com/en-us/nuget/reference/package-versioning#version-ranges-and-wildcards
+
+.. NuGet spec docs https://docs.microsoft.com/en-us/nuget/reference/nuspec
diff --git a/Help/cpack_gen/packagemaker.rst b/Help/cpack_gen/packagemaker.rst
new file mode 100644
index 000000000..e9464b749
--- /dev/null
+++ b/Help/cpack_gen/packagemaker.rst
@@ -0,0 +1,23 @@
+CPack PackageMaker Generator
+----------------------------
+
+PackageMaker CPack generator (macOS).
+
+Variables specific to CPack PackageMaker generator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The following variable is specific to installers built on Mac
+macOS using PackageMaker:
+
+.. variable:: CPACK_OSX_PACKAGE_VERSION
+
+ The version of macOS that the resulting PackageMaker archive should be
+ compatible with. Different versions of macOS support different
+ features. For example, CPack can only build component-based installers for
+ macOS 10.4 or newer, and can only build installers that download
+ component son-the-fly for macOS 10.5 or newer. If left blank, this value
+ will be set to the minimum version of macOS that supports the requested
+ features. Set this variable to some value (e.g., 10.4) only if you want to
+ guarantee that your installer will work on that version of macOS, and
+ don't mind missing extra features available in the installer shipping with
+ later versions of macOS.
diff --git a/Help/cpack_gen/productbuild.rst b/Help/cpack_gen/productbuild.rst
new file mode 100644
index 000000000..d22fcd48a
--- /dev/null
+++ b/Help/cpack_gen/productbuild.rst
@@ -0,0 +1,68 @@
+CPack productbuild Generator
+----------------------------
+
+productbuild CPack generator (macOS).
+
+Variables specific to CPack productbuild generator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The following variable is specific to installers built on Mac
+macOS using ProductBuild:
+
+.. variable:: CPACK_COMMAND_PRODUCTBUILD
+
+ Path to the ``productbuild(1)`` command used to generate a product archive for
+ the macOS Installer or Mac App Store. This variable can be used to override
+ the automatically detected command (or specify its location if the
+ auto-detection fails to find it).
+
+.. variable:: CPACK_PRODUCTBUILD_IDENTITY_NAME
+
+ Adds a digital signature to the resulting package.
+
+
+.. variable:: CPACK_PRODUCTBUILD_KEYCHAIN_PATH
+
+ Specify a specific keychain to search for the signing identity.
+
+
+.. variable:: CPACK_COMMAND_PKGBUILD
+
+ Path to the ``pkgbuild(1)`` command used to generate an macOS component package
+ on macOS. This variable can be used to override the automatically detected
+ command (or specify its location if the auto-detection fails to find it).
+
+
+.. variable:: CPACK_PKGBUILD_IDENTITY_NAME
+
+ Adds a digital signature to the resulting package.
+
+
+.. variable:: CPACK_PKGBUILD_KEYCHAIN_PATH
+
+ Specify a specific keychain to search for the signing identity.
+
+
+.. variable:: CPACK_PREFLIGHT_<COMP>_SCRIPT
+
+ Full path to a file that will be used as the ``preinstall`` script for the
+ named ``<COMP>`` component's package, where ``<COMP>`` is the uppercased
+ component name. No ``preinstall`` script is added if this variable is not
+ defined for a given component.
+
+
+.. variable:: CPACK_POSTFLIGHT_<COMP>_SCRIPT
+
+ Full path to a file that will be used as the ``postinstall`` script for the
+ named ``<COMP>`` component's package, where ``<COMP>`` is the uppercased
+ component name. No ``postinstall`` script is added if this variable is not
+ defined for a given component.
+
+
+.. variable:: CPACK_PRODUCTBUILD_RESOURCES_DIR
+
+ If specified the productbuild generator copies files from this directory
+ (including subdirectories) to the ``Resources`` directory. This is done
+ before the :variable:`CPACK_RESOURCE_FILE_WELCOME`,
+ :variable:`CPACK_RESOURCE_FILE_README`, and
+ :variable:`CPACK_RESOURCE_FILE_LICENSE` files are copied.
diff --git a/Help/cpack_gen/rpm.rst b/Help/cpack_gen/rpm.rst
new file mode 100644
index 000000000..2693c7b62
--- /dev/null
+++ b/Help/cpack_gen/rpm.rst
@@ -0,0 +1,955 @@
+CPack RPM Generator
+-------------------
+
+The built in (binary) CPack RPM generator (Unix only)
+
+Variables specific to CPack RPM generator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The CPack RPM generator may be used to create RPM packages using :module:`CPack`.
+The CPack RPM generator is a :module:`CPack` generator thus it uses the
+``CPACK_XXX`` variables used by :module:`CPack`.
+
+The CPack RPM generator has specific features which are controlled by the specifics
+``CPACK_RPM_XXX`` variables.
+
+``CPACK_RPM_<COMPONENT>_XXXX`` variables may be used in order to have
+**component** specific values. Note however that ``<COMPONENT>`` refers to the
+**grouping name** written in upper case. It may be either a component name or
+a component GROUP name. Usually those variables correspond to RPM spec file
+entities. One may find information about spec files here
+http://www.rpm.org/wiki/Docs
+
+.. note::
+
+ `<COMPONENT>` part of variables is preferred to be in upper case (e.g. if
+ component is named ``foo`` then use ``CPACK_RPM_FOO_XXXX`` variable name format)
+ as is with other ``CPACK_<COMPONENT>_XXXX`` variables.
+ For the purposes of back compatibility (CMake/CPack version 3.5 and lower)
+ support for same cased component (e.g. ``fOo`` would be used as
+ ``CPACK_RPM_fOo_XXXX``) is still supported for variables defined in older
+ versions of CMake/CPack but is not guaranteed for variables that
+ will be added in the future. For the sake of back compatibility same cased
+ component variables also override upper cased versions where both are
+ present.
+
+Here are some CPack RPM generator wiki resources that are here for historic
+reasons and are no longer maintained but may still prove useful:
+
+ - https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/Configuration
+ - https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/PackageGenerators#rpm-unix-only
+
+List of CPack RPM generator specific variables:
+
+.. variable:: CPACK_RPM_COMPONENT_INSTALL
+
+ Enable component packaging for CPack RPM generator
+
+ * Mandatory : NO
+ * Default : OFF
+
+ If enabled (``ON``) multiple packages are generated. By default
+ a single package containing files of all components is generated.
+
+.. variable:: CPACK_RPM_PACKAGE_SUMMARY
+ CPACK_RPM_<component>_PACKAGE_SUMMARY
+
+ The RPM package summary.
+
+ * Mandatory : YES
+ * Default : :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`
+
+.. variable:: CPACK_RPM_PACKAGE_NAME
+ CPACK_RPM_<component>_PACKAGE_NAME
+
+ The RPM package name.
+
+ * Mandatory : YES
+ * Default : :variable:`CPACK_PACKAGE_NAME`
+
+.. variable:: CPACK_RPM_FILE_NAME
+ CPACK_RPM_<component>_FILE_NAME
+
+ Package file name.
+
+ * Mandatory : YES
+ * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].rpm`` with spaces
+ replaced by '-'
+
+ This may be set to ``RPM-DEFAULT`` to allow ``rpmbuild`` tool to generate package
+ file name by itself.
+ Alternatively provided package file name must end with ``.rpm`` suffix.
+
+ .. note::
+
+ By using user provided spec file, rpm macro extensions such as for
+ generating ``debuginfo`` packages or by simply using multiple components more
+ than one rpm file may be generated, either from a single spec file or from
+ multiple spec files (each component execution produces its own spec file).
+ In such cases duplicate file names may occur as a result of this variable
+ setting or spec file content structure. Duplicate files get overwritten
+ and it is up to the packager to set the variables in a manner that will
+ prevent such errors.
+
+.. variable:: CPACK_RPM_MAIN_COMPONENT
+
+ Main component that is packaged without component suffix.
+
+ * Mandatory : NO
+ * Default : -
+
+ This variable can be set to any component or group name so that component or
+ group rpm package is generated without component suffix in filename and
+ package name.
+
+.. variable:: CPACK_RPM_PACKAGE_EPOCH
+
+ The RPM package epoch
+
+ * Mandatory : No
+ * Default : -
+
+ Optional number that should be incremented when changing versioning schemas
+ or fixing mistakes in the version numbers of older packages.
+
+.. variable:: CPACK_RPM_PACKAGE_VERSION
+
+ The RPM package version.
+
+ * Mandatory : YES
+ * Default : :variable:`CPACK_PACKAGE_VERSION`
+
+.. variable:: CPACK_RPM_PACKAGE_ARCHITECTURE
+ CPACK_RPM_<component>_PACKAGE_ARCHITECTURE
+
+ The RPM package architecture.
+
+ * Mandatory : YES
+ * Default : Native architecture output by ``uname -m``
+
+ This may be set to ``noarch`` if you know you are building a ``noarch`` package.
+
+.. variable:: CPACK_RPM_PACKAGE_RELEASE
+
+ The RPM package release.
+
+ * Mandatory : YES
+ * Default : 1
+
+ This is the numbering of the RPM package itself, i.e. the version of the
+ packaging and not the version of the content (see
+ :variable:`CPACK_RPM_PACKAGE_VERSION`). One may change the default value if
+ the previous packaging was buggy and/or you want to put here a fancy Linux
+ distro specific numbering.
+
+.. note::
+
+ This is the string that goes into the RPM ``Release:`` field. Some distros
+ (e.g. Fedora, CentOS) require ``1%{?dist}`` format and not just a number.
+ ``%{?dist}`` part can be added by setting :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`.
+
+.. variable:: CPACK_RPM_PACKAGE_RELEASE_DIST
+
+ The dist tag that is added RPM ``Release:`` field.
+
+ * Mandatory : NO
+ * Default : OFF
+
+ This is the reported ``%{dist}`` tag from the current distribution or empty
+ ``%{dist}`` if RPM macro is not set. If this variable is set then RPM
+ ``Release:`` field value is set to ``${CPACK_RPM_PACKAGE_RELEASE}%{?dist}``.
+
+.. variable:: CPACK_RPM_PACKAGE_LICENSE
+
+ The RPM package license policy.
+
+ * Mandatory : YES
+ * Default : "unknown"
+
+.. variable:: CPACK_RPM_PACKAGE_GROUP
+ CPACK_RPM_<component>_PACKAGE_GROUP
+
+ The RPM package group.
+
+ * Mandatory : YES
+ * Default : "unknown"
+
+.. variable:: CPACK_RPM_PACKAGE_VENDOR
+
+ The RPM package vendor.
+
+ * Mandatory : YES
+ * Default : CPACK_PACKAGE_VENDOR if set or "unknown"
+
+.. variable:: CPACK_RPM_PACKAGE_URL
+ CPACK_RPM_<component>_PACKAGE_URL
+
+ The projects URL.
+
+ * Mandatory : NO
+ * Default : :variable:`CMAKE_PROJECT_HOMEPAGE_URL`
+
+.. variable:: CPACK_RPM_PACKAGE_DESCRIPTION
+ CPACK_RPM_<component>_PACKAGE_DESCRIPTION
+
+ RPM package description.
+
+ * Mandatory : YES
+ * Default : :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION` (component
+ based installers only) if set, :variable:`CPACK_PACKAGE_DESCRIPTION_FILE`
+ if set or "no package description available"
+
+.. variable:: CPACK_RPM_COMPRESSION_TYPE
+
+ RPM compression type.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to override RPM compression type to be used to build the
+ RPM. For example some Linux distribution now default to ``lzma`` or ``xz``
+ compression whereas older cannot use such RPM. Using this one can enforce
+ compression type to be used.
+
+ Possible values are:
+
+ - lzma
+ - xz
+ - bzip2
+ - gzip
+
+.. variable:: CPACK_RPM_PACKAGE_AUTOREQ
+ CPACK_RPM_<component>_PACKAGE_AUTOREQ
+
+ RPM spec autoreq field.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to enable (``1``, ``yes``) or disable (``0``, ``no``) automatic
+ shared libraries dependency detection. Dependencies are added to requires list.
+
+ .. note::
+
+ By default automatic dependency detection is enabled by rpm generator.
+
+.. variable:: CPACK_RPM_PACKAGE_AUTOPROV
+ CPACK_RPM_<component>_PACKAGE_AUTOPROV
+
+ RPM spec autoprov field.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to enable (``1``, ``yes``) or disable (``0``, ``no``)
+ automatic listing of shared libraries that are provided by the package.
+ Shared libraries are added to provides list.
+
+ .. note::
+
+ By default automatic provides detection is enabled by rpm generator.
+
+.. variable:: CPACK_RPM_PACKAGE_AUTOREQPROV
+ CPACK_RPM_<component>_PACKAGE_AUTOREQPROV
+
+ RPM spec autoreqprov field.
+
+ * Mandatory : NO
+ * Default : -
+
+ Variable enables/disables autoreq and autoprov at the same time.
+ See :variable:`CPACK_RPM_PACKAGE_AUTOREQ` and
+ :variable:`CPACK_RPM_PACKAGE_AUTOPROV` for more details.
+
+ .. note::
+
+ By default automatic detection feature is enabled by rpm.
+
+.. variable:: CPACK_RPM_PACKAGE_REQUIRES
+ CPACK_RPM_<component>_PACKAGE_REQUIRES
+
+ RPM spec requires field.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to set RPM dependencies (requires). Note that you must enclose
+ the complete requires string between quotes, for example::
+
+ set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8")
+
+ The required package list of an RPM file could be printed with::
+
+ rpm -qp --requires file.rpm
+
+.. variable:: CPACK_RPM_PACKAGE_CONFLICTS
+ CPACK_RPM_<component>_PACKAGE_CONFLICTS
+
+ RPM spec conflicts field.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to set negative RPM dependencies (conflicts). Note that you must
+ enclose the complete requires string between quotes, for example::
+
+ set(CPACK_RPM_PACKAGE_CONFLICTS "libxml2")
+
+ The conflicting package list of an RPM file could be printed with::
+
+ rpm -qp --conflicts file.rpm
+
+.. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE
+ CPACK_RPM_<component>_PACKAGE_REQUIRES_PRE
+
+ RPM spec requires(pre) field.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to set RPM preinstall dependencies (requires(pre)). Note that
+ you must enclose the complete requires string between quotes, for example::
+
+ set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
+
+.. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST
+ CPACK_RPM_<component>_PACKAGE_REQUIRES_POST
+
+ RPM spec requires(post) field.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to set RPM postinstall dependencies (requires(post)). Note that
+ you must enclose the complete requires string between quotes, for example::
+
+ set(CPACK_RPM_PACKAGE_REQUIRES_POST "shadow-utils, initscripts")
+
+.. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN
+ CPACK_RPM_<component>_PACKAGE_REQUIRES_POSTUN
+
+ RPM spec requires(postun) field.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to set RPM postuninstall dependencies (requires(postun)). Note
+ that you must enclose the complete requires string between quotes, for
+ example::
+
+ set(CPACK_RPM_PACKAGE_REQUIRES_POSTUN "shadow-utils, initscripts")
+
+.. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN
+ CPACK_RPM_<component>_PACKAGE_REQUIRES_PREUN
+
+ RPM spec requires(preun) field.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to set RPM preuninstall dependencies (requires(preun)). Note that
+ you must enclose the complete requires string between quotes, for example::
+
+ set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts")
+
+.. variable:: CPACK_RPM_PACKAGE_SUGGESTS
+ CPACK_RPM_<component>_PACKAGE_SUGGESTS
+
+ RPM spec suggest field.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to set weak RPM dependencies (suggests). Note that you must
+ enclose the complete requires string between quotes.
+
+.. variable:: CPACK_RPM_PACKAGE_PROVIDES
+ CPACK_RPM_<component>_PACKAGE_PROVIDES
+
+ RPM spec provides field.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to set RPM dependencies (provides). The provided package list
+ of an RPM file could be printed with::
+
+ rpm -qp --provides file.rpm
+
+.. variable:: CPACK_RPM_PACKAGE_OBSOLETES
+ CPACK_RPM_<component>_PACKAGE_OBSOLETES
+
+ RPM spec obsoletes field.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to set RPM packages that are obsoleted by this one.
+
+.. variable:: CPACK_RPM_PACKAGE_RELOCATABLE
+
+ build a relocatable RPM.
+
+ * Mandatory : NO
+ * Default : CPACK_PACKAGE_RELOCATABLE
+
+ If this variable is set to TRUE or ON, the CPack RPM generator will try
+ to build a relocatable RPM package. A relocatable RPM may
+ be installed using::
+
+ rpm --prefix or --relocate
+
+ in order to install it at an alternate place see rpm(8). Note that
+ currently this may fail if :variable:`CPACK_SET_DESTDIR` is set to ``ON``. If
+ :variable:`CPACK_SET_DESTDIR` is set then you will get a warning message but
+ if there is file installed with absolute path you'll get unexpected behavior.
+
+.. variable:: CPACK_RPM_SPEC_INSTALL_POST
+
+ Deprecated - use :variable:`CPACK_RPM_SPEC_MORE_DEFINE` instead.
+
+ * Mandatory : NO
+ * Default : -
+ * Deprecated: YES
+
+ May be used to override the ``__spec_install_post`` section within the
+ generated spec file. This affects the install step during package creation,
+ not during package installation. For adding operations to be performed
+ during package installation, use
+ :variable:`CPACK_RPM_POST_INSTALL_SCRIPT_FILE` instead.
+
+.. variable:: CPACK_RPM_SPEC_MORE_DEFINE
+
+ RPM extended spec definitions lines.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to add any ``%define`` lines to the generated spec file. An
+ example of its use is to prevent stripping of executables (but note that
+ this may also disable other default post install processing)::
+
+ set(CPACK_RPM_SPEC_MORE_DEFINE "%define __spec_install_post /bin/true")
+
+.. variable:: CPACK_RPM_PACKAGE_DEBUG
+
+ Toggle CPack RPM generator debug output.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be set when invoking cpack in order to trace debug information
+ during CPack RPM run. For example you may launch CPack like this::
+
+ cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM
+
+.. variable:: CPACK_RPM_USER_BINARY_SPECFILE
+ CPACK_RPM_<componentName>_USER_BINARY_SPECFILE
+
+ A user provided spec file.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be set by the user in order to specify a USER binary spec file
+ to be used by the CPack RPM generator instead of generating the file.
+ The specified file will be processed by configure_file( @ONLY).
+
+.. variable:: CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE
+
+ Spec file template.
+
+ * Mandatory : NO
+ * Default : -
+
+ If set CPack will generate a template for USER specified binary
+ spec file and stop with an error. For example launch CPack like this::
+
+ cpack -D CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE=1 -G RPM
+
+ The user may then use this file in order to hand-craft is own
+ binary spec file which may be used with
+ :variable:`CPACK_RPM_USER_BINARY_SPECFILE`.
+
+.. variable:: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
+ CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
+
+ Path to file containing pre (un)install script.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to embed a pre (un)installation script in the spec file.
+ The referred script file (or both) will be read and directly
+ put after the ``%pre`` or ``%preun`` section
+ If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the (un)install
+ script for each component can be overridden with
+ ``CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE`` and
+ ``CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE``.
+ One may verify which scriptlet has been included with::
+
+ rpm -qp --scripts package.rpm
+
+.. variable:: CPACK_RPM_POST_INSTALL_SCRIPT_FILE
+ CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
+
+ Path to file containing post (un)install script.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to embed a post (un)installation script in the spec file.
+ The referred script file (or both) will be read and directly
+ put after the ``%post`` or ``%postun`` section.
+ If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the (un)install
+ script for each component can be overridden with
+ ``CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE`` and
+ ``CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE``.
+ One may verify which scriptlet has been included with::
+
+ rpm -qp --scripts package.rpm
+
+.. variable:: CPACK_RPM_USER_FILELIST
+ CPACK_RPM_<COMPONENT>_USER_FILELIST
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to explicitly specify ``%(<directive>)`` file line
+ in the spec file. Like ``%config(noreplace)`` or any other directive
+ that be found in the ``%files`` section. You can have multiple directives
+ per line, as in ``%attr(600,root,root) %config(noreplace)``. Since
+ the CPack RPM generator is generating the list of files (and directories) the
+ user specified files of the ``CPACK_RPM_<COMPONENT>_USER_FILELIST`` list will
+ be removed from the generated list. If referring to directories do
+ not add a trailing slash.
+
+.. variable:: CPACK_RPM_CHANGELOG_FILE
+
+ RPM changelog file.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to embed a changelog in the spec file.
+ The referred file will be read and directly put after the ``%changelog``
+ section.
+
+.. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST
+
+ list of path to be excluded.
+
+ * Mandatory : NO
+ * Default : /etc /etc/init.d /usr /usr/bin /usr/include /usr/lib
+ /usr/libx32 /usr/lib64 /usr/share /usr/share/aclocal
+ /usr/share/doc
+
+ May be used to exclude path (directories or files) from the auto-generated
+ list of paths discovered by CPack RPM. The default value contains a
+ reasonable set of values if the variable is not defined by the user. If the
+ variable is defined by the user then the CPack RPM generator will NOT any of
+ the default path. If you want to add some path to the default list then you
+ can use :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION` variable.
+
+.. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
+
+ additional list of path to be excluded.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to add more exclude path (directories or files) from the initial
+ default list of excluded paths. See
+ :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST`.
+
+.. variable:: CPACK_RPM_RELOCATION_PATHS
+
+ Packages relocation paths list.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to specify more than one relocation path per relocatable RPM.
+ Variable contains a list of relocation paths that if relative are prefixed
+ by the value of :variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX` or by the
+ value of :variable:`CPACK_PACKAGING_INSTALL_PREFIX` if the component version
+ is not provided.
+ Variable is not component based as its content can be used to set a different
+ path prefix for e.g. binary dir and documentation dir at the same time.
+ Only prefixes that are required by a certain component are added to that
+ component - component must contain at least one file/directory/symbolic link
+ with :variable:`CPACK_RPM_RELOCATION_PATHS` prefix for a certain relocation
+ path to be added. Package will not contain any relocation paths if there are
+ no files/directories/symbolic links on any of the provided prefix locations.
+ Packages that either do not contain any relocation paths or contain
+ files/directories/symbolic links that are outside relocation paths print
+ out an ``AUTHOR_WARNING`` that RPM will be partially relocatable.
+
+.. variable:: CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
+
+ Per component relocation path install prefix.
+
+ * Mandatory : NO
+ * Default : CPACK_PACKAGING_INSTALL_PREFIX
+
+ May be used to set per component :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
+ for relocatable RPM packages.
+
+.. variable:: CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION
+ CPACK_RPM_NO_<COMPONENT>_INSTALL_PREFIX_RELOCATION
+
+ Removal of default install prefix from relocation paths list.
+
+ * Mandatory : NO
+ * Default : CPACK_PACKAGING_INSTALL_PREFIX or CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
+ are treated as one of relocation paths
+
+ May be used to remove CPACK_PACKAGING_INSTALL_PREFIX and CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
+ from relocatable RPM prefix paths.
+
+.. variable:: CPACK_RPM_ADDITIONAL_MAN_DIRS
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to set additional man dirs that could potentially be compressed
+ by brp-compress RPM macro. Variable content must be a list of regular
+ expressions that point to directories containing man files or to man files
+ directly. Note that in order to compress man pages a path must also be
+ present in brp-compress RPM script and that brp-compress script must be
+ added to RPM configuration by the operating system.
+
+ Regular expressions that are added by default were taken from brp-compress
+ RPM macro:
+
+ - /usr/man/man.*
+ - /usr/man/.*/man.*
+ - /usr/info.*
+ - /usr/share/man/man.*
+ - /usr/share/man/.*/man.*
+ - /usr/share/info.*
+ - /usr/kerberos/man.*
+ - /usr/X11R6/man/man.*
+ - /usr/lib/perl5/man/man.*
+ - /usr/share/doc/.*/man/man.*
+ - /usr/lib/.*/man/man.*
+
+.. variable:: CPACK_RPM_DEFAULT_USER
+ CPACK_RPM_<compName>_DEFAULT_USER
+
+ default user ownership of RPM content
+
+ * Mandatory : NO
+ * Default : root
+
+ Value should be user name and not UID.
+ Note that <compName> must be in upper-case.
+
+.. variable:: CPACK_RPM_DEFAULT_GROUP
+ CPACK_RPM_<compName>_DEFAULT_GROUP
+
+ default group ownership of RPM content
+
+ * Mandatory : NO
+ * Default : root
+
+ Value should be group name and not GID.
+ Note that <compName> must be in upper-case.
+
+.. variable:: CPACK_RPM_DEFAULT_FILE_PERMISSIONS
+ CPACK_RPM_<compName>_DEFAULT_FILE_PERMISSIONS
+
+ default permissions used for packaged files
+
+ * Mandatory : NO
+ * Default : - (system default)
+
+ Accepted values are lists with ``PERMISSIONS``. Valid permissions
+ are:
+
+ - OWNER_READ
+ - OWNER_WRITE
+ - OWNER_EXECUTE
+ - GROUP_READ
+ - GROUP_WRITE
+ - GROUP_EXECUTE
+ - WORLD_READ
+ - WORLD_WRITE
+ - WORLD_EXECUTE
+
+ Note that <compName> must be in upper-case.
+
+.. variable:: CPACK_RPM_DEFAULT_DIR_PERMISSIONS
+ CPACK_RPM_<compName>_DEFAULT_DIR_PERMISSIONS
+
+ default permissions used for packaged directories
+
+ * Mandatory : NO
+ * Default : - (system default)
+
+ Accepted values are lists with PERMISSIONS. Valid permissions
+ are the same as for :variable:`CPACK_RPM_DEFAULT_FILE_PERMISSIONS`.
+ Note that <compName> must be in upper-case.
+
+.. variable:: CPACK_RPM_INSTALL_WITH_EXEC
+
+ force execute permissions on programs and shared libraries
+
+ * Mandatory : NO
+ * Default : - (system default)
+
+ Force set owner, group and world execute permissions on programs and shared
+ libraries. This can be used for creating valid rpm packages on systems such
+ as Debian where shared libraries do not have execute permissions set.
+
+.. note::
+
+ Programs and shared libraries without execute permissions are ignored during
+ separation of debug symbols from the binary for debuginfo packages.
+
+Packaging of Symbolic Links
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The CPack RPM generator supports packaging of symbolic links::
+
+ execute_process(COMMAND ${CMAKE_COMMAND}
+ -E create_symlink <relative_path_location> <symlink_name>)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/<symlink_name>
+ DESTINATION <symlink_location> COMPONENT libraries)
+
+Symbolic links will be optimized (paths will be shortened if possible)
+before being added to the package or if multiple relocation paths are
+detected, a post install symlink relocation script will be generated.
+
+Symbolic links may point to locations that are not packaged by the same
+package (either a different component or even not packaged at all) but
+those locations will be treated as if they were a part of the package
+while determining if symlink should be either created or present in a
+post install script - depending on relocation paths.
+
+Symbolic links that point to locations outside packaging path produce a
+warning and are treated as non relocatable permanent symbolic links.
+
+Currently there are a few limitations though:
+
+* For component based packaging component interdependency is not checked
+ when processing symbolic links. Symbolic links pointing to content of
+ a different component are treated the same way as if pointing to location
+ that will not be packaged.
+
+* Symbolic links pointing to a location through one or more intermediate
+ symbolic links will not be handled differently - if the intermediate
+ symbolic link(s) is also on a relocatable path, relocating it during
+ package installation may cause initial symbolic link to point to an
+ invalid location.
+
+Packaging of debug information
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Debuginfo packages contain debug symbols and sources for debugging packaged
+binaries.
+
+Debuginfo RPM packaging has its own set of variables:
+
+.. variable:: CPACK_RPM_DEBUGINFO_PACKAGE
+ CPACK_RPM_<component>_DEBUGINFO_PACKAGE
+
+ Enable generation of debuginfo RPM package(s).
+
+ * Mandatory : NO
+ * Default : OFF
+
+.. note::
+
+ Binaries must contain debug symbols before packaging so use either ``Debug``
+ or ``RelWithDebInfo`` for :variable:`CMAKE_BUILD_TYPE` variable value.
+
+.. note::
+
+ Packages generated from packages without binary files, with binary files but
+ without execute permissions or without debug symbols will cause packaging
+ termination.
+
+.. variable:: CPACK_BUILD_SOURCE_DIRS
+
+ Provides locations of root directories of source files from which binaries
+ were built.
+
+ * Mandatory : YES if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
+ * Default : -
+
+.. note::
+
+ For CMake project :variable:`CPACK_BUILD_SOURCE_DIRS` is set by default to
+ point to :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR` paths.
+
+.. note::
+
+ Sources with path prefixes that do not fall under any location provided with
+ :variable:`CPACK_BUILD_SOURCE_DIRS` will not be present in debuginfo package.
+
+.. variable:: CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX
+ CPACK_RPM_<component>_BUILD_SOURCE_DIRS_PREFIX
+
+ Prefix of location where sources will be placed during package installation.
+
+ * Mandatory : YES if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
+ * Default : "/usr/src/debug/<CPACK_PACKAGE_FILE_NAME>" and
+ for component packaging "/usr/src/debug/<CPACK_PACKAGE_FILE_NAME>-<component>"
+
+.. note::
+
+ Each source path prefix is additionally suffixed by ``src_<index>`` where
+ index is index of the path used from :variable:`CPACK_BUILD_SOURCE_DIRS`
+ variable. This produces ``<CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX>/src_<index>``
+ replacement path.
+ Limitation is that replaced path part must be shorter or of equal
+ length than the length of its replacement. If that is not the case either
+ :variable:`CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX` variable has to be set to
+ a shorter path or source directories must be placed on a longer path.
+
+.. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS
+
+ Directories containing sources that should be excluded from debuginfo packages.
+
+ * Mandatory : NO
+ * Default : "/usr /usr/src /usr/src/debug"
+
+ Listed paths are owned by other RPM packages and should therefore not be
+ deleted on debuginfo package uninstallation.
+
+.. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION
+
+ Paths that should be appended to :variable:`CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS`
+ for exclusion.
+
+ * Mandatory : NO
+ * Default : -
+
+.. variable:: CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE
+
+ Create a single debuginfo package even if components packaging is set.
+
+ * Mandatory : NO
+ * Default : OFF
+
+ When this variable is enabled it produces a single debuginfo package even if
+ component packaging is enabled.
+
+ When using this feature in combination with components packaging and there is
+ more than one component this variable requires :variable:`CPACK_RPM_MAIN_COMPONENT`
+ to be set.
+
+.. note::
+
+ If none of the :variable:`CPACK_RPM_<component>_DEBUGINFO_PACKAGE` variables
+ is set then :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is automatically set to
+ ``ON`` when :variable:`CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE` is set.
+
+.. variable:: CPACK_RPM_DEBUGINFO_FILE_NAME
+ CPACK_RPM_<component>_DEBUGINFO_FILE_NAME
+
+ Debuginfo package file name.
+
+ * Mandatory : NO
+ * Default : rpmbuild tool generated package file name
+
+ Alternatively provided debuginfo package file name must end with ``.rpm``
+ suffix and should differ from file names of other generated packages.
+
+ Variable may contain ``@cpack_component@`` placeholder which will be
+ replaced by component name if component packaging is enabled otherwise it
+ deletes the placeholder.
+
+ Setting the variable to ``RPM-DEFAULT`` may be used to explicitly set
+ filename generation to default.
+
+.. note::
+
+ :variable:`CPACK_RPM_FILE_NAME` also supports rpmbuild tool generated package
+ file name - disabled by default but can be enabled by setting the variable to
+ ``RPM-DEFAULT``.
+
+Packaging of sources (SRPM)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+SRPM packaging is enabled by setting :variable:`CPACK_RPM_PACKAGE_SOURCES`
+variable while usually using :variable:`CPACK_INSTALLED_DIRECTORIES` variable
+to provide directory containing CMakeLists.txt and source files.
+
+For CMake projects SRPM package would be produced by executing::
+
+ cpack -G RPM --config ./CPackSourceConfig.cmake
+
+.. note::
+
+ Produced SRPM package is expected to be built with :manual:`cmake(1)` executable
+ and packaged with :manual:`cpack(1)` executable so CMakeLists.txt has to be
+ located in root source directory and must be able to generate binary rpm
+ packages by executing ``cpack -G`` command. The two executables as well as
+ rpmbuild must also be present when generating binary rpm packages from the
+ produced SRPM package.
+
+Once the SRPM package is generated it can be used to generate binary packages
+by creating a directory structure for rpm generation and executing rpmbuild
+tool::
+
+ mkdir -p build_dir/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
+ rpmbuild --define "_topdir <path_to_build_dir>" --rebuild <SRPM_file_name>
+
+Generated packages will be located in build_dir/RPMS directory or its sub
+directories.
+
+.. note::
+
+ SRPM package internally uses CPack/RPM generator to generate binary packages
+ so CMakeScripts.txt can decide during the SRPM to binary rpm generation step
+ what content the package(s) should have as well as how they should be packaged
+ (monolithic or components). CMake can decide this for e.g. by reading environment
+ variables set by the package manager before starting the process of generating
+ binary rpm packages. This way a single SRPM package can be used to produce
+ different binary rpm packages on different platforms depending on the platform's
+ packaging rules.
+
+Source RPM packaging has its own set of variables:
+
+.. variable:: CPACK_RPM_PACKAGE_SOURCES
+
+ Should the content be packaged as a source rpm (default is binary rpm).
+
+ * Mandatory : NO
+ * Default : OFF
+
+.. note::
+
+ For cmake projects :variable:`CPACK_RPM_PACKAGE_SOURCES` variable is set
+ to ``OFF`` in CPackConfig.cmake and ``ON`` in CPackSourceConfig.cmake
+ generated files.
+
+.. variable:: CPACK_RPM_SOURCE_PKG_BUILD_PARAMS
+
+ Additional command-line parameters provided to :manual:`cmake(1)` executable.
+
+ * Mandatory : NO
+ * Default : -
+
+.. variable:: CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX
+
+ Packaging install prefix that would be provided in :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
+ variable for producing binary RPM packages.
+
+ * Mandatory : YES
+ * Default : "/"
+
+.. VARIABLE:: CPACK_RPM_BUILDREQUIRES
+
+ List of source rpm build dependencies.
+
+ * Mandatory : NO
+ * Default : -
+
+ May be used to set source RPM build dependencies (BuildRequires). Note that
+ you must enclose the complete build requirements string between quotes, for
+ example::
+
+ set(CPACK_RPM_BUILDREQUIRES "python >= 2.5.0, cmake >= 2.8")
diff --git a/Help/cpack_gen/wix.rst b/Help/cpack_gen/wix.rst
new file mode 100644
index 000000000..7fb5a12a7
--- /dev/null
+++ b/Help/cpack_gen/wix.rst
@@ -0,0 +1,288 @@
+CPack WIX Generator
+-------------------
+
+CPack WIX generator specific options
+
+Variables specific to CPack WIX generator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The following variables are specific to the installers built on
+Windows using WiX.
+
+.. variable:: CPACK_WIX_UPGRADE_GUID
+
+ Upgrade GUID (``Product/@UpgradeCode``)
+
+ Will be automatically generated unless explicitly provided.
+
+ It should be explicitly set to a constant generated globally unique
+ identifier (GUID) to allow your installers to replace existing
+ installations that use the same GUID.
+
+ You may for example explicitly set this variable in your
+ CMakeLists.txt to the value that has been generated per default. You
+ should not use GUIDs that you did not generate yourself or which may
+ belong to other projects.
+
+ A GUID shall have the following fixed length syntax::
+
+ XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
+
+ (each X represents an uppercase hexadecimal digit)
+
+.. variable:: CPACK_WIX_PRODUCT_GUID
+
+ Product GUID (``Product/@Id``)
+
+ Will be automatically generated unless explicitly provided.
+
+ If explicitly provided this will set the Product Id of your installer.
+
+ The installer will abort if it detects a pre-existing installation that
+ uses the same GUID.
+
+ The GUID shall use the syntax described for CPACK_WIX_UPGRADE_GUID.
+
+.. variable:: CPACK_WIX_LICENSE_RTF
+
+ RTF License File
+
+ If CPACK_RESOURCE_FILE_LICENSE has an .rtf extension it is used as-is.
+
+ If CPACK_RESOURCE_FILE_LICENSE has an .txt extension it is implicitly
+ converted to RTF by the WIX Generator.
+ The expected encoding of the .txt file is UTF-8.
+
+ With CPACK_WIX_LICENSE_RTF you can override the license file used by the
+ WIX Generator in case CPACK_RESOURCE_FILE_LICENSE is in an unsupported
+ format or the .txt -> .rtf conversion does not work as expected.
+
+.. variable:: CPACK_WIX_PRODUCT_ICON
+
+ The Icon shown next to the program name in Add/Remove programs.
+
+ If set, this icon is used in place of the default icon.
+
+.. variable:: CPACK_WIX_UI_REF
+
+ This variable allows you to override the Id of the ``<UIRef>`` element
+ in the WiX template.
+
+ The default is ``WixUI_InstallDir`` in case no CPack components have
+ been defined and ``WixUI_FeatureTree`` otherwise.
+
+.. variable:: CPACK_WIX_UI_BANNER
+
+ The bitmap will appear at the top of all installer pages other than the
+ welcome and completion dialogs.
+
+ If set, this image will replace the default banner image.
+
+ This image must be 493 by 58 pixels.
+
+.. variable:: CPACK_WIX_UI_DIALOG
+
+ Background bitmap used on the welcome and completion dialogs.
+
+ If this variable is set, the installer will replace the default dialog
+ image.
+
+ This image must be 493 by 312 pixels.
+
+.. variable:: CPACK_WIX_PROGRAM_MENU_FOLDER
+
+ Start menu folder name for launcher.
+
+ If this variable is not set, it will be initialized with CPACK_PACKAGE_NAME
+
+ If this variable is set to ``.``, then application shortcuts will be
+ created directly in the start menu and the uninstaller shortcut will be
+ omitted.
+
+.. variable:: CPACK_WIX_CULTURES
+
+ Language(s) of the installer
+
+ Languages are compiled into the WixUI extension library. To use them,
+ simply provide the name of the culture. If you specify more than one
+ culture identifier in a comma or semicolon delimited list, the first one
+ that is found will be used. You can find a list of supported languages at:
+ http://wix.sourceforge.net/manual-wix3/WixUI_localization.htm
+
+.. variable:: CPACK_WIX_TEMPLATE
+
+ Template file for WiX generation
+
+ If this variable is set, the specified template will be used to generate
+ the WiX wxs file. This should be used if further customization of the
+ output is required.
+
+ If this variable is not set, the default MSI template included with CMake
+ will be used.
+
+.. variable:: CPACK_WIX_PATCH_FILE
+
+ Optional list of XML files with fragments to be inserted into
+ generated WiX sources
+
+ This optional variable can be used to specify an XML file that the
+ WIX generator will use to inject fragments into its generated
+ source files.
+
+ Patch files understood by the CPack WIX generator
+ roughly follow this RELAX NG compact schema:
+
+ .. code-block:: none
+
+ start = CPackWiXPatch
+
+ CPackWiXPatch = element CPackWiXPatch { CPackWiXFragment* }
+
+ CPackWiXFragment = element CPackWiXFragment
+ {
+ attribute Id { string },
+ fragmentContent*
+ }
+
+ fragmentContent = element * - CPackWiXFragment
+ {
+ (attribute * { text } | text | fragmentContent)*
+ }
+
+ Currently fragments can be injected into most
+ Component, File, Directory and Feature elements.
+
+ The following additional special Ids can be used:
+
+ * ``#PRODUCT`` for the ``<Product>`` element.
+ * ``#PRODUCTFEATURE`` for the root ``<Feature>`` element.
+
+ The following example illustrates how this works.
+
+ Given that the WIX generator creates the following XML element:
+
+ .. code-block:: xml
+
+ <Component Id="CM_CP_applications.bin.my_libapp.exe" Guid="*"/>
+
+ The following XML patch file may be used to inject an Environment element
+ into it:
+
+ .. code-block:: xml
+
+ <CPackWiXPatch>
+ <CPackWiXFragment Id="CM_CP_applications.bin.my_libapp.exe">
+ <Environment Id="MyEnvironment" Action="set"
+ Name="MyVariableName" Value="MyVariableValue"/>
+ </CPackWiXFragment>
+ </CPackWiXPatch>
+
+.. variable:: CPACK_WIX_EXTRA_SOURCES
+
+ Extra WiX source files
+
+ This variable provides an optional list of extra WiX source files (.wxs)
+ that should be compiled and linked. The full path to source files is
+ required.
+
+.. variable:: CPACK_WIX_EXTRA_OBJECTS
+
+ Extra WiX object files or libraries
+
+ This variable provides an optional list of extra WiX object (.wixobj)
+ and/or WiX library (.wixlib) files. The full path to objects and libraries
+ is required.
+
+.. variable:: CPACK_WIX_EXTENSIONS
+
+ This variable provides a list of additional extensions for the WiX
+ tools light and candle.
+
+.. variable:: CPACK_WIX_<TOOL>_EXTENSIONS
+
+ This is the tool specific version of CPACK_WIX_EXTENSIONS.
+ ``<TOOL>`` can be either LIGHT or CANDLE.
+
+.. variable:: CPACK_WIX_<TOOL>_EXTRA_FLAGS
+
+ This list variable allows you to pass additional
+ flags to the WiX tool ``<TOOL>``.
+
+ Use it at your own risk.
+ Future versions of CPack may generate flags which may be in conflict
+ with your own flags.
+
+ ``<TOOL>`` can be either LIGHT or CANDLE.
+
+.. variable:: CPACK_WIX_CMAKE_PACKAGE_REGISTRY
+
+ If this variable is set the generated installer will create
+ an entry in the windows registry key
+ ``HKEY_LOCAL_MACHINE\Software\Kitware\CMake\Packages\<PackageName>``
+ The value for ``<PackageName>`` is provided by this variable.
+
+ Assuming you also install a CMake configuration file this will
+ allow other CMake projects to find your package with
+ the :command:`find_package` command.
+
+.. variable:: CPACK_WIX_PROPERTY_<PROPERTY>
+
+ This variable can be used to provide a value for
+ the Windows Installer property ``<PROPERTY>``
+
+ The following list contains some example properties that can be used to
+ customize information under
+ "Programs and Features" (also known as "Add or Remove Programs")
+
+ * ARPCOMMENTS - Comments
+ * ARPHELPLINK - Help and support information URL
+ * ARPURLINFOABOUT - General information URL
+ * ARPURLUPDATEINFO - Update information URL
+ * ARPHELPTELEPHONE - Help and support telephone number
+ * ARPSIZE - Size (in kilobytes) of the application
+
+.. variable:: CPACK_WIX_ROOT_FEATURE_TITLE
+
+ Sets the name of the root install feature in the WIX installer. Same as
+ CPACK_COMPONENT_<compName>_DISPLAY_NAME for components.
+
+.. variable:: CPACK_WIX_ROOT_FEATURE_DESCRIPTION
+
+ Sets the description of the root install feature in the WIX installer. Same as
+ CPACK_COMPONENT_<compName>_DESCRIPTION for components.
+
+.. variable:: CPACK_WIX_SKIP_PROGRAM_FOLDER
+
+ If this variable is set to true, the default install location
+ of the generated package will be CPACK_PACKAGE_INSTALL_DIRECTORY directly.
+ The install location will not be located relatively below
+ ProgramFiles or ProgramFiles64.
+
+ .. note::
+ Installers created with this feature do not take differences
+ between the system on which the installer is created
+ and the system on which the installer might be used into account.
+
+ It is therefore possible that the installer e.g. might try to install
+ onto a drive that is unavailable or unintended or a path that does not
+ follow the localization or convention of the system on which the
+ installation is performed.
+
+.. variable:: CPACK_WIX_ROOT_FOLDER_ID
+
+ This variable allows specification of a custom root folder ID.
+ The generator specific ``<64>`` token can be used for
+ folder IDs that come in 32-bit and 64-bit variants.
+ In 32-bit builds the token will expand empty while in 64-bit builds
+ it will expand to ``64``.
+
+ When unset generated installers will default installing to
+ ``ProgramFiles<64>Folder``.
+
+.. variable:: CPACK_WIX_ROOT
+
+ This variable can optionally be set to the root directory
+ of a custom WiX Toolset installation.
+
+ When unspecified CPack will try to locate a WiX Toolset
+ installation via the ``WIX`` environment variable instead.
diff --git a/Help/dev/README.rst b/Help/dev/README.rst
index ce62abc4b..84da4f1d3 100644
--- a/Help/dev/README.rst
+++ b/Help/dev/README.rst
@@ -36,8 +36,10 @@ Developer Documentation
CMake developer documentation is provided by the following documents:
* The `CMake Source Code Guide`_.
+* The `CMake Documentation Guide`_.
.. _`CMake Source Code Guide`: source.rst
+.. _`CMake Documentation Guide`: documentation.rst
Maintainer Documentation
========================
diff --git a/Help/dev/documentation.rst b/Help/dev/documentation.rst
new file mode 100644
index 000000000..c302790aa
--- /dev/null
+++ b/Help/dev/documentation.rst
@@ -0,0 +1,530 @@
+CMake Documentation Guide
+*************************
+
+The following is a guide to the CMake documentation source for developers.
+See documentation on `CMake Development`_ for more information.
+
+.. _`CMake Development`: README.rst
+
+Help
+====
+
+The ``Help`` directory contains CMake help manual source files.
+They are written using the `reStructuredText`_ markup syntax and
+processed by `Sphinx`_ to generate the CMake help manuals.
+
+.. _`reStructuredText`: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
+.. _`Sphinx`: http://sphinx-doc.org
+
+Markup Constructs
+-----------------
+
+In addition to using Sphinx to generate the CMake help manuals, we
+also use a C++-implemented document processor to print documents for
+the ``--help-*`` command-line help options. It supports a subset of
+reStructuredText markup. When authoring or modifying documents,
+please verify that the command-line help looks good in addition to the
+Sphinx-generated html and man pages.
+
+The command-line help processor supports the following constructs
+defined by reStructuredText, Sphinx, and a CMake extension to Sphinx.
+
+..
+ Note: This list must be kept consistent with the cmRST implementation.
+
+CMake Domain directives
+ Directives defined in the `CMake Domain`_ for defining CMake
+ documentation objects are printed in command-line help output as
+ if the lines were normal paragraph text with interpretation.
+
+CMake Domain interpreted text roles
+ Interpreted text roles defined in the `CMake Domain`_ for
+ cross-referencing CMake documentation objects are replaced by their
+ link text in command-line help output. Other roles are printed
+ literally and not processed.
+
+``code-block`` directive
+ Add a literal code block without interpretation. The command-line
+ help processor prints the block content without the leading directive
+ line and with common indentation replaced by one space.
+
+``include`` directive
+ Include another document source file. The command-line help
+ processor prints the included document inline with the referencing
+ document.
+
+literal block after ``::``
+ A paragraph ending in ``::`` followed by a blank line treats
+ the following indented block as literal text without interpretation.
+ The command-line help processor prints the ``::`` literally and
+ prints the block content with common indentation replaced by one
+ space.
+
+``note`` directive
+ Call out a side note. The command-line help processor prints the
+ block content as if the lines were normal paragraph text with
+ interpretation.
+
+``parsed-literal`` directive
+ Add a literal block with markup interpretation. The command-line
+ help processor prints the block content without the leading
+ directive line and with common indentation replaced by one space.
+
+``productionlist`` directive
+ Render context-free grammar productions. The command-line help
+ processor prints the block content as if the lines were normal
+ paragraph text with interpretation.
+
+``replace`` directive
+ Define a ``|substitution|`` replacement.
+ The command-line help processor requires a substitution replacement
+ to be defined before it is referenced.
+
+``|substitution|`` reference
+ Reference a substitution replacement previously defined by
+ the ``replace`` directive. The command-line help processor
+ performs the substitution and replaces all newlines in the
+ replacement text with spaces.
+
+``toctree`` directive
+ Include other document sources in the Table-of-Contents
+ document tree. The command-line help processor prints
+ the referenced documents inline as part of the referencing
+ document.
+
+Inline markup constructs not listed above are printed literally in the
+command-line help output. We prefer to use inline markup constructs that
+look correct in source form, so avoid use of \\-escapes in favor of inline
+literals when possible.
+
+Explicit markup blocks not matching directives listed above are removed from
+command-line help output. Do not use them, except for plain ``..`` comments
+that are removed by Sphinx too.
+
+Note that nested indentation of blocks is not recognized by the
+command-line help processor. Therefore:
+
+* Explicit markup blocks are recognized only when not indented
+ inside other blocks.
+
+* Literal blocks after paragraphs ending in ``::`` but not
+ at the top indentation level may consume all indented lines
+ following them.
+
+Try to avoid these cases in practice.
+
+CMake Domain
+------------
+
+CMake adds a `Sphinx Domain`_ called ``cmake``, also called the
+"CMake Domain". It defines several "object" types for CMake
+documentation:
+
+``command``
+ A CMake language command.
+
+``generator``
+ A CMake native build system generator.
+ See the `cmake(1)`_ command-line tool's ``-G`` option.
+
+``manual``
+ A CMake manual page, like the `cmake(1)`_ manual.
+
+``module``
+ A CMake module.
+ See the `cmake-modules(7)`_ manual
+ and the `include()`_ command.
+
+``policy``
+ A CMake policy.
+ See the `cmake-policies(7)`_ manual
+ and the `cmake_policy()`_ command.
+
+``prop_cache, prop_dir, prop_gbl, prop_sf, prop_inst, prop_test, prop_tgt``
+ A CMake cache, directory, global, source file, installed file, test,
+ or target property, respectively. See the `cmake-properties(7)`_
+ manual and the `set_property()`_ command.
+
+``variable``
+ A CMake language variable.
+ See the `cmake-variables(7)`_ manual
+ and the `set()`_ command.
+
+Documentation objects in the CMake Domain come from two sources.
+First, the CMake extension to Sphinx transforms every document named
+with the form ``Help/<type>/<file-name>.rst`` to a domain object with
+type ``<type>``. The object name is extracted from the document title,
+which is expected to be of the form::
+
+ <object-name>
+ -------------
+
+and to appear at or near the top of the ``.rst`` file before any other
+lines starting in a letter, digit, or ``<``. If no such title appears
+literally in the ``.rst`` file, the object name is the ``<file-name>``.
+If a title does appear, it is expected that ``<file-name>`` is equal
+to ``<object-name>`` with any ``<`` and ``>`` characters removed.
+
+Second, the CMake Domain provides directives to define objects inside
+other documents:
+
+.. code-block:: rst
+
+ .. command:: <command-name>
+
+ This indented block documents <command-name>.
+
+ .. variable:: <variable-name>
+
+ This indented block documents <variable-name>.
+
+Object types for which no directive is available must be defined using
+the first approach above.
+
+.. _`Sphinx Domain`: http://sphinx-doc.org/domains.html
+.. _`cmake(1)`: https://cmake.org/cmake/help/latest/manual/cmake.1.html
+.. _`cmake-modules(7)`: https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html
+.. _`cmake-policies(7)`: https://cmake.org/cmake/help/latest/manual/cmake-policies.7.html
+.. _`cmake-properties(7)`: https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html
+.. _`cmake-variables(7)`: https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html
+.. _`cmake_policy()`: https://cmake.org/cmake/help/latest/command/cmake_policy.html
+.. _`include()`: https://cmake.org/cmake/help/latest/command/include.html
+.. _`set()`: https://cmake.org/cmake/help/latest/command/set.html
+.. _`set_property()`: https://cmake.org/cmake/help/latest/command/set_property.html
+
+Cross-References
+----------------
+
+Sphinx uses reStructuredText interpreted text roles to provide
+cross-reference syntax. The `CMake Domain`_ provides for each
+domain object type a role of the same name to cross-reference it.
+CMake Domain roles are inline markup of the forms::
+
+ :type:`name`
+ :type:`text <name>`
+
+where ``type`` is the domain object type and ``name`` is the
+domain object name. In the first form the link text will be
+``name`` (or ``name()`` if the type is ``command``) and in
+the second form the link text will be the explicit ``text``.
+For example, the code:
+
+.. code-block:: rst
+
+ * The :command:`list` command.
+ * The :command:`list(APPEND)` sub-command.
+ * The :command:`list() command <list>`.
+ * The :command:`list(APPEND) sub-command <list>`.
+ * The :variable:`CMAKE_VERSION` variable.
+ * The :prop_tgt:`OUTPUT_NAME_<CONFIG>` target property.
+
+produces:
+
+* The `list()`_ command.
+* The `list(APPEND)`_ sub-command.
+* The `list() command`_.
+* The `list(APPEND) sub-command`_.
+* The `CMAKE_VERSION`_ variable.
+* The `OUTPUT_NAME_<CONFIG>`_ target property.
+
+Note that CMake Domain roles differ from Sphinx and reStructuredText
+convention in that the form ``a<b>``, without a space preceding ``<``,
+is interpreted as a name instead of link text with an explicit target.
+This is necessary because we use ``<placeholders>`` frequently in
+object names like ``OUTPUT_NAME_<CONFIG>``. The form ``a <b>``,
+with a space preceding ``<``, is still interpreted as a link text
+with an explicit target.
+
+.. _`list()`: https://cmake.org/cmake/help/latest/command/list.html
+.. _`list(APPEND)`: https://cmake.org/cmake/help/latest/command/list.html
+.. _`list(APPEND) sub-command`: https://cmake.org/cmake/help/latest/command/list.html
+.. _`list() command`: https://cmake.org/cmake/help/latest/command/list.html
+.. _`CMAKE_VERSION`: https://cmake.org/cmake/help/latest/variable/CMAKE_VERSION.html
+.. _`OUTPUT_NAME_<CONFIG>`: https://cmake.org/cmake/help/latest/prop_tgt/OUTPUT_NAME_CONFIG.html
+
+Style
+-----
+
+Style: Section Headers
+^^^^^^^^^^^^^^^^^^^^^^
+
+When marking section titles, make the section decoration line as long as
+the title text. Use only a line below the title, not above. For
+example:
+
+.. code-block:: rst
+
+ Title Text
+ ----------
+
+Capitalize the first letter of each non-minor word in the title.
+
+The section header underline character hierarchy is
+
+* ``#``: Manual group (part) in the master document
+* ``*``: Manual (chapter) title
+* ``=``: Section within a manual
+* ``-``: Subsection or `CMake Domain`_ object document title
+* ``^``: Subsubsection or `CMake Domain`_ object document section
+* ``"``: Paragraph or `CMake Domain`_ object document subsection
+
+Style: Whitespace
+^^^^^^^^^^^^^^^^^
+
+Use two spaces for indentation. Use two spaces between sentences in
+prose.
+
+Style: Line Length
+^^^^^^^^^^^^^^^^^^
+
+Prefer to restrict the width of lines to 75-80 columns. This is not a
+hard restriction, but writing new paragraphs wrapped at 75 columns
+allows space for adding minor content without significant re-wrapping of
+content.
+
+Style: Prose
+^^^^^^^^^^^^
+
+Use American English spellings in prose.
+
+Style: Starting Literal Blocks
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Prefer to mark the start of literal blocks with ``::`` at the end of
+the preceding paragraph. In cases where the following block gets
+a ``code-block`` marker, put a single ``:`` at the end of the preceding
+paragraph.
+
+Style: CMake Command Signatures
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Command signatures should be marked up as plain literal blocks, not as
+cmake ``code-blocks``.
+
+Signatures are separated from preceding content by a section header.
+That is, use:
+
+.. code-block:: rst
+
+ ... preceding paragraph.
+
+ Normal Libraries
+ ^^^^^^^^^^^^^^^^
+
+ ::
+
+ add_library(<lib> ...)
+
+ This signature is used for ...
+
+Signatures of commands should wrap optional parts with square brackets,
+and should mark list of optional arguments with an ellipsis (``...``).
+Elements of the signature which are specified by the user should be
+specified with angle brackets, and may be referred to in prose using
+``inline-literal`` syntax.
+
+Style: Boolean Constants
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Use "``OFF``" and "``ON``" for boolean values which can be modified by
+the user, such as ``POSITION_INDEPENDENT_CODE``. Such properties
+may be "enabled" and "disabled". Use "``True``" and "``False``" for
+inherent values which can't be modified after being set, such as the
+``IMPORTED`` property of a build target.
+
+Style: Inline Literals
+^^^^^^^^^^^^^^^^^^^^^^
+
+Mark up references to keywords in signatures, file names, and other
+technical terms with ``inline-literal`` syntax, for example:
+
+.. code-block:: rst
+
+ If ``WIN32`` is used with :command:`add_executable`, the
+ :prop_tgt:`WIN32_EXECUTABLE` target property is enabled. That command
+ creates the file ``<name>.exe`` on Windows.
+
+Style: Cross-References
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Mark up linkable references as links, including repeats.
+An alternative, which is used by wikipedia
+(`<http://en.wikipedia.org/wiki/WP:REPEATLINK>`_),
+is to link to a reference only once per article. That style is not used
+in CMake documentation.
+
+Style: Referencing CMake Concepts
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If referring to a concept which corresponds to a property, and that
+concept is described in a high-level manual, prefer to link to the
+manual section instead of the property. For example:
+
+.. code-block:: rst
+
+ This command creates an :ref:`Imported Target <Imported Targets>`.
+
+instead of:
+
+.. code-block:: rst
+
+ This command creates an :prop_tgt:`IMPORTED` target.
+
+The latter should be used only when referring specifically to the
+property.
+
+References to manual sections are not automatically created by creating
+a section, but code such as:
+
+.. code-block:: rst
+
+ .. _`Imported Targets`:
+
+creates a suitable anchor. Use an anchor name which matches the name
+of the corresponding section. Refer to the anchor using a
+cross-reference with specified text.
+
+Imported Targets need the ``IMPORTED`` term marked up with care in
+particular because the term may refer to a command keyword, a target
+property, or a concept.
+
+Where a property, command or variable is related conceptually to others,
+by for example, being related to the buildsystem description, generator
+expressions or Qt, each relevant property, command or variable should
+link to the primary manual, which provides high-level information. Only
+particular information relating to the command should be in the
+documentation of the command.
+
+Style: Referencing CMake Domain Objects
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+When referring to `CMake Domain`_ objects such as properties, variables,
+commands etc, prefer to link to the target object and follow that with
+the type of object it is. For example:
+
+.. code-block:: rst
+
+ Set the :prop_tgt:`AUTOMOC` target property to ``ON``.
+
+Instead of
+
+.. code-block:: rst
+
+ Set the target property :prop_tgt:`AUTOMOC` to ``ON``.
+
+The ``policy`` directive is an exception, and the type us usually
+referred to before the link:
+
+.. code-block:: rst
+
+ If policy :policy:`CMP0022` is set to ``NEW`` the behavior is ...
+
+However, markup self-references with ``inline-literal`` syntax.
+For example, within the ``add_executable`` command documentation, use
+
+.. code-block:: rst
+
+ ``add_executable``
+
+not
+
+.. code-block:: rst
+
+ :command:`add_executable`
+
+which is used elsewhere.
+
+Modules
+=======
+
+The ``Modules`` directory contains CMake-language ``.cmake`` module files.
+
+Module Documentation
+--------------------
+
+To document CMake module ``Modules/<module-name>.cmake``, modify
+``Help/manual/cmake-modules.7.rst`` to reference the module in the
+``toctree`` directive, in sorted order, as::
+
+ /module/<module-name>
+
+Then add the module document file ``Help/module/<module-name>.rst``
+containing just the line::
+
+ .. cmake-module:: ../../Modules/<module-name>.cmake
+
+The ``cmake-module`` directive will scan the module file to extract
+reStructuredText markup from comment blocks that start in ``.rst:``.
+At the top of ``Modules/<module-name>.cmake``, begin with the following
+license notice:
+
+::
+
+ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ # file Copyright.txt or https://cmake.org/licensing for details.
+
+After this notice, add a *BLANK* line. Then, add documentation using
+a `Bracket Comment`_ of the form:
+
+::
+
+ #[=======================================================================[.rst:
+ <module-name>
+ -------------
+
+ <reStructuredText documentation of module>
+ #]=======================================================================]
+
+Any number of ``=`` may be used in the opening and closing brackets
+as long as they match. Content on the line containing the closing
+bracket is excluded if and only if the line starts in ``#``.
+
+Additional such ``.rst:`` comments may appear anywhere in the module file.
+All such comments must start with ``#`` in the first column.
+
+For example, a ``Findxxx.cmake`` module may contain:
+
+::
+
+ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ # file Copyright.txt or https://cmake.org/licensing for details.
+
+ #[=======================================================================[.rst:
+ FindXxx
+ -------
+
+ This is a cool module.
+ This module does really cool stuff.
+ It can do even more than you think.
+
+ It even needs two paragraphs to tell you about it.
+ And it defines the following variables:
+
+ ``VAR_COOL``
+ this is great isn't it?
+ ``VAR_REALLY_COOL``
+ cool right?
+ #]=======================================================================]
+
+ <code>
+
+ #[=======================================================================[.rst:
+ .. command:: xxx_do_something
+
+ This command does something for Xxx::
+
+ xxx_do_something(some arguments)
+ #]=======================================================================]
+ macro(xxx_do_something)
+ <code>
+ endmacro()
+
+Test the documentation formatting by running
+``cmake --help-module <module-name>``, and also by enabling the
+``SPHINX_HTML`` and ``SPHINX_MAN`` options to build the documentation.
+Edit the comments until generated documentation looks satisfactory. To
+have a .cmake file in this directory NOT show up in the modules
+documentation, simply leave out the ``Help/module/<module-name>.rst``
+file and the ``Help/manual/cmake-modules.7.rst`` toctree entry.
+
+.. _`Bracket Comment`: https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#bracket-comment
diff --git a/Help/dev/maint.rst b/Help/dev/maint.rst
index 78c06df65..44e227347 100644
--- a/Help/dev/maint.rst
+++ b/Help/dev/maint.rst
@@ -8,6 +8,129 @@ See documentation on `CMake Development`_ for more information.
.. contents:: Maintainer Processes:
+Review a Merge Request
+======================
+
+The `CMake Review Process`_ requires a maintainer to issue the ``Do: merge``
+command to integrate a merge request. Please check at least the following:
+
+* If the MR source branch is not named well for the change it makes
+ (e.g. it is just ``master`` or the patch changed during review),
+ add a ``Topic-rename: <topic>`` trailing line to the MR description
+ to provide a better topic name.
+
+* If the MR introduces a new feature or a user-facing behavior change,
+ such as a policy, ensure that a ``Help/release/dev/$topic.rst`` file
+ is added with a release note.
+
+* If a commit changes a specific area, such as a module, its commit
+ message should have an ``area:`` prefix on its first line.
+
+* If a commit fixes a tracked issue, its commit message should have
+ a trailing line such as ``Fixes: #00000``.
+
+* Ensure that the MR adds sufficient documentation and test cases.
+
+* Ensure that the MR has been tested sufficiently. Typically it should
+ be staged for nightly testing with ``Do: stage``. Then manually
+ review the `CMake CDash Page`_ to verify that no regressions were
+ introduced. (Learn to tolerate spurious failures due to idiosyncrasies
+ of various nightly builders.)
+
+* Ensure that the MR targets the ``master`` branch. A MR intended for
+ the ``release`` branch should be based on ``release`` but still merged
+ to ``master`` first (via ``Do: merge``). A maintainer may then merge
+ the MR topic to ``release`` manually.
+
+Maintain Current Release
+========================
+
+The ``release`` branch is used to maintain the current release or release
+candidate. The branch is published with no version number but maintained
+using a local branch named ``release-$ver``, where ``$ver`` is the version
+number of the current release in the form ``$major.$minor``. It is always
+merged into ``master`` before publishing.
+
+Before merging a ``$topic`` branch into ``release``, verify that the
+``$topic`` branch has already been merged to ``master`` via the usual
+``Do: merge`` process. Then, to merge the ``$topic`` branch into
+``release``, start by creating the local branch:
+
+.. code-block:: shell
+
+ git fetch origin
+ git checkout -b release-$ver origin/release
+
+Merge the ``$topic`` branch into the local ``release-$ver`` branch, making
+sure to include a ``Merge-request: !xxxx`` footer in the commit message:
+
+.. code-block:: shell
+
+ git merge --no-ff $topic
+
+Merge the ``release-$ver`` branch to ``master``:
+
+.. code-block:: shell
+
+ git checkout master
+ git pull
+ git merge --no-ff release-$ver
+
+Review new ancestry to ensure nothing unexpected was merged to either branch:
+
+.. code-block:: shell
+
+ git log --graph --boundary origin/master..master
+ git log --graph --boundary origin/release..release-$ver
+
+Publish both ``master`` and ``release`` simultaneously:
+
+.. code-block:: shell
+
+ git push --atomic origin master release-$ver:release
+
+.. _`CMake Review Process`: review.rst
+.. _`CMake CDash Page`: https://open.cdash.org/index.php?project=CMake
+
+Create Release Version
+======================
+
+When the ``release`` branch is ready to create a new release, follow the
+steps in the above `Maintain Current Release`_ section to checkout a local
+``release-$ver`` branch, where ``$ver`` is the version number of the
+current release in the form ``$major.$minor``.
+
+Edit ``Source/CMakeVersion.cmake`` to set the full version:
+
+.. code-block:: cmake
+
+ # CMake version number components.
+ set(CMake_VERSION_MAJOR $major)
+ set(CMake_VERSION_MINOR $minor)
+ set(CMake_VERSION_PATCH $patch)
+ #set(CMake_VERSION_RC $rc) # uncomment for release candidates
+
+In the following we use the placeholder ``$fullver`` for the full version
+number of the new release with the form ``$major.$minor.$patch[-rc$rc]``.
+If the version is not a release candidate, comment out the RC version
+component above and leave off the ``-rc$rc`` suffix from ``$fullver``.
+
+Commit the release version with the **exact** message ``CMake $fullver``:
+
+.. code-block:: shell
+
+ git commit -m "CMake $fullver"
+
+Tag the release using an annotated tag with the same message as the
+commit and named with the **exact** form ``v$fullver``:
+
+.. code-block:: shell
+
+ git tag -s -m "CMake $fullver" "v$fullver"
+
+Follow the steps in the above `Maintain Current Release`_ section to
+merge the ``release-$ver`` branch into ``master`` and publish both.
+
Branch a New Release
====================
@@ -94,7 +217,7 @@ Commit with a message such as::
the CMake Release Notes index page.
Update ``Source/CMakeVersion.cmake`` to set the version to
-``$major.$minor.0-rc1``:
+``$major.$minor.0-rc0``:
.. code-block:: cmake
@@ -102,13 +225,7 @@ Update ``Source/CMakeVersion.cmake`` to set the version to
set(CMake_VERSION_MAJOR $major)
set(CMake_VERSION_MINOR $minor)
set(CMake_VERSION_PATCH 0)
- set(CMake_VERSION_RC 1)
-
-Update ``Utilities/Release/upload_release.cmake``:
-
-.. code-block:: cmake
-
- set(VERSION $ver)
+ set(CMake_VERSION_RC 0)
Update uses of ``DEVEL_CMAKE_VERSION`` in the source tree to mention the
actual version number:
@@ -119,7 +236,7 @@ actual version number:
Commit with a message such as::
- CMake $major.$minor.0-rc1 version update
+ Begin $ver release versioning
Merge the ``release-$ver`` branch to ``master``:
@@ -147,7 +264,7 @@ Update ``Source/CMakeVersion.cmake`` to set the version to
set(CMake_VERSION_MAJOR $major)
set(CMake_VERSION_MINOR $minor)
set(CMake_VERSION_PATCH $date)
- #set(CMake_VERSION_RC 1)
+ #set(CMake_VERSION_RC 0)
Commit with a message such as::
@@ -162,10 +279,11 @@ Push the update to the ``master`` and ``release`` branches:
Announce 'release' Branch
-------------------------
-Send email to the ``cmake-developers@cmake.org`` mailing list (perhaps
-in reply to a release preparation thread) announcing that post-release
-development is open::
+Post a topic to the `CMake Discourse Forum Development Category`_
+announcing that post-release development is open::
- I've branched 'release' for $ver. The repository is now open for
- post-$ver development. Please rebase open merge requests on 'master'
+ I've branched `release` for $ver. The repository is now open for
+ post-$ver development. Please rebase open merge requests on `master`
before staging or merging.
+
+.. _`CMake Discourse Forum Development Category`: https://discourse.cmake.org/c/development
diff --git a/Help/dev/review.rst b/Help/dev/review.rst
index 9450bf081..cbde6feea 100644
--- a/Help/dev/review.rst
+++ b/Help/dev/review.rst
@@ -185,6 +185,92 @@ commands to ``@kwrobot`` using the form ``Do: ...``:
See the corresponding sections for details on permissions and options
for each command.
+Commit Messages
+---------------
+
+Part of the human review is to check that each commit message is appropriate.
+The first line of the message should begin with one or two words indicating the
+area the commit applies to, followed by a colon and then a brief summary.
+Committers should aim to keep this first line short. Any subsequent lines
+should be separated from the first by a blank line and provide relevant, useful
+information.
+
+Area Prefix on Commit Messages
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The appropriateness of the initial word describing the area the commit applies
+to is not something the automatic robot review can judge, so it is up to the
+human reviewer to confirm that the area is specified and that it is
+appropriate. Good area words include the module name the commit is primarily
+fixing, the main C++ source file being edited, ``Help`` for generic
+documentation changes or a feature or functionality theme the changes apply to
+(e.g. ``server`` or ``Autogen``). Examples of suitable first lines of a commit
+message include:
+
+* ``Help: Fix example in cmake-buildsystem(7) manual``
+* ``FindBoost: Add support for 1.64``
+* ``Autogen: Extended mocInclude tests``
+* ``cmLocalGenerator: Explain standard flag selection logic in comments``
+
+Referencing Issues in Commit Messages
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+If the commit fixes a particular reported issue, this information should
+ideally also be part of the commit message. The recommended way to do this is
+to place a line at the end of the message in the form ``Fixes: #xxxxx`` where
+``xxxxx`` is the GitLab issue number and to separate it from the rest of the
+text by a blank line. For example::
+
+ Help: Fix FooBar example robustness issue
+
+ FooBar supports option X, but the example provided
+ would not work if Y was also specified.
+
+ Fixes: #12345
+
+GitLab will automatically create relevant links to the merge request and will
+close the issue when the commit is merged into master. GitLab understands a few
+other synonyms for ``Fixes`` and allows much more flexible forms than the
+above, but committers should aim for this format for consistency. Note that
+such details can alternatively be specified in the merge request description.
+
+Referencing Commits in Commit Messages
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The preferred form for references to other commits is
+``commit <shorthash> (<subject>, <date>)``, where:
+
+* ``<shorthash>``:
+ The abbreviated hash of the commit.
+
+* ``<subject>``:
+ The first line of the commit message.
+
+* ``<date>``:
+ The author date of the commit, in its original time zone, formatted as
+ ``CCYY-MM-DD``. ``git-log(1)`` shows the original time zone by default.
+
+This may be generated with
+``git show -s --date=short --pretty="format:%h (%s, %ad)" <commit>``.
+
+If the commit is a fix for the mentioned commit, consider using a ``Fixes:``
+trailer in the commit message with the specified format. This trailer should
+not be word-wrapped. Note that if there is also an issue for what is being
+fixed, it is preferrable to link to the issue instead.
+
+If relevant, add the first release tag of CMake containing the commit after
+the ``<date>``, i.e., ``commit <shorthash> (<subject>, <date>, <tag>)``.
+
+Alternatively, the full commit ``<hash>`` may be used.
+
+Revising Commit Messages
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Reviewers are encouraged to ask the committer to amend commit messages to
+follow these guidelines, but prefer to focus on the changes themselves as a
+first priority. Maintainers will also make a check of commit messages before
+merging.
+
Topic Testing
=============
@@ -246,6 +332,14 @@ branch (e.g. ``master``) branch followed by a sequence of merges each
integrating changes from an open MR that has been staged for integration
testing. Each time the target integration branch is updated the stage
is rebuilt automatically by merging the staged MR topics again.
+The branch is stored in the upstream repository by special refs:
+
+* ``refs/stage/master/head``: The current topic stage branch.
+ This is used by continuous builds that report to CDash.
+* ``refs/stage/master/nightly/latest``: Topic stage as of 1am UTC each night.
+ This is used by most nightly builds that report to CDash.
+* ``refs/stage/master/nightly/<yyyy>/<mm>/<dd>``: Topic stage as of 1am UTC
+ on the date specified. This is used for historical reference.
`CMake GitLab Project Developers`_ may stage a MR for integration testing
by adding a comment with a command among the `comment trailing lines`_::
@@ -283,7 +377,15 @@ command is needed to stage it again.
Resolve
=======
-A MR may be resolved in one of the following ways.
+The workflow used by the CMake project supports a number of different
+ways in which a MR can be moved to a resolved state. In addition to
+the conventional practices of merging or closing a MR without merging it,
+a MR can also be moved to a quasi-resolved state pending some action.
+This may involve moving discussion to an issue or it may be the result of
+an extended period of inactivity. These quasi-resolved states are used
+to help manage the relatively large number of MRs the project receives
+and are not an indication of the changes being rejected. The following
+sections explain the different resolutions a MR may be given.
Merge
-----
@@ -324,11 +426,14 @@ The ``Do: merge`` command accepts the following arguments:
branch in the constructed merge commit message.
Additionally, ``Do: merge`` extracts configuration from trailing lines
-in the MR description:
+in the MR description (the following have no effect if used in a MR
+comment instead):
* ``Topic-rename: <topic>``: substitute ``<topic>`` for the name of
the MR topic branch in the constructed merge commit message.
- The ``-t`` option overrides this.
+ It is also used in merge commits constructed by ``Do: stage``.
+ The ``-t`` option to a ``Do: merge`` command overrides any topic
+ rename set in the MR description.
.. _`CMake GitLab Project Masters`: https://gitlab.kitware.com/cmake/cmake/settings/members
@@ -336,15 +441,68 @@ Close
-----
If review has concluded that the MR should not be integrated then it
-may be closed through GitLab.
+may be closed through GitLab. This would normally be a final state
+with no expectation that the MR would be re-opened in the future.
+It is also used when a MR is being superseded by another separate one,
+in which case a reference to the new MR should be added to the MR being
+closed.
Expire
------
If progress on a MR has stalled for a while, it may be closed with a
``workflow:expired`` label and a comment indicating that the MR has
-been closed due to inactivity.
-
-Contributors are welcome to re-open an expired MR when they are ready
-to continue work. Please re-open *before* pushing an update to the
-MR topic branch to ensure GitLab will still act on the association.
+been closed due to inactivity (it may also be done where the MR is blocked
+for an extended period by work in a different MR). This is not an
+indication that there is a problem with the MR's content, it is only a
+practical measure to allow the reviewers to focus attention on MRs that
+are actively being worked on. As a guide, the average period of inactivity
+before transitioning a MR to the expired state would be around 2 weeks,
+but this may decrease to 1 week or less when there is a high number of
+open merge requests.
+
+Reviewers would usually provide a message similar to the following when
+resolving a MR as expired::
+
+ Closing for now. @<MR-author> please re-open when ready to continue work.
+
+This is to make it clear to contributors that they are welcome to re-open
+the expired MR when they are ready to return to working on it and moving
+it forward. In the meantime, the MR will appear as ``Closed`` in GitLab,
+but it can be differentiated from permanently closed MRs by the presence
+of the ``workflow:expired`` label.
+
+**NOTE:** Please re-open *before* pushing an update to the MR topic branch
+to ensure GitLab will still act on the association. If changes are pushed
+before re-opening the MR, the reviewer should initiate a ``Do: check`` to
+force GitLab to act on the updates.
+
+External Discussion
+-------------------
+
+In some situations, a series of comments on a MR may develop into a more
+involved discussion, or it may become apparent that there are broader
+discussions that need to take place before the MR can move forward in an
+agreed direction. Such discussions are better suited to GitLab issues
+rather than in a MR because MRs may be superseded by a different MR, or
+the set of changes may evolve to look quite different to the context in
+which the discussions began. When this occurs, reviewers may ask the
+MR author to open an issue to discuss things there and they will transition
+the MR to a resolved state with the label ``workflow:external-discussion``.
+The MR will appear in GitLab as closed, but it can be differentiated from
+permanently closed MRs by the presence of the ``workflow:external-discussion``
+label. Reviewers should leave a message clearly explaining the action
+so that the MR author understands that the MR closure is temporary and
+it is clear what actions need to happen next. The following is an example
+of such a message, but it will usually be necessary to tailor the message
+to the individual situation::
+
+ The desired behavior here looks to be more involved than first thought.
+ Please open an issue so we can discuss the relevant details there.
+ Once the path forward is clear, we can re-open this MR and continue work.
+
+When the discussion in the associated issue runs its course and the way
+forward is clear, the MR can be re-opened again and the
+``workflow:external-discussion`` label removed. Reviewers should ensure
+that the issue created contains a reference to the MR so that GitLab
+provides a cross-reference to link the two.
diff --git a/Help/dev/source.rst b/Help/dev/source.rst
index 7e4499559..0f7488be0 100644
--- a/Help/dev/source.rst
+++ b/Help/dev/source.rst
@@ -9,7 +9,7 @@ See documentation on `CMake Development`_ for more information.
C++ Code Style
==============
-We use `clang-format`_ version **3.8** to define our style for C++ code in
+We use `clang-format`_ version **6.0** to define our style for C++ code in
the CMake source tree. See the `.clang-format`_ configuration file for our
style settings. Use the `Utilities/Scripts/clang-format.bash`_ script to
format source code. It automatically runs ``clang-format`` on the set of
@@ -23,38 +23,59 @@ format only a subset of files, such as those that are locally modified.
C++ Subset Permitted
====================
-CMake supports compiling as C++98 in addition to C++11 and C++14.
-In order to support building on older toolchains some constructs
-need to be handled with care:
+CMake requires compiling as C++11 or above. However, in order to support
+building on older toolchains some constructs need to be handled with care:
-* Use ``CM_AUTO_PTR`` instead of ``std::auto_ptr``.
+* Do not use ``std::auto_ptr``.
- The ``std::auto_ptr`` template is deprecated in C++11. We want to use it
- so we can build on C++98 compilers but we do not want to turn off compiler
- warnings about deprecated interfaces in general. Use the ``CM_AUTO_PTR``
- macro instead.
+ The ``std::auto_ptr`` template is deprecated in C++11. Use ``std::unique_ptr``.
-* Use ``CM_EQ_DELETE;`` instead of ``= delete;``.
+Source Tree Layout
+==================
- Defining functions as *deleted* is not supported in C++98. Using
- ``CM_EQ_DELETE`` will delete the functions if the compiler supports it and
- give them no implementation otherwise. Calling such a function will lead
- to compiler errors if the compiler supports *deleted* functions and linker
- errors otherwise.
+The CMake source tree is organized as follows.
-* Use ``CM_DISABLE_COPY(Class)`` to mark classes as non-copyable.
+* ``Auxiliary/``:
+ Shell and editor integration files.
- The ``CM_DISABLE_COPY`` macro should be used in the private section of a
- class to make sure that attempts to copy or assign an instance of the class
- lead to compiler errors even if the compiler does not support *deleted*
- functions. As a guideline, all polymorphic classes should be made
- non-copyable in order to avoid slicing. Classes that are composed of or
- derived from non-copyable classes must also be made non-copyable explicitly
- with ``CM_DISABLE_COPY``.
+* ``Help/``:
+ Documentation. See the `CMake Documentation Guide`_.
-* Use ``size_t`` instead of ``std::size_t``.
+ * ``Help/dev/``:
+ Developer documentation.
- Various implementations have differing implementation of ``size_t``.
- When assigning the result of ``.size()`` on a container for example,
- the result should be assigned to ``size_t`` not to ``std::size_t``,
- ``unsigned int`` or similar types.
+ * ``Help/release/dev/``:
+ Release note snippets for development since last release.
+
+* ``Licenses/``:
+ License files for third-party libraries in binary distributions.
+
+* ``Modules/``:
+ CMake language modules installed with CMake.
+
+* ``Packaging/``:
+ Files used for packaging CMake itself for distribution.
+
+* ``Source/``:
+ Source code of CMake itself.
+
+* ``Templates/``:
+ Files distributed with CMake as implementation details for generators,
+ packagers, etc.
+
+* ``Tests/``:
+ The test suite. See `Tests/README.rst`_.
+
+* ``Utilities/``:
+ Scripts, third-party source code.
+
+ * ``Utilities/Sphinx/``:
+ Sphinx configuration to build CMake user documentation.
+
+ * ``Utilities/Release/``:
+ Scripts used to package CMake itself for distribution on ``cmake.org``.
+ See `Utilities/Release/README.rst`_.
+
+.. _`CMake Documentation Guide`: documentation.rst
+.. _`Tests/README.rst`: ../../Tests/README.rst
+.. _`Utilities/Release/README.rst`: ../../Utilities/Release/README.rst
diff --git a/Help/dev/testing.rst b/Help/dev/testing.rst
index 731930c8f..23d0ca3f2 100644
--- a/Help/dev/testing.rst
+++ b/Help/dev/testing.rst
@@ -16,7 +16,7 @@ welcome to provide testing machines in order to help keep support for their
platforms working.
The `CMake Dashboard Scripts Repository`_ provides CTest scripts to drive
-nightly, continous, and experimental testing of CMake. Use the following
+nightly, continuous, and experimental testing of CMake. Use the following
commands to set up a new integration testing client:
.. code-block:: console
@@ -26,13 +26,14 @@ commands to set up a new integration testing client:
$ git clone https://gitlab.kitware.com/cmake/dashboard-scripts.git CMakeScripts
$ cd CMakeScripts
-The ``cmake_common.cmake`` script contains comments at the top with
+The `cmake_common.cmake`_ script contains comments at the top with
instructions to set up a testing client. As it instructs, create a
CTest script with local settings and include ``cmake_common.cmake``.
.. _`CMake Review Process`: review.rst
.. _`CMake CDash Page`: https://open.cdash.org/index.php?project=CMake
.. _`CMake Dashboard Scripts Repository`: https://gitlab.kitware.com/cmake/dashboard-scripts
+.. _`cmake_common.cmake`: https://gitlab.kitware.com/cmake/dashboard-scripts/blob/master/cmake_common.cmake
Nightly Start Time
------------------
diff --git a/Help/envvar/ASM_DIALECT.rst b/Help/envvar/ASM_DIALECT.rst
new file mode 100644
index 000000000..a06e3cba2
--- /dev/null
+++ b/Help/envvar/ASM_DIALECT.rst
@@ -0,0 +1,14 @@
+ASM<DIALECT>
+------------
+
+.. include:: ENV_VAR.txt
+
+Preferred executable for compiling a specific dialect of assembly language
+files. ``ASM<DIALECT>`` can be ``ASM``, ``ASM_NASM`` (Netwide Assembler),
+``ASM_MASM`` (Microsoft Assembler) or ``ASM-ATT`` (Assembler AT&T).
+Will only be used by CMake on the first configuration to determine
+``ASM<DIALECT>`` compiler, after which the value for ``ASM<DIALECT>`` is stored
+in the cache as
+:variable:`CMAKE_ASM<DIALECT>_COMPILER <CMAKE_<LANG>_COMPILER>`. For subsequent
+configuration runs, the environment variable will be ignored in favor of
+:variable:`CMAKE_ASM<DIALECT>_COMPILER <CMAKE_<LANG>_COMPILER>`.
diff --git a/Help/envvar/ASM_DIALECTFLAGS.rst b/Help/envvar/ASM_DIALECTFLAGS.rst
new file mode 100644
index 000000000..3c3b02a76
--- /dev/null
+++ b/Help/envvar/ASM_DIALECTFLAGS.rst
@@ -0,0 +1,13 @@
+ASM<DIALECT>FLAGS
+-----------------
+
+.. include:: ENV_VAR.txt
+
+Default compilation flags to be used when compiling a specific dialect of an
+assembly language. ``ASM<DIALECT>FLAGS`` can be ``ASMFLAGS``, ``ASM_NASMFLAGS``,
+``ASM_MASMFLAGS`` or ``ASM-ATTFLAGS``. Will only be used by CMake on the
+first configuration to determine ``ASM_<DIALECT>`` default compilation
+flags, after which the value for ``ASM<DIALECT>FLAGS`` is stored in the cache
+as ``CMAKE_ASM<DIALECT>_FLAGS <CMAKE_<LANG>_FLAGS>``. For any configuration
+run (including the first), the environment variable will be ignored, if the
+``CMAKE_ASM<DIALECT>_FLAGS <CMAKE_<LANG>_FLAGS>`` variable is defined.
diff --git a/Help/envvar/CC.rst b/Help/envvar/CC.rst
new file mode 100644
index 000000000..ef120593e
--- /dev/null
+++ b/Help/envvar/CC.rst
@@ -0,0 +1,11 @@
+CC
+--
+
+.. include:: ENV_VAR.txt
+
+Preferred executable for compiling ``C`` language files. Will only be used by
+CMake on the first configuration to determine ``C`` compiler, after which the
+value for ``CC`` is stored in the cache as
+:variable:`CMAKE_C_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration run
+(including the first), the environment variable will be ignored if the
+:variable:`CMAKE_C_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined.
diff --git a/Help/envvar/CFLAGS.rst b/Help/envvar/CFLAGS.rst
new file mode 100644
index 000000000..fda9ccc48
--- /dev/null
+++ b/Help/envvar/CFLAGS.rst
@@ -0,0 +1,11 @@
+CFLAGS
+------
+
+.. include:: ENV_VAR.txt
+
+Default compilation flags to be used when compiling ``C`` files. Will only be
+used by CMake on the first configuration to determine ``CC`` default compilation
+flags, after which the value for ``CFLAGS`` is stored in the cache
+as :variable:`CMAKE_C_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration run
+(including the first), the environment variable will be ignored if the
+:variable:`CMAKE_C_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined.
diff --git a/Help/envvar/CMAKE_BUILD_PARALLEL_LEVEL.rst b/Help/envvar/CMAKE_BUILD_PARALLEL_LEVEL.rst
new file mode 100644
index 000000000..199ca3e4b
--- /dev/null
+++ b/Help/envvar/CMAKE_BUILD_PARALLEL_LEVEL.rst
@@ -0,0 +1,11 @@
+CMAKE_BUILD_PARALLEL_LEVEL
+--------------------------
+
+.. include:: ENV_VAR.txt
+
+Specifies the maximum number of concurrent processes to use when building
+using the ``cmake --build`` command line
+:ref:`Build Tool Mode <Build Tool Mode>`.
+
+If this variable is defined empty the native build tool's default number is
+used.
diff --git a/Help/envvar/CMAKE_CONFIG_TYPE.rst b/Help/envvar/CMAKE_CONFIG_TYPE.rst
new file mode 100644
index 000000000..168593d50
--- /dev/null
+++ b/Help/envvar/CMAKE_CONFIG_TYPE.rst
@@ -0,0 +1,7 @@
+CMAKE_CONFIG_TYPE
+-----------------
+
+.. include:: ENV_VAR.txt
+
+The default build configuration for :ref:`Build Tool Mode` and
+``ctest`` build handler when there is no explicit configuration given.
diff --git a/Help/envvar/CMAKE_GENERATOR.rst b/Help/envvar/CMAKE_GENERATOR.rst
new file mode 100644
index 000000000..f2d055f10
--- /dev/null
+++ b/Help/envvar/CMAKE_GENERATOR.rst
@@ -0,0 +1,16 @@
+CMAKE_GENERATOR
+---------------
+
+.. include:: ENV_VAR.txt
+
+Specifies the CMake default generator to use when no generator is supplied
+with ``-G``. If the provided value doesn't name a generator known by CMake,
+the internal default is used. Either way the resulting generator selection
+is stored in the :variable:`CMAKE_GENERATOR` variable.
+
+Some generators may be additionally configured using the environment
+variables:
+
+* :envvar:`CMAKE_GENERATOR_PLATFORM`
+* :envvar:`CMAKE_GENERATOR_TOOLSET`
+* :envvar:`CMAKE_GENERATOR_INSTANCE`
diff --git a/Help/envvar/CMAKE_GENERATOR_INSTANCE.rst b/Help/envvar/CMAKE_GENERATOR_INSTANCE.rst
new file mode 100644
index 000000000..1654fa1db
--- /dev/null
+++ b/Help/envvar/CMAKE_GENERATOR_INSTANCE.rst
@@ -0,0 +1,7 @@
+CMAKE_GENERATOR_INSTANCE
+------------------------
+
+.. include:: ENV_VAR.txt
+
+Default value for :variable:`CMAKE_GENERATOR_INSTANCE` if no Cache entry is
+present. This value is only applied if :envvar:`CMAKE_GENERATOR` is set.
diff --git a/Help/envvar/CMAKE_GENERATOR_PLATFORM.rst b/Help/envvar/CMAKE_GENERATOR_PLATFORM.rst
new file mode 100644
index 000000000..917b30b14
--- /dev/null
+++ b/Help/envvar/CMAKE_GENERATOR_PLATFORM.rst
@@ -0,0 +1,8 @@
+CMAKE_GENERATOR_PLATFORM
+------------------------
+
+.. include:: ENV_VAR.txt
+
+Default value for :variable:`CMAKE_GENERATOR_PLATFORM` if no Cache entry
+is present and no value is specified by :manual:`cmake(1)` ``-A`` option.
+This value is only applied if :envvar:`CMAKE_GENERATOR` is set.
diff --git a/Help/envvar/CMAKE_GENERATOR_TOOLSET.rst b/Help/envvar/CMAKE_GENERATOR_TOOLSET.rst
new file mode 100644
index 000000000..7ac3856a1
--- /dev/null
+++ b/Help/envvar/CMAKE_GENERATOR_TOOLSET.rst
@@ -0,0 +1,8 @@
+CMAKE_GENERATOR_TOOLSET
+-----------------------
+
+.. include:: ENV_VAR.txt
+
+Default value for :variable:`CMAKE_GENERATOR_TOOLSET` if no Cache entry
+is present and no value is specified by :manual:`cmake(1)` ``-T`` option.
+This value is only applied if :envvar:`CMAKE_GENERATOR` is set.
diff --git a/Help/envvar/CMAKE_MSVCIDE_RUN_PATH.rst b/Help/envvar/CMAKE_MSVCIDE_RUN_PATH.rst
new file mode 100644
index 000000000..77ead4d55
--- /dev/null
+++ b/Help/envvar/CMAKE_MSVCIDE_RUN_PATH.rst
@@ -0,0 +1,10 @@
+CMAKE_MSVCIDE_RUN_PATH
+----------------------
+
+.. include:: ENV_VAR.txt
+
+Extra PATH locations for custom commands when using
+:generator:`Visual Studio 9 2008` (or above) generators.
+
+The ``CMAKE_MSVCIDE_RUN_PATH`` environment variable sets the default value for
+the :variable:`CMAKE_MSVCIDE_RUN_PATH` variable if not already explicitly set.
diff --git a/Help/envvar/CMAKE_NO_VERBOSE.rst b/Help/envvar/CMAKE_NO_VERBOSE.rst
new file mode 100644
index 000000000..149efbd6f
--- /dev/null
+++ b/Help/envvar/CMAKE_NO_VERBOSE.rst
@@ -0,0 +1,8 @@
+CMAKE_NO_VERBOSE
+----------------
+
+Disables verbose output from CMake when :envvar:`VERBOSE` environment variable
+is set.
+
+Only your build tool of choice will still print verbose output when you start
+to actually build your project.
diff --git a/Help/envvar/CMAKE_OSX_ARCHITECTURES.rst b/Help/envvar/CMAKE_OSX_ARCHITECTURES.rst
new file mode 100644
index 000000000..ef7d5470b
--- /dev/null
+++ b/Help/envvar/CMAKE_OSX_ARCHITECTURES.rst
@@ -0,0 +1,10 @@
+CMAKE_OSX_ARCHITECTURES
+-----------------------
+
+.. include:: ENV_VAR.txt
+
+Target specific architectures for macOS.
+
+The ``CMAKE_OSX_ARCHITECTURES`` environment variable sets the default value for
+the :variable:`CMAKE_OSX_ARCHITECTURES` variable. See
+:prop_tgt:`OSX_ARCHITECTURES` for more information.
diff --git a/Help/envvar/CSFLAGS.rst b/Help/envvar/CSFLAGS.rst
new file mode 100644
index 000000000..404bb5930
--- /dev/null
+++ b/Help/envvar/CSFLAGS.rst
@@ -0,0 +1,11 @@
+CSFLAGS
+-------
+
+.. include:: ENV_VAR.txt
+
+Preferred executable for compiling ``CSharp`` language files. Will only be
+used by CMake on the first configuration to determine ``CSharp`` default
+compilation flags, after which the value for ``CSFLAGS`` is stored in the cache
+as :variable:`CMAKE_CSharp_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration
+run (including the first), the environment variable will be ignored if the
+:variable:`CMAKE_CSharp_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined.
diff --git a/Help/envvar/CTEST_INTERACTIVE_DEBUG_MODE.rst b/Help/envvar/CTEST_INTERACTIVE_DEBUG_MODE.rst
new file mode 100644
index 000000000..e1991b2df
--- /dev/null
+++ b/Help/envvar/CTEST_INTERACTIVE_DEBUG_MODE.rst
@@ -0,0 +1,7 @@
+CTEST_INTERACTIVE_DEBUG_MODE
+----------------------------
+
+.. include:: ENV_VAR.txt
+
+Environment variable that will exist and be set to ``1`` when a test executed
+by :manual:`ctest(1)` is run in interactive mode.
diff --git a/Help/envvar/CTEST_OUTPUT_ON_FAILURE.rst b/Help/envvar/CTEST_OUTPUT_ON_FAILURE.rst
new file mode 100644
index 000000000..d8b42624f
--- /dev/null
+++ b/Help/envvar/CTEST_OUTPUT_ON_FAILURE.rst
@@ -0,0 +1,9 @@
+CTEST_OUTPUT_ON_FAILURE
+-----------------------
+
+.. include:: ENV_VAR.txt
+
+Boolean environment variable that controls if the output should be logged for
+failed tests. Set the value to ``1``, ``True``, or ``ON`` to enable output on failure.
+See :manual:`ctest(1)` for more information on controlling output of failed
+tests.
diff --git a/Help/envvar/CTEST_PARALLEL_LEVEL.rst b/Help/envvar/CTEST_PARALLEL_LEVEL.rst
new file mode 100644
index 000000000..fd4936e37
--- /dev/null
+++ b/Help/envvar/CTEST_PARALLEL_LEVEL.rst
@@ -0,0 +1,7 @@
+CTEST_PARALLEL_LEVEL
+--------------------
+
+.. include:: ENV_VAR.txt
+
+Specify the number of tests for CTest to run in parallel. See :manual:`ctest(1)`
+for more information on parallel test execution.
diff --git a/Help/envvar/CTEST_PROGRESS_OUTPUT.rst b/Help/envvar/CTEST_PROGRESS_OUTPUT.rst
new file mode 100644
index 000000000..b36a6b8c2
--- /dev/null
+++ b/Help/envvar/CTEST_PROGRESS_OUTPUT.rst
@@ -0,0 +1,16 @@
+CTEST_PROGRESS_OUTPUT
+---------------------
+
+.. include:: ENV_VAR.txt
+
+Boolean environment variable that affects how :manual:`ctest <ctest(1)>`
+command output reports overall progress. When set to ``1``, ``TRUE``, ``ON`` or anything
+else that evaluates to boolean true, progress is reported by repeatedly
+updating the same line. This greatly reduces the overall verbosity, but is
+only supported when output is sent directly to a terminal. If the environment
+variable is not set or has a value that evaluates to false, output is reported
+normally with each test having its own start and end lines logged to the
+output.
+
+The ``--progress`` option to :manual:`ctest <ctest(1)>` overrides this
+environment variable if both are given.
diff --git a/Help/envvar/CTEST_USE_LAUNCHERS_DEFAULT.rst b/Help/envvar/CTEST_USE_LAUNCHERS_DEFAULT.rst
new file mode 100644
index 000000000..79dbb79f3
--- /dev/null
+++ b/Help/envvar/CTEST_USE_LAUNCHERS_DEFAULT.rst
@@ -0,0 +1,6 @@
+CTEST_USE_LAUNCHERS_DEFAULT
+---------------------------
+
+.. include:: ENV_VAR.txt
+
+Initializes the :variable:`CTEST_USE_LAUNCHERS` variable if not already defined.
diff --git a/Help/envvar/CUDACXX.rst b/Help/envvar/CUDACXX.rst
new file mode 100644
index 000000000..10c0f9dd7
--- /dev/null
+++ b/Help/envvar/CUDACXX.rst
@@ -0,0 +1,11 @@
+CUDACXX
+-------
+
+.. include:: ENV_VAR.txt
+
+Preferred executable for compiling ``CUDA`` language files. Will only be used by
+CMake on the first configuration to determine ``CUDA`` compiler, after which the
+value for ``CUDA`` is stored in the cache as
+:variable:`CMAKE_CUDA_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration
+run (including the first), the environment variable will be ignored if the
+:variable:`CMAKE_CUDA_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined.
diff --git a/Help/envvar/CUDAFLAGS.rst b/Help/envvar/CUDAFLAGS.rst
new file mode 100644
index 000000000..4456d6bf8
--- /dev/null
+++ b/Help/envvar/CUDAFLAGS.rst
@@ -0,0 +1,11 @@
+CUDAFLAGS
+---------
+
+.. include:: ENV_VAR.txt
+
+Default compilation flags to be used when compiling ``CUDA`` files. Will only be
+used by CMake on the first configuration to determine ``CUDA`` default
+compilation flags, after which the value for ``CUDAFLAGS`` is stored in the
+cache as :variable:`CMAKE_CUDA_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration
+run (including the first), the environment variable will be ignored if
+the :variable:`CMAKE_CUDA_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined.
diff --git a/Help/envvar/CUDAHOSTCXX.rst b/Help/envvar/CUDAHOSTCXX.rst
new file mode 100644
index 000000000..b9f65bd1e
--- /dev/null
+++ b/Help/envvar/CUDAHOSTCXX.rst
@@ -0,0 +1,15 @@
+CUDAHOSTCXX
+-----------
+
+.. include:: ENV_VAR.txt
+
+Preferred executable for compiling host code when compiling ``CUDA``
+language files. Will only be used by CMake on the first configuration to
+determine ``CUDA`` host compiler, after which the value for ``CUDAHOSTCXX`` is
+stored in the cache as :variable:`CMAKE_CUDA_HOST_COMPILER`. For any
+configuration run (including the first), the environment variable will be
+ignored if the :variable:`CMAKE_CUDA_HOST_COMPILER` variable is defined.
+
+This environment variable is primarily meant for use with projects that
+enable ``CUDA`` as a first-class language. The :module:`FindCUDA`
+module will also use it to initialize its ``CUDA_HOST_COMPILER`` setting.
diff --git a/Help/envvar/CXX.rst b/Help/envvar/CXX.rst
new file mode 100644
index 000000000..d6553501a
--- /dev/null
+++ b/Help/envvar/CXX.rst
@@ -0,0 +1,11 @@
+CXX
+---
+
+.. include:: ENV_VAR.txt
+
+Preferred executable for compiling ``CXX`` language files. Will only be used by
+CMake on the first configuration to determine ``CXX`` compiler, after which the
+value for ``CXX`` is stored in the cache as
+:variable:`CMAKE_CXX_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration
+run (including the first), the environment variable will be ignored if the
+:variable:`CMAKE_CXX_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined.
diff --git a/Help/envvar/CXXFLAGS.rst b/Help/envvar/CXXFLAGS.rst
new file mode 100644
index 000000000..d7296dca0
--- /dev/null
+++ b/Help/envvar/CXXFLAGS.rst
@@ -0,0 +1,11 @@
+CXXFLAGS
+--------
+
+.. include:: ENV_VAR.txt
+
+Default compilation flags to be used when compiling ``CXX`` (C++) files. Will
+only be used by CMake on the first configuration to determine ``CXX`` default
+compilation flags, after which the value for ``CXXFLAGS`` is stored in the cache
+as :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration run (
+including the first), the environment variable will be ignored if
+the :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined.
diff --git a/Help/envvar/DASHBOARD_TEST_FROM_CTEST.rst b/Help/envvar/DASHBOARD_TEST_FROM_CTEST.rst
new file mode 100644
index 000000000..6a52d6494
--- /dev/null
+++ b/Help/envvar/DASHBOARD_TEST_FROM_CTEST.rst
@@ -0,0 +1,8 @@
+DASHBOARD_TEST_FROM_CTEST
+-------------------------
+
+.. include:: ENV_VAR.txt
+
+Environment variable that will exist when a test executed by :manual:`ctest(1)`
+is run in non-interactive mode. The value will be equal to
+:variable:`CMAKE_VERSION`.
diff --git a/Help/envvar/DESTDIR.rst b/Help/envvar/DESTDIR.rst
new file mode 100644
index 000000000..d2144ae7c
--- /dev/null
+++ b/Help/envvar/DESTDIR.rst
@@ -0,0 +1,21 @@
+DESTDIR
+-------
+
+.. include:: ENV_VAR.txt
+
+On UNIX one can use the ``DESTDIR`` mechanism in order to relocate the
+whole installation. ``DESTDIR`` means DESTination DIRectory. It is
+commonly used by makefile users in order to install software at
+non-default location. It is usually invoked like this:
+
+::
+
+ make DESTDIR=/home/john install
+
+which will install the concerned software using the installation
+prefix, e.g. ``/usr/local`` prepended with the ``DESTDIR`` value which
+finally gives ``/home/john/usr/local``.
+
+WARNING: ``DESTDIR`` may not be used on Windows because installation
+prefix usually contains a drive letter like in ``C:/Program Files``
+which cannot be prepended with some other prefix.
diff --git a/Help/envvar/ENV_VAR.txt b/Help/envvar/ENV_VAR.txt
new file mode 100644
index 000000000..e1e70cd99
--- /dev/null
+++ b/Help/envvar/ENV_VAR.txt
@@ -0,0 +1,3 @@
+This is a CMake :ref:`Environment Variable <CMake Language
+Environment Variables>`. Its initial value is taken from
+the calling process environment.
diff --git a/Help/envvar/FC.rst b/Help/envvar/FC.rst
new file mode 100644
index 000000000..d6cabbc90
--- /dev/null
+++ b/Help/envvar/FC.rst
@@ -0,0 +1,12 @@
+FC
+--
+
+.. include:: ENV_VAR.txt
+
+Preferred executable for compiling ``Fortran`` language files. Will only be used
+by CMake on the first configuration to determine ``Fortran`` compiler, after
+which the value for ``Fortran`` is stored in the cache as
+:variable:`CMAKE_Fortran_COMPILER <CMAKE_<LANG>_COMPILER>`. For any
+configuration run (including the first), the environment variable will be
+ignored if the :variable:`CMAKE_Fortran_COMPILER <CMAKE_<LANG>_COMPILER>`
+variable is defined.
diff --git a/Help/envvar/FFLAGS.rst b/Help/envvar/FFLAGS.rst
new file mode 100644
index 000000000..02d3c3461
--- /dev/null
+++ b/Help/envvar/FFLAGS.rst
@@ -0,0 +1,11 @@
+FFLAGS
+------
+
+.. include:: ENV_VAR.txt
+
+Default compilation flags to be used when compiling ``Fortran`` files. Will only
+be used by CMake on the first configuration to determine ``Fortran`` default
+compilation flags, after which the value for ``FFLAGS`` is stored in the cache
+as :variable:`CMAKE_Fortran_FLAGS <CMAKE_<LANG>_FLAGS>`. For any configuration
+run (including the first), the environment variable will be ignored if
+the :variable:`CMAKE_Fortran_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined.
diff --git a/Help/envvar/LDFLAGS.rst b/Help/envvar/LDFLAGS.rst
new file mode 100644
index 000000000..816d6ef77
--- /dev/null
+++ b/Help/envvar/LDFLAGS.rst
@@ -0,0 +1,12 @@
+LDFLAGS
+-------
+
+.. include:: ENV_VAR.txt
+
+Will only be used by CMake on the first configuration to determine the default
+linker flags, after which the value for ``LDFLAGS`` is stored in the cache
+as :variable:`CMAKE_EXE_LINKER_FLAGS_INIT`,
+:variable:`CMAKE_SHARED_LINKER_FLAGS_INIT`, and
+:variable:`CMAKE_MODULE_LINKER_FLAGS_INIT`. For any configuration run
+(including the first), the environment variable will be ignored if the
+equivalent ``CMAKE_<TYPE>_LINKER_FLAGS_INIT`` variable is defined.
diff --git a/Help/envvar/MACOSX_DEPLOYMENT_TARGET.rst b/Help/envvar/MACOSX_DEPLOYMENT_TARGET.rst
new file mode 100644
index 000000000..662bd03ec
--- /dev/null
+++ b/Help/envvar/MACOSX_DEPLOYMENT_TARGET.rst
@@ -0,0 +1,10 @@
+MACOSX_DEPLOYMENT_TARGET
+------------------------
+
+.. include:: ENV_VAR.txt
+
+Specify the minimum version of macOS on which the target binaries are
+to be deployed.
+
+The ``MACOSX_DEPLOYMENT_TARGET`` environment variable sets the default value for
+the :variable:`CMAKE_OSX_DEPLOYMENT_TARGET` variable.
diff --git a/Help/envvar/PackageName_ROOT.rst b/Help/envvar/PackageName_ROOT.rst
new file mode 100644
index 000000000..82b0a069e
--- /dev/null
+++ b/Help/envvar/PackageName_ROOT.rst
@@ -0,0 +1,17 @@
+<PackageName>_ROOT
+------------------
+
+.. include:: ENV_VAR.txt
+
+Calls to :command:`find_package(<PackageName>)` will search in prefixes
+specified by the ``<PackageName>_ROOT`` environment variable, where
+``<PackageName>`` is the name given to the :command:`find_package` call
+and ``_ROOT`` is literal. For example, ``find_package(Foo)`` will search
+prefixes specified in the ``Foo_ROOT`` environment variable (if set).
+See policy :policy:`CMP0074`.
+
+This variable may hold a single prefix or a list of prefixes separated
+by ``:`` on UNIX or ``;`` on Windows (the same as the ``PATH`` environment
+variable convention on those platforms).
+
+See also the :variable:`<PackageName>_ROOT` CMake variable.
diff --git a/Help/envvar/RC.rst b/Help/envvar/RC.rst
new file mode 100644
index 000000000..557520e8f
--- /dev/null
+++ b/Help/envvar/RC.rst
@@ -0,0 +1,11 @@
+RC
+--
+
+.. include:: ENV_VAR.txt
+
+Preferred executable for compiling ``resource`` files. Will only be used by CMake
+on the first configuration to determine ``resource`` compiler, after which the
+value for ``RC`` is stored in the cache as
+:variable:`CMAKE_RC_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration run
+(including the first), the environment variable will be ignored if the
+:variable:`CMAKE_RC_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined.
diff --git a/Help/envvar/RCFLAGS.rst b/Help/envvar/RCFLAGS.rst
new file mode 100644
index 000000000..45419fed1
--- /dev/null
+++ b/Help/envvar/RCFLAGS.rst
@@ -0,0 +1,11 @@
+RCFLAGS
+-------
+
+.. include:: ENV_VAR.txt
+
+Default compilation flags to be used when compiling ``resource`` files. Will
+only be used by CMake on the first configuration to determine ``resource``
+default compilation flags, after which the value for ``RCFLAGS`` is stored in
+the cache as :variable:`CMAKE_RC_FLAGS <CMAKE_<LANG>_FLAGS>`. For any
+configuration run (including the first), the environment variable will be ignored
+if the :variable:`CMAKE_RC_FLAGS <CMAKE_<LANG>_FLAGS>` variable is defined.
diff --git a/Help/envvar/SWIFTC.rst b/Help/envvar/SWIFTC.rst
new file mode 100644
index 000000000..b12e51df9
--- /dev/null
+++ b/Help/envvar/SWIFTC.rst
@@ -0,0 +1,11 @@
+SWIFTC
+------
+
+.. include:: ENV_VAR.txt
+
+Preferred executable for compiling ``Swift`` language files. Will only be used by
+CMake on the first configuration to determine ``Swift`` compiler, after which the
+value for ``SWIFTC`` is stored in the cache as
+:variable:`CMAKE_Swift_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration run
+(including the first), the environment variable will be ignored if the
+:variable:`CMAKE_Swift_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined.
diff --git a/Help/envvar/VERBOSE.rst b/Help/envvar/VERBOSE.rst
new file mode 100644
index 000000000..2d775a5be
--- /dev/null
+++ b/Help/envvar/VERBOSE.rst
@@ -0,0 +1,10 @@
+VERBOSE
+-------
+
+Activates verbose output from CMake and your build tools of choice when
+you start to actually build your project.
+
+Note that any given value is ignored. It's just checked for existence.
+
+See also :ref:`Build Tool Mode <Build Tool Mode>` and
+:envvar:`CMAKE_NO_VERBOSE` environment variable
diff --git a/Help/generator/CodeBlocks.rst b/Help/generator/CodeBlocks.rst
index d03cb0ce6..d830542eb 100644
--- a/Help/generator/CodeBlocks.rst
+++ b/Help/generator/CodeBlocks.rst
@@ -4,10 +4,14 @@ CodeBlocks
Generates CodeBlocks project files.
Project files for CodeBlocks will be created in the top directory and
-in every subdirectory which features a CMakeLists.txt file containing
-a PROJECT() call. Additionally a hierarchy of makefiles is generated
-into the build tree. The appropriate make program can build the
-project through the default make target. A "make install" target is
+in every subdirectory which features a ``CMakeLists.txt`` file containing
+a :command:`project` call. Additionally a hierarchy of makefiles is generated
+into the build tree.
+The :variable:`CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES` variable may
+be set to ``ON`` to exclude any files which are located outside of
+the project root directory.
+The appropriate make program can build the
+project through the default ``all`` target. An ``install`` target is
also provided.
This "extra" generator may be specified as:
diff --git a/Help/generator/CodeLite.rst b/Help/generator/CodeLite.rst
index 3e60aa6d6..46fa5bef7 100644
--- a/Help/generator/CodeLite.rst
+++ b/Help/generator/CodeLite.rst
@@ -7,11 +7,11 @@ Project files for CodeLite will be created in the top directory and
in every subdirectory which features a CMakeLists.txt file containing
a :command:`project` call.
The :variable:`CMAKE_CODELITE_USE_TARGETS` variable may be set to ``ON``
-to change the default behaviour from projects to targets as the basis
+to change the default behavior from projects to targets as the basis
for project files.
The appropriate make program can build the
-project through the default make target. A "make install" target is
-also provided.
+project through the default ``all`` target. An ``install`` target
+is also provided.
This "extra" generator may be specified as:
diff --git a/Help/generator/Eclipse CDT4.rst b/Help/generator/Eclipse CDT4.rst
index eb68bf094..634e2b6dd 100644
--- a/Help/generator/Eclipse CDT4.rst
+++ b/Help/generator/Eclipse CDT4.rst
@@ -7,7 +7,7 @@ Project files for Eclipse will be created in the top directory. In
out of source builds, a linked resource to the top level source
directory will be created. Additionally a hierarchy of makefiles is
generated into the build tree. The appropriate make program can build
-the project through the default make target. A "make install" target
+the project through the default ``all`` target. An ``install`` target
is also provided.
This "extra" generator may be specified as:
diff --git a/Help/generator/Green Hills MULTI.rst b/Help/generator/Green Hills MULTI.rst
index 4d3169026..dffc6795d 100644
--- a/Help/generator/Green Hills MULTI.rst
+++ b/Help/generator/Green Hills MULTI.rst
@@ -3,12 +3,65 @@ Green Hills MULTI
Generates Green Hills MULTI project files (experimental, work-in-progress).
-Customizations are available through the following cache variables:
+The buildsystem has predetermined build-configuration settings that can be controlled
+via the :variable:`CMAKE_BUILD_TYPE` variable.
+
+Customizations that are used to pick toolset and target system:
+
+The ``-A <arch>`` can be supplied for setting the target architecture.
+``<arch>`` usually is one of ``arm``, ``ppc``, ``86``, etcetera.
+If the target architecture is not specified then
+the default architecture of ``arm`` will be used.
+
+The ``-T <toolset>`` option can be used to set the directory location of the toolset.
+Both absolute and relative paths are valid. Relative paths use ``GHS_TOOLSET_ROOT``
+as the root. If the toolset is not specified then the latest toolset found in
+``GHS_TOOLSET_ROOT`` will be used.
+
+Cache variables that are used for toolset and target system customization:
+
+* ``GHS_TARGET_PLATFORM``
+
+ | Defaults to ``integrity``.
+ | Usual values are ``integrity``, ``threadx``, ``uvelosity``, ``velosity``,
+ ``vxworks``, ``standalone``.
+
+* ``GHS_PRIMARY_TARGET``
+
+ | Sets ``primaryTarget`` entry in project file.
+ | Defaults to ``<arch>_<GHS_TARGET_PLATFORM>.tgt``.
+
+* ``GHS_TOOLSET_ROOT``
+
+ | Root path for ``toolset`` searches.
+ | Defaults to ``C:/ghs`` in Windows or ``/usr/ghs`` in Linux.
+
+* ``GHS_OS_ROOT``
+
+ | Root path for RTOS searches.
+ | Defaults to ``C:/ghs`` in Windows or ``/usr/ghs`` in Linux.
+
+* ``GHS_OS_DIR`` and ``GHS_OS_DIR_OPTION``
+
+ | Sets ``-os_dir`` entry in project file.
+ | Defaults to latest platform OS installation at ``GHS_OS_ROOT``. Set this value if
+ a specific RTOS is to be used.
+ | ``GHS_OS_DIR_OPTION`` default value is ``-os_dir``.
* ``GHS_BSP_NAME``
+
+ | Sets ``-bsp`` entry in project file.
+ | Defaults to ``sim<arch>`` for ``integrity`` platforms.
+
+Customizations are available through the following cache variables:
+
* ``GHS_CUSTOMIZATION``
* ``GHS_GPJ_MACROS``
-* ``GHS_OS_DIR``
+
+The following properties are available:
+
+* :prop_tgt:`GHS_INTEGRITY_APP`
+* :prop_tgt:`GHS_NO_SOURCE_GROUP_FILE`
.. note::
This generator is deemed experimental as of CMake |release|
diff --git a/Help/generator/KDevelop3.rst b/Help/generator/KDevelop3.rst
deleted file mode 100644
index eaa218bc8..000000000
--- a/Help/generator/KDevelop3.rst
+++ /dev/null
@@ -1,25 +0,0 @@
-KDevelop3
----------
-
-Generates KDevelop 3 project files.
-
-Project files for KDevelop 3 will be created in the top directory and
-in every subdirectory which features a CMakeLists.txt file containing
-a PROJECT() call. If you change the settings using KDevelop cmake
-will try its best to keep your changes when regenerating the project
-files. Additionally a hierarchy of UNIX makefiles is generated into
-the build tree. Any standard UNIX-style make program can build the
-project through the default make target. A "make install" target is
-also provided.
-
-This "extra" generator may be specified as:
-
-``KDevelop3 - Unix Makefiles``
- Generate with :generator:`Unix Makefiles`.
-
-``KDevelop3``
- Generate with :generator:`Unix Makefiles`.
-
- For historical reasons this extra generator may be specified
- directly as the main generator and it will be used as the
- extra generator with :generator:`Unix Makefiles` automatically.
diff --git a/Help/generator/Kate.rst b/Help/generator/Kate.rst
index 9b61a93b3..129bf631b 100644
--- a/Help/generator/Kate.rst
+++ b/Help/generator/Kate.rst
@@ -5,10 +5,10 @@ Generates Kate project files.
A project file for Kate will be created in the top directory in the top level
build directory.
-To use it in kate, the Project plugin must be enabled.
-The project file is loaded in kate simply by opening the
-ProjectName.kateproject file in the editor.
-If the kate Build-plugin is enabled, all targets generated by CMake are
+To use it in Kate, the Project plugin must be enabled.
+The project file is loaded in Kate by opening the
+``ProjectName.kateproject`` file in the editor.
+If the Kate Build-plugin is enabled, all targets generated by CMake are
available for building.
This "extra" generator may be specified as:
diff --git a/Help/generator/MSYS Makefiles.rst b/Help/generator/MSYS Makefiles.rst
index f7cfa4461..75b9fe531 100644
--- a/Help/generator/MSYS Makefiles.rst
+++ b/Help/generator/MSYS Makefiles.rst
@@ -1,7 +1,8 @@
MSYS Makefiles
--------------
-Generates makefiles for use with MSYS ``make`` under the MSYS shell.
+Generates makefiles for use with MSYS (Minimal SYStem)
+``make`` under the MSYS shell.
Use this generator in a MSYS shell prompt and using ``make`` as the build
tool. The generated makefiles use ``/bin/sh`` as the shell to launch build
diff --git a/Help/generator/MinGW Makefiles.rst b/Help/generator/MinGW Makefiles.rst
index 9fe5fe3e5..134ea7094 100644
--- a/Help/generator/MinGW Makefiles.rst
+++ b/Help/generator/MinGW Makefiles.rst
@@ -4,7 +4,8 @@ MinGW Makefiles
Generates makefiles for use with ``mingw32-make`` under a Windows command
prompt.
-Use this generator under a Windows command prompt with MinGW in the ``PATH``
+Use this generator under a Windows command prompt with
+MinGW (Minimalist GNU for Windows) in the ``PATH``
and using ``mingw32-make`` as the build tool. The generated makefiles use
``cmd.exe`` as the shell to launch build rules. They are not compatible with
MSYS or a unix shell.
diff --git a/Help/generator/Ninja.rst b/Help/generator/Ninja.rst
index 3bbd9dcbe..c75d2c4cf 100644
--- a/Help/generator/Ninja.rst
+++ b/Help/generator/Ninja.rst
@@ -3,9 +3,9 @@ Ninja
Generates build.ninja files.
-A build.ninja file is generated into the build tree. Recent versions
-of the ninja program can build the project through the "all" target.
-An "install" target is also provided.
+A ``build.ninja`` file is generated into the build tree. Use the ninja
+program to build the project through the ``all`` target and install the
+project through the ``install`` (or ``install/strip``) target.
For each subdirectory ``sub/dir`` of the project, additional targets
are generated:
@@ -16,6 +16,13 @@ are generated:
``sub/dir/install``
Runs the install step in the subdirectory, if any.
+``sub/dir/install/strip``
+ Runs the install step in the subdirectory followed by a ``CMAKE_STRIP`` command,
+ if any.
+
+ The ``CMAKE_STRIP`` variable will contain the platform's ``strip`` utility, which
+ removes symbols information from generated binaries.
+
``sub/dir/test``
Runs the test step in the subdirectory, if any.
diff --git a/Help/generator/Sublime Text 2.rst b/Help/generator/Sublime Text 2.rst
index 0597a9528..0a07ea983 100644
--- a/Help/generator/Sublime Text 2.rst
+++ b/Help/generator/Sublime Text 2.rst
@@ -4,11 +4,11 @@ Sublime Text 2
Generates Sublime Text 2 project files.
Project files for Sublime Text 2 will be created in the top directory
-and in every subdirectory which features a CMakeLists.txt file
-containing a PROJECT() call. Additionally Makefiles (or build.ninja
-files) are generated into the build tree. The appropriate make
-program can build the project through the default make target. A
-"make install" target is also provided.
+and in every subdirectory which features a ``CMakeLists.txt`` file
+containing a :command:`project` call. Additionally ``Makefiles``
+(or ``build.ninja`` files) are generated into the build tree.
+The appropriate make program can build the project through the default ``all``
+target. An ``install`` target is also provided.
This "extra" generator may be specified as:
diff --git a/Help/generator/Unix Makefiles.rst b/Help/generator/Unix Makefiles.rst
index 97d74a853..dfe4ecbd9 100644
--- a/Help/generator/Unix Makefiles.rst
+++ b/Help/generator/Unix Makefiles.rst
@@ -3,6 +3,29 @@ Unix Makefiles
Generates standard UNIX makefiles.
-A hierarchy of UNIX makefiles is generated into the build tree. Any
-standard UNIX-style make program can build the project through the
-default make target. A "make install" target is also provided.
+A hierarchy of UNIX makefiles is generated into the build tree. Use
+any standard UNIX-style make program to build the project through
+the ``all`` target and install the project through the ``install``
+(or ``install/strip``) target.
+
+For each subdirectory ``sub/dir`` of the project a UNIX makefile will
+be created, containing the following targets:
+
+``all``
+ Depends on all targets required by the subdirectory.
+
+``install``
+ Runs the install step in the subdirectory, if any.
+
+``install/strip``
+ Runs the install step in the subdirectory followed by a ``CMAKE_STRIP`` command,
+ if any.
+
+ The ``CMAKE_STRIP`` variable will contain the platform's ``strip`` utility, which
+ removes symbols information from generated binaries.
+
+``test``
+ Runs the test step in the subdirectory, if any.
+
+``package``
+ Runs the package step in the subdirectory, if any.
diff --git a/Help/generator/VS_TOOLSET_HOST_ARCH.txt b/Help/generator/VS_TOOLSET_HOST_ARCH.txt
index 5d13e7741..029363115 100644
--- a/Help/generator/VS_TOOLSET_HOST_ARCH.txt
+++ b/Help/generator/VS_TOOLSET_HOST_ARCH.txt
@@ -1,6 +1,7 @@
For each toolset that comes with this version of Visual Studio, there are
-variants that are themselves compiled for 32-bit (x86) and 64-bit (x64) hosts
-(independent of the architecture they target). By default Visual Studio
-chooses the 32-bit variant even on a 64-bit host. One may request use of the
-64-bit host tools by adding a ``host=x64`` option to the toolset specification.
+variants that are themselves compiled for 32-bit (``x86``) and
+64-bit (``x64``) hosts (independent of the architecture they target).
+|VS_TOOLSET_HOST_ARCH_DEFAULT|
+One may explicitly request use of either the 32-bit or 64-bit host tools
+by adding either ``host=x86`` or ``host=x64`` to the toolset specification.
See the :variable:`CMAKE_GENERATOR_TOOLSET` variable for details.
diff --git a/Help/generator/Visual Studio 10 2010.rst b/Help/generator/Visual Studio 10 2010.rst
index 04eef1039..4bf9a8f15 100644
--- a/Help/generator/Visual Studio 10 2010.rst
+++ b/Help/generator/Visual Studio 10 2010.rst
@@ -3,11 +3,31 @@ Visual Studio 10 2010
Generates Visual Studio 10 (VS 2010) project files.
-The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set
-to specify a target platform name (architecture).
+For compatibility with CMake versions prior to 3.0, one may specify this
+generator using the name ``Visual Studio 10`` without the year component.
+
+Project Types
+^^^^^^^^^^^^^
+
+Only Visual C++ and C# projects may be generated. Other types of
+projects (Database, Website, etc.) are not supported.
+
+Platform Selection
+^^^^^^^^^^^^^^^^^^
+
+The default target platform name (architecture) is ``Win32``.
+
+The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
+via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
+name (architecture). For example:
+
+* ``cmake -G "Visual Studio 10 2010" -A Win32``
+* ``cmake -G "Visual Studio 10 2010" -A x64``
+* ``cmake -G "Visual Studio 10 2010" -A Itanium``
For compatibility with CMake versions prior to 3.1, one may specify
-a target platform name optionally at the end of this generator name:
+a target platform name optionally at the end of the generator name.
+This is supported only for:
``Visual Studio 10 2010 Win64``
Specify target platform ``x64``.
@@ -15,9 +35,6 @@ a target platform name optionally at the end of this generator name:
``Visual Studio 10 2010 IA64``
Specify target platform ``Itanium``.
-For compatibility with CMake versions prior to 3.0, one may specify this
-generator using the name ``Visual Studio 10`` without the year component.
-
Toolset Selection
^^^^^^^^^^^^^^^^^
diff --git a/Help/generator/Visual Studio 11 2012.rst b/Help/generator/Visual Studio 11 2012.rst
index 347a153b9..5d89a6e7c 100644
--- a/Help/generator/Visual Studio 11 2012.rst
+++ b/Help/generator/Visual Studio 11 2012.rst
@@ -3,11 +3,33 @@ Visual Studio 11 2012
Generates Visual Studio 11 (VS 2012) project files.
-The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set
-to specify a target platform name (architecture).
+For compatibility with CMake versions prior to 3.0, one may specify this
+generator using the name "Visual Studio 11" without the year component.
+
+Project Types
+^^^^^^^^^^^^^
+
+Only Visual C++ and C# projects may be generated. Other types of
+projects (JavaScript, Database, Website, etc.) are not supported.
+
+Platform Selection
+^^^^^^^^^^^^^^^^^^
+
+The default target platform name (architecture) is ``Win32``.
+
+The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
+via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
+name (architecture). For example:
+
+* ``cmake -G "Visual Studio 11 2012" -A Win32``
+* ``cmake -G "Visual Studio 11 2012" -A x64``
+* ``cmake -G "Visual Studio 11 2012" -A ARM``
+* ``cmake -G "Visual Studio 11 2012" -A <WinCE-SDK>``
+ (Specify a target platform matching a Windows CE SDK name.)
For compatibility with CMake versions prior to 3.1, one may specify
-a target platform name optionally at the end of this generator name:
+a target platform name optionally at the end of the generator name.
+This is supported only for:
``Visual Studio 11 2012 Win64``
Specify target platform ``x64``.
@@ -18,9 +40,6 @@ a target platform name optionally at the end of this generator name:
``Visual Studio 11 2012 <WinCE-SDK>``
Specify target platform matching a Windows CE SDK name.
-For compatibility with CMake versions prior to 3.0, one may specify this
-generator using the name "Visual Studio 11" without the year component.
-
Toolset Selection
^^^^^^^^^^^^^^^^^
diff --git a/Help/generator/Visual Studio 12 2013.rst b/Help/generator/Visual Studio 12 2013.rst
index 5071b20ce..fb8e021bc 100644
--- a/Help/generator/Visual Studio 12 2013.rst
+++ b/Help/generator/Visual Studio 12 2013.rst
@@ -3,11 +3,31 @@ Visual Studio 12 2013
Generates Visual Studio 12 (VS 2013) project files.
-The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set
-to specify a target platform name (architecture).
+For compatibility with CMake versions prior to 3.0, one may specify this
+generator using the name "Visual Studio 12" without the year component.
+
+Project Types
+^^^^^^^^^^^^^
+
+Only Visual C++ and C# projects may be generated. Other types of
+projects (JavaScript, Powershell, Python, etc.) are not supported.
+
+Platform Selection
+^^^^^^^^^^^^^^^^^^
+
+The default target platform name (architecture) is ``Win32``.
+
+The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
+via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
+name (architecture). For example:
+
+* ``cmake -G "Visual Studio 12 2013" -A Win32``
+* ``cmake -G "Visual Studio 12 2013" -A x64``
+* ``cmake -G "Visual Studio 12 2013" -A ARM``
For compatibility with CMake versions prior to 3.1, one may specify
-a target platform name optionally at the end of this generator name:
+a target platform name optionally at the end of the generator name.
+This is supported only for:
``Visual Studio 12 2013 Win64``
Specify target platform ``x64``.
@@ -15,9 +35,6 @@ a target platform name optionally at the end of this generator name:
``Visual Studio 12 2013 ARM``
Specify target platform ``ARM``.
-For compatibility with CMake versions prior to 3.0, one may specify this
-generator using the name "Visual Studio 12" without the year component.
-
Toolset Selection
^^^^^^^^^^^^^^^^^
@@ -25,4 +42,7 @@ The ``v120`` toolset that comes with Visual Studio 12 2013 is selected by
default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps
via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
+.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace::
+ By default this generator uses the 32-bit variant even on a 64-bit host.
+
.. include:: VS_TOOLSET_HOST_ARCH.txt
diff --git a/Help/generator/Visual Studio 14 2015.rst b/Help/generator/Visual Studio 14 2015.rst
index 64254b579..7383f7a6f 100644
--- a/Help/generator/Visual Studio 14 2015.rst
+++ b/Help/generator/Visual Studio 14 2015.rst
@@ -3,11 +3,28 @@ Visual Studio 14 2015
Generates Visual Studio 14 (VS 2015) project files.
-The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set
-to specify a target platform name (architecture).
+Project Types
+^^^^^^^^^^^^^
+
+Only Visual C++ and C# projects may be generated. Other types of
+projects (JavaScript, Powershell, Python, etc.) are not supported.
+
+Platform Selection
+^^^^^^^^^^^^^^^^^^
+
+The default target platform name (architecture) is ``Win32``.
+
+The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
+via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
+name (architecture). For example:
+
+* ``cmake -G "Visual Studio 14 2015" -A Win32``
+* ``cmake -G "Visual Studio 14 2015" -A x64``
+* ``cmake -G "Visual Studio 14 2015" -A ARM``
For compatibility with CMake versions prior to 3.1, one may specify
-a target platform name optionally at the end of this generator name:
+a target platform name optionally at the end of the generator name.
+This is supported only for:
``Visual Studio 14 2015 Win64``
Specify target platform ``x64``.
@@ -22,4 +39,7 @@ The ``v140`` toolset that comes with Visual Studio 14 2015 is selected by
default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps
via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
+.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace::
+ By default this generator uses the 32-bit variant even on a 64-bit host.
+
.. include:: VS_TOOLSET_HOST_ARCH.txt
diff --git a/Help/generator/Visual Studio 15 2017.rst b/Help/generator/Visual Studio 15 2017.rst
index 2ac044968..7e6f0fb20 100644
--- a/Help/generator/Visual Studio 15 2017.rst
+++ b/Help/generator/Visual Studio 15 2017.rst
@@ -3,11 +3,45 @@ Visual Studio 15 2017
Generates Visual Studio 15 (VS 2017) project files.
-The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set
-to specify a target platform name (architecture).
+Project Types
+^^^^^^^^^^^^^
+
+Only Visual C++ and C# projects may be generated. Other types of
+projects (JavaScript, Powershell, Python, etc.) are not supported.
+
+Instance Selection
+^^^^^^^^^^^^^^^^^^
+
+VS 2017 supports multiple installations on the same machine.
+The :variable:`CMAKE_GENERATOR_INSTANCE` variable may be set as a
+cache entry containing the absolute path to a Visual Studio instance.
+If the value is not specified explicitly by the user or a toolchain file,
+CMake queries the Visual Studio Installer to locate VS instances, chooses
+one, and sets the variable as a cache entry to hold the value persistently.
+
+When CMake first chooses an instance, if the ``VS150COMNTOOLS`` environment
+variable is set and points to the ``Common7/Tools`` directory within
+one of the instances, that instance will be used. Otherwise, if more
+than one instance is installed we do not define which one is chosen
+by default.
+
+Platform Selection
+^^^^^^^^^^^^^^^^^^
+
+The default target platform name (architecture) is ``Win32``.
+
+The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
+via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
+name (architecture). For example:
+
+* ``cmake -G "Visual Studio 15 2017" -A Win32``
+* ``cmake -G "Visual Studio 15 2017" -A x64``
+* ``cmake -G "Visual Studio 15 2017" -A ARM``
+* ``cmake -G "Visual Studio 15 2017" -A ARM64``
For compatibility with CMake versions prior to 3.1, one may specify
-a target platform name optionally at the end of this generator name:
+a target platform name optionally at the end of the generator name.
+This is supported only for:
``Visual Studio 15 2017 Win64``
Specify target platform ``x64``.
@@ -15,18 +49,6 @@ a target platform name optionally at the end of this generator name:
``Visual Studio 15 2017 ARM``
Specify target platform ``ARM``.
-Instance Selection
-^^^^^^^^^^^^^^^^^^
-
-VS 2017 supports multiple installations on the same machine.
-CMake queries the Visual Studio Installer to locate VS instances.
-If more than one instance is installed we do not define which one
-is chosen by default. If the ``VS150COMNTOOLS`` environment variable
-is set and points to the ``Common7/Tools`` directory within one of
-the instances, that instance will be used. The environment variable
-must remain consistently set whenever CMake is re-run within a given
-build tree.
-
Toolset Selection
^^^^^^^^^^^^^^^^^
@@ -34,4 +56,7 @@ The ``v141`` toolset that comes with Visual Studio 15 2017 is selected by
default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps
via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
+.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace::
+ By default this generator uses the 32-bit variant even on a 64-bit host.
+
.. include:: VS_TOOLSET_HOST_ARCH.txt
diff --git a/Help/generator/Visual Studio 16 2019.rst b/Help/generator/Visual Studio 16 2019.rst
new file mode 100644
index 000000000..4aec7f73c
--- /dev/null
+++ b/Help/generator/Visual Studio 16 2019.rst
@@ -0,0 +1,54 @@
+Visual Studio 16 2019
+---------------------
+
+Generates Visual Studio 16 (VS 2019) project files.
+
+Project Types
+^^^^^^^^^^^^^
+
+Only Visual C++ and C# projects may be generated. Other types of
+projects (JavaScript, Powershell, Python, etc.) are not supported.
+
+Instance Selection
+^^^^^^^^^^^^^^^^^^
+
+VS 2019 supports multiple installations on the same machine.
+The :variable:`CMAKE_GENERATOR_INSTANCE` variable may be set as a
+cache entry containing the absolute path to a Visual Studio instance.
+If the value is not specified explicitly by the user or a toolchain file,
+CMake queries the Visual Studio Installer to locate VS instances, chooses
+one, and sets the variable as a cache entry to hold the value persistently.
+
+When CMake first chooses an instance, if the ``VS160COMNTOOLS`` environment
+variable is set and points to the ``Common7/Tools`` directory within
+one of the instances, that instance will be used. Otherwise, if more
+than one instance is installed we do not define which one is chosen
+by default.
+
+Platform Selection
+^^^^^^^^^^^^^^^^^^
+
+The default target platform name (architecture) is that of the host
+and is provided in the :variable:`CMAKE_VS_PLATFORM_NAME_DEFAULT` variable.
+
+The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
+via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
+name (architecture). For example:
+
+* ``cmake -G "Visual Studio 16 2019" -A Win32``
+* ``cmake -G "Visual Studio 16 2019" -A x64``
+* ``cmake -G "Visual Studio 16 2019" -A ARM``
+* ``cmake -G "Visual Studio 16 2019" -A ARM64``
+
+Toolset Selection
+^^^^^^^^^^^^^^^^^
+
+The ``v142`` toolset that comes with Visual Studio 16 2019 is selected by
+default. The :variable:`CMAKE_GENERATOR_TOOLSET` option may be set, perhaps
+via the :manual:`cmake(1)` ``-T`` option, to specify another toolset.
+
+.. |VS_TOOLSET_HOST_ARCH_DEFAULT| replace::
+ By default this generator uses the 64-bit variant on x64 hosts and
+ the 32-bit variant otherwise.
+
+.. include:: VS_TOOLSET_HOST_ARCH.txt
diff --git a/Help/generator/Visual Studio 8 2005.rst b/Help/generator/Visual Studio 8 2005.rst
index acbbf01ae..947e7a597 100644
--- a/Help/generator/Visual Studio 8 2005.rst
+++ b/Help/generator/Visual Studio 8 2005.rst
@@ -1,23 +1,6 @@
Visual Studio 8 2005
--------------------
-Deprecated. Generates Visual Studio 8 2005 project files.
-
-.. note::
- This generator is deprecated and will be removed in a future version
- of CMake. It will still be possible to build with VS 8 2005 tools
- using the :generator:`Visual Studio 10 2010` (or above) generator
- with :variable:`CMAKE_GENERATOR_TOOLSET` set to ``v80``, or by
- using the :generator:`NMake Makefiles` generator.
-
-The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set
-to specify a target platform name.
-
-For compatibility with CMake versions prior to 3.1, one may specify
-a target platform name optionally at the end of this generator name:
-
-``Visual Studio 8 2005 Win64``
- Specify target platform ``x64``.
-
-``Visual Studio 8 2005 <WinCE-SDK>``
- Specify target platform matching a Windows CE SDK name.
+Removed. This once generated Visual Studio 8 2005 project files, but
+the generator has been removed since CMake 3.12. It is still possible to
+build with VS 2005 tools using the :generator:`NMake Makefiles` generator.
diff --git a/Help/generator/Visual Studio 9 2008.rst b/Help/generator/Visual Studio 9 2008.rst
index 40471b92e..a09d047ae 100644
--- a/Help/generator/Visual Studio 9 2008.rst
+++ b/Help/generator/Visual Studio 9 2008.rst
@@ -3,11 +3,24 @@ Visual Studio 9 2008
Generates Visual Studio 9 2008 project files.
-The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set
-to specify a target platform name.
+Platform Selection
+^^^^^^^^^^^^^^^^^^
+
+The default target platform name (architecture) is ``Win32``.
+
+The :variable:`CMAKE_GENERATOR_PLATFORM` variable may be set, perhaps
+via the :manual:`cmake(1)` ``-A`` option, to specify a target platform
+name (architecture). For example:
+
+* ``cmake -G "Visual Studio 9 2008" -A Win32``
+* ``cmake -G "Visual Studio 9 2008" -A x64``
+* ``cmake -G "Visual Studio 9 2008" -A Itanium``
+* ``cmake -G "Visual Studio 9 2008" -A <WinCE-SDK>``
+ (Specify a target platform matching a Windows CE SDK name.)
For compatibility with CMake versions prior to 3.1, one may specify
-a target platform name optionally at the end of this generator name:
+a target platform name optionally at the end of the generator name.
+This is supported only for:
``Visual Studio 9 2008 Win64``
Specify target platform ``x64``.
diff --git a/Help/generator/Xcode.rst b/Help/generator/Xcode.rst
index 968c26a70..d893ac504 100644
--- a/Help/generator/Xcode.rst
+++ b/Help/generator/Xcode.rst
@@ -3,7 +3,7 @@ Xcode
Generate Xcode project files.
-This supports Xcode 3.0 and above.
+This supports Xcode 5.0 and above.
Toolset Selection
^^^^^^^^^^^^^^^^^
diff --git a/Help/guide/tutorial/Complete/CMakeLists.txt b/Help/guide/tutorial/Complete/CMakeLists.txt
new file mode 100644
index 000000000..eca79d9df
--- /dev/null
+++ b/Help/guide/tutorial/Complete/CMakeLists.txt
@@ -0,0 +1,120 @@
+cmake_minimum_required(VERSION 3.15)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+add_library(tutorial_compiler_flags INTERFACE)
+target_compile_features(tutorial_compiler_flags INTERFACE cxx_std_11)
+
+# add compiler warning flags just when building this project via
+# the BUILD_INTERFACE genex
+set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU>")
+set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>")
+target_compile_options(tutorial_compiler_flags INTERFACE
+ "$<${gcc_like_cxx}:$<BUILD_INTERFACE:-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused>>"
+ "$<${msvc_cxx}:$<BUILD_INTERFACE:-W3>>"
+)
+
+# control where the static and shared libraries are built so that on windows
+# we don't need to tinker with the path to run the executable
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+
+option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
+
+if(APPLE)
+ set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
+elseif(UNIX)
+ set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
+endif()
+
+# configure a header file to pass the version number only
+configure_file(TutorialConfig.h.in TutorialConfig.h)
+
+# add the MathFunctions library
+add_subdirectory(MathFunctions)
+
+# add the executable
+add_executable(Tutorial tutorial.cxx)
+target_link_libraries(Tutorial PUBLIC MathFunctions)
+
+# add the binary tree to the search path for include files
+# so that we will find TutorialConfig.h
+target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ )
+
+# add the install targets
+install(TARGETS Tutorial DESTINATION bin)
+install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
+ DESTINATION include
+ )
+
+# enable testing
+enable_testing()
+
+# does the application run
+add_test(NAME Runs COMMAND Tutorial 25)
+
+# does the usage message work?
+add_test(NAME Usage COMMAND Tutorial)
+set_tests_properties(Usage
+ PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number"
+ )
+
+# define a function to simplify adding tests
+function(do_test target arg result)
+ add_test(NAME Comp${arg} COMMAND ${target} ${arg})
+ set_tests_properties(Comp${arg}
+ PROPERTIES PASS_REGULAR_EXPRESSION ${result}
+ )
+endfunction(do_test)
+
+# do a bunch of result based tests
+do_test(Tutorial 4 "4 is 2")
+do_test(Tutorial 9 "9 is 3")
+do_test(Tutorial 5 "5 is 2.236")
+do_test(Tutorial 7 "7 is 2.645")
+do_test(Tutorial 25 "25 is 5")
+do_test(Tutorial -25 "-25 is [-nan|nan|0]")
+do_test(Tutorial 0.0001 "0.0001 is 0.01")
+
+include(InstallRequiredSystemLibraries)
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
+set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}")
+include(CPack)
+
+# install the configuration targets
+install(EXPORT MathFunctionsTargets
+ FILE MathFunctionsTargets.cmake
+ DESTINATION lib/cmake/MathFunctions
+)
+
+include(CMakePackageConfigHelpers)
+# generate the config file that is includes the exports
+configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
+ "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake"
+ INSTALL_DESTINATION "lib/cmake/example"
+ NO_SET_AND_CHECK_MACRO
+ NO_CHECK_REQUIRED_COMPONENTS_MACRO
+ )
+# generate the version file for the config file
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake"
+ VERSION "${Tutorial_VERSION_MAJOR}.${Tutorial_VERSION_MINOR}"
+ COMPATIBILITY AnyNewerVersion
+)
+
+# install the configuration file
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake
+ DESTINATION lib/cmake/MathFunctions
+ )
+
+# generate the export targets for the build tree
+# needs to be after the install(TARGETS ) command
+export(EXPORT MathFunctionsTargets
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsTargets.cmake"
+)
diff --git a/Help/guide/tutorial/Complete/CTestConfig.cmake b/Help/guide/tutorial/Complete/CTestConfig.cmake
new file mode 100644
index 000000000..73efdb1f6
--- /dev/null
+++ b/Help/guide/tutorial/Complete/CTestConfig.cmake
@@ -0,0 +1,7 @@
+set(CTEST_PROJECT_NAME "CMakeTutorial")
+set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
+
+set(CTEST_DROP_METHOD "http")
+set(CTEST_DROP_SITE "my.cdash.org")
+set(CTEST_DROP_LOCATION "/submit.php?project=CMakeTutorial")
+set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Help/guide/tutorial/Complete/Config.cmake.in b/Help/guide/tutorial/Complete/Config.cmake.in
new file mode 100644
index 000000000..17cbabd99
--- /dev/null
+++ b/Help/guide/tutorial/Complete/Config.cmake.in
@@ -0,0 +1,4 @@
+
+@PACKAGE_INIT@
+
+include ( "${CMAKE_CURRENT_LIST_DIR}/MathFunctionsTargets.cmake" )
diff --git a/Help/guide/tutorial/Complete/License.txt b/Help/guide/tutorial/Complete/License.txt
new file mode 100644
index 000000000..c62d00b9e
--- /dev/null
+++ b/Help/guide/tutorial/Complete/License.txt
@@ -0,0 +1,2 @@
+This is the open source License.txt file introduced in
+CMake/Tutorial/Step7...
diff --git a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
new file mode 100644
index 000000000..dfa84c941
--- /dev/null
+++ b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
@@ -0,0 +1,63 @@
+# add the library that runs
+add_library(MathFunctions MathFunctions.cxx)
+
+# state that anybody linking to us needs to include the current source dir
+# to find MathFunctions.h, while we don't.
+target_include_directories(MathFunctions
+ INTERFACE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ $<INSTALL_INTERFACE:include>
+ )
+
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+if(USE_MYMATH)
+
+ target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
+
+ # first we add the executable that generates the table
+ add_executable(MakeTable MakeTable.cxx)
+ target_link_libraries(MakeTable tutorial_compiler_flags)
+
+ # add the command to generate the source code
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ DEPENDS MakeTable
+ )
+
+ # library that just does sqrt
+ add_library(SqrtLibrary STATIC
+ mysqrt.cxx
+ ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ )
+
+ # state that we depend on our binary dir to find Table.h
+ target_include_directories(SqrtLibrary PRIVATE
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+ # state that SqrtLibrary need PIC when the default is shared libraries
+ set_target_properties(SqrtLibrary PROPERTIES
+ POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
+ )
+
+ target_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags)
+ target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
+endif()
+
+target_link_libraries(MathFunctions PUBLIC tutorial_compiler_flags)
+
+# define the symbol stating we are using the declspec(dllexport) when
+# building on windows
+target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
+
+# setup the version numbering
+set_property(TARGET MathFunctions PROPERTY VERSION "1.0.0")
+set_property(TARGET MathFunctions PROPERTY SOVERSION "1")
+
+# install rules
+install(TARGETS MathFunctions tutorial_compiler_flags
+ DESTINATION lib
+ EXPORT MathFunctionsTargets)
+install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Complete/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Complete/MathFunctions/MakeTable.cxx
new file mode 100644
index 000000000..ee585568c
--- /dev/null
+++ b/Help/guide/tutorial/Complete/MathFunctions/MakeTable.cxx
@@ -0,0 +1,25 @@
+// A simple program that builds a sqrt table
+#include <cmath>
+#include <fstream>
+#include <iostream>
+
+int main(int argc, char* argv[])
+{
+ // make sure we have enough arguments
+ if (argc < 2) {
+ return 1;
+ }
+
+ std::ofstream fout(argv[1], std::ios_base::out);
+ const bool fileOpen = fout.is_open();
+ if (fileOpen) {
+ fout << "double sqrtTable[] = {" << std::endl;
+ for (int i = 0; i < 10; ++i) {
+ fout << sqrt(static_cast<double>(i)) << "," << std::endl;
+ }
+ // close the table with a zero
+ fout << "0};" << std::endl;
+ fout.close();
+ }
+ return fileOpen ? 0 : 1; // return 0 if wrote the file
+}
diff --git a/Help/guide/tutorial/Complete/MathFunctions/MathFunctions.cxx b/Help/guide/tutorial/Complete/MathFunctions/MathFunctions.cxx
new file mode 100644
index 000000000..014530062
--- /dev/null
+++ b/Help/guide/tutorial/Complete/MathFunctions/MathFunctions.cxx
@@ -0,0 +1,19 @@
+
+#include "MathFunctions.h"
+
+#include <cmath>
+
+#ifdef USE_MYMATH
+# include "mysqrt.h"
+#endif
+
+namespace mathfunctions {
+double sqrt(double x)
+{
+#ifdef USE_MYMATH
+ return detail::mysqrt(x);
+#else
+ return std::sqrt(x);
+#endif
+}
+}
diff --git a/Help/guide/tutorial/Complete/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Complete/MathFunctions/MathFunctions.h
new file mode 100644
index 000000000..3fb547b4a
--- /dev/null
+++ b/Help/guide/tutorial/Complete/MathFunctions/MathFunctions.h
@@ -0,0 +1,14 @@
+
+#if defined(_WIN32)
+# if defined(EXPORTING_MYMATH)
+# define DECLSPEC __declspec(dllexport)
+# else
+# define DECLSPEC __declspec(dllimport)
+# endif
+#else // non windows
+# define DECLSPEC
+#endif
+
+namespace mathfunctions {
+double DECLSPEC sqrt(double x);
+}
diff --git a/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx
new file mode 100644
index 000000000..8153f18be
--- /dev/null
+++ b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx
@@ -0,0 +1,37 @@
+#include <iostream>
+
+#include "MathFunctions.h"
+
+// include the generated table
+#include "Table.h"
+
+namespace mathfunctions {
+namespace detail {
+// a hack square root calculation using simple operations
+double mysqrt(double x)
+{
+ if (x <= 0) {
+ return 0;
+ }
+
+ // use the table to help find an initial value
+ double result = x;
+ if (x >= 1 && x < 10) {
+ std::cout << "Use the table to help find an initial value " << std::endl;
+ result = sqrtTable[static_cast<int>(x)];
+ }
+
+ // do ten iterations
+ for (int i = 0; i < 10; ++i) {
+ if (result <= 0) {
+ result = 0.1;
+ }
+ double delta = x - (result * result);
+ result = result + 0.5 * delta / result;
+ std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
+ }
+
+ return result;
+}
+}
+}
diff --git a/Help/guide/tutorial/Complete/MathFunctions/mysqrt.h b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.h
new file mode 100644
index 000000000..e1c42ef0c
--- /dev/null
+++ b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.h
@@ -0,0 +1,6 @@
+
+namespace mathfunctions {
+namespace detail {
+double mysqrt(double x);
+}
+}
diff --git a/Help/guide/tutorial/Complete/TutorialConfig.h.in b/Help/guide/tutorial/Complete/TutorialConfig.h.in
new file mode 100644
index 000000000..7e4d7fa1f
--- /dev/null
+++ b/Help/guide/tutorial/Complete/TutorialConfig.h.in
@@ -0,0 +1,3 @@
+// the configured options and settings for Tutorial
+#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
+#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
diff --git a/Help/guide/tutorial/Complete/tutorial.cxx b/Help/guide/tutorial/Complete/tutorial.cxx
new file mode 100644
index 000000000..586d183a7
--- /dev/null
+++ b/Help/guide/tutorial/Complete/tutorial.cxx
@@ -0,0 +1,26 @@
+// A simple program that computes the square root of a number
+#include <iostream>
+#include <sstream>
+#include <string>
+
+#include "MathFunctions.h"
+#include "TutorialConfig.h"
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MINOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
+ return 1;
+ }
+
+ // convert input to double
+ const double inputValue = std::stod(argv[1]);
+
+ // calculate square root
+ const double outputValue = mathfunctions::sqrt(inputValue);
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
+ return 0;
+}
diff --git a/Help/guide/tutorial/Consumer/CMakeLists.txt b/Help/guide/tutorial/Consumer/CMakeLists.txt
new file mode 100644
index 000000000..a0e4598bc
--- /dev/null
+++ b/Help/guide/tutorial/Consumer/CMakeLists.txt
@@ -0,0 +1,51 @@
+cmake_minimum_required(VERSION 3.10)
+
+if(NOT DEFINED CMAKE_CXX_STANDARD)
+ set(CMAKE_CXX_STANDARD 11)
+ set(CMAKE_CXX_STANDARD_REQUIRED True)
+endif()
+
+
+function(find_external_dependency name)
+ set(${name}_ROOT "" CACHE PATH "Root directory to find ${name}")
+ mark_as_advanced(${name}_DIR)
+ find_package(${name} PATHS ${${name}_ROOT} REQUIRED)
+endfunction()
+
+
+project(Consumer)
+
+find_external_dependency(MathFunctions)
+
+add_library(consumer consumer.cxx)
+target_link_libraries(consumer PUBLIC MathFunctions)
+
+# install the consumer library
+install(TARGETS consumer DESTINATION bin EXPORT ConsumerTargets)
+
+# install the configuration targets
+install(EXPORT ConsumerTargets
+ FILE ConsumerTargets.cmake
+ DESTINATION lib/cmake/Consumer
+)
+
+include(CMakePackageConfigHelpers)
+# generate the config file that is includes the exports
+configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
+ "${CMAKE_CURRENT_BINARY_DIR}/ConsumerConfig.cmake"
+ INSTALL_DESTINATION "lib/cmake/example"
+ NO_SET_AND_CHECK_MACRO
+ NO_CHECK_REQUIRED_COMPONENTS_MACRO
+ )
+
+# install the configuration file
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/ConsumerConfig.cmake
+ DESTINATION lib/cmake/Consumer
+ )
+
+# generate the export targets for the build tree
+# needs to be after the install(TARGETS ) command
+export(EXPORT ConsumerTargets
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/ConsumerTargets.cmake"
+)
diff --git a/Help/guide/tutorial/Consumer/Config.cmake.in b/Help/guide/tutorial/Consumer/Config.cmake.in
new file mode 100644
index 000000000..0b3f1e4ef
--- /dev/null
+++ b/Help/guide/tutorial/Consumer/Config.cmake.in
@@ -0,0 +1,14 @@
+
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+
+function(find_external_dependency name)
+ set(${name}_ROOT "" CACHE PATH "Root directory to find ${name}")
+ mark_as_advanced(${name}_DIR)
+ find_dependency(${name} PATHS ${${name}_ROOT} REQUIRED)
+endfunction()
+
+find_external_dependency(MathFunctions)
+
+include ( "${CMAKE_CURRENT_LIST_DIR}/ConsumerTargets.cmake" )
diff --git a/Help/guide/tutorial/Consumer/consumer.cxx b/Help/guide/tutorial/Consumer/consumer.cxx
new file mode 100644
index 000000000..ae7877b5a
--- /dev/null
+++ b/Help/guide/tutorial/Consumer/consumer.cxx
@@ -0,0 +1,11 @@
+// A simple function that computes the square root of a number
+#include <iostream>
+#include <sstream>
+#include <string>
+
+#include "MathFunctions.h"
+
+double string_square_root(std::string const& value)
+{
+ return mathfunctions::sqrt(std::stod(value));
+}
diff --git a/Help/guide/tutorial/MultiPackage/CMakeLists.txt b/Help/guide/tutorial/MultiPackage/CMakeLists.txt
new file mode 100644
index 000000000..01d417ad4
--- /dev/null
+++ b/Help/guide/tutorial/MultiPackage/CMakeLists.txt
@@ -0,0 +1,112 @@
+cmake_minimum_required(VERSION 3.10)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
+
+
+# control where the static and shared libraries are built so that on windows
+# we don't need to tinker with the path to run the executable
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+
+option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
+
+if(APPLE)
+ set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
+elseif(UNIX)
+ set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
+endif()
+
+# configure a header file to pass the version number only
+configure_file(TutorialConfig.h.in TutorialConfig.h)
+
+# add the MathFunctions library
+add_subdirectory(MathFunctions)
+
+# add the executable
+add_executable(Tutorial tutorial.cxx)
+target_link_libraries(Tutorial PUBLIC MathFunctions)
+
+# add the binary tree to the search path for include files
+# so that we will find TutorialConfig.h
+target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ )
+
+# add the install targets
+install(TARGETS Tutorial DESTINATION bin)
+install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
+ DESTINATION include
+ )
+
+# enable testing
+enable_testing()
+
+# does the application run
+add_test(NAME Runs COMMAND Tutorial 25)
+
+# does the usage message work?
+add_test(NAME Usage COMMAND Tutorial)
+set_tests_properties(Usage
+ PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number"
+ )
+
+# define a function to simplify adding tests
+function(do_test target arg result)
+ add_test(NAME Comp${arg} COMMAND ${target} ${arg})
+ set_tests_properties(Comp${arg}
+ PROPERTIES PASS_REGULAR_EXPRESSION ${result}
+ )
+endfunction(do_test)
+
+# do a bunch of result based tests
+do_test(Tutorial 4 "4 is 2")
+do_test(Tutorial 9 "9 is 3")
+do_test(Tutorial 5 "5 is 2.236")
+do_test(Tutorial 7 "7 is 2.645")
+do_test(Tutorial 25 "25 is 5")
+do_test(Tutorial -25 "-25 is [-nan|nan|0]")
+do_test(Tutorial 0.0001 "0.0001 is 0.01")
+
+include(InstallRequiredSystemLibraries)
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
+set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}")
+include(CPack)
+
+# install the configuration targets
+install(EXPORT MathFunctionsTargets
+ FILE MathFunctionsTargets.cmake
+ DESTINATION lib/cmake/MathFunctions
+)
+
+include(CMakePackageConfigHelpers)
+# generate the config file that is includes the exports
+configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
+ "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake"
+ INSTALL_DESTINATION "lib/cmake/example"
+ NO_SET_AND_CHECK_MACRO
+ NO_CHECK_REQUIRED_COMPONENTS_MACRO
+ )
+# generate the version file for the config file
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake"
+ VERSION "${Tutorial_VERSION_MAJOR}.${Tutorial_VERSION_MINOR}"
+ COMPATIBILITY AnyNewerVersion
+)
+
+# install the configuration file
+install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake
+ DESTINATION lib/cmake/MathFunctions
+ )
+
+# generate the export targets for the build tree
+# needs to be after the install(TARGETS ) command
+export(EXPORT MathFunctionsTargets
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsTargets.cmake"
+)
diff --git a/Help/guide/tutorial/MultiPackage/Config.cmake.in b/Help/guide/tutorial/MultiPackage/Config.cmake.in
new file mode 100644
index 000000000..17cbabd99
--- /dev/null
+++ b/Help/guide/tutorial/MultiPackage/Config.cmake.in
@@ -0,0 +1,4 @@
+
+@PACKAGE_INIT@
+
+include ( "${CMAKE_CURRENT_LIST_DIR}/MathFunctionsTargets.cmake" )
diff --git a/Help/guide/tutorial/MultiPackage/License.txt b/Help/guide/tutorial/MultiPackage/License.txt
new file mode 100644
index 000000000..c62d00b9e
--- /dev/null
+++ b/Help/guide/tutorial/MultiPackage/License.txt
@@ -0,0 +1,2 @@
+This is the open source License.txt file introduced in
+CMake/Tutorial/Step7...
diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt
new file mode 100644
index 000000000..a2df2a732
--- /dev/null
+++ b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt
@@ -0,0 +1,59 @@
+# add the library that runs
+add_library(MathFunctions MathFunctions.cxx)
+
+# state that anybody linking to us needs to include the current source dir
+# to find MathFunctions.h, while we don't.
+target_include_directories(MathFunctions
+ INTERFACE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ $<INSTALL_INTERFACE:include>
+ )
+
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+if(USE_MYMATH)
+
+ target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
+
+ # first we add the executable that generates the table
+ add_executable(MakeTable MakeTable.cxx)
+
+ # add the command to generate the source code
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ DEPENDS MakeTable
+ )
+
+ # library that just does sqrt
+ add_library(SqrtLibrary STATIC
+ mysqrt.cxx
+ ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ )
+
+ # state that we depend on our binary dir to find Table.h
+ target_include_directories(SqrtLibrary PRIVATE
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+ # state that SqrtLibrary need PIC when the default is shared libraries
+ set_target_properties(SqrtLibrary PROPERTIES
+ POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
+ )
+
+ target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
+endif()
+
+# define the symbol stating we are using the declspec(dllexport) when
+# building on windows
+target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
+
+# setup the version numbering
+set_property(TARGET MathFunctions PROPERTY VERSION "1.0.0")
+set_property(TARGET MathFunctions PROPERTY SOVERSION "1")
+
+# install rules
+install(TARGETS MathFunctions
+ DESTINATION lib
+ EXPORT MathFunctionsTargets)
+install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/MultiPackage/MathFunctions/MakeTable.cxx
new file mode 100644
index 000000000..ee585568c
--- /dev/null
+++ b/Help/guide/tutorial/MultiPackage/MathFunctions/MakeTable.cxx
@@ -0,0 +1,25 @@
+// A simple program that builds a sqrt table
+#include <cmath>
+#include <fstream>
+#include <iostream>
+
+int main(int argc, char* argv[])
+{
+ // make sure we have enough arguments
+ if (argc < 2) {
+ return 1;
+ }
+
+ std::ofstream fout(argv[1], std::ios_base::out);
+ const bool fileOpen = fout.is_open();
+ if (fileOpen) {
+ fout << "double sqrtTable[] = {" << std::endl;
+ for (int i = 0; i < 10; ++i) {
+ fout << sqrt(static_cast<double>(i)) << "," << std::endl;
+ }
+ // close the table with a zero
+ fout << "0};" << std::endl;
+ fout.close();
+ }
+ return fileOpen ? 0 : 1; // return 0 if wrote the file
+}
diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.cxx b/Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.cxx
new file mode 100644
index 000000000..014530062
--- /dev/null
+++ b/Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.cxx
@@ -0,0 +1,19 @@
+
+#include "MathFunctions.h"
+
+#include <cmath>
+
+#ifdef USE_MYMATH
+# include "mysqrt.h"
+#endif
+
+namespace mathfunctions {
+double sqrt(double x)
+{
+#ifdef USE_MYMATH
+ return detail::mysqrt(x);
+#else
+ return std::sqrt(x);
+#endif
+}
+}
diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.h b/Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.h
new file mode 100644
index 000000000..3fb547b4a
--- /dev/null
+++ b/Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.h
@@ -0,0 +1,14 @@
+
+#if defined(_WIN32)
+# if defined(EXPORTING_MYMATH)
+# define DECLSPEC __declspec(dllexport)
+# else
+# define DECLSPEC __declspec(dllimport)
+# endif
+#else // non windows
+# define DECLSPEC
+#endif
+
+namespace mathfunctions {
+double DECLSPEC sqrt(double x);
+}
diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx
new file mode 100644
index 000000000..5e622beb5
--- /dev/null
+++ b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx
@@ -0,0 +1,38 @@
+#include <iostream>
+
+#include "MathFunctions.h"
+
+// include the generated table
+#include "Table.h"
+
+namespace mathfunctions {
+namespace detail {
+// a hack square root calculation using simple operations
+double mysqrt(double x)
+{
+ if (x <= 0) {
+ return 0;
+ }
+
+ // use the table to help find an initial value
+ double result = x;
+ if (x >= 1 && x < 10) {
+ result = sqrtTable[static_cast<int>(x)];
+ }
+
+ // if we have both log and exp then use them
+
+ // do ten iterations
+ for (int i = 0; i < 10; ++i) {
+ if (result <= 0) {
+ result = 0.1;
+ }
+ double delta = x - (result * result);
+ result = result + 0.5 * delta / result;
+ std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
+ }
+
+ return result;
+}
+}
+}
diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.h b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.h
new file mode 100644
index 000000000..e1c42ef0c
--- /dev/null
+++ b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.h
@@ -0,0 +1,6 @@
+
+namespace mathfunctions {
+namespace detail {
+double mysqrt(double x);
+}
+}
diff --git a/Help/guide/tutorial/MultiPackage/MultiCPackConfig.cmake b/Help/guide/tutorial/MultiPackage/MultiCPackConfig.cmake
new file mode 100644
index 000000000..403b633e1
--- /dev/null
+++ b/Help/guide/tutorial/MultiPackage/MultiCPackConfig.cmake
@@ -0,0 +1,7 @@
+
+include("release/CPackConfig.cmake")
+
+set(CPACK_INSTALL_CMAKE_PROJECTS
+ "debug;Tutorial;ALL;/"
+ "release;Tutorial;ALL;/"
+ )
diff --git a/Help/guide/tutorial/MultiPackage/TutorialConfig.h.in b/Help/guide/tutorial/MultiPackage/TutorialConfig.h.in
new file mode 100644
index 000000000..8cd2fc9c6
--- /dev/null
+++ b/Help/guide/tutorial/MultiPackage/TutorialConfig.h.in
@@ -0,0 +1,3 @@
+// the configured version number
+#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
+#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
diff --git a/Help/guide/tutorial/MultiPackage/tutorial.cxx b/Help/guide/tutorial/MultiPackage/tutorial.cxx
new file mode 100644
index 000000000..f97805b1c
--- /dev/null
+++ b/Help/guide/tutorial/MultiPackage/tutorial.cxx
@@ -0,0 +1,25 @@
+// A simple program that computes the square root of a number
+#include <iostream>
+#include <string>
+
+#include "MathFunctions.h"
+#include "TutorialConfig.h"
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MINOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
+ return 1;
+ }
+
+ // convert input to double
+ double inputValue = std::stod(argv[1]);
+
+ const double outputValue = mathfunctions::sqrt(inputValue);
+
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
+ return 0;
+}
diff --git a/Help/guide/tutorial/Step1/tutorial.cxx b/Help/guide/tutorial/Step1/tutorial.cxx
new file mode 100644
index 000000000..08323bfac
--- /dev/null
+++ b/Help/guide/tutorial/Step1/tutorial.cxx
@@ -0,0 +1,22 @@
+// A simple program that computes the square root of a number
+#include <cmath>
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
+ return 1;
+ }
+
+ // convert input to double
+ const double inputValue = atof(argv[1]);
+
+ // calculate square root
+ const double outputValue = sqrt(inputValue);
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
+ return 0;
+}
diff --git a/Help/guide/tutorial/Step10/CMakeLists.txt b/Help/guide/tutorial/Step10/CMakeLists.txt
new file mode 100644
index 000000000..34ae70c27
--- /dev/null
+++ b/Help/guide/tutorial/Step10/CMakeLists.txt
@@ -0,0 +1,73 @@
+cmake_minimum_required(VERSION 3.10)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
+
+# control where the static and shared libraries are built so that on windows
+# we don't need to tinker with the path to run the executable
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+
+option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
+
+# configure a header file to pass the version number only
+configure_file(TutorialConfig.h.in TutorialConfig.h)
+
+# add the MathFunctions library
+add_subdirectory(MathFunctions)
+
+# add the executable
+add_executable(Tutorial tutorial.cxx)
+target_link_libraries(Tutorial PUBLIC MathFunctions)
+
+# add the binary tree to the search path for include files
+# so that we will find TutorialConfig.h
+target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ )
+
+# add the install targets
+install(TARGETS Tutorial DESTINATION bin)
+install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
+ DESTINATION include
+ )
+
+# enable testing
+include(CTest)
+
+# does the application run
+add_test(NAME Runs COMMAND Tutorial 25)
+
+# does the usage message work?
+add_test(NAME Usage COMMAND Tutorial)
+set_tests_properties(Usage
+ PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number"
+ )
+
+# define a function to simplify adding tests
+function(do_test target arg result)
+ add_test(NAME Comp${arg} COMMAND ${target} ${arg})
+ set_tests_properties(Comp${arg}
+ PROPERTIES PASS_REGULAR_EXPRESSION ${result}
+ )
+endfunction(do_test)
+
+# do a bunch of result based tests
+do_test(Tutorial 4 "4 is 2")
+do_test(Tutorial 9 "9 is 3")
+do_test(Tutorial 5 "5 is 2.236")
+do_test(Tutorial 7 "7 is 2.645")
+do_test(Tutorial 25 "25 is 5")
+do_test(Tutorial -25 "-25 is [-nan|nan|0]")
+do_test(Tutorial 0.0001 "0.0001 is 0.01")
+
+include(InstallRequiredSystemLibraries)
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
+set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}")
+include(CPack)
diff --git a/Help/guide/tutorial/Step10/CTestConfig.cmake b/Help/guide/tutorial/Step10/CTestConfig.cmake
new file mode 100644
index 000000000..73efdb1f6
--- /dev/null
+++ b/Help/guide/tutorial/Step10/CTestConfig.cmake
@@ -0,0 +1,7 @@
+set(CTEST_PROJECT_NAME "CMakeTutorial")
+set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
+
+set(CTEST_DROP_METHOD "http")
+set(CTEST_DROP_SITE "my.cdash.org")
+set(CTEST_DROP_LOCATION "/submit.php?project=CMakeTutorial")
+set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Help/guide/tutorial/Step10/License.txt b/Help/guide/tutorial/Step10/License.txt
new file mode 100644
index 000000000..c62d00b9e
--- /dev/null
+++ b/Help/guide/tutorial/Step10/License.txt
@@ -0,0 +1,2 @@
+This is the open source License.txt file introduced in
+CMake/Tutorial/Step7...
diff --git a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
new file mode 100644
index 000000000..e0c06214c
--- /dev/null
+++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
@@ -0,0 +1,51 @@
+# add the library that runs
+add_library(MathFunctions MathFunctions.cxx)
+
+# state that anybody linking to us needs to include the current source dir
+# to find MathFunctions.h, while we don't.
+target_include_directories(MathFunctions
+ INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+if(USE_MYMATH)
+
+ target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
+
+ # first we add the executable that generates the table
+ add_executable(MakeTable MakeTable.cxx)
+
+ # add the command to generate the source code
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ DEPENDS MakeTable
+ )
+
+ # library that just does sqrt
+ add_library(SqrtLibrary STATIC
+ mysqrt.cxx
+ ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ )
+
+ # state that we depend on our binary dir to find Table.h
+ target_include_directories(SqrtLibrary PRIVATE
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+ # state that SqrtLibrary need PIC when the default is shared libraries
+ set_target_properties(SqrtLibrary PROPERTIES
+ POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
+ )
+
+ target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
+endif()
+
+# define the symbol stating we are using the declspec(dllexport) when
+# building on windows
+target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
+
+# install rules
+install(TARGETS MathFunctions DESTINATION lib)
+install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step10/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step10/MathFunctions/MakeTable.cxx
new file mode 100644
index 000000000..ee585568c
--- /dev/null
+++ b/Help/guide/tutorial/Step10/MathFunctions/MakeTable.cxx
@@ -0,0 +1,25 @@
+// A simple program that builds a sqrt table
+#include <cmath>
+#include <fstream>
+#include <iostream>
+
+int main(int argc, char* argv[])
+{
+ // make sure we have enough arguments
+ if (argc < 2) {
+ return 1;
+ }
+
+ std::ofstream fout(argv[1], std::ios_base::out);
+ const bool fileOpen = fout.is_open();
+ if (fileOpen) {
+ fout << "double sqrtTable[] = {" << std::endl;
+ for (int i = 0; i < 10; ++i) {
+ fout << sqrt(static_cast<double>(i)) << "," << std::endl;
+ }
+ // close the table with a zero
+ fout << "0};" << std::endl;
+ fout.close();
+ }
+ return fileOpen ? 0 : 1; // return 0 if wrote the file
+}
diff --git a/Help/guide/tutorial/Step10/MathFunctions/MathFunctions.cxx b/Help/guide/tutorial/Step10/MathFunctions/MathFunctions.cxx
new file mode 100644
index 000000000..014530062
--- /dev/null
+++ b/Help/guide/tutorial/Step10/MathFunctions/MathFunctions.cxx
@@ -0,0 +1,19 @@
+
+#include "MathFunctions.h"
+
+#include <cmath>
+
+#ifdef USE_MYMATH
+# include "mysqrt.h"
+#endif
+
+namespace mathfunctions {
+double sqrt(double x)
+{
+#ifdef USE_MYMATH
+ return detail::mysqrt(x);
+#else
+ return std::sqrt(x);
+#endif
+}
+}
diff --git a/Help/guide/tutorial/Step10/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step10/MathFunctions/MathFunctions.h
new file mode 100644
index 000000000..3fb547b4a
--- /dev/null
+++ b/Help/guide/tutorial/Step10/MathFunctions/MathFunctions.h
@@ -0,0 +1,14 @@
+
+#if defined(_WIN32)
+# if defined(EXPORTING_MYMATH)
+# define DECLSPEC __declspec(dllexport)
+# else
+# define DECLSPEC __declspec(dllimport)
+# endif
+#else // non windows
+# define DECLSPEC
+#endif
+
+namespace mathfunctions {
+double DECLSPEC sqrt(double x);
+}
diff --git a/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx
new file mode 100644
index 000000000..8153f18be
--- /dev/null
+++ b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx
@@ -0,0 +1,37 @@
+#include <iostream>
+
+#include "MathFunctions.h"
+
+// include the generated table
+#include "Table.h"
+
+namespace mathfunctions {
+namespace detail {
+// a hack square root calculation using simple operations
+double mysqrt(double x)
+{
+ if (x <= 0) {
+ return 0;
+ }
+
+ // use the table to help find an initial value
+ double result = x;
+ if (x >= 1 && x < 10) {
+ std::cout << "Use the table to help find an initial value " << std::endl;
+ result = sqrtTable[static_cast<int>(x)];
+ }
+
+ // do ten iterations
+ for (int i = 0; i < 10; ++i) {
+ if (result <= 0) {
+ result = 0.1;
+ }
+ double delta = x - (result * result);
+ result = result + 0.5 * delta / result;
+ std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
+ }
+
+ return result;
+}
+}
+}
diff --git a/Help/guide/tutorial/Step10/MathFunctions/mysqrt.h b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.h
new file mode 100644
index 000000000..e1c42ef0c
--- /dev/null
+++ b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.h
@@ -0,0 +1,6 @@
+
+namespace mathfunctions {
+namespace detail {
+double mysqrt(double x);
+}
+}
diff --git a/Help/guide/tutorial/Step10/TutorialConfig.h.in b/Help/guide/tutorial/Step10/TutorialConfig.h.in
new file mode 100644
index 000000000..7e4d7fa1f
--- /dev/null
+++ b/Help/guide/tutorial/Step10/TutorialConfig.h.in
@@ -0,0 +1,3 @@
+// the configured options and settings for Tutorial
+#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
+#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
diff --git a/Help/guide/tutorial/Step10/tutorial.cxx b/Help/guide/tutorial/Step10/tutorial.cxx
new file mode 100644
index 000000000..37a03336c
--- /dev/null
+++ b/Help/guide/tutorial/Step10/tutorial.cxx
@@ -0,0 +1,27 @@
+// A simple program that computes the square root of a number
+#include <iostream>
+#include <sstream>
+#include <string>
+
+#include "MathFunctions.h"
+#include "TutorialConfig.h"
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ // report version
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MINOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
+ return 1;
+ }
+
+ // convert input to double
+ const double inputValue = std::stod(argv[1]);
+
+ const double outputValue = mathfunctions::sqrt(inputValue);
+
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
+ return 0;
+}
diff --git a/Help/guide/tutorial/Step11/CMakeLists.txt b/Help/guide/tutorial/Step11/CMakeLists.txt
new file mode 100644
index 000000000..4763951c7
--- /dev/null
+++ b/Help/guide/tutorial/Step11/CMakeLists.txt
@@ -0,0 +1,81 @@
+cmake_minimum_required(VERSION 3.15)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+add_library(tutorial_compiler_flags INTERFACE)
+target_compile_features(tutorial_compiler_flags INTERFACE cxx_std_11)
+
+# add compiler warning flags just when building this project via
+# the BUILD_INTERFACE genex
+set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU>")
+set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>")
+target_compile_options(tutorial_compiler_flags INTERFACE
+ "$<${gcc_like_cxx}:$<BUILD_INTERFACE:-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused>>"
+ "$<${msvc_cxx}:$<BUILD_INTERFACE:-W3>>"
+)
+
+# control where the static and shared libraries are built so that on windows
+# we don't need to tinker with the path to run the executable
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
+
+option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
+
+# configure a header file to pass the version number only
+configure_file(TutorialConfig.h.in TutorialConfig.h)
+
+# add the MathFunctions library
+add_subdirectory(MathFunctions)
+
+# add the executable
+add_executable(Tutorial tutorial.cxx)
+target_link_libraries(Tutorial PUBLIC MathFunctions)
+
+# add the binary tree to the search path for include files
+# so that we will find TutorialConfig.h
+target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ )
+
+# add the install targets
+install(TARGETS Tutorial DESTINATION bin)
+install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
+ DESTINATION include
+ )
+
+# enable testing
+enable_testing()
+
+# does the application run
+add_test(NAME Runs COMMAND Tutorial 25)
+
+# does the usage message work?
+add_test(NAME Usage COMMAND Tutorial)
+set_tests_properties(Usage
+ PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number"
+ )
+
+# define a function to simplify adding tests
+function(do_test target arg result)
+ add_test(NAME Comp${arg} COMMAND ${target} ${arg})
+ set_tests_properties(Comp${arg}
+ PROPERTIES PASS_REGULAR_EXPRESSION ${result}
+ )
+endfunction(do_test)
+
+# do a bunch of result based tests
+do_test(Tutorial 4 "4 is 2")
+do_test(Tutorial 9 "9 is 3")
+do_test(Tutorial 5 "5 is 2.236")
+do_test(Tutorial 7 "7 is 2.645")
+do_test(Tutorial 25 "25 is 5")
+do_test(Tutorial -25 "-25 is [-nan|nan|0]")
+do_test(Tutorial 0.0001 "0.0001 is 0.01")
+
+include(InstallRequiredSystemLibraries)
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
+set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}")
+include(CPack)
diff --git a/Help/guide/tutorial/Step11/CTestConfig.cmake b/Help/guide/tutorial/Step11/CTestConfig.cmake
new file mode 100644
index 000000000..73efdb1f6
--- /dev/null
+++ b/Help/guide/tutorial/Step11/CTestConfig.cmake
@@ -0,0 +1,7 @@
+set(CTEST_PROJECT_NAME "CMakeTutorial")
+set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
+
+set(CTEST_DROP_METHOD "http")
+set(CTEST_DROP_SITE "my.cdash.org")
+set(CTEST_DROP_LOCATION "/submit.php?project=CMakeTutorial")
+set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Help/guide/tutorial/Step11/License.txt b/Help/guide/tutorial/Step11/License.txt
new file mode 100644
index 000000000..c62d00b9e
--- /dev/null
+++ b/Help/guide/tutorial/Step11/License.txt
@@ -0,0 +1,2 @@
+This is the open source License.txt file introduced in
+CMake/Tutorial/Step7...
diff --git a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
new file mode 100644
index 000000000..e6cb8baca
--- /dev/null
+++ b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
@@ -0,0 +1,55 @@
+# add the library that runs
+add_library(MathFunctions MathFunctions.cxx)
+
+# state that anybody linking to us needs to include the current source dir
+# to find MathFunctions.h, while we don't.
+target_include_directories(MathFunctions
+ INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+if(USE_MYMATH)
+
+ target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
+
+ # first we add the executable that generates the table
+ add_executable(MakeTable MakeTable.cxx)
+ target_link_libraries(MakeTable tutorial_compiler_flags)
+
+ # add the command to generate the source code
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ DEPENDS MakeTable
+ )
+
+ # library that just does sqrt
+ add_library(SqrtLibrary STATIC
+ mysqrt.cxx
+ ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ )
+
+ # state that we depend on our binary dir to find Table.h
+ target_include_directories(SqrtLibrary PRIVATE
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+ # state that SqrtLibrary need PIC when the default is shared libraries
+ set_target_properties(SqrtLibrary PROPERTIES
+ POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
+ )
+
+ target_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags)
+ target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
+endif()
+
+target_link_libraries(MathFunctions PUBLIC tutorial_compiler_flags)
+
+# define the symbol stating we are using the declspec(dllexport) when
+#building on windows
+target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
+
+# install rules
+install(TARGETS MathFunctions DESTINATION lib)
+install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step11/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step11/MathFunctions/MakeTable.cxx
new file mode 100644
index 000000000..ee585568c
--- /dev/null
+++ b/Help/guide/tutorial/Step11/MathFunctions/MakeTable.cxx
@@ -0,0 +1,25 @@
+// A simple program that builds a sqrt table
+#include <cmath>
+#include <fstream>
+#include <iostream>
+
+int main(int argc, char* argv[])
+{
+ // make sure we have enough arguments
+ if (argc < 2) {
+ return 1;
+ }
+
+ std::ofstream fout(argv[1], std::ios_base::out);
+ const bool fileOpen = fout.is_open();
+ if (fileOpen) {
+ fout << "double sqrtTable[] = {" << std::endl;
+ for (int i = 0; i < 10; ++i) {
+ fout << sqrt(static_cast<double>(i)) << "," << std::endl;
+ }
+ // close the table with a zero
+ fout << "0};" << std::endl;
+ fout.close();
+ }
+ return fileOpen ? 0 : 1; // return 0 if wrote the file
+}
diff --git a/Help/guide/tutorial/Step11/MathFunctions/MathFunctions.cxx b/Help/guide/tutorial/Step11/MathFunctions/MathFunctions.cxx
new file mode 100644
index 000000000..014530062
--- /dev/null
+++ b/Help/guide/tutorial/Step11/MathFunctions/MathFunctions.cxx
@@ -0,0 +1,19 @@
+
+#include "MathFunctions.h"
+
+#include <cmath>
+
+#ifdef USE_MYMATH
+# include "mysqrt.h"
+#endif
+
+namespace mathfunctions {
+double sqrt(double x)
+{
+#ifdef USE_MYMATH
+ return detail::mysqrt(x);
+#else
+ return std::sqrt(x);
+#endif
+}
+}
diff --git a/Help/guide/tutorial/Step11/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step11/MathFunctions/MathFunctions.h
new file mode 100644
index 000000000..3fb547b4a
--- /dev/null
+++ b/Help/guide/tutorial/Step11/MathFunctions/MathFunctions.h
@@ -0,0 +1,14 @@
+
+#if defined(_WIN32)
+# if defined(EXPORTING_MYMATH)
+# define DECLSPEC __declspec(dllexport)
+# else
+# define DECLSPEC __declspec(dllimport)
+# endif
+#else // non windows
+# define DECLSPEC
+#endif
+
+namespace mathfunctions {
+double DECLSPEC sqrt(double x);
+}
diff --git a/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx
new file mode 100644
index 000000000..8153f18be
--- /dev/null
+++ b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx
@@ -0,0 +1,37 @@
+#include <iostream>
+
+#include "MathFunctions.h"
+
+// include the generated table
+#include "Table.h"
+
+namespace mathfunctions {
+namespace detail {
+// a hack square root calculation using simple operations
+double mysqrt(double x)
+{
+ if (x <= 0) {
+ return 0;
+ }
+
+ // use the table to help find an initial value
+ double result = x;
+ if (x >= 1 && x < 10) {
+ std::cout << "Use the table to help find an initial value " << std::endl;
+ result = sqrtTable[static_cast<int>(x)];
+ }
+
+ // do ten iterations
+ for (int i = 0; i < 10; ++i) {
+ if (result <= 0) {
+ result = 0.1;
+ }
+ double delta = x - (result * result);
+ result = result + 0.5 * delta / result;
+ std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
+ }
+
+ return result;
+}
+}
+}
diff --git a/Help/guide/tutorial/Step11/MathFunctions/mysqrt.h b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.h
new file mode 100644
index 000000000..e1c42ef0c
--- /dev/null
+++ b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.h
@@ -0,0 +1,6 @@
+
+namespace mathfunctions {
+namespace detail {
+double mysqrt(double x);
+}
+}
diff --git a/Help/guide/tutorial/Step11/TutorialConfig.h.in b/Help/guide/tutorial/Step11/TutorialConfig.h.in
new file mode 100644
index 000000000..7e4d7fa1f
--- /dev/null
+++ b/Help/guide/tutorial/Step11/TutorialConfig.h.in
@@ -0,0 +1,3 @@
+// the configured options and settings for Tutorial
+#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
+#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
diff --git a/Help/guide/tutorial/Step11/tutorial.cxx b/Help/guide/tutorial/Step11/tutorial.cxx
new file mode 100644
index 000000000..a4f44d54f
--- /dev/null
+++ b/Help/guide/tutorial/Step11/tutorial.cxx
@@ -0,0 +1,26 @@
+// A simple program that computes the square root of a number
+#include <iostream>
+#include <string>
+
+#include "MathFunctions.h"
+#include "TutorialConfig.h"
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ // report version
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MINOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
+ return 1;
+ }
+
+ // convert input to double
+ const double inputValue = std::stod(argv[1]);
+
+ const double outputValue = mathfunctions::sqrt(inputValue);
+
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
+ return 0;
+}
diff --git a/Help/guide/tutorial/Step2/CMakeLists.txt b/Help/guide/tutorial/Step2/CMakeLists.txt
new file mode 100644
index 000000000..7aa59e917
--- /dev/null
+++ b/Help/guide/tutorial/Step2/CMakeLists.txt
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 3.10)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
+
+# configure a header file to pass some of the CMake settings
+# to the source code
+configure_file(TutorialConfig.h.in TutorialConfig.h)
+
+# add the executable
+add_executable(Tutorial tutorial.cxx)
+
+# add the binary tree to the search path for include files
+# so that we will find TutorialConfig.h
+target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ )
diff --git a/Tests/Tutorial/Step2/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step2/MathFunctions/MathFunctions.h
index cd36bccff..cd36bccff 100644
--- a/Tests/Tutorial/Step2/MathFunctions/MathFunctions.h
+++ b/Help/guide/tutorial/Step2/MathFunctions/MathFunctions.h
diff --git a/Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx
new file mode 100644
index 000000000..1e4d97ae7
--- /dev/null
+++ b/Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx
@@ -0,0 +1,22 @@
+#include <iostream>
+
+// a hack square root calculation using simple operations
+double mysqrt(double x)
+{
+ if (x <= 0) {
+ return 0;
+ }
+
+ double result = x;
+
+ // do ten iterations
+ for (int i = 0; i < 10; ++i) {
+ if (result <= 0) {
+ result = 0.1;
+ }
+ double delta = x - (result * result);
+ result = result + 0.5 * delta / result;
+ std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
+ }
+ return result;
+}
diff --git a/Help/guide/tutorial/Step2/TutorialConfig.h.in b/Help/guide/tutorial/Step2/TutorialConfig.h.in
new file mode 100644
index 000000000..7e4d7fa1f
--- /dev/null
+++ b/Help/guide/tutorial/Step2/TutorialConfig.h.in
@@ -0,0 +1,3 @@
+// the configured options and settings for Tutorial
+#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
+#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
diff --git a/Help/guide/tutorial/Step2/tutorial.cxx b/Help/guide/tutorial/Step2/tutorial.cxx
new file mode 100644
index 000000000..53b081053
--- /dev/null
+++ b/Help/guide/tutorial/Step2/tutorial.cxx
@@ -0,0 +1,26 @@
+// A simple program that computes the square root of a number
+#include <cmath>
+#include <iostream>
+#include <string>
+
+#include "TutorialConfig.h"
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ // report version
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MINOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
+ return 1;
+ }
+
+ // convert input to double
+ const double inputValue = std::stod(argv[1]);
+
+ // calculate square root
+ const double outputValue = sqrt(inputValue);
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
+ return 0;
+}
diff --git a/Help/guide/tutorial/Step3/CMakeLists.txt b/Help/guide/tutorial/Step3/CMakeLists.txt
new file mode 100644
index 000000000..1c128165f
--- /dev/null
+++ b/Help/guide/tutorial/Step3/CMakeLists.txt
@@ -0,0 +1,34 @@
+cmake_minimum_required(VERSION 3.10)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
+
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+
+# configure a header file to pass some of the CMake settings
+# to the source code
+configure_file(TutorialConfig.h.in TutorialConfig.h)
+
+# add the MathFunctions library
+if(USE_MYMATH)
+ add_subdirectory(MathFunctions)
+ list(APPEND EXTRA_LIBS MathFunctions)
+ list(APPEND EXTRA_INCLUDES "${PROJECT_SOURCE_DIR}/MathFunctions")
+endif()
+
+# add the executable
+add_executable(Tutorial tutorial.cxx)
+
+target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS})
+
+# add the binary tree to the search path for include files
+# so that we will find TutorialConfig.h
+target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ ${EXTRA_INCLUDES}
+ )
diff --git a/Tests/Tutorial/Step2/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt
index 8b443a659..8b443a659 100644
--- a/Tests/Tutorial/Step2/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt
diff --git a/Tests/Tutorial/Step3/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step3/MathFunctions/MathFunctions.h
index cd36bccff..cd36bccff 100644
--- a/Tests/Tutorial/Step3/MathFunctions/MathFunctions.h
+++ b/Help/guide/tutorial/Step3/MathFunctions/MathFunctions.h
diff --git a/Help/guide/tutorial/Step3/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step3/MathFunctions/mysqrt.cxx
new file mode 100644
index 000000000..abe767d5a
--- /dev/null
+++ b/Help/guide/tutorial/Step3/MathFunctions/mysqrt.cxx
@@ -0,0 +1,24 @@
+#include <iostream>
+
+#include "MathFunctions.h"
+
+// a hack square root calculation using simple operations
+double mysqrt(double x)
+{
+ if (x <= 0) {
+ return 0;
+ }
+
+ double result = x;
+
+ // do ten iterations
+ for (int i = 0; i < 10; ++i) {
+ if (result <= 0) {
+ result = 0.1;
+ }
+ double delta = x - (result * result);
+ result = result + 0.5 * delta / result;
+ std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
+ }
+ return result;
+}
diff --git a/Help/guide/tutorial/Step3/TutorialConfig.h.in b/Help/guide/tutorial/Step3/TutorialConfig.h.in
new file mode 100644
index 000000000..e23f5213c
--- /dev/null
+++ b/Help/guide/tutorial/Step3/TutorialConfig.h.in
@@ -0,0 +1,4 @@
+// the configured options and settings for Tutorial
+#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
+#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
+#cmakedefine USE_MYMATH
diff --git a/Help/guide/tutorial/Step3/tutorial.cxx b/Help/guide/tutorial/Step3/tutorial.cxx
new file mode 100644
index 000000000..b3c6a4f43
--- /dev/null
+++ b/Help/guide/tutorial/Step3/tutorial.cxx
@@ -0,0 +1,36 @@
+// A simple program that computes the square root of a number
+#include <cmath>
+#include <iostream>
+#include <string>
+
+#include "TutorialConfig.h"
+
+// should we include the MathFunctions header?
+#ifdef USE_MYMATH
+# include "MathFunctions.h"
+#endif
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ // report version
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MINOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
+ return 1;
+ }
+
+ // convert input to double
+ const double inputValue = std::stod(argv[1]);
+
+ // which square root function should we use?
+#ifdef USE_MYMATH
+ const double outputValue = mysqrt(inputValue);
+#else
+ const double outputValue = sqrt(inputValue);
+#endif
+
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
+ return 0;
+}
diff --git a/Help/guide/tutorial/Step4/CMakeLists.txt b/Help/guide/tutorial/Step4/CMakeLists.txt
new file mode 100644
index 000000000..38e9b1f72
--- /dev/null
+++ b/Help/guide/tutorial/Step4/CMakeLists.txt
@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 3.10)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
+
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+
+# configure a header file to pass some of the CMake settings
+# to the source code
+configure_file(TutorialConfig.h.in TutorialConfig.h)
+
+# add the MathFunctions library
+if(USE_MYMATH)
+ add_subdirectory(MathFunctions)
+ list(APPEND EXTRA_LIBS MathFunctions)
+endif()
+
+# add the executable
+add_executable(Tutorial tutorial.cxx)
+
+target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS})
+
+# add the binary tree to the search path for include files
+# so that we will find TutorialConfig.h
+target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ )
diff --git a/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt
new file mode 100644
index 000000000..0515852a0
--- /dev/null
+++ b/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_library(MathFunctions mysqrt.cxx)
+
+# state that anybody linking to us needs to include the current source dir
+# to find MathFunctions.h, while we don't.
+target_include_directories(MathFunctions
+ INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+ )
diff --git a/Tests/Tutorial/Step4/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step4/MathFunctions/MathFunctions.h
index cd36bccff..cd36bccff 100644
--- a/Tests/Tutorial/Step4/MathFunctions/MathFunctions.h
+++ b/Help/guide/tutorial/Step4/MathFunctions/MathFunctions.h
diff --git a/Help/guide/tutorial/Step4/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step4/MathFunctions/mysqrt.cxx
new file mode 100644
index 000000000..abe767d5a
--- /dev/null
+++ b/Help/guide/tutorial/Step4/MathFunctions/mysqrt.cxx
@@ -0,0 +1,24 @@
+#include <iostream>
+
+#include "MathFunctions.h"
+
+// a hack square root calculation using simple operations
+double mysqrt(double x)
+{
+ if (x <= 0) {
+ return 0;
+ }
+
+ double result = x;
+
+ // do ten iterations
+ for (int i = 0; i < 10; ++i) {
+ if (result <= 0) {
+ result = 0.1;
+ }
+ double delta = x - (result * result);
+ result = result + 0.5 * delta / result;
+ std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
+ }
+ return result;
+}
diff --git a/Help/guide/tutorial/Step4/TutorialConfig.h.in b/Help/guide/tutorial/Step4/TutorialConfig.h.in
new file mode 100644
index 000000000..e23f5213c
--- /dev/null
+++ b/Help/guide/tutorial/Step4/TutorialConfig.h.in
@@ -0,0 +1,4 @@
+// the configured options and settings for Tutorial
+#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
+#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
+#cmakedefine USE_MYMATH
diff --git a/Help/guide/tutorial/Step4/tutorial.cxx b/Help/guide/tutorial/Step4/tutorial.cxx
new file mode 100644
index 000000000..b3c6a4f43
--- /dev/null
+++ b/Help/guide/tutorial/Step4/tutorial.cxx
@@ -0,0 +1,36 @@
+// A simple program that computes the square root of a number
+#include <cmath>
+#include <iostream>
+#include <string>
+
+#include "TutorialConfig.h"
+
+// should we include the MathFunctions header?
+#ifdef USE_MYMATH
+# include "MathFunctions.h"
+#endif
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ // report version
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MINOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
+ return 1;
+ }
+
+ // convert input to double
+ const double inputValue = std::stod(argv[1]);
+
+ // which square root function should we use?
+#ifdef USE_MYMATH
+ const double outputValue = mysqrt(inputValue);
+#else
+ const double outputValue = sqrt(inputValue);
+#endif
+
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
+ return 0;
+}
diff --git a/Help/guide/tutorial/Step5/CMakeLists.txt b/Help/guide/tutorial/Step5/CMakeLists.txt
new file mode 100644
index 000000000..c3b375a3d
--- /dev/null
+++ b/Help/guide/tutorial/Step5/CMakeLists.txt
@@ -0,0 +1,66 @@
+cmake_minimum_required(VERSION 3.10)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
+
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+
+# configure a header file to pass some of the CMake settings
+# to the source code
+configure_file(TutorialConfig.h.in TutorialConfig.h)
+
+# add the MathFunctions library
+if(USE_MYMATH)
+ add_subdirectory(MathFunctions)
+ list(APPEND EXTRA_LIBS MathFunctions)
+endif()
+
+# add the executable
+add_executable(Tutorial tutorial.cxx)
+target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS})
+
+# add the binary tree to the search path for include files
+# so that we will find TutorialConfig.h
+target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ )
+
+# add the install targets
+install(TARGETS Tutorial DESTINATION bin)
+install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
+ DESTINATION include
+ )
+
+# enable testing
+enable_testing()
+
+# does the application run
+add_test(NAME Runs COMMAND Tutorial 25)
+
+# does the usage message work?
+add_test(NAME Usage COMMAND Tutorial)
+set_tests_properties(Usage
+ PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number"
+ )
+
+# define a function to simplify adding tests
+function(do_test target arg result)
+ add_test(NAME Comp${arg} COMMAND ${target} ${arg})
+ set_tests_properties(Comp${arg}
+ PROPERTIES PASS_REGULAR_EXPRESSION ${result}
+ )
+endfunction(do_test)
+
+# do a bunch of result based tests
+do_test(Tutorial 4 "4 is 2")
+do_test(Tutorial 9 "9 is 3")
+do_test(Tutorial 5 "5 is 2.236")
+do_test(Tutorial 7 "7 is 2.645")
+do_test(Tutorial 25 "25 is 5")
+do_test(Tutorial -25 "-25 is [-nan|nan|0]")
+do_test(Tutorial 0.0001 "0.0001 is 0.01")
diff --git a/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt
new file mode 100644
index 000000000..b12f27d94
--- /dev/null
+++ b/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_library(MathFunctions mysqrt.cxx)
+
+# state that anybody linking to us needs to include the current source dir
+# to find MathFunctions.h, while we don't.
+target_include_directories(MathFunctions
+ INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+
+# install rules
+install(TARGETS MathFunctions DESTINATION lib)
+install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step5/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step5/MathFunctions/MakeTable.cxx
new file mode 100644
index 000000000..ee585568c
--- /dev/null
+++ b/Help/guide/tutorial/Step5/MathFunctions/MakeTable.cxx
@@ -0,0 +1,25 @@
+// A simple program that builds a sqrt table
+#include <cmath>
+#include <fstream>
+#include <iostream>
+
+int main(int argc, char* argv[])
+{
+ // make sure we have enough arguments
+ if (argc < 2) {
+ return 1;
+ }
+
+ std::ofstream fout(argv[1], std::ios_base::out);
+ const bool fileOpen = fout.is_open();
+ if (fileOpen) {
+ fout << "double sqrtTable[] = {" << std::endl;
+ for (int i = 0; i < 10; ++i) {
+ fout << sqrt(static_cast<double>(i)) << "," << std::endl;
+ }
+ // close the table with a zero
+ fout << "0};" << std::endl;
+ fout.close();
+ }
+ return fileOpen ? 0 : 1; // return 0 if wrote the file
+}
diff --git a/Tests/Tutorial/Step5/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step5/MathFunctions/MathFunctions.h
index cd36bccff..cd36bccff 100644
--- a/Tests/Tutorial/Step5/MathFunctions/MathFunctions.h
+++ b/Help/guide/tutorial/Step5/MathFunctions/MathFunctions.h
diff --git a/Help/guide/tutorial/Step5/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step5/MathFunctions/mysqrt.cxx
new file mode 100644
index 000000000..abe767d5a
--- /dev/null
+++ b/Help/guide/tutorial/Step5/MathFunctions/mysqrt.cxx
@@ -0,0 +1,24 @@
+#include <iostream>
+
+#include "MathFunctions.h"
+
+// a hack square root calculation using simple operations
+double mysqrt(double x)
+{
+ if (x <= 0) {
+ return 0;
+ }
+
+ double result = x;
+
+ // do ten iterations
+ for (int i = 0; i < 10; ++i) {
+ if (result <= 0) {
+ result = 0.1;
+ }
+ double delta = x - (result * result);
+ result = result + 0.5 * delta / result;
+ std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
+ }
+ return result;
+}
diff --git a/Help/guide/tutorial/Step5/TutorialConfig.h.in b/Help/guide/tutorial/Step5/TutorialConfig.h.in
new file mode 100644
index 000000000..e23f5213c
--- /dev/null
+++ b/Help/guide/tutorial/Step5/TutorialConfig.h.in
@@ -0,0 +1,4 @@
+// the configured options and settings for Tutorial
+#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
+#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
+#cmakedefine USE_MYMATH
diff --git a/Help/guide/tutorial/Step5/tutorial.cxx b/Help/guide/tutorial/Step5/tutorial.cxx
new file mode 100644
index 000000000..b3c6a4f43
--- /dev/null
+++ b/Help/guide/tutorial/Step5/tutorial.cxx
@@ -0,0 +1,36 @@
+// A simple program that computes the square root of a number
+#include <cmath>
+#include <iostream>
+#include <string>
+
+#include "TutorialConfig.h"
+
+// should we include the MathFunctions header?
+#ifdef USE_MYMATH
+# include "MathFunctions.h"
+#endif
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ // report version
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MINOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
+ return 1;
+ }
+
+ // convert input to double
+ const double inputValue = std::stod(argv[1]);
+
+ // which square root function should we use?
+#ifdef USE_MYMATH
+ const double outputValue = mysqrt(inputValue);
+#else
+ const double outputValue = sqrt(inputValue);
+#endif
+
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
+ return 0;
+}
diff --git a/Help/guide/tutorial/Step6/CMakeLists.txt b/Help/guide/tutorial/Step6/CMakeLists.txt
new file mode 100644
index 000000000..c3b375a3d
--- /dev/null
+++ b/Help/guide/tutorial/Step6/CMakeLists.txt
@@ -0,0 +1,66 @@
+cmake_minimum_required(VERSION 3.10)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
+
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+
+# configure a header file to pass some of the CMake settings
+# to the source code
+configure_file(TutorialConfig.h.in TutorialConfig.h)
+
+# add the MathFunctions library
+if(USE_MYMATH)
+ add_subdirectory(MathFunctions)
+ list(APPEND EXTRA_LIBS MathFunctions)
+endif()
+
+# add the executable
+add_executable(Tutorial tutorial.cxx)
+target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS})
+
+# add the binary tree to the search path for include files
+# so that we will find TutorialConfig.h
+target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ )
+
+# add the install targets
+install(TARGETS Tutorial DESTINATION bin)
+install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
+ DESTINATION include
+ )
+
+# enable testing
+enable_testing()
+
+# does the application run
+add_test(NAME Runs COMMAND Tutorial 25)
+
+# does the usage message work?
+add_test(NAME Usage COMMAND Tutorial)
+set_tests_properties(Usage
+ PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number"
+ )
+
+# define a function to simplify adding tests
+function(do_test target arg result)
+ add_test(NAME Comp${arg} COMMAND ${target} ${arg})
+ set_tests_properties(Comp${arg}
+ PROPERTIES PASS_REGULAR_EXPRESSION ${result}
+ )
+endfunction(do_test)
+
+# do a bunch of result based tests
+do_test(Tutorial 4 "4 is 2")
+do_test(Tutorial 9 "9 is 3")
+do_test(Tutorial 5 "5 is 2.236")
+do_test(Tutorial 7 "7 is 2.645")
+do_test(Tutorial 25 "25 is 5")
+do_test(Tutorial -25 "-25 is [-nan|nan|0]")
+do_test(Tutorial 0.0001 "0.0001 is 0.01")
diff --git a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt
new file mode 100644
index 000000000..4bf6024c2
--- /dev/null
+++ b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt
@@ -0,0 +1,22 @@
+add_library(MathFunctions mysqrt.cxx)
+
+# state that anybody linking to us needs to include the current source dir
+# to find MathFunctions.h, while we don't.
+target_include_directories(MathFunctions
+ INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+
+# does this system provide the log and exp functions?
+include(CheckSymbolExists)
+set(CMAKE_REQUIRED_LIBRARIES "m")
+check_symbol_exists(log "math.h" HAVE_LOG)
+check_symbol_exists(exp "math.h" HAVE_EXP)
+
+if(HAVE_LOG AND HAVE_EXP)
+ target_compile_definitions(MathFunctions
+ PRIVATE "HAVE_LOG" "HAVE_EXP")
+endif()
+
+# install rules
+install(TARGETS MathFunctions DESTINATION lib)
+install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step6/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step6/MathFunctions/MakeTable.cxx
new file mode 100644
index 000000000..ee585568c
--- /dev/null
+++ b/Help/guide/tutorial/Step6/MathFunctions/MakeTable.cxx
@@ -0,0 +1,25 @@
+// A simple program that builds a sqrt table
+#include <cmath>
+#include <fstream>
+#include <iostream>
+
+int main(int argc, char* argv[])
+{
+ // make sure we have enough arguments
+ if (argc < 2) {
+ return 1;
+ }
+
+ std::ofstream fout(argv[1], std::ios_base::out);
+ const bool fileOpen = fout.is_open();
+ if (fileOpen) {
+ fout << "double sqrtTable[] = {" << std::endl;
+ for (int i = 0; i < 10; ++i) {
+ fout << sqrt(static_cast<double>(i)) << "," << std::endl;
+ }
+ // close the table with a zero
+ fout << "0};" << std::endl;
+ fout.close();
+ }
+ return fileOpen ? 0 : 1; // return 0 if wrote the file
+}
diff --git a/Tests/Tutorial/Step6/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step6/MathFunctions/MathFunctions.h
index cd36bccff..cd36bccff 100644
--- a/Tests/Tutorial/Step6/MathFunctions/MathFunctions.h
+++ b/Help/guide/tutorial/Step6/MathFunctions/MathFunctions.h
diff --git a/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx
new file mode 100644
index 000000000..063706365
--- /dev/null
+++ b/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx
@@ -0,0 +1,32 @@
+#include <cmath>
+#include <iostream>
+
+#include "MathFunctions.h"
+
+// a hack square root calculation using simple operations
+double mysqrt(double x)
+{
+ if (x <= 0) {
+ return 0;
+ }
+
+ // if we have both log and exp then use them
+#if defined(HAVE_LOG) && defined(HAVE_EXP)
+ double result = exp(log(x) * 0.5);
+ std::cout << "Computing sqrt of " << x << " to be " << result
+ << " using log and exp" << std::endl;
+#else
+ double result = x;
+
+ // do ten iterations
+ for (int i = 0; i < 10; ++i) {
+ if (result <= 0) {
+ result = 0.1;
+ }
+ double delta = x - (result * result);
+ result = result + 0.5 * delta / result;
+ std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
+ }
+#endif
+ return result;
+}
diff --git a/Help/guide/tutorial/Step6/TutorialConfig.h.in b/Help/guide/tutorial/Step6/TutorialConfig.h.in
new file mode 100644
index 000000000..e23f5213c
--- /dev/null
+++ b/Help/guide/tutorial/Step6/TutorialConfig.h.in
@@ -0,0 +1,4 @@
+// the configured options and settings for Tutorial
+#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
+#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
+#cmakedefine USE_MYMATH
diff --git a/Help/guide/tutorial/Step6/tutorial.cxx b/Help/guide/tutorial/Step6/tutorial.cxx
new file mode 100644
index 000000000..b3c6a4f43
--- /dev/null
+++ b/Help/guide/tutorial/Step6/tutorial.cxx
@@ -0,0 +1,36 @@
+// A simple program that computes the square root of a number
+#include <cmath>
+#include <iostream>
+#include <string>
+
+#include "TutorialConfig.h"
+
+// should we include the MathFunctions header?
+#ifdef USE_MYMATH
+# include "MathFunctions.h"
+#endif
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ // report version
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MINOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
+ return 1;
+ }
+
+ // convert input to double
+ const double inputValue = std::stod(argv[1]);
+
+ // which square root function should we use?
+#ifdef USE_MYMATH
+ const double outputValue = mysqrt(inputValue);
+#else
+ const double outputValue = sqrt(inputValue);
+#endif
+
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
+ return 0;
+}
diff --git a/Help/guide/tutorial/Step7/CMakeLists.txt b/Help/guide/tutorial/Step7/CMakeLists.txt
new file mode 100644
index 000000000..c3b375a3d
--- /dev/null
+++ b/Help/guide/tutorial/Step7/CMakeLists.txt
@@ -0,0 +1,66 @@
+cmake_minimum_required(VERSION 3.10)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
+
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+
+# configure a header file to pass some of the CMake settings
+# to the source code
+configure_file(TutorialConfig.h.in TutorialConfig.h)
+
+# add the MathFunctions library
+if(USE_MYMATH)
+ add_subdirectory(MathFunctions)
+ list(APPEND EXTRA_LIBS MathFunctions)
+endif()
+
+# add the executable
+add_executable(Tutorial tutorial.cxx)
+target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS})
+
+# add the binary tree to the search path for include files
+# so that we will find TutorialConfig.h
+target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ )
+
+# add the install targets
+install(TARGETS Tutorial DESTINATION bin)
+install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
+ DESTINATION include
+ )
+
+# enable testing
+enable_testing()
+
+# does the application run
+add_test(NAME Runs COMMAND Tutorial 25)
+
+# does the usage message work?
+add_test(NAME Usage COMMAND Tutorial)
+set_tests_properties(Usage
+ PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number"
+ )
+
+# define a function to simplify adding tests
+function(do_test target arg result)
+ add_test(NAME Comp${arg} COMMAND ${target} ${arg})
+ set_tests_properties(Comp${arg}
+ PROPERTIES PASS_REGULAR_EXPRESSION ${result}
+ )
+endfunction(do_test)
+
+# do a bunch of result based tests
+do_test(Tutorial 4 "4 is 2")
+do_test(Tutorial 9 "9 is 3")
+do_test(Tutorial 5 "5 is 2.236")
+do_test(Tutorial 7 "7 is 2.645")
+do_test(Tutorial 25 "25 is 5")
+do_test(Tutorial -25 "-25 is [-nan|nan|0]")
+do_test(Tutorial 0.0001 "0.0001 is 0.01")
diff --git a/Help/guide/tutorial/Step7/License.txt b/Help/guide/tutorial/Step7/License.txt
new file mode 100644
index 000000000..c62d00b9e
--- /dev/null
+++ b/Help/guide/tutorial/Step7/License.txt
@@ -0,0 +1,2 @@
+This is the open source License.txt file introduced in
+CMake/Tutorial/Step7...
diff --git a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt
new file mode 100644
index 000000000..9ede4b327
--- /dev/null
+++ b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt
@@ -0,0 +1,29 @@
+# first we add the executable that generates the table
+add_executable(MakeTable MakeTable.cxx)
+
+# add the command to generate the source code
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ DEPENDS MakeTable
+ )
+
+# add the main library
+add_library(MathFunctions
+ mysqrt.cxx
+ ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ )
+
+# state that anybody linking to us needs to include the current source dir
+# to find MathFunctions.h, while we don't.
+# state that we depend on Tutorial_BINARY_DIR but consumers don't, as the
+# TutorialConfig.h include is an implementation detail
+# state that we depend on our binary dir to find Table.h
+target_include_directories(MathFunctions
+ INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+# install rules
+install(TARGETS MathFunctions DESTINATION lib)
+install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step7/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step7/MathFunctions/MakeTable.cxx
new file mode 100644
index 000000000..ee585568c
--- /dev/null
+++ b/Help/guide/tutorial/Step7/MathFunctions/MakeTable.cxx
@@ -0,0 +1,25 @@
+// A simple program that builds a sqrt table
+#include <cmath>
+#include <fstream>
+#include <iostream>
+
+int main(int argc, char* argv[])
+{
+ // make sure we have enough arguments
+ if (argc < 2) {
+ return 1;
+ }
+
+ std::ofstream fout(argv[1], std::ios_base::out);
+ const bool fileOpen = fout.is_open();
+ if (fileOpen) {
+ fout << "double sqrtTable[] = {" << std::endl;
+ for (int i = 0; i < 10; ++i) {
+ fout << sqrt(static_cast<double>(i)) << "," << std::endl;
+ }
+ // close the table with a zero
+ fout << "0};" << std::endl;
+ fout.close();
+ }
+ return fileOpen ? 0 : 1; // return 0 if wrote the file
+}
diff --git a/Tests/Tutorial/Step7/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step7/MathFunctions/MathFunctions.h
index cd36bccff..cd36bccff 100644
--- a/Tests/Tutorial/Step7/MathFunctions/MathFunctions.h
+++ b/Help/guide/tutorial/Step7/MathFunctions/MathFunctions.h
diff --git a/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx
new file mode 100644
index 000000000..7d80ee964
--- /dev/null
+++ b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx
@@ -0,0 +1,33 @@
+#include <iostream>
+
+#include "MathFunctions.h"
+
+// include the generated table
+#include "Table.h"
+
+// a hack square root calculation using simple operations
+double mysqrt(double x)
+{
+ if (x <= 0) {
+ return 0;
+ }
+
+ // use the table to help find an initial value
+ double result = x;
+ if (x >= 1 && x < 10) {
+ std::cout << "Use the table to help find an initial value " << std::endl;
+ result = sqrtTable[static_cast<int>(x)];
+ }
+
+ // do ten iterations
+ for (int i = 0; i < 10; ++i) {
+ if (result <= 0) {
+ result = 0.1;
+ }
+ double delta = x - (result * result);
+ result = result + 0.5 * delta / result;
+ std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
+ }
+
+ return result;
+}
diff --git a/Help/guide/tutorial/Step7/TutorialConfig.h.in b/Help/guide/tutorial/Step7/TutorialConfig.h.in
new file mode 100644
index 000000000..e23f5213c
--- /dev/null
+++ b/Help/guide/tutorial/Step7/TutorialConfig.h.in
@@ -0,0 +1,4 @@
+// the configured options and settings for Tutorial
+#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
+#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
+#cmakedefine USE_MYMATH
diff --git a/Help/guide/tutorial/Step7/tutorial.cxx b/Help/guide/tutorial/Step7/tutorial.cxx
new file mode 100644
index 000000000..b3c6a4f43
--- /dev/null
+++ b/Help/guide/tutorial/Step7/tutorial.cxx
@@ -0,0 +1,36 @@
+// A simple program that computes the square root of a number
+#include <cmath>
+#include <iostream>
+#include <string>
+
+#include "TutorialConfig.h"
+
+// should we include the MathFunctions header?
+#ifdef USE_MYMATH
+# include "MathFunctions.h"
+#endif
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ // report version
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MINOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
+ return 1;
+ }
+
+ // convert input to double
+ const double inputValue = std::stod(argv[1]);
+
+ // which square root function should we use?
+#ifdef USE_MYMATH
+ const double outputValue = mysqrt(inputValue);
+#else
+ const double outputValue = sqrt(inputValue);
+#endif
+
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
+ return 0;
+}
diff --git a/Help/guide/tutorial/Step8/CMakeLists.txt b/Help/guide/tutorial/Step8/CMakeLists.txt
new file mode 100644
index 000000000..19b9913e9
--- /dev/null
+++ b/Help/guide/tutorial/Step8/CMakeLists.txt
@@ -0,0 +1,73 @@
+cmake_minimum_required(VERSION 3.10)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
+
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+
+# configure a header file to pass some of the CMake settings
+# to the source code
+configure_file(TutorialConfig.h.in TutorialConfig.h)
+
+# add the MathFunctions library
+if(USE_MYMATH)
+ add_subdirectory(MathFunctions)
+ list(APPEND EXTRA_LIBS MathFunctions)
+endif()
+
+# add the executable
+add_executable(Tutorial tutorial.cxx)
+target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS})
+
+# add the binary tree to the search path for include files
+# so that we will find TutorialConfig.h
+target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ )
+
+# add the install targets
+install(TARGETS Tutorial DESTINATION bin)
+install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
+ DESTINATION include
+ )
+
+# enable testing
+enable_testing()
+
+# does the application run
+add_test(NAME Runs COMMAND Tutorial 25)
+
+# does the usage message work?
+add_test(NAME Usage COMMAND Tutorial)
+set_tests_properties(Usage
+ PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number"
+ )
+
+# define a function to simplify adding tests
+function(do_test target arg result)
+ add_test(NAME Comp${arg} COMMAND ${target} ${arg})
+ set_tests_properties(Comp${arg}
+ PROPERTIES PASS_REGULAR_EXPRESSION ${result}
+ )
+endfunction(do_test)
+
+# do a bunch of result based tests
+do_test(Tutorial 4 "4 is 2")
+do_test(Tutorial 9 "9 is 3")
+do_test(Tutorial 5 "5 is 2.236")
+do_test(Tutorial 7 "7 is 2.645")
+do_test(Tutorial 25 "25 is 5")
+do_test(Tutorial -25 "-25 is [-nan|nan|0]")
+do_test(Tutorial 0.0001 "0.0001 is 0.01")
+
+# setup installer
+include(InstallRequiredSystemLibraries)
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
+set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}")
+include(CPack)
diff --git a/Help/guide/tutorial/Step8/License.txt b/Help/guide/tutorial/Step8/License.txt
new file mode 100644
index 000000000..c62d00b9e
--- /dev/null
+++ b/Help/guide/tutorial/Step8/License.txt
@@ -0,0 +1,2 @@
+This is the open source License.txt file introduced in
+CMake/Tutorial/Step7...
diff --git a/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt
new file mode 100644
index 000000000..9ede4b327
--- /dev/null
+++ b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt
@@ -0,0 +1,29 @@
+# first we add the executable that generates the table
+add_executable(MakeTable MakeTable.cxx)
+
+# add the command to generate the source code
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ DEPENDS MakeTable
+ )
+
+# add the main library
+add_library(MathFunctions
+ mysqrt.cxx
+ ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ )
+
+# state that anybody linking to us needs to include the current source dir
+# to find MathFunctions.h, while we don't.
+# state that we depend on Tutorial_BINARY_DIR but consumers don't, as the
+# TutorialConfig.h include is an implementation detail
+# state that we depend on our binary dir to find Table.h
+target_include_directories(MathFunctions
+ INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+# install rules
+install(TARGETS MathFunctions DESTINATION lib)
+install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step8/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step8/MathFunctions/MakeTable.cxx
new file mode 100644
index 000000000..ee585568c
--- /dev/null
+++ b/Help/guide/tutorial/Step8/MathFunctions/MakeTable.cxx
@@ -0,0 +1,25 @@
+// A simple program that builds a sqrt table
+#include <cmath>
+#include <fstream>
+#include <iostream>
+
+int main(int argc, char* argv[])
+{
+ // make sure we have enough arguments
+ if (argc < 2) {
+ return 1;
+ }
+
+ std::ofstream fout(argv[1], std::ios_base::out);
+ const bool fileOpen = fout.is_open();
+ if (fileOpen) {
+ fout << "double sqrtTable[] = {" << std::endl;
+ for (int i = 0; i < 10; ++i) {
+ fout << sqrt(static_cast<double>(i)) << "," << std::endl;
+ }
+ // close the table with a zero
+ fout << "0};" << std::endl;
+ fout.close();
+ }
+ return fileOpen ? 0 : 1; // return 0 if wrote the file
+}
diff --git a/Help/guide/tutorial/Step8/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step8/MathFunctions/MathFunctions.h
new file mode 100644
index 000000000..cd36bccff
--- /dev/null
+++ b/Help/guide/tutorial/Step8/MathFunctions/MathFunctions.h
@@ -0,0 +1 @@
+double mysqrt(double x);
diff --git a/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx
new file mode 100644
index 000000000..7d80ee964
--- /dev/null
+++ b/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx
@@ -0,0 +1,33 @@
+#include <iostream>
+
+#include "MathFunctions.h"
+
+// include the generated table
+#include "Table.h"
+
+// a hack square root calculation using simple operations
+double mysqrt(double x)
+{
+ if (x <= 0) {
+ return 0;
+ }
+
+ // use the table to help find an initial value
+ double result = x;
+ if (x >= 1 && x < 10) {
+ std::cout << "Use the table to help find an initial value " << std::endl;
+ result = sqrtTable[static_cast<int>(x)];
+ }
+
+ // do ten iterations
+ for (int i = 0; i < 10; ++i) {
+ if (result <= 0) {
+ result = 0.1;
+ }
+ double delta = x - (result * result);
+ result = result + 0.5 * delta / result;
+ std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
+ }
+
+ return result;
+}
diff --git a/Help/guide/tutorial/Step8/TutorialConfig.h.in b/Help/guide/tutorial/Step8/TutorialConfig.h.in
new file mode 100644
index 000000000..e23f5213c
--- /dev/null
+++ b/Help/guide/tutorial/Step8/TutorialConfig.h.in
@@ -0,0 +1,4 @@
+// the configured options and settings for Tutorial
+#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
+#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
+#cmakedefine USE_MYMATH
diff --git a/Help/guide/tutorial/Step8/tutorial.cxx b/Help/guide/tutorial/Step8/tutorial.cxx
new file mode 100644
index 000000000..b3c6a4f43
--- /dev/null
+++ b/Help/guide/tutorial/Step8/tutorial.cxx
@@ -0,0 +1,36 @@
+// A simple program that computes the square root of a number
+#include <cmath>
+#include <iostream>
+#include <string>
+
+#include "TutorialConfig.h"
+
+// should we include the MathFunctions header?
+#ifdef USE_MYMATH
+# include "MathFunctions.h"
+#endif
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ // report version
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MINOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
+ return 1;
+ }
+
+ // convert input to double
+ const double inputValue = std::stod(argv[1]);
+
+ // which square root function should we use?
+#ifdef USE_MYMATH
+ const double outputValue = mysqrt(inputValue);
+#else
+ const double outputValue = sqrt(inputValue);
+#endif
+
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
+ return 0;
+}
diff --git a/Help/guide/tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt
new file mode 100644
index 000000000..d5f1cc897
--- /dev/null
+++ b/Help/guide/tutorial/Step9/CMakeLists.txt
@@ -0,0 +1,72 @@
+cmake_minimum_required(VERSION 3.10)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
+
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+
+# configure a header file to pass some of the CMake settings
+# to the source code
+configure_file(TutorialConfig.h.in TutorialConfig.h)
+
+# add the MathFunctions library
+if(USE_MYMATH)
+ add_subdirectory(MathFunctions)
+ list(APPEND EXTRA_LIBS MathFunctions)
+endif()
+
+# add the executable
+add_executable(Tutorial tutorial.cxx)
+target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS})
+
+# add the binary tree to the search path for include files
+# so that we will find TutorialConfig.h
+target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ )
+
+# add the install targets
+install(TARGETS Tutorial DESTINATION bin)
+install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
+ DESTINATION include
+ )
+
+# enable testing
+include(CTest)
+
+# does the application run
+add_test(NAME Runs COMMAND Tutorial 25)
+
+# does the usage message work?
+add_test(NAME Usage COMMAND Tutorial)
+set_tests_properties(Usage
+ PROPERTIES PASS_REGULAR_EXPRESSION "Usage:.*number"
+ )
+
+# define a function to simplify adding tests
+function(do_test target arg result)
+ add_test(NAME Comp${arg} COMMAND ${target} ${arg})
+ set_tests_properties(Comp${arg}
+ PROPERTIES PASS_REGULAR_EXPRESSION ${result}
+ )
+endfunction(do_test)
+
+# do a bunch of result based tests
+do_test(Tutorial 4 "4 is 2")
+do_test(Tutorial 9 "9 is 3")
+do_test(Tutorial 5 "5 is 2.236")
+do_test(Tutorial 7 "7 is 2.645")
+do_test(Tutorial 25 "25 is 5")
+do_test(Tutorial -25 "-25 is [-nan|nan|0]")
+do_test(Tutorial 0.0001 "0.0001 is 0.01")
+
+include(InstallRequiredSystemLibraries)
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
+set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}")
+include(CPack)
diff --git a/Help/guide/tutorial/Step9/CTestConfig.cmake b/Help/guide/tutorial/Step9/CTestConfig.cmake
new file mode 100644
index 000000000..73efdb1f6
--- /dev/null
+++ b/Help/guide/tutorial/Step9/CTestConfig.cmake
@@ -0,0 +1,7 @@
+set(CTEST_PROJECT_NAME "CMakeTutorial")
+set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
+
+set(CTEST_DROP_METHOD "http")
+set(CTEST_DROP_SITE "my.cdash.org")
+set(CTEST_DROP_LOCATION "/submit.php?project=CMakeTutorial")
+set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Help/guide/tutorial/Step9/License.txt b/Help/guide/tutorial/Step9/License.txt
new file mode 100644
index 000000000..c62d00b9e
--- /dev/null
+++ b/Help/guide/tutorial/Step9/License.txt
@@ -0,0 +1,2 @@
+This is the open source License.txt file introduced in
+CMake/Tutorial/Step7...
diff --git a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
new file mode 100644
index 000000000..50f0701fe
--- /dev/null
+++ b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
@@ -0,0 +1,27 @@
+# first we add the executable that generates the table
+add_executable(MakeTable MakeTable.cxx)
+
+# add the command to generate the source code
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ DEPENDS MakeTable
+ )
+
+# add the main library
+add_library(MathFunctions
+ mysqrt.cxx
+ ${CMAKE_CURRENT_BINARY_DIR}/Table.h
+ )
+
+# state that anybody linking to us needs to include the current source dir
+# to find MathFunctions.h, while we don't.
+# state that we depend on our binary dir to find Table.h
+target_include_directories(MathFunctions
+ INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+# install rules
+install(TARGETS MathFunctions DESTINATION lib)
+install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step9/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step9/MathFunctions/MakeTable.cxx
new file mode 100644
index 000000000..ee585568c
--- /dev/null
+++ b/Help/guide/tutorial/Step9/MathFunctions/MakeTable.cxx
@@ -0,0 +1,25 @@
+// A simple program that builds a sqrt table
+#include <cmath>
+#include <fstream>
+#include <iostream>
+
+int main(int argc, char* argv[])
+{
+ // make sure we have enough arguments
+ if (argc < 2) {
+ return 1;
+ }
+
+ std::ofstream fout(argv[1], std::ios_base::out);
+ const bool fileOpen = fout.is_open();
+ if (fileOpen) {
+ fout << "double sqrtTable[] = {" << std::endl;
+ for (int i = 0; i < 10; ++i) {
+ fout << sqrt(static_cast<double>(i)) << "," << std::endl;
+ }
+ // close the table with a zero
+ fout << "0};" << std::endl;
+ fout.close();
+ }
+ return fileOpen ? 0 : 1; // return 0 if wrote the file
+}
diff --git a/Help/guide/tutorial/Step9/MathFunctions/MathFunctions.cxx b/Help/guide/tutorial/Step9/MathFunctions/MathFunctions.cxx
new file mode 100644
index 000000000..014530062
--- /dev/null
+++ b/Help/guide/tutorial/Step9/MathFunctions/MathFunctions.cxx
@@ -0,0 +1,19 @@
+
+#include "MathFunctions.h"
+
+#include <cmath>
+
+#ifdef USE_MYMATH
+# include "mysqrt.h"
+#endif
+
+namespace mathfunctions {
+double sqrt(double x)
+{
+#ifdef USE_MYMATH
+ return detail::mysqrt(x);
+#else
+ return std::sqrt(x);
+#endif
+}
+}
diff --git a/Help/guide/tutorial/Step9/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step9/MathFunctions/MathFunctions.h
new file mode 100644
index 000000000..cd36bccff
--- /dev/null
+++ b/Help/guide/tutorial/Step9/MathFunctions/MathFunctions.h
@@ -0,0 +1 @@
+double mysqrt(double x);
diff --git a/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx
new file mode 100644
index 000000000..7d80ee964
--- /dev/null
+++ b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx
@@ -0,0 +1,33 @@
+#include <iostream>
+
+#include "MathFunctions.h"
+
+// include the generated table
+#include "Table.h"
+
+// a hack square root calculation using simple operations
+double mysqrt(double x)
+{
+ if (x <= 0) {
+ return 0;
+ }
+
+ // use the table to help find an initial value
+ double result = x;
+ if (x >= 1 && x < 10) {
+ std::cout << "Use the table to help find an initial value " << std::endl;
+ result = sqrtTable[static_cast<int>(x)];
+ }
+
+ // do ten iterations
+ for (int i = 0; i < 10; ++i) {
+ if (result <= 0) {
+ result = 0.1;
+ }
+ double delta = x - (result * result);
+ result = result + 0.5 * delta / result;
+ std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
+ }
+
+ return result;
+}
diff --git a/Help/guide/tutorial/Step9/MathFunctions/mysqrt.h b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.h
new file mode 100644
index 000000000..e1c42ef0c
--- /dev/null
+++ b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.h
@@ -0,0 +1,6 @@
+
+namespace mathfunctions {
+namespace detail {
+double mysqrt(double x);
+}
+}
diff --git a/Help/guide/tutorial/Step9/TutorialConfig.h.in b/Help/guide/tutorial/Step9/TutorialConfig.h.in
new file mode 100644
index 000000000..e23f5213c
--- /dev/null
+++ b/Help/guide/tutorial/Step9/TutorialConfig.h.in
@@ -0,0 +1,4 @@
+// the configured options and settings for Tutorial
+#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
+#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
+#cmakedefine USE_MYMATH
diff --git a/Help/guide/tutorial/Step9/tutorial.cxx b/Help/guide/tutorial/Step9/tutorial.cxx
new file mode 100644
index 000000000..b3c6a4f43
--- /dev/null
+++ b/Help/guide/tutorial/Step9/tutorial.cxx
@@ -0,0 +1,36 @@
+// A simple program that computes the square root of a number
+#include <cmath>
+#include <iostream>
+#include <string>
+
+#include "TutorialConfig.h"
+
+// should we include the MathFunctions header?
+#ifdef USE_MYMATH
+# include "MathFunctions.h"
+#endif
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ // report version
+ std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
+ << Tutorial_VERSION_MINOR << std::endl;
+ std::cout << "Usage: " << argv[0] << " number" << std::endl;
+ return 1;
+ }
+
+ // convert input to double
+ const double inputValue = std::stod(argv[1]);
+
+ // which square root function should we use?
+#ifdef USE_MYMATH
+ const double outputValue = mysqrt(inputValue);
+#else
+ const double outputValue = sqrt(inputValue);
+#endif
+
+ std::cout << "The square root of " << inputValue << " is " << outputValue
+ << std::endl;
+ return 0;
+}
diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst
new file mode 100644
index 000000000..d74d16047
--- /dev/null
+++ b/Help/guide/tutorial/index.rst
@@ -0,0 +1,902 @@
+CMake Tutorial
+**************
+
+.. only:: html
+
+ .. contents::
+
+The CMake tutorial provides a step-by-step guide that covers common build
+system issues that CMake helps address. Seeing how various topics all
+work together in an example project can be very helpful. The tutorial
+documentation and source code for examples can be found in the
+``Help/guide/tutorial`` directory of the CMake source code tree. Each step has
+its own subdirectory containing code that may be used as a starting point. The
+tutorial examples are progressive so that each step provides the complete
+solution for the previous step.
+
+A Basic Starting Point (Step 1)
+===============================
+
+The most basic project is an executable built from source code files.
+For simple projects, a three line ``CMakeLists.txt`` file is all that is
+required. This will be the starting point for our tutorial. Create a
+``CMakeLists.txt`` file in the ``Step1`` directory that looks like:
+
+.. code-block:: cmake
+
+ cmake_minimum_required(VERSION 3.10)
+
+ # set the project name
+ project(Tutorial)
+
+ # add the executable
+ add_executable(Tutorial tutorial.cxx)
+
+
+Note that this example uses lower case commands in the ``CMakeLists.txt`` file.
+Upper, lower, and mixed case commands are supported by CMake. The source
+code for ``tutorial.cxx`` is provided in the ``Step1`` directory and can be
+used to compute the square root of a number.
+
+Adding a Version Number and Configured Header File
+--------------------------------------------------
+
+The first feature we will add is to provide our executable and project with a
+version number. While we could do this exclusively in the source code, using
+``CMakeLists.txt`` provides more flexibility.
+
+First, modify the ``CMakeLists.txt`` file to set the version number.
+
+.. literalinclude:: Step2/CMakeLists.txt
+ :language: cmake
+ :end-before: # specify the C++ standard
+
+Then, configure a header file to pass the version number to the source
+code:
+
+.. literalinclude:: Step2/CMakeLists.txt
+ :language: cmake
+ :start-after: # to the source code
+ :end-before: # add the executable
+
+Since the configured file will be written into the binary tree, we
+must add that directory to the list of paths to search for include
+files. Add the following lines to the end of the ``CMakeLists.txt`` file:
+
+.. literalinclude:: Step2/CMakeLists.txt
+ :language: cmake
+ :start-after: # so that we will find TutorialConfig.h
+
+Using your favorite editor, create ``TutorialConfig.h.in`` in the source
+directory with the following contents:
+
+.. literalinclude:: Step2/TutorialConfig.h.in
+ :language: cmake
+
+When CMake configures this header file the values for
+``@Tutorial_VERSION_MAJOR@`` and ``@Tutorial_VERSION_MINOR@`` will be
+replaced.
+
+Next modify ``tutorial.cxx`` to include the configured header file,
+``TutorialConfig.h``.
+
+Finally, let's print out the version number by updating ``tutorial.cxx`` as
+follows:
+
+.. literalinclude:: Step2/tutorial.cxx
+ :language: c++
+ :start-after: {
+ :end-before: // convert input to double
+
+Specify the C++ Standard
+-------------------------
+
+Next let's add some C++11 features to our project by replacing ``atof`` with
+``std::stod`` in ``tutorial.cxx``. At the same time, remove
+``#include <cstdlib>``.
+
+.. literalinclude:: Step2/tutorial.cxx
+ :language: c++
+ :start-after: // convert input to double
+ :end-before: // calculate square root
+
+We will need to explicitly state in the CMake code that it should use the
+correct flags. The easiest way to enable support for a specific C++ standard
+in CMake is by using the ``CMAKE_CXX_STANDARD`` variable. For this tutorial,
+set the ``CMAKE_CXX_STANDARD`` variable in the ``CMakeLists.txt`` file to 11
+and ``CMAKE_CXX_STANDARD_REQUIRED`` to True:
+
+.. literalinclude:: Step2/CMakeLists.txt
+ :language: cmake
+ :end-before: # configure a header file to pass some of the CMake settings
+
+Build and Test
+--------------
+
+Run **cmake** or **cmake-gui** to configure the project and then build it
+with your chosen build tool.
+
+For example, from the command line we could navigate to the
+``Help/guide/tutorial`` directory of the CMake source code tree and run the
+following commands:
+
+.. code-block:: console
+
+ mkdir Step1_build
+ cd Step1_build
+ cmake ../Step1
+ cmake --build .
+
+Navigate to the directory where Tutorial was built (likely the make directory
+or a Debug or Release build configuration subdirectory) and run these commands:
+
+.. code-block:: console
+
+ Tutorial 4294967296
+ Tutorial 10
+ Tutorial
+
+Adding a Library (Step 2)
+=========================
+
+Now we will add a library to our project. This library will contain our own
+implementation for computing the square root of a number. The executable can
+then use this library instead of the standard square root function provided by
+the compiler.
+
+For this tutorial we will put the library into a subdirectory
+called ``MathFunctions``. This directory already contains a header file,
+``MathFunctions.h``, and a source file ``mysqrt.cxx``. The source file has one
+function called ``mysqrt`` that provides similar functionality to the
+compiler's ``sqrt`` function.
+
+Add the following one line ``CMakeLists.txt`` file to the ``MathFunctions``
+directory:
+
+.. literalinclude:: Step3/MathFunctions/CMakeLists.txt
+ :language: cmake
+
+To make use of the new library we will add an ``add_subdirectory`` call in the
+top-level ``CMakeLists.txt`` file so that the library will get built. We add
+the new library to the executable, and add ``MathFunctions`` as an include
+directory so that the ``mqsqrt.h`` header file can be found. The last few lines
+of the top-level ``CMakeLists.txt`` file should now look like:
+
+.. code-block:: cmake
+
+ # add the MathFunctions library
+ add_subdirectory(MathFunctions)
+
+ # add the executable
+ add_executable(Tutorial tutorial.cxx)
+
+ target_link_libraries(Tutorial PUBLIC MathFunctions)
+
+ # add the binary tree to the search path for include files
+ # so that we will find TutorialConfig.h
+ target_include_directories(Tutorial PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ "${PROJECT_SOURCE_DIR}/MathFunctions"
+ )
+
+Now let us make the MathFunctions library optional. While for the tutorial
+there really isn’t any need to do so, for larger projects this is a common
+occurrence. The first step is to add an option to the top-level
+``CMakeLists.txt`` file.
+
+.. literalinclude:: Step3/CMakeLists.txt
+ :language: cmake
+ :start-after: # should we use our own math functions
+ :end-before: # add the MathFunctions library
+
+This option will be displayed in the CMake GUI and ccmake with a default
+value of ON that can be changed by the user. This setting will be stored in
+the cache so that the user does not need to set the value each time they run
+CMake on a build directory.
+
+The next change is to make building and linking the MathFunctions library
+conditional. To do this we change the end of the top-level ``CMakeLists.txt``
+file to look like the following:
+
+.. literalinclude:: Step3/CMakeLists.txt
+ :language: cmake
+ :start-after: # add the MathFunctions library
+
+Note the use of the variable ``EXTRA_LIBS`` to collect up any optional
+libraries to later be linked into the executable. The variable
+``EXTRA_INCLUDES`` is used similarly for optional header files. This is a
+classic approach when dealing with many optional components, we will cover
+the modern approach in the next step.
+
+The corresponding changes to the source code are fairly straightforward. First,
+in ``tutorial.cxx``, include the ``MathFunctions.h`` header if we need it:
+
+.. literalinclude:: Step3/tutorial.cxx
+ :language: c++
+ :start-after: // should we include the MathFunctions header
+ :end-before: int main
+
+Then, in the same file, make ``USE_MYMATH`` control which square root
+function is used:
+
+.. literalinclude:: Step3/tutorial.cxx
+ :language: c++
+ :start-after: // which square root function should we use?
+ :end-before: std::cout << "The square root of
+
+Since the source code now requires ``USE_MYMATH`` we can add it to
+``TutorialConfig.h.in`` with the following line:
+
+.. literalinclude:: Step3/TutorialConfig.h.in
+ :language: c
+ :lines: 4
+
+**Exercise**: Why is it important that we configure ``TutorialConfig.h.in``
+after the option for ``USE_MYMATH``? What would happen if we inverted the two?
+
+Run **cmake** or **cmake-gui** to configure the project and then build it
+with your chosen build tool. Then run the built Tutorial executable.
+
+Use ccmake or the CMake GUI to update the value of ``USE_MYMATH``. Rebuild and
+run the tutorial again. Which function gives better results, sqrt or mysqrt?
+
+Adding Usage Requirements for Library (Step 3)
+==============================================
+
+Usage requirements allow for far better control over a library or executable's
+link and include line while also giving more control over the transitive
+property of targets inside CMake. The primary commands that leverage usage
+requirements are:
+
+ - ``target_compile_definitions``
+ - ``target_compile_options``
+ - ``target_include_directories``
+ - ``target_link_libraries``
+
+Let's refactor our code from `Adding a Library (Step 2)`_ to use the modern
+CMake approach of usage requirements. We first state that anybody linking to
+MathFunctions needs to include the current source directory, while
+MathFunctions itself doesn't. So this can become an ``INTERFACE`` usage
+requirement.
+
+Remember ``INTERFACE`` means things that consumers require but the producer
+doesn't. Add the following lines to the end of ``MathFunctions/CMakeLists.txt``:
+
+.. literalinclude:: Step4/MathFunctions/CMakeLists.txt
+ :language: cmake
+ :start-after: # to find MathFunctions.h
+
+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:
+
+.. literalinclude:: Step4/CMakeLists.txt
+ :language: cmake
+ :start-after: # add the MathFunctions library
+ :end-before: # add the executable
+
+And here:
+
+.. literalinclude:: Step4/CMakeLists.txt
+ :language: cmake
+ :start-after: # so that we will find TutorialConfig.h
+
+Once this is done, run **cmake** or **cmake-gui** to configure the project
+and then build it with your chosen build tool or by using ``cmake --build .``
+from the build directory.
+
+Installing and Testing (Step 4)
+===============================
+
+Now we can start adding install rules and testing support to our project.
+
+Install Rules
+-------------
+
+The install rules are fairly simple: for MathFunctions we want to install the
+library and header file and for the application we want to install the
+executable and configured header.
+
+So to the end of ``MathFunctions/CMakeLists.txt`` we add:
+
+.. literalinclude:: Step5/MathFunctions/CMakeLists.txt
+ :language: cmake
+ :start-after: # install rules
+
+And to the end of the top-level ``CMakeLists.txt`` we add:
+
+.. literalinclude:: Step5/CMakeLists.txt
+ :language: cmake
+ :start-after: # add the install targets
+ :end-before: # enable testing
+
+That is all that is needed to create a basic local install of the tutorial.
+
+Run **cmake** or **cmake-gui** to configure the project and then build it
+with your chosen build tool. Run the install step by typing
+``cmake --install .`` (introduced in 3.15, older versions of CMake must use
+``make install``) from the command line, or build the ``INSTALL`` target from
+an IDE. This will install the appropriate header files, libraries, and
+executables.
+
+The CMake variable ``CMAKE_INSTALL_PREFIX`` is used to determine the root of
+where the files will be installed. If using ``cmake --install`` a custom
+installation directory can be given via ``--prefix`` argument. For
+multi-configuration tools, use the ``--config`` argument to specify the
+configuration.
+
+Verify that the installed Tutorial runs.
+
+Testing Support
+---------------
+
+Next let's test our application. At the end of the top-level ``CMakeLists.txt``
+file we can enable testing and then add a number of basic tests to verify that
+the application is working correctly.
+
+.. literalinclude:: Step5/CMakeLists.txt
+ :language: cmake
+ :start-after: # enable testing
+
+The first test simply verifies that the application runs, does not segfault or
+otherwise crash, and has a zero return value. This is the basic form of a CTest
+test.
+
+The next test makes use of the ``PASS_REGULAR_EXPRESSION`` test property to
+verify that the output of the test contains certain strings. In this case,
+verifying that the usage message is printed when an incorrect number of
+arguments are provided.
+
+Lastly, we have a function called ``do_test`` that runs the application and
+verifies that the computed square root is correct for given input. For each
+invocation of ``do_test``, another test is added to the project with a name,
+input, and expected results based on the passed arguments.
+
+Rebuild the application and then cd to the binary directory and run
+``ctest -N`` and ``ctest -VV``. For multi-config generators (e.g. Visual
+Studio), the configuration type must be specified. To run tests in Debug mode,
+for example, use ``ctest -C Debug -VV`` from the build directory (not the
+Debug subdirectory!). Alternatively, build the ``RUN_TESTS`` target from the
+IDE.
+
+Adding System Introspection (Step 5)
+====================================
+
+Let us consider adding some code to our project that depends on features the
+target platform may not have. For this example, we will add some code that
+depends on whether or not the target platform has the ``log`` and ``exp``
+functions. Of course almost every platform has these functions but for this
+tutorial assume that they are not common.
+
+If the platform has ``log`` and ``exp`` then we will use them to compute the
+square root in the ``mysqrt`` function. We first test for the availability of
+these functions using the ``CheckSymbolExists`` module in the top-level
+``CMakeLists.txt``. We're going to use the new defines in
+``TutorialConfig.h.in``, so be sure to set them before that file is configured.
+
+.. literalinclude:: Step6/MathFunctions/CMakeLists.txt
+ :language: cmake
+ :start-after: # does this system provide the log and exp functions?
+ :end-before: if(HAVE_LOG AND HAVE_EXP)
+
+Now let's add these defines to ``TutorialConfig.h.in`` so that we can use them
+from ``mysqrt.cxx``:
+
+.. code-block:: console
+
+ // does the platform provide exp and log functions?
+ #cmakedefine HAVE_LOG
+ #cmakedefine HAVE_EXP
+
+Modify ``mysqrt.cxx`` to include cmath. Next, in that same file in the
+``mysqrt`` function we can provide an alternate implementation based on
+``log`` and ``exp`` if they are available on the system using the following
+code (don't forget the ``#endif`` before returning the result!):
+
+.. literalinclude:: Step6/MathFunctions/mysqrt.cxx
+ :language: c++
+ :start-after: // if we have both log and exp then use them
+ :end-before: // do ten iterations
+
+Run **cmake** or **cmake-gui** to configure the project and then build it
+with your chosen build tool and run the Tutorial executable.
+
+You will notice that we're not using ``log`` and ``exp``, even if we think they
+should be available. We should realize quickly that we have forgotten to include
+``TutorialConfig.h`` in ``mysqrt.cxx``.
+
+We will also need to update ``MathFunctions/CMakeLists.txt`` so ``mysqrt.cxx``
+knows where this file is located:
+
+.. code-block:: cmake
+
+ target_include_directories(MathFunctions
+ INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_BINARY_DIR}
+ )
+
+After making this update, go ahead and build the project again and run the built
+Tutorial executable. If ``log`` and ``exp`` are still not being used, open the
+generated ``TutorialConfig.h`` file from the build directory. Maybe they aren't
+available on the current system?
+
+Which function gives better results now, sqrt or mysqrt?
+
+Specify Compile Definition
+--------------------------
+
+Is there a better place for us to save the ``HAVE_LOG`` and ``HAVE_EXP`` values
+other than in ``TutorialConfig.h``? Let's try to use
+``target_compile_definitions``.
+
+First, remove the defines from ``TutorialConfig.h.in``. We no longer need to
+include ``TutorialConfig.h`` from ``mysqrt.cxx`` or the extra include in
+``MathFunctions/CMakeLists.txt``.
+
+Next, we can move the check for ``HAVE_LOG`` and ``HAVE_EXP`` to
+``MathFunctions/CMakeLists.txt`` and then specify those values as ``PRIVATE``
+compile definitions.
+
+.. literalinclude:: Step6/MathFunctions/CMakeLists.txt
+ :language: cmake
+ :start-after: # does this system provide the log and exp functions?
+ :end-before: # install rules
+
+After making these updates, go ahead and build the project again. Run the
+built Tutorial executable and verify that the results are same as earlier in
+this step.
+
+Adding a Custom Command and Generated File (Step 6)
+===================================================
+
+Suppose, for the purpose of this tutorial, we decide that we never want to use
+the platform ``log`` and ``exp`` functions and instead would like to
+generate a table of precomputed values to use in the ``mysqrt`` function.
+In this section, we will create the table as part of the build process,
+and then compile that table into our application.
+
+First, let's remove the check for the ``log`` and ``exp`` functions in
+``MathFunctions/CMakeLists.txt``. Then remove the check for ``HAVE_LOG`` and
+``HAVE_EXP`` from ``mysqrt.cxx``. At the same time, we can remove
+:code:`#include <cmath>`.
+
+In the ``MathFunctions`` subdirectory, a new source file named ``MakeTable.cxx``
+has been provided to generate the table.
+
+After reviewing the file, we can see that the table is produced as valid C++
+code and that the output filename is passed in as an argument.
+
+The next step is to add the appropriate commands to the
+``MathFunctions/CMakeLists.txt`` file to build the MakeTable executable and
+then run it as part of the build process. A few commands are needed to
+accomplish this.
+
+First, at the top of ``MathFunctions/CMakeLists.txt``, the executable for
+``MakeTable`` is added as any other executable would be added.
+
+.. literalinclude:: Step7/MathFunctions/CMakeLists.txt
+ :language: cmake
+ :start-after: # first we add the executable that generates the table
+ :end-before: # add the command to generate the source code
+
+Then we add a custom command that specifies how to produce ``Table.h``
+by running MakeTable.
+
+.. literalinclude:: Step7/MathFunctions/CMakeLists.txt
+ :language: cmake
+ :start-after: # add the command to generate the source code
+ :end-before: # add the main library
+
+Next we have to let CMake know that ``mysqrt.cxx`` depends on the generated
+file ``Table.h``. This is done by adding the generated ``Table.h`` to the list
+of sources for the library MathFunctions.
+
+.. literalinclude:: Step7/MathFunctions/CMakeLists.txt
+ :language: cmake
+ :start-after: # add the main library
+ :end-before: # state that anybody linking
+
+We also have to add the current binary directory to the list of include
+directories so that ``Table.h`` can be found and included by ``mysqrt.cxx``.
+
+.. literalinclude:: Step7/MathFunctions/CMakeLists.txt
+ :start-after: # state that we depend on our bin
+ :end-before: # install rules
+
+Now let's use the generated table. First, modify ``mysqrt.cxx`` to include
+``Table.h``. Next, we can rewrite the mysqrt function to use the table:
+
+.. literalinclude:: Step7/MathFunctions/mysqrt.cxx
+ :language: c++
+ :start-after: // a hack square root calculation using simple operations
+
+Run **cmake** or **cmake-gui** to configure the project and then build it
+with your chosen build tool.
+
+When this project is built it will first build the ``MakeTable`` executable.
+It will then run ``MakeTable`` to produce ``Table.h``. Finally, it will
+compile ``mysqrt.cxx`` which includes ``Table.h`` to produce the MathFunctions
+library.
+
+Run the Tutorial executable and verify that it is using the table.
+
+Building an Installer (Step 7)
+==============================
+
+Next suppose that we want to distribute our project to other people so that
+they can use it. We want to provide both binary and source distributions on a
+variety of platforms. This is a little different from the install we did
+previously in `Installing and Testing (Step 4)`_ , where we were
+installing the binaries that we had built from the source code. In this
+example we will be building installation packages that support binary
+installations and package management features. To accomplish this we will use
+CPack to create platform specific installers. Specifically we need to add
+a few lines to the bottom of our top-level ``CMakeLists.txt`` file.
+
+.. literalinclude:: Step8/CMakeLists.txt
+ :language: cmake
+ :start-after: # setup installer
+
+That is all there is to it. We start by including
+``InstallRequiredSystemLibraries``. This module will include any runtime
+libraries that are needed by the project for the current platform. Next we
+set some CPack variables to where we have stored the license and version
+information for this project. The version information was set earlier in this
+tutorial and the ``license.txt`` has been included in the top-level source
+directory for this step.
+
+Finally we include the CPack module which will use these variables and some
+other properties of the current system to setup an installer.
+
+The next step is to build the project in the usual manner and then run
+CPack on it. To build a binary distribution, from the binary directory run:
+
+.. code-block:: console
+
+ cpack
+
+To specify the generator, use the ``-G`` option. For multi-config builds, use
+``-C`` to specify the configuration. For example:
+
+.. code-block:: console
+
+ cpack -G ZIP -C Debug
+
+To create a source distribution you would type:
+
+.. code-block:: console
+
+ cpack --config CPackSourceConfig.cmake
+
+Alternatively, run ``make package`` or right click the ``Package`` target and
+``Build Project`` from an IDE.
+
+Run the installer found in the binary directory. Then run the
+installed executable and verify that it works.
+
+Adding Support for a Dashboard (Step 8)
+=======================================
+
+Adding support for submitting our test results to a dashboard is very easy. We
+already defined a number of tests for our project in `Testing Support`_. Now we
+just have to run those tests and submit them to a dashboard. To include support
+for dashboards we include the CTest module in our top-level ``CMakeLists.txt``.
+
+Replace:
+
+.. code-block:: cmake
+
+ # enable testing
+ enable_testing()
+
+With:
+
+.. code-block:: cmake
+
+ # enable dashboard scripting
+ include(CTest)
+
+The CTest module will automatically call ``enable_testing()``, so
+we can remove it from our CMake files.
+
+We will also need to create a ``CTestConfig.cmake`` file in the top-level
+directory where we can specify the name of the project and where to submit the
+dashboard.
+
+.. literalinclude:: Step9/CTestConfig.cmake
+ :language: cmake
+
+CTest will read in this file when it runs. To create a simple dashboard you can
+run **cmake** or **cmake-gui** to configure the project, but do not build it
+yet. Instead, change directory to the binary tree, and then run::
+
+ ctest [-VV] -D Experimental
+
+Remember, for multi-config generators (e.g. Visual Studio), the configuration
+type must be specified::
+
+ ctest [-VV] -C Debug -D Experimental
+
+Or, from an IDE, build the ``Experimental`` target.
+
+``ctest`` will build and test the project and submit the results to the Kitware
+public dashboard. The results of your dashboard will be uploaded to Kitware's
+public dashboard here: https://my.cdash.org/index.php?project=CMakeTutorial.
+
+Mixing Static and Shared (Step 9)
+=================================
+
+In this section we will show how by using the ``BUILD_SHARED_LIBS`` variable
+we can control the default behavior of ``add_library``, and allow control
+over how libraries without an explicit type (``STATIC``, ``SHARED``, ``MODULE``
+or ``OBJECT``) are built.
+
+To accomplish this we need to add ``BUILD_SHARED_LIBS`` to the top-level
+``CMakeLists.txt``. We use the ``option`` command as it allows users to
+optionally select if the value should be On or Off.
+
+Next we are going to refactor MathFunctions to become a real library that
+encapsulates using ``mysqrt`` or ``sqrt``, instead of requiring the calling
+code to do this logic. This will also mean that ``USE_MYMATH`` will not control
+building MathFuctions, but instead will control the behavior of this library.
+
+The first step is to update the starting section of the top-level
+``CMakeLists.txt`` to look like:
+
+.. literalinclude:: Step10/CMakeLists.txt
+ :language: cmake
+ :end-before: # add the binary tree
+
+Now that we have made MathFunctions always be used, we will need to update
+the logic of that library. So, in ``MathFunctions/CMakeLists.txt`` we need to
+create a SqrtLibrary that will conditionally be built when ``USE_MYMATH`` is
+enabled. Now, since this is a tutorial, we are going to explicitly require
+that SqrtLibrary is built statically.
+
+The end result is that ``MathFunctions/CMakeLists.txt`` should look like:
+
+.. literalinclude:: Step10/MathFunctions/CMakeLists.txt
+ :language: cmake
+ :lines: 1-36,42-
+
+Next, update ``MathFunctions/mysqrt.cxx`` to use the ``mathfunctions`` and
+``detail`` namespaces:
+
+.. literalinclude:: Step10/MathFunctions/mysqrt.cxx
+ :language: c++
+
+We also need to make some changes in ``tutorial.cxx``, so that it no longer
+uses ``USE_MYMATH``:
+
+#. Always include ``MathFunctions.h``
+#. Always use ``mathfunctions::sqrt``
+#. Don't include cmath
+
+Finally, update ``MathFunctions/MathFunctions.h`` to use dll export defines:
+
+.. literalinclude:: Step10/MathFunctions/MathFunctions.h
+ :language: c++
+
+At this point, if you build everything, you will notice that linking fails
+as we are combining a static library without position independent code with a
+library that has position independent code. The solution to this is to
+explicitly set the ``POSITION_INDEPENDENT_CODE`` target property of SqrtLibrary
+to be True no matter the build type.
+
+.. literalinclude:: Step10/MathFunctions/CMakeLists.txt
+ :language: cmake
+ :lines: 37-42
+
+**Exercise**: We modified ``MathFunctions.h`` to use dll export defines.
+Using CMake documentation can you find a helper module to simplify this?
+
+
+Adding Generator Expressions (Step 10)
+======================================
+
+Generator expressions are evaluated during build system generation to produce
+information specific to each build configuration.
+
+Generator expressions are allowed in the context of many target properties,
+such as ``LINK_LIBRARIES``, ``INCLUDE_DIRECTORIES``, ``COMPILE_DEFINITIONS``
+and others. They may also be used when using commands to populate those
+properties, such as ``target_link_libraries()``,
+``target_include_directories()``,
+``target_compile_definitions()`` and others.
+
+Generator expressions may be used to enable conditional linking, conditional
+definitions used when compiling, conditional include directories and more.
+The conditions may be based on the build configuration, target properties,
+platform information or any other queryable information.
+
+There are different types of generator expressions including Logical,
+Informational, and Output expressions.
+
+Logical expressions are used to create conditional output. The basic
+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.
+
+A common usage of generator expressions is to conditionally add compiler
+flags, such as those for language levels or warnings. A nice pattern is
+to associate this information to an ``INTERFACE`` target allowing this
+information to propagate. Lets start by constructing an ``INTERFACE``
+target and specifying the required C++ standard level of ``11`` instead
+of using ``CMAKE_CXX_STANDARD``.
+
+So the following code:
+
+.. literalinclude:: Step10/CMakeLists.txt
+ :language: cmake
+ :start-after: project(Tutorial VERSION 1.0)
+ :end-before: # control where the static and shared libraries are built so that on windows
+
+Would be replaced with:
+
+.. literalinclude:: Step11/CMakeLists.txt
+ :language: cmake
+ :start-after: project(Tutorial VERSION 1.0)
+ :end-before: # add compiler warning flags just when building this project via
+
+
+Next we add the desired compiler warning flags that we want for our
+project. As warning flags vary based on the compiler we use
+the ``COMPILE_LANG_AND_ID`` generator expression to control which
+flags to apply given a language and a set of compiler ids as seen
+below:
+
+.. literalinclude:: Step11/CMakeLists.txt
+ :language: cmake
+ :start-after: # the BUILD_INTERFACE genex
+ :end-before: # control where the static and shared libraries are built so that on windows
+
+Looking at this we see that the warning flags are encapsulated inside a
+``BUILD_INTERFACE`` condition. This is done so that consumers of our installed
+project will not inherit our warning flags.
+
+
+**Exercise**: Modify ``MathFunctions/CMakeLists.txt`` so that
+all targets have a ``target_link_libraries()`` call to ``tutorial_compiler_flags``.
+
+
+Adding Export Configuration (Step 11)
+=====================================
+
+During `Installing and Testing (Step 4)`_ of the tutorial we added the ability
+for CMake to install the library and headers of the project. During
+`Building an Installer (Step 7)`_ we added the ability to package up this
+information so it could be distributed to other people.
+
+The next step is to add the necessary information so that other CMake projects
+can use our project, be it from a build directory, a local install or when
+packaged.
+
+The first step is to update our ``install(TARGETS)`` commands to not only
+specify a ``DESTINATION`` but also an ``EXPORT``. The ``EXPORT`` keyword
+generates and installs a CMake file containing code to import all targets
+listed in the install command from the installation tree. So let's go ahead
+and explicitly ``EXPORT`` the MathFunctions library by updating the
+``install`` command in ``MathFunctions/CMakeLists.txt`` to look like:
+
+.. literalinclude:: Complete/MathFunctions/CMakeLists.txt
+ :language: cmake
+ :start-after: # install rules
+
+Now that we have MathFunctions being exported, we also need to explicitly
+install the generated ``MathFunctionsTargets.cmake`` file. This is done by
+adding the following to the bottom of the top-level ``CMakeLists.txt``:
+
+.. literalinclude:: Complete/CMakeLists.txt
+ :language: cmake
+ :start-after: # install the configuration targets
+ :end-before: include(CMakePackageConfigHelpers)
+
+At this point you should try and run CMake. If everything is setup properly
+you will see that CMake will generate an error that looks like:
+
+.. code-block:: console
+
+ Target "MathFunctions" INTERFACE_INCLUDE_DIRECTORIES property contains
+ path:
+
+ "/Users/robert/Documents/CMakeClass/Tutorial/Step11/MathFunctions"
+
+ which is prefixed in the source directory.
+
+What CMake is trying to say is that during generating the export information
+it will export a path that is intrinsically tied to the current machine and
+will not be valid on other machines. The solution to this is to update the
+MathFunctions ``target_include_directories`` to understand that it needs
+different ``INTERFACE`` locations when being used from within the build
+directory and from an install / package. This means converting the
+``target_include_directories`` call for MathFunctions to look like:
+
+.. literalinclude:: Complete/MathFunctions/CMakeLists.txt
+ :language: cmake
+ :start-after: # to find MathFunctions.h, while we don't.
+ :end-before: # should we use our own math functions
+
+Once this has been updated, we can re-run CMake and verify that it doesn't
+warn anymore.
+
+At this point, we have CMake properly packaging the target information that is
+required but we will still need to generate a ``MathFunctionsConfig.cmake`` so
+that the CMake ``find_package`` command can find our project. So let's go
+ahead and add a new file to the top-level of the project called
+``Config.cmake.in`` with the following contents:
+
+.. literalinclude:: Complete/Config.cmake.in
+
+Then, to properly configure and install that file, add the following to the
+bottom of the top-level ``CMakeLists.txt``:
+
+.. literalinclude:: Complete/CMakeLists.txt
+ :language: cmake
+ :start-after: # install the configuration targets
+ :end-before: # generate the export
+
+At this point, we have generated a relocatable CMake Configuration for our
+project that can be used after the project has been installed or packaged. If
+we want our project to also be used from a build directory we only have to add
+the following to the bottom of the top level ``CMakeLists.txt``:
+
+.. literalinclude:: Complete/CMakeLists.txt
+ :language: cmake
+ :start-after: # needs to be after the install(TARGETS ) command
+
+With this export call we now generate a ``Targets.cmake``, allowing the
+configured ``MathFunctionsConfig.cmake`` in the build directory to be used by
+other projects, without needing it to be installed.
+
+Import a CMake Project (Consumer)
+=================================
+
+This example shows how a project can find other CMake packages that
+generate ``Config.cmake`` files.
+
+It also shows how to state a project's external dependencies when generating
+a ``Config.cmake``.
+
+Packaging Debug and Release (MultiPackage)
+==========================================
+
+By default CMake's model is that a build directory only contains a single
+configuration, be it Debug, Release, MinSizeRel, or RelWithDebInfo.
+
+But it is possible to setup CPack to bundle multiple build directories at the
+same time to build a package that contains multiple configurations of the
+same project.
+
+First we need to construct a directory called ``multi_config``, which
+will contain all the builds that we want to package together.
+
+Second create a ``debug`` and ``release`` directory underneath
+``multi_config``. At the end you should have a layout that looks like:
+
+.. code-block:: none
+
+ ─ multi_config
+ ├── debug
+ └── release
+
+Now we need to setup debug and release builds, which would roughly entail
+the following:
+
+.. code-block:: console
+
+ cd debug
+ cmake -DCMAKE_BUILD_TYPE=Debug ../../MultiPackage/
+ cmake --build .
+ cd ../release
+ cmake -DCMAKE_BUILD_TYPE=Release ../../MultiPackage/
+ cmake --build .
+ cd ..
+
+
+Now that both the debug and release builds are complete, we can use
+a custom ``MultiCPackConfig.cmake`` file to package both builds into a single
+release.
+
+.. code-block:: console
+
+ cpack --config ../../MultiPackage/MultiCPackConfig.cmake
diff --git a/Help/index.rst b/Help/index.rst
index 97cd1073b..cc6cee644 100644
--- a/Help/index.rst
+++ b/Help/index.rst
@@ -29,17 +29,30 @@ Reference Manuals
/manual/cmake-commands.7
/manual/cmake-compile-features.7
/manual/cmake-developer.7
+ /manual/cmake-env-variables.7
+ /manual/cmake-file-api.7
/manual/cmake-generator-expressions.7
/manual/cmake-generators.7
/manual/cmake-language.7
- /manual/cmake-server.7
/manual/cmake-modules.7
/manual/cmake-packages.7
/manual/cmake-policies.7
/manual/cmake-properties.7
/manual/cmake-qt.7
+ /manual/cmake-server.7
/manual/cmake-toolchains.7
/manual/cmake-variables.7
+ /manual/cpack-generators.7
+
+.. only:: not man
+
+ Guides
+ ######
+
+ .. toctree::
+ :maxdepth: 1
+
+ /guide/tutorial/index
.. only:: html or text
diff --git a/Help/manual/LINKS.txt b/Help/manual/LINKS.txt
index 3993ff83d..810fa0b34 100644
--- a/Help/manual/LINKS.txt
+++ b/Help/manual/LINKS.txt
@@ -5,21 +5,13 @@ Home Page
The primary starting point for learning about CMake.
-Frequently Asked Questions
- https://cmake.org/Wiki/CMake_FAQ
-
- A Wiki is provided containing answers to frequently asked questions.
-
-Online Documentation
+Online Documentation and Community Resources
https://cmake.org/documentation
- Links to available documentation may be found on this web page.
+ Links to available documentation and community resources may be
+ found on this web page.
-Mailing List
- https://cmake.org/mailing-lists
+Discourse Forum
+ https://discourse.cmake.org
- For help and discussion about using cmake, a mailing list is
- provided at cmake@cmake.org. The list is member-post-only but one
- may sign up on the CMake web page. Please first read the full
- documentation at https://cmake.org before posting questions to
- the list.
+ The Discourse Forum hosts discussion and questions about CMake.
diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt
index e8b87c923..0947e41cb 100644
--- a/Help/manual/OPTIONS_BUILD.txt
+++ b/Help/manual/OPTIONS_BUILD.txt
@@ -1,23 +1,34 @@
+``-S <path-to-source>``
+ Path to root directory of the CMake project to build.
+
+``-B <path-to-build>``
+ Path to directory which CMake will use as the root of build directory.
+
+ If the directory doesn't already exist CMake will make it.
+
``-C <initial-cache>``
Pre-load a script to populate the cache.
- When cmake is first run in an empty build tree, it creates a
- CMakeCache.txt file and populates it with customizable settings for
+ When CMake is first run in an empty build tree, it creates a
+ ``CMakeCache.txt`` file and populates it with customizable settings for
the project. This option may be used to specify a file from which
to load cache entries before the first pass through the project's
- cmake listfiles. The loaded entries take priority over the
+ CMake listfiles. The loaded entries take priority over the
project's default values. The given file should be a CMake script
- containing SET commands that use the CACHE option, not a
+ containing :command:`set` commands that use the ``CACHE`` option, not a
cache-format file.
+ References to :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR`
+ within the script evaluate to the top-level source and build tree.
+
``-D <var>:<type>=<value>, -D <var>=<value>``
- Create a cmake cache entry.
+ Create or update a CMake ``CACHE`` entry.
- When cmake is first run in an empty build tree, it creates a
- CMakeCache.txt file and populates it with customizable settings for
+ When CMake is first run in an empty build tree, it creates a
+ ``CMakeCache.txt`` file and populates it with customizable settings for
the project. This option may be used to specify a setting that
takes priority over the project's default value. The option may be
- repeated for as many cache entries as desired.
+ repeated for as many ``CACHE`` entries as desired.
If the ``:<type>`` portion is given it must be one of the types
specified by the :command:`set` command documentation for its
@@ -31,14 +42,14 @@
``-D<var>:<type>=<value>`` or ``-D<var>=<value>``.
``-U <globbing_expr>``
- Remove matching entries from CMake cache.
+ Remove matching entries from CMake ``CACHE``.
This option may be used to remove one or more variables from the
- CMakeCache.txt file, globbing expressions using * and ? are
- supported. The option may be repeated for as many cache entries as
+ ``CMakeCache.txt`` file, globbing expressions using ``*`` and ``?`` are
+ supported. The option may be repeated for as many ``CACHE`` entries as
desired.
- Use with care, you can make your CMakeCache.txt non-working.
+ Use with care, you can make your ``CMakeCache.txt`` non-working.
``-G <generator-name>``
Specify a build system generator.
@@ -48,6 +59,9 @@
build system. Possible generator names are specified in the
:manual:`cmake-generators(7)` manual.
+ If not specified, CMake checks the :envvar:`CMAKE_GENERATOR` environment
+ variable and otherwise falls back to a builtin default selection.
+
``-T <toolset-spec>``
Toolset specification for the generator, if supported.
@@ -66,47 +80,47 @@
Suppress developer warnings.
Suppress warnings that are meant for the author of the
- CMakeLists.txt files. By default this will also turn off
+ ``CMakeLists.txt`` files. By default this will also turn off
deprecation warnings.
``-Wdev``
Enable developer warnings.
- Enable warnings that are meant for the author of the CMakeLists.txt
+ Enable warnings that are meant for the author of the ``CMakeLists.txt``
files. By default this will also turn on deprecation warnings.
``-Werror=dev``
Make developer warnings errors.
- Make warnings that are meant for the author of the CMakeLists.txt files
+ Make warnings that are meant for the author of the ``CMakeLists.txt`` files
errors. By default this will also turn on deprecated warnings as errors.
``-Wno-error=dev``
Make developer warnings not errors.
- Make warnings that are meant for the author of the CMakeLists.txt files not
+ Make warnings that are meant for the author of the ``CMakeLists.txt`` files not
errors. By default this will also turn off deprecated warnings as errors.
``-Wdeprecated``
Enable deprecated functionality warnings.
Enable warnings for usage of deprecated functionality, that are meant
- for the author of the CMakeLists.txt files.
+ for the author of the ``CMakeLists.txt`` files.
``-Wno-deprecated``
Suppress deprecated functionality warnings.
Suppress warnings for usage of deprecated functionality, that are meant
- for the author of the CMakeLists.txt files.
+ for the author of the ``CMakeLists.txt`` files.
``-Werror=deprecated``
Make deprecated macro and function warnings errors.
Make warnings for usage of deprecated macros and functions, that are meant
- for the author of the CMakeLists.txt files, errors.
+ for the author of the ``CMakeLists.txt`` files, errors.
``-Wno-error=deprecated``
Make deprecated macro and function warnings not errors.
Make warnings for usage of deprecated macros and functions, that are meant
- for the author of the CMakeLists.txt files, not errors.
+ for the author of the ``CMakeLists.txt`` files, not errors.
diff --git a/Help/manual/ccmake.1.rst b/Help/manual/ccmake.1.rst
index a5fe19168..60d45a35d 100644
--- a/Help/manual/ccmake.1.rst
+++ b/Help/manual/ccmake.1.rst
@@ -8,19 +8,19 @@ Synopsis
.. parsed-literal::
- ccmake [<options>] (<path-to-source> | <path-to-existing-build>)
+ ccmake [<options>] {<path-to-source> | <path-to-existing-build>}
Description
===========
-The "ccmake" executable is the CMake curses interface. Project
+The **ccmake** executable is the CMake curses interface. Project
configuration settings may be specified interactively through this
GUI. Brief instructions are provided at the bottom of the terminal
when the program is running.
CMake is a cross-platform build system generator. Projects specify
their build process with platform-independent CMake listfiles included
-in each directory of a source tree with the name CMakeLists.txt.
+in each directory of a source tree with the name ``CMakeLists.txt``.
Users build a project by using CMake to generate a build system for a
native tool on their platform.
diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst
index 95f5b8735..d8142a263 100644
--- a/Help/manual/cmake-buildsystem.7.rst
+++ b/Help/manual/cmake-buildsystem.7.rst
@@ -21,7 +21,7 @@ Binary Targets
Executables and libraries are defined using the :command:`add_executable`
and :command:`add_library` commands. The resulting binary files have
-appropriate prefixes, suffixes and extensions for the platform targeted.
+appropriate :prop_tgt:`PREFIX`, :prop_tgt:`SUFFIX` and extensions for the platform targeted.
Dependencies between binary targets are expressed using the
:command:`target_link_libraries` command:
@@ -31,7 +31,7 @@ Dependencies between binary targets are expressed using the
add_executable(zipapp zipapp.cpp)
target_link_libraries(zipapp archive)
-``archive`` is defined as a static library -- an archive containing objects
+``archive`` is defined as a ``STATIC`` library -- an archive containing objects
compiled from ``archive.cpp``, ``zip.cpp``, and ``lzma.cpp``. ``zipapp``
is defined as an executable formed by compiling and linking ``zipapp.cpp``.
When linking the ``zipapp`` executable, the ``archive`` static library is
@@ -59,7 +59,7 @@ Binary Library Types
Normal Libraries
^^^^^^^^^^^^^^^^
-By default, the :command:`add_library` command defines a static library,
+By default, the :command:`add_library` command defines a ``STATIC`` library,
unless a type is specified. A type may be specified when using the command:
.. code-block:: cmake
@@ -95,7 +95,7 @@ Apple Frameworks
""""""""""""""""
A ``SHARED`` library may be marked with the :prop_tgt:`FRAMEWORK`
-target property to create an OS X or iOS Framework Bundle.
+target property to create an macOS or iOS Framework Bundle.
The ``MACOSX_FRAMEWORK_IDENTIFIER`` sets ``CFBundleIdentifier`` key
and it uniquely identifies the bundle.
@@ -113,9 +113,9 @@ and it uniquely identifies the bundle.
Object Libraries
^^^^^^^^^^^^^^^^
-The ``OBJECT`` library type is also not linked to. It defines a non-archival
-collection of object files resulting from compiling the given source files.
-The object files collection can be used as source inputs to other targets:
+The ``OBJECT`` library type defines a non-archival collection of object files
+resulting from compiling the given source files. The object files collection
+may be used as source inputs to other targets:
.. code-block:: cmake
@@ -125,22 +125,31 @@ The object files collection can be used as source inputs to other targets:
add_executable(test_exe $<TARGET_OBJECTS:archive> test.cpp)
-``OBJECT`` libraries may not be used in the right hand side of
-:command:`target_link_libraries`. They also may not be used as the ``TARGET``
-in a use of the :command:`add_custom_command(TARGET)` command signature. They
-may be installed, and will be exported as an INTERFACE library.
+The link (or archiving) step of those other targets will use the object
+files collection in addition to those from their own sources.
-Although object libraries may not be named directly in calls to
-the :command:`target_link_libraries` command, they can be "linked"
-indirectly by using an :ref:`Interface Library <Interface Libraries>`
-whose :prop_tgt:`INTERFACE_SOURCES` target property is set to name
-``$<TARGET_OBJECTS:objlib>``.
+Alternatively, object libraries may be linked into other targets:
-Although object libraries may not be used as the ``TARGET``
-in a use of the :command:`add_custom_command(TARGET)` command signature,
-the list of objects can be used by :command:`add_custom_command(OUTPUT)` or
-:command:`file(GENERATE)` by using ``$<TARGET_OBJECTS:objlib>``.
+.. code-block:: cmake
+
+ add_library(archive OBJECT archive.cpp zip.cpp lzma.cpp)
+
+ add_library(archiveExtras STATIC extras.cpp)
+ target_link_libraries(archiveExtras PUBLIC archive)
+
+ add_executable(test_exe test.cpp)
+ target_link_libraries(test_exe archive)
+The link (or archiving) step of those other targets will use the object
+files from ``OBJECT`` libraries that are *directly* linked. Additionally,
+usage requirements of the ``OBJECT`` libraries will be honored when compiling
+sources in those other targets. Furthermore, those usage requirements
+will propagate transitively to dependents of those other targets.
+
+Object libraries may not be used as the ``TARGET`` in a use of the
+:command:`add_custom_command(TARGET)` command signature. However,
+the list of objects can be used by :command:`add_custom_command(OUTPUT)`
+or :command:`file(GENERATE)` by using ``$<TARGET_OBJECTS:objlib>``.
Build Specification and Usage Requirements
==========================================
@@ -266,7 +275,7 @@ The :command:`target_link_libraries` command has ``PRIVATE``,
Because ``archive`` is a ``PUBLIC`` dependency of ``archiveExtras``, the
usage requirements of it are propagated to ``consumer`` too. Because
-``serialization`` is a ``PRIVATE`` dependency of ``archive``, the usage
+``serialization`` is a ``PRIVATE`` dependency of ``archiveExtras``, the usage
requirements of it are not propagated to ``consumer``.
Generally, a dependency should be specified in a use of
@@ -356,8 +365,8 @@ non-compatible requirements :manual:`cmake(1)` issues a diagnostic:
target_link_libraries(exe2 lib1 lib2)
The ``lib1`` requirement ``INTERFACE_POSITION_INDEPENDENT_CODE`` is not
-"compatible" with the ``POSITION_INDEPENDENT_CODE`` property of the ``exe1``
-target. The library requires that consumers are built as
+"compatible" with the :prop_tgt:`POSITION_INDEPENDENT_CODE` property of
+the ``exe1`` target. The library requires that consumers are built as
position-independent-code, while the executable specifies to not built as
position-independent-code, so a diagnostic is issued.
@@ -538,10 +547,10 @@ is not known until build-time. Therefore, code such as
target_compile_definitions(exe1 PRIVATE DEBUG_BUILD)
endif()
-may appear to work for ``Makefile`` based and ``Ninja`` generators, but is not
-portable to IDE generators. Additionally, the :prop_tgt:`IMPORTED`
-configuration-mappings are not accounted for with code like this, so it should
-be avoided.
+may appear to work for :ref:`Makefile Generators` and :generator:`Ninja`
+generators, but is not portable to IDE generators. Additionally,
+the :prop_tgt:`IMPORTED` configuration-mappings are not accounted for
+with code like this, so it should be avoided.
The unary ``TARGET_PROPERTY`` generator expression and the ``TARGET_POLICY``
generator expression are evaluated with the consuming target context. This
@@ -687,9 +696,10 @@ property are treated as ``SYSTEM`` include directories, as if they were
listed in the :prop_tgt:`INTERFACE_SYSTEM_INCLUDE_DIRECTORIES` of the
dependency. This can result in omission of compiler warnings for headers
found in those directories. This behavior for :ref:`imported targets` may
-be controlled with the :prop_tgt:`NO_SYSTEM_FROM_IMPORTED` target property.
+be controlled by setting the :prop_tgt:`NO_SYSTEM_FROM_IMPORTED` target
+property on the *consumers* of imported targets.
-If a binary target is linked transitively to a Mac OX framework, the
+If a binary target is linked transitively to a macOS :prop_tgt:`FRAMEWORK`, the
``Headers`` directory of the framework is also treated as a usage requirement.
This has the same effect as passing the framework directory as an include
directory.
@@ -774,7 +784,7 @@ A *library* output artifact of a buildsystem target may be:
with the ``MODULE`` option.
* On non-DLL platforms: the shared library file (e.g. ``.so`` or ``.dylib``)
- of a shared shared library target created by the :command:`add_library`
+ of a shared library target created by the :command:`add_library`
command with the ``SHARED`` option.
The :prop_tgt:`LIBRARY_OUTPUT_DIRECTORY` and :prop_tgt:`LIBRARY_OUTPUT_NAME`
@@ -801,6 +811,10 @@ An *archive* output artifact of a buildsystem target may be:
executable target created by the :command:`add_executable` command
when its :prop_tgt:`ENABLE_EXPORTS` target property is set.
+* On AIX: the linker import file (e.g. ``.imp``) of an executable target
+ created by the :command:`add_executable` command when its
+ :prop_tgt:`ENABLE_EXPORTS` target property is set.
+
The :prop_tgt:`ARCHIVE_OUTPUT_DIRECTORY` and :prop_tgt:`ARCHIVE_OUTPUT_NAME`
target properties may be used to control archive output artifact locations
and names in the build tree.
@@ -811,7 +825,7 @@ Directory-Scoped Commands
The :command:`target_include_directories`,
:command:`target_compile_definitions` and
:command:`target_compile_options` commands have an effect on only one
-target at a time. The commands :command:`add_definitions`,
+target at a time. The commands :command:`add_compile_definitions`,
:command:`add_compile_options` and :command:`include_directories` have
a similar function, but operate at directory scope instead of target
scope for convenience.
@@ -830,12 +844,11 @@ Imported Targets
An :prop_tgt:`IMPORTED` target represents a pre-existing dependency. Usually
such targets are defined by an upstream package and should be treated as
-immutable. It is not possible to use an :prop_tgt:`IMPORTED` target in the
-left-hand-side of the :command:`target_compile_definitions`,
-:command:`target_include_directories`, :command:`target_compile_options` or
-:command:`target_link_libraries` commands, as that would be an attempt to
-modify it. :prop_tgt:`IMPORTED` targets are designed to be used only in the
-right-hand-side of those commands.
+immutable. After declaring an :prop_tgt:`IMPORTED` target one can adjust its
+target properties by using the customary commands such as
+:command:`target_compile_definitions`, :command:`target_include_directories`,
+:command:`target_compile_options` or :command:`target_link_libraries` just like
+with any other regular target.
:prop_tgt:`IMPORTED` targets may have the same usage requirement properties
populated as binary targets, such as
@@ -968,9 +981,10 @@ are:
* Properties matching ``INTERFACE_*``
* Built-in properties matching ``COMPATIBLE_INTERFACE_*``
* ``EXPORT_NAME``
+* ``EXPORT_PROPERTIES``
* ``IMPORTED``
+* ``MANUALLY_ADDED_DEPENDENCIES``
* ``NAME``
-* ``NO_SYSTEM_FROM_IMPORTED``
* Properties matching ``IMPORTED_LIBNAME_*``
* Properties matching ``MAP_IMPORTED_CONFIG_*``
diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst
index 611c989a0..59ba89727 100644
--- a/Help/manual/cmake-commands.7.rst
+++ b/Help/manual/cmake-commands.7.rst
@@ -22,8 +22,8 @@ These commands are always available.
/command/cmake_policy
/command/configure_file
/command/continue
- /command/elseif
/command/else
+ /command/elseif
/command/endforeach
/command/endfunction
/command/endif
@@ -44,6 +44,7 @@ These commands are always available.
/command/get_property
/command/if
/command/include
+ /command/include_guard
/command/list
/command/macro
/command/mark_as_advanced
@@ -52,9 +53,9 @@ These commands are always available.
/command/option
/command/return
/command/separate_arguments
+ /command/set
/command/set_directory_properties
/command/set_property
- /command/set
/command/site_name
/command/string
/command/unset
@@ -69,6 +70,7 @@ These commands are available only in CMake projects.
.. toctree::
:maxdepth: 1
+ /command/add_compile_definitions
/command/add_compile_options
/command/add_custom_command
/command/add_custom_target
@@ -76,6 +78,7 @@ These commands are available only in CMake projects.
/command/add_dependencies
/command/add_executable
/command/add_library
+ /command/add_link_options
/command/add_subdirectory
/command/add_test
/command/aux_source_directory
@@ -97,8 +100,6 @@ These commands are available only in CMake projects.
/command/link_libraries
/command/load_cache
/command/project
- /command/qt_wrap_cpp
- /command/qt_wrap_ui
/command/remove_definitions
/command/set_source_files_properties
/command/set_target_properties
@@ -108,7 +109,10 @@ These commands are available only in CMake projects.
/command/target_compile_features
/command/target_compile_options
/command/target_include_directories
+ /command/target_link_directories
/command/target_link_libraries
+ /command/target_link_options
+ /command/target_precompile_headers
/command/target_sources
/command/try_compile
/command/try_run
@@ -140,8 +144,10 @@ These commands are available only in CTest scripts.
Deprecated Commands
===================
-These commands are available only for compatibility with older
-versions of CMake. Do not use them in new code.
+These commands are deprecated and are only made available to maintain
+backward compatibility. The documentation of each command states the
+CMake version in which it was deprecated. Do not use these commands
+in new code.
.. toctree::
:maxdepth: 1
@@ -155,6 +161,8 @@ versions of CMake. Do not use them in new code.
/command/load_command
/command/make_directory
/command/output_required_files
+ /command/qt_wrap_cpp
+ /command/qt_wrap_ui
/command/remove
/command/subdir_depends
/command/subdirs
diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst
index 012439500..a14e3222c 100644
--- a/Help/manual/cmake-compile-features.7.rst
+++ b/Help/manual/cmake-compile-features.7.rst
@@ -28,10 +28,15 @@ CMake knows are known to the compiler, regardless of language standard
or compile flags needed to use them.
Features known to CMake are named mostly following the same convention
-as the Clang feature test macros. The are some exceptions, such as
+as the Clang feature test macros. There are some exceptions, such as
CMake using ``cxx_final`` and ``cxx_override`` instead of the single
``cxx_override_control`` used by Clang.
+Note that there are no separate compile features properties or variables for
+the ``OBJC`` or ``OBJCXX`` languages. These are based off ``C`` or ``C++``
+respectively, so the properties and variables for their corresponding base
+language should be used instead.
+
Compile Feature Requirements
============================
@@ -90,21 +95,21 @@ Requiring Language Standards
In projects that use a large number of commonly available features from
a particular language standard (e.g. C++ 11) one may specify a
meta-feature (e.g. ``cxx_std_11``) that requires use of a compiler mode
-aware of that standard. This is simpler than specifying all the
-features individually, but does not guarantee the existence of any
-particular feature. Diagnosis of use of unsupported features will be
-delayed until compile time.
+that is at minimum aware of that standard, but could be greater.
+This is simpler than specifying all the features individually, but does
+not guarantee the existence of any particular feature.
+Diagnosis of use of unsupported features will be delayed until compile time.
For example, if C++ 11 features are used extensively in a project's
-header files, then clients must use a compiler mode aware of C++ 11
-or above. This can be requested with the code:
+header files, then clients must use a compiler mode that is no less
+than C++ 11. This can be requested with the code:
.. code-block:: cmake
target_compile_features(mylib PUBLIC cxx_std_11)
In this example, CMake will ensure the compiler is invoked in a mode
-that is aware of C++ 11 (or above), adding flags such as
+of at-least C++ 11 (or C++ 14, C++ 17, ...), adding flags such as
``-std=gnu++11`` if necessary. This applies to sources within ``mylib``
as well as any dependents (that may include headers from ``mylib``).
@@ -331,12 +336,12 @@ and :prop_gbl:`compile features <CMAKE_CXX_KNOWN_FEATURES>` available from
the following :variable:`compiler ids <CMAKE_<LANG>_COMPILER_ID>` as of the
versions specified for each:
-* ``AppleClang``: Apple Clang for Xcode versions 4.4 though 6.2.
-* ``Clang``: Clang compiler versions 2.9 through 3.4.
-* ``GNU``: GNU compiler versions 4.4 through 5.0.
-* ``MSVC``: Microsoft Visual Studio versions 2010 through 2017.
-* ``SunPro``: Oracle SolarisStudio versions 12.4 through 12.5.
-* ``Intel``: Intel compiler versions 12.1 through 17.0.
+* ``AppleClang``: Apple Clang for Xcode versions 4.4+.
+* ``Clang``: Clang compiler versions 2.9+.
+* ``GNU``: GNU compiler versions 4.4+.
+* ``MSVC``: Microsoft Visual Studio versions 2010+.
+* ``SunPro``: Oracle SolarisStudio versions 12.4+.
+* ``Intel``: Intel compiler versions 12.1+.
CMake is currently aware of the :prop_tgt:`C standards <C_STANDARD>`
and :prop_gbl:`compile features <CMAKE_C_KNOWN_FEATURES>` available from
@@ -344,16 +349,16 @@ the following :variable:`compiler ids <CMAKE_<LANG>_COMPILER_ID>` as of the
versions specified for each:
* all compilers and versions listed above for C++.
-* ``GNU``: GNU compiler versions 3.4 through 5.0.
+* ``GNU``: GNU compiler versions 3.4+
CMake is currently aware of the :prop_tgt:`C++ standards <CXX_STANDARD>` and
their associated meta-features (e.g. ``cxx_std_11``) available from the
following :variable:`compiler ids <CMAKE_<LANG>_COMPILER_ID>` as of the
versions specified for each:
-* ``Cray``: Cray Compiler Environment version 8.1 through 8.5.8.
-* ``PGI``: PGI version 12.10 through 17.5.
-* ``XL``: IBM XL version 10.1 through 13.1.5.
+* ``Cray``: Cray Compiler Environment version 8.1+.
+* ``PGI``: PGI version 12.10+.
+* ``XL``: IBM XL version 10.1+.
CMake is currently aware of the :prop_tgt:`C standards <C_STANDARD>` and
their associated meta-features (e.g. ``c_std_99``) available from the
@@ -361,9 +366,10 @@ following :variable:`compiler ids <CMAKE_<LANG>_COMPILER_ID>` as of the
versions specified for each:
* all compilers and versions listed above with only meta-features for C++.
+* ``TI``: Texas Instruments compiler.
CMake is currently aware of the :prop_tgt:`CUDA standards <CUDA_STANDARD>`
from the following :variable:`compiler ids <CMAKE_<LANG>_COMPILER_ID>` as of the
versions specified for each:
-* ``NVIDIA``: NVIDIA nvcc compiler 7.5 though 8.0.
+* ``NVIDIA``: NVIDIA nvcc compiler 7.5+.
diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst
index cd509ac20..85ed935e6 100644
--- a/Help/manual/cmake-developer.7.rst
+++ b/Help/manual/cmake-developer.7.rst
@@ -10,580 +10,24 @@ cmake-developer(7)
Introduction
============
-This manual is intended for reference by developers modifying the CMake
-source tree itself, and by those authoring externally-maintained modules.
-
-Adding Compile Features
-=======================
-
-CMake reports an error if a compiler whose features are known does not report
-support for a particular requested feature. A compiler is considered to have
-known features if it reports support for at least one feature.
-
-When adding a new compile feature to CMake, it is therefore necessary to list
-support for the feature for all CompilerIds which already have one or more
-feature supported, if the new feature is available for any version of the
-compiler.
-
-When adding the first supported feature to a particular CompilerId, it is
-necessary to list support for all features known to cmake (See
-:variable:`CMAKE_C_COMPILE_FEATURES` and
-:variable:`CMAKE_CXX_COMPILE_FEATURES` as appropriate), where available for
-the compiler. Ensure that the ``CMAKE_<LANG>_STANDARD_DEFAULT`` is set to
-the computed internal variable ``CMAKE_<LANG>_STANDARD_COMPUTED_DEFAULT``
-for compiler versions which should be supported.
-
-It is sensible to record the features for the most recent version of a
-particular CompilerId first, and then work backwards. It is sensible to
-try to create a continuous range of versions of feature releases of the
-compiler. Gaps in the range indicate incorrect features recorded for
-intermediate releases.
-
-Generally, features are made available for a particular version if the
-compiler vendor documents availability of the feature with that
-version. Note that sometimes partially implemented features appear to
-be functional in previous releases (such as ``cxx_constexpr`` in GNU 4.6,
-though availability is documented in GNU 4.7), and sometimes compiler vendors
-document availability of features, though supporting infrastructure is
-not available (such as ``__has_feature(cxx_generic_lambdas)`` indicating
-non-availability in Clang 3.4, though it is documented as available, and
-fixed in Clang 3.5). Similar cases for other compilers and versions
-need to be investigated when extending CMake to support them.
-
-When a vendor releases a new version of a known compiler which supports
-a previously unsupported feature, and there are already known features for
-that compiler, the feature should be listed as supported in CMake for
-that version of the compiler as soon as reasonably possible.
-
-Standard-specific/compiler-specific variables such
-``CMAKE_CXX98_COMPILE_FEATURES`` are deliberately not documented. They
-only exist for the compiler-specific implementation of adding the ``-std``
-compile flag for compilers which need that.
-
-Help
-====
-
-The ``Help`` directory contains CMake help manual source files.
-They are written using the `reStructuredText`_ markup syntax and
-processed by `Sphinx`_ to generate the CMake help manuals.
-
-.. _`reStructuredText`: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
-.. _`Sphinx`: http://sphinx-doc.org
-
-Markup Constructs
------------------
-
-In addition to using Sphinx to generate the CMake help manuals, we
-also use a C++-implemented document processor to print documents for
-the ``--help-*`` command-line help options. It supports a subset of
-reStructuredText markup. When authoring or modifying documents,
-please verify that the command-line help looks good in addition to the
-Sphinx-generated html and man pages.
-
-The command-line help processor supports the following constructs
-defined by reStructuredText, Sphinx, and a CMake extension to Sphinx.
-
-..
- Note: This list must be kept consistent with the cmRST implementation.
-
-CMake Domain directives
- Directives defined in the `CMake Domain`_ for defining CMake
- documentation objects are printed in command-line help output as
- if the lines were normal paragraph text with interpretation.
-
-CMake Domain interpreted text roles
- Interpreted text roles defined in the `CMake Domain`_ for
- cross-referencing CMake documentation objects are replaced by their
- link text in command-line help output. Other roles are printed
- literally and not processed.
-
-``code-block`` directive
- Add a literal code block without interpretation. The command-line
- help processor prints the block content without the leading directive
- line and with common indentation replaced by one space.
-
-``include`` directive
- Include another document source file. The command-line help
- processor prints the included document inline with the referencing
- document.
-
-literal block after ``::``
- A paragraph ending in ``::`` followed by a blank line treats
- the following indented block as literal text without interpretation.
- The command-line help processor prints the ``::`` literally and
- prints the block content with common indentation replaced by one
- space.
-
-``note`` directive
- Call out a side note. The command-line help processor prints the
- block content as if the lines were normal paragraph text with
- interpretation.
-
-``parsed-literal`` directive
- Add a literal block with markup interpretation. The command-line
- help processor prints the block content without the leading
- directive line and with common indentation replaced by one space.
-
-``productionlist`` directive
- Render context-free grammar productions. The command-line help
- processor prints the block content as if the lines were normal
- paragraph text with interpretation.
-
-``replace`` directive
- Define a ``|substitution|`` replacement.
- The command-line help processor requires a substitution replacement
- to be defined before it is referenced.
-
-``|substitution|`` reference
- Reference a substitution replacement previously defined by
- the ``replace`` directive. The command-line help processor
- performs the substitution and replaces all newlines in the
- replacement text with spaces.
-
-``toctree`` directive
- Include other document sources in the Table-of-Contents
- document tree. The command-line help processor prints
- the referenced documents inline as part of the referencing
- document.
-
-Inline markup constructs not listed above are printed literally in the
-command-line help output. We prefer to use inline markup constructs that
-look correct in source form, so avoid use of \\-escapes in favor of inline
-literals when possible.
-
-Explicit markup blocks not matching directives listed above are removed from
-command-line help output. Do not use them, except for plain ``..`` comments
-that are removed by Sphinx too.
+This manual is intended for reference by developers working with
+:manual:`cmake-language(7)` code, whether writing their own modules,
+authoring their own build systems, or working on CMake itself.
-Note that nested indentation of blocks is not recognized by the
-command-line help processor. Therefore:
-
-* Explicit markup blocks are recognized only when not indented
- inside other blocks.
-
-* Literal blocks after paragraphs ending in ``::`` but not
- at the top indentation level may consume all indented lines
- following them.
-
-Try to avoid these cases in practice.
-
-CMake Domain
-------------
-
-CMake adds a `Sphinx Domain`_ called ``cmake``, also called the
-"CMake Domain". It defines several "object" types for CMake
-documentation:
-
-``command``
- A CMake language command.
-
-``generator``
- A CMake native build system generator.
- See the :manual:`cmake(1)` command-line tool's ``-G`` option.
-
-``manual``
- A CMake manual page, like this :manual:`cmake-developer(7)` manual.
-
-``module``
- A CMake module.
- See the :manual:`cmake-modules(7)` manual
- and the :command:`include` command.
-
-``policy``
- A CMake policy.
- See the :manual:`cmake-policies(7)` manual
- and the :command:`cmake_policy` command.
-
-``prop_cache, prop_dir, prop_gbl, prop_sf, prop_inst, prop_test, prop_tgt``
- A CMake cache, directory, global, source file, installed file, test,
- or target property, respectively. See the :manual:`cmake-properties(7)`
- manual and the :command:`set_property` command.
-
-``variable``
- A CMake language variable.
- See the :manual:`cmake-variables(7)` manual
- and the :command:`set` command.
-
-Documentation objects in the CMake Domain come from two sources.
-First, the CMake extension to Sphinx transforms every document named
-with the form ``Help/<type>/<file-name>.rst`` to a domain object with
-type ``<type>``. The object name is extracted from the document title,
-which is expected to be of the form::
-
- <object-name>
- -------------
-
-and to appear at or near the top of the ``.rst`` file before any other
-lines starting in a letter, digit, or ``<``. If no such title appears
-literally in the ``.rst`` file, the object name is the ``<file-name>``.
-If a title does appear, it is expected that ``<file-name>`` is equal
-to ``<object-name>`` with any ``<`` and ``>`` characters removed.
-
-Second, the CMake Domain provides directives to define objects inside
-other documents:
-
-.. code-block:: rst
-
- .. command:: <command-name>
-
- This indented block documents <command-name>.
-
- .. variable:: <variable-name>
-
- This indented block documents <variable-name>.
-
-Object types for which no directive is available must be defined using
-the first approach above.
-
-.. _`Sphinx Domain`: http://sphinx-doc.org/domains.html
-
-Cross-References
-----------------
-
-Sphinx uses reStructuredText interpreted text roles to provide
-cross-reference syntax. The `CMake Domain`_ provides for each
-domain object type a role of the same name to cross-reference it.
-CMake Domain roles are inline markup of the forms::
-
- :type:`name`
- :type:`text <name>`
-
-where ``type`` is the domain object type and ``name`` is the
-domain object name. In the first form the link text will be
-``name`` (or ``name()`` if the type is ``command``) and in
-the second form the link text will be the explicit ``text``.
-For example, the code:
-
-.. code-block:: rst
-
- * The :command:`list` command.
- * The :command:`list(APPEND)` sub-command.
- * The :command:`list() command <list>`.
- * The :command:`list(APPEND) sub-command <list>`.
- * The :variable:`CMAKE_VERSION` variable.
- * The :prop_tgt:`OUTPUT_NAME_<CONFIG>` target property.
-
-produces:
-
-* The :command:`list` command.
-* The :command:`list(APPEND)` sub-command.
-* The :command:`list() command <list>`.
-* The :command:`list(APPEND) sub-command <list>`.
-* The :variable:`CMAKE_VERSION` variable.
-* The :prop_tgt:`OUTPUT_NAME_<CONFIG>` target property.
-
-Note that CMake Domain roles differ from Sphinx and reStructuredText
-convention in that the form ``a<b>``, without a space preceding ``<``,
-is interpreted as a name instead of link text with an explicit target.
-This is necessary because we use ``<placeholders>`` frequently in
-object names like ``OUTPUT_NAME_<CONFIG>``. The form ``a <b>``,
-with a space preceding ``<``, is still interpreted as a link text
-with an explicit target.
-
-Style
------
-
-Style: Section Headers
-^^^^^^^^^^^^^^^^^^^^^^
-
-When marking section titles, make the section decoration line as long as
-the title text. Use only a line below the title, not above. For
-example:
-
-.. code-block:: rst
-
- Title Text
- ----------
-
-Capitalize the first letter of each non-minor word in the title.
-
-The section header underline character hierarchy is
-
-* ``#``: Manual group (part) in the master document
-* ``*``: Manual (chapter) title
-* ``=``: Section within a manual
-* ``-``: Subsection or `CMake Domain`_ object document title
-* ``^``: Subsubsection or `CMake Domain`_ object document section
-* ``"``: Paragraph or `CMake Domain`_ object document subsection
-
-Style: Whitespace
-^^^^^^^^^^^^^^^^^
-
-Use two spaces for indentation. Use two spaces between sentences in
-prose.
-
-Style: Line Length
-^^^^^^^^^^^^^^^^^^
-
-Prefer to restrict the width of lines to 75-80 columns. This is not a
-hard restriction, but writing new paragraphs wrapped at 75 columns
-allows space for adding minor content without significant re-wrapping of
-content.
-
-Style: Prose
-^^^^^^^^^^^^
-
-Use American English spellings in prose.
-
-Style: Starting Literal Blocks
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Prefer to mark the start of literal blocks with ``::`` at the end of
-the preceding paragraph. In cases where the following block gets
-a ``code-block`` marker, put a single ``:`` at the end of the preceding
-paragraph.
-
-Style: CMake Command Signatures
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Command signatures should be marked up as plain literal blocks, not as
-cmake ``code-blocks``.
-
-Signatures are separated from preceding content by a section header.
-That is, use:
-
-.. code-block:: rst
-
- ... preceding paragraph.
-
- Normal Libraries
- ^^^^^^^^^^^^^^^^
-
- ::
-
- add_library(<lib> ...)
-
- This signature is used for ...
-
-Signatures of commands should wrap optional parts with square brackets,
-and should mark list of optional arguments with an ellipsis (``...``).
-Elements of the signature which are specified by the user should be
-specified with angle brackets, and may be referred to in prose using
-``inline-literal`` syntax.
-
-Style: Boolean Constants
-^^^^^^^^^^^^^^^^^^^^^^^^
-
-Use "``OFF``" and "``ON``" for boolean values which can be modified by
-the user, such as :prop_tgt:`POSITION_INDEPENDENT_CODE`. Such properties
-may be "enabled" and "disabled". Use "``True``" and "``False``" for
-inherent values which can't be modified after being set, such as the
-:prop_tgt:`IMPORTED` property of a build target.
-
-Style: Inline Literals
-^^^^^^^^^^^^^^^^^^^^^^
-
-Mark up references to keywords in signatures, file names, and other
-technical terms with ``inline-literal`` syntax, for example:
-
-.. code-block:: rst
-
- If ``WIN32`` is used with :command:`add_executable`, the
- :prop_tgt:`WIN32_EXECUTABLE` target property is enabled. That command
- creates the file ``<name>.exe`` on Windows.
-
-Style: Cross-References
-^^^^^^^^^^^^^^^^^^^^^^^
-
-Mark up linkable references as links, including repeats.
-An alternative, which is used by wikipedia
-(`<http://en.wikipedia.org/wiki/WP:REPEATLINK>`_),
-is to link to a reference only once per article. That style is not used
-in CMake documentation.
-
-Style: Referencing CMake Concepts
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-If referring to a concept which corresponds to a property, and that
-concept is described in a high-level manual, prefer to link to the
-manual section instead of the property. For example:
-
-.. code-block:: rst
-
- This command creates an :ref:`Imported Target <Imported Targets>`.
-
-instead of:
-
-.. code-block:: rst
-
- This command creates an :prop_tgt:`IMPORTED` target.
-
-The latter should be used only when referring specifically to the
-property.
-
-References to manual sections are not automatically created by creating
-a section, but code such as:
-
-.. code-block:: rst
-
- .. _`Imported Targets`:
-
-creates a suitable anchor. Use an anchor name which matches the name
-of the corresponding section. Refer to the anchor using a
-cross-reference with specified text.
-
-Imported Targets need the ``IMPORTED`` term marked up with care in
-particular because the term may refer to a command keyword
-(``IMPORTED``), a target property (:prop_tgt:`IMPORTED`), or a
-concept (:ref:`Imported Targets`).
-
-Where a property, command or variable is related conceptually to others,
-by for example, being related to the buildsystem description, generator
-expressions or Qt, each relevant property, command or variable should
-link to the primary manual, which provides high-level information. Only
-particular information relating to the command should be in the
-documentation of the command.
-
-Style: Referencing CMake Domain Objects
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-When referring to `CMake Domain`_ objects such as properties, variables,
-commands etc, prefer to link to the target object and follow that with
-the type of object it is. For example:
-
-.. code-block:: rst
-
- Set the :prop_tgt:`AUTOMOC` target property to ``ON``.
-
-Instead of
-
-.. code-block:: rst
-
- Set the target property :prop_tgt:`AUTOMOC` to ``ON``.
-
-The ``policy`` directive is an exception, and the type us usually
-referred to before the link:
-
-.. code-block:: rst
-
- If policy :prop_tgt:`CMP0022` is set to ``NEW`` the behavior is ...
-
-However, markup self-references with ``inline-literal`` syntax.
-For example, within the :command:`add_executable` command
-documentation, use
-
-.. code-block:: rst
-
- ``add_executable``
-
-not
-
-.. code-block:: rst
-
- :command:`add_executable`
-
-which is used elsewhere.
-
-Modules
-=======
-
-The ``Modules`` directory contains CMake-language ``.cmake`` module files.
-
-Module Documentation
---------------------
-
-To document CMake module ``Modules/<module-name>.cmake``, modify
-``Help/manual/cmake-modules.7.rst`` to reference the module in the
-``toctree`` directive, in sorted order, as::
-
- /module/<module-name>
-
-Then add the module document file ``Help/module/<module-name>.rst``
-containing just the line::
-
- .. cmake-module:: ../../Modules/<module-name>.cmake
-
-The ``cmake-module`` directive will scan the module file to extract
-reStructuredText markup from comment blocks that start in ``.rst:``.
-At the top of ``Modules/<module-name>.cmake``, begin with the following
-license notice:
-
-.. code-block:: cmake
-
- # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- # file Copyright.txt or https://cmake.org/licensing for details.
-
-After this notice, add a *BLANK* line. Then, add documentation using
-a :ref:`Line Comment` block of the form:
-
-.. code-block:: cmake
-
- #.rst:
- # <module-name>
- # -------------
- #
- # <reStructuredText documentation of module>
-
-or a :ref:`Bracket Comment` of the form:
-
-::
-
- #[[.rst:
- <module-name>
- -------------
-
- <reStructuredText documentation of module>
- #]]
-
-Any number of ``=`` may be used in the opening and closing brackets
-as long as they match. Content on the line containing the closing
-bracket is excluded if and only if the line starts in ``#``.
-
-Additional such ``.rst:`` comments may appear anywhere in the module file.
-All such comments must start with ``#`` in the first column.
-
-For example, a ``Modules/Findxxx.cmake`` module may contain:
-
-::
-
- # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- # file Copyright.txt or https://cmake.org/licensing for details.
-
- #.rst:
- # FindXxx
- # -------
- #
- # This is a cool module.
- # This module does really cool stuff.
- # It can do even more than you think.
- #
- # It even needs two paragraphs to tell you about it.
- # And it defines the following variables:
- #
- # * VAR_COOL: this is great isn't it?
- # * VAR_REALLY_COOL: cool right?
-
- <code>
-
- #[========================================[.rst:
- .. command:: xxx_do_something
-
- This command does something for Xxx::
-
- xxx_do_something(some arguments)
- #]========================================]
- macro(xxx_do_something)
- <code>
- endmacro()
-
-Test the documentation formatting by running
-``cmake --help-module <module-name>``, and also by enabling the
-``SPHINX_HTML`` and ``SPHINX_MAN`` options to build the documentation.
-Edit the comments until generated documentation looks satisfactory. To
-have a .cmake file in this directory NOT show up in the modules
-documentation, simply leave out the ``Help/module/<module-name>.rst``
-file and the ``Help/manual/cmake-modules.7.rst`` toctree entry.
+See https://cmake.org/get-involved/ to get involved in development of
+CMake upstream. It includes links to contribution instructions, which
+in turn link to developer guides for CMake itself.
.. _`Find Modules`:
Find Modules
-------------
+============
-A "find module" is a ``Modules/Find<package>.cmake`` file to be loaded
-by the :command:`find_package` command when invoked for ``<package>``.
+A "find module" is a ``Find<PackageName>.cmake`` file to be loaded
+by the :command:`find_package` command when invoked for ``<PackageName>``.
The primary task of a find module is to determine whether a package
-exists on the system, set the ``<package>_FOUND`` variable to reflect
+exists on the system, set the ``<PackageName>_FOUND`` variable to reflect
this and provide any variables, macros and imported targets required to
use the package. A find module is useful in cases where an upstream
library does not provide a
@@ -638,14 +82,11 @@ and required is up to the find module, but should be documented.
For internal implementation, it is a generally accepted convention that
variables starting with underscore are for temporary use only.
-Like all modules, find modules should be properly documented. To add a
-module to the CMake documentation, follow the steps in the `Module
-Documentation`_ section above.
-
+.. _`CMake Developer Standard Variable Names`:
Standard Variable Names
-^^^^^^^^^^^^^^^^^^^^^^^
+-----------------------
For a ``FindXxx.cmake`` module that takes the approach of setting
variables (either instead of or in addition to creating imported
@@ -752,54 +193,81 @@ Make sure you comment them as deprecated, so that no-one starts using
them.
-
A Sample Find Module
-^^^^^^^^^^^^^^^^^^^^
+--------------------
-We will describe how to create a simple find module for a library
-``Foo``.
+We will describe how to create a simple find module for a library ``Foo``.
-The first thing that is needed is a license notice.
+The top of the module should begin with a license notice, followed by
+a blank line, and then followed by a :ref:`Bracket Comment`. The comment
+should begin with ``.rst:`` to indicate that the rest of its content is
+reStructuredText-format documentation. For example:
-.. code-block:: cmake
+::
- # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- # file Copyright.txt or https://cmake.org/licensing for details.
+ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ # file Copyright.txt or https://cmake.org/licensing for details.
-Next we need module documentation. CMake's documentation system requires you
-to follow the license notice with a blank line and then with a documentation
-marker and the name of the module. You should follow this with a simple
-statement of what the module does.
+ #[=======================================================================[.rst:
+ FindFoo
+ -------
-.. code-block:: cmake
+ Finds the Foo library.
- #.rst:
- # FindFoo
- # -------
- #
- # Finds the Foo library
- #
+ Imported Targets
+ ^^^^^^^^^^^^^^^^
-More description may be required for some packages. If there are
-caveats or other details users of the module should be aware of, you can
-add further paragraphs below this. Then you need to document what
-variables and imported targets are set by the module, such as
+ This module provides the following imported targets, if found:
-.. code-block:: cmake
+ ``Foo::Foo``
+ The Foo library
+
+ Result Variables
+ ^^^^^^^^^^^^^^^^
+
+ This will define the following variables:
+
+ ``Foo_FOUND``
+ True if the system has the Foo library.
+ ``Foo_VERSION``
+ The version of the Foo library which was found.
+ ``Foo_INCLUDE_DIRS``
+ Include directories needed to use Foo.
+ ``Foo_LIBRARIES``
+ Libraries needed to link to Foo.
+
+ Cache Variables
+ ^^^^^^^^^^^^^^^
+
+ The following cache variables may also be set:
+
+ ``Foo_INCLUDE_DIR``
+ The directory containing ``foo.h``.
+ ``Foo_LIBRARY``
+ The path to the Foo library.
+
+ #]=======================================================================]
+
+The module documentation consists of:
+
+* An underlined heading specifying the module name.
+
+* A simple description of what the module finds.
+ More description may be required for some packages. If there are
+ caveats or other details users of the module should be aware of,
+ specify them here.
+
+* A section listing imported targets provided by the module, if any.
+
+* A section listing result variables provided by the module.
- # This will define the following variables::
- #
- # Foo_FOUND - True if the system has the Foo library
- # Foo_VERSION - The version of the Foo library which was found
- #
- # and the following imported targets::
- #
- # Foo::Foo - The Foo library
+* Optionally a section listing cache variables used by the module, if any.
-If the package provides any macros, they should be listed here, but can
-be documented where they are defined. See the `Module
-Documentation`_ section above for more details.
+If the package provides any macros or functions, they should be listed in
+an additional section, but can be documented by additional ``.rst:``
+comment blocks immediately above where those macros or functions are defined.
+The find module implementation may begin below the documentation block.
Now the actual libraries and so on have to be found. The code here will
obviously vary from module to module (dealing with that, after all, is the
point of find modules), but there tends to be a common pattern for libraries.
@@ -943,7 +411,7 @@ populated:
endif()
The ``RELEASE`` variant should be listed first in the property
-so that that variant is chosen if the user uses a configuration which is
+so that the variant is chosen if the user uses a configuration which is
not an exact match for any listed ``IMPORTED_CONFIGURATIONS``.
Most of the cache variables should be hidden in the ``ccmake`` interface unless
diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst
new file mode 100644
index 000000000..96ceb945a
--- /dev/null
+++ b/Help/manual/cmake-env-variables.7.rst
@@ -0,0 +1,73 @@
+.. cmake-manual-description: CMake Environment Variables Reference
+
+cmake-env-variables(7)
+**********************
+
+.. only:: html
+
+ .. contents::
+
+This page lists environment variables that have special
+meaning to CMake.
+
+For general information on environment variables, see the
+:ref:`Environment Variables <CMake Language Environment Variables>`
+section in the cmake-language manual.
+
+
+Environment Variables that Control the Build
+============================================
+
+.. toctree::
+ :maxdepth: 1
+
+ /envvar/CMAKE_BUILD_PARALLEL_LEVEL
+ /envvar/CMAKE_CONFIG_TYPE
+ /envvar/CMAKE_GENERATOR
+ /envvar/CMAKE_GENERATOR_INSTANCE
+ /envvar/CMAKE_GENERATOR_PLATFORM
+ /envvar/CMAKE_GENERATOR_TOOLSET
+ /envvar/CMAKE_MSVCIDE_RUN_PATH
+ /envvar/CMAKE_NO_VERBOSE
+ /envvar/CMAKE_OSX_ARCHITECTURES
+ /envvar/DESTDIR
+ /envvar/LDFLAGS
+ /envvar/MACOSX_DEPLOYMENT_TARGET
+ /envvar/PackageName_ROOT
+ /envvar/VERBOSE
+
+Environment Variables for Languages
+===================================
+
+.. toctree::
+ :maxdepth: 1
+
+ /envvar/ASM_DIALECT
+ /envvar/ASM_DIALECTFLAGS
+ /envvar/CC
+ /envvar/CFLAGS
+ /envvar/CSFLAGS
+ /envvar/CUDACXX
+ /envvar/CUDAFLAGS
+ /envvar/CUDAHOSTCXX
+ /envvar/CXX
+ /envvar/CXXFLAGS
+ /envvar/FC
+ /envvar/FFLAGS
+ /envvar/RC
+ /envvar/RCFLAGS
+ /envvar/SWIFTC
+
+Environment Variables for CTest
+===============================
+
+.. toctree::
+ :maxdepth: 1
+
+ /envvar/CMAKE_CONFIG_TYPE
+ /envvar/CTEST_INTERACTIVE_DEBUG_MODE
+ /envvar/CTEST_OUTPUT_ON_FAILURE
+ /envvar/CTEST_PARALLEL_LEVEL
+ /envvar/CTEST_PROGRESS_OUTPUT
+ /envvar/CTEST_USE_LAUNCHERS_DEFAULT
+ /envvar/DASHBOARD_TEST_FROM_CTEST
diff --git a/Help/manual/cmake-file-api.7.rst b/Help/manual/cmake-file-api.7.rst
new file mode 100644
index 000000000..04b6ed259
--- /dev/null
+++ b/Help/manual/cmake-file-api.7.rst
@@ -0,0 +1,1113 @@
+.. cmake-manual-description: CMake File-Based API
+
+cmake-file-api(7)
+*****************
+
+.. only:: html
+
+ .. contents::
+
+Introduction
+============
+
+CMake provides a file-based API that clients may use to get semantic
+information about the buildsystems CMake generates. Clients may use
+the API by writing query files to a specific location in a build tree
+to request zero or more `Object Kinds`_. When CMake generates the
+buildsystem in that build tree it will read the query files and write
+reply files for the client to read.
+
+The file-based API uses a ``<build>/.cmake/api/`` directory at the top
+of a build tree. The API is versioned to support changes to the layout
+of files within the API directory. API file layout versioning is
+orthogonal to the versioning of `Object Kinds`_ used in replies.
+This version of CMake supports only one API version, `API v1`_.
+
+API v1
+======
+
+API v1 is housed in the ``<build>/.cmake/api/v1/`` directory.
+It has the following subdirectories:
+
+``query/``
+ Holds query files written by clients.
+ These may be `v1 Shared Stateless Query Files`_,
+ `v1 Client Stateless Query Files`_, or `v1 Client Stateful Query Files`_.
+
+``reply/``
+ Holds reply files written by CMake whenever it runs to generate a build
+ system. These are indexed by a `v1 Reply Index File`_ file that may
+ reference additional `v1 Reply Files`_. CMake owns all reply files.
+ Clients must never remove them.
+
+ Clients may look for and read a reply index file at any time.
+ Clients may optionally create the ``reply/`` directory at any time
+ and monitor it for the appearance of a new reply index file.
+
+v1 Shared Stateless Query Files
+-------------------------------
+
+Shared stateless query files allow clients to share requests for
+major versions of the `Object Kinds`_ and get all requested versions
+recognized by the CMake that runs.
+
+Clients may create shared requests by creating empty files in the
+``v1/query/`` directory. The form is::
+
+ <build>/.cmake/api/v1/query/<kind>-v<major>
+
+where ``<kind>`` is one of the `Object Kinds`_, ``-v`` is literal,
+and ``<major>`` is the major version number.
+
+Files of this form are stateless shared queries not owned by any specific
+client. Once created they should not be removed without external client
+coordination or human intervention.
+
+v1 Client Stateless Query Files
+-------------------------------
+
+Client stateless query files allow clients to create owned requests for
+major versions of the `Object Kinds`_ and get all requested versions
+recognized by the CMake that runs.
+
+Clients may create owned requests by creating empty files in
+client-specific query subdirectories. The form is::
+
+ <build>/.cmake/api/v1/query/client-<client>/<kind>-v<major>
+
+where ``client-`` is literal, ``<client>`` is a string uniquely
+identifying the client, ``<kind>`` is one of the `Object Kinds`_,
+``-v`` is literal, and ``<major>`` is the major version number.
+Each client must choose a unique ``<client>`` identifier via its
+own means.
+
+Files of this form are stateless queries owned by the client ``<client>``.
+The owning client may remove them at any time.
+
+v1 Client Stateful Query Files
+------------------------------
+
+Stateful query files allow clients to request a list of versions of
+each of the `Object Kinds`_ and get only the most recent version
+recognized by the CMake that runs.
+
+Clients may create owned stateful queries by creating ``query.json``
+files in client-specific query subdirectories. The form is::
+
+ <build>/.cmake/api/v1/query/client-<client>/query.json
+
+where ``client-`` is literal, ``<client>`` is a string uniquely
+identifying the client, and ``query.json`` is literal. Each client
+must choose a unique ``<client>`` identifier via its own means.
+
+``query.json`` files are stateful queries owned by the client ``<client>``.
+The owning client may update or remove them at any time. When a
+given client installation is updated it may then update the stateful
+query it writes to build trees to request newer object versions.
+This can be used to avoid asking CMake to generate multiple object
+versions unnecessarily.
+
+A ``query.json`` file must contain a JSON object:
+
+.. code-block:: json
+
+ {
+ "requests": [
+ { "kind": "<kind>" , "version": 1 },
+ { "kind": "<kind>" , "version": { "major": 1, "minor": 2 } },
+ { "kind": "<kind>" , "version": [2, 1] },
+ { "kind": "<kind>" , "version": [2, { "major": 1, "minor": 2 }] },
+ { "kind": "<kind>" , "version": 1, "client": {} },
+ { "kind": "..." }
+ ],
+ "client": {}
+ }
+
+The members are:
+
+``requests``
+ A JSON array containing zero or more requests. Each request is
+ a JSON object with members:
+
+ ``kind``
+ Specifies one of the `Object Kinds`_ to be included in the reply.
+
+ ``version``
+ Indicates the version(s) of the object kind that the client
+ understands. Versions have major and minor components following
+ semantic version conventions. The value must be
+
+ * a JSON integer specifying a (non-negative) major version number, or
+ * a JSON object containing ``major`` and (optionally) ``minor``
+ members specifying non-negative integer version components, or
+ * a JSON array whose elements are each one of the above.
+
+ ``client``
+ Optional member reserved for use by the client. This value is
+ preserved in the reply written for the client in the
+ `v1 Reply Index File`_ but is otherwise ignored. Clients may use
+ this to pass custom information with a request through to its reply.
+
+ For each requested object kind CMake will choose the *first* version
+ that it recognizes for that kind among those listed in the request.
+ The response will use the selected *major* version with the highest
+ *minor* version known to the running CMake for that major version.
+ Therefore clients should list all supported major versions in
+ preferred order along with the minimal minor version required
+ for each major version.
+
+``client``
+ Optional member reserved for use by the client. This value is
+ preserved in the reply written for the client in the
+ `v1 Reply Index File`_ but is otherwise ignored. Clients may use
+ this to pass custom information with a query through to its reply.
+
+Other ``query.json`` top-level members are reserved for future use.
+If present they are ignored for forward compatibility.
+
+v1 Reply Index File
+-------------------
+
+CMake writes an ``index-*.json`` file to the ``v1/reply/`` directory
+whenever it runs to generate a build system. Clients must read the
+reply index file first and may read other `v1 Reply Files`_ only by
+following references. The form of the reply index file name is::
+
+ <build>/.cmake/api/v1/reply/index-<unspecified>.json
+
+where ``index-`` is literal and ``<unspecified>`` is an unspecified
+name selected by CMake. Whenever a new index file is generated it
+is given a new name and any old one is deleted. During the short
+time between these steps there may be multiple index files present;
+the one with the largest name in lexicographic order is the current
+index file.
+
+The reply index file contains a JSON object:
+
+.. code-block:: json
+
+ {
+ "cmake": {
+ "version": {
+ "major": 3, "minor": 14, "patch": 0, "suffix": "",
+ "string": "3.14.0", "isDirty": false
+ },
+ "paths": {
+ "cmake": "/prefix/bin/cmake",
+ "ctest": "/prefix/bin/ctest",
+ "cpack": "/prefix/bin/cpack",
+ "root": "/prefix/share/cmake-3.14"
+ },
+ "generator": {
+ "name": "Unix Makefiles"
+ }
+ },
+ "objects": [
+ { "kind": "<kind>",
+ "version": { "major": 1, "minor": 0 },
+ "jsonFile": "<file>" },
+ { "...": "..." }
+ ],
+ "reply": {
+ "<kind>-v<major>": { "kind": "<kind>",
+ "version": { "major": 1, "minor": 0 },
+ "jsonFile": "<file>" },
+ "<unknown>": { "error": "unknown query file" },
+ "...": {},
+ "client-<client>": {
+ "<kind>-v<major>": { "kind": "<kind>",
+ "version": { "major": 1, "minor": 0 },
+ "jsonFile": "<file>" },
+ "<unknown>": { "error": "unknown query file" },
+ "...": {},
+ "query.json": {
+ "requests": [ {}, {}, {} ],
+ "responses": [
+ { "kind": "<kind>",
+ "version": { "major": 1, "minor": 0 },
+ "jsonFile": "<file>" },
+ { "error": "unknown query file" },
+ { "...": {} }
+ ],
+ "client": {}
+ }
+ }
+ }
+ }
+
+The members are:
+
+``cmake``
+ A JSON object containing information about the instance of CMake that
+ generated the reply. It contains members:
+
+ ``version``
+ A JSON object specifying the version of CMake with members:
+
+ ``major``, ``minor``, ``patch``
+ Integer values specifying the major, minor, and patch version components.
+ ``suffix``
+ A string specifying the version suffix, if any, e.g. ``g0abc3``.
+ ``string``
+ A string specifying the full version in the format
+ ``<major>.<minor>.<patch>[-<suffix>]``.
+ ``isDirty``
+ A boolean indicating whether the version was built from a version
+ controlled source tree with local modifications.
+
+ ``paths``
+ A JSON object specifying paths to things that come with CMake.
+ It has members for ``cmake``, ``ctest``, and ``cpack`` whose values
+ are JSON strings specifying the absolute path to each tool,
+ represented with forward slashes. It also has a ``root`` member for
+ the absolute path to the directory containing CMake resources like the
+ ``Modules/`` directory (see :variable:`CMAKE_ROOT`).
+
+ ``generator``
+ A JSON object describing the CMake generator used for the build.
+ It has members:
+
+ ``name``
+ A string specifying the name of the generator.
+ ``platform``
+ If the generator supports :variable:`CMAKE_GENERATOR_PLATFORM`,
+ this is a string specifying the generator platform name.
+
+``objects``
+ A JSON array listing all versions of all `Object Kinds`_ generated
+ as part of the reply. Each array entry is a
+ `v1 Reply File Reference`_.
+
+``reply``
+ A JSON object mirroring the content of the ``query/`` directory
+ that CMake loaded to produce the reply. The members are of the form
+
+ ``<kind>-v<major>``
+ A member of this form appears for each of the
+ `v1 Shared Stateless Query Files`_ that CMake recognized as a
+ request for object kind ``<kind>`` with major version ``<major>``.
+ The value is a `v1 Reply File Reference`_ to the corresponding
+ reply file for that object kind and version.
+
+ ``<unknown>``
+ A member of this form appears for each of the
+ `v1 Shared Stateless Query Files`_ that CMake did not recognize.
+ The value is a JSON object with a single ``error`` member
+ containing a string with an error message indicating that the
+ query file is unknown.
+
+ ``client-<client>``
+ A member of this form appears for each client-owned directory
+ holding `v1 Client Stateless Query Files`_.
+ The value is a JSON object mirroring the content of the
+ ``query/client-<client>/`` directory. The members are of the form:
+
+ ``<kind>-v<major>``
+ A member of this form appears for each of the
+ `v1 Client Stateless Query Files`_ that CMake recognized as a
+ request for object kind ``<kind>`` with major version ``<major>``.
+ The value is a `v1 Reply File Reference`_ to the corresponding
+ reply file for that object kind and version.
+
+ ``<unknown>``
+ A member of this form appears for each of the
+ `v1 Client Stateless Query Files`_ that CMake did not recognize.
+ The value is a JSON object with a single ``error`` member
+ containing a string with an error message indicating that the
+ query file is unknown.
+
+ ``query.json``
+ This member appears for clients using
+ `v1 Client Stateful Query Files`_.
+ If the ``query.json`` file failed to read or parse as a JSON object,
+ this member is a JSON object with a single ``error`` member
+ containing a string with an error message. Otherwise, this member
+ is a JSON object mirroring the content of the ``query.json`` file.
+ The members are:
+
+ ``client``
+ A copy of the ``query.json`` file ``client`` member, if it exists.
+
+ ``requests``
+ A copy of the ``query.json`` file ``requests`` member, if it exists.
+
+ ``responses``
+ If the ``query.json`` file ``requests`` member is missing or invalid,
+ this member is a JSON object with a single ``error`` member
+ containing a string with an error message. Otherwise, this member
+ contains a JSON array with a response for each entry of the
+ ``requests`` array, in the same order. Each response is
+
+ * a JSON object with a single ``error`` member containing a string
+ with an error message, or
+ * a `v1 Reply File Reference`_ to the corresponding reply file for
+ the requested object kind and selected version.
+
+After reading the reply index file, clients may read the other
+`v1 Reply Files`_ it references.
+
+v1 Reply File Reference
+^^^^^^^^^^^^^^^^^^^^^^^
+
+The reply index file represents each reference to another reply file
+using a JSON object with members:
+
+``kind``
+ A string specifying one of the `Object Kinds`_.
+``version``
+ A JSON object with members ``major`` and ``minor`` specifying
+ integer version components of the object kind.
+``jsonFile``
+ A JSON string specifying a path relative to the reply index file
+ to another JSON file containing the object.
+
+v1 Reply Files
+--------------
+
+Reply files containing specific `Object Kinds`_ are written by CMake.
+The names of these files are unspecified and must not be interpreted
+by clients. Clients must first read the `v1 Reply Index File`_ and
+and follow references to the names of the desired response objects.
+
+Reply files (including the index file) will never be replaced by
+files of the same name but different content. This allows a client
+to read the files concurrently with a running CMake that may generate
+a new reply. However, after generating a new reply CMake will attempt
+to remove reply files from previous runs that it did not just write.
+If a client attempts to read a reply file referenced by the index but
+finds the file missing, that means a concurrent CMake has generated
+a new reply. The client may simply start again by reading the new
+reply index file.
+
+.. _`file-api object kinds`:
+
+Object Kinds
+============
+
+The CMake file-based API reports semantic information about the build
+system using the following kinds of JSON objects. Each kind of object
+is versioned independently using semantic versioning with major and
+minor components. Every kind of object has the form:
+
+.. code-block:: json
+
+ {
+ "kind": "<kind>",
+ "version": { "major": 1, "minor": 0 },
+ "...": {}
+ }
+
+The ``kind`` member is a string specifying the object kind name.
+The ``version`` member is a JSON object with ``major`` and ``minor``
+members specifying integer components of the object kind's version.
+Additional top-level members are specific to each object kind.
+
+Object Kind "codemodel"
+-----------------------
+
+The ``codemodel`` object kind describes the build system structure as
+modeled by CMake.
+
+There is only one ``codemodel`` object major version, version 2.
+Version 1 does not exist to avoid confusion with that from
+:manual:`cmake-server(7)` mode.
+
+"codemodel" version 2
+^^^^^^^^^^^^^^^^^^^^^
+
+``codemodel`` object version 2 is a JSON object:
+
+.. code-block:: json
+
+ {
+ "kind": "codemodel",
+ "version": { "major": 2, "minor": 0 },
+ "paths": {
+ "source": "/path/to/top-level-source-dir",
+ "build": "/path/to/top-level-build-dir"
+ },
+ "configurations": [
+ {
+ "name": "Debug",
+ "directories": [
+ {
+ "source": ".",
+ "build": ".",
+ "childIndexes": [ 1 ],
+ "projectIndex": 0,
+ "targetIndexes": [ 0 ],
+ "hasInstallRule": true,
+ "minimumCMakeVersion": {
+ "string": "3.14"
+ }
+ },
+ {
+ "source": "sub",
+ "build": "sub",
+ "parentIndex": 0,
+ "projectIndex": 0,
+ "targetIndexes": [ 1 ],
+ "minimumCMakeVersion": {
+ "string": "3.14"
+ }
+ }
+ ],
+ "projects": [
+ {
+ "name": "MyProject",
+ "directoryIndexes": [ 0, 1 ],
+ "targetIndexes": [ 0, 1 ]
+ }
+ ],
+ "targets": [
+ {
+ "name": "MyExecutable",
+ "directoryIndex": 0,
+ "projectIndex": 0,
+ "jsonFile": "<file>"
+ },
+ {
+ "name": "MyLibrary",
+ "directoryIndex": 1,
+ "projectIndex": 0,
+ "jsonFile": "<file>"
+ }
+ ]
+ }
+ ]
+ }
+
+The members specific to ``codemodel`` objects are:
+
+``paths``
+ A JSON object containing members:
+
+ ``source``
+ A string specifying the absolute path to the top-level source directory,
+ represented with forward slashes.
+
+ ``build``
+ A string specifying the absolute path to the top-level build directory,
+ represented with forward slashes.
+
+``configurations``
+ A JSON array of entries corresponding to available build configurations.
+ On single-configuration generators there is one entry for the value
+ of the :variable:`CMAKE_BUILD_TYPE` variable. For multi-configuration
+ generators there is an entry for each configuration listed in the
+ :variable:`CMAKE_CONFIGURATION_TYPES` variable.
+ Each entry is a JSON object containing members:
+
+ ``name``
+ A string specifying the name of the configuration, e.g. ``Debug``.
+
+ ``directories``
+ A JSON array of entries each corresponding to a build system directory
+ whose source directory contains a ``CMakeLists.txt`` file. The first
+ entry corresponds to the top-level directory. Each entry is a
+ JSON object containing members:
+
+ ``source``
+ A string specifying the path to the source directory, represented
+ with forward slashes. If the directory is inside the top-level
+ source directory then the path is specified relative to that
+ directory (with ``.`` for the top-level source directory itself).
+ Otherwise the path is absolute.
+
+ ``build``
+ A string specifying the path to the build directory, represented
+ with forward slashes. If the directory is inside the top-level
+ build directory then the path is specified relative to that
+ directory (with ``.`` for the top-level build directory itself).
+ Otherwise the path is absolute.
+
+ ``parentIndex``
+ Optional member that is present when the directory is not top-level.
+ The value is an unsigned integer 0-based index of another entry in
+ the main ``directories`` array that corresponds to the parent
+ directory that added this directory as a subdirectory.
+
+ ``childIndexes``
+ Optional member that is present when the directory has subdirectories.
+ The value is a JSON array of entries corresponding to child directories
+ created by the :command:`add_subdirectory` or :command:`subdirs`
+ command. Each entry is an unsigned integer 0-based index of another
+ entry in the main ``directories`` array.
+
+ ``projectIndex``
+ An unsigned integer 0-based index into the main ``projects`` array
+ indicating the build system project to which the this directory belongs.
+
+ ``targetIndexes``
+ Optional member that is present when the directory itself has targets,
+ excluding those belonging to subdirectories. The value is a JSON
+ array of entries corresponding to the targets. Each entry is an
+ unsigned integer 0-based index into the main ``targets`` array.
+
+ ``minimumCMakeVersion``
+ Optional member present when a minimum required version of CMake is
+ known for the directory. This is the ``<min>`` version given to the
+ most local call to the :command:`cmake_minimum_required(VERSION)`
+ command in the directory itself or one of its ancestors.
+ The value is a JSON object with one member:
+
+ ``string``
+ A string specifying the minimum required version in the format::
+
+ <major>.<minor>[.<patch>[.<tweak>]][<suffix>]
+
+ Each component is an unsigned integer and the suffix may be an
+ arbitrary string.
+
+ ``hasInstallRule``
+ Optional member that is present with boolean value ``true`` when
+ the directory or one of its subdirectories contains any
+ :command:`install` rules, i.e. whether a ``make install``
+ or equivalent rule is available.
+
+ ``projects``
+ A JSON array of entries corresponding to the top-level project
+ and sub-projects defined in the build system. Each (sub-)project
+ corresponds to a source directory whose ``CMakeLists.txt`` file
+ calls the :command:`project` command with a project name different
+ from its parent directory. The first entry corresponds to the
+ top-level project.
+
+ Each entry is a JSON object containing members:
+
+ ``name``
+ A string specifying the name given to the :command:`project` command.
+
+ ``parentIndex``
+ Optional member that is present when the project is not top-level.
+ The value is an unsigned integer 0-based index of another entry in
+ the main ``projects`` array that corresponds to the parent project
+ that added this project as a sub-project.
+
+ ``childIndexes``
+ Optional member that is present when the project has sub-projects.
+ The value is a JSON array of entries corresponding to the sub-projects.
+ Each entry is an unsigned integer 0-based index of another
+ entry in the main ``projects`` array.
+
+ ``directoryIndexes``
+ A JSON array of entries corresponding to build system directories
+ that are part of the project. The first entry corresponds to the
+ top-level directory of the project. Each entry is an unsigned
+ integer 0-based index into the main ``directories`` array.
+
+ ``targetIndexes``
+ Optional member that is present when the project itself has targets,
+ excluding those belonging to sub-projects. The value is a JSON
+ array of entries corresponding to the targets. Each entry is an
+ unsigned integer 0-based index into the main ``targets`` array.
+
+ ``targets``
+ A JSON array of entries corresponding to the build system targets.
+ Such targets are created by calls to :command:`add_executable`,
+ :command:`add_library`, and :command:`add_custom_target`, excluding
+ imported targets and interface libraries (which do not generate any
+ build rules). Each entry is a JSON object containing members:
+
+ ``name``
+ A string specifying the target name.
+
+ ``id``
+ A string uniquely identifying the target. This matches the ``id``
+ field in the file referenced by ``jsonFile``.
+
+ ``directoryIndex``
+ An unsigned integer 0-based index into the main ``directories`` array
+ indicating the build system directory in which the target is defined.
+
+ ``projectIndex``
+ An unsigned integer 0-based index into the main ``projects`` array
+ indicating the build system project in which the target is defined.
+
+ ``jsonFile``
+ A JSON string specifying a path relative to the codemodel file
+ to another JSON file containing a
+ `"codemodel" version 2 "target" object`_.
+
+"codemodel" version 2 "target" object
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+A codemodel "target" object is referenced by a `"codemodel" version 2`_
+object's ``targets`` array. Each "target" object is a JSON object
+with members:
+
+``name``
+ A string specifying the logical name of the target.
+
+``id``
+ A string uniquely identifying the target. The format is unspecified
+ and should not be interpreted by clients.
+
+``type``
+ A string specifying the type of the target. The value is one of
+ ``EXECUTABLE``, ``STATIC_LIBRARY``, ``SHARED_LIBRARY``,
+ ``MODULE_LIBRARY``, ``OBJECT_LIBRARY``, or ``UTILITY``.
+
+``backtrace``
+ Optional member that is present when a CMake language backtrace to
+ the command in the source code that created the target is available.
+ The value is an unsigned integer 0-based index into the
+ ``backtraceGraph`` member's ``nodes`` array.
+
+``folder``
+ Optional member that is present when the :prop_tgt:`FOLDER` target
+ property is set. The value is a JSON object with one member:
+
+ ``name``
+ A string specifying the name of the target folder.
+
+``paths``
+ A JSON object containing members:
+
+ ``source``
+ A string specifying the path to the target's source directory,
+ represented with forward slashes. If the directory is inside the
+ top-level source directory then the path is specified relative to
+ that directory (with ``.`` for the top-level source directory itself).
+ Otherwise the path is absolute.
+
+ ``build``
+ A string specifying the path to the target's build directory,
+ represented with forward slashes. If the directory is inside the
+ top-level build directory then the path is specified relative to
+ that directory (with ``.`` for the top-level build directory itself).
+ Otherwise the path is absolute.
+
+``nameOnDisk``
+ Optional member that is present for executable and library targets
+ that are linked or archived into a single primary artifact.
+ The value is a string specifying the file name of that artifact on disk.
+
+``artifacts``
+ Optional member that is present for executable and library targets
+ that produce artifacts on disk meant for consumption by dependents.
+ The value is a JSON array of entries corresponding to the artifacts.
+ Each entry is a JSON object containing one member:
+
+ ``path``
+ A string specifying the path to the file on disk, represented with
+ forward slashes. If the file is inside the top-level build directory
+ then the path is specified relative to that directory.
+ Otherwise the path is absolute.
+
+``isGeneratorProvided``
+ Optional member that is present with boolean value ``true`` if the
+ target is provided by CMake's build system generator rather than by
+ a command in the source code.
+
+``install``
+ Optional member that is present when the target has an :command:`install`
+ rule. The value is a JSON object with members:
+
+ ``prefix``
+ A JSON object specifying the installation prefix. It has one member:
+
+ ``path``
+ A string specifying the value of :variable:`CMAKE_INSTALL_PREFIX`.
+
+ ``destinations``
+ A JSON array of entries specifying an install destination path.
+ Each entry is a JSON object with members:
+
+ ``path``
+ A string specifying the install destination path. The path may
+ be absolute or relative to the install prefix.
+
+ ``backtrace``
+ Optional member that is present when a CMake language backtrace to
+ the :command:`install` command invocation that specified this
+ destination is available. The value is an unsigned integer 0-based
+ index into the ``backtraceGraph`` member's ``nodes`` array.
+
+``link``
+ Optional member that is present for executables and shared library
+ targets that link into a runtime binary. The value is a JSON object
+ with members describing the link step:
+
+ ``language``
+ A string specifying the language (e.g. ``C``, ``CXX``, ``Fortran``)
+ of the toolchain is used to invoke the linker.
+
+ ``commandFragments``
+ Optional member that is present when fragments of the link command
+ line invocation are available. The value is a JSON array of entries
+ specifying ordered fragments. Each entry is a JSON object with members:
+
+ ``fragment``
+ A string specifying a fragment of the link command line invocation.
+ The value is encoded in the build system's native shell format.
+
+ ``role``
+ A string specifying the role of the fragment's content:
+
+ * ``flags``: link flags.
+ * ``libraries``: link library file paths or flags.
+ * ``libraryPath``: library search path flags.
+ * ``frameworkPath``: macOS framework search path flags.
+
+ ``lto``
+ Optional member that is present with boolean value ``true``
+ when link-time optimization (a.k.a. interprocedural optimization
+ or link-time code generation) is enabled.
+
+ ``sysroot``
+ Optional member that is present when the :variable:`CMAKE_SYSROOT_LINK`
+ or :variable:`CMAKE_SYSROOT` variable is defined. The value is a
+ JSON object with one member:
+
+ ``path``
+ A string specifying the absolute path to the sysroot, represented
+ with forward slashes.
+
+``archive``
+ Optional member that is present for static library targets. The value
+ is a JSON object with members describing the archive step:
+
+ ``commandFragments``
+ Optional member that is present when fragments of the archiver command
+ line invocation are available. The value is a JSON array of entries
+ specifying the fragments. Each entry is a JSON object with members:
+
+ ``fragment``
+ A string specifying a fragment of the archiver command line invocation.
+ The value is encoded in the build system's native shell format.
+
+ ``role``
+ A string specifying the role of the fragment's content:
+
+ * ``flags``: archiver flags.
+
+ ``lto``
+ Optional member that is present with boolean value ``true``
+ when link-time optimization (a.k.a. interprocedural optimization
+ or link-time code generation) is enabled.
+
+``dependencies``
+ Optional member that is present when the target depends on other targets.
+ The value is a JSON array of entries corresponding to the dependencies.
+ Each entry is a JSON object with members:
+
+ ``id``
+ A string uniquely identifying the target on which this target depends.
+ This matches the main ``id`` member of the other target.
+
+ ``backtrace``
+ Optional member that is present when a CMake language backtrace to
+ the :command:`add_dependencies`, :command:`target_link_libraries`,
+ or other command invocation that created this dependency is
+ available. The value is an unsigned integer 0-based index into
+ the ``backtraceGraph`` member's ``nodes`` array.
+
+``sources``
+ A JSON array of entries corresponding to the target's source files.
+ Each entry is a JSON object with members:
+
+ ``path``
+ A string specifying the path to the source file on disk, represented
+ with forward slashes. If the file is inside the top-level source
+ directory then the path is specified relative to that directory.
+ Otherwise the path is absolute.
+
+ ``compileGroupIndex``
+ Optional member that is present when the source is compiled.
+ The value is an unsigned integer 0-based index into the
+ ``compileGroups`` array.
+
+ ``sourceGroupIndex``
+ Optional member that is present when the source is part of a source
+ group either via the :command:`source_group` command or by default.
+ The value is an unsigned integer 0-based index into the
+ ``sourceGroups`` array.
+
+ ``isGenerated``
+ Optional member that is present with boolean value ``true`` if
+ the source is :prop_sf:`GENERATED`.
+
+ ``backtrace``
+ Optional member that is present when a CMake language backtrace to
+ the :command:`target_sources`, :command:`add_executable`,
+ :command:`add_library`, :command:`add_custom_target`, or other
+ command invocation that added this source to the target is
+ available. The value is an unsigned integer 0-based index into
+ the ``backtraceGraph`` member's ``nodes`` array.
+
+``sourceGroups``
+ Optional member that is present when sources are grouped together by
+ the :command:`source_group` command or by default. The value is a
+ JSON array of entries corresponding to the groups. Each entry is
+ a JSON object with members:
+
+ ``name``
+ A string specifying the name of the source group.
+
+ ``sourceIndexes``
+ A JSON array listing the sources belonging to the group.
+ Each entry is an unsigned integer 0-based index into the
+ main ``sources`` array for the target.
+
+``compileGroups``
+ Optional member that is present when the target has sources that compile.
+ The value is a JSON array of entries corresponding to groups of sources
+ that all compile with the same settings. Each entry is a JSON object
+ with members:
+
+ ``sourceIndexes``
+ A JSON array listing the sources belonging to the group.
+ Each entry is an unsigned integer 0-based index into the
+ main ``sources`` array for the target.
+
+ ``language``
+ A string specifying the language (e.g. ``C``, ``CXX``, ``Fortran``)
+ of the toolchain is used to compile the source file.
+
+ ``compileCommandFragments``
+ Optional member that is present when fragments of the compiler command
+ line invocation are available. The value is a JSON array of entries
+ specifying ordered fragments. Each entry is a JSON object with
+ one member:
+
+ ``fragment``
+ A string specifying a fragment of the compile command line invocation.
+ The value is encoded in the build system's native shell format.
+
+ ``includes``
+ Optional member that is present when there are include directories.
+ The value is a JSON array with an entry for each directory. Each
+ entry is a JSON object with members:
+
+ ``path``
+ A string specifying the path to the include directory,
+ represented with forward slashes.
+
+ ``isSystem``
+ Optional member that is present with boolean value ``true`` if
+ the include directory is marked as a system include directory.
+
+ ``backtrace``
+ Optional member that is present when a CMake language backtrace to
+ the :command:`target_include_directories` or other command invocation
+ that added this include directory is available. The value is
+ an unsigned integer 0-based index into the ``backtraceGraph``
+ member's ``nodes`` array.
+
+ ``defines``
+ Optional member that is present when there are preprocessor definitions.
+ The value is a JSON array with an entry for each definition. Each
+ entry is a JSON object with members:
+
+ ``define``
+ A string specifying the preprocessor definition in the format
+ ``<name>[=<value>]``, e.g. ``DEF`` or ``DEF=1``.
+
+ ``backtrace``
+ Optional member that is present when a CMake language backtrace to
+ the :command:`target_compile_definitions` or other command invocation
+ that added this preprocessor definition is available. The value is
+ an unsigned integer 0-based index into the ``backtraceGraph``
+ member's ``nodes`` array.
+
+ ``sysroot``
+ Optional member that is present when the
+ :variable:`CMAKE_SYSROOT_COMPILE` or :variable:`CMAKE_SYSROOT`
+ variable is defined. The value is a JSON object with one member:
+
+ ``path``
+ A string specifying the absolute path to the sysroot, represented
+ with forward slashes.
+
+``backtraceGraph``
+ A JSON object describing the graph of backtraces whose nodes are
+ referenced from ``backtrace`` members elsewhere. The members are:
+
+ ``nodes``
+ A JSON array listing nodes in the backtrace graph. Each entry
+ is a JSON object with members:
+
+ ``file``
+ An unsigned integer 0-based index into the backtrace ``files`` array.
+
+ ``line``
+ An optional member present when the node represents a line within
+ the file. The value is an unsigned integer 1-based line number.
+
+ ``command``
+ An optional member present when the node represents a command
+ invocation within the file. The value is an unsigned integer
+ 0-based index into the backtrace ``commands`` array.
+
+ ``parent``
+ An optional member present when the node is not the bottom of
+ the call stack. The value is an unsigned integer 0-based index
+ of another entry in the backtrace ``nodes`` array.
+
+ ``commands``
+ A JSON array listing command names referenced by backtrace nodes.
+ Each entry is a string specifying a command name.
+
+ ``files``
+ A JSON array listing CMake language files referenced by backtrace nodes.
+ Each entry is a string specifying the path to a file, represented
+ with forward slashes. If the file is inside the top-level source
+ directory then the path is specified relative to that directory.
+ Otherwise the path is absolute.
+
+Object Kind "cache"
+-------------------
+
+The ``cache`` object kind lists cache entries. These are the
+:ref:`CMake Language Variables` stored in the persistent cache
+(``CMakeCache.txt``) for the build tree.
+
+There is only one ``cache`` object major version, version 2.
+Version 1 does not exist to avoid confusion with that from
+:manual:`cmake-server(7)` mode.
+
+"cache" version 2
+^^^^^^^^^^^^^^^^^
+
+``cache`` object version 2 is a JSON object:
+
+.. code-block:: json
+
+ {
+ "kind": "cache",
+ "version": { "major": 2, "minor": 0 },
+ "entries": [
+ {
+ "name": "BUILD_SHARED_LIBS",
+ "value": "ON",
+ "type": "BOOL",
+ "properties": [
+ {
+ "name": "HELPSTRING",
+ "value": "Build shared libraries"
+ }
+ ]
+ },
+ {
+ "name": "CMAKE_GENERATOR",
+ "value": "Unix Makefiles",
+ "type": "INTERNAL",
+ "properties": [
+ {
+ "name": "HELPSTRING",
+ "value": "Name of generator."
+ }
+ ]
+ }
+ ]
+ }
+
+The members specific to ``cache`` objects are:
+
+``entries``
+ A JSON array whose entries are each a JSON object specifying a
+ cache entry. The members of each entry are:
+
+ ``name``
+ A string specifying the name of the entry.
+
+ ``value``
+ A string specifying the value of the entry.
+
+ ``type``
+ A string specifying the type of the entry used by
+ :manual:`cmake-gui(1)` to choose a widget for editing.
+
+ ``properties``
+ A JSON array of entries specifying associated
+ :ref:`cache entry properties <Cache Entry Properties>`.
+ Each entry is a JSON object containing members:
+
+ ``name``
+ A string specifying the name of the cache entry property.
+
+ ``value``
+ A string specifying the value of the cache entry property.
+
+Object Kind "cmakeFiles"
+------------------------
+
+The ``cmakeFiles`` object kind lists files used by CMake while
+configuring and generating the build system. These include the
+``CMakeLists.txt`` files as well as included ``.cmake`` files.
+
+There is only one ``cmakeFiles`` object major version, version 1.
+
+"cmakeFiles" version 1
+^^^^^^^^^^^^^^^^^^^^^^
+
+``cmakeFiles`` object version 1 is a JSON object:
+
+.. code-block:: json
+
+ {
+ "kind": "cmakeFiles",
+ "version": { "major": 1, "minor": 0 },
+ "paths": {
+ "build": "/path/to/top-level-build-dir",
+ "source": "/path/to/top-level-source-dir"
+ },
+ "inputs": [
+ {
+ "path": "CMakeLists.txt"
+ },
+ {
+ "isGenerated": true,
+ "path": "/path/to/top-level-build-dir/.../CMakeSystem.cmake"
+ },
+ {
+ "isExternal": true,
+ "path": "/path/to/external/third-party/module.cmake"
+ },
+ {
+ "isCMake": true,
+ "isExternal": true,
+ "path": "/path/to/cmake/Modules/CMakeGenericSystem.cmake"
+ }
+ ]
+ }
+
+The members specific to ``cmakeFiles`` objects are:
+
+``paths``
+ A JSON object containing members:
+
+ ``source``
+ A string specifying the absolute path to the top-level source directory,
+ represented with forward slashes.
+
+ ``build``
+ A string specifying the absolute path to the top-level build directory,
+ represented with forward slashes.
+
+``inputs``
+ A JSON array whose entries are each a JSON object specifying an input
+ file used by CMake when configuring and generating the build system.
+ The members of each entry are:
+
+ ``path``
+ A string specifying the path to an input file to CMake, represented
+ with forward slashes. If the file is inside the top-level source
+ directory then the path is specified relative to that directory.
+ Otherwise the path is absolute.
+
+ ``isGenerated``
+ Optional member that is present with boolean value ``true``
+ if the path specifies a file that is under the top-level
+ build directory and the build is out-of-source.
+ This member is not available on in-source builds.
+
+ ``isExternal``
+ Optional member that is present with boolean value ``true``
+ if the path specifies a file that is not under the top-level
+ source or build directories.
+
+ ``isCMake``
+ Optional member that is present with boolean value ``true``
+ if the path specifies a file in the CMake installation.
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index bddb17477..75f4bd48a 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -20,54 +20,74 @@ commands to populate those properties, such as :command:`target_link_libraries`,
:command:`target_include_directories`, :command:`target_compile_definitions`
and others.
-This means that they enable conditional linking, conditional
-definitions used when compiling, and conditional include directories and
-more. The conditions may be based on the build configuration, target
-properties, platform information or any other queryable information.
+They enable conditional linking, conditional definitions used when compiling,
+conditional include directories, and more. The conditions may be based on
+the build configuration, target properties, platform information or any other
+queryable information.
-Logical Expressions
-===================
+Generator expressions have the form ``$<...>``. To avoid confusion, this page
+deviates from most of the CMake documentation in that it omits angular brackets
+``<...>`` around placeholders like ``condition``, ``string``, ``target``,
+among others.
-Logical expressions are used to create conditional output. The basic
-expressions are the ``0`` and ``1`` expressions. Because other logical
-expressions evaluate to either ``0`` or ``1``, they can be composed to
-create conditional output::
+Generator expressions can be nested, as shown in most of the examples below.
- $<$<CONFIG:Debug>:DEBUG_MODE>
+.. _`Boolean Generator Expressions`:
-expands to ``DEBUG_MODE`` when the ``Debug`` configuration is used, and
-otherwise expands to nothing.
-
-Available logical expressions are:
-
-``$<BOOL:...>``
- ``1`` if the ``...`` is true, else ``0``
-``$<AND:?[,?]...>``
- ``1`` if all ``?`` are ``1``, else ``0``
-
- The ``?`` must always be either ``0`` or ``1`` in boolean expressions.
-
-``$<OR:?[,?]...>``
- ``0`` if all ``?`` are ``0``, else ``1``
-``$<NOT:?>``
- ``0`` if ``?`` is ``1``, else ``1``
-``$<IF:?,true-value...,false-value...>```
- ``true-value...`` if ``?`` is ``1``, ``false-value...`` if ``?`` is ``0``
-``$<STREQUAL:a,b>``
- ``1`` if ``a`` is STREQUAL ``b``, else ``0``
-``$<EQUAL:a,b>``
- ``1`` if ``a`` is EQUAL ``b`` in a numeric comparison, else ``0``
-``$<CONFIG:cfg>``
- ``1`` if config is ``cfg``, else ``0``. This is a case-insensitive comparison.
- The mapping in :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` is also considered by
- this expression when it is evaluated on a property on an :prop_tgt:`IMPORTED`
- target.
-``$<PLATFORM_ID:comp>``
- ``1`` if the CMake-id of the platform matches ``comp``, otherwise ``0``.
-``$<C_COMPILER_ID:comp>``
- ``1`` if the CMake-id of the C compiler matches ``comp``, otherwise ``0``.
-``$<CXX_COMPILER_ID:comp>``
- ``1`` if the CMake-id of the CXX compiler matches ``comp``, otherwise ``0``.
+Boolean Generator Expressions
+=============================
+
+Boolean expressions evaluate to either ``0`` or ``1``.
+They are typically used to construct the condition in a :ref:`conditional
+generator expression<Conditional Generator Expressions>`.
+
+Available boolean expressions are:
+
+Logical Operators
+-----------------
+
+``$<BOOL:string>``
+ Converts ``string`` to ``0`` or ``1``. Evaluates to ``0`` if any of the
+ following is true:
+
+ * ``string`` is empty,
+ * ``string`` is a case-insensitive equal of
+ ``0``, ``FALSE``, ``OFF``, ``N``, ``NO``, ``IGNORE``, or ``NOTFOUND``, or
+ * ``string`` ends in the suffix ``-NOTFOUND`` (case-sensitive).
+
+ Otherwise evaluates to ``1``.
+
+``$<AND:conditions>``
+ where ``conditions`` is a comma-separated list of boolean expressions.
+ Evaluates to ``1`` if all conditions are ``1``.
+ Otherwise evaluates to ``0``.
+
+``$<OR:conditions>``
+ where ``conditions`` is a comma-separated list of boolean expressions.
+ Evaluates to ``1`` if at least one of the conditions is ``1``.
+ Otherwise evaluates to ``0``.
+
+``$<NOT:condition>``
+ ``0`` if ``condition`` is ``1``, else ``1``.
+
+String Comparisons
+------------------
+
+``$<STREQUAL:string1,string2>``
+ ``1`` if ``string1`` and ``string2`` are equal, else ``0``.
+ The comparison is case-sensitive. For a case-insensitive comparison,
+ combine with a :ref:`string transforming generator expression
+ <String Transforming Generator Expressions>`,
+
+ .. code-block:: cmake
+
+ $<STREQUAL:$<UPPER_CASE:${foo}>,"BAR"> # "1" if ${foo} is any of "BAR", "Bar", "bar", ...
+
+``$<EQUAL:value1,value2>``
+ ``1`` if ``value1`` and ``value2`` are numerically equal, else ``0``.
+``$<IN_LIST:string,list>``
+ ``1`` if ``string`` is member of the semicolon-separated ``list``, else ``0``.
+ Uses case-sensitive comparisons.
``$<VERSION_LESS:v1,v2>``
``1`` if ``v1`` is a version less than ``v2``, else ``0``.
``$<VERSION_GREATER:v1,v2>``
@@ -78,76 +98,185 @@ Available logical expressions are:
``1`` if ``v1`` is a version less than or equal to ``v2``, else ``0``.
``$<VERSION_GREATER_EQUAL:v1,v2>``
``1`` if ``v1`` is a version greater than or equal to ``v2``, else ``0``.
-``$<C_COMPILER_VERSION:ver>``
- ``1`` if the version of the C compiler matches ``ver``, otherwise ``0``.
-``$<CXX_COMPILER_VERSION:ver>``
- ``1`` if the version of the CXX compiler matches ``ver``, otherwise ``0``.
-``$<TARGET_POLICY:pol>``
- ``1`` if the policy ``pol`` was NEW when the 'head' target was created,
- else ``0``. If the policy was not set, the warning message for the policy
+
+
+Variable Queries
+----------------
+
+``$<TARGET_EXISTS:target>``
+ ``1`` if ``target`` exists, else ``0``.
+``$<CONFIG:cfg>``
+ ``1`` if config is ``cfg``, else ``0``. This is a case-insensitive comparison.
+ The mapping in :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` is also considered by
+ this expression when it is evaluated on a property on an :prop_tgt:`IMPORTED`
+ target.
+``$<PLATFORM_ID:platform_ids>``
+ where ``platform_ids`` is a comma-separated list.
+ ``1`` if the CMake's platform id matches any one of the entries in
+ ``platform_ids``, otherwise ``0``.
+ See also the :variable:`CMAKE_SYSTEM_NAME` variable.
+``$<C_COMPILER_ID:compiler_ids>``
+ where ``compiler_ids`` is a comma-separated list.
+ ``1`` if the CMake's compiler id of the C compiler matches any one
+ of the entries in ``compiler_ids``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+``$<CXX_COMPILER_ID:compiler_ids>``
+ where ``compiler_ids`` is a comma-separated list.
+ ``1`` if the CMake's compiler id of the CXX compiler matches any one
+ of the entries in ``compiler_ids``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+``$<CUDA_COMPILER_ID:compiler_ids>``
+ where ``compiler_ids`` is a comma-separated list.
+ ``1`` if the CMake's compiler id of the CUDA compiler matches any one
+ of the entries in ``compiler_ids``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+``$<OBJC_COMPILER_ID:compiler_ids>``
+ where ``compiler_ids`` is a comma-separated list.
+ ``1`` if the CMake's compiler id of the Objective-C compiler matches any one
+ of the entries in ``compiler_ids``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+``$<OBJCXX_COMPILER_ID:compiler_ids>``
+ where ``compiler_ids`` is a comma-separated list.
+ ``1`` if the CMake's compiler id of the Objective-C++ compiler matches any one
+ of the entries in ``compiler_ids``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+``$<Fortran_COMPILER_ID:compiler_ids>``
+ where ``compiler_ids`` is a comma-separated list.
+ ``1`` if the CMake's compiler id of the Fortran compiler matches any one
+ of the entries in ``compiler_ids``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+``$<C_COMPILER_VERSION:version>``
+ ``1`` if the version of the C compiler matches ``version``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+``$<CXX_COMPILER_VERSION:version>``
+ ``1`` if the version of the CXX compiler matches ``version``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+``$<CUDA_COMPILER_VERSION:version>``
+ ``1`` if the version of the CXX compiler matches ``version``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+``$<OBJC_COMPILER_VERSION:version>``
+ ``1`` if the version of the OBJC compiler matches ``version``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+``$<OBJCXX_COMPILER_VERSION:version>``
+ ``1`` if the version of the OBJCXX compiler matches ``version``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+``$<Fortran_COMPILER_VERSION:version>``
+ ``1`` if the version of the Fortran compiler matches ``version``, otherwise ``0``.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+``$<TARGET_POLICY:policy>``
+ ``1`` if the ``policy`` was NEW when the 'head' target was created,
+ else ``0``. If the ``policy`` was not set, the warning message for the policy
will be emitted. This generator expression only works for a subset of
policies.
-``$<COMPILE_FEATURES:feature[,feature]...>``
- ``1`` if all of the ``feature`` features are available for the 'head'
+``$<COMPILE_FEATURES:features>``
+ where ``features`` is a comma-spearated list.
+ Evaluates to ``1`` if all of the ``features`` are available for the 'head'
target, and ``0`` otherwise. If this expression is used while evaluating
the link implementation of a target and if any dependency transitively
increases the required :prop_tgt:`C_STANDARD` or :prop_tgt:`CXX_STANDARD`
for the 'head' target, an error is reported. See the
:manual:`cmake-compile-features(7)` manual for information on
compile features and a list of supported compilers.
-``$<COMPILE_LANGUAGE:lang>``
- ``1`` when the language used for compilation unit matches ``lang``,
- otherwise ``0``. This expression used to specify compile options for
- source files of a particular language in a target. For example, to specify
- the use of the ``-fno-exceptions`` compile option (compiler id checks
- elided):
+
+.. _`Boolean COMPILE_LANGUAGE Generator Expression`:
+
+``$<COMPILE_LANG_AND_ID:language,compiler_ids>``
+ ``1`` when the language used for compilation unit matches ``language`` and
+ the CMake's compiler id of the language compiler matches any one of the
+ entries in ``compiler_ids``, otherwise ``0``. This expression is a short form
+ for the combination of ``$<COMPILE_LANGUAGE:language>`` and
+ ``$<LANG_COMPILER_ID:compiler_ids>``. This expression may be used to specify
+ compile options, compile definitions, and include directories for source files of a
+ particular language and compiler combination in a target. For example:
.. code-block:: cmake
- add_executable(myapp main.cpp foo.c bar.cpp)
- target_compile_options(myapp
- PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
+ add_executable(myapp main.cpp foo.c bar.cpp zot.cu)
+ target_compile_definitions(myapp
+ PRIVATE $<$<COMPILE_LANG_AND_ID:CXX,AppleClang,Clang>:COMPILING_CXX_WITH_CLANG>
+ $<$<COMPILE_LANG_AND_ID:CXX,Intel>:COMPILING_CXX_WITH_INTEL>
+ $<$<COMPILE_LANG_AND_ID:C,Clang>:COMPILING_C_WITH_CLANG>
)
- This generator expression has limited use because it is not possible to
- use it with the Visual Studio generators. Portable buildsystems would
- not use this expression, and would create separate libraries for each
- source file language instead:
+ This specifies the use of different compile definitions based on both
+ the compiler id and compilation language. This example will have a
+ ``COMPILING_CXX_WITH_CLANG`` compile definition when Clang is the CXX
+ compiler, and ``COMPILING_CXX_WITH_INTEL`` when Intel is the CXX compiler.
+ Likewise when the C compiler is Clang it will only see the ``COMPILING_C_WITH_CLANG``
+ definition.
+
+ Without the ``COMPILE_LANG_AND_ID`` generator expression the same logic
+ would be expressed as:
.. code-block:: cmake
- add_library(myapp_c foo.c)
- add_library(myapp_cxx bar.cpp)
- target_compile_options(myapp_cxx PUBLIC -fno-exceptions)
- add_executable(myapp main.cpp)
- target_link_libraries(myapp myapp_c myapp_cxx)
+ target_compile_definitions(myapp
+ PRIVATE $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:AppleClang,Clang>>:COMPILING_CXX_WITH_CLANG>
+ $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:Intel>>:COMPILING_CXX_WITH_INTEL>
+ $<$<AND:$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:Clang>>:COMPILING_C_WITH_CLANG>
+ )
- The ``Makefile`` and ``Ninja`` based generators can also use this
- expression to specify compile-language specific compile definitions
- and include directories:
+``$<COMPILE_LANGUAGE:languages>``
+ ``1`` when the language used for compilation unit matches any of the entries
+ in ``languages``, otherwise ``0``. This expression may be used to specify
+ compile options, compile definitions, and include directories for source files of a
+ particular language in a target. For example:
.. code-block:: cmake
- add_executable(myapp main.cpp foo.c bar.cpp)
+ add_executable(myapp main.cpp foo.c bar.cpp zot.cu)
+ target_compile_options(myapp
+ PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
+ )
target_compile_definitions(myapp
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:COMPILING_CXX>
+ $<$<COMPILE_LANGUAGE:CUDA>:COMPILING_CUDA>
)
target_include_directories(myapp
- PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/opt/foo/cxx_headers>
+ PRIVATE $<$<COMPILE_LANGUAGE:CXX,CUDA>:/opt/foo/headers>
)
-Informational Expressions
-=========================
+ This specifies the use of the ``-fno-exceptions`` compile option,
+ ``COMPILING_CXX`` compile definition, and ``cxx_headers`` include
+ directory for C++ only (compiler id checks elided). It also specifies
+ a ``COMPILING_CUDA`` compile definition for CUDA.
+
+ Note that with :ref:`Visual Studio Generators` and :generator:`Xcode` there
+ is no way to represent target-wide compile definitions or include directories
+ separately for ``C`` and ``CXX`` languages.
+ Also, with :ref:`Visual Studio Generators` there is no way to represent
+ target-wide flags separately for ``C`` and ``CXX`` languages. Under these
+ generators, expressions for both C and C++ sources will be evaluated
+ using ``CXX`` if there are any C++ sources and otherwise using ``C``.
+ A workaround is to create separate libraries for each source file language
+ instead:
-These expressions expand to some information. The information may be used
-directly, eg::
+ .. code-block:: cmake
+
+ add_library(myapp_c foo.c)
+ add_library(myapp_cxx bar.cpp)
+ target_compile_options(myapp_cxx PUBLIC -fno-exceptions)
+ add_executable(myapp main.cpp)
+ target_link_libraries(myapp myapp_c myapp_cxx)
+
+String-Valued Generator Expressions
+===================================
+
+These expressions expand to some string.
+For example,
+
+.. code-block:: cmake
include_directories(/usr/include/$<CXX_COMPILER_ID>/)
expands to ``/usr/include/GNU/`` or ``/usr/include/Clang/`` etc, depending on
-the Id of the compiler.
+the compiler identifier.
+
+String-valued expressions may also be combined with other expressions.
+Here an example for a string-valued expression within a boolean expressions
+within a conditional expression:
-These expressions may also may be combined with logical expressions::
+.. code-block:: cmake
$<$<VERSION_LESS:$<CXX_COMPILER_VERSION>,4.2.0>:OLD_COMPILER>
@@ -155,20 +284,147 @@ expands to ``OLD_COMPILER`` if the
:variable:`CMAKE_CXX_COMPILER_VERSION <CMAKE_<LANG>_COMPILER_VERSION>` is less
than 4.2.0.
-Available informational expressions are:
+And here two nested string-valued expressions:
+
+.. code-block:: cmake
+
+ -I$<JOIN:$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>, -I>
+
+generates a string of the entries in the :prop_tgt:`INCLUDE_DIRECTORIES` target
+property with each entry preceded by ``-I``.
+
+Expanding on the previous example, if one first wants to check if the
+``INCLUDE_DIRECTORIES`` property is non-empty, then it is advisable to
+introduce a helper variable to keep the code readable:
+
+.. code-block:: cmake
+
+ set(prop "$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>") # helper variable
+ $<$<BOOL:${prop}>:-I$<JOIN:${prop}, -I>>
+
+The following string-valued generator expressions are available:
+
+Escaped Characters
+------------------
+
+String literals to escape the special meaning a character would otherwise have:
+
+``$<ANGLE-R>``
+ A literal ``>``. Used for example to compare strings that contain a ``>``.
+``$<COMMA>``
+ A literal ``,``. Used for example to compare strings which contain a ``,``.
+``$<SEMICOLON>``
+ A literal ``;``. Used to prevent list expansion on an argument with ``;``.
+
+.. _`Conditional Generator Expressions`:
+
+Conditional Expressions
+-----------------------
+
+Conditional generator expressions depend on a boolean condition
+that must be ``0`` or ``1``.
+
+``$<condition:true_string>``
+ Evaluates to ``true_string`` if ``condition`` is ``1``.
+ Otherwise evaluates to the empty string.
+
+``$<IF:condition,true_string,false_string>``
+ Evaluates to ``true_string`` if ``condition`` is ``1``.
+ Otherwise evaluates to ``false_string``.
+
+Typically, the ``condition`` is a :ref:`boolean generator expression
+<Boolean Generator Expressions>`. For instance,
+
+.. code-block:: cmake
+
+ $<$<CONFIG:Debug>:DEBUG_MODE>
+
+expands to ``DEBUG_MODE`` when the ``Debug`` configuration is used, and
+otherwise expands to the empty string.
+
+.. _`String Transforming Generator Expressions`:
+
+String Transformations
+----------------------
+
+``$<JOIN:list,string>``
+ Joins the list with the content of ``string``.
+``$<REMOVE_DUPLICATES:list>``
+ Removes duplicated items in the given ``list``.
+``$<FILTER:list,INCLUDE|EXCLUDE,regex>``
+ Includes or removes items from ``list`` that match the regular expression ``regex``.
+``$<LOWER_CASE:string>``
+ Content of ``string`` converted to lower case.
+``$<UPPER_CASE:string>``
+ Content of ``string`` converted to upper case.
+
+``$<GENEX_EVAL:expr>``
+ Content of ``expr`` evaluated as a generator expression in the current
+ context. This enables consumption of generator expressions whose
+ evaluation results itself in generator expressions.
+``$<TARGET_GENEX_EVAL:tgt,expr>``
+ Content of ``expr`` evaluated as a generator expression in the context of
+ ``tgt`` target. This enables consumption of custom target properties that
+ themselves contain generator expressions.
+
+ Having the capability to evaluate generator expressions is very useful when
+ you want to manage custom properties supporting generator expressions.
+ For example:
+
+ .. code-block:: cmake
+
+ add_library(foo ...)
+
+ set_property(TARGET foo PROPERTY
+ CUSTOM_KEYS $<$<CONFIG:DEBUG>:FOO_EXTRA_THINGS>
+ )
+
+ add_custom_target(printFooKeys
+ COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_PROPERTY:foo,CUSTOM_KEYS>
+ )
+
+ This naive implementation of the ``printFooKeys`` custom command is wrong
+ because ``CUSTOM_KEYS`` target property is not evaluated and the content
+ is passed as is (i.e. ``$<$<CONFIG:DEBUG>:FOO_EXTRA_THINGS>``).
+
+ To have the expected result (i.e. ``FOO_EXTRA_THINGS`` if config is
+ ``Debug``), it is required to evaluate the output of
+ ``$<TARGET_PROPERTY:foo,CUSTOM_KEYS>``:
+
+ .. code-block:: cmake
+
+ add_custom_target(printFooKeys
+ COMMAND ${CMAKE_COMMAND} -E
+ echo $<TARGET_GENEX_EVAL:foo,$<TARGET_PROPERTY:foo,CUSTOM_KEYS>>
+ )
+
+Variable Queries
+----------------
-``$<CONFIGURATION>``
- Configuration name. Deprecated. Use ``CONFIG`` instead.
``$<CONFIG>``
- Configuration name
+ Configuration name.
+``$<CONFIGURATION>``
+ Configuration name. Deprecated since CMake 3.0. Use ``CONFIG`` instead.
``$<PLATFORM_ID>``
- The CMake-id of the platform.
+ The current system's CMake platform id.
See also the :variable:`CMAKE_SYSTEM_NAME` variable.
``$<C_COMPILER_ID>``
- The CMake-id of the C compiler used.
+ The CMake's compiler id of the C compiler used.
See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
``$<CXX_COMPILER_ID>``
- The CMake-id of the CXX compiler used.
+ The CMake's compiler id of the CXX compiler used.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+``$<CUDA_COMPILER_ID>``
+ The CMake's compiler id of the CUDA compiler used.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+``$<OBJC_COMPILER_ID>``
+ The CMake's compiler id of the OBJC compiler used.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+``$<OBJCXX_COMPILER_ID>``
+ The CMake's compiler id of the OBJCXX compiler used.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+``$<Fortran_COMPILER_ID>``
+ The CMake's compiler id of the Fortran compiler used.
See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
``$<C_COMPILER_VERSION>``
The version of the C compiler used.
@@ -176,14 +432,111 @@ Available informational expressions are:
``$<CXX_COMPILER_VERSION>``
The version of the CXX compiler used.
See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+``$<CUDA_COMPILER_VERSION>``
+ The version of the CUDA compiler used.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+``$<OBJC_COMPILER_VERSION>``
+ The version of the OBJC compiler used.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+``$<OBJCXX_COMPILER_VERSION>``
+ The version of the OBJCXX compiler used.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+``$<Fortran_COMPILER_VERSION>``
+ The version of the Fortran compiler used.
+ See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
+``$<COMPILE_LANGUAGE>``
+ The compile language of source files when evaluating compile options.
+ See :ref:`the related boolean expression
+ <Boolean COMPILE_LANGUAGE Generator Expression>`
+ ``$<COMPILE_LANGUAGE:language>``
+ for notes about the portability of this generator expression.
+
+Target-Dependent Queries
+------------------------
+
+``$<TARGET_NAME_IF_EXISTS:tgt>``
+ Expands to the ``tgt`` if the given target exists, an empty string
+ otherwise.
``$<TARGET_FILE:tgt>``
- Full path to main file (.exe, .so.1.2, .a) where ``tgt`` is the name of a target.
+ Full path to main file (.exe, .so.1.2, .a) where ``tgt`` is the name of a
+ target.
+``$<TARGET_FILE_BASE_NAME:tgt>``
+ Base name of main file where ``tgt`` is the name of a target.
+
+ The base name corresponds to the target file name (see
+ ``$<TARGET_FILE_NAME:tgt>``) without prefix and suffix. For example, if
+ target file name is ``libbase.so``, the base name is ``base``.
+
+ See also the :prop_tgt:`OUTPUT_NAME`, :prop_tgt:`ARCHIVE_OUTPUT_NAME`,
+ :prop_tgt:`LIBRARY_OUTPUT_NAME` and :prop_tgt:`RUNTIME_OUTPUT_NAME`
+ target properties and their configuration specific variants
+ :prop_tgt:`OUTPUT_NAME_<CONFIG>`, :prop_tgt:`ARCHIVE_OUTPUT_NAME_<CONFIG>`,
+ :prop_tgt:`LIBRARY_OUTPUT_NAME_<CONFIG>` and
+ :prop_tgt:`RUNTIME_OUTPUT_NAME_<CONFIG>`.
+
+ The :prop_tgt:`<CONFIG>_POSTFIX` and :prop_tgt:`DEBUG_POSTFIX` target
+ properties can also be considered.
+
+ Note that ``tgt`` is not added as a dependency of the target this
+ expression is evaluated on.
+``$<TARGET_FILE_PREFIX:tgt>``
+ Prefix of main file where ``tgt`` is the name of a target.
+
+ See also the :prop_tgt:`PREFIX` target property.
+
+ Note that ``tgt`` is not added as a dependency of the target this
+ expression is evaluated on.
+``$<TARGET_FILE_SUFFIX:tgt>``
+ Suffix of main file where ``tgt`` is the name of a target.
+
+ The suffix corresponds to the file extension (such as ".so" or ".exe").
+
+ See also the :prop_tgt:`SUFFIX` target property.
+
+ Note that ``tgt`` is not added as a dependency of the target this
+ expression is evaluated on.
``$<TARGET_FILE_NAME:tgt>``
Name of main file (.exe, .so.1.2, .a).
``$<TARGET_FILE_DIR:tgt>``
Directory of main file (.exe, .so.1.2, .a).
``$<TARGET_LINKER_FILE:tgt>``
File used to link (.a, .lib, .so) where ``tgt`` is the name of a target.
+``$<TARGET_LINKER_FILE_BASE_NAME:tgt>``
+ Base name of file used to link where ``tgt`` is the name of a target.
+
+ The base name corresponds to the target linker file name (see
+ ``$<TARGET_LINKER_FILE_NAME:tgt>``) without prefix and suffix. For example,
+ if target file name is ``libbase.a``, the base name is ``base``.
+
+ See also the :prop_tgt:`OUTPUT_NAME`, :prop_tgt:`ARCHIVE_OUTPUT_NAME`,
+ and :prop_tgt:`LIBRARY_OUTPUT_NAME` target properties and their configuration
+ specific variants :prop_tgt:`OUTPUT_NAME_<CONFIG>`,
+ :prop_tgt:`ARCHIVE_OUTPUT_NAME_<CONFIG>` and
+ :prop_tgt:`LIBRARY_OUTPUT_NAME_<CONFIG>`.
+
+ The :prop_tgt:`<CONFIG>_POSTFIX` and :prop_tgt:`DEBUG_POSTFIX` target
+ properties can also be considered.
+
+ Note that ``tgt`` is not added as a dependency of the target this
+ expression is evaluated on.
+``$<TARGET_LINKER_FILE_PREFIX:tgt>``
+ Prefix of file used to link where ``tgt`` is the name of a target.
+
+ See also the :prop_tgt:`PREFIX` and :prop_tgt:`IMPORT_PREFIX` target
+ properties.
+
+ Note that ``tgt`` is not added as a dependency of the target this
+ expression is evaluated on.
+``$<TARGET_LINKER_FILE_SUFFIX:tgt>``
+ Suffix of file used to link where ``tgt`` is the name of a target.
+
+ The suffix corresponds to the file extension (such as ".so" or ".lib").
+
+ See also the :prop_tgt:`SUFFIX` and :prop_tgt:`IMPORT_SUFFIX` target
+ properties.
+
+ Note that ``tgt`` is not added as a dependency of the target this
+ expression is evaluated on.
``$<TARGET_LINKER_FILE_NAME:tgt>``
Name of file used to link (.a, .lib, .so).
``$<TARGET_LINKER_FILE_DIR:tgt>``
@@ -201,6 +554,22 @@ Available informational expressions are:
See also the :prop_tgt:`PDB_NAME` and :prop_tgt:`PDB_OUTPUT_DIRECTORY`
target properties and their configuration specific variants
:prop_tgt:`PDB_NAME_<CONFIG>` and :prop_tgt:`PDB_OUTPUT_DIRECTORY_<CONFIG>`.
+``$<TARGET_PDB_FILE_BASE_NAME:tgt>``
+ Base name of the linker generated program database file (.pdb)
+ where ``tgt`` is the name of a target.
+
+ The base name corresponds to the target PDB file name (see
+ ``$<TARGET_PDB_FILE_NAME:tgt>``) without prefix and suffix. For example,
+ if target file name is ``base.pdb``, the base name is ``base``.
+
+ See also the :prop_tgt:`PDB_NAME` target property and its configuration
+ specific variant :prop_tgt:`PDB_NAME_<CONFIG>`.
+
+ The :prop_tgt:`<CONFIG>_POSTFIX` and :prop_tgt:`DEBUG_POSTFIX` target
+ properties can also be considered.
+
+ Note that ``tgt`` is not added as a dependency of the target this
+ expression is evaluated on.
``$<TARGET_PDB_FILE_NAME:tgt>``
Name of the linker generated program database file (.pdb).
``$<TARGET_PDB_FILE_DIR:tgt>``
@@ -221,49 +590,17 @@ Available informational expressions are:
expression is evaluated on.
``$<TARGET_PROPERTY:prop>``
Value of the property ``prop`` on the target on which the generator
- expression is evaluated.
+ expression is evaluated. Note that for generator expressions in
+ :ref:`Target Usage Requirements` this is the value of the property
+ on the consuming target rather than the target specifying the
+ requirement.
``$<INSTALL_PREFIX>``
Content of the install prefix when the target is exported via
:command:`install(EXPORT)` and empty otherwise.
-``$<COMPILE_LANGUAGE>``
- The compile language of source files when evaluating compile options. See
- the unary version for notes about portability of this generator
- expression.
-Output Expressions
-==================
+Output-Related Expressions
+--------------------------
-These expressions generate output, in some cases depending on an input. These
-expressions may be combined with other expressions for information or logical
-comparison::
-
- -I$<JOIN:$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>, -I>
-
-generates a string of the entries in the :prop_tgt:`INCLUDE_DIRECTORIES` target
-property with each entry preceded by ``-I``. Note that a more-complete use
-in this situation would require first checking if the INCLUDE_DIRECTORIES
-property is non-empty::
-
- $<$<BOOL:${prop}>:-I$<JOIN:${prop}, -I>>
-
-where ``${prop}`` refers to a helper variable::
-
- set(prop "$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>")
-
-Available output expressions are:
-
-``$<0:...>``
- Empty string (ignores ``...``)
-``$<1:...>``
- Content of ``...``
-``$<JOIN:list,...>``
- Joins the list with the content of ``...``
-``$<ANGLE-R>``
- A literal ``>``. Used to compare strings which contain a ``>`` for example.
-``$<COMMA>``
- A literal ``,``. Used to compare strings which contain a ``,`` for example.
-``$<SEMICOLON>``
- A literal ``;``. Used to prevent list expansion on an argument with ``;``.
``$<TARGET_NAME:...>``
Marks ``...`` as being the name of a target. This is required if exporting
targets to multiple dependent export sets. The ``...`` must be a literal
@@ -282,16 +619,39 @@ Available output expressions are:
Content of ``...`` when the property is exported using :command:`export`, or
when the target is used by another target in the same buildsystem. Expands to
the empty string otherwise.
-``$<LOWER_CASE:...>``
- Content of ``...`` converted to lower case.
-``$<UPPER_CASE:...>``
- Content of ``...`` converted to upper case.
``$<MAKE_C_IDENTIFIER:...>``
- Content of ``...`` converted to a C identifier.
+ Content of ``...`` converted to a C identifier. The conversion follows the
+ same behavior as :command:`string(MAKE_C_IDENTIFIER)`.
``$<TARGET_OBJECTS:objLib>``
- List of objects resulting from build of ``objLib``. ``objLib`` must be an
- object of type ``OBJECT_LIBRARY``.
+ List of objects resulting from build of ``objLib``.
``$<SHELL_PATH:...>``
Content of ``...`` converted to shell path style. For example, slashes are
converted to backslashes in Windows shells and drive letters are converted
to posix paths in MSYS shells. The ``...`` must be an absolute path.
+ The ``...`` may be a :ref:`semicolon-separated list <CMake Language Lists>`
+ of paths, in which case each path is converted individually and a result
+ list is generated using the shell path separator (``:`` on POSIX and
+ ``;`` on Windows). Be sure to enclose the argument containing this genex
+ in double quotes in CMake source code so that ``;`` does not split arguments.
+
+Debugging
+=========
+
+Since generator expressions are evaluated during generation of the buildsystem,
+and not during processing of ``CMakeLists.txt`` files, it is not possible to
+inspect their result with the :command:`message()` command.
+
+One possible way to generate debug messages is to add a custom target,
+
+.. code-block:: cmake
+
+ add_custom_target(genexdebug COMMAND ${CMAKE_COMMAND} -E echo "$<...>")
+
+The shell command ``make genexdebug`` (invoked after execution of ``cmake``)
+would then print the result of ``$<...>``.
+
+Another way is to write debug messages to a file:
+
+.. code-block:: cmake
+
+ file(GENERATE OUTPUT filename CONTENT "$<...>")
diff --git a/Help/manual/cmake-generators.7.rst b/Help/manual/cmake-generators.7.rst
index a37c65b39..41f765220 100644
--- a/Help/manual/cmake-generators.7.rst
+++ b/Help/manual/cmake-generators.7.rst
@@ -27,6 +27,8 @@ when creating a new build tree.
CMake Generators
================
+.. _`Command-Line Build Tool Generators`:
+
Command-Line Build Tool Generators
----------------------------------
@@ -58,6 +60,8 @@ Ninja Generator
/generator/Ninja
+.. _`IDE Build Tool Generators`:
+
IDE Build Tool Generators
-------------------------
@@ -83,6 +87,7 @@ Visual Studio Generators
/generator/Visual Studio 12 2013
/generator/Visual Studio 14 2015
/generator/Visual Studio 15 2017
+ /generator/Visual Studio 16 2019
Other Generators
^^^^^^^^^^^^^^^^
@@ -108,6 +113,5 @@ The following extra generators are known to CMake.
/generator/CodeBlocks
/generator/CodeLite
/generator/Eclipse CDT4
- /generator/KDevelop3
/generator/Kate
/generator/Sublime Text 2
diff --git a/Help/manual/cmake-gui.1.rst b/Help/manual/cmake-gui.1.rst
index 032b51fda..ff8311bbe 100644
--- a/Help/manual/cmake-gui.1.rst
+++ b/Help/manual/cmake-gui.1.rst
@@ -9,24 +9,33 @@ Synopsis
.. parsed-literal::
cmake-gui [<options>]
- cmake-gui [<options>] (<path-to-source> | <path-to-existing-build>)
+ cmake-gui [<options>] {<path-to-source> | <path-to-existing-build>}
+ cmake-gui [<options>] -S <path-to-source> -B <path-to-build>
Description
===========
-The "cmake-gui" executable is the CMake GUI. Project configuration
+The **cmake-gui** executable is the CMake GUI. Project configuration
settings may be specified interactively. Brief instructions are
provided at the bottom of the window when the program is running.
CMake is a cross-platform build system generator. Projects specify
their build process with platform-independent CMake listfiles included
-in each directory of a source tree with the name CMakeLists.txt.
+in each directory of a source tree with the name ``CMakeLists.txt``.
Users build a project by using CMake to generate a build system for a
native tool on their platform.
Options
=======
+``-S <path-to-source>``
+ Path to root directory of the CMake project to build.
+
+``-B <path-to-build>``
+ Path to directory which CMake will use as the root of build directory.
+
+ If the directory doesn't already exist CMake will make it.
+
.. include:: OPTIONS_HELP.txt
See Also
diff --git a/Help/manual/cmake-language.7.rst b/Help/manual/cmake-language.7.rst
index 27b5d30b4..4ca8e3a26 100644
--- a/Help/manual/cmake-language.7.rst
+++ b/Help/manual/cmake-language.7.rst
@@ -183,18 +183,18 @@ same length:
.. productionlist::
bracket_argument: `bracket_open` `bracket_content` `bracket_close`
- bracket_open: '[' '='{len} '['
- bracket_content: <any text not containing a `bracket_close`
- : of the same {len} as the `bracket_open`>
- bracket_close: ']' '='{len} ']'
+ bracket_open: '[' '='* '['
+ bracket_content: <any text not containing a `bracket_close` with
+ : the same number of '=' as the `bracket_open`>
+ bracket_close: ']' '='* ']'
.. raw:: latex
\end{small}
-An opening bracket of length *len >= 0* is written ``[`` followed
-by *len* ``=`` followed by ``[`` and the corresponding closing
-bracket is written ``]`` followed by *len* ``=`` followed by ``]``.
+An opening bracket is written ``[`` followed by zero or more ``=`` followed
+by ``[``. The corresponding closing bracket is written ``]`` followed
+by the same number of ``=`` followed by ``]``.
Brackets do not nest. A unique length may always be chosen
for the opening and closing brackets to contain closing brackets
of other lengths.
@@ -206,9 +206,10 @@ enclosed content, such as `Escape Sequences`_ or `Variable References`_,
is performed. A bracket argument is always given to the command
invocation as exactly one argument.
-For example:
+.. No code-block syntax highlighting in the following example
+ (long string literal not supported by our cmake.py)
-.. code-block:: cmake
+For example::
message([=[
This is the first line in a bracket argument with bracket length 1.
@@ -253,16 +254,22 @@ closing quotes. Both `Escape Sequences`_ and `Variable References`_
are evaluated. A quoted argument is always given to the command
invocation as exactly one argument.
+.. No code-block syntax highlighting in the following example
+ (escape \" not supported by our cmake.py)
+
For example:
-::
+.. code-block:: cmake
- message("This is a quoted argument containing multiple lines.
- This is always one argument even though it contains a ; character.
- Both \\-escape sequences and ${variable} references are evaluated.
- The text does not end on an escaped double-quote like \".
- It does end in an unescaped double quote.
- ")
+ message("This is a quoted argument containing multiple lines.
+ This is always one argument even though it contains a ; character.
+ Both \\-escape sequences and ${variable} references are evaluated.
+ The text does not end on an escaped double-quote like \".
+ It does end in an unescaped double quote.
+ ")
+
+.. No code-block syntax highlighting in the following example
+ (for conformity with the two above examples)
The final ``\`` on any line ending in an odd number of backslashes
is treated as a line continuation and ignored along with the
@@ -270,11 +277,11 @@ immediately following newline character. For example:
.. code-block:: cmake
- message("\
- This is the first line of a quoted argument. \
- In fact it is the only line but since it is long \
- the source code uses line continuation.\
- ")
+ message("\
+ This is the first line of a quoted argument. \
+ In fact it is the only line but since it is long \
+ the source code uses line continuation.\
+ ")
.. note::
CMake versions prior to 3.0 do not support continuation with ``\``.
@@ -334,6 +341,8 @@ For example:
beginning of an unquoted argument, and are treated as part of the
content. For example, the unquoted arguments ``-Da="b c"``,
``-Da=$(v)``, and ``a" "b"c"d`` are each interpreted literally.
+ They may instead be written as quoted arguments ``"-Da=\"b c\""``,
+ ``"-Da=$(v)"``, and ``"a\" \"b\"c\"d"``, respectively.
Make-style references are treated literally as part of the content
and do not undergo variable expansion. They are treated as part
@@ -380,7 +389,7 @@ historical considerations.)
Variable References
-------------------
-A *variable reference* has the form ``${variable_name}`` and is
+A *variable reference* has the form ``${<variable>}`` and is
evaluated inside a `Quoted Argument`_ or an `Unquoted Argument`_.
A variable reference is replaced by the value of the variable,
or by the empty string if the variable is not set.
@@ -389,14 +398,24 @@ inside out, e.g. ``${outer_${inner_variable}_variable}``.
Literal variable references may consist of alphanumeric characters,
the characters ``/_.+-``, and `Escape Sequences`_. Nested references
-may be used to evaluate variables of any name. (See also policy
-:policy:`CMP0053` documentation for historical considerations.)
+may be used to evaluate variables of any name. See also policy
+:policy:`CMP0053` documentation for historical considerations and reasons why
+the ``$`` is also technically permitted but is discouraged.
The `Variables`_ section documents the scope of variable names
and how their values are set.
-An *environment variable reference* has the form ``$ENV{VAR}`` and
-is evaluated in the same contexts as a normal variable reference.
+An *environment variable reference* has the form ``$ENV{<variable>}``.
+See the `Environment Variables`_ section for more information.
+
+A *cache variable reference* has the form ``$CACHE{<variable>}``.
+See :variable:`CACHE` for more information.
+
+The :command:`if` command has a special condition syntax that
+allows for variable references in the short form ``<variable>``
+instead of ``${<variable>}``.
+However, environment and cache variables always need to be
+referenced as ``$ENV{<variable>}`` or ``$CACHE{<variable>}``.
Comments
--------
@@ -411,7 +430,7 @@ comments: a `Bracket Comment`_ and a `Line Comment`_.
Bracket Comment
^^^^^^^^^^^^^^^
-A ``#`` immediately followed by a `Bracket Argument`_ forms a
+A ``#`` immediately followed by a :token:`bracket_open` forms a
*bracket comment* consisting of the entire bracket enclosure:
.. raw:: latex
@@ -442,7 +461,7 @@ For example:
Line Comment
^^^^^^^^^^^^
-A ``#`` not immediately followed by a `Bracket Argument`_ forms a
+A ``#`` not immediately followed by a :token:`bracket_open` forms a
*line comment* that runs until the end of the line:
.. raw:: latex
@@ -450,7 +469,7 @@ A ``#`` not immediately followed by a `Bracket Argument`_ forms a
\begin{small}
.. productionlist::
- line_comment: '#' <any text not starting in a `bracket_argument`
+ line_comment: '#' <any text not starting in a `bracket_open`
: and not containing a `newline`>
.. raw:: latex
@@ -514,7 +533,7 @@ Function Scope
create commands that, when invoked, process the recorded commands
in a new variable binding scope. A variable "set" or "unset"
binds in this scope and is visible for the current function and
- any nested calls, but not after the function returns.
+ any nested calls within it, but not after the function returns.
Directory Scope
Each of the `Directories`_ in a source tree has its own variable
@@ -541,11 +560,41 @@ to the binding in the current directory scope, if any. If a
is found, or no binding is found, CMake then searches for a
cache entry. If a cache entry is found, its value is used.
Otherwise, the variable reference evaluates to an empty string.
+The ``$CACHE{VAR}`` syntax can be used to do direct cache entry
+lookups.
-The :manual:`cmake-variables(7)` manual documents many variables
+The :manual:`cmake-variables(7)` manual documents the many variables
that are provided by CMake or have meaning to CMake when set
by project code.
+.. _`CMake Language Environment Variables`:
+
+Environment Variables
+=====================
+
+Environment Variables are like ordinary `Variables`_, with the
+following differences:
+
+Scope
+ Environment variables have global scope in a CMake process.
+ They are never cached.
+
+References
+ `Variable References`_ have the form ``$ENV{<variable>}``.
+
+Initialization
+ Initial values of the CMake environment variables are those of
+ the calling process.
+ Values can be changed using the :command:`set` and :command:`unset`
+ commands.
+ These commands only affect the running CMake process,
+ not the system environment at large.
+ Changed values are not written back to the calling process,
+ and they are not seen by subsequent build or test processes.
+
+The :manual:`cmake-env-variables(7)` manual documents environment
+variables that have special meaning to CMake.
+
.. _`CMake Language Lists`:
Lists
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index 4a03b7a80..c60dc4010 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -3,12 +3,14 @@
cmake-modules(7)
****************
-.. only:: html
+The modules listed here are part of the CMake distribution.
+Projects may provide further modules; their location(s)
+can be specified in the :variable:`CMAKE_MODULE_PATH` variable.
- .. contents::
+Utility Modules
+^^^^^^^^^^^^^^^
-All Modules
-===========
+These modules are loaded using the :command:`include` command.
.. toctree::
:maxdepth: 1
@@ -26,6 +28,7 @@ All Modules
/module/CheckFortranCompilerFlag
/module/CheckFortranFunctionExists
/module/CheckFortranSourceCompiles
+ /module/CheckFortranSourceRuns
/module/CheckFunctionExists
/module/CheckIPOSupported
/module/CheckIncludeFileCXX
@@ -33,6 +36,13 @@ All Modules
/module/CheckIncludeFiles
/module/CheckLanguage
/module/CheckLibraryExists
+ /module/CheckOBJCCompilerFlag
+ /module/CheckOBJCSourceCompiles
+ /module/CheckOBJCSourceRuns
+ /module/CheckOBJCXXCompilerFlag
+ /module/CheckOBJCXXSourceCompiles
+ /module/CheckOBJCXXSourceRuns
+ /module/CheckPIESupported
/module/CheckPrototypeDefinition
/module/CheckStructHasMember
/module/CheckSymbolExists
@@ -41,33 +51,19 @@ All Modules
/module/CMakeAddFortranSubdirectory
/module/CMakeBackwardCompatibilityCXX
/module/CMakeDependentOption
- /module/CMakeDetermineVSServicePack
- /module/CMakeExpandImportedTargets
/module/CMakeFindDependencyMacro
/module/CMakeFindFrameworks
/module/CMakeFindPackageMode
- /module/CMakeForceCompiler
/module/CMakeGraphVizOptions
/module/CMakePackageConfigHelpers
- /module/CMakeParseArguments
/module/CMakePrintHelpers
/module/CMakePrintSystemInformation
/module/CMakePushCheckState
/module/CMakeVerifyManifest
- /module/CPackArchive
- /module/CPackBundle
/module/CPackComponent
- /module/CPackCygwin
- /module/CPackDeb
- /module/CPackDMG
/module/CPackIFW
/module/CPackIFWConfigureFile
- /module/CPackNSIS
- /module/CPackPackageMaker
- /module/CPackProductBuild
- /module/CPackRPM
/module/CPack
- /module/CPackWIX
/module/CSharpUtilities
/module/CTest
/module/CTestCoverageCollectGCOV
@@ -79,6 +75,40 @@ All Modules
/module/ExternalData
/module/ExternalProject
/module/FeatureSummary
+ /module/FetchContent
+ /module/FindPackageHandleStandardArgs
+ /module/FindPackageMessage
+ /module/FortranCInterface
+ /module/GenerateExportHeader
+ /module/GetPrerequisites
+ /module/GNUInstallDirs
+ /module/GoogleTest
+ /module/InstallRequiredSystemLibraries
+ /module/ProcessorCount
+ /module/SelectLibraryConfigurations
+ /module/SquishTestScript
+ /module/TestBigEndian
+ /module/TestForANSIForScope
+ /module/TestForANSIStreamHeaders
+ /module/TestForSSTREAM
+ /module/TestForSTDNamespace
+ /module/UseEcos
+ /module/UseJavaClassFilelist
+ /module/UseJava
+ /module/UseJavaSymlinks
+ /module/UseSWIG
+ /module/UsewxWidgets
+ /module/WriteCompilerDetectionHeader
+
+Find Modules
+^^^^^^^^^^^^
+
+These modules search for third-party software.
+They are normally called through the :command:`find_package` command.
+
+.. toctree::
+ :maxdepth: 1
+
/module/FindALSA
/module/FindArmadillo
/module/FindASPELL
@@ -91,7 +121,6 @@ All Modules
/module/FindBZip2
/module/FindCABLE
/module/FindCoin3D
- /module/FindCUDA
/module/FindCups
/module/FindCURL
/module/FindCurses
@@ -102,10 +131,12 @@ All Modules
/module/FindDCMTK
/module/FindDevIL
/module/FindDoxygen
+ /module/FindEnvModules
/module/FindEXPAT
/module/FindFLEX
/module/FindFLTK2
/module/FindFLTK
+ /module/FindFontconfig
/module/FindFreetype
/module/FindGCCXML
/module/FindGDAL
@@ -128,6 +159,7 @@ All Modules
/module/FindIcotool
/module/FindICU
/module/FindImageMagick
+ /module/FindIconv
/module/FindIntl
/module/FindITK
/module/FindJasper
@@ -139,6 +171,7 @@ All Modules
/module/FindLAPACK
/module/FindLATEX
/module/FindLibArchive
+ /module/FindLibinput
/module/FindLibLZMA
/module/FindLibXml2
/module/FindLibXslt
@@ -152,6 +185,8 @@ All Modules
/module/FindMPEG2
/module/FindMPEG
/module/FindMPI
+ /module/FindODBC
+ /module/FindOpenACC
/module/FindOpenAL
/module/FindOpenCL
/module/FindOpenGL
@@ -179,8 +214,7 @@ All Modules
/module/FindosgViewer
/module/FindosgVolume
/module/FindosgWidget
- /module/FindPackageHandleStandardArgs
- /module/FindPackageMessage
+ /module/FindPatch
/module/FindPerlLibs
/module/FindPerl
/module/FindPHP4
@@ -191,11 +225,11 @@ All Modules
/module/FindPostgreSQL
/module/FindProducer
/module/FindProtobuf
- /module/FindPythonInterp
- /module/FindPythonLibs
+ /module/FindPython
+ /module/FindPython2
+ /module/FindPython3
/module/FindQt3
/module/FindQt4
- /module/FindQt
/module/FindQuickTime
/module/FindRTI
/module/FindRuby
@@ -207,6 +241,7 @@ All Modules
/module/FindSDL_ttf
/module/FindSelfPackers
/module/FindSquish
+ /module/FindSQLite3
/module/FindSubversion
/module/FindSWIG
/module/FindTCL
@@ -220,36 +255,63 @@ All Modules
/module/FindWget
/module/FindWish
/module/FindwxWidgets
- /module/FindwxWindows
/module/FindXCTest
/module/FindXalanC
/module/FindXercesC
/module/FindX11
/module/FindXMLRPC
/module/FindZLIB
- /module/FortranCInterface
- /module/GenerateExportHeader
- /module/GetPrerequisites
- /module/GNUInstallDirs
- /module/GoogleTest
- /module/InstallRequiredSystemLibraries
+
+Deprecated Modules
+^^^^^^^^^^^^^^^^^^^
+
+Deprecated Utility Modules
+==========================
+
+.. toctree::
+ :maxdepth: 1
+
+ /module/CMakeDetermineVSServicePack
+ /module/CMakeExpandImportedTargets
+ /module/CMakeForceCompiler
+ /module/CMakeParseArguments
/module/MacroAddFileDependencies
- /module/ProcessorCount
- /module/SelectLibraryConfigurations
- /module/SquishTestScript
- /module/TestBigEndian
/module/TestCXXAcceptsFlag
- /module/TestForANSIForScope
- /module/TestForANSIStreamHeaders
- /module/TestForSSTREAM
- /module/TestForSTDNamespace
- /module/UseEcos
- /module/UseJavaClassFilelist
- /module/UseJava
- /module/UseJavaSymlinks
/module/UsePkgConfig
- /module/UseSWIG
- /module/UsewxWidgets
/module/Use_wxWindows
/module/WriteBasicConfigVersionFile
- /module/WriteCompilerDetectionHeader
+
+Deprecated Find Modules
+=======================
+
+.. toctree::
+ :maxdepth: 1
+
+ /module/FindCUDA
+ /module/FindPythonInterp
+ /module/FindPythonLibs
+ /module/FindQt
+ /module/FindwxWindows
+
+Legacy CPack Modules
+====================
+
+These modules used to be mistakenly exposed to the user, and have been moved
+out of user visibility. They are for CPack internal use, and should never be
+used directly.
+
+.. toctree::
+ :maxdepth: 1
+
+ /module/CPackArchive
+ /module/CPackBundle
+ /module/CPackCygwin
+ /module/CPackDeb
+ /module/CPackDMG
+ /module/CPackFreeBSD
+ /module/CPackNSIS
+ /module/CPackNuGet
+ /module/CPackPackageMaker
+ /module/CPackProductBuild
+ /module/CPackRPM
+ /module/CPackWIX
diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst
index c9442bc19..4b2934a8e 100644
--- a/Help/manual/cmake-packages.7.rst
+++ b/Help/manual/cmake-packages.7.rst
@@ -12,7 +12,7 @@ Introduction
Packages provide dependency information to CMake based buildsystems. Packages
are found with the :command:`find_package` command. The result of
-using ``find_package`` is either a set of :prop_tgt:`IMPORTED` targets, or
+using :command:`find_package` is either a set of :prop_tgt:`IMPORTED` targets, or
a set of variables corresponding to build-relevant information.
Using Packages
@@ -73,7 +73,7 @@ Handling of ``COMPONENTS`` and ``OPTIONAL_COMPONENTS`` is defined by the
package.
By setting the :variable:`CMAKE_DISABLE_FIND_PACKAGE_<PackageName>` variable to
-``TRUE``, the ``PackageName`` package will not be searched, and will always
+``TRUE``, the ``<PackageName>`` package will not be searched, and will always
be ``NOTFOUND``.
.. _`Config File Packages`:
@@ -92,9 +92,9 @@ packages, that is, they belong with the header files and any other files
provided to assist downstreams in using the package.
A set of variables which provide package status information are also set
-automatically when using a config-file package. The ``<Package>_FOUND``
+automatically when using a config-file package. The ``<PackageName>_FOUND``
variable is set to true or false, depending on whether the package was
-found. The ``<Package>_DIR`` cache variable is set to the location of the
+found. The ``<PackageName>_DIR`` cache variable is set to the location of the
package configuration file.
Find-module Packages
@@ -108,10 +108,10 @@ file, it is not shipped with upstream, but is used by downstream to find the
files by guessing locations of files with platform-specific hints.
Unlike the case of an upstream-provided package configuration file, no single point
-of reference identifies the package as being found, so the ``<Package>_FOUND``
+of reference identifies the package as being found, so the ``<PackageName>_FOUND``
variable is not automatically set by the :command:`find_package` command. It
can still be expected to be set by convention however and should be set by
-the author of the Find-module. Similarly there is no ``<Package>_DIR`` variable,
+the author of the Find-module. Similarly there is no ``<PackageName>_DIR`` variable,
but each of the artifacts such as library locations and header file locations
provide a separate cache variable.
@@ -197,7 +197,7 @@ When the :command:`find_package` command loads a version file it first sets the
following variables:
``PACKAGE_FIND_NAME``
- The <package> name
+ The ``<PackageName>``
``PACKAGE_FIND_VERSION``
Full requested version string
@@ -240,26 +240,26 @@ variables. When the version file claims to be an acceptable match for the
requested version the find_package command sets the following variables for
use by the project:
-``<package>_VERSION``
+``<PackageName>_VERSION``
Full provided version string
-``<package>_VERSION_MAJOR``
+``<PackageName>_VERSION_MAJOR``
Major version if provided, else 0
-``<package>_VERSION_MINOR``
+``<PackageName>_VERSION_MINOR``
Minor version if provided, else 0
-``<package>_VERSION_PATCH``
+``<PackageName>_VERSION_PATCH``
Patch version if provided, else 0
-``<package>_VERSION_TWEAK``
+``<PackageName>_VERSION_TWEAK``
Tweak version if provided, else 0
-``<package>_VERSION_COUNT``
+``<PackageName>_VERSION_COUNT``
Number of version components, 0 to 4
The variables report the version of the package that was actually found.
-The ``<package>`` part of their name matches the argument given to the
+The ``<PackageName>`` part of their name matches the argument given to the
:command:`find_package` command.
.. _`Creating Packages`:
@@ -347,8 +347,8 @@ The :module:`CMakePackageConfigHelpers` module provides a macro for creating
a simple ``ConfigVersion.cmake`` file. This file sets the version of the
package. It is read by CMake when :command:`find_package` is called to
determine the compatibility with the requested version, and to set some
-version-specific variables ``<Package>_VERSION``, ``<Package>_VERSION_MAJOR``,
-``<Package>_VERSION_MINOR`` etc. The :command:`install(EXPORT)` command is
+version-specific variables ``<PackageName>_VERSION``, ``<PackageName>_VERSION_MAJOR``,
+``<PackageName>_VERSION_MINOR`` etc. The :command:`install(EXPORT)` command is
used to export the targets in the ``ClimbingStatsTargets`` export-set, defined
previously by the :command:`install(TARGETS)` command. This command generates
the ``ClimbingStatsTargets.cmake`` file to contain :prop_tgt:`IMPORTED`
@@ -432,8 +432,8 @@ the dependency is not found, along with a diagnostic that the ``ClimbingStats``
package can not be used without the ``Stats`` package.
If ``COMPONENTS`` are specified when the downstream uses :command:`find_package`,
-they are listed in the ``<Package>_FIND_COMPONENTS`` variable. If a particular
-component is non-optional, then the ``<Package>_FIND_REQUIRED_<comp>`` will
+they are listed in the ``<PackageName>_FIND_COMPONENTS`` variable. If a particular
+component is non-optional, then the ``<PackageName>_FIND_REQUIRED_<comp>`` will
be true. This can be tested with logic in the package configuration file:
.. code-block:: cmake
@@ -580,8 +580,8 @@ non-standard install locations or directly in their own build trees.
A project may populate either the user or system registry (using its own
means, see below) to refer to its location.
In either case the package should store at the registered location a
-`Package Configuration File`_ (``<package>Config.cmake``) and optionally a
-`Package Version File`_ (``<package>ConfigVersion.cmake``).
+`Package Configuration File`_ (``<PackageName>Config.cmake``) and optionally a
+`Package Version File`_ (``<PackageName>ConfigVersion.cmake``).
The :command:`find_package` command searches the two package registries
as two of the search steps specified in its documentation. If it has
@@ -603,18 +603,18 @@ must be manually taught to register their packages if desired.
On Windows the user package registry is stored in the Windows registry
under a key in ``HKEY_CURRENT_USER``.
-A ``<package>`` may appear under registry key::
+A ``<PackageName>`` may appear under registry key::
- HKEY_CURRENT_USER\Software\Kitware\CMake\Packages\<package>
+ HKEY_CURRENT_USER\Software\Kitware\CMake\Packages\<PackageName>
as a ``REG_SZ`` value, with arbitrary name, that specifies the directory
containing the package configuration file.
On UNIX platforms the user package registry is stored in the user home
-directory under ``~/.cmake/packages``. A ``<package>`` may appear under
+directory under ``~/.cmake/packages``. A ``<PackageName>`` may appear under
the directory::
- ~/.cmake/packages/<package>
+ ~/.cmake/packages/<PackageName>
as a file, with arbitrary name, whose content specifies the directory
containing the package configuration file.
@@ -629,10 +629,10 @@ CMake currently provides no interface to add to the system package registry.
Installers must be manually taught to register their packages if desired.
On Windows the system package registry is stored in the Windows registry
-under a key in ``HKEY_LOCAL_MACHINE``. A ``<package>`` may appear under
+under a key in ``HKEY_LOCAL_MACHINE``. A ``<PackageName>`` may appear under
registry key::
- HKEY_LOCAL_MACHINE\Software\Kitware\CMake\Packages\<package>
+ HKEY_LOCAL_MACHINE\Software\Kitware\CMake\Packages\<PackageName>
as a ``REG_SZ`` value, with arbitrary name, that specifies the directory
containing the package configuration file.
@@ -647,12 +647,22 @@ Disabling the Package Registry
In some cases using the Package Registries is not desirable. CMake
allows one to disable them using the following variables:
- * :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` disables the
- :command:`export(PACKAGE)` command.
- * :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` disables the
- User Package Registry in all the :command:`find_package` calls.
- * :variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` disables
- the System Package Registry in all the :command:`find_package` calls.
+* The :command:`export(PACKAGE)` command does not populate the user
+ package registry when :policy:`CMP0090` is set to ``NEW`` unless the
+ :variable:`CMAKE_EXPORT_PACKAGE_REGISTRY` variable explicitly enables it.
+ When :policy:`CMP0090` is *not* set to ``NEW`` then
+ :command:`export(PACKAGE)` populates the user package registry unless
+ the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable explicitly
+ disables it.
+* :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` disables the
+ User Package Registry in all the :command:`find_package` calls when
+ set to ``FALSE``.
+* Deprecated :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` disables the
+ User Package Registry in all the :command:`find_package` calls when set
+ to ``TRUE``. This variable is ignored when
+ :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` has been set.
+* :variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` disables
+ the System Package Registry in all the :command:`find_package` calls.
Package Registry Example
------------------------
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 7b858176f..44ea1a8fd 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -51,6 +51,84 @@ The :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable may also be used
to determine whether to report an error on use of deprecated macros or
functions.
+Policies Introduced by CMake 3.16
+=================================
+
+.. toctree::
+ :maxdepth: 1
+
+ CMP0097: ExternalProject_Add with GIT_SUBMODULES "" initializes no submodules. </policy/CMP0097>
+ CMP0096: project() preserves leading zeros in version components. </policy/CMP0096>
+ CMP0095: RPATH entries are properly escaped in the intermediary CMake install script. </policy/CMP0095>
+
+Policies Introduced by CMake 3.15
+=================================
+
+.. toctree::
+ :maxdepth: 1
+
+ CMP0094: FindPython3, FindPython2 and FindPython use LOCATION for lookup strategy. </policy/CMP0094>
+ CMP0093: FindBoost reports Boost_VERSION in x.y.z format. </policy/CMP0093>
+ CMP0092: MSVC warning flags are not in CMAKE_{C,CXX}_FLAGS by default. </policy/CMP0092>
+ CMP0091: MSVC runtime library flags are selected by an abstraction. </policy/CMP0091>
+ CMP0090: export(PACKAGE) does not populate package registry by default. </policy/CMP0090>
+ CMP0089: Compiler id for IBM Clang-based XL compilers is now XLClang. </policy/CMP0089>
+
+Policies Introduced by CMake 3.14
+=================================
+
+.. toctree::
+ :maxdepth: 1
+
+ CMP0088: FindBISON runs bison in CMAKE_CURRENT_BINARY_DIR when executing. </policy/CMP0088>
+ CMP0087: install(SCRIPT | CODE) supports generator expressions. </policy/CMP0087>
+ CMP0086: UseSWIG honors SWIG_MODULE_NAME via -module flag. </policy/CMP0086>
+ CMP0085: IN_LIST generator expression handles empty list items. </policy/CMP0085>
+ CMP0084: The FindQt module does not exist for find_package(). </policy/CMP0084>
+ CMP0083: Add PIE options when linking executable. </policy/CMP0083>
+ CMP0082: Install rules from add_subdirectory() are interleaved with those in caller. </policy/CMP0082>
+
+
+Policies Introduced by CMake 3.13
+=================================
+
+.. toctree::
+ :maxdepth: 1
+
+ CMP0081: Relative paths not allowed in LINK_DIRECTORIES target property. </policy/CMP0081>
+ CMP0080: BundleUtilities cannot be included at configure time. </policy/CMP0080>
+ CMP0079: target_link_libraries allows use with targets in other directories. </policy/CMP0079>
+ CMP0078: UseSWIG generates standard target names. </policy/CMP0078>
+ CMP0077: option() honors normal variables. </policy/CMP0077>
+ CMP0076: target_sources() command converts relative paths to absolute. </policy/CMP0076>
+
+Policies Introduced by CMake 3.12
+=================================
+
+.. toctree::
+ :maxdepth: 1
+
+ CMP0075: Include file check macros honor CMAKE_REQUIRED_LIBRARIES. </policy/CMP0075>
+ CMP0074: find_package uses PackageName_ROOT variables. </policy/CMP0074>
+ CMP0073: Do not produce legacy _LIB_DEPENDS cache entries. </policy/CMP0073>
+
+Policies Introduced by CMake 3.11
+=================================
+
+.. toctree::
+ :maxdepth: 1
+
+ CMP0072: FindOpenGL prefers GLVND by default when available. </policy/CMP0072>
+
+Policies Introduced by CMake 3.10
+=================================
+
+.. toctree::
+ :maxdepth: 1
+
+ CMP0071: Let AUTOMOC and AUTOUIC process GENERATED files. </policy/CMP0071>
+ CMP0070: Define file(GENERATE) behavior for relative paths. </policy/CMP0070>
+
Policies Introduced by CMake 3.9
================================
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index ec25596f3..e7043714c 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -23,6 +23,7 @@ Properties of Global Scope
/prop_gbl/AUTORCC_SOURCE_GROUP
/prop_gbl/CMAKE_C_KNOWN_FEATURES
/prop_gbl/CMAKE_CXX_KNOWN_FEATURES
+ /prop_gbl/CMAKE_ROLE
/prop_gbl/DEBUG_CONFIGURATIONS
/prop_gbl/DISABLED_FEATURES
/prop_gbl/ENABLED_FEATURES
@@ -40,6 +41,7 @@ Properties of Global Scope
/prop_gbl/JOB_POOLS
/prop_gbl/PREDEFINED_TARGETS_FOLDER
/prop_gbl/ECLIPSE_EXTRA_NATURES
+ /prop_gbl/ECLIPSE_EXTRA_CPROJECT_CONTENTS
/prop_gbl/REPORT_UNDEFINED_PROPERTIES
/prop_gbl/RULE_LAUNCH_COMPILE
/prop_gbl/RULE_LAUNCH_CUSTOM
@@ -59,7 +61,7 @@ Properties on Directories
.. toctree::
:maxdepth: 1
- /prop_dir/ADDITIONAL_MAKE_CLEAN_FILES
+ /prop_dir/ADDITIONAL_CLEAN_FILES
/prop_dir/BINARY_DIR
/prop_dir/BUILDSYSTEM_TARGETS
/prop_dir/CACHE_VARIABLES
@@ -74,7 +76,9 @@ Properties on Directories
/prop_dir/INCLUDE_REGULAR_EXPRESSION
/prop_dir/INTERPROCEDURAL_OPTIMIZATION_CONFIG
/prop_dir/INTERPROCEDURAL_OPTIMIZATION
+ /prop_dir/LABELS
/prop_dir/LINK_DIRECTORIES
+ /prop_dir/LINK_OPTIONS
/prop_dir/LISTFILE_STACK
/prop_dir/MACROS
/prop_dir/PARENT_DIRECTORY
@@ -83,7 +87,8 @@ Properties on Directories
/prop_dir/RULE_LAUNCH_LINK
/prop_dir/SOURCE_DIR
/prop_dir/SUBDIRECTORIES
- /prop_dir/TEST_INCLUDE_FILE
+ /prop_dir/TESTS
+ /prop_dir/TEST_INCLUDE_FILES
/prop_dir/VARIABLES
/prop_dir/VS_GLOBAL_SECTION_POST_section
/prop_dir/VS_GLOBAL_SECTION_PRE_section
@@ -97,6 +102,7 @@ Properties on Targets
.. toctree::
:maxdepth: 1
+ /prop_tgt/ADDITIONAL_CLEAN_FILES
/prop_tgt/ALIASED_TARGET
/prop_tgt/ANDROID_ANT_ADDITIONAL_OPTIONS
/prop_tgt/ANDROID_API
@@ -120,17 +126,26 @@ Properties on Targets
/prop_tgt/ARCHIVE_OUTPUT_NAME_CONFIG
/prop_tgt/ARCHIVE_OUTPUT_NAME
/prop_tgt/AUTOGEN_BUILD_DIR
+ /prop_tgt/AUTOGEN_ORIGIN_DEPENDS
+ /prop_tgt/AUTOGEN_PARALLEL
/prop_tgt/AUTOGEN_TARGET_DEPENDS
+ /prop_tgt/AUTOMOC_COMPILER_PREDEFINES
/prop_tgt/AUTOMOC_DEPEND_FILTERS
+ /prop_tgt/AUTOMOC_EXECUTABLE
+ /prop_tgt/AUTOMOC_MACRO_NAMES
/prop_tgt/AUTOMOC_MOC_OPTIONS
+ /prop_tgt/AUTOMOC_PATH_PREFIX
/prop_tgt/AUTOMOC
/prop_tgt/AUTOUIC
+ /prop_tgt/AUTOUIC_EXECUTABLE
/prop_tgt/AUTOUIC_OPTIONS
/prop_tgt/AUTOUIC_SEARCH_PATHS
/prop_tgt/AUTORCC
+ /prop_tgt/AUTORCC_EXECUTABLE
/prop_tgt/AUTORCC_OPTIONS
/prop_tgt/BINARY_DIR
/prop_tgt/BUILD_RPATH
+ /prop_tgt/BUILD_RPATH_USE_ORIGIN
/prop_tgt/BUILD_WITH_INSTALL_NAME_DIR
/prop_tgt/BUILD_WITH_INSTALL_RPATH
/prop_tgt/BUNDLE_EXTENSION
@@ -138,6 +153,7 @@ Properties on Targets
/prop_tgt/C_EXTENSIONS
/prop_tgt/C_STANDARD
/prop_tgt/C_STANDARD_REQUIRED
+ /prop_tgt/COMMON_LANGUAGE_RUNTIME
/prop_tgt/COMPATIBLE_INTERFACE_BOOL
/prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MAX
/prop_tgt/COMPATIBLE_INTERFACE_NUMBER_MIN
@@ -165,22 +181,30 @@ Properties on Targets
/prop_tgt/DEBUG_POSTFIX
/prop_tgt/DEFINE_SYMBOL
/prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY
+ /prop_tgt/DEPLOYMENT_ADDITIONAL_FILES
+ /prop_tgt/DISABLE_PRECOMPILE_HEADERS
+ /prop_tgt/DOTNET_TARGET_FRAMEWORK_VERSION
/prop_tgt/EchoString
/prop_tgt/ENABLE_EXPORTS
/prop_tgt/EXCLUDE_FROM_ALL
/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD_CONFIG
/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD
/prop_tgt/EXPORT_NAME
+ /prop_tgt/EXPORT_PROPERTIES
/prop_tgt/FOLDER
/prop_tgt/Fortran_FORMAT
/prop_tgt/Fortran_MODULE_DIRECTORY
/prop_tgt/FRAMEWORK
/prop_tgt/FRAMEWORK_VERSION
/prop_tgt/GENERATOR_FILE_NAME
+ /prop_tgt/GHS_INTEGRITY_APP
+ /prop_tgt/GHS_NO_SOURCE_GROUP_FILE
/prop_tgt/GNUtoMS
/prop_tgt/HAS_CXX
/prop_tgt/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM
+ /prop_tgt/IMPORTED_COMMON_LANGUAGE_RUNTIME
/prop_tgt/IMPORTED_CONFIGURATIONS
+ /prop_tgt/IMPORTED_GLOBAL
/prop_tgt/IMPORTED_IMPLIB_CONFIG
/prop_tgt/IMPORTED_IMPLIB
/prop_tgt/IMPORTED_LIBNAME_CONFIG
@@ -206,6 +230,7 @@ Properties on Targets
/prop_tgt/IMPORT_SUFFIX
/prop_tgt/INCLUDE_DIRECTORIES
/prop_tgt/INSTALL_NAME_DIR
+ /prop_tgt/INSTALL_REMOVE_ENVIRONMENT_RPATH
/prop_tgt/INSTALL_RPATH
/prop_tgt/INSTALL_RPATH_USE_LINK_PATH
/prop_tgt/INTERFACE_AUTOUIC_OPTIONS
@@ -213,7 +238,11 @@ Properties on Targets
/prop_tgt/INTERFACE_COMPILE_FEATURES
/prop_tgt/INTERFACE_COMPILE_OPTIONS
/prop_tgt/INTERFACE_INCLUDE_DIRECTORIES
+ /prop_tgt/INTERFACE_LINK_DEPENDS
+ /prop_tgt/INTERFACE_LINK_DIRECTORIES
/prop_tgt/INTERFACE_LINK_LIBRARIES
+ /prop_tgt/INTERFACE_LINK_OPTIONS
+ /prop_tgt/INTERFACE_PRECOMPILE_HEADERS
/prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE
/prop_tgt/INTERFACE_SOURCES
/prop_tgt/INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
@@ -225,6 +254,7 @@ Properties on Targets
/prop_tgt/LABELS
/prop_tgt/LANG_CLANG_TIDY
/prop_tgt/LANG_COMPILER_LAUNCHER
+ /prop_tgt/LANG_CPPCHECK
/prop_tgt/LANG_CPPLINT
/prop_tgt/LANG_INCLUDE_WHAT_YOU_USE
/prop_tgt/LANG_VISIBILITY_PRESET
@@ -235,6 +265,7 @@ Properties on Targets
/prop_tgt/LINK_DEPENDS_NO_SHARED
/prop_tgt/LINK_DEPENDS
/prop_tgt/LINKER_LANGUAGE
+ /prop_tgt/LINK_DIRECTORIES
/prop_tgt/LINK_FLAGS_CONFIG
/prop_tgt/LINK_FLAGS
/prop_tgt/LINK_INTERFACE_LIBRARIES_CONFIG
@@ -242,6 +273,7 @@ Properties on Targets
/prop_tgt/LINK_INTERFACE_MULTIPLICITY_CONFIG
/prop_tgt/LINK_INTERFACE_MULTIPLICITY
/prop_tgt/LINK_LIBRARIES
+ /prop_tgt/LINK_OPTIONS
/prop_tgt/LINK_SEARCH_END_STATIC
/prop_tgt/LINK_SEARCH_START_STATIC
/prop_tgt/LINK_WHAT_YOU_USE
@@ -253,9 +285,16 @@ Properties on Targets
/prop_tgt/MACOSX_RPATH
/prop_tgt/MANUALLY_ADDED_DEPENDENCIES
/prop_tgt/MAP_IMPORTED_CONFIG_CONFIG
+ /prop_tgt/MSVC_RUNTIME_LIBRARY
/prop_tgt/NAME
/prop_tgt/NO_SONAME
/prop_tgt/NO_SYSTEM_FROM_IMPORTED
+ /prop_tgt/OBJC_EXTENSIONS
+ /prop_tgt/OBJC_STANDARD
+ /prop_tgt/OBJC_STANDARD_REQUIRED
+ /prop_tgt/OBJCXX_EXTENSIONS
+ /prop_tgt/OBJCXX_STANDARD
+ /prop_tgt/OBJCXX_STANDARD_REQUIRED
/prop_tgt/OSX_ARCHITECTURES_CONFIG
/prop_tgt/OSX_ARCHITECTURES
/prop_tgt/OUTPUT_NAME_CONFIG
@@ -265,6 +304,8 @@ Properties on Targets
/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG
/prop_tgt/PDB_OUTPUT_DIRECTORY
/prop_tgt/POSITION_INDEPENDENT_CODE
+ /prop_tgt/PRECOMPILE_HEADERS
+ /prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM
/prop_tgt/PREFIX
/prop_tgt/PRIVATE_HEADER
/prop_tgt/PROJECT_LABEL
@@ -283,25 +324,43 @@ Properties on Targets
/prop_tgt/SOVERSION
/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG
/prop_tgt/STATIC_LIBRARY_FLAGS
+ /prop_tgt/STATIC_LIBRARY_OPTIONS
/prop_tgt/SUFFIX
+ /prop_tgt/Swift_DEPENDENCIES_FILE
+ /prop_tgt/Swift_LANGUAGE_VERSION
+ /prop_tgt/Swift_MODULE_DIRECTORY
+ /prop_tgt/Swift_MODULE_NAME
/prop_tgt/TYPE
+ /prop_tgt/UNITY_BUILD
+ /prop_tgt/UNITY_BUILD_BATCH_SIZE
+ /prop_tgt/UNITY_BUILD_CODE_AFTER_INCLUDE
+ /prop_tgt/UNITY_BUILD_CODE_BEFORE_INCLUDE
/prop_tgt/VERSION
/prop_tgt/VISIBILITY_INLINES_HIDDEN
/prop_tgt/VS_CONFIGURATION_TYPE
+ /prop_tgt/VS_DEBUGGER_COMMAND
+ /prop_tgt/VS_DEBUGGER_COMMAND_ARGUMENTS
+ /prop_tgt/VS_DEBUGGER_ENVIRONMENT
/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY
/prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION
/prop_tgt/VS_DOTNET_REFERENCE_refname
+ /prop_tgt/VS_DOTNET_REFERENCEPROP_refname_TAG_tagname
/prop_tgt/VS_DOTNET_REFERENCES
/prop_tgt/VS_DOTNET_REFERENCES_COPY_LOCAL
/prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION
+ /prop_tgt/VS_DPI_AWARE
/prop_tgt/VS_GLOBAL_KEYWORD
/prop_tgt/VS_GLOBAL_PROJECT_TYPES
/prop_tgt/VS_GLOBAL_ROOTNAMESPACE
/prop_tgt/VS_GLOBAL_variable
/prop_tgt/VS_IOT_EXTENSIONS_VERSION
/prop_tgt/VS_IOT_STARTUP_TASK
+ /prop_tgt/VS_JUST_MY_CODE_DEBUGGING
/prop_tgt/VS_KEYWORD
/prop_tgt/VS_MOBILE_EXTENSIONS_VERSION
+ /prop_tgt/VS_NO_SOLUTION_DEPLOY
+ /prop_tgt/VS_PACKAGE_REFERENCES
+ /prop_tgt/VS_PROJECT_IMPORT
/prop_tgt/VS_SCC_AUXPATH
/prop_tgt/VS_SCC_LOCALPATH
/prop_tgt/VS_SCC_PROJECTNAME
@@ -316,7 +375,28 @@ Properties on Targets
/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS
/prop_tgt/XCODE_ATTRIBUTE_an-attribute
/prop_tgt/XCODE_EXPLICIT_FILE_TYPE
+ /prop_tgt/XCODE_GENERATE_SCHEME
/prop_tgt/XCODE_PRODUCT_TYPE
+ /prop_tgt/XCODE_SCHEME_ADDRESS_SANITIZER
+ /prop_tgt/XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN
+ /prop_tgt/XCODE_SCHEME_ARGUMENTS
+ /prop_tgt/XCODE_SCHEME_DEBUG_AS_ROOT
+ /prop_tgt/XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING
+ /prop_tgt/XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER
+ /prop_tgt/XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS
+ /prop_tgt/XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE
+ /prop_tgt/XCODE_SCHEME_ENVIRONMENT
+ /prop_tgt/XCODE_SCHEME_EXECUTABLE
+ /prop_tgt/XCODE_SCHEME_GUARD_MALLOC
+ /prop_tgt/XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP
+ /prop_tgt/XCODE_SCHEME_MALLOC_GUARD_EDGES
+ /prop_tgt/XCODE_SCHEME_MALLOC_SCRIBBLE
+ /prop_tgt/XCODE_SCHEME_MALLOC_STACK
+ /prop_tgt/XCODE_SCHEME_THREAD_SANITIZER
+ /prop_tgt/XCODE_SCHEME_THREAD_SANITIZER_STOP
+ /prop_tgt/XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER
+ /prop_tgt/XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP
+ /prop_tgt/XCODE_SCHEME_ZOMBIE_OBJECTS
/prop_tgt/XCTEST
.. _`Test Properties`:
@@ -340,10 +420,13 @@ Properties on Tests
/prop_test/LABELS
/prop_test/MEASUREMENT
/prop_test/PASS_REGULAR_EXPRESSION
+ /prop_test/PROCESSOR_AFFINITY
/prop_test/PROCESSORS
/prop_test/REQUIRED_FILES
+ /prop_test/RESOURCE_GROUPS
/prop_test/RESOURCE_LOCK
/prop_test/RUN_SERIAL
+ /prop_test/SKIP_REGULAR_EXPRESSION
/prop_test/SKIP_RETURN_CODE
/prop_test/TIMEOUT
/prop_test/TIMEOUT_AFTER_MATCH
@@ -363,10 +446,12 @@ Properties on Source Files
/prop_sf/AUTORCC_OPTIONS
/prop_sf/COMPILE_DEFINITIONS
/prop_sf/COMPILE_FLAGS
+ /prop_sf/COMPILE_OPTIONS
/prop_sf/EXTERNAL_OBJECT
/prop_sf/Fortran_FORMAT
/prop_sf/GENERATED
/prop_sf/HEADER_FILE_ONLY
+ /prop_sf/INCLUDE_DIRECTORIES
/prop_sf/KEEP_EXTENSION
/prop_sf/LABELS
/prop_sf/LANGUAGE
@@ -378,6 +463,10 @@ Properties on Source Files
/prop_sf/SKIP_AUTOMOC
/prop_sf/SKIP_AUTORCC
/prop_sf/SKIP_AUTOUIC
+ /prop_sf/SKIP_PRECOMPILE_HEADERS
+ /prop_sf/SKIP_UNITY_BUILD_INCLUSION
+ /prop_sf/Swift_DEPENDENCIES_FILE
+ /prop_sf/Swift_DIAGNOSTICS_FILE
/prop_sf/SYMBOLIC
/prop_sf/VS_COPY_TO_OUT_DIR
/prop_sf/VS_CSHARP_tagname
@@ -385,10 +474,15 @@ Properties on Source Files
/prop_sf/VS_DEPLOYMENT_LOCATION
/prop_sf/VS_INCLUDE_IN_VSIX
/prop_sf/VS_RESOURCE_GENERATOR
+ /prop_sf/VS_SHADER_DISABLE_OPTIMIZATIONS
+ /prop_sf/VS_SHADER_ENABLE_DEBUG
/prop_sf/VS_SHADER_ENTRYPOINT
/prop_sf/VS_SHADER_FLAGS
/prop_sf/VS_SHADER_MODEL
+ /prop_sf/VS_SHADER_OBJECT_FILE_NAME
+ /prop_sf/VS_SHADER_OUTPUT_HEADER_FILE
/prop_sf/VS_SHADER_TYPE
+ /prop_sf/VS_SHADER_VARIABLE_NAME
/prop_sf/VS_TOOL_OVERRIDE.rst
/prop_sf/VS_XAML_TYPE
/prop_sf/WRAP_EXCLUDE
@@ -433,7 +527,9 @@ Deprecated Properties on Directories
.. toctree::
:maxdepth: 1
+ /prop_dir/ADDITIONAL_MAKE_CLEAN_FILES
/prop_dir/COMPILE_DEFINITIONS_CONFIG
+ /prop_dir/TEST_INCLUDE_FILE
Deprecated Properties on Targets
diff --git a/Help/manual/cmake-qt.7.rst b/Help/manual/cmake-qt.7.rst
index b7f16b9ea..d8d61729e 100644
--- a/Help/manual/cmake-qt.7.rst
+++ b/Help/manual/cmake-qt.7.rst
@@ -44,14 +44,10 @@ Qt Build Tools
Qt relies on some bundled tools for code generation, such as ``moc`` for
meta-object code generation, ``uic`` for widget layout and population,
-and ``rcc`` for virtual filesystem content generation. These tools may be
+and ``rcc`` for virtual file system content generation. These tools may be
automatically invoked by :manual:`cmake(1)` if the appropriate conditions
are met. The automatic tool invocation may be used with both Qt 4 and Qt 5.
-The tools are executed as part of a synthesized custom target generated by
-CMake. Target dependencies may be added to that custom target by adding them
-to the :prop_tgt:`AUTOGEN_TARGET_DEPENDS` target property.
-
AUTOMOC
^^^^^^^
@@ -59,9 +55,10 @@ The :prop_tgt:`AUTOMOC` target property controls whether :manual:`cmake(1)`
inspects the C++ files in the target to determine if they require ``moc`` to
be run, and to create rules to execute ``moc`` at the appropriate time.
-If a ``Q_OBJECT`` or ``Q_GADGET`` macro is found in a header file, ``moc``
-will be run on the file. The result will be put into a file named according
-to ``moc_<basename>.cpp``. If the macro is found in a C++ implementation
+If a macro from :prop_tgt:`AUTOMOC_MACRO_NAMES` is found in a header file,
+``moc`` will be run on the file. The result will be put into a file named
+according to ``moc_<basename>.cpp``.
+If the macro is found in a C++ implementation
file, the moc output will be put into a file named according to
``<basename>.moc``, following the Qt conventions. The ``<basename>.moc`` must
be included by the user in the C++ implementation file with a preprocessor
@@ -72,6 +69,10 @@ Included ``moc_*.cpp`` and ``*.moc`` files will be generated in the
automatically added to the target's :prop_tgt:`INCLUDE_DIRECTORIES`.
* This differs from CMake 3.7 and below; see their documentation for details.
+
+* For :prop_gbl:`multi configuration generators <GENERATOR_IS_MULTI_CONFIG>`,
+ the include directory is ``<AUTOGEN_BUILD_DIR>/include_<CONFIG>``.
+
* See :prop_tgt:`AUTOGEN_BUILD_DIR`.
Not included ``moc_<basename>.cpp`` files will be generated in custom
@@ -91,6 +92,9 @@ following targets by setting the :variable:`CMAKE_AUTOMOC` variable. The
options to pass to ``moc``. The :variable:`CMAKE_AUTOMOC_MOC_OPTIONS`
variable may be populated to pre-set the options for all following targets.
+Additional macro names to search for can be added to
+:prop_tgt:`AUTOMOC_MACRO_NAMES`.
+
Additional ``moc`` dependency file names can be extracted from source code
by using :prop_tgt:`AUTOMOC_DEPEND_FILTERS`.
@@ -124,6 +128,10 @@ The generated generated ``ui_*.h`` files are placed in the
automatically added to the target's :prop_tgt:`INCLUDE_DIRECTORIES`.
* This differs from CMake 3.7 and below; see their documentation for details.
+
+* For :prop_gbl:`multi configuration generators <GENERATOR_IS_MULTI_CONFIG>`,
+ the include directory is ``<AUTOGEN_BUILD_DIR>/include_<CONFIG>``.
+
* See :prop_tgt:`AUTOGEN_BUILD_DIR`.
The :prop_tgt:`AUTOUIC` target property may be pre-set for all following
@@ -202,6 +210,34 @@ overrides options from the :prop_tgt:`AUTORCC_OPTIONS` target property.
Source files can be excluded from :prop_tgt:`AUTORCC` processing by
enabling :prop_sf:`SKIP_AUTORCC` or the broader :prop_sf:`SKIP_AUTOGEN`.
+The ``<ORIGIN>_autogen`` target
+===============================
+
+The ``moc`` and ``uic`` tools are executed as part of a synthesized
+``<ORIGIN>_autogen`` :command:`custom target <add_custom_target>` generated by
+CMake. By default that ``<ORIGIN>_autogen`` target inherits the dependencies
+of the ``<ORIGIN>`` target (see :prop_tgt:`AUTOGEN_ORIGIN_DEPENDS`).
+Target dependencies may be added to the ``<ORIGIN>_autogen`` target by adding
+them to the :prop_tgt:`AUTOGEN_TARGET_DEPENDS` target property.
+
+Visual Studio Generators
+========================
+
+When using the :manual:`Visual Studio generators <cmake-generators(7)>`, CMake
+generates a ``PRE_BUILD`` :command:`custom command <add_custom_command>`
+instead of the ``<ORIGIN>_autogen`` :command:`custom target <add_custom_target>`
+(for :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC`).
+This isn't always possible though and
+an ``<ORIGIN>_autogen`` :command:`custom target <add_custom_target>` is used,
+when either
+
+- the ``<ORIGIN>`` target depends on :prop_sf:`GENERATED` files which aren't
+ excluded from :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC` by
+ :prop_sf:`SKIP_AUTOMOC`, :prop_sf:`SKIP_AUTOUIC`, :prop_sf:`SKIP_AUTOGEN`
+ or :policy:`CMP0071`
+- :prop_tgt:`AUTOGEN_TARGET_DEPENDS` lists a source file
+- :variable:`CMAKE_GLOBAL_AUTOGEN_TARGET` is enabled
+
qtmain.lib on Windows
=====================
diff --git a/Help/manual/cmake-server.7.rst b/Help/manual/cmake-server.7.rst
index 9520cc140..8f10b9f0e 100644
--- a/Help/manual/cmake-server.7.rst
+++ b/Help/manual/cmake-server.7.rst
@@ -7,6 +7,11 @@ cmake-server(7)
.. contents::
+.. deprecated:: 3.15
+
+ This will be removed from a future version of CMake.
+ Clients should use the :manual:`cmake-file-api(7)` instead.
+
Introduction
============
@@ -49,10 +54,12 @@ Operation
Start :manual:`cmake(1)` in the server command mode, supplying the path to
the build directory to process::
- cmake -E server (--debug|--pipe <NAMED_PIPE>)
+ cmake -E server (--debug|--pipe=<NAMED_PIPE>)
The server will communicate using stdin/stdout (with the ``--debug`` parameter)
-or using a named pipe (with the ``--pipe <NAMED_PIPE>`` parameter).
+or using a named pipe (with the ``--pipe=<NAMED_PIPE>`` parameter). Note
+that "named pipe" refers to a local domain socket on Unix and to a named pipe
+on Windows.
When connecting to the server (via named pipe or by starting it in ``--debug``
mode), the server will reply with a hello message::
@@ -162,7 +169,7 @@ When the server is busy for a long time, it is polite to send back replies of
type "progress" to the client. These will contain a "progressMessage" with a
string describing the action currently taking place as well as
"progressMinimum", "progressMaximum" and "progressCurrent" with integer values
-describing the range of progess.
+describing the range of progress.
Messages of type "progress" will be followed by more "progress" messages or with
a message of type "reply" or "error" that complete the request.
@@ -254,6 +261,11 @@ versions supported by the cmake server. These are JSON objects with "major" and
as experimental. These will contain the "isExperimental" key set to true. Enabling
these requires a special command line argument when starting the cmake server mode.
+Within a "major" version all "minor" versions are fully backwards compatible.
+New "minor" versions may introduce functionality in such a way that existing
+clients of the same "major" version will continue to work, provided they
+ignore keys in the output that they do not know about.
+
Example::
[== "CMake Server" ==[
@@ -268,8 +280,9 @@ The first request that the client may send to the server is of type "handshake".
This request needs to pass one of the "supportedProtocolVersions" of the "hello"
type response received earlier back to the server in the "protocolVersion" field.
-
-Each protocol version may request additional attributes to be present.
+Giving the "major" version of the requested protocol version will make the server
+use the latest minor version of that protocol. Use this if you do not explicitly
+need to depend on a specific minor version.
Protocol version 1.0 requires the following attributes to be set:
@@ -280,6 +293,10 @@ Protocol version 1.0 requires the following attributes to be set:
* "platform" with the generator platform (if supported by the generator)
* "toolset" with the generator toolset (if supported by the generator)
+Protocol version 1.2 makes all but the build directory optional, provided
+there is a valid cache in the build directory that contains all the other
+information already.
+
Example::
[== "CMake Server" ==[
@@ -448,6 +465,11 @@ Each project object can have the following keys:
"name"
contains the (sub-)projects name.
+"minimumCMakeVersion"
+ contains the minimum cmake version allowed for this project, null if the
+ project doesn't specify one.
+"hasInstallRule"
+ true if the project contains any install rules, false otherwise.
"sourceDirectory"
contains the current source directory
"buildDirectory"
@@ -471,6 +493,12 @@ Each target object can have the following keys:
contains the current source directory.
"buildDirectory"
contains the current build directory.
+"isGeneratorProvided"
+ true if the target is auto-created by a generator, false otherwise
+"hasInstallRule"
+ true if the target contains any install rules, false otherwise.
+"installPaths"
+ full path to the destination directories defined by target install rules.
"artifacts"
with a list of build artifacts. The list is sorted with the most
important artifacts first (e.g. a .DLL file is listed before a
@@ -572,6 +600,51 @@ CMake will reply::
]== "CMake Server" ==]
+Type "ctestInfo"
+^^^^^^^^^^^^^^^^
+
+The "ctestInfo" request can be used after a project was "compute"d successfully.
+
+It will list the complete project test structure as it is known to cmake.
+
+The reply will contain a key "configurations", which will contain a list of
+configuration objects. Configuration objects are used to destinquish between
+different configurations the build directory might have enabled. While most
+generators only support one configuration, others might support several.
+
+Each configuration object can have the following keys:
+
+"name"
+ contains the name of the configuration. The name may be empty.
+"projects"
+ contains a list of project objects, one for each build project.
+
+Project objects define one (sub-)project defined in the cmake build system.
+
+Each project object can have the following keys:
+
+"name"
+ contains the (sub-)projects name.
+"ctestInfo"
+ contains a list of test objects.
+
+Each test object can have the following keys:
+
+"ctestName"
+ contains the name of the test.
+"ctestCommand"
+ contains the test command.
+"properties"
+ contains a list of test property objects.
+
+Each test property object can have the following keys:
+
+"key"
+ contains the test property key.
+"value"
+ contains the test property value.
+
+
Type "cmakeInputs"
^^^^^^^^^^^^^^^^^^
@@ -616,8 +689,7 @@ and will not survive the build directory getting cleaned out.
Type "cache"
^^^^^^^^^^^^
-The "cache" request can be used once a project is configured and will
-list the cached configuration values.
+The "cache" request will list the cached configuration values.
Example::
diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst
index 8554e87f9..f233d0884 100644
--- a/Help/manual/cmake-toolchains.7.rst
+++ b/Help/manual/cmake-toolchains.7.rst
@@ -26,13 +26,13 @@ built-in variables, such as
:variable:`CMAKE_CXX_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` etc are set by
invoking the :command:`project` command. If no project command
is in the top-level CMakeLists file, one will be implicitly generated. By default
-the enabled languages are C and CXX:
+the enabled languages are ``C`` and ``CXX``:
.. code-block:: cmake
project(C_Only C)
-A special value of NONE can also be used with the :command:`project` command
+A special value of ``NONE`` can also be used with the :command:`project` command
to enable no languages:
.. code-block:: cmake
@@ -101,6 +101,14 @@ values for the compilers.
The :variable:`CMAKE_CROSSCOMPILING` variable is set to true when CMake is
cross-compiling.
+Note that using the :variable:`CMAKE_SOURCE_DIR` or :variable:`CMAKE_BINARY_DIR`
+variables inside a toolchain file is typically undesirable. The toolchain
+file is used in contexts where these variables have different values when used
+in different places (e.g. as part of a call to :command:`try_compile`). In most
+cases, where there is a need to evaluate paths inside a toolchain file, the more
+appropriate variable to use would be :variable:`CMAKE_CURRENT_LIST_DIR`, since
+it always has an unambiguous, predictable value.
+
Cross Compiling for Linux
-------------------------
@@ -391,8 +399,10 @@ Configure use of an Android NDK with the following variables:
be false unless using a NDK that does not provide unified headers.
:variable:`CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION`
- Set to the version of the NDK toolchain to be selected as the compiler.
- If not specified, the default will be the latest available GCC toolchain.
+ On NDK r19 or above, this variable must be unset or set to ``clang``.
+ On NDK r18 or below, set this to the version of the NDK toolchain to
+ be selected as the compiler. If not specified, the default will be
+ the latest available GCC toolchain.
:variable:`CMAKE_ANDROID_STL_TYPE`
Set to specify which C++ standard library to use. If not specified,
@@ -468,10 +478,10 @@ The following variables will be computed and provided automatically:
The Android ABI detected from the standalone toolchain.
:variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_PREFIX`
- The absolute path prefix to the binutils in the standalone toolchain.
+ The absolute path prefix to the ``binutils`` in the standalone toolchain.
:variable:`CMAKE_<LANG>_ANDROID_TOOLCHAIN_SUFFIX`
- The host platform suffix of the binutils in the standalone toolchain.
+ The host platform suffix of the ``binutils`` in the standalone toolchain.
For example, a toolchain file might contain:
@@ -522,3 +532,132 @@ See also target properties:
* :prop_tgt:`ANDROID_SECURE_PROPS_PATH`
* :prop_tgt:`ANDROID_SKIP_ANT_STEP`
* :prop_tgt:`ANDROID_STL_TYPE`
+
+.. _`Cross Compiling for iOS, tvOS, or watchOS`:
+
+Cross Compiling for iOS, tvOS, or watchOS
+-----------------------------------------
+
+For cross-compiling to iOS, tvOS, or watchOS, the :generator:`Xcode`
+generator is recommended. The :generator:`Unix Makefiles` or
+:generator:`Ninja` generators can also be used, but they require the
+project to handle more areas like target CPU selection and code signing.
+
+Any of the three systems can be targeted by setting the
+:variable:`CMAKE_SYSTEM_NAME` variable to a value from the table below.
+By default, the latest Device SDK is chosen. As for all Apple platforms,
+a different SDK (e.g. a simulator) can be selected by setting the
+:variable:`CMAKE_OSX_SYSROOT` variable, although this should rarely be
+necessary (see :ref:`Switching Between Device and Simulator` below).
+A list of available SDKs can be obtained by running ``xcodebuild -showsdks``.
+
+======= ================= ==================== ================
+OS CMAKE_SYSTEM_NAME Device SDK (default) Simulator SDK
+======= ================= ==================== ================
+iOS iOS iphoneos iphonesimulator
+tvOS tvOS appletvos appletvsimulator
+watchOS watchOS watchos watchsimulator
+======= ================= ==================== ================
+
+For example, to create a CMake configuration for iOS, the following
+command is sufficient:
+
+.. code-block:: console
+
+ cmake .. -GXcode -DCMAKE_SYSTEM_NAME=iOS
+
+Variable :variable:`CMAKE_OSX_ARCHITECTURES` can be used to set architectures
+for both device and simulator. Variable :variable:`CMAKE_OSX_DEPLOYMENT_TARGET`
+can be used to set an iOS/tvOS/watchOS deployment target.
+
+Next configuration will install fat 5 architectures iOS library
+and add the ``-miphoneos-version-min=9.3``/``-mios-simulator-version-min=9.3``
+flags to the compiler:
+
+.. code-block:: console
+
+ $ cmake -S. -B_builds -GXcode \
+ -DCMAKE_SYSTEM_NAME=iOS \
+ "-DCMAKE_OSX_ARCHITECTURES=armv7;armv7s;arm64;i386;x86_64" \
+ -DCMAKE_OSX_DEPLOYMENT_TARGET=9.3 \
+ -DCMAKE_INSTALL_PREFIX=`pwd`/_install \
+ -DCMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=NO \
+ -DCMAKE_IOS_INSTALL_COMBINED=YES
+
+Example:
+
+.. code-block:: cmake
+
+ # CMakeLists.txt
+ cmake_minimum_required(VERSION 3.14)
+ project(foo)
+ add_library(foo foo.cpp)
+ install(TARGETS foo DESTINATION lib)
+
+Install:
+
+.. code-block:: console
+
+ $ cmake --build _builds --config Release --target install
+
+Check library:
+
+.. code-block:: console
+
+ $ lipo -info _install/lib/libfoo.a
+ Architectures in the fat file: _install/lib/libfoo.a are: i386 armv7 armv7s x86_64 arm64
+
+.. code-block:: console
+
+ $ otool -l _install/lib/libfoo.a | grep -A2 LC_VERSION_MIN_IPHONEOS
+ cmd LC_VERSION_MIN_IPHONEOS
+ cmdsize 16
+ version 9.3
+
+Code Signing
+^^^^^^^^^^^^
+
+Some build artifacts for the embedded Apple platforms require mandatory
+code signing. If the :generator:`Xcode` generator is being used and
+code signing is required or desired, the development team ID can be
+specified via the ``CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM`` CMake variable.
+This team ID will then be included in the generated Xcode project.
+By default, CMake avoids the need for code signing during the internal
+configuration phase (i.e compiler ID and feature detection).
+
+.. _`Switching Between Device and Simulator`:
+
+Switching Between Device and Simulator
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+When configuring for any of the embedded platforms, one can target either
+real devices or the simulator. Both have their own separate SDK, but CMake
+only supports specifying a single SDK for the configuration phase. This
+means the developer must select one or the other at configuration time.
+When using the :generator:`Xcode` generator, this is less of a limitation
+because Xcode still allows you to build for either a device or a simulator,
+even though configuration was only performed for one of the two. From
+within the Xcode IDE, builds are performed for the selected "destination"
+platform. When building from the command line, the desired sdk can be
+specified directly by passing a ``-sdk`` option to the underlying build
+tool (``xcodebuild``). For example:
+
+.. code-block:: console
+
+ $ cmake --build ... -- -sdk iphonesimulator
+
+Please note that checks made during configuration were performed against
+the configure-time SDK and might not hold true for other SDKs. Commands
+like :command:`find_package`, :command:`find_library`, etc. store and use
+details only for the configured SDK/platform, so they can be problematic
+if wanting to switch between device and simulator builds. You can follow
+the next rules to make device + simulator configuration work:
+
+- Use explicit ``-l`` linker flag,
+ e.g. ``target_link_libraries(foo PUBLIC "-lz")``
+
+- Use explicit ``-framework`` linker flag,
+ e.g. ``target_link_libraries(foo PUBLIC "-framework CoreFoundation")``
+
+- Use :command:`find_package` only for libraries installed with
+ :variable:`CMAKE_IOS_INSTALL_COMBINED` feature
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 1a2726dd3..53b7f8ddd 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -7,6 +7,14 @@ cmake-variables(7)
.. contents::
+This page documents variables that are provided by CMake
+or have meaning to CMake when set by project code.
+
+For general information on variables, see the
+:ref:`Variables <CMake Language Variables>`
+section in the cmake-language manual.
+
+
Variables that Provide Information
==================================
@@ -24,6 +32,7 @@ Variables that Provide Information
/variable/CMAKE_CACHE_PATCH_VERSION
/variable/CMAKE_CFG_INTDIR
/variable/CMAKE_COMMAND
+ /variable/CMAKE_CPACK_COMMAND
/variable/CMAKE_CROSSCOMPILING
/variable/CMAKE_CROSSCOMPILING_EMULATOR
/variable/CMAKE_CTEST_COMMAND
@@ -32,7 +41,9 @@ Variables that Provide Information
/variable/CMAKE_CURRENT_LIST_FILE
/variable/CMAKE_CURRENT_LIST_LINE
/variable/CMAKE_CURRENT_SOURCE_DIR
+ /variable/CMAKE_DIRECTORY_LABELS
/variable/CMAKE_DL_LIBS
+ /variable/CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION
/variable/CMAKE_EDIT_COMMAND
/variable/CMAKE_EXECUTABLE_SUFFIX
/variable/CMAKE_EXTRA_GENERATOR
@@ -41,15 +52,17 @@ Variables that Provide Information
/variable/CMAKE_FIND_PACKAGE_SORT_DIRECTION
/variable/CMAKE_FIND_PACKAGE_SORT_ORDER
/variable/CMAKE_GENERATOR
+ /variable/CMAKE_GENERATOR_INSTANCE
/variable/CMAKE_GENERATOR_PLATFORM
/variable/CMAKE_GENERATOR_TOOLSET
- /variable/CMAKE_HOME_DIRECTORY
/variable/CMAKE_IMPORT_LIBRARY_PREFIX
/variable/CMAKE_IMPORT_LIBRARY_SUFFIX
/variable/CMAKE_JOB_POOL_COMPILE
/variable/CMAKE_JOB_POOL_LINK
+ /variable/CMAKE_JOB_POOLS
/variable/CMAKE_LANG_COMPILER_AR
/variable/CMAKE_LANG_COMPILER_RANLIB
+ /variable/CMAKE_LANG_LINK_LIBRARY_SUFFIX
/variable/CMAKE_LINK_LIBRARY_SUFFIX
/variable/CMAKE_LINK_SEARCH_END_STATIC
/variable/CMAKE_LINK_SEARCH_START_STATIC
@@ -57,14 +70,24 @@ Variables that Provide Information
/variable/CMAKE_MAKE_PROGRAM
/variable/CMAKE_MATCH_COUNT
/variable/CMAKE_MATCH_n
+ /variable/CMAKE_MESSAGE_INDENT
/variable/CMAKE_MINIMUM_REQUIRED_VERSION
/variable/CMAKE_MINOR_VERSION
+ /variable/CMAKE_NETRC
+ /variable/CMAKE_NETRC_FILE
/variable/CMAKE_PARENT_LIST_FILE
/variable/CMAKE_PATCH_VERSION
/variable/CMAKE_PROJECT_DESCRIPTION
+ /variable/CMAKE_PROJECT_HOMEPAGE_URL
/variable/CMAKE_PROJECT_NAME
+ /variable/CMAKE_PROJECT_VERSION
+ /variable/CMAKE_PROJECT_VERSION_MAJOR
+ /variable/CMAKE_PROJECT_VERSION_MINOR
+ /variable/CMAKE_PROJECT_VERSION_PATCH
+ /variable/CMAKE_PROJECT_VERSION_TWEAK
/variable/CMAKE_RANLIB
/variable/CMAKE_ROOT
+ /variable/CMAKE_RULE_MESSAGES
/variable/CMAKE_SCRIPT_MODE_FILE
/variable/CMAKE_SHARED_LIBRARY_PREFIX
/variable/CMAKE_SHARED_LIBRARY_SUFFIX
@@ -76,22 +99,28 @@ Variables that Provide Information
/variable/CMAKE_SOURCE_DIR
/variable/CMAKE_STATIC_LIBRARY_PREFIX
/variable/CMAKE_STATIC_LIBRARY_SUFFIX
+ /variable/CMAKE_Swift_MODULE_DIRECTORY
+ /variable/CMAKE_Swift_NUM_THREADS
/variable/CMAKE_TOOLCHAIN_FILE
/variable/CMAKE_TWEAK_VERSION
/variable/CMAKE_VERBOSE_MAKEFILE
/variable/CMAKE_VERSION
/variable/CMAKE_VS_DEVENV_COMMAND
- /variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION
/variable/CMAKE_VS_MSBUILD_COMMAND
/variable/CMAKE_VS_NsightTegra_VERSION
/variable/CMAKE_VS_PLATFORM_NAME
+ /variable/CMAKE_VS_PLATFORM_NAME_DEFAULT
/variable/CMAKE_VS_PLATFORM_TOOLSET
/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA
+ /variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR
/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE
+ /variable/CMAKE_VS_PLATFORM_TOOLSET_VERSION
/variable/CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION
/variable/CMAKE_XCODE_GENERATE_SCHEME
/variable/CMAKE_XCODE_PLATFORM_TOOLSET
/variable/PROJECT-NAME_BINARY_DIR
+ /variable/PROJECT-NAME_DESCRIPTION
+ /variable/PROJECT-NAME_HOMEPAGE_URL
/variable/PROJECT-NAME_SOURCE_DIR
/variable/PROJECT-NAME_VERSION
/variable/PROJECT-NAME_VERSION_MAJOR
@@ -100,6 +129,7 @@ Variables that Provide Information
/variable/PROJECT-NAME_VERSION_TWEAK
/variable/PROJECT_BINARY_DIR
/variable/PROJECT_DESCRIPTION
+ /variable/PROJECT_HOMEPAGE_URL
/variable/PROJECT_NAME
/variable/PROJECT_SOURCE_DIR
/variable/PROJECT_VERSION
@@ -120,6 +150,8 @@ Variables that Change Behavior
/variable/CMAKE_AUTOMOC_RELAXED_MODE
/variable/CMAKE_BACKWARDS_COMPATIBILITY
/variable/CMAKE_BUILD_TYPE
+ /variable/CMAKE_CODEBLOCKS_COMPILER_ID
+ /variable/CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES
/variable/CMAKE_CODELITE_USE_TARGETS
/variable/CMAKE_COLOR_MAKEFILE
/variable/CMAKE_CONFIGURATION_TYPES
@@ -129,10 +161,13 @@ Variables that Change Behavior
/variable/CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES
/variable/CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT
/variable/CMAKE_ECLIPSE_MAKE_ARGUMENTS
+ /variable/CMAKE_ECLIPSE_RESOURCE_ENCODING
/variable/CMAKE_ECLIPSE_VERSION
/variable/CMAKE_ERROR_DEPRECATED
/variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
+ /variable/CMAKE_EXECUTE_PROCESS_COMMAND_ECHO
/variable/CMAKE_EXPORT_COMPILE_COMMANDS
+ /variable/CMAKE_EXPORT_PACKAGE_REGISTRY
/variable/CMAKE_EXPORT_NO_PACKAGE_REGISTRY
/variable/CMAKE_FIND_APPBUNDLE
/variable/CMAKE_FIND_FRAMEWORK
@@ -142,34 +177,48 @@ Variables that Change Behavior
/variable/CMAKE_FIND_NO_INSTALL_PREFIX
/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
/variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
+ /variable/CMAKE_FIND_PACKAGE_PREFER_CONFIG
+ /variable/CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS
/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE
/variable/CMAKE_FIND_ROOT_PATH
/variable/CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
/variable/CMAKE_FIND_ROOT_PATH_MODE_LIBRARY
/variable/CMAKE_FIND_ROOT_PATH_MODE_PACKAGE
/variable/CMAKE_FIND_ROOT_PATH_MODE_PROGRAM
+ /variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH
+ /variable/CMAKE_FIND_USE_CMAKE_PATH
+ /variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH
+ /variable/CMAKE_FIND_USE_PACKAGE_REGISTRY
+ /variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH
+ /variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH
+ /variable/CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY
/variable/CMAKE_FRAMEWORK_PATH
/variable/CMAKE_IGNORE_PATH
/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE
/variable/CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE
/variable/CMAKE_INCLUDE_PATH
/variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME
+ /variable/CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
/variable/CMAKE_INSTALL_MESSAGE
/variable/CMAKE_INSTALL_PREFIX
/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
/variable/CMAKE_LIBRARY_PATH
+ /variable/CMAKE_LINK_DIRECTORIES_BEFORE
/variable/CMAKE_MFC_FLAG
+ /variable/CMAKE_MAXIMUM_RECURSION_DEPTH
/variable/CMAKE_MODULE_PATH
- /variable/CMAKE_NOT_USING_CONFIG_FLAGS
/variable/CMAKE_POLICY_DEFAULT_CMPNNNN
/variable/CMAKE_POLICY_WARNING_CMPNNNN
/variable/CMAKE_PREFIX_PATH
/variable/CMAKE_PROGRAM_PATH
+ /variable/CMAKE_PROJECT_INCLUDE
+ /variable/CMAKE_PROJECT_INCLUDE_BEFORE
/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE
/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY
/variable/CMAKE_STAGING_PREFIX
/variable/CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS
/variable/CMAKE_SUBLIME_TEXT_2_EXCLUDE_BUILD_TREE
+ /variable/CMAKE_SUPPRESS_REGENERATION
/variable/CMAKE_SYSROOT
/variable/CMAKE_SYSROOT_COMPILE
/variable/CMAKE_SYSROOT_LINK
@@ -183,6 +232,24 @@ Variables that Change Behavior
/variable/CMAKE_USER_MAKE_RULES_OVERRIDE
/variable/CMAKE_WARN_DEPRECATED
/variable/CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION
+ /variable/CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY
+ /variable/CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER
+ /variable/CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN
+ /variable/CMAKE_XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING
+ /variable/CMAKE_XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER
+ /variable/CMAKE_XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS
+ /variable/CMAKE_XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE
+ /variable/CMAKE_XCODE_SCHEME_GUARD_MALLOC
+ /variable/CMAKE_XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP
+ /variable/CMAKE_XCODE_SCHEME_MALLOC_GUARD_EDGES
+ /variable/CMAKE_XCODE_SCHEME_MALLOC_SCRIBBLE
+ /variable/CMAKE_XCODE_SCHEME_MALLOC_STACK
+ /variable/CMAKE_XCODE_SCHEME_THREAD_SANITIZER
+ /variable/CMAKE_XCODE_SCHEME_THREAD_SANITIZER_STOP
+ /variable/CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER
+ /variable/CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP
+ /variable/CMAKE_XCODE_SCHEME_ZOMBIE_OBJECTS
+ /variable/PackageName_ROOT
Variables that Describe the System
==================================
@@ -211,8 +278,8 @@ Variables that Describe the System
/variable/CMAKE_SYSTEM_PROCESSOR
/variable/CMAKE_SYSTEM_VERSION
/variable/CYGWIN
- /variable/ENV
/variable/GHS-MULTI
+ /variable/IOS
/variable/MINGW
/variable/MSVC
/variable/MSVC10
@@ -225,7 +292,9 @@ Variables that Describe the System
/variable/MSVC80
/variable/MSVC90
/variable/MSVC_IDE
+ /variable/MSVC_TOOLSET_VERSION
/variable/MSVC_VERSION
+ /variable/MSYS
/variable/UNIX
/variable/WIN32
/variable/WINCE
@@ -267,32 +336,50 @@ Variables that Control the Build
/variable/CMAKE_ANDROID_STL_TYPE
/variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY
/variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY_CONFIG
+ /variable/CMAKE_AUTOGEN_ORIGIN_DEPENDS
+ /variable/CMAKE_AUTOGEN_PARALLEL
+ /variable/CMAKE_AUTOGEN_VERBOSE
/variable/CMAKE_AUTOMOC
+ /variable/CMAKE_AUTOMOC_COMPILER_PREDEFINES
/variable/CMAKE_AUTOMOC_DEPEND_FILTERS
+ /variable/CMAKE_AUTOMOC_MACRO_NAMES
/variable/CMAKE_AUTOMOC_MOC_OPTIONS
+ /variable/CMAKE_AUTOMOC_PATH_PREFIX
/variable/CMAKE_AUTORCC
/variable/CMAKE_AUTORCC_OPTIONS
/variable/CMAKE_AUTOUIC
/variable/CMAKE_AUTOUIC_OPTIONS
/variable/CMAKE_AUTOUIC_SEARCH_PATHS
/variable/CMAKE_BUILD_RPATH
+ /variable/CMAKE_BUILD_RPATH_USE_ORIGIN
/variable/CMAKE_BUILD_WITH_INSTALL_NAME_DIR
/variable/CMAKE_BUILD_WITH_INSTALL_RPATH
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
/variable/CMAKE_CONFIG_POSTFIX
+ /variable/CMAKE_CUDA_SEPARABLE_COMPILATION
+ /variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS
/variable/CMAKE_DEBUG_POSTFIX
+ /variable/CMAKE_DISABLE_PRECOMPILE_HEADERS
/variable/CMAKE_ENABLE_EXPORTS
/variable/CMAKE_EXE_LINKER_FLAGS
/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG
/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG_INIT
/variable/CMAKE_EXE_LINKER_FLAGS_INIT
+ /variable/CMAKE_FOLDER
+ /variable/CMAKE_FRAMEWORK
/variable/CMAKE_Fortran_FORMAT
/variable/CMAKE_Fortran_MODULE_DIRECTORY
+ /variable/CMAKE_GHS_NO_SOURCE_GROUP_FILE
+ /variable/CMAKE_GLOBAL_AUTOGEN_TARGET
+ /variable/CMAKE_GLOBAL_AUTOGEN_TARGET_NAME
+ /variable/CMAKE_GLOBAL_AUTORCC_TARGET
+ /variable/CMAKE_GLOBAL_AUTORCC_TARGET_NAME
/variable/CMAKE_GNUtoMS
/variable/CMAKE_INCLUDE_CURRENT_DIR
/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE
/variable/CMAKE_INSTALL_NAME_DIR
+ /variable/CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH
/variable/CMAKE_INSTALL_RPATH
/variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH
/variable/CMAKE_INTERPROCEDURAL_OPTIMIZATION
@@ -300,8 +387,11 @@ Variables that Control the Build
/variable/CMAKE_IOS_INSTALL_COMBINED
/variable/CMAKE_LANG_CLANG_TIDY
/variable/CMAKE_LANG_COMPILER_LAUNCHER
+ /variable/CMAKE_LANG_CPPCHECK
/variable/CMAKE_LANG_CPPLINT
/variable/CMAKE_LANG_INCLUDE_WHAT_YOU_USE
+ /variable/CMAKE_LANG_LINK_LIBRARY_FILE_FLAG
+ /variable/CMAKE_LANG_LINK_LIBRARY_FLAG
/variable/CMAKE_LANG_VISIBILITY_PRESET
/variable/CMAKE_LIBRARY_OUTPUT_DIRECTORY
/variable/CMAKE_LIBRARY_OUTPUT_DIRECTORY_CONFIG
@@ -319,6 +409,8 @@ Variables that Control the Build
/variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG
/variable/CMAKE_MODULE_LINKER_FLAGS_CONFIG_INIT
/variable/CMAKE_MODULE_LINKER_FLAGS_INIT
+ /variable/CMAKE_MSVCIDE_RUN_PATH
+ /variable/CMAKE_MSVC_RUNTIME_LIBRARY
/variable/CMAKE_NINJA_OUTPUT_PATH_PREFIX
/variable/CMAKE_NO_BUILTIN_CHRPATH
/variable/CMAKE_NO_SYSTEM_FROM_IMPORTED
@@ -343,10 +435,22 @@ Variables that Control the Build
/variable/CMAKE_TRY_COMPILE_CONFIGURATION
/variable/CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
/variable/CMAKE_TRY_COMPILE_TARGET_TYPE
+ /variable/CMAKE_UNITY_BUILD
+ /variable/CMAKE_UNITY_BUILD_BATCH_SIZE
/variable/CMAKE_USE_RELATIVE_PATHS
/variable/CMAKE_VISIBILITY_INLINES_HIDDEN
+ /variable/CMAKE_VS_GLOBALS
/variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD
/variable/CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD
+ /variable/CMAKE_VS_JUST_MY_CODE_DEBUGGING
+ /variable/CMAKE_VS_SDK_EXCLUDE_DIRECTORIES
+ /variable/CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES
+ /variable/CMAKE_VS_SDK_INCLUDE_DIRECTORIES
+ /variable/CMAKE_VS_SDK_LIBRARY_DIRECTORIES
+ /variable/CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES
+ /variable/CMAKE_VS_SDK_REFERENCE_DIRECTORIES
+ /variable/CMAKE_VS_SDK_SOURCE_DIRECTORIES
+ /variable/CMAKE_VS_WINRT_BY_DEFAULT
/variable/CMAKE_WIN32_EXECUTABLE
/variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS
/variable/CMAKE_XCODE_ATTRIBUTE_an-attribute
@@ -362,6 +466,7 @@ Variables for Languages
/variable/CMAKE_COMPILER_IS_GNUCC
/variable/CMAKE_COMPILER_IS_GNUCXX
/variable/CMAKE_COMPILER_IS_GNUG77
+ /variable/CMAKE_CUDA_HOST_COMPILER
/variable/CMAKE_CUDA_EXTENSIONS
/variable/CMAKE_CUDA_STANDARD
/variable/CMAKE_CUDA_STANDARD_REQUIRED
@@ -377,7 +482,6 @@ Variables for Languages
/variable/CMAKE_Fortran_MODDIR_DEFAULT
/variable/CMAKE_Fortran_MODDIR_FLAG
/variable/CMAKE_Fortran_MODOUT_FLAG
- /variable/CMAKE_INTERNAL_PLATFORM_ABI
/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_MACHINE
/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_PREFIX
/variable/CMAKE_LANG_ANDROID_TOOLCHAIN_SUFFIX
@@ -385,10 +489,10 @@ Variables for Languages
/variable/CMAKE_LANG_ARCHIVE_CREATE
/variable/CMAKE_LANG_ARCHIVE_FINISH
/variable/CMAKE_LANG_COMPILER
- /variable/CMAKE_LANG_COMPILER_ABI
/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN
/variable/CMAKE_LANG_COMPILER_ID
/variable/CMAKE_LANG_COMPILER_LOADED
+ /variable/CMAKE_LANG_COMPILER_PREDEFINES_COMMAND
/variable/CMAKE_LANG_COMPILER_TARGET
/variable/CMAKE_LANG_COMPILER_VERSION
/variable/CMAKE_LANG_COMPILE_OBJECT
@@ -396,6 +500,8 @@ Variables for Languages
/variable/CMAKE_LANG_CREATE_SHARED_MODULE
/variable/CMAKE_LANG_CREATE_STATIC_LIBRARY
/variable/CMAKE_LANG_FLAGS
+ /variable/CMAKE_LANG_FLAGS_CONFIG
+ /variable/CMAKE_LANG_FLAGS_CONFIG_INIT
/variable/CMAKE_LANG_FLAGS_DEBUG
/variable/CMAKE_LANG_FLAGS_DEBUG_INIT
/variable/CMAKE_LANG_FLAGS_INIT
@@ -405,10 +511,6 @@ Variables for Languages
/variable/CMAKE_LANG_FLAGS_RELEASE_INIT
/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO
/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO_INIT
- /variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG
- /variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL
- /variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE
- /variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO
/variable/CMAKE_LANG_IGNORE_EXTENSIONS
/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES
/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES
@@ -417,15 +519,22 @@ Variables for Languages
/variable/CMAKE_LANG_LIBRARY_ARCHITECTURE
/variable/CMAKE_LANG_LINKER_PREFERENCE
/variable/CMAKE_LANG_LINKER_PREFERENCE_PROPAGATES
+ /variable/CMAKE_LANG_LINKER_WRAPPER_FLAG
+ /variable/CMAKE_LANG_LINKER_WRAPPER_FLAG_SEP
/variable/CMAKE_LANG_LINK_EXECUTABLE
/variable/CMAKE_LANG_OUTPUT_EXTENSION
- /variable/CMAKE_LANG_PLATFORM_ID
/variable/CMAKE_LANG_SIMULATE_ID
/variable/CMAKE_LANG_SIMULATE_VERSION
/variable/CMAKE_LANG_SIZEOF_DATA_PTR
/variable/CMAKE_LANG_SOURCE_FILE_EXTENSIONS
/variable/CMAKE_LANG_STANDARD_INCLUDE_DIRECTORIES
/variable/CMAKE_LANG_STANDARD_LIBRARIES
+ /variable/CMAKE_OBJC_EXTENSIONS
+ /variable/CMAKE_OBJC_STANDARD
+ /variable/CMAKE_OBJC_STANDARD_REQUIRED
+ /variable/CMAKE_OBJCXX_EXTENSIONS
+ /variable/CMAKE_OBJCXX_STANDARD
+ /variable/CMAKE_OBJCXX_STANDARD_REQUIRED
/variable/CMAKE_Swift_LANGUAGE_VERSION
/variable/CMAKE_USER_MAKE_RULES_OVERRIDE_LANG
@@ -461,7 +570,7 @@ Variables for CTest
/variable/CTEST_CUSTOM_POST_TEST
/variable/CTEST_CUSTOM_PRE_MEMCHECK
/variable/CTEST_CUSTOM_PRE_TEST
- /variable/CTEST_CUSTOM_TEST_IGNORE
+ /variable/CTEST_CUSTOM_TESTS_IGNORE
/variable/CTEST_CUSTOM_WARNING_EXCEPTION
/variable/CTEST_CUSTOM_WARNING_MATCH
/variable/CTEST_CVS_CHECKOUT
@@ -480,6 +589,7 @@ Variables for CTest
/variable/CTEST_GIT_UPDATE_OPTIONS
/variable/CTEST_HG_COMMAND
/variable/CTEST_HG_UPDATE_OPTIONS
+ /variable/CTEST_LABELS_FOR_SUBPROJECTS
/variable/CTEST_MEMORYCHECK_COMMAND
/variable/CTEST_MEMORYCHECK_COMMAND_OPTIONS
/variable/CTEST_MEMORYCHECK_SANITIZER_OPTIONS
@@ -490,8 +600,10 @@ Variables for CTest
/variable/CTEST_P4_COMMAND
/variable/CTEST_P4_OPTIONS
/variable/CTEST_P4_UPDATE_OPTIONS
+ /variable/CTEST_RUN_CURRENT_SCRIPT
/variable/CTEST_SCP_COMMAND
/variable/CTEST_SITE
+ /variable/CTEST_SUBMIT_URL
/variable/CTEST_SOURCE_DIRECTORY
/variable/CTEST_SVN_COMMAND
/variable/CTEST_SVN_OPTIONS
@@ -502,6 +614,7 @@ Variables for CTest
/variable/CTEST_UPDATE_COMMAND
/variable/CTEST_UPDATE_OPTIONS
/variable/CTEST_UPDATE_VERSION_ONLY
+ /variable/CTEST_UPDATE_VERSION_OVERRIDE
/variable/CTEST_USE_LAUNCHERS
Variables for CPack
@@ -514,7 +627,36 @@ Variables for CPack
/variable/CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY
/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
/variable/CPACK_INCLUDE_TOPLEVEL_DIRECTORY
- /variable/CPACK_INSTALL_SCRIPT
+ /variable/CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
/variable/CPACK_PACKAGING_INSTALL_PREFIX
/variable/CPACK_SET_DESTDIR
/variable/CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION
+
+Variable Expansion Operators
+============================
+
+.. toctree::
+ :maxdepth: 1
+
+ /variable/CACHE
+ /variable/ENV
+
+Internal Variables
+==================
+
+CMake has many internal variables. Most of them are undocumented.
+Some of them, however, were at some point described as normal
+variables, and therefore may be encountered in legacy code. They
+are subject to change, and not recommended for use in project code.
+
+.. toctree::
+ :maxdepth: 1
+
+ /variable/CMAKE_HOME_DIRECTORY
+ /variable/CMAKE_INTERNAL_PLATFORM_ABI
+ /variable/CMAKE_LANG_COMPILER_ABI
+ /variable/CMAKE_LANG_COMPILER_ARCHITECTURE_ID
+ /variable/CMAKE_LANG_COMPILER_VERSION_INTERNAL
+ /variable/CMAKE_LANG_PLATFORM_ID
+ /variable/CMAKE_NOT_USING_CONFIG_FLAGS
+ /variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index ba925e8ec..4ab55a0d0 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -8,72 +8,190 @@ Synopsis
.. parsed-literal::
- cmake [<options>] (<path-to-source> | <path-to-existing-build>)
- cmake [(-D <var>=<value>)...] -P <cmake-script-file>
- cmake --build <dir> [<options>...] [-- <build-tool-options>...]
- cmake -E <command> [<options>...]
- cmake --find-package <options>...
+ `Generate a Project Buildsystem`_
+ cmake [<options>] <path-to-source>
+ cmake [<options>] <path-to-existing-build>
+ cmake [<options>] -S <path-to-source> -B <path-to-build>
+
+ `Build a Project`_
+ cmake --build <dir> [<options>] [-- <build-tool-options>]
+
+ `Install a Project`_
+ cmake --install <dir> [<options>]
+
+ `Open a Project`_
+ cmake --open <dir>
+
+ `Run a Script`_
+ cmake [{-D <var>=<value>}...] -P <cmake-script-file>
+
+ `Run a Command-Line Tool`_
+ cmake -E <command> [<options>]
+
+ `Run the Find-Package Tool`_
+ cmake --find-package [<options>]
+
+ `View Help`_
+ cmake --help[-<topic>]
Description
===========
-The "cmake" executable is the CMake command-line interface. It may be
-used to configure projects in scripts. Project configuration settings
-may be specified on the command line with the -D option.
+The **cmake** executable is the command-line interface of the cross-platform
+buildsystem generator CMake. The above `Synopsis`_ lists various actions
+the tool can perform as described in sections below.
+
+To build a software project with CMake, `Generate a Project Buildsystem`_.
+Optionally use **cmake** to `Build a Project`_, `Install a Project`_ or just
+run the corresponding build tool (e.g. ``make``) directly. **cmake** can also
+be used to `View Help`_.
+
+The other actions are meant for use by software developers writing
+scripts in the :manual:`CMake language <cmake-language(7)>` to support
+their builds.
+
+For graphical user interfaces that may be used in place of **cmake**,
+see :manual:`ccmake <ccmake(1)>` and :manual:`cmake-gui <cmake-gui(1)>`.
+For command-line interfaces to the CMake testing and packaging facilities,
+see :manual:`ctest <ctest(1)>` and :manual:`cpack <cpack(1)>`.
+
+For more information on CMake at large, `see also`_ the links at the end
+of this manual.
+
+
+Introduction to CMake Buildsystems
+==================================
+
+A *buildsystem* describes how to build a project's executables and libraries
+from its source code using a *build tool* to automate the process. For
+example, a buildsystem may be a ``Makefile`` for use with a command-line
+``make`` tool or a project file for an Integrated Development Environment
+(IDE). In order to avoid maintaining multiple such buildsystems, a project
+may specify its buildsystem abstractly using files written in the
+:manual:`CMake language <cmake-language(7)>`. From these files CMake
+generates a preferred buildsystem locally for each user through a backend
+called a *generator*.
+
+To generate a buildsystem with CMake, the following must be selected:
+
+Source Tree
+ The top-level directory containing source files provided by the project.
+ The project specifies its buildsystem using files as described in the
+ :manual:`cmake-language(7)` manual, starting with a top-level file named
+ ``CMakeLists.txt``. These files specify build targets and their
+ dependencies as described in the :manual:`cmake-buildsystem(7)` manual.
+
+Build Tree
+ The top-level directory in which buildsystem files and build output
+ artifacts (e.g. executables and libraries) are to be stored.
+ CMake will write a ``CMakeCache.txt`` file to identify the directory
+ as a build tree and store persistent information such as buildsystem
+ configuration options.
+
+ To maintain a pristine source tree, perform an *out-of-source* build
+ by using a separate dedicated build tree. An *in-source* build in
+ which the build tree is placed in the same directory as the source
+ tree is also supported, but discouraged.
+
+Generator
+ This chooses the kind of buildsystem to generate. See the
+ :manual:`cmake-generators(7)` manual for documentation of all generators.
+ Run ``cmake --help`` to see a list of generators available locally.
+ Optionally use the ``-G`` option below to specify a generator, or simply
+ accept the default CMake chooses for the current platform.
+
+ When using one of the :ref:`Command-Line Build Tool Generators`
+ CMake expects that the environment needed by the compiler toolchain
+ is already configured in the shell. When using one of the
+ :ref:`IDE Build Tool Generators`, no particular environment is needed.
+
+
+Generate a Project Buildsystem
+==============================
+
+Run CMake with one of the following command signatures to specify the
+source and build trees and generate a buildsystem:
+
+``cmake [<options>] <path-to-source>``
+ Uses the current working directory as the build tree, and
+ ``<path-to-source>`` as the source tree. The specified path may
+ be absolute or relative to the current working directory.
+ The source tree must contain a ``CMakeLists.txt`` file and must
+ *not* contain a ``CMakeCache.txt`` file because the latter
+ identifies an existing build tree. For example:
+
+ .. code-block:: console
+
+ $ mkdir build ; cd build
+ $ cmake ../src
+
+``cmake [<options>] <path-to-existing-build>``
+ Uses ``<path-to-existing-build>`` as the build tree, and loads the
+ path to the source tree from its ``CMakeCache.txt`` file, which must
+ have already been generated by a previous run of CMake. The specified
+ path may be absolute or relative to the current working directory.
+ For example:
+
+ .. code-block:: console
+
+ $ cd build
+ $ cmake .
+
+``cmake [<options>] -S <path-to-source> -B <path-to-build>``
+ Uses ``<path-to-build>`` as the build tree and ``<path-to-source>``
+ as the source tree. The specified paths may be absolute or relative
+ to the current working directory. The source tree must contain a
+ ``CMakeLists.txt`` file. The build tree will be created automatically
+ if it does not already exist. For example:
+
+ .. code-block:: console
+
+ $ cmake -S src -B build
+
+In all cases the ``<options>`` may be zero or more of the `Options`_ below.
-CMake is a cross-platform build system generator. Projects specify
-their build process with platform-independent CMake listfiles included
-in each directory of a source tree with the name CMakeLists.txt.
-Users build a project by using CMake to generate a build system for a
-native tool on their platform.
+After generating a buildsystem one may use the corresponding native
+build tool to build the project. For example, after using the
+:generator:`Unix Makefiles` generator one may run ``make`` directly:
+
+ .. code-block:: console
+
+ $ make
+ $ make install
+
+Alternatively, one may use **cmake** to `Build a Project`_ by
+automatically choosing and invoking the appropriate native build tool.
.. _`CMake Options`:
Options
-=======
+-------
.. include:: OPTIONS_BUILD.txt
-``-E <command> [<options>...]``
- See `Command-Line Tool Mode`_.
-
``-L[A][H]``
List non-advanced cached variables.
- List cache variables will run CMake and list all the variables from
- the CMake cache that are not marked as INTERNAL or ADVANCED. This
- will effectively display current CMake settings, which can then be
- changed with -D option. Changing some of the variables may result
- in more variables being created. If A is specified, then it will
- display also advanced variables. If H is specified, it will also
+ List ``CACHE`` variables will run CMake and list all the variables from
+ the CMake ``CACHE`` that are not marked as ``INTERNAL`` or :prop_cache:`ADVANCED`.
+ This will effectively display current CMake settings, which can then be
+ changed with ``-D`` option. Changing some of the variables may result
+ in more variables being created. If ``A`` is specified, then it will
+ display also advanced variables. If ``H`` is specified, it will also
display help for each variable.
-``--build <dir>``
- See `Build Tool Mode`_.
-
``-N``
View mode only.
Only load the cache. Do not actually run configure and generate
steps.
-``-P <file>``
- Process script mode.
-
- Process the given cmake file as a script written in the CMake
- language. No configure or generate step is performed and the cache
- is not modified. If variables are defined using -D, this must be
- done before the -P argument.
-
-``--find-package``
- See `Find-Package Tool Mode`_.
-
``--graphviz=[file]``
- Generate graphviz of dependencies, see CMakeGraphVizOptions.cmake for more.
+ Generate graphviz of dependencies, see :module:`CMakeGraphVizOptions` for more.
Generate a graphviz input file that will contain all the library and
executable dependencies in the project. See the documentation for
- CMakeGraphVizOptions.cmake for more details.
+ :module:`CMakeGraphVizOptions` for more details.
``--system-information [file]``
Dump information about this system.
@@ -82,10 +200,20 @@ Options
from the top of a binary tree for a CMake project it will dump
additional information such as the cache, log files etc.
+``--log-level=<ERROR|WARNING|NOTICE|STATUS|VERBOSE|DEBUG|TRACE>``
+ Set the log level.
+
+ The :command:`message` command will only output messages of the specified
+ log level or higher. The default log level is ``STATUS``.
+
+ For backward compatibility reasons, ``--loglevel`` is also accepted as a
+ synonym for this option.
+
``--debug-trycompile``
- Do not delete the try_compile build tree. Only useful on one try_compile at a time.
+ Do not delete the :command:`try_compile` build tree.
+ Only useful on one :command:`try_compile` at a time.
- Do not delete the files and directories created for try_compile
+ Do not delete the files and directories created for :command:`try_compile`
calls. This is useful in debugging failed try_compiles. It may
however change the results of the try-compiles as old junk from a
previous try-compile may cause a different test to either pass or
@@ -96,7 +224,7 @@ Options
Put cmake in a debug mode.
Print extra information during the cmake run like stack traces with
- message(send_error ) calls.
+ :command:`message(SEND_ERROR)` calls.
``--trace``
Put cmake in trace mode.
@@ -113,6 +241,9 @@ Options
Multiple options are allowed.
+``--trace-redirect=<file>``
+ Put cmake in trace mode and redirect trace output to a file instead of stderr.
+
``--warn-uninitialized``
Warn about uninitialized values.
@@ -133,18 +264,20 @@ Options
Find problems with variable usage in system files.
Normally, unused and uninitialized variables are searched for only
- in CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR. This flag tells CMake to
- warn about other files as well.
+ in :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR`.
+ This flag tells CMake to warn about other files as well.
-.. include:: OPTIONS_HELP.txt
+.. _`Build Tool Mode`:
-Build Tool Mode
+Build a Project
===============
CMake provides a command-line signature to build an already-generated
-project binary tree::
+project binary tree:
- cmake --build <dir> [<options>...] [-- <build-tool-options>...]
+.. code-block:: shell
+
+ cmake --build <dir> [<options>] [-- <build-tool-options>]
This abstracts a native build tool's command-line interface with the
following options:
@@ -152,8 +285,19 @@ following options:
``--build <dir>``
Project binary directory to be built. This is required and must be first.
-``--target <tgt>``
- Build ``<tgt>`` instead of default targets. May only be specified once.
+``--parallel [<jobs>], -j [<jobs>]``
+ The maximum number of concurrent processes to use when building.
+ If ``<jobs>`` is omitted the native build tool's default number is used.
+
+ The :envvar:`CMAKE_BUILD_PARALLEL_LEVEL` environment variable, if set,
+ specifies a default parallel level when this option is not given.
+
+ Some native build tools always build in parallel. The use of ``<jobs>``
+ value of ``1`` can be used to limit to a single job.
+
+``--target <tgt>..., -t <tgt>...``
+ Build ``<tgt>`` instead of the default target. Multiple targets may be
+ given, separated by spaces.
``--config <cfg>``
For multi-configuration tools, choose configuration ``<cfg>``.
@@ -165,17 +309,89 @@ following options:
``--use-stderr``
Ignored. Behavior is default in CMake >= 3.0.
+``--verbose, -v``
+ Enable verbose output - if supported - including the build commands to be
+ executed.
+
+ This option can be omitted if :envvar:`VERBOSE` environment variable or
+ :variable:`CMAKE_VERBOSE_MAKEFILE` cached variable is set.
+
+
``--``
Pass remaining options to the native tool.
Run ``cmake --build`` with no options for quick help.
-Command-Line Tool Mode
-======================
+Install a Project
+=================
+
+CMake provides a command-line signature to install an already-generated
+project binary tree:
+
+.. code-block:: shell
+
+ cmake --install <dir> [<options>]
+
+This may be used after building a project to run installation without
+using the generated build system or the native build tool.
+The options are:
+
+``--install <dir>``
+ Project binary directory to install. This is required and must be first.
+
+``--config <cfg>``
+ For multi-configuration generators, choose configuration ``<cfg>``.
+
+``--component <comp>``
+ Component-based install. Only install component ``<comp>``.
+
+``--prefix <prefix>``
+ Override the installation prefix, :variable:`CMAKE_INSTALL_PREFIX`.
+
+``--strip``
+ Strip before installing.
-CMake provides builtin command-line tools through the signature::
+``-v, --verbose``
+ Enable verbose output.
- cmake -E <command> [<options>...]
+ This option can be omitted if :envvar:`VERBOSE` environment variable is set.
+
+Run ``cmake --install`` with no options for quick help.
+
+Open a Project
+==============
+
+.. code-block:: shell
+
+ cmake --open <dir>
+
+Open the generated project in the associated application. This is only
+supported by some generators.
+
+
+.. _`Script Processing Mode`:
+
+Run a Script
+============
+
+.. code-block:: shell
+
+ cmake [{-D <var>=<value>}...] -P <cmake-script-file>
+
+Process the given cmake file as a script written in the CMake
+language. No configure or generate step is performed and the cache
+is not modified. If variables are defined using ``-D``, this must be
+done before the ``-P`` argument.
+
+
+Run a Command-Line Tool
+=======================
+
+CMake provides builtin command-line tools through the signature
+
+.. code-block:: shell
+
+ cmake -E <command> [<options>]
Run ``cmake -E`` or ``cmake -E help`` for a summary of commands.
Available commands are:
@@ -214,30 +430,57 @@ Available commands are:
A list of strings with all the extra generators compatible with
the generator.
+ ``fileApi``
+ Optional member that is present when the :manual:`cmake-file-api(7)`
+ is available. The value is a JSON object with one member:
+
+ ``requests``
+ A JSON array containing zero or more supported file-api requests.
+ Each request is a JSON object with members:
+
+ ``kind``
+ Specifies one of the supported :ref:`file-api object kinds`.
+
+ ``version``
+ A JSON array whose elements are each a JSON object containing
+ ``major`` and ``minor`` members specifying non-negative integer
+ version components.
+
``serverMode``
``true`` if cmake supports server-mode and ``false`` otherwise.
``chdir <dir> <cmd> [<arg>...]``
Change the current working directory and run a command.
-``compare_files <file1> <file2>``
+``compare_files [--ignore-eol] <file1> <file2>``
Check if ``<file1>`` is same as ``<file2>``. If files are the same,
- then returns 0, if not it returns 1.
+ then returns ``0``, if not it returns ``1``. The ``--ignore-eol`` option
+ implies line-wise comparison and ignores LF/CRLF differences.
``copy <file>... <destination>``
Copy files to ``<destination>`` (either file or directory).
If multiple files are specified, the ``<destination>`` must be
directory and it must exist. Wildcards are not supported.
+ ``copy`` does follow symlinks. That means it does not copy symlinks,
+ but the files or directories it point to.
``copy_directory <dir>... <destination>``
- Copy directories to ``<destination>`` directory.
+ Copy content of ``<dir>...`` directories to ``<destination>`` directory.
If ``<destination>`` directory does not exist it will be created.
+ ``copy_directory`` does follow symlinks.
``copy_if_different <file>... <destination>``
Copy files to ``<destination>`` (either file or directory) if
they have changed.
If multiple files are specified, the ``<destination>`` must be
directory and it must exist.
+ ``copy_if_different`` does follow symlinks.
+
+``create_symlink <old> <new>``
+ Create a symbolic link ``<new>`` naming ``<old>``.
+
+ .. note::
+ Path to where ``<new>`` symbolic link will be created has to exist beforehand.
``echo [<string>...]``
Displays arguments as text.
@@ -251,6 +494,9 @@ Available commands are:
``environment``
Display the current environment variables.
+``false``
+ Do nothing, with an exit code of 1.
+
``make_directory <dir>...``
Create ``<dir>`` directories. If necessary, create parent
directories too. If a directory already exists it will be
@@ -262,18 +508,52 @@ Available commands are:
351abe79cd3800b38cdfb25d45015a15 file1.txt
052f86c15bbde68af55c7f7b340ab639 file2.txt
+``sha1sum <file>...``
+ Create SHA1 checksum of files in ``sha1sum`` compatible format::
+
+ 4bb7932a29e6f73c97bb9272f2bdc393122f86e0 file1.txt
+ 1df4c8f318665f9a5f2ed38f55adadb7ef9f559c file2.txt
+
+``sha224sum <file>...``
+ Create SHA224 checksum of files in ``sha224sum`` compatible format::
+
+ b9b9346bc8437bbda630b0b7ddfc5ea9ca157546dbbf4c613192f930 file1.txt
+ 6dfbe55f4d2edc5fe5c9197bca51ceaaf824e48eba0cc453088aee24 file2.txt
+
+``sha256sum <file>...``
+ Create SHA256 checksum of files in ``sha256sum`` compatible format::
+
+ 76713b23615d31680afeb0e9efe94d47d3d4229191198bb46d7485f9cb191acc file1.txt
+ 15b682ead6c12dedb1baf91231e1e89cfc7974b3787c1e2e01b986bffadae0ea file2.txt
+
+``sha384sum <file>...``
+ Create SHA384 checksum of files in ``sha384sum`` compatible format::
+
+ acc049fedc091a22f5f2ce39a43b9057fd93c910e9afd76a6411a28a8f2b8a12c73d7129e292f94fc0329c309df49434 file1.txt
+ 668ddeb108710d271ee21c0f3acbd6a7517e2b78f9181c6a2ff3b8943af92b0195dcb7cce48aa3e17893173c0a39e23d file2.txt
+
+``sha512sum <file>...``
+ Create SHA512 checksum of files in ``sha512sum`` compatible format::
+
+ 2a78d7a6c5328cfb1467c63beac8ff21794213901eaadafd48e7800289afbc08e5fb3e86aa31116c945ee3d7bf2a6194489ec6101051083d1108defc8e1dba89 file1.txt
+ 7a0b54896fe5e70cca6dd643ad6f672614b189bf26f8153061c4d219474b05dad08c4e729af9f4b009f1a1a280cb625454bf587c690f4617c27e3aebdf3b7a2d file2.txt
+
``remove [-f] <file>...``
Remove the file(s). If any of the listed files already do not
exist, the command returns a non-zero exit code, but no message
is logged. The ``-f`` option changes the behavior to return a
zero exit code (i.e. success) in such situations instead.
+ ``remove`` does not follow symlinks. That means it remove only symlinks
+ and not files it point to.
-``remove_directory <dir>``
- Remove a directory and its contents. If a directory does
- not exist it will be silently ignored.
+``remove_directory <dir>...``
+ Remove ``<dir>`` directories and their contents. If a directory does
+ not exist it will be silently ignored. If ``<dir>`` is a symlink to
+ a directory, just the symlink will be removed.
``rename <oldname> <newname>``
- Rename a file or directory (on one volume).
+ Rename a file or directory (on one volume). If file with the ``<newname>`` name
+ already exists, then it will be silently replaced.
``server``
Launch :manual:`cmake-server(7)` mode.
@@ -281,44 +561,61 @@ Available commands are:
``sleep <number>...``
Sleep for given number of seconds.
-``tar [cxt][vf][zjJ] file.tar [<options>...] [--] [<file>...]``
+``tar [cxt][vf][zjJ] file.tar [<options>] [--] [<pathname>...]``
Create or extract a tar or zip archive. Options are:
- ``--``
- Stop interpreting options and treat all remaining arguments
- as file names even if they start in ``-``.
+ ``c``
+ Create a new archive containing the specified files.
+ If used, the ``<pathname>...`` argument is mandatory.
+ ``x``
+ Extract to disk from the archive.
+ The ``<pathname>...`` argument could be used to extract only selected files
+ or directories.
+ When extracting selected files or directories, you must provide their exact
+ names including the path, as printed by list (``-t``).
+ ``t``
+ List archive contents.
+ The ``<pathname>...`` argument could be used to list only selected files
+ or directories.
+ ``v``
+ Produce verbose output.
+ ``z``
+ Compress the resulting archive with gzip.
+ ``j``
+ Compress the resulting archive with bzip2.
+ ``J``
+ Compress the resulting archive with XZ.
+ ``--zstd``
+ Compress the resulting archive with Zstandard.
``--files-from=<file>``
Read file names from the given file, one per line.
Blank lines are ignored. Lines may not start in ``-``
except for ``--add-file=<name>`` to add files whose
names start in ``-``.
- ``--mtime=<date>``
- Specify modification time recorded in tarball entries.
``--format=<format>``
Specify the format of the archive to be created.
Supported formats are: ``7zip``, ``gnutar``, ``pax``,
``paxr`` (restricted pax, default), and ``zip``.
+ ``--mtime=<date>``
+ Specify modification time recorded in tarball entries.
+ ``--``
+ Stop interpreting options and treat all remaining arguments
+ as file names, even if they start with ``-``.
+
``time <command> [<args>...]``
- Run command and return elapsed time.
+ Run command and display elapsed time.
-``touch <file>``
- Touch a file.
+``touch <file>...``
+ Creates ``<file>`` if file do not exist.
+ If ``<file>`` exists, it is changing ``<file>`` access and modification times.
-``touch_nocreate <file>``
+``touch_nocreate <file>...``
Touch a file if it exists but do not create it. If a file does
not exist it will be silently ignored.
-UNIX-specific Command-Line Tools
---------------------------------
-
-The following ``cmake -E`` commands are available only on UNIX:
-
-``create_symlink <old> <new>``
- Create a symbolic link ``<new>`` naming ``<old>``.
-
-.. note::
- Path to where ``<new>`` symbolic link will be created has to exist beforehand.
+``true``
+ Do nothing, with an exit code of 0.
Windows-specific Command-Line Tools
-----------------------------------
@@ -339,24 +636,40 @@ The following ``cmake -E`` commands are available only on Windows:
``write_regv <key> <value>``
Write Windows registry value.
-Find-Package Tool Mode
-======================
-CMake provides a helper for Makefile-based projects with the signature::
+Run the Find-Package Tool
+=========================
+
+CMake provides a pkg-config like helper for Makefile-based projects:
- cmake --find-package <options>...
+.. code-block:: shell
-This runs in a pkg-config like mode.
+ cmake --find-package [<options>]
-Search a package using :command:`find_package()` and print the resulting flags
-to stdout. This can be used to use cmake instead of pkg-config to find
-installed libraries in plain Makefile-based projects or in autoconf-based
-projects (via ``share/aclocal/cmake.m4``).
+It searches a package using :command:`find_package()` and prints the
+resulting flags to stdout. This can be used instead of pkg-config
+to find installed libraries in plain Makefile-based projects or in
+autoconf-based projects (via ``share/aclocal/cmake.m4``).
.. note::
This mode is not well-supported due to some technical limitations.
It is kept for compatibility but should not be used in new projects.
+
+View Help
+=========
+
+To print selected pages from the CMake documentation, use
+
+.. code-block:: shell
+
+ cmake --help[-<topic>]
+
+with one of the following options:
+
+.. include:: OPTIONS_HELP.txt
+
+
See Also
========
diff --git a/Help/manual/cpack-generators.7.rst b/Help/manual/cpack-generators.7.rst
new file mode 100644
index 000000000..ade9149c1
--- /dev/null
+++ b/Help/manual/cpack-generators.7.rst
@@ -0,0 +1,29 @@
+.. cmake-manual-description: CPack Generator Reference
+
+cpack-generators(7)
+*******************
+
+.. only:: html
+
+ .. contents::
+
+Generators
+==========
+
+.. toctree::
+ :maxdepth: 1
+
+ /cpack_gen/archive
+ /cpack_gen/bundle
+ /cpack_gen/cygwin
+ /cpack_gen/deb
+ /cpack_gen/dmg
+ /cpack_gen/external
+ /cpack_gen/freebsd
+ /cpack_gen/ifw
+ /cpack_gen/nsis
+ /cpack_gen/nuget
+ /cpack_gen/packagemaker
+ /cpack_gen/productbuild
+ /cpack_gen/rpm
+ /cpack_gen/wix
diff --git a/Help/manual/cpack.1.rst b/Help/manual/cpack.1.rst
index 4f9f28d4e..395cd4189 100644
--- a/Help/manual/cpack.1.rst
+++ b/Help/manual/cpack.1.rst
@@ -8,86 +8,102 @@ Synopsis
.. parsed-literal::
- cpack -G <generator> [<options>]
+ cpack [<options>]
Description
===========
-The "cpack" executable is the CMake packaging program.
-CMake-generated build trees created for projects that use the
-INSTALL_* commands have packaging support. This program will generate
-the package.
+The **cpack** executable is the CMake packaging program. It generates
+installers and source packages in a variety of formats.
-CMake is a cross-platform build system generator. Projects specify
-their build process with platform-independent CMake listfiles included
-in each directory of a source tree with the name CMakeLists.txt.
-Users build a project by using CMake to generate a build system for a
-native tool on their platform.
+For each installer or package format, **cpack** has a specific backend,
+called "generator". A generator is responsible for generating the required
+inputs and invoking the specific package creation tools. These installer
+or package generators are not to be confused with the makefile generators
+of the :manual:`cmake <cmake(1)>` command.
-Options
-=======
+All supported generators are specified in the :manual:`cpack-generators
+<cpack-generators(7)>` manual. The command ``cpack --help`` prints a
+list of generators supported for the target platform. Which of them are
+to be used can be selected through the :variable:`CPACK_GENERATOR` variable
+or through the command-line option ``-G``.
-``-G <generator>``
- Use the specified generator to generate package.
+The **cpack** program is steered by a configuration file written in the
+:manual:`CMake language <cmake-language(7)>`. Unless chosen differently
+through the command-line option ``--config``, the file ``CPackConfig.cmake``
+in the current directory is used.
- CPack may support multiple native packaging systems on certain
- platforms. A generator is responsible for generating input files
- for particular system and invoking that systems. Possible generator
- names are specified in the Generators section.
+In the standard CMake workflow, the file ``CPackConfig.cmake`` is generated
+by the :manual:`cmake <cmake(1)>` executable, provided the :module:`CPack`
+module is included by the project's ``CMakeLists.txt`` file.
-``-C <Configuration>``
- Specify the project configuration
+Options
+=======
- This option specifies the configuration that the project was build
- with, for example 'Debug', 'Release'.
+``-G <generators>``
+ ``<generators>`` is a :ref:`semicolon-separated list <CMake Language Lists>`
+ of generator names. ``cpack`` will iterate through this list and produce
+ package(s) in that generator's format according to the details provided in
+ the ``CPackConfig.cmake`` configuration file. If this option is not given,
+ the :variable:`CPACK_GENERATOR` variable determines the default set of
+ generators that will be used.
+
+``-C <configs>``
+ Specify the project configuration(s) to be packaged (e.g. ``Debug``,
+ ``Release``, etc.), where ``<configs>`` is a
+ :ref:`semicolon-separated list <CMake Language Lists>`.
+ When the CMake project uses a multi-configuration
+ generator such as Xcode or Visual Studio, this option is needed to tell
+ ``cpack`` which built executables to include in the package.
+ The user is responsible for ensuring that the configuration(s) listed
+ have already been built before invoking ``cpack``.
``-D <var>=<value>``
- Set a CPack variable.
+ Set a CPack variable. This will override any value set for ``<var>`` in the
+ input file read by ``cpack``.
- Set a variable that can be used by the generator.
+``--config <configFile>``
+ Specify the configuration file read by ``cpack`` to provide the packaging
+ details. By default, ``CPackConfig.cmake`` in the current directory will
+ be used.
-``--config <config file>``
- Specify the config file.
-
- Specify the config file to use to create the package. By default
- CPackConfig.cmake in the current directory will be used.
-
-``--verbose,-V``
- enable verbose output
-
- Run cpack with verbose output.
+``--verbose, -V``
+ Run ``cpack`` with verbose output. This can be used to show more details
+ from the package generation tools and is suitable for project developers.
``--debug``
- enable debug output (for CPack developers)
-
- Run cpack with debug output (for CPack developers).
-
-``-P <package name>``
- override/define CPACK_PACKAGE_NAME
-
- If the package name is not specified on cpack command line
- thenCPack.cmake defines it as CMAKE_PROJECT_NAME
-
-``-R <package version>``
- override/define CPACK_PACKAGE_VERSION
-
- If version is not specified on cpack command line thenCPack.cmake
- defines it from CPACK_PACKAGE_VERSION_[MAJOR|MINOR|PATCH]look into
- CPack.cmake for detail
-
-``-B <package directory>``
- override/define CPACK_PACKAGE_DIRECTORY
-
- The directory where CPack will be doing its packaging work.The
- resulting package will be found there. Inside this directoryCPack
- creates '_CPack_Packages' sub-directory which is theCPack temporary
- directory.
-
-``--vendor <vendor name>``
- override/define CPACK_PACKAGE_VENDOR
-
- If vendor is not specified on cpack command line (or inside
- CMakeLists.txt) thenCPack.cmake defines it with a default value
+ Run ``cpack`` with debug output. This option is intended mainly for the
+ developers of ``cpack`` itself and is not normally needed by project
+ developers.
+
+``--trace``
+ Put the underlying cmake scripts in trace mode.
+
+``--trace-expand``
+ Put the underlying cmake scripts in expanded trace mode.
+
+``-P <packageName>``
+ Override/define the value of the :variable:`CPACK_PACKAGE_NAME` variable used
+ for packaging. Any value set for this variable in the ``CPackConfig.cmake``
+ file will then be ignored.
+
+``-R <packageVersion>``
+ Override/define the value of the :variable:`CPACK_PACKAGE_VERSION`
+ variable used for packaging. It will override a value set in the
+ ``CPackConfig.cmake`` file or one automatically computed from
+ :variable:`CPACK_PACKAGE_VERSION_MAJOR`,
+ :variable:`CPACK_PACKAGE_VERSION_MINOR` and
+ :variable:`CPACK_PACKAGE_VERSION_PATCH`.
+
+``-B <packageDirectory>``
+ Override/define :variable:`CPACK_PACKAGE_DIRECTORY`, which controls the
+ directory where CPack will perform its packaging work. The resultant
+ package(s) will be created at this location by default and a
+ ``_CPack_Packages`` subdirectory will also be created below this directory to
+ use as a working area during package creation.
+
+``--vendor <vendorName>``
+ Override/define :variable:`CPACK_PACKAGE_VENDOR`.
.. include:: OPTIONS_HELP.txt
diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst
index a89c4e9bb..e29ebcaf6 100644
--- a/Help/manual/ctest.1.rst
+++ b/Help/manual/ctest.1.rst
@@ -3,20 +3,27 @@
ctest(1)
********
+.. contents::
+
Synopsis
========
.. parsed-literal::
ctest [<options>]
+ ctest --build-and-test <path-to-source> <path-to-build>
+ --build-generator <generator> [<options>...]
+ [--build-options <opts>...] [--test-command <command> [<args>...]]
+ ctest {-D <dashboard> | -M <model> -T <action> | -S <script> | -SP <script>}
+ [-- <dashboard-options>...]
Description
===========
-The "ctest" executable is the CMake test driver program.
+The **ctest** executable is the CMake test driver program.
CMake-generated build trees created for projects that use the
-ENABLE_TESTING and ADD_TEST commands have testing support. This
-program will run the tests and report results.
+:command:`enable_testing` and :command:`add_test` commands have testing support.
+This program will run the tests and report results.
Options
=======
@@ -26,8 +33,21 @@ Options
Some CMake-generated build trees can have multiple build
configurations in the same tree. This option can be used to specify
- which one should be tested. Example configurations are "Debug" and
- "Release".
+ which one should be tested. Example configurations are ``Debug`` and
+ ``Release``.
+
+``--progress``
+ Enable short progress output from tests.
+
+ When the output of **ctest** is being sent directly to a terminal, the
+ progress through the set of tests is reported by updating the same line
+ rather than printing start and end messages for each test on new lines.
+ This can significantly reduce the verbosity of the test output.
+ Test completion messages are still output on their own line for failed
+ tests and the final test summary will also still be logged.
+
+ This option can also be enabled by setting the environment variable
+ :envvar:`CTEST_PROGRESS_OUTPUT`.
``-V,--verbose``
Enable verbose output from tests.
@@ -49,22 +69,35 @@ Options
``--output-on-failure``
Output anything outputted by the test program if the test should fail.
- This option can also be enabled by setting the environment variable
- ``CTEST_OUTPUT_ON_FAILURE``.
+ This option can also be enabled by setting the
+ :envvar:`CTEST_OUTPUT_ON_FAILURE` environment variable
``-F``
Enable failover.
- This option allows ctest to resume a test set execution that was
+ This option allows CTest to resume a test set execution that was
previously interrupted. If no interruption occurred, the ``-F`` option
will have no effect.
``-j <jobs>, --parallel <jobs>``
Run the tests in parallel using the given number of jobs.
- This option tells ctest to run the tests in parallel using given
- number of jobs. This option can also be set by setting the
- environment variable ``CTEST_PARALLEL_LEVEL``.
+ This option tells CTest to run the tests in parallel using given
+ number of jobs. This option can also be set by setting the
+ :envvar:`CTEST_PARALLEL_LEVEL` environment variable.
+
+ This option can be used with the :prop_test:`PROCESSORS` test property.
+
+ See `Label and Subproject Summary`_.
+
+``--resource-spec-file <file>``
+ Run CTest with :ref:`resource allocation <ctest-resource-allocation>` enabled,
+ using the
+ :ref:`resource specification file <ctest-resource-specification-file>`
+ specified in ``<file>``.
+
+ When ``ctest`` is run as a `Dashboard Client`_ this sets the
+ ``ResourceSpecFile`` option of the `CTest Test Step`_.
``--test-load <level>``
While running tests in parallel (e.g. with ``-j``), try not to start
@@ -74,7 +107,7 @@ Options
``TestLoad`` option of the `CTest Test Step`_.
``-Q,--quiet``
- Make ctest quiet.
+ Make CTest quiet.
This option will suppress all the output. The output log file will
still be generated if the ``--output-log`` is specified. Options such
@@ -84,37 +117,47 @@ Options
``-O <file>, --output-log <file>``
Output to log file.
- This option tells ctest to write all its output to a log file.
+ This option tells CTest to write all its output to a ``<file>`` log file.
-``-N,--show-only``
+``-N,--show-only[=<format>]``
Disable actual execution of tests.
- This option tells ctest to list the tests that would be run but not
+ This option tells CTest to list the tests that would be run but not
actually run them. Useful in conjunction with the ``-R`` and ``-E``
options.
+ ``<format>`` can be one of the following values.
+
+ ``human``
+ Human-friendly output. This is not guaranteed to be stable.
+ This is the default.
+
+ ``json-v1``
+ Dump the test information in JSON format.
+ See `Show as JSON Object Model`_.
+
``-L <regex>, --label-regex <regex>``
Run tests with labels matching regular expression.
- This option tells ctest to run only the tests whose labels match the
+ This option tells CTest to run only the tests whose labels match the
given regular expression.
``-R <regex>, --tests-regex <regex>``
Run tests matching regular expression.
- This option tells ctest to run only the tests whose names match the
+ This option tells CTest to run only the tests whose names match the
given regular expression.
``-E <regex>, --exclude-regex <regex>``
Exclude tests matching regular expression.
- This option tells ctest to NOT run the tests whose names match the
+ This option tells CTest to NOT run the tests whose names match the
given regular expression.
``-LE <regex>, --label-exclude <regex>``
Exclude tests with labels matching regular expression.
- This option tells ctest to NOT run the tests whose labels match the
+ This option tells CTest to NOT run the tests whose labels match the
given regular expression.
``-FA <regex>, --fixture-exclude-any <regex>``
@@ -137,10 +180,13 @@ Options
``-D <dashboard>, --dashboard <dashboard>``
Execute dashboard test.
- This option tells ctest to act as a CDash client and perform a
- dashboard test. All tests are <Mode><Test>, where Mode can be
- Experimental, Nightly, and Continuous, and Test can be Start,
- Update, Configure, Build, Test, Coverage, and Submit.
+ This option tells CTest to act as a CDash client and perform a
+ dashboard test. All tests are ``<Mode><Test>``, where ``<Mode>`` can be
+ ``Experimental``, ``Nightly``, and ``Continuous``, and ``<Test>`` can be
+ ``Start``, ``Update``, ``Configure``, ``Build``, ``Test``,
+ ``Coverage``, and ``Submit``.
+
+ See `Dashboard Client`_.
``-D <var>:<type>=<value>``
Define a variable for script mode.
@@ -153,35 +199,33 @@ Options
``-M <model>, --test-model <model>``
Sets the model for a dashboard.
- This option tells ctest to act as a CDash client where the ``<model>``
+ This option tells CTest to act as a CDash client where the ``<model>``
can be ``Experimental``, ``Nightly``, and ``Continuous``.
Combining ``-M`` and ``-T`` is similar to ``-D``.
+ See `Dashboard Client`_.
+
``-T <action>, --test-action <action>``
Sets the dashboard action to perform.
- This option tells ctest to act as a CDash client and perform some
+ This option tells CTest to act as a CDash client and perform some
action such as ``start``, ``build``, ``test`` etc. See
`Dashboard Client Steps`_ for the full list of actions.
Combining ``-M`` and ``-T`` is similar to ``-D``.
-``--track <track>``
- Specify the track to submit dashboard to
-
- Submit dashboard to specified track instead of default one. By
- default, the dashboard is submitted to Nightly, Experimental, or
- Continuous track, but by specifying this option, the track can be
- arbitrary.
+ See `Dashboard Client`_.
``-S <script>, --script <script>``
Execute a dashboard for a configuration.
- This option tells ctest to load in a configuration script which sets
+ This option tells CTest to load in a configuration script which sets
a number of parameters such as the binary and source directories.
- Then ctest will do what is required to create and run a dashboard.
+ Then CTest will do what is required to create and run a dashboard.
This option basically sets up a dashboard and then runs ``ctest -D``
with the appropriate options.
+ See `Dashboard Client`_.
+
``-SP <script>, --script-new-process <script>``
Execute a dashboard for a configuration.
@@ -190,19 +234,15 @@ Options
script may modify the environment and you do not want the modified
environment to impact other ``-S`` scripts.
-``-A <file>, --add-notes <file>``
- Add a notes file with submission.
-
- This option tells ctest to include a notes file when submitting
- dashboard.
+ See `Dashboard Client`_.
``-I [Start,End,Stride,test#,test#|Test file], --tests-information``
Run a specific number of tests by number.
- This option causes ctest to run tests starting at number Start,
- ending at number End, and incrementing by Stride. Any additional
- numbers after Stride are considered individual test numbers. Start,
- End,or stride can be empty. Optionally a file can be given that
+ This option causes CTest to run tests starting at number ``Start``,
+ ending at number ``End``, and incrementing by ``Stride``. Any additional
+ numbers after ``Stride`` are considered individual test numbers. ``Start``,
+ ``End``, or ``Stride`` can be empty. Optionally a file can be given that
contains the same syntax as the command line.
``-U, --union``
@@ -214,11 +254,11 @@ Options
``--rerun-failed``
Run only the tests that failed previously.
- This option tells ctest to perform only the tests that failed during
- its previous run. When this option is specified, ctest ignores all
+ This option tells CTest to perform only the tests that failed during
+ its previous run. When this option is specified, CTest ignores all
other options intended to modify the list of tests to run (``-L``, ``-R``,
``-E``, ``-LE``, ``-I``, etc). In the event that CTest runs and no tests
- fail, subsequent calls to ctest with the ``--rerun-failed`` option will run
+ fail, subsequent calls to CTest with the ``--rerun-failed`` option will run
the set of tests that most recently failed (if any).
``--repeat-until-fail <n>``
@@ -234,41 +274,154 @@ Options
name which can be very annoying.
``--interactive-debug-mode [0|1]``
- Set the interactive mode to 0 or 1.
+ Set the interactive mode to ``0`` or ``1``.
- This option causes ctest to run tests in either an interactive mode
+ This option causes CTest to run tests in either an interactive mode
or a non-interactive mode. On Windows this means that in
non-interactive mode, all system debug pop up windows are blocked.
- In dashboard mode (Experimental, Nightly, Continuous), the default
+ In dashboard mode (``Experimental``, ``Nightly``, ``Continuous``), the default
is non-interactive. When just running tests not for a dashboard the
default is to allow popups and interactive debugging.
``--no-label-summary``
Disable timing summary information for labels.
- This option tells ctest not to print summary information for each
+ This option tells CTest not to print summary information for each
label associated with the tests run. If there are no labels on the
tests, nothing extra is printed.
-``--build-and-test <path-to-source> <path-to-build>``
- Configure, build and run a test.
+ See `Label and Subproject Summary`_.
+
+``--no-subproject-summary``
+ Disable timing summary information for subprojects.
+
+ This option tells CTest not to print summary information for each
+ subproject associated with the tests run. If there are no subprojects on the
+ tests, nothing extra is printed.
+
+ See `Label and Subproject Summary`_.
+
+``--build-and-test``
+See `Build and Test Mode`_.
+
+``--test-output-size-passed <size>``
+ Limit the output for passed tests to ``<size>`` bytes.
+
+``--test-output-size-failed <size>``
+ Limit the output for failed tests to ``<size>`` bytes.
- This option tells ctest to configure (i.e. run cmake on), build,
- and or execute a test. The configure and test steps are optional.
- The arguments to this command line are the source and binary
- directories.
- The ``--build-generator`` option *must* be provided to use
- ``--build-and-test``. If ``--test-command`` is specified then that will be
- run after the build is complete. Other options that affect this
- mode are ``--build-target``, ``--build-nocmake``, ``--build-run-dir``,
- ``--build-two-config``, ``--build-exe-dir``,
- ``--build-project``, ``--build-noclean`` and ``--build-options``.
+``--overwrite``
+ Overwrite CTest configuration option.
+
+ By default CTest uses configuration options from configuration file.
+ This option will overwrite the configuration option.
+
+``--force-new-ctest-process``
+ Run child CTest instances as new processes.
+
+ By default CTest will run child CTest instances within the same
+ process. If this behavior is not desired, this argument will
+ enforce new processes for child CTest processes.
+
+``--schedule-random``
+ Use a random order for scheduling tests.
+
+ This option will run the tests in a random order. It is commonly
+ used to detect implicit dependencies in a test suite.
+
+``--submit-index``
+ Legacy option for old Dart2 dashboard server feature.
+ Do not use.
+
+``--timeout <seconds>``
+ Set the default test timeout.
+
+ This option effectively sets a timeout on all tests that do not
+ already have a timeout set on them via the :prop_test:`TIMEOUT`
+ property.
+
+``--stop-time <time>``
+ Set a time at which all tests should stop running.
+
+ Set a real time of day at which all tests should timeout. Example:
+ ``7:00:00 -0400``. Any time format understood by the curl date parser
+ is accepted. Local time is assumed if no timezone is specified.
+
+``--print-labels``
+ Print all available test labels.
+
+ This option will not run any tests, it will simply print the list of
+ all labels associated with the test set.
+
+.. include:: OPTIONS_HELP.txt
+
+.. _`Label and Subproject Summary`:
+
+Label and Subproject Summary
+============================
+
+CTest prints timing summary information for each ``LABEL`` and subproject
+associated with the tests run. The label time summary will not include labels
+that are mapped to subprojects.
+
+When the :prop_test:`PROCESSORS` test property is set, CTest will display a
+weighted test timing result in label and subproject summaries. The time is
+reported with `sec*proc` instead of just `sec`.
+
+The weighted time summary reported for each label or subproject ``j``
+is computed as::
+
+ Weighted Time Summary for Label/Subproject j =
+ sum(raw_test_time[j,i] * num_processors[j,i], i=1...num_tests[j])
+
+ for labels/subprojects j=1...total
+
+where:
+
+* ``raw_test_time[j,i]``: Wall-clock time for the ``i`` test
+ for the ``j`` label or subproject
+* ``num_processors[j,i]``: Value of the CTest :prop_test:`PROCESSORS` property
+ for the ``i`` test for the ``j`` label or subproject
+* ``num_tests[j]``: Number of tests associated with the ``j`` label or subproject
+* ``total``: Total number of labels or subprojects that have at least one test run
+
+Therefore, the weighted time summary for each label or subproject represents
+the amount of time that CTest gave to run the tests for each label or
+subproject and gives a good representation of the total expense of the tests
+for each label or subproject when compared to other labels or subprojects.
+
+For example, if ``SubprojectA`` showed ``100 sec*proc`` and ``SubprojectB`` showed
+``10 sec*proc``, then CTest allocated approximately 10 times the CPU/core time
+to run the tests for ``SubprojectA`` than for ``SubprojectB`` (e.g. so if effort
+is going to be expended to reduce the cost of the test suite for the whole
+project, then reducing the cost of the test suite for ``SubprojectA`` would
+likely have a larger impact than effort to reduce the cost of the test suite
+for ``SubprojectB``).
+
+.. _`Build and Test Mode`:
+
+Build and Test Mode
+===================
+
+CTest provides a command-line signature to configure (i.e. run cmake on),
+build, and/or execute a test::
+
+ ctest --build-and-test <path-to-source> <path-to-build>
+ --build-generator <generator>
+ [<options>...]
+ [--build-options <opts>...]
+ [--test-command <command> [<args>...]]
+
+The configure and test steps are optional. The arguments to this command line
+are the source and binary directories. The ``--build-generator`` option *must*
+be provided to use ``--build-and-test``. If ``--test-command`` is specified
+then that will be run after the build is complete. Other options that affect
+this mode include:
``--build-target``
Specify a specific target to build.
- This option goes with the ``--build-and-test`` option, if left out the
- ``all`` target is built.
+ If left out the ``all`` target is built.
``--build-nocmake``
Run the build without running cmake first.
@@ -299,91 +452,77 @@ Options
Specify the name of the project to build.
``--build-makeprogram``
- Override the make program chosen by CTest with a given one.
+ Specify the explicit make program to be used by CMake when configuring and
+ building the project. Only applicable for Make and Ninja based generators.
``--build-noclean``
Skip the make clean step.
``--build-config-sample``
A sample executable to use to determine the configuration that
- should be used. e.g. Debug/Release/etc.
+ should be used. e.g. ``Debug``, ``Release`` etc.
``--build-options``
- Add extra options to the build step.
-
- This option must be the last option with the exception of
- ``--test-command``
+ Additional options for configuring the build (i.e. for CMake, not for
+ the build tool). Note that if this is specified, the ``--build-options``
+ keyword and its arguments must be the last option given on the command
+ line, with the possible exception of ``--test-command``.
``--test-command``
- The test to run with the ``--build-and-test`` option.
-
-``--test-output-size-passed <size>``
- Limit the output for passed tests to ``<size>`` bytes.
-
-``--test-output-size-failed <size>``
- Limit the output for failed tests to ``<size>`` bytes.
+ The command to run as the test step with the ``--build-and-test`` option.
+ All arguments following this keyword will be assumed to be part of the
+ test command line, so it must be the last option given.
``--test-timeout``
- The time limit in seconds, internal use only.
+ The time limit in seconds
-``--tomorrow-tag``
- Nightly or experimental starts with next day tag.
-
- This is useful if the build will not finish in one day.
-
-``--ctest-config``
- The configuration file used to initialize CTest state when submitting dashboards.
+.. _`Dashboard Client`:
- This option tells CTest to use different initialization file instead
- of CTestConfiguration.tcl. This way multiple initialization files
- can be used for example to submit to multiple dashboards.
+Dashboard Client
+================
-``--overwrite``
- Overwrite CTest configuration option.
+CTest can operate as a client for the `CDash`_ software quality dashboard
+application. As a dashboard client, CTest performs a sequence of steps
+to configure, build, and test software, and then submits the results to
+a `CDash`_ server. The command-line signature used to submit to `CDash`_ is::
- By default ctest uses configuration options from configuration file.
- This option will overwrite the configuration option.
+ ctest (-D <dashboard> | -M <model> -T <action> | -S <script> | -SP <script>)
+ [-- <dashboard-options>...]
-``--extra-submit <file>[;<file>]``
- Submit extra files to the dashboard.
+Options for Dashboard Client include:
- This option will submit extra files to the dashboard.
+``--group <group>``
+ Specify what group you'd like to submit results to
-``--force-new-ctest-process``
- Run child CTest instances as new processes.
-
- By default CTest will run child CTest instances within the same
- process. If this behavior is not desired, this argument will
- enforce new processes for child CTest processes.
+ Submit dashboard to specified group instead of default one. By
+ default, the dashboard is submitted to Nightly, Experimental, or
+ Continuous group, but by specifying this option, the group can be
+ arbitrary.
-``--schedule-random``
- Use a random order for scheduling tests.
+ This replaces the deprecated option ``--track``.
+ Despite the name change its behavior is unchanged.
- This option will run the tests in a random order. It is commonly
- used to detect implicit dependencies in a test suite.
+``-A <file>, --add-notes <file>``
+ Add a notes file with submission.
-``--submit-index``
- Legacy option for old Dart2 dashboard server feature.
- Do not use.
+ This option tells CTest to include a notes file when submitting
+ dashboard.
-``--timeout <seconds>``
- Set a global timeout on all tests.
+``--tomorrow-tag``
+ ``Nightly`` or ``Experimental`` starts with next day tag.
- This option will set a global timeout on all tests that do not
- already have a timeout set on them.
+ This is useful if the build will not finish in one day.
-``--stop-time <time>``
- Set a time at which all tests should stop running.
+``--extra-submit <file>[;<file>]``
+ Submit extra files to the dashboard.
- Set a real time of day at which all tests should timeout. Example:
- ``7:00:00 -0400``. Any time format understood by the curl date parser
- is accepted. Local time is assumed if no timezone is specified.
+ This option will submit extra files to the dashboard.
``--http1.0``
- Submit using HTTP 1.0.
+ Submit using `HTTP 1.0`.
- This option will force CTest to use HTTP 1.0 to submit files to the
- dashboard, instead of HTTP 1.1.
+ This option will force CTest to use `HTTP 1.0` to submit files to the
+ dashboard, instead of `HTTP 1.1`.
``--no-compress-output``
Do not compress test output when submitting.
@@ -392,26 +531,6 @@ Options
this to maintain compatibility with an older version of CDash which
doesn't support compressed test output.
-``--print-labels``
- Print all available test labels.
-
- This option will not run any tests, it will simply print the list of
- all labels associated with the test set.
-
-.. include:: OPTIONS_HELP.txt
-
-.. _`Dashboard Client`:
-
-Dashboard Client
-================
-
-CTest can operate as a client for the `CDash`_ software quality dashboard
-application. As a dashboard client, CTest performs a sequence of steps
-to configure, build, and test software, and then submits the results to
-a `CDash`_ server.
-
-.. _`CDash`: http://cdash.org/
-
Dashboard Client Steps
----------------------
@@ -606,7 +725,7 @@ Configuration settings to specify the version control tool include:
The source tree is updated by ``git fetch`` followed by
``git reset --hard`` to the ``FETCH_HEAD``. The result is the same
- as ``git pull`` except that any local moficiations are overwritten.
+ as ``git pull`` except that any local modifications are overwritten.
Use ``GITUpdateCustom`` to specify a different approach.
``GITInitSubmodules``
@@ -716,6 +835,8 @@ Configuration settings to specify the version control tool include:
* :module:`CTest` module variable: ``UPDATE_TYPE`` if set,
else ``CTEST_UPDATE_TYPE``
+.. _`UpdateVersionOnly`:
+
``UpdateVersionOnly``
Specify that you want the version control update command to only
discover the current version that is checked out, and not to update
@@ -723,7 +844,18 @@ Configuration settings to specify the version control tool include:
* `CTest Script`_ variable: :variable:`CTEST_UPDATE_VERSION_ONLY`
+.. _`UpdateVersionOverride`:
+``UpdateVersionOverride``
+ Specify the current version of your source tree.
+
+ When this variable is set to a non-empty string, CTest will report the value
+ you specified rather than using the update command to discover the current
+ version that is checked out. Use of this variable supersedes
+ ``UpdateVersionOnly``. Like ``UpdateVersionOnly``, using this variable tells
+ CTest not to update the source tree to a different version.
+
+ * `CTest Script`_ variable: :variable:`CTEST_UPDATE_VERSION_OVERRIDE`
Additional configuration settings include:
@@ -758,6 +890,16 @@ Configuration settings include:
* :module:`CTest` module variable: :variable:`CMAKE_COMMAND`
followed by :variable:`PROJECT_SOURCE_DIR`
+``LabelsForSubprojects``
+ Specify a semicolon-separated list of labels that will be treated as
+ subprojects. This mapping will be passed on to CDash when configure, test or
+ build results are submitted.
+
+ * `CTest Script`_ variable: :variable:`CTEST_LABELS_FOR_SUBPROJECTS`
+ * :module:`CTest` module variable: ``CTEST_LABELS_FOR_SUBPROJECTS``
+
+ See `Label and Subproject Summary`_.
+
.. _`CTest Build Step`:
CTest Build Step
@@ -778,7 +920,17 @@ Configuration settings include:
* `CTest Script`_ variable: :variable:`CTEST_CONFIGURATION_TYPE`
* :module:`CTest` module variable: ``DEFAULT_CTEST_CONFIGURATION_TYPE``,
- initialized by the ``CMAKE_CONFIG_TYPE`` environment variable
+ initialized by the :envvar:`CMAKE_CONFIG_TYPE` environment variable
+
+``LabelsForSubprojects``
+ Specify a semicolon-separated list of labels that will be treated as
+ subprojects. This mapping will be passed on to CDash when configure, test or
+ build results are submitted.
+
+ * `CTest Script`_ variable: :variable:`CTEST_LABELS_FOR_SUBPROJECTS`
+ * :module:`CTest` module variable: ``CTEST_LABELS_FOR_SUBPROJECTS``
+
+ See `Label and Subproject Summary`_.
``MakeCommand``
Command-line to launch the software build process.
@@ -815,6 +967,21 @@ Arguments to the command may specify some of the step settings.
Configuration settings include:
+``ResourceSpecFile``
+ Specify a
+ :ref:`resource specification file <ctest-resource-specification-file>`. See
+ :ref:`ctest-resource-allocation` for more information.
+
+``LabelsForSubprojects``
+ Specify a semicolon-separated list of labels that will be treated as
+ subprojects. This mapping will be passed on to CDash when configure, test or
+ build results are submitted.
+
+ * `CTest Script`_ variable: :variable:`CTEST_LABELS_FOR_SUBPROJECTS`
+ * :module:`CTest` module variable: ``CTEST_LABELS_FOR_SUBPROJECTS``
+
+ See `Label and Subproject Summary`_.
+
``TestLoad``
While running tests in parallel (e.g. with ``-j``), try not to start
tests when they may cause the CPU load to pass above a given threshold.
@@ -853,6 +1020,8 @@ Configuration settings include:
* `CTest Script`_ variable: :variable:`CTEST_COVERAGE_EXTRA_FLAGS`
* :module:`CTest` module variable: ``COVERAGE_EXTRA_FLAGS``
+ These options are the first arguments passed to ``CoverageCommand``.
+
.. _`CTest MemCheck Step`:
CTest MemCheck Step
@@ -945,7 +1114,7 @@ Configuration settings include:
* :module:`CTest` module variable: ``BUILDNAME``
``CDashVersion``
- Specify the version of `CDash`_ on the server.
+ Legacy option. Not used.
* `CTest Script`_ variable: none, detected from server
* :module:`CTest` module variable: ``CTEST_CDASH_VERSION``
@@ -974,55 +1143,58 @@ Configuration settings include:
* :module:`CTest` module variable: ``CTEST_CURL_OPTIONS``
``DropLocation``
- The path on the dashboard server to send the submission.
+ Legacy option. When ``SubmitURL`` is not set, it is constructed from
+ ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
+ ``DropLocation``.
* `CTest Script`_ variable: :variable:`CTEST_DROP_LOCATION`
* :module:`CTest` module variable: ``DROP_LOCATION`` if set,
else ``CTEST_DROP_LOCATION``
``DropMethod``
- Specify the method by which results should be submitted to the
- dashboard server. The value may be ``cp``, ``ftp``, ``http``,
- ``https``, ``scp``, or ``xmlrpc`` (if CMake was built with
- support for it).
+ Legacy option. When ``SubmitURL`` is not set, it is constructed from
+ ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
+ ``DropLocation``.
* `CTest Script`_ variable: :variable:`CTEST_DROP_METHOD`
* :module:`CTest` module variable: ``DROP_METHOD`` if set,
else ``CTEST_DROP_METHOD``
``DropSite``
- The dashboard server name
- (for ``ftp``, ``http``, and ``https``, ``scp``, and ``xmlrpc``).
+ Legacy option. When ``SubmitURL`` is not set, it is constructed from
+ ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
+ ``DropLocation``.
* `CTest Script`_ variable: :variable:`CTEST_DROP_SITE`
* :module:`CTest` module variable: ``DROP_SITE`` if set,
else ``CTEST_DROP_SITE``
``DropSitePassword``
- The dashboard server login password, if any
- (for ``ftp``, ``http``, and ``https``).
+ Legacy option. When ``SubmitURL`` is not set, it is constructed from
+ ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
+ ``DropLocation``.
* `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_PASSWORD`
* :module:`CTest` module variable: ``DROP_SITE_PASSWORD`` if set,
else ``CTEST_DROP_SITE_PASWORD``
``DropSiteUser``
- The dashboard server login user name, if any
- (for ``ftp``, ``http``, and ``https``).
+ Legacy option. When ``SubmitURL`` is not set, it is constructed from
+ ``DropMethod``, ``DropSiteUser``, ``DropSitePassword``, ``DropSite``, and
+ ``DropLocation``.
* `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_USER`
* :module:`CTest` module variable: ``DROP_SITE_USER`` if set,
else ``CTEST_DROP_SITE_USER``
``IsCDash``
- Specify whether the dashboard server is `CDash`_ or an older
- dashboard server implementation requiring ``TriggerSite``.
+ Legacy option. Not used.
* `CTest Script`_ variable: :variable:`CTEST_DROP_SITE_CDASH`
* :module:`CTest` module variable: ``CTEST_DROP_SITE_CDASH``
``ScpCommand``
- ``scp`` command-line tool to use when ``DropMethod`` is ``scp``.
+ Legacy option. Not used.
* `CTest Script`_ variable: :variable:`CTEST_SCP_COMMAND`
* :module:`CTest` module variable: ``SCPCOMMAND``
@@ -1035,15 +1207,325 @@ Configuration settings include:
* :module:`CTest` module variable: ``SITE``,
initialized by the :command:`site_name` command
+``SubmitURL``
+ The ``http`` or ``https`` URL of the dashboard server to send the submission
+ to.
+
+ * `CTest Script`_ variable: :variable:`CTEST_SUBMIT_URL`
+ * :module:`CTest` module variable: ``SUBMIT_URL`` if set,
+ else ``CTEST_SUBMIT_URL``
+
``TriggerSite``
- Legacy option to support older dashboard server implementations.
- Not used when ``IsCDash`` is true.
+ Legacy option. Not used.
* `CTest Script`_ variable: :variable:`CTEST_TRIGGER_SITE`
* :module:`CTest` module variable: ``TRIGGER_SITE`` if set,
else ``CTEST_TRIGGER_SITE``
+.. _`Show as JSON Object Model`:
+
+Show as JSON Object Model
+=========================
+
+When the ``--show-only=json-v1`` command line option is given, the test
+information is output in JSON format. Version 1.0 of the JSON object
+model is defined as follows:
+
+``kind``
+ The string "ctestInfo".
+
+``version``
+ A JSON object specifying the version components. Its members are
+
+ ``major``
+ A non-negative integer specifying the major version component.
+ ``minor``
+ A non-negative integer specifying the minor version component.
+
+``backtraceGraph``
+ JSON object representing backtrace information with the
+ following members:
+
+ ``commands``
+ List of command names.
+ ``files``
+ List of file names.
+ ``nodes``
+ List of node JSON objects with members:
+
+ ``command``
+ Index into the ``commands`` member of the ``backtraceGraph``.
+ ``file``
+ Index into the ``files`` member of the ``backtraceGraph``.
+ ``line``
+ Line number in the file where the backtrace was added.
+ ``parent``
+ Index into the ``nodes`` member of the ``backtraceGraph``
+ representing the parent in the graph.
+
+``tests``
+ A JSON array listing information about each test. Each entry
+ is a JSON object with members:
+
+ ``name``
+ Test name.
+ ``config``
+ Configuration that the test can run on.
+ Empty string means any config.
+ ``command``
+ List where the first element is the test command and the
+ remaining elements are the command arguments.
+ ``backtrace``
+ Index into the ``nodes`` member of the ``backtraceGraph``.
+ ``properties``
+ Test properties.
+ Can contain keys for each of the supported test properties.
+
+.. _`ctest-resource-allocation`:
+
+Resource Allocation
+===================
+
+CTest provides a mechanism for tests to specify the resources that they need
+in a fine-grained way, and for users to specify the resources availiable on
+the running machine. This allows CTest to internally keep track of which
+resources are in use and which are free, scheduling tests in a way that
+prevents them from trying to claim resources that are not available.
+
+A common use case for this feature is for tests that require the use of a GPU.
+Multiple tests can simultaneously allocate memory from a GPU, but if too many
+tests try to do this at once, some of them will fail to allocate, resulting in
+a failed test, even though the test would have succeeded if it had the memory
+it needed. By using the resource allocation feature, each test can specify how
+much memory it requires from a GPU, allowing CTest to schedule tests in a way
+that running several of these tests at once does not exhaust the GPU's memory
+pool.
+
+Please note that CTest has no concept of what a GPU is or how much memory it
+has, nor does it have any way of communicating with a GPU to retrieve this
+information or perform any memory management. CTest simply keeps track of a
+list of abstract resource types, each of which has a certain number of slots
+available for tests to use. Each test specifies the number of slots that it
+requires from a certain resource, and CTest then schedules them in a way that
+prevents the total number of slots in use from exceeding the listed capacity.
+When a test is executed, and slots from a resource are allocated to that test,
+tests may assume that they have exclusive use of those slots for the duration
+of the test's process.
+
+The CTest resource allocation feature consists of two inputs:
+
+* The :ref:`resource specification file <ctest-resource-specification-file>`,
+ described below, which describes the resources available on the system.
+* The :prop_test:`RESOURCE_GROUPS` property of tests, which describes the
+ resources required by the test.
+
+When CTest runs a test, the resources allocated to that test are passed in the
+form of a set of
+:ref:`environment variables <ctest-resource-environment-variables>` as
+described below. Using this information to decide which resource to connect to
+is left to the test writer.
+
+The ``RESOURCE_GROUPS`` property tells CTest what resources a test expects
+to use grouped in a way meaningful to the test. The test itself must read
+the :ref:`environment variables <ctest-resource-environment-variables>` to
+determine which resources have been allocated to each group. For example,
+each group may correspond to a process the test will spawn when executed.
+
+Note that even if a test specifies a ``RESOURCE_GROUPS`` property, it is still
+possible for that to test to run without any resource allocation (and without
+the corresponding
+:ref:`environment variables <ctest-resource-environment-variables>`)
+if the user does not pass a resource specification file. Passing this file,
+either through the ``--resource-spec-file`` command-line argument or the
+``RESOURCE_SPEC_FILE`` argument to :command:`ctest_test`, is what activates the
+resource allocation feature. Tests should check the
+``CTEST_RESOURCE_GROUP_COUNT`` environment variable to find out whether or not
+resource allocation is activated. This variable will always (and only) be
+defined if resource allocation is activated. If resource allocation is not
+activated, then the ``CTEST_RESOURCE_GROUP_COUNT`` variable will not exist,
+even if it exists for the parent ``ctest`` process. If a test absolutely must
+have resource allocation, then it can return a failing exit code or use the
+:prop_test:`SKIP_RETURN_CODE` or :prop_test:`SKIP_REGULAR_EXPRESSION`
+properties to indicate a skipped test.
+
+.. _`ctest-resource-specification-file`:
+
+Resource Specification File
+---------------------------
+
+The resource specification file is a JSON file which is passed to CTest, either
+on the :manual:`ctest(1)` command line as ``--resource-spec-file``, or as the
+``RESOURCE_SPEC_FILE`` argument of :command:`ctest_test`. The resource
+specification file must be a JSON object. All examples in this document assume
+the following resource specification file:
+
+.. code-block:: json
+
+ {
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ {
+ "id": "0",
+ "slots": 2
+ },
+ {
+ "id": "1",
+ "slots": 4
+ },
+ {
+ "id": "2",
+ "slots": 2
+ },
+ {
+ "id": "3"
+ }
+ ],
+ "crypto_chips": [
+ {
+ "id": "card0",
+ "slots": 4
+ }
+ ]
+ }
+ ]
+ }
+
+The members are:
+
+``version``
+ An object containing a ``major`` integer field and a ``minor`` integer field.
+ Currently, the only supported version is major ``1``, minor ``0``. Any other
+ value is an error.
+
+``local``
+ A JSON array of resource sets present on the system. Currently, this array
+ is restricted to being of size 1.
+
+ Each array element is a JSON object with members whose names are equal to the
+ desired resource types, such as ``gpus``. These names must start with a
+ lowercase letter or an underscore, and subsequent characters can be a
+ lowercase letter, a digit, or an underscore. Uppercase letters are not
+ allowed, because certain platforms have case-insensitive environment
+ variables. See the `Environment Variables`_ section below for
+ more information. It is recommended that the resource type name be the plural
+ of a noun, such as ``gpus`` or ``crypto_chips`` (and not ``gpu`` or
+ ``crypto_chip``.)
+
+ Please note that the names ``gpus`` and ``crypto_chips`` are just examples,
+ and CTest does not interpret them in any way. You are free to make up any
+ resource type you want to meet your own requirements.
+
+ The value for each resource type is a JSON array consisting of JSON objects,
+ each of which describe a specific instance of the specified resource. These
+ objects have the following members:
+
+ ``id``
+ A string consisting of an identifier for the resource. Each character in
+ the identifier can be a lowercase letter, a digit, or an underscore.
+ Uppercase letters are not allowed.
+
+ Identifiers must be unique within a resource type. However, they do not
+ have to be unique across resource types. For example, it is valid to have a
+ ``gpus`` resource named ``0`` and a ``crypto_chips`` resource named ``0``,
+ but not two ``gpus`` resources both named ``0``.
+
+ Please note that the IDs ``0``, ``1``, ``2``, ``3``, and ``card0`` are just
+ examples, and CTest does not interpret them in any way. You are free to
+ make up any IDs you want to meet your own requirements.
+
+ ``slots``
+ An optional unsigned number specifying the number of slots available on the
+ resource. For example, this could be megabytes of RAM on a GPU, or
+ cryptography units available on a cryptography chip. If ``slots`` is not
+ specified, a default value of ``1`` is assumed.
+
+In the example file above, there are four GPUs with ID's 0 through 3. GPU 0 has
+2 slots, GPU 1 has 4, GPU 2 has 2, and GPU 3 has a default of 1 slot. There is
+also one cryptography chip with 4 slots.
+
+``RESOURCE_GROUPS`` Property
+----------------------------
+
+See :prop_test:`RESOURCE_GROUPS` for a description of this property.
+
+.. _`ctest-resource-environment-variables`:
+
+Environment Variables
+---------------------
+
+Once CTest has decided which resources to allocate to a test, it passes this
+information to the test executable as a series of environment variables. For
+each example below, we will assume that the test in question has a
+:prop_test:`RESOURCE_GROUPS` property of
+``2,gpus:2;gpus:4,gpus:1,crypto_chips:2``.
+
+The following variables are passed to the test process:
+
+.. envvar:: CTEST_RESOURCE_GROUP_COUNT
+
+ The total number of groups specified by the :prop_test:`RESOURCE_GROUPS`
+ property. For example:
+
+ * ``CTEST_RESOURCE_GROUP_COUNT=3``
+
+ This variable will only be defined if :manual:`ctest(1)` has been given a
+ ``--resource-spec-file``, or if :command:`ctest_test` has been given a
+ ``RESOURCE_SPEC_FILE``. If no resource specification file has been given,
+ this variable will not be defined.
+
+.. envvar:: CTEST_RESOURCE_GROUP_<num>
+
+ The list of resource types allocated to each group, with each item
+ separated by a comma. ``<num>`` is a number from zero to
+ ``CTEST_RESOURCE_GROUP_COUNT`` minus one. ``CTEST_RESOURCE_GROUP_<num>``
+ is defined for each ``<num>`` in this range. For example:
+
+ * ``CTEST_RESOURCE_GROUP_0=gpus``
+ * ``CTEST_RESOURCE_GROUP_1=gpus``
+ * ``CTEST_RESOURCE_GROUP_2=crypto_chips,gpus``
+
+.. envvar:: CTEST_RESOURCE_GROUP_<num>_<resource-type>
+
+ The list of resource IDs and number of slots from each ID allocated to each
+ group for a given resource type. This variable consists of a series of
+ pairs, each pair separated by a semicolon, and with the two items in the pair
+ separated by a comma. The first item in each pair is ``id:`` followed by the
+ ID of a resource of type ``<resource-type>``, and the second item is
+ ``slots:`` followed by the number of slots from that resource allocated to
+ the given group. For example:
+
+ * ``CTEST_RESOURCE_GROUP_0_GPUS=id:0,slots:2``
+ * ``CTEST_RESOURCE_GROUP_1_GPUS=id:2,slots:2``
+ * ``CTEST_RESOURCE_GROUP_2_GPUS=id:1,slots:4;id:3,slots:1``
+ * ``CTEST_RESOURCE_GROUP_2_CRYPTO_CHIPS=id:card0,slots:2``
+
+ In this example, group 0 gets 2 slots from GPU ``0``, group 1 gets 2 slots
+ from GPU ``2``, and group 2 gets 4 slots from GPU ``1``, 1 slot from GPU
+ ``3``, and 2 slots from cryptography chip ``card0``.
+
+ ``<num>`` is a number from zero to ``CTEST_RESOURCE_GROUP_COUNT`` minus one.
+ ``<resource-type>`` is the name of a resource type, converted to uppercase.
+ ``CTEST_RESOURCE_GROUP_<num>_<resource-type>`` is defined for the product
+ of each ``<num>`` in the range listed above and each resource type listed in
+ ``CTEST_RESOURCE_GROUP_<num>``.
+
+ Because some platforms have case-insensitive names for environment variables,
+ the names of resource types may not clash in a case-insensitive environment.
+ Because of this, for the sake of simplicity, all resource types must be
+ listed in all lowercase in the
+ :ref:`resource specification file <ctest-resource-specification-file>` and
+ in the :prop_test:`RESOURCE_GROUPS` property, and they are converted to all
+ uppercase in the ``CTEST_RESOURCE_GROUP_<num>_<resource-type>`` environment
+ variable.
+
See Also
========
.. include:: LINKS.txt
+
+.. _`CDash`: http://cdash.org/
diff --git a/Help/module/CPackArchive.rst b/Help/module/CPackArchive.rst
index eb8d9d244..8616098cb 100644
--- a/Help/module/CPackArchive.rst
+++ b/Help/module/CPackArchive.rst
@@ -1 +1,4 @@
-.. cmake-module:: ../../Modules/CPackArchive.cmake
+CPackArchive
+------------
+
+The documentation for the CPack Archive generator has moved here: :cpack_gen:`CPack Archive Generator`
diff --git a/Help/module/CPackBundle.rst b/Help/module/CPackBundle.rst
index 651e87426..513488427 100644
--- a/Help/module/CPackBundle.rst
+++ b/Help/module/CPackBundle.rst
@@ -1 +1,4 @@
-.. cmake-module:: ../../Modules/CPackBundle.cmake
+CPackBundle
+-----------
+
+The documentation for the CPack Bundle generator has moved here: :cpack_gen:`CPack Bundle Generator`
diff --git a/Help/module/CPackCygwin.rst b/Help/module/CPackCygwin.rst
index 21f447348..719dfceb1 100644
--- a/Help/module/CPackCygwin.rst
+++ b/Help/module/CPackCygwin.rst
@@ -1 +1,4 @@
-.. cmake-module:: ../../Modules/CPackCygwin.cmake
+CPackCygwin
+-----------
+
+The documentation for the CPack Cygwin generator has moved here: :cpack_gen:`CPack Cygwin Generator`
diff --git a/Help/module/CPackDMG.rst b/Help/module/CPackDMG.rst
index 784262c5e..e59dcbb7a 100644
--- a/Help/module/CPackDMG.rst
+++ b/Help/module/CPackDMG.rst
@@ -1 +1,4 @@
-.. cmake-module:: ../../Modules/CPackDMG.cmake
+CPackDMG
+--------
+
+The documentation for the CPack DragNDrop generator has moved here: :cpack_gen:`CPack DragNDrop Generator`
diff --git a/Help/module/CPackDeb.rst b/Help/module/CPackDeb.rst
index d1526ee49..cd7e5f305 100644
--- a/Help/module/CPackDeb.rst
+++ b/Help/module/CPackDeb.rst
@@ -1 +1,4 @@
-.. cmake-module:: ../../Modules/CPackDeb.cmake
+CPackDeb
+--------
+
+The documentation for the CPack DEB generator has moved here: :cpack_gen:`CPack DEB Generator`
diff --git a/Help/module/CPackFreeBSD.rst b/Help/module/CPackFreeBSD.rst
new file mode 100644
index 000000000..69701b8e9
--- /dev/null
+++ b/Help/module/CPackFreeBSD.rst
@@ -0,0 +1,4 @@
+CPackFreeBSD
+------------
+
+The documentation for the CPack FreeBSD generator has moved here: :cpack_gen:`CPack FreeBSD Generator`
diff --git a/Help/module/CPackNSIS.rst b/Help/module/CPackNSIS.rst
index bb35ed60a..2cb407a97 100644
--- a/Help/module/CPackNSIS.rst
+++ b/Help/module/CPackNSIS.rst
@@ -1 +1,4 @@
-.. cmake-module:: ../../Modules/CPackNSIS.cmake
+CPackNSIS
+---------
+
+The documentation for the CPack NSIS generator has moved here: :cpack_gen:`CPack NSIS Generator`
diff --git a/Help/module/CPackNuGet.rst b/Help/module/CPackNuGet.rst
new file mode 100644
index 000000000..4f39b3a7e
--- /dev/null
+++ b/Help/module/CPackNuGet.rst
@@ -0,0 +1,4 @@
+CPackNuGet
+----------
+
+The documentation for the CPack NuGet generator has moved here: :cpack_gen:`CPack NuGet Generator`
diff --git a/Help/module/CPackPackageMaker.rst b/Help/module/CPackPackageMaker.rst
index de5544869..226b6fd8e 100644
--- a/Help/module/CPackPackageMaker.rst
+++ b/Help/module/CPackPackageMaker.rst
@@ -1 +1,4 @@
-.. cmake-module:: ../../Modules/CPackPackageMaker.cmake
+CPackPackageMaker
+-----------------
+
+The documentation for the CPack PackageMaker generator has moved here: :cpack_gen:`CPack PackageMaker Generator`
diff --git a/Help/module/CPackProductBuild.rst b/Help/module/CPackProductBuild.rst
index 6081fe48a..8cd9198b4 100644
--- a/Help/module/CPackProductBuild.rst
+++ b/Help/module/CPackProductBuild.rst
@@ -1 +1,4 @@
-.. cmake-module:: ../../Modules/CPackProductBuild.cmake
+CPackProductBuild
+-----------------
+
+The documentation for the CPack productbuild generator has moved here: :cpack_gen:`CPack productbuild Generator`
diff --git a/Help/module/CPackRPM.rst b/Help/module/CPackRPM.rst
index 28d0e6912..00b7e0ad7 100644
--- a/Help/module/CPackRPM.rst
+++ b/Help/module/CPackRPM.rst
@@ -1 +1,4 @@
-.. cmake-module:: ../../Modules/CPackRPM.cmake
+CPackRPM
+--------
+
+The documentation for the CPack RPM generator has moved here: :cpack_gen:`CPack RPM Generator`
diff --git a/Help/module/CPackWIX.rst b/Help/module/CPackWIX.rst
index 1f5e451e9..fd378b86a 100644
--- a/Help/module/CPackWIX.rst
+++ b/Help/module/CPackWIX.rst
@@ -1 +1,5 @@
-.. cmake-module:: ../../Modules/CPackWIX.cmake
+CPackWIX
+--------
+
+The documentation for the CPack WIX generator has moved here:
+:cpack_gen:`CPack WIX Generator`
diff --git a/Help/module/CheckFortranSourceRuns.rst b/Help/module/CheckFortranSourceRuns.rst
new file mode 100644
index 000000000..a1bff7063
--- /dev/null
+++ b/Help/module/CheckFortranSourceRuns.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/CheckFortranSourceRuns.cmake
diff --git a/Help/module/CheckOBJCCompilerFlag.rst b/Help/module/CheckOBJCCompilerFlag.rst
new file mode 100644
index 000000000..e4bd6fdae
--- /dev/null
+++ b/Help/module/CheckOBJCCompilerFlag.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/CheckOBJCCompilerFlag.cmake
diff --git a/Help/module/CheckOBJCSourceCompiles.rst b/Help/module/CheckOBJCSourceCompiles.rst
new file mode 100644
index 000000000..d4a1484ec
--- /dev/null
+++ b/Help/module/CheckOBJCSourceCompiles.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/CheckOBJCSourceCompiles.cmake
diff --git a/Help/module/CheckOBJCSourceRuns.rst b/Help/module/CheckOBJCSourceRuns.rst
new file mode 100644
index 000000000..c72f0db20
--- /dev/null
+++ b/Help/module/CheckOBJCSourceRuns.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/CheckOBJCSourceRuns.cmake
diff --git a/Help/module/CheckOBJCXXCompilerFlag.rst b/Help/module/CheckOBJCXXCompilerFlag.rst
new file mode 100644
index 000000000..1518a48ee
--- /dev/null
+++ b/Help/module/CheckOBJCXXCompilerFlag.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/CheckOBJCXXCompilerFlag.cmake
diff --git a/Help/module/CheckOBJCXXSourceCompiles.rst b/Help/module/CheckOBJCXXSourceCompiles.rst
new file mode 100644
index 000000000..a1c8ae94e
--- /dev/null
+++ b/Help/module/CheckOBJCXXSourceCompiles.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/CheckOBJCXXSourceCompiles.cmake
diff --git a/Help/module/CheckOBJCXXSourceRuns.rst b/Help/module/CheckOBJCXXSourceRuns.rst
new file mode 100644
index 000000000..5198e1b6d
--- /dev/null
+++ b/Help/module/CheckOBJCXXSourceRuns.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/CheckOBJCXXSourceRuns.cmake
diff --git a/Help/module/CheckPIESupported.rst b/Help/module/CheckPIESupported.rst
new file mode 100644
index 000000000..02e7b4316
--- /dev/null
+++ b/Help/module/CheckPIESupported.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/CheckPIESupported.cmake
diff --git a/Help/module/FetchContent.rst b/Help/module/FetchContent.rst
new file mode 100644
index 000000000..c130a6dcb
--- /dev/null
+++ b/Help/module/FetchContent.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FetchContent.cmake
diff --git a/Help/module/FindEnvModules.rst b/Help/module/FindEnvModules.rst
new file mode 100644
index 000000000..72c120f22
--- /dev/null
+++ b/Help/module/FindEnvModules.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindEnvModules.cmake
diff --git a/Help/module/FindFontconfig.rst b/Help/module/FindFontconfig.rst
new file mode 100644
index 000000000..449fe09d0
--- /dev/null
+++ b/Help/module/FindFontconfig.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindFontconfig.cmake
diff --git a/Help/module/FindIconv.rst b/Help/module/FindIconv.rst
new file mode 100644
index 000000000..c1f3ed080
--- /dev/null
+++ b/Help/module/FindIconv.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindIconv.cmake
diff --git a/Help/module/FindLibinput.rst b/Help/module/FindLibinput.rst
new file mode 100644
index 000000000..a8ca0b024
--- /dev/null
+++ b/Help/module/FindLibinput.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindLibinput.cmake
diff --git a/Help/module/FindODBC.rst b/Help/module/FindODBC.rst
new file mode 100644
index 000000000..8558334df
--- /dev/null
+++ b/Help/module/FindODBC.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindODBC.cmake
diff --git a/Help/module/FindOpenACC.rst b/Help/module/FindOpenACC.rst
new file mode 100644
index 000000000..dda330831
--- /dev/null
+++ b/Help/module/FindOpenACC.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindOpenACC.cmake
diff --git a/Help/module/FindPatch.rst b/Help/module/FindPatch.rst
new file mode 100644
index 000000000..ba5e9102d
--- /dev/null
+++ b/Help/module/FindPatch.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindPatch.cmake
diff --git a/Help/module/FindPython.rst b/Help/module/FindPython.rst
new file mode 100644
index 000000000..057a350c0
--- /dev/null
+++ b/Help/module/FindPython.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindPython.cmake
diff --git a/Help/module/FindPython2.rst b/Help/module/FindPython2.rst
new file mode 100644
index 000000000..1696bedc1
--- /dev/null
+++ b/Help/module/FindPython2.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindPython2.cmake
diff --git a/Help/module/FindPython3.rst b/Help/module/FindPython3.rst
new file mode 100644
index 000000000..e530ab85c
--- /dev/null
+++ b/Help/module/FindPython3.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindPython3.cmake
diff --git a/Help/module/FindSQLite3.rst b/Help/module/FindSQLite3.rst
new file mode 100644
index 000000000..d1910e5a6
--- /dev/null
+++ b/Help/module/FindSQLite3.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindSQLite3.cmake
diff --git a/Help/policy/CMP0000.rst b/Help/policy/CMP0000.rst
index 97ea633b2..aecfa7187 100644
--- a/Help/policy/CMP0000.rst
+++ b/Help/policy/CMP0000.rst
@@ -7,25 +7,27 @@ CMake requires that projects specify the version of CMake to which
they have been written. This policy has been put in place so users
trying to build the project may be told when they need to update their
CMake. Specifying a version also helps the project build with CMake
-versions newer than that specified. Use the cmake_minimum_required
-command at the top of your main CMakeLists.txt file:
+versions newer than that specified. Use the :command:`cmake_minimum_required`
+command at the top of your main ``CMakeLists.txt`` file:
::
cmake_minimum_required(VERSION <major>.<minor>)
-where "<major>.<minor>" is the version of CMake you want to support
-(such as "2.6"). The command will ensure that at least the given
+where ``<major>.<minor>`` is the version of CMake you want to support
+(such as ``3.14``). The command will ensure that at least the given
version of CMake is running and help newer versions be compatible with
-the project. See documentation of cmake_minimum_required for details.
+the project. See documentation of :command:`cmake_minimum_required` for
+details.
-Note that the command invocation must appear in the CMakeLists.txt
+Note that the command invocation must appear in the ``CMakeLists.txt``
file itself; a call in an included file is not sufficient. However,
-the cmake_policy command may be called to set policy CMP0000 to OLD or
-NEW behavior explicitly. The OLD behavior is to silently ignore the
-missing invocation. The NEW behavior is to issue an error instead of
-a warning. An included file may set CMP0000 explicitly to affect how
-this policy is enforced for the main CMakeLists.txt file.
+the :command:`cmake_policy` command may be called to set policy ``CMP0000``
+to ``OLD`` or ``NEW`` behavior explicitly. The ``OLD`` behavior is to
+silently ignore the missing invocation. The ``NEW`` behavior is to issue
+an error instead of a warning. An included file may set ``CMP0000``
+explicitly to affect how this policy is enforced for the main
+``CMakeLists.txt`` file.
This policy was introduced in CMake version 2.6.0.
diff --git a/Help/policy/CMP0001.rst b/Help/policy/CMP0001.rst
index 09ad38702..6fa64d983 100644
--- a/Help/policy/CMP0001.rst
+++ b/Help/policy/CMP0001.rst
@@ -1,21 +1,21 @@
CMP0001
-------
-CMAKE_BACKWARDS_COMPATIBILITY should no longer be used.
+``CMAKE_BACKWARDS_COMPATIBILITY`` should no longer be used.
-The OLD behavior is to check CMAKE_BACKWARDS_COMPATIBILITY and present
-it to the user. The NEW behavior is to ignore
+The behavior is to check ``CMAKE_BACKWARDS_COMPATIBILITY`` and present
+it to the user. The ``NEW`` behavior is to ignore
CMAKE_BACKWARDS_COMPATIBILITY completely.
-In CMake 2.4 and below the variable CMAKE_BACKWARDS_COMPATIBILITY was
+In CMake 2.4 and below the variable ``CMAKE_BACKWARDS_COMPATIBILITY`` was
used to request compatibility with earlier versions of CMake. In
CMake 2.6 and above all compatibility issues are handled by policies
-and the cmake_policy command. However, CMake must still check
-CMAKE_BACKWARDS_COMPATIBILITY for projects written for CMake 2.4 and
+and the :command:`cmake_policy` command. However, CMake must still check
+``CMAKE_BACKWARDS_COMPATIBILITY`` for projects written for CMake 2.4 and
below.
This policy was introduced in CMake version 2.6.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0002.rst b/Help/policy/CMP0002.rst
index 7cc53efa1..dc68d5180 100644
--- a/Help/policy/CMP0002.rst
+++ b/Help/policy/CMP0002.rst
@@ -3,8 +3,8 @@ CMP0002
Logical target names must be globally unique.
-Targets names created with add_executable, add_library, or
-add_custom_target are logical build target names. Logical target
+Targets names created with :command:`add_executable`, :command:`add_library`, or
+:command:`add_custom_target` are logical build target names. Logical target
names must be globally unique because:
::
@@ -16,13 +16,13 @@ names must be globally unique because:
The logical name of executable and library targets does not have to
correspond to the physical file names built. Consider using the
-OUTPUT_NAME target property to create two targets with the same
+:prop_tgt:`OUTPUT_NAME` target property to create two targets with the same
physical name while keeping logical names distinct. Custom targets
must simply have globally unique names (unless one uses the global
-property ALLOW_DUPLICATE_CUSTOM_TARGETS with a Makefiles generator).
+property :prop_gbl:`ALLOW_DUPLICATE_CUSTOM_TARGETS` with a Makefiles generator).
This policy was introduced in CMake version 2.6.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0003.rst b/Help/policy/CMP0003.rst
index 16b045165..dd90883dc 100644
--- a/Help/policy/CMP0003.rst
+++ b/Help/policy/CMP0003.rst
@@ -37,7 +37,7 @@ Unfortunately this change can break code like
target_link_libraries(myexe /path/to/libA.so B)
-where "B" is meant to find "/path/to/libB.so". This code is wrong
+where ``B`` is meant to find ``/path/to/libB.so``. This code is wrong
because the user is asking the linker to find library B but has not
provided a linker search path (which may be added with the
link_directories command). However, with the old linking
@@ -45,9 +45,9 @@ implementation the code would work accidentally because the linker
search path added for library A allowed library B to be found.
In order to support projects depending on linker search paths added by
-linking to libraries with known full paths, the OLD behavior for this
+linking to libraries with known full paths, the ``OLD`` behavior for this
policy will add the linker search paths even though they are not
-needed for their own libraries. When this policy is set to OLD, CMake
+needed for their own libraries. When this policy is set to ``OLD``, CMake
will produce a link line such as
::
@@ -98,7 +98,7 @@ target. This avoids flooding users with messages for every target
when setting the policy once will probably fix all targets.
This policy was introduced in CMake version 2.6.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0004.rst b/Help/policy/CMP0004.rst
index 55da4d293..be6d3079b 100644
--- a/Help/policy/CMP0004.rst
+++ b/Help/policy/CMP0004.rst
@@ -12,14 +12,15 @@ whitespace from libraries linked with code like
This could lead to subtle errors in user projects.
-The OLD behavior for this policy is to silently remove leading and
-trailing whitespace. The NEW behavior for this policy is to diagnose
+The ``OLD`` behavior for this policy is to silently remove leading and
+trailing whitespace. The ``NEW`` behavior for this policy is to diagnose
the existence of such whitespace as an error. The setting for this
policy used when checking the library names is that in effect when the
-target is created by an add_executable or add_library command.
+target is created by an :command:`add_executable` or :command:`add_library`
+command.
This policy was introduced in CMake version 2.6.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0005.rst b/Help/policy/CMP0005.rst
index 66d125fb7..59567d56e 100644
--- a/Help/policy/CMP0005.rst
+++ b/Help/policy/CMP0005.rst
@@ -12,15 +12,15 @@ CMake versions 2.6 and above support escaping of most values, but
cannot assume the user has not added escapes already in an attempt to
work around limitations in earlier versions.
-The OLD behavior for this policy is to place definition values given
+The ``OLD`` behavior for this policy is to place definition values given
to add_definitions directly in the generated build rules without
-attempting to escape anything. The NEW behavior for this policy is to
+attempting to escape anything. The ``NEW`` behavior for this policy is to
generate correct escapes for all native build tools automatically.
-See documentation of the COMPILE_DEFINITIONS target property for
+See documentation of the ``COMPILE_DEFINITIONS`` target property for
limitations of the escaping implementation.
This policy was introduced in CMake version 2.6.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0006.rst b/Help/policy/CMP0006.rst
index d1b9ece7f..181958b39 100644
--- a/Help/policy/CMP0006.rst
+++ b/Help/policy/CMP0006.rst
@@ -1,24 +1,24 @@
CMP0006
-------
-Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION.
+Installing :prop_tgt:`MACOSX_BUNDLE` targets requires a ``BUNDLE DESTINATION``.
-This policy determines whether the install(TARGETS) command must be
-given a BUNDLE DESTINATION when asked to install a target with the
-MACOSX_BUNDLE property set. CMake 2.4 and below did not distinguish
+This policy determines whether the :command:`install(TARGETS)` command must be
+given a ``BUNDLE DESTINATION`` when asked to install a target with the
+:prop_tgt:`MACOSX_BUNDLE` property set. CMake 2.4 and below did not distinguish
application bundles from normal executables when installing targets.
-CMake 2.6 provides a BUNDLE option to the install(TARGETS) command
-that specifies rules specific to application bundles on the Mac.
+CMake 2.6 provides a ``BUNDLE`` option to the :command:`install(TARGETS)`
+command that specifies rules specific to application bundles on the Mac.
Projects should use this option when installing a target with the
-MACOSX_BUNDLE property set.
+:prop_tgt:`MACOSX_BUNDLE` property set.
-The OLD behavior for this policy is to fall back to the RUNTIME
-DESTINATION if a BUNDLE DESTINATION is not given. The NEW behavior
-for this policy is to produce an error if a bundle target is installed
-without a BUNDLE DESTINATION.
+The ``OLD`` behavior for this policy is to fall back to the
+``RUNTIME DESTINATION`` if a ``BUNDLE DESTINATION`` is not given. The ``NEW``
+behavior for this policy is to produce an error if a bundle target is installed
+without a ``BUNDLE DESTINATION``.
This policy was introduced in CMake version 2.6.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0007.rst b/Help/policy/CMP0007.rst
index 39276457a..1006ed33a 100644
--- a/Help/policy/CMP0007.rst
+++ b/Help/policy/CMP0007.rst
@@ -5,13 +5,13 @@ list command no longer ignores empty elements.
This policy determines whether the list command will ignore empty
elements in the list. CMake 2.4 and below list commands ignored all
-empty elements in the list. For example, a;b;;c would have length 3
-and not 4. The OLD behavior for this policy is to ignore empty list
-elements. The NEW behavior for this policy is to correctly count
+empty elements in the list. For example, ``a;b;;c`` would have length 3
+and not 4. The ``OLD`` behavior for this policy is to ignore empty list
+elements. The ``NEW`` behavior for this policy is to correctly count
empty elements in a list.
This policy was introduced in CMake version 2.6.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0008.rst b/Help/policy/CMP0008.rst
index f1e2ddde5..18ede821c 100644
--- a/Help/policy/CMP0008.rst
+++ b/Help/policy/CMP0008.rst
@@ -9,26 +9,27 @@ In CMake 2.4 and below it is possible to write code like
target_link_libraries(myexe /full/path/to/somelib)
-where "somelib" is supposed to be a valid library file name such as
-"libsomelib.a" or "somelib.lib". For Makefile generators this
+where ``somelib`` is supposed to be a valid library file name such as
+``libsomelib.a`` or ``somelib.lib``. For Makefile generators this
produces an error at build time because the dependency on the full
-path cannot be found. For VS IDE and Xcode generators this used to
+path cannot be found. For :ref:`Visual Studio Generators` IDE
+and :generator:`Xcode` generators this used to
work by accident because CMake would always split off the library
directory and ask the linker to search for the library by name
-(-lsomelib or somelib.lib). Despite the failure with Makefiles, some
-projects have code like this and build only with VS and/or Xcode.
+(``-lsomelib`` or ``somelib.lib``). Despite the failure with Makefiles, some
+projects have code like this and build only with Visual Studio and/or Xcode.
This version of CMake prefers to pass the full path directly to the
native build tool, which will fail in this case because it does not
name a valid library file.
This policy determines what to do with full paths that do not appear
-to name a valid library file. The OLD behavior for this policy is to
+to name a valid library file. The ``OLD`` behavior for this policy is to
split the library name from the path and ask the linker to search for
-it. The NEW behavior for this policy is to trust the given path and
+it. The ``NEW`` behavior for this policy is to trust the given path and
pass it directly to the native build tool unchanged.
This policy was introduced in CMake version 2.6.1. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0009.rst b/Help/policy/CMP0009.rst
index 44baeb449..27cfde0db 100644
--- a/Help/policy/CMP0009.rst
+++ b/Help/policy/CMP0009.rst
@@ -3,19 +3,19 @@ CMP0009
FILE GLOB_RECURSE calls should not follow symlinks by default.
-In CMake 2.6.1 and below, FILE GLOB_RECURSE calls would follow through
-symlinks, sometimes coming up with unexpectedly large result sets
+In CMake 2.6.1 and below, :command:`file(GLOB_RECURSE)` calls would follow
+through symlinks, sometimes coming up with unexpectedly large result sets
because of symlinks to top level directories that contain hundreds of
thousands of files.
This policy determines whether or not to follow symlinks encountered
-during a FILE GLOB_RECURSE call. The OLD behavior for this policy is
-to follow the symlinks. The NEW behavior for this policy is not to
-follow the symlinks by default, but only if FOLLOW_SYMLINKS is given
-as an additional argument to the FILE command.
+during a :command:`file(GLOB_RECURSE)` call. The ``OLD`` behavior for this
+policy is to follow the symlinks. The ``NEW`` behavior for this policy is not
+to follow the symlinks by default, but only if ``FOLLOW_SYMLINKS`` is given
+as an additional argument to the ``FILE`` command.
This policy was introduced in CMake version 2.6.2. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0010.rst b/Help/policy/CMP0010.rst
index 344d70475..cfae4982a 100644
--- a/Help/policy/CMP0010.rst
+++ b/Help/policy/CMP0010.rst
@@ -4,17 +4,17 @@ CMP0010
Bad variable reference syntax is an error.
In CMake 2.6.2 and below, incorrect variable reference syntax such as
-a missing close-brace ("${FOO") was reported but did not stop
+a missing close-brace (``${FOO``) was reported but did not stop
processing of CMake code. This policy determines whether a bad
-variable reference is an error. The OLD behavior for this policy is
+variable reference is an error. The ``OLD`` behavior for this policy is
to warn about the error, leave the string untouched, and continue.
-The NEW behavior for this policy is to report an error.
+The ``NEW`` behavior for this policy is to report an error.
If :policy:`CMP0053` is set to ``NEW``, this policy has no effect
and is treated as always being ``NEW``.
This policy was introduced in CMake version 2.6.3. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0011.rst b/Help/policy/CMP0011.rst
index d281e0ef7..257415c26 100644
--- a/Help/policy/CMP0011.rst
+++ b/Help/policy/CMP0011.rst
@@ -1,24 +1,25 @@
CMP0011
-------
-Included scripts do automatic cmake_policy PUSH and POP.
+Included scripts do automatic :command:`cmake_policy` PUSH and POP.
In CMake 2.6.2 and below, CMake Policy settings in scripts loaded by
-the include() and find_package() commands would affect the includer.
-Explicit invocations of cmake_policy(PUSH) and cmake_policy(POP) were
-required to isolate policy changes and protect the includer. While
-some scripts intend to affect the policies of their includer, most do
-not. In CMake 2.6.3 and above, include() and find_package() by
-default PUSH and POP an entry on the policy stack around an included
-script, but provide a NO_POLICY_SCOPE option to disable it. This
-policy determines whether or not to imply NO_POLICY_SCOPE for
-compatibility. The OLD behavior for this policy is to imply
-NO_POLICY_SCOPE for include() and find_package() commands. The NEW
-behavior for this policy is to allow the commands to do their default
-cmake_policy PUSH and POP.
+the :command:`include` and :command:`find_package` commands would affect
+the includer. Explicit invocations of ``cmake_policy(PUSH)`` and
+``cmake_policy(POP)`` were required to isolate policy changes and protect
+the includer. While some scripts intend to affect the policies of their
+includer, most do not. In CMake 2.6.3 and above, :command:`include` and
+:command:`find_package` by default ``PUSH`` and ``POP`` an entry on
+the policy stack around an included
+script, but provide a ``NO_POLICY_SCOPE`` option to disable it. This
+policy determines whether or not to imply ``NO_POLICY_SCOPE`` for
+compatibility. The ``OLD`` behavior for this policy is to imply
+``NO_POLICY_SCOPE`` for :command:`include` and :command:`find_package` commands.
+The ``NEW`` behavior for this policy is to allow the commands to do
+their default cmake_policy ``PUSH`` and ``POP``.
This policy was introduced in CMake version 2.6.3. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0012.rst b/Help/policy/CMP0012.rst
index 85d64f4d4..17ec8d33d 100644
--- a/Help/policy/CMP0012.rst
+++ b/Help/policy/CMP0012.rst
@@ -1,27 +1,28 @@
CMP0012
-------
-if() recognizes numbers and boolean constants.
+:command:`if` recognizes numbers and boolean constants.
-In CMake versions 2.6.4 and lower the if() command implicitly
+In CMake versions 2.6.4 and lower the :command:`if` command implicitly
dereferenced arguments corresponding to variables, even those named
-like numbers or boolean constants, except for 0 and 1. Numbers and
-boolean constants such as true, false, yes, no, on, off, y, n,
-notfound, ignore (all case insensitive) were recognized in some cases
-but not all. For example, the code "if(TRUE)" might have evaluated as
-false. Numbers such as 2 were recognized only in boolean expressions
-like "if(NOT 2)" (leading to false) but not as a single-argument like
-"if(2)" (also leading to false). Later versions of CMake prefer to
+like numbers or boolean constants, except for ``0`` and ``1``. Numbers and
+boolean constants such as ``true``, ``false``, ``yes``, ``no``, ``on``,
+``off``, ``y``, ``n``, ``notfound``, ``ignore`` (all case insensitive)
+were recognized in some cases but not all. For example, the code ``if(TRUE)``
+might have evaluated as ``false``.
+Numbers such as 2 were recognized only in boolean expressions
+like ``if(NOT 2)`` (leading to ``false``) but not as a single-argument like
+``if(2)`` (also leading to ``false``). Later versions of CMake prefer to
treat numbers and boolean constants literally, so they should not be
used as variable names.
-The OLD behavior for this policy is to implicitly dereference
-variables named like numbers and boolean constants. The NEW behavior
+The ``OLD`` behavior for this policy is to implicitly dereference
+variables named like numbers and boolean constants. The ``NEW`` behavior
for this policy is to recognize numbers and boolean constants without
dereferencing variables with such names.
This policy was introduced in CMake version 2.8.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0013.rst b/Help/policy/CMP0013.rst
index 2fabb8920..dbd67a177 100644
--- a/Help/policy/CMP0013.rst
+++ b/Help/policy/CMP0013.rst
@@ -9,13 +9,13 @@ generation files would be written and then overwritten in the build
tree and could lead to strange behavior. CMake 2.6.4 and above
explicitly detect duplicate binary directories. CMake 2.6.4 always
considers this case an error. In CMake 2.8.0 and above this policy
-determines whether or not the case is an error. The OLD behavior for
+determines whether or not the case is an error. The ``OLD`` behavior for
this policy is to allow duplicate binary directories. The NEW
behavior for this policy is to disallow duplicate binary directories
with an error.
This policy was introduced in CMake version 2.8.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0014.rst b/Help/policy/CMP0014.rst
index f1f7b77b8..331dde5ef 100644
--- a/Help/policy/CMP0014.rst
+++ b/Help/policy/CMP0014.rst
@@ -1,17 +1,17 @@
CMP0014
-------
-Input directories must have CMakeLists.txt.
+Input directories must have ``CMakeLists.txt``.
-CMake versions before 2.8 silently ignored missing CMakeLists.txt
-files in directories referenced by add_subdirectory() or subdirs(),
+CMake versions before 2.8 silently ignored missing ``CMakeLists.txt``
+files in directories referenced by :command:`add_subdirectory` or :command:`subdirs`,
treating them as if present but empty. In CMake 2.8.0 and above this
-policy determines whether or not the case is an error. The OLD
-behavior for this policy is to silently ignore the problem. The NEW
-behavior for this policy is to report an error.
+:command:`cmake_policy` determines whether or not the case is an error.
+The ``OLD`` behavior for this policy is to silently ignore the problem.
+The ``NEW`` behavior for this policy is to report an error.
This policy was introduced in CMake version 2.8.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0015.rst b/Help/policy/CMP0015.rst
index 9a48e3dac..90d520334 100644
--- a/Help/policy/CMP0015.rst
+++ b/Help/policy/CMP0015.rst
@@ -1,19 +1,19 @@
CMP0015
-------
-link_directories() treats paths relative to the source dir.
+ :command:`link_directories` treats paths relative to the source dir.
-In CMake 2.8.0 and lower the link_directories() command passed
+In CMake 2.8.0 and lower the :command:`link_directories` command passed
relative paths unchanged to the linker. In CMake 2.8.1 and above the
-link_directories() command prefers to interpret relative paths with
-respect to CMAKE_CURRENT_SOURCE_DIR, which is consistent with
-include_directories() and other commands. The OLD behavior for this
-policy is to use relative paths verbatim in the linker command. The
-NEW behavior for this policy is to convert relative paths to absolute
-paths by appending the relative path to CMAKE_CURRENT_SOURCE_DIR.
+:command:`link_directories` command prefers to interpret relative paths with
+respect to ``CMAKE_CURRENT_SOURCE_DIR``, which is consistent with
+:command:`include_directories` and other commands. The ``OLD`` behavior for
+this policy is to use relative paths verbatim in the linker command. The
+``NEW`` behavior for this policy is to convert relative paths to absolute
+paths by appending the relative path to ``CMAKE_CURRENT_SOURCE_DIR``.
This policy was introduced in CMake version 2.8.1. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0016.rst b/Help/policy/CMP0016.rst
index cc898c8ca..026d02a9d 100644
--- a/Help/policy/CMP0016.rst
+++ b/Help/policy/CMP0016.rst
@@ -1,15 +1,16 @@
CMP0016
-------
-target_link_libraries() reports error if its only argument is not a target.
+:command:`target_link_libraries` reports error if its only argument
+is not a target.
-In CMake 2.8.2 and lower the target_link_libraries() command silently
+In CMake 2.8.2 and lower the :command:`target_link_libraries` command silently
ignored if it was called with only one argument, and this argument
wasn't a valid target. In CMake 2.8.3 and above it reports an error
in this case.
This policy was introduced in CMake version 2.8.3. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0017.rst b/Help/policy/CMP0017.rst
index 9f0f0380f..ca4664eed 100644
--- a/Help/policy/CMP0017.rst
+++ b/Help/policy/CMP0017.rst
@@ -4,18 +4,18 @@ CMP0017
Prefer files from the CMake module directory when including from there.
Starting with CMake 2.8.4, if a cmake-module shipped with CMake (i.e.
-located in the CMake module directory) calls include() or
-find_package(), the files located in the CMake module directory are
-preferred over the files in CMAKE_MODULE_PATH. This makes sure that
-the modules belonging to CMake always get those files included which
+located in the CMake module directory) calls :command:`include` or
+:command:`find_package`, the files located in the CMake module directory are
+preferred over the files in :variable:`CMAKE_MODULE_PATH`. This makes sure
+that the modules belonging to CMake always get those files included which
they expect, and against which they were developed and tested. In all
-other cases, the files found in CMAKE_MODULE_PATH still take
-precedence over the ones in the CMake module directory. The OLD
+other cases, the files found in :variable:`CMAKE_MODULE_PATH` still take
+precedence over the ones in the CMake module directory. The ``OLD``
behavior is to always prefer files from CMAKE_MODULE_PATH over files
from the CMake modules directory.
This policy was introduced in CMake version 2.8.4. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0018.rst b/Help/policy/CMP0018.rst
index a3a7a12bd..624840678 100644
--- a/Help/policy/CMP0018.rst
+++ b/Help/policy/CMP0018.rst
@@ -1,34 +1,35 @@
CMP0018
-------
-Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.
+Ignore ``CMAKE_SHARED_LIBRARY_<Lang>_FLAGS`` variable.
-CMake 2.8.8 and lower compiled sources in SHARED and MODULE libraries
-using the value of the undocumented CMAKE_SHARED_LIBRARY_<Lang>_FLAGS
+CMake 2.8.8 and lower compiled sources in ``SHARED`` and ``MODULE`` libraries
+using the value of the undocumented ``CMAKE_SHARED_LIBRARY_<Lang>_FLAGS``
platform variable. The variable contained platform-specific flags
needed to compile objects for shared libraries. Typically it included
-a flag such as -fPIC for position independent code but also included
+a flag such as ``-fPIC`` for position independent code but also included
other flags needed on certain platforms. CMake 2.8.9 and higher
-prefer instead to use the POSITION_INDEPENDENT_CODE target property to
-determine what targets should be position independent, and new
+prefer instead to use the :prop_tgt:`POSITION_INDEPENDENT_CODE` target
+property to determine what targets should be position independent, and new
undocumented platform variables to select flags while ignoring
-CMAKE_SHARED_LIBRARY_<Lang>_FLAGS completely.
+``CMAKE_SHARED_LIBRARY_<Lang>_FLAGS`` completely.
The default for either approach produces identical compilation flags,
-but if a project modifies CMAKE_SHARED_LIBRARY_<Lang>_FLAGS from its
+but if a project modifies ``CMAKE_SHARED_LIBRARY_<Lang>_FLAGS`` from its
original value this policy determines which approach to use.
-The OLD behavior for this policy is to ignore the
-POSITION_INDEPENDENT_CODE property for all targets and use the
-modified value of CMAKE_SHARED_LIBRARY_<Lang>_FLAGS for SHARED and
-MODULE libraries.
+The ``OLD`` behavior for this policy is to ignore the
+:prop_tgt:`POSITION_INDEPENDENT_CODE` property for all targets and use the
+modified value of ``CMAKE_SHARED_LIBRARY_<Lang>_FLAGS`` for ``SHARED`` and
+``MODULE`` libraries.
-The NEW behavior for this policy is to ignore
-CMAKE_SHARED_LIBRARY_<Lang>_FLAGS whether it is modified or not and
-honor the POSITION_INDEPENDENT_CODE target property.
+The ``NEW`` behavior for this policy is to ignore
+``CMAKE_SHARED_LIBRARY_<Lang>_FLAGS`` whether it is modified or not and
+honor the :prop_tgt:`POSITION_INDEPENDENT_CODE` target property.
This policy was introduced in CMake version 2.8.9. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0019.rst b/Help/policy/CMP0019.rst
index 2e3557d32..682dcdf86 100644
--- a/Help/policy/CMP0019.rst
+++ b/Help/policy/CMP0019.rst
@@ -11,12 +11,12 @@ CMake versions because all variable references are now normally
evaluated during CMake language processing. CMake 2.8.11 and higher
prefer to skip the extra evaluation.
-The OLD behavior for this policy is to re-evaluate the values for
-strict compatibility. The NEW behavior for this policy is to leave
+The ``OLD`` behavior for this policy is to re-evaluate the values for
+strict compatibility. The ``NEW`` behavior for this policy is to leave
the values untouched.
This policy was introduced in CMake version 2.8.11. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0020.rst b/Help/policy/CMP0020.rst
index 75ca9deb2..6d27684f2 100644
--- a/Help/policy/CMP0020.rst
+++ b/Help/policy/CMP0020.rst
@@ -1,27 +1,27 @@
CMP0020
-------
-Automatically link Qt executables to qtmain target on Windows.
+Automatically link Qt executables to ``qtmain`` target on Windows.
CMake 2.8.10 and lower required users of Qt to always specify a link
-dependency to the qtmain.lib static library manually on Windows.
+dependency to the ``qtmain.lib`` static library manually on Windows.
CMake 2.8.11 gained the ability to evaluate generator expressions
-while determining the link dependencies from IMPORTED targets. This
+while determining the link dependencies from ``IMPORTED`` targets. This
allows CMake itself to automatically link executables which link to Qt
-to the qtmain.lib library when using IMPORTED Qt targets. For
-applications already linking to qtmain.lib, this should have little
+to the ``qtmain.lib`` library when using ``IMPORTED`` Qt targets. For
+applications already linking to ``qtmain.lib``, this should have little
impact. For applications which supply their own alternative WinMain
implementation and for applications which use the QAxServer library,
this automatic linking will need to be disabled as per the
documentation.
-The OLD behavior for this policy is not to link executables to
-qtmain.lib automatically when they link to the QtCore IMPORTED target.
-The NEW behavior for this policy is to link executables to qtmain.lib
-automatically when they link to QtCore IMPORTED target.
+The ``OLD`` behavior for this policy is not to link executables to
+``qtmain.lib`` automatically when they link to the QtCore ``IMPORTED`` target.
+The ``NEW`` behavior for this policy is to link executables to ``qtmain.lib``
+automatically when they link to QtCore ``IMPORTED`` target.
This policy was introduced in CMake version 2.8.11. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0021.rst b/Help/policy/CMP0021.rst
index 3a792ca14..937b106eb 100644
--- a/Help/policy/CMP0021.rst
+++ b/Help/policy/CMP0021.rst
@@ -1,20 +1,21 @@
CMP0021
-------
-Fatal error on relative paths in INCLUDE_DIRECTORIES target property.
+Fatal error on relative paths in :prop_tgt:`INCLUDE_DIRECTORIES` target
+property.
-CMake 2.8.10.2 and lower allowed the INCLUDE_DIRECTORIES target
+CMake 2.8.10.2 and lower allowed the :prop_tgt:`INCLUDE_DIRECTORIES` target
property to contain relative paths. The base path for such relative
-entries is not well defined. CMake 2.8.12 issues a FATAL_ERROR if the
-INCLUDE_DIRECTORIES property contains a relative path.
+entries is not well defined. CMake 2.8.12 issues a ``FATAL_ERROR`` if the
+:prop_tgt:`INCLUDE_DIRECTORIES` property contains a relative path.
-The OLD behavior for this policy is not to warn about relative paths
-in the INCLUDE_DIRECTORIES target property. The NEW behavior for this
-policy is to issue a FATAL_ERROR if INCLUDE_DIRECTORIES contains a
+The ``OLD`` behavior for this policy is not to warn about relative paths
+in the ``INCLUDE_DIRECTORIES`` target property. The ``NEW`` behavior for this
+policy is to issue a ``FATAL_ERROR`` if ``INCLUDE_DIRECTORIES`` contains a
relative path.
This policy was introduced in CMake version 2.8.12. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0022.rst b/Help/policy/CMP0022.rst
index 579d09ac0..be60e375a 100644
--- a/Help/policy/CMP0022.rst
+++ b/Help/policy/CMP0022.rst
@@ -1,39 +1,39 @@
CMP0022
-------
-INTERFACE_LINK_LIBRARIES defines the link interface.
+:prop_tgt:`INTERFACE_LINK_LIBRARIES` defines the link interface.
CMake 2.8.11 constructed the 'link interface' of a target from
properties matching ``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?``.
The modern way to specify config-sensitive content is to use generator
expressions and the ``IMPORTED_`` prefix makes uniform processing of the
link interface with generator expressions impossible. The
-INTERFACE_LINK_LIBRARIES target property was introduced as a
+:prop_tgt:`INTERFACE_LINK_LIBRARIES` target property was introduced as a
replacement in CMake 2.8.12. This new property is named consistently
-with the INTERFACE_COMPILE_DEFINITIONS, INTERFACE_INCLUDE_DIRECTORIES
-and INTERFACE_COMPILE_OPTIONS properties. For in-build targets, CMake
+with the ``INTERFACE_COMPILE_DEFINITIONS``, ``INTERFACE_INCLUDE_DIRECTORIES``
+and ``INTERFACE_COMPILE_OPTIONS`` properties. For in-build targets, CMake
will use the INTERFACE_LINK_LIBRARIES property as the source of the
-link interface only if policy CMP0022 is NEW. When exporting a target
-which has this policy set to NEW, only the INTERFACE_LINK_LIBRARIES
-property will be processed and generated for the IMPORTED target by
-default. A new option to the install(EXPORT) and export commands
+link interface only if policy ``CMP0022`` is ``NEW``. When exporting a target
+which has this policy set to ``NEW``, only the :prop_tgt:`INTERFACE_LINK_LIBRARIES`
+property will be processed and generated for the ``IMPORTED`` target by
+default. A new option to the :command:`install(EXPORT)` and export commands
allows export of the old-style properties for compatibility with
downstream users of CMake versions older than 2.8.12. The
-target_link_libraries command will no longer populate the properties
-matching LINK_INTERFACE_LIBRARIES(_<CONFIG>)? if this policy is NEW.
+:command:`target_link_libraries` command will no longer populate the properties
+matching ``LINK_INTERFACE_LIBRARIES(_<CONFIG>)?`` if this policy is ``NEW``.
Warning-free future-compatible code which works with CMake 2.8.7 onwards
can be written by using the ``LINK_PRIVATE`` and ``LINK_PUBLIC`` keywords
of :command:`target_link_libraries`.
-The OLD behavior for this policy is to ignore the
-INTERFACE_LINK_LIBRARIES property for in-build targets. The NEW
-behavior for this policy is to use the INTERFACE_LINK_LIBRARIES
+The ``OLD`` behavior for this policy is to ignore the
+:prop_tgt:`INTERFACE_LINK_LIBRARIES` property for in-build targets.
+The ``NEW`` behavior for this policy is to use the ``INTERFACE_LINK_LIBRARIES``
property for in-build targets, and ignore the old properties matching
``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?``.
This policy was introduced in CMake version 2.8.12. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0023.rst b/Help/policy/CMP0023.rst
index 76a4900b6..3c72c8195 100644
--- a/Help/policy/CMP0023.rst
+++ b/Help/policy/CMP0023.rst
@@ -1,15 +1,15 @@
CMP0023
-------
-Plain and keyword target_link_libraries signatures cannot be mixed.
+Plain and keyword :command:`target_link_libraries` signatures cannot be mixed.
-CMake 2.8.12 introduced the target_link_libraries signature using the
-PUBLIC, PRIVATE, and INTERFACE keywords to generalize the LINK_PUBLIC
-and LINK_PRIVATE keywords introduced in CMake 2.8.7. Use of
-signatures with any of these keywords sets the link interface of a
+CMake 2.8.12 introduced the :command:`target_link_libraries` signature using
+the ``PUBLIC``, ``PRIVATE``, and ``INTERFACE`` keywords to generalize the
+``LINK_PUBLIC`` and ``LINK_PRIVATE`` keywords introduced in CMake 2.8.7.
+Use of signatures with any of these keywords sets the link interface of a
target explicitly, even if empty. This produces confusing behavior
when used in combination with the historical behavior of the plain
-target_link_libraries signature. For example, consider the code:
+:command:`target_link_libraries` signature. For example, consider the code:
::
@@ -20,16 +20,16 @@ After the first line the link interface has not been set explicitly so
CMake would use the link implementation, A, as the link interface.
However, the second line sets the link interface to empty. In order
to avoid this subtle behavior CMake now prefers to disallow mixing the
-plain and keyword signatures of target_link_libraries for a single
+plain and keyword signatures of :command:`target_link_libraries` for a single
target.
-The OLD behavior for this policy is to allow keyword and plain
-target_link_libraries signatures to be mixed. The NEW behavior for
+The ``OLD`` behavior for this policy is to allow keyword and plain
+:command:`target_link_libraries` signatures to be mixed. The ``NEW`` behavior for
this policy is to not to allow mixing of the keyword and plain
signatures.
This policy was introduced in CMake version 2.8.12. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0024.rst b/Help/policy/CMP0024.rst
index 272a56c8d..6e24b0454 100644
--- a/Help/policy/CMP0024.rst
+++ b/Help/policy/CMP0024.rst
@@ -3,22 +3,23 @@ CMP0024
Disallow include export result.
-CMake 2.8.12 and lower allowed use of the include() command with the
-result of the export() command. This relies on the assumption that
-the export() command has an immediate effect at configure-time during
+CMake 2.8.12 and lower allowed use of the :command:`include` command with the
+result of the :command:`export` command. This relies on the assumption that
+the :command:`export` command has an immediate effect at configure-time during
a cmake run. Certain properties of targets are not fully determined
until later at generate-time, such as the link language and complete
list of link libraries. Future refactoring will change the effect of
-the export() command to be executed at generate-time. Use ALIAS
+the :command:`export` command to be executed at generate-time. Use ``ALIAS``
targets instead in cases where the goal is to refer to targets by
another name.
-The OLD behavior for this policy is to allow including the result of
-an export() command. The NEW behavior for this policy is not to
-allow including the result of an export() command.
+The ``OLD`` behavior for this policy is to allow including the result of
+an :command:`export` command. The ``NEW`` behavior for this policy is not to
+allow including the result of an :command:`export` command.
This policy was introduced in CMake version 3.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0025.rst b/Help/policy/CMP0025.rst
index 62dd50985..ba5e1e948 100644
--- a/Help/policy/CMP0025.rst
+++ b/Help/policy/CMP0025.rst
@@ -15,13 +15,13 @@ language ``<LANG>`` is enabled by the :command:`project` or
:command:`enable_language` command. The policy must be set prior
to the invocation of either command.
-The OLD behavior for this policy is to use compiler id ``Clang``. The
-NEW behavior for this policy is to use compiler id ``AppleClang``.
+The ``OLD`` behavior for this policy is to use compiler id ``Clang``. The
+``NEW`` behavior for this policy is to use compiler id ``AppleClang``.
This policy was introduced in CMake version 3.0. Use the
-:command:`cmake_policy` command to set this policy to OLD or NEW explicitly.
-Unlike most policies, CMake version |release| does *not* warn
-by default when this policy is not set and simply uses OLD behavior.
+:command:`cmake_policy` command to set this policy to ``OLD`` or ``NEW``
+explicitly. Unlike most policies, CMake version |release| does *not* warn
+by default when this policy is not set and simply uses ``OLD`` behavior.
See documentation of the
:variable:`CMAKE_POLICY_WARNING_CMP0025 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
variable to control the warning.
diff --git a/Help/policy/CMP0026.rst b/Help/policy/CMP0026.rst
index 3fe1374c8..3401d4a9a 100644
--- a/Help/policy/CMP0026.rst
+++ b/Help/policy/CMP0026.rst
@@ -3,26 +3,27 @@ CMP0026
Disallow use of the LOCATION property for build targets.
-CMake 2.8.12 and lower allowed reading the LOCATION target
+CMake 2.8.12 and lower allowed reading the :prop_tgt:`LOCATION` target
property (and configuration-specific variants) to
determine the eventual location of build targets. This relies on the
assumption that all necessary information is available at
configure-time to determine the final location and filename of the
target. However, this property is not fully determined until later at
-generate-time. At generate time, the $<TARGET_FILE> generator
-expression can be used to determine the eventual LOCATION of a target
+generate-time. At generate time, the ``$<TARGET_FILE>`` generator
+expression can be used to determine the eventual :prop_tgt:`LOCATION` of a target
output.
-Code which reads the LOCATION target property can be ported to use the
-$<TARGET_FILE> generator expression together with the file(GENERATE)
-subcommand to generate a file containing the target location.
+Code which reads the :prop_tgt:`LOCATION` target property can be ported to
+use the ``$<TARGET_FILE>`` generator expression together with the
+:command:`file(GENERATE)` subcommand to generate a file containing
+the target location.
-The OLD behavior for this policy is to allow reading the LOCATION
-properties from build-targets. The NEW behavior for this policy is to
-not to allow reading the LOCATION properties from build-targets.
+The ``OLD`` behavior for this policy is to allow reading the :prop_tgt:`LOCATION`
+properties from build-targets. The ``NEW`` behavior for this policy is to
+not to allow reading the :prop_tgt:`LOCATION` properties from build-targets.
This policy was introduced in CMake version 3.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0027.rst b/Help/policy/CMP0027.rst
index 28913cee4..bf7b6a978 100644
--- a/Help/policy/CMP0027.rst
+++ b/Help/policy/CMP0027.rst
@@ -4,24 +4,24 @@ CMP0027
Conditionally linked imported targets with missing include directories.
CMake 2.8.11 introduced introduced the concept of
-INTERFACE_INCLUDE_DIRECTORIES, and a check at cmake time that the
-entries in the INTERFACE_INCLUDE_DIRECTORIES of an IMPORTED target
-actually exist. CMake 2.8.11 also introduced generator expression
-support in the target_link_libraries command. However, if an imported
-target is linked as a result of a generator expression evaluation, the
-entries in the INTERFACE_INCLUDE_DIRECTORIES of that target were not
+:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES`, and a check at cmake time that the
+entries in the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` of an ``IMPORTED``
+target actually exist. CMake 2.8.11 also introduced generator expression
+support in the :command:`target_link_libraries` command. However, if an
+imported target is linked as a result of a generator expression evaluation, the
+entries in the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` of that target were not
checked for existence as they should be.
-The OLD behavior of this policy is to report a warning if an entry in
-the INTERFACE_INCLUDE_DIRECTORIES of a generator-expression
-conditionally linked IMPORTED target does not exist.
+The ``OLD`` behavior of this policy is to report a warning if an entry in
+the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` of a generator-expression
+conditionally linked ``IMPORTED`` target does not exist.
-The NEW behavior of this policy is to report an error if an entry in
-the INTERFACE_INCLUDE_DIRECTORIES of a generator-expression
-conditionally linked IMPORTED target does not exist.
+The ``NEW`` behavior of this policy is to report an error if an entry in
+the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` of a generator-expression
+conditionally linked ``IMPORTED`` target does not exist.
This policy was introduced in CMake version 3.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0028.rst b/Help/policy/CMP0028.rst
index be57125d4..ab3822993 100644
--- a/Help/policy/CMP0028.rst
+++ b/Help/policy/CMP0028.rst
@@ -1,25 +1,25 @@
CMP0028
-------
-Double colon in target name means ALIAS or IMPORTED target.
+Double colon in target name means ``ALIAS`` or ``IMPORTED`` target.
CMake 2.8.12 and lower allowed the use of targets and files with double
-colons in target_link_libraries, with some buildsystem generators.
+colons in :command:`target_link_libraries`, with some buildsystem generators.
-The use of double-colons is a common pattern used to namespace IMPORTED
-targets and ALIAS targets. When computing the link dependencies of a target,
-the name of each dependency could either be a target, or a file on disk.
-Previously, if a target was not found with a matching name, the name was
-considered to refer to a file on disk. This can lead to confusing error
+The use of double-colons is a common pattern used to namespace ``IMPORTED``
+targets and ``ALIAS`` targets. When computing the link dependencies of
+a target, the name of each dependency could either be a target, or a file
+on disk. Previously, if a target was not found with a matching name, the name
+was considered to refer to a file on disk. This can lead to confusing error
messages if there is a typo in what should be a target name.
-The OLD behavior for this policy is to search for targets, then files on disk,
-even if the search term contains double-colons. The NEW behavior for this
-policy is to issue a FATAL_ERROR if a link dependency contains
-double-colons but is not an IMPORTED target or an ALIAS target.
+The ``OLD`` behavior for this policy is to search for targets, then files on
+disk, even if the search term contains double-colons. The ``NEW`` behavior
+for this policy is to issue a ``FATAL_ERROR`` if a link dependency contains
+double-colons but is not an ``IMPORTED`` target or an ``ALIAS`` target.
This policy was introduced in CMake version 3.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0037.rst b/Help/policy/CMP0037.rst
index 9f8457c62..9895fb0b4 100644
--- a/Help/policy/CMP0037.rst
+++ b/Help/policy/CMP0037.rst
@@ -10,19 +10,25 @@ as :manual:`cmake-generator-expressions(7)` and some
diagnostics expect target names to match a restricted pattern.
Target names may contain upper and lower case letters, numbers, the underscore
-character (_), dot(.), plus(+) and minus(-). As a special case, ALIAS
-targets and IMPORTED targets may contain two consequtive colons.
+character (``_``), dot(``.``), plus(``+``) and minus(``-``).
+As a special case, ``ALIAS`` and ``IMPORTED`` targets may contain
+two consecutive colons.
Target names reserved by one or more CMake generators are not allowed.
-Among others these include "all", "help" and "test".
+Among others these include ``all``, ``clean``, ``help``, and ``install``.
-The OLD behavior for this policy is to allow creating targets with
+Target names associated with optional features, such as ``test`` and
+``package``, may also be reserved. CMake 3.10 and below always reserve them.
+CMake 3.11 and above reserve them only when the corresponding feature is
+enabled (e.g. by including the :module:`CTest` or :module:`CPack` modules).
+
+The ``OLD`` behavior for this policy is to allow creating targets with
reserved names or which do not match the validity pattern.
-The NEW behavior for this policy is to report an error
+The ``NEW`` behavior for this policy is to report an error
if an add_* command is used with an invalid target name.
This policy was introduced in CMake version 3.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0038.rst b/Help/policy/CMP0038.rst
index a306d90a9..7fb2209fa 100644
--- a/Help/policy/CMP0038.rst
+++ b/Help/policy/CMP0038.rst
@@ -7,12 +7,12 @@ CMake 2.8.12 and lower allowed a build target to link to itself directly with
a :command:`target_link_libraries` call. This is an indicator of a bug in
user code.
-The OLD behavior for this policy is to ignore targets which list themselves
-in their own link implementation. The NEW behavior for this policy is to
+The ``OLD`` behavior for this policy is to ignore targets which list themselves
+in their own link implementation. The ``NEW`` behavior for this policy is to
report an error if a target attempts to link to itself.
This policy was introduced in CMake version 3.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0039.rst b/Help/policy/CMP0039.rst
index 97d78ae2a..4b14e21ae 100644
--- a/Help/policy/CMP0039.rst
+++ b/Help/policy/CMP0039.rst
@@ -7,13 +7,13 @@ CMake 2.8.12 and lower allowed using utility targets in the left hand side
position of the :command:`target_link_libraries` command. This is an indicator
of a bug in user code.
-The OLD behavior for this policy is to ignore attempts to set the link
-libraries of utility targets. The NEW behavior for this policy is to
+The ``OLD`` behavior for this policy is to ignore attempts to set the link
+libraries of utility targets. The ``NEW`` behavior for this policy is to
report an error if an attempt is made to set the link libraries of a
utility target.
This policy was introduced in CMake version 3.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0040.rst b/Help/policy/CMP0040.rst
index d46baf647..0afe5895d 100644
--- a/Help/policy/CMP0040.rst
+++ b/Help/policy/CMP0040.rst
@@ -2,7 +2,7 @@ CMP0040
-------
The target in the ``TARGET`` signature of :command:`add_custom_command`
-must exist and must be defined in current directory.
+must exist and must be defined in the current directory.
CMake 2.8.12 and lower silently ignored a custom command created with
the ``TARGET`` signature of :command:`add_custom_command`
diff --git a/Help/policy/CMP0041.rst b/Help/policy/CMP0041.rst
index f027d5de9..3b4df3601 100644
--- a/Help/policy/CMP0041.rst
+++ b/Help/policy/CMP0041.rst
@@ -15,13 +15,13 @@ As an additional diagnostic, the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` gener
on an :prop_tgt:`IMPORTED` target for the install location should not contain
paths in the source directory or the build directory.
-The OLD behavior for this policy is to ignore relative path entries if they
-contain a generator expression. The NEW behavior for this policy is to report
+The ``OLD`` behavior for this policy is to ignore relative path entries if they
+contain a generator expression. The ``NEW`` behavior for this policy is to report
an error if a generator expression appears in another location and the path is
relative.
This policy was introduced in CMake version 3.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0042.rst b/Help/policy/CMP0042.rst
index 31314b2cd..087756450 100644
--- a/Help/policy/CMP0042.rst
+++ b/Help/policy/CMP0042.rst
@@ -15,7 +15,7 @@ the :prop_tgt:`INSTALL_NAME_DIR` and :variable:`CMAKE_INSTALL_NAME_DIR`
variables.
This policy was introduced in CMake version 3.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0043.rst b/Help/policy/CMP0043.rst
index 9e427c377..05210ac6e 100644
--- a/Help/policy/CMP0043.rst
+++ b/Help/policy/CMP0043.rst
@@ -35,13 +35,13 @@ or via :command:`target_compile_definitions`:
COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DIR_DEBUG_MODE>
)
-The OLD behavior for this policy is to consume the content of the suffixed
+The ``OLD`` behavior for this policy is to consume the content of the suffixed
:prop_tgt:`COMPILE_DEFINITIONS_<CONFIG>` target property when generating the
-compilation command. The NEW behavior for this policy is to ignore the content
+compilation command. The ``NEW`` behavior for this policy is to ignore the content
of the :prop_tgt:`COMPILE_DEFINITIONS_<CONFIG>` target property .
This policy was introduced in CMake version 3.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0044.rst b/Help/policy/CMP0044.rst
index 02afa9f1a..6a4d040b1 100644
--- a/Help/policy/CMP0044.rst
+++ b/Help/policy/CMP0044.rst
@@ -9,13 +9,13 @@ comparison of the :variable:`CMAKE_<LANG>_COMPILER_ID` with a test value. The
possible valid values are lowercase, but the comparison with the test value
was performed case-insensitively.
-The OLD behavior for this policy is to perform a case-insensitive comparison
-with the value in the ``<LANG>_COMPILER_ID`` expression. The NEW behavior
+The ``OLD`` behavior for this policy is to perform a case-insensitive comparison
+with the value in the ``<LANG>_COMPILER_ID`` expression. The ``NEW`` behavior
for this policy is to perform a case-sensitive comparison with the value in
the ``<LANG>_COMPILER_ID`` expression.
This policy was introduced in CMake version 3.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0045.rst b/Help/policy/CMP0045.rst
index c7e1a90f6..80e217b18 100644
--- a/Help/policy/CMP0045.rst
+++ b/Help/policy/CMP0045.rst
@@ -7,13 +7,13 @@ In CMake 2.8.12 and lower, the :command:`get_target_property` command accepted
a non-existent target argument without issuing any error or warning. The
result variable is set to a ``-NOTFOUND`` value.
-The OLD behavior for this policy is to issue no warning and set the result
-variable to a ``-NOTFOUND`` value. The NEW behavior
+The ``OLD`` behavior for this policy is to issue no warning and set the result
+variable to a ``-NOTFOUND`` value. The ``NEW`` behavior
for this policy is to issue a ``FATAL_ERROR`` if the command is called with a
non-existent target.
This policy was introduced in CMake version 3.0. CMake version
-|release| warns when the policy is not set and uses OLD behavior. Use
-the cmake_policy command to set it to OLD or NEW explicitly.
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0046.rst b/Help/policy/CMP0046.rst
index 576d1b1cc..bf785842c 100644
--- a/Help/policy/CMP0046.rst
+++ b/Help/policy/CMP0046.rst
@@ -6,14 +6,14 @@ Error on non-existent dependency in add_dependencies.
CMake 2.8.12 and lower silently ignored non-existent dependencies
listed in the :command:`add_dependencies` command.
-The OLD behavior for this policy is to silently ignore non-existent
-dependencies. The NEW behavior for this policy is to report an error
+The ``OLD`` behavior for this policy is to silently ignore non-existent
+dependencies. The ``NEW`` behavior for this policy is to report an error
if non-existent dependencies are listed in the :command:`add_dependencies`
command.
This policy was introduced in CMake version 3.0.
CMake version |release| warns when the policy is not set and uses
-OLD behavior. Use the cmake_policy command to set it to OLD or
-NEW explicitly.
+``OLD`` behavior. Use the :command:`cmake_policy` command to set it
+to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0047.rst b/Help/policy/CMP0047.rst
index 882dd7828..9588edd7a 100644
--- a/Help/policy/CMP0047.rst
+++ b/Help/policy/CMP0047.rst
@@ -15,14 +15,14 @@ language ``<LANG>`` is enabled by the :command:`project` or
:command:`enable_language` command. The policy must be set prior
to the invocation of either command.
-The OLD behavior for this policy is to use the ``GNU`` compiler id
-for the qcc and QCC compiler drivers. The NEW behavior for this policy
+The ``OLD`` behavior for this policy is to use the ``GNU`` compiler id
+for the qcc and QCC compiler drivers. The ``NEW`` behavior for this policy
is to use the ``QCC`` compiler id for those drivers.
This policy was introduced in CMake version 3.0. Use the
-:command:`cmake_policy` command to set this policy to OLD or NEW explicitly.
-Unlike most policies, CMake version |release| does *not* warn
-by default when this policy is not set and simply uses OLD behavior.
+:command:`cmake_policy` command to set this policy to ``OLD`` or ``NEW``
+explicitly. Unlike most policies, CMake version |release| does *not* warn
+by default when this policy is not set and simply uses ``OLD`` behavior.
See documentation of the
:variable:`CMAKE_POLICY_WARNING_CMP0047 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
variable to control the warning.
diff --git a/Help/policy/CMP0048.rst b/Help/policy/CMP0048.rst
index 0e7e60681..e63ec01a2 100644
--- a/Help/policy/CMP0048.rst
+++ b/Help/policy/CMP0048.rst
@@ -1,24 +1,24 @@
CMP0048
-------
-The :command:`project` command manages VERSION variables.
+The :command:`project` command manages ``VERSION`` variables.
CMake version 3.0 introduced the ``VERSION`` option of the :command:`project`
command to specify a project version as well as the name. In order to keep
:variable:`PROJECT_VERSION` and related variables consistent with variable
-:variable:`PROJECT_NAME` it is necessary to set the VERSION variables
+:variable:`PROJECT_NAME` it is necessary to set the ``VERSION`` variables
to the empty string when no ``VERSION`` is given to :command:`project`.
-However, this can change behavior for existing projects that set VERSION
+However, this can change behavior for existing projects that set ``VERSION``
variables themselves since :command:`project` may now clear them.
This policy controls the behavior for compatibility with such projects.
-The OLD behavior for this policy is to leave VERSION variables untouched.
-The NEW behavior for this policy is to set VERSION as documented by the
+The ``OLD`` behavior for this policy is to leave ``VERSION`` variables untouched.
+The ``NEW`` behavior for this policy is to set ``VERSION`` as documented by the
:command:`project` command.
This policy was introduced in CMake version 3.0.
CMake version |release| warns when the policy is not set and uses
-OLD behavior. Use the cmake_policy command to set it to OLD or
-NEW explicitly.
+``OLD`` behavior. Use the :command:`cmake_policy` command to set
+it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0049.rst b/Help/policy/CMP0049.rst
index a3ce4b1fa..49b20be17 100644
--- a/Help/policy/CMP0049.rst
+++ b/Help/policy/CMP0049.rst
@@ -3,23 +3,23 @@ CMP0049
Do not expand variables in target source entries.
-CMake 2.8.12 and lower performed and extra layer of variable expansion
-when evaluating source file names:
-
-.. code-block:: cmake
+CMake 2.8.12 and lower performed an extra layer of variable expansion
+when evaluating source file names::
set(a_source foo.c)
add_executable(foo \${a_source})
+.. note: no cmake highlighting since this syntax is deprecated
+
This was undocumented behavior.
-The OLD behavior for this policy is to expand such variables when processing
-the target sources. The NEW behavior for this policy is to issue an error
+The ``OLD`` behavior for this policy is to expand such variables when processing
+the target sources. The ``NEW`` behavior for this policy is to issue an error
if such variables need to be expanded.
This policy was introduced in CMake version 3.0.
CMake version |release| warns when the policy is not set and uses
-OLD behavior. Use the cmake_policy command to set it to OLD or
-NEW explicitly.
+``OLD`` behavior. Use the :command:`cmake_policy` command to set
+it to ``OLD`` or ``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0050.rst b/Help/policy/CMP0050.rst
index 39e40b698..27e7b1d50 100644
--- a/Help/policy/CMP0050.rst
+++ b/Help/policy/CMP0050.rst
@@ -8,13 +8,13 @@ which specified an input to a command. This was undocumented behavior.
Modern use of CMake associates custom commands with their output, rather
than their input.
-The OLD behavior for this policy is to allow the use of
-:command:`add_custom_command` SOURCE signatures. The NEW behavior for this
+The ``OLD`` behavior for this policy is to allow the use of
+:command:`add_custom_command` SOURCE signatures. The ``NEW`` behavior for this
policy is to issue an error if such a signature is used.
This policy was introduced in CMake version 3.0.
CMake version |release| warns when the policy is not set and uses
-OLD behavior. Use the cmake_policy command to set it to OLD or
-NEW explicitly.
+``OLD`` behavior. Use the :command:`cmake_policy` command to set it to ``OLD`` or
+``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0052.rst b/Help/policy/CMP0052.rst
index 0ea5ace77..ee2e6e8de 100644
--- a/Help/policy/CMP0052.rst
+++ b/Help/policy/CMP0052.rst
@@ -1,7 +1,8 @@
CMP0052
-------
-Reject source and build dirs in installed INTERFACE_INCLUDE_DIRECTORIES.
+Reject source and build dirs in installed
+:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES`.
CMake 3.0 and lower allowed subdirectories of the source directory or build
directory to be in the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` of
@@ -13,9 +14,9 @@ broken if either are removed after installation.
See :ref:`Include Directories and Usage Requirements` for more on
specifying include directories for targets.
-The OLD behavior for this policy is to export the content of the
+The ``OLD`` behavior for this policy is to export the content of the
:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` with the source or binary
-directory. The NEW behavior for this
+directory. The ``NEW`` behavior for this
policy is to issue an error if such a directory is used.
This policy was introduced in CMake version 3.1.
diff --git a/Help/policy/CMP0053.rst b/Help/policy/CMP0053.rst
index 2620a60e0..032b3e5c6 100644
--- a/Help/policy/CMP0053.rst
+++ b/Help/policy/CMP0053.rst
@@ -16,6 +16,10 @@ cleaned up to simplify the behavior. Specifically:
* Literal ``${VAR}`` reference syntax may contain only
alphanumeric characters (``A-Z``, ``a-z``, ``0-9``) and
the characters ``_``, ``.``, ``/``, ``-``, and ``+``.
+ Note that ``$`` is technically allowed in the ``NEW`` behavior, but is
+ invalid for ``OLD`` behavior. This is due to an oversight during the
+ implementation of :policy:`CMP0053` and its use as a literal variable
+ reference is discouraged for this reason.
Variables with other characters in their name may still
be referenced indirectly, e.g.
diff --git a/Help/policy/CMP0055.rst b/Help/policy/CMP0055.rst
index b3df758fe..bc5ad086b 100644
--- a/Help/policy/CMP0055.rst
+++ b/Help/policy/CMP0055.rst
@@ -7,13 +7,13 @@ CMake 3.1 and lower allowed calls to the :command:`break` command
outside of a loop context and also ignored any given arguments.
This was undefined behavior.
-The OLD behavior for this policy is to allow :command:`break` to be placed
-outside of loop contexts and ignores any arguments. The NEW behavior for this
+The ``OLD`` behavior for this policy is to allow :command:`break` to be placed
+outside of loop contexts and ignores any arguments. The ``NEW`` behavior for this
policy is to issue an error if a misplaced break or any arguments are found.
This policy was introduced in CMake version 3.2.
CMake version |release| warns when the policy is not set and uses
-OLD behavior. Use the cmake_policy command to set it to OLD or
-NEW explicitly.
+``OLD`` behavior. Use the :command:`cmake_policy` command to set it to ``OLD`` or
+``NEW`` explicitly.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0056.rst b/Help/policy/CMP0056.rst
index 3ba89d576..834da844f 100644
--- a/Help/policy/CMP0056.rst
+++ b/Help/policy/CMP0056.rst
@@ -14,9 +14,9 @@ the generated project. CMake 3.2 and above prefer to set it so that
linker flags are honored as well as compiler flags. This policy
provides compatibility with the pre-3.2 behavior.
-The OLD behavior for this policy is to not set the value of the
+The ``OLD`` behavior for this policy is to not set the value of the
:variable:`CMAKE_EXE_LINKER_FLAGS` variable in the generated test
-project. The NEW behavior for this policy is to set the value of
+project. The ``NEW`` behavior for this policy is to set the value of
the :variable:`CMAKE_EXE_LINKER_FLAGS` variable in the test project
to the same as it is in the calling project.
@@ -27,7 +27,7 @@ variable in the cache.
This policy was introduced in CMake version 3.2. Unlike most policies,
CMake version |release| does *not* warn by default when this policy
-is not set and simply uses OLD behavior. See documentation of the
+is not set and simply uses ``OLD`` behavior. See documentation of the
:variable:`CMAKE_POLICY_WARNING_CMP0056 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
variable to control the warning.
diff --git a/Help/policy/CMP0060.rst b/Help/policy/CMP0060.rst
index 8611affac..98ac2cf69 100644
--- a/Help/policy/CMP0060.rst
+++ b/Help/policy/CMP0060.rst
@@ -51,14 +51,14 @@ and link libraries by full path even when they are in implicit link
directories. Policy ``CMP0060`` provides compatibility for existing
projects.
-The OLD behavior for this policy is to ask the linker to search for
+The ``OLD`` behavior for this policy is to ask the linker to search for
libraries whose full paths are known to be in implicit link directories.
-The NEW behavior for this policy is to link libraries by full path even
+The ``NEW`` behavior for this policy is to link libraries by full path even
if they are in implicit link directories.
This policy was introduced in CMake version 3.3. Unlike most policies,
CMake version |release| does *not* warn by default when this policy
-is not set and simply uses OLD behavior. See documentation of the
+is not set and simply uses ``OLD`` behavior. See documentation of the
:variable:`CMAKE_POLICY_WARNING_CMP0060 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
variable to control the warning.
diff --git a/Help/policy/CMP0061.rst b/Help/policy/CMP0061.rst
index cb2ac2840..57e4161d0 100644
--- a/Help/policy/CMP0061.rst
+++ b/Help/policy/CMP0061.rst
@@ -21,6 +21,6 @@ add ``-i``.
This policy was introduced in CMake version 3.3. Unlike most policies,
CMake version |release| does *not* warn when this policy is not set and
-simply uses OLD behavior.
+simply uses ``OLD`` behavior.
.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0062.rst b/Help/policy/CMP0062.rst
index 9047fffbe..0db7aafd0 100644
--- a/Help/policy/CMP0062.rst
+++ b/Help/policy/CMP0062.rst
@@ -1,7 +1,7 @@
CMP0062
-------
-Disallow install() of export() result.
+Disallow :command:`install` of :command:`export` result.
The :command:`export()` command generates a file containing
:ref:`Imported Targets`, which is suitable for use from the build
diff --git a/Help/policy/CMP0065.rst b/Help/policy/CMP0065.rst
index 2ed775dee..b820aad51 100644
--- a/Help/policy/CMP0065.rst
+++ b/Help/policy/CMP0065.rst
@@ -20,7 +20,7 @@ property is set to ``True``.
This policy was introduced in CMake version 3.4. Unlike most policies,
CMake version |release| does *not* warn by default when this policy
-is not set and simply uses OLD behavior. See documentation of the
+is not set and simply uses ``OLD`` behavior. See documentation of the
:variable:`CMAKE_POLICY_WARNING_CMP0065 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
variable to control the warning.
diff --git a/Help/policy/CMP0066.rst b/Help/policy/CMP0066.rst
index d1dcb0ec6..e110ae127 100644
--- a/Help/policy/CMP0066.rst
+++ b/Help/policy/CMP0066.rst
@@ -20,7 +20,7 @@ variabldes like :variable:`CMAKE_<LANG>_FLAGS_DEBUG`.
This policy was introduced in CMake version 3.7. Unlike most policies,
CMake version |release| does *not* warn by default when this policy
-is not set and simply uses OLD behavior. See documentation of the
+is not set and simply uses ``OLD`` behavior. See documentation of the
:variable:`CMAKE_POLICY_WARNING_CMP0066 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
variable to control the warning.
diff --git a/Help/policy/CMP0067.rst b/Help/policy/CMP0067.rst
index e6dda8018..f802787ff 100644
--- a/Help/policy/CMP0067.rst
+++ b/Help/policy/CMP0067.rst
@@ -30,7 +30,7 @@ setting variables.
This policy was introduced in CMake version 3.8. Unlike most policies,
CMake version |release| does *not* warn by default when this policy
-is not set and simply uses OLD behavior. See documentation of the
+is not set and simply uses ``OLD`` behavior. See documentation of the
:variable:`CMAKE_POLICY_WARNING_CMP0067 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
variable to control the warning.
diff --git a/Help/policy/CMP0070.rst b/Help/policy/CMP0070.rst
new file mode 100644
index 000000000..0fb361779
--- /dev/null
+++ b/Help/policy/CMP0070.rst
@@ -0,0 +1,25 @@
+CMP0070
+-------
+
+Define :command:`file(GENERATE)` behavior for relative paths.
+
+CMake 3.10 and newer define that relative paths given to ``INPUT`` and
+``OUTPUT`` arguments of ``file(GENERATE)`` are interpreted relative to the
+current source and binary directories, respectively. CMake 3.9 and lower did
+not define any behavior for relative paths but did not diagnose them either
+and accidentally treated them relative to the process working directory.
+Policy ``CMP0070`` provides compatibility with projects that used the old
+undefined behavior.
+
+This policy affects behavior of relative paths given to ``file(GENERATE)``.
+The ``OLD`` behavior for this policy is to treat the paths relative to the
+working directory of CMake. The ``NEW`` behavior for this policy is to
+interpret relative paths with respect to the current source or binary
+directory of the caller.
+
+This policy was introduced in CMake version 3.10. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0071.rst b/Help/policy/CMP0071.rst
new file mode 100644
index 000000000..855ecf0e9
--- /dev/null
+++ b/Help/policy/CMP0071.rst
@@ -0,0 +1,42 @@
+CMP0071
+-------
+
+Let :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC` process
+:prop_sf:`GENERATED` files.
+
+Since version 3.10, CMake processes **regular** and :prop_sf:`GENERATED`
+source files in :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC`.
+In earlier CMake versions, only **regular** source files were processed.
+:prop_sf:`GENERATED` source files were ignored silently.
+
+This policy affects how source files that are :prop_sf:`GENERATED`
+get treated in :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC`.
+
+The ``OLD`` behavior for this policy is to ignore :prop_sf:`GENERATED`
+source files in :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC`.
+
+The ``NEW`` behavior for this policy is to process :prop_sf:`GENERATED`
+source files in :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC` just like regular
+source files.
+
+.. note::
+
+ To silence the ``CMP0071`` warning source files can be excluded from
+ :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC` processing by setting the
+ source file properties :prop_sf:`SKIP_AUTOMOC`, :prop_sf:`SKIP_AUTOUIC` or
+ :prop_sf:`SKIP_AUTOGEN`.
+
+Source skip example::
+
+ # ...
+ set_property(SOURCE /path/to/file1.h PROPERTY SKIP_AUTOMOC ON)
+ set_property(SOURCE /path/to/file2.h PROPERTY SKIP_AUTOUIC ON)
+ set_property(SOURCE /path/to/file3.h PROPERTY SKIP_AUTOGEN ON)
+ # ...
+
+This policy was introduced in CMake version 3.10. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0072.rst b/Help/policy/CMP0072.rst
new file mode 100644
index 000000000..3abbad790
--- /dev/null
+++ b/Help/policy/CMP0072.rst
@@ -0,0 +1,26 @@
+CMP0072
+-------
+
+:module:`FindOpenGL` prefers GLVND by default when available.
+
+The :module:`FindOpenGL` module provides an ``OpenGL::GL`` target and an
+``OPENGL_LIBRARIES`` variable for projects to use for legacy GL interfaces.
+When both a legacy GL library (e.g. ``libGL.so``) and GLVND libraries
+for OpenGL and GLX (e.g. ``libOpenGL.so`` and ``libGLX.so``) are available,
+the module must choose between them. It documents an ``OpenGL_GL_PREFERENCE``
+variable that can be used to specify an explicit preference. When no such
+preference is set, the module must choose a default preference.
+
+CMake 3.11 and above prefer to choose GLVND libraries. This policy provides
+compatibility with projects that expect the legacy GL library to be used.
+
+The ``OLD`` behavior for this policy is to set ``OpenGL_GL_PREFERENCE`` to
+``LEGACY``. The ``NEW`` behavior for this policy is to set
+``OpenGL_GL_PREFERENCE`` to ``GLVND``.
+
+This policy was introduced in CMake version 3.11. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0073.rst b/Help/policy/CMP0073.rst
new file mode 100644
index 000000000..9bfa0e905
--- /dev/null
+++ b/Help/policy/CMP0073.rst
@@ -0,0 +1,25 @@
+CMP0073
+-------
+
+Do not produce legacy ``_LIB_DEPENDS`` cache entries.
+
+Ancient CMake versions once used ``<tgt>_LIB_DEPENDS`` cache entries to
+propagate library link dependencies. This has long been done by other
+means, leaving the :command:`export_library_dependencies` command as the
+only user of these values. That command has long been disallowed by
+policy :policy:`CMP0033`, but the ``<tgt>_LIB_DEPENDS`` cache entries
+were left for compatibility with possible non-standard uses by projects.
+
+CMake 3.12 and above now prefer to not produce these cache entries
+at all. This policy provides compatibility with projects that have
+not been updated to avoid using them.
+
+The ``OLD`` behavior for this policy is to set ``<tgt>_LIB_DEPENDS`` cache
+entries. The ``NEW`` behavior for this policy is to not set them.
+
+This policy was introduced in CMake version 3.12. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike most policies, CMake version |release| does *not* warn
+when this policy is not set and simply uses ``OLD`` behavior.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0074.rst b/Help/policy/CMP0074.rst
new file mode 100644
index 000000000..63ebf7b43
--- /dev/null
+++ b/Help/policy/CMP0074.rst
@@ -0,0 +1,23 @@
+CMP0074
+-------
+
+:command:`find_package` uses ``<PackageName>_ROOT`` variables.
+
+In CMake 3.12 and above the :command:`find_package(<PackageName>)` command now
+searches prefixes specified by the :variable:`<PackageName>_ROOT` CMake
+variable and the :envvar:`<PackageName>_ROOT` environment variable.
+Package roots are maintained as a stack so nested calls to all ``find_*``
+commands inside find modules and config packages also search the roots as
+prefixes. This policy provides compatibility with projects that have not been
+updated to avoid using ``<PackageName>_ROOT`` variables for other purposes.
+
+The ``OLD`` behavior for this policy is to ignore ``<PackageName>_ROOT``
+variables. The ``NEW`` behavior for this policy is to use
+``<PackageName>_ROOT`` variables.
+
+This policy was introduced in CMake version 3.12. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0075.rst b/Help/policy/CMP0075.rst
new file mode 100644
index 000000000..aa5c3f76f
--- /dev/null
+++ b/Help/policy/CMP0075.rst
@@ -0,0 +1,26 @@
+CMP0075
+-------
+
+Include file check macros honor ``CMAKE_REQUIRED_LIBRARIES``.
+
+In CMake 3.12 and above, the
+
+* ``check_include_file`` macro in the :module:`CheckIncludeFile` module, the
+* ``check_include_file_cxx`` macro in the
+ :module:`CheckIncludeFileCXX` module, and the
+* ``check_include_files`` macro in the :module:`CheckIncludeFiles` module
+
+now prefer to link the check executable to the libraries listed in the
+``CMAKE_REQUIRED_LIBRARIES`` variable. This policy provides compatibility
+with projects that have not been updated to expect this behavior.
+
+The ``OLD`` behavior for this policy is to ignore ``CMAKE_REQUIRED_LIBRARIES``
+in the include file check macros. The ``NEW`` behavior of this policy is to
+honor ``CMAKE_REQUIRED_LIBRARIES`` in the include file check macros.
+
+This policy was introduced in CMake version 3.12. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0076.rst b/Help/policy/CMP0076.rst
new file mode 100644
index 000000000..dd25f80c6
--- /dev/null
+++ b/Help/policy/CMP0076.rst
@@ -0,0 +1,26 @@
+CMP0076
+-------
+
+The :command:`target_sources` command converts relative paths to absolute.
+
+In CMake 3.13 and above, the :command:`target_sources` command now converts
+relative source file paths to absolute paths in the following cases:
+
+* Source files are added to the target's :prop_tgt:`INTERFACE_SOURCES`
+ property.
+* The target's :prop_tgt:`SOURCE_DIR` property differs from
+ :variable:`CMAKE_CURRENT_SOURCE_DIR`.
+
+A path that begins with a generator expression is always left unmodified.
+
+This policy provides compatibility with projects that have not been updated
+to expect this behavior. The ``OLD`` behavior for this policy is to leave
+all relative source file paths unmodified. The ``NEW`` behavior of this
+policy is to convert relative paths to absolute according to above rules.
+
+This policy was introduced in CMake version 3.13. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0077.rst b/Help/policy/CMP0077.rst
new file mode 100644
index 000000000..44797b648
--- /dev/null
+++ b/Help/policy/CMP0077.rst
@@ -0,0 +1,52 @@
+CMP0077
+-------
+
+:command:`option` honors normal variables.
+
+The :command:`option` command is typically used to create a cache entry
+to allow users to set the option. However, there are cases in which a
+normal (non-cached) variable of the same name as the option may be
+defined by the project prior to calling the :command:`option` command.
+For example, a project that embeds another project as a subdirectory
+may want to hard-code options of the subproject to build the way it needs.
+
+For historical reasons in CMake 3.12 and below the :command:`option`
+command *removes* a normal (non-cached) variable of the same name when:
+
+* a cache entry of the specified name does not exist at all, or
+* a cache entry of the specified name exists but has not been given
+ a type (e.g. via ``-D<name>=ON`` on the command line).
+
+In both of these cases (typically on the first run in a new build tree),
+the :command:`option` command gives the cache entry type ``BOOL`` and
+removes any normal (non-cached) variable of the same name. In the
+remaining case that the cache entry of the specified name already
+exists and has a type (typically on later runs in a build tree), the
+:command:`option` command changes nothing and any normal variable of
+the same name remains set.
+
+In CMake 3.13 and above the :command:`option` command prefers to
+do nothing when a normal variable of the given name already exists.
+It does not create or update a cache entry or remove the normal variable.
+The new behavior is consistent between the first and later runs in a
+build tree. This policy provides compatibility with projects that have
+not been updated to expect the new behavior.
+
+When the :command:`option` command sees a normal variable of the given
+name:
+
+* The ``OLD`` behavior for this policy is to proceed even when a normal
+ variable of the same name exists. If the cache entry does not already
+ exist and have a type then it is created and/or given a type and the
+ normal variable is removed.
+
+* The ``NEW`` behavior for this policy is to do nothing when a normal
+ variable of the same name exists. The normal variable is not removed.
+ The cache entry is not created or updated and is ignored if it exists.
+
+This policy was introduced in CMake version 3.13. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0078.rst b/Help/policy/CMP0078.rst
new file mode 100644
index 000000000..2e97934f4
--- /dev/null
+++ b/Help/policy/CMP0078.rst
@@ -0,0 +1,24 @@
+CMP0078
+-------
+
+:module:`UseSWIG` generates standard target names.
+
+Starting with CMake 3.13, :module:`UseSWIG` generates now standard target
+names. This policy provides compatibility with projects that expect the legacy
+behavior.
+
+The ``OLD`` behavior for this policy relies on
+``UseSWIG_TARGET_NAME_PREFERENCE`` variable that can be used to specify an
+explicit preference. The value may be one of:
+
+* ``LEGACY``: legacy strategy is applied. Variable
+ ``SWIG_MODULE_<name>_REAL_NAME`` must be used to get real target name.
+ This is the default if not specified.
+* ``STANDARD``: target name matches specified name.
+
+This policy was introduced in CMake version 3.13. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0079.rst b/Help/policy/CMP0079.rst
new file mode 100644
index 000000000..0244d6ca6
--- /dev/null
+++ b/Help/policy/CMP0079.rst
@@ -0,0 +1,40 @@
+CMP0079
+-------
+
+:command:`target_link_libraries` allows use with targets in other directories.
+
+Prior to CMake 3.13 the :command:`target_link_libraries` command did not
+accept targets not created in the calling directory as its first argument
+for calls that update the :prop_tgt:`LINK_LIBRARIES` of the target itself.
+It did accidentally accept targets from other directories on calls that
+only update the :prop_tgt:`INTERFACE_LINK_LIBRARIES`, but would simply
+add entries to the property as if the call were made in the original
+directory. Thus link interface libraries specified this way were always
+looked up by generators in the scope of the original target rather than
+in the scope that called :command:`target_link_libraries`.
+
+CMake 3.13 now allows the :command:`target_link_libraries` command to
+be called from any directory to add link dependencies and link interface
+libraries to targets created in other directories. The entries are added
+to :prop_tgt:`LINK_LIBRARIES` and :prop_tgt:`INTERFACE_LINK_LIBRARIES`
+using a special (internal) suffix to tell the generators to look up the
+names in the calling scope rather than the scope that created the target.
+
+This policy provides compatibility with projects that already use
+:command:`target_link_libraries` with the ``INTERFACE`` keyword
+on a target in another directory to add :prop_tgt:`INTERFACE_LINK_LIBRARIES`
+entries to be looked up in the target's directory. Such projects should
+be updated to be aware of the new scoping rules in that case.
+
+The ``OLD`` behavior of this policy is to disallow
+:command:`target_link_libraries` calls naming targets from another directory
+except in the previously accidentally allowed case of using the ``INTERFACE``
+keyword only. The ``NEW`` behavior of this policy is to allow all such
+calls but use the new scoping rules.
+
+This policy was introduced in CMake version 3.13. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0080.rst b/Help/policy/CMP0080.rst
new file mode 100644
index 000000000..5ce9591da
--- /dev/null
+++ b/Help/policy/CMP0080.rst
@@ -0,0 +1,25 @@
+CMP0080
+-------
+
+:module:`BundleUtilities` cannot be included at configure time.
+
+The macros provided by :module:`BundleUtilities` are intended to be invoked
+at install time rather than at configure time, because they depend on the
+listed targets already existing at the time they are invoked. If they are
+invoked at configure time, the targets haven't been built yet, and the
+commands will fail.
+
+This policy restricts the inclusion of :module:`BundleUtilities` to
+``cmake -P`` style scripts and install rules. Specifically, it looks for the
+presence of :variable:`CMAKE_GENERATOR` and throws a fatal error if it exists.
+
+The ``OLD`` behavior of this policy is to allow :module:`BundleUtilities` to
+be included at configure time. The ``NEW`` behavior of this policy is to
+disallow such inclusion.
+
+This policy was introduced in CMake version 3.13. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0081.rst b/Help/policy/CMP0081.rst
new file mode 100644
index 000000000..d3b2872c4
--- /dev/null
+++ b/Help/policy/CMP0081.rst
@@ -0,0 +1,22 @@
+CMP0081
+-------
+
+Relative paths not allowed in :prop_tgt:`LINK_DIRECTORIES` target property.
+
+CMake 3.12 and lower allowed the :prop_dir:`LINK_DIRECTORIES` directory
+property to contain relative paths. The base path for such relative
+entries is not well defined. CMake 3.13 and later will issue a
+``FATAL_ERROR`` if the :prop_tgt:`LINK_DIRECTORIES` target property
+(which is initialized by the :prop_dir:`LINK_DIRECTORIES` directory property)
+contains a relative path.
+
+The ``OLD`` behavior for this policy is not to warn about relative paths
+in the :prop_tgt:`LINK_DIRECTORIES` target property. The ``NEW`` behavior for
+this policy is to issue a ``FATAL_ERROR`` if :prop_tgt:`LINK_DIRECTORIES`
+contains a relative path.
+
+This policy was introduced in CMake version 3.13. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior. Use
+the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0082.rst b/Help/policy/CMP0082.rst
new file mode 100644
index 000000000..d887616be
--- /dev/null
+++ b/Help/policy/CMP0082.rst
@@ -0,0 +1,26 @@
+CMP0082
+-------
+
+Install rules from :command:`add_subdirectory` calls are interleaved with
+those in caller.
+
+CMake 3.13 and lower ran the install rules from :command:`add_subdirectory`
+after all other install rules, even if :command:`add_subdirectory` was called
+before the other install rules. CMake 3.14 and above prefer to interleave
+these :command:`add_subdirectory` install rules with the others so that
+they are run in the order they are declared. This policy provides
+compatibility for projects that have not been updated to expect the
+new behavior.
+
+The ``OLD`` behavior for this policy is to run the install rules from
+:command:`add_subdirectory` after the other install rules. The ``NEW``
+behavior for this policy is to run all install rules in the order they are
+declared.
+
+This policy was introduced in CMake version 3.14. Unlike most policies,
+CMake version |release| does *not* warn by default when this policy
+is not set and simply uses ``OLD`` behavior. See documentation of the
+:variable:`CMAKE_POLICY_WARNING_CMP0082 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
+variable to control the warning.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0083.rst b/Help/policy/CMP0083.rst
new file mode 100644
index 000000000..e0b09cff5
--- /dev/null
+++ b/Help/policy/CMP0083.rst
@@ -0,0 +1,69 @@
+CMP0083
+-------
+
+To control generation of Position Independent Executable (``PIE``) or not, some
+flags are required at link time.
+
+CMake 3.13 and lower did not add these link flags when
+:prop_tgt:`POSITION_INDEPENDENT_CODE` is set.
+
+The ``OLD`` behavior for this policy is to not manage ``PIE`` link flags. The
+``NEW`` behavior is to add link flags if :prop_tgt:`POSITION_INDEPENDENT_CODE`
+is set:
+
+* Set to ``TRUE``: flags to produce a position independent executable are
+ passed to the linker step. For example ``-pie`` for ``GCC``.
+* Set to ``FALSE``: flags not to produce a position independent executable are
+ passed to the linker step. For example ``-no-pie`` for ``GCC``.
+* Not set: no flags are passed to the linker step.
+
+Since a given linker may not support ``PIE`` flags in all environments in
+which it is used, it is the project's responsibility to use the
+:module:`CheckPIESupported` module to check for support to ensure that the
+:prop_tgt:`POSITION_INDEPENDENT_CODE` target property for executables will be
+honored at link time.
+
+This policy was introduced in CMake version 3.14. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike most policies, CMake version |release| does not warn when this policy is
+not set and simply uses ``OLD`` behavior.
+
+.. Note::
+
+ Android platform has a special handling of ``PIE`` so it is not required
+ to use the :module:`CheckPIESupported` module to ensure flags are passed to
+ the linker.
+
+.. include:: DEPRECATED.txt
+
+Examples
+^^^^^^^^
+
+Behave like CMake 3.13 and do not apply any ``PIE`` flags at link stage.
+
+.. code-block:: cmake
+
+ cmake_minimum_required(VERSION 3.13)
+ project(foo)
+
+ # ...
+
+ add_executable(foo ...)
+ set_property(TARGET foo PROPERTY POSITION_INDEPENDENT_CODE TRUE)
+
+Use the :module:`CheckPIESupported` module to detect whether ``PIE`` is
+supported by the current linker and environment. Apply ``PIE`` flags only
+if the linker supports them.
+
+.. code-block:: cmake
+
+ cmake_minimum_required(VERSION 3.14) # CMP0083 NEW
+ project(foo)
+
+ include(CheckPIESupported)
+ check_pie_supported()
+
+ # ...
+
+ add_executable(foo ...)
+ set_property(TARGET foo PROPERTY POSITION_INDEPENDENT_CODE TRUE)
diff --git a/Help/policy/CMP0084.rst b/Help/policy/CMP0084.rst
new file mode 100644
index 000000000..713d295f8
--- /dev/null
+++ b/Help/policy/CMP0084.rst
@@ -0,0 +1,26 @@
+CMP0084
+-------
+
+The :module:`FindQt` module does not exist for :command:`find_package`.
+
+The existence of :module:`FindQt` means that for Qt upstream to provide
+package config files that can be found by ``find_package(Qt)``, the consuming
+project has to explicitly specify ``find_package(Qt CONFIG)``. Removing this
+module gives Qt a path forward for exporting its own config files which can
+easily be found by consuming projects.
+
+This policy pretends that CMake's internal :module:`FindQt` module does not
+exist for :command:`find_package`. If a project really wants to use Qt 3 or 4,
+it can call ``find_package(Qt[34])``, ``include(FindQt)``, or add
+:module:`FindQt` to their :variable:`CMAKE_MODULE_PATH`.
+
+The ``OLD`` behavior of this policy is for :module:`FindQt` to exist for
+:command:`find_package`. The ``NEW`` behavior is to pretend that it doesn't
+exist for :command:`find_package`.
+
+This policy was introduced in CMake version 3.14. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0085.rst b/Help/policy/CMP0085.rst
new file mode 100644
index 000000000..d9ec9a207
--- /dev/null
+++ b/Help/policy/CMP0085.rst
@@ -0,0 +1,21 @@
+CMP0085
+-------
+
+``$<IN_LIST:...>`` handles empty list items.
+
+In CMake 3.13 and lower, the ``$<IN_LIST:...>`` generator expression always
+returned ``0`` if the first argument was empty, even if the list contained an
+empty item. This behavior is inconsistent with the ``IN_LIST`` behavior of
+:command:`if`, which this generator expression is meant to emulate. CMake 3.14
+and later handles this case correctly.
+
+The ``OLD`` behavior of this policy is for ``$<IN_LIST:...>`` to always return
+``0`` if the first argument is empty. The ``NEW`` behavior is to return ``1``
+if the first argument is empty and the list contains an empty item.
+
+This policy was introduced in CMake version 3.14. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0086.rst b/Help/policy/CMP0086.rst
new file mode 100644
index 000000000..4a9e8b80a
--- /dev/null
+++ b/Help/policy/CMP0086.rst
@@ -0,0 +1,20 @@
+CMP0086
+-------
+
+:module:`UseSWIG` honors ``SWIG_MODULE_NAME`` via ``-module`` flag.
+
+Starting with CMake 3.14, :module:`UseSWIG` passes option
+``-module <module_name>`` to ``SWIG`` compiler if the file property
+``SWIG_MODULE_NAME`` is specified. This policy provides compatibility with
+projects that expect the legacy behavior.
+
+The ``OLD`` behavior for this policy is to never pass ``-module`` option.
+The ``NEW`` behavior is to pass ``-module`` option to ``SWIG`` compiler if
+``SWIG_MODULE_NAME`` is specified.
+
+This policy was introduced in CMake version 3.14. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0087.rst b/Help/policy/CMP0087.rst
new file mode 100644
index 000000000..4c45b99e4
--- /dev/null
+++ b/Help/policy/CMP0087.rst
@@ -0,0 +1,29 @@
+CMP0087
+-------
+
+:command:`install(CODE)` and :command:`install(SCRIPT)` support generator
+expressions.
+
+In CMake 3.13 and earlier, :command:`install(CODE)` and
+:command:`install(SCRIPT)` did not evaluate generator expressions. CMake 3.14
+and later will evaluate generator expressions for :command:`install(CODE)` and
+:command:`install(SCRIPT)`.
+
+The ``OLD`` behavior of this policy is for :command:`install(CODE)` and
+:command:`install(SCRIPT)` to not evaluate generator expressions. The ``NEW``
+behavior is to evaluate generator expressions for :command:`install(CODE)` and
+:command:`install(SCRIPT)`.
+
+Note that it is the value of this policy setting at the end of the directory
+scope that is important, not its setting at the time of the call to
+:command:`install(CODE)` or :command:`install(SCRIPT)`. This has implications
+for calling these commands from places that have their own policy scope but not
+their own directory scope (e.g. from files brought in via :command:`include()`
+rather than :command:`add_subdirectory()`).
+
+This policy was introduced in CMake version 3.14. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0088.rst b/Help/policy/CMP0088.rst
new file mode 100644
index 000000000..82c04ef7b
--- /dev/null
+++ b/Help/policy/CMP0088.rst
@@ -0,0 +1,29 @@
+CMP0088
+-------
+
+:module:`FindBISON` runs bison in :variable:`CMAKE_CURRENT_BINARY_DIR`
+when executing.
+
+The module provides a ``BISON_TARGET`` macro which generates BISON output.
+In CMake 3.13 and below the macro would generate a custom command that runs
+``bison`` in the source directory. CMake 3.14 and later prefer to run it
+in the build directory and use :variable:`CMAKE_CURRENT_BINARY_DIR` as the
+``WORKING_DIRECTORY`` of its :command:`add_custom_command` invocation.
+This ensures that any implicitly generated file is written to the build
+tree rather than the source.
+
+This policy provides compatibility for projects that have not been updated
+to expect the new behavior.
+
+The ``OLD`` behavior for this policy is for ``BISON_TARGET`` to use
+the current source directory for the ``WORKING_DIRECTORY`` and where
+to generate implicit files. The ``NEW`` behavior of this policy is to
+use the current binary directory for the ``WORKING_DIRECTORY`` and where
+to generate implicit files.
+
+This policy was introduced in CMake version 3.14. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike most policies, CMake version |release| does *not* warn
+when this policy is not set and simply uses ``OLD`` behavior.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0089.rst b/Help/policy/CMP0089.rst
new file mode 100644
index 000000000..029de5534
--- /dev/null
+++ b/Help/policy/CMP0089.rst
@@ -0,0 +1,30 @@
+CMP0089
+-------
+
+Compiler id for IBM Clang-based XL compilers is now ``XLClang``.
+
+CMake 3.15 and above recognize that IBM's Clang-based XL compilers
+that define ``__ibmxl__`` are a new front-end distinct from ``xlc``
+with a different command line and set of capabilities.
+CMake now prefers to present this to projects by setting the
+:variable:`CMAKE_<LANG>_COMPILER_ID` variable to ``XLClang`` instead
+of ``XL``. However, existing projects may assume the compiler id for
+Clang-based XL is just ``XL`` as it was in CMake versions prior to 3.15.
+Therefore this policy determines for Clang-based XL compilers which
+compiler id to report in the :variable:`CMAKE_<LANG>_COMPILER_ID`
+variable after language ``<LANG>`` is enabled by the :command:`project`
+or :command:`enable_language` command. The policy must be set prior
+to the invocation of either command.
+
+The ``OLD`` behavior for this policy is to use compiler id ``XL``. The
+``NEW`` behavior for this policy is to use compiler id ``XLClang``.
+
+This policy was introduced in CMake version 3.15. Use the
+:command:`cmake_policy` command to set this policy to ``OLD`` or ``NEW`` explicitly.
+Unlike most policies, CMake version |release| does *not* warn
+by default when this policy is not set and simply uses ``OLD`` behavior.
+See documentation of the
+:variable:`CMAKE_POLICY_WARNING_CMP0089 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
+variable to control the warning.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0090.rst b/Help/policy/CMP0090.rst
new file mode 100644
index 000000000..720c17c2a
--- /dev/null
+++ b/Help/policy/CMP0090.rst
@@ -0,0 +1,27 @@
+CMP0090
+-------
+
+:command:`export(PACKAGE)` does not populate package registry by default.
+
+In CMake 3.14 and below the :command:`export(PACKAGE)` command populated the
+user package registry by default and users needed to set the
+:variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` to disable it, e.g. in automated
+build and packaging environments. Since the user package registry is stored
+outside the build tree, this side effect should not be enabled by default.
+Therefore CMake 3.15 and above prefer that :command:`export(PACKAGE)` does
+nothing unless an explicit :variable:`CMAKE_EXPORT_PACKAGE_REGISTRY` variable
+is set to enable it. This policy provides compatibility with projects that
+have not been updated.
+
+The ``OLD`` behavior for this policy is for :command:`export(PACKAGE)` command
+to populate the user package registry unless
+:variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` is enabled.
+The ``NEW`` behavior is for :command:`export(PACKAGE)` command to do nothing
+unless the :variable:`CMAKE_EXPORT_PACKAGE_REGISTRY` is enabled.
+
+This policy was introduced in CMake version 3.15. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike most policies, CMake version |release| does *not* warn
+when this policy is not set and simply uses ``OLD`` behavior.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0091.rst b/Help/policy/CMP0091.rst
new file mode 100644
index 000000000..1a5878a1f
--- /dev/null
+++ b/Help/policy/CMP0091.rst
@@ -0,0 +1,49 @@
+CMP0091
+-------
+
+MSVC runtime library flags are selected by an abstraction.
+
+Compilers targeting the MSVC ABI have flags to select the MSVC runtime library.
+Runtime library selection typically varies with build configuration because
+there is a separate runtime library for Debug builds.
+
+In CMake 3.14 and below, MSVC runtime library selection flags are added to
+the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` cache entries by CMake
+automatically. This allows users to edit their cache entries to adjust the
+flags. However, the presence of such default flags is problematic for
+projects that want to choose a different runtime library programmatically.
+In particular, it requires string editing of the
+:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variables with knowledge of the
+CMake builtin defaults so they can be replaced.
+
+CMake 3.15 and above prefer to leave the MSVC runtime library selection flags
+out of the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` values and instead
+offer a first-class abstraction. The :variable:`CMAKE_MSVC_RUNTIME_LIBRARY`
+variable and :prop_tgt:`MSVC_RUNTIME_LIBRARY` target property may be set to
+select the MSVC runtime library. If they are not set then CMake uses the
+default value ``MultiThreaded$<$<CONFIG:Debug>:Debug>DLL`` which is
+equivalent to the original flags.
+
+This policy provides compatibility with projects that have not been updated
+to be aware of the abstraction. The policy setting takes effect as of the
+first :command:`project` or :command:`enable_language` command that enables
+a language whose compiler targets the MSVC ABI.
+
+.. note::
+
+ Once the policy has taken effect at the top of a project, that choice
+ must be used throughout the tree. In projects that have nested projects
+ in subdirectories, be sure to convert everything together.
+
+The ``OLD`` behavior for this policy is to place MSVC runtime library
+flags in the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` cache
+entries and ignore the :variable:`CMAKE_MSVC_RUNTIME_LIBRARY` abstraction.
+The ``NEW`` behavior for this policy is to *not* place MSVC runtime
+library flags in the default cache entries and use the abstraction instead.
+
+This policy was introduced in CMake version 3.15. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike many policies, CMake version |release| does *not* warn
+when this policy is not set and simply uses ``OLD`` behavior.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0092.rst b/Help/policy/CMP0092.rst
new file mode 100644
index 000000000..8d3a288ae
--- /dev/null
+++ b/Help/policy/CMP0092.rst
@@ -0,0 +1,38 @@
+CMP0092
+-------
+
+MSVC warning flags are not in :variable:`CMAKE_<LANG>_FLAGS` by default.
+
+When using MSVC-like compilers in CMake 3.14 and below, warning flags
+like ``/W3`` are added to :variable:`CMAKE_<LANG>_FLAGS` by default.
+This is problematic for projects that want to choose a different warning
+level programmatically. In particular, it requires string editing of the
+:variable:`CMAKE_<LANG>_FLAGS` variables with knowledge of the
+CMake builtin defaults so they can be replaced.
+
+CMake 3.15 and above prefer to leave out warning flags from the value of
+:variable:`CMAKE_<LANG>_FLAGS` by default.
+
+This policy provides compatibility with projects that have not been updated
+to expect the lack of warning flags. The policy setting takes effect as of
+the first :command:`project` or :command:`enable_language` command that
+initializes :variable:`CMAKE_<LANG>_FLAGS` for a given lanuage ``<LANG>``.
+
+.. note::
+
+ Once the policy has taken effect at the top of a project for a given
+ language, that choice must be used throughout the tree for that language.
+ In projects that have nested projects in subdirectories, be sure to
+ convert everything together.
+
+The ``OLD`` behavior for this policy is to place MSVC warning flags in the
+default :variable:`CMAKE_<LANG>_FLAGS` cache entries. The ``NEW`` behavior
+for this policy is to *not* place MSVC warning flags in the default cache
+entries.
+
+This policy was introduced in CMake version 3.15. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike many policies, CMake version |release| does *not* warn
+when this policy is not set and simply uses ``OLD`` behavior.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0093.rst b/Help/policy/CMP0093.rst
new file mode 100644
index 000000000..0ffc493de
--- /dev/null
+++ b/Help/policy/CMP0093.rst
@@ -0,0 +1,24 @@
+CMP0093
+-------
+
+:module:`FindBoost` reports ``Boost_VERSION`` in ``x.y.z`` format.
+
+In CMake 3.14 and below the module would report the Boost version
+number as specified in the preprocessor definition ``BOOST_VERSION`` in
+the ``boost/version.hpp`` file. In CMake 3.15 and later it is preferred
+that the reported version number matches the ``x.y.z`` format reported
+by the CMake package shipped with Boost ``1.70.0`` and later. The macro
+value is still reported in the ``Boost_VERSION_MACRO`` variable.
+
+The ``OLD`` behavior for this policy is for :module:`FindBoost` to report
+``Boost_VERSION`` as specified in the preprocessor definition
+``BOOST_VERSION`` in ``boost/version.hpp``. The ``NEW`` behavior for this
+policy is for :module:`FindBoost` to report ``Boost_VERSION`` in
+``x.y.z`` format.
+
+This policy was introduced in CMake version 3.15. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike many policies, CMake version |release| does *not* warn
+when this policy is not set and simply uses the ``OLD`` behavior.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0094.rst b/Help/policy/CMP0094.rst
new file mode 100644
index 000000000..836f30f09
--- /dev/null
+++ b/Help/policy/CMP0094.rst
@@ -0,0 +1,22 @@
+CMP0094
+-------
+
+Modules :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython`
+use ``LOCATION`` for lookup strategy.
+
+Starting with CMake 3.15, Modules :module:`FindPython3`, :module:`FindPython2`
+and :module:`FindPython` set value ``LOCATION`` for, respectively, variables
+``Python3_FIND_STRATEGY``, ``Python2_FIND_STRATEGY`` and
+``Python_FIND_STRATEGY``. This policy provides compatibility with projects that
+expect the legacy behavior.
+
+The ``OLD`` behavior for this policy set value ``VERSION`` for variables
+``Python3_FIND_STRATEGY``, ``Python2_FIND_STRATEGY`` and
+``Python_FIND_STRATEGY``.
+
+This policy was introduced in CMake version 3.15. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike many policies, CMake version |release| does *not* warn
+when this policy is not set and simply uses the ``OLD`` behavior.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0095.rst b/Help/policy/CMP0095.rst
new file mode 100644
index 000000000..4c56a0524
--- /dev/null
+++ b/Help/policy/CMP0095.rst
@@ -0,0 +1,30 @@
+CMP0095
+-------
+
+``RPATH`` entries are properly escaped in the intermediary CMake install script.
+
+In CMake 3.15 and earlier, ``RPATH`` entries set via
+:variable:`CMAKE_INSTALL_RPATH` or via :prop_tgt:`INSTALL_RPATH` have not been
+escaped before being inserted into the ``cmake_install.cmake`` script. Dynamic
+linkers on ELF-based systems (e.g. Linux and FreeBSD) allow certain keywords in
+``RPATH`` entries, such as ``${ORIGIN}`` (More details are available in the
+``ld.so`` man pages on those systems). The syntax of these keywords can match
+CMake's variable syntax. In order to not be substituted (usually to an empty
+string) already by the intermediary ``cmake_install.cmake`` script, the user had
+to double-escape such ``RPATH`` keywords, e.g.
+``set(CMAKE_INSTALL_RPATH "\\\${ORIGIN}/../lib")``. Since the intermediary
+``cmake_install.cmake`` script is an implementation detail of CMake, CMake 3.16
+and later will make sure ``RPATH`` entries are inserted literally by escaping
+any coincidental CMake syntax.
+
+The ``OLD`` behavior of this policy is to not escape ``RPATH`` entries in the
+intermediary ``cmake_install.cmake`` script. The ``NEW`` behavior is to properly
+escape coincidental CMake syntax in ``RPATH`` entries when generating the
+intermediary ``cmake_install.cmake`` script.
+
+This policy was introduced in CMake version 3.16. CMake version |release| warns
+when the policy is not set and detected usage of CMake-like syntax and uses
+``OLD`` behavior. Use the :command:`cmake_policy` command to set it to ``OLD``
+or ``NEW`` explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0096.rst b/Help/policy/CMP0096.rst
new file mode 100644
index 000000000..8eaf0f95d
--- /dev/null
+++ b/Help/policy/CMP0096.rst
@@ -0,0 +1,25 @@
+CMP0096
+-------
+
+The :command:`project` command preserves leading zeros in version components.
+
+When a ``VERSION <major>[.<minor>[.<patch>[.<tweak>]]]]`` argument is given
+to the :command:`project` command, it stores the version string in the
+``PROJECT_VERSION`` variable and stores individual integer version components
+in ``PROJECT_VERSION_{MAJOR,MINOR,PATCH,TWEAK}`` variables (see policy
+:policy:`CMP0048`). CMake 3.15 and below dropped leading zeros from each
+component. CMake 3.16 and higher prefer to preserve leading zeros. This
+policy provides compatibility for projects that have not been updated to
+expect the new behavior.
+
+The ``OLD`` behavior of this policy drops leading zeros in all components,
+e.g. such that version ``1.07.06`` becomes ``1.7.6``. The ``NEW`` behavior
+of this policy preserves the leading zeros in all components, such that
+version ``1.07.06`` remains unchanged.
+
+This policy was introduced in CMake version 3.16. Unlike many policies, CMake
+version |release| does *not* warn when this policy is not set and simply uses
+the ``OLD`` behavior. Use the :command:`cmake_policy` command to set it to
+``OLD`` or ``NEW`` explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/policy/CMP0097.rst b/Help/policy/CMP0097.rst
new file mode 100644
index 000000000..4840aa69d
--- /dev/null
+++ b/Help/policy/CMP0097.rst
@@ -0,0 +1,23 @@
+CMP0097
+-------
+
+:command:`ExternalProject_Add` with ``GIT_SUBMODULES ""`` initializes no
+submodules.
+
+The module provides a ``GIT_SUBMODULES`` option which controls what submodules
+to initialize and update. Starting with CMake 3.16, explicitly setting
+``GIT_SUBMODULES`` to an empty string means no submodules will be initialized
+or updated.
+
+This policy provides compatibility for projects that have not been updated
+to expect the new behavior.
+
+The ``OLD`` behavior for this policy is for ``GIT_SUBMODULES`` when set to
+an empty string to initialize and update all git submodules.
+The ``NEW`` behavior for this policy is for ``GIT_SUBMODULES`` when set to
+an empty string to initialize and update no git submodules.
+
+This policy was introduced in CMake version 3.16. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike most policies, CMake version |release| does *not* warn
+when this policy is not set and simply uses ``OLD`` behavior.
diff --git a/Help/policy/DISALLOWED_COMMAND.txt b/Help/policy/DISALLOWED_COMMAND.txt
index 36280d2b6..6500bb0f3 100644
--- a/Help/policy/DISALLOWED_COMMAND.txt
+++ b/Help/policy/DISALLOWED_COMMAND.txt
@@ -1,9 +1,9 @@
CMake >= |disallowed_version| prefer that this command never be called.
-The OLD behavior for this policy is to allow the command to be called.
-The NEW behavior for this policy is to issue a FATAL_ERROR when the
+The ``OLD`` behavior for this policy is to allow the command to be called.
+The ``NEW`` behavior for this policy is to issue a ``FATAL_ERROR`` when the
command is called.
This policy was introduced in CMake version |disallowed_version|.
CMake version |release| warns when the policy is not set and uses
-OLD behavior. Use the cmake_policy command to set it to OLD or
-NEW explicitly.
+``OLD`` behavior. Use the :command:`cmake_policy` command to set it to ``OLD`` or
+``NEW`` explicitly.
diff --git a/Help/prop_cache/ADVANCED.rst b/Help/prop_cache/ADVANCED.rst
index a0a4f73bb..ec4de9d85 100644
--- a/Help/prop_cache/ADVANCED.rst
+++ b/Help/prop_cache/ADVANCED.rst
@@ -4,5 +4,5 @@ ADVANCED
True if entry should be hidden by default in GUIs.
This is a boolean value indicating whether the entry is considered
-interesting only for advanced configuration. The mark_as_advanced()
+interesting only for advanced configuration. The :command:`mark_as_advanced`
command modifies this property.
diff --git a/Help/prop_cache/STRINGS.rst b/Help/prop_cache/STRINGS.rst
index 2f8e32e3f..0e3c326d2 100644
--- a/Help/prop_cache/STRINGS.rst
+++ b/Help/prop_cache/STRINGS.rst
@@ -1,9 +1,9 @@
STRINGS
-------
-Enumerate possible STRING entry values for GUI selection.
+Enumerate possible ``STRING`` entry values for GUI selection.
-For cache entries with type STRING, this enumerates a set of values.
+For cache entries with type ``STRING``, this enumerates a set of values.
CMake GUIs may use this to provide a selection widget instead of a
generic string entry field. This is for convenience only. CMake does
not enforce that the value matches one of those listed.
diff --git a/Help/prop_cache/TYPE.rst b/Help/prop_cache/TYPE.rst
index eb75c2ab2..7ca859f68 100644
--- a/Help/prop_cache/TYPE.rst
+++ b/Help/prop_cache/TYPE.rst
@@ -5,7 +5,7 @@ Widget type for entry in GUIs.
Cache entry values are always strings, but CMake GUIs present widgets
to help users set values. The GUIs use this property as a hint to
-determine the widget type. Valid TYPE values are:
+determine the widget type. Valid ``TYPE`` values are:
::
@@ -17,5 +17,5 @@ determine the widget type. Valid TYPE values are:
STATIC = Value managed by CMake, do not change.
UNINITIALIZED = Type not yet specified.
-Generally the TYPE of a cache entry should be set by the command which
-creates it (set, option, find_library, etc.).
+Generally the ``TYPE`` of a cache entry should be set by the command which
+creates it ( :command:`set`, :command:`option`, :command:`find_library`, etc.).
diff --git a/Help/prop_dir/ADDITIONAL_CLEAN_FILES.rst b/Help/prop_dir/ADDITIONAL_CLEAN_FILES.rst
new file mode 100644
index 000000000..051d22a81
--- /dev/null
+++ b/Help/prop_dir/ADDITIONAL_CLEAN_FILES.rst
@@ -0,0 +1,21 @@
+ADDITIONAL_CLEAN_FILES
+----------------------
+
+A :ref:`;-list <CMake Language Lists>` of files or directories that will be
+removed as a part of the global ``clean`` target. It is useful for
+specifying generated files or directories that are used by multiple targets
+or by CMake itself, or that are generated in ways which cannot be captured as
+outputs or byproducts of custom commands.
+
+If an additional clean file is specific to a single target only, then the
+:prop_tgt:`ADDITIONAL_CLEAN_FILES` target property would usually be a better
+choice than this directory property.
+
+Relative paths are allowed and are interpreted relative to the
+current binary directory.
+
+Contents of ``ADDITIONAL_CLEAN_FILES`` may use
+:manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+This property only works for the :generator:`Ninja` and the Makefile
+generators. It is ignored by other generators.
diff --git a/Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst b/Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst
index e32eed3ed..b6f616099 100644
--- a/Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst
+++ b/Help/prop_dir/ADDITIONAL_MAKE_CLEAN_FILES.rst
@@ -1,7 +1,17 @@
ADDITIONAL_MAKE_CLEAN_FILES
---------------------------
-Additional files to clean during the make clean stage.
+.. deprecated:: 3.15
-A list of files that will be cleaned as a part of the "make clean"
-stage.
+ Use :prop_dir:`ADDITIONAL_CLEAN_FILES` instead.
+
+Additional files to remove during the clean stage.
+
+A :ref:`;-list <CMake Language Lists>` of files that will be removed as a
+part of the ``make clean`` target.
+
+Arguments to :prop_dir:`ADDITIONAL_MAKE_CLEAN_FILES` may use
+:manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+This property only works for the Makefile generators.
+It is ignored on other generators.
diff --git a/Help/prop_dir/BUILDSYSTEM_TARGETS.rst b/Help/prop_dir/BUILDSYSTEM_TARGETS.rst
index da907cb93..04bb56ec1 100644
--- a/Help/prop_dir/BUILDSYSTEM_TARGETS.rst
+++ b/Help/prop_dir/BUILDSYSTEM_TARGETS.rst
@@ -2,7 +2,7 @@ BUILDSYSTEM_TARGETS
-------------------
This read-only directory property contains a
-:ref:`;-list <CMake Language Lists>` of buildsystem targets added in the
+:ref:`semicolon-separated list <CMake Language Lists>` of buildsystem targets added in the
directory by calls to the :command:`add_library`, :command:`add_executable`,
and :command:`add_custom_target` commands. The list does not include any
:ref:`Imported Targets` or :ref:`Alias Targets`, but does include
diff --git a/Help/prop_dir/COMPILE_DEFINITIONS.rst b/Help/prop_dir/COMPILE_DEFINITIONS.rst
index 85adcb58a..18f4567c5 100644
--- a/Help/prop_dir/COMPILE_DEFINITIONS.rst
+++ b/Help/prop_dir/COMPILE_DEFINITIONS.rst
@@ -4,7 +4,7 @@ COMPILE_DEFINITIONS
Preprocessor definitions for compiling a directory's sources.
This property specifies the list of options given so far to the
-:command:`add_definitions` command.
+:command:`add_compile_definitions` (or :command:`add_definitions`) command.
The ``COMPILE_DEFINITIONS`` property may be set to a semicolon-separated
list of preprocessor definitions using the syntax ``VAR`` or ``VAR=value``.
diff --git a/Help/prop_dir/COMPILE_OPTIONS.rst b/Help/prop_dir/COMPILE_OPTIONS.rst
index 877deb000..48e8b9b8d 100644
--- a/Help/prop_dir/COMPILE_OPTIONS.rst
+++ b/Help/prop_dir/COMPILE_OPTIONS.rst
@@ -3,7 +3,7 @@ COMPILE_OPTIONS
List of options to pass to the compiler.
-This property holds a :ref:`;-list <CMake Language Lists>` of options
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of options
given so far to the :command:`add_compile_options` command.
This property is used to initialize the :prop_tgt:`COMPILE_OPTIONS` target
diff --git a/Help/prop_dir/EXCLUDE_FROM_ALL.rst b/Help/prop_dir/EXCLUDE_FROM_ALL.rst
index 1aa24e44b..8e3cca0c2 100644
--- a/Help/prop_dir/EXCLUDE_FROM_ALL.rst
+++ b/Help/prop_dir/EXCLUDE_FROM_ALL.rst
@@ -1,9 +1,13 @@
EXCLUDE_FROM_ALL
----------------
-Exclude the directory from the all target of its parent.
+Set this directory property to a true value on a subdirectory to exclude
+its targets from the "all" target of its ancestors. If excluded, running
+e.g. ``make`` in the parent directory will not build targets the
+subdirectory by default. This does not affect the "all" target of the
+subdirectory itself. Running e.g. ``make`` inside the subdirectory will
+still build its targets.
-A property on a directory that indicates if its targets are excluded
-from the default build target. If it is not, then with a Makefile for
-example typing make will cause the targets to be built. The same
-concept applies to the default build of other generators.
+If the :prop_tgt:`EXCLUDE_FROM_ALL` target property is set on a target
+then its value determines whether the target is included in the "all"
+target of this directory and its ancestors.
diff --git a/Help/prop_dir/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM.rst b/Help/prop_dir/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM.rst
index 993f6200e..f5349763a 100644
--- a/Help/prop_dir/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM.rst
+++ b/Help/prop_dir/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM.rst
@@ -1,15 +1,15 @@
IMPLICIT_DEPENDS_INCLUDE_TRANSFORM
----------------------------------
-Specify #include line transforms for dependencies in a directory.
+Specify ``#include`` line transforms for dependencies in a directory.
-This property specifies rules to transform macro-like #include lines
+This property specifies rules to transform macro-like ``#include`` lines
during implicit dependency scanning of C and C++ source files. The
list of rules must be semicolon-separated with each entry of the form
-"A_MACRO(%)=value-with-%" (the % must be literal). During dependency
-scanning occurrences of A_MACRO(...) on #include lines will be
+``A_MACRO(%)=value-with-%`` (the ``%`` must be literal). During dependency
+scanning occurrences of ``A_MACRO(...)`` on ``#include`` lines will be
replaced by the value given with the macro argument substituted for
-'%'. For example, the entry
+``%``. For example, the entry
::
diff --git a/Help/prop_dir/INCLUDE_DIRECTORIES.rst b/Help/prop_dir/INCLUDE_DIRECTORIES.rst
index 6789a5644..5d856b80a 100644
--- a/Help/prop_dir/INCLUDE_DIRECTORIES.rst
+++ b/Help/prop_dir/INCLUDE_DIRECTORIES.rst
@@ -11,11 +11,17 @@ target property, which is used by the generators to set the include
directories for the compiler.
In addition to accepting values from that command, values may be set
-directly on any directory using the :command:`set_property` command. A
-directory gets its initial value from its parent directory if it has one.
-The initial value of the :prop_tgt:`INCLUDE_DIRECTORIES` target property
+directly on any directory using the :command:`set_property` command, and can be
+set on the current directory using the :command:`set_directory_properties`
+command. A directory gets its initial value from its parent directory if it has
+one. The initial value of the :prop_tgt:`INCLUDE_DIRECTORIES` target property
comes from the value of this property. Both directory and target property
values are adjusted by calls to the :command:`include_directories` command.
+Calls to :command:`set_property` or :command:`set_directory_properties`,
+however, will update the directory property value without updating target
+property values. Therefore direct property updates must be made before
+calls to :command:`add_executable` or :command:`add_library` for targets
+they are meant to affect.
The target property values are used by the generators to set the
include paths for the compiler.
diff --git a/Help/prop_dir/INTERPROCEDURAL_OPTIMIZATION_CONFIG.rst b/Help/prop_dir/INTERPROCEDURAL_OPTIMIZATION_CONFIG.rst
index 325208656..840a1dbc7 100644
--- a/Help/prop_dir/INTERPROCEDURAL_OPTIMIZATION_CONFIG.rst
+++ b/Help/prop_dir/INTERPROCEDURAL_OPTIMIZATION_CONFIG.rst
@@ -3,6 +3,6 @@ INTERPROCEDURAL_OPTIMIZATION_<CONFIG>
Per-configuration interprocedural optimization for a directory.
-This is a per-configuration version of INTERPROCEDURAL_OPTIMIZATION.
+This is a per-configuration version of ``INTERPROCEDURAL_OPTIMIZATION``.
If set, this property overrides the generic property for the named
configuration.
diff --git a/Help/prop_dir/LABELS.rst b/Help/prop_dir/LABELS.rst
new file mode 100644
index 000000000..de27d906e
--- /dev/null
+++ b/Help/prop_dir/LABELS.rst
@@ -0,0 +1,13 @@
+LABELS
+------
+
+Specify a list of text labels associated with a directory and all of its
+subdirectories. This is equivalent to setting the :prop_tgt:`LABELS` target
+property and the :prop_test:`LABELS` test property on all targets and tests in
+the current directory and subdirectories. Note: Launchers must enabled to
+propagate labels to targets.
+
+The :variable:`CMAKE_DIRECTORY_LABELS` variable can be used to initialize this
+property.
+
+The list is reported in dashboard submissions.
diff --git a/Help/prop_dir/LINK_DIRECTORIES.rst b/Help/prop_dir/LINK_DIRECTORIES.rst
index fa375766d..44dc2304e 100644
--- a/Help/prop_dir/LINK_DIRECTORIES.rst
+++ b/Help/prop_dir/LINK_DIRECTORIES.rst
@@ -3,6 +3,15 @@ LINK_DIRECTORIES
List of linker search directories.
-This read-only property specifies the list of directories given so far
-to the link_directories command. It is intended for debugging
-purposes.
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of directories
+and is typically populated using the :command:`link_directories` command.
+It gets its initial value from its parent directory, if it has one.
+
+The directory property is used to initialize the :prop_tgt:`LINK_DIRECTORIES`
+target property when a target is created. That target property is used
+by the generators to set the library search directories for the linker.
+
+Contents of ``LINK_DIRECTORIES`` may use "generator expressions" with
+the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
diff --git a/Help/prop_dir/LINK_OPTIONS.rst b/Help/prop_dir/LINK_OPTIONS.rst
new file mode 100644
index 000000000..54ac6ddaa
--- /dev/null
+++ b/Help/prop_dir/LINK_OPTIONS.rst
@@ -0,0 +1,17 @@
+LINK_OPTIONS
+------------
+
+List of options to use for the link step of shared library, module
+and executable targets.
+
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of options
+given so far to the :command:`add_link_options` command.
+
+This property is used to initialize the :prop_tgt:`LINK_OPTIONS` target
+property when a target is created, which is used by the generators to set
+the options for the compiler.
+
+Contents of ``LINK_OPTIONS`` may use "generator expressions" with the
+syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual
+for available expressions. See the :manual:`cmake-buildsystem(7)` manual
+for more on defining buildsystem properties.
diff --git a/Help/prop_dir/MACROS.rst b/Help/prop_dir/MACROS.rst
index e4feadaa5..245cc1b91 100644
--- a/Help/prop_dir/MACROS.rst
+++ b/Help/prop_dir/MACROS.rst
@@ -4,5 +4,5 @@ MACROS
List of macro commands available in the current directory.
This read-only property specifies the list of CMake macros currently
-defined. It is intended for debugging purposes. See the macro
+defined. It is intended for debugging purposes. See the :command:`macro`
command.
diff --git a/Help/prop_dir/SUBDIRECTORIES.rst b/Help/prop_dir/SUBDIRECTORIES.rst
index 2c2ea773e..6a0ac80d8 100644
--- a/Help/prop_dir/SUBDIRECTORIES.rst
+++ b/Help/prop_dir/SUBDIRECTORIES.rst
@@ -2,7 +2,7 @@ SUBDIRECTORIES
--------------
This read-only directory property contains a
-:ref:`;-list <CMake Language Lists>` of subdirectories processed so far by
+:ref:`semicolon-separated list <CMake Language Lists>` of subdirectories processed so far by
the :command:`add_subdirectory` or :command:`subdirs` commands. Each entry is
the absolute path to the source directory (containing the ``CMakeLists.txt``
file). This is suitable to pass to the :command:`get_property` command
diff --git a/Help/prop_dir/TESTS.rst b/Help/prop_dir/TESTS.rst
new file mode 100644
index 000000000..1c9f6e5c6
--- /dev/null
+++ b/Help/prop_dir/TESTS.rst
@@ -0,0 +1,8 @@
+TESTS
+-----
+
+List of tests.
+
+This read-only property holds a
+:ref:`semicolon-separated list <CMake Language Lists>` of tests
+defined so far, in the current directory, by the :command:`add_test` command.
diff --git a/Help/prop_dir/TEST_INCLUDE_FILE.rst b/Help/prop_dir/TEST_INCLUDE_FILE.rst
index e47795191..31b23829d 100644
--- a/Help/prop_dir/TEST_INCLUDE_FILE.rst
+++ b/Help/prop_dir/TEST_INCLUDE_FILE.rst
@@ -1,7 +1,9 @@
TEST_INCLUDE_FILE
-----------------
+Deprecated. Use :prop_dir:`TEST_INCLUDE_FILES` instead.
+
A cmake file that will be included when ctest is run.
-If you specify TEST_INCLUDE_FILE, that file will be included and
+If you specify ``TEST_INCLUDE_FILE``, that file will be included and
processed when ctest is run on the directory.
diff --git a/Help/prop_dir/TEST_INCLUDE_FILES.rst b/Help/prop_dir/TEST_INCLUDE_FILES.rst
new file mode 100644
index 000000000..c3e4602b0
--- /dev/null
+++ b/Help/prop_dir/TEST_INCLUDE_FILES.rst
@@ -0,0 +1,7 @@
+TEST_INCLUDE_FILES
+------------------
+
+A list of cmake files that will be included when ctest is run.
+
+If you specify ``TEST_INCLUDE_FILES``, those files will be included and
+processed when ctest is run on the directory.
diff --git a/Help/prop_dir/VS_GLOBAL_SECTION_POST_section.rst b/Help/prop_dir/VS_GLOBAL_SECTION_POST_section.rst
index a316abec9..b65db99f3 100644
--- a/Help/prop_dir/VS_GLOBAL_SECTION_POST_section.rst
+++ b/Help/prop_dir/VS_GLOBAL_SECTION_POST_section.rst
@@ -12,20 +12,20 @@ in the solution file:
<contents based on property value>
EndGlobalSection
-The property must be set to a semicolon-separated list of key=value
+The property must be set to a semicolon-separated list of ``key=value``
pairs. Each such pair will be transformed into an entry in the
solution global section. Whitespace around key and value is ignored.
List elements which do not contain an equal sign are skipped.
-This property only works for Visual Studio 8 and above; it is ignored
+This property only works for Visual Studio 9 and above; it is ignored
on other generators. The property only applies when set on a
-directory whose CMakeLists.txt contains a project() command.
+directory whose ``CMakeLists.txt`` contains a :command:`project` command.
-Note that CMake generates postSolution sections ExtensibilityGlobals
-and ExtensibilityAddIns by default. If you set the corresponding
+Note that CMake generates postSolution sections ``ExtensibilityGlobals``
+and ``ExtensibilityAddIns`` by default. If you set the corresponding
property, it will override the default section. For example, setting
-VS_GLOBAL_SECTION_POST_ExtensibilityGlobals will override the default
-contents of the ExtensibilityGlobals section, while keeping
+``VS_GLOBAL_SECTION_POST_ExtensibilityGlobals`` will override the default
+contents of the ``ExtensibilityGlobals`` section, while keeping
ExtensibilityAddIns on its default. However, CMake will always
add a ``SolutionGuid`` to the ``ExtensibilityGlobals`` section
if it is not specified explicitly.
diff --git a/Help/prop_dir/VS_GLOBAL_SECTION_PRE_section.rst b/Help/prop_dir/VS_GLOBAL_SECTION_PRE_section.rst
index 200e8e62f..7f8bf6161 100644
--- a/Help/prop_dir/VS_GLOBAL_SECTION_PRE_section.rst
+++ b/Help/prop_dir/VS_GLOBAL_SECTION_PRE_section.rst
@@ -12,11 +12,11 @@ in the solution file:
<contents based on property value>
EndGlobalSection
-The property must be set to a semicolon-separated list of key=value
+The property must be set to a semicolon-separated list of ``key=value``
pairs. Each such pair will be transformed into an entry in the
solution global section. Whitespace around key and value is ignored.
List elements which do not contain an equal sign are skipped.
-This property only works for Visual Studio 8 and above; it is ignored
+This property only works for Visual Studio 9 and above; it is ignored
on other generators. The property only applies when set on a
-directory whose CMakeLists.txt contains a project() command.
+directory whose ``CMakeLists.txt`` contains a :command:`project` command.
diff --git a/Help/prop_dir/VS_STARTUP_PROJECT.rst b/Help/prop_dir/VS_STARTUP_PROJECT.rst
index 04441b621..2680dfa6c 100644
--- a/Help/prop_dir/VS_STARTUP_PROJECT.rst
+++ b/Help/prop_dir/VS_STARTUP_PROJECT.rst
@@ -7,7 +7,7 @@ The :ref:`Visual Studio Generators` create a ``.sln`` file for each directory
whose ``CMakeLists.txt`` file calls the :command:`project` command. Set this
property in the same directory as a :command:`project` command call (e.g. in
the top-level ``CMakeLists.txt`` file) to specify the default startup project
-for the correpsonding solution file.
+for the corresponding solution file.
The property must be set to the name of an existing target. This
will cause that project to be listed first in the generated solution
diff --git a/Help/prop_gbl/ALLOW_DUPLICATE_CUSTOM_TARGETS.rst b/Help/prop_gbl/ALLOW_DUPLICATE_CUSTOM_TARGETS.rst
index 8fab50345..19775ff2d 100644
--- a/Help/prop_gbl/ALLOW_DUPLICATE_CUSTOM_TARGETS.rst
+++ b/Help/prop_gbl/ALLOW_DUPLICATE_CUSTOM_TARGETS.rst
@@ -4,16 +4,18 @@ ALLOW_DUPLICATE_CUSTOM_TARGETS
Allow duplicate custom targets to be created.
Normally CMake requires that all targets built in a project have
-globally unique logical names (see policy CMP0002). This is necessary
-to generate meaningful project file names in Xcode and VS IDE
+globally unique logical names (see policy :policy:`CMP0002`).
+This is necessary to generate meaningful project file names in
+:generator:`Xcode` and :ref:`Visual Studio Generators` IDE
generators. It also allows the target names to be referenced
unambiguously.
-Makefile generators are capable of supporting duplicate custom target
-names. For projects that care only about Makefile generators and do
-not wish to support Xcode or VS IDE generators, one may set this
-property to true to allow duplicate custom targets. The property
-allows multiple add_custom_target command calls in different
+Makefile generators are capable of supporting duplicate :command:`add_custom_target`
+names. For projects that care only about :ref:`Makefile Generators` and do
+not wish to support :generator:`Xcode` or :ref:`Visual Studio Generators` IDE
+generators, one may set this property to ``True``
+to allow duplicate custom targets. The property
+allows multiple :command:`add_custom_target` command calls in different
directories to specify the same target name. However, setting this
property will cause non-Makefile generators to produce an error and
refuse to generate the project.
diff --git a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst
index 2ad81574f..b921c6b03 100644
--- a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst
+++ b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst
@@ -15,16 +15,19 @@ compile features and a list of supported compilers.
The features known to this version of CMake are:
``cxx_std_98``
- Compiler mode is aware of C++ 98.
+ Compiler mode is at least C++ 98.
``cxx_std_11``
- Compiler mode is aware of C++ 11.
+ Compiler mode is at least C++ 11.
``cxx_std_14``
- Compiler mode is aware of C++ 14.
+ Compiler mode is at least C++ 14.
``cxx_std_17``
- Compiler mode is aware of C++ 17.
+ Compiler mode is at least C++ 17.
+
+``cxx_std_20``
+ Compiler mode is at least C++ 20.
``cxx_aggregate_default_initializers``
Aggregate default initializers, as defined in N3605_.
diff --git a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
index 3707fef1e..e5f896ee0 100644
--- a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
+++ b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst
@@ -14,13 +14,13 @@ compile features and a list of supported compilers.
The features known to this version of CMake are:
``c_std_90``
- Compiler mode is aware of C 90.
+ Compiler mode is at least C 90.
``c_std_99``
- Compiler mode is aware of C 99.
+ Compiler mode is at least C 99.
``c_std_11``
- Compiler mode is aware of C 11.
+ Compiler mode is at least C 11.
``c_function_prototypes``
Function prototypes, as defined in ``ISO/IEC 9899:1990``.
diff --git a/Help/prop_gbl/CMAKE_ROLE.rst b/Help/prop_gbl/CMAKE_ROLE.rst
new file mode 100644
index 000000000..27512fada
--- /dev/null
+++ b/Help/prop_gbl/CMAKE_ROLE.rst
@@ -0,0 +1,20 @@
+CMAKE_ROLE
+----------
+
+Tells what mode the current running script is in. Could be one of several
+values:
+
+``PROJECT``
+ Running in project mode (processing a ``CMakeLists.txt`` file).
+
+``SCRIPT``
+ Running in ``-P`` script mode.
+
+``FIND_PACKAGE``
+ Running in ``--find-package`` mode.
+
+``CTEST``
+ Running in CTest script mode.
+
+``CPACK``
+ Running in CPack.
diff --git a/Help/prop_gbl/DEBUG_CONFIGURATIONS.rst b/Help/prop_gbl/DEBUG_CONFIGURATIONS.rst
index 690143f82..fec6fdac8 100644
--- a/Help/prop_gbl/DEBUG_CONFIGURATIONS.rst
+++ b/Help/prop_gbl/DEBUG_CONFIGURATIONS.rst
@@ -4,11 +4,10 @@ DEBUG_CONFIGURATIONS
Specify which configurations are for debugging.
The value must be a semi-colon separated list of configuration names.
-Currently this property is used only by the target_link_libraries
-command (see its documentation for details). Additional uses may be
-defined in the future.
+Currently this property is used only by the :command:`target_link_libraries`
+command. Additional uses may be defined in the future.
This property must be set at the top level of the project and before
-the first target_link_libraries command invocation. If any entry in
+the first :command:`target_link_libraries` command invocation. If any entry in
the list does not match a valid configuration for the project the
behavior is undefined.
diff --git a/Help/prop_gbl/DISABLED_FEATURES.rst b/Help/prop_gbl/DISABLED_FEATURES.rst
index 111cdf67e..882bbfacd 100644
--- a/Help/prop_gbl/DISABLED_FEATURES.rst
+++ b/Help/prop_gbl/DISABLED_FEATURES.rst
@@ -5,7 +5,7 @@ List of features which are disabled during the CMake run.
List of features which are disabled during the CMake run. By default
it contains the names of all packages which were not found. This is
-determined using the <NAME>_FOUND variables. Packages which are
-searched QUIET are not listed. A project can add its own features to
+determined using the ``<NAME>_FOUND`` variables. Packages which are
+searched ``QUIET`` are not listed. A project can add its own features to
this list. This property is used by the macros in
-FeatureSummary.cmake.
+``FeatureSummary.cmake``.
diff --git a/Help/prop_gbl/ECLIPSE_EXTRA_CPROJECT_CONTENTS.rst b/Help/prop_gbl/ECLIPSE_EXTRA_CPROJECT_CONTENTS.rst
new file mode 100644
index 000000000..50c41a923
--- /dev/null
+++ b/Help/prop_gbl/ECLIPSE_EXTRA_CPROJECT_CONTENTS.rst
@@ -0,0 +1,12 @@
+ECLIPSE_EXTRA_CPROJECT_CONTENTS
+-------------------------------
+
+Additional contents to be inserted into the generated Eclipse cproject file.
+
+The cproject file defines the CDT specific information. Some third party IDE's
+are based on Eclipse with the addition of other information specific to that IDE.
+Through this property, it is possible to add this additional contents to
+the generated project.
+It is expected to contain valid XML.
+
+Also see the :prop_gbl:`ECLIPSE_EXTRA_NATURES` property.
diff --git a/Help/prop_gbl/ECLIPSE_EXTRA_NATURES.rst b/Help/prop_gbl/ECLIPSE_EXTRA_NATURES.rst
index 6d1529d3a..a46575ffa 100644
--- a/Help/prop_gbl/ECLIPSE_EXTRA_NATURES.rst
+++ b/Help/prop_gbl/ECLIPSE_EXTRA_NATURES.rst
@@ -6,3 +6,5 @@ List of natures to add to the generated Eclipse project file.
Eclipse projects specify language plugins by using natures. This property
should be set to the unique identifier for a nature (which looks like a Java
package name).
+
+Also see the :prop_gbl:`ECLIPSE_EXTRA_CPROJECT_CONTENTS` property.
diff --git a/Help/prop_gbl/ENABLED_FEATURES.rst b/Help/prop_gbl/ENABLED_FEATURES.rst
index b03da5a45..acbb3d018 100644
--- a/Help/prop_gbl/ENABLED_FEATURES.rst
+++ b/Help/prop_gbl/ENABLED_FEATURES.rst
@@ -5,7 +5,7 @@ List of features which are enabled during the CMake run.
List of features which are enabled during the CMake run. By default
it contains the names of all packages which were found. This is
-determined using the <NAME>_FOUND variables. Packages which are
-searched QUIET are not listed. A project can add its own features to
+determined using the ``<NAME>_FOUND`` variables. Packages which are
+searched ``QUIET`` are not listed. A project can add its own features to
this list. This property is used by the macros in
-FeatureSummary.cmake.
+``FeatureSummary.cmake``.
diff --git a/Help/prop_gbl/JOB_POOLS.rst b/Help/prop_gbl/JOB_POOLS.rst
index 2ce74b81c..21da4662d 100644
--- a/Help/prop_gbl/JOB_POOLS.rst
+++ b/Help/prop_gbl/JOB_POOLS.rst
@@ -18,6 +18,14 @@ Defined pools could be used globally by setting
:variable:`CMAKE_JOB_POOL_COMPILE` and :variable:`CMAKE_JOB_POOL_LINK`
or per target by setting the target properties
:prop_tgt:`JOB_POOL_COMPILE` and :prop_tgt:`JOB_POOL_LINK`.
+:command:`Custom commands <add_custom_command>` and
+:command:`custom targets <add_custom_target>` can specify pools using the
+option ``JOB_POOL``.
+Using a pool that is not defined by :prop_gbl:`JOB_POOLS` causes
+an error by ninja at build time.
+
+If not set, this property uses the value of the :variable:`CMAKE_JOB_POOLS`
+variable.
Build targets provided by CMake that are meant for individual interactive
use, such as ``install``, are placed in the ``console`` pool automatically.
diff --git a/Help/prop_gbl/RULE_MESSAGES.rst b/Help/prop_gbl/RULE_MESSAGES.rst
index 87a5ca613..a9734a730 100644
--- a/Help/prop_gbl/RULE_MESSAGES.rst
+++ b/Help/prop_gbl/RULE_MESSAGES.rst
@@ -8,6 +8,6 @@ progress message describing what each build rule does. If the
property is not set the default is ON. Set the property to OFF to
disable granular messages and report only as each target completes.
This is intended to allow scripted builds to avoid the build time cost
-of detailed reports. If a ``CMAKE_RULE_MESSAGES`` cache entry exists
+of detailed reports. If a :variable:`CMAKE_RULE_MESSAGES` cache entry exists
its value initializes the value of this property. Non-Makefile
generators currently ignore this property.
diff --git a/Help/prop_gbl/USE_FOLDERS.rst b/Help/prop_gbl/USE_FOLDERS.rst
index a1b4ccb5b..591972327 100644
--- a/Help/prop_gbl/USE_FOLDERS.rst
+++ b/Help/prop_gbl/USE_FOLDERS.rst
@@ -4,7 +4,7 @@ USE_FOLDERS
Use the :prop_tgt:`FOLDER` target property to organize targets into
folders.
-If not set, CMake treats this property as OFF by default. CMake
+If not set, CMake treats this property as ``OFF`` by default. CMake
generators that are capable of organizing into a hierarchy of folders
use the values of the :prop_tgt:`FOLDER` target property to name those
-folders. See also the documentation for the FOLDER target property.
+folders. See also the documentation for the :prop_tgt:`FOLDER` target property.
diff --git a/Help/prop_gbl/XCODE_EMIT_EFFECTIVE_PLATFORM_NAME.rst b/Help/prop_gbl/XCODE_EMIT_EFFECTIVE_PLATFORM_NAME.rst
index 9a6086ed8..950044301 100644
--- a/Help/prop_gbl/XCODE_EMIT_EFFECTIVE_PLATFORM_NAME.rst
+++ b/Help/prop_gbl/XCODE_EMIT_EFFECTIVE_PLATFORM_NAME.rst
@@ -1,14 +1,15 @@
XCODE_EMIT_EFFECTIVE_PLATFORM_NAME
----------------------------------
-Control emission of ``EFFECTIVE_PLATFORM_NAME`` by the Xcode generator.
+Control emission of ``EFFECTIVE_PLATFORM_NAME`` by the :generator:`Xcode`
+generator.
It is required for building the same target with multiple SDKs. A
common use case is the parallel use of ``iphoneos`` and
``iphonesimulator`` SDKs.
-Three different states possible that control when the Xcode generator
-emits the ``EFFECTIVE_PLATFORM_NAME`` variable:
+Three different states possible that control when the :generator:`Xcode`
+generator emits the ``EFFECTIVE_PLATFORM_NAME`` variable:
- If set to ``ON`` it will always be emitted
- If set to ``OFF`` it will never be emitted
diff --git a/Help/prop_inst/CPACK_DESKTOP_SHORTCUTS.rst b/Help/prop_inst/CPACK_DESKTOP_SHORTCUTS.rst
index 11f2c036c..729ab603c 100644
--- a/Help/prop_inst/CPACK_DESKTOP_SHORTCUTS.rst
+++ b/Help/prop_inst/CPACK_DESKTOP_SHORTCUTS.rst
@@ -1,7 +1,7 @@
CPACK_DESKTOP_SHORTCUTS
-----------------------
-Species a list of shortcut names that should be created on the Desktop
+Species a list of shortcut names that should be created on the `Desktop`
for this file.
-The property is currently only supported by the WIX generator.
+The property is currently only supported by the :cpack_gen:`CPack WIX Generator`.
diff --git a/Help/prop_inst/CPACK_NEVER_OVERWRITE.rst b/Help/prop_inst/CPACK_NEVER_OVERWRITE.rst
index 11f44d0df..4789e253d 100644
--- a/Help/prop_inst/CPACK_NEVER_OVERWRITE.rst
+++ b/Help/prop_inst/CPACK_NEVER_OVERWRITE.rst
@@ -3,4 +3,4 @@ CPACK_NEVER_OVERWRITE
Request that this file not be overwritten on install or reinstall.
-The property is currently only supported by the WIX generator.
+The property is currently only supported by the :cpack_gen:`CPack WIX Generator`.
diff --git a/Help/prop_inst/CPACK_PERMANENT.rst b/Help/prop_inst/CPACK_PERMANENT.rst
index 5e191d08e..985de0da9 100644
--- a/Help/prop_inst/CPACK_PERMANENT.rst
+++ b/Help/prop_inst/CPACK_PERMANENT.rst
@@ -3,4 +3,4 @@ CPACK_PERMANENT
Request that this file not be removed on uninstall.
-The property is currently only supported by the WIX generator.
+The property is currently only supported by the :cpack_gen:`CPack WIX Generator`.
diff --git a/Help/prop_inst/CPACK_STARTUP_SHORTCUTS.rst b/Help/prop_inst/CPACK_STARTUP_SHORTCUTS.rst
index 8a160223d..d9208b9f9 100644
--- a/Help/prop_inst/CPACK_STARTUP_SHORTCUTS.rst
+++ b/Help/prop_inst/CPACK_STARTUP_SHORTCUTS.rst
@@ -1,7 +1,7 @@
CPACK_STARTUP_SHORTCUTS
-----------------------
-Species a list of shortcut names that should be created in the Startup folder
+Species a list of shortcut names that should be created in the `Startup` folder
for this file.
-The property is currently only supported by the WIX generator.
+The property is currently only supported by the :cpack_gen:`CPack WIX Generator`.
diff --git a/Help/prop_inst/CPACK_START_MENU_SHORTCUTS.rst b/Help/prop_inst/CPACK_START_MENU_SHORTCUTS.rst
index d30ea39fd..092334a5a 100644
--- a/Help/prop_inst/CPACK_START_MENU_SHORTCUTS.rst
+++ b/Help/prop_inst/CPACK_START_MENU_SHORTCUTS.rst
@@ -1,7 +1,7 @@
CPACK_START_MENU_SHORTCUTS
--------------------------
-Species a list of shortcut names that should be created in the Start Menu
+Species a list of shortcut names that should be created in the `Start Menu`
for this file.
-The property is currently only supported by the WIX generator.
+The property is currently only supported by the :cpack_gen:`CPack WIX Generator`.
diff --git a/Help/prop_inst/CPACK_WIX_ACL.rst b/Help/prop_inst/CPACK_WIX_ACL.rst
index 4e13ec48c..c88f42675 100644
--- a/Help/prop_inst/CPACK_WIX_ACL.rst
+++ b/Help/prop_inst/CPACK_WIX_ACL.rst
@@ -17,3 +17,5 @@ each of which has to match the following format.
``<permission>`` is any of the YesNoType attributes listed here::
http://wixtoolset.org/documentation/manual/v3/xsd/wix/permission.html
+
+The property is currently only supported by the :cpack_gen:`CPack WIX Generator`.
diff --git a/Help/prop_sf/AUTORCC_OPTIONS.rst b/Help/prop_sf/AUTORCC_OPTIONS.rst
index d9dc4d33e..2bec033e4 100644
--- a/Help/prop_sf/AUTORCC_OPTIONS.rst
+++ b/Help/prop_sf/AUTORCC_OPTIONS.rst
@@ -9,5 +9,14 @@ optional ``OPTIONS`` argument of the :module:`qt4_add_resources() <FindQt4>` mac
By default it is empty.
-The options set on the ``.qrc`` source file may override :prop_tgt:`AUTORCC_OPTIONS` set
-on the target.
+The options set on the ``.qrc`` source file may override
+:prop_tgt:`AUTORCC_OPTIONS` set on the target.
+
+EXAMPLE
+^^^^^^^
+
+.. code-block:: cmake
+
+ # ...
+ set_property(SOURCE resources.qrc PROPERTY AUTORCC_OPTIONS "--compress;9")
+ # ...
diff --git a/Help/prop_sf/AUTOUIC_OPTIONS.rst b/Help/prop_sf/AUTOUIC_OPTIONS.rst
index bb48da90f..e2f47ecd2 100644
--- a/Help/prop_sf/AUTOUIC_OPTIONS.rst
+++ b/Help/prop_sf/AUTOUIC_OPTIONS.rst
@@ -4,11 +4,20 @@ AUTOUIC_OPTIONS
Additional options for ``uic`` when using :prop_tgt:`AUTOUIC`
This property holds additional command line options
-which will be used when ``uic`` is executed during the build via :prop_tgt:`AUTOUIC`,
-i.e. it is equivalent to the optional ``OPTIONS`` argument of the
-:module:`qt4_wrap_ui() <FindQt4>` macro.
+which will be used when ``uic`` is executed during the build via
+:prop_tgt:`AUTOUIC`, i.e. it is equivalent to the optional ``OPTIONS``
+argument of the :module:`qt4_wrap_ui() <FindQt4>` macro.
By default it is empty.
-The options set on the ``.ui`` source file may override :prop_tgt:`AUTOUIC_OPTIONS` set
-on the target.
+The options set on the ``.ui`` source file may override
+:prop_tgt:`AUTOUIC_OPTIONS` set on the target.
+
+EXAMPLE
+^^^^^^^
+
+.. code-block:: cmake
+
+ # ...
+ set_property(SOURCE widget.ui PROPERTY AUTOUIC_OPTIONS "--no-protection")
+ # ...
diff --git a/Help/prop_sf/COMPILE_DEFINITIONS.rst b/Help/prop_sf/COMPILE_DEFINITIONS.rst
index 1626825f1..63176901e 100644
--- a/Help/prop_sf/COMPILE_DEFINITIONS.rst
+++ b/Help/prop_sf/COMPILE_DEFINITIONS.rst
@@ -3,17 +3,27 @@ COMPILE_DEFINITIONS
Preprocessor definitions for compiling a source file.
-The COMPILE_DEFINITIONS property may be set to a semicolon-separated
-list of preprocessor definitions using the syntax VAR or VAR=value.
+The ``COMPILE_DEFINITIONS`` property may be set to a semicolon-separated
+list of preprocessor definitions using the syntax ``VAR`` or ``VAR=value``.
Function-style definitions are not supported. CMake will
automatically escape the value correctly for the native build system
(note that CMake language syntax may require escapes to specify some
values). This property may be set on a per-configuration basis using
-the name COMPILE_DEFINITIONS_<CONFIG> where <CONFIG> is an upper-case
-name (ex. "COMPILE_DEFINITIONS_DEBUG").
+the name ``COMPILE_DEFINITIONS_<CONFIG>`` where ``<CONFIG>`` is an upper-case
+name (ex. ``COMPILE_DEFINITIONS_DEBUG``).
CMake will automatically drop some definitions that are not supported
by the native build tool. Xcode does not support per-configuration
definitions on source files.
.. include:: /include/COMPILE_DEFINITIONS_DISCLAIMER.txt
+
+Contents of ``COMPILE_DEFINITIONS`` may use :manual:`cmake-generator-expressions(7)`
+with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. However, :generator:`Xcode`
+does not support per-config per-source settings, so expressions
+that depend on the build configuration are not allowed with that
+generator.
+
+Generator expressions should be preferred instead of setting the alternative per-configuration
+property.
diff --git a/Help/prop_sf/COMPILE_DEFINITIONS_CONFIG.rst b/Help/prop_sf/COMPILE_DEFINITIONS_CONFIG.rst
index 848707647..ec867b65d 100644
--- a/Help/prop_sf/COMPILE_DEFINITIONS_CONFIG.rst
+++ b/Help/prop_sf/COMPILE_DEFINITIONS_CONFIG.rst
@@ -5,6 +5,6 @@ Ignored. See CMake Policy :policy:`CMP0043`.
Per-configuration preprocessor definitions on a source file.
-This is the configuration-specific version of COMPILE_DEFINITIONS.
-Note that Xcode does not support per-configuration source file flags
-so this property will be ignored by the Xcode generator.
+This is the configuration-specific version of :prop_tgt:`COMPILE_DEFINITIONS`.
+Note that :generator:`Xcode` does not support per-configuration source
+file flags so this property will be ignored by the :generator:`Xcode` generator.
diff --git a/Help/prop_sf/COMPILE_FLAGS.rst b/Help/prop_sf/COMPILE_FLAGS.rst
index 10121644e..c211b89ac 100644
--- a/Help/prop_sf/COMPILE_FLAGS.rst
+++ b/Help/prop_sf/COMPILE_FLAGS.rst
@@ -3,8 +3,8 @@ COMPILE_FLAGS
Additional flags to be added when compiling this source file.
-These flags will be added to the list of compile flags when this
-source file builds. Use :prop_sf:`COMPILE_DEFINITIONS` to pass
+The ``COMPILE_FLAGS`` property, managed as a string, sets additional compiler
+flags used to build source files. Use :prop_sf:`COMPILE_DEFINITIONS` to pass
additional preprocessor definitions.
Contents of ``COMPILE_FLAGS`` may use "generator expressions"
@@ -13,3 +13,7 @@ manual for available expressions. However, :generator:`Xcode`
does not support per-config per-source settings, so expressions
that depend on the build configuration are not allowed with that
generator.
+
+.. note::
+
+ This property has been superseded by the :prop_sf:`COMPILE_OPTIONS` property.
diff --git a/Help/prop_sf/COMPILE_OPTIONS.rst b/Help/prop_sf/COMPILE_OPTIONS.rst
new file mode 100644
index 000000000..7e48271d0
--- /dev/null
+++ b/Help/prop_sf/COMPILE_OPTIONS.rst
@@ -0,0 +1,21 @@
+COMPILE_OPTIONS
+---------------
+
+List of additional options to pass to the compiler.
+
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of options
+and will be added to the list of compile flags when this
+source file builds. Use :prop_sf:`COMPILE_DEFINITIONS` to pass
+additional preprocessor definitions and :prop_sf:`INCLUDE_DIRECTORIES` to pass
+additional include directories.
+
+Contents of ``COMPILE_OPTIONS`` may use "generator expressions" with the
+syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual
+for available expressions. However, :generator:`Xcode`
+does not support per-config per-source settings, so expressions
+that depend on the build configuration are not allowed with that
+generator.
+
+.. note::
+
+ This property should be preferred over the :prop_sf:`COMPILE_FLAGS` property.
diff --git a/Help/prop_sf/EXTERNAL_OBJECT.rst b/Help/prop_sf/EXTERNAL_OBJECT.rst
index efa0e9bea..351c04d51 100644
--- a/Help/prop_sf/EXTERNAL_OBJECT.rst
+++ b/Help/prop_sf/EXTERNAL_OBJECT.rst
@@ -3,6 +3,6 @@ EXTERNAL_OBJECT
If set to true then this is an object file.
-If this property is set to true then the source file is really an
+If this property is set to ``True`` then the source file is really an
object file and should not be compiled. It will still be linked into
the target though.
diff --git a/Help/prop_sf/Fortran_FORMAT.rst b/Help/prop_sf/Fortran_FORMAT.rst
index 69e34aafd..1cbbf4809 100644
--- a/Help/prop_sf/Fortran_FORMAT.rst
+++ b/Help/prop_sf/Fortran_FORMAT.rst
@@ -1,9 +1,10 @@
Fortran_FORMAT
--------------
-Set to FIXED or FREE to indicate the Fortran source layout.
+Set to ``FIXED`` or ``FREE`` to indicate the Fortran source layout.
This property tells CMake whether a given Fortran source file uses
fixed-format or free-format. CMake will pass the corresponding format
-flag to the compiler. Consider using the target-wide Fortran_FORMAT
-property if all source files in a target share the same format.
+flag to the compiler. Consider using the target-wide
+:prop_tgt:`Fortran_FORMAT` property if all source files in a target
+share the same format.
diff --git a/Help/prop_sf/GENERATED.rst b/Help/prop_sf/GENERATED.rst
index a3aa12747..d430ee264 100644
--- a/Help/prop_sf/GENERATED.rst
+++ b/Help/prop_sf/GENERATED.rst
@@ -1,8 +1,23 @@
GENERATED
---------
-Is this source file generated as part of the build process.
+Is this source file generated as part of the build or CMake process.
-If a source file is generated by the build process CMake will handle
-it differently in terms of dependency checking etc. Otherwise having
-a non-existent source file could create problems.
+Tells the internal CMake engine that a source file is generated by an outside
+process such as another build step, or the execution of CMake itself. This
+information is then used to exempt the file from any existence or validity
+checks. Generated files are created by the execution of commands such as
+:command:`add_custom_command` and :command:`file(GENERATE)`.
+
+When a generated file created by an :command:`add_custom_command` command
+is explicitly listed as a source file for any target in the same
+directory scope (which usually means the same ``CMakeLists.txt`` file),
+CMake will automatically create a dependency to make sure the file is
+generated before building that target.
+
+Generated sources may be hidden in some IDE tools, while in others they might
+be shown. For the special case of sources generated by CMake's :prop_tgt:`AUTOMOC`
+or :prop_tgt:`AUTORCC` functionality, the :prop_gbl:`AUTOGEN_SOURCE_GROUP`,
+:prop_gbl:`AUTOMOC_SOURCE_GROUP` and :prop_gbl:`AUTORCC_SOURCE_GROUP` target
+properties may influence where the generated sources are grouped in the project's
+file lists.
diff --git a/Help/prop_sf/INCLUDE_DIRECTORIES.rst b/Help/prop_sf/INCLUDE_DIRECTORIES.rst
new file mode 100644
index 000000000..23de70e16
--- /dev/null
+++ b/Help/prop_sf/INCLUDE_DIRECTORIES.rst
@@ -0,0 +1,18 @@
+INCLUDE_DIRECTORIES
+-------------------
+
+List of preprocessor include file search directories.
+
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of paths
+and will be added to the list of include directories when this
+source file builds. These directories will take precedence over directories
+defined at target level except for :generator:`Xcode` generator due to technical
+limitations.
+
+Relative paths should not be added to this property directly.
+
+Contents of ``INCLUDE_DIRECTORIES`` may use "generator expressions" with
+the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual
+for available expressions. However, :generator:`Xcode` does not support
+per-config per-source settings, so expressions that depend on the build
+configuration are not allowed with that generator.
diff --git a/Help/prop_sf/KEEP_EXTENSION.rst b/Help/prop_sf/KEEP_EXTENSION.rst
index d6167e5a9..a32f96834 100644
--- a/Help/prop_sf/KEEP_EXTENSION.rst
+++ b/Help/prop_sf/KEEP_EXTENSION.rst
@@ -6,4 +6,4 @@ Make the output file have the same extension as the source file.
If this property is set then the file extension of the output file
will be the same as that of the source file. Normally the output file
extension is computed based on the language of the source file, for
-example .cxx will go to a .o extension.
+example ``.cxx`` will go to a ``.o`` extension.
diff --git a/Help/prop_sf/LABELS.rst b/Help/prop_sf/LABELS.rst
index e1c10696a..d0d2a0a92 100644
--- a/Help/prop_sf/LABELS.rst
+++ b/Help/prop_sf/LABELS.rst
@@ -4,5 +4,5 @@ LABELS
Specify a list of text labels associated with a source file.
This property has meaning only when the source file is listed in a
-target whose LABELS property is also set. No other semantics are
+target whose ``LABELS`` property is also set. No other semantics are
currently specified.
diff --git a/Help/prop_sf/LANGUAGE.rst b/Help/prop_sf/LANGUAGE.rst
index 97bfa20f4..88d438e7b 100644
--- a/Help/prop_sf/LANGUAGE.rst
+++ b/Help/prop_sf/LANGUAGE.rst
@@ -5,6 +5,7 @@ What programming language is the file.
A property that can be set to indicate what programming language the
source file is. If it is not set the language is determined based on
-the file extension. Typical values are CXX C etc. Setting this
+the file extension. Typical values are ``CXX`` (i.e. C++), ``C``,
+``CSharp``, ``CUDA``, ``Fortran``, and ``ASM``. Setting this
property for a file means this file will be compiled. Do not set this
for headers or files that should not be compiled.
diff --git a/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst b/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst
index a064afa63..d185d9197 100644
--- a/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst
+++ b/Help/prop_sf/MACOSX_PACKAGE_LOCATION.rst
@@ -3,19 +3,19 @@ MACOSX_PACKAGE_LOCATION
Place a source file inside a Application Bundle
(:prop_tgt:`MACOSX_BUNDLE`), Core Foundation Bundle (:prop_tgt:`BUNDLE`),
-or Framework Bundle (:prop_tgt:`FRAMEWORK`). It is applicable for OS X
+or Framework Bundle (:prop_tgt:`FRAMEWORK`). It is applicable for macOS
and iOS.
Executable targets with the :prop_tgt:`MACOSX_BUNDLE` property set are
-built as OS X or iOS application bundles on Apple platforms. Shared
+built as macOS or iOS application bundles on Apple platforms. Shared
library targets with the :prop_tgt:`FRAMEWORK` property set are built as
-OS X or iOS frameworks on Apple platforms. Module library targets with
-the :prop_tgt:`BUNDLE` property set are built as OS X ``CFBundle`` bundles
+macOS or iOS frameworks on Apple platforms. Module library targets with
+the :prop_tgt:`BUNDLE` property set are built as macOS ``CFBundle`` bundles
on Apple platforms. Source files listed in the target with this property
set will be copied to a directory inside the bundle or framework content
-folder specified by the property value. For OS X Application Bundles the
-content folder is ``<name>.app/Contents``. For OS X Frameworks the
-content folder is ``<name>.framework/Versions/<version>``. For OS X
+folder specified by the property value. For macOS Application Bundles the
+content folder is ``<name>.app/Contents``. For macOS Frameworks the
+content folder is ``<name>.framework/Versions/<version>``. For macOS
CFBundles the content folder is ``<name>.bundle/Contents`` (unless the
extension is changed). See the :prop_tgt:`PUBLIC_HEADER`,
:prop_tgt:`PRIVATE_HEADER`, and :prop_tgt:`RESOURCE` target properties for
diff --git a/Help/prop_sf/OBJECT_DEPENDS.rst b/Help/prop_sf/OBJECT_DEPENDS.rst
index 1d24960b5..aaff95659 100644
--- a/Help/prop_sf/OBJECT_DEPENDS.rst
+++ b/Help/prop_sf/OBJECT_DEPENDS.rst
@@ -3,7 +3,7 @@ OBJECT_DEPENDS
Additional files on which a compiled object file depends.
-Specifies a :ref:`;-list <CMake Language Lists>` of full-paths to
+Specifies a :ref:`semicolon-separated list <CMake Language Lists>` of full-paths to
files on which any object files compiled from this source file depend.
On :ref:`Makefile Generators` and the :generator:`Ninja` generator an
object file will be recompiled if any of the named files is newer than it.
diff --git a/Help/prop_sf/OBJECT_OUTPUTS.rst b/Help/prop_sf/OBJECT_OUTPUTS.rst
index 6a2855374..e7e880b29 100644
--- a/Help/prop_sf/OBJECT_OUTPUTS.rst
+++ b/Help/prop_sf/OBJECT_OUTPUTS.rst
@@ -1,9 +1,9 @@
OBJECT_OUTPUTS
--------------
-Additional outputs for a Makefile rule.
+Additional outputs for a :generator:`Ninja` or :ref:`Makefile Generators` rule.
Additional outputs created by compilation of this source file. If any
of these outputs is missing the object will be recompiled. This is
-supported only on Makefile generators and will be ignored on other
-generators.
+supported only on the :generator:`Ninja` and :ref:`Makefile Generators`
+and will be ignored on other generators.
diff --git a/Help/prop_sf/SKIP_AUTOGEN.rst b/Help/prop_sf/SKIP_AUTOGEN.rst
index 6bf2409b2..f31185a5b 100644
--- a/Help/prop_sf/SKIP_AUTOGEN.rst
+++ b/Help/prop_sf/SKIP_AUTOGEN.rst
@@ -4,5 +4,14 @@ SKIP_AUTOGEN
Exclude the source file from :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTOUIC` and
:prop_tgt:`AUTORCC` processing (for Qt projects).
-For finer control see :prop_sf:`SKIP_AUTOMOC`, :prop_sf:`SKIP_AUTOUIC` and
-:prop_sf:`SKIP_AUTORCC`.
+For finer exclusion control see :prop_sf:`SKIP_AUTOMOC`,
+:prop_sf:`SKIP_AUTOUIC` and :prop_sf:`SKIP_AUTORCC`.
+
+EXAMPLE
+^^^^^^^
+
+.. code-block:: cmake
+
+ # ...
+ set_property(SOURCE file.h PROPERTY SKIP_AUTOGEN ON)
+ # ...
diff --git a/Help/prop_sf/SKIP_AUTOMOC.rst b/Help/prop_sf/SKIP_AUTOMOC.rst
index 2245ca639..a9294489a 100644
--- a/Help/prop_sf/SKIP_AUTOMOC.rst
+++ b/Help/prop_sf/SKIP_AUTOMOC.rst
@@ -3,4 +3,13 @@ SKIP_AUTOMOC
Exclude the source file from :prop_tgt:`AUTOMOC` processing (for Qt projects).
-For broader control see :prop_sf:`SKIP_AUTOGEN`
+For broader exclusion control see :prop_sf:`SKIP_AUTOGEN`.
+
+EXAMPLE
+^^^^^^^
+
+.. code-block:: cmake
+
+ # ...
+ set_property(SOURCE file.h PROPERTY SKIP_AUTOMOC ON)
+ # ...
diff --git a/Help/prop_sf/SKIP_AUTORCC.rst b/Help/prop_sf/SKIP_AUTORCC.rst
index 394d8f8cf..bccccfc93 100644
--- a/Help/prop_sf/SKIP_AUTORCC.rst
+++ b/Help/prop_sf/SKIP_AUTORCC.rst
@@ -3,4 +3,13 @@ SKIP_AUTORCC
Exclude the source file from :prop_tgt:`AUTORCC` processing (for Qt projects).
-For broader control see :prop_sf:`SKIP_AUTOGEN`
+For broader exclusion control see :prop_sf:`SKIP_AUTOGEN`.
+
+EXAMPLE
+^^^^^^^
+
+.. code-block:: cmake
+
+ # ...
+ set_property(SOURCE file.qrc PROPERTY SKIP_AUTORCC ON)
+ # ...
diff --git a/Help/prop_sf/SKIP_AUTOUIC.rst b/Help/prop_sf/SKIP_AUTOUIC.rst
index 50f78ef66..8c962dbfe 100644
--- a/Help/prop_sf/SKIP_AUTOUIC.rst
+++ b/Help/prop_sf/SKIP_AUTOUIC.rst
@@ -3,4 +3,18 @@ SKIP_AUTOUIC
Exclude the source file from :prop_tgt:`AUTOUIC` processing (for Qt projects).
-For broader control see :prop_sf:`SKIP_AUTOGEN`
+:prop_sf:`SKIP_AUTOUIC` can be set on C++ header and source files and on
+``.ui`` files.
+
+For broader exclusion control see :prop_sf:`SKIP_AUTOGEN`.
+
+EXAMPLE
+^^^^^^^
+
+.. code-block:: cmake
+
+ # ...
+ set_property(SOURCE file.h PROPERTY SKIP_AUTOUIC ON)
+ set_property(SOURCE file.cpp PROPERTY SKIP_AUTOUIC ON)
+ set_property(SOURCE widget.ui PROPERTY SKIP_AUTOUIC ON)
+ # ...
diff --git a/Help/prop_sf/SKIP_PRECOMPILE_HEADERS.rst b/Help/prop_sf/SKIP_PRECOMPILE_HEADERS.rst
new file mode 100644
index 000000000..5f39f30aa
--- /dev/null
+++ b/Help/prop_sf/SKIP_PRECOMPILE_HEADERS.rst
@@ -0,0 +1,13 @@
+SKIP_PRECOMPILE_HEADERS
+-----------------------
+
+Is this source file skipped by :prop_tgt:`PRECOMPILE_HEADERS` feature.
+
+This property helps with build problems that one would run into
+when using the :prop_tgt:`PRECOMPILE_HEADERS` feature.
+
+One example would be the usage of Objective-C (*.m) files, and
+Objective-C++ (*.mm) files, which lead to compilation failure
+because they are treated (in case of Ninja / Makefile generator)
+as C, and CXX respectively. The precompile headers are not
+compatible between languages.
diff --git a/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst b/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst
new file mode 100644
index 000000000..6d1e60d4a
--- /dev/null
+++ b/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst
@@ -0,0 +1,11 @@
+SKIP_UNITY_BUILD_INCLUSION
+--------------------------
+
+Setting this property to true ensures the source file will be skipped by
+unity builds when its associated target has its :prop_tgt:`UNITY_BUILD`
+property set to true. The source file will instead be compiled on its own
+in the same way as it would with unity builds disabled.
+
+This property helps with "ODR (One definition rule)" problems where combining
+a particular source file with others might lead to build errors or other
+unintended side effects.
diff --git a/Help/prop_sf/SYMBOLIC.rst b/Help/prop_sf/SYMBOLIC.rst
index c7d0b2603..8bebe30bb 100644
--- a/Help/prop_sf/SYMBOLIC.rst
+++ b/Help/prop_sf/SYMBOLIC.rst
@@ -3,6 +3,6 @@ SYMBOLIC
Is this just a name for a rule.
-If SYMBOLIC (boolean) is set to true the build system will be informed
+If ``SYMBOLIC`` (boolean) is set to ``True`` the build system will be informed
that the source file is not actually created on disk but instead used
as a symbolic name for a build rule.
diff --git a/Help/prop_sf/Swift_DEPENDENCIES_FILE.rst b/Help/prop_sf/Swift_DEPENDENCIES_FILE.rst
new file mode 100644
index 000000000..faac2df7b
--- /dev/null
+++ b/Help/prop_sf/Swift_DEPENDENCIES_FILE.rst
@@ -0,0 +1,5 @@
+Swift_DEPENDENCIES_FILE
+-----------------------
+
+This property sets the path for the Swift dependency file (swiftdeps) for the
+source. If one is not specified, it will default to ``<OBJECT>.swiftdeps``.
diff --git a/Help/prop_sf/Swift_DIAGNOSTICS_FILE.rst b/Help/prop_sf/Swift_DIAGNOSTICS_FILE.rst
new file mode 100644
index 000000000..5bf5d59cd
--- /dev/null
+++ b/Help/prop_sf/Swift_DIAGNOSTICS_FILE.rst
@@ -0,0 +1,4 @@
+Swift_DIAGNOSTICS_FILE
+----------------------
+
+This property controls where the Swift diagnostics are serialized.
diff --git a/Help/prop_sf/VS_CSHARP_tagname.rst b/Help/prop_sf/VS_CSHARP_tagname.rst
index d42159f6d..91c4a06c1 100644
--- a/Help/prop_sf/VS_CSHARP_tagname.rst
+++ b/Help/prop_sf/VS_CSHARP_tagname.rst
@@ -3,8 +3,9 @@ VS_CSHARP_<tagname>
Visual Studio and CSharp source-file-specific configuration.
-Tell the Visual Studio generator to set the source file tag
-``<tagname>`` to a given value in the generated Visual Studio CSharp
+Tell the :manual:`Visual Studio generators <cmake-generators(7)>`
+to set the source file tag ``<tagname>``
+to a given value in the generated Visual Studio CSharp
project. Ignored on other generators and languages. This property
can be used to define dependencies between source files or set any
other Visual Studio specific parameters.
diff --git a/Help/prop_sf/VS_DEPLOYMENT_CONTENT.rst b/Help/prop_sf/VS_DEPLOYMENT_CONTENT.rst
index 9fb3ba3d0..6a38478fe 100644
--- a/Help/prop_sf/VS_DEPLOYMENT_CONTENT.rst
+++ b/Help/prop_sf/VS_DEPLOYMENT_CONTENT.rst
@@ -2,7 +2,8 @@ VS_DEPLOYMENT_CONTENT
---------------------
Mark a source file as content for deployment with a Windows Phone or
-Windows Store application when built with a Visual Studio generator.
+Windows Store application when built with a
+:manual:`Visual Studio generators <cmake-generators(7)>`.
The value must evaluate to either ``1`` or ``0`` and may use
:manual:`generator expressions <cmake-generator-expressions(7)>`
to make the choice based on the build configuration.
diff --git a/Help/prop_sf/VS_DEPLOYMENT_LOCATION.rst b/Help/prop_sf/VS_DEPLOYMENT_LOCATION.rst
index 303db952b..2ce22fced 100644
--- a/Help/prop_sf/VS_DEPLOYMENT_LOCATION.rst
+++ b/Help/prop_sf/VS_DEPLOYMENT_LOCATION.rst
@@ -2,7 +2,8 @@ VS_DEPLOYMENT_LOCATION
----------------------
Specifies the deployment location for a content source file with a Windows
-Phone or Windows Store application when built with a Visual Studio generator.
+Phone or Windows Store application when built
+with a :manual:`Visual Studio generators <cmake-generators(7)>`.
This property is only applicable when using :prop_sf:`VS_DEPLOYMENT_CONTENT`.
The value represent the path relative to the app package and applies to all
configurations.
diff --git a/Help/prop_sf/VS_INCLUDE_IN_VSIX.rst b/Help/prop_sf/VS_INCLUDE_IN_VSIX.rst
index 30f471d30..db470ef00 100644
--- a/Help/prop_sf/VS_INCLUDE_IN_VSIX.rst
+++ b/Help/prop_sf/VS_INCLUDE_IN_VSIX.rst
@@ -1,6 +1,6 @@
VS_INCLUDE_IN_VSIX
------------------
-Boolean property to specify if the file should be included within a VSIX
-extension package. This is needed for development of Visual Studio
-extensions.
+Boolean property to specify if the file should be included within a
+VSIX (Visual Studio Integration Extension) extension package.
+This is needed for development of Visual Studio extensions.
diff --git a/Help/prop_sf/VS_SHADER_DISABLE_OPTIMIZATIONS.rst b/Help/prop_sf/VS_SHADER_DISABLE_OPTIMIZATIONS.rst
new file mode 100644
index 000000000..446dd26d9
--- /dev/null
+++ b/Help/prop_sf/VS_SHADER_DISABLE_OPTIMIZATIONS.rst
@@ -0,0 +1,6 @@
+VS_SHADER_DISABLE_OPTIMIZATIONS
+-------------------------------
+
+Disable compiler optimizations for an ``.hlsl`` source file. This adds the
+``-Od`` flag to the command line for the FxCompiler tool. Specify the value
+``true`` for this property to disable compiler optimizations.
diff --git a/Help/prop_sf/VS_SHADER_ENABLE_DEBUG.rst b/Help/prop_sf/VS_SHADER_ENABLE_DEBUG.rst
new file mode 100644
index 000000000..c0e60a3e3
--- /dev/null
+++ b/Help/prop_sf/VS_SHADER_ENABLE_DEBUG.rst
@@ -0,0 +1,6 @@
+VS_SHADER_ENABLE_DEBUG
+----------------------
+
+Enable debugging information for an ``.hlsl`` source file. This adds the
+``-Zi`` flag to the command line for the FxCompiler tool. Specify the value
+``true`` to generate debugging information for the compiled shader.
diff --git a/Help/prop_sf/VS_SHADER_FLAGS.rst b/Help/prop_sf/VS_SHADER_FLAGS.rst
index 09011231b..0a53afd1c 100644
--- a/Help/prop_sf/VS_SHADER_FLAGS.rst
+++ b/Help/prop_sf/VS_SHADER_FLAGS.rst
@@ -1,4 +1,4 @@
VS_SHADER_FLAGS
---------------
-Set additional VS shader flags of a ``.hlsl`` source file.
+Set additional Visual Studio shader flags of a ``.hlsl`` source file.
diff --git a/Help/prop_sf/VS_SHADER_OBJECT_FILE_NAME.rst b/Help/prop_sf/VS_SHADER_OBJECT_FILE_NAME.rst
new file mode 100644
index 000000000..093bcc666
--- /dev/null
+++ b/Help/prop_sf/VS_SHADER_OBJECT_FILE_NAME.rst
@@ -0,0 +1,6 @@
+VS_SHADER_OBJECT_FILE_NAME
+--------------------------
+
+Specifies a file name for the compiled shader object file for an ``.hlsl``
+source file. This adds the ``-Fo`` flag to the command line for the FxCompiler
+tool.
diff --git a/Help/prop_sf/VS_SHADER_OUTPUT_HEADER_FILE.rst b/Help/prop_sf/VS_SHADER_OUTPUT_HEADER_FILE.rst
new file mode 100644
index 000000000..e6763d332
--- /dev/null
+++ b/Help/prop_sf/VS_SHADER_OUTPUT_HEADER_FILE.rst
@@ -0,0 +1,5 @@
+VS_SHADER_OUTPUT_HEADER_FILE
+----------------------------
+
+Set filename for output header file containing object code of a ``.hlsl``
+source file.
diff --git a/Help/prop_sf/VS_SHADER_TYPE.rst b/Help/prop_sf/VS_SHADER_TYPE.rst
index 688025608..f1048379a 100644
--- a/Help/prop_sf/VS_SHADER_TYPE.rst
+++ b/Help/prop_sf/VS_SHADER_TYPE.rst
@@ -1,4 +1,4 @@
VS_SHADER_TYPE
--------------
-Set the VS shader type of a ``.hlsl`` source file.
+Set the Visual Studio shader type of a ``.hlsl`` source file.
diff --git a/Help/prop_sf/VS_SHADER_VARIABLE_NAME.rst b/Help/prop_sf/VS_SHADER_VARIABLE_NAME.rst
new file mode 100644
index 000000000..1a5e36921
--- /dev/null
+++ b/Help/prop_sf/VS_SHADER_VARIABLE_NAME.rst
@@ -0,0 +1,5 @@
+VS_SHADER_VARIABLE_NAME
+-----------------------
+
+Set name of variable in header file containing object code of a ``.hlsl``
+source file.
diff --git a/Help/prop_sf/VS_XAML_TYPE.rst b/Help/prop_sf/VS_XAML_TYPE.rst
index e92191dcb..1a274ba4e 100644
--- a/Help/prop_sf/VS_XAML_TYPE.rst
+++ b/Help/prop_sf/VS_XAML_TYPE.rst
@@ -1,6 +1,7 @@
VS_XAML_TYPE
------------
-Mark a XAML source file as a different type than the default ``Page``.
-The most common usage would be to set the default App.xaml file as
-ApplicationDefinition.
+Mark a Extensible Application Markup Language (XAML) source file
+as a different type than the default ``Page``.
+The most common usage would be to set the default ``App.xaml`` file as
+``ApplicationDefinition``.
diff --git a/Help/prop_sf/WRAP_EXCLUDE.rst b/Help/prop_sf/WRAP_EXCLUDE.rst
index 2c79f72a2..638ff0398 100644
--- a/Help/prop_sf/WRAP_EXCLUDE.rst
+++ b/Help/prop_sf/WRAP_EXCLUDE.rst
@@ -4,7 +4,8 @@ WRAP_EXCLUDE
Exclude this source file from any code wrapping techniques.
Some packages can wrap source files into alternate languages to
-provide additional functionality. For example, C++ code can be
-wrapped into Java or Python etc using SWIG etc. If WRAP_EXCLUDE is
-set to true (1 etc) that indicates that this source file should not be
-wrapped.
+provide additional functionality.
+
+For example, C++ code can be wrapped into Java or Python, using SWIG.
+If ``WRAP_EXCLUDE`` is set to ``True``, that indicates that this
+source file should not be wrapped.
diff --git a/Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst b/Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst
index 1b24701a3..b8cf946ea 100644
--- a/Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst
+++ b/Help/prop_sf/XCODE_EXPLICIT_FILE_TYPE.rst
@@ -1,7 +1,7 @@
XCODE_EXPLICIT_FILE_TYPE
------------------------
-Set the Xcode ``explicitFileType`` attribute on its reference to a
+Set the :generator:`Xcode` ``explicitFileType`` attribute on its reference to a
source file. CMake computes a default based on file extension but
can be told explicitly with this property.
diff --git a/Help/prop_sf/XCODE_FILE_ATTRIBUTES.rst b/Help/prop_sf/XCODE_FILE_ATTRIBUTES.rst
index 39e69665a..4c93f444a 100644
--- a/Help/prop_sf/XCODE_FILE_ATTRIBUTES.rst
+++ b/Help/prop_sf/XCODE_FILE_ATTRIBUTES.rst
@@ -1,9 +1,9 @@
XCODE_FILE_ATTRIBUTES
---------------------
-Add values to the Xcode ``ATTRIBUTES`` setting on its reference to a
+Add values to the :generator:`Xcode` ``ATTRIBUTES`` setting on its reference to a
source file. Among other things, this can be used to set the role on
-a mig file::
+a ``.mig`` file::
set_source_files_properties(defs.mig
PROPERTIES
diff --git a/Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst b/Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst
index 42e37574d..b21891fce 100644
--- a/Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst
+++ b/Help/prop_sf/XCODE_LAST_KNOWN_FILE_TYPE.rst
@@ -1,8 +1,8 @@
XCODE_LAST_KNOWN_FILE_TYPE
--------------------------
-Set the Xcode ``lastKnownFileType`` attribute on its reference to a
-source file. CMake computes a default based on file extension but
+Set the :generator:`Xcode` ``lastKnownFileType`` attribute on its reference to
+a source file. CMake computes a default based on file extension but
can be told explicitly with this property.
See also :prop_sf:`XCODE_EXPLICIT_FILE_TYPE`, which is preferred
diff --git a/Help/prop_test/COST.rst b/Help/prop_test/COST.rst
index 3236a0295..9300d7b27 100644
--- a/Help/prop_test/COST.rst
+++ b/Help/prop_test/COST.rst
@@ -1,7 +1,14 @@
COST
----
-Set this to a floating point value. Tests in a test set will be run in descending order of cost.
+This property describes the cost of a test. When parallel testing is
+enabled, tests in the test set will be run in descending order of cost.
+Projects can explicitly define the cost of a test by setting this property
+to a floating point value.
-This property describes the cost of a test. You can explicitly set
-this value; tests with higher COST values will run first.
+When the cost of a test is not defined by the project,
+:manual:`ctest <ctest(1)>` will initially use a default cost of ``0``.
+It computes a weighted average of the cost each time a test is run and
+uses that as an improved estimate of the cost for the next run. The more
+a test is re-run in the same build directory, the more representative the
+cost should become.
diff --git a/Help/prop_test/DISABLED.rst b/Help/prop_test/DISABLED.rst
index c18ae7ffa..1d469e80b 100644
--- a/Help/prop_test/DISABLED.rst
+++ b/Help/prop_test/DISABLED.rst
@@ -1,15 +1,15 @@
DISABLED
--------
-If set to true, the test will be skipped and its status will be 'Not Run'. A
-DISABLED test will not be counted in the total number of tests and its
-completion status will be reported to CDash as 'Disabled'.
+If set to ``True``, the test will be skipped and its status will be 'Not Run'. A
+``DISABLED`` test will not be counted in the total number of tests and its
+completion status will be reported to CDash as ``Disabled``.
-A DISABLED test does not participate in test fixture dependency resolution.
-If a DISABLED test has fixture requirements defined in its
+A ``DISABLED`` test does not participate in test fixture dependency resolution.
+If a ``DISABLED`` test has fixture requirements defined in its
:prop_test:`FIXTURES_REQUIRED` property, it will not cause setup or cleanup
tests for those fixtures to be added to the test set.
-If a test with the :prop_test:`FIXTURES_SETUP` property set is DISABLED, the
-fixture behavior will be as though that setup test was passing and any test
+If a test with the :prop_test:`FIXTURES_SETUP` property set is ``DISABLED``,
+the fixture behavior will be as though that setup test was passing and any test
case requiring that fixture will still run.
diff --git a/Help/prop_test/ENVIRONMENT.rst b/Help/prop_test/ENVIRONMENT.rst
index df9bc9e14..102c7922f 100644
--- a/Help/prop_test/ENVIRONMENT.rst
+++ b/Help/prop_test/ENVIRONMENT.rst
@@ -4,6 +4,6 @@ ENVIRONMENT
Specify environment variables that should be defined for running a test.
If set to a list of environment variables and values of the form
-MYVAR=value those environment variables will be defined while running
+``MYVAR=value`` those environment variables will be defined while running
the test. The environment is restored to its previous state after the
test is done.
diff --git a/Help/prop_test/FIXTURES_CLEANUP.rst b/Help/prop_test/FIXTURES_CLEANUP.rst
index f0a4be0ec..3075b4d48 100644
--- a/Help/prop_test/FIXTURES_CLEANUP.rst
+++ b/Help/prop_test/FIXTURES_CLEANUP.rst
@@ -2,7 +2,8 @@ FIXTURES_CLEANUP
----------------
Specifies a list of fixtures for which the test is to be treated as a cleanup
-test.
+test. These fixture names are distinct from test case names and are not
+required to have any similarity to the names of tests associated with them.
Fixture cleanup tests are ordinary tests with all of the usual test
functionality. Setting the ``FIXTURES_CLEANUP`` property for a test has two
diff --git a/Help/prop_test/FIXTURES_REQUIRED.rst b/Help/prop_test/FIXTURES_REQUIRED.rst
index e37dfb57d..e3f60c426 100644
--- a/Help/prop_test/FIXTURES_REQUIRED.rst
+++ b/Help/prop_test/FIXTURES_REQUIRED.rst
@@ -2,7 +2,7 @@ FIXTURES_REQUIRED
-----------------
Specifies a list of fixtures the test requires. Fixture names are case
-sensitive.
+sensitive and they are not required to have any similarity to test names.
Fixtures are a way to attach setup and cleanup tasks to a set of tests. If a
test requires a given fixture, then all tests marked as setup tasks for that
@@ -19,7 +19,9 @@ some setup tests fail.
When CTest is asked to execute only a subset of tests (e.g. by the use of
regular expressions or when run with the ``--rerun-failed`` command line
option), it will automatically add any setup or cleanup tests for fixtures
-required by any of the tests that are in the execution set.
+required by any of the tests that are in the execution set. This behavior can
+be overridden with the ``-FS``, ``-FC`` and ``-FA`` command line options to
+:manual:`ctest(1)` if desired.
Since setup and cleanup tasks are also tests, they can have an ordering
specified by the :prop_test:`DEPENDS` test property just like any other tests.
diff --git a/Help/prop_test/FIXTURES_SETUP.rst b/Help/prop_test/FIXTURES_SETUP.rst
index a22021592..fdb21cc76 100644
--- a/Help/prop_test/FIXTURES_SETUP.rst
+++ b/Help/prop_test/FIXTURES_SETUP.rst
@@ -2,14 +2,15 @@ FIXTURES_SETUP
--------------
Specifies a list of fixtures for which the test is to be treated as a setup
-test.
+test. These fixture names are distinct from test case names and are not
+required to have any similarity to the names of tests associated with them.
Fixture setup tests are ordinary tests with all of the usual test
functionality. Setting the ``FIXTURES_SETUP`` property for a test has two
primary effects:
- CTest will ensure the test executes before any other test which lists the
- fixture(s) in its :prop_test:`FIXTURES_REQUIRED` property.
+ fixture name(s) in its :prop_test:`FIXTURES_REQUIRED` property.
- If CTest is asked to run only a subset of tests (e.g. using regular
expressions or the ``--rerun-failed`` option) and the setup test is not in
diff --git a/Help/prop_test/MEASUREMENT.rst b/Help/prop_test/MEASUREMENT.rst
index bc4936e97..de459ed4e 100644
--- a/Help/prop_test/MEASUREMENT.rst
+++ b/Help/prop_test/MEASUREMENT.rst
@@ -1,8 +1,8 @@
MEASUREMENT
-----------
-Specify a CDASH measurement and value to be reported for a test.
+Specify a ``CDASH`` measurement and value to be reported for a test.
-If set to a name then that name will be reported to CDASH as a named
-measurement with a value of 1. You may also specify a value by
-setting MEASUREMENT to "measurement=value".
+If set to a name then that name will be reported to ``CDASH`` as a named
+measurement with a value of ``1``. You may also specify a value by
+setting ``MEASUREMENT`` to ``measurement=value``.
diff --git a/Help/prop_test/PROCESSORS.rst b/Help/prop_test/PROCESSORS.rst
index 763b6d003..a927c1078 100644
--- a/Help/prop_test/PROCESSORS.rst
+++ b/Help/prop_test/PROCESSORS.rst
@@ -1,8 +1,16 @@
PROCESSORS
----------
-How many process slots this test requires
+Set to specify how many process slots this test requires.
+If not set, the default is ``1`` processor.
Denotes the number of processors that this test will require. This is
typically used for MPI tests, and should be used in conjunction with
-the ctest_test PARALLEL_LEVEL option.
+the :command:`ctest_test` ``PARALLEL_LEVEL`` option.
+
+This will also be used to display a weighted test timing result in label and
+subproject summaries in the command line output of :manual:`ctest(1)`. The wall
+clock time for the test run will be multiplied by this property to give a
+better idea of how much cpu resource CTest allocated for the test.
+
+See also the :prop_test:`PROCESSOR_AFFINITY` test property.
diff --git a/Help/prop_test/PROCESSOR_AFFINITY.rst b/Help/prop_test/PROCESSOR_AFFINITY.rst
new file mode 100644
index 000000000..38ec17947
--- /dev/null
+++ b/Help/prop_test/PROCESSOR_AFFINITY.rst
@@ -0,0 +1,11 @@
+PROCESSOR_AFFINITY
+------------------
+
+Set to a true value to ask CTest to launch the test process with CPU affinity
+for a fixed set of processors. If enabled and supported for the current
+platform, CTest will choose a set of processors to place in the CPU affinity
+mask when launching the test process. The number of processors in the set is
+determined by the :prop_test:`PROCESSORS` test property or the number of
+processors available to CTest, whichever is smaller. The set of processors
+chosen will be disjoint from the processors assigned to other concurrently
+running tests that also have the ``PROCESSOR_AFFINITY`` property enabled.
diff --git a/Help/prop_test/RESOURCE_GROUPS.rst b/Help/prop_test/RESOURCE_GROUPS.rst
new file mode 100644
index 000000000..63c56ce55
--- /dev/null
+++ b/Help/prop_test/RESOURCE_GROUPS.rst
@@ -0,0 +1,70 @@
+RESOURCE_GROUPS
+---------------
+
+Specify resources required by a test, grouped in a way that is meaningful to
+the test. See :ref:`resource allocation <ctest-resource-allocation>`
+for more information on how this property integrates into the CTest resource
+allocation feature.
+
+The ``RESOURCE_GROUPS`` property is a :ref:`semicolon-separated list <CMake
+Language Lists>` of group descriptions. Each entry consists of an optional
+number of groups using the description followed by a series of resource
+requirements for those groups. These requirements (and the number of groups)
+are separated by commas. The resource requirements consist of the name of a
+resource type, followed by a colon, followed by an unsigned integer
+specifying the number of slots required on one resource of the given type.
+
+The ``RESOURCE_GROUPS`` property tells CTest what resources a test expects
+to use grouped in a way meaningful to the test. The test itself must read
+the :ref:`environment variables <ctest-resource-environment-variables>` to
+determine which resources have been allocated to each group. For example,
+each group may correspond to a process the test will spawn when executed.
+
+Consider the following example:
+
+.. code-block:: cmake
+
+ add_test(NAME MyTest COMMAND MyExe)
+ set_property(TEST MyTest PROPERTY RESOURCE_GROUPS
+ "2,gpus:2"
+ "gpus:4,crypto_chips:2")
+
+In this example, there are two group descriptions (implicitly separated by a
+semicolon.) The content of the first description is ``2,gpus:2``. This
+description specifies 2 groups, each of which requires 2 slots from a single
+GPU. The content of the second description is ``gpus:4,crypto_chips:2``. This
+description does not specify a group count, so a default of 1 is assumed.
+This single group requires 4 slots from a single GPU and 2 slots from a
+single cryptography chip. In total, 3 resource groups are specified for this
+test, each with its own unique requirements.
+
+Note that the number of slots following the resource type specifies slots from
+a *single* instance of the resource. If the resource group can tolerate
+receiving slots from different instances of the same resource, it can indicate
+this by splitting the specification into multiple requirements of one slot. For
+example:
+
+.. code-block:: cmake
+
+ add_test(NAME MyTest COMMAND MyExe)
+ set_property(TEST MyTest PROPERTY RESOURCE_GROUPS
+ "gpus:1,gpus:1,gpus:1,gpus:1")
+
+In this case, the single resource group indicates that it needs four GPU slots,
+all of which may come from separate GPUs (though they don't have to; CTest may
+still assign slots from the same GPU.)
+
+When CTest sets the :ref:`environment variables
+<ctest-resource-environment-variables>` for a test, it assigns a group number
+based on the group description, starting at 0 on the left and the number of
+groups minus 1 on the right. For example, in the example above, the two
+groups in the first description would have IDs of 0 and 1, and the single
+group in the second description would have an ID of 2.
+
+Both the ``RESOURCE_GROUPS`` and :prop_test:`RESOURCE_LOCK` properties serve
+similar purposes, but they are distinct and orthogonal. Resources specified by
+``RESOURCE_GROUPS`` do not affect :prop_test:`RESOURCE_LOCK`, and vice versa.
+Whereas :prop_test:`RESOURCE_LOCK` is a simpler property that is used for
+locking one global resource, ``RESOURCE_GROUPS`` is a more advanced property
+that allows multiple tests to simultaneously use multiple resources of the
+same type, specifying their requirements in a fine-grained manner.
diff --git a/Help/prop_test/RESOURCE_LOCK.rst b/Help/prop_test/RESOURCE_LOCK.rst
index 755e0aaa3..8b13a01d4 100644
--- a/Help/prop_test/RESOURCE_LOCK.rst
+++ b/Help/prop_test/RESOURCE_LOCK.rst
@@ -8,3 +8,11 @@ not to run concurrently.
See also :prop_test:`FIXTURES_REQUIRED` if the resource requires any setup or
cleanup steps.
+
+Both the :prop_test:`RESOURCE_GROUPS` and ``RESOURCE_LOCK`` properties serve
+similar purposes, but they are distinct and orthogonal. Resources specified by
+:prop_test:`RESOURCE_GROUPS` do not affect ``RESOURCE_LOCK``, and vice versa.
+Whereas ``RESOURCE_LOCK`` is a simpler property that is used for locking one
+global resource, :prop_test:`RESOURCE_GROUPS` is a more advanced property
+that allows multiple tests to simultaneously use multiple resources of the
+same type, specifying their requirements in a fine-grained manner.
diff --git a/Help/prop_test/RUN_SERIAL.rst b/Help/prop_test/RUN_SERIAL.rst
index 8f65ae18a..ab4c54233 100644
--- a/Help/prop_test/RUN_SERIAL.rst
+++ b/Help/prop_test/RUN_SERIAL.rst
@@ -3,6 +3,6 @@ RUN_SERIAL
Do not run this test in parallel with any other test.
-Use this option in conjunction with the ctest_test PARALLEL_LEVEL
+Use this option in conjunction with the ctest_test ``PARALLEL_LEVEL``
option to specify that this test should not be run in parallel with
any other tests.
diff --git a/Help/prop_test/SKIP_REGULAR_EXPRESSION.rst b/Help/prop_test/SKIP_REGULAR_EXPRESSION.rst
new file mode 100644
index 000000000..2c6d98049
--- /dev/null
+++ b/Help/prop_test/SKIP_REGULAR_EXPRESSION.rst
@@ -0,0 +1,17 @@
+SKIP_REGULAR_EXPRESSION
+-----------------------
+
+If the output matches this regular expression the test will be marked as skipped.
+
+If set, if the output matches one of specified regular expressions,
+the test will be marked as skipped. Example:
+
+.. code-block:: cmake
+
+ set_property(TEST mytest PROPERTY
+ SKIP_REGULAR_EXPRESSION "[^a-z]Skip" "SKIP" "Skipped"
+ )
+
+``SKIP_REGULAR_EXPRESSION`` expects a list of regular expressions.
+
+See also the :prop_test:`SKIP_RETURN_CODE` property.
diff --git a/Help/prop_test/SKIP_RETURN_CODE.rst b/Help/prop_test/SKIP_RETURN_CODE.rst
index c61273c56..23c4c625f 100644
--- a/Help/prop_test/SKIP_RETURN_CODE.rst
+++ b/Help/prop_test/SKIP_RETURN_CODE.rst
@@ -6,4 +6,7 @@ Return code to mark a test as skipped.
Sometimes only a test itself can determine if all requirements for the
test are met. If such a situation should not be considered a hard failure
a return code of the process can be specified that will mark the test as
-"Not Run" if it is encountered.
+``Not Run`` if it is encountered. Valid values are in the range of
+0 to 255, inclusive.
+
+See also the :prop_test:`SKIP_REGULAR_EXPRESSION` property.
diff --git a/Help/prop_test/WORKING_DIRECTORY.rst b/Help/prop_test/WORKING_DIRECTORY.rst
index 5222a197b..92a040967 100644
--- a/Help/prop_test/WORKING_DIRECTORY.rst
+++ b/Help/prop_test/WORKING_DIRECTORY.rst
@@ -3,5 +3,7 @@ WORKING_DIRECTORY
The directory from which the test executable will be called.
-If this is not set it is called from the directory the test executable
-is located in.
+If this is not set, the test will be run with the working directory set to the
+binary directory associated with where the test was created (i.e. the
+:variable:`CMAKE_CURRENT_BINARY_DIR` for where :command:`add_test` was
+called).
diff --git a/Help/prop_tgt/ADDITIONAL_CLEAN_FILES.rst b/Help/prop_tgt/ADDITIONAL_CLEAN_FILES.rst
new file mode 100644
index 000000000..3b9d965f8
--- /dev/null
+++ b/Help/prop_tgt/ADDITIONAL_CLEAN_FILES.rst
@@ -0,0 +1,23 @@
+ADDITIONAL_CLEAN_FILES
+----------------------
+
+A :ref:`;-list <CMake Language Lists>` of files or directories that will be
+removed as a part of the global ``clean`` target. It can be used to specify
+files and directories that are generated as part of building the target or
+that are directly associated with the target in some way (e.g. created as a
+result of running the target).
+
+For custom targets, if such files can be captured as outputs or byproducts
+instead, then that should be preferred over adding them to this property.
+If an additional clean file is used by multiple targets or isn't
+target-specific, then the :prop_dir:`ADDITIONAL_CLEAN_FILES` directory
+property may be the more appropriate property to use.
+
+Relative paths are allowed and are interpreted relative to the
+current binary directory.
+
+Contents of ``ADDITIONAL_CLEAN_FILES`` may use
+:manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+This property only works for the :generator:`Ninja` and the Makefile
+generators. It is ignored by other generators.
diff --git a/Help/prop_tgt/ANDROID_NATIVE_LIB_DIRECTORIES.rst b/Help/prop_tgt/ANDROID_NATIVE_LIB_DIRECTORIES.rst
index bc673804d..d0cd29de8 100644
--- a/Help/prop_tgt/ANDROID_NATIVE_LIB_DIRECTORIES.rst
+++ b/Help/prop_tgt/ANDROID_NATIVE_LIB_DIRECTORIES.rst
@@ -1,8 +1,8 @@
ANDROID_NATIVE_LIB_DIRECTORIES
------------------------------
-Set the Android property that specifies directories to search for the
-.so libraries.
+Set the Android property that specifies directories to search for the ``.so``
+libraries.
This a string property that contains the directory paths separated
by semicolons.
diff --git a/Help/prop_tgt/AUTOGEN_BUILD_DIR.rst b/Help/prop_tgt/AUTOGEN_BUILD_DIR.rst
index 8db6ede91..909b14c34 100644
--- a/Help/prop_tgt/AUTOGEN_BUILD_DIR.rst
+++ b/Help/prop_tgt/AUTOGEN_BUILD_DIR.rst
@@ -5,7 +5,7 @@ Directory where :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTOUIC` and :prop_tgt:`AUTORCC`
generate files for the target.
The directory is created on demand and automatically added to the
-:prop_dir:`ADDITIONAL_MAKE_CLEAN_FILES`.
+:prop_tgt:`ADDITIONAL_CLEAN_FILES` target property.
When unset or empty the directory ``<dir>/<target-name>_autogen`` is used where
``<dir>`` is :variable:`CMAKE_CURRENT_BINARY_DIR` and ``<target-name>``
diff --git a/Help/prop_tgt/AUTOGEN_ORIGIN_DEPENDS.rst b/Help/prop_tgt/AUTOGEN_ORIGIN_DEPENDS.rst
new file mode 100644
index 000000000..022bab502
--- /dev/null
+++ b/Help/prop_tgt/AUTOGEN_ORIGIN_DEPENDS.rst
@@ -0,0 +1,38 @@
+AUTOGEN_ORIGIN_DEPENDS
+----------------------
+
+Switch for forwarding origin target dependencies to the corresponding
+``_autogen`` target.
+
+Targets which have their :prop_tgt:`AUTOMOC` or :prop_tgt:`AUTOUIC` property
+``ON`` have a corresponding ``_autogen`` target which generates
+``moc`` and ``uic`` files. As this ``_autogen`` target is created at
+generate-time, it is not possible to define dependencies of it using
+e.g. :command:`add_dependencies`. Instead the
+:prop_tgt:`AUTOGEN_ORIGIN_DEPENDS` target property decides whether the origin
+target dependencies should be forwarded to the ``_autogen`` target or not.
+
+By default :prop_tgt:`AUTOGEN_ORIGIN_DEPENDS` is initialized from
+:variable:`CMAKE_AUTOGEN_ORIGIN_DEPENDS` which is ``ON`` by default.
+
+In total the dependencies of the ``_autogen`` target are composed from
+
+- forwarded origin target dependencies
+ (enabled by default via :prop_tgt:`AUTOGEN_ORIGIN_DEPENDS`)
+- additional user defined dependencies from :prop_tgt:`AUTOGEN_TARGET_DEPENDS`
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
+
+Note
+^^^^
+
+Disabling :prop_tgt:`AUTOGEN_ORIGIN_DEPENDS` is useful to avoid building of
+origin target dependencies when building the ``_autogen`` target only.
+This is especially interesting when a
+:variable:`global autogen target <CMAKE_GLOBAL_AUTOGEN_TARGET>` is enabled.
+
+When the ``_autogen`` target doesn't require all the origin target's
+dependencies, and :prop_tgt:`AUTOGEN_ORIGIN_DEPENDS` is disabled, it might be
+necessary to extend :prop_tgt:`AUTOGEN_TARGET_DEPENDS` to add missing
+dependencies.
diff --git a/Help/prop_tgt/AUTOGEN_PARALLEL.rst b/Help/prop_tgt/AUTOGEN_PARALLEL.rst
new file mode 100644
index 000000000..07fbc5a5e
--- /dev/null
+++ b/Help/prop_tgt/AUTOGEN_PARALLEL.rst
@@ -0,0 +1,21 @@
+AUTOGEN_PARALLEL
+----------------
+
+Number of parallel ``moc`` or ``uic`` processes to start when using
+:prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC`.
+
+The custom `<origin>_autogen` target starts a number of threads of which
+each one parses a source file and on demand starts a ``moc`` or ``uic``
+process. :prop_tgt:`AUTOGEN_PARALLEL` controls how many parallel threads
+(and therefore ``moc`` or ``uic`` processes) are started.
+
+- An empty (or unset) value or the string ``AUTO`` sets the number of
+ threads/processes to the number of physical CPUs on the host system.
+- A positive non zero integer value sets the exact thread/process count.
+- Otherwise a single thread/process is started.
+
+By default :prop_tgt:`AUTOGEN_PARALLEL` is initialized from
+:variable:`CMAKE_AUTOGEN_PARALLEL`.
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
diff --git a/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst b/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst
index f522c6bf2..d5c5e147d 100644
--- a/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst
+++ b/Help/prop_tgt/AUTOGEN_TARGET_DEPENDS.rst
@@ -1,17 +1,36 @@
AUTOGEN_TARGET_DEPENDS
----------------------
-Target dependencies of the corresponding ``_autogen`` target.
+Additional target dependencies of the corresponding ``_autogen`` target.
-Targets which have their :prop_tgt:`AUTOMOC` target ``ON`` have a
-corresponding ``_autogen`` target which is used to autogenerate generate moc
-files. As this ``_autogen`` target is created at generate-time, it is not
-possible to define dependencies of it, such as to create inputs for the ``moc``
-executable.
+Targets which have their :prop_tgt:`AUTOMOC` or :prop_tgt:`AUTOUIC` property
+``ON`` have a corresponding ``_autogen`` target which generates
+``moc`` and ``uic`` files. As this ``_autogen`` target is created at
+generate-time, it is not possible to define dependencies of it using
+e.g. :command:`add_dependencies`. Instead the
+:prop_tgt:`AUTOGEN_TARGET_DEPENDS` target property can be set to a
+:ref:`;-list <CMake Language Lists>` of additional dependencies for the
+``_autogen`` target. Dependencies can be target names or file names.
-The ``AUTOGEN_TARGET_DEPENDS`` target property can be set instead to a list of
-dependencies for the ``_autogen`` target. The buildsystem will be generated to
-depend on its contents.
+In total the dependencies of the ``_autogen`` target are composed from
+
+- forwarded origin target dependencies
+ (enabled by default via :prop_tgt:`AUTOGEN_ORIGIN_DEPENDS`)
+- additional user defined dependencies from :prop_tgt:`AUTOGEN_TARGET_DEPENDS`
See the :manual:`cmake-qt(7)` manual for more information on using CMake
with Qt.
+
+Use cases
+^^^^^^^^^
+
+If :prop_tgt:`AUTOMOC` or :prop_tgt:`AUTOUIC` depends on a file that is either
+
+- a :prop_sf:`GENERATED` non C++ file (e.g. a :prop_sf:`GENERATED` ``.json``
+ or ``.ui`` file) or
+- a :prop_sf:`GENERATED` C++ file that isn't recognized by :prop_tgt:`AUTOMOC`
+ and :prop_tgt:`AUTOUIC` because it's skipped by :prop_sf:`SKIP_AUTOMOC`,
+ :prop_sf:`SKIP_AUTOUIC`, :prop_sf:`SKIP_AUTOGEN` or :policy:`CMP0071` or
+- a file that isn't in the origin target's sources
+
+it must added to :prop_tgt:`AUTOGEN_TARGET_DEPENDS`.
diff --git a/Help/prop_tgt/AUTOMOC.rst b/Help/prop_tgt/AUTOMOC.rst
index 0171d20e7..f6dfabdd3 100644
--- a/Help/prop_tgt/AUTOMOC.rst
+++ b/Help/prop_tgt/AUTOMOC.rst
@@ -1,76 +1,247 @@
AUTOMOC
-------
-Should the target be processed with automoc (for Qt projects).
+Should the target be processed with auto-moc (for Qt projects).
-AUTOMOC is a boolean specifying whether CMake will handle the Qt ``moc``
-preprocessor automatically, i.e. without having to use the
-:module:`QT4_WRAP_CPP() <FindQt4>` or QT5_WRAP_CPP() macro. Currently Qt4 and Qt5 are
-supported.
+:prop_tgt:`AUTOMOC` is a boolean specifying whether CMake will handle the Qt
+``moc`` preprocessor automatically, i.e. without having to use the
+:module:`QT4_WRAP_CPP() <FindQt4>` or ``QT5_WRAP_CPP()`` macro.
+Currently Qt4 and Qt5 are supported.
+
+This property is initialized by the value of the :variable:`CMAKE_AUTOMOC`
+variable if it is set when a target is created.
When this property is set ``ON``, CMake will scan the header and
-source files at build time and invoke moc accordingly.
+source files at build time and invoke ``moc`` accordingly.
-* If an ``#include`` statement like ``#include "moc_<basename>.cpp"`` is found,
- the ``Q_OBJECT`` or ``Q_GADGET`` macros are expected in an otherwise empty
- line of the ``<basename>.h(xx)`` header file. ``moc`` is run on the header
- file to generate ``moc_<basename>.cpp`` in the
- ``<AUTOGEN_BUILD_DIR>/include`` directory which is automatically added
- to the target's :prop_tgt:`INCLUDE_DIRECTORIES`.
- This allows the compiler to find the included ``moc_<basename>.cpp`` file
- regardless of the location the original source.
- * See :prop_tgt:`AUTOGEN_BUILD_DIR`.
+Header file processing
+^^^^^^^^^^^^^^^^^^^^^^
-* If an ``#include`` statement like ``#include "<basename>.moc"`` is found,
- then ``Q_OBJECT`` or ``Q_GADGET`` macros are expected in the current source
- file and ``moc`` is run on the source file itself.
+At configuration time, a list of header files that should be scanned by
+:prop_tgt:`AUTOMOC` is computed from the target's sources.
-* Header files that are not included by an ``#include "moc_<basename>.cpp"``
- statement are nonetheless scanned for ``Q_OBJECT`` or ``Q_GADGET`` macros.
- The resulting ``moc_<basename>.cpp`` files are generated in custom
- directories and automatically included in a generated
- ``<AUTOGEN_BUILD_DIR>/mocs_compilation.cpp`` file,
- which is compiled as part of the target.
+- All header files in the target's sources are added to the scan list.
+- For all C++ source files ``<source_base>.<source_extension>`` in the
+ target's sources, CMake searches for
- * The custom directories with checksum
- based names help to avoid name collisions for moc files with the same
- ``<basename>``.
+ - a regular header with the same base name
+ (``<source_base>.<header_extention>``) and
+ - a private header with the same base name and a ``_p`` suffix
+ (``<source_base>_p.<header_extention>``)
- * See :prop_tgt:`AUTOGEN_BUILD_DIR`.
+ and adds these to the scan list.
-* Additionally, header files with the same base name as a source file,
- (like ``<basename>.h``) or ``_p`` appended to the base name (like
- ``<basename>_p.h``), are parsed for ``Q_OBJECT`` or ``Q_GADGET`` macros,
- and if found, ``moc`` is also executed on those files.
+At build time, CMake scans each unknown or modified header file from the
+list and searches for
-* ``AUTOMOC`` always checks multiple header alternative extensions,
- such as ``hpp``, ``hxx``, etc. when searching for headers.
+- a Qt macro from :prop_tgt:`AUTOMOC_MACRO_NAMES`,
+- additional file dependencies from the ``FILE`` argument of a
+ ``Q_PLUGIN_METADATA`` macro and
+- additional file dependencies detected by filters defined in
+ :prop_tgt:`AUTOMOC_DEPEND_FILTERS`.
-* ``AUTOMOC`` looks for the ``Q_PLUGIN_METADATA`` macro and reruns the
- ``moc`` when the file addressed by the ``FILE`` argument of the macro changes.
+If a Qt macro is found, then the header will be compiled by the ``moc`` to the
+output file ``moc_<base_name>.cpp``. The complete output file path is
+described in the section `Output file location`_.
-This property is initialized by the value of the :variable:`CMAKE_AUTOMOC`
-variable if it is set when a target is created.
+The header will be ``moc`` compiled again if a file from the additional file
+dependencies changes.
+
+Header ``moc`` output files ``moc_<base_name>.cpp`` can be included in source
+files. In the section `Including header moc files in sources`_ there is more
+information on that topic.
+
+
+Source file processing
+^^^^^^^^^^^^^^^^^^^^^^
+
+At build time, CMake scans each unknown or modified C++ source file from the
+target's sources for
+
+- a Qt macro from :prop_tgt:`AUTOMOC_MACRO_NAMES`,
+- includes of header ``moc`` files
+ (see `Including header moc files in sources`_),
+- additional file dependencies from the ``FILE`` argument of a
+ ``Q_PLUGIN_METADATA`` macro and
+- additional file dependencies detected by filters defined in
+ :prop_tgt:`AUTOMOC_DEPEND_FILTERS`.
+
+If a Qt macro is found, then the C++ source file
+``<base>.<source_extension>`` is expected to as well contain an include
+statement
+
+.. code-block:: c++
+
+ #include <<base>.moc> // or
+ #include "<base>.moc"
+
+The source file then will be compiled by the ``moc`` to the output file
+``<base>.moc``. A description of the complete output file path is in section
+`Output file location`_.
+
+The source will be ``moc`` compiled again if a file from the additional file
+dependencies changes.
+
+Including header moc files in sources
+"""""""""""""""""""""""""""""""""""""
+
+A source file can include the ``moc`` output file of a header
+``<header_base>.<header_extension>`` by using an include statement of
+the form
+
+.. code-block:: c++
+
+ #include <moc_<header_base>.cpp> // or
+ #include "moc_<header_base>.cpp"
+
+If the ``moc`` output file of a header is included by a source, it will
+be generated in a different location than if it was not included. This is
+described in the section `Output file location`_.
+
+
+Output file location
+^^^^^^^^^^^^^^^^^^^^
+
+Included moc output files
+"""""""""""""""""""""""""
+
+``moc`` output files that are included by a source file will be generated in
+
+- ``<AUTOGEN_BUILD_DIR>/include``
+ for single configuration generators or in
+- ``<AUTOGEN_BUILD_DIR>/include_<CONFIG>``
+ for :prop_gbl:`multi configuration <GENERATOR_IS_MULTI_CONFIG>` generators.
+
+Where ``<AUTOGEN_BUILD_DIR>`` is the value of the target property
+:prop_tgt:`AUTOGEN_BUILD_DIR`.
+
+The include directory is automatically added to the target's
+:prop_tgt:`INCLUDE_DIRECTORIES`.
+
+Not included moc output files
+"""""""""""""""""""""""""""""
+
+``moc`` output files that are not included in a source file will be generated
+in
+
+- ``<AUTOGEN_BUILD_DIR>/<SOURCE_DIR_CHECKSUM>``
+ for single configuration generators or in,
+- ``<AUTOGEN_BUILD_DIR>/include_<CONFIG>/<SOURCE_DIR_CHECKSUM>``
+ for :prop_gbl:`multi configuration <GENERATOR_IS_MULTI_CONFIG>` generators.
+
+Where ``<SOURCE_DIR_CHECKSUM>`` is a checksum computed from the relative
+parent directory path of the ``moc`` input file. This scheme allows to have
+``moc`` input files with the same name in different directories.
+
+All not included ``moc`` output files will be included automatically by the
+CMake generated file
+
+- ``<AUTOGEN_BUILD_DIR>/mocs_compilation.cpp``,
+
+which is added to the target's sources.
+
+
+Qt version detection
+^^^^^^^^^^^^^^^^^^^^
+
+:prop_tgt:`AUTOMOC` enabled targets need to know the Qt major and minor
+version they're working with. The major version usually is provided by the
+``INTERFACE_QT_MAJOR_VERSION`` property of the ``Qt[45]Core`` library,
+that the target links to. To find the minor version, CMake builds a list of
+available Qt versions from
+
+- ``Qt5Core_VERSION_MAJOR`` and ``Qt5Core_VERSION_MINOR`` variables
+ (usually set by ``find_package(Qt5...)``)
+- ``Qt5Core_VERSION_MAJOR`` and ``Qt5Core_VERSION_MINOR`` directory properties
+- ``QT_VERSION_MAJOR`` and ``QT_VERSION_MINOR`` variables
+ (usually set by ``find_package(Qt4...)``)
+- ``QT_VERSION_MAJOR`` and ``QT_VERSION_MINOR`` directory properties
+
+in the context of the :command:`add_executable` or :command:`add_library` call.
+
+Assumed ``INTERFACE_QT_MAJOR_VERSION`` is a valid number, the first
+entry in the list with a matching major version is taken. If no matching major
+version was found, an error is generated.
+If ``INTERFACE_QT_MAJOR_VERSION`` is not a valid number, the first
+entry in the list is taken.
-Additional command line options for moc can be set via the
-:prop_tgt:`AUTOMOC_MOC_OPTIONS` property.
+A ``find_package(Qt[45]...)`` call sets the ``QT/Qt5Core_VERSION_MAJOR/MINOR``
+variables. If the call is in a different context than the
+:command:`add_executable` or :command:`add_library` call, e.g. in a function,
+then the version variables might not be available to the :prop_tgt:`AUTOMOC`
+enabled target.
+In that case the version variables can be forwarded from the
+`find_package(Qt[45]...)` calling context to the :command:`add_executable`
+or :command:`add_library` calling context as directory properties.
+The following Qt5 example demonstrates the procedure.
-By enabling the :variable:`CMAKE_AUTOMOC_RELAXED_MODE` variable the
-rules for searching the files which will be processed by moc can be relaxed.
-See the documentation for this variable for more details.
+.. code-block:: cmake
-The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group the
-automoc targets together in an IDE, e.g. in MSVS.
+ function (add_qt5_client)
+ find_package(Qt5 REQUIRED QUIET COMPONENTS Core Widgets)
+ ...
+ set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ PROPERTY Qt5Core_VERSION_MAJOR "${Qt5Core_VERSION_MAJOR}")
+ set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ PROPERTY Qt5Core_VERSION_MINOR "${Qt5Core_VERSION_MAJOR}")
+ ...
+ endfunction ()
+ ...
+ add_qt5_client()
+ add_executable(myTarget main.cpp)
+ target_link_libraries(myTarget Qt5::QtWidgets)
+ set_property(TARGET myTarget PROPERTY AUTOMOC ON)
-The global property :prop_gbl:`AUTOGEN_SOURCE_GROUP` can be used to group
-files generated by :prop_tgt:`AUTOMOC` together in an IDE, e.g. in MSVS.
-Additional ``moc`` dependency file names can be extracted from source code
-by using :prop_tgt:`AUTOMOC_DEPEND_FILTERS`.
+Modifiers
+^^^^^^^^^
-Source C++ files can be excluded from :prop_tgt:`AUTOMOC` processing by
-enabling :prop_sf:`SKIP_AUTOMOC` or the broader :prop_sf:`SKIP_AUTOGEN`.
+:prop_tgt:`AUTOMOC_EXECUTABLE`:
+The ``moc`` executable will be detected automatically, but can be forced to
+a certain binary using this target property.
+
+:prop_tgt:`AUTOMOC_MOC_OPTIONS`:
+Additional command line options for ``moc`` can be set in this target property.
+
+:prop_tgt:`AUTOMOC_MACRO_NAMES`:
+This list of Qt macro names can be extended to search for additional macros in
+headers and sources.
+
+:prop_tgt:`AUTOMOC_DEPEND_FILTERS`:
+``moc`` dependency file names can be extracted from headers or sources by
+defining file name filters in this target property.
+
+:prop_tgt:`AUTOMOC_COMPILER_PREDEFINES`:
+Compiler pre definitions for ``moc`` are written to the ``moc_predefs.h`` file.
+The generation of this file can be enabled or disabled in this target property.
+
+:prop_sf:`SKIP_AUTOMOC`:
+Sources and headers can be excluded from :prop_tgt:`AUTOMOC` processing by
+setting this source file property.
+
+:prop_sf:`SKIP_AUTOGEN`:
+Source files can be excluded from :prop_tgt:`AUTOMOC`,
+:prop_tgt:`AUTOUIC` and :prop_tgt:`AUTORCC` processing by
+setting this source file property.
+
+:prop_gbl:`AUTOGEN_SOURCE_GROUP`:
+This global property can be used to group files generated by
+:prop_tgt:`AUTOMOC` or :prop_tgt:`AUTORCC` together in an IDE, e.g. in MSVS.
+
+:prop_gbl:`AUTOGEN_TARGETS_FOLDER`:
+This global property can be used to group :prop_tgt:`AUTOMOC`,
+:prop_tgt:`AUTOUIC` and :prop_tgt:`AUTORCC` targets together in an IDE,
+e.g. in MSVS.
+
+:variable:`CMAKE_GLOBAL_AUTOGEN_TARGET`:
+A global ``autogen`` target, that depends on all :prop_tgt:`AUTOMOC` or
+:prop_tgt:`AUTOUIC` generated ``<ORIGIN>_autogen`` targets in the project,
+will be generated when this variable is ``ON``.
+
+:prop_tgt:`AUTOGEN_PARALLEL`:
+This target property controls the number of ``moc`` or ``uic`` processes to
+start in parallel during builds.
See the :manual:`cmake-qt(7)` manual for more information on using CMake
with Qt.
diff --git a/Help/prop_tgt/AUTOMOC_COMPILER_PREDEFINES.rst b/Help/prop_tgt/AUTOMOC_COMPILER_PREDEFINES.rst
new file mode 100644
index 000000000..57a647f3c
--- /dev/null
+++ b/Help/prop_tgt/AUTOMOC_COMPILER_PREDEFINES.rst
@@ -0,0 +1,24 @@
+AUTOMOC_COMPILER_PREDEFINES
+---------------------------
+
+Boolean value used by :prop_tgt:`AUTOMOC` to determine if the
+compiler pre definitions file ``moc_predefs.h`` should be generated.
+
+CMake generates a ``moc_predefs.h`` file with compiler pre definitions
+from the output of the command defined in
+:variable:`CMAKE_CXX_COMPILER_PREDEFINES_COMMAND <CMAKE_<LANG>_COMPILER_PREDEFINES_COMMAND>`
+when
+
+- :prop_tgt:`AUTOMOC` is enabled,
+- :prop_tgt:`AUTOMOC_COMPILER_PREDEFINES` is enabled,
+- :variable:`CMAKE_CXX_COMPILER_PREDEFINES_COMMAND <CMAKE_<LANG>_COMPILER_PREDEFINES_COMMAND>` isn't empty and
+- the Qt version is greater or equal 5.8.
+
+The ``moc_predefs.h`` file, which is generated in :prop_tgt:`AUTOGEN_BUILD_DIR`,
+is passed to ``moc`` as the argument to the ``--include`` option.
+
+By default :prop_tgt:`AUTOMOC_COMPILER_PREDEFINES` is initialized from
+:variable:`CMAKE_AUTOMOC_COMPILER_PREDEFINES`, which is ON by default.
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
diff --git a/Help/prop_tgt/AUTOMOC_DEPEND_FILTERS.rst b/Help/prop_tgt/AUTOMOC_DEPEND_FILTERS.rst
index 810cbf4ae..69957bf18 100644
--- a/Help/prop_tgt/AUTOMOC_DEPEND_FILTERS.rst
+++ b/Help/prop_tgt/AUTOMOC_DEPEND_FILTERS.rst
@@ -1,21 +1,27 @@
AUTOMOC_DEPEND_FILTERS
----------------------
-Filter definitions used by :prop_tgt:`AUTOMOC` to extract file names from
-source code as additional dependencies for the ``moc`` file.
-
-This property is only used if the :prop_tgt:`AUTOMOC` property is ``ON``
-for this target.
+Filter definitions used by :prop_tgt:`AUTOMOC` to extract file names from a
+source file that are registered as additional dependencies for the
+``moc`` file of the source file.
Filters are defined as ``KEYWORD;REGULAR_EXPRESSION`` pairs. First the file
content is searched for ``KEYWORD``. If it is found at least once, then file
names are extracted by successively searching for ``REGULAR_EXPRESSION`` and
taking the first match group.
-Consider a filter extracts the file name ``DEP`` from the content of a file
-``FOO``. If ``DEP`` changes, then the ``moc`` file for ``FOO`` gets rebuilt.
-The file ``DEP`` is searched for first in the vicinity
-of ``FOO`` and afterwards in the target's :prop_tgt:`INCLUDE_DIRECTORIES`.
+The file name found in the first match group is searched for
+
+- first in the vicinity of the source file
+- and afterwards in the target's :prop_tgt:`INCLUDE_DIRECTORIES`.
+
+If any of the extracted files changes, then the ``moc`` file for the source
+file gets rebuilt even when the source file itself doesn't change.
+
+If any of the extracted files is :prop_sf:`GENERATED` or if it is not in the
+target's sources, then it might be necessary to add it to the
+``_autogen`` target dependencies.
+See :prop_tgt:`AUTOGEN_TARGET_DEPENDS` for reference.
By default :prop_tgt:`AUTOMOC_DEPEND_FILTERS` is initialized from
:variable:`CMAKE_AUTOMOC_DEPEND_FILTERS`, which is empty by default.
@@ -24,22 +30,75 @@ See the :manual:`cmake-qt(7)` manual for more information on using CMake
with Qt.
-Example
--------
+Example 1
+^^^^^^^^^
-Consider a file ``FOO.hpp`` holds a custom macro ``OBJ_JSON_FILE`` and we
-want the ``moc`` file to depend on the macro`s file name argument::
+A header file ``my_class.hpp`` uses a custom macro ``JSON_FILE_MACRO`` which
+is defined in an other header ``macros.hpp``.
+We want the ``moc`` file of ``my_class.hpp`` to depend on the file name
+argument of ``JSON_FILE_MACRO``::
+ // my_class.hpp
class My_Class : public QObject
{
Q_OBJECT
- OBJ_JSON_FILE ( "DEP.json" )
+ JSON_FILE_MACRO ( "info.json" )
+ ...
+ };
+
+In ``CMakeLists.txt`` we add a filter to
+:variable:`CMAKE_AUTOMOC_DEPEND_FILTERS` like this::
+
+ list( APPEND CMAKE_AUTOMOC_DEPEND_FILTERS
+ "JSON_FILE_MACRO"
+ "[\n][ \t]*JSON_FILE_MACRO[ \t]*\\([ \t]*\"([^\"]+)\""
+ )
+
+We assume ``info.json`` is a plain (not :prop_sf:`GENERATED`) file that is
+listed in the target's source. Therefore we do not need to add it to
+:prop_tgt:`AUTOGEN_TARGET_DEPENDS`.
+
+Example 2
+^^^^^^^^^
+
+In the target ``my_target`` a header file ``complex_class.hpp`` uses a
+custom macro ``JSON_BASED_CLASS`` which is defined in an other header
+``macros.hpp``::
+
+ // macros.hpp
...
+ #define JSON_BASED_CLASS(name, json) \
+ class name : public QObject \
+ { \
+ Q_OBJECT \
+ Q_PLUGIN_METADATA(IID "demo" FILE json) \
+ name() {} \
};
+ ...
+
+::
-Then we might use :variable:`CMAKE_AUTOMOC_DEPEND_FILTERS` to
-define a filter like this::
+ // complex_class.hpp
+ #pragma once
+ JSON_BASED_CLASS(Complex_Class, "meta.json")
+ // end of file
- set(CMAKE_AUTOMOC_DEPEND_FILTERS
- "OBJ_JSON_FILE" "[\n][ \t]*OBJ_JSON_FILE[ \t]*\\([ \t]*\"([^\"]+)\""
+Since ``complex_class.hpp`` doesn't contain a ``Q_OBJECT`` macro it would be
+ignored by :prop_tgt:`AUTOMOC`. We change this by adding ``JSON_BASED_CLASS``
+to :variable:`CMAKE_AUTOMOC_MACRO_NAMES`::
+
+ list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "JSON_BASED_CLASS")
+
+We want the ``moc`` file of ``complex_class.hpp`` to depend on
+``meta.json``. So we add a filter to
+:variable:`CMAKE_AUTOMOC_DEPEND_FILTERS`::
+
+ list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS
+ "JSON_BASED_CLASS"
+ "[\n^][ \t]*JSON_BASED_CLASS[ \t]*\\([^,]*,[ \t]*\"([^\"]+)\""
)
+
+Additionally we assume ``meta.json`` is :prop_sf:`GENERATED` which is
+why we have to add it to :prop_tgt:`AUTOGEN_TARGET_DEPENDS`::
+
+ set_property(TARGET my_target APPEND PROPERTY AUTOGEN_TARGET_DEPENDS "meta.json")
diff --git a/Help/prop_tgt/AUTOMOC_EXECUTABLE.rst b/Help/prop_tgt/AUTOMOC_EXECUTABLE.rst
new file mode 100644
index 000000000..6b66ce81f
--- /dev/null
+++ b/Help/prop_tgt/AUTOMOC_EXECUTABLE.rst
@@ -0,0 +1,15 @@
+AUTOMOC_EXECUTABLE
+------------------
+
+:prop_tgt:`AUTOMOC_EXECUTABLE` is file path pointing to the ``moc``
+executable to use for :prop_tgt:`AUTOMOC` enabled files. Setting
+this property will make CMake skip the automatic detection of the
+``moc`` binary as well as the sanity-tests normally run to ensure
+that the binary is available and working as expected.
+
+Usually this property does not need to be set. Only consider this
+property if auto-detection of ``moc`` can not work -- e.g. because
+you are building the ``moc`` binary as part of your project.
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
diff --git a/Help/prop_tgt/AUTOMOC_MACRO_NAMES.rst b/Help/prop_tgt/AUTOMOC_MACRO_NAMES.rst
new file mode 100644
index 000000000..5329bbac9
--- /dev/null
+++ b/Help/prop_tgt/AUTOMOC_MACRO_NAMES.rst
@@ -0,0 +1,32 @@
+AUTOMOC_MACRO_NAMES
+-------------------
+
+A :ref:`semicolon-separated list <CMake Language Lists>` list of macro names used by
+:prop_tgt:`AUTOMOC` to determine if a C++ file needs to be processed by ``moc``.
+
+This property is only used if the :prop_tgt:`AUTOMOC` property is ``ON``
+for this target.
+
+When running :prop_tgt:`AUTOMOC`, CMake searches for the strings listed in
+:prop_tgt:`AUTOMOC_MACRO_NAMES` in C++ source and header files.
+If any of the strings is found
+
+- as the first non space string on a new line or
+- as the first non space string after a ``{`` on a new line,
+
+then the file will be processed by ``moc``.
+
+By default :prop_tgt:`AUTOMOC_MACRO_NAMES` is initialized from
+:variable:`CMAKE_AUTOMOC_MACRO_NAMES`.
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
+
+Example
+^^^^^^^
+
+In this case the ``Q_OBJECT`` macro is hidden inside another macro
+called ``CUSTOM_MACRO``. To let CMake know that source files that contain
+``CUSTOM_MACRO`` need to be ``moc`` processed, we call::
+
+ set_property(TARGET tgt APPEND PROPERTY AUTOMOC_MACRO_NAMES "CUSTOM_MACRO")
diff --git a/Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst b/Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst
new file mode 100644
index 000000000..e2ebb3ffc
--- /dev/null
+++ b/Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst
@@ -0,0 +1,32 @@
+AUTOMOC_PATH_PREFIX
+-------------------
+
+When this property is ``ON``, CMake will generate the ``-p`` path prefix
+option for ``moc`` on :prop_tgt:`AUTOMOC` enabled Qt targets.
+
+To generate the path prefix, CMake tests if the header compiled by ``moc``
+is in any of the target
+:command:`include directories <target_include_directories>`. If so, CMake will
+compute the relative path accordingly. If the header is not in the
+:command:`include directories <target_include_directories>`, CMake will omit
+the ``-p`` path prefix option. ``moc`` usually generates a
+relative include path in that case.
+
+:prop_tgt:`AUTOMOC_PATH_PREFIX` is initialized from the variable
+:variable:`CMAKE_AUTOMOC_PATH_PREFIX`, which is ``ON`` by default.
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
+
+Reproducible builds
+^^^^^^^^^^^^^^^^^^^
+
+For reproducible builds is is recommended to keep headers that are ``moc``
+compiled in one of the target
+:command:`include directories <target_include_directories>` and set
+:prop_tgt:`AUTOMOC_PATH_PREFIX` to ``ON`` (which is the default). This ensures
+that
+
+- ``moc`` output files are identical on different build setups,
+- ``moc`` output files will compile correctly when the source and/or
+ build directory is a symbolic link.
diff --git a/Help/prop_tgt/AUTORCC.rst b/Help/prop_tgt/AUTORCC.rst
index c0f6a26b2..cca3e583f 100644
--- a/Help/prop_tgt/AUTORCC.rst
+++ b/Help/prop_tgt/AUTORCC.rst
@@ -1,9 +1,9 @@
AUTORCC
-------
-Should the target be processed with autorcc (for Qt projects).
+Should the target be processed with auto-rcc (for Qt projects).
-``AUTORCC`` is a boolean specifying whether CMake will handle
+:prop_tgt:`AUTORCC` is a boolean specifying whether CMake will handle
the Qt ``rcc`` code generator automatically, i.e. without having to use
the :module:`QT4_ADD_RESOURCES() <FindQt4>` or ``QT5_ADD_RESOURCES()``
macro. Currently Qt4 and Qt5 are supported.
@@ -13,22 +13,49 @@ as target sources at build time and invoke ``rcc`` accordingly.
This property is initialized by the value of the :variable:`CMAKE_AUTORCC`
variable if it is set when a target is created.
-Additional command line options for rcc can be set via the
-:prop_sf:`AUTORCC_OPTIONS` source file property on the ``.qrc`` file.
-
-The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group
-the autorcc targets together in an IDE, e.g. in MSVS.
-
-The global property :prop_gbl:`AUTOGEN_SOURCE_GROUP` can be used to group
-files generated by :prop_tgt:`AUTORCC` together in an IDE, e.g. in MSVS.
+By default :prop_tgt:`AUTORCC` is processed by a
+:command:`custom command <add_custom_command>`.
+If the ``.qrc`` file is :prop_sf:`GENERATED`, a
+:command:`custom target <add_custom_target>` is used instead.
When there are multiple ``.qrc`` files with the same name, CMake will
-generate unspecified unique names for ``rcc``. Therefore if
-``Q_INIT_RESOURCE()`` or ``Q_CLEANUP_RESOURCE()`` need to be used the
+generate unspecified unique output file names for ``rcc``. Therefore, if
+``Q_INIT_RESOURCE()`` or ``Q_CLEANUP_RESOURCE()`` need to be used, the
``.qrc`` file name must be unique.
-Source files can be excluded from :prop_tgt:`AUTORCC` processing by
-enabling :prop_sf:`SKIP_AUTORCC` or the broader :prop_sf:`SKIP_AUTOGEN`.
+
+Modifiers
+^^^^^^^^^
+
+:prop_tgt:`AUTORCC_EXECUTABLE`:
+The ``rcc`` executable will be detected automatically, but can be forced to
+a certain binary by setting this target property.
+
+:prop_sf:`AUTORCC_OPTIONS`:
+Additional command line options for ``rcc`` can be set via this ``.qrc``
+source file property.
+
+:prop_sf:`SKIP_AUTORCC`:
+``.qrc`` files can be excluded from :prop_tgt:`AUTORCC` processing by
+setting this source file property.
+
+:prop_sf:`SKIP_AUTOGEN`:
+Source files can be excluded from :prop_tgt:`AUTOMOC`,
+:prop_tgt:`AUTOUIC` and :prop_tgt:`AUTORCC` processing by
+setting this source file property.
+
+:prop_gbl:`AUTOGEN_SOURCE_GROUP`:
+This global property can be used to group files generated by
+:prop_tgt:`AUTOMOC` or :prop_tgt:`AUTORCC` together in an IDE, e.g. in MSVS.
+
+:prop_gbl:`AUTOGEN_TARGETS_FOLDER`:
+This global property can be used to group :prop_tgt:`AUTOMOC`,
+:prop_tgt:`AUTOUIC` and :prop_tgt:`AUTORCC` targets together in an IDE,
+e.g. in MSVS.
+
+:variable:`CMAKE_GLOBAL_AUTORCC_TARGET`:
+A global ``autorcc`` target that depends on all :prop_tgt:`AUTORCC` targets
+in the project will be generated when this variable is ``ON``.
See the :manual:`cmake-qt(7)` manual for more information on using CMake
with Qt.
diff --git a/Help/prop_tgt/AUTORCC_EXECUTABLE.rst b/Help/prop_tgt/AUTORCC_EXECUTABLE.rst
new file mode 100644
index 000000000..ca0fbd75b
--- /dev/null
+++ b/Help/prop_tgt/AUTORCC_EXECUTABLE.rst
@@ -0,0 +1,15 @@
+AUTORCC_EXECUTABLE
+------------------
+
+:prop_tgt:`AUTORCC_EXECUTABLE` is file path pointing to the ``rcc``
+executable to use for :prop_tgt:`AUTORCC` enabled files. Setting
+this property will make CMake skip the automatic detection of the
+``rcc`` binary as well as the sanity-tests normally run to ensure
+that the binary is available and working as expected.
+
+Usually this property does not need to be set. Only consider this
+property if auto-detection of ``rcc`` can not work -- e.g. because
+you are building the ``rcc`` binary as part of your project.
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
diff --git a/Help/prop_tgt/AUTORCC_OPTIONS.rst b/Help/prop_tgt/AUTORCC_OPTIONS.rst
index 8a0f632c2..d6ade5adb 100644
--- a/Help/prop_tgt/AUTORCC_OPTIONS.rst
+++ b/Help/prop_tgt/AUTORCC_OPTIONS.rst
@@ -19,3 +19,12 @@ set on the ``.qrc`` source file.
See the :manual:`cmake-qt(7)` manual for more information on using CMake
with Qt.
+
+EXAMPLE
+^^^^^^^
+
+.. code-block:: cmake
+
+ # ...
+ set_property(TARGET tgt PROPERTY AUTORCC_OPTIONS "--compress;9")
+ # ...
diff --git a/Help/prop_tgt/AUTOUIC.rst b/Help/prop_tgt/AUTOUIC.rst
index 6493bbc78..5cf87552c 100644
--- a/Help/prop_tgt/AUTOUIC.rst
+++ b/Help/prop_tgt/AUTOUIC.rst
@@ -1,34 +1,82 @@
AUTOUIC
-------
-Should the target be processed with autouic (for Qt projects).
+Should the target be processed with auto-uic (for Qt projects).
-``AUTOUIC`` is a boolean specifying whether CMake will handle
+:prop_tgt:`AUTOUIC` is a boolean specifying whether CMake will handle
the Qt ``uic`` code generator automatically, i.e. without having to use
the :module:`QT4_WRAP_UI() <FindQt4>` or ``QT5_WRAP_UI()`` macro. Currently
Qt4 and Qt5 are supported.
-When this property is ``ON``, CMake will scan the source files at build time
-and invoke ``uic`` accordingly. If an ``#include`` statement like
-``#include "ui_foo.h"`` is found in ``source.cpp``, a ``foo.ui`` file is
-searched for first in the vicinity of ``source.cpp`` and afterwards in the
-optional :prop_tgt:`AUTOUIC_SEARCH_PATHS` of the target.
-``uic`` is run on the ``foo.ui`` file to generate ``ui_foo.h`` in the directory
-``<AUTOGEN_BUILD_DIR>/include``,
-which is automatically added to the target's :prop_tgt:`INCLUDE_DIRECTORIES`.
-
-* See :prop_tgt:`AUTOGEN_BUILD_DIR`.
-
This property is initialized by the value of the :variable:`CMAKE_AUTOUIC`
variable if it is set when a target is created.
-Additional command line options for ``uic`` can be set via the
-:prop_sf:`AUTOUIC_OPTIONS` source file property on the ``foo.ui`` file.
-The global property :prop_gbl:`AUTOGEN_TARGETS_FOLDER` can be used to group the
-autouic targets together in an IDE, e.g. in MSVS.
+When this property is ``ON``, CMake will scan the header and source files at
+build time and invoke ``uic`` accordingly.
+
+
+Header and source file processing
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+At build time, CMake scans each header and source file from the
+target's sources for include statements of the form
+
+.. code-block:: c++
+
+ #include "ui_<ui_base>.h"
+
+Once such an include statement is found in a file, CMake searches for the
+``uic`` input file ``<ui_base>.ui``
+
+- in the vicinity of the file and
+- in the :prop_tgt:`AUTOUIC_SEARCH_PATHS` of the target.
+
+If the ``<ui_base>.ui`` file was found, ``uic`` is called on it to generate
+``ui_<ui_base>.h`` in the directory
+
+- ``<AUTOGEN_BUILD_DIR>/include`` for single configuration generators or in
+- ``<AUTOGEN_BUILD_DIR>/include_<CONFIG>`` for
+ :prop_gbl:`multi configuration <GENERATOR_IS_MULTI_CONFIG>` generators.
+
+Where ``<AUTOGEN_BUILD_DIR>`` is the value of the target property
+:prop_tgt:`AUTOGEN_BUILD_DIR`.
+
+The include directory is automatically added to the target's
+:prop_tgt:`INCLUDE_DIRECTORIES`.
+
+
+Modifiers
+^^^^^^^^^
+
+:prop_tgt:`AUTOUIC_EXECUTABLE`:
+The ``uic`` executable will be detected automatically, but can be forced to
+a certain binary using this target property.
+
+:prop_sf:`AUTOUIC_OPTIONS`: Additional command line options for ``uic`` can
+be set via this source file property on a ``<base_name>.ui`` file.
+
+:prop_sf:`SKIP_AUTOUIC`:
+Source files can be excluded from :prop_tgt:`AUTOUIC` processing by setting
+this source file property.
+
+:prop_sf:`SKIP_AUTOGEN`:
+Source files can be excluded from :prop_tgt:`AUTOMOC`,
+:prop_tgt:`AUTOUIC` and :prop_tgt:`AUTORCC` processing by
+setting this source file property.
+
+:prop_gbl:`AUTOGEN_TARGETS_FOLDER`:
+This global property can be used to group :prop_tgt:`AUTOMOC`,
+:prop_tgt:`AUTOUIC` and :prop_tgt:`AUTORCC` targets together in an IDE,
+e.g. in MSVS.
+
+:variable:`CMAKE_GLOBAL_AUTOGEN_TARGET`:
+A global ``autogen`` target, that depends on all :prop_tgt:`AUTOMOC` or
+:prop_tgt:`AUTOUIC` generated ``<ORIGIN>_autogen`` targets in the project,
+will be generated when this variable is ``ON``.
-Source files can be excluded from :prop_tgt:`AUTOUIC` processing by
-enabling :prop_sf:`SKIP_AUTOUIC` or the broader :prop_sf:`SKIP_AUTOGEN`.
+:prop_tgt:`AUTOGEN_PARALLEL`:
+This target property controls the number of ``moc`` or ``uic`` processes to
+start in parallel during builds.
See the :manual:`cmake-qt(7)` manual for more information on using CMake
with Qt.
diff --git a/Help/prop_tgt/AUTOUIC_EXECUTABLE.rst b/Help/prop_tgt/AUTOUIC_EXECUTABLE.rst
new file mode 100644
index 000000000..03bd55499
--- /dev/null
+++ b/Help/prop_tgt/AUTOUIC_EXECUTABLE.rst
@@ -0,0 +1,15 @@
+AUTOUIC_EXECUTABLE
+------------------
+
+:prop_tgt:`AUTOUIC_EXECUTABLE` is file path pointing to the ``uic``
+executable to use for :prop_tgt:`AUTOUIC` enabled files. Setting
+this property will make CMake skip the automatic detection of the
+``uic`` binary as well as the sanity-tests normally run to ensure
+that the binary is available and working as expected.
+
+Usually this property does not need to be set. Only consider this
+property if auto-detection of ``uic`` can not work -- e.g. because
+you are building the ``uic`` binary as part of your project.
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
diff --git a/Help/prop_tgt/AUTOUIC_OPTIONS.rst b/Help/prop_tgt/AUTOUIC_OPTIONS.rst
index 9fb042ea6..3f613b952 100644
--- a/Help/prop_tgt/AUTOUIC_OPTIONS.rst
+++ b/Help/prop_tgt/AUTOUIC_OPTIONS.rst
@@ -23,3 +23,12 @@ expressions.
See the :manual:`cmake-qt(7)` manual for more information on using CMake
with Qt.
+
+EXAMPLE
+^^^^^^^
+
+.. code-block:: cmake
+
+ # ...
+ set_property(TARGET tgt PROPERTY AUTOUIC_OPTIONS "--no-protection")
+ # ...
diff --git a/Help/prop_tgt/BUILD_RPATH.rst b/Help/prop_tgt/BUILD_RPATH.rst
index 27393f5d7..d978b9439 100644
--- a/Help/prop_tgt/BUILD_RPATH.rst
+++ b/Help/prop_tgt/BUILD_RPATH.rst
@@ -1,10 +1,13 @@
BUILD_RPATH
-----------
-A :ref:`;-list <CMake Language Lists>` specifying runtime path (``RPATH``)
+A :ref:`semicolon-separated list <CMake Language Lists>` specifying runtime path (``RPATH``)
entries to add to binaries linked in the build tree (for platforms that
support it). The entries will *not* be used for binaries in the install
tree. See also the :prop_tgt:`INSTALL_RPATH` target property.
This property is initialized by the value of the variable
:variable:`CMAKE_BUILD_RPATH` if it is set when a target is created.
+
+This property supports
+:manual:`generator expressions <cmake-generator-expressions(7)>`.
diff --git a/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst b/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst
new file mode 100644
index 000000000..337879780
--- /dev/null
+++ b/Help/prop_tgt/BUILD_RPATH_USE_ORIGIN.rst
@@ -0,0 +1,24 @@
+BUILD_RPATH_USE_ORIGIN
+----------------------
+
+Whether to use relative paths for the build ``RPATH``.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_BUILD_RPATH_USE_ORIGIN`.
+
+On platforms that support runtime paths (``RPATH``) with the
+``$ORIGIN`` token, setting this property to ``TRUE`` enables relative
+paths in the build ``RPATH`` for executables and shared libraries that
+point to shared libraries in the same build tree.
+
+Normally the build ``RPATH`` of a binary contains absolute paths
+to the directory of each shared library it links to. The ``RPATH``
+entries for directories contained within the build tree can be made
+relative to enable relocatable builds and to help achieve reproducible
+builds by omitting the build directory from the build environment.
+
+This property has no effect on platforms that do not support the
+``$ORIGIN`` token in ``RPATH``, or when the :variable:`CMAKE_SKIP_RPATH`
+variable is set. The runtime path set through the
+:prop_tgt:`BUILD_RPATH` target property is also unaffected by this
+property.
diff --git a/Help/prop_tgt/BUNDLE.rst b/Help/prop_tgt/BUNDLE.rst
index 075f017df..c556ac32c 100644
--- a/Help/prop_tgt/BUNDLE.rst
+++ b/Help/prop_tgt/BUNDLE.rst
@@ -1,7 +1,7 @@
BUNDLE
------
-This target is a ``CFBundle`` on the OS X.
+This target is a ``CFBundle`` on the macOS.
If a module library target has this property set to true it will be
built as a ``CFBundle`` when built on the mac. It will have the directory
diff --git a/Help/prop_tgt/BUNDLE_EXTENSION.rst b/Help/prop_tgt/BUNDLE_EXTENSION.rst
index 6b3d58023..70de11c40 100644
--- a/Help/prop_tgt/BUNDLE_EXTENSION.rst
+++ b/Help/prop_tgt/BUNDLE_EXTENSION.rst
@@ -2,7 +2,7 @@ BUNDLE_EXTENSION
----------------
The file extension used to name a :prop_tgt:`BUNDLE`, a :prop_tgt:`FRAMEWORK`,
-or a :prop_tgt:`MACOSX_BUNDLE` target on the OS X and iOS.
+or a :prop_tgt:`MACOSX_BUNDLE` target on the macOS and iOS.
The default value is ``bundle``, ``framework``, or ``app`` for the respective
target types.
diff --git a/Help/prop_tgt/COMMON_LANGUAGE_RUNTIME.rst b/Help/prop_tgt/COMMON_LANGUAGE_RUNTIME.rst
new file mode 100644
index 000000000..052ac6df0
--- /dev/null
+++ b/Help/prop_tgt/COMMON_LANGUAGE_RUNTIME.rst
@@ -0,0 +1,22 @@
+COMMON_LANGUAGE_RUNTIME
+-----------------------
+
+By setting this target property, the target is configured to build with
+``C++/CLI`` support.
+
+The Visual Studio generator defines the ``clr`` parameter depending on
+the value of ``COMMON_LANGUAGE_RUNTIME``:
+
+* property not set: native C++ (i.e. default)
+* property set but empty: mixed unmanaged/managed C++
+* property set to any non empty value: managed C++
+
+Supported values: ``""``, ``"pure"``, ``"safe"``
+
+This property is only evaluated :ref:`Visual Studio Generators` for
+VS 2010 and above.
+
+To be able to build managed C++ targets with VS 2017 and above the component
+``C++/CLI support`` must be installed, which may not be done by default.
+
+See also :prop_tgt:`IMPORTED_COMMON_LANGUAGE_RUNTIME`
diff --git a/Help/prop_tgt/COMPILE_FLAGS.rst b/Help/prop_tgt/COMPILE_FLAGS.rst
index 1a5389e48..8fe651b4a 100644
--- a/Help/prop_tgt/COMPILE_FLAGS.rst
+++ b/Help/prop_tgt/COMPILE_FLAGS.rst
@@ -8,4 +8,4 @@ build sources within the target. Use :prop_tgt:`COMPILE_DEFINITIONS`
to pass additional preprocessor definitions.
This property is deprecated. Use the :prop_tgt:`COMPILE_OPTIONS`
-property or the command:`target_compile_options` command instead.
+property or the :command:`target_compile_options` command instead.
diff --git a/Help/prop_tgt/COMPILE_OPTIONS.rst b/Help/prop_tgt/COMPILE_OPTIONS.rst
index 892ac23e1..0cd683610 100644
--- a/Help/prop_tgt/COMPILE_OPTIONS.rst
+++ b/Help/prop_tgt/COMPILE_OPTIONS.rst
@@ -3,7 +3,7 @@ COMPILE_OPTIONS
List of options to pass to the compiler.
-This property holds a :ref:`;-list <CMake Language Lists>` of options
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of options
specified so far for its target. Use the :command:`target_compile_options`
command to append more options.
diff --git a/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst
index 52ef013da..f261756f1 100644
--- a/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst
+++ b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst
@@ -6,7 +6,7 @@ generated by the compiler while building source files.
This is a per-configuration version of
:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY`,
-but multi-configuration generators (VS, Xcode) do NOT append a
+but multi-configuration generators (Visual Studio, Xcode) do NOT append a
per-configuration subdirectory to the specified directory. This
property is initialized by the value of the
:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>` variable
diff --git a/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst b/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst
index a0811bcaa..87c5978bc 100644
--- a/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst
+++ b/Help/prop_tgt/CROSSCOMPILING_EMULATOR.rst
@@ -6,6 +6,10 @@ This command will be added as a prefix to :command:`add_test`,
:command:`add_custom_command`, and :command:`add_custom_target` commands
for built target system executables.
+If this property contains a :ref:`semicolon-separated list <CMake Language
+Lists>`, then the first value is the command and remaining values are its
+arguments.
+
This property is initialized by the value of the
:variable:`CMAKE_CROSSCOMPILING_EMULATOR` variable if it is set when a target
is created.
diff --git a/Help/prop_tgt/CUDA_RESOLVE_DEVICE_SYMBOLS.rst b/Help/prop_tgt/CUDA_RESOLVE_DEVICE_SYMBOLS.rst
index 127d79fb3..dae960fbe 100644
--- a/Help/prop_tgt/CUDA_RESOLVE_DEVICE_SYMBOLS.rst
+++ b/Help/prop_tgt/CUDA_RESOLVE_DEVICE_SYMBOLS.rst
@@ -1,12 +1,22 @@
CUDA_RESOLVE_DEVICE_SYMBOLS
---------------------------
-CUDA only: Enables device linking for the specific static library target
+CUDA only: Enables device linking for the specific library target where
+required.
+
+If set, this will tell the required compilers to enable device linking
+on the library target. Device linking is an additional link step
+required by some CUDA compilers when :prop_tgt:`CUDA_SEPARABLE_COMPILATION` is
+enabled. Normally device linking is deferred until a shared library or
+executable is generated, allowing for multiple static libraries to resolve
+device symbols at the same time when they are used by a shared library or
+executable.
+
+By default static library targets have this property is disabled,
+while shared, module, and executable targets have this property enabled.
+
+Note that device linking is not supported for :ref:`Object Libraries`.
-If set this will enable device linking on this static library target. Normally
-device linking is deferred until a shared library or executable is generated,
-allowing for multiple static libraries to resolve device symbols at the same
-time.
For instance:
diff --git a/Help/prop_tgt/CUDA_SEPARABLE_COMPILATION.rst b/Help/prop_tgt/CUDA_SEPARABLE_COMPILATION.rst
index 1c7dd8083..d306d7f82 100644
--- a/Help/prop_tgt/CUDA_SEPARABLE_COMPILATION.rst
+++ b/Help/prop_tgt/CUDA_SEPARABLE_COMPILATION.rst
@@ -11,3 +11,7 @@ For instance:
.. code-block:: cmake
set_property(TARGET myexe PROPERTY CUDA_SEPARABLE_COMPILATION ON)
+
+This property is initialized by the value of the
+:variable:`CMAKE_CUDA_SEPARABLE_COMPILATION` variable if it is set when a
+target is created.
diff --git a/Help/prop_tgt/CUDA_STANDARD.rst b/Help/prop_tgt/CUDA_STANDARD.rst
index b26281471..a3a2f5689 100644
--- a/Help/prop_tgt/CUDA_STANDARD.rst
+++ b/Help/prop_tgt/CUDA_STANDARD.rst
@@ -7,7 +7,7 @@ This property specifies the CUDA/C++ standard whose features are requested
to build this target. For some compilers, this results in adding a
flag such as ``-std=gnu++11`` to the compile line.
-Supported values are ``98``, ``11``.
+Supported values are ``98``, ``11``, ``14``.
If the value requested does not result in a compile flag being added for
the compiler in use, a previous standard flag will be added instead. This
diff --git a/Help/prop_tgt/CXX_STANDARD.rst b/Help/prop_tgt/CXX_STANDARD.rst
index 30a612db6..ccc014790 100644
--- a/Help/prop_tgt/CXX_STANDARD.rst
+++ b/Help/prop_tgt/CXX_STANDARD.rst
@@ -6,9 +6,10 @@ The C++ standard whose features are requested to build this target.
This property specifies the C++ standard whose features are requested
to build this target. For some compilers, this results in adding a
flag such as ``-std=gnu++11`` to the compile line. For compilers that
-have no notion of a standard level, such as MSVC, this has no effect.
+have no notion of a standard level, such as Microsoft Visual C++ before
+2015 Update 3, this has no effect.
-Supported values are ``98``, ``11``, ``14``, and ``17``.
+Supported values are ``98``, ``11``, ``14``, ``17``, and ``20``.
If the value requested does not result in a compile flag being added for
the compiler in use, a previous standard flag will be added instead. This
diff --git a/Help/prop_tgt/C_STANDARD.rst b/Help/prop_tgt/C_STANDARD.rst
index 815a68676..e7f7904f2 100644
--- a/Help/prop_tgt/C_STANDARD.rst
+++ b/Help/prop_tgt/C_STANDARD.rst
@@ -6,7 +6,8 @@ The C standard whose features are requested to build this target.
This property specifies the C standard whose features are requested
to build this target. For some compilers, this results in adding a
flag such as ``-std=gnu11`` to the compile line. For compilers that
-have no notion of a standard level, such as MSVC, this has no effect.
+have no notion of a standard level, such as Microsoft Visual C++ before
+2015 Update 3, this has no effect.
Supported values are ``90``, ``99`` and ``11``.
diff --git a/Help/prop_tgt/DEBUG_POSTFIX.rst b/Help/prop_tgt/DEBUG_POSTFIX.rst
index 1487656d9..04e312e37 100644
--- a/Help/prop_tgt/DEBUG_POSTFIX.rst
+++ b/Help/prop_tgt/DEBUG_POSTFIX.rst
@@ -1,7 +1,7 @@
DEBUG_POSTFIX
-------------
-See target property <CONFIG>_POSTFIX.
+See target property ``<CONFIG>_POSTFIX``.
-This property is a special case of the more-general <CONFIG>_POSTFIX
-property for the DEBUG configuration.
+This property is a special case of the more-general ``<CONFIG>_POSTFIX``
+property for the ``DEBUG`` configuration.
diff --git a/Help/prop_tgt/DEFINE_SYMBOL.rst b/Help/prop_tgt/DEFINE_SYMBOL.rst
index f47f135ea..eb7f93735 100644
--- a/Help/prop_tgt/DEFINE_SYMBOL.rst
+++ b/Help/prop_tgt/DEFINE_SYMBOL.rst
@@ -3,9 +3,9 @@ DEFINE_SYMBOL
Define a symbol when compiling this target's sources.
-DEFINE_SYMBOL sets the name of the preprocessor symbol defined when
+``DEFINE_SYMBOL`` sets the name of the preprocessor symbol defined when
compiling sources in a shared library. If not set here then it is set
-to target_EXPORTS by default (with some substitutions if the target is
+to ``target_EXPORTS`` by default (with some substitutions if the target is
not a valid C identifier). This is useful for headers to know whether
they are being included from inside their library or outside to
properly setup dllexport/dllimport decorations.
diff --git a/Help/prop_tgt/DEPLOYMENT_ADDITIONAL_FILES.rst b/Help/prop_tgt/DEPLOYMENT_ADDITIONAL_FILES.rst
new file mode 100644
index 000000000..5e9c19158
--- /dev/null
+++ b/Help/prop_tgt/DEPLOYMENT_ADDITIONAL_FILES.rst
@@ -0,0 +1,18 @@
+DEPLOYMENT_ADDITIONAL_FILES
+---------------------------
+
+Set the WinCE project ``AdditionalFiles`` in ``DeploymentTool`` in ``.vcproj``
+files generated by the :generator:`Visual Studio 9 2008` generator.
+This is useful when you want to debug on remote WinCE device.
+Specify additional files that will be copied to the device.
+For example:
+
+.. code-block:: cmake
+
+ set_property(TARGET ${TARGET} PROPERTY
+ DEPLOYMENT_ADDITIONAL_FILES "english.lng|local_folder|remote_folder|0"
+ "german.lng|local_folder|remote_folder|0")
+
+produces::
+
+ <DeploymentTool AdditionalFiles="english.lng|local_folder|remote_folder|0;german.lng|local_folder|remote_folder|0" ... />
diff --git a/Help/prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY.rst b/Help/prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY.rst
index 1ff5bf01e..368768ae7 100644
--- a/Help/prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY.rst
+++ b/Help/prop_tgt/DEPLOYMENT_REMOTE_DIRECTORY.rst
@@ -3,8 +3,8 @@ DEPLOYMENT_REMOTE_DIRECTORY
Set the WinCE project ``RemoteDirectory`` in ``DeploymentTool`` and
``RemoteExecutable`` in ``DebuggerTool`` in ``.vcproj`` files generated
-by the :generator:`Visual Studio 9 2008` and :generator:`Visual Studio 8 2005`
-generators. This is useful when you want to debug on remote WinCE device.
+by the :generator:`Visual Studio 9 2008` generator.
+This is useful when you want to debug on remote WinCE device.
For example:
.. code-block:: cmake
diff --git a/Help/prop_tgt/DISABLE_PRECOMPILE_HEADERS.rst b/Help/prop_tgt/DISABLE_PRECOMPILE_HEADERS.rst
new file mode 100644
index 000000000..4cef0231a
--- /dev/null
+++ b/Help/prop_tgt/DISABLE_PRECOMPILE_HEADERS.rst
@@ -0,0 +1,8 @@
+DISABLE_PRECOMPILE_HEADERS
+--------------------------
+
+Disables the precompilation of header files specified by
+:prop_tgt:`PRECOMPILE_HEADERS` property.
+
+If the property is not set, CMake will use the value provided
+by :variable:`CMAKE_DISABLE_PRECOMPILE_HEADERS`.
diff --git a/Help/prop_tgt/DOTNET_TARGET_FRAMEWORK_VERSION.rst b/Help/prop_tgt/DOTNET_TARGET_FRAMEWORK_VERSION.rst
new file mode 100644
index 000000000..c100326b9
--- /dev/null
+++ b/Help/prop_tgt/DOTNET_TARGET_FRAMEWORK_VERSION.rst
@@ -0,0 +1,13 @@
+DOTNET_TARGET_FRAMEWORK_VERSION
+-------------------------------
+
+Specify the .NET target framework version.
+
+Used to specify the .NET target framework version for C++/CLI. For
+example: ``v4.5``.
+
+This property is only evaluated for :ref:`Visual Studio Generators`
+VS 2010 and above.
+
+Can be initialized for all targets using the variable
+:variable:`CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION`.
diff --git a/Help/prop_tgt/ENABLE_EXPORTS.rst b/Help/prop_tgt/ENABLE_EXPORTS.rst
index 9e2230971..0b1064ab4 100644
--- a/Help/prop_tgt/ENABLE_EXPORTS.rst
+++ b/Help/prop_tgt/ENABLE_EXPORTS.rst
@@ -7,16 +7,25 @@ Normally an executable does not export any symbols because it is the
final program. It is possible for an executable to export symbols to
be used by loadable modules. When this property is set to true CMake
will allow other targets to "link" to the executable with the
-:command:`TARGET_LINK_LIBRARIES` command. On all platforms a target-level
+:command:`target_link_libraries` command. On all platforms a target-level
dependency on the executable is created for targets that link to it.
-For DLL platforms an import library will be created for the exported
-symbols and then used for linking. All Windows-based systems
-including Cygwin are DLL platforms. For non-DLL platforms that
-require all symbols to be resolved at link time, such as OS X, the
-module will "link" to the executable using a flag like
-``-bundle_loader``. For other non-DLL platforms the link rule is simply
-ignored since the dynamic loader will automatically bind symbols when
-the module is loaded.
+Handling of the executable on the link lines of the loadable modules
+varies by platform:
+
+* On Windows-based systems (including Cygwin) an "import library" is
+ created along with the executable to list the exported symbols.
+ Loadable modules link to the import library to get the symbols.
+
+* On macOS, loadable modules link to the executable itself using the
+ ``-bundle_loader`` flag.
+
+* On AIX, a linker "import file" is created along with the executable
+ to list the exported symbols for import when linking other targets.
+ Loadable modules link to the import file to get the symbols.
+
+* On other platforms, loadable modules are simply linked without
+ referencing the executable since the dynamic loader will
+ automatically bind symbols when the module is loaded.
This property is initialized by the value of the variable
:variable:`CMAKE_ENABLE_EXPORTS` if it is set when a target is created.
diff --git a/Help/prop_tgt/EXCLUDE_FROM_ALL.rst b/Help/prop_tgt/EXCLUDE_FROM_ALL.rst
index caa5741f8..3aa296d3b 100644
--- a/Help/prop_tgt/EXCLUDE_FROM_ALL.rst
+++ b/Help/prop_tgt/EXCLUDE_FROM_ALL.rst
@@ -1,10 +1,21 @@
EXCLUDE_FROM_ALL
----------------
-Exclude the target from the all target.
+Set this target property to a true (or false) value to exclude (or include)
+the target from the "all" target of the containing directory and its
+ancestors. If excluded, running e.g. ``make`` in the containing directory
+or its ancestors will not build the target by default.
-A property on a target that indicates if the target is excluded from
-the default build target. If it is not, then with a Makefile for
-example typing make will cause this target to be built. The same
-concept applies to the default build of other generators. Installing
-a target with EXCLUDE_FROM_ALL set to true has undefined behavior.
+If this target property is not set then the target will be included in
+the "all" target of the containing directory. Furthermore, it will be
+included in the "all" target of its ancestor directories unless the
+:prop_dir:`EXCLUDE_FROM_ALL` directory property is set.
+
+With ``EXCLUDE_FROM_ALL`` set to false or not set at all, the target
+will be brought up to date as part of doing a ``make install`` or its
+equivalent for the CMake generator being used. If a target has
+``EXCLUDE_FROM_ALL`` set to true, then any attempt to install that
+target has undefined behavior. Note that such a target can still safely
+be listed in an :command:`install(TARGETS)` command as long as the install
+components the target belongs to are not part of the set of components
+that anything tries to install.
diff --git a/Help/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD.rst b/Help/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD.rst
index a14e48c19..664704bfa 100644
--- a/Help/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD.rst
+++ b/Help/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD.rst
@@ -1,8 +1,8 @@
EXCLUDE_FROM_DEFAULT_BUILD
--------------------------
-Exclude target from "Build Solution".
+Exclude target from ``Build Solution``.
This property is only used by Visual Studio generators.
-When set to TRUE, the target will not be built when you press "Build
-Solution".
+When set to ``TRUE``, the target will not be built when you press
+``Build Solution``.
diff --git a/Help/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD_CONFIG.rst b/Help/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD_CONFIG.rst
index 655a9dee0..ad1021aa4 100644
--- a/Help/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD_CONFIG.rst
+++ b/Help/prop_tgt/EXCLUDE_FROM_DEFAULT_BUILD_CONFIG.rst
@@ -1,9 +1,10 @@
EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG>
-----------------------------------
-Per-configuration version of target exclusion from "Build Solution".
+Per-configuration version of target exclusion from ``Build Solution``.
This is the configuration-specific version of
-EXCLUDE_FROM_DEFAULT_BUILD. If the generic EXCLUDE_FROM_DEFAULT_BUILD
-is also set on a target, EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG> takes
+:prop_tgt:`EXCLUDE_FROM_DEFAULT_BUILD`. If the generic
+:prop_tgt:`EXCLUDE_FROM_DEFAULT_BUILD` is also set on a target,
+``EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG>`` takes
precedence in configurations for which it has a value.
diff --git a/Help/prop_tgt/EXPORT_NAME.rst b/Help/prop_tgt/EXPORT_NAME.rst
index 1b4247cc5..0e021d0db 100644
--- a/Help/prop_tgt/EXPORT_NAME.rst
+++ b/Help/prop_tgt/EXPORT_NAME.rst
@@ -3,6 +3,6 @@ EXPORT_NAME
Exported name for target files.
-This sets the name for the IMPORTED target generated when it this
-target is is exported. If not set, the logical target name is used by
-default.
+This sets the name for the ``IMPORTED`` target generated by the
+:command:`install(EXPORT)` and :command:`export` commands.
+If not set, the logical target name is used by default.
diff --git a/Help/prop_tgt/EXPORT_PROPERTIES.rst b/Help/prop_tgt/EXPORT_PROPERTIES.rst
new file mode 100644
index 000000000..bcf47a624
--- /dev/null
+++ b/Help/prop_tgt/EXPORT_PROPERTIES.rst
@@ -0,0 +1,14 @@
+EXPORT_PROPERTIES
+-----------------
+
+List additional properties to export for a target.
+
+This property contains a list of property names that should be exported by
+the :command:`install(EXPORT)` and :command:`export` commands. By default
+only a limited number of properties are exported. This property can be used
+to additionally export other properties as well.
+
+Properties starting with ``INTERFACE_`` or ``IMPORTED_`` are not allowed as
+they are reserved for internal CMake use.
+
+Properties containing generator expressions are also not allowed.
diff --git a/Help/prop_tgt/EchoString.rst b/Help/prop_tgt/EchoString.rst
index 32ae2aa8f..352d06258 100644
--- a/Help/prop_tgt/EchoString.rst
+++ b/Help/prop_tgt/EchoString.rst
@@ -3,5 +3,5 @@ EchoString
A message to be displayed when the target is built.
-A message to display on some generators (such as makefiles) when the
-target is built.
+A message to display on some generators (such as :ref:`Makefile Generators`)
+when the target is built.
diff --git a/Help/prop_tgt/FOLDER.rst b/Help/prop_tgt/FOLDER.rst
index bfe4e8e16..f6be9e673 100644
--- a/Help/prop_tgt/FOLDER.rst
+++ b/Help/prop_tgt/FOLDER.rst
@@ -3,8 +3,11 @@ FOLDER
Set the folder name. Use to organize targets in an IDE.
-Targets with no FOLDER property will appear as top level entities in
-IDEs like Visual Studio. Targets with the same FOLDER property value
+Targets with no ``FOLDER`` property will appear as top level entities in
+IDEs like Visual Studio. Targets with the same ``FOLDER`` property value
will appear next to each other in a folder of that name. To nest
-folders, use FOLDER values such as 'GUI/Dialogs' with '/' characters
+folders, use ``FOLDER`` values such as 'GUI/Dialogs' with '/' characters
separating folder levels.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_FOLDER` if it is set when a target is created.
diff --git a/Help/prop_tgt/FRAMEWORK.rst b/Help/prop_tgt/FRAMEWORK.rst
index 495d30e95..3dff1be3c 100644
--- a/Help/prop_tgt/FRAMEWORK.rst
+++ b/Help/prop_tgt/FRAMEWORK.rst
@@ -1,17 +1,19 @@
FRAMEWORK
---------
-Build ``SHARED`` or ``STATIC`` library as Framework Bundle on the OS X and iOS.
+Build ``SHARED`` or ``STATIC`` library as Framework Bundle on the macOS and iOS.
If such a library target has this property set to ``TRUE`` it will be
-built as a framework when built on the OS X and iOS. It will have the
+built as a framework when built on the macOS and iOS. It will have the
directory structure required for a framework and will be suitable to
-be used with the ``-framework`` option
+be used with the ``-framework`` option. This property is initialized by the
+value of the :variable:`CMAKE_FRAMEWORK` variable if it is set when a target is
+created.
To customize ``Info.plist`` file in the framework, use
:prop_tgt:`MACOSX_FRAMEWORK_INFO_PLIST` target property.
-For OS X see also the :prop_tgt:`FRAMEWORK_VERSION` target property.
+For macOS see also the :prop_tgt:`FRAMEWORK_VERSION` target property.
Example of creation ``dynamicFramework``:
diff --git a/Help/prop_tgt/FRAMEWORK_VERSION.rst b/Help/prop_tgt/FRAMEWORK_VERSION.rst
index 6aa30268a..c2ae7b98f 100644
--- a/Help/prop_tgt/FRAMEWORK_VERSION.rst
+++ b/Help/prop_tgt/FRAMEWORK_VERSION.rst
@@ -4,5 +4,5 @@ FRAMEWORK_VERSION
Version of a framework created using the :prop_tgt:`FRAMEWORK` target
property (e.g. ``A``).
-This property only affects OS X, as iOS doesn't have versioned
+This property only affects macOS, as iOS doesn't have versioned
directory structure.
diff --git a/Help/prop_tgt/Fortran_FORMAT.rst b/Help/prop_tgt/Fortran_FORMAT.rst
index 0a11d91ca..8704e5f42 100644
--- a/Help/prop_tgt/Fortran_FORMAT.rst
+++ b/Help/prop_tgt/Fortran_FORMAT.rst
@@ -1,11 +1,11 @@
Fortran_FORMAT
--------------
-Set to FIXED or FREE to indicate the Fortran source layout.
+Set to ``FIXED`` or ``FREE`` to indicate the Fortran source layout.
This property tells CMake whether the Fortran source files in a target
use fixed-format or free-format. CMake will pass the corresponding
-format flag to the compiler. Use the source-specific Fortran_FORMAT
+format flag to the compiler. Use the source-specific ``Fortran_FORMAT``
property to change the format of a specific source file. If the
-variable CMAKE_Fortran_FORMAT is set when a target is created its
+variable :variable:`CMAKE_Fortran_FORMAT` is set when a target is created its
value is used to initialize this property.
diff --git a/Help/prop_tgt/Fortran_MODULE_DIRECTORY.rst b/Help/prop_tgt/Fortran_MODULE_DIRECTORY.rst
index 9c8643764..e061863b3 100644
--- a/Help/prop_tgt/Fortran_MODULE_DIRECTORY.rst
+++ b/Help/prop_tgt/Fortran_MODULE_DIRECTORY.rst
@@ -8,10 +8,10 @@ the compiler supports a module output directory this specifies the
directory in which the modules will be placed. When this property is
not set the modules will be placed in the build directory
corresponding to the target's source directory. If the variable
-CMAKE_Fortran_MODULE_DIRECTORY is set when a target is created its
+:variable:`CMAKE_Fortran_MODULE_DIRECTORY` is set when a target is created its
value is used to initialize this property.
Note that some compilers will automatically search the module output
directory for modules USEd during compilation but others will not. If
your sources USE modules their location must be specified by
-INCLUDE_DIRECTORIES regardless of this property.
+:prop_tgt:`INCLUDE_DIRECTORIES` regardless of this property.
diff --git a/Help/prop_tgt/GENERATOR_FILE_NAME.rst b/Help/prop_tgt/GENERATOR_FILE_NAME.rst
index 032b22acf..a48610550 100644
--- a/Help/prop_tgt/GENERATOR_FILE_NAME.rst
+++ b/Help/prop_tgt/GENERATOR_FILE_NAME.rst
@@ -6,4 +6,4 @@ Generator's file for this target.
An internal property used by some generators to record the name of the
project or dsp file associated with this target. Note that at
configure time, this property is only set for targets created by
-include_external_msproject().
+:command:`include_external_msproject`.
diff --git a/Help/prop_tgt/GHS_INTEGRITY_APP.rst b/Help/prop_tgt/GHS_INTEGRITY_APP.rst
new file mode 100644
index 000000000..b6697817a
--- /dev/null
+++ b/Help/prop_tgt/GHS_INTEGRITY_APP.rst
@@ -0,0 +1,10 @@
+GHS_INTEGRITY_APP
+-----------------
+
+``ON`` / ``OFF`` boolean to determine if an executable target should
+be treated as an `Integrity Application`.
+
+If no value is set and if a ``.int`` file is added as a source file to the
+executable target it will be treated as an `Integrity Application`.
+
+Supported on :generator:`Green Hills MULTI`.
diff --git a/Help/prop_tgt/GHS_NO_SOURCE_GROUP_FILE.rst b/Help/prop_tgt/GHS_NO_SOURCE_GROUP_FILE.rst
new file mode 100644
index 000000000..11ce0b223
--- /dev/null
+++ b/Help/prop_tgt/GHS_NO_SOURCE_GROUP_FILE.rst
@@ -0,0 +1,13 @@
+GHS_NO_SOURCE_GROUP_FILE
+------------------------
+
+``ON`` / ``OFF`` boolean to control if the project file for a target should
+be one single file or multiple files.
+
+The default behavior or when the property is ``OFF`` is to generate a project
+file for the target and then a sub-project file for each source group.
+
+When this property is ``ON`` or if :variable:`CMAKE_GHS_NO_SOURCE_GROUP_FILE`
+is ``ON`` then only a single project file is generated for the target.
+
+Supported on :generator:`Green Hills MULTI`.
diff --git a/Help/prop_tgt/GNUtoMS.rst b/Help/prop_tgt/GNUtoMS.rst
index cf34da9c3..a09ebbfae 100644
--- a/Help/prop_tgt/GNUtoMS.rst
+++ b/Help/prop_tgt/GNUtoMS.rst
@@ -1,17 +1,17 @@
GNUtoMS
-------
-Convert GNU import library (.dll.a) to MS format (.lib).
+Convert GNU import library (``.dll.a``) to MS format (``.lib``).
When linking a shared library or executable that exports symbols using
GNU tools on Windows (MinGW/MSYS) with Visual Studio installed convert
-the import library (.dll.a) from GNU to MS format (.lib). Both import
-libraries will be installed by install(TARGETS) and exported by
-install(EXPORT) and export() to be linked by applications with either
-GNU- or MS-compatible tools.
+the import library (``.dll.a``) from GNU to MS format (``.lib``). Both import
+libraries will be installed by :command:`install(TARGETS)` and exported by
+:command:`install(EXPORT)` and :command:`export` to be linked
+by applications with either GNU- or MS-compatible tools.
-If the variable CMAKE_GNUtoMS is set when a target is created its
+If the variable ``CMAKE_GNUtoMS`` is set when a target is created its
value is used to initialize this property. The variable must be set
-prior to the first command that enables a language such as project()
-or enable_language(). CMake provides the variable as an option to the
+prior to the first command that enables a language such as :command:`project`
+or :command:`enable_language`. CMake provides the variable as an option to the
user automatically when configuring on Windows with GNU tools.
diff --git a/Help/prop_tgt/HAS_CXX.rst b/Help/prop_tgt/HAS_CXX.rst
index 7790932ae..15199b15b 100644
--- a/Help/prop_tgt/HAS_CXX.rst
+++ b/Help/prop_tgt/HAS_CXX.rst
@@ -3,5 +3,5 @@ HAS_CXX
Link the target using the C++ linker tool (obsolete).
-This is equivalent to setting the LINKER_LANGUAGE property to CXX.
-See that property's documentation for details.
+This is equivalent to setting the :prop_tgt:`LINKER_LANGUAGE`
+property to ``CXX``.
diff --git a/Help/prop_tgt/IMPORTED.rst b/Help/prop_tgt/IMPORTED.rst
index 605c1ce6c..22d28aaf7 100644
--- a/Help/prop_tgt/IMPORTED.rst
+++ b/Help/prop_tgt/IMPORTED.rst
@@ -1,8 +1,8 @@
IMPORTED
--------
-Read-only indication of whether a target is IMPORTED.
+Read-only indication of whether a target is ``IMPORTED``.
The boolean value of this property is ``True`` for targets created with
-the IMPORTED option to :command:`add_executable` or :command:`add_library`.
+the ``IMPORTED`` option to :command:`add_executable` or :command:`add_library`.
It is ``False`` for targets built within the project.
diff --git a/Help/prop_tgt/IMPORTED_COMMON_LANGUAGE_RUNTIME.rst b/Help/prop_tgt/IMPORTED_COMMON_LANGUAGE_RUNTIME.rst
new file mode 100644
index 000000000..99e3bc45e
--- /dev/null
+++ b/Help/prop_tgt/IMPORTED_COMMON_LANGUAGE_RUNTIME.rst
@@ -0,0 +1,8 @@
+IMPORTED_COMMON_LANGUAGE_RUNTIME
+--------------------------------
+
+Property to define if the target uses ``C++/CLI``.
+
+Ignored for non-imported targets.
+
+See also the :prop_tgt:`COMMON_LANGUAGE_RUNTIME` target property.
diff --git a/Help/prop_tgt/IMPORTED_GLOBAL.rst b/Help/prop_tgt/IMPORTED_GLOBAL.rst
new file mode 100644
index 000000000..1feca049d
--- /dev/null
+++ b/Help/prop_tgt/IMPORTED_GLOBAL.rst
@@ -0,0 +1,22 @@
+IMPORTED_GLOBAL
+---------------
+
+Indication of whether an :ref:`IMPORTED target <Imported Targets>` is
+globally visible.
+
+The boolean value of this property is True for targets created with the
+``IMPORTED`` ``GLOBAL`` options to :command:`add_executable()` or
+:command:`add_library()`. It is always False for targets built within the
+project.
+
+For targets created with the ``IMPORTED`` option to
+:command:`add_executable()` or :command:`add_library()` but without the
+additional option ``GLOBAL`` this is False, too. However, setting this
+property for such a locally ``IMPORTED`` target to True promotes that
+target to global scope. This promotion can only be done in the same
+directory where that ``IMPORTED`` target was created in the first place.
+
+Once an imported target has been made global, it cannot be changed back to
+non-global. Therefore, if a project sets this property, it may only
+provide a value of True. CMake will issue an error if the project tries to
+set the property to a non-True value, even if the value was already False.
diff --git a/Help/prop_tgt/IMPORTED_IMPLIB.rst b/Help/prop_tgt/IMPORTED_IMPLIB.rst
index acf4b321f..c8b6fde95 100644
--- a/Help/prop_tgt/IMPORTED_IMPLIB.rst
+++ b/Help/prop_tgt/IMPORTED_IMPLIB.rst
@@ -1,7 +1,9 @@
IMPORTED_IMPLIB
---------------
-Full path to the import library for an IMPORTED target.
+Full path to the import library for an ``IMPORTED`` target.
-Set this to the location of the ".lib" part of a windows DLL. Ignored
-for non-imported targets.
+Set this to the location of the ``.lib`` part of a Windows DLL, or on
+AIX set it to an import file created for executables that export symbols
+(see the :prop_tgt:`ENABLE_EXPORTS` target property).
+Ignored for non-imported targets.
diff --git a/Help/prop_tgt/IMPORTED_IMPLIB_CONFIG.rst b/Help/prop_tgt/IMPORTED_IMPLIB_CONFIG.rst
index b4b3f0228..5debabc95 100644
--- a/Help/prop_tgt/IMPORTED_IMPLIB_CONFIG.rst
+++ b/Help/prop_tgt/IMPORTED_IMPLIB_CONFIG.rst
@@ -1,7 +1,7 @@
IMPORTED_IMPLIB_<CONFIG>
------------------------
-<CONFIG>-specific version of IMPORTED_IMPLIB property.
+<CONFIG>-specific version of :prop_tgt:`IMPORTED_IMPLIB` property.
Configuration names correspond to those provided by the project from
which the target is imported.
diff --git a/Help/prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES.rst b/Help/prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES.rst
index 2db2b0e58..f7e216581 100644
--- a/Help/prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES.rst
+++ b/Help/prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES.rst
@@ -8,7 +8,7 @@ their implementation. On some platforms the linker searches for the
dependent libraries of shared libraries they are including in the
link. Set this property to the list of dependent shared libraries of
an imported library. The list should be disjoint from the list of
-interface libraries in the INTERFACE_LINK_LIBRARIES property. On
+interface libraries in the :prop_tgt:`INTERFACE_LINK_LIBRARIES` property. On
platforms requiring dependent shared libraries to be found at link
time CMake uses this list to add appropriate files or paths to the
link command line. Ignored for non-imported targets.
diff --git a/Help/prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES_CONFIG.rst b/Help/prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES_CONFIG.rst
index ee243c75d..5b9c51308 100644
--- a/Help/prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES_CONFIG.rst
+++ b/Help/prop_tgt/IMPORTED_LINK_DEPENDENT_LIBRARIES_CONFIG.rst
@@ -1,7 +1,7 @@
IMPORTED_LINK_DEPENDENT_LIBRARIES_<CONFIG>
------------------------------------------
-<CONFIG>-specific version of IMPORTED_LINK_DEPENDENT_LIBRARIES.
+<CONFIG>-specific version of :prop_tgt:`IMPORTED_LINK_DEPENDENT_LIBRARIES`.
Configuration names correspond to those provided by the project from
which the target is imported. If set, this property completely
diff --git a/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES.rst b/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES.rst
index 5ca9c8b6f..4ed4281f3 100644
--- a/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES.rst
+++ b/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES.rst
@@ -1,14 +1,14 @@
IMPORTED_LINK_INTERFACE_LANGUAGES
---------------------------------
-Languages compiled into an IMPORTED static library.
+Languages compiled into an ``IMPORTED`` static library.
Set this to the list of languages of source files compiled to produce
-a STATIC IMPORTED library (such as "C" or "CXX"). CMake accounts for
+a ``STATIC IMPORTED`` library (such as ``C`` or ``CXX``). CMake accounts for
these languages when computing how to link a target to the imported
library. For example, when a C executable links to an imported C++
static library CMake chooses the C++ linker to satisfy language
runtime dependencies of the static library.
-This property is ignored for targets that are not STATIC libraries.
+This property is ignored for targets that are not ``STATIC`` libraries.
This property is ignored for non-imported targets.
diff --git a/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES_CONFIG.rst b/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES_CONFIG.rst
index d4a10fbdd..40fcf7fcf 100644
--- a/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES_CONFIG.rst
+++ b/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LANGUAGES_CONFIG.rst
@@ -1,7 +1,7 @@
IMPORTED_LINK_INTERFACE_LANGUAGES_<CONFIG>
------------------------------------------
-<CONFIG>-specific version of IMPORTED_LINK_INTERFACE_LANGUAGES.
+<CONFIG>-specific version of :prop_tgt:`IMPORTED_LINK_INTERFACE_LANGUAGES`.
Configuration names correspond to those provided by the project from
which the target is imported. If set, this property completely
diff --git a/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES.rst b/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES.rst
index 61134a401..527cf2ebe 100644
--- a/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES.rst
+++ b/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES.rst
@@ -1,16 +1,16 @@
IMPORTED_LINK_INTERFACE_LIBRARIES
---------------------------------
-Transitive link interface of an IMPORTED target.
+Transitive link interface of an ``IMPORTED`` target.
Set this to the list of libraries whose interface is included when an
-IMPORTED library target is linked to another target. The libraries
+``IMPORTED`` library target is linked to another target. The libraries
will be included on the link line for the target. Unlike the
-LINK_INTERFACE_LIBRARIES property, this property applies to all
-imported target types, including STATIC libraries. This property is
+:prop_tgt:`LINK_INTERFACE_LIBRARIES` property, this property applies to all
+imported target types, including ``STATIC`` libraries. This property is
ignored for non-imported targets.
This property is ignored if the target also has a non-empty
-INTERFACE_LINK_LIBRARIES property.
+:prop_tgt:`INTERFACE_LINK_LIBRARIES` property.
-This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead.
+This property is deprecated. Use :prop_tgt:`INTERFACE_LINK_LIBRARIES` instead.
diff --git a/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES_CONFIG.rst b/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES_CONFIG.rst
index 13b93ba98..050fb1dff 100644
--- a/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES_CONFIG.rst
+++ b/Help/prop_tgt/IMPORTED_LINK_INTERFACE_LIBRARIES_CONFIG.rst
@@ -1,13 +1,13 @@
IMPORTED_LINK_INTERFACE_LIBRARIES_<CONFIG>
------------------------------------------
-<CONFIG>-specific version of IMPORTED_LINK_INTERFACE_LIBRARIES.
+<CONFIG>-specific version of :prop_tgt:`IMPORTED_LINK_INTERFACE_LIBRARIES`.
Configuration names correspond to those provided by the project from
which the target is imported. If set, this property completely
overrides the generic property for the named configuration.
This property is ignored if the target also has a non-empty
-INTERFACE_LINK_LIBRARIES property.
+:prop_tgt:`INTERFACE_LINK_LIBRARIES` property.
-This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead.
+This property is deprecated. Use :prop_tgt:`INTERFACE_LINK_LIBRARIES` instead.
diff --git a/Help/prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY.rst b/Help/prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY.rst
index 3a86b9985..7a92d96b6 100644
--- a/Help/prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY.rst
+++ b/Help/prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY.rst
@@ -1,6 +1,6 @@
IMPORTED_LINK_INTERFACE_MULTIPLICITY
------------------------------------
-Repetition count for cycles of IMPORTED static libraries.
+Repetition count for cycles of ``IMPORTED`` static libraries.
-This is LINK_INTERFACE_MULTIPLICITY for IMPORTED targets.
+This is :prop_tgt:`LINK_INTERFACE_MULTIPLICITY` for ``IMPORTED`` targets.
diff --git a/Help/prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY_CONFIG.rst b/Help/prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY_CONFIG.rst
index 33b9b8419..758237bf1 100644
--- a/Help/prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY_CONFIG.rst
+++ b/Help/prop_tgt/IMPORTED_LINK_INTERFACE_MULTIPLICITY_CONFIG.rst
@@ -1,7 +1,7 @@
IMPORTED_LINK_INTERFACE_MULTIPLICITY_<CONFIG>
---------------------------------------------
-<CONFIG>-specific version of IMPORTED_LINK_INTERFACE_MULTIPLICITY.
+<CONFIG>-specific version of :prop_tgt:`IMPORTED_LINK_INTERFACE_MULTIPLICITY`.
If set, this property completely overrides the generic property for
the named configuration.
diff --git a/Help/prop_tgt/IMPORTED_LOCATION.rst b/Help/prop_tgt/IMPORTED_LOCATION.rst
index 8cfef7343..f0a1646b1 100644
--- a/Help/prop_tgt/IMPORTED_LOCATION.rst
+++ b/Help/prop_tgt/IMPORTED_LOCATION.rst
@@ -1,21 +1,31 @@
IMPORTED_LOCATION
-----------------
-Full path to the main file on disk for an IMPORTED target.
+Full path to the main file on disk for an ``IMPORTED`` target.
-Set this to the location of an IMPORTED target file on disk. For
+Set this to the location of an ``IMPORTED`` target file on disk. For
executables this is the location of the executable file. For bundles
-on OS X this is the location of the executable file inside
-Contents/MacOS under the application bundle folder. For static
+on macOS this is the location of the executable file inside
+``Contents/MacOS`` under the application bundle folder. For ``STATIC``
libraries and modules this is the location of the library or module.
-For shared libraries on non-DLL platforms this is the location of the
-shared library. For frameworks on OS X this is the location of the
+For ``SHARED`` libraries on non-DLL platforms this is the location of the
+shared library. For frameworks on macOS this is the location of the
library file symlink just inside the framework folder. For DLLs this
-is the location of the ".dll" part of the library. For UNKNOWN
+is the location of the ``.dll`` part of the library. For ``UNKNOWN``
libraries this is the location of the file to be linked. Ignored for
non-imported targets.
-Projects may skip IMPORTED_LOCATION if the configuration-specific
-property IMPORTED_LOCATION_<CONFIG> is set. To get the location of an
-imported target read one of the LOCATION or LOCATION_<CONFIG>
-properties.
+The ``IMPORTED_LOCATION`` target property may be overridden for a
+given configuration ``<CONFIG>`` by the configuration-specific
+:prop_tgt:`IMPORTED_LOCATION_<CONFIG>` target property. Furthermore,
+the :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` target property may be
+used to map between a project's configurations and those of an imported
+target. If none of these is set then the name of any other configuration
+listed in the :prop_tgt:`IMPORTED_CONFIGURATIONS` target property may be
+selected and its :prop_tgt:`IMPORTED_LOCATION_<CONFIG>` value used.
+
+To get the location of an imported target read one of the :prop_tgt:`LOCATION`
+or ``LOCATION_<CONFIG>`` properties.
+
+For platforms with import libraries (e.g. Windows) see also
+:prop_tgt:`IMPORTED_IMPLIB`.
diff --git a/Help/prop_tgt/IMPORTED_LOCATION_CONFIG.rst b/Help/prop_tgt/IMPORTED_LOCATION_CONFIG.rst
index f85bb19c9..c5f5f048c 100644
--- a/Help/prop_tgt/IMPORTED_LOCATION_CONFIG.rst
+++ b/Help/prop_tgt/IMPORTED_LOCATION_CONFIG.rst
@@ -1,7 +1,7 @@
IMPORTED_LOCATION_<CONFIG>
--------------------------
-<CONFIG>-specific version of IMPORTED_LOCATION property.
+<CONFIG>-specific version of :prop_tgt:`IMPORTED_LOCATION` property.
Configuration names correspond to those provided by the project from
which the target is imported.
diff --git a/Help/prop_tgt/IMPORTED_NO_SONAME.rst b/Help/prop_tgt/IMPORTED_NO_SONAME.rst
index 4a1bb447a..cbb764226 100644
--- a/Help/prop_tgt/IMPORTED_NO_SONAME.rst
+++ b/Help/prop_tgt/IMPORTED_NO_SONAME.rst
@@ -1,9 +1,9 @@
IMPORTED_NO_SONAME
------------------
-Specifies that an IMPORTED shared library target has no "soname".
+Specifies that an ``IMPORTED`` shared library target has no ``soname``.
Set this property to true for an imported shared library file that has
-no "soname" field. CMake may adjust generated link commands for some
+no ``soname`` field. CMake may adjust generated link commands for some
platforms to prevent the linker from using the path to the library in
-place of its missing soname. Ignored for non-imported targets.
+place of its missing ``soname``. Ignored for non-imported targets.
diff --git a/Help/prop_tgt/IMPORTED_NO_SONAME_CONFIG.rst b/Help/prop_tgt/IMPORTED_NO_SONAME_CONFIG.rst
index 22d68220c..76fe471f4 100644
--- a/Help/prop_tgt/IMPORTED_NO_SONAME_CONFIG.rst
+++ b/Help/prop_tgt/IMPORTED_NO_SONAME_CONFIG.rst
@@ -1,7 +1,7 @@
IMPORTED_NO_SONAME_<CONFIG>
---------------------------
-<CONFIG>-specific version of IMPORTED_NO_SONAME property.
+<CONFIG>-specific version of :prop_tgt:`IMPORTED_NO_SONAME` property.
Configuration names correspond to those provided by the project from
which the target is imported.
diff --git a/Help/prop_tgt/IMPORTED_OBJECTS.rst b/Help/prop_tgt/IMPORTED_OBJECTS.rst
index 222e6cc02..50a329fb3 100644
--- a/Help/prop_tgt/IMPORTED_OBJECTS.rst
+++ b/Help/prop_tgt/IMPORTED_OBJECTS.rst
@@ -1,7 +1,7 @@
IMPORTED_OBJECTS
----------------
-:ref:`;-list <CMake Language Lists>` of absolute paths to the object
+A :ref:`semicolon-separated list <CMake Language Lists>` of absolute paths to the object
files on disk for an :ref:`imported <Imported targets>`
:ref:`object library <object libraries>`.
diff --git a/Help/prop_tgt/IMPORTED_SONAME.rst b/Help/prop_tgt/IMPORTED_SONAME.rst
index d80907e3e..bf0c3cbc1 100644
--- a/Help/prop_tgt/IMPORTED_SONAME.rst
+++ b/Help/prop_tgt/IMPORTED_SONAME.rst
@@ -1,8 +1,8 @@
IMPORTED_SONAME
---------------
-The "soname" of an IMPORTED target of shared library type.
+The ``soname`` of an ``IMPORTED`` target of shared library type.
-Set this to the "soname" embedded in an imported shared library. This
+Set this to the ``soname`` embedded in an imported shared library. This
is meaningful only on platforms supporting the feature. Ignored for
non-imported targets.
diff --git a/Help/prop_tgt/IMPORTED_SONAME_CONFIG.rst b/Help/prop_tgt/IMPORTED_SONAME_CONFIG.rst
index 6ec9af3f8..59a9d1a45 100644
--- a/Help/prop_tgt/IMPORTED_SONAME_CONFIG.rst
+++ b/Help/prop_tgt/IMPORTED_SONAME_CONFIG.rst
@@ -1,7 +1,7 @@
IMPORTED_SONAME_<CONFIG>
------------------------
-<CONFIG>-specific version of IMPORTED_SONAME property.
+<CONFIG>-specific version of :prop_tgt:`IMPORTED_SONAME` property.
Configuration names correspond to those provided by the project from
which the target is imported.
diff --git a/Help/prop_tgt/IMPORT_PREFIX.rst b/Help/prop_tgt/IMPORT_PREFIX.rst
index deede9788..17e381be4 100644
--- a/Help/prop_tgt/IMPORT_PREFIX.rst
+++ b/Help/prop_tgt/IMPORT_PREFIX.rst
@@ -3,7 +3,7 @@ IMPORT_PREFIX
What comes before the import library name.
-Similar to the target property PREFIX, but used for import libraries
-(typically corresponding to a DLL) instead of regular libraries. A
-target property that can be set to override the prefix (such as "lib")
+Similar to the target property :prop_tgt:`PREFIX`, but used for import libraries
+(typically corresponding to a ``DLL``) instead of regular libraries. A
+target property that can be set to override the prefix (such as ``lib``)
on an import library name.
diff --git a/Help/prop_tgt/IMPORT_SUFFIX.rst b/Help/prop_tgt/IMPORT_SUFFIX.rst
index bd0125037..9307115b4 100644
--- a/Help/prop_tgt/IMPORT_SUFFIX.rst
+++ b/Help/prop_tgt/IMPORT_SUFFIX.rst
@@ -3,7 +3,7 @@ IMPORT_SUFFIX
What comes after the import library name.
-Similar to the target property SUFFIX, but used for import libraries
-(typically corresponding to a DLL) instead of regular libraries. A
-target property that can be set to override the suffix (such as
-".lib") on an import library name.
+Similar to the target property :prop_tgt:`SUFFIX`, but used
+for import libraries (typically corresponding to a ``DLL``) instead of
+regular libraries. A target property that can be set to override
+the suffix (such as ``.lib``) on an import library name.
diff --git a/Help/prop_tgt/INCLUDE_DIRECTORIES.rst b/Help/prop_tgt/INCLUDE_DIRECTORIES.rst
index 8b40d9c34..b381d1dbd 100644
--- a/Help/prop_tgt/INCLUDE_DIRECTORIES.rst
+++ b/Help/prop_tgt/INCLUDE_DIRECTORIES.rst
@@ -18,7 +18,7 @@ paths for the compiler.
Relative paths should not be added to this property directly. Use one of
the commands above instead to handle relative paths.
-Contents of ``INCLUDE_DIRECTORIES`` may use "generator expressions" with
+Contents of ``INCLUDE_DIRECTORIES`` may use :manual:`cmake-generator-expressions(7)` with
the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
diff --git a/Help/prop_tgt/INSTALL_NAME_DIR.rst b/Help/prop_tgt/INSTALL_NAME_DIR.rst
index a67ec1584..2216072ac 100644
--- a/Help/prop_tgt/INSTALL_NAME_DIR.rst
+++ b/Help/prop_tgt/INSTALL_NAME_DIR.rst
@@ -1,8 +1,12 @@
INSTALL_NAME_DIR
----------------
-Mac OSX directory name for installed targets.
+macOS directory name for installed targets.
-INSTALL_NAME_DIR is a string specifying the directory portion of the
-"install_name" field of shared libraries on Mac OSX to use in the
+``INSTALL_NAME_DIR`` is a string specifying the directory portion of the
+"install_name" field of shared libraries on macOS to use in the
installed targets.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_INSTALL_NAME_DIR` if it is set when a target is
+created.
diff --git a/Help/prop_tgt/INSTALL_REMOVE_ENVIRONMENT_RPATH.rst b/Help/prop_tgt/INSTALL_REMOVE_ENVIRONMENT_RPATH.rst
new file mode 100644
index 000000000..72dcaa0b1
--- /dev/null
+++ b/Help/prop_tgt/INSTALL_REMOVE_ENVIRONMENT_RPATH.rst
@@ -0,0 +1,16 @@
+INSTALL_REMOVE_ENVIRONMENT_RPATH
+--------------------------------
+
+Controls whether toolchain-defined rpaths should be removed during installation.
+
+When a target is being installed, CMake may need to rewrite its rpath
+information. This occurs when the install rpath (as specified by the
+:prop_tgt:`INSTALL_RPATH` target property) has different contents to the rpath
+that the target was built with. Some toolchains insert their own rpath
+contents into the binary as part of the build. By default, CMake will
+preserve those extra inserted contents in the install rpath. For those
+scenarios where such toolchain-inserted entries need to be discarded during
+install, set the ``INSTALL_REMOVE_ENVIRONMENT_RPATH`` target property to true.
+
+This property is initialized by the value of
+:variable:`CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH` when the target is created.
diff --git a/Help/prop_tgt/INSTALL_RPATH.rst b/Help/prop_tgt/INSTALL_RPATH.rst
index 6206b6889..93b448830 100644
--- a/Help/prop_tgt/INSTALL_RPATH.rst
+++ b/Help/prop_tgt/INSTALL_RPATH.rst
@@ -5,5 +5,8 @@ The rpath to use for installed targets.
A semicolon-separated list specifying the rpath to use in installed
targets (for platforms that support it). This property is initialized
-by the value of the variable CMAKE_INSTALL_RPATH if it is set when a
-target is created.
+by the value of the variable :variable:`CMAKE_INSTALL_RPATH` if it is set when
+a target is created.
+
+This property supports
+:manual:`generator expressions <cmake-generator-expressions(7)>`.
diff --git a/Help/prop_tgt/INSTALL_RPATH_USE_LINK_PATH.rst b/Help/prop_tgt/INSTALL_RPATH_USE_LINK_PATH.rst
index f0006f85b..d8be9548a 100644
--- a/Help/prop_tgt/INSTALL_RPATH_USE_LINK_PATH.rst
+++ b/Help/prop_tgt/INSTALL_RPATH_USE_LINK_PATH.rst
@@ -3,8 +3,8 @@ INSTALL_RPATH_USE_LINK_PATH
Add paths to linker search and installed rpath.
-INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to true will
+``INSTALL_RPATH_USE_LINK_PATH`` is a boolean that if set to ``True`` will
append directories in the linker search path and outside the project
-to the INSTALL_RPATH. This property is initialized by the value of
-the variable CMAKE_INSTALL_RPATH_USE_LINK_PATH if it is set when a
+to the :prop_tgt:`INSTALL_RPATH`. This property is initialized by the value of
+the variable ``CMAKE_INSTALL_RPATH_USE_LINK_PATH`` if it is set when a
target is created.
diff --git a/Help/prop_tgt/INTERFACE_LINK_DEPENDS.rst b/Help/prop_tgt/INTERFACE_LINK_DEPENDS.rst
new file mode 100644
index 000000000..790554d9f
--- /dev/null
+++ b/Help/prop_tgt/INTERFACE_LINK_DEPENDS.rst
@@ -0,0 +1,32 @@
+INTERFACE_LINK_DEPENDS
+----------------------
+
+Additional public interface files on which a target binary depends for linking.
+
+This property is supported only by :generator:`Ninja` and
+:ref:`Makefile Generators`.
+It is intended to specify dependencies on "linker scripts" for
+custom Makefile link rules.
+
+When target dependencies are specified using :command:`target_link_libraries`,
+CMake will read this property from all target dependencies to determine the
+build properties of the consumer.
+
+Contents of ``INTERFACE_LINK_DEPENDS`` may use "generator expressions"
+with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. See the :manual:`cmake-buildsystem(7)`
+-manual for more on defining buildsystem properties.
+
+Link dependency files usage requirements commonly differ between the build-tree
+and the install-tree. The ``BUILD_INTERFACE`` and ``INSTALL_INTERFACE``
+generator expressions can be used to describe separate usage requirements
+based on the usage location. Relative paths are allowed within the
+``INSTALL_INTERFACE`` expression and are interpreted relative to the
+installation prefix. For example:
+
+.. code-block:: cmake
+
+ set_property(TARGET mylib PROPERTY INTERFACE_LINK_DEPENDS
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/mylinkscript>
+ $<INSTALL_INTERFACE:mylinkscript> # <prefix>/mylinkscript
+ )
diff --git a/Help/prop_tgt/INTERFACE_LINK_DIRECTORIES.rst b/Help/prop_tgt/INTERFACE_LINK_DIRECTORIES.rst
new file mode 100644
index 000000000..56a4ec0ec
--- /dev/null
+++ b/Help/prop_tgt/INTERFACE_LINK_DIRECTORIES.rst
@@ -0,0 +1,9 @@
+INTERFACE_LINK_DIRECTORIES
+--------------------------
+
+.. |property_name| replace:: link directories
+.. |command_name| replace:: :command:`target_link_directories`
+.. |PROPERTY_INTERFACE_NAME| replace:: ``INTERFACE_LINK_DIRECTORIES``
+.. |PROPERTY_LINK| replace:: :prop_tgt:`LINK_DIRECTORIES`
+.. |PROPERTY_GENEX| replace:: ``$<TARGET_PROPERTY:foo,INTERFACE_LINK_DIRECTORIES>``
+.. include:: INTERFACE_BUILD_PROPERTY.txt
diff --git a/Help/prop_tgt/INTERFACE_LINK_LIBRARIES.rst b/Help/prop_tgt/INTERFACE_LINK_LIBRARIES.rst
index 832d12bbc..bf7f72f4c 100644
--- a/Help/prop_tgt/INTERFACE_LINK_LIBRARIES.rst
+++ b/Help/prop_tgt/INTERFACE_LINK_LIBRARIES.rst
@@ -17,6 +17,8 @@ with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
manual for available expressions. See the :manual:`cmake-buildsystem(7)`
manual for more on defining buildsystem properties.
+.. include:: LINK_LIBRARIES_INDIRECTION.txt
+
Creating Relocatable Packages
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Help/prop_tgt/INTERFACE_LINK_OPTIONS.rst b/Help/prop_tgt/INTERFACE_LINK_OPTIONS.rst
new file mode 100644
index 000000000..c293b986d
--- /dev/null
+++ b/Help/prop_tgt/INTERFACE_LINK_OPTIONS.rst
@@ -0,0 +1,9 @@
+INTERFACE_LINK_OPTIONS
+----------------------
+
+.. |property_name| replace:: link options
+.. |command_name| replace:: :command:`target_link_options`
+.. |PROPERTY_INTERFACE_NAME| replace:: ``INTERFACE_LINK_OPTIONS``
+.. |PROPERTY_LINK| replace:: :prop_tgt:`LINK_OPTIONS`
+.. |PROPERTY_GENEX| replace:: ``$<TARGET_PROPERTY:foo,INTERFACE_LINK_OPTIONS>``
+.. include:: INTERFACE_BUILD_PROPERTY.txt
diff --git a/Help/prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE.rst b/Help/prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE.rst
index ea700dfe9..4336d7182 100644
--- a/Help/prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE.rst
+++ b/Help/prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE.rst
@@ -14,3 +14,9 @@ undefined, then consumers will determine their
:prop_tgt:`POSITION_INDEPENDENT_CODE` property by other means. Consumers
must ensure that the targets that they link to have a consistent
requirement for their ``INTERFACE_POSITION_INDEPENDENT_CODE`` property.
+
+Contents of ``INTERFACE_POSITION_INDEPENDENT_CODE`` may use
+"generator expressions" with the syntax ``$<...>``. See the
+:manual:`cmake-generator-expressions(7)` manual for available expressions.
+See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem
+properties.
diff --git a/Help/prop_tgt/INTERFACE_PRECOMPILE_HEADERS.rst b/Help/prop_tgt/INTERFACE_PRECOMPILE_HEADERS.rst
new file mode 100644
index 000000000..e2854074c
--- /dev/null
+++ b/Help/prop_tgt/INTERFACE_PRECOMPILE_HEADERS.rst
@@ -0,0 +1,16 @@
+INTERFACE_PRECOMPILE_HEADERS
+----------------------------
+
+List of interface header files to precompile into consuming targets.
+
+Targets may populate this property to publish the header files
+for consuming targets to precompile. The :command:`target_precompile_headers`
+command populates this property with values given to the ``PUBLIC`` and
+``INTERFACE`` keywords. Projects may also get and set the property directly.
+See the discussion in :command:`target_precompile_headers` for guidance on
+appropriate use of this property for installed or exported targets.
+
+Contents of ``INTERFACE_PRECOMPILE_HEADERS`` may use "generator expressions"
+with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
diff --git a/Help/prop_tgt/INTERPROCEDURAL_OPTIMIZATION.rst b/Help/prop_tgt/INTERPROCEDURAL_OPTIMIZATION.rst
index 3f68c3128..d3a5e9414 100644
--- a/Help/prop_tgt/INTERPROCEDURAL_OPTIMIZATION.rst
+++ b/Help/prop_tgt/INTERPROCEDURAL_OPTIMIZATION.rst
@@ -4,7 +4,9 @@ INTERPROCEDURAL_OPTIMIZATION
Enable interprocedural optimization for a target.
If set to true, enables interprocedural optimizations if they are
-known to be supported by the compiler.
+known :module:`to be supported <CheckIPOSupported>` by the compiler. Depending
+on value of policy :policy:`CMP0069`, the error will be reported or ignored,
+if interprocedural optimization is enabled but not supported.
This property is initialized by the
:variable:`CMAKE_INTERPROCEDURAL_OPTIMIZATION` variable if it is set when a
diff --git a/Help/prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG.rst b/Help/prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG.rst
index 782b0f0a6..79d46048b 100644
--- a/Help/prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG.rst
+++ b/Help/prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG.rst
@@ -3,7 +3,7 @@ INTERPROCEDURAL_OPTIMIZATION_<CONFIG>
Per-configuration interprocedural optimization for a target.
-This is a per-configuration version of INTERPROCEDURAL_OPTIMIZATION.
+This is a per-configuration version of :prop_tgt:`INTERPROCEDURAL_OPTIMIZATION`.
If set, this property overrides the generic property for the named
configuration.
diff --git a/Help/prop_tgt/LANG_CLANG_TIDY.rst b/Help/prop_tgt/LANG_CLANG_TIDY.rst
index 2887e235d..2bfef6673 100644
--- a/Help/prop_tgt/LANG_CLANG_TIDY.rst
+++ b/Help/prop_tgt/LANG_CLANG_TIDY.rst
@@ -3,7 +3,7 @@
This property is implemented only when ``<LANG>`` is ``C`` or ``CXX``.
-Specify a :ref:`;-list <CMake Language Lists>` containing a command
+Specify a :ref:`semicolon-separated list <CMake Language Lists>` containing a command
line for the ``clang-tidy`` tool. The :ref:`Makefile Generators`
and the :generator:`Ninja` generator will run this tool along with the
compiler and report a warning if the tool reports any problems.
diff --git a/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst b/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst
index 0fe0b31e5..a6f2b24f6 100644
--- a/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst
+++ b/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst
@@ -1,9 +1,10 @@
<LANG>_COMPILER_LAUNCHER
------------------------
-This property is implemented only when ``<LANG>`` is ``C`` or ``CXX``.
+This property is implemented only when ``<LANG>`` is ``C``, ``CXX``,
+``Fortran``, ``OBJC``, ``OBJCXX``, or ``CUDA``.
-Specify a :ref:`;-list <CMake Language Lists>` containing a command line
+Specify a :ref:`semicolon-separated list <CMake Language Lists>` containing a command line
for a compiler launching tool. The :ref:`Makefile Generators` and the
:generator:`Ninja` generator will run this tool and pass the compiler and
its arguments to the tool. Some example tools are distcc and ccache.
diff --git a/Help/prop_tgt/LANG_CPPCHECK.rst b/Help/prop_tgt/LANG_CPPCHECK.rst
new file mode 100644
index 000000000..60785d062
--- /dev/null
+++ b/Help/prop_tgt/LANG_CPPCHECK.rst
@@ -0,0 +1,15 @@
+<LANG>_CPPCHECK
+---------------
+
+This property is supported only when ``<LANG>`` is ``C`` or ``CXX``.
+
+Specify a :ref:`semicolon-separated list <CMake Language Lists>` containing a command line
+for the ``cppcheck`` static analysis tool. The :ref:`Makefile Generators`
+and the :generator:`Ninja` generator will run ``cppcheck`` along with the
+compiler and report any problems. If the command-line specifies the
+exit code options to ``cppcheck`` then the build will fail if the
+tool returns non-zero.
+
+This property is initialized by the value of the
+:variable:`CMAKE_<LANG>_CPPCHECK` variable if it is set when a target is
+created.
diff --git a/Help/prop_tgt/LANG_CPPLINT.rst b/Help/prop_tgt/LANG_CPPLINT.rst
index 14f47d465..9944c88ba 100644
--- a/Help/prop_tgt/LANG_CPPLINT.rst
+++ b/Help/prop_tgt/LANG_CPPLINT.rst
@@ -3,7 +3,7 @@
This property is supported only when ``<LANG>`` is ``C`` or ``CXX``.
-Specify a :ref:`;-list <CMake Language Lists>` containing a command line
+Specify a :ref:`semicolon-separated list <CMake Language Lists>` containing a command line
for the ``cpplint`` style checker. The :ref:`Makefile Generators` and the
:generator:`Ninja` generator will run ``cpplint`` along with the compiler
and report any problems.
diff --git a/Help/prop_tgt/LANG_INCLUDE_WHAT_YOU_USE.rst b/Help/prop_tgt/LANG_INCLUDE_WHAT_YOU_USE.rst
index 26f6d1671..35220e414 100644
--- a/Help/prop_tgt/LANG_INCLUDE_WHAT_YOU_USE.rst
+++ b/Help/prop_tgt/LANG_INCLUDE_WHAT_YOU_USE.rst
@@ -3,7 +3,7 @@
This property is implemented only when ``<LANG>`` is ``C`` or ``CXX``.
-Specify a :ref:`;-list <CMake Language Lists>` containing a command
+Specify a :ref:`semicolon-separated list <CMake Language Lists>` containing a command
line for the ``include-what-you-use`` tool. The :ref:`Makefile Generators`
and the :generator:`Ninja` generator will run this tool along with the
compiler and report a warning if the tool reports any problems.
diff --git a/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst
index 28dd404df..5cefc38bb 100644
--- a/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst
+++ b/Help/prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG.rst
@@ -6,7 +6,8 @@ Per-configuration output directory for
This is a per-configuration version of the
:prop_tgt:`LIBRARY_OUTPUT_DIRECTORY` target property, but
-multi-configuration generators (VS, Xcode) do NOT append a
+multi-configuration generators (:ref:`Visual Studio Generators`,
+:generator:`Xcode`) do NOT append a
per-configuration subdirectory to the specified directory. This
property is initialized by the value of the
:variable:`CMAKE_LIBRARY_OUTPUT_DIRECTORY_<CONFIG>` variable if
diff --git a/Help/prop_tgt/LINKER_LANGUAGE.rst b/Help/prop_tgt/LINKER_LANGUAGE.rst
index b1ca86710..b0a572b5c 100644
--- a/Help/prop_tgt/LINKER_LANGUAGE.rst
+++ b/Help/prop_tgt/LINKER_LANGUAGE.rst
@@ -8,7 +8,7 @@ whose compiler is used to link the target (such as "C" or "CXX"). A
typical value for an executable is the language of the source file
providing the program entry point (main). If not set, the language
with the highest linker preference value is the default. See
-documentation of CMAKE_<LANG>_LINKER_PREFERENCE variables.
+documentation of :variable:`CMAKE_<LANG>_LINKER_PREFERENCE` variables.
If this property is not set by the user, it will be calculated at
generate-time by CMake.
diff --git a/Help/prop_tgt/LINK_DEPENDS.rst b/Help/prop_tgt/LINK_DEPENDS.rst
index 5576b85fa..e59d4c014 100644
--- a/Help/prop_tgt/LINK_DEPENDS.rst
+++ b/Help/prop_tgt/LINK_DEPENDS.rst
@@ -7,6 +7,12 @@ Specifies a semicolon-separated list of full-paths to files on which
the link rule for this target depends. The target binary will be
linked if any of the named files is newer than it.
-This property is ignored by non-Makefile generators. It is intended
-to specify dependencies on "linker scripts" for custom Makefile link
+This property is supported only by :generator:`Ninja` and
+:ref:`Makefile Generators`. It is
+intended to specify dependencies on "linker scripts" for custom Makefile link
rules.
+
+Contents of ``LINK_DEPENDS`` may use "generator expressions" with
+the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
diff --git a/Help/prop_tgt/LINK_DIRECTORIES.rst b/Help/prop_tgt/LINK_DIRECTORIES.rst
new file mode 100644
index 000000000..c2905b37d
--- /dev/null
+++ b/Help/prop_tgt/LINK_DIRECTORIES.rst
@@ -0,0 +1,18 @@
+LINK_DIRECTORIES
+----------------
+
+List of directories to use for the link step of shared library, module
+and executable targets.
+
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of directories
+specified so far for its target. Use the :command:`target_link_directories`
+command to append more search directories.
+
+This property is initialized by the :prop_dir:`LINK_DIRECTORIES` directory
+property when a target is created, and is used by the generators to set
+the search directories for the linker.
+
+Contents of ``LINK_DIRECTORIES`` may use "generator expressions" with the
+syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual
+for available expressions. See the :manual:`cmake-buildsystem(7)` manual
+for more on defining buildsystem properties.
diff --git a/Help/prop_tgt/LINK_FLAGS.rst b/Help/prop_tgt/LINK_FLAGS.rst
index 409d00a29..92cd3c0a5 100644
--- a/Help/prop_tgt/LINK_FLAGS.rst
+++ b/Help/prop_tgt/LINK_FLAGS.rst
@@ -1,8 +1,16 @@
LINK_FLAGS
----------
-Additional flags to use when linking this target.
+Additional flags to use when linking this target if it is a shared library,
+module library, or an executable. Static libraries need to use
+:prop_tgt:`STATIC_LIBRARY_OPTIONS` or :prop_tgt:`STATIC_LIBRARY_FLAGS`
+properties.
-The LINK_FLAGS property can be used to add extra flags to the link
-step of a target. LINK_FLAGS_<CONFIG> will add to the configuration
-<CONFIG>, for example, DEBUG, RELEASE, MINSIZEREL, RELWITHDEBINFO.
+The ``LINK_FLAGS`` property, managed as a string, can be used to add extra
+flags to the link step of a target. :prop_tgt:`LINK_FLAGS_<CONFIG>` will add
+to the configuration ``<CONFIG>``, for example, ``DEBUG``, ``RELEASE``,
+``MINSIZEREL``, ``RELWITHDEBINFO``, ...
+
+.. note::
+
+ This property has been superseded by :prop_tgt:`LINK_OPTIONS` property.
diff --git a/Help/prop_tgt/LINK_FLAGS_CONFIG.rst b/Help/prop_tgt/LINK_FLAGS_CONFIG.rst
index ba7adc84f..68c312932 100644
--- a/Help/prop_tgt/LINK_FLAGS_CONFIG.rst
+++ b/Help/prop_tgt/LINK_FLAGS_CONFIG.rst
@@ -1,6 +1,11 @@
LINK_FLAGS_<CONFIG>
-------------------
-Per-configuration linker flags for a target.
+Per-configuration linker flags for a ``SHARED`` library, ``MODULE`` or
+``EXECUTABLE`` target.
-This is the configuration-specific version of LINK_FLAGS.
+This is the configuration-specific version of :prop_tgt:`LINK_FLAGS`.
+
+.. note::
+
+ This property has been superseded by :prop_tgt:`LINK_OPTIONS` property.
diff --git a/Help/prop_tgt/LINK_INTERFACE_MULTIPLICITY.rst b/Help/prop_tgt/LINK_INTERFACE_MULTIPLICITY.rst
index 4e26388a9..b798af954 100644
--- a/Help/prop_tgt/LINK_INTERFACE_MULTIPLICITY.rst
+++ b/Help/prop_tgt/LINK_INTERFACE_MULTIPLICITY.rst
@@ -1,9 +1,9 @@
LINK_INTERFACE_MULTIPLICITY
---------------------------
-Repetition count for STATIC libraries with cyclic dependencies.
+Repetition count for ``STATIC`` libraries with cyclic dependencies.
-When linking to a STATIC library target with cyclic dependencies the
+When linking to a ``STATIC`` library target with cyclic dependencies the
linker may need to scan more than once through the archives in the
strongly connected component of the dependency graph. CMake by
default constructs the link line so that the linker will scan through
diff --git a/Help/prop_tgt/LINK_INTERFACE_MULTIPLICITY_CONFIG.rst b/Help/prop_tgt/LINK_INTERFACE_MULTIPLICITY_CONFIG.rst
index 5ea4a45cf..7c9461fde 100644
--- a/Help/prop_tgt/LINK_INTERFACE_MULTIPLICITY_CONFIG.rst
+++ b/Help/prop_tgt/LINK_INTERFACE_MULTIPLICITY_CONFIG.rst
@@ -1,8 +1,8 @@
LINK_INTERFACE_MULTIPLICITY_<CONFIG>
------------------------------------
-Per-configuration repetition count for cycles of STATIC libraries.
+Per-configuration repetition count for cycles of ``STATIC`` libraries.
This is the configuration-specific version of
-LINK_INTERFACE_MULTIPLICITY. If set, this property completely
+:prop_tgt:`LINK_INTERFACE_MULTIPLICITY`. If set, this property completely
overrides the generic property for the named configuration.
diff --git a/Help/prop_tgt/LINK_LIBRARIES.rst b/Help/prop_tgt/LINK_LIBRARIES.rst
index aa4b9f55f..d88e79881 100644
--- a/Help/prop_tgt/LINK_LIBRARIES.rst
+++ b/Help/prop_tgt/LINK_LIBRARIES.rst
@@ -15,3 +15,5 @@ Contents of ``LINK_LIBRARIES`` may use "generator expressions" with the
syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual
for available expressions. See the :manual:`cmake-buildsystem(7)` manual
for more on defining buildsystem properties.
+
+.. include:: LINK_LIBRARIES_INDIRECTION.txt
diff --git a/Help/prop_tgt/LINK_LIBRARIES_INDIRECTION.txt b/Help/prop_tgt/LINK_LIBRARIES_INDIRECTION.txt
new file mode 100644
index 000000000..1fdb6ad0e
--- /dev/null
+++ b/Help/prop_tgt/LINK_LIBRARIES_INDIRECTION.txt
@@ -0,0 +1,10 @@
+.. note::
+ A call to :command:`target_link_libraries(<target> ...)` may update this
+ property on ``<target>``. If ``<target>`` was not created in the same
+ directory as the call then :command:`target_link_libraries` will add a
+ suffix of the form ``::@<directory-id>`` to each entry, where the
+ ``::@`` is a separator and the ``<directory-id>`` is unspecified.
+ This tells the generators that the named libraries must be looked up in
+ the scope of the caller rather than in the scope in which the
+ ``<target>`` was created. Valid directory ids are stripped on export
+ by the :command:`install(EXPORT)` and :command:`export` commands.
diff --git a/Help/prop_tgt/LINK_OPTIONS.rst b/Help/prop_tgt/LINK_OPTIONS.rst
new file mode 100644
index 000000000..2a05ea75a
--- /dev/null
+++ b/Help/prop_tgt/LINK_OPTIONS.rst
@@ -0,0 +1,24 @@
+LINK_OPTIONS
+------------
+
+List of options to use for the link step of shared library, module
+and executable targets. Targets that are static libraries need to use
+the :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property.
+
+
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of options
+specified so far for its target. Use the :command:`target_link_options`
+command to append more options.
+
+This property is initialized by the :prop_dir:`LINK_OPTIONS` directory
+property when a target is created, and is used by the generators to set
+the options for the compiler.
+
+Contents of ``LINK_OPTIONS`` may use "generator expressions" with the
+syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual
+for available expressions. See the :manual:`cmake-buildsystem(7)` manual
+for more on defining buildsystem properties.
+
+.. note::
+
+ This property must be used in preference to :prop_tgt:`LINK_FLAGS` property.
diff --git a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst
index cf9c87147..fecbb1480 100644
--- a/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst
+++ b/Help/prop_tgt/LINK_SEARCH_END_STATIC.rst
@@ -3,16 +3,17 @@ LINK_SEARCH_END_STATIC
End a link line such that static system libraries are used.
-Some linkers support switches such as -Bstatic and -Bdynamic to
-determine whether to use static or shared libraries for -lXXX options.
+Some linkers support switches such as ``-Bstatic`` and ``-Bdynamic`` to
+determine whether to use static or shared libraries for ``-lXXX`` options.
CMake uses these options to set the link type for libraries whose full
paths are not known or (in some cases) are in implicit link
directories for the platform. By default CMake adds an option at the
end of the library list (if necessary) to set the linker search type
back to its starting type. This property switches the final linker
-search type to -Bstatic regardless of how it started.
+search type to ``-Bstatic`` regardless of how it started.
This property is initialized by the value of the variable
-CMAKE_LINK_SEARCH_END_STATIC if it is set when a target is created.
+:variable:`CMAKE_LINK_SEARCH_END_STATIC` if it is set
+when a target is created.
-See also LINK_SEARCH_START_STATIC.
+See also :prop_tgt:`LINK_SEARCH_START_STATIC`.
diff --git a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst
index 2e0f9bd33..83cf231c5 100644
--- a/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst
+++ b/Help/prop_tgt/LINK_SEARCH_START_STATIC.rst
@@ -3,17 +3,18 @@ LINK_SEARCH_START_STATIC
Assume the linker looks for static libraries by default.
-Some linkers support switches such as -Bstatic and -Bdynamic to
-determine whether to use static or shared libraries for -lXXX options.
+Some linkers support switches such as ``-Bstatic`` and ``-Bdynamic`` to
+determine whether to use static or shared libraries for ``-lXXX`` options.
CMake uses these options to set the link type for libraries whose full
paths are not known or (in some cases) are in implicit link
directories for the platform. By default the linker search type is
-assumed to be -Bdynamic at the beginning of the library list. This
-property switches the assumption to -Bstatic. It is intended for use
-when linking an executable statically (e.g. with the GNU -static
+assumed to be ``-Bdynamic`` at the beginning of the library list. This
+property switches the assumption to ``-Bstatic``. It is intended for use
+when linking an executable statically (e.g. with the GNU ``-static``
option).
This property is initialized by the value of the variable
-CMAKE_LINK_SEARCH_START_STATIC if it is set when a target is created.
+ :variable:`CMAKE_LINK_SEARCH_START_STATIC` if it is set
+ when a target is created.
-See also LINK_SEARCH_END_STATIC.
+See also :prop_tgt:`LINK_SEARCH_END_STATIC`.
diff --git a/Help/prop_tgt/LOCATION.rst b/Help/prop_tgt/LOCATION.rst
index 16d5696e5..d058064d6 100644
--- a/Help/prop_tgt/LOCATION.rst
+++ b/Help/prop_tgt/LOCATION.rst
@@ -4,24 +4,25 @@ LOCATION
Read-only location of a target on disk.
For an imported target, this read-only property returns the value of
-the LOCATION_<CONFIG> property for an unspecified configuration
-<CONFIG> provided by the target.
+the ``LOCATION_<CONFIG>`` property for an unspecified configuration
+``<CONFIG>`` provided by the target.
For a non-imported target, this property is provided for compatibility
with CMake 2.4 and below. It was meant to get the location of an
-executable target's output file for use in add_custom_command. The
+executable target's output file for use in :command:`add_custom_command`. The
path may contain a build-system-specific portion that is replaced at
build time with the configuration getting built (such as
-"$(ConfigurationName)" in VS). In CMake 2.6 and above
-add_custom_command automatically recognizes a target name in its
-COMMAND and DEPENDS options and computes the target location. In
-CMake 2.8.4 and above add_custom_command recognizes generator
-expressions to refer to target locations anywhere in the command.
+``$(ConfigurationName)`` in VS). In CMake 2.6 and above
+:command:`add_custom_command` automatically recognizes a target name in its
+``COMMAND`` and ``DEPENDS`` options and computes the target location. In
+CMake 2.8.4 and above :command:`add_custom_command` recognizes
+:manual:`generator expressions <cmake-generator-expressions(7)>`
+to refer to target locations anywhere in the command.
Therefore this property is not needed for creating custom commands.
Do not set properties that affect the location of a target after
reading this property. These include properties whose names match
-"(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_<CONFIG>)?",
+``(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_<CONFIG>)?``,
``(IMPLIB_)?(PREFIX|SUFFIX)``, or "LINKER_LANGUAGE". Failure to follow
this rule is not diagnosed and leaves the location of the target
undefined.
diff --git a/Help/prop_tgt/LOCATION_CONFIG.rst b/Help/prop_tgt/LOCATION_CONFIG.rst
index ac6bdb786..67de8ed21 100644
--- a/Help/prop_tgt/LOCATION_CONFIG.rst
+++ b/Help/prop_tgt/LOCATION_CONFIG.rst
@@ -4,17 +4,17 @@ LOCATION_<CONFIG>
Read-only property providing a target location on disk.
A read-only property that indicates where a target's main file is
-located on disk for the configuration <CONFIG>. The property is
+located on disk for the configuration ``<CONFIG>``. The property is
defined only for library and executable targets. An imported target
may provide a set of configurations different from that of the
importing project. By default CMake looks for an exact-match but
otherwise uses an arbitrary available configuration. Use the
-MAP_IMPORTED_CONFIG_<CONFIG> property to map imported configurations
-explicitly.
+:prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` property to map imported
+configurations explicitly.
Do not set properties that affect the location of a target after
reading this property. These include properties whose names match
-"(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_<CONFIG>)?",
-``(IMPLIB_)?(PREFIX|SUFFIX)``, or "LINKER_LANGUAGE". Failure to follow
-this rule is not diagnosed and leaves the location of the target
-undefined.
+``(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_<CONFIG>)?``,
+``(IMPLIB_)?(PREFIX|SUFFIX)``, or :prop_tgt:`LINKER_LANGUAGE`.
+Failure to follow this rule is not diagnosed and leaves
+the location of the target undefined.
diff --git a/Help/prop_tgt/MACOSX_BUNDLE.rst b/Help/prop_tgt/MACOSX_BUNDLE.rst
index 7cd80462a..92bce53ee 100644
--- a/Help/prop_tgt/MACOSX_BUNDLE.rst
+++ b/Help/prop_tgt/MACOSX_BUNDLE.rst
@@ -1,12 +1,12 @@
MACOSX_BUNDLE
-------------
-Build an executable as an Application Bundle on OS X or iOS.
+Build an executable as an Application Bundle on macOS or iOS.
-When this property is set to ``TRUE`` the executable when built on OS X
+When this property is set to ``TRUE`` the executable when built on macOS
or iOS will be created as an application bundle. This makes it
a GUI executable that can be launched from the Finder. See the
-:prop_tgt:`MACOSX_FRAMEWORK_INFO_PLIST` target property for information about
+:prop_tgt:`MACOSX_BUNDLE_INFO_PLIST` target property for information about
creation of the ``Info.plist`` file for the application bundle.
This property is initialized by the value of the variable
:variable:`CMAKE_MACOSX_BUNDLE` if it is set when a target is created.
diff --git a/Help/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.rst b/Help/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.rst
index 8515accc2..443a645e4 100644
--- a/Help/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.rst
+++ b/Help/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.rst
@@ -1,10 +1,10 @@
MACOSX_BUNDLE_INFO_PLIST
------------------------
-Specify a custom ``Info.plist`` template for a OS X and iOS Application Bundle.
+Specify a custom ``Info.plist`` template for a macOS and iOS Application Bundle.
An executable target with :prop_tgt:`MACOSX_BUNDLE` enabled will be built as an
-application bundle on OS X. By default its ``Info.plist`` file is created
+application bundle on macOS. By default its ``Info.plist`` file is created
by configuring a template called ``MacOSXBundleInfo.plist.in`` located in the
:variable:`CMAKE_MODULE_PATH`. This property specifies an alternative template
file name which may be a full path.
diff --git a/Help/prop_tgt/MACOSX_FRAMEWORK_INFO_PLIST.rst b/Help/prop_tgt/MACOSX_FRAMEWORK_INFO_PLIST.rst
index 58f31d495..82fdcc0fb 100644
--- a/Help/prop_tgt/MACOSX_FRAMEWORK_INFO_PLIST.rst
+++ b/Help/prop_tgt/MACOSX_FRAMEWORK_INFO_PLIST.rst
@@ -1,10 +1,10 @@
MACOSX_FRAMEWORK_INFO_PLIST
---------------------------
-Specify a custom ``Info.plist`` template for a OS X and iOS Framework.
+Specify a custom ``Info.plist`` template for a macOS and iOS Framework.
A library target with :prop_tgt:`FRAMEWORK` enabled will be built as a
-framework on OS X. By default its ``Info.plist`` file is created by
+framework on macOS. By default its ``Info.plist`` file is created by
configuring a template called ``MacOSXFrameworkInfo.plist.in`` located in the
:variable:`CMAKE_MODULE_PATH`. This property specifies an alternative template
file name which may be a full path.
diff --git a/Help/prop_tgt/MACOSX_RPATH.rst b/Help/prop_tgt/MACOSX_RPATH.rst
index 1f9a036bf..acd5a7aa4 100644
--- a/Help/prop_tgt/MACOSX_RPATH.rst
+++ b/Help/prop_tgt/MACOSX_RPATH.rst
@@ -1,7 +1,7 @@
MACOSX_RPATH
------------
-Whether this target on OS X or iOS is located at runtime using rpaths.
+Whether this target on macOS or iOS is located at runtime using rpaths.
When this property is set to ``TRUE``, the directory portion of
the ``install_name`` field of this shared library will be ``@rpath``
diff --git a/Help/prop_tgt/MSVC_RUNTIME_LIBRARY-VALUES.txt b/Help/prop_tgt/MSVC_RUNTIME_LIBRARY-VALUES.txt
new file mode 100644
index 000000000..6c6134197
--- /dev/null
+++ b/Help/prop_tgt/MSVC_RUNTIME_LIBRARY-VALUES.txt
@@ -0,0 +1,20 @@
+``MultiThreaded``
+ Compile with ``-MT`` or equivalent flag(s) to use a multi-threaded
+ statically-linked runtime library.
+``MultiThreadedDLL``
+ Compile with ``-MD`` or equivalent flag(s) to use a multi-threaded
+ dynamically-linked runtime library.
+``MultiThreadedDebug``
+ Compile with ``-MTd`` or equivalent flag(s) to use a multi-threaded
+ statically-linked runtime library.
+``MultiThreadedDebugDLL``
+ Compile with ``-MDd`` or equivalent flag(s) to use a multi-threaded
+ dynamically-linked runtime library.
+
+The value is ignored on non-MSVC compilers but an unsupported value will
+be rejected as an error when using a compiler targeting the MSVC ABI.
+
+The value may also be the empty string (``""``) in which case no runtime
+library selection flag will be added explicitly by CMake. Note that with
+:ref:`Visual Studio Generators` the native build system may choose to
+add its own default runtime library selection flag.
diff --git a/Help/prop_tgt/MSVC_RUNTIME_LIBRARY.rst b/Help/prop_tgt/MSVC_RUNTIME_LIBRARY.rst
new file mode 100644
index 000000000..73792def1
--- /dev/null
+++ b/Help/prop_tgt/MSVC_RUNTIME_LIBRARY.rst
@@ -0,0 +1,29 @@
+MSVC_RUNTIME_LIBRARY
+--------------------
+
+Select the MSVC runtime library for use by compilers targeting the MSVC ABI.
+
+The allowed values are:
+
+.. include:: MSVC_RUNTIME_LIBRARY-VALUES.txt
+
+Use :manual:`generator expressions <cmake-generator-expressions(7)>` to
+support per-configuration specification. For example, the code:
+
+.. code-block:: cmake
+
+ add_executable(foo foo.c)
+ set_property(TARGET foo PROPERTY
+ MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+
+selects for the target ``foo`` a multi-threaded statically-linked runtime
+library with or without debug information depending on the configuration.
+
+If this property is not set then CMake uses the default value
+``MultiThreaded$<$<CONFIG:Debug>:Debug>DLL`` to select a MSVC runtime library.
+
+.. note::
+
+ This property has effect only when policy :policy:`CMP0091` is set to ``NEW``
+ prior to the first :command:`project` or :command:`enable_language` command
+ that enables a language using a compiler targeting the MSVC ABI.
diff --git a/Help/prop_tgt/NO_SONAME.rst b/Help/prop_tgt/NO_SONAME.rst
index ee45ed849..d381a9c3b 100644
--- a/Help/prop_tgt/NO_SONAME.rst
+++ b/Help/prop_tgt/NO_SONAME.rst
@@ -1,10 +1,10 @@
NO_SONAME
---------
-Whether to set "soname" when linking a shared library.
+Whether to set ``soname`` when linking a shared library.
-Enable this boolean property if a generated shared library
-should not have "soname" set. Default is to set "soname" on all
+Enable this boolean property if a generated ``SHARED`` library
+should not have ``soname`` set. Default is to set ``soname`` on all
shared libraries as long as the platform supports it.
Generally, use this property only for leaf private libraries or
plugins. If you use it on normal shared libraries which other targets
diff --git a/Help/prop_tgt/NO_SYSTEM_FROM_IMPORTED.rst b/Help/prop_tgt/NO_SYSTEM_FROM_IMPORTED.rst
index 070dd3018..880343de4 100644
--- a/Help/prop_tgt/NO_SYSTEM_FROM_IMPORTED.rst
+++ b/Help/prop_tgt/NO_SYSTEM_FROM_IMPORTED.rst
@@ -1,11 +1,15 @@
NO_SYSTEM_FROM_IMPORTED
-----------------------
-Do not treat includes from IMPORTED target interfaces as SYSTEM.
+Do not treat include directories from the interfaces of consumed
+:ref:`imported targets` as ``SYSTEM``.
-The contents of the INTERFACE_INCLUDE_DIRECTORIES of IMPORTED targets
-are treated as SYSTEM includes by default. If this property is
-enabled, the contents of the INTERFACE_INCLUDE_DIRECTORIES of IMPORTED
-targets are not treated as system includes. This property is
-initialized by the value of the variable CMAKE_NO_SYSTEM_FROM_IMPORTED
-if it is set when a target is created.
+The contents of the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target property
+of imported targets are treated as ``SYSTEM`` includes by default. If this
+property is enabled on a target, compilation of sources in that target will
+not treat the contents of the ``INTERFACE_INCLUDE_DIRECTORIES`` of consumed
+imported targets as system includes.
+
+This property is initialized by the value of the
+:variable:`CMAKE_NO_SYSTEM_FROM_IMPORTED` variable if it is set when a target
+is created.
diff --git a/Help/prop_tgt/OBJCXX_EXTENSIONS.rst b/Help/prop_tgt/OBJCXX_EXTENSIONS.rst
new file mode 100644
index 000000000..9f9d804b6
--- /dev/null
+++ b/Help/prop_tgt/OBJCXX_EXTENSIONS.rst
@@ -0,0 +1,20 @@
+OBJCXX_EXTENSIONS
+-----------------
+
+Boolean specifying whether compiler specific extensions are requested.
+
+This property specifies whether compiler specific extensions should be
+used. For some compilers, this results in adding a flag such
+as ``-std=gnu++11`` instead of ``-std=c++11`` to the compile line. This
+property is ``ON`` by default. The basic ObjC++ standard level is
+controlled by the :prop_tgt:`OBJCXX_STANDARD` target property.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features and a list of supported compilers.
+
+If the property is not set, and the project has set the :prop_tgt:`CXX_EXTENSIONS`,
+the value of :prop_tgt:`CXX_EXTENSIONS` is set for :prop_tgt:`OBJCXX_EXTENSIONS`.
+
+This property is initialized by the value of
+the :variable:`CMAKE_OBJCXX_EXTENSIONS` variable if it is set when a target
+is created.
diff --git a/Help/prop_tgt/OBJCXX_STANDARD.rst b/Help/prop_tgt/OBJCXX_STANDARD.rst
new file mode 100644
index 000000000..3c925dcba
--- /dev/null
+++ b/Help/prop_tgt/OBJCXX_STANDARD.rst
@@ -0,0 +1,35 @@
+OBJCXX_STANDARD
+---------------
+
+The ObjC++ standard whose features are requested to build this target.
+
+This property specifies the ObjC++ standard whose features are requested
+to build this target. For some compilers, this results in adding a
+flag such as ``-std=gnu++11`` to the compile line.
+
+Supported values are ``98``, ``11``, ``14``, ``17``, and ``20``.
+
+If the value requested does not result in a compile flag being added for
+the compiler in use, a previous standard flag will be added instead. This
+means that using:
+
+.. code-block:: cmake
+
+ set_property(TARGET tgt PROPERTY OBJCXX_STANDARD 11)
+
+with a compiler which does not support ``-std=gnu++11`` or an equivalent
+flag will not result in an error or warning, but will instead add the
+``-std=gnu++98`` flag if supported. This "decay" behavior may be controlled
+with the :prop_tgt:`OBJCXX_STANDARD_REQUIRED` target property.
+Additionally, the :prop_tgt:`OBJCXX_EXTENSIONS` target property may be used to
+control whether compiler-specific extensions are enabled on a per-target basis.
+
+If the property is not set, and the project has set the :prop_tgt:`CXX_STANDARD`,
+the value of :prop_tgt:`CXX_STANDARD` is set for :prop_tgt:`OBJCXX_STANDARD`.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features and a list of supported compilers.
+
+This property is initialized by the value of
+the :variable:`CMAKE_OBJCXX_STANDARD` variable if it is set when a target
+is created.
diff --git a/Help/prop_tgt/OBJCXX_STANDARD_REQUIRED.rst b/Help/prop_tgt/OBJCXX_STANDARD_REQUIRED.rst
new file mode 100644
index 000000000..c330abfdd
--- /dev/null
+++ b/Help/prop_tgt/OBJCXX_STANDARD_REQUIRED.rst
@@ -0,0 +1,20 @@
+OBJCXX_STANDARD_REQUIRED
+------------------------
+
+Boolean describing whether the value of :prop_tgt:`OBJCXX_STANDARD` is a requirement.
+
+If this property is set to ``ON``, then the value of the
+:prop_tgt:`OBJCXX_STANDARD` target property is treated as a requirement. If this
+property is ``OFF`` or unset, the :prop_tgt:`OBJCXX_STANDARD` target property is
+treated as optional and may "decay" to a previous standard if the requested is
+not available.
+
+If the property is not set, and the project has set the :prop_tgt:`CXX_STANDARD_REQUIRED`,
+the value of :prop_tgt:`CXX_STANDARD_REQUIRED` is set for :prop_tgt:`OBJCXX_STANDARD_REQUIRED`.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features and a list of supported compilers.
+
+This property is initialized by the value of
+the :variable:`CMAKE_OBJCXX_STANDARD_REQUIRED` variable if it is set when a
+target is created.
diff --git a/Help/prop_tgt/OBJC_EXTENSIONS.rst b/Help/prop_tgt/OBJC_EXTENSIONS.rst
new file mode 100644
index 000000000..2de9e48fe
--- /dev/null
+++ b/Help/prop_tgt/OBJC_EXTENSIONS.rst
@@ -0,0 +1,20 @@
+OBJC_EXTENSIONS
+---------------
+
+Boolean specifying whether compiler specific extensions are requested.
+
+This property specifies whether compiler specific extensions should be
+used. For some compilers, this results in adding a flag such
+as ``-std=gnu11`` instead of ``-std=c11`` to the compile line. This
+property is ``ON`` by default. The basic OBJC standard level is
+controlled by the :prop_tgt:`OBJC_STANDARD` target property.
+
+If the property is not set, and the project has set the :prop_tgt:`C_EXTENSIONS`,
+the value of :prop_tgt:`C_EXTENSIONS` is set for :prop_tgt:`OBJC_EXTENSIONS`.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features and a list of supported compilers.
+
+This property is initialized by the value of
+the :variable:`CMAKE_OBJC_EXTENSIONS` variable if it is set when a target
+is created.
diff --git a/Help/prop_tgt/OBJC_STANDARD.rst b/Help/prop_tgt/OBJC_STANDARD.rst
new file mode 100644
index 000000000..d1e1b2425
--- /dev/null
+++ b/Help/prop_tgt/OBJC_STANDARD.rst
@@ -0,0 +1,35 @@
+OBJC_STANDARD
+-------------
+
+The OBJC standard whose features are requested to build this target.
+
+This property specifies the OBJC standard whose features are requested
+to build this target. For some compilers, this results in adding a
+flag such as ``-std=gnu11`` to the compile line.
+
+Supported values are ``90``, ``99`` and ``11``.
+
+If the value requested does not result in a compile flag being added for
+the compiler in use, a previous standard flag will be added instead. This
+means that using:
+
+.. code-block:: cmake
+
+ set_property(TARGET tgt PROPERTY OBJC_STANDARD 11)
+
+with a compiler which does not support ``-std=gnu11`` or an equivalent
+flag will not result in an error or warning, but will instead add the
+``-std=gnu99`` or ``-std=gnu90`` flag if supported. This "decay" behavior may
+be controlled with the :prop_tgt:`OBJC_STANDARD_REQUIRED` target property.
+Additionally, the :prop_tgt:`OBJC_EXTENSIONS` target property may be used to
+control whether compiler-specific extensions are enabled on a per-target basis.
+
+If the property is not set, and the project has set the :prop_tgt:`C_STANDARD`,
+the value of :prop_tgt:`C_STANDARD` is set for :prop_tgt:`OBJC_STANDARD`.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features and a list of supported compilers.
+
+This property is initialized by the value of
+the :variable:`CMAKE_OBJC_STANDARD` variable if it is set when a target
+is created.
diff --git a/Help/prop_tgt/OBJC_STANDARD_REQUIRED.rst b/Help/prop_tgt/OBJC_STANDARD_REQUIRED.rst
new file mode 100644
index 000000000..8cf377cd1
--- /dev/null
+++ b/Help/prop_tgt/OBJC_STANDARD_REQUIRED.rst
@@ -0,0 +1,20 @@
+OBJC_STANDARD_REQUIRED
+----------------------
+
+Boolean describing whether the value of :prop_tgt:`OBJC_STANDARD` is a requirement.
+
+If this property is set to ``ON``, then the value of the
+:prop_tgt:`OBJC_STANDARD` target property is treated as a requirement. If this
+property is ``OFF`` or unset, the :prop_tgt:`OBJC_STANDARD` target property is
+treated as optional and may "decay" to a previous standard if the requested is
+not available.
+
+If the property is not set, and the project has set the :prop_tgt:`C_STANDARD_REQUIRED`,
+the value of :prop_tgt:`C_STANDARD_REQUIRED` is set for :prop_tgt:`OBJC_STANDARD_REQUIRED`.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features and a list of supported compilers.
+
+This property is initialized by the value of
+the :variable:`CMAKE_OBJC_STANDARD_REQUIRED` variable if it is set when a
+target is created.
diff --git a/Help/prop_tgt/OSX_ARCHITECTURES.rst b/Help/prop_tgt/OSX_ARCHITECTURES.rst
index cefe03f5b..996a4be72 100644
--- a/Help/prop_tgt/OSX_ARCHITECTURES.rst
+++ b/Help/prop_tgt/OSX_ARCHITECTURES.rst
@@ -1,10 +1,10 @@
OSX_ARCHITECTURES
-----------------
-Target specific architectures for OS X.
+Target specific architectures for macOS.
The ``OSX_ARCHITECTURES`` property sets the target binary architecture for
-targets on OS X (``-arch``). This property is initialized by the value of the
+targets on macOS (``-arch``). This property is initialized by the value of the
variable :variable:`CMAKE_OSX_ARCHITECTURES` if it is set when a target is
created. Use :prop_tgt:`OSX_ARCHITECTURES_<CONFIG>` to set the binary
architectures on a per-configuration basis, where ``<CONFIG>`` is an
diff --git a/Help/prop_tgt/OSX_ARCHITECTURES_CONFIG.rst b/Help/prop_tgt/OSX_ARCHITECTURES_CONFIG.rst
index fb78177fb..06da4fb09 100644
--- a/Help/prop_tgt/OSX_ARCHITECTURES_CONFIG.rst
+++ b/Help/prop_tgt/OSX_ARCHITECTURES_CONFIG.rst
@@ -1,7 +1,7 @@
OSX_ARCHITECTURES_<CONFIG>
--------------------------
-Per-configuration OS X and iOS binary architectures for a target.
+Per-configuration macOS and iOS binary architectures for a target.
This property is the configuration-specific version of
:prop_tgt:`OSX_ARCHITECTURES`.
diff --git a/Help/prop_tgt/OUTPUT_NAME.rst b/Help/prop_tgt/OUTPUT_NAME.rst
index f1bdb7c88..4b33b38e0 100644
--- a/Help/prop_tgt/OUTPUT_NAME.rst
+++ b/Help/prop_tgt/OUTPUT_NAME.rst
@@ -5,7 +5,8 @@ Output name for target files.
This sets the base name for output files created for an executable or
library target. If not set, the logical target name is used by
-default.
+default during generation. The value is not set by default during
+configuration.
Contents of ``OUTPUT_NAME`` and the variants listed below may use
:manual:`generator expressions <cmake-generator-expressions(7)>`.
diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst
index 730cf5776..2f667f364 100644
--- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst
+++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst
@@ -5,8 +5,14 @@ Output directory for the MS debug symbols ``.pdb`` file
generated by the linker for an executable or shared library target.
This property specifies the directory into which the MS debug symbols
-will be placed by the linker. This property is initialized by the
-value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY` variable if it is
+will be placed by the linker. The property value may use
+:manual:`generator expressions <cmake-generator-expressions(7)>`.
+Multi-configuration generators append a per-configuration
+subdirectory to the specified directory unless a generator expression
+is used.
+
+This property is initialized by the value of the
+:variable:`CMAKE_PDB_OUTPUT_DIRECTORY` variable if it is
set when a target is created.
.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY`
diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst
index 6037fa0c7..6c550831f 100644
--- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst
+++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst
@@ -5,11 +5,15 @@ Per-configuration output directory for the MS debug symbol ``.pdb`` file
generated by the linker for an executable or shared library target.
This is a per-configuration version of :prop_tgt:`PDB_OUTPUT_DIRECTORY`,
-but multi-configuration generators (VS, Xcode) do NOT append a
+but multi-configuration generators (:ref:`Visual Studio Generators`,
+:generator:`Xcode`) do NOT append a
per-configuration subdirectory to the specified directory. This
property is initialized by the value of the
:variable:`CMAKE_PDB_OUTPUT_DIRECTORY_<CONFIG>` variable if it is
set when a target is created.
+Contents of ``PDB_OUTPUT_DIRECTORY_<CONFIG>`` may use
+:manual:`generator expressions <cmake-generator-expressions(7)>`.
+
.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>`
.. include:: PDB_NOTE.txt
diff --git a/Help/prop_tgt/POSITION_INDEPENDENT_CODE.rst b/Help/prop_tgt/POSITION_INDEPENDENT_CODE.rst
index 54af8c6de..0aaf66bd0 100644
--- a/Help/prop_tgt/POSITION_INDEPENDENT_CODE.rst
+++ b/Help/prop_tgt/POSITION_INDEPENDENT_CODE.rst
@@ -9,3 +9,8 @@ property is ``True`` by default for ``SHARED`` and ``MODULE`` library
targets and ``False`` otherwise. This property is initialized by the value
of the :variable:`CMAKE_POSITION_INDEPENDENT_CODE` variable if it is set
when a target is created.
+
+.. note::
+
+ For executable targets, the link step is controlled by the :policy:`CMP0083`
+ policy and the :module:`CheckPIESupported` module.
diff --git a/Help/prop_tgt/POST_INSTALL_SCRIPT.rst b/Help/prop_tgt/POST_INSTALL_SCRIPT.rst
index f1adb40b7..23935bcdf 100644
--- a/Help/prop_tgt/POST_INSTALL_SCRIPT.rst
+++ b/Help/prop_tgt/POST_INSTALL_SCRIPT.rst
@@ -3,7 +3,7 @@ POST_INSTALL_SCRIPT
Deprecated install support.
-The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the old
-way to specify CMake scripts to run before and after installing a
-target. They are used only when the old INSTALL_TARGETS command is
-used to install the target. Use the INSTALL command instead.
+The :prop_tgt:`PRE_INSTALL_SCRIPT` and ``POST_INSTALL_SCRIPT`` properties are
+the old way to specify CMake scripts to run before and after installing a
+target. They are used only when the old ``INSTALL_TARGETS`` command is
+used to install the target. Use the :command:`install` command instead.
diff --git a/Help/prop_tgt/PRECOMPILE_HEADERS.rst b/Help/prop_tgt/PRECOMPILE_HEADERS.rst
new file mode 100644
index 000000000..9e70b654d
--- /dev/null
+++ b/Help/prop_tgt/PRECOMPILE_HEADERS.rst
@@ -0,0 +1,12 @@
+PRECOMPILE_HEADERS
+------------------
+
+List of header files to precompile.
+
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>`
+of header files to precompile specified so far for its target.
+Use the :command:`target_precompile_headers` command to append more header
+files.
+
+This property supports
+:manual:`generator expressions <cmake-generator-expressions(7)>`.
diff --git a/Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst b/Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst
new file mode 100644
index 000000000..9c3e7eaf3
--- /dev/null
+++ b/Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst
@@ -0,0 +1,7 @@
+PRECOMPILE_HEADERS_REUSE_FROM
+-----------------------------
+
+Target from which to reuse the precompiled headers build artifact.
+
+See the second signature of :command:`target_precompile_headers` command
+for more detailed information.
diff --git a/Help/prop_tgt/PREFIX.rst b/Help/prop_tgt/PREFIX.rst
index a16510461..a40129268 100644
--- a/Help/prop_tgt/PREFIX.rst
+++ b/Help/prop_tgt/PREFIX.rst
@@ -4,4 +4,4 @@ PREFIX
What comes before the library name.
A target property that can be set to override the prefix (such as
-"lib") on a library name.
+``lib``) on a library name.
diff --git a/Help/prop_tgt/PRE_INSTALL_SCRIPT.rst b/Help/prop_tgt/PRE_INSTALL_SCRIPT.rst
index 113d7c56a..43432f4d8 100644
--- a/Help/prop_tgt/PRE_INSTALL_SCRIPT.rst
+++ b/Help/prop_tgt/PRE_INSTALL_SCRIPT.rst
@@ -3,7 +3,7 @@ PRE_INSTALL_SCRIPT
Deprecated install support.
-The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the old
-way to specify CMake scripts to run before and after installing a
-target. They are used only when the old INSTALL_TARGETS command is
-used to install the target. Use the INSTALL command instead.
+The ``PRE_INSTALL_SCRIPT`` and :prop_tgt:`POST_INSTALL_SCRIPT` properties are
+the old way to specify CMake scripts to run before and after installing a
+target. They are used only when the old ``INSTALL_TARGETS`` command is
+used to install the target. Use the :command:`install` command instead.
diff --git a/Help/prop_tgt/PRIVATE_HEADER.rst b/Help/prop_tgt/PRIVATE_HEADER.rst
index c4412ed25..23e1f8e6f 100644
--- a/Help/prop_tgt/PRIVATE_HEADER.rst
+++ b/Help/prop_tgt/PRIVATE_HEADER.rst
@@ -4,8 +4,8 @@ PRIVATE_HEADER
Specify private header files in a :prop_tgt:`FRAMEWORK` shared library target.
Shared library targets marked with the :prop_tgt:`FRAMEWORK` property generate
-frameworks on OS X, iOS and normal shared libraries on other platforms.
+frameworks on macOS, iOS and normal shared libraries on other platforms.
This property may be set to a list of header files to be placed in the
PrivateHeaders directory inside the framework folder. On non-Apple
platforms these headers may be installed using the ``PRIVATE_HEADER``
-option to the ``install(TARGETS)`` command.
+option to the :command:`install(TARGETS)` command.
diff --git a/Help/prop_tgt/PUBLIC_HEADER.rst b/Help/prop_tgt/PUBLIC_HEADER.rst
index d4a636caf..915e39cd2 100644
--- a/Help/prop_tgt/PUBLIC_HEADER.rst
+++ b/Help/prop_tgt/PUBLIC_HEADER.rst
@@ -4,8 +4,8 @@ PUBLIC_HEADER
Specify public header files in a :prop_tgt:`FRAMEWORK` shared library target.
Shared library targets marked with the :prop_tgt:`FRAMEWORK` property generate
-frameworks on OS X, iOS and normal shared libraries on other platforms.
+frameworks on macOS, iOS and normal shared libraries on other platforms.
This property may be set to a list of header files to be placed in the
``Headers`` directory inside the framework folder. On non-Apple platforms
these headers may be installed using the ``PUBLIC_HEADER`` option to the
-``install(TARGETS)`` command.
+:command:`install(TARGETS)` command.
diff --git a/Help/prop_tgt/RESOURCE.rst b/Help/prop_tgt/RESOURCE.rst
index d837f7b33..e5a1cb677 100644
--- a/Help/prop_tgt/RESOURCE.rst
+++ b/Help/prop_tgt/RESOURCE.rst
@@ -4,12 +4,12 @@ RESOURCE
Specify resource files in a :prop_tgt:`FRAMEWORK` or :prop_tgt:`BUNDLE`.
Target marked with the :prop_tgt:`FRAMEWORK` or :prop_tgt:`BUNDLE` property
-generate framework or application bundle (both OS X and iOS is supported)
+generate framework or application bundle (both macOS and iOS is supported)
or normal shared libraries on other platforms.
This property may be set to a list of files to be placed in the corresponding
-directory (eg. ``Resources`` directory for OS X) inside the bundle.
+directory (eg. ``Resources`` directory for macOS) inside the bundle.
On non-Apple platforms these files may be installed using the ``RESOURCE``
-option to the ``install(TARGETS)`` command.
+option to the :command:`install(TARGETS)` command.
Following example of Application Bundle:
@@ -18,21 +18,18 @@ Following example of Application Bundle:
add_executable(ExecutableTarget
addDemo.c
resourcefile.txt
- appresourcedir/appres.txt
- )
+ appresourcedir/appres.txt)
target_link_libraries(ExecutableTarget heymath mul)
set(RESOURCE_FILES
resourcefile.txt
- appresourcedir/appres.txt
- )
+ appresourcedir/appres.txt)
set_target_properties(ExecutableTarget PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_FRAMEWORK_IDENTIFIER org.cmake.ExecutableTarget
- RESOURCE "${RESOURCE_FILES}"
- )
+ RESOURCE "${RESOURCE_FILES}")
will produce flat structure for iOS systems::
@@ -42,7 +39,7 @@ will produce flat structure for iOS systems::
Info.plist
resourcefile.txt
-For OS X systems it will produce following directory structure::
+For macOS systems it will produce following directory structure::
ExecutableTarget.app/
Contents
@@ -53,7 +50,7 @@ For OS X systems it will produce following directory structure::
appres.txt
resourcefile.txt
-For Linux, such cmake script produce following files::
+For Linux, such CMake script produce following files::
ExecutableTarget
Resources
diff --git a/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst
index 94fb2776a..67277548e 100644
--- a/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst
+++ b/Help/prop_tgt/RUNTIME_OUTPUT_DIRECTORY_CONFIG.rst
@@ -6,7 +6,8 @@ Per-configuration output directory for
This is a per-configuration version of the
:prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` target property, but
-multi-configuration generators (VS, Xcode) do NOT append a
+multi-configuration generators (:ref:`Visual Studio Generators`,
+:generator:`Xcode`) do NOT append a
per-configuration subdirectory to the specified directory. This
property is initialized by the value of the
:variable:`CMAKE_RUNTIME_OUTPUT_DIRECTORY_<CONFIG>` variable if
diff --git a/Help/prop_tgt/SKIP_BUILD_RPATH.rst b/Help/prop_tgt/SKIP_BUILD_RPATH.rst
index a91fa9ca3..7086b1bc4 100644
--- a/Help/prop_tgt/SKIP_BUILD_RPATH.rst
+++ b/Help/prop_tgt/SKIP_BUILD_RPATH.rst
@@ -3,7 +3,7 @@ SKIP_BUILD_RPATH
Should rpaths be used for the build tree.
-SKIP_BUILD_RPATH is a boolean specifying whether to skip automatic
+``SKIP_BUILD_RPATH`` is a boolean specifying whether to skip automatic
generation of an rpath allowing the target to run from the build tree.
This property is initialized by the value of the variable
-CMAKE_SKIP_BUILD_RPATH if it is set when a target is created.
+:variable:`CMAKE_SKIP_BUILD_RPATH` if it is set when a target is created.
diff --git a/Help/prop_tgt/SOVERSION.rst b/Help/prop_tgt/SOVERSION.rst
index 82b6b976a..b07c17cfe 100644
--- a/Help/prop_tgt/SOVERSION.rst
+++ b/Help/prop_tgt/SOVERSION.rst
@@ -20,7 +20,7 @@ These numbers are used as the image version of the binary.
Mach-O Versions
^^^^^^^^^^^^^^^
-For shared libraries and executables on Mach-O systems (e.g. OS X, iOS),
+For shared libraries and executables on Mach-O systems (e.g. macOS, iOS),
the ``SOVERSION`` property corresponds to *compatibility version* and
:prop_tgt:`VERSION` to *current version*. See the :prop_tgt:`FRAMEWORK` target
property for an example. Versions of Mach-O binaries may be checked with the
diff --git a/Help/prop_tgt/STATIC_LIBRARY_FLAGS.rst b/Help/prop_tgt/STATIC_LIBRARY_FLAGS.rst
index d3b2cd478..66e0e8b96 100644
--- a/Help/prop_tgt/STATIC_LIBRARY_FLAGS.rst
+++ b/Help/prop_tgt/STATIC_LIBRARY_FLAGS.rst
@@ -1,6 +1,17 @@
STATIC_LIBRARY_FLAGS
--------------------
-Extra flags to use when linking static libraries.
+Archiver (or MSVC librarian) flags for a static library target.
+Targets that are shared libraries, modules, or executables need to use
+the :prop_tgt:`LINK_OPTIONS` or :prop_tgt:`LINK_FLAGS` target properties.
-Extra flags to use when linking a static library.
+The ``STATIC_LIBRARY_FLAGS`` property, managed as a string, can be used to add
+extra flags to the link step of a static library target.
+:prop_tgt:`STATIC_LIBRARY_FLAGS_<CONFIG>` will add to the configuration
+``<CONFIG>``, for example, ``DEBUG``, ``RELEASE``, ``MINSIZEREL``,
+``RELWITHDEBINFO``, ...
+
+.. note::
+
+ This property has been superseded by :prop_tgt:`STATIC_LIBRARY_OPTIONS`
+ property.
diff --git a/Help/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG.rst b/Help/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG.rst
index cca353ddc..5b97941da 100644
--- a/Help/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG.rst
+++ b/Help/prop_tgt/STATIC_LIBRARY_FLAGS_CONFIG.rst
@@ -1,6 +1,12 @@
STATIC_LIBRARY_FLAGS_<CONFIG>
-----------------------------
-Per-configuration flags for creating a static library.
+Per-configuration archiver (or MSVC librarian) flags for a static library
+target.
-This is the configuration-specific version of STATIC_LIBRARY_FLAGS.
+This is the configuration-specific version of :prop_tgt:`STATIC_LIBRARY_FLAGS`.
+
+.. note::
+
+ This property has been superseded by :prop_tgt:`STATIC_LIBRARY_OPTIONS`
+ property.
diff --git a/Help/prop_tgt/STATIC_LIBRARY_OPTIONS.rst b/Help/prop_tgt/STATIC_LIBRARY_OPTIONS.rst
new file mode 100644
index 000000000..d05fda4aa
--- /dev/null
+++ b/Help/prop_tgt/STATIC_LIBRARY_OPTIONS.rst
@@ -0,0 +1,20 @@
+STATIC_LIBRARY_OPTIONS
+----------------------
+
+Archiver (or MSVC librarian) flags for a static library target.
+Targets that are shared libraries, modules, or executables need to use
+the :prop_tgt:`LINK_OPTIONS` target property.
+
+This property holds a :ref:`semicolon-separated list <CMake Language Lists>` of options
+specified so far for its target. Use :command:`set_target_properties` or
+:command:`set_property` commands to set its content.
+
+Contents of ``STATIC_LIBRARY_OPTIONS`` may use "generator expressions" with the
+syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual
+for available expressions. See the :manual:`cmake-buildsystem(7)` manual
+for more on defining buildsystem properties.
+
+.. note::
+
+ This property must be used in preference to :prop_tgt:`STATIC_LIBRARY_FLAGS`
+ property.
diff --git a/Help/prop_tgt/SUFFIX.rst b/Help/prop_tgt/SUFFIX.rst
index 70844be5c..32ec42910 100644
--- a/Help/prop_tgt/SUFFIX.rst
+++ b/Help/prop_tgt/SUFFIX.rst
@@ -4,4 +4,4 @@ SUFFIX
What comes after the target name.
A target property that can be set to override the suffix (such as
-".so" or ".exe") on the name of a library, module or executable.
+``.so`` or ``.exe``) on the name of a library, module or executable.
diff --git a/Help/prop_tgt/Swift_DEPENDENCIES_FILE.rst b/Help/prop_tgt/Swift_DEPENDENCIES_FILE.rst
new file mode 100644
index 000000000..46c9a1d9b
--- /dev/null
+++ b/Help/prop_tgt/Swift_DEPENDENCIES_FILE.rst
@@ -0,0 +1,5 @@
+Swift_DEPENDENCIES_FILE
+-----------------------
+
+This property sets the path for the Swift dependency file (swiftdep) for the
+target. If one is not specified, it will default to ``<TARGET>.swiftdeps``.
diff --git a/Help/prop_tgt/Swift_LANGUAGE_VERSION.rst b/Help/prop_tgt/Swift_LANGUAGE_VERSION.rst
new file mode 100644
index 000000000..7579447a4
--- /dev/null
+++ b/Help/prop_tgt/Swift_LANGUAGE_VERSION.rst
@@ -0,0 +1,6 @@
+Swift_LANGUAGE_VERSION
+----------------------
+
+This property sets the language version for the Swift sources in the target. If
+one is not specified, it will default to ``<CMAKE_Swift_LANGUAGE_VERSION>`` if
+specified, otherwise it is the latest version supported by the compiler.
diff --git a/Help/prop_tgt/Swift_MODULE_DIRECTORY.rst b/Help/prop_tgt/Swift_MODULE_DIRECTORY.rst
new file mode 100644
index 000000000..d40425166
--- /dev/null
+++ b/Help/prop_tgt/Swift_MODULE_DIRECTORY.rst
@@ -0,0 +1,10 @@
+Swift_MODULE_DIRECTORY
+----------------------
+
+Specify output directory for Swift modules provided by the target.
+
+If the target contains Swift source files, this specifies the directory in which
+the modules will be placed. When this property is not set, the modules will be
+placed in the build directory corresponding to the target's source directory.
+If the variable :variable:`CMAKE_Swift_MODULE_DIRECTORY` is set when a target is
+created its value is used to initialise this property.
diff --git a/Help/prop_tgt/Swift_MODULE_NAME.rst b/Help/prop_tgt/Swift_MODULE_NAME.rst
new file mode 100644
index 000000000..28660203e
--- /dev/null
+++ b/Help/prop_tgt/Swift_MODULE_NAME.rst
@@ -0,0 +1,5 @@
+Swift_MODULE_NAME
+-----------------
+
+This property specifies the name of the Swift module. It is defaulted to the
+name of the target.
diff --git a/Help/prop_tgt/TYPE.rst b/Help/prop_tgt/TYPE.rst
index 5ac63cc37..3136d119d 100644
--- a/Help/prop_tgt/TYPE.rst
+++ b/Help/prop_tgt/TYPE.rst
@@ -4,6 +4,6 @@ TYPE
The type of the target.
This read-only property can be used to test the type of the given
-target. It will be one of STATIC_LIBRARY, MODULE_LIBRARY,
-SHARED_LIBRARY, INTERFACE_LIBRARY, EXECUTABLE or one of the internal
-target types.
+target. It will be one of ``STATIC_LIBRARY``, ``MODULE_LIBRARY``,
+``SHARED_LIBRARY``, ``OBJECT_LIBRARY``, ``INTERFACE_LIBRARY``, ``EXECUTABLE``
+or one of the internal target types.
diff --git a/Help/prop_tgt/UNITY_BUILD.rst b/Help/prop_tgt/UNITY_BUILD.rst
new file mode 100644
index 000000000..479802e59
--- /dev/null
+++ b/Help/prop_tgt/UNITY_BUILD.rst
@@ -0,0 +1,60 @@
+UNITY_BUILD
+-----------
+
+When this property is set to true, the target source files will be combined
+into batches for faster compilation. This is done by creating a (set of)
+unity sources which ``#include`` the original sources, then compiling these
+unity sources instead of the originals. This is known as a *Unity* or *Jumbo*
+build. The :prop_tgt:`UNITY_BUILD_BATCH_SIZE` property controls the upper
+limit on how many sources can be combined per unity source file.
+
+Unity builds are not currently supported for all languages. CMake version
+|release| supports combining ``C`` and ``CXX`` source files. For targets that
+mix source files from more than one language, CMake will separate the languages
+such that each generated unity source file only contains sources for a single
+language.
+
+This property is initialized by the value of the :variable:`CMAKE_UNITY_BUILD`
+variable when a target is created.
+
+.. note::
+
+ Projects should not directly set the ``UNITY_BUILD`` property or its
+ associated :variable:`CMAKE_UNITY_BUILD` variable to true. Depending
+ on the capabilities of the build machine and compiler used, it might or
+ might not be appropriate to enable unity builds. Therefore, this feature
+ should be under developer control, which would normally be through the
+ developer choosing whether or not to set the :variable:`CMAKE_UNITY_BUILD`
+ variable on the :manual:`cmake(1)` command line or some other equivalent
+ method. However, it IS recommended to set the ``UNITY_BUILD`` target
+ property to false if it is known that enabling unity builds for the
+ target can lead to problems.
+
+ODR (One definition rule) errors
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+When multiple source files are included into one source file, as is done
+for unity builds, it can potentially lead to ODR errors. CMake provides
+a number of measures to help address such problems:
+
+* Any source file that has a non-empty :prop_sf:`COMPILE_OPTIONS`,
+ :prop_sf:`COMPILE_DEFINITIONS`, :prop_sf:`COMPILE_FLAGS`, or
+ :prop_sf:`INCLUDE_DIRECTORIES` source property will not be combined
+ into a unity source.
+
+* Projects can prevent an individual source file from being combined into
+ a unity source by setting its :prop_sf:`SKIP_UNITY_BUILD_INCLUSION`
+ source property to true. This can be a more effective way to prevent
+ problems with specific files than disabling unity builds for an entire
+ target.
+
+* The :prop_tgt:`UNITY_BUILD_CODE_BEFORE_INCLUDE` and
+ :prop_tgt:`UNITY_BUILD_CODE_AFTER_INCLUDE` target properties can be used
+ to inject code into the unity source files before and after every
+ ``#include`` statement.
+
+* The order of source files added to the target via commands like
+ :command:`add_library`, :command:`add_executable` or
+ :command:`target_sources` will be preserved in the generated unity source
+ files. This can be used to manually enforce a specific grouping based on
+ the :prop_tgt:`UNITY_BUILD_BATCH_SIZE` target property.
diff --git a/Help/prop_tgt/UNITY_BUILD_BATCH_SIZE.rst b/Help/prop_tgt/UNITY_BUILD_BATCH_SIZE.rst
new file mode 100644
index 000000000..44ffe2784
--- /dev/null
+++ b/Help/prop_tgt/UNITY_BUILD_BATCH_SIZE.rst
@@ -0,0 +1,23 @@
+UNITY_BUILD_BATCH_SIZE
+----------------------
+
+Specifies the maximum number of source files that can be combined into any one
+unity source file when unity builds are enabled by the :prop_tgt:`UNITY_BUILD`
+target property. The original source files will be distributed across as many
+unity source files as necessary to honor this limit.
+
+The initial value for this property is taken from the
+:variable:`CMAKE_UNITY_BUILD_BATCH_SIZE` variable when the target is created.
+If that variable has not been set, the initial value will be 8.
+
+The batch size needs to be selected carefully. If set too high, the size of
+the combined source files could result in the compiler using excessive memory
+or hitting other similar limits. In extreme cases, this can even result in
+build failure. On the other hand, if the batch size is too low, there will be
+little gain in build performance.
+
+Although strongly discouraged, the batch size may be set to a value of 0 to
+combine all the sources for the target into a single unity file, regardless of
+how many sources are involved. This runs the risk of creating an excessively
+large unity source file and negatively impacting the build performance, so
+a value of 0 is not generally recommended.
diff --git a/Help/prop_tgt/UNITY_BUILD_CODE_AFTER_INCLUDE.rst b/Help/prop_tgt/UNITY_BUILD_CODE_AFTER_INCLUDE.rst
new file mode 100644
index 000000000..7231b6116
--- /dev/null
+++ b/Help/prop_tgt/UNITY_BUILD_CODE_AFTER_INCLUDE.rst
@@ -0,0 +1,19 @@
+UNITY_BUILD_CODE_AFTER_INCLUDE
+------------------------------
+
+Code snippet which is included verbatim by the :prop_tgt:`UNITY_BUILD`
+feature just after every ``#include`` statement in the generated unity
+source files. For example:
+
+.. code-block:: cmake
+
+ set(after [[
+ #if defined(NOMINMAX)
+ #undef NOMINMAX
+ #endif
+ ]])
+ set_target_properties(myTarget PROPERTIES
+ UNITY_BUILD_CODE_AFTER_INCLUDE "${after}"
+ )
+
+See also :prop_tgt:`UNITY_BUILD_CODE_BEFORE_INCLUDE`.
diff --git a/Help/prop_tgt/UNITY_BUILD_CODE_BEFORE_INCLUDE.rst b/Help/prop_tgt/UNITY_BUILD_CODE_BEFORE_INCLUDE.rst
new file mode 100644
index 000000000..7ed6fa10a
--- /dev/null
+++ b/Help/prop_tgt/UNITY_BUILD_CODE_BEFORE_INCLUDE.rst
@@ -0,0 +1,19 @@
+UNITY_BUILD_CODE_BEFORE_INCLUDE
+-------------------------------
+
+Code snippet which is included verbatim by the :prop_tgt:`UNITY_BUILD`
+feature just before every ``#include`` statement in the generated unity
+source files. For example:
+
+.. code-block:: cmake
+
+ set(before [[
+ #if !defined(NOMINMAX)
+ #define NOMINMAX
+ #endif
+ ]])
+ set_target_properties(myTarget PROPERTIES
+ UNITY_BUILD_CODE_BEFORE_INCLUDE "${before}"
+ )
+
+See also :prop_tgt:`UNITY_BUILD_CODE_AFTER_INCLUDE`.
diff --git a/Help/prop_tgt/VERSION.rst b/Help/prop_tgt/VERSION.rst
index 66e7bde71..ff3b3030f 100644
--- a/Help/prop_tgt/VERSION.rst
+++ b/Help/prop_tgt/VERSION.rst
@@ -22,7 +22,7 @@ These numbers are used as the image version of the binary.
Mach-O Versions
^^^^^^^^^^^^^^^
-For shared libraries and executables on Mach-O systems (e.g. OS X, iOS),
+For shared libraries and executables on Mach-O systems (e.g. macOS, iOS),
the :prop_tgt:`SOVERSION` property correspond to *compatibility version* and
``VERSION`` to *current version*. See the :prop_tgt:`FRAMEWORK` target
property for an example. Versions of Mach-O binaries may be checked with the
diff --git a/Help/prop_tgt/VS_CONFIGURATION_TYPE.rst b/Help/prop_tgt/VS_CONFIGURATION_TYPE.rst
index ff987ffb8..640bed596 100644
--- a/Help/prop_tgt/VS_CONFIGURATION_TYPE.rst
+++ b/Help/prop_tgt/VS_CONFIGURATION_TYPE.rst
@@ -4,6 +4,8 @@ VS_CONFIGURATION_TYPE
Visual Studio project configuration type.
Sets the ``ConfigurationType`` attribute for a generated Visual Studio project.
+The property value may use
+:manual:`generator expressions <cmake-generator-expressions(7)>`.
If this property is set, it overrides the default setting that is based on the
target type (e.g. ``StaticLibrary``, ``Application``, ...).
diff --git a/Help/prop_tgt/VS_DEBUGGER_COMMAND.rst b/Help/prop_tgt/VS_DEBUGGER_COMMAND.rst
new file mode 100644
index 000000000..ba5fd0aeb
--- /dev/null
+++ b/Help/prop_tgt/VS_DEBUGGER_COMMAND.rst
@@ -0,0 +1,11 @@
+VS_DEBUGGER_COMMAND
+-------------------
+
+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.
+
+This property only works for Visual Studio 2010 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
new file mode 100644
index 000000000..06ef5d5fc
--- /dev/null
+++ b/Help/prop_tgt/VS_DEBUGGER_COMMAND_ARGUMENTS.rst
@@ -0,0 +1,11 @@
+VS_DEBUGGER_COMMAND_ARGUMENTS
+-----------------------------
+
+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.
+
+This property only works for Visual Studio 2010 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
new file mode 100644
index 000000000..f55ac7bee
--- /dev/null
+++ b/Help/prop_tgt/VS_DEBUGGER_ENVIRONMENT.rst
@@ -0,0 +1,11 @@
+VS_DEBUGGER_ENVIRONMENT
+-----------------------
+
+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.
+
+This property only works for Visual Studio 2010 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 0af85cbdc..008bbf6e6 100644
--- a/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst
+++ b/Help/prop_tgt/VS_DEBUGGER_WORKING_DIRECTORY.rst
@@ -2,5 +2,10 @@ VS_DEBUGGER_WORKING_DIRECTORY
-----------------------------
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.
+
+This property only works for Visual Studio 2010 and above;
+it is ignored on other generators.
diff --git a/Help/prop_tgt/VS_DOTNET_REFERENCEPROP_refname_TAG_tagname.rst b/Help/prop_tgt/VS_DOTNET_REFERENCEPROP_refname_TAG_tagname.rst
new file mode 100644
index 000000000..ab311eaf6
--- /dev/null
+++ b/Help/prop_tgt/VS_DOTNET_REFERENCEPROP_refname_TAG_tagname.rst
@@ -0,0 +1,14 @@
+VS_DOTNET_REFERENCEPROP_<refname>_TAG_<tagname>
+-----------------------------------------------
+
+Defines an XML property ``<tagname>`` for a .NET reference
+``<refname>``.
+
+Reference properties can be set for .NET references which are
+defined by the target properties :prop_tgt:`VS_DOTNET_REFERENCES`,
+:prop_tgt:`VS_DOTNET_REFERENCE_<refname>`
+and also for project references to other C# targets which are
+established by :command:`target_link_libraries()`.
+
+This property is only applicable to C# targets and Visual Studio
+generators 2010 and later.
diff --git a/Help/prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION.rst b/Help/prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION.rst
index 829d696d5..9f5a313d3 100644
--- a/Help/prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION.rst
+++ b/Help/prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION.rst
@@ -5,3 +5,6 @@ Specify the .NET target framework version.
Used to specify the .NET target framework version for C++/CLI. For
example, "v4.5".
+
+This property is deprecated and should not be used anymore. Use
+:prop_tgt:`DOTNET_TARGET_FRAMEWORK_VERSION` instead.
diff --git a/Help/prop_tgt/VS_DPI_AWARE.rst b/Help/prop_tgt/VS_DPI_AWARE.rst
new file mode 100644
index 000000000..82640cc60
--- /dev/null
+++ b/Help/prop_tgt/VS_DPI_AWARE.rst
@@ -0,0 +1,14 @@
+VS_DPI_AWARE
+------------
+
+Set the Manifest Tool -> Input and Output -> DPI Awareness in the Visual Studio
+target project properties.
+
+Valid values are ``PerMonitor``, ``ON``, or ``OFF``.
+
+For example:
+
+.. code-block:: cmake
+
+ add_executable(myproject myproject.cpp)
+ set_property(TARGET myproject PROPERTY VS_DPI_AWARE "PerMonitor")
diff --git a/Help/prop_tgt/VS_JUST_MY_CODE_DEBUGGING.rst b/Help/prop_tgt/VS_JUST_MY_CODE_DEBUGGING.rst
new file mode 100644
index 000000000..42fb8ad86
--- /dev/null
+++ b/Help/prop_tgt/VS_JUST_MY_CODE_DEBUGGING.rst
@@ -0,0 +1,10 @@
+VS_JUST_MY_CODE_DEBUGGING
+-------------------------
+
+Enable Just My Code with Visual Studio debugger.
+
+Supported on :ref:`Visual Studio Generators` for VS 2010 and higher,
+:ref:`Makefile Generators` and the :generator:`Ninja` generators.
+
+This property is initialized by the :variable:`CMAKE_VS_JUST_MY_CODE_DEBUGGING`
+variable if it is set when a target is created.
diff --git a/Help/prop_tgt/VS_NO_SOLUTION_DEPLOY.rst b/Help/prop_tgt/VS_NO_SOLUTION_DEPLOY.rst
new file mode 100644
index 000000000..ffcbde572
--- /dev/null
+++ b/Help/prop_tgt/VS_NO_SOLUTION_DEPLOY.rst
@@ -0,0 +1,46 @@
+VS_NO_SOLUTION_DEPLOY
+---------------------
+
+Specify that the target should not be marked for deployment to a Windows CE
+or Windows Phone device in the generated Visual Studio solution.
+
+Be default, all EXE and shared library (DLL) targets are marked to deploy to
+the target device in the generated Visual Studio solution.
+
+Generator expressions are supported.
+
+There are reasons one might want to exclude a target / generated project from
+deployment:
+
+- The library or executable may not be necessary in the primary deploy/debug
+ scenario, and excluding from deployment saves time in the
+ develop/download/debug cycle.
+- There may be insufficient space on the target device to accommodate all of
+ the build products.
+- Visual Studio 2013 requires a target device IP address be entered for each
+ target marked for deployment. For large numbers of targets, this can be
+ tedious.
+ NOTE: Visual Studio *will* deploy all project dependencies of a project
+ tagged for deployment to the IP address configured for that project even
+ if those dependencies are not tagged for deployment.
+
+
+Example 1
+^^^^^^^^^
+
+This shows setting the variable for the target foo.
+
+.. code-block:: cmake
+
+ add_library(foo SHARED foo.cpp)
+ set_property(TARGET foo PROPERTY VS_NO_SOLUTION_DEPLOY ON)
+
+Example 2
+^^^^^^^^^
+
+This shows setting the variable for the Release configuration only.
+
+.. code-block:: cmake
+
+ add_library(foo SHARED foo.cpp)
+ set_property(TARGET foo PROPERTY VS_NO_SOLUTION_DEPLOY "$<CONFIG:Release>")
diff --git a/Help/prop_tgt/VS_PACKAGE_REFERENCES.rst b/Help/prop_tgt/VS_PACKAGE_REFERENCES.rst
new file mode 100644
index 000000000..5a0465bcc
--- /dev/null
+++ b/Help/prop_tgt/VS_PACKAGE_REFERENCES.rst
@@ -0,0 +1,13 @@
+VS_PACKAGE_REFERENCES
+---------------------
+
+Visual Studio package references for nuget.
+
+Adds one or more semicolon-delimited package references to a generated
+Visual Studio project. The version of the package will be
+underscore delimited. For example, ``boost_1.7.0;nunit_3.12.*``.
+
+.. code-block:: cmake
+
+ set_property(TARGET ${TARGET_NAME} PROPERTY
+ VS_PACKAGE_REFERENCES "boost_1.7.0")
diff --git a/Help/prop_tgt/VS_PROJECT_IMPORT.rst b/Help/prop_tgt/VS_PROJECT_IMPORT.rst
new file mode 100644
index 000000000..569c8ea74
--- /dev/null
+++ b/Help/prop_tgt/VS_PROJECT_IMPORT.rst
@@ -0,0 +1,8 @@
+VS_PROJECT_IMPORT
+-----------------
+
+Visual Studio managed project imports
+
+Adds to a generated Visual Studio project one or more semicolon-delimited paths
+to .props files needed when building projects from some NuGet packages.
+For example, ``my_packages_path/MyPackage.1.0.0/build/MyPackage.props``.
diff --git a/Help/prop_tgt/VS_SDK_REFERENCES.rst b/Help/prop_tgt/VS_SDK_REFERENCES.rst
index 769a0d1d5..99987f561 100644
--- a/Help/prop_tgt/VS_SDK_REFERENCES.rst
+++ b/Help/prop_tgt/VS_SDK_REFERENCES.rst
@@ -2,6 +2,6 @@ VS_SDK_REFERENCES
-----------------
Visual Studio project SDK references.
-Specify a :ref:`;-list <CMake Language Lists>` of SDK references
+Specify a :ref:`semicolon-separated list <CMake Language Lists>` of SDK references
to be added to a generated Visual Studio project, e.g.
``Microsoft.AdMediatorWindows81, Version=1.0``.
diff --git a/Help/prop_tgt/WIN32_EXECUTABLE.rst b/Help/prop_tgt/WIN32_EXECUTABLE.rst
index 336d5f7f3..060d16671 100644
--- a/Help/prop_tgt/WIN32_EXECUTABLE.rst
+++ b/Help/prop_tgt/WIN32_EXECUTABLE.rst
@@ -5,8 +5,9 @@ Build an executable with a WinMain entry point on windows.
When this property is set to true the executable when linked on
Windows will be created with a WinMain() entry point instead of just
-main(). This makes it a GUI executable instead of a console
-application. See the CMAKE_MFC_FLAG variable documentation to
-configure use of MFC for WinMain executables. This property is
-initialized by the value of the variable CMAKE_WIN32_EXECUTABLE if it
-is set when a target is created.
+main(). This makes it a GUI executable instead of a console application.
+See the :variable:`CMAKE_MFC_FLAG` variable documentation to
+configure use of the Microsoft Foundation Classes (MFC) for WinMain
+executables. This property is initialized by the value of the
+:variable:`CMAKE_WIN32_EXECUTABLE` variable if it is set when
+a target is created.
diff --git a/Help/prop_tgt/XCODE_ATTRIBUTE_an-attribute.rst b/Help/prop_tgt/XCODE_ATTRIBUTE_an-attribute.rst
index 7e00ac430..71858c50e 100644
--- a/Help/prop_tgt/XCODE_ATTRIBUTE_an-attribute.rst
+++ b/Help/prop_tgt/XCODE_ATTRIBUTE_an-attribute.rst
@@ -3,8 +3,8 @@ XCODE_ATTRIBUTE_<an-attribute>
Set Xcode target attributes directly.
-Tell the Xcode generator to set '<an-attribute>' to a given value in
-the generated Xcode project. Ignored on other generators.
+Tell the :generator:`Xcode` generator to set '<an-attribute>' to a given
+value in the generated Xcode project. Ignored on other generators.
See the :variable:`CMAKE_XCODE_ATTRIBUTE_<an-attribute>` variable
to set attributes on all targets in a directory tree.
diff --git a/Help/prop_tgt/XCODE_GENERATE_SCHEME.rst b/Help/prop_tgt/XCODE_GENERATE_SCHEME.rst
new file mode 100644
index 000000000..0e182cfc2
--- /dev/null
+++ b/Help/prop_tgt/XCODE_GENERATE_SCHEME.rst
@@ -0,0 +1,40 @@
+XCODE_GENERATE_SCHEME
+---------------------
+
+If enabled, the :generator:`Xcode` generator will generate schema files. These
+are useful to invoke analyze, archive, build-for-testing and test
+actions from the command line.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_GENERATE_SCHEME` if it is set when a target
+is created.
+
+The following target properties overwrite the default of the
+corresponding settings on the "Diagnostic" tab for each schema file.
+Each of those is initialized by the respective ``CMAKE_`` variable
+at target creation time.
+
+- :prop_tgt:`XCODE_SCHEME_ADDRESS_SANITIZER`
+- :prop_tgt:`XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN`
+- :prop_tgt:`XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER`
+- :prop_tgt:`XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS`
+- :prop_tgt:`XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE`
+- :prop_tgt:`XCODE_SCHEME_GUARD_MALLOC`
+- :prop_tgt:`XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP`
+- :prop_tgt:`XCODE_SCHEME_MALLOC_GUARD_EDGES`
+- :prop_tgt:`XCODE_SCHEME_MALLOC_SCRIBBLE`
+- :prop_tgt:`XCODE_SCHEME_MALLOC_STACK`
+- :prop_tgt:`XCODE_SCHEME_THREAD_SANITIZER`
+- :prop_tgt:`XCODE_SCHEME_THREAD_SANITIZER_STOP`
+- :prop_tgt:`XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER`
+- :prop_tgt:`XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP`
+- :prop_tgt:`XCODE_SCHEME_ZOMBIE_OBJECTS`
+
+The following target properties will be applied on the
+"Info", "Arguments", and "Options" tab:
+
+- :prop_tgt:`XCODE_SCHEME_ARGUMENTS`
+- :prop_tgt:`XCODE_SCHEME_DEBUG_AS_ROOT`
+- :prop_tgt:`XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING`
+- :prop_tgt:`XCODE_SCHEME_ENVIRONMENT`
+- :prop_tgt:`XCODE_SCHEME_EXECUTABLE`
diff --git a/Help/prop_tgt/XCODE_SCHEME_ADDRESS_SANITIZER.rst b/Help/prop_tgt/XCODE_SCHEME_ADDRESS_SANITIZER.rst
new file mode 100644
index 000000000..cc9bac2e6
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_ADDRESS_SANITIZER.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_ADDRESS_SANITIZER
+------------------------------
+
+Whether to enable ``Address Sanitizer`` in the Diagnostics
+section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER` if it is set
+when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN.rst b/Help/prop_tgt/XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN.rst
new file mode 100644
index 000000000..37a043a1a
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN
+-----------------------------------------------
+
+Whether to enable ``Detect use of stack after return``
+in the Diagnostics section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN`
+if it is set when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_ARGUMENTS.rst b/Help/prop_tgt/XCODE_SCHEME_ARGUMENTS.rst
new file mode 100644
index 000000000..1f228e34c
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_ARGUMENTS.rst
@@ -0,0 +1,10 @@
+XCODE_SCHEME_ARGUMENTS
+----------------------
+
+Specify command line arguments that should be added to the Arguments
+section of the generated Xcode scheme.
+
+If set to a list of arguments those will be added to the scheme.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_DEBUG_AS_ROOT.rst b/Help/prop_tgt/XCODE_SCHEME_DEBUG_AS_ROOT.rst
new file mode 100644
index 000000000..5407e807b
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_DEBUG_AS_ROOT.rst
@@ -0,0 +1,7 @@
+XCODE_SCHEME_DEBUG_AS_ROOT
+--------------------------
+
+Whether to debug the target as 'root'.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING.rst b/Help/prop_tgt/XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING.rst
new file mode 100644
index 000000000..9afeedd99
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING.rst
@@ -0,0 +1,13 @@
+XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING
+--------------------------------------
+
+Whether to enable
+``Allow debugging when using document Versions Browser``
+in the Options section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING`
+if it is set when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER.rst b/Help/prop_tgt/XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER.rst
new file mode 100644
index 000000000..1a6fcfd2e
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER
+----------------------------------------
+
+Whether to disable the ``Main Thread Checker``
+in the Diagnostics section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER`
+if it is set when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS.rst b/Help/prop_tgt/XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS.rst
new file mode 100644
index 000000000..922402290
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS
+----------------------------------
+
+Whether to enable ``Dynamic Library Loads``
+in the Diagnostics section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS` if it is set
+when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE.rst b/Help/prop_tgt/XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE.rst
new file mode 100644
index 000000000..203c80329
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE
+-------------------------------------
+
+Whether to enable ``Dynamic Linker API usage``
+in the Diagnostics section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE` if it is set
+when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_ENVIRONMENT.rst b/Help/prop_tgt/XCODE_SCHEME_ENVIRONMENT.rst
new file mode 100644
index 000000000..c6d875e88
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_ENVIRONMENT.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_ENVIRONMENT
+------------------------
+
+Specify environment variables that should be added to the Arguments
+section of the generated Xcode scheme.
+
+If set to a list of environment variables and values of the form
+``MYVAR=value`` those environment variables will be added to the
+scheme.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_EXECUTABLE.rst b/Help/prop_tgt/XCODE_SCHEME_EXECUTABLE.rst
new file mode 100644
index 000000000..104841b7c
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_EXECUTABLE.rst
@@ -0,0 +1,9 @@
+XCODE_SCHEME_EXECUTABLE
+-----------------------
+
+Specify path to executable in the Info section of the generated
+Xcode scheme. If not set the schema generator will select the
+current target if it is actually executable.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_GUARD_MALLOC.rst b/Help/prop_tgt/XCODE_SCHEME_GUARD_MALLOC.rst
new file mode 100644
index 000000000..c4e83da2f
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_GUARD_MALLOC.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_GUARD_MALLOC
+------------------------------
+
+Whether to enable ``Guard Malloc``
+in the Diagnostics section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_GUARD_MALLOC` if it is set
+when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP.rst b/Help/prop_tgt/XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP.rst
new file mode 100644
index 000000000..73992c3c3
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP.rst
@@ -0,0 +1,13 @@
+XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP
+-------------------------------------
+
+Whether to enable the ``Main Thread Checker`` option
+``Pause on issues``
+in the Diagnostics section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP` if it is set
+when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_MALLOC_GUARD_EDGES.rst b/Help/prop_tgt/XCODE_SCHEME_MALLOC_GUARD_EDGES.rst
new file mode 100644
index 000000000..ca761c05b
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_MALLOC_GUARD_EDGES.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_MALLOC_GUARD_EDGES
+-------------------------------
+
+Whether to enable ``Malloc Guard Edges``
+in the Diagnostics section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_MALLOC_GUARD_EDGES` if it is set
+when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_MALLOC_SCRIBBLE.rst b/Help/prop_tgt/XCODE_SCHEME_MALLOC_SCRIBBLE.rst
new file mode 100644
index 000000000..c5ddb950f
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_MALLOC_SCRIBBLE.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_MALLOC_SCRIBBLE
+------------------------------
+
+Whether to enable ``Malloc Scribble``
+in the Diagnostics section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_MALLOC_SCRIBBLE` if it is set
+when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_MALLOC_STACK.rst b/Help/prop_tgt/XCODE_SCHEME_MALLOC_STACK.rst
new file mode 100644
index 000000000..170f33d90
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_MALLOC_STACK.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_MALLOC_STACK
+-------------------------
+
+Whether to enable ``Malloc Stack`` in the Diagnostics
+section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_MALLOC_STACK` if it is set
+when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_THREAD_SANITIZER.rst b/Help/prop_tgt/XCODE_SCHEME_THREAD_SANITIZER.rst
new file mode 100644
index 000000000..bb70141f3
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_THREAD_SANITIZER.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_THREAD_SANITIZER
+-----------------------------
+
+Whether to enable ``Thread Sanitizer`` in the Diagnostics
+section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_THREAD_SANITIZER` if it is set
+when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_THREAD_SANITIZER_STOP.rst b/Help/prop_tgt/XCODE_SCHEME_THREAD_SANITIZER_STOP.rst
new file mode 100644
index 000000000..5deadb16e
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_THREAD_SANITIZER_STOP.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_THREAD_SANITIZER_STOP
+----------------------------------
+
+Whether to enable ``Thread Sanitizer - Pause on issues``
+in the Diagnostics section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_THREAD_SANITIZER_STOP` if it is set
+when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER.rst b/Help/prop_tgt/XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER.rst
new file mode 100644
index 000000000..0cd823dec
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER
+------------------------------------------
+
+Whether to enable ``Undefined Behavior Sanitizer``
+in the Diagnostics section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER`
+if it is set when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP.rst b/Help/prop_tgt/XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP.rst
new file mode 100644
index 000000000..d1a9bca2c
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP.rst
@@ -0,0 +1,13 @@
+XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP
+-----------------------------------------------
+
+Whether to enable ``Undefined Behavior Sanitizer`` option
+``Pause on issues``
+in the Diagnostics section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP`
+if it is set when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/prop_tgt/XCODE_SCHEME_ZOMBIE_OBJECTS.rst b/Help/prop_tgt/XCODE_SCHEME_ZOMBIE_OBJECTS.rst
new file mode 100644
index 000000000..6e70e8be9
--- /dev/null
+++ b/Help/prop_tgt/XCODE_SCHEME_ZOMBIE_OBJECTS.rst
@@ -0,0 +1,12 @@
+XCODE_SCHEME_ZOMBIE_OBJECTS
+------------------------------
+
+Whether to enable ``Zombie Objects``
+in the Diagnostics section of the generated Xcode scheme.
+
+This property is initialized by the value of the variable
+:variable:`CMAKE_XCODE_SCHEME_ZOMBIE_OBJECTS` if it is set
+when a target is created.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/release/3.0.rst b/Help/release/3.0.rst
index d02f94093..64491e310 100644
--- a/Help/release/3.0.rst
+++ b/Help/release/3.0.rst
@@ -224,7 +224,7 @@ Modules
option to change the ``boost`` prefix on library names.
* The :module:`FindBoost` module learned to control search
- for libraies with the ``g`` tag (for MS debug runtime) with
+ for libraries with the ``g`` tag (for MS debug runtime) with
a new ``Boost_USE_DEBUG_RUNTIME`` option. It is ``ON`` by
default to preserve existing behavior.
diff --git a/Help/release/3.1.rst b/Help/release/3.1.rst
index dca42cdcd..8bea28f70 100644
--- a/Help/release/3.1.rst
+++ b/Help/release/3.1.rst
@@ -289,16 +289,16 @@ CPack
-----
* :manual:`cpack(1)` gained an ``IFW`` generator to package using
- Qt Framework Installer tools. See the :module:`CPackIFW` module.
+ Qt Framework Installer tools. See the :cpack_gen:`CPack IFW Generator`.
* :manual:`cpack(1)` gained ``7Z`` and ``TXZ`` generators supporting
lzma-compressed archives.
-* The :module:`CPackDeb` module learned a new
+* The :cpack_gen:`CPack DEB Generator` learned a new
:variable:`CPACK_DEBIAN_COMPRESSION_TYPE` variable to set the
tarball compression type.
-* The :manual:`cpack(1)` ``WiX`` generator learned to support
+* The :cpack_gen:`CPack WIX Generator` learned to support
a :prop_inst:`CPACK_WIX_ACL` installed file property to
specify an Access Control List.
diff --git a/Help/release/3.10.rst b/Help/release/3.10.rst
new file mode 100644
index 000000000..03eda362d
--- /dev/null
+++ b/Help/release/3.10.rst
@@ -0,0 +1,282 @@
+CMake 3.10 Release Notes
+************************
+
+.. only:: html
+
+ .. contents::
+
+Changes made since CMake 3.9 include the following.
+
+New Features
+============
+
+Platforms
+---------
+
+* The `flang`_ Fortran compiler is now supported, with compiler id ``Flang``.
+
+* A new minimal platform file for ``Midipix`` was added.
+
+* Support for the MSVC ARM64 architecture was added.
+ Visual Studio 2017 Update 4 and above offer an ARM64 toolchain.
+
+* Support for the IAR ARM Compiler was improved.
+
+.. _`flang`: https://github.com/flang-compiler/flang
+
+Generators
+----------
+
+* The :ref:`Makefile Generators` and the :generator:`Ninja` generator learned
+ to add compiler launcher tools like ccache along with the compiler for the
+ ``CUDA`` language (``C`` and ``CXX`` were supported previously). See the
+ :variable:`CMAKE_<LANG>_COMPILER_LAUNCHER` variable and
+ :prop_tgt:`<LANG>_COMPILER_LAUNCHER` target property for details.
+
+* The :generator:`CodeBlocks` extra generator learned to optionally exclude
+ files from outside the project root directory from the generated project.
+ See the :variable:`CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES` variable.
+
+Commands
+--------
+
+* The :command:`cmake_host_system_information` command learned more keys
+ to get information about the processor capabilities and the host OS
+ version.
+
+* The :command:`configure_file` command learned to support indented
+ ``# cmakedefine`` and ``# cmakedefine01``. Spaces and/or tabs between
+ the ``#`` character and the ``cmakedefine``/``cmakedefine01`` words
+ are now understood and preserved in the output.
+
+* The :command:`execute_process` command gained a ``RESULTS_VARIABLE``
+ option to collect a list of results from all children in a pipeline
+ of processes when multiple ``COMMAND`` arguments are given.
+
+* The :command:`include_guard` command was introduced to allow guarding
+ CMake scripts from being included more than once. The command supports
+ ``DIRECTORY`` and ``GLOBAL`` options to adjust the corresponding include guard
+ scope. If no options given, include guard is similar to basic variable-based
+ check.
+
+* The :command:`string` command learned a new ``PREPEND`` subcommand.
+
+* The :command:`string(TIMESTAMP)` command now supports ``%A``
+ for full weekday name and ``%B`` for full month name.
+
+Variables
+---------
+
+* A :variable:`CMAKE_DIRECTORY_LABELS` variable was added to specify
+ labels for all tests in a directory.
+
+Properties
+----------
+
+* A :prop_tgt:`<LANG>_CPPCHECK` target property and supporting
+ :variable:`CMAKE_<LANG>_CPPCHECK` variable were introduced to tell
+ the :ref:`Makefile Generators` and the :generator:`Ninja` generator to
+ run ``cppcheck`` with the compiler for ``C`` and ``CXX`` languages.
+
+* A :prop_dir:`LABELS` directory property was added to specify labels
+ for all targets and tests in a directory.
+
+* A :prop_dir:`TEST_INCLUDE_FILES` directory property was added to
+ list any number of files to be included when running tests with
+ :manual:`ctest(1)`. This generalizes the :prop_dir:`TEST_INCLUDE_FILE`
+ property.
+
+* The :prop_tgt:`VS_DOTNET_REFERENCEPROP_<refname>_TAG_<tagname>`
+ target property was added to support custom XML tags for reference
+ assemblies in C# targets.
+
+* Source file properties :prop_sf:`VS_SHADER_OUTPUT_HEADER_FILE` and
+ :prop_sf:`VS_SHADER_VARIABLE_NAME` have been added to specify more
+ details of ``.hlsl`` sources with :ref:`Visual Studio Generators`.
+
+Modules
+-------
+
+* The :module:`FindCurses` module gained a ``CURSES_NEED_WIDE`` option
+ to request the wide-character variant.
+
+* The :module:`FindEXPAT` module now provides imported targets.
+
+* The :module:`FindFreetype` module now provides imported targets.
+
+* :module:`FindMPI` gained a number of new features, including:
+
+ * Language-specific components have been added to the module.
+ * Many more MPI environments are now supported.
+ * The environmental support for Fortran has been improved.
+ * A user now has fine-grained control over the MPI selection process,
+ including passing custom parameters to the MPI compiler.
+ * The version of the implemented MPI standard is now being exposed.
+ * MPI-2 C++ bindings can now be detected and also suppressed if so desired.
+ * The available Fortran bindings are now being detected and verified.
+ * Various MPI-3 information can be requested, including the library version
+ and Fortran capabilities of the individual bindings.
+ * Statically linked MPI implementations are supported.
+
+* A :module:`FindOpenACC` module was added to detect compiler support
+ for OpenACC. Currently only supports PGI, GNU and Cray compilers.
+
+* The :module:`FindOpenGL` module gained support for GLVND on Linux.
+
+* The :module:`FindOpenMP` module gained support for
+ language-specific components.
+
+* A :module:`FindPatch` module was added to find the ``patch``
+ command-line executable.
+
+* The :module:`FindProtobuf` module :command:`protobuf_generate_cpp` command
+ gained a ``DESCRIPTORS`` option to generate descriptor files.
+
+* The :module:`GoogleTest` module gained a new command
+ :command:`gtest_discover_tests` implementing dynamic (build-time) test
+ discovery. Unlike the source parsing approach, dynamic discovery executes
+ the test (in 'list available tests' mode) at build time to discover tests.
+ This is robust against unusual ways of labeling tests, provides much better
+ support for advanced features such as parameterized tests, and does not
+ require re-running CMake to discover added or removed tests within a test
+ executable. Note that a breaking change was made in CMake 3.10.3 to address
+ an ambiguity of the ``TIMEOUT`` keyword (see :ref:`Release Notes 3.10.3`).
+
+* The :module:`InstallRequiredSystemLibraries` module gained support
+ for installing Intel compiler runtimes.
+
+Autogen
+-------
+
+* When using :prop_tgt:`AUTOMOC` or :prop_tgt:`AUTOUIC` with a
+ multi configuration generator (e.g. :generator:`Xcode`),
+ included ``*.moc``, ``moc_*.cpp`` and ``ui_*.h`` files are generated in
+ ``<AUTOGEN_BUILD_DIR>/include_<CONFIG>`` instead of
+ ``<AUTOGEN_BUILD_DIR>/include``.
+
+* When using :prop_tgt:`AUTOMOC` or :prop_tgt:`AUTOUIC`,
+ source files that are :prop_sf:`GENERATED` will be processed as well.
+ They were ignored by :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC`
+ in earlier releases.
+ See policy :policy:`CMP0071`.
+
+* When using :prop_tgt:`AUTOMOC`, CMake searches for the strings ``Q_OBJECT``,
+ ``Q_GADGET`` or ``Q_NAMESPACE`` in a source file to determine if it needs
+ to be ``moc`` processed. The new :variable:`CMAKE_AUTOMOC_MACRO_NAMES`
+ variable and :prop_tgt:`AUTOMOC_MACRO_NAMES` target property may be set
+ to register additional strings (macro names) to search for.
+
+* When using :prop_tgt:`AUTOMOC`, the new
+ :variable:`CMAKE_AUTOMOC_COMPILER_PREDEFINES` variable and
+ :prop_tgt:`AUTOMOC_COMPILER_PREDEFINES` target property specify whether
+ to enable or disable the generation of the compiler pre definitions file
+ ``moc_predefs.h``.
+
+CTest
+-----
+
+* A :variable:`CTEST_LABELS_FOR_SUBPROJECTS` CTest module variable and CTest
+ script variable were added to specify a list of labels that should be
+ treated as subprojects by CDash. To use this value in both the CTest module
+ and the ctest command line :ref:`Dashboard Client` mode (e.g. ``ctest -S``)
+ set it in the ``CTestConfig.cmake`` config file.
+
+CPack
+-----
+
+* A :cpack_gen:`CPack FreeBSD Generator` was added for FreeBSD ``pkg(8)``.
+
+* The :cpack_gen:`CPack DEB Generator` was enabled on Windows. While not
+ fully featured (due to the lack of external UNIX tools) this will allow
+ building basic cross-platform Debian packages.
+
+* The :cpack_gen:`CPack DEB Generator` learned to set package release
+ version in ``Version`` info property.
+ See the :variable:`CPACK_DEBIAN_PACKAGE_RELEASE` variable.
+
+* The :cpack_gen:`CPack DEB Generator` learned more strict package
+ version checking that complies with Debian rules.
+
+* The :module:`CPackIFW` module :command:`cpack_ifw_configure_component` and
+ :command:`cpack_ifw_configure_component_group` commands gained a new
+ ``REPLACES`` and ``CHECKABLE`` options.
+
+* The :cpack_gen:`CPack IFW Generator` gained new
+ :variable:`CPACK_IFW_PACKAGE_FILE_EXTENSION` variable to customize
+ target binary format.
+
+* The :cpack_gen:`CPack IFW Generator` gained new
+ :variable:`CPACK_IFW_REPOSITORIES_DIRECTORIES` variable to specify
+ additional repositories dirs that will be used to resolve and
+ repack dependent components. This feature is only available when
+ using QtIFW 3.1 or later.
+
+* The :cpack_gen:`CPack RPM Generator` and :cpack_gen:`CPack DEB Generator`
+ learned to set the package epoch version.
+ See :variable:`CPACK_RPM_PACKAGE_EPOCH` and
+ :variable:`CPACK_DEBIAN_PACKAGE_EPOCH` variables.
+
+Other
+-----
+
+* The :manual:`cmake(1)` ``-E`` mode gained support for ``sha1sum``,
+ ``sha224sum``, ``sha256sum``, ``sha384sum``, and ``sha512sum``.
+
+* The graphviz output now distinguishes among the different dependency types
+ ``PUBLIC``, ``PRIVATE`` and ``INTERFACE`` and represents them in the output
+ graph as solid, dashed and dotted edges.
+
+Deprecated and Removed Features
+===============================
+
+* Support for building CMake itself with C++98 compilers was dropped.
+ CMake is now implemented using C++11.
+
+* Support for building CMake on HP-UX has been dropped pending better
+ support for C++11 and a port of libuv. See `CMake Issue 17137`_.
+ Use CMake 3.9 or lower instead for HP-UX support.
+
+.. _`CMake Issue 17137`: https://gitlab.kitware.com/cmake/cmake/issues/17137
+
+Other Changes
+=============
+
+* On FreeBSD the C++ compiler named ``c++`` is now the preferred default.
+
+* The :command:`file(GENERATE)` command now interprets relative paths
+ given to its ``OUTPUT`` and ``INPUT`` arguments with respect to the
+ caller's current binary and source directories, respectively.
+ See policy :policy:`CMP0070`.
+
+* The :command:`get_filename_component` ``PROGRAM`` mode semantics
+ have been revised to not tolerate unquoted spaces in the path
+ to the program while also accepting arguments. While technically
+ incompatible with the old behavior, it is expected that behavior
+ under typical use cases with properly-quoted command-lines has
+ not changed.
+
+Updates
+=======
+
+Changes made since CMake 3.10.0 include the following.
+
+3.10.1
+------
+
+* The :manual:`cmake-server(7)` ``codemodel`` response ``crossReferences``
+ field added by 3.10.0 has been dropped due to excessive memory usage.
+ Another approach will be needed to provide backtrace information.
+
+.. _`Release Notes 3.10.3`:
+
+3.10.3
+------
+
+* CMake 3.10.1 added a ``TIMEOUT`` option to :command:`gtest_discover_tests`
+ from the :module:`GoogleTest` module. That keyword clashed with the
+ ``TIMEOUT`` test property, which is one of the common properties that
+ would be set with the command's ``PROPERTIES`` keyword, usually leading
+ to legal but unintended behavior. The keyword was changed to
+ ``DISCOVERY_TIMEOUT`` in CMake 3.10.3 to address this problem. The
+ ambiguous behavior of the :command:`gtest_discover_tests` command's
+ ``TIMEOUT`` keyword in 3.10.1 and 3.10.2 has not been preserved.
diff --git a/Help/release/3.11.rst b/Help/release/3.11.rst
new file mode 100644
index 000000000..a80657d2d
--- /dev/null
+++ b/Help/release/3.11.rst
@@ -0,0 +1,307 @@
+CMake 3.11 Release Notes
+************************
+
+.. only:: html
+
+ .. contents::
+
+Changes made since CMake 3.10 include the following.
+
+New Features
+============
+
+Platforms
+---------
+
+* TI C/C++ compilers are now supported by the :generator:`Ninja` generator.
+
+Generators
+----------
+
+* The :generator:`CodeBlocks` extra generator learned to check a
+ :variable:`CMAKE_CODEBLOCKS_COMPILER_ID` variable for a custom
+ compiler identification value to place in the project file.
+
+* The :ref:`Makefile Generators` and the :generator:`Ninja` generator learned
+ to add compiler launcher tools along with the compiler for the ``Fortran``
+ language (``C``, ``CXX``, and ``CUDA`` were supported previously).
+ See the :variable:`CMAKE_<LANG>_COMPILER_LAUNCHER` variable and
+ :prop_tgt:`<LANG>_COMPILER_LAUNCHER` target property for details.
+
+* :ref:`Visual Studio Generators` learned to support the ``COMPILE_LANGUAGE``
+ :manual:`generator expression <cmake-generator-expressions(7)>` in
+ target-wide :prop_tgt:`COMPILE_DEFINITIONS`,
+ :prop_tgt:`INCLUDE_DIRECTORIES`, :prop_tgt:`COMPILE_OPTIONS`, and
+ :command:`file(GENERATE)`. See generator expression documentation
+ for caveats.
+
+* The :generator:`Xcode` generator learned to support the ``COMPILE_LANGUAGE``
+ :manual:`generator expression <cmake-generator-expressions(7)>` in
+ target-wide :prop_tgt:`COMPILE_DEFINITIONS` and
+ :prop_tgt:`INCLUDE_DIRECTORIES`. It previously supported only
+ :prop_tgt:`COMPILE_OPTIONS` and :command:`file(GENERATE)`.
+ See generator expression documentation for caveats.
+
+Commands
+--------
+
+* :command:`add_library` and :command:`add_executable` commands can now be
+ called without any sources and will not complain as long as sources are
+ added later via the :command:`target_sources` command.
+
+* The :command:`file(DOWNLOAD)` and :command:`file(UPLOAD)` commands
+ gained ``NETRC`` and ``NETRC_FILE`` options to specify use of a
+ ``.netrc`` file.
+
+* The :command:`target_compile_definitions` command learned to set the
+ :prop_tgt:`INTERFACE_COMPILE_DEFINITIONS` property on
+ :ref:`Imported Targets`.
+
+* The :command:`target_compile_features` command learned to set the
+ :prop_tgt:`INTERFACE_COMPILE_FEATURES` property on :ref:`Imported Targets`.
+
+* The :command:`target_compile_options` command learned to set the
+ :prop_tgt:`INTERFACE_COMPILE_OPTIONS` property on :ref:`Imported Targets`.
+
+* The :command:`target_include_directories` command learned to set the
+ :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` property on
+ :ref:`Imported Targets`.
+
+* The :command:`target_sources` command learned to set the
+ :prop_tgt:`INTERFACE_SOURCES` property on :ref:`Imported Targets`.
+
+* The :command:`target_link_libraries` command learned to set the
+ :prop_tgt:`INTERFACE_LINK_LIBRARIES` property on :ref:`Imported Targets`.
+
+Variables
+---------
+
+* A :variable:`CMAKE_GENERATOR_INSTANCE` variable was introduced
+ to hold the selected instance of the generator's corresponding
+ native tools if multiple are available. This is used by the
+ :generator:`Visual Studio 15 2017` generator to hold the
+ selected instance of Visual Studio persistently.
+
+* A :variable:`CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS` variable was added
+ to enable setting of default permissions for directories created implicitly
+ during installation of files by :command:`install` and
+ :command:`file(INSTALL)`, e.g. during ``make install``.
+
+* A :variable:`CMAKE_JOB_POOLS` variable was added specify a value to use for
+ the :prop_gbl:`JOB_POOLS` property. This enables control over build
+ parallelism with command line configuration parameters when using the Ninja
+ generator.
+
+* The :variable:`CMAKE_NETRC` and :variable:`CMAKE_NETRC_FILE` variables
+ were added to specify use of a ``.netrc`` file by the
+ :command:`file(DOWNLOAD)` and :command:`file(UPLOAD)` commands and
+ the :module:`ExternalProject` module.
+
+* A :variable:`CMAKE_CUDA_SEPARABLE_COMPILATION` variable was added to
+ initialize the :prop_tgt:`CUDA_SEPARABLE_COMPILATION` target property
+ on targets when they are created.
+
+Properties
+----------
+
+* The :prop_sf:`COMPILE_DEFINITIONS` source file property learned to support
+ :manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+* A :prop_sf:`COMPILE_OPTIONS` source file property was added to manage list
+ of options to pass to the compiler.
+
+* An :prop_tgt:`IMPORTED_GLOBAL` target property was added to indicate
+ whether an :ref:`IMPORTED target <Imported Targets>` is globally visible.
+ It is automatically set to a true value for targets created with the
+ ``GLOBAL`` option to :command:`add_library` or :command:`add_executable`.
+ Additionally, project code may now *promote* a local imported target
+ to be globally visible by setting this property to ``TRUE``.
+
+* An :prop_sf:`INCLUDE_DIRECTORIES` source file property was added to specify
+ list of preprocessor include file search directories.
+
+* Source file properties :prop_sf:`VS_SHADER_DISABLE_OPTIMIZATIONS` and
+ :prop_sf:`VS_SHADER_ENABLE_DEBUG` have been added to specify more
+ details of ``.hlsl`` sources with :ref:`Visual Studio Generators`.
+
+Modules
+-------
+
+* The :module:`CheckIncludeFiles` module :command:`CHECK_INCLUDE_FILES`
+ command gained a ``LANGUAGE`` option to specify whether to check using the
+ ``C`` or ``CXX`` compiler.
+
+* The :module:`CMakePackageConfigHelpers` module
+ :command:`write_basic_package_version_file` command learned a new
+ ``SameMinorVersion`` mode for the ``COMPATIBILITY`` argument.
+
+* The :module:`ExternalProject` module learned to substitute ``<DOWNLOAD_DIR>``
+ in comments, commands, working directory and byproducts.
+
+* The :module:`ExternalProject` module gained ``NETRC`` and ``NETRC_FILE``
+ options to specify use of a ``.netrc`` file.
+
+* A new :module:`FetchContent` module was added which supports populating
+ content at configure time using any of the download/update methods
+ supported by :command:`ExternalProject_Add`. This allows the content
+ to be used immediately during the configure stage, such as with
+ :command:`add_subdirectory`, etc. Hierarchical project structures are
+ well supported, allowing parent projects to override the content details
+ of child projects and ensuring content is not populated multiple times
+ throughout the whole project tree.
+
+* The :module:`FindBLAS` and :module:`FindLAPACK` modules learned to support
+ `FLAME`_ ``blis`` and ``libflame``.
+
+* The :module:`FindDoxygen` module :command:`doxygen_add_docs` function
+ now supports a new ``DOXYGEN_VERBATIM_VARS`` list variable. Any
+ ``DOXYGEN_...`` variable contained in that list will bypass the automatic
+ quoting logic, leaving its contents untouched when transferring them to the
+ output ``Doxyfile``.
+
+* A :module:`FindIconv` module was added to locate iconv support.
+
+* The :module:`GenerateExportHeader` module ``GENERATE_EXPORT_HEADER`` command
+ gained an ``INCLUDE_GUARD_NAME`` option to change the name of the include
+ guard symbol written to the generated export header.
+ Additionally, it now adds a comment after the closing ``#endif`` on the
+ generated export header's include guard.
+
+* The :module:`UseJava` module ``add_jar`` command gained a
+ ``GENERATE_NATIVE_HEADERS`` option to generate native header files
+ using ``javac -h`` for ``javac`` 1.8 or above. This supersedes
+ ``create_javah``, which no longer works with JDK 1.10 and above due
+ to removal of the ``javah`` tool by `JEP 313`_.
+
+.. _`FLAME`: https://github.com/flame
+.. _`JEP 313`: http://openjdk.java.net/jeps/313
+
+Autogen
+-------
+
+* When using :prop_tgt:`AUTOMOC` or :prop_tgt:`AUTOUIC`, CMake now starts
+ multiple parallel ``moc`` or ``uic`` processes to reduce the build time.
+ A new :variable:`CMAKE_AUTOGEN_PARALLEL` variable and
+ :prop_tgt:`AUTOGEN_PARALLEL` target property may be set to specify the
+ number of parallel ``moc`` or ``uic`` processes to start. The default
+ is derived from the number of CPUs on the host.
+
+CTest
+-----
+
+* The :command:`ctest_start` command no longer sets
+ :variable:`CTEST_RUN_CURRENT_SCRIPT` due to issues with scoping if it is
+ called from inside a function. Instead, it sets an internal variable in
+ CTest. However, setting :variable:`CTEST_RUN_CURRENT_SCRIPT` to 0 at the
+ global scope still prevents the script from being re-run at the end.
+
+CPack
+-----
+
+* :manual:`cpack(1)` gained ``--trace`` and ``--trace-expand`` options.
+
+* The :cpack_gen:`CPack IFW Generator` gained new
+ :variable:`CPACK_IFW_PACKAGE_REMOVE_TARGET_DIR` variable to control
+ if the target directory should not be deleted when uninstalling.
+
+* The :cpack_gen:`CPack RPM Generator` learned to enable enforcing of execute
+ privileges on programs and shared libraries.
+ See :variable:`CPACK_RPM_INSTALL_WITH_EXEC` variable.
+
+* A :variable:`CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS` variable was added
+ which serves the same purpose during packaging (e.g. ``make package``) as the
+ :variable:`CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS` variable serves during
+ installation (e.g. ``make install``).
+
+Other
+-----
+
+* :ref:`Alias Targets` may now alias :ref:`Imported Targets` that are
+ created with the ``GLOBAL`` option to :command:`add_library`.
+
+* :ref:`Interface Libraries` may now have custom properties set on them if
+ they start with either an underscore (``_``) or a lowercase ASCII character.
+ The original intention was to only allow properties which made sense for
+ ``INTERFACE`` libraries, but it also blocked usage of custom properties.
+
+* The :manual:`cmake(1)` ``--open <dir>`` command-line option was added
+ to open generated IDE projects like Visual Studio solutions or Xcode
+ projects.
+
+Deprecated and Removed Features
+===============================
+
+* An explicit deprecation diagnostic was added for policies ``CMP0037``
+ through ``CMP0054`` (``CMP0036`` and below were already deprecated).
+ The :manual:`cmake-policies(7)` manual explains that the OLD behaviors
+ of all policies are deprecated and that projects should port to the
+ NEW behaviors.
+
+* The ``KDevelop3`` generator has been removed.
+
+Other Changes
+=============
+
+* Policy :policy:`CMP0037` no longer reserves target names associated
+ with optional features, such as ``test`` and ``package``, unless
+ the corresponding feature is enabled.
+
+* The :module:`FindOpenGL` module now prefers GLVND libraries if available.
+ See policy :policy:`CMP0072`.
+
+* The minimum deployment target set in the
+ :variable:`CMAKE_OSX_DEPLOYMENT_TARGET` variable used to be only
+ applied for macOS regardless of the selected SDK. It is now properly
+ set for the target platform selected by :variable:`CMAKE_OSX_SYSROOT`.
+ For example, if the sysroot variable specifies an iOS SDK then the
+ value in ``CMAKE_OSX_DEPLOYMENT_TARGET`` is interpreted as minimum
+ iOS version.
+
+* The :generator:`Xcode` generator behavior of generating one project
+ file per :command:`project()` command may now be controlled with the
+ :variable:`CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY` variable.
+ This could be useful to speed up the CMake generation step for
+ large projects and to work-around a bug in the ``ZERO_CHECK`` logic.
+
+* Since the ``CMakeCache.txt`` format does not support newlines in values,
+ values containing newlines are now truncated before writing to the file.
+ In addition, a warning comment is written to the cache file, and a warning
+ message is displayed to the user on the console.
+
+Updates
+=======
+
+Changes made since CMake 3.11.0 include the following.
+
+3.11.1
+------
+
+* The :module:`CheckIncludeFile` module ``check_include_file`` macro,
+ :module:`CheckIncludeFileCXX` module ``check_include_file_cxx`` macro,
+ and :module:`CheckIncludeFiles` module ``check_include_files`` macro
+ were taught to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable in
+ CMake 3.11.0. This has been reverted due to changing behavior of
+ checks for existing projects. It may be restored in the future
+ with a policy for compatibility.
+
+3.11.2
+------
+
+* Calling :command:`add_library` to create an alias of an imported
+ target that is not globally visible now causes an error again as
+ it did prior to 3.11.0. This diagnostic was accidentally dropped
+ from CMake 3.11.0 and 3.11.1 by the change to allow globally visible
+ imported targets to be aliased.
+
+* The :module:`FindQt4` module ``qt4_wrap_cpp``, ``qt4_wrap_ui`` and
+ ``qt4_add_resources`` macros now set :prop_sf:`SKIP_AUTOMOC` and
+ :prop_sf:`SKIP_AUTOUIC` on their generated files. These files never
+ need to be processed by moc or uic, and we must say so explicitly to
+ account for policy :policy:`CMP0071`.
+
+3.11.3
+------
+
+* CMake 3.11.0 introduced support for resolving symbolic links on
+ Windows in code paths that typically do so on UNIX. This has been
+ reverted due to breakage on ``subst`` drives.
diff --git a/Help/release/3.12.rst b/Help/release/3.12.rst
new file mode 100644
index 000000000..481027ec7
--- /dev/null
+++ b/Help/release/3.12.rst
@@ -0,0 +1,305 @@
+CMake 3.12 Release Notes
+************************
+
+.. only:: html
+
+ .. contents::
+
+Changes made since CMake 3.11 include the following.
+
+New Features
+============
+
+Generators
+----------
+
+* The :ref:`Visual Studio Generators` for VS 2017 learned to support a
+ ``version=14.##`` option in the :variable:`CMAKE_GENERATOR_TOOLSET`
+ value (e.g. via the :manual:`cmake(1)` ``-T`` option) to specify a
+ toolset version number.
+
+Command-Line
+------------
+
+* The :manual:`cmake(1)` :ref:`Build Tool Mode` (``cmake --build``) gained
+ ``--parallel [<jobs>]`` and ``-j [<jobs>]`` options to specify a parallel
+ build level. They map to corresponding options of the native build tool.
+
+Commands
+--------
+
+* The :command:`add_compile_definitions` command was added to set preprocessor
+ definitions at directory level. This supersedes :command:`add_definitions`.
+
+* The :command:`cmake_minimum_required` and :command:`cmake_policy(VERSION)`
+ commands now accept a version range using the form ``<min>[...<max>]``.
+ The ``<min>`` version is required but policies are set based on the
+ older of the running CMake version and the version specified by
+ ``<max>``. This allows projects to specify a range of versions
+ for which they have been updated and avoid explicit policy settings.
+
+* The :command:`file(GLOB)` and :command:`file(GLOB_RECURSE)` commands
+ learned a new flag ``CONFIGURE_DEPENDS`` which enables expression of
+ build system dependency on globbed directory's contents.
+
+* The :command:`file(TOUCH)` and :command:`file(TOUCH_NOCREATE)` commands
+ were added to expose ``TOUCH`` functionality without having to use
+ CMake's command-line tool mode with :command:`execute_process`.
+
+* The :command:`find_package` command now searches prefixes specified by
+ the :variable:`<PackageName>_ROOT` CMake variable and the
+ :envvar:`<PackageName>_ROOT` environment variable. Package roots are
+ maintained as a stack so nested calls to all ``find_*`` commands inside
+ find modules also search the roots as prefixes.
+ See policy :policy:`CMP0074`.
+
+* The :command:`install` command learned an optional ``NAMELINK_COMPONENT``
+ parameter, which allows you to change the component for a shared library's
+ namelink. If none is specified, the value of ``COMPONENT`` is used by
+ default.
+
+* The :command:`list` command learned a ``JOIN`` sub-command
+ to concatenate list's elements separated by a glue string.
+
+* The :command:`list` command learned a ``SUBLIST`` sub-command
+ to get a sublist of the list.
+
+* The :command:`list` command learned a ``TRANSFORM`` sub-command
+ to apply various string transformation to list's elements.
+
+* The :command:`project` command learned an optional ``HOMEPAGE_URL``
+ parameter which has the effect of setting variables like
+ :variable:`PROJECT_HOMEPAGE_URL`, :variable:`<PROJECT-NAME>_HOMEPAGE_URL`
+ and :variable:`CMAKE_PROJECT_HOMEPAGE_URL`.
+
+* The :command:`string` command learned a ``JOIN`` sub-command
+ to concatenate input strings separated by a glue string.
+
+* :command:`target_compile_options` and :command:`add_compile_options`
+ commands gained a ``SHELL:`` prefix to specify a group of related
+ options using shell-like quoting.
+
+* The :command:`target_link_libraries` command now supports
+ :ref:`Object Libraries`. Linking to an object library uses its object
+ files in direct dependents and also propagates usage requirements.
+
+Variables
+---------
+
+* The :variable:`CMAKE_FOLDER` variable was added to initialize the
+ :prop_tgt:`FOLDER` property on all targets.
+
+* The :variable:`CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION` variable
+ was defined to initialize all
+ :prop_tgt:`DOTNET_TARGET_FRAMEWORK_VERSION` target properties.
+
+* ``CMAKE_PROJECT_VERSION*`` variables have been introduced:
+
+ - :variable:`CMAKE_PROJECT_VERSION`
+ - :variable:`CMAKE_PROJECT_VERSION_MAJOR`
+ - :variable:`CMAKE_PROJECT_VERSION_MINOR`
+ - :variable:`CMAKE_PROJECT_VERSION_PATCH`
+ - :variable:`CMAKE_PROJECT_VERSION_TWEAK`
+
+* The :variable:`CMAKE_SUPPRESS_REGENERATION` variable was extended to
+ support the :generator:`Ninja` and :ref:`Makefile Generators`.
+ It is also now documented.
+
+* ``CMAKE_VS_SDK_*_DIRECTORIES`` variables were defined to tell
+ :ref:`Visual Studio Generators` for VS 2010 and above how to populate
+ fields in ``.vcxproj`` files that specify SDK directories. The
+ variables are:
+
+ - :variable:`CMAKE_VS_SDK_EXCLUDE_DIRECTORIES`
+ - :variable:`CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES`
+ - :variable:`CMAKE_VS_SDK_INCLUDE_DIRECTORIES`
+ - :variable:`CMAKE_VS_SDK_LIBRARY_DIRECTORIES`
+ - :variable:`CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES`
+ - :variable:`CMAKE_VS_SDK_REFERENCE_DIRECTORIES`
+ - :variable:`CMAKE_VS_SDK_SOURCE_DIRECTORIES`
+
+* A :variable:`MSVC_TOOLSET_VERSION` variable was added to provide the
+ MSVC toolset version associated with the current MSVC compiler version
+ in :variable:`MSVC_VERSION`.
+
+Properties
+----------
+
+* The :prop_tgt:`COMMON_LANGUAGE_RUNTIME` target property was introduced
+ to configure the use of managed C++ for :ref:`Visual Studio Generators`
+ for VS 2010 and above.
+ A corresponding :prop_tgt:`IMPORTED_COMMON_LANGUAGE_RUNTIME` target
+ property was added to support ``C++/CLI`` for imported targets.
+
+* The :prop_tgt:`DOTNET_TARGET_FRAMEWORK_VERSION` target property
+ was introduced as replacement for
+ :prop_tgt:`VS_DOTNET_TARGET_FRAMEWORK_VERSION`, which is considered
+ deprecated now.
+
+* An :prop_tgt:`EXPORT_PROPERTIES` target property was added to specify a
+ custom list of target properties to include in targets exported by the
+ :command:`install(EXPORT)` and :command:`export` commands.
+
+* The :prop_tgt:`PDB_OUTPUT_DIRECTORY` property learned to support
+ :manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+* A :prop_dir:`TESTS` directory property was added to hold the list of
+ tests defined by the :command:`add_test` command.
+
+* A :prop_tgt:`VS_DEBUGGER_COMMAND` target property was created to set the
+ debugging command line with :ref:`Visual Studio Generators` for VS 2010
+ and above.
+
+* HLSL source file properties :prop_sf:`VS_SHADER_DISABLE_OPTIMIZATIONS`
+ and :prop_sf:`VS_SHADER_ENABLE_DEBUG` gained support for generator
+ expressions.
+
+* HLSL source file property :prop_sf:`VS_SHADER_OBJECT_FILE_NAME` has been
+ added to the :ref:`Visual Studio Generators` for VS 2010 and above.
+ The property specifies the file name of the compiled shader object.
+
+Modules
+-------
+
+* The :module:`FindALSA` module now provides imported targets.
+
+* The :module:`FindCURL` module now provides imported targets.
+
+* The :module:`FindJPEG` module now provides imported targets.
+
+* The :module:`FindLibXml2` module now provides imported targets.
+
+* The :module:`FindMatlab` module now supports the Matlab Runtime
+ Compiler (MCR) for compiling and linking matlab extensions.
+
+* A :module:`FindODBC` module was added to find an Open Database Connectivity
+ (ODBC) library.
+
+* The :module:`FindPkgConfig` module has learned to export the found
+ libraries with full path for direct consumption with the
+ :command:`target_link_libraries` command.
+
+* New :module:`FindPython3` and :module:`FindPython2` modules, as well as
+ a new :module:`FindPython` module, have been added to provide a new way
+ to locate python environments.
+
+* The :module:`UseSWIG` module gained a whole refresh and is now more
+ consistent with standard CMake commands to generate libraries and is
+ fully configurable through properties.
+
+* The :module:`UseSWIG` module learned to manage multiple behaviors through
+ ``UseSWIG_MODULE_VERSION`` variable to ensure legacy support as well as more
+ robust handling of ``SWIG`` advanced features (like ``%template``).
+
+* The :module:`UseSWIG` module learned to support CSHARP variant
+ wrapper files.
+
+* The :module:`WriteCompilerDetectionHeader` module gained a ``BARE_FEATURES``
+ option to add a compatibility define for the exact keyword of a new language
+ feature.
+
+Generator Expressions
+---------------------
+
+* A new ``$<GENEX_EVAL:...>`` and ``$<TARGET_GENEX_EVAL:target,...>``
+ :manual:`generator expression <cmake-generator-expressions(7)>`
+ has been added to enable consumption of generator expressions whose
+ evaluation results itself in generator expressions.
+
+* A new ``$<IN_LIST:...>``
+ :manual:`generator expression <cmake-generator-expressions(7)>`
+ has been added.
+
+* A new ``$<TARGET_EXISTS:...>``
+ :manual:`generator expression <cmake-generator-expressions(7)>`
+ has been added.
+
+* A new ``$<TARGET_NAME_IF_EXISTS:...>``
+ :manual:`generator expression <cmake-generator-expressions(7)>`
+ has been added.
+
+CTest
+-----
+
+* The :command:`ctest_start` command has been reworked so that you can simply
+ call ``ctest_start(APPEND)`` and it will read all the needed information from
+ the TAG file. The argument parsing has also been relaxed so that the order of
+ the arguments is less significant.
+
+* A :prop_test:`PROCESSOR_AFFINITY` test property was added to request
+ that CTest run a test with CPU affinity for a set of processors
+ disjoint from other concurrently running tests with the property set.
+
+CPack
+-----
+
+* The :module:`CPack` module now uses variables
+ :variable:`CMAKE_PROJECT_VERSION_MAJOR`,
+ :variable:`CMAKE_PROJECT_VERSION_MINOR` and
+ :variable:`CMAKE_PROJECT_VERSION_PATCH`
+ to initialize corresponding CPack variables.
+
+* A :cpack_gen:`CPack NuGet Generator` was was added with basic
+ support for `NuGet`_.
+
+.. _NuGet: https://docs.microsoft.com/en-us/nuget/what-is-nuget
+
+Other
+-----
+
+* The :manual:`Compile Features <cmake-compile-features(7)>` functionality
+ is now aware of C++ 20. No specific features are yet enumerated besides
+ the ``cxx_std_20`` meta-feature.
+
+* The :manual:`Compile Features <cmake-compile-features(7)>` functionality
+ is now aware of the availability of C features in MSVC since VS 2010.
+
+* The :manual:`Compile Features <cmake-compile-features(7)>` functionality
+ is now aware of C language standards supported by Texas Instruments C
+ compilers.
+
+Deprecated and Removed Features
+===============================
+
+* The :generator:`Visual Studio 8 2005` generator has been removed.
+
+* CMake no longer produces ``<tgt>_LIB_DEPENDS`` cache entries
+ for library targets. See policy :policy:`CMP0073`.
+
+Other Changes
+=============
+
+* Include flags for directories marked as ``SYSTEM`` are now moved after
+ non-system directories. The ``-isystem`` flag does this automatically,
+ so moving them explicitly to the end makes the behavior consistent on
+ compilers that do not have any ``-isystem`` flag.
+
+* Fortran dependency scanning now supports dependencies implied by
+ `Fortran Submodules`_.
+
+* The existence and functionality of the file
+ ``${CMAKE_BINARY_DIR}/cmake_install.cmake`` has now been documented in the
+ :command:`install` documentation so that external packaging software can take
+ advantage of CPack-style component installs.
+
+* The :module:`CheckIncludeFile` module ``check_include_file`` macro
+ learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable.
+ See policy :policy:`CMP0075`.
+
+* The :module:`CheckIncludeFileCXX` module ``check_include_file_cxx`` macro
+ learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable.
+ See policy :policy:`CMP0075`.
+
+* The :module:`CheckIncludeFiles` module ``check_include_files`` macro
+ learned to honor the ``CMAKE_REQUIRED_LIBRARIES`` variable.
+ See policy :policy:`CMP0075`.
+
+* The :manual:`cmake(1)` ``-E copy_directory`` tool now fails when the
+ source directory does not exist. Previously it succeeded by creating
+ an empty destination directory.
+
+* The :module:`UseSWIG` module :command:`swig_add_library` command
+ (and legacy ``swig_add_module`` command) now set the prefix of
+ Java modules to ``""`` for MINGW, MSYS, and CYGWIN environments.
+
+.. _`Fortran Submodules`: http://fortranwiki.org/fortran/show/Submodules
diff --git a/Help/release/3.13.rst b/Help/release/3.13.rst
new file mode 100644
index 000000000..a8dd0baf7
--- /dev/null
+++ b/Help/release/3.13.rst
@@ -0,0 +1,289 @@
+CMake 3.13 Release Notes
+************************
+
+.. only:: html
+
+ .. contents::
+
+Changes made since CMake 3.12 include the following.
+
+New Features
+============
+
+Generators
+----------
+
+* The :ref:`Visual Studio Generators` for VS 2010 and above learned to
+ support the :prop_tgt:`INTERPROCEDURAL_OPTIMIZATION` target property
+ and supporting :module:`CheckIPOSupported` module.
+
+* The :generator:`Xcode` generator learned to configure more Xcode Scheme
+ fields. See the :variable:`CMAKE_XCODE_GENERATE_SCHEME` variable.
+
+* The :generator:`Green Hills MULTI` generator has been updated:
+
+ - Added support for architecture selection through
+ :variable:`CMAKE_GENERATOR_PLATFORM`:
+ e.g. ``arm``, ``ppc``, and ``86``.
+
+ - Added support for toolset selection through
+ :variable:`CMAKE_GENERATOR_TOOLSET`,
+ e.g. ``comp_201205``, ``comp_201510``, ``comp_201722_beta``.
+
+ - Added support for platform selection through ``GHS_TARGET_PLATFORM``,
+ e.g. ``integrity``, ``linux``, ``standalone``, etc.
+
+ - No longer checks that ``arm`` based compilers are installed but ensures
+ that the correct ``gbuild.exe`` exists.
+
+ - No longer hard-codes ARM files, BSP, toolset, or OS locations.
+
+Command-Line
+------------
+
+* The :manual:`cmake(1)` command gained the ``-S <source_dir>``
+ command line option to specify the location of the source directory.
+ This option can be used independently of ``-B``.
+
+* The :manual:`cmake(1)` command gained the ``-B <build_dir>``
+ command line option to specify the location of the build directory.
+ This option can be used independently of ``-S``.
+
+* The :manual:`cmake(1)` ``-E create_symlink`` command can now be used
+ on Windows.
+
+Commands
+--------
+
+* The :command:`add_custom_command` and :command:`add_custom_target` commands
+ learned to support generator expressions in ``WORKING_DIRECTORY`` options.
+
+* The :command:`add_link_options` command was created to add link
+ options in the current directory.
+
+* The :command:`install(TARGETS)` command learned to install targets
+ created outside the current directory.
+
+* The :command:`link_directories` command gained options to control
+ insertion position.
+
+* The :command:`list(SORT)` command gained options to control the
+ comparison operation used to order the entries.
+
+* The :command:`math` command gained options for hexadecimal.
+
+* The :command:`target_link_directories` command was created to
+ specify link directories for targets and their dependents.
+
+* The :command:`target_link_options` command was created to
+ specify link options for targets and their dependents.
+
+* The :command:`target_link_libraries` command may now be called
+ to modify targets created outside the current directory.
+ See policy :policy:`CMP0079`.
+
+Variables
+---------
+
+* A :variable:`CMAKE_AUTOGEN_VERBOSE` variable was added to optionally
+ increase the verbosity of :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTOUIC`
+ and :prop_tgt:`AUTORCC` from within CMake project code.
+
+* A :variable:`CMAKE_VS_GLOBALS` variable was added to initialize
+ :prop_tgt:`VS_GLOBAL_<variable>` target properties on targets as
+ they are created.
+
+Properties
+----------
+
+* The :prop_tgt:`DEPLOYMENT_ADDITIONAL_FILES` target property was
+ added to tell the :generator:`Visual Studio 9 2008` generator
+ to specify additional files for deployment to WinCE devices
+ for remote debugging.
+
+* The :prop_tgt:`INTERFACE_LINK_DEPENDS` target property was created
+ to specify transitive link dependencies on files.
+
+* The :prop_tgt:`LINK_DEPENDS` target property learned to support
+ :manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+* :prop_tgt:`LINK_DIRECTORIES` and :prop_tgt:`INTERFACE_LINK_DIRECTORIES`
+ target properties were added to collect link directories for a target
+ and its dependents. Use the :command:`target_link_directories` command
+ to set them.
+
+* :prop_tgt:`LINK_OPTIONS` and :prop_tgt:`INTERFACE_LINK_OPTIONS` target
+ properties were added to collect link options for a target and its
+ dependents. Use the :command:`target_link_options` command to set them.
+
+* A :prop_dir:`LINK_OPTIONS` directory property was added to collect
+ link options for targets created under the current directory.
+ Use the :command:`add_link_options` command to set it.
+
+* A :prop_tgt:`STATIC_LIBRARY_OPTIONS` target property was created
+ to specify archiver options to use when creating static libraries.
+
+* A :prop_tgt:`VS_DEBUGGER_COMMAND_ARGUMENTS` target property was created to
+ set the debugging command line arguments with
+ :ref:`Visual Studio Generators` for VS 2010 and above.
+
+* A :prop_tgt:`VS_DEBUGGER_ENVIRONMENT` target property was created to
+ set the debugging environment with
+ :ref:`Visual Studio Generators` for VS 2010 and above.
+
+* The :prop_tgt:`VS_DEBUGGER_COMMAND` and
+ :prop_tgt:`VS_DEBUGGER_WORKING_DIRECTORY` target properties
+ now support generator expressions.
+
+Modules
+-------
+
+* The :module:`FindBoost` module gained a ``Boost_ARCHITECTURE`` option
+ to specify a Boost architecture-specific library filename fragment.
+
+* The :module:`FindCURL` module learned to find debug and release variants
+ separately.
+
+* The :module:`FindMatlab` module gained new components ``ENGINE_LIBRARY`` and
+ ``DATAARRAY_LIBRARY`` to request finding the Matlab C++ Engine and DataArray
+ libraries respectively.
+
+* The :module:`FindMatlab` module now explicitly exports mexFunction in Visual
+ Studio.
+
+* The :module:`FindMatlab` module gained a new ``MCC_COMPILER``
+ component to request finding the Matlab Compiler add-on.
+
+* The :module:`FindPkgConfig` module gained an option to create imported
+ targets in global scope.
+
+* The :module:`FindPkgConfig` module gained support for ``<`` and ``>``
+ operators for version checks in addition to the already supported
+ operators ``>=``, ``<=``, and ``=``.
+
+* Modules :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython`
+ gain capability to control order of resource lookup on macOS (Framework) and
+ Windows (Registry).
+
+* The :module:`FindSubversion` module ``Subversion_WC_INFO`` command
+ gained an ``IGNORE_SVN_FAILURE`` option to suppress failures,
+ e.g. when the source tree is not under Subversion control.
+
+* The :module:`UseSWIG` module learned to manage target property
+ :prop_tgt:`INCLUDE_DIRECTORIES` for ``SWIG`` compilation.
+
+CTest
+-----
+
+* :manual:`ctest(1)` gained a ``--progress`` option to enable a live
+ test progress summary when output goes to a terminal.
+
+CPack
+-----
+
+* The :cpack_gen:`CPack DEB Generator` learned to split debug symbols into
+ a corresponding .ddeb package when ``CPACK_DEBIAN_DEBUGINFO_PACKAGE`` is
+ set.
+
+* The :cpack_gen:`CPack DEB Generator` learned to honor the ``SOURCE_DATE_EPOCH``
+ environment variable when packaging files. This is useful for generating
+ reproducible packages.
+
+* CPack gained a new :cpack_gen:`CPack External Generator` which is used to
+ export the CPack metadata in a format that other software can understand. The
+ intention of this generator is to allow external packaging software to take
+ advantage of CPack's features when it may not be possible to use CPack for
+ the entire packaging process.
+
+Deprecated and Removed Features
+===============================
+
+* An explicit deprecation diagnostic was added for policies ``CMP0055``
+ through ``CMP0063`` (``CMP0054`` and below were already deprecated).
+ The :manual:`cmake-policies(7)` manual explains that the OLD behaviors
+ of all policies are deprecated and that projects should port to the
+ NEW behaviors.
+
+Other Changes
+=============
+
+* The precompiled binaries provided on ``cmake.org`` now include
+ qthelp-format documentation.
+
+* The :command:`option` command now honors an existing normal variable
+ of the same name and does nothing instead of possibly creating a cache
+ entry (or setting its type) and removing the normal variable.
+ See policy :policy:`CMP0077`.
+
+* The :ref:`Makefile Generators` learned to remove custom command and
+ custom target byproducts during ``make clean``.
+
+* The :command:`target_sources` command now interprets relative source file
+ paths as relative to the current source directory. This simplifies
+ incrementally building up a target's sources from subdirectories. The
+ :policy:`CMP0076` policy was added to provide backward compatibility with
+ the old behavior where required.
+
+* The :module:`BundleUtilities` module may no longer be included at configure
+ time. This was always a bug anyway. See policy :policy:`CMP0080`.
+
+* The :module:`UseSWIG` module has changed strategy for target naming.
+ See policy :policy:`CMP0078`.
+
+* The :prop_tgt:`LINK_DIRECTORIES` target property now expects absolute paths.
+ See policy :policy:`CMP0081`.
+
+* The CPack generators have been moved into their own separate section
+ in the documentation, rather than having the documentation in their
+ internal implementation modules.
+ These internal implementation modules are also no longer available
+ to scripts that may have been incorrectly including them, because
+ they should never have been available in the first place.
+
+Updates
+=======
+
+Changes made since CMake 3.13.0 include the following.
+
+3.13.2
+------
+
+* CMake 3.13.0 included a change to pass compiler implicit include
+ directories to the ``moc`` tool for :prop_tgt:`AUTOMOC`. This has
+ been reverted due to regressing existing builds and will need
+ further investigation before being re-introduced in a later release.
+
+3.13.3
+------
+
+* The :generator:`Visual Studio 15 2017` generator has been fixed to work
+ when VS 2019 is installed.
+
+* CMake now checks that at least one of the source or binary directory
+ is specified when running CMake and issues an error if both are missing.
+ This has always been a documented requirement, but the implementation
+ previously accidentally accepted cases in which neither are specified
+ so long as some other argument is given, and silently used the current
+ working directory as the source and build tree.
+
+3.13.4
+------
+
+* The error added by 3.13.3 in cases that neither a source or binary
+ directory is specified has been downgraded to a warning. While this
+ was never intended, documented, nor supported behavior, some projects
+ relied on it. The error has been downgraded to a warning for the
+ remainder of the 3.13.x release series to allow a transition period,
+ but it may become a fatal error again in a later release. Scripts
+ relying on the old behavior can be trivially fixed by specifying
+ the path to the source tree (even if just ``.``) explicitly and
+ continue to work with all versions of CMake.
+
+3.13.5
+------
+
+* In CMake 3.13.0 through 3.13.4, calling :command:`target_link_libraries`
+ to add ``PRIVATE`` dependencies to a static library created in another
+ directory (under policy :policy:`CMP0079` ``NEW`` behavior) would
+ incorrectly propagate usage requirements of those dependencies to
+ dependents that link the static library. This has been fixed.
diff --git a/Help/release/3.14.rst b/Help/release/3.14.rst
new file mode 100644
index 000000000..8a9738c84
--- /dev/null
+++ b/Help/release/3.14.rst
@@ -0,0 +1,438 @@
+CMake 3.14 Release Notes
+************************
+
+.. only:: html
+
+ .. contents::
+
+Changes made since CMake 3.13 include the following.
+
+New Features
+============
+
+Generators
+----------
+
+* The :generator:`Visual Studio 16 2019` generator was added. This is
+ experimental and based on "Visual Studio 2019 Preview 4" because this
+ version of VS has not been released.
+
+ The VS 2019 generator differs from generators for earlier versions
+ in that it does not provide variants that specify the target platform
+ in the generator name. Instead :variable:`CMAKE_GENERATOR_PLATFORM`
+ must be used, e.g. through the ``-A`` command-line option. Furthermore,
+ the default target platform (architecture) is now based on the *host*
+ platform. The VS host toolset selection is now based on the host
+ architecture as well.
+
+* The :generator:`Green Hills MULTI` generator has been updated:
+
+ * Now supports :ref:`Object Libraries`.
+
+ * Now warns on unsupported project types such as shared libraries.
+
+ * Now generates a top-level ``<PROJECT-NAME>.top.gpj`` for each directory
+ calling the :command:`project` command. The top-level project file
+ ``default.gpj`` is no longer created.
+
+ * Now honors target renaming and destination output control properties
+ such as :prop_tgt:`RUNTIME_OUTPUT_DIRECTORY` and :prop_tgt:`OUTPUT_NAME`.
+ This also fixes support for installation rules generated by
+ :command:`install`.
+
+ * Now honors source file properties :prop_sf:`INCLUDE_DIRECTORIES`,
+ :prop_sf:`COMPILE_DEFINITIONS`, and :prop_sf:`COMPILE_OPTIONS`.
+
+ * Now supports Dynamic Download Integrity Applications which did not include
+ Integrate Files via :prop_tgt:`GHS_INTEGRITY_APP` and setting a target
+ link flag of ``-dynamic``.
+
+ * The contents of project files now sorts sources groups and files by name.
+ Set the :prop_tgt:`GHS_NO_SOURCE_GROUP_FILE` target property to ``ON`` to
+ generate a single project file for the target instead of a project file for
+ each source group. Set the :variable:`CMAKE_GHS_NO_SOURCE_GROUP_FILE`
+ variable to enable this for all targets.
+
+File-Based API
+--------------
+
+* A file-based api for clients to get semantic buildsystem information
+ has been added. See the :manual:`cmake-file-api(7)` manual.
+ This is intended to replace the :manual:`cmake-server(7)` mode for IDEs.
+
+Platforms
+---------
+
+* CMake now supports :ref:`Cross Compiling for iOS, tvOS, or watchOS`
+ using simple toolchain files.
+
+Command-Line
+------------
+
+* The :manual:`cmake(1)` :ref:`Build Tool Mode <Build Tool Mode>`
+ (``cmake --build``) gained ``--verbose`` and ``-v`` options to
+ specify verbose build output. Some generators such as Xcode don't
+ support this option currently.
+
+* The :manual:`cmake(1)` ``-E compare_files`` command learned a new
+ ``--ignore-eol`` option to specify that end-of-line differences
+ (e.g. LF vs CRLF) should be ignored when comparing files.
+
+* The :manual:`cmake-gui(1)` dialog gained new ``-S`` and ``-B`` arguments to
+ explicitly specify source and build directories.
+
+Commands
+--------
+
+* The :command:`file` command learned a new sub-command, ``CREATE_LINK``,
+ which can be used to create hard or symbolic links.
+
+* The :command:`file` command learned a new sub-command, ``READ_SYMLINK``,
+ which can be used to determine the path that a symlink points to.
+
+* The :command:`file` command gained a ``SIZE`` mode to get the size
+ of a file on disk.
+
+* The :command:`find_package` command learned to optionally resolve
+ symbolic links in the paths to package configuration files.
+ See the :variable:`CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS` variable.
+
+* The :command:`get_filename_component` command gained new
+ ``LAST_EXT`` and ``NAME_WLE`` variants to work with the
+ extension after the last ``.`` in the name.
+
+* The :command:`if` command gained support for checking if cache variables
+ are defined with the ``DEFINED CACHE{VAR}`` syntax.
+
+* The :command:`install(CODE)` and :command:`install(SCRIPT)` commands
+ learned to support generator expressions. See policy :policy:`CMP0087`.
+
+* The :command:`install(TARGETS)` command learned how to install to an
+ appropriate default directory for a given target type, based on
+ variables from the :module:`GNUInstallDirs` module and built-in defaults,
+ in lieu of a ``DESTINATION`` argument.
+
+* The :command:`install(FILES)` and :command:`install(DIRECTORY)` commands
+ learned a new set of parameters for installing files as a file type,
+ setting the destination based on the appropriate variables from
+ :module:`GNUInstallDirs` and built-in defaults, in lieu of a
+ ``DESTINATION`` argument.
+
+* The :command:`list` operations ``REMOVE_ITEM``, ``REMOVE_DUPLICATES``,
+ ``SORT``, ``REVERSE``, and ``FILTER`` all now accept a non-existent variable
+ as the list since these operations on empty lists is also the empty list.
+
+* The :command:`list` operation ``REMOVE_AT`` now indicates that the given
+ indices are invalid for a non-existent variable or empty list.
+
+* The :command:`try_compile` and :command:`try_run` commands gained a new
+ ``LINK_OPTIONS`` option.
+
+Variables
+---------
+
+* A :variable:`CMAKE_BUILD_RPATH_USE_ORIGIN` variable and corresponding
+ :prop_tgt:`BUILD_RPATH_USE_ORIGIN` target property were added to
+ enable use of relative runtime paths (RPATHs). This helps achieving
+ relocatable and reproducible builds that are invariant of the build
+ directory.
+
+* A :variable:`CMAKE_VS_PLATFORM_NAME_DEFAULT` variable was added for
+ :ref:`Visual Studio Generators` to report their default platform used
+ when :variable:`CMAKE_GENERATOR_PLATFORM` is not set explicitly.
+
+Properties
+----------
+
+* A :prop_gbl:`CMAKE_ROLE` global property was added to allow scripts to
+ determine whether they're running in project mode, script mode,
+ find-package mode, CTest, or CPack.
+
+* The :prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` target property is now supported
+ on shared library, module library, and executable targets. Previously it was
+ only honored on static libraries.
+
+* The :prop_tgt:`EXCLUDE_FROM_ALL` target property was created to override
+ the setting of its directory. A target will now be built as part of "all"
+ if its :prop_tgt:`EXCLUDE_FROM_ALL` property is set to ``OFF``, even if its
+ containing directory is marked as :prop_dir:`EXCLUDE_FROM_ALL`.
+
+* :prop_tgt:`INTERFACE_POSITION_INDEPENDENT_CODE` target property gains the
+ support of :manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+Modules
+-------
+
+* The family of modules to check capabilities (like
+ :module:`CheckCSourceCompiles`) gain capability to manage ``LINK_OPTIONS``.
+
+* A :module:`CheckFortranSourceRuns` module was added to provide a
+ :command:`check_fortran_source_runs` command to check if a Fortran
+ source snippet compiles and runs.
+
+* The :module:`CMakePackageConfigHelpers` module's
+ :command:`write_basic_package_version_file` command gained a new
+ ``ARCH_INDEPENDENT`` option for supporting architecture-independent
+ packages.
+
+* The :module:`ExternalProject` module :command:`ExternalProject_Add` command
+ gained ``LOG_DIR`` and ``LOG_MERGED_STDOUTERR`` options to control logging.
+
+* The :module:`ExternalProject` module :command:`ExternalProject_Add` command
+ gained ``LOG_PATCH`` to optionally log the patch step.
+
+* The :module:`ExternalProject` module :command:`ExternalProject_Add` command
+ learned to apply ``SOURCE_SUBDIR`` when ``BUILD_IN_SOURCE`` is also used.
+ The ``BUILD_COMMAND`` is run in the given ``SOURCE_SUBDIR`` of the
+ ``SOURCE_DIR``.
+
+* The :module:`FetchContent` module gained a new
+ :command:`FetchContent_MakeAvailable` command. It accepts a list of
+ dependency names, which it then iterates over, populating and adding
+ each one to the main build using the canonical pattern. This
+ significantly reduces the amount of boilerplate needed in a project.
+
+* The :module:`FindBISON` module's ``BISON_TARGET`` command now runs ``bison``
+ with :variable:`CMAKE_CURRENT_BINARY_DIR` as the working directory.
+ See policy :policy:`CMP0088`.
+
+* The :module:`FindCURL` module gained support for requesting
+ protocols as package components.
+
+* The :module:`FindFontconfig` module was added to find `fontconfig`_.
+
+* The :module:`FindGDAL` module now provides imported targets.
+
+* The :module:`FindGIF` module now provides imported targets.
+
+* The :module:`FindGit` module now provides an imported target for the
+ Git executable.
+
+* The :module:`FindIce` module learned to find ``slice2confluence``
+ and ``slice2matlab``.
+
+* The :module:`FindLibinput` module was added to find `libinput`_.
+
+* The :module:`FindLibLZMA` module now provides imported targets.
+
+* The :module:`FindMatlab` module gained new options ``R2017b`` and
+ ``R2018a`` to specify the MEX API version to use; these options
+ mirror the new options to the ``mex`` command in MATLAB R2018a.
+ The option ``MX_LIBRARY`` is no longer needed.
+
+* The :module:`FindPostgreSQL` module now provides imported targets.
+
+* The :module:`FindPython`, :module:`FindPython2`, and :module:`FindPython3`
+ modules gained support for ``NumPy`` component.
+
+* The :module:`FindPython2`, :module:`FindPython3`, and :module:`FindPython`
+ modules now support running in script mode by skipping the creation of
+ imported targets and helper functions.
+
+* The :module:`FindSQLite3` module was added to find the SQLite v3.x library.
+
+* The :module:`FindX11` had the following variables renamed in order to match
+ their library names rather than header names. The old variables are provided
+ for compatibility:
+
+ - ``X11_Xxf86misc_INCLUDE_PATH`` instead of ``X11_xf86misc_INCLUDE_PATH``
+ - ``X11_Xxf86misc_LIB`` instead of ``X11_xf86misc_LIB``
+ - ``X11_Xxf86misc_FOUND`` instead of ``X11_xf86misc_FOUND``
+ - ``X11_Xxf86vm_INCLUDE_PATH`` instead of ``X11_xf86vmode_INCLUDE_PATH``
+ - ``X11_Xxf86vm_LIB`` instead of ``X11_xf86vmode_LIB``
+ - ``X11_Xxf86vm_FOUND`` instead of ``X11_xf86vmode_FOUND``
+ - ``X11_xkbfile_INCLUDE_PATH`` instead of ``X11_Xkbfile_INCLUDE_PATH``
+ - ``X11_xkbfile_LIB`` instead of ``X11_Xkbfile_LIB``
+ - ``X11_xkbfile_FOUND`` instead of ``X11_Xkbfile_FOUND``
+ - ``X11_Xtst_INCLUDE_PATH`` instead of ``X11_XTest_INCLUDE_PATH``
+ - ``X11_Xtst_LIB`` instead of ``X11_XTest_LIB``
+ - ``X11_Xtst_FOUND`` instead of ``X11_XTest_FOUND``
+ - ``X11_Xss_INCLUDE_PATH`` instead of ``X11_Xscreensaver_INCLUDE_PATH``
+ - ``X11_Xss_LIB`` instead of ``X11_Xscreensaver_LIB``
+ - ``X11_Xss_FOUND`` instead of ``X11_Xscreensaver_FOUND``
+
+ The following variables are deprecated completely since they were
+ essentially duplicates:
+
+ - ``X11_Xinput_INCLUDE_PATH`` (use ``X11_Xi_INCLUDE_PATH``)
+ - ``X11_Xinput_LIB`` (use ``X11_Xi_LIB``)
+ - ``X11_Xinput_FOUND`` (use ``X11_Xi_FOUND``)
+
+* The :module:`FindX11` now provides ``X11_Xext_INCLUDE_PATH``.
+
+* The :module:`FindX11` now provides imported targets.
+
+* The :module:`UseSWIG` module learned to pass ``-module <module_name>`` to
+ the ``SWIG`` compiler if the file property ``SWIG_MODULE_NAME`` is defined.
+ See policy :policy:`CMP0086`.
+
+* The :module:`UseSWIG` module gained an option to specify
+ ``SWIG`` source file extensions.
+
+.. _`fontconfig`: https://www.freedesktop.org/wiki/Software/fontconfig/
+.. _`libinput`: https://www.freedesktop.org/wiki/Software/libinput/
+
+Generator Expressions
+---------------------
+
+* The ``$<Fortran_COMPILER_ID:...>`` and ``$<Fortran_COMPILER_VERSION:...>``
+ :manual:`generator expressions <cmake-generator-expressions(7)>` were added.
+
+* The ``$<IN_LIST:...>`` generator expression now correctly handles an
+ empty argument. See :policy:`CMP0085` for details.
+
+Autogen
+-------
+
+* The :prop_tgt:`AUTOMOC_EXECUTABLE`, :prop_tgt:`AUTORCC_EXECUTABLE`, and
+ :prop_tgt:`AUTOUIC_EXECUTABLE` target properties were added. They all
+ take a path to an executable and force automoc/autorcc/autouic to use
+ this executable.
+
+ Setting these will also prevent the configure time testing for these
+ executables. This is mainly useful when you build these tools yourself.
+
+* The new variables :variable:`CMAKE_GLOBAL_AUTOGEN_TARGET`,
+ :variable:`CMAKE_GLOBAL_AUTOGEN_TARGET_NAME`,
+ :variable:`CMAKE_GLOBAL_AUTORCC_TARGET` and
+ :variable:`CMAKE_GLOBAL_AUTORCC_TARGET_NAME` control the generation
+ of global ``autogen`` and ``autorcc`` targets.
+
+* A new :variable:`CMAKE_AUTOGEN_ORIGIN_DEPENDS` variable and
+ :prop_tgt:`AUTOGEN_ORIGIN_DEPENDS` target property may be set to enable or
+ disable forwarding of the origin target dependencies to the corresponding
+ ``_autogen`` target.
+
+CTest
+-----
+
+* :manual:`ctest(1)` gained a ``--show-only=json-v1`` option to show the
+ list of tests in a machine-readable JSON format.
+ See the :ref:`Show as JSON Object Model` section of the manual.
+
+* The :command:`ctest_submit` command learned a new ``Done`` part that can be used
+ to inform CDash that a build is complete and that no more parts will be uploaded.
+
+* CTest learned to accept the dashboard server submission URL from a single
+ variable. See the ``SubmitURL`` setting in :manual:`ctest(1)`,
+ the :variable:`CTEST_SUBMIT_URL` variable, and the ``SUBMIT_URL``
+ argument of the :command:`ctest_submit` command.
+
+Deprecated and Removed Features
+===============================
+
+* An explicit deprecation diagnostic was added for policies ``CMP0064``
+ and ``CMP0065`` (``CMP0063`` and below were already deprecated).
+ The :manual:`cmake-policies(7)` manual explains that the OLD behaviors
+ of all policies are deprecated and that projects should port to the
+ NEW behaviors.
+
+* The :generator:`Xcode` generator deprecated support for Xcode
+ versions prior to Xcode 5. Support for those will be dropped in a
+ future version of CMake.
+
+* The :module:`FindQt` module is no longer used by the :command:`find_package`
+ command as a find module. This allows the Qt Project upstream to optionally
+ provide its own ``QtConfig.cmake`` package configuration file and have
+ applications use it via ``find_package(Qt)`` rather than
+ ``find_package(Qt CONFIG)``. See policy :policy:`CMP0084`.
+
+* Support for running CMake on Windows XP and Windows Vista has been dropped.
+ The precompiled Windows binaries provided on ``cmake.org`` now require
+ Windows 7 or higher.
+
+* CTest no longer supports submissions via ``ftp``, ``scp``, ``cp``, and
+ ``xmlrpc``. CDash is the only maintained testing dashboard for CTest,
+ and it only supports submissions over ``http`` and ``https``.
+
+Other Changes
+=============
+
+* Object library linking has been fixed to propagate private link libraries
+ of object libraries to consuming targets.
+
+* Install rules under :command:`add_subdirectory` now interleave with those in
+ the calling directory. See policy :policy:`CMP0082` for details.
+
+* CMake now imposes a maximum recursion limit to prevent a stack overflow on
+ scripts that recurse infinitely. The limit can be adjusted at runtime with
+ :variable:`CMAKE_MAXIMUM_RECURSION_DEPTH`.
+
+* When using cppcheck via the :variable:`CMAKE_<LANG>_CPPCHECK` variable
+ or :prop_tgt:`<LANG>_CPPCHECK` property, the build will now fail if
+ ``cppcheck`` returns non-zero as configured by its command-line options.
+
+* Required link options to manage Position Independent Executable are now
+ added when :prop_tgt:`POSITION_INDEPENDENT_CODE` is set. The project is
+ responsible for using the :module:`CheckPIESupported` module to check for
+ ``PIE`` support to ensure that the :prop_tgt:`POSITION_INDEPENDENT_CODE`
+ target property will be honored at link time for executables. This behavior
+ is controlled by policy :policy:`CMP0083`.
+
+* :ref:`Visual Studio Generators` for VS 2010 and above learned
+ to support the ``VS_DEBUGGER_*`` properties on targets created
+ via :command:`add_custom_target`.
+
+* The :module:`CPack` module no longer defaults to the ``paxr`` value in the
+ :variable:`CPACK_DEBIAN_ARCHIVE_TYPE` variable, because ``dpkg`` has
+ never supported the PAX tar format. The ``paxr`` value will be mapped
+ to ``gnutar`` and a deprecation message emitted.
+
+* CMake no longer issues a warning if a target listed in an
+ :command:`install(TARGETS)` command has its :prop_tgt:`EXCLUDE_FROM_ALL`
+ property set to true.
+
+Updates
+=======
+
+Changes made since CMake 3.14.0 include the following.
+
+3.14.1
+------
+
+* The :module:`FindFontconfig` module added by 3.14.0 accidentally
+ used uppercase ``FONTCONFIG_*`` variable names that do not match
+ our conventions. 3.14.1 revises the module to use ``Fontconfig_*``
+ variable names. This is incompatible with 3.14.0 but since the
+ module is new in the 3.14 series usage should not yet be widespread.
+
+3.14.3
+------
+
+* The :variable:`CMAKE_VS_PLATFORM_NAME_DEFAULT` variable was added
+ to help toolchain files work with the :generator:`Visual Studio 16 2019`
+ generator where the default platform now depends on the host platform.
+
+3.14.4
+------
+
+* In CMake 3.14.0 through 3.14.3, calling :command:`target_link_libraries`
+ to add ``PRIVATE`` dependencies to a static library created in another
+ directory (under policy :policy:`CMP0079` ``NEW`` behavior) would
+ incorrectly propagate usage requirements of those dependencies to
+ dependents that link the static library. This has been fixed.
+ The bug also existed in 3.13.0 through 3.13.4 and is fixed in 3.13.5.
+
+3.14.5
+------
+
+* Entries of the ``CPATH`` environment variable are no longer excluded
+ from explicit use via :command:`include_directories` and
+ :command:`target_include_directories` as they were in CMake 3.14.0
+ through 3.14.4.
+
+3.14.6
+------
+
+* In CMake 3.14.0 through 3.14.5, the :module:`FindBISON` module
+ policy :policy:`CMP0088` ``NEW`` behavior accidentally interpreted
+ a relative path to the ``.y`` input as relative to the build tree
+ directory instead of the source tree directory. This has been fixed.
+
+3.14.7
+------
+
+* In CMake 3.14.0 through 3.14.6, the :prop_dir:`EXCLUDE_FROM_ALL`
+ directory property was regressed from pre-3.14 behavior and caused
+ targets within the directory to be excluded even from its own "all".
+ This has been fixed.
diff --git a/Help/release/3.15.rst b/Help/release/3.15.rst
new file mode 100644
index 000000000..957e6e958
--- /dev/null
+++ b/Help/release/3.15.rst
@@ -0,0 +1,387 @@
+CMake 3.15 Release Notes
+************************
+
+.. only:: html
+
+ .. contents::
+
+Changes made since CMake 3.14 include the following.
+
+New Features
+============
+
+Generators
+----------
+
+* The :generator:`Xcode` generator now supports per-target schemes.
+ See the :variable:`CMAKE_XCODE_GENERATE_SCHEME` variable and
+ :prop_tgt:`XCODE_GENERATE_SCHEME` target property.
+
+* The :generator:`Green Hills MULTI` generator has been updated:
+
+ * It now supports the :command:`add_custom_command` and
+ :command:`add_custom_target` commands.
+
+ * It is now available on Linux.
+
+Languages
+---------
+
+* Preliminary support for the ``Swift`` language was added to the
+ :generator:`Ninja` generator:
+
+ * Use the :envvar:`SWIFTC` environment variable to specify a compiler.
+
+ * The :prop_tgt:`Swift_DEPENDENCIES_FILE` target property and
+ :prop_sf:`Swift_DEPENDENCIES_FILE` source file property were added
+ to customize dependency files.
+
+ * The :prop_tgt:`Swift_MODULE_NAME` target property was added to
+ customize the Swift module name.
+
+ * The :prop_sf:`Swift_DIAGNOSTICS_FILE` source property was added to
+ indicate where to write the serialised Swift diagnostics.
+
+ The Swift support is experimental, not considered stable, and may change
+ in future releases of CMake.
+
+Compilers
+---------
+
+* The ``Clang`` compiler variant on Windows that targets the MSVC ABI
+ but has a GNU-like command line is now supported.
+
+* Support for the Clang-based ARM compiler was added with compiler id
+ ``ARMClang``.
+
+* Support was added for the IAR compiler architectures Renesas RX,
+ RL78, RH850 and Texas Instruments MSP430.
+
+* Support was added for the IAR compilers built for Linux (IAR BuildLx).
+
+Command-Line
+------------
+
+* The :envvar:`CMAKE_GENERATOR` environment variable was added
+ to specify a default generator to use when :manual:`cmake(1)` is
+ run without a ``-G`` option. Additionally, environment variables
+ :envvar:`CMAKE_GENERATOR_PLATFORM`, :envvar:`CMAKE_GENERATOR_TOOLSET`,
+ and :envvar:`CMAKE_GENERATOR_INSTANCE` were created to configure
+ the generator.
+
+* The :manual:`cmake(1)` ``--build`` tool ``--target`` parameter gained support
+ for multiple targets, e.g. ``cmake --build . --target Library1 Library2``.
+ It now also has a short form ``-t`` alias, e.g.
+ ``cmake --build . -t Library1 Library2``.
+
+* The :manual:`cmake(1)` command gained a new ``--install`` option.
+ This may be used after building a project to run installation without
+ using the generated build system or the native build tool.
+
+* The :manual:`cmake(1)` command learned a new CLI option ``--loglevel``.
+
+* The :manual:`cmake(1)` ``-E remove_directory`` command-line tool learned
+ to support removing multiple directories.
+
+* The :manual:`cmake(1)` ``-E tar`` tool has been improved:
+
+ * It now continues adding files to an archive even if some of the files
+ are not readable. This behavior is more consistent with the
+ classic ``tar`` tool.
+
+ * It now parses all flags, and if an invalid flag was provided, a
+ warning is issued.
+
+ * It now displays an error if no action flag was specified, along with a
+ list of possible actions: ``t`` (list), ``c`` (create) or ``x`` (extract).
+
+ * It now supports extracting (``-x``) or listing (``-t``) only specific
+ files or directories.
+
+ * It now supports Zstandard compression with a ``--zstd`` option.
+ Zstandard was designed to give a compression ratio comparable to that
+ of the DEFLATE (zip) algorithm, but faster, especially for decompression.
+
+Commands
+--------
+
+* The :command:`add_custom_command` and :command:`add_custom_target` commands
+ gained a new ``JOB_POOL`` option that works with the :generator:`Ninja`
+ generator to set the pool variable on the build statement.
+
+* The :command:`add_library` command ``ALIAS`` option learned to support
+ import libraries of the ``UNKNOWN`` type.
+
+* The :command:`cmake_parse_arguments` command gained an additional
+ ``<prefix>_KEYWORDS_MISSING_VALUES`` output variable to report
+ keyword arguments that were given by the caller with no values.
+
+* The :command:`execute_process` command gained a ``COMMAND_ECHO`` option
+ and supporting :variable:`CMAKE_EXECUTE_PROCESS_COMMAND_ECHO` variable
+ to enable echoing of the command-line string before execution.
+
+* The :command:`file(INSTALL)` command learned a new argument,
+ ``FOLLOW_SYMLINK_CHAIN``, which can be used to recursively resolve and
+ install symlinks.
+
+* :command:`list` learned new sub-commands:
+ ``PREPEND``, ``POP_FRONT`` and ``POP_BACK``.
+
+* The :command:`message` command learned new types:
+ ``NOTICE``, ``VERBOSE``, ``DEBUG`` and ``TRACE``.
+
+* The :command:`string` learned a new sub-command ``REPEAT``.
+
+Variables
+---------
+
+* The :variable:`CMAKE_CROSSCOMPILING_EMULATOR` variable and corresponding
+ :prop_tgt:`CROSSCOMPILING_EMULATOR` target property learned to support
+ arguments to the emulator.
+
+* The :variable:`CMAKE_FIND_PACKAGE_PREFER_CONFIG` variable was added to tell
+ :command:`find_package` calls to look for a package configuration
+ file first even if a find module is available.
+
+* The :variable:`CMAKE_FRAMEWORK` variable was added to initialize the
+ :prop_tgt:`FRAMEWORK` property on all targets.
+
+* The :variable:`CMAKE_VS_JUST_MY_CODE_DEBUGGING` variable and
+ :prop_tgt:`VS_JUST_MY_CODE_DEBUGGING` target property were added to
+ enable the Just My Code feature of the Visual Studio Debugger when
+ compiling with MSVC cl 19.05 and higher.
+
+* The :variable:`CMAKE_MSVC_RUNTIME_LIBRARY` variable and
+ :prop_tgt:`MSVC_RUNTIME_LIBRARY` target property were introduced to
+ select the runtime library used by compilers targeting the MSVC ABI.
+ See policy :policy:`CMP0091`.
+
+* The :variable:`CMAKE_PROJECT_INCLUDE` and
+ :variable:`CMAKE_PROJECT_INCLUDE_BEFORE` variables were added to allow
+ injection of custom code at the sites of :command:`project` calls
+ without knowing the project name a priori.
+
+Properties
+----------
+
+* The :prop_tgt:`ADDITIONAL_CLEAN_FILES` target property and
+ :prop_dir:`ADDITIONAL_CLEAN_FILES` directory property were added.
+ They allow to register additional files that should be removed during
+ the clean stage.
+
+* The :prop_tgt:`PUBLIC_HEADER` and :prop_tgt:`PRIVATE_HEADER` properties
+ may now be set on :ref:`Interface Libraries`. The headers specified by those
+ properties can be installed using the :command:`install(TARGETS)` command by
+ passing the ``PUBLIC_HEADER`` and ``PRIVATE_HEADER`` arguments respectively.
+
+* The :prop_tgt:`VS_PACKAGE_REFERENCES` target property was added to
+ tell :ref:`Visual Studio Generators` to add references to ``nuget``
+ packages.
+
+* The :prop_tgt:`VS_PROJECT_IMPORT` target property was added to allow
+ managed Visual Studio project files to import external ``.props`` files.
+
+* The :prop_tgt:`VS_NO_SOLUTION_DEPLOY` target property was added to
+ tell :ref:`Visual Studio Generators` whether to deploy an artifact
+ to the WinCE or Windows Phone target device.
+
+Modules
+-------
+
+* The :module:`FindBoost` module was reworked to expose a more consistent
+ user experience between its "Config" and "Module" modes and with other
+ find modules in general.
+
+ * A new imported target ``Boost::headers`` is now defined (same
+ as ``Boost::boost``).
+
+ * New output variables ``Boost_VERSION_MACRO``,
+ ``Boost_VERSION_MAJOR``, ``Boost_VERSION_MINOR``,
+ ``Boost_VERSION_PATCH``, and ``Boost_VERSION_COUNT``
+ were added.
+
+ * The ``QUIET`` argument passed to :command:`find_package` is no
+ longer ignored in config mode. Note that the CMake package shipped with
+ Boost ``1.70.0`` ignores the ``QUIET`` argument passed to
+ :command:`find_package`. This is fixed in the next Boost release.
+
+ * The input switch ``Boost_DETAILED_FAILURE_MSG`` was removed.
+
+ * ``Boost_VERSION`` now reports the version in ``x.y.z``
+ format in module mode. See policy :policy:`CMP0093`.
+
+* The :module:`FindCups` module now provides imported targets.
+
+* The :module:`FindEnvModules` module was added to use Lua- and TCL-based
+ environment modules in :ref:`CTest Scripts <CTest Script>`.
+
+* The :module:`FindGLEW` module now provides an interface more consistent
+ with what upstream GLEW provides in its own CMake package files.
+
+* The :module:`FindPkgConfig` now populates :prop_tgt:`INTERFACE_LINK_OPTIONS`
+ property of imported targets with other (non-library) linker flags.
+
+* The :module:`FindPostgreSQL` module learned to find debug and release
+ variants separately.
+
+* Modules :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython`
+ gained additional lookup strategies and controls, and a new default.
+ See policy :policy:`CMP0094`.
+
+* Modules :module:`FindPython`, :module:`FindPython2` and :module:`FindPython3`
+ gain a new target (respectively ``Python::Module``, ``Python2::Module``
+ and ``Python3::Module``) which can be used to develop Python modules.
+
+* Modules :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython`
+ gain capability to control how virtual environments are handled.
+
+* The :module:`UseSWIG` module learned to manage alternate library names
+ by passing ``-interface <library_name>`` for ``python`` language or
+ ``-dllimport <library_name>`` for ``CSharp`` language to the ``SWIG``
+ compiler.
+
+Generator Expressions
+---------------------
+
+* The :manual:`generator expressions <cmake-generator-expressions(7)>`
+ ``C_COMPILER_ID``, ``CXX_COMPILER_ID``, ``CUDA_COMPILER_ID``,
+ ``Fortran_COMPILER_ID``, ``COMPILE_LANGUAGE``, ``COMPILE_LANG_AND_ID``, and
+ ``PLATFORM_ID`` learned to support matching one value from a comma-separated
+ list.
+
+* The ``$<CUDA_COMPILER_ID:...>`` and ``$<CUDA_COMPILER_VERSION:...>``
+ :manual:`generator expressions <cmake-generator-expressions(7)>` were added.
+
+* The ``$<COMPILE_LANG_AND_ID:...>`` generator expression was introduced to
+ allow specification of compile options for target files based on the
+ :variable:`CMAKE_<LANG>_COMPILER_ID` and :prop_sf:`LANGUAGE` of
+ each source file.
+
+* A ``$<FILTER:list,INCLUDE|EXCLUDE,regex>``
+ :manual:`generator expression <cmake-generator-expressions(7)>`
+ has been added.
+
+* A ``$<REMOVE_DUPLICATES:list>``
+ :manual:`generator expression <cmake-generator-expressions(7)>`
+ has been added.
+
+* The ``$<SHELL_PATH:...>`` :manual:`generator expression
+ <cmake-generator-expressions(7)>` gained support for a list of paths.
+
+* New ``$<TARGET_FILE*>`` :manual:`generator expressions
+ <cmake-generator-expressions(7)>` were added to retrieve the prefix, base
+ name, and suffix of the file names of various artifacts:
+
+ * ``$<TARGET_FILE_PREFIX:...>``
+ * ``$<TARGET_FILE_BASE_NAME:...>``
+ * ``$<TARGET_FILE_SUFFIX:...>``
+ * ``$<TARGET_LINKER_FILE_PREFIX:...>``
+ * ``$<TARGET_LINKER_FILE_BASE_NAME:...>``
+ * ``$<TARGET_LINKER_FILE_SUFFIX:...>``
+ * ``$<TARGET_PDB_FILE_BASE_NAME:...>``
+
+* The ``$<TARGET_OBJECTS:...>`` :manual:`generator expression
+ <cmake-generator-expressions(7)>` is now supported on ``SHARED``,
+ ``STATIC``, ``MODULE`` libraries and executables.
+
+CTest
+-----
+
+* The :command:`ctest_submit` command learned a new option: ``BUILD_ID``.
+ This can be used to store the ID assigned to this build by CDash to a
+ variable.
+
+* The :command:`ctest_update` command learned to honor a new variable:
+ :variable:`CTEST_UPDATE_VERSION_OVERRIDE`. This can be used to specify
+ the current version of your source tree rather than using the update
+ command to discover the current version that is checked out.
+
+CPack
+-----
+
+* The :cpack_gen:`CPack IFW Generator` gained a new
+ :variable:`CPACK_IFW_PACKAGE_STYLE_SHEET` variable to customize the
+ installer stylesheet.
+
+Deprecated and Removed Features
+===============================
+
+* The :manual:`cmake-server(7)` mode has been deprecated and will be
+ removed from a future version of CMake. Please port clients to use
+ the :manual:`cmake-file-api(7)` instead.
+
+* The :prop_dir:`ADDITIONAL_MAKE_CLEAN_FILES` directory property is now
+ deprecated. Use the :prop_dir:`ADDITIONAL_CLEAN_FILES` directory property
+ instead.
+
+* The variable :variable:`CMAKE_AUTOMOC_RELAXED_MODE` is considered
+ deprecated. Support still exists but will be removed in future versions.
+
+* The :command:`export(PACKAGE)` command now does nothing unless
+ enabled via :variable:`CMAKE_EXPORT_PACKAGE_REGISTRY`.
+ See policy :policy:`CMP0090`.
+
+* The :generator:`Xcode` generator now requires at least Xcode 5.
+
+* An explicit deprecation diagnostic was added for policy ``CMP0066``
+ (``CMP0065`` and below were already deprecated).
+ The :manual:`cmake-policies(7)` manual explains that the OLD behaviors
+ of all policies are deprecated and that projects should port to the
+ NEW behaviors.
+
+Other Changes
+=============
+
+* CMake learned how to compile C++14 with the IBM AIX XL compiler
+ and the SunPro compiler and to compile C++20 with the AppleClang compiler.
+
+* With MSVC-like compilers the value of :variable:`CMAKE_<LANG>_FLAGS`
+ no longer contains warning flags like ``/W3`` by default.
+ See policy :policy:`CMP0092`.
+
+* IBM Clang-based XL compilers that define ``__ibmxl__`` now use the
+ compiler id ``XLClang`` instead of ``XL``. See policy :policy:`CMP0089`.
+
+* The :command:`file(REMOVE)` and :command:`file(REMOVE_RECURSE)` commands
+ were changed to ignore empty arguments with a warning instead of treating
+ them as a relative path and removing the contents of the current directory.
+
+Updates
+=======
+
+Changes made since CMake 3.15.0 include the following.
+
+3.15.1
+------
+
+* In CMake 3.15.0 support for the GNU-like ``Clang`` compiler targeting the
+ MSVC ABI implemented :variable:`CMAKE_CXX_STANDARD` values 98 and 11 using
+ the corresponding ``-std=`` flags. However, these modes do not work with
+ the MSVC standard library. Therefore CMake 3.15.1 passes C++14 standard
+ flags even for C++98 and C++11. This is consistent with MSVC itself which
+ always runs in a mode aware of C++14.
+
+* Preliminary Swift support added in 3.15.0 has been updated.
+
+3.15.2
+------
+
+* In CMake 3.15.0 and 3.15.1 the :variable:`CMAKE_FIND_PACKAGE_PREFER_CONFIG`
+ variable caused the :command:`find_package` command to fail on a missing
+ package even without the ``REQUIRED`` option. This has been fixed.
+
+3.15.3
+------
+
+* ``CrayPrgEnv`` compiler wrapper support has been updated for the 19.06
+ release of the Cray Programming Environment for which the default linking
+ mode on XC Cray systems is now dynamic instead of static.
+
+3.15.4
+------
+
+* In CMake 3.15.0 through 3.15.3, the :prop_dir:`EXCLUDE_FROM_ALL`
+ directory property was regressed from pre-3.14 behavior and caused
+ targets within the directory to be excluded even from its own "all".
+ This has been fixed.
+ The bug also existed in 3.14.0 through 3.14.6 and is fixed in 3.14.7.
diff --git a/Help/release/3.16.rst b/Help/release/3.16.rst
new file mode 100644
index 000000000..0d1cc1ed6
--- /dev/null
+++ b/Help/release/3.16.rst
@@ -0,0 +1,279 @@
+CMake 3.16 Release Notes
+************************
+
+.. only:: html
+
+ .. contents::
+
+Changes made since CMake 3.15 include the following.
+
+New Features
+============
+
+Languages
+---------
+
+* CMake learned to support the Objective C (``OBJC``) and Objective C++
+ (``OBJCXX``) languages. They may be enabled via the :command:`project`
+ and :command:`enable_language` commands. When ``OBJC`` or ``OBJCXX``
+ is enabled, source files with the ``.m`` or ``.mm``, respectively,
+ will be compiled as Objective C or C++. Otherwise they will be treated
+ as plain C++ sources as they were before.
+
+Compilers
+---------
+
+* The ``Clang`` compiler is now supported on ``Solaris``.
+
+Platforms
+---------
+
+* On AIX, executables using the :prop_tgt:`ENABLE_EXPORTS` target property
+ now produce a linker import file with a ``.imp`` extension in addition
+ to the executable file. Plugins (created via :command:`add_library` with
+ the ``MODULE`` option) that use :command:`target_link_libraries` to link
+ to the executable for its symbols are now linked using the import file.
+ The :command:`install(TARGETS)` command now installs the import file as
+ an ``ARCHIVE`` artifact.
+
+* On AIX, runtime linking is no longer enabled by default. CMake provides
+ the linker enough information to resolve all symbols up front.
+ One may manually enable runtime linking for shared libraries and/or
+ loadable modules by adding ``-Wl,-G`` to their link flags
+ (e.g. in the :variable:`CMAKE_SHARED_LINKER_FLAGS` or
+ :variable:`CMAKE_MODULE_LINKER_FLAGS` variable).
+ One may manually enable runtime linking for executables by adding
+ ``-Wl,-brtl`` to their link flags (e.g. in the
+ :variable:`CMAKE_EXE_LINKER_FLAGS` variable).
+
+Command-Line
+------------
+
+* :manual:`cmake(1)` ``-E`` now supports ``true`` and ``false`` commands,
+ which do nothing while returning exit codes of 0 and 1, respectively.
+
+* :manual:`cmake(1)` gained a ``--trace-redirect=<file>`` command line
+ option that can be used to redirect ``--trace`` output to a file instead
+ of ``stderr``.
+
+* The :manual:`cmake(1)` ``--loglevel`` command line option has been
+ renamed to ``--log-level`` to make it consistent with the naming of other
+ command line options. The ``--loglevel`` option is still supported to
+ preserve backward compatibility.
+
+Commands
+--------
+
+* The :command:`add_test` command learned the option ``COMMAND_EXPAND_LISTS``
+ which causes lists in the ``COMMAND`` argument to be expanded, including
+ lists created by generator expressions.
+
+* The :command:`file` command learned a new sub-command,
+ ``GET_RUNTIME_DEPENDENCIES``, which allows you to recursively get the list of
+ libraries linked by an executable or library. This sub-command is intended as
+ a replacement for :module:`GetPrerequisites`.
+
+* The :command:`find_file`, :command:`find_library`, :command:`find_path`,
+ :command:`find_package`, and :command:`find_program` commands have learned to
+ check the following variables to control the default behavior for groups of
+ search locations:
+
+ * :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` - Controls the default
+ behavior of searching the :variable:`<PackageName>_ROOT` variables.
+
+ * :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` - Controls the default
+ behavior of searching the CMake-specific environment variables.
+
+ * :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` - Controls the default
+ behavior of searching the standard system environment variables.
+
+ * :variable:`CMAKE_FIND_USE_CMAKE_PATH` - Controls the default behavior of
+ searching the CMake-specific cache variables.
+
+ * :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH` - Controls the default
+ behavior of searching the platform-specific CMake variables.
+
+* The :command:`find_package` command has learned to check the
+ :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variable to control the default
+ behavior of searching the CMake user package registry and to check the
+ :variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` variable to control
+ the default behavior of searching the CMake system package registry.
+
+* The :command:`message` command learned indentation control with the new
+ :variable:`CMAKE_MESSAGE_INDENT` variable.
+
+* The :command:`target_precompile_headers` command was added to specify
+ a list of headers to precompile for faster compilation times.
+
+Variables
+---------
+
+* The :variable:`CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS` variable has been
+ introduced to optionally initialize the
+ :prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` target property.
+
+* The :variable:`CMAKE_ECLIPSE_RESOURCE_ENCODING` variable was added to
+ specify the resource encoding for the the :generator:`Eclipse CDT4` extra
+ generator.
+
+* The :variable:`CMAKE_UNITY_BUILD` variable was added to initialize the
+ :prop_tgt:`UNITY_BUILD` target property to tell generators to batch
+ include source files for faster compilation times.
+
+Properties
+----------
+
+* The :prop_tgt:`BUILD_RPATH` and :prop_tgt:`INSTALL_RPATH` target properties
+ now support :manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+* The :prop_tgt:`INSTALL_REMOVE_ENVIRONMENT_RPATH` target property was
+ added to remove compiler-defined ``RPATH`` entries from a target.
+ This property is initialized by the
+ :variable:`CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH` variable.
+
+* The :prop_tgt:`PRECOMPILE_HEADERS` target property was added to specify
+ a list of headers to precompile for faster compilation times.
+ Set it using the :command:`target_precompile_headers` command.
+
+* The :prop_tgt:`UNITY_BUILD` target property was added to tell
+ generators to batch include source files for faster compilation
+ times.
+
+* The :prop_tgt:`VS_CONFIGURATION_TYPE` target property now supports
+ :manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+* The :prop_tgt:`VS_DPI_AWARE` target property was added to tell
+ :ref:`Visual Studio Generators` to set the ``EnableDpiAwareness``
+ property in ``.vcxproj`` files.
+
+* The :prop_tgt:`XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING` target property was
+ added to tell the :generator:`Xcode` generator to set the value of the
+ ``Allow debugging when using document Versions Browser`` schema option.
+
+Modules
+-------
+
+* The :module:`FindDoxygen` module :command:`doxygen_add_docs` command
+ gained a new ``USE_STAMP_FILE`` option. When this option present,
+ the custom target created by the command will only re-run Doxygen if
+ any of the source files have changed since the last successful run.
+
+* The :module:`FindGnuTLS` module now provides an imported target.
+
+* The :module:`FindPackageHandleStandardArgs` module
+ :command:`find_package_handle_standard_args` command gained
+ a new ``REASON_FAILURE_MESSAGE`` option to specify a message
+ giving the reason for the failure.
+
+* The :module:`FindPkgConfig` module :command:`pkg_search_module` macro
+ now defines a ``<prefix>_MODULE_NAME`` result variable containing the
+ first matching module name.
+
+* The :module:`FindPython3` and :module:`FindPython` modules gained
+ options to control which ``ABIs`` will be searched.
+
+* The :module:`FindPython3`, :module:`FindPython2`, and :module:`FindPython`
+ modules now support direct specification of artifacts via cache entries.
+
+Autogen
+-------
+
+* When using :prop_tgt:`AUTOMOC`, CMake now generates the ``-p`` path prefix
+ option for ``moc``. This ensures that ``moc`` output files are identical
+ on different build setups (given, that the headers compiled by ``moc`` are
+ in an :command:`include directory <target_include_directories>`).
+ Also it ensures that ``moc`` output files will compile correctly when the
+ source and/or build directory is a symbolic link.
+
+ The ``moc`` path prefix generation behavior can be configured by setting
+ the new :variable:`CMAKE_AUTOMOC_PATH_PREFIX` variable and/or
+ :prop_tgt:`AUTOMOC_PATH_PREFIX` target property.
+
+CTest
+-----
+
+* :manual:`ctest(1)` now has the ability to schedule tests based on resource
+ requirements for each test. See :ref:`ctest-resource-allocation` for
+ details.
+
+* A new test property, :prop_test:`SKIP_REGULAR_EXPRESSION`, has been added.
+ This property is similar to :prop_test:`FAIL_REGULAR_EXPRESSION` and
+ :prop_test:`PASS_REGULAR_EXPRESSION`, but with the same meaning as
+ :prop_test:`SKIP_RETURN_CODE`. This is useful, for example, in cases where
+ the user has no control over the return code of the test. For example, in
+ Catch2, the return value is the number of assertion failed, therefore it is
+ impossible to use it for :prop_test:`SKIP_RETURN_CODE`.
+
+CPack
+-----
+
+* :manual:`cpack(1)` learned support for multiple configurations for ``-C``
+ option.
+
+* The :cpack_gen:`CPack DEB Generator` is now able to format generic text
+ (usually used as the description for multiple CPack generators) according
+ to the `Debian Policy Manual`_. See the
+ :variable:`CPACK_PACKAGE_DESCRIPTION_FILE` and
+ :variable:`CPACK_DEBIAN_<COMPONENT>_DESCRIPTION` variables.
+
+* The :cpack_gen:`CPack Archive Generator` learned to generate ``.tar.zst``
+ packages with Zstandard compression.
+
+.. _`Debian Policy Manual`: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description
+
+Deprecated and Removed Features
+===============================
+
+* An explicit deprecation diagnostic was added for policy ``CMP0067``
+ (``CMP0066`` and below were already deprecated).
+ The :manual:`cmake-policies(7)` manual explains that the OLD behaviors
+ of all policies are deprecated and that projects should port to the
+ NEW behaviors.
+
+* The :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` variable has been
+ deprecated. Use the :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variable
+ instead.
+
+* The :module:`GetPrerequisites` module has been deprecated, as it has been
+ superceded by :command:`file(GET_RUNTIME_DEPENDENCIES)`.
+
+* The ``CPACK_INSTALL_SCRIPT`` variable has been deprecated in favor of the
+ new, more accurately named :variable:`CPACK_INSTALL_SCRIPTS` variable.
+
+Other Changes
+=============
+
+* The :manual:`cmake(1)` ``-C <initial-cache>`` option now evaluates the
+ initial cache script with :variable:`CMAKE_SOURCE_DIR` and
+ :variable:`CMAKE_BINARY_DIR` set to the top-level source and build trees.
+
+* The :manual:`cmake(1)` ``-E remove_directory`` command-line tool,
+ when given the path to a symlink to a directory, now removes just
+ the symlink. It no longer removes content of the linked directory.
+
+* The :manual:`ctest(1)` ``--build-makeprogram`` command-line option now
+ specifies the make program used when configuring a project with the
+ :generator:`Ninja` generator or the :ref:`Makefile Generators`.
+
+* The :module:`ExternalProject` module :command:`ExternalProject_Add` command
+ has been updated so that ``GIT_SUBMODULES ""`` initializes no submodules.
+ See policy :policy:`CMP0097`.
+
+* The :module:`FindGTest` module has been updated to recognize
+ MSVC build trees generated by GTest 1.8.1.
+
+* The :command:`project` command no longer strips leading zeros in version
+ components. See policy :policy:`CMP0096`.
+
+* The Qt Compressed Help file is now named ``CMake.qch``, which no longer
+ contains the release version in the file name. When CMake is upgraded
+ in-place, the name and location of this file will remain constant.
+ Tools such as IDEs, help viewers, etc. should now be able to refer to this
+ file at a fixed location that remains valid across CMake upgrades.
+
+* ``RPATH`` entries are properly escaped in the generated CMake scripts
+ used for installation. See policy :policy:`CMP0095`.
+
+* When using :variable:`CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS` on Windows the
+ auto-generated exports are now updated only when the object files
+ providing the symbols are updated.
diff --git a/Help/release/3.2.rst b/Help/release/3.2.rst
index 8abb1ca62..992d44b65 100644
--- a/Help/release/3.2.rst
+++ b/Help/release/3.2.rst
@@ -156,27 +156,27 @@ CTest
CPack
-----
-* The :module:`CPackRPM` module learned options to set per-component
+* The :cpack_gen:`CPack RPM Generator` learned options to set per-component
descriptions and summaries. See the
:variable:`CPACK_RPM_<component>_PACKAGE_DESCRIPTION` and
:variable:`CPACK_RPM_<component>_PACKAGE_SUMMARY` variables.
-* The :module:`CPackRPM` module learned options to specify
+* The :cpack_gen:`CPack RPM Generator` learned options to specify
requirements for pre- and post-install scripts. See the
:variable:`CPACK_RPM_PACKAGE_REQUIRES_PRE` and
:variable:`CPACK_RPM_PACKAGE_REQUIRES_POST` variables.
-* The :module:`CPackRPM` module learned options to specify
+* The :cpack_gen:`CPack RPM Generator` learned options to specify
requirements for pre- and post-uninstall scripts. See the
:variable:`CPACK_RPM_PACKAGE_REQUIRES_PREUN` and
:variable:`CPACK_RPM_PACKAGE_REQUIRES_POSTUN` variables.
-* The :module:`CPackRPM` module learned a new
+* The :cpack_gen:`CPack RPM Generator` learned a new
:variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX` variable to
specify a component-specific value to use instead of
:variable:`CPACK_PACKAGING_INSTALL_PREFIX`.
-* The :module:`CPackRPM` module learned a new
+* The :cpack_gen:`CPack RPM Generator` learned a new
:variable:`CPACK_RPM_RELOCATION_PATHS` variable to
specify multiple relocation prefixes for a single rpm package.
diff --git a/Help/release/3.3.rst b/Help/release/3.3.rst
index 0beb354ac..6657e8df1 100644
--- a/Help/release/3.3.rst
+++ b/Help/release/3.3.rst
@@ -169,26 +169,26 @@ CTest
CPack
-----
-* The :manual:`cpack(1)` ``IFW`` generator and the :module:`CPackIFW`
- module learned to support Qt Framework Installer 2.0 tools.
+* The :cpack_gen:`CPack IFW Generator` learned to support
+ Qt Framework Installer 2.0 tools.
-* The :module:`CPackDeb` module learned a new
+* The :cpack_gen:`CPack DEB Generator` learned a new
:variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS`
variable to specify per-component use of ``dpkg-shlibdeps``.
-* The :module:`CPackDeb` module learned a new
+* The :cpack_gen:`CPack DEB Generator` learned a new
:variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS`
option to specify per-component dependencies.
-* The :module:`CPackRPM` module learned to package symbolic links
+* The :cpack_gen:`CPack RPM Generator` learned to package symbolic links
more cleanly and now supports directory symlinks with recent
``rpmbuild`` versions.
-* The :module:`CPackRPM` module learned a new
+* The :cpack_gen:`CPack RPM Generator` learned a new
:variable:`CPACK_RPM_ADDITIONAL_MAN_DIRS` variable to specify
directories containing man pages for the brp-compress RPM macro.
-* The :module:`CPackRPM` module learned a new
+* The :cpack_gen:`CPack RPM Generator` learned a new
:variable:`CPACK_RPM_<component>_PACKAGE_ARCHITECTURE` variable
to specify a component-specific package architecture.
diff --git a/Help/release/3.4.rst b/Help/release/3.4.rst
index 89c5561d3..943d26716 100644
--- a/Help/release/3.4.rst
+++ b/Help/release/3.4.rst
@@ -66,7 +66,7 @@ Variables
Properties
----------
-* :ref:`Visual Studio Generators` learned to support additonal
+* :ref:`Visual Studio Generators` learned to support additional
target properties to customize projects for NVIDIA Nsight
Tegra Visual Studio Edition:
@@ -197,7 +197,7 @@ CTest
CPack
-----
-* The :module:`CPackDeb` module learned to set package dependencies
+* The :cpack_gen:`CPack DEB Generator` learned to set package dependencies
per component. See variables:
* :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_BREAKS`
@@ -249,11 +249,11 @@ Other Changes
:module:`CheckSymbolExists`, and :module:`FindThreads` modules learned to
work in environments where only CXX is enabled.
-* The :module:`CPackDeb` module now correctly excludes symlinks during package
- checksum calculation.
+* The :cpack_gen:`CPack DEB Generator` now correctly excludes symlinks
+ during package checksum calculation.
-* The :module:`CPackDeb` no longer uses fakeroot and system tar program for
- packaging.
+* The :cpack_gen:`CPack DEB Generator` no longer uses fakeroot and
+ system tar program for packaging.
* The :module:`CPack` module no longer mangles settings with CMake-special
characters when they're used as defaults for other settings. The macro
diff --git a/Help/release/3.5.rst b/Help/release/3.5.rst
index 009eb3c7c..58a5d4eef 100644
--- a/Help/release/3.5.rst
+++ b/Help/release/3.5.rst
@@ -120,31 +120,33 @@ Platforms
CPack
-----
-* The :module:`CPackDMG` module learned new variable to specify AppleScript
- file run to customize appearance of ``DragNDrop`` installer folder,
- including background image setting using supplied PNG or multi-resolution
- TIFF file. See the :variable:`CPACK_DMG_DS_STORE_SETUP_SCRIPT` and
+* The :cpack_gen:`CPack DragNDrop Generator` learned new variable to
+ specify AppleScript file run to customize appearance of ``DragNDrop``
+ installer folder, including background image setting using supplied
+ PNG or multi-resolution TIFF file.
+ See the :variable:`CPACK_DMG_DS_STORE_SETUP_SCRIPT` and
:variable:`CPACK_DMG_BACKGROUND_IMAGE` variables.
-* The :module:`CPackDeb` module learned to set the optional config
+* The :cpack_gen:`CPack DEB Generator` learned to set the optional config
file ``Source`` field using a monolithic or per-component variable.
See :variable:`CPACK_DEBIAN_PACKAGE_SOURCE`.
-* The :module:`CPackDeb` module learned to set Package, Section
+* The :cpack_gen:`CPack DEB Generator` learned to set Package, Section
and Priority control fields per-component.
See variables :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION` and
:variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY`.
-* The :module:`CPack DragNDrop generator <CPackDMG>` learned to add
+* The :cpack_gen:`CPack DragNDrop Generator` learned to add
multi-lingual SLAs to a DMG which is presented to the user when they try to
mount the DMG. See the :variable:`CPACK_DMG_SLA_LANGUAGES` and
:variable:`CPACK_DMG_SLA_DIR` variables for details.
-* The :module:`CPackNSIS` module learned new variables to add bitmaps to the
- installer. See the :variable:`CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP`
+* The :cpack_gen:`CPack NSIS Generator` learned new variables to
+ add bitmaps to the installer.
+ See the :variable:`CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP`
and :variable:`CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP` variables.
-* The :module:`CPackRPM` module learned to set Name and Group
+* The :cpack_gen:`CPack RPM Generator` learned to set Name and Group
control fields per-component.
See :variable:`CPACK_RPM_<component>_PACKAGE_NAME`
and :variable:`CPACK_RPM_<component>_PACKAGE_GROUP`.
diff --git a/Help/release/3.6.rst b/Help/release/3.6.rst
index 144537de0..f0add07ff 100644
--- a/Help/release/3.6.rst
+++ b/Help/release/3.6.rst
@@ -111,7 +111,7 @@ Modules
* The :module:`ExternalProject` module learned to initialize Git submodules
recursively and also to initialize new submodules on updates. Use the
- ``GIT_SUBMODULES`` option to restrict which submodules are initalized and
+ ``GIT_SUBMODULES`` option to restrict which submodules are initialized and
updated.
* The :module:`ExternalProject` module leared the ``DOWNLOAD_NO_EXTRACT 1``
@@ -165,25 +165,25 @@ CTest
CPack
-----
-* The :module:`CPackDeb` module learned how to handle ``$ORIGIN``
+* The :cpack_gen:`CPack DEB Generator` learned how to handle ``$ORIGIN``
in ``CMAKE_INSTALL_RPATH`` when :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS`
is used for dependency auto detection.
-* The :module:`CPackDeb` module learned how to generate ``DEBIAN/shlibs``
- contorl file when package contains shared libraries.
+* The :cpack_gen:`CPack DEB Generator` learned how to generate
+ ``DEBIAN/shlibs`` contorl file when package contains shared libraries.
-* The :module:`CPackDeb` module learned how to generate ``DEBIAN/postinst`` and
- ``DEBIAN/postrm`` files if the package installs libraries in
- ldconfig-controlled locations (e.g. ``/lib/``, ``/usr/lib/``).
+* The :cpack_gen:`CPack DEB Generator` learned how to generate
+ ``DEBIAN/postinst`` and ``DEBIAN/postrm`` files if the package installs
+ libraries in ldconfig-controlled locations (e.g. ``/lib/``, ``/usr/lib/``).
-* The :module:`CPackDeb` module learned how to generate dependencies between
- Debian packages if multi-component setup is used and
+* The :cpack_gen:`CPack DEB Generator` learned how to generate dependencies
+ between Debian packages if multi-component setup is used and
:variable:`CPACK_COMPONENT_<compName>_DEPENDS` variables are set.
For backward compatibility this feature is disabled by default.
See :variable:`CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS`.
-* The :module:`CPackDeb` module learned how to set custom package file names
- including how to generate properly-named Debian packages::
+* The :cpack_gen:`CPack DEB Generator` learned how to set custom package
+ file names including how to generate properly-named Debian packages::
<PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
@@ -191,42 +191,44 @@ CPack
:variable:`CPACK_DEBIAN_FILE_NAME` and
:variable:`CPACK_DEBIAN_<COMPONENT>_FILE_NAME`.
-* The :module:`CPackDeb` module learned how to set the package release number
- (``DebianRevisionNumber`` in package file name when used in combination with
- ``DEB-DEFAULT`` value set by :variable:`CPACK_DEBIAN_FILE_NAME`). See
- :variable:`CPACK_DEBIAN_PACKAGE_RELEASE`.
+* The :cpack_gen:`CPack DEB Generator` learned how to set the package
+ release number (``DebianRevisionNumber`` in package file name when
+ used in combination with ``DEB-DEFAULT`` value set by
+ :variable:`CPACK_DEBIAN_FILE_NAME`).
+ See :variable:`CPACK_DEBIAN_PACKAGE_RELEASE`.
-* The :module:`CPackDeb` module learned how to set the package architecture
- per-component. See :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE`.
+* The :cpack_gen:`CPack DEB Generator` learned how to set the package
+ architecture per-component.
+ See :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE`.
-* The :module:`CPackDMG` module learned a new option to tell the CPack
- ``DragNDrop`` generaor to skip the ``/Applications`` symlink.
+* The :cpack_gen:`CPack DragNDrop Generator` learned a new option to skip the
+ ``/Applications`` symlink.
See the :variable:`CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK` variable.
* The :module:`CPackIFW` module gained a new
:command:`cpack_ifw_update_repository` command to update a QtIFW-specific
repository from a remote repository.
-* The :module:`CPackRPM` module learned how to set RPM ``dist`` tag as part of
- RPM ``Release:`` tag when enabled (mandatory on some Linux distributions for
- e.g. on Fedora).
+* The :cpack_gen:`CPack RPM Generator` learned how to set RPM ``dist`` tag
+ as part of RPM ``Release:`` tag when enabled (mandatory on some Linux
+ distributions for e.g. on Fedora).
See :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`.
-* The :module:`CPackRPM` module learned how to set default values for owning
- user/group and file/directory permissions of package content.
+* The :cpack_gen:`CPack RPM Generator` learned how to set default values
+ for owning user/group and file/directory permissions of package content.
See :variable:`CPACK_RPM_DEFAULT_USER`, :variable:`CPACK_RPM_DEFAULT_GROUP`,
:variable:`CPACK_RPM_DEFAULT_FILE_PERMISSIONS`,
:variable:`CPACK_RPM_DEFAULT_DIR_PERMISSIONS` and their per component
counterparts.
-* The :module:`CPackRPM` module learned how to set user defined package file
- names, how to specify that rpmbuild should decide on file name format as
- well as handling of multiple rpm packages generated by a single user defined
- spec file.
+* The :cpack_gen:`CPack RPM Generator` learned how to set user defined
+ package file names, how to specify that rpmbuild should decide on file
+ name format as well as handling of multiple rpm packages generated by a
+ single user defined spec file.
See :variable:`CPACK_RPM_PACKAGE_NAME` and
:variable:`CPACK_RPM_<component>_PACKAGE_NAME`.
-* The :module:`CPackRPM` module learned how to correctly handle symlinks
+* The :cpack_gen:`CPack RPM Generator` learned how to correctly handle symlinks
that are pointing outside generated packages.
Other
@@ -249,7 +251,7 @@ Deprecated and Removed Features
Users that keep some ``<prefix>/bin`` directories in the ``PATH`` just for
their tools do not necessarily want any supporting ``<prefix>/lib``
directories searched. One may set the ``CMAKE_PREFIX_PATH`` environment
- variable with a :ref:`;-list <CMake Language Lists>` of prefixes that are
+ variable with a :ref:`semicolon-separated list <CMake Language Lists>` of prefixes that are
to be searched.
* The :generator:`Visual Studio 7 .NET 2003` generator is now
@@ -296,7 +298,7 @@ Other Changes
Input variables of the old case will be honored if provided, and output
variables of the old case are always provided.
-* The :module:`CPackRPM` module now supports upper cased component
+* The :cpack_gen:`CPack RPM Generator` now supports upper cased component
names in per component CPackRPM specific variables.
E.g. component named ``foo`` now expects component specific
variable to be ``CPACK_RPM_FOO_PACKAGE_NAME`` while before
diff --git a/Help/release/3.7.rst b/Help/release/3.7.rst
index 4c51af43e..345c056df 100644
--- a/Help/release/3.7.rst
+++ b/Help/release/3.7.rst
@@ -221,13 +221,12 @@ CTest
CPack
-----
-* CPack gained a ``productbuild`` generator on OS X, configured by
- the :module:`CPackProductBuild` module.
+* CPack gained a :cpack_gen:`CPack productbuild Generator` on OS X.
* CPack gained a new :variable:`CPACK_PACKAGE_CHECKSUM` variable to
enable generation of a checksum file for each package file.
-* The :module:`CPackDeb` module learned to support long file names
+* The :cpack_gen:`CPack DEB Generator` learned to support long file names
when archive format is set to GNU tar.
See :variable:`CPACK_DEBIAN_ARCHIVE_TYPE`
@@ -237,35 +236,35 @@ CPack
* The :module:`CPackIFW` module :command:`cpack_ifw_configure_component` and
:command:`cpack_ifw_configure_component_group` commands gained a new
- ``USER_INTERFACES`` option to add a list of additonal pages to the IFW
+ ``USER_INTERFACES`` option to add a list of additional pages to the IFW
installer.
-* The :module:`CPackRPM` module learned to generate debuginfo
+* The :cpack_gen:`CPack RPM Generator` learned to generate debuginfo
packages on demand. See :variable:`CPACK_RPM_DEBUGINFO_PACKAGE`
and its per component version.
-* The :module:`CPackRPM` module learned to generate source rpm
+* The :cpack_gen:`CPack RPM Generator` learned to generate source rpm
(SRPM) packages on demand. See :variable:`CPACK_RPM_PACKAGE_SOURCES`,
:variable:`CPACK_RPM_SOURCE_PKG_BUILD_PARAMS` and
:variable:`CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX`.
-* The CPack NSIS generator now supports
+* The :cpack_gen:`CPack NSIS Generator` now supports
:variable:`CPACK_NSIS_<compName>_INSTALL_DIRECTORY`.
This can be used to set component specific installation directories.
-* The CPack WIX generator now supports
+* The :cpack_gen:`CPack WIX Generator` now supports
:variable:`CPACK_WIX_SKIP_PROGRAM_FOLDER` to allow specification
of a custom absolute installation prefix outside
of the ProgramFiles folders.
-* The CPack WIX generator now supports
+* The :cpack_gen:`CPack WIX Generator` now supports
:variable:`CPACK_COMPONENT_<compName>_DISABLED`.
This can be used to deselect a component from being installed by default.
-* The CPack WIX generator now supports :variable:`CPACK_WIX_PATCH_FILE`
- fragments for Feature elements.
+* The :cpack_gen:`CPack WIX Generator` now supports
+ :variable:`CPACK_WIX_PATCH_FILE` fragments for Feature elements.
-* The CPack WIX generator now supports
+* The :cpack_gen:`CPack WIX Generator` now supports
:variable:`CPACK_WIX_ROOT_FEATURE_TITLE` and
:variable:`CPACK_WIX_ROOT_FEATURE_DESCRIPTION` to allow the specification
of a custom title and description for the root feature element.
diff --git a/Help/release/3.8.rst b/Help/release/3.8.rst
index efb2aa5a7..de51a7bc3 100644
--- a/Help/release/3.8.rst
+++ b/Help/release/3.8.rst
@@ -307,7 +307,7 @@ CPack
option now is deprecated and will be removed in a future version of CMake.
Please use new ``SORTING_PRIORITY`` option instead.
-* The :module:`CPackIFW` module gained new
+* The :cpack_gen:`CPack IFW Generator` gained new
:variable:`CPACK_IFW_PACKAGE_WATERMARK`,
:variable:`CPACK_IFW_PACKAGE_BANNER`,
:variable:`CPACK_IFW_PACKAGE_BACKGROUND`,
@@ -317,26 +317,26 @@ CPack
:variable:`CPACK_IFW_PACKAGE_TITLE_COLOR`
variables to customize a QtIFW installer look.
-* The :module:`CPackProductBuild` module gained options to sign packages.
+* The :cpack_gen:`CPack productbuild Generator` gained options to sign packages.
See the variables :variable:`CPACK_PRODUCTBUILD_IDENTITY_NAME`,
:variable:`CPACK_PRODUCTBUILD_KEYCHAIN_PATH`,
:variable:`CPACK_PKGBUILD_IDENTITY_NAME`, and
:variable:`CPACK_PKGBUILD_KEYCHAIN_PATH`.
-* The :module:`CPackRPM` module learned to omit tags that are not supported by
- provided ``rpmbuild`` tool. If unsupported tags are set they are ignored
- and a developer warning is printed out.
+* The :cpack_gen:`CPack RPM Generator` learned to omit tags that are not
+ supported by provided ``rpmbuild`` tool. If unsupported tags are set they
+ are ignored and a developer warning is printed out.
-* The :module:`CPackRPM` module learned to generate main component package
- which forces generation of a rpm for defined component without component
- suffix in filename and package name.
+* The :cpack_gen:`CPack RPM Generator` learned to generate main component
+ package which forces generation of a rpm for defined component without
+ component suffix in filename and package name.
See :variable:`CPACK_RPM_MAIN_COMPONENT` variable.
-* The :module:`CPackRPM` module learned to generate a single ``debuginfo``
- package on demand even if components packaging is used.
+* The :cpack_gen:`CPack RPM Generator` learned to generate a single
+ ``debuginfo`` package on demand even if components packaging is used.
See :variable:`CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE` variable.
-* The :module:`CPackRPM` module learned to support
+* The :cpack_gen:`CPack RPM Generator` learned to support
multiple directives per file when using
:variable:`CPACK_RPM_USER_FILELIST` variable.
diff --git a/Help/release/3.9.rst b/Help/release/3.9.rst
index 897e268b5..89da62751 100644
--- a/Help/release/3.9.rst
+++ b/Help/release/3.9.rst
@@ -150,7 +150,7 @@ Modules
* The :module:`CMakeFindDependencyMacro` module ``find_dependency`` macro
now forwards all arguments to the underlying :command:`find_package`
call. Existing uses will continue to function as before, but callers can
- now access the full suite of arguments that ``find_package`` accepts.
+ now access the full suite of arguments that :command:`find_package` accepts.
* The :module:`FeatureSummary` module :command:`feature_summary` command now
accepts the new ``DEFAULT_DESCRIPTION`` option that will print the default
@@ -206,7 +206,7 @@ CTest
CPack
-----
-* The :module:`CPackArchive` module learned to modify the filename
+* The :cpack_gen:`CPack Archive Generator` learned to modify the filename
per-component. See the :variable:`CPACK_ARCHIVE_FILE_NAME` variable and
its per-component version :variable:`CPACK_ARCHIVE_<component>_FILE_NAME`.
@@ -220,23 +220,24 @@ CPack
internationalization support for ``DISPLAY_NAME`` and ``DESCRIPTION``
options.
-* The :module:`CPackIFW` module learned the new hint :variable:`CPACK_IFW_ROOT`
- variable for finding the QtIFW tool suite installed in a non-standard place.
+* The :cpack_gen:`CPack IFW Generator` learned the new hint
+ :variable:`CPACK_IFW_ROOT` variable for finding the QtIFW tool suite
+ installed in a non-standard place.
-* The :module:`CPackProductBuild` module gained a new
+* The :cpack_gen:`CPack productbuild Generator` gained a new
:variable:`CPACK_PRODUCTBUILD_RESOURCES_DIR` variable to
specify resources to be copied into the ``Resources``
directory.
-* The :module:`CPackRPM` module learned to modify the ``debuginfo`` package
- name. See the :variable:`CPACK_RPM_DEBUGINFO_FILE_NAME` variable.
+* The :cpack_gen:`CPack RPM Generator` learned to modify the ``debuginfo``
+ package name. See the :variable:`CPACK_RPM_DEBUGINFO_FILE_NAME` variable.
-* The :module:`CPackWIX` module patching system now has the ability to set
- additional attributes. This can be done by specifying attributes with
- the ``CPackWiXFragment`` XML tag after the ``Id`` attribute.
+* The :cpack_gen:`CPack WIX Generator` patching system now has the
+ ability to set additional attributes. This can be done by specifying
+ attributes with the ``CPackWiXFragment`` XML tag after the ``Id`` attribute.
See the :variable:`CPACK_WIX_PATCH_FILE` variable.
-* The CPack WIX generator implemented a new
+* The :cpack_gen:`CPack WIX Generator` implemented a new
:variable:`CPACK_WIX_ROOT_FOLDER_ID` variable which allows
using a custom root folder ID instead of the default
``ProgramFilesFolder`` / ``ProgramFiles64Folder``.
diff --git a/Help/release/index.rst b/Help/release/index.rst
index 6af282cff..0cc3f9726 100644
--- a/Help/release/index.rst
+++ b/Help/release/index.rst
@@ -13,6 +13,13 @@ Releases
.. toctree::
:maxdepth: 1
+ 3.16 <3.16>
+ 3.15 <3.15>
+ 3.14 <3.14>
+ 3.13 <3.13>
+ 3.12 <3.12>
+ 3.11 <3.11>
+ 3.10 <3.10>
3.9 <3.9>
3.8 <3.8>
3.7 <3.7>
diff --git a/Help/variable/APPLE.rst b/Help/variable/APPLE.rst
index 75eecf183..810d5fc3a 100644
--- a/Help/variable/APPLE.rst
+++ b/Help/variable/APPLE.rst
@@ -1,6 +1,5 @@
APPLE
-----
-``True`` if running on OS X.
-
-Set to ``true`` on OS X.
+Set to ``True`` when the target system is an Apple platform
+(macOS, iOS, tvOS or watchOS).
diff --git a/Help/variable/CACHE.rst b/Help/variable/CACHE.rst
new file mode 100644
index 000000000..2cef27efa
--- /dev/null
+++ b/Help/variable/CACHE.rst
@@ -0,0 +1,18 @@
+CACHE
+-----
+
+Operator to read cache variables.
+
+Use the syntax ``$CACHE{VAR}`` to read cache entry ``VAR``.
+See the :ref:`cmake-language(7) variables <CMake Language Variables>`
+documentation for more complete documentation of the interaction of
+normal variables and cache entries.
+
+When evaluating :ref:`Variable References` of the form ``${VAR}``,
+CMake first searches for a normal variable with that name, and if not
+found CMake will search for a cache entry with that name.
+The ``$CACHE{VAR}`` syntax can be used to do direct cache lookup and
+ignore any existing normal variable.
+
+See the :command:`set` and :command:`unset` commands to see how to
+write or remove cache variables.
diff --git a/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION.rst b/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION.rst
index 5ae55d15b..22808e3ed 100644
--- a/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION.rst
+++ b/Help/variable/CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION.rst
@@ -3,7 +3,11 @@ CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION
When :ref:`Cross Compiling for Android with the NDK`, this variable
may be set to specify the version of the toolchain to be used
-as the compiler. The variable must be set to one of these forms:
+as the compiler.
+
+On NDK r19 or above, this variable must be unset or set to ``clang``.
+
+On NDK r18 or below, this variable must be set to one of these forms:
* ``<major>.<minor>``: GCC of specified version
* ``clang<major>.<minor>``: Clang of specified version
diff --git a/Help/variable/CMAKE_ANDROID_STL_TYPE.rst b/Help/variable/CMAKE_ANDROID_STL_TYPE.rst
index cfb76aa04..d174575c8 100644
--- a/Help/variable/CMAKE_ANDROID_STL_TYPE.rst
+++ b/Help/variable/CMAKE_ANDROID_STL_TYPE.rst
@@ -30,7 +30,8 @@ set to specify the STL variant to be used. The value may be one of:
``stlport_shared``
STLport Shared
-The default value is ``gnustl_static``. Note that this default differs from
+The default value is ``gnustl_static`` on NDK versions that provide it
+and otherwise ``c++_static``. Note that this default differs from
the native NDK build system because CMake may be used to build projects for
Android that are not natively implemented for it and use the C++ standard
library.
diff --git a/Help/variable/CMAKE_APPBUNDLE_PATH.rst b/Help/variable/CMAKE_APPBUNDLE_PATH.rst
index 2bc79ac3a..1c7ca51c2 100644
--- a/Help/variable/CMAKE_APPBUNDLE_PATH.rst
+++ b/Help/variable/CMAKE_APPBUNDLE_PATH.rst
@@ -1,6 +1,6 @@
CMAKE_APPBUNDLE_PATH
--------------------
-:ref:`;-list <CMake Language Lists>` of directories specifying a search path
-for OS X application bundles used by the :command:`find_program`, and
+: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.
diff --git a/Help/variable/CMAKE_ARGC.rst b/Help/variable/CMAKE_ARGC.rst
index aec97119a..30db2a2da 100644
--- a/Help/variable/CMAKE_ARGC.rst
+++ b/Help/variable/CMAKE_ARGC.rst
@@ -3,6 +3,6 @@ CMAKE_ARGC
Number of command line arguments passed to CMake in script mode.
-When run in :ref:`-P <CMake Options>` script mode, CMake sets this variable to
-the number of command line arguments. See also :variable:`CMAKE_ARGV0`,
-``1``, ``2`` ...
+When run in :ref:`-P <Script Processing Mode>` script mode, CMake sets this
+variable to the number of command line arguments. See also
+:variable:`CMAKE_ARGV0`, ``1``, ``2`` ...
diff --git a/Help/variable/CMAKE_ARGV0.rst b/Help/variable/CMAKE_ARGV0.rst
index 8b1ecb79e..c4d1c219e 100644
--- a/Help/variable/CMAKE_ARGV0.rst
+++ b/Help/variable/CMAKE_ARGV0.rst
@@ -3,7 +3,7 @@ CMAKE_ARGV0
Command line argument passed to CMake in script mode.
-When run in :ref:`-P <CMake Options>` script mode, CMake sets this variable to
-the first command line argument. It then also sets ``CMAKE_ARGV1``,
+When run in :ref:`-P <Script Processing Mode>` script mode, CMake sets this
+variable to the first command line argument. It then also sets ``CMAKE_ARGV1``,
``CMAKE_ARGV2``, ... and so on, up to the number of command line arguments
given. See also :variable:`CMAKE_ARGC`.
diff --git a/Help/variable/CMAKE_AUTOGEN_ORIGIN_DEPENDS.rst b/Help/variable/CMAKE_AUTOGEN_ORIGIN_DEPENDS.rst
new file mode 100644
index 000000000..1398e7856
--- /dev/null
+++ b/Help/variable/CMAKE_AUTOGEN_ORIGIN_DEPENDS.rst
@@ -0,0 +1,11 @@
+CMAKE_AUTOGEN_ORIGIN_DEPENDS
+----------------------------
+
+Switch for forwarding origin target dependencies to the corresponding
+``_autogen`` targets.
+
+This variable is used to initialize the :prop_tgt:`AUTOGEN_ORIGIN_DEPENDS`
+property on all the targets. See that target property for additional
+information.
+
+By default :variable:`CMAKE_AUTOGEN_ORIGIN_DEPENDS` is ``ON``.
diff --git a/Help/variable/CMAKE_AUTOGEN_PARALLEL.rst b/Help/variable/CMAKE_AUTOGEN_PARALLEL.rst
new file mode 100644
index 000000000..dd9499af3
--- /dev/null
+++ b/Help/variable/CMAKE_AUTOGEN_PARALLEL.rst
@@ -0,0 +1,10 @@
+CMAKE_AUTOGEN_PARALLEL
+----------------------
+
+Number of parallel ``moc`` or ``uic`` processes to start when using
+:prop_tgt:`AUTOMOC` and :prop_tgt:`AUTOUIC`.
+
+This variable is used to initialize the :prop_tgt:`AUTOGEN_PARALLEL` property
+on all the targets. See that target property for additional information.
+
+By default :variable:`CMAKE_AUTOGEN_PARALLEL` is unset.
diff --git a/Help/variable/CMAKE_AUTOGEN_VERBOSE.rst b/Help/variable/CMAKE_AUTOGEN_VERBOSE.rst
new file mode 100644
index 000000000..bad9cf2b3
--- /dev/null
+++ b/Help/variable/CMAKE_AUTOGEN_VERBOSE.rst
@@ -0,0 +1,13 @@
+CMAKE_AUTOGEN_VERBOSE
+---------------------
+
+Sets the verbosity of :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTOUIC` and
+:prop_tgt:`AUTORCC`. A positive integer value or a true boolean value
+lets the ``AUTO*`` generators output additional processing information.
+
+Setting :variable:`CMAKE_AUTOGEN_VERBOSE` has the same effect
+as setting the ``VERBOSE`` environment variable during
+generation (e.g. by calling ``make VERBOSE=1``).
+The extra verbosity is limited to the ``AUTO*`` generators though.
+
+By default :variable:`CMAKE_AUTOGEN_VERBOSE` is unset.
diff --git a/Help/variable/CMAKE_AUTOMOC_COMPILER_PREDEFINES.rst b/Help/variable/CMAKE_AUTOMOC_COMPILER_PREDEFINES.rst
new file mode 100644
index 000000000..7e1c53d06
--- /dev/null
+++ b/Help/variable/CMAKE_AUTOMOC_COMPILER_PREDEFINES.rst
@@ -0,0 +1,8 @@
+CMAKE_AUTOMOC_COMPILER_PREDEFINES
+---------------------------------
+
+This variable is used to initialize the :prop_tgt:`AUTOMOC_COMPILER_PREDEFINES`
+property on all the targets. See that target property for additional
+information.
+
+By default it is ON.
diff --git a/Help/variable/CMAKE_AUTOMOC_MACRO_NAMES.rst b/Help/variable/CMAKE_AUTOMOC_MACRO_NAMES.rst
new file mode 100644
index 000000000..ba1b9d27a
--- /dev/null
+++ b/Help/variable/CMAKE_AUTOMOC_MACRO_NAMES.rst
@@ -0,0 +1,20 @@
+CMAKE_AUTOMOC_MACRO_NAMES
+----------------------------
+
+:ref:`Semicolon-separated list <CMake Language Lists>` list of macro names used by
+:variable:`CMAKE_AUTOMOC` to determine if a C++ file needs to be
+processed by ``moc``.
+
+This variable is used to initialize the :prop_tgt:`AUTOMOC_MACRO_NAMES`
+property on all the targets. See that target property for additional
+information.
+
+The default value is ``Q_OBJECT;Q_GADGET;Q_NAMESPACE``.
+
+Example
+^^^^^^^
+Let CMake know that source files that contain ``CUSTOM_MACRO`` must be ``moc``
+processed as well::
+
+ set(CMAKE_AUTOMOC ON)
+ list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "CUSTOM_MACRO")
diff --git a/Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst b/Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst
new file mode 100644
index 000000000..dca0b0657
--- /dev/null
+++ b/Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst
@@ -0,0 +1,11 @@
+CMAKE_AUTOMOC_PATH_PREFIX
+-------------------------
+
+Whether to generate the ``-p`` path prefix option for ``moc`` on
+:prop_tgt:`AUTOMOC` enabled Qt targets.
+
+This variable is used to initialize the :prop_tgt:`AUTOMOC_PATH_PREFIX`
+property on all the targets. See that target property for additional
+information.
+
+The default value is ``ON``.
diff --git a/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst b/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst
index addc62de4..6c0c61b11 100644
--- a/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst
+++ b/Help/variable/CMAKE_AUTOMOC_RELAXED_MODE.rst
@@ -1,6 +1,8 @@
CMAKE_AUTOMOC_RELAXED_MODE
--------------------------
+.. deprecated:: 3.15
+
Switch between strict and relaxed automoc mode.
By default, :prop_tgt:`AUTOMOC` behaves exactly as described in the
diff --git a/Help/variable/CMAKE_AUTORCC_OPTIONS.rst b/Help/variable/CMAKE_AUTORCC_OPTIONS.rst
index 298cb6be7..815d39d41 100644
--- a/Help/variable/CMAKE_AUTORCC_OPTIONS.rst
+++ b/Help/variable/CMAKE_AUTORCC_OPTIONS.rst
@@ -1,7 +1,16 @@
CMAKE_AUTORCC_OPTIONS
---------------------
-Whether to handle ``rcc`` automatically for Qt targets.
+Additional options for ``rcc`` when using :variable:`CMAKE_AUTORCC`.
This variable is used to initialize the :prop_tgt:`AUTORCC_OPTIONS` property on
all the targets. See that target property for additional information.
+
+EXAMPLE
+^^^^^^^
+
+.. code-block:: cmake
+
+ # ...
+ set(CMAKE_AUTORCC_OPTIONS "--compress;9")
+ # ...
diff --git a/Help/variable/CMAKE_AUTOUIC_OPTIONS.rst b/Help/variable/CMAKE_AUTOUIC_OPTIONS.rst
index 3c9b8c4f5..28fa92f16 100644
--- a/Help/variable/CMAKE_AUTOUIC_OPTIONS.rst
+++ b/Help/variable/CMAKE_AUTOUIC_OPTIONS.rst
@@ -1,7 +1,16 @@
CMAKE_AUTOUIC_OPTIONS
---------------------
-Whether to handle ``uic`` automatically for Qt targets.
+Additional options for ``uic`` when using :variable:`CMAKE_AUTOUIC`.
This variable is used to initialize the :prop_tgt:`AUTOUIC_OPTIONS` property on
all the targets. See that target property for additional information.
+
+EXAMPLE
+^^^^^^^
+
+.. code-block:: cmake
+
+ # ...
+ set_property(CMAKE_AUTOUIC_OPTIONS "--no-protection")
+ # ...
diff --git a/Help/variable/CMAKE_BUILD_RPATH.rst b/Help/variable/CMAKE_BUILD_RPATH.rst
index f20eb418f..f5d53b88c 100644
--- a/Help/variable/CMAKE_BUILD_RPATH.rst
+++ b/Help/variable/CMAKE_BUILD_RPATH.rst
@@ -1,7 +1,7 @@
CMAKE_BUILD_RPATH
-----------------
-A :ref:`;-list <CMake Language Lists>` specifying runtime path (``RPATH``)
+:ref:`Semicolon-separated list <CMake Language Lists>` specifying runtime path (``RPATH``)
entries to add to binaries linked in the build tree (for platforms that
support it). The entries will *not* be used for binaries in the install
tree. See also the :variable:`CMAKE_INSTALL_RPATH` variable.
diff --git a/Help/variable/CMAKE_BUILD_RPATH_USE_ORIGIN.rst b/Help/variable/CMAKE_BUILD_RPATH_USE_ORIGIN.rst
new file mode 100644
index 000000000..e34ede6ad
--- /dev/null
+++ b/Help/variable/CMAKE_BUILD_RPATH_USE_ORIGIN.rst
@@ -0,0 +1,7 @@
+CMAKE_BUILD_RPATH_USE_ORIGIN
+----------------------------
+
+Whether to use relative paths for the build ``RPATH``.
+
+This is used to initialize the :prop_tgt:`BUILD_RPATH_USE_ORIGIN` target
+property for all targets, see that property for more details.
diff --git a/Help/variable/CMAKE_BUILD_TYPE.rst b/Help/variable/CMAKE_BUILD_TYPE.rst
index 2d54d6049..2d35635ac 100644
--- a/Help/variable/CMAKE_BUILD_TYPE.rst
+++ b/Help/variable/CMAKE_BUILD_TYPE.rst
@@ -5,7 +5,7 @@ Specifies the build type on single-configuration generators.
This statically specifies what build type (configuration) will be
built in this build tree. Possible values are empty, ``Debug``, ``Release``,
-``RelWithDebInfo`` and ``MinSizeRel``. This variable is only meaningful to
+``RelWithDebInfo``, ``MinSizeRel``, ... This variable is only meaningful to
single-configuration generators (such as :ref:`Makefile Generators` and
:generator:`Ninja`) i.e. those which choose a single configuration when CMake
runs to generate a build tree as opposed to multi-configuration generators
@@ -13,7 +13,7 @@ which offer selection of the build configuration within the generated build
environment. There are many per-config properties and variables
(usually following clean ``SOME_VAR_<CONFIG>`` order conventions), such as
``CMAKE_C_FLAGS_<CONFIG>``, specified as uppercase:
-``CMAKE_C_FLAGS_[DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL]``. For example,
+``CMAKE_C_FLAGS_[DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL|...]``. For example,
in a build tree configured to build type ``Debug``, CMake will see to
having :variable:`CMAKE_C_FLAGS_DEBUG <CMAKE_<LANG>_FLAGS_DEBUG>` settings get
added to the :variable:`CMAKE_C_FLAGS <CMAKE_<LANG>_FLAGS>` settings. See
diff --git a/Help/variable/CMAKE_CFG_INTDIR.rst b/Help/variable/CMAKE_CFG_INTDIR.rst
index c36599adf..af82f7571 100644
--- a/Help/variable/CMAKE_CFG_INTDIR.rst
+++ b/Help/variable/CMAKE_CFG_INTDIR.rst
@@ -12,7 +12,7 @@ Example values:
::
- $(ConfigurationName) = Visual Studio 8, 9
+ $(ConfigurationName) = Visual Studio 9
$(Configuration) = Visual Studio 10
$(CONFIGURATION) = Xcode
. = Make-based tools
diff --git a/Help/variable/CMAKE_CODEBLOCKS_COMPILER_ID.rst b/Help/variable/CMAKE_CODEBLOCKS_COMPILER_ID.rst
new file mode 100644
index 000000000..ad2709dc3
--- /dev/null
+++ b/Help/variable/CMAKE_CODEBLOCKS_COMPILER_ID.rst
@@ -0,0 +1,13 @@
+CMAKE_CODEBLOCKS_COMPILER_ID
+----------------------------
+
+Change the compiler id in the generated CodeBlocks project files.
+
+CodeBlocks uses its own compiler id string which differs from
+:variable:`CMAKE_<LANG>_COMPILER_ID`. If this variable is left empty,
+CMake tries to recognize the CodeBlocks compiler id automatically.
+Otherwise the specified string is used in the CodeBlocks project file.
+See the CodeBlocks documentation for valid compiler id strings.
+
+Other IDEs like QtCreator that also use the CodeBlocks generator may ignore
+this setting.
diff --git a/Help/variable/CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES.rst b/Help/variable/CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES.rst
new file mode 100644
index 000000000..80ffce3a7
--- /dev/null
+++ b/Help/variable/CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES.rst
@@ -0,0 +1,7 @@
+CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES
+---------------------------------------
+
+Change the way the CodeBlocks generator creates project files.
+
+If this variable evaluates to ``ON`` the generator excludes from
+the project file any files that are located outside the project root.
diff --git a/Help/variable/CMAKE_CPACK_COMMAND.rst b/Help/variable/CMAKE_CPACK_COMMAND.rst
new file mode 100644
index 000000000..559108a1a
--- /dev/null
+++ b/Help/variable/CMAKE_CPACK_COMMAND.rst
@@ -0,0 +1,8 @@
+CMAKE_CPACK_COMMAND
+-------------------
+
+Full path to :manual:`cpack(1)` command installed with CMake.
+
+This is the full path to the CPack executable :manual:`cpack(1)` which is
+useful from custom commands that want to use the :manual:`cmake(1)` ``-E``
+option for portable system commands.
diff --git a/Help/variable/CMAKE_CROSSCOMPILING.rst b/Help/variable/CMAKE_CROSSCOMPILING.rst
index cf9865b61..7e6ec3371 100644
--- a/Help/variable/CMAKE_CROSSCOMPILING.rst
+++ b/Help/variable/CMAKE_CROSSCOMPILING.rst
@@ -1,8 +1,27 @@
CMAKE_CROSSCOMPILING
--------------------
-Is CMake currently cross compiling.
+Intended to indicate whether CMake is cross compiling, but note limitations
+discussed below.
-This variable will be set to true by CMake if CMake is cross
-compiling. Specifically if the build platform is different from the
-target platform.
+This variable will be set to true by CMake if the :variable:`CMAKE_SYSTEM_NAME`
+variable has been set manually (i.e. in a toolchain file or as a cache entry
+from the :manual:`cmake <cmake(1)>` command line). In most cases, manually
+setting :variable:`CMAKE_SYSTEM_NAME` will only be done when cross compiling,
+since it will otherwise be given the same value as
+:variable:`CMAKE_HOST_SYSTEM_NAME` if not manually set, which is correct for
+the non-cross-compiling case. In the event that :variable:`CMAKE_SYSTEM_NAME`
+is manually set to the same value as :variable:`CMAKE_HOST_SYSTEM_NAME`, then
+``CMAKE_CROSSCOMPILING`` will still be set to true.
+
+Another case to be aware of is that builds targeting Apple platforms other than
+macOS are handled differently to other cross compiling scenarios. Rather than
+relying on :variable:`CMAKE_SYSTEM_NAME` to select the target platform, Apple
+device builds use :variable:`CMAKE_OSX_SYSROOT` to select the appropriate SDK,
+which indirectly determines the target platform. Furthermore, when using the
+:generator:`Xcode` generator, developers can switch between device and
+simulator builds at build time rather than having a single
+choice at configure time, so the concept
+of whether the build is cross compiling or not is more complex. Therefore, the
+use of ``CMAKE_CROSSCOMPILING`` is not recommended for projects targeting Apple
+devices.
diff --git a/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst b/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst
index 95d2c7ffc..1d013b7a6 100644
--- a/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst
+++ b/Help/variable/CMAKE_CROSSCOMPILING_EMULATOR.rst
@@ -5,8 +5,12 @@ This variable is only used when :variable:`CMAKE_CROSSCOMPILING` is on. It
should point to a command on the host system that can run executable built
for the target system.
+If this variable contains a :ref:`semicolon-separated list <CMake Language
+Lists>`, then the first value is the command and remaining values are its
+arguments.
+
The command will be used to run :command:`try_run` generated executables,
-which avoids manual population of the TryRunResults.cmake file.
+which avoids manual population of the ``TryRunResults.cmake`` file.
It is also used as the default value for the
:prop_tgt:`CROSSCOMPILING_EMULATOR` target property of executables.
diff --git a/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst b/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst
new file mode 100644
index 000000000..6d34c5ccc
--- /dev/null
+++ b/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst
@@ -0,0 +1,8 @@
+CMAKE_CUDA_HOST_COMPILER
+------------------------
+
+Executable to use when compiling host code when compiling ``CUDA`` language
+files. Maps to the ``nvcc -ccbin`` option. Will only be used by CMake on the first
+configuration to determine a valid host compiler for ``CUDA``. After a valid
+host compiler has been found, this value is read-only. This variable takes
+priority over the :envvar:`CUDAHOSTCXX` environment variable.
diff --git a/Help/variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst b/Help/variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst
new file mode 100644
index 000000000..fc835cd12
--- /dev/null
+++ b/Help/variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst
@@ -0,0 +1,6 @@
+CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS
+---------------------------------
+
+Default value for :prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` target
+property. This variable is used to initialize the property on each target as
+it is created.
diff --git a/Help/variable/CMAKE_CUDA_SEPARABLE_COMPILATION.rst b/Help/variable/CMAKE_CUDA_SEPARABLE_COMPILATION.rst
new file mode 100644
index 000000000..eef92fb16
--- /dev/null
+++ b/Help/variable/CMAKE_CUDA_SEPARABLE_COMPILATION.rst
@@ -0,0 +1,6 @@
+CMAKE_CUDA_SEPARABLE_COMPILATION
+--------------------------------
+
+Default value for :prop_tgt:`CUDA_SEPARABLE_COMPILATION` target property.
+This variable is used to initialize the property on each target as it is
+created.
diff --git a/Help/variable/CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES.rst b/Help/variable/CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES.rst
index 768f571c0..7de50a5a7 100644
--- a/Help/variable/CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES.rst
+++ b/Help/variable/CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES.rst
@@ -2,6 +2,6 @@ CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES
--------------------------------------
When the ``CUDA`` language has been enabled, this provides a
-:ref:`;-list <CMake Language Lists>` of include directories provided
+:ref:`semicolon-separated list <CMake Language Lists>` of include directories provided
by the CUDA Toolkit. The value may be useful for C++ source files
to include CUDA headers.
diff --git a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
index 513276e57..a1fa1fffa 100644
--- a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
+++ b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
@@ -5,10 +5,19 @@ Enables tracing output for target properties.
This variable can be populated with a list of properties to generate
debug output for when evaluating target properties. Currently it can
-only be used when evaluating the :prop_tgt:`INCLUDE_DIRECTORIES`,
-:prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`,
-:prop_tgt:`AUTOUIC_OPTIONS`, :prop_tgt:`SOURCES`, :prop_tgt:`COMPILE_FEATURES`,
-:prop_tgt:`POSITION_INDEPENDENT_CODE` target properties and any other property
-listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other
-``COMPATIBLE_INTERFACE_`` properties. It outputs an origin for each entry in
-the target property. Default is unset.
+only be used when evaluating:
+
+* :prop_tgt:`AUTOUIC_OPTIONS`
+* :prop_tgt:`COMPILE_DEFINITIONS`
+* :prop_tgt:`COMPILE_FEATURES`
+* :prop_tgt:`COMPILE_OPTIONS`
+* :prop_tgt:`INCLUDE_DIRECTORIES`
+* :prop_tgt:`LINK_DIRECTORIES`
+* :prop_tgt:`LINK_OPTIONS`
+* :prop_tgt:`POSITION_INDEPENDENT_CODE`
+* :prop_tgt:`SOURCES`
+
+target properties and any other property listed in
+:prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other
+``COMPATIBLE_INTERFACE_`` properties. It outputs an origin for each entry
+in the target property. Default is unset.
diff --git a/Help/variable/CMAKE_DIRECTORY_LABELS.rst b/Help/variable/CMAKE_DIRECTORY_LABELS.rst
new file mode 100644
index 000000000..2a6c41000
--- /dev/null
+++ b/Help/variable/CMAKE_DIRECTORY_LABELS.rst
@@ -0,0 +1,6 @@
+CMAKE_DIRECTORY_LABELS
+-----------------------
+
+Specify labels for the current directory.
+
+This is used to initialize the :prop_dir:`LABELS` directory property.
diff --git a/Help/variable/CMAKE_DISABLE_PRECOMPILE_HEADERS.rst b/Help/variable/CMAKE_DISABLE_PRECOMPILE_HEADERS.rst
new file mode 100644
index 000000000..7c30edebc
--- /dev/null
+++ b/Help/variable/CMAKE_DISABLE_PRECOMPILE_HEADERS.rst
@@ -0,0 +1,6 @@
+CMAKE_DISABLE_PRECOMPILE_HEADERS
+--------------------------------
+
+Default value for :prop_tgt:`DISABLE_PRECOMPILE_HEADERS` of targets.
+
+By default ``CMAKE_DISABLE_PRECOMPILE_HEADERS`` is ``OFF``.
diff --git a/Help/variable/CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION.rst b/Help/variable/CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION.rst
new file mode 100644
index 000000000..124fefef1
--- /dev/null
+++ b/Help/variable/CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION.rst
@@ -0,0 +1,16 @@
+CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION
+-------------------------------------
+
+Default value for :prop_tgt:`DOTNET_TARGET_FRAMEWORK_VERSION`
+property of targets.
+
+This variable is used to initialize the
+:prop_tgt:`DOTNET_TARGET_FRAMEWORK_VERSION` property on all
+targets. See that target property for additional information.
+
+Setting ``CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION`` may be necessary
+when working with ``C#`` and newer .NET framework versions to
+avoid referencing errors with the ``ALL_BUILD`` CMake target.
+
+This variable is only evaluated for :ref:`Visual Studio Generators`
+VS 2010 and above.
diff --git a/Help/variable/CMAKE_ECLIPSE_RESOURCE_ENCODING.rst b/Help/variable/CMAKE_ECLIPSE_RESOURCE_ENCODING.rst
new file mode 100644
index 000000000..314efe5fe
--- /dev/null
+++ b/Help/variable/CMAKE_ECLIPSE_RESOURCE_ENCODING.rst
@@ -0,0 +1,6 @@
+CMAKE_ECLIPSE_RESOURCE_ENCODING
+-------------------------------
+
+This cache variable tells the :generator:`Eclipse CDT4` project generator
+to set the resource encoding to the given value in generated project files.
+If no value is given, no encoding will be set.
diff --git a/Help/variable/CMAKE_ENABLE_EXPORTS.rst b/Help/variable/CMAKE_ENABLE_EXPORTS.rst
index 9a877e7e6..8848da123 100644
--- a/Help/variable/CMAKE_ENABLE_EXPORTS.rst
+++ b/Help/variable/CMAKE_ENABLE_EXPORTS.rst
@@ -1,22 +1,8 @@
CMAKE_ENABLE_EXPORTS
--------------------
-Specify whether an executable exports symbols for loadable modules.
+Specify whether executables export symbols for loadable modules.
-Normally an executable does not export any symbols because it is the
-final program. It is possible for an executable to export symbols to
-be used by loadable modules. When this property is set to true CMake
-will allow other targets to ``link`` to the executable with the
-:command:`TARGET_LINK_LIBRARIES` command. On all platforms a target-level
-dependency on the executable is created for targets that link to it.
-For DLL platforms an import library will be created for the exported
-symbols and then used for linking. All Windows-based systems
-including Cygwin are DLL platforms. For non-DLL platforms that
-require all symbols to be resolved at link time, such as OS X, the
-module will ``link`` to the executable using a flag like
-``-bundle_loader``. For other non-DLL platforms the link rule is simply
-ignored since the dynamic loader will automatically bind symbols when
-the module is loaded.
-
-This variable is used to initialize the target property
-:prop_tgt:`ENABLE_EXPORTS` for executable targets.
+This variable is used to initialize the :prop_tgt:`ENABLE_EXPORTS` target
+property for executable targets when they are created by calls to the
+:command:`add_executable` command. See the property documentation for details.
diff --git a/Help/variable/CMAKE_EXECUTE_PROCESS_COMMAND_ECHO.rst b/Help/variable/CMAKE_EXECUTE_PROCESS_COMMAND_ECHO.rst
new file mode 100644
index 000000000..76561d82b
--- /dev/null
+++ b/Help/variable/CMAKE_EXECUTE_PROCESS_COMMAND_ECHO.rst
@@ -0,0 +1,6 @@
+CMAKE_EXECUTE_PROCESS_COMMAND_ECHO
+----------------------------------
+
+If this variable is set to ``STDERR``, ``STDOUT`` or ``NONE`` then commands
+in :command:`execute_process` calls will be printed to either stderr or
+stdout or not at all.
diff --git a/Help/variable/CMAKE_EXPORT_COMPILE_COMMANDS.rst b/Help/variable/CMAKE_EXPORT_COMPILE_COMMANDS.rst
index 8776279e8..4548abcc7 100644
--- a/Help/variable/CMAKE_EXPORT_COMPILE_COMMANDS.rst
+++ b/Help/variable/CMAKE_EXPORT_COMPILE_COMMANDS.rst
@@ -28,3 +28,7 @@ form. The format of the JSON file looks like:
.. note::
This option is implemented only by :ref:`Makefile Generators`
and the :generator:`Ninja`. It is ignored on other generators.
+
+ This option currently does not work well in combination with
+ the :prop_tgt:`UNITY_BUILD` target property or the
+ :variable:`CMAKE_UNITY_BUILD` variable.
diff --git a/Help/variable/CMAKE_EXPORT_NO_PACKAGE_REGISTRY.rst b/Help/variable/CMAKE_EXPORT_NO_PACKAGE_REGISTRY.rst
index ee109ba1a..768ed64bf 100644
--- a/Help/variable/CMAKE_EXPORT_NO_PACKAGE_REGISTRY.rst
+++ b/Help/variable/CMAKE_EXPORT_NO_PACKAGE_REGISTRY.rst
@@ -1,11 +1,16 @@
CMAKE_EXPORT_NO_PACKAGE_REGISTRY
--------------------------------
-Disable the :command:`export(PACKAGE)` command.
+Disable the :command:`export(PACKAGE)` command when :policy:`CMP0090`
+is not set to ``NEW``.
In some cases, for example for packaging and for system wide
installations, it is not desirable to write the user package registry.
-If the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable is enabled,
+If the ``CMAKE_EXPORT_NO_PACKAGE_REGISTRY`` variable is enabled,
the :command:`export(PACKAGE)` command will do nothing.
+If :policy:`CMP0090` is set to ``NEW`` this variable does nothing, and the
+:variable:`CMAKE_EXPORT_PACKAGE_REGISTRY` variable controls the behavior
+instead.
+
See also :ref:`Disabling the Package Registry`.
diff --git a/Help/variable/CMAKE_EXPORT_PACKAGE_REGISTRY.rst b/Help/variable/CMAKE_EXPORT_PACKAGE_REGISTRY.rst
new file mode 100644
index 000000000..3476a199c
--- /dev/null
+++ b/Help/variable/CMAKE_EXPORT_PACKAGE_REGISTRY.rst
@@ -0,0 +1,15 @@
+CMAKE_EXPORT_PACKAGE_REGISTRY
+-----------------------------
+
+Enables the :command:`export(PACKAGE)` command when :policy:`CMP0090`
+is set to ``NEW``.
+
+The :command:`export(PACKAGE)` command does nothing by default. In some cases
+it is desirable to write to the user package registry, so the
+``CMAKE_EXPORT_PACKAGE_REGISTRY`` variable may be set to enable it.
+
+If :policy:`CMP0090` is *not* set to ``NEW`` this variable does nothing, and
+the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable controls the behavior
+instead.
+
+See also :ref:`Disabling the Package Registry`.
diff --git a/Help/variable/CMAKE_EXTRA_GENERATOR.rst b/Help/variable/CMAKE_EXTRA_GENERATOR.rst
index 4d513e474..2c9232345 100644
--- a/Help/variable/CMAKE_EXTRA_GENERATOR.rst
+++ b/Help/variable/CMAKE_EXTRA_GENERATOR.rst
@@ -4,7 +4,7 @@ CMAKE_EXTRA_GENERATOR
The extra generator used to build the project. See
:manual:`cmake-generators(7)`.
-When using the Eclipse, CodeBlocks or KDevelop generators, CMake
+When using the Eclipse, CodeBlocks, CodeLite, Kate or Sublime generators, CMake
generates Makefiles (:variable:`CMAKE_GENERATOR`) and additionally project
files for the respective IDE. This IDE project file generator is stored in
``CMAKE_EXTRA_GENERATOR`` (e.g. ``Eclipse CDT4``).
diff --git a/Help/variable/CMAKE_FIND_APPBUNDLE.rst b/Help/variable/CMAKE_FIND_APPBUNDLE.rst
index e0727b547..7a05facf8 100644
--- a/Help/variable/CMAKE_FIND_APPBUNDLE.rst
+++ b/Help/variable/CMAKE_FIND_APPBUNDLE.rst
@@ -2,9 +2,9 @@ CMAKE_FIND_APPBUNDLE
--------------------
This variable affects how ``find_*`` commands choose between
-OS X Application Bundles and unix-style package components.
+macOS Application Bundles and unix-style package components.
-On Darwin or systems supporting OS X Application Bundles, the
+On Darwin or systems supporting macOS Application Bundles, the
``CMAKE_FIND_APPBUNDLE`` variable can be set to empty or
one of the following:
diff --git a/Help/variable/CMAKE_FIND_FRAMEWORK.rst b/Help/variable/CMAKE_FIND_FRAMEWORK.rst
index 790694ac5..4d5078fb6 100644
--- a/Help/variable/CMAKE_FIND_FRAMEWORK.rst
+++ b/Help/variable/CMAKE_FIND_FRAMEWORK.rst
@@ -2,9 +2,9 @@ CMAKE_FIND_FRAMEWORK
--------------------
This variable affects how ``find_*`` commands choose between
-OS X Frameworks and unix-style package components.
+macOS Frameworks and unix-style package components.
-On Darwin or systems supporting OS X Frameworks, the
+On Darwin or systems supporting macOS Frameworks, the
``CMAKE_FIND_FRAMEWORK`` variable can be set to empty or
one of the following:
diff --git a/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst b/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst
index c49d2641b..789dc99aa 100644
--- a/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst
+++ b/Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst
@@ -1,15 +1,19 @@
CMAKE_FIND_NO_INSTALL_PREFIX
----------------------------
-Ignore the :variable:`CMAKE_INSTALL_PREFIX` when searching for assets.
+Exclude the values of the :variable:`CMAKE_INSTALL_PREFIX` and
+:variable:`CMAKE_STAGING_PREFIX` variables from
+:variable:`CMAKE_SYSTEM_PREFIX_PATH`. CMake adds these project-destination
+prefixes to :variable:`CMAKE_SYSTEM_PREFIX_PATH` by default in order to
+support building a series of dependent packages and installing them into
+a common prefix. Set ``CMAKE_FIND_NO_INSTALL_PREFIX`` to ``TRUE``
+to suppress this behavior.
-CMake adds the :variable:`CMAKE_INSTALL_PREFIX` and the
-:variable:`CMAKE_STAGING_PREFIX` variable to the
-:variable:`CMAKE_SYSTEM_PREFIX_PATH` by default. This variable may be set
-on the command line to control that behavior.
+The :variable:`CMAKE_SYSTEM_PREFIX_PATH` is initialized on the first call to a
+:command:`project` or :command:`enable_language` command. Therefore one must
+set ``CMAKE_FIND_NO_INSTALL_PREFIX`` before this in order to take effect. A
+user may set the variable as a cache entry on the command line to achieve this.
-Set ``CMAKE_FIND_NO_INSTALL_PREFIX`` to ``TRUE`` to tell
-:command:`find_package` not to search in the :variable:`CMAKE_INSTALL_PREFIX`
-or :variable:`CMAKE_STAGING_PREFIX` by default. Note that the
-prefix may still be searched for other reasons, such as being the same prefix
-as the CMake installation, or for being a built-in system prefix.
+Note that the prefix(es) may still be searched for other reasons, such as being
+the same prefix as the CMake installation, or for being a built-in system
+prefix.
diff --git a/Help/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY.rst b/Help/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY.rst
index 90584710e..4ee9d8b81 100644
--- a/Help/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY.rst
+++ b/Help/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY.rst
@@ -1,12 +1,23 @@
CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
--------------------------------------
-Skip :ref:`User Package Registry` in :command:`find_package` calls.
+.. deprecated:: 3.16
+
+ Use the :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variable instead.
+
+By default this variable is not set. If neither
+:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` nor
+``CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`` is set, then
+:command:`find_package()` will use the :ref:`User Package Registry`
+unless the ``NO_CMAKE_PACKAGE_REGISTRY`` option is provided.
+
+``CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`` is ignored if
+:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` is set.
In some cases, for example to locate only system wide installations, it
is not desirable to use the :ref:`User Package Registry` when searching
for packages. If the :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`
-variable is enabled, all the :command:`find_package` commands will skip
+variable is ``TRUE``, all the :command:`find_package` commands will skip
the :ref:`User Package Registry` as if they were called with the
``NO_CMAKE_PACKAGE_REGISTRY`` argument.
diff --git a/Help/variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY.rst b/Help/variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY.rst
index 44588b17a..107c183eb 100644
--- a/Help/variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY.rst
+++ b/Help/variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY.rst
@@ -1,12 +1,23 @@
CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
---------------------------------------------
-Skip :ref:`System Package Registry` in :command:`find_package` calls.
+.. deprecated:: 3.16
+
+ Use the :variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` variable instead.
+
+By default this variable is not set. If neither
+:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` nor
+``CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY`` is set, then
+:command:`find_package()` will use the :ref:`System Package Registry`
+unless the ``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` option is provided.
+
+``CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY`` is ignored if
+:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` is set.
In some cases, it is not desirable to use the
:ref:`System Package Registry` when searching for packages. If the
:variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` variable is
-enabled, all the :command:`find_package` commands will skip
+``TRUE``, all the :command:`find_package` commands will skip
the :ref:`System Package Registry` as if they were called with the
``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` argument.
diff --git a/Help/variable/CMAKE_FIND_PACKAGE_PREFER_CONFIG.rst b/Help/variable/CMAKE_FIND_PACKAGE_PREFER_CONFIG.rst
new file mode 100644
index 000000000..db658a1e0
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_PACKAGE_PREFER_CONFIG.rst
@@ -0,0 +1,27 @@
+CMAKE_FIND_PACKAGE_PREFER_CONFIG
+---------------------------------
+
+Tell :command:`find_package` to try "Config" mode before "Module" mode if no
+mode was specified.
+
+The command :command:`find_package` operates without an explicit mode when
+the reduced signature is used without the ``MODULE`` option. In this case,
+by default, CMake first tries Module mode by searching for a
+``Find<pkg>.cmake`` module. If it fails, CMake then searches for the package
+using Config mode.
+
+Set ``CMAKE_FIND_PACKAGE_PREFER_CONFIG`` to ``TRUE`` to tell
+:command:`find_package` to first search using Config mode before falling back
+to Module mode.
+
+This variable may be useful when a developer has compiled a custom version of
+a common library and wishes to link it to a dependent project. If this
+variable is set to ``TRUE``, it would prevent a dependent project's call
+to :command:`find_package` from selecting the default library located by the
+system's ``Find<pkg>.cmake`` module before finding the developer's custom
+built library.
+
+Once this variable is set, it is the responsibility of the exported
+``<pkg>Config.cmake`` files to provide the same result variables as the
+``Find<pkg>.cmake`` modules so that dependent projects can use them
+interchangeably.
diff --git a/Help/variable/CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS.rst b/Help/variable/CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS.rst
new file mode 100644
index 000000000..dfbde2035
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS.rst
@@ -0,0 +1,10 @@
+CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS
+-----------------------------------
+
+Set to ``TRUE`` to tell :command:`find_package` calls to resolve symbolic
+links in the value of ``<PackageName>_DIR``.
+
+This is helpful in use cases where the package search path points at a
+proxy directory in which symlinks to the real package locations appear.
+This is not enabled by default because there are also common use cases
+in which the symlinks should be preserved.
diff --git a/Help/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst b/Help/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst
index f1116bb62..5c4f23a4a 100644
--- a/Help/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst
+++ b/Help/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE.rst
@@ -17,3 +17,6 @@ Set ``CMAKE_FIND_PACKAGE_WARN_NO_MODULE`` to ``TRUE`` to tell
:command:`find_package` to warn when it implicitly assumes Config mode. This
helps developers enforce use of an explicit mode in all calls to
:command:`find_package` within a project.
+
+This variable has no effect if :variable:`CMAKE_FIND_PACKAGE_PREFER_CONFIG` is
+set to ``TRUE``.
diff --git a/Help/variable/CMAKE_FIND_ROOT_PATH.rst b/Help/variable/CMAKE_FIND_ROOT_PATH.rst
index ba2cf313e..6172c56ae 100644
--- a/Help/variable/CMAKE_FIND_ROOT_PATH.rst
+++ b/Help/variable/CMAKE_FIND_ROOT_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_FIND_ROOT_PATH
--------------------
-:ref:`;-list <CMake Language Lists>` of root paths to search on the filesystem.
+:ref:`Semicolon-separated list <CMake Language Lists>` of root paths to search on the filesystem.
This variable is most useful when cross-compiling. CMake uses the paths in
this list as alternative roots to find filesystem items with
diff --git a/Help/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH.rst b/Help/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH.rst
new file mode 100644
index 000000000..957e956f3
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH.rst
@@ -0,0 +1,24 @@
+CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH
+-------------------------------------
+
+Controls the default behavior of the following commands for whether or not to
+search paths provided by cmake-specific environment variables:
+
+* :command:`find_program`
+* :command:`find_library`
+* :command:`find_file`
+* :command:`find_path`
+* :command:`find_package`
+
+This is useful in cross-compiling environments.
+
+By default this variable is not set, which is equivalent to it having
+a value of ``TRUE``. Explicit options given to the above commands
+take precedence over this variable.
+
+See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
+:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
+:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
+:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY`,
+:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
+and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
diff --git a/Help/variable/CMAKE_FIND_USE_CMAKE_PATH.rst b/Help/variable/CMAKE_FIND_USE_CMAKE_PATH.rst
new file mode 100644
index 000000000..d2bdb09b5
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_USE_CMAKE_PATH.rst
@@ -0,0 +1,24 @@
+CMAKE_FIND_USE_CMAKE_PATH
+-------------------------
+
+Controls the default behavior of the following commands for whether or not to
+search paths provided by cmake-specific cache variables:
+
+* :command:`find_program`
+* :command:`find_library`
+* :command:`find_file`
+* :command:`find_path`
+* :command:`find_package`
+
+This is useful in cross-compiling environments.
+
+By default this variable is not set, which is equivalent to it having
+a value of ``TRUE``. Explicit options given to the above commands
+take precedence over this variable.
+
+See also the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
+:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
+:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
+:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY`,
+:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
+and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
diff --git a/Help/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.rst b/Help/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.rst
new file mode 100644
index 000000000..b99081d3e
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.rst
@@ -0,0 +1,24 @@
+CMAKE_FIND_USE_CMAKE_SYSTEM_PATH
+--------------------------------
+
+Controls the default behavior of the following commands for whether or not to
+search paths provided by platform-specific cmake variables:
+
+* :command:`find_program`
+* :command:`find_library`
+* :command:`find_file`
+* :command:`find_path`
+* :command:`find_package`
+
+This is useful in cross-compiling environments.
+
+By default this variable is not set, which is equivalent to it having
+a value of ``TRUE``. Explicit options given to the above commands
+take precedence over this variable.
+
+See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
+:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
+:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
+:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY`,
+:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
+and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
diff --git a/Help/variable/CMAKE_FIND_USE_PACKAGE_REGISTRY.rst b/Help/variable/CMAKE_FIND_USE_PACKAGE_REGISTRY.rst
new file mode 100644
index 000000000..7c7ca3618
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_USE_PACKAGE_REGISTRY.rst
@@ -0,0 +1,30 @@
+CMAKE_FIND_USE_PACKAGE_REGISTRY
+-------------------------------
+
+Controls the default behavior of the :command:`find_package` command for
+whether or not to search paths provided by the :ref:`User Package Registry`.
+
+By default this variable is not set and the behavior will fall back
+to that determined by the deprecated
+:variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` variable. If that is
+also not set, then :command:`find_package` will use the
+:ref:`User Package Registry` unless the ``NO_CMAKE_PACKAGE_REGISTRY`` option
+is provided.
+
+This variable takes precedence over
+:variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` when both are set.
+
+In some cases, for example to locate only system wide installations, it
+is not desirable to use the :ref:`User Package Registry` when searching
+for packages. If the :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`
+variable is ``FALSE``, all the :command:`find_package` commands will skip
+the :ref:`User Package Registry` as if they were called with the
+``NO_CMAKE_PACKAGE_REGISTRY`` argument.
+
+See also :ref:`Disabling the Package Registry` and the
+:variable:`CMAKE_FIND_USE_CMAKE_PATH`,
+:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
+:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
+:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
+:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY`,
+and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
diff --git a/Help/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH.rst b/Help/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH.rst
new file mode 100644
index 000000000..e7f5b0ff8
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH.rst
@@ -0,0 +1,22 @@
+CMAKE_FIND_USE_PACKAGE_ROOT_PATH
+--------------------------------
+
+Controls the default behavior of the following commands for whether or not to
+search paths provided by :variable:`<PackageName>_ROOT` variables:
+
+* :command:`find_program`
+* :command:`find_library`
+* :command:`find_file`
+* :command:`find_path`
+* :command:`find_package`
+
+By default this variable is not set, which is equivalent to it having
+a value of ``TRUE``. Explicit options given to the above commands
+take precedence over this variable.
+
+See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
+:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
+:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
+:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
+:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY`,
+and :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variables.
diff --git a/Help/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH.rst b/Help/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH.rst
new file mode 100644
index 000000000..fbaba5a73
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH.rst
@@ -0,0 +1,24 @@
+CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH
+--------------------------------------
+
+Controls the default behavior of the following commands for whether or not to
+search paths provided by standard system environment variables:
+
+* :command:`find_program`
+* :command:`find_library`
+* :command:`find_file`
+* :command:`find_path`
+* :command:`find_package`
+
+This is useful in cross-compiling environments.
+
+By default this variable is not set, which is equivalent to it having
+a value of ``TRUE``. Explicit options given to the above commands
+take precedence over this variable.
+
+See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
+:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
+:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
+:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
+:variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH`,
+and :variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` variables.
diff --git a/Help/variable/CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY.rst b/Help/variable/CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY.rst
new file mode 100644
index 000000000..cb4eec5d1
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY.rst
@@ -0,0 +1,31 @@
+CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY
+--------------------------------------
+
+Controls searching the :ref:`System Package Registry` by the
+:command:`find_package` command.
+
+By default this variable is not set and the behavior will fall back
+to that determined by the deprecated
+:variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` variable.
+If that is also not set, then :command:`find_package()` will use the
+:ref:`System Package Registry` unless the ``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY``
+option is provided.
+
+This variable takes precedence over
+:variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` when both are set.
+
+In some cases, for example to locate only user specific installations, it
+is not desirable to use the :ref:`System Package Registry` when searching
+for packages. If the ``CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY``
+variable is ``FALSE``, all the :command:`find_package` commands will skip
+the :ref:`System Package Registry` as if they were called with the
+``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` argument.
+
+See also :ref:`Disabling the Package Registry`.
+
+See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
+:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
+:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
+:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
+:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
+and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
diff --git a/Help/variable/CMAKE_FOLDER.rst b/Help/variable/CMAKE_FOLDER.rst
new file mode 100644
index 000000000..50a2b88d7
--- /dev/null
+++ b/Help/variable/CMAKE_FOLDER.rst
@@ -0,0 +1,7 @@
+CMAKE_FOLDER
+------------
+
+Set the folder name. Use to organize targets in an IDE.
+
+This variable is used to initialize the :prop_tgt:`FOLDER` property on all the
+targets. See that target property for additional information.
diff --git a/Help/variable/CMAKE_FRAMEWORK.rst b/Help/variable/CMAKE_FRAMEWORK.rst
new file mode 100644
index 000000000..591041c8b
--- /dev/null
+++ b/Help/variable/CMAKE_FRAMEWORK.rst
@@ -0,0 +1,7 @@
+CMAKE_FRAMEWORK
+---------------
+
+Default value for :prop_tgt:`FRAMEWORK` of targets.
+
+This variable is used to initialize the :prop_tgt:`FRAMEWORK` property on
+all the targets. See that target property for additional information.
diff --git a/Help/variable/CMAKE_FRAMEWORK_PATH.rst b/Help/variable/CMAKE_FRAMEWORK_PATH.rst
index 5ff08e679..13ade4e5f 100644
--- a/Help/variable/CMAKE_FRAMEWORK_PATH.rst
+++ b/Help/variable/CMAKE_FRAMEWORK_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_FRAMEWORK_PATH
--------------------
-:ref:`;-list <CMake Language Lists>` of directories specifying a search path
-for OS X frameworks used by the :command:`find_library`,
+:ref:`Semicolon-separated list <CMake Language Lists>` of directories specifying a search path
+for macOS frameworks used by the :command:`find_library`,
:command:`find_package`, :command:`find_path`, and :command:`find_file`
commands.
diff --git a/Help/variable/CMAKE_GENERATOR.rst b/Help/variable/CMAKE_GENERATOR.rst
index cce04c136..ec52cd4d8 100644
--- a/Help/variable/CMAKE_GENERATOR.rst
+++ b/Help/variable/CMAKE_GENERATOR.rst
@@ -5,3 +5,8 @@ The generator used to build the project. See :manual:`cmake-generators(7)`.
The name of the generator that is being used to generate the build
files. (e.g. ``Unix Makefiles``, ``Ninja``, etc.)
+
+The value of this variable should never be modified by project code.
+A generator may be selected via the :manual:`cmake(1)` ``-G`` option,
+interactively in :manual:`cmake-gui(1)`, or via the :envvar:`CMAKE_GENERATOR`
+environment variable.
diff --git a/Help/variable/CMAKE_GENERATOR_INSTANCE.rst b/Help/variable/CMAKE_GENERATOR_INSTANCE.rst
new file mode 100644
index 000000000..3657ed4ff
--- /dev/null
+++ b/Help/variable/CMAKE_GENERATOR_INSTANCE.rst
@@ -0,0 +1,25 @@
+CMAKE_GENERATOR_INSTANCE
+------------------------
+
+Generator-specific instance specification provided by user.
+
+Some CMake generators support selection of an instance of the native build
+system when multiple instances are available. If the user specifies an
+instance (e.g. by setting this cache entry or via the
+:envvar:`CMAKE_GENERATOR_INSTANCE` environment variable), or after a default
+instance is chosen when a build tree is first configured, the value will be
+available in this variable.
+
+The value of this variable should never be modified by project code.
+A toolchain file specified by the :variable:`CMAKE_TOOLCHAIN_FILE`
+variable may initialize ``CMAKE_GENERATOR_INSTANCE`` as a cache entry.
+Once a given build tree has been initialized with a particular value
+for this variable, changing the value has undefined behavior.
+
+Instance specification is supported only on specific generators:
+
+* For the :generator:`Visual Studio 15 2017` generator (and above)
+ this specifies the absolute path to the VS installation directory
+ of the selected VS instance.
+
+See native build system documentation for allowed instance values.
diff --git a/Help/variable/CMAKE_GENERATOR_PLATFORM.rst b/Help/variable/CMAKE_GENERATOR_PLATFORM.rst
index 50412ffff..2c115a3ab 100644
--- a/Help/variable/CMAKE_GENERATOR_PLATFORM.rst
+++ b/Help/variable/CMAKE_GENERATOR_PLATFORM.rst
@@ -6,7 +6,8 @@ Generator-specific target platform specification provided by user.
Some CMake generators support a target platform name to be given
to the native build system to choose a compiler toolchain.
If the user specifies a platform name (e.g. via the :manual:`cmake(1)` ``-A``
-option) the value will be available in this variable.
+option or via the :envvar:`CMAKE_GENERATOR_PLATFORM` environment variable)
+the value will be available in this variable.
The value of this variable should never be modified by project code.
A toolchain file specified by the :variable:`CMAKE_TOOLCHAIN_FILE`
@@ -19,6 +20,8 @@ Platform specification is supported only on specific generators:
* For :ref:`Visual Studio Generators` with VS 2005 and above this
specifies the target architecture.
+* For :generator:`Green Hills MULTI` this specifies the target architecture.
+
See native build system documentation for allowed platform names.
Visual Studio Platform Selection
diff --git a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst
index 11c37d746..222824f6a 100644
--- a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst
+++ b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst
@@ -5,7 +5,8 @@ Native build system toolset specification provided by user.
Some CMake generators support a toolset specification to tell the
native build system how to choose a compiler. If the user specifies
-a toolset (e.g. via the :manual:`cmake(1)` ``-T`` option) the value
+a toolset (e.g. via the :manual:`cmake(1)` ``-T`` option or via
+the :envvar:`CMAKE_GENERATOR_TOOLSET` environment variable) the value
will be available in this variable.
The value of this variable should never be modified by project code.
@@ -18,6 +19,7 @@ Toolset specification is supported only on specific generators:
* :ref:`Visual Studio Generators` for VS 2010 and above
* The :generator:`Xcode` generator for Xcode 3.0 and above
+* The :generator:`Green Hills MULTI` generator
See native build system documentation for allowed toolset names.
@@ -38,13 +40,21 @@ The ``key=value`` pairs form a comma-separated list of options to
specify generator-specific details of the toolset selection.
Supported pairs are:
-``cuda=<version>``
- Specify the CUDA toolkit version to use. Supported by VS 2010
- and above with the CUDA toolkit VS integration installed.
- See the :variable:`CMAKE_VS_PLATFORM_TOOLSET_CUDA` variable.
+``cuda=<version>|<path>``
+ Specify the CUDA toolkit version to use or the path to a
+ standalone CUDA toolkit directory. Supported by VS 2010
+ and above. The version can only be used with the CUDA
+ toolkit VS integration globally installed.
+ See the :variable:`CMAKE_VS_PLATFORM_TOOLSET_CUDA` and
+ :variable:`CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR` variables.
-``host=x64``
- Request use of the native ``x64`` toolchain on ``x64`` hosts.
+``host=<arch>``
+ Specify the host tools architecture as ``x64`` or ``x86``.
Supported by VS 2013 and above.
See the :variable:`CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE`
variable.
+
+``version=<version>``
+ Specify the toolset version to use. Supported by VS 2017
+ and above with the specified toolset installed.
+ See the :variable:`CMAKE_VS_PLATFORM_TOOLSET_VERSION` variable.
diff --git a/Help/variable/CMAKE_GHS_NO_SOURCE_GROUP_FILE.rst b/Help/variable/CMAKE_GHS_NO_SOURCE_GROUP_FILE.rst
new file mode 100644
index 000000000..b6768a131
--- /dev/null
+++ b/Help/variable/CMAKE_GHS_NO_SOURCE_GROUP_FILE.rst
@@ -0,0 +1,6 @@
+CMAKE_GHS_NO_SOURCE_GROUP_FILE
+------------------------------
+
+``ON`` / ``OFF`` boolean to control if the project file for a target should
+be one single file or multiple files. Refer to
+:prop_tgt:`GHS_NO_SOURCE_GROUP_FILE` for further details.
diff --git a/Help/variable/CMAKE_GLOBAL_AUTOGEN_TARGET.rst b/Help/variable/CMAKE_GLOBAL_AUTOGEN_TARGET.rst
new file mode 100644
index 000000000..e82867dfd
--- /dev/null
+++ b/Help/variable/CMAKE_GLOBAL_AUTOGEN_TARGET.rst
@@ -0,0 +1,26 @@
+CMAKE_GLOBAL_AUTOGEN_TARGET
+---------------------------
+
+Switch to enable generation of a global ``autogen`` target.
+
+When :variable:`CMAKE_GLOBAL_AUTORCC_TARGET` is enabled, a custom target
+``autogen`` is generated. This target depends on all :prop_tgt:`AUTOMOC` and
+:prop_tgt:`AUTOUIC` generated ``<ORIGIN>_autogen`` targets in the project.
+By building the global ``autogen`` target, all :prop_tgt:`AUTOMOC` and
+:prop_tgt:`AUTOUIC` files in the project will be generated.
+
+The name of the global ``autogen`` target can be changed by setting
+:variable:`CMAKE_GLOBAL_AUTOGEN_TARGET_NAME`.
+
+By default :variable:`CMAKE_GLOBAL_AUTOGEN_TARGET` is unset.
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
+
+Note
+^^^^
+
+``<ORIGIN>_autogen`` targets by default inherit their origin target's
+dependencies. This might result in unintended dependency target
+builds when only ``<ORIGIN>_autogen`` targets are built. A solution is to
+disable :prop_tgt:`AUTOGEN_ORIGIN_DEPENDS` on the respective origin targets.
diff --git a/Help/variable/CMAKE_GLOBAL_AUTOGEN_TARGET_NAME.rst b/Help/variable/CMAKE_GLOBAL_AUTOGEN_TARGET_NAME.rst
new file mode 100644
index 000000000..c86a5d0af
--- /dev/null
+++ b/Help/variable/CMAKE_GLOBAL_AUTOGEN_TARGET_NAME.rst
@@ -0,0 +1,13 @@
+CMAKE_GLOBAL_AUTOGEN_TARGET_NAME
+--------------------------------
+
+Change the name of the global ``autogen`` target.
+
+When :variable:`CMAKE_GLOBAL_AUTOGEN_TARGET` is enabled, a global custom target
+named ``autogen`` is created. :variable:`CMAKE_GLOBAL_AUTOGEN_TARGET_NAME`
+allows to set a different name for that target.
+
+By default :variable:`CMAKE_GLOBAL_AUTOGEN_TARGET_NAME` is unset.
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
diff --git a/Help/variable/CMAKE_GLOBAL_AUTORCC_TARGET.rst b/Help/variable/CMAKE_GLOBAL_AUTORCC_TARGET.rst
new file mode 100644
index 000000000..f92128cda
--- /dev/null
+++ b/Help/variable/CMAKE_GLOBAL_AUTORCC_TARGET.rst
@@ -0,0 +1,18 @@
+CMAKE_GLOBAL_AUTORCC_TARGET
+---------------------------
+
+Switch to enable generation of a global ``autorcc`` target.
+
+When :variable:`CMAKE_GLOBAL_AUTORCC_TARGET` is enabled, a custom target
+``autorcc`` is generated. This target depends on all :prop_tgt:`AUTORCC`
+generated ``<ORIGIN>_arcc_<QRC>`` targets in the project.
+By building the global ``autorcc`` target, all :prop_tgt:`AUTORCC`
+files in the project will be generated.
+
+The name of the global ``autorcc`` target can be changed by setting
+:variable:`CMAKE_GLOBAL_AUTORCC_TARGET_NAME`.
+
+By default :variable:`CMAKE_GLOBAL_AUTORCC_TARGET` is unset.
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
diff --git a/Help/variable/CMAKE_GLOBAL_AUTORCC_TARGET_NAME.rst b/Help/variable/CMAKE_GLOBAL_AUTORCC_TARGET_NAME.rst
new file mode 100644
index 000000000..c6e05de4e
--- /dev/null
+++ b/Help/variable/CMAKE_GLOBAL_AUTORCC_TARGET_NAME.rst
@@ -0,0 +1,13 @@
+CMAKE_GLOBAL_AUTORCC_TARGET_NAME
+--------------------------------
+
+Change the name of the global ``autorcc`` target.
+
+When :variable:`CMAKE_GLOBAL_AUTORCC_TARGET` is enabled, a global custom target
+named ``autorcc`` is created. :variable:`CMAKE_GLOBAL_AUTORCC_TARGET_NAME`
+allows to set a different name for that target.
+
+By default :variable:`CMAKE_GLOBAL_AUTOGEN_TARGET_NAME` is unset.
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
diff --git a/Help/variable/CMAKE_HOME_DIRECTORY.rst b/Help/variable/CMAKE_HOME_DIRECTORY.rst
index fdc5d8190..b03d95618 100644
--- a/Help/variable/CMAKE_HOME_DIRECTORY.rst
+++ b/Help/variable/CMAKE_HOME_DIRECTORY.rst
@@ -1,6 +1,9 @@
CMAKE_HOME_DIRECTORY
--------------------
-Path to top of source tree.
+Path to top of source tree. Same as :variable:`CMAKE_SOURCE_DIR`.
-This is the path to the top level of the source tree.
+This is an internal cache entry used to locate the source directory
+when loading a ``CMakeCache.txt`` from a build tree. It should not
+be used in project code. The variable :variable:`CMAKE_SOURCE_DIR`
+has the same value and should be preferred.
diff --git a/Help/variable/CMAKE_HOST_APPLE.rst b/Help/variable/CMAKE_HOST_APPLE.rst
index ac7b03004..9c205ec34 100644
--- a/Help/variable/CMAKE_HOST_APPLE.rst
+++ b/Help/variable/CMAKE_HOST_APPLE.rst
@@ -1,6 +1,6 @@
CMAKE_HOST_APPLE
----------------
-``True`` for Apple OS X operating systems.
+``True`` for Apple macOS operating systems.
-Set to ``true`` when the host system is Apple OS X.
+Set to ``true`` when the host system is Apple macOS.
diff --git a/Help/variable/CMAKE_HOST_SYSTEM.rst b/Help/variable/CMAKE_HOST_SYSTEM.rst
index c2a8f1a5f..12d11d198 100644
--- a/Help/variable/CMAKE_HOST_SYSTEM.rst
+++ b/Help/variable/CMAKE_HOST_SYSTEM.rst
@@ -1,7 +1,7 @@
CMAKE_HOST_SYSTEM
-----------------
-Composit Name of OS CMake is being run on.
+Composite Name of OS CMake is being run on.
This variable is the composite of :variable:`CMAKE_HOST_SYSTEM_NAME` and
:variable:`CMAKE_HOST_SYSTEM_VERSION`, e.g.
diff --git a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst
index c67359272..e8926771c 100644
--- a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst
+++ b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst
@@ -4,5 +4,5 @@ CMAKE_HOST_SYSTEM_NAME
Name of the OS CMake is running on.
On systems that have the uname command, this variable is set to the
-output of ``uname -s``. ``Linux``, ``Windows``, and ``Darwin`` for OS X
+output of ``uname -s``. ``Linux``, ``Windows``, and ``Darwin`` for macOS
are the values found on the big three operating systems.
diff --git a/Help/variable/CMAKE_IGNORE_PATH.rst b/Help/variable/CMAKE_IGNORE_PATH.rst
index 92f377086..4bca34b7e 100644
--- a/Help/variable/CMAKE_IGNORE_PATH.rst
+++ b/Help/variable/CMAKE_IGNORE_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_IGNORE_PATH
-----------------
-:ref:`;-list <CMake Language Lists>` of directories to be *ignored* by
+:ref:`Semicolon-separated list <CMake Language Lists>` of directories to be *ignored* by
the :command:`find_program`, :command:`find_library`, :command:`find_file`,
and :command:`find_path` commands. This is useful in cross-compiling
environments where some system directories contain incompatible but
diff --git a/Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst b/Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst
index 6eea322f8..98d99eb64 100644
--- a/Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst
+++ b/Help/variable/CMAKE_INCLUDE_CURRENT_DIR.rst
@@ -1,7 +1,7 @@
CMAKE_INCLUDE_CURRENT_DIR
-------------------------
-Automatically add the current source- and build directories to the include path.
+Automatically add the current source and build directories to the include path.
If this variable is enabled, CMake automatically adds
:variable:`CMAKE_CURRENT_SOURCE_DIR` and :variable:`CMAKE_CURRENT_BINARY_DIR`
diff --git a/Help/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst b/Help/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst
index 5fc95f00b..697682ba6 100644
--- a/Help/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst
+++ b/Help/variable/CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.rst
@@ -1,7 +1,7 @@
CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE
--------------------------------------
-Automatically add the current source- and build directories to the
+Automatically add the current source and build directories to the
:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target property.
If this variable is enabled, CMake automatically adds for each shared
diff --git a/Help/variable/CMAKE_INCLUDE_PATH.rst b/Help/variable/CMAKE_INCLUDE_PATH.rst
index e4e7f2cfc..4918e9960 100644
--- a/Help/variable/CMAKE_INCLUDE_PATH.rst
+++ b/Help/variable/CMAKE_INCLUDE_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_INCLUDE_PATH
------------------
-:ref:`;-list <CMake Language Lists>` of directories specifying a search 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`.
diff --git a/Help/variable/CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS.rst b/Help/variable/CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS.rst
new file mode 100644
index 000000000..f994fbe87
--- /dev/null
+++ b/Help/variable/CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS.rst
@@ -0,0 +1,29 @@
+CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
+-------------------------------------------
+
+Default permissions for directories created implicitly during installation
+of files by :command:`install` and :command:`file(INSTALL)`.
+
+If ``make install`` is invoked and directories are implicitly created they
+get permissions set by :variable:`CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS`
+variable or platform specific default permissions if the variable is not set.
+
+Implicitly created directories are created if they are not explicitly installed
+by :command:`install` command but are needed to install a file on a certain
+path. Example of such locations are directories created due to the setting of
+:variable:`CMAKE_INSTALL_PREFIX`.
+
+Expected content of the :variable:`CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS`
+variable is a list of permissions that can be used by :command:`install` command
+`PERMISSIONS` section.
+
+Example usage:
+
+::
+
+ set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
+ OWNER_READ
+ OWNER_WRITE
+ OWNER_EXECUTE
+ GROUP_READ
+ )
diff --git a/Help/variable/CMAKE_INSTALL_NAME_DIR.rst b/Help/variable/CMAKE_INSTALL_NAME_DIR.rst
index 1f2d62bf6..5ba4c04cb 100644
--- a/Help/variable/CMAKE_INSTALL_NAME_DIR.rst
+++ b/Help/variable/CMAKE_INSTALL_NAME_DIR.rst
@@ -1,7 +1,7 @@
CMAKE_INSTALL_NAME_DIR
----------------------
-OS X directory name for installed targets.
+macOS directory name for installed targets.
``CMAKE_INSTALL_NAME_DIR`` is used to initialize the
:prop_tgt:`INSTALL_NAME_DIR` property on all targets. See that target
diff --git a/Help/variable/CMAKE_INSTALL_PREFIX.rst b/Help/variable/CMAKE_INSTALL_PREFIX.rst
index 7bd87d6aa..02ba645c7 100644
--- a/Help/variable/CMAKE_INSTALL_PREFIX.rst
+++ b/Help/variable/CMAKE_INSTALL_PREFIX.rst
@@ -10,21 +10,7 @@ See :variable:`CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT` for how a
project might choose its own default.
On UNIX one can use the ``DESTDIR`` mechanism in order to relocate the
-whole installation. ``DESTDIR`` means DESTination DIRectory. It is
-commonly used by makefile users in order to install software at
-non-default location. It is usually invoked like this:
-
-::
-
- make DESTDIR=/home/john install
-
-which will install the concerned software using the installation
-prefix, e.g. ``/usr/local`` prepended with the ``DESTDIR`` value which
-finally gives ``/home/john/usr/local``.
-
-WARNING: ``DESTDIR`` may not be used on Windows because installation
-prefix usually contains a drive letter like in ``C:/Program Files``
-which cannot be prepended with some other prefix.
+whole installation. See :envvar:`DESTDIR` for more information.
The installation prefix is also added to :variable:`CMAKE_SYSTEM_PREFIX_PATH`
so that :command:`find_package`, :command:`find_program`,
diff --git a/Help/variable/CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH.rst b/Help/variable/CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH.rst
new file mode 100644
index 000000000..76ca3da02
--- /dev/null
+++ b/Help/variable/CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH.rst
@@ -0,0 +1,9 @@
+CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH
+--------------------------------------
+
+Sets the default for whether toolchain-defined rpaths should be removed during
+installation.
+
+``CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH`` is a boolean that provides the
+default value for the :prop_tgt:`INSTALL_REMOVE_ENVIRONMENT_RPATH` property
+of all subsequently created targets.
diff --git a/Help/variable/CMAKE_JOB_POOLS.rst b/Help/variable/CMAKE_JOB_POOLS.rst
new file mode 100644
index 000000000..72b50b490
--- /dev/null
+++ b/Help/variable/CMAKE_JOB_POOLS.rst
@@ -0,0 +1,6 @@
+CMAKE_JOB_POOLS
+---------------
+
+If the :prop_gbl:`JOB_POOLS` global property is not set, the value
+of this variable is used in its place. See :prop_gbl:`JOB_POOLS`
+for additional information.
diff --git a/Help/variable/CMAKE_JOB_POOL_LINK.rst b/Help/variable/CMAKE_JOB_POOL_LINK.rst
index 338f7714e..eeee6e069 100644
--- a/Help/variable/CMAKE_JOB_POOL_LINK.rst
+++ b/Help/variable/CMAKE_JOB_POOL_LINK.rst
@@ -1,5 +1,5 @@
CMAKE_JOB_POOL_LINK
-----------------------
+-------------------
This variable is used to initialize the :prop_tgt:`JOB_POOL_LINK`
property on all the targets. See :prop_tgt:`JOB_POOL_LINK`
diff --git a/Help/variable/CMAKE_LANG_CLANG_TIDY.rst b/Help/variable/CMAKE_LANG_CLANG_TIDY.rst
index 492c12c6d..bd49de369 100644
--- a/Help/variable/CMAKE_LANG_CLANG_TIDY.rst
+++ b/Help/variable/CMAKE_LANG_CLANG_TIDY.rst
@@ -1,6 +1,13 @@
CMAKE_<LANG>_CLANG_TIDY
-----------------------
-Default value for :prop_tgt:`<LANG>_CLANG_TIDY` target property.
+Default value for :prop_tgt:`<LANG>_CLANG_TIDY` target property
+when ``<LANG>`` is ``C`` or ``CXX``.
+
This variable is used to initialize the property on each target as it is
-created. This is done only when ``<LANG>`` is ``C`` or ``CXX``.
+created. For example:
+
+.. code-block:: cmake
+
+ set(CMAKE_CXX_CLANG_TIDY clang-tidy -checks=-*,readability-*)
+ add_executable(foo foo.cxx)
diff --git a/Help/variable/CMAKE_LANG_COMPILER_ARCHITECTURE_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ARCHITECTURE_ID.rst
new file mode 100644
index 000000000..054c64884
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_COMPILER_ARCHITECTURE_ID.rst
@@ -0,0 +1,8 @@
+CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID
+-------------------------------------
+
+An internal variable subject to change.
+
+This is used to identify the variant of a compiler based on its target
+architecture. For some compilers this is needed to determine the correct
+usage.
diff --git a/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst
index 5be935bad..cbe35441e 100644
--- a/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst
+++ b/Help/variable/CMAKE_LANG_COMPILER_EXTERNAL_TOOLCHAIN.rst
@@ -6,7 +6,7 @@ The external toolchain for cross-compiling, if supported.
Some compiler toolchains do not ship their own auxiliary utilities such as
archivers and linkers. The compiler driver may support a command-line argument
to specify the location of such tools.
-``CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN`` may be set to a path to a path to
+``CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN`` may be set to a path to
the external toolchain and will be passed to the compiler driver if supported.
This variable may only be set in a toolchain file specified by
diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
index 0fab10ca8..8eb4fb612 100644
--- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst
+++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
@@ -12,16 +12,19 @@ include:
ADSP = Analog VisualDSP++ (analog.com)
AppleClang = Apple Clang (apple.com)
ARMCC = ARM Compiler (arm.com)
+ ARMClang = ARM Compiler based on Clang (arm.com)
Bruce = Bruce C Compiler
CCur = Concurrent Fortran (ccur.com)
Clang = LLVM Clang (clang.llvm.org)
Cray = Cray Compiler (cray.com)
Embarcadero, Borland = Embarcadero (embarcadero.com)
+ Flang = Flang LLVM Fortran Compiler
G95 = G95 Fortran (g95.org)
GNU = GNU Compiler Collection (gcc.gnu.org)
+ GHS = Green Hills Software (www.ghs.com)
HP = Hewlett-Packard Compiler (hp.com)
+ IAR = IAR Systems (iar.com)
Intel = Intel Compiler (intel.com)
- MIPSpro = SGI MIPSpro (sgi.com)
MSVC = Microsoft Visual Studio (microsoft.com)
NVIDIA = NVIDIA CUDA Compiler (nvidia.com)
OpenWatcom = Open Watcom (openwatcom.org)
@@ -32,6 +35,7 @@ include:
TI = Texas Instruments (ti.com)
TinyCC = Tiny C Compiler (tinycc.org)
XL, VisualAge, zOS = IBM XL (ibm.com)
+ XLClang = IBM Clang-based XL (ibm.com)
This variable is not guaranteed to be defined for all compilers or
languages.
diff --git a/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst b/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst
index 7961f609e..6b7e35a0a 100644
--- a/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst
+++ b/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst
@@ -3,4 +3,5 @@ CMAKE_<LANG>_COMPILER_LAUNCHER
Default value for :prop_tgt:`<LANG>_COMPILER_LAUNCHER` target property.
This variable is used to initialize the property on each target as it is
-created. This is done only when ``<LANG>`` is ``C`` or ``CXX``.
+created. This is done only when ``<LANG>`` is ``C``, ``CXX``, ``Fortran``,
+``OBJC``, ``OBJCXX``, or ``CUDA``.
diff --git a/Help/variable/CMAKE_LANG_COMPILER_PREDEFINES_COMMAND.rst b/Help/variable/CMAKE_LANG_COMPILER_PREDEFINES_COMMAND.rst
new file mode 100644
index 000000000..e050f43e6
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_COMPILER_PREDEFINES_COMMAND.rst
@@ -0,0 +1,8 @@
+CMAKE_<LANG>_COMPILER_PREDEFINES_COMMAND
+----------------------------------------
+
+Command that outputs the compiler pre definitions.
+
+See :prop_tgt:`AUTOMOC` which uses
+:variable:`CMAKE_CXX_COMPILER_PREDEFINES_COMMAND <CMAKE_<LANG>_COMPILER_PREDEFINES_COMMAND>`
+to generate the :prop_tgt:`AUTOMOC_COMPILER_PREDEFINES`.
diff --git a/Help/variable/CMAKE_LANG_COMPILER_VERSION_INTERNAL.rst b/Help/variable/CMAKE_LANG_COMPILER_VERSION_INTERNAL.rst
new file mode 100644
index 000000000..c3cd9801a
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_COMPILER_VERSION_INTERNAL.rst
@@ -0,0 +1,8 @@
+CMAKE_<LANG>_COMPILER_VERSION_INTERNAL
+--------------------------------------
+
+An internal variable subject to change.
+
+This is used to identify the variant of a compiler based on an internal
+version number. For some compilers this is needed to determine the
+correct usage.
diff --git a/Help/variable/CMAKE_LANG_CPPCHECK.rst b/Help/variable/CMAKE_LANG_CPPCHECK.rst
new file mode 100644
index 000000000..50b478fd0
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_CPPCHECK.rst
@@ -0,0 +1,6 @@
+CMAKE_<LANG>_CPPCHECK
+---------------------
+
+Default value for :prop_tgt:`<LANG>_CPPCHECK` target property. This variable
+is used to initialize the property on each target as it is created. This
+is done only when ``<LANG>`` is ``C`` or ``CXX``.
diff --git a/Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst b/Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst
index be89f8529..16fcc0344 100644
--- a/Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst
+++ b/Help/variable/CMAKE_LANG_CREATE_SHARED_LIBRARY.rst
@@ -4,4 +4,5 @@ CMAKE_<LANG>_CREATE_SHARED_LIBRARY
Rule variable to create a shared library.
This is a rule variable that tells CMake how to create a shared
-library for the language ``<LANG>``.
+library for the language ``<LANG>``. This rule variable is a ``;`` delimited
+list of commands to run to perform the linking step.
diff --git a/Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst b/Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst
index ae5f69d56..807229dec 100644
--- a/Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst
+++ b/Help/variable/CMAKE_LANG_CREATE_SHARED_MODULE.rst
@@ -4,4 +4,5 @@ CMAKE_<LANG>_CREATE_SHARED_MODULE
Rule variable to create a shared module.
This is a rule variable that tells CMake how to create a shared
-library for the language ``<LANG>``.
+library for the language ``<LANG>``. This rule variable is a ``;`` delimited
+list of commands to run.
diff --git a/Help/variable/CMAKE_LANG_FLAGS.rst b/Help/variable/CMAKE_LANG_FLAGS.rst
index c57d92cbf..14b2694ef 100644
--- a/Help/variable/CMAKE_LANG_FLAGS.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS.rst
@@ -4,3 +4,14 @@ CMAKE_<LANG>_FLAGS
Flags for all build types.
``<LANG>`` flags used regardless of the value of :variable:`CMAKE_BUILD_TYPE`.
+
+This is initialized for each language from environment variables:
+
+* ``CMAKE_C_FLAGS``:
+ Initialized by the :envvar:`CFLAGS` environment variable.
+* ``CMAKE_CXX_FLAGS``:
+ Initialized by the :envvar:`CXXFLAGS` environment variable.
+* ``CMAKE_CUDA_FLAGS``:
+ Initialized by the :envvar:`CUDAFLAGS` environment variable.
+* ``CMAKE_Fortran_FLAGS``:
+ Initialized by the :envvar:`FFLAGS` environment variable.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst
new file mode 100644
index 000000000..1dbd03640
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_FLAGS_CONFIG.rst
@@ -0,0 +1,4 @@
+CMAKE_<LANG>_FLAGS_<CONFIG>
+---------------------------
+
+Flags for language ``<LANG>`` when building for the ``<CONFIG>`` configuration.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_CONFIG_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_CONFIG_INIT.rst
new file mode 100644
index 000000000..1eb5b3f61
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_FLAGS_CONFIG_INIT.rst
@@ -0,0 +1,10 @@
+CMAKE_<LANG>_FLAGS_<CONFIG>_INIT
+--------------------------------
+
+Value used to initialize the :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` cache
+entry the first time a build tree is configured for language ``<LANG>``.
+This variable is meant to be set by a :variable:`toolchain file
+<CMAKE_TOOLCHAIN_FILE>`. CMake may prepend or append content to
+the value based on the environment and target platform.
+
+See also :variable:`CMAKE_<LANG>_FLAGS_INIT`.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst b/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst
index a233d4ad7..6be424aa9 100644
--- a/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS_DEBUG.rst
@@ -1,6 +1,5 @@
CMAKE_<LANG>_FLAGS_DEBUG
------------------------
-Flags for ``Debug`` build type or configuration.
-
-``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Debug``.
+This variable is the ``Debug`` variant of the
+:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variable.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_DEBUG_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_DEBUG_INIT.rst
index dcddb2e26..de7fcfc1d 100644
--- a/Help/variable/CMAKE_LANG_FLAGS_DEBUG_INIT.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS_DEBUG_INIT.rst
@@ -1,10 +1,5 @@
CMAKE_<LANG>_FLAGS_DEBUG_INIT
-----------------------------
-Value used to initialize the :variable:`CMAKE_<LANG>_FLAGS_DEBUG` cache
-entry the first time a build tree is configured for language ``<LANG>``.
-This variable is meant to be set by a :variable:`toolchain file
-<CMAKE_TOOLCHAIN_FILE>`. CMake may prepend or append content to
-the value based on the environment and target platform.
-
-See also :variable:`CMAKE_<LANG>_FLAGS_INIT`.
+This variable is the ``Debug`` variant of the
+:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>_INIT` variable.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_INIT.rst
index 1d32cc3fd..a88d1229e 100644
--- a/Help/variable/CMAKE_LANG_FLAGS_INIT.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS_INIT.rst
@@ -7,9 +7,5 @@ This variable is meant to be set by a :variable:`toolchain file
<CMAKE_TOOLCHAIN_FILE>`. CMake may prepend or append content to
the value based on the environment and target platform.
-See also the configuration-specific variables:
-
-* :variable:`CMAKE_<LANG>_FLAGS_DEBUG_INIT`
-* :variable:`CMAKE_<LANG>_FLAGS_RELEASE_INIT`
-* :variable:`CMAKE_<LANG>_FLAGS_MINSIZEREL_INIT`
-* :variable:`CMAKE_<LANG>_FLAGS_RELWITHDEBINFO_INIT`
+See also the configuration-specific
+:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>_INIT` variable.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst b/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst
index a9436c184..634fab9d6 100644
--- a/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL.rst
@@ -1,7 +1,5 @@
CMAKE_<LANG>_FLAGS_MINSIZEREL
-----------------------------
-Flags for ``MinSizeRel`` build type or configuration.
-
-``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``MinSizeRel``
-(short for minimum size release).
+This variable is the ``MinSizeRel`` variant of the
+:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variable.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL_INIT.rst
index c0aedf403..1e7003cec 100644
--- a/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL_INIT.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS_MINSIZEREL_INIT.rst
@@ -1,10 +1,5 @@
CMAKE_<LANG>_FLAGS_MINSIZEREL_INIT
----------------------------------
-Value used to initialize the :variable:`CMAKE_<LANG>_FLAGS_MINSIZEREL`
-cache entry the first time a build tree is configured for language ``<LANG>``.
-This variable is meant to be set by a :variable:`toolchain file
-<CMAKE_TOOLCHAIN_FILE>`. CMake may prepend or append content to
-the value based on the environment and target platform.
-
-See also :variable:`CMAKE_<LANG>_FLAGS_INIT`.
+This variable is the ``MinSizeRel`` variant of the
+:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>_INIT` variable.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst b/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst
index ffc5d795d..3baeab090 100644
--- a/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS_RELEASE.rst
@@ -1,6 +1,5 @@
CMAKE_<LANG>_FLAGS_RELEASE
--------------------------
-Flags for ``Release`` build type or configuration.
-
-``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Release``.
+This variable is the ``Release`` variant of the
+:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variable.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_RELEASE_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_RELEASE_INIT.rst
index 59f92ff6f..e7c73fea6 100644
--- a/Help/variable/CMAKE_LANG_FLAGS_RELEASE_INIT.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS_RELEASE_INIT.rst
@@ -1,10 +1,5 @@
CMAKE_<LANG>_FLAGS_RELEASE_INIT
-------------------------------
-Value used to initialize the :variable:`CMAKE_<LANG>_FLAGS_RELEASE`
-cache entry the first time a build tree is configured for language ``<LANG>``.
-This variable is meant to be set by a :variable:`toolchain file
-<CMAKE_TOOLCHAIN_FILE>`. CMake may prepend or append content to
-the value based on the environment and target platform.
-
-See also :variable:`CMAKE_<LANG>_FLAGS_INIT`.
+This variable is the ``Release`` variant of the
+:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>_INIT` variable.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst b/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst
index 962768e44..67a507377 100644
--- a/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO.rst
@@ -1,7 +1,5 @@
CMAKE_<LANG>_FLAGS_RELWITHDEBINFO
---------------------------------
-Flags for ``RelWithDebInfo`` type or configuration.
-
-``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``RelWithDebInfo``
-(short for Release With Debug Information).
+This variable is the ``RelWithDebInfo`` variant of the
+:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` variable.
diff --git a/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO_INIT.rst
index 915f02305..3ab39753d 100644
--- a/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO_INIT.rst
+++ b/Help/variable/CMAKE_LANG_FLAGS_RELWITHDEBINFO_INIT.rst
@@ -1,10 +1,5 @@
CMAKE_<LANG>_FLAGS_RELWITHDEBINFO_INIT
--------------------------------------
-Value used to initialize the :variable:`CMAKE_<LANG>_FLAGS_RELWITHDEBINFO`
-cache entry the first time a build tree is configured for language ``<LANG>``.
-This variable is meant to be set by a :variable:`toolchain file
-<CMAKE_TOOLCHAIN_FILE>`. CMake may prepend or append content to
-the value based on the environment and target platform.
-
-See also :variable:`CMAKE_<LANG>_FLAGS_INIT`.
+This variable is the ``RelWithDebInfo`` variant of the
+:variable:`CMAKE_<LANG>_FLAGS_<CONFIG>_INIT` variable.
diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst
deleted file mode 100644
index 1f639a3ba..000000000
--- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_DEBUG.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-CMAKE_<LANG>_GHS_KERNEL_FLAGS_DEBUG
------------------------------------
-
-GHS kernel flags for ``Debug`` build type or configuration.
-
-``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Debug``.
diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst
deleted file mode 100644
index 94e21150a..000000000
--- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_MINSIZEREL.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-CMAKE_<LANG>_GHS_KERNEL_FLAGS_MINSIZEREL
-----------------------------------------
-
-GHS kernel flags for ``MinSizeRel`` build type or configuration.
-
-``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``MinSizeRel``
-(short for minimum size release).
diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst
deleted file mode 100644
index 74566efca..000000000
--- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELEASE.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-CMAKE_<LANG>_GHS_KERNEL_FLAGS_RELEASE
--------------------------------------
-
-GHS kernel flags for ``Release`` build type or configuration.
-
-``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``Release``.
diff --git a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst b/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst
deleted file mode 100644
index d148193d8..000000000
--- a/Help/variable/CMAKE_LANG_GHS_KERNEL_FLAGS_RELWITHDEBINFO.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-CMAKE_<LANG>_GHS_KERNEL_FLAGS_RELWITHDEBINFO
---------------------------------------------
-
-GHS kernel flags for ``RelWithDebInfo`` type or configuration.
-
-``<LANG>`` flags used when :variable:`CMAKE_BUILD_TYPE` is ``RelWithDebInfo``
-(short for Release With Debug Information).
diff --git a/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst b/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst
index cc8085107..e361fd98e 100644
--- a/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst
+++ b/Help/variable/CMAKE_LANG_IMPLICIT_INCLUDE_DIRECTORIES.rst
@@ -6,4 +6,9 @@ Directories implicitly searched by the compiler for header files.
CMake does not explicitly specify these directories on compiler
command lines for language ``<LANG>``. This prevents system include
directories from being treated as user include directories on some
-compilers.
+compilers, which is important for ``C``, ``CXX``, and ``CUDA`` to
+avoid overriding standard library headers.
+
+This value is not used for ``Fortran`` because it has no standard
+library headers and some compilers do not search their implicit
+include directories for module ``.mod`` files.
diff --git a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst
index a0bd8303c..e9e04be6e 100644
--- a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst
+++ b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst
@@ -9,9 +9,12 @@ These paths are implicit linker search directories for the compiler's
language. CMake automatically detects these directories for each
language and reports the results in this variable.
-When a library in one of these directories is given by full path to
-:command:`target_link_libraries` CMake will generate the ``-l<name>`` form on
-link lines to ensure the linker searches its implicit directories for the
-library. Note that some toolchains read implicit directories from an
-environment variable such as ``LIBRARY_PATH`` so keep its value consistent
-when operating in a given build tree.
+Some toolchains read implicit directories from an environment variable such as
+``LIBRARY_PATH``. If using such an environment variable, keep its value
+consistent when operating in a given build tree because CMake saves the value
+detected when first creating a build tree.
+
+If policy :policy:`CMP0060` is not set to ``NEW``, then when a library in one
+of these directories is given by full path to :command:`target_link_libraries`
+CMake will generate the ``-l<name>`` form on link lines for historical
+purposes.
diff --git a/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst b/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst
new file mode 100644
index 000000000..df514075c
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG.rst
@@ -0,0 +1,39 @@
+CMAKE_<LANG>_LINKER_WRAPPER_FLAG
+--------------------------------
+
+Defines the syntax of compiler driver option to pass options to the linker
+tool. It will be used to translate the ``LINKER:`` prefix in the link options
+(see :command:`add_link_options` and :command:`target_link_options`).
+
+This variable holds a :ref:`semicolon-separated list <CMake Language Lists>` of tokens.
+If a space (i.e. " ") is specified as last token, flag and ``LINKER:``
+arguments will be specified as separate arguments to the compiler driver.
+The :variable:`CMAKE_<LANG>_LINKER_WRAPPER_FLAG_SEP` variable can be specified
+to manage concatenation of arguments.
+
+For example, for ``Clang`` we have:
+
+.. code-block:: cmake
+
+ set (CMAKE_C_LINKER_WRAPPER_FLAG "-Xlinker" " ")
+
+Specifying ``"LINKER:-z,defs"`` will be transformed in
+``-Xlinker -z -Xlinker defs``.
+
+For ``GNU GCC``:
+
+.. code-block:: cmake
+
+ set (CMAKE_C_LINKER_WRAPPER_FLAG "-Wl,")
+ set (CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",")
+
+Specifying ``"LINKER:-z,defs"`` will be transformed in ``-Wl,-z,defs``.
+
+And for ``SunPro``:
+
+.. code-block:: cmake
+
+ set (CMAKE_C_LINKER_WRAPPER_FLAG "-Qoption" "ld" " ")
+ set (CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",")
+
+Specifying ``"LINKER:-z,defs"`` will be transformed in ``-Qoption ld -z,defs``.
diff --git a/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG_SEP.rst b/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG_SEP.rst
new file mode 100644
index 000000000..faf14815c
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_LINKER_WRAPPER_FLAG_SEP.rst
@@ -0,0 +1,9 @@
+CMAKE_<LANG>_LINKER_WRAPPER_FLAG_SEP
+------------------------------------
+
+This variable is used with :variable:`CMAKE_<LANG>_LINKER_WRAPPER_FLAG`
+variable to format ``LINKER:`` prefix in the link options
+(see :command:`add_link_options` and :command:`target_link_options`).
+
+When specified, arguments of the ``LINKER:`` prefix will be concatenated using
+this value as separator.
diff --git a/Help/variable/CMAKE_LANG_LINK_LIBRARY_FILE_FLAG.rst b/Help/variable/CMAKE_LANG_LINK_LIBRARY_FILE_FLAG.rst
new file mode 100644
index 000000000..d54f08022
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_LINK_LIBRARY_FILE_FLAG.rst
@@ -0,0 +1,8 @@
+CMAKE_<LANG>_LINK_LIBRARY_FILE_FLAG
+-----------------------------------
+
+Language-specific flag to be used to link a library specified by
+a path to its file.
+
+The flag will be used before a library file path is given to the
+linker. This is needed only on very few platforms.
diff --git a/Help/variable/CMAKE_LANG_LINK_LIBRARY_FLAG.rst b/Help/variable/CMAKE_LANG_LINK_LIBRARY_FLAG.rst
new file mode 100644
index 000000000..d7bb0d875
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_LINK_LIBRARY_FLAG.rst
@@ -0,0 +1,7 @@
+CMAKE_<LANG>_LINK_LIBRARY_FLAG
+------------------------------
+
+Flag to be used to link a library into a shared library or executable.
+
+This flag will be used to specify a library to link to a shared library or an
+executable for the specific language. On most compilers this is ``-l``.
diff --git a/Help/variable/CMAKE_LANG_LINK_LIBRARY_SUFFIX.rst b/Help/variable/CMAKE_LANG_LINK_LIBRARY_SUFFIX.rst
new file mode 100644
index 000000000..a37865795
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_LINK_LIBRARY_SUFFIX.rst
@@ -0,0 +1,6 @@
+CMAKE_<LANG>_LINK_LIBRARY_SUFFIX
+--------------------------------
+
+Language-specific suffix for libraries that you link to.
+
+The suffix to use for the end of a library filename, ``.lib`` on Windows.
diff --git a/Help/variable/CMAKE_LIBRARY_PATH.rst b/Help/variable/CMAKE_LIBRARY_PATH.rst
index b1770dc26..8135b6581 100644
--- a/Help/variable/CMAKE_LIBRARY_PATH.rst
+++ b/Help/variable/CMAKE_LIBRARY_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_LIBRARY_PATH
------------------
-:ref:`;-list <CMake Language Lists>` of directories specifying a search 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`.
diff --git a/Help/variable/CMAKE_LINK_DIRECTORIES_BEFORE.rst b/Help/variable/CMAKE_LINK_DIRECTORIES_BEFORE.rst
new file mode 100644
index 000000000..026ca35b3
--- /dev/null
+++ b/Help/variable/CMAKE_LINK_DIRECTORIES_BEFORE.rst
@@ -0,0 +1,9 @@
+CMAKE_LINK_DIRECTORIES_BEFORE
+-----------------------------
+
+Whether to append or prepend directories by default in
+:command:`link_directories`.
+
+This variable affects the default behavior of the :command:`link_directories`
+command. Setting this variable to ``ON`` is equivalent to using the ``BEFORE``
+option in all uses of that command.
diff --git a/Help/variable/CMAKE_MACOSX_BUNDLE.rst b/Help/variable/CMAKE_MACOSX_BUNDLE.rst
index 0badaf0da..43ddff517 100644
--- a/Help/variable/CMAKE_MACOSX_BUNDLE.rst
+++ b/Help/variable/CMAKE_MACOSX_BUNDLE.rst
@@ -5,3 +5,6 @@ Default value for :prop_tgt:`MACOSX_BUNDLE` of targets.
This variable is used to initialize the :prop_tgt:`MACOSX_BUNDLE` property on
all the targets. See that target property for additional information.
+
+This variable is set to ``ON`` by default if :variable:`CMAKE_SYSTEM_NAME`
+equals to :ref:`iOS, tvOS or watchOS <Cross Compiling for iOS, tvOS, or watchOS>`.
diff --git a/Help/variable/CMAKE_MACOSX_RPATH.rst b/Help/variable/CMAKE_MACOSX_RPATH.rst
index 042e807f5..2fc648d61 100644
--- a/Help/variable/CMAKE_MACOSX_RPATH.rst
+++ b/Help/variable/CMAKE_MACOSX_RPATH.rst
@@ -1,7 +1,7 @@
CMAKE_MACOSX_RPATH
-------------------
-Whether to use rpaths on OS X and iOS.
+Whether to use rpaths on macOS and iOS.
This variable is used to initialize the :prop_tgt:`MACOSX_RPATH` property on
all targets.
diff --git a/Help/variable/CMAKE_MAKE_PROGRAM.rst b/Help/variable/CMAKE_MAKE_PROGRAM.rst
index a3b997af2..a3c8b7c8a 100644
--- a/Help/variable/CMAKE_MAKE_PROGRAM.rst
+++ b/Help/variable/CMAKE_MAKE_PROGRAM.rst
@@ -19,15 +19,11 @@ to configure the project:
This generator stores ``CMAKE_MAKE_PROGRAM`` in the CMake cache
so that it may be edited by the user.
-* The :generator:`Xcode` generator sets this to ``xcodebuild`` (or possibly an
- otherwise undocumented ``cmakexbuild`` wrapper implementing some
- workarounds).
+* The :generator:`Xcode` generator sets this to ``xcodebuild``.
This generator prefers to lookup the build tool at build time
rather than to store ``CMAKE_MAKE_PROGRAM`` in the CMake cache
- ahead of time. This is because ``xcodebuild`` is easy to find,
- the ``cmakexbuild`` wrapper is needed only for older Xcode versions,
- and the path to ``cmakexbuild`` may be outdated if CMake itself moves.
+ ahead of time. This is because ``xcodebuild`` is easy to find.
For compatibility with versions of CMake prior to 3.2, if
a user or project explicitly adds ``CMAKE_MAKE_PROGRAM`` to
@@ -55,9 +51,12 @@ to configure the project:
the CMake cache then CMake will use the specified value if
possible.
-* The :generator:`Green Hills MULTI` generator sets this to ``gbuild``.
- If a user or project explicitly adds ``CMAKE_MAKE_PROGRAM`` to
- the CMake cache then CMake will use the specified value.
+* The :generator:`Green Hills MULTI` generator sets this to the full
+ path to ``gbuild.exe(Windows)`` or ``gbuild(Linux)`` based upon
+ the toolset being used.
+
+ Once the generator has initialized a particular value for this
+ variable, changing the value has undefined behavior.
The ``CMAKE_MAKE_PROGRAM`` variable is set for use by project code.
The value is also used by the :manual:`cmake(1)` ``--build`` and
diff --git a/Help/variable/CMAKE_MAXIMUM_RECURSION_DEPTH.rst b/Help/variable/CMAKE_MAXIMUM_RECURSION_DEPTH.rst
new file mode 100644
index 000000000..7110b1685
--- /dev/null
+++ b/Help/variable/CMAKE_MAXIMUM_RECURSION_DEPTH.rst
@@ -0,0 +1,33 @@
+CMAKE_MAXIMUM_RECURSION_DEPTH
+-----------------------------
+
+Maximum recursion depth for CMake scripts. It is intended to be set on the
+command line with ``-DCMAKE_MAXIMUM_RECURSION_DEPTH=<x>``, or within
+``CMakeLists.txt`` by projects that require a large recursion depth. Projects
+that set this variable should provide the user with a way to override it. For
+example:
+
+.. code-block:: cmake
+
+ # About to perform deeply recursive actions
+ if(NOT CMAKE_MAXIMUM_RECURSION_DEPTH)
+ set(CMAKE_MAXIMUM_RECURSION_DEPTH 2000)
+ endif()
+
+If it is not set, or is set to a non-integer value, a sensible default limit is
+used. If the recursion limit is reached, the script terminates immediately with
+a fatal error.
+
+Calling any of the following commands increases the recursion depth:
+
+* :command:`include`
+* :command:`find_package`
+* :command:`add_subdirectory`
+* :command:`try_compile`
+* :command:`ctest_read_custom_files`
+* :command:`ctest_run_script` (unless ``NEW_PROCESS`` is specified)
+* User-defined :command:`function`'s and :command:`macro`'s (note that
+ :command:`function` and :command:`macro` themselves don't increase recursion
+ depth)
+* Reading or writing variables that are being watched by a
+ :command:`variable_watch`
diff --git a/Help/variable/CMAKE_MESSAGE_INDENT.rst b/Help/variable/CMAKE_MESSAGE_INDENT.rst
new file mode 100644
index 000000000..7e44a4cad
--- /dev/null
+++ b/Help/variable/CMAKE_MESSAGE_INDENT.rst
@@ -0,0 +1,32 @@
+CMAKE_MESSAGE_INDENT
+--------------------
+
+The :command:`message` command joins the strings from this list and for
+log levels of ``NOTICE`` and below, it prepends the resultant string to
+each line of the message.
+
+Example:
+
+.. code-block:: cmake
+
+ list(APPEND listVar one two three)
+
+ message(VERBOSE [[Collected items in the "listVar":]])
+ list(APPEND CMAKE_MESSAGE_INDENT " ")
+
+ foreach(item IN LISTS listVar)
+ message(VERBOSE ${item})
+ endforeach()
+
+ list(POP_BACK CMAKE_MESSAGE_INDENT)
+ message(VERBOSE "No more indent")
+
+Which results in the following output:
+
+.. code-block:: none
+
+ -- Collected items in the "listVar":
+ -- one
+ -- two
+ -- three
+ -- No more indent
diff --git a/Help/variable/CMAKE_MFC_FLAG.rst b/Help/variable/CMAKE_MFC_FLAG.rst
index 5a392bfbb..2c4d1c551 100644
--- a/Help/variable/CMAKE_MFC_FLAG.rst
+++ b/Help/variable/CMAKE_MFC_FLAG.rst
@@ -1,15 +1,16 @@
CMAKE_MFC_FLAG
--------------
-Tell cmake to use MFC for an executable or dll.
+Use the MFC library for an executable or dll.
-This can be set in a ``CMakeLists.txt`` file and will enable MFC in the
-application. It should be set to ``1`` for the static MFC library, and ``2``
-for the shared MFC library. This is used in Visual Studio
-project files. The CMakeSetup dialog used MFC and the ``CMakeLists.txt``
-looks like this:
+Enables the use of the Microsoft Foundation Classes (MFC).
+It should be set to ``1`` for the static MFC library, and
+``2`` for the shared MFC library. This is used in Visual Studio
+project files.
-::
+Usage example:
+
+.. code-block:: cmake
add_definitions(-D_AFXDLL)
set(CMAKE_MFC_FLAG 2)
diff --git a/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst b/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst
index 5a51634db..f466468d8 100644
--- a/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst
+++ b/Help/variable/CMAKE_MINIMUM_REQUIRED_VERSION.rst
@@ -1,7 +1,5 @@
CMAKE_MINIMUM_REQUIRED_VERSION
------------------------------
-Version specified to :command:`cmake_minimum_required` command
-
-Variable containing the ``VERSION`` component specified in the
-:command:`cmake_minimum_required` command.
+The ``<min>`` version of CMake given to the most recent call to the
+:command:`cmake_minimum_required(VERSION)` command.
diff --git a/Help/variable/CMAKE_MODULE_PATH.rst b/Help/variable/CMAKE_MODULE_PATH.rst
index 5ea7cbbc0..4dcf6b526 100644
--- a/Help/variable/CMAKE_MODULE_PATH.rst
+++ b/Help/variable/CMAKE_MODULE_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_MODULE_PATH
-----------------
-:ref:`;-list <CMake Language Lists>` of directories specifying a search path
-for CMake modules to be loaded by the the :command:`include` or
+:ref:`Semicolon-separated list <CMake Language Lists>` of directories specifying a search path
+for CMake modules to be loaded by the :command:`include` or
:command:`find_package` commands before checking the default modules that come
with CMake. By default it is empty, it is intended to be set by the project.
diff --git a/Help/variable/CMAKE_MSVCIDE_RUN_PATH.rst b/Help/variable/CMAKE_MSVCIDE_RUN_PATH.rst
new file mode 100644
index 000000000..22e727f37
--- /dev/null
+++ b/Help/variable/CMAKE_MSVCIDE_RUN_PATH.rst
@@ -0,0 +1,10 @@
+CMAKE_MSVCIDE_RUN_PATH
+----------------------
+
+Extra PATH locations that should be used when executing
+:command:`add_custom_command` or :command:`add_custom_target` when using the
+:generator:`Visual Studio 9 2008` (or above) generator. This allows
+for running commands and using dll's that the IDE environment is not aware of.
+
+If not set explicitly the value is initialized by the ``CMAKE_MSVCIDE_RUN_PATH``
+environment variable, if set, and otherwise left empty.
diff --git a/Help/variable/CMAKE_MSVC_RUNTIME_LIBRARY.rst b/Help/variable/CMAKE_MSVC_RUNTIME_LIBRARY.rst
new file mode 100644
index 000000000..8b54e7ecc
--- /dev/null
+++ b/Help/variable/CMAKE_MSVC_RUNTIME_LIBRARY.rst
@@ -0,0 +1,32 @@
+CMAKE_MSVC_RUNTIME_LIBRARY
+--------------------------
+
+Select the MSVC runtime library for use by compilers targeting the MSVC ABI.
+This variable is used to initialize the :prop_tgt:`MSVC_RUNTIME_LIBRARY`
+property on all targets as they are created. It is also propagated by
+calls to the :command:`try_compile` command into the test project.
+
+The allowed values are:
+
+.. include:: ../prop_tgt/MSVC_RUNTIME_LIBRARY-VALUES.txt
+
+Use :manual:`generator expressions <cmake-generator-expressions(7)>` to
+support per-configuration specification. For example, the code:
+
+.. code-block:: cmake
+
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+
+selects for all following targets a multi-threaded statically-linked runtime
+library with or without debug information depending on the configuration.
+
+If this variable is not set then the :prop_tgt:`MSVC_RUNTIME_LIBRARY` target
+property will not be set automatically. If that property is not set then
+CMake uses the default value ``MultiThreaded$<$<CONFIG:Debug>:Debug>DLL``
+to select a MSVC runtime library.
+
+.. note::
+
+ This variable has effect only when policy :policy:`CMP0091` is set to ``NEW``
+ prior to the first :command:`project` or :command:`enable_language` command
+ that enables a language using a compiler targeting the MSVC ABI.
diff --git a/Help/variable/CMAKE_NETRC.rst b/Help/variable/CMAKE_NETRC.rst
new file mode 100644
index 000000000..903ec31b6
--- /dev/null
+++ b/Help/variable/CMAKE_NETRC.rst
@@ -0,0 +1,9 @@
+CMAKE_NETRC
+-----------
+
+This variable is used to initialize the ``NETRC`` option for
+:command:`file(DOWNLOAD)` and :command:`file(UPLOAD)` commands and the
+module :module:`ExternalProject`. See those commands for additional
+information.
+
+The local option takes precedence over this variable.
diff --git a/Help/variable/CMAKE_NETRC_FILE.rst b/Help/variable/CMAKE_NETRC_FILE.rst
new file mode 100644
index 000000000..0f09afe86
--- /dev/null
+++ b/Help/variable/CMAKE_NETRC_FILE.rst
@@ -0,0 +1,9 @@
+CMAKE_NETRC_FILE
+----------------
+
+This variable is used to initialize the ``NETRC_FILE`` option for
+:command:`file(DOWNLOAD)` and :command:`file(UPLOAD)` commands and the
+module :module:`ExternalProject`. See those commands for additional
+information.
+
+The local option takes precedence over this variable.
diff --git a/Help/variable/CMAKE_OBJCXX_EXTENSIONS.rst b/Help/variable/CMAKE_OBJCXX_EXTENSIONS.rst
new file mode 100644
index 000000000..8afa6f275
--- /dev/null
+++ b/Help/variable/CMAKE_OBJCXX_EXTENSIONS.rst
@@ -0,0 +1,11 @@
+CMAKE_OBJCXX_EXTENSIONS
+-----------------------
+
+Default value for :prop_tgt:`OBJCXX_EXTENSIONS` property of targets.
+
+This variable is used to initialize the :prop_tgt:`OBJCXX_EXTENSIONS`
+property on all targets. See that target property for additional
+information.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features and a list of supported compilers.
diff --git a/Help/variable/CMAKE_OBJCXX_STANDARD.rst b/Help/variable/CMAKE_OBJCXX_STANDARD.rst
new file mode 100644
index 000000000..4e5016a40
--- /dev/null
+++ b/Help/variable/CMAKE_OBJCXX_STANDARD.rst
@@ -0,0 +1,11 @@
+CMAKE_OBJCXX_STANDARD
+---------------------
+
+Default value for :prop_tgt:`OBJCXX_STANDARD` property of targets.
+
+This variable is used to initialize the :prop_tgt:`OBJCXX_STANDARD`
+property on all targets. See that target property for additional
+information.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features and a list of supported compilers.
diff --git a/Help/variable/CMAKE_OBJCXX_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_OBJCXX_STANDARD_REQUIRED.rst
new file mode 100644
index 000000000..3a0602acf
--- /dev/null
+++ b/Help/variable/CMAKE_OBJCXX_STANDARD_REQUIRED.rst
@@ -0,0 +1,11 @@
+CMAKE_OBJCXX_STANDARD_REQUIRED
+------------------------------
+
+Default value for :prop_tgt:`OBJCXX_STANDARD_REQUIRED` property of targets.
+
+This variable is used to initialize the :prop_tgt:`OBJCXX_STANDARD_REQUIRED`
+property on all targets. See that target property for additional
+information.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features and a list of supported compilers.
diff --git a/Help/variable/CMAKE_OBJC_EXTENSIONS.rst b/Help/variable/CMAKE_OBJC_EXTENSIONS.rst
new file mode 100644
index 000000000..d9619d8f2
--- /dev/null
+++ b/Help/variable/CMAKE_OBJC_EXTENSIONS.rst
@@ -0,0 +1,11 @@
+CMAKE_OBJC_EXTENSIONS
+---------------------
+
+Default value for :prop_tgt:`OBJC_EXTENSIONS` property of targets.
+
+This variable is used to initialize the :prop_tgt:`OBJC_EXTENSIONS`
+property on all targets. See that target property for additional
+information.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features and a list of supported compilers.
diff --git a/Help/variable/CMAKE_OBJC_STANDARD.rst b/Help/variable/CMAKE_OBJC_STANDARD.rst
new file mode 100644
index 000000000..976c44145
--- /dev/null
+++ b/Help/variable/CMAKE_OBJC_STANDARD.rst
@@ -0,0 +1,11 @@
+CMAKE_OBJC_STANDARD
+-------------------
+
+Default value for :prop_tgt:`OBJC_STANDARD` property of targets.
+
+This variable is used to initialize the :prop_tgt:`OBJC_STANDARD`
+property on all targets. See that target property for additional
+information.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features and a list of supported compilers.
diff --git a/Help/variable/CMAKE_OBJC_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_OBJC_STANDARD_REQUIRED.rst
new file mode 100644
index 000000000..5c02096dc
--- /dev/null
+++ b/Help/variable/CMAKE_OBJC_STANDARD_REQUIRED.rst
@@ -0,0 +1,11 @@
+CMAKE_OBJC_STANDARD_REQUIRED
+----------------------------
+
+Default value for :prop_tgt:`OBJC_STANDARD_REQUIRED` property of targets.
+
+This variable is used to initialize the :prop_tgt:`OBJC_STANDARD_REQUIRED`
+property on all targets. See that target property for additional
+information.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features and a list of supported compilers.
diff --git a/Help/variable/CMAKE_OSX_ARCHITECTURES.rst b/Help/variable/CMAKE_OSX_ARCHITECTURES.rst
index 93916dd62..fdaca28e3 100644
--- a/Help/variable/CMAKE_OSX_ARCHITECTURES.rst
+++ b/Help/variable/CMAKE_OSX_ARCHITECTURES.rst
@@ -1,10 +1,10 @@
CMAKE_OSX_ARCHITECTURES
-----------------------
-Target specific architectures for OS X and iOS.
+Target specific architectures for macOS and iOS.
This variable is used to initialize the :prop_tgt:`OSX_ARCHITECTURES`
-property on each target as it is creaed. See that target property
+property on each target as it is created. See that target property
for additional information.
.. include:: CMAKE_OSX_VARIABLE.txt
diff --git a/Help/variable/CMAKE_OSX_DEPLOYMENT_TARGET.rst b/Help/variable/CMAKE_OSX_DEPLOYMENT_TARGET.rst
index 4fb2caa4f..9df5edda6 100644
--- a/Help/variable/CMAKE_OSX_DEPLOYMENT_TARGET.rst
+++ b/Help/variable/CMAKE_OSX_DEPLOYMENT_TARGET.rst
@@ -1,10 +1,12 @@
CMAKE_OSX_DEPLOYMENT_TARGET
---------------------------
-Specify the minimum version of OS X on which the target binaries are
-to be deployed. CMake uses this value for the ``-mmacosx-version-min``
-flag and to help choose the default SDK
-(see :variable:`CMAKE_OSX_SYSROOT`).
+Specify the minimum version of the target platform (e.g. macOS or iOS)
+on which the target binaries are to be deployed. CMake uses this
+variable value for the ``-mmacosx-version-min`` flag or their respective
+target platform equivalents. For older Xcode versions that shipped
+multiple macOS SDKs this variable also helps to choose the SDK in case
+:variable:`CMAKE_OSX_SYSROOT` is unset.
If not set explicitly the value is initialized by the
``MACOSX_DEPLOYMENT_TARGET`` environment variable, if set,
diff --git a/Help/variable/CMAKE_OSX_SYSROOT.rst b/Help/variable/CMAKE_OSX_SYSROOT.rst
index f1d58c6b5..db9fccdd1 100644
--- a/Help/variable/CMAKE_OSX_SYSROOT.rst
+++ b/Help/variable/CMAKE_OSX_SYSROOT.rst
@@ -1,7 +1,7 @@
CMAKE_OSX_SYSROOT
-----------------
-Specify the location or name of the OS X platform SDK to be used.
+Specify the location or name of the macOS platform SDK to be used.
CMake uses this value to compute the value of the ``-isysroot`` flag
or equivalent and to help the ``find_*`` commands locate files in
the SDK.
diff --git a/Help/variable/CMAKE_OSX_VARIABLE.txt b/Help/variable/CMAKE_OSX_VARIABLE.txt
index 385f871f3..16f3c1a1a 100644
--- a/Help/variable/CMAKE_OSX_VARIABLE.txt
+++ b/Help/variable/CMAKE_OSX_VARIABLE.txt
@@ -2,5 +2,10 @@ The value of this variable should be set prior to the first
:command:`project` or :command:`enable_language` command invocation
because it may influence configuration of the toolchain and flags.
It is intended to be set locally by the user creating a build tree.
+This variable should be set as a ``CACHE`` entry (or else CMake may
+remove it while initializing a cache entry of the same name).
-This variable is ignored on platforms other than OS X.
+Despite the ``OSX`` part in the variable name(s) they apply also to
+other SDKs than macOS like iOS, tvOS, or watchOS.
+
+This variable is ignored on platforms other than Apple.
diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
index aa23b65f9..fc52e7b5d 100644
--- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
+++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
@@ -19,6 +19,10 @@ warn by default:
policy :policy:`CMP0066`.
* ``CMAKE_POLICY_WARNING_CMP0067`` controls the warning for
policy :policy:`CMP0067`.
+* ``CMAKE_POLICY_WARNING_CMP0082`` controls the warning for
+ policy :policy:`CMP0082`.
+* ``CMAKE_POLICY_WARNING_CMP0089`` controls the warning for
+ policy :policy:`CMP0089`.
This variable should not be set by a project in CMake code. Project
developers running CMake may set this variable in their cache to
diff --git a/Help/variable/CMAKE_PREFIX_PATH.rst b/Help/variable/CMAKE_PREFIX_PATH.rst
index c2a4a6038..1d4fd0b42 100644
--- a/Help/variable/CMAKE_PREFIX_PATH.rst
+++ b/Help/variable/CMAKE_PREFIX_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_PREFIX_PATH
-----------------
-:ref:`;-list <CMake Language Lists>` of directories specifying installation
+:ref:`Semicolon-separated list <CMake Language Lists>` of directories specifying installation
*prefixes* to be searched by the :command:`find_package`,
:command:`find_program`, :command:`find_library`, :command:`find_file`, and
:command:`find_path` commands. Each command will add appropriate
diff --git a/Help/variable/CMAKE_PROGRAM_PATH.rst b/Help/variable/CMAKE_PROGRAM_PATH.rst
index 799e1192c..2d0c090df 100644
--- a/Help/variable/CMAKE_PROGRAM_PATH.rst
+++ b/Help/variable/CMAKE_PROGRAM_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_PROGRAM_PATH
------------------
-:ref:`;-list <CMake Language Lists>` of directories specifying a search 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`.
diff --git a/Help/variable/CMAKE_PROJECT_DESCRIPTION.rst b/Help/variable/CMAKE_PROJECT_DESCRIPTION.rst
index f1911eced..51b0592ea 100644
--- a/Help/variable/CMAKE_PROJECT_DESCRIPTION.rst
+++ b/Help/variable/CMAKE_PROJECT_DESCRIPTION.rst
@@ -1,7 +1,35 @@
CMAKE_PROJECT_DESCRIPTION
-------------------------
-The description of the current project.
+The description of the top level project.
-This specifies description of the current project from the closest inherited
-:command:`project` command.
+This variable holds the description of the project as specified in the top
+level CMakeLists.txt file by a :command:`project` command. In the event that
+the top level CMakeLists.txt contains multiple :command:`project` calls,
+the most recently called one from that top level CMakeLists.txt will determine
+the value that ``CMAKE_PROJECT_DESCRIPTION`` contains. For example, consider
+the following top level CMakeLists.txt:
+
+.. code-block:: cmake
+
+ cmake_minimum_required(VERSION 3.0)
+ project(First DESCRIPTION "I am First")
+ project(Second DESCRIPTION "I am Second")
+ add_subdirectory(sub)
+ project(Third DESCRIPTION "I am Third")
+
+And ``sub/CMakeLists.txt`` with the following contents:
+
+.. code-block:: cmake
+
+ project(SubProj DESCRIPTION "I am SubProj")
+ message("CMAKE_PROJECT_DESCRIPTION = ${CMAKE_PROJECT_DESCRIPTION}")
+
+The most recently seen :command:`project` command from the top level
+CMakeLists.txt would be ``project(Second ...)``, so this will print::
+
+ CMAKE_PROJECT_DESCRIPTION = I am Second
+
+To obtain the description from the most recent call to :command:`project` in
+the current directory scope or above, see the :variable:`PROJECT_DESCRIPTION`
+variable.
diff --git a/Help/variable/CMAKE_PROJECT_HOMEPAGE_URL.rst b/Help/variable/CMAKE_PROJECT_HOMEPAGE_URL.rst
new file mode 100644
index 000000000..ee0bf7c19
--- /dev/null
+++ b/Help/variable/CMAKE_PROJECT_HOMEPAGE_URL.rst
@@ -0,0 +1,35 @@
+CMAKE_PROJECT_HOMEPAGE_URL
+--------------------------
+
+The homepage URL of the top level project.
+
+This variable holds the homepage URL of the project as specified in the top
+level CMakeLists.txt file by a :command:`project` command. In the event that
+the top level CMakeLists.txt contains multiple :command:`project` calls,
+the most recently called one from that top level CMakeLists.txt will determine
+the value that ``CMAKE_PROJECT_HOMEPAGE_URL`` contains. For example, consider
+the following top level CMakeLists.txt:
+
+.. code-block:: cmake
+
+ cmake_minimum_required(VERSION 3.0)
+ project(First HOMEPAGE_URL "http://first.example.com")
+ project(Second HOMEPAGE_URL "http://second.example.com")
+ add_subdirectory(sub)
+ project(Third HOMEPAGE_URL "http://third.example.com")
+
+And ``sub/CMakeLists.txt`` with the following contents:
+
+.. code-block:: cmake
+
+ project(SubProj HOMEPAGE_URL "http://subproj.example.com")
+ message("CMAKE_PROJECT_HOMEPAGE_URL = ${CMAKE_PROJECT_HOMEPAGE_URL}")
+
+The most recently seen :command:`project` command from the top level
+CMakeLists.txt would be ``project(Second ...)``, so this will print::
+
+ CMAKE_PROJECT_HOMEPAGE_URL = http://second.example.com
+
+To obtain the homepage URL from the most recent call to :command:`project` in
+the current directory scope or above, see the :variable:`PROJECT_HOMEPAGE_URL`
+variable.
diff --git a/Help/variable/CMAKE_PROJECT_INCLUDE.rst b/Help/variable/CMAKE_PROJECT_INCLUDE.rst
new file mode 100644
index 000000000..965c94ee7
--- /dev/null
+++ b/Help/variable/CMAKE_PROJECT_INCLUDE.rst
@@ -0,0 +1,9 @@
+CMAKE_PROJECT_INCLUDE
+---------------------
+
+A CMake language file or module to be included as the last step of all
+:command:`project` command calls. This is intended for injecting custom code
+into project builds without modifying their source.
+
+See also the :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE` and
+:variable:`CMAKE_PROJECT_INCLUDE_BEFORE` variables.
diff --git a/Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst b/Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst
new file mode 100644
index 000000000..70b15e662
--- /dev/null
+++ b/Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst
@@ -0,0 +1,9 @@
+CMAKE_PROJECT_INCLUDE_BEFORE
+----------------------------
+
+A CMake language file or module to be included as the first step of all
+:command:`project` command calls. This is intended for injecting custom code
+into project builds without modifying their source.
+
+See also the :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE` and
+:variable:`CMAKE_PROJECT_INCLUDE` variables.
diff --git a/Help/variable/CMAKE_PROJECT_NAME.rst b/Help/variable/CMAKE_PROJECT_NAME.rst
index 431e9f302..94b8dbab8 100644
--- a/Help/variable/CMAKE_PROJECT_NAME.rst
+++ b/Help/variable/CMAKE_PROJECT_NAME.rst
@@ -1,7 +1,35 @@
CMAKE_PROJECT_NAME
------------------
-The name of the current project.
+The name of the top level project.
-This specifies name of the current project from the closest inherited
-:command:`project` command.
+This variable holds the name of the project as specified in the top
+level CMakeLists.txt file by a :command:`project` command. In the event that
+the top level CMakeLists.txt contains multiple :command:`project` calls,
+the most recently called one from that top level CMakeLists.txt will determine
+the name that ``CMAKE_PROJECT_NAME`` contains. For example, consider
+the following top level CMakeLists.txt:
+
+.. code-block:: cmake
+
+ cmake_minimum_required(VERSION 3.0)
+ project(First)
+ project(Second)
+ add_subdirectory(sub)
+ project(Third)
+
+And ``sub/CMakeLists.txt`` with the following contents:
+
+.. code-block:: cmake
+
+ project(SubProj)
+ message("CMAKE_PROJECT_NAME = ${CMAKE_PROJECT_NAME}")
+
+The most recently seen :command:`project` command from the top level
+CMakeLists.txt would be ``project(Second)``, so this will print::
+
+ CMAKE_PROJECT_NAME = Second
+
+To obtain the name from the most recent call to :command:`project` in
+the current directory scope or above, see the :variable:`PROJECT_NAME`
+variable.
diff --git a/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst
index ba9df5a34..3485c38e4 100644
--- a/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst
+++ b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst
@@ -1,6 +1,10 @@
CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE
------------------------------------
-A CMake language file or module to be included by the :command:`project`
-command. This is is intended for injecting custom code into project
-builds without modifying their source.
+A CMake language file or module to be included as the last step of any
+:command:`project` command calls that specify ``<PROJECT-NAME>`` as the project
+name. This is intended for injecting custom code into project builds without
+modifying their source.
+
+See also the :variable:`CMAKE_PROJECT_INCLUDE` and
+:variable:`CMAKE_PROJECT_INCLUDE_BEFORE` variables.
diff --git a/Help/variable/CMAKE_PROJECT_VERSION.rst b/Help/variable/CMAKE_PROJECT_VERSION.rst
new file mode 100644
index 000000000..4f8f55605
--- /dev/null
+++ b/Help/variable/CMAKE_PROJECT_VERSION.rst
@@ -0,0 +1,35 @@
+CMAKE_PROJECT_VERSION
+---------------------
+
+The version of the top level project.
+
+This variable holds the version of the project as specified in the top
+level CMakeLists.txt file by a :command:`project` command. In the event that
+the top level CMakeLists.txt contains multiple :command:`project` calls,
+the most recently called one from that top level CMakeLists.txt will determine
+the value that ``CMAKE_PROJECT_VERSION`` contains. For example, consider
+the following top level CMakeLists.txt:
+
+.. code-block:: cmake
+
+ cmake_minimum_required(VERSION 3.0)
+ project(First VERSION 1.2.3)
+ project(Second VERSION 3.4.5)
+ add_subdirectory(sub)
+ project(Third VERSION 6.7.8)
+
+And ``sub/CMakeLists.txt`` with the following contents:
+
+.. code-block:: cmake
+
+ project(SubProj VERSION 1)
+ message("CMAKE_PROJECT_VERSION = ${CMAKE_PROJECT_VERSION}")
+
+The most recently seen :command:`project` command from the top level
+CMakeLists.txt would be ``project(Second ...)``, so this will print::
+
+ CMAKE_PROJECT_VERSION = 3.4.5
+
+To obtain the version from the most recent call to :command:`project` in
+the current directory scope or above, see the :variable:`PROJECT_VERSION`
+variable.
diff --git a/Help/variable/CMAKE_PROJECT_VERSION_MAJOR.rst b/Help/variable/CMAKE_PROJECT_VERSION_MAJOR.rst
new file mode 100644
index 000000000..f1001acaf
--- /dev/null
+++ b/Help/variable/CMAKE_PROJECT_VERSION_MAJOR.rst
@@ -0,0 +1,9 @@
+CMAKE_PROJECT_VERSION_MAJOR
+---------------------------
+
+The major version of the top level project.
+
+This variable holds the major version of the project as specified in the top
+level CMakeLists.txt file by a :command:`project` command. Please see
+:variable:`CMAKE_PROJECT_VERSION` documentation for the behavior when
+multiple :command:`project` commands are used in the sources.
diff --git a/Help/variable/CMAKE_PROJECT_VERSION_MINOR.rst b/Help/variable/CMAKE_PROJECT_VERSION_MINOR.rst
new file mode 100644
index 000000000..13202be98
--- /dev/null
+++ b/Help/variable/CMAKE_PROJECT_VERSION_MINOR.rst
@@ -0,0 +1,9 @@
+CMAKE_PROJECT_VERSION_MINOR
+---------------------------
+
+The minor version of the top level project.
+
+This variable holds the minor version of the project as specified in the top
+level CMakeLists.txt file by a :command:`project` command. Please see
+:variable:`CMAKE_PROJECT_VERSION` documentation for the behavior when
+multiple :command:`project` commands are used in the sources.
diff --git a/Help/variable/CMAKE_PROJECT_VERSION_PATCH.rst b/Help/variable/CMAKE_PROJECT_VERSION_PATCH.rst
new file mode 100644
index 000000000..b8570d9fe
--- /dev/null
+++ b/Help/variable/CMAKE_PROJECT_VERSION_PATCH.rst
@@ -0,0 +1,9 @@
+CMAKE_PROJECT_VERSION_PATCH
+---------------------------
+
+The patch version of the top level project.
+
+This variable holds the patch version of the project as specified in the top
+level CMakeLists.txt file by a :command:`project` command. Please see
+:variable:`CMAKE_PROJECT_VERSION` documentation for the behavior when
+multiple :command:`project` commands are used in the sources.
diff --git a/Help/variable/CMAKE_PROJECT_VERSION_TWEAK.rst b/Help/variable/CMAKE_PROJECT_VERSION_TWEAK.rst
new file mode 100644
index 000000000..e1ad4be33
--- /dev/null
+++ b/Help/variable/CMAKE_PROJECT_VERSION_TWEAK.rst
@@ -0,0 +1,9 @@
+CMAKE_PROJECT_VERSION_TWEAK
+---------------------------
+
+The tweak version of the top level project.
+
+This variable holds the tweak version of the project as specified in the top
+level CMakeLists.txt file by a :command:`project` command. Please see
+:variable:`CMAKE_PROJECT_VERSION` documentation for the behavior when
+multiple :command:`project` commands are used in the sources.
diff --git a/Help/variable/CMAKE_RULE_MESSAGES.rst b/Help/variable/CMAKE_RULE_MESSAGES.rst
new file mode 100644
index 000000000..7460a81ee
--- /dev/null
+++ b/Help/variable/CMAKE_RULE_MESSAGES.rst
@@ -0,0 +1,8 @@
+CMAKE_RULE_MESSAGES
+-------------------
+
+Specify whether to report a message for each make rule.
+
+If set in the cache it is used to initialize the value of the :prop_gbl:`RULE_MESSAGES` property.
+Users may disable the option in their local build tree to disable granular messages
+and report only as each target completes in Makefile builds.
diff --git a/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst b/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst
index 44966f32f..b77bb686a 100644
--- a/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst
+++ b/Help/variable/CMAKE_SKIP_INSTALL_RULES.rst
@@ -3,6 +3,6 @@ CMAKE_SKIP_INSTALL_RULES
Whether to disable generation of installation rules.
-If ``TRUE``, cmake will neither generate installaton rules nor
+If ``TRUE``, CMake will neither generate installation rules nor
will it generate ``cmake_install.cmake`` files. This variable is ``FALSE`` by
default.
diff --git a/Help/variable/CMAKE_SOURCE_DIR.rst b/Help/variable/CMAKE_SOURCE_DIR.rst
index 416fbe1a8..d1f179838 100644
--- a/Help/variable/CMAKE_SOURCE_DIR.rst
+++ b/Help/variable/CMAKE_SOURCE_DIR.rst
@@ -7,7 +7,7 @@ This is the full path to the top level of the current CMake source
tree. For an in-source build, this would be the same as
:variable:`CMAKE_BINARY_DIR`.
-When run in -P script mode, CMake sets the variables
+When run in ``-P`` script mode, CMake sets the variables
:variable:`CMAKE_BINARY_DIR`, :variable:`CMAKE_SOURCE_DIR`,
:variable:`CMAKE_CURRENT_BINARY_DIR` and
:variable:`CMAKE_CURRENT_SOURCE_DIR` to the current working directory.
diff --git a/Help/variable/CMAKE_STAGING_PREFIX.rst b/Help/variable/CMAKE_STAGING_PREFIX.rst
index 1310e9471..bdb97faef 100644
--- a/Help/variable/CMAKE_STAGING_PREFIX.rst
+++ b/Help/variable/CMAKE_STAGING_PREFIX.rst
@@ -5,10 +5,10 @@ This variable may be set to a path to install to when cross-compiling. This can
be useful if the path in :variable:`CMAKE_SYSROOT` is read-only, or otherwise
should remain pristine.
-The ``CMAKE_STAGING_PREFIX`` location is also used as a search prefix by the
-``find_*`` commands. This can be controlled by setting the
+The :variable:`CMAKE_STAGING_PREFIX` location is also used as a search prefix
+by the ``find_*`` commands. This can be controlled by setting the
:variable:`CMAKE_FIND_NO_INSTALL_PREFIX` variable.
-If any RPATH/RUNPATH entries passed to the linker contain the
-``CMAKE_STAGING_PREFIX``, the matching path fragments are replaced with the
-:variable:`CMAKE_INSTALL_PREFIX`.
+If any ``RPATH``/``RUNPATH`` entries passed to the linker contain the
+:variable:`CMAKE_STAGING_PREFIX`, the matching path fragments are replaced
+with the :variable:`CMAKE_INSTALL_PREFIX`.
diff --git a/Help/variable/CMAKE_STATIC_LINKER_FLAGS.rst b/Help/variable/CMAKE_STATIC_LINKER_FLAGS.rst
index 9c38673aa..1a810ce14 100644
--- a/Help/variable/CMAKE_STATIC_LINKER_FLAGS.rst
+++ b/Help/variable/CMAKE_STATIC_LINKER_FLAGS.rst
@@ -1,6 +1,12 @@
CMAKE_STATIC_LINKER_FLAGS
-------------------------
-Linker flags to be used to create static libraries.
+Flags to be used to create static libraries. These flags will be passed
+to the archiver when creating a static library.
-These flags will be used by the linker when creating a static library.
+See also :variable:`CMAKE_STATIC_LINKER_FLAGS_<CONFIG>`.
+
+.. note::
+ Static libraries do not actually link. They are essentially archives
+ of object files. The use of the name "linker" in the name of this
+ variable is kept for compatibility.
diff --git a/Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst b/Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst
index b9f8003c7..e561dc645 100644
--- a/Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst
+++ b/Help/variable/CMAKE_STATIC_LINKER_FLAGS_CONFIG.rst
@@ -1,7 +1,13 @@
CMAKE_STATIC_LINKER_FLAGS_<CONFIG>
----------------------------------
-Flags to be used when linking a static library.
+Flags to be used to create static libraries. These flags will be passed
+to the archiver when creating a static library in the ``<CONFIG>``
+configuration.
-Same as ``CMAKE_C_FLAGS_*`` but used by the linker when creating static
-libraries.
+See also :variable:`CMAKE_STATIC_LINKER_FLAGS`.
+
+.. note::
+ Static libraries do not actually link. They are essentially archives
+ of object files. The use of the name "linker" in the name of this
+ variable is kept for compatibility.
diff --git a/Help/variable/CMAKE_SUPPRESS_REGENERATION.rst b/Help/variable/CMAKE_SUPPRESS_REGENERATION.rst
new file mode 100644
index 000000000..96184dd5e
--- /dev/null
+++ b/Help/variable/CMAKE_SUPPRESS_REGENERATION.rst
@@ -0,0 +1,11 @@
+CMAKE_SUPPRESS_REGENERATION
+---------------------------
+
+If ``CMAKE_SUPPRESS_REGENERATION`` is ``OFF``, which is default, then CMake
+adds a special target on which all other targets depend that checks the build
+system and optionally re-runs CMake to regenerate the build system when
+the target specification source changes.
+
+If this variable evaluates to ``ON`` at the end of the top-level
+``CMakeLists.txt`` file, CMake will not add the regeneration target to the
+build system or perform any build system checks.
diff --git a/Help/variable/CMAKE_SYSROOT.rst b/Help/variable/CMAKE_SYSROOT.rst
index 64f81bbc2..35b944fa4 100644
--- a/Help/variable/CMAKE_SYSROOT.rst
+++ b/Help/variable/CMAKE_SYSROOT.rst
@@ -4,8 +4,8 @@ CMAKE_SYSROOT
Path to pass to the compiler in the ``--sysroot`` flag.
The ``CMAKE_SYSROOT`` content is passed to the compiler in the ``--sysroot``
-flag, if supported. The path is also stripped from the RPATH/RUNPATH if
-necessary on installation. The ``CMAKE_SYSROOT`` is also used to prefix
+flag, if supported. The path is also stripped from the ``RPATH``/``RUNPATH``
+if necessary on installation. The ``CMAKE_SYSROOT`` is also used to prefix
paths searched by the ``find_*`` commands.
This variable may only be set in a toolchain file specified by
diff --git a/Help/variable/CMAKE_SYSTEM_APPBUNDLE_PATH.rst b/Help/variable/CMAKE_SYSTEM_APPBUNDLE_PATH.rst
index 3c6687c6e..666af4615 100644
--- a/Help/variable/CMAKE_SYSTEM_APPBUNDLE_PATH.rst
+++ b/Help/variable/CMAKE_SYSTEM_APPBUNDLE_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_SYSTEM_APPBUNDLE_PATH
---------------------------
-Search path for OS X application bundles used by the :command:`find_program`,
+Search path for macOS application bundles used by the :command:`find_program`,
and :command:`find_package` commands. By default it contains the standard
directories for the current system. It is *not* intended to be modified by
the project, use :variable:`CMAKE_APPBUNDLE_PATH` for this.
diff --git a/Help/variable/CMAKE_SYSTEM_FRAMEWORK_PATH.rst b/Help/variable/CMAKE_SYSTEM_FRAMEWORK_PATH.rst
index 1e8b0d947..14ba18eff 100644
--- a/Help/variable/CMAKE_SYSTEM_FRAMEWORK_PATH.rst
+++ b/Help/variable/CMAKE_SYSTEM_FRAMEWORK_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_SYSTEM_FRAMEWORK_PATH
---------------------------
-Search path for OS X frameworks used by the :command:`find_library`,
+Search path for macOS frameworks used by the :command:`find_library`,
:command:`find_package`, :command:`find_path`, and :command:`find_file`
commands. By default it contains the standard directories for the
current system. It is *not* intended to be modified by the project,
diff --git a/Help/variable/CMAKE_SYSTEM_IGNORE_PATH.rst b/Help/variable/CMAKE_SYSTEM_IGNORE_PATH.rst
index 4ad7e33ce..6afbd337a 100644
--- a/Help/variable/CMAKE_SYSTEM_IGNORE_PATH.rst
+++ b/Help/variable/CMAKE_SYSTEM_IGNORE_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_SYSTEM_IGNORE_PATH
------------------------
-:ref:`;-list <CMake Language Lists>` of directories to be *ignored* by
+:ref:`Semicolon-separated list <CMake Language Lists>` of directories to be *ignored* by
the :command:`find_program`, :command:`find_library`, :command:`find_file`,
and :command:`find_path` commands. This is useful in cross-compiling
environments where some system directories contain incompatible but
diff --git a/Help/variable/CMAKE_SYSTEM_INCLUDE_PATH.rst b/Help/variable/CMAKE_SYSTEM_INCLUDE_PATH.rst
index 2c14345c0..680404ef5 100644
--- a/Help/variable/CMAKE_SYSTEM_INCLUDE_PATH.rst
+++ b/Help/variable/CMAKE_SYSTEM_INCLUDE_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_SYSTEM_INCLUDE_PATH
-------------------------
-:ref:`;-list <CMake Language Lists>` of directories specifying a search 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
this contains the standard directories for the current system. It is *not*
intended to be modified by the project; use :variable:`CMAKE_INCLUDE_PATH` for
diff --git a/Help/variable/CMAKE_SYSTEM_LIBRARY_PATH.rst b/Help/variable/CMAKE_SYSTEM_LIBRARY_PATH.rst
index 3969cb94c..116832bf9 100644
--- a/Help/variable/CMAKE_SYSTEM_LIBRARY_PATH.rst
+++ b/Help/variable/CMAKE_SYSTEM_LIBRARY_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_SYSTEM_LIBRARY_PATH
-------------------------
-:ref:`;-list <CMake Language Lists>` of directories specifying a search path
+:ref:`Semicolon-separated list <CMake Language Lists>` of directories specifying a search path
for the :command:`find_library` command. By default this contains the
standard directories for the current system. It is *not* intended to be
modified by the project; use :variable:`CMAKE_LIBRARY_PATH` for this.
diff --git a/Help/variable/CMAKE_SYSTEM_NAME.rst b/Help/variable/CMAKE_SYSTEM_NAME.rst
index c3a42e5b4..fef53eecb 100644
--- a/Help/variable/CMAKE_SYSTEM_NAME.rst
+++ b/Help/variable/CMAKE_SYSTEM_NAME.rst
@@ -4,6 +4,9 @@ CMAKE_SYSTEM_NAME
The name of the operating system for which CMake is to build.
See the :variable:`CMAKE_SYSTEM_VERSION` variable for the OS version.
+Note that ``CMAKE_SYSTEM_NAME`` is not set to anything by default when running
+in script mode, since it's not building anything.
+
System Name for Host Builds
^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst b/Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst
index e74dfad18..87a9d06a8 100644
--- a/Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst
+++ b/Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_SYSTEM_PREFIX_PATH
------------------------
-:ref:`;-list <CMake Language Lists>` of directories specifying installation
+:ref:`Semicolon-separated list <CMake Language Lists>` of directories specifying installation
*prefixes* to be searched by the :command:`find_package`,
:command:`find_program`, :command:`find_library`, :command:`find_file`, and
:command:`find_path` commands. Each command will add appropriate
@@ -10,8 +10,11 @@ documentation.
By default this contains the standard directories for the current system, the
:variable:`CMAKE_INSTALL_PREFIX`, and the :variable:`CMAKE_STAGING_PREFIX`.
-It is *not* intended to be modified by the project; use
-:variable:`CMAKE_PREFIX_PATH` for this.
+The installation and staging prefixes may be excluded by setting
+the :variable:`CMAKE_FIND_NO_INSTALL_PREFIX` variable.
+
+``CMAKE_SYSTEM_PREFIX_PATH`` is *not* intended to be modified by the project;
+use :variable:`CMAKE_PREFIX_PATH` for this.
See also :variable:`CMAKE_SYSTEM_INCLUDE_PATH`,
:variable:`CMAKE_SYSTEM_LIBRARY_PATH`, :variable:`CMAKE_SYSTEM_PROGRAM_PATH`,
diff --git a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst
index 09280dee6..8ad89f128 100644
--- a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst
+++ b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst
@@ -6,5 +6,3 @@ The name of the CPU CMake is building for.
This variable is the same as :variable:`CMAKE_HOST_SYSTEM_PROCESSOR` if
you build for the host system instead of the target system when
cross compiling.
-
-* The :generator:`Green Hills MULTI` generator sets this to ``ARM`` by default.
diff --git a/Help/variable/CMAKE_SYSTEM_PROGRAM_PATH.rst b/Help/variable/CMAKE_SYSTEM_PROGRAM_PATH.rst
index cf1b83e80..9b7036182 100644
--- a/Help/variable/CMAKE_SYSTEM_PROGRAM_PATH.rst
+++ b/Help/variable/CMAKE_SYSTEM_PROGRAM_PATH.rst
@@ -1,7 +1,7 @@
CMAKE_SYSTEM_PROGRAM_PATH
-------------------------
-:ref:`;-list <CMake Language Lists>` of directories specifying a search path
+:ref:`Semicolon-separated list <CMake Language Lists>` of directories specifying a search path
for the :command:`find_program` command. By default this contains the
standard directories for the current system. It is *not* intended to be
modified by the project; use :variable:`CMAKE_PROGRAM_PATH` for this.
diff --git a/Help/variable/CMAKE_Swift_LANGUAGE_VERSION.rst b/Help/variable/CMAKE_Swift_LANGUAGE_VERSION.rst
index 50121e286..b4a74eb03 100644
--- a/Help/variable/CMAKE_Swift_LANGUAGE_VERSION.rst
+++ b/Help/variable/CMAKE_Swift_LANGUAGE_VERSION.rst
@@ -1,5 +1,9 @@
CMAKE_Swift_LANGUAGE_VERSION
----------------------------
-Set to the Swift language version number. If not set, the legacy "2.3"
-version is assumed.
+Set to the Swift language version number. If not set, the oldest legacy
+version known to be available in the host Xcode version is assumed:
+
+* Swift ``4.0`` for Xcode 10.2 and above.
+* Swift ``3.0`` for Xcode 8.3 and above.
+* Swift ``2.3`` for Xcode 8.2 and below.
diff --git a/Help/variable/CMAKE_Swift_MODULE_DIRECTORY.rst b/Help/variable/CMAKE_Swift_MODULE_DIRECTORY.rst
new file mode 100644
index 000000000..b11253bc1
--- /dev/null
+++ b/Help/variable/CMAKE_Swift_MODULE_DIRECTORY.rst
@@ -0,0 +1,8 @@
+CMAKE_Swift_MODULE_DIRECTORY
+----------------------------
+
+Swift module output directory.
+
+This variable is used to initialise the :prop_tgt:`Swift_MODULE_DIRECTORY`
+property on all the targets. See the target property for additional
+information.
diff --git a/Help/variable/CMAKE_Swift_NUM_THREADS.rst b/Help/variable/CMAKE_Swift_NUM_THREADS.rst
new file mode 100644
index 000000000..cb3367855
--- /dev/null
+++ b/Help/variable/CMAKE_Swift_NUM_THREADS.rst
@@ -0,0 +1,8 @@
+CMAKE_Swift_NUM_THREADS
+-----------------------
+
+Number of threads for parallel compilation for Swift targets.
+
+This variable controls the number of parallel jobs that the swift driver creates
+for building targets. If not specified, it will default to the number of
+logical CPUs on the host.
diff --git a/Help/variable/CMAKE_UNITY_BUILD.rst b/Help/variable/CMAKE_UNITY_BUILD.rst
new file mode 100644
index 000000000..a86cd67ff
--- /dev/null
+++ b/Help/variable/CMAKE_UNITY_BUILD.rst
@@ -0,0 +1,20 @@
+CMAKE_UNITY_BUILD
+-----------------
+
+This variable is used to initialize the :prop_tgt:`UNITY_BUILD`
+property of targets when they are created. Setting it to true
+enables batch compilation of multiple sources within each target.
+This feature is known as a *Unity* or *Jumbo* build.
+
+Projects should not set this variable, it is intended as a developer
+control to be set on the :manual:`cmake(1)` command line or other
+equivalent methods. The developer must have the ability to enable or
+disable unity builds according to the capabilities of their own machine
+and compiler.
+
+By default, this variable is not set, which will result in unity builds
+being disabled.
+
+.. note::
+ This option currently does not work well in combination with
+ the :variable:`CMAKE_EXPORT_COMPILE_COMMANDS` variable.
diff --git a/Help/variable/CMAKE_UNITY_BUILD_BATCH_SIZE.rst b/Help/variable/CMAKE_UNITY_BUILD_BATCH_SIZE.rst
new file mode 100644
index 000000000..7988d4b28
--- /dev/null
+++ b/Help/variable/CMAKE_UNITY_BUILD_BATCH_SIZE.rst
@@ -0,0 +1,7 @@
+CMAKE_UNITY_BUILD_BATCH_SIZE
+----------------------------
+
+This variable is used to initialize the :prop_tgt:`UNITY_BUILD_BATCH_SIZE`
+property of targets when they are created. It specifies the default upper
+limit on the number of source files that may be combined in any one unity
+source file when unity builds are enabled for a target.
diff --git a/Help/variable/CMAKE_VS_DEVENV_COMMAND.rst b/Help/variable/CMAKE_VS_DEVENV_COMMAND.rst
index 51b42dd4b..f109a9eda 100644
--- a/Help/variable/CMAKE_VS_DEVENV_COMMAND.rst
+++ b/Help/variable/CMAKE_VS_DEVENV_COMMAND.rst
@@ -1,7 +1,7 @@
CMAKE_VS_DEVENV_COMMAND
-----------------------
-The generators for :generator:`Visual Studio 8 2005` and above set this
+The generators for :generator:`Visual Studio 9 2008` and above set this
variable to the ``devenv.com`` command installed with the corresponding
Visual Studio version. Note that this variable may be empty on
Visual Studio Express editions because they do not provide this tool.
diff --git a/Help/variable/CMAKE_VS_GLOBALS.rst b/Help/variable/CMAKE_VS_GLOBALS.rst
new file mode 100644
index 000000000..83777b619
--- /dev/null
+++ b/Help/variable/CMAKE_VS_GLOBALS.rst
@@ -0,0 +1,21 @@
+CMAKE_VS_GLOBALS
+----------------
+
+List of ``Key=Value`` records to be set per target as target properties
+:prop_tgt:`VS_GLOBAL_<variable>` with ``variable=Key`` and value ``Value``.
+
+For example:
+
+.. code-block:: cmake
+
+ set(CMAKE_VS_GLOBALS
+ "DefaultLanguage=en-US"
+ "MinimumVisualStudioVersion=14.0"
+ )
+
+will set properties ``VS_GLOBAL_DefaultLanguage`` to ``en-US`` and
+``VS_GLOBAL_MinimumVisualStudioVersion`` to ``14.0`` for all targets
+(except for ``INTERFACE`` libraries).
+
+This variable is meant to be set by a
+:variable:`toolchain file <CMAKE_TOOLCHAIN_FILE>`.
diff --git a/Help/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst b/Help/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst
index 6d196f917..ceedf2861 100644
--- a/Help/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst
+++ b/Help/variable/CMAKE_VS_INTEL_Fortran_PROJECT_VERSION.rst
@@ -1,7 +1,7 @@
CMAKE_VS_INTEL_Fortran_PROJECT_VERSION
--------------------------------------
-When generating for :generator:`Visual Studio 8 2005` or greater with the Intel
+When generating for :generator:`Visual Studio 9 2008` or greater with the Intel
Fortran plugin installed, this specifies the ``.vfproj`` project file format
version. This is intended for internal use by CMake and should not be
used by project code.
diff --git a/Help/variable/CMAKE_VS_JUST_MY_CODE_DEBUGGING.rst b/Help/variable/CMAKE_VS_JUST_MY_CODE_DEBUGGING.rst
new file mode 100644
index 000000000..546cdf492
--- /dev/null
+++ b/Help/variable/CMAKE_VS_JUST_MY_CODE_DEBUGGING.rst
@@ -0,0 +1,8 @@
+CMAKE_VS_JUST_MY_CODE_DEBUGGING
+-------------------------------
+
+Enable Just My Code with Visual Studio debugger.
+
+This variable is used to initialize the :prop_tgt:`VS_JUST_MY_CODE_DEBUGGING`
+property on all targets when they are created. See that target property for
+additional information.
diff --git a/Help/variable/CMAKE_VS_PLATFORM_NAME.rst b/Help/variable/CMAKE_VS_PLATFORM_NAME.rst
index a532743fb..7a4642a31 100644
--- a/Help/variable/CMAKE_VS_PLATFORM_NAME.rst
+++ b/Help/variable/CMAKE_VS_PLATFORM_NAME.rst
@@ -1,8 +1,10 @@
CMAKE_VS_PLATFORM_NAME
----------------------
-Visual Studio target platform name.
+Visual Studio target platform name used by the current generator.
VS 8 and above allow project files to specify a target platform.
CMake provides the name of the chosen platform in this variable.
See the :variable:`CMAKE_GENERATOR_PLATFORM` variable for details.
+
+See also the :variable:`CMAKE_VS_PLATFORM_NAME_DEFAULT` variable.
diff --git a/Help/variable/CMAKE_VS_PLATFORM_NAME_DEFAULT.rst b/Help/variable/CMAKE_VS_PLATFORM_NAME_DEFAULT.rst
new file mode 100644
index 000000000..c18e6fd37
--- /dev/null
+++ b/Help/variable/CMAKE_VS_PLATFORM_NAME_DEFAULT.rst
@@ -0,0 +1,9 @@
+CMAKE_VS_PLATFORM_NAME_DEFAULT
+------------------------------
+
+Default for the Visual Studio target platform name for the current generator
+without considering the value of the :variable:`CMAKE_GENERATOR_PLATFORM`
+variable. For :ref:`Visual Studio Generators` for VS 2017 and below this is
+always ``Win32``. For VS 2019 and above this is based on the host platform.
+
+See also the :variable:`CMAKE_VS_PLATFORM_NAME` variable.
diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA.rst
index 1604a7667..67b7f7401 100644
--- a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA.rst
+++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA.rst
@@ -6,7 +6,9 @@ NVIDIA CUDA Toolkit version whose Visual Studio toolset to use.
The :ref:`Visual Studio Generators` for VS 2010 and above support using
a CUDA toolset provided by a CUDA Toolkit. The toolset version number
may be specified by a field in :variable:`CMAKE_GENERATOR_TOOLSET` of
-the form ``cuda=8.0``. If none is specified CMake will choose a default
-version. CMake provides the selected CUDA toolset version in this variable.
+the form ``cuda=8.0``. Or it is automatically detected if a path to
+a standalone CUDA directory is specified in the form ``cuda=C:\path\to\cuda``.
+If none is specified CMake will choose a default version.
+CMake provides the selected CUDA toolset version in this variable.
The value may be empty if no CUDA Toolkit with Visual Studio integration
is installed.
diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst
new file mode 100644
index 000000000..060648afc
--- /dev/null
+++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst
@@ -0,0 +1,16 @@
+CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR
+-----------------------------------------
+
+Path to standalone NVIDIA CUDA Toolkit (eg. extracted from installer).
+
+The :ref:`Visual Studio Generators` for VS 2010 and above support using
+a standalone (non-installed) NVIDIA CUDA toolkit. The path
+may be specified by a field in :variable:`CMAKE_GENERATOR_TOOLSET` of
+the form ``cuda=C:\path\to\cuda``. The given directory must at least
+contain a folder ``.\nvcc`` and must provide Visual Studio integration
+files in path ``.\CUDAVisualStudioIntegration\extras\
+visual_studio_integration\MSBuildExtensions\``. One can create a standalone
+CUDA toolkit directory by either opening a installer with 7zip or
+copying the files that are extracted by the running installer.
+The value may be empty if no path to a standalone CUDA Toolkit was
+specified.
diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst
index 9b59c52a6..99ac90ddc 100644
--- a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst
+++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE.rst
@@ -3,8 +3,8 @@ CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE
Visual Studio preferred tool architecture.
-The :ref:`Visual Studio Generators` for VS 2013 and above support optional
-selection of a 64-bit toolchain on 64-bit hosts by specifying a ``host=x64``
-value in the :variable:`CMAKE_GENERATOR_TOOLSET` option. CMake provides
-the selected toolchain architecture preference in this variable (either
-``x64`` or empty).
+The :ref:`Visual Studio Generators` for VS 2013 and above support using
+either the 32-bit or 64-bit host toolchains by specifying a ``host=x86``
+or ``host=x64`` value in the :variable:`CMAKE_GENERATOR_TOOLSET` option.
+CMake provides the selected toolchain architecture preference in this
+variable (``x86``, ``x64``, or empty).
diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_VERSION.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_VERSION.rst
new file mode 100644
index 000000000..4d9b978f4
--- /dev/null
+++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_VERSION.rst
@@ -0,0 +1,11 @@
+CMAKE_VS_PLATFORM_TOOLSET_VERSION
+---------------------------------
+
+Visual Studio Platform Toolset version.
+
+The :ref:`Visual Studio Generators` for VS 2017 and above allow to
+select minor versions of the same toolset. The toolset version number
+may be specified by a field in :variable:`CMAKE_GENERATOR_TOOLSET` of
+the form ``version=14.11``. If none is specified CMake will choose a default
+toolset. The value may be empty if no minor version was selected and the
+default is used.
diff --git a/Help/variable/CMAKE_VS_SDK_EXCLUDE_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_EXCLUDE_DIRECTORIES.rst
new file mode 100644
index 000000000..36c4dccca
--- /dev/null
+++ b/Help/variable/CMAKE_VS_SDK_EXCLUDE_DIRECTORIES.rst
@@ -0,0 +1,4 @@
+CMAKE_VS_SDK_EXCLUDE_DIRECTORIES
+--------------------------------
+
+This variable allows to override Visual Studio default Exclude Directories.
diff --git a/Help/variable/CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES.rst
new file mode 100644
index 000000000..3ec755ba9
--- /dev/null
+++ b/Help/variable/CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES.rst
@@ -0,0 +1,4 @@
+CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES
+-----------------------------------
+
+This variable allows to override Visual Studio default Executable Directories.
diff --git a/Help/variable/CMAKE_VS_SDK_INCLUDE_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_INCLUDE_DIRECTORIES.rst
new file mode 100644
index 000000000..da10bdea9
--- /dev/null
+++ b/Help/variable/CMAKE_VS_SDK_INCLUDE_DIRECTORIES.rst
@@ -0,0 +1,4 @@
+CMAKE_VS_SDK_INCLUDE_DIRECTORIES
+--------------------------------
+
+This variable allows to override Visual Studio default Include Directories.
diff --git a/Help/variable/CMAKE_VS_SDK_LIBRARY_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_LIBRARY_DIRECTORIES.rst
new file mode 100644
index 000000000..b33754a47
--- /dev/null
+++ b/Help/variable/CMAKE_VS_SDK_LIBRARY_DIRECTORIES.rst
@@ -0,0 +1,4 @@
+CMAKE_VS_SDK_LIBRARY_DIRECTORIES
+--------------------------------
+
+This variable allows to override Visual Studio default Library Directories.
diff --git a/Help/variable/CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES.rst
new file mode 100644
index 000000000..b0222157b
--- /dev/null
+++ b/Help/variable/CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES.rst
@@ -0,0 +1,5 @@
+CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES
+--------------------------------------
+
+This variable allows to override Visual Studio default Library WinRT
+Directories.
diff --git a/Help/variable/CMAKE_VS_SDK_REFERENCE_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_REFERENCE_DIRECTORIES.rst
new file mode 100644
index 000000000..c03f0aed2
--- /dev/null
+++ b/Help/variable/CMAKE_VS_SDK_REFERENCE_DIRECTORIES.rst
@@ -0,0 +1,4 @@
+CMAKE_VS_SDK_REFERENCE_DIRECTORIES
+----------------------------------
+
+This variable allows to override Visual Studio default Reference Directories.
diff --git a/Help/variable/CMAKE_VS_SDK_SOURCE_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_SOURCE_DIRECTORIES.rst
new file mode 100644
index 000000000..0c73f064a
--- /dev/null
+++ b/Help/variable/CMAKE_VS_SDK_SOURCE_DIRECTORIES.rst
@@ -0,0 +1,4 @@
+CMAKE_VS_SDK_SOURCE_DIRECTORIES
+-------------------------------
+
+This variable allows to override Visual Studio default Source Directories.
diff --git a/Help/variable/CMAKE_VS_WINRT_BY_DEFAULT.rst b/Help/variable/CMAKE_VS_WINRT_BY_DEFAULT.rst
new file mode 100644
index 000000000..2ba8fe27e
--- /dev/null
+++ b/Help/variable/CMAKE_VS_WINRT_BY_DEFAULT.rst
@@ -0,0 +1,8 @@
+CMAKE_VS_WINRT_BY_DEFAULT
+-------------------------
+
+Tell :ref:`Visual Studio Generators` for VS 2010 and above that the
+target platform compiles as WinRT by default (compiles with ``/ZW``).
+
+This variable is meant to be set by a
+:variable:`toolchain file <CMAKE_TOOLCHAIN_FILE>` for such platforms.
diff --git a/Help/variable/CMAKE_XCODE_GENERATE_SCHEME.rst b/Help/variable/CMAKE_XCODE_GENERATE_SCHEME.rst
index c9fcc92e0..5b1a003f0 100644
--- a/Help/variable/CMAKE_XCODE_GENERATE_SCHEME.rst
+++ b/Help/variable/CMAKE_XCODE_GENERATE_SCHEME.rst
@@ -1,11 +1,10 @@
CMAKE_XCODE_GENERATE_SCHEME
---------------------------
-If enabled, the Xcode generator will generate schema files. Those are
+If enabled, the :generator:`Xcode` generator will generate schema files. These
are useful to invoke analyze, archive, build-for-testing and test
actions from the command line.
-.. note::
-
- The Xcode Schema Generator is still experimental and subject to
- change.
+This variable initializes the
+:prop_tgt:`XCODE_GENERATE_SCHEME`
+target property on all targets.
diff --git a/Help/variable/CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY.rst b/Help/variable/CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY.rst
new file mode 100644
index 000000000..ea3e240b1
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY.rst
@@ -0,0 +1,9 @@
+CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY
+-------------------------------------------
+
+If enabled, the :generator:`Xcode` generator will generate only a
+single Xcode project file for the topmost :command:`project()` command
+instead of generating one for every ``project()`` command.
+
+This could be useful to speed up the CMake generation step for
+large projects and to work-around a bug in the ``ZERO_CHECK`` logic.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER.rst b/Help/variable/CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER.rst
new file mode 100644
index 000000000..b972ba573
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER.rst
@@ -0,0 +1,12 @@
+CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER
+------------------------------------
+
+Whether to enable ``Address Sanitizer`` in the Diagnostics
+section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_ADDRESS_SANITIZER`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN.rst b/Help/variable/CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN.rst
new file mode 100644
index 000000000..59eb32df3
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN.rst
@@ -0,0 +1,12 @@
+CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN
+-----------------------------------------------------
+
+Whether to enable ``Detect use of stack after return``
+in the Diagnostics section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING.rst b/Help/variable/CMAKE_XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING.rst
new file mode 100644
index 000000000..a264d36c8
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING.rst
@@ -0,0 +1,13 @@
+CMAKE_XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING
+--------------------------------------------
+
+Whether to enable
+``Allow debugging when using document Versions Browser``
+in the Options section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER.rst b/Help/variable/CMAKE_XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER.rst
new file mode 100644
index 000000000..71bcf4235
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER.rst
@@ -0,0 +1,12 @@
+CMAKE_XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER
+----------------------------------------------
+
+Whether to disable the ``Main Thread Checker``
+in the Diagnostics section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS.rst b/Help/variable/CMAKE_XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS.rst
new file mode 100644
index 000000000..53f55e604
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS.rst
@@ -0,0 +1,12 @@
+CMAKE_XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS
+----------------------------------------
+
+Whether to enable ``Dynamic Library Loads``
+in the Diagnostics section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE.rst b/Help/variable/CMAKE_XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE.rst
new file mode 100644
index 000000000..784ceb6b7
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE.rst
@@ -0,0 +1,12 @@
+CMAKE_XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE
+-------------------------------------------
+
+Whether to enable ``Dynamic Linker API usage``
+in the Diagnostics section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_GUARD_MALLOC.rst b/Help/variable/CMAKE_XCODE_SCHEME_GUARD_MALLOC.rst
new file mode 100644
index 000000000..9350244b0
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_GUARD_MALLOC.rst
@@ -0,0 +1,12 @@
+CMAKE_XCODE_SCHEME_GUARD_MALLOC
+-------------------------------
+
+Whether to enable ``Guard Malloc``
+in the Diagnostics section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_GUARD_MALLOC`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP.rst b/Help/variable/CMAKE_XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP.rst
new file mode 100644
index 000000000..45a2dad69
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP.rst
@@ -0,0 +1,13 @@
+CMAKE_XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP
+-------------------------------------------
+
+Whether to enable the ``Main Thread Checker`` option
+``Pause on issues``
+in the Diagnostics section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_MALLOC_GUARD_EDGES.rst b/Help/variable/CMAKE_XCODE_SCHEME_MALLOC_GUARD_EDGES.rst
new file mode 100644
index 000000000..94d1c61fb
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_MALLOC_GUARD_EDGES.rst
@@ -0,0 +1,12 @@
+CMAKE_XCODE_SCHEME_MALLOC_GUARD_EDGES
+-------------------------------------
+
+Whether to enable ``Malloc Guard Edges``
+in the Diagnostics section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_MALLOC_GUARD_EDGES`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_MALLOC_SCRIBBLE.rst b/Help/variable/CMAKE_XCODE_SCHEME_MALLOC_SCRIBBLE.rst
new file mode 100644
index 000000000..9bf0eb419
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_MALLOC_SCRIBBLE.rst
@@ -0,0 +1,12 @@
+CMAKE_XCODE_SCHEME_MALLOC_SCRIBBLE
+----------------------------------
+
+Whether to enable ``Malloc Scribble``
+in the Diagnostics section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_MALLOC_SCRIBBLE`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_MALLOC_STACK.rst b/Help/variable/CMAKE_XCODE_SCHEME_MALLOC_STACK.rst
new file mode 100644
index 000000000..4cc21ee2b
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_MALLOC_STACK.rst
@@ -0,0 +1,12 @@
+CMAKE_XCODE_SCHEME_MALLOC_STACK
+-------------------------------
+
+Whether to enable ``Malloc Stack`` in the Diagnostics
+section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_MALLOC_STACK`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_THREAD_SANITIZER.rst b/Help/variable/CMAKE_XCODE_SCHEME_THREAD_SANITIZER.rst
new file mode 100644
index 000000000..6d1b56eea
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_THREAD_SANITIZER.rst
@@ -0,0 +1,12 @@
+CMAKE_XCODE_SCHEME_THREAD_SANITIZER
+-----------------------------------
+
+Whether to enable ``Thread Sanitizer`` in the Diagnostics
+section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_THREAD_SANITIZER`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_THREAD_SANITIZER_STOP.rst b/Help/variable/CMAKE_XCODE_SCHEME_THREAD_SANITIZER_STOP.rst
new file mode 100644
index 000000000..de40478ea
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_THREAD_SANITIZER_STOP.rst
@@ -0,0 +1,12 @@
+CMAKE_XCODE_SCHEME_THREAD_SANITIZER_STOP
+----------------------------------------
+
+Whether to enable ``Thread Sanitizer - Pause on issues``
+in the Diagnostics section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_THREAD_SANITIZER_STOP`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER.rst b/Help/variable/CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER.rst
new file mode 100644
index 000000000..ec5df6613
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER.rst
@@ -0,0 +1,12 @@
+CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER
+------------------------------------------------
+
+Whether to enable ``Undefined Behavior Sanitizer``
+in the Diagnostics section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP.rst b/Help/variable/CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP.rst
new file mode 100644
index 000000000..dcec9b0ea
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP.rst
@@ -0,0 +1,13 @@
+CMAKE_XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP
+-----------------------------------------------------
+
+Whether to enable ``Undefined Behavior Sanitizer`` option
+``Pause on issues``
+in the Diagnostics section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CMAKE_XCODE_SCHEME_ZOMBIE_OBJECTS.rst b/Help/variable/CMAKE_XCODE_SCHEME_ZOMBIE_OBJECTS.rst
new file mode 100644
index 000000000..82e9d76cc
--- /dev/null
+++ b/Help/variable/CMAKE_XCODE_SCHEME_ZOMBIE_OBJECTS.rst
@@ -0,0 +1,12 @@
+CMAKE_XCODE_SCHEME_ZOMBIE_OBJECTS
+---------------------------------
+
+Whether to enable ``Zombie Objects``
+in the Diagnostics section of the generated Xcode scheme.
+
+This variable initializes the
+:prop_tgt:`XCODE_SCHEME_ZOMBIE_OBJECTS`
+property on all targets.
+
+Please refer to the :prop_tgt:`XCODE_GENERATE_SCHEME` target property
+documentation to see all Xcode schema related properties.
diff --git a/Help/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst b/Help/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst
index 5dad6bd68..30ae23638 100644
--- a/Help/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst
+++ b/Help/variable/CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION.rst
@@ -5,7 +5,7 @@ Ask CPack to error out as soon as a file with absolute ``INSTALL DESTINATION``
is encountered.
The fatal error is emitted before the installation of the offending
-file takes place. Some CPack generators, like NSIS, enforce this
+file takes place. Some CPack generators, like ``NSIS``, enforce this
internally. This variable triggers the definition
of :variable:`CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION` when CPack
runs.
diff --git a/Help/variable/CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS.rst b/Help/variable/CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS.rst
new file mode 100644
index 000000000..83d5ce7fc
--- /dev/null
+++ b/Help/variable/CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS.rst
@@ -0,0 +1,11 @@
+CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
+-------------------------------------------
+
+Default permissions for implicitly created directories during packaging.
+
+This variable serves the same purpose during packaging as the
+:variable:`CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS` variable
+serves during installation (e.g. ``make install``).
+
+If `include(CPack)` is used then by default this variable is set to the content
+of :variable:`CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS`.
diff --git a/Help/variable/CPACK_INSTALL_SCRIPT.rst b/Help/variable/CPACK_INSTALL_SCRIPT.rst
deleted file mode 100644
index 12a48a40d..000000000
--- a/Help/variable/CPACK_INSTALL_SCRIPT.rst
+++ /dev/null
@@ -1,8 +0,0 @@
-CPACK_INSTALL_SCRIPT
---------------------
-
-Extra CMake script provided by the user.
-
-If set this CMake script will be executed by CPack during its local
-[CPack-private] installation which is done right before packaging the
-files. The script is not called by e.g.: ``make install``.
diff --git a/Help/variable/CTEST_CUSTOM_TESTS_IGNORE.rst b/Help/variable/CTEST_CUSTOM_TESTS_IGNORE.rst
new file mode 100644
index 000000000..57222ca1e
--- /dev/null
+++ b/Help/variable/CTEST_CUSTOM_TESTS_IGNORE.rst
@@ -0,0 +1,7 @@
+CTEST_CUSTOM_TESTS_IGNORE
+-------------------------
+
+A list of regular expressions to use to exclude tests during the
+:command:`ctest_test` command.
+
+.. include:: CTEST_CUSTOM_XXX.txt
diff --git a/Help/variable/CTEST_CUSTOM_TEST_IGNORE.rst b/Help/variable/CTEST_CUSTOM_TEST_IGNORE.rst
deleted file mode 100644
index 6114e608c..000000000
--- a/Help/variable/CTEST_CUSTOM_TEST_IGNORE.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-CTEST_CUSTOM_TEST_IGNORE
-------------------------
-
-A list of regular expressions to use to exclude tests during the
-:command:`ctest_test` command.
-
-.. include:: CTEST_CUSTOM_XXX.txt
diff --git a/Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst b/Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst
index 36fa37d92..a03d47342 100644
--- a/Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst
+++ b/Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst
@@ -2,6 +2,6 @@ CTEST_CUSTOM_WARNING_EXCEPTION
------------------------------
A list of regular expressions which will be used to exclude when detecting
-warning messages in build outputs by the :command:`ctest_test` command.
+warning messages in build outputs by the :command:`ctest_build` command.
.. include:: CTEST_CUSTOM_XXX.txt
diff --git a/Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst b/Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst
index a35be96b5..18aa6b31d 100644
--- a/Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst
+++ b/Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst
@@ -2,6 +2,6 @@ CTEST_CUSTOM_WARNING_MATCH
--------------------------
A list of regular expressions which will be used to detect warning messages in
-build outputs by the :command:`ctest_test` command.
+build outputs by the :command:`ctest_build` command.
.. include:: CTEST_CUSTOM_XXX.txt
diff --git a/Help/variable/CTEST_LABELS_FOR_SUBPROJECTS.rst b/Help/variable/CTEST_LABELS_FOR_SUBPROJECTS.rst
new file mode 100644
index 000000000..959596bf3
--- /dev/null
+++ b/Help/variable/CTEST_LABELS_FOR_SUBPROJECTS.rst
@@ -0,0 +1,5 @@
+CTEST_LABELS_FOR_SUBPROJECTS
+----------------------------
+
+Specify the CTest ``LabelsForSubprojects`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_RUN_CURRENT_SCRIPT.rst b/Help/variable/CTEST_RUN_CURRENT_SCRIPT.rst
new file mode 100644
index 000000000..abc123c09
--- /dev/null
+++ b/Help/variable/CTEST_RUN_CURRENT_SCRIPT.rst
@@ -0,0 +1,5 @@
+CTEST_RUN_CURRENT_SCRIPT
+------------------------
+
+Setting this to 0 prevents :manual:`ctest(1)` from being run again when it
+reaches the end of a script run by calling ``ctest -S``.
diff --git a/Help/variable/CTEST_SCP_COMMAND.rst b/Help/variable/CTEST_SCP_COMMAND.rst
index 0f128b14a..19ea8b33d 100644
--- a/Help/variable/CTEST_SCP_COMMAND.rst
+++ b/Help/variable/CTEST_SCP_COMMAND.rst
@@ -1,5 +1,4 @@
CTEST_SCP_COMMAND
-----------------
-Specify the CTest ``SCPCommand`` setting
-in a :manual:`ctest(1)` dashboard client script.
+Legacy option. Not used.
diff --git a/Help/variable/CTEST_SUBMIT_URL.rst b/Help/variable/CTEST_SUBMIT_URL.rst
new file mode 100644
index 000000000..7d84da4b4
--- /dev/null
+++ b/Help/variable/CTEST_SUBMIT_URL.rst
@@ -0,0 +1,5 @@
+CTEST_SUBMIT_URL
+----------------
+
+Specify the CTest ``SubmitURL`` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_TRIGGER_SITE.rst b/Help/variable/CTEST_TRIGGER_SITE.rst
index de9242807..a50e405cc 100644
--- a/Help/variable/CTEST_TRIGGER_SITE.rst
+++ b/Help/variable/CTEST_TRIGGER_SITE.rst
@@ -1,5 +1,4 @@
CTEST_TRIGGER_SITE
------------------
-Specify the CTest ``TriggerSite`` setting
-in a :manual:`ctest(1)` dashboard client script.
+Legacy option. Not used.
diff --git a/Help/variable/CTEST_UPDATE_VERSION_ONLY.rst b/Help/variable/CTEST_UPDATE_VERSION_ONLY.rst
index e646e6eea..a862baa14 100644
--- a/Help/variable/CTEST_UPDATE_VERSION_ONLY.rst
+++ b/Help/variable/CTEST_UPDATE_VERSION_ONLY.rst
@@ -1,5 +1,5 @@
CTEST_UPDATE_VERSION_ONLY
-------------------------
-Specify the CTest ``UpdateVersionOnly`` setting
+Specify the CTest :ref:`UpdateVersionOnly <UpdateVersionOnly>` setting
in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/CTEST_UPDATE_VERSION_OVERRIDE.rst b/Help/variable/CTEST_UPDATE_VERSION_OVERRIDE.rst
new file mode 100644
index 000000000..39fbaba79
--- /dev/null
+++ b/Help/variable/CTEST_UPDATE_VERSION_OVERRIDE.rst
@@ -0,0 +1,5 @@
+CTEST_UPDATE_VERSION_OVERRIDE
+-----------------------------
+
+Specify the CTest :ref:`UpdateVersionOverride <UpdateVersionOverride>` setting
+in a :manual:`ctest(1)` dashboard client script.
diff --git a/Help/variable/ENV.rst b/Help/variable/ENV.rst
index 368152aeb..2b439342e 100644
--- a/Help/variable/ENV.rst
+++ b/Help/variable/ENV.rst
@@ -1,7 +1,12 @@
ENV
---
-Access environment variables.
+Operator to read environment variables.
-Use the syntax ``$ENV{VAR}`` to read environment variable ``VAR``. See also
-the :command:`set` command to set ``ENV{VAR}``.
+Use the syntax ``$ENV{VAR}`` to read environment variable ``VAR``.
+
+To test whether an environment variable is defined, use the signature
+``if(DEFINED ENV{<name>})`` of the :command:`if` command.
+
+See the :command:`set` and :command:`unset` commands to see how to
+write or remove environment variables.
diff --git a/Help/variable/GHS-MULTI.rst b/Help/variable/GHS-MULTI.rst
index 0f91be8ad..fe3b17e18 100644
--- a/Help/variable/GHS-MULTI.rst
+++ b/Help/variable/GHS-MULTI.rst
@@ -1,4 +1,4 @@
GHS-MULTI
---------
-True when using Green Hills MULTI
+``True`` when using :generator:`Green Hills MULTI` generator.
diff --git a/Help/variable/IOS.rst b/Help/variable/IOS.rst
new file mode 100644
index 000000000..e5cc3f69c
--- /dev/null
+++ b/Help/variable/IOS.rst
@@ -0,0 +1,4 @@
+IOS
+---
+
+Set to ``1`` when the target system (:variable:`CMAKE_SYSTEM_NAME`) is ``iOS``.
diff --git a/Help/variable/LIBRARY_OUTPUT_PATH.rst b/Help/variable/LIBRARY_OUTPUT_PATH.rst
index ba02911e6..bb4328f5b 100644
--- a/Help/variable/LIBRARY_OUTPUT_PATH.rst
+++ b/Help/variable/LIBRARY_OUTPUT_PATH.rst
@@ -5,5 +5,5 @@ Old library location variable.
The target properties :prop_tgt:`ARCHIVE_OUTPUT_DIRECTORY`,
:prop_tgt:`LIBRARY_OUTPUT_DIRECTORY`, and :prop_tgt:`RUNTIME_OUTPUT_DIRECTORY`
-supercede this variable for a target if they are set. Library targets are
+supersede this variable for a target if they are set. Library targets are
otherwise placed in this directory.
diff --git a/Help/variable/MSVC.rst b/Help/variable/MSVC.rst
index 22a087a77..ca8775cb3 100644
--- a/Help/variable/MSVC.rst
+++ b/Help/variable/MSVC.rst
@@ -1,8 +1,8 @@
MSVC
----
-``True`` when using Microsoft Visual C++.
-
-Set to ``true`` when the compiler is some version of Microsoft Visual C++.
+Set to ``true`` when the compiler is some version of Microsoft Visual
+C++ or another compiler simulating Visual C++. Any compiler defining
+``_MSC_VER`` is considered simulating Visual C++.
See also the :variable:`MSVC_VERSION` variable.
diff --git a/Help/variable/MSVC_TOOLSET_VERSION.rst b/Help/variable/MSVC_TOOLSET_VERSION.rst
new file mode 100644
index 000000000..f4a33e246
--- /dev/null
+++ b/Help/variable/MSVC_TOOLSET_VERSION.rst
@@ -0,0 +1,22 @@
+MSVC_TOOLSET_VERSION
+--------------------
+
+The toolset version of Microsoft Visual C/C++ being used if any.
+If MSVC-like is being used, this variable is set based on the version
+of the compiler as given by the :variable:`MSVC_VERSION` variable.
+
+Known toolset version numbers are::
+
+ 80 = VS 2005 (8.0)
+ 90 = VS 2008 (9.0)
+ 100 = VS 2010 (10.0)
+ 110 = VS 2012 (11.0)
+ 120 = VS 2013 (12.0)
+ 140 = VS 2015 (14.0)
+ 141 = VS 2017 (15.0)
+ 142 = VS 2019 (16.0)
+
+Compiler versions newer than those known to CMake will be reported
+as the latest known toolset version.
+
+See also the :variable:`MSVC_VERSION` variable.
diff --git a/Help/variable/MSVC_VERSION.rst b/Help/variable/MSVC_VERSION.rst
index 8932147c6..45df37fa0 100644
--- a/Help/variable/MSVC_VERSION.rst
+++ b/Help/variable/MSVC_VERSION.rst
@@ -2,16 +2,23 @@ MSVC_VERSION
------------
The version of Microsoft Visual C/C++ being used if any.
+If a compiler simulating Visual C++ is being used, this variable is set
+to the toolset version simulated as given by the ``_MSC_VER``
+preprocessor definition.
Known version numbers are::
- 1200 = VS 6.0
- 1300 = VS 7.0
- 1310 = VS 7.1
- 1400 = VS 8.0
- 1500 = VS 9.0
- 1600 = VS 10.0
- 1700 = VS 11.0
- 1800 = VS 12.0
- 1900 = VS 14.0
- 1910 = VS 15.0
+ 1200 = VS 6.0
+ 1300 = VS 7.0
+ 1310 = VS 7.1
+ 1400 = VS 8.0 (v80 toolset)
+ 1500 = VS 9.0 (v90 toolset)
+ 1600 = VS 10.0 (v100 toolset)
+ 1700 = VS 11.0 (v110 toolset)
+ 1800 = VS 12.0 (v120 toolset)
+ 1900 = VS 14.0 (v140 toolset)
+ 1910-1919 = VS 15.0 (v141 toolset)
+ 1920-1929 = VS 16.0 (v142 toolset)
+
+See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` and
+:variable:`MSVC_TOOLSET_VERSION` variable.
diff --git a/Help/variable/MSYS.rst b/Help/variable/MSYS.rst
new file mode 100644
index 000000000..25ddc7f73
--- /dev/null
+++ b/Help/variable/MSYS.rst
@@ -0,0 +1,4 @@
+MSYS
+----
+
+``True`` when using the :generator:`MSYS Makefiles` generator.
diff --git a/Help/variable/PROJECT-NAME_DESCRIPTION.rst b/Help/variable/PROJECT-NAME_DESCRIPTION.rst
new file mode 100644
index 000000000..2b88b1acf
--- /dev/null
+++ b/Help/variable/PROJECT-NAME_DESCRIPTION.rst
@@ -0,0 +1,5 @@
+<PROJECT-NAME>_DESCRIPTION
+--------------------------
+
+Value given to the ``DESCRIPTION`` option of the most recent call to the
+:command:`project` command with project name ``<PROJECT-NAME>``, if any.
diff --git a/Help/variable/PROJECT-NAME_HOMEPAGE_URL.rst b/Help/variable/PROJECT-NAME_HOMEPAGE_URL.rst
new file mode 100644
index 000000000..22cc304b0
--- /dev/null
+++ b/Help/variable/PROJECT-NAME_HOMEPAGE_URL.rst
@@ -0,0 +1,5 @@
+<PROJECT-NAME>_HOMEPAGE_URL
+---------------------------
+
+Value given to the ``HOMEPAGE_URL`` option of the most recent call to the
+:command:`project` command with project name ``<PROJECT-NAME>``, if any.
diff --git a/Help/variable/PROJECT_DESCRIPTION.rst b/Help/variable/PROJECT_DESCRIPTION.rst
index 05ede8fcc..2833e1101 100644
--- a/Help/variable/PROJECT_DESCRIPTION.rst
+++ b/Help/variable/PROJECT_DESCRIPTION.rst
@@ -3,4 +3,7 @@ PROJECT_DESCRIPTION
Short project description given to the project command.
-This is the description given to the most recent :command:`project` command.
+This is the description given to the most recently called :command:`project`
+command in the current directory scope or above. To obtain the description
+of the top level project, see the :variable:`CMAKE_PROJECT_DESCRIPTION`
+variable.
diff --git a/Help/variable/PROJECT_HOMEPAGE_URL.rst b/Help/variable/PROJECT_HOMEPAGE_URL.rst
new file mode 100644
index 000000000..754c9e8b3
--- /dev/null
+++ b/Help/variable/PROJECT_HOMEPAGE_URL.rst
@@ -0,0 +1,9 @@
+PROJECT_HOMEPAGE_URL
+--------------------
+
+The homepage URL of the project.
+
+This is the homepage URL given to the most recently called :command:`project`
+command in the current directory scope or above. To obtain the homepage URL
+of the top level project, see the :variable:`CMAKE_PROJECT_HOMEPAGE_URL`
+variable.
diff --git a/Help/variable/PROJECT_NAME.rst b/Help/variable/PROJECT_NAME.rst
index 61aa8bc00..672680a71 100644
--- a/Help/variable/PROJECT_NAME.rst
+++ b/Help/variable/PROJECT_NAME.rst
@@ -3,4 +3,6 @@ PROJECT_NAME
Name of the project given to the project command.
-This is the name given to the most recent :command:`project` command.
+This is the name given to the most recently called :command:`project`
+command in the current directory scope or above. To obtain the name of
+the top level project, see the :variable:`CMAKE_PROJECT_NAME` variable.
diff --git a/Help/variable/PackageName_ROOT.rst b/Help/variable/PackageName_ROOT.rst
new file mode 100644
index 000000000..1c2fd34f3
--- /dev/null
+++ b/Help/variable/PackageName_ROOT.rst
@@ -0,0 +1,14 @@
+<PackageName>_ROOT
+------------------
+
+Calls to :command:`find_package(<PackageName>)` will search in prefixes
+specified by the ``<PackageName>_ROOT`` CMake variable, where
+``<PackageName>`` is the name given to the :command:`find_package` call
+and ``_ROOT`` is literal. For example, ``find_package(Foo)`` will search
+prefixes specified in the ``Foo_ROOT`` CMake variable (if set).
+See policy :policy:`CMP0074`.
+
+This variable may hold a single prefix or a
+:ref:`semicolon-separated list <CMake Language Lists>` of multiple prefixes.
+
+See also the :envvar:`<PackageName>_ROOT` environment variable.
diff --git a/Help/variable/UNIX.rst b/Help/variable/UNIX.rst
index 0877b7c07..49d866838 100644
--- a/Help/variable/UNIX.rst
+++ b/Help/variable/UNIX.rst
@@ -1,7 +1,7 @@
UNIX
----
-``True`` for UNIX and UNIX like operating systems.
-
-Set to ``true`` when the target system is UNIX or UNIX like (i.e.
-:variable:`APPLE` and :variable:`CYGWIN`).
+Set to ``True`` when the target system is UNIX or UNIX-like
+(e.g. :variable:`APPLE` and :variable:`CYGWIN`). The
+:variable:`CMAKE_SYSTEM_NAME` variable should be queried if
+a more specific understanding of the target system is required.
diff --git a/Help/variable/WIN32.rst b/Help/variable/WIN32.rst
index 218906955..78ab77279 100644
--- a/Help/variable/WIN32.rst
+++ b/Help/variable/WIN32.rst
@@ -1,6 +1,4 @@
WIN32
-----
-``True`` on Windows systems, including Win64.
-
-Set to ``true`` when the target system is Windows.
+Set to ``True`` when the target system is Windows, including Win64.
diff --git a/Help/variable/XCODE_VERSION.rst b/Help/variable/XCODE_VERSION.rst
index b85d41e91..9caf19a41 100644
--- a/Help/variable/XCODE_VERSION.rst
+++ b/Help/variable/XCODE_VERSION.rst
@@ -3,5 +3,5 @@ XCODE_VERSION
Version of Xcode (:generator:`Xcode` generator only).
-Under the Xcode generator, this is the version of Xcode as specified
-in ``Xcode.app/Contents/version.plist`` (such as ``3.1.2``).
+Under the :generator:`Xcode` generator, this is the version of Xcode
+as specified in ``Xcode.app/Contents/version.plist`` (such as ``3.1.2``).
diff --git a/Modules/AddFileDependencies.cmake b/Modules/AddFileDependencies.cmake
index fdd843266..598a52fa9 100644
--- a/Modules/AddFileDependencies.cmake
+++ b/Modules/AddFileDependencies.cmake
@@ -1,23 +1,28 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# AddFileDependencies
-# -------------------
-#
-# ADD_FILE_DEPENDENCIES(source_file depend_files...)
-#
-# Adds the given files as dependencies to source_file
+#[=======================================================================[.rst:
+AddFileDependencies
+-------------------
+
+Add dependencies to a source file.
+
+.. code-block:: cmake
+
+ ADD_FILE_DEPENDENCIES(<source> <files>)
+
+Adds the given ``<files>`` to the dependencies of file ``<source>``.
+#]=======================================================================]
macro(ADD_FILE_DEPENDENCIES _file)
- get_source_file_property(_deps ${_file} OBJECT_DEPENDS)
- if (_deps)
- set(_deps ${_deps} ${ARGN})
- else ()
- set(_deps ${ARGN})
- endif ()
+ get_source_file_property(_deps ${_file} OBJECT_DEPENDS)
+ if (_deps)
+ set(_deps ${_deps} ${ARGN})
+ else ()
+ set(_deps ${ARGN})
+ endif ()
- set_source_files_properties(${_file} PROPERTIES OBJECT_DEPENDS "${_deps}")
+ set_source_files_properties(${_file} PROPERTIES OBJECT_DEPENDS "${_deps}")
endmacro()
diff --git a/Modules/AndroidTestUtilities.cmake b/Modules/AndroidTestUtilities.cmake
index 62d04f3ef..e333cdbc6 100644
--- a/Modules/AndroidTestUtilities.cmake
+++ b/Modules/AndroidTestUtilities.cmake
@@ -40,7 +40,7 @@ Module Functions
.. command:: android_add_test_data
- ::
+ .. code-block:: cmake
android_add_test_data(<test-name>
[FILES <files>...] [FILES_DEST <device-dir>]
diff --git a/Modules/AndroidTestUtilities/PushToAndroidDevice.cmake b/Modules/AndroidTestUtilities/PushToAndroidDevice.cmake
index 04529b10a..fccff6725 100644
--- a/Modules/AndroidTestUtilities/PushToAndroidDevice.cmake
+++ b/Modules/AndroidTestUtilities/PushToAndroidDevice.cmake
@@ -31,7 +31,7 @@ function(android_push_test_files_to_device)
set(out_var ${out_var} PARENT_SCOPE)
if(res_var)
string(REGEX REPLACE ";" " " com "${ARGN}")
- message(FATAL_ERROR "Error occured during adb command: adb ${com}\nError: ${err_var}.")
+ message(FATAL_ERROR "Error occurred during adb command: adb ${com}\nError: ${err_var}.")
endif()
endfunction()
diff --git a/Modules/AutogenInfo.cmake.in b/Modules/AutogenInfo.cmake.in
deleted file mode 100644
index 4e85474d3..000000000
--- a/Modules/AutogenInfo.cmake.in
+++ /dev/null
@@ -1,33 +0,0 @@
-# Directories and files
-set(AM_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@/")
-set(AM_CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@/")
-set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/")
-set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/")
-set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@")
-set(AM_BUILD_DIR @_autogen_build_dir@)
-set(AM_SOURCES @_sources@)
-set(AM_HEADERS @_headers@)
-# Qt environment
-set(AM_QT_VERSION_MAJOR @_qt_version_major@)
-set(AM_QT_MOC_EXECUTABLE @_qt_moc_executable@)
-set(AM_QT_UIC_EXECUTABLE @_qt_uic_executable@)
-set(AM_QT_RCC_EXECUTABLE @_qt_rcc_executable@)
-# MOC settings
-set(AM_MOC_SKIP @_moc_skip@)
-set(AM_MOC_DEFINITIONS @_moc_compile_defs@)
-set(AM_MOC_INCLUDES @_moc_incs@)
-set(AM_MOC_OPTIONS @_moc_options@)
-set(AM_MOC_RELAXED_MODE @_moc_relaxed_mode@)
-set(AM_MOC_DEPEND_FILTERS @_moc_depend_filters@)
-set(AM_MOC_PREDEFS_CMD @_moc_predefs_cmd@)
-# UIC settings
-set(AM_UIC_SKIP @_uic_skip@)
-set(AM_UIC_TARGET_OPTIONS @_uic_target_options@)
-set(AM_UIC_OPTIONS_FILES @_qt_uic_options_files@)
-set(AM_UIC_OPTIONS_OPTIONS @_qt_uic_options_options@)
-set(AM_UIC_SEARCH_PATHS @_uic_search_paths@)
-# RCC settings
-set(AM_RCC_SOURCES @_rcc_files@ )
-set(AM_RCC_INPUTS @_rcc_inputs@)
-set(AM_RCC_OPTIONS_FILES @_rcc_options_files@)
-set(AM_RCC_OPTIONS_OPTIONS @_rcc_options_options@)
diff --git a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in
index bc78016df..a6e5fda38 100644
--- a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in
+++ b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in
@@ -18,14 +18,20 @@ else()
endif()
endif()
+
+# if the installed project requested no architecture check, don't perform the check
+if("@CVF_ARCH_INDEPENDENT@")
+ return()
+endif()
+
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
- return()
+ return()
endif()
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@")
- math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
- set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
- set(PACKAGE_VERSION_UNSUITABLE TRUE)
+ math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()
diff --git a/Modules/BasicConfigVersion-ExactVersion.cmake.in b/Modules/BasicConfigVersion-ExactVersion.cmake.in
index de4a23af0..43fc4d0b1 100644
--- a/Modules/BasicConfigVersion-ExactVersion.cmake.in
+++ b/Modules/BasicConfigVersion-ExactVersion.cmake.in
@@ -34,9 +34,14 @@ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
endif()
+# if the installed project requested no architecture check, don't perform the check
+if("@CVF_ARCH_INDEPENDENT@")
+ return()
+endif()
+
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
- return()
+ return()
endif()
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
index a32245dd5..8c3b6a212 100644
--- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
+++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
@@ -33,9 +33,14 @@ else()
endif()
+# if the installed project requested no architecture check, don't perform the check
+if("@CVF_ARCH_INDEPENDENT@")
+ return()
+endif()
+
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
- return()
+ return()
endif()
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
diff --git a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in
new file mode 100644
index 000000000..e2030d230
--- /dev/null
+++ b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in
@@ -0,0 +1,55 @@
+# This is a basic version file for the Config-mode of find_package().
+# It is used by write_basic_package_version_file() as input file for configure_file()
+# to create a version-file which can be installed along a config.cmake file.
+#
+# The created file sets PACKAGE_VERSION_EXACT if the current version string and
+# the requested version string are exactly the same and it sets
+# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
+# but only if the requested major and minor versions are the same as the current
+# one.
+# The variable CVF_VERSION must be set before calling configure_file().
+
+
+set(PACKAGE_VERSION "@CVF_VERSION@")
+
+if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+
+ if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.([0-9]+)")
+ set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
+ set(CVF_VERSION_MINOR "${CMAKE_MATCH_2}")
+ else()
+ set(CVF_VERSION_MAJOR "@CVF_VERSION@")
+ set(CVF_VERSION_MINOR "")
+ endif()
+
+ if((PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) AND
+ (PACKAGE_FIND_VERSION_MINOR STREQUAL CVF_VERSION_MINOR))
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ else()
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ endif()
+
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
+
+
+# if the installed project requested no architecture check, don't perform the check
+if("@CVF_ARCH_INDEPENDENT@")
+ return()
+endif()
+
+# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
+if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
+ return()
+endif()
+
+# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
+if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@")
+ math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
+endif()
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake
index 121a8f015..2f3b9e1d3 100644
--- a/Modules/BundleUtilities.cmake
+++ b/Modules/BundleUtilities.cmake
@@ -1,229 +1,255 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# BundleUtilities
-# ---------------
-#
-# Functions to help assemble a standalone bundle application.
-#
-# A collection of CMake utility functions useful for dealing with .app
-# bundles on the Mac and bundle-like directories on any OS.
-#
-# The following functions are provided by this module:
-#
-# ::
-#
-# fixup_bundle
-# copy_and_fixup_bundle
-# verify_app
-# get_bundle_main_executable
-# get_dotapp_dir
-# get_bundle_and_executable
-# get_bundle_all_executables
-# get_item_key
-# get_item_rpaths
-# clear_bundle_keys
-# set_bundle_key_values
-# get_bundle_keys
-# copy_resolved_item_into_bundle
-# copy_resolved_framework_into_bundle
-# fixup_bundle_item
-# verify_bundle_prerequisites
-# verify_bundle_symlinks
-#
-# Requires CMake 2.6 or greater because it uses function, break and
-# PARENT_SCOPE. Also depends on GetPrerequisites.cmake.
-#
-# ::
-#
-# FIXUP_BUNDLE(<app> <libs> <dirs>)
-#
-# Fix up a bundle in-place and make it standalone, such that it can be
-# drag-n-drop copied to another machine and run on that machine as long
-# as all of the system libraries are compatible.
-#
-# If you pass plugins to fixup_bundle as the libs parameter, you should
-# install them or copy them into the bundle before calling fixup_bundle.
-# The "libs" parameter is a list of libraries that must be fixed up, but
-# that cannot be determined by otool output analysis. (i.e., plugins)
-#
-# Gather all the keys for all the executables and libraries in a bundle,
-# and then, for each key, copy each prerequisite into the bundle. Then
-# fix each one up according to its own list of prerequisites.
-#
-# Then clear all the keys and call verify_app on the final bundle to
-# ensure that it is truly standalone.
-#
-# As an optional parameter (IGNORE_ITEM) a list of file names can be passed,
-# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
-#
-# ::
-#
-# COPY_AND_FIXUP_BUNDLE(<src> <dst> <libs> <dirs>)
-#
-# Makes a copy of the bundle <src> at location <dst> and then fixes up
-# the new copied bundle in-place at <dst>...
-#
-# ::
-#
-# VERIFY_APP(<app>)
-#
-# Verifies that an application <app> appears valid based on running
-# analysis tools on it. Calls "message(FATAL_ERROR" if the application
-# is not verified.
-#
-# As an optional parameter (IGNORE_ITEM) a list of file names can be passed,
-# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
-#
-# ::
-#
-# GET_BUNDLE_MAIN_EXECUTABLE(<bundle> <result_var>)
-#
-# The result will be the full path name of the bundle's main executable
-# file or an "error:" prefixed string if it could not be determined.
-#
-# ::
-#
-# GET_DOTAPP_DIR(<exe> <dotapp_dir_var>)
-#
-# Returns the nearest parent dir whose name ends with ".app" given the
-# full path to an executable. If there is no such parent dir, then
-# simply return the dir containing the executable.
-#
-# The returned directory may or may not exist.
-#
-# ::
-#
-# GET_BUNDLE_AND_EXECUTABLE(<app> <bundle_var> <executable_var> <valid_var>)
-#
-# Takes either a ".app" directory name or the name of an executable
-# nested inside a ".app" directory and returns the path to the ".app"
-# directory in <bundle_var> and the path to its main executable in
-# <executable_var>
-#
-# ::
-#
-# GET_BUNDLE_ALL_EXECUTABLES(<bundle> <exes_var>)
-#
-# Scans the given bundle recursively for all executable files and
-# accumulates them into a variable.
-#
-# ::
-#
-# GET_ITEM_KEY(<item> <key_var>)
-#
-# Given a file (item) name, generate a key that should be unique
-# considering the set of libraries that need copying or fixing up to
-# make a bundle standalone. This is essentially the file name including
-# extension with "." replaced by "_"
-#
-# This key is used as a prefix for CMake variables so that we can
-# associate a set of variables with a given item based on its key.
-#
-# ::
-#
-# CLEAR_BUNDLE_KEYS(<keys_var>)
-#
-# Loop over the list of keys, clearing all the variables associated with
-# each key. After the loop, clear the list of keys itself.
-#
-# Caller of get_bundle_keys should call clear_bundle_keys when done with
-# list of keys.
-#
-# ::
-#
-# SET_BUNDLE_KEY_VALUES(<keys_var> <context> <item> <exepath> <dirs>
-# <copyflag> [<rpaths>])
-#
-# Add a key to the list (if necessary) for the given item. If added,
-# also set all the variables associated with that key.
-#
-# ::
-#
-# GET_BUNDLE_KEYS(<app> <libs> <dirs> <keys_var>)
-#
-# Loop over all the executable and library files within the bundle (and
-# given as extra <libs>) and accumulate a list of keys representing
-# them. Set values associated with each key such that we can loop over
-# all of them and copy prerequisite libs into the bundle and then do
-# appropriate install_name_tool fixups.
-#
-# As an optional parameter (IGNORE_ITEM) a list of file names can be passed,
-# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
-#
-# ::
-#
-# COPY_RESOLVED_ITEM_INTO_BUNDLE(<resolved_item> <resolved_embedded_item>)
-#
-# Copy a resolved item into the bundle if necessary. Copy is not
-# necessary if the resolved_item is "the same as" the
-# resolved_embedded_item.
-#
-# ::
-#
-# COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE(<resolved_item> <resolved_embedded_item>)
-#
-# Copy a resolved framework into the bundle if necessary. Copy is not
-# necessary if the resolved_item is "the same as" the
-# resolved_embedded_item.
-#
-# By default, BU_COPY_FULL_FRAMEWORK_CONTENTS is not set. If you want
-# full frameworks embedded in your bundles, set
-# BU_COPY_FULL_FRAMEWORK_CONTENTS to ON before calling fixup_bundle. By
-# default, COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE copies the framework
-# dylib itself plus the framework Resources directory.
-#
-# ::
-#
-# FIXUP_BUNDLE_ITEM(<resolved_embedded_item> <exepath> <dirs>)
-#
-# Get the direct/non-system prerequisites of the resolved embedded item.
-# For each prerequisite, change the way it is referenced to the value of
-# the _EMBEDDED_ITEM keyed variable for that prerequisite. (Most likely
-# changing to an "@executable_path" style reference.)
-#
-# This function requires that the resolved_embedded_item be "inside" the
-# bundle already. In other words, if you pass plugins to fixup_bundle
-# as the libs parameter, you should install them or copy them into the
-# bundle before calling fixup_bundle. The "libs" parameter is a list of
-# libraries that must be fixed up, but that cannot be determined by
-# otool output analysis. (i.e., plugins)
-#
-# Also, change the id of the item being fixed up to its own
-# _EMBEDDED_ITEM value.
-#
-# Accumulate changes in a local variable and make *one* call to
-# install_name_tool at the end of the function with all the changes at
-# once.
-#
-# If the BU_CHMOD_BUNDLE_ITEMS variable is set then bundle items will be
-# marked writable before install_name_tool tries to change them.
-#
-# ::
-#
-# VERIFY_BUNDLE_PREREQUISITES(<bundle> <result_var> <info_var>)
-#
-# Verifies that the sum of all prerequisites of all files inside the
-# bundle are contained within the bundle or are "system" libraries,
-# presumed to exist everywhere.
-#
-# As an optional parameter (IGNORE_ITEM) a list of file names can be passed,
-# which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe")
-#
-# ::
-#
-# VERIFY_BUNDLE_SYMLINKS(<bundle> <result_var> <info_var>)
-#
-# Verifies that any symlinks found in the bundle point to other files
-# that are already also in the bundle... Anything that points to an
-# external file causes this function to fail the verification.
+#[=======================================================================[.rst:
+BundleUtilities
+---------------
+
+Functions to help assemble a standalone bundle application.
+
+A collection of CMake utility functions useful for dealing with ``.app``
+bundles on the Mac and bundle-like directories on any OS.
+
+The following functions are provided by this module:
+
+.. code-block:: cmake
+
+ fixup_bundle
+ copy_and_fixup_bundle
+ verify_app
+ get_bundle_main_executable
+ get_dotapp_dir
+ get_bundle_and_executable
+ get_bundle_all_executables
+ get_item_key
+ get_item_rpaths
+ clear_bundle_keys
+ set_bundle_key_values
+ get_bundle_keys
+ copy_resolved_item_into_bundle
+ copy_resolved_framework_into_bundle
+ fixup_bundle_item
+ verify_bundle_prerequisites
+ verify_bundle_symlinks
+
+Requires CMake 2.6 or greater because it uses function, break and
+``PARENT_SCOPE``. Also depends on ``GetPrerequisites.cmake``.
+
+DO NOT USE THESE FUNCTIONS AT CONFIGURE TIME (from ``CMakeLists.txt``)!
+Instead, invoke them from an :command:`install(CODE)` or
+:command:`install(SCRIPT)` rule.
+
+.. code-block:: cmake
+
+ fixup_bundle(<app> <libs> <dirs>)
+
+Fix up ``<app>`` bundle in-place and make it standalone, such that it can be
+drag-n-drop copied to another machine and run on that machine as long
+as all of the system libraries are compatible.
+
+If you pass plugins to ``fixup_bundle`` as the libs parameter, you should
+install them or copy them into the bundle before calling ``fixup_bundle``.
+The ``<libs>`` parameter is a list of libraries that must be fixed up, but
+that cannot be determined by ``otool`` output analysis (i.e. ``plugins``).
+
+Gather all the keys for all the executables and libraries in a bundle,
+and then, for each key, copy each prerequisite into the bundle. Then
+fix each one up according to its own list of prerequisites.
+
+Then clear all the keys and call ``verify_app`` on the final bundle to
+ensure that it is truly standalone.
+
+As an optional parameter (``IGNORE_ITEM``) a list of file names can be passed,
+which are then ignored
+(e.g. ``IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe"``).
+
+.. code-block:: cmake
+
+ copy_and_fixup_bundle(<src> <dst> <libs> <dirs>)
+
+Makes a copy of the bundle ``<src>`` at location ``<dst>`` and then fixes up
+the new copied bundle in-place at ``<dst>``.
+
+.. code-block:: cmake
+
+ verify_app(<app>)
+
+Verifies that an application ``<app>`` appears valid based on running
+analysis tools on it. Calls :command:`message(FATAL_ERROR)` if the application
+is not verified.
+
+As an optional parameter (``IGNORE_ITEM``) a list of file names can be passed,
+which are then ignored
+(e.g. ``IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe"``)
+
+.. code-block:: cmake
+
+ get_bundle_main_executable(<bundle> <result_var>)
+
+The result will be the full path name of the bundle's main executable
+file or an ``error:`` prefixed string if it could not be determined.
+
+.. code-block:: cmake
+
+ get_dotapp_dir(<exe> <dotapp_dir_var>)
+
+Returns the nearest parent dir whose name ends with ``.app`` given the
+full path to an executable. If there is no such parent dir, then
+simply return the dir containing the executable.
+
+The returned directory may or may not exist.
+
+.. code-block:: cmake
+
+ get_bundle_and_executable(<app> <bundle_var> <executable_var> <valid_var>)
+
+Takes either a ``.app`` directory name or the name of an executable
+nested inside a ``.app`` directory and returns the path to the ``.app``
+directory in ``<bundle_var>`` and the path to its main executable in
+``<executable_var>``.
+
+.. code-block:: cmake
+
+ get_bundle_all_executables(<bundle> <exes_var>)
+
+Scans ``<bundle>`` bundle recursively for all ``<exes_var>`` executable
+files and accumulates them into a variable.
+
+.. code-block:: cmake
+
+ get_item_key(<item> <key_var>)
+
+Given ``<item>`` file name, generate ``<key_var>`` key that should be unique
+considering the set of libraries that need copying or fixing up to
+make a bundle standalone. This is essentially the file name including
+extension with ``.`` replaced by ``_``
+
+This key is used as a prefix for CMake variables so that we can
+associate a set of variables with a given item based on its key.
+
+.. code-block:: cmake
+
+ clear_bundle_keys(<keys_var>)
+
+Loop over the ``<keys_var>`` list of keys, clearing all the variables
+associated with each key. After the loop, clear the list of keys itself.
+
+Caller of ``get_bundle_keys`` should call ``clear_bundle_keys`` when done with
+list of keys.
+
+.. code-block:: cmake
+
+ set_bundle_key_values(<keys_var> <context> <item> <exepath> <dirs>
+ <copyflag> [<rpaths>])
+
+Add ``<keys_var>`` key to the list (if necessary) for the given item.
+If added, also set all the variables associated with that key.
+
+.. code-block:: cmake
+
+ get_bundle_keys(<app> <libs> <dirs> <keys_var>)
+
+Loop over all the executable and library files within ``<app>`` bundle (and
+given as extra ``<libs>``) and accumulate a list of keys representing
+them. Set values associated with each key such that we can loop over
+all of them and copy prerequisite libs into the bundle and then do
+appropriate ``install_name_tool`` fixups.
+
+As an optional parameter (``IGNORE_ITEM``) a list of file names can be passed,
+which are then ignored
+(e.g. ``IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe"``)
+
+.. code-block:: cmake
+
+ copy_resolved_item_into_bundle(<resolved_item> <resolved_embedded_item>)
+
+Copy a resolved item into the bundle if necessary.
+Copy is not necessary, if the ``<resolved_item>`` is "the same as" the
+``<resolved_embedded_item>``.
+
+.. code-block:: cmake
+
+ copy_resolved_framework_into_bundle(<resolved_item> <resolved_embedded_item>)
+
+Copy a resolved framework into the bundle if necessary.
+Copy is not necessary, if the ``<resolved_item>`` is "the same as" the
+``<resolved_embedded_item>``.
+
+By default, ``BU_COPY_FULL_FRAMEWORK_CONTENTS`` is not set. If you want
+full frameworks embedded in your bundles, set
+``BU_COPY_FULL_FRAMEWORK_CONTENTS`` to ``ON`` before calling fixup_bundle. By
+default, ``COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE`` copies the framework
+dylib itself plus the framework ``Resources`` directory.
+
+.. code-block:: cmake
+
+ fixup_bundle_item(<resolved_embedded_item> <exepath> <dirs>)
+
+Get the direct/non-system prerequisites of the ``<resolved_embedded_item>``.
+For each prerequisite, change the way it is referenced to the value of
+the ``_EMBEDDED_ITEM`` keyed variable for that prerequisite. (Most likely
+changing to an ``@executable_path`` style reference.)
+
+This function requires that the ``<resolved_embedded_item>`` be ``inside``
+the bundle already. In other words, if you pass plugins to ``fixup_bundle``
+as the libs parameter, you should install them or copy them into the
+bundle before calling ``fixup_bundle``. The ``libs`` parameter is a list of
+libraries that must be fixed up, but that cannot be determined by
+otool output analysis. (i.e., ``plugins``)
+
+Also, change the id of the item being fixed up to its own
+``_EMBEDDED_ITEM`` value.
+
+Accumulate changes in a local variable and make *one* call to
+``install_name_tool`` at the end of the function with all the changes at
+once.
+
+If the ``BU_CHMOD_BUNDLE_ITEMS`` variable is set then bundle items will be
+marked writable before ``install_name_tool`` tries to change them.
+
+.. code-block:: cmake
+
+ verify_bundle_prerequisites(<bundle> <result_var> <info_var>)
+
+Verifies that the sum of all prerequisites of all files inside the
+bundle are contained within the bundle or are ``system`` libraries,
+presumed to exist everywhere.
+
+As an optional parameter (``IGNORE_ITEM``) a list of file names can be passed,
+which are then ignored
+(e.g. ``IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe"``)
+
+.. code-block:: cmake
+
+ verify_bundle_symlinks(<bundle> <result_var> <info_var>)
+
+Verifies that any symlinks found in the ``<bundle>`` bundle point to other files
+that are already also in the bundle... Anything that points to an
+external file causes this function to fail the verification.
+#]=======================================================================]
+
+function(_warn_cmp0080)
+ cmake_policy(GET_WARNING CMP0080 _cmp0080_warning)
+ message(AUTHOR_WARNING "${_cmp0080_warning}\n")
+endfunction()
+
+# Do not include this module at configure time!
+if(DEFINED CMAKE_GENERATOR)
+ cmake_policy(GET CMP0080 _BundleUtilities_CMP0080)
+ if(_BundleUtilities_CMP0080 STREQUAL "NEW")
+ message(FATAL_ERROR "BundleUtilities cannot be included at configure time!")
+ elseif(NOT _BundleUtilities_CMP0080 STREQUAL "OLD" AND NOT _CMP0080_SUPPRESS_WARNING)
+ _warn_cmp0080()
+ endif()
+endif()
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
# The functions defined in this file depend on the get_prerequisites function
# (and possibly others) found in:
#
-get_filename_component(BundleUtilities_cmake_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
-include("${BundleUtilities_cmake_dir}/GetPrerequisites.cmake")
+include("${CMAKE_CURRENT_LIST_DIR}/GetPrerequisites.cmake")
function(get_bundle_main_executable bundle result_var)
@@ -256,7 +282,7 @@ function(get_bundle_main_executable bundle result_var)
endif()
endforeach()
- if(NOT "${bundle_executable}" STREQUAL "")
+ if(NOT bundle_executable STREQUAL "")
if(EXISTS "${bundle}/Contents/MacOS/${bundle_executable}")
set(result "${bundle}/Contents/MacOS/${bundle_executable}")
else()
@@ -421,7 +447,12 @@ function(get_item_rpaths item rpaths_var)
execute_process(
COMMAND "${otool_cmd}" -l "${item}"
OUTPUT_VARIABLE load_cmds_ov
+ RESULT_VARIABLE otool_rv
+ ERROR_VARIABLE otool_ev
)
+ if(NOT otool_rv STREQUAL "0")
+ message(FATAL_ERROR "otool -l failed: ${otool_rv}\n${otool_ev}")
+ endif()
string(REGEX REPLACE "[^\n]+cmd LC_RPATH\n[^\n]+\n[^\n]+path ([^\n]+) \\(offset[^\n]+\n" "rpath \\1\n" load_cmds_ov "${load_cmds_ov}")
string(REGEX MATCHALL "rpath [^\n]+" load_cmds_ov "${load_cmds_ov}")
string(REGEX REPLACE "rpath " "" load_cmds_ov "${load_cmds_ov}")
@@ -571,17 +602,9 @@ function(get_bundle_keys app libs dirs keys_var)
set_bundle_key_values(${keys_var} "${lib}" "${lib}" "${exepath}" "${dirs}" 0 "${main_rpaths}")
set(prereqs "")
- set(ignoreFile FALSE)
get_filename_component(prereq_filename ${lib} NAME)
- if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
- foreach(item ${CFG_IGNORE_ITEM})
- if("${item}" STREQUAL "${prereq_filename}")
- set(ignoreFile TRUE)
- endif()
- endforeach()
- endif()
- if(NOT ignoreFile)
+ if(NOT prereq_filename IN_LIST CFG_IGNORE_ITEM)
get_prerequisites("${lib}" prereqs 1 1 "${exepath}" "${dirs}" "${main_rpaths}")
foreach(pr ${prereqs})
set_bundle_key_values(${keys_var} "${lib}" "${pr}" "${exepath}" "${dirs}" 1 "${main_rpaths}")
@@ -598,7 +621,7 @@ function(get_bundle_keys app libs dirs keys_var)
foreach(exe ${exes})
# Main executable is scanned first above:
#
- if(NOT "${exe}" STREQUAL "${executable}")
+ if(NOT exe STREQUAL executable)
# Add the exe itself to the keys:
#
set_bundle_key_values(${keys_var} "${exe}" "${exe}" "${exepath}" "${dirs}" 0 "${main_rpaths}")
@@ -614,17 +637,9 @@ function(get_bundle_keys app libs dirs keys_var)
# Add each prerequisite to the keys:
#
set(prereqs "")
- set(ignoreFile FALSE)
get_filename_component(prereq_filename ${exe} NAME)
- if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
- foreach(item ${CFG_IGNORE_ITEM})
- if("${item}" STREQUAL "${prereq_filename}")
- set(ignoreFile TRUE)
- endif()
- endforeach()
- endif()
- if(NOT ignoreFile)
+ if(NOT prereq_filename IN_LIST CFG_IGNORE_ITEM)
get_prerequisites("${exe}" prereqs 1 1 "${exepath}" "${dirs}" "${exe_rpaths}")
foreach(pr ${prereqs})
set_bundle_key_values(${keys_var} "${exe}" "${pr}" "${exepath}" "${dirs}" 1 "${exe_rpaths}")
@@ -636,7 +651,7 @@ function(get_bundle_keys app libs dirs keys_var)
# preserve library symlink structure
foreach(key ${${keys_var}})
- if("${${key}_COPYFLAG}" STREQUAL 1)
+ if("${${key}_COPYFLAG}" STREQUAL "1")
if(IS_SYMLINK "${${key}_RESOLVED_ITEM}")
get_filename_component(target "${${key}_RESOLVED_ITEM}" REALPATH)
set_bundle_key_values(${keys_var} "${exe}" "${target}" "${exepath}" "${dirs}" 1 "${exe_rpaths}")
@@ -653,7 +668,7 @@ function(get_bundle_keys app libs dirs keys_var)
get_filename_component(resolved_item_compare "${resolved_item_compare}" NAME)
get_filename_component(resolved_embedded_item_compare "${resolved_embedded_item_compare}" NAME)
- if(NOT "${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
+ if(NOT resolved_item_compare STREQUAL resolved_embedded_item_compare)
set(${key}_COPYFLAG "2")
set(${key}_RESOLVED_ITEM "${${targetkey}_RESOLVED_EMBEDDED_ITEM}")
endif()
@@ -687,11 +702,14 @@ function(link_resolved_item_into_bundle resolved_item resolved_embedded_item)
set(resolved_embedded_item_compare "${resolved_embedded_item}")
endif()
- if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
+ if(resolved_item_compare STREQUAL resolved_embedded_item_compare)
message(STATUS "warning: resolved_item == resolved_embedded_item - not linking...")
else()
get_filename_component(target_dir "${resolved_embedded_item}" DIRECTORY)
file(RELATIVE_PATH symlink_target "${target_dir}" "${resolved_item}")
+ if (NOT EXISTS "${target_dir}")
+ file(MAKE_DIRECTORY "${target_dir}")
+ endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${symlink_target}" "${resolved_embedded_item}")
endif()
endfunction()
@@ -706,7 +724,7 @@ function(copy_resolved_item_into_bundle resolved_item resolved_embedded_item)
set(resolved_embedded_item_compare "${resolved_embedded_item}")
endif()
- if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
+ if(resolved_item_compare STREQUAL resolved_embedded_item_compare)
message(STATUS "warning: resolved_item == resolved_embedded_item - not copying...")
else()
#message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy ${resolved_item} ${resolved_embedded_item}")
@@ -729,7 +747,7 @@ function(copy_resolved_framework_into_bundle resolved_item resolved_embedded_ite
set(resolved_embedded_item_compare "${resolved_embedded_item}")
endif()
- if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}")
+ if(resolved_item_compare STREQUAL resolved_embedded_item_compare)
message(STATUS "warning: resolved_item == resolved_embedded_item - not copying...")
else()
if(BU_COPY_FULL_FRAMEWORK_CONTENTS)
@@ -809,12 +827,12 @@ function(fixup_bundle_item resolved_embedded_item exepath dirs)
string(LENGTH "${resolved_embedded_item}" resolved_embedded_item_length)
set(path_too_short 0)
set(is_embedded 0)
- if(${resolved_embedded_item_length} LESS ${exe_dotapp_dir_length})
+ if(resolved_embedded_item_length LESS exe_dotapp_dir_length)
set(path_too_short 1)
endif()
if(NOT path_too_short)
string(SUBSTRING "${resolved_embedded_item}" 0 ${exe_dotapp_dir_length} item_substring)
- if("${exe_dotapp_dir}/" STREQUAL "${item_substring}")
+ if("${exe_dotapp_dir}/" STREQUAL item_substring)
set(is_embedded 1)
endif()
endif()
@@ -852,9 +870,13 @@ function(fixup_bundle_item resolved_embedded_item exepath dirs)
execute_process(COMMAND chmod u+w "${resolved_embedded_item}")
endif()
+ # CMAKE_INSTALL_NAME_TOOL may not be set if executed in script mode
+ # Duplicated from CMakeFindBinUtils.cmake
+ find_program(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+
# Only if install_name_tool supports -delete_rpath:
#
- execute_process(COMMAND install_name_tool
+ execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL}
OUTPUT_VARIABLE install_name_tool_usage
ERROR_VARIABLE install_name_tool_usage
)
@@ -872,7 +894,7 @@ function(fixup_bundle_item resolved_embedded_item exepath dirs)
# to install_name_tool:
#
if(changes)
- set(cmd install_name_tool ${changes} "${resolved_embedded_item}")
+ set(cmd ${CMAKE_INSTALL_NAME_TOOL} ${changes} "${resolved_embedded_item}")
execute_process(COMMAND ${cmd} RESULT_VARIABLE install_name_tool_result)
if(NOT install_name_tool_result EQUAL 0)
string(REPLACE ";" "' '" msg "'${cmd}'")
@@ -996,18 +1018,9 @@ function(verify_bundle_prerequisites bundle result_var info_var)
message(STATUS "executable file ${count}: ${f}")
set(prereqs "")
- set(ignoreFile FALSE)
get_filename_component(prereq_filename ${f} NAME)
- if(NOT "${CFG_IGNORE_ITEM}" STREQUAL "" )
- foreach(item ${CFG_IGNORE_ITEM})
- if("${item}" STREQUAL "${prereq_filename}")
- set(ignoreFile TRUE)
- endif()
- endforeach()
- endif()
-
- if(NOT ignoreFile)
+ if(NOT prereq_filename IN_LIST CFG_IGNORE_ITEM)
get_item_rpaths(${f} _main_exe_rpaths)
get_prerequisites("${f}" prereqs 1 1 "${exepath}" "${_main_exe_rpaths}")
@@ -1027,11 +1040,11 @@ function(verify_bundle_prerequisites bundle result_var info_var)
gp_file_type("${f}" "${p}" p_type)
if(APPLE)
- if(NOT "${p_type}" STREQUAL "embedded" AND NOT "${p_type}" STREQUAL "system")
+ if(NOT p_type STREQUAL "embedded" AND NOT p_type STREQUAL "system")
set(external_prereqs ${external_prereqs} "${p}")
endif()
else()
- if(NOT "${p_type}" STREQUAL "local" AND NOT "${p_type}" STREQUAL "system")
+ if(NOT p_type STREQUAL "local" AND NOT p_type STREQUAL "system")
set(external_prereqs ${external_prereqs} "${p}")
endif()
endif()
@@ -1106,3 +1119,5 @@ function(verify_app app)
message(FATAL_ERROR "error: verify_app failed")
endif()
endfunction()
+
+cmake_policy(POP)
diff --git a/Modules/CMakeASMCompiler.cmake.in b/Modules/CMakeASMCompiler.cmake.in
index 7b94d0f6e..b8e09fefa 100644
--- a/Modules/CMakeASMCompiler.cmake.in
+++ b/Modules/CMakeASMCompiler.cmake.in
@@ -5,10 +5,14 @@ set(CMAKE_ASM@ASM_DIALECT@_COMPILER_AR "@_CMAKE_ASM_COMPILER_AR@")
set(CMAKE_RANLIB "@CMAKE_RANLIB@")
set(CMAKE_ASM@ASM_DIALECT@_COMPILER_RANLIB "@_CMAKE_ASM_COMPILER_RANLIB@")
set(CMAKE_LINKER "@CMAKE_LINKER@")
+set(CMAKE_MT "@CMAKE_MT@")
set(CMAKE_ASM@ASM_DIALECT@_COMPILER_LOADED 1)
set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ID "@_CMAKE_ASM_COMPILER_ID@")
+set(CMAKE_ASM@ASM_DIALECT@_COMPILER_VERSION "@_CMAKE_ASM_COMPILER_VERSION@")
set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ENV_VAR "@_CMAKE_ASM_COMPILER_ENV_VAR@")
+@_SET_CMAKE_ASM_COMPILER_ARCHITECTURE_ID@
set(CMAKE_ASM@ASM_DIALECT@_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
set(CMAKE_ASM@ASM_DIALECT@_LINKER_PREFERENCE 0)
+@CMAKE_ASM_COMPILER_CUSTOM_CODE@
diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake
index f7cf900fd..6b7373067 100644
--- a/Modules/CMakeASMInformation.cmake
+++ b/Modules/CMakeASMInformation.cmake
@@ -29,15 +29,15 @@ if(NOT _INCLUDED_FILE)
endif()
if(CMAKE_SYSTEM_PROCESSOR)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
if(NOT _INCLUDED_FILE)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
endif()
endif()
-include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
+include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
if(NOT _INCLUDED_FILE)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
endif()
# This should be included before the _INIT variables are
@@ -67,38 +67,7 @@ endif()
# Support for CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT and friends:
set(CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT "$ENV{ASM${ASM_DIALECT}FLAGS} ${CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT}")
-foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO)
- string(STRIP "${CMAKE_ASM${ASM_DIALECT}_FLAGS${c}_INIT}" CMAKE_ASM${ASM_DIALECT}_FLAGS${c}_INIT)
-endforeach()
-
-set (CMAKE_ASM${ASM_DIALECT}_FLAGS "${CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT}" CACHE STRING
- "Flags used by the assembler during all build types.")
-
-if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
- get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
- # default build type is none
- if(NOT _GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_NO_BUILD_TYPE)
- set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING
- "Choose the type of build, options are: None, Debug Release RelWithDebInfo MinSizeRel.")
- endif()
- unset(_GENERATOR_IS_MULTI_CONFIG)
- set (CMAKE_ASM${ASM_DIALECT}_FLAGS_DEBUG "${CMAKE_ASM${ASM_DIALECT}_FLAGS_DEBUG_INIT}" CACHE STRING
- "Flags used by the assembler during debug builds.")
- set (CMAKE_ASM${ASM_DIALECT}_FLAGS_MINSIZEREL "${CMAKE_ASM${ASM_DIALECT}_FLAGS_MINSIZEREL_INIT}" CACHE STRING
- "Flags used by the assembler during release minsize builds.")
- set (CMAKE_ASM${ASM_DIALECT}_FLAGS_RELEASE "${CMAKE_ASM${ASM_DIALECT}_FLAGS_RELEASE_INIT}" CACHE STRING
- "Flags used by the assembler during release builds.")
- set (CMAKE_ASM${ASM_DIALECT}_FLAGS_RELWITHDEBINFO "${CMAKE_ASM${ASM_DIALECT}_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
- "Flags used by the assembler during Release with Debug Info builds.")
-endif()
-
-mark_as_advanced(CMAKE_ASM${ASM_DIALECT}_FLAGS
- CMAKE_ASM${ASM_DIALECT}_FLAGS_DEBUG
- CMAKE_ASM${ASM_DIALECT}_FLAGS_MINSIZEREL
- CMAKE_ASM${ASM_DIALECT}_FLAGS_RELEASE
- CMAKE_ASM${ASM_DIALECT}_FLAGS_RELWITHDEBINFO
- )
-
+cmake_initialize_per_config_variable(CMAKE_ASM${ASM_DIALECT}_FLAGS "Flags used by the ASM${ASM_DIALECT} compiler")
if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT)
set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
diff --git a/Modules/CMakeASM_MASMInformation.cmake b/Modules/CMakeASM_MASMInformation.cmake
index a38c1140c..9f7e93412 100644
--- a/Modules/CMakeASM_MASMInformation.cmake
+++ b/Modules/CMakeASM_MASMInformation.cmake
@@ -10,5 +10,11 @@ set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS asm)
set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /c /Fo <OBJECT> <SOURCE>")
+# The ASM_MASM compiler id for this compiler is "MSVC", so fill out the runtime library table.
+set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "")
+set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "")
+set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "")
+set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "")
+
include(CMakeASMInformation)
set(ASM_DIALECT)
diff --git a/Modules/CMakeASM_NASMInformation.cmake b/Modules/CMakeASM_NASMInformation.cmake
index 1e3c60845..cb793e7c2 100644
--- a/Modules/CMakeASM_NASMInformation.cmake
+++ b/Modules/CMakeASM_NASMInformation.cmake
@@ -28,7 +28,9 @@ if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT)
endif()
endif()
-set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <INCLUDES> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>")
+if(NOT CMAKE_ASM_NASM_COMPILE_OBJECT)
+ set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <INCLUDES> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>")
+endif()
# Load the generic ASMInformation file:
set(ASM_DIALECT "_NASM")
diff --git a/Modules/CMakeAddFortranSubdirectory.cmake b/Modules/CMakeAddFortranSubdirectory.cmake
index 4649f35a1..2613569d1 100644
--- a/Modules/CMakeAddFortranSubdirectory.cmake
+++ b/Modules/CMakeAddFortranSubdirectory.cmake
@@ -1,46 +1,47 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakeAddFortranSubdirectory
-# ---------------------------
-#
-# Use MinGW gfortran from VS if a fortran compiler is not found.
-#
-# The 'add_fortran_subdirectory' function adds a subdirectory to a
-# project that contains a fortran only sub-project. The module will
-# check the current compiler and see if it can support fortran. If no
-# fortran compiler is found and the compiler is MSVC, then this module
-# will find the MinGW gfortran. It will then use an external project to
-# build with the MinGW tools. It will also create imported targets for
-# the libraries created. This will only work if the fortran code is
-# built into a dll, so BUILD_SHARED_LIBS is turned on in the project.
-# In addition the CMAKE_GNUtoMS option is set to on, so that the MS .lib
-# files are created. Usage is as follows:
-#
-# ::
-#
-# cmake_add_fortran_subdirectory(
-# <subdir> # name of subdirectory
-# PROJECT <project_name> # project name in subdir top CMakeLists.txt
-# ARCHIVE_DIR <dir> # dir where project places .lib files
-# RUNTIME_DIR <dir> # dir where project places .dll files
-# LIBRARIES <lib>... # names of library targets to import
-# LINK_LIBRARIES # link interface libraries for LIBRARIES
-# [LINK_LIBS <lib> <dep>...]...
-# CMAKE_COMMAND_LINE ... # extra command line flags to pass to cmake
-# NO_EXTERNAL_INSTALL # skip installation of external project
-# )
-#
-# Relative paths in ARCHIVE_DIR and RUNTIME_DIR are interpreted with
-# respect to the build directory corresponding to the source directory
-# in which the function is invoked.
-#
-# Limitations:
-#
-# NO_EXTERNAL_INSTALL is required for forward compatibility with a
-# future version that supports installation of the external project
-# binaries during "make install".
+#[=======================================================================[.rst:
+CMakeAddFortranSubdirectory
+---------------------------
+
+Add a fortran-only subdirectory, find a fortran compiler, and build.
+
+The ``cmake_add_fortran_subdirectory`` function adds a subdirectory
+to a project that contains a fortran-only subproject. The module will
+check the current compiler and see if it can support fortran. If no
+fortran compiler is found and the compiler is MSVC, then this module
+will find the MinGW gfortran. It will then use an external project to
+build with the MinGW tools. It will also create imported targets for
+the libraries created. This will only work if the fortran code is
+built into a dll, so :variable:`BUILD_SHARED_LIBS` is turned on in
+the project. In addition the :variable:`CMAKE_GNUtoMS` option is set
+to on, so that Microsoft ``.lib`` files are created. Usage is as follows:
+
+::
+
+ cmake_add_fortran_subdirectory(
+ <subdir> # name of subdirectory
+ PROJECT <project_name> # project name in subdir top CMakeLists.txt
+ ARCHIVE_DIR <dir> # dir where project places .lib files
+ RUNTIME_DIR <dir> # dir where project places .dll files
+ LIBRARIES <lib>... # names of library targets to import
+ LINK_LIBRARIES # link interface libraries for LIBRARIES
+ [LINK_LIBS <lib> <dep>...]...
+ CMAKE_COMMAND_LINE ... # extra command line flags to pass to cmake
+ NO_EXTERNAL_INSTALL # skip installation of external project
+ )
+
+Relative paths in ``ARCHIVE_DIR`` and ``RUNTIME_DIR`` are interpreted with
+respect to the build directory corresponding to the source directory
+in which the function is invoked.
+
+Limitations:
+
+``NO_EXTERNAL_INSTALL`` is required for forward compatibility with a
+future version that supports installation of the external project
+binaries during ``make install``.
+#]=======================================================================]
set(_MS_MINGW_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
include(CheckLanguage)
diff --git a/Modules/CMakeAddNewLanguage.txt b/Modules/CMakeAddNewLanguage.txt
index 612e1a3a5..b0be590ae 100644
--- a/Modules/CMakeAddNewLanguage.txt
+++ b/Modules/CMakeAddNewLanguage.txt
@@ -1,7 +1,7 @@
This file provides a few notes to CMake developers about how to add
support for a new language to CMake. It is also possible to place
-these files in CMAKE_MODULE_PATH within an outside project to add
-languages not supported by upstream CMake. However, this is not
+these files in :variable:`CMAKE_MODULE_PATH` within an outside project
+to add languages not supported by upstream CMake. However, this is not
a fully supported use case.
The implementation behind the scenes of project/enable_language,
@@ -17,17 +17,15 @@ changes in release notes.
CMakeDetermine(LANG)Compiler.cmake -> this should find the compiler for LANG and configure CMake(LANG)Compiler.cmake.in
CMake(LANG)Compiler.cmake.in -> used by CMakeDetermine(LANG)Compiler.cmake
- This file is used to store compiler information and is copied down into try
- compile directories so that try compiles do not need to re-determine and test the LANG
+ This file is used to store compiler information and is copied down into try
+ compile directories so that try compiles do not need to re-determine and test the LANG
CMakeTest(LANG)Compiler.cmake -> test the compiler and set:
- SET(CMAKE_(LANG)_COMPILER_WORKS 1 CACHE INTERNAL "")
+ SET(CMAKE_(LANG)_COMPILER_WORKS 1 CACHE INTERNAL "")
CMake(LANG)Information.cmake -> set up rule variables for LANG :
- CMAKE_(LANG)_CREATE_SHARED_LIBRARY
- CMAKE_(LANG)_CREATE_SHARED_MODULE
- CMAKE_(LANG)_CREATE_STATIC_LIBRARY
- CMAKE_(LANG)_COMPILE_OBJECT
- CMAKE_(LANG)_LINK_EXECUTABLE
-
-
+ CMAKE_(LANG)_CREATE_SHARED_LIBRARY
+ CMAKE_(LANG)_CREATE_SHARED_MODULE
+ CMAKE_(LANG)_CREATE_STATIC_LIBRARY
+ CMAKE_(LANG)_COMPILE_OBJECT
+ CMAKE_(LANG)_LINK_EXECUTABLE
diff --git a/Modules/CMakeBackwardCompatibilityC.cmake b/Modules/CMakeBackwardCompatibilityC.cmake
index 5d86d7313..775a5137d 100644
--- a/Modules/CMakeBackwardCompatibilityC.cmake
+++ b/Modules/CMakeBackwardCompatibilityC.cmake
@@ -59,9 +59,6 @@ if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS)
set (CMAKE_HP_PTHREADS ${CMAKE_HP_PTHREADS_INIT} CACHE BOOL
"Use HP pthreads.")
- set (CMAKE_USE_SPROC ${CMAKE_USE_SPROC_INIT} CACHE BOOL
- "Use sproc libs.")
-
if(__ERASE_CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
set(CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
set(__ERASE_CMAKE_TRY_COMPILE_OSX_ARCHITECTURES)
@@ -72,7 +69,6 @@ mark_as_advanced(
CMAKE_HP_PTHREADS
CMAKE_THREAD_LIBS
CMAKE_USE_PTHREADS
-CMAKE_USE_SPROC
CMAKE_USE_WIN32_THREADS
CMAKE_X_CFLAGS
CMAKE_X_LIBS
diff --git a/Modules/CMakeBackwardCompatibilityCXX.cmake b/Modules/CMakeBackwardCompatibilityCXX.cmake
index cbd5ea76c..02744a985 100644
--- a/Modules/CMakeBackwardCompatibilityCXX.cmake
+++ b/Modules/CMakeBackwardCompatibilityCXX.cmake
@@ -1,29 +1,27 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakeBackwardCompatibilityCXX
-# -----------------------------
-#
-# define a bunch of backwards compatibility variables
-#
-# ::
-#
-# CMAKE_ANSI_CXXFLAGS - flag for ansi c++
-# CMAKE_HAS_ANSI_STRING_STREAM - has <strstream>
-# include(TestForANSIStreamHeaders)
-# include(CheckIncludeFileCXX)
-# include(TestForSTDNamespace)
-# include(TestForANSIForScope)
+#[=======================================================================[.rst:
+CMakeBackwardCompatibilityCXX
+-----------------------------
+
+define a bunch of backwards compatibility variables
+
+::
+
+ CMAKE_ANSI_CXXFLAGS - flag for ansi c++
+ CMAKE_HAS_ANSI_STRING_STREAM - has <strstream>
+ include(TestForANSIStreamHeaders)
+ include(CheckIncludeFileCXX)
+ include(TestForSTDNamespace)
+ include(TestForANSIForScope)
+#]=======================================================================]
if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS)
# check for some ANSI flags in the CXX compiler if it is not gnu
if(NOT CMAKE_COMPILER_IS_GNUCXX)
include(TestCXXAcceptsFlag)
set(CMAKE_TRY_ANSI_CXX_FLAGS "")
- if(CMAKE_SYSTEM_NAME MATCHES "IRIX")
- set(CMAKE_TRY_ANSI_CXX_FLAGS "-LANG:std")
- endif()
if(CMAKE_SYSTEM_NAME MATCHES "OSF")
set(CMAKE_TRY_ANSI_CXX_FLAGS "-std strict_ansi -nopure_cname")
endif()
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in
index 974a57927..9b8d423a6 100644
--- a/Modules/CMakeCCompiler.cmake.in
+++ b/Modules/CMakeCCompiler.cmake.in
@@ -2,6 +2,7 @@ set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@")
set(CMAKE_C_COMPILER_ARG1 "@CMAKE_C_COMPILER_ARG1@")
set(CMAKE_C_COMPILER_ID "@CMAKE_C_COMPILER_ID@")
set(CMAKE_C_COMPILER_VERSION "@CMAKE_C_COMPILER_VERSION@")
+set(CMAKE_C_COMPILER_VERSION_INTERNAL "@CMAKE_C_COMPILER_VERSION_INTERNAL@")
set(CMAKE_C_COMPILER_WRAPPER "@CMAKE_C_COMPILER_WRAPPER@")
set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "@CMAKE_C_STANDARD_COMPUTED_DEFAULT@")
set(CMAKE_C_COMPILE_FEATURES "@CMAKE_C_COMPILE_FEATURES@")
@@ -11,14 +12,17 @@ set(CMAKE_C11_COMPILE_FEATURES "@CMAKE_C11_COMPILE_FEATURES@")
set(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@")
set(CMAKE_C_SIMULATE_ID "@CMAKE_C_SIMULATE_ID@")
+set(CMAKE_C_COMPILER_FRONTEND_VARIANT "@CMAKE_C_COMPILER_FRONTEND_VARIANT@")
set(CMAKE_C_SIMULATE_VERSION "@CMAKE_C_SIMULATE_VERSION@")
+@_SET_CMAKE_C_COMPILER_ARCHITECTURE_ID@
@SET_MSVC_C_ARCHITECTURE_ID@
-@SET_CMAKE_XCODE_CURRENT_ARCH@
+@SET_CMAKE_XCODE_ARCHS@
set(CMAKE_AR "@CMAKE_AR@")
set(CMAKE_C_COMPILER_AR "@CMAKE_C_COMPILER_AR@")
set(CMAKE_RANLIB "@CMAKE_RANLIB@")
set(CMAKE_C_COMPILER_RANLIB "@CMAKE_C_COMPILER_RANLIB@")
set(CMAKE_LINKER "@CMAKE_LINKER@")
+set(CMAKE_MT "@CMAKE_MT@")
set(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@)
set(CMAKE_C_COMPILER_LOADED 1)
set(CMAKE_C_COMPILER_WORKS @CMAKE_C_COMPILER_WORKS@)
@@ -66,6 +70,7 @@ endif()
@CMAKE_C_SYSROOT_FLAG_CODE@
@CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
+set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES@")
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "@CMAKE_C_IMPLICIT_LINK_LIBRARIES@")
set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_DIRECTORIES@")
set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
diff --git a/Modules/CMakeCCompilerABI.c b/Modules/CMakeCCompilerABI.c
index 55f9a9b51..08cf39bd8 100644
--- a/Modules/CMakeCCompilerABI.c
+++ b/Modules/CMakeCCompilerABI.c
@@ -1,9 +1,9 @@
#ifdef __cplusplus
-#error "A C++ compiler has been selected for C."
+# error "A C++ compiler has been selected for C."
#endif
#ifdef __CLASSIC_C__
-#define const
+# define const
#endif
#include "CMakeCompilerABI.h"
diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in
index 95184c982..2f6bdb4a7 100644
--- a/Modules/CMakeCCompilerId.c.in
+++ b/Modules/CMakeCCompilerId.c.in
@@ -34,7 +34,8 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
@CMAKE_C_COMPILER_ID_ERROR_FOR_TEST@
#if !defined(__STDC__)
-# if defined(_MSC_VER) && !defined(__clang__)
+# if (defined(_MSC_VER) && !defined(__clang__)) \
+ || (defined(__ibmxl__) || defined(__IBMC__))
# define C_DIALECT "90"
# else
# define C_DIALECT
@@ -67,6 +68,9 @@ int main(int argc, char* argv[])
#ifdef COMPILER_VERSION_MAJOR
require += info_version[argc];
#endif
+#ifdef COMPILER_VERSION_INTERNAL
+ require += info_version_internal[argc];
+#endif
#ifdef SIMULATE_ID
require += info_simulate[argc];
#endif
diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake
index 71aadb474..df43559c9 100644
--- a/Modules/CMakeCInformation.cmake
+++ b/Modules/CMakeCInformation.cmake
@@ -35,21 +35,21 @@ endif()
# load a hardware specific file, mostly useful for embedded compilers
if(CMAKE_SYSTEM_PROCESSOR)
if(CMAKE_C_COMPILER_ID)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-C-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-C-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif()
if (NOT _INCLUDED_FILE)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
endif ()
endif()
# load the system- and compiler specific files
if(CMAKE_C_COMPILER_ID)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-C
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-C
OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif()
if (NOT _INCLUDED_FILE)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME}
OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif ()
@@ -102,30 +102,7 @@ endif()
set(CMAKE_C_FLAGS_INIT "$ENV{CFLAGS} ${CMAKE_C_FLAGS_INIT}")
-foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO)
- string(STRIP "${CMAKE_C_FLAGS${c}_INIT}" CMAKE_C_FLAGS${c}_INIT)
-endforeach()
-
-set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_INIT}" CACHE STRING
- "Flags used by the compiler during all build types.")
-
-if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
- get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
- # default build type is none
- if(NOT _GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_NO_BUILD_TYPE)
- set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING
- "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
- endif()
- unset(_GENERATOR_IS_MULTI_CONFIG)
- set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT}" CACHE STRING
- "Flags used by the compiler during debug builds.")
- set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL_INIT}" CACHE STRING
- "Flags used by the compiler during release builds for minimum size.")
- set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_INIT}" CACHE STRING
- "Flags used by the compiler during release builds.")
- set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
- "Flags used by the compiler during release builds with debug info.")
-endif()
+cmake_initialize_per_config_variable(CMAKE_C_FLAGS "Flags used by the C compiler")
if(CMAKE_C_STANDARD_LIBRARIES_INIT)
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES_INIT}"
@@ -208,13 +185,6 @@ if(NOT CMAKE_EXECUTABLE_RPATH_LINK_C_FLAG)
set(CMAKE_EXECUTABLE_RPATH_LINK_C_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG})
endif()
-mark_as_advanced(
-CMAKE_C_FLAGS
-CMAKE_C_FLAGS_DEBUG
-CMAKE_C_FLAGS_MINSIZEREL
-CMAKE_C_FLAGS_RELEASE
-CMAKE_C_FLAGS_RELWITHDEBINFO
-)
set(CMAKE_C_INFORMATION_LOADED 1)
diff --git a/Modules/CMakeCSharpCompiler.cmake.in b/Modules/CMakeCSharpCompiler.cmake.in
index 5ecc4800b..3d49b6bc9 100644
--- a/Modules/CMakeCSharpCompiler.cmake.in
+++ b/Modules/CMakeCSharpCompiler.cmake.in
@@ -2,6 +2,7 @@ set(CMAKE_CSharp_COMPILER "@CMAKE_CSharp_COMPILER@")
set(CMAKE_CSharp_COMPILER_ID "@CMAKE_CSharp_COMPILER_ID@")
set(CMAKE_CSharp_COMPILER_VERSION "@CMAKE_CSharp_COMPILER_VERSION@")
+set(CMAKE_CSharp_COMPILER_LOADED 1)
set(CMAKE_CSharp_COMPILER_WORKS "@CMAKE_CSharp_COMPILER_WORKS@")
set(CMAKE_CSharp_COMPILER_ID_RUN "@CMAKE_CSharp_COMPILER_ID_RUN@")
diff --git a/Modules/CMakeCSharpInformation.cmake b/Modules/CMakeCSharpInformation.cmake
index f71dcefe9..48e1a1e5f 100644
--- a/Modules/CMakeCSharpInformation.cmake
+++ b/Modules/CMakeCSharpInformation.cmake
@@ -10,7 +10,7 @@ get_filename_component(CMAKE_BASE_NAME "${CMAKE_CSharp_COMPILER}" NAME_WE)
set(CMAKE_BUILD_TYPE_INIT Debug)
-set(CMAKE_CSharp_FLAGS_INIT "/define:TRACE /langversion:3 /nowin32manifest")
+set(CMAKE_CSharp_FLAGS_INIT "/define:TRACE /langversion:3")
set(CMAKE_CSharp_FLAGS_DEBUG_INIT "/debug:full /optimize- /warn:3 /errorreport:prompt /define:DEBUG")
set(CMAKE_CSharp_FLAGS_RELEASE_INIT "/debug:none /optimize /warn:1 /errorreport:queue")
set(CMAKE_CSharp_FLAGS_RELWITHDEBINFO_INIT "/debug:full /optimize-")
@@ -44,23 +44,8 @@ endif()
# use _INIT variables so that this only happens the first time
# and you can set these flags in the cmake cache
set(CMAKE_CSharp_FLAGS_INIT "$ENV{CSFLAGS} ${CMAKE_CSharp_FLAGS_INIT}")
-# avoid just having a space as the initial value for the cache
-if(CMAKE_CSharp_FLAGS_INIT STREQUAL " ")
- set(CMAKE_CSharp_FLAGS_INIT)
-endif()
-set (CMAKE_CSharp_FLAGS "${CMAKE_CSharp_FLAGS_INIT}" CACHE STRING
- "Flags used by the C# compiler during all build types.")
-if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
- set (CMAKE_CSharp_FLAGS_DEBUG "${CMAKE_CSharp_FLAGS_DEBUG_INIT}" CACHE STRING
- "Flags used by the C# compiler during debug builds.")
- set (CMAKE_CSharp_FLAGS_MINSIZEREL "${CMAKE_CSharp_FLAGS_MINSIZEREL_INIT}" CACHE STRING
- "Flags used by the C# compiler during release builds for minimum size.")
- set (CMAKE_CSharp_FLAGS_RELEASE "${CMAKE_CSharp_FLAGS_RELEASE_INIT}" CACHE STRING
- "Flags used by the C# compiler during release builds.")
- set (CMAKE_CSharp_FLAGS_RELWITHDEBINFO "${CMAKE_CSharp_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
- "Flags used by the C# compiler during release builds with debug info.")
-endif()
+cmake_initialize_per_config_variable(CMAKE_CSharp_FLAGS "Flags used by the C# compiler")
if(CMAKE_CSharp_STANDARD_LIBRARIES_INIT)
set(CMAKE_CSharp_STANDARD_LIBRARIES "${CMAKE_CSharp_STANDARD_LIBRARIES_INIT}"
@@ -71,49 +56,12 @@ endif()
# set missing flags (if they are not defined). This is needed in the
# unlikely case that you have only C# and no C/C++ targets in your
# project.
-if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS)
- set(CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "" FORCE)
-endif()
-if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_DEBUG)
- set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "" CACHE STRING "" FORCE)
-endif()
-if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_RELEASE)
- set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "" CACHE STRING "" FORCE)
-endif()
-if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL)
- set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "" CACHE STRING "" FORCE)
-endif()
-if(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO)
- set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "" CACHE STRING "" FORCE)
-endif()
-
-if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS)
- set(CMAKE_EXE_LINKER_FLAGS "" CACHE STRING "" FORCE)
-endif()
-if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_DEBUG)
- set(CMAKE_EXE_LINKER_FLAGS_DEBUG "" CACHE STRING "" FORCE)
-endif()
-if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_RELEASE)
- set(CMAKE_EXE_LINKER_FLAGS_RELEASE "" CACHE STRING "" FORCE)
-endif()
-if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_MINSIZEREL)
- set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "" CACHE STRING "" FORCE)
-endif()
-if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO)
- set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "" CACHE STRING "" FORCE)
-endif()
+cmake_initialize_per_config_variable(CMAKE_EXE_LINKER_FLAGS "Flags used by the linker")
+cmake_initialize_per_config_variable(CMAKE_SHARED_LINKER_FLAGS "Flags used by the linker during the creation of shared libraries")
set(CMAKE_CSharp_CREATE_SHARED_LIBRARY "CSharp_NO_CREATE_SHARED_LIBRARY")
set(CMAKE_CSharp_CREATE_SHARED_MODULE "CSharp_NO_CREATE_SHARED_MODULE")
set(CMAKE_CSharp_LINK_EXECUTABLE "CSharp_NO_LINK_EXECUTABLE")
-mark_as_advanced(
- CMAKE_CSharp_FLAGS
- CMAKE_CSharp_FLAGS_RELEASE
- CMAKE_CSharp_FLAGS_RELWITHDEBINFO
- CMAKE_CSharp_FLAGS_MINSIZEREL
- CMAKE_CSharp_FLAGS_DEBUG
- )
-
set(CMAKE_CSharp_USE_RESPONSE_FILE_FOR_OBJECTS 1)
set(CMAKE_CSharp_INFORMATION_LOADED 1)
diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in
index f524e5f36..711129a39 100644
--- a/Modules/CMakeCUDACompiler.cmake.in
+++ b/Modules/CMakeCUDACompiler.cmake.in
@@ -11,6 +11,7 @@ set(CMAKE_CUDA_SIMULATE_VERSION "@CMAKE_CUDA_SIMULATE_VERSION@")
set(CMAKE_CUDA_COMPILER_ENV_VAR "CUDACXX")
set(CMAKE_CUDA_HOST_COMPILER_ENV_VAR "CUDAHOSTCXX")
+set(CMAKE_CUDA_COMPILER_LOADED 1)
set(CMAKE_CUDA_COMPILER_ID_RUN 1)
set(CMAKE_CUDA_SOURCE_FILE_EXTENSIONS cu)
set(CMAKE_CUDA_LINKER_PREFERENCE 15)
@@ -22,6 +23,10 @@ set(CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBR
set(CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES@")
set(CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
+set(CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES@")
set(CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES "@CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES@")
set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES@")
set(CMAKE_CUDA_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
+
+set(CMAKE_LINKER "@CMAKE_LINKER@")
+set(CMAKE_MT "@CMAKE_MT@")
diff --git a/Modules/CMakeCUDACompilerABI.cu b/Modules/CMakeCUDACompilerABI.cu
index 99bacefb6..702a7c53a 100644
--- a/Modules/CMakeCUDACompilerABI.cu
+++ b/Modules/CMakeCUDACompilerABI.cu
@@ -1,5 +1,5 @@
#ifndef __CUDACC__
-#error "A C or C++ compiler has been selected for CUDA"
+# error "A C or C++ compiler has been selected for CUDA"
#endif
#include "CMakeCompilerABI.h"
diff --git a/Modules/CMakeCUDACompilerId.cu.in b/Modules/CMakeCUDACompilerId.cu.in
index 018bab7ff..6eda9244c 100644
--- a/Modules/CMakeCUDACompilerId.cu.in
+++ b/Modules/CMakeCUDACompilerId.cu.in
@@ -17,7 +17,9 @@ char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
@CMAKE_CUDA_COMPILER_ID_ERROR_FOR_TEST@
const char* info_language_dialect_default = "INFO" ":" "dialect_default["
-#if __cplusplus > 201402L
+#if __cplusplus > 201703L
+ "20"
+#elif __cplusplus >= 201703L
"17"
#elif __cplusplus >= 201402L
"14"
diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake
index f4609cd8b..b0d80d161 100644
--- a/Modules/CMakeCUDAInformation.cmake
+++ b/Modules/CMakeCUDAInformation.cmake
@@ -17,9 +17,9 @@ endif()
if(CMAKE_CUDA_COMPILER_ID)
# load a hardware specific file, mostly useful for embedded compilers
if(CMAKE_SYSTEM_PROCESSOR)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CUDA_COMPILER_ID}-CUDA-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_CUDA_COMPILER_ID}-CUDA-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
endif()
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CUDA_COMPILER_ID}-CUDA OPTIONAL)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_CUDA_COMPILER_ID}-CUDA OPTIONAL)
endif()
@@ -74,24 +74,7 @@ endif()
# and you can set these flags in the cmake cache
set(CMAKE_CUDA_FLAGS_INIT "$ENV{CUDAFLAGS} ${CMAKE_CUDA_FLAGS_INIT}")
-foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO)
- string(STRIP "${CMAKE_CUDA_FLAGS${c}_INIT}" CMAKE_CUDA_FLAGS${c}_INIT)
-endforeach()
-
-set (CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS_INIT}" CACHE STRING
- "Flags used by the compiler during all build types.")
-
-if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
- set (CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG_INIT}" CACHE STRING
- "Flags used by the compiler during debug builds.")
- set (CMAKE_CUDA_FLAGS_MINSIZEREL "${CMAKE_CUDA_FLAGS_MINSIZEREL_INIT}" CACHE STRING
- "Flags used by the compiler during release builds for minimum size.")
- set (CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE_INIT}" CACHE STRING
- "Flags used by the compiler during release builds.")
- set (CMAKE_CUDA_FLAGS_RELWITHDEBINFO "${CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
- "Flags used by the compiler during release builds with debug info.")
-
-endif()
+cmake_initialize_per_config_variable(CMAKE_CUDA_FLAGS "Flags used by the CUDA compiler")
if(CMAKE_CUDA_STANDARD_LIBRARIES_INIT)
set(CMAKE_CUDA_STANDARD_LIBRARIES "${CMAKE_CUDA_STANDARD_LIBRARIES_INIT}"
@@ -185,33 +168,41 @@ endif()
# compile a cu file into an executable
if(NOT CMAKE_CUDA_LINK_EXECUTABLE)
set(CMAKE_CUDA_LINK_EXECUTABLE
- "<CMAKE_CUDA_HOST_LINK_LAUNCHER> <CMAKE_CUDA_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_LINKS}")
+ "<CMAKE_CUDA_HOST_LINK_LAUNCHER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_LINKS}")
endif()
-if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0")
+if( CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND
+ CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0")
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "-Wno-deprecated-gpu-targets")
else()
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "")
endif()
+# Add implicit host link directories that contain device libraries
+# to the device link line.
+set(__IMPLICT_DLINK_DIRS ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
+if(__IMPLICT_DLINK_DIRS)
+ list(REMOVE_ITEM __IMPLICT_DLINK_DIRS ${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES})
+endif()
+set(__IMPLICT_DLINK_FLAGS )
+foreach(dir ${__IMPLICT_DLINK_DIRS})
+ if(EXISTS "${dir}/libcurand_static.a")
+ string(APPEND __IMPLICT_DLINK_FLAGS " -L\"${dir}\"")
+ endif()
+endforeach()
+unset(__IMPLICT_DLINK_DIRS)
#These are used when linking relocatable (dc) cuda code
if(NOT CMAKE_CUDA_DEVICE_LINK_LIBRARY)
set(CMAKE_CUDA_DEVICE_LINK_LIBRARY
- "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <CMAKE_CUDA_LINK_FLAGS> <LANGUAGE_COMPILE_FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
+ "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <LANGUAGE_COMPILE_FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}")
endif()
if(NOT CMAKE_CUDA_DEVICE_LINK_EXECUTABLE)
set(CMAKE_CUDA_DEVICE_LINK_EXECUTABLE
- "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <FLAGS> <CMAKE_CUDA_LINK_FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
+ "<CMAKE_CUDA_COMPILER> ${CMAKE_CUDA_HOST_FLAGS} <FLAGS> ${CMAKE_CUDA_COMPILE_OPTIONS_PIC} ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES>${__IMPLICT_DLINK_FLAGS}")
endif()
unset(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS)
-
-mark_as_advanced(
-CMAKE_CUDA_FLAGS
-CMAKE_CUDA_FLAGS_RELEASE
-CMAKE_CUDA_FLAGS_RELWITHDEBINFO
-CMAKE_CUDA_FLAGS_MINSIZEREL
-CMAKE_CUDA_FLAGS_DEBUG)
+unset(__IMPLICT_DLINK_FLAGS)
set(CMAKE_CUDA_INFORMATION_LOADED 1)
diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in
index fda79508b..efb8abf09 100644
--- a/Modules/CMakeCXXCompiler.cmake.in
+++ b/Modules/CMakeCXXCompiler.cmake.in
@@ -2,6 +2,7 @@ set(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@")
set(CMAKE_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@")
set(CMAKE_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@")
set(CMAKE_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@")
+set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "@CMAKE_CXX_COMPILER_VERSION_INTERNAL@")
set(CMAKE_CXX_COMPILER_WRAPPER "@CMAKE_CXX_COMPILER_WRAPPER@")
set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "@CMAKE_CXX_STANDARD_COMPUTED_DEFAULT@")
set(CMAKE_CXX_COMPILE_FEATURES "@CMAKE_CXX_COMPILE_FEATURES@")
@@ -9,17 +10,21 @@ set(CMAKE_CXX98_COMPILE_FEATURES "@CMAKE_CXX98_COMPILE_FEATURES@")
set(CMAKE_CXX11_COMPILE_FEATURES "@CMAKE_CXX11_COMPILE_FEATURES@")
set(CMAKE_CXX14_COMPILE_FEATURES "@CMAKE_CXX14_COMPILE_FEATURES@")
set(CMAKE_CXX17_COMPILE_FEATURES "@CMAKE_CXX17_COMPILE_FEATURES@")
+set(CMAKE_CXX20_COMPILE_FEATURES "@CMAKE_CXX20_COMPILE_FEATURES@")
set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@")
set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@")
+set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "@CMAKE_CXX_COMPILER_FRONTEND_VARIANT@")
set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@")
+@_SET_CMAKE_CXX_COMPILER_ARCHITECTURE_ID@
@SET_MSVC_CXX_ARCHITECTURE_ID@
-@SET_CMAKE_XCODE_CURRENT_ARCH@
+@SET_CMAKE_XCODE_ARCHS@
set(CMAKE_AR "@CMAKE_AR@")
set(CMAKE_CXX_COMPILER_AR "@CMAKE_CXX_COMPILER_AR@")
set(CMAKE_RANLIB "@CMAKE_RANLIB@")
set(CMAKE_CXX_COMPILER_RANLIB "@CMAKE_CXX_COMPILER_RANLIB@")
set(CMAKE_LINKER "@CMAKE_LINKER@")
+set(CMAKE_MT "@CMAKE_MT@")
set(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@)
set(CMAKE_CXX_COMPILER_LOADED 1)
set(CMAKE_CXX_COMPILER_WORKS @CMAKE_CXX_COMPILER_WORKS@)
@@ -37,8 +42,17 @@ if(CMAKE_COMPILER_IS_MINGW)
set(MINGW 1)
endif()
set(CMAKE_CXX_COMPILER_ID_RUN 1)
+set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;CPP)
set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
-set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP)
+
+foreach (lang C OBJC OBJCXX)
+ if (CMAKE_${lang}_COMPILER_ID_RUN)
+ foreach(extension IN LISTS CMAKE_${lang}_SOURCE_FILE_EXTENSIONS)
+ list(REMOVE_ITEM CMAKE_CXX_SOURCE_FILE_EXTENSIONS ${extension})
+ endforeach()
+ endif()
+endforeach()
+
set(CMAKE_CXX_LINKER_PREFERENCE 30)
set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1)
@@ -68,6 +82,7 @@ endif()
@CMAKE_CXX_SYSROOT_FLAG_CODE@
@CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
+set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES@")
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "@CMAKE_CXX_IMPLICIT_LINK_LIBRARIES@")
set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES@")
set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
diff --git a/Modules/CMakeCXXCompilerABI.cpp b/Modules/CMakeCXXCompilerABI.cpp
index 2dee883fd..236053452 100644
--- a/Modules/CMakeCXXCompilerABI.cpp
+++ b/Modules/CMakeCXXCompilerABI.cpp
@@ -1,5 +1,5 @@
#ifndef __cplusplus
-#error "A C compiler has been selected for C++."
+# error "A C compiler has been selected for C++."
#endif
#include "CMakeCompilerABI.h"
diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in
index 9aa096dbb..a743ce781 100644
--- a/Modules/CMakeCXXCompilerId.cpp.in
+++ b/Modules/CMakeCXXCompilerId.cpp.in
@@ -27,12 +27,30 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
@CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@
@CMAKE_CXX_COMPILER_ID_ERROR_FOR_TEST@
+#if defined(__INTEL_COMPILER) && defined(_MSVC_LANG) && _MSVC_LANG < 201403L
+# if defined(__INTEL_CXX11_MODE__)
+# if defined(__cpp_aggregate_nsdmi)
+# define CXX_STD 201402L
+# else
+# define CXX_STD 201103L
+# endif
+# else
+# define CXX_STD 199711L
+# endif
+#elif defined(_MSC_VER) && defined(_MSVC_LANG)
+# define CXX_STD _MSVC_LANG
+#else
+# define CXX_STD __cplusplus
+#endif
+
const char* info_language_dialect_default = "INFO" ":" "dialect_default["
-#if __cplusplus > 201402L
+#if CXX_STD > 201703L
+ "20"
+#elif CXX_STD >= 201703L
"17"
-#elif __cplusplus >= 201402L
+#elif CXX_STD >= 201402L
"14"
-#elif __cplusplus >= 201103L
+#elif CXX_STD >= 201103L
"11"
#else
"98"
@@ -49,6 +67,9 @@ int main(int argc, char* argv[])
#ifdef COMPILER_VERSION_MAJOR
require += info_version[argc];
#endif
+#ifdef COMPILER_VERSION_INTERNAL
+ require += info_version_internal[argc];
+#endif
#ifdef SIMULATE_ID
require += info_simulate[argc];
#endif
diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake
index ec731fae7..a896b99b6 100644
--- a/Modules/CMakeCXXInformation.cmake
+++ b/Modules/CMakeCXXInformation.cmake
@@ -36,19 +36,19 @@ endif()
# load a hardware specific file, mostly useful for embedded compilers
if(CMAKE_SYSTEM_PROCESSOR)
if(CMAKE_CXX_COMPILER_ID)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-CXX-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-CXX-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif()
if (NOT _INCLUDED_FILE)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
endif ()
endif()
# load the system- and compiler specific files
if(CMAKE_CXX_COMPILER_ID)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-CXX OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}-CXX OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif()
if (NOT _INCLUDED_FILE)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL
RESULT_VARIABLE _INCLUDED_FILE)
endif ()
@@ -105,6 +105,12 @@ endif()
if(NOT CMAKE_CXX_COMPILE_OPTIONS_PIE)
set(CMAKE_CXX_COMPILE_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE})
endif()
+if(NOT CMAKE_CXX_LINK_OPTIONS_PIE)
+ set(CMAKE_CXX_LINK_OPTIONS_PIE ${CMAKE_C_LINK_OPTIONS_PIE})
+endif()
+if(NOT CMAKE_CXX_LINK_OPTIONS_NO_PIE)
+ set(CMAKE_CXX_LINK_OPTIONS_NO_PIE ${CMAKE_C_LINK_OPTIONS_NO_PIE})
+endif()
if(NOT CMAKE_CXX_COMPILE_OPTIONS_DLL)
set(CMAKE_CXX_COMPILE_OPTIONS_DLL ${CMAKE_C_COMPILE_OPTIONS_DLL})
@@ -158,10 +164,6 @@ if(NOT CMAKE_INCLUDE_FLAG_CXX)
set(CMAKE_INCLUDE_FLAG_CXX ${CMAKE_INCLUDE_FLAG_C})
endif()
-if(NOT CMAKE_INCLUDE_FLAG_SEP_CXX)
- set(CMAKE_INCLUDE_FLAG_SEP_CXX ${CMAKE_INCLUDE_FLAG_SEP_C})
-endif()
-
# for most systems a module is the same as a shared library
# so unless the variable CMAKE_MODULE_EXISTS is set just
# copy the values from the LIBRARY variables
@@ -197,24 +199,7 @@ endforeach()
# and you can set these flags in the cmake cache
set(CMAKE_CXX_FLAGS_INIT "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS_INIT}")
-foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO)
- string(STRIP "${CMAKE_CXX_FLAGS${c}_INIT}" CMAKE_CXX_FLAGS${c}_INIT)
-endforeach()
-
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT}" CACHE STRING
- "Flags used by the compiler during all build types.")
-
-if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
- set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT}" CACHE STRING
- "Flags used by the compiler during debug builds.")
- set (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT}" CACHE STRING
- "Flags used by the compiler during release builds for minimum size.")
- set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_INIT}" CACHE STRING
- "Flags used by the compiler during release builds.")
- set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
- "Flags used by the compiler during release builds with debug info.")
-
-endif()
+cmake_initialize_per_config_variable(CMAKE_CXX_FLAGS "Flags used by the CXX compiler")
if(CMAKE_CXX_STANDARD_LIBRARIES_INIT)
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES_INIT}"
@@ -287,11 +272,6 @@ endif()
mark_as_advanced(
CMAKE_VERBOSE_MAKEFILE
-CMAKE_CXX_FLAGS
-CMAKE_CXX_FLAGS_RELEASE
-CMAKE_CXX_FLAGS_RELWITHDEBINFO
-CMAKE_CXX_FLAGS_MINSIZEREL
-CMAKE_CXX_FLAGS_DEBUG)
+)
set(CMAKE_CXX_INFORMATION_LOADED 1)
-
diff --git a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake
index e60ffe019..e1ce617dc 100644
--- a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake
+++ b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake
@@ -7,28 +7,29 @@
# any way between releases.
macro (CHECK_COMPILER_FLAG_COMMON_PATTERNS _VAR)
- set(${_VAR}
- FAIL_REGEX "[Uu]nrecogni[sz]ed .*option" # GNU, NAG
- FAIL_REGEX "unknown .*option" # Clang
- FAIL_REGEX "optimization flag .* not supported" # Clang
- FAIL_REGEX "unknown argument ignored" # Clang (cl)
- FAIL_REGEX "ignoring unknown option" # MSVC, Intel
- FAIL_REGEX "warning D9002" # MSVC, any lang
- FAIL_REGEX "option.*not supported" # Intel
- FAIL_REGEX "invalid argument .*option" # Intel
- FAIL_REGEX "ignoring option .*argument required" # Intel
- FAIL_REGEX "ignoring option .*argument is of wrong type" # Intel
- FAIL_REGEX "[Uu]nknown option" # HP
- FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro
- FAIL_REGEX "command option .* is not recognized" # XL
- FAIL_REGEX "command option .* contains an incorrect subargument" # XL
- FAIL_REGEX "Option .* is not recognized. Option will be ignored." # XL
- FAIL_REGEX "not supported in this configuration. ignored" # AIX
- FAIL_REGEX "File with unknown suffix passed to linker" # PGI
- FAIL_REGEX "[Uu]nknown switch" # PGI
- FAIL_REGEX "WARNING: unknown flag:" # Open64
- FAIL_REGEX "Incorrect command line option:" # Borland
- FAIL_REGEX "Warning: illegal option" # SunStudio 12
- FAIL_REGEX "[Ww]arning: Invalid suboption" # Fujitsu
- )
+ set(${_VAR}
+ FAIL_REGEX "[Uu]nrecogni[sz]ed .*option" # GNU, NAG
+ FAIL_REGEX "unknown .*option" # Clang
+ FAIL_REGEX "optimization flag .* not supported" # Clang
+ FAIL_REGEX "unknown argument ignored" # Clang (cl)
+ FAIL_REGEX "ignoring unknown option" # MSVC, Intel
+ FAIL_REGEX "warning D9002" # MSVC, any lang
+ FAIL_REGEX "option.*not supported" # Intel
+ FAIL_REGEX "invalid argument .*option" # Intel
+ FAIL_REGEX "ignoring option .*argument required" # Intel
+ FAIL_REGEX "ignoring option .*argument is of wrong type" # Intel
+ FAIL_REGEX "[Uu]nknown option" # HP
+ FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro
+ FAIL_REGEX "command option .* is not recognized" # XL
+ FAIL_REGEX "command option .* contains an incorrect subargument" # XL
+ FAIL_REGEX "Option .* is not recognized. Option will be ignored." # XL
+ FAIL_REGEX "not supported in this configuration. ignored" # AIX
+ FAIL_REGEX "File with unknown suffix passed to linker" # PGI
+ FAIL_REGEX "[Uu]nknown switch" # PGI
+ FAIL_REGEX "WARNING: unknown flag:" # Open64
+ FAIL_REGEX "Incorrect command line option:" # Borland
+ FAIL_REGEX "Warning: illegal option" # SunStudio 12
+ FAIL_REGEX "[Ww]arning: Invalid suboption" # Fujitsu
+ FAIL_REGEX "An invalid option .* appears on the command line" # Cray
+ )
endmacro ()
diff --git a/Modules/CMakeCommonLanguageInclude.cmake b/Modules/CMakeCommonLanguageInclude.cmake
index 43b5da022..b043e1815 100644
--- a/Modules/CMakeCommonLanguageInclude.cmake
+++ b/Modules/CMakeCommonLanguageInclude.cmake
@@ -10,120 +10,14 @@ string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " $ENV{LDFLAGS}")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " $ENV{LDFLAGS}")
string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " $ENV{LDFLAGS}")
-foreach(t EXE SHARED MODULE STATIC)
- foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO)
- string(STRIP "${CMAKE_${t}_LINKER_FLAGS${c}_INIT}" CMAKE_${t}_LINKER_FLAGS${c}_INIT)
- endforeach()
-endforeach()
-
-if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
- get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
- # default build type is none
- if(NOT _GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_NO_BUILD_TYPE)
- set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING
- "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
- endif()
- unset(_GENERATOR_IS_MULTI_CONFIG)
-
- set (CMAKE_EXE_LINKER_FLAGS_DEBUG ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT} CACHE STRING
- "Flags used by the linker during debug builds.")
-
- set (CMAKE_EXE_LINKER_FLAGS_MINSIZEREL ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT} CACHE STRING
- "Flags used by the linker during release minsize builds.")
-
- set (CMAKE_EXE_LINKER_FLAGS_RELEASE ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT} CACHE STRING
- "Flags used by the linker during release builds.")
-
- set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
- ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
- "Flags used by the linker during Release with Debug Info builds.")
-
- set (CMAKE_SHARED_LINKER_FLAGS_DEBUG ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT} CACHE STRING
- "Flags used by the linker during debug builds.")
-
- set (CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL ${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL_INIT}
- CACHE STRING
- "Flags used by the linker during release minsize builds.")
-
- set (CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT} CACHE STRING
- "Flags used by the linker during release builds.")
-
- set (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
- ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
- "Flags used by the linker during Release with Debug Info builds.")
-
- set (CMAKE_MODULE_LINKER_FLAGS_DEBUG ${CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT} CACHE STRING
- "Flags used by the linker during debug builds.")
-
- set (CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL ${CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL_INIT}
- CACHE STRING
- "Flags used by the linker during release minsize builds.")
-
- set (CMAKE_MODULE_LINKER_FLAGS_RELEASE ${CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT} CACHE STRING
- "Flags used by the linker during release builds.")
-
- set (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
- ${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
- "Flags used by the linker during Release with Debug Info builds.")
-
- set (CMAKE_STATIC_LINKER_FLAGS_DEBUG ${CMAKE_STATIC_LINKER_FLAGS_DEBUG_INIT} CACHE STRING
- "Flags used by the linker during debug builds.")
-
- set (CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL ${CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL_INIT}
- CACHE STRING
- "Flags used by the linker during release minsize builds.")
-
- set (CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELEASE_INIT} CACHE STRING
- "Flags used by the linker during release builds.")
-
- set (CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
- ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
- "Flags used by the linker during Release with Debug Info builds.")
-endif()
-
-# executable linker flags
-set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT}"
- CACHE STRING "Flags used by the linker.")
-
-# shared linker flags
-set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT}"
- CACHE STRING "Flags used by the linker during the creation of dll's.")
-
-# module linker flags
-set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT}"
- CACHE STRING "Flags used by the linker during the creation of modules.")
-
-# static linker flags
-set (CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS_INIT}"
- CACHE STRING "Flags used by the linker during the creation of static libraries.")
+cmake_initialize_per_config_variable(CMAKE_EXE_LINKER_FLAGS "Flags used by the linker")
+cmake_initialize_per_config_variable(CMAKE_SHARED_LINKER_FLAGS "Flags used by the linker during the creation of shared libraries")
+cmake_initialize_per_config_variable(CMAKE_MODULE_LINKER_FLAGS "Flags used by the linker during the creation of modules")
+cmake_initialize_per_config_variable(CMAKE_STATIC_LINKER_FLAGS "Flags used by the linker during the creation of static libraries")
# Alias the build tool variable for backward compatibility.
set(CMAKE_BUILD_TOOL ${CMAKE_MAKE_PROGRAM})
mark_as_advanced(
CMAKE_VERBOSE_MAKEFILE
-
-CMAKE_EXE_LINKER_FLAGS
-CMAKE_EXE_LINKER_FLAGS_DEBUG
-CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
-CMAKE_EXE_LINKER_FLAGS_RELEASE
-CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
-
-CMAKE_SHARED_LINKER_FLAGS
-CMAKE_SHARED_LINKER_FLAGS_DEBUG
-CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
-CMAKE_SHARED_LINKER_FLAGS_RELEASE
-CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
-
-CMAKE_MODULE_LINKER_FLAGS
-CMAKE_MODULE_LINKER_FLAGS_DEBUG
-CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
-CMAKE_MODULE_LINKER_FLAGS_RELEASE
-CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
-
-CMAKE_STATIC_LINKER_FLAGS
-CMAKE_STATIC_LINKER_FLAGS_DEBUG
-CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
-CMAKE_STATIC_LINKER_FLAGS_RELEASE
-CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
)
diff --git a/Modules/CMakeCompilerABI.h b/Modules/CMakeCompilerABI.h
index ad481d6f0..45532afdb 100644
--- a/Modules/CMakeCompilerABI.h
+++ b/Modules/CMakeCompilerABI.h
@@ -2,35 +2,30 @@
/* Size of a pointer-to-data in bytes. */
#define SIZEOF_DPTR (sizeof(void*))
const char info_sizeof_dptr[] = {
+ /* clang-format off */
'I', 'N', 'F', 'O', ':', 's', 'i', 'z', 'e', 'o', 'f', '_', 'd', 'p', 't',
'r', '[', ('0' + ((SIZEOF_DPTR / 10) % 10)), ('0' + (SIZEOF_DPTR % 10)), ']',
'\0'
- /* clang-format needs this comment to break after the opening brace */
+ /* clang-format on */
};
/* Application Binary Interface. */
-#if defined(__sgi) && defined(_ABIO32)
-#define ABI_ID "ELF O32"
-#elif defined(__sgi) && defined(_ABIN32)
-#define ABI_ID "ELF N32"
-#elif defined(__sgi) && defined(_ABI64)
-#define ABI_ID "ELF 64"
/* Check for (some) ARM ABIs.
* See e.g. http://wiki.debian.org/ArmEabiPort for some information on this. */
-#elif defined(__GNU__) && defined(__ELF__) && defined(__ARM_EABI__)
-#define ABI_ID "ELF ARMEABI"
+#if defined(__GNU__) && defined(__ELF__) && defined(__ARM_EABI__)
+# define ABI_ID "ELF ARMEABI"
#elif defined(__GNU__) && defined(__ELF__) && defined(__ARMEB__)
-#define ABI_ID "ELF ARM"
+# define ABI_ID "ELF ARM"
#elif defined(__GNU__) && defined(__ELF__) && defined(__ARMEL__)
-#define ABI_ID "ELF ARM"
+# define ABI_ID "ELF ARM"
#elif defined(__linux__) && defined(__ELF__) && defined(__amd64__) && \
defined(__ILP32__)
-#define ABI_ID "ELF X32"
+# define ABI_ID "ELF X32"
#elif defined(__ELF__)
-#define ABI_ID "ELF"
+# define ABI_ID "ELF"
#endif
#if defined(ABI_ID)
diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake
index f2d43b687..bb573b7dc 100644
--- a/Modules/CMakeCompilerIdDetection.cmake
+++ b/Modules/CMakeCompilerIdDetection.cmake
@@ -57,12 +57,14 @@ function(compiler_id_detection outvar lang)
HP
Compaq
zOS
+ XLClang
XL
VisualAge
PGI
Cray
TI
Fujitsu
+ GHS
)
if (lang STREQUAL C)
list(APPEND ordered_compilers
@@ -72,21 +74,20 @@ function(compiler_id_detection outvar lang)
endif()
list(APPEND ordered_compilers
SCO
+ ARMCC
AppleClang
+ ARMClang
Clang
GNU
MSVC
ADSP
IAR
- ARMCC
)
if (lang STREQUAL C)
list(APPEND ordered_compilers
SDCC
)
endif()
- list(APPEND ordered_compilers
- MIPSpro)
#Currently the only CUDA compilers are NVIDIA
if(lang STREQUAL CUDA)
@@ -97,6 +98,8 @@ function(compiler_id_detection outvar lang)
foreach(Id ${ordered_compilers})
string(APPEND CMAKE_${lang}_COMPILER_ID_CONTENT "# define ${CID_PREFIX}COMPILER_IS_${Id} 0\n")
endforeach()
+ # Hard-code definitions for compilers that are no longer supported.
+ string(APPEND CMAKE_${lang}_COMPILER_ID_CONTENT "# define ${CID_PREFIX}COMPILER_IS_MIPSpro 0\n")
endif()
set(pp_if "#if")
@@ -135,9 +138,6 @@ function(compiler_id_detection outvar lang)
/* These compilers are either not known or too old to define an
identification macro. Try to identify the platform and guess that
it is the native compiler. */
-#elif defined(__sgi)
-# define ${CID_PREFIX}COMPILER_ID \"MIPSpro\"
-
#elif defined(__hpux) || defined(__hpua)
# define ${CID_PREFIX}COMPILER_ID \"HP\"
diff --git a/Modules/CMakeDependentOption.cmake b/Modules/CMakeDependentOption.cmake
index 21d3c96b3..99d5070d6 100644
--- a/Modules/CMakeDependentOption.cmake
+++ b/Modules/CMakeDependentOption.cmake
@@ -1,27 +1,29 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakeDependentOption
-# --------------------
-#
-# Macro to provide an option dependent on other options.
-#
-# This macro presents an option to the user only if a set of other
-# conditions are true. When the option is not presented a default value
-# is used, but any value set by the user is preserved for when the
-# option is presented again. Example invocation:
-#
-# ::
-#
-# CMAKE_DEPENDENT_OPTION(USE_FOO "Use Foo" ON
-# "USE_BAR;NOT USE_ZOT" OFF)
-#
-# If USE_BAR is true and USE_ZOT is false, this provides an option
-# called USE_FOO that defaults to ON. Otherwise, it sets USE_FOO to
-# OFF. If the status of USE_BAR or USE_ZOT ever changes, any value for
-# the USE_FOO option is saved so that when the option is re-enabled it
-# retains its old value.
+#[=======================================================================[.rst:
+CMakeDependentOption
+--------------------
+
+Macro to provide an option dependent on other options.
+
+This macro presents an option to the user only if a set of other
+conditions are true. When the option is not presented a default value
+is used, but any value set by the user is preserved for when the
+option is presented again. Example invocation:
+
+.. code-block:: cmake
+
+ CMAKE_DEPENDENT_OPTION(USE_FOO "Use Foo" ON
+ "USE_BAR;NOT USE_ZOT" OFF)
+
+If USE_BAR is true and USE_ZOT is false, this provides an option
+called USE_FOO that defaults to ON. Otherwise, it sets USE_FOO to
+OFF. If the status of USE_BAR or USE_ZOT ever changes, any value for
+the USE_FOO option is saved so that when the option is re-enabled it
+retains its old value. Each element in the fourth parameter is
+evaluated as an if-condition, so :ref:`Condition Syntax` can be used.
+#]=======================================================================]
macro(CMAKE_DEPENDENT_OPTION option doc default depends force)
if(${option}_ISSET MATCHES "^${option}_ISSET$")
diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake
index 87c6b2872..e47f3a441 100644
--- a/Modules/CMakeDetermineASMCompiler.cmake
+++ b/Modules/CMakeDetermineASMCompiler.cmake
@@ -22,11 +22,9 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
if("ASM${ASM_DIALECT}" STREQUAL "ASM") # the generic assembler support
if(NOT CMAKE_ASM_COMPILER_INIT)
if(CMAKE_C_COMPILER)
- set(CMAKE_ASM_COMPILER "${CMAKE_C_COMPILER}" CACHE FILEPATH "The ASM compiler")
- set(CMAKE_ASM_COMPILER_ID "${CMAKE_C_COMPILER_ID}")
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${CMAKE_C_COMPILER})
elseif(CMAKE_CXX_COMPILER)
- set(CMAKE_ASM_COMPILER "${CMAKE_CXX_COMPILER}" CACHE FILEPATH "The ASM compiler")
- set(CMAKE_ASM_COMPILER_ID "${CMAKE_CXX_COMPILER_ID}")
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${CMAKE_CXX_COMPILER})
else()
# List all default C and CXX compilers
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST
@@ -60,6 +58,18 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_GNU "--version")
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_GNU "(GNU assembler)|(GCC)|(Free Software Foundation)")
+ list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS Clang )
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_Clang "--version")
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_Clang "(clang version)")
+
+ list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS AppleClang )
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_AppleClang "--version")
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_AppleClang "(Apple LLVM version)")
+
+ list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS ARMClang )
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_ARMClang "--version")
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_ARMClang "armclang")
+
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS HP )
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_HP "-V")
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_HP "HP C")
@@ -77,14 +87,14 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_XL "XL C")
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS MSVC )
- set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_MSVC "/?")
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_MSVC "-?")
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_MSVC "Microsoft")
list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS TI )
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_TI "-h")
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_TI "Texas Instruments")
- list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS GNU IAR)
+ list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS IAR)
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_IAR )
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_IAR "IAR Assembler")
@@ -100,19 +110,53 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_YASM "--version")
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_YASM "(yasm)")
+ list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS ADSP)
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_ADSP "-version")
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_ADSP "Analog Devices")
+
+ list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS QCC)
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_QCC "-V")
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_QCC "gcc_nto")
+
include(CMakeDetermineCompilerId)
set(userflags)
CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT} "${userflags}")
+ if("x${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}" STREQUAL "xIAR")
+ # primary necessary to detect architecture, so the right archiver and linker can be picked
+ # eg. "IAR Assembler V8.10.1.12857/W32 for ARM" or "IAR Assembler V4.11.1.4666 for Renesas RX"
+ # Cut out identification first, newline handling is a pain
+ string(REGEX MATCH "IAR Assembler[^\r\n]*" _compileid "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_OUTPUT}")
+ if("${_compileid}" MATCHES "V([0-9]+\\.[0-9]+\\.[0-9]+)")
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_VERSION ${CMAKE_MATCH_1})
+ endif()
+ string(REGEX MATCHALL "([A-Za-z0-9-]+)" _all_compileid_matches "${_compileid}")
+ if(_all_compileid_matches)
+ list(GET _all_compileid_matches "-1" CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID)
+ endif()
+ endif()
+ unset(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_OUTPUT)
+ unset(_all_compileid_matches)
+ unset(_compileid)
endif()
if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
- message(STATUS "The ASM${ASM_DIALECT} compiler identification is ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}")
+ if(CMAKE_ASM${ASM_DIALECT}_COMPILER_VERSION)
+ set(_version " ${CMAKE_ASM${ASM_DIALECT}_COMPILER_VERSION}")
+ else()
+ set(_version "")
+ endif()
+ if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID AND "x${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}" STREQUAL "xIAR")
+ set(_archid " ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}")
+ else()
+ set(_archid "")
+ endif()
+ message(STATUS "The ASM${ASM_DIALECT} compiler identification is ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}${_archid}${_version}")
+ unset(_archid)
+ unset(_version)
else()
message(STATUS "The ASM${ASM_DIALECT} compiler identification is unknown")
endif()
-
-
# If we have a gas/as cross compiler, they have usually some prefix, like
# e.g. powerpc-linux-gas, arm-elf-gas or i586-mingw32msvc-gas , optionally
# with a 3-component version number at the end
@@ -142,7 +186,10 @@ if (NOT _CMAKE_TOOLCHAIN_PREFIX)
endif ()
+set(_CMAKE_PROCESSING_LANGUAGE "ASM")
include(CMakeFindBinUtils)
+include(Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-FindBinUtils OPTIONAL)
+unset(_CMAKE_PROCESSING_LANGUAGE)
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR "ASM${ASM_DIALECT}")
@@ -152,20 +199,37 @@ else()
message(STATUS "Didn't find assembler")
endif()
-
-set(_CMAKE_ASM_COMPILER "${CMAKE_ASM${ASM_DIALECT}_COMPILER}")
-set(_CMAKE_ASM_COMPILER_ID "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}")
-set(_CMAKE_ASM_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1}")
-set(_CMAKE_ASM_COMPILER_ENV_VAR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR}")
-set(_CMAKE_ASM_COMPILER_AR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_AR}")
-set(_CMAKE_ASM_COMPILER_RANLIB "${CMAKE_ASM${ASM_DIALECT}_COMPILER_RANLIB}")
+foreach(_var
+ COMPILER
+ COMPILER_ID
+ COMPILER_ARG1
+ COMPILER_ENV_VAR
+ COMPILER_AR
+ COMPILER_RANLIB
+ COMPILER_VERSION
+ )
+ set(_CMAKE_ASM_${_var} "${CMAKE_ASM${ASM_DIALECT}_${_var}}")
+endforeach()
+
+if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID)
+ set(_SET_CMAKE_ASM_COMPILER_ARCHITECTURE_ID
+ "set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID})")
+else()
+ set(_SET_CMAKE_ASM_COMPILER_ARCHITECTURE_ID "")
+endif()
# configure variables set in this file for fast reload later on
configure_file(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in
${CMAKE_PLATFORM_INFO_DIR}/CMakeASM${ASM_DIALECT}Compiler.cmake @ONLY)
-set(_CMAKE_ASM_COMPILER)
-set(_CMAKE_ASM_COMPILER_ARG1)
-set(_CMAKE_ASM_COMPILER_ENV_VAR)
-set(_CMAKE_ASM_COMPILER_AR)
-set(_CMAKE_ASM_COMPILER_RANLIB)
+foreach(_var
+ COMPILER
+ COMPILER_ID
+ COMPILER_ARG1
+ COMPILER_ENV_VAR
+ COMPILER_AR
+ COMPILER_RANLIB
+ COMPILER_VERSION
+ )
+ unset(_CMAKE_ASM_${_var})
+endforeach()
diff --git a/Modules/CMakeDetermineASM_MASMCompiler.cmake b/Modules/CMakeDetermineASM_MASMCompiler.cmake
index 789b0494c..80188fb25 100644
--- a/Modules/CMakeDetermineASM_MASMCompiler.cmake
+++ b/Modules/CMakeDetermineASM_MASMCompiler.cmake
@@ -8,10 +8,10 @@ set(ASM_DIALECT "_MASM")
# if we are using the 64bit cl compiler, assume we also want the 64bit assembler
if(";${CMAKE_VS_PLATFORM_NAME};${MSVC_C_ARCHITECTURE_ID};${MSVC_CXX_ARCHITECTURE_ID};"
- MATCHES ";(Win64|Itanium|x64|IA64);")
- set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT ml64)
+ MATCHES ";(Win64|Itanium|x64|IA64);")
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT ml64)
else()
- set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT ml)
+ set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT ml)
endif()
include(CMakeDetermineASMCompiler)
diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake
index 3caccdeab..037c33b6d 100644
--- a/Modules/CMakeDetermineCCompiler.cmake
+++ b/Modules/CMakeDetermineCCompiler.cmake
@@ -31,6 +31,7 @@ if(NOT CMAKE_C_COMPILER_NAMES)
endif()
if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
+elseif("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI")
elseif("${CMAKE_GENERATOR}" MATCHES "Xcode")
set(CMAKE_C_COMPILER_XCODE_TYPE sourcecode.c.c)
_cmake_find_compiler_path(C)
@@ -81,6 +82,9 @@ else()
# Try compiling K&R-compatible code (needed by Bruce C Compiler).
"-D__CLASSIC_C__"
+
+ # ARMClang need target options
+ "--target=arm-arm-none-eabi -mcpu=cortex-m3"
)
endif()
@@ -105,7 +109,7 @@ if(NOT CMAKE_C_COMPILER_ID_RUN)
# ...
# /path/to/cc ...CompilerIdC/...
# to extract the compiler front-end for the language.
- set(CMAKE_C_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdC/(\\./)?(CompilerIdC.xctest/)?CompilerIdC[ \t\n\\\"]")
+ set(CMAKE_C_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdC/(\\./)?(CompilerIdC.(framework|xctest)/)?CompilerIdC[ \t\n\\\"]")
set(CMAKE_C_COMPILER_ID_TOOL_MATCH_INDEX 2)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
@@ -120,6 +124,22 @@ if(NOT CMAKE_C_COMPILER_ID_RUN)
elseif(CMAKE_C_PLATFORM_ID MATCHES "Cygwin")
set(CMAKE_COMPILER_IS_CYGWIN 1)
endif()
+else()
+ if(NOT DEFINED CMAKE_C_COMPILER_FRONTEND_VARIANT)
+ # Some toolchain files set our internal CMAKE_C_COMPILER_ID_RUN
+ # variable but are not aware of CMAKE_C_COMPILER_FRONTEND_VARIANT.
+ # They pre-date our support for the GNU-like variant targeting the
+ # MSVC ABI so we do not consider that here.
+ if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
+ set(CMAKE_C_COMPILER_FRONTEND_VARIANT "MSVC")
+ else()
+ set(CMAKE_C_COMPILER_FRONTEND_VARIANT "GNU")
+ endif()
+ else()
+ set(CMAKE_C_COMPILER_FRONTEND_VARIANT "")
+ endif()
+ endif()
endif()
if (NOT _CMAKE_TOOLCHAIN_LOCATION)
@@ -135,16 +155,17 @@ endif ()
# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-"
if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
- if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
+ if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|QCC")
get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME)
- if (COMPILER_BASENAME MATCHES "^(.+-)(clang|g?cc)(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$")
+ if (COMPILER_BASENAME MATCHES "^(.+-)(clang|g?cc)(-[0-9]+(\\.[0-9]+)*)?(-[^.]+)?(\\.exe)?$")
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
+ set(_CMAKE_COMPILER_SUFFIX ${CMAKE_MATCH_5})
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_C_COMPILER_TARGET)
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_C_COMPILER_TARGET}-)
endif()
elseif(COMPILER_BASENAME MATCHES "qcc(\\.exe)?$")
- if(CMAKE_C_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?")
+ if(CMAKE_C_COMPILER_TARGET MATCHES "gcc_nto([a-z0-9]+_[0-9]+|[^_le]+)(le)?")
set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-)
endif()
endif ()
@@ -165,19 +186,26 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
endif ()
-include(CMakeFindBinUtils)
set(_CMAKE_PROCESSING_LANGUAGE "C")
+include(CMakeFindBinUtils)
include(Compiler/${CMAKE_C_COMPILER_ID}-FindBinUtils OPTIONAL)
unset(_CMAKE_PROCESSING_LANGUAGE)
+if(CMAKE_C_COMPILER_ARCHITECTURE_ID)
+ set(_SET_CMAKE_C_COMPILER_ARCHITECTURE_ID
+ "set(CMAKE_C_COMPILER_ARCHITECTURE_ID ${CMAKE_C_COMPILER_ARCHITECTURE_ID})")
+else()
+ set(_SET_CMAKE_C_COMPILER_ARCHITECTURE_ID "")
+endif()
+
if(MSVC_C_ARCHITECTURE_ID)
set(SET_MSVC_C_ARCHITECTURE_ID
"set(MSVC_C_ARCHITECTURE_ID ${MSVC_C_ARCHITECTURE_ID})")
endif()
-if(CMAKE_C_XCODE_CURRENT_ARCH)
- set(SET_CMAKE_XCODE_CURRENT_ARCH
- "set(CMAKE_XCODE_CURRENT_ARCH ${CMAKE_C_XCODE_CURRENT_ARCH})")
+if(CMAKE_C_XCODE_ARCHS)
+ set(SET_CMAKE_XCODE_ARCHS
+ "set(CMAKE_XCODE_ARCHS \"${CMAKE_C_XCODE_ARCHS}\")")
endif()
# configure variables set in this file for fast reload later on
diff --git a/Modules/CMakeDetermineCSharpCompiler.cmake b/Modules/CMakeDetermineCSharpCompiler.cmake
index 55b2fb303..da860a843 100644
--- a/Modules/CMakeDetermineCSharpCompiler.cmake
+++ b/Modules/CMakeDetermineCSharpCompiler.cmake
@@ -1,8 +1,8 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-if(NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])")
- message(FATAL_ERROR
+if(NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])")
+ message(FATAL_ERROR
"C# is currently only supported for Microsoft Visual Studio 2010 and later.")
endif()
@@ -18,12 +18,11 @@ if(NOT CMAKE_CSharp_COMPILER_ID_RUN)
set(CMAKE_CSharp_COMPILER_ID_RUN 1)
# Try to identify the compiler.
- set(CMAKE_CSharp_COMPILER_ID_STRINGS_PARAMETERS ENCODING UTF-16LE)
set(CMAKE_CSharp_COMPILER_ID)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
CMAKE_DETERMINE_COMPILER_ID(CSharp CSFLAGS CMakeCSharpCompilerId.cs)
- execute_process(COMMAND "${CMAKE_CSharp_COMPILER}" "/help" OUTPUT_VARIABLE output)
+ execute_process(COMMAND "${CMAKE_CSharp_COMPILER}" "/help /preferreduilang:en-US" OUTPUT_VARIABLE output)
string(REPLACE "\n" ";" output "${output}")
foreach(line ${output})
string(TOUPPER ${line} line)
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index 89ac9fa67..490d6592e 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -6,7 +6,7 @@ include(${CMAKE_ROOT}/Modules//CMakeParseImplicitLinkInfo.cmake)
if( NOT ( ("${CMAKE_GENERATOR}" MATCHES "Make") OR
("${CMAKE_GENERATOR}" MATCHES "Ninja") OR
- ("${CMAKE_GENERATOR}" MATCHES "Visual Studio (1|[89][0-9])") ) )
+ ("${CMAKE_GENERATOR}" MATCHES "Visual Studio (1|[9][0-9])") ) )
message(FATAL_ERROR "CUDA language not currently supported by \"${CMAKE_GENERATOR}\" generator")
endif()
@@ -40,7 +40,6 @@ else()
endif()
#Allow the user to specify a host compiler
-set(CMAKE_CUDA_HOST_COMPILER "" CACHE FILEPATH "Host compiler to be used by nvcc")
if(NOT $ENV{CUDAHOSTCXX} STREQUAL "")
get_filename_component(CMAKE_CUDA_HOST_COMPILER $ENV{CUDAHOSTCXX} PROGRAM)
if(NOT EXISTS ${CMAKE_CUDA_HOST_COMPILER})
@@ -73,7 +72,10 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN)
CMAKE_DETERMINE_COMPILER_ID(CUDA CUDAFLAGS CMakeCUDACompilerId.cu)
endif()
+set(_CMAKE_PROCESSING_LANGUAGE "CUDA")
include(CMakeFindBinUtils)
+unset(_CMAKE_PROCESSING_LANGUAGE)
+
if(MSVC_CUDA_ARCHITECTURE_ID)
set(SET_MSVC_CUDA_ARCHITECTURE_ID
"set(MSVC_CUDA_ARCHITECTURE_ID ${MSVC_CUDA_ARCHITECTURE_ID})")
@@ -87,6 +89,15 @@ if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
elseif(CMAKE_CUDA_COMPILER_ID STREQUAL NVIDIA)
set(_nvcc_log "")
string(REPLACE "\r" "" _nvcc_output_orig "${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}")
+ if(_nvcc_output_orig MATCHES "#\\\$ +PATH= *([^\n]*)\n")
+ set(_nvcc_path "${CMAKE_MATCH_1}")
+ string(APPEND _nvcc_log " found 'PATH=' string: [${_nvcc_path}]\n")
+ string(REPLACE ":" ";" _nvcc_path "${_nvcc_path}")
+ else()
+ set(_nvcc_path "")
+ string(REPLACE "\n" "\n " _nvcc_output_log "\n${_nvcc_output_orig}")
+ string(APPEND _nvcc_log " no 'PATH=' string found in nvcc output:${_nvcc_output_log}\n")
+ endif()
if(_nvcc_output_orig MATCHES "#\\\$ +LIBRARIES= *([^\n]*)\n")
set(_nvcc_libraries "${CMAKE_MATCH_1}")
string(APPEND _nvcc_log " found 'LIBRARIES=' string: [${_nvcc_libraries}]\n")
@@ -100,10 +111,15 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL NVIDIA)
if(_nvcc_libraries)
# Remove variable assignments.
string(REGEX REPLACE "#\\\$ *[^= ]+=[^\n]*\n" "" _nvcc_output "${_nvcc_output_orig}")
+ # Encode [] characters that break list expansion.
+ string(REPLACE "[" "{==={" _nvcc_output "${_nvcc_output}")
+ string(REPLACE "]" "}===}" _nvcc_output "${_nvcc_output}")
# Split lines.
string(REGEX REPLACE "\n+(#\\\$ )?" ";" _nvcc_output "${_nvcc_output}")
foreach(line IN LISTS _nvcc_output)
set(_nvcc_output_line "${line}")
+ string(REPLACE "{==={" "[" _nvcc_output_line "${_nvcc_output_line}")
+ string(REPLACE "}===}" "]" _nvcc_output_line "${_nvcc_output_line}")
string(APPEND _nvcc_log " considering line: [${_nvcc_output_line}]\n")
if("${_nvcc_output_line}" MATCHES "^ *nvlink")
string(APPEND _nvcc_log " ignoring nvlink line\n")
@@ -131,7 +147,26 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL NVIDIA)
else()
#extract the compiler that is being used for linking
separate_arguments(_nvcc_link_line_args UNIX_COMMAND "${_nvcc_link_line}")
- list(GET _nvcc_link_line_args 0 CMAKE_CUDA_HOST_LINK_LAUNCHER)
+ list(GET _nvcc_link_line_args 0 _nvcc_host_link_launcher)
+ if(IS_ABSOLUTE "${_nvcc_host_link_launcher}")
+ string(APPEND _nvcc_log " extracted link launcher absolute path: [${_nvcc_host_link_launcher}]\n")
+ set(CMAKE_CUDA_HOST_LINK_LAUNCHER "${_nvcc_host_link_launcher}")
+ else()
+ string(APPEND _nvcc_log " extracted link launcher name: [${_nvcc_host_link_launcher}]\n")
+ find_program(_nvcc_find_host_link_launcher
+ NAMES ${_nvcc_host_link_launcher}
+ PATHS ${_nvcc_path} NO_DEFAULT_PATH)
+ find_program(_nvcc_find_host_link_launcher
+ NAMES ${_nvcc_host_link_launcher})
+ if(_nvcc_find_host_link_launcher)
+ string(APPEND _nvcc_log " found link launcher absolute path: [${_nvcc_find_host_link_launcher}]\n")
+ set(CMAKE_CUDA_HOST_LINK_LAUNCHER "${_nvcc_find_host_link_launcher}")
+ else()
+ string(APPEND _nvcc_log " could not find link launcher absolute path\n")
+ set(CMAKE_CUDA_HOST_LINK_LAUNCHER "${_nvcc_host_link_launcher}")
+ endif()
+ unset(_nvcc_find_host_link_launcher CACHE)
+ endif()
endif()
#prefix the line with cuda-fake-ld so that implicit link info believes it is
diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake
index 9150962d9..7274eecdf 100644
--- a/Modules/CMakeDetermineCXXCompiler.cmake
+++ b/Modules/CMakeDetermineCXXCompiler.cmake
@@ -30,6 +30,7 @@ if(NOT CMAKE_CXX_COMPILER_NAMES)
endif()
if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
+elseif("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI")
elseif("${CMAKE_GENERATOR}" MATCHES "Xcode")
set(CMAKE_CXX_COMPILER_XCODE_TYPE sourcecode.cpp.cpp)
_cmake_find_compiler_path(CXX)
@@ -73,6 +74,12 @@ else()
set(CMAKE_CXX_COMPILER_ID_TEST_FLAGS
# Try compiling to an object file only.
"-c"
+ # IAR does not detect language automatically
+ "--c++"
+ "--ec++"
+
+ # ARMClang need target options
+ "--target=arm-arm-none-eabi -mcpu=cortex-m3"
)
endif()
@@ -97,7 +104,7 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN)
# ...
# /path/to/cc ...CompilerIdCXX/...
# to extract the compiler front-end for the language.
- set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdCXX/(\\./)?(CompilerIdCXX.xctest/)?CompilerIdCXX[ \t\n\\\"]")
+ set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdCXX/(\\./)?(CompilerIdCXX.(framework|xctest)/)?CompilerIdCXX[ \t\n\\\"]")
set(CMAKE_CXX_COMPILER_ID_TOOL_MATCH_INDEX 2)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
@@ -112,6 +119,22 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN)
elseif(CMAKE_CXX_PLATFORM_ID MATCHES "Cygwin")
set(CMAKE_COMPILER_IS_CYGWIN 1)
endif()
+else()
+ if(NOT DEFINED CMAKE_CXX_COMPILER_FRONTEND_VARIANT)
+ # Some toolchain files set our internal CMAKE_CXX_COMPILER_ID_RUN
+ # variable but are not aware of CMAKE_CXX_COMPILER_FRONTEND_VARIANT.
+ # They pre-date our support for the GNU-like variant targeting the
+ # MSVC ABI so we do not consider that here.
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+ set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "MSVC")
+ else()
+ set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "GNU")
+ endif()
+ else()
+ set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "")
+ endif()
+ endif()
endif()
if (NOT _CMAKE_TOOLCHAIN_LOCATION)
@@ -129,16 +152,17 @@ endif ()
if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
- if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|QCC")
get_filename_component(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME)
- if (COMPILER_BASENAME MATCHES "^(.+-)(clan)?[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$")
+ if (COMPILER_BASENAME MATCHES "^(.+-)(clan)?[gc]\\+\\+(-[0-9]+(\\.[0-9]+)*)?(-[^.]+)?(\\.exe)?$")
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
+ set(_CMAKE_COMPILER_SUFFIX ${CMAKE_MATCH_5})
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
if(CMAKE_CXX_COMPILER_TARGET)
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_CXX_COMPILER_TARGET}-)
endif()
elseif(COMPILER_BASENAME MATCHES "QCC(\\.exe)?$")
- if(CMAKE_CXX_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?")
+ if(CMAKE_CXX_COMPILER_TARGET MATCHES "gcc_nto([a-z0-9]+_[0-9]+|[^_le]+)(le)")
set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-)
endif()
endif ()
@@ -160,19 +184,26 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
endif ()
-include(CMakeFindBinUtils)
set(_CMAKE_PROCESSING_LANGUAGE "CXX")
+include(CMakeFindBinUtils)
include(Compiler/${CMAKE_CXX_COMPILER_ID}-FindBinUtils OPTIONAL)
unset(_CMAKE_PROCESSING_LANGUAGE)
+if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID)
+ set(_SET_CMAKE_CXX_COMPILER_ARCHITECTURE_ID
+ "set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID})")
+else()
+ set(_SET_CMAKE_CXX_COMPILER_ARCHITECTURE_ID "")
+endif()
+
if(MSVC_CXX_ARCHITECTURE_ID)
set(SET_MSVC_CXX_ARCHITECTURE_ID
"set(MSVC_CXX_ARCHITECTURE_ID ${MSVC_CXX_ARCHITECTURE_ID})")
endif()
-if(CMAKE_CXX_XCODE_CURRENT_ARCH)
- set(SET_CMAKE_XCODE_CURRENT_ARCH
- "set(CMAKE_XCODE_CURRENT_ARCH ${CMAKE_CXX_XCODE_CURRENT_ARCH})")
+if(CMAKE_CXX_XCODE_ARCHS)
+ set(SET_CMAKE_XCODE_ARCHS
+ "set(CMAKE_XCODE_ARCHS \"${CMAKE_CXX_XCODE_ARCHS}\")")
endif()
# configure all variables set in this file
diff --git a/Modules/CMakeDetermineCompileFeatures.cmake b/Modules/CMakeDetermineCompileFeatures.cmake
index 3ed92bee3..01a81a1a8 100644
--- a/Modules/CMakeDetermineCompileFeatures.cmake
+++ b/Modules/CMakeDetermineCompileFeatures.cmake
@@ -49,6 +49,7 @@ function(cmake_determine_compile_features lang)
set(CMAKE_CXX11_COMPILE_FEATURES)
set(CMAKE_CXX14_COMPILE_FEATURES)
set(CMAKE_CXX17_COMPILE_FEATURES)
+ set(CMAKE_CXX20_COMPILE_FEATURES)
include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake")
@@ -59,6 +60,9 @@ function(cmake_determine_compile_features lang)
return()
endif()
+ if (CMAKE_CXX17_COMPILE_FEATURES AND CMAKE_CXX20_COMPILE_FEATURES)
+ list(REMOVE_ITEM CMAKE_CXX20_COMPILE_FEATURES ${CMAKE_CXX17_COMPILE_FEATURES})
+ endif()
if (CMAKE_CXX14_COMPILE_FEATURES AND CMAKE_CXX17_COMPILE_FEATURES)
list(REMOVE_ITEM CMAKE_CXX17_COMPILE_FEATURES ${CMAKE_CXX14_COMPILE_FEATURES})
endif()
@@ -75,6 +79,7 @@ function(cmake_determine_compile_features lang)
${CMAKE_CXX11_COMPILE_FEATURES}
${CMAKE_CXX14_COMPILE_FEATURES}
${CMAKE_CXX17_COMPILE_FEATURES}
+ ${CMAKE_CXX20_COMPILE_FEATURES}
)
endif()
@@ -83,6 +88,7 @@ function(cmake_determine_compile_features lang)
set(CMAKE_CXX11_COMPILE_FEATURES ${CMAKE_CXX11_COMPILE_FEATURES} PARENT_SCOPE)
set(CMAKE_CXX14_COMPILE_FEATURES ${CMAKE_CXX14_COMPILE_FEATURES} PARENT_SCOPE)
set(CMAKE_CXX17_COMPILE_FEATURES ${CMAKE_CXX17_COMPILE_FEATURES} PARENT_SCOPE)
+ set(CMAKE_CXX20_COMPILE_FEATURES ${CMAKE_CXX20_COMPILE_FEATURES} PARENT_SCOPE)
message(STATUS "Detecting ${lang} compile features - done")
endif()
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake
index 604ac27e6..06f3ba22d 100644
--- a/Modules/CMakeDetermineCompilerABI.cmake
+++ b/Modules/CMakeDetermineCompilerABI.cmake
@@ -6,7 +6,9 @@
# This is used internally by CMake and should not be included by user
# code.
+include(${CMAKE_ROOT}/Modules/CMakeParseImplicitIncludeInfo.cmake)
include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake)
+include(CMakeTestCompilerCommon)
function(CMAKE_DETERMINE_COMPILER_ABI lang src)
if(NOT DEFINED CMAKE_${lang}_ABI_COMPILED)
@@ -15,23 +17,48 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
# Compile the ABI identification source.
set(BIN "${CMAKE_PLATFORM_INFO_DIR}/CMakeDetermineCompilerABI_${lang}.bin")
set(CMAKE_FLAGS )
+ set(COMPILE_DEFINITIONS )
if(DEFINED CMAKE_${lang}_VERBOSE_FLAG)
set(CMAKE_FLAGS "-DEXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}")
+ set(COMPILE_DEFINITIONS "${CMAKE_${lang}_VERBOSE_FLAG}")
+ endif()
+ if(DEFINED CMAKE_${lang}_VERBOSE_COMPILE_FLAG)
+ set(COMPILE_DEFINITIONS "${CMAKE_${lang}_VERBOSE_COMPILE_FLAG}")
endif()
if(NOT "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC")
# Avoid adding our own platform standard libraries for compilers
# from which we might detect implicit link libraries.
list(APPEND CMAKE_FLAGS "-DCMAKE_${lang}_STANDARD_LIBRARIES=")
endif()
+ __TestCompiler_setTryCompileTargetType()
+
+ # Save the current LC_ALL, LC_MESSAGES, and LANG environment variables
+ # and set them to "C" that way GCC's "search starts here" text is in
+ # English and we can grok it.
+ set(_orig_lc_all $ENV{LC_ALL})
+ set(_orig_lc_messages $ENV{LC_MESSAGES})
+ set(_orig_lang $ENV{LANG})
+ set(ENV{LC_ALL} C)
+ set(ENV{LC_MESSAGES} C)
+ set(ENV{LANG} C)
+
try_compile(CMAKE_${lang}_ABI_COMPILED
${CMAKE_BINARY_DIR} ${src}
CMAKE_FLAGS ${CMAKE_FLAGS}
# Ignore unused flags when we are just determining the ABI.
"--no-warn-unused-cli"
+ COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS}
OUTPUT_VARIABLE OUTPUT
COPY_FILE "${BIN}"
COPY_FILE_ERROR _copy_error
+ __CMAKE_INTERNAL ABI
)
+
+ # Restore original LC_ALL, LC_MESSAGES, and LANG
+ set(ENV{LC_ALL} ${_orig_lc_all})
+ set(ENV{LC_MESSAGES} ${_orig_lc_messages})
+ set(ENV{LANG} ${_orig_lang})
+
# Move result from cache to normal variable.
set(CMAKE_${lang}_ABI_COMPILED ${CMAKE_${lang}_ABI_COMPILED})
unset(CMAKE_${lang}_ABI_COMPILED CACHE)
@@ -62,6 +89,26 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
set(CMAKE_${lang}_COMPILER_ABI "${ABI_NAME}" PARENT_SCOPE)
endif()
+ # Parse implicit include directory for this language, if available.
+ if(CMAKE_${lang}_VERBOSE_FLAG)
+ set (implicit_incdirs "")
+ cmake_parse_implicit_include_info("${OUTPUT}" "${lang}"
+ implicit_incdirs log rv)
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Parsed ${lang} implicit include dir info from above output: rv=${rv}\n${log}\n\n")
+ if("${rv}" STREQUAL "done")
+ # Entries that we have been told to explicitly pass as standard include
+ # directories will not be implicitly added by the compiler.
+ if(CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES)
+ list(REMOVE_ITEM implicit_incdirs ${CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES})
+ endif()
+
+ # We parsed implicit include directories, so override the default initializer.
+ set(_CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT "${implicit_incdirs}")
+ endif()
+ endif()
+ set(CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES "${_CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT}" PARENT_SCOPE)
+
# Parse implicit linker information for this language, if available.
set(implicit_dirs "")
set(implicit_libs "")
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 7588f63b7..7b571c3c8 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -28,6 +28,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
foreach(testflags ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS_FIRST}
""
${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS})
+ separate_arguments(testflags UNIX_COMMAND "${testflags}")
CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${testflags}" "${userflags}" "${src}")
CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR("${lang}" "${COMPILER_${lang}_PRODUCED_OUTPUT}")
if(CMAKE_${lang}_COMPILER_ID)
@@ -45,6 +46,14 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
endif()
endforeach()
+ # Check if compiler id detection gave us the compiler tool.
+ if(CMAKE_${lang}_COMPILER_ID_TOOL)
+ set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER_ID_TOOL}")
+ set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER_ID_TOOL}" PARENT_SCOPE)
+ elseif(NOT CMAKE_${lang}_COMPILER)
+ set(CMAKE_${lang}_COMPILER "CMAKE_${lang}_COMPILER-NOTFOUND" PARENT_SCOPE)
+ endif()
+
# If the compiler is still unknown, try to query its vendor.
if(CMAKE_${lang}_COMPILER AND NOT CMAKE_${lang}_COMPILER_ID)
foreach(userflags "${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}" "")
@@ -52,6 +61,53 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
endforeach()
endif()
+ # If the compiler is still unknown, fallback to GHS
+ if(NOT CMAKE_${lang}_COMPILER_ID AND "${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI")
+ set(CMAKE_${lang}_COMPILER_ID GHS)
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "The ${lang} compiler identification is falling back to GHS.\n\n")
+ endif()
+
+ # CUDA < 7.5 is missing version macros
+ if(lang STREQUAL "CUDA"
+ AND CMAKE_${lang}_COMPILER_ID STREQUAL "NVIDIA"
+ AND NOT CMAKE_${lang}_COMPILER_VERSION)
+ execute_process(
+ COMMAND "${CMAKE_${lang}_COMPILER}"
+ --version
+ OUTPUT_VARIABLE output ERROR_VARIABLE output
+ RESULT_VARIABLE result
+ TIMEOUT 10
+ )
+ if(output MATCHES [=[ V([0-9]+)\.([0-9]+)\.([0-9]+)]=])
+ set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
+ endif()
+ endif()
+
+ # For Swift we need to explicitly query the version.
+ if(lang STREQUAL "Swift"
+ AND CMAKE_${lang}_COMPILER
+ AND NOT CMAKE_${lang}_COMPILER_VERSION)
+ execute_process(
+ COMMAND "${CMAKE_${lang}_COMPILER}"
+ -version
+ OUTPUT_VARIABLE output ERROR_VARIABLE output
+ RESULT_VARIABLE result
+ TIMEOUT 10
+ )
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Running the ${lang} compiler: \"${CMAKE_${lang}_COMPILER}\" -version\n"
+ "${output}\n"
+ )
+
+ if(output MATCHES [[Swift version ([0-9]+\.[0-9]+(\.[0-9]+)?)]])
+ set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_MATCH_1}")
+ if(NOT CMAKE_${lang}_COMPILER_ID)
+ set(CMAKE_Swift_COMPILER_ID "Apple")
+ endif()
+ endif()
+ endif()
+
if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU")
execute_process(
COMMAND "${CMAKE_${lang}_COMPILER}"
@@ -80,6 +136,31 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "")
endif()
+ set(_variant "")
+ if("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xClang")
+ if("x${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "xMSVC")
+ if(CMAKE_GENERATOR MATCHES "Visual Studio")
+ set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "MSVC")
+ else()
+ # Test whether an MSVC-like command-line option works.
+ execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -?
+ RESULT_VARIABLE _clang_result
+ OUTPUT_VARIABLE _clang_stdout
+ ERROR_VARIABLE _clang_stderr)
+ if(_clang_result EQUAL 0)
+ set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "MSVC")
+ else()
+ set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU")
+ endif()
+ endif()
+ set(_variant " with ${CMAKE_${lang}_COMPILER_FRONTEND_VARIANT}-like command-line")
+ else()
+ set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU")
+ endif()
+ else()
+ set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "")
+ endif()
+
# Display the final identification result.
if(CMAKE_${lang}_COMPILER_ID)
if(CMAKE_${lang}_COMPILER_VERSION)
@@ -87,26 +168,30 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
else()
set(_version "")
endif()
+ if(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID AND "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xIAR")
+ set(_archid " ${CMAKE_${lang}_COMPILER_ARCHITECTURE_ID}")
+ else()
+ set(_archid "")
+ endif()
message(STATUS "The ${lang} compiler identification is "
- "${CMAKE_${lang}_COMPILER_ID}${_version}")
+ "${CMAKE_${lang}_COMPILER_ID}${_archid}${_version}${_variant}")
+ unset(_archid)
+ unset(_version)
+ unset(_variant)
else()
message(STATUS "The ${lang} compiler identification is unknown")
endif()
- # Check if compiler id detection gave us the compiler tool.
- if(CMAKE_${lang}_COMPILER_ID_TOOL)
- set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER_ID_TOOL}" PARENT_SCOPE)
- elseif(NOT CMAKE_${lang}_COMPILER)
- set(CMAKE_${lang}_COMPILER "CMAKE_${lang}_COMPILER-NOTFOUND" PARENT_SCOPE)
- endif()
-
set(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE)
set(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE)
+ set(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID "${CMAKE_${lang}_COMPILER_ARCHITECTURE_ID}" PARENT_SCOPE)
set(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}"
PARENT_SCOPE)
- set(CMAKE_${lang}_XCODE_CURRENT_ARCH "${CMAKE_${lang}_XCODE_CURRENT_ARCH}" PARENT_SCOPE)
+ set(CMAKE_${lang}_XCODE_ARCHS "${CMAKE_${lang}_XCODE_ARCHS}" PARENT_SCOPE)
set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX}" PARENT_SCOPE)
+ set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "${CMAKE_${lang}_COMPILER_FRONTEND_VARIANT}" PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE)
+ set(CMAKE_${lang}_COMPILER_VERSION_INTERNAL "${CMAKE_${lang}_COMPILER_VERSION_INTERNAL}" PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_WRAPPER "${CMAKE_${lang}_COMPILER_WRAPPER}" PARENT_SCOPE)
set(CMAKE_${lang}_SIMULATE_ID "${CMAKE_${lang}_SIMULATE_ID}" PARENT_SCOPE)
set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE)
@@ -156,7 +241,10 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(vs_version ${CMAKE_MATCH_1})
set(id_platform ${CMAKE_VS_PLATFORM_NAME})
set(id_lang "${lang}")
- if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*")
+ set(id_PostBuildEvent_Command "")
+ if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Ll][Ll][Vv][Mm](_v[0-9]+(_xp)?)?$")
+ set(id_cl_var "ClangClExecutable")
+ elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*")
set(id_cl clang.exe)
else()
set(id_cl cl.exe)
@@ -195,9 +283,20 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "Intel")
set(id_cl icl.exe)
endif()
+ if(CMAKE_VS_PLATFORM_TOOLSET_VERSION)
+ set(id_sep "\\")
+ if(CMAKE_VS_PLATFORM_TOOLSET_VERSION VERSION_GREATER_EQUAL "14.20")
+ if(EXISTS "${CMAKE_GENERATOR_INSTANCE}/VC/Auxiliary/Build.${CMAKE_VS_PLATFORM_TOOLSET_VERSION}/Microsoft.VCToolsVersion.${CMAKE_VS_PLATFORM_TOOLSET_VERSION}.props")
+ set(id_sep ".")
+ endif()
+ endif()
+ set(id_toolset_version_props "<Import Project=\"${CMAKE_GENERATOR_INSTANCE}\\VC\\Auxiliary\\Build${id_sep}${CMAKE_VS_PLATFORM_TOOLSET_VERSION}\\Microsoft.VCToolsVersion.${CMAKE_VS_PLATFORM_TOOLSET_VERSION}.props\" />")
+ unset(id_sep)
+ endif()
endif()
else()
set(id_toolset "")
+ set(id_toolset_version_props "")
endif()
if(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE)
set(id_PreferredToolArchitecture "<PreferredToolArchitecture>${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}</PreferredToolArchitecture>")
@@ -211,15 +310,17 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
else()
set(id_system "")
endif()
- if(id_system AND CMAKE_SYSTEM_VERSION)
- set(id_system_version "<ApplicationTypeRevision>${CMAKE_SYSTEM_VERSION}</ApplicationTypeRevision>")
+ if(id_system AND CMAKE_SYSTEM_VERSION MATCHES "^([0-9]+\\.[0-9]+)")
+ set(id_system_version "<ApplicationTypeRevision>${CMAKE_MATCH_1}</ApplicationTypeRevision>")
else()
set(id_system_version "")
endif()
if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
set(id_WindowsTargetPlatformVersion "<WindowsTargetPlatformVersion>${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}</WindowsTargetPlatformVersion>")
endif()
- if(id_platform STREQUAL ARM)
+ if(id_platform STREQUAL ARM64)
+ set(id_WindowsSDKDesktopARMSupport "<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>")
+ elseif(id_platform STREQUAL ARM)
set(id_WindowsSDKDesktopARMSupport "<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>")
else()
set(id_WindowsSDKDesktopARMSupport "")
@@ -237,7 +338,11 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR})
set(id_src "${src}")
set(id_compile "ClCompile")
- set(id_PostBuildEvent_Command "for %%i in (${id_cl}) do %40echo CMAKE_${lang}_COMPILER=%%~$PATH:i")
+ if(id_cl_var)
+ set(id_PostBuildEvent_Command "echo CMAKE_${lang}_COMPILER=$(${id_cl_var})")
+ else()
+ set(id_PostBuildEvent_Command "for %%i in (${id_cl}) do %40echo CMAKE_${lang}_COMPILER=%%~$PATH:i")
+ endif()
set(id_Import_props "")
set(id_Import_targets "")
set(id_ItemDefinitionGroup_entry "")
@@ -249,8 +354,14 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(cuda_tools "CUDA ${CMAKE_VS_PLATFORM_TOOLSET_CUDA}")
set(id_compile "CudaCompile")
set(id_PostBuildEvent_Command [[echo CMAKE_CUDA_COMPILER=$(CudaToolkitBinDir)\nvcc.exe]])
- string(CONCAT id_Import_props [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.props" />]])
- string(CONCAT id_Import_targets [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.targets" />]])
+ if(CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR)
+ set(id_CudaToolkitCustomDir "<CudaToolkitCustomDir>${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}nvcc</CudaToolkitCustomDir>")
+ string(CONCAT id_Import_props "<Import Project=\"${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}\\CUDAVisualStudioIntegration\\extras\\visual_studio_integration\\MSBuildExtensions\\${cuda_tools}.props\" />")
+ string(CONCAT id_Import_targets "<Import Project=\"${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}\\CUDAVisualStudioIntegration\\extras\\visual_studio_integration\\MSBuildExtensions\\${cuda_tools}.targets\" />")
+ else()
+ string(CONCAT id_Import_props [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.props" />]])
+ string(CONCAT id_Import_targets [[<Import Project="$(VCTargetsPath)\BuildCustomizations\]] "${cuda_tools}" [[.targets" />]])
+ endif()
if(CMAKE_VS_PLATFORM_NAME STREQUAL x64)
set(id_ItemDefinitionGroup_entry "<CudaCompile><TargetMachinePlatform>64</TargetMachinePlatform></CudaCompile>")
endif()
@@ -301,6 +412,8 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
if("${lang}" STREQUAL "Swift")
if(CMAKE_Swift_LANGUAGE_VERSION)
set(id_lang_version "SWIFT_VERSION = ${CMAKE_Swift_LANGUAGE_VERSION};")
+ elseif(XCODE_VERSION VERSION_GREATER_EQUAL 10.2)
+ set(id_lang_version "SWIFT_VERSION = 4.0;")
elseif(XCODE_VERSION VERSION_GREATER_EQUAL 8.3)
set(id_lang_version "SWIFT_VERSION = 3.0;")
else()
@@ -318,12 +431,24 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(id_product_type "com.apple.product-type.tool")
if(CMAKE_OSX_SYSROOT)
set(id_sdkroot "SDKROOT = \"${CMAKE_OSX_SYSROOT}\";")
- if(CMAKE_OSX_SYSROOT MATCHES "(^|/)[Ii][Pp][Hh][Oo][Nn][Ee]")
+ if(CMAKE_OSX_SYSROOT MATCHES "(^|/)[Ii][Pp][Hh][Oo][Nn][Ee]" OR
+ CMAKE_OSX_SYSROOT MATCHES "(^|/)[Aa][Pp][Pp][Ll][Ee][Tt][Vv]")
set(id_product_type "com.apple.product-type.bundle.unit-test")
+ elseif(CMAKE_OSX_SYSROOT MATCHES "(^|/)[Ww][Aa][Tt][Cc][Hh]")
+ set(id_product_type "com.apple.product-type.framework")
endif()
else()
set(id_sdkroot "")
endif()
+ set(id_clang_cxx_library "")
+ set(stdlib_regex "(^| )(-stdlib=)([^ ]+)( |$)")
+ string(REGEX MATCHALL "${stdlib_regex}" all_stdlib_matches "${CMAKE_CXX_FLAGS}")
+ if(all_stdlib_matches)
+ list(GET all_stdlib_matches "-1" last_stdlib_match)
+ if(last_stdlib_match MATCHES "${stdlib_regex}")
+ set(id_clang_cxx_library "CLANG_CXX_LIBRARY = \"${CMAKE_MATCH_3}\";")
+ endif()
+ endif()
configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-3.pbxproj.in
${id_dir}/CompilerId${lang}.xcodeproj/project.pbxproj @ONLY)
unset(_ENV_MACOSX_DEPLOYMENT_TARGET)
@@ -349,8 +474,52 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
endif()
endif()
endif()
- if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "CURRENT_ARCH=([^%\r\n]+)[\r\n]")
- set(CMAKE_${lang}_XCODE_CURRENT_ARCH "${CMAKE_MATCH_1}" PARENT_SCOPE)
+ if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "ARCHS=([^%\r\n]+)[\r\n]")
+ set(CMAKE_${lang}_XCODE_ARCHS "${CMAKE_MATCH_1}")
+ separate_arguments(CMAKE_${lang}_XCODE_ARCHS)
+ set(CMAKE_${lang}_XCODE_ARCHS "${CMAKE_${lang}_XCODE_ARCHS}" PARENT_SCOPE)
+ endif()
+ elseif("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI")
+ set(id_dir ${CMAKE_${lang}_COMPILER_ID_DIR})
+ set(id_src "${src}")
+ if (GHS_PRIMARY_TARGET)
+ set(ghs_primary_target "${GHS_PRIMARY_TARGET}")
+ else()
+ set(ghs_primary_target "${CMAKE_GENERATOR_PLATFORM}_${GHS_TARGET_PLATFORM}.tgt")
+ endif()
+ if ("${GHS_TARGET_PLATFORM}" MATCHES "integrity")
+ set(bsp_name "macro GHS_BSP=${GHS_BSP_NAME}")
+ set(os_dir "macro GHS_OS=${GHS_OS_DIR}")
+ endif()
+ set(command "${CMAKE_MAKE_PROGRAM}" "-commands" "-top" "GHS_default.gpj")
+ configure_file(${CMAKE_ROOT}/Modules/CompilerId/GHS_default.gpj.in
+ ${id_dir}/GHS_default.gpj @ONLY)
+ configure_file(${CMAKE_ROOT}/Modules/CompilerId/GHS_lib.gpj.in
+ ${id_dir}/GHS_lib.gpj @ONLY)
+ execute_process(COMMAND ${command}
+ WORKING_DIRECTORY ${id_dir}
+ OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
+ ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT
+ RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT
+ )
+ # Match the compiler location line printed out.
+ set(ghs_toolpath "${CMAKE_MAKE_PROGRAM}")
+ if(CMAKE_HOST_UNIX)
+ string(REPLACE "/gbuild" "/" ghs_toolpath ${ghs_toolpath})
+ else()
+ string(REPLACE "/gbuild.exe" "/" ghs_toolpath ${ghs_toolpath})
+ string(REPLACE / "\\\\" ghs_toolpath ${ghs_toolpath})
+ endif()
+ if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "(${ghs_toolpath}[^ ]*)")
+ if(CMAKE_HOST_UNIX)
+ set(_comp "${CMAKE_MATCH_1}")
+ else()
+ set(_comp "${CMAKE_MATCH_1}.exe")
+ endif()
+ if(EXISTS "${_comp}")
+ file(TO_CMAKE_PATH "${_comp}" _comp)
+ set(CMAKE_${lang}_COMPILER_ID_TOOL "${_comp}" PARENT_SCOPE)
+ endif()
endif()
else()
execute_process(
@@ -411,6 +580,9 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
# com.apple.package-type.bundle.unit-test
${_glob_id_dir}/*.xctest/*
+
+ # com.apple.product-type.framework
+ ${_glob_id_dir}/*.framework/*
)
list(REMOVE_ITEM files "${src}")
set(COMPILER_${lang}_PRODUCED_FILES "")
@@ -463,6 +635,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
set(COMPILER_VERSION_MINOR 0)
set(COMPILER_VERSION_PATCH 0)
set(COMPILER_VERSION_TWEAK 0)
+ set(COMPILER_VERSION_INTERNAL "")
set(HAVE_COMPILER_VERSION_MAJOR 0)
set(HAVE_COMPILER_VERSION_MINOR 0)
set(HAVE_COMPILER_VERSION_PATCH 0)
@@ -480,14 +653,27 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
set(ARCHITECTURE_ID)
set(SIMULATE_ID)
set(SIMULATE_VERSION)
- file(STRINGS ${file}
- CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 38
- ${CMAKE_${lang}_COMPILER_ID_STRINGS_PARAMETERS}
- REGEX "INFO:[A-Za-z0-9_]+\\[[^]]*\\]")
+ foreach(encoding "" "ENCODING;UTF-16LE" "ENCODING;UTF-16BE")
+ file(STRINGS "${file}" CMAKE_${lang}_COMPILER_ID_STRINGS
+ LIMIT_COUNT 38 ${encoding}
+ REGEX ".?I.?N.?F.?O.?:.?[A-Za-z0-9_]+\\[[^]]*\\]")
+ if(NOT CMAKE_${lang}_COMPILER_ID_STRINGS STREQUAL "")
+ break()
+ endif()
+ endforeach()
set(COMPILER_ID_TWICE)
+ # With the IAR Compiler, some strings are found twice, first time as incomplete
+ # list like "?<Constant "INFO:compiler[IAR]">". Remove the incomplete copies.
+ list(FILTER CMAKE_${lang}_COMPILER_ID_STRINGS EXCLUDE REGEX "\\?<Constant \\\"")
# In C# binaries, some strings are found more than once.
list(REMOVE_DUPLICATES CMAKE_${lang}_COMPILER_ID_STRINGS)
foreach(info ${CMAKE_${lang}_COMPILER_ID_STRINGS})
+ # The IAR-AVR compiler uses a binary format that places a '6'
+ # character (0x34) before each character in the string. Strip
+ # out these characters without removing any legitamate characters.
+ if("${info}" MATCHES "(.)I.N.F.O.:.")
+ string(REGEX REPLACE "${CMAKE_MATCH_1}(.)" "\\1" info "${info}")
+ endif()
if("${info}" MATCHES "INFO:compiler\\[([^]\"]*)\\]")
if(COMPILER_ID)
set(COMPILER_ID_TWICE 1)
@@ -501,9 +687,13 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
set(ARCHITECTURE_ID "${CMAKE_MATCH_1}")
endif()
if("${info}" MATCHES "INFO:compiler_version\\[([^]\"]*)\\]")
- string(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION "${CMAKE_MATCH_1}")
+ string(REGEX REPLACE "^0+([0-9]+)" "\\1" COMPILER_VERSION "${CMAKE_MATCH_1}")
string(REGEX REPLACE "\\.0+([0-9])" ".\\1" COMPILER_VERSION "${COMPILER_VERSION}")
endif()
+ if("${info}" MATCHES "INFO:compiler_version_internal\\[([^]\"]*)\\]")
+ string(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION_INTERNAL "${CMAKE_MATCH_1}")
+ string(REGEX REPLACE "\\.0+([0-9])" ".\\1" COMPILER_VERSION_INTERNAL "${COMPILER_VERSION_INTERNAL}")
+ endif()
foreach(comp MAJOR MINOR PATCH TWEAK)
foreach(digit 1 2 3 4 5 6 7 8 9)
if("${info}" MATCHES "INFO:compiler_version_${comp}_digit_${digit}\\[([0-9])\\]")
@@ -549,26 +739,28 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
if(WIN32)
# The offset to the PE signature is stored at 0x3c.
file(READ ${file} peoffsethex LIMIT 1 OFFSET 60 HEX)
- string(SUBSTRING "${peoffsethex}" 0 1 peoffsethex1)
- string(SUBSTRING "${peoffsethex}" 1 1 peoffsethex2)
- set(peoffsetexpression "${peoffsethex1} * 16 + ${peoffsethex2}")
- string(REPLACE "a" "10" peoffsetexpression "${peoffsetexpression}")
- string(REPLACE "b" "11" peoffsetexpression "${peoffsetexpression}")
- string(REPLACE "c" "12" peoffsetexpression "${peoffsetexpression}")
- string(REPLACE "d" "13" peoffsetexpression "${peoffsetexpression}")
- string(REPLACE "e" "14" peoffsetexpression "${peoffsetexpression}")
- string(REPLACE "f" "15" peoffsetexpression "${peoffsetexpression}")
- math(EXPR peoffset "${peoffsetexpression}")
-
- file(READ ${file} peheader LIMIT 6 OFFSET ${peoffset} HEX)
- if(peheader STREQUAL "50450000a201")
- set(ARCHITECTURE_ID "SH3")
- elseif(peheader STREQUAL "50450000a301")
- set(ARCHITECTURE_ID "SH3DSP")
- elseif(peheader STREQUAL "50450000a601")
- set(ARCHITECTURE_ID "SH4")
- elseif(peheader STREQUAL "50450000a801")
- set(ARCHITECTURE_ID "SH5")
+ if(NOT peoffsethex STREQUAL "")
+ string(SUBSTRING "${peoffsethex}" 0 1 peoffsethex1)
+ string(SUBSTRING "${peoffsethex}" 1 1 peoffsethex2)
+ set(peoffsetexpression "${peoffsethex1} * 16 + ${peoffsethex2}")
+ string(REPLACE "a" "10" peoffsetexpression "${peoffsetexpression}")
+ string(REPLACE "b" "11" peoffsetexpression "${peoffsetexpression}")
+ string(REPLACE "c" "12" peoffsetexpression "${peoffsetexpression}")
+ string(REPLACE "d" "13" peoffsetexpression "${peoffsetexpression}")
+ string(REPLACE "e" "14" peoffsetexpression "${peoffsetexpression}")
+ string(REPLACE "f" "15" peoffsetexpression "${peoffsetexpression}")
+ math(EXPR peoffset "${peoffsetexpression}")
+
+ file(READ ${file} peheader LIMIT 6 OFFSET ${peoffset} HEX)
+ if(peheader STREQUAL "50450000a201")
+ set(ARCHITECTURE_ID "SH3")
+ elseif(peheader STREQUAL "50450000a301")
+ set(ARCHITECTURE_ID "SH3DSP")
+ elseif(peheader STREQUAL "50450000a601")
+ set(ARCHITECTURE_ID "SH4")
+ elseif(peheader STREQUAL "50450000a801")
+ set(ARCHITECTURE_ID "SH5")
+ endif()
endif()
endif()
@@ -576,8 +768,10 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
if(COMPILER_ID AND NOT COMPILER_ID_TWICE)
set(CMAKE_${lang}_COMPILER_ID "${COMPILER_ID}")
set(CMAKE_${lang}_PLATFORM_ID "${PLATFORM_ID}")
+ set(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID "${ARCHITECTURE_ID}")
set(MSVC_${lang}_ARCHITECTURE_ID "${ARCHITECTURE_ID}")
set(CMAKE_${lang}_COMPILER_VERSION "${COMPILER_VERSION}")
+ set(CMAKE_${lang}_COMPILER_VERSION_INTERNAL "${COMPILER_VERSION_INTERNAL}")
set(CMAKE_${lang}_SIMULATE_ID "${SIMULATE_ID}")
set(CMAKE_${lang}_SIMULATE_VERSION "${SIMULATE_VERSION}")
endif()
@@ -610,13 +804,10 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
# set(CMAKE_EXECUTABLE_FORMAT "COFF" CACHE STRING "Executable file format")
# endif()
#
-# # Mach-O files start with CAFEBABE or FEEDFACE, according to http://radio.weblogs.com/0100490/2003/01/28.html
-# if("${CMAKE_EXECUTABLE_MAGIC}" MATCHES "cafebabe")
-# set(CMAKE_EXECUTABLE_FORMAT "MACHO" CACHE STRING "Executable file format")
-# endif()
-# if("${CMAKE_EXECUTABLE_MAGIC}" MATCHES "feedface")
-# set(CMAKE_EXECUTABLE_FORMAT "MACHO" CACHE STRING "Executable file format")
-# endif()
+ # Mach-O files start with MH_MAGIC or MH_CIGAM
+ if("${CMAKE_EXECUTABLE_MAGIC}" MATCHES "feedface|cefaedfe|feedfacf|cffaedfe")
+ set(CMAKE_EXECUTABLE_FORMAT "MACHO" CACHE STRING "Executable file format")
+ endif()
endif()
if(NOT DEFINED CMAKE_EXECUTABLE_FORMAT)
@@ -625,9 +816,11 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
# Return the information extracted.
set(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE)
set(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE)
+ set(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID "${CMAKE_${lang}_COMPILER_ARCHITECTURE_ID}" PARENT_SCOPE)
set(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}"
PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE)
+ set(CMAKE_${lang}_COMPILER_VERSION_INTERNAL "${CMAKE_${lang}_COMPILER_VERSION_INTERNAL}" PARENT_SCOPE)
set(CMAKE_${lang}_COMPILER_WRAPPER "${COMPILER_WRAPPER}" PARENT_SCOPE)
set(CMAKE_${lang}_SIMULATE_ID "${CMAKE_${lang}_SIMULATE_ID}" PARENT_SCOPE)
set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE)
@@ -675,6 +868,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang userflags)
"Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" "
"matched \"${regex}\":\n${output}")
set(CMAKE_${lang}_COMPILER_ID "${vendor}" PARENT_SCOPE)
+ set(CMAKE_${lang}_COMPILER_ID_OUTPUT "${output}" PARENT_SCOPE)
break()
else()
if("${result}" MATCHES "timeout")
diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake
index d5220b4de..5ddd64fae 100644
--- a/Modules/CMakeDetermineFortranCompiler.cmake
+++ b/Modules/CMakeDetermineFortranCompiler.cmake
@@ -52,6 +52,7 @@ else()
# frt: Fujitsu F77 compiler
# pathf90/pathf95/pathf2003: PathScale Fortran compiler
# pgf77/pgf90/pgf95/pgfortran: Portland Group F77/F90/F95 compilers
+ # flang: Flang Fortran compiler
# xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers
# lf95: Lahey-Fujitsu F95 compiler
# fl32: Microsoft Fortran 77 "PowerStation" compiler
@@ -65,22 +66,31 @@ else()
# The order is 95 or newer compilers first, then 90,
# then 77 or older compilers, gnu is always last in the group,
# so if you paid for a compiler it is picked by default.
- set(CMAKE_Fortran_COMPILER_LIST
- ftn
- ifort ifc af95 af90 efc f95 pathf2003 pathf95 pgf95 pgfortran lf95 xlf95
- fort gfortran gfortran-4 g95 f90 pathf90 pgf90 xlf90 epcf90 fort77
- frt pgf77 xlf fl32 af77 g77 f77 nag
- )
+ if(CMAKE_HOST_WIN32)
+ set(CMAKE_Fortran_COMPILER_LIST
+ ifort pgf95 pgfortran lf95 fort
+ flang gfortran gfortran-4 g95 f90 pgf90
+ pgf77 g77 f77 nag
+ )
+ else()
+ set(CMAKE_Fortran_COMPILER_LIST
+ ftn
+ ifort ifc efc pgf95 pgfortran lf95 xlf95 fort
+ flang gfortran gfortran-4 g95 f90 pgf90
+ frt pgf77 xlf g77 f77 nag
+ )
+ endif()
# Vendor-specific compiler names.
set(_Fortran_COMPILER_NAMES_GNU gfortran gfortran-4 g95 g77)
set(_Fortran_COMPILER_NAMES_Intel ifort ifc efc)
set(_Fortran_COMPILER_NAMES_Absoft af95 af90 af77)
set(_Fortran_COMPILER_NAMES_PGI pgf95 pgfortran pgf90 pgf77)
+ set(_Fortran_COMPILER_NAMES_Flang flang)
set(_Fortran_COMPILER_NAMES_PathScale pathf2003 pathf95 pathf90)
set(_Fortran_COMPILER_NAMES_XL xlf)
set(_Fortran_COMPILER_NAMES_VisualAge xlf95 xlf90 xlf)
- set(_Fortran_COMPILER_NAMES_NAG nagfor)
+ set(_Fortran_COMPILER_NAMES_NAG nagfor)
endif()
_cmake_find_compiler(Fortran)
@@ -256,11 +266,18 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
endif ()
-include(CMakeFindBinUtils)
set(_CMAKE_PROCESSING_LANGUAGE "Fortran")
+include(CMakeFindBinUtils)
include(Compiler/${CMAKE_Fortran_COMPILER_ID}-FindBinUtils OPTIONAL)
unset(_CMAKE_PROCESSING_LANGUAGE)
+if(CMAKE_Fortran_COMPILER_ARCHITECTURE_ID)
+ set(_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID
+ "set(CMAKE_Fortran_COMPILER_ARCHITECTURE_ID ${CMAKE_Fortran_COMPILER_ARCHITECTURE_ID})")
+else()
+ set(_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID "")
+endif()
+
if(MSVC_Fortran_ARCHITECTURE_ID)
set(SET_MSVC_Fortran_ARCHITECTURE_ID
"set(MSVC_Fortran_ARCHITECTURE_ID ${MSVC_Fortran_ARCHITECTURE_ID})")
diff --git a/Modules/CMakeDetermineOBJCCompiler.cmake b/Modules/CMakeDetermineOBJCCompiler.cmake
new file mode 100644
index 000000000..ad13eab5e
--- /dev/null
+++ b/Modules/CMakeDetermineOBJCCompiler.cmake
@@ -0,0 +1,189 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+# determine the compiler to use for Objective-C programs
+# NOTE, a generator may set CMAKE_OBJC_COMPILER before
+# loading this file to force a compiler.
+# use environment variable OBJC first if defined by user, next use
+# the cmake variable CMAKE_GENERATOR_OBJC which can be defined by a generator
+# as a default compiler
+#
+# Sets the following variables:
+# CMAKE_OBJC_COMPILER
+# CMAKE_AR
+# CMAKE_RANLIB
+# CMAKE_COMPILER_IS_GNUOBJC
+# CMAKE_COMPILER_IS_CLANGOBJC
+#
+# If not already set before, it also sets
+# _CMAKE_TOOLCHAIN_PREFIX
+
+include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
+
+# Load system-specific compiler preferences for this language.
+include(Platform/${CMAKE_SYSTEM_NAME}-Determine-OBJC OPTIONAL)
+include(Platform/${CMAKE_SYSTEM_NAME}-OBJC OPTIONAL)
+if(NOT CMAKE_OBJC_COMPILER_NAMES)
+ set(CMAKE_OBJC_COMPILER_NAMES clang)
+endif()
+
+if("${CMAKE_GENERATOR}" MATCHES "Xcode")
+ set(CMAKE_OBJC_COMPILER_XCODE_TYPE sourcecode.c.objc)
+else()
+ if(NOT CMAKE_OBJC_COMPILER)
+ set(CMAKE_OBJC_COMPILER_INIT NOTFOUND)
+
+ # prefer the environment variable OBJC
+ if($ENV{OBJC} MATCHES ".+")
+ get_filename_component(CMAKE_OBJC_COMPILER_INIT $ENV{OBJC} PROGRAM PROGRAM_ARGS CMAKE_OBJC_FLAGS_ENV_INIT)
+ if(CMAKE_OBJC_FLAGS_ENV_INIT)
+ set(CMAKE_OBJC_COMPILER_ARG1 "${CMAKE_OBJC_FLAGS_ENV_INIT}" CACHE STRING "First argument to Objective-C compiler")
+ endif()
+ if(NOT EXISTS ${CMAKE_OBJC_COMPILER_INIT})
+ message(FATAL_ERROR "Could not find compiler set in environment variable OBJC:\n$ENV{OBJC}.")
+ endif()
+ endif()
+
+ # next try prefer the compiler specified by the generator
+ if(CMAKE_GENERATOR_OBJC)
+ if(NOT CMAKE_OBJC_COMPILER_INIT)
+ set(CMAKE_OBJC_COMPILER_INIT ${CMAKE_GENERATOR_OBJC})
+ endif()
+ endif()
+
+ # finally list compilers to try
+ if(NOT CMAKE_OBJC_COMPILER_INIT)
+ set(CMAKE_OBJC_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}cc ${_CMAKE_TOOLCHAIN_PREFIX}gcc clang)
+ endif()
+
+ _cmake_find_compiler(OBJC)
+
+ else()
+ # we only get here if CMAKE_OBJC_COMPILER was specified using -D or a pre-made CMakeCache.txt
+ # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE
+ # if CMAKE_OBJC_COMPILER is a list of length 2, use the first item as
+ # CMAKE_OBJC_COMPILER and the 2nd one as CMAKE_OBJC_COMPILER_ARG1
+
+ list(LENGTH CMAKE_OBJC_COMPILER _CMAKE_OBJC_COMPILER_LIST_LENGTH)
+ if("${_CMAKE_OBJC_COMPILER_LIST_LENGTH}" EQUAL 2)
+ list(GET CMAKE_OBJC_COMPILER 1 CMAKE_OBJC_COMPILER_ARG1)
+ list(GET CMAKE_OBJC_COMPILER 0 CMAKE_OBJC_COMPILER)
+ endif()
+
+ # if a compiler was specified by the user but without path,
+ # now try to find it with the full path
+ # if it is found, force it into the cache,
+ # if not, don't overwrite the setting (which was given by the user) with "NOTFOUND"
+ # if the C compiler already had a path, reuse it for searching the CXX compiler
+ get_filename_component(_CMAKE_USER_OBJC_COMPILER_PATH "${CMAKE_OBJC_COMPILER}" PATH)
+ if(NOT _CMAKE_USER_OBJC_COMPILER_PATH)
+ find_program(CMAKE_OBJC_COMPILER_WITH_PATH NAMES ${CMAKE_OBJC_COMPILER})
+ if(CMAKE_OBJC_COMPILER_WITH_PATH)
+ set(CMAKE_OBJC_COMPILER ${CMAKE_OBJC_COMPILER_WITH_PATH} CACHE STRING "Objective-C compiler" FORCE)
+ endif()
+ unset(CMAKE_OBJC_COMPILER_WITH_PATH CACHE)
+ endif()
+ endif()
+ mark_as_advanced(CMAKE_OBJC_COMPILER)
+
+ # Each entry in this list is a set of extra flags to try
+ # adding to the compile line to see if it helps produce
+ # a valid identification file.
+ set(CMAKE_OBJC_COMPILER_ID_TEST_FLAGS_FIRST)
+ set(CMAKE_OBJC_COMPILER_ID_TEST_FLAGS
+ # Try compiling to an object file only.
+ "-c"
+
+ )
+endif()
+
+# Build a small source file to identify the compiler.
+if(NOT CMAKE_OBJC_COMPILER_ID_RUN)
+ set(CMAKE_OBJC_COMPILER_ID_RUN 1)
+
+ # Try to identify the compiler.
+ set(CMAKE_OBJC_COMPILER_ID)
+ file(READ ${CMAKE_ROOT}/Modules/CMakePlatformId.h.in
+ CMAKE_OBJC_COMPILER_ID_PLATFORM_CONTENT)
+
+ # Match the link line from xcodebuild output of the form
+ # Ld ...
+ # ...
+ # /path/to/cc ...CompilerIdOBJC/...
+ # to extract the compiler front-end for the language.
+ set(CMAKE_OBJC_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdOBJC/(\\./)?(CompilerIdOBJC.(framework|xctest)/)?CompilerIdOBJC[ \t\n\\\"]")
+ set(CMAKE_OBJC_COMPILER_ID_TOOL_MATCH_INDEX 2)
+
+ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
+ CMAKE_DETERMINE_COMPILER_ID(OBJC OBJCCFLAGS CMakeOBJCCompilerId.m)
+
+ # Set old compiler and platform id variables.
+ if(CMAKE_OBJC_COMPILER_ID STREQUAL "GNU")
+ set(CMAKE_COMPILER_IS_GNUOBJC 1)
+ endif()
+ if(CMAKE_OBJC_COMPILER_ID STREQUAL "Clang")
+ set(CMAKE_COMPILER_IS_CLANGOBJC 1)
+ endif()
+endif()
+
+if (NOT _CMAKE_TOOLCHAIN_LOCATION)
+ get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_OBJC_COMPILER}" PATH)
+endif ()
+
+# If we have a gcc cross compiler, they have usually some prefix, like
+# e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc, optionally
+# with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2).
+# The other tools of the toolchain usually have the same prefix
+# NAME_WE cannot be used since then this test will fail for names like
+# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be
+# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-"
+if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
+
+ if(CMAKE_OBJC_COMPILER_ID MATCHES "GNU|Clang|QCC")
+ get_filename_component(COMPILER_BASENAME "${CMAKE_OBJC_COMPILER}" NAME)
+ if (COMPILER_BASENAME MATCHES "^(.+-)(clang|g?cc)(-[0-9]+(\\.[0-9]+)*)?(-[^.]+)?(\\.exe)?$")
+ set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
+ set(_CMAKE_COMPILER_SUFFIX ${CMAKE_MATCH_5})
+ elseif(CMAKE_OBJC_COMPILER_ID MATCHES "Clang")
+ if(CMAKE_OBJC_COMPILER_TARGET)
+ set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_OBJC_COMPILER_TARGET}-)
+ endif()
+ elseif(COMPILER_BASENAME MATCHES "qcc(\\.exe)?$")
+ if(CMAKE_OBJC_COMPILER_TARGET MATCHES "gcc_nto([a-z0-9]+_[0-9]+|[^_le]+)(le)?")
+ set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-)
+ endif()
+ endif ()
+
+ # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils
+ # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.)
+ if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$")
+ set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
+ endif ()
+ endif()
+
+endif ()
+
+set(_CMAKE_PROCESSING_LANGUAGE "OBJC")
+include(CMakeFindBinUtils)
+include(Compiler/${CMAKE_OBJC_COMPILER_ID}-FindBinUtils OPTIONAL)
+unset(_CMAKE_PROCESSING_LANGUAGE)
+
+if(CMAKE_OBJC_COMPILER_ARCHITECTURE_ID)
+ set(_SET_CMAKE_OBJC_COMPILER_ARCHITECTURE_ID
+ "set(CMAKE_OBJC_COMPILER_ARCHITECTURE_ID ${CMAKE_OBJC_COMPILER_ARCHITECTURE_ID})")
+else()
+ set(_SET_CMAKE_OBJC_COMPILER_ARCHITECTURE_ID "")
+endif()
+
+if(CMAKE_OBJC_XCODE_ARCHS)
+ set(SET_CMAKE_XCODE_ARCHS
+ "set(CMAKE_XCODE_ARCHS \"${CMAKE_OBJC_XCODE_ARCHS}\")")
+endif()
+
+# configure variables set in this file for fast reload later on
+configure_file(${CMAKE_ROOT}/Modules/CMakeOBJCCompiler.cmake.in
+ ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake
+ @ONLY
+ )
+set(CMAKE_OBJC_COMPILER_ENV_VAR "OBJC")
diff --git a/Modules/CMakeDetermineOBJCXXCompiler.cmake b/Modules/CMakeDetermineOBJCXXCompiler.cmake
new file mode 100644
index 000000000..60fcbb3f5
--- /dev/null
+++ b/Modules/CMakeDetermineOBJCXXCompiler.cmake
@@ -0,0 +1,197 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+# determine the compiler to use for Objective-C++ programs
+# NOTE, a generator may set CMAKE_OBJCXX_COMPILER before
+# loading this file to force a compiler.
+# use environment variable OBJCXX first if defined by user, next use
+# the cmake variable CMAKE_GENERATOR_OBJCXX which can be defined by a generator
+# as a default compiler
+# If the internal cmake variable _CMAKE_TOOLCHAIN_PREFIX is set, this is used
+# as prefix for the tools (e.g. arm-elf-g++, arm-elf-ar etc.)
+#
+# Sets the following variables:
+# CMAKE_OBJCXX_COMPILER
+# CMAKE_COMPILER_IS_GNUOBJCXX
+# CMAKE_COMPILER_IS_CLANGOBJCXX
+# CMAKE_AR
+# CMAKE_RANLIB
+#
+# If not already set before, it also sets
+# _CMAKE_TOOLCHAIN_PREFIX
+
+include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
+
+# Load system-specific compiler preferences for this language.
+include(Platform/${CMAKE_SYSTEM_NAME}-Determine-OBJCXX OPTIONAL)
+include(Platform/${CMAKE_SYSTEM_NAME}-OBJCXX OPTIONAL)
+if(NOT CMAKE_OBJCXX_COMPILER_NAMES)
+ set(CMAKE_OBJCXX_COMPILER_NAMES clang++)
+endif()
+
+if("${CMAKE_GENERATOR}" MATCHES "Xcode")
+ set(CMAKE_OBJCXX_COMPILER_XCODE_TYPE sourcecode.cpp.objcpp)
+else()
+ if(NOT CMAKE_OBJCXX_COMPILER)
+ set(CMAKE_OBJCXX_COMPILER_INIT NOTFOUND)
+
+ # prefer the environment variable OBJCXX
+ if($ENV{OBJCXX} MATCHES ".+")
+ get_filename_component(CMAKE_OBJCXX_COMPILER_INIT $ENV{OBJCXX} PROGRAM PROGRAM_ARGS CMAKE_OBJCXX_FLAGS_ENV_INIT)
+ if(CMAKE_OBJCXX_FLAGS_ENV_INIT)
+ set(CMAKE_OBJCXX_COMPILER_ARG1 "${CMAKE_OBJCXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to Objective-C++ compiler")
+ endif()
+ if(NOT EXISTS ${CMAKE_OBJCXX_COMPILER_INIT})
+ message(FATAL_ERROR "Could not find compiler set in environment variable OBJCXX:\n$ENV{OBJCXX}.\n${CMAKE_OBJCXX_COMPILER_INIT}")
+ endif()
+ endif()
+
+ # next prefer the generator specified compiler
+ if(CMAKE_GENERATOR_OBJCXX)
+ if(NOT CMAKE_OBJCXX_COMPILER_INIT)
+ set(CMAKE_OBJCXX_COMPILER_INIT ${CMAKE_GENERATOR_OBJCXX})
+ endif()
+ endif()
+
+ # finally list compilers to try
+ if(NOT CMAKE_OBJCXX_COMPILER_INIT)
+ set(CMAKE_OBJCXX_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}c++ ${_CMAKE_TOOLCHAIN_PREFIX}g++ clang++)
+ endif()
+
+ _cmake_find_compiler(OBJCXX)
+
+ else()
+ # we only get here if CMAKE_OBJCXX_COMPILER was specified using -D or a pre-made CMakeCache.txt
+ # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE
+ # if CMAKE_OBJCXX_COMPILER is a list of length 2, use the first item as
+ # CMAKE_OBJCXX_COMPILER and the 2nd one as CMAKE_OBJCXX_COMPILER_ARG1
+
+ list(LENGTH CMAKE_OBJCXX_COMPILER _CMAKE_OBJCXX_COMPILER_LIST_LENGTH)
+ if("${_CMAKE_OBJCXX_COMPILER_LIST_LENGTH}" EQUAL 2)
+ list(GET CMAKE_OBJCXX_COMPILER 1 CMAKE_OBJCXX_COMPILER_ARG1)
+ list(GET CMAKE_OBJCXX_COMPILER 0 CMAKE_OBJCXX_COMPILER)
+ endif()
+
+ # if a compiler was specified by the user but without path,
+ # now try to find it with the full path
+ # if it is found, force it into the cache,
+ # if not, don't overwrite the setting (which was given by the user) with "NOTFOUND"
+ # if the C compiler already had a path, reuse it for searching the CXX compiler
+ get_filename_component(_CMAKE_USER_OBJCXX_COMPILER_PATH "${CMAKE_OBJCXX_COMPILER}" PATH)
+ if(NOT _CMAKE_USER_OBJCXX_COMPILER_PATH)
+ find_program(CMAKE_OBJCXX_COMPILER_WITH_PATH NAMES ${CMAKE_OBJCXX_COMPILER})
+ if(CMAKE_OBJCXX_COMPILER_WITH_PATH)
+ set(CMAKE_OBJCXX_COMPILER ${CMAKE_OBJCXX_COMPILER_WITH_PATH} CACHE STRING "Objective-C++ compiler" FORCE)
+ endif()
+ unset(CMAKE_OBJCXX_COMPILER_WITH_PATH CACHE)
+ endif()
+
+ endif()
+ mark_as_advanced(CMAKE_OBJCXX_COMPILER)
+
+ # Each entry in this list is a set of extra flags to try
+ # adding to the compile line to see if it helps produce
+ # a valid identification file.
+ set(CMAKE_OBJCXX_COMPILER_ID_TEST_FLAGS_FIRST)
+ set(CMAKE_OBJCXX_COMPILER_ID_TEST_FLAGS
+ # Try compiling to an object file only.
+ "-c"
+
+ # ARMClang need target options
+ "--target=arm-arm-none-eabi -mcpu=cortex-m3"
+ )
+endif()
+
+# Build a small source file to identify the compiler.
+if(NOT CMAKE_OBJCXX_COMPILER_ID_RUN)
+ set(CMAKE_OBJCXX_COMPILER_ID_RUN 1)
+
+ # Try to identify the compiler.
+ set(CMAKE_OBJCXX_COMPILER_ID)
+ file(READ ${CMAKE_ROOT}/Modules/CMakePlatformId.h.in
+ CMAKE_OBJCXX_COMPILER_ID_PLATFORM_CONTENT)
+
+ # Match the link line from xcodebuild output of the form
+ # Ld ...
+ # ...
+ # /path/to/cc ...CompilerIdOBJCXX/...
+ # to extract the compiler front-end for the language.
+ set(CMAKE_OBJCXX_COMPILER_ID_TOOL_MATCH_REGEX "\nLd[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]*-o[^\r\n]*CompilerIdOBJCXX/(\\./)?(CompilerIdOBJCXX.(framework|xctest)/)?CompilerIdOBJCXX[ \t\n\\\"]")
+ set(CMAKE_OBJCXX_COMPILER_ID_TOOL_MATCH_INDEX 2)
+
+ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
+ CMAKE_DETERMINE_COMPILER_ID(OBJCXX OBJCXXFLAGS CMakeOBJCXXCompilerId.mm)
+
+ # Set old compiler and platform id variables.
+ if(CMAKE_OBJCXX_COMPILER_ID MATCHES "GNU")
+ set(CMAKE_COMPILER_IS_GNUOBJCXX 1)
+ endif()
+ if(CMAKE_OBJCXX_COMPILER_ID MATCHES "Clang")
+ set(CMAKE_COMPILER_IS_CLANGOBJCXX 1)
+ endif()
+endif()
+
+if (NOT _CMAKE_TOOLCHAIN_LOCATION)
+ get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_OBJCXX_COMPILER}" PATH)
+endif ()
+
+# if we have a g++ cross compiler, they have usually some prefix, like
+# e.g. powerpc-linux-g++, arm-elf-g++ or i586-mingw32msvc-g++ , optionally
+# with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2).
+# The other tools of the toolchain usually have the same prefix
+# NAME_WE cannot be used since then this test will fail for names like
+# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be
+# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-"
+
+
+if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
+
+ if("${CMAKE_OBJCXX_COMPILER_ID}" MATCHES "GNU|Clang|QCC")
+ get_filename_component(COMPILER_BASENAME "${CMAKE_OBJCXX_COMPILER}" NAME)
+ if (COMPILER_BASENAME MATCHES "^(.+-)(clan)?[gc]\\+\\+(-[0-9]+(\\.[0-9]+)*)?(-[^.]+)?(\\.exe)?$")
+ set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
+ set(_CMAKE_COMPILER_SUFFIX ${CMAKE_MATCH_5})
+ elseif("${CMAKE_OBJCXX_COMPILER_ID}" MATCHES "Clang")
+ if(CMAKE_OBJCXX_COMPILER_TARGET)
+ set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_OBJCXX_COMPILER_TARGET}-)
+ endif()
+ elseif(COMPILER_BASENAME MATCHES "QCC(\\.exe)?$")
+ if(CMAKE_OBJCXX_COMPILER_TARGET MATCHES "gcc_nto([a-z0-9]+_[0-9]+|[^_le]+)(le)")
+ set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-)
+ endif()
+ endif ()
+
+ # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils
+ # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.)
+ if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$")
+ set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
+ endif ()
+ endif()
+
+endif ()
+
+set(_CMAKE_PROCESSING_LANGUAGE "OBJCXX")
+include(CMakeFindBinUtils)
+include(Compiler/${CMAKE_OBJCXX_COMPILER_ID}-FindBinUtils OPTIONAL)
+unset(_CMAKE_PROCESSING_LANGUAGE)
+
+if(CMAKE_OBJCXX_COMPILER_ARCHITECTURE_ID)
+ set(_SET_CMAKE_OBJCXX_COMPILER_ARCHITECTURE_ID
+ "set(CMAKE_OBJCXX_COMPILER_ARCHITECTURE_ID ${CMAKE_OBJCXX_COMPILER_ARCHITECTURE_ID})")
+else()
+ set(_SET_CMAKE_OBJCXX_COMPILER_ARCHITECTURE_ID "")
+endif()
+
+if(CMAKE_OBJCXX_XCODE_ARCHS)
+ set(SET_CMAKE_XCODE_ARCHS
+ "set(CMAKE_XCODE_ARCHS \"${CMAKE_OBJCXX_XCODE_ARCHS}\")")
+endif()
+
+# configure all variables set in this file
+configure_file(${CMAKE_ROOT}/Modules/CMakeOBJCXXCompiler.cmake.in
+ ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake
+ @ONLY
+ )
+
+set(CMAKE_OBJCXX_COMPILER_ENV_VAR "OBJCXX")
diff --git a/Modules/CMakeDetermineSwiftCompiler.cmake b/Modules/CMakeDetermineSwiftCompiler.cmake
index 2604906e5..9aafe4820 100644
--- a/Modules/CMakeDetermineSwiftCompiler.cmake
+++ b/Modules/CMakeDetermineSwiftCompiler.cmake
@@ -1,15 +1,46 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
+# Local system-specific compiler preferences for this language.
+include(Platform/${CMAKE_SYSTEM_NAME}-Determine-Swift OPTIONAL)
+include(Platform/${CMAKE_SYSTEM_NAME}-Swift OPTIONAL)
+if(NOT CMAKE_Swift_COMPILER_NAMES)
+ set(CMAKE_Swift_COMPILER_NAMES swiftc)
+endif()
+
if("${CMAKE_GENERATOR}" STREQUAL "Xcode")
if(XCODE_VERSION VERSION_LESS 6.1)
message(FATAL_ERROR "Swift language not supported by Xcode ${XCODE_VERSION}")
endif()
set(CMAKE_Swift_COMPILER_XCODE_TYPE sourcecode.swift)
_cmake_find_compiler_path(Swift)
+elseif("${CMAKE_GENERATOR}" STREQUAL "Ninja")
+ if(CMAKE_Swift_COMPILER)
+ _cmake_find_compiler_path(Swift)
+ else()
+ set(CMAKE_Swift_COMPILER_INIT NOTFOUND)
+
+ if(NOT $ENV{SWIFTC} STREQUAL "")
+ get_filename_component(CMAKE_Swift_COMPILER_INIT $ENV{SWIFTC} PROGRAM
+ PROGRAM_ARGS CMAKE_Swift_FLAGS_ENV_INIT)
+ if(CMAKE_Swift_FLAGS_ENV_INIT)
+ set(CMAKE_Swift_COMPILER_ARG1 "${CMAKE_Swift_FLAGS_ENV_INIT}" CACHE
+ STRING "First argument to the Swift compiler")
+ endif()
+ if(NOT EXISTS ${CMAKE_Swift_COMPILER_INIT})
+ message(FATAL_ERROR "Could not find compiler set in environment variable SWIFTC\n$ENV{SWIFTC}.\n${CMAKE_Swift_COMPILER_INIT}")
+ endif()
+ endif()
+
+ if(NOT CMAKE_Swift_COMPILER_INIT)
+ set(CMAKE_Swift_COMPILER_LIST swiftc ${_CMAKE_TOOLCHAIN_PREFIX}swiftc)
+ endif()
+
+ _cmake_find_compiler(Swift)
+ endif()
+ mark_as_advanced(CMAKE_Swift_COMPILER)
else()
message(FATAL_ERROR "Swift language not supported by \"${CMAKE_GENERATOR}\" generator")
endif()
@@ -18,11 +49,13 @@ endif()
if(NOT CMAKE_Swift_COMPILER_ID_RUN)
set(CMAKE_Swift_COMPILER_ID_RUN 1)
- list(APPEND CMAKE_Swift_COMPILER_ID_MATCH_VENDORS Apple)
- set(CMAKE_Swift_COMPILER_ID_MATCH_VENDOR_REGEX_Apple "com.apple.xcode.tools.swift.compiler")
+ if("${CMAKE_GENERATOR}" STREQUAL "Xcode")
+ list(APPEND CMAKE_Swift_COMPILER_ID_MATCH_VENDORS Apple)
+ set(CMAKE_Swift_COMPILER_ID_MATCH_VENDOR_REGEX_Apple "com.apple.xcode.tools.swift.compiler")
- set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_REGEX "\nCompileSwiftSources[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]* -c[^\r\n]*CompilerIdSwift/CompilerId/main.swift")
- set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_INDEX 2)
+ set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_REGEX "\nCompileSwift[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]* -c[^\r\n]*CompilerIdSwift/CompilerId/main.swift")
+ set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_INDEX 2)
+ endif()
# Try to identify the compiler.
set(CMAKE_Swift_COMPILER_ID)
@@ -34,10 +67,12 @@ if (NOT _CMAKE_TOOLCHAIN_LOCATION)
get_filename_component(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_Swift_COMPILER}" PATH)
endif ()
+set(_CMAKE_PROCESSING_LANGUAGE "Swift")
include(CMakeFindBinUtils)
+unset(_CMAKE_PROCESSING_LANGUAGE)
# configure variables set in this file for fast reload later on
configure_file(${CMAKE_ROOT}/Modules/CMakeSwiftCompiler.cmake.in
- ${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake
- @ONLY
- )
+ ${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake @ONLY)
+
+set(CMAKE_Swift_COMPILER_ENV_VAR "SWIFTC")
diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake
index 20dcf1bb5..dc208c600 100644
--- a/Modules/CMakeDetermineSystem.cmake
+++ b/Modules/CMakeDetermineSystem.cmake
@@ -2,7 +2,7 @@
# file Copyright.txt or https://cmake.org/licensing for details.
-# This module is used by the Makefile generator to determin the following variables:
+# This module is used by the Makefile generator to determine the following variables:
# CMAKE_SYSTEM_NAME - on unix this is uname -s, for windows it is Windows
# CMAKE_SYSTEM_VERSION - on unix this is uname -r, for windows it is empty
# CMAKE_SYSTEM - ${CMAKE_SYSTEM}-${CMAKE_SYSTEM_VERSION}, for windows: ${CMAKE_SYSTEM}
@@ -13,7 +13,6 @@
# BSD/OS BSD/OS
# FreeBSD FreeBSD
# HP-UX HP-UX
-# IRIX IRIX
# Linux Linux
# GNU/kFreeBSD GNU/kFreeBSD
# NetBSD NetBSD
diff --git a/Modules/CMakeDetermineVSServicePack.cmake b/Modules/CMakeDetermineVSServicePack.cmake
index 026462144..53868d21a 100644
--- a/Modules/CMakeDetermineVSServicePack.cmake
+++ b/Modules/CMakeDetermineVSServicePack.cmake
@@ -1,35 +1,38 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakeDetermineVSServicePack
-# ---------------------------
-#
-# Deprecated. Do not use.
-#
-# The functionality of this module has been superseded by the
-# :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable that contains
-# the compiler version number.
-#
-# Determine the Visual Studio service pack of the 'cl' in use.
-#
-# Usage::
-#
-# if(MSVC)
-# include(CMakeDetermineVSServicePack)
-# DetermineVSServicePack( my_service_pack )
-# if( my_service_pack )
-# message(STATUS "Detected: ${my_service_pack}")
-# endif()
-# endif()
-#
-# Function DetermineVSServicePack sets the given variable to one of the
-# following values or an empty string if unknown::
-#
-# vc80, vc80sp1
-# vc90, vc90sp1
-# vc100, vc100sp1
-# vc110, vc110sp1, vc110sp2, vc110sp3, vc110sp4
+#[=======================================================================[.rst:
+CMakeDetermineVSServicePack
+---------------------------
+
+.. deprecated:: 3.0
+
+ Do not use.
+
+The functionality of this module has been superseded by the
+:variable:`CMAKE_<LANG>_COMPILER_VERSION` variable that contains
+the compiler version number.
+
+Determine the Visual Studio service pack of the 'cl' in use.
+
+Usage::
+
+ if(MSVC)
+ include(CMakeDetermineVSServicePack)
+ DetermineVSServicePack( my_service_pack )
+ if( my_service_pack )
+ message(STATUS "Detected: ${my_service_pack}")
+ endif()
+ endif()
+
+Function DetermineVSServicePack sets the given variable to one of the
+following values or an empty string if unknown::
+
+ vc80, vc80sp1
+ vc90, vc90sp1
+ vc100, vc100sp1
+ vc110, vc110sp1, vc110sp2, vc110sp3, vc110sp4
+#]=======================================================================]
if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.8)
message(DEPRECATION
@@ -41,32 +44,32 @@ endif()
# [INTERNAL]
# Please do not call this function directly
function(_DetermineVSServicePackFromCompiler _OUT_VAR _cl_version)
- if (${_cl_version} VERSION_EQUAL "14.00.50727.42")
- set(_version "vc80")
- elseif(${_cl_version} VERSION_EQUAL "14.00.50727.762")
- set(_version "vc80sp1")
- elseif(${_cl_version} VERSION_EQUAL "15.00.21022.08")
- set(_version "vc90")
- elseif(${_cl_version} VERSION_EQUAL "15.00.30729.01")
- set(_version "vc90sp1")
- elseif(${_cl_version} VERSION_EQUAL "16.00.30319.01")
- set(_version "vc100")
- elseif(${_cl_version} VERSION_EQUAL "16.00.40219.01")
- set(_version "vc100sp1")
- elseif(${_cl_version} VERSION_EQUAL "17.00.50727.1")
- set(_version "vc110")
- elseif(${_cl_version} VERSION_EQUAL "17.00.51106.1")
- set(_version "vc110sp1")
- elseif(${_cl_version} VERSION_EQUAL "17.00.60315.1")
- set(_version "vc110sp2")
- elseif(${_cl_version} VERSION_EQUAL "17.00.60610.1")
- set(_version "vc110sp3")
- elseif(${_cl_version} VERSION_EQUAL "17.00.61030")
- set(_version "vc110sp4")
- else()
- set(_version "")
- endif()
- set(${_OUT_VAR} ${_version} PARENT_SCOPE)
+ if (${_cl_version} VERSION_EQUAL "14.00.50727.42")
+ set(_version "vc80")
+ elseif(${_cl_version} VERSION_EQUAL "14.00.50727.762")
+ set(_version "vc80sp1")
+ elseif(${_cl_version} VERSION_EQUAL "15.00.21022.08")
+ set(_version "vc90")
+ elseif(${_cl_version} VERSION_EQUAL "15.00.30729.01")
+ set(_version "vc90sp1")
+ elseif(${_cl_version} VERSION_EQUAL "16.00.30319.01")
+ set(_version "vc100")
+ elseif(${_cl_version} VERSION_EQUAL "16.00.40219.01")
+ set(_version "vc100sp1")
+ elseif(${_cl_version} VERSION_EQUAL "17.00.50727.1")
+ set(_version "vc110")
+ elseif(${_cl_version} VERSION_EQUAL "17.00.51106.1")
+ set(_version "vc110sp1")
+ elseif(${_cl_version} VERSION_EQUAL "17.00.60315.1")
+ set(_version "vc110sp2")
+ elseif(${_cl_version} VERSION_EQUAL "17.00.60610.1")
+ set(_version "vc110sp3")
+ elseif(${_cl_version} VERSION_EQUAL "17.00.61030")
+ set(_version "vc110sp4")
+ else()
+ set(_version "")
+ endif()
+ set(${_OUT_VAR} ${_version} PARENT_SCOPE)
endfunction()
@@ -76,7 +79,7 @@ endfunction()
function(_DetermineVSServicePack_FastCheckVersionWithCompiler _SUCCESS_VAR _VERSION_VAR)
if(EXISTS ${CMAKE_CXX_COMPILER})
execute_process(
- COMMAND ${CMAKE_CXX_COMPILER} /?
+ COMMAND ${CMAKE_CXX_COMPILER} -?
ERROR_VARIABLE _output
OUTPUT_QUIET
)
@@ -169,4 +172,3 @@ function(DetermineVSServicePack _pack)
endif()
endif()
endfunction()
-
diff --git a/Modules/CMakeExpandImportedTargets.cmake b/Modules/CMakeExpandImportedTargets.cmake
index ad065f050..b8f471c10 100644
--- a/Modules/CMakeExpandImportedTargets.cmake
+++ b/Modules/CMakeExpandImportedTargets.cmake
@@ -1,142 +1,148 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakeExpandImportedTargets
-# --------------------------
-#
-# Deprecated. Do not use.
-#
-# This module was once needed to expand imported targets to the underlying
-# libraries they reference on disk for use with the :command:`try_compile`
-# and :command:`try_run` commands. These commands now support imported
-# libraries in their ``LINK_LIBRARIES`` options (since CMake 2.8.11
-# for :command:`try_compile` and since CMake 3.2 for :command:`try_run`).
-#
-# This module does not support the policy :policy:`CMP0022` ``NEW``
-# behavior or use of the :prop_tgt:`INTERFACE_LINK_LIBRARIES` property
-# because :manual:`generator expressions <cmake-generator-expressions(7)>`
-# cannot be evaluated during configuration.
-#
-# ::
-#
-# CMAKE_EXPAND_IMPORTED_TARGETS(<var> LIBRARIES lib1 lib2...libN
-# [CONFIGURATION <config>])
-#
-# CMAKE_EXPAND_IMPORTED_TARGETS() takes a list of libraries and replaces
-# all imported targets contained in this list with their actual file
-# paths of the referenced libraries on disk, including the libraries
-# from their link interfaces. If a CONFIGURATION is given, it uses the
-# respective configuration of the imported targets if it exists. If no
-# CONFIGURATION is given, it uses the first configuration from
-# ${CMAKE_CONFIGURATION_TYPES} if set, otherwise ${CMAKE_BUILD_TYPE}.
-#
-# ::
-#
-# cmake_expand_imported_targets(expandedLibs
-# LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}
-# CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}" )
+#[=======================================================================[.rst:
+CMakeExpandImportedTargets
+--------------------------
-function(CMAKE_EXPAND_IMPORTED_TARGETS _RESULT )
+.. deprecated:: 3.4
- set(options )
- set(oneValueArgs CONFIGURATION )
- set(multiValueArgs LIBRARIES )
+ Do not use.
- cmake_parse_arguments(CEIT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+This module was once needed to expand imported targets to the underlying
+libraries they reference on disk for use with the :command:`try_compile`
+and :command:`try_run` commands. These commands now support imported
+libraries in their ``LINK_LIBRARIES`` options (since CMake 2.8.11
+for :command:`try_compile` and since CMake 3.2 for :command:`try_run`).
- if(CEIT_UNPARSED_ARGUMENTS)
- message(FATAL_ERROR "Unknown keywords given to CMAKE_EXPAND_IMPORTED_TARGETS(): \"${CEIT_UNPARSED_ARGUMENTS}\"")
- endif()
+This module does not support the policy :policy:`CMP0022` ``NEW``
+behavior or use of the :prop_tgt:`INTERFACE_LINK_LIBRARIES` property
+because :manual:`generator expressions <cmake-generator-expressions(7)>`
+cannot be evaluated during configuration.
- if(NOT CEIT_CONFIGURATION)
- if(CMAKE_CONFIGURATION_TYPES)
- list(GET CMAKE_CONFIGURATION_TYPES 0 CEIT_CONFIGURATION)
- else()
- set(CEIT_CONFIGURATION ${CMAKE_BUILD_TYPE})
- endif()
- endif()
-
- # handle imported library targets
-
- set(_CCSR_REQ_LIBS ${CEIT_LIBRARIES})
-
- set(_CHECK_FOR_IMPORTED_TARGETS TRUE)
- set(_CCSR_LOOP_COUNTER 0)
- while(_CHECK_FOR_IMPORTED_TARGETS)
- math(EXPR _CCSR_LOOP_COUNTER "${_CCSR_LOOP_COUNTER} + 1 ")
- set(_CCSR_NEW_REQ_LIBS )
- set(_CHECK_FOR_IMPORTED_TARGETS FALSE)
- foreach(_CURRENT_LIB ${_CCSR_REQ_LIBS})
- if(TARGET "${_CURRENT_LIB}")
- get_target_property(_importedConfigs "${_CURRENT_LIB}" IMPORTED_CONFIGURATIONS)
- else()
- set(_importedConfigs "")
- endif()
- if (_importedConfigs)
-# message(STATUS "Detected imported target ${_CURRENT_LIB}")
- # Ok, so this is an imported target.
- # First we get the imported configurations.
- # Then we get the location of the actual library on disk of the first configuration.
- # then we'll get its link interface libraries property,
- # iterate through it and replace all imported targets we find there
- # with there actual location.
-
- # guard against infinite loop: abort after 100 iterations ( 100 is arbitrary chosen)
- if ("${_CCSR_LOOP_COUNTER}" LESS 100)
- set(_CHECK_FOR_IMPORTED_TARGETS TRUE)
-# else ()
-# message(STATUS "********* aborting loop, counter : ${_CCSR_LOOP_COUNTER}")
- endif ()
-
- # if one of the imported configurations equals ${CMAKE_TRY_COMPILE_CONFIGURATION},
- # use it, otherwise simply use the first one:
- list(FIND _importedConfigs "${CEIT_CONFIGURATION}" _configIndexToUse)
- if("${_configIndexToUse}" EQUAL -1)
- set(_configIndexToUse 0)
- endif()
- list(GET _importedConfigs ${_configIndexToUse} _importedConfigToUse)
-
- get_target_property(_importedLocation "${_CURRENT_LIB}" IMPORTED_LOCATION_${_importedConfigToUse})
- get_target_property(_linkInterfaceLibs "${_CURRENT_LIB}" IMPORTED_LINK_INTERFACE_LIBRARIES_${_importedConfigToUse} )
-
- list(APPEND _CCSR_NEW_REQ_LIBS "${_importedLocation}")
-# message(STATUS "Appending lib ${_CURRENT_LIB} as ${_importedLocation}")
- if(_linkInterfaceLibs)
- foreach(_currentLinkInterfaceLib ${_linkInterfaceLibs})
-# message(STATUS "Appending link interface lib ${_currentLinkInterfaceLib}")
- if(_currentLinkInterfaceLib)
- list(APPEND _CCSR_NEW_REQ_LIBS "${_currentLinkInterfaceLib}" )
- endif()
- endforeach()
- endif()
- else()
- # "Normal" libraries are just used as they are.
- list(APPEND _CCSR_NEW_REQ_LIBS "${_CURRENT_LIB}" )
-# message(STATUS "Appending lib directly: ${_CURRENT_LIB}")
- endif()
- endforeach()
-
- set(_CCSR_REQ_LIBS ${_CCSR_NEW_REQ_LIBS} )
- endwhile()
-
- # Finally we iterate once more over all libraries. This loop only removes
- # all remaining imported target names (there shouldn't be any left anyway).
- set(_CCSR_NEW_REQ_LIBS )
- foreach(_CURRENT_LIB ${_CCSR_REQ_LIBS})
+::
+
+ CMAKE_EXPAND_IMPORTED_TARGETS(<var> LIBRARIES lib1 lib2...libN
+ [CONFIGURATION <config>])
+
+CMAKE_EXPAND_IMPORTED_TARGETS() takes a list of libraries and replaces
+all imported targets contained in this list with their actual file
+paths of the referenced libraries on disk, including the libraries
+from their link interfaces. If a CONFIGURATION is given, it uses the
+respective configuration of the imported targets if it exists. If no
+CONFIGURATION is given, it uses the first configuration from
+${CMAKE_CONFIGURATION_TYPES} if set, otherwise ${CMAKE_BUILD_TYPE}.
+
+::
+
+ cmake_expand_imported_targets(expandedLibs
+ LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}
+ CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}" )
+#]=======================================================================]
+
+function(CMAKE_EXPAND_IMPORTED_TARGETS _RESULT )
+
+ set(options )
+ set(oneValueArgs CONFIGURATION )
+ set(multiValueArgs LIBRARIES )
+
+ cmake_parse_arguments(CEIT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if(CEIT_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unknown keywords given to CMAKE_EXPAND_IMPORTED_TARGETS(): \"${CEIT_UNPARSED_ARGUMENTS}\"")
+ endif()
+
+ if(NOT CEIT_CONFIGURATION)
+ # Would be better to test GENERATOR_IS_MULTI_CONFIG global property,
+ # but the documented behavior specifically says we check
+ # CMAKE_CONFIGURATION_TYPES and fall back to CMAKE_BUILD_TYPE if no
+ # config types are defined.
+ if(CMAKE_CONFIGURATION_TYPES)
+ list(GET CMAKE_CONFIGURATION_TYPES 0 CEIT_CONFIGURATION)
+ else()
+ set(CEIT_CONFIGURATION ${CMAKE_BUILD_TYPE})
+ endif()
+ endif()
+
+ # handle imported library targets
+
+ set(_CCSR_REQ_LIBS ${CEIT_LIBRARIES})
+
+ set(_CHECK_FOR_IMPORTED_TARGETS TRUE)
+ set(_CCSR_LOOP_COUNTER 0)
+ while(_CHECK_FOR_IMPORTED_TARGETS)
+ math(EXPR _CCSR_LOOP_COUNTER "${_CCSR_LOOP_COUNTER} + 1 ")
+ set(_CCSR_NEW_REQ_LIBS )
+ set(_CHECK_FOR_IMPORTED_TARGETS FALSE)
+ foreach(_CURRENT_LIB ${_CCSR_REQ_LIBS})
if(TARGET "${_CURRENT_LIB}")
get_target_property(_importedConfigs "${_CURRENT_LIB}" IMPORTED_CONFIGURATIONS)
else()
set(_importedConfigs "")
endif()
- if (NOT _importedConfigs)
- list(APPEND _CCSR_NEW_REQ_LIBS "${_CURRENT_LIB}" )
-# message(STATUS "final: appending ${_CURRENT_LIB}")
- else ()
-# message(STATUS "final: skipping ${_CURRENT_LIB}")
- endif ()
- endforeach()
-# message(STATUS "setting -${_RESULT}- to -${_CCSR_NEW_REQ_LIBS}-")
- set(${_RESULT} "${_CCSR_NEW_REQ_LIBS}" PARENT_SCOPE)
+ if (_importedConfigs)
+ # message(STATUS "Detected imported target ${_CURRENT_LIB}")
+ # Ok, so this is an imported target.
+ # First we get the imported configurations.
+ # Then we get the location of the actual library on disk of the first configuration.
+ # then we'll get its link interface libraries property,
+ # iterate through it and replace all imported targets we find there
+ # with there actual location.
+
+ # guard against infinite loop: abort after 100 iterations ( 100 is arbitrary chosen)
+ if ("${_CCSR_LOOP_COUNTER}" LESS 100)
+ set(_CHECK_FOR_IMPORTED_TARGETS TRUE)
+# else ()
+# message(STATUS "********* aborting loop, counter : ${_CCSR_LOOP_COUNTER}")
+ endif ()
+
+ # if one of the imported configurations equals ${CMAKE_TRY_COMPILE_CONFIGURATION},
+ # use it, otherwise simply use the first one:
+ list(FIND _importedConfigs "${CEIT_CONFIGURATION}" _configIndexToUse)
+ if("${_configIndexToUse}" EQUAL -1)
+ set(_configIndexToUse 0)
+ endif()
+ list(GET _importedConfigs ${_configIndexToUse} _importedConfigToUse)
+
+ get_target_property(_importedLocation "${_CURRENT_LIB}" IMPORTED_LOCATION_${_importedConfigToUse})
+ get_target_property(_linkInterfaceLibs "${_CURRENT_LIB}" IMPORTED_LINK_INTERFACE_LIBRARIES_${_importedConfigToUse} )
+
+ list(APPEND _CCSR_NEW_REQ_LIBS "${_importedLocation}")
+# message(STATUS "Appending lib ${_CURRENT_LIB} as ${_importedLocation}")
+ if(_linkInterfaceLibs)
+ foreach(_currentLinkInterfaceLib ${_linkInterfaceLibs})
+# message(STATUS "Appending link interface lib ${_currentLinkInterfaceLib}")
+ if(_currentLinkInterfaceLib)
+ list(APPEND _CCSR_NEW_REQ_LIBS "${_currentLinkInterfaceLib}" )
+ endif()
+ endforeach()
+ endif()
+ else()
+ # "Normal" libraries are just used as they are.
+ list(APPEND _CCSR_NEW_REQ_LIBS "${_CURRENT_LIB}" )
+# message(STATUS "Appending lib directly: ${_CURRENT_LIB}")
+ endif()
+ endforeach()
+ set(_CCSR_REQ_LIBS ${_CCSR_NEW_REQ_LIBS} )
+ endwhile()
+
+ # Finally we iterate once more over all libraries. This loop only removes
+ # all remaining imported target names (there shouldn't be any left anyway).
+ set(_CCSR_NEW_REQ_LIBS )
+ foreach(_CURRENT_LIB ${_CCSR_REQ_LIBS})
+ if(TARGET "${_CURRENT_LIB}")
+ get_target_property(_importedConfigs "${_CURRENT_LIB}" IMPORTED_CONFIGURATIONS)
+ else()
+ set(_importedConfigs "")
+ endif()
+ if (NOT _importedConfigs)
+ list(APPEND _CCSR_NEW_REQ_LIBS "${_CURRENT_LIB}" )
+# message(STATUS "final: appending ${_CURRENT_LIB}")
+# else ()
+# message(STATUS "final: skipping ${_CURRENT_LIB}")
+ endif ()
+ endforeach()
+# message(STATUS "setting -${_RESULT}- to -${_CCSR_NEW_REQ_LIBS}-")
+ set(${_RESULT} "${_CCSR_NEW_REQ_LIBS}" PARENT_SCOPE)
endfunction()
diff --git a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake
index 3a72622e4..11f4a29b4 100644
--- a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake
+++ b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake
@@ -27,6 +27,7 @@ macro(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines
set(_compilerExecutable "${CMAKE_C_COMPILER}")
set(_arg1 "${CMAKE_C_COMPILER_ARG1}")
endif ()
+ separate_arguments(_arg1 NATIVE_COMMAND "${_arg1}")
execute_process(COMMAND ${_compilerExecutable} ${_arg1} ${_stdver} ${_stdlib} -v -E -x ${_lang} -dD dummy
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles
ERROR_VARIABLE _gccOutput
@@ -66,10 +67,10 @@ macro(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines
#message(STATUS "m1: -${CMAKE_MATCH_1}- m2: -${CMAKE_MATCH_2}- m3: -${CMAKE_MATCH_3}-")
list(APPEND ${_resultDefines} "${_name}")
- if(_value)
- list(APPEND ${_resultDefines} "${_value}")
- else()
+ if ("${_value}" STREQUAL "")
list(APPEND ${_resultDefines} " ")
+ else()
+ list(APPEND ${_resultDefines} "${_value}")
endif()
endforeach()
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake
index e4103d0b7..c23e44742 100644
--- a/Modules/CMakeFindBinUtils.cmake
+++ b/Modules/CMakeFindBinUtils.cmake
@@ -14,28 +14,70 @@
# CMAKE_AR
# CMAKE_RANLIB
# CMAKE_LINKER
+# CMAKE_MT
# CMAKE_STRIP
# CMAKE_INSTALL_NAME_TOOL
# on UNIX, cygwin and mingw
+# Resolve full path of CMAKE_TOOL from user-defined name and SEARCH_PATH.
+function(__resolve_tool_path CMAKE_TOOL SEARCH_PATH DOCSTRING)
+
+ if(${CMAKE_TOOL})
+ # We only get here if CMAKE_TOOL was
+ # specified using -D or a pre-made CMakeCache.txt (e.g. via ctest)
+ # or set in CMAKE_TOOLCHAIN_FILE.
+
+ get_filename_component(_CMAKE_USER_TOOL_PATH "${${CMAKE_TOOL}}" DIRECTORY)
+ # Is CMAKE_TOOL a user-defined name instead of a full path?
+ if(NOT _CMAKE_USER_TOOL_PATH)
+
+ # Find CMAKE_TOOL in the SEARCH_PATH directory by user-defined name.
+ find_program(_CMAKE_TOOL_WITH_PATH NAMES ${${CMAKE_TOOL}} HINTS ${SEARCH_PATH})
+ if(_CMAKE_TOOL_WITH_PATH)
+
+ # Overwrite CMAKE_TOOL with full path found in SEARCH_PATH.
+ set(${CMAKE_TOOL} ${_CMAKE_TOOL_WITH_PATH} PARENT_SCOPE)
+
+ get_property(_CMAKE_TOOL_CACHED CACHE ${CMAKE_TOOL} PROPERTY TYPE)
+ # If CMAKE_TOOL is present in the CMake Cache, then overwrit it as well.
+ if(_CMAKE_TOOL_CACHED)
+ set(${CMAKE_TOOL} "${_CMAKE_TOOL_WITH_PATH}" CACHE STRING ${DOCSTRING} FORCE)
+ endif()
+
+ endif()
+ unset(_CMAKE_TOOL_WITH_PATH CACHE)
+
+ endif()
+
+ endif()
+
+endfunction()
+
+__resolve_tool_path(CMAKE_LINKER "${_CMAKE_TOOLCHAIN_LOCATION}" "Default Linker")
+__resolve_tool_path(CMAKE_MT "${_CMAKE_TOOLCHAIN_LOCATION}" "Default Manifest Tool")
+
+set(_CMAKE_TOOL_VARS "")
+
# if it's the MS C/CXX compiler, search for link
-if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
- OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC"
- OR "x${CMAKE_Fortran_SIMULATE_ID}" STREQUAL "xMSVC"
- OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC"
- OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC"
- OR "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC"
- OR (CMAKE_HOST_WIN32 AND (
- "x${CMAKE_C_COMPILER_ID}" STREQUAL "xPGI"
- OR "x${CMAKE_Fortran_COMPILER_ID}" STREQUAL "xPGI"
- ))
+if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND
+ ("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC"
+ OR NOT "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xClang"))
+ OR "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xMSVC"
+ OR (CMAKE_HOST_WIN32 AND "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xPGI")
+ OR (CMAKE_HOST_WIN32 AND "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xNVIDIA")
OR (CMAKE_GENERATOR MATCHES "Visual Studio"
AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android"))
- find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xClang")
+ find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm llvm-nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ set(_CMAKE_ADDITIONAL_LINKER_NAMES "lld-link")
+ endif()
+
+ find_program(CMAKE_LINKER NAMES ${_CMAKE_ADDITIONAL_LINKER_NAMES} link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_MT NAMES mt HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- mark_as_advanced(CMAKE_LINKER)
+ list(APPEND _CMAKE_TOOL_VARS LINKER MT)
# in all other cases search for ar, ranlib, etc.
else()
@@ -45,29 +87,57 @@ else()
if(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN)
set(_CMAKE_TOOLCHAIN_LOCATION ${_CMAKE_TOOLCHAIN_LOCATION} ${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}/bin)
endif()
- find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL Clang)
+ set(_CMAKE_ADDITIONAL_AR_NAMES "llvm-ar")
+ set(_CMAKE_ADDITIONAL_RANLIB_NAMES "llvm-ranlib")
+ set(_CMAKE_ADDITIONAL_STRIP_NAMES "llvm-strip")
+ set(_CMAKE_ADDITIONAL_LINKER_NAMES "ld.lld")
+ set(_CMAKE_ADDITIONAL_NM_NAMES "llvm-nm")
+ set(_CMAKE_ADDITIONAL_OBJDUMP_NAMES "llvm-objdump")
+ set(_CMAKE_ADDITIONAL_OBJCOPY_NAMES "llvm-objcopy")
+ set(_CMAKE_ADDITIONAL_READELF_NAMES "llvm-readelf")
+ set(_CMAKE_ADDITIONAL_DLLTOOL_NAMES "llvm-dlltool")
+ set(_CMAKE_ADDITIONAL_ADDR2LINE_NAMES "llvm-addr2line")
+ endif()
+
+ find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_AR_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+
+ find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${_CMAKE_ADDITIONAL_RANLIB_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
if(NOT CMAKE_RANLIB)
set(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
endif()
- find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
- mark_as_advanced(CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY)
+ find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} ${_CMAKE_ADDITIONAL_STRIP_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld ${_CMAKE_ADDITIONAL_LINKER_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm ${_CMAKE_ADDITIONAL_NM_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump ${_CMAKE_ADDITIONAL_OBJDUMP_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy ${_CMAKE_ADDITIONAL_OBJCOPY_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_READELF NAMES ${_CMAKE_TOOLCHAIN_PREFIX}readelf ${_CMAKE_ADDITIONAL_READELF_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_DLLTOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}dlltool ${_CMAKE_ADDITIONAL_DLLTOOL_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_ADDR2LINE NAMES ${_CMAKE_TOOLCHAIN_PREFIX}addr2line ${_CMAKE_ADDITIONAL_ADDR2LINE_NAMES} HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ list(APPEND _CMAKE_TOOL_VARS AR RANLIB STRIP LINKER NM OBJDUMP OBJCOPY READELF DLLTOOL ADDR2LINE)
endif()
if(CMAKE_PLATFORM_HAS_INSTALLNAME)
- find_program(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_INSTALL_NAME_TOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
if(NOT CMAKE_INSTALL_NAME_TOOL)
message(FATAL_ERROR "Could not find install_name_tool, please check your installation.")
endif()
- mark_as_advanced(CMAKE_INSTALL_NAME_TOOL)
+ list(APPEND _CMAKE_TOOL_VARS INSTALL_NAME_TOOL)
endif()
+
+# Mark any tool cache entries as advanced.
+foreach(var IN LISTS _CMAKE_TOOL_VARS)
+ get_property(_CMAKE_TOOL_CACHED CACHE CMAKE_${var} PROPERTY TYPE)
+ if(_CMAKE_TOOL_CACHED)
+ mark_as_advanced(CMAKE_${var})
+ endif()
+ unset(_CMAKE_ADDITIONAL_${var}_NAMES)
+endforeach()
+unset(_CMAKE_TOOL_VARS)
+unset(_CMAKE_TOOL_CACHED)
diff --git a/Modules/CMakeFindCodeBlocks.cmake b/Modules/CMakeFindCodeBlocks.cmake
index b76e5c57f..bf27ec111 100644
--- a/Modules/CMakeFindCodeBlocks.cmake
+++ b/Modules/CMakeFindCodeBlocks.cmake
@@ -8,7 +8,7 @@
find_program(CMAKE_CODEBLOCKS_EXECUTABLE NAMES codeblocks DOC "The CodeBlocks executable")
if(CMAKE_CODEBLOCKS_EXECUTABLE)
- set(CMAKE_OPEN_PROJECT_COMMAND "${CMAKE_CODEBLOCKS_EXECUTABLE} <PROJECT_FILE>" )
+ set(CMAKE_OPEN_PROJECT_COMMAND "${CMAKE_CODEBLOCKS_EXECUTABLE} <PROJECT_FILE>" )
endif()
# Determine builtin macros and include dirs:
@@ -28,3 +28,6 @@ endif()
# This variable is used by the CodeBlocks generator and appended to the make invocation commands.
set(CMAKE_CODEBLOCKS_MAKE_ARGUMENTS "${_CMAKE_CODEBLOCKS_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when CodeBlocks invokes make. Enter e.g. -j<some_number> to get parallel builds")
+
+# This variable is used by the CodeBlocks generator and allows the user to overwrite the autodetected CodeBlocks compiler id
+set(CMAKE_CODEBLOCKS_COMPILER_ID "" CACHE STRING "Id string of the compiler for the CodeBlocks IDE. Automatically detected when left empty")
diff --git a/Modules/CMakeFindDependencyMacro.cmake b/Modules/CMakeFindDependencyMacro.cmake
index 81606cef6..bcdfbebe3 100644
--- a/Modules/CMakeFindDependencyMacro.cmake
+++ b/Modules/CMakeFindDependencyMacro.cmake
@@ -1,55 +1,63 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakeFindDependencyMacro
-# -------------------------
-#
-# ::
-#
-# find_dependency(<dep> [...])
-#
-#
-# ``find_dependency()`` wraps a :command:`find_package` call for a package
-# dependency. It is designed to be used in a <package>Config.cmake file, and it
-# forwards the correct parameters for QUIET and REQUIRED which were passed to
-# the original :command:`find_package` call. It also sets an informative
-# diagnostic message if the dependency could not be found.
-#
-# Any additional arguments specified are forwarded to :command:`find_package`.
-#
+#[=======================================================================[.rst:
+CMakeFindDependencyMacro
+-------------------------
+
+.. command:: find_dependency
+
+ The ``find_dependency()`` macro wraps a :command:`find_package` call for
+ a package dependency::
+
+ find_dependency(<dep> [...])
+
+ It is designed to be used in a
+ :ref:`Package Configuration File <Config File Packages>`
+ (``<PackageName>Config.cmake``). ``find_dependency`` forwards the correct
+ parameters for ``QUIET`` and ``REQUIRED`` which were passed to
+ the original :command:`find_package` call. Any additional arguments
+ specified are forwarded to :command:`find_package`.
+
+ If the dependency could not be found it sets an informative diagnostic
+ message and calls :command:`return` to end processing of the calling
+ package configuration file and return to the :command:`find_package`
+ command that loaded it.
+
+ .. note::
+
+ The call to :command:`return` makes this macro unsuitable to call
+ from :ref:`Find Modules`.
+#]=======================================================================]
macro(find_dependency dep)
+ set(cmake_fd_quiet_arg)
+ if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
+ set(cmake_fd_quiet_arg QUIET)
+ endif()
+ set(cmake_fd_required_arg)
+ if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
+ set(cmake_fd_required_arg REQUIRED)
+ endif()
+
+ get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY
+ _CMAKE_${dep}_TRANSITIVE_DEPENDENCY
+ )
+
+ find_package(${dep} ${ARGN}
+ ${cmake_fd_quiet_arg}
+ ${cmake_fd_required_arg}
+ )
+
+ if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive)
+ set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE)
+ endif()
+
if (NOT ${dep}_FOUND)
- set(cmake_fd_quiet_arg)
- if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
- set(cmake_fd_quiet_arg QUIET)
- endif()
- set(cmake_fd_required_arg)
- if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
- set(cmake_fd_required_arg REQUIRED)
- endif()
-
- get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY
- _CMAKE_${dep}_TRANSITIVE_DEPENDENCY
- )
-
- find_package(${dep} ${ARGN}
- ${cmake_fd_quiet_arg}
- ${cmake_fd_required_arg}
- )
-
- if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive)
- set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE)
- endif()
-
- if (NOT ${dep}_FOUND)
- set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.")
- set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
- return()
- endif()
- set(cmake_fd_required_arg)
- set(cmake_fd_quiet_arg)
- set(cmake_fd_exact_arg)
+ set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.")
+ set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False)
+ return()
endif()
+ set(cmake_fd_required_arg)
+ set(cmake_fd_quiet_arg)
endmacro()
diff --git a/Modules/CMakeFindFrameworks.cmake b/Modules/CMakeFindFrameworks.cmake
index 6c4c52729..06c05fb91 100644
--- a/Modules/CMakeFindFrameworks.cmake
+++ b/Modules/CMakeFindFrameworks.cmake
@@ -1,15 +1,16 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakeFindFrameworks
-# -------------------
-#
-# helper module to find OSX frameworks
-#
-# This module reads hints about search locations from variables::
-#
-# CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS - Extra directories
+#[=======================================================================[.rst:
+CMakeFindFrameworks
+-------------------
+
+helper module to find OSX frameworks
+
+This module reads hints about search locations from variables::
+
+ CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS - Extra directories
+#]=======================================================================]
if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED)
set(CMAKE_FIND_FRAMEWORKS_INCLUDED 1)
diff --git a/Modules/CMakeFindKDevelop3.cmake b/Modules/CMakeFindKDevelop3.cmake
deleted file mode 100644
index 488acf758..000000000
--- a/Modules/CMakeFindKDevelop3.cmake
+++ /dev/null
@@ -1,13 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-
-# This file is included in CMakeSystemSpecificInformation.cmake if
-# the KDevelop3 extra generator has been selected.
-
-find_program(CMAKE_KDEVELOP3_EXECUTABLE NAMES kdevelop DOC "The KDevelop3 executable")
-
-if(CMAKE_KDEVELOP3_EXECUTABLE)
- set(CMAKE_OPEN_PROJECT_COMMAND "${CMAKE_KDEVELOP3_EXECUTABLE} <PROJECT_FILE>" )
-endif()
-
diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake
index 1261137c1..815dfc90d 100644
--- a/Modules/CMakeFindPackageMode.cmake
+++ b/Modules/CMakeFindPackageMode.cmake
@@ -1,33 +1,34 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakeFindPackageMode
-# --------------------
-#
-#
-#
-# This file is executed by cmake when invoked with --find-package. It
-# expects that the following variables are set using -D:
-#
-# ``NAME``
-# name of the package
-# ``COMPILER_ID``
-# the CMake compiler ID for which the result is,
-# i.e. GNU/Intel/Clang/MSVC, etc.
-# ``LANGUAGE``
-# language for which the result will be used,
-# i.e. C/CXX/Fortan/ASM
-# ``MODE``
-# ``EXIST``
-# only check for existence of the given package
-# ``COMPILE``
-# print the flags needed for compiling an object file which uses
-# the given package
-# ``LINK``
-# print the flags needed for linking when using the given package
-# ``QUIET``
-# if TRUE, don't print anything
+#[=======================================================================[.rst:
+CMakeFindPackageMode
+--------------------
+
+
+
+This file is executed by cmake when invoked with --find-package. It
+expects that the following variables are set using -D:
+
+``NAME``
+ name of the package
+``COMPILER_ID``
+ the CMake compiler ID for which the result is,
+ i.e. GNU/Intel/Clang/MSVC, etc.
+``LANGUAGE``
+ language for which the result will be used,
+ i.e. C/CXX/Fortran/ASM
+``MODE``
+ ``EXIST``
+ only check for existence of the given package
+ ``COMPILE``
+ print the flags needed for compiling an object file which uses
+ the given package
+ ``LINK``
+ print the flags needed for linking when using the given package
+``QUIET``
+ if TRUE, don't print anything
+#]=======================================================================]
if(NOT NAME)
message(FATAL_ERROR "Name of the package to be searched not specified. Set the CMake variable NAME, e.g. -DNAME=JPEG .")
@@ -65,6 +66,8 @@ if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin AND "${COMPILER_ID}" MATCHES GNU)
set(CMAKE_${LANGUAGE}_OSX_DEPLOYMENT_TARGET_FLAG "")
endif()
+include(CMakeSystemSpecificInitialize)
+
# Also load the system specific file, which sets up e.g. the search paths.
# This makes the FIND_XXX() calls work much better
include(CMakeSystemSpecificInformation)
diff --git a/Modules/CMakeFindSublimeText2.cmake b/Modules/CMakeFindSublimeText2.cmake
new file mode 100644
index 000000000..7f67bf03d
--- /dev/null
+++ b/Modules/CMakeFindSublimeText2.cmake
@@ -0,0 +1,23 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+# This file is included in CMakeSystemSpecificInformation.cmake if
+# the Sublime Text 2 extra generator has been selected.
+
+find_program(CMAKE_SUBLIMETEXT_EXECUTABLE
+ NAMES subl3 subl sublime_text
+ PATHS
+ "/Applications/Sublime Text.app/Contents/SharedSupport/bin"
+ "/Applications/Sublime Text 3.app/Contents/SharedSupport/bin"
+ "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin"
+ "$ENV{HOME}/Applications/Sublime Text.app/Contents/SharedSupport/bin"
+ "$ENV{HOME}/Applications/Sublime Text 3.app/Contents/SharedSupport/bin"
+ "$ENV{HOME}/Applications/Sublime Text 2.app/Contents/SharedSupport/bin"
+ "/opt/sublime_text"
+ "/opt/sublime_text_3"
+ DOC "The Sublime Text executable")
+
+if(CMAKE_SUBLIMETEXT_EXECUTABLE)
+ set(CMAKE_OPEN_PROJECT_COMMAND "${CMAKE_SUBLIMETEXT_EXECUTABLE} --project <PROJECT_FILE>" )
+endif()
diff --git a/Modules/CMakeForceCompiler.cmake b/Modules/CMakeForceCompiler.cmake
index 1bc80fd75..704880631 100644
--- a/Modules/CMakeForceCompiler.cmake
+++ b/Modules/CMakeForceCompiler.cmake
@@ -1,69 +1,75 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakeForceCompiler
-# ------------------
-#
-# Deprecated. Do not use.
-#
-# The macros provided by this module were once intended for use by
-# cross-compiling toolchain files when CMake was not able to automatically
-# detect the compiler identification. Since the introduction of this module,
-# CMake's compiler identification capabilities have improved and can now be
-# taught to recognize any compiler. Furthermore, the suite of information
-# CMake detects from a compiler is now too extensive to be provided by
-# toolchain files using these macros.
-#
-# One common use case for this module was to skip CMake's checks for a
-# working compiler when using a cross-compiler that cannot link binaries
-# without special flags or custom linker scripts. This case is now supported
-# by setting the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable in the
-# toolchain file instead.
-#
-# -------------------------------------------------------------------------
-#
-# Macro CMAKE_FORCE_C_COMPILER has the following signature:
-#
-# ::
-#
-# CMAKE_FORCE_C_COMPILER(<compiler> <compiler-id>)
-#
-# It sets CMAKE_C_COMPILER to the given compiler and the cmake internal
-# variable CMAKE_C_COMPILER_ID to the given compiler-id. It also
-# bypasses the check for working compiler and basic compiler information
-# tests.
-#
-# Macro CMAKE_FORCE_CXX_COMPILER has the following signature:
-#
-# ::
-#
-# CMAKE_FORCE_CXX_COMPILER(<compiler> <compiler-id>)
-#
-# It sets CMAKE_CXX_COMPILER to the given compiler and the cmake
-# internal variable CMAKE_CXX_COMPILER_ID to the given compiler-id. It
-# also bypasses the check for working compiler and basic compiler
-# information tests.
-#
-# Macro CMAKE_FORCE_Fortran_COMPILER has the following signature:
-#
-# ::
-#
-# CMAKE_FORCE_Fortran_COMPILER(<compiler> <compiler-id>)
-#
-# It sets CMAKE_Fortran_COMPILER to the given compiler and the cmake
-# internal variable CMAKE_Fortran_COMPILER_ID to the given compiler-id.
-# It also bypasses the check for working compiler and basic compiler
-# information tests.
-#
-# So a simple toolchain file could look like this:
-#
-# ::
-#
-# include (CMakeForceCompiler)
-# set(CMAKE_SYSTEM_NAME Generic)
-# CMAKE_FORCE_C_COMPILER (chc12 MetrowerksHicross)
-# CMAKE_FORCE_CXX_COMPILER (chc12 MetrowerksHicross)
+#[=======================================================================[.rst:
+CMakeForceCompiler
+------------------
+
+.. deprecated:: 3.6
+
+ Do not use.
+
+The macros provided by this module were once intended for use by
+cross-compiling toolchain files when CMake was not able to automatically
+detect the compiler identification. Since the introduction of this module,
+CMake's compiler identification capabilities have improved and can now be
+taught to recognize any compiler. Furthermore, the suite of information
+CMake detects from a compiler is now too extensive to be provided by
+toolchain files using these macros.
+
+One common use case for this module was to skip CMake's checks for a
+working compiler when using a cross-compiler that cannot link binaries
+without special flags or custom linker scripts. This case is now supported
+by setting the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable in the
+toolchain file instead.
+
+-------------------------------------------------------------------------
+
+Macro ``CMAKE_FORCE_C_COMPILER`` has the following signature:
+
+::
+
+ CMAKE_FORCE_C_COMPILER(<compiler> <compiler-id>)
+
+It sets :variable:`CMAKE_C_COMPILER <CMAKE_<LANG>_COMPILER>` to
+the given compiler and the cmake internal variable
+:variable:`CMAKE_C_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` to the given
+compiler-id. It also bypasses the check for working compiler and basic
+compiler information tests.
+
+Macro ``CMAKE_FORCE_CXX_COMPILER`` has the following signature:
+
+::
+
+ CMAKE_FORCE_CXX_COMPILER(<compiler> <compiler-id>)
+
+It sets :variable:`CMAKE_CXX_COMPILER <CMAKE_<LANG>_COMPILER>` to
+the given compiler and the cmake internal variable
+:variable:`CMAKE_CXX_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` to the given
+compiler-id. It also bypasses the check for working compiler and basic
+compiler information tests.
+
+Macro ``CMAKE_FORCE_Fortran_COMPILER`` has the following signature:
+
+::
+
+ CMAKE_FORCE_Fortran_COMPILER(<compiler> <compiler-id>)
+
+It sets :variable:`CMAKE_Fortran_COMPILER <CMAKE_<LANG>_COMPILER>` to
+the given compiler and the cmake internal variable
+:variable:`CMAKE_Fortran_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` to the given
+compiler-id. It also bypasses the check for working compiler and basic
+compiler information tests.
+
+So a simple toolchain file could look like this:
+
+::
+
+ include (CMakeForceCompiler)
+ set(CMAKE_SYSTEM_NAME Generic)
+ CMAKE_FORCE_C_COMPILER (chc12 MetrowerksHicross)
+ CMAKE_FORCE_CXX_COMPILER (chc12 MetrowerksHicross)
+#]=======================================================================]
macro(CMAKE_FORCE_C_COMPILER compiler id)
message(DEPRECATION "The CMAKE_FORCE_C_COMPILER macro is deprecated. "
diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in
index d52119050..ae7b73ac4 100644
--- a/Modules/CMakeFortranCompiler.cmake.in
+++ b/Modules/CMakeFortranCompiler.cmake.in
@@ -6,6 +6,7 @@ set(CMAKE_Fortran_COMPILER_WRAPPER "@CMAKE_Fortran_COMPILER_WRAPPER@")
set(CMAKE_Fortran_PLATFORM_ID "@CMAKE_Fortran_PLATFORM_ID@")
set(CMAKE_Fortran_SIMULATE_ID "@CMAKE_Fortran_SIMULATE_ID@")
set(CMAKE_Fortran_SIMULATE_VERSION "@CMAKE_Fortran_SIMULATE_VERSION@")
+@_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID@
@SET_MSVC_Fortran_ARCHITECTURE_ID@
set(CMAKE_AR "@CMAKE_AR@")
set(CMAKE_Fortran_COMPILER_AR "@CMAKE_Fortran_COMPILER_AR@")
@@ -30,7 +31,7 @@ if(CMAKE_COMPILER_IS_MINGW)
set(MINGW 1)
endif()
set(CMAKE_Fortran_COMPILER_ID_RUN 1)
-set(CMAKE_Fortran_SOURCE_FILE_EXTENSIONS f;F;f77;F77;f90;F90;for;For;FOR;f95;F95)
+set(CMAKE_Fortran_SOURCE_FILE_EXTENSIONS f;F;fpp;FPP;f77;F77;f90;F90;for;For;FOR;f95;F95)
set(CMAKE_Fortran_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
set(CMAKE_Fortran_LINKER_PREFERENCE 20)
if(UNIX)
@@ -60,6 +61,7 @@ endif()
@CMAKE_Fortran_SYSROOT_FLAG_CODE@
@CMAKE_Fortran_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
+set(CMAKE_Fortran_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_INCLUDE_DIRECTORIES@")
set(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "@CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES@")
set(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES@")
set(CMAKE_Fortran_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
diff --git a/Modules/CMakeFortranCompilerABI.F b/Modules/CMakeFortranCompilerABI.F
index b34c28484..f4a5489a1 100644
--- a/Modules/CMakeFortranCompilerABI.F
+++ b/Modules/CMakeFortranCompilerABI.F
@@ -33,13 +33,7 @@
#if 0
! Application Binary Interface
#endif
-#if defined(__sgi) && defined(_ABIO32)
- PRINT *, 'INFO:abi[ELF O32]'
-#elif defined(__sgi) && defined(_ABIN32)
- PRINT *, 'INFO:abi[ELF N32]'
-#elif defined(__sgi) && defined(_ABI64)
- PRINT *, 'INFO:abi[ELF 64]'
-#elif defined(__ELF__)
+#if defined(__ELF__)
PRINT *, 'INFO:abi[ELF]'
#endif
PRINT *, 'ABI Detection'
diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in
index 26b2ed656..30f8d4c45 100644
--- a/Modules/CMakeFortranCompilerId.F.in
+++ b/Modules/CMakeFortranCompilerId.F.in
@@ -2,6 +2,26 @@
#if 0
! Identify the compiler
#endif
+#if defined(_MSC_VER)
+ PRINT *, 'INFO:simulate[MSVC]'
+# if _MSC_VER >= 1900
+ PRINT *, 'INFO:simulate_version[019.00]'
+# elif _MSC_VER >= 1800
+ PRINT *, 'INFO:simulate_version[018.00]'
+# elif _MSC_VER >= 1700
+ PRINT *, 'INFO:simulate_version[017.00]'
+# elif _MSC_VER >= 1600
+ PRINT *, 'INFO:simulate_version[016.00]'
+# elif _MSC_VER >= 1500
+ PRINT *, 'INFO:simulate_version[015.00]'
+# elif _MSC_VER >= 1400
+ PRINT *, 'INFO:simulate_version[014.00]'
+# elif _MSC_VER >= 1310
+ PRINT *, 'INFO:simulate_version[013.01]'
+# else
+ PRINT *, 'INFO:simulate_version[013.00]'
+# endif
+#endif
#if defined(__INTEL_COMPILER) || defined(__ICC)
PRINT *, 'INFO:compiler[Intel]'
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
@@ -14,27 +34,6 @@
# if defined(__INTEL_COMPILER_BUILD_DATE)
# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
# endif
-
-# if defined(_MSC_VER)
- PRINT *, 'INFO:simulate[MSVC]'
-# if _MSC_VER >= 1900
- PRINT *, 'INFO:simulate_version[019.00]'
-# elif _MSC_VER >= 1800
- PRINT *, 'INFO:simulate_version[018.00]'
-# elif _MSC_VER >= 1700
- PRINT *, 'INFO:simulate_version[017.00]'
-# elif _MSC_VER >= 1600
- PRINT *, 'INFO:simulate_version[016.00]'
-# elif _MSC_VER >= 1500
- PRINT *, 'INFO:simulate_version[015.00]'
-# elif _MSC_VER >= 1400
- PRINT *, 'INFO:simulate_version[014.00]'
-# elif _MSC_VER >= 1310
- PRINT *, 'INFO:simulate_version[013.01]'
-# else
- PRINT *, 'INFO:simulate_version[013.00]'
-# endif
-# endif
#elif defined(__SUNPRO_F95)
PRINT *, 'INFO:compiler[SunPro]'
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_F95>>8)
@@ -90,17 +89,15 @@
# if defined(__PGIC_PATCHLEVEL__)
# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
# endif
-#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
- PRINT *, 'INFO:compiler[MIPSpro]'
-# if 0
-! This compiler is either not known or is too old to define an
-! identification macro. Try to identify the platform and guess that
-! it is the native compiler.
-# endif
+#elif defined(__FLANG)
+ PRINT *, 'INFO:compiler[Flang]'
+# define COMPILER_VERSION_MAJOR DEC(__FLANG_MAJOR__)
+# define COMPILER_VERSION_MINOR DEC(__FLANG_MINOR__)
+# if defined(__FLANG_PATCHLEVEL__)
+# define COMPILER_VERSION_PATCH DEC(__FLANG_PATCHLEVEL__)
+# endif
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
PRINT *, 'INFO:compiler[VisualAge]'
-#elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
- PRINT *, 'INFO:compiler[MIPSpro]'
#elif defined(__hpux) || defined(__hpux__)
PRINT *, 'INFO:compiler[HP]'
#elif defined(NAGFOR)
@@ -108,11 +105,7 @@
#define COMPILER_VERSION_MAJOR DEC(__NAG_COMPILER_RELEASE/10)
#define COMPILER_VERSION_MINOR DEC(__NAG_COMPILER_RELEASE % 10)
#define COMPILER_VERSION_PATCH DEC(__NAG_COMPILER_BUILD)
-#elif 1
-# if 0
-! The above 'elif 1' instead of 'else' is to work around a bug in the
-! SGI preprocessor which produces both the __sgi and else blocks.
-# endif
+#else
PRINT *, 'INFO:compiler[]'
#endif
#if defined(__CRAYXE) || defined(__CRAYXC)
@@ -142,8 +135,6 @@
PRINT *, 'INFO:platform[SunOS]'
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
PRINT *, 'INFO:platform[AIX]'
-#elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
- PRINT *, 'INFO:platform[IRIX]'
#elif defined(__hpux) || defined(__hpux__)
PRINT *, 'INFO:platform[HP-UX]'
#elif defined(__HAIKU__)
@@ -172,11 +163,7 @@
PRINT *, 'INFO:platform[ULTRIX]'
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
PRINT *, 'INFO:platform[Xenix]'
-#elif 1
-# if 0
-! The above 'elif 1' instead of 'else' is to work around a bug in the
-! SGI preprocessor which produces both the __sgi and else blocks.
-# endif
+#else
PRINT *, 'INFO:platform[]'
#endif
#if defined(_WIN32) && (defined(__INTEL_COMPILER) || defined(__ICC))
diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake
index 8005da6e4..ffa6a2471 100644
--- a/Modules/CMakeFortranInformation.cmake
+++ b/Modules/CMakeFortranInformation.cmake
@@ -22,10 +22,10 @@ if(CMAKE_COMPILER_IS_GNUG77)
set(CMAKE_BASE_NAME g77)
endif()
if(CMAKE_Fortran_COMPILER_ID)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_Fortran_COMPILER_ID}-Fortran OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_Fortran_COMPILER_ID}-Fortran OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif()
if (NOT _INCLUDED_FILE)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL
RESULT_VARIABLE _INCLUDED_FILE)
endif ()
@@ -67,11 +67,6 @@ if(CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_Fortran "${_override}")
endif()
-
-# Fortran needs cmake to do a requires step during its build process to
-# catch any modules
-set(CMAKE_NEEDS_REQUIRES_STEP_Fortran_FLAG 1)
-
if(NOT CMAKE_Fortran_COMPILE_OPTIONS_PIC)
set(CMAKE_Fortran_COMPILE_OPTIONS_PIC ${CMAKE_C_COMPILE_OPTIONS_PIC})
endif()
@@ -79,6 +74,12 @@ endif()
if(NOT CMAKE_Fortran_COMPILE_OPTIONS_PIE)
set(CMAKE_Fortran_COMPILE_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE})
endif()
+if(NOT CMAKE_Fortran_LINK_OPTIONS_PIE)
+ set(CMAKE_Fortran_LINK_OPTIONS_PIE ${CMAKE_C_LINK_OPTIONS_PIE})
+endif()
+if(NOT CMAKE_Fortran_LINK_OPTIONS_NO_PIE)
+ set(CMAKE_Fortran_LINK_OPTIONS_NO_PIE ${CMAKE_C_LINK_OPTIONS_NO_PIE})
+endif()
if(NOT CMAKE_Fortran_COMPILE_OPTIONS_DLL)
set(CMAKE_Fortran_COMPILE_OPTIONS_DLL ${CMAKE_C_COMPILE_OPTIONS_DLL})
@@ -156,20 +157,11 @@ if(NOT CMAKE_INCLUDE_FLAG_Fortran)
set(CMAKE_INCLUDE_FLAG_Fortran ${CMAKE_INCLUDE_FLAG_C})
endif()
-if(NOT CMAKE_INCLUDE_FLAG_SEP_Fortran)
- set(CMAKE_INCLUDE_FLAG_SEP_Fortran ${CMAKE_INCLUDE_FLAG_SEP_C})
-endif()
-
set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.")
set(CMAKE_Fortran_FLAGS_INIT "$ENV{FFLAGS} ${CMAKE_Fortran_FLAGS_INIT}")
-foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO)
- string(STRIP "${CMAKE_Fortran_FLAGS${c}_INIT}" CMAKE_Fortran_FLAGS${c}_INIT)
-endforeach()
-
-set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS_INIT}" CACHE STRING
- "Flags for Fortran compiler.")
+cmake_initialize_per_config_variable(CMAKE_Fortran_FLAGS "Flags used by the Fortran compiler")
include(CMakeCommonLanguageInclude)
@@ -221,24 +213,5 @@ if(CMAKE_Fortran_STANDARD_LIBRARIES_INIT)
mark_as_advanced(CMAKE_Fortran_STANDARD_LIBRARIES)
endif()
-if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
- set (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG_INIT}" CACHE STRING
- "Flags used by the compiler during debug builds.")
- set (CMAKE_Fortran_FLAGS_MINSIZEREL "${CMAKE_Fortran_FLAGS_MINSIZEREL_INIT}" CACHE STRING
- "Flags used by the compiler during release builds for minimum size.")
- set (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE_INIT}" CACHE STRING
- "Flags used by the compiler during release builds.")
- set (CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
- "Flags used by the compiler during release builds with debug info.")
-
-endif()
-
-mark_as_advanced(
-CMAKE_Fortran_FLAGS
-CMAKE_Fortran_FLAGS_DEBUG
-CMAKE_Fortran_FLAGS_MINSIZEREL
-CMAKE_Fortran_FLAGS_RELEASE
-CMAKE_Fortran_FLAGS_RELWITHDEBINFO)
-
# set this variable so we can avoid loading this more than once.
set(CMAKE_Fortran_INFORMATION_LOADED 1)
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake
index cd052376b..77d8cfd4f 100644
--- a/Modules/CMakeGenericSystem.cmake
+++ b/Modules/CMakeGenericSystem.cmake
@@ -1,6 +1,7 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
+include(CMakeInitializeConfigs)
set(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared
@@ -8,7 +9,6 @@ set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") # -rpath
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty
set(CMAKE_INCLUDE_FLAG_C "-I") # -I
-set(CMAKE_INCLUDE_FLAG_C_SEP "") # , or empty
set(CMAKE_LIBRARY_PATH_FLAG "-L")
set(CMAKE_LIBRARY_PATH_TERMINATOR "") # for the Digital Mars D compiler the link paths have to be terminated with a "/"
set(CMAKE_LINK_LIBRARY_FLAG "-l")
@@ -24,6 +24,11 @@ set(CMAKE_DL_LIBS "dl")
set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
+set(CMAKE_AUTOGEN_ORIGIN_DEPENDS ON)
+set(CMAKE_AUTOMOC_COMPILER_PREDEFINES ON)
+set(CMAKE_AUTOMOC_PATH_PREFIX ON)
+set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_NAMESPACE")
+
# basically all general purpose OSs support shared libs
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
@@ -76,6 +81,8 @@ function(GetDefaultWindowsPrefixBase var)
#
if("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)")
set(arch_hint "x64")
+ elseif("${CMAKE_GENERATOR_PLATFORM}" MATCHES "ARM64")
+ set(arch_hint "ARM64")
elseif("${CMAKE_GENERATOR}" MATCHES "ARM")
set(arch_hint "ARM")
elseif("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
diff --git a/Modules/CMakeGraphVizOptions.cmake b/Modules/CMakeGraphVizOptions.cmake
index 420e3a9e7..1911e7392 100644
--- a/Modules/CMakeGraphVizOptions.cmake
+++ b/Modules/CMakeGraphVizOptions.cmake
@@ -1,119 +1,123 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakeGraphVizOptions
-# --------------------
-#
-# The builtin graphviz support of CMake.
-#
-# Variables specific to the graphviz support
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# CMake
-# can generate graphviz files, showing the dependencies between the
-# targets in a project and also external libraries which are linked
-# against. When CMake is run with the --graphviz=foo.dot option, it will
-# produce:
-#
-# * a foo.dot file showing all dependencies in the project
-# * a foo.dot.<target> file for each target, file showing on which other targets the respective target depends
-# * a foo.dot.<target>.dependers file, showing which other targets depend on the respective target
-#
-# This can result in huge graphs. Using the file
-# CMakeGraphVizOptions.cmake the look and content of the generated
-# graphs can be influenced. This file is searched first in
-# ${CMAKE_BINARY_DIR} and then in ${CMAKE_SOURCE_DIR}. If found, it is
-# read and the variables set in it are used to adjust options for the
-# generated graphviz files.
-#
-# .. variable:: GRAPHVIZ_GRAPH_TYPE
-#
-# The graph type.
-#
-# * Mandatory : NO
-# * Default : "digraph"
-#
-# Valid graph types are:
-#
-# * "graph" : Nodes are joined with lines
-# * "digraph" : Nodes are joined with arrows showing direction
-# * "strict graph" : Like "graph" but max one line between each node
-# * "strict digraph" : Like "graph" but max one line between each node in each direction
-#
-# .. variable:: GRAPHVIZ_GRAPH_NAME
-#
-# The graph name.
-#
-# * Mandatory : NO
-# * Default : "GG"
-#
-# .. variable:: GRAPHVIZ_GRAPH_HEADER
-#
-# The header written at the top of the graphviz file.
-#
-# * Mandatory : NO
-# * Default : "node [n fontsize = "12"];"
-#
-# .. variable:: GRAPHVIZ_NODE_PREFIX
-#
-# The prefix for each node in the graphviz file.
-#
-# * Mandatory : NO
-# * Default : "node"
-#
-# .. variable:: GRAPHVIZ_EXECUTABLES
-#
-# Set this to FALSE to exclude executables from the generated graphs.
-#
-# * Mandatory : NO
-# * Default : TRUE
-#
-# .. variable:: GRAPHVIZ_STATIC_LIBS
-#
-# Set this to FALSE to exclude static libraries from the generated graphs.
-#
-# * Mandatory : NO
-# * Default : TRUE
-#
-# .. variable:: GRAPHVIZ_SHARED_LIBS
-#
-# Set this to FALSE to exclude shared libraries from the generated graphs.
-#
-# * Mandatory : NO
-# * Default : TRUE
-#
-# .. variable:: GRAPHVIZ_MODULE_LIBS
-#
-# Set this to FALSE to exclude module libraries from the generated graphs.
-#
-# * Mandatory : NO
-# * Default : TRUE
-#
-# .. variable:: GRAPHVIZ_EXTERNAL_LIBS
-#
-# Set this to FALSE to exclude external libraries from the generated graphs.
-#
-# * Mandatory : NO
-# * Default : TRUE
-#
-# .. variable:: GRAPHVIZ_IGNORE_TARGETS
-#
-# A list of regular expressions for ignoring targets.
-#
-# * Mandatory : NO
-# * Default : empty
-#
-# .. variable:: GRAPHVIZ_GENERATE_PER_TARGET
-#
-# Set this to FALSE to exclude per target graphs ``foo.dot.<target>``.
-#
-# * Mandatory : NO
-# * Default : TRUE
-#
-# .. variable:: GRAPHVIZ_GENERATE_DEPENDERS
-#
-# Set this to FALSE to exclude depender graphs ``foo.dot.<target>.dependers``.
-#
-# * Mandatory : NO
-# * Default : TRUE
+#[=======================================================================[.rst:
+CMakeGraphVizOptions
+--------------------
+
+The builtin graphviz support of CMake.
+
+Variables specific to the graphviz support
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+CMake
+can generate `graphviz <http://www.graphviz.org/>`_ files, showing the dependencies between the
+targets in a project and also external libraries which are linked
+against. When CMake is run with the ``--graphviz=foo.dot`` option, it will
+produce:
+
+* a ``foo.dot`` file showing all dependencies in the project
+* a ``foo.dot.<target>`` file for each target, file showing on which other targets the respective target depends
+* a ``foo.dot.<target>.dependers`` file, showing which other targets depend on the respective target
+
+The different dependency types ``PUBLIC``, ``PRIVATE`` and ``INTERFACE``
+are represented as solid, dashed and dotted edges.
+
+This can result in huge graphs. Using the file
+``CMakeGraphVizOptions.cmake`` the look and content of the generated
+graphs can be influenced. This file is searched first in
+:variable:`CMAKE_BINARY_DIR` and then in :variable:`CMAKE_SOURCE_DIR`. If found, it is
+read and the variables set in it are used to adjust options for the
+generated graphviz files.
+
+.. variable:: GRAPHVIZ_GRAPH_TYPE
+
+ The graph type.
+
+ * Mandatory : NO
+ * Default : "digraph"
+
+ Valid graph types are:
+
+ * "graph" : Nodes are joined with lines
+ * "digraph" : Nodes are joined with arrows showing direction
+ * "strict graph" : Like "graph" but max one line between each node
+ * "strict digraph" : Like "graph" but max one line between each node in each direction
+
+.. variable:: GRAPHVIZ_GRAPH_NAME
+
+ The graph name.
+
+ * Mandatory : NO
+ * Default : "GG"
+
+.. variable:: GRAPHVIZ_GRAPH_HEADER
+
+ The header written at the top of the graphviz file.
+
+ * Mandatory : NO
+ * Default : "node [n fontsize = "12"];"
+
+.. variable:: GRAPHVIZ_NODE_PREFIX
+
+ The prefix for each node in the graphviz file.
+
+ * Mandatory : NO
+ * Default : "node"
+
+.. variable:: GRAPHVIZ_EXECUTABLES
+
+ Set this to FALSE to exclude executables from the generated graphs.
+
+ * Mandatory : NO
+ * Default : TRUE
+
+.. variable:: GRAPHVIZ_STATIC_LIBS
+
+ Set this to FALSE to exclude static libraries from the generated graphs.
+
+ * Mandatory : NO
+ * Default : TRUE
+
+.. variable:: GRAPHVIZ_SHARED_LIBS
+
+ Set this to FALSE to exclude shared libraries from the generated graphs.
+
+ * Mandatory : NO
+ * Default : TRUE
+
+.. variable:: GRAPHVIZ_MODULE_LIBS
+
+ Set this to FALSE to exclude module libraries from the generated graphs.
+
+ * Mandatory : NO
+ * Default : TRUE
+
+.. variable:: GRAPHVIZ_EXTERNAL_LIBS
+
+ Set this to FALSE to exclude external libraries from the generated graphs.
+
+ * Mandatory : NO
+ * Default : TRUE
+
+.. variable:: GRAPHVIZ_IGNORE_TARGETS
+
+ A list of regular expressions for ignoring targets.
+
+ * Mandatory : NO
+ * Default : empty
+
+.. variable:: GRAPHVIZ_GENERATE_PER_TARGET
+
+ Set this to FALSE to exclude per target graphs ``foo.dot.<target>``.
+
+ * Mandatory : NO
+ * Default : TRUE
+
+.. variable:: GRAPHVIZ_GENERATE_DEPENDERS
+
+ Set this to FALSE to exclude depender graphs ``foo.dot.<target>.dependers``.
+
+ * Mandatory : NO
+ * Default : TRUE
+#]=======================================================================]
diff --git a/Modules/CMakeIOSInstallCombined.cmake b/Modules/CMakeIOSInstallCombined.cmake
index fad2e8f69..418bafd63 100644
--- a/Modules/CMakeIOSInstallCombined.cmake
+++ b/Modules/CMakeIOSInstallCombined.cmake
@@ -1,6 +1,8 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
# Function to print messages of this module
function(_ios_install_combined_message)
@@ -57,6 +59,7 @@ endfunction()
# Get architectures of given SDK (iphonesimulator/iphoneos)
function(_ios_install_combined_get_valid_archs sdk resultvar)
+ cmake_policy(PUSH)
cmake_policy(SET CMP0007 NEW)
if("${resultvar}" STREQUAL "")
@@ -73,6 +76,8 @@ function(_ios_install_combined_get_valid_archs sdk resultvar)
_ios_install_combined_message("Architectures (${sdk}): ${printable}")
set("${resultvar}" "${valid_archs}" PARENT_SCOPE)
+
+ cmake_policy(POP)
endfunction()
# Final target can contain more architectures that specified by SDK. This
@@ -161,8 +166,6 @@ function(_ios_install_combined_keep_archs lib archs)
endfunction()
function(_ios_install_combined_detect_sdks this_sdk_var corr_sdk_var)
- cmake_policy(SET CMP0057 NEW)
-
set(this_sdk "$ENV{PLATFORM_NAME}")
if("${this_sdk}" STREQUAL "")
message(FATAL_ERROR "Environment variable PLATFORM_NAME is empty")
@@ -305,3 +308,5 @@ function(ios_install_combined target destination)
_ios_install_combined_message("Install done: ${destination}")
endfunction()
+
+cmake_policy(POP)
diff --git a/Modules/CMakeInitializeConfigs.cmake b/Modules/CMakeInitializeConfigs.cmake
new file mode 100644
index 000000000..9dfe04086
--- /dev/null
+++ b/Modules/CMakeInitializeConfigs.cmake
@@ -0,0 +1,39 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+include_guard(GLOBAL)
+
+# Initializes `<_PREFIX>_<CONFIG>` variables from the corresponding
+# `<_PREFIX>_<CONFIG>_INIT`, for the configurations currently used.
+function(cmake_initialize_per_config_variable _PREFIX _DOCSTRING)
+ string(STRIP "${${_PREFIX}_INIT}" _INIT)
+ set("${_PREFIX}" "${_INIT}"
+ CACHE STRING "${_DOCSTRING} during all build types.")
+ mark_as_advanced("${_PREFIX}")
+
+ if (NOT CMAKE_NOT_USING_CONFIG_FLAGS)
+ set(_CONFIGS Debug Release MinSizeRel RelWithDebInfo)
+
+ get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if (_GENERATOR_IS_MULTI_CONFIG)
+ list(APPEND _CONFIGS ${CMAKE_CONFIGURATION_TYPES})
+ else()
+ if (NOT CMAKE_NO_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE_INIT}" CACHE STRING
+ "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ...")
+ endif()
+ list(APPEND _CONFIGS ${CMAKE_BUILD_TYPE})
+ endif()
+
+ list(REMOVE_DUPLICATES _CONFIGS)
+ foreach(_BUILD_TYPE IN LISTS _CONFIGS)
+ if (NOT "${_BUILD_TYPE}" STREQUAL "")
+ string(TOUPPER "${_BUILD_TYPE}" _BUILD_TYPE)
+ string(STRIP "${${_PREFIX}_${_BUILD_TYPE}_INIT}" _INIT)
+ set("${_PREFIX}_${_BUILD_TYPE}" "${_INIT}"
+ CACHE STRING "${_DOCSTRING} during ${_BUILD_TYPE} builds.")
+ mark_as_advanced("${_PREFIX}_${_BUILD_TYPE}")
+ endif()
+ endforeach()
+ endif()
+endfunction()
diff --git a/Modules/CMakeJavaInformation.cmake b/Modules/CMakeJavaInformation.cmake
index 844bbbbbf..989afc11b 100644
--- a/Modules/CMakeJavaInformation.cmake
+++ b/Modules/CMakeJavaInformation.cmake
@@ -16,8 +16,8 @@ endif()
if(CMAKE_USER_MAKE_RULES_OVERRIDE_Java)
# Save the full path of the file so try_compile can use it.
- include(${CMAKE_USER_MAKE_RULES_OVERRIDE_Java} RESULT_VARIABLE _override)
- set(CMAKE_USER_MAKE_RULES_OVERRIDE_Java "${_override}")
+ include(${CMAKE_USER_MAKE_RULES_OVERRIDE_Java} RESULT_VARIABLE _override)
+ set(CMAKE_USER_MAKE_RULES_OVERRIDE_Java "${_override}")
endif()
# this is a place holder if java needed flags for javac they would go here.
@@ -30,7 +30,7 @@ if(NOT CMAKE_Java_CREATE_STATIC_LIBRARY)
set(CMAKE_Java_CREATE_STATIC_LIBRARY
"<CMAKE_Java_ARCHIVE> -cf <TARGET> -C <OBJECT_DIR> ${class_files_mask}")
- # "${class_files_mask}" should really be "<OBJECTS>" but compling a *.java
+ # "${class_files_mask}" should really be "<OBJECTS>" but compiling a *.java
# file can create more than one *.class file...
endif()
diff --git a/Modules/CMakeLanguageInformation.cmake b/Modules/CMakeLanguageInformation.cmake
index 18c8624fa..674ab8696 100644
--- a/Modules/CMakeLanguageInformation.cmake
+++ b/Modules/CMakeLanguageInformation.cmake
@@ -9,10 +9,10 @@
macro(__cmake_include_compiler_wrapper lang)
set(_INCLUDED_WRAPPER_FILE 0)
if (CMAKE_${lang}_COMPILER_ID)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_${lang}_COMPILER_WRAPPER}-${CMAKE_${lang}_COMPILER_ID}-${lang} OPTIONAL RESULT_VARIABLE _INCLUDED_WRAPPER_FILE)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_${lang}_COMPILER_WRAPPER}-${CMAKE_${lang}_COMPILER_ID}-${lang} OPTIONAL RESULT_VARIABLE _INCLUDED_WRAPPER_FILE)
endif()
if (NOT _INCLUDED_WRAPPER_FILE)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_${lang}_COMPILER_WRAPPER}-${lang} OPTIONAL RESULT_VARIABLE _INCLUDED_WRAPPER_FILE)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_${lang}_COMPILER_WRAPPER}-${lang} OPTIONAL RESULT_VARIABLE _INCLUDED_WRAPPER_FILE)
endif ()
# No platform - wrapper - lang information so maybe there's just wrapper - lang information
diff --git a/Modules/CMakeNinjaFindMake.cmake b/Modules/CMakeNinjaFindMake.cmake
index 6a0c47eec..702af1338 100644
--- a/Modules/CMakeNinjaFindMake.cmake
+++ b/Modules/CMakeNinjaFindMake.cmake
@@ -3,6 +3,6 @@
find_program(CMAKE_MAKE_PROGRAM
- NAMES ninja-build ninja
+ NAMES ninja-build ninja samu
DOC "Program used to build from build.ninja files.")
mark_as_advanced(CMAKE_MAKE_PROGRAM)
diff --git a/Modules/CMakeOBJCCompiler.cmake.in b/Modules/CMakeOBJCCompiler.cmake.in
new file mode 100644
index 000000000..155551789
--- /dev/null
+++ b/Modules/CMakeOBJCCompiler.cmake.in
@@ -0,0 +1,69 @@
+set(CMAKE_OBJC_COMPILER "@CMAKE_OBJC_COMPILER@")
+set(CMAKE_OBJC_COMPILER_ARG1 "@CMAKE_OBJC_COMPILER_ARG1@")
+set(CMAKE_OBJC_COMPILER_ID "@CMAKE_OBJC_COMPILER_ID@")
+set(CMAKE_OBJC_COMPILER_VERSION "@CMAKE_OBJC_COMPILER_VERSION@")
+set(CMAKE_OBJC_COMPILER_VERSION_INTERNAL "@CMAKE_OBJC_COMPILER_VERSION_INTERNAL@")
+set(CMAKE_OBJC_COMPILER_WRAPPER "@CMAKE_OBJC_COMPILER_WRAPPER@")
+set(CMAKE_OBJC_STANDARD_COMPUTED_DEFAULT "@CMAKE_OBJC_STANDARD_COMPUTED_DEFAULT@")
+set(CMAKE_OBJC_COMPILE_FEATURES "@CMAKE_OBJC_COMPILE_FEATURES@")
+set(CMAKE_OBJC90_COMPILE_FEATURES "@CMAKE_OBJC90_COMPILE_FEATURES@")
+set(CMAKE_OBJC99_COMPILE_FEATURES "@CMAKE_OBJC99_COMPILE_FEATURES@")
+set(CMAKE_OBJC11_COMPILE_FEATURES "@CMAKE_OBJC11_COMPILE_FEATURES@")
+
+set(CMAKE_OBJC_PLATFORM_ID "@CMAKE_OBJC_PLATFORM_ID@")
+set(CMAKE_OBJC_SIMULATE_ID "@CMAKE_OBJC_SIMULATE_ID@")
+set(CMAKE_OBJC_COMPILER_FRONTEND_VARIANT "@CMAKE_OBJC_COMPILER_FRONTEND_VARIANT@")
+set(CMAKE_OBJC_SIMULATE_VERSION "@CMAKE_OBJC_SIMULATE_VERSION@")
+@_SET_CMAKE_OBJC_COMPILER_ARCHITECTURE_ID@
+@SET_CMAKE_XCODE_ARCHS@
+set(CMAKE_AR "@CMAKE_AR@")
+set(CMAKE_OBJC_COMPILER_AR "@CMAKE_OBJC_COMPILER_AR@")
+set(CMAKE_RANLIB "@CMAKE_RANLIB@")
+set(CMAKE_OBJC_COMPILER_RANLIB "@CMAKE_OBJC_COMPILER_RANLIB@")
+set(CMAKE_LINKER "@CMAKE_LINKER@")
+set(CMAKE_MT "@CMAKE_MT@")
+set(CMAKE_COMPILER_IS_GNUOBJC @CMAKE_COMPILER_IS_GNUOBJC@)
+set(CMAKE_OBJC_COMPILER_LOADED 1)
+set(CMAKE_OBJC_COMPILER_WORKS @CMAKE_OBJC_COMPILER_WORKS@)
+set(CMAKE_OBJC_ABI_COMPILED @CMAKE_OBJC_ABI_COMPILED@)
+
+set(CMAKE_OBJC_COMPILER_ENV_VAR "OBJC")
+
+set(CMAKE_OBJC_COMPILER_ID_RUN 1)
+set(CMAKE_OBJC_SOURCE_FILE_EXTENSIONS m)
+set(CMAKE_OBJC_IGNORE_EXTENSIONS h;H;o;O)
+set(CMAKE_OBJC_LINKER_PREFERENCE 5)
+
+foreach (lang C CXX OBJCXX)
+ foreach(extension IN LISTS CMAKE_OBJC_SOURCE_FILE_EXTENSIONS)
+ if (CMAKE_${lang}_COMPILER_ID_RUN)
+ list(REMOVE_ITEM CMAKE_${lang}_SOURCE_FILE_EXTENSIONS ${extension})
+ endif()
+ endforeach()
+endforeach()
+
+# Save compiler ABI information.
+set(CMAKE_OBJC_SIZEOF_DATA_PTR "@CMAKE_OBJC_SIZEOF_DATA_PTR@")
+set(CMAKE_OBJC_COMPILER_ABI "@CMAKE_OBJC_COMPILER_ABI@")
+set(CMAKE_OBJC_LIBRARY_ARCHITECTURE "@CMAKE_OBJC_LIBRARY_ARCHITECTURE@")
+
+if(CMAKE_OBJC_SIZEOF_DATA_PTR)
+ set(CMAKE_SIZEOF_VOID_P "${CMAKE_OBJC_SIZEOF_DATA_PTR}")
+endif()
+
+if(CMAKE_OBJC_COMPILER_ABI)
+ set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_OBJC_COMPILER_ABI}")
+endif()
+
+if(CMAKE_OBJC_LIBRARY_ARCHITECTURE)
+ set(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_OBJC_LIBRARY_ARCHITECTURE@")
+endif()
+
+@CMAKE_OBJC_COMPILER_CUSTOM_CODE@
+@CMAKE_OBJC_SYSROOT_FLAG_CODE@
+@CMAKE_OBJC_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
+
+set(CMAKE_OBJC_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_OBJC_IMPLICIT_INCLUDE_DIRECTORIES@")
+set(CMAKE_OBJC_IMPLICIT_LINK_LIBRARIES "@CMAKE_OBJC_IMPLICIT_LINK_LIBRARIES@")
+set(CMAKE_OBJC_IMPLICIT_LINK_DIRECTORIES "@CMAKE_OBJC_IMPLICIT_LINK_DIRECTORIES@")
+set(CMAKE_OBJC_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_OBJC_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
diff --git a/Modules/CMakeOBJCCompilerABI.m b/Modules/CMakeOBJCCompilerABI.m
new file mode 100644
index 000000000..8fa85117c
--- /dev/null
+++ b/Modules/CMakeOBJCCompilerABI.m
@@ -0,0 +1,20 @@
+#ifdef __cplusplus
+# error "A C++ compiler has been selected for Objective-C."
+#endif
+
+/*--------------------------------------------------------------------------*/
+
+#include "CMakeCompilerABI.h"
+
+/*--------------------------------------------------------------------------*/
+
+int main(int argc, char *argv[])
+{
+ int require = 0;
+ require += info_sizeof_dptr[argc];
+#if defined(ABI_ID)
+ require += info_abi[argc];
+#endif
+ (void)argv;
+ return require;
+}
diff --git a/Modules/CMakeOBJCCompilerId.m.in b/Modules/CMakeOBJCCompilerId.m.in
new file mode 100644
index 000000000..2b8aa3020
--- /dev/null
+++ b/Modules/CMakeOBJCCompilerId.m.in
@@ -0,0 +1,63 @@
+#ifdef __cplusplus
+# error "An Objective-C++ compiler has been selected for Objective-C."
+#endif
+
+@CMAKE_OBJC_COMPILER_ID_CONTENT@
+
+/* Construct the string literal in pieces to prevent the source from
+ getting matched. Store it in a pointer rather than an array
+ because some compilers will just produce instructions to fill the
+ array rather than assigning a pointer to a static array. */
+char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
+#ifdef SIMULATE_ID
+char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
+#endif
+
+#ifdef __QNXNTO__
+char const* qnxnto = "INFO" ":" "qnxnto[]";
+#endif
+
+@CMAKE_OBJC_COMPILER_ID_PLATFORM_CONTENT@
+@CMAKE_OBJC_COMPILER_ID_ERROR_FOR_TEST@
+
+#if !defined(__STDC__)
+# if (defined(_MSC_VER) && !defined(__clang__)) \
+ || (defined(__ibmxl__) || defined(__IBMC__))
+# define C_DIALECT "90"
+# else
+# define C_DIALECT
+# endif
+#elif __STDC_VERSION__ >= 201000L
+# define C_DIALECT "11"
+#elif __STDC_VERSION__ >= 199901L
+# define C_DIALECT "99"
+#else
+# define C_DIALECT "90"
+#endif
+const char* info_language_dialect_default =
+ "INFO" ":" "dialect_default[" C_DIALECT "]";
+
+/*--------------------------------------------------------------------------*/
+
+int main(int argc, char* argv[])
+{
+ int require = 0;
+ require += info_compiler[argc];
+ require += info_platform[argc];
+ require += info_arch[argc];
+#ifdef COMPILER_VERSION_MAJOR
+ require += info_version[argc];
+#endif
+#ifdef COMPILER_VERSION_INTERNAL
+ require += info_version_internal[argc];
+#endif
+#ifdef SIMULATE_ID
+ require += info_simulate[argc];
+#endif
+#ifdef SIMULATE_VERSION_MAJOR
+ require += info_simulate_version[argc];
+#endif
+ require += info_language_dialect_default[argc];
+ (void)argv;
+ return require;
+}
diff --git a/Modules/CMakeOBJCInformation.cmake b/Modules/CMakeOBJCInformation.cmake
new file mode 100644
index 000000000..cb61cb880
--- /dev/null
+++ b/Modules/CMakeOBJCInformation.cmake
@@ -0,0 +1,188 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+# This file sets the basic flags for the Objective-C language in CMake.
+# It also loads the available platform file for the system-compiler
+# if it exists.
+# It also loads a system - compiler - processor (or target hardware)
+# specific file, which is mainly useful for crosscompiling and embedded systems.
+
+include(CMakeLanguageInformation)
+
+# some compilers use different extensions (e.g. sdcc uses .rel)
+# so set the extension here first so it can be overridden by the compiler specific file
+set(CMAKE_OBJC_OUTPUT_EXTENSION .o)
+
+if(NOT CMAKE_INCLUDE_FLAG_OBJC)
+ set(CMAKE_INCLUDE_FLAG_OBJC ${CMAKE_INCLUDE_FLAG_C})
+endif()
+
+set(_INCLUDED_FILE 0)
+
+# Load compiler-specific information.
+if(CMAKE_OBJC_COMPILER_ID)
+ include(Compiler/${CMAKE_OBJC_COMPILER_ID}-OBJC OPTIONAL)
+endif()
+
+set(CMAKE_BASE_NAME)
+get_filename_component(CMAKE_BASE_NAME "${CMAKE_OBJC_COMPILER}" NAME_WE)
+if(CMAKE_COMPILER_IS_GNUOBJC)
+ set(CMAKE_BASE_NAME gcc)
+endif()
+
+
+# load a hardware specific file, mostly useful for embedded compilers
+if(CMAKE_SYSTEM_PROCESSOR)
+ if(CMAKE_OBJC_COMPILER_ID)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_OBJC_COMPILER_ID}-OBJC-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
+ endif()
+ if (NOT _INCLUDED_FILE)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
+ endif ()
+endif()
+
+
+# load the system- and compiler specific files
+if(CMAKE_OBJC_COMPILER_ID)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_OBJC_COMPILER_ID}-OBJC
+ OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
+endif()
+if (NOT _INCLUDED_FILE)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME}
+ OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
+endif ()
+
+# load any compiler-wrapper specific information
+if (CMAKE_OBJC_COMPILER_WRAPPER)
+ __cmake_include_compiler_wrapper(OBJC)
+endif ()
+
+# We specify the compiler information in the system file for some
+# platforms, but this language may not have been enabled when the file
+# was first included. Include it again to get the language info.
+# Remove this when all compiler info is removed from system files.
+if (NOT _INCLUDED_FILE)
+ include(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL)
+endif ()
+
+if(CMAKE_OBJC_SIZEOF_DATA_PTR)
+ foreach(f ${CMAKE_OBJC_ABI_FILES})
+ include(${f})
+ endforeach()
+ unset(CMAKE_OBJC_ABI_FILES)
+endif()
+
+# This should be included before the _INIT variables are
+# used to initialize the cache. Since the rule variables
+# have if blocks on them, users can still define them here.
+# But, it should still be after the platform file so changes can
+# be made to those values.
+
+if(CMAKE_USER_MAKE_RULES_OVERRIDE)
+ # Save the full path of the file so try_compile can use it.
+ include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override)
+ set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}")
+endif()
+
+if(CMAKE_USER_MAKE_RULES_OVERRIDE_OBJC)
+ # Save the full path of the file so try_compile can use it.
+ include(${CMAKE_USER_MAKE_RULES_OVERRIDE_OBJC} RESULT_VARIABLE _override)
+ set(CMAKE_USER_MAKE_RULES_OVERRIDE_OBJC "${_override}")
+endif()
+
+
+# for most systems a module is the same as a shared library
+# so unless the variable CMAKE_MODULE_EXISTS is set just
+# copy the values from the LIBRARY variables
+if(NOT CMAKE_MODULE_EXISTS)
+ set(CMAKE_SHARED_MODULE_OBJC_FLAGS ${CMAKE_SHARED_LIBRARY_OBJC_FLAGS})
+ set(CMAKE_SHARED_MODULE_CREATE_OBJC_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_OBJC_FLAGS})
+endif()
+
+set(CMAKE_OBJC_FLAGS_INIT "$ENV{OBJCFLAGS} ${CMAKE_OBJC_FLAGS_INIT}")
+
+cmake_initialize_per_config_variable(CMAKE_OBJC_FLAGS "Flags used by the Objective-C compiler")
+
+if(CMAKE_OBJC_STANDARD_LIBRARIES_INIT)
+ set(CMAKE_OBJC_STANDARD_LIBRARIES "${CMAKE_OBJC_STANDARD_LIBRARIES_INIT}"
+ CACHE STRING "Libraries linked by default with all Objective-C applications.")
+ mark_as_advanced(CMAKE_OBJC_STANDARD_LIBRARIES)
+endif()
+
+include(CMakeCommonLanguageInclude)
+
+# now define the following rule variables
+
+# CMAKE_OBJC_CREATE_SHARED_LIBRARY
+# CMAKE_OBJC_CREATE_SHARED_MODULE
+# CMAKE_OBJC_COMPILE_OBJECT
+# CMAKE_OBJC_LINK_EXECUTABLE
+
+# variables supplied by the generator at use time
+# <TARGET>
+# <TARGET_BASE> the target without the suffix
+# <OBJECTS>
+# <OBJECT>
+# <LINK_LIBRARIES>
+# <FLAGS>
+# <LINK_FLAGS>
+
+# Objective-C compiler information
+# <CMAKE_OBJC_COMPILER>
+# <CMAKE_SHARED_LIBRARY_CREATE_OBJC_FLAGS>
+# <CMAKE_SHARED_MODULE_CREATE_OBJC_FLAGS>
+# <CMAKE_OBJC_LINK_FLAGS>
+
+# Static library tools
+# <CMAKE_AR>
+# <CMAKE_RANLIB>
+
+
+# create an Objective-C shared library
+if(NOT CMAKE_OBJC_CREATE_SHARED_LIBRARY)
+ set(CMAKE_OBJC_CREATE_SHARED_LIBRARY
+ "<CMAKE_OBJC_COMPILER> <CMAKE_SHARED_LIBRARY_OBJC_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_OBJC_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
+endif()
+
+# create an Objective-C shared module just copy the shared library rule
+if(NOT CMAKE_OBJC_CREATE_SHARED_MODULE)
+ set(CMAKE_OBJC_CREATE_SHARED_MODULE ${CMAKE_OBJC_CREATE_SHARED_LIBRARY})
+endif()
+
+# Create an static archive incrementally for large object file counts.
+# If CMAKE_OBJC_CREATE_STATIC_LIBRARY is set it will override these.
+if(NOT DEFINED CMAKE_OBJC_ARCHIVE_CREATE)
+ set(CMAKE_OBJC_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>")
+endif()
+if(NOT DEFINED CMAKE_OBJC_ARCHIVE_APPEND)
+ set(CMAKE_OBJC_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
+endif()
+if(NOT DEFINED CMAKE_OBJC_ARCHIVE_FINISH)
+ set(CMAKE_OBJC_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
+endif()
+
+# compile an Objective-C file into an object file
+if(NOT CMAKE_OBJC_COMPILE_OBJECT)
+ set(CMAKE_OBJC_COMPILE_OBJECT
+ "<CMAKE_OBJC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -x objective-c -o <OBJECT> -c <SOURCE>")
+endif()
+
+if(NOT CMAKE_OBJC_LINK_EXECUTABLE)
+ set(CMAKE_OBJC_LINK_EXECUTABLE
+ "<CMAKE_OBJC_COMPILER> <FLAGS> <CMAKE_OBJC_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
+endif()
+
+if(NOT CMAKE_EXECUTABLE_RUNTIME_OBJC_FLAG)
+ set(CMAKE_EXECUTABLE_RUNTIME_OBJC_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_OBJC_FLAG})
+endif()
+
+if(NOT CMAKE_EXECUTABLE_RUNTIME_OBJC_FLAG_SEP)
+ set(CMAKE_EXECUTABLE_RUNTIME_OBJC_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_OBJC_FLAG_SEP})
+endif()
+
+if(NOT CMAKE_EXECUTABLE_RPATH_LINK_OBJC_FLAG)
+ set(CMAKE_EXECUTABLE_RPATH_LINK_OBJC_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_OBJC_FLAG})
+endif()
+
+set(CMAKE_OBJC_INFORMATION_LOADED 1)
diff --git a/Modules/CMakeOBJCXXCompiler.cmake.in b/Modules/CMakeOBJCXXCompiler.cmake.in
new file mode 100644
index 000000000..b6452c464
--- /dev/null
+++ b/Modules/CMakeOBJCXXCompiler.cmake.in
@@ -0,0 +1,79 @@
+set(CMAKE_OBJCXX_COMPILER "@CMAKE_OBJCXX_COMPILER@")
+set(CMAKE_OBJCXX_COMPILER_ARG1 "@CMAKE_OBJCXX_COMPILER_ARG1@")
+set(CMAKE_OBJCXX_COMPILER_ID "@CMAKE_OBJCXX_COMPILER_ID@")
+set(CMAKE_OBJCXX_COMPILER_VERSION "@CMAKE_OBJCXX_COMPILER_VERSION@")
+set(CMAKE_OBJCXX_COMPILER_VERSION_INTERNAL "@CMAKE_OBJCXX_COMPILER_VERSION_INTERNAL@")
+set(CMAKE_OBJCXX_COMPILER_WRAPPER "@CMAKE_OBJCXX_COMPILER_WRAPPER@")
+set(CMAKE_OBJCXX_STANDARD_COMPUTED_DEFAULT "@CMAKE_OBJCXX_STANDARD_COMPUTED_DEFAULT@")
+set(CMAKE_OBJCXX_COMPILE_FEATURES "@CMAKE_OBJCXX_COMPILE_FEATURES@")
+set(CMAKE_OBJCXX98_COMPILE_FEATURES "@CMAKE_OBJCXX98_COMPILE_FEATURES@")
+set(CMAKE_OBJCXX11_COMPILE_FEATURES "@CMAKE_OBJCXX11_COMPILE_FEATURES@")
+set(CMAKE_OBJCXX14_COMPILE_FEATURES "@CMAKE_OBJCXX14_COMPILE_FEATURES@")
+set(CMAKE_OBJCXX17_COMPILE_FEATURES "@CMAKE_OBJCXX17_COMPILE_FEATURES@")
+set(CMAKE_OBJCXX20_COMPILE_FEATURES "@CMAKE_OBJCXX20_COMPILE_FEATURES@")
+
+set(CMAKE_OBJCXX_PLATFORM_ID "@CMAKE_OBJCXX_PLATFORM_ID@")
+set(CMAKE_OBJCXX_SIMULATE_ID "@CMAKE_OBJCXX_SIMULATE_ID@")
+set(CMAKE_OBJCXX_COMPILER_FRONTEND_VARIANT "@CMAKE_OBJCXX_COMPILER_FRONTEND_VARIANT@")
+set(CMAKE_OBJCXX_SIMULATE_VERSION "@CMAKE_OBJCXX_SIMULATE_VERSION@")
+@_SET_CMAKE_OBJCXX_COMPILER_ARCHITECTURE_ID@
+@SET_CMAKE_XCODE_ARCHS@
+set(CMAKE_AR "@CMAKE_AR@")
+set(CMAKE_OBJCXX_COMPILER_AR "@CMAKE_OBJCXX_COMPILER_AR@")
+set(CMAKE_RANLIB "@CMAKE_RANLIB@")
+set(CMAKE_OBJCXX_COMPILER_RANLIB "@CMAKE_OBJCXX_COMPILER_RANLIB@")
+set(CMAKE_LINKER "@CMAKE_LINKER@")
+set(CMAKE_MT "@CMAKE_MT@")
+set(CMAKE_COMPILER_IS_GNUOBJCXX @CMAKE_COMPILER_IS_GNUOBJCXX@)
+set(CMAKE_OBJCXX_COMPILER_LOADED 1)
+set(CMAKE_OBJCXX_COMPILER_WORKS @CMAKE_OBJCXX_COMPILER_WORKS@)
+set(CMAKE_OBJCXX_ABI_COMPILED @CMAKE_OBJCXX_ABI_COMPILED@)
+
+set(CMAKE_OBJCXX_COMPILER_ENV_VAR "OBJCXX")
+
+set(CMAKE_OBJCXX_COMPILER_ID_RUN 1)
+set(CMAKE_OBJCXX_SOURCE_FILE_EXTENSIONS M;m;mm)
+set(CMAKE_OBJCXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O)
+
+if (CMAKE_OBJC_COMPILER_ID_RUN)
+ foreach(extension IN LISTS CMAKE_OBJC_SOURCE_FILE_EXTENSIONS)
+ list(REMOVE_ITEM CMAKE_OBJCXX_SOURCE_FILE_EXTENSIONS ${extension})
+ endforeach()
+endif()
+
+foreach (lang C CXX OBJC)
+ foreach(extension IN LISTS CMAKE_OBJCXX_SOURCE_FILE_EXTENSIONS)
+ if (CMAKE_${lang}_COMPILER_ID_RUN)
+ list(REMOVE_ITEM CMAKE_${lang}_SOURCE_FILE_EXTENSIONS ${extension})
+ endif()
+ endforeach()
+endforeach()
+
+set(CMAKE_OBJCXX_LINKER_PREFERENCE 25)
+set(CMAKE_OBJCXX_LINKER_PREFERENCE_PROPAGATES 1)
+
+# Save compiler ABI information.
+set(CMAKE_OBJCXX_SIZEOF_DATA_PTR "@CMAKE_OBJCXX_SIZEOF_DATA_PTR@")
+set(CMAKE_OBJCXX_COMPILER_ABI "@CMAKE_OBJCXX_COMPILER_ABI@")
+set(CMAKE_OBJCXX_LIBRARY_ARCHITECTURE "@CMAKE_OBJCXX_LIBRARY_ARCHITECTURE@")
+
+if(CMAKE_OBJCXX_SIZEOF_DATA_PTR)
+ set(CMAKE_SIZEOF_VOID_P "${CMAKE_OBJCXX_SIZEOF_DATA_PTR}")
+endif()
+
+if(CMAKE_OBJCXX_COMPILER_ABI)
+ set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_OBJCXX_COMPILER_ABI}")
+endif()
+
+if(CMAKE_OBJCXX_LIBRARY_ARCHITECTURE)
+ set(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_OBJCXX_LIBRARY_ARCHITECTURE@")
+endif()
+
+@CMAKE_OBJCXX_COMPILER_CUSTOM_CODE@
+@CMAKE_OBJCXX_SYSROOT_FLAG_CODE@
+@CMAKE_OBJCXX_OSX_DEPLOYMENT_TARGET_FLAG_CODE@
+
+set(CMAKE_OBJCXX_IMPLICIT_INCLUDE_DIRECTORIES "@CMAKE_OBJCXX_IMPLICIT_INCLUDE_DIRECTORIES@")
+set(CMAKE_OBJCXX_IMPLICIT_LINK_LIBRARIES "@CMAKE_OBJCXX_IMPLICIT_LINK_LIBRARIES@")
+set(CMAKE_OBJCXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_OBJCXX_IMPLICIT_LINK_DIRECTORIES@")
+set(CMAKE_OBJCXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_OBJCXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
diff --git a/Modules/CMakeOBJCXXCompilerABI.mm b/Modules/CMakeOBJCXXCompilerABI.mm
new file mode 100644
index 000000000..288a58c8d
--- /dev/null
+++ b/Modules/CMakeOBJCXXCompilerABI.mm
@@ -0,0 +1,20 @@
+#ifndef __cplusplus
+# error "A C compiler has been selected for Objective-C++."
+#endif
+
+/*--------------------------------------------------------------------------*/
+
+#include "CMakeCompilerABI.h"
+
+/*--------------------------------------------------------------------------*/
+
+int main(int argc, char *argv[])
+{
+ int require = 0;
+ require += info_sizeof_dptr[argc];
+#if defined(ABI_ID)
+ require += info_abi[argc];
+#endif
+ (void)argv;
+ return require;
+}
diff --git a/Modules/CMakeOBJCXXCompilerId.mm.in b/Modules/CMakeOBJCXXCompilerId.mm.in
new file mode 100644
index 000000000..fe04de1c6
--- /dev/null
+++ b/Modules/CMakeOBJCXXCompilerId.mm.in
@@ -0,0 +1,68 @@
+/* This source file must have a .cpp extension so that all C++ compilers
+ recognize the extension without flags. Borland does not know .cxx for
+ example. */
+#ifndef __cplusplus
+# error "An Objective-C compiler has been selected for Objective-C++."
+#endif
+
+@CMAKE_OBJCXX_COMPILER_ID_CONTENT@
+
+/* Construct the string literal in pieces to prevent the source from
+ getting matched. Store it in a pointer rather than an array
+ because some compilers will just produce instructions to fill the
+ array rather than assigning a pointer to a static array. */
+char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
+#ifdef SIMULATE_ID
+char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
+#endif
+
+#ifdef __QNXNTO__
+char const* qnxnto = "INFO" ":" "qnxnto[]";
+#endif
+
+@CMAKE_OBJCXX_COMPILER_ID_PLATFORM_CONTENT@
+@CMAKE_OBJCXX_COMPILER_ID_ERROR_FOR_TEST@
+
+#if defined(_MSC_VER) && defined(_MSVC_LANG)
+#define CXX_STD _MSVC_LANG
+#else
+#define CXX_STD __cplusplus
+#endif
+
+const char* info_language_dialect_default = "INFO" ":" "dialect_default["
+#if CXX_STD > 201703L
+ "20"
+#elif CXX_STD >= 201703L
+ "17"
+#elif CXX_STD >= 201402L
+ "14"
+#elif CXX_STD >= 201103L
+ "11"
+#else
+ "98"
+#endif
+"]";
+
+/*--------------------------------------------------------------------------*/
+
+int main(int argc, char* argv[])
+{
+ int require = 0;
+ require += info_compiler[argc];
+ require += info_platform[argc];
+#ifdef COMPILER_VERSION_MAJOR
+ require += info_version[argc];
+#endif
+#ifdef COMPILER_VERSION_INTERNAL
+ require += info_version_internal[argc];
+#endif
+#ifdef SIMULATE_ID
+ require += info_simulate[argc];
+#endif
+#ifdef SIMULATE_VERSION_MAJOR
+ require += info_simulate_version[argc];
+#endif
+ require += info_language_dialect_default[argc];
+ (void)argv;
+ return require;
+}
diff --git a/Modules/CMakeOBJCXXInformation.cmake b/Modules/CMakeOBJCXXInformation.cmake
new file mode 100644
index 000000000..71ac26ab2
--- /dev/null
+++ b/Modules/CMakeOBJCXXInformation.cmake
@@ -0,0 +1,273 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+# This file sets the basic flags for the Objective-C++ language in CMake.
+# It also loads the available platform file for the system-compiler
+# if it exists.
+# It also loads a system - compiler - processor (or target hardware)
+# specific file, which is mainly useful for crosscompiling and embedded systems.
+
+include(CMakeLanguageInformation)
+
+# some compilers use different extensions (e.g. sdcc uses .rel)
+# so set the extension here first so it can be overridden by the compiler specific file
+set(CMAKE_OBJCXX_OUTPUT_EXTENSION .o)
+
+set(_INCLUDED_FILE 0)
+
+# Load compiler-specific information.
+if(CMAKE_OBJCXX_COMPILER_ID)
+ include(Compiler/${CMAKE_OBJCXX_COMPILER_ID}-OBJCXX OPTIONAL)
+endif()
+
+set(CMAKE_BASE_NAME)
+get_filename_component(CMAKE_BASE_NAME "${CMAKE_OBJCXX_COMPILER}" NAME_WE)
+# since the gnu compiler has several names force g++
+if(CMAKE_COMPILER_IS_GNUOBJCXX)
+ set(CMAKE_BASE_NAME g++)
+endif()
+
+
+# load a hardware specific file, mostly useful for embedded compilers
+if(CMAKE_SYSTEM_PROCESSOR)
+ if(CMAKE_OBJCXX_COMPILER_ID)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_OBJCXX_COMPILER_ID}-OBJCXX-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
+ endif()
+ if (NOT _INCLUDED_FILE)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
+ endif ()
+endif()
+
+# load the system- and compiler specific files
+if(CMAKE_OBJCXX_COMPILER_ID)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_OBJCXX_COMPILER_ID}-OBJCXX OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
+endif()
+if (NOT _INCLUDED_FILE)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL
+ RESULT_VARIABLE _INCLUDED_FILE)
+endif ()
+
+# load any compiler-wrapper specific information
+if (CMAKE_OBJCXX_COMPILER_WRAPPER)
+ __cmake_include_compiler_wrapper(OBJCXX)
+endif ()
+
+# We specify the compiler information in the system file for some
+# platforms, but this language may not have been enabled when the file
+# was first included. Include it again to get the language info.
+# Remove this when all compiler info is removed from system files.
+if (NOT _INCLUDED_FILE)
+ include(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL)
+endif ()
+
+if(CMAKE_OBJCXX_SIZEOF_DATA_PTR)
+ foreach(f ${CMAKE_OBJCXX_ABI_FILES})
+ include(${f})
+ endforeach()
+ unset(CMAKE_OBJCXX_ABI_FILES)
+endif()
+
+# This should be included before the _INIT variables are
+# used to initialize the cache. Since the rule variables
+# have if blocks on them, users can still define them here.
+# But, it should still be after the platform file so changes can
+# be made to those values.
+
+if(CMAKE_USER_MAKE_RULES_OVERRIDE)
+ # Save the full path of the file so try_compile can use it.
+ include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override)
+ set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}")
+endif()
+
+if(CMAKE_USER_MAKE_RULES_OVERRIDE_OBJCXX)
+ # Save the full path of the file so try_compile can use it.
+ include(${CMAKE_USER_MAKE_RULES_OVERRIDE_OBJCXX} RESULT_VARIABLE _override)
+ set(CMAKE_USER_MAKE_RULES_OVERRIDE_OBJCXX "${_override}")
+endif()
+
+
+# Create a set of shared library variable specific to Objective-C++
+# For 90% of the systems, these are the same flags as the Objective-C versions
+# so if these are not set just copy the flags from the Objective-C version
+if(NOT CMAKE_SHARED_LIBRARY_CREATE_OBJCXX_FLAGS)
+ set(CMAKE_SHARED_LIBRARY_CREATE_OBJCXX_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_OBJC_FLAGS})
+endif()
+
+if(NOT CMAKE_OBJCXX_COMPILE_OPTIONS_PIC)
+ set(CMAKE_OBJCXX_COMPILE_OPTIONS_PIC ${CMAKE_OBJC_COMPILE_OPTIONS_PIC})
+endif()
+
+if(NOT CMAKE_OBJCXX_COMPILE_OPTIONS_PIE)
+ set(CMAKE_OBJCXX_COMPILE_OPTIONS_PIE ${CMAKE_OBJC_COMPILE_OPTIONS_PIE})
+endif()
+if(NOT CMAKE_OBJCXX_LINK_OPTIONS_PIE)
+ set(CMAKE_OBJCXX_LINK_OPTIONS_PIE ${CMAKE_OBJC_LINK_OPTIONS_PIE})
+endif()
+if(NOT CMAKE_OBJCXX_LINK_OPTIONS_NO_PIE)
+ set(CMAKE_OBJCXX_LINK_OPTIONS_NO_PIE ${CMAKE_OBJC_LINK_OPTIONS_NO_PIE})
+endif()
+
+if(NOT CMAKE_OBJCXX_COMPILE_OPTIONS_DLL)
+ set(CMAKE_OBJCXX_COMPILE_OPTIONS_DLL ${CMAKE_OBJC_COMPILE_OPTIONS_DLL})
+endif()
+
+if(NOT CMAKE_SHARED_LIBRARY_OBJCXX_FLAGS)
+ set(CMAKE_SHARED_LIBRARY_OBJCXX_FLAGS ${CMAKE_SHARED_LIBRARY_OBJC_FLAGS})
+endif()
+
+if(NOT DEFINED CMAKE_SHARED_LIBRARY_LINK_OBJCXX_FLAGS)
+ set(CMAKE_SHARED_LIBRARY_LINK_OBJCXX_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_OBJC_FLAGS})
+endif()
+
+if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_OBJCXX_FLAG)
+ set(CMAKE_SHARED_LIBRARY_RUNTIME_OBJCXX_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_OBJC_FLAG})
+endif()
+
+if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_OBJCXX_FLAG_SEP)
+ set(CMAKE_SHARED_LIBRARY_RUNTIME_OBJCXX_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_OBJC_FLAG_SEP})
+endif()
+
+if(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_OBJCXX_FLAG)
+ set(CMAKE_SHARED_LIBRARY_RPATH_LINK_OBJCXX_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_OBJC_FLAG})
+endif()
+
+if(NOT DEFINED CMAKE_EXE_EXPORTS_OBJCXX_FLAG)
+ set(CMAKE_EXE_EXPORTS_OBJCXX_FLAG ${CMAKE_EXE_EXPORTS_OBJC_FLAG})
+endif()
+
+if(NOT DEFINED CMAKE_SHARED_LIBRARY_SONAME_OBJCXX_FLAG)
+ set(CMAKE_SHARED_LIBRARY_SONAME_OBJCXX_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_OBJC_FLAG})
+endif()
+
+if(NOT CMAKE_EXECUTABLE_RUNTIME_OBJCXX_FLAG)
+ set(CMAKE_EXECUTABLE_RUNTIME_OBJCXX_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_OBJCXX_FLAG})
+endif()
+
+if(NOT CMAKE_EXECUTABLE_RUNTIME_OBJCXX_FLAG_SEP)
+ set(CMAKE_EXECUTABLE_RUNTIME_OBJCXX_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_OBJCXX_FLAG_SEP})
+endif()
+
+if(NOT CMAKE_EXECUTABLE_RPATH_LINK_OBJCXX_FLAG)
+ set(CMAKE_EXECUTABLE_RPATH_LINK_OBJCXX_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_OBJCXX_FLAG})
+endif()
+
+if(NOT DEFINED CMAKE_SHARED_LIBRARY_LINK_OBJCXX_WITH_RUNTIME_PATH)
+ set(CMAKE_SHARED_LIBRARY_LINK_OBJCXX_WITH_RUNTIME_PATH ${CMAKE_SHARED_LIBRARY_LINK_OBJC_WITH_RUNTIME_PATH})
+endif()
+
+if(NOT CMAKE_INCLUDE_FLAG_OBJCXX)
+ set(CMAKE_INCLUDE_FLAG_OBJCXX ${CMAKE_INCLUDE_FLAG_C})
+endif()
+
+# for most systems a module is the same as a shared library
+# so unless the variable CMAKE_MODULE_EXISTS is set just
+# copy the values from the LIBRARY variables
+if(NOT CMAKE_MODULE_EXISTS)
+ set(CMAKE_SHARED_MODULE_OBJCXX_FLAGS ${CMAKE_SHARED_LIBRARY_OBJCXX_FLAGS})
+ set(CMAKE_SHARED_MODULE_CREATE_OBJCXX_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_OBJCXX_FLAGS})
+endif()
+
+# repeat for modules
+if(NOT CMAKE_SHARED_MODULE_CREATE_OBJCXX_FLAGS)
+ set(CMAKE_SHARED_MODULE_CREATE_OBJCXX_FLAGS ${CMAKE_SHARED_MODULE_CREATE_OBJC_FLAGS})
+endif()
+
+if(NOT CMAKE_SHARED_MODULE_OBJCXX_FLAGS)
+ set(CMAKE_SHARED_MODULE_OBJCXX_FLAGS ${CMAKE_SHARED_MODULE_OBJC_FLAGS})
+endif()
+
+# Initialize OBJCXX link type selection flags from OBJC versions.
+foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
+ if(NOT CMAKE_${type}_LINK_STATIC_OBJCXX_FLAGS)
+ set(CMAKE_${type}_LINK_STATIC_OBJCXX_FLAGS
+ ${CMAKE_${type}_LINK_STATIC_OBJC_FLAGS})
+ endif()
+ if(NOT CMAKE_${type}_LINK_DYNAMIC_OBJCXX_FLAGS)
+ set(CMAKE_${type}_LINK_DYNAMIC_OBJCXX_FLAGS
+ ${CMAKE_${type}_LINK_DYNAMIC_OBJC_FLAGS})
+ endif()
+endforeach()
+
+# add the flags to the cache based
+# on the initial values computed in the platform/*.cmake files
+# use _INIT variables so that this only happens the first time
+# and you can set these flags in the cmake cache
+set(CMAKE_OBJCXX_FLAGS_INIT "$ENV{OBJCXXFLAGS} ${CMAKE_OBJCXX_FLAGS_INIT}")
+
+cmake_initialize_per_config_variable(CMAKE_OBJCXX_FLAGS "Flags used by the Objective-C++ compiler")
+
+if(CMAKE_OBJCXX_STANDARD_LIBRARIES_INIT)
+ set(CMAKE_OBJCXX_STANDARD_LIBRARIES "${CMAKE_OBJCXX_STANDARD_LIBRARIES_INIT}"
+ CACHE STRING "Libraries linked by default with all Objective-C++ applications.")
+ mark_as_advanced(CMAKE_OBJCXX_STANDARD_LIBRARIES)
+endif()
+
+include(CMakeCommonLanguageInclude)
+
+# now define the following rules:
+# CMAKE_OBJCXX_CREATE_SHARED_LIBRARY
+# CMAKE_OBJCXX_CREATE_SHARED_MODULE
+# CMAKE_OBJCXX_COMPILE_OBJECT
+# CMAKE_OBJCXX_LINK_EXECUTABLE
+
+# variables supplied by the generator at use time
+# <TARGET>
+# <TARGET_BASE> the target without the suffix
+# <OBJECTS>
+# <OBJECT>
+# <LINK_LIBRARIES>
+# <FLAGS>
+# <LINK_FLAGS>
+
+# Objective-C++ compiler information
+# <CMAKE_OBJCXX_COMPILER>
+# <CMAKE_SHARED_LIBRARY_CREATE_OBJCXX_FLAGS>
+# <CMAKE_OBJCXX_SHARED_MODULE_CREATE_FLAGS>
+# <CMAKE_OBJCXX_LINK_FLAGS>
+
+# Static library tools
+# <CMAKE_AR>
+# <CMAKE_RANLIB>
+
+
+# create a shared Objective-C++ library
+if(NOT CMAKE_OBJCXX_CREATE_SHARED_LIBRARY)
+ set(CMAKE_OBJCXX_CREATE_SHARED_LIBRARY
+ "<CMAKE_OBJCXX_COMPILER> <CMAKE_SHARED_LIBRARY_OBJCXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_OBJCXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
+endif()
+
+# create an Objective-C++ shared module copy the shared library rule by default
+if(NOT CMAKE_OBJCXX_CREATE_SHARED_MODULE)
+ set(CMAKE_OBJCXX_CREATE_SHARED_MODULE ${CMAKE_OBJCXX_CREATE_SHARED_LIBRARY})
+endif()
+
+
+# Create a static archive incrementally for large object file counts.
+# If CMAKE_OBJCXX_CREATE_STATIC_LIBRARY is set it will override these.
+if(NOT DEFINED CMAKE_OBJCXX_ARCHIVE_CREATE)
+ set(CMAKE_OBJCXX_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>")
+endif()
+if(NOT DEFINED CMAKE_OBJCXX_ARCHIVE_APPEND)
+ set(CMAKE_OBJCXX_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
+endif()
+if(NOT DEFINED CMAKE_OBJCXX_ARCHIVE_FINISH)
+ set(CMAKE_OBJCXX_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
+endif()
+
+# compile an Objective-C++ file into an object file
+if(NOT CMAKE_OBJCXX_COMPILE_OBJECT)
+ set(CMAKE_OBJCXX_COMPILE_OBJECT
+ "<CMAKE_OBJCXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -x objective-c++ -o <OBJECT> -c <SOURCE>")
+endif()
+
+if(NOT CMAKE_OBJCXX_LINK_EXECUTABLE)
+ set(CMAKE_OBJCXX_LINK_EXECUTABLE
+ "<CMAKE_OBJCXX_COMPILER> <FLAGS> <CMAKE_OBJCXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
+endif()
+
+mark_as_advanced(
+CMAKE_VERBOSE_MAKEFILE
+)
+
+set(CMAKE_OBJCXX_INFORMATION_LOADED 1)
diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake
index 90c2a5719..22fc95366 100644
--- a/Modules/CMakePackageConfigHelpers.cmake
+++ b/Modules/CMakePackageConfigHelpers.cmake
@@ -1,205 +1,223 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakePackageConfigHelpers
-# -------------------------
-#
-# Helpers functions for creating config files that can be included by other
-# projects to find and use a package.
-#
-# Adds the :command:`configure_package_config_file()` and
-# :command:`write_basic_package_version_file()` commands.
-#
-# Generating a Package Configuration File
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# .. command:: configure_package_config_file
-#
-# Create a config file for a project::
-#
-# configure_package_config_file(<input> <output>
-# INSTALL_DESTINATION <path>
-# [PATH_VARS <var1> <var2> ... <varN>]
-# [NO_SET_AND_CHECK_MACRO]
-# [NO_CHECK_REQUIRED_COMPONENTS_MACRO]
-# [INSTALL_PREFIX <path>]
-# )
-#
-# ``configure_package_config_file()`` should be used instead of the plain
-# :command:`configure_file()` command when creating the ``<Name>Config.cmake``
-# or ``<Name>-config.cmake`` file for installing a project or library. It helps
-# making the resulting package relocatable by avoiding hardcoded paths in the
-# installed ``Config.cmake`` file.
-#
-# In a ``FooConfig.cmake`` file there may be code like this to make the install
-# destinations know to the using project:
-#
-# .. code-block:: cmake
-#
-# set(FOO_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@" )
-# set(FOO_DATA_DIR "@CMAKE_INSTALL_PREFIX@/@RELATIVE_DATA_INSTALL_DIR@" )
-# set(FOO_ICONS_DIR "@CMAKE_INSTALL_PREFIX@/share/icons" )
-# #...logic to determine installedPrefix from the own location...
-# set(FOO_CONFIG_DIR "${installedPrefix}/@CONFIG_INSTALL_DIR@" )
-#
-# All 4 options shown above are not sufficient, since the first 3 hardcode the
-# absolute directory locations, and the 4th case works only if the logic to
-# determine the ``installedPrefix`` is correct, and if ``CONFIG_INSTALL_DIR``
-# contains a relative path, which in general cannot be guaranteed. This has the
-# effect that the resulting ``FooConfig.cmake`` file would work poorly under
-# Windows and OSX, where users are used to choose the install location of a
-# binary package at install time, independent from how
-# :variable:`CMAKE_INSTALL_PREFIX` was set at build/cmake time.
-#
-# Using ``configure_package_config_file`` helps. If used correctly, it makes
-# the resulting ``FooConfig.cmake`` file relocatable. Usage:
-#
-# 1. write a ``FooConfig.cmake.in`` file as you are used to
-# 2. insert a line containing only the string ``@PACKAGE_INIT@``
-# 3. instead of ``set(FOO_DIR "@SOME_INSTALL_DIR@")``, use
-# ``set(FOO_DIR "@PACKAGE_SOME_INSTALL_DIR@")`` (this must be after the
-# ``@PACKAGE_INIT@`` line)
-# 4. instead of using the normal :command:`configure_file()`, use
-# ``configure_package_config_file()``
-#
-#
-#
-# The ``<input>`` and ``<output>`` arguments are the input and output file, the
-# same way as in :command:`configure_file()`.
-#
-# The ``<path>`` given to ``INSTALL_DESTINATION`` must be the destination where
-# the ``FooConfig.cmake`` file will be installed to. This path can either be
-# absolute, or relative to the ``INSTALL_PREFIX`` path.
-#
-# The variables ``<var1>`` to ``<varN>`` given as ``PATH_VARS`` are the
-# variables which contain install destinations. For each of them the macro will
-# create a helper variable ``PACKAGE_<var...>``. These helper variables must be
-# used in the ``FooConfig.cmake.in`` file for setting the installed location.
-# They are calculated by ``configure_package_config_file`` so that they are
-# always relative to the installed location of the package. This works both for
-# relative and also for absolute locations. For absolute locations it works
-# only if the absolute location is a subdirectory of ``INSTALL_PREFIX``.
-#
-# If the ``INSTALL_PREFIX`` argument is passed, this is used as base path to
-# calculate all the relative paths. The ``<path>`` argument must be an absolute
-# path. If this argument is not passed, the :variable:`CMAKE_INSTALL_PREFIX`
-# variable will be used instead. The default value is good when generating a
-# FooConfig.cmake file to use your package from the install tree. When
-# generating a FooConfig.cmake file to use your package from the build tree this
-# option should be used.
-#
-# By default ``configure_package_config_file`` also generates two helper macros,
-# ``set_and_check()`` and ``check_required_components()`` into the
-# ``FooConfig.cmake`` file.
-#
-# ``set_and_check()`` should be used instead of the normal ``set()`` command for
-# setting directories and file locations. Additionally to setting the variable
-# it also checks that the referenced file or directory actually exists and fails
-# with a ``FATAL_ERROR`` otherwise. This makes sure that the created
-# ``FooConfig.cmake`` file does not contain wrong references.
-# When using the ``NO_SET_AND_CHECK_MACRO``, this macro is not generated
-# into the ``FooConfig.cmake`` file.
-#
-# ``check_required_components(<package_name>)`` should be called at the end of
-# the ``FooConfig.cmake`` file if the package supports components. This macro
-# checks whether all requested, non-optional components have been found, and if
-# this is not the case, sets the ``Foo_FOUND`` variable to ``FALSE``, so that
-# the package is considered to be not found. It does that by testing the
-# ``Foo_<Component>_FOUND`` variables for all requested required components.
-# When using the ``NO_CHECK_REQUIRED_COMPONENTS_MACRO`` option, this macro is
-# not generated into the ``FooConfig.cmake`` file.
-#
-# For an example see below the documentation for
-# :command:`write_basic_package_version_file()`.
-#
-# Generating a Package Version File
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# .. command:: write_basic_package_version_file
-#
-# Create a version file for a project::
-#
-# write_basic_package_version_file(<filename>
-# [VERSION <major.minor.patch>]
-# COMPATIBILITY <AnyNewerVersion|SameMajorVersion|ExactVersion> )
-#
-#
-# Writes a file for use as ``<package>ConfigVersion.cmake`` file to
-# ``<filename>``. See the documentation of :command:`find_package()` for
-# details on this.
-#
-# ``<filename>`` is the output filename, it should be in the build tree.
-# ``<major.minor.patch>`` is the version number of the project to be installed.
-#
-# If no ``VERSION`` is given, the :variable:`PROJECT_VERSION` variable is used.
-# If this hasn't been set, it errors out.
-#
-# The ``COMPATIBILITY`` mode ``AnyNewerVersion`` means that the installed
-# package version will be considered compatible if it is newer or exactly the
-# same as the requested version. This mode should be used for packages which
-# are fully backward compatible, also across major versions.
-# If ``SameMajorVersion`` is used instead, then the behaviour differs from
-# ``AnyNewerVersion`` in that the major version number must be the same as
-# requested, e.g. version 2.0 will not be considered compatible if 1.0 is
-# requested. This mode should be used for packages which guarantee backward
-# compatibility within the same major version.
-# If ``ExactVersion`` is used, then the package is only considered compatible if
-# the requested version matches exactly its own version number (not considering
-# the tweak version). For example, version 1.2.3 of a package is only
-# considered compatible to requested version 1.2.3. This mode is for packages
-# without compatibility guarantees.
-# If your project has more elaborated version matching rules, you will need to
-# write your own custom ``ConfigVersion.cmake`` file instead of using this
-# macro.
-#
-# Internally, this macro executes :command:`configure_file()` to create the
-# resulting version file. Depending on the ``COMPATIBLITY``, either the file
-# ``BasicConfigVersion-SameMajorVersion.cmake.in`` or
-# ``BasicConfigVersion-AnyNewerVersion.cmake.in`` is used. Please note that
-# these two files are internal to CMake and you should not call
-# :command:`configure_file()` on them yourself, but they can be used as starting
-# point to create more sophisticted custom ``ConfigVersion.cmake`` files.
-#
-# Example Generating Package Files
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# Example using both :command:`configure_package_config_file` and
-# ``write_basic_package_version_file()``:
-#
-# ``CMakeLists.txt``:
-#
-# .. code-block:: cmake
-#
-# set(INCLUDE_INSTALL_DIR include/ ... CACHE )
-# set(LIB_INSTALL_DIR lib/ ... CACHE )
-# set(SYSCONFIG_INSTALL_DIR etc/foo/ ... CACHE )
-# #...
-# include(CMakePackageConfigHelpers)
-# configure_package_config_file(FooConfig.cmake.in
-# ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake
-# INSTALL_DESTINATION ${LIB_INSTALL_DIR}/Foo/cmake
-# PATH_VARS INCLUDE_INSTALL_DIR SYSCONFIG_INSTALL_DIR)
-# write_basic_package_version_file(
-# ${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake
-# VERSION 1.2.3
-# COMPATIBILITY SameMajorVersion )
-# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake
-# ${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake
-# DESTINATION ${LIB_INSTALL_DIR}/Foo/cmake )
-#
-# ``FooConfig.cmake.in``:
-#
-# ::
-#
-# set(FOO_VERSION x.y.z)
-# ...
-# @PACKAGE_INIT@
-# ...
-# set_and_check(FOO_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
-# set_and_check(FOO_SYSCONFIG_DIR "@PACKAGE_SYSCONFIG_INSTALL_DIR@")
-#
-# check_required_components(Foo)
+#[=======================================================================[.rst:
+CMakePackageConfigHelpers
+-------------------------
+
+Helpers functions for creating config files that can be included by other
+projects to find and use a package.
+
+Adds the :command:`configure_package_config_file()` and
+:command:`write_basic_package_version_file()` commands.
+
+Generating a Package Configuration File
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. command:: configure_package_config_file
+
+ Create a config file for a project::
+
+ configure_package_config_file(<input> <output>
+ INSTALL_DESTINATION <path>
+ [PATH_VARS <var1> <var2> ... <varN>]
+ [NO_SET_AND_CHECK_MACRO]
+ [NO_CHECK_REQUIRED_COMPONENTS_MACRO]
+ [INSTALL_PREFIX <path>]
+ )
+
+``configure_package_config_file()`` should be used instead of the plain
+:command:`configure_file()` command when creating the ``<PackageName>Config.cmake``
+or ``<PackageName>-config.cmake`` file for installing a project or library.
+It helps making the resulting package relocatable by avoiding hardcoded paths
+in the installed ``Config.cmake`` file.
+
+In a ``FooConfig.cmake`` file there may be code like this to make the install
+destinations know to the using project:
+
+.. code-block:: cmake
+
+ set(FOO_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@" )
+ set(FOO_DATA_DIR "@CMAKE_INSTALL_PREFIX@/@RELATIVE_DATA_INSTALL_DIR@" )
+ set(FOO_ICONS_DIR "@CMAKE_INSTALL_PREFIX@/share/icons" )
+ #...logic to determine installedPrefix from the own location...
+ set(FOO_CONFIG_DIR "${installedPrefix}/@CONFIG_INSTALL_DIR@" )
+
+All 4 options shown above are not sufficient, since the first 3 hardcode the
+absolute directory locations, and the 4th case works only if the logic to
+determine the ``installedPrefix`` is correct, and if ``CONFIG_INSTALL_DIR``
+contains a relative path, which in general cannot be guaranteed. This has the
+effect that the resulting ``FooConfig.cmake`` file would work poorly under
+Windows and OSX, where users are used to choose the install location of a
+binary package at install time, independent from how
+:variable:`CMAKE_INSTALL_PREFIX` was set at build/cmake time.
+
+Using ``configure_package_config_file`` helps. If used correctly, it makes
+the resulting ``FooConfig.cmake`` file relocatable. Usage:
+
+1. write a ``FooConfig.cmake.in`` file as you are used to
+2. insert a line containing only the string ``@PACKAGE_INIT@``
+3. instead of ``set(FOO_DIR "@SOME_INSTALL_DIR@")``, use
+ ``set(FOO_DIR "@PACKAGE_SOME_INSTALL_DIR@")`` (this must be after the
+ ``@PACKAGE_INIT@`` line)
+4. instead of using the normal :command:`configure_file()`, use
+ ``configure_package_config_file()``
+
+
+
+The ``<input>`` and ``<output>`` arguments are the input and output file, the
+same way as in :command:`configure_file()`.
+
+The ``<path>`` given to ``INSTALL_DESTINATION`` must be the destination where
+the ``FooConfig.cmake`` file will be installed to. This path can either be
+absolute, or relative to the ``INSTALL_PREFIX`` path.
+
+The variables ``<var1>`` to ``<varN>`` given as ``PATH_VARS`` are the
+variables which contain install destinations. For each of them the macro will
+create a helper variable ``PACKAGE_<var...>``. These helper variables must be
+used in the ``FooConfig.cmake.in`` file for setting the installed location.
+They are calculated by ``configure_package_config_file`` so that they are
+always relative to the installed location of the package. This works both for
+relative and also for absolute locations. For absolute locations it works
+only if the absolute location is a subdirectory of ``INSTALL_PREFIX``.
+
+If the ``INSTALL_PREFIX`` argument is passed, this is used as base path to
+calculate all the relative paths. The ``<path>`` argument must be an absolute
+path. If this argument is not passed, the :variable:`CMAKE_INSTALL_PREFIX`
+variable will be used instead. The default value is good when generating a
+FooConfig.cmake file to use your package from the install tree. When
+generating a FooConfig.cmake file to use your package from the build tree this
+option should be used.
+
+By default ``configure_package_config_file`` also generates two helper macros,
+``set_and_check()`` and ``check_required_components()`` into the
+``FooConfig.cmake`` file.
+
+``set_and_check()`` should be used instead of the normal ``set()`` command for
+setting directories and file locations. Additionally to setting the variable
+it also checks that the referenced file or directory actually exists and fails
+with a ``FATAL_ERROR`` otherwise. This makes sure that the created
+``FooConfig.cmake`` file does not contain wrong references.
+When using the ``NO_SET_AND_CHECK_MACRO``, this macro is not generated
+into the ``FooConfig.cmake`` file.
+
+``check_required_components(<PackageName>)`` should be called at the end of
+the ``FooConfig.cmake`` file. This macro checks whether all requested,
+non-optional components have been found, and if this is not the case, sets
+the ``Foo_FOUND`` variable to ``FALSE``, so that the package is considered to
+be not found. It does that by testing the ``Foo_<Component>_FOUND``
+variables for all requested required components. This macro should be
+called even if the package doesn't provide any components to make sure
+users are not specifying components erroneously. When using the
+``NO_CHECK_REQUIRED_COMPONENTS_MACRO`` option, this macro is not generated
+into the ``FooConfig.cmake`` file.
+
+For an example see below the documentation for
+:command:`write_basic_package_version_file()`.
+
+Generating a Package Version File
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. command:: write_basic_package_version_file
+
+ Create a version file for a project::
+
+ write_basic_package_version_file(<filename>
+ [VERSION <major.minor.patch>]
+ COMPATIBILITY <AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion>
+ [ARCH_INDEPENDENT] )
+
+
+Writes a file for use as ``<PackageName>ConfigVersion.cmake`` file to
+``<filename>``. See the documentation of :command:`find_package()` for
+details on this.
+
+``<filename>`` is the output filename, it should be in the build tree.
+``<major.minor.patch>`` is the version number of the project to be installed.
+
+If no ``VERSION`` is given, the :variable:`PROJECT_VERSION` variable is used.
+If this hasn't been set, it errors out.
+
+The ``COMPATIBILITY`` mode ``AnyNewerVersion`` means that the installed
+package version will be considered compatible if it is newer or exactly the
+same as the requested version. This mode should be used for packages which
+are fully backward compatible, also across major versions.
+If ``SameMajorVersion`` is used instead, then the behaviour differs from
+``AnyNewerVersion`` in that the major version number must be the same as
+requested, e.g. version 2.0 will not be considered compatible if 1.0 is
+requested. This mode should be used for packages which guarantee backward
+compatibility within the same major version.
+If ``SameMinorVersion`` is used, the behaviour is the same as
+``SameMajorVersion``, but both major and minor version must be the same as
+requested, e.g version 0.2 will not be compatible if 0.1 is requested.
+If ``ExactVersion`` is used, then the package is only considered compatible if
+the requested version matches exactly its own version number (not considering
+the tweak version). For example, version 1.2.3 of a package is only
+considered compatible to requested version 1.2.3. This mode is for packages
+without compatibility guarantees.
+If your project has more elaborated version matching rules, you will need to
+write your own custom ``ConfigVersion.cmake`` file instead of using this
+macro.
+
+If ``ARCH_INDEPENDENT`` is given, the installed package version will be
+considered compatible even if it was built for a different architecture than
+the requested architecture. Otherwise, an architecture check will be performed,
+and the package will be considered compatible only if the architecture matches
+exactly. For example, if the package is built for a 32-bit architecture, the
+package is only considered compatible if it is used on a 32-bit architecture,
+unless ``ARCH_INDEPENDENT`` is given, in which case the package is considered
+compatible on any architecture.
+
+.. note:: ``ARCH_INDEPENDENT`` is intended for header-only libraries or similar
+ packages with no binaries.
+
+Internally, this macro executes :command:`configure_file()` to create the
+resulting version file. Depending on the ``COMPATIBILITY``, the corresponding
+``BasicConfigVersion-<COMPATIBILITY>.cmake.in`` file is used.
+Please note that these files are internal to CMake and you should not call
+:command:`configure_file()` on them yourself, but they can be used as starting
+point to create more sophisticted custom ``ConfigVersion.cmake`` files.
+
+Example Generating Package Files
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Example using both :command:`configure_package_config_file` and
+``write_basic_package_version_file()``:
+
+``CMakeLists.txt``:
+
+.. code-block:: cmake
+
+ set(INCLUDE_INSTALL_DIR include/ ... CACHE )
+ set(LIB_INSTALL_DIR lib/ ... CACHE )
+ set(SYSCONFIG_INSTALL_DIR etc/foo/ ... CACHE )
+ #...
+ include(CMakePackageConfigHelpers)
+ configure_package_config_file(FooConfig.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake
+ INSTALL_DESTINATION ${LIB_INSTALL_DIR}/Foo/cmake
+ PATH_VARS INCLUDE_INSTALL_DIR SYSCONFIG_INSTALL_DIR)
+ write_basic_package_version_file(
+ ${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake
+ VERSION 1.2.3
+ COMPATIBILITY SameMajorVersion )
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake
+ DESTINATION ${LIB_INSTALL_DIR}/Foo/cmake )
+
+``FooConfig.cmake.in``:
+
+::
+
+ set(FOO_VERSION x.y.z)
+ ...
+ @PACKAGE_INIT@
+ ...
+ set_and_check(FOO_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
+ set_and_check(FOO_SYSCONFIG_DIR "@PACKAGE_SYSCONFIG_INSTALL_DIR@")
+
+ check_required_components(Foo)
+#]=======================================================================]
include(WriteBasicConfigVersionFile)
diff --git a/Modules/CMakeParseArguments.cmake b/Modules/CMakeParseArguments.cmake
index 7ee2bbace..c753b7f51 100644
--- a/Modules/CMakeParseArguments.cmake
+++ b/Modules/CMakeParseArguments.cmake
@@ -1,11 +1,12 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakeParseArguments
-# -------------------
-#
-# This module once implemented the :command:`cmake_parse_arguments` command
-# that is now implemented natively by CMake. It is now an empty placeholder
-# for compatibility with projects that include it to get the command from
-# CMake 3.4 and lower.
+#[=======================================================================[.rst:
+CMakeParseArguments
+-------------------
+
+This module once implemented the :command:`cmake_parse_arguments` command
+that is now implemented natively by CMake. It is now an empty placeholder
+for compatibility with projects that include it to get the command from
+CMake 3.4 and lower.
+#]=======================================================================]
diff --git a/Modules/CMakeParseImplicitIncludeInfo.cmake b/Modules/CMakeParseImplicitIncludeInfo.cmake
new file mode 100644
index 000000000..ff4c32561
--- /dev/null
+++ b/Modules/CMakeParseImplicitIncludeInfo.cmake
@@ -0,0 +1,247 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# This is used internally by CMake and should not be included by user code.
+
+# helper function that parses implicit include dirs from a single line
+# for compilers that report them that way. on success we return the
+# list of dirs in id_var and set state_var to the 'done' state.
+function(cmake_parse_implicit_include_line line lang id_var log_var state_var)
+ # clear variables we append to (avoids possible polution from parent scopes)
+ unset(rv)
+ set(log "")
+
+ # Cray compiler (from cray wrapper, via PrgEnv-cray)
+ if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "Cray" AND
+ "${line}" MATCHES "^/" AND "${line}" MATCHES "/ccfe |/ftnfe " AND
+ "${line}" MATCHES " -isystem| -I")
+ string(REGEX MATCHALL " (-I ?|-isystem )(\"[^\"]+\"|[^ \"]+)" incs "${line}")
+ foreach(inc IN LISTS incs)
+ string(REGEX REPLACE " (-I ?|-isystem )(\"[^\"]+\"|[^ \"]+)" "\\2" idir "${inc}")
+ list(APPEND rv "${idir}")
+ endforeach()
+ if(rv)
+ string(APPEND log " got implicit includes via cray ccfe parser!\n")
+ else()
+ string(APPEND log " warning: cray ccfe parse failed!\n")
+ endif()
+ endif()
+
+ # PGI compiler
+ if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "PGI")
+ # pgc++ verbose output differs
+ if(("${lang}" STREQUAL "C" OR "${lang}" STREQUAL "Fortran") AND
+ "${line}" MATCHES "^/" AND
+ "${line}" MATCHES "/pgc |/pgf901 |/pgftnc " AND
+ "${line}" MATCHES " -cmdline ")
+ # cmdline has unparsed cmdline, remove it
+ string(REGEX REPLACE "-cmdline .*" "" line "${line}")
+ if("${line}" MATCHES " -nostdinc ")
+ set(rv "") # defined, but empty
+ else()
+ string(REGEX MATCHALL " -stdinc ([^ ]*)" incs "${line}")
+ foreach(inc IN LISTS incs)
+ string(REGEX REPLACE " -stdinc ([^ ]*)" "\\1" idir "${inc}")
+ string(REPLACE ":" ";" idir "${idir}")
+ list(APPEND rv ${idir})
+ endforeach()
+ endif()
+ if(DEFINED rv)
+ string(APPEND log " got implicit includes via PGI C/F parser!\n")
+ else()
+ string(APPEND log " warning: PGI C/F parse failed!\n")
+ endif()
+ elseif("${lang}" STREQUAL "CXX" AND "${line}" MATCHES "^/" AND
+ "${line}" MATCHES "/pggpp1 " AND "${line}" MATCHES " -I")
+ # oddly, -Mnostdinc does not get rid of system -I's, at least in
+ # PGI 18.10.1 ...
+ string(REGEX MATCHALL " (-I ?)([^ ]*)" incs "${line}")
+ foreach(inc IN LISTS incs)
+ string(REGEX REPLACE " (-I ?)([^ ]*)" "\\2" idir "${inc}")
+ if(NOT "${idir}" STREQUAL "-") # filter out "-I-"
+ list(APPEND rv "${idir}")
+ endif()
+ endforeach()
+ if(DEFINED rv)
+ string(APPEND log " got implicit includes via PGI CXX parser!\n")
+ else()
+ string(APPEND log " warning: PGI CXX parse failed!\n")
+ endif()
+ endif()
+ endif()
+
+ # SunPro compiler
+ if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "SunPro" AND
+ ("${line}" MATCHES "-D__SUNPRO_C" OR "${line}" MATCHES "-D__SUNPRO_F") )
+ string(REGEX MATCHALL " (-I ?)([^ ]*)" incs "${line}")
+ foreach(inc IN LISTS incs)
+ string(REGEX REPLACE " (-I ?)([^ ]*)" "\\2" idir "${inc}")
+ if(NOT "${idir}" STREQUAL "-xbuiltin")
+ list(APPEND rv "${idir}")
+ endif()
+ endforeach()
+ if(rv)
+ if ("${lang}" STREQUAL "C" OR "${lang}" STREQUAL "CXX")
+ # /usr/include appears to be hardwired in
+ list(APPEND rv "/usr/include")
+ endif()
+ string(APPEND log " got implicit includes via sunpro parser!\n")
+ else()
+ string(APPEND log " warning: sunpro parse failed!\n")
+ endif()
+ endif()
+
+ # XL compiler
+ if(("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "XL"
+ OR "${CMAKE_${lang}_COMPILER_ID}" STREQUAL "XLClang")
+ AND "${line}" MATCHES "^/"
+ AND ( ("${lang}" STREQUAL "Fortran" AND
+ "${line}" MATCHES "/xl[fF]entry " AND
+ "${line}" MATCHES "OSVAR\\([^ ]+\\)")
+ OR
+ ( ("${lang}" STREQUAL "C" OR "${lang}" STREQUAL "CXX") AND
+ "${line}" MATCHES "/xl[cC]2?entry " AND
+ "${line}" MATCHES " -qosvar=")
+ ) )
+ # -qnostdinc cancels other stdinc flags, even if present
+ string(FIND "${line}" " -qnostdinc" nostd)
+ if(NOT ${nostd} EQUAL -1)
+ set(rv "") # defined but empty
+ string(APPEND log " got implicit includes via XL parser (nostdinc)\n")
+ else()
+ if("${lang}" STREQUAL "CXX")
+ string(REGEX MATCHALL " -qcpp_stdinc=([^ ]*)" std "${line}")
+ string(REGEX MATCHALL " -qgcc_cpp_stdinc=([^ ]*)" gcc_std "${line}")
+ else()
+ string(REGEX MATCHALL " -qc_stdinc=([^ ]*)" std "${line}")
+ string(REGEX MATCHALL " -qgcc_c_stdinc=([^ ]*)" gcc_std "${line}")
+ endif()
+ set(xlstd ${std} ${gcc_std})
+ foreach(inc IN LISTS xlstd)
+ string(REGEX REPLACE " -q(cpp|gcc_cpp|c|gcc_c)_stdinc=([^ ]*)" "\\2"
+ ipath "${inc}")
+ string(REPLACE ":" ";" ipath "${ipath}")
+ list(APPEND rv ${ipath})
+ endforeach()
+ endif()
+ # user can add -I flags via CMAKE_{C,CXX}_FLAGS, look for that too
+ string(REGEX MATCHALL " (-I ?)([^ ]*)" incs "${line}")
+ unset(urv)
+ foreach(inc IN LISTS incs)
+ string(REGEX REPLACE " (-I ?)([^ ]*)" "\\2" idir "${inc}")
+ list(APPEND urv "${idir}")
+ endforeach()
+ if(urv)
+ if ("${rv}" STREQUAL "")
+ set(rv ${urv})
+ else()
+ list(APPEND rv ${urv})
+ endif()
+ endif()
+
+ if(DEFINED rv)
+ string(APPEND log " got implicit includes via XL parser!\n")
+ else()
+ string(APPEND log " warning: XL parse failed!\n")
+ endif()
+ endif()
+
+ if(log)
+ set(${log_var} "${log}" PARENT_SCOPE)
+ else()
+ unset(${log_var} PARENT_SCOPE)
+ endif()
+ if(DEFINED rv)
+ set(${id_var} "${rv}" PARENT_SCOPE)
+ set(${state_var} "done" PARENT_SCOPE)
+ endif()
+endfunction()
+
+# top-level function to parse implicit include directory information
+# from verbose compiler output. sets state_var in parent to 'done' on success.
+function(cmake_parse_implicit_include_info text lang dir_var log_var state_var)
+ set(state start) # values: start, loading, done
+
+ # clear variables we append to (avoids possible polution from parent scopes)
+ set(implicit_dirs_tmp)
+ set(log "")
+
+ # go through each line of output...
+ string(REGEX REPLACE "\r*\n" ";" output_lines "${text}")
+ foreach(line IN LISTS output_lines)
+ if(state STREQUAL start)
+ string(FIND "${line}" "#include \"...\" search starts here:" rv)
+ if(rv GREATER -1)
+ set(state loading)
+ set(preload 1) # looking for include <...> now
+ string(APPEND log " found start of include info\n")
+ else()
+ cmake_parse_implicit_include_line("${line}" "${lang}" implicit_dirs_tmp
+ linelog state)
+ if(linelog)
+ string(APPEND log ${linelog})
+ endif()
+ if(state STREQUAL done)
+ break()
+ endif()
+ endif()
+ elseif(state STREQUAL loading)
+ string(FIND "${line}" "End of search list." rv)
+ if(rv GREATER -1)
+ set(state done)
+ string(APPEND log " end of search list found\n")
+ break()
+ endif()
+ if(preload)
+ string(FIND "${line}" "#include <...> search starts here:" rv)
+ if(rv GREATER -1)
+ set(preload 0)
+ string(APPEND log " found start of implicit include info\n")
+ endif()
+ continue()
+ endif()
+ if("${line}" MATCHES "^ ")
+ string(SUBSTRING "${line}" 1 -1 line) # remove leading space
+ endif()
+ if ("${line}" MATCHES " \\(framework directory\\)$")
+ continue() # frameworks are handled elsewhere, ignore them here
+ endif()
+ string(REPLACE "\\" "/" path "${line}")
+ list(APPEND implicit_dirs_tmp "${path}")
+ string(APPEND log " add: [${path}]\n")
+ endif()
+ endforeach()
+
+ set(implicit_dirs "")
+ foreach(d IN LISTS implicit_dirs_tmp)
+ if(IS_ABSOLUTE "${d}")
+ get_filename_component(dir "${d}" ABSOLUTE)
+ list(APPEND implicit_dirs "${dir}")
+ string(APPEND log " collapse include dir [${d}] ==> [${dir}]\n")
+ elseif("${d}" MATCHES [[^\.\.[\/]\.\.[\/](.*)$]])
+ # This relative path is deep enough to get out of the CMakeFiles/CMakeTmp
+ # directory where the ABI check is done. Assume that the compiler has
+ # computed this path adaptively based on the current working directory
+ # such that the effective result is absolute.
+ get_filename_component(dir "${CMAKE_BINARY_DIR}/${CMAKE_MATCH_1}" ABSOLUTE)
+ list(APPEND implicit_dirs "${dir}")
+ string(APPEND log " collapse relative include dir [${d}] ==> [${dir}]\n")
+ else()
+ string(APPEND log " skipping relative include dir [${d}]\n")
+ endif()
+ endforeach()
+ list(REMOVE_DUPLICATES implicit_dirs)
+
+ # Log results.
+ if(state STREQUAL done)
+ string(APPEND log " implicit include dirs: [${implicit_dirs}]\n")
+ else()
+ string(APPEND log " warn: unable to parse implicit include dirs!\n")
+ endif()
+
+ # Return results.
+ set(${dir_var} "${implicit_dirs}" PARENT_SCOPE)
+ set(${log_var} "${log}" PARENT_SCOPE)
+ set(${state_var} "${state}" PARENT_SCOPE)
+
+endfunction()
diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake
index 3b772784b..04655156e 100644
--- a/Modules/CMakeParseImplicitLinkInfo.cmake
+++ b/Modules/CMakeParseImplicitLinkInfo.cmake
@@ -1,6 +1,9 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
+cmake_policy(PUSH)
+cmake_policy(SET CMP0053 NEW)
+cmake_policy(SET CMP0054 NEW)
# Function parse implicit linker options.
# This is used internally by CMake and should not be included by user
@@ -44,6 +47,18 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
endif()
separate_arguments(args NATIVE_COMMAND "${line}")
list(GET args 0 cmd)
+ else()
+ #check to see if the link line is comma-separated instead of space separated
+ string(REGEX REPLACE "," " " line "${line}")
+ if("${line}" MATCHES "${linker_regex}" AND
+ NOT "${line}" MATCHES "${linker_exclude_regex}")
+ separate_arguments(args NATIVE_COMMAND "${line}")
+ list(GET args 0 cmd)
+ if("${cmd}" MATCHES "exec:")
+ # ibm xl sometimes has 'exec: ' in-front of the linker
+ list(GET args 1 cmd)
+ endif()
+ endif()
endif()
set(is_msvc 0)
if("${cmd}" MATCHES "${linker_regex}")
@@ -142,7 +157,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
# We remove items that are not language-specific.
set(implicit_libs "")
foreach(lib IN LISTS implicit_libs_tmp)
- if("x${lib}" MATCHES "^x(crt.*\\.o|System.*|.*libclang_rt.*|msvcrt.*|libvcruntime.*|libucrt.*|libcmt.*)$")
+ if("x${lib}" MATCHES "^x(crt.*\\.o|gcc_eh.*|.*libgcc_eh.*|System.*|.*libclang_rt.*|msvcrt.*|libvcruntime.*|libucrt.*|libcmt.*)$")
string(APPEND log " remove lib [${lib}]\n")
elseif(IS_ABSOLUTE "${lib}")
get_filename_component(abs "${lib}" ABSOLUTE)
@@ -185,3 +200,5 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
set(${fwk_var} "${implicit_fwks}" PARENT_SCOPE)
set(${log_var} "${log}" PARENT_SCOPE)
endfunction()
+
+cmake_policy(POP)
diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in
index 47eb00a39..64a00b3d4 100644
--- a/Modules/CMakePlatformId.h.in
+++ b/Modules/CMakePlatformId.h.in
@@ -32,9 +32,6 @@
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
# define PLATFORM_ID "AIX"
-#elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
-# define PLATFORM_ID "IRIX"
-
#elif defined(__hpux) || defined(__hpux__)
# define PLATFORM_ID "HP-UX"
@@ -94,6 +91,14 @@
# define PLATFORM_ID
# endif
+#elif defined(__INTEGRITY)
+# if defined(INT_178B)
+# define PLATFORM_ID "Integrity178"
+
+# else /* regular Integrity */
+# define PLATFORM_ID "Integrity"
+# endif
+
#else /* unknown platform */
# define PLATFORM_ID
@@ -114,6 +119,9 @@
# elif defined(_M_IX86)
# define ARCHITECTURE_ID "X86"
+# elif defined(_M_ARM64)
+# define ARCHITECTURE_ID "ARM64"
+
# elif defined(_M_ARM)
# if _M_ARM == 4
# define ARCHITECTURE_ID "ARMV4I"
@@ -144,6 +152,57 @@
# define ARCHITECTURE_ID ""
# endif
+#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
+# if defined(__ICCARM__)
+# define ARCHITECTURE_ID "ARM"
+
+# elif defined(__ICCRX__)
+# define ARCHITECTURE_ID "RX"
+
+# elif defined(__ICCRH850__)
+# define ARCHITECTURE_ID "RH850"
+
+# elif defined(__ICCRL78__)
+# define ARCHITECTURE_ID "RL78"
+
+# elif defined(__ICCRISCV__)
+# define ARCHITECTURE_ID "RISCV"
+
+# elif defined(__ICCAVR__)
+# define ARCHITECTURE_ID "AVR"
+
+# elif defined(__ICC430__)
+# define ARCHITECTURE_ID "MSP430"
+
+# elif defined(__ICCV850__)
+# define ARCHITECTURE_ID "V850"
+
+# elif defined(__ICC8051__)
+# define ARCHITECTURE_ID "8051"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
+#elif defined(__ghs__)
+# if defined(__PPC64__)
+# define ARCHITECTURE_ID "PPC64"
+
+# elif defined(__ppc__)
+# define ARCHITECTURE_ID "PPC"
+
+# elif defined(__ARM__)
+# define ARCHITECTURE_ID "ARM"
+
+# elif defined(__x86_64__)
+# define ARCHITECTURE_ID "x64"
+
+# elif defined(__i386__)
+# define ARCHITECTURE_ID "X86"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
#else
# define ARCHITECTURE_ID
#endif
@@ -188,6 +247,15 @@ char const info_version[] = {
']','\0'};
#endif
+/* Construct a string literal encoding the internal version number. */
+#ifdef COMPILER_VERSION_INTERNAL
+char const info_version_internal[] = {
+ 'I', 'N', 'F', 'O', ':',
+ 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
+ 'i','n','t','e','r','n','a','l','[',
+ COMPILER_VERSION_INTERNAL,']','\0'};
+#endif
+
/* Construct a string literal encoding the version number components. */
#ifdef SIMULATE_VERSION_MAJOR
char const info_simulate_version[] = {
diff --git a/Modules/CMakePrintHelpers.cmake b/Modules/CMakePrintHelpers.cmake
index 21c333e31..d652ffa5c 100644
--- a/Modules/CMakePrintHelpers.cmake
+++ b/Modules/CMakePrintHelpers.cmake
@@ -1,57 +1,59 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakePrintHelpers
-# -----------------
-#
-# Convenience macros for printing properties and variables, useful e.g. for debugging.
-#
-# ::
-#
-# CMAKE_PRINT_PROPERTIES([TARGETS target1 .. targetN]
-# [SOURCES source1 .. sourceN]
-# [DIRECTORIES dir1 .. dirN]
-# [TESTS test1 .. testN]
-# [CACHE_ENTRIES entry1 .. entryN]
-# PROPERTIES prop1 .. propN )
-#
-# This macro prints the values of the properties of the given targets,
-# source files, directories, tests or cache entries. Exactly one of the
-# scope keywords must be used. Example::
-#
-# cmake_print_properties(TARGETS foo bar PROPERTIES
-# LOCATION INTERFACE_INCLUDE_DIRS)
-#
-# This will print the LOCATION and INTERFACE_INCLUDE_DIRS properties for
-# both targets foo and bar.
-#
-#
-#
-# CMAKE_PRINT_VARIABLES(var1 var2 .. varN)
-#
-# This macro will print the name of each variable followed by its value.
-# Example::
-#
-# cmake_print_variables(CMAKE_C_COMPILER CMAKE_MAJOR_VERSION DOES_NOT_EXIST)
-#
-# Gives::
-#
-# -- CMAKE_C_COMPILER="/usr/bin/gcc" ; CMAKE_MAJOR_VERSION="2" ; DOES_NOT_EXIST=""
-
-function(CMAKE_PRINT_VARIABLES)
- set(msg "")
- foreach(var ${ARGN})
- if(msg)
- string(APPEND msg " ; ")
- endif()
- string(APPEND msg "${var}=\"${${var}}\"")
- endforeach()
- message(STATUS "${msg}")
+#[=======================================================================[.rst:
+CMakePrintHelpers
+-----------------
+
+Convenience functions for printing properties and variables, useful
+e.g. for debugging.
+
+::
+
+ cmake_print_properties([TARGETS target1 .. targetN]
+ [SOURCES source1 .. sourceN]
+ [DIRECTORIES dir1 .. dirN]
+ [TESTS test1 .. testN]
+ [CACHE_ENTRIES entry1 .. entryN]
+ PROPERTIES prop1 .. propN )
+
+This function prints the values of the properties of the given targets,
+source files, directories, tests or cache entries. Exactly one of the
+scope keywords must be used. Example::
+
+ cmake_print_properties(TARGETS foo bar PROPERTIES
+ LOCATION INTERFACE_INCLUDE_DIRECTORIES)
+
+This will print the LOCATION and INTERFACE_INCLUDE_DIRECTORIES properties for
+both targets foo and bar.
+
+::
+
+ cmake_print_variables(var1 var2 .. varN)
+
+This function will print the name of each variable followed by its value.
+Example::
+
+ cmake_print_variables(CMAKE_C_COMPILER CMAKE_MAJOR_VERSION DOES_NOT_EXIST)
+
+Gives::
+
+ -- CMAKE_C_COMPILER="/usr/bin/gcc" ; CMAKE_MAJOR_VERSION="2" ; DOES_NOT_EXIST=""
+#]=======================================================================]
+
+function(cmake_print_variables)
+ set(msg "")
+ foreach(var ${ARGN})
+ if(msg)
+ string(APPEND msg " ; ")
+ endif()
+ string(APPEND msg "${var}=\"${${var}}\"")
+ endforeach()
+ message(STATUS "${msg}")
endfunction()
-function(CMAKE_PRINT_PROPERTIES )
+function(cmake_print_properties)
set(options )
set(oneValueArgs )
set(multiValueArgs TARGETS SOURCES TESTS DIRECTORIES CACHE_ENTRIES PROPERTIES )
diff --git a/Modules/CMakePrintSystemInformation.cmake b/Modules/CMakePrintSystemInformation.cmake
index e74c801db..f873a4d97 100644
--- a/Modules/CMakePrintSystemInformation.cmake
+++ b/Modules/CMakePrintSystemInformation.cmake
@@ -1,14 +1,15 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakePrintSystemInformation
-# ---------------------------
-#
-# print system information
-#
-# This file can be used for diagnostic purposes just include it in a
-# project to see various internal CMake variables.
+#[=======================================================================[.rst:
+CMakePrintSystemInformation
+---------------------------
+
+print system information
+
+This file can be used for diagnostic purposes just include it in a
+project to see various internal CMake variables.
+#]=======================================================================]
message("CMAKE_SYSTEM is ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}")
message("CMAKE_SYSTEM file is ${CMAKE_SYSTEM_INFO_FILE}")
diff --git a/Modules/CMakePushCheckState.cmake b/Modules/CMakePushCheckState.cmake
index 2a527d5bd..3e519ee51 100644
--- a/Modules/CMakePushCheckState.cmake
+++ b/Modules/CMakePushCheckState.cmake
@@ -1,86 +1,91 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakePushCheckState
-# -------------------
-#
-#
-#
-# This module defines three macros: CMAKE_PUSH_CHECK_STATE()
-# CMAKE_POP_CHECK_STATE() and CMAKE_RESET_CHECK_STATE() These macros can
-# be used to save, restore and reset (i.e., clear contents) the state of
-# the variables CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS,
-# CMAKE_REQUIRED_LIBRARIES, CMAKE_REQUIRED_INCLUDES and CMAKE_EXTRA_INCLUDE_FILES
-# used by the various Check-files coming with CMake, like e.g.
-# check_function_exists() etc. The variable contents are pushed on a
-# stack, pushing multiple times is supported. This is useful e.g. when
-# executing such tests in a Find-module, where they have to be set, but
-# after the Find-module has been executed they should have the same
-# value as they had before.
-#
-# CMAKE_PUSH_CHECK_STATE() macro receives optional argument RESET.
-# Whether it's specified, CMAKE_PUSH_CHECK_STATE() will set all
-# CMAKE_REQUIRED_* variables to empty values, same as
-# CMAKE_RESET_CHECK_STATE() call will do.
-#
-# Usage:
-#
-# ::
-#
-# cmake_push_check_state(RESET)
-# set(CMAKE_REQUIRED_DEFINITIONS -DSOME_MORE_DEF)
-# check_function_exists(...)
-# cmake_reset_check_state()
-# set(CMAKE_REQUIRED_DEFINITIONS -DANOTHER_DEF)
-# check_function_exists(...)
-# cmake_pop_check_state()
+#[=======================================================================[.rst:
+CMakePushCheckState
+-------------------
+
+
+
+This module defines three macros: ``CMAKE_PUSH_CHECK_STATE()``
+``CMAKE_POP_CHECK_STATE()`` and ``CMAKE_RESET_CHECK_STATE()`` These macros can
+be used to save, restore and reset (i.e., clear contents) the state of
+the variables ``CMAKE_REQUIRED_FLAGS``, ``CMAKE_REQUIRED_DEFINITIONS``,
+``CMAKE_REQUIRED_LINK_OPTIONS``, ``CMAKE_REQUIRED_LIBRARIES``,
+``CMAKE_REQUIRED_INCLUDES`` and ``CMAKE_EXTRA_INCLUDE_FILES`` used by the
+various Check-files coming with CMake, like e.g. ``check_function_exists()``
+etc.
+The variable contents are pushed on a stack, pushing multiple times is
+supported. This is useful e.g. when executing such tests in a Find-module,
+where they have to be set, but after the Find-module has been executed they
+should have the same value as they had before.
+
+``CMAKE_PUSH_CHECK_STATE()`` macro receives optional argument ``RESET``.
+Whether it's specified, ``CMAKE_PUSH_CHECK_STATE()`` will set all
+``CMAKE_REQUIRED_*`` variables to empty values, same as
+``CMAKE_RESET_CHECK_STATE()`` call will do.
+
+Usage:
+
+.. code-block:: cmake
+
+ cmake_push_check_state(RESET)
+ set(CMAKE_REQUIRED_DEFINITIONS -DSOME_MORE_DEF)
+ check_function_exists(...)
+ cmake_reset_check_state()
+ set(CMAKE_REQUIRED_DEFINITIONS -DANOTHER_DEF)
+ check_function_exists(...)
+ cmake_pop_check_state()
+#]=======================================================================]
macro(CMAKE_RESET_CHECK_STATE)
- set(CMAKE_EXTRA_INCLUDE_FILES)
- set(CMAKE_REQUIRED_INCLUDES)
- set(CMAKE_REQUIRED_DEFINITIONS)
- set(CMAKE_REQUIRED_LIBRARIES)
- set(CMAKE_REQUIRED_FLAGS)
- set(CMAKE_REQUIRED_QUIET)
+ set(CMAKE_EXTRA_INCLUDE_FILES)
+ set(CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_REQUIRED_DEFINITIONS)
+ set(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CMAKE_REQUIRED_LIBRARIES)
+ set(CMAKE_REQUIRED_FLAGS)
+ set(CMAKE_REQUIRED_QUIET)
endmacro()
macro(CMAKE_PUSH_CHECK_STATE)
- if(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER)
- set(_CMAKE_PUSH_CHECK_STATE_COUNTER 0)
- endif()
+ if(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER)
+ set(_CMAKE_PUSH_CHECK_STATE_COUNTER 0)
+ endif()
- math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1")
+ math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1")
- set(_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_EXTRA_INCLUDE_FILES})
- set(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES})
- set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS})
- set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES})
- set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS})
- set(_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_QUIET})
+ set(_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_EXTRA_INCLUDE_FILES})
+ set(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES})
+ set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS})
+ set(_CMAKE_REQUIRED_LINK_OPTIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LINK_OPTIONS})
+ set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES})
+ set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS})
+ set(_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_QUIET})
- if (ARGC GREATER 0 AND ARGV0 STREQUAL "RESET")
- cmake_reset_check_state()
- endif()
+ if (${ARGC} GREATER 0 AND "${ARGV0}" STREQUAL "RESET")
+ cmake_reset_check_state()
+ endif()
endmacro()
macro(CMAKE_POP_CHECK_STATE)
# don't pop more than we pushed
- if("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0")
+ if("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0")
- set(CMAKE_EXTRA_INCLUDE_FILES ${_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
- set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
- set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
- set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
- set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
- set(CMAKE_REQUIRED_QUIET ${_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
+ set(CMAKE_EXTRA_INCLUDE_FILES ${_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
+ set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
+ set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
+ set(CMAKE_REQUIRED_LINK_OPTIONS ${_CMAKE_REQUIRED_LINK_OPTIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
+ set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
+ set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
+ set(CMAKE_REQUIRED_QUIET ${_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
- math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1")
- endif()
+ math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1")
+ endif()
endmacro()
diff --git a/Modules/CMakeRCInformation.cmake b/Modules/CMakeRCInformation.cmake
index a34028867..7c3a5ab30 100644
--- a/Modules/CMakeRCInformation.cmake
+++ b/Modules/CMakeRCInformation.cmake
@@ -17,25 +17,20 @@ set(CMAKE_SYSTEM_AND_RC_COMPILER_INFO_FILE
${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
+# This should be included before the _INIT variables are
+# used to initialize the cache. Since the rule variables
+# have if blocks on them, users can still define them here.
+# But, it should still be after the platform file so changes can
+# be made to those values.
+if(CMAKE_USER_MAKE_RULES_OVERRIDE)
+ # Save the full path of the file so try_compile can use it.
+ include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override)
+ set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}")
+endif()
+
set(CMAKE_RC_FLAGS_INIT "$ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}")
-foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO)
- string(STRIP "${CMAKE_RC_FLAGS${c}_INIT}" CMAKE_RC_FLAGS${c}_INIT)
-endforeach()
-
-set (CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS_INIT}" CACHE STRING
- "Flags for Windows Resource Compiler.")
-
-if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
- set (CMAKE_RC_FLAGS_DEBUG "${CMAKE_RC_FLAGS_DEBUG_INIT}" CACHE STRING
- "Flags for Windows Resource Compiler during debug builds.")
- set (CMAKE_RC_FLAGS_MINSIZEREL "${CMAKE_RC_FLAGS_MINSIZEREL_INIT}" CACHE STRING
- "Flags for Windows Resource Compiler during release builds for minimum size.")
- set (CMAKE_RC_FLAGS_RELEASE "${CMAKE_RC_FLAGS_RELEASE_INIT}" CACHE STRING
- "Flags for Windows Resource Compiler during release builds.")
- set (CMAKE_RC_FLAGS_RELWITHDEBINFO "${CMAKE_RC_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
- "Flags for Windows Resource Compiler during release builds with debug info.")
-endif()
+cmake_initialize_per_config_variable(CMAKE_RC_FLAGS "Flags for Windows Resource Compiler")
# These are the only types of flags that should be passed to the rc
# command, if COMPILE_FLAGS is used on a target this will be used
@@ -48,15 +43,8 @@ set(CMAKE_INCLUDE_FLAG_RC "-I")
# compile a Resource file into an object file
if(NOT CMAKE_RC_COMPILE_OBJECT)
set(CMAKE_RC_COMPILE_OBJECT
- "<CMAKE_RC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /fo<OBJECT> <SOURCE>")
+ "<CMAKE_RC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /fo <OBJECT> <SOURCE>")
endif()
-mark_as_advanced(
-CMAKE_RC_FLAGS
-CMAKE_RC_FLAGS_DEBUG
-CMAKE_RC_FLAGS_MINSIZEREL
-CMAKE_RC_FLAGS_RELEASE
-CMAKE_RC_FLAGS_RELWITHDEBINFO
-)
# set this variable so we can avoid loading this more than once.
set(CMAKE_RC_INFORMATION_LOADED 1)
diff --git a/Modules/CMakeSwiftCompiler.cmake.in b/Modules/CMakeSwiftCompiler.cmake.in
index 45f0a3105..7c8d1c19a 100644
--- a/Modules/CMakeSwiftCompiler.cmake.in
+++ b/Modules/CMakeSwiftCompiler.cmake.in
@@ -1,5 +1,14 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
set(CMAKE_Swift_COMPILER "@CMAKE_Swift_COMPILER@")
set(CMAKE_Swift_COMPILER_ID "@CMAKE_Swift_COMPILER_ID@")
+set(CMAKE_Swift_COMPILER_VERSION "@CMAKE_Swift_COMPILER_VERSION@")
+
+set(CMAKE_Swift_COMPILER_LOADED 1)
+set(CMAKE_Swift_COMPILER_WORKS "@CMAKE_Swift_COMPILER_WORKS@")
+
+set(CMAKE_Swift_COMPILER_ENV_VAR "SWIFTC")
set(CMAKE_Swift_COMPILER_ID_RUN 1)
set(CMAKE_Swift_SOURCE_FILE_EXTENSIONS swift)
diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake
index d9b408d3b..2c54da013 100644
--- a/Modules/CMakeSwiftInformation.cmake
+++ b/Modules/CMakeSwiftInformation.cmake
@@ -1,32 +1,98 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-
-set(CMAKE_Swift_OUTPUT_EXTENSION .o)
-set(CMAKE_INCLUDE_FLAG_Swift "-I")
+if(UNIX)
+ set(CMAKE_Swift_OUTPUT_EXTENSION .o)
+else()
+ set(CMAKE_Swift_OUTPUT_EXTENSION .obj)
+endif()
# Load compiler-specific information.
if(CMAKE_Swift_COMPILER_ID)
include(Compiler/${CMAKE_Swift_COMPILER_ID}-Swift OPTIONAL)
-endif()
-# load the system- and compiler specific files
-if(CMAKE_Swift_COMPILER_ID)
- # load a hardware specific file, mostly useful for embedded compilers
if(CMAKE_SYSTEM_PROCESSOR)
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
endif()
- include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift OPTIONAL)
+ include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift OPTIONAL)
endif()
-# for most systems a module is the same as a shared library
-# so unless the variable CMAKE_MODULE_EXISTS is set just
-# copy the values from the LIBRARY variables
-if(NOT CMAKE_MODULE_EXISTS)
- set(CMAKE_SHARED_MODULE_Swift_FLAGS ${CMAKE_SHARED_LIBRARY_Swift_FLAGS})
- set(CMAKE_SHARED_MODULE_CREATE_Swift_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_Swift_FLAGS})
+set(CMAKE_INCLUDE_FLAG_Swift "-I ")
+if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
+ set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -install_name -Xlinker ")
+elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
+ set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -soname -Xlinker ")
+endif()
+
+if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
+ set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG "-Xlinker -rpath -Xlinker ")
+ set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG_SEP ":")
+endif()
+
+set(CMAKE_Swift_COMPILE_OPTIONS_TARGET "-target ")
+set(CMAKE_Swift_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "-tools-directory ")
+# NOTE(compnerd) the `-sdk` support is not yet ready in the compiler; when that
+# is fully working, we should be able to enable this.
+# set(CMAKE_Swift_COMPILE_OPTIONS_SYSROOT "-sdk ")
+# NOTE(compnerd) do not setup `-frontend` as we use the compiler as the driver
+# during the link phase and use that to drive the compilation
+set(CMAKE_Swift_COMPILER_ARG1 "")
+set(CMAKE_Swift_DEFINE_FLAG -D)
+set(CMAKE_Swift_FRAMEWORK_SEARCH_FLAG "-F ")
+set(CMAKE_Swift_LIBRARY_PATH_FLAG "-L ")
+set(CMAKE_Swift_LIBRARY_PATH_TERMINATOR "")
+set(CMAKE_Swift_LINK_LIBRARY_FLAG "-l")
+set(CMAKE_Swift_LINKER_WRAPPER_FLAG "-Xlinker" " ")
+set(CMAKE_Swift_RESPONSE_FILE_LINK_FLAG @)
+
+set(CMAKE_Swift_LINKER_PREFERENCE 50)
+set(CMAKE_Swift_LINKER_PREFERENCE_PROPAGATES 1)
+
+# NOTE(compnerd) use the short form for convenience and ease of search. They
+# are treated equivalent to their long form names as well as custom Swift
+# specific names.
+set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -libc MT)
+set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -libc MD)
+set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -libc MTd)
+set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -libc MDd)
+
+set(CMAKE_Swift_FLAGS_DEBUG_INIT "-g")
+set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O")
+set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g")
+set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize")
+
+cmake_initialize_per_config_variable(CMAKE_Swift_FLAGS "Swift Compiler Flags")
+
+# NOTE(compnerd) we do not have an object compile rule since we build the objects as part of the link step
+if(NOT CMAKE_Swift_COMPILE_OBJECT)
+ set(CMAKE_Swift_COMPILE_OBJECT ":")
endif()
-include(CMakeCommonLanguageInclude)
+if(NOT CMAKE_Swift_NUM_THREADS MATCHES "^[0-9]+$")
+ cmake_host_system_information(RESULT CMAKE_Swift_NUM_THREADS QUERY NUMBER_OF_LOGICAL_CORES)
+endif()
+
+if(CMAKE_SYSTEM_NAME STREQUAL Windows)
+ set(CMAKE_Swift_IMPLIB_LINKER_FLAGS "-Xlinker -implib:<TARGET_IMPLIB>")
+endif()
+
+if(NOT CMAKE_Swift_CREATE_SHARED_LIBRARY)
+ set(CMAKE_Swift_CREATE_SHARED_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -j ${CMAKE_Swift_NUM_THREADS} -emit-library -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <LINK_LIBRARIES>")
+endif()
+
+if(NOT CMAKE_Swift_CREATE_SHARED_MODULE)
+ set(CMAKE_Swift_CREATE_SHARED_MODULE ${CMAKE_Swift_CREATE_SHARED_LIBRARY})
+endif()
+
+if(NOT CMAKE_Swift_LINK_EXECUTABLE)
+ set(CMAKE_Swift_LINK_EXECUTABLE "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -j ${CMAKE_Swift_NUM_THREADS} -emit-executable -o <TARGET> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <LINK_LIBRARIES>")
+endif()
+
+if(NOT CMAKE_Swift_CREATE_STATIC_LIBRARY)
+ set(CMAKE_Swift_CREATE_STATIC_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -j ${CMAKE_Swift_NUM_THREADS} -emit-library -static -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>")
+
+ set(CMAKE_Swift_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <OBJECTS>")
+ set(CMAKE_Swift_ARCHIVE_FINISH "")
+endif()
set(CMAKE_Swift_INFORMATION_LOADED 1)
diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake
index 03f348d72..ea3a445b6 100644
--- a/Modules/CMakeSystemSpecificInformation.cmake
+++ b/Modules/CMakeSystemSpecificInformation.cmake
@@ -27,17 +27,16 @@ include(${CMAKE_SYSTEM_INFO_FILE} OPTIONAL RESULT_VARIABLE _INCLUDED_SYSTEM_INFO
if(NOT _INCLUDED_SYSTEM_INFO_FILE)
message("System is unknown to cmake, create:\n${CMAKE_SYSTEM_INFO_FILE}"
- " to use this system, please send your config file to "
- "cmake@www.cmake.org so it can be added to cmake")
+ " to use this system, please post your config file on "
+ "discourse.cmake.org so it can be added to cmake")
if(EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt)
configure_file(${CMAKE_BINARY_DIR}/CMakeCache.txt
${CMAKE_BINARY_DIR}/CopyOfCMakeCache.txt COPYONLY)
message("Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. "
- "Please send that file to cmake@www.cmake.org.")
- endif()
+ "Please post that file on discourse.cmake.org.")
+ endif()
endif()
-
# optionally include a file which can do extra-generator specific things, e.g.
# CMakeFindEclipseCDT4.cmake asks gcc for the system include dirs for the Eclipse CDT4 generator
if(CMAKE_EXTRA_GENERATOR)
diff --git a/Modules/CMakeSystemSpecificInitialize.cmake b/Modules/CMakeSystemSpecificInitialize.cmake
index 6200e9c0d..21bcd403c 100644
--- a/Modules/CMakeSystemSpecificInitialize.cmake
+++ b/Modules/CMakeSystemSpecificInitialize.cmake
@@ -5,6 +5,19 @@
# This file is included by cmGlobalGenerator::EnableLanguage.
# It is included before the compiler has been determined.
+# The CMAKE_EFFECTIVE_SYSTEM_NAME is used to load compiler and compiler
+# wrapper configuration files. By default it equals to CMAKE_SYSTEM_NAME
+# but could be overridden in the ${CMAKE_SYSTEM_NAME}-Initialize files.
+#
+# It is useful to share the same aforementioned configuration files and
+# avoids duplicating them in case of tightly related platforms.
+#
+# An example are the platforms supported by Xcode (macOS, iOS, tvOS,
+# and watchOS). For all of those the CMAKE_EFFECTIVE_SYSTEM_NAME is
+# set to Apple which results in using
+# Platform/Apple-AppleClang-CXX.cmake for the Apple C++ compiler.
+set(CMAKE_EFFECTIVE_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}")
+
include(Platform/${CMAKE_SYSTEM_NAME}-Initialize OPTIONAL)
set(CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED 1)
diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake
index 7f199699e..7bf6fde3b 100644
--- a/Modules/CMakeTestCCompiler.cmake
+++ b/Modules/CMakeTestCCompiler.cmake
@@ -11,6 +11,12 @@ endif()
include(CMakeTestCompilerCommon)
+# work around enforced code signing and / or missing exectuable target type
+set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
+if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE)
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE})
+endif()
+
# Remove any cached result from an older CMake version.
# We now store this in CMakeCCompiler.cmake.
unset(CMAKE_C_COMPILER_WORKS CACHE)
@@ -22,6 +28,7 @@ unset(CMAKE_C_COMPILER_WORKS CACHE)
# any makefiles or projects.
if(NOT CMAKE_C_COMPILER_WORKS)
PrintTestCompilerStatus("C" "")
+ __TestCompiler_setTryCompileTargetType()
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c
"#ifdef __cplusplus\n"
"# error \"The CMAKE_C_COMPILER is set to a C++ compiler\"\n"
@@ -41,6 +48,7 @@ if(NOT CMAKE_C_COMPILER_WORKS)
set(CMAKE_C_COMPILER_WORKS ${CMAKE_C_COMPILER_WORKS})
unset(CMAKE_C_COMPILER_WORKS CACHE)
set(C_TEST_WAS_RUN 1)
+ __TestCompiler_restoreTryCompileTargetType()
endif()
if(NOT CMAKE_C_COMPILER_WORKS)
@@ -48,9 +56,10 @@ if(NOT CMAKE_C_COMPILER_WORKS)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the C compiler works failed with "
"the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n")
- message(FATAL_ERROR "The C compiler \"${CMAKE_C_COMPILER}\" "
+ string(REPLACE "\n" "\n " _output "${__CMAKE_C_COMPILER_OUTPUT}")
+ message(FATAL_ERROR "The C compiler\n \"${CMAKE_C_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
- "with the following output:\n ${__CMAKE_C_COMPILER_OUTPUT}\n\n"
+ "with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(C_TEST_WAS_RUN)
@@ -83,4 +92,6 @@ else()
endif()
endif()
+set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE})
+unset(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE)
unset(__CMAKE_C_COMPILER_OUTPUT)
diff --git a/Modules/CMakeTestCSharpCompiler.cmake b/Modules/CMakeTestCSharpCompiler.cmake
index 1a8bf32e0..6715c30db 100644
--- a/Modules/CMakeTestCSharpCompiler.cmake
+++ b/Modules/CMakeTestCSharpCompiler.cmake
@@ -15,7 +15,7 @@ unset(CMAKE_CSharp_COMPILER_WORKS CACHE)
set(test_compile_file "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCSharpCompiler.cs")
# This file is used by EnableLanguage in cmGlobalGenerator to
-# determine that that selected C# compiler can actually compile
+# determine that the selected C# compiler can actually compile
# and link the most basic of programs. If not, a fatal error
# is set and cmake stops processing commands and will not generate
# any makefiles or projects.
@@ -42,9 +42,10 @@ if(NOT CMAKE_CSharp_COMPILER_WORKS)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the C# compiler works failed with "
"the following output:\n${__CMAKE_CSharp_COMPILER_OUTPUT}\n\n")
- message(FATAL_ERROR "The C# compiler \"${CMAKE_CSharp_COMPILER}\" "
+ string(REPLACE "\n" "\n " _output "${__CMAKE_CSharp_COMPILER_OUTPUT}")
+ message(FATAL_ERROR "The C# compiler\n \"${CMAKE_CSharp_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
- "with the following output:\n ${__CMAKE_CSharp_COMPILER_OUTPUT}\n\n"
+ "with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(CSharp_TEST_WAS_RUN)
diff --git a/Modules/CMakeTestCUDACompiler.cmake b/Modules/CMakeTestCUDACompiler.cmake
index 80113cb4a..f0454da67 100644
--- a/Modules/CMakeTestCUDACompiler.cmake
+++ b/Modules/CMakeTestCUDACompiler.cmake
@@ -15,7 +15,7 @@ include(CMakeTestCompilerCommon)
unset(CMAKE_CUDA_COMPILER_WORKS CACHE)
# This file is used by EnableLanguage in cmGlobalGenerator to
-# determine that that selected cuda compiler can actually compile
+# determine that the selected cuda compiler can actually compile
# and link the most basic of programs. If not, a fatal error
# is set and cmake stops processing commands and will not generate
# any makefiles or projects.
@@ -42,9 +42,10 @@ if(NOT CMAKE_CUDA_COMPILER_WORKS)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the CUDA compiler works failed with "
"the following output:\n${__CMAKE_CUDA_COMPILER_OUTPUT}\n\n")
- message(FATAL_ERROR "The CUDA compiler \"${CMAKE_CUDA_COMPILER}\" "
+ string(REPLACE "\n" "\n " _output "${__CMAKE_CUDA_COMPILER_OUTPUT}")
+ message(FATAL_ERROR "The CUDA compiler\n \"${CMAKE_CUDA_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
- "with the following output:\n ${__CMAKE_CUDA_COMPILER_OUTPUT}\n\n"
+ "with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(CUDA_TEST_WAS_RUN)
diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake
index a31067b60..7e595b74f 100644
--- a/Modules/CMakeTestCXXCompiler.cmake
+++ b/Modules/CMakeTestCXXCompiler.cmake
@@ -11,17 +11,24 @@ endif()
include(CMakeTestCompilerCommon)
+# work around enforced code signing and / or missing exectuable target type
+set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
+if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE)
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE})
+endif()
+
# Remove any cached result from an older CMake version.
# We now store this in CMakeCXXCompiler.cmake.
unset(CMAKE_CXX_COMPILER_WORKS CACHE)
# This file is used by EnableLanguage in cmGlobalGenerator to
-# determine that that selected C++ compiler can actually compile
+# determine that the selected C++ compiler can actually compile
# and link the most basic of programs. If not, a fatal error
# is set and cmake stops processing commands and will not generate
# any makefiles or projects.
if(NOT CMAKE_CXX_COMPILER_WORKS)
PrintTestCompilerStatus("CXX" "")
+ __TestCompiler_setTryCompileTargetType()
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx
"#ifndef __cplusplus\n"
"# error \"The CMAKE_CXX_COMPILER is set to a C compiler\"\n"
@@ -34,6 +41,7 @@ if(NOT CMAKE_CXX_COMPILER_WORKS)
set(CMAKE_CXX_COMPILER_WORKS ${CMAKE_CXX_COMPILER_WORKS})
unset(CMAKE_CXX_COMPILER_WORKS CACHE)
set(CXX_TEST_WAS_RUN 1)
+ __TestCompiler_restoreTryCompileTargetType()
endif()
if(NOT CMAKE_CXX_COMPILER_WORKS)
@@ -41,9 +49,10 @@ if(NOT CMAKE_CXX_COMPILER_WORKS)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the CXX compiler works failed with "
"the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n")
- message(FATAL_ERROR "The C++ compiler \"${CMAKE_CXX_COMPILER}\" "
+ string(REPLACE "\n" "\n " _output "${__CMAKE_CXX_COMPILER_OUTPUT}")
+ message(FATAL_ERROR "The C++ compiler\n \"${CMAKE_CXX_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
- "with the following output:\n ${__CMAKE_CXX_COMPILER_OUTPUT}\n\n"
+ "with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(CXX_TEST_WAS_RUN)
@@ -76,4 +85,6 @@ else()
endif()
endif()
+set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE})
+unset(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE)
unset(__CMAKE_CXX_COMPILER_OUTPUT)
diff --git a/Modules/CMakeTestCompilerCommon.cmake b/Modules/CMakeTestCompilerCommon.cmake
index f76076fe2..6ee5175dd 100644
--- a/Modules/CMakeTestCompilerCommon.cmake
+++ b/Modules/CMakeTestCompilerCommon.cmake
@@ -5,3 +5,23 @@
function(PrintTestCompilerStatus LANG MSG)
message(STATUS "Check for working ${LANG} compiler: ${CMAKE_${LANG}_COMPILER}${MSG}")
endfunction()
+
+# if required set the target type if not already explicitly set
+macro(__TestCompiler_setTryCompileTargetType)
+ if(NOT CMAKE_TRY_COMPILE_TARGET_TYPE)
+ if("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI")
+ #prefer static libraries to avoid linking issues
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+ set(__CMAKE_TEST_COMPILER_TARGET_TYPE_RESTORE 1)
+ endif()
+ endif()
+endmacro()
+
+# restore the original value
+# -- not necessary if __TestCompiler_setTryCompileTargetType() was used in function scope
+macro(__TestCompiler_restoreTryCompileTargetType)
+ if(__CMAKE_TEST_COMPILER_TARGET_TYPE_RESTORE)
+ unset(CMAKE_TRY_COMPILE_TARGET_TYPE)
+ unset(__CMAKE_TEST_COMPILER_TARGET_TYPE_RESTORE)
+ endif()
+endmacro()
diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake
index c81694ef9..e9860e9de 100644
--- a/Modules/CMakeTestFortranCompiler.cmake
+++ b/Modules/CMakeTestFortranCompiler.cmake
@@ -16,7 +16,7 @@ include(CMakeTestCompilerCommon)
unset(CMAKE_Fortran_COMPILER_WORKS CACHE)
# This file is used by EnableLanguage in cmGlobalGenerator to
-# determine that that selected Fortran compiler can actually compile
+# determine that the selected Fortran compiler can actually compile
# and link the most basic of programs. If not, a fatal error
# is set and cmake stops processing commands and will not generate
# any makefiles or projects.
@@ -41,9 +41,10 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the Fortran compiler works failed with "
"the following output:\n${OUTPUT}\n\n")
- message(FATAL_ERROR "The Fortran compiler \"${CMAKE_Fortran_COMPILER}\" "
+ string(REPLACE "\n" "\n " _output "${OUTPUT}")
+ message(FATAL_ERROR "The Fortran compiler\n \"${CMAKE_Fortran_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
- "with the following output:\n ${OUTPUT}\n\n"
+ "with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(FORTRAN_TEST_WAS_RUN)
diff --git a/Modules/CMakeTestJavaCompiler.cmake b/Modules/CMakeTestJavaCompiler.cmake
index 23fdbdce7..3c33573b9 100644
--- a/Modules/CMakeTestJavaCompiler.cmake
+++ b/Modules/CMakeTestJavaCompiler.cmake
@@ -3,7 +3,7 @@
# This file is used by EnableLanguage in cmGlobalGenerator to
-# determine that that selected Fortran compiler can actually compile
+# determine that the selected Fortran compiler can actually compile
# and link the most basic of programs. If not, a fatal error
# is set and cmake stops processing commands and will not generate
# any makefiles or projects.
diff --git a/Modules/CMakeTestOBJCCompiler.cmake b/Modules/CMakeTestOBJCCompiler.cmake
new file mode 100644
index 000000000..003068322
--- /dev/null
+++ b/Modules/CMakeTestOBJCCompiler.cmake
@@ -0,0 +1,94 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+if(CMAKE_OBJC_COMPILER_FORCED)
+ # The compiler configuration was forced by the user.
+ # Assume the user has configured all compiler information.
+ set(CMAKE_OBJC_COMPILER_WORKS TRUE)
+ return()
+endif()
+
+include(CMakeTestCompilerCommon)
+
+# work around enforced code signing and / or missing exectuable target type
+set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
+if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE)
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE})
+endif()
+
+# Remove any cached result from an older CMake version.
+# We now store this in CMakeCCompiler.cmake.
+unset(CMAKE_OBJC_COMPILER_WORKS CACHE)
+
+# This file is used by EnableLanguage in cmGlobalGenerator to
+# determine that that selected Objective-C compiler can actually compile
+# and link the most basic of programs. If not, a fatal error
+# is set and cmake stops processing commands and will not generate
+# any makefiles or projects.
+if(NOT CMAKE_OBJC_COMPILER_WORKS)
+ PrintTestCompilerStatus("OBJC" "")
+ __TestCompiler_setTryCompileTargetType()
+ file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m
+ "#ifdef __cplusplus\n"
+ "# error \"The CMAKE_OBJC_COMPILER is set to a C++ compiler\"\n"
+ "#endif\n"
+ "#ifndef __OBJC__\n"
+ "# error \"The CMAKE_OBJC_COMPILER is not an Objective-C compiler\"\n"
+ "#endif\n"
+ "int main(int argc, char* argv[])\n"
+ "{ (void)argv; return argc-1;}\n")
+ try_compile(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m
+ OUTPUT_VARIABLE __CMAKE_OBJC_COMPILER_OUTPUT)
+ # Move result from cache to normal variable.
+ set(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_OBJC_COMPILER_WORKS})
+ unset(CMAKE_OBJC_COMPILER_WORKS CACHE)
+ set(OBJC_TEST_WAS_RUN 1)
+ __TestCompiler_restoreTryCompileTargetType()
+endif()
+
+if(NOT CMAKE_OBJC_COMPILER_WORKS)
+ PrintTestCompilerStatus("OBJC" " -- broken")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if the Objective-C compiler works failed with "
+ "the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n")
+ string(REPLACE "\n" "\n " _output "${__CMAKE_OBJC_COMPILER_OUTPUT}")
+ message(FATAL_ERROR "The Objective-C compiler\n \"${CMAKE_OBJC_COMPILER}\"\n"
+ "is not able to compile a simple test program.\nIt fails "
+ "with the following output:\n ${_output}\n\n"
+ "CMake will not be able to correctly generate this project.")
+else()
+ if(OBJC_TEST_WAS_RUN)
+ PrintTestCompilerStatus("OBJC" " -- works")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining if the Objective-C compiler works passed with "
+ "the following output:\n${__CMAKE_OBJC_COMPILER_OUTPUT}\n\n")
+ endif()
+
+ # Try to identify the ABI and configure it into CMakeOBJCCompiler.cmake
+ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
+ CMAKE_DETERMINE_COMPILER_ABI(OBJC ${CMAKE_ROOT}/Modules/CMakeOBJCCompilerABI.m)
+ # Try to identify the compiler features
+ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake)
+ CMAKE_DETERMINE_COMPILE_FEATURES(OBJC)
+
+ # Re-configure to save learned information.
+ configure_file(
+ ${CMAKE_ROOT}/Modules/CMakeOBJCCompiler.cmake.in
+ ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake
+ @ONLY
+ )
+ include(${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCCompiler.cmake)
+
+ if(CMAKE_OBJC_SIZEOF_DATA_PTR)
+ foreach(f ${CMAKE_OBJC_ABI_FILES})
+ include(${f})
+ endforeach()
+ unset(CMAKE_OBJC_ABI_FILES)
+ endif()
+endif()
+
+set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE})
+unset(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE)
+unset(__CMAKE_OBJC_COMPILER_OUTPUT)
diff --git a/Modules/CMakeTestOBJCXXCompiler.cmake b/Modules/CMakeTestOBJCXXCompiler.cmake
new file mode 100644
index 000000000..bcce2f148
--- /dev/null
+++ b/Modules/CMakeTestOBJCXXCompiler.cmake
@@ -0,0 +1,93 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+if(CMAKE_OBJCXX_COMPILER_FORCED)
+ # The compiler configuration was forced by the user.
+ # Assume the user has configured all compiler information.
+ set(CMAKE_OBJCXX_COMPILER_WORKS TRUE)
+ return()
+endif()
+
+include(CMakeTestCompilerCommon)
+
+# work around enforced code signing and / or missing exectuable target type
+set(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
+if(_CMAKE_FEATURE_DETECTION_TARGET_TYPE)
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE ${_CMAKE_FEATURE_DETECTION_TARGET_TYPE})
+endif()
+
+# Remove any cached result from an older CMake version.
+# We now store this in CMakeOBJCXXCompiler.cmake.
+unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE)
+
+# This file is used by EnableLanguage in cmGlobalGenerator to
+# determine that the selected Objective-C++ compiler can actually compile
+# and link the most basic of programs. If not, a fatal error
+# is set and cmake stops processing commands and will not generate
+# any makefiles or projects.
+if(NOT CMAKE_OBJCXX_COMPILER_WORKS)
+ PrintTestCompilerStatus("OBJCXX" "")
+ __TestCompiler_setTryCompileTargetType()
+ file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCXXCompiler.mm
+ "#ifndef __cplusplus\n"
+ "# error \"The CMAKE_OBJCXX_COMPILER is set to a C compiler\"\n"
+ "#endif\n"
+ "#ifndef __OBJC__\n"
+ "# error \"The CMAKE_OBJCXX_COMPILER is not an Objective-C++ compiler\"\n"
+ "#endif\n"
+ "int main(){return 0;}\n")
+ try_compile(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCXXCompiler.mm
+ OUTPUT_VARIABLE __CMAKE_OBJCXX_COMPILER_OUTPUT)
+ # Move result from cache to normal variable.
+ set(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_OBJCXX_COMPILER_WORKS})
+ unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE)
+ set(OBJCXX_TEST_WAS_RUN 1)
+ __TestCompiler_restoreTryCompileTargetType()
+endif()
+
+if(NOT CMAKE_OBJCXX_COMPILER_WORKS)
+ PrintTestCompilerStatus("OBJCXX" " -- broken")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if the Objective-C++ compiler works failed with "
+ "the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n")
+ string(REPLACE "\n" "\n " _output "${__CMAKE_OBJCXX_COMPILER_OUTPUT}")
+ message(FATAL_ERROR "The Objective-C++ compiler\n \"${CMAKE_OBJCXX_COMPILER}\"\n"
+ "is not able to compile a simple test program.\nIt fails "
+ "with the following output:\n ${_output}\n\n"
+ "CMake will not be able to correctly generate this project.")
+else()
+ if(OBJCXX_TEST_WAS_RUN)
+ PrintTestCompilerStatus("OBJCXX" " -- works")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining if the Objective-C++ compiler works passed with "
+ "the following output:\n${__CMAKE_OBJCXX_COMPILER_OUTPUT}\n\n")
+ endif()
+
+ # Try to identify the ABI and configure it into CMakeOBJCXXCompiler.cmake
+ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
+ CMAKE_DETERMINE_COMPILER_ABI(OBJCXX ${CMAKE_ROOT}/Modules/CMakeOBJCXXCompilerABI.mm)
+ # Try to identify the compiler features
+ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake)
+ CMAKE_DETERMINE_COMPILE_FEATURES(OBJCXX)
+
+ # Re-configure to save learned information.
+ configure_file(
+ ${CMAKE_ROOT}/Modules/CMakeOBJCXXCompiler.cmake.in
+ ${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake
+ @ONLY
+ )
+ include(${CMAKE_PLATFORM_INFO_DIR}/CMakeOBJCXXCompiler.cmake)
+
+ if(CMAKE_OBJCXX_SIZEOF_DATA_PTR)
+ foreach(f ${CMAKE_OBJCXX_ABI_FILES})
+ include(${f})
+ endforeach()
+ unset(CMAKE_OBJCXX_ABI_FILES)
+ endif()
+endif()
+
+set(CMAKE_TRY_COMPILE_TARGET_TYPE ${__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE})
+unset(__CMAKE_SAVED_TRY_COMPILE_TARGET_TYPE)
+unset(__CMAKE_OBJCXX_COMPILER_OUTPUT)
diff --git a/Modules/CMakeTestRCCompiler.cmake b/Modules/CMakeTestRCCompiler.cmake
index c510d3a80..3123a6cf4 100644
--- a/Modules/CMakeTestRCCompiler.cmake
+++ b/Modules/CMakeTestRCCompiler.cmake
@@ -3,7 +3,7 @@
# This file is used by EnableLanguage in cmGlobalGenerator to
-# determine that that selected RC compiler can actually compile
+# determine that the selected RC compiler can actually compile
# and link the most basic of programs. If not, a fatal error
# is set and cmake stops processing commands and will not generate
# any makefiles or projects.
diff --git a/Modules/CMakeTestSwiftCompiler.cmake b/Modules/CMakeTestSwiftCompiler.cmake
index 6393f44a0..841aee643 100644
--- a/Modules/CMakeTestSwiftCompiler.cmake
+++ b/Modules/CMakeTestSwiftCompiler.cmake
@@ -1,7 +1,6 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-
if(CMAKE_Swift_COMPILER_FORCED)
# The compiler configuration was forced by the user.
# Assume the user has configured all compiler information.
@@ -16,14 +15,13 @@ include(CMakeTestCompilerCommon)
unset(CMAKE_Swift_COMPILER_WORKS CACHE)
# This file is used by EnableLanguage in cmGlobalGenerator to
-# determine that that selected C++ compiler can actually compile
+# determine that the selected C++ compiler can actually compile
# and link the most basic of programs. If not, a fatal error
# is set and cmake stops processing commands and will not generate
# any makefiles or projects.
if(NOT CMAKE_Swift_COMPILER_WORKS)
PrintTestCompilerStatus("Swift" "")
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.swift
- "import Foundation\n"
"print(\"CMake\")\n")
try_compile(CMAKE_Swift_COMPILER_WORKS ${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.swift
@@ -39,9 +37,10 @@ if(NOT CMAKE_Swift_COMPILER_WORKS)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the Swift compiler works failed with "
"the following output:\n${__CMAKE_Swift_COMPILER_OUTPUT}\n\n")
- message(FATAL_ERROR "The Swift compiler \"${CMAKE_Swift_COMPILER}\" "
+ string(REPLACE "\n" "\n " _output "${__CMAKE_Swift_COMPILER_OUTPUT}")
+ message(FATAL_ERROR "The Swift compiler\n \"${CMAKE_Swift_COMPILER}\"\n"
"is not able to compile a simple test program.\nIt fails "
- "with the following output:\n ${__CMAKE_Swift_COMPILER_OUTPUT}\n\n"
+ "with the following output:\n ${_output}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(Swift_TEST_WAS_RUN)
@@ -50,6 +49,11 @@ else()
"Determining if the Swift compiler works passed with "
"the following output:\n${__CMAKE_Swift_COMPILER_OUTPUT}\n\n")
endif()
+
+ # Re-configure to save learned information.
+ configure_file(${CMAKE_ROOT}/Modules/CMakeSwiftCompiler.cmake.in
+ ${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake @ONLY)
+ include(${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake)
endif()
unset(__CMAKE_Swift_COMPILER_OUTPUT)
diff --git a/Modules/CMakeVerifyManifest.cmake b/Modules/CMakeVerifyManifest.cmake
index c477ab1c2..705ef8aa7 100644
--- a/Modules/CMakeVerifyManifest.cmake
+++ b/Modules/CMakeVerifyManifest.cmake
@@ -1,22 +1,23 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CMakeVerifyManifest
-# -------------------
-#
-#
-#
-# CMakeVerifyManifest.cmake
-#
-# This script is used to verify that embedded manifests and side by side
-# manifests for a project match. To run this script, cd to a directory
-# and run the script with cmake -P. On the command line you can pass in
-# versions that are OK even if not found in the .manifest files. For
-# example, cmake -Dallow_versions=8.0.50608.0
-# -PCmakeVerifyManifest.cmake could be used to allow an embedded manifest
-# of 8.0.50608.0 to be used in a project even if that version was not
-# found in the .manifest file.
+#[=======================================================================[.rst:
+CMakeVerifyManifest
+-------------------
+
+
+
+CMakeVerifyManifest.cmake
+
+This script is used to verify that embedded manifests and side by side
+manifests for a project match. To run this script, cd to a directory
+and run the script with cmake -P. On the command line you can pass in
+versions that are OK even if not found in the .manifest files. For
+example, cmake -Dallow_versions=8.0.50608.0
+-PCmakeVerifyManifest.cmake could be used to allow an embedded manifest
+of 8.0.50608.0 to be used in a project even if that version was not
+found in the .manifest file.
+#]=======================================================================]
# This script first recursively globs *.manifest files from
# the current directory. Then globs *.exe and *.dll. Each
diff --git a/Modules/CPack.STGZ_Header.sh.in b/Modules/CPack.STGZ_Header.sh.in
deleted file mode 100755
index c61585136..000000000
--- a/Modules/CPack.STGZ_Header.sh.in
+++ /dev/null
@@ -1,144 +0,0 @@
-#!/bin/sh
-
-# Display usage
-cpack_usage()
-{
- cat <<EOF
-Usage: $0 [options]
-Options: [defaults in brackets after descriptions]
- --help print this message
- --prefix=dir directory in which to install
- --include-subdir include the @CPACK_PACKAGE_FILE_NAME@ subdirectory
- --exclude-subdir exclude the @CPACK_PACKAGE_FILE_NAME@ subdirectory
-EOF
- exit 1
-}
-
-cpack_echo_exit()
-{
- echo $1
- exit 1
-}
-
-# Display version
-cpack_version()
-{
- echo "@CPACK_PACKAGE_NAME@ Installer Version: @CPACK_PACKAGE_VERSION@, Copyright (c) @CPACK_PACKAGE_VENDOR@"
-}
-
-# Helper function to fix windows paths.
-cpack_fix_slashes ()
-{
- echo "$1" | sed 's/\\/\//g'
-}
-
-interactive=TRUE
-cpack_skip_license=FALSE
-cpack_include_subdir=""
-for a in "$@CPACK_AT_SIGN@"; do
- if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
- cpack_prefix_dir=`echo $a | sed "s/^--prefix=//"`
- cpack_prefix_dir=`cpack_fix_slashes "${cpack_prefix_dir}"`
- fi
- if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
- cpack_usage
- fi
- if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
- cpack_version
- exit 2
- fi
- if echo $a | grep "^--include-subdir" > /dev/null 2> /dev/null; then
- cpack_include_subdir=TRUE
- fi
- if echo $a | grep "^--exclude-subdir" > /dev/null 2> /dev/null; then
- cpack_include_subdir=FALSE
- fi
- if echo $a | grep "^--skip-license" > /dev/null 2> /dev/null; then
- cpack_skip_license=TRUE
- fi
-done
-
-if [ "x${cpack_include_subdir}x" != "xx" -o "x${cpack_skip_license}x" = "xTRUEx" ]
-then
- interactive=FALSE
-fi
-
-cpack_version
-echo "This is a self-extracting archive."
-toplevel="`pwd`"
-if [ "x${cpack_prefix_dir}x" != "xx" ]
-then
- toplevel="${cpack_prefix_dir}"
-fi
-
-echo "The archive will be extracted to: ${toplevel}"
-
-if [ "x${interactive}x" = "xTRUEx" ]
-then
- echo ""
- echo "If you want to stop extracting, please press <ctrl-C>."
-
- if [ "x${cpack_skip_license}x" != "xTRUEx" ]
- then
- more << '____cpack__here_doc____'
-@CPACK_RESOURCE_FILE_LICENSE_CONTENT@
-____cpack__here_doc____
- echo
- echo "Do you accept the license? [yN]: "
- read line leftover
- case ${line} in
- y* | Y*)
- cpack_license_accepted=TRUE;;
- *)
- echo "License not accepted. Exiting ..."
- exit 1;;
- esac
- fi
-
- if [ "x${cpack_include_subdir}x" = "xx" ]
- then
- echo "By default the @CPACK_PACKAGE_NAME@ will be installed in:"
- echo " \"${toplevel}/@CPACK_PACKAGE_FILE_NAME@\""
- echo "Do you want to include the subdirectory @CPACK_PACKAGE_FILE_NAME@?"
- echo "Saying no will install in: \"${toplevel}\" [Yn]: "
- read line leftover
- cpack_include_subdir=TRUE
- case ${line} in
- n* | N*)
- cpack_include_subdir=FALSE
- esac
- fi
-fi
-
-if [ "x${cpack_include_subdir}x" = "xTRUEx" ]
-then
- toplevel="${toplevel}/@CPACK_PACKAGE_FILE_NAME@"
- mkdir -p "${toplevel}"
-fi
-echo
-echo "Using target directory: ${toplevel}"
-echo "Extracting, please wait..."
-echo ""
-
-# take the archive portion of this file and pipe it to tar
-# the NUMERIC parameter in this command should be one more
-# than the number of lines in this header file
-# there are tails which don't understand the "-n" argument, e.g. on SunOS
-# OTOH there are tails which complain when not using the "-n" argument (e.g. GNU)
-# so at first try to tail some file to see if tail fails if used with "-n"
-# if so, don't use "-n"
-use_new_tail_syntax="-n"
-tail $use_new_tail_syntax +1 "$0" > /dev/null 2> /dev/null || use_new_tail_syntax=""
-
-extractor="pax -r"
-command -v pax > /dev/null 2> /dev/null || extractor="tar xf -"
-
-tail $use_new_tail_syntax +###CPACK_HEADER_LENGTH### "$0" | gunzip | (cd "${toplevel}" && ${extractor}) || cpack_echo_exit "Problem unpacking the @CPACK_PACKAGE_FILE_NAME@"
-
-echo "Unpacking finished successfully"
-
-exit 0
-#-----------------------------------------------------------
-# Start of TAR.GZ file
-#-----------------------------------------------------------;
-
diff --git a/Modules/CPack.background.png.in b/Modules/CPack.background.png.in
deleted file mode 100644
index 9339e7cad..000000000
--- a/Modules/CPack.background.png.in
+++ /dev/null
Binary files differ
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index a63fc8325..c2ed3de5f 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -1,298 +1,371 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CPack
-# -----
-#
-# Build binary and source package installers.
-#
-# Variables common to all CPack generators
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# The
-# CPack module generates binary and source installers in a variety of
-# formats using the cpack program. Inclusion of the CPack module adds
-# two new targets to the resulting makefiles, package and
-# package_source, which build the binary and source installers,
-# respectively. The generated binary installers contain everything
-# installed via CMake's INSTALL command (and the deprecated
-# INSTALL_FILES, INSTALL_PROGRAMS, and INSTALL_TARGETS commands).
-#
-# For certain kinds of binary installers (including the graphical
-# installers on Mac OS X and Windows), CPack generates installers that
-# allow users to select individual application components to install.
-# See CPackComponent module for that.
-#
-# The CPACK_GENERATOR variable has different meanings in different
-# contexts. In your CMakeLists.txt file, CPACK_GENERATOR is a *list of
-# generators*: when run with no other arguments, CPack will iterate over
-# that list and produce one package for each generator. In a
-# CPACK_PROJECT_CONFIG_FILE, though, CPACK_GENERATOR is a *string naming
-# a single generator*. If you need per-cpack- generator logic to
-# control *other* cpack settings, then you need a
-# CPACK_PROJECT_CONFIG_FILE.
-#
-# The CMake source tree itself contains a CPACK_PROJECT_CONFIG_FILE.
-# See the top level file CMakeCPackOptions.cmake.in for an example.
-#
-# If set, the CPACK_PROJECT_CONFIG_FILE is included automatically on a
-# per-generator basis. It only need contain overrides.
-#
-# Here's how it works:
-#
-# * cpack runs
-# * it includes CPackConfig.cmake
-# * it iterates over the generators listed in that file's
-# CPACK_GENERATOR list variable (unless told to use just a
-# specific one via -G on the command line...)
-# * foreach generator, it then
-#
-# - sets CPACK_GENERATOR to the one currently being iterated
-# - includes the CPACK_PROJECT_CONFIG_FILE
-# - produces the package for that generator
-#
-# This is the key: For each generator listed in CPACK_GENERATOR in
-# CPackConfig.cmake, cpack will *reset* CPACK_GENERATOR internally to
-# *the one currently being used* and then include the
-# CPACK_PROJECT_CONFIG_FILE.
-#
-# Before including this CPack module in your CMakeLists.txt file, there
-# are a variety of variables that can be set to customize the resulting
-# installers. The most commonly-used variables are:
-#
-# .. variable:: CPACK_PACKAGE_NAME
-#
-# The name of the package (or application). If not specified, defaults to
-# the project name.
-#
-# .. variable:: CPACK_PACKAGE_VENDOR
-#
-# The name of the package vendor. (e.g., "Kitware").
-#
-# .. variable:: CPACK_PACKAGE_DIRECTORY
-#
-# The directory in which CPack is doing its packaging. If it is not set
-# then this will default (internally) to the build dir. This variable may
-# be defined in CPack config file or from the cpack command line option
-# "-B". If set the command line option override the value found in the
-# config file.
-#
-# .. variable:: CPACK_PACKAGE_VERSION_MAJOR
-#
-# Package major Version
-#
-# .. variable:: CPACK_PACKAGE_VERSION_MINOR
-#
-# Package minor Version
-#
-# .. variable:: CPACK_PACKAGE_VERSION_PATCH
-#
-# Package patch Version
-#
-# .. variable:: CPACK_PACKAGE_DESCRIPTION_FILE
-#
-# A text file used to describe the project. Used, for example, the
-# introduction screen of a CPack-generated Windows installer to describe
-# the project.
-#
-# .. variable:: CPACK_PACKAGE_DESCRIPTION_SUMMARY
-#
-# Short description of the project (only a few words). Default value is::
-#
-# ${PROJECT_DESCRIPTION}
-#
-# if DESCRIPTION has given to the project() call or
-# CMake generated string with PROJECT_NAME otherwise.
-#
-# .. variable:: CPACK_PACKAGE_FILE_NAME
-#
-# The name of the package file to generate, not including the
-# extension. For example, cmake-2.6.1-Linux-i686. The default value is::
-#
-# ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}.
-#
-# .. variable:: CPACK_PACKAGE_INSTALL_DIRECTORY
-#
-# Installation directory on the target system. This may be used by some
-# CPack generators like NSIS to create an installation directory e.g.,
-# "CMake 2.5" below the installation prefix. All installed element will be
-# put inside this directory.
-#
-# .. variable:: CPACK_PACKAGE_ICON
-#
-# A branding image that will be displayed inside the installer (used by GUI
-# installers).
-#
-# .. variable:: CPACK_PACKAGE_CHECKSUM
-#
-# An algorithm that will be used to generate additional file with checksum
-# of the package. Output file name will be::
-#
-# ${CPACK_PACKAGE_FILE_NAME}.${CPACK_PACKAGE_CHECKSUM}
-#
-# Supported algorithms are those listed by the
-# :ref:`string(\<HASH\>) <Supported Hash Algorithms>`
-# command.
-#
-# .. variable:: CPACK_PROJECT_CONFIG_FILE
-#
-# CPack-time project CPack configuration file. This file included at cpack
-# time, once per generator after CPack has set CPACK_GENERATOR to the
-# actual generator being used. It allows per-generator setting of CPACK_*
-# variables at cpack time.
-#
-# .. variable:: CPACK_RESOURCE_FILE_LICENSE
-#
-# License to be embedded in the installer. It will typically be displayed
-# to the user by the produced installer (often with an explicit "Accept"
-# button, for graphical installers) prior to installation. This license
-# file is NOT added to installed file but is used by some CPack generators
-# like NSIS. If you want to install a license file (may be the same as this
-# one) along with your project you must add an appropriate CMake INSTALL
-# command in your CMakeLists.txt.
-#
-# .. variable:: CPACK_RESOURCE_FILE_README
-#
-# ReadMe file to be embedded in the installer. It typically describes in
-# some detail the purpose of the project during the installation. Not all
-# CPack generators uses this file.
-#
-# .. variable:: CPACK_RESOURCE_FILE_WELCOME
-#
-# Welcome file to be embedded in the installer. It welcomes users to this
-# installer. Typically used in the graphical installers on Windows and Mac
-# OS X.
-#
-# .. variable:: CPACK_MONOLITHIC_INSTALL
-#
-# Disables the component-based installation mechanism. When set the
-# component specification is ignored and all installed items are put in a
-# single "MONOLITHIC" package. Some CPack generators do monolithic
-# packaging by default and may be asked to do component packaging by
-# setting CPACK_<GENNAME>_COMPONENT_INSTALL to 1/TRUE.
-#
-# .. variable:: CPACK_GENERATOR
-#
-# List of CPack generators to use. If not specified, CPack will create a
-# set of options CPACK_BINARY_<GENNAME> (e.g., CPACK_BINARY_NSIS) allowing
-# the user to enable/disable individual generators. This variable may be
-# used on the command line as well as in::
-#
-# cpack -D CPACK_GENERATOR="ZIP;TGZ" /path/to/build/tree
-#
-# .. variable:: CPACK_OUTPUT_CONFIG_FILE
-#
-# The name of the CPack binary configuration file. This file is the CPack
-# configuration generated by the CPack module for binary
-# installers. Defaults to CPackConfig.cmake.
-#
-# .. variable:: CPACK_PACKAGE_EXECUTABLES
-#
-# 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 ccmake. Not all CPack generators use it (at least
-# NSIS, WIX and OSXX11 do).
-#
-# .. variable:: CPACK_STRIP_FILES
-#
-# List of files to be stripped. Starting with CMake 2.6.0 CPACK_STRIP_FILES
-# will be a boolean variable which enables stripping of all files (a list
-# of files evaluates to TRUE in CMake, so this change is compatible).
-#
-# .. variable:: CPACK_VERBATIM_VARIABLES
-#
-# If set to TRUE, values of variables prefixed with CPACK_ will be escaped
-# before being written to the configuration files, so that the cpack program
-# receives them exactly as they were specified. If not, characters like quotes
-# and backslashes can cause parsing errors or alter the value received by the
-# cpack program. Defaults to FALSE for backwards compatibility.
-#
-# * Mandatory : NO
-# * Default : FALSE
-#
-# The following CPack variables are specific to source packages, and
-# will not affect binary packages:
-#
-# .. variable:: CPACK_SOURCE_PACKAGE_FILE_NAME
-#
-# The name of the source package. For example cmake-2.6.1.
-#
-# .. variable:: CPACK_SOURCE_STRIP_FILES
-#
-# List of files in the source tree that will be stripped. Starting with
-# CMake 2.6.0 CPACK_SOURCE_STRIP_FILES will be a boolean variable which
-# enables stripping of all files (a list of files evaluates to TRUE in
-# CMake, so this change is compatible).
-#
-# .. variable:: CPACK_SOURCE_GENERATOR
-#
-# List of generators used for the source packages. As with CPACK_GENERATOR,
-# if this is not specified then CPack will create a set of options (e.g.,
-# CPACK_SOURCE_ZIP) allowing users to select which packages will be
-# generated.
-#
-# .. variable:: CPACK_SOURCE_OUTPUT_CONFIG_FILE
-#
-# The name of the CPack source configuration file. This file is the CPack
-# configuration generated by the CPack module for source
-# installers. Defaults to CPackSourceConfig.cmake.
-#
-# .. variable:: CPACK_SOURCE_IGNORE_FILES
-#
-# Pattern of files in the source tree that won't be packaged when building
-# a source package. This is a list of regular expression patterns (that
-# must be properly escaped), e.g.,
-# /CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~;cscope.*
-#
-# The following variables are for advanced uses of CPack:
-#
-# .. variable:: CPACK_CMAKE_GENERATOR
-#
-# What CMake generator should be used if the project is CMake
-# project. Defaults to the value of CMAKE_GENERATOR few users will want to
-# change this setting.
-#
-# .. variable:: CPACK_INSTALL_CMAKE_PROJECTS
-#
-# List of four values that specify what project to install. The four values
-# are: Build directory, Project Name, Project Component, Directory. If
-# omitted, CPack will build an installer that installs everything.
-#
-# .. variable:: CPACK_SYSTEM_NAME
-#
-# System name, defaults to the value of ${CMAKE_SYSTEM_NAME}.
-#
-# .. variable:: CPACK_PACKAGE_VERSION
-#
-# Package full version, used internally. By default, this is built from
-# CPACK_PACKAGE_VERSION_MAJOR, CPACK_PACKAGE_VERSION_MINOR, and
-# CPACK_PACKAGE_VERSION_PATCH.
-#
-# .. variable:: CPACK_TOPLEVEL_TAG
-#
-# Directory for the installed files.
-#
-# .. variable:: CPACK_INSTALL_COMMANDS
-#
-# Extra commands to install components.
-#
-# .. variable:: CPACK_INSTALLED_DIRECTORIES
-#
-# Extra directories to install.
-#
-# .. variable:: CPACK_PACKAGE_INSTALL_REGISTRY_KEY
-#
-# Registry key used when installing this project. This is only used by
-# installer for Windows. The default value is based on the installation
-# directory.
-#
-# .. variable:: CPACK_CREATE_DESKTOP_LINKS
-#
-# List of desktop links to create.
-# Each desktop link requires a corresponding start menu shortcut
-# as created by :variable:`CPACK_PACKAGE_EXECUTABLES`.
+#[=======================================================================[.rst:
+CPack
+-----
+
+Build binary and source package installers.
+
+Introduction
+^^^^^^^^^^^^
+
+The CPack module generates a file ``CPackConfig.cmake`` intended for
+use in a subsequent run of the :manual:`cpack <cpack(1)>` program
+where it steers the generation of installers or/and source packages.
+
+Inclusion of the CPack module adds two new build targets, ``package``
+and ``package_source``, which build the binary and source installers
+respectively. The generated binary installers contain everything
+installed via CMake's :command:`install` command (and the deprecated
+commands :command:`install_files`, :command:`install_programs`, and
+:command:`install_targets`).
+
+For certain kinds of binary installers (including the graphical
+installers on macOS and Windows), CPack generates installers that
+allow users to select individual application components to install.
+See :module:`CPackComponent` module for further details.
+
+CPack Generators
+^^^^^^^^^^^^^^^^
+
+The :variable:`CPACK_GENERATOR` variable has different meanings in different
+contexts. In a ``CMakeLists.txt`` file, :variable:`CPACK_GENERATOR` is a
+*list of generators*: and when :manual:`cpack <cpack(1)>` is run with no other
+arguments, it will iterate over that list and produce one package for each
+generator. In a :variable:`CPACK_PROJECT_CONFIG_FILE`,
+:variable:`CPACK_GENERATOR` is a *string naming a single generator*. If you
+need per-cpack-generator logic to control *other* cpack settings, then you
+need a :variable:`CPACK_PROJECT_CONFIG_FILE`.
+
+The CMake source tree itself contains a :variable:`CPACK_PROJECT_CONFIG_FILE`.
+See the top level file ``CMakeCPackOptions.cmake.in`` for an example.
+
+If set, the :variable:`CPACK_PROJECT_CONFIG_FILE` is included automatically
+on a per-generator basis. It only need contain overrides.
+
+Here's how it works:
+
+* :manual:`cpack <cpack(1)>` runs
+* it includes ``CPackConfig.cmake``
+* it iterates over the generators given by the ``-G`` command line option,
+ or if no such option was specified, over the list of generators given by
+ the :variable:`CPACK_GENERATOR` variable set in the ``CPackConfig.cmake``
+ input file.
+* foreach generator, it then
+
+ - sets :variable:`CPACK_GENERATOR` to the one currently being iterated
+ - includes the :variable:`CPACK_PROJECT_CONFIG_FILE`
+ - produces the package for that generator
+
+This is the key: For each generator listed in :variable:`CPACK_GENERATOR` in
+``CPackConfig.cmake``, cpack will *reset* :variable:`CPACK_GENERATOR`
+internally to *the one currently being used* and then include the
+:variable:`CPACK_PROJECT_CONFIG_FILE`.
+
+Variables common to all CPack Generators
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Before including this CPack module in your ``CMakeLists.txt`` file, there
+are a variety of variables that can be set to customize the resulting
+installers. The most commonly-used variables are:
+
+.. variable:: CPACK_PACKAGE_NAME
+
+ The name of the package (or application). If not specified, it defaults to
+ the project name.
+
+.. variable:: CPACK_PACKAGE_VENDOR
+
+ The name of the package vendor. (e.g., "Kitware"). The default is "Humanity".
+
+.. variable:: CPACK_PACKAGE_DIRECTORY
+
+ The directory in which CPack is doing its packaging. If it is not set
+ then this will default (internally) to the build dir. This variable may
+ be defined in a CPack config file or from the :manual:`cpack <cpack(1)>`
+ command line option ``-B``. If set, the command line option overrides the
+ value found in the config file.
+
+.. variable:: CPACK_PACKAGE_VERSION_MAJOR
+
+ Package major version. This variable will always be set, but its default
+ value depends on whether or not version details were given to the
+ :command:`project` command in the top level CMakeLists.txt file. If version
+ details were given, the default value will be
+ :variable:`CMAKE_PROJECT_VERSION_MAJOR`. If no version details were given,
+ a default version of 0.1.1 will be assumed, leading to
+ ``CPACK_PACKAGE_VERSION_MAJOR`` having a default value of 0.
+
+.. variable:: CPACK_PACKAGE_VERSION_MINOR
+
+ Package minor version. The default value is determined based on whether or
+ not version details were given to the :command:`project` command in the top
+ level CMakeLists.txt file. If version details were given, the default
+ value will be :variable:`CMAKE_PROJECT_VERSION_MINOR`, but if no minor
+ version component was specified then ``CPACK_PACKAGE_VERSION_MINOR`` will be
+ left unset. If no project version was given at all, a default version of
+ 0.1.1 will be assumed, leading to ``CPACK_PACKAGE_VERSION_MINOR`` having a
+ default value of 1.
+
+.. variable:: CPACK_PACKAGE_VERSION_PATCH
+
+ Package patch version. The default value is determined based on whether or
+ not version details were given to the :command:`project` command in the top
+ level CMakeLists.txt file. If version details were given, the default
+ value will be :variable:`CMAKE_PROJECT_VERSION_PATCH`, but if no patch
+ version component was specified then ``CPACK_PACKAGE_VERSION_PATCH`` will be
+ left unset. If no project version was given at all, a default version of
+ 0.1.1 will be assumed, leading to ``CPACK_PACKAGE_VERSION_PATCH`` having a
+ default value of 1.
+
+.. variable:: CPACK_PACKAGE_DESCRIPTION
+
+ A description of the project, used in places such as the introduction
+ screen of CPack-generated Windows installers. If not set, the value of
+ this variable is populated from the file named by
+ :variable:`CPACK_PACKAGE_DESCRIPTION_FILE`.
+
+.. variable:: CPACK_PACKAGE_DESCRIPTION_FILE
+
+ A text file used to describe the project when
+ :variable:`CPACK_PACKAGE_DESCRIPTION` is not explicitly set. The default
+ value for ``CPACK_PACKAGE_DESCRIPTION_FILE`` points to a built-in template
+ file ``Templates/CPack.GenericDescription.txt``.
+
+.. variable:: CPACK_PACKAGE_DESCRIPTION_SUMMARY
+
+ Short description of the project (only a few words). If the
+ :variable:`CMAKE_PROJECT_DESCRIPTION` variable is set, it is used as the
+ default value, otherwise the default will be a string generated by CMake
+ based on :variable:`CMAKE_PROJECT_NAME`.
+
+.. variable:: CPACK_PACKAGE_HOMEPAGE_URL
+
+ Project homepage URL. The default value is taken from the
+ :variable:`CMAKE_PROJECT_HOMEPAGE_URL` variable, which is set by the top
+ level :command:`project` command, or else the default will be empty if no
+ URL was provided to :command:`project`.
+
+.. variable:: CPACK_PACKAGE_FILE_NAME
+
+ The name of the package file to generate, not including the
+ extension. For example, ``cmake-2.6.1-Linux-i686``. The default value
+ is::
+
+ ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}
+
+.. variable:: CPACK_PACKAGE_INSTALL_DIRECTORY
+
+ Installation directory on the target system. This may be used by some
+ CPack generators like NSIS to create an installation directory e.g.,
+ "CMake 2.5" below the installation prefix. All installed elements will be
+ put inside this directory.
+
+.. variable:: CPACK_PACKAGE_ICON
+
+ A branding image that will be displayed inside the installer (used by GUI
+ installers).
+
+.. variable:: CPACK_PACKAGE_CHECKSUM
+
+ An algorithm that will be used to generate an additional file with the
+ checksum of the package. The output file name will be::
+
+ ${CPACK_PACKAGE_FILE_NAME}.${CPACK_PACKAGE_CHECKSUM}
+
+ Supported algorithms are those listed by the
+ :ref:`string(\<HASH\>) <Supported Hash Algorithms>` command.
+
+.. variable:: CPACK_PROJECT_CONFIG_FILE
+
+ CPack-time project CPack configuration file. This file is included at cpack
+ time, once per generator after CPack has set :variable:`CPACK_GENERATOR`
+ to the actual generator being used. It allows per-generator setting of
+ ``CPACK_*`` variables at cpack time.
+
+.. variable:: CPACK_RESOURCE_FILE_LICENSE
+
+ License to be embedded in the installer. It will typically be displayed
+ to the user by the produced installer (often with an explicit "Accept"
+ button, for graphical installers) prior to installation. This license
+ file is NOT added to the installed files but is used by some CPack generators
+ like NSIS. If you want to install a license file (may be the same as this
+ one) along with your project, you must add an appropriate CMake
+ :command:`install` command in your ``CMakeLists.txt``.
+
+.. variable:: CPACK_RESOURCE_FILE_README
+
+ ReadMe file to be embedded in the installer. It typically describes in
+ some detail the purpose of the project during the installation. Not all
+ CPack generators use this file.
+
+.. variable:: CPACK_RESOURCE_FILE_WELCOME
+
+ Welcome file to be embedded in the installer. It welcomes users to this
+ installer. Typically used in the graphical installers on Windows and Mac
+ OS X.
+
+.. variable:: CPACK_MONOLITHIC_INSTALL
+
+ Disables the component-based installation mechanism. When set, the
+ component specification is ignored and all installed items are put in a
+ single "MONOLITHIC" package. Some CPack generators do monolithic
+ packaging by default and may be asked to do component packaging by
+ setting ``CPACK_<GENNAME>_COMPONENT_INSTALL`` to ``TRUE``.
+
+.. variable:: CPACK_GENERATOR
+
+ List of CPack generators to use. If not specified, CPack will create a
+ set of options following the naming pattern
+ :variable:`CPACK_BINARY_<GENNAME>` (e.g. ``CPACK_BINARY_NSIS``) allowing
+ the user to enable/disable individual generators. If the ``-G`` option is
+ given on the :manual:`cpack <cpack(1)>` command line, it will override this
+ variable and any ``CPACK_BINARY_<GENNAME>`` options.
+
+.. variable:: CPACK_OUTPUT_CONFIG_FILE
+
+ The name of the CPack binary configuration file. This file is the CPack
+ configuration generated by the CPack module for binary installers.
+ Defaults to ``CPackConfig.cmake``.
+
+.. variable:: CPACK_PACKAGE_EXECUTABLES
+
+ 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 ``ccmake``. Not all CPack generators use it (at least
+ NSIS, WIX and OSXX11 do).
+
+.. variable:: CPACK_STRIP_FILES
+
+ List of files to be stripped. Starting with CMake 2.6.0,
+ ``CPACK_STRIP_FILES`` will be a boolean variable which enables
+ stripping of all files (a list of files evaluates to ``TRUE`` in CMake,
+ so this change is compatible).
+
+.. variable:: CPACK_VERBATIM_VARIABLES
+
+ If set to ``TRUE``, values of variables prefixed with ``CPACK_`` will be
+ escaped before being written to the configuration files, so that the cpack
+ program receives them exactly as they were specified. If not, characters
+ like quotes and backslashes can cause parsing errors or alter the value
+ received by the cpack program. Defaults to ``FALSE`` for backwards
+ compatibility.
+
+Variables for Source Package Generators
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The following CPack variables are specific to source packages, and
+will not affect binary packages:
+
+.. variable:: CPACK_SOURCE_PACKAGE_FILE_NAME
+
+ The name of the source package. For example ``cmake-2.6.1``.
+
+.. variable:: CPACK_SOURCE_STRIP_FILES
+
+ List of files in the source tree that will be stripped. Starting with
+ CMake 2.6.0, ``CPACK_SOURCE_STRIP_FILES`` will be a boolean
+ variable which enables stripping of all files (a list of files evaluates
+ to ``TRUE`` in CMake, so this change is compatible).
+
+.. variable:: CPACK_SOURCE_GENERATOR
+
+ List of generators used for the source packages. As with
+ :variable:`CPACK_GENERATOR`, if this is not specified then CPack will
+ create a set of options (e.g. ``CPACK_SOURCE_ZIP``) allowing
+ users to select which packages will be generated.
+
+.. variable:: CPACK_SOURCE_OUTPUT_CONFIG_FILE
+
+ The name of the CPack source configuration file. This file is the CPack
+ configuration generated by the CPack module for source installers.
+ Defaults to ``CPackSourceConfig.cmake``.
+
+.. variable:: CPACK_SOURCE_IGNORE_FILES
+
+ Pattern of files in the source tree that won't be packaged when building
+ a source package. This is a list of regular expression patterns (that
+ must be properly escaped), e.g.,
+ ``/CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~;cscope.*``
+
+Variables for Advanced Use
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The following variables are for advanced uses of CPack:
+
+.. variable:: CPACK_CMAKE_GENERATOR
+
+ What CMake generator should be used if the project is a CMake
+ project. Defaults to the value of :variable:`CMAKE_GENERATOR`. Few users
+ will want to change this setting.
+
+.. variable:: CPACK_INSTALL_CMAKE_PROJECTS
+
+ List of four values that specify what project to install. The four values
+ are: Build directory, Project Name, Project Component, Directory. If
+ omitted, CPack will build an installer that installs everything.
+
+.. variable:: CPACK_SYSTEM_NAME
+
+ System name, defaults to the value of :variable:`CMAKE_SYSTEM_NAME`,
+ except on Windows where it will be ``win32`` or ``win64``.
+
+.. variable:: CPACK_PACKAGE_VERSION
+
+ Package full version, used internally. By default, this is built from
+ :variable:`CPACK_PACKAGE_VERSION_MAJOR`,
+ :variable:`CPACK_PACKAGE_VERSION_MINOR`, and
+ :variable:`CPACK_PACKAGE_VERSION_PATCH`.
+
+.. variable:: CPACK_TOPLEVEL_TAG
+
+ Directory for the installed files.
+
+.. variable:: CPACK_INSTALL_COMMANDS
+
+ Extra commands to install components. The environment variable
+ ``CMAKE_INSTALL_PREFIX`` is set to the temporary install directory
+ during execution.
+
+.. variable:: CPACK_INSTALL_SCRIPTS
+
+ Extra CMake scripts executed by CPack during its local staging
+ installation, which is done right before packaging the files.
+ The scripts are not called by a standalone install (e.g.: ``make install``).
+ For every script, the following variables will be set:
+ :variable:`CMAKE_CURRENT_SOURCE_DIR`, :variable:`CMAKE_CURRENT_BINARY_DIR`
+ and :variable:`CMAKE_INSTALL_PREFIX` (which is set to the staging install
+ directory). The singular form ``CMAKE_INSTALL_SCRIPT`` is supported as
+ an alternative variable for historical reasons, but its value is ignored if
+ ``CMAKE_INSTALL_SCRIPTS`` is set and a warning will be issued.
+
+.. variable:: CPACK_INSTALLED_DIRECTORIES
+
+ Extra directories to install.
+
+.. variable:: CPACK_PACKAGE_INSTALL_REGISTRY_KEY
+
+ Registry key used when installing this project. This is only used by
+ installers for Windows. The default value is based on the installation
+ directory.
+
+.. variable:: CPACK_CREATE_DESKTOP_LINKS
+
+ List of desktop links to create. Each desktop link requires a
+ corresponding start menu shortcut as created by
+ :variable:`CPACK_PACKAGE_EXECUTABLES`.
+
+.. variable:: CPACK_BINARY_<GENNAME>
+
+ CPack generated options for binary generators. The ``CPack.cmake`` module
+ generates (when :variable:`CPACK_GENERATOR` is not set) a set of CMake
+ options (see CMake :command:`option` command) which may then be used to
+ select the CPack generator(s) to be used when building the ``package``
+ target or when running :manual:`cpack <cpack(1)>` without the ``-G`` option.
+
+#]=======================================================================]
# Define this var in order to avoid (or warn) concerning multiple inclusion
if(CPack_CMake_INCLUDED)
@@ -338,7 +411,7 @@ function(cpack_encode_variables)
set(value "${${var}}")
endif()
- string(APPEND commands "\nSET(${var} \"${value}\")")
+ string(APPEND commands "\nset(${var} \"${value}\")")
endif()
endforeach()
@@ -359,22 +432,49 @@ endfunction()
# Set the package name
_cpack_set_default(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
-_cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "0")
-_cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "1")
-_cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "1")
-_cpack_set_default(CPACK_PACKAGE_VERSION
- "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
+
+# Set the package version
+if(CMAKE_PROJECT_VERSION_MAJOR GREATER_EQUAL 0)
+ _cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "${CMAKE_PROJECT_VERSION_MAJOR}")
+ if(CMAKE_PROJECT_VERSION_MINOR GREATER_EQUAL 0)
+ _cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "${CMAKE_PROJECT_VERSION_MINOR}")
+ if(CMAKE_PROJECT_VERSION_PATCH GREATER_EQUAL 0)
+ _cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "${CMAKE_PROJECT_VERSION_PATCH}")
+ endif()
+ endif()
+else()
+ _cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "0")
+ _cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "1")
+ _cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "1")
+endif()
+if(NOT DEFINED CPACK_PACKAGE_VERSION)
+ set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}")
+ if(CPACK_PACKAGE_VERSION_MINOR GREATER_EQUAL 0)
+ string(APPEND CPACK_PACKAGE_VERSION ".${CPACK_PACKAGE_VERSION_MINOR}")
+ if(CPACK_PACKAGE_VERSION_PATCH GREATER_EQUAL 0)
+ string(APPEND CPACK_PACKAGE_VERSION ".${CPACK_PACKAGE_VERSION_PATCH}")
+ endif()
+ endif()
+endif()
+
_cpack_set_default(CPACK_PACKAGE_VENDOR "Humanity")
+set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY "${CMAKE_PROJECT_NAME} built using CMake")
if(CMAKE_PROJECT_DESCRIPTION)
_cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"${CMAKE_PROJECT_DESCRIPTION}")
else()
_cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY
- "${CMAKE_PROJECT_NAME} built using CMake")
+ "${CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY}")
+endif()
+if(CMAKE_PROJECT_HOMEPAGE_URL)
+ _cpack_set_default(CPACK_PACKAGE_HOMEPAGE_URL
+ "${CMAKE_PROJECT_HOMEPAGE_URL}")
endif()
-_cpack_set_default(CPACK_PACKAGE_DESCRIPTION_FILE
+set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE
"${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt")
+_cpack_set_default(CPACK_PACKAGE_DESCRIPTION_FILE
+ "${CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE}")
_cpack_set_default(CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt")
_cpack_set_default(CPACK_RESOURCE_FILE_README
@@ -384,6 +484,12 @@ _cpack_set_default(CPACK_RESOURCE_FILE_WELCOME
_cpack_set_default(CPACK_MODULE_PATH "${CMAKE_MODULE_PATH}")
+# Set default directory creation permissions mode
+if(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS)
+ _cpack_set_default(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
+ "${CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS}")
+endif()
+
if(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
endif()
@@ -446,16 +552,9 @@ macro(cpack_optional_append _list _cond _item)
endif()
endmacro()
-#.rst:
-# .. variable:: CPACK_BINARY_<GENNAME>
-#
-# CPack generated options for binary generators. The CPack.cmake module
-# generates (when CPACK_GENERATOR is not set) a set of CMake options (see
-# CMake option command) which may then be used to select the CPack
-# generator(s) to be used when launching the package target.
-#
-# Provide options to choose generators we might check here if the required
-# tools for the generates exist and set the defaults according to the results
+# Provide options to choose generators we might check here if the required
+# tools for the generators exist and set the defaults according to the
+# results.
if(NOT CPACK_GENERATOR)
if(UNIX)
if(CYGWIN)
@@ -471,6 +570,7 @@ if(NOT CPACK_GENERATOR)
option(CPACK_BINARY_TZ "Enable to build TZ packages" ON)
endif()
option(CPACK_BINARY_DEB "Enable to build Debian packages" OFF)
+ option(CPACK_BINARY_FREEBSD "Enable to build FreeBSD packages" OFF)
option(CPACK_BINARY_NSIS "Enable to build NSIS packages" OFF)
option(CPACK_BINARY_RPM "Enable to build RPM packages" OFF)
option(CPACK_BINARY_STGZ "Enable to build STGZ packages" ON)
@@ -479,10 +579,11 @@ if(NOT CPACK_GENERATOR)
option(CPACK_BINARY_TXZ "Enable to build TXZ packages" OFF)
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_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_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)
endif()
option(CPACK_BINARY_IFW "Enable to build IFW packages" OFF)
@@ -491,8 +592,10 @@ if(NOT CPACK_GENERATOR)
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_CYGWIN CygwinBinary)
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DEB DEB)
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_DRAGNDROP DragNDrop)
+ 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_NUGET NuGet)
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_OSXX11 OSXX11)
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PACKAGEMAKER PackageMaker)
cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PRODUCTBUILD productbuild)
@@ -542,8 +645,10 @@ mark_as_advanced(
CPACK_BINARY_CYGWIN
CPACK_BINARY_DEB
CPACK_BINARY_DRAGNDROP
+ CPACK_BINARY_FREEBSD
CPACK_BINARY_IFW
CPACK_BINARY_NSIS
+ CPACK_BINARY_NUGET
CPACK_BINARY_OSXX11
CPACK_BINARY_PACKAGEMAKER
CPACK_BINARY_PRODUCTBUILD
diff --git a/Modules/CPackArchive.cmake b/Modules/CPackArchive.cmake
deleted file mode 100644
index 741fb1fdd..000000000
--- a/Modules/CPackArchive.cmake
+++ /dev/null
@@ -1,39 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-#.rst:
-# CPackArchive
-# ------------
-#
-# Archive CPack generator that supports packaging of sources and binaries in
-# different formats:
-#
-# - 7Z - 7zip - (.7z)
-# - TBZ2 (.tar.bz2)
-# - TGZ (.tar.gz)
-# - TXZ (.tar.xz)
-# - TZ (.tar.Z)
-# - ZIP (.zip)
-#
-# Variables specific to CPack Archive generator
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# .. variable:: CPACK_ARCHIVE_FILE_NAME
-# CPACK_ARCHIVE_<component>_FILE_NAME
-#
-# Package file name without extension which is added automatically depending
-# on the archive format.
-#
-# * Mandatory : YES
-# * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].<extension>`` with
-# spaces replaced by '-'
-#
-# .. variable:: CPACK_ARCHIVE_COMPONENT_INSTALL
-#
-# Enable component packaging for CPackArchive
-#
-# * Mandatory : NO
-# * Default : OFF
-#
-# If enabled (ON) multiple packages are generated. By default a single package
-# containing files of all components is generated.
diff --git a/Modules/CPackBundle.cmake b/Modules/CPackBundle.cmake
deleted file mode 100644
index 8f37ef87e..000000000
--- a/Modules/CPackBundle.cmake
+++ /dev/null
@@ -1,70 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-#.rst:
-# CPackBundle
-# -----------
-#
-# CPack Bundle generator (Mac OS X) specific options
-#
-# Variables specific to CPack Bundle generator
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# Installers built on Mac OS X using the Bundle generator use the
-# aforementioned DragNDrop (CPACK_DMG_xxx) variables, plus the following
-# Bundle-specific parameters (CPACK_BUNDLE_xxx).
-#
-# .. variable:: CPACK_BUNDLE_NAME
-#
-# The name of the generated bundle. This appears in the OSX finder as the
-# bundle name. Required.
-#
-# .. variable:: CPACK_BUNDLE_PLIST
-#
-# Path to an OSX plist file that will be used for the generated bundle. This
-# assumes that the caller has generated or specified their own Info.plist
-# file. Required.
-#
-# .. variable:: CPACK_BUNDLE_ICON
-#
-# Path to an OSX icon file that will be used as the icon for the generated
-# bundle. This is the icon that appears in the OSX finder for the bundle, and
-# in the OSX dock when the bundle is opened. Required.
-#
-# .. variable:: CPACK_BUNDLE_STARTUP_COMMAND
-#
-# Path to a startup script. This is a path to an executable or script that
-# will be run whenever an end-user double-clicks the generated bundle in the
-# OSX Finder. Optional.
-#
-# .. variable:: CPACK_BUNDLE_APPLE_CERT_APP
-#
-# The name of your Apple supplied code signing certificate for the application.
-# The name usually takes the form "Developer ID Application: [Name]" or
-# "3rd Party Mac Developer Application: [Name]". If this variable is not set
-# the application will not be signed.
-#
-# .. variable:: CPACK_BUNDLE_APPLE_ENTITLEMENTS
-#
-# The name of the plist file that contains your apple entitlements for sandboxing
-# your application. This file is required for submission to the Mac App Store.
-#
-# .. variable:: CPACK_BUNDLE_APPLE_CODESIGN_FILES
-#
-# A list of additional files that you wish to be signed. You do not need to
-# list the main application folder, or the main executable. You should
-# list any frameworks and plugins that are included in your app bundle.
-#
-# .. variable:: CPACK_BUNDLE_APPLE_CODESIGN_PARAMETER
-#
-# Additional parameter that will passed to codesign.
-# Default value: "--deep -f"
-#
-# .. variable:: CPACK_COMMAND_CODESIGN
-#
-# Path to the codesign(1) command used to sign applications with an
-# Apple cert. This variable can be used to override the automatically
-# detected command (or specify its location if the auto-detection fails
-# to find it.)
-
-#Bundle Generator specific code should be put here
diff --git a/Modules/CPackComponent.cmake b/Modules/CPackComponent.cmake
index 3a10b9930..211d7673c 100644
--- a/Modules/CPackComponent.cmake
+++ b/Modules/CPackComponent.cmake
@@ -1,303 +1,314 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CPackComponent
-# --------------
-#
-# Build binary and source package installers
-#
-# Variables concerning CPack Components
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# The CPackComponent module is the module which handles the component
-# part of CPack. See CPack module for general information about CPack.
-#
-# For certain kinds of binary installers (including the graphical
-# installers on Mac OS X and Windows), CPack generates installers that
-# allow users to select individual application components to install.
-# The contents of each of the components are identified by the COMPONENT
-# argument of CMake's INSTALL command. These components can be
-# annotated with user-friendly names and descriptions, inter-component
-# dependencies, etc., and grouped in various ways to customize the
-# resulting installer. See the cpack_add_* commands, described below,
-# for more information about component-specific installations.
-#
-# Component-specific installation allows users to select specific sets
-# of components to install during the install process. Installation
-# components are identified by the COMPONENT argument of CMake's INSTALL
-# commands, and should be further described by the following CPack
-# commands:
-#
-# .. variable:: CPACK_COMPONENTS_ALL
-#
-# The list of component to install.
-#
-# The default value of this variable is computed by CPack and contains all
-# components defined by the project. The user may set it to only include the
-# specified components.
-#
-# .. variable:: CPACK_<GENNAME>_COMPONENT_INSTALL
-#
-# Enable/Disable component install for CPack generator <GENNAME>.
-#
-# Each CPack Generator (RPM, DEB, ARCHIVE, NSIS, DMG, etc...) has a legacy
-# default behavior. e.g. RPM builds monolithic whereas NSIS builds
-# component. One can change the default behavior by setting this variable to
-# 0/1 or OFF/ON.
-#
-# .. variable:: CPACK_COMPONENTS_GROUPING
-#
-# Specify how components are grouped for multi-package component-aware CPack
-# generators.
-#
-# Some generators like RPM or ARCHIVE family (TGZ, ZIP, ...) generates
-# several packages files when asked for component packaging. They group
-# the component differently depending on the value of this variable:
-#
-# * ONE_PER_GROUP (default): creates one package file per component group
-# * ALL_COMPONENTS_IN_ONE : creates a single package with all (requested) component
-# * IGNORE : creates one package per component, i.e. IGNORE component group
-#
-# One can specify different grouping for different CPack generator by
-# using a CPACK_PROJECT_CONFIG_FILE.
-#
-# .. variable:: CPACK_COMPONENT_<compName>_DISPLAY_NAME
-#
-# The name to be displayed for a component.
-#
-# .. variable:: CPACK_COMPONENT_<compName>_DESCRIPTION
-#
-# The description of a component.
-#
-# .. variable:: CPACK_COMPONENT_<compName>_GROUP
-#
-# The group of a component.
-#
-# .. variable:: CPACK_COMPONENT_<compName>_DEPENDS
-#
-# The dependencies (list of components) on which this component depends.
-#
-# .. variable:: CPACK_COMPONENT_<compName>_HIDDEN
-#
-# True if this component is hidden from the user.
-#
-# .. variable:: CPACK_COMPONENT_<compName>_REQUIRED
-#
-# True if this component is required.
-#
-# .. variable:: CPACK_COMPONENT_<compName>_DISABLED
-#
-# True if this component is not selected to be installed by default.
-#
-# .. command:: cpack_add_component
-#
-# Describes a CPack installation
-# component named by the COMPONENT argument to a CMake INSTALL command.
-#
-# ::
-#
-# cpack_add_component(compname
-# [DISPLAY_NAME name]
-# [DESCRIPTION description]
-# [HIDDEN | REQUIRED | DISABLED ]
-# [GROUP group]
-# [DEPENDS comp1 comp2 ... ]
-# [INSTALL_TYPES type1 type2 ... ]
-# [DOWNLOADED]
-# [ARCHIVE_FILE filename]
-# [PLIST filename])
-#
-#
-#
-# The cmake_add_component command describes an installation component,
-# which the user can opt to install or remove as part of the graphical
-# installation process. compname is the name of the component, as
-# provided to the COMPONENT argument of one or more CMake INSTALL
-# commands.
-#
-# DISPLAY_NAME is the displayed name of the component, used in graphical
-# installers to display the component name. This value can be any
-# string.
-#
-# DESCRIPTION is an extended description of the component, used in
-# graphical installers to give the user additional information about the
-# component. Descriptions can span multiple lines using ``\n`` as the
-# line separator. Typically, these descriptions should be no more than
-# a few lines long.
-#
-# HIDDEN indicates that this component will be hidden in the graphical
-# installer, so that the user cannot directly change whether it is
-# installed or not.
-#
-# REQUIRED indicates that this component is required, and therefore will
-# always be installed. It will be visible in the graphical installer,
-# but it cannot be unselected. (Typically, required components are
-# shown greyed out).
-#
-# DISABLED indicates that this component should be disabled (unselected)
-# by default. The user is free to select this component for
-# installation, unless it is also HIDDEN.
-#
-# DEPENDS lists the components on which this component depends. If this
-# component is selected, then each of the components listed must also be
-# selected. The dependency information is encoded within the installer
-# itself, so that users cannot install inconsistent sets of components.
-#
-# GROUP names the component group of which this component is a part. If
-# not provided, the component will be a standalone component, not part
-# of any component group. Component groups are described with the
-# cpack_add_component_group command, detailed below.
-#
-# INSTALL_TYPES lists the installation types of which this component is
-# a part. When one of these installations types is selected, this
-# component will automatically be selected. Installation types are
-# described with the cpack_add_install_type command, detailed below.
-#
-# DOWNLOADED indicates that this component should be downloaded
-# on-the-fly by the installer, rather than packaged in with the
-# installer itself. For more information, see the
-# cpack_configure_downloads command.
-#
-# ARCHIVE_FILE provides a name for the archive file created by CPack to
-# be used for downloaded components. If not supplied, CPack will create
-# a file with some name based on CPACK_PACKAGE_FILE_NAME and the name of
-# the component. See cpack_configure_downloads for more information.
-#
-# PLIST gives a filename that is passed to pkgbuild with the
-# ``--component-plist`` argument when using the productbuild generator.
-#
-# .. command:: cpack_add_component_group
-#
-# Describes a group of related CPack installation components.
-#
-# ::
-#
-# cpack_add_component_group(groupname
-# [DISPLAY_NAME name]
-# [DESCRIPTION description]
-# [PARENT_GROUP parent]
-# [EXPANDED]
-# [BOLD_TITLE])
-#
-#
-#
-# The cpack_add_component_group describes a group of installation
-# components, which will be placed together within the listing of
-# options. Typically, component groups allow the user to
-# select/deselect all of the components within a single group via a
-# single group-level option. Use component groups to reduce the
-# complexity of installers with many options. groupname is an arbitrary
-# name used to identify the group in the GROUP argument of the
-# cpack_add_component command, which is used to place a component in a
-# group. The name of the group must not conflict with the name of any
-# component.
-#
-# DISPLAY_NAME is the displayed name of the component group, used in
-# graphical installers to display the component group name. This value
-# can be any string.
-#
-# DESCRIPTION is an extended description of the component group, used in
-# graphical installers to give the user additional information about the
-# components within that group. Descriptions can span multiple lines
-# using ``\n`` as the line separator. Typically, these descriptions
-# should be no more than a few lines long.
-#
-# PARENT_GROUP, if supplied, names the parent group of this group.
-# Parent groups are used to establish a hierarchy of groups, providing
-# an arbitrary hierarchy of groups.
-#
-# EXPANDED indicates that, by default, the group should show up as
-# "expanded", so that the user immediately sees all of the components
-# within the group. Otherwise, the group will initially show up as a
-# single entry.
-#
-# BOLD_TITLE indicates that the group title should appear in bold, to
-# call the user's attention to the group.
-#
-# .. command:: cpack_add_install_type
-#
-# Add a new installation type containing
-# a set of predefined component selections to the graphical installer.
-#
-# ::
-#
-# cpack_add_install_type(typename
-# [DISPLAY_NAME name])
-#
-#
-#
-# The cpack_add_install_type command identifies a set of preselected
-# components that represents a common use case for an application. For
-# example, a "Developer" install type might include an application along
-# with its header and library files, while an "End user" install type
-# might just include the application's executable. Each component
-# identifies itself with one or more install types via the INSTALL_TYPES
-# argument to cpack_add_component.
-#
-# DISPLAY_NAME is the displayed name of the install type, which will
-# typically show up in a drop-down box within a graphical installer.
-# This value can be any string.
-#
-# .. command:: cpack_configure_downloads
-#
-# Configure CPack to download
-# selected components on-the-fly as part of the installation process.
-#
-# ::
-#
-# cpack_configure_downloads(site
-# [UPLOAD_DIRECTORY dirname]
-# [ALL]
-# [ADD_REMOVE|NO_ADD_REMOVE])
-#
-#
-#
-# The cpack_configure_downloads command configures installation-time
-# downloads of selected components. For each downloadable component,
-# CPack will create an archive containing the contents of that
-# component, which should be uploaded to the given site. When the user
-# selects that component for installation, the installer will download
-# and extract the component in place. This feature is useful for
-# creating small installers that only download the requested components,
-# saving bandwidth. Additionally, the installers are small enough that
-# they will be installed as part of the normal installation process, and
-# the "Change" button in Windows Add/Remove Programs control panel will
-# allow one to add or remove parts of the application after the original
-# installation. On Windows, the downloaded-components functionality
-# requires the ZipDLL plug-in for NSIS, available at:
-#
-# ::
-#
-# http://nsis.sourceforge.net/ZipDLL_plug-in
-#
-#
-#
-# On Mac OS X, installers that download components on-the-fly can only
-# be built and installed on system using Mac OS X 10.5 or later.
-#
-# The site argument is a URL where the archives for downloadable
-# components will reside, e.g.,
-# https://cmake.org/files/2.6.1/installer/ All of the archives
-# produced by CPack should be uploaded to that location.
-#
-# UPLOAD_DIRECTORY is the local directory where CPack will create the
-# various archives for each of the components. The contents of this
-# directory should be uploaded to a location accessible by the URL given
-# in the site argument. If omitted, CPack will use the directory
-# CPackUploads inside the CMake binary directory to store the generated
-# archives.
-#
-# The ALL flag indicates that all components be downloaded. Otherwise,
-# only those components explicitly marked as DOWNLOADED or that have a
-# specified ARCHIVE_FILE will be downloaded. Additionally, the ALL
-# option implies ADD_REMOVE (unless NO_ADD_REMOVE is specified).
-#
-# ADD_REMOVE indicates that CPack should install a copy of the installer
-# that can be called from Windows' Add/Remove Programs dialog (via the
-# "Modify" button) to change the set of installed components.
-# NO_ADD_REMOVE turns off this behavior. This option is ignored on Mac
-# OS X.
+#[=======================================================================[.rst:
+CPackComponent
+--------------
+
+Build binary and source package installers
+
+Variables concerning CPack Components
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The CPackComponent module is the module which handles the component
+part of CPack. See CPack module for general information about CPack.
+
+For certain kinds of binary installers (including the graphical
+installers on macOS and Windows), CPack generates installers that
+allow users to select individual application components to install.
+The contents of each of the components are identified by the COMPONENT
+argument of CMake's INSTALL command. These components can be
+annotated with user-friendly names and descriptions, inter-component
+dependencies, etc., and grouped in various ways to customize the
+resulting installer. See the cpack_add_* commands, described below,
+for more information about component-specific installations.
+
+Component-specific installation allows users to select specific sets
+of components to install during the install process. Installation
+components are identified by the COMPONENT argument of CMake's INSTALL
+commands, and should be further described by the following CPack
+commands:
+
+.. variable:: CPACK_COMPONENTS_ALL
+
+ The list of component to install.
+
+ The default value of this variable is computed by CPack and contains all
+ components defined by the project. The user may set it to only include the
+ specified components.
+
+ Instead of specifying all the desired components, it is possible to obtain a
+ list of all defined components and then remove the unwanted ones from the
+ list. The :command:`get_cmake_property` command can be used to obtain the
+ ``COMPONENTS`` property, then the :command:`list(REMOVE_ITEM)` command can be
+ used to remove the unwanted ones. For example, to use all defined components
+ except ``foo`` and ``bar``::
+
+ get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
+ list(REMOVE_ITEM CPACK_COMPONENTS_ALL "foo" "bar")
+
+.. variable:: CPACK_<GENNAME>_COMPONENT_INSTALL
+
+ Enable/Disable component install for CPack generator <GENNAME>.
+
+ Each CPack Generator (RPM, DEB, ARCHIVE, NSIS, DMG, etc...) has a legacy
+ default behavior. e.g. RPM builds monolithic whereas NSIS builds
+ component. One can change the default behavior by setting this variable to
+ 0/1 or OFF/ON.
+
+.. variable:: CPACK_COMPONENTS_GROUPING
+
+ Specify how components are grouped for multi-package component-aware CPack
+ generators.
+
+ Some generators like RPM or ARCHIVE family (TGZ, ZIP, ...) generates
+ several packages files when asked for component packaging. They group
+ the component differently depending on the value of this variable:
+
+ * ONE_PER_GROUP (default): creates one package file per component group
+ * ALL_COMPONENTS_IN_ONE : creates a single package with all (requested) components
+ * IGNORE : creates one package per component, i.e. IGNORE component group
+
+ One can specify different grouping for different CPack generator by
+ using a CPACK_PROJECT_CONFIG_FILE.
+
+.. variable:: CPACK_COMPONENT_<compName>_DISPLAY_NAME
+
+ The name to be displayed for a component.
+
+.. variable:: CPACK_COMPONENT_<compName>_DESCRIPTION
+
+ The description of a component.
+
+.. variable:: CPACK_COMPONENT_<compName>_GROUP
+
+ The group of a component.
+
+.. variable:: CPACK_COMPONENT_<compName>_DEPENDS
+
+ The dependencies (list of components) on which this component depends.
+
+.. variable:: CPACK_COMPONENT_<compName>_HIDDEN
+
+ True if this component is hidden from the user.
+
+.. variable:: CPACK_COMPONENT_<compName>_REQUIRED
+
+ True if this component is required.
+
+.. variable:: CPACK_COMPONENT_<compName>_DISABLED
+
+ True if this component is not selected to be installed by default.
+
+.. command:: cpack_add_component
+
+Describes a CPack installation
+component named by the COMPONENT argument to a CMake INSTALL command.
+
+::
+
+ cpack_add_component(compname
+ [DISPLAY_NAME name]
+ [DESCRIPTION description]
+ [HIDDEN | REQUIRED | DISABLED ]
+ [GROUP group]
+ [DEPENDS comp1 comp2 ... ]
+ [INSTALL_TYPES type1 type2 ... ]
+ [DOWNLOADED]
+ [ARCHIVE_FILE filename]
+ [PLIST filename])
+
+
+
+The cmake_add_component command describes an installation component,
+which the user can opt to install or remove as part of the graphical
+installation process. compname is the name of the component, as
+provided to the COMPONENT argument of one or more CMake INSTALL
+commands.
+
+DISPLAY_NAME is the displayed name of the component, used in graphical
+installers to display the component name. This value can be any
+string.
+
+DESCRIPTION is an extended description of the component, used in
+graphical installers to give the user additional information about the
+component. Descriptions can span multiple lines using ``\n`` as the
+line separator. Typically, these descriptions should be no more than
+a few lines long.
+
+HIDDEN indicates that this component will be hidden in the graphical
+installer, so that the user cannot directly change whether it is
+installed or not.
+
+REQUIRED indicates that this component is required, and therefore will
+always be installed. It will be visible in the graphical installer,
+but it cannot be unselected. (Typically, required components are
+shown greyed out).
+
+DISABLED indicates that this component should be disabled (unselected)
+by default. The user is free to select this component for
+installation, unless it is also HIDDEN.
+
+DEPENDS lists the components on which this component depends. If this
+component is selected, then each of the components listed must also be
+selected. The dependency information is encoded within the installer
+itself, so that users cannot install inconsistent sets of components.
+
+GROUP names the component group of which this component is a part. If
+not provided, the component will be a standalone component, not part
+of any component group. Component groups are described with the
+cpack_add_component_group command, detailed below.
+
+INSTALL_TYPES lists the installation types of which this component is
+a part. When one of these installations types is selected, this
+component will automatically be selected. Installation types are
+described with the cpack_add_install_type command, detailed below.
+
+DOWNLOADED indicates that this component should be downloaded
+on-the-fly by the installer, rather than packaged in with the
+installer itself. For more information, see the
+cpack_configure_downloads command.
+
+ARCHIVE_FILE provides a name for the archive file created by CPack to
+be used for downloaded components. If not supplied, CPack will create
+a file with some name based on CPACK_PACKAGE_FILE_NAME and the name of
+the component. See cpack_configure_downloads for more information.
+
+PLIST gives a filename that is passed to pkgbuild with the
+``--component-plist`` argument when using the productbuild generator.
+
+.. command:: cpack_add_component_group
+
+Describes a group of related CPack installation components.
+
+::
+
+ cpack_add_component_group(groupname
+ [DISPLAY_NAME name]
+ [DESCRIPTION description]
+ [PARENT_GROUP parent]
+ [EXPANDED]
+ [BOLD_TITLE])
+
+
+
+The cpack_add_component_group describes a group of installation
+components, which will be placed together within the listing of
+options. Typically, component groups allow the user to
+select/deselect all of the components within a single group via a
+single group-level option. Use component groups to reduce the
+complexity of installers with many options. groupname is an arbitrary
+name used to identify the group in the GROUP argument of the
+cpack_add_component command, which is used to place a component in a
+group. The name of the group must not conflict with the name of any
+component.
+
+DISPLAY_NAME is the displayed name of the component group, used in
+graphical installers to display the component group name. This value
+can be any string.
+
+DESCRIPTION is an extended description of the component group, used in
+graphical installers to give the user additional information about the
+components within that group. Descriptions can span multiple lines
+using ``\n`` as the line separator. Typically, these descriptions
+should be no more than a few lines long.
+
+PARENT_GROUP, if supplied, names the parent group of this group.
+Parent groups are used to establish a hierarchy of groups, providing
+an arbitrary hierarchy of groups.
+
+EXPANDED indicates that, by default, the group should show up as
+"expanded", so that the user immediately sees all of the components
+within the group. Otherwise, the group will initially show up as a
+single entry.
+
+BOLD_TITLE indicates that the group title should appear in bold, to
+call the user's attention to the group.
+
+.. command:: cpack_add_install_type
+
+Add a new installation type containing
+a set of predefined component selections to the graphical installer.
+
+::
+
+ cpack_add_install_type(typename
+ [DISPLAY_NAME name])
+
+
+
+The cpack_add_install_type command identifies a set of preselected
+components that represents a common use case for an application. For
+example, a "Developer" install type might include an application along
+with its header and library files, while an "End user" install type
+might just include the application's executable. Each component
+identifies itself with one or more install types via the INSTALL_TYPES
+argument to cpack_add_component.
+
+DISPLAY_NAME is the displayed name of the install type, which will
+typically show up in a drop-down box within a graphical installer.
+This value can be any string.
+
+.. command:: cpack_configure_downloads
+
+Configure CPack to download
+selected components on-the-fly as part of the installation process.
+
+::
+
+ cpack_configure_downloads(site
+ [UPLOAD_DIRECTORY dirname]
+ [ALL]
+ [ADD_REMOVE|NO_ADD_REMOVE])
+
+
+
+The cpack_configure_downloads command configures installation-time
+downloads of selected components. For each downloadable component,
+CPack will create an archive containing the contents of that
+component, which should be uploaded to the given site. When the user
+selects that component for installation, the installer will download
+and extract the component in place. This feature is useful for
+creating small installers that only download the requested components,
+saving bandwidth. Additionally, the installers are small enough that
+they will be installed as part of the normal installation process, and
+the "Change" button in Windows Add/Remove Programs control panel will
+allow one to add or remove parts of the application after the original
+installation. On Windows, the downloaded-components functionality
+requires the ZipDLL plug-in for NSIS, available at:
+
+::
+
+ http://nsis.sourceforge.net/ZipDLL_plug-in
+
+
+
+On macOS, installers that download components on-the-fly can only
+be built and installed on system using macOS 10.5 or later.
+
+The site argument is a URL where the archives for downloadable
+components will reside, e.g.,
+https://cmake.org/files/2.6.1/installer/ All of the archives
+produced by CPack should be uploaded to that location.
+
+UPLOAD_DIRECTORY is the local directory where CPack will create the
+various archives for each of the components. The contents of this
+directory should be uploaded to a location accessible by the URL given
+in the site argument. If omitted, CPack will use the directory
+CPackUploads inside the CMake binary directory to store the generated
+archives.
+
+The ALL flag indicates that all components be downloaded. Otherwise,
+only those components explicitly marked as DOWNLOADED or that have a
+specified ARCHIVE_FILE will be downloaded. Additionally, the ALL
+option implies ADD_REMOVE (unless NO_ADD_REMOVE is specified).
+
+ADD_REMOVE indicates that CPack should install a copy of the installer
+that can be called from Windows' Add/Remove Programs dialog (via the
+"Modify" button) to change the set of installed components.
+NO_ADD_REMOVE turns off this behavior. This option is ignored on Mac
+OS X.
+#]=======================================================================]
# Define var in order to avoid multiple inclusion
if(NOT CPackComponent_CMake_INCLUDED)
diff --git a/Modules/CPackCygwin.cmake b/Modules/CPackCygwin.cmake
deleted file mode 100644
index 6d203c313..000000000
--- a/Modules/CPackCygwin.cmake
+++ /dev/null
@@ -1,27 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-#.rst:
-# CPackCygwin
-# -----------
-#
-# Cygwin CPack generator (Cygwin).
-#
-# Variables specific to CPack Cygwin generator
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# The
-# following variable is specific to installers build on and/or for
-# Cygwin:
-#
-# .. variable:: CPACK_CYGWIN_PATCH_NUMBER
-#
-# The Cygwin patch number. FIXME: This documentation is incomplete.
-#
-# .. variable:: CPACK_CYGWIN_PATCH_FILE
-#
-# The Cygwin patch file. FIXME: This documentation is incomplete.
-#
-# .. variable:: CPACK_CYGWIN_BUILD_SCRIPT
-#
-# The Cygwin build script. FIXME: This documentation is incomplete.
diff --git a/Modules/CPackDMG.cmake b/Modules/CPackDMG.cmake
deleted file mode 100644
index bda600fd4..000000000
--- a/Modules/CPackDMG.cmake
+++ /dev/null
@@ -1,105 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-#.rst:
-# CPackDMG
-# --------
-#
-# DragNDrop CPack generator (Mac OS X).
-#
-# Variables specific to CPack DragNDrop generator
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# The following variables are specific to the DragNDrop installers built
-# on Mac OS X:
-#
-# .. variable:: CPACK_DMG_VOLUME_NAME
-#
-# The volume name of the generated disk image. Defaults to
-# CPACK_PACKAGE_FILE_NAME.
-#
-# .. variable:: CPACK_DMG_FORMAT
-#
-# The disk image format. Common values are UDRO (UDIF read-only), UDZO (UDIF
-# zlib-compressed) or UDBZ (UDIF bzip2-compressed). Refer to hdiutil(1) for
-# more information on other available formats. Defaults to UDZO.
-#
-# .. variable:: CPACK_DMG_DS_STORE
-#
-# Path to a custom DS_Store file. This .DS_Store file e.g. can be used to
-# specify the Finder window position/geometry and layout (such as hidden
-# toolbars, placement of the icons etc.). This file has to be generated by
-# the Finder (either manually or through AppleScript) using a normal folder
-# from which the .DS_Store file can then be extracted.
-#
-# .. variable:: CPACK_DMG_DS_STORE_SETUP_SCRIPT
-#
-# Path to a custom AppleScript file. This AppleScript is used to generate
-# a .DS_Store file which specifies the Finder window position/geometry and
-# layout (such as hidden toolbars, placement of the icons etc.).
-# By specifying a custom AppleScript there is no need to use
-# CPACK_DMG_DS_STORE, as the .DS_Store that is generated by the AppleScript
-# will be packaged.
-#
-# .. variable:: CPACK_DMG_BACKGROUND_IMAGE
-#
-# Path to an image file to be used as the background. This file will be
-# copied to .background/background.<ext>, where ext is the original image file
-# extension. The background image is installed into the image before
-# CPACK_DMG_DS_STORE_SETUP_SCRIPT is executed or CPACK_DMG_DS_STORE is
-# installed. By default no background image is set.
-#
-# .. variable:: CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK
-#
-# Default behaviour is to include a symlink to ``/Applications`` in the DMG.
-# Set this option to ``ON`` to avoid adding the symlink.
-#
-# .. variable:: CPACK_DMG_SLA_DIR
-#
-# Directory where license and menu files for different languages are stored.
-# Setting this causes CPack to look for a ``<language>.menu.txt`` and
-# ``<language>.license.txt`` file for every language defined in
-# ``CPACK_DMG_SLA_LANGUAGES``. If both this variable and
-# ``CPACK_RESOURCE_FILE_LICENSE`` are set, CPack will only look for the menu
-# files and use the same license file for all languages.
-#
-# .. variable:: CPACK_DMG_SLA_LANGUAGES
-#
-# Languages for which a license agreement is provided when mounting the
-# generated DMG. A menu file consists of 9 lines of text. The first line is
-# is the name of the language itself, uppercase, in English (e.g. German).
-# The other lines are translations of the following strings:
-#
-# - Agree
-# - Disagree
-# - Print
-# - Save...
-# - You agree to the terms of the License Agreement when you click the
-# "Agree" button.
-# - Software License Agreement
-# - This text cannot be saved. The disk may be full or locked, or the file
-# may be locked.
-# - Unable to print. Make sure you have selected a printer.
-#
-# For every language in this list, CPack will try to find files
-# ``<language>.menu.txt`` and ``<language>.license.txt`` in the directory
-# specified by the :variable:`CPACK_DMG_SLA_DIR` variable.
-#
-# .. variable:: CPACK_COMMAND_HDIUTIL
-#
-# Path to the hdiutil(1) command used to operate on disk image files on Mac
-# OS X. This variable can be used to override the automatically detected
-# command (or specify its location if the auto-detection fails to find it.)
-#
-# .. variable:: CPACK_COMMAND_SETFILE
-#
-# Path to the SetFile(1) command used to set extended attributes on files and
-# directories on Mac OS X. This variable can be used to override the
-# automatically detected command (or specify its location if the
-# auto-detection fails to find it.)
-#
-# .. variable:: CPACK_COMMAND_REZ
-#
-# Path to the Rez(1) command used to compile resources on Mac OS X. This
-# variable can be used to override the automatically detected command (or
-# specify its location if the auto-detection fails to find it.)
diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake
deleted file mode 100644
index ddf8b23ee..000000000
--- a/Modules/CPackDeb.cmake
+++ /dev/null
@@ -1,1049 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-#.rst:
-# CPackDeb
-# --------
-#
-# The built in (binary) CPack Deb generator (Unix only)
-#
-# Variables specific to CPack Debian (DEB) generator
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# CPackDeb may be used to create Deb package using :module:`CPack`.
-# CPackDeb is a :module:`CPack` generator thus it uses the ``CPACK_XXX``
-# variables used by :module:`CPack`.
-#
-# CPackDeb generator should work on any Linux host but it will produce
-# better deb package when Debian specific tools ``dpkg-xxx`` are usable on
-# the build system.
-#
-# CPackDeb has specific features which are controlled by the specifics
-# :code:`CPACK_DEBIAN_XXX` variables.
-#
-# :code:`CPACK_DEBIAN_<COMPONENT>_XXXX` variables may be used in order to have
-# **component** specific values. Note however that ``<COMPONENT>`` refers to
-# the **grouping name** written in upper case. It may be either a component name
-# or a component GROUP name.
-#
-# Here are some CPackDeb wiki resources that are here for historic reasons and
-# are no longer maintained but may still prove useful:
-#
-# - https://cmake.org/Wiki/CMake:CPackConfiguration
-# - https://cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29
-#
-# List of CPackDEB specific variables:
-#
-# .. variable:: CPACK_DEB_COMPONENT_INSTALL
-#
-# Enable component packaging for CPackDEB
-#
-# * Mandatory : NO
-# * Default : OFF
-#
-# If enabled (ON) multiple packages are generated. By default a single package
-# containing files of all components is generated.
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_NAME
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAME
-#
-# Set Package control field (variable is automatically transformed to lower
-# case).
-#
-# * Mandatory : YES
-# * Default :
-#
-# - :variable:`CPACK_PACKAGE_NAME` for non-component based
-# installations
-# - :variable:`CPACK_DEBIAN_PACKAGE_NAME` suffixed with -<COMPONENT>
-# for component-based installations.
-#
-# See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
-#
-# .. variable:: CPACK_DEBIAN_FILE_NAME
-# CPACK_DEBIAN_<COMPONENT>_FILE_NAME
-#
-# Package file name.
-#
-# * Mandatory : YES
-# * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].deb``
-#
-# This may be set to ``DEB-DEFAULT`` to allow CPackDeb to generate package file
-# name by itself in deb format::
-#
-# <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
-#
-# Alternatively provided package file name must end with ``.deb`` suffix.
-#
-# .. note::
-#
-# Preferred setting of this variable is ``DEB-DEFAULT`` but for backward
-# compatibility with CPackDeb in CMake prior to version 3.6 this feature
-# is disabled by default.
-#
-# .. note::
-#
-# By using non default filenames duplicate names may occur. Duplicate files
-# get overwritten and it is up to the packager to set the variables in a
-# manner that will prevent such errors.
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_VERSION
-#
-# The Debian package version
-#
-# * Mandatory : YES
-# * Default : :variable:`CPACK_PACKAGE_VERSION`
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_RELEASE
-#
-# The Debian package release - Debian revision number.
-#
-# * Mandatory : YES
-# * Default : 1
-#
-# This is the numbering of the DEB package itself, i.e. the version of the
-# packaging and not the version of the content (see
-# :variable:`CPACK_DEBIAN_PACKAGE_VERSION`). One may change the default value
-# if the previous packaging was buggy and/or you want to put here a fancy Linux
-# distro specific numbering.
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_ARCHITECTURE
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_ARCHITECTURE
-#
-# The Debian package architecture
-#
-# * Mandatory : YES
-# * Default : Output of :code:`dpkg --print-architecture` (or :code:`i386`
-# if :code:`dpkg` is not found)
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_DEPENDS
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS
-#
-# Sets the Debian dependencies of this package.
-#
-# * Mandatory : NO
-# * Default :
-#
-# - An empty string for non-component based installations
-# - :variable:`CPACK_DEBIAN_PACKAGE_DEPENDS` for component-based
-# installations.
-#
-# .. note::
-#
-# If :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` or
-# more specifically :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS`
-# is set for this component, the discovered dependencies will be appended
-# to :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS` instead of
-# :variable:`CPACK_DEBIAN_PACKAGE_DEPENDS`. If
-# :variable:`CPACK_DEBIAN_<COMPONENT>_PACKAGE_DEPENDS` is an empty string,
-# only the automatically discovered dependencies will be set for this
-# component.
-#
-# Example::
-#
-# set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libc6 (< 2.4)")
-#
-# .. variable:: CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS
-#
-# Sets inter component dependencies if listed with
-# :variable:`CPACK_COMPONENT_<compName>_DEPENDS` variables.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_MAINTAINER
-#
-# The Debian package maintainer
-#
-# * Mandatory : YES
-# * Default : :code:`CPACK_PACKAGE_CONTACT`
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_DESCRIPTION
-# CPACK_COMPONENT_<COMPONENT>_DESCRIPTION
-#
-# The Debian package description
-#
-# * Mandatory : YES
-# * Default :
-#
-# - :variable:`CPACK_DEBIAN_PACKAGE_DESCRIPTION` if set or
-# - :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`
-#
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_SECTION
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_SECTION
-#
-# Set Section control field e.g. admin, devel, doc, ...
-#
-# * Mandatory : YES
-# * Default : "devel"
-#
-# See https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
-#
-# .. variable:: CPACK_DEBIAN_ARCHIVE_TYPE
-#
-# The archive format used for creating the Debian package.
-#
-# * Mandatory : YES
-# * Default : "paxr"
-#
-# Possible values are:
-#
-# - paxr
-# - gnutar
-#
-# .. note::
-#
-# Default pax archive format is the most portable format and generates
-# packages that do not treat sparse files specially.
-# GNU tar format on the other hand supports longer filenames.
-#
-# .. variable:: CPACK_DEBIAN_COMPRESSION_TYPE
-#
-# The compression used for creating the Debian package.
-#
-# * Mandatory : YES
-# * Default : "gzip"
-#
-# Possible values are:
-#
-# - lzma
-# - xz
-# - bzip2
-# - gzip
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_PRIORITY
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_PRIORITY
-#
-# Set Priority control field e.g. required, important, standard, optional,
-# extra
-#
-# * Mandatory : YES
-# * Default : "optional"
-#
-# See https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_HOMEPAGE
-#
-# The URL of the web site for this package, preferably (when applicable) the
-# site from which the original source can be obtained and any additional
-# upstream documentation or information may be found.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# .. note::
-#
-# The content of this field is a simple URL without any surrounding
-# characters such as <>.
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_SHLIBDEPS
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_SHLIBDEPS
-#
-# May be set to ON in order to use :code:`dpkg-shlibdeps` to generate
-# better package dependency list.
-#
-# * Mandatory : NO
-# * Default :
-#
-# - :variable:`CPACK_DEBIAN_PACKAGE_SHLIBDEPS` if set or
-# - OFF
-#
-# .. note::
-#
-# You may need set :variable:`CMAKE_INSTALL_RPATH` to an appropriate value
-# if you use this feature, because if you don't :code:`dpkg-shlibdeps`
-# may fail to find your own shared libs.
-# See https://cmake.org/Wiki/CMake_RPATH_handling.
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_DEBUG
-#
-# May be set when invoking cpack in order to trace debug information
-# during CPackDeb run.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_PREDEPENDS
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_PREDEPENDS
-#
-# Sets the `Pre-Depends` field of the Debian package.
-# Like :variable:`Depends <CPACK_DEBIAN_PACKAGE_DEPENDS>`, except that it
-# also forces :code:`dpkg` to complete installation of the packages named
-# before even starting the installation of the package which declares the
-# pre-dependency.
-#
-# * Mandatory : NO
-# * Default :
-#
-# - An empty string for non-component based installations
-# - :variable:`CPACK_DEBIAN_PACKAGE_PREDEPENDS` for component-based
-# installations.
-#
-# See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_ENHANCES
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_ENHANCES
-#
-# Sets the `Enhances` field of the Debian package.
-# Similar to :variable:`Suggests <CPACK_DEBIAN_PACKAGE_SUGGESTS>` but works
-# in the opposite direction: declares that a package can enhance the
-# functionality of another package.
-#
-# * Mandatory : NO
-# * Default :
-#
-# - An empty string for non-component based installations
-# - :variable:`CPACK_DEBIAN_PACKAGE_ENHANCES` for component-based
-# installations.
-#
-# See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_BREAKS
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_BREAKS
-#
-# Sets the `Breaks` field of the Debian package.
-# When a binary package (P) declares that it breaks other packages (B),
-# :code:`dpkg` will not allow the package (P) which declares `Breaks` be
-# **unpacked** unless the packages that will be broken (B) are deconfigured
-# first.
-# As long as the package (P) is configured, the previously deconfigured
-# packages (B) cannot be reconfigured again.
-#
-# * Mandatory : NO
-# * Default :
-#
-# - An empty string for non-component based installations
-# - :variable:`CPACK_DEBIAN_PACKAGE_BREAKS` for component-based
-# installations.
-#
-# See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-breaks
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_CONFLICTS
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONFLICTS
-#
-# Sets the `Conflicts` field of the Debian package.
-# When one binary package declares a conflict with another using a `Conflicts`
-# field, :code:`dpkg` will not allow them to be unpacked on the system at
-# the same time.
-#
-# * Mandatory : NO
-# * Default :
-#
-# - An empty string for non-component based installations
-# - :variable:`CPACK_DEBIAN_PACKAGE_CONFLICTS` for component-based
-# installations.
-#
-# See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-conflicts
-#
-# .. note::
-#
-# This is a stronger restriction than
-# :variable:`Breaks <CPACK_DEBIAN_PACKAGE_BREAKS>`, which prevents the
-# broken package from being configured while the breaking package is in
-# the "Unpacked" state but allows both packages to be unpacked at the same
-# time.
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_PROVIDES
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_PROVIDES
-#
-# Sets the `Provides` field of the Debian package.
-# A virtual package is one which appears in the `Provides` control field of
-# another package.
-#
-# * Mandatory : NO
-# * Default :
-#
-# - An empty string for non-component based installations
-# - :variable:`CPACK_DEBIAN_PACKAGE_PROVIDES` for component-based
-# installations.
-#
-# See https://www.debian.org/doc/debian-policy/ch-relationships.html#s-virtual
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_REPLACES
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_REPLACES
-#
-# Sets the `Replaces` field of the Debian package.
-# Packages can declare in their control file that they should overwrite
-# files in certain other packages, or completely replace other packages.
-#
-# * Mandatory : NO
-# * Default :
-#
-# - An empty string for non-component based installations
-# - :variable:`CPACK_DEBIAN_PACKAGE_REPLACES` for component-based
-# installations.
-#
-# See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_RECOMMENDS
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_RECOMMENDS
-#
-# Sets the `Recommends` field of the Debian package.
-# Allows packages to declare a strong, but not absolute, dependency on other
-# packages.
-#
-# * Mandatory : NO
-# * Default :
-#
-# - An empty string for non-component based installations
-# - :variable:`CPACK_DEBIAN_PACKAGE_RECOMMENDS` for component-based
-# installations.
-#
-# See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_SUGGESTS
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_SUGGESTS
-#
-# Sets the `Suggests` field of the Debian package.
-# Allows packages to declare a suggested package install grouping.
-#
-# * Mandatory : NO
-# * Default :
-#
-# - An empty string for non-component based installations
-# - :variable:`CPACK_DEBIAN_PACKAGE_SUGGESTS` for component-based
-# installations.
-#
-# See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS
-#
-# * Mandatory : NO
-# * Default : OFF
-#
-# Allows to generate shlibs control file automatically. Compatibility is defined by
-# :variable:`CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY` variable value.
-#
-# .. note::
-#
-# Libraries are only considered if they have both library name and version
-# set. This can be done by setting SOVERSION property with
-# :command:`set_target_properties` command.
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY
-#
-# Compatibility policy for auto-generated shlibs control file.
-#
-# * Mandatory : NO
-# * Default : "="
-#
-# Defines compatibility policy for auto-generated shlibs control file.
-# Possible values: "=", ">="
-#
-# See https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-shlibdeps
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRA
-#
-# This variable allow advanced user to add custom script to the
-# control.tar.gz.
-# Typical usage is for conffiles, postinst, postrm, prerm.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# Usage::
-#
-# set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
-# "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
-#
-# .. note::
-#
-# The original permissions of the files will be used in the final
-# package unless the variable
-# :variable:`CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION` is set.
-# In particular, the scripts should have the proper executable
-# flag prior to the generation of the package.
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_STRICT_PERMISSION
-#
-# This variable indicates if the Debian policy on control files should be
-# strictly followed.
-#
-# * Mandatory : NO
-# * Default : FALSE
-#
-# Usage::
-#
-# set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
-#
-# .. note::
-#
-# This overrides the permissions on the original files, following the rules
-# set by Debian policy
-# https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
-#
-# .. variable:: CPACK_DEBIAN_PACKAGE_SOURCE
-# CPACK_DEBIAN_<COMPONENT>_PACKAGE_SOURCE
-#
-# Sets the ``Source`` field of the binary Debian package.
-# When the binary package name is not the same as the source package name
-# (in particular when several components/binaries are generated from one
-# source) the source from which the binary has been generated should be
-# indicated with the field ``Source``.
-#
-# * Mandatory : NO
-# * Default :
-#
-# - An empty string for non-component based installations
-# - :variable:`CPACK_DEBIAN_PACKAGE_SOURCE` for component-based
-# installations.
-#
-# See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
-#
-# .. note::
-#
-# This value is not interpreted. It is possible to pass an optional
-# revision number of the referenced source package as well.
-
-# CPack script for creating Debian package
-# Author: Mathieu Malaterre
-#
-# http://wiki.debian.org/HowToPackageForDebian
-
-if(CMAKE_BINARY_DIR)
- message(FATAL_ERROR "CPackDeb.cmake may only be used by CPack internally.")
-endif()
-
-if(NOT UNIX)
- message(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.")
-endif()
-
-function(cpack_deb_variable_fallback OUTPUT_VAR_NAME)
- set(FALLBACK_VAR_NAMES ${ARGN})
-
- foreach(variable_name IN LISTS FALLBACK_VAR_NAMES)
- if(${variable_name})
- set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE)
- break()
- endif()
- endforeach()
-endfunction()
-
-function(get_component_package_name var component)
- string(TOUPPER "${component}" component_upcase)
- if(CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME)
- string(TOLOWER "${CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME}" package_name)
- else()
- string(TOLOWER "${CPACK_DEBIAN_PACKAGE_NAME}-${component}" package_name)
- endif()
-
- set("${var}" "${package_name}" PARENT_SCOPE)
-endfunction()
-
-#extract library name and version for given shared object
-function(extract_so_info shared_object libname version)
- if(READELF_EXECUTABLE)
- execute_process(COMMAND "${READELF_EXECUTABLE}" -d "${shared_object}"
- WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
- RESULT_VARIABLE result
- OUTPUT_VARIABLE output
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if(result EQUAL 0)
- string(REGEX MATCH "\\(SONAME\\)[^\n]*\\[([^\n]+)\\.so\\.([^\n]*)\\]" soname "${output}")
- set(${libname} "${CMAKE_MATCH_1}" PARENT_SCOPE)
- set(${version} "${CMAKE_MATCH_2}" PARENT_SCOPE)
- else()
- message(WARNING "Error running readelf for \"${shared_object}\"")
- endif()
- else()
- message(FATAL_ERROR "Readelf utility is not available.")
- endif()
-endfunction()
-
-function(cpack_deb_prepare_package_vars)
- # CPACK_DEBIAN_PACKAGE_SHLIBDEPS
- # If specify OFF, only user depends are used
- if(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
- set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF)
- endif()
-
- set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_PATH}")
-
- # per component automatic discover: some of the component might not have
- # binaries.
- if(CPACK_DEB_PACKAGE_COMPONENT)
- string(TOUPPER "${CPACK_DEB_PACKAGE_COMPONENT}" _local_component_name)
- set(_component_shlibdeps_var "CPACK_DEBIAN_${_local_component_name}_PACKAGE_SHLIBDEPS")
-
- # if set, overrides the global configuration
- if(DEFINED ${_component_shlibdeps_var})
- set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS "${${_component_shlibdeps_var}}")
- if(CPACK_DEBIAN_PACKAGE_DEBUG)
- message("CPackDeb Debug: component '${CPACK_DEB_PACKAGE_COMPONENT}' dpkg-shlibdeps set to ${CPACK_DEBIAN_PACKAGE_SHLIBDEPS}")
- endif()
- endif()
- endif()
-
- if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OR CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS)
- # Generating binary list - Get type of all install files
- cmake_policy(PUSH)
- # Tell file(GLOB_RECURSE) not to follow directory symlinks
- # even if the project does not set this policy to NEW.
- cmake_policy(SET CMP0009 NEW)
- file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false RELATIVE "${WDIR}" "${WDIR}/*")
- cmake_policy(POP)
-
- find_program(FILE_EXECUTABLE file)
- if(NOT FILE_EXECUTABLE)
- message(FATAL_ERROR "CPackDeb: file utility is not available. CPACK_DEBIAN_PACKAGE_SHLIBDEPS and CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS options are not available.")
- endif()
-
- # get file info so that we can determine if file is executable or not
- unset(CPACK_DEB_INSTALL_FILES)
- foreach(FILE_ IN LISTS FILE_PATHS_)
- execute_process(COMMAND env LC_ALL=C ${FILE_EXECUTABLE} "./${FILE_}"
- WORKING_DIRECTORY "${WDIR}"
- RESULT_VARIABLE FILE_RESULT_
- OUTPUT_VARIABLE INSTALL_FILE_)
- if(NOT FILE_RESULT_ EQUAL 0)
- message (FATAL_ERROR "CPackDeb: execution of command: '${FILE_EXECUTABLE} ./${FILE_}' failed with exit code: ${FILE_RESULT_}")
- endif()
- list(APPEND CPACK_DEB_INSTALL_FILES "${INSTALL_FILE_}")
- endforeach()
-
- # Only dynamically linked ELF files are included
- # Extract only file name infront of ":"
- foreach(_FILE IN LISTS CPACK_DEB_INSTALL_FILES)
- if(_FILE MATCHES "ELF.*dynamically linked")
- string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
- list(APPEND CPACK_DEB_BINARY_FILES "${CMAKE_MATCH_1}")
- set(CONTAINS_EXECUTABLE_FILES_ TRUE)
- endif()
- if(_FILE MATCHES "ELF.*shared object")
- string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
- list(APPEND CPACK_DEB_SHARED_OBJECT_FILES "${CMAKE_MATCH_1}")
- endif()
- endforeach()
- endif()
-
- if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
- # dpkg-shlibdeps is a Debian utility for generating dependency list
- find_program(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps)
-
- if(SHLIBDEPS_EXECUTABLE)
- # Check version of the dpkg-shlibdeps tool using CPackDEB method
- execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --version
- OUTPUT_VARIABLE _TMP_VERSION
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if(_TMP_VERSION MATCHES "dpkg-shlibdeps version ([0-9]+\\.[0-9]+\\.[0-9]+)")
- set(SHLIBDEPS_EXECUTABLE_VERSION "${CMAKE_MATCH_1}")
- else()
- set(SHLIBDEPS_EXECUTABLE_VERSION "")
- endif()
-
- if(CPACK_DEBIAN_PACKAGE_DEBUG)
- message("CPackDeb Debug: dpkg-shlibdeps --version output is '${_TMP_VERSION}'")
- message("CPackDeb Debug: dpkg-shlibdeps version is <${SHLIBDEPS_EXECUTABLE_VERSION}>")
- endif()
-
- if(CONTAINS_EXECUTABLE_FILES_)
- message("CPackDeb: - Generating dependency list")
-
- # Create blank control file for running dpkg-shlibdeps
- # There might be some other way to invoke dpkg-shlibdeps without creating this file
- # but standard debian package should not have anything that can collide with this file or directory
- file(MAKE_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY}/debian)
- file(WRITE ${CPACK_TEMPORARY_DIRECTORY}/debian/control "")
-
- # Create a DEBIAN directory so that dpkg-shlibdeps can find the package dir when resolving $ORIGIN.
- file(MAKE_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN")
-
- # Add --ignore-missing-info if the tool supports it
- execute_process(COMMAND env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --help
- OUTPUT_VARIABLE _TMP_HELP
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- if(_TMP_HELP MATCHES "--ignore-missing-info")
- set(IGNORE_MISSING_INFO_FLAG "--ignore-missing-info")
- endif()
-
- # Execute dpkg-shlibdeps
- # --ignore-missing-info : allow dpkg-shlibdeps to run even if some libs do not belong to a package
- # -O : print to STDOUT
- execute_process(COMMAND ${SHLIBDEPS_EXECUTABLE} ${IGNORE_MISSING_INFO_FLAG} -O ${CPACK_DEB_BINARY_FILES}
- WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
- OUTPUT_VARIABLE SHLIBDEPS_OUTPUT
- RESULT_VARIABLE SHLIBDEPS_RESULT
- ERROR_VARIABLE SHLIBDEPS_ERROR
- OUTPUT_STRIP_TRAILING_WHITESPACE )
- if(CPACK_DEBIAN_PACKAGE_DEBUG)
- # dpkg-shlibdeps will throw some warnings if some input files are not binary
- message( "CPackDeb Debug: dpkg-shlibdeps warnings \n${SHLIBDEPS_ERROR}")
- endif()
- if(NOT SHLIBDEPS_RESULT EQUAL 0)
- message (FATAL_ERROR "CPackDeb: dpkg-shlibdeps: '${SHLIBDEPS_ERROR}';\n"
- "executed command: '${SHLIBDEPS_EXECUTABLE} ${IGNORE_MISSING_INFO_FLAG} -O ${CPACK_DEB_BINARY_FILES}';\n"
- "found files: '${INSTALL_FILE_}';\n"
- "files info: '${CPACK_DEB_INSTALL_FILES}';\n"
- "binary files: '${CPACK_DEB_BINARY_FILES}'")
- endif()
-
- #Get rid of prefix generated by dpkg-shlibdeps
- string(REGEX REPLACE "^.*Depends=" "" CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS "${SHLIBDEPS_OUTPUT}")
-
- if(CPACK_DEBIAN_PACKAGE_DEBUG)
- message("CPackDeb Debug: Found dependency: ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS} from output ${SHLIBDEPS_OUTPUT}")
- endif()
-
- # Remove blank control file
- # Might not be safe if package actual contain file or directory named debian
- file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/debian")
-
- # remove temporary directory that was created only for dpkg-shlibdeps execution
- file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN")
- else()
- if(CPACK_DEBIAN_PACKAGE_DEBUG)
- message(AUTHOR_WARNING "CPackDeb Debug: Using only user-provided depends because package does not contain executable files that link to shared libraries.")
- endif()
- endif()
- else()
- message("CPackDeb: Using only user-provided dependencies because dpkg-shlibdeps is not found.")
- endif()
-
- else()
- if(CPACK_DEBIAN_PACKAGE_DEBUG)
- message("CPackDeb Debug: Using only user-provided dependencies")
- endif()
- endif()
-
- # Let's define the control file found in debian package:
-
- # Binary package:
- # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles
-
- # DEBIAN/control
- # debian policy enforce lower case for package name
- # Package: (mandatory)
- if(NOT CPACK_DEBIAN_PACKAGE_NAME)
- string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
- endif()
-
- # Version: (mandatory)
- if(NOT CPACK_DEBIAN_PACKAGE_VERSION)
- if(NOT CPACK_PACKAGE_VERSION)
- message(FATAL_ERROR "CPackDeb: Debian package requires a package version")
- endif()
- set(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
- endif()
-
- # Architecture: (mandatory)
- if(CPACK_DEB_PACKAGE_COMPONENT AND CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE)
- set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE}")
- elseif(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
- # There is no such thing as i686 architecture on debian, you should use i386 instead
- # $ dpkg --print-architecture
- find_program(DPKG_CMD dpkg)
- if(NOT DPKG_CMD)
- message(STATUS "CPackDeb: Can not find dpkg in your path, default to i386.")
- set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
- endif()
- execute_process(COMMAND "${DPKG_CMD}" --print-architecture
- OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- endif()
-
- # Source: (optional)
- # in case several packages are constructed from a unique source
- # (multipackaging), the source may be indicated as well.
- # The source might contain a version if the generated package
- # version is different from the source version
- if(NOT CPACK_DEBIAN_PACKAGE_SOURCE)
- set(CPACK_DEBIAN_PACKAGE_SOURCE "")
- endif()
-
- # have a look at get_property(result GLOBAL PROPERTY ENABLED_FEATURES),
- # this returns the successful find_package() calls, maybe this can help
- # Depends:
- # You should set: DEBIAN_PACKAGE_DEPENDS
- # TODO: automate 'objdump -p | grep NEEDED'
-
- # if per-component variable, overrides the global CPACK_DEBIAN_PACKAGE_${variable_type_}
- # automatic dependency discovery will be performed afterwards.
- if(CPACK_DEB_PACKAGE_COMPONENT)
- foreach(value_type_ DEPENDS RECOMMENDS SUGGESTS PREDEPENDS ENHANCES BREAKS CONFLICTS PROVIDES REPLACES SOURCE SECTION PRIORITY NAME)
- set(_component_var "CPACK_DEBIAN_${_local_component_name}_PACKAGE_${value_type_}")
-
- # if set, overrides the global variable
- if(DEFINED ${_component_var})
- set(CPACK_DEBIAN_PACKAGE_${value_type_} "${${_component_var}}")
- if(CPACK_DEBIAN_PACKAGE_DEBUG)
- message("CPackDeb Debug: component '${_local_component_name}' ${value_type_} "
- "value set to '${CPACK_DEBIAN_PACKAGE_${value_type_}}'")
- endif()
- endif()
- endforeach()
-
- if(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS)
- set(COMPONENT_DEPENDS "")
- foreach (_PACK ${CPACK_COMPONENT_${_local_component_name}_DEPENDS})
- get_component_package_name(_PACK_NAME "${_PACK}")
- if(COMPONENT_DEPENDS)
- set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION}), ${COMPONENT_DEPENDS}")
- else()
- set(COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION})")
- endif()
- endforeach()
- if(COMPONENT_DEPENDS)
- if(CPACK_DEBIAN_PACKAGE_DEPENDS)
- set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}")
- else()
- set(CPACK_DEBIAN_PACKAGE_DEPENDS "${COMPONENT_DEPENDS}")
- endif()
- endif()
- endif()
- endif()
-
- # at this point, the CPACK_DEBIAN_PACKAGE_DEPENDS is properly set
- # to the minimal dependency of the package
- # Append automatically discovered dependencies .
- if(NOT "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}" STREQUAL "")
- if (CPACK_DEBIAN_PACKAGE_DEPENDS)
- set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
- else ()
- set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}")
- endif ()
- endif()
-
- if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
- message(STATUS "CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.")
- endif()
-
- # Maintainer: (mandatory)
- if(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
- if(NOT CPACK_PACKAGE_CONTACT)
- message(FATAL_ERROR "CPackDeb: Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER")
- endif()
- set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
- endif()
-
- # Description: (mandatory)
- if(NOT CPACK_DEB_PACKAGE_COMPONENT)
- if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
- if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
- message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION")
- endif()
- set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
- endif()
- else()
- set(component_description_var CPACK_COMPONENT_${_local_component_name}_DESCRIPTION)
-
- # component description overrides package description
- if(${component_description_var})
- set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${${component_description_var}})
- elseif(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
- if(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY)
- message(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION or ${component_description_var}")
- endif()
- set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
- endif()
- endif()
-
- # Section: (recommended)
- if(NOT CPACK_DEBIAN_PACKAGE_SECTION)
- set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
- endif()
-
- # Priority: (recommended)
- if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
- set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
- endif()
-
- if(CPACK_DEBIAN_ARCHIVE_TYPE)
- set(archive_types_ "paxr;gnutar")
- cmake_policy(PUSH)
- cmake_policy(SET CMP0057 NEW)
- if(NOT CPACK_DEBIAN_ARCHIVE_TYPE IN_LIST archive_types_)
- message(FATAL_ERROR "CPACK_DEBIAN_ARCHIVE_TYPE set to unsupported"
- "type ${CPACK_DEBIAN_ARCHIVE_TYPE}")
- endif()
- cmake_policy(POP)
- else()
- set(CPACK_DEBIAN_ARCHIVE_TYPE "paxr")
- endif()
-
- # Compression: (recommended)
- if(NOT CPACK_DEBIAN_COMPRESSION_TYPE)
- set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip")
- endif()
-
- # Recommends:
- # You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS
-
- # Suggests:
- # You should set: CPACK_DEBIAN_PACKAGE_SUGGESTS
-
- # CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
- # This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive)
- # Typical examples are:
- # - conffiles
- # - postinst
- # - postrm
- # - prerm
- # Usage:
- # set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
- # "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
-
- # Are we packaging components ?
- if(CPACK_DEB_PACKAGE_COMPONENT)
- # override values with per component version if set
- foreach(VAR_NAME_ "PACKAGE_CONTROL_EXTRA" "PACKAGE_CONTROL_STRICT_PERMISSION")
- if(CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_})
- set(CPACK_DEBIAN_${VAR_NAME_} "${CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_}}")
- endif()
- endforeach()
- get_component_package_name(CPACK_DEBIAN_PACKAGE_NAME ${_local_component_name})
- endif()
-
- set(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "")
-
- if (NOT CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY)
- set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=")
- endif()
-
- find_program(READELF_EXECUTABLE NAMES readelf)
-
- if(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS)
- if(READELF_EXECUTABLE)
- foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES)
- extract_so_info("${_FILE}" libname soversion)
- if(libname AND soversion)
- list(APPEND CPACK_DEBIAN_PACKAGE_SHLIBS_LIST
- "${libname} ${soversion} ${CPACK_DEBIAN_PACKAGE_NAME} (${CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY} ${CPACK_DEBIAN_PACKAGE_VERSION})")
- else()
- message(AUTHOR_WARNING "Shared library '${_FILE}' is missing soname or soversion. Library will not be added to DEBIAN/shlibs control file.")
- endif()
- endforeach()
- if (CPACK_DEBIAN_PACKAGE_SHLIBS_LIST)
- string(REPLACE ";" "\n" CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}")
- endif()
- else()
- message(FATAL_ERROR "Readelf utility is not available. CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS option is not available.")
- endif()
- endif()
-
- # add ldconfig call in default postrm and postint
- set(CPACK_ADD_LDCONFIG_CALL 0)
- foreach(_FILE ${CPACK_DEB_SHARED_OBJECT_FILES})
- get_filename_component(_DIR ${_FILE} DIRECTORY)
- # all files in CPACK_DEB_SHARED_OBJECT_FILES have dot at the beginning
- if(_DIR STREQUAL "./lib" OR _DIR STREQUAL "./usr/lib")
- set(CPACK_ADD_LDCONFIG_CALL 1)
- endif()
- endforeach()
-
- if(CPACK_ADD_LDCONFIG_CALL)
- set(CPACK_DEBIAN_GENERATE_POSTINST 1)
- set(CPACK_DEBIAN_GENERATE_POSTRM 1)
- foreach(f ${PACKAGE_CONTROL_EXTRA})
- get_filename_component(n "${f}" NAME)
- if("${n}" STREQUAL "postinst")
- set(CPACK_DEBIAN_GENERATE_POSTINST 0)
- endif()
- if("${n}" STREQUAL "postrm")
- set(CPACK_DEBIAN_GENERATE_POSTRM 0)
- endif()
- endforeach()
- else()
- set(CPACK_DEBIAN_GENERATE_POSTINST 0)
- set(CPACK_DEBIAN_GENERATE_POSTRM 0)
- endif()
-
- if(NOT CPACK_DEBIAN_PACKAGE_RELEASE)
- set(CPACK_DEBIAN_PACKAGE_RELEASE 1)
- endif()
-
-
- cpack_deb_variable_fallback("CPACK_DEBIAN_FILE_NAME"
- "CPACK_DEBIAN_${_local_component_name}_FILE_NAME"
- "CPACK_DEBIAN_FILE_NAME")
- if(CPACK_DEBIAN_FILE_NAME)
- if(CPACK_DEBIAN_FILE_NAME STREQUAL "DEB-DEFAULT")
- # Patch package file name to be in corrent debian format:
- # <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
- set(CPACK_OUTPUT_FILE_NAME
- "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
- else()
- cmake_policy(PUSH)
- cmake_policy(SET CMP0010 NEW)
- if(NOT CPACK_DEBIAN_FILE_NAME MATCHES ".*\\.deb")
- cmake_policy(POP)
- message(FATAL_ERROR "'${CPACK_DEBIAN_FILE_NAME}' is not a valid DEB package file name as it must end with '.deb'!")
- endif()
- cmake_policy(POP)
-
- set(CPACK_OUTPUT_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}")
- endif()
-
- set(CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_OUTPUT_FILE_NAME}")
- get_filename_component(BINARY_DIR "${CPACK_OUTPUT_FILE_PATH}" DIRECTORY)
- set(CPACK_OUTPUT_FILE_PATH "${BINARY_DIR}/${CPACK_OUTPUT_FILE_NAME}")
- endif() # else() back compatibility - don't change the name
-
- # Print out some debug information if we were asked for that
- if(CPACK_DEBIAN_PACKAGE_DEBUG)
- message("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY = '${CPACK_TOPLEVEL_DIRECTORY}'")
- message("CPackDeb:Debug: CPACK_TOPLEVEL_TAG = '${CPACK_TOPLEVEL_TAG}'")
- message("CPackDeb:Debug: CPACK_TEMPORARY_DIRECTORY = '${CPACK_TEMPORARY_DIRECTORY}'")
- message("CPackDeb:Debug: CPACK_OUTPUT_FILE_NAME = '${CPACK_OUTPUT_FILE_NAME}'")
- message("CPackDeb:Debug: CPACK_OUTPUT_FILE_PATH = '${CPACK_OUTPUT_FILE_PATH}'")
- message("CPackDeb:Debug: CPACK_PACKAGE_FILE_NAME = '${CPACK_PACKAGE_FILE_NAME}'")
- message("CPackDeb:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = '${CPACK_PACKAGE_INSTALL_DIRECTORY}'")
- message("CPackDeb:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = '${CPACK_TEMPORARY_PACKAGE_FILE_NAME}'")
- message("CPackDeb:Debug: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION = '${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}'")
- message("CPackDeb:Debug: CPACK_DEBIAN_PACKAGE_SOURCE = '${CPACK_DEBIAN_PACKAGE_SOURCE}'")
- endif()
-
- # For debian source packages:
- # debian/control
- # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles
-
- # .dsc
- # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-debiansourcecontrolfiles
-
- # Builds-Depends:
- #if(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS)
- # set(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS
- # "debhelper (>> 5.0.0), libncurses5-dev, tcl8.4"
- # )
- #endif()
-
- # move variables to parent scope so that they may be used to create debian package
- set(GEN_CPACK_OUTPUT_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}" PARENT_SCOPE)
- set(GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TEMPORARY_PACKAGE_FILE_NAME}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_DEBIAN_PACKAGE_VERSION}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_SECTION "${CPACK_DEBIAN_PACKAGE_SECTION}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_PRIORITY "${CPACK_DEBIAN_PACKAGE_PRIORITY}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_DEBIAN_PACKAGE_MAINTAINER}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_DEBIAN_PACKAGE_DESCRIPTION}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_ARCHIVE_TYPE "${CPACK_DEBIAN_ARCHIVE_TYPE}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_COMPRESSION_TYPE "${CPACK_DEBIAN_COMPRESSION_TYPE}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS "${CPACK_DEBIAN_PACKAGE_RECOMMENDS}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS "${CPACK_DEBIAN_PACKAGE_SUGGESTS}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_DEBIAN_PACKAGE_HOMEPAGE}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS "${CPACK_DEBIAN_PACKAGE_PREDEPENDS}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_ENHANCES "${CPACK_DEBIAN_PACKAGE_ENHANCES}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_BREAKS "${CPACK_DEBIAN_PACKAGE_BREAKS}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS "${CPACK_DEBIAN_PACKAGE_CONFLICTS}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_PROVIDES "${CPACK_DEBIAN_PACKAGE_PROVIDES}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_REPLACES "${CPACK_DEBIAN_PACKAGE_REPLACES}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_SHLIBS "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
- "${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_PACKAGE_SOURCE
- "${CPACK_DEBIAN_PACKAGE_SOURCE}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_GENERATE_POSTINST "${CPACK_DEBIAN_GENERATE_POSTINST}" PARENT_SCOPE)
- set(GEN_CPACK_DEBIAN_GENERATE_POSTRM "${CPACK_DEBIAN_GENERATE_POSTRM}" PARENT_SCOPE)
- set(GEN_WDIR "${WDIR}" PARENT_SCOPE)
-endfunction()
-
-cpack_deb_prepare_package_vars()
diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake
index c1cb52f16..42ef8c7b7 100644
--- a/Modules/CPackIFW.cmake
+++ b/Modules/CPackIFW.cmake
@@ -1,630 +1,331 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CPackIFW
-# --------
-#
-# .. _QtIFW: http://doc.qt.io/qtinstallerframework/index.html
-#
-# This module looks for the location of the command line utilities supplied
-# with the Qt Installer Framework (QtIFW_).
-#
-# The module also defines several commands to control the behavior of the
-# CPack ``IFW`` generator.
-#
-#
-# Overview
-# ^^^^^^^^
-#
-# CPack ``IFW`` generator helps you to create online and offline
-# binary cross-platform installers with a graphical user interface.
-#
-# CPack IFW generator prepares project installation and generates configuration
-# and meta information for QtIFW_ tools.
-#
-# The QtIFW_ provides a set of tools and utilities to create
-# installers for the supported desktop Qt platforms: Linux, Microsoft Windows,
-# and Mac OS X.
-#
-# You should also install QtIFW_ to use CPack ``IFW`` generator.
-#
-# Hints
-# ^^^^^
-#
-# Generally, the CPack ``IFW`` generator automatically finds QtIFW_ tools,
-# but if you don't use a default path for installation of the QtIFW_ tools,
-# the path may be specified in either a CMake or an environment variable:
-#
-# .. variable:: CPACK_IFW_ROOT
-#
-# An CMake variable which specifies the location of the QtIFW_ tool suite.
-#
-# The variable will be cached in the ``CPackConfig.cmake`` file and used at
-# CPack runtime.
-#
-# .. variable:: QTIFWDIR
-#
-# An environment variable which specifies the location of the QtIFW_ tool
-# suite.
-#
-# .. note::
-# The specified path should not contain "bin" at the end
-# (for example: "D:\\DevTools\\QtIFW2.0.5").
-#
-# The :variable:`CPACK_IFW_ROOT` variable has a higher priority and overrides
-# the value of the :variable:`QTIFWDIR` variable.
-#
-# Internationalization
-# ^^^^^^^^^^^^^^^^^^^^
-#
-# Some variables and command arguments support internationalization via
-# CMake script. This is an optional feature.
-#
-# Installers created by QtIFW_ tools have built-in support for
-# internationalization and many phrases are localized to many languages,
-# but this does not apply to the description of the your components and groups
-# that will be distributed.
-#
-# Localization of the description of your components and groups is useful for
-# users of your installers.
-#
-# A localized variable or argument can contain a single default value, and a
-# set of pairs the name of the locale and the localized value.
-#
-# For example:
-#
-# .. code-block:: cmake
-#
-# set(LOCALIZABLE_VARIABLE "Default value"
-# en "English value"
-# en_US "American value"
-# en_GB "Great Britain value"
-# )
-#
-# Variables
-# ^^^^^^^^^
-#
-# You can use the following variables to change behavior of CPack ``IFW``
-# generator.
-#
-# Debug
-# """"""
-#
-# .. variable:: CPACK_IFW_VERBOSE
-#
-# Set to ``ON`` to enable addition debug output.
-# By default is ``OFF``.
-#
-# Package
-# """""""
-#
-# .. variable:: CPACK_IFW_PACKAGE_TITLE
-#
-# Name of the installer as displayed on the title bar.
-# By default used :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`.
-#
-# .. variable:: CPACK_IFW_PACKAGE_PUBLISHER
-#
-# Publisher of the software (as shown in the Windows Control Panel).
-# By default used :variable:`CPACK_PACKAGE_VENDOR`.
-#
-# .. variable:: CPACK_IFW_PRODUCT_URL
-#
-# URL to a page that contains product information on your web site.
-#
-# .. variable:: CPACK_IFW_PACKAGE_ICON
-#
-# Filename for a custom installer icon. The actual file is '.icns' (Mac OS X),
-# '.ico' (Windows). No functionality on Unix.
-#
-# .. variable:: CPACK_IFW_PACKAGE_WINDOW_ICON
-#
-# Filename for a custom window icon in PNG format for the Installer
-# application.
-#
-# .. variable:: CPACK_IFW_PACKAGE_LOGO
-#
-# Filename for a logo is used as QWizard::LogoPixmap.
-#
-# .. variable:: CPACK_IFW_PACKAGE_WATERMARK
-#
-# Filename for a watermark is used as QWizard::WatermarkPixmap.
-#
-# .. variable:: CPACK_IFW_PACKAGE_BANNER
-#
-# Filename for a banner is used as QWizard::BannerPixmap.
-#
-# .. variable:: CPACK_IFW_PACKAGE_BACKGROUND
-#
-# Filename for an image used as QWizard::BackgroundPixmap (only used by MacStyle).
-#
-# .. variable:: CPACK_IFW_PACKAGE_WIZARD_STYLE
-#
-# Wizard style to be used ("Modern", "Mac", "Aero" or "Classic").
-#
-# .. variable:: CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH
-#
-# Default width of the wizard in pixels. Setting a banner image will override this.
-#
-# .. variable:: CPACK_IFW_PACKAGE_WIZARD_DEFAULT_HEIGHT
-#
-# Default height of the wizard in pixels. Setting a watermark image will override this.
-#
-# .. variable:: CPACK_IFW_PACKAGE_TITLE_COLOR
-#
-# Color of the titles and subtitles (takes an HTML color code, such as "#88FF33").
-#
-# .. variable:: CPACK_IFW_PACKAGE_START_MENU_DIRECTORY
-#
-# Name of the default program group for the product in the Windows Start menu.
-#
-# By default used :variable:`CPACK_IFW_PACKAGE_NAME`.
-#
-# .. variable:: CPACK_IFW_TARGET_DIRECTORY
-#
-# Default target directory for installation.
-# By default used
-# "@ApplicationsDir@/:variable:`CPACK_PACKAGE_INSTALL_DIRECTORY`"
-#
-# You can use predefined variables.
-#
-# .. variable:: CPACK_IFW_ADMIN_TARGET_DIRECTORY
-#
-# Default target directory for installation with administrator rights.
-#
-# You can use predefined variables.
-#
-# .. variable:: CPACK_IFW_PACKAGE_GROUP
-#
-# The group, which will be used to configure the root package
-#
-# .. variable:: CPACK_IFW_PACKAGE_NAME
-#
-# The root package name, which will be used if configuration group is not
-# specified
-#
-# .. variable:: CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME
-#
-# Filename of the generated maintenance tool.
-# The platform-specific executable file extension is appended.
-#
-# By default used QtIFW_ defaults (``maintenancetool``).
-#
-# .. variable:: CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE
-#
-# Filename for the configuration of the generated maintenance tool.
-#
-# By default used QtIFW_ defaults (``maintenancetool.ini``).
-#
-# .. variable:: CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS
-#
-# Set to ``ON`` if the installation path can contain non-ASCII characters.
-#
-# Is ``ON`` for QtIFW_ less 2.0 tools.
-#
-# .. variable:: CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH
-#
-# Set to ``OFF`` if the installation path cannot contain space characters.
-#
-# Is ``ON`` for QtIFW_ less 2.0 tools.
-#
-# .. variable:: CPACK_IFW_PACKAGE_CONTROL_SCRIPT
-#
-# Filename for a custom installer control script.
-#
-# .. variable:: CPACK_IFW_PACKAGE_RESOURCES
-#
-# List of additional resources ('.qrc' files) to include in the installer
-# binary.
-#
-# You can use :command:`cpack_ifw_add_package_resources` command to resolve
-# relative paths.
-#
-# .. variable:: CPACK_IFW_REPOSITORIES_ALL
-#
-# The list of remote repositories.
-#
-# The default value of this variable is computed by CPack and contains
-# all repositories added with command :command:`cpack_ifw_add_repository`
-# or updated with command :command:`cpack_ifw_update_repository`.
-#
-# .. variable:: CPACK_IFW_DOWNLOAD_ALL
-#
-# If this is ``ON`` all components will be downloaded.
-# By default is ``OFF`` or used value
-# from ``CPACK_DOWNLOAD_ALL`` if set
-#
-# Components
-# """"""""""
-#
-# .. variable:: CPACK_IFW_RESOLVE_DUPLICATE_NAMES
-#
-# Resolve duplicate names when installing components with groups.
-#
-# .. variable:: CPACK_IFW_PACKAGES_DIRECTORIES
-#
-# Additional prepared packages dirs that will be used to resolve
-# dependent components.
-#
-# Tools
-# """""
-#
-# .. variable:: CPACK_IFW_FRAMEWORK_VERSION
-#
-# The version of used QtIFW_ tools.
-#
-# .. variable:: CPACK_IFW_BINARYCREATOR_EXECUTABLE
-#
-# The path to "binarycreator" command line client.
-#
-# This variable is cached and may be configured if needed.
-#
-# .. variable:: CPACK_IFW_REPOGEN_EXECUTABLE
-#
-# The path to "repogen" command line client.
-#
-# This variable is cached and may be configured if needed.
-#
-# .. variable:: CPACK_IFW_INSTALLERBASE_EXECUTABLE
-#
-# The path to "installerbase" installer executable base.
-#
-# This variable is cached and may be configured if needed.
-#
-# .. variable:: CPACK_IFW_DEVTOOL_EXECUTABLE
-#
-# The path to "devtool" command line client.
-#
-# This variable is cached and may be configured if needed.
-#
-# Commands
-# ^^^^^^^^^
-#
-# The module defines the following commands:
-#
-# .. command:: cpack_ifw_configure_component
-#
-# Sets the arguments specific to the CPack IFW generator.
-#
-# ::
-#
-# cpack_ifw_configure_component(<compname> [COMMON] [ESSENTIAL] [VIRTUAL]
-# [FORCED_INSTALLATION] [REQUIRES_ADMIN_RIGHTS]
-# [NAME <name>]
-# [DISPLAY_NAME <display_name>] # Note: Internationalization supported
-# [DESCRIPTION <description>] # Note: Internationalization supported
-# [UPDATE_TEXT <update_text>]
-# [VERSION <version>]
-# [RELEASE_DATE <release_date>]
-# [SCRIPT <script>]
-# [PRIORITY|SORTING_PRIORITY <sorting_priority>] # Note: PRIORITY is deprecated
-# [DEPENDS|DEPENDENCIES <com_id> ...]
-# [AUTO_DEPEND_ON <comp_id> ...]
-# [LICENSES <display_name> <file_path> ...]
-# [DEFAULT <value>]
-# [USER_INTERFACES <file_path> <file_path> ...]
-# [TRANSLATIONS <file_path> <file_path> ...])
-#
-# This command should be called after :command:`cpack_add_component` command.
-#
-# ``COMMON``
-# if set, then the component will be packaged and installed as part
-# of a group to which it belongs.
-#
-# ``ESSENTIAL``
-# if set, then the package manager stays disabled until that
-# component is updated.
-#
-# ``VIRTUAL``
-# if set, then the component will be hidden from the installer.
-# It is a equivalent of the ``HIDDEN`` option from the
-# :command:`cpack_add_component` command.
-#
-# ``FORCED_INSTALLATION``
-# if set, then the component must always be installed.
-# It is a equivalent of the ``REQUARED`` option from the
-# :command:`cpack_add_component` command.
-#
-# ``REQUIRES_ADMIN_RIGHTS``
-# set it if the component needs to be installed with elevated permissions.
-#
-# ``NAME``
-# is used to create domain-like identification for this component.
-# By default used origin component name.
-#
-# ``DISPLAY_NAME``
-# set to rewrite original name configured by
-# :command:`cpack_add_component` command.
-#
-# ``DESCRIPTION``
-# set to rewrite original description configured by
-# :command:`cpack_add_component` command.
-#
-# ``UPDATE_TEXT``
-# will be added to the component description if this is an update to
-# the component.
-#
-# ``VERSION``
-# is version of component.
-# By default used :variable:`CPACK_PACKAGE_VERSION`.
-#
-# ``RELEASE_DATE``
-# keep empty to auto generate.
-#
-# ``SCRIPT``
-# is a relative or absolute path to operations script
-# for this component.
-#
-# ``PRIORITY`` | ``SORTING_PRIORITY``
-# is priority of the component in the tree.
-# The ``PRIORITY`` option is deprecated and will be removed in a future
-# version of CMake. Please use ``SORTING_PRIORITY`` option instead.
-#
-# ``DEPENDS`` | ``DEPENDENCIES``
-# list of dependency component or component group identifiers in
-# QtIFW_ style.
-#
-# ``AUTO_DEPEND_ON``
-# list of identifiers of component or component group in QtIFW_ style
-# that this component has an automatic dependency on.
-#
-# ``LICENSES``
-# pair of <display_name> and <file_path> of license text for this
-# component. You can specify more then one license.
-#
-# ``DEFAULT``
-# Possible values are: TRUE, FALSE, and SCRIPT.
-# Set to FALSE to disable the component in the installer or to SCRIPT
-# to resolved during runtime (don't forget add the file of the script
-# as a value of the ``SCRIPT`` option).
-#
-# ``USER_INTERFACES``
-# is a list of <file_path> ('.ui' files) representing pages to load.
-#
-# ``TRANSLATIONS``
-# is a list of <file_path> ('.qm' files) representing translations to load.
-#
-#
-# .. command:: cpack_ifw_configure_component_group
-#
-# Sets the arguments specific to the CPack IFW generator.
-#
-# ::
-#
-# cpack_ifw_configure_component_group(<groupname> [VIRTUAL]
-# [FORCED_INSTALLATION] [REQUIRES_ADMIN_RIGHTS]
-# [NAME <name>]
-# [DISPLAY_NAME <display_name>] # Note: Internationalization supported
-# [DESCRIPTION <description>] # Note: Internationalization supported
-# [UPDATE_TEXT <update_text>]
-# [VERSION <version>]
-# [RELEASE_DATE <release_date>]
-# [SCRIPT <script>]
-# [PRIORITY|SORTING_PRIORITY <sorting_priority>] # Note: PRIORITY is deprecated
-# [DEPENDS|DEPENDENCIES <com_id> ...]
-# [AUTO_DEPEND_ON <comp_id> ...]
-# [LICENSES <display_name> <file_path> ...]
-# [DEFAULT <value>]
-# [USER_INTERFACES <file_path> <file_path> ...]
-# [TRANSLATIONS <file_path> <file_path> ...])
-#
-# This command should be called after :command:`cpack_add_component_group`
-# command.
-#
-# ``VIRTUAL``
-# if set, then the group will be hidden from the installer.
-# Note that setting this on a root component does not work.
-#
-# ``FORCED_INSTALLATION``
-# if set, then the group must always be installed.
-#
-# ``REQUIRES_ADMIN_RIGHTS``
-# set it if the component group needs to be installed with elevated
-# permissions.
-#
-# ``NAME``
-# is used to create domain-like identification for this component group.
-# By default used origin component group name.
-#
-# ``DISPLAY_NAME``
-# set to rewrite original name configured by
-# :command:`cpack_add_component_group` command.
-#
-# ``DESCRIPTION``
-# set to rewrite original description configured by
-# :command:`cpack_add_component_group` command.
-#
-# ``UPDATE_TEXT``
-# will be added to the component group description if this is an update to
-# the component group.
-#
-# ``VERSION``
-# is version of component group.
-# By default used :variable:`CPACK_PACKAGE_VERSION`.
-#
-# ``RELEASE_DATE``
-# keep empty to auto generate.
-#
-# ``SCRIPT``
-# is a relative or absolute path to operations script
-# for this component group.
-#
-# ``PRIORITY`` | ``SORTING_PRIORITY``
-# is priority of the component group in the tree.
-# The ``PRIORITY`` option is deprecated and will be removed in a future
-# version of CMake. Please use ``SORTING_PRIORITY`` option instead.
-#
-# ``DEPENDS`` | ``DEPENDENCIES``
-# list of dependency component or component group identifiers in
-# QtIFW_ style.
-#
-# ``AUTO_DEPEND_ON``
-# list of identifiers of component or component group in QtIFW_ style
-# that this component group has an automatic dependency on.
-#
-# ``LICENSES``
-# pair of <display_name> and <file_path> of license text for this
-# component group. You can specify more then one license.
-#
-# ``DEFAULT``
-# Possible values are: TRUE, FALSE, and SCRIPT.
-# Set to TRUE to preselect the group in the installer
-# (this takes effect only on groups that have no visible child components)
-# or to SCRIPT to resolved during runtime (don't forget add the file of
-# the script as a value of the ``SCRIPT`` option).
-#
-# ``USER_INTERFACES``
-# is a list of <file_path> ('.ui' files) representing pages to load.
-#
-# ``TRANSLATIONS``
-# is a list of <file_path> ('.qm' files) representing translations to load.
-#
-#
-# .. command:: cpack_ifw_add_repository
-#
-# Add QtIFW_ specific remote repository to binary installer.
-#
-# ::
-#
-# cpack_ifw_add_repository(<reponame> [DISABLED]
-# URL <url>
-# [USERNAME <username>]
-# [PASSWORD <password>]
-# [DISPLAY_NAME <display_name>])
-#
-# This command will also add the <reponame> repository
-# to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`.
-#
-# ``DISABLED``
-# if set, then the repository will be disabled by default.
-#
-# ``URL``
-# is points to a list of available components.
-#
-# ``USERNAME``
-# is used as user on a protected repository.
-#
-# ``PASSWORD``
-# is password to use on a protected repository.
-#
-# ``DISPLAY_NAME``
-# is string to display instead of the URL.
-#
-#
-# .. command:: cpack_ifw_update_repository
-#
-# Update QtIFW_ specific repository from remote repository.
-#
-# ::
-#
-# cpack_ifw_update_repository(<reponame>
-# [[ADD|REMOVE] URL <url>]|
-# [REPLACE OLD_URL <old_url> NEW_URL <new_url>]]
-# [USERNAME <username>]
-# [PASSWORD <password>]
-# [DISPLAY_NAME <display_name>])
-#
-# This command will also add the <reponame> repository
-# to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`.
-#
-# ``URL``
-# is points to a list of available components.
-#
-# ``OLD_URL``
-# is points to a list that will replaced.
-#
-# ``NEW_URL``
-# is points to a list that will replace to.
-#
-# ``USERNAME``
-# is used as user on a protected repository.
-#
-# ``PASSWORD``
-# is password to use on a protected repository.
-#
-# ``DISPLAY_NAME``
-# is string to display instead of the URL.
-#
-#
-# .. command:: cpack_ifw_add_package_resources
-#
-# Add additional resources in the installer binary.
-#
-# ::
-#
-# cpack_ifw_add_package_resources(<file_path> <file_path> ...)
-#
-# This command will also add the specified files
-# to a variable :variable:`CPACK_IFW_PACKAGE_RESOURCES`.
-#
-#
-# Example usage
-# ^^^^^^^^^^^^^
-#
-# .. code-block:: cmake
-#
-# set(CPACK_PACKAGE_NAME "MyPackage")
-# set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyPackage Installation Example")
-# set(CPACK_PACKAGE_VERSION "1.0.0") # Version of installer
-#
-# include(CPack)
-# include(CPackIFW)
-#
-# cpack_add_component(myapp
-# DISPLAY_NAME "MyApp"
-# DESCRIPTION "My Application") # Default description
-# cpack_ifw_configure_component(myapp
-# DESCRIPTION ru_RU "Мое Приложение" # Localized description
-# VERSION "1.2.3" # Version of component
-# SCRIPT "operations.qs")
-# cpack_add_component(mybigplugin
-# DISPLAY_NAME "MyBigPlugin"
-# DESCRIPTION "My Big Downloadable Plugin"
-# DOWNLOADED)
-# cpack_ifw_add_repository(myrepo
-# URL "http://example.com/ifw/repo/myapp"
-# DISPLAY_NAME "My Application Repository")
-#
-#
-# Online installer
-# ^^^^^^^^^^^^^^^^
-#
-# By default CPack IFW generator makes offline installer. This means that all
-# components will be packaged into a binary file.
-#
-# To make a component downloaded, you must set the ``DOWNLOADED`` option in
-# :command:`cpack_add_component`.
-#
-# Then you would use the command :command:`cpack_configure_downloads`.
-# If you set ``ALL`` option all components will be downloaded.
-#
-# You also can use command :command:`cpack_ifw_add_repository` and
-# variable :variable:`CPACK_IFW_DOWNLOAD_ALL` for more specific configuration.
-#
-# CPack IFW generator creates "repository" dir in current binary dir. You
-# would copy content of this dir to specified ``site`` (``url``).
-#
-# See Also
-# ^^^^^^^^
-#
-# Qt Installer Framework Manual:
-#
-# * Index page:
-# http://doc.qt.io/qtinstallerframework/index.html
-#
-# * Component Scripting:
-# http://doc.qt.io/qtinstallerframework/scripting.html
-#
-# * Predefined Variables:
-# http://doc.qt.io/qtinstallerframework/scripting.html#predefined-variables
-#
-# * Promoting Updates:
-# http://doc.qt.io/qtinstallerframework/ifw-updates.html
-#
-# Download Qt Installer Framework for you platform from Qt site:
-# http://download.qt.io/official_releases/qt-installer-framework
-#
+#[=======================================================================[.rst:
+CPackIFW
+--------
+
+The documentation for the CPack IFW generator has moved here: :cpack_gen:`CPack IFW Generator`
+
+.. _QtIFW: http://doc.qt.io/qtinstallerframework/index.html
+
+This module looks for the location of the command line utilities supplied
+with the Qt Installer Framework (QtIFW_).
+
+The module also defines several commands to control the behavior of the
+CPack ``IFW`` generator.
+
+Commands
+^^^^^^^^
+
+The module defines the following commands:
+
+.. command:: cpack_ifw_configure_component
+
+ Sets the arguments specific to the CPack IFW generator.
+
+ ::
+
+ cpack_ifw_configure_component(<compname> [COMMON] [ESSENTIAL] [VIRTUAL]
+ [FORCED_INSTALLATION] [REQUIRES_ADMIN_RIGHTS]
+ [NAME <name>]
+ [DISPLAY_NAME <display_name>] # Note: Internationalization supported
+ [DESCRIPTION <description>] # Note: Internationalization supported
+ [UPDATE_TEXT <update_text>]
+ [VERSION <version>]
+ [RELEASE_DATE <release_date>]
+ [SCRIPT <script>]
+ [PRIORITY|SORTING_PRIORITY <sorting_priority>] # Note: PRIORITY is deprecated
+ [DEPENDS|DEPENDENCIES <com_id> ...]
+ [AUTO_DEPEND_ON <comp_id> ...]
+ [LICENSES <display_name> <file_path> ...]
+ [DEFAULT <value>]
+ [USER_INTERFACES <file_path> <file_path> ...]
+ [TRANSLATIONS <file_path> <file_path> ...]
+ [REPLACES <comp_id> ...]
+ [CHECKABLE <value>])
+
+ This command should be called after :command:`cpack_add_component` command.
+
+ ``COMMON``
+ if set, then the component will be packaged and installed as part
+ of a group to which it belongs.
+
+ ``ESSENTIAL``
+ if set, then the package manager stays disabled until that
+ component is updated.
+
+ ``VIRTUAL``
+ if set, then the component will be hidden from the installer.
+ It is a equivalent of the ``HIDDEN`` option from the
+ :command:`cpack_add_component` command.
+
+ ``FORCED_INSTALLATION``
+ if set, then the component must always be installed.
+ It is a equivalent of the ``REQUARED`` option from the
+ :command:`cpack_add_component` command.
+
+ ``REQUIRES_ADMIN_RIGHTS``
+ set it if the component needs to be installed with elevated permissions.
+
+ ``NAME``
+ is used to create domain-like identification for this component.
+ By default used origin component name.
+
+ ``DISPLAY_NAME``
+ set to rewrite original name configured by
+ :command:`cpack_add_component` command.
+
+ ``DESCRIPTION``
+ set to rewrite original description configured by
+ :command:`cpack_add_component` command.
+
+ ``UPDATE_TEXT``
+ will be added to the component description if this is an update to
+ the component.
+
+ ``VERSION``
+ is version of component.
+ By default used :variable:`CPACK_PACKAGE_VERSION`.
+
+ ``RELEASE_DATE``
+ keep empty to auto generate.
+
+ ``SCRIPT``
+ is a relative or absolute path to operations script
+ for this component.
+
+ ``PRIORITY`` | ``SORTING_PRIORITY``
+ is priority of the component in the tree.
+ The ``PRIORITY`` option is deprecated and will be removed in a future
+ version of CMake. Please use ``SORTING_PRIORITY`` option instead.
+
+ ``DEPENDS`` | ``DEPENDENCIES``
+ list of dependency component or component group identifiers in
+ QtIFW_ style.
+
+ ``AUTO_DEPEND_ON``
+ list of identifiers of component or component group in QtIFW_ style
+ that this component has an automatic dependency on.
+
+ ``LICENSES``
+ pair of <display_name> and <file_path> of license text for this
+ component. You can specify more then one license.
+
+ ``DEFAULT``
+ Possible values are: TRUE, FALSE, and SCRIPT.
+ Set to FALSE to disable the component in the installer or to SCRIPT
+ to resolved during runtime (don't forget add the file of the script
+ as a value of the ``SCRIPT`` option).
+
+ ``USER_INTERFACES``
+ is a list of <file_path> ('.ui' files) representing pages to load.
+
+ ``TRANSLATIONS``
+ is a list of <file_path> ('.qm' files) representing translations to load.
+
+ ``REPLACES``
+ list of identifiers of component or component group to replace.
+
+ ``CHECKABLE``
+ Possible values are: TRUE, FALSE.
+ Set to FALSE if you want to hide the checkbox for an item.
+ This is useful when only a few subcomponents should be selected
+ instead of all.
+
+
+.. command:: cpack_ifw_configure_component_group
+
+ Sets the arguments specific to the CPack IFW generator.
+
+ ::
+
+ cpack_ifw_configure_component_group(<groupname> [VIRTUAL]
+ [FORCED_INSTALLATION] [REQUIRES_ADMIN_RIGHTS]
+ [NAME <name>]
+ [DISPLAY_NAME <display_name>] # Note: Internationalization supported
+ [DESCRIPTION <description>] # Note: Internationalization supported
+ [UPDATE_TEXT <update_text>]
+ [VERSION <version>]
+ [RELEASE_DATE <release_date>]
+ [SCRIPT <script>]
+ [PRIORITY|SORTING_PRIORITY <sorting_priority>] # Note: PRIORITY is deprecated
+ [DEPENDS|DEPENDENCIES <com_id> ...]
+ [AUTO_DEPEND_ON <comp_id> ...]
+ [LICENSES <display_name> <file_path> ...]
+ [DEFAULT <value>]
+ [USER_INTERFACES <file_path> <file_path> ...]
+ [TRANSLATIONS <file_path> <file_path> ...]
+ [REPLACES <comp_id> ...]
+ [CHECKABLE <value>])
+
+ This command should be called after :command:`cpack_add_component_group`
+ command.
+
+ ``VIRTUAL``
+ if set, then the group will be hidden from the installer.
+ Note that setting this on a root component does not work.
+
+ ``FORCED_INSTALLATION``
+ if set, then the group must always be installed.
+
+ ``REQUIRES_ADMIN_RIGHTS``
+ set it if the component group needs to be installed with elevated
+ permissions.
+
+ ``NAME``
+ is used to create domain-like identification for this component group.
+ By default used origin component group name.
+
+ ``DISPLAY_NAME``
+ set to rewrite original name configured by
+ :command:`cpack_add_component_group` command.
+
+ ``DESCRIPTION``
+ set to rewrite original description configured by
+ :command:`cpack_add_component_group` command.
+
+ ``UPDATE_TEXT``
+ will be added to the component group description if this is an update to
+ the component group.
+
+ ``VERSION``
+ is version of component group.
+ By default used :variable:`CPACK_PACKAGE_VERSION`.
+
+ ``RELEASE_DATE``
+ keep empty to auto generate.
+
+ ``SCRIPT``
+ is a relative or absolute path to operations script
+ for this component group.
+
+ ``PRIORITY`` | ``SORTING_PRIORITY``
+ is priority of the component group in the tree.
+ The ``PRIORITY`` option is deprecated and will be removed in a future
+ version of CMake. Please use ``SORTING_PRIORITY`` option instead.
+
+ ``DEPENDS`` | ``DEPENDENCIES``
+ list of dependency component or component group identifiers in
+ QtIFW_ style.
+
+ ``AUTO_DEPEND_ON``
+ list of identifiers of component or component group in QtIFW_ style
+ that this component group has an automatic dependency on.
+
+ ``LICENSES``
+ pair of <display_name> and <file_path> of license text for this
+ component group. You can specify more then one license.
+
+ ``DEFAULT``
+ Possible values are: TRUE, FALSE, and SCRIPT.
+ Set to TRUE to preselect the group in the installer
+ (this takes effect only on groups that have no visible child components)
+ or to SCRIPT to resolved during runtime (don't forget add the file of
+ the script as a value of the ``SCRIPT`` option).
+
+ ``USER_INTERFACES``
+ is a list of <file_path> ('.ui' files) representing pages to load.
+
+ ``TRANSLATIONS``
+ is a list of <file_path> ('.qm' files) representing translations to load.
+
+ ``REPLACES``
+ list of identifiers of component or component group to replace.
+
+ ``CHECKABLE``
+ Possible values are: TRUE, FALSE.
+ Set to FALSE if you want to hide the checkbox for an item.
+ This is useful when only a few subcomponents should be selected
+ instead of all.
+
+
+.. command:: cpack_ifw_add_repository
+
+ Add QtIFW_ specific remote repository to binary installer.
+
+ ::
+
+ cpack_ifw_add_repository(<reponame> [DISABLED]
+ URL <url>
+ [USERNAME <username>]
+ [PASSWORD <password>]
+ [DISPLAY_NAME <display_name>])
+
+ This command will also add the <reponame> repository
+ to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`.
+
+ ``DISABLED``
+ if set, then the repository will be disabled by default.
+
+ ``URL``
+ is points to a list of available components.
+
+ ``USERNAME``
+ is used as user on a protected repository.
+
+ ``PASSWORD``
+ is password to use on a protected repository.
+
+ ``DISPLAY_NAME``
+ is string to display instead of the URL.
+
+
+.. command:: cpack_ifw_update_repository
+
+ Update QtIFW_ specific repository from remote repository.
+
+ ::
+
+ cpack_ifw_update_repository(<reponame>
+ [[ADD|REMOVE] URL <url>]|
+ [REPLACE OLD_URL <old_url> NEW_URL <new_url>]]
+ [USERNAME <username>]
+ [PASSWORD <password>]
+ [DISPLAY_NAME <display_name>])
+
+ This command will also add the <reponame> repository
+ to a variable :variable:`CPACK_IFW_REPOSITORIES_ALL`.
+
+ ``URL``
+ is points to a list of available components.
+
+ ``OLD_URL``
+ is points to a list that will replaced.
+
+ ``NEW_URL``
+ is points to a list that will replace to.
+
+ ``USERNAME``
+ is used as user on a protected repository.
+
+ ``PASSWORD``
+ is password to use on a protected repository.
+
+ ``DISPLAY_NAME``
+ is string to display instead of the URL.
+
+
+.. command:: cpack_ifw_add_package_resources
+
+ Add additional resources in the installer binary.
+
+ ::
+
+ cpack_ifw_add_package_resources(<file_path> <file_path> ...)
+
+ This command will also add the specified files
+ to a variable :variable:`CPACK_IFW_PACKAGE_RESOURCES`.
+
+#]=======================================================================]
+
+# TODO:
+# All of the internal implementation CMake modules for other CPack generators
+# have been moved into the Internal/CPack directory. This one has not, because
+# it contains user-facing macros which would be lost if it were moved. At some
+# point, this module should be split into user-facing macros (which would live
+# in this module) and internal implementation details (which would live in
+# Internal/CPack/CPackIFW.cmake).
#=============================================================================
# Search Qt Installer Framework tools
@@ -776,7 +477,7 @@ if(CPACK_IFW_INSTALLERBASE_EXECUTABLE AND NOT CPACK_IFW_FRAMEWORK_VERSION_FORCED
endif()
endif()
endforeach()
- # Finaly try to get version from executable path
+ # Finally try to get version from executable path
if(NOT CPACK_IFW_FRAMEWORK_VERSION)
string(REGEX MATCH "[0-9]+(\\.[0-9]+)*"
CPACK_IFW_FRAMEWORK_VERSION "${CPACK_IFW_INSTALLERBASE_EXECUTABLE}")
@@ -796,7 +497,7 @@ if(CPACK_IFW_VERBOSE)
endif()
endif()
if(CPACK_IFW_INSTALLERBASE_EXECUTABLE AND NOT CPACK_IFW_FRAMEWORK_VERSION)
- message(WARNING "Could not detect QtIFW tools version. Set used version to variable \"CPACK_IFW_FRAMEWORK_VERSION_FORCED\" manualy.")
+ message(WARNING "Could not detect QtIFW tools version. Set used version to variable \"CPACK_IFW_FRAMEWORK_VERSION_FORCED\" manually.")
endif()
#=============================================================================
@@ -817,13 +518,13 @@ macro(_cpack_ifw_resolve_script _variable)
get_filename_component(${_ifw_script_macro} ${_ifw_script_file} ABSOLUTE)
set(_ifw_script_file ${${_ifw_script_macro}})
if(NOT EXISTS ${_ifw_script_file})
- message(WARNING "CPack IFW: script file \"${_ifw_script_file}\" is not exists")
+ message(WARNING "CPack IFW: script file \"${_ifw_script_file}\" does not exist")
set(${_ifw_script_macro})
endif()
endif()
endmacro()
-# Resolve full path to lisense file
+# Resolve full path to license file
macro(_cpack_ifw_resolve_lisenses _variable)
if(${_variable})
set(_ifw_license_file FALSE)
@@ -863,8 +564,8 @@ macro(cpack_ifw_configure_component compname)
string(TOUPPER ${compname} _CPACK_IFWCOMP_UNAME)
set(_IFW_OPT COMMON ESSENTIAL VIRTUAL FORCED_INSTALLATION REQUIRES_ADMIN_RIGHTS)
- set(_IFW_ARGS NAME VERSION RELEASE_DATE SCRIPT PRIORITY SORTING_PRIORITY UPDATE_TEXT DEFAULT)
- set(_IFW_MULTI_ARGS DISPLAY_NAME DESCRIPTION DEPENDS DEPENDENCIES AUTO_DEPEND_ON LICENSES USER_INTERFACES TRANSLATIONS)
+ set(_IFW_ARGS NAME VERSION RELEASE_DATE SCRIPT PRIORITY SORTING_PRIORITY UPDATE_TEXT DEFAULT CHECKABLE)
+ set(_IFW_MULTI_ARGS DISPLAY_NAME DESCRIPTION DEPENDS DEPENDENCIES AUTO_DEPEND_ON LICENSES USER_INTERFACES TRANSLATIONS REPLACES)
cmake_parse_arguments(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
_cpack_ifw_resolve_script(CPACK_IFW_COMPONENT_${_CPACK_IFWCOMP_UNAME}_SCRIPT)
@@ -904,8 +605,8 @@ macro(cpack_ifw_configure_component_group grpname)
string(TOUPPER ${grpname} _CPACK_IFWGRP_UNAME)
set(_IFW_OPT VIRTUAL FORCED_INSTALLATION REQUIRES_ADMIN_RIGHTS)
- set(_IFW_ARGS NAME VERSION RELEASE_DATE SCRIPT PRIORITY SORTING_PRIORITY UPDATE_TEXT DEFAULT)
- set(_IFW_MULTI_ARGS DISPLAY_NAME DESCRIPTION DEPENDS DEPENDENCIES AUTO_DEPEND_ON LICENSES USER_INTERFACES TRANSLATIONS)
+ set(_IFW_ARGS NAME VERSION RELEASE_DATE SCRIPT PRIORITY SORTING_PRIORITY UPDATE_TEXT DEFAULT CHECKABLE)
+ set(_IFW_MULTI_ARGS DISPLAY_NAME DESCRIPTION DEPENDS DEPENDENCIES AUTO_DEPEND_ON LICENSES USER_INTERFACES TRANSLATIONS REPLACES)
cmake_parse_arguments(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME} "${_IFW_OPT}" "${_IFW_ARGS}" "${_IFW_MULTI_ARGS}" ${ARGN})
_cpack_ifw_resolve_script(CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_SCRIPT)
@@ -915,6 +616,12 @@ macro(cpack_ifw_configure_component_group grpname)
set(_CPACK_IFWGRP_STR "\n# Configuration for IFW component group \"${grpname}\"\n")
+ foreach(_IFW_ARG_NAME ${_IFW_OPT})
+ cpack_append_option_set_command(
+ CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_${_IFW_ARG_NAME}
+ _CPACK_IFWGRP_STR)
+ endforeach()
+
foreach(_IFW_ARG_NAME ${_IFW_ARGS})
cpack_append_string_variable_set_command(
CPACK_IFW_COMPONENT_GROUP_${_CPACK_IFWGRP_UNAME}_${_IFW_ARG_NAME}
diff --git a/Modules/CPackIFWConfigureFile.cmake b/Modules/CPackIFWConfigureFile.cmake
index 790574a52..0abe0da37 100644
--- a/Modules/CPackIFWConfigureFile.cmake
+++ b/Modules/CPackIFWConfigureFile.cmake
@@ -1,32 +1,33 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CPackIFWConfigureFile
-# ---------------------
-#
-# The module defines :command:`configure_file` similar command to
-# configure file templates prepared in QtIFW/SDK/Creator style.
-#
-#
-# Commands
-# ^^^^^^^^
-#
-# The module defines the following commands:
-#
-# .. command:: cpack_ifw_configure_file
-#
-# Copy a file to another location and modify its contents.
-#
-# ::
-#
-# cpack_ifw_configure_file(<input> <output>)
-#
-# Copies an ``<input>`` file to an ``<output>`` file and substitutes variable
-# values referenced as ``%{VAR}`` or ``%VAR%`` in the input file content.
-# Each variable reference will be replaced with the current value of the
-# variable, or the empty string if the variable is not defined.
-#
+#[=======================================================================[.rst:
+CPackIFWConfigureFile
+---------------------
+
+The module defines :command:`configure_file` similar command to
+configure file templates prepared in QtIFW/SDK/Creator style.
+
+
+Commands
+^^^^^^^^
+
+The module defines the following commands:
+
+.. command:: cpack_ifw_configure_file
+
+ Copy a file to another location and modify its contents.
+
+ ::
+
+ cpack_ifw_configure_file(<input> <output>)
+
+ Copies an ``<input>`` file to an ``<output>`` file and substitutes variable
+ values referenced as ``%{VAR}`` or ``%VAR%`` in the input file content.
+ Each variable reference will be replaced with the current value of the
+ variable, or the empty string if the variable is not defined.
+
+#]=======================================================================]
# NOTE: This file used to himself packaging via CPack IFW generator and
# should be compatible with minimal CMake version defined in
diff --git a/Modules/CPackNSIS.cmake b/Modules/CPackNSIS.cmake
deleted file mode 100644
index 18d187157..000000000
--- a/Modules/CPackNSIS.cmake
+++ /dev/null
@@ -1,138 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-#.rst:
-# CPackNSIS
-# ---------
-#
-# CPack NSIS generator specific options
-#
-# Variables specific to CPack NSIS generator
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# The following variables are specific to the graphical installers built
-# on Windows using the Nullsoft Installation System.
-#
-# .. variable:: CPACK_NSIS_INSTALL_ROOT
-#
-# The default installation directory presented to the end user by the NSIS
-# installer is under this root dir. The full directory presented to the end
-# user is: ${CPACK_NSIS_INSTALL_ROOT}/${CPACK_PACKAGE_INSTALL_DIRECTORY}
-#
-# .. variable:: CPACK_NSIS_MUI_ICON
-#
-# An icon filename. The name of a ``*.ico`` file used as the main icon for the
-# generated install program.
-#
-# .. variable:: CPACK_NSIS_MUI_UNIICON
-#
-# An icon filename. The name of a ``*.ico`` file used as the main icon for the
-# generated uninstall program.
-#
-# .. variable:: CPACK_NSIS_INSTALLER_MUI_ICON_CODE
-#
-# undocumented.
-#
-# .. variable:: CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP
-#
-# The filename of a bitmap to use as the NSIS MUI_WELCOMEFINISHPAGE_BITMAP.
-#
-# .. variable:: CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP
-#
-# The filename of a bitmap to use as the NSIS MUI_UNWELCOMEFINISHPAGE_BITMAP.
-#
-# .. variable:: CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS
-#
-# Extra NSIS commands that will be added to the beginning of the install
-# Section, before your install tree is available on the target system.
-#
-# .. variable:: CPACK_NSIS_EXTRA_INSTALL_COMMANDS
-#
-# Extra NSIS commands that will be added to the end of the install Section,
-# after your install tree is available on the target system.
-#
-# .. variable:: CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
-#
-# Extra NSIS commands that will be added to the uninstall Section, before
-# your install tree is removed from the target system.
-#
-# .. variable:: CPACK_NSIS_COMPRESSOR
-#
-# The arguments that will be passed to the NSIS SetCompressor command.
-#
-# .. variable:: CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL
-#
-# Ask about uninstalling previous versions first. If this is set to "ON",
-# then an installer will look for previous installed versions and if one is
-# found, ask the user whether to uninstall it before proceeding with the
-# install.
-#
-# .. variable:: CPACK_NSIS_MODIFY_PATH
-#
-# Modify PATH toggle. If this is set to "ON", then an extra page will appear
-# in the installer that will allow the user to choose whether the program
-# directory should be added to the system PATH variable.
-#
-# .. variable:: CPACK_NSIS_DISPLAY_NAME
-#
-# The display name string that appears in the Windows Add/Remove Program
-# control panel
-#
-# .. variable:: CPACK_NSIS_PACKAGE_NAME
-#
-# The title displayed at the top of the installer.
-#
-# .. variable:: CPACK_NSIS_INSTALLED_ICON_NAME
-#
-# A path to the executable that contains the installer icon.
-#
-# .. variable:: CPACK_NSIS_HELP_LINK
-#
-# URL to a web site providing assistance in installing your application.
-#
-# .. variable:: CPACK_NSIS_URL_INFO_ABOUT
-#
-# URL to a web site providing more information about your application.
-#
-# .. variable:: CPACK_NSIS_CONTACT
-#
-# Contact information for questions and comments about the installation
-# process.
-#
-# .. variable:: CPACK_NSIS_<compName>_INSTALL_DIRECTORY
-#
-# Custom install directory for the specified component <compName> instead
-# of $INSTDIR.
-#
-# .. variable:: CPACK_NSIS_CREATE_ICONS_EXTRA
-#
-# Additional NSIS commands for creating start menu shortcuts.
-#
-# .. variable:: CPACK_NSIS_DELETE_ICONS_EXTRA
-#
-# Additional NSIS commands to uninstall start menu shortcuts.
-#
-# .. variable:: CPACK_NSIS_EXECUTABLES_DIRECTORY
-#
-# Creating NSIS start menu links assumes that they are in 'bin' unless this
-# variable is set. For example, you would set this to 'exec' if your
-# executables are in an exec directory.
-#
-# .. variable:: CPACK_NSIS_MUI_FINISHPAGE_RUN
-#
-# Specify an executable to add an option to run on the finish page of the
-# NSIS installer.
-#
-# .. variable:: CPACK_NSIS_MENU_LINKS
-#
-# Specify links in [application] menu. This should contain a list of pair
-# "link" "link name". The link may be an URL or a path relative to
-# installation prefix. Like::
-#
-# set(CPACK_NSIS_MENU_LINKS
-# "doc/cmake-@CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@/cmake.html"
-# "CMake Help" "https://cmake.org" "CMake Web Site")
-#
-
-#FIXME we should put NSIS specific code here
-#FIXME but I'm not doing it because I'm not able to test it...
diff --git a/Modules/CPackPackageMaker.cmake b/Modules/CPackPackageMaker.cmake
deleted file mode 100644
index c2ca4c63c..000000000
--- a/Modules/CPackPackageMaker.cmake
+++ /dev/null
@@ -1,27 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-#.rst:
-# CPackPackageMaker
-# -----------------
-#
-# PackageMaker CPack generator (Mac OS X).
-#
-# Variables specific to CPack PackageMaker generator
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# The following variable is specific to installers built on Mac
-# OS X using PackageMaker:
-#
-# .. variable:: CPACK_OSX_PACKAGE_VERSION
-#
-# The version of Mac OS X that the resulting PackageMaker archive should be
-# compatible with. Different versions of Mac OS X support different
-# features. For example, CPack can only build component-based installers for
-# Mac OS X 10.4 or newer, and can only build installers that download
-# component son-the-fly for Mac OS X 10.5 or newer. If left blank, this value
-# will be set to the minimum version of Mac OS X that supports the requested
-# features. Set this variable to some value (e.g., 10.4) only if you want to
-# guarantee that your installer will work on that version of Mac OS X, and
-# don't mind missing extra features available in the installer shipping with
-# later versions of Mac OS X.
diff --git a/Modules/CPackProductBuild.cmake b/Modules/CPackProductBuild.cmake
deleted file mode 100644
index 4779b95b9..000000000
--- a/Modules/CPackProductBuild.cmake
+++ /dev/null
@@ -1,56 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-#.rst:
-# CPackProductBuild
-# -----------------
-#
-# productbuild CPack generator (Mac OS X).
-#
-# Variables specific to CPack productbuild generator
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# The following variable is specific to installers built on Mac
-# OS X using productbuild:
-#
-# .. variable:: CPACK_COMMAND_PRODUCTBUILD
-#
-# Path to the productbuild(1) command used to generate a product archive for
-# the OS X Installer or Mac App Store. This variable can be used to override
-# the automatically detected command (or specify its location if the
-# auto-detection fails to find it.)
-#
-# .. variable:: CPACK_PRODUCTBUILD_IDENTITY_NAME
-#
-# Adds a digital signature to the resulting package.
-#
-#
-# .. variable:: CPACK_PRODUCTBUILD_KEYCHAIN_PATH
-#
-# Specify a specific keychain to search for the signing identity.
-#
-#
-# .. variable:: CPACK_COMMAND_PKGBUILD
-#
-# Path to the pkgbuild(1) command used to generate an OS X component package
-# on OS X. This variable can be used to override the automatically detected
-# command (or specify its location if the auto-detection fails to find it.)
-#
-#
-# .. variable:: CPACK_PKGBUILD_IDENTITY_NAME
-#
-# Adds a digital signature to the resulting package.
-#
-#
-# .. variable:: CPACK_PKGBUILD_KEYCHAIN_PATH
-#
-# Specify a specific keychain to search for the signing identity.
-#
-#
-# .. variable:: CPACK_PRODUCTBUILD_RESOURCES_DIR
-#
-# If specified the productbuild generator copies files from this directory
-# (including subdirectories) to the ``Resources`` directory. This is done
-# before the :variable:`CPACK_RESOURCE_FILE_WELCOME`,
-# :variable:`CPACK_RESOURCE_FILE_README`, and
-# :variable:`CPACK_RESOURCE_FILE_LICENSE` files are copied.
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
deleted file mode 100644
index fa2a6e409..000000000
--- a/Modules/CPackRPM.cmake
+++ /dev/null
@@ -1,2745 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-#.rst:
-# CPackRPM
-# --------
-#
-# The built in (binary) CPack RPM generator (Unix only)
-#
-# Variables specific to CPack RPM generator
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# CPackRPM may be used to create RPM packages using :module:`CPack`.
-# CPackRPM is a :module:`CPack` generator thus it uses the ``CPACK_XXX``
-# variables used by :module:`CPack`.
-#
-# CPackRPM has specific features which are controlled by the specifics
-# :code:`CPACK_RPM_XXX` variables.
-#
-# :code:`CPACK_RPM_<COMPONENT>_XXXX` variables may be used in order to have
-# **component** specific values. Note however that ``<COMPONENT>`` refers to the
-# **grouping name** written in upper case. It may be either a component name or
-# a component GROUP name. Usually those variables correspond to RPM spec file
-# entities. One may find information about spec files here
-# http://www.rpm.org/wiki/Docs
-#
-# .. note::
-#
-# `<COMPONENT>` part of variables is preferred to be in upper case (for e.g. if
-# component is named `foo` then use `CPACK_RPM_FOO_XXXX` variable name format)
-# as is with other `CPACK_<COMPONENT>_XXXX` variables.
-# For the purposes of back compatibility (CMake/CPack version 3.5 and lower)
-# support for same cased component (e.g. `fOo` would be used as
-# `CPACK_RPM_fOo_XXXX`) is still supported for variables defined in older
-# versions of CMake/CPack but is not guaranteed for variables that
-# will be added in the future. For the sake of back compatibility same cased
-# component variables also override upper cased versions where both are
-# present.
-#
-# Here are some CPackRPM wiki resources that are here for historic reasons and
-# are no longer maintained but may still prove useful:
-#
-# - https://cmake.org/Wiki/CMake:CPackConfiguration
-# - https://cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29
-#
-# List of CPackRPM specific variables:
-#
-# .. variable:: CPACK_RPM_COMPONENT_INSTALL
-#
-# Enable component packaging for CPackRPM
-#
-# * Mandatory : NO
-# * Default : OFF
-#
-# If enabled (ON) multiple packages are generated. By default a single package
-# containing files of all components is generated.
-#
-# .. variable:: CPACK_RPM_PACKAGE_SUMMARY
-# CPACK_RPM_<component>_PACKAGE_SUMMARY
-#
-# The RPM package summary.
-#
-# * Mandatory : YES
-# * Default : :variable:`CPACK_PACKAGE_DESCRIPTION_SUMMARY`
-#
-# .. variable:: CPACK_RPM_PACKAGE_NAME
-# CPACK_RPM_<component>_PACKAGE_NAME
-#
-# The RPM package name.
-#
-# * Mandatory : YES
-# * Default : :variable:`CPACK_PACKAGE_NAME`
-#
-# .. variable:: CPACK_RPM_FILE_NAME
-# CPACK_RPM_<component>_FILE_NAME
-#
-# Package file name.
-#
-# * Mandatory : YES
-# * Default : ``<CPACK_PACKAGE_FILE_NAME>[-<component>].rpm`` with spaces
-# replaced by '-'
-#
-# This may be set to ``RPM-DEFAULT`` to allow rpmbuild tool to generate package
-# file name by itself.
-# Alternatively provided package file name must end with ``.rpm`` suffix.
-#
-# .. note::
-#
-# By using user provided spec file, rpm macro extensions such as for
-# generating debuginfo packages or by simply using multiple components more
-# than one rpm file may be generated, either from a single spec file or from
-# multiple spec files (each component execution produces it's own spec file).
-# In such cases duplicate file names may occur as a result of this variable
-# setting or spec file content structure. Duplicate files get overwritten
-# and it is up to the packager to set the variables in a manner that will
-# prevent such errors.
-#
-# .. variable:: CPACK_RPM_MAIN_COMPONENT
-#
-# Main component that is packaged without component suffix.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# This variable can be set to any component or group name so that component or
-# group rpm package is generated without component suffix in filename and
-# package name.
-#
-# .. variable:: CPACK_RPM_PACKAGE_VERSION
-#
-# The RPM package version.
-#
-# * Mandatory : YES
-# * Default : :variable:`CPACK_PACKAGE_VERSION`
-#
-# .. variable:: CPACK_RPM_PACKAGE_ARCHITECTURE
-# CPACK_RPM_<component>_PACKAGE_ARCHITECTURE
-#
-# The RPM package architecture.
-#
-# * Mandatory : YES
-# * Default : Native architecture output by ``uname -m``
-#
-# This may be set to ``noarch`` if you know you are building a noarch package.
-#
-# .. variable:: CPACK_RPM_PACKAGE_RELEASE
-#
-# The RPM package release.
-#
-# * Mandatory : YES
-# * Default : 1
-#
-# This is the numbering of the RPM package itself, i.e. the version of the
-# packaging and not the version of the content (see
-# :variable:`CPACK_RPM_PACKAGE_VERSION`). One may change the default value if
-# the previous packaging was buggy and/or you want to put here a fancy Linux
-# distro specific numbering.
-#
-# .. note::
-#
-# This is the string that goes into the RPM ``Release:`` field. Some distros
-# (e.g. Fedora, CentOS) require ``1%{?dist}`` format and not just a number.
-# ``%{?dist}`` part can be added by setting :variable:`CPACK_RPM_PACKAGE_RELEASE_DIST`.
-#
-# .. variable:: CPACK_RPM_PACKAGE_RELEASE_DIST
-#
-# The dist tag that is added RPM ``Release:`` field.
-#
-# * Mandatory : NO
-# * Default : OFF
-#
-# This is the reported ``%{dist}`` tag from the current distribution or empty
-# ``%{dist}`` if RPM macro is not set. If this variable is set then RPM
-# ``Release:`` field value is set to ``${CPACK_RPM_PACKAGE_RELEASE}%{?dist}``.
-#
-# .. variable:: CPACK_RPM_PACKAGE_LICENSE
-#
-# The RPM package license policy.
-#
-# * Mandatory : YES
-# * Default : "unknown"
-#
-# .. variable:: CPACK_RPM_PACKAGE_GROUP
-# CPACK_RPM_<component>_PACKAGE_GROUP
-#
-# The RPM package group.
-#
-# * Mandatory : YES
-# * Default : "unknown"
-#
-# .. variable:: CPACK_RPM_PACKAGE_VENDOR
-#
-# The RPM package vendor.
-#
-# * Mandatory : YES
-# * Default : CPACK_PACKAGE_VENDOR if set or "unknown"
-#
-# .. variable:: CPACK_RPM_PACKAGE_URL
-# CPACK_RPM_<component>_PACKAGE_URL
-#
-# The projects URL.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# .. variable:: CPACK_RPM_PACKAGE_DESCRIPTION
-# CPACK_RPM_<component>_PACKAGE_DESCRIPTION
-#
-# RPM package description.
-#
-# * Mandatory : YES
-# * Default : :variable:`CPACK_COMPONENT_<compName>_DESCRIPTION` (component
-# based installers only) if set, :variable:`CPACK_PACKAGE_DESCRIPTION_FILE`
-# if set or "no package description available"
-#
-# .. variable:: CPACK_RPM_COMPRESSION_TYPE
-#
-# RPM compression type.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to override RPM compression type to be used to build the
-# RPM. For example some Linux distribution now default to lzma or xz
-# compression whereas older cannot use such RPM. Using this one can enforce
-# compression type to be used.
-#
-# Possible values are:
-#
-# - lzma
-# - xz
-# - bzip2
-# - gzip
-#
-# .. variable:: CPACK_RPM_PACKAGE_AUTOREQ
-# CPACK_RPM_<component>_PACKAGE_AUTOREQ
-#
-# RPM spec autoreq field.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to enable (1, yes) or disable (0, no) automatic shared libraries
-# dependency detection. Dependencies are added to requires list.
-#
-# .. note::
-#
-# By default automatic dependency detection is enabled by rpm generator.
-#
-# .. variable:: CPACK_RPM_PACKAGE_AUTOPROV
-# CPACK_RPM_<component>_PACKAGE_AUTOPROV
-#
-# RPM spec autoprov field.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to enable (1, yes) or disable (0, no) automatic listing of shared
-# libraries that are provided by the package. Shared libraries are added to
-# provides list.
-#
-# .. note::
-#
-# By default automatic provides detection is enabled by rpm generator.
-#
-# .. variable:: CPACK_RPM_PACKAGE_AUTOREQPROV
-# CPACK_RPM_<component>_PACKAGE_AUTOREQPROV
-#
-# RPM spec autoreqprov field.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# Variable enables/disables autoreq and autoprov at the same time.
-# See :variable:`CPACK_RPM_PACKAGE_AUTOREQ` and :variable:`CPACK_RPM_PACKAGE_AUTOPROV`
-# for more details.
-#
-# .. note::
-#
-# By default automatic detection feature is enabled by rpm.
-#
-# .. variable:: CPACK_RPM_PACKAGE_REQUIRES
-# CPACK_RPM_<component>_PACKAGE_REQUIRES
-#
-# RPM spec requires field.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to set RPM dependencies (requires). Note that you must enclose
-# the complete requires string between quotes, for example::
-#
-# set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8")
-#
-# The required package list of an RPM file could be printed with::
-#
-# rpm -qp --requires file.rpm
-#
-# .. variable:: CPACK_RPM_PACKAGE_CONFLICTS
-# CPACK_RPM_<component>_PACKAGE_CONFLICTS
-#
-# RPM spec conflicts field.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to set negative RPM dependencies (conflicts). Note that you must
-# enclose the complete requires string between quotes, for example::
-#
-# set(CPACK_RPM_PACKAGE_CONFLICTS "libxml2")
-#
-# The conflicting package list of an RPM file could be printed with::
-#
-# rpm -qp --conflicts file.rpm
-#
-# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PRE
-# CPACK_RPM_<component>_PACKAGE_REQUIRES_PRE
-#
-# RPM spec requires(pre) field.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to set RPM preinstall dependencies (requires(pre)). Note that
-# you must enclose the complete requires string between quotes, for example::
-#
-# set(CPACK_RPM_PACKAGE_REQUIRES_PRE "shadow-utils, initscripts")
-#
-# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POST
-# CPACK_RPM_<component>_PACKAGE_REQUIRES_POST
-#
-# RPM spec requires(post) field.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to set RPM postinstall dependencies (requires(post)). Note that
-# you must enclose the complete requires string between quotes, for example::
-#
-# set(CPACK_RPM_PACKAGE_REQUIRES_POST "shadow-utils, initscripts")
-#
-# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_POSTUN
-# CPACK_RPM_<component>_PACKAGE_REQUIRES_POSTUN
-#
-# RPM spec requires(postun) field.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to set RPM postuninstall dependencies (requires(postun)). Note
-# that you must enclose the complete requires string between quotes, for
-# example::
-#
-# set(CPACK_RPM_PACKAGE_REQUIRES_POSTUN "shadow-utils, initscripts")
-#
-# .. variable:: CPACK_RPM_PACKAGE_REQUIRES_PREUN
-# CPACK_RPM_<component>_PACKAGE_REQUIRES_PREUN
-#
-# RPM spec requires(preun) field.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to set RPM preuninstall dependencies (requires(preun)). Note that
-# you must enclose the complete requires string between quotes, for example::
-#
-# set(CPACK_RPM_PACKAGE_REQUIRES_PREUN "shadow-utils, initscripts")
-#
-# .. variable:: CPACK_RPM_PACKAGE_SUGGESTS
-# CPACK_RPM_<component>_PACKAGE_SUGGESTS
-#
-# RPM spec suggest field.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to set weak RPM dependencies (suggests). Note that you must
-# enclose the complete requires string between quotes.
-#
-# .. variable:: CPACK_RPM_PACKAGE_PROVIDES
-# CPACK_RPM_<component>_PACKAGE_PROVIDES
-#
-# RPM spec provides field.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to set RPM dependencies (provides). The provided package list
-# of an RPM file could be printed with::
-#
-# rpm -qp --provides file.rpm
-#
-# .. variable:: CPACK_RPM_PACKAGE_OBSOLETES
-# CPACK_RPM_<component>_PACKAGE_OBSOLETES
-#
-# RPM spec obsoletes field.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to set RPM packages that are obsoleted by this one.
-#
-# .. variable:: CPACK_RPM_PACKAGE_RELOCATABLE
-#
-# build a relocatable RPM.
-#
-# * Mandatory : NO
-# * Default : CPACK_PACKAGE_RELOCATABLE
-#
-# If this variable is set to TRUE or ON CPackRPM will try
-# to build a relocatable RPM package. A relocatable RPM may
-# be installed using::
-#
-# rpm --prefix or --relocate
-#
-# in order to install it at an alternate place see rpm(8). Note that
-# currently this may fail if :variable:`CPACK_SET_DESTDIR` is set to ``ON``. If
-# :variable:`CPACK_SET_DESTDIR` is set then you will get a warning message but
-# if there is file installed with absolute path you'll get unexpected behavior.
-#
-# .. variable:: CPACK_RPM_SPEC_INSTALL_POST
-#
-# Deprecated - use :variable:`CPACK_RPM_POST_INSTALL_SCRIPT_FILE` instead.
-#
-# * Mandatory : NO
-# * Default : -
-# * Deprecated: YES
-#
-# This way of specifying post-install script is deprecated, use
-# :variable:`CPACK_RPM_POST_INSTALL_SCRIPT_FILE`.
-# May be used to set an RPM post-install command inside the spec file.
-# For example setting it to ``/bin/true`` may be used to prevent
-# rpmbuild to strip binaries.
-#
-# .. variable:: CPACK_RPM_SPEC_MORE_DEFINE
-#
-# RPM extended spec definitions lines.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to add any ``%define`` lines to the generated spec file.
-#
-# .. variable:: CPACK_RPM_PACKAGE_DEBUG
-#
-# Toggle CPackRPM debug output.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be set when invoking cpack in order to trace debug information
-# during CPack RPM run. For example you may launch CPack like this::
-#
-# cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM
-#
-# .. variable:: CPACK_RPM_USER_BINARY_SPECFILE
-# CPACK_RPM_<componentName>_USER_BINARY_SPECFILE
-#
-# A user provided spec file.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be set by the user in order to specify a USER binary spec file
-# to be used by CPackRPM instead of generating the file.
-# The specified file will be processed by configure_file( @ONLY).
-#
-# .. variable:: CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE
-#
-# Spec file template.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# If set CPack will generate a template for USER specified binary
-# spec file and stop with an error. For example launch CPack like this::
-#
-# cpack -D CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE=1 -G RPM
-#
-# The user may then use this file in order to hand-craft is own
-# binary spec file which may be used with
-# :variable:`CPACK_RPM_USER_BINARY_SPECFILE`.
-#
-# .. variable:: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
-# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
-#
-# Path to file containing pre (un)install script.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to embed a pre (un)installation script in the spec file.
-# The referred script file (or both) will be read and directly
-# put after the ``%pre`` or ``%preun`` section
-# If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the (un)install
-# script for each component can be overridden with
-# ``CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE`` and
-# ``CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE``.
-# One may verify which scriptlet has been included with::
-#
-# rpm -qp --scripts package.rpm
-#
-# .. variable:: CPACK_RPM_POST_INSTALL_SCRIPT_FILE
-# CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
-#
-# Path to file containing post (un)install script.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to embed a post (un)installation script in the spec file.
-# The referred script file (or both) will be read and directly
-# put after the ``%post`` or ``%postun`` section.
-# If :variable:`CPACK_RPM_COMPONENT_INSTALL` is set to ON the (un)install
-# script for each component can be overridden with
-# ``CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE`` and
-# ``CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE``.
-# One may verify which scriptlet has been included with::
-#
-# rpm -qp --scripts package.rpm
-#
-# .. variable:: CPACK_RPM_USER_FILELIST
-# CPACK_RPM_<COMPONENT>_USER_FILELIST
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to explicitly specify ``%(<directive>)`` file line
-# in the spec file. Like ``%config(noreplace)`` or any other directive
-# that be found in the ``%files`` section. You can have multiple directives
-# per line, as in ``%attr(600,root,root) %config(noreplace)``. Since
-# CPackRPM is generating the list of files (and directories) the user
-# specified files of the ``CPACK_RPM_<COMPONENT>_USER_FILELIST`` list will
-# be removed from the generated list. If referring to directories do
-# not add a trailing slash.
-#
-# .. variable:: CPACK_RPM_CHANGELOG_FILE
-#
-# RPM changelog file.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to embed a changelog in the spec file.
-# The referred file will be read and directly put after the ``%changelog``
-# section.
-#
-# .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST
-#
-# list of path to be excluded.
-#
-# * Mandatory : NO
-# * Default : /etc /etc/init.d /usr /usr/share /usr/share/doc /usr/bin /usr/lib /usr/lib64 /usr/include
-#
-# May be used to exclude path (directories or files) from the auto-generated
-# list of paths discovered by CPack RPM. The defaut value contains a
-# reasonable set of values if the variable is not defined by the user. If the
-# variable is defined by the user then CPackRPM will NOT any of the default
-# path. If you want to add some path to the default list then you can use
-# :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION` variable.
-#
-# .. variable:: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
-#
-# additional list of path to be excluded.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to add more exclude path (directories or files) from the initial
-# default list of excluded paths. See
-# :variable:`CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST`.
-#
-# .. variable:: CPACK_RPM_RELOCATION_PATHS
-#
-# Packages relocation paths list.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to specify more than one relocation path per relocatable RPM.
-# Variable contains a list of relocation paths that if relative are prefixed
-# by the value of :variable:`CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX` or by the
-# value of :variable:`CPACK_PACKAGING_INSTALL_PREFIX` if the component version
-# is not provided.
-# Variable is not component based as its content can be used to set a different
-# path prefix for e.g. binary dir and documentation dir at the same time.
-# Only prefixes that are required by a certain component are added to that
-# component - component must contain at least one file/directory/symbolic link
-# with :variable:`CPACK_RPM_RELOCATION_PATHS` prefix for a certain relocation
-# path to be added. Package will not contain any relocation paths if there are
-# no files/directories/symbolic links on any of the provided prefix locations.
-# Packages that either do not contain any relocation paths or contain
-# files/directories/symbolic links that are outside relocation paths print
-# out an ``AUTHOR_WARNING`` that RPM will be partially relocatable.
-#
-# .. variable:: CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
-#
-# Per component relocation path install prefix.
-#
-# * Mandatory : NO
-# * Default : CPACK_PACKAGING_INSTALL_PREFIX
-#
-# May be used to set per component :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
-# for relocatable RPM packages.
-#
-# .. variable:: CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION
-# CPACK_RPM_NO_<COMPONENT>_INSTALL_PREFIX_RELOCATION
-#
-# Removal of default install prefix from relocation paths list.
-#
-# * Mandatory : NO
-# * Default : CPACK_PACKAGING_INSTALL_PREFIX or CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
-# are treated as one of relocation paths
-#
-# May be used to remove CPACK_PACKAGING_INSTALL_PREFIX and CPACK_RPM_<COMPONENT>_PACKAGE_PREFIX
-# from relocatable RPM prefix paths.
-#
-# .. variable:: CPACK_RPM_ADDITIONAL_MAN_DIRS
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to set additional man dirs that could potentially be compressed
-# by brp-compress RPM macro. Variable content must be a list of regular
-# expressions that point to directories containing man files or to man files
-# directly. Note that in order to compress man pages a path must also be
-# present in brp-compress RPM script and that brp-compress script must be
-# added to RPM configuration by the operating system.
-#
-# Regular expressions that are added by default were taken from brp-compress
-# RPM macro:
-#
-# - /usr/man/man.*
-# - /usr/man/.*/man.*
-# - /usr/info.*
-# - /usr/share/man/man.*
-# - /usr/share/man/.*/man.*
-# - /usr/share/info.*
-# - /usr/kerberos/man.*
-# - /usr/X11R6/man/man.*
-# - /usr/lib/perl5/man/man.*
-# - /usr/share/doc/.*/man/man.*
-# - /usr/lib/.*/man/man.*
-#
-# .. variable:: CPACK_RPM_DEFAULT_USER
-# CPACK_RPM_<compName>_DEFAULT_USER
-#
-# default user ownership of RPM content
-#
-# * Mandatory : NO
-# * Default : root
-#
-# Value should be user name and not UID.
-# Note that <compName> must be in upper-case.
-#
-# .. variable:: CPACK_RPM_DEFAULT_GROUP
-# CPACK_RPM_<compName>_DEFAULT_GROUP
-#
-# default group ownership of RPM content
-#
-# * Mandatory : NO
-# * Default : root
-#
-# Value should be group name and not GID.
-# Note that <compName> must be in upper-case.
-#
-# .. variable:: CPACK_RPM_DEFAULT_FILE_PERMISSIONS
-# CPACK_RPM_<compName>_DEFAULT_FILE_PERMISSIONS
-#
-# default permissions used for packaged files
-#
-# * Mandatory : NO
-# * Default : - (system default)
-#
-# Accepted values are lists with ``PERMISSIONS``. Valid permissions
-# are:
-#
-# - OWNER_READ
-# - OWNER_WRITE
-# - OWNER_EXECUTE
-# - GROUP_READ
-# - GROUP_WRITE
-# - GROUP_EXECUTE
-# - WORLD_READ
-# - WORLD_WRITE
-# - WORLD_EXECUTE
-#
-# Note that <compName> must be in upper-case.
-#
-# .. variable:: CPACK_RPM_DEFAULT_DIR_PERMISSIONS
-# CPACK_RPM_<compName>_DEFAULT_DIR_PERMISSIONS
-#
-# default permissions used for packaged directories
-#
-# * Mandatory : NO
-# * Default : - (system default)
-#
-# Accepted values are lists with PERMISSIONS. Valid permissions
-# are the same as for :variable:`CPACK_RPM_DEFAULT_FILE_PERMISSIONS`.
-# Note that <compName> must be in upper-case.
-#
-# Packaging of Symbolic Links
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# CPackRPM supports packaging of symbolic links::
-#
-# execute_process(COMMAND ${CMAKE_COMMAND}
-# -E create_symlink <relative_path_location> <symlink_name>)
-# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/<symlink_name>
-# DESTINATION <symlink_location> COMPONENT libraries)
-#
-# Symbolic links will be optimized (paths will be shortened if possible)
-# before being added to the package or if multiple relocation paths are
-# detected, a post install symlink relocation script will be generated.
-#
-# Symbolic links may point to locations that are not packaged by the same
-# package (either a different component or even not packaged at all) but
-# those locations will be treated as if they were a part of the package
-# while determining if symlink should be either created or present in a
-# post install script - depending on relocation paths.
-#
-# Symbolic links that point to locations outside packaging path produce a
-# warning and are treated as non relocatable permanent symbolic links.
-#
-# Currently there are a few limitations though:
-#
-# * For component based packaging component interdependency is not checked
-# when processing symbolic links. Symbolic links pointing to content of
-# a different component are treated the same way as if pointing to location
-# that will not be packaged.
-#
-# * Symbolic links pointing to a location through one or more intermediate
-# symbolic links will not be handled differently - if the intermediate
-# symbolic link(s) is also on a relocatable path, relocating it during
-# package installation may cause initial symbolic link to point to an
-# invalid location.
-#
-# Packaging of debug information
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# Debuginfo packages contain debug symbols and sources for debugging packaged
-# binaries.
-#
-# Debuginfo RPM packaging has it's own set of variables:
-#
-# .. variable:: CPACK_RPM_DEBUGINFO_PACKAGE
-# CPACK_RPM_<component>_DEBUGINFO_PACKAGE
-#
-# Enable generation of debuginfo RPM package(s).
-#
-# * Mandatory : NO
-# * Default : OFF
-#
-# .. note::
-#
-# Binaries must contain debug symbols before packaging so use either ``Debug``
-# or ``RelWithDebInfo`` for :variable:`CMAKE_BUILD_TYPE` variable value.
-#
-# .. note::
-#
-# Packages generated from packages without binary files, with binary files but
-# without execute permissions or without debug symbols will be empty.
-#
-# .. variable:: CPACK_BUILD_SOURCE_DIRS
-#
-# Provides locations of root directories of source files from which binaries
-# were built.
-#
-# * Mandatory : YES if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
-# * Default : -
-#
-# .. note::
-#
-# For CMake project :variable:`CPACK_BUILD_SOURCE_DIRS` is set by default to
-# point to :variable:`CMAKE_SOURCE_DIR` and :variable:`CMAKE_BINARY_DIR` paths.
-#
-# .. note::
-#
-# Sources with path prefixes that do not fall under any location provided with
-# :variable:`CPACK_BUILD_SOURCE_DIRS` will not be present in debuginfo package.
-#
-# .. variable:: CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX
-# CPACK_RPM_<component>_BUILD_SOURCE_DIRS_PREFIX
-#
-# Prefix of location where sources will be placed during package installation.
-#
-# * Mandatory : YES if :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is set
-# * Default : "/usr/src/debug/<CPACK_PACKAGE_FILE_NAME>" and
-# for component packaging "/usr/src/debug/<CPACK_PACKAGE_FILE_NAME>-<component>"
-#
-# .. note::
-#
-# Each source path prefix is additionaly suffixed by ``src_<index>`` where
-# index is index of the path used from :variable:`CPACK_BUILD_SOURCE_DIRS`
-# variable. This produces ``<CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX>/src_<index>``
-# replacement path.
-# Limitation is that replaced path part must be shorter or of equal
-# length than the length of its replacement. If that is not the case either
-# :variable:`CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX` variable has to be set to
-# a shorter path or source directories must be placed on a longer path.
-#
-# .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS
-#
-# Directories containing sources that should be excluded from debuginfo packages.
-#
-# * Mandatory : NO
-# * Default : "/usr /usr/src /usr/src/debug"
-#
-# Listed paths are owned by other RPM packages and should therefore not be
-# deleted on debuginfo package uninstallation.
-#
-# .. variable:: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION
-#
-# Paths that should be appended to :variable:`CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS`
-# for exclusion.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# .. variable:: CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE
-#
-# Create a single debuginfo package even if components packaging is set.
-#
-# * Mandatory : NO
-# * Default : OFF
-#
-# When this variable is enabled it produces a single debuginfo package even if
-# component packaging is enabled.
-#
-# When using this feature in combination with components packaging and there is
-# more than one component this variable requires :variable:`CPACK_RPM_MAIN_COMPONENT`
-# to be set.
-#
-# .. note::
-#
-# If none of the :variable:`CPACK_RPM_<component>_DEBUGINFO_PACKAGE` variables
-# is set then :variable:`CPACK_RPM_DEBUGINFO_PACKAGE` is automatically set to
-# ``ON`` when :variable:`CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE` is set.
-#
-# .. variable:: CPACK_RPM_DEBUGINFO_FILE_NAME
-# CPACK_RPM_<component>_DEBUGINFO_FILE_NAME
-#
-# Debuginfo package file name.
-#
-# * Mandatory : NO
-# * Default : rpmbuild tool generated package file name
-#
-# Alternatively provided debuginfo package file name must end with ``.rpm``
-# suffix and should differ from file names of other generated packages.
-#
-# Variable may contain ``@cpack_component@`` placeholder which will be
-# replaced by component name if component packaging is enabled otherwise it
-# deletes the placeholder.
-#
-# Setting the variable to ``RPM-DEFAULT`` may be used to explicitly set
-# filename generation to default.
-#
-# .. note::
-#
-# :variable:`CPACK_RPM_FILE_NAME` also supports rpmbuild tool generated package
-# file name - disabled by default but can be enabled by setting the variable to
-# ``RPM-DEFAULT``.
-#
-# Packaging of sources (SRPM)
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# SRPM packaging is enabled by setting :variable:`CPACK_RPM_PACKAGE_SOURCES`
-# variable while usually using :variable:`CPACK_INSTALLED_DIRECTORIES` variable
-# to provide directory containing CMakeLists.txt and source files.
-#
-# For CMake projects SRPM package would be product by executing:
-#
-# ``cpack -G RPM --config ./CPackSourceConfig.cmake``
-#
-# .. note::
-#
-# Produced SRPM package is expected to be built with :manual:`cmake(1)` executable
-# and packaged with :manual:`cpack(1)` executable so CMakeLists.txt has to be
-# located in root source directory and must be able to generate binary rpm
-# packages by executing ``cpack -G`` command. The two executables as well as
-# rpmbuild must also be present when generating binary rpm packages from the
-# produced SRPM package.
-#
-# Once the SRPM package is generated it can be used to generate binary packages
-# by creating a directory structure for rpm generation and executing rpmbuild
-# tool:
-#
-# ``mkdir -p build_dir/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}``
-# ``rpmbuild --define "_topdir <path_to_build_dir>" --rebuild <SRPM_file_name>``
-#
-# Generated packages will be located in build_dir/RPMS directory or its sub
-# directories.
-#
-# .. note::
-#
-# SRPM package internally uses CPack/RPM generator to generate binary packages
-# so CMakeScripts.txt can decide during the SRPM to binary rpm generation step
-# what content the package(s) should have as well as how they should be packaged
-# (monolithic or components). CMake can decide this for e.g. by reading environment
-# variables set by the package manager before starting the process of generating
-# binary rpm packages. This way a single SRPM package can be used to produce
-# different binary rpm packages on different platforms depending on the platform's
-# packaging rules.
-#
-# Source RPM packaging has it's own set of variables:
-#
-# .. variable:: CPACK_RPM_PACKAGE_SOURCES
-#
-# Should the content be packaged as a source rpm (default is binary rpm).
-#
-# * Mandatory : NO
-# * Default : OFF
-#
-# .. note::
-#
-# For cmake projects :variable:`CPACK_RPM_PACKAGE_SOURCES` variable is set
-# to ``OFF`` in CPackConfig.cmake and ``ON`` in CPackSourceConfig.cmake
-# generated files.
-#
-# .. variable:: CPACK_RPM_SOURCE_PKG_BUILD_PARAMS
-#
-# Additional command-line parameters provided to :manual:`cmake(1)` executable.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# .. variable:: CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX
-#
-# Packaging install prefix that would be provided in :variable:`CPACK_PACKAGING_INSTALL_PREFIX`
-# variable for producing binary RPM packages.
-#
-# * Mandatory : YES
-# * Default : "/"
-#
-# .. VARIABLE:: CPACK_RPM_BUILDREQUIRES
-#
-# List of source rpm build dependencies.
-#
-# * Mandatory : NO
-# * Default : -
-#
-# May be used to set source RPM build dependencies (BuildRequires). Note that
-# you must enclose the complete build requirements string between quotes, for
-# example::
-#
-# set(CPACK_RPM_BUILDREQUIRES "python >= 2.5.0, cmake >= 2.8")
-
-# Author: Eric Noulard with the help of Alexander Neundorf.
-
-function(get_unix_permissions_octal_notation PERMISSIONS_VAR RETURN_VAR)
- set(PERMISSIONS ${${PERMISSIONS_VAR}})
- list(LENGTH PERMISSIONS PERM_LEN_PRE)
- list(REMOVE_DUPLICATES PERMISSIONS)
- list(LENGTH PERMISSIONS PERM_LEN_POST)
-
- if(NOT ${PERM_LEN_PRE} EQUAL ${PERM_LEN_POST})
- message(FATAL_ERROR "${PERMISSIONS_VAR} contains duplicate values.")
- endif()
-
- foreach(PERMISSION_TYPE "OWNER" "GROUP" "WORLD")
- set(${PERMISSION_TYPE}_PERMISSIONS 0)
-
- foreach(PERMISSION ${PERMISSIONS})
- if("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_READ")
- math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 4")
- elseif("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_WRITE")
- math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 2")
- elseif("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_EXECUTE")
- math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 1")
- elseif(PERMISSION MATCHES "${PERMISSION_TYPE}.*")
- message(FATAL_ERROR "${PERMISSIONS_VAR} contains invalid values.")
- endif()
- endforeach()
- endforeach()
-
- set(${RETURN_VAR} "${OWNER_PERMISSIONS}${GROUP_PERMISSIONS}${WORLD_PERMISSIONS}" PARENT_SCOPE)
-endfunction()
-
-function(cpack_rpm_prepare_relocation_paths)
- # set appropriate prefix, remove possible trailing slash and convert backslashes to slashes
- if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX)
- file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX}" PATH_PREFIX)
- elseif(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_PREFIX)
- file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_PREFIX}" PATH_PREFIX)
- else()
- file(TO_CMAKE_PATH "${CPACK_PACKAGING_INSTALL_PREFIX}" PATH_PREFIX)
- endif()
-
- set(RPM_RELOCATION_PATHS "${CPACK_RPM_RELOCATION_PATHS}")
- list(REMOVE_DUPLICATES RPM_RELOCATION_PATHS)
-
- # set base path prefix
- if(EXISTS "${WDIR}/${PATH_PREFIX}")
- if(NOT CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION AND
- NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT}_INSTALL_PREFIX_RELOCATION AND
- NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_INSTALL_PREFIX_RELOCATION)
- string(APPEND TMP_RPM_PREFIXES "Prefix: ${PATH_PREFIX}\n")
- list(APPEND RPM_USED_PACKAGE_PREFIXES "${PATH_PREFIX}")
-
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: removing '${PATH_PREFIX}' from relocation paths")
- endif()
- endif()
- endif()
-
- # set other path prefixes
- foreach(RELOCATION_PATH ${RPM_RELOCATION_PATHS})
- if(IS_ABSOLUTE "${RELOCATION_PATH}")
- set(PREPARED_RELOCATION_PATH "${RELOCATION_PATH}")
- elseif(PATH_PREFIX STREQUAL "/")
- # don't prefix path with a second slash as "//" is treated as network path
- # by get_filename_component() so it remains in path even inside rpm
- # package where it may cause problems with relocation
- set(PREPARED_RELOCATION_PATH "/${RELOCATION_PATH}")
- else()
- set(PREPARED_RELOCATION_PATH "${PATH_PREFIX}/${RELOCATION_PATH}")
- endif()
-
- # handle cases where path contains extra slashes (e.g. /a//b/ instead of
- # /a/b)
- get_filename_component(PREPARED_RELOCATION_PATH
- "${PREPARED_RELOCATION_PATH}" ABSOLUTE)
-
- if(EXISTS "${WDIR}/${PREPARED_RELOCATION_PATH}")
- string(APPEND TMP_RPM_PREFIXES "Prefix: ${PREPARED_RELOCATION_PATH}\n")
- list(APPEND RPM_USED_PACKAGE_PREFIXES "${PREPARED_RELOCATION_PATH}")
- endif()
- endforeach()
-
- # warn about all the paths that are not relocatable
- cmake_policy(PUSH)
- # Tell file(GLOB_RECURSE) not to follow directory symlinks
- # even if the project does not set this policy to NEW.
- cmake_policy(SET CMP0009 NEW)
- file(GLOB_RECURSE FILE_PATHS_ "${WDIR}/*")
- cmake_policy(POP)
- foreach(TMP_PATH ${FILE_PATHS_})
- string(LENGTH "${WDIR}" WDIR_LEN)
- string(SUBSTRING "${TMP_PATH}" ${WDIR_LEN} -1 TMP_PATH)
- unset(TMP_PATH_FOUND_)
-
- foreach(RELOCATION_PATH ${RPM_USED_PACKAGE_PREFIXES})
- file(RELATIVE_PATH REL_PATH_ "${RELOCATION_PATH}" "${TMP_PATH}")
- string(SUBSTRING "${REL_PATH_}" 0 2 PREFIX_)
-
- if(NOT "${PREFIX_}" STREQUAL "..")
- set(TPM_PATH_FOUND_ TRUE)
- break()
- endif()
- endforeach()
-
- if(NOT TPM_PATH_FOUND_)
- message(AUTHOR_WARNING "CPackRPM:Warning: Path ${TMP_PATH} is not on one of the relocatable paths! Package will be partially relocatable.")
- endif()
- endforeach()
-
- set(RPM_USED_PACKAGE_PREFIXES "${RPM_USED_PACKAGE_PREFIXES}" PARENT_SCOPE)
- set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}" PARENT_SCOPE)
-endfunction()
-
-function(cpack_rpm_prepare_content_list)
- # get files list
- cmake_policy(PUSH)
- cmake_policy(SET CMP0009 NEW)
- file(GLOB_RECURSE CPACK_RPM_INSTALL_FILES LIST_DIRECTORIES true RELATIVE "${WDIR}" "${WDIR}/*")
- cmake_policy(POP)
- set(CPACK_RPM_INSTALL_FILES "/${CPACK_RPM_INSTALL_FILES}")
- string(REPLACE ";" ";/" CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}")
-
- # if we are creating a relocatable package, omit parent directories of
- # CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list"
- # which is passed to the find command that generates the content-list
- if(CPACK_RPM_PACKAGE_RELOCATABLE)
- # get a list of the elements in CPACK_RPM_PACKAGE_PREFIXES that are
- # destinct parent paths of other relocation paths and remove the
- # final element (so the install-prefix dir itself is not omitted
- # from the RPM's content-list)
- list(SORT RPM_USED_PACKAGE_PREFIXES)
- set(_DISTINCT_PATH "NOT_SET")
- foreach(_RPM_RELOCATION_PREFIX ${RPM_USED_PACKAGE_PREFIXES})
- if(NOT "${_RPM_RELOCATION_PREFIX}" MATCHES "${_DISTINCT_PATH}/.*")
- set(_DISTINCT_PATH "${_RPM_RELOCATION_PREFIX}")
-
- string(REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS " ${_RPM_RELOCATION_PREFIX}")
- cmake_policy(PUSH)
- cmake_policy(SET CMP0007 NEW)
- list(REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1)
- cmake_policy(POP)
- unset(_TMP_LIST)
- # Now generate all of the parent dirs of the relocation path
- foreach(_PREFIX_PATH_ELEM ${_CPACK_RPM_PACKAGE_PREFIX_ELEMS})
- list(APPEND _TMP_LIST "${_PREFIX_PATH_ELEM}")
- string(REPLACE ";" "/" _OMIT_DIR "${_TMP_LIST}")
- separate_arguments(_OMIT_DIR)
- list(APPEND _RPM_DIRS_TO_OMIT ${_OMIT_DIR})
- endforeach()
- endif()
- endforeach()
- endif()
-
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: Initial list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}")
- endif()
-
- if(NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST)
- set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/share /usr/share/doc /usr/bin /usr/lib /usr/lib64 /usr/libx32 /usr/include)
- if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION)
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list.")
- endif()
- list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}")
- endif()
- endif()
-
- if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST)
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST= ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}")
- endif()
- list(APPEND _RPM_DIRS_TO_OMIT ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST})
- endif()
-
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: Final list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}")
- endif()
-
- list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES ${_RPM_DIRS_TO_OMIT})
-
- # add man paths that will be compressed
- # (copied from /usr/lib/rpm/brp-compress - script that does the actual
- # compressing)
- list(APPEND MAN_LOCATIONS "/usr/man/man.*" "/usr/man/.*/man.*" "/usr/info.*"
- "/usr/share/man/man.*" "/usr/share/man/.*/man.*" "/usr/share/info.*"
- "/usr/kerberos/man.*" "/usr/X11R6/man/man.*" "/usr/lib/perl5/man/man.*"
- "/usr/share/doc/.*/man/man.*" "/usr/lib/.*/man/man.*")
-
- if(CPACK_RPM_ADDITIONAL_MAN_DIRS)
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: CPACK_RPM_ADDITIONAL_MAN_DIRS= ${CPACK_RPM_ADDITIONAL_MAN_DIRS}")
- endif()
- list(APPEND MAN_LOCATIONS ${CPACK_RPM_ADDITIONAL_MAN_DIRS})
- endif()
-
- foreach(PACK_LOCATION IN LISTS CPACK_RPM_INSTALL_FILES)
- foreach(MAN_LOCATION IN LISTS MAN_LOCATIONS)
- # man pages are files inside a certain location
- if(PACK_LOCATION MATCHES "${MAN_LOCATION}/"
- AND NOT IS_DIRECTORY "${WDIR}${PACK_LOCATION}"
- AND NOT IS_SYMLINK "${WDIR}${PACK_LOCATION}")
- list(FIND CPACK_RPM_INSTALL_FILES "${PACK_LOCATION}" INDEX)
- # insert file location that covers compressed man pages
- # even if using a wildcard causes duplicates as those are
- # handled by RPM and we still keep the same file list
- # in spec file - wildcard only represents file type (e.g. .gz)
- list(INSERT CPACK_RPM_INSTALL_FILES ${INDEX} "${PACK_LOCATION}*")
- # remove file location that doesn't cover compressed man pages
- math(EXPR INDEX ${INDEX}+1)
- list(REMOVE_AT CPACK_RPM_INSTALL_FILES ${INDEX})
-
- break()
- endif()
- endforeach()
- endforeach()
-
- set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}" PARENT_SCOPE)
-endfunction()
-
-function(cpack_rpm_symlink_get_relocation_prefixes LOCATION PACKAGE_PREFIXES RETURN_VARIABLE)
- foreach(PKG_PREFIX IN LISTS PACKAGE_PREFIXES)
- string(REGEX MATCH "^${PKG_PREFIX}/.*" FOUND_ "${LOCATION}")
- if(FOUND_)
- list(APPEND TMP_PREFIXES "${PKG_PREFIX}")
- endif()
- endforeach()
-
- set(${RETURN_VARIABLE} "${TMP_PREFIXES}" PARENT_SCOPE)
-endfunction()
-
-function(cpack_rpm_symlink_create_relocation_script PACKAGE_PREFIXES)
- list(LENGTH PACKAGE_PREFIXES LAST_INDEX)
- set(SORTED_PACKAGE_PREFIXES "${PACKAGE_PREFIXES}")
- list(SORT SORTED_PACKAGE_PREFIXES)
- list(REVERSE SORTED_PACKAGE_PREFIXES)
- math(EXPR LAST_INDEX ${LAST_INDEX}-1)
-
- foreach(SYMLINK_INDEX RANGE ${LAST_INDEX})
- list(GET SORTED_PACKAGE_PREFIXES ${SYMLINK_INDEX} SRC_PATH)
- list(FIND PACKAGE_PREFIXES "${SRC_PATH}" SYMLINK_INDEX) # reverse magic
- string(LENGTH "${SRC_PATH}" SRC_PATH_LEN)
-
- set(PARTS_CNT 0)
- set(SCRIPT_PART "if [ \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}\" != \"${SRC_PATH}\" ]; then\n")
-
- # both paths relocated
- foreach(POINT_INDEX RANGE ${LAST_INDEX})
- list(GET SORTED_PACKAGE_PREFIXES ${POINT_INDEX} POINT_PATH)
- list(FIND PACKAGE_PREFIXES "${POINT_PATH}" POINT_INDEX) # reverse magic
- string(LENGTH "${POINT_PATH}" POINT_PATH_LEN)
-
- if(_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX})
- if("${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}")
- set(INDENT "")
- else()
- string(APPEND SCRIPT_PART " if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n")
- set(INDENT " ")
- endif()
-
- foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX})
- math(EXPR PARTS_CNT ${PARTS_CNT}+1)
-
- math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1)
- list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR)
- string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX)
-
- math(EXPR SRC_PATH_END ${SPLIT_INDEX}-${SRC_PATH_LEN})
- string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${SRC_PATH_LEN} ${SRC_PATH_END} SYMLINK_)
-
- math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1+${POINT_PATH_LEN})
- string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_)
-
- string(APPEND SCRIPT_PART " ${INDENT}if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n")
- string(APPEND SCRIPT_PART " ${INDENT}ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n")
- string(APPEND SCRIPT_PART " ${INDENT}CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n")
- string(APPEND SCRIPT_PART " ${INDENT}fi\n")
- endforeach()
-
- if(NOT "${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}")
- string(APPEND SCRIPT_PART " fi\n")
- endif()
- endif()
- endforeach()
-
- # source path relocated
- if(_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X)
- foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X)
- math(EXPR PARTS_CNT ${PARTS_CNT}+1)
-
- math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1)
- list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR)
- string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX)
-
- math(EXPR SRC_PATH_END ${SPLIT_INDEX}-${SRC_PATH_LEN})
- string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${SRC_PATH_LEN} ${SRC_PATH_END} SYMLINK_)
-
- math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1)
- string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_)
-
- string(APPEND SCRIPT_PART " if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n")
- string(APPEND SCRIPT_PART " ln -s \"${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n")
- string(APPEND SCRIPT_PART " CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n")
- string(APPEND SCRIPT_PART " fi\n")
- endforeach()
- endif()
-
- if(PARTS_CNT)
- set(SCRIPT "${SCRIPT_PART}")
- string(APPEND SCRIPT "fi\n")
- endif()
- endforeach()
-
- # point path relocated
- foreach(POINT_INDEX RANGE ${LAST_INDEX})
- list(GET SORTED_PACKAGE_PREFIXES ${POINT_INDEX} POINT_PATH)
- list(FIND PACKAGE_PREFIXES "${POINT_PATH}" POINT_INDEX) # reverse magic
- string(LENGTH "${POINT_PATH}" POINT_PATH_LEN)
-
- if(_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX})
- string(APPEND SCRIPT "if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n")
-
- foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX})
- math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1)
- list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR)
- string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX)
-
- string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} 0 ${SPLIT_INDEX} SYMLINK_)
-
- math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1+${POINT_PATH_LEN})
- string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_)
-
- string(APPEND SCRIPT " if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n")
- string(APPEND SCRIPT " ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"${SYMLINK_}\"\n")
- string(APPEND SCRIPT " CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n")
- string(APPEND SCRIPT " fi\n")
- endforeach()
-
- string(APPEND SCRIPT "fi\n")
- endif()
- endforeach()
-
- # no path relocated
- if(_RPM_RELOCATION_SCRIPT_X_X)
- foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_X_X)
- math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1)
- list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR)
- string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX)
-
- string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} 0 ${SPLIT_INDEX} SYMLINK_)
-
- math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1)
- string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_)
-
- string(APPEND SCRIPT "if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n")
- string(APPEND SCRIPT " ln -s \"${POINT_}\" \"${SYMLINK_}\"\n")
- string(APPEND SCRIPT "fi\n")
- endforeach()
- endif()
-
- set(RPM_SYMLINK_POSTINSTALL "${SCRIPT}" PARENT_SCOPE)
-endfunction()
-
-function(cpack_rpm_symlink_add_for_relocation_script PACKAGE_PREFIXES SYMLINK SYMLINK_RELOCATION_PATHS POINT POINT_RELOCATION_PATHS)
- list(LENGTH SYMLINK_RELOCATION_PATHS SYMLINK_PATHS_COUTN)
- list(LENGTH POINT_RELOCATION_PATHS POINT_PATHS_COUNT)
-
- list(APPEND _RPM_RELOCATION_SCRIPT_PAIRS "${SYMLINK}:${POINT}")
- list(LENGTH _RPM_RELOCATION_SCRIPT_PAIRS PAIR_NO)
-
- if(SYMLINK_PATHS_COUTN)
- foreach(SYMLINK_RELOC_PATH IN LISTS SYMLINK_RELOCATION_PATHS)
- list(FIND PACKAGE_PREFIXES "${SYMLINK_RELOC_PATH}" SYMLINK_INDEX)
-
- # source path relocated
- list(APPEND _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X "${PAIR_NO}")
- list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X")
-
- foreach(POINT_RELOC_PATH IN LISTS POINT_RELOCATION_PATHS)
- list(FIND PACKAGE_PREFIXES "${POINT_RELOC_PATH}" POINT_INDEX)
-
- # both paths relocated
- list(APPEND _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX} "${PAIR_NO}")
- list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX}")
-
- # point path relocated
- list(APPEND _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX} "${PAIR_NO}")
- list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}")
- endforeach()
- endforeach()
- elseif(POINT_PATHS_COUNT)
- foreach(POINT_RELOC_PATH IN LISTS POINT_RELOCATION_PATHS)
- list(FIND PACKAGE_PREFIXES "${POINT_RELOC_PATH}" POINT_INDEX)
-
- # point path relocated
- list(APPEND _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX} "${PAIR_NO}")
- list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}")
- endforeach()
- endif()
-
- # no path relocated
- list(APPEND _RPM_RELOCATION_SCRIPT_X_X "${PAIR_NO}")
- list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_X")
-
- # place variables into parent scope
- foreach(VAR IN LISTS RELOCATION_VARS)
- set(${VAR} "${${VAR}}" PARENT_SCOPE)
- endforeach()
- set(_RPM_RELOCATION_SCRIPT_PAIRS "${_RPM_RELOCATION_SCRIPT_PAIRS}" PARENT_SCOPE)
- set(REQUIRES_SYMLINK_RELOCATION_SCRIPT "true" PARENT_SCOPE)
- set(DIRECTIVE "%ghost " PARENT_SCOPE)
-endfunction()
-
-function(cpack_rpm_prepare_install_files INSTALL_FILES_LIST WDIR PACKAGE_PREFIXES IS_RELOCATABLE)
- # Prepend directories in ${CPACK_RPM_INSTALL_FILES} with %dir
- # This is necessary to avoid duplicate files since rpmbuild does
- # recursion on its own when encountering a pathname which is a directory
- # which is not flagged as %dir
- string(STRIP "${INSTALL_FILES_LIST}" INSTALL_FILES_LIST)
- string(REPLACE "\n" ";" INSTALL_FILES_LIST
- "${INSTALL_FILES_LIST}")
- string(REPLACE "\"" "" INSTALL_FILES_LIST
- "${INSTALL_FILES_LIST}")
- string(LENGTH "${WDIR}" WDR_LEN_)
-
- list(SORT INSTALL_FILES_LIST) # make file order consistent on all platforms
-
- foreach(F IN LISTS INSTALL_FILES_LIST)
- unset(DIRECTIVE)
-
- if(IS_SYMLINK "${WDIR}/${F}")
- if(IS_RELOCATABLE)
- # check that symlink has relocatable format
- get_filename_component(SYMLINK_LOCATION_ "${WDIR}/${F}" DIRECTORY)
- execute_process(COMMAND ls -la "${WDIR}/${F}"
- WORKING_DIRECTORY "${WDIR}"
- OUTPUT_VARIABLE SYMLINK_POINT_
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- string(FIND "${SYMLINK_POINT_}" "->" SYMLINK_POINT_INDEX_ REVERSE)
- math(EXPR SYMLINK_POINT_INDEX_ ${SYMLINK_POINT_INDEX_}+3)
- string(LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_)
-
- # get destination path
- string(SUBSTRING "${SYMLINK_POINT_}" ${SYMLINK_POINT_INDEX_} ${SYMLINK_POINT_LENGTH_} SYMLINK_POINT_)
-
- # check if path is relative or absolute
- string(SUBSTRING "${SYMLINK_POINT_}" 0 1 SYMLINK_IS_ABSOLUTE_)
-
- if(${SYMLINK_IS_ABSOLUTE_} STREQUAL "/")
- # prevent absolute paths from having /../ or /./ section inside of them
- get_filename_component(SYMLINK_POINT_ "${SYMLINK_POINT_}" ABSOLUTE)
- else()
- # handle relative path
- get_filename_component(SYMLINK_POINT_ "${SYMLINK_LOCATION_}/${SYMLINK_POINT_}" ABSOLUTE)
- endif()
-
- # recalculate path length after conversion to canonical form
- string(LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_)
-
- if(SYMLINK_POINT_ MATCHES "${WDIR}/.*")
- # only symlinks that are pointing inside the packaging structure should be checked for relocation
- string(SUBSTRING "${SYMLINK_POINT_}" ${WDR_LEN_} -1 SYMLINK_POINT_WD_)
- cpack_rpm_symlink_get_relocation_prefixes("${F}" "${PACKAGE_PREFIXES}" "SYMLINK_RELOCATIONS")
- cpack_rpm_symlink_get_relocation_prefixes("${SYMLINK_POINT_WD_}" "${PACKAGE_PREFIXES}" "POINT_RELOCATIONS")
-
- list(LENGTH SYMLINK_RELOCATIONS SYMLINK_RELOCATIONS_COUNT)
- list(LENGTH POINT_RELOCATIONS POINT_RELOCATIONS_COUNT)
- else()
- # location pointed to is ouside WDR so it should be treated as a permanent symlink
- set(SYMLINK_POINT_WD_ "${SYMLINK_POINT_}")
-
- unset(SYMLINK_RELOCATIONS)
- unset(POINT_RELOCATIONS)
- unset(SYMLINK_RELOCATIONS_COUNT)
- unset(POINT_RELOCATIONS_COUNT)
-
- message(AUTHOR_WARNING "CPackRPM:Warning: Symbolic link '${F}' points to location that is outside packaging path! Link will possibly not be relocatable.")
- endif()
-
- if(SYMLINK_RELOCATIONS_COUNT AND POINT_RELOCATIONS_COUNT)
- # find matching
- foreach(SYMLINK_RELOCATION_PREFIX IN LISTS SYMLINK_RELOCATIONS)
- list(FIND POINT_RELOCATIONS "${SYMLINK_RELOCATION_PREFIX}" FOUND_INDEX)
- if(NOT ${FOUND_INDEX} EQUAL -1)
- break()
- endif()
- endforeach()
-
- if(NOT ${FOUND_INDEX} EQUAL -1)
- # symlinks have the same subpath
- if(${SYMLINK_RELOCATIONS_COUNT} EQUAL 1 AND ${POINT_RELOCATIONS_COUNT} EQUAL 1)
- # permanent symlink
- get_filename_component(SYMLINK_LOCATION_ "${F}" DIRECTORY)
- file(RELATIVE_PATH FINAL_PATH_ ${SYMLINK_LOCATION_} ${SYMLINK_POINT_WD_})
- execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${FINAL_PATH_}" "${WDIR}/${F}")
- else()
- # relocation subpaths
- cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}"
- "${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}")
- endif()
- else()
- # not on the same relocation path
- cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}"
- "${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}")
- endif()
- elseif(POINT_RELOCATIONS_COUNT)
- # point is relocatable
- cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}"
- "${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}")
- else()
- # is not relocatable or points to non relocatable path - permanent symlink
- execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${SYMLINK_POINT_WD_}" "${WDIR}/${F}")
- endif()
- endif()
- elseif(IS_DIRECTORY "${WDIR}/${F}")
- set(DIRECTIVE "%dir ")
- endif()
-
- string(APPEND INSTALL_FILES "${DIRECTIVE}\"${F}\"\n")
- endforeach()
-
- if(REQUIRES_SYMLINK_RELOCATION_SCRIPT)
- cpack_rpm_symlink_create_relocation_script("${PACKAGE_PREFIXES}")
- endif()
-
- set(RPM_SYMLINK_POSTINSTALL "${RPM_SYMLINK_POSTINSTALL}" PARENT_SCOPE)
- set(CPACK_RPM_INSTALL_FILES "${INSTALL_FILES}" PARENT_SCOPE)
-endfunction()
-
-if(CMAKE_BINARY_DIR)
- message(FATAL_ERROR "CPackRPM.cmake may only be used by CPack internally.")
-endif()
-
-if(NOT UNIX)
- message(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.")
-endif()
-
-# We need to check if the binaries were compiled with debug symbols
-# because without them the package will be useless
-function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR)
- if(NOT CPACK_BUILD_SOURCE_DIRS)
- message(FATAL_ERROR "CPackRPM: CPACK_BUILD_SOURCE_DIRS variable is not set!"
- " Required for debuginfo packaging. See documentation of"
- " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.")
- endif()
-
- # With objdump we should check the debug symbols
- find_program(OBJDUMP_EXECUTABLE objdump)
- if(NOT OBJDUMP_EXECUTABLE)
- message(FATAL_ERROR "CPackRPM: objdump binary could not be found!"
- " Required for debuginfo packaging. See documentation of"
- " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.")
- endif()
-
- # With debugedit we prepare source files list
- find_program(DEBUGEDIT_EXECUTABLE debugedit "/usr/lib/rpm/")
- if(NOT DEBUGEDIT_EXECUTABLE)
- message(FATAL_ERROR "CPackRPM: debugedit binary could not be found!"
- " Required for debuginfo packaging. See documentation of"
- " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.")
- endif()
-
- unset(mkdir_list_)
- unset(cp_list_)
- unset(additional_sources_)
-
- foreach(F IN LISTS INSTALL_FILES)
- if(IS_DIRECTORY "${WORKING_DIR}/${F}" OR IS_SYMLINK "${WORKING_DIR}/${F}")
- continue()
- endif()
-
- execute_process(COMMAND "${OBJDUMP_EXECUTABLE}" -h ${WORKING_DIR}/${F}
- WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}"
- RESULT_VARIABLE OBJDUMP_EXEC_RESULT
- OUTPUT_VARIABLE OBJDUMP_OUT
- ERROR_QUIET)
- # Check that if the given file was executable or not
- if(NOT OBJDUMP_EXEC_RESULT)
- string(FIND "${OBJDUMP_OUT}" "debug" FIND_RESULT)
- if(FIND_RESULT GREATER -1)
- set(index_ 0)
- foreach(source_dir_ IN LISTS CPACK_BUILD_SOURCE_DIRS)
- string(LENGTH "${source_dir_}" source_dir_len_)
- string(LENGTH "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}" debuginfo_dir_len)
- if(source_dir_len_ LESS debuginfo_dir_len)
- message(FATAL_ERROR "CPackRPM: source dir path '${source_dir_}' is"
- " shorter than debuginfo sources dir path '${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}'!"
- " Source dir path must be longer than debuginfo sources dir path."
- " Set CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX variable to a shorter value"
- " or make source dir path longer."
- " Required for debuginfo packaging. See documentation of"
- " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.")
- endif()
-
- file(REMOVE "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list")
- execute_process(COMMAND "${DEBUGEDIT_EXECUTABLE}" -b "${source_dir_}" -d "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}" -i -l "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list" "${WORKING_DIR}/${F}"
- RESULT_VARIABLE res_
- OUTPUT_VARIABLE opt_
- ERROR_VARIABLE err_
- )
-
- file(STRINGS
- "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list"
- sources_)
- list(REMOVE_DUPLICATES sources_)
-
- foreach(source_ IN LISTS sources_)
- if(EXISTS "${source_dir_}/${source_}" AND NOT IS_DIRECTORY "${source_dir_}/${source_}")
- get_filename_component(path_part_ "${source_}" DIRECTORY)
- list(APPEND mkdir_list_ "%{buildroot}${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${path_part_}")
- list(APPEND cp_list_ "cp \"${source_dir_}/${source_}\" \"%{buildroot}${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${path_part_}\"")
-
- list(APPEND additional_sources_ "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${source_}")
- endif()
- endforeach()
-
- math(EXPR index_ "${index_} + 1")
- endforeach()
- else()
- message(WARNING "CPackRPM: File: ${F} does not contain debug symbols. They will possibly be missing from debuginfo package!")
- endif()
- endif()
- endforeach()
-
- list(LENGTH mkdir_list_ len_)
- if(len_)
- list(REMOVE_DUPLICATES mkdir_list_)
- unset(TMP_RPM_DEBUGINFO_INSTALL)
- foreach(part_ IN LISTS mkdir_list_)
- string(APPEND TMP_RPM_DEBUGINFO_INSTALL "mkdir -p \"${part_}\"\n")
- endforeach()
- endif()
-
- list(LENGTH cp_list_ len_)
- if(len_)
- list(REMOVE_DUPLICATES cp_list_)
- foreach(part_ IN LISTS cp_list_)
- string(APPEND TMP_RPM_DEBUGINFO_INSTALL "${part_}\n")
- endforeach()
- endif()
-
- if(NOT DEFINED CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS)
- set(CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS /usr /usr/src /usr/src/debug)
- if(CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION)
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: Adding ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION} to builtin omit list.")
- endif()
- list(APPEND CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS "${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION}")
- endif()
- endif()
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS= ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS}")
- endif()
-
- list(LENGTH additional_sources_ len_)
- if(len_)
- list(REMOVE_DUPLICATES additional_sources_)
- unset(additional_sources_all_)
- foreach(source_ IN LISTS additional_sources_)
- string(REPLACE "/" ";" split_source_ " ${source_}")
- list(REMOVE_AT split_source_ 0)
- unset(tmp_path_)
- # Now generate all segments of the path
- foreach(segment_ IN LISTS split_source_)
- string(APPEND tmp_path_ "/${segment_}")
- list(APPEND additional_sources_all_ "${tmp_path_}")
- endforeach()
- endforeach()
-
- list(REMOVE_DUPLICATES additional_sources_all_)
- list(REMOVE_ITEM additional_sources_all_
- ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS})
-
- unset(TMP_DEBUGINFO_ADDITIONAL_SOURCES)
- foreach(source_ IN LISTS additional_sources_all_)
- string(APPEND TMP_DEBUGINFO_ADDITIONAL_SOURCES "${source_}\n")
- endforeach()
- endif()
-
- set(TMP_RPM_DEBUGINFO_INSTALL "${TMP_RPM_DEBUGINFO_INSTALL}" PARENT_SCOPE)
- set(TMP_DEBUGINFO_ADDITIONAL_SOURCES "${TMP_DEBUGINFO_ADDITIONAL_SOURCES}"
- PARENT_SCOPE)
-endfunction()
-
-function(cpack_rpm_variable_fallback OUTPUT_VAR_NAME)
- set(FALLBACK_VAR_NAMES ${ARGN})
-
- foreach(variable_name IN LISTS FALLBACK_VAR_NAMES)
- if(${variable_name})
- set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE)
- break()
- endif()
- endforeach()
-endfunction()
-
-function(cpack_rpm_generate_package)
- # rpmbuild is the basic command for building RPM package
- # it may be a simple (symbolic) link to rpm command.
- find_program(RPMBUILD_EXECUTABLE rpmbuild)
-
- # Check version of the rpmbuild tool this would be easier to
- # track bugs with users and CPackRPM debug mode.
- # We may use RPM version in order to check for available version dependent features
- if(RPMBUILD_EXECUTABLE)
- execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --version
- OUTPUT_VARIABLE _TMP_VERSION
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- string(REGEX REPLACE "^.* " ""
- RPMBUILD_EXECUTABLE_VERSION
- ${_TMP_VERSION})
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: rpmbuild version is <${RPMBUILD_EXECUTABLE_VERSION}>")
- endif()
- endif()
-
- if(NOT RPMBUILD_EXECUTABLE)
- message(FATAL_ERROR "RPM package requires rpmbuild executable")
- endif()
-
- # Display lsb_release output if DEBUG mode enable
- # This will help to diagnose problem with CPackRPM
- # because we will know on which kind of Linux we are
- if(CPACK_RPM_PACKAGE_DEBUG)
- find_program(LSB_RELEASE_EXECUTABLE lsb_release)
- if(LSB_RELEASE_EXECUTABLE)
- execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -a
- OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- string(REGEX REPLACE "\n" ", "
- LSB_RELEASE_OUTPUT
- ${_TMP_LSB_RELEASE_OUTPUT})
- else ()
- set(LSB_RELEASE_OUTPUT "lsb_release not installed/found!")
- endif()
- message("CPackRPM:Debug: LSB_RELEASE = ${LSB_RELEASE_OUTPUT}")
- endif()
-
- # We may use RPM version in the future in order
- # to shut down warning about space in buildtree
- # some recent RPM version should support space in different places.
- # not checked [yet].
- if(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*")
- message(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.")
- endif()
-
- # If rpmbuild is found
- # we try to discover alien since we may be on non RPM distro like Debian.
- # In this case we may try to to use more advanced features
- # like generating RPM directly from DEB using alien.
- # FIXME feature not finished (yet)
- find_program(ALIEN_EXECUTABLE alien)
- if(ALIEN_EXECUTABLE)
- message(STATUS "alien found, we may be on a Debian based distro.")
- endif()
-
- # Are we packaging components ?
- if(CPACK_RPM_PACKAGE_COMPONENT)
- string(TOUPPER ${CPACK_RPM_PACKAGE_COMPONENT} CPACK_RPM_PACKAGE_COMPONENT_UPPER)
- endif()
-
- set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}")
-
- #
- # Use user-defined RPM specific variables value
- # or generate reasonable default value from
- # CPACK_xxx generic values.
- # The variables comes from the needed (mandatory or not)
- # values found in the RPM specification file aka ".spec" file.
- # The variables which may/should be defined are:
- #
-
- # CPACK_RPM_PACKAGE_SUMMARY (mandatory)
-
- if(CPACK_RPM_PACKAGE_COMPONENT)
- cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_SUMMARY"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_SUMMARY")
- endif()
-
- if(NOT CPACK_RPM_PACKAGE_SUMMARY)
- if(CPACK_PACKAGE_DESCRIPTION_SUMMARY)
- set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
- else()
- # if neither var is defined lets use the name as summary
- string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY)
- endif()
- endif()
-
- # CPACK_RPM_PACKAGE_NAME (mandatory)
- if(NOT CPACK_RPM_PACKAGE_NAME)
- string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME)
- endif()
-
- if(CPACK_RPM_PACKAGE_COMPONENT)
- string(TOUPPER "${CPACK_RPM_MAIN_COMPONENT}"
- CPACK_RPM_MAIN_COMPONENT_UPPER)
-
- if(NOT CPACK_RPM_MAIN_COMPONENT_UPPER STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER)
- string(APPEND CPACK_RPM_PACKAGE_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}")
-
- cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_NAME"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME")
- endif()
- endif()
-
- # CPACK_RPM_PACKAGE_VERSION (mandatory)
- if(NOT CPACK_RPM_PACKAGE_VERSION)
- if(NOT CPACK_PACKAGE_VERSION)
- message(FATAL_ERROR "RPM package requires a package version")
- endif()
- set(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
- endif()
- # Replace '-' in version with '_'
- # '-' character is an Illegal RPM version character
- # it is illegal because it is used to separate
- # RPM "Version" from RPM "Release"
- string(REPLACE "-" "_" CPACK_RPM_PACKAGE_VERSION ${CPACK_RPM_PACKAGE_VERSION})
-
- # CPACK_RPM_PACKAGE_ARCHITECTURE (mandatory)
- if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
- execute_process(COMMAND uname "-m"
- OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- else()
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
- endif()
- endif()
-
- if(CPACK_RPM_PACKAGE_COMPONENT)
- cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_ARCHITECTURE"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_ARCHITECTURE")
-
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: using component build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
- endif()
- endif()
-
- if(${CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch")
- set(TMP_RPM_BUILDARCH "Buildarch: ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
- else()
- set(TMP_RPM_BUILDARCH "")
- endif()
-
- # CPACK_RPM_PACKAGE_RELEASE
- # The RPM release is the numbering of the RPM package ITSELF
- # this is the version of the PACKAGING and NOT the version
- # of the CONTENT of the package.
- # You may well need to generate a new RPM package release
- # without changing the version of the packaged software.
- # This is the case when the packaging is buggy (not) the software :=)
- # If not set, 1 is a good candidate
- if(NOT CPACK_RPM_PACKAGE_RELEASE)
- set(CPACK_RPM_PACKAGE_RELEASE "1")
- endif()
-
- if(CPACK_RPM_PACKAGE_RELEASE_DIST)
- string(APPEND CPACK_RPM_PACKAGE_RELEASE "%{?dist}")
- endif()
-
- # CPACK_RPM_PACKAGE_LICENSE
- if(NOT CPACK_RPM_PACKAGE_LICENSE)
- set(CPACK_RPM_PACKAGE_LICENSE "unknown")
- endif()
-
- # CPACK_RPM_PACKAGE_GROUP
- if(CPACK_RPM_PACKAGE_COMPONENT)
- cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_GROUP"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_GROUP")
- endif()
-
- if(NOT CPACK_RPM_PACKAGE_GROUP)
- set(CPACK_RPM_PACKAGE_GROUP "unknown")
- endif()
-
- # CPACK_RPM_PACKAGE_VENDOR
- if(NOT CPACK_RPM_PACKAGE_VENDOR)
- if(CPACK_PACKAGE_VENDOR)
- set(CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}")
- else()
- set(CPACK_RPM_PACKAGE_VENDOR "unknown")
- endif()
- endif()
-
- # CPACK_RPM_PACKAGE_SOURCE
- # The name of the source tarball in case we generate a source RPM
-
- # CPACK_RPM_PACKAGE_DESCRIPTION
- # The variable content may be either
- # - explicitly given by the user or
- # - filled with the content of CPACK_PACKAGE_DESCRIPTION_FILE
- # if it is defined
- # - set to a default value
- #
-
- if(CPACK_RPM_PACKAGE_COMPONENT)
- cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_DESCRIPTION"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_DESCRIPTION"
- "CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION")
- endif()
-
- if(NOT CPACK_RPM_PACKAGE_DESCRIPTION)
- if(CPACK_PACKAGE_DESCRIPTION_FILE)
- file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION)
- else ()
- set(CPACK_RPM_PACKAGE_DESCRIPTION "no package description available")
- endif ()
- endif ()
-
- # CPACK_RPM_COMPRESSION_TYPE
- #
- if (CPACK_RPM_COMPRESSION_TYPE)
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: User Specified RPM compression type: ${CPACK_RPM_COMPRESSION_TYPE}")
- endif()
- if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma")
- set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.lzdio")
- endif()
- if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz")
- set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7.xzdio")
- endif()
- if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2")
- set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.bzdio")
- endif()
- if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip")
- set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.gzdio")
- endif()
- else()
- set(CPACK_RPM_COMPRESSION_TYPE_TMP "")
- endif()
-
- if(NOT CPACK_RPM_PACKAGE_SOURCES)
- if(CPACK_PACKAGE_RELOCATABLE OR CPACK_RPM_PACKAGE_RELOCATABLE)
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: Trying to build a relocatable package")
- endif()
- if(CPACK_SET_DESTDIR AND (NOT CPACK_SET_DESTDIR STREQUAL "I_ON"))
- message("CPackRPM:Warning: CPACK_SET_DESTDIR is set (=${CPACK_SET_DESTDIR}) while requesting a relocatable package (CPACK_RPM_PACKAGE_RELOCATABLE is set): this is not supported, the package won't be relocatable.")
- set(CPACK_RPM_PACKAGE_RELOCATABLE FALSE)
- else()
- set(CPACK_RPM_PACKAGE_PREFIX ${CPACK_PACKAGING_INSTALL_PREFIX}) # kept for back compatibility (provided external RPM spec files)
- cpack_rpm_prepare_relocation_paths()
- set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE)
- endif()
- endif()
- else()
- if(CPACK_RPM_PACKAGE_COMPONENT)
- message(FATAL_ERROR "CPACK_RPM_PACKAGE_SOURCES parameter can not be used"
- " in combination with CPACK_RPM_PACKAGE_COMPONENT parameter!")
- endif()
-
- set(CPACK_RPM_PACKAGE_RELOCATABLE FALSE) # disable relocatable option if building source RPM
- endif()
-
- execute_process(
- COMMAND "${RPMBUILD_EXECUTABLE}" --querytags
- OUTPUT_VARIABLE RPMBUILD_TAG_LIST
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- string(REPLACE "\n" ";" RPMBUILD_TAG_LIST "${RPMBUILD_TAG_LIST}")
-
- # Check if additional fields for RPM spec header are given
- # There may be some COMPONENT specific variables as well
- # If component specific var is not provided we use the global one
- # for each component
- foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN)
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}")
- endif()
-
- if(CPACK_RPM_PACKAGE_COMPONENT)
- cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_${_RPM_SPEC_HEADER}")
- endif()
-
- if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER})
- cmake_policy(PUSH)
- cmake_policy(SET CMP0057 NEW)
- # Prefix can be replaced by Prefixes but the old version stil works so we'll ignore it for now
- # Requires* is a special case because it gets transformed to Requires(pre/post/preun/postun)
- # Auto* is a special case because the tags can not be queried by querytags rpmbuild flag
- set(special_case_tags_ PREFIX REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN AUTOPROV AUTOREQ AUTOREQPROV)
- if(NOT _RPM_SPEC_HEADER IN_LIST RPMBUILD_TAG_LIST AND NOT _RPM_SPEC_HEADER IN_LIST special_case_tags_)
- cmake_policy(POP)
- message(AUTHOR_WARNING "CPackRPM:Warning: ${_RPM_SPEC_HEADER} not "
- "supported in provided rpmbuild. Tag will not be used.")
- continue()
- endif()
- cmake_policy(POP)
-
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}")
- endif()
-
- set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}})
- endif()
-
- # Treat the RPM Spec keyword iff it has been properly defined
- if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP)
- # Transform NAME --> Name e.g. PROVIDES --> Provides
- # The Upper-case first letter and lowercase tail is the
- # appropriate value required in the final RPM spec file.
- string(SUBSTRING ${_RPM_SPEC_HEADER} 1 -1 _PACKAGE_HEADER_TAIL)
- string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL)
- string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME)
- string(APPEND _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_TAIL}")
- # The following keywords require parentheses around the "pre" or "post" suffix in the final RPM spec file.
- set(SCRIPTS_REQUIREMENTS_LIST REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN)
- list(FIND SCRIPTS_REQUIREMENTS_LIST ${_RPM_SPEC_HEADER} IS_SCRIPTS_REQUIREMENT_FOUND)
- if(NOT ${IS_SCRIPTS_REQUIREMENT_FOUND} EQUAL -1)
- string(REPLACE "_" "(" _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}")
- string(APPEND _PACKAGE_HEADER_NAME ")")
- endif()
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}")
- endif()
- set(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}")
- unset(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP)
- endif()
- endforeach()
-
- # CPACK_RPM_SPEC_INSTALL_POST
- # May be used to define a RPM post intallation script
- # for example setting it to "/bin/true" may prevent
- # rpmbuild from stripping binaries.
- if(CPACK_RPM_SPEC_INSTALL_POST)
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: User defined CPACK_RPM_SPEC_INSTALL_POST = ${CPACK_RPM_SPEC_INSTALL_POST}")
- endif()
- set(TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}")
- endif()
-
- # CPACK_RPM_POST_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE)
- # CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE)
- # May be used to embed a post (un)installation script in the spec file.
- # The refered script file(s) will be read and directly
- # put after the %post or %postun section
- # ----------------------------------------------------------------
- # CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE)
- # CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE)
- # May be used to embed a pre (un)installation script in the spec file.
- # The refered script file(s) will be read and directly
- # put after the %pre or %preun section
- foreach(RPM_SCRIPT_FILE_TYPE_ "INSTALL" "UNINSTALL")
- foreach(RPM_SCRIPT_FILE_TIME_ "PRE" "POST")
- set("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE"
- "${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE}")
-
- if(CPACK_RPM_PACKAGE_COMPONENT)
- cpack_rpm_variable_fallback("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE")
- endif()
-
- # Handle file if it has been specified
- if(CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE)
- if(EXISTS ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE})
- file(READ ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}
- "CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}")
- else()
- message("CPackRPM:Warning: CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE <${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}> does not exists - ignoring")
- endif()
- else()
- # reset SPEC var value if no file has been specified
- # (either globally or component-wise)
- set("CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}" "")
- endif()
- endforeach()
- endforeach()
-
- # CPACK_RPM_CHANGELOG_FILE
- # May be used to embed a changelog in the spec file.
- # The refered file will be read and directly put after the %changelog section
- if(CPACK_RPM_CHANGELOG_FILE)
- if(EXISTS ${CPACK_RPM_CHANGELOG_FILE})
- file(READ ${CPACK_RPM_CHANGELOG_FILE} CPACK_RPM_SPEC_CHANGELOG)
- else()
- message(SEND_ERROR "CPackRPM:Warning: CPACK_RPM_CHANGELOG_FILE <${CPACK_RPM_CHANGELOG_FILE}> does not exists - ignoring")
- endif()
- else()
- set(CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Eric Noulard <eric.noulard@gmail.com> - ${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}\n Generated by CPack RPM (no Changelog file were provided)")
- endif()
-
- # CPACK_RPM_SPEC_MORE_DEFINE
- # This is a generated spec rpm file spaceholder
- if(CPACK_RPM_SPEC_MORE_DEFINE)
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: User defined more define spec line specified:\n ${CPACK_RPM_SPEC_MORE_DEFINE}")
- endif()
- endif()
-
- # Now we may create the RPM build tree structure
- set(CPACK_RPM_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}")
- message(STATUS "CPackRPM:Debug: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}")
- # Prepare RPM build tree
- file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR})
- file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/tmp)
- file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/BUILD)
- file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/RPMS)
- file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SOURCES)
- file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SPECS)
- file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SRPMS)
-
- # it seems rpmbuild can't handle spaces in the path
- # neither escaping (as below) nor putting quotes around the path seem to help
- #string(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}")
- set(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}")
-
- cpack_rpm_prepare_content_list()
-
- # In component case, put CPACK_ABSOLUTE_DESTINATION_FILES_<COMPONENT>
- # into CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL
- # otherwise, put CPACK_ABSOLUTE_DESTINATION_FILES
- # This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL handling
- if(CPACK_RPM_PACKAGE_COMPONENT)
- if(CPACK_ABSOLUTE_DESTINATION_FILES)
- cpack_rpm_variable_fallback("COMPONENT_FILES_TAG"
- "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}"
- "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}")
- set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${${COMPONENT_FILES_TAG}}")
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>")
- message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}")
- endif()
- endif()
- else()
- if(CPACK_ABSOLUTE_DESTINATION_FILES)
- set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${CPACK_ABSOLUTE_DESTINATION_FILES}")
- endif()
- endif()
-
- # In component case, set CPACK_RPM_USER_FILELIST_INTERNAL with CPACK_RPM_<COMPONENT>_USER_FILELIST.
- set(CPACK_RPM_USER_FILELIST_INTERNAL "")
- if(CPACK_RPM_PACKAGE_COMPONENT)
- cpack_rpm_variable_fallback("CPACK_RPM_USER_FILELIST_INTERNAL"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_FILELIST")
-
- if(CPACK_RPM_PACKAGE_DEBUG AND CPACK_RPM_USER_FILELIST_INTERNAL)
- message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>")
- message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}")
- endif()
- elseif(CPACK_RPM_USER_FILELIST)
- set(CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}")
- endif()
-
- # Handle user specified file line list in CPACK_RPM_USER_FILELIST_INTERNAL
- # Remove those files from CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL
- # or CPACK_RPM_INSTALL_FILES,
- # hence it must be done before these auto-generated lists are processed.
- if(CPACK_RPM_USER_FILELIST_INTERNAL)
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>")
- endif()
-
- # Create CMake list from CPACK_RPM_INSTALL_FILES
- string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST)
- string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST
- "${CPACK_RPM_INSTALL_FILES_LIST}")
- string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST
- "${CPACK_RPM_INSTALL_FILES_LIST}")
-
- set(CPACK_RPM_USER_INSTALL_FILES "")
- foreach(F IN LISTS CPACK_RPM_USER_FILELIST_INTERNAL)
- string(REGEX REPLACE "%[A-Za-z]+(\\([^()]*\\))? " "" F_PATH ${F})
- string(REGEX MATCH "(%[A-Za-z]+(\\([^()]*\\))? )*" F_PREFIX ${F})
- string(STRIP ${F_PREFIX} F_PREFIX)
-
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: F_PREFIX=<${F_PREFIX}>, F_PATH=<${F_PATH}>")
- endif()
- if(F_PREFIX)
- string(APPEND F_PREFIX " ")
- endif()
- # Rebuild the user list file
- string(APPEND CPACK_RPM_USER_INSTALL_FILES "${F_PREFIX}\"${F_PATH}\"\n")
-
- # Remove from CPACK_RPM_INSTALL_FILES and CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL
- list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${F_PATH})
- # ABSOLUTE destination files list may not exists at all
- if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL)
- list(REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${F_PATH})
- endif()
- endforeach()
-
- # Rebuild CPACK_RPM_INSTALL_FILES
- set(CPACK_RPM_INSTALL_FILES "")
- foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST)
- string(APPEND CPACK_RPM_INSTALL_FILES "\"${F}\"\n")
- endforeach()
- else()
- set(CPACK_RPM_USER_INSTALL_FILES "")
- endif()
-
- if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL)
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: Handling Absolute Destination Files: ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}")
- endif()
- # Remove trailing space
- string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST)
- # Transform endline separated - string into CMake List
- string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}")
- # Remove unecessary quotes
- string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}")
- # Remove ABSOLUTE install file from INSTALL FILE LIST
- list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL})
- # Rebuild INSTALL_FILES
- set(CPACK_RPM_INSTALL_FILES "")
- foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST)
- string(APPEND CPACK_RPM_INSTALL_FILES "\"${F}\"\n")
- endforeach()
- # Build ABSOLUTE_INSTALL_FILES
- set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "")
- foreach(F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL)
- string(APPEND CPACK_RPM_ABSOLUTE_INSTALL_FILES "%config \"${F}\"\n")
- endforeach()
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: CPACK_RPM_ABSOLUTE_INSTALL_FILES=${CPACK_RPM_ABSOLUTE_INSTALL_FILES}")
- message("CPackRPM:Debug: CPACK_RPM_INSTALL_FILES=${CPACK_RPM_INSTALL_FILES}")
- endif()
- else()
- # reset vars in order to avoid leakage of value(s) from one component to another
- set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "")
- endif()
-
- cpack_rpm_variable_fallback("CPACK_RPM_DEBUGINFO_PACKAGE"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_DEBUGINFO_PACKAGE"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEBUGINFO_PACKAGE"
- "CPACK_RPM_DEBUGINFO_PACKAGE")
- if(CPACK_RPM_DEBUGINFO_PACKAGE OR (CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND NOT GENERATE_SPEC_PARTS))
- cpack_rpm_variable_fallback("CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_BUILD_SOURCE_DIRS_PREFIX"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_BUILD_SOURCE_DIRS_PREFIX"
- "CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX")
- if(NOT CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX)
- set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}")
- endif()
-
- # handle cases where path contains extra slashes (e.g. /a//b/ instead of
- # /a/b)
- get_filename_component(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX
- "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}" ABSOLUTE)
-
- if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND GENERATE_SPEC_PARTS)
- file(WRITE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}.files"
- "${CPACK_RPM_INSTALL_FILES}")
- else()
- if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND CPACK_RPM_PACKAGE_COMPONENT)
- # this part is only required by components packaging - with monolithic
- # packages we can be certain that there are no other components present
- # so CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE is a noop
- if(CPACK_RPM_DEBUGINFO_PACKAGE)
- # only add current package files to debuginfo list if debuginfo
- # generation is enabled for current package
- string(STRIP "${CPACK_RPM_INSTALL_FILES}" install_files_)
- string(REPLACE "\n" ";" install_files_ "${install_files_}")
- string(REPLACE "\"" "" install_files_ "${install_files_}")
- else()
- unset(install_files_)
- endif()
-
- file(GLOB files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.files")
-
- foreach(f_ IN LISTS files_)
- file(READ "${f_}" tmp_)
- string(APPEND install_files_ ";${tmp_}")
- endforeach()
-
- # if there were other components/groups so we need to move files from them
- # to current component otherwise those files won't be found
- file(GLOB components_ LIST_DIRECTORIES true RELATIVE
- "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}"
- "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/*")
- foreach(component_ IN LISTS components_)
- string(TOUPPER "${component_}" component_dir_upper_)
- if(component_dir_upper_ STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER)
- # skip current component
- continue()
- endif()
-
- cmake_policy(PUSH)
- cmake_policy(SET CMP0009 NEW)
- file(GLOB_RECURSE files_for_move_ LIST_DIRECTORIES false RELATIVE
- "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}"
- "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/*")
- cmake_policy(POP)
-
- foreach(f_ IN LISTS files_for_move_)
- get_filename_component(dir_path_ "${f_}" DIRECTORY)
- set(src_file_
- "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/${f_}")
-
- # check that we are not overriding an existing file that doesn't
- # match the file that we want to copy
- if(EXISTS "${src_file_}" AND EXISTS "${WDIR}/${f_}")
- execute_process(
- COMMAND ${CMAKE_COMMAND} -E compare_files "${src_file_}" "${WDIR}/${f_}"
- RESULT_VARIABLE res_
- )
- if(res_)
- message(FATAL_ERROR "CPackRPM:Error: File on path '${WDIR}/${f_}'"
- " already exists but is a different than the one in component"
- " '${component_}'! Packages will not be generated.")
- endif()
- endif()
-
- file(MAKE_DIRECTORY "${WDIR}/${dir_path_}")
- file(RENAME "${src_file_}"
- "${WDIR}/${f_}")
- endforeach()
- endforeach()
-
- cpack_rpm_debugsymbol_check("${install_files_}" "${WDIR}")
- else()
- string(STRIP "${CPACK_RPM_INSTALL_FILES}" install_files_)
- string(REPLACE "\n" ";" install_files_ "${install_files_}")
- string(REPLACE "\"" "" install_files_ "${install_files_}")
-
- cpack_rpm_debugsymbol_check("${install_files_}" "${WDIR}")
- endif()
-
- if(TMP_DEBUGINFO_ADDITIONAL_SOURCES)
- set(TMP_RPM_DEBUGINFO "
-# Modified version of %%debug_package macro
-# defined in /usr/lib/rpm/macros as that one
-# can't handle injection of extra source files.
-%ifnarch noarch
-%global __debug_package 1
-%package debuginfo
-Summary: Debug information for package %{name}
-Group: Development/Debug
-AutoReqProv: 0
-%description debuginfo
-This package provides debug information for package %{name}.
-Debug information is useful when developing applications that use this
-package or when debugging this package.
-%files debuginfo -f debugfiles.list
-%defattr(-,root,root)
-${TMP_DEBUGINFO_ADDITIONAL_SOURCES}
-%endif
-")
- elseif(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE)
- message(AUTHOR_WARNING "CPackRPM:Warning: debuginfo package was requested"
- " but will not be generated as no source files were found!")
- else()
- message(AUTHOR_WARNING "CPackRPM:Warning: debuginfo package was requested"
- " but will not be generated as no source files were found! Component: '"
- "${CPACK_RPM_PACKAGE_COMPONENT}'.")
- endif()
- endif()
- endif()
-
- # Prepare install files
- cpack_rpm_prepare_install_files(
- "${CPACK_RPM_INSTALL_FILES}"
- "${WDIR}"
- "${RPM_USED_PACKAGE_PREFIXES}"
- "${CPACK_RPM_PACKAGE_RELOCATABLE}"
- )
-
- # set default user and group
- foreach(_PERM_TYPE "USER" "GROUP")
- if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE})
- set(TMP_DEFAULT_${_PERM_TYPE} "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}}")
- elseif(CPACK_RPM_DEFAULT_${_PERM_TYPE})
- set(TMP_DEFAULT_${_PERM_TYPE} "${CPACK_RPM_DEFAULT_${_PERM_TYPE}}")
- else()
- set(TMP_DEFAULT_${_PERM_TYPE} "root")
- endif()
- endforeach()
-
- # set default file and dir permissions
- foreach(_PERM_TYPE "FILE" "DIR")
- if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS)
- get_unix_permissions_octal_notation("CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS" "TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
- set(_PERMISSIONS_VAR "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
- elseif(CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS)
- get_unix_permissions_octal_notation("CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS" "TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
- set(_PERMISSIONS_VAR "CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
- else()
- set(TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS "-")
- endif()
- endforeach()
-
- # The name of the final spec file to be used by rpmbuild
- set(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}.spec")
-
- # Print out some debug information if we were asked for that
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}")
- message("CPackRPM:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}")
- message("CPackRPM:Debug: CPACK_TEMPORARY_DIRECTORY = ${CPACK_TEMPORARY_DIRECTORY}")
- message("CPackRPM:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}")
- message("CPackRPM:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}")
- message("CPackRPM:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}")
- message("CPackRPM:Debug: CPACK_RPM_BINARY_SPECFILE = ${CPACK_RPM_BINARY_SPECFILE}")
- message("CPackRPM:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}")
- message("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}")
- endif()
-
- #
- # USER generated/provided spec file handling.
- #
-
- # We can have a component specific spec file.
- if(CPACK_RPM_PACKAGE_COMPONENT)
- cpack_rpm_variable_fallback("CPACK_RPM_USER_BINARY_SPECFILE"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_BINARY_SPECFILE")
- endif()
-
- cpack_rpm_variable_fallback("CPACK_RPM_FILE_NAME"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_FILE_NAME"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_FILE_NAME"
- "CPACK_RPM_FILE_NAME")
- if(NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT")
- if(CPACK_RPM_FILE_NAME)
- cmake_policy(PUSH)
- cmake_policy(SET CMP0010 NEW)
- if(NOT CPACK_RPM_FILE_NAME MATCHES ".*\\.rpm")
- cmake_policy(POP)
- message(FATAL_ERROR "'${CPACK_RPM_FILE_NAME}' is not a valid RPM package file name as it must end with '.rpm'!")
- endif()
- cmake_policy(POP)
- else()
- # old file name format for back compatibility
- string(TOUPPER "${CPACK_RPM_MAIN_COMPONENT}"
- CPACK_RPM_MAIN_COMPONENT_UPPER)
-
- if(CPACK_RPM_MAIN_COMPONENT_UPPER STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER)
- # this is the main component so ignore the component filename part
- set(CPACK_RPM_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.rpm")
- else()
- set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}")
- endif()
- endif()
- # else example:
- #set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
-
- if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND GENERATE_SPEC_PARTS)
- string(TOLOWER "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm" expected_filename_)
-
- file(WRITE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}.rpm_name"
- "${expected_filename_};${CPACK_RPM_FILE_NAME}")
- elseif(NOT CPACK_RPM_DEBUGINFO_PACKAGE)
- set(FILE_NAME_DEFINE "%define _rpmfilename ${CPACK_RPM_FILE_NAME}")
- endif()
- endif()
-
- if(CPACK_RPM_PACKAGE_SOURCES) # source rpm
- set(archive_name_ "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}")
-
- execute_process(
- COMMAND ${CMAKE_COMMAND} -E tar "cfvz" "${CPACK_RPM_DIRECTORY}/SOURCES/${archive_name_}.tar.gz" "${CPACK_PACKAGE_FILE_NAME}"
- WORKING_DIRECTORY ${CPACK_RPM_DIRECTORY}
- )
- set(TMP_RPM_SOURCE "Source: ${archive_name_}.tar.gz")
-
- if(CPACK_RPM_BUILDREQUIRES)
- set(TMP_RPM_BUILD_REQUIRES "BuildRequires: ${CPACK_RPM_BUILDREQUIRES}")
- endif()
-
- # Disable debuginfo packages - srpm generates invalid packages due to
- # releasing controll to cpack to generate binary packages.
- # Note however that this doesn't prevent cpack to generate debuginfo
- # packages when run from srpm with --rebuild.
- set(TMP_RPM_DISABLE_DEBUGINFO "%define debug_package %{nil}")
-
- if(NOT CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX)
- set(CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX "/")
- endif()
-
- set(TMP_RPM_BUILD
- "
-%build
-mkdir cpack_rpm_build_dir
-cd cpack_rpm_build_dir
-cmake ${CPACK_RPM_SOURCE_PKG_BUILD_PARAMS} -DCPACK_PACKAGING_INSTALL_PREFIX=${CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX} ../${CPACK_PACKAGE_FILE_NAME}
-make %{?_smp_mflags}" # %{?_smp_mflags} -> -j option
- )
- set(TMP_RPM_INSTALL
- "
-cd cpack_rpm_build_dir
-cpack -G RPM
-mv *.rpm %_rpmdir"
- )
- set(TMP_RPM_PREP "%setup -c")
-
- set(RPMBUILD_FLAGS "-bs")
-
- file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in
- "# -*- rpm-spec -*-
-BuildRoot: %_topdir/\@CPACK_PACKAGE_FILE_NAME\@
-Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@
-Name: \@CPACK_RPM_PACKAGE_NAME\@
-Version: \@CPACK_RPM_PACKAGE_VERSION\@
-Release: \@CPACK_RPM_PACKAGE_RELEASE\@
-License: \@CPACK_RPM_PACKAGE_LICENSE\@
-Group: \@CPACK_RPM_PACKAGE_GROUP\@
-Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@
-
-\@TMP_RPM_SOURCE\@
-\@TMP_RPM_BUILD_REQUIRES\@
-\@TMP_RPM_BUILDARCH\@
-\@TMP_RPM_PREFIXES\@
-
-\@TMP_RPM_DISABLE_DEBUGINFO\@
-
-%define _rpmdir %_topdir/RPMS
-%define _srcrpmdir %_topdir/SRPMS
-\@FILE_NAME_DEFINE\@
-%define _unpackaged_files_terminate_build 0
-\@TMP_RPM_SPEC_INSTALL_POST\@
-\@CPACK_RPM_SPEC_MORE_DEFINE\@
-\@CPACK_RPM_COMPRESSION_TYPE_TMP\@
-
-%description
-\@CPACK_RPM_PACKAGE_DESCRIPTION\@
-
-# This is a shortcutted spec file generated by CMake RPM generator
-# we skip _install step because CPack does that for us.
-# We do only save CPack installed tree in _prepr
-# and then restore it in build.
-%prep
-\@TMP_RPM_PREP\@
-
-\@TMP_RPM_BUILD\@
-
-#p build
-
-%install
-\@TMP_RPM_INSTALL\@
-
-%clean
-
-%changelog
-\@CPACK_RPM_SPEC_CHANGELOG\@
-"
- )
-
- elseif(GENERATE_SPEC_PARTS) # binary rpm with single debuginfo package
- file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in
- "# -*- rpm-spec -*-
-%package -n \@CPACK_RPM_PACKAGE_NAME\@
-Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@
-Version: \@CPACK_RPM_PACKAGE_VERSION\@
-Release: \@CPACK_RPM_PACKAGE_RELEASE\@
-License: \@CPACK_RPM_PACKAGE_LICENSE\@
-Group: \@CPACK_RPM_PACKAGE_GROUP\@
-Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@
-
-\@TMP_RPM_URL\@
-\@TMP_RPM_REQUIRES\@
-\@TMP_RPM_REQUIRES_PRE\@
-\@TMP_RPM_REQUIRES_POST\@
-\@TMP_RPM_REQUIRES_PREUN\@
-\@TMP_RPM_REQUIRES_POSTUN\@
-\@TMP_RPM_PROVIDES\@
-\@TMP_RPM_OBSOLETES\@
-\@TMP_RPM_CONFLICTS\@
-\@TMP_RPM_SUGGESTS\@
-\@TMP_RPM_AUTOPROV\@
-\@TMP_RPM_AUTOREQ\@
-\@TMP_RPM_AUTOREQPROV\@
-\@TMP_RPM_BUILDARCH\@
-\@TMP_RPM_PREFIXES\@
-
-%description -n \@CPACK_RPM_PACKAGE_NAME\@
-\@CPACK_RPM_PACKAGE_DESCRIPTION\@
-
-%files -n \@CPACK_RPM_PACKAGE_NAME\@
-%defattr(\@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@)
-\@CPACK_RPM_INSTALL_FILES\@
-\@CPACK_RPM_ABSOLUTE_INSTALL_FILES\@
-\@CPACK_RPM_USER_INSTALL_FILES\@
-"
- )
-
- else() # binary rpm
- if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE)
- # find generated spec file and take its name
- file(GLOB spec_files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.spec")
-
- foreach(f_ IN LISTS spec_files_)
- file(READ "${f_}" tmp_)
- string(APPEND TMP_OTHER_COMPONENTS "\n${tmp_}\n")
- endforeach()
- endif()
-
- # We should generate a USER spec file template:
- # - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE
- # - or the user did not provide one : NOT CPACK_RPM_USER_BINARY_SPECFILE
- set(RPMBUILD_FLAGS "-bb")
- if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE)
-
- file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in
- "# -*- rpm-spec -*-
-BuildRoot: %_topdir/\@CPACK_PACKAGE_FILE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH\@
-Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@
-Name: \@CPACK_RPM_PACKAGE_NAME\@
-Version: \@CPACK_RPM_PACKAGE_VERSION\@
-Release: \@CPACK_RPM_PACKAGE_RELEASE\@
-License: \@CPACK_RPM_PACKAGE_LICENSE\@
-Group: \@CPACK_RPM_PACKAGE_GROUP\@
-Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@
-
-\@TMP_RPM_URL\@
-\@TMP_RPM_REQUIRES\@
-\@TMP_RPM_REQUIRES_PRE\@
-\@TMP_RPM_REQUIRES_POST\@
-\@TMP_RPM_REQUIRES_PREUN\@
-\@TMP_RPM_REQUIRES_POSTUN\@
-\@TMP_RPM_PROVIDES\@
-\@TMP_RPM_OBSOLETES\@
-\@TMP_RPM_CONFLICTS\@
-\@TMP_RPM_SUGGESTS\@
-\@TMP_RPM_AUTOPROV\@
-\@TMP_RPM_AUTOREQ\@
-\@TMP_RPM_AUTOREQPROV\@
-\@TMP_RPM_BUILDARCH\@
-\@TMP_RPM_PREFIXES\@
-
-\@TMP_RPM_DEBUGINFO\@
-
-%define _rpmdir %_topdir/RPMS
-%define _srcrpmdir %_topdir/SRPMS
-\@FILE_NAME_DEFINE\@
-%define _unpackaged_files_terminate_build 0
-\@TMP_RPM_SPEC_INSTALL_POST\@
-\@CPACK_RPM_SPEC_MORE_DEFINE\@
-\@CPACK_RPM_COMPRESSION_TYPE_TMP\@
-
-%description
-\@CPACK_RPM_PACKAGE_DESCRIPTION\@
-
-# This is a shortcutted spec file generated by CMake RPM generator
-# we skip _install step because CPack does that for us.
-# We do only save CPack installed tree in _prepr
-# and then restore it in build.
-%prep
-mv $RPM_BUILD_ROOT %_topdir/tmpBBroot
-
-%install
-if [ -e $RPM_BUILD_ROOT ];
-then
- rm -rf $RPM_BUILD_ROOT
-fi
-mv %_topdir/tmpBBroot $RPM_BUILD_ROOT
-
-\@TMP_RPM_DEBUGINFO_INSTALL\@
-
-%clean
-
-%post
-\@RPM_SYMLINK_POSTINSTALL\@
-\@CPACK_RPM_SPEC_POSTINSTALL\@
-
-%postun
-\@CPACK_RPM_SPEC_POSTUNINSTALL\@
-
-%pre
-\@CPACK_RPM_SPEC_PREINSTALL\@
-
-%preun
-\@CPACK_RPM_SPEC_PREUNINSTALL\@
-
-%files
-%defattr(\@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@)
-\@CPACK_RPM_INSTALL_FILES\@
-\@CPACK_RPM_ABSOLUTE_INSTALL_FILES\@
-\@CPACK_RPM_USER_INSTALL_FILES\@
-
-%changelog
-\@CPACK_RPM_SPEC_CHANGELOG\@
-
-\@TMP_OTHER_COMPONENTS\@
-"
- )
- endif()
-
- # Stop here if we were asked to only generate a template USER spec file
- # The generated file may then be used as a template by user who wants
- # to customize their own spec file.
- if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE)
- message(FATAL_ERROR "CPackRPM: STOP here Generated USER binary spec file template is: ${CPACK_RPM_BINARY_SPECFILE}.in")
- endif()
- endif()
-
- # After that we may either use a user provided spec file
- # or generate one using appropriate variables value.
- if(CPACK_RPM_USER_BINARY_SPECFILE)
- # User may have specified SPECFILE just use it
- message("CPackRPM: Will use USER specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}")
- # The user provided file is processed for @var replacement
- configure_file(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY)
- else()
- # No User specified spec file, will use the generated spec file
- message("CPackRPM: Will use GENERATED spec file: ${CPACK_RPM_BINARY_SPECFILE}")
- # Note the just created file is processed for @var replacement
- configure_file(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY)
- endif()
-
- if(NOT GENERATE_SPEC_PARTS) # generate package
- if(RPMBUILD_EXECUTABLE)
- # Now call rpmbuild using the SPECFILE
- execute_process(
- COMMAND "${RPMBUILD_EXECUTABLE}" ${RPMBUILD_FLAGS}
- --define "_topdir ${CPACK_RPM_DIRECTORY}"
- --buildroot "%_topdir/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
- --target "${CPACK_RPM_PACKAGE_ARCHITECTURE}"
- "${CPACK_RPM_BINARY_SPECFILE}"
- WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
- RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT
- ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err"
- OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out")
- if(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT)
- file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err RPMBUILDERR)
- file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out RPMBUILDOUT)
- message("CPackRPM:Debug: You may consult rpmbuild logs in: ")
- message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err")
- message("CPackRPM:Debug: *** ${RPMBUILDERR} ***")
- message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out")
- message("CPackRPM:Debug: *** ${RPMBUILDOUT} ***")
- endif()
- else()
- if(ALIEN_EXECUTABLE)
- message(FATAL_ERROR "RPM packaging through alien not done (yet)")
- endif()
- endif()
-
- # find generated rpm files and take their names
- cmake_policy(PUSH)
- # Tell file(GLOB_RECURSE) not to follow directory symlinks
- # even if the project does not set this policy to NEW.
- cmake_policy(SET CMP0009 NEW)
- file(GLOB_RECURSE GENERATED_FILES "${CPACK_RPM_DIRECTORY}/RPMS/*.rpm"
- "${CPACK_RPM_DIRECTORY}/SRPMS/*.rpm")
- cmake_policy(POP)
-
- if(NOT GENERATED_FILES)
- message(FATAL_ERROR "RPM package was not generated! ${CPACK_RPM_DIRECTORY}")
- endif()
-
- unset(expected_filenames_)
- unset(filenames_)
- if(CPACK_RPM_DEBUGINFO_PACKAGE AND NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT")
- list(APPEND expected_filenames_
- "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm")
- list(APPEND filenames_ "${CPACK_RPM_FILE_NAME}")
- endif()
-
- if(CPACK_RPM_DEBUGINFO_PACKAGE)
- cpack_rpm_variable_fallback("CPACK_RPM_DEBUGINFO_FILE_NAME"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_DEBUGINFO_FILE_NAME"
- "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEBUGINFO_FILE_NAME"
- "CPACK_RPM_DEBUGINFO_FILE_NAME")
-
- if(CPACK_RPM_DEBUGINFO_FILE_NAME AND
- NOT CPACK_RPM_DEBUGINFO_FILE_NAME STREQUAL "RPM-DEFAULT")
- list(APPEND expected_filenames_
- "${CPACK_RPM_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}.*\\.rpm")
- string(REPLACE "@cpack_component@" "${CPACK_RPM_PACKAGE_COMPONENT}"
- CPACK_RPM_DEBUGINFO_FILE_NAME "${CPACK_RPM_DEBUGINFO_FILE_NAME}")
- list(APPEND filenames_ "${CPACK_RPM_DEBUGINFO_FILE_NAME}")
- endif()
- endif()
-
- # check if other files have to be renamed
- file(GLOB rename_files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.rpm_name")
- if(rename_files_)
- foreach(f_ IN LISTS rename_files_)
- file(READ "${f_}" tmp_)
- list(GET tmp_ 0 efn_)
- list(APPEND expected_filenames_ "${efn_}")
- list(GET tmp_ 1 fn_)
- list(APPEND filenames_ "${fn_}")
- endforeach()
- endif()
-
- if(expected_filenames_)
- foreach(F IN LISTS GENERATED_FILES)
- unset(matched_)
- foreach(expected_ IN LISTS expected_filenames_)
- if(F MATCHES ".*/${expected_}")
- list(FIND expected_filenames_ "${expected_}" idx_)
- list(GET filenames_ ${idx_} filename_)
- get_filename_component(FILE_PATH "${F}" DIRECTORY)
- file(RENAME "${F}" "${FILE_PATH}/${filename_}")
- list(APPEND new_files_list_ "${FILE_PATH}/${filename_}")
- set(matched_ "YES")
-
- break()
- endif()
- endforeach()
-
- if(NOT matched_)
- list(APPEND new_files_list_ "${F}")
- endif()
- endforeach()
-
- set(GENERATED_FILES "${new_files_list_}")
- endif()
- endif()
-
- set(GEN_CPACK_OUTPUT_FILES "${GENERATED_FILES}" PARENT_SCOPE)
-
- if(CPACK_RPM_PACKAGE_DEBUG)
- message("CPackRPM:Debug: GEN_CPACK_OUTPUT_FILES = ${GENERATED_FILES}")
- endif()
-endfunction()
-
-cpack_rpm_generate_package()
diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake
deleted file mode 100644
index 1dc37d415..000000000
--- a/Modules/CPackWIX.cmake
+++ /dev/null
@@ -1,307 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-#.rst:
-# CPackWIX
-# --------
-#
-# CPack WiX generator specific options
-#
-# Variables specific to CPack WiX generator
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# The following variables are specific to the installers built on
-# Windows using WiX.
-#
-# .. variable:: CPACK_WIX_UPGRADE_GUID
-#
-# Upgrade GUID (``Product/@UpgradeCode``)
-#
-# Will be automatically generated unless explicitly provided.
-#
-# It should be explicitly set to a constant generated globally unique
-# identifier (GUID) to allow your installers to replace existing
-# installations that use the same GUID.
-#
-# You may for example explicitly set this variable in your
-# CMakeLists.txt to the value that has been generated per default. You
-# should not use GUIDs that you did not generate yourself or which may
-# belong to other projects.
-#
-# A GUID shall have the following fixed length syntax::
-#
-# XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
-#
-# (each X represents an uppercase hexadecimal digit)
-#
-# .. variable:: CPACK_WIX_PRODUCT_GUID
-#
-# Product GUID (``Product/@Id``)
-#
-# Will be automatically generated unless explicitly provided.
-#
-# If explicitly provided this will set the Product Id of your installer.
-#
-# The installer will abort if it detects a pre-existing installation that
-# uses the same GUID.
-#
-# The GUID shall use the syntax described for CPACK_WIX_UPGRADE_GUID.
-#
-# .. variable:: CPACK_WIX_LICENSE_RTF
-#
-# RTF License File
-#
-# If CPACK_RESOURCE_FILE_LICENSE has an .rtf extension it is used as-is.
-#
-# If CPACK_RESOURCE_FILE_LICENSE has an .txt extension it is implicitly
-# converted to RTF by the WiX Generator.
-# The expected encoding of the .txt file is UTF-8.
-#
-# With CPACK_WIX_LICENSE_RTF you can override the license file used by the
-# WiX Generator in case CPACK_RESOURCE_FILE_LICENSE is in an unsupported
-# format or the .txt -> .rtf conversion does not work as expected.
-#
-# .. variable:: CPACK_WIX_PRODUCT_ICON
-#
-# The Icon shown next to the program name in Add/Remove programs.
-#
-# If set, this icon is used in place of the default icon.
-#
-# .. variable:: CPACK_WIX_UI_REF
-#
-# This variable allows you to override the Id of the ``<UIRef>`` element
-# in the WiX template.
-#
-# The default is ``WixUI_InstallDir`` in case no CPack components have
-# been defined and ``WixUI_FeatureTree`` otherwise.
-#
-# .. variable:: CPACK_WIX_UI_BANNER
-#
-# The bitmap will appear at the top of all installer pages other than the
-# welcome and completion dialogs.
-#
-# If set, this image will replace the default banner image.
-#
-# This image must be 493 by 58 pixels.
-#
-# .. variable:: CPACK_WIX_UI_DIALOG
-#
-# Background bitmap used on the welcome and completion dialogs.
-#
-# If this variable is set, the installer will replace the default dialog
-# image.
-#
-# This image must be 493 by 312 pixels.
-#
-# .. variable:: CPACK_WIX_PROGRAM_MENU_FOLDER
-#
-# Start menu folder name for launcher.
-#
-# If this variable is not set, it will be initialized with CPACK_PACKAGE_NAME
-#
-# .. variable:: CPACK_WIX_CULTURES
-#
-# Language(s) of the installer
-#
-# Languages are compiled into the WixUI extension library. To use them,
-# simply provide the name of the culture. If you specify more than one
-# culture identifier in a comma or semicolon delimited list, the first one
-# that is found will be used. You can find a list of supported languages at:
-# http://wix.sourceforge.net/manual-wix3/WixUI_localization.htm
-#
-# .. variable:: CPACK_WIX_TEMPLATE
-#
-# Template file for WiX generation
-#
-# If this variable is set, the specified template will be used to generate
-# the WiX wxs file. This should be used if further customization of the
-# output is required.
-#
-# If this variable is not set, the default MSI template included with CMake
-# will be used.
-#
-# .. variable:: CPACK_WIX_PATCH_FILE
-#
-# Optional list of XML files with fragments to be inserted into
-# generated WiX sources
-#
-# This optional variable can be used to specify an XML file that the
-# WiX generator will use to inject fragments into its generated
-# source files.
-#
-# Patch files understood by the CPack WiX generator
-# roughly follow this RELAX NG compact schema:
-#
-# .. code-block:: none
-#
-# start = CPackWiXPatch
-#
-# CPackWiXPatch = element CPackWiXPatch { CPackWiXFragment* }
-#
-# CPackWiXFragment = element CPackWiXFragment
-# {
-# attribute Id { string },
-# fragmentContent*
-# }
-#
-# fragmentContent = element * - CPackWiXFragment
-# {
-# (attribute * { text } | text | fragmentContent)*
-# }
-#
-# Currently fragments can be injected into most
-# Component, File, Directory and Feature elements.
-#
-# The following additional special Ids can be used:
-#
-# * ``#PRODUCT`` for the ``<Product>`` element.
-# * ``#PRODUCTFEATURE`` for the root ``<Feature>`` element.
-#
-# The following example illustrates how this works.
-#
-# Given that the WiX generator creates the following XML element:
-#
-# .. code-block:: xml
-#
-# <Component Id="CM_CP_applications.bin.my_libapp.exe" Guid="*"/>
-#
-# The following XML patch file may be used to inject an Environment element
-# into it:
-#
-# .. code-block:: xml
-#
-# <CPackWiXPatch>
-# <CPackWiXFragment Id="CM_CP_applications.bin.my_libapp.exe">
-# <Environment Id="MyEnvironment" Action="set"
-# Name="MyVariableName" Value="MyVariableValue"/>
-# </CPackWiXFragment>
-# </CPackWiXPatch>
-#
-# .. variable:: CPACK_WIX_EXTRA_SOURCES
-#
-# Extra WiX source files
-#
-# This variable provides an optional list of extra WiX source files (.wxs)
-# that should be compiled and linked. The full path to source files is
-# required.
-#
-# .. variable:: CPACK_WIX_EXTRA_OBJECTS
-#
-# Extra WiX object files or libraries
-#
-# This variable provides an optional list of extra WiX object (.wixobj)
-# and/or WiX library (.wixlib) files. The full path to objects and libraries
-# is required.
-#
-# .. variable:: CPACK_WIX_EXTENSIONS
-#
-# This variable provides a list of additional extensions for the WiX
-# tools light and candle.
-#
-# .. variable:: CPACK_WIX_<TOOL>_EXTENSIONS
-#
-# This is the tool specific version of CPACK_WIX_EXTENSIONS.
-# ``<TOOL>`` can be either LIGHT or CANDLE.
-#
-# .. variable:: CPACK_WIX_<TOOL>_EXTRA_FLAGS
-#
-# This list variable allows you to pass additional
-# flags to the WiX tool ``<TOOL>``.
-#
-# Use it at your own risk.
-# Future versions of CPack may generate flags which may be in conflict
-# with your own flags.
-#
-# ``<TOOL>`` can be either LIGHT or CANDLE.
-#
-# .. variable:: CPACK_WIX_CMAKE_PACKAGE_REGISTRY
-#
-# If this variable is set the generated installer will create
-# an entry in the windows registry key
-# ``HKEY_LOCAL_MACHINE\Software\Kitware\CMake\Packages\<package>``
-# The value for ``<package>`` is provided by this variable.
-#
-# Assuming you also install a CMake configuration file this will
-# allow other CMake projects to find your package with
-# the :command:`find_package` command.
-#
-# .. variable:: CPACK_WIX_PROPERTY_<PROPERTY>
-#
-# This variable can be used to provide a value for
-# the Windows Installer property ``<PROPERTY>``
-#
-# The following list contains some example properties that can be used to
-# customize information under
-# "Programs and Features" (also known as "Add or Remove Programs")
-#
-# * ARPCOMMENTS - Comments
-# * ARPHELPLINK - Help and support information URL
-# * ARPURLINFOABOUT - General information URL
-# * ARPURLUPDATEINFO - Update information URL
-# * ARPHELPTELEPHONE - Help and support telephone number
-# * ARPSIZE - Size (in kilobytes) of the application
-#
-# .. variable:: CPACK_WIX_ROOT_FEATURE_TITLE
-#
-# Sets the name of the root install feature in the WIX installer. Same as
-# CPACK_COMPONENT_<compName>_DISPLAY_NAME for components.
-#
-# .. variable:: CPACK_WIX_ROOT_FEATURE_DESCRIPTION
-#
-# Sets the description of the root install feature in the WIX installer. Same as
-# CPACK_COMPONENT_<compName>_DESCRIPTION for components.
-#
-# .. variable:: CPACK_WIX_SKIP_PROGRAM_FOLDER
-#
-# If this variable is set to true, the default install location
-# of the generated package will be CPACK_PACKAGE_INSTALL_DIRECTORY directly.
-# The install location will not be located relatively below
-# ProgramFiles or ProgramFiles64.
-#
-# .. note::
-# Installers created with this feature do not take differences
-# between the system on which the installer is created
-# and the system on which the installer might be used into account.
-#
-# It is therefor possible that the installer e.g. might try to install
-# onto a drive that is unavailable or unintended or a path that does not
-# follow the localization or convention of the system on which the
-# installation is performed.
-#
-# .. variable:: CPACK_WIX_ROOT_FOLDER_ID
-#
-# This variable allows specification of a custom root folder ID.
-# The generator specific ``<64>`` token can be used for
-# folder IDs that come in 32-bit and 64-bit variants.
-# In 32-bit builds the token will expand empty while in 64-bit builds
-# it will expand to ``64``.
-#
-# When unset generated installers will default installing to
-# ``ProgramFiles<64>Folder``.
-#
-# .. variable:: CPACK_WIX_ROOT
-#
-# This variable can optionally be set to the root directory
-# of a custom WiX Toolset installation.
-#
-# When unspecified CPack will try to locate a WiX Toolset
-# installation via the ``WIX`` environment variable instead.
-#
-
-if(NOT CPACK_WIX_ROOT)
- file(TO_CMAKE_PATH "$ENV{WIX}" CPACK_WIX_ROOT)
-endif()
-
-find_program(CPACK_WIX_CANDLE_EXECUTABLE candle
- PATHS "${CPACK_WIX_ROOT}" PATH_SUFFIXES "bin")
-
-if(NOT CPACK_WIX_CANDLE_EXECUTABLE)
- message(FATAL_ERROR "Could not find the WiX candle executable.")
-endif()
-
-find_program(CPACK_WIX_LIGHT_EXECUTABLE light
- PATHS "${CPACK_WIX_ROOT}" PATH_SUFFIXES "bin")
-
-if(NOT CPACK_WIX_LIGHT_EXECUTABLE)
- message(FATAL_ERROR "Could not find the WiX light executable.")
-endif()
diff --git a/Modules/CPackZIP.cmake b/Modules/CPackZIP.cmake
deleted file mode 100644
index 376520c12..000000000
--- a/Modules/CPackZIP.cmake
+++ /dev/null
@@ -1,31 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-
-if(CMAKE_BINARY_DIR)
- message(FATAL_ERROR "CPackZIP.cmake may only be used by CPack internally.")
-endif()
-
-find_program(ZIP_EXECUTABLE wzzip PATHS "$ENV{ProgramFiles}/WinZip")
-if(ZIP_EXECUTABLE)
- set(CPACK_ZIP_COMMAND "\"${ZIP_EXECUTABLE}\" -P \"<ARCHIVE>\" @<FILELIST>")
- set(CPACK_ZIP_NEED_QUOTES TRUE)
-endif()
-
-if(NOT ZIP_EXECUTABLE)
- find_program(ZIP_EXECUTABLE 7z PATHS "$ENV{ProgramFiles}/7-Zip")
- if(ZIP_EXECUTABLE)
- set(CPACK_ZIP_COMMAND "\"${ZIP_EXECUTABLE}\" a -tzip \"<ARCHIVE>\" @<FILELIST>")
- set(CPACK_ZIP_NEED_QUOTES TRUE)
- endif()
-endif()
-
-if(NOT ZIP_EXECUTABLE)
- find_package(Cygwin)
- find_program(ZIP_EXECUTABLE zip PATHS "${CYGWIN_INSTALL_PATH}/bin")
- if(ZIP_EXECUTABLE)
- set(CPACK_ZIP_COMMAND "\"${ZIP_EXECUTABLE}\" -r \"<ARCHIVE>\" . -i@<FILELIST>")
- set(CPACK_ZIP_NEED_QUOTES FALSE)
- endif()
-endif()
-
diff --git a/Modules/CSharpUtilities.cmake b/Modules/CSharpUtilities.cmake
index e9e1510b6..6a4b5c7f7 100644
--- a/Modules/CSharpUtilities.cmake
+++ b/Modules/CSharpUtilities.cmake
@@ -184,6 +184,9 @@ Helper functions which are used by the above ones
#]=======================================================================]
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
function(csharp_get_filename_keys OUT)
set(${OUT} "")
foreach(f ${ARGN})
@@ -304,3 +307,5 @@ function(csharp_set_xaml_cs_properties)
endif()
endforeach()
endfunction()
+
+cmake_policy(POP)
diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake
index 9370596a8..3a111ca92 100644
--- a/Modules/CTest.cmake
+++ b/Modules/CTest.cmake
@@ -27,12 +27,8 @@ to creating tests when testing is enabled.
To enable submissions to a CDash server, create a ``CTestConfig.cmake``
file at the top of the project with content such as::
- set(CTEST_PROJECT_NAME "MyProject")
set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
- set(CTEST_DROP_METHOD "http")
- set(CTEST_DROP_SITE "my.cdash.org")
- set(CTEST_DROP_LOCATION "/submit.php?project=MyProject")
- set(CTEST_DROP_SITE_CDASH TRUE)
+ set(CTEST_SUBMIT_URL "http://my.cdash.org/submit.php?project=MyProject")
(the CDash server can provide the file to a project administrator who
configures ``MyProject``). Settings in the config file are shared by
@@ -54,7 +50,7 @@ in the ``CTestConfig.cmake`` file.
option(BUILD_TESTING "Build the testing tree." ON)
# function to turn generator name into a version string
-# like vs8 vs9
+# like vs9 or vs10
function(GET_VS_VERSION_STRING generator var)
string(REGEX REPLACE "Visual Studio ([0-9][0-9]?)($|.*)" "\\1"
NUMBER "${generator}")
@@ -65,7 +61,7 @@ endfunction()
include(CTestUseLaunchers)
if(BUILD_TESTING)
- # Setup some auxilary macros
+ # Setup some auxiliary macros
macro(SET_IF_NOT_SET var val)
if(NOT DEFINED "${var}")
set("${var}" "${val}")
@@ -90,6 +86,7 @@ if(BUILD_TESTING)
if(EXISTS "${PROJECT_SOURCE_DIR}/CTestConfig.cmake")
include("${PROJECT_SOURCE_DIR}/CTestConfig.cmake")
SET_IF_SET_AND_NOT_SET(NIGHTLY_START_TIME "${CTEST_NIGHTLY_START_TIME}")
+ SET_IF_SET_AND_NOT_SET(SUBMIT_URL "${CTEST_SUBMIT_URL}")
SET_IF_SET_AND_NOT_SET(DROP_METHOD "${CTEST_DROP_METHOD}")
SET_IF_SET_AND_NOT_SET(DROP_SITE "${CTEST_DROP_SITE}")
SET_IF_SET_AND_NOT_SET(DROP_SITE_USER "${CTEST_DROP_SITE_USER}")
@@ -112,6 +109,18 @@ if(BUILD_TESTING)
endif()
SET_IF_NOT_SET (NIGHTLY_START_TIME "00:00:00 EDT")
+ if(NOT SUBMIT_URL)
+ set(SUBMIT_URL "${DROP_METHOD}://")
+ if(DROP_SITE_USER)
+ string(APPEND SUBMIT_URL "${DROP_SITE_USER}")
+ if(DROP_SITE_PASSWORD)
+ string(APPEND SUBMIT_URL ":${DROP_SITE_PASSWORD}")
+ endif()
+ string(APPEND SUBMIT_URL "@")
+ endif()
+ string(APPEND SUBMIT_URL "${DROP_SITE}${DROP_LOCATION}")
+ endif()
+
find_program(CVSCOMMAND cvs )
set(CVS_UPDATE_OPTIONS "-d -A -P" CACHE STRING
"Options passed to the cvs update command.")
@@ -178,9 +187,6 @@ if(BUILD_TESTING)
)
set(MEMORYCHECK_SUPPRESSIONS_FILE "" CACHE FILEPATH
"File that contains suppressions for the memory checker")
- find_program(SCPCOMMAND scp DOC
- "Path to scp command, used by CTest for submitting results to a Dart server"
- )
find_program(COVERAGE_COMMAND gcov DOC
"Path to the coverage program that CTest uses for performing coverage inspection"
)
diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake
index 1203be4c2..ff48cc2dc 100644
--- a/Modules/CTestCoverageCollectGCOV.cmake
+++ b/Modules/CTestCoverageCollectGCOV.cmake
@@ -1,69 +1,70 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CTestCoverageCollectGCOV
-# ------------------------
-#
-# This module provides the ``ctest_coverage_collect_gcov`` function.
-#
-# This function runs gcov on all .gcda files found in the binary tree
-# and packages the resulting .gcov files into a tar file.
-# This tarball also contains the following:
-#
-# * *data.json* defines the source and build directories for use by CDash.
-# * *Labels.json* indicates any :prop_sf:`LABELS` that have been set on the
-# source files.
-# * The *uncovered* directory holds any uncovered files found by
-# :variable:`CTEST_EXTRA_COVERAGE_GLOB`.
-#
-# After generating this tar file, it can be sent to CDash for display with the
-# :command:`ctest_submit(CDASH_UPLOAD)` command.
-#
-# .. command:: cdash_coverage_collect_gcov
-#
-# ::
-#
-# ctest_coverage_collect_gcov(TARBALL <tarfile>
-# [SOURCE <source_dir>][BUILD <build_dir>]
-# [GCOV_COMMAND <gcov_command>]
-# [GCOV_OPTIONS <options>...]
-# )
-#
-# Run gcov and package a tar file for CDash. The options are:
-#
-# ``TARBALL <tarfile>``
-# Specify the location of the ``.tar`` file to be created for later
-# upload to CDash. Relative paths will be interpreted with respect
-# to the top-level build directory.
-#
-# ``SOURCE <source_dir>``
-# Specify the top-level source directory for the build.
-# Default is the value of :variable:`CTEST_SOURCE_DIRECTORY`.
-#
-# ``BUILD <build_dir>``
-# Specify the top-level build directory for the build.
-# Default is the value of :variable:`CTEST_BINARY_DIRECTORY`.
-#
-# ``GCOV_COMMAND <gcov_command>``
-# Specify the full path to the ``gcov`` command on the machine.
-# Default is the value of :variable:`CTEST_COVERAGE_COMMAND`.
-#
-# ``GCOV_OPTIONS <options>...``
-# Specify options to be passed to gcov. The ``gcov`` command
-# is run as ``gcov <options>... -o <gcov-dir> <file>.gcda``.
-# If not specified, the default option is just ``-b``.
-#
-# ``GLOB``
-# Recursively search for .gcda files in build_dir rather than
-# determining search locations by reading TargetDirectories.txt.
-#
-# ``DELETE``
-# Delete coverage files after they've been packaged into the .tar.
-#
-# ``QUIET``
-# Suppress non-error messages that otherwise would have been
-# printed out by this function.
+#[=======================================================================[.rst:
+CTestCoverageCollectGCOV
+------------------------
+
+This module provides the ``ctest_coverage_collect_gcov`` function.
+
+This function runs gcov on all .gcda files found in the binary tree
+and packages the resulting .gcov files into a tar file.
+This tarball also contains the following:
+
+* *data.json* defines the source and build directories for use by CDash.
+* *Labels.json* indicates any :prop_sf:`LABELS` that have been set on the
+ source files.
+* The *uncovered* directory holds any uncovered files found by
+ :variable:`CTEST_EXTRA_COVERAGE_GLOB`.
+
+After generating this tar file, it can be sent to CDash for display with the
+:command:`ctest_submit(CDASH_UPLOAD)` command.
+
+.. command:: ctest_coverage_collect_gcov
+
+ ::
+
+ ctest_coverage_collect_gcov(TARBALL <tarfile>
+ [SOURCE <source_dir>][BUILD <build_dir>]
+ [GCOV_COMMAND <gcov_command>]
+ [GCOV_OPTIONS <options>...]
+ )
+
+ Run gcov and package a tar file for CDash. The options are:
+
+ ``TARBALL <tarfile>``
+ Specify the location of the ``.tar`` file to be created for later
+ upload to CDash. Relative paths will be interpreted with respect
+ to the top-level build directory.
+
+ ``SOURCE <source_dir>``
+ Specify the top-level source directory for the build.
+ Default is the value of :variable:`CTEST_SOURCE_DIRECTORY`.
+
+ ``BUILD <build_dir>``
+ Specify the top-level build directory for the build.
+ Default is the value of :variable:`CTEST_BINARY_DIRECTORY`.
+
+ ``GCOV_COMMAND <gcov_command>``
+ Specify the full path to the ``gcov`` command on the machine.
+ Default is the value of :variable:`CTEST_COVERAGE_COMMAND`.
+
+ ``GCOV_OPTIONS <options>...``
+ Specify options to be passed to gcov. The ``gcov`` command
+ is run as ``gcov <options>... -o <gcov-dir> <file>.gcda``.
+ If not specified, the default option is just ``-b -x``.
+
+ ``GLOB``
+ Recursively search for .gcda files in build_dir rather than
+ determining search locations by reading TargetDirectories.txt.
+
+ ``DELETE``
+ Delete coverage files after they've been packaged into the .tar.
+
+ ``QUIET``
+ Suppress non-error messages that otherwise would have been
+ printed out by this function.
+#]=======================================================================]
function(ctest_coverage_collect_gcov)
set(options QUIET GLOB DELETE)
@@ -94,7 +95,7 @@ function(ctest_coverage_collect_gcov)
set(gcda_files)
set(label_files)
if (GCOV_GLOB)
- file(GLOB_RECURSE gfiles RELATIVE ${binary_dir} "${binary_dir}/*.gcda")
+ file(GLOB_RECURSE gfiles "${binary_dir}/*.gcda")
list(LENGTH gfiles len)
# if we have gcda files then also grab the labels file for that target
if(${len} GREATER 0)
@@ -108,7 +109,7 @@ function(ctest_coverage_collect_gcov)
file(STRINGS "${binary_dir}/CMakeFiles/TargetDirectories.txt" target_dirs
ENCODING UTF-8)
foreach(target_dir ${target_dirs})
- file(GLOB_RECURSE gfiles RELATIVE ${binary_dir} "${target_dir}/*.gcda")
+ file(GLOB_RECURSE gfiles "${target_dir}/*.gcda")
list(LENGTH gfiles len)
# if we have gcda files then also grab the labels file for that target
if(${len} GREATER 0)
@@ -131,27 +132,21 @@ function(ctest_coverage_collect_gcov)
# setup the dir for the coverage files
set(coverage_dir "${binary_dir}/Testing/CoverageInfo")
file(MAKE_DIRECTORY "${coverage_dir}")
- # call gcov on each .gcda file
- foreach (gcda_file ${gcda_files})
- # get the directory of the gcda file
- get_filename_component(gcda_file ${binary_dir}/${gcda_file} ABSOLUTE)
- get_filename_component(gcov_dir ${gcda_file} DIRECTORY)
- # run gcov, this will produce the .gcov file in the current
- # working directory
- if(NOT DEFINED GCOV_GCOV_OPTIONS)
- set(GCOV_GCOV_OPTIONS -b)
- endif()
- execute_process(COMMAND
- ${gcov_command} ${GCOV_GCOV_OPTIONS} -o ${gcov_dir} ${gcda_file}
- OUTPUT_VARIABLE out
- RESULT_VARIABLE res
- WORKING_DIRECTORY ${coverage_dir})
-
- if (GCOV_DELETE)
- file(REMOVE ${gcda_file})
- endif()
+ # run gcov, this will produce the .gcov files in the current
+ # working directory
+ if(NOT DEFINED GCOV_GCOV_OPTIONS)
+ set(GCOV_GCOV_OPTIONS -b -x)
+ endif()
+ execute_process(COMMAND
+ ${gcov_command} ${GCOV_GCOV_OPTIONS} ${gcda_files}
+ OUTPUT_VARIABLE out
+ RESULT_VARIABLE res
+ WORKING_DIRECTORY ${coverage_dir})
+
+ if (GCOV_DELETE)
+ file(REMOVE ${gcda_files})
+ endif()
- endforeach()
if(NOT "${res}" EQUAL 0)
if (NOT GCOV_QUIET)
message(STATUS "Error running gcov: ${res} ${out}")
diff --git a/Modules/CTestScriptMode.cmake b/Modules/CTestScriptMode.cmake
index 5be78d5a3..7af3577e0 100644
--- a/Modules/CTestScriptMode.cmake
+++ b/Modules/CTestScriptMode.cmake
@@ -1,13 +1,14 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CTestScriptMode
-# ---------------
-#
-#
-#
-# This file is read by ctest in script mode (-S)
+#[=======================================================================[.rst:
+CTestScriptMode
+---------------
+
+
+
+This file is read by ctest in script mode (-S)
+#]=======================================================================]
# Determine the current system, so this information can be used
# in ctest scripts
diff --git a/Modules/CTestTargets.cmake b/Modules/CTestTargets.cmake
index ff9aada54..838fbbfeb 100644
--- a/Modules/CTestTargets.cmake
+++ b/Modules/CTestTargets.cmake
@@ -3,7 +3,7 @@
if(NOT RUN_FROM_CTEST_OR_DART)
- message(FATAL_ERROR "Do not incldue CTestTargets.cmake directly")
+ message(FATAL_ERROR "Do not include CTestTargets.cmake directly")
endif()
if(NOT PROJECT_BINARY_DIR)
@@ -38,7 +38,8 @@ endif()
#
set(__conf_types "")
-if(CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
# We need to pass the configuration type on the test command line.
set(__conf_types -C "${CMAKE_CFG_INTDIR}")
endif()
diff --git a/Modules/CTestUseLaunchers.cmake b/Modules/CTestUseLaunchers.cmake
index dc90513a9..3dff92605 100644
--- a/Modules/CTestUseLaunchers.cmake
+++ b/Modules/CTestUseLaunchers.cmake
@@ -1,32 +1,33 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CTestUseLaunchers
-# -----------------
-#
-# Set the RULE_LAUNCH_* global properties when CTEST_USE_LAUNCHERS is on.
-#
-# CTestUseLaunchers is automatically included when you include(CTest).
-# However, it is split out into its own module file so projects can use
-# the CTEST_USE_LAUNCHERS functionality independently.
-#
-# To use launchers, set CTEST_USE_LAUNCHERS to ON in a ctest -S
-# dashboard script, and then also set it in the cache of the configured
-# project. Both cmake and ctest need to know the value of it for the
-# launchers to work properly. CMake needs to know in order to generate
-# proper build rules, and ctest, in order to produce the proper error
-# and warning analysis.
-#
-# For convenience, you may set the ENV variable
-# CTEST_USE_LAUNCHERS_DEFAULT in your ctest -S script, too. Then, as
-# long as your CMakeLists uses include(CTest) or
-# include(CTestUseLaunchers), it will use the value of the ENV variable
-# to initialize a CTEST_USE_LAUNCHERS cache variable. This cache
-# variable initialization only occurs if CTEST_USE_LAUNCHERS is not
-# already defined. If CTEST_USE_LAUNCHERS is on in a ctest -S script
-# the ctest_configure command will add -DCTEST_USE_LAUNCHERS:BOOL=TRUE
-# to the cmake command used to configure the project.
+#[=======================================================================[.rst:
+CTestUseLaunchers
+-----------------
+
+Set the RULE_LAUNCH_* global properties when CTEST_USE_LAUNCHERS is on.
+
+CTestUseLaunchers is automatically included when you include(CTest).
+However, it is split out into its own module file so projects can use
+the CTEST_USE_LAUNCHERS functionality independently.
+
+To use launchers, set CTEST_USE_LAUNCHERS to ON in a ctest -S
+dashboard script, and then also set it in the cache of the configured
+project. Both cmake and ctest need to know the value of it for the
+launchers to work properly. CMake needs to know in order to generate
+proper build rules, and ctest, in order to produce the proper error
+and warning analysis.
+
+For convenience, you may set the ENV variable
+CTEST_USE_LAUNCHERS_DEFAULT in your ctest -S script, too. Then, as
+long as your CMakeLists uses include(CTest) or
+include(CTestUseLaunchers), it will use the value of the ENV variable
+to initialize a CTEST_USE_LAUNCHERS cache variable. This cache
+variable initialization only occurs if CTEST_USE_LAUNCHERS is not
+already defined. If CTEST_USE_LAUNCHERS is on in a ctest -S script
+the ctest_configure command will add -DCTEST_USE_LAUNCHERS:BOOL=TRUE
+to the cmake command used to configure the project.
+#]=======================================================================]
if(NOT DEFINED CTEST_USE_LAUNCHERS AND DEFINED ENV{CTEST_USE_LAUNCHERS_DEFAULT})
set(CTEST_USE_LAUNCHERS "$ENV{CTEST_USE_LAUNCHERS_DEFAULT}"
diff --git a/Modules/CheckCCompilerFlag.cmake b/Modules/CheckCCompilerFlag.cmake
index 1ba67fca3..a3e2da368 100644
--- a/Modules/CheckCCompilerFlag.cmake
+++ b/Modules/CheckCCompilerFlag.cmake
@@ -1,52 +1,63 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckCCompilerFlag
-# ------------------
-#
-# Check whether the C compiler supports a given flag.
-#
-# CHECK_C_COMPILER_FLAG(<flag> <var>)
-#
-# ::
-#
-# <flag> - the compiler flag
-# <var> - variable to store the result
-# Will be created as an internal cache variable.
-#
-# This internally calls the check_c_source_compiles macro and sets
-# CMAKE_REQUIRED_DEFINITIONS to <flag>. See help for
-# CheckCSourceCompiles for a listing of variables that can otherwise
-# modify the build. The result only tells that the compiler does not
-# give an error message when it encounters the flag. If the flag has
-# any effect or even a specific one is beyond the scope of this module.
+#[=======================================================================[.rst:
+CheckCCompilerFlag
+------------------
+Check whether the C compiler supports a given flag.
+
+.. command:: check_c_compiler_flag
+
+ .. code-block:: cmake
+
+ check_c_compiler_flag(<flag> <var>)
+
+ Check that the ``<flag>`` is accepted by the compiler without
+ a diagnostic. Stores the result in an internal cache entry
+ named ``<var>``.
+
+This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable
+and calls the ``check_c_source_compiles`` macro from the
+:module:`CheckCSourceCompiles` module. See documentation of that
+module for a listing of variables that can otherwise modify the build.
+
+A positive result from this check indicates only that the compiler did not
+issue a diagnostic message when given the flag. Whether the flag has any
+effect or even a specific one is beyond the scope of this module.
+
+.. note::
+ Since the :command:`try_compile` command forwards flags from variables
+ like :variable:`CMAKE_C_FLAGS <CMAKE_<LANG>_FLAGS>`, unknown flags
+ in such variables may cause a false negative for this check.
+#]=======================================================================]
+
+include_guard(GLOBAL)
include(CheckCSourceCompiles)
include(CMakeCheckCompilerFlagCommonPatterns)
macro (CHECK_C_COMPILER_FLAG _FLAG _RESULT)
- set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
- set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
+ set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
+ set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
# Normalize locale during test compilation.
- set(_CheckCCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG)
- foreach(v ${_CheckCCompilerFlag_LOCALE_VARS})
- set(_CheckCCompilerFlag_SAVED_${v} "$ENV{${v}}")
- set(ENV{${v}} C)
- endforeach()
- CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCCompilerFlag_COMMON_PATTERNS)
- CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${_RESULT}
- # Some compilers do not fail with a bad flag
- FAIL_REGEX "command line option .* is valid for .* but not for C" # GNU
- ${_CheckCCompilerFlag_COMMON_PATTERNS}
- )
- foreach(v ${_CheckCCompilerFlag_LOCALE_VARS})
- set(ENV{${v}} ${_CheckCCompilerFlag_SAVED_${v}})
- unset(_CheckCCompilerFlag_SAVED_${v})
- endforeach()
- unset(_CheckCCompilerFlag_LOCALE_VARS)
- unset(_CheckCCompilerFlag_COMMON_PATTERNS)
-
- set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
+ set(_CheckCCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG)
+ foreach(v ${_CheckCCompilerFlag_LOCALE_VARS})
+ set(_CheckCCompilerFlag_SAVED_${v} "$ENV{${v}}")
+ set(ENV{${v}} C)
+ endforeach()
+ CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCCompilerFlag_COMMON_PATTERNS)
+ CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${_RESULT}
+ # Some compilers do not fail with a bad flag
+ FAIL_REGEX "command line option .* is valid for .* but not for C" # GNU
+ ${_CheckCCompilerFlag_COMMON_PATTERNS}
+ )
+ foreach(v ${_CheckCCompilerFlag_LOCALE_VARS})
+ set(ENV{${v}} ${_CheckCCompilerFlag_SAVED_${v}})
+ unset(_CheckCCompilerFlag_SAVED_${v})
+ endforeach()
+ unset(_CheckCCompilerFlag_LOCALE_VARS)
+ unset(_CheckCCompilerFlag_COMMON_PATTERNS)
+
+ set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
endmacro ()
diff --git a/Modules/CheckCSourceCompiles.cmake b/Modules/CheckCSourceCompiles.cmake
index ac2c6c583..77ba0cc46 100644
--- a/Modules/CheckCSourceCompiles.cmake
+++ b/Modules/CheckCSourceCompiles.cmake
@@ -1,31 +1,71 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckCSourceCompiles
-# --------------------
-#
-# Check if given C source compiles and links into an executable
-#
-# CHECK_C_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>])
-#
-# ::
-#
-# <code> - source code to try to compile, must define 'main'
-# <var> - variable to store whether the source code compiled
-# Will be created as an internal cache variable.
-# <fail-regex> - fail if test output matches this regex
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ::
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-# CMAKE_REQUIRED_QUIET = execute quietly without messages
+#[=======================================================================[.rst:
+CheckCSourceCompiles
+--------------------
+
+Check if given C source compiles and links into an executable.
+
+.. command:: check_c_source_compiles
+
+ .. code-block:: cmake
+
+ check_c_source_compiles(<code> <resultVar>
+ [FAIL_REGEX <regex1> [<regex2>...]])
+
+ Check that the source supplied in ``<code>`` can be compiled as a C source
+ file and linked as an executable (so it must contain at least a ``main()``
+ function). The result will be stored in the internal cache variable specified
+ by ``<resultVar>``, with a boolean true value for success and boolean false
+ for failure. If ``FAIL_REGEX`` is provided, then failure is determined by
+ checking if anything in the output matches any of the specified regular
+ expressions.
+
+ The underlying check is performed by the :command:`try_compile` command. The
+ compile and link commands can be influenced by setting any of the following
+ variables prior to calling ``check_c_source_compiles()``:
+
+ ``CMAKE_REQUIRED_FLAGS``
+ Additional flags to pass to the compiler. Note that the contents of
+ :variable:`CMAKE_C_FLAGS <CMAKE_<LANG>_FLAGS>` and its associated
+ configuration-specific variable are automatically added to the compiler
+ command before the contents of ``CMAKE_REQUIRED_FLAGS``.
+
+ ``CMAKE_REQUIRED_DEFINITIONS``
+ A :ref:`;-list <CMake Language Lists>` of compiler definitions of the form
+ ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by
+ ``<resultVar>`` will also be added automatically.
+
+ ``CMAKE_REQUIRED_INCLUDES``
+ A :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler. These will be the only header search paths used by
+ ``try_compile()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES`
+ directory property will be ignored.
+
+ ``CMAKE_REQUIRED_LINK_OPTIONS``
+ A :ref:`;-list <CMake Language Lists>` of options to add to the link
+ command (see :command:`try_compile` for further details).
+
+ ``CMAKE_REQUIRED_LIBRARIES``
+ A :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. These can be the name of system libraries or they can be
+ :ref:`Imported Targets <Imported Targets>` (see :command:`try_compile` for
+ further details).
+
+ ``CMAKE_REQUIRED_QUIET``
+ If this variable evaluates to a boolean true value, all status messages
+ associated with the check will be suppressed.
+
+ The check is only performed once, with the result cached in the variable
+ named by ``<resultVar>``. Every subsequent CMake run will re-use this cached
+ value rather than performing the check again, even if the ``<code>`` changes.
+ In order to force the check to be re-evaluated, the variable named by
+ ``<resultVar>`` must be manually removed from the cache.
+
+#]=======================================================================]
+
+include_guard(GLOBAL)
macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
if(NOT DEFINED "${VAR}")
@@ -42,6 +82,12 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
endforeach()
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_C_SOURCE_COMPILES_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_C_SOURCE_COMPILES_ADD_LINK_OPTIONS)
+ endif()
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -64,6 +110,7 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_C_SOURCE_COMPILES_ADD_LINK_OPTIONS}
${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
"${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
@@ -96,4 +143,3 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
endif()
endif()
endmacro()
-
diff --git a/Modules/CheckCSourceRuns.cmake b/Modules/CheckCSourceRuns.cmake
index 70aa9fd2d..eba70f2ba 100644
--- a/Modules/CheckCSourceRuns.cmake
+++ b/Modules/CheckCSourceRuns.cmake
@@ -1,36 +1,81 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckCSourceRuns
-# ----------------
-#
-# Check if the given C source code compiles and runs.
-#
-# CHECK_C_SOURCE_RUNS(<code> <var>)
-#
-# ::
-#
-# <code> - source code to try to compile
-# <var> - variable to store the result
-# (1 for success, empty for failure)
-# Will be created as an internal cache variable.
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ::
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-# CMAKE_REQUIRED_QUIET = execute quietly without messages
+#[=======================================================================[.rst:
+CheckCSourceRuns
+----------------
+
+Check if given C source compiles and links into an executable and can
+subsequently be run.
+
+.. command:: check_c_source_runs
+
+ .. code-block:: cmake
+
+ check_c_source_runs(<code> <resultVar>)
+
+ Check that the source supplied in ``<code>`` can be compiled as a C source
+ file, linked as an executable and then run. The ``<code>`` must contain at
+ least a ``main()`` function. If the ``<code>`` could be built and run
+ successfully, the internal cache variable specified by ``<resultVar>`` will
+ be set to 1, otherwise it will be set to an value that evaluates to boolean
+ false (e.g. an empty string or an error message).
+
+ The underlying check is performed by the :command:`try_run` command. The
+ compile and link commands can be influenced by setting any of the following
+ variables prior to calling ``check_c_source_runs()``:
+
+ ``CMAKE_REQUIRED_FLAGS``
+ Additional flags to pass to the compiler. Note that the contents of
+ :variable:`CMAKE_C_FLAGS <CMAKE_<LANG>_FLAGS>` and its associated
+ configuration-specific variable are automatically added to the compiler
+ command before the contents of ``CMAKE_REQUIRED_FLAGS``.
+
+ ``CMAKE_REQUIRED_DEFINITIONS``
+ A :ref:`;-list <CMake Language Lists>` of compiler definitions of the form
+ ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by
+ ``<resultVar>`` will also be added automatically.
+
+ ``CMAKE_REQUIRED_INCLUDES``
+ A :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler. These will be the only header search paths used by
+ ``try_run()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES`
+ directory property will be ignored.
+
+ ``CMAKE_REQUIRED_LINK_OPTIONS``
+ A :ref:`;-list <CMake Language Lists>` of options to add to the link
+ command (see :command:`try_run` for further details).
+
+ ``CMAKE_REQUIRED_LIBRARIES``
+ A :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. These can be the name of system libraries or they can be
+ :ref:`Imported Targets <Imported Targets>` (see :command:`try_run` for
+ further details).
+
+ ``CMAKE_REQUIRED_QUIET``
+ If this variable evaluates to a boolean true value, all status messages
+ associated with the check will be suppressed.
+
+ The check is only performed once, with the result cached in the variable
+ named by ``<resultVar>``. Every subsequent CMake run will re-use this cached
+ value rather than performing the check again, even if the ``<code>`` changes.
+ In order to force the check to be re-evaluated, the variable named by
+ ``<resultVar>`` must be manually removed from the cache.
+
+#]=======================================================================]
+
+include_guard(GLOBAL)
macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
if(NOT DEFINED "${VAR}")
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_C_SOURCE_COMPILES_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_C_SOURCE_COMPILES_ADD_LINK_OPTIONS)
+ endif()
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -53,11 +98,13 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_C_SOURCE_COMPILES_ADD_LINK_OPTIONS}
${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
-DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
"${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
- COMPILE_OUTPUT_VARIABLE OUTPUT)
+ COMPILE_OUTPUT_VARIABLE OUTPUT
+ RUN_OUTPUT_VARIABLE RUN_OUTPUT)
# if it did not compile make the return value fail code of 1
if(NOT ${VAR}_COMPILED)
set(${VAR}_EXITCODE 1)
@@ -69,8 +116,10 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
message(STATUS "Performing Test ${VAR} - Success")
endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
- "Performing C SOURCE FILE Test ${VAR} succeeded with the following output:\n"
+ "Performing C SOURCE FILE Test ${VAR} succeeded with the following compile output:\n"
"${OUTPUT}\n"
+ "...and run output:\n"
+ "${RUN_OUTPUT}\n"
"Return value: ${${VAR}}\n"
"Source file was:\n${SOURCE}\n")
else()
@@ -84,12 +133,13 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
message(STATUS "Performing Test ${VAR} - Failed")
endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
+ "Performing C SOURCE FILE Test ${VAR} failed with the following compile output:\n"
"${OUTPUT}\n"
+ "...and run output:\n"
+ "${RUN_OUTPUT}\n"
"Return value: ${${VAR}_EXITCODE}\n"
"Source file was:\n${SOURCE}\n")
endif()
endif()
endmacro()
-
diff --git a/Modules/CheckCXXCompilerFlag.cmake b/Modules/CheckCXXCompilerFlag.cmake
index afbb23128..5729843c3 100644
--- a/Modules/CheckCXXCompilerFlag.cmake
+++ b/Modules/CheckCXXCompilerFlag.cmake
@@ -1,52 +1,63 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckCXXCompilerFlag
-# --------------------
-#
-# Check whether the CXX compiler supports a given flag.
-#
-# CHECK_CXX_COMPILER_FLAG(<flag> <var>)
-#
-# ::
-#
-# <flag> - the compiler flag
-# <var> - variable to store the result
-#
-# This internally calls the check_cxx_source_compiles macro and sets
-# CMAKE_REQUIRED_DEFINITIONS to <flag>. See help for
-# CheckCXXSourceCompiles for a listing of variables that can otherwise
-# modify the build. The result only tells that the compiler does not
-# give an error message when it encounters the flag. If the flag has
-# any effect or even a specific one is beyond the scope of this module.
+#[=======================================================================[.rst:
+CheckCXXCompilerFlag
+------------------------
+Check whether the CXX compiler supports a given flag.
+
+.. command:: check_cxx_compiler_flag
+
+ .. code-block:: cmake
+
+ check_cxx_compiler_flag(<flag> <var>)
+
+ Check that the ``<flag>`` is accepted by the compiler without
+ a diagnostic. Stores the result in an internal cache entry
+ named ``<var>``.
+
+This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable
+and calls the ``check_cxx_source_compiles`` macro from the
+:module:`CheckCXXSourceCompiles` module. See documentation of that
+module for a listing of variables that can otherwise modify the build.
+
+A positive result from this check indicates only that the compiler did not
+issue a diagnostic message when given the flag. Whether the flag has any
+effect or even a specific one is beyond the scope of this module.
+
+.. note::
+ Since the :command:`try_compile` command forwards flags from variables
+ like :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>`, unknown flags
+ in such variables may cause a false negative for this check.
+#]=======================================================================]
+
+include_guard(GLOBAL)
include(CheckCXXSourceCompiles)
include(CMakeCheckCompilerFlagCommonPatterns)
macro (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)
- set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
- set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
-
- # Normalize locale during test compilation.
- set(_CheckCXXCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG)
- foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS})
- set(_CheckCXXCompilerFlag_SAVED_${v} "$ENV{${v}}")
- set(ENV{${v}} C)
- endforeach()
- CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCXXCompilerFlag_COMMON_PATTERNS)
- CHECK_CXX_SOURCE_COMPILES("int main() { return 0; }" ${_RESULT}
- # Some compilers do not fail with a bad flag
- FAIL_REGEX "command line option .* is valid for .* but not for C\\\\+\\\\+" # GNU
- ${_CheckCXXCompilerFlag_COMMON_PATTERNS}
- )
- foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS})
- set(ENV{${v}} ${_CheckCXXCompilerFlag_SAVED_${v}})
- unset(_CheckCXXCompilerFlag_SAVED_${v})
- endforeach()
- unset(_CheckCXXCompilerFlag_LOCALE_VARS)
- unset(_CheckCXXCompilerFlag_COMMON_PATTERNS)
-
- set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
-endmacro ()
+ set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
+ set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
+ # Normalize locale during test compilation.
+ set(_CheckCXXCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG)
+ foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS})
+ set(_CheckCXXCompilerFlag_SAVED_${v} "$ENV{${v}}")
+ set(ENV{${v}} C)
+ endforeach()
+ CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCXXCompilerFlag_COMMON_PATTERNS)
+ CHECK_CXX_SOURCE_COMPILES("int main() { return 0; }" ${_RESULT}
+ # Some compilers do not fail with a bad flag
+ FAIL_REGEX "command line option .* is valid for .* but not for C\\\\+\\\\+" # GNU
+ ${_CheckCXXCompilerFlag_COMMON_PATTERNS}
+ )
+ foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS})
+ set(ENV{${v}} ${_CheckCXXCompilerFlag_SAVED_${v}})
+ unset(_CheckCXXCompilerFlag_SAVED_${v})
+ endforeach()
+ unset(_CheckCXXCompilerFlag_LOCALE_VARS)
+ unset(_CheckCXXCompilerFlag_COMMON_PATTERNS)
+
+ set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
+endmacro ()
diff --git a/Modules/CheckCXXSourceCompiles.cmake b/Modules/CheckCXXSourceCompiles.cmake
index e54d09e61..cc457a565 100644
--- a/Modules/CheckCXXSourceCompiles.cmake
+++ b/Modules/CheckCXXSourceCompiles.cmake
@@ -1,31 +1,71 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckCXXSourceCompiles
-# ----------------------
-#
-# Check if given C++ source compiles and links into an executable
-#
-# CHECK_CXX_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>])
-#
-# ::
-#
-# <code> - source code to try to compile, must define 'main'
-# <var> - variable to store whether the source code compiled
-# Will be created as an internal cache variable.
-# <fail-regex> - fail if test output matches this regex
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ::
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-# CMAKE_REQUIRED_QUIET = execute quietly without messages
+#[=======================================================================[.rst:
+CheckCXXSourceCompiles
+----------------------
+
+Check if given C++ source compiles and links into an executable.
+
+.. command:: check_cxx_source_compiles
+
+ .. code-block:: cmake
+
+ check_cxx_source_compiles(<code> <resultVar>
+ [FAIL_REGEX <regex1> [<regex2>...]])
+
+ Check that the source supplied in ``<code>`` can be compiled as a C++ source
+ file and linked as an executable (so it must contain at least a ``main()``
+ function). The result will be stored in the internal cache variable specified
+ by ``<resultVar>``, with a boolean true value for success and boolean false
+ for failure. If ``FAIL_REGEX`` is provided, then failure is determined by
+ checking if anything in the output matches any of the specified regular
+ expressions.
+
+ The underlying check is performed by the :command:`try_compile` command. The
+ compile and link commands can be influenced by setting any of the following
+ variables prior to calling ``check_cxx_source_compiles()``:
+
+ ``CMAKE_REQUIRED_FLAGS``
+ Additional flags to pass to the compiler. Note that the contents of
+ :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` and its associated
+ configuration-specific variable are automatically added to the compiler
+ command before the contents of ``CMAKE_REQUIRED_FLAGS``.
+
+ ``CMAKE_REQUIRED_DEFINITIONS``
+ A :ref:`;-list <CMake Language Lists>` of compiler definitions of the form
+ ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by
+ ``<resultVar>`` will also be added automatically.
+
+ ``CMAKE_REQUIRED_INCLUDES``
+ A :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler. These will be the only header search paths used by
+ ``try_compile()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES`
+ directory property will be ignored.
+
+ ``CMAKE_REQUIRED_LINK_OPTIONS``
+ A :ref:`;-list <CMake Language Lists>` of options to add to the link
+ command (see :command:`try_compile` for further details).
+
+ ``CMAKE_REQUIRED_LIBRARIES``
+ A :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. These can be the name of system libraries or they can be
+ :ref:`Imported Targets <Imported Targets>` (see :command:`try_compile` for
+ further details).
+
+ ``CMAKE_REQUIRED_QUIET``
+ If this variable evaluates to a boolean true value, all status messages
+ associated with the check will be suppressed.
+
+ The check is only performed once, with the result cached in the variable
+ named by ``<resultVar>``. Every subsequent CMake run will re-use this cached
+ value rather than performing the check again, even if the ``<code>`` changes.
+ In order to force the check to be re-evaluated, the variable named by
+ ``<resultVar>`` must be manually removed from the cache.
+
+#]=======================================================================]
+
+include_guard(GLOBAL)
macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
if(NOT DEFINED "${VAR}")
@@ -43,6 +83,12 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_CXX_SOURCE_COMPILES_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_CXX_SOURCE_COMPILES_ADD_LINK_OPTIONS)
+ endif()
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -65,6 +111,7 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_CXX_SOURCE_COMPILES_ADD_LINK_OPTIONS}
${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
"${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}"
@@ -97,4 +144,3 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
endif()
endif()
endmacro()
-
diff --git a/Modules/CheckCXXSourceRuns.cmake b/Modules/CheckCXXSourceRuns.cmake
index e08365950..5e3f19581 100644
--- a/Modules/CheckCXXSourceRuns.cmake
+++ b/Modules/CheckCXXSourceRuns.cmake
@@ -1,36 +1,81 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckCXXSourceRuns
-# ------------------
-#
-# Check if the given C++ source code compiles and runs.
-#
-# CHECK_CXX_SOURCE_RUNS(<code> <var>)
-#
-# ::
-#
-# <code> - source code to try to compile
-# <var> - variable to store the result
-# (1 for success, empty for failure)
-# Will be created as an internal cache variable.
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ::
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-# CMAKE_REQUIRED_QUIET = execute quietly without messages
+#[=======================================================================[.rst:
+CheckCXXSourceRuns
+------------------
+
+Check if given C++ source compiles and links into an executable and can
+subsequently be run.
+
+.. command:: check_cxx_source_runs
+
+ .. code-block:: cmake
+
+ check_cxx_source_runs(<code> <resultVar>)
+
+ Check that the source supplied in ``<code>`` can be compiled as a C++ source
+ file, linked as an executable and then run. The ``<code>`` must contain at
+ least a ``main()`` function. If the ``<code>`` could be built and run
+ successfully, the internal cache variable specified by ``<resultVar>`` will
+ be set to 1, otherwise it will be set to an value that evaluates to boolean
+ false (e.g. an empty string or an error message).
+
+ The underlying check is performed by the :command:`try_run` command. The
+ compile and link commands can be influenced by setting any of the following
+ variables prior to calling ``check_cxx_source_runs()``:
+
+ ``CMAKE_REQUIRED_FLAGS``
+ Additional flags to pass to the compiler. Note that the contents of
+ :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` and its associated
+ configuration-specific variable are automatically added to the compiler
+ command before the contents of ``CMAKE_REQUIRED_FLAGS``.
+
+ ``CMAKE_REQUIRED_DEFINITIONS``
+ A :ref:`;-list <CMake Language Lists>` of compiler definitions of the form
+ ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by
+ ``<resultVar>`` will also be added automatically.
+
+ ``CMAKE_REQUIRED_INCLUDES``
+ A :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler. These will be the only header search paths used by
+ ``try_run()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES`
+ directory property will be ignored.
+
+ ``CMAKE_REQUIRED_LINK_OPTIONS``
+ A :ref:`;-list <CMake Language Lists>` of options to add to the link
+ command (see :command:`try_run` for further details).
+
+ ``CMAKE_REQUIRED_LIBRARIES``
+ A :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. These can be the name of system libraries or they can be
+ :ref:`Imported Targets <Imported Targets>` (see :command:`try_run` for
+ further details).
+
+ ``CMAKE_REQUIRED_QUIET``
+ If this variable evaluates to a boolean true value, all status messages
+ associated with the check will be suppressed.
+
+ The check is only performed once, with the result cached in the variable
+ named by ``<resultVar>``. Every subsequent CMake run will re-use this cached
+ value rather than performing the check again, even if the ``<code>`` changes.
+ In order to force the check to be re-evaluated, the variable named by
+ ``<resultVar>`` must be manually removed from the cache.
+
+#]=======================================================================]
+
+include_guard(GLOBAL)
macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
if(NOT DEFINED "${VAR}")
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_CXX_SOURCE_COMPILES_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_CXX_SOURCE_COMPILES_ADD_LINK_OPTIONS)
+ endif()
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -53,11 +98,13 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_CXX_SOURCE_COMPILES_ADD_LINK_OPTIONS}
${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
-DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
"${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}"
- COMPILE_OUTPUT_VARIABLE OUTPUT)
+ COMPILE_OUTPUT_VARIABLE OUTPUT
+ RUN_OUTPUT_VARIABLE RUN_OUTPUT)
# if it did not compile make the return value fail code of 1
if(NOT ${VAR}_COMPILED)
@@ -72,6 +119,8 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Performing C++ SOURCE FILE Test ${VAR} succeeded with the following output:\n"
"${OUTPUT}\n"
+ "...and run output:\n"
+ "${RUN_OUTPUT}\n"
"Return value: ${${VAR}}\n"
"Source file was:\n${SOURCE}\n")
else()
@@ -87,9 +136,10 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n"
"${OUTPUT}\n"
+ "...and run output:\n"
+ "${RUN_OUTPUT}\n"
"Return value: ${${VAR}_EXITCODE}\n"
"Source file was:\n${SOURCE}\n")
endif()
endif()
endmacro()
-
diff --git a/Modules/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake
index 354eea3d2..5c9079dbf 100644
--- a/Modules/CheckCXXSymbolExists.cmake
+++ b/Modules/CheckCXXSymbolExists.cmake
@@ -1,39 +1,76 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckCXXSymbolExists
-# --------------------
-#
-# Check if a symbol exists as a function, variable, or macro in C++
-#
-# CHECK_CXX_SYMBOL_EXISTS(<symbol> <files> <variable>)
-#
-# Check that the <symbol> is available after including given header
-# <files> and store the result in a <variable>. Specify the list of
-# files in one argument as a semicolon-separated list.
-# CHECK_CXX_SYMBOL_EXISTS() can be used to check in C++ files, as
-# opposed to CHECK_SYMBOL_EXISTS(), which works only for C.
-#
-# If the header files define the symbol as a macro it is considered
-# available and assumed to work. If the header files declare the symbol
-# as a function or variable then the symbol must also be available for
-# linking. If the symbol is a type or enum value it will not be
-# recognized (consider using CheckTypeSize or CheckCSourceCompiles).
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ::
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-# CMAKE_REQUIRED_QUIET = execute quietly without messages
+#[=======================================================================[.rst:
+CheckCXXSymbolExists
+--------------------
+Check if a symbol exists as a function, variable, or macro in ``C++``.
+
+.. command:: check_cxx_symbol_exists
+
+ .. code-block:: cmake
+
+ check_cxx_symbol_exists(<symbol> <files> <variable>)
+
+ Check that the ``<symbol>`` is available after including given header
+ ``<files>`` and store the result in a ``<variable>``. Specify the list of
+ files in one argument as a semicolon-separated list.
+ ``check_cxx_symbol_exists()`` can be used to check for symbols as seen by
+ the C++ compiler, as opposed to :command:`check_symbol_exists`, which always
+ uses the ``C`` compiler.
+
+ If the header files define the symbol as a macro it is considered
+ available and assumed to work. If the header files declare the symbol
+ as a function or variable then the symbol must also be available for
+ linking. If the symbol is a type, enum value, or C++ template it will
+ not be recognized: consider using the :module:`CheckTypeSize`
+ or :module:`CheckCXXSourceCompiles` module instead.
+
+.. note::
+
+ This command is unreliable when ``<symbol>`` is (potentially) an overloaded
+ function. Since there is no reliable way to predict whether a given function
+ in the system environment may be defined as an overloaded function or may be
+ an overloaded function on other systems or will become so in the future, it
+ is generally advised to use the :module:`CheckCXXSourceCompiles` module for
+ checking any function symbol (unless somehow you surely know the checked
+ function is not overloaded on other systems or will not be so in the
+ future).
+
+The following variables may be set before calling this macro to modify
+the way the check is run:
+
+``CMAKE_REQUIRED_FLAGS``
+ string of compile command line flags.
+``CMAKE_REQUIRED_DEFINITIONS``
+ a :ref:`;-list <CMake Language Lists>` of macros to define (-DFOO=bar).
+``CMAKE_REQUIRED_INCLUDES``
+ a :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler.
+``CMAKE_REQUIRED_LINK_OPTIONS``
+ a :ref:`;-list <CMake Language Lists>` of options to add to the link command.
+``CMAKE_REQUIRED_LIBRARIES``
+ a :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. See policy :policy:`CMP0075`.
+``CMAKE_REQUIRED_QUIET``
+ execute quietly without messages.
+
+For example:
+
+.. code-block:: cmake
+
+ include(CheckCXXSymbolExists)
+
+ # Check for macro SEEK_SET
+ check_cxx_symbol_exists(SEEK_SET "cstdio" HAVE_SEEK_SET)
+ # Check for function std::fopen
+ check_cxx_symbol_exists(std::fopen "cstdio" HAVE_STD_FOPEN)
+#]=======================================================================]
+
+include_guard(GLOBAL)
include(CheckSymbolExists)
macro(CHECK_CXX_SYMBOL_EXISTS SYMBOL FILES VARIABLE)
- _CHECK_SYMBOL_EXISTS("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.cxx" "${SYMBOL}" "${FILES}" "${VARIABLE}" )
+ __CHECK_SYMBOL_EXISTS_IMPL("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.cxx" "${SYMBOL}" "${FILES}" "${VARIABLE}" )
endmacro()
diff --git a/Modules/CheckForPthreads.c b/Modules/CheckForPthreads.c
index 6fc6f2634..e70ceb1da 100644
--- a/Modules/CheckForPthreads.c
+++ b/Modules/CheckForPthreads.c
@@ -1,41 +1,15 @@
#include <pthread.h>
-#include <stdio.h>
-#include <unistd.h>
-void* runner(void*);
-
-int res = 0;
-#ifdef __CLASSIC_C__
-int main()
-{
- int ac;
- char* av[];
-#else
-int main(int ac, char* av[])
+void* start_routine(void* args)
{
-#endif
- pthread_t tid[2];
- pthread_create(&tid[0], 0, runner, (void*)1);
- pthread_create(&tid[1], 0, runner, (void*)2);
-
-#if defined(__BEOS__) && !defined(__ZETA__) /* (no usleep on BeOS 5.) */
- usleep(1); /* for strange behavior on single-processor sun */
-#endif
-
- pthread_join(tid[0], 0);
- pthread_join(tid[1], 0);
- if (ac > 1000) {
- return *av[0];
- }
- return res;
+ return args;
}
-void* runner(void* args)
+int main(void)
{
- int cc;
- for (cc = 0; cc < 10; cc++) {
- printf("%p CC: %d\n", args, cc);
- }
- res++;
+ /* This is a compile and link test, no code to actually run things. */
+ pthread_t thread;
+ pthread_create(&thread, 0, start_routine, 0);
+ pthread_join(thread, 0);
return 0;
}
diff --git a/Modules/CheckFortranCompilerFlag.cmake b/Modules/CheckFortranCompilerFlag.cmake
index 8519fccf7..299cd8cfc 100644
--- a/Modules/CheckFortranCompilerFlag.cmake
+++ b/Modules/CheckFortranCompilerFlag.cmake
@@ -1,28 +1,38 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckFortranCompilerFlag
-# ------------------------
-#
-# Check whether the Fortran compiler supports a given flag.
-#
-# CHECK_Fortran_COMPILER_FLAG(<flag> <var>)
-#
-# ::
-#
-# <flag> - the compiler flag
-# <var> - variable to store the result
-# Will be created as an internal cache variable.
-#
-# This internally calls the check_fortran_source_compiles macro and
-# sets CMAKE_REQUIRED_DEFINITIONS to <flag>. See help for
-# CheckFortranSourceCompiles for a listing of variables that can
-# otherwise modify the build. The result only tells that the compiler
-# does not give an error message when it encounters the flag. If the
-# flag has any effect or even a specific one is beyond the scope of
-# this module.
+#[=======================================================================[.rst:
+CheckFortranCompilerFlag
+------------------------
+Check whether the Fortran compiler supports a given flag.
+
+.. command:: check_fortran_compiler_flag
+
+ .. code-block:: cmake
+
+ check_fortran_compiler_flag(<flag> <var>)
+
+ Check that the ``<flag>`` is accepted by the compiler without
+ a diagnostic. Stores the result in an internal cache entry
+ named ``<var>``.
+
+This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable
+and calls the ``check_fortran_source_compiles`` macro from the
+:module:`CheckFortranSourceCompiles` module. See documentation of that
+module for a listing of variables that can otherwise modify the build.
+
+A positive result from this check indicates only that the compiler did not
+issue a diagnostic message when given the flag. Whether the flag has any
+effect or even a specific one is beyond the scope of this module.
+
+.. note::
+ Since the :command:`try_compile` command forwards flags from variables
+ like :variable:`CMAKE_Fortran_FLAGS <CMAKE_<LANG>_FLAGS>`, unknown flags
+ in such variables may cause a false negative for this check.
+#]=======================================================================]
+
+include_guard(GLOBAL)
include(CheckFortranSourceCompiles)
include(CMakeCheckCompilerFlagCommonPatterns)
diff --git a/Modules/CheckFortranFunctionExists.cmake b/Modules/CheckFortranFunctionExists.cmake
index 5fc740ab8..7ca205a6d 100644
--- a/Modules/CheckFortranFunctionExists.cmake
+++ b/Modules/CheckFortranFunctionExists.cmake
@@ -1,32 +1,50 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckFortranFunctionExists
-# --------------------------
-#
-# macro which checks if the Fortran function exists
-#
-# CHECK_FORTRAN_FUNCTION_EXISTS(FUNCTION VARIABLE)
-#
-# ::
-#
-# FUNCTION - the name of the Fortran function
-# VARIABLE - variable to store the result
-# Will be created as an internal cache variable.
-#
-#
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ::
-#
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+#[=======================================================================[.rst:
+CheckFortranFunctionExists
+--------------------------
+
+Check if a Fortran function exists.
+
+.. command:: CHECK_FORTRAN_FUNCTION_EXISTS
+
+ .. code-block:: cmake
+
+ CHECK_FORTRAN_FUNCTION_EXISTS(<function> <result>)
+
+ where
+
+ ``<function>``
+ the name of the Fortran function
+ ``<result>``
+ variable to store the result; will be created as an internal cache variable.
+
+The following variables may be set before calling this macro to modify
+the way the check is run:
+
+``CMAKE_REQUIRED_LINK_OPTIONS``
+ A :ref:`;-list <CMake Language Lists>` of options to add to the link
+ command (see :command:`try_compile` for further details).
+
+``CMAKE_REQUIRED_LIBRARIES``
+ A :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. These can be the name of system libraries or they can be
+ :ref:`Imported Targets <Imported Targets>` (see :command:`try_compile` for
+ further details).
+#]=======================================================================]
+
+include_guard(GLOBAL)
macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE)
if(NOT DEFINED ${VARIABLE})
message(STATUS "Looking for Fortran ${FUNCTION}")
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS)
+ endif()
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -45,6 +63,7 @@ macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE)
try_compile(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f
+ ${CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS}
${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}
OUTPUT_VARIABLE OUTPUT
)
diff --git a/Modules/CheckFortranSourceCompiles.cmake b/Modules/CheckFortranSourceCompiles.cmake
index c42254cd9..f94b25468 100644
--- a/Modules/CheckFortranSourceCompiles.cmake
+++ b/Modules/CheckFortranSourceCompiles.cmake
@@ -1,35 +1,90 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckFortranSourceCompiles
-# --------------------------
-#
-# Check if given Fortran source compiles and links into an executable::
-#
-# CHECK_Fortran_SOURCE_COMPILES(<code> <var> [FAIL_REGEX <fail-regex>]
-# [SRC_EXT <ext>])
-#
-# The arguments are:
-#
-# ``<code>``
-# Source code to try to compile. It must define a PROGRAM entry point.
-# ``<var>``
-# Variable to store whether the source code compiled.
-# Will be created as an internal cache variable.
-# ``FAIL_REGEX <fail-regex>``
-# Fail if test output matches this regex.
-# ``SRC_EXT <ext>``
-# Use source extension ``.<ext>`` instead of the default ``.F``.
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run::
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-# CMAKE_REQUIRED_QUIET = execute quietly without messages
+#[=======================================================================[.rst:
+CheckFortranSourceCompiles
+--------------------------
+
+Check if given Fortran source compiles and links into an executable.
+
+.. command:: check_fortran_source_compiles
+
+ .. code-block:: cmake
+
+ check_fortran_source_compiles(<code> <resultVar>
+ [FAIL_REGEX <regex>...]
+ [SRC_EXT <extension>]
+ )
+
+ Checks that the source supplied in ``<code>`` can be compiled as a Fortran
+ source file and linked as an executable. The ``<code>`` must be a Fortran program
+ containing at least an ``end`` statement--for example:
+
+ .. code-block:: cmake
+
+ check_fortran_source_compiles("character :: b; error stop b; end" F2018ESTOPOK SRC_EXT F90)
+
+ This command can help avoid costly build processes when a compiler lacks support
+ for a necessary feature, or a particular vendor library is not compatible with
+ the Fortran compiler version being used. This generate-time check may advise the
+ user of such before the main build process. See also the
+ :command:`check_fortran_source_runs` command to actually run the compiled code.
+
+ The result will be stored in the internal cache
+ variable ``<resultVar>``, with a boolean true value for success and boolean
+ false for failure.
+
+ If ``FAIL_REGEX`` is provided, then failure is determined by checking
+ if anything in the output matches any of the specified regular expressions.
+
+ By default, the test source file will be given a ``.F`` file extension. The
+ ``SRC_EXT`` option can be used to override this with ``.<extension>`` instead--
+ ``.F90`` is a typical choice.
+
+ The underlying check is performed by the :command:`try_compile` command. The
+ compile and link commands can be influenced by setting any of the following
+ variables prior to calling ``check_fortran_source_compiles()``:
+
+ ``CMAKE_REQUIRED_FLAGS``
+ Additional flags to pass to the compiler. Note that the contents of
+ :variable:`CMAKE_Fortran_FLAGS <CMAKE_<LANG>_FLAGS>` and its associated
+ configuration-specific variable are automatically added to the compiler
+ command before the contents of ``CMAKE_REQUIRED_FLAGS``.
+
+ ``CMAKE_REQUIRED_DEFINITIONS``
+ A :ref:`;-list <CMake Language Lists>` of compiler definitions of the form
+ ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by
+ ``<resultVar>`` will also be added automatically.
+
+ ``CMAKE_REQUIRED_INCLUDES``
+ A :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler. These will be the only header search paths used by
+ ``try_compile()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES`
+ directory property will be ignored.
+
+ ``CMAKE_REQUIRED_LINK_OPTIONS``
+ A :ref:`;-list <CMake Language Lists>` of options to add to the link
+ command (see :command:`try_compile` for further details).
+
+ ``CMAKE_REQUIRED_LIBRARIES``
+ A :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. These can be the name of system libraries or they can be
+ :ref:`Imported Targets <Imported Targets>` (see :command:`try_compile` for
+ further details).
+
+ ``CMAKE_REQUIRED_QUIET``
+ If this variable evaluates to a boolean true value, all status messages
+ associated with the check will be suppressed.
+
+ The check is only performed once, with the result cached in the variable
+ named by ``<resultVar>``. Every subsequent CMake run will re-use this cached
+ value rather than performing the check again, even if the ``<code>`` changes.
+ In order to force the check to be re-evaluated, the variable named by
+ ``<resultVar>`` must be manually removed from the cache.
+
+#]=======================================================================]
+
+include_guard(GLOBAL)
macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR)
if(NOT DEFINED "${VAR}")
@@ -50,6 +105,12 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR)
endif()
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS)
+ endif()
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -72,6 +133,7 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR)
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS}
${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
"${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}"
diff --git a/Modules/CheckFortranSourceRuns.cmake b/Modules/CheckFortranSourceRuns.cmake
new file mode 100644
index 000000000..a80c13d00
--- /dev/null
+++ b/Modules/CheckFortranSourceRuns.cmake
@@ -0,0 +1,175 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+CheckFortranSourceRuns
+----------------------
+
+Check if given Fortran source compiles and links into an executable and can
+subsequently be run.
+
+.. command:: check_fortran_source_runs
+
+ .. code-block:: cmake
+
+ check_fortran_source_runs(<code> <resultVar>
+ [SRC_EXT <extension>])
+
+ Check that the source supplied in ``<code>`` can be compiled as a Fortran source
+ file, linked as an executable and then run. The ``<code>`` must be a Fortran program
+ containing at least an ``end`` statement--for example:
+
+ .. code-block:: cmake
+
+ check_fortran_source_runs("real :: x[*]; call co_sum(x); end" F2018coarrayOK)
+
+ This command can help avoid costly build processes when a compiler lacks support
+ for a necessary feature, or a particular vendor library is not compatible with
+ the Fortran compiler version being used. Some of these failures only occur at runtime
+ instead of linktime, and a trivial runtime example can catch the issue before the
+ main build process.
+
+ If the ``<code>`` could be built and run
+ successfully, the internal cache variable specified by ``<resultVar>`` will
+ be set to 1, otherwise it will be set to an value that evaluates to boolean
+ false (e.g. an empty string or an error message).
+
+ By default, the test source file will be given a ``.F90`` file extension. The
+ ``SRC_EXT`` option can be used to override this with ``.<extension>`` instead.
+
+ The underlying check is performed by the :command:`try_run` command. The
+ compile and link commands can be influenced by setting any of the following
+ variables prior to calling ``check_fortran_source_runs()``:
+
+ ``CMAKE_REQUIRED_FLAGS``
+ Additional flags to pass to the compiler. Note that the contents of
+ :variable:`CMAKE_Fortran_FLAGS <CMAKE_<LANG>_FLAGS>` and its associated
+ configuration-specific variable are automatically added to the compiler
+ command before the contents of ``CMAKE_REQUIRED_FLAGS``.
+
+ ``CMAKE_REQUIRED_DEFINITIONS``
+ A :ref:`;-list <CMake Language Lists>` of compiler definitions of the form
+ ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by
+ ``<resultVar>`` will also be added automatically.
+
+ ``CMAKE_REQUIRED_INCLUDES``
+ A :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler. These will be the only header search paths used by
+ ``try_run()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES`
+ directory property will be ignored.
+
+ ``CMAKE_REQUIRED_LINK_OPTIONS``
+ A :ref:`;-list <CMake Language Lists>` of options to add to the link
+ command (see :command:`try_run` for further details).
+
+ ``CMAKE_REQUIRED_LIBRARIES``
+ A :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. These can be the name of system libraries or they can be
+ :ref:`Imported Targets <Imported Targets>` (see :command:`try_run` for
+ further details).
+
+ ``CMAKE_REQUIRED_QUIET``
+ If this variable evaluates to a boolean true value, all status messages
+ associated with the check will be suppressed.
+
+ The check is only performed once, with the result cached in the variable
+ named by ``<resultVar>``. Every subsequent CMake run will re-use this cached
+ value rather than performing the check again, even if the ``<code>`` changes.
+ In order to force the check to be re-evaluated, the variable named by
+ ``<resultVar>`` must be manually removed from the cache.
+
+#]=======================================================================]
+
+include_guard(GLOBAL)
+
+macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR)
+ if(NOT DEFINED "${VAR}")
+ set(_SRC_EXT)
+ set(_key)
+ foreach(arg ${ARGN})
+ if("${arg}" MATCHES "^(SRC_EXT)$")
+ set(_key "${arg}")
+ elseif(_key)
+ list(APPEND _${_key} "${arg}")
+ else()
+ message(FATAL_ERROR "Unknown argument:\n ${arg}\n")
+ endif()
+ endforeach()
+ if(NOT _SRC_EXT)
+ set(_SRC_EXT F90)
+ endif()
+ set(MACRO_CHECK_FUNCTION_DEFINITIONS
+ "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS)
+ endif()
+ if(CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES
+ LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ else()
+ set(CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES)
+ endif()
+ if(CMAKE_REQUIRED_INCLUDES)
+ set(CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES
+ "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
+ else()
+ set(CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES)
+ endif()
+ file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}"
+ "${SOURCE}\n")
+
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR}")
+ endif()
+ try_run(${VAR}_EXITCODE ${VAR}_COMPILED
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS}
+ ${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
+ -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
+ "${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}"
+ COMPILE_OUTPUT_VARIABLE OUTPUT
+ RUN_OUTPUT_VARIABLE RUN_OUTPUT)
+
+ # if it did not compile make the return value fail code of 1
+ if(NOT ${VAR}_COMPILED)
+ set(${VAR}_EXITCODE 1)
+ endif()
+ # if the return value was 0 then it worked
+ if("${${VAR}_EXITCODE}" EQUAL 0)
+ set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Success")
+ endif()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Performing Fortran SOURCE FILE Test ${VAR} succeeded with the following output:\n"
+ "${OUTPUT}\n"
+ "...and run output:\n"
+ "${RUN_OUTPUT}\n"
+ "Return value: ${${VAR}}\n"
+ "Source file was:\n${SOURCE}\n")
+ else()
+ if(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN")
+ set(${VAR} "${${VAR}_EXITCODE}")
+ else()
+ set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
+ endif()
+
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Failed")
+ endif()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Performing Fortran SOURCE FILE Test ${VAR} failed with the following output:\n"
+ "${OUTPUT}\n"
+ "...and run output:\n"
+ "${RUN_OUTPUT}\n"
+ "Return value: ${${VAR}_EXITCODE}\n"
+ "Source file was:\n${SOURCE}\n")
+ endif()
+ endif()
+endmacro()
diff --git a/Modules/CheckFunctionExists.c b/Modules/CheckFunctionExists.c
index 224e34041..13435e07e 100644
--- a/Modules/CheckFunctionExists.c
+++ b/Modules/CheckFunctionExists.c
@@ -1,19 +1,19 @@
#ifdef CHECK_FUNCTION_EXISTS
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C"
-#endif
+# endif
char
CHECK_FUNCTION_EXISTS(void);
-#ifdef __CLASSIC_C__
+# ifdef __CLASSIC_C__
int main()
{
int ac;
char* av[];
-#else
+# else
int main(int ac, char* av[])
{
-#endif
+# endif
CHECK_FUNCTION_EXISTS();
if (ac > 1000) {
return *av[0];
@@ -23,6 +23,6 @@ int main(int ac, char* av[])
#else /* CHECK_FUNCTION_EXISTS */
-#error "CHECK_FUNCTION_EXISTS has to specify the function"
+# error "CHECK_FUNCTION_EXISTS has to specify the function"
#endif /* CHECK_FUNCTION_EXISTS */
diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake
index ef080621d..c39144fa8 100644
--- a/Modules/CheckFunctionExists.cmake
+++ b/Modules/CheckFunctionExists.cmake
@@ -1,42 +1,56 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckFunctionExists
-# -------------------
-#
-# Check if a C function can be linked::
-#
-# check_function_exists(<function> <variable>)
-#
-# Check that the ``<function>`` is provided by libraries on the system and store
-# the result in a ``<variable>``. ``<variable>`` will be created as an internal
-# cache variable.
-#
-# The following variables may be set before calling this macro to modify the
-# way the check is run:
-#
-# ::
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-# CMAKE_REQUIRED_QUIET = execute quietly without messages
-#
-# .. note::
-#
-# Prefer using :Module:`CheckSymbolExists` instead of this module,
-# for the following reasons:
-#
-# * ``check_function_exists()`` can't detect functions that are inlined
-# in headers or specified as a macro.
-#
-# * ``check_function_exists()`` can't detect anything in the 32-bit
-# versions of the Win32 API, because of a mismatch in calling conventions.
-#
-# * ``check_function_exists()`` only verifies linking, it does not verify
-# that the function is declared in system headers.
+#[=======================================================================[.rst:
+CheckFunctionExists
+-------------------
+
+Check if a C function can be linked
+
+.. command:: check_function_exists
+
+ .. code-block:: cmake
+
+ check_function_exists(<function> <variable>)
+
+ Checks that the ``<function>`` is provided by libraries on the system and store
+ the result in a ``<variable>``, which will be created as an internal
+ cache variable.
+
+The following variables may be set before calling this macro to modify the
+way the check is run:
+
+``CMAKE_REQUIRED_FLAGS``
+ string of compile command line flags.
+``CMAKE_REQUIRED_DEFINITIONS``
+ a :ref:`;-list <CMake Language Lists>` of macros to define (-DFOO=bar).
+``CMAKE_REQUIRED_INCLUDES``
+ a :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler.
+``CMAKE_REQUIRED_LINK_OPTIONS``
+ a :ref:`;-list <CMake Language Lists>` of options to add to the link command.
+``CMAKE_REQUIRED_LIBRARIES``
+ a :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. See policy :policy:`CMP0075`.
+``CMAKE_REQUIRED_QUIET``
+ execute quietly without messages.
+
+.. note::
+
+ Prefer using :Module:`CheckSymbolExists` instead of this module,
+ for the following reasons:
+
+ * ``check_function_exists()`` can't detect functions that are inlined
+ in headers or specified as a macro.
+
+ * ``check_function_exists()`` can't detect anything in the 32-bit
+ versions of the Win32 API, because of a mismatch in calling conventions.
+
+ * ``check_function_exists()`` only verifies linking, it does not verify
+ that the function is declared in system headers.
+#]=======================================================================]
+
+include_guard(GLOBAL)
macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
if(NOT DEFINED "${VARIABLE}" OR "x${${VARIABLE}}" STREQUAL "x${VARIABLE}")
@@ -45,6 +59,12 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
if(NOT CMAKE_REQUIRED_QUIET)
message(STATUS "Looking for ${FUNCTION}")
endif()
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS)
+ endif()
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -71,6 +91,7 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
${CMAKE_BINARY_DIR}
${_cfe_source}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS}
${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
"${CHECK_FUNCTION_EXISTS_ADD_INCLUDES}"
diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake
index e04ab1c54..0d6ad20ae 100644
--- a/Modules/CheckIPOSupported.cmake
+++ b/Modules/CheckIPOSupported.cmake
@@ -26,7 +26,7 @@ property.
Set ``<output>`` variable with details about any error.
``LANGUAGES <lang>...``
Specify languages whose compilers to check.
- Languages ``C`` and ``CXX`` are supported.
+ Languages ``C``, ``CXX``, and ``Fortran`` are supported.
It makes no sense to use this module when :policy:`CMP0069` is set to ``OLD`` so
module will return error in this case. See policy :policy:`CMP0069` for details.
@@ -51,18 +51,17 @@ Examples
#]=======================================================================]
-include(CMakeParseArguments) # cmake_parse_arguments
-
# X_RESULT - name of the final result variable
# X_OUTPUT - name of the variable with information about error
macro(_ipo_not_supported output)
- string(COMPARE EQUAL "${X_RESULT}" "" is_empty)
- if(is_empty)
+ if(NOT X_RESULT)
message(FATAL_ERROR "IPO is not supported (${output}).")
endif()
set("${X_RESULT}" NO PARENT_SCOPE)
- set("${X_OUTPUT}" "${output}" PARENT_SCOPE)
+ if(X_OUTPUT)
+ set("${X_OUTPUT}" "${output}" PARENT_SCOPE)
+ endif()
endmacro()
# Run IPO/LTO test
@@ -125,7 +124,13 @@ macro(_ipo_run_language_check language)
)
if(NOT result)
- _ipo_not_supported("${output}")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "${language} compiler IPO check failed with the following output:\n"
+ "${output}\n")
+ _ipo_not_supported("check failed to compile")
+ if(X_OUTPUT)
+ set("${X_OUTPUT}" "${output}" PARENT_SCOPE)
+ endif()
return()
endif()
endmacro()
@@ -219,7 +224,7 @@ function(check_ipo_supported)
endif()
endforeach()
- if(CMAKE_GENERATOR MATCHES "^Visual Studio ")
+ if(CMAKE_GENERATOR MATCHES "^Visual Studio 9 ")
_ipo_not_supported("CMake doesn't support IPO for current generator")
return()
endif()
diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake
index c566e1448..d7b9481da 100644
--- a/Modules/CheckIncludeFile.cmake
+++ b/Modules/CheckIncludeFile.cmake
@@ -1,38 +1,47 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckIncludeFile
-# ----------------
-#
-# Provides a macro to check if a header file can be included in ``C``.
-#
-# .. command:: CHECK_INCLUDE_FILE
-#
-# ::
-#
-# CHECK_INCLUDE_FILE(<include> <variable> [<flags>])
-#
-# Check if the given ``<include>`` file may be included in a ``C``
-# source file and store the result in an internal cache entry named
-# ``<variable>``. The optional third argument may be used to add
-# compilation flags to the check (or use ``CMAKE_REQUIRED_FLAGS`` below).
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ``CMAKE_REQUIRED_FLAGS``
-# string of compile command line flags
-# ``CMAKE_REQUIRED_DEFINITIONS``
-# list of macros to define (-DFOO=bar)
-# ``CMAKE_REQUIRED_INCLUDES``
-# list of include directories
-# ``CMAKE_REQUIRED_QUIET``
-# execute quietly without messages
-#
-# See the :module:`CheckIncludeFiles` module to check for multiple headers
-# at once. See the :module:`CheckIncludeFileCXX` module to check for headers
-# using the ``CXX`` language.
+#[=======================================================================[.rst:
+CheckIncludeFile
+----------------
+
+Provides a macro to check if a header file can be included in ``C``.
+
+.. command:: CHECK_INCLUDE_FILE
+
+ .. code-block:: cmake
+
+ CHECK_INCLUDE_FILE(<include> <variable> [<flags>])
+
+ Check if the given ``<include>`` file may be included in a ``C``
+ source file and store the result in an internal cache entry named
+ ``<variable>``. The optional third argument may be used to add
+ compilation flags to the check (or use ``CMAKE_REQUIRED_FLAGS`` below).
+
+The following variables may be set before calling this macro to modify
+the way the check is run:
+
+``CMAKE_REQUIRED_FLAGS``
+ string of compile command line flags.
+``CMAKE_REQUIRED_DEFINITIONS``
+ a :ref:`;-list <CMake Language Lists>` of macros to define (-DFOO=bar).
+``CMAKE_REQUIRED_INCLUDES``
+ a :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler.
+``CMAKE_REQUIRED_LINK_OPTIONS``
+ a :ref:`;-list <CMake Language Lists>` of options to add to the link command.
+``CMAKE_REQUIRED_LIBRARIES``
+ a :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. See policy :policy:`CMP0075`.
+``CMAKE_REQUIRED_QUIET``
+ execute quietly without messages.
+
+See the :module:`CheckIncludeFiles` module to check for multiple headers
+at once. See the :module:`CheckIncludeFileCXX` module to check for headers
+using the ``CXX`` language.
+#]=======================================================================]
+
+include_guard(GLOBAL)
macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE)
if(NOT DEFINED "${VARIABLE}")
@@ -53,14 +62,46 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE)
string(APPEND CMAKE_C_FLAGS " ${ARGV2}")
endif()
+ set(_CIF_LINK_OPTIONS)
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(_CIF_LINK_OPTIONS LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ endif()
+
+ set(_CIF_LINK_LIBRARIES "")
+ if(CMAKE_REQUIRED_LIBRARIES)
+ cmake_policy(GET CMP0075 _CIF_CMP0075
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ if("x${_CIF_CMP0075}x" STREQUAL "xNEWx")
+ set(_CIF_LINK_LIBRARIES LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ elseif("x${_CIF_CMP0075}x" STREQUAL "xOLDx")
+ elseif(NOT _CIF_CMP0075_WARNED)
+ set(_CIF_CMP0075_WARNED 1)
+ message(AUTHOR_WARNING
+ "Policy CMP0075 is not set: Include file check macros honor CMAKE_REQUIRED_LIBRARIES. "
+ "Run \"cmake --help-policy CMP0075\" for policy details. "
+ "Use the cmake_policy command to set the policy and suppress this warning."
+ "\n"
+ "CMAKE_REQUIRED_LIBRARIES is set to:\n"
+ " ${CMAKE_REQUIRED_LIBRARIES}\n"
+ "For compatibility with CMake 3.11 and below this check is ignoring it."
+ )
+ endif()
+ unset(_CIF_CMP0075)
+ endif()
+
try_compile(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${_CIF_LINK_OPTIONS}
+ ${_CIF_LINK_LIBRARIES}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
"${CHECK_INCLUDE_FILE_C_INCLUDE_DIRS}"
OUTPUT_VARIABLE OUTPUT)
+ unset(_CIF_LINK_OPTIONS)
+ unset(_CIF_LINK_LIBRARIES)
if(${ARGC} EQUAL 3)
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS_SAVE})
diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake
index 19b1ef6f8..de5a83b35 100644
--- a/Modules/CheckIncludeFileCXX.cmake
+++ b/Modules/CheckIncludeFileCXX.cmake
@@ -1,37 +1,46 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckIncludeFileCXX
-# -------------------
-#
-# Provides a macro to check if a header file can be included in ``CXX``.
-#
-# .. command:: CHECK_INCLUDE_FILE_CXX
-#
-# ::
-#
-# CHECK_INCLUDE_FILE_CXX(<include> <variable> [<flags>])
-#
-# Check if the given ``<include>`` file may be included in a ``CXX``
-# source file and store the result in an internal cache entry named
-# ``<variable>``. The optional third argument may be used to add
-# compilation flags to the check (or use ``CMAKE_REQUIRED_FLAGS`` below).
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ``CMAKE_REQUIRED_FLAGS``
-# string of compile command line flags
-# ``CMAKE_REQUIRED_DEFINITIONS``
-# list of macros to define (-DFOO=bar)
-# ``CMAKE_REQUIRED_INCLUDES``
-# list of include directories
-# ``CMAKE_REQUIRED_QUIET``
-# execute quietly without messages
-#
-# See modules :module:`CheckIncludeFile` and :module:`CheckIncludeFiles`
-# to check for one or more ``C`` headers.
+#[=======================================================================[.rst:
+CheckIncludeFileCXX
+-------------------
+
+Provides a macro to check if a header file can be included in ``CXX``.
+
+.. command:: CHECK_INCLUDE_FILE_CXX
+
+ .. code-block:: cmake
+
+ CHECK_INCLUDE_FILE_CXX(<include> <variable> [<flags>])
+
+ Check if the given ``<include>`` file may be included in a ``CXX``
+ source file and store the result in an internal cache entry named
+ ``<variable>``. The optional third argument may be used to add
+ compilation flags to the check (or use ``CMAKE_REQUIRED_FLAGS`` below).
+
+The following variables may be set before calling this macro to modify
+the way the check is run:
+
+``CMAKE_REQUIRED_FLAGS``
+ string of compile command line flags.
+``CMAKE_REQUIRED_DEFINITIONS``
+ a :ref:`;-list <CMake Language Lists>` of macros to define (-DFOO=bar).
+``CMAKE_REQUIRED_INCLUDES``
+ a :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler.
+``CMAKE_REQUIRED_LINK_OPTIONS``
+ a :ref:`;-list <CMake Language Lists>` of options to add to the link command.
+``CMAKE_REQUIRED_LIBRARIES``
+ a :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. See policy :policy:`CMP0075`.
+``CMAKE_REQUIRED_QUIET``
+ execute quietly without messages.
+
+See modules :module:`CheckIncludeFile` and :module:`CheckIncludeFiles`
+to check for one or more ``C`` headers.
+#]=======================================================================]
+
+include_guard(GLOBAL)
macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE)
if(NOT DEFINED "${VARIABLE}" OR "x${${VARIABLE}}" STREQUAL "x${VARIABLE}")
@@ -52,14 +61,46 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE)
string(APPEND CMAKE_CXX_FLAGS " ${ARGV2}")
endif()
+ set(_CIF_LINK_OPTIONS)
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(_CIF_LINK_OPTIONS LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ endif()
+
+ set(_CIF_LINK_LIBRARIES "")
+ if(CMAKE_REQUIRED_LIBRARIES)
+ cmake_policy(GET CMP0075 _CIF_CMP0075
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ if("x${_CIF_CMP0075}x" STREQUAL "xNEWx")
+ set(_CIF_LINK_LIBRARIES LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ elseif("x${_CIF_CMP0075}x" STREQUAL "xOLDx")
+ elseif(NOT _CIF_CMP0075_WARNED)
+ set(_CIF_CMP0075_WARNED 1)
+ message(AUTHOR_WARNING
+ "Policy CMP0075 is not set: Include file check macros honor CMAKE_REQUIRED_LIBRARIES. "
+ "Run \"cmake --help-policy CMP0075\" for policy details. "
+ "Use the cmake_policy command to set the policy and suppress this warning."
+ "\n"
+ "CMAKE_REQUIRED_LIBRARIES is set to:\n"
+ " ${CMAKE_REQUIRED_LIBRARIES}\n"
+ "For compatibility with CMake 3.11 and below this check is ignoring it."
+ )
+ endif()
+ unset(_CIF_CMP0075)
+ endif()
+
try_compile(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${_CIF_LINK_OPTIONS}
+ ${_CIF_LINK_LIBRARIES}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILE_FLAGS}
"${CHECK_INCLUDE_FILE_CXX_INCLUDE_DIRS}"
OUTPUT_VARIABLE OUTPUT)
+ unset(_CIF_LINK_OPTIONS)
+ unset(_CIF_LINK_LIBRARIES)
if(${ARGC} EQUAL 3)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_SAVE})
diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake
index bef11a5e9..f52ab55fb 100644
--- a/Modules/CheckIncludeFiles.cmake
+++ b/Modules/CheckIncludeFiles.cmake
@@ -1,42 +1,81 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckIncludeFiles
-# -----------------
-#
-# Provides a macro to check if a list of one or more header files can
-# be included together in ``C``.
-#
-# .. command:: CHECK_INCLUDE_FILES
-#
-# ::
-#
-# CHECK_INCLUDE_FILES("<includes>" <variable>)
-#
-# Check if the given ``<includes>`` list may be included together
-# in a ``C`` source file and store the result in an internal cache
-# entry named ``<variable>``. Specify the ``<includes>`` argument
-# as a :ref:`;-list <CMake Language Lists>` of header file names.
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ``CMAKE_REQUIRED_FLAGS``
-# string of compile command line flags
-# ``CMAKE_REQUIRED_DEFINITIONS``
-# list of macros to define (-DFOO=bar)
-# ``CMAKE_REQUIRED_INCLUDES``
-# list of include directories
-# ``CMAKE_REQUIRED_QUIET``
-# execute quietly without messages
-#
-# See modules :module:`CheckIncludeFile` and :module:`CheckIncludeFileCXX`
-# to check for a single header file in ``C`` or ``CXX`` languages.
+#[=======================================================================[.rst:
+CheckIncludeFiles
+-----------------
+
+Provides a macro to check if a list of one or more header files can
+be included together.
+
+.. command:: CHECK_INCLUDE_FILES
+
+ .. code-block:: cmake
+
+ CHECK_INCLUDE_FILES("<includes>" <variable> [LANGUAGE <language>])
+
+ Check if the given ``<includes>`` list may be included together
+ in a source file and store the result in an internal cache
+ entry named ``<variable>``. Specify the ``<includes>`` argument
+ as a :ref:`;-list <CMake Language Lists>` of header file names.
+
+ If ``LANGUAGE`` is set, the specified compiler will be used to perform the
+ check. Acceptable values are ``C`` and ``CXX``. If not set, the C compiler
+ will be used if enabled. If the C compiler is not enabled, the C++
+ compiler will be used if enabled.
+
+The following variables may be set before calling this macro to modify
+the way the check is run:
+
+``CMAKE_REQUIRED_FLAGS``
+ string of compile command line flags.
+``CMAKE_REQUIRED_DEFINITIONS``
+ a :ref:`;-list <CMake Language Lists>` of macros to define (-DFOO=bar).
+``CMAKE_REQUIRED_INCLUDES``
+ a :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler.
+``CMAKE_REQUIRED_LINK_OPTIONS``
+ a :ref:`;-list <CMake Language Lists>` of options to add to the link command.
+``CMAKE_REQUIRED_LIBRARIES``
+ a :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. See policy :policy:`CMP0075`.
+``CMAKE_REQUIRED_QUIET``
+ execute quietly without messages.
+
+See modules :module:`CheckIncludeFile` and :module:`CheckIncludeFileCXX`
+to check for a single header file in ``C`` or ``CXX`` languages.
+#]=======================================================================]
+
+include_guard(GLOBAL)
macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
if(NOT DEFINED "${VARIABLE}")
set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n")
+
+ if("x${ARGN}" STREQUAL "x")
+ if(CMAKE_C_COMPILER_LOADED)
+ set(_lang C)
+ elseif(CMAKE_CXX_COMPILER_LOADED)
+ set(_lang CXX)
+ else()
+ message(FATAL_ERROR "CHECK_INCLUDE_FILES needs either C or CXX language enabled.\n")
+ endif()
+ elseif("x${ARGN}" MATCHES "^xLANGUAGE;([a-zA-Z]+)$")
+ set(_lang "${CMAKE_MATCH_1}")
+ elseif("x${ARGN}" MATCHES "^xLANGUAGE$")
+ message(FATAL_ERROR "No languages listed for LANGUAGE option.\nSupported languages: C, CXX.\n")
+ else()
+ message(FATAL_ERROR "Unknown arguments:\n ${ARGN}\n")
+ endif()
+
+ if(_lang STREQUAL "C")
+ set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckIncludeFiles/${VARIABLE}.c)
+ elseif(_lang STREQUAL "CXX")
+ set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckIncludeFiles/${VARIABLE}.cpp)
+ else()
+ message(FATAL_ERROR "Unknown language:\n ${_lang}\nSupported languages: C, CXX.\n")
+ endif()
+
if(CMAKE_REQUIRED_INCLUDES)
set(CHECK_INCLUDE_FILES_INCLUDE_DIRS "-DINCLUDE_DIRECTORIES=${CMAKE_REQUIRED_INCLUDES}")
else()
@@ -51,7 +90,7 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT
"\n\nint main(void){return 0;}\n")
configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
- "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c" @ONLY)
+ "${src}" @ONLY)
set(_INCLUDE ${INCLUDE}) # remove empty elements
if("${_INCLUDE}" MATCHES "^([^;]+);.+;([^;]+)$")
@@ -63,17 +102,49 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
set(_description "include file ${_INCLUDE}")
endif()
+ set(_CIF_LINK_OPTIONS)
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(_CIF_LINK_OPTIONS LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ endif()
+
+ set(_CIF_LINK_LIBRARIES "")
+ if(CMAKE_REQUIRED_LIBRARIES)
+ cmake_policy(GET CMP0075 _CIF_CMP0075
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ if("x${_CIF_CMP0075}x" STREQUAL "xNEWx")
+ set(_CIF_LINK_LIBRARIES LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ elseif("x${_CIF_CMP0075}x" STREQUAL "xOLDx")
+ elseif(NOT _CIF_CMP0075_WARNED)
+ set(_CIF_CMP0075_WARNED 1)
+ message(AUTHOR_WARNING
+ "Policy CMP0075 is not set: Include file check macros honor CMAKE_REQUIRED_LIBRARIES. "
+ "Run \"cmake --help-policy CMP0075\" for policy details. "
+ "Use the cmake_policy command to set the policy and suppress this warning."
+ "\n"
+ "CMAKE_REQUIRED_LIBRARIES is set to:\n"
+ " ${CMAKE_REQUIRED_LIBRARIES}\n"
+ "For compatibility with CMake 3.11 and below this check is ignoring it."
+ )
+ endif()
+ unset(_CIF_CMP0075)
+ endif()
+
if(NOT CMAKE_REQUIRED_QUIET)
message(STATUS "Looking for ${_description}")
endif()
try_compile(${VARIABLE}
${CMAKE_BINARY_DIR}
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c
+ ${src}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${_CIF_LINK_OPTIONS}
+ ${_CIF_LINK_LIBRARIES}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_INCLUDE_FILES_FLAGS}
"${CHECK_INCLUDE_FILES_INCLUDE_DIRS}"
OUTPUT_VARIABLE OUTPUT)
+ unset(_CIF_LINK_OPTIONS)
+ unset(_CIF_LINK_LIBRARIES)
if(${VARIABLE})
if(NOT CMAKE_REQUIRED_QUIET)
message(STATUS "Looking for ${_description} - found")
diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake
index 1ea91d2d0..a1a3a7aac 100644
--- a/Modules/CheckLanguage.cmake
+++ b/Modules/CheckLanguage.cmake
@@ -1,53 +1,74 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckLanguage
-# -------------
-#
-# Check if a language can be enabled
-#
-# Usage:
-#
-# ::
-#
-# check_language(<lang>)
-#
-# where <lang> is a language that may be passed to enable_language()
-# such as "Fortran". If CMAKE_<lang>_COMPILER is already defined the
-# check does nothing. Otherwise it tries enabling the language in a
-# test project. The result is cached in CMAKE_<lang>_COMPILER as the
-# compiler that was found, or NOTFOUND if the language cannot be
-# enabled.
-#
-# Example:
-#
-# ::
-#
-# check_language(Fortran)
-# if(CMAKE_Fortran_COMPILER)
-# enable_language(Fortran)
-# else()
-# message(STATUS "No Fortran support")
-# endif()
+#[=======================================================================[.rst:
+CheckLanguage
+-------------
+
+Check if a language can be enabled
+
+Usage:
+
+::
+
+ check_language(<lang>)
+
+where ``<lang>`` is a language that may be passed to :command:`enable_language`
+such as ``Fortran``. If :variable:`CMAKE_<LANG>_COMPILER` is already defined
+the check does nothing. Otherwise it tries enabling the language in a
+test project. The result is cached in :variable:`CMAKE_<LANG>_COMPILER`
+as the compiler that was found, or ``NOTFOUND`` if the language cannot be
+enabled. For CUDA which can have an explicit host compiler, the cache
+:variable:`CMAKE_CUDA_HOST_COMPILER` variable will be set if it was required
+for compilation.
+
+Example:
+
+::
+
+ check_language(Fortran)
+ if(CMAKE_Fortran_COMPILER)
+ enable_language(Fortran)
+ else()
+ message(STATUS "No Fortran support")
+ endif()
+#]=======================================================================]
+
+include_guard(GLOBAL)
macro(check_language lang)
if(NOT DEFINED CMAKE_${lang}_COMPILER)
set(_desc "Looking for a ${lang} compiler")
message(STATUS ${_desc})
file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang})
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}/CMakeLists.txt"
+
+ set(extra_compiler_variables)
+ if(lang STREQUAL CUDA)
+ set(extra_compiler_variables "set(CMAKE_CUDA_HOST_COMPILER \\\"\${CMAKE_CUDA_HOST_COMPILER}\\\")")
+ endif()
+
+ set(content
"cmake_minimum_required(VERSION ${CMAKE_VERSION})
project(Check${lang} ${lang})
file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
\"set(CMAKE_${lang}_COMPILER \\\"\${CMAKE_${lang}_COMPILER}\\\")\\n\"
- )
-")
+ \"${extra_compiler_variables}\\n\"
+ )"
+ )
+
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}/CMakeLists.txt"
+ "${content}")
+ if(CMAKE_GENERATOR_INSTANCE)
+ set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}")
+ else()
+ set(_D_CMAKE_GENERATOR_INSTANCE "")
+ endif()
execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}
COMMAND ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR}
-A "${CMAKE_GENERATOR_PLATFORM}"
-T "${CMAKE_GENERATOR_TOOLSET}"
+ ${_D_CMAKE_GENERATOR_INSTANCE}
OUTPUT_VARIABLE output
ERROR_VARIABLE output
RESULT_VARIABLE result
@@ -66,5 +87,12 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
message(STATUS "${_desc} - ${CMAKE_${lang}_COMPILER}")
set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER}" CACHE FILEPATH "${lang} compiler")
mark_as_advanced(CMAKE_${lang}_COMPILER)
+
+ if(CMAKE_${lang}_HOST_COMPILER)
+ message(STATUS "Looking for a ${lang} host compiler - ${CMAKE_${lang}_HOST_COMPILER}")
+ set(CMAKE_${lang}_HOST_COMPILER "${CMAKE_${lang}_HOST_COMPILER}" CACHE FILEPATH "${lang} host compiler")
+ mark_as_advanced(CMAKE_${lang}_HOST_COMPILER)
+ endif()
+
endif()
endmacro()
diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake
index 528a45085..6504df5d7 100644
--- a/Modules/CheckLibraryExists.cmake
+++ b/Modules/CheckLibraryExists.cmake
@@ -1,33 +1,41 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckLibraryExists
-# ------------------
-#
-# Check if the function exists.
-#
-# CHECK_LIBRARY_EXISTS (LIBRARY FUNCTION LOCATION VARIABLE)
-#
-# ::
-#
-# LIBRARY - the name of the library you are looking for
-# FUNCTION - the name of the function
-# LOCATION - location where the library should be found
-# VARIABLE - variable to store the result
-# Will be created as an internal cache variable.
-#
-#
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ::
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-# CMAKE_REQUIRED_QUIET = execute quietly without messages
+#[=======================================================================[.rst:
+CheckLibraryExists
+------------------
+
+Check if the function exists.
+
+.. command:: CHECK_LIBRARY_EXISTS
+
+ .. code-block:: cmake
+
+ CHECK_LIBRARY_EXISTS(LIBRARY FUNCTION LOCATION VARIABLE)
+
+ ::
+
+ LIBRARY - the name of the library you are looking for
+ FUNCTION - the name of the function
+ LOCATION - location where the library should be found
+ VARIABLE - variable to store the result
+ Will be created as an internal cache variable.
+
+
+
+The following variables may be set before calling this macro to modify
+the way the check is run:
+
+::
+
+ CMAKE_REQUIRED_FLAGS = string of compile command line flags
+ CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+ CMAKE_REQUIRED_LINK_OPTIONS = list of options to pass to link command
+ CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+ CMAKE_REQUIRED_QUIET = execute quietly without messages
+#]=======================================================================]
+
+include_guard(GLOBAL)
macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
if(NOT DEFINED "${VARIABLE}")
@@ -36,6 +44,11 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
if(NOT CMAKE_REQUIRED_QUIET)
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}")
endif()
+ set(CHECK_LIBRARY_EXISTS_LINK_OPTIONS)
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_LIBRARY_EXISTS_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ endif()
set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY})
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_LIBRARY_EXISTS_LIBRARIES
@@ -55,6 +68,7 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
${CMAKE_BINARY_DIR}
${_cle_source}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_LIBRARY_EXISTS_LINK_OPTIONS}
LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}
diff --git a/Modules/CheckOBJCCompilerFlag.cmake b/Modules/CheckOBJCCompilerFlag.cmake
new file mode 100644
index 000000000..1d975da88
--- /dev/null
+++ b/Modules/CheckOBJCCompilerFlag.cmake
@@ -0,0 +1,64 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+CheckOBJCCompilerFlag
+---------------------
+
+Check whether the Objective-C compiler supports a given flag.
+
+.. command:: check_objc_compiler_flag
+
+ .. code-block:: cmake
+
+ check_objc_compiler_flag(<flag> <var>)
+
+ Check that the ``<flag>`` is accepted by the compiler without
+ a diagnostic. Stores the result in an internal cache entry
+ named ``<var>``.
+
+This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable
+and calls the ``check_objc_source_compiles`` macro from the
+:module:`CheckOBJCSourceCompiles` module. See documentation of that
+module for a listing of variables that can otherwise modify the build.
+
+A positive result from this check indicates only that the compiler did not
+issue a diagnostic message when given the flag. Whether the flag has any
+effect or even a specific one is beyond the scope of this module.
+
+.. note::
+ Since the :command:`try_compile` command forwards flags from variables
+ like :variable:`CMAKE_OBJC_FLAGS <CMAKE_<LANG>_FLAGS>`, unknown flags
+ in such variables may cause a false negative for this check.
+#]=======================================================================]
+
+include_guard(GLOBAL)
+include(CheckOBJCSourceCompiles)
+include(CMakeCheckCompilerFlagCommonPatterns)
+
+macro (CHECK_OBJC_COMPILER_FLAG _FLAG _RESULT)
+ set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
+ set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
+
+ # Normalize locale during test compilation.
+ set(_CheckOBJCCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG)
+ foreach(v ${_CheckOBJCCompilerFlag_LOCALE_VARS})
+ set(_CheckOBJCCompilerFlag_SAVED_${v} "$ENV{${v}}")
+ set(ENV{${v}} OBJC)
+ endforeach()
+ CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckOBJCCompilerFlag_COMMON_PATTERNS)
+ CHECK_OBJC_SOURCE_COMPILES("#ifndef __OBJC__\n# error \"Not an Objective-C compiler\"\n#endif\nint main(void) { return 0; }" ${_RESULT}
+ # Some compilers do not fail with a bad flag
+ FAIL_REGEX "command line option .* is valid for .* but not for Objective-C" # GNU
+ FAIL_REGEX "argument unused during compilation: .*" # Clang
+ ${_CheckOBJCCompilerFlag_COMMON_PATTERNS}
+ )
+ foreach(v ${_CheckOBJCCompilerFlag_LOCALE_VARS})
+ set(ENV{${v}} ${_CheckOBJCCompilerFlag_SAVED_${v}})
+ unset(_CheckOBJCCompilerFlag_SAVED_${v})
+ endforeach()
+ unset(_CheckOBJCCompilerFlag_LOCALE_VARS)
+ unset(_CheckOBJCCompilerFlag_COMMON_PATTERNS)
+
+ set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
+endmacro ()
diff --git a/Modules/CheckOBJCSourceCompiles.cmake b/Modules/CheckOBJCSourceCompiles.cmake
new file mode 100644
index 000000000..a4676ad6e
--- /dev/null
+++ b/Modules/CheckOBJCSourceCompiles.cmake
@@ -0,0 +1,145 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+CheckOBJCSourceCompiles
+-----------------------
+
+Check if given Objective-C source compiles and links into an executable.
+
+.. command:: check_objc_source_compiles
+
+ .. code-block:: cmake
+
+ check_objc_source_compiles(<code> <resultVar>
+ [FAIL_REGEX <regex1> [<regex2>...]])
+
+ Check that the source supplied in ``<code>`` can be compiled as a Objectie-C source
+ file and linked as an executable (so it must contain at least a ``main()``
+ function). The result will be stored in the internal cache variable specified
+ by ``<resultVar>``, with a boolean true value for success and boolean false
+ for failure. If ``FAIL_REGEX`` is provided, then failure is determined by
+ checking if anything in the output matches any of the specified regular
+ expressions.
+
+ The underlying check is performed by the :command:`try_compile` command. The
+ compile and link commands can be influenced by setting any of the following
+ variables prior to calling ``check_objc_source_compiles()``:
+
+ ``CMAKE_REQUIRED_FLAGS``
+ Additional flags to pass to the compiler. Note that the contents of
+ :variable:`CMAKE_OBJC_FLAGS <CMAKE_<LANG>_FLAGS>` and its associated
+ configuration-specific variable are automatically added to the compiler
+ command before the contents of ``CMAKE_REQUIRED_FLAGS``.
+
+ ``CMAKE_REQUIRED_DEFINITIONS``
+ A :ref:`;-list <CMake Language Lists>` of compiler definitions of the form
+ ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by
+ ``<resultVar>`` will also be added automatically.
+
+ ``CMAKE_REQUIRED_INCLUDES``
+ A :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler. These will be the only header search paths used by
+ ``try_compile()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES`
+ directory property will be ignored.
+
+ ``CMAKE_REQUIRED_LINK_OPTIONS``
+ A :ref:`;-list <CMake Language Lists>` of options to add to the link
+ command (see :command:`try_compile` for further details).
+
+ ``CMAKE_REQUIRED_LIBRARIES``
+ A :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. These can be the name of system libraries or they can be
+ :ref:`Imported Targets <Imported Targets>` (see :command:`try_compile` for
+ further details).
+
+ ``CMAKE_REQUIRED_QUIET``
+ If this variable evaluates to a boolean true value, all status messages
+ associated with the check will be suppressed.
+
+ The check is only performed once, with the result cached in the variable
+ named by ``<resultVar>``. Every subsequent CMake run will re-use this cached
+ value rather than performing the check again, even if the ``<code>`` changes.
+ In order to force the check to be re-evaluated, the variable named by
+ ``<resultVar>`` must be manually removed from the cache.
+
+#]=======================================================================]
+
+include_guard(GLOBAL)
+
+macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR)
+ if(NOT DEFINED "${VAR}")
+ set(_FAIL_REGEX)
+ set(_key)
+ foreach(arg ${ARGN})
+ if("${arg}" MATCHES "^(FAIL_REGEX)$")
+ set(_key "${arg}")
+ elseif(_key)
+ list(APPEND _${_key} "${arg}")
+ else()
+ message(FATAL_ERROR "Unknown argument:\n ${arg}\n")
+ endif()
+ endforeach()
+ set(MACRO_CHECK_FUNCTION_DEFINITIONS
+ "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS)
+ endif()
+ if(CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES
+ LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ else()
+ set(CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES)
+ endif()
+ if(CMAKE_REQUIRED_INCLUDES)
+ set(CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES
+ "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
+ else()
+ set(CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES)
+ endif()
+ file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.m"
+ "${SOURCE}\n")
+
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR}")
+ endif()
+ try_compile(${VAR}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.m
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS}
+ ${CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
+ "${CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES}"
+ OUTPUT_VARIABLE OUTPUT)
+
+ foreach(_regex ${_FAIL_REGEX})
+ if("${OUTPUT}" MATCHES "${_regex}")
+ set(${VAR} 0)
+ endif()
+ endforeach()
+
+ if(${VAR})
+ set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Success")
+ endif()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Performing Objective-C SOURCE FILE Test ${VAR} succeeded with the following output:\n"
+ "${OUTPUT}\n"
+ "Source file was:\n${SOURCE}\n")
+ else()
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Failed")
+ endif()
+ set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Performing Objective-C SOURCE FILE Test ${VAR} failed with the following output:\n"
+ "${OUTPUT}\n"
+ "Source file was:\n${SOURCE}\n")
+ endif()
+ endif()
+endmacro()
diff --git a/Modules/CheckOBJCSourceRuns.cmake b/Modules/CheckOBJCSourceRuns.cmake
new file mode 100644
index 000000000..00a1ebd0c
--- /dev/null
+++ b/Modules/CheckOBJCSourceRuns.cmake
@@ -0,0 +1,145 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+CheckOBJCSourceRuns
+-------------------
+
+Check if given Objective-C source compiles and links into an executable and can
+subsequently be run.
+
+.. command:: check_objc_source_runs
+
+ .. code-block:: cmake
+
+ check_objc_source_runs(<code> <resultVar>)
+
+ Check that the source supplied in ``<code>`` can be compiled as a Objective-C source
+ file, linked as an executable and then run. The ``<code>`` must contain at
+ least a ``main()`` function. If the ``<code>`` could be built and run
+ successfully, the internal cache variable specified by ``<resultVar>`` will
+ be set to 1, otherwise it will be set to an value that evaluates to boolean
+ false (e.g. an empty string or an error message).
+
+ The underlying check is performed by the :command:`try_run` command. The
+ compile and link commands can be influenced by setting any of the following
+ variables prior to calling ``check_objc_source_runs()``:
+
+ ``CMAKE_REQUIRED_FLAGS``
+ Additional flags to pass to the compiler. Note that the contents of
+ :variable:`CMAKE_OBJC_FLAGS <CMAKE_<LANG>_FLAGS>` and its associated
+ configuration-specific variable are automatically added to the compiler
+ command before the contents of ``CMAKE_REQUIRED_FLAGS``.
+
+ ``CMAKE_REQUIRED_DEFINITIONS``
+ A :ref:`;-list <CMake Language Lists>` of compiler definitions of the form
+ ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by
+ ``<resultVar>`` will also be added automatically.
+
+ ``CMAKE_REQUIRED_INCLUDES``
+ A :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler. These will be the only header search paths used by
+ ``try_run()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES`
+ directory property will be ignored.
+
+ ``CMAKE_REQUIRED_LINK_OPTIONS``
+ A :ref:`;-list <CMake Language Lists>` of options to add to the link
+ command (see :command:`try_run` for further details).
+
+ ``CMAKE_REQUIRED_LIBRARIES``
+ A :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. These can be the name of system libraries or they can be
+ :ref:`Imported Targets <Imported Targets>` (see :command:`try_run` for
+ further details).
+
+ ``CMAKE_REQUIRED_QUIET``
+ If this variable evaluates to a boolean true value, all status messages
+ associated with the check will be suppressed.
+
+ The check is only performed once, with the result cached in the variable
+ named by ``<resultVar>``. Every subsequent CMake run will re-use this cached
+ value rather than performing the check again, even if the ``<code>`` changes.
+ In order to force the check to be re-evaluated, the variable named by
+ ``<resultVar>`` must be manually removed from the cache.
+
+#]=======================================================================]
+
+include_guard(GLOBAL)
+
+macro(CHECK_OBJC_SOURCE_RUNS SOURCE VAR)
+ if(NOT DEFINED "${VAR}")
+ set(MACRO_CHECK_FUNCTION_DEFINITIONS
+ "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS)
+ endif()
+ if(CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES
+ LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ else()
+ set(CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES)
+ endif()
+ if(CMAKE_REQUIRED_INCLUDES)
+ set(CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES
+ "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
+ else()
+ set(CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES)
+ endif()
+ file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.m"
+ "${SOURCE}\n")
+
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR}")
+ endif()
+ try_run(${VAR}_EXITCODE ${VAR}_COMPILED
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.m
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_OBJC_SOURCE_COMPILES_ADD_LINK_OPTIONS}
+ ${CHECK_OBJC_SOURCE_COMPILES_ADD_LIBRARIES}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
+ -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
+ "${CHECK_OBJC_SOURCE_COMPILES_ADD_INCLUDES}"
+ COMPILE_OUTPUT_VARIABLE OUTPUT
+ RUN_OUTPUT_VARIABLE RUN_OUTPUT)
+ # if it did not compile make the return value fail code of 1
+ if(NOT ${VAR}_COMPILED)
+ set(${VAR}_EXITCODE 1)
+ endif()
+ # if the return value was 0 then it worked
+ if("${${VAR}_EXITCODE}" EQUAL 0)
+ set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Success")
+ endif()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Performing Objective-C SOURCE FILE Test ${VAR} succeeded with the following compile output:\n"
+ "${OUTPUT}\n"
+ "...and run output:\n"
+ "${RUN_OUTPUT}\n"
+ "Return value: ${${VAR}}\n"
+ "Source file was:\n${SOURCE}\n")
+ else()
+ if(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN")
+ set(${VAR} "${${VAR}_EXITCODE}")
+ else()
+ set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
+ endif()
+
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Failed")
+ endif()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Performing Objective-C SOURCE FILE Test ${VAR} failed with the following compile output:\n"
+ "${OUTPUT}\n"
+ "...and run output:\n"
+ "${RUN_OUTPUT}\n"
+ "Return value: ${${VAR}_EXITCODE}\n"
+ "Source file was:\n${SOURCE}\n")
+
+ endif()
+ endif()
+endmacro()
diff --git a/Modules/CheckOBJCXXCompilerFlag.cmake b/Modules/CheckOBJCXXCompilerFlag.cmake
new file mode 100644
index 000000000..c32741b54
--- /dev/null
+++ b/Modules/CheckOBJCXXCompilerFlag.cmake
@@ -0,0 +1,64 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+CheckOBJCXXCompilerFlag
+-----------------------
+
+Check whether the Objective-C++ compiler supports a given flag.
+
+.. command:: check_objcxx_compiler_flag
+
+ .. code-block:: cmake
+
+ check_objcxx_compiler_flag(<flag> <var>)
+
+ Check that the ``<flag>`` is accepted by the compiler without
+ a diagnostic. Stores the result in an internal cache entry
+ named ``<var>``.
+
+This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable
+and calls the ``check_objcxx_source_compiles`` macro from the
+:module:`CheckOBJCXXSourceCompiles` module. See documentation of that
+module for a listing of variables that can otherwise modify the build.
+
+A positive result from this check indicates only that the compiler did not
+issue a diagnostic message when given the flag. Whether the flag has any
+effect or even a specific one is beyond the scope of this module.
+
+.. note::
+ Since the :command:`try_compile` command forwards flags from variables
+ like :variable:`CMAKE_OBJCXX_FLAGS <CMAKE_<LANG>_FLAGS>`, unknown flags
+ in such variables may cause a false negative for this check.
+#]=======================================================================]
+
+include_guard(GLOBAL)
+include(CheckOBJCXXSourceCompiles)
+include(CMakeCheckCompilerFlagCommonPatterns)
+
+macro (CHECK_OBJCXX_COMPILER_FLAG _FLAG _RESULT)
+ set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
+ set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
+
+ # Normalize locale during test compilation.
+ set(_CheckOBJCXXCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG)
+ foreach(v ${_CheckOBJCXXCompilerFlag_LOCALE_VARS})
+ set(_CheckOBJCXXCompilerFlag_SAVED_${v} "$ENV{${v}}")
+ set(ENV{${v}} OBJCXX)
+ endforeach()
+ CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckOBJCXXCompilerFlag_COMMON_PATTERNS)
+ CHECK_OBJCXX_SOURCE_COMPILES("#ifndef __OBJC__\n# error \"Not an Objective-C++ compiler\"\n#endif\nint main(void) { return 0; }" ${_RESULT}
+ # Some compilers do not fail with a bad flag
+ FAIL_REGEX "command line option .* is valid for .* but not for Objective-C\\\\+\\\\+" # GNU
+ FAIL_REGEX "argument unused during compilation: .*" # Clang
+ ${_CheckOBJCXXCompilerFlag_COMMON_PATTERNS}
+ )
+ foreach(v ${_CheckOBJCXXCompilerFlag_LOCALE_VARS})
+ set(ENV{${v}} ${_CheckOBJCXXCompilerFlag_SAVED_${v}})
+ unset(_CheckOBJCXXCompilerFlag_SAVED_${v})
+ endforeach()
+ unset(_CheckOBJCXXCompilerFlag_LOCALE_VARS)
+ unset(_CheckOBJCXXCompilerFlag_COMMON_PATTERNS)
+
+ set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
+endmacro ()
diff --git a/Modules/CheckOBJCXXSourceCompiles.cmake b/Modules/CheckOBJCXXSourceCompiles.cmake
new file mode 100644
index 000000000..4c0fdd0d3
--- /dev/null
+++ b/Modules/CheckOBJCXXSourceCompiles.cmake
@@ -0,0 +1,146 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+CheckOBJCXXSourceCompiles
+-------------------------
+
+Check if given Objective-C++ source compiles and links into an executable.
+
+.. command:: check_objcxx_source_compiles
+
+ .. code-block:: cmake
+
+ check_objcxx_source_compiles(<code> <resultVar>
+ [FAIL_REGEX <regex1> [<regex2>...]])
+
+ Check that the source supplied in ``<code>`` can be compiled as a Objective-C++ source
+ file and linked as an executable (so it must contain at least a ``main()``
+ function). The result will be stored in the internal cache variable specified
+ by ``<resultVar>``, with a boolean true value for success and boolean false
+ for failure. If ``FAIL_REGEX`` is provided, then failure is determined by
+ checking if anything in the output matches any of the specified regular
+ expressions.
+
+ The underlying check is performed by the :command:`try_compile` command. The
+ compile and link commands can be influenced by setting any of the following
+ variables prior to calling ``check_objcxx_source_compiles()``:
+
+ ``CMAKE_REQUIRED_FLAGS``
+ Additional flags to pass to the compiler. Note that the contents of
+ :variable:`CMAKE_OBJCXX_FLAGS <CMAKE_<LANG>_FLAGS>` and its associated
+ configuration-specific variable are automatically added to the compiler
+ command before the contents of ``CMAKE_REQUIRED_FLAGS``.
+
+ ``CMAKE_REQUIRED_DEFINITIONS``
+ A :ref:`;-list <CMake Language Lists>` of compiler definitions of the form
+ ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by
+ ``<resultVar>`` will also be added automatically.
+
+ ``CMAKE_REQUIRED_INCLUDES``
+ A :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler. These will be the only header search paths used by
+ ``try_compile()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES`
+ directory property will be ignored.
+
+ ``CMAKE_REQUIRED_LINK_OPTIONS``
+ A :ref:`;-list <CMake Language Lists>` of options to add to the link
+ command (see :command:`try_compile` for further details).
+
+ ``CMAKE_REQUIRED_LIBRARIES``
+ A :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. These can be the name of system libraries or they can be
+ :ref:`Imported Targets <Imported Targets>` (see :command:`try_compile` for
+ further details).
+
+ ``CMAKE_REQUIRED_QUIET``
+ If this variable evaluates to a boolean true value, all status messages
+ associated with the check will be suppressed.
+
+ The check is only performed once, with the result cached in the variable
+ named by ``<resultVar>``. Every subsequent CMake run will re-use this cached
+ value rather than performing the check again, even if the ``<code>`` changes.
+ In order to force the check to be re-evaluated, the variable named by
+ ``<resultVar>`` must be manually removed from the cache.
+
+#]=======================================================================]
+
+include_guard(GLOBAL)
+
+macro(CHECK_OBJCXX_SOURCE_COMPILES SOURCE VAR)
+ if(NOT DEFINED "${VAR}")
+ set(_FAIL_REGEX)
+ set(_key)
+ foreach(arg ${ARGN})
+ if("${arg}" MATCHES "^(FAIL_REGEX)$")
+ set(_key "${arg}")
+ elseif(_key)
+ list(APPEND _${_key} "${arg}")
+ else()
+ message(FATAL_ERROR "Unknown argument:\n ${arg}\n")
+ endif()
+ endforeach()
+
+ set(MACRO_CHECK_FUNCTION_DEFINITIONS
+ "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LINK_OPTIONS)
+ endif()
+ if(CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LIBRARIES
+ LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ else()
+ set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LIBRARIES)
+ endif()
+ if(CMAKE_REQUIRED_INCLUDES)
+ set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_INCLUDES
+ "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
+ else()
+ set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_INCLUDES)
+ endif()
+ file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.mm"
+ "${SOURCE}\n")
+
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR}")
+ endif()
+ try_compile(${VAR}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.mm
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_OBJCXX_SOURCE_COMPILES_ADD_LINK_OPTIONS}
+ ${CHECK_OBJCXX_SOURCE_COMPILES_ADD_LIBRARIES}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
+ "${CHECK_OBJCXX_SOURCE_COMPILES_ADD_INCLUDES}"
+ OUTPUT_VARIABLE OUTPUT)
+
+ foreach(_regex ${_FAIL_REGEX})
+ if("${OUTPUT}" MATCHES "${_regex}")
+ set(${VAR} 0)
+ endif()
+ endforeach()
+
+ if(${VAR})
+ set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Success")
+ endif()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Performing Objective-C++ SOURCE FILE Test ${VAR} succeeded with the following output:\n"
+ "${OUTPUT}\n"
+ "Source file was:\n${SOURCE}\n")
+ else()
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Failed")
+ endif()
+ set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Performing Objective-C++ SOURCE FILE Test ${VAR} failed with the following output:\n"
+ "${OUTPUT}\n"
+ "Source file was:\n${SOURCE}\n")
+ endif()
+ endif()
+endmacro()
diff --git a/Modules/CheckOBJCXXSourceRuns.cmake b/Modules/CheckOBJCXXSourceRuns.cmake
new file mode 100644
index 000000000..a3d5923e9
--- /dev/null
+++ b/Modules/CheckOBJCXXSourceRuns.cmake
@@ -0,0 +1,145 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+CheckOBJCXXSourceRuns
+---------------------
+
+Check if given Objective-C++ source compiles and links into an executable and can
+subsequently be run.
+
+.. command:: check_objcxx_source_runs
+
+ .. code-block:: cmake
+
+ check_objcxx_source_runs(<code> <resultVar>)
+
+ Check that the source supplied in ``<code>`` can be compiled as a Objective-C++ source
+ file, linked as an executable and then run. The ``<code>`` must contain at
+ least a ``main()`` function. If the ``<code>`` could be built and run
+ successfully, the internal cache variable specified by ``<resultVar>`` will
+ be set to 1, otherwise it will be set to an value that evaluates to boolean
+ false (e.g. an empty string or an error message).
+
+ The underlying check is performed by the :command:`try_run` command. The
+ compile and link commands can be influenced by setting any of the following
+ variables prior to calling ``check_objcxx_source_runs()``:
+
+ ``CMAKE_REQUIRED_FLAGS``
+ Additional flags to pass to the compiler. Note that the contents of
+ :variable:`CMAKE_OBJCXX_FLAGS <CMAKE_<LANG>_FLAGS>` and its associated
+ configuration-specific variable are automatically added to the compiler
+ command before the contents of ``CMAKE_REQUIRED_FLAGS``.
+
+ ``CMAKE_REQUIRED_DEFINITIONS``
+ A :ref:`;-list <CMake Language Lists>` of compiler definitions of the form
+ ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by
+ ``<resultVar>`` will also be added automatically.
+
+ ``CMAKE_REQUIRED_INCLUDES``
+ A :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler. These will be the only header search paths used by
+ ``try_run()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES`
+ directory property will be ignored.
+
+ ``CMAKE_REQUIRED_LINK_OPTIONS``
+ A :ref:`;-list <CMake Language Lists>` of options to add to the link
+ command (see :command:`try_run` for further details).
+
+ ``CMAKE_REQUIRED_LIBRARIES``
+ A :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. These can be the name of system libraries or they can be
+ :ref:`Imported Targets <Imported Targets>` (see :command:`try_run` for
+ further details).
+
+ ``CMAKE_REQUIRED_QUIET``
+ If this variable evaluates to a boolean true value, all status messages
+ associated with the check will be suppressed.
+
+ The check is only performed once, with the result cached in the variable
+ named by ``<resultVar>``. Every subsequent CMake run will re-use this cached
+ value rather than performing the check again, even if the ``<code>`` changes.
+ In order to force the check to be re-evaluated, the variable named by
+ ``<resultVar>`` must be manually removed from the cache.
+
+#]=======================================================================]
+
+include_guard(GLOBAL)
+
+macro(CHECK_OBJCXX_SOURCE_RUNS SOURCE VAR)
+ if(NOT DEFINED "${VAR}")
+ set(MACRO_CHECK_FUNCTION_DEFINITIONS
+ "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LINK_OPTIONS)
+ endif()
+ if(CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LIBRARIES
+ LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ else()
+ set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_LIBRARIES)
+ endif()
+ if(CMAKE_REQUIRED_INCLUDES)
+ set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_INCLUDES
+ "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
+ else()
+ set(CHECK_OBJCXX_SOURCE_COMPILES_ADD_INCLUDES)
+ endif()
+ file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.mm"
+ "${SOURCE}\n")
+
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR}")
+ endif()
+ try_run(${VAR}_EXITCODE ${VAR}_COMPILED
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.mm
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_OBJCXX_SOURCE_COMPILES_ADD_LINK_OPTIONS}
+ ${CHECK_OBJCXX_SOURCE_COMPILES_ADD_LIBRARIES}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
+ -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
+ "${CHECK_OBJCXX_SOURCE_COMPILES_ADD_INCLUDES}"
+ COMPILE_OUTPUT_VARIABLE OUTPUT
+ RUN_OUTPUT_VARIABLE RUN_OUTPUT)
+
+ # if it did not compile make the return value fail code of 1
+ if(NOT ${VAR}_COMPILED)
+ set(${VAR}_EXITCODE 1)
+ endif()
+ # if the return value was 0 then it worked
+ if("${${VAR}_EXITCODE}" EQUAL 0)
+ set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Success")
+ endif()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Performing Objective-C++ SOURCE FILE Test ${VAR} succeeded with the following output:\n"
+ "${OUTPUT}\n"
+ "...and run output:\n"
+ "${RUN_OUTPUT}\n"
+ "Return value: ${${VAR}}\n"
+ "Source file was:\n${SOURCE}\n")
+ else()
+ if(CMAKE_CROSSCOMPILING AND "${${VAR}_EXITCODE}" MATCHES "FAILED_TO_RUN")
+ set(${VAR} "${${VAR}_EXITCODE}")
+ else()
+ set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
+ endif()
+
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Failed")
+ endif()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Performing Objective-C++ SOURCE FILE Test ${VAR} failed with the following output:\n"
+ "${OUTPUT}\n"
+ "...and run output:\n"
+ "${RUN_OUTPUT}\n"
+ "Return value: ${${VAR}_EXITCODE}\n"
+ "Source file was:\n${SOURCE}\n")
+ endif()
+ endif()
+endmacro()
diff --git a/Modules/CheckPIESupported.cmake b/Modules/CheckPIESupported.cmake
new file mode 100644
index 000000000..6d63f0bad
--- /dev/null
+++ b/Modules/CheckPIESupported.cmake
@@ -0,0 +1,134 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+CheckPIESupported
+-----------------
+
+Check whether the linker supports Position Independent Code (PIE) or No
+Position Independent Code (NO_PIE) for executables.
+Use this to ensure that the :prop_tgt:`POSITION_INDEPENDENT_CODE` target
+property for executables will be honored at link time.
+
+.. command:: check_pie_supported
+
+ ::
+
+ check_pie_supported([OUTPUT_VARIABLE <output>]
+ [LANGUAGES <lang>...])
+
+ Options are:
+
+ ``OUTPUT_VARIABLE <output>``
+ Set ``<output>`` variable with details about any error.
+ ``LANGUAGES <lang>...``
+ Check the linkers used for each of the specified languages.
+ Supported languages are ``C``, ``CXX``, and ``Fortran``.
+
+It makes no sense to use this module when :policy:`CMP0083` is set to ``OLD``,
+so the command will return an error in this case. See policy :policy:`CMP0083`
+for details.
+
+Variables
+^^^^^^^^^
+
+For each language checked, two boolean cache variables are defined.
+
+ ``CMAKE_<lang>_LINK_PIE_SUPPORTED``
+ Set to ``YES`` if ``PIE`` is supported by the linker and ``NO`` otherwise.
+ ``CMAKE_<lang>_LINK_NO_PIE_SUPPORTED``
+ Set to ``YES`` if ``NO_PIE`` is supported by the linker and ``NO`` otherwise.
+
+Examples
+^^^^^^^^
+
+.. code-block:: cmake
+
+ check_pie_supported()
+ set_property(TARGET foo PROPERTY POSITION_INDEPENDENT_CODE TRUE)
+
+.. code-block:: cmake
+
+ # Retrieve any error message.
+ check_pie_supported(OUTPUT_VARIABLE output LANGUAGES C)
+ set_property(TARGET foo PROPERTY POSITION_INDEPENDENT_CODE TRUE)
+ if(NOT CMAKE_C_LINK_PIE_SUPPORTED)
+ message(WARNING "PIE is not supported at link time: ${output}.\n"
+ "PIE link options will not be passed to linker.")
+ endif()
+
+#]=======================================================================]
+
+
+include (Internal/CMakeCheckCompilerFlag)
+
+function (check_pie_supported)
+ cmake_policy(GET CMP0083 cmp0083)
+
+ if (NOT cmp0083)
+ message(FATAL_ERROR "check_pie_supported: Policy CMP0083 is not set")
+ endif()
+
+ if(cmp0083 STREQUAL "OLD")
+ message(FATAL_ERROR "check_pie_supported: Policy CMP0083 set to OLD")
+ endif()
+
+ set(optional)
+ set(one OUTPUT_VARIABLE)
+ set(multiple LANGUAGES)
+
+ cmake_parse_arguments(CHECK_PIE "${optional}" "${one}" "${multiple}" "${ARGN}")
+ if(CHECK_PIE_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "check_pie_supported: Unparsed arguments: ${CHECK_PIE_UNPARSED_ARGUMENTS}")
+ endif()
+
+ if (CHECK_PIE_LANGUAGES)
+ set (unsupported_languages "${CHECK_PIE_LANGUAGES}")
+ list (REMOVE_ITEM unsupported_languages "C" "CXX" "Fortran")
+ if(unsupported_languages)
+ message(FATAL_ERROR "check_pie_supported: language(s) '${unsupported_languages}' not supported")
+ endif()
+ else()
+ # User did not set any languages, use defaults
+ get_property (enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
+ if (NOT enabled_languages)
+ return()
+ endif()
+
+ list (FILTER enabled_languages INCLUDE REGEX "^(C|CXX|Fortran)$")
+ if (NOT enabled_languages)
+ return()
+ endif()
+
+ set (CHECK_PIE_LANGUAGES ${enabled_languages})
+ endif()
+
+ set (outputs)
+
+ foreach(lang IN LISTS CHECK_PIE_LANGUAGES)
+ if(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER)
+ cmake_check_compiler_flag(${lang} "${CMAKE_${lang}_LINK_OPTIONS_PIE}"
+ CMAKE_${lang}_LINK_PIE_SUPPORTED
+ OUTPUT_VARIABLE output)
+ if (NOT CMAKE_${lang}_LINK_PIE_SUPPORTED)
+ string (APPEND outputs "PIE (${lang}): ${output}\n")
+ endif()
+
+ cmake_check_compiler_flag(${lang} "${CMAKE_${lang}_LINK_OPTIONS_NO_PIE}"
+ CMAKE_${lang}_LINK_NO_PIE_SUPPORTED
+ OUTPUT_VARIABLE output)
+ if (NOT CMAKE_${lang}_LINK_NO_PIE_SUPPORTED)
+ string (APPEND outputs "NO_PIE (${lang}): ${output}\n")
+ endif()
+ else()
+ # no support at link time. Set cache variables to NO
+ set(CMAKE_${lang}_LINK_PIE_SUPPORTED NO CACHE INTERNAL "PIE (${lang})")
+ set(CMAKE_${lang}_LINK_NO_PIE_SUPPORTED NO CACHE INTERNAL "NO_PIE (${lang})")
+ string (APPEND outputs "PIE and NO_PIE are not supported by linker for ${lang}")
+ endif()
+ endforeach()
+
+ if (CHECK_PIE_OUTPUT_VARIABLE)
+ set (${CHECK_PIE_OUTPUT_VARIABLE} "${outputs}" PARENT_SCOPE)
+ endif()
+endfunction()
diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake
index 785959496..a7b020c06 100644
--- a/Modules/CheckPrototypeDefinition.cmake
+++ b/Modules/CheckPrototypeDefinition.cmake
@@ -1,56 +1,68 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckPrototypeDefinition
-# ------------------------
-#
-# Check if the protoype we expect is correct.
-#
-# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE)
-#
-# ::
-#
-# FUNCTION - The name of the function (used to check if prototype exists)
-# PROTOTYPE- The prototype to check.
-# RETURN - The return value of the function.
-# HEADER - The header files required.
-# VARIABLE - The variable to store the result.
-# Will be created as an internal cache variable.
-#
-# Example:
-#
-# ::
-#
-# check_prototype_definition(getpwent_r
-# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)"
-# "NULL"
-# "unistd.h;pwd.h"
-# SOLARIS_GETPWENT_R)
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ::
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-# CMAKE_REQUIRED_QUIET = execute quietly without messages
+#[=======================================================================[.rst:
+CheckPrototypeDefinition
+------------------------
-#
+Check if the prototype we expect is correct.
+
+.. command:: check_prototype_definition
+
+ .. code-block:: cmake
+ check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE)
+
+ ::
+
+ FUNCTION - The name of the function (used to check if prototype exists)
+ PROTOTYPE- The prototype to check.
+ RETURN - The return value of the function.
+ HEADER - The header files required.
+ VARIABLE - The variable to store the result.
+ Will be created as an internal cache variable.
+
+ Example:
+
+ .. code-block:: cmake
+
+ check_prototype_definition(getpwent_r
+ "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)"
+ "NULL"
+ "unistd.h;pwd.h"
+ SOLARIS_GETPWENT_R)
+
+The following variables may be set before calling this function to modify
+the way the check is run:
+
+::
+
+ CMAKE_REQUIRED_FLAGS = string of compile command line flags
+ CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+ CMAKE_REQUIRED_INCLUDES = list of include directories
+ CMAKE_REQUIRED_LINK_OPTIONS = list of options to pass to link command
+ CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+ CMAKE_REQUIRED_QUIET = execute quietly without messages
+#]=======================================================================]
+
+#
get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
+include_guard(GLOBAL)
-function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
+function(check_prototype_definition _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
if (NOT DEFINED ${_VARIABLE})
set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n")
set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ if (CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_PROTOTYPE_DEFINITION_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_PROTOTYPE_DEFINITION_LINK_OPTIONS)
+ endif()
if (CMAKE_REQUIRED_LIBRARIES)
set(CHECK_PROTOTYPE_DEFINITION_LIBS
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -82,6 +94,7 @@ function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIAB
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_PROTOTYPE_DEFINITION_LINK_OPTIONS}
${CHECK_PROTOTYPE_DEFINITION_LIBS}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS}
"${CMAKE_SYMBOL_EXISTS_INCLUDES}"
diff --git a/Modules/CheckStructHasMember.cmake b/Modules/CheckStructHasMember.cmake
index 085b46492..842a8fdb7 100644
--- a/Modules/CheckStructHasMember.cmake
+++ b/Modules/CheckStructHasMember.cmake
@@ -1,74 +1,82 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckStructHasMember
-# --------------------
-#
-# Check if the given struct or class has the specified member variable
-#
-# ::
-#
-# CHECK_STRUCT_HAS_MEMBER(<struct> <member> <header> <variable>
-# [LANGUAGE <language>])
-#
-# ::
-#
-# <struct> - the name of the struct or class you are interested in
-# <member> - the member which existence you want to check
-# <header> - the header(s) where the prototype should be declared
-# <variable> - variable to store the result
-# <language> - the compiler to use (C or CXX)
-#
-#
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ::
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-# CMAKE_REQUIRED_QUIET = execute quietly without messages
-#
-#
-#
-# Example: CHECK_STRUCT_HAS_MEMBER("struct timeval" tv_sec sys/select.h
-# HAVE_TIMEVAL_TV_SEC LANGUAGE C)
+#[=======================================================================[.rst:
+CheckStructHasMember
+--------------------
+Check if the given struct or class has the specified member variable
+
+.. command:: CHECK_STRUCT_HAS_MEMBER
+
+ .. code-block:: cmake
+
+ CHECK_STRUCT_HAS_MEMBER(<struct> <member> <header> <variable>
+ [LANGUAGE <language>])
+
+ ::
+
+ <struct> - the name of the struct or class you are interested in
+ <member> - the member which existence you want to check
+ <header> - the header(s) where the prototype should be declared
+ <variable> - variable to store the result
+ <language> - the compiler to use (C or CXX)
+
+
+
+The following variables may be set before calling this macro to modify
+the way the check is run:
+
+::
+
+ CMAKE_REQUIRED_FLAGS = string of compile command line flags
+ CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+ CMAKE_REQUIRED_INCLUDES = list of include directories
+ CMAKE_REQUIRED_LINK_OPTIONS = list of options to pass to link command
+ CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+ CMAKE_REQUIRED_QUIET = execute quietly without messages
+
+
+Example:
+
+.. code-block:: cmake
+
+ CHECK_STRUCT_HAS_MEMBER("struct timeval" tv_sec sys/select.h
+ HAVE_TIMEVAL_TV_SEC LANGUAGE C)
+#]=======================================================================]
+
+include_guard(GLOBAL)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
macro (CHECK_STRUCT_HAS_MEMBER _STRUCT _MEMBER _HEADER _RESULT)
- set(_INCLUDE_FILES)
- foreach (it ${_HEADER})
- string(APPEND _INCLUDE_FILES "#include <${it}>\n")
- endforeach ()
-
- if("x${ARGN}" STREQUAL "x")
- set(_lang C)
- elseif("x${ARGN}" MATCHES "^xLANGUAGE;([a-zA-Z]+)$")
- set(_lang "${CMAKE_MATCH_1}")
- else()
- message(FATAL_ERROR "Unknown arguments:\n ${ARGN}\n")
- endif()
-
- set(_CHECK_STRUCT_MEMBER_SOURCE_CODE "
+ set(_INCLUDE_FILES)
+ foreach (it ${_HEADER})
+ string(APPEND _INCLUDE_FILES "#include <${it}>\n")
+ endforeach ()
+
+ if("x${ARGN}" STREQUAL "x")
+ set(_lang C)
+ elseif("x${ARGN}" MATCHES "^xLANGUAGE;([a-zA-Z]+)$")
+ set(_lang "${CMAKE_MATCH_1}")
+ else()
+ message(FATAL_ERROR "Unknown arguments:\n ${ARGN}\n")
+ endif()
+
+ set(_CHECK_STRUCT_MEMBER_SOURCE_CODE "
${_INCLUDE_FILES}
int main()
{
- (void)sizeof(((${_STRUCT} *)0)->${_MEMBER});
- return 0;
+ (void)sizeof(((${_STRUCT} *)0)->${_MEMBER});
+ return 0;
}
")
- if("${_lang}" STREQUAL "C")
- CHECK_C_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT})
- elseif("${_lang}" STREQUAL "CXX")
- CHECK_CXX_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT})
- else()
- message(FATAL_ERROR "Unknown language:\n ${_lang}\nSupported languages: C, CXX.\n")
- endif()
+ if("${_lang}" STREQUAL "C")
+ CHECK_C_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT})
+ elseif("${_lang}" STREQUAL "CXX")
+ CHECK_CXX_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT})
+ else()
+ message(FATAL_ERROR "Unknown language:\n ${_lang}\nSupported languages: C, CXX.\n")
+ endif()
endmacro ()
diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake
index 6f1afcfda..105338301 100644
--- a/Modules/CheckSymbolExists.cmake
+++ b/Modules/CheckSymbolExists.cmake
@@ -10,7 +10,7 @@ or macro in ``C``.
.. command:: check_symbol_exists
- ::
+ .. code-block:: cmake
check_symbol_exists(<symbol> <files> <variable>)
@@ -32,31 +32,57 @@ The following variables may be set before calling this macro to modify
the way the check is run:
``CMAKE_REQUIRED_FLAGS``
- string of compile command line flags
+ string of compile command line flags.
``CMAKE_REQUIRED_DEFINITIONS``
- list of macros to define (-DFOO=bar)
+ a :ref:`;-list <CMake Language Lists>` of macros to define (-DFOO=bar).
``CMAKE_REQUIRED_INCLUDES``
- list of include directories
+ a :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler.
+``CMAKE_REQUIRED_LINK_OPTIONS``
+ a :ref:`;-list <CMake Language Lists>` of options to add to the link command.
``CMAKE_REQUIRED_LIBRARIES``
- list of libraries to link
+ a :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. See policy :policy:`CMP0075`.
``CMAKE_REQUIRED_QUIET``
- execute quietly without messages
+ execute quietly without messages.
+
+For example:
+
+.. code-block:: cmake
+
+ include(CheckSymbolExists)
+
+ # Check for macro SEEK_SET
+ check_symbol_exists(SEEK_SET "stdio.h" HAVE_SEEK_SET)
+ # Check for function fopen
+ check_symbol_exists(fopen "stdio.h" HAVE_FOPEN)
#]=======================================================================]
+include_guard(GLOBAL)
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced
+
macro(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE)
if(CMAKE_C_COMPILER_LOADED)
- _CHECK_SYMBOL_EXISTS("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c" "${SYMBOL}" "${FILES}" "${VARIABLE}" )
+ __CHECK_SYMBOL_EXISTS_IMPL("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c" "${SYMBOL}" "${FILES}" "${VARIABLE}" )
elseif(CMAKE_CXX_COMPILER_LOADED)
- _CHECK_SYMBOL_EXISTS("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.cxx" "${SYMBOL}" "${FILES}" "${VARIABLE}" )
+ __CHECK_SYMBOL_EXISTS_IMPL("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.cxx" "${SYMBOL}" "${FILES}" "${VARIABLE}" )
else()
message(FATAL_ERROR "CHECK_SYMBOL_EXISTS needs either C or CXX language enabled")
endif()
endmacro()
-macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
+macro(__CHECK_SYMBOL_EXISTS_IMPL SOURCEFILE SYMBOL FILES VARIABLE)
if(NOT DEFINED "${VARIABLE}" OR "x${${VARIABLE}}" STREQUAL "x${VARIABLE}")
set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n")
set(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_SYMBOL_EXISTS_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_SYMBOL_EXISTS_LINK_OPTIONS)
+ endif()
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_SYMBOL_EXISTS_LIBS
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -73,8 +99,28 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT
"#include <${FILE}>\n")
endforeach()
- string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT
- "\nint main(int argc, char** argv)\n{\n (void)argv;\n#ifndef ${SYMBOL}\n return ((int*)(&${SYMBOL}))[argc];\n#else\n (void)argc;\n return 0;\n#endif\n}\n")
+ string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT "
+int main(int argc, char** argv)
+{
+ (void)argv;")
+ set(_CSE_CHECK_NON_MACRO "return ((int*)(&${SYMBOL}))[argc];")
+ if("${SYMBOL}" MATCHES "^[a-zA-Z_][a-zA-Z0-9_]*$")
+ # The SYMBOL has a legal macro name. Test whether it exists as a macro.
+ string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT "
+#ifndef ${SYMBOL}
+ ${_CSE_CHECK_NON_MACRO}
+#else
+ (void)argc;
+ return 0;
+#endif")
+ else()
+ # The SYMBOL cannot be a macro (e.g., a template function).
+ string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT "
+ ${_CSE_CHECK_NON_MACRO}")
+ endif()
+ string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT "
+}")
+ unset(_CSE_CHECK_NON_MACRO)
configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
"${SOURCEFILE}" @ONLY)
@@ -86,6 +132,7 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
${CMAKE_BINARY_DIR}
"${SOURCEFILE}"
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_SYMBOL_EXISTS_LINK_OPTIONS}
${CHECK_SYMBOL_EXISTS_LIBS}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_SYMBOL_EXISTS_FLAGS}
@@ -112,5 +159,8 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
"${OUTPUT}\nFile ${SOURCEFILE}:\n"
"${CMAKE_CONFIGURABLE_FILE_CONTENT}\n")
endif()
+ unset(CMAKE_CONFIGURABLE_FILE_CONTENT)
endif()
endmacro()
+
+cmake_policy(POP)
diff --git a/Modules/CheckTypeSize.c.in b/Modules/CheckTypeSize.c.in
index b6c368801..82035a336 100644
--- a/Modules/CheckTypeSize.c.in
+++ b/Modules/CheckTypeSize.c.in
@@ -9,10 +9,16 @@
# define KEY '_','_','p','p','c','_','_'
#elif defined(__ppc64__)
# define KEY '_','_','p','p','c','6','4','_','_'
+#elif defined(__aarch64__)
+# define KEY '_','_','a','a','r','c','h','6','4','_','_'
+#elif defined(__ARM_ARCH_7A__)
+# define KEY '_','_','A','R','M','_','A','R','C','H','_','7','A','_','_'
+#elif defined(__ARM_ARCH_7S__)
+# define KEY '_','_','A','R','M','_','A','R','C','H','_','7','S','_','_'
#endif
#define SIZE (sizeof(@type@))
-char info_size[] = {'I', 'N', 'F', 'O', ':', 's','i','z','e','[',
+static char info_size[] = {'I', 'N', 'F', 'O', ':', 's','i','z','e','[',
('0' + ((SIZE / 10000)%10)),
('0' + ((SIZE / 1000)%10)),
('0' + ((SIZE / 100)%10)),
diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake
index fcf1df740..372737307 100644
--- a/Modules/CheckTypeSize.cmake
+++ b/Modules/CheckTypeSize.cmake
@@ -1,81 +1,87 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckTypeSize
-# -------------
-#
-# Check sizeof a type
-#
-# ::
-#
-# CHECK_TYPE_SIZE(TYPE VARIABLE [BUILTIN_TYPES_ONLY]
-# [LANGUAGE <language>])
-#
-# Check if the type exists and determine its size. On return,
-# "HAVE_${VARIABLE}" holds the existence of the type, and "${VARIABLE}"
-# holds one of the following:
-#
-# ::
-#
-# <size> = type has non-zero size <size>
-# "0" = type has arch-dependent size (see below)
-# "" = type does not exist
-#
-# Both ``HAVE_${VARIABLE}`` and ``${VARIABLE}`` will be created as internal
-# cache variables.
-#
-# Furthermore, the variable "${VARIABLE}_CODE" holds C preprocessor code
-# to define the macro "${VARIABLE}" to the size of the type, or leave
-# the macro undefined if the type does not exist.
-#
-# The variable "${VARIABLE}" may be "0" when CMAKE_OSX_ARCHITECTURES has
-# multiple architectures for building OS X universal binaries. This
-# indicates that the type size varies across architectures. In this
-# case "${VARIABLE}_CODE" contains C preprocessor tests mapping from
-# each architecture macro to the corresponding type size. The list of
-# architecture macros is stored in "${VARIABLE}_KEYS", and the value for
-# each key is stored in "${VARIABLE}-${KEY}".
-#
-# If the BUILTIN_TYPES_ONLY option is not given, the macro checks for
-# headers <sys/types.h>, <stdint.h>, and <stddef.h>, and saves results
-# in HAVE_SYS_TYPES_H, HAVE_STDINT_H, and HAVE_STDDEF_H. The type size
-# check automatically includes the available headers, thus supporting
-# checks of types defined in the headers.
-#
-# If LANGUAGE is set, the specified compiler will be used to perform the
-# check. Acceptable values are C and CXX
-#
-# Despite the name of the macro you may use it to check the size of more
-# complex expressions, too. To check e.g. for the size of a struct
-# member you can do something like this:
-#
-# ::
-#
-# check_type_size("((struct something*)0)->member" SIZEOF_MEMBER)
-#
-#
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ::
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_INCLUDES = list of include directories
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-# CMAKE_REQUIRED_QUIET = execute quietly without messages
-# CMAKE_EXTRA_INCLUDE_FILES = list of extra headers to include
+#[=======================================================================[.rst:
+CheckTypeSize
+-------------
+
+Check sizeof a type
+
+.. command:: CHECK_TYPE_SIZE
+
+ .. code-block:: cmake
+
+ CHECK_TYPE_SIZE(TYPE VARIABLE [BUILTIN_TYPES_ONLY]
+ [LANGUAGE <language>])
+
+ Check if the type exists and determine its size. On return,
+ ``HAVE_${VARIABLE}`` holds the existence of the type, and ``${VARIABLE}``
+ holds one of the following:
+
+ ::
+
+ <size> = type has non-zero size <size>
+ "0" = type has arch-dependent size (see below)
+ "" = type does not exist
+
+ Both ``HAVE_${VARIABLE}`` and ``${VARIABLE}`` will be created as internal
+ cache variables.
+
+ Furthermore, the variable ``${VARIABLE}_CODE`` holds C preprocessor code
+ to define the macro ``${VARIABLE}`` to the size of the type, or leave
+ the macro undefined if the type does not exist.
+
+ The variable ``${VARIABLE}`` may be ``0`` when
+ :variable:`CMAKE_OSX_ARCHITECTURES` has multiple architectures for building
+ OS X universal binaries. This indicates that the type size varies across
+ architectures. In this case ``${VARIABLE}_CODE`` contains C preprocessor
+ tests mapping from each architecture macro to the corresponding type size.
+ The list of architecture macros is stored in ``${VARIABLE}_KEYS``, and the
+ value for each key is stored in ``${VARIABLE}-${KEY}``.
+
+ If the ``BUILTIN_TYPES_ONLY`` option is not given, the macro checks for
+ headers ``<sys/types.h>``, ``<stdint.h>``, and ``<stddef.h>``, and saves
+ results in ``HAVE_SYS_TYPES_H``, ``HAVE_STDINT_H``, and ``HAVE_STDDEF_H``.
+ The type size check automatically includes the available headers, thus
+ supporting checks of types defined in the headers.
+
+ If ``LANGUAGE`` is set, the specified compiler will be used to perform the
+ check. Acceptable values are ``C`` and ``CXX``.
+
+Despite the name of the macro you may use it to check the size of more
+complex expressions, too. To check e.g. for the size of a struct
+member you can do something like this:
+
+.. code-block:: cmake
+
+ check_type_size("((struct something*)0)->member" SIZEOF_MEMBER)
+
+
+
+The following variables may be set before calling this macro to modify
+the way the check is run:
+
+::
+
+ CMAKE_REQUIRED_FLAGS = string of compile command line flags
+ CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+ CMAKE_REQUIRED_INCLUDES = list of include directories
+ CMAKE_REQUIRED_LINK_OPTIONS = list of options to pass to link command
+ CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+ CMAKE_REQUIRED_QUIET = execute quietly without messages
+ CMAKE_EXTRA_INCLUDE_FILES = list of extra headers to include
+#]=======================================================================]
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
+get_filename_component(__check_type_size_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+include_guard(GLOBAL)
+
cmake_policy(PUSH)
cmake_policy(SET CMP0054 NEW)
-get_filename_component(__check_type_size_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
-
#-----------------------------------------------------------------------------
# Helper function. DO NOT CALL DIRECTLY.
function(__check_type_size_impl type var map builtin language)
@@ -113,6 +119,7 @@ function(__check_type_size_impl type var map builtin language)
configure_file(${__check_type_size_dir}/CheckTypeSize.c.in ${src} @ONLY)
try_compile(HAVE_${var} ${CMAKE_BINARY_DIR} ${src}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}
CMAKE_FLAGS
"-DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}"
diff --git a/Modules/CheckVariableExists.c b/Modules/CheckVariableExists.c
index 6e948771b..d68afb46a 100644
--- a/Modules/CheckVariableExists.c
+++ b/Modules/CheckVariableExists.c
@@ -2,15 +2,15 @@
extern int CHECK_VARIABLE_EXISTS;
-#ifdef __CLASSIC_C__
+# ifdef __CLASSIC_C__
int main()
{
int ac;
char* av[];
-#else
+# else
int main(int ac, char* av[])
{
-#endif
+# endif
if (ac > 1000) {
return *av[0];
}
@@ -19,6 +19,6 @@ int main(int ac, char* av[])
#else /* CHECK_VARIABLE_EXISTS */
-#error "CHECK_VARIABLE_EXISTS has to specify the variable"
+# error "CHECK_VARIABLE_EXISTS has to specify the variable"
#endif /* CHECK_VARIABLE_EXISTS */
diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake
index fd5c36c6a..f4953a349 100644
--- a/Modules/CheckVariableExists.cmake
+++ b/Modules/CheckVariableExists.cmake
@@ -1,36 +1,41 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# CheckVariableExists
-# -------------------
-#
-# Check if the variable exists.
-#
-# ::
-#
-# CHECK_VARIABLE_EXISTS(VAR VARIABLE)
-#
-#
-#
-# ::
-#
-# VAR - the name of the variable
-# VARIABLE - variable to store the result
-# Will be created as an internal cache variable.
-#
-#
-# This macro is only for C variables.
-#
-# The following variables may be set before calling this macro to modify
-# the way the check is run:
-#
-# ::
-#
-# CMAKE_REQUIRED_FLAGS = string of compile command line flags
-# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
-# CMAKE_REQUIRED_QUIET = execute quietly without messages
+#[=======================================================================[.rst:
+CheckVariableExists
+-------------------
+
+Check if the variable exists.
+
+.. command:: CHECK_VARIABLE_EXISTS
+
+ .. code-block:: cmake
+
+ CHECK_VARIABLE_EXISTS(VAR VARIABLE)
+
+
+ ::
+
+ VAR - the name of the variable
+ VARIABLE - variable to store the result
+ Will be created as an internal cache variable.
+
+
+ This macro is only for ``C`` variables.
+
+The following variables may be set before calling this macro to modify
+the way the check is run:
+
+::
+
+ CMAKE_REQUIRED_FLAGS = string of compile command line flags
+ CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
+ CMAKE_REQUIRED_LINK_OPTIONS = list of options to pass to link command
+ CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+ CMAKE_REQUIRED_QUIET = execute quietly without messages
+#]=======================================================================]
+
+include_guard(GLOBAL)
macro(CHECK_VARIABLE_EXISTS VAR VARIABLE)
if(NOT DEFINED "${VARIABLE}")
@@ -39,6 +44,12 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE)
if(NOT CMAKE_REQUIRED_QUIET)
message(STATUS "Looking for ${VAR}")
endif()
+ if(CMAKE_REQUIRED_LINK_OPTIONS)
+ set(CHECK_VARIABLE_EXISTS_ADD_LINK_OPTIONS
+ LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+ else()
+ set(CHECK_VARIABLE_EXISTS_ADD_LINK_OPTIONS)
+ endif()
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -49,6 +60,7 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE)
${CMAKE_BINARY_DIR}
${CMAKE_ROOT}/Modules/CheckVariableExists.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_VARIABLE_EXISTS_ADD_LINK_OPTIONS}
${CHECK_VARIABLE_EXISTS_ADD_LIBRARIES}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_VARIABLE_DEFINITIONS}
OUTPUT_VARIABLE OUTPUT)
diff --git a/Modules/Compiler/ARMCC-ASM.cmake b/Modules/Compiler/ARMCC-ASM.cmake
index 539d5259f..5819fc756 100644
--- a/Modules/Compiler/ARMCC-ASM.cmake
+++ b/Modules/Compiler/ARMCC-ASM.cmake
@@ -4,4 +4,4 @@ set(CMAKE_ASM_OUTPUT_EXTENSION ".o")
set(CMAKE_ASM_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>")
-set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa)
+set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS S;s;asm;msa)
diff --git a/Modules/Compiler/ARMCC-DetermineCompiler.cmake b/Modules/Compiler/ARMCC-DetermineCompiler.cmake
index a3667d7c2..5f2d0f846 100644
--- a/Modules/Compiler/ARMCC-DetermineCompiler.cmake
+++ b/Modules/Compiler/ARMCC-DetermineCompiler.cmake
@@ -1,5 +1,5 @@
# ARMCC Toolchain
-set(_compiler_id_pp_test "defined(__ARMCC_VERSION)")
+set(_compiler_id_pp_test "defined(__ARMCC_VERSION) && !defined(__clang__)")
set(_compiler_id_version_compute "
#if __ARMCC_VERSION >= 1000000
diff --git a/Modules/Compiler/ARMCC.cmake b/Modules/Compiler/ARMCC.cmake
index 250a8f481..f94956821 100644
--- a/Modules/Compiler/ARMCC.cmake
+++ b/Modules/Compiler/ARMCC.cmake
@@ -34,4 +34,6 @@ macro(__compiler_armcc lang)
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> --create -cr <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_DEPFILE_FLAGS_${lang} "--depend=<DEPFILE> --depend_single_line --no_depend_system_headers")
+
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ")
endmacro()
diff --git a/Modules/Compiler/ARMClang-ASM.cmake b/Modules/Compiler/ARMClang-ASM.cmake
new file mode 100644
index 000000000..ceff3e8ce
--- /dev/null
+++ b/Modules/Compiler/ARMClang-ASM.cmake
@@ -0,0 +1,9 @@
+include(Compiler/ARMClang)
+
+set(CMAKE_ASM_OUTPUT_EXTENSION ".o")
+set(CMAKE_ASM_OUTPUT_EXTENSION_REPLACE 1)
+
+set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <INCLUDES> <FLAGS> -c -o <OBJECT> <SOURCE>")
+set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS S;s;asm;msa)
+
+__compiler_armclang(ASM)
diff --git a/Modules/Compiler/ARMClang-C-FeatureTests.cmake b/Modules/Compiler/ARMClang-C-FeatureTests.cmake
new file mode 100644
index 000000000..ef79229d0
--- /dev/null
+++ b/Modules/Compiler/ARMClang-C-FeatureTests.cmake
@@ -0,0 +1 @@
+include(Compiler/Clang-C-FeatureTests)
diff --git a/Modules/Compiler/ARMClang-C.cmake b/Modules/Compiler/ARMClang-C.cmake
new file mode 100644
index 000000000..0a64a8a4f
--- /dev/null
+++ b/Modules/Compiler/ARMClang-C.cmake
@@ -0,0 +1,15 @@
+include(Compiler/Clang-C)
+include(Compiler/ARMClang)
+__compiler_armclang(C)
+
+set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
+set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
+set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
+
+set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
+set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
+
+set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
+set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
diff --git a/Modules/Compiler/ARMClang-CXX-FeatureTests.cmake b/Modules/Compiler/ARMClang-CXX-FeatureTests.cmake
new file mode 100644
index 000000000..e038e807b
--- /dev/null
+++ b/Modules/Compiler/ARMClang-CXX-FeatureTests.cmake
@@ -0,0 +1 @@
+include(Compiler/Clang-CXX-FeatureTests)
diff --git a/Modules/Compiler/ARMClang-CXX.cmake b/Modules/Compiler/ARMClang-CXX.cmake
new file mode 100644
index 000000000..5dfb4011e
--- /dev/null
+++ b/Modules/Compiler/ARMClang-CXX.cmake
@@ -0,0 +1,3 @@
+include(Compiler/Clang-CXX)
+include(Compiler/ARMClang)
+__compiler_armclang(CXX)
diff --git a/Modules/Compiler/ARMClang-DetermineCompiler.cmake b/Modules/Compiler/ARMClang-DetermineCompiler.cmake
new file mode 100644
index 000000000..eb0de5306
--- /dev/null
+++ b/Modules/Compiler/ARMClang-DetermineCompiler.cmake
@@ -0,0 +1,10 @@
+# ARMClang Toolchain
+set(_compiler_id_pp_test "defined(__clang__) && defined(__ARMCOMPILER_VERSION)")
+
+set(_compiler_id_version_compute "
+ # define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__ARMCOMPILER_VERSION/1000000)
+ # define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__ARMCOMPILER_VERSION/10000 % 100)
+ # define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__ARMCOMPILER_VERSION % 10000)")
+
+string(APPEND _compiler_id_version_compute "
+# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__ARMCOMPILER_VERSION)")
diff --git a/Modules/Compiler/ARMClang.cmake b/Modules/Compiler/ARMClang.cmake
new file mode 100644
index 000000000..2518ac714
--- /dev/null
+++ b/Modules/Compiler/ARMClang.cmake
@@ -0,0 +1,71 @@
+if(_ARMClang_CMAKE_LOADED)
+ return()
+endif()
+set(_ARMClang_CMAKE_LOADED TRUE)
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
+get_filename_component(_CMAKE_C_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH)
+get_filename_component(_CMAKE_CXX_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH)
+
+set(CMAKE_EXECUTABLE_SUFFIX ".elf")
+
+find_program(CMAKE_ARMClang_LINKER armlink HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" )
+find_program(CMAKE_ARMClang_AR armar HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" )
+
+set(CMAKE_LINKER "${CMAKE_ARMClang_LINKER}" CACHE FILEPATH "The ARMClang linker" FORCE)
+mark_as_advanced(CMAKE_ARMClang_LINKER)
+set(CMAKE_AR "${CMAKE_ARMClang_AR}" CACHE FILEPATH "The ARMClang archiver" FORCE)
+mark_as_advanced(CMAKE_ARMClang_AR)
+
+# get compiler supported cpu list
+function(__armclang_set_processor_list lang out_var)
+ execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" --target=${CMAKE_${lang}_COMPILER_TARGET} -mcpu=list
+ OUTPUT_VARIABLE processor_list
+ ERROR_VARIABLE processor_list)
+ string(REGEX MATCHALL "-mcpu=([^ \n]*)" processor_list "${processor_list}")
+ string(REGEX REPLACE "-mcpu=" "" processor_list "${processor_list}")
+ set(${out_var} "${processor_list}" PARENT_SCOPE)
+endfunction()
+
+# check processor is in list
+function(__armclang_check_processor processor list out_var)
+ string(TOLOWER "${processor}" processor)
+ if(processor IN_LIST list)
+ set(${out_var} TRUE PARENT_SCOPE)
+ else()
+ set(${out_var} FALSE PARENT_SCOPE)
+ endif()
+endfunction()
+
+macro(__compiler_armclang lang)
+ if(NOT CMAKE_${lang}_COMPILER_TARGET)
+ set(CMAKE_${lang}_COMPILER_TARGET arm-arm-none-eabi)
+ endif()
+ if(NOT CMAKE_${lang}_COMPILER_PROCESSOR_LIST)
+ __armclang_set_processor_list(${lang} CMAKE_${lang}_COMPILER_PROCESSOR_LIST)
+ endif()
+ if(NOT CMAKE_SYSTEM_PROCESSOR)
+ message(FATAL_ERROR " CMAKE_SYSTEM_PROCESSOR must be set for ARMClang\n"
+ " Supported processor: ${CMAKE_${lang}_COMPILER_PROCESSOR_LIST}\n")
+ else()
+ __armclang_check_processor("${CMAKE_SYSTEM_PROCESSOR}" "${CMAKE_${lang}_COMPILER_PROCESSOR_LIST}" _CMAKE_${lang}_CHECK_RESULT)
+ if(NOT _CMAKE_${lang}_CHECK_RESULT)
+ message(FATAL_ERROR " System processor '${CMAKE_SYSTEM_PROCESSOR}' not supported by ARMClang ${lang} compiler\n"
+ " Supported processor: ${CMAKE_${lang}_COMPILER_PROCESSOR_LIST}\n")
+ endif()
+ unset(_CMAKE_${lang}_CHECK_RESULT)
+ endif()
+ string(APPEND CMAKE_${lang}_FLAGS_INIT "-mcpu=${CMAKE_SYSTEM_PROCESSOR}")
+ string(APPEND CMAKE_${lang}_LINK_FLAGS "--cpu=${CMAKE_SYSTEM_PROCESSOR}")
+
+ set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS> -o <TARGET> --list <TARGET_BASE>.map")
+ set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> --create -cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> --create -cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "--via=")
+ set(CMAKE_${lang}_OUTPUT_EXTENSION ".o")
+ set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1)
+endmacro()
+
+cmake_policy(POP)
diff --git a/Modules/Compiler/Absoft-Fortran.cmake b/Modules/Compiler/Absoft-Fortran.cmake
index da1fc80d4..76502dca7 100644
--- a/Modules/Compiler/Absoft-Fortran.cmake
+++ b/Modules/Compiler/Absoft-Fortran.cmake
@@ -8,3 +8,4 @@ set(CMAKE_Fortran_MODPATH_FLAG "-p")
set(CMAKE_Fortran_VERBOSE_FLAG "-v")
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed")
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree")
+set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-X")
diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake
index a48adec92..2794f52bb 100644
--- a/Modules/Compiler/AppleClang-C.cmake
+++ b/Modules/Compiler/AppleClang-C.cmake
@@ -4,12 +4,15 @@ __compiler_clang(C)
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
endif()
__compiler_check_default_language_standard(C 4.0 99)
diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake
index e5fd64721..3fa69904a 100644
--- a/Modules/Compiler/AppleClang-CXX.cmake
+++ b/Modules/Compiler/AppleClang-CXX.cmake
@@ -8,6 +8,7 @@ endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0)
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
+ set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
@@ -16,10 +17,12 @@ endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.1)
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14")
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
+ set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
# AppleClang 5.0 knows this flag, but does not set a __cplusplus macro greater than 201103L
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
+ set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
endif()
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.1)
@@ -27,4 +30,13 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.1)
set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
endif()
+if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
+ set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON)
+endif()
+
+if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0)
+ set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a")
+ set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
+endif()
+
__compiler_check_default_language_standard(CXX 4.0 98)
diff --git a/Modules/Compiler/AppleClang-OBJC.cmake b/Modules/Compiler/AppleClang-OBJC.cmake
new file mode 100644
index 000000000..d1f37062e
--- /dev/null
+++ b/Modules/Compiler/AppleClang-OBJC.cmake
@@ -0,0 +1,17 @@
+include(Compiler/Clang-OBJC)
+
+if(NOT CMAKE_OBJC_COMPILER_VERSION VERSION_LESS 4.0)
+ set(CMAKE_OBJC90_STANDARD_COMPILE_OPTION "-std=c90")
+ set(CMAKE_OBJC90_EXTENSION_COMPILE_OPTION "-std=gnu90")
+ set(CMAKE_OBJC90_STANDARD__HAS_FULL_SUPPORT ON)
+
+ set(CMAKE_OBJC99_STANDARD_COMPILE_OPTION "-std=c99")
+ set(CMAKE_OBJC99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+ set(CMAKE_OBJC99_STANDARD__HAS_FULL_SUPPORT ON)
+
+ set(CMAKE_OBJC11_STANDARD_COMPILE_OPTION "-std=c11")
+ set(CMAKE_OBJC11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+ set(CMAKE_OBJC11_STANDARD__HAS_FULL_SUPPORT ON)
+endif()
+
+__compiler_check_default_language_standard(OBJC 4.0 99)
diff --git a/Modules/Compiler/AppleClang-OBJCXX.cmake b/Modules/Compiler/AppleClang-OBJCXX.cmake
new file mode 100644
index 000000000..2c084af02
--- /dev/null
+++ b/Modules/Compiler/AppleClang-OBJCXX.cmake
@@ -0,0 +1,39 @@
+include(Compiler/Clang-OBJCXX)
+
+set(CMAKE_OBJCXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
+
+if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 4.0)
+ set(CMAKE_OBJCXX98_STANDARD_COMPILE_OPTION "-std=c++98")
+ set(CMAKE_OBJCXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
+ set(CMAKE_OBJCXX98_STANDARD__HAS_FULL_SUPPORT ON)
+
+ set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "-std=c++11")
+ set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
+endif()
+
+if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 6.1)
+ set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
+ set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON)
+elseif(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 5.1)
+ # AppleClang 5.0 knows this flag, but does not set a __cplusplus macro greater than 201103L
+ set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
+ set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
+ set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON)
+endif()
+
+if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 6.1)
+ set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std=c++1z")
+ set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
+endif()
+
+if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 8.0)
+ set(CMAKE_OBJCXX11_STANDARD__HAS_FULL_SUPPORT ON)
+endif()
+
+if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 10.0)
+ set(CMAKE_OBJCXX20_STANDARD_COMPILE_OPTION "-std=c++2a")
+ set(CMAKE_OBJCXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
+endif()
+
+__compiler_check_default_language_standard(OBJCXX 4.0 98)
diff --git a/Modules/Compiler/Bruce-C.cmake b/Modules/Compiler/Bruce-C.cmake
index cfabe6523..6b64e5806 100644
--- a/Modules/Compiler/Bruce-C.cmake
+++ b/Modules/Compiler/Bruce-C.cmake
@@ -5,3 +5,5 @@ string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " -g")
string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG")
string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -g -DNDEBUG")
+
+set(CMAKE_C_LINKER_WRAPPER_FLAG "-X")
diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake
index 684fd30cb..96537f8dd 100644
--- a/Modules/Compiler/CMakeCommonCompilerMacros.cmake
+++ b/Modules/Compiler/CMakeCommonCompilerMacros.cmake
@@ -65,29 +65,72 @@ endmacro()
macro(cmake_record_c_compile_features)
set(_result 0)
if(_result EQUAL 0 AND DEFINED CMAKE_C11_STANDARD_COMPILE_OPTION)
- _record_compiler_features_c(11)
+ if(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT)
+ _has_compiler_features_c(11)
+ else()
+ _record_compiler_features_c(11)
+ endif()
+ unset(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT)
endif()
if(_result EQUAL 0 AND DEFINED CMAKE_C99_STANDARD_COMPILE_OPTION)
- _record_compiler_features_c(99)
+ if(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT)
+ _has_compiler_features_c(99)
+ else()
+ _record_compiler_features_c(99)
+ endif()
+ unset(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT)
endif()
if(_result EQUAL 0 AND DEFINED CMAKE_C90_STANDARD_COMPILE_OPTION)
- _record_compiler_features_c(90)
+ if(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT)
+ _has_compiler_features_c(90)
+ else()
+ _record_compiler_features_c(90)
+ endif()
+ unset(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT)
endif()
endmacro()
# Define to allow compile features to be automatically determined
macro(cmake_record_cxx_compile_features)
set(_result 0)
+ if(_result EQUAL 0 AND DEFINED CMAKE_CXX20_STANDARD_COMPILE_OPTION)
+ if(CMAKE_CXX20_STANDARD__HAS_FULL_SUPPORT)
+ _has_compiler_features_cxx(20)
+ else()
+ _record_compiler_features_cxx(20)
+ endif()
+ unset(CMAKE_CXX20_STANDARD__HAS_FULL_SUPPORT)
+ endif()
if(_result EQUAL 0 AND DEFINED CMAKE_CXX17_STANDARD_COMPILE_OPTION)
- _record_compiler_features_cxx(17)
+ if(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT)
+ _has_compiler_features_cxx(17)
+ else()
+ _record_compiler_features_cxx(17)
+ endif()
+ unset(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT)
endif()
if(_result EQUAL 0 AND DEFINED CMAKE_CXX14_STANDARD_COMPILE_OPTION)
- _record_compiler_features_cxx(14)
+ if(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT)
+ _has_compiler_features_cxx(14)
+ else()
+ _record_compiler_features_cxx(14)
+ endif()
+ unset(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT)
endif()
if(_result EQUAL 0 AND DEFINED CMAKE_CXX11_STANDARD_COMPILE_OPTION)
- _record_compiler_features_cxx(11)
+ if(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT)
+ _has_compiler_features_cxx(11)
+ else()
+ _record_compiler_features_cxx(11)
+ endif()
+ unset(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT)
endif()
if(_result EQUAL 0 AND DEFINED CMAKE_CXX98_STANDARD_COMPILE_OPTION)
- _record_compiler_features_cxx(98)
+ if(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT)
+ _has_compiler_features_cxx(98)
+ else()
+ _record_compiler_features_cxx(98)
+ endif()
+ unset(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT)
endif()
endmacro()
diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake
index b881e2b03..0448965ee 100644
--- a/Modules/Compiler/Clang-C.cmake
+++ b/Modules/Compiler/Clang-C.cmake
@@ -2,19 +2,41 @@ include(Compiler/Clang)
__compiler_clang(C)
cmake_policy(GET CMP0025 appleClangPolicy)
-if(WIN32 OR (APPLE AND NOT appleClangPolicy STREQUAL NEW))
+if(APPLE AND NOT appleClangPolicy STREQUAL NEW)
return()
endif()
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
- set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
- set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
+ if(NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
+ set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
+ set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
- set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
- set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+ set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
+ set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
- set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
- set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+ set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
+ set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
+ else()
+ # clang-cl doesn't have any of these
+ set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_C90_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
+
+ set(CMAKE_C99_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_C99_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
+
+ set(CMAKE_C11_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_C11_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
+ endif()
endif()
-__compiler_check_default_language_standard(C 3.4 99 3.6 11)
+if(NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
+ __compiler_check_default_language_standard(C 3.4 99 3.6 11)
+else()
+ set(CMAKE_C_STANDARD_DEFAULT "")
+endif()
diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake
index d3707eed8..61709f828 100644
--- a/Modules/Compiler/Clang-CXX.cmake
+++ b/Modules/Compiler/Clang-CXX.cmake
@@ -1,7 +1,7 @@
include(Compiler/Clang)
__compiler_clang(CXX)
-if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
endif()
@@ -10,30 +10,121 @@ if(APPLE AND NOT appleClangPolicy STREQUAL NEW)
return()
endif()
-if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
- set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
- set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
-endif()
-if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
- set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
- set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
-elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
- set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
- set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
-endif()
+if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
+ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
+ endif()
-if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
- set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14")
- set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
-elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
- set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
- set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
-endif()
+ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
+ set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
+ set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON)
+ elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
+ endif()
-if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
- set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++1z")
- set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
-endif()
+ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
+ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
+ set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
+ elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
+ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
+ set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
+ endif()
+
+ set(_clang_version_std17 5.0)
+ if(CMAKE_SYSTEM_NAME STREQUAL "Android")
+ set(_clang_version_std17 6.0)
+ endif()
+
+ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
+ set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17")
+ set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17")
+ elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
+ set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++1z")
+ set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
+ endif()
+
+ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
+ set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a")
+ set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
+ endif()
-__compiler_check_default_language_standard(CXX 2.1 98)
+ unset(_clang_version_std17)
+
+ if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+ # The MSVC standard library requires C++14, and MSVC itself has no
+ # notion of operating in a mode not aware of at least that standard.
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++14")
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++14")
+
+ # This clang++ is missing some features because of MSVC compatibility.
+ unset(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT)
+ unset(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT)
+ unset(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT)
+ unset(CMAKE_CXX20_STANDARD__HAS_FULL_SUPPORT)
+ endif()
+
+ __compiler_check_default_language_standard(CXX 2.1 98)
+elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.9
+ AND CMAKE_CXX_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.0)
+ # This version of clang-cl and the MSVC version it simulates have
+ # support for -std: flags.
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std:c++14")
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std:c++14")
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
+ set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std:c++17")
+ set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std:c++17")
+ set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std:c++latest")
+ set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std:c++latest")
+ else()
+ set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std:c++latest")
+ set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std:c++latest")
+ endif()
+
+ __compiler_check_default_language_standard(CXX 3.9 14)
+else()
+ # This version of clang-cl, or the MSVC version it simulates, does not have
+ # language standards. Set these options as empty strings so the feature
+ # test infrastructure can at least check to see if they are defined.
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "")
+
+ # There is no meaningful default for this
+ set(CMAKE_CXX_STANDARD_DEFAULT "")
+
+ # There are no compiler modes so we only need to test features once.
+ # Override the default macro for this special case. Pretend that
+ # all language standards are available so that at least compilation
+ # can be attempted.
+ macro(cmake_record_cxx_compile_features)
+ list(APPEND CMAKE_CXX_COMPILE_FEATURES
+ cxx_std_98
+ cxx_std_11
+ cxx_std_14
+ cxx_std_17
+ cxx_std_20
+ )
+ _record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES)
+ endmacro()
+endif()
diff --git a/Modules/Compiler/Clang-OBJC.cmake b/Modules/Compiler/Clang-OBJC.cmake
new file mode 100644
index 000000000..c61c497fc
--- /dev/null
+++ b/Modules/Compiler/Clang-OBJC.cmake
@@ -0,0 +1,18 @@
+include(Compiler/Clang)
+__compiler_clang(OBJC)
+
+if(NOT CMAKE_OBJC_COMPILER_VERSION VERSION_LESS 3.4)
+ set(CMAKE_OBJC90_STANDARD_COMPILE_OPTION "-std=c90")
+ set(CMAKE_OBJC90_EXTENSION_COMPILE_OPTION "-std=gnu90")
+ set(CMAKE_OBJC90_STANDARD__HAS_FULL_SUPPORT ON)
+
+ set(CMAKE_OBJC99_STANDARD_COMPILE_OPTION "-std=c99")
+ set(CMAKE_OBJC99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+ set(CMAKE_OBJC99_STANDARD__HAS_FULL_SUPPORT ON)
+
+ set(CMAKE_OBJC11_STANDARD_COMPILE_OPTION "-std=c11")
+ set(CMAKE_OBJC11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+ set(CMAKE_OBJC11_STANDARD__HAS_FULL_SUPPORT ON)
+endif()
+
+__compiler_check_default_language_standard(OBJC 3.4 99 3.6 11)
diff --git a/Modules/Compiler/Clang-OBJCXX.cmake b/Modules/Compiler/Clang-OBJCXX.cmake
new file mode 100644
index 000000000..b01ce6484
--- /dev/null
+++ b/Modules/Compiler/Clang-OBJCXX.cmake
@@ -0,0 +1,70 @@
+include(Compiler/Clang)
+__compiler_clang(OBJCXX)
+
+if("x${CMAKE_OBJCXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
+ if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 2.1)
+ set(CMAKE_OBJCXX98_STANDARD_COMPILE_OPTION "-std=c++98")
+ set(CMAKE_OBJCXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
+ endif()
+
+ if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.1)
+ set(CMAKE_OBJCXX98_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "-std=c++11")
+ set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
+ set(CMAKE_OBJCXX11_STANDARD__HAS_FULL_SUPPORT ON)
+ elseif(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 2.1)
+ set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
+ set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
+ endif()
+
+ if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.5)
+ set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
+ set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON)
+ elseif(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.4)
+ set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
+ set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
+ set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON)
+ endif()
+
+ set(_clang_version_std17 5.0)
+
+ if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
+ set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std=c++17")
+ set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17")
+ elseif (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.5)
+ set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std=c++1z")
+ set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
+ endif()
+
+ if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
+ set(CMAKE_OBJCXX20_STANDARD_COMPILE_OPTION "-std=c++2a")
+ set(CMAKE_OBJCXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
+ endif()
+
+ unset(_clang_version_std17)
+
+ __compiler_check_default_language_standard(OBJCXX 2.1 98)
+elseif(CMAKE_OBJCXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.9
+ AND CMAKE_OBJCXX_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.0)
+ # This version of clang-cl and the MSVC version it simulates have
+ # support for -std: flags.
+ set(CMAKE_OBJCXX98_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_OBJCXX98_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_OBJCXX98_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std:c++14")
+ set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std:c++14")
+ if (CMAKE_OBJCXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
+ set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std:c++17")
+ set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std:c++17")
+ set(CMAKE_OBJCXX20_STANDARD_COMPILE_OPTION "-std:c++latest")
+ set(CMAKE_OBJCXX20_EXTENSION_COMPILE_OPTION "-std:c++latest")
+ else()
+ set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std:c++latest")
+ set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std:c++latest")
+ endif()
+
+ __compiler_check_default_language_standard(OBJCXX 3.9 14)
+endif()
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake
index 7d476f965..5cc93284b 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/Clang.cmake
@@ -11,7 +11,8 @@ set(__COMPILER_CLANG 1)
include(Compiler/CMakeCommonCompilerMacros)
if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
- OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+ OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC"
+ OR "x${CMAKE_Fortran_SIMULATE_ID}" STREQUAL "xMSVC")
macro(__compiler_clang lang)
endmacro()
else()
@@ -20,6 +21,12 @@ else()
macro(__compiler_clang lang)
__compiler_gnu(${lang})
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
+ # Link options for PIE are already set in 'Compiler/GNU.cmake'
+ # but clang may require alternate syntax on some platforms
+ if (APPLE)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} -Xlinker -pie)
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE -Xlinker -no_pie)
+ endif()
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4.0)
@@ -29,6 +36,16 @@ else()
set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "--target=")
set(CMAKE_${lang}_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "--gcc-toolchain=")
endif()
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Xlinker" " ")
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP)
+
+ if(CMAKE_${lang}_COMPILER_TARGET)
+ if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4.0)
+ list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-target" "${CMAKE_${lang}_COMPILER_TARGET}")
+ else()
+ list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "--target=${CMAKE_${lang}_COMPILER_TARGET}")
+ endif()
+ endif()
set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
@@ -69,15 +86,22 @@ else()
endif()
set(CMAKE_${lang}_ARCHIVE_CREATE_IPO
- "${__ar} cr <TARGET> <LINK_FLAGS> <OBJECTS>"
+ "\"${__ar}\" cr <TARGET> <LINK_FLAGS> <OBJECTS>"
)
set(CMAKE_${lang}_ARCHIVE_APPEND_IPO
- "${__ar} r <TARGET> <LINK_FLAGS> <OBJECTS>"
+ "\"${__ar}\" r <TARGET> <LINK_FLAGS> <OBJECTS>"
)
set(CMAKE_${lang}_ARCHIVE_FINISH_IPO
- "${__ranlib} <TARGET>"
+ "\"${__ranlib}\" <TARGET>"
)
+
+ set(CMAKE_PCH_EXTENSION .pch)
+ if (NOT CMAKE_GENERATOR MATCHES "Xcode")
+ set(CMAKE_PCH_PROLOGUE "#pragma clang system_header")
+ endif()
+ set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE>)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER>)
endmacro()
endif()
diff --git a/Modules/Compiler/Cray-C.cmake b/Modules/Compiler/Cray-C.cmake
index 87ce20f71..93409489b 100644
--- a/Modules/Compiler/Cray-C.cmake
+++ b/Modules/Compiler/Cray-C.cmake
@@ -2,8 +2,7 @@
# file Copyright.txt or https://cmake.org/licensing for details.
include(Compiler/Cray)
-
-set(CMAKE_C_VERBOSE_FLAG "-v")
+__compiler_cray(C)
string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG")
@@ -11,11 +10,14 @@ string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG")
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1)
set(CMAKE_C90_STANDARD_COMPILE_OPTION -h noc99,conform)
set(CMAKE_C90_EXTENSION_COMPILE_OPTION -h noc99,gnu)
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION -h c99,conform)
set(CMAKE_C99_EXTENSION_COMPILE_OPTION -h c99,gnu)
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.5)
set(CMAKE_C11_STANDARD_COMPILE_OPTION -h std=c11,conform)
set(CMAKE_C11_EXTENSION_COMPILE_OPTION -h std=c11,gnu)
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
endif ()
endif ()
diff --git a/Modules/Compiler/Cray-CXX.cmake b/Modules/Compiler/Cray-CXX.cmake
index 8506c0942..38c8b1ee9 100644
--- a/Modules/Compiler/Cray-CXX.cmake
+++ b/Modules/Compiler/Cray-CXX.cmake
@@ -2,8 +2,7 @@
# file Copyright.txt or https://cmake.org/licensing for details.
include(Compiler/Cray)
-
-set(CMAKE_CXX_VERBOSE_FLAG "-v")
+__compiler_cray(CXX)
string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG")
@@ -11,9 +10,16 @@ string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1)
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -h conform)
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -h gnu)
+ set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.4)
set(CMAKE_CXX11_STANDARD_COMPILE_OPTION -h std=c++11)
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -h std=c++11,gnu)
+ set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON)
+ endif()
+ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.6)
+ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION -h std=c++14)
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -h std=c++14,gnu)
+ set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
endif ()
endif ()
diff --git a/Modules/Compiler/Cray-Fortran.cmake b/Modules/Compiler/Cray-Fortran.cmake
index 5d81bb02c..ccb7c2ee5 100644
--- a/Modules/Compiler/Cray-Fortran.cmake
+++ b/Modules/Compiler/Cray-Fortran.cmake
@@ -1,4 +1,11 @@
-set(CMAKE_Fortran_VERBOSE_FLAG "-v")
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+include(Compiler/Cray)
+__compiler_cray(Fortran)
+
+set(CMAKE_Fortran_SUBMODULE_SEP "")
+set(CMAKE_Fortran_SUBMODULE_EXT ".mod")
set(CMAKE_Fortran_MODOUT_FLAG -em)
set(CMAKE_Fortran_MODDIR_FLAG -J)
set(CMAKE_Fortran_MODDIR_DEFAULT .)
diff --git a/Modules/Compiler/Cray.cmake b/Modules/Compiler/Cray.cmake
index 8fe8eebda..c214afc69 100644
--- a/Modules/Compiler/Cray.cmake
+++ b/Modules/Compiler/Cray.cmake
@@ -8,3 +8,10 @@ endif()
set(__COMPILER_CRAY 1)
include(Compiler/CMakeCommonCompilerMacros)
+
+macro(__compiler_cray lang)
+ set(CMAKE_${lang}_VERBOSE_FLAG "-v")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_PIC -h PIC)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_PIE -h PIC)
+ set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-h PIC")
+endmacro()
diff --git a/Modules/Compiler/CrayPrgEnv-C.cmake b/Modules/Compiler/CrayPrgEnv-C.cmake
index 6b461ce06..76aa93b95 100644
--- a/Modules/Compiler/CrayPrgEnv-C.cmake
+++ b/Modules/Compiler/CrayPrgEnv-C.cmake
@@ -4,8 +4,4 @@ endif()
set(__craylinux_crayprgenv_c 1)
include(Compiler/CrayPrgEnv)
-macro(__CrayPrgEnv_setup_C compiler_cmd link_cmd)
- __CrayPrgEnv_setup(C
- ${CMAKE_ROOT}/Modules/CMakeCCompilerABI.c
- ${compiler_cmd} ${link_cmd})
-endmacro()
+__CrayPrgEnv_setup(C)
diff --git a/Modules/Compiler/CrayPrgEnv-CXX.cmake b/Modules/Compiler/CrayPrgEnv-CXX.cmake
index aad85b67e..442370ecc 100644
--- a/Modules/Compiler/CrayPrgEnv-CXX.cmake
+++ b/Modules/Compiler/CrayPrgEnv-CXX.cmake
@@ -4,8 +4,4 @@ endif()
set(__craylinux_crayprgenv_cxx 1)
include(Compiler/CrayPrgEnv)
-macro(__CrayPrgEnv_setup_CXX compiler_cmd link_cmd)
- __CrayPrgEnv_setup(CXX
- ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp
- ${compiler_cmd} ${link_cmd})
-endmacro()
+__CrayPrgEnv_setup(CXX)
diff --git a/Modules/Compiler/CrayPrgEnv-Cray-C.cmake b/Modules/Compiler/CrayPrgEnv-Cray-C.cmake
deleted file mode 100644
index 547a4b4d5..000000000
--- a/Modules/Compiler/CrayPrgEnv-Cray-C.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if(__craylinux_crayprgenv_cray_c)
- return()
-endif()
-set(__craylinux_crayprgenv_cray_c 1)
-
-include(Compiler/CrayPrgEnv-C)
-__CrayPrgEnv_setup_C("/opt/cray/cce/.*/ccfe" "/opt/cray/cce/.*/ld")
diff --git a/Modules/Compiler/CrayPrgEnv-Cray-CXX.cmake b/Modules/Compiler/CrayPrgEnv-Cray-CXX.cmake
deleted file mode 100644
index df8452c15..000000000
--- a/Modules/Compiler/CrayPrgEnv-Cray-CXX.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if(__craylinux_crayprgenv_cray_cxx)
- return()
-endif()
-set(__craylinux_crayprgenv_cray_cxx 1)
-
-include(Compiler/CrayPrgEnv-CXX)
-__CrayPrgEnv_setup_CXX("/opt/cray/cce/.*/ccfe" "/opt/cray/cce/.*/ld")
diff --git a/Modules/Compiler/CrayPrgEnv-Cray-Fortran.cmake b/Modules/Compiler/CrayPrgEnv-Cray-Fortran.cmake
deleted file mode 100644
index 9f46a04c8..000000000
--- a/Modules/Compiler/CrayPrgEnv-Cray-Fortran.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if(__craylinux_crayprgenv_cray_fortran)
- return()
-endif()
-set(__craylinux_crayprgenv_cray_fortran 1)
-
-include(Compiler/CrayPrgEnv-Fortran)
-__CrayPrgEnv_setup_Fortran("/opt/cray/cce/.*/ftnfe" "/opt/cray/cce/.*/ld")
diff --git a/Modules/Compiler/CrayPrgEnv-Fortran.cmake b/Modules/Compiler/CrayPrgEnv-Fortran.cmake
index 9c4d2694a..85f82d3f7 100644
--- a/Modules/Compiler/CrayPrgEnv-Fortran.cmake
+++ b/Modules/Compiler/CrayPrgEnv-Fortran.cmake
@@ -4,8 +4,4 @@ endif()
set(__craylinux_crayprgenv_fortran 1)
include(Compiler/CrayPrgEnv)
-macro(__CrayPrgEnv_setup_Fortran compiler_cmd link_cmd)
- __CrayPrgEnv_setup(Fortran
- ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F
- ${compiler_cmd} ${link_cmd})
-endmacro()
+__CrayPrgEnv_setup(Fortran)
diff --git a/Modules/Compiler/CrayPrgEnv-GNU-C.cmake b/Modules/Compiler/CrayPrgEnv-GNU-C.cmake
deleted file mode 100644
index 248081b87..000000000
--- a/Modules/Compiler/CrayPrgEnv-GNU-C.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if(__craylinux_crayprgenv_gnu_c)
- return()
-endif()
-set(__craylinux_crayprgenv_gnu_c 1)
-
-include(Compiler/CrayPrgEnv-C)
-__CrayPrgEnv_setup_C("/opt/gcc/.*/cc1" "/opt/gcc/.*/collect2")
diff --git a/Modules/Compiler/CrayPrgEnv-GNU-CXX.cmake b/Modules/Compiler/CrayPrgEnv-GNU-CXX.cmake
deleted file mode 100644
index be4eb6d54..000000000
--- a/Modules/Compiler/CrayPrgEnv-GNU-CXX.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if(__craylinux_crayprgenv_gnu_cxx)
- return()
-endif()
-set(__craylinux_crayprgenv_gnu_cxx 1)
-
-include(Compiler/CrayPrgEnv-CXX)
-__CrayPrgEnv_setup_CXX("/opt/gcc/.*/cc1plus" "/opt/gcc/.*/collect2")
diff --git a/Modules/Compiler/CrayPrgEnv-GNU-Fortran.cmake b/Modules/Compiler/CrayPrgEnv-GNU-Fortran.cmake
deleted file mode 100644
index 8bd23ff88..000000000
--- a/Modules/Compiler/CrayPrgEnv-GNU-Fortran.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if(__craylinux_crayprgenv_gnu_fortran)
- return()
-endif()
-set(__craylinux_crayprgenv_gnu_fortran 1)
-
-include(Compiler/CrayPrgEnv-Fortran)
-__CrayPrgEnv_setup_Fortran("/opt/gcc/.*/f951" "/opt/gcc/.*/collect2")
diff --git a/Modules/Compiler/CrayPrgEnv-Intel-C.cmake b/Modules/Compiler/CrayPrgEnv-Intel-C.cmake
deleted file mode 100644
index 83c4e3801..000000000
--- a/Modules/Compiler/CrayPrgEnv-Intel-C.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if(__craylinux_crayprgenv_intel_c)
- return()
-endif()
-set(__craylinux_crayprgenv_intel_c 1)
-
-include(Compiler/CrayPrgEnv-C)
-__CrayPrgEnv_setup_C("/opt/intel/.*/mcpcom" "^ld ")
diff --git a/Modules/Compiler/CrayPrgEnv-Intel-CXX.cmake b/Modules/Compiler/CrayPrgEnv-Intel-CXX.cmake
deleted file mode 100644
index 3c3c3e63f..000000000
--- a/Modules/Compiler/CrayPrgEnv-Intel-CXX.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if(__craylinux_crayprgenv_intel_cxx)
- return()
-endif()
-set(__craylinux_crayprgenv_intel_cxx 1)
-
-include(Compiler/CrayPrgEnv-CXX)
-__CrayPrgEnv_setup_CXX("/opt/intel/.*/mcpcom" "^ld ")
diff --git a/Modules/Compiler/CrayPrgEnv-Intel-Fortran.cmake b/Modules/Compiler/CrayPrgEnv-Intel-Fortran.cmake
deleted file mode 100644
index 08a316d2c..000000000
--- a/Modules/Compiler/CrayPrgEnv-Intel-Fortran.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if(__craylinux_crayprgenv_intel_fortran)
- return()
-endif()
-set(__craylinux_crayprgenv_intel_fortran 1)
-
-include(Compiler/CrayPrgEnv-Fortran)
-__CrayPrgEnv_setup_Fortran("/opt/intel/.*/fortcom" "^ld ")
diff --git a/Modules/Compiler/CrayPrgEnv-PGI-C.cmake b/Modules/Compiler/CrayPrgEnv-PGI-C.cmake
deleted file mode 100644
index f45767caf..000000000
--- a/Modules/Compiler/CrayPrgEnv-PGI-C.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if(__craylinux_crayprgenv_pgi_c)
- return()
-endif()
-set(__craylinux_crayprgenv_pgi_c 1)
-
-include(Compiler/CrayPrgEnv-C)
-__CrayPrgEnv_setup_C("/opt/pgi/[^ ]*/pgc" "/usr/bin/ld")
diff --git a/Modules/Compiler/CrayPrgEnv-PGI-CXX.cmake b/Modules/Compiler/CrayPrgEnv-PGI-CXX.cmake
deleted file mode 100644
index a2a286f8c..000000000
--- a/Modules/Compiler/CrayPrgEnv-PGI-CXX.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if(__craylinux_crayprgenv_pgi_cxx)
- return()
-endif()
-set(__craylinux_crayprgenv_pgi_cxx 1)
-
-include(Compiler/CrayPrgEnv-CXX)
-__CrayPrgEnv_setup_CXX("/opt/pgi/[^ ]*/pgcpp" "/usr/bin/ld")
diff --git a/Modules/Compiler/CrayPrgEnv-PGI-Fortran.cmake b/Modules/Compiler/CrayPrgEnv-PGI-Fortran.cmake
deleted file mode 100644
index f6ba7c0fa..000000000
--- a/Modules/Compiler/CrayPrgEnv-PGI-Fortran.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if(__craylinux_crayprgenv_pgi_fortran)
- return()
-endif()
-set(__craylinux_crayprgenv_pgi_fortran 1)
-
-include(Compiler/CrayPrgEnv-Fortran)
-__CrayPrgEnv_setup_Fortran("/opt/pgi/[^ ]*/pgf" "/usr/bin/ld")
diff --git a/Modules/Compiler/CrayPrgEnv.cmake b/Modules/Compiler/CrayPrgEnv.cmake
index 9f8befda3..f6e46acaa 100644
--- a/Modules/Compiler/CrayPrgEnv.cmake
+++ b/Modules/Compiler/CrayPrgEnv.cmake
@@ -1,57 +1,109 @@
# Guard against multiple inclusions
-if(__craylinux_crayprgenv)
+if(__cmake_craype_crayprgenv)
return()
endif()
-set(__craylinux_crayprgenv 1)
+set(__cmake_craype_crayprgenv 1)
-macro(__cray_extract_args cmd tag_regex out_var make_absolute)
- string(REGEX MATCHALL "${tag_regex}" args "${cmd}")
- foreach(arg IN LISTS args)
- string(REGEX REPLACE "^${tag_regex}$" "\\2" param "${arg}")
- if(make_absolute)
- get_filename_component(param "${param}" ABSOLUTE)
- endif()
- list(APPEND ${out_var} ${param})
- endforeach()
-endmacro()
+# CrayPrgEnv: loaded when compiling through the Cray compiler wrapper.
+# The compiler wrapper can run on a front-end node or a compute node.
-function(__cray_extract_implicit src compiler_cmd link_cmd lang include_dirs_var link_dirs_var link_libs_var)
- set(BIN "${CMAKE_PLATFORM_INFO_DIR}/CrayExtractImplicit_${lang}.bin")
- execute_process(
- COMMAND ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_VERBOSE_FLAG} -o ${BIN}
- RESULT_VARIABLE result
- OUTPUT_VARIABLE output
- ERROR_VARIABLE error
- )
- if(EXISTS "${BIN}")
- file(REMOVE "${BIN}")
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
+# One-time setup of the craype environment. First, check the wrapper config.
+# The wrapper's selection of a compiler (gcc, clang, intel, etc.) and
+# default include/library paths is selected using the "module" command.
+# The CRAYPE_LINK_TYPE environment variable partly controls if static
+# or dynamic binaries are generated (see __cmake_craype_linktype below).
+# Running cmake and then changing module and/or linktype configuration
+# may cause build problems (since the data in the cmake cache may no
+# longer be correct after the change). We can look for this and warn
+# the user about it. Second, use the "module" provided PKG_CONFIG_PATH-like
+# environment variable to add additional prefixes to the system prefix
+# path.
+function(__cmake_craype_setupenv)
+ if(NOT DEFINED __cmake_craype_setupenv_done) # only done once per run
+ set(__cmake_craype_setupenv_done 1 PARENT_SCOPE)
+ unset(__cmake_check)
+ set(CMAKE_CRAYPE_LINKTYPE "$ENV{CRAYPE_LINK_TYPE}" CACHE STRING
+ "saved value of CRAYPE_LINK_TYPE environment variable")
+ set(CMAKE_CRAYPE_LOADEDMODULES "$ENV{LOADEDMODULES}" CACHE STRING
+ "saved value of LOADEDMODULES environment variable")
+ mark_as_advanced(CMAKE_CRAYPE_LINKTYPE CMAKE_CRAYPE_LOADEDMODULES)
+ if (NOT "${CMAKE_CRAYPE_LINKTYPE}" STREQUAL "$ENV{CRAYPE_LINK_TYPE}")
+ string(APPEND __cmake_check "CRAYPE_LINK_TYPE ")
+ endif()
+ if (NOT "${CMAKE_CRAYPE_LOADEDMODULES}" STREQUAL "$ENV{LOADEDMODULES}")
+ string(APPEND __cmake_check "LOADEDMODULES ")
+ endif()
+ if(DEFINED __cmake_check)
+ message(STATUS "NOTE: ${__cmake_check}changed since initial config!")
+ message(STATUS "NOTE: this may cause unexpected build errors.")
+ endif()
+ # loop over variables of interest
+ foreach(pkgcfgvar PKG_CONFIG_PATH PKG_CONFIG_PATH_DEFAULT
+ PE_PKG_CONFIG_PATH)
+ file(TO_CMAKE_PATH "$ENV{${pkgcfgvar}}" pkgcfg)
+ foreach(path ${pkgcfg})
+ string(REGEX REPLACE "(.*)/lib[^/]*/pkgconfig$" "\\1" path "${path}")
+ if(NOT "${path}" STREQUAL "" AND
+ NOT "${path}" IN_LIST CMAKE_SYSTEM_PREFIX_PATH)
+ list(APPEND CMAKE_SYSTEM_PREFIX_PATH "${path}")
+ endif()
+ endforeach()
+ endforeach()
+ # push it up out of this function into the parent scope
+ set(CMAKE_SYSTEM_PREFIX_PATH "${CMAKE_SYSTEM_PREFIX_PATH}" PARENT_SCOPE)
endif()
- set(include_dirs)
- set(link_dirs)
- set(link_libs)
- string(REGEX REPLACE "\r?\n" ";" output_lines "${output}\n${error}")
- foreach(line IN LISTS output_lines)
- if("${line}" MATCHES "${compiler_cmd}")
- __cray_extract_args("${line}" " -(I ?|isystem )([^ ]*)" include_dirs 1)
- set(processed_include 1)
+endfunction()
+
+# The wrapper disables dynamic linking by default. Dynamic linking is
+# enabled either by setting $ENV{CRAYPE_LINK_TYPE} to "dynamic" or by
+# specifying "-dynamic" to the wrapper when linking. Specifying "-static"
+# to the wrapper when linking takes priority over $ENV{CRAYPE_LINK_TYPE}.
+# Furthermore, if you specify multiple "-dynamic" and "-static" flags to
+# the wrapper when linking, the last one will win. In this case, the
+# wrapper will also print a warning like:
+# Warning: -dynamic was already seen on command line, overriding with -static.
+#
+# note that cmake applies both CMAKE_${lang}_FLAGS and CMAKE_EXE_LINKER_FLAGS
+# (in that order) to the linking command, so -dynamic can appear in either
+# variable.
+#
+# Note: As of CrayPE v19.06 (which translates to the craype/2.6.0 module)
+# the default has changed and is now dynamic by default. This is handled
+# accordingly
+function(__cmake_craype_linktype lang rv)
+ # start with ENV, but allow flags to override
+ if(("$ENV{CRAYPE_VERSION}" STREQUAL "") OR
+ ("$ENV{CRAYPE_VERSION}" VERSION_LESS "2.6"))
+ if("$ENV{CRAYPE_LINK_TYPE}" STREQUAL "dynamic")
+ set(linktype dynamic)
+ else()
+ set(linktype static)
endif()
- if("${line}" MATCHES "${link_cmd}")
- __cray_extract_args("${line}" " -(L ?)([^ ]*)" link_dirs 1)
- __cray_extract_args("${line}" " -(l ?)([^ ]*)" link_libs 0)
- set(processed_link 1)
+ else()
+ if("$ENV{CRAYPE_LINK_TYPE}" STREQUAL "static")
+ set(linktype static)
+ else()
+ set(linktype dynamic)
endif()
- if(processed_include AND processed_link)
- break()
+ endif()
+
+ # combine flags and convert to a list so we can apply the flags in order
+ set(linkflags "${CMAKE_${lang}_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}")
+ string(REPLACE " " ";" linkflags "${linkflags}")
+ foreach(flag IN LISTS linkflags)
+ if("${flag}" STREQUAL "-dynamic")
+ set(linktype dynamic)
+ elseif("${flag}" STREQUAL "-static")
+ set(linktype static)
endif()
endforeach()
-
- set(${include_dirs_var} "${include_dirs}" PARENT_SCOPE)
- set(${link_dirs_var} "${link_dirs}" PARENT_SCOPE)
- set(${link_libs_var} "${link_libs}" PARENT_SCOPE)
- set(CRAY_${lang}_EXTRACTED_IMPLICIT 1 CACHE INTERNAL "" FORCE)
+ set(${rv} ${linktype} PARENT_SCOPE)
endfunction()
-macro(__CrayPrgEnv_setup lang test_src compiler_cmd link_cmd)
+macro(__CrayPrgEnv_setup lang)
if(DEFINED ENV{CRAYPE_VERSION})
message(STATUS "Cray Programming Environment $ENV{CRAYPE_VERSION} ${lang}")
elseif(DEFINED ENV{ASYNCPE_VERSION})
@@ -60,34 +112,25 @@ macro(__CrayPrgEnv_setup lang test_src compiler_cmd link_cmd)
message(STATUS "Cray Programming Environment (unknown version) ${lang}")
endif()
+ # setup the craype environment
+ __cmake_craype_setupenv()
+
# Flags for the Cray wrappers
set(CMAKE_STATIC_LIBRARY_LINK_${lang}_FLAGS "-static")
- set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "")
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared")
set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-dynamic")
- # If the link type is not explicitly specified in the environment then
- # the Cray wrappers assume that the code will be built staticly so
- # we check the following condition(s) are NOT met
- # Compiler flags are explicitly dynamic
- # Env var is dynamic and compiler flags are not explicitly static
- if(NOT (((CMAKE_${lang}_FLAGS MATCHES "(^| )-dynamic($| )") OR
- (CMAKE_EXE_LINKER_FLAGS MATCHES "(^| )-dynamic($| )"))
- OR
- (("$ENV{CRAYPE_LINK_TYPE}" STREQUAL "dynamic") AND
- NOT ((CMAKE_${lang}_FLAGS MATCHES "(^| )-static($| )") OR
- (CMAKE_EXE_LINKER_FLAGS MATCHES "(^| )-static($| )")))))
+ # determine linktype from environment and compiler flags
+ __cmake_craype_linktype(${lang} __cmake_craype_${lang}_linktype)
+
+ # switch off shared libs if we get a static linktype
+ if("${__cmake_craype_${lang}_linktype}" STREQUAL "static")
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
set(BUILD_SHARED_LIBS FALSE CACHE BOOL "")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(CMAKE_LINK_SEARCH_START_STATIC TRUE)
endif()
- if(NOT CRAY_${lang}_EXTRACTED_IMPLICIT)
- __cray_extract_implicit(
- ${test_src} ${compiler_cmd} ${link_cmd} ${lang}
- CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES
- CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES
- CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES
- )
- endif()
+
endmacro()
+
+cmake_policy(POP)
diff --git a/Modules/Compiler/Flang-FindBinUtils.cmake b/Modules/Compiler/Flang-FindBinUtils.cmake
new file mode 100644
index 000000000..e721c8708
--- /dev/null
+++ b/Modules/Compiler/Flang-FindBinUtils.cmake
@@ -0,0 +1 @@
+include(Compiler/Clang-FindBinUtils)
diff --git a/Modules/Compiler/Flang-Fortran.cmake b/Modules/Compiler/Flang-Fortran.cmake
new file mode 100644
index 000000000..f0e61d824
--- /dev/null
+++ b/Modules/Compiler/Flang-Fortran.cmake
@@ -0,0 +1,13 @@
+include(Compiler/Clang)
+__compiler_clang(Fortran)
+
+set(CMAKE_Fortran_SUBMODULE_SEP "-")
+set(CMAKE_Fortran_SUBMODULE_EXT ".mod")
+
+set(CMAKE_Fortran_PREPROCESS_SOURCE
+ "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
+
+set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form")
+set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form")
+
+set(CMAKE_Fortran_MODDIR_FLAG "-J")
diff --git a/Modules/Compiler/G95-Fortran.cmake b/Modules/Compiler/G95-Fortran.cmake
index 2c83fb8fc..03b7e08b9 100644
--- a/Modules/Compiler/G95-Fortran.cmake
+++ b/Modules/Compiler/G95-Fortran.cmake
@@ -7,3 +7,5 @@ set(CMAKE_Fortran_MODDIR_FLAG "-fmod=")
set(CMAKE_Fortran_VERBOSE_FLAG "-v")
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form")
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form")
+set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Wl,")
+set(CMAKE_Fortran_LINKER_WRAPPER_FLAG_SEP ",")
diff --git a/Modules/Compiler/GHS-C.cmake b/Modules/Compiler/GHS-C.cmake
index c30bdecaf..a825b0bba 100644
--- a/Modules/Compiler/GHS-C.cmake
+++ b/Modules/Compiler/GHS-C.cmake
@@ -8,23 +8,3 @@ string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " -Odebug -g")
string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -Ospace")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -O")
string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -O -g")
-
-set(CMAKE_C_GHS_KERNEL_FLAGS_DEBUG_INIT "-ldebug ${CMAKE_C_FLAGS_DEBUG_INIT}")
-set(CMAKE_C_GHS_KERNEL_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT}")
-set(CMAKE_C_GHS_KERNEL_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT}")
-set(CMAKE_C_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT
- "-ldebug ${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}")
-
-if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
- set (CMAKE_C_GHS_KERNEL_FLAGS_DEBUG "${CMAKE_C_GHS_KERNEL_FLAGS_DEBUG_INIT}"
- CACHE STRING "Kernel flags used by the compiler during debug builds.")
- set (CMAKE_C_GHS_KERNEL_FLAGS_MINSIZEREL
- "${CMAKE_C_GHS_KERNEL_FLAGS_MINSIZEREL_INIT}" CACHE STRING
- "Kernel flags used by the compiler during release builds for minimum size.")
- set (CMAKE_C_GHS_KERNEL_FLAGS_RELEASE
- "${CMAKE_C_GHS_KERNEL_FLAGS_RELEASE_INIT}"
- CACHE STRING "Kernel flags used by the compiler during release builds.")
- set (CMAKE_C_GHS_KERNEL_FLAGS_RELWITHDEBINFO
- "${CMAKE_C_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
- "Kernel flags used by the compiler during release builds with debug info.")
-endif()
diff --git a/Modules/Compiler/GHS-CXX.cmake b/Modules/Compiler/GHS-CXX.cmake
index b3018a7b6..07b504424 100644
--- a/Modules/Compiler/GHS-CXX.cmake
+++ b/Modules/Compiler/GHS-CXX.cmake
@@ -8,27 +8,3 @@ string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " -Odebug -g")
string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -Ospace")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -O")
string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " -O -g")
-
-set(CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG_INIT
- "-ldebug ${CMAKE_CXX_FLAGS_DEBUG_INIT}")
-set(CMAKE_CXX_GHS_KERNEL_FLAGS_MINSIZEREL_INIT
- "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT}")
-set(CMAKE_CXX_GHS_KERNEL_FLAGS_RELEASE_INIT
- "${CMAKE_CXX_FLAGS_RELEASE_INIT}")
-set(CMAKE_CXX_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT
- "-ldebug ${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT}")
-
-if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
- set (CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG
- "${CMAKE_CXX_GHS_KERNEL_FLAGS_DEBUG_INIT}"
- CACHE STRING "Kernel flags used by the compiler during debug builds.")
- set (CMAKE_CXX_GHS_KERNEL_FLAGS_MINSIZEREL
- "${CMAKE_CXX_GHS_KERNEL_FLAGS_MINSIZEREL_INIT}" CACHE STRING
- "Kernel flags used by the compiler during release builds for minimum size.")
- set (CMAKE_CXX_GHS_KERNEL_FLAGS_RELEASE
- "${CMAKE_CXX_GHS_KERNEL_FLAGS_RELEASE_INIT}"
- CACHE STRING "Kernel flags used by the compiler during release builds.")
- set (CMAKE_CXX_GHS_KERNEL_FLAGS_RELWITHDEBINFO
- "${CMAKE_CXX_GHS_KERNEL_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
- "Kernel flags used by the compiler during release builds with debug info.")
-endif()
diff --git a/Modules/Compiler/GHS-DetermineCompiler.cmake b/Modules/Compiler/GHS-DetermineCompiler.cmake
index 56d24e266..368b3759d 100644
--- a/Modules/Compiler/GHS-DetermineCompiler.cmake
+++ b/Modules/Compiler/GHS-DetermineCompiler.cmake
@@ -1,6 +1,9 @@
-set(_compiler_id_pp_test "defined(__INTEGRITY)")
+set(_compiler_id_pp_test "defined(__ghs__)")
set(_compiler_id_version_compute "
-# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__INTEGRITY_MAJOR_VERSION)
-# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__INTEGRITY_MINOR_VERSION)
-# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__INTEGRITY_PATCH_VERSION)")
+/* __GHS_VERSION_NUMBER = VVVVRP */
+# ifdef __GHS_VERSION_NUMBER
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__GHS_VERSION_NUMBER / 100)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__GHS_VERSION_NUMBER / 10 % 10)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__GHS_VERSION_NUMBER % 10)
+# endif")
diff --git a/Modules/Compiler/GHS.cmake b/Modules/Compiler/GHS.cmake
index e6a867d04..b41c3ebf8 100644
--- a/Modules/Compiler/GHS.cmake
+++ b/Modules/Compiler/GHS.cmake
@@ -3,6 +3,6 @@ if(__COMPILER_GHS)
endif()
set(__COMPILER_GHS 1)
-set(CMAKE_EXECUTABLE_SUFFIX ".as")
-set(CMAKE_LIBRARY_PATH_TERMINATOR "\n")
-set(CMAKE_LIBRARY_PATH_FLAG " -L")
+set(CMAKE_EXECUTABLE_SUFFIX "")
+set(CMAKE_LIBRARY_PATH_TERMINATOR "")
+set(CMAKE_LIBRARY_PATH_FLAG "")
diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake
index f072c546a..ca286b397 100644
--- a/Modules/Compiler/GNU-C.cmake
+++ b/Modules/Compiler/GNU-C.cmake
@@ -10,13 +10,16 @@ elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
endif()
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
endif()
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c1x")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x")
diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake
index d18adaff0..45c54708e 100644
--- a/Modules/Compiler/GNU-CXX-FeatureTests.cmake
+++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake
@@ -18,18 +18,18 @@ set(_cmake_feature_test_cxx_attribute_deprecated "${GNU49_CXX14}")
set(_cmake_feature_test_cxx_decltype_auto "${GNU49_CXX14}")
set(_cmake_feature_test_cxx_digit_separators "${GNU49_CXX14}")
set(_cmake_feature_test_cxx_generic_lambdas "${GNU49_CXX14}")
-set(_cmake_feature_test_cxx_lambda_init_captures "${GNU49_CXX14}")
# GNU 4.3 supports binary literals as an extension, but may warn about
# use of extensions prior to GNU 4.9
# http://stackoverflow.com/questions/16334024/difference-between-gcc-binary-literals-and-c14-ones
set(_cmake_feature_test_cxx_binary_literals "${GNU49_CXX14}")
-# The feature below is documented as available in GNU 4.8 (by implementing an
+# The features below are documented as available in GNU 4.8 (by implementing an
# earlier draft of the standard paper), but that version of the compiler
# does not set __cplusplus to a value greater than 201103L until GNU 4.9:
# http://gcc.gnu.org/onlinedocs/gcc-4.8.2/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros
# http://gcc.gnu.org/onlinedocs/gcc-4.9.0/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros
# So, CMake only reports availability for it with GNU 4.9 or later.
set(_cmake_feature_test_cxx_return_type_deduction "${GNU49_CXX14}")
+set(_cmake_feature_test_cxx_lambda_init_captures "${GNU49_CXX14}")
# Introduced in GCC 4.8.1
set(GNU481_CXX11 "((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L")
diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake
index 4f1f30e87..fcaaeab43 100644
--- a/Modules/Compiler/GNU-CXX.cmake
+++ b/Modules/Compiler/GNU-CXX.cmake
@@ -17,6 +17,7 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
endif()
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
+ set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
@@ -25,6 +26,10 @@ elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
endif()
+if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.1)
+ set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON)
+endif()
+
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14")
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
@@ -33,9 +38,21 @@ elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
endif()
-if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
+if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
+ set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
+endif()
+
+if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
+ set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17")
+ set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17")
+elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++1z")
set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
endif()
+if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
+ set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a")
+ set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
+endif()
+
__compiler_check_default_language_standard(CXX 3.4 98 6.0 14)
diff --git a/Modules/Compiler/GNU-FindBinUtils.cmake b/Modules/Compiler/GNU-FindBinUtils.cmake
index 16b7bbda4..097fbf3ac 100644
--- a/Modules/Compiler/GNU-FindBinUtils.cmake
+++ b/Modules/Compiler/GNU-FindBinUtils.cmake
@@ -18,7 +18,7 @@ get_filename_component(__gcc_hints "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPIL
find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR NAMES
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x_y}"
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x}"
- "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar"
+ "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar${_CMAKE_COMPILER_SUFFIX}"
HINTS ${__gcc_hints}
DOC "A wrapper around 'ar' adding the appropriate '--plugin' option for the GCC compiler"
)
@@ -28,7 +28,7 @@ mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR)
find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB NAMES
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x_y}"
"${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x}"
- "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib"
+ "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib${_CMAKE_COMPILER_SUFFIX}"
HINTS ${__gcc_hints}
DOC "A wrapper around 'ranlib' adding the appropriate '--plugin' option for the GCC compiler"
)
diff --git a/Modules/Compiler/GNU-Fortran.cmake b/Modules/Compiler/GNU-Fortran.cmake
index 94dc2755a..6413769cf 100644
--- a/Modules/Compiler/GNU-Fortran.cmake
+++ b/Modules/Compiler/GNU-Fortran.cmake
@@ -1,12 +1,17 @@
include(Compiler/GNU)
__compiler_gnu(Fortran)
+set(CMAKE_Fortran_SUBMODULE_SEP "@")
+set(CMAKE_Fortran_SUBMODULE_EXT ".smod")
+
set(CMAKE_Fortran_PREPROCESS_SOURCE
"<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> -o <PREPROCESSED_SOURCE>")
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form")
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form")
+set(CMAKE_Fortran_POSTPROCESS_FLAG "-fpreprocessed")
+
# No -DNDEBUG for Fortran.
string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " -Os")
string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " -O3")
diff --git a/Modules/Compiler/GNU-OBJC.cmake b/Modules/Compiler/GNU-OBJC.cmake
new file mode 100644
index 000000000..fb9b0b2a5
--- /dev/null
+++ b/Modules/Compiler/GNU-OBJC.cmake
@@ -0,0 +1,2 @@
+include(Compiler/GNU)
+__compiler_gnu(OBJC)
diff --git a/Modules/Compiler/GNU-OBJCXX.cmake b/Modules/Compiler/GNU-OBJCXX.cmake
new file mode 100644
index 000000000..06f0244da
--- /dev/null
+++ b/Modules/Compiler/GNU-OBJCXX.cmake
@@ -0,0 +1,10 @@
+include(Compiler/GNU)
+__compiler_gnu(OBJCXX)
+
+if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 4.2)
+ set(CMAKE_OBJCXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
+endif()
+
+if(NOT CMAKE_OBJCXX_LINK_FLAGS)
+ set(CMAKE_OBCXX_LINK_FLAGS "-lstdc++")
+endif()
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index 675e50534..1c050a297 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -9,13 +9,25 @@ endif()
set(__COMPILER_GNU 1)
include(Compiler/CMakeCommonCompilerMacros)
+include(Internal/CMakeCheckCompilerFlag)
+
+set(__pch_header_C "c-header")
+set(__pch_header_CXX "c++-header")
+set(__pch_header_OBJC "objective-c-header")
+set(__pch_header_OBJCXX "objective-c++-header")
macro(__compiler_gnu lang)
# Feature flags.
set(CMAKE_${lang}_VERBOSE_FLAG "-v")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
+ set (_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4)
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
+ # Support of PIE at link stage depends on various elements : platform, compiler, linker
+ # so to activate it, module CheckPIESupported must be used.
+ set (_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER YES)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie")
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie")
endif()
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.0)
set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
@@ -24,6 +36,9 @@ macro(__compiler_gnu lang)
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared")
set(CMAKE_${lang}_COMPILE_OPTIONS_SYSROOT "--sysroot=")
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,")
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",")
+
# Older versions of gcc (< 4.5) contain a bug causing them to report a missing
# header file as a warning if depfiles are enabled, causing check_header_file
# tests to always succeed. Work around this by disabling dependency tracking
@@ -75,15 +90,30 @@ macro(__compiler_gnu lang)
#
# [1]: https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gcc/Optimize-Options.html
set(CMAKE_${lang}_ARCHIVE_CREATE_IPO
- "${CMAKE_${lang}_COMPILER_AR} cr <TARGET> <LINK_FLAGS> <OBJECTS>"
+ "\"${CMAKE_${lang}_COMPILER_AR}\" cr <TARGET> <LINK_FLAGS> <OBJECTS>"
)
set(CMAKE_${lang}_ARCHIVE_APPEND_IPO
- "${CMAKE_${lang}_COMPILER_AR} r <TARGET> <LINK_FLAGS> <OBJECTS>"
+ "\"${CMAKE_${lang}_COMPILER_AR}\" r <TARGET> <LINK_FLAGS> <OBJECTS>"
)
set(CMAKE_${lang}_ARCHIVE_FINISH_IPO
- "${CMAKE_${lang}_COMPILER_RANLIB} <TARGET>"
+ "\"${CMAKE_${lang}_COMPILER_RANLIB}\" <TARGET>"
)
endif()
+
+ set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}")
+ if(CMAKE_${lang}_COMPILER_ARG1)
+ separate_arguments(_COMPILER_ARGS NATIVE_COMMAND "${CMAKE_${lang}_COMPILER_ARG1}")
+ list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND ${_COMPILER_ARGS})
+ unset(_COMPILER_ARGS)
+ endif()
+ list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
+
+ set(CMAKE_PCH_EXTENSION .gch)
+ if (NOT CMAKE_GENERATOR MATCHES "Xcode")
+ set(CMAKE_PCH_PROLOGUE "#pragma GCC system_header")
+ endif()
+ set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Winvalid-pch -include <PCH_HEADER>)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Winvalid-pch -x ${__pch_header_${lang}} -include <PCH_HEADER>)
endmacro()
diff --git a/Modules/Compiler/HP-C.cmake b/Modules/Compiler/HP-C.cmake
index b42ba2be8..8fa4c08e2 100644
--- a/Modules/Compiler/HP-C.cmake
+++ b/Modules/Compiler/HP-C.cmake
@@ -2,3 +2,6 @@ set(CMAKE_C_VERBOSE_FLAG "-v")
set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
+
+set(CMAKE_C_LINKER_WRAPPER_FLAG "-Wl,")
+set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",")
diff --git a/Modules/Compiler/HP-CXX.cmake b/Modules/Compiler/HP-CXX.cmake
index 7548754d3..5726b6494 100644
--- a/Modules/Compiler/HP-CXX.cmake
+++ b/Modules/Compiler/HP-CXX.cmake
@@ -3,6 +3,9 @@ set(CMAKE_CXX_VERBOSE_FLAG "-v")
set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
+set(CMAKE_CXX_LINKER_WRAPPER_FLAG "-Wl,")
+set(CMAKE_CXX_LINKER_WRAPPER_FLAG_SEP ",")
+
# HP aCC since version 3.80 supports the flag +hpxstd98 to get ANSI C++98
# template support. It is known that version 6.25 doesn't need that flag.
# Current assumption: the flag is needed for every version from 3.80 to 4
diff --git a/Modules/Compiler/HP-Fortran.cmake b/Modules/Compiler/HP-Fortran.cmake
index a6ca2c2b8..63a033135 100644
--- a/Modules/Compiler/HP-Fortran.cmake
+++ b/Modules/Compiler/HP-Fortran.cmake
@@ -4,3 +4,6 @@ set(CMAKE_Fortran_FORMAT_FREE_FLAG "+source=free")
set(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
set(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
+
+set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Wl,")
+set(CMAKE_Fortran_LINKER_WRAPPER_FLAG ",")
diff --git a/Modules/Compiler/IAR-ASM.cmake b/Modules/Compiler/IAR-ASM.cmake
index 844c30e50..936d4ae30 100644
--- a/Modules/Compiler/IAR-ASM.cmake
+++ b/Modules/Compiler/IAR-ASM.cmake
@@ -2,13 +2,51 @@
include(Compiler/IAR)
-set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
+if("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM")
+ set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
+ __compiler_iar_ilink(ASM)
+ set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa)
-if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "ARM")
+elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX")
+ set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
+ __compiler_iar_ilink(ASM)
+ set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa)
+
+elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850")
+ set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
+ __compiler_iar_ilink(ASM)
set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa)
-endif()
+elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78")
+ set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
+ __compiler_iar_ilink(ASM)
+ set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa)
-if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "AVR")
+elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISC-V")
+ set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
+ __compiler_iar_ilink(ASM)
+ set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa)
+
+elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR")
+ set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
+ __compiler_iar_xlink(ASM)
set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s90;asm;msa)
+
+elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430")
+ set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
+ __compiler_iar_xlink(ASM)
+ set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s43;asm;msa)
+
+elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850")
+ set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
+ __compiler_iar_xlink(ASM)
+ set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s85;asm;msa)
+
+elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "8051")
+ set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
+ __compiler_iar_xlink(ASM)
+ set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s51;asm;msa)
+
+else()
+ message(FATAL_ERROR "CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID not detected. This should be automatic.")
endif()
diff --git a/Modules/Compiler/IAR-C.cmake b/Modules/Compiler/IAR-C.cmake
index f65b0c7da..e27fdfcb8 100644
--- a/Modules/Compiler/IAR-C.cmake
+++ b/Modules/Compiler/IAR-C.cmake
@@ -1,37 +1,75 @@
# This file is processed when the IAR compiler is used for a C file
-
include(Compiler/IAR)
+include(Compiler/CMakeCommonCompilerMacros)
-set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
-set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>")
-set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy")
-
-set(CMAKE_C_RESPONSE_FILE_LINK_FLAG "-f ")
-set(CMAKE_DEPFILE_FLAGS_C "--dependencies=ns <DEPFILE>")
+# Common
+if(NOT CMAKE_C_COMPILER_VERSION)
+ message(FATAL_ERROR "CMAKE_C_COMPILER_VERSION not detected. This should be automatic.")
+endif()
-# The toolchains for ARM and AVR are quite different:
-if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "ARM")
+set(CMAKE_C_EXTENSION_COMPILE_OPTION -e)
- set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
- set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> <TARGET> --create <LINK_FLAGS> <OBJECTS> ")
+if(CMAKE_C_COMPILER_VERSION_INTERNAL VERSION_GREATER 7)
+ set(CMAKE_C90_STANDARD_COMPILE_OPTION --c89)
+ set(CMAKE_C90_EXTENSION_COMPILE_OPTION --c89 -e)
+ set(CMAKE_C99_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_C99_EXTENSION_COMPILE_OPTION -e)
+else()
+ set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_C90_EXTENSION_COMPILE_OPTION -e)
+endif()
+if(CMAKE_C_COMPILER_VERSION_INTERNAL VERSION_GREATER 8)
+ set(CMAKE_C11_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_C11_EXTENSION_COMPILE_OPTION -e)
endif()
+# Architecture specific
+if("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM")
+ if(CMAKE_C_COMPILER_VERSION_INTERNAL VERSION_LESS 7)
+ # IAR ARM 4.X uses xlink.exe, detection is not yet implemented
+ message(FATAL_ERROR "CMAKE_C_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION} not supported by CMake.")
+ endif()
+ __compiler_iar_ilink(C)
+ __compiler_check_default_language_standard(C 1.10 90 6.10 99 8.10 11)
+
+elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX")
+ __compiler_iar_ilink(C)
+ __compiler_check_default_language_standard(C 1.10 90 2.10 99 4.10 11)
-if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "AVR")
+elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850")
+ __compiler_iar_ilink(C)
+ __compiler_check_default_language_standard(C 1.10 90 1.10 99 2.10 11)
+
+elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78")
+ __compiler_iar_ilink(C)
+ __compiler_check_default_language_standard(C 1.10 90 1.10 99 4.10 11)
+
+elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV")
+ __compiler_iar_ilink(C)
+ __compiler_check_default_language_standard(C 1.10 90 1.10 99 1.10 11)
+
+elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR")
+ __compiler_iar_xlink(C)
+ __compiler_check_default_language_standard(C 7.10 99)
set(CMAKE_C_OUTPUT_EXTENSION ".r90")
- if(NOT CMAKE_C_LINK_FLAGS)
- set(CMAKE_C_LINK_FLAGS "-Fmotorola")
- endif()
+elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430")
+ __compiler_iar_xlink(C)
+ __compiler_check_default_language_standard(C 1.10 90 5.10 99)
+ set(CMAKE_C_OUTPUT_EXTENSION ".r43")
- set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
- set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> -o <TARGET> <OBJECTS> ")
+elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850")
+ __compiler_iar_xlink(C)
+ __compiler_check_default_language_standard(C 1.10 90 4.10 99)
+ set(CMAKE_C_OUTPUT_EXTENSION ".r85")
-endif()
+elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "8051")
+ __compiler_iar_xlink(C)
+ __compiler_check_default_language_standard(C 6.10 90 8.10 99)
+ set(CMAKE_C_OUTPUT_EXTENSION ".r51")
-# add the target specific include directory:
-get_filename_component(_compilerDir "${CMAKE_C_COMPILER}" PATH)
-get_filename_component(_compilerDir "${_compilerDir}" PATH)
-include_directories("${_compilerDir}/inc" )
+else()
+ message(FATAL_ERROR "CMAKE_C_COMPILER_ARCHITECTURE_ID not detected. This should be automatic.")
+endif()
diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake
index f49968e90..eca89c541 100644
--- a/Modules/Compiler/IAR-CXX.cmake
+++ b/Modules/Compiler/IAR-CXX.cmake
@@ -1,35 +1,83 @@
# This file is processed when the IAR compiler is used for a C++ file
include(Compiler/IAR)
+include(Compiler/CMakeCommonCompilerMacros)
-set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
-
-set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>")
-set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy")
-
-set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "-f ")
-set(CMAKE_DEPFILE_FLAGS_CXX "--dependencies=ns <DEPFILE>")
+# Common
+if(NOT CMAKE_CXX_COMPILER_VERSION)
+ message(FATAL_ERROR "CMAKE_CXX_COMPILER_VERSION not detected. This should be automatic.")
+endif()
-if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "ARM")
+if(NOT CMAKE_IAR_CXX_FLAG)
+ # The --c++ flag was introduced in platform version 9 for all architectures except ARM where it was introduced already in version 7
+ if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 8 OR
+ (CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 6 AND "${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") )
+ set(CMAKE_IAR_CXX_FLAG --c++)
+ else()
+ set(CMAKE_IAR_CXX_FLAG --eec++)
+ endif()
+endif()
- set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
- set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> <TARGET> --create <LINK_FLAGS> <OBJECTS> ")
+set(CMAKE_CXX_EXTENSION_COMPILE_OPTION -e)
+if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 7)
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -e)
+ set(CMAKE_CXX03_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX03_EXTENSION_COMPILE_OPTION -e)
endif()
+if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 8)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -e)
+ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -e)
+endif()
-if("${IAR_TARGET_ARCHITECTURE}" STREQUAL "AVR")
- set(CMAKE_CXX_OUTPUT_EXTENSION ".r90")
- if(NOT CMAKE_CXX_LINK_FLAGS)
- set(CMAKE_CXX_LINK_FLAGS "-Fmotorola")
+# Architecture specific
+if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM")
+ if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_LESS 7)
+ # IAR ARM 4.X uses xlink.exe, detection is not yet implemented
+ message(FATAL_ERROR "CMAKE_CXX_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION} not supported by CMake.")
endif()
+ __compiler_iar_ilink(CXX)
+ __compiler_check_default_language_standard(CXX 6.10 98 8.10 14)
- set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
- set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> -o <TARGET> <OBJECTS> ")
+elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX")
+ __compiler_iar_ilink(CXX)
+ __compiler_check_default_language_standard(CXX 2.10 98 4.10 14)
-endif()
+elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850")
+ __compiler_iar_ilink(CXX)
+ __compiler_check_default_language_standard(CXX 1.10 98 2.10 14)
-# add the target specific include directory:
-get_filename_component(_compilerDir "${CMAKE_C_COMPILER}" PATH)
-get_filename_component(_compilerDir "${_compilerDir}" PATH)
-include_directories("${_compilerDir}/inc")
+elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78")
+ __compiler_iar_ilink(CXX)
+ __compiler_check_default_language_standard(CXX 1.10 98 4.10 14)
+
+elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV")
+ __compiler_iar_ilink(CXX)
+ __compiler_check_default_language_standard(CXX 1.10 98 1.10 14)
+
+elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR")
+ __compiler_iar_xlink(CXX)
+ __compiler_check_default_language_standard(CXX 7.10 98)
+
+elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430")
+ __compiler_iar_xlink(CXX)
+ __compiler_check_default_language_standard(CXX 5.10 98)
+ set(CMAKE_CXX_OUTPUT_EXTENSION ".r43")
+
+elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850")
+ __compiler_iar_xlink(CXX)
+ __compiler_check_default_language_standard(CXX 1.10 98)
+ set(CMAKE_C_OUTPUT_EXTENSION ".r85")
+
+elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "8051")
+ __compiler_iar_xlink(CXX)
+ __compiler_check_default_language_standard(CXX 6.10 98)
+ set(CMAKE_C_OUTPUT_EXTENSION ".r51")
+
+else()
+ message(FATAL_ERROR "CMAKE_CXX_COMPILER_ARCHITECTURE_ID not detected. This should be automatic." )
+endif()
diff --git a/Modules/Compiler/IAR-DetermineCompiler.cmake b/Modules/Compiler/IAR-DetermineCompiler.cmake
index c39810a24..0a026b2e8 100644
--- a/Modules/Compiler/IAR-DetermineCompiler.cmake
+++ b/Modules/Compiler/IAR-DetermineCompiler.cmake
@@ -1,4 +1,39 @@
-
-# IAR Systems compiler for embedded systems.
+# IAR Systems compiler for ARM embedded systems.
# http://www.iar.com
-set(_compiler_id_pp_test "defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)")
+# http://supp.iar.com/FilesPublic/UPDINFO/004916/arm/doc/EWARM_DevelopmentGuide.ENU.pdf
+#
+# __IAR_SYSTEMS_ICC__ An integer that identifies the IAR compiler platform:
+# 9 and higher means C11 and C++14 as language default
+# 8 means C99 and C++03 as language default
+# 7 and lower means C89 and EC++ as language default.
+# __ICCARM__ An integer that is set to 1 when the code is compiled with the IAR C/C++ Compiler for ARM
+# __VER__ An integer that identifies the version number of the IAR compiler in use. For example,
+# version 5.11.3 is returned as 5011003.
+#
+# IAR Systems Compiler for AVR embedded systems
+# http://supp.iar.com/FilesPublic/UPDINFO/007051/ew/doc/EWAVR_CompilerReference.pdf
+#
+# __IAR_SYSTEMS_ICC__ An integer that identifies the IAR compiler platform.
+# __ICCAVR__ An integer that is set to 1 when the code is compiled with the IAR C/C++ Compiler for AVR
+# __VER__ An integer that identifies the version number of the IAR compiler in use.
+# The value is calculated by (100 * VERSION_MAJOR + VERSION_MINOR). For example the version
+# 3.34 is given as 334
+# __SUBVERSION__ An integer that identifies the subversion number of the compiler version number
+# for example 3 in 1.2.3.4. THis is used as the patch version, as seen when running iccavr
+# from the command line
+#
+
+set(_compiler_id_pp_test "defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)")
+
+set(_compiler_id_version_compute "
+# if defined(__VER__) && defined(__ICCARM__)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@((__VER__) / 1000000)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(((__VER__) / 1000) % 1000)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@((__VER__) % 1000)
+# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__IAR_SYSTEMS_ICC__)
+# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__))
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@((__VER__) / 100)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@((__VER__) - (((__VER__) / 100)*100))
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__SUBVERSION__)
+# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__IAR_SYSTEMS_ICC__)
+# endif")
diff --git a/Modules/Compiler/IAR-FindBinUtils.cmake b/Modules/Compiler/IAR-FindBinUtils.cmake
new file mode 100644
index 000000000..6ef3759ba
--- /dev/null
+++ b/Modules/Compiler/IAR-FindBinUtils.cmake
@@ -0,0 +1,63 @@
+if(NOT DEFINED _CMAKE_PROCESSING_LANGUAGE OR _CMAKE_PROCESSING_LANGUAGE STREQUAL "")
+ message(FATAL_ERROR "Internal error: _CMAKE_PROCESSING_LANGUAGE is not set")
+endif()
+
+# Try to find tools in the same directory as the compiler itself
+get_filename_component(__iar_hint_1 "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" REALPATH)
+get_filename_component(__iar_hint_1 "${__iar_hint_1}" DIRECTORY)
+
+get_filename_component(__iar_hint_2 "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" DIRECTORY)
+
+set(__iar_hints "${__iar_hint_1}" "${__iar_hint_2}")
+
+if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM" OR
+ "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX" OR
+ "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850" OR
+ "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78" OR
+ "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV")
+
+ string(TOLOWER "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" _archid_lower)
+
+ # Find linker
+ find_program(CMAKE_IAR_LINKER ilink${_archid_lower} HINTS ${__iar_hints}
+ DOC "The IAR ILINK linker")
+ find_program(CMAKE_IAR_ARCHIVE iarchive HINTS ${__iar_hints}
+ DOC "The IAR archiver")
+
+ # Find utility tools
+ find_program(CMAKE_IAR_ELFTOOL ielftool HINTS ${__iar_hints}
+ DOC "The IAR ELF Tool")
+ find_program(CMAKE_IAR_ELFDUMP ielfdump${_archid_lower} HINTS ${__iar_hints}
+ DOC "The IAR ELF Dumper")
+ find_program(CMAKE_IAR_OBJMANIP iobjmanip HINTS ${__iar_hints}
+ DOC "The IAR ELF Object Tool")
+ find_program(CMAKE_IAR_SYMEXPORT isymexport HINTS ${__iar_hints}
+ DOC "The IAR Absolute Symbol Exporter")
+ mark_as_advanced(CMAKE_IAR_LINKER CMAKE_IAR_ARCHIVE CMAKE_IAR_ELFTOOL CMAKE_IAR_ELFDUMP CMAKE_IAR_OBJMANIP CMAKE_IAR_SYMEXPORT)
+
+ set(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_CUSTOM_CODE
+"set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\")
+set(CMAKE_IAR_ARCHIVE \"${CMAKE_IAR_ARCHIVE}\")
+set(CMAKE_IAR_ELFTOOL \"${CMAKE_IAR_ELFTOOL}\")
+set(CMAKE_IAR_ELFDUMP \"${CMAKE_IAR_ELFDUMP}\")
+set(CMAKE_IAR_OBJMANIP \"${CMAKE_IAR_OBJMANIP}\")
+set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\")
+")
+
+elseif("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR" OR
+ "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430" OR
+ "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850" OR
+ "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "8051")
+
+ # Find the "xlink" linker and "xar" archiver:
+ find_program(CMAKE_IAR_LINKER xlink HINTS ${__iar_hints}
+ DOC "The IAR XLINK linker")
+ find_program(CMAKE_IAR_AR xar HINTS ${__iar_hints}
+ DOC "The IAR archiver")
+ mark_as_advanced(CMAKE_IAR_LINKER CMAKE_IAR_AR)
+
+ set(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_CUSTOM_CODE
+"set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\")
+set(CMAKE_IAR_AR \"${CMAKE_IAR_AR}\")
+")
+endif()
diff --git a/Modules/Compiler/IAR.cmake b/Modules/Compiler/IAR.cmake
index 8c45276db..8e75caafe 100644
--- a/Modules/Compiler/IAR.cmake
+++ b/Modules/Compiler/IAR.cmake
@@ -2,46 +2,113 @@
# Documentation can be downloaded here: http://www.iar.com/website1/1.0.1.0/675/1/
# The initial feature request is here: https://gitlab.kitware.com/cmake/cmake/issues/10176
# It also contains additional links and information.
+# See USER GUIDES -> C/C++ Development Guide and ReleaseNotes for EWARM:
+# version 6.30.8: http://supp.iar.com/FilesPublic/UPDINFO/006607/arm/doc/infocenter/index.ENU.html
+# version 7.60.1: http://supp.iar.com/FilesPublic/UPDINFO/011006/arm/doc/infocenter/index.ENU.html
+# version 8.10.1: http://netstorage.iar.com/SuppDB/Public/UPDINFO/011854/arm/doc/infocenter/index.ENU.html
-if(_IAR_CMAKE_LOADED)
- return()
-endif()
-set(_IAR_CMAKE_LOADED TRUE)
+# The IAR internal compiler platform generations (Predefined symbol __IAR_SYSTEMS_ICC__):
+# 9 and higher means C11 and C++14 as language default (EWARM v8.x, EWRX v4.x and higher)
+# 8 means C99 and C++03 as language default (EWARM v6.x, v7.x. EWRX v2.x, 3.x)
+# 7 and lower means C89 and EC++ as language default. (EWARM v5.x and lower)
+# C/C++ Standard versions
+#
+# IAR typically only supports one C and C++ Standard version,
+# the exception is C89 which is always supported and can be selected
+# if its not the default
+#
+# C++ is trickier, there were historically 3 switches,
+# and some IAR versions support multiple of those.
+# they are --eec++, --ec++ and --c++ and where used to
+# enable various language features like exceptions
+#
+# recent versions only have --c++ for full support
+# but can choose to disable features with further arguments
+#
+# C/C++ Standard compliance
+#
+# IAR has 3 modes: default, strict and extended
+# the extended mode is needed for popular libraries like CMSIS
+#
+# "Silent" Operation
+#
+# this really is different to most programs I know.
+# nothing meaningful from the operation is lost, just some redundant
+# code and data size printouts (that can be inspected with common tools).
-get_filename_component(_CMAKE_C_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH)
-get_filename_component(_CMAKE_CXX_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH)
-get_filename_component(_CMAKE_ASM_TOOLCHAIN_LOCATION "${CMAKE_ASM_COMPILER}" PATH)
+# This module is shared by multiple languages; use include blocker.
+include_guard()
-
-if("${CMAKE_C_COMPILER}" MATCHES "arm" OR "${CMAKE_CXX_COMPILER}" MATCHES "arm" OR "${CMAKE_ASM_COMPILER}" MATCHES "arm")
+macro(__compiler_iar_ilink lang)
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
+ if (${lang} STREQUAL "C" OR ${lang} STREQUAL "CXX")
+ set(CMAKE_${lang}_COMPILE_OBJECT "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
+ set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>")
+ set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy")
+
+ set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-f ")
+ set(CMAKE_DEPFILE_FLAGS_${lang} "--dependencies=ns <DEPFILE>")
+
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
+ string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -r")
+ string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Ohz -DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -Oh -DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Oh -r -DNDEBUG")
+ endif()
+
+ if (${lang} STREQUAL "ASM")
+ string(APPEND CMAKE_ASM_FLAGS_INIT " ")
+ string(APPEND CMAKE_ASM_FLAGS_DEBUG_INIT " -r")
+ string(APPEND CMAKE_ASM_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
+ string(APPEND CMAKE_ASM_FLAGS_RELEASE_INIT " -DNDEBUG")
+ string(APPEND CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT " -r -DNDEBUG")
+ endif()
- # For arm, IAR uses the "ilinkarm" linker and "iarchive" archiver:
- find_program(CMAKE_IAR_LINKER ilinkarm HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" "${_CMAKE_ASM_TOOLCHAIN_LOCATION}")
- find_program(CMAKE_IAR_AR iarchive HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" "${_CMAKE_ASM_TOOLCHAIN_LOCATION}" )
+ set(CMAKE_${lang}_LINK_EXECUTABLE "\"${CMAKE_IAR_LINKER}\" --silent <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
+ set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "\"${CMAKE_IAR_ARCHIVE}\" <TARGET> --create <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_CREATE "\"${CMAKE_IAR_ARCHIVE}\" <TARGET> --create <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_APPEND "\"${CMAKE_IAR_ARCHIVE}\" <TARGET> --replace <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_FINISH "")
- set(IAR_TARGET_ARCHITECTURE "ARM" CACHE STRING "IAR compiler target architecture")
-endif()
+ set(CMAKE_LINKER "${CMAKE_IAR_LINKER}" CACHE FILEPATH "The IAR linker" FORCE)
+ set(CMAKE_AR "${CMAKE_IAR_ARCHIVE}" CACHE FILEPATH "The IAR archiver" FORCE)
+endmacro()
-if("${CMAKE_C_COMPILER}" MATCHES "avr" OR "${CMAKE_CXX_COMPILER}" MATCHES "avr" OR "${CMAKE_ASM_COMPILER}" MATCHES "avr")
+macro(__compiler_iar_xlink lang)
set(CMAKE_EXECUTABLE_SUFFIX ".bin")
+ if (${lang} STREQUAL "C" OR ${lang} STREQUAL "CXX")
- # For AVR and AVR32, IAR uses the "xlink" linker and the "xar" archiver:
- find_program(CMAKE_IAR_LINKER xlink HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" "${_CMAKE_ASM_TOOLCHAIN_LOCATION}" )
- find_program(CMAKE_IAR_AR xar HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" "${_CMAKE_ASM_TOOLCHAIN_LOCATION}" )
+ set(CMAKE_${lang}_COMPILE_OBJECT "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>")
+ set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>")
+ set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy")
- set(IAR_TARGET_ARCHITECTURE "AVR" CACHE STRING "IAR compiler target architecture")
+ set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-f ")
+ set(CMAKE_DEPFILE_FLAGS_${lang} "--dependencies=ns <DEPFILE>")
- set(CMAKE_LIBRARY_PATH_FLAG "-I")
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " ")
+ string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -r")
+ string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Ohz -DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -Oh -DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Oh -r -DNDEBUG")
+ endif()
+
+ if (${lang} STREQUAL "ASM")
+ string(APPEND CMAKE_ASM_FLAGS_INIT " ")
+ string(APPEND CMAKE_ASM_FLAGS_DEBUG_INIT " -r")
+ string(APPEND CMAKE_ASM_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
+ string(APPEND CMAKE_ASM_FLAGS_RELEASE_INIT " -DNDEBUG")
+ string(APPEND CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT " -r -DNDEBUG")
+ endif()
-endif()
+ set(CMAKE_${lang}_LINK_EXECUTABLE "\"${CMAKE_IAR_LINKER}\" -S <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>")
+ set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "\"${CMAKE_IAR_AR}\" <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_CREATE "\"${CMAKE_IAR_AR}\" <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_APPEND "")
+ set(CMAKE_${lang}_ARCHIVE_FINISH "")
-if(NOT IAR_TARGET_ARCHITECTURE)
- message(FATAL_ERROR "The IAR compiler for this architecture is not yet supported "
- "by CMake. Please go to https://gitlab.kitware.com/cmake/cmake/issues "
- "and enter a feature request there.")
-endif()
+ set(CMAKE_LIBRARY_PATH_FLAG "-I")
-set(CMAKE_LINKER "${CMAKE_IAR_LINKER}" CACHE FILEPATH "The IAR linker" FORCE)
-set(CMAKE_AR "${CMAKE_IAR_AR}" CACHE FILEPATH "The IAR archiver" FORCE)
+ set(CMAKE_LINKER "${CMAKE_IAR_LINKER}" CACHE FILEPATH "The IAR linker" FORCE)
+ set(CMAKE_AR "${CMAKE_IAR_AR}" CACHE FILEPATH "The IAR archiver" FORCE)
+endmacro()
diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake
index 4e4af2956..e9e59a20c 100644
--- a/Modules/Compiler/Intel-C.cmake
+++ b/Modules/Compiler/Intel-C.cmake
@@ -12,13 +12,16 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 16.0.0)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-Qstd=c11")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-Qstd=c11")
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
endif()
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-Qstd=c89")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-Qstd=c89")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION "-Qstd=c99")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-Qstd=c99")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
endif()
else()
@@ -26,13 +29,16 @@ else()
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
endif()
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
endif()
endif()
diff --git a/Modules/Compiler/Intel-CXX-FeatureTests.cmake b/Modules/Compiler/Intel-CXX-FeatureTests.cmake
index 929a7c632..bbefe15de 100644
--- a/Modules/Compiler/Intel-CXX-FeatureTests.cmake
+++ b/Modules/Compiler/Intel-CXX-FeatureTests.cmake
@@ -31,11 +31,6 @@ set(_cmake_feature_test_cxx_aggregate_default_initializers "${Intel16_CXX14}")
set(_cmake_feature_test_cxx_contextual_conversions "${Intel16_CXX14}")
set(_cmake_feature_test_cxx_generic_lambdas "__cpp_generic_lambdas >= 201304")
set(_cmake_feature_test_cxx_digit_separators "${Intel16_CXX14}")
-# This test is supposed to work in Intel 14 but the compiler has a bug
-# in versions 14 and 15::
-# https://software.intel.com/en-us/forums/intel-c-compiler/topic/600514
-# It also appears to fail with an internal compiler error on Intel 16 and 17.
-#set(_cmake_feature_test_cxx_generalized_initializers "${Intel16_CXX14}")
unset(Intel16_CXX14)
set(Intel15 "__INTEL_COMPILER >= 1500")
@@ -75,6 +70,7 @@ set(_cmake_feature_test_cxx_override "${Intel14_CXX11}")
set(_cmake_feature_test_cxx_final "${Intel14_CXX11}")
set(_cmake_feature_test_cxx_noexcept "${Intel14_CXX11}")
set(_cmake_feature_test_cxx_defaulted_move_initializers "${Intel14_CXX11}")
+set(_cmake_feature_test_cxx_generalized_initializers "${Intel14_CXX11}")
unset(Intel14_CXX11)
set(Intel13_CXX11 "__INTEL_COMPILER >= 1300 && ${DETECT_CXX11}")
diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake
index 0eb9e1fd7..b630a6bc4 100644
--- a/Modules/Compiler/Intel-CXX.cmake
+++ b/Modules/Compiler/Intel-CXX.cmake
@@ -9,6 +9,11 @@ set(CMAKE_DEPFILE_FLAGS_CXX "-MD -MT <OBJECT> -MF <DEPFILE>")
if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.0)
+ set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-Qstd=c++17")
+ set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-Qstd=c++17")
+ endif()
+
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0)
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-Qstd=c++14")
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-Qstd=c++14")
@@ -25,18 +30,36 @@ if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1)
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "")
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
endif()
else()
+ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.0)
+ set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17")
+ set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17")
+ endif()
+
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.0)
+ set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
+ endif()
+
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0.2)
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14")
- # todo: there is no gnu++14 value supported; figure out what to do
- set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=c++14")
elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0.0)
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
- # todo: there is no gnu++14 value supported; figure out what to do
- set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=c++1y")
+ endif()
+
+ # Intel 15.0.2 accepts c++14 instead of c++1y, but not gnu++14
+ # instead of gnu++1y. Intel 17.0.0 accepts gnu++14 too.
+ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.0)
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
+ elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0.0)
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
+ endif()
+
+ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0)
+ set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON)
endif()
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0)
@@ -50,6 +73,7 @@ else()
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1)
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
+ set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
endif()
endif()
diff --git a/Modules/Compiler/Intel-DetermineCompiler.cmake b/Modules/Compiler/Intel-DetermineCompiler.cmake
index d7e453211..c31aa7752 100644
--- a/Modules/Compiler/Intel-DetermineCompiler.cmake
+++ b/Modules/Compiler/Intel-DetermineCompiler.cmake
@@ -18,9 +18,23 @@ set(_compiler_id_version_compute "
/* _MSC_VER = VVRR */
# define @PREFIX@SIMULATE_VERSION_MAJOR @MACRO_DEC@(_MSC_VER / 100)
# define @PREFIX@SIMULATE_VERSION_MINOR @MACRO_DEC@(_MSC_VER % 100)
+# endif
+# if defined(__GNUC__)
+# define @PREFIX@SIMULATE_VERSION_MAJOR @MACRO_DEC@(__GNUC__)
+# elif defined(__GNUG__)
+# define @PREFIX@SIMULATE_VERSION_MAJOR @MACRO_DEC@(__GNUG__)
+# endif
+# if defined(__GNUC_MINOR__)
+# define @PREFIX@SIMULATE_VERSION_MINOR @MACRO_DEC@(__GNUC_MINOR__)
+# endif
+# if defined(__GNUC_PATCHLEVEL__)
+# define @PREFIX@SIMULATE_VERSION_PATCH @MACRO_DEC@(__GNUC_PATCHLEVEL__)
# endif")
set(_compiler_id_simulate "
# if defined(_MSC_VER)
# define @PREFIX@SIMULATE_ID \"MSVC\"
+# endif
+# if defined(__GNUC__)
+# define @PREFIX@SIMULATE_ID \"GNU\"
# endif")
diff --git a/Modules/Compiler/Intel-Fortran.cmake b/Modules/Compiler/Intel-Fortran.cmake
index a1320555a..156b5339a 100644
--- a/Modules/Compiler/Intel-Fortran.cmake
+++ b/Modules/Compiler/Intel-Fortran.cmake
@@ -1,10 +1,15 @@
include(Compiler/Intel)
__compiler_intel(Fortran)
+set(CMAKE_Fortran_SUBMODULE_SEP "@")
+set(CMAKE_Fortran_SUBMODULE_EXT ".smod")
+
set(CMAKE_Fortran_MODDIR_FLAG "-module ")
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed")
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free")
+set(CMAKE_Fortran_COMPILE_WITH_DEFINES 1)
+
set(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
set(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE "<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
diff --git a/Modules/Compiler/Intel.cmake b/Modules/Compiler/Intel.cmake
index 635ac4d3c..d895ed023 100644
--- a/Modules/Compiler/Intel.cmake
+++ b/Modules/Compiler/Intel.cmake
@@ -25,6 +25,19 @@ else()
string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3")
string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g")
- set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-QdM" "-P" "-Za" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
+ set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}")
+ if(CMAKE_${lang}_COMPILER_ARG1)
+ separate_arguments(_COMPILER_ARGS NATIVE_COMMAND "${CMAKE_${lang}_COMPILER_ARG1}")
+ list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND ${_COMPILER_ARGS})
+ unset(_COMPILER_ARGS)
+ endif()
+ list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-QdM" "-P" "-Za" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
+
+ # Precompile Headers
+ set(CMAKE_PCH_EXTENSION .pchi)
+ set(CMAKE_LINK_PCH ON)
+ set(CMAKE_PCH_EPILOGUE "#pragma hdrstop")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Winvalid-pch -Wno-pch-messages -pch-use <PCH_FILE> -include <PCH_HEADER>)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Winvalid-pch -Wno-pch-messages -pch-create <PCH_FILE> -include <PCH_HEADER>)
endmacro()
endif()
diff --git a/Modules/Compiler/MIPSpro-C.cmake b/Modules/Compiler/MIPSpro-C.cmake
deleted file mode 100644
index 675560c2a..000000000
--- a/Modules/Compiler/MIPSpro-C.cmake
+++ /dev/null
@@ -1 +0,0 @@
-set(CMAKE_C_VERBOSE_FLAG "-v")
diff --git a/Modules/Compiler/MIPSpro-CXX.cmake b/Modules/Compiler/MIPSpro-CXX.cmake
deleted file mode 100644
index 9fb191c75..000000000
--- a/Modules/Compiler/MIPSpro-CXX.cmake
+++ /dev/null
@@ -1 +0,0 @@
-set(CMAKE_CXX_VERBOSE_FLAG "-v")
diff --git a/Modules/Compiler/MIPSpro-DetermineCompiler.cmake b/Modules/Compiler/MIPSpro-DetermineCompiler.cmake
deleted file mode 100644
index 9e485532b..000000000
--- a/Modules/Compiler/MIPSpro-DetermineCompiler.cmake
+++ /dev/null
@@ -1,15 +0,0 @@
-
-set(_compiler_id_pp_test "defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)")
-
-set(_compiler_id_version_compute "
-# if defined(_SGI_COMPILER_VERSION)
- /* _SGI_COMPILER_VERSION = VRP */
-# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_SGI_COMPILER_VERSION/100)
-# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(_SGI_COMPILER_VERSION/10 % 10)
-# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(_SGI_COMPILER_VERSION % 10)
-# else
- /* _COMPILER_VERSION = VRP */
-# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_COMPILER_VERSION/100)
-# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(_COMPILER_VERSION/10 % 10)
-# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(_COMPILER_VERSION % 10)
-# endif")
diff --git a/Modules/Compiler/MIPSpro-Fortran.cmake b/Modules/Compiler/MIPSpro-Fortran.cmake
deleted file mode 100644
index ffceea80d..000000000
--- a/Modules/Compiler/MIPSpro-Fortran.cmake
+++ /dev/null
@@ -1,3 +0,0 @@
-set(CMAKE_Fortran_VERBOSE_FLAG "-v")
-set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixedform")
-set(CMAKE_Fortran_FORMAT_FREE_FLAG "-freeform")
diff --git a/Modules/Compiler/MSVC-ASM.cmake b/Modules/Compiler/MSVC-ASM.cmake
new file mode 100644
index 000000000..45978c5e2
--- /dev/null
+++ b/Modules/Compiler/MSVC-ASM.cmake
@@ -0,0 +1 @@
+# This file is loaded when Visual Studio is used for the ASM language.
diff --git a/Modules/Compiler/MSVC-C-FeatureTests.cmake b/Modules/Compiler/MSVC-C-FeatureTests.cmake
new file mode 100644
index 000000000..3f09be201
--- /dev/null
+++ b/Modules/Compiler/MSVC-C-FeatureTests.cmake
@@ -0,0 +1,8 @@
+set(_cmake_oldestSupported "_MSC_VER >= 1600")
+
+# Not yet supported:
+#set(_cmake_feature_test_c_static_assert "")
+#set(_cmake_feature_test_c_restrict "")
+
+set(_cmake_feature_test_c_variadic_macros "${_cmake_oldestSupported}")
+set(_cmake_feature_test_c_function_prototypes "${_cmake_oldestSupported}")
diff --git a/Modules/Compiler/MSVC-C.cmake b/Modules/Compiler/MSVC-C.cmake
new file mode 100644
index 000000000..20787a399
--- /dev/null
+++ b/Modules/Compiler/MSVC-C.cmake
@@ -0,0 +1,38 @@
+# MSVC has no specific options to set C language standards, but set them as
+# empty strings anyways so the feature test infrastructure can at least check
+# to see if they are defined.
+set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
+set(CMAKE_C90_EXTENSION_COMPILE_OPTION "")
+set(CMAKE_C99_STANDARD_COMPILE_OPTION "")
+set(CMAKE_C99_EXTENSION_COMPILE_OPTION "")
+set(CMAKE_C11_STANDARD_COMPILE_OPTION "")
+set(CMAKE_C11_EXTENSION_COMPILE_OPTION "")
+
+# There is no meaningful default for this
+set(CMAKE_C_STANDARD_DEFAULT "")
+
+# There are no C compiler modes so we hard-code the known compiler supported
+# features. Override the default macro for this special case. Pretend that
+# all language standards are available so that at least compilation
+# can be attempted.
+macro(cmake_record_c_compile_features)
+ list(APPEND CMAKE_C_COMPILE_FEATURES
+ c_std_90
+ c_std_99
+ c_std_11
+ c_function_prototypes
+ )
+ list(APPEND CMAKE_C90_COMPILE_FEATURES c_std_90 c_function_prototypes)
+ list(APPEND CMAKE_C99_COMPILE_FEATURES c_std_99)
+ list(APPEND CMAKE_C11_COMPILE_FEATURES c_std_11)
+ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0)
+ list(APPEND CMAKE_C_COMPILE_FEATURES c_variadic_macros)
+ list(APPEND CMAKE_C99_COMPILE_FEATURES c_variadic_macros)
+ endif()
+ set(_result 0) # expected by cmake_determine_compile_features
+endmacro()
+
+# /JMC "Just My Code" is only supported by MSVC 19.05 onward.
+if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05)
+ set(CMAKE_C_COMPILE_OPTIONS_JMC "-JMC")
+endif()
diff --git a/Modules/Compiler/MSVC-CXX-FeatureTests.cmake b/Modules/Compiler/MSVC-CXX-FeatureTests.cmake
index 596958668..125974a8d 100644
--- a/Modules/Compiler/MSVC-CXX-FeatureTests.cmake
+++ b/Modules/Compiler/MSVC-CXX-FeatureTests.cmake
@@ -1,15 +1,18 @@
+# Reference: https://docs.microsoft.com/en-us/cpp/visual-cpp-language-conformance
+# https://blogs.msdn.microsoft.com/vcblog/2015/06/19/c111417-features-in-vs-2015-rtm/
+# https://blogs.msdn.microsoft.com/vcblog/2013/12/02/c1114-core-language-features-in-vs-2013-and-the-nov-2013-ctp/
+# https://blogs.msdn.microsoft.com/vcblog/2011/09/12/c11-features-in-visual-c-11/
-# Reference: http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx
-# http://blogs.msdn.com/b/vcblog/archive/2013/06/28/c-11-14-stl-features-fixes-and-breaking-changes-in-vs-2013.aspx
-# http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx
-# http://www.visualstudio.com/en-us/news/vs2015-preview-vs.aspx
-# http://blogs.msdn.com/b/vcblog/archive/2015/04/29/c-11-14-17-features-in-vs-2015-rc.aspx
-# http://blogs.msdn.com/b/vcblog/archive/2015/06/19/c-11-14-17-features-in-vs-2015-rtm.aspx
+set(_cmake_oldestSupported "_MSC_VER >= 1600")
+# VS 2017 v15.3 fixes support for incomplete decltypes
+# https://docs.microsoft.com/en-us/cpp/cpp-conformance-improvements-2017#update_153
+set(_cmake_feature_test_cxx_decltype_incomplete_return_types "_MSC_VER >= 1911")
-set(_cmake_oldestSupported "_MSC_VER >= 1600")
+# VS 2017 v15.3 fixes support for "N3652 Extended constexpr"
+set(_cmake_feature_test_cxx_relaxed_constexpr "_MSC_VER >= 1911")
-# VS version 15 (not 2015) introduces support for aggregate initializers.
+# VS 2017 Preview introduces support for aggregate initializers.
set(_cmake_feature_test_cxx_aggregate_default_initializers "_MSC_FULL_VER >= 190024406")
# VS 2015 Update 2 introduces support for variable templates.
@@ -48,7 +51,6 @@ set(_cmake_feature_test_cxx_reference_qualified_functions "${MSVC_2015}")
# lists this as 'partial' in 2013
set(_cmake_feature_test_cxx_deleted_functions "${MSVC_2015}")
-set(MSVC_2013_v30723 "_MSC_FULL_VER >= 180030723")
# http://blogs.msdn.com/b/vcblog/archive/2014/11/17/c-11-14-17-features-in-vs-2015-preview.aspx
# Note 1. While previous version of VisualStudio said they supported these
# they silently produced bad code, and are now marked as having partial
@@ -56,7 +58,7 @@ set(MSVC_2013_v30723 "_MSC_FULL_VER >= 180030723")
# in MSVC 2015, so support the feature for that version, assuming that is true.
# The blog post also says that VS 2013 Update 3 generates an error in cases
# that previously produced bad code.
-set(_cmake_feature_test_cxx_generalized_initializers "${MSVC_2013_v30723}")
+set(_cmake_feature_test_cxx_generalized_initializers "_MSC_FULL_VER >= 180030723")
set(MSVC_2013 "_MSC_VER >= 1800")
set(_cmake_feature_test_cxx_alias_templates "${MSVC_2013}")
@@ -98,20 +100,10 @@ set(_cmake_feature_test_cxx_template_template_parameters "${MSVC_2010}")
set(_cmake_feature_test_cxx_trailing_return_types "${MSVC_2010}")
set(_cmake_feature_test_cxx_variadic_macros "${MSVC_2010}")
-# Currently unsupported:
-# set(_cmake_feature_test_cxx_relaxed_constexpr )
-# 'NSDMIs for aggregates'
-# set(_cmake_feature_test_cxx_aggregate_default_initializers )
-
-# In theory decltype incomplete return types was added in 2012
-# but without support for decltype_auto and return type deduction this
-# feature is unusable. This remains so as of VS 2015 Preview.
-# set(_cmake_feature_test_cxx_decltype_incomplete_return_types )
-
# Unset all the variables that we don't need exposed.
# _cmake_oldestSupported is required by WriteCompilerDetectionHeader
+set(MSVC_2017)
set(MSVC_2015)
-set(MSVC_2013_v30723)
set(MSVC_2013)
set(MSVC_2012)
set(MSVC_2010)
diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake
index 9371301d7..915295d38 100644
--- a/Modules/Compiler/MSVC-CXX.cmake
+++ b/Modules/Compiler/MSVC-CXX.cmake
@@ -3,7 +3,36 @@
include(Compiler/CMakeCommonCompilerMacros)
-if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)
+if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0.24215.1 AND
+ CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) OR
+ CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.10.25017)
+
+ # VS 2015 Update 3 and above support language standard level flags,
+ # with the default and minimum level being C++14.
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std:c++14")
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std:c++14")
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.11.25505)
+ set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std:c++17")
+ set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std:c++17")
+ else()
+ set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std:c++latest")
+ set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std:c++latest")
+ endif()
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.12.25835)
+ set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std:c++latest")
+ set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std:c++latest")
+ endif()
+
+ __compiler_check_default_language_standard(CXX 19.0 14)
+
+elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)
# MSVC has no specific options to set language standards, but set them as
# empty strings anyways so the feature test infrastructure can at least check
# to see if they are defined.
@@ -15,7 +44,29 @@ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "")
set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "")
set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "")
# There is no meaningful default for this
set(CMAKE_CXX_STANDARD_DEFAULT "")
+
+ # There are no compiler modes so we only need to test features once.
+ # Override the default macro for this special case. Pretend that
+ # all language standards are available so that at least compilation
+ # can be attempted.
+ macro(cmake_record_cxx_compile_features)
+ list(APPEND CMAKE_CXX_COMPILE_FEATURES
+ cxx_std_98
+ cxx_std_11
+ cxx_std_14
+ cxx_std_17
+ cxx_std_20
+ )
+ _record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES)
+ endmacro()
+endif()
+
+# /JMC "Just My Code" is only supported by MSVC 19.05 onward.
+if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05)
+ set(CMAKE_CXX_COMPILE_OPTIONS_JMC "-JMC")
endif()
diff --git a/Modules/Compiler/NAG-Fortran.cmake b/Modules/Compiler/NAG-Fortran.cmake
index 39aae1883..edc56fd22 100644
--- a/Modules/Compiler/NAG-Fortran.cmake
+++ b/Modules/Compiler/NAG-Fortran.cmake
@@ -28,9 +28,12 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS AND NOT CMAKE_Fortran_COMPILER_FORCED)
endif()
endif()
+set(CMAKE_Fortran_SUBMODULE_SEP ".")
+set(CMAKE_Fortran_SUBMODULE_EXT ".sub")
set(CMAKE_Fortran_MODDIR_FLAG "-mdir ")
set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-PIC")
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed")
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free")
set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-PIC")
set(CMAKE_Fortran_COMPILE_OPTIONS_PIE "-PIC")
+set(CMAKE_Fortran_RESPONSE_FILE_LINK_FLAG "-Wl,@")
diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake
index 785e26998..b59deda17 100644
--- a/Modules/Compiler/NVIDIA-CUDA.cmake
+++ b/Modules/Compiler/NVIDIA-CUDA.cmake
@@ -1,4 +1,6 @@
+set(CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE True)
set(CMAKE_CUDA_VERBOSE_FLAG "-v")
+set(CMAKE_CUDA_VERBOSE_COMPILE_FLAG "-Xcompiler=-v")
if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
set(CMAKE_CUDA_COMPILE_OPTIONS_PIE -Xcompiler=-fPIE)
@@ -26,8 +28,21 @@ else()
set(CMAKE_CUDA11_EXTENSION_COMPILE_OPTION "-std=c++11")
if (NOT CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0)
+ set(CMAKE_CUDA98_STANDARD_COMPILE_OPTION "-std=c++03")
+ set(CMAKE_CUDA98_EXTENSION_COMPILE_OPTION "-std=c++03")
set(CMAKE_CUDA14_STANDARD_COMPILE_OPTION "-std=c++14")
set(CMAKE_CUDA14_EXTENSION_COMPILE_OPTION "-std=c++14")
endif()
endif()
+
+# FIXME: investigate use of --options-file.
+# Tell Makefile generator that nvcc does not support @<rspfile> syntax.
+set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_INCLUDES 0)
+set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_LIBRARIES 0)
+set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_OBJECTS 0)
+
+if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "9.0")
+ set(CMAKE_CUDA_RESPONSE_FILE_LINK_FLAG "--options-file ")
+ set(CMAKE_CUDA_RESPONSE_FILE_FLAG "--options-file ")
+endif()
diff --git a/Modules/Compiler/NVIDIA-DetermineCompiler.cmake b/Modules/Compiler/NVIDIA-DetermineCompiler.cmake
index cb0beaf52..bf9111a24 100644
--- a/Modules/Compiler/NVIDIA-DetermineCompiler.cmake
+++ b/Modules/Compiler/NVIDIA-DetermineCompiler.cmake
@@ -2,9 +2,11 @@
set(_compiler_id_pp_test "defined(__NVCC__)")
set(_compiler_id_version_compute "
-# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__CUDACC_VER_MAJOR__)
-# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__CUDACC_VER_MINOR__)
-# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__CUDACC_VER_BUILD__)
+# if defined(__CUDACC_VER_MAJOR__)
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__CUDACC_VER_MAJOR__)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__CUDACC_VER_MINOR__)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__CUDACC_VER_BUILD__)
+# endif
# if defined(_MSC_VER)
/* _MSC_VER = VVRR */
# define @PREFIX@SIMULATE_VERSION_MAJOR @MACRO_DEC@(_MSC_VER / 100)
diff --git a/Modules/Compiler/PGI-C.cmake b/Modules/Compiler/PGI-C.cmake
index 3b3848a2c..c39dbe517 100644
--- a/Modules/Compiler/PGI-C.cmake
+++ b/Modules/Compiler/PGI-C.cmake
@@ -6,11 +6,14 @@ string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG")
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.10)
set(CMAKE_C90_STANDARD_COMPILE_OPTION -c89)
set(CMAKE_C90_EXTENSION_COMPILE_OPTION -c89)
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION -c99)
set(CMAKE_C99_EXTENSION_COMPILE_OPTION -c99)
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15.3)
set(CMAKE_C11_STANDARD_COMPILE_OPTION -c11)
set(CMAKE_C11_EXTENSION_COMPILE_OPTION -c11)
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
endif ()
endif ()
diff --git a/Modules/Compiler/PGI-CXX.cmake b/Modules/Compiler/PGI-CXX.cmake
index 35076bb38..c77de3605 100644
--- a/Modules/Compiler/PGI-CXX.cmake
+++ b/Modules/Compiler/PGI-CXX.cmake
@@ -6,15 +6,19 @@ string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12.10)
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -A)
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION --gnu_extensions)
+ set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.10)
set(CMAKE_CXX11_STANDARD_COMPILE_OPTION --c++11 -A)
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION --c++11 --gnu_extensions)
+ set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.7)
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION --c++14 -A)
set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION --c++14 --gnu_extensions)
+ set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.1)
set(CMAKE_CXX17_STANDARD_COMPILE_OPTION --c++17 -A)
set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION --c++17 --gnu_extensions)
+ set(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT ON)
endif()
endif()
endif()
diff --git a/Modules/Compiler/PGI-Fortran.cmake b/Modules/Compiler/PGI-Fortran.cmake
index 478342436..3daf7987e 100644
--- a/Modules/Compiler/PGI-Fortran.cmake
+++ b/Modules/Compiler/PGI-Fortran.cmake
@@ -1,13 +1,15 @@
include(Compiler/PGI)
__compiler_pgi(Fortran)
+set(CMAKE_Fortran_SUBMODULE_SEP "-")
+set(CMAKE_Fortran_SUBMODULE_EXT ".mod")
+
set(CMAKE_Fortran_PREPROCESS_SOURCE
"<CMAKE_Fortran_COMPILER> -Mpreprocess <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-Mnofreeform")
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-Mfreeform")
-string(APPEND CMAKE_Fortran_FLAGS_INIT " -Mpreprocess -Kieee")
string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " -Mbounds")
set(CMAKE_Fortran_MODDIR_FLAG "-module ")
diff --git a/Modules/Compiler/PGI.cmake b/Modules/Compiler/PGI.cmake
index 0cbfd8a0b..4f8b90b13 100644
--- a/Modules/Compiler/PGI.cmake
+++ b/Modules/Compiler/PGI.cmake
@@ -19,16 +19,23 @@ macro(__compiler_pgi lang)
string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -O0")
string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O2 -s")
string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -fast -O3")
- # -Mipa was dropped with PGI 16.3 from Windows versions
- if(NOT CMAKE_HOST_WIN32 OR CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 16.3)
- string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -Mipa=fast")
- endif()
string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -gopt")
if(CMAKE_HOST_WIN32)
string(APPEND CMAKE_${lang}_FLAGS_INIT " -Bdynamic")
endif()
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,")
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG ",")
+
+ set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
+ if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ppc64le AND (NOT CMAKE_HOST_WIN32 OR CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 16.3))
+ set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-Mipa=fast,inline")
+ else()
+ set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO)
+ endif()
+
# Preprocessing and assembly rules.
set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
diff --git a/Modules/Compiler/QCC-ASM.cmake b/Modules/Compiler/QCC-ASM.cmake
new file mode 100644
index 000000000..9a9935b27
--- /dev/null
+++ b/Modules/Compiler/QCC-ASM.cmake
@@ -0,0 +1,2 @@
+include(Compiler/QCC)
+__compiler_qcc(ASM)
diff --git a/Modules/Compiler/QCC-C-FeatureTests.cmake b/Modules/Compiler/QCC-C-FeatureTests.cmake
new file mode 100644
index 000000000..68f41970d
--- /dev/null
+++ b/Modules/Compiler/QCC-C-FeatureTests.cmake
@@ -0,0 +1 @@
+include(Compiler/GNU-C-FeatureTests)
diff --git a/Modules/Compiler/QCC-C.cmake b/Modules/Compiler/QCC-C.cmake
index ae4a2f491..6db619e57 100644
--- a/Modules/Compiler/QCC-C.cmake
+++ b/Modules/Compiler/QCC-C.cmake
@@ -1,2 +1,5 @@
+# To include compiler feature detection
+include(Compiler/GNU-C)
+
include(Compiler/QCC)
__compiler_qcc(C)
diff --git a/Modules/Compiler/QCC-CXX-FeatureTests.cmake b/Modules/Compiler/QCC-CXX-FeatureTests.cmake
new file mode 100644
index 000000000..c836b9416
--- /dev/null
+++ b/Modules/Compiler/QCC-CXX-FeatureTests.cmake
@@ -0,0 +1 @@
+include(Compiler/GNU-CXX-FeatureTests)
diff --git a/Modules/Compiler/QCC-CXX.cmake b/Modules/Compiler/QCC-CXX.cmake
index e86d1fa47..0e7314ae5 100644
--- a/Modules/Compiler/QCC-CXX.cmake
+++ b/Modules/Compiler/QCC-CXX.cmake
@@ -1,3 +1,6 @@
+# To include compiler feature detection
+include(Compiler/GNU-CXX)
+
include(Compiler/QCC)
__compiler_qcc(CXX)
diff --git a/Modules/Compiler/QCC.cmake b/Modules/Compiler/QCC.cmake
index 0da7050ba..9df826909 100644
--- a/Modules/Compiler/QCC.cmake
+++ b/Modules/Compiler/QCC.cmake
@@ -11,11 +11,22 @@ macro(__compiler_qcc lang)
set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-V")
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-Wp,-isystem,")
- set(CMAKE_DEPFILE_FLAGS_${lang} "-Wc,-MD,<DEPFILE>,-MT,<OBJECT>,-MF,<DEPFILE>")
+ set(CMAKE_DEPFILE_FLAGS_${lang} "-Wp,-MD,<DEPFILE> -Wp,-MT,<OBJECT> -Wp,-MF,<DEPFILE>")
+
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,")
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",")
set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE NO)
set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO)
+ set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}")
+ if(CMAKE_${lang}_COMPILER_ARG1)
+ separate_arguments(_COMPILER_ARGS NATIVE_COMMAND "${CMAKE_${lang}_COMPILER_ARG1}")
+ list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND ${_COMPILER_ARGS})
+ unset(_COMPILER_ARGS)
+ endif()
+ list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-Wp,-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
+
unset(CMAKE_${lang}_COMPILE_OPTIONS_IPO)
unset(CMAKE_${lang}_ARCHIVE_CREATE_IPO)
unset(CMAKE_${lang}_ARCHIVE_APPEND_IPO)
diff --git a/Modules/Compiler/SCO.cmake b/Modules/Compiler/SCO.cmake
index c55a048a5..7f643d920 100644
--- a/Modules/Compiler/SCO.cmake
+++ b/Modules/Compiler/SCO.cmake
@@ -15,4 +15,7 @@ macro(__compiler_sco lang)
set(CMAKE_${lang}_COMPILE_OPTIONS_DLL -belf)
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-Kpic -belf")
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-belf -Wl,-Bexport")
+
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,")
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",")
endmacro()
diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake
index 29c2f22f9..7e962b8ee 100644
--- a/Modules/Compiler/SunPro-C.cmake
+++ b/Modules/Compiler/SunPro-C.cmake
@@ -6,6 +6,10 @@ include(Compiler/SunPro)
set(CMAKE_C_VERBOSE_FLAG "-#")
set(CMAKE_C_COMPILE_OPTIONS_PIC -KPIC)
+set(CMAKE_C_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_C_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
+set(CMAKE_C_LINK_OPTIONS_PIE "")
+set(CMAKE_C_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-KPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-G")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-R")
@@ -18,6 +22,8 @@ string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -xO2 -xspace -DNDEBUG")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -xO3 -DNDEBUG")
string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -g -xO2 -DNDEBUG")
+set(CMAKE_DEPFILE_FLAGS_C "-xMD -xMF <DEPFILE>")
+
# Initialize C link type selection flags. These flags are used when
# building a shared library, shared module, or executable that links
# to other libraries to select whether to use the static or shared
@@ -27,13 +33,19 @@ foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Bdynamic")
endforeach()
+set(CMAKE_C_LINKER_WRAPPER_FLAG "-Qoption" "ld" " ")
+set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",")
+
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.13)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=c89")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=c99")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=c11")
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
elseif (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.11)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "")
diff --git a/Modules/Compiler/SunPro-CXX-FeatureTests.cmake b/Modules/Compiler/SunPro-CXX-FeatureTests.cmake
index 60280cadc..e7133c153 100644
--- a/Modules/Compiler/SunPro-CXX-FeatureTests.cmake
+++ b/Modules/Compiler/SunPro-CXX-FeatureTests.cmake
@@ -1,10 +1,22 @@
# Based on GNU 4.8.2
-# http://docs.oracle.com/cd/E37069_01/html/E37071/gncix.html
+# https://docs.oracle.com/cd/E37069_01/html/E37071/gncix.html
+# https://docs.oracle.com/cd/E77782_01/html/E77784/gkeza.html
# Reference: http://gcc.gnu.org/projects/cxx0x.html
set(_cmake_oldestSupported "__SUNPRO_CC >= 0x5130")
+set(SolarisStudio126_CXX14 "(__SUNPRO_CC >= 0x5150) && __cplusplus >= 201402L")
+set(_cmake_feature_test_cxx_aggregate_default_initializers "${SolarisStudio126_CXX14}")
+set(_cmake_feature_test_cxx_digit_separators "${SolarisStudio126_CXX14}")
+set(_cmake_feature_test_cxx_generic_lambdas "${SolarisStudio126_CXX14}")
+set(_cmake_feature_test_cxx_lambda_init_captures "${SolarisStudio126_CXX14}")
+set(_cmake_feature_test_cxx_return_type_deduction "${SolarisStudio126_CXX14}")
+set(_cmake_feature_test_cxx_variable_templates "${SolarisStudio126_CXX14}")
+
+set(SolarisStudio126_CXX11 "(__SUNPRO_CC >= 0x5150) && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_decltype_auto "${SolarisStudio126_CXX11}")
+
set(SolarisStudio125_CXX11 "(__SUNPRO_CC >= 0x5140) && __cplusplus >= 201103L")
set(_cmake_feature_test_cxx_binary_literals "${SolarisStudio125_CXX11}")
set(_cmake_feature_test_cxx_reference_qualified_functions "${SolarisStudio125_CXX11}")
diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake
index 5cb7edced..c946c6436 100644
--- a/Modules/Compiler/SunPro-CXX.cmake
+++ b/Modules/Compiler/SunPro-CXX.cmake
@@ -6,6 +6,10 @@ include(Compiler/SunPro)
set(CMAKE_CXX_VERBOSE_FLAG "-v")
set(CMAKE_CXX_COMPILE_OPTIONS_PIC -KPIC)
+set(CMAKE_CXX_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_CXX_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
+set(CMAKE_CXX_LINK_OPTIONS_PIE "")
+set(CMAKE_CXX_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-KPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-G")
set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-R")
@@ -18,6 +22,8 @@ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -xO2 -xspace -DNDEBUG")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -xO3 -DNDEBUG")
string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " -g -xO2 -DNDEBUG")
+set(CMAKE_DEPFILE_FLAGS_CXX "-xMD -xMF <DEPFILE>")
+
# Initialize C link type selection flags. These flags are used when
# building a shared library, shared module, or executable that links
# to other libraries to select whether to use the static or shared
@@ -27,6 +33,9 @@ foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
set(CMAKE_${type}_LINK_DYNAMIC_CXX_FLAGS "-Bdynamic")
endforeach()
+set(CMAKE_CXX_LINKER_WRAPPER_FLAG "-Qoption" "ld" " ")
+set(CMAKE_CXX_LINKER_WRAPPER_FLAG_SEP ",")
+
set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
@@ -39,9 +48,15 @@ set(CMAKE_CXX_CREATE_STATIC_LIBRARY
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++03")
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=c++03")
+ set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11")
set(CMAKE_CXX_LINK_WITH_STANDARD_COMPILE_OPTION 1)
+
+ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.14)
+ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=c++14")
+ endif()
else()
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-library=stlport4")
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-library=stlport4")
diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake
index 9b25c0b25..0c93c94a8 100644
--- a/Modules/Compiler/SunPro-Fortran.cmake
+++ b/Modules/Compiler/SunPro-Fortran.cmake
@@ -3,6 +3,10 @@ set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed")
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free")
set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-KPIC")
+set(CMAKE_Fortran_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_Fortran_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
+set(CMAKE_Fortran_LINK_OPTIONS_PIE "")
+set(CMAKE_Fortran_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-KPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-G")
set(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG "-R")
@@ -18,6 +22,9 @@ string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT " -g -xO2 -DNDEBUG")
set(CMAKE_Fortran_MODDIR_FLAG "-moddir=")
set(CMAKE_Fortran_MODPATH_FLAG "-M")
+set(CMAKE_Fortran_LINKER_WRAPPER_FLAG "-Qoption" "ld" " ")
+set(CMAKE_Fortran_LINKER_WRAPPER_FLAG_SEP ",")
+
set(CMAKE_Fortran_PREPROCESS_SOURCE
"<CMAKE_Fortran_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -F -fpp <SOURCE> -o <PREPROCESSED_SOURCE>")
diff --git a/Modules/Compiler/TI-C.cmake b/Modules/Compiler/TI-C.cmake
index ebc79f424..1c0f4bc1f 100644
--- a/Modules/Compiler/TI-C.cmake
+++ b/Modules/Compiler/TI-C.cmake
@@ -2,6 +2,14 @@ set(CMAKE_LIBRARY_PATH_FLAG "--search_path=")
set(CMAKE_LINK_LIBRARY_FLAG "--library=")
set(CMAKE_INCLUDE_FLAG_C "--include_path=")
+set(CMAKE_C90_STANDARD_COMPILE_OPTION "--c89")
+set(CMAKE_C90_EXTENSION_COMPILE_OPTION "--c89 --relaxed_ansi")
+
+set(CMAKE_C99_STANDARD_COMPILE_OPTION "--c99")
+set(CMAKE_C99_EXTENSION_COMPILE_OPTION "--c99 --relaxed_ansi")
+
+set(CMAKE_DEPFILE_FLAGS_C "--preproc_with_compile --preproc_dependency=<DEPFILE>")
+
set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> --compile_only --skip_assembler --c_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<ASSEMBLY_SOURCE>")
set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> --preproc_only --c_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<PREPROCESSED_SOURCE>")
diff --git a/Modules/Compiler/TI-CXX.cmake b/Modules/Compiler/TI-CXX.cmake
index 4104c3b18..4c6af06cd 100644
--- a/Modules/Compiler/TI-CXX.cmake
+++ b/Modules/Compiler/TI-CXX.cmake
@@ -2,6 +2,8 @@ set(CMAKE_LIBRARY_PATH_FLAG "--search_path=")
set(CMAKE_LINK_LIBRARY_FLAG "--library=")
set(CMAKE_INCLUDE_FLAG_CXX "--include_path=")
+set(CMAKE_DEPFILE_FLAGS_CXX "--preproc_with_compile --preproc_dependency=<DEPFILE>")
+
set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE "<CMAKE_CXX_COMPILER> --compile_only --skip_assembler --cpp_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<ASSEMBLY_SOURCE>")
set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> --preproc_only --cpp_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<PREPROCESSED_SOURCE>")
diff --git a/Modules/Compiler/TinyCC-C.cmake b/Modules/Compiler/TinyCC-C.cmake
index fbd2841e3..6367695b9 100644
--- a/Modules/Compiler/TinyCC-C.cmake
+++ b/Modules/Compiler/TinyCC-C.cmake
@@ -6,3 +6,6 @@ string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " -g")
string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG")
string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " -g -DNDEBUG")
+
+set(CMAKE_C_LINKER_WRAPPER_FLAG "-Wl,")
+set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",")
diff --git a/Modules/Compiler/XL-C.cmake b/Modules/Compiler/XL-C.cmake
index 5dc8bc17f..2077bdabd 100644
--- a/Modules/Compiler/XL-C.cmake
+++ b/Modules/Compiler/XL-C.cmake
@@ -6,36 +6,18 @@ string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
# -qthreaded = Ensures that all optimizations will be thread-safe
string(APPEND CMAKE_C_FLAGS_INIT " -qthreaded")
-# XL v13.1.1 for Linux ppc64 little-endian switched to using a clang based
-# front end and accepts the -std= option while only reserving -qlanglevel= for
-# compatibility. All other versions (previous versions on Linux ppc64
-# little-endian, all versions on Linux ppc64 big-endian, all versions on AIX
-# and BGQ, etc) are derived from the UNIX compiler and only accept the
-# -qlanglvl option.
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1)
- if (CMAKE_SYSTEM MATCHES "Linux.*ppc64le" AND
- CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1)
- set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89")
- set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89")
- set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
- set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
- if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2)
- set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
- set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
- else ()
- set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x")
- set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x")
- endif ()
- else ()
- set(CMAKE_C90_STANDARD_COMPILE_OPTION "-qlanglvl=stdc89")
- set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-qlanglvl=extc89")
- set(CMAKE_C99_STANDARD_COMPILE_OPTION "-qlanglvl=stdc99")
- set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-qlanglvl=extc99")
- if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.1)
- set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x")
- set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x")
- endif ()
+ set(CMAKE_C90_STANDARD_COMPILE_OPTION "-qlanglvl=stdc89")
+ set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-qlanglvl=extc89")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_C99_STANDARD_COMPILE_OPTION "-qlanglvl=stdc99")
+ set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-qlanglvl=extc99")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
+ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.1)
+ set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x")
+ set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x")
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
endif ()
endif()
-__compiler_check_default_language_standard(C 10.1 90)
+__compiler_check_default_language_standard(C 10.1 90 11.1 99)
diff --git a/Modules/Compiler/XL-CXX.cmake b/Modules/Compiler/XL-CXX.cmake
index b87e9238b..303785112 100644
--- a/Modules/Compiler/XL-CXX.cmake
+++ b/Modules/Compiler/XL-CXX.cmake
@@ -6,41 +6,23 @@ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG")
# -qthreaded = Ensures that all optimizations will be thread-safe
string(APPEND CMAKE_CXX_FLAGS_INIT " -qthreaded")
-# XL v13.1.1 for Linux ppc64 little-endian switched to using a clang based
-# front end and accepts the -std= option while only reserving -qlanglevel= for
-# compatibility. All other versions (previous versions on Linux ppc64
-# little-endian, all versions on Linux ppc64 big-endian, all versions on AIX
-# and BGQ, etc) are derived from the UNIX compiler and only accept the
-# -qlanglvl option.
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1)
- if (CMAKE_SYSTEM MATCHES "Linux.*ppc64")
- if (CMAKE_SYSTEM MATCHES "Linux.*ppc64le" AND
- CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1)
- set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
- set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
- if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2)
- set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
- set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
- set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
- set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-qlanglvl=extended1y")
- else ()
- set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x")
- set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x")
- endif ()
- else ()
- # The non-clang based Linux ppc64 compiler, both big-endian and
- # little-endian lacks, the non-extension language level flags
- set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-qlanglvl=extended")
- set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-qlanglvl=extended")
- set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x")
- set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x")
- endif ()
- else ()
+ if(CMAKE_SYSTEM MATCHES "Linux")
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "")
+ else()
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-qlanglvl=strict98")
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-qlanglvl=extended")
- set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x")
- set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x")
- endif ()
+ endif()
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x")
+ set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON)
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.1.0)
+ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-qlanglvl=extended1y")
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-qlanglvl=extended1y")
+ set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
+ endif()
endif ()
__compiler_check_default_language_standard(CXX 10.1 98)
diff --git a/Modules/Compiler/XL-Fortran.cmake b/Modules/Compiler/XL-Fortran.cmake
index 6bab6f69e..c4fb09712 100644
--- a/Modules/Compiler/XL-Fortran.cmake
+++ b/Modules/Compiler/XL-Fortran.cmake
@@ -1,6 +1,9 @@
include(Compiler/XL)
__compiler_xl(Fortran)
+set(CMAKE_Fortran_SUBMODULE_SEP "_")
+set(CMAKE_Fortran_SUBMODULE_EXT ".smod")
+
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-qfixed") # [=<right_margin>]
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-qfree") # [=f90|ibm]
diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake
index 478378570..fc71ab489 100644
--- a/Modules/Compiler/XL.cmake
+++ b/Modules/Compiler/XL.cmake
@@ -10,16 +10,18 @@ set(__COMPILER_XL 1)
include(Compiler/CMakeCommonCompilerMacros)
-# Find the CreateExportList program that comes with this toolchain.
-find_program(CMAKE_XL_CreateExportList
- NAMES CreateExportList
- DOC "IBM XL CreateExportList tool"
- )
-
macro(__compiler_xl lang)
# Feature flags.
set(CMAKE_${lang}_VERBOSE_FLAG "-V")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-qpic")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-qpic")
+ set(CMAKE_${lang}_RESPONSE_FILE_FLAG "-qoptfile=")
+ set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-qoptfile=")
+
+ set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj")
+
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,")
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",")
string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g")
string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O")
@@ -28,19 +30,5 @@ macro(__compiler_xl lang)
set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
- # CMAKE_XL_CreateExportList is part of the AIX XL compilers but not the linux ones.
- # If we found the tool, we'll use it to create exports, otherwise stick with the regular
- # create shared library compile line.
- if (CMAKE_XL_CreateExportList)
- # The compiler front-end passes all object files, archive files, and shared
- # library files named on the command line to CreateExportList to create a
- # list of all symbols to be exported from the shared library. This causes
- # all archive members to be copied into the shared library whether they are
- # needed or not. Instead we run the tool ourselves to pass only the object
- # files so that we export only the symbols actually provided by the sources.
- set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
- "${CMAKE_XL_CreateExportList} <OBJECT_DIR>/objects.exp <OBJECTS>"
- "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
- )
- endif()
+ set(CMAKE_DEPFILE_FLAGS_${lang} "-MF <DEPFILE> -qmakedep=gcc")
endmacro()
diff --git a/Modules/Compiler/XLClang-C-DetermineCompiler.cmake b/Modules/Compiler/XLClang-C-DetermineCompiler.cmake
new file mode 100644
index 000000000..4d899213a
--- /dev/null
+++ b/Modules/Compiler/XLClang-C-DetermineCompiler.cmake
@@ -0,0 +1,8 @@
+set(_compiler_id_pp_test "defined(__ibmxl__) && defined(__clang__)")
+
+set(_compiler_id_version_compute "
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__ibmxl_version__)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__ibmxl_release__)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__ibmxl_modification__)
+# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__ibmxl_ptf_fix_level__)
+")
diff --git a/Modules/Compiler/XLClang-C.cmake b/Modules/Compiler/XLClang-C.cmake
new file mode 100644
index 000000000..54c18a668
--- /dev/null
+++ b/Modules/Compiler/XLClang-C.cmake
@@ -0,0 +1,20 @@
+include(Compiler/XLClang)
+__compiler_xlclang(C)
+
+if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1)
+ set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89")
+ set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89")
+ set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99")
+ set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99")
+ set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x")
+ set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x")
+ if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2)
+ set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
+ set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
+ set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON)
+ endif ()
+endif()
+
+__compiler_check_default_language_standard(C 13.1.1 99)
diff --git a/Modules/Compiler/XLClang-CXX-DetermineCompiler.cmake b/Modules/Compiler/XLClang-CXX-DetermineCompiler.cmake
new file mode 100644
index 000000000..4d899213a
--- /dev/null
+++ b/Modules/Compiler/XLClang-CXX-DetermineCompiler.cmake
@@ -0,0 +1,8 @@
+set(_compiler_id_pp_test "defined(__ibmxl__) && defined(__clang__)")
+
+set(_compiler_id_version_compute "
+# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__ibmxl_version__)
+# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__ibmxl_release__)
+# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__ibmxl_modification__)
+# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__ibmxl_ptf_fix_level__)
+")
diff --git a/Modules/Compiler/XLClang-CXX.cmake b/Modules/Compiler/XLClang-CXX.cmake
new file mode 100644
index 000000000..9ea3d7cac
--- /dev/null
+++ b/Modules/Compiler/XLClang-CXX.cmake
@@ -0,0 +1,27 @@
+include(Compiler/XLClang)
+__compiler_xlclang(CXX)
+
+if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1)
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x")
+ set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON)
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
+ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
+ set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
+ endif ()
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.1.0)
+ set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
+ endif()
+endif()
+
+__compiler_check_default_language_standard(CXX 13.1.1 98)
+
+set(CMAKE_CXX_COMPILE_OBJECT
+ "<CMAKE_CXX_COMPILER> -x c++ <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
diff --git a/Modules/Compiler/XLClang.cmake b/Modules/Compiler/XLClang.cmake
new file mode 100644
index 000000000..cdf0fdca1
--- /dev/null
+++ b/Modules/Compiler/XLClang.cmake
@@ -0,0 +1,22 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+# This module is shared by multiple languages; use include blocker.
+if(__COMPILER_XLCLANG)
+ return()
+endif()
+set(__COMPILER_XLCLANG 1)
+
+include(Compiler/XL)
+
+macro(__compiler_xlclang lang)
+ __compiler_xl(${lang})
+
+ # Feature flags.
+ set(CMAKE_${lang}_VERBOSE_FLAG "-V")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIC")
+ set(CMAKE_${lang}_RESPONSE_FILE_FLAG "@")
+ set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@")
+endmacro()
diff --git a/Modules/CompilerId/GHS_default.gpj.in b/Modules/CompilerId/GHS_default.gpj.in
new file mode 100644
index 000000000..b5cea5cf8
--- /dev/null
+++ b/Modules/CompilerId/GHS_default.gpj.in
@@ -0,0 +1,8 @@
+#!gbuild
+@bsp_name@
+@os_dir@
+primaryTarget=@ghs_primary_target@
+[Project]
+ {isdefined(GHS_BSP)} -bsp $GHS_BSP
+ {isdefined(GHS_OS)} -os_dir $GHS_OS
+GHS_lib.gpj [Library]
diff --git a/Modules/CompilerId/GHS_lib.gpj.in b/Modules/CompilerId/GHS_lib.gpj.in
new file mode 100644
index 000000000..149b98144
--- /dev/null
+++ b/Modules/CompilerId/GHS_lib.gpj.in
@@ -0,0 +1,3 @@
+#!gbuild
+[Library]
+@id_src@
diff --git a/Modules/CompilerId/VS-10.vcxproj.in b/Modules/CompilerId/VS-10.vcxproj.in
index 6b9b361cc..d742274c4 100644
--- a/Modules/CompilerId/VS-10.vcxproj.in
+++ b/Modules/CompilerId/VS-10.vcxproj.in
@@ -14,7 +14,9 @@
@id_system_version@
@id_WindowsTargetPlatformVersion@
@id_WindowsSDKDesktopARMSupport@
+ @id_CudaToolkitCustomDir@
</PropertyGroup>
+ @id_toolset_version_props@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup>
@id_PreferredToolArchitecture@
diff --git a/Modules/CompilerId/Xcode-3.pbxproj.in b/Modules/CompilerId/Xcode-3.pbxproj.in
index 84f48ae65..672044e13 100644
--- a/Modules/CompilerId/Xcode-3.pbxproj.in
+++ b/Modules/CompilerId/Xcode-3.pbxproj.in
@@ -58,7 +58,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "echo \"GCC_VERSION=$GCC_VERSION\" ; echo \"CURRENT_ARCH=$CURRENT_ARCH\"";
+ shellScript = "echo \"GCC_VERSION=$GCC_VERSION\" ; echo \"ARCHS=$ARCHS\"";
showEnvVarsInLog = 0;
};
2C18F0B515DC1DCE00593670 = {
@@ -72,6 +72,7 @@
1DEB928608733DD80010E9CD = {
isa = XCBuildConfiguration;
buildSettings = {
+ CODE_SIGN_IDENTITY = "";
PRODUCT_NAME = CompilerId@id_lang@;
};
name = Debug;
@@ -85,6 +86,7 @@
SYMROOT = .;
@id_toolset@
@id_lang_version@
+ @id_clang_cxx_library@
@id_deployment_target@
@id_sdkroot@
};
diff --git a/Modules/Dart.cmake b/Modules/Dart.cmake
index e003cd5cc..154fe9d7d 100644
--- a/Modules/Dart.cmake
+++ b/Modules/Dart.cmake
@@ -1,27 +1,28 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# Dart
-# ----
-#
-# Configure a project for testing with CTest or old Dart Tcl Client
-#
-# This file is the backwards-compatibility version of the CTest module.
-# It supports using the old Dart 1 Tcl client for driving dashboard
-# submissions as well as testing with CTest. This module should be
-# included in the CMakeLists.txt file at the top of a project. Typical
-# usage:
-#
-# ::
-#
-# include(Dart)
-# if(BUILD_TESTING)
-# # ... testing related CMake code ...
-# endif()
-#
-# The BUILD_TESTING option is created by the Dart module to determine
-# whether testing support should be enabled. The default is ON.
+#[=======================================================================[.rst:
+Dart
+----
+
+Configure a project for testing with CTest or old Dart Tcl Client
+
+This file is the backwards-compatibility version of the CTest module.
+It supports using the old Dart 1 Tcl client for driving dashboard
+submissions as well as testing with CTest. This module should be
+included in the CMakeLists.txt file at the top of a project. Typical
+usage:
+
+::
+
+ include(Dart)
+ if(BUILD_TESTING)
+ # ... testing related CMake code ...
+ endif()
+
+The BUILD_TESTING option is created by the Dart module to determine
+whether testing support should be enabled. The default is ON.
+#]=======================================================================]
# This file configures a project to use the Dart testing/dashboard process.
# It is broken into 3 sections.
diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in
index 0ff2eed8b..e4513b363 100644
--- a/Modules/DartConfiguration.tcl.in
+++ b/Modules/DartConfiguration.tcl.in
@@ -16,18 +16,11 @@ Site: @SITE@
# Build name is osname-revision-compiler, i.e. Linux-2.4.2-2smp-c++
BuildName: @BUILDNAME@
+# Subprojects
+LabelsForSubprojects: @CTEST_LABELS_FOR_SUBPROJECTS@
+
# Submission information
-IsCDash: @CTEST_DROP_SITE_CDASH@
-CDashVersion: @CTEST_CDASH_VERSION@
-QueryCDashVersion: @CTEST_CDASH_QUERY_VERSION@
-DropSite: @DROP_SITE@
-DropLocation: @DROP_LOCATION@
-DropSiteUser: @DROP_SITE_USER@
-DropSitePassword: @DROP_SITE_PASSWORD@
-DropSiteMode: @DROP_SITE_MODE@
-DropMethod: @DROP_METHOD@
-TriggerSite: @TRIGGER_SITE@
-ScpCommand: @SCPCOMMAND@
+SubmitURL: @SUBMIT_URL@
# Dashboard start time
NightlyStartTime: @NIGHTLY_START_TIME@
diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake
index 8ada451a6..4a18927c2 100644
--- a/Modules/DeployQt4.cmake
+++ b/Modules/DeployQt4.cmake
@@ -1,380 +1,400 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# DeployQt4
-# ---------
-#
-# Functions to help assemble a standalone Qt4 executable.
-#
-# A collection of CMake utility functions useful for deploying Qt4
-# executables.
-#
-# The following functions are provided by this module:
-#
-# ::
-#
-# write_qt4_conf
-# resolve_qt4_paths
-# fixup_qt4_executable
-# install_qt4_plugin_path
-# install_qt4_plugin
-# install_qt4_executable
-#
-# Requires CMake 2.6 or greater because it uses function and
-# PARENT_SCOPE. Also depends on BundleUtilities.cmake.
-#
-# ::
-#
-# WRITE_QT4_CONF(<qt_conf_dir> <qt_conf_contents>)
-#
-# Writes a qt.conf file with the <qt_conf_contents> into <qt_conf_dir>.
-#
-# ::
-#
-# RESOLVE_QT4_PATHS(<paths_var> [<executable_path>])
-#
-# Loop through <paths_var> list and if any don't exist resolve them
-# relative to the <executable_path> (if supplied) or the
-# CMAKE_INSTALL_PREFIX.
-#
-# ::
-#
-# FIXUP_QT4_EXECUTABLE(<executable>
-# [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf>])
-#
-# Copies Qt plugins, writes a Qt configuration file (if needed) and
-# fixes up a Qt4 executable using BundleUtilities so it is standalone
-# and can be drag-and-drop copied to another machine as long as all of
-# the system libraries are compatible.
-#
-# <executable> should point to the executable to be fixed-up.
-#
-# <qtplugins> should contain a list of the names or paths of any Qt
-# plugins to be installed.
-#
-# <libs> will be passed to BundleUtilities and should be a list of any
-# already installed plugins, libraries or executables to also be
-# fixed-up.
-#
-# <dirs> will be passed to BundleUtilities and should contain and
-# directories to be searched to find library dependencies.
-#
-# <plugins_dir> allows an custom plugins directory to be used.
-#
-# <request_qt_conf> will force a qt.conf file to be written even if not
-# needed.
-#
-# ::
-#
-# INSTALL_QT4_PLUGIN_PATH(plugin executable copy installed_plugin_path_var
-# <plugins_dir> <component> <configurations>)
-#
-# Install (or copy) a resolved <plugin> to the default plugins directory
-# (or <plugins_dir>) relative to <executable> and store the result in
-# <installed_plugin_path_var>.
-#
-# If <copy> is set to TRUE then the plugins will be copied rather than
-# installed. This is to allow this module to be used at CMake time
-# rather than install time.
-#
-# If <component> is set then anything installed will use this COMPONENT.
-#
-# ::
-#
-# INSTALL_QT4_PLUGIN(plugin executable copy installed_plugin_path_var
-# <plugins_dir> <component>)
-#
-# Install (or copy) an unresolved <plugin> to the default plugins
-# directory (or <plugins_dir>) relative to <executable> and store the
-# result in <installed_plugin_path_var>. See documentation of
-# INSTALL_QT4_PLUGIN_PATH.
-#
-# ::
-#
-# INSTALL_QT4_EXECUTABLE(<executable>
-# [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf> <component>])
-#
-# Installs Qt plugins, writes a Qt configuration file (if needed) and
-# fixes up a Qt4 executable using BundleUtilities so it is standalone
-# and can be drag-and-drop copied to another machine as long as all of
-# the system libraries are compatible. The executable will be fixed-up
-# at install time. <component> is the COMPONENT used for bundle fixup
-# and plugin installation. See documentation of FIXUP_QT4_BUNDLE.
+#[=======================================================================[.rst:
+DeployQt4
+---------
+
+Functions to help assemble a standalone Qt4 executable.
+
+A collection of CMake utility functions useful for deploying Qt4
+executables.
+
+The following functions are provided by this module:
+
+::
+
+ write_qt4_conf
+ resolve_qt4_paths
+ fixup_qt4_executable
+ install_qt4_plugin_path
+ install_qt4_plugin
+ install_qt4_executable
+
+Requires CMake 2.6 or greater because it uses function and
+PARENT_SCOPE. Also depends on BundleUtilities.cmake.
+
+::
+
+ write_qt4_conf(<qt_conf_dir> <qt_conf_contents>)
+
+Writes a qt.conf file with the <qt_conf_contents> into <qt_conf_dir>.
+
+::
+
+ resolve_qt4_paths(<paths_var> [<executable_path>])
+
+Loop through <paths_var> list and if any don't exist resolve them
+relative to the <executable_path> (if supplied) or the
+CMAKE_INSTALL_PREFIX.
+
+::
+
+ fixup_qt4_executable(<executable>
+ [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf>])
+
+Copies Qt plugins, writes a Qt configuration file (if needed) and
+fixes up a Qt4 executable using BundleUtilities so it is standalone
+and can be drag-and-drop copied to another machine as long as all of
+the system libraries are compatible.
+
+<executable> should point to the executable to be fixed-up.
+
+<qtplugins> should contain a list of the names or paths of any Qt
+plugins to be installed.
+
+<libs> will be passed to BundleUtilities and should be a list of any
+already installed plugins, libraries or executables to also be
+fixed-up.
+
+<dirs> will be passed to BundleUtilities and should contain and
+directories to be searched to find library dependencies.
+
+<plugins_dir> allows an custom plugins directory to be used.
+
+<request_qt_conf> will force a qt.conf file to be written even if not
+needed.
+
+::
+
+ install_qt4_plugin_path(plugin executable copy installed_plugin_path_var
+ <plugins_dir> <component> <configurations>)
+
+Install (or copy) a resolved <plugin> to the default plugins directory
+(or <plugins_dir>) relative to <executable> and store the result in
+<installed_plugin_path_var>.
+
+If <copy> is set to TRUE then the plugins will be copied rather than
+installed. This is to allow this module to be used at CMake time
+rather than install time.
+
+If <component> is set then anything installed will use this COMPONENT.
+
+::
+
+ install_qt4_plugin(plugin executable copy installed_plugin_path_var
+ <plugins_dir> <component>)
+
+Install (or copy) an unresolved <plugin> to the default plugins
+directory (or <plugins_dir>) relative to <executable> and store the
+result in <installed_plugin_path_var>. See documentation of
+INSTALL_QT4_PLUGIN_PATH.
+
+::
+
+ install_qt4_executable(<executable>
+ [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf> <component>])
+
+Installs Qt plugins, writes a Qt configuration file (if needed) and
+fixes up a Qt4 executable using BundleUtilities so it is standalone
+and can be drag-and-drop copied to another machine as long as all of
+the system libraries are compatible. The executable will be fixed-up
+at install time. <component> is the COMPONENT used for bundle fixup
+and plugin installation. See documentation of FIXUP_QT4_BUNDLE.
+#]=======================================================================]
# The functions defined in this file depend on the fixup_bundle function
# (and others) found in BundleUtilities.cmake
-include("${CMAKE_CURRENT_LIST_DIR}/BundleUtilities.cmake")
set(DeployQt4_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
set(DeployQt4_apple_plugins_dir "PlugIns")
function(write_qt4_conf qt_conf_dir qt_conf_contents)
- set(qt_conf_path "${qt_conf_dir}/qt.conf")
- message(STATUS "Writing ${qt_conf_path}")
- file(WRITE "${qt_conf_path}" "${qt_conf_contents}")
+ set(qt_conf_path "${qt_conf_dir}/qt.conf")
+ message(STATUS "Writing ${qt_conf_path}")
+ file(WRITE "${qt_conf_path}" "${qt_conf_contents}")
endfunction()
function(resolve_qt4_paths paths_var)
- unset(executable_path)
- if(ARGC GREATER 1)
- set(executable_path ${ARGV1})
- endif()
-
- set(paths_resolved)
- foreach(path ${${paths_var}})
- if(EXISTS "${path}")
- list(APPEND paths_resolved "${path}")
- else()
- if(${executable_path})
- list(APPEND paths_resolved "${executable_path}/${path}")
- else()
- list(APPEND paths_resolved "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${path}")
- endif()
- endif()
- endforeach()
- set(${paths_var} ${paths_resolved} PARENT_SCOPE)
-endfunction()
+ unset(executable_path)
+ if(ARGC GREATER 1)
+ set(executable_path ${ARGV1})
+ endif()
-function(fixup_qt4_executable executable)
- unset(qtplugins)
- if(ARGC GREATER 1)
- set(qtplugins ${ARGV1})
- endif()
- unset(libs)
- if(ARGC GREATER 2)
- set(libs ${ARGV2})
- endif()
- unset(dirs)
- if(ARGC GREATER 3)
- set(dirs ${ARGV3})
- endif()
- unset(plugins_dir)
- if(ARGC GREATER 4)
- set(plugins_dir ${ARGV4})
- endif()
- unset(request_qt_conf)
- if(ARGC GREATER 5)
- set(request_qt_conf ${ARGV5})
- endif()
-
- message(STATUS "fixup_qt4_executable")
- message(STATUS " executable='${executable}'")
- message(STATUS " qtplugins='${qtplugins}'")
- message(STATUS " libs='${libs}'")
- message(STATUS " dirs='${dirs}'")
- message(STATUS " plugins_dir='${plugins_dir}'")
- message(STATUS " request_qt_conf='${request_qt_conf}'")
-
- if(QT_LIBRARY_DIR)
- list(APPEND dirs "${QT_LIBRARY_DIR}")
- endif()
- if(QT_BINARY_DIR)
- list(APPEND dirs "${QT_BINARY_DIR}")
- endif()
-
- if(APPLE)
- set(qt_conf_dir "${executable}/Contents/Resources")
- set(executable_path "${executable}")
- set(write_qt_conf TRUE)
- if(NOT DEFINED plugins_dir)
- set(plugins_dir "${DeployQt4_apple_plugins_dir}")
- endif()
- else()
- get_filename_component(executable_path "${executable}" PATH)
- if(NOT executable_path)
- set(executable_path ".")
- endif()
- set(qt_conf_dir "${executable_path}")
- set(write_qt_conf ${request_qt_conf})
- endif()
-
- foreach(plugin ${qtplugins})
- set(installed_plugin_path "")
- install_qt4_plugin("${plugin}" "${executable}" 1 installed_plugin_path)
- list(APPEND libs ${installed_plugin_path})
- endforeach()
-
- foreach(lib ${libs})
- if(NOT EXISTS "${lib}")
- message(FATAL_ERROR "Library does not exist: ${lib}")
- endif()
- endforeach()
-
- resolve_qt4_paths(libs "${executable_path}")
-
- if(write_qt_conf)
- set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}")
- write_qt4_conf("${qt_conf_dir}" "${qt_conf_contents}")
- endif()
-
- fixup_bundle("${executable}" "${libs}" "${dirs}")
+ set(paths_resolved)
+ foreach(path ${${paths_var}})
+ if(EXISTS "${path}")
+ list(APPEND paths_resolved "${path}")
+ else()
+ if(${executable_path})
+ list(APPEND paths_resolved "${executable_path}/${path}")
+ else()
+ list(APPEND paths_resolved "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${path}")
+ endif()
+ endif()
+ endforeach()
+ set(${paths_var} ${paths_resolved} PARENT_SCOPE)
endfunction()
+cmake_policy(GET CMP0080 _cmp0080_value)
+if(NOT DEFINED CMAKE_GENERATOR OR NOT _cmp0080_value STREQUAL "NEW")
+ set(_CMP0080_SUPPRESS_WARNING TRUE)
+ include("${CMAKE_CURRENT_LIST_DIR}/BundleUtilities.cmake")
+ unset(_CMP0080_SUPPRESS_WARNING)
+
+ function(fixup_qt4_executable executable)
+ cmake_policy(GET CMP0080 _cmp0080_value)
+ if(_cmp0080_value STREQUAL "" AND DEFINED CMAKE_GENERATOR)
+ _warn_cmp0080()
+ endif()
+
+ unset(qtplugins)
+ if(ARGC GREATER 1)
+ set(qtplugins ${ARGV1})
+ endif()
+ unset(libs)
+ if(ARGC GREATER 2)
+ set(libs ${ARGV2})
+ endif()
+ unset(dirs)
+ if(ARGC GREATER 3)
+ set(dirs ${ARGV3})
+ endif()
+ unset(plugins_dir)
+ if(ARGC GREATER 4)
+ set(plugins_dir ${ARGV4})
+ endif()
+ unset(request_qt_conf)
+ if(ARGC GREATER 5)
+ set(request_qt_conf ${ARGV5})
+ endif()
+
+ message(STATUS "fixup_qt4_executable")
+ message(STATUS " executable='${executable}'")
+ message(STATUS " qtplugins='${qtplugins}'")
+ message(STATUS " libs='${libs}'")
+ message(STATUS " dirs='${dirs}'")
+ message(STATUS " plugins_dir='${plugins_dir}'")
+ message(STATUS " request_qt_conf='${request_qt_conf}'")
+
+ if(QT_LIBRARY_DIR)
+ list(APPEND dirs "${QT_LIBRARY_DIR}")
+ endif()
+ if(QT_BINARY_DIR)
+ list(APPEND dirs "${QT_BINARY_DIR}")
+ endif()
+
+ if(APPLE)
+ set(qt_conf_dir "${executable}/Contents/Resources")
+ set(executable_path "${executable}")
+ set(write_qt_conf TRUE)
+ if(NOT DEFINED plugins_dir)
+ set(plugins_dir "${DeployQt4_apple_plugins_dir}")
+ endif()
+ else()
+ get_filename_component(executable_path "${executable}" PATH)
+ if(NOT executable_path)
+ set(executable_path ".")
+ endif()
+ set(qt_conf_dir "${executable_path}")
+ set(write_qt_conf ${request_qt_conf})
+ endif()
+
+ foreach(plugin ${qtplugins})
+ set(installed_plugin_path "")
+ install_qt4_plugin("${plugin}" "${executable}" 1 installed_plugin_path)
+ list(APPEND libs ${installed_plugin_path})
+ endforeach()
+
+ foreach(lib ${libs})
+ if(NOT EXISTS "${lib}")
+ message(FATAL_ERROR "Library does not exist: ${lib}")
+ endif()
+ endforeach()
+
+ resolve_qt4_paths(libs "${executable_path}")
+
+ if(write_qt_conf)
+ set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}")
+ write_qt4_conf("${qt_conf_dir}" "${qt_conf_contents}")
+ endif()
+
+ fixup_bundle("${executable}" "${libs}" "${dirs}")
+ endfunction()
+endif()
+
function(install_qt4_plugin_path plugin executable copy installed_plugin_path_var)
- unset(plugins_dir)
- if(ARGC GREATER 4)
- set(plugins_dir ${ARGV4})
- endif()
- unset(component)
- if(ARGC GREATER 5)
- set(component ${ARGV5})
- endif()
+ unset(plugins_dir)
+ if(ARGC GREATER 4)
+ set(plugins_dir ${ARGV4})
+ endif()
+ unset(component)
+ if(ARGC GREATER 5)
+ set(component ${ARGV5})
+ endif()
+ unset(configurations)
+ if(ARGC GREATER 6)
+ set(configurations ${ARGV6})
+ endif()
+
+ if(EXISTS "${plugin}")
+ if(APPLE)
+ if(NOT plugins_dir)
+ set(plugins_dir "${DeployQt4_apple_plugins_dir}")
+ endif()
+ set(plugins_path "${executable}/Contents/${plugins_dir}")
+ else()
+ get_filename_component(plugins_path "${executable}" PATH)
+ if(NOT plugins_path)
+ set(plugins_path ".")
+ endif()
+ if(plugins_dir)
+ string(APPEND plugins_path "/${plugins_dir}")
+ endif()
+ endif()
+
+ set(plugin_group "")
+
+ get_filename_component(plugin_path "${plugin}" PATH)
+ get_filename_component(plugin_parent_path "${plugin_path}" PATH)
+ get_filename_component(plugin_parent_dir_name "${plugin_parent_path}" NAME)
+ get_filename_component(plugin_name "${plugin}" NAME)
+ string(TOLOWER "${plugin_parent_dir_name}" plugin_parent_dir_name)
+
+ if("${plugin_parent_dir_name}" STREQUAL "plugins")
+ get_filename_component(plugin_group "${plugin_path}" NAME)
+ set(${plugin_group_var} "${plugin_group}")
+ endif()
+ string(APPEND plugins_path "/${plugin_group}")
+
+ if(${copy})
+ file(MAKE_DIRECTORY "${plugins_path}")
+ file(COPY "${plugin}" DESTINATION "${plugins_path}")
+ else()
+ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if(configurations AND (_isMultiConfig OR CMAKE_BUILD_TYPE))
+ set(configurations CONFIGURATIONS ${configurations})
+ else()
unset(configurations)
- if(ARGC GREATER 6)
- set(configurations ${ARGV6})
- endif()
-
- if(EXISTS "${plugin}")
- if(APPLE)
- if(NOT plugins_dir)
- set(plugins_dir "${DeployQt4_apple_plugins_dir}")
- endif()
- set(plugins_path "${executable}/Contents/${plugins_dir}")
- else()
- get_filename_component(plugins_path "${executable}" PATH)
- if(NOT plugins_path)
- set(plugins_path ".")
- endif()
- if(plugins_dir)
- string(APPEND plugins_path "/${plugins_dir}")
- endif()
- endif()
-
- set(plugin_group "")
-
- get_filename_component(plugin_path "${plugin}" PATH)
- get_filename_component(plugin_parent_path "${plugin_path}" PATH)
- get_filename_component(plugin_parent_dir_name "${plugin_parent_path}" NAME)
- get_filename_component(plugin_name "${plugin}" NAME)
- string(TOLOWER "${plugin_parent_dir_name}" plugin_parent_dir_name)
-
- if("${plugin_parent_dir_name}" STREQUAL "plugins")
- get_filename_component(plugin_group "${plugin_path}" NAME)
- set(${plugin_group_var} "${plugin_group}")
- endif()
- string(APPEND plugins_path "/${plugin_group}")
-
- if(${copy})
- file(MAKE_DIRECTORY "${plugins_path}")
- file(COPY "${plugin}" DESTINATION "${plugins_path}")
- else()
- if(configurations AND (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE))
- set(configurations CONFIGURATIONS ${configurations})
- else()
- unset(configurations)
- endif()
- install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component})
- endif()
- set(${installed_plugin_path_var} "${plugins_path}/${plugin_name}" PARENT_SCOPE)
- endif()
+ endif()
+ install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component})
+ endif()
+ set(${installed_plugin_path_var} "${plugins_path}/${plugin_name}" PARENT_SCOPE)
+ endif()
endfunction()
function(install_qt4_plugin plugin executable copy installed_plugin_path_var)
- unset(plugins_dir)
- if(ARGC GREATER 4)
- set(plugins_dir ${ARGV4})
- endif()
- unset(component)
- if(ARGC GREATER 5)
- set(component ${ARGV5})
- endif()
-
- if(EXISTS "${plugin}")
- install_qt4_plugin_path("${plugin}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
- else()
- string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var)
- set(plugin_release_var "${plugin_var}_RELEASE")
- set(plugin_debug_var "${plugin_var}_DEBUG")
- set(plugin_release "${${plugin_release_var}}")
- set(plugin_debug "${${plugin_debug_var}}")
- if(DEFINED "${plugin_release_var}" AND DEFINED "${plugin_debug_var}" AND NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}")
- message(WARNING "Qt plugin \"${plugin}\" not recognized or found.")
- endif()
- if(NOT EXISTS "${${plugin_debug_var}}")
- set(plugin_debug "${plugin_release}")
- endif()
-
- if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
- install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "Release|RelWithDebInfo|MinSizeRel")
- install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}" "${component}" "Debug")
-
- if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
- set(${installed_plugin_path_var} ${${installed_plugin_path_var}_debug})
- else()
- set(${installed_plugin_path_var} ${${installed_plugin_path_var}_release})
- endif()
- else()
- install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
- endif()
- endif()
- set(${installed_plugin_path_var} ${${installed_plugin_path_var}} PARENT_SCOPE)
+ unset(plugins_dir)
+ if(ARGC GREATER 4)
+ set(plugins_dir ${ARGV4})
+ endif()
+ unset(component)
+ if(ARGC GREATER 5)
+ set(component ${ARGV5})
+ endif()
+
+ if(EXISTS "${plugin}")
+ install_qt4_plugin_path("${plugin}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
+ else()
+ string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var)
+ set(plugin_release_var "${plugin_var}_RELEASE")
+ set(plugin_debug_var "${plugin_var}_DEBUG")
+ set(plugin_release "${${plugin_release_var}}")
+ set(plugin_debug "${${plugin_debug_var}}")
+ if(DEFINED "${plugin_release_var}" AND DEFINED "${plugin_debug_var}" AND NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}")
+ message(WARNING "Qt plugin \"${plugin}\" not recognized or found.")
+ endif()
+ if(NOT EXISTS "${${plugin_debug_var}}")
+ set(plugin_debug "${plugin_release}")
+ endif()
+
+ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if(_isMultiConfig OR CMAKE_BUILD_TYPE)
+ set(_RELEASE_CONFIGS ${CMAKE_CONFIGURATION_TYPES} "${CMAKE_BUILD_TYPE}")
+ if (_RELEASE_CONFIGS)
+ list(FILTER _RELEASE_CONFIGS EXCLUDE REGEX "[Dd][Ee][Bb][Uu][Gg]")
+ endif()
+ string(REPLACE ";" "|" _RELEASE_CONFIGS "${_RELEASE_CONFIGS}")
+ install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "${_RELEASE_CONFIGS}")
+ install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}" "${component}" "Debug")
+ unset(_RELEASE_CONFIGS)
+
+ if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
+ set(${installed_plugin_path_var} ${${installed_plugin_path_var}_debug})
+ else()
+ set(${installed_plugin_path_var} ${${installed_plugin_path_var}_release})
+ endif()
+ else()
+ install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}")
+ endif()
+ endif()
+ set(${installed_plugin_path_var} ${${installed_plugin_path_var}} PARENT_SCOPE)
endfunction()
function(install_qt4_executable executable)
- unset(qtplugins)
- if(ARGC GREATER 1)
- set(qtplugins ${ARGV1})
- endif()
- unset(libs)
- if(ARGC GREATER 2)
- set(libs ${ARGV2})
- endif()
- unset(dirs)
- if(ARGC GREATER 3)
- set(dirs ${ARGV3})
- endif()
- unset(plugins_dir)
- if(ARGC GREATER 4)
- set(plugins_dir ${ARGV4})
- endif()
- unset(request_qt_conf)
- if(ARGC GREATER 5)
- set(request_qt_conf ${ARGV5})
- endif()
- unset(component)
- if(ARGC GREATER 6)
- set(component ${ARGV6})
- endif()
-
- if(QT_LIBRARY_DIR)
- list(APPEND dirs "${QT_LIBRARY_DIR}")
- endif()
- if(QT_BINARY_DIR)
- list(APPEND dirs "${QT_BINARY_DIR}")
- endif()
- if(component)
- set(component COMPONENT ${component})
- else()
- unset(component)
- endif()
-
- get_filename_component(executable_absolute "${executable}" ABSOLUTE)
- if(EXISTS "${QT_QTCORE_LIBRARY_RELEASE}")
- gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_RELEASE}" qtcore_type)
- elseif(EXISTS "${QT_QTCORE_LIBRARY_DEBUG}")
- gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_DEBUG}" qtcore_type)
- endif()
- if(qtcore_type STREQUAL "system")
- set(qt_plugins_dir "")
- endif()
-
- if(QT_IS_STATIC)
- message(WARNING "Qt built statically: not installing plugins.")
- else()
- foreach(plugin ${qtplugins})
- set(installed_plugin_paths "")
- install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}")
- list(APPEND libs ${installed_plugin_paths})
- endforeach()
- endif()
-
- resolve_qt4_paths(libs "")
-
- install(CODE
- "include(\"${DeployQt4_cmake_dir}/DeployQt4.cmake\")
- set(BU_CHMOD_BUNDLE_ITEMS TRUE)
- FIXUP_QT4_EXECUTABLE(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${executable}\" \"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\")"
- ${component}
- )
+ unset(qtplugins)
+ if(ARGC GREATER 1)
+ set(qtplugins ${ARGV1})
+ endif()
+ unset(libs)
+ if(ARGC GREATER 2)
+ set(libs ${ARGV2})
+ endif()
+ unset(dirs)
+ if(ARGC GREATER 3)
+ set(dirs ${ARGV3})
+ endif()
+ unset(plugins_dir)
+ if(ARGC GREATER 4)
+ set(plugins_dir ${ARGV4})
+ endif()
+ unset(request_qt_conf)
+ if(ARGC GREATER 5)
+ set(request_qt_conf ${ARGV5})
+ endif()
+ unset(component)
+ if(ARGC GREATER 6)
+ set(component ${ARGV6})
+ endif()
+
+ if(QT_LIBRARY_DIR)
+ list(APPEND dirs "${QT_LIBRARY_DIR}")
+ endif()
+ if(QT_BINARY_DIR)
+ list(APPEND dirs "${QT_BINARY_DIR}")
+ endif()
+ if(component)
+ set(component COMPONENT ${component})
+ else()
+ unset(component)
+ endif()
+
+ get_filename_component(executable_absolute "${executable}" ABSOLUTE)
+ if(EXISTS "${QT_QTCORE_LIBRARY_RELEASE}")
+ gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_RELEASE}" qtcore_type)
+ elseif(EXISTS "${QT_QTCORE_LIBRARY_DEBUG}")
+ gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_DEBUG}" qtcore_type)
+ endif()
+ if(qtcore_type STREQUAL "system")
+ set(qt_plugins_dir "")
+ endif()
+
+ if(QT_IS_STATIC)
+ message(WARNING "Qt built statically: not installing plugins.")
+ else()
+ foreach(plugin ${qtplugins})
+ set(installed_plugin_paths "")
+ install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}")
+ list(APPEND libs ${installed_plugin_paths})
+ endforeach()
+ endif()
+
+ resolve_qt4_paths(libs "")
+
+ install(CODE
+"include(\"${DeployQt4_cmake_dir}/DeployQt4.cmake\")
+set(BU_CHMOD_BUNDLE_ITEMS TRUE)
+FIXUP_QT4_EXECUTABLE(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${executable}\" \"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\")"
+ ${component}
+ )
endfunction()
diff --git a/Modules/Documentation.cmake b/Modules/Documentation.cmake
index fc398e6c5..aaf24f656 100644
--- a/Modules/Documentation.cmake
+++ b/Modules/Documentation.cmake
@@ -1,14 +1,13 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# Documentation
-# -------------
-#
-# DocumentationVTK.cmake
-#
-# This file provides support for the VTK documentation framework. It
-# relies on several tools (Doxygen, Perl, etc).
+#[=======================================================================[.rst:
+Documentation
+-------------
+
+This module provides support for the VTK documentation framework. It
+relies on several tools (Doxygen, Perl, etc).
+#]=======================================================================]
#
# Build the documentation ?
@@ -40,7 +39,7 @@ if (BUILD_DOCUMENTATION)
)
#
- # The documentation process is controled by a batch file.
+ # The documentation process is controlled by a batch file.
# We will probably need bash to create the custom target
#
diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake
index 7331fb2b4..e5dbcd963 100644
--- a/Modules/ExternalData.cmake
+++ b/Modules/ExternalData.cmake
@@ -1133,7 +1133,7 @@ if("${ExternalData_ACTION}" STREQUAL "fetch")
if(file_up_to_date)
# Touch the file to convince the build system it is up to date.
- execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${file}")
+ file(TOUCH "${file}")
else()
_ExternalData_link_or_copy("${obj}" "${file}")
endif()
diff --git a/Modules/ExternalProject-download.cmake.in b/Modules/ExternalProject-download.cmake.in
index 7f92596c5..99fb91781 100644
--- a/Modules/ExternalProject-download.cmake.in
+++ b/Modules/ExternalProject-download.cmake.in
@@ -116,6 +116,8 @@ foreach(i RANGE ${retry_number})
@TLS_VERIFY_CODE@
@TLS_CAINFO_CODE@
+ @NETRC_CODE@
+ @NETRC_FILE_CODE@
file(
DOWNLOAD
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 24957363e..66061a137 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -5,413 +5,937 @@
ExternalProject
---------------
-Create custom targets to build projects in external trees
+.. only:: html
+
+ .. contents::
+
+External Project Definition
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. command:: ExternalProject_Add
- The ``ExternalProject_Add`` function creates a custom target to drive
+ The ``ExternalProject_Add()`` function creates a custom target to drive
download, update/patch, configure, build, install and test steps of an
- external project::
-
- ExternalProject_Add(<name> [<option>...])
-
- General options are:
-
- ``DEPENDS <projects>...``
- Targets on which the project depends
- ``PREFIX <dir>``
- Root dir for entire project
- ``LIST_SEPARATOR <sep>``
- Sep to be replaced by ; in cmd lines
- ``TMP_DIR <dir>``
- Directory to store temporary files
- ``STAMP_DIR <dir>``
- Directory to store step timestamps
- ``EXCLUDE_FROM_ALL 1``
- The "all" target does not depend on this
-
- Download step options are:
-
- ``DOWNLOAD_NAME <fname>``
- File name to store (if not end of URL)
- ``DOWNLOAD_DIR <dir>``
- Directory to store downloaded files
- ``DOWNLOAD_COMMAND <cmd>...``
- Command to download source tree
- ``DOWNLOAD_NO_PROGRESS 1``
- Disable download progress reports
- ``CVS_REPOSITORY <cvsroot>``
- CVSROOT of CVS repository
- ``CVS_MODULE <mod>``
- Module to checkout from CVS repo
- ``CVS_TAG <tag>``
- Tag to checkout from CVS repo
- ``SVN_REPOSITORY <url>``
- URL of Subversion repo
- ``SVN_REVISION -r<rev>``
- Revision to checkout from Subversion repo
- ``SVN_USERNAME <username>``
- Username for Subversion checkout and update
- ``SVN_PASSWORD <password>``
- Password for Subversion checkout and update
- ``SVN_TRUST_CERT 1``
- Trust the Subversion server site certificate
- ``GIT_REPOSITORY <url>``
- URL of git repo
- ``GIT_TAG <tag>``
- Git branch name, commit id or tag
- ``GIT_REMOTE_NAME <name>``
- The optional name of the remote, default to ``origin``
- ``GIT_SUBMODULES <module>...``
- Git submodules that shall be updated, all if empty
- ``GIT_SHALLOW 1``
- Tell Git to clone with ``--depth 1``. Use when ``GIT_TAG`` is not
- specified or when it names a branch in order to download only the
- tip of the branch without the rest of its history.
- ``GIT_PROGRESS 1``
- Tell Git to clone with ``--progress``. For large projects, the clone step
- does not output anything which can make the build appear to have stalled.
- This option forces Git to output progress information during the clone step
- so that forward progress is indicated.
- ``GIT_CONFIG <option>...``
- Tell Git to clone with ``--config <option>``. Use additional configuration
- parameters when cloning the project (``key=value`` as expected by ``git
- config``).
- ``HG_REPOSITORY <url>``
- URL of mercurial repo
- ``HG_TAG <tag>``
- Mercurial branch name, commit id or tag
- ``URL /.../src.tgz [/.../src.tgz]...``
- Full path or URL(s) of source. Multiple URLs are allowed as mirrors.
- ``URL_HASH ALGO=value``
- Hash of file at URL
- ``URL_MD5 md5``
- Equivalent to URL_HASH MD5=md5
- ``HTTP_USERNAME <username>``
- Username for download operation
- ``HTTP_PASSWORD <username>``
- Password for download operation
- ``HTTP_HEADER <header>``
- HTTP header for download operation. Suboption can be repeated several times.
- ``TLS_VERIFY <bool>``
- Should certificate for https be checked
- ``TLS_CAINFO <file>``
- Path to a certificate authority file
- ``TIMEOUT <seconds>``
- Time allowed for file download operations
- ``DOWNLOAD_NO_EXTRACT 1``
- Just download the file and do not extract it; the full path to the
- downloaded file is available as ``<DOWNLOADED_FILE>``.
-
- Update/Patch step options are:
-
- ``UPDATE_COMMAND <cmd>...``
- Source work-tree update command
- ``UPDATE_DISCONNECTED 1``
- Never update automatically from the remote repository
- ``PATCH_COMMAND <cmd>...``
- Command to patch downloaded source
-
- Configure step options are:
-
- ``SOURCE_DIR <dir>``
- Source dir to be used for build
- ``SOURCE_SUBDIR <dir>``
- Path to source CMakeLists.txt relative to ``SOURCE_DIR``
- ``CONFIGURE_COMMAND <cmd>...``
- Build tree configuration command
- ``CMAKE_COMMAND /.../cmake``
- Specify alternative cmake executable
- ``CMAKE_GENERATOR <gen>``
- Specify generator for native build
- ``CMAKE_GENERATOR_PLATFORM <platform>``
- Generator-specific platform name
- ``CMAKE_GENERATOR_TOOLSET <toolset>``
- Generator-specific toolset name
- ``CMAKE_ARGS <arg>...``
- Arguments to CMake command line.
- These arguments are passed to CMake command line, and can contain
- arguments other than cache values, see also
- :manual:`CMake Options <cmake(1)>`. Arguments in the form
- ``-Dvar:string=on`` are always passed to the command line, and
- therefore cannot be changed by the user.
- Arguments may use
- :manual:`generator expressions <cmake-generator-expressions(7)>`.
- ``CMAKE_CACHE_ARGS <arg>...``
- Initial cache arguments, of the form ``-Dvar:string=on``.
- These arguments are written in a pre-load a script that populates
- CMake cache, see also :manual:`cmake -C <cmake(1)>`. This allows one to
- overcome command line length limits.
- These arguments are :command:`set` using the ``FORCE`` argument,
- and therefore cannot be changed by the user.
- Arguments may use
- :manual:`generator expressions <cmake-generator-expressions(7)>`.
- ``CMAKE_CACHE_DEFAULT_ARGS <arg>...``
- Initial default cache arguments, of the form ``-Dvar:string=on``.
- These arguments are written in a pre-load a script that populates
- CMake cache, see also :manual:`cmake -C <cmake(1)>`. This allows one to
- overcome command line length limits.
- These arguments can be used as default value that will be set if no
- previous value is found in the cache, and that the user can change
- later.
- Arguments may use
- :manual:`generator expressions <cmake-generator-expressions(7)>`.
-
- Build step options are:
-
- ``BINARY_DIR <dir>``
- Specify build dir location
- ``BUILD_COMMAND <cmd>...``
- Command to drive the native build
- ``BUILD_IN_SOURCE 1``
- Use source dir for build dir
- ``BUILD_ALWAYS 1``
- No stamp file, build step always runs
- ``BUILD_BYPRODUCTS <file>...``
- Files that will be generated by the build command but may or may
- not have their modification time updated by subsequent builds.
-
- Install step options are:
-
- ``INSTALL_DIR <dir>``
- Installation prefix to be placed in the ``<INSTALL_DIR>`` placeholder.
- This does not actually configure the external project to install to
- the given prefix. That must be done by passing appropriate arguments
- to the external project configuration step, e.g. using ``<INSTALL_DIR>``.
- ``INSTALL_COMMAND <cmd>...``
- Command to drive installation of the external project after it has been
- built. This only happens at the *build* time of the calling project.
- In order to install files from the external project alongside the
- locally-built files, a separate local :command:`install` call must be
- added to pick the files up from one of the external project trees.
-
- Test step options are:
-
- ``TEST_BEFORE_INSTALL 1``
- Add test step executed before install step
- ``TEST_AFTER_INSTALL 1``
- Add test step executed after install step
- ``TEST_EXCLUDE_FROM_MAIN 1``
- Main target does not depend on the test step
- ``TEST_COMMAND <cmd>...``
- Command to drive test
-
- Output logging options are:
-
- ``LOG_DOWNLOAD 1``
- Wrap download in script to log output
- ``LOG_UPDATE 1``
- Wrap update in script to log output
- ``LOG_CONFIGURE 1``
- Wrap configure in script to log output
- ``LOG_BUILD 1``
- Wrap build in script to log output
- ``LOG_TEST 1``
- Wrap test in script to log output
- ``LOG_INSTALL 1``
- Wrap install in script to log output
-
- Steps can be given direct access to the terminal if possible. With
- the :generator:`Ninja` generator, this places the steps in the
- ``console`` :prop_gbl:`pool <JOB_POOLS>`. Options are:
-
- ``USES_TERMINAL_DOWNLOAD 1``
- Give download terminal access.
- ``USES_TERMINAL_UPDATE 1``
- Give update terminal access.
- ``USES_TERMINAL_CONFIGURE 1``
- Give configure terminal access.
- ``USES_TERMINAL_BUILD 1``
- Give build terminal access.
- ``USES_TERMINAL_TEST 1``
- Give test terminal access.
- ``USES_TERMINAL_INSTALL 1``
- Give install terminal access.
-
- Other options are:
-
- ``STEP_TARGETS <step-target>...``
- Generate custom targets for these steps
- ``INDEPENDENT_STEP_TARGETS <step-target>...``
- Generate custom targets for these steps that do not depend on other
- external projects even if a dependency is set
-
- The ``*_DIR`` options specify directories for the project, with default
- directories computed as follows. If the ``PREFIX`` option is given to
- ``ExternalProject_Add()`` or the ``EP_PREFIX`` directory property is set,
- then an external project is built and installed under the specified prefix::
-
- TMP_DIR = <prefix>/tmp
- STAMP_DIR = <prefix>/src/<name>-stamp
- DOWNLOAD_DIR = <prefix>/src
- SOURCE_DIR = <prefix>/src/<name>
- BINARY_DIR = <prefix>/src/<name>-build
- INSTALL_DIR = <prefix>
-
- Otherwise, if the ``EP_BASE`` directory property is set then components
- of an external project are stored under the specified base::
-
- TMP_DIR = <base>/tmp/<name>
- STAMP_DIR = <base>/Stamp/<name>
- DOWNLOAD_DIR = <base>/Download/<name>
- SOURCE_DIR = <base>/Source/<name>
- BINARY_DIR = <base>/Build/<name>
- INSTALL_DIR = <base>/Install/<name>
-
- If no ``PREFIX``, ``EP_PREFIX``, or ``EP_BASE`` is specified then the
- default is to set ``PREFIX`` to ``<name>-prefix``. Relative paths are
- interpreted with respect to the build directory corresponding to the
- source directory in which ``ExternalProject_Add`` is invoked.
-
- If ``SOURCE_SUBDIR`` is set and no ``CONFIGURE_COMMAND`` is specified, the
- configure command will run CMake using the ``CMakeLists.txt`` located in the
- relative path specified by ``SOURCE_SUBDIR``, relative to the ``SOURCE_DIR``.
- If no ``SOURCE_SUBDIR`` is given, ``SOURCE_DIR`` is used.
-
- If ``SOURCE_DIR`` is explicitly set to an existing directory the project
- will be built from it. Otherwise a download step must be specified
- using one of the ``DOWNLOAD_COMMAND``, ``CVS_*``, ``SVN_*``, or ``URL``
- options. The ``URL`` option may refer locally to a directory or source
- tarball, or refer to a remote tarball (e.g. ``http://.../src.tgz``).
-
- If ``UPDATE_DISCONNECTED`` is set, the update step is not executed
- automatically when building the main target. The update step can still
- be added as a step target and called manually. This is useful if you
- want to allow one to build the project when you are disconnected from the
- network (you might still need the network for the download step).
- This is disabled by default.
- The directory property ``EP_UPDATE_DISCONNECTED`` can be used to change
- the default value for all the external projects in the current
- directory and its subdirectories.
+ external project:
+
+ .. code-block:: cmake
+
+ ExternalProject_Add(<name> [<option>...])
+
+ The individual steps within the process can be driven independently if
+ required (e.g. for CDash submission) and extra custom steps can be defined,
+ along with the ability to control the step dependencies. The directory
+ structure used for the management of the external project can also be
+ customized. The function supports a large number of options which can be used
+ to tailor the external project behavior.
+
+ **Directory Options:**
+ Most of the time, the default directory layout is sufficient. It is largely
+ an implementation detail that the main project usually doesn't need to
+ change. In some circumstances, however, control over the directory layout
+ can be useful or necessary. The directory options are potentially more
+ useful from the point of view that the main build can use the
+ :command:`ExternalProject_Get_Property` command to retrieve their values,
+ thereby allowing the main project to refer to build artifacts of the
+ external project.
+
+ ``PREFIX <dir>``
+ Root directory for the external project. Unless otherwise noted below,
+ all other directories associated with the external project will be
+ created under here.
+
+ ``TMP_DIR <dir>``
+ Directory in which to store temporary files.
+
+ ``STAMP_DIR <dir>``
+ Directory in which to store the timestamps of each step. Log files from
+ individual steps are also created in here unless overridden by LOG_DIR
+ (see *Logging Options* below).
+
+ ``LOG_DIR <dir>``
+ Directory in which to store the logs of each step.
+
+ ``DOWNLOAD_DIR <dir>``
+ Directory in which to store downloaded files before unpacking them. This
+ directory is only used by the URL download method, all other download
+ methods use ``SOURCE_DIR`` directly instead.
+
+ ``SOURCE_DIR <dir>``
+ Source directory into which downloaded contents will be unpacked, or for
+ non-URL download methods, the directory in which the repository should be
+ checked out, cloned, etc. If no download method is specified, this must
+ point to an existing directory where the external project has already
+ been unpacked or cloned/checked out.
+
+ .. note::
+ If a download method is specified, any existing contents of the source
+ directory may be deleted. Only the URL download method checks whether
+ this directory is either missing or empty before initiating the
+ download, stopping with an error if it is not empty. All other
+ download methods silently discard any previous contents of the source
+ directory.
+
+ ``BINARY_DIR <dir>``
+ Specify the build directory location. This option is ignored if
+ ``BUILD_IN_SOURCE`` is enabled.
+
+ ``INSTALL_DIR <dir>``
+ Installation prefix to be placed in the ``<INSTALL_DIR>`` placeholder.
+ This does not actually configure the external project to install to
+ the given prefix. That must be done by passing appropriate arguments
+ to the external project configuration step, e.g. using ``<INSTALL_DIR>``.
+
+ If any of the above ``..._DIR`` options are not specified, their defaults
+ are computed as follows. If the ``PREFIX`` option is given or the
+ ``EP_PREFIX`` directory property is set, then an external project is built
+ and installed under the specified prefix::
+
+ TMP_DIR = <prefix>/tmp
+ STAMP_DIR = <prefix>/src/<name>-stamp
+ DOWNLOAD_DIR = <prefix>/src
+ SOURCE_DIR = <prefix>/src/<name>
+ BINARY_DIR = <prefix>/src/<name>-build
+ INSTALL_DIR = <prefix>
+ LOG_DIR = <STAMP_DIR>
+
+ Otherwise, if the ``EP_BASE`` directory property is set then components
+ of an external project are stored under the specified base::
+
+ TMP_DIR = <base>/tmp/<name>
+ STAMP_DIR = <base>/Stamp/<name>
+ DOWNLOAD_DIR = <base>/Download/<name>
+ SOURCE_DIR = <base>/Source/<name>
+ BINARY_DIR = <base>/Build/<name>
+ INSTALL_DIR = <base>/Install/<name>
+ LOG_DIR = <STAMP_DIR>
+
+ If no ``PREFIX``, ``EP_PREFIX``, or ``EP_BASE`` is specified, then the
+ default is to set ``PREFIX`` to ``<name>-prefix``. Relative paths are
+ interpreted with respect to :variable:`CMAKE_CURRENT_BINARY_DIR` at the
+ point where ``ExternalProject_Add()`` is called.
+
+ **Download Step Options:**
+ A download method can be omitted if the ``SOURCE_DIR`` option is used to
+ point to an existing non-empty directory. Otherwise, one of the download
+ methods below must be specified (multiple download methods should not be
+ given) or a custom ``DOWNLOAD_COMMAND`` provided.
+
+ ``DOWNLOAD_COMMAND <cmd>...``
+ Overrides the command used for the download step
+ (:manual:`generator expressions <cmake-generator-expressions(7)>` are
+ supported). If this option is specified, all other download options will
+ be ignored. Providing an empty string for ``<cmd>`` effectively disables
+ the download step.
+
+ *URL Download*
+ ``URL <url1> [<url2>...]``
+ List of paths and/or URL(s) of the external project's source. When more
+ than one URL is given, they are tried in turn until one succeeds. A URL
+ may be an ordinary path in the local file system (in which case it
+ must be the only URL provided) or any downloadable URL supported by the
+ :command:`file(DOWNLOAD)` command. A local filesystem path may refer to
+ either an existing directory or to an archive file, whereas a URL is
+ expected to point to a file which can be treated as an archive. When an
+ archive is used, it will be unpacked automatically unless the
+ ``DOWNLOAD_NO_EXTRACT`` option is set to prevent it. The archive type
+ is determined by inspecting the actual content rather than using logic
+ based on the file extension.
+
+ ``URL_HASH <algo>=<hashValue>``
+ Hash of the archive file to be downloaded. The argument should be of
+ the form ``<algo>=<hashValue>`` where ``algo`` can be any of the hashing
+ algorithms supported by the :command:`file()` command. Specifying this
+ option is strongly recommended for URL downloads, as it ensures the
+ integrity of the downloaded content. It is also used as a check for a
+ previously downloaded file, allowing connection to the remote location
+ to be avoided altogether if the local directory already has a file from
+ an earlier download that matches the specified hash.
+
+ ``URL_MD5 <md5>``
+ Equivalent to ``URL_HASH MD5=<md5>``.
+
+ ``DOWNLOAD_NAME <fname>``
+ File name to use for the downloaded file. If not given, the end of the
+ URL is used to determine the file name. This option is rarely needed,
+ the default name is generally suitable and is not normally used outside
+ of code internal to the ``ExternalProject`` module.
+
+ ``DOWNLOAD_NO_EXTRACT <bool>``
+ Allows the extraction part of the download step to be disabled by
+ passing a boolean true value for this option. If this option is not
+ given, the downloaded contents will be unpacked automatically if
+ required. If extraction has been disabled, the full path to the
+ downloaded file is available as ``<DOWNLOADED_FILE>`` in subsequent
+ steps or as the property ``DOWNLOADED_FILE`` with the
+ :command:`ExternalProject_Get_Property` command.
+
+ ``DOWNLOAD_NO_PROGRESS <bool>``
+ Can be used to disable logging the download progress. If this option is
+ not given, download progress messages will be logged.
+
+ ``TIMEOUT <seconds>``
+ Maximum time allowed for file download operations.
+
+ ``HTTP_USERNAME <username>``
+ Username for the download operation if authentication is required.
+
+ ``HTTP_PASSWORD <password>``
+ Password for the download operation if authentication is required.
+
+ ``HTTP_HEADER <header1> [<header2>...]``
+ Provides an arbitrary list of HTTP headers for the download operation.
+ This can be useful for accessing content in systems like AWS, etc.
+
+ ``TLS_VERIFY <bool>``
+ Specifies whether certificate verification should be performed for
+ https URLs. If this option is not provided, the default behavior is
+ determined by the ``CMAKE_TLS_VERIFY`` variable (see
+ :command:`file(DOWNLOAD)`). If that is also not set, certificate
+ verification will not be performed. In situations where ``URL_HASH``
+ cannot be provided, this option can be an alternative verification
+ measure.
+
+ ``TLS_CAINFO <file>``
+ Specify a custom certificate authority file to use if ``TLS_VERIFY``
+ is enabled. If this option is not specified, the value of the
+ ``CMAKE_TLS_CAINFO`` variable will be used instead (see
+ :command:`file(DOWNLOAD)`)
+
+ ``NETRC <level>``
+ Specify whether the ``.netrc`` file is to be used for operation.
+ If this option is not specified, the value of the ``CMAKE_NETRC``
+ variable will be used instead (see :command:`file(DOWNLOAD)`)
+ Valid levels are:
+
+ ``IGNORED``
+ The ``.netrc`` file is ignored.
+ This is the default.
+ ``OPTIONAL``
+ The ``.netrc`` file is optional, and information in the URL
+ is preferred. The file will be scanned to find which ever
+ information is not specified in the URL.
+ ``REQUIRED``
+ The ``.netrc`` file is required, and information in the URL
+ is ignored.
+
+ ``NETRC_FILE <file>``
+ Specify an alternative ``.netrc`` file to the one in your home directory
+ if the ``NETRC`` level is ``OPTIONAL`` or ``REQUIRED``. If this option
+ is not specified, the value of the ``CMAKE_NETRC_FILE`` variable will
+ be used instead (see :command:`file(DOWNLOAD)`)
+
+ *Git*
+ NOTE: A git version of 1.6.5 or later is required if this download method
+ is used.
+
+ ``GIT_REPOSITORY <url>``
+ URL of the git repository. Any URL understood by the ``git`` command
+ may be used.
+
+ ``GIT_TAG <tag>``
+ Git branch name, tag or commit hash. Note that branch names and tags
+ should generally be specified as remote names (i.e. ``origin/myBranch``
+ rather than simply ``myBranch``). This ensures that if the remote end
+ has its tag moved or branch rebased or history rewritten, the local
+ clone will still be updated correctly. In general, however, specifying
+ a commit hash should be preferred for a number of reasons:
+
+ - If the local clone already has the commit corresponding to the hash,
+ no ``git fetch`` needs to be performed to check for changes each time
+ CMake is re-run. This can result in a significant speed up if many
+ external projects are being used.
+ - Using a specific git hash ensures that the main project's own history
+ is fully traceable to a specific point in the external project's
+ evolution. If a branch or tag name is used instead, then checking out
+ a specific commit of the main project doesn't necessarily pin the
+ whole build to a specific point in the life of the external project.
+ The lack of such deterministic behavior makes the main project lose
+ traceability and repeatability.
+
+ If ``GIT_SHALLOW`` is enabled then ``GIT_TAG`` works only with
+ branch names and tags. A commit hash is not allowed.
+
+ ``GIT_REMOTE_NAME <name>``
+ The optional name of the remote. If this option is not specified, it
+ defaults to ``origin``.
+
+ ``GIT_SUBMODULES <module>...``
+ Specific git submodules that should also be updated. If this option is
+ not provided, all git submodules will be updated. When :policy:`CMP0097`
+ is set to ``NEW`` if this value is set to an empty string then no submodules
+ are initialized or updated.
+
+ ``GIT_SHALLOW <bool>``
+ When this option is enabled, the ``git clone`` operation will be given
+ the ``--depth 1`` option. This performs a shallow clone, which avoids
+ downloading the whole history and instead retrieves just the commit
+ denoted by the ``GIT_TAG`` option.
+
+ ``GIT_PROGRESS <bool>``
+ When enabled, this option instructs the ``git clone`` operation to
+ report its progress by passing it the ``--progress`` option. Without
+ this option, the clone step for large projects may appear to make the
+ build stall, since nothing will be logged until the clone operation
+ finishes. While this option can be used to provide progress to prevent
+ the appearance of the build having stalled, it may also make the build
+ overly noisy if lots of external projects are used.
+
+ ``GIT_CONFIG <option1> [<option2>...]``
+ Specify a list of config options to pass to ``git clone``. Each option
+ listed will be transformed into its own ``--config <option>`` on the
+ ``git clone`` command line, with each option required to be in the
+ form ``key=value``.
+
+ *Subversion*
+ ``SVN_REPOSITORY <url>``
+ URL of the Subversion repository.
+
+ ``SVN_REVISION -r<rev>``
+ Revision to checkout from the Subversion repository.
+
+ ``SVN_USERNAME <username>``
+ Username for the Subversion checkout and update.
+
+ ``SVN_PASSWORD <password>``
+ Password for the Subversion checkout and update.
+
+ ``SVN_TRUST_CERT <bool>``
+ Specifies whether to trust the Subversion server site certificate. If
+ enabled, the ``--trust-server-cert`` option is passed to the ``svn``
+ checkout and update commands.
+
+ *Mercurial*
+ ``HG_REPOSITORY <url>``
+ URL of the mercurial repository.
+
+ ``HG_TAG <tag>``
+ Mercurial branch name, tag or commit id.
+
+ *CVS*
+ ``CVS_REPOSITORY <cvsroot>``
+ CVSROOT of the CVS repository.
+
+ ``CVS_MODULE <mod>``
+ Module to checkout from the CVS repository.
+
+ ``CVS_TAG <tag>``
+ Tag to checkout from the CVS repository.
+
+ **Update/Patch Step Options:**
+ Whenever CMake is re-run, by default the external project's sources will be
+ updated if the download method supports updates (e.g. a git repository
+ would be checked if the ``GIT_TAG`` does not refer to a specific commit).
+
+ ``UPDATE_COMMAND <cmd>...``
+ Overrides the download method's update step with a custom command.
+ The command may use
+ :manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+ ``UPDATE_DISCONNECTED <bool>``
+ When enabled, this option causes the update step to be skipped. It does
+ not, however, prevent the download step. The update step can still be
+ added as a step target (see :command:`ExternalProject_Add_StepTargets`)
+ and called manually. This is useful if you want to allow developers to
+ build the project when disconnected from the network (the network may
+ still be needed for the download step though).
+
+ When this option is present, it is generally advisable to make the value
+ a cache variable under the developer's control rather than hard-coding
+ it. If this option is not present, the default value is taken from the
+ ``EP_UPDATE_DISCONNECTED`` directory property. If that is also not
+ defined, updates are performed as normal. The ``EP_UPDATE_DISCONNECTED``
+ directory property is intended as a convenience for controlling the
+ ``UPDATE_DISCONNECTED`` behavior for an entire section of a project's
+ directory hierarchy and may be a more convenient method of giving
+ developers control over whether or not to perform updates (assuming the
+ project also provides a cache variable or some other convenient method
+ for setting the directory property).
+
+ ``PATCH_COMMAND <cmd>...``
+ Specifies a custom command to patch the sources after an update. By
+ default, no patch command is defined. Note that it can be quite difficult
+ to define an appropriate patch command that performs robustly, especially
+ for download methods such as git where changing the ``GIT_TAG`` will not
+ discard changes from a previous patch, but the patch command will be
+ called again after updating to the new tag.
+
+ **Configure Step Options:**
+ The configure step is run after the download and update steps. By default,
+ the external project is assumed to be a CMake project, but this can be
+ overridden if required.
+
+ ``CONFIGURE_COMMAND <cmd>...``
+ The default configure command runs CMake with options based on the main
+ project. For non-CMake external projects, the ``CONFIGURE_COMMAND``
+ option must be used to override this behavior
+ (:manual:`generator expressions <cmake-generator-expressions(7)>` are
+ supported). For projects that require no configure step, specify this
+ option with an empty string as the command to execute.
+
+ ``CMAKE_COMMAND /.../cmake``
+ Specify an alternative cmake executable for the configure step (use an
+ absolute path). This is generally not recommended, since it is
+ usually desirable to use the same CMake version throughout the whole
+ build. This option is ignored if a custom configure command has been
+ specified with ``CONFIGURE_COMMAND``.
+
+ ``CMAKE_GENERATOR <gen>``
+ Override the CMake generator used for the configure step. Without this
+ option, the same generator as the main build will be used. This option is
+ ignored if a custom configure command has been specified with the
+ ``CONFIGURE_COMMAND`` option.
+
+ ``CMAKE_GENERATOR_PLATFORM <platform>``
+ Pass a generator-specific platform name to the CMake command (see
+ :variable:`CMAKE_GENERATOR_PLATFORM`). It is an error to provide this
+ option without the ``CMAKE_GENERATOR`` option.
+
+ ``CMAKE_GENERATOR_TOOLSET <toolset>``
+ Pass a generator-specific toolset name to the CMake command (see
+ :variable:`CMAKE_GENERATOR_TOOLSET`). It is an error to provide this
+ option without the ``CMAKE_GENERATOR`` option.
+
+ ``CMAKE_GENERATOR_INSTANCE <instance>``
+ Pass a generator-specific instance selection to the CMake command (see
+ :variable:`CMAKE_GENERATOR_INSTANCE`). It is an error to provide this
+ option without the ``CMAKE_GENERATOR`` option.
+
+ ``CMAKE_ARGS <arg>...``
+ The specified arguments are passed to the ``cmake`` command line. They
+ can be any argument the ``cmake`` command understands, not just cache
+ values defined by ``-D...`` arguments (see also
+ :manual:`CMake Options <cmake(1)>`). In addition, arguments may use
+ :manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+ ``CMAKE_CACHE_ARGS <arg>...``
+ This is an alternate way of specifying cache variables where command line
+ length issues may become a problem. The arguments are expected to be in
+ the form ``-Dvar:STRING=value``, which are then transformed into
+ CMake :command:`set` commands with the ``FORCE`` option used. These
+ ``set()`` commands are written to a pre-load script which is then applied
+ using the :manual:`cmake -C <cmake(1)>` command line option. Arguments
+ may use :manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+ ``CMAKE_CACHE_DEFAULT_ARGS <arg>...``
+ This is the same as the ``CMAKE_CACHE_ARGS`` option except the ``set()``
+ commands do not include the ``FORCE`` keyword. This means the values act
+ as initial defaults only and will not override any variables already set
+ from a previous run. Use this option with care, as it can lead to
+ different behavior depending on whether the build starts from a fresh
+ build directory or re-uses previous build contents.
+
+ If the CMake generator is the ``Green Hills MULTI`` and not overridden then
+ the original project's settings for the GHS toolset and target system
+ customization cache variables are propagated into the external project.
+
+ ``SOURCE_SUBDIR <dir>``
+ When no ``CONFIGURE_COMMAND`` option is specified, the configure step
+ assumes the external project has a ``CMakeLists.txt`` file at the top of
+ its source tree (i.e. in ``SOURCE_DIR``). The ``SOURCE_SUBDIR`` option
+ can be used to point to an alternative directory within the source tree
+ to use as the top of the CMake source tree instead. This must be a
+ relative path and it will be interpreted as being relative to
+ ``SOURCE_DIR``. When ``BUILD_IN_SOURCE 1`` is specified, the
+ ``BUILD_COMMAND`` is used to point to an alternative directory within the
+ source tree.
+
+ **Build Step Options:**
+ If the configure step assumed the external project uses CMake as its build
+ system, the build step will also. Otherwise, the build step will assume a
+ Makefile-based build and simply run ``make`` with no arguments as the
+ default build step. This can be overridden with custom build commands if
+ required.
+
+ ``BUILD_COMMAND <cmd>...``
+ Overrides the default build command
+ (:manual:`generator expressions <cmake-generator-expressions(7)>` are
+ supported). If this option is not given, the default build command will
+ be chosen to integrate with the main build in the most appropriate way
+ (e.g. using recursive ``make`` for Makefile generators or
+ ``cmake --build`` if the project uses a CMake build). This option can be
+ specified with an empty string as the command to make the build step do
+ nothing.
+
+ ``BUILD_IN_SOURCE <bool>``
+ When this option is enabled, the build will be done directly within the
+ external project's source tree. This should generally be avoided, the use
+ of a separate build directory is usually preferred, but it can be useful
+ when the external project assumes an in-source build. The ``BINARY_DIR``
+ option should not be specified if building in-source.
+
+ ``BUILD_ALWAYS <bool>``
+ Enabling this option forces the build step to always be run. This can be
+ the easiest way to robustly ensure that the external project's own build
+ dependencies are evaluated rather than relying on the default
+ success timestamp-based method. This option is not normally needed unless
+ developers are expected to modify something the external project's build
+ depends on in a way that is not detectable via the step target
+ dependencies (e.g. ``SOURCE_DIR`` is used without a download method and
+ developers might modify the sources in ``SOURCE_DIR``).
+
+ ``BUILD_BYPRODUCTS <file>...``
+ Specifies files that will be generated by the build command but which
+ might or might not have their modification time updated by subsequent
+ builds. These ultimately get passed through as ``BYPRODUCTS`` to the
+ build step's own underlying call to :command:`add_custom_command`.
+
+ **Install Step Options:**
+ If the configure step assumed the external project uses CMake as its build
+ system, the install step will also. Otherwise, the install step will assume
+ a Makefile-based build and simply run ``make install`` as the default build
+ step. This can be overridden with custom install commands if required.
+
+ ``INSTALL_COMMAND <cmd>...``
+ The external project's own install step is invoked as part of the main
+ project's *build*. It is done after the external project's build step
+ and may be before or after the external project's test step (see the
+ ``TEST_BEFORE_INSTALL`` option below). The external project's install
+ rules are not part of the main project's install rules, so if anything
+ from the external project should be installed as part of the main build,
+ these need to be specified in the main build as additional
+ :command:`install` commands. The default install step builds the
+ ``install`` target of the external project, but this can be overridden
+ with a custom command using this option
+ (:manual:`generator expressions <cmake-generator-expressions(7)>` are
+ supported). Passing an empty string as the ``<cmd>`` makes the install
+ step do nothing.
+
+ **Test Step Options:**
+ The test step is only defined if at least one of the following ``TEST_...``
+ options are provided.
+
+ ``TEST_COMMAND <cmd>...``
+ Overrides the default test command
+ (:manual:`generator expressions <cmake-generator-expressions(7)>` are
+ supported). If this option is not given, the default behavior of the test
+ step is to build the external project's own ``test`` target. This option
+ can be specified with ``<cmd>`` as an empty string, which allows the test
+ step to still be defined, but it will do nothing. Do not specify any of
+ the other ``TEST_...`` options if providing an empty string as the test
+ command, but prefer to omit all ``TEST_...`` options altogether if the
+ test step target is not needed.
+
+ ``TEST_BEFORE_INSTALL <bool>``
+ When this option is enabled, the test step will be executed before the
+ install step. The default behavior is for the test step to run after the
+ install step.
+
+ ``TEST_AFTER_INSTALL <bool>``
+ This option is mainly useful as a way to indicate that the test step is
+ desired but all default behavior is sufficient. Specifying this option
+ with a boolean true value ensures the test step is defined and that it
+ comes after the install step. If both ``TEST_BEFORE_INSTALL`` and
+ ``TEST_AFTER_INSTALL`` are enabled, the latter is silently ignored.
+
+ ``TEST_EXCLUDE_FROM_MAIN <bool>``
+ If enabled, the main build's default ALL target will not depend on the
+ test step. This can be a useful way of ensuring the test step is defined
+ but only gets invoked when manually requested.
+
+ **Output Logging Options:**
+ Each of the following ``LOG_...`` options can be used to wrap the relevant
+ step in a script to capture its output to files. The log files will be
+ created in ``LOG_DIR`` if supplied or otherwise the ``STAMP_DIR``
+ directory with step-specific file names.
+
+ ``LOG_DOWNLOAD <bool>``
+ When enabled, the output of the download step is logged to files.
+
+ ``LOG_UPDATE <bool>``
+ When enabled, the output of the update step is logged to files.
+
+ ``LOG_PATCH <bool>``
+ When enabled, the output of the patch step is logged to files.
+
+ ``LOG_CONFIGURE <bool>``
+ When enabled, the output of the configure step is logged to files.
+
+ ``LOG_BUILD <bool>``
+ When enabled, the output of the build step is logged to files.
+
+ ``LOG_INSTALL <bool>``
+ When enabled, the output of the install step is logged to files.
+
+ ``LOG_TEST <bool>``
+ When enabled, the output of the test step is logged to files.
+
+ ``LOG_MERGED_STDOUTERR <bool>``
+ When enabled, stdout and stderr will be merged for any step whose
+ output is being logged to files.
+
+ ``LOG_OUTPUT_ON_FAILURE <bool>``
+ This option only has an effect if at least one of the other ``LOG_<step>``
+ options is enabled. If an error occurs for a step which has logging to
+ file enabled, that step's output will be printed to the console if
+ ``LOG_OUTPUT_ON_FAILURE`` is set to true. For cases where a large amount
+ of output is recorded, just the end of that output may be printed to the
+ console.
+
+ **Terminal Access Options:**
+ Steps can be given direct access to the terminal in some cases. Giving a
+ step access to the terminal may allow it to receive terminal input if
+ required, such as for authentication details not provided by other options.
+ With the :generator:`Ninja` generator, these options place the steps in the
+ ``console`` :prop_gbl:`job pool <JOB_POOLS>`. Each step can be given access
+ to the terminal individually via the following options:
+
+ ``USES_TERMINAL_DOWNLOAD <bool>``
+ Give the download step access to the terminal.
+
+ ``USES_TERMINAL_UPDATE <bool>``
+ Give the update step access to the terminal.
+
+ ``USES_TERMINAL_CONFIGURE <bool>``
+ Give the configure step access to the terminal.
+
+ ``USES_TERMINAL_BUILD <bool>``
+ Give the build step access to the terminal.
+
+ ``USES_TERMINAL_INSTALL <bool>``
+ Give the install step access to the terminal.
+
+ ``USES_TERMINAL_TEST <bool>``
+ Give the test step access to the terminal.
+
+ **Target Options:**
+ ``DEPENDS <targets>...``
+ Specify other targets on which the external project depends. The other
+ targets will be brought up to date before any of the external project's
+ steps are executed. Because the external project uses additional custom
+ targets internally for each step, the ``DEPENDS`` option is the most
+ convenient way to ensure all of those steps depend on the other targets.
+ Simply doing
+ :command:`add_dependencies(\<name\> \<targets\>) <add_dependencies>` will
+ not make any of the steps dependent on ``<targets>``.
+
+ ``EXCLUDE_FROM_ALL <bool>``
+ When enabled, this option excludes the external project from the default
+ ALL target of the main build.
+
+ ``STEP_TARGETS <step-target>...``
+ Generate custom targets for the specified steps. This is required if the
+ steps need to be triggered manually or if they need to be used as
+ dependencies of other targets. If this option is not specified, the
+ default value is taken from the ``EP_STEP_TARGETS`` directory property.
+ See :command:`ExternalProject_Add_Step` below for further discussion of
+ the effects of this option.
+
+ ``INDEPENDENT_STEP_TARGETS <step-target>...``
+ Generate custom targets for the specified steps and prevent these targets
+ from having the usual dependencies applied to them. If this option is not
+ specified, the default value is taken from the
+ ``EP_INDEPENDENT_STEP_TARGETS`` directory property. This option is mostly
+ useful for allowing individual steps to be driven independently, such as
+ for a CDash setup where each step should be initiated and reported
+ individually rather than as one whole build. See
+ :command:`ExternalProject_Add_Step` below for further discussion of the
+ effects of this option.
+
+ **Miscellaneous Options:**
+ ``LIST_SEPARATOR <sep>``
+ For any of the various ``..._COMMAND`` options, replace ``;`` with
+ ``<sep>`` in the specified command lines. This can be useful where list
+ variables may be given in commands where they should end up as
+ space-separated arguments (``<sep>`` would be a single space character
+ string in this case).
+
+ ``COMMAND <cmd>...``
+ Any of the other ``..._COMMAND`` options can have additional commands
+ appended to them by following them with as many ``COMMAND ...`` options
+ as needed
+ (:manual:`generator expressions <cmake-generator-expressions(7)>` are
+ supported). For example:
+
+ .. code-block:: cmake
+
+ ExternalProject_Add(example
+ ... # Download options, etc.
+ BUILD_COMMAND ${CMAKE_COMMAND} -E echo "Starting $<CONFIG> build"
+ COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG>
+ COMMAND ${CMAKE_COMMAND} -E echo "$<CONFIG> build complete"
+ )
+
+ It should also be noted that each build step is created via a call to
+ :command:`ExternalProject_Add_Step`. See that command's documentation for the
+ automatic substitutions that are supported for some options.
+
+Obtaining Project Properties
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. command:: ExternalProject_Get_Property
+
+ The ``ExternalProject_Get_Property()`` function retrieves external project
+ target properties:
+
+ .. code-block:: cmake
+
+ ExternalProject_Get_Property(<name> <prop1> [<prop2>...])
+
+ The function stores property values in variables of the same name. Property
+ names correspond to the keyword argument names of ``ExternalProject_Add()``.
+ For example, the source directory might be retrieved like so:
+
+ .. code-block:: cmake
+
+ ExternalProject_Get_property(myExtProj SOURCE_DIR)
+ message("Source dir of myExtProj = ${SOURCE_DIR}")
+
+Explicit Step Management
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+The ``ExternalProject_Add()`` function on its own is often sufficient for
+incorporating an external project into the main build. Certain scenarios
+require additional work to implement desired behavior, such as adding in a
+custom step or making steps available as manually triggerable targets. The
+``ExternalProject_Add_Step()``, ``ExternalProject_Add_StepTargets()`` and
+``ExternalProject_Add_StepDependencies`` functions provide the lower level
+control needed to implement such step-level capabilities.
.. command:: ExternalProject_Add_Step
- The ``ExternalProject_Add_Step`` function adds a custom step to an
- external project::
+ The ``ExternalProject_Add_Step()`` function specifies an additional custom
+ step for an external project defined by an earlier call to
+ :command:`ExternalProject_Add`:
- ExternalProject_Add_Step(<name> <step> [<option>...])
+ .. code-block:: cmake
- Options are:
+ ExternalProject_Add_Step(<name> <step> [<option>...])
+
+ ``<name>`` is the same as the name passed to the original call to
+ :command:`ExternalProject_Add`. The specified ``<step>`` must not be one of
+ the pre-defined steps (``mkdir``, ``download``, ``update``, ``skip-update``,
+ ``patch``, ``configure``, ``build``, ``install`` or ``test``). The supported
+ options are:
``COMMAND <cmd>...``
- Command line invoked by this step
+ The command line to be executed by this custom step
+ (:manual:`generator expressions <cmake-generator-expressions(7)>` are
+ supported). This option can be repeated multiple times to specify multiple
+ commands to be executed in order.
+
``COMMENT "<text>..."``
- Text printed when step executes
+ Text to be printed when the custom step executes.
+
``DEPENDEES <step>...``
- Steps on which this step depends
+ Other steps (custom or pre-defined) on which this step depends.
+
``DEPENDERS <step>...``
- Steps that depend on this step
+ Other steps (custom or pre-defined) that depend on this new custom step.
+
``DEPENDS <file>...``
- Files on which this step depends
+ Files on which this custom step depends.
+
``BYPRODUCTS <file>...``
- Files that will be generated by this step but may or may not
- have their modification time updated by subsequent builds.
- ``ALWAYS 1``
- No stamp file, step always runs
- ``EXCLUDE_FROM_MAIN 1``
- Main target does not depend on this step
+ Files that will be generated by this custom step but which might or might
+ not have their modification time updated by subsequent builds. This list of
+ files will ultimately be passed through as the ``BYPRODUCTS`` option to the
+ :command:`add_custom_command` used to implement the custom step internally.
+
+ ``ALWAYS <bool>``
+ When enabled, this option specifies that the custom step should always be
+ run (i.e. that it is always considered out of date).
+
+ ``EXCLUDE_FROM_MAIN <bool>``
+ When enabled, this option specifies that the external project's main target
+ does not depend on the custom step.
+
``WORKING_DIRECTORY <dir>``
- Working directory for command
- ``LOG 1``
- Wrap step in script to log output
- ``USES_TERMINAL 1``
- Give the step direct access to the terminal if possible.
+ Specifies the working directory to set before running the custom step's
+ command. If this option is not specified, the directory will be the value
+ of the :variable:`CMAKE_CURRENT_BINARY_DIR` at the point where
+ ``ExternalProject_Add_Step()`` was called.
+
+ ``LOG <bool>``
+ If set, this causes the output from the custom step to be captured to files
+ in the external project's ``LOG_DIR`` if supplied or ``STAMP_DIR``.
+
+ ``USES_TERMINAL <bool>``
+ If enabled, this gives the custom step direct access to the terminal if
+ possible.
+
+ The command line, comment, working directory and byproducts of every
+ standard and custom step are processed to replace the tokens
+ ``<SOURCE_DIR>``, ``<SOURCE_SUBDIR>``, ``<BINARY_DIR>``, ``<INSTALL_DIR>``
+ ``<TMP_DIR>``, ``<DOWNLOAD_DIR>`` and ``<DOWNLOADED_FILE>`` with their
+ corresponding property values defined in the original call to
+ :command:`ExternalProject_Add`.
- The command line, comment, working directory, and byproducts of every
- standard and custom step are processed to replace tokens ``<SOURCE_DIR>``,
- ``<SOURCE_SUBDIR>``, ``<BINARY_DIR>``, ``<INSTALL_DIR>``, and ``<TMP_DIR>``
- with corresponding property values.
+.. command:: ExternalProject_Add_StepTargets
-Any builtin step that specifies a ``<step>_COMMAND cmd...`` or custom
-step that specifies a ``COMMAND cmd...`` may specify additional command
-lines using the form ``COMMAND cmd...``. At build time the commands
-will be executed in order and aborted if any one fails. For example::
+ The ``ExternalProject_Add_StepTargets()`` function generates targets for the
+ steps listed. The name of each created target will be of the form
+ ``<name>-<step>``:
+
+ .. code-block:: cmake
+
+ ExternalProject_Add_StepTargets(<name> [NO_DEPENDS] <step1> [<step2>...])
+
+ Creating a target for a step allows it to be used as a dependency of another
+ target or to be triggered manually. Having targets for specific steps also
+ allows them to be driven independently of each other by specifying targets on
+ build command lines. For example, you may be submitting to a sub-project
+ based dashboard where you want to drive the configure portion of the build,
+ then submit to the dashboard, followed by the build portion, followed
+ by tests. If you invoke a custom target that depends on a step halfway
+ through the step dependency chain, then all the previous steps will also run
+ to ensure everything is up to date.
+
+ If the ``NO_DEPENDS`` option is specified, the step target will not depend on
+ the dependencies of the external project (i.e. on any dependencies of the
+ ``<name>`` custom target created by :command:`ExternalProject_Add`). This is
+ usually safe for the ``download``, ``update`` and ``patch`` steps, since they
+ do not typically require that the dependencies are updated and built. Using
+ ``NO_DEPENDS`` for any of the other pre-defined steps, however, may break
+ parallel builds. Only use ``NO_DEPENDS`` where it is certain that the named
+ steps genuinely do not have dependencies. For custom steps, consider whether
+ or not the custom commands require the dependencies to be configured, built
+ and installed.
+
+ Internally, :command:`ExternalProject_Add` calls
+ :command:`ExternalProject_Add_Step` to create each step. If any
+ ``STEP_TARGETS`` or ``INDEPENDENT_STEP_TARGETS`` were specified, then
+ ``ExternalProject_Add_StepTargets()`` will also be called after
+ :command:`ExternalProject_Add_Step`. ``INDEPENDENT_STEP_TARGETS`` have the
+ ``NO_DEPENDS`` option set, whereas ``STEP_TARGETS`` do not. Other than that,
+ the two options result in ``ExternalProject_Add_StepTargets()`` being called
+ in the same way. Even if a step is not mentioned in either of those two
+ options, ``ExternalProject_Add_StepTargets()`` can still be called later to
+ manually define a target for the step.
+
+ The ``STEP_TARGETS`` and ``INDEPENDENT_STEP_TARGETS`` options for
+ :command:`ExternalProject_Add` are generally the easiest way to ensure
+ targets are created for specific steps of interest. For custom steps,
+ ``ExternalProject_Add_StepTargets()`` must be called explicitly if a target
+ should also be created for that custom step. An alternative to these two
+ options is to populate the ``EP_STEP_TARGETS`` and
+ ``EP_INDEPENDENT_STEP_TARGETS`` directory properties. These act as defaults
+ for the step target options and can save having to repeatedly specify the
+ same set of step targets when multiple external projects are being defined.
- ... BUILD_COMMAND make COMMAND echo done ...
+.. command:: ExternalProject_Add_StepDependencies
-specifies to run ``make`` and then ``echo done`` during the build step.
-Whether the current working directory is preserved between commands is
-not defined. Behavior of shell operators like ``&&`` is not defined.
+ The ``ExternalProject_Add_StepDependencies()`` function can be used to add
+ dependencies to a step. The dependencies added must be targets CMake already
+ knows about (these can be ordinary executable or library targets, custom
+ targets or even step targets of another external project):
-Arguments to ``<step>_COMMAND`` or ``COMMAND`` options may use
-:manual:`generator expressions <cmake-generator-expressions(7)>`.
+ .. code-block:: cmake
-.. command:: ExternalProject_Get_Property
+ ExternalProject_Add_StepDependencies(<name> <step> <target1> [<target2>...])
- The ``ExternalProject_Get_Property`` function retrieves external project
- target properties::
+ This function takes care to set both target and file level dependencies and
+ will ensure that parallel builds will not break. It should be used instead of
+ :command:`add_dependencies` whenever adding a dependency for some of the step
+ targets generated by the ``ExternalProject`` module.
- ExternalProject_Get_Property(<name> [prop1 [prop2 [...]]])
+Examples
+^^^^^^^^
- It stores property values in variables of the same name. Property
- names correspond to the keyword argument names of
- ``ExternalProject_Add``.
+The following example shows how to download and build a hypothetical project
+called *FooBar* from github:
-.. command:: ExternalProject_Add_StepTargets
+.. code-block:: cmake
- The ``ExternalProject_Add_StepTargets`` function generates custom
- targets for the steps listed::
-
- ExternalProject_Add_StepTargets(<name> [NO_DEPENDS] [step1 [step2 [...]]])
-
-If ``NO_DEPENDS`` is set, the target will not depend on the
-dependencies of the complete project. This is usually safe to use for
-the download, update, and patch steps that do not require that all the
-dependencies are updated and built. Using ``NO_DEPENDS`` for other
-of the default steps might break parallel builds, so you should avoid,
-it. For custom steps, you should consider whether or not the custom
-commands requires that the dependencies are configured, built and
-installed.
-
-If ``STEP_TARGETS`` or ``INDEPENDENT_STEP_TARGETS`` is set then
-``ExternalProject_Add_StepTargets`` is automatically called at the end
-of matching calls to ``ExternalProject_Add_Step``. Pass
-``STEP_TARGETS`` or ``INDEPENDENT_STEP_TARGETS`` explicitly to
-individual ``ExternalProject_Add`` calls, or implicitly to all
-``ExternalProject_Add`` calls by setting the directory properties
-``EP_STEP_TARGETS`` and ``EP_INDEPENDENT_STEP_TARGETS``. The
-``INDEPENDENT`` version of the argument and of the property will call
-``ExternalProject_Add_StepTargets`` with the ``NO_DEPENDS`` argument.
-
-If ``STEP_TARGETS`` and ``INDEPENDENT_STEP_TARGETS`` are not set,
-clients may still manually call ``ExternalProject_Add_StepTargets``
-after calling ``ExternalProject_Add`` or ``ExternalProject_Add_Step``.
-
-This functionality is provided to make it easy to drive the steps
-independently of each other by specifying targets on build command
-lines. For example, you may be submitting to a sub-project based
-dashboard, where you want to drive the configure portion of the build,
-then submit to the dashboard, followed by the build portion, followed
-by tests. If you invoke a custom target that depends on a step
-halfway through the step dependency chain, then all the previous steps
-will also run to ensure everything is up to date.
-
-For example, to drive configure, build and test steps independently
-for each ``ExternalProject_Add`` call in your project, write the following
-line prior to any ``ExternalProject_Add`` calls in your ``CMakeLists.txt``
-file::
-
- set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test)
+ include(ExternalProject)
+ ExternalProject_Add(foobar
+ GIT_REPOSITORY git@github.com:FooCo/FooBar.git
+ GIT_TAG origin/release/1.2.3
+ )
-.. command:: ExternalProject_Add_StepDependencies
+For the sake of the example, also define a second hypothetical external project
+called *SecretSauce*, which is downloaded from a web server. Two URLs are given
+to take advantage of a faster internal network if available, with a fallback to
+a slower external server. The project is a typical ``Makefile`` project with no
+configure step, so some of the default commands are overridden. The build is
+only required to build the *sauce* target:
+
+.. code-block:: cmake
+
+ find_program(MAKE_EXE NAMES gmake nmake make)
+ ExternalProject_Add(secretsauce
+ URL http://intranet.somecompany.com/artifacts/sauce-2.7.tgz
+ https://www.somecompany.com/downloads/sauce-2.7.zip
+ URL_HASH MD5=d41d8cd98f00b204e9800998ecf8427e
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ${MAKE_EXE} sauce
+ )
+
+Suppose the build step of ``secretsauce`` requires that ``foobar`` must already
+be built. This could be enforced like so:
+
+.. code-block:: cmake
+
+ ExternalProject_Add_StepDependencies(secretsauce build foobar)
+
+Another alternative would be to create a custom target for ``foobar``'s build
+step and make ``secretsauce`` depend on that rather than the whole ``foobar``
+project. This would mean ``foobar`` only needs to be built, it doesn't need to
+run its install or test steps before ``secretsauce`` can be built. The
+dependency can also be defined along with the ``secretsauce`` project:
+
+.. code-block:: cmake
+
+ ExternalProject_Add_StepTargets(foobar build)
+ ExternalProject_Add(secretsauce
+ URL http://intranet.somecompany.com/artifacts/sauce-2.7.tgz
+ https://www.somecompany.com/downloads/sauce-2.7.zip
+ URL_HASH MD5=d41d8cd98f00b204e9800998ecf8427e
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ${MAKE_EXE} sauce
+ DEPENDS foobar-build
+ )
+
+Instead of calling :command:`ExternalProject_Add_StepTargets`, the target could
+be defined along with the ``foobar`` project itself:
+
+.. code-block:: cmake
+
+ ExternalProject_Add(foobar
+ GIT_REPOSITORY git@github.com:FooCo/FooBar.git
+ GIT_TAG origin/release/1.2.3
+ STEP_TARGETS build
+ )
+
+If many external projects should have the same set of step targets, setting a
+directory property may be more convenient. The ``build`` step target could be
+created automatically by setting the ``EP_STEP_TARGETS`` directory property
+before creating the external projects with :command:`ExternalProject_Add`:
+
+.. code-block:: cmake
+
+ set_property(DIRECTORY PROPERTY EP_STEP_TARGETS build)
+
+Lastly, suppose that ``secretsauce`` provides a script called ``makedoc`` which
+can be used to generate its own documentation. Further suppose that the script
+expects the output directory to be provided as the only parameter and that it
+should be run from the ``secretsauce`` source directory. A custom step and a
+custom target to trigger the script can be defined like so:
+
+.. code-block:: cmake
- The ``ExternalProject_Add_StepDependencies`` function add some
- dependencies for some external project step::
+ ExternalProject_Add_Step(secretsauce docs
+ COMMAND <SOURCE_DIR>/makedoc <BINARY_DIR>
+ WORKING_DIRECTORY <SOURCE_DIR>
+ COMMENT "Building secretsauce docs"
+ ALWAYS TRUE
+ EXCLUDE_FROM_MAIN TRUE
+ )
+ ExternalProject_Add_StepTargets(secretsauce docs)
+
+The custom step could then be triggered from the main build like so::
- ExternalProject_Add_StepDependencies(<name> <step> [target1 [target2 [...]]])
+ cmake --build . --target secretsauce-docs
- This function takes care to set both target and file level
- dependencies, and will ensure that parallel builds will not break.
- It should be used instead of :command:`add_dependencies()` when adding
- a dependency for some of the step targets generated by
- ``ExternalProject``.
#]=======================================================================]
+cmake_policy(PUSH)
+cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced
+
# Pre-compute a regex to match documented keywords for each command.
-math(EXPR _ep_documentation_line_count "${CMAKE_CURRENT_LIST_LINE} - 16")
+math(EXPR _ep_documentation_line_count "${CMAKE_CURRENT_LIST_LINE} - 4")
file(STRINGS "${CMAKE_CURRENT_LIST_FILE}" lines
LIMIT_COUNT ${_ep_documentation_line_count}
- REGEX "^\\.\\. command:: [A-Za-z0-9_]+|^ ``[A-Z0-9_]+ .*``$")
+ REGEX "^\\.\\. command:: [A-Za-z0-9_]+|^ +``[A-Z0-9_]+ [^`]*``$")
foreach(line IN LISTS lines)
if("${line}" MATCHES "^\\.\\. command:: ([A-Za-z0-9_]+)")
if(_ep_func)
@@ -421,8 +945,16 @@ foreach(line IN LISTS lines)
#message("function [${_ep_func}]")
set(_ep_keywords_${_ep_func} "^(")
set(_ep_keyword_sep)
- elseif("${line}" MATCHES "^ ``([A-Z0-9_]+) .*``$")
+ elseif("${line}" MATCHES "^ +``([A-Z0-9_]+) [^`]*``$")
set(_ep_key "${CMAKE_MATCH_1}")
+ # COMMAND should never be included as a keyword,
+ # for ExternalProject_Add(), as it is treated as a
+ # special case by argument parsing as an extension
+ # of a previous ..._COMMAND
+ if("x${_ep_key}x" STREQUAL "xCOMMANDx" AND
+ "x${_ep_func}x" STREQUAL "xExternalProject_Addx")
+ continue()
+ endif()
#message(" keyword [${_ep_key}]")
string(APPEND _ep_keywords_${_ep_func}
"${_ep_keyword_sep}${_ep_key}")
@@ -448,6 +980,11 @@ function(_ep_parse_arguments f name ns args)
# We loop through ARGN and consider the namespace starting with an
# upper-case letter followed by at least two more upper-case letters,
# numbers or underscores to be keywords.
+
+ if(NOT DEFINED _ExternalProject_SELF)
+ message(FATAL_ERROR "error: ExternalProject module must be explicitly included before using ${f} function")
+ endif()
+
set(key)
foreach(arg IN LISTS args)
@@ -481,6 +1018,9 @@ function(_ep_parse_arguments f name ns args)
endif()
else()
set(key "${arg}")
+ if(key MATCHES GIT)
+ get_property(have_key TARGET ${name} PROPERTY ${ns}${key} SET)
+ endif()
endif()
endforeach()
endfunction()
@@ -504,7 +1044,7 @@ define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED
BRIEF_DOCS
"List of ExternalProject steps that automatically get corresponding targets"
FULL_DOCS
- "These targets will be dependent on the main target dependencies"
+ "These targets will be dependent on the main target dependencies. "
"See documentation of the ExternalProject_Add_StepTargets() function in the "
"ExternalProject module."
)
@@ -513,7 +1053,7 @@ define_property(DIRECTORY PROPERTY "EP_INDEPENDENT_STEP_TARGETS" INHERITED
BRIEF_DOCS
"List of ExternalProject steps that automatically get corresponding targets"
FULL_DOCS
- "These targets will not be dependent on the main target dependencies"
+ "These targets will not be dependent on the main target dependencies. "
"See documentation of the ExternalProject_Add_StepTargets() function in the "
"ExternalProject module."
)
@@ -525,12 +1065,7 @@ define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED
"ExternalProject module."
)
-function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
- if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.10)
- set(git_clone_shallow_options "--depth 1 --no-single-branch")
- else()
- set(git_clone_shallow_options "--depth 1")
- endif()
+function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name init_submodules git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify)
if(NOT GIT_VERSION_STRING VERSION_LESS 1.8.5)
# Use `git checkout <tree-ish> --` to avoid ambiguity with a local path.
set(git_checkout_explicit-- "--")
@@ -540,18 +1075,41 @@ function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git
# because that will not search for remote branch names, a common use case.
set(git_checkout_explicit-- "")
endif()
- file(WRITE ${script_filename}
-"if(\"${git_tag}\" STREQUAL \"\")
- message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
-endif()
+ if("${git_tag}" STREQUAL "")
+ message(FATAL_ERROR "Tag for git checkout should not be empty.")
+ endif()
+
+ set(git_clone_options "--no-checkout")
+ if(git_shallow)
+ if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.10)
+ list(APPEND git_clone_options "--depth 1 --no-single-branch")
+ else()
+ list(APPEND git_clone_options "--depth 1")
+ endif()
+ endif()
+ if(git_progress)
+ list(APPEND git_clone_options --progress)
+ endif()
+ foreach(config IN LISTS git_config)
+ list(APPEND git_clone_options --config ${config})
+ endforeach()
+ if(NOT ${git_remote_name} STREQUAL "origin")
+ list(APPEND git_clone_options --origin \"${git_remote_name}\")
+ endif()
-set(run 0)
+ string (REPLACE ";" " " git_clone_options "${git_clone_options}")
-if(\"${gitclone_infofile}\" IS_NEWER_THAN \"${gitclone_stampfile}\")
- set(run 1)
-endif()
+ set(git_options)
+ # disable cert checking if explicitly told not to do it
+ if(NOT "x${tls_verify}" STREQUAL "x" AND NOT tls_verify)
+ set(git_options
+ -c http.sslVerify=false)
+ endif()
+ string (REPLACE ";" " " git_options "${git_options}")
-if(NOT run)
+ file(WRITE ${script_filename}
+"
+if(NOT \"${gitclone_infofile}\" IS_NEWER_THAN \"${gitclone_stampfile}\")
message(STATUS \"Avoiding repeated git clone, stamp file is up to date: '${gitclone_stampfile}'\")
return()
endif()
@@ -564,38 +1122,12 @@ if(error_code)
message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\")
endif()
-set(git_options)
-
-# disable cert checking if explicitly told not to do it
-set(tls_verify \"${tls_verify}\")
-if(NOT \"x${tls_verify}\" STREQUAL \"x\" AND NOT tls_verify)
- list(APPEND git_options
- -c http.sslVerify=false)
-endif()
-
-set(git_clone_options)
-
-set(git_shallow \"${git_shallow}\")
-if(git_shallow)
- list(APPEND git_clone_options ${git_clone_shallow_options})
-endif()
-
-set(git_progress \"${git_progress}\")
-if(git_progress)
- list(APPEND git_clone_options --progress)
-endif()
-
-set(git_config \"${git_config}\")
-foreach(config IN LISTS git_config)
- list(APPEND git_clone_options --config \${config})
-endforeach()
-
-# try the clone 3 times incase there is an odd git clone issue
+# try the clone 3 times in case there is an odd git clone issue
set(error_code 1)
set(number_of_tries 0)
while(error_code AND number_of_tries LESS 3)
execute_process(
- COMMAND \"${git_EXECUTABLE}\" \${git_options} clone \${git_clone_options} --origin \"${git_remote_name}\" \"${git_repository}\" \"${src_name}\"
+ COMMAND \"${git_EXECUTABLE}\" ${git_options} clone ${git_clone_options} \"${git_repository}\" \"${src_name}\"
WORKING_DIRECTORY \"${work_dir}\"
RESULT_VARIABLE error_code
)
@@ -610,7 +1142,7 @@ if(error_code)
endif()
execute_process(
- COMMAND \"${git_EXECUTABLE}\" \${git_options} checkout ${git_tag} ${git_checkout_explicit--}
+ COMMAND \"${git_EXECUTABLE}\" ${git_options} checkout ${git_tag} ${git_checkout_explicit--}
WORKING_DIRECTORY \"${work_dir}/${src_name}\"
RESULT_VARIABLE error_code
)
@@ -618,20 +1150,14 @@ if(error_code)
message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\")
endif()
-execute_process(
- COMMAND \"${git_EXECUTABLE}\" \${git_options} submodule init ${git_submodules}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
-if(error_code)
- message(FATAL_ERROR \"Failed to init submodules in: '${work_dir}/${src_name}'\")
+set(init_submodules ${init_submodules})
+if(init_submodules)
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" ${git_options} submodule update --recursive --init ${git_submodules}
+ WORKING_DIRECTORY \"${work_dir}/${src_name}\"
+ RESULT_VARIABLE error_code
+ )
endif()
-
-execute_process(
- COMMAND \"${git_EXECUTABLE}\" \${git_options} submodule update --recursive --init ${git_submodules}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
if(error_code)
message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\")
endif()
@@ -642,7 +1168,6 @@ execute_process(
COMMAND \${CMAKE_COMMAND} -E copy
\"${gitclone_infofile}\"
\"${gitclone_stampfile}\"
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
RESULT_VARIABLE error_code
)
if(error_code)
@@ -655,18 +1180,12 @@ endif()
endfunction()
function(_ep_write_hgclone_script script_filename source_dir hg_EXECUTABLE hg_repository hg_tag src_name work_dir hgclone_infofile hgclone_stampfile)
+ if("${hg_tag}" STREQUAL "")
+ message(FATAL_ERROR "Tag for hg checkout should not be empty.")
+ endif()
file(WRITE ${script_filename}
-"if(\"${hg_tag}\" STREQUAL \"\")
- message(FATAL_ERROR \"Tag for hg checkout should not be empty.\")
-endif()
-
-set(run 0)
-
-if(\"${hgclone_infofile}\" IS_NEWER_THAN \"${hgclone_stampfile}\")
- set(run 1)
-endif()
-
-if(NOT run)
+"
+if(NOT \"${hgclone_infofile}\" IS_NEWER_THAN \"${hgclone_stampfile}\")
message(STATUS \"Avoiding repeated hg clone, stamp file is up to date: '${hgclone_stampfile}'\")
return()
endif()
@@ -703,7 +1222,6 @@ execute_process(
COMMAND \${CMAKE_COMMAND} -E copy
\"${hgclone_infofile}\"
\"${hgclone_stampfile}\"
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
RESULT_VARIABLE error_code
)
if(error_code)
@@ -716,17 +1234,17 @@ endif()
endfunction()
-function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name git_submodules git_repository work_dir)
+function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name init_submodules git_submodules git_repository work_dir)
+ if("${git_tag}" STREQUAL "")
+ message(FATAL_ERROR "Tag for git checkout should not be empty.")
+ endif()
if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.6)
set(git_stash_save_options --all --quiet)
else()
set(git_stash_save_options --quiet)
endif()
file(WRITE ${script_filename}
-"if(\"${git_tag}\" STREQUAL \"\")
- message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
-endif()
-
+"
execute_process(
COMMAND \"${git_EXECUTABLE}\" rev-list --max-count=1 HEAD
WORKING_DIRECTORY \"${work_dir}\"
@@ -873,11 +1391,14 @@ if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\"
endif()
endif()
- execute_process(
- COMMAND \"${git_EXECUTABLE}\" submodule update --recursive --init ${git_submodules}
- WORKING_DIRECTORY \"${work_dir}/${src_name}\"
- RESULT_VARIABLE error_code
- )
+ set(init_submodules ${init_submodules})
+ if(init_submodules)
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" submodule update --recursive --init ${git_submodules}
+ WORKING_DIRECTORY \"${work_dir}/${src_name}\"
+ RESULT_VARIABLE error_code
+ )
+ endif()
if(error_code)
message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\")
endif()
@@ -888,7 +1409,7 @@ endif()
endfunction(_ep_write_gitupdate_script)
-function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_progress hash tls_verify tls_cainfo userpwd http_headers)
+function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_progress hash tls_verify tls_cainfo userpwd http_headers netrc netrc_file)
if(timeout)
set(TIMEOUT_ARGS TIMEOUT ${timeout})
set(TIMEOUT_MSG "${timeout} seconds")
@@ -913,6 +1434,8 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p
set(TLS_VERIFY_CODE "")
set(TLS_CAINFO_CODE "")
+ set(NETRC_CODE "")
+ set(NETRC_FILE_CODE "")
# check for curl globals in the project
if(DEFINED CMAKE_TLS_VERIFY)
@@ -921,6 +1444,12 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p
if(DEFINED CMAKE_TLS_CAINFO)
set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${CMAKE_TLS_CAINFO}\")")
endif()
+ if(DEFINED CMAKE_NETRC)
+ set(NETRC_CODE "set(CMAKE_NETRC \"${CMAKE_NETRC}\")")
+ endif()
+ if(DEFINED CMAKE_NETRC_FILE)
+ set(NETRC_FILE_CODE "set(CMAKE_NETRC_FILE \"${CMAKE_NETRC_FILE}\")")
+ endif()
# now check for curl locals so that the local values
# will override the globals
@@ -935,6 +1464,16 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p
if(tls_cainfo_len GREATER 0)
set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${tls_cainfo}\")")
endif()
+ # check for netrc argument
+ string(LENGTH "${netrc}" netrc_len)
+ if(netrc_len GREATER 0)
+ set(NETRC_CODE "set(CMAKE_NETRC \"${netrc}\")")
+ endif()
+ # check for netrc_file argument
+ string(LENGTH "${netrc_file}" netrc_file_len)
+ if(netrc_file_len GREATER 0)
+ set(NETRC_FILE_CODE "set(CMAKE_NETRC_FILE \"${netrc_file}\")")
+ endif()
if(userpwd STREQUAL ":")
set(USERPWD_ARGS)
@@ -1108,6 +1647,8 @@ function(_ep_set_directories name)
endif()
endif()
set(top "${CMAKE_CURRENT_BINARY_DIR}")
+
+ # Apply defaults and convert to absolute paths.
set(places stamp download source binary install tmp)
foreach(var ${places})
string(TOUPPER "${var}" VAR)
@@ -1120,6 +1661,17 @@ function(_ep_set_directories name)
endif()
set_property(TARGET ${name} PROPERTY _EP_${VAR}_DIR "${${var}_dir}")
endforeach()
+
+ # Special case for default log directory based on stamp directory.
+ get_property(log_dir TARGET ${name} PROPERTY _EP_LOG_DIR)
+ if(NOT log_dir)
+ get_property(log_dir TARGET ${name} PROPERTY _EP_STAMP_DIR)
+ endif()
+ if(NOT IS_ABSOLUTE "${log_dir}")
+ get_filename_component(log_dir "${top}/${log_dir}" ABSOLUTE)
+ endif()
+ set_property(TARGET ${name} PROPERTY _EP_LOG_DIR "${log_dir}")
+
get_property(source_subdir TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR)
if(NOT source_subdir)
set_property(TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR "")
@@ -1133,7 +1685,11 @@ function(_ep_set_directories name)
endif()
if(build_in_source)
get_property(source_dir TARGET ${name} PROPERTY _EP_SOURCE_DIR)
- set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}")
+ if(source_subdir)
+ set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}/${source_subdir}")
+ else()
+ set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}")
+ endif()
endif()
# Make the directories at CMake configure time *and* add a custom command
@@ -1162,7 +1718,7 @@ macro(_ep_replace_location_tags target_name)
set(vars ${ARGN})
foreach(var ${vars})
if(${var})
- foreach(dir SOURCE_DIR SOURCE_SUBDIR BINARY_DIR INSTALL_DIR TMP_DIR DOWNLOADED_FILE)
+ foreach(dir SOURCE_DIR SOURCE_SUBDIR BINARY_DIR INSTALL_DIR TMP_DIR DOWNLOAD_DIR DOWNLOADED_FILE LOG_DIR)
get_property(val TARGET ${target_name} PROPERTY _EP_${dir})
string(REPLACE "<${dir}>" "${val}" ${var} "${${var}}")
endforeach()
@@ -1182,7 +1738,7 @@ function(_ep_command_line_to_initial_cache var args force)
foreach(line ${args})
if("${line}" MATCHES "^-D(.*)")
set(line "${CMAKE_MATCH_1}")
- if(setArg)
+ if(NOT "${setArg}" STREQUAL "")
# This is required to build up lists in variables, or complete an entry
string(APPEND setArg "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})")
string(APPEND script_initial_cache "\n${setArg}")
@@ -1203,7 +1759,7 @@ function(_ep_command_line_to_initial_cache var args force)
endif()
endforeach()
# Catch the final line of the args
- if(setArg)
+ if(NOT "${setArg}" STREQUAL "")
string(APPEND setArg "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})")
string(APPEND script_initial_cache "\n${setArg}")
endif()
@@ -1286,7 +1842,8 @@ function(_ep_get_build_command name step cmd_var)
set(cmd "${CMAKE_COMMAND}")
endif()
set(args --build ".")
- if(CMAKE_CONFIGURATION_TYPES)
+ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if(_isMultiConfig)
if (CMAKE_CFG_INTDIR AND
NOT CMAKE_CFG_INTDIR STREQUAL "." AND
NOT CMAKE_CFG_INTDIR MATCHES "\\$")
@@ -1311,7 +1868,7 @@ function(_ep_get_build_command name step cmd_var)
if("x${step}x" STREQUAL "xTESTx")
string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}")
set(args "")
- if(CMAKE_CONFIGURATION_TYPES)
+ if(_isMultiConfig)
list(APPEND args -C ${config})
endif()
endif()
@@ -1343,6 +1900,7 @@ function(_ep_get_build_command name step cmd_var)
endfunction()
function(_ep_write_log_script name step cmd_var)
+ ExternalProject_Get_Property(${name} log_dir)
ExternalProject_Get_Property(${name} stamp_dir)
set(command "${${cmd_var}}")
@@ -1414,23 +1972,66 @@ endif()
# Wrap the command in a script to log output to files.
set(script ${stamp_dir}/${name}-${step}-$<CONFIG>.cmake)
- set(logbase ${stamp_dir}/${name}-${step})
+ set(logbase ${log_dir}/${name}-${step})
+ get_property(log_merged TARGET ${name} PROPERTY _EP_LOG_MERGED_STDOUTERR)
+ get_property(log_output_on_failure TARGET ${name} PROPERTY _EP_LOG_OUTPUT_ON_FAILURE)
+ if (log_merged)
+ set(stdout_log "${logbase}.log")
+ set(stderr_log "${logbase}.log")
+ else()
+ set(stdout_log "${logbase}-out.log")
+ set(stderr_log "${logbase}-err.log")
+ endif()
set(code "
+cmake_minimum_required(VERSION 3.15)
${code_cygpath_make}
set(command \"${command}\")
+set(log_merged \"${log_merged}\")
+set(log_output_on_failure \"${log_output_on_failure}\")
+set(stdout_log \"${stdout_log}\")
+set(stderr_log \"${stderr_log}\")
execute_process(
COMMAND \${command}
RESULT_VARIABLE result
- OUTPUT_FILE \"${logbase}-out.log\"
- ERROR_FILE \"${logbase}-err.log\"
+ OUTPUT_FILE \"\${stdout_log}\"
+ ERROR_FILE \"\${stderr_log}\"
)
+macro(read_up_to_max_size log_file output_var)
+ file(SIZE \${log_file} determined_size)
+ set(max_size 10240)
+ if (determined_size GREATER max_size)
+ math(EXPR seek_position \"\${determined_size} - \${max_size}\")
+ file(READ \${log_file} \${output_var} OFFSET \${seek_position})
+ set(\${output_var} \"...skipping to end...\\n\${\${output_var}}\")
+ else()
+ file(READ \${log_file} \${output_var})
+ endif()
+endmacro()
if(result)
set(msg \"Command failed: \${result}\\n\")
foreach(arg IN LISTS command)
set(msg \"\${msg} '\${arg}'\")
endforeach()
- set(msg \"\${msg}\\nSee also\\n ${logbase}-*.log\")
- message(FATAL_ERROR \"\${msg}\")
+ if (\${log_merged})
+ set(msg \"\${msg}\\nSee also\\n \${stderr_log}\")
+ else()
+ set(msg \"\${msg}\\nSee also\\n ${logbase}-*.log\")
+ endif()
+ if (\${log_output_on_failure})
+ message(SEND_ERROR \"\${msg}\")
+ if (\${log_merged})
+ read_up_to_max_size(\"\${stderr_log}\" error_log_contents)
+ message(STATUS \"Log output is:\\n\${error_log_contents}\")
+ else()
+ read_up_to_max_size(\"\${stdout_log}\" out_log_contents)
+ read_up_to_max_size(\"\${stderr_log}\" err_log_contents)
+ message(STATUS \"stdout output is:\\n\${out_log_contents}\")
+ message(STATUS \"stderr output is:\\n\${err_log_contents}\")
+ endif()
+ message(FATAL_ERROR \"Stopping after outputting logs.\")
+ else()
+ message(FATAL_ERROR \"\${msg}\")
+ endif()
else()
set(msg \"${name} ${step} command succeeded. See also ${logbase}-*.log\")
message(STATUS \"\${msg}\")
@@ -1451,7 +2052,8 @@ endfunction()
#
function(_ep_get_configuration_subdir_suffix suffix_var)
set(suffix "")
- if(CMAKE_CONFIGURATION_TYPES)
+ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if(_isMultiConfig)
set(suffix "/${CMAKE_CFG_INTDIR}")
endif()
set(${suffix_var} "${suffix}" PARENT_SCOPE)
@@ -1468,6 +2070,15 @@ function(_ep_get_step_stampfile name step stampfile_var)
endfunction()
+function(_ep_get_complete_stampfile name stampfile_var)
+ set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
+ _ep_get_configuration_subdir_suffix(cfgdir)
+ set(stampfile "${cmf_dir}${cfgdir}/${name}-complete")
+
+ set(${stampfile_var} ${stampfile} PARENT_SCOPE)
+endfunction()
+
+
function(ExternalProject_Add_StepTargets name)
set(steps ${ARGN})
if(ARGC GREATER 1 AND "${ARGV1}" STREQUAL "NO_DEPENDS")
@@ -1497,10 +2108,7 @@ endfunction()
function(ExternalProject_Add_Step name step)
- set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
- _ep_get_configuration_subdir_suffix(cfgdir)
-
- set(complete_stamp_file "${cmf_dir}${cfgdir}/${name}-complete")
+ _ep_get_complete_stampfile(${name} complete_stamp_file)
_ep_get_step_stampfile(${name} ${step} stamp_file)
_ep_parse_arguments(ExternalProject_Add_Step
@@ -1575,7 +2183,8 @@ function(ExternalProject_Add_Step name step)
set_property(SOURCE ${stamp_file} PROPERTY SYMBOLIC 1)
set(touch)
# Remove any existing stamp in case the option changed in an existing tree.
- if(CMAKE_CONFIGURATION_TYPES)
+ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if(_isMultiConfig)
foreach(cfg ${CMAKE_CONFIGURATION_TYPES})
string(REPLACE "/${CMAKE_CFG_INTDIR}" "/${cfg}" stamp_file_config "${stamp_file}")
file(REMOVE ${stamp_file_config})
@@ -1694,7 +2303,7 @@ endfunction()
function(_ep_add_mkdir_command name)
ExternalProject_Get_Property(${name}
- source_dir binary_dir install_dir stamp_dir download_dir tmp_dir)
+ source_dir binary_dir install_dir stamp_dir download_dir tmp_dir log_dir)
_ep_get_configuration_subdir_suffix(cfgdir)
@@ -1706,6 +2315,7 @@ function(_ep_add_mkdir_command name)
COMMAND ${CMAKE_COMMAND} -E make_directory ${tmp_dir}
COMMAND ${CMAKE_COMMAND} -E make_directory ${stamp_dir}${cfgdir}
COMMAND ${CMAKE_COMMAND} -E make_directory ${download_dir}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${log_dir}
)
endfunction()
@@ -1821,7 +2431,15 @@ function(_ep_add_download_command name)
if(NOT git_tag)
set(git_tag "master")
endif()
- get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
+
+ set(git_init_submodules TRUE)
+ get_property(git_submodules_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES SET)
+ if(git_submodules_set)
+ get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
+ if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW")
+ set(git_init_submodules FALSE)
+ endif()
+ endif()
get_property(git_remote_name TARGET ${name} PROPERTY _EP_GIT_REMOTE_NAME)
if(NOT git_remote_name)
@@ -1844,7 +2462,7 @@ function(_ep_add_download_command name)
#
set(repository ${git_repository})
set(module)
- set(tag)
+ set(tag ${git_remote_name})
configure_file(
"${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
"${stamp_dir}/${name}-gitinfo.txt"
@@ -1859,7 +2477,7 @@ function(_ep_add_download_command name)
# The script will delete the source directory and then call git clone.
#
_ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir}
- ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} "${git_submodules}" "${git_shallow}" "${git_progress}" "${git_config}" ${src_name} ${work_dir}
+ ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules}" "${git_shallow}" "${git_progress}" "${git_config}" ${src_name} ${work_dir}
${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt "${tls_verify}"
)
set(comment "Performing download step (git clone) for '${name}'")
@@ -1972,11 +2590,13 @@ function(_ep_add_download_command name)
get_property(no_progress TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS)
get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY)
get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO)
+ get_property(netrc TARGET ${name} PROPERTY _EP_NETRC)
+ get_property(netrc_file TARGET ${name} PROPERTY _EP_NETRC_FILE)
get_property(http_username TARGET ${name} PROPERTY _EP_HTTP_USERNAME)
get_property(http_password TARGET ${name} PROPERTY _EP_HTTP_PASSWORD)
get_property(http_headers TARGET ${name} PROPERTY _EP_HTTP_HEADER)
set(download_script "${stamp_dir}/download-${name}.cmake")
- _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}")
+ _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}" "${netrc}" "${netrc_file}")
set(cmd ${CMAKE_COMMAND} -P "${download_script}"
COMMAND)
if (no_extract)
@@ -2012,12 +2632,12 @@ function(_ep_add_download_command name)
" ${source_dir}\n"
"is not an existing non-empty directory. Please specify one of:\n"
" * SOURCE_DIR with an existing non-empty directory\n"
+ " * DOWNLOAD_COMMAND\n"
" * URL\n"
" * GIT_REPOSITORY\n"
+ " * SVN_REPOSITORY\n"
" * HG_REPOSITORY\n"
- " * CVS_REPOSITORY and CVS_MODULE\n"
- " * SVN_REVISION\n"
- " * DOWNLOAD_COMMAND"
+ " * CVS_REPOSITORY and CVS_MODULE"
)
endif()
endif()
@@ -2122,9 +2742,18 @@ function(_ep_add_update_command name)
if(NOT git_remote_name)
set(git_remote_name "origin")
endif()
- get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
+
+ set(git_init_submodules TRUE)
+ get_property(git_submodules_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES SET)
+ if(git_submodules_set)
+ get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES)
+ if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW")
+ set(git_init_submodules FALSE)
+ endif()
+ endif()
+
_ep_write_gitupdate_script(${tmp_dir}/${name}-gitupdate.cmake
- ${GIT_EXECUTABLE} ${git_tag} ${git_remote_name} "${git_submodules}" ${git_repository} ${work_dir}
+ ${GIT_EXECUTABLE} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules}" ${git_repository} ${work_dir}
)
set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitupdate.cmake)
set(always 1)
@@ -2207,10 +2836,18 @@ function(_ep_add_patch_command name)
set(work_dir ${source_dir})
endif()
+ get_property(log TARGET ${name} PROPERTY _EP_LOG_PATCH)
+ if(log)
+ set(log LOG 1)
+ else()
+ set(log "")
+ endif()
+
ExternalProject_Add_Step(${name} patch
COMMAND ${cmd}
WORKING_DIRECTORY ${work_dir}
DEPENDEES download
+ ${log}
)
endfunction()
@@ -2235,19 +2872,18 @@ function(_ep_extract_configure_command var name)
get_property(cmake_cache_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_ARGS)
get_property(cmake_cache_default_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_DEFAULT_ARGS)
- if(cmake_cache_args OR cmake_cache_default_args)
- set(_ep_cache_args_script "<TMP_DIR>/${name}-cache-$<CONFIG>.cmake")
- if(cmake_cache_args)
- _ep_command_line_to_initial_cache(script_initial_cache_force "${cmake_cache_args}" 1)
- endif()
- if(cmake_cache_default_args)
- _ep_command_line_to_initial_cache(script_initial_cache_default "${cmake_cache_default_args}" 0)
- endif()
- _ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${script_initial_cache_force}${script_initial_cache_default}")
- list(APPEND cmd "-C${_ep_cache_args_script}")
+ set(has_cmake_cache_args 0)
+ if(NOT "${cmake_cache_args}" STREQUAL "")
+ set(has_cmake_cache_args 1)
+ endif()
+
+ set(has_cmake_cache_default_args 0)
+ if(NOT "${cmake_cache_default_args}" STREQUAL "")
+ set(has_cmake_cache_default_args 1)
endif()
get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR)
+ get_target_property(cmake_generator_instance ${name} _EP_CMAKE_GENERATOR_INSTANCE)
get_target_property(cmake_generator_platform ${name} _EP_CMAKE_GENERATOR_PLATFORM)
get_target_property(cmake_generator_toolset ${name} _EP_CMAKE_GENERATOR_TOOLSET)
if(cmake_generator)
@@ -2258,11 +2894,24 @@ function(_ep_extract_configure_command var name)
if(cmake_generator_toolset)
list(APPEND cmd "-T${cmake_generator_toolset}")
endif()
+ if(cmake_generator_instance)
+ list(APPEND cmd "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${cmake_generator_instance}")
+ endif()
else()
if(CMAKE_EXTRA_GENERATOR)
list(APPEND cmd "-G${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}")
else()
list(APPEND cmd "-G${CMAKE_GENERATOR}")
+ if("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI")
+ set(has_cmake_cache_default_args 1)
+ set(cmake_cache_default_args ${cmake_cache_default_args}
+ "-DGHS_TARGET_PLATFORM:STRING=${GHS_TARGET_PLATFORM}"
+ "-DGHS_PRIMARY_TARGET:STRING=${GHS_PRIMARY_TARGET}"
+ "-DGHS_TOOLSET_ROOT:STRING=${GHS_TOOLSET_ROOT}"
+ "-DGHS_OS_ROOT:STRING=${GHS_OS_ROOT}"
+ "-DGHS_OS_DIR:STRING=${GHS_OS_DIR}"
+ "-DGHS_BSP_NAME:STRING=${GHS_BSP_NAME}")
+ endif()
endif()
if(cmake_generator_platform)
message(FATAL_ERROR "Option CMAKE_GENERATOR_PLATFORM not allowed without CMAKE_GENERATOR.")
@@ -2276,6 +2925,24 @@ function(_ep_extract_configure_command var name)
if(CMAKE_GENERATOR_TOOLSET)
list(APPEND cmd "-T${CMAKE_GENERATOR_TOOLSET}")
endif()
+ if(cmake_generator_instance)
+ message(FATAL_ERROR "Option CMAKE_GENERATOR_INSTANCE not allowed without CMAKE_GENERATOR.")
+ endif()
+ if(CMAKE_GENERATOR_INSTANCE)
+ list(APPEND cmd "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}")
+ endif()
+ endif()
+
+ if(has_cmake_cache_args OR has_cmake_cache_default_args)
+ set(_ep_cache_args_script "<TMP_DIR>/${name}-cache-$<CONFIG>.cmake")
+ if(has_cmake_cache_args)
+ _ep_command_line_to_initial_cache(script_initial_cache_force "${cmake_cache_args}" 1)
+ endif()
+ if(has_cmake_cache_default_args)
+ _ep_command_line_to_initial_cache(script_initial_cache_default "${cmake_cache_default_args}" 0)
+ endif()
+ _ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${script_initial_cache_force}${script_initial_cache_default}")
+ list(APPEND cmd "-C${_ep_cache_args_script}")
endif()
list(APPEND cmd "<SOURCE_DIR><SOURCE_SUBDIR>")
@@ -2499,11 +3166,15 @@ endfunction()
function(ExternalProject_Add name)
+ cmake_policy(GET CMP0097 _EP_CMP0097
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+
_ep_get_configuration_subdir_suffix(cfgdir)
# Add a custom target for the external project.
set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
- set(complete_stamp_file "${cmf_dir}${cfgdir}/${name}-complete")
+ _ep_get_complete_stampfile(${name} complete_stamp_file)
# The "ALL" option to add_custom_target just tells it to not set the
# EXCLUDE_FROM_ALL target property. Later, if the EXCLUDE_FROM_ALL
@@ -2574,3 +3245,5 @@ function(ExternalProject_Add name)
#
_ep_add_test_command(${name})
endfunction()
+
+cmake_policy(POP)
diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake
index 1b93304bb..4a3e83af3 100644
--- a/Modules/FeatureSummary.cmake
+++ b/Modules/FeatureSummary.cmake
@@ -97,8 +97,6 @@ Functions
#]=======================================================================]
-include(CMakeParseArguments)
-
function(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet)
get_property(_fsPkgTypes GLOBAL PROPERTY FeatureSummary_PKG_TYPES)
@@ -493,7 +491,7 @@ endfunction()
by the project when available at buildtime, but it also work without.
``RECOMMENDED`` is similar to ``OPTIONAL``, i.e. the project will build if
the package is not present, but the functionality of the resulting
- binaries will be severly limited. If a ``REQUIRED`` package is not
+ binaries will be severely limited. If a ``REQUIRED`` package is not
available at buildtime, the project may not even build. This can be
combined with the ``FATAL_ON_MISSING_REQUIRED_PACKAGES`` argument for
``feature_summary()``. Last, a ``RUNTIME`` package is a package which is
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
new file mode 100644
index 000000000..5716b0112
--- /dev/null
+++ b/Modules/FetchContent.cmake
@@ -0,0 +1,1061 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FetchContent
+------------------
+
+.. only:: html
+
+ .. contents::
+
+Overview
+^^^^^^^^
+
+This module enables populating content at configure time via any method
+supported by the :module:`ExternalProject` module. Whereas
+:command:`ExternalProject_Add` downloads at build time, the
+``FetchContent`` module makes content available immediately, allowing the
+configure step to use the content in commands like :command:`add_subdirectory`,
+:command:`include` or :command:`file` operations.
+
+Content population details would normally be defined separately from the
+command that performs the actual population. This separation ensures that
+all of the dependency details are defined before anything may try to use those
+details to populate content. This is particularly important in more complex
+project hierarchies where dependencies may be shared between multiple projects.
+
+The following shows a typical example of declaring content details:
+
+.. code-block:: cmake
+
+ FetchContent_Declare(
+ googletest
+ GIT_REPOSITORY https://github.com/google/googletest.git
+ GIT_TAG release-1.8.0
+ )
+
+For most typical cases, populating the content can then be done with a single
+command like so:
+
+.. code-block:: cmake
+
+ FetchContent_MakeAvailable(googletest)
+
+The above command not only populates the content, it also adds it to the main
+build (if possible) so that the main build can use the populated project's
+targets, etc. In some cases, the main project may need to have more precise
+control over the population or may be required to explicitly define the
+population steps (e.g. if CMake versions earlier than 3.14 need to be
+supported). The typical pattern of such custom steps looks like this:
+
+.. code-block:: cmake
+
+ FetchContent_GetProperties(googletest)
+ if(NOT googletest_POPULATED)
+ FetchContent_Populate(googletest)
+ add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
+ endif()
+
+Regardless of which population method is used, when using the
+declare-populate pattern with a hierarchical project arrangement, projects at
+higher levels in the hierarchy are able to override the population details of
+content specified anywhere lower in the project hierarchy. The ability to
+detect whether content has already been populated ensures that even if
+multiple child projects want certain content to be available, the first one
+to populate it wins. The other child project can simply make use of the
+already available content instead of repeating the population for itself.
+See the :ref:`Examples <fetch-content-examples>` section which demonstrates
+this scenario.
+
+The ``FetchContent`` module also supports defining and populating
+content in a single call, with no check for whether the content has been
+populated elsewhere in the project already. This is a more low level
+operation and would not normally be the way the module is used, but it is
+sometimes useful as part of implementing some higher level feature or to
+populate some content in CMake's script mode.
+
+
+Declaring Content Details
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. command:: FetchContent_Declare
+
+ .. code-block:: cmake
+
+ FetchContent_Declare(<name> <contentOptions>...)
+
+ The ``FetchContent_Declare()`` function records the options that describe
+ how to populate the specified content, but if such details have already
+ been recorded earlier in this project (regardless of where in the project
+ hierarchy), this and all later calls for the same content ``<name>`` are
+ ignored. This "first to record, wins" approach is what allows hierarchical
+ projects to have parent projects override content details of child projects.
+
+ The content ``<name>`` can be any string without spaces, but good practice
+ would be to use only letters, numbers and underscores. The name will be
+ treated case-insensitively and it should be obvious for the content it
+ represents, often being the name of the child project or the value given
+ to its top level :command:`project` command (if it is a CMake project).
+ For well-known public projects, the name should generally be the official
+ name of the project. Choosing an unusual name makes it unlikely that other
+ projects needing that same content will use the same name, leading to
+ the content being populated multiple times.
+
+ The ``<contentOptions>`` can be any of the download or update/patch options
+ that the :command:`ExternalProject_Add` command understands. The configure,
+ build, install and test steps are explicitly disabled and therefore options
+ related to them will be ignored. In most cases, ``<contentOptions>`` will
+ just be a couple of options defining the download method and method-specific
+ details like a commit tag or archive hash. For example:
+
+ .. code-block:: cmake
+
+ FetchContent_Declare(
+ googletest
+ GIT_REPOSITORY https://github.com/google/googletest.git
+ GIT_TAG release-1.8.0
+ )
+
+ FetchContent_Declare(
+ myCompanyIcons
+ URL https://intranet.mycompany.com/assets/iconset_1.12.tar.gz
+ URL_HASH 5588a7b18261c20068beabfb4f530b87
+ )
+
+ FetchContent_Declare(
+ myCompanyCertificates
+ SVN_REPOSITORY svn+ssh://svn.mycompany.com/srv/svn/trunk/certs
+ SVN_REVISION -r12345
+ )
+
+Populating The Content
+^^^^^^^^^^^^^^^^^^^^^^
+
+For most common scenarios, population means making content available to the
+main build according to previously declared details for that dependency.
+There are two main patterns for populating content, one based on calling
+:command:`FetchContent_GetProperties` and
+:command:`FetchContent_Populate` for more precise control and the other on
+calling :command:`FetchContent_MakeAvailable` for a simpler, more automated
+approach. The former generally follows this canonical pattern:
+
+.. _`fetch-content-canonical-pattern`:
+
+.. code-block:: cmake
+
+ # Check if population has already been performed
+ FetchContent_GetProperties(<name>)
+ string(TOLOWER "<name>" lcName)
+ if(NOT ${lcName}_POPULATED)
+ # Fetch the content using previously declared details
+ FetchContent_Populate(<name>)
+
+ # Set custom variables, policies, etc.
+ # ...
+
+ # Bring the populated content into the build
+ add_subdirectory(${${lcName}_SOURCE_DIR} ${${lcName}_BINARY_DIR})
+ endif()
+
+The above is such a common pattern that, where no custom steps are needed
+between the calls to :command:`FetchContent_Populate` and
+:command:`add_subdirectory`, equivalent logic can be obtained by calling
+:command:`FetchContent_MakeAvailable` instead (and should be preferred where
+it meets the needs of the project).
+
+.. command:: FetchContent_Populate
+
+ .. code-block:: cmake
+
+ FetchContent_Populate( <name> )
+
+ In most cases, the only argument given to ``FetchContent_Populate()`` is the
+ ``<name>``. When used this way, the command assumes the content details have
+ been recorded by an earlier call to :command:`FetchContent_Declare`. The
+ details are stored in a global property, so they are unaffected by things
+ like variable or directory scope. Therefore, it doesn't matter where in the
+ project the details were previously declared, as long as they have been
+ declared before the call to ``FetchContent_Populate()``. Those saved details
+ are then used to construct a call to :command:`ExternalProject_Add` in a
+ private sub-build to perform the content population immediately. The
+ implementation of ``ExternalProject_Add()`` ensures that if the content has
+ already been populated in a previous CMake run, that content will be reused
+ rather than repopulating them again. For the common case where population
+ involves downloading content, the cost of the download is only paid once.
+
+ An internal global property records when a particular content population
+ request has been processed. If ``FetchContent_Populate()`` is called more
+ than once for the same content name within a configure run, the second call
+ will halt with an error. Projects can and should check whether content
+ population has already been processed with the
+ :command:`FetchContent_GetProperties` command before calling
+ ``FetchContent_Populate()``.
+
+ ``FetchContent_Populate()`` will set three variables in the scope of the
+ caller; ``<lcName>_POPULATED``, ``<lcName>_SOURCE_DIR`` and
+ ``<lcName>_BINARY_DIR``, where ``<lcName>`` is the lowercased ``<name>``.
+ ``<lcName>_POPULATED`` will always be set to ``True`` by the call.
+ ``<lcName>_SOURCE_DIR`` is the location where the
+ content can be found upon return (it will have already been populated), while
+ ``<lcName>_BINARY_DIR`` is a directory intended for use as a corresponding
+ build directory. The main use case for the two directory variables is to
+ call :command:`add_subdirectory` immediately after population, i.e.:
+
+ .. code-block:: cmake
+
+ FetchContent_Populate(FooBar ...)
+ add_subdirectory(${foobar_SOURCE_DIR} ${foobar_BINARY_DIR})
+
+ The values of the three variables can also be retrieved from anywhere in the
+ project hierarchy using the :command:`FetchContent_GetProperties` command.
+
+ A number of cache variables influence the behavior of all content population
+ performed using details saved from a :command:`FetchContent_Declare` call:
+
+ ``FETCHCONTENT_BASE_DIR``
+ In most cases, the saved details do not specify any options relating to the
+ directories to use for the internal sub-build, final source and build areas.
+ It is generally best to leave these decisions up to the ``FetchContent``
+ module to handle on the project's behalf. The ``FETCHCONTENT_BASE_DIR``
+ cache variable controls the point under which all content population
+ directories are collected, but in most cases developers would not need to
+ change this. The default location is ``${CMAKE_BINARY_DIR}/_deps``, but if
+ developers change this value, they should aim to keep the path short and
+ just below the top level of the build tree to avoid running into path
+ length problems on Windows.
+
+ ``FETCHCONTENT_QUIET``
+ The logging output during population can be quite verbose, making the
+ configure stage quite noisy. This cache option (``ON`` by default) hides
+ all population output unless an error is encountered. If experiencing
+ problems with hung downloads, temporarily switching this option off may
+ help diagnose which content population is causing the issue.
+
+ ``FETCHCONTENT_FULLY_DISCONNECTED``
+ When this option is enabled, no attempt is made to download or update
+ any content. It is assumed that all content has already been populated in
+ a previous run or the source directories have been pointed at existing
+ contents the developer has provided manually (using options described
+ further below). When the developer knows that no changes have been made to
+ any content details, turning this option ``ON`` can significantly speed up
+ the configure stage. It is ``OFF`` by default.
+
+ ``FETCHCONTENT_UPDATES_DISCONNECTED``
+ This is a less severe download/update control compared to
+ ``FETCHCONTENT_FULLY_DISCONNECTED``. Instead of bypassing all download and
+ update logic, the ``FETCHCONTENT_UPDATES_DISCONNECTED`` only disables the
+ update stage. Therefore, if content has not been downloaded previously,
+ it will still be downloaded when this option is enabled. This can speed up
+ the configure stage, but not as much as
+ ``FETCHCONTENT_FULLY_DISCONNECTED``. It is ``OFF`` by default.
+
+ In addition to the above cache variables, the following cache variables are
+ also defined for each content name (``<ucName>`` is the uppercased value of
+ ``<name>``):
+
+ ``FETCHCONTENT_SOURCE_DIR_<ucName>``
+ If this is set, no download or update steps are performed for the specified
+ content and the ``<lcName>_SOURCE_DIR`` variable returned to the caller is
+ pointed at this location. This gives developers a way to have a separate
+ checkout of the content that they can modify freely without interference
+ from the build. The build simply uses that existing source, but it still
+ defines ``<lcName>_BINARY_DIR`` to point inside its own build area.
+ Developers are strongly encouraged to use this mechanism rather than
+ editing the sources populated in the default location, as changes to
+ sources in the default location can be lost when content population details
+ are changed by the project.
+
+ ``FETCHCONTENT_UPDATES_DISCONNECTED_<ucName>``
+ This is the per-content equivalent of
+ ``FETCHCONTENT_UPDATES_DISCONNECTED``. If the global option or this option
+ is ``ON``, then updates will be disabled for the named content.
+ Disabling updates for individual content can be useful for content whose
+ details rarely change, while still leaving other frequently changing
+ content with updates enabled.
+
+
+ The ``FetchContent_Populate()`` command also supports a syntax allowing the
+ content details to be specified directly rather than using any saved
+ details. This is more low-level and use of this form is generally to be
+ avoided in favour of using saved content details as outlined above.
+ Nevertheless, in certain situations it can be useful to invoke the content
+ population as an isolated operation (typically as part of implementing some
+ other higher level feature or when using CMake in script mode):
+
+ .. code-block:: cmake
+
+ FetchContent_Populate( <name>
+ [QUIET]
+ [SUBBUILD_DIR <subBuildDir>]
+ [SOURCE_DIR <srcDir>]
+ [BINARY_DIR <binDir>]
+ ...
+ )
+
+ This form has a number of key differences to that where only ``<name>`` is
+ provided:
+
+ - All required population details are assumed to have been provided directly
+ in the call to ``FetchContent_Populate()``. Any saved details for
+ ``<name>`` are ignored.
+ - No check is made for whether content for ``<name>`` has already been
+ populated.
+ - No global property is set to record that the population has occurred.
+ - No global properties record the source or binary directories used for the
+ populated content.
+ - The ``FETCHCONTENT_FULLY_DISCONNECTED`` and
+ ``FETCHCONTENT_UPDATES_DISCONNECTED`` cache variables are ignored.
+
+ The ``<lcName>_SOURCE_DIR`` and ``<lcName>_BINARY_DIR`` variables are still
+ returned to the caller, but since these locations are not stored as global
+ properties when this form is used, they are only available to the calling
+ scope and below rather than the entire project hierarchy. No
+ ``<lcName>_POPULATED`` variable is set in the caller's scope with this form.
+
+ The supported options for ``FetchContent_Populate()`` are the same as those
+ for :command:`FetchContent_Declare()`. Those few options shown just
+ above are either specific to ``FetchContent_Populate()`` or their behavior is
+ slightly modified from how :command:`ExternalProject_Add` treats them.
+
+ ``QUIET``
+ The ``QUIET`` option can be given to hide the output associated with
+ populating the specified content. If the population fails, the output will
+ be shown regardless of whether this option was given or not so that the
+ cause of the failure can be diagnosed. The global ``FETCHCONTENT_QUIET``
+ cache variable has no effect on ``FetchContent_Populate()`` calls where the
+ content details are provided directly.
+
+ ``SUBBUILD_DIR``
+ The ``SUBBUILD_DIR`` argument can be provided to change the location of the
+ sub-build created to perform the population. The default value is
+ ``${CMAKE_CURRENT_BINARY_DIR}/<lcName>-subbuild`` and it would be unusual
+ to need to override this default. If a relative path is specified, it will
+ be interpreted as relative to :variable:`CMAKE_CURRENT_BINARY_DIR`.
+
+ ``SOURCE_DIR``, ``BINARY_DIR``
+ The ``SOURCE_DIR`` and ``BINARY_DIR`` arguments are supported by
+ :command:`ExternalProject_Add`, but different default values are used by
+ ``FetchContent_Populate()``. ``SOURCE_DIR`` defaults to
+ ``${CMAKE_CURRENT_BINARY_DIR}/<lcName>-src`` and ``BINARY_DIR`` defaults to
+ ``${CMAKE_CURRENT_BINARY_DIR}/<lcName>-build``. If a relative path is
+ specified, it will be interpreted as relative to
+ :variable:`CMAKE_CURRENT_BINARY_DIR`.
+
+ In addition to the above explicit options, any other unrecognized options are
+ passed through unmodified to :command:`ExternalProject_Add` to perform the
+ download, patch and update steps. The following options are explicitly
+ prohibited (they are disabled by the ``FetchContent_Populate()`` command):
+
+ - ``CONFIGURE_COMMAND``
+ - ``BUILD_COMMAND``
+ - ``INSTALL_COMMAND``
+ - ``TEST_COMMAND``
+
+ If using ``FetchContent_Populate()`` within CMake's script mode, be aware
+ that the implementation sets up a sub-build which therefore requires a CMake
+ generator and build tool to be available. If these cannot be found by
+ default, then the :variable:`CMAKE_GENERATOR` and/or
+ :variable:`CMAKE_MAKE_PROGRAM` variables will need to be set appropriately
+ on the command line invoking the script.
+
+
+.. command:: FetchContent_GetProperties
+
+ When using saved content details, a call to :command:`FetchContent_Populate`
+ records information in global properties which can be queried at any time.
+ This information includes the source and binary directories associated with
+ the content and also whether or not the content population has been processed
+ during the current configure run.
+
+ .. code-block:: cmake
+
+ FetchContent_GetProperties( <name>
+ [SOURCE_DIR <srcDirVar>]
+ [BINARY_DIR <binDirVar>]
+ [POPULATED <doneVar>]
+ )
+
+ The ``SOURCE_DIR``, ``BINARY_DIR`` and ``POPULATED`` options can be used to
+ specify which properties should be retrieved. Each option accepts a value
+ which is the name of the variable in which to store that property. Most of
+ the time though, only ``<name>`` is given, in which case the call will then
+ set the same variables as a call to
+ :command:`FetchContent_Populate(name) <FetchContent_Populate>`. This allows
+ the following canonical pattern to be used, which ensures that the relevant
+ variables will always be defined regardless of whether or not the population
+ has been performed elsewhere in the project already:
+
+ .. code-block:: cmake
+
+ FetchContent_GetProperties(foobar)
+ if(NOT foobar_POPULATED)
+ FetchContent_Populate(foobar)
+ ...
+ endif()
+
+ The above pattern allows other parts of the overall project hierarchy to
+ re-use the same content and ensure that it is only populated once.
+
+
+.. command:: FetchContent_MakeAvailable
+
+ .. code-block:: cmake
+
+ FetchContent_MakeAvailable( <name1> [<name2>...] )
+
+ This command implements the common pattern typically needed for most
+ dependencies. It iterates over each of the named dependencies in turn
+ and for each one it loosely follows the same
+ :ref:`canonical pattern <fetch-content-canonical-pattern>` as
+ presented at the beginning of this section. One small difference to
+ that pattern is that it will only call :command:`add_subdirectory` on the
+ populated content if there is a ``CMakeLists.txt`` file in its top level
+ source directory. This allows the command to be used for dependencies
+ that make downloaded content available at a known location but which do
+ not need or support being added directly to the build.
+
+
+.. _`fetch-content-examples`:
+
+Examples
+^^^^^^^^
+
+This first fairly straightforward example ensures that some popular testing
+frameworks are available to the main build:
+
+.. code-block:: cmake
+
+ include(FetchContent)
+ FetchContent_Declare(
+ googletest
+ GIT_REPOSITORY https://github.com/google/googletest.git
+ GIT_TAG release-1.8.0
+ )
+ FetchContent_Declare(
+ Catch2
+ GIT_REPOSITORY https://github.com/catchorg/Catch2.git
+ GIT_TAG v2.5.0
+ )
+
+ # After the following call, the CMake targets defined by googletest and
+ # Catch2 will be defined and available to the rest of the build
+ FetchContent_MakeAvailable(googletest Catch2)
+
+
+In more complex project hierarchies, the dependency relationships can be more
+complicated. Consider a hierarchy where ``projA`` is the top level project and
+it depends directly on projects ``projB`` and ``projC``. Both ``projB`` and
+``projC`` can be built standalone and they also both depend on another project
+``projD``. ``projB`` additionally depends on ``projE``. This example assumes
+that all five projects are available on a company git server. The
+``CMakeLists.txt`` of each project might have sections like the following:
+
+*projA*:
+
+.. code-block:: cmake
+
+ include(FetchContent)
+ FetchContent_Declare(
+ projB
+ GIT_REPOSITORY git@mycompany.com:git/projB.git
+ GIT_TAG 4a89dc7e24ff212a7b5167bef7ab079d
+ )
+ FetchContent_Declare(
+ projC
+ GIT_REPOSITORY git@mycompany.com:git/projC.git
+ GIT_TAG 4ad4016bd1d8d5412d135cf8ceea1bb9
+ )
+ FetchContent_Declare(
+ projD
+ GIT_REPOSITORY git@mycompany.com:git/projD.git
+ GIT_TAG origin/integrationBranch
+ )
+ FetchContent_Declare(
+ projE
+ GIT_REPOSITORY git@mycompany.com:git/projE.git
+ GIT_TAG origin/release/2.3-rc1
+ )
+
+ # Order is important, see notes in the discussion further below
+ FetchContent_MakeAvailable(projD projB projC)
+
+*projB*:
+
+.. code-block:: cmake
+
+ include(FetchContent)
+ FetchContent_Declare(
+ projD
+ GIT_REPOSITORY git@mycompany.com:git/projD.git
+ GIT_TAG 20b415f9034bbd2a2e8216e9a5c9e632
+ )
+ FetchContent_Declare(
+ projE
+ GIT_REPOSITORY git@mycompany.com:git/projE.git
+ GIT_TAG 68e20f674a48be38d60e129f600faf7d
+ )
+
+ FetchContent_MakeAvailable(projD projE)
+
+*projC*:
+
+.. code-block:: cmake
+
+ include(FetchContent)
+ FetchContent_Declare(
+ projD
+ GIT_REPOSITORY git@mycompany.com:git/projD.git
+ GIT_TAG 7d9a17ad2c962aa13e2fbb8043fb6b8a
+ )
+
+ # This particular version of projD requires workarounds
+ FetchContent_GetProperties(projD)
+ if(NOT projd_POPULATED)
+ FetchContent_Populate(projD)
+
+ # Copy an additional/replacement file into the populated source
+ file(COPY someFile.c DESTINATION ${projd_SOURCE_DIR}/src)
+
+ add_subdirectory(${projd_SOURCE_DIR} ${projd_BINARY_DIR})
+ endif()
+
+A few key points should be noted in the above:
+
+- ``projB`` and ``projC`` define different content details for ``projD``,
+ but ``projA`` also defines a set of content details for ``projD``.
+ Because ``projA`` will define them first, the details from ``projB`` and
+ ``projC`` will not be used. The override details defined by ``projA``
+ are not required to match either of those from ``projB`` or ``projC``, but
+ it is up to the higher level project to ensure that the details it does
+ define still make sense for the child projects.
+- In the ``projA`` call to :command:`FetchContent_MakeAvailable`, ``projD``
+ is listed ahead of ``projB`` and ``projC`` to ensure that ``projA`` is in
+ control of how ``projD`` is populated.
+- While ``projA`` defines content details for ``projE``, it does not need
+ to explicitly call ``FetchContent_MakeAvailable(projE)`` or
+ ``FetchContent_Populate(projD)`` itself. Instead, it leaves that to the
+ child ``projB``. For higher level projects, it is often enough to just
+ define the override content details and leave the actual population to the
+ child projects. This saves repeating the same thing at each level of the
+ project hierarchy unnecessarily.
+
+
+Projects don't always need to add the populated content to the build.
+Sometimes the project just wants to make the downloaded content available at
+a predictable location. The next example ensures that a set of standard
+company toolchain files (and potentially even the toolchain binaries
+themselves) is available early enough to be used for that same build.
+
+.. code-block:: cmake
+
+ cmake_minimum_required(VERSION 3.14)
+
+ include(FetchContent)
+ FetchContent_Declare(
+ mycom_toolchains
+ URL https://intranet.mycompany.com//toolchains_1.3.2.tar.gz
+ )
+ FetchContent_MakeAvailable(mycom_toolchains)
+
+ project(CrossCompileExample)
+
+The project could be configured to use one of the downloaded toolchains like
+so:
+
+.. code-block:: shell
+
+ cmake -DCMAKE_TOOLCHAIN_FILE=_deps/mycom_toolchains-src/toolchain_arm.cmake /path/to/src
+
+When CMake processes the ``CMakeLists.txt`` file, it will download and unpack
+the tarball into ``_deps/mycompany_toolchains-src`` relative to the build
+directory. The :variable:`CMAKE_TOOLCHAIN_FILE` variable is not used until
+the :command:`project` command is reached, at which point CMake looks for the
+named toolchain file relative to the build directory. Because the tarball has
+already been downloaded and unpacked by then, the toolchain file will be in
+place, even the very first time that ``cmake`` is run in the build directory.
+
+Lastly, the following example demonstrates how one might download and unpack a
+firmware tarball using CMake's :manual:`script mode <cmake(1)>`. The call to
+:command:`FetchContent_Populate` specifies all the content details and the
+unpacked firmware will be placed in a ``firmware`` directory below the
+current working directory.
+
+*getFirmware.cmake*:
+
+.. code-block:: cmake
+
+ # NOTE: Intended to be run in script mode with cmake -P
+ include(FetchContent)
+ FetchContent_Populate(
+ firmware
+ URL https://mycompany.com/assets/firmware-1.23-arm.tar.gz
+ URL_HASH MD5=68247684da89b608d466253762b0ff11
+ SOURCE_DIR firmware
+ )
+
+#]=======================================================================]
+
+
+set(__FetchContent_privateDir "${CMAKE_CURRENT_LIST_DIR}/FetchContent")
+
+#=======================================================================
+# Recording and retrieving content details for later population
+#=======================================================================
+
+# Internal use, projects must not call this directly. It is
+# intended for use by FetchContent_Declare() only.
+#
+# Sets a content-specific global property (not meant for use
+# outside of functions defined here in this file) which can later
+# be retrieved using __FetchContent_getSavedDetails() with just the
+# same content name. If there is already a value stored in the
+# property, it is left unchanged and this call has no effect.
+# This allows parent projects to define the content details,
+# overriding anything a child project may try to set (properties
+# are not cached between runs, so the first thing to set it in a
+# build will be in control).
+function(__FetchContent_declareDetails contentName)
+
+ string(TOLOWER ${contentName} contentNameLower)
+ set(propertyName "_FetchContent_${contentNameLower}_savedDetails")
+ get_property(alreadyDefined GLOBAL PROPERTY ${propertyName} DEFINED)
+ if(NOT alreadyDefined)
+ define_property(GLOBAL PROPERTY ${propertyName}
+ BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
+ FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
+ )
+ set_property(GLOBAL PROPERTY ${propertyName} ${ARGN})
+ endif()
+
+endfunction()
+
+
+# Internal use, projects must not call this directly. It is
+# intended for use by the FetchContent_Declare() function.
+#
+# Retrieves details saved for the specified content in an
+# earlier call to __FetchContent_declareDetails().
+function(__FetchContent_getSavedDetails contentName outVar)
+
+ string(TOLOWER ${contentName} contentNameLower)
+ set(propertyName "_FetchContent_${contentNameLower}_savedDetails")
+ get_property(alreadyDefined GLOBAL PROPERTY ${propertyName} DEFINED)
+ if(NOT alreadyDefined)
+ message(FATAL_ERROR "No content details recorded for ${contentName}")
+ endif()
+ get_property(propertyValue GLOBAL PROPERTY ${propertyName})
+ set(${outVar} "${propertyValue}" PARENT_SCOPE)
+
+endfunction()
+
+
+# Saves population details of the content, sets defaults for the
+# SOURCE_DIR and BUILD_DIR.
+function(FetchContent_Declare contentName)
+
+ set(options "")
+ set(oneValueArgs SVN_REPOSITORY)
+ set(multiValueArgs "")
+
+ cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ unset(srcDirSuffix)
+ unset(svnRepoArgs)
+ if(ARG_SVN_REPOSITORY)
+ # Add a hash of the svn repository URL to the source dir. This works
+ # around the problem where if the URL changes, the download would
+ # fail because it tries to checkout/update rather than switch the
+ # old URL to the new one. We limit the hash to the first 7 characters
+ # so that the source path doesn't get overly long (which can be a
+ # problem on windows due to path length limits).
+ string(SHA1 urlSHA ${ARG_SVN_REPOSITORY})
+ string(SUBSTRING ${urlSHA} 0 7 urlSHA)
+ set(srcDirSuffix "-${urlSHA}")
+ set(svnRepoArgs SVN_REPOSITORY ${ARG_SVN_REPOSITORY})
+ endif()
+
+ string(TOLOWER ${contentName} contentNameLower)
+ __FetchContent_declareDetails(
+ ${contentNameLower}
+ SOURCE_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src${srcDirSuffix}"
+ BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build"
+ ${svnRepoArgs}
+ # List these last so they can override things we set above
+ ${ARG_UNPARSED_ARGUMENTS}
+ )
+
+endfunction()
+
+
+#=======================================================================
+# Set/get whether the specified content has been populated yet.
+# The setter also records the source and binary dirs used.
+#=======================================================================
+
+# Internal use, projects must not call this directly. It is
+# intended for use by the FetchContent_Populate() function to
+# record when FetchContent_Populate() is called for a particular
+# content name.
+function(__FetchContent_setPopulated contentName sourceDir binaryDir)
+
+ string(TOLOWER ${contentName} contentNameLower)
+ set(prefix "_FetchContent_${contentNameLower}")
+
+ set(propertyName "${prefix}_sourceDir")
+ define_property(GLOBAL PROPERTY ${propertyName}
+ BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
+ FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
+ )
+ set_property(GLOBAL PROPERTY ${propertyName} ${sourceDir})
+
+ set(propertyName "${prefix}_binaryDir")
+ define_property(GLOBAL PROPERTY ${propertyName}
+ BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
+ FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
+ )
+ set_property(GLOBAL PROPERTY ${propertyName} ${binaryDir})
+
+ set(propertyName "${prefix}_populated")
+ define_property(GLOBAL PROPERTY ${propertyName}
+ BRIEF_DOCS "Internal implementation detail of FetchContent_Populate()"
+ FULL_DOCS "Details used by FetchContent_Populate() for ${contentName}"
+ )
+ set_property(GLOBAL PROPERTY ${propertyName} True)
+
+endfunction()
+
+
+# Set variables in the calling scope for any of the retrievable
+# properties. If no specific properties are requested, variables
+# will be set for all retrievable properties.
+#
+# This function is intended to also be used by projects as the canonical
+# way to detect whether they should call FetchContent_Populate()
+# and pull the populated source into the build with add_subdirectory(),
+# if they are using the populated content in that way.
+function(FetchContent_GetProperties contentName)
+
+ string(TOLOWER ${contentName} contentNameLower)
+
+ set(options "")
+ set(oneValueArgs SOURCE_DIR BINARY_DIR POPULATED)
+ set(multiValueArgs "")
+
+ cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if(NOT ARG_SOURCE_DIR AND
+ NOT ARG_BINARY_DIR AND
+ NOT ARG_POPULATED)
+ # No specific properties requested, provide them all
+ set(ARG_SOURCE_DIR ${contentNameLower}_SOURCE_DIR)
+ set(ARG_BINARY_DIR ${contentNameLower}_BINARY_DIR)
+ set(ARG_POPULATED ${contentNameLower}_POPULATED)
+ endif()
+
+ set(prefix "_FetchContent_${contentNameLower}")
+
+ if(ARG_SOURCE_DIR)
+ set(propertyName "${prefix}_sourceDir")
+ get_property(value GLOBAL PROPERTY ${propertyName})
+ if(value)
+ set(${ARG_SOURCE_DIR} ${value} PARENT_SCOPE)
+ endif()
+ endif()
+
+ if(ARG_BINARY_DIR)
+ set(propertyName "${prefix}_binaryDir")
+ get_property(value GLOBAL PROPERTY ${propertyName})
+ if(value)
+ set(${ARG_BINARY_DIR} ${value} PARENT_SCOPE)
+ endif()
+ endif()
+
+ if(ARG_POPULATED)
+ set(propertyName "${prefix}_populated")
+ get_property(value GLOBAL PROPERTY ${propertyName} DEFINED)
+ set(${ARG_POPULATED} ${value} PARENT_SCOPE)
+ endif()
+
+endfunction()
+
+
+#=======================================================================
+# Performing the population
+#=======================================================================
+
+# The value of contentName will always have been lowercased by the caller.
+# All other arguments are assumed to be options that are understood by
+# ExternalProject_Add(), except for QUIET and SUBBUILD_DIR.
+function(__FetchContent_directPopulate contentName)
+
+ set(options
+ QUIET
+ )
+ set(oneValueArgs
+ SUBBUILD_DIR
+ SOURCE_DIR
+ BINARY_DIR
+ # Prevent the following from being passed through
+ CONFIGURE_COMMAND
+ BUILD_COMMAND
+ INSTALL_COMMAND
+ TEST_COMMAND
+ # We force both of these to be ON since we are always executing serially
+ # and we want all steps to have access to the terminal in case they
+ # need input from the command line (e.g. ask for a private key password)
+ # or they want to provide timely progress. We silently absorb and
+ # discard these if they are set by the caller.
+ USES_TERMINAL_DOWNLOAD
+ USES_TERMINAL_UPDATE
+ )
+ set(multiValueArgs "")
+
+ cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if(NOT ARG_SUBBUILD_DIR)
+ message(FATAL_ERROR "Internal error: SUBBUILD_DIR not set")
+ elseif(NOT IS_ABSOLUTE "${ARG_SUBBUILD_DIR}")
+ set(ARG_SUBBUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_SUBBUILD_DIR}")
+ endif()
+
+ if(NOT ARG_SOURCE_DIR)
+ message(FATAL_ERROR "Internal error: SOURCE_DIR not set")
+ elseif(NOT IS_ABSOLUTE "${ARG_SOURCE_DIR}")
+ set(ARG_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_SOURCE_DIR}")
+ endif()
+
+ if(NOT ARG_BINARY_DIR)
+ message(FATAL_ERROR "Internal error: BINARY_DIR not set")
+ elseif(NOT IS_ABSOLUTE "${ARG_BINARY_DIR}")
+ set(ARG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ARG_BINARY_DIR}")
+ endif()
+
+ # Ensure the caller can know where to find the source and build directories
+ # with some convenient variables. Doing this here ensures the caller sees
+ # the correct result in the case where the default values are overridden by
+ # the content details set by the project.
+ set(${contentName}_SOURCE_DIR "${ARG_SOURCE_DIR}" PARENT_SCOPE)
+ set(${contentName}_BINARY_DIR "${ARG_BINARY_DIR}" PARENT_SCOPE)
+
+ # The unparsed arguments may contain spaces, so build up ARG_EXTRA
+ # in such a way that it correctly substitutes into the generated
+ # CMakeLists.txt file with each argument quoted.
+ unset(ARG_EXTRA)
+ foreach(arg IN LISTS ARG_UNPARSED_ARGUMENTS)
+ set(ARG_EXTRA "${ARG_EXTRA} \"${arg}\"")
+ endforeach()
+
+ # Hide output if requested, but save it to a variable in case there's an
+ # error so we can show the output upon failure. When not quiet, don't
+ # capture the output to a variable because the user may want to see the
+ # output as it happens (e.g. progress during long downloads). Combine both
+ # stdout and stderr in the one capture variable so the output stays in order.
+ if (ARG_QUIET)
+ set(outputOptions
+ OUTPUT_VARIABLE capturedOutput
+ ERROR_VARIABLE capturedOutput
+ )
+ else()
+ set(capturedOutput)
+ set(outputOptions)
+ message(STATUS "Populating ${contentName}")
+ endif()
+
+ if(CMAKE_GENERATOR)
+ set(generatorOpts "-G${CMAKE_GENERATOR}")
+ if(CMAKE_GENERATOR_PLATFORM)
+ list(APPEND generatorOpts "-A${CMAKE_GENERATOR_PLATFORM}")
+ endif()
+ if(CMAKE_GENERATOR_TOOLSET)
+ list(APPEND generatorOpts "-T${CMAKE_GENERATOR_TOOLSET}")
+ endif()
+
+ if(CMAKE_MAKE_PROGRAM)
+ list(APPEND generatorOpts "-DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_MAKE_PROGRAM}")
+ endif()
+
+ else()
+ # Likely we've been invoked via CMake's script mode where no
+ # generator is set (and hence CMAKE_MAKE_PROGRAM could not be
+ # trusted even if provided). We will have to rely on being
+ # able to find the default generator and build tool.
+ unset(generatorOpts)
+ endif()
+
+ # Create and build a separate CMake project to carry out the population.
+ # If we've already previously done these steps, they will not cause
+ # anything to be updated, so extra rebuilds of the project won't occur.
+ # Make sure to pass through CMAKE_MAKE_PROGRAM in case the main project
+ # has this set to something not findable on the PATH.
+ configure_file("${__FetchContent_privateDir}/CMakeLists.cmake.in"
+ "${ARG_SUBBUILD_DIR}/CMakeLists.txt")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} ${generatorOpts} .
+ RESULT_VARIABLE result
+ ${outputOptions}
+ WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}"
+ )
+ if(result)
+ if(capturedOutput)
+ message("${capturedOutput}")
+ endif()
+ message(FATAL_ERROR "CMake step for ${contentName} failed: ${result}")
+ endif()
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} --build .
+ RESULT_VARIABLE result
+ ${outputOptions}
+ WORKING_DIRECTORY "${ARG_SUBBUILD_DIR}"
+ )
+ if(result)
+ if(capturedOutput)
+ message("${capturedOutput}")
+ endif()
+ message(FATAL_ERROR "Build step for ${contentName} failed: ${result}")
+ endif()
+
+endfunction()
+
+
+option(FETCHCONTENT_FULLY_DISCONNECTED "Disables all attempts to download or update content and assumes source dirs already exist")
+option(FETCHCONTENT_UPDATES_DISCONNECTED "Enables UPDATE_DISCONNECTED behavior for all content population")
+option(FETCHCONTENT_QUIET "Enables QUIET option for all content population" ON)
+set(FETCHCONTENT_BASE_DIR "${CMAKE_BINARY_DIR}/_deps" CACHE PATH "Directory under which to collect all populated content")
+
+# Populate the specified content using details stored from
+# an earlier call to FetchContent_Declare().
+function(FetchContent_Populate contentName)
+
+ if(NOT contentName)
+ message(FATAL_ERROR "Empty contentName not allowed for FetchContent_Populate()")
+ endif()
+
+ string(TOLOWER ${contentName} contentNameLower)
+
+ if(ARGN)
+ # This is the direct population form with details fully specified
+ # as part of the call, so we already have everything we need
+ __FetchContent_directPopulate(
+ ${contentNameLower}
+ SUBBUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${contentNameLower}-subbuild"
+ SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/${contentNameLower}-src"
+ BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${contentNameLower}-build"
+ ${ARGN} # Could override any of the above ..._DIR variables
+ )
+
+ # Pass source and binary dir variables back to the caller
+ set(${contentNameLower}_SOURCE_DIR "${${contentNameLower}_SOURCE_DIR}" PARENT_SCOPE)
+ set(${contentNameLower}_BINARY_DIR "${${contentNameLower}_BINARY_DIR}" PARENT_SCOPE)
+
+ # Don't set global properties, or record that we did this population, since
+ # this was a direct call outside of the normal declared details form.
+ # We only want to save values in the global properties for content that
+ # honours the hierarchical details mechanism so that projects are not
+ # robbed of the ability to override details set in nested projects.
+ return()
+ endif()
+
+ # No details provided, so assume they were saved from an earlier call
+ # to FetchContent_Declare(). Do a check that we haven't already
+ # populated this content before in case the caller forgot to check.
+ FetchContent_GetProperties(${contentName})
+ if(${contentNameLower}_POPULATED)
+ message(FATAL_ERROR "Content ${contentName} already populated in ${${contentNameLower}_SOURCE_DIR}")
+ endif()
+
+ string(TOUPPER ${contentName} contentNameUpper)
+ set(FETCHCONTENT_SOURCE_DIR_${contentNameUpper}
+ "${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}"
+ CACHE PATH "When not empty, overrides where to find pre-populated content for ${contentName}")
+
+ if(FETCHCONTENT_SOURCE_DIR_${contentNameUpper})
+ # The source directory has been explicitly provided in the cache,
+ # so no population is required
+ set(${contentNameLower}_SOURCE_DIR "${FETCHCONTENT_SOURCE_DIR_${contentNameUpper}}")
+ set(${contentNameLower}_BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build")
+
+ elseif(FETCHCONTENT_FULLY_DISCONNECTED)
+ # Bypass population and assume source is already there from a previous run
+ set(${contentNameLower}_SOURCE_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src")
+ set(${contentNameLower}_BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build")
+
+ else()
+ # Support both a global "disconnect all updates" and a per-content
+ # update test (either one being set disables updates for this content).
+ option(FETCHCONTENT_UPDATES_DISCONNECTED_${contentNameUpper}
+ "Enables UPDATE_DISCONNECTED behavior just for population of ${contentName}")
+ if(FETCHCONTENT_UPDATES_DISCONNECTED OR
+ FETCHCONTENT_UPDATES_DISCONNECTED_${contentNameUpper})
+ set(disconnectUpdates True)
+ else()
+ set(disconnectUpdates False)
+ endif()
+
+ if(FETCHCONTENT_QUIET)
+ set(quietFlag QUIET)
+ else()
+ unset(quietFlag)
+ endif()
+
+ __FetchContent_getSavedDetails(${contentName} contentDetails)
+ if("${contentDetails}" STREQUAL "")
+ message(FATAL_ERROR "No details have been set for content: ${contentName}")
+ endif()
+
+ __FetchContent_directPopulate(
+ ${contentNameLower}
+ ${quietFlag}
+ UPDATE_DISCONNECTED ${disconnectUpdates}
+ SUBBUILD_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-subbuild"
+ SOURCE_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src"
+ BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build"
+ # Put the saved details last so they can override any of the
+ # the options we set above (this can include SOURCE_DIR or
+ # BUILD_DIR)
+ ${contentDetails}
+ )
+ endif()
+
+ __FetchContent_setPopulated(
+ ${contentName}
+ ${${contentNameLower}_SOURCE_DIR}
+ ${${contentNameLower}_BINARY_DIR}
+ )
+
+ # Pass variables back to the caller. The variables passed back here
+ # must match what FetchContent_GetProperties() sets when it is called
+ # with just the content name.
+ set(${contentNameLower}_SOURCE_DIR "${${contentNameLower}_SOURCE_DIR}" PARENT_SCOPE)
+ set(${contentNameLower}_BINARY_DIR "${${contentNameLower}_BINARY_DIR}" PARENT_SCOPE)
+ set(${contentNameLower}_POPULATED True PARENT_SCOPE)
+
+endfunction()
+
+# Arguments are assumed to be the names of dependencies that have been
+# declared previously and should be populated. It is not an error if
+# any of them have already been populated (they will just be skipped in
+# that case). The command is implemented as a macro so that the variables
+# defined by the FetchContent_GetProperties() and FetchContent_Populate()
+# calls will be available to the caller.
+macro(FetchContent_MakeAvailable)
+
+ foreach(contentName IN ITEMS ${ARGV})
+ string(TOLOWER ${contentName} contentNameLower)
+ FetchContent_GetProperties(${contentName})
+ if(NOT ${contentNameLower}_POPULATED)
+ FetchContent_Populate(${contentName})
+
+ # Only try to call add_subdirectory() if the populated content
+ # can be treated that way. Protecting the call with the check
+ # allows this function to be used for projects that just want
+ # to ensure the content exists, such as to provide content at
+ # a known location.
+ if(EXISTS ${${contentNameLower}_SOURCE_DIR}/CMakeLists.txt)
+ add_subdirectory(${${contentNameLower}_SOURCE_DIR}
+ ${${contentNameLower}_BINARY_DIR})
+ endif()
+ endif()
+ endforeach()
+
+endmacro()
diff --git a/Modules/FetchContent/CMakeLists.cmake.in b/Modules/FetchContent/CMakeLists.cmake.in
new file mode 100644
index 000000000..0095b111b
--- /dev/null
+++ b/Modules/FetchContent/CMakeLists.cmake.in
@@ -0,0 +1,23 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION ${CMAKE_VERSION})
+
+# We name the project and the target for the ExternalProject_Add() call
+# to something that will highlight to the user what we are working on if
+# something goes wrong and an error message is produced.
+
+project(${contentName}-populate NONE)
+
+include(ExternalProject)
+ExternalProject_Add(${contentName}-populate
+ ${ARG_EXTRA}
+ SOURCE_DIR "${ARG_SOURCE_DIR}"
+ BINARY_DIR "${ARG_BINARY_DIR}"
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ""
+ TEST_COMMAND ""
+ USES_TERMINAL_DOWNLOAD YES
+ USES_TERMINAL_UPDATE YES
+)
diff --git a/Modules/FindALSA.cmake b/Modules/FindALSA.cmake
index fa9a43438..88e2681eb 100644
--- a/Modules/FindALSA.cmake
+++ b/Modules/FindALSA.cmake
@@ -1,28 +1,45 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindALSA
-# --------
-#
-# Find alsa
-#
-# Find the alsa libraries (asound)
-#
-# ::
-#
-# This module defines the following variables:
-# ALSA_FOUND - True if ALSA_INCLUDE_DIR & ALSA_LIBRARY are found
-# ALSA_LIBRARIES - Set when ALSA_LIBRARY is found
-# ALSA_INCLUDE_DIRS - Set when ALSA_INCLUDE_DIR is found
-#
-#
-#
-# ::
-#
-# ALSA_INCLUDE_DIR - where to find asoundlib.h, etc.
-# ALSA_LIBRARY - the asound library
-# ALSA_VERSION_STRING - the version of alsa found (since CMake 2.8.8)
+#[=======================================================================[.rst:
+FindALSA
+--------
+
+Find Advanced Linux Sound Architecture (ALSA)
+
+Find the alsa libraries (``asound``)
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``ALSA::ALSA``, if
+ALSA has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+``ALSA_FOUND``
+ True if ALSA_INCLUDE_DIR & ALSA_LIBRARY are found
+
+``ALSA_LIBRARIES``
+ List of libraries when using ALSA.
+
+``ALSA_INCLUDE_DIRS``
+ Where to find the ALSA headers.
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``ALSA_INCLUDE_DIR``
+ the ALSA include directory
+
+``ALSA_LIBRARY``
+ the absolute path of the asound library
+#]=======================================================================]
find_path(ALSA_INCLUDE_DIR NAMES alsa/asoundlib.h
DOC "The ALSA (asound) include directory"
@@ -47,6 +64,11 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALSA
if(ALSA_FOUND)
set( ALSA_LIBRARIES ${ALSA_LIBRARY} )
set( ALSA_INCLUDE_DIRS ${ALSA_INCLUDE_DIR} )
+ if(NOT TARGET ALSA::ALSA)
+ add_library(ALSA::ALSA UNKNOWN IMPORTED)
+ set_target_properties(ALSA::ALSA PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ALSA_INCLUDE_DIRS}")
+ set_property(TARGET ALSA::ALSA APPEND PROPERTY IMPORTED_LOCATION "${ALSA_LIBRARY}")
+ endif()
endif()
mark_as_advanced(ALSA_INCLUDE_DIR ALSA_LIBRARY)
diff --git a/Modules/FindASPELL.cmake b/Modules/FindASPELL.cmake
index 6944ac192..c2d29e295 100644
--- a/Modules/FindASPELL.cmake
+++ b/Modules/FindASPELL.cmake
@@ -1,21 +1,22 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindASPELL
-# ----------
-#
-# Try to find ASPELL
-#
-# Once done this will define
-#
-# ::
-#
-# ASPELL_FOUND - system has ASPELL
-# ASPELL_EXECUTABLE - the ASPELL executable
-# ASPELL_INCLUDE_DIR - the ASPELL include directory
-# ASPELL_LIBRARIES - The libraries needed to use ASPELL
-# ASPELL_DEFINITIONS - Compiler switches required for using ASPELL
+#[=======================================================================[.rst:
+FindASPELL
+----------
+
+Try to find ASPELL
+
+Once done this will define
+
+::
+
+ ASPELL_FOUND - system has ASPELL
+ ASPELL_EXECUTABLE - the ASPELL executable
+ ASPELL_INCLUDE_DIR - the ASPELL include directory
+ ASPELL_LIBRARIES - The libraries needed to use ASPELL
+ ASPELL_DEFINITIONS - Compiler switches required for using ASPELL
+#]=======================================================================]
find_path(ASPELL_INCLUDE_DIR aspell.h )
diff --git a/Modules/FindAVIFile.cmake b/Modules/FindAVIFile.cmake
index 88a2a25b0..96554405d 100644
--- a/Modules/FindAVIFile.cmake
+++ b/Modules/FindAVIFile.cmake
@@ -1,34 +1,29 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindAVIFile
-# -----------
-#
-# Locate AVIFILE library and include paths
-#
-# AVIFILE (http://avifile.sourceforge.net/)is a set of libraries for
-# i386 machines to use various AVI codecs. Support is limited beyond
-# Linux. Windows provides native AVI support, and so doesn't need this
-# library. This module defines
-#
-# ::
-#
-# AVIFILE_INCLUDE_DIR, where to find avifile.h , etc.
-# AVIFILE_LIBRARIES, the libraries to link against
-# AVIFILE_DEFINITIONS, definitions to use when compiling
-# AVIFILE_FOUND, If false, don't try to use AVIFILE
+#[=======================================================================[.rst:
+FindAVIFile
+-----------
-if (UNIX)
+Locate AVIFILE library and include paths
+
+AVIFILE (http://avifile.sourceforge.net/) is a set of libraries for
+i386 machines to use various AVI codecs. Support is limited beyond
+Linux. Windows provides native AVI support, and so doesn't need this
+library. This module defines
+
+::
- find_path(AVIFILE_INCLUDE_DIR avifile.h
- /usr/local/avifile/include
- /usr/local/include/avifile
- )
+ AVIFILE_INCLUDE_DIR, where to find avifile.h , etc.
+ AVIFILE_LIBRARIES, the libraries to link against
+ AVIFILE_DEFINITIONS, definitions to use when compiling
+ AVIFILE_FOUND, If false, don't try to use AVIFILE
+#]=======================================================================]
+
+if (UNIX)
- find_library(AVIFILE_AVIPLAY_LIBRARY aviplay
- /usr/local/avifile/lib
- )
+ find_path(AVIFILE_INCLUDE_DIR avifile.h PATH_SUFFIXES avifile/include include/avifile include/avifile-0.7)
+ find_library(AVIFILE_AVIPLAY_LIBRARY aviplay aviplay-0.7 PATH_SUFFIXES avifile/lib)
endif ()
diff --git a/Modules/FindArmadillo.cmake b/Modules/FindArmadillo.cmake
index 95f0c5629..c4e55ce57 100644
--- a/Modules/FindArmadillo.cmake
+++ b/Modules/FindArmadillo.cmake
@@ -1,35 +1,35 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindArmadillo
-# -------------
-#
-# Find Armadillo
-#
-# Find the Armadillo C++ library
-#
-# Using Armadillo:
-#
-# ::
-#
-# find_package(Armadillo REQUIRED)
-# include_directories(${ARMADILLO_INCLUDE_DIRS})
-# add_executable(foo foo.cc)
-# target_link_libraries(foo ${ARMADILLO_LIBRARIES})
-#
-# This module sets the following variables:
-#
-# ::
-#
-# ARMADILLO_FOUND - set to true if the library is found
-# ARMADILLO_INCLUDE_DIRS - list of required include directories
-# ARMADILLO_LIBRARIES - list of libraries to be linked
-# ARMADILLO_VERSION_MAJOR - major version number
-# ARMADILLO_VERSION_MINOR - minor version number
-# ARMADILLO_VERSION_PATCH - patch version number
-# ARMADILLO_VERSION_STRING - version number as a string (ex: "1.0.4")
-# ARMADILLO_VERSION_NAME - name of the version (ex: "Antipodean Antileech")
+#[=======================================================================[.rst:
+FindArmadillo
+-------------
+
+Find the Armadillo C++ library.
+Armadillo is library for linear algebra & scientific computing.
+
+Using Armadillo:
+
+::
+
+ find_package(Armadillo REQUIRED)
+ include_directories(${ARMADILLO_INCLUDE_DIRS})
+ add_executable(foo foo.cc)
+ target_link_libraries(foo ${ARMADILLO_LIBRARIES})
+
+This module sets the following variables:
+
+::
+
+ ARMADILLO_FOUND - set to true if the library is found
+ ARMADILLO_INCLUDE_DIRS - list of required include directories
+ ARMADILLO_LIBRARIES - list of libraries to be linked
+ ARMADILLO_VERSION_MAJOR - major version number
+ ARMADILLO_VERSION_MINOR - minor version number
+ ARMADILLO_VERSION_PATCH - patch version number
+ ARMADILLO_VERSION_STRING - version number as a string (ex: "1.0.4")
+ ARMADILLO_VERSION_NAME - name of the version (ex: "Antipodean Antileech")
+#]=======================================================================]
# UNIX paths are standard, no need to write.
find_library(ARMADILLO_LIBRARY
diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake
index d684ccd86..6b5828eef 100644
--- a/Modules/FindBISON.cmake
+++ b/Modules/FindBISON.cmake
@@ -1,85 +1,86 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindBISON
-# ---------
-#
-# Find ``bison`` executable and provide a macro to generate custom build rules.
-#
-# The module defines the following variables:
-#
-# ``BISON_EXECUTABLE``
-# path to the ``bison`` program
-#
-# ``BISON_VERSION``
-# version of ``bison``
-#
-# ``BISON_FOUND``
-# true if the program was found
-#
-# The minimum required version of ``bison`` can be specified using the
-# standard CMake syntax, e.g. ``find_package(BISON 2.1.3)``.
-#
-# If ``bison`` is found, the module defines the macro::
-#
-# BISON_TARGET(<Name> <YaccInput> <CodeOutput>
-# [COMPILE_FLAGS <flags>]
-# [DEFINES_FILE <file>]
-# [VERBOSE [<file>]]
-# [REPORT_FILE <file>]
-# )
-#
-# which will create a custom rule to generate a parser. ``<YaccInput>`` is
-# the path to a yacc file. ``<CodeOutput>`` is the name of the source file
-# generated by bison. A header file is also be generated, and contains
-# the token list.
-#
-# The options are:
-#
-# ``COMPILE_FLAGS <flags>``
-# Specify flags to be added to the ``bison`` command line.
-#
-# ``DEFINES_FILE <file>``
-# Specify a non-default header ``<file>`` to be generated by ``bison``.
-#
-# ``VERBOSE [<file>]``
-# Tell ``bison`` to write a report file of the grammar and parser.
-# If ``<file>`` is given, it specifies path the report file is copied to.
-# ``[<file>]`` is left for backward compatibility of this module.
-# Use ``VERBOSE REPORT_FILE <file>``.
-#
-# ``REPORT_FILE <file>``
-# Specify a non-default report ``<file>``, if generated.
-#
-# The macro defines the following variables:
-#
-# ``BISON_<Name>_DEFINED``
-# true is the macro ran successfully
-#
-# ``BISON_<Name>_INPUT``
-# The input source file, an alias for <YaccInput>
-#
-# ``BISON_<Name>_OUTPUT_SOURCE``
-# The source file generated by bison
-#
-# ``BISON_<Name>_OUTPUT_HEADER``
-# The header file generated by bison
-#
-# ``BISON_<Name>_OUTPUTS``
-# All files generated by bison including the source, the header and the report
-#
-# ``BISON_<Name>_COMPILE_FLAGS``
-# Options used in the ``bison`` command line
-#
-# Example usage:
-#
-# .. code-block:: cmake
-#
-# find_package(BISON)
-# BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp
-# DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/parser.h)
-# add_executable(Foo main.cpp ${BISON_MyParser_OUTPUTS})
+#[=======================================================================[.rst:
+FindBISON
+---------
+
+Find ``bison`` executable and provide a macro to generate custom build rules.
+
+The module defines the following variables:
+
+``BISON_EXECUTABLE``
+ path to the ``bison`` program
+
+``BISON_VERSION``
+ version of ``bison``
+
+``BISON_FOUND``
+ "True" if the program was found
+
+The minimum required version of ``bison`` can be specified using the
+standard CMake syntax, e.g. :command:`find_package(BISON 2.1.3)`.
+
+If ``bison`` is found, the module defines the macro::
+
+ BISON_TARGET(<Name> <YaccInput> <CodeOutput>
+ [COMPILE_FLAGS <flags>]
+ [DEFINES_FILE <file>]
+ [VERBOSE [<file>]]
+ [REPORT_FILE <file>]
+ )
+
+which will create a custom rule to generate a parser. ``<YaccInput>`` is
+the path to a yacc file. ``<CodeOutput>`` is the name of the source file
+generated by bison. A header file is also be generated, and contains
+the token list.
+
+The options are:
+
+``COMPILE_FLAGS <flags>``
+ Specify flags to be added to the ``bison`` command line.
+
+``DEFINES_FILE <file>``
+ Specify a non-default header ``<file>`` to be generated by ``bison``.
+
+``VERBOSE [<file>]``
+ Tell ``bison`` to write a report file of the grammar and parser.
+ If ``<file>`` is given, it specifies path the report file is copied to.
+ ``[<file>]`` is left for backward compatibility of this module.
+ Use ``VERBOSE REPORT_FILE <file>``.
+
+``REPORT_FILE <file>``
+ Specify a non-default report ``<file>``, if generated.
+
+The macro defines the following variables:
+
+``BISON_<Name>_DEFINED``
+ ``True`` is the macro ran successfully
+
+``BISON_<Name>_INPUT``
+ The input source file, an alias for <YaccInput>
+
+``BISON_<Name>_OUTPUT_SOURCE``
+ The source file generated by bison
+
+``BISON_<Name>_OUTPUT_HEADER``
+ The header file generated by bison
+
+``BISON_<Name>_OUTPUTS``
+ All files generated by bison including the source, the header and the report
+
+``BISON_<Name>_COMPILE_FLAGS``
+ Options used in the ``bison`` command line
+
+Example usage:
+
+.. code-block:: cmake
+
+ find_package(BISON)
+ BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp
+ DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/parser.h)
+ add_executable(Foo main.cpp ${BISON_MyParser_OUTPUTS})
+#]=======================================================================]
find_program(BISON_EXECUTABLE NAMES bison win_bison DOC "path to the bison executable")
mark_as_advanced(BISON_EXECUTABLE)
@@ -149,17 +150,43 @@ if(BISON_EXECUTABLE)
set(BISON_TARGET_verbose_file "${ReportFile}")
list(APPEND BISON_TARGET_cmdopt "--report-file=${BISON_TARGET_verbose_file}")
endif()
+ if(NOT IS_ABSOLUTE "${BISON_TARGET_verbose_file}")
+ cmake_policy(GET CMP0088 _BISON_CMP0088
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ if("x${_BISON_CMP0088}x" STREQUAL "xNEWx")
+ set(BISON_TARGET_verbose_file "${CMAKE_CURRENT_BINARY_DIR}/${BISON_TARGET_verbose_file}")
+ else()
+ set(BISON_TARGET_verbose_file "${CMAKE_CURRENT_SOURCE_DIR}/${BISON_TARGET_verbose_file}")
+ endif()
+ unset(_BISON_CMP0088)
+ endif()
endmacro()
# internal macro
# adds a custom command and sets
- # BISON_TARGET_cmdopt, BISON_TARGET_verbose_file, BISON_TARGET_extraoutputs
+ # BISON_TARGET_cmdopt, BISON_TARGET_extraoutputs
macro(BISON_TARGET_option_verbose Name BisonOutput filename)
+ cmake_policy(GET CMP0088 _BISON_CMP0088
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ set(_BISON_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+ if("x${_BISON_CMP0088}x" STREQUAL "xNEWx")
+ set(_BISON_WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ endif()
+ unset(_BISON_CMP0088)
+
list(APPEND BISON_TARGET_cmdopt "--verbose")
- list(APPEND BISON_TARGET_extraoutputs
+ list(APPEND BISON_TARGET_outputs
"${BISON_TARGET_verbose_file}")
if (NOT "${filename}" STREQUAL "")
- add_custom_command(OUTPUT ${filename}
+ if(IS_ABSOLUTE "${filename}")
+ set(BISON_TARGET_verbose_extra_file "${filename}")
+ else()
+ set(BISON_TARGET_verbose_extra_file "${_BISON_WORKING_DIRECTORY}/${filename}")
+ endif()
+
+ add_custom_command(OUTPUT ${BISON_TARGET_verbose_extra_file}
COMMAND ${CMAKE_COMMAND} -E copy
"${BISON_TARGET_verbose_file}"
"${filename}"
@@ -167,10 +194,11 @@ if(BISON_EXECUTABLE)
DEPENDS
"${BISON_TARGET_verbose_file}"
COMMENT "[BISON][${Name}] Copying bison verbose table to ${filename}"
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
- set(BISON_${Name}_VERBOSE_FILE ${filename})
+ WORKING_DIRECTORY ${_BISON_WORKING_DIRECTORY})
list(APPEND BISON_TARGET_extraoutputs
- "${filename}")
+ "${BISON_TARGET_verbose_extra_file}")
+ unset(BISON_TARGET_verbose_extra_file)
+ unset(_BISON_WORKING_DIRECTORY)
endif()
endmacro()
@@ -225,22 +253,38 @@ if(BISON_EXECUTABLE)
list(APPEND BISON_TARGET_outputs "${BISON_TARGET_output_header}")
+ cmake_policy(GET CMP0088 _BISON_CMP0088
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ set(_BISON_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+ set(_BisonInput "${BisonInput}")
+ if("x${_BISON_CMP0088}x" STREQUAL "xNEWx")
+ set(_BISON_WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ if(NOT IS_ABSOLUTE "${_BisonInput}")
+ set(_BisonInput "${CMAKE_CURRENT_SOURCE_DIR}/${_BisonInput}")
+ endif()
+ endif()
+ unset(_BISON_CMP0088)
+
add_custom_command(OUTPUT ${BISON_TARGET_outputs}
- ${BISON_TARGET_extraoutputs}
- COMMAND ${BISON_EXECUTABLE} ${BISON_TARGET_cmdopt} -o ${BisonOutput} ${BisonInput}
+ COMMAND ${BISON_EXECUTABLE} ${BISON_TARGET_cmdopt} -o ${BisonOutput} ${_BisonInput}
VERBATIM
- DEPENDS ${BisonInput}
+ DEPENDS ${_BisonInput}
COMMENT "[BISON][${Name}] Building parser with bison ${BISON_VERSION}"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+ WORKING_DIRECTORY ${_BISON_WORKING_DIRECTORY})
+
+ unset(_BISON_WORKING_DIRECTORY)
# define target variables
set(BISON_${Name}_DEFINED TRUE)
- set(BISON_${Name}_INPUT ${BisonInput})
+ set(BISON_${Name}_INPUT ${_BisonInput})
set(BISON_${Name}_OUTPUTS ${BISON_TARGET_outputs} ${BISON_TARGET_extraoutputs})
set(BISON_${Name}_COMPILE_FLAGS ${BISON_TARGET_cmdopt})
set(BISON_${Name}_OUTPUT_SOURCE "${BisonOutput}")
set(BISON_${Name}_OUTPUT_HEADER "${BISON_TARGET_output_header}")
+ unset(_BisonInput)
+
endif()
endmacro()
#
diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake
index 2684617fe..d3acafcd9 100644
--- a/Modules/FindBLAS.cmake
+++ b/Modules/FindBLAS.cmake
@@ -1,67 +1,101 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindBLAS
-# --------
-#
-# Find BLAS library
-#
-# This module finds an installed fortran library that implements the
-# BLAS linear-algebra interface (see http://www.netlib.org/blas/). The
-# list of libraries searched for is taken from the autoconf macro file,
-# acx_blas.m4 (distributed at
-# http://ac-archive.sourceforge.net/ac-archive/acx_blas.html).
-#
-# This module sets the following variables:
-#
-# ::
-#
-# BLAS_FOUND - set to true if a library implementing the BLAS interface
-# is found
-# BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l
-# and -L).
-# BLAS_LIBRARIES - uncached list of libraries (using full path name) to
-# link against to use BLAS
-# BLAS95_LIBRARIES - uncached list of libraries (using full path name)
-# to link against to use BLAS95 interface
-# BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface
-# is found
-# BLA_STATIC if set on this determines what kind of linkage we do (static)
-# BLA_VENDOR if set checks only the specified vendor, if not set checks
-# all the possibilities
-# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK
-#
-# List of vendors (BLA_VENDOR) valid in this module:
-#
-# * Goto
-# * OpenBLAS
-# * ATLAS PhiPACK
-# * CXML
-# * DXML
-# * SunPerf
-# * SCSL
-# * SGIMATH
-# * IBMESSL
-# * Intel10_32 (intel mkl v10 32 bit)
-# * Intel10_64lp (intel mkl v10 64 bit, lp thread model, lp64 model)
-# * Intel10_64lp_seq (intel mkl v10 64 bit, sequential code, lp64 model)
-# * Intel (older versions of mkl 32 and 64 bit)
-# * ACML
-# * ACML_MP
-# * ACML_GPU
-# * Apple
-# * NAS
-# * Generic
-#
-# .. note::
-#
-# C/CXX should be enabled to use Intel mkl
-#
+#[=======================================================================[.rst:
+FindBLAS
+--------
+
+Find Basic Linear Algebra Subprograms (BLAS) library
+
+This module finds an installed Fortran library that implements the
+BLAS linear-algebra interface (see http://www.netlib.org/blas/). The
+list of libraries searched for is taken from the ``autoconf`` macro file,
+``acx_blas.m4`` (distributed at
+http://ac-archive.sourceforge.net/ac-archive/acx_blas.html).
+
+Input Variables
+^^^^^^^^^^^^^^^
+
+The following variables may be set to influence this module's behavior:
+
+``BLA_STATIC``
+ if ``ON`` use static linkage
+
+``BLA_VENDOR``
+ If set, checks only the specified vendor, if not set checks all the
+ possibilities. List of vendors valid in this module:
+
+ * Goto
+ * OpenBLAS
+ * FLAME
+ * ATLAS PhiPACK
+ * CXML
+ * DXML
+ * SunPerf
+ * SCSL
+ * SGIMATH
+ * IBMESSL
+ * Intel10_32 (intel mkl v10 32 bit)
+ * Intel10_64lp (intel mkl v10+ 64 bit, threaded code, lp64 model)
+ * Intel10_64lp_seq (intel mkl v10+ 64 bit, sequential code, lp64 model)
+ * Intel10_64ilp (intel mkl v10+ 64 bit, threaded code, ilp64 model)
+ * Intel10_64ilp_seq (intel mkl v10+ 64 bit, sequential code, ilp64 model)
+ * Intel (obsolete versions of mkl 32 and 64 bit)
+ * ACML
+ * ACML_MP
+ * ACML_GPU
+ * Apple
+ * NAS
+ * Generic
+
+``BLA_F95``
+ if ``ON`` tries to find the BLAS95 interfaces
+
+``BLA_PREFER_PKGCONFIG``
+ if set ``pkg-config`` will be used to search for a BLAS library first
+ and if one is found that is preferred
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+``BLAS_FOUND``
+ library implementing the BLAS interface is found
+``BLAS_LINKER_FLAGS``
+ uncached list of required linker flags (excluding ``-l`` and ``-L``).
+``BLAS_LIBRARIES``
+ uncached list of libraries (using full path name) to link against
+ to use BLAS (may be empty if compiler implicitly links BLAS)
+``BLAS95_LIBRARIES``
+ uncached list of libraries (using full path name) to link against
+ to use BLAS95 interface
+``BLAS95_FOUND``
+ library implementing the BLAS95 interface is found
+
+.. note::
+
+ C or CXX must be enabled to use Intel Math Kernel Library (MKL)
+
+ For example, to use Intel MKL libraries and/or Intel compiler:
+
+ .. code-block:: cmake
+
+ set(BLA_VENDOR Intel10_64lp)
+ find_package(BLAS)
+
+Hints
+^^^^^
+
+Set ``MKLROOT`` environment variable to a directory that contains an MKL
+installation.
+
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
cmake_push_check_state()
set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY})
@@ -77,78 +111,97 @@ if( NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_C
endif()
endif()
+if(BLA_PREFER_PKGCONFIG)
+ find_package(PkgConfig)
+ pkg_check_modules(PKGC_BLAS blas)
+ if(PKGC_BLAS_FOUND)
+ set(BLAS_FOUND ${PKGC_BLAS_FOUND})
+ set(BLAS_LIBRARIES "${PKGC_BLAS_LINK_LIBRARIES}")
+ return()
+ endif()
+endif()
+
macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
-# This macro checks for the existence of the combination of fortran libraries
-# given by _list. If the combination is found, this macro checks (using the
-# Check_Fortran_Function_Exists macro) whether can link against that library
-# combination using the name of a routine given by _name using the linker
-# flags given by _flags. If the combination of libraries is found and passes
-# the link test, LIBRARIES is set to the list of complete library paths that
-# have been found. Otherwise, LIBRARIES is set to FALSE.
-
-# N.B. _prefix is the prefix applied to the names of all cached variables that
-# are generated internally and marked advanced by this macro.
-
-set(_libdir ${ARGN})
-
-set(_libraries_work TRUE)
-set(${LIBRARIES})
-set(_combined_name)
-if (NOT _libdir)
- if (WIN32)
- set(_libdir ENV LIB)
- elseif (APPLE)
- set(_libdir ENV DYLD_LIBRARY_PATH)
- else ()
- set(_libdir ENV LD_LIBRARY_PATH)
+ # This macro checks for the existence of the combination of fortran libraries
+ # given by _list. If the combination is found, this macro checks (using the
+ # Check_Fortran_Function_Exists macro) whether can link against that library
+ # combination using the name of a routine given by _name using the linker
+ # flags given by _flags. If the combination of libraries is found and passes
+ # the link test, LIBRARIES is set to the list of complete library paths that
+ # have been found. Otherwise, LIBRARIES is set to FALSE.
+
+ # N.B. _prefix is the prefix applied to the names of all cached variables that
+ # are generated internally and marked advanced by this macro.
+
+ set(_libdir ${ARGN})
+
+ set(_libraries_work TRUE)
+ set(${LIBRARIES})
+ set(_combined_name)
+ if (NOT _libdir)
+ if (WIN32)
+ set(_libdir ENV LIB)
+ elseif (APPLE)
+ set(_libdir ENV DYLD_LIBRARY_PATH)
+ else ()
+ set(_libdir ENV LD_LIBRARY_PATH)
+ endif ()
endif ()
-endif ()
-foreach(_library ${_list})
- set(_combined_name ${_combined_name}_${_library})
+ list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
- if(_libraries_work)
- if (BLA_STATIC)
- if (WIN32)
- set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
- endif ()
- if (APPLE)
- set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ foreach(_library ${_list})
+ set(_combined_name ${_combined_name}_${_library})
+ if(NOT "${_thread}" STREQUAL "")
+ set(_combined_name ${_combined_name}_thread)
+ endif()
+ if(_libraries_work)
+ if (BLA_STATIC)
+ if (WIN32)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ endif ()
+ if (APPLE)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ else ()
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ endif ()
else ()
- set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
- endif ()
- else ()
- if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
- # for ubuntu's libblas3gf and liblapack3gf packages
- set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
+ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ # for ubuntu's libblas3gf and liblapack3gf packages
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
+ endif ()
endif ()
- endif ()
- find_library(${_prefix}_${_library}_LIBRARY
- NAMES ${_library}
- PATHS ${_libdir}
- )
- mark_as_advanced(${_prefix}_${_library}_LIBRARY)
- set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
- set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
+ find_library(${_prefix}_${_library}_LIBRARY
+ NAMES ${_library}
+ PATHS ${_libdir}
+ )
+ mark_as_advanced(${_prefix}_${_library}_LIBRARY)
+ set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
+ set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
+ endif()
+ endforeach()
+ if(_libraries_work)
+ # Test this combination of libraries.
+ set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_thread})
+ # message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
+ if (CMAKE_Fortran_COMPILER_LOADED)
+ check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS)
+ else()
+ check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
+ endif()
+ set(CMAKE_REQUIRED_LIBRARIES)
+ set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
endif()
-endforeach()
-if(_libraries_work)
- # Test this combination of libraries.
- set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_thread})
-# message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
- if (CMAKE_Fortran_COMPILER_LOADED)
- check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS)
+ if(_libraries_work)
+ if("${_list}" STREQUAL "")
+ set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
+ else()
+ set(${LIBRARIES} ${${LIBRARIES}} ${_thread}) # for static link
+ endif()
else()
- check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
+ set(${LIBRARIES} FALSE)
endif()
- set(CMAKE_REQUIRED_LIBRARIES)
- mark_as_advanced(${_prefix}${_combined_name}_WORKS)
- set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
-endif()
-if(NOT _libraries_work)
- set(${LIBRARIES} FALSE)
-endif()
-#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
+ #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
endmacro()
set(BLAS_LINKER_FLAGS)
@@ -162,550 +215,605 @@ else ()
endif()
endif ()
+if (BLA_VENDOR STREQUAL "All")
+ if(NOT BLAS_LIBRARIES)
+ # Implicitly linked BLAS libraries
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ ""
+ ""
+ )
+ endif()
+endif ()
+
+#BLAS in intel mkl 10+ library? (em64t 64bit)
+if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
+ if (NOT BLAS_LIBRARIES)
+
+ # System-specific settings
+ if (WIN32)
+ if (BLA_STATIC)
+ set(BLAS_mkl_DLL_SUFFIX "")
+ else()
+ set(BLAS_mkl_DLL_SUFFIX "_dll")
+ endif()
+ else()
+ # Switch to GNU Fortran support layer if needed (but not on Apple, where MKL does not provide it)
+ if(CMAKE_Fortran_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT APPLE)
+ set(BLAS_mkl_INTFACE "gf")
+ set(BLAS_mkl_THREADING "gnu")
+ set(BLAS_mkl_OMP "gomp")
+ else()
+ set(BLAS_mkl_INTFACE "intel")
+ set(BLAS_mkl_THREADING "intel")
+ set(BLAS_mkl_OMP "iomp5")
+ endif()
+ set(BLAS_mkl_LM "-lm")
+ set(BLAS_mkl_LDL "-ldl")
+ endif()
+
+ if (BLA_VENDOR MATCHES "_64ilp")
+ set(BLAS_mkl_ILP_MODE "ilp64")
+ else ()
+ set(BLAS_mkl_ILP_MODE "lp64")
+ endif ()
+
+ if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED)
+ if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
+ find_package(Threads)
+ else()
+ find_package(Threads REQUIRED)
+ endif()
+
+ set(BLAS_SEARCH_LIBS "")
+
+ if(BLA_F95)
+ set(BLAS_mkl_SEARCH_SYMBOL sgemm_f95)
+ set(_LIBRARIES BLAS95_LIBRARIES)
+ if (WIN32)
+ # Find the main file (32-bit or 64-bit)
+ set(BLAS_SEARCH_LIBS_WIN_MAIN "")
+ if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
+ list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
+ "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}")
+ endif()
+ if (BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All")
+ list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
+ "mkl_blas95_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX} mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}")
+ endif ()
+
+ # Add threading/sequential libs
+ set(BLAS_SEARCH_LIBS_WIN_THREAD "")
+ if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All")
+ list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
+ "mkl_sequential${BLAS_mkl_DLL_SUFFIX}")
+ endif()
+ if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All")
+ # old version
+ list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
+ "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
+ # mkl >= 10.3
+ list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
+ "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
+ endif()
+
+ # Cartesian product of the above
+ foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN})
+ foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD})
+ list(APPEND BLAS_SEARCH_LIBS
+ "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}")
+ endforeach()
+ endforeach()
+ else ()
+ if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
+ # old version
+ list(APPEND BLAS_SEARCH_LIBS
+ "mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide")
+
+ # mkl >= 10.3
+ list(APPEND BLAS_SEARCH_LIBS
+ "mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}")
+ endif ()
+ if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All")
+ # old version
+ list(APPEND BLAS_SEARCH_LIBS
+ "mkl_blas95 mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide")
+
+ # mkl >= 10.3
+ list(APPEND BLAS_SEARCH_LIBS
+ "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}")
+ endif ()
+ if (BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All")
+ list(APPEND BLAS_SEARCH_LIBS
+ "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core")
+ endif ()
+ endif ()
+ else ()
+ set(BLAS_mkl_SEARCH_SYMBOL sgemm)
+ set(_LIBRARIES BLAS_LIBRARIES)
+ if (WIN32)
+ # Find the main file (32-bit or 64-bit)
+ set(BLAS_SEARCH_LIBS_WIN_MAIN "")
+ if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
+ list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
+ "mkl_intel_c${BLAS_mkl_DLL_SUFFIX}")
+ endif()
+ if (BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All")
+ list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
+ "mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}")
+ endif ()
+
+ # Add threading/sequential libs
+ set(BLAS_SEARCH_LIBS_WIN_THREAD "")
+ if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All")
+ # old version
+ list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
+ "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
+ # mkl >= 10.3
+ list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
+ "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
+ endif()
+ if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All")
+ list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
+ "mkl_sequential${BLAS_mkl_DLL_SUFFIX}")
+ endif()
+
+ # Cartesian product of the above
+ foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN})
+ foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD})
+ list(APPEND BLAS_SEARCH_LIBS
+ "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}")
+ endforeach()
+ endforeach()
+ else ()
+ if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
+ # old version
+ list(APPEND BLAS_SEARCH_LIBS
+ "mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide")
+
+ # mkl >= 10.3
+ list(APPEND BLAS_SEARCH_LIBS
+ "mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}")
+ endif ()
+ if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All")
+ # old version
+ list(APPEND BLAS_SEARCH_LIBS
+ "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide")
+
+ # mkl >= 10.3
+ list(APPEND BLAS_SEARCH_LIBS
+ "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_OMP}")
+ endif ()
+ if (BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All")
+ list(APPEND BLAS_SEARCH_LIBS
+ "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core")
+ endif ()
+
+ #older vesions of intel mkl libs
+ if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All")
+ list(APPEND BLAS_SEARCH_LIBS
+ "mkl")
+ list(APPEND BLAS_SEARCH_LIBS
+ "mkl_ia32")
+ list(APPEND BLAS_SEARCH_LIBS
+ "mkl_em64t")
+ endif ()
+ endif ()
+ endif ()
+
+ if (DEFINED ENV{MKLROOT})
+ if (BLA_VENDOR STREQUAL "Intel10_32")
+ set(_BLAS_MKLROOT_LIB_DIR "$ENV{MKLROOT}/lib/ia32")
+ elseif (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$")
+ set(_BLAS_MKLROOT_LIB_DIR "$ENV{MKLROOT}/lib/intel64")
+ endif ()
+ endif ()
+ if (_BLAS_MKLROOT_LIB_DIR)
+ if (WIN32)
+ string(APPEND _BLAS_MKLROOT_LIB_DIR "_win")
+ elseif (APPLE)
+ string(APPEND _BLAS_MKLROOT_LIB_DIR "_mac")
+ else ()
+ string(APPEND _BLAS_MKLROOT_LIB_DIR "_lin")
+ endif ()
+ endif ()
+
+ foreach (IT ${BLAS_SEARCH_LIBS})
+ string(REPLACE " " ";" SEARCH_LIBS ${IT})
+ if (NOT ${_LIBRARIES})
+ check_fortran_libraries(
+ ${_LIBRARIES}
+ BLAS
+ ${BLAS_mkl_SEARCH_SYMBOL}
+ ""
+ "${SEARCH_LIBS}"
+ "${CMAKE_THREAD_LIBS_INIT};${BLAS_mkl_LM};${BLAS_mkl_LDL}"
+ "${_BLAS_MKLROOT_LIB_DIR}"
+ )
+ endif ()
+ endforeach ()
+
+ endif ()
+ unset(BLAS_mkl_ILP_MODE)
+ unset(BLAS_mkl_INTFACE)
+ unset(BLAS_mkl_THREADING)
+ unset(BLAS_mkl_OMP)
+ unset(BLAS_mkl_DLL_SUFFIX)
+ unset(BLAS_mkl_LM)
+ unset(BLAS_mkl_LDL)
+ endif ()
+endif ()
+
+if(BLA_F95)
+ find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS95_LIBRARIES)
+ set(BLAS95_FOUND ${BLAS_FOUND})
+ if(BLAS_FOUND)
+ set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}")
+ endif()
+endif()
+
if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
- if(NOT BLAS_LIBRARIES)
- # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2)
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "goto2"
- ""
- )
- endif()
+ if(NOT BLAS_LIBRARIES)
+ # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "goto2"
+ ""
+ )
+ endif()
endif ()
if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")
- if(NOT BLAS_LIBRARIES)
- # OpenBLAS (http://www.openblas.net)
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "openblas"
- ""
- )
- endif()
+ if(NOT BLAS_LIBRARIES)
+ # OpenBLAS (http://www.openblas.net)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "openblas"
+ ""
+ )
+ endif()
+ if(NOT BLAS_LIBRARIES AND (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED))
+ if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
+ find_package(Threads)
+ else()
+ find_package(Threads REQUIRED)
+ endif()
+ # OpenBLAS (http://www.openblas.net)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "openblas"
+ "${CMAKE_THREAD_LIBS_INIT}"
+ )
+ endif()
+endif ()
+
+if (BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All")
+ if(NOT BLAS_LIBRARIES)
+ # FLAME's blis library (https://github.com/flame/blis)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "blis"
+ ""
+ )
+ endif()
endif ()
if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")
- if(NOT BLAS_LIBRARIES)
- # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- dgemm
- ""
- "f77blas;atlas"
- ""
- )
- endif()
+ if(NOT BLAS_LIBRARIES)
+ # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ dgemm
+ ""
+ "f77blas;atlas"
+ ""
+ )
+ endif()
endif ()
# BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All")
- if(NOT BLAS_LIBRARIES)
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "sgemm;dgemm;blas"
- ""
- )
- endif()
+ if(NOT BLAS_LIBRARIES)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "sgemm;dgemm;blas"
+ ""
+ )
+ endif()
endif ()
# BLAS in Alpha CXML library?
if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All")
- if(NOT BLAS_LIBRARIES)
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "cxml"
- ""
- )
- endif()
+ if(NOT BLAS_LIBRARIES)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "cxml"
+ ""
+ )
+ endif()
endif ()
# BLAS in Alpha DXML library? (now called CXML, see above)
if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All")
- if(NOT BLAS_LIBRARIES)
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "dxml"
- ""
- )
- endif()
+ if(NOT BLAS_LIBRARIES)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "dxml"
+ ""
+ )
+ endif()
endif ()
# BLAS in Sun Performance library?
if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All")
- if(NOT BLAS_LIBRARIES)
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- "-xlic_lib=sunperf"
- "sunperf;sunmath"
- ""
- )
- if(BLAS_LIBRARIES)
- set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf")
+ if(NOT BLAS_LIBRARIES)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ "-xlic_lib=sunperf"
+ "sunperf;sunmath"
+ ""
+ )
+ if(BLAS_LIBRARIES)
+ set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf")
+ endif()
endif()
- endif()
endif ()
# BLAS in SCSL library? (SGI/Cray Scientific Library)
if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All")
- if(NOT BLAS_LIBRARIES)
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "scsl"
- ""
- )
- endif()
+ if(NOT BLAS_LIBRARIES)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "scsl"
+ ""
+ )
+ endif()
endif ()
# BLAS in SGIMATH library?
if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All")
- if(NOT BLAS_LIBRARIES)
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "complib.sgimath"
- ""
- )
- endif()
+ if(NOT BLAS_LIBRARIES)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "complib.sgimath"
+ ""
+ )
+ endif()
endif ()
# BLAS in IBM ESSL library? (requires generic BLAS lib, too)
if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All")
- if(NOT BLAS_LIBRARIES)
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "essl;blas"
- ""
- )
- endif()
+ if(NOT BLAS_LIBRARIES)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "essl;blas"
+ ""
+ )
+ endif()
endif ()
#BLAS in acml library?
if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All")
- if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR
- ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR
- ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS))
- )
- # try to find acml in "standard" paths
- if( WIN32 )
+ if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR
+ ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR
+ ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS))
+ )
+ # try to find acml in "standard" paths
+ if( WIN32 )
file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" )
- else()
+ else()
file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" )
- endif()
- if( WIN32 )
+ endif()
+ if( WIN32 )
file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" )
- else()
+ else()
file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" )
- endif()
- list(GET _ACML_ROOT 0 _ACML_ROOT)
- list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT)
- if( _ACML_ROOT )
+ endif()
+ list(GET _ACML_ROOT 0 _ACML_ROOT)
+ list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT)
+ if( _ACML_ROOT )
get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH )
if( SIZEOF_INTEGER EQUAL 8 )
- set( _ACML_PATH_SUFFIX "_int64" )
+ set( _ACML_PATH_SUFFIX "_int64" )
else()
- set( _ACML_PATH_SUFFIX "" )
- endif()
- if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" )
- set( _ACML_COMPILER32 "ifort32" )
- set( _ACML_COMPILER64 "ifort64" )
- elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" )
- set( _ACML_COMPILER32 "sun32" )
- set( _ACML_COMPILER64 "sun64" )
- elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" )
- set( _ACML_COMPILER32 "pgi32" )
- if( WIN32 )
- set( _ACML_COMPILER64 "win64" )
+ set( _ACML_PATH_SUFFIX "" )
+ endif()
+ if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" )
+ set( _ACML_COMPILER32 "ifort32" )
+ set( _ACML_COMPILER64 "ifort64" )
+ elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" )
+ set( _ACML_COMPILER32 "sun32" )
+ set( _ACML_COMPILER64 "sun64" )
+ elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" )
+ set( _ACML_COMPILER32 "pgi32" )
+ if( WIN32 )
+ set( _ACML_COMPILER64 "win64" )
+ else()
+ set( _ACML_COMPILER64 "pgi64" )
+ endif()
+ elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" )
+ # 32 bit builds not supported on Open64 but for code simplicity
+ # We'll just use the same directory twice
+ set( _ACML_COMPILER32 "open64_64" )
+ set( _ACML_COMPILER64 "open64_64" )
+ elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" )
+ set( _ACML_COMPILER32 "nag32" )
+ set( _ACML_COMPILER64 "nag64" )
else()
- set( _ACML_COMPILER64 "pgi64" )
+ set( _ACML_COMPILER32 "gfortran32" )
+ set( _ACML_COMPILER64 "gfortran64" )
+ endif()
+
+ if( BLA_VENDOR STREQUAL "ACML_MP" )
+ set(_ACML_MP_LIB_DIRS
+ "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib"
+ "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" )
+ else()
+ set(_ACML_LIB_DIRS
+ "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib"
+ "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" )
endif()
- elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" )
- # 32 bit builds not supported on Open64 but for code simplicity
- # We'll just use the same directory twice
- set( _ACML_COMPILER32 "open64_64" )
- set( _ACML_COMPILER64 "open64_64" )
- elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" )
- set( _ACML_COMPILER32 "nag32" )
- set( _ACML_COMPILER64 "nag64" )
- else()
- set( _ACML_COMPILER32 "gfortran32" )
- set( _ACML_COMPILER64 "gfortran64" )
- endif()
-
- if( BLA_VENDOR STREQUAL "ACML_MP" )
- set(_ACML_MP_LIB_DIRS
- "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib"
- "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" )
- else()
- set(_ACML_LIB_DIRS
- "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib"
- "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" )
- endif()
endif()
- elseif(BLAS_${BLA_VENDOR}_LIB_DIRS)
- set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS})
- endif()
+elseif(BLAS_${BLA_VENDOR}_LIB_DIRS)
+ set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS})
+endif()
- if( BLA_VENDOR STREQUAL "ACML_MP" )
+if( BLA_VENDOR STREQUAL "ACML_MP" )
foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS})
- check_fortran_libraries (
- BLAS_LIBRARIES
- BLAS
- sgemm
- "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS}
- )
- if( BLAS_LIBRARIES )
- break()
- endif()
+ check_fortran_libraries (
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS}
+ )
+ if( BLAS_LIBRARIES )
+ break()
+ endif()
endforeach()
- elseif( BLA_VENDOR STREQUAL "ACML_GPU" )
+elseif( BLA_VENDOR STREQUAL "ACML_GPU" )
foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS})
- check_fortran_libraries (
- BLAS_LIBRARIES
- BLAS
- sgemm
- "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS}
- )
- if( BLAS_LIBRARIES )
- break()
- endif()
+ check_fortran_libraries (
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS}
+ )
+ if( BLAS_LIBRARIES )
+ break()
+ endif()
endforeach()
- else()
+else()
foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} )
- check_fortran_libraries (
- BLAS_LIBRARIES
- BLAS
- sgemm
- "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS}
- )
- if( BLAS_LIBRARIES )
- break()
- endif()
+ check_fortran_libraries (
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS}
+ )
+ if( BLAS_LIBRARIES )
+ break()
+ endif()
endforeach()
- endif()
+endif()
- # Either acml or acml_mp should be in LD_LIBRARY_PATH but not both
- if(NOT BLAS_LIBRARIES)
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "acml;acml_mv"
- ""
- )
- endif()
- if(NOT BLAS_LIBRARIES)
- check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "acml_mp;acml_mv"
- ""
- )
- endif()
- if(NOT BLAS_LIBRARIES)
+# Either acml or acml_mp should be in LD_LIBRARY_PATH but not both
+if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "acml;acml_mv;CALBLAS"
- ""
- )
- endif()
-endif () # ACML
-
-# Apple BLAS library?
-if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "acml;acml_mv"
+ ""
+ )
+endif()
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- dgemm
- ""
- "Accelerate"
- ""
- )
- endif()
-endif ()
-
-if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
- if ( NOT BLAS_LIBRARIES )
- check_fortran_libraries(
BLAS_LIBRARIES
BLAS
- dgemm
+ sgemm
""
- "vecLib"
+ "acml_mp;acml_mv"
""
)
- endif ()
-endif ()
-# Generic BLAS library?
-if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
- if(NOT BLAS_LIBRARIES)
+endif()
+if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
- BLAS_LIBRARIES
- BLAS
- sgemm
- ""
- "blas"
- ""
- )
- endif()
-endif ()
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "acml;acml_mv;CALBLAS"
+ ""
+ )
+endif()
+endif () # ACML
-#BLAS in intel mkl 10 library? (em64t 64bit)
-if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
- if (NOT WIN32)
- set(LM "-lm")
- endif ()
- if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED)
- if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
- find_package(Threads)
- else()
- find_package(Threads REQUIRED)
+# Apple BLAS library?
+if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
+ if(NOT BLAS_LIBRARIES)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ dgemm
+ ""
+ "Accelerate"
+ ""
+ )
endif()
+endif ()
- set(BLAS_SEARCH_LIBS "")
-
- if(BLA_F95)
- set(BLAS_mkl_SEARCH_SYMBOL SGEMM)
- set(_LIBRARIES BLAS95_LIBRARIES)
- if (WIN32)
- if (BLA_STATIC)
- set(BLAS_mkl_DLL_SUFFIX "")
- else()
- set(BLAS_mkl_DLL_SUFFIX "_dll")
- endif()
-
- # Find the main file (32-bit or 64-bit)
- set(BLAS_SEARCH_LIBS_WIN_MAIN "")
- if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
- list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
- "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}")
- endif()
- if (BLA_VENDOR MATCHES "^Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
- list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
- "mkl_blas95_lp64${BLAS_mkl_DLL_SUFFIX} mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}")
- endif ()
-
- # Add threading/sequential libs
- set(BLAS_SEARCH_LIBS_WIN_THREAD "")
- if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All")
- list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
- "mkl_sequential${BLAS_mkl_DLL_SUFFIX}")
- endif()
- if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All")
- # old version
- list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
- "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
- # mkl >= 10.3
- list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
- "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
- endif()
-
- # Cartesian product of the above
- foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN})
- foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD})
- list(APPEND BLAS_SEARCH_LIBS
- "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}")
- endforeach()
- endforeach()
- else ()
- if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
- list(APPEND BLAS_SEARCH_LIBS
- "mkl_blas95 mkl_intel mkl_intel_thread mkl_core guide")
- endif ()
- if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
- # old version
- list(APPEND BLAS_SEARCH_LIBS
- "mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide")
-
- # mkl >= 10.3
- if (CMAKE_C_COMPILER MATCHES ".+gcc")
- list(APPEND BLAS_SEARCH_LIBS
- "mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core gomp")
- else ()
- list(APPEND BLAS_SEARCH_LIBS
- "mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core iomp5")
- endif ()
- endif ()
- if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All")
- list(APPEND BLAS_SEARCH_LIBS
- "mkl_intel_lp64 mkl_sequential mkl_core")
- endif ()
- endif ()
- else ()
- set(BLAS_mkl_SEARCH_SYMBOL sgemm)
- set(_LIBRARIES BLAS_LIBRARIES)
- if (WIN32)
- if (BLA_STATIC)
- set(BLAS_mkl_DLL_SUFFIX "")
- else()
- set(BLAS_mkl_DLL_SUFFIX "_dll")
- endif()
-
- # Find the main file (32-bit or 64-bit)
- set(BLAS_SEARCH_LIBS_WIN_MAIN "")
- if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
- list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
- "mkl_intel_c${BLAS_mkl_DLL_SUFFIX}")
- endif()
- if (BLA_VENDOR MATCHES "^Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
- list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
- "mkl_intel_lp64${BLAS_mkl_DLL_SUFFIX}")
- endif ()
-
- # Add threading/sequential libs
- set(BLAS_SEARCH_LIBS_WIN_THREAD "")
- if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All")
- # old version
- list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
- "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
- # mkl >= 10.3
- list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
- "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
- endif()
- if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All")
- list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
- "mkl_sequential${BLAS_mkl_DLL_SUFFIX}")
- endif()
-
- # Cartesian product of the above
- foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN})
- foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD})
- list(APPEND BLAS_SEARCH_LIBS
- "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}")
- endforeach()
- endforeach()
- else ()
- if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
- list(APPEND BLAS_SEARCH_LIBS
- "mkl_intel mkl_intel_thread mkl_core guide")
- endif ()
- if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
-
- # old version
- list(APPEND BLAS_SEARCH_LIBS
- "mkl_intel_lp64 mkl_intel_thread mkl_core guide")
-
- # mkl >= 10.3
- if (CMAKE_C_COMPILER MATCHES ".+gcc")
- list(APPEND BLAS_SEARCH_LIBS
- "mkl_intel_lp64 mkl_gnu_thread mkl_core gomp")
- else ()
- list(APPEND BLAS_SEARCH_LIBS
- "mkl_intel_lp64 mkl_intel_thread mkl_core iomp5")
- endif ()
- endif ()
- if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All")
- list(APPEND BLAS_SEARCH_LIBS
- "mkl_intel_lp64 mkl_sequential mkl_core")
- endif ()
-
- #older vesions of intel mkl libs
- if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All")
- list(APPEND BLAS_SEARCH_LIBS
- "mkl")
- list(APPEND BLAS_SEARCH_LIBS
- "mkl_ia32")
- list(APPEND BLAS_SEARCH_LIBS
- "mkl_em64t")
- endif ()
- endif ()
+if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
+ if ( NOT BLAS_LIBRARIES )
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ dgemm
+ ""
+ "vecLib"
+ ""
+ )
endif ()
-
- foreach (IT ${BLAS_SEARCH_LIBS})
- string(REPLACE " " ";" SEARCH_LIBS ${IT})
- if (${_LIBRARIES})
- else ()
- check_fortran_libraries(
- ${_LIBRARIES}
- BLAS
- ${BLAS_mkl_SEARCH_SYMBOL}
- ""
- "${SEARCH_LIBS}"
- "${CMAKE_THREAD_LIBS_INIT};${LM}"
- )
- endif ()
- endforeach ()
-
- endif ()
endif ()
-
-if(BLA_F95)
- if(BLAS95_LIBRARIES)
- set(BLAS95_FOUND TRUE)
- else()
- set(BLAS95_FOUND FALSE)
+# Generic BLAS library?
+if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
+ if(NOT BLAS_LIBRARIES)
+ check_fortran_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "blas"
+ ""
+ )
endif()
+endif ()
- if(NOT BLAS_FIND_QUIETLY)
- if(BLAS95_FOUND)
- message(STATUS "A library with BLAS95 API found.")
- else()
- if(BLAS_FIND_REQUIRED)
- message(FATAL_ERROR
- "A required library with BLAS95 API not found. Please specify library location.")
- else()
- message(STATUS
- "A library with BLAS95 API not found. Please specify library location.")
- endif()
- endif()
- endif()
- set(BLAS_FOUND TRUE)
- set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}")
-else()
- if(BLAS_LIBRARIES)
- set(BLAS_FOUND TRUE)
- else()
- set(BLAS_FOUND FALSE)
- endif()
+if(NOT BLA_F95)
+ find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS_LIBRARIES)
+endif()
- if(NOT BLAS_FIND_QUIETLY)
- if(BLAS_FOUND)
- message(STATUS "A library with BLAS API found.")
- else()
- if(BLAS_FIND_REQUIRED)
- message(FATAL_ERROR
- "A required library with BLAS API not found. Please specify library location."
- )
- else()
- message(STATUS
- "A library with BLAS API not found. Please specify library location."
- )
- endif()
- endif()
- endif()
+# On compilers that implicitly link BLAS (such as ftn, cc, and CC on Cray HPC machines)
+# we used a placeholder for empty BLAS_LIBRARIES to get through our logic above.
+if (BLAS_LIBRARIES STREQUAL "BLAS_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
+ set(BLAS_LIBRARIES "")
endif()
cmake_pop_check_state()
diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake
index d2307f131..98ab72cd8 100644
--- a/Modules/FindBZip2.cmake
+++ b/Modules/FindBZip2.cmake
@@ -1,30 +1,42 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindBZip2
-# ---------
-#
-# Try to find BZip2
-#
-# IMPORTED Targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines :prop_tgt:`IMPORTED` target ``BZip2::BZip2``, if
-# BZip2 has been found.
-#
-# Result Variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the following variables:
-#
-# ::
-#
-# BZIP2_FOUND - system has BZip2
-# BZIP2_INCLUDE_DIR - the BZip2 include directory
-# BZIP2_LIBRARIES - Link these to use BZip2
-# BZIP2_NEED_PREFIX - this is set if the functions are prefixed with BZ2_
-# BZIP2_VERSION_STRING - the version of BZip2 found (since CMake 2.8.8)
+#[=======================================================================[.rst:
+FindBZip2
+---------
+
+Try to find BZip2
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``BZip2::BZip2``, if
+BZip2 has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+``BZIP2_FOUND``
+ system has BZip2
+``BZIP2_INCLUDE_DIRS``
+ the BZip2 include directories
+``BZIP2_LIBRARIES``
+ Link these to use BZip2
+``BZIP2_NEED_PREFIX``
+ this is set if the functions are prefixed with ``BZ2_``
+``BZIP2_VERSION_STRING``
+ the version of BZip2 found
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``BZIP2_INCLUDE_DIR``
+ the BZip2 include directory
+#]=======================================================================]
set(_BZIP2_PATHS PATHS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Bzip2;InstallPath]"
@@ -33,11 +45,13 @@ set(_BZIP2_PATHS PATHS
find_path(BZIP2_INCLUDE_DIR bzlib.h ${_BZIP2_PATHS} PATH_SUFFIXES include)
if (NOT BZIP2_LIBRARIES)
- find_library(BZIP2_LIBRARY_RELEASE NAMES bz2 bzip2 ${_BZIP2_PATHS} PATH_SUFFIXES lib)
- find_library(BZIP2_LIBRARY_DEBUG NAMES bz2d bzip2d ${_BZIP2_PATHS} PATH_SUFFIXES lib)
+ find_library(BZIP2_LIBRARY_RELEASE NAMES bz2 bzip2 libbz2 libbzip2 ${_BZIP2_PATHS} PATH_SUFFIXES lib)
+ find_library(BZIP2_LIBRARY_DEBUG NAMES bz2d bzip2d libbz2d libbzip2d ${_BZIP2_PATHS} PATH_SUFFIXES lib)
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
SELECT_LIBRARY_CONFIGURATIONS(BZIP2)
+else ()
+ file(TO_CMAKE_PATH "${BZIP2_LIBRARIES}" BZIP2_LIBRARIES)
endif ()
if (BZIP2_INCLUDE_DIR AND EXISTS "${BZIP2_INCLUDE_DIR}/bzlib.h")
@@ -51,39 +65,40 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2
VERSION_VAR BZIP2_VERSION_STRING)
if (BZIP2_FOUND)
- include(${CMAKE_CURRENT_LIST_DIR}/CheckSymbolExists.cmake)
- include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
- cmake_push_check_state()
- set(CMAKE_REQUIRED_QUIET ${BZip2_FIND_QUIETLY})
- set(CMAKE_REQUIRED_INCLUDES ${BZIP2_INCLUDE_DIR})
- set(CMAKE_REQUIRED_LIBRARIES ${BZIP2_LIBRARIES})
- CHECK_SYMBOL_EXISTS(BZ2_bzCompressInit "bzlib.h" BZIP2_NEED_PREFIX)
- cmake_pop_check_state()
-
- if(NOT TARGET BZip2::BZip2)
- add_library(BZip2::BZip2 UNKNOWN IMPORTED)
+ set(BZIP2_INCLUDE_DIRS ${BZIP2_INCLUDE_DIR})
+ include(${CMAKE_CURRENT_LIST_DIR}/CheckSymbolExists.cmake)
+ include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_QUIET ${BZip2_FIND_QUIETLY})
+ set(CMAKE_REQUIRED_INCLUDES ${BZIP2_INCLUDE_DIR})
+ set(CMAKE_REQUIRED_LIBRARIES ${BZIP2_LIBRARIES})
+ CHECK_SYMBOL_EXISTS(BZ2_bzCompressInit "bzlib.h" BZIP2_NEED_PREFIX)
+ cmake_pop_check_state()
+
+ if(NOT TARGET BZip2::BZip2)
+ add_library(BZip2::BZip2 UNKNOWN IMPORTED)
+ set_target_properties(BZip2::BZip2 PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIRS}")
+
+ if(BZIP2_LIBRARY_RELEASE)
+ set_property(TARGET BZip2::BZip2 APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(BZip2::BZip2 PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${BZIP2_LIBRARY_RELEASE}")
+ endif()
+
+ if(BZIP2_LIBRARY_DEBUG)
+ set_property(TARGET BZip2::BZip2 APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(BZip2::BZip2 PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIRS}")
-
- if(BZIP2_LIBRARY_RELEASE)
- set_property(TARGET BZip2::BZip2 APPEND PROPERTY
- IMPORTED_CONFIGURATIONS RELEASE)
- set_target_properties(BZip2::BZip2 PROPERTIES
- IMPORTED_LOCATION_RELEASE "${BZIP2_LIBRARY_RELEASE}")
- endif()
-
- if(BZIP2_LIBRARY_DEBUG)
- set_property(TARGET BZip2::BZip2 APPEND PROPERTY
- IMPORTED_CONFIGURATIONS DEBUG)
- set_target_properties(BZip2::BZip2 PROPERTIES
- IMPORTED_LOCATION_DEBUG "${BZIP2_LIBRARY_DEBUG}")
- endif()
-
- if(NOT BZIP2_LIBRARY_RELEASE AND NOT BZIP2_LIBRARY_DEBUG)
- set_property(TARGET BZip2::BZip2 APPEND PROPERTY
- IMPORTED_LOCATION "${BZIP2_LIBRARY}")
- endif()
+ IMPORTED_LOCATION_DEBUG "${BZIP2_LIBRARY_DEBUG}")
+ endif()
+
+ if(NOT BZIP2_LIBRARY_RELEASE AND NOT BZIP2_LIBRARY_DEBUG)
+ set_property(TARGET BZip2::BZip2 APPEND PROPERTY
+ IMPORTED_LOCATION "${BZIP2_LIBRARY}")
endif()
+ endif()
endif ()
mark_as_advanced(BZIP2_INCLUDE_DIR)
diff --git a/Modules/FindBacktrace.cmake b/Modules/FindBacktrace.cmake
index 59ebdc26d..3d8ce884a 100644
--- a/Modules/FindBacktrace.cmake
+++ b/Modules/FindBacktrace.cmake
@@ -1,41 +1,42 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindBacktrace
-# -------------
-#
-# Find provider for backtrace(3).
-#
-# Checks if OS supports backtrace(3) via either libc or custom library.
-# This module defines the following variables:
-#
-# ``Backtrace_HEADER``
-# The header file needed for backtrace(3). Cached.
-# Could be forcibly set by user.
-# ``Backtrace_INCLUDE_DIRS``
-# The include directories needed to use backtrace(3) header.
-# ``Backtrace_LIBRARIES``
-# The libraries (linker flags) needed to use backtrace(3), if any.
-# ``Backtrace_FOUND``
-# Is set if and only if backtrace(3) support detected.
-#
-# The following cache variables are also available to set or use:
-#
-# ``Backtrace_LIBRARY``
-# The external library providing backtrace, if any.
-# ``Backtrace_INCLUDE_DIR``
-# The directory holding the backtrace(3) header.
-#
-# Typical usage is to generate of header file using configure_file() with the
-# contents like the following::
-#
-# #cmakedefine01 Backtrace_FOUND
-# #if Backtrace_FOUND
-# # include <${Backtrace_HEADER}>
-# #endif
-#
-# And then reference that generated header file in actual source.
+#[=======================================================================[.rst:
+FindBacktrace
+-------------
+
+Find provider for `backtrace(3) <http://man7.org/linux/man-pages/man3/backtrace.3.html>`__.
+
+Checks if OS supports ``backtrace(3)`` via either ``libc`` or custom library.
+This module defines the following variables:
+
+``Backtrace_HEADER``
+ The header file needed for ``backtrace(3)``. Cached.
+ Could be forcibly set by user.
+``Backtrace_INCLUDE_DIRS``
+ The include directories needed to use ``backtrace(3)`` header.
+``Backtrace_LIBRARIES``
+ The libraries (linker flags) needed to use ``backtrace(3)``, if any.
+``Backtrace_FOUND``
+ Is set if and only if ``backtrace(3)`` support detected.
+
+The following cache variables are also available to set or use:
+
+``Backtrace_LIBRARY``
+ The external library providing backtrace, if any.
+``Backtrace_INCLUDE_DIR``
+ The directory holding the ``backtrace(3)`` header.
+
+Typical usage is to generate of header file using :command:`configure_file`
+with the contents like the following::
+
+ #cmakedefine01 Backtrace_FOUND
+ #if Backtrace_FOUND
+ # include <${Backtrace_HEADER}>
+ #endif
+
+And then reference that generated header file in actual source.
+#]=======================================================================]
include(CMakePushCheckState)
include(CheckSymbolExists)
@@ -73,7 +74,7 @@ else()
if(Backtrace_INCLUDE_DIR)
# OpenBSD has libbacktrace renamed to libexecinfo
find_library(Backtrace_LIBRARY "execinfo")
- elseif() # respect user wishes
+ else() # respect user wishes
set(_Backtrace_HEADER_TRY "backtrace.h")
find_path(Backtrace_INCLUDE_DIR ${_Backtrace_HEADER_TRY})
find_library(Backtrace_LIBRARY "backtrace")
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index 6d7cc27f4..0e84fabfc 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -1,216 +1,427 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindBoost
-# ---------
-#
-# Find Boost include dirs and libraries
-#
-# Use this module by invoking find_package with the form::
-#
-# find_package(Boost
-# [version] [EXACT] # Minimum or EXACT version e.g. 1.36.0
-# [REQUIRED] # Fail with error if Boost is not found
-# [COMPONENTS <libs>...] # Boost libraries by their canonical name
-# ) # e.g. "date_time" for "libboost_date_time"
-#
-# This module finds headers and requested component libraries OR a CMake
-# package configuration file provided by a "Boost CMake" build. For the
-# latter case skip to the "Boost CMake" section below. For the former
-# case results are reported in variables::
-#
-# Boost_FOUND - True if headers and requested libraries were found
-# Boost_INCLUDE_DIRS - Boost include directories
-# Boost_LIBRARY_DIRS - Link directories for Boost libraries
-# Boost_LIBRARIES - Boost component libraries to be linked
-# Boost_<C>_FOUND - True if component <C> was found (<C> is upper-case)
-# Boost_<C>_LIBRARY - Libraries to link for component <C> (may include
-# target_link_libraries debug/optimized keywords)
-# Boost_VERSION - BOOST_VERSION value from boost/version.hpp
-# Boost_LIB_VERSION - Version string appended to library filenames
-# Boost_MAJOR_VERSION - Boost major version number (X in X.y.z)
-# Boost_MINOR_VERSION - Boost minor version number (Y in x.Y.z)
-# Boost_SUBMINOR_VERSION - Boost subminor version number (Z in x.y.Z)
-# Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows)
-# - Pass to add_definitions() to have diagnostic
-# information about Boost's automatic linking
-# displayed during compilation
-#
-# This module reads hints about search locations from variables::
-#
-# BOOST_ROOT - Preferred installation prefix
-# (or BOOSTROOT)
-# BOOST_INCLUDEDIR - Preferred include directory e.g. <prefix>/include
-# BOOST_LIBRARYDIR - Preferred library directory e.g. <prefix>/lib
-# Boost_NO_SYSTEM_PATHS - Set to ON to disable searching in locations not
-# specified by these hint variables. Default is OFF.
-# Boost_ADDITIONAL_VERSIONS
-# - List of Boost versions not known to this module
-# (Boost install locations may contain the version)
-#
-# and saves search results persistently in CMake cache entries::
-#
-# Boost_INCLUDE_DIR - Directory containing Boost headers
-# Boost_LIBRARY_DIR_RELEASE - Directory containing release Boost libraries
-# Boost_LIBRARY_DIR_DEBUG - Directory containing debug Boost libraries
-# Boost_<C>_LIBRARY_DEBUG - Component <C> library debug variant
-# Boost_<C>_LIBRARY_RELEASE - Component <C> library release variant
-#
-# The following :prop_tgt:`IMPORTED` targets are also defined::
-#
-# Boost::boost - Target for header-only dependencies
-# (Boost include directory)
-# Boost::<C> - Target for specific component dependency
-# (shared or static library); <C> is lower-
-# case
-# Boost::diagnostic_definitions - interface target to enable diagnostic
-# information about Boost's automatic linking
-# during compilation (adds BOOST_LIB_DIAGNOSTIC)
-# Boost::disable_autolinking - interface target to disable automatic
-# linking with MSVC (adds BOOST_ALL_NO_LIB)
-# Boost::dynamic_linking - interface target to enable dynamic linking
-# linking with MSVC (adds BOOST_ALL_DYN_LINK)
-#
-# Implicit dependencies such as Boost::filesystem requiring
-# Boost::system will be automatically detected and satisfied, even
-# if system is not specified when using find_package and if
-# Boost::system is not added to target_link_libraries. If using
-# Boost::thread, then Thread::Thread will also be added automatically.
-#
-# It is important to note that the imported targets behave differently
-# than variables created by this module: multiple calls to
-# find_package(Boost) in the same directory or sub-directories with
-# different options (e.g. static or shared) will not override the
-# values of the targets created by the first call.
-#
-# Users may set these hints or results as cache entries. Projects
-# should not read these entries directly but instead use the above
-# result variables. Note that some hint names start in upper-case
-# "BOOST". One may specify these as environment variables if they are
-# not specified as CMake variables or cache entries.
-#
-# This module first searches for the Boost header files using the above
-# hint variables (excluding BOOST_LIBRARYDIR) and saves the result in
-# Boost_INCLUDE_DIR. Then it searches for requested component libraries
-# using the above hints (excluding BOOST_INCLUDEDIR and
-# Boost_ADDITIONAL_VERSIONS), "lib" directories near Boost_INCLUDE_DIR,
-# and the library name configuration settings below. It saves the
-# library directories in Boost_LIBRARY_DIR_DEBUG and
-# Boost_LIBRARY_DIR_RELEASE and individual library
-# locations in Boost_<C>_LIBRARY_DEBUG and Boost_<C>_LIBRARY_RELEASE.
-# When one changes settings used by previous searches in the same build
-# tree (excluding environment variables) this module discards previous
-# search results affected by the changes and searches again.
-#
-# Boost libraries come in many variants encoded in their file name.
-# Users or projects may tell this module which variant to find by
-# setting variables::
-#
-# Boost_USE_MULTITHREADED - Set to OFF to use the non-multithreaded
-# libraries ('mt' tag). Default is ON.
-# Boost_USE_STATIC_LIBS - Set to ON to force the use of the static
-# libraries. Default is OFF.
-# Boost_USE_STATIC_RUNTIME - Set to ON or OFF to specify whether to use
-# libraries linked statically to the C++ runtime
-# ('s' tag). Default is platform dependent.
-# Boost_USE_DEBUG_RUNTIME - Set to ON or OFF to specify whether to use
-# libraries linked to the MS debug C++ runtime
-# ('g' tag). Default is ON.
-# Boost_USE_DEBUG_PYTHON - Set to ON to use libraries compiled with a
-# debug Python build ('y' tag). Default is OFF.
-# Boost_USE_STLPORT - Set to ON to use libraries compiled with
-# STLPort ('p' tag). Default is OFF.
-# Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS
-# - Set to ON to use libraries compiled with
-# STLPort deprecated "native iostreams"
-# ('n' tag). Default is OFF.
-# Boost_COMPILER - Set to the compiler-specific library suffix
-# (e.g. "-gcc43"). Default is auto-computed
-# for the C++ compiler in use. A list may be
-# used if multiple compatible suffixes should
-# be tested for, in decreasing order of
-# preference.
-# Boost_THREADAPI - Suffix for "thread" component library name,
-# such as "pthread" or "win32". Names with
-# and without this suffix will both be tried.
-# Boost_NAMESPACE - Alternate namespace used to build boost with
-# e.g. if set to "myboost", will search for
-# myboost_thread instead of boost_thread.
-#
-# Other variables one may set to control this module are::
-#
-# Boost_DEBUG - Set to ON to enable debug output from FindBoost.
-# Please enable this before filing any bug report.
-# Boost_DETAILED_FAILURE_MSG
-# - Set to ON to add detailed information to the
-# failure message even when the REQUIRED option
-# is not given to the find_package call.
-# Boost_REALPATH - Set to ON to resolve symlinks for discovered
-# libraries to assist with packaging. For example,
-# the "system" component library may be resolved to
-# "/usr/lib/libboost_system.so.1.42.0" instead of
-# "/usr/lib/libboost_system.so". This does not
-# affect linking and should not be enabled unless
-# the user needs this information.
-# Boost_LIBRARY_DIR - Default value for Boost_LIBRARY_DIR_RELEASE and
-# Boost_LIBRARY_DIR_DEBUG.
-#
-# On Visual Studio and Borland compilers Boost headers request automatic
-# linking to corresponding libraries. This requires matching libraries
-# to be linked explicitly or available in the link library search path.
-# In this case setting Boost_USE_STATIC_LIBS to OFF may not achieve
-# dynamic linking. Boost automatic linking typically requests static
-# libraries with a few exceptions (such as Boost.Python). Use::
-#
-# add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
-#
-# to ask Boost to report information about automatic linking requests.
-#
-# Example to find Boost headers only::
-#
-# find_package(Boost 1.36.0)
-# if(Boost_FOUND)
-# include_directories(${Boost_INCLUDE_DIRS})
-# add_executable(foo foo.cc)
-# endif()
-#
-# Example to find Boost libraries and use imported targets::
-#
-# find_package(Boost 1.56 REQUIRED COMPONENTS
-# date_time filesystem iostreams)
-# add_executable(foo foo.cc)
-# target_link_libraries(foo Boost::date_time Boost::filesystem
-# Boost::iostreams)
-#
-# Example to find Boost headers and some *static* libraries::
-#
-# set(Boost_USE_STATIC_LIBS ON) # only find static libs
-# set(Boost_USE_MULTITHREADED ON)
-# set(Boost_USE_STATIC_RUNTIME OFF)
-# find_package(Boost 1.36.0 COMPONENTS date_time filesystem system ...)
-# if(Boost_FOUND)
-# include_directories(${Boost_INCLUDE_DIRS})
-# add_executable(foo foo.cc)
-# target_link_libraries(foo ${Boost_LIBRARIES})
-# endif()
-#
-# Boost CMake
-# ^^^^^^^^^^^
-#
-# If Boost was built using the boost-cmake project it provides a package
-# configuration file for use with find_package's Config mode. This
-# module looks for the package configuration file called
-# BoostConfig.cmake or boost-config.cmake and stores the result in cache
-# entry "Boost_DIR". If found, the package configuration file is loaded
-# and this module returns with no further action. See documentation of
-# the Boost CMake package configuration for details on what it provides.
-#
-# Set Boost_NO_BOOST_CMAKE to ON to disable the search for boost-cmake.
+#[=======================================================================[.rst:
+FindBoost
+---------
+
+Find Boost include dirs and libraries
+
+Use this module by invoking find_package with the form::
+
+ find_package(Boost
+ [version] [EXACT] # Minimum or EXACT version e.g. 1.67.0
+ [REQUIRED] # Fail with error if Boost is not found
+ [COMPONENTS <libs>...] # Boost libraries by their canonical name
+ # e.g. "date_time" for "libboost_date_time"
+ [OPTIONAL_COMPONENTS <libs>...]
+ # Optional Boost libraries by their canonical name)
+ ) # e.g. "date_time" for "libboost_date_time"
+
+This module finds headers and requested component libraries OR a CMake
+package configuration file provided by a "Boost CMake" build. For the
+latter case skip to the "Boost CMake" section below. For the former
+case results are reported in variables::
+
+ Boost_FOUND - True if headers and requested libraries were found
+ Boost_INCLUDE_DIRS - Boost include directories
+ Boost_LIBRARY_DIRS - Link directories for Boost libraries
+ Boost_LIBRARIES - Boost component libraries to be linked
+ Boost_<C>_FOUND - True if component <C> was found (<C> is upper-case)
+ Boost_<C>_LIBRARY - Libraries to link for component <C> (may include
+ target_link_libraries debug/optimized keywords)
+ Boost_VERSION_MACRO - BOOST_VERSION value from boost/version.hpp
+ Boost_VERSION_STRING - Boost version number in x.y.z format
+ Boost_VERSION - if CMP0093 NEW => same as Boost_VERSION_STRING
+ if CMP0093 OLD or unset => same as Boost_VERSION_MACRO
+ Boost_LIB_VERSION - Version string appended to library filenames
+ Boost_VERSION_MAJOR - Boost major version number (X in X.y.z)
+ alias: Boost_MAJOR_VERSION
+ Boost_VERSION_MINOR - Boost minor version number (Y in x.Y.z)
+ alias: Boost_MINOR_VERSION
+ Boost_VERSION_PATCH - Boost subminor version number (Z in x.y.Z)
+ alias: Boost_SUBMINOR_VERSION
+ Boost_VERSION_COUNT - Amount of version components (3)
+ Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows)
+ - Pass to add_definitions() to have diagnostic
+ information about Boost's automatic linking
+ displayed during compilation
+
+Note that Boost Python components require a Python version suffix
+(Boost 1.67 and later), e.g. ``python36`` or ``python27`` for the
+versions built against Python 3.6 and 2.7, respectively. This also
+applies to additional components using Python including
+``mpi_python`` and ``numpy``. Earlier Boost releases may use
+distribution-specific suffixes such as ``2``, ``3`` or ``2.7``.
+These may also be used as suffixes, but note that they are not
+portable.
+
+This module reads hints about search locations from variables::
+
+ BOOST_ROOT - Preferred installation prefix
+ (or BOOSTROOT)
+ BOOST_INCLUDEDIR - Preferred include directory e.g. <prefix>/include
+ BOOST_LIBRARYDIR - Preferred library directory e.g. <prefix>/lib
+ Boost_NO_SYSTEM_PATHS - Set to ON to disable searching in locations not
+ specified by these hint variables. Default is OFF.
+ Boost_ADDITIONAL_VERSIONS
+ - List of Boost versions not known to this module
+ (Boost install locations may contain the version)
+
+and saves search results persistently in CMake cache entries::
+
+ Boost_INCLUDE_DIR - Directory containing Boost headers
+ Boost_LIBRARY_DIR_RELEASE - Directory containing release Boost libraries
+ Boost_LIBRARY_DIR_DEBUG - Directory containing debug Boost libraries
+ Boost_<C>_LIBRARY_DEBUG - Component <C> library debug variant
+ Boost_<C>_LIBRARY_RELEASE - Component <C> library release variant
+
+The following :prop_tgt:`IMPORTED` targets are also defined::
+
+ Boost::headers - Target for header-only dependencies
+ (Boost include directory)
+ alias: Boost::boost
+ Boost::<C> - Target for specific component dependency
+ (shared or static library); <C> is lower-
+ case
+ Boost::diagnostic_definitions - interface target to enable diagnostic
+ information about Boost's automatic linking
+ during compilation (adds BOOST_LIB_DIAGNOSTIC)
+ Boost::disable_autolinking - interface target to disable automatic
+ linking with MSVC (adds BOOST_ALL_NO_LIB)
+ Boost::dynamic_linking - interface target to enable dynamic linking
+ linking with MSVC (adds BOOST_ALL_DYN_LINK)
+
+Implicit dependencies such as ``Boost::filesystem`` requiring
+``Boost::system`` will be automatically detected and satisfied, even
+if system is not specified when using :command:`find_package` and if
+``Boost::system`` is not added to :command:`target_link_libraries`. If using
+``Boost::thread``, then ``Threads::Threads`` will also be added automatically.
+
+It is important to note that the imported targets behave differently
+than variables created by this module: multiple calls to
+:command:`find_package(Boost)` in the same directory or sub-directories with
+different options (e.g. static or shared) will not override the
+values of the targets created by the first call.
+
+Users may set these hints or results as ``CACHE`` entries. Projects
+should not read these entries directly but instead use the above
+result variables. Note that some hint names start in upper-case
+"BOOST". One may specify these as environment variables if they are
+not specified as CMake variables or cache entries.
+
+This module first searches for the ``Boost`` header files using the above
+hint variables (excluding ``BOOST_LIBRARYDIR``) and saves the result in
+``Boost_INCLUDE_DIR``. Then it searches for requested component libraries
+using the above hints (excluding ``BOOST_INCLUDEDIR`` and
+``Boost_ADDITIONAL_VERSIONS``), "lib" directories near ``Boost_INCLUDE_DIR``,
+and the library name configuration settings below. It saves the
+library directories in ``Boost_LIBRARY_DIR_DEBUG`` and
+``Boost_LIBRARY_DIR_RELEASE`` and individual library
+locations in ``Boost_<C>_LIBRARY_DEBUG`` and ``Boost_<C>_LIBRARY_RELEASE``.
+When one changes settings used by previous searches in the same build
+tree (excluding environment variables) this module discards previous
+search results affected by the changes and searches again.
+
+Boost libraries come in many variants encoded in their file name.
+Users or projects may tell this module which variant to find by
+setting variables::
+
+ Boost_USE_DEBUG_LIBS - Set to ON or OFF to specify whether to search
+ and use the debug libraries. Default is ON.
+ Boost_USE_RELEASE_LIBS - Set to ON or OFF to specify whether to search
+ and use the release libraries. Default is ON.
+ Boost_USE_MULTITHREADED - Set to OFF to use the non-multithreaded
+ libraries ('mt' tag). Default is ON.
+ Boost_USE_STATIC_LIBS - Set to ON to force the use of the static
+ libraries. Default is OFF.
+ Boost_USE_STATIC_RUNTIME - Set to ON or OFF to specify whether to use
+ libraries linked statically to the C++ runtime
+ ('s' tag). Default is platform dependent.
+ Boost_USE_DEBUG_RUNTIME - Set to ON or OFF to specify whether to use
+ libraries linked to the MS debug C++ runtime
+ ('g' tag). Default is ON.
+ Boost_USE_DEBUG_PYTHON - Set to ON to use libraries compiled with a
+ debug Python build ('y' tag). Default is OFF.
+ Boost_USE_STLPORT - Set to ON to use libraries compiled with
+ STLPort ('p' tag). Default is OFF.
+ Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS
+ - Set to ON to use libraries compiled with
+ STLPort deprecated "native iostreams"
+ ('n' tag). Default is OFF.
+ Boost_COMPILER - Set to the compiler-specific library suffix
+ (e.g. "-gcc43"). Default is auto-computed
+ for the C++ compiler in use. A list may be
+ used if multiple compatible suffixes should
+ be tested for, in decreasing order of
+ preference.
+ Boost_ARCHITECTURE - Set to the architecture-specific library suffix
+ (e.g. "-x64"). Default is auto-computed for the
+ C++ compiler in use.
+ Boost_THREADAPI - Suffix for "thread" component library name,
+ such as "pthread" or "win32". Names with
+ and without this suffix will both be tried.
+ Boost_NAMESPACE - Alternate namespace used to build boost with
+ e.g. if set to "myboost", will search for
+ myboost_thread instead of boost_thread.
+
+Other variables one may set to control this module are::
+
+ Boost_DEBUG - Set to ON to enable debug output from FindBoost.
+ Please enable this before filing any bug report.
+ Boost_REALPATH - Set to ON to resolve symlinks for discovered
+ libraries to assist with packaging. For example,
+ the "system" component library may be resolved to
+ "/usr/lib/libboost_system.so.1.67.0" instead of
+ "/usr/lib/libboost_system.so". This does not
+ affect linking and should not be enabled unless
+ the user needs this information.
+ Boost_LIBRARY_DIR - Default value for Boost_LIBRARY_DIR_RELEASE and
+ Boost_LIBRARY_DIR_DEBUG.
+
+On Visual Studio and Borland compilers Boost headers request automatic
+linking to corresponding libraries. This requires matching libraries
+to be linked explicitly or available in the link library search path.
+In this case setting ``Boost_USE_STATIC_LIBS`` to ``OFF`` may not achieve
+dynamic linking. Boost automatic linking typically requests static
+libraries with a few exceptions (such as ``Boost.Python``). Use::
+
+ add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
+
+to ask Boost to report information about automatic linking requests.
+
+Example to find Boost headers only::
+
+ find_package(Boost 1.36.0)
+ if(Boost_FOUND)
+ include_directories(${Boost_INCLUDE_DIRS})
+ add_executable(foo foo.cc)
+ endif()
+
+Example to find Boost libraries and use imported targets::
+
+ find_package(Boost 1.56 REQUIRED COMPONENTS
+ date_time filesystem iostreams)
+ add_executable(foo foo.cc)
+ target_link_libraries(foo Boost::date_time Boost::filesystem
+ Boost::iostreams)
+
+Example to find Boost Python 3.6 libraries and use imported targets::
+
+ find_package(Boost 1.67 REQUIRED COMPONENTS
+ python36 numpy36)
+ add_executable(foo foo.cc)
+ target_link_libraries(foo Boost::python36 Boost::numpy36)
+
+Example to find Boost headers and some *static* (release only) libraries::
+
+ set(Boost_USE_STATIC_LIBS ON) # only find static libs
+ set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and
+ set(Boost_USE_RELEASE_LIBS ON) # only find release libs
+ set(Boost_USE_MULTITHREADED ON)
+ set(Boost_USE_STATIC_RUNTIME OFF)
+ find_package(Boost 1.66.0 COMPONENTS date_time filesystem system ...)
+ if(Boost_FOUND)
+ include_directories(${Boost_INCLUDE_DIRS})
+ add_executable(foo foo.cc)
+ target_link_libraries(foo ${Boost_LIBRARIES})
+ endif()
+
+Boost CMake
+^^^^^^^^^^^
+
+If Boost was built using the boost-cmake project or from Boost 1.70.0 on
+it provides a package configuration file for use with find_package's config mode.
+This module looks for the package configuration file called
+``BoostConfig.cmake`` or ``boost-config.cmake`` and stores the result in
+``CACHE`` entry "Boost_DIR". If found, the package configuration file is loaded
+and this module returns with no further action. See documentation of
+the Boost CMake package configuration for details on what it provides.
+
+Set ``Boost_NO_BOOST_CMAKE`` to ``ON``, to disable the search for boost-cmake.
+#]=======================================================================]
+
+# The FPHSA helper provides standard way of reporting final search results to
+# the user including the version and component checks.
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+
+# Save project's policies
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
+function(_boost_get_existing_target component target_var)
+ set(names "${component}")
+ if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9])?$")
+ # handle pythonXY and numpyXY versioned components and also python X.Y, mpi_python etc.
+ list(APPEND names
+ "${CMAKE_MATCH_1}${CMAKE_MATCH_2}" # python
+ "${CMAKE_MATCH_1}${CMAKE_MATCH_2}${CMAKE_MATCH_3}" # pythonX
+ "${CMAKE_MATCH_1}${CMAKE_MATCH_2}${CMAKE_MATCH_3}${CMAKE_MATCH_4}" #pythonXY
+ )
+ endif()
+ # https://github.com/boost-cmake/boost-cmake uses boost::file_system etc.
+ # So handle similar constructions of target names
+ string(TOLOWER "${component}" lower_component)
+ list(APPEND names "${lower_component}")
+ foreach(prefix Boost boost)
+ foreach(name IN LISTS names)
+ if(TARGET "${prefix}::${name}")
+ # The target may be an INTERFACE library that wraps around a single other
+ # target for compatibility. Unwrap this layer so we can extract real info.
+ if("${name}" MATCHES "^(python|numpy|mpi_python)([1-9])([0-9])$")
+ set(name_nv "${CMAKE_MATCH_1}")
+ if(TARGET "${prefix}::${name_nv}")
+ get_property(type TARGET "${prefix}::${name}" PROPERTY TYPE)
+ if(type STREQUAL "INTERFACE_LIBRARY")
+ get_property(lib TARGET "${prefix}::${name}" PROPERTY INTERFACE_LINK_LIBRARIES)
+ if("${lib}" STREQUAL "${prefix}::${name_nv}")
+ set(${target_var} "${prefix}::${name_nv}" PARENT_SCOPE)
+ return()
+ endif()
+ endif()
+ endif()
+ endif()
+ set(${target_var} "${prefix}::${name}" PARENT_SCOPE)
+ return()
+ endif()
+ endforeach()
+ endforeach()
+ set(${target_var} "" PARENT_SCOPE)
+endfunction()
+
+function(_boost_get_canonical_target_name component target_var)
+ string(TOLOWER "${component}" component)
+ if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9])?$")
+ # handle pythonXY and numpyXY versioned components and also python X.Y, mpi_python etc.
+ set(${target_var} "Boost::${CMAKE_MATCH_1}${CMAKE_MATCH_2}" PARENT_SCOPE)
+ else()
+ set(${target_var} "Boost::${component}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+macro(_boost_set_in_parent_scope name value)
+ # Set a variable in parent scope and make it visibile in current scope
+ set(${name} "${value}" PARENT_SCOPE)
+ set(${name} "${value}")
+endmacro()
+
+macro(_boost_set_if_unset name value)
+ if(NOT ${name})
+ _boost_set_in_parent_scope(${name} "${value}")
+ endif()
+endmacro()
+
+macro(_boost_set_cache_if_unset name value)
+ if(NOT ${name})
+ set(${name} "${value}" CACHE STRING "" FORCE)
+ endif()
+endmacro()
+
+macro(_boost_append_include_dir target)
+ get_target_property(inc "${target}" INTERFACE_INCLUDE_DIRECTORIES)
+ if(inc)
+ list(APPEND include_dirs "${inc}")
+ endif()
+endmacro()
+
+function(_boost_set_legacy_variables_from_config)
+ # Set legacy variables for compatibility if not set
+ set(include_dirs "")
+ set(library_dirs "")
+ set(libraries "")
+ # Header targets Boost::headers or Boost::boost
+ foreach(comp headers boost)
+ _boost_get_existing_target(${comp} target)
+ if(target)
+ _boost_append_include_dir("${target}")
+ endif()
+ endforeach()
+ # Library targets
+ foreach(comp IN LISTS Boost_FIND_COMPONENTS)
+ string(TOUPPER ${comp} uppercomp)
+ # Overwrite if set
+ _boost_set_in_parent_scope(Boost_${uppercomp}_FOUND "${Boost_${comp}_FOUND}")
+ if(Boost_${comp}_FOUND)
+ _boost_get_existing_target(${comp} target)
+ if(NOT target)
+ if(Boost_DEBUG OR Boost_VERBOSE)
+ message(WARNING "Could not find imported target for required component '${comp}'. Legacy variables for this component might be missing. Refer to the documentation of your Boost installation for help on variables to use.")
+ endif()
+ continue()
+ endif()
+ _boost_append_include_dir("${target}")
+ _boost_set_if_unset(Boost_${uppercomp}_LIBRARY "${target}")
+ _boost_set_if_unset(Boost_${uppercomp}_LIBRARIES "${target}") # Very old legacy variable
+ list(APPEND libraries "${target}")
+ get_property(type TARGET "${target}" PROPERTY TYPE)
+ if(NOT type STREQUAL "INTERFACE_LIBRARY")
+ foreach(cfg RELEASE DEBUG)
+ get_target_property(lib ${target} IMPORTED_LOCATION_${cfg})
+ if(lib)
+ get_filename_component(lib_dir "${lib}" DIRECTORY)
+ list(APPEND library_dirs ${lib_dir})
+ _boost_set_cache_if_unset(Boost_${uppercomp}_LIBRARY_${cfg} "${lib}")
+ endif()
+ endforeach()
+ elseif(Boost_DEBUG OR Boost_VERBOSE)
+ # For projects using only the Boost::* targets this warning can be safely ignored.
+ message(WARNING "Imported target '${target}' for required component '${comp}' has no artifact. Legacy variables for this component might be missing. Refer to the documentation of your Boost installation for help on variables to use.")
+ endif()
+ _boost_get_canonical_target_name("${comp}" canonical_target)
+ if(NOT TARGET "${canonical_target}")
+ add_library("${canonical_target}" INTERFACE IMPORTED)
+ target_link_libraries("${canonical_target}" INTERFACE "${target}")
+ endif()
+ endif()
+ endforeach()
+ list(REMOVE_DUPLICATES include_dirs)
+ list(REMOVE_DUPLICATES library_dirs)
+ _boost_set_if_unset(Boost_INCLUDE_DIRS "${include_dirs}")
+ _boost_set_if_unset(Boost_LIBRARY_DIRS "${library_dirs}")
+ _boost_set_if_unset(Boost_LIBRARIES "${libraries}")
+ _boost_set_if_unset(Boost_VERSION_STRING "${Boost_VERSION_MAJOR}.${Boost_VERSION_MINOR}.${Boost_VERSION_PATCH}")
+ find_path(Boost_INCLUDE_DIR
+ NAMES boost/version.hpp boost/config.hpp
+ HINTS ${Boost_INCLUDE_DIRS}
+ NO_DEFAULT_PATH
+ )
+ if(NOT Boost_VERSION_MACRO OR NOT Boost_LIB_VERSION)
+ set(version_file ${Boost_INCLUDE_DIR}/boost/version.hpp)
+ if(EXISTS "${version_file}")
+ file(STRINGS "${version_file}" contents REGEX "#define BOOST_(LIB_)?VERSION ")
+ if(contents MATCHES "#define BOOST_VERSION ([0-9]+)")
+ _boost_set_if_unset(Boost_VERSION_MACRO "${CMAKE_MATCH_1}")
+ endif()
+ if(contents MATCHES "#define BOOST_LIB_VERSION \"([0-9_]+)\"")
+ _boost_set_if_unset(Boost_LIB_VERSION "${CMAKE_MATCH_1}")
+ endif()
+ endif()
+ endif()
+ _boost_set_if_unset(Boost_MAJOR_VERSION ${Boost_VERSION_MAJOR})
+ _boost_set_if_unset(Boost_MINOR_VERSION ${Boost_VERSION_MINOR})
+ _boost_set_if_unset(Boost_SUBMINOR_VERSION ${Boost_VERSION_PATCH})
+ if(WIN32)
+ _boost_set_if_unset(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC")
+ endif()
+ if(NOT TARGET Boost::headers)
+ add_library(Boost::headers INTERFACE IMPORTED)
+ target_include_directories(Boost::headers INTERFACE ${Boost_INCLUDE_DIRS})
+ endif()
+ # Legacy targets w/o functionality as all handled by defined targets
+ foreach(lib diagnostic_definitions disable_autolinking dynamic_linking)
+ if(NOT TARGET Boost::${lib})
+ add_library(Boost::${lib} INTERFACE IMPORTED)
+ endif()
+ endforeach()
+ if(NOT TARGET Boost::boost)
+ add_library(Boost::boost INTERFACE IMPORTED)
+ target_link_libraries(Boost::boost INTERFACE Boost::headers)
+ endif()
+endfunction()
#-------------------------------------------------------------------------------
-# Before we go searching, check whether boost-cmake is available, unless the
-# user specifically asked NOT to search for boost-cmake.
+# Before we go searching, check whether a boost cmake package is available, unless
+# the user specifically asked NOT to search for one.
#
# If Boost_DIR is set, this behaves as any find_package call would. If not,
# it looks at BOOST_ROOT and BOOSTROOT to find Boost.
@@ -232,14 +443,33 @@ if (NOT Boost_NO_BOOST_CMAKE)
find_package(Boost QUIET NO_MODULE)
mark_as_advanced(Boost_DIR)
- # If we found boost-cmake, then we're done. Print out what we found.
+ # If we found a boost cmake package, then we're done. Print out what we found.
# Otherwise let the rest of the module try to find it.
- if (Boost_FOUND)
- message("Boost ${Boost_FIND_VERSION} found.")
- if (Boost_FIND_COMPONENTS)
- message("Found Boost components:")
- message(" ${Boost_FIND_COMPONENTS}")
+ if(Boost_FOUND)
+ # Convert component found variables to standard variables if required
+ # Necessary for legacy boost-cmake and 1.70 builtin BoostConfig
+ if(Boost_FIND_COMPONENTS)
+ # Ignore the meta-component "ALL", introduced by Boost 1.73
+ list(REMOVE_ITEM Boost_FIND_COMPONENTS "ALL")
+
+ foreach(_comp IN LISTS Boost_FIND_COMPONENTS)
+ if(DEFINED Boost_${_comp}_FOUND)
+ continue()
+ endif()
+ string(TOUPPER ${_comp} _uppercomp)
+ if(DEFINED Boost${_comp}_FOUND) # legacy boost-cmake project
+ set(Boost_${_comp}_FOUND ${Boost${_comp}_FOUND})
+ elseif(DEFINED Boost_${_uppercomp}_FOUND) # Boost 1.70
+ set(Boost_${_comp}_FOUND ${Boost_${_uppercomp}_FOUND})
+ endif()
+ endforeach()
endif()
+
+ find_package_handle_standard_args(Boost HANDLE_COMPONENTS CONFIG_MODE)
+ _boost_set_legacy_variables_from_config()
+
+ # Restore project's policies
+ cmake_policy(POP)
return()
endif()
endif()
@@ -249,6 +479,56 @@ endif()
# FindBoost functions & macros
#
+#
+# Print debug text if Boost_DEBUG is set.
+# Call example:
+# _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "debug message")
+#
+function(_Boost_DEBUG_PRINT file line text)
+ if(Boost_DEBUG)
+ message(STATUS "[ ${file}:${line} ] ${text}")
+ endif()
+endfunction()
+
+#
+# _Boost_DEBUG_PRINT_VAR(file line variable_name [ENVIRONMENT]
+# [SOURCE "short explanation of origin of var value"])
+#
+# ENVIRONMENT - look up environment variable instead of CMake variable
+#
+# Print variable name and its value if Boost_DEBUG is set.
+# Call example:
+# _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" BOOST_ROOT)
+#
+function(_Boost_DEBUG_PRINT_VAR file line name)
+ if(Boost_DEBUG)
+ cmake_parse_arguments(_args "ENVIRONMENT" "SOURCE" "" ${ARGN})
+
+ unset(source)
+ if(_args_SOURCE)
+ set(source " (${_args_SOURCE})")
+ endif()
+
+ if(_args_ENVIRONMENT)
+ if(DEFINED ENV{${name}})
+ set(value "\"$ENV{${name}}\"")
+ else()
+ set(value "<unset>")
+ endif()
+ set(_name "ENV{${name}}")
+ else()
+ if(DEFINED "${name}")
+ set(value "\"${${name}}\"")
+ else()
+ set(value "<unset>")
+ endif()
+ set(_name "${name}")
+ endif()
+
+ _Boost_DEBUG_PRINT("${file}" "${line}" "${_name} = ${value}${source}")
+ endif()
+endfunction()
+
############################################
#
# Check the existence of the libraries.
@@ -264,13 +544,14 @@ endif()
macro(_Boost_ADJUST_LIB_VARS basename)
if(Boost_INCLUDE_DIR )
if(Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
- # if the generator supports configuration types then set
- # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
- if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
+ # if the generator is multi-config or if CMAKE_BUILD_TYPE is set for
+ # single-config generators, set optimized and debug libraries
+ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if(_isMultiConfig OR CMAKE_BUILD_TYPE)
set(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
else()
- # if there are no configuration types and CMAKE_BUILD_TYPE has no value
- # then just use the release libraries
+ # For single-config generators where CMAKE_BUILD_TYPE has no value,
+ # just use the release libraries
set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
endif()
# FIXME: This probably should be set for both cases
@@ -292,13 +573,17 @@ macro(_Boost_ADJUST_LIB_VARS basename)
endif()
# If the debug & release library ends up being the same, omit the keywords
- if(${Boost_${basename}_LIBRARY_RELEASE} STREQUAL ${Boost_${basename}_LIBRARY_DEBUG})
+ if("${Boost_${basename}_LIBRARY_RELEASE}" STREQUAL "${Boost_${basename}_LIBRARY_DEBUG}")
set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE} )
endif()
if(Boost_${basename}_LIBRARY AND Boost_${basename}_HEADER)
set(Boost_${basename}_FOUND ON)
+ if("x${basename}" STREQUAL "xTHREAD" AND NOT TARGET Threads::Threads)
+ string(APPEND Boost_ERROR_REASON_THREAD " (missing dependency: Threads)")
+ set(Boost_THREAD_FOUND OFF)
+ endif()
endif()
endif()
@@ -361,30 +646,27 @@ macro(_Boost_FIND_LIBRARY var build_type)
# If Boost_LIBRARY_DIR_[RELEASE,DEBUG] is known then search only there.
if(Boost_LIBRARY_DIR_${build_type})
set(_boost_LIBRARY_SEARCH_DIRS_${build_type} ${Boost_LIBRARY_DIR_${build_type}} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
- if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- " Boost_LIBRARY_DIR_${build_type} = ${Boost_LIBRARY_DIR_${build_type}}"
- " _boost_LIBRARY_SEARCH_DIRS_${build_type} = ${_boost_LIBRARY_SEARCH_DIRS_${build_type}}")
- endif()
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}"
+ "Boost_LIBRARY_DIR_${build_type}")
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}"
+ "_boost_LIBRARY_SEARCH_DIRS_${build_type}")
endif()
endmacro()
#-------------------------------------------------------------------------------
-#
-# Runs compiler with "-dumpversion" and parses major/minor
-# version with a regex.
-#
-function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION)
+# Convert CMAKE_CXX_COMPILER_VERSION to boost compiler suffix version.
+function(_Boost_COMPILER_DUMPVERSION _OUTPUT_VERSION _OUTPUT_VERSION_MAJOR _OUTPUT_VERSION_MINOR)
+ string(REGEX REPLACE "([0-9]+)\\.([0-9]+)(\\.[0-9]+)?" "\\1"
+ _boost_COMPILER_VERSION_MAJOR "${CMAKE_CXX_COMPILER_VERSION}")
+ string(REGEX REPLACE "([0-9]+)\\.([0-9]+)(\\.[0-9]+)?" "\\2"
+ _boost_COMPILER_VERSION_MINOR "${CMAKE_CXX_COMPILER_VERSION}")
- exec_program(${CMAKE_CXX_COMPILER}
- ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
- OUTPUT_VARIABLE _boost_COMPILER_VERSION
- )
- string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
- _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION})
+ set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}${_boost_COMPILER_VERSION_MINOR}")
set(${_OUTPUT_VERSION} ${_boost_COMPILER_VERSION} PARENT_SCOPE)
+ set(${_OUTPUT_VERSION_MAJOR} ${_boost_COMPILER_VERSION_MAJOR} PARENT_SCOPE)
+ set(${_OUTPUT_VERSION_MINOR} ${_boost_COMPILER_VERSION_MINOR} PARENT_SCOPE)
endfunction()
#
@@ -419,9 +701,7 @@ endfunction()
# Guesses Boost's compiler prefix used in built library names
# Returns the guess by setting the variable pointed to by _ret
function(_Boost_GUESS_COMPILER_PREFIX _ret)
- if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel"
- OR CMAKE_CXX_COMPILER MATCHES "icl"
- OR CMAKE_CXX_COMPILER MATCHES "icpc")
+ if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xIntel")
if(WIN32)
set (_boost_COMPILER "-iw")
else()
@@ -429,21 +709,20 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret)
endif()
elseif (GHSMULTI)
set(_boost_COMPILER "-ghs")
- elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
- if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10)
- set(_boost_COMPILER "-vc141;-vc140")
- elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
- set(_boost_COMPILER "-vc140")
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18)
- set(_boost_COMPILER "-vc120")
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
- set(_boost_COMPILER "-vc110")
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
- set(_boost_COMPILER "-vc100")
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15)
- set(_boost_COMPILER "-vc90")
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
- set(_boost_COMPILER "-vc80")
+ elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+ if(MSVC_TOOLSET_VERSION GREATER_EQUAL 150)
+ # Not yet known.
+ set(_boost_COMPILER "")
+ elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 140)
+ # MSVC toolset 14.x versions are forward compatible.
+ set(_boost_COMPILER "")
+ foreach(v 9 8 7 6 5 4 3 2 1 0)
+ if(MSVC_TOOLSET_VERSION GREATER_EQUAL 14${v})
+ list(APPEND _boost_COMPILER "-vc14${v}")
+ endif()
+ endforeach()
+ elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 80)
+ set(_boost_COMPILER "-vc${MSVC_TOOLSET_VERSION}")
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.10)
set(_boost_COMPILER "-vc71")
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) # Good luck!
@@ -451,6 +730,12 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret)
else() # VS 6.0 Good luck!
set(_boost_COMPILER "-vc6") # yes, this is correct
endif()
+
+ if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang")
+ string(REPLACE "." ";" VERSION_LIST "${CMAKE_CXX_COMPILER_VERSION}")
+ list(GET VERSION_LIST 0 CLANG_VERSION_MAJOR)
+ set(_boost_COMPILER "-clangw${CLANG_VERSION_MAJOR};${_boost_COMPILER}")
+ endif()
elseif (BORLAND)
set(_boost_COMPILER "-bcb")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
@@ -458,44 +743,52 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "XL")
set(_boost_COMPILER "-xlc")
elseif (MINGW)
- if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
+ if(Boost_VERSION_STRING VERSION_LESS 1.34)
set(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34
else()
- _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
+ _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION _boost_COMPILER_VERSION_MAJOR _boost_COMPILER_VERSION_MINOR)
set(_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}")
endif()
elseif (UNIX)
- if (CMAKE_COMPILER_IS_GNUCXX)
- if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34)
+ _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION _boost_COMPILER_VERSION_MAJOR _boost_COMPILER_VERSION_MINOR)
+ if(NOT Boost_VERSION_STRING VERSION_LESS 1.69.0)
+ # From GCC 5 and clang 4, versioning changes and minor becomes patch.
+ # For those compilers, patch is exclude from compiler tag in Boost 1.69+ library naming.
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND _boost_COMPILER_VERSION_MAJOR VERSION_GREATER 4)
+ set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}")
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND _boost_COMPILER_VERSION_MAJOR VERSION_GREATER 3)
+ set(_boost_COMPILER_VERSION "${_boost_COMPILER_VERSION_MAJOR}")
+ endif()
+ endif()
+
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ if(Boost_VERSION_STRING VERSION_LESS 1.34)
set(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34
else()
- _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION)
# Determine which version of GCC we have.
if(APPLE)
- if(Boost_MINOR_VERSION)
- if(${Boost_MINOR_VERSION} GREATER 35)
- # In Boost 1.36.0 and newer, the mangled compiler name used
- # on Mac OS X/Darwin is "xgcc".
- set(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
- else()
- # In Boost <= 1.35.0, there is no mangled compiler name for
- # the Mac OS X/Darwin version of GCC.
- set(_boost_COMPILER "")
- endif()
- else()
- # We don't know the Boost version, so assume it's
- # pre-1.36.0.
+ if(Boost_VERSION_STRING VERSION_LESS 1.36.0)
+ # In Boost <= 1.35.0, there is no mangled compiler name for
+ # the macOS/Darwin version of GCC.
set(_boost_COMPILER "")
+ else()
+ # In Boost 1.36.0 and newer, the mangled compiler name used
+ # on macOS/Darwin is "xgcc".
+ set(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}")
endif()
else()
set(_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}")
endif()
endif()
- endif ()
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ # TODO: Find out any Boost version constraints vs clang support.
+ set(_boost_COMPILER "-clang${_boost_COMPILER_VERSION}")
+ endif()
else()
- # TODO at least Boost_DEBUG here?
set(_boost_COMPILER "")
endif()
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}"
+ "_boost_COMPILER" SOURCE "guessed")
set(${_ret} ${_boost_COMPILER} PARENT_SCOPE)
endfunction()
@@ -533,125 +826,131 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
# - Indent
# s;^set(; set(;;
# - Add conditionals
- # s;Scanning /path/to/boost/sources/boost_\(.*\)_\(.*\)_\(.*); elseif(NOT Boost_VERSION VERSION_LESS \10\20\3 AND Boost_VERSION VERSION_LESS xxxx);
+ # s;Scanning /path/to/boost/sources/boost_\(.*\)_\(.*\)_\(.*); elseif(NOT Boost_VERSION_STRING VERSION_LESS \1\.\2\.\3 AND Boost_VERSION_STRING VERSION_LESS xxxx);
#
# This results in the logic seen below, but will require the xxxx
# replacing with the following Boost release version (or the next
# minor version to be released, e.g. 1.59 was the latest at the time
- # of writing, making 1.60 the next, so 106000 is the needed version
- # number). Identical consecutive releases were then merged together
- # by updating the end range of the first block and removing the
- # following redundant blocks.
+ # of writing, making 1.60 the next. Identical consecutive releases
+ # were then merged together by updating the end range of the first
+ # block and removing the following redundant blocks.
#
# Running the script against all historical releases should be
# required only if the BoostScanDeps.cmake script logic is changed.
# The addition of a new release should only require it to be run
# against the new release.
+
+ # Handle Python version suffixes
+ if(component MATCHES "^(python|mpi_python|numpy)([0-9][0-9]?|[0-9]\\.[0-9])\$")
+ set(component "${CMAKE_MATCH_1}")
+ set(component_python_version "${CMAKE_MATCH_2}")
+ endif()
+
set(_Boost_IMPORTED_TARGETS TRUE)
- if(Boost_VERSION VERSION_LESS 103300)
- message(WARNING "Imported targets and dependency information not available for Boost version ${Boost_VERSION} (all versions older than 1.33)")
+ if(Boost_VERSION_STRING AND Boost_VERSION_STRING VERSION_LESS 1.33.0)
+ message(WARNING "Imported targets and dependency information not available for Boost version ${Boost_VERSION_STRING} (all versions older than 1.33)")
set(_Boost_IMPORTED_TARGETS FALSE)
- elseif(NOT Boost_VERSION VERSION_LESS 103300 AND Boost_VERSION VERSION_LESS 103500)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.33.0 AND Boost_VERSION_STRING VERSION_LESS 1.35.0)
set(_Boost_IOSTREAMS_DEPENDENCIES regex thread)
set(_Boost_REGEX_DEPENDENCIES thread)
set(_Boost_WAVE_DEPENDENCIES filesystem thread)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 103500 AND Boost_VERSION VERSION_LESS 103600)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.35.0 AND Boost_VERSION_STRING VERSION_LESS 1.36.0)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_WAVE_DEPENDENCIES filesystem system thread)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 103600 AND Boost_VERSION VERSION_LESS 103800)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.36.0 AND Boost_VERSION_STRING VERSION_LESS 1.38.0)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_WAVE_DEPENDENCIES filesystem system thread)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 103800 AND Boost_VERSION VERSION_LESS 104300)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.38.0 AND Boost_VERSION_STRING VERSION_LESS 1.43.0)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_THREAD_DEPENDENCIES date_time)
set(_Boost_WAVE_DEPENDENCIES filesystem system thread date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 104300 AND Boost_VERSION VERSION_LESS 104400)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.43.0 AND Boost_VERSION_STRING VERSION_LESS 1.44.0)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_THREAD_DEPENDENCIES date_time)
set(_Boost_WAVE_DEPENDENCIES filesystem system thread date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 104400 AND Boost_VERSION VERSION_LESS 104500)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.44.0 AND Boost_VERSION_STRING VERSION_LESS 1.45.0)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random serialization)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_THREAD_DEPENDENCIES date_time)
set(_Boost_WAVE_DEPENDENCIES serialization filesystem system thread date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 104500 AND Boost_VERSION VERSION_LESS 104700)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.45.0 AND Boost_VERSION_STRING VERSION_LESS 1.47.0)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_THREAD_DEPENDENCIES date_time)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 104700 AND Boost_VERSION VERSION_LESS 104800)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.47.0 AND Boost_VERSION_STRING VERSION_LESS 1.48.0)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_THREAD_DEPENDENCIES date_time)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 104800 AND Boost_VERSION VERSION_LESS 105000)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.48.0 AND Boost_VERSION_STRING VERSION_LESS 1.50.0)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_THREAD_DEPENDENCIES date_time)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 105000 AND Boost_VERSION VERSION_LESS 105300)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.50.0 AND Boost_VERSION_STRING VERSION_LESS 1.53.0)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 105300 AND Boost_VERSION VERSION_LESS 105400)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.53.0 AND Boost_VERSION_STRING VERSION_LESS 1.54.0)
set(_Boost_ATOMIC_DEPENDENCIES thread chrono system date_time)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
set(_Boost_IOSTREAMS_DEPENDENCIES regex)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 105400 AND Boost_VERSION VERSION_LESS 105500)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.54.0 AND Boost_VERSION_STRING VERSION_LESS 1.55.0)
set(_Boost_ATOMIC_DEPENDENCIES thread chrono system date_time)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
@@ -659,12 +958,12 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 105500 AND Boost_VERSION VERSION_LESS 105600)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.55.0 AND Boost_VERSION_STRING VERSION_LESS 1.56.0)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_COROUTINE_DEPENDENCIES context system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
@@ -672,12 +971,12 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l regex random)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 105600 AND Boost_VERSION VERSION_LESS 105900)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.56.0 AND Boost_VERSION_STRING VERSION_LESS 1.59.0)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_COROUTINE_DEPENDENCIES context system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
@@ -685,13 +984,13 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_RANDOM_DEPENDENCIES system)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 105900 AND Boost_VERSION VERSION_LESS 106000)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.59.0 AND Boost_VERSION_STRING VERSION_LESS 1.60.0)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_COROUTINE_DEPENDENCIES context system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
@@ -699,13 +998,13 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
set(_Boost_LOG_DEPENDENCIES log_setup date_time system filesystem thread regex chrono atomic)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_RANDOM_DEPENDENCIES system)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 106000 AND Boost_VERSION VERSION_LESS 106100)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.60.0 AND Boost_VERSION_STRING VERSION_LESS 1.61.0)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_COROUTINE_DEPENDENCIES context system)
set(_Boost_FILESYSTEM_DEPENDENCIES system)
@@ -713,13 +1012,13 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_RANDOM_DEPENDENCIES system)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_TIMER_DEPENDENCIES chrono system)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 106100 AND Boost_VERSION VERSION_LESS 106200)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.61.0 AND Boost_VERSION_STRING VERSION_LESS 1.62.0)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time)
set(_Boost_COROUTINE_DEPENDENCIES context system)
@@ -728,12 +1027,12 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_RANDOM_DEPENDENCIES system)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 106200 AND Boost_VERSION VERSION_LESS 106300)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.62.0 AND Boost_VERSION_STRING VERSION_LESS 1.63.0)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time)
set(_Boost_COROUTINE_DEPENDENCIES context system)
@@ -743,12 +1042,12 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_RANDOM_DEPENDENCIES system)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- elseif(NOT Boost_VERSION VERSION_LESS 106300 AND Boost_VERSION VERSION_LESS 106500)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.63.0 AND Boost_VERSION_STRING VERSION_LESS 1.65.0)
set(_Boost_CHRONO_DEPENDENCIES system)
set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time)
set(_Boost_COROUTINE_DEPENDENCIES context system)
@@ -759,32 +1058,107 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
set(_Boost_RANDOM_DEPENDENCIES system)
set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- else()
- if(NOT Boost_VERSION VERSION_LESS 106500)
- set(_Boost_CHRONO_DEPENDENCIES system)
- set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time)
- set(_Boost_COROUTINE_DEPENDENCIES context system)
- set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time)
- set(_Boost_FILESYSTEM_DEPENDENCIES system)
- set(_Boost_IOSTREAMS_DEPENDENCIES regex)
- set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
- set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
- set(_Boost_MPI_DEPENDENCIES serialization)
- set(_Boost_MPI_PYTHON_DEPENDENCIES python mpi serialization)
- set(_Boost_NUMPY_DEPENDENCIES python)
- set(_Boost_RANDOM_DEPENDENCIES system)
- set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
- set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
- set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- endif()
- if(NOT Boost_VERSION VERSION_LESS 106600)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.65.0 AND Boost_VERSION_STRING VERSION_LESS 1.67.0)
+ set(_Boost_CHRONO_DEPENDENCIES system)
+ set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time)
+ set(_Boost_COROUTINE_DEPENDENCIES context system)
+ set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time)
+ set(_Boost_FILESYSTEM_DEPENDENCIES system)
+ set(_Boost_IOSTREAMS_DEPENDENCIES regex)
+ set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
+ set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
+ set(_Boost_MPI_DEPENDENCIES serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
+ set(_Boost_NUMPY_DEPENDENCIES python${component_python_version})
+ set(_Boost_RANDOM_DEPENDENCIES system)
+ set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
+ set(_Boost_TIMER_DEPENDENCIES chrono system)
+ set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
+ set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.67.0 AND Boost_VERSION_STRING VERSION_LESS 1.68.0)
+ set(_Boost_CHRONO_DEPENDENCIES system)
+ set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time)
+ set(_Boost_COROUTINE_DEPENDENCIES context system)
+ set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time)
+ set(_Boost_FILESYSTEM_DEPENDENCIES system)
+ set(_Boost_IOSTREAMS_DEPENDENCIES regex)
+ set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
+ set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
+ set(_Boost_MPI_DEPENDENCIES serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
+ set(_Boost_NUMPY_DEPENDENCIES python${component_python_version})
+ set(_Boost_RANDOM_DEPENDENCIES system)
+ set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
+ set(_Boost_TIMER_DEPENDENCIES chrono system)
+ set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
+ set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.68.0 AND Boost_VERSION_STRING VERSION_LESS 1.69.0)
+ set(_Boost_CHRONO_DEPENDENCIES system)
+ set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time)
+ set(_Boost_CONTRACT_DEPENDENCIES thread chrono system date_time)
+ set(_Boost_COROUTINE_DEPENDENCIES context system)
+ set(_Boost_FIBER_DEPENDENCIES context thread chrono system date_time)
+ set(_Boost_FILESYSTEM_DEPENDENCIES system)
+ set(_Boost_IOSTREAMS_DEPENDENCIES regex)
+ set(_Boost_LOG_DEPENDENCIES date_time log_setup system filesystem thread regex chrono atomic)
+ set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
+ set(_Boost_MPI_DEPENDENCIES serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
+ set(_Boost_NUMPY_DEPENDENCIES python${component_python_version})
+ set(_Boost_RANDOM_DEPENDENCIES system)
+ set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic)
+ set(_Boost_TIMER_DEPENDENCIES chrono system)
+ set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic)
+ set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.69.0 AND Boost_VERSION_STRING VERSION_LESS 1.70.0)
+ set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time)
+ set(_Boost_COROUTINE_DEPENDENCIES context)
+ set(_Boost_FIBER_DEPENDENCIES context)
+ set(_Boost_IOSTREAMS_DEPENDENCIES regex)
+ set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic)
+ set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
+ set(_Boost_MPI_DEPENDENCIES serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
+ set(_Boost_NUMPY_DEPENDENCIES python${component_python_version})
+ set(_Boost_THREAD_DEPENDENCIES chrono date_time atomic)
+ set(_Boost_TIMER_DEPENDENCIES chrono system)
+ set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic)
+ set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.70.0 AND Boost_VERSION_STRING VERSION_LESS 1.72.0)
+ set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time)
+ set(_Boost_COROUTINE_DEPENDENCIES context)
+ set(_Boost_FIBER_DEPENDENCIES context)
+ set(_Boost_IOSTREAMS_DEPENDENCIES regex)
+ set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic)
+ set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l atomic)
+ set(_Boost_MPI_DEPENDENCIES serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
+ set(_Boost_NUMPY_DEPENDENCIES python${component_python_version})
+ set(_Boost_THREAD_DEPENDENCIES chrono date_time atomic)
+ set(_Boost_TIMER_DEPENDENCIES chrono)
+ set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic)
+ set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
+ elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.72.0)
+ set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time)
+ set(_Boost_COROUTINE_DEPENDENCIES context)
+ set(_Boost_FIBER_DEPENDENCIES context)
+ set(_Boost_IOSTREAMS_DEPENDENCIES regex)
+ set(_Boost_LOG_DEPENDENCIES date_time log_setup filesystem thread regex chrono atomic)
+ set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l chrono atomic)
+ set(_Boost_MPI_DEPENDENCIES serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
+ set(_Boost_NUMPY_DEPENDENCIES python${component_python_version})
+ set(_Boost_THREAD_DEPENDENCIES chrono date_time atomic)
+ set(_Boost_TIMER_DEPENDENCIES chrono)
+ set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic)
+ set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
+ if(NOT Boost_VERSION_STRING VERSION_LESS 1.73.0)
message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets")
- set(_Boost_IMPORTED_TARGETS FALSE)
endif()
endif()
@@ -809,15 +1183,26 @@ endfunction()
# _hdrs
#
function(_Boost_COMPONENT_HEADERS component _hdrs)
+ # Handle Python version suffixes
+ if(component MATCHES "^(python|mpi_python|numpy)([0-9][0-9]?|[0-9]\\.[0-9])\$")
+ set(component "${CMAKE_MATCH_1}")
+ set(component_python_version "${CMAKE_MATCH_2}")
+ endif()
+
# Note: new boost components will require adding here. The header
# must be present in all versions of Boost providing a library.
set(_Boost_ATOMIC_HEADERS "boost/atomic.hpp")
set(_Boost_CHRONO_HEADERS "boost/chrono.hpp")
set(_Boost_CONTAINER_HEADERS "boost/container/container_fwd.hpp")
- set(_Boost_CONTEXT_HEADERS "boost/context/all.hpp")
+ set(_Boost_CONTRACT_HEADERS "boost/contract.hpp")
+ if(Boost_VERSION_STRING VERSION_LESS 1.61.0)
+ set(_Boost_CONTEXT_HEADERS "boost/context/all.hpp")
+ else()
+ set(_Boost_CONTEXT_HEADERS "boost/context/detail/fcontext.hpp")
+ endif()
set(_Boost_COROUTINE_HEADERS "boost/coroutine/all.hpp")
- set(_Boost_EXCEPTION_HEADERS "boost/exception/exception.hpp")
set(_Boost_DATE_TIME_HEADERS "boost/date_time/date.hpp")
+ set(_Boost_EXCEPTION_HEADERS "boost/exception/exception.hpp")
set(_Boost_FIBER_HEADERS "boost/fiber/all.hpp")
set(_Boost_FILESYSTEM_HEADERS "boost/filesystem/path.hpp")
set(_Boost_GRAPH_HEADERS "boost/graph/adjacency_list.hpp")
@@ -843,6 +1228,12 @@ function(_Boost_COMPONENT_HEADERS component _hdrs)
set(_Boost_REGEX_HEADERS "boost/regex.hpp")
set(_Boost_SERIALIZATION_HEADERS "boost/serialization/serialization.hpp")
set(_Boost_SIGNALS_HEADERS "boost/signals.hpp")
+ set(_Boost_STACKTRACE_ADDR2LINE_HEADERS "boost/stacktrace.hpp")
+ set(_Boost_STACKTRACE_BACKTRACE_HEADERS "boost/stacktrace.hpp")
+ set(_Boost_STACKTRACE_BASIC_HEADERS "boost/stacktrace.hpp")
+ set(_Boost_STACKTRACE_NOOP_HEADERS "boost/stacktrace.hpp")
+ set(_Boost_STACKTRACE_WINDBG_CACHED_HEADERS "boost/stacktrace.hpp")
+ set(_Boost_STACKTRACE_WINDBG_HEADERS "boost/stacktrace.hpp")
set(_Boost_SYSTEM_HEADERS "boost/system/config.hpp")
set(_Boost_TEST_EXEC_MONITOR_HEADERS "boost/test/test_exec_monitor.hpp")
set(_Boost_THREAD_HEADERS "boost/thread.hpp")
@@ -893,9 +1284,7 @@ function(_Boost_MISSING_DEPENDENCIES componentvar extravar)
set(_Boost_${uppercomponent}_DEPENDENCIES ${_Boost_${uppercomponent}_DEPENDENCIES} PARENT_SCOPE)
set(_Boost_IMPORTED_TARGETS ${_Boost_IMPORTED_TARGETS} PARENT_SCOPE)
foreach(componentdep ${_Boost_${uppercomponent}_DEPENDENCIES})
- list(FIND _boost_processed_components "${componentdep}" _boost_component_found)
- list(FIND _boost_new_components "${componentdep}" _boost_component_new)
- if (_boost_component_found EQUAL -1 AND _boost_component_new EQUAL -1)
+ if (NOT ("${componentdep}" IN_LIST _boost_processed_components OR "${componentdep}" IN_LIST _boost_new_components))
list(APPEND _boost_new_components ${componentdep})
endif()
endforeach()
@@ -915,11 +1304,17 @@ endfunction()
# Some boost libraries may require particular set of compler features.
# The very first one was `boost::fiber` introduced in Boost 1.62.
# One can check required compiler features of it in
-# `${Boost_ROOT}/libs/fiber/build/Jamfile.v2`.
+# - `${Boost_ROOT}/libs/fiber/build/Jamfile.v2`;
+# - `${Boost_ROOT}/libs/context/build/Jamfile.v2`.
+#
+# TODO (Re)Check compiler features on (every?) release ???
+# One may use the following command to get the files to check:
+#
+# $ find . -name Jamfile.v2 | grep build | xargs grep -l cxx1
#
function(_Boost_COMPILER_FEATURES component _ret)
- # Boost >= 1.62 and < 1.65
- if(NOT Boost_VERSION VERSION_LESS 106200 AND Boost_VERSION VERSION_LESS 106500)
+ # Boost >= 1.62
+ if(NOT Boost_VERSION_STRING VERSION_LESS 1.62.0)
set(_Boost_FIBER_COMPILER_FEATURES
cxx_alias_templates
cxx_auto_type
@@ -933,7 +1328,19 @@ function(_Boost_COMPILER_FEATURES component _ret)
cxx_thread_local
cxx_variadic_templates
)
+ # Compiler feature for `context` same as for `fiber`.
+ set(_Boost_CONTEXT_COMPILER_FEATURES ${_Boost_FIBER_COMPILER_FEATURES})
+ endif()
+
+ # Boost Contract library available in >= 1.67
+ if(NOT Boost_VERSION_STRING VERSION_LESS 1.67.0)
+ # From `libs/contract/build/boost_contract_build.jam`
+ set(_Boost_CONTRACT_COMPILER_FEATURES
+ cxx_lambdas
+ cxx_variadic_templates
+ )
endif()
+
string(TOUPPER ${component} uppercomponent)
set(${_ret} ${_Boost_${uppercomponent}_COMPILER_FEATURES} PARENT_SCOPE)
endfunction()
@@ -953,21 +1360,18 @@ function(_Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS component
else()
set(_arch_suffix 32)
endif()
- if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10)
- list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.1)
- list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.0)
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
- list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.0)
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18)
- list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-12.0)
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
- list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-11.0)
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
- list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-10.0)
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15)
- list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-9.0)
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
- list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-8.0)
+ if(MSVC_TOOLSET_VERSION GREATER_EQUAL 150)
+ # Not yet known.
+ elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 140)
+ # MSVC toolset 14.x versions are forward compatible.
+ foreach(v 9 8 7 6 5 4 3 2 1 0)
+ if(MSVC_TOOLSET_VERSION GREATER_EQUAL 14${v})
+ list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-14.${v})
+ endif()
+ endforeach()
+ elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 80)
+ math(EXPR _toolset_major_version "${MSVC_TOOLSET_VERSION} / 10")
+ list(APPEND ${componentlibvar} ${basedir}/lib${_arch_suffix}-msvc-${_toolset_major_version}.0)
endif()
set(${componentlibvar} ${${componentlibvar}} PARENT_SCOPE)
endif()
@@ -992,8 +1396,14 @@ if(NOT Boost_LIBRARY_DIR_DEBUG AND Boost_LIBRARY_DIR)
set(Boost_LIBRARY_DIR_DEBUG "${Boost_LIBRARY_DIR}")
endif()
+if(NOT DEFINED Boost_USE_DEBUG_LIBS)
+ set(Boost_USE_DEBUG_LIBS TRUE)
+endif()
+if(NOT DEFINED Boost_USE_RELEASE_LIBS)
+ set(Boost_USE_RELEASE_LIBS TRUE)
+endif()
if(NOT DEFINED Boost_USE_MULTITHREADED)
- set(Boost_USE_MULTITHREADED TRUE)
+ set(Boost_USE_MULTITHREADED TRUE)
endif()
if(NOT DEFINED Boost_USE_DEBUG_RUNTIME)
set(Boost_USE_DEBUG_RUNTIME TRUE)
@@ -1019,7 +1429,8 @@ else()
# _Boost_COMPONENT_HEADERS. See the instructions at the top of
# _Boost_COMPONENT_DEPENDENCIES.
set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
- "1.65.1" "1.65.0" "1.65"
+ "1.72.0" "1.72" "1.71.0" "1.71" "1.70.0" "1.70" "1.69.0" "1.69"
+ "1.68.0" "1.68" "1.67.0" "1.67" "1.66.0" "1.66" "1.65.1" "1.65.0" "1.65"
"1.64.0" "1.64" "1.63.0" "1.63" "1.62.0" "1.62" "1.61.0" "1.61" "1.60.0" "1.60"
"1.59.0" "1.59" "1.58.0" "1.58" "1.57.0" "1.57" "1.56.0" "1.56" "1.55.0" "1.55"
"1.54.0" "1.54" "1.53.0" "1.53" "1.52.0" "1.52" "1.51.0" "1.51"
@@ -1049,26 +1460,12 @@ else()
endif()
endif()
-# The reason that we failed to find Boost. This will be set to a
-# user-friendly message when we fail to find some necessary piece of
-# Boost.
-set(Boost_ERROR_REASON)
-
-if(Boost_DEBUG)
- # Output some of their choices
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}")
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}")
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "Boost_USE_STATIC_RUNTIME = ${Boost_USE_STATIC_RUNTIME}")
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "Boost_ADDITIONAL_VERSIONS = ${Boost_ADDITIONAL_VERSIONS}")
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "Boost_NO_SYSTEM_PATHS = ${Boost_NO_SYSTEM_PATHS}")
-endif()
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_TEST_VERSIONS")
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_USE_MULTITHREADED")
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_USE_STATIC_LIBS")
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_USE_STATIC_RUNTIME")
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_ADDITIONAL_VERSIONS")
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_NO_SYSTEM_PATHS")
# Supply Boost_LIB_DIAGNOSTIC_DEFINITIONS as a convenience target. It
# will only contain any interface definitions on WIN32, but is created
@@ -1079,6 +1476,8 @@ if(NOT TARGET Boost::diagnostic_definitions)
add_library(Boost::diagnostic_definitions INTERFACE IMPORTED)
add_library(Boost::disable_autolinking INTERFACE IMPORTED)
add_library(Boost::dynamic_linking INTERFACE IMPORTED)
+ set_target_properties(Boost::dynamic_linking PROPERTIES
+ INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_DYN_LINK")
endif()
if(WIN32)
# In windows, automatic linking is performed, so you do not have
@@ -1103,11 +1502,13 @@ if(WIN32)
INTERFACE_COMPILE_DEFINITIONS "BOOST_LIB_DIAGNOSTIC")
set_target_properties(Boost::disable_autolinking PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB")
- set_target_properties(Boost::dynamic_linking PROPERTIES
- INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_DYN_LINK")
endif()
-_Boost_CHECK_SPELLING(Boost_ROOT)
+cmake_policy(GET CMP0074 _Boost_CMP0074)
+if(NOT "x${_Boost_CMP0074}x" STREQUAL "xNEWx")
+ _Boost_CHECK_SPELLING(Boost_ROOT)
+endif()
+unset(_Boost_CMP0074)
_Boost_CHECK_SPELLING(Boost_LIBRARYDIR)
_Boost_CHECK_SPELLING(Boost_INCLUDEDIR)
@@ -1133,18 +1534,12 @@ set(_Boost_VARS_DIR
Boost_NO_SYSTEM_PATHS
)
-if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "Declared as CMake or Environmental Variables:")
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- " BOOST_ROOT = ${BOOST_ROOT}")
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- " BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}")
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- " BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}")
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}")
-endif()
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_ROOT")
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_ROOT" ENVIRONMENT)
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_INCLUDEDIR")
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_INCLUDEDIR" ENVIRONMENT)
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_LIBRARYDIR")
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_LIBRARYDIR" ENVIRONMENT)
# ------------------------------------------------------------------------
# Search for Boost include DIR
@@ -1176,7 +1571,7 @@ if(NOT Boost_INCLUDE_DIR)
list(APPEND _boost_INCLUDE_SEARCH_DIRS NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH)
else()
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
- foreach(ver ${_Boost_KNOWN_VERSIONS})
+ foreach(ver ${_boost_TEST_VERSIONS})
string(REPLACE "." "_" ver "${ver}")
list(APPEND _boost_INCLUDE_SEARCH_DIRS PATHS "C:/local/boost_${ver}")
endforeach()
@@ -1216,14 +1611,8 @@ if(NOT Boost_INCLUDE_DIR)
endforeach()
- if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "Include debugging info:")
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- " _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}")
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- " _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}")
- endif()
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_INCLUDE_SEARCH_DIRS")
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_PATH_SUFFIXES")
# Look for a standard boost header file.
find_path(Boost_INCLUDE_DIR
@@ -1237,73 +1626,54 @@ endif()
# Extract version information from version.hpp
# ------------------------------------------------------------------------
-# Set Boost_FOUND based only on header location and version.
-# It will be updated below for component libraries.
if(Boost_INCLUDE_DIR)
- if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp")
- endif()
+ _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}"
+ "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp")
- # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp
- set(Boost_VERSION 0)
+ # Extract Boost_VERSION_MACRO and Boost_LIB_VERSION from version.hpp
+ set(Boost_VERSION_MACRO 0)
set(Boost_LIB_VERSION "")
file(STRINGS "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS REGEX "#define BOOST_(LIB_)?VERSION ")
- set(_Boost_VERSION_REGEX "([0-9]+)")
- set(_Boost_LIB_VERSION_REGEX "\"([0-9_]+)\"")
- foreach(v VERSION LIB_VERSION)
- if("${_boost_VERSION_HPP_CONTENTS}" MATCHES "#define BOOST_${v} ${_Boost_${v}_REGEX}")
- set(Boost_${v} "${CMAKE_MATCH_1}")
- endif()
- endforeach()
+ if("${_boost_VERSION_HPP_CONTENTS}" MATCHES "#define BOOST_VERSION ([0-9]+)")
+ set(Boost_VERSION_MACRO "${CMAKE_MATCH_1}")
+ endif()
+ if("${_boost_VERSION_HPP_CONTENTS}" MATCHES "#define BOOST_LIB_VERSION \"([0-9_]+)\"")
+ set(Boost_LIB_VERSION "${CMAKE_MATCH_1}")
+ endif()
unset(_boost_VERSION_HPP_CONTENTS)
- math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000")
- math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000")
- math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100")
+ # Calculate version components
+ math(EXPR Boost_VERSION_MAJOR "${Boost_VERSION_MACRO} / 100000")
+ math(EXPR Boost_VERSION_MINOR "${Boost_VERSION_MACRO} / 100 % 1000")
+ math(EXPR Boost_VERSION_PATCH "${Boost_VERSION_MACRO} % 100")
+ set(Boost_VERSION_COUNT 3)
- string(APPEND Boost_ERROR_REASON
- "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}")
- if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "version.hpp reveals boost "
- "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
- endif()
+ # Define alias variables for backwards compat.
+ set(Boost_MAJOR_VERSION ${Boost_VERSION_MAJOR})
+ set(Boost_MINOR_VERSION ${Boost_VERSION_MINOR})
+ set(Boost_SUBMINOR_VERSION ${Boost_VERSION_PATCH})
- if(Boost_FIND_VERSION)
- # Set Boost_FOUND based on requested version.
- set(_Boost_VERSION "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
- if("${_Boost_VERSION}" VERSION_LESS "${Boost_FIND_VERSION}")
- set(Boost_FOUND 0)
- set(_Boost_VERSION_AGE "old")
- elseif(Boost_FIND_VERSION_EXACT AND
- NOT "${_Boost_VERSION}" VERSION_EQUAL "${Boost_FIND_VERSION}")
- set(Boost_FOUND 0)
- set(_Boost_VERSION_AGE "new")
- else()
- set(Boost_FOUND 1)
- endif()
- if(NOT Boost_FOUND)
- # State that we found a version of Boost that is too new or too old.
- string(APPEND Boost_ERROR_REASON
- "\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}")
- if (Boost_FIND_VERSION_PATCH)
- string(APPEND Boost_ERROR_REASON
- ".${Boost_FIND_VERSION_PATCH}")
- endif ()
- if (NOT Boost_FIND_VERSION_EXACT)
- string(APPEND Boost_ERROR_REASON " (or newer)")
- endif ()
- string(APPEND Boost_ERROR_REASON ".")
- endif ()
+ # Define Boost version in x.y.z format
+ set(Boost_VERSION_STRING "${Boost_VERSION_MAJOR}.${Boost_VERSION_MINOR}.${Boost_VERSION_PATCH}")
+
+ # Define final Boost_VERSION
+ cmake_policy(GET CMP0093 _Boost_CMP0093
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ if("x${_Boost_CMP0093}x" STREQUAL "xNEWx")
+ set(Boost_VERSION ${Boost_VERSION_STRING})
else()
- # Caller will accept any Boost version.
- set(Boost_FOUND 1)
+ set(Boost_VERSION ${Boost_VERSION_MACRO})
endif()
-else()
- set(Boost_FOUND 0)
- string(APPEND Boost_ERROR_REASON
- "Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.")
+ unset(_Boost_CMP0093)
+
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION")
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_STRING")
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_MACRO")
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_MAJOR")
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_MINOR")
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_PATCH")
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_COUNT")
endif()
# ------------------------------------------------------------------------
@@ -1320,6 +1690,9 @@ if ( NOT Boost_NAMESPACE )
set(Boost_NAMESPACE "boost")
endif()
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_LIB_PREFIX")
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_NAMESPACE")
+
# ------------------------------------------------------------------------
# Suffix initialization and compiler suffix detection.
# ------------------------------------------------------------------------
@@ -1340,34 +1713,28 @@ _Boost_CHANGE_DETECT(_Boost_CHANGE_LIBNAME ${_Boost_VARS_NAME})
# Setting some more suffixes for the library
if (Boost_COMPILER)
set(_boost_COMPILER ${Boost_COMPILER})
- if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "using user-specified Boost_COMPILER = ${_boost_COMPILER}")
- endif()
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}"
+ "_boost_COMPILER" SOURCE "user-specified via Boost_COMPILER")
else()
# Attempt to guess the compiler suffix
# NOTE: this is not perfect yet, if you experience any issues
# please report them and use the Boost_COMPILER variable
# to work around the problems.
_Boost_GUESS_COMPILER_PREFIX(_boost_COMPILER)
- if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "guessed _boost_COMPILER = ${_boost_COMPILER}")
- endif()
endif()
set (_boost_MULTITHREADED "-mt")
if( NOT Boost_USE_MULTITHREADED )
set (_boost_MULTITHREADED "")
endif()
-if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "_boost_MULTITHREADED = ${_boost_MULTITHREADED}")
-endif()
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_MULTITHREADED")
#======================
-# Systematically build up the Boost ABI tag
-# http://boost.org/doc/libs/1_41_0/more/getting_started/windows.html#library-naming
+# Systematically build up the Boost ABI tag for the 'tagged' and 'versioned' layouts
+# http://boost.org/doc/libs/1_66_0/more/getting_started/windows.html#library-naming
+# http://boost.org/doc/libs/1_66_0/boost/config/auto_link.hpp
+# http://boost.org/doc/libs/1_66_0/tools/build/src/tools/common.jam
+# http://boost.org/doc/libs/1_66_0/boostcpp.jam
set( _boost_RELEASE_ABI_TAG "-")
set( _boost_DEBUG_ABI_TAG "-")
# Key Use this library when:
@@ -1381,8 +1748,8 @@ endif()
# support libraries
if(WIN32 AND Boost_USE_DEBUG_RUNTIME)
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC"
- OR "${CMAKE_CXX_COMPILER}" MATCHES "icl"
- OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc")
+ OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang"
+ OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xIntel")
string(APPEND _boost_DEBUG_ABI_TAG "g")
endif()
endif()
@@ -1399,18 +1766,51 @@ if(Boost_USE_STLPORT)
string(APPEND _boost_DEBUG_ABI_TAG "p")
endif()
# n using the STLport deprecated "native iostreams" feature
+# removed from the documentation in 1.43.0 but still present in
+# boost/config/auto_link.hpp
if(Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS)
string(APPEND _boost_RELEASE_ABI_TAG "n")
string(APPEND _boost_DEBUG_ABI_TAG "n")
endif()
-if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "_boost_RELEASE_ABI_TAG = ${_boost_RELEASE_ABI_TAG}")
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "_boost_DEBUG_ABI_TAG = ${_boost_DEBUG_ABI_TAG}")
+# -x86 Architecture and address model tag
+# First character is the architecture, then word-size, either 32 or 64
+# Only used in 'versioned' layout, added in Boost 1.66.0
+if(DEFINED Boost_ARCHITECTURE)
+ set(_boost_ARCHITECTURE_TAG "${Boost_ARCHITECTURE}")
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}"
+ "_boost_ARCHITECTURE_TAG" SOURCE "user-specified via Boost_ARCHITECTURE")
+else()
+ set(_boost_ARCHITECTURE_TAG "")
+ # {CMAKE_CXX_COMPILER_ARCHITECTURE_ID} is not currently set for all compilers
+ if(NOT "x${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "x" AND NOT Boost_VERSION_STRING VERSION_LESS 1.66.0)
+ string(APPEND _boost_ARCHITECTURE_TAG "-")
+ # This needs to be kept in-sync with the section of CMakePlatformId.h.in
+ # inside 'defined(_WIN32) && defined(_MSC_VER)'
+ if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "IA64")
+ string(APPEND _boost_ARCHITECTURE_TAG "i")
+ elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "X86"
+ OR CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "x64")
+ string(APPEND _boost_ARCHITECTURE_TAG "x")
+ elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID MATCHES "^ARM")
+ string(APPEND _boost_ARCHITECTURE_TAG "a")
+ elseif(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "MIPS")
+ string(APPEND _boost_ARCHITECTURE_TAG "m")
+ endif()
+
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ string(APPEND _boost_ARCHITECTURE_TAG "64")
+ else()
+ string(APPEND _boost_ARCHITECTURE_TAG "32")
+ endif()
+ endif()
+ _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}"
+ "_boost_ARCHITECTURE_TAG" SOURCE "detected")
endif()
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_RELEASE_ABI_TAG")
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_DEBUG_ABI_TAG")
+
# ------------------------------------------------------------------------
# Begin finding boost libraries
# ------------------------------------------------------------------------
@@ -1451,10 +1851,11 @@ foreach(c DEBUG RELEASE)
${Boost_INCLUDE_DIR}/stage/lib
)
_Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "${Boost_INCLUDE_DIR}/..")
+ _Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "${Boost_INCLUDE_DIR}")
if( Boost_NO_SYSTEM_PATHS )
list(APPEND _boost_LIBRARY_SEARCH_DIRS_${c} NO_CMAKE_SYSTEM_PATH NO_SYSTEM_ENVIRONMENT_PATH)
else()
- foreach(ver ${_Boost_KNOWN_VERSIONS})
+ foreach(ver ${_boost_TEST_VERSIONS})
string(REPLACE "." "_" ver "${ver}")
_Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS(_boost_LIBRARY_SEARCH_DIRS_${c} "C:/local/boost_${ver}")
endforeach()
@@ -1468,11 +1869,8 @@ foreach(c DEBUG RELEASE)
endif()
endforeach()
-if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "_boost_LIBRARY_SEARCH_DIRS_RELEASE = ${_boost_LIBRARY_SEARCH_DIRS_RELEASE}"
- "_boost_LIBRARY_SEARCH_DIRS_DEBUG = ${_boost_LIBRARY_SEARCH_DIRS_DEBUG}")
-endif()
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_LIBRARY_SEARCH_DIRS_RELEASE")
+_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_LIBRARY_SEARCH_DIRS_DEBUG")
# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
if( Boost_USE_STATIC_LIBS )
@@ -1512,10 +1910,10 @@ endif()
# On versions < 1.35, remove the System library from the considered list
# since it wasn't added until 1.35.
-if(Boost_VERSION AND Boost_FIND_COMPONENTS)
- if(Boost_VERSION LESS 103500)
- list(REMOVE_ITEM Boost_FIND_COMPONENTS system)
- endif()
+if(Boost_VERSION_STRING AND Boost_FIND_COMPONENTS)
+ if(Boost_VERSION_STRING VERSION_LESS 1.35.0)
+ list(REMOVE_ITEM Boost_FIND_COMPONENTS system)
+ endif()
endif()
# Additional components may be required via component dependencies.
@@ -1523,10 +1921,14 @@ endif()
_Boost_MISSING_DEPENDENCIES(Boost_FIND_COMPONENTS _Boost_EXTRA_FIND_COMPONENTS)
# If thread is required, get the thread libs as a dependency
-list(FIND Boost_FIND_COMPONENTS thread _Boost_THREAD_DEPENDENCY_LIBS)
-if(NOT _Boost_THREAD_DEPENDENCY_LIBS EQUAL -1)
- include(CMakeFindDependencyMacro)
- find_dependency(Threads)
+if("thread" IN_LIST Boost_FIND_COMPONENTS)
+ if(Boost_FIND_QUIETLY)
+ set(_Boost_find_quiet QUIET)
+ else()
+ set(_Boost_find_quiet "")
+ endif()
+ find_package(Threads ${_Boost_find_quiet})
+ unset(_Boost_find_quiet)
endif()
# If the user changed any of our control inputs flush previous results.
@@ -1561,14 +1963,45 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
endforeach()
endif()
+ # Handle Python version suffixes
+ unset(COMPONENT_PYTHON_VERSION_MAJOR)
+ unset(COMPONENT_PYTHON_VERSION_MINOR)
+ if(${COMPONENT} MATCHES "^(python|mpi_python|numpy)([0-9])\$")
+ set(COMPONENT_UNVERSIONED "${CMAKE_MATCH_1}")
+ set(COMPONENT_PYTHON_VERSION_MAJOR "${CMAKE_MATCH_2}")
+ elseif(${COMPONENT} MATCHES "^(python|mpi_python|numpy)([0-9])\\.?([0-9])\$")
+ set(COMPONENT_UNVERSIONED "${CMAKE_MATCH_1}")
+ set(COMPONENT_PYTHON_VERSION_MAJOR "${CMAKE_MATCH_2}")
+ set(COMPONENT_PYTHON_VERSION_MINOR "${CMAKE_MATCH_3}")
+ endif()
+
+ unset(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME)
+ if (COMPONENT_PYTHON_VERSION_MINOR)
+ # Boost >= 1.67
+ list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME "${COMPONENT_UNVERSIONED}${COMPONENT_PYTHON_VERSION_MAJOR}${COMPONENT_PYTHON_VERSION_MINOR}")
+ # Debian/Ubuntu (Some versions omit the 2 and/or 3 from the suffix)
+ list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME "${COMPONENT_UNVERSIONED}${COMPONENT_PYTHON_VERSION_MAJOR}-py${COMPONENT_PYTHON_VERSION_MAJOR}${COMPONENT_PYTHON_VERSION_MINOR}")
+ list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME "${COMPONENT_UNVERSIONED}-py${COMPONENT_PYTHON_VERSION_MAJOR}${COMPONENT_PYTHON_VERSION_MINOR}")
+ # Gentoo
+ list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME "${COMPONENT_UNVERSIONED}-${COMPONENT_PYTHON_VERSION_MAJOR}.${COMPONENT_PYTHON_VERSION_MINOR}")
+ # RPMs
+ list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME "${COMPONENT_UNVERSIONED}-${COMPONENT_PYTHON_VERSION_MAJOR}${COMPONENT_PYTHON_VERSION_MINOR}")
+ endif()
+ if (COMPONENT_PYTHON_VERSION_MAJOR AND NOT COMPONENT_PYTHON_VERSION_MINOR)
+ # Boost < 1.67
+ list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME "${COMPONENT_UNVERSIONED}${COMPONENT_PYTHON_VERSION_MAJOR}")
+ endif()
+
# Consolidate and report component-specific hints.
+ if(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME)
+ list(REMOVE_DUPLICATES _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME)
+ _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}"
+ "Component-specific library search names for ${COMPONENT_NAME}: ${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME}")
+ endif()
if(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
list(REMOVE_DUPLICATES _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
- if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "Component-specific library search paths for ${COMPONENT}: "
- "${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT}")
- endif()
+ _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}"
+ "Component-specific library search paths for ${COMPONENT}: ${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT}")
endif()
#
@@ -1584,40 +2017,46 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
endif()
else()
set(Boost_${UPPERCOMPONENT}_HEADER ON)
- message(WARNING "No header defined for ${COMPONENT}; skipping header check")
+ message(WARNING "No header defined for ${COMPONENT}; skipping header check "
+ "(note: header-only libraries have no designated component)")
endif()
#
# Find RELEASE libraries
#
unset(_boost_RELEASE_NAMES)
- foreach(compiler IN LISTS _boost_COMPILER)
- list(APPEND _boost_RELEASE_NAMES
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} )
- endforeach()
- list(APPEND _boost_RELEASE_NAMES
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION}
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} )
- if(_boost_STATIC_RUNTIME_WORKAROUND)
- set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}")
+ foreach(component IN LISTS _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME COMPONENT)
foreach(compiler IN LISTS _boost_COMPILER)
list(APPEND _boost_RELEASE_NAMES
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} )
endforeach()
list(APPEND _boost_RELEASE_NAMES
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
- endif()
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}${_boost_ARCHITECTURE_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component} )
+ if(_boost_STATIC_RUNTIME_WORKAROUND)
+ set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}")
+ foreach(compiler IN LISTS _boost_COMPILER)
+ list(APPEND _boost_RELEASE_NAMES
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
+ endforeach()
+ list(APPEND _boost_RELEASE_NAMES
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} )
+ endif()
+ endforeach()
if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
- _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES})
- endif()
- if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}")
+ _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES})
endif()
+ _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}"
+ "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}")
# if Boost_LIBRARY_DIR_RELEASE is not defined,
# but Boost_LIBRARY_DIR_DEBUG is, look there first for RELEASE libs
@@ -1628,45 +2067,51 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
# Avoid passing backslashes to _Boost_FIND_LIBRARY due to macro re-parsing.
string(REPLACE "\\" "/" _boost_LIBRARY_SEARCH_DIRS_tmp "${_boost_LIBRARY_SEARCH_DIRS_RELEASE}")
- _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE RELEASE
- NAMES ${_boost_RELEASE_NAMES}
- HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp}
- NAMES_PER_DIR
- DOC "${_boost_docstring_release}"
- )
+ if(Boost_USE_RELEASE_LIBS)
+ _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE RELEASE
+ NAMES ${_boost_RELEASE_NAMES}
+ HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp}
+ NAMES_PER_DIR
+ DOC "${_boost_docstring_release}"
+ )
+ endif()
#
# Find DEBUG libraries
#
unset(_boost_DEBUG_NAMES)
- foreach(compiler IN LISTS _boost_COMPILER)
- list(APPEND _boost_DEBUG_NAMES
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} )
- endforeach()
- list(APPEND _boost_DEBUG_NAMES
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION}
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT} )
- if(_boost_STATIC_RUNTIME_WORKAROUND)
- set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}")
+ foreach(component IN LISTS _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME COMPONENT)
foreach(compiler IN LISTS _boost_COMPILER)
list(APPEND _boost_DEBUG_NAMES
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}${_boost_ARCHITECTURE_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} )
endforeach()
list(APPEND _boost_DEBUG_NAMES
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION}
- ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
- endif()
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}${_boost_ARCHITECTURE_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component} )
+ if(_boost_STATIC_RUNTIME_WORKAROUND)
+ set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}")
+ foreach(compiler IN LISTS _boost_COMPILER)
+ list(APPEND _boost_DEBUG_NAMES
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${compiler}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
+ endforeach()
+ list(APPEND _boost_DEBUG_NAMES
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}-${Boost_LIB_VERSION}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}${_boost_ARCHITECTURE_TAG}
+ ${Boost_LIB_PREFIX}${Boost_NAMESPACE}_${component}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} )
+ endif()
+ endforeach()
if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread")
_Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES})
endif()
- if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}")
- endif()
+ _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}"
+ "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}")
# if Boost_LIBRARY_DIR_DEBUG is not defined,
# but Boost_LIBRARY_DIR_RELEASE is, look there first for DEBUG libs
@@ -1677,12 +2122,14 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
# Avoid passing backslashes to _Boost_FIND_LIBRARY due to macro re-parsing.
string(REPLACE "\\" "/" _boost_LIBRARY_SEARCH_DIRS_tmp "${_boost_LIBRARY_SEARCH_DIRS_DEBUG}")
- _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG DEBUG
- NAMES ${_boost_DEBUG_NAMES}
- HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp}
- NAMES_PER_DIR
- DOC "${_boost_docstring_debug}"
- )
+ if(Boost_USE_DEBUG_LIBS)
+ _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG DEBUG
+ NAMES ${_boost_DEBUG_NAMES}
+ HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp}
+ NAMES_PER_DIR
+ DOC "${_boost_docstring_debug}"
+ )
+ endif ()
if(Boost_REALPATH)
_Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "${_boost_docstring_release}")
@@ -1717,57 +2164,25 @@ if(Boost_LIBRARY_DIRS)
list(REMOVE_DUPLICATES Boost_LIBRARY_DIRS)
endif()
-# The above setting of Boost_FOUND was based only on the header files.
-# Update it for the requested component libraries.
-if(Boost_FOUND)
- # The headers were found. Check for requested component libs.
- set(_boost_CHECKED_COMPONENT FALSE)
- set(_Boost_MISSING_COMPONENTS "")
- foreach(COMPONENT ${Boost_FIND_COMPONENTS})
- string(TOUPPER ${COMPONENT} COMPONENT)
- set(_boost_CHECKED_COMPONENT TRUE)
- if(NOT Boost_${COMPONENT}_FOUND)
- string(TOLOWER ${COMPONENT} COMPONENT)
- list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
- endif()
- endforeach()
- if(_Boost_MISSING_COMPONENTS AND _Boost_EXTRA_FIND_COMPONENTS)
- # Optional indirect dependencies are not counted as missing.
- list(REMOVE_ITEM _Boost_MISSING_COMPONENTS ${_Boost_EXTRA_FIND_COMPONENTS})
- endif()
+# ------------------------------------------------------------------------
+# Call FPHSA helper, see https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html
+# ------------------------------------------------------------------------
- if(Boost_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}")
+# Define aliases as needed by the component handler in the FPHSA helper below
+foreach(_comp IN LISTS Boost_FIND_COMPONENTS)
+ string(TOUPPER ${_comp} _uppercomp)
+ if(DEFINED Boost_${_uppercomp}_FOUND)
+ set(Boost_${_comp}_FOUND ${Boost_${_uppercomp}_FOUND})
endif()
+endforeach()
- if (_Boost_MISSING_COMPONENTS)
- set(Boost_FOUND 0)
- # We were unable to find some libraries, so generate a sensible
- # error message that lists the libraries we were unable to find.
- string(APPEND Boost_ERROR_REASON
- "\nCould not find the following")
- if(Boost_USE_STATIC_LIBS)
- string(APPEND Boost_ERROR_REASON " static")
- endif()
- string(APPEND Boost_ERROR_REASON
- " Boost libraries:\n")
- foreach(COMPONENT ${_Boost_MISSING_COMPONENTS})
- string(APPEND Boost_ERROR_REASON
- " ${Boost_NAMESPACE}_${COMPONENT}\n")
- endforeach()
-
- list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED)
- list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS)
- if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS})
- string(APPEND Boost_ERROR_REASON
- "No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.")
- else ()
- string(APPEND Boost_ERROR_REASON
- "Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.")
- endif ()
- endif ()
+find_package_handle_standard_args(Boost
+ REQUIRED_VARS Boost_INCLUDE_DIR
+ VERSION_VAR Boost_VERSION_STRING
+ HANDLE_COMPONENTS)
- if( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT )
+if(Boost_FOUND)
+ if( NOT Boost_LIBRARY_DIRS )
# Compatibility Code for backwards compatibility with CMake
# 2.4's FindBoost module.
@@ -1811,15 +2226,24 @@ endif()
# ------------------------------------------------------------------------
if(Boost_FOUND)
- # For header-only libraries
- if(NOT TARGET Boost::boost)
- add_library(Boost::boost INTERFACE IMPORTED)
+ # The builtin CMake package in Boost 1.70+ introduces a new name
+ # for the header-only lib, let's provide the same UI in module mode
+ if(NOT TARGET Boost::headers)
+ add_library(Boost::headers INTERFACE IMPORTED)
if(Boost_INCLUDE_DIRS)
- set_target_properties(Boost::boost PROPERTIES
+ set_target_properties(Boost::headers PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}")
endif()
endif()
+ # Define the old target name for header-only libraries for backwards
+ # compat.
+ if(NOT TARGET Boost::boost)
+ add_library(Boost::boost INTERFACE IMPORTED)
+ set_target_properties(Boost::boost
+ PROPERTIES INTERFACE_LINK_LIBRARIES Boost::headers)
+ endif()
+
foreach(COMPONENT ${Boost_FIND_COMPONENTS})
if(_Boost_IMPORTED_TARGETS AND NOT TARGET Boost::${COMPONENT})
string(TOUPPER ${COMPONENT} UPPERCOMPONENT)
@@ -1875,43 +2299,20 @@ if(Boost_FOUND)
endif()
# ------------------------------------------------------------------------
-# Notification to end user about what was found
+# Finalize
# ------------------------------------------------------------------------
+# Report Boost_LIBRARIES
set(Boost_LIBRARIES "")
-if(Boost_FOUND)
- if(NOT Boost_FIND_QUIETLY)
- message(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
- if(Boost_FIND_COMPONENTS)
- message(STATUS "Found the following Boost libraries:")
+foreach(_comp IN LISTS Boost_FIND_COMPONENTS)
+ string(TOUPPER ${_comp} _uppercomp)
+ if(Boost_${_uppercomp}_FOUND)
+ list(APPEND Boost_LIBRARIES ${Boost_${_uppercomp}_LIBRARY})
+ if(_comp STREQUAL "thread")
+ list(APPEND Boost_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif()
endif()
- foreach( COMPONENT ${Boost_FIND_COMPONENTS} )
- string( TOUPPER ${COMPONENT} UPPERCOMPONENT )
- if( Boost_${UPPERCOMPONENT}_FOUND )
- if(NOT Boost_FIND_QUIETLY)
- message (STATUS " ${COMPONENT}")
- endif()
- list(APPEND Boost_LIBRARIES ${Boost_${UPPERCOMPONENT}_LIBRARY})
- endif()
- endforeach()
-else()
- if(Boost_FIND_REQUIRED)
- message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
- else()
- if(NOT Boost_FIND_QUIETLY)
- # we opt not to automatically output Boost_ERROR_REASON here as
- # it could be quite lengthy and somewhat imposing in its requests
- # Since Boost is not always a required dependency we'll leave this
- # up to the end-user.
- if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG)
- message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}")
- else()
- message(STATUS "Could NOT find Boost")
- endif()
- endif()
- endif()
-endif()
+endforeach()
# Configure display of cache entries in GUI.
foreach(v BOOSTROOT BOOST_ROOT ${_Boost_VARS_INC} ${_Boost_VARS_LIB})
@@ -1949,3 +2350,6 @@ list(REMOVE_DUPLICATES _Boost_COMPONENTS_SEARCHED)
list(SORT _Boost_COMPONENTS_SEARCHED)
set(_Boost_COMPONENTS_SEARCHED "${_Boost_COMPONENTS_SEARCHED}"
CACHE INTERNAL "Components requested for this build tree.")
+
+# Restore project's policies
+cmake_policy(POP)
diff --git a/Modules/FindBullet.cmake b/Modules/FindBullet.cmake
index fc6695c35..6d6418521 100644
--- a/Modules/FindBullet.cmake
+++ b/Modules/FindBullet.cmake
@@ -1,39 +1,40 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindBullet
-# ----------
-#
-# Try to find the Bullet physics engine
-#
-#
-#
-# ::
-#
-# This module defines the following variables
-#
-#
-#
-# ::
-#
-# BULLET_FOUND - Was bullet found
-# BULLET_INCLUDE_DIRS - the Bullet include directories
-# BULLET_LIBRARIES - Link to this, by default it includes
-# all bullet components (Dynamics,
-# Collision, LinearMath, & SoftBody)
-#
-#
-#
-# ::
-#
-# This module accepts the following variables
-#
-#
-#
-# ::
-#
-# BULLET_ROOT - Can be set to bullet install path or Windows build path
+#[=======================================================================[.rst:
+FindBullet
+----------
+
+Try to find the Bullet physics engine
+
+
+
+::
+
+ This module defines the following variables
+
+
+
+::
+
+ BULLET_FOUND - Was bullet found
+ BULLET_INCLUDE_DIRS - the Bullet include directories
+ BULLET_LIBRARIES - Link to this, by default it includes
+ all bullet components (Dynamics,
+ Collision, LinearMath, & SoftBody)
+
+
+
+::
+
+ This module accepts the following variables
+
+
+
+::
+
+ BULLET_ROOT - Can be set to bullet install path or Windows build path
+#]=======================================================================]
macro(_FIND_BULLET_LIBRARY _var)
find_library(${_var}
@@ -51,12 +52,12 @@ macro(_FIND_BULLET_LIBRARY _var)
endmacro()
macro(_BULLET_APPEND_LIBRARIES _list _release)
- set(_debug ${_release}_DEBUG)
- if(${_debug})
- set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}})
- else()
- set(${_list} ${${_list}} ${${_release}})
- endif()
+ set(_debug ${_release}_DEBUG)
+ if(${_debug})
+ set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}})
+ else()
+ set(${_list} ${${_list}} ${${_release}})
+ endif()
endmacro()
find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h
diff --git a/Modules/FindCABLE.cmake b/Modules/FindCABLE.cmake
index 450e32237..1f4ae7633 100644
--- a/Modules/FindCABLE.cmake
+++ b/Modules/FindCABLE.cmake
@@ -1,27 +1,28 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindCABLE
-# ---------
-#
-# Find CABLE
-#
-# This module finds if CABLE is installed and determines where the
-# include files and libraries are. This code sets the following
-# variables:
-#
-# ::
-#
-# CABLE the path to the cable executable
-# CABLE_TCL_LIBRARY the path to the Tcl wrapper library
-# CABLE_INCLUDE_DIR the path to the include directory
-#
-#
-#
-# To build Tcl wrappers, you should add shared library and link it to
-# ${CABLE_TCL_LIBRARY}. You should also add ${CABLE_INCLUDE_DIR} as an
-# include directory.
+#[=======================================================================[.rst:
+FindCABLE
+---------
+
+Find CABLE
+
+This module finds if CABLE is installed and determines where the
+include files and libraries are. This code sets the following
+variables:
+
+::
+
+ CABLE the path to the cable executable
+ CABLE_TCL_LIBRARY the path to the Tcl wrapper library
+ CABLE_INCLUDE_DIR the path to the include directory
+
+
+
+To build Tcl wrappers, you should add shared library and link it to
+${CABLE_TCL_LIBRARY}. You should also add ${CABLE_INCLUDE_DIR} as an
+include directory.
+#]=======================================================================]
if(NOT CABLE)
find_path(CABLE_BUILD_DIR cableVersion.h)
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index a4dca5433..b6859aaf4 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -1,340 +1,387 @@
-#.rst:
-# FindCUDA
-# --------
-#
-# Tools for building CUDA C files: libraries and build dependencies.
-#
-# This script locates the NVIDIA CUDA C tools. It should work on linux,
-# windows, and mac and should be reasonably up to date with CUDA C
-# releases.
-#
-# This script makes use of the standard find_package arguments of
-# <VERSION>, REQUIRED and QUIET. CUDA_FOUND will report if an
-# acceptable version of CUDA was found.
-#
-# The script will prompt the user to specify CUDA_TOOLKIT_ROOT_DIR if
-# the prefix cannot be determined by the location of nvcc in the system
-# path and REQUIRED is specified to find_package(). To use a different
-# installed version of the toolkit set the environment variable
-# CUDA_BIN_PATH before running cmake (e.g.
-# CUDA_BIN_PATH=/usr/local/cuda1.0 instead of the default
-# /usr/local/cuda) or set CUDA_TOOLKIT_ROOT_DIR after configuring. If
-# you change the value of CUDA_TOOLKIT_ROOT_DIR, various components that
-# depend on the path will be relocated.
-#
-# It might be necessary to set CUDA_TOOLKIT_ROOT_DIR manually on certain
-# platforms, or to use a cuda runtime not installed in the default
-# location. In newer versions of the toolkit the cuda library is
-# included with the graphics driver- be sure that the driver version
-# matches what is needed by the cuda runtime version.
-#
-# The following variables affect the behavior of the macros in the
-# script (in alphebetical order). Note that any of these flags can be
-# changed multiple times in the same directory before calling
-# CUDA_ADD_EXECUTABLE, CUDA_ADD_LIBRARY, CUDA_COMPILE, CUDA_COMPILE_PTX,
-# CUDA_COMPILE_FATBIN, CUDA_COMPILE_CUBIN or CUDA_WRAP_SRCS::
-#
-# CUDA_64_BIT_DEVICE_CODE (Default matches host bit size)
-# -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code.
-# Note that making this different from the host code when generating object
-# or C files from CUDA code just won't work, because size_t gets defined by
-# nvcc in the generated source. If you compile to PTX and then load the
-# file yourself, you can mix bit sizes between device and host.
-#
-# CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON)
-# -- Set to ON if you want the custom build rule to be attached to the source
-# file in Visual Studio. Turn OFF if you add the same cuda file to multiple
-# targets.
-#
-# This allows the user to build the target from the CUDA file; however, bad
-# things can happen if the CUDA source file is added to multiple targets.
-# When performing parallel builds it is possible for the custom build
-# command to be run more than once and in parallel causing cryptic build
-# errors. VS runs the rules for every source file in the target, and a
-# source can have only one rule no matter how many projects it is added to.
-# When the rule is run from multiple targets race conditions can occur on
-# the generated file. Eventually everything will get built, but if the user
-# is unaware of this behavior, there may be confusion. It would be nice if
-# this script could detect the reuse of source files across multiple targets
-# and turn the option off for the user, but no good solution could be found.
-#
-# CUDA_BUILD_CUBIN (Default OFF)
-# -- Set to ON to enable and extra compilation pass with the -cubin option in
-# Device mode. The output is parsed and register, shared memory usage is
-# printed during build.
-#
-# CUDA_BUILD_EMULATION (Default OFF for device mode)
-# -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files
-# when CUDA_BUILD_EMULATION is TRUE.
-#
-# CUDA_LINK_LIBRARIES_KEYWORD (Default "")
-# -- The <PRIVATE|PUBLIC|INTERFACE> keyword to use for internal
-# target_link_libraries calls. The default is to use no keyword which
-# uses the old "plain" form of target_link_libraries. Note that is matters
-# because whatever is used inside the FindCUDA module must also be used
-# outside - the two forms of target_link_libraries cannot be mixed.
-#
-# CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR)
-# -- Set to the path you wish to have the generated files placed. If it is
-# blank output files will be placed in CMAKE_CURRENT_BINARY_DIR.
-# Intermediate files will always be placed in
-# CMAKE_CURRENT_BINARY_DIR/CMakeFiles.
-#
-# CUDA_HOST_COMPILATION_CPP (Default ON)
-# -- Set to OFF for C compilation of host code.
-#
-# CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER, $(VCInstallDir)/bin for VS)
-# -- Set the host compiler to be used by nvcc. Ignored if -ccbin or
-# --compiler-bindir is already present in the CUDA_NVCC_FLAGS or
-# CUDA_NVCC_FLAGS_<CONFIG> variables. For Visual Studio targets
-# $(VCInstallDir)/bin is a special value that expands out to the path when
-# the command is run from within VS.
-#
-# CUDA_NVCC_FLAGS
-# CUDA_NVCC_FLAGS_<CONFIG>
-# -- Additional NVCC command line arguments. NOTE: multiple arguments must be
-# semi-colon delimited (e.g. --compiler-options;-Wall)
-#
-# CUDA_PROPAGATE_HOST_FLAGS (Default ON)
-# -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration
-# dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the
-# host compiler through nvcc's -Xcompiler flag. This helps make the
-# generated host code match the rest of the system better. Sometimes
-# certain flags give nvcc problems, and this will help you turn the flag
-# propagation off. This does not affect the flags supplied directly to nvcc
-# via CUDA_NVCC_FLAGS or through the OPTION flags specified through
-# CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for
-# shared library compilation are not affected by this flag.
-#
-# CUDA_SEPARABLE_COMPILATION (Default OFF)
-# -- If set this will enable separable compilation for all CUDA runtime object
-# files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY
-# (e.g. calling CUDA_WRAP_SRCS directly),
-# CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and
-# CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called.
-#
-# CUDA_SOURCE_PROPERTY_FORMAT
-# -- If this source file property is set, it can override the format specified
-# to CUDA_WRAP_SRCS (OBJ, PTX, CUBIN, or FATBIN). If an input source file
-# is not a .cu file, setting this file will cause it to be treated as a .cu
-# file. See documentation for set_source_files_properties on how to set
-# this property.
-#
-# CUDA_USE_STATIC_CUDA_RUNTIME (Default ON)
-# -- When enabled the static version of the CUDA runtime library will be used
-# in CUDA_LIBRARIES. If the version of CUDA configured doesn't support
-# this option, then it will be silently disabled.
-#
-# CUDA_VERBOSE_BUILD (Default OFF)
-# -- Set to ON to see all the commands used when building the CUDA file. When
-# using a Makefile generator the value defaults to VERBOSE (run make
-# VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will
-# always print the output.
-#
-# The script creates the following macros (in alphebetical order)::
-#
-# CUDA_ADD_CUFFT_TO_TARGET( cuda_target )
-# -- Adds the cufft library to the target (can be any target). Handles whether
-# you are in emulation mode or not.
-#
-# CUDA_ADD_CUBLAS_TO_TARGET( cuda_target )
-# -- Adds the cublas library to the target (can be any target). Handles
-# whether you are in emulation mode or not.
-#
-# CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ...
-# [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] )
-# -- Creates an executable "cuda_target" which is made up of the files
-# specified. All of the non CUDA C files are compiled using the standard
-# build rules specified by CMAKE and the cuda files are compiled to object
-# files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is
-# added automatically to include_directories(). Some standard CMake target
-# calls can be used on the target after calling this macro
-# (e.g. set_target_properties and target_link_libraries), but setting
-# properties that adjust compilation flags will not affect code compiled by
-# nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE,
-# CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS.
-#
-# CUDA_ADD_LIBRARY( cuda_target file0 file1 ...
-# [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] )
-# -- Same as CUDA_ADD_EXECUTABLE except that a library is created.
-#
-# CUDA_BUILD_CLEAN_TARGET()
-# -- Creates a convience target that deletes all the dependency files
-# generated. You should make clean after running this target to ensure the
-# dependency files get regenerated.
-#
-# CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE]
-# [OPTIONS ...] )
-# -- Returns a list of generated files from the input source files to be used
-# with ADD_LIBRARY or ADD_EXECUTABLE.
-#
-# CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] )
-# -- Returns a list of PTX files generated from the input source files.
-#
-# CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] )
-# -- Returns a list of FATBIN files generated from the input source files.
-#
-# CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] )
-# -- Returns a list of CUBIN files generated from the input source files.
-#
-# CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var
-# cuda_target
-# object_files )
-# -- Compute the name of the intermediate link file used for separable
-# compilation. This file name is typically passed into
-# CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced
-# based on cuda_target the list of objects files that need separable
-# compilation as specified by object_files. If the object_files list is
-# empty, then output_file_var will be empty. This function is called
-# automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that
-# this is a function and not a macro.
-#
-# CUDA_INCLUDE_DIRECTORIES( path0 path1 ... )
-# -- Sets the directories that should be passed to nvcc
-# (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu
-# files.
-#
-#
-# CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target
-# nvcc_flags object_files)
-# -- Generates the link object required by separable compilation from the given
-# object files. This is called automatically for CUDA_ADD_EXECUTABLE and
-# CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS
-# directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the
-# nvcc_flags passed in are the same as the flags passed in via the OPTIONS
-# argument. The only nvcc flag added automatically is the bitness flag as
-# specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function
-# instead of a macro.
-#
-# CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures])
-# -- Selects GPU arch flags for nvcc based on target_CUDA_architectures
-# target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...)
-# - "Auto" detects local machine GPU compute arch at runtime.
-# - "Common" and "All" cover common and entire subsets of architectures
-# ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX
-# NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal
-# NUM: Any number. Only those pairs are currently accepted by NVCC though:
-# 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2
-# Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable}
-# Additionally, sets ${out_variable}_readable to the resulting numeric list
-# Example:
-# CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell)
-# LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS})
-#
-# More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA
-# Note that this is a function instead of a macro.
-#
-# CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ...
-# [STATIC | SHARED | MODULE] [OPTIONS ...] )
-# -- This is where all the magic happens. CUDA_ADD_EXECUTABLE,
-# CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this
-# function under the hood.
-#
-# Given the list of files (file0 file1 ... fileN) this macro generates
-# custom commands that generate either PTX or linkable objects (use "PTX" or
-# "OBJ" for the format argument to switch). Files that don't end with .cu
-# or have the HEADER_FILE_ONLY property are ignored.
-#
-# The arguments passed in after OPTIONS are extra command line options to
-# give to nvcc. You can also specify per configuration options by
-# specifying the name of the configuration followed by the options. General
-# options must precede configuration specific options. Not all
-# configurations need to be specified, only the ones provided will be used.
-#
-# OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag"
-# DEBUG -g
-# RELEASE --use_fast_math
-# RELWITHDEBINFO --use_fast_math;-g
-# MINSIZEREL --use_fast_math
-#
-# For certain configurations (namely VS generating object files with
-# CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will
-# be produced for the given cuda file. This is because when you add the
-# cuda file to Visual Studio it knows that this file produces an object file
-# and will link in the resulting object file automatically.
-#
-# This script will also generate a separate cmake script that is used at
-# build time to invoke nvcc. This is for several reasons.
-#
-# 1. nvcc can return negative numbers as return values which confuses
-# Visual Studio into thinking that the command succeeded. The script now
-# checks the error codes and produces errors when there was a problem.
-#
-# 2. nvcc has been known to not delete incomplete results when it
-# encounters problems. This confuses build systems into thinking the
-# target was generated when in fact an unusable file exists. The script
-# now deletes the output files if there was an error.
-#
-# 3. By putting all the options that affect the build into a file and then
-# make the build rule dependent on the file, the output files will be
-# regenerated when the options change.
-#
-# This script also looks at optional arguments STATIC, SHARED, or MODULE to
-# determine when to target the object compilation for a shared library.
-# BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in
-# CUDA_ADD_LIBRARY. On some systems special flags are added for building
-# objects intended for shared libraries. A preprocessor macro,
-# <target_name>_EXPORTS is defined when a shared library compilation is
-# detected.
-#
-# Flags passed into add_definitions with -D or /D are passed along to nvcc.
-#
-#
-#
-# The script defines the following variables::
-#
-# CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc.
-# CUDA_VERSION_MINOR -- The minor version.
-# CUDA_VERSION
-# CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR
-# CUDA_HAS_FP16 -- Whether a short float (float16,fp16) is supported.
-#
-# CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set).
-# CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the
-# SDK. This script will not directly support finding
-# specific libraries or headers, as that isn't
-# supported by NVIDIA. If you want to change
-# libraries when the path changes see the
-# FindCUDA.cmake script for an example of how to clear
-# these variables. There are also examples of how to
-# use the CUDA_SDK_ROOT_DIR to locate headers or
-# libraries, if you so choose (at your own risk).
-# CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically
-# for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY.
-# CUDA_LIBRARIES -- Cuda RT library.
-# CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT
-# implementation (alternative to:
-# CUDA_ADD_CUFFT_TO_TARGET macro)
-# CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS
-# implementation (alternative to:
-# CUDA_ADD_CUBLAS_TO_TARGET macro).
-# CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library.
-# Only available for CUDA version 5.5+
-# CUDA_cudadevrt_LIBRARY -- Device runtime library.
-# Required for separable compilation.
-# CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library.
-# Only available for CUDA version 4.0+.
-# CUDA_curand_LIBRARY -- CUDA Random Number Generation library.
-# Only available for CUDA version 3.2+.
-# CUDA_cusolver_LIBRARY -- CUDA Direct Solver library.
-# Only available for CUDA version 7.0+.
-# CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library.
-# Only available for CUDA version 3.2+.
-# CUDA_npp_LIBRARY -- NVIDIA Performance Primitives lib.
-# Only available for CUDA version 4.0+.
-# CUDA_nppc_LIBRARY -- NVIDIA Performance Primitives lib (core).
-# Only available for CUDA version 5.5+.
-# CUDA_nppi_LIBRARY -- NVIDIA Performance Primitives lib (image processing).
-# Only available for CUDA version 5.5+.
-# CUDA_npps_LIBRARY -- NVIDIA Performance Primitives lib (signal processing).
-# Only available for CUDA version 5.5+.
-# CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library.
-# Only available for CUDA version 3.2+.
-# Windows only.
-# CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library.
-# Only available for CUDA version 3.2+.
-# Windows only.
-#
+#[=======================================================================[.rst:
+FindCUDA
+--------
+
+.. deprecated:: 3.10
+
+ Superseded by first-class support for the CUDA language in CMake.
+
+Replacement
+^^^^^^^^^^^
+
+It is no longer necessary to use this module or call ``find_package(CUDA)``.
+Instead, list ``CUDA`` among the languages named in the top-level
+call to the :command:`project` command, or call the
+:command:`enable_language` command with ``CUDA``.
+Then one can add CUDA (``.cu``) sources to programs directly
+in calls to :command:`add_library` and :command:`add_executable`.
+
+Documentation of Deprecated Usage
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Tools for building CUDA C files: libraries and build dependencies.
+
+This script locates the NVIDIA CUDA C tools. It should work on Linux,
+Windows, and macOS and should be reasonably up to date with CUDA C
+releases.
+
+This script makes use of the standard :command:`find_package` arguments of
+``<VERSION>``, ``REQUIRED`` and ``QUIET``. ``CUDA_FOUND`` will report if an
+acceptable version of CUDA was found.
+
+The script will prompt the user to specify ``CUDA_TOOLKIT_ROOT_DIR`` if
+the prefix cannot be determined by the location of nvcc in the system
+path and ``REQUIRED`` is specified to :command:`find_package`. To use
+a different installed version of the toolkit set the environment variable
+``CUDA_BIN_PATH`` before running cmake (e.g.
+``CUDA_BIN_PATH=/usr/local/cuda1.0`` instead of the default
+``/usr/local/cuda``) or set ``CUDA_TOOLKIT_ROOT_DIR`` after configuring. If
+you change the value of ``CUDA_TOOLKIT_ROOT_DIR``, various components that
+depend on the path will be relocated.
+
+It might be necessary to set ``CUDA_TOOLKIT_ROOT_DIR`` manually on certain
+platforms, or to use a CUDA runtime not installed in the default
+location. In newer versions of the toolkit the CUDA library is
+included with the graphics driver -- be sure that the driver version
+matches what is needed by the CUDA runtime version.
+
+The following variables affect the behavior of the macros in the
+script (in alphabetical order). Note that any of these flags can be
+changed multiple times in the same directory before calling
+``CUDA_ADD_EXECUTABLE``, ``CUDA_ADD_LIBRARY``, ``CUDA_COMPILE``,
+``CUDA_COMPILE_PTX``, ``CUDA_COMPILE_FATBIN``, ``CUDA_COMPILE_CUBIN``
+or ``CUDA_WRAP_SRCS``::
+
+ CUDA_64_BIT_DEVICE_CODE (Default matches host bit size)
+ -- Set to ON to compile for 64 bit device code, OFF for 32 bit device code.
+ Note that making this different from the host code when generating object
+ or C files from CUDA code just won't work, because size_t gets defined by
+ nvcc in the generated source. If you compile to PTX and then load the
+ file yourself, you can mix bit sizes between device and host.
+
+ CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE (Default ON)
+ -- Set to ON if you want the custom build rule to be attached to the source
+ file in Visual Studio. Turn OFF if you add the same cuda file to multiple
+ targets.
+
+ This allows the user to build the target from the CUDA file; however, bad
+ things can happen if the CUDA source file is added to multiple targets.
+ When performing parallel builds it is possible for the custom build
+ command to be run more than once and in parallel causing cryptic build
+ errors. VS runs the rules for every source file in the target, and a
+ source can have only one rule no matter how many projects it is added to.
+ When the rule is run from multiple targets race conditions can occur on
+ the generated file. Eventually everything will get built, but if the user
+ is unaware of this behavior, there may be confusion. It would be nice if
+ this script could detect the reuse of source files across multiple targets
+ and turn the option off for the user, but no good solution could be found.
+
+ CUDA_BUILD_CUBIN (Default OFF)
+ -- Set to ON to enable and extra compilation pass with the -cubin option in
+ Device mode. The output is parsed and register, shared memory usage is
+ printed during build.
+
+ CUDA_BUILD_EMULATION (Default OFF for device mode)
+ -- Set to ON for Emulation mode. -D_DEVICEEMU is defined for CUDA C files
+ when CUDA_BUILD_EMULATION is TRUE.
+
+ CUDA_LINK_LIBRARIES_KEYWORD (Default "")
+ -- The <PRIVATE|PUBLIC|INTERFACE> keyword to use for internal
+ target_link_libraries calls. The default is to use no keyword which
+ uses the old "plain" form of target_link_libraries. Note that is matters
+ because whatever is used inside the FindCUDA module must also be used
+ outside - the two forms of target_link_libraries cannot be mixed.
+
+ CUDA_GENERATED_OUTPUT_DIR (Default CMAKE_CURRENT_BINARY_DIR)
+ -- Set to the path you wish to have the generated files placed. If it is
+ blank output files will be placed in CMAKE_CURRENT_BINARY_DIR.
+ Intermediate files will always be placed in
+ CMAKE_CURRENT_BINARY_DIR/CMakeFiles.
+
+ CUDA_HOST_COMPILATION_CPP (Default ON)
+ -- Set to OFF for C compilation of host code.
+
+ CUDA_HOST_COMPILER (Default CMAKE_C_COMPILER)
+ -- Set the host compiler to be used by nvcc. Ignored if -ccbin or
+ --compiler-bindir is already present in the CUDA_NVCC_FLAGS or
+ CUDA_NVCC_FLAGS_<CONFIG> variables. For Visual Studio targets,
+ the host compiler is constructed with one or more visual studio macros
+ such as $(VCInstallDir), that expands out to the path when
+ the command is run from within VS.
+ If the CUDAHOSTCXX environment variable is set it will
+ be used as the default.
+
+ CUDA_NVCC_FLAGS
+ CUDA_NVCC_FLAGS_<CONFIG>
+ -- Additional NVCC command line arguments. NOTE: multiple arguments must be
+ semi-colon delimited (e.g. --compiler-options;-Wall)
+
+ CUDA_PROPAGATE_HOST_FLAGS (Default ON)
+ -- Set to ON to propagate CMAKE_{C,CXX}_FLAGS and their configuration
+ dependent counterparts (e.g. CMAKE_C_FLAGS_DEBUG) automatically to the
+ host compiler through nvcc's -Xcompiler flag. This helps make the
+ generated host code match the rest of the system better. Sometimes
+ certain flags give nvcc problems, and this will help you turn the flag
+ propagation off. This does not affect the flags supplied directly to nvcc
+ via CUDA_NVCC_FLAGS or through the OPTION flags specified through
+ CUDA_ADD_LIBRARY, CUDA_ADD_EXECUTABLE, or CUDA_WRAP_SRCS. Flags used for
+ shared library compilation are not affected by this flag.
+
+ CUDA_SEPARABLE_COMPILATION (Default OFF)
+ -- If set this will enable separable compilation for all CUDA runtime object
+ files. If used outside of CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY
+ (e.g. calling CUDA_WRAP_SRCS directly),
+ CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME and
+ CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS should be called.
+
+ CUDA_SOURCE_PROPERTY_FORMAT
+ -- If this source file property is set, it can override the format specified
+ to CUDA_WRAP_SRCS (OBJ, PTX, CUBIN, or FATBIN). If an input source file
+ is not a .cu file, setting this file will cause it to be treated as a .cu
+ file. See documentation for set_source_files_properties on how to set
+ this property.
+
+ CUDA_USE_STATIC_CUDA_RUNTIME (Default ON)
+ -- When enabled the static version of the CUDA runtime library will be used
+ in CUDA_LIBRARIES. If the version of CUDA configured doesn't support
+ this option, then it will be silently disabled.
+
+ CUDA_VERBOSE_BUILD (Default OFF)
+ -- Set to ON to see all the commands used when building the CUDA file. When
+ using a Makefile generator the value defaults to VERBOSE (run make
+ VERBOSE=1 to see output), although setting CUDA_VERBOSE_BUILD to ON will
+ always print the output.
+
+The script creates the following macros (in alphabetical order)::
+
+ CUDA_ADD_CUFFT_TO_TARGET( cuda_target )
+ -- Adds the cufft library to the target (can be any target). Handles whether
+ you are in emulation mode or not.
+
+ CUDA_ADD_CUBLAS_TO_TARGET( cuda_target )
+ -- Adds the cublas library to the target (can be any target). Handles
+ whether you are in emulation mode or not.
+
+ CUDA_ADD_EXECUTABLE( cuda_target file0 file1 ...
+ [WIN32] [MACOSX_BUNDLE] [EXCLUDE_FROM_ALL] [OPTIONS ...] )
+ -- Creates an executable "cuda_target" which is made up of the files
+ specified. All of the non CUDA C files are compiled using the standard
+ build rules specified by CMAKE and the cuda files are compiled to object
+ files using nvcc and the host compiler. In addition CUDA_INCLUDE_DIRS is
+ added automatically to include_directories(). Some standard CMake target
+ calls can be used on the target after calling this macro
+ (e.g. set_target_properties and target_link_libraries), but setting
+ properties that adjust compilation flags will not affect code compiled by
+ nvcc. Such flags should be modified before calling CUDA_ADD_EXECUTABLE,
+ CUDA_ADD_LIBRARY or CUDA_WRAP_SRCS.
+
+ CUDA_ADD_LIBRARY( cuda_target file0 file1 ...
+ [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] [OPTIONS ...] )
+ -- Same as CUDA_ADD_EXECUTABLE except that a library is created.
+
+ CUDA_BUILD_CLEAN_TARGET()
+ -- Creates a convenience target that deletes all the dependency files
+ generated. You should make clean after running this target to ensure the
+ dependency files get regenerated.
+
+ CUDA_COMPILE( generated_files file0 file1 ... [STATIC | SHARED | MODULE]
+ [OPTIONS ...] )
+ -- Returns a list of generated files from the input source files to be used
+ with ADD_LIBRARY or ADD_EXECUTABLE.
+
+ CUDA_COMPILE_PTX( generated_files file0 file1 ... [OPTIONS ...] )
+ -- Returns a list of PTX files generated from the input source files.
+
+ CUDA_COMPILE_FATBIN( generated_files file0 file1 ... [OPTIONS ...] )
+ -- Returns a list of FATBIN files generated from the input source files.
+
+ CUDA_COMPILE_CUBIN( generated_files file0 file1 ... [OPTIONS ...] )
+ -- Returns a list of CUBIN files generated from the input source files.
+
+ CUDA_COMPUTE_SEPARABLE_COMPILATION_OBJECT_FILE_NAME( output_file_var
+ cuda_target
+ object_files )
+ -- Compute the name of the intermediate link file used for separable
+ compilation. This file name is typically passed into
+ CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS. output_file_var is produced
+ based on cuda_target the list of objects files that need separable
+ compilation as specified by object_files. If the object_files list is
+ empty, then output_file_var will be empty. This function is called
+ automatically for CUDA_ADD_LIBRARY and CUDA_ADD_EXECUTABLE. Note that
+ this is a function and not a macro.
+
+ CUDA_INCLUDE_DIRECTORIES( path0 path1 ... )
+ -- Sets the directories that should be passed to nvcc
+ (e.g. nvcc -Ipath0 -Ipath1 ... ). These paths usually contain other .cu
+ files.
+
+
+ CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS( output_file_var cuda_target
+ nvcc_flags object_files)
+ -- Generates the link object required by separable compilation from the given
+ object files. This is called automatically for CUDA_ADD_EXECUTABLE and
+ CUDA_ADD_LIBRARY, but can be called manually when using CUDA_WRAP_SRCS
+ directly. When called from CUDA_ADD_LIBRARY or CUDA_ADD_EXECUTABLE the
+ nvcc_flags passed in are the same as the flags passed in via the OPTIONS
+ argument. The only nvcc flag added automatically is the bitness flag as
+ specified by CUDA_64_BIT_DEVICE_CODE. Note that this is a function
+ instead of a macro.
+
+ CUDA_SELECT_NVCC_ARCH_FLAGS(out_variable [target_CUDA_architectures])
+ -- Selects GPU arch flags for nvcc based on target_CUDA_architectures
+ target_CUDA_architectures : Auto | Common | All | LIST(ARCH_AND_PTX ...)
+ - "Auto" detects local machine GPU compute arch at runtime.
+ - "Common" and "All" cover common and entire subsets of architectures
+ ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX
+ NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal
+ NUM: Any number. Only those pairs are currently accepted by NVCC though:
+ 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2
+ Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable}
+ Additionally, sets ${out_variable}_readable to the resulting numeric list
+ Example:
+ CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS 3.0 3.5+PTX 5.2(5.0) Maxwell)
+ LIST(APPEND CUDA_NVCC_FLAGS ${ARCH_FLAGS})
+
+ More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA
+ Note that this is a function instead of a macro.
+
+ CUDA_WRAP_SRCS ( cuda_target format generated_files file0 file1 ...
+ [STATIC | SHARED | MODULE] [OPTIONS ...] )
+ -- This is where all the magic happens. CUDA_ADD_EXECUTABLE,
+ CUDA_ADD_LIBRARY, CUDA_COMPILE, and CUDA_COMPILE_PTX all call this
+ function under the hood.
+
+ Given the list of files (file0 file1 ... fileN) this macro generates
+ custom commands that generate either PTX or linkable objects (use "PTX" or
+ "OBJ" for the format argument to switch). Files that don't end with .cu
+ or have the HEADER_FILE_ONLY property are ignored.
+
+ The arguments passed in after OPTIONS are extra command line options to
+ give to nvcc. You can also specify per configuration options by
+ specifying the name of the configuration followed by the options. General
+ options must precede configuration specific options. Not all
+ configurations need to be specified, only the ones provided will be used.
+
+ OPTIONS -DFLAG=2 "-DFLAG_OTHER=space in flag"
+ DEBUG -g
+ RELEASE --use_fast_math
+ RELWITHDEBINFO --use_fast_math;-g
+ MINSIZEREL --use_fast_math
+
+ For certain configurations (namely VS generating object files with
+ CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE set to ON), no generated file will
+ be produced for the given cuda file. This is because when you add the
+ cuda file to Visual Studio it knows that this file produces an object file
+ and will link in the resulting object file automatically.
+
+ This script will also generate a separate cmake script that is used at
+ build time to invoke nvcc. This is for several reasons.
+
+ 1. nvcc can return negative numbers as return values which confuses
+ Visual Studio into thinking that the command succeeded. The script now
+ checks the error codes and produces errors when there was a problem.
+
+ 2. nvcc has been known to not delete incomplete results when it
+ encounters problems. This confuses build systems into thinking the
+ target was generated when in fact an unusable file exists. The script
+ now deletes the output files if there was an error.
+
+ 3. By putting all the options that affect the build into a file and then
+ make the build rule dependent on the file, the output files will be
+ regenerated when the options change.
+
+ This script also looks at optional arguments STATIC, SHARED, or MODULE to
+ determine when to target the object compilation for a shared library.
+ BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in
+ CUDA_ADD_LIBRARY. On some systems special flags are added for building
+ objects intended for shared libraries. A preprocessor macro,
+ <target_name>_EXPORTS is defined when a shared library compilation is
+ detected.
+
+ Flags passed into add_definitions with -D or /D are passed along to nvcc.
+
+
+
+The script defines the following variables::
+
+ CUDA_VERSION_MAJOR -- The major version of cuda as reported by nvcc.
+ CUDA_VERSION_MINOR -- The minor version.
+ CUDA_VERSION
+ CUDA_VERSION_STRING -- CUDA_VERSION_MAJOR.CUDA_VERSION_MINOR
+ CUDA_HAS_FP16 -- Whether a short float (float16,fp16) is supported.
+
+ CUDA_TOOLKIT_ROOT_DIR -- Path to the CUDA Toolkit (defined if not set).
+ CUDA_SDK_ROOT_DIR -- Path to the CUDA SDK. Use this to find files in the
+ SDK. This script will not directly support finding
+ specific libraries or headers, as that isn't
+ supported by NVIDIA. If you want to change
+ libraries when the path changes see the
+ FindCUDA.cmake script for an example of how to clear
+ these variables. There are also examples of how to
+ use the CUDA_SDK_ROOT_DIR to locate headers or
+ libraries, if you so choose (at your own risk).
+ CUDA_INCLUDE_DIRS -- Include directory for cuda headers. Added automatically
+ for CUDA_ADD_EXECUTABLE and CUDA_ADD_LIBRARY.
+ CUDA_LIBRARIES -- Cuda RT library.
+ CUDA_CUFFT_LIBRARIES -- Device or emulation library for the Cuda FFT
+ implementation (alternative to:
+ CUDA_ADD_CUFFT_TO_TARGET macro)
+ CUDA_CUBLAS_LIBRARIES -- Device or emulation library for the Cuda BLAS
+ implementation (alternative to:
+ CUDA_ADD_CUBLAS_TO_TARGET macro).
+ CUDA_cudart_static_LIBRARY -- Statically linkable cuda runtime library.
+ Only available for CUDA version 5.5+
+ CUDA_cudadevrt_LIBRARY -- Device runtime library.
+ Required for separable compilation.
+ CUDA_cupti_LIBRARY -- CUDA Profiling Tools Interface library.
+ Only available for CUDA version 4.0+.
+ CUDA_curand_LIBRARY -- CUDA Random Number Generation library.
+ Only available for CUDA version 3.2+.
+ CUDA_cusolver_LIBRARY -- CUDA Direct Solver library.
+ Only available for CUDA version 7.0+.
+ CUDA_cusparse_LIBRARY -- CUDA Sparse Matrix library.
+ Only available for CUDA version 3.2+.
+ CUDA_npp_LIBRARY -- NVIDIA Performance Primitives lib.
+ Only available for CUDA version 4.0+.
+ CUDA_nppc_LIBRARY -- NVIDIA Performance Primitives lib (core).
+ Only available for CUDA version 5.5+.
+ CUDA_nppi_LIBRARY -- NVIDIA Performance Primitives lib (image processing).
+ Only available for CUDA version 5.5 - 8.0.
+ CUDA_nppial_LIBRARY -- NVIDIA Performance Primitives lib (image processing).
+ Only available for CUDA version 9.0.
+ CUDA_nppicc_LIBRARY -- NVIDIA Performance Primitives lib (image processing).
+ Only available for CUDA version 9.0.
+ CUDA_nppicom_LIBRARY -- NVIDIA Performance Primitives lib (image processing).
+ Only available for CUDA version 9.0.
+ CUDA_nppidei_LIBRARY -- NVIDIA Performance Primitives lib (image processing).
+ Only available for CUDA version 9.0.
+ CUDA_nppif_LIBRARY -- NVIDIA Performance Primitives lib (image processing).
+ Only available for CUDA version 9.0.
+ CUDA_nppig_LIBRARY -- NVIDIA Performance Primitives lib (image processing).
+ Only available for CUDA version 9.0.
+ CUDA_nppim_LIBRARY -- NVIDIA Performance Primitives lib (image processing).
+ Only available for CUDA version 9.0.
+ CUDA_nppist_LIBRARY -- NVIDIA Performance Primitives lib (image processing).
+ Only available for CUDA version 9.0.
+ CUDA_nppisu_LIBRARY -- NVIDIA Performance Primitives lib (image processing).
+ Only available for CUDA version 9.0.
+ CUDA_nppitc_LIBRARY -- NVIDIA Performance Primitives lib (image processing).
+ Only available for CUDA version 9.0.
+ CUDA_npps_LIBRARY -- NVIDIA Performance Primitives lib (signal processing).
+ Only available for CUDA version 5.5+.
+ CUDA_nvcuvenc_LIBRARY -- CUDA Video Encoder library.
+ Only available for CUDA version 3.2+.
+ Windows only.
+ CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library.
+ Only available for CUDA version 3.2+.
+ Windows only.
+ CUDA_nvToolsExt_LIBRARY
+ -- NVIDA CUDA Tools Extension library.
+ Available for CUDA version 5+.
+ CUDA_OpenCL_LIBRARY -- NVIDA CUDA OpenCL library.
+ Available for CUDA version 5+.
+
+#]=======================================================================]
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
@@ -489,10 +536,18 @@ set(CUDA_GENERATED_OUTPUT_DIR "" CACHE PATH "Directory to put all the output fil
option(CUDA_HOST_COMPILATION_CPP "Generated file extension" ON)
# Extra user settable flags
-set(CUDA_NVCC_FLAGS "" CACHE STRING "Semi-colon delimit multiple arguments.")
+cmake_initialize_per_config_variable(CUDA_NVCC_FLAGS "Semi-colon delimit multiple arguments.")
+
+if(DEFINED ENV{CUDAHOSTCXX})
+ set(CUDA_HOST_COMPILER "$ENV{CUDAHOSTCXX}" CACHE FILEPATH "Host side compiler used by NVCC")
+elseif(CMAKE_GENERATOR MATCHES "Visual Studio")
+ set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)")
+ if(MSVC_VERSION LESS 1910)
+ set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin")
+ endif()
+
+ set(CUDA_HOST_COMPILER "${_CUDA_MSVC_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC")
-if(CMAKE_GENERATOR MATCHES "Visual Studio")
- set(CUDA_HOST_COMPILER "$(VCInstallDir)bin" CACHE FILEPATH "Host side compiler used by NVCC")
else()
if(APPLE
AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang"
@@ -515,6 +570,11 @@ else()
set(c_compiler_realpath "")
endif()
set(CUDA_HOST_COMPILER "${c_compiler_realpath}" CACHE FILEPATH "Host side compiler used by NVCC")
+ elseif(MSVC AND "${CMAKE_C_COMPILER}" MATCHES "clcache|sccache")
+ # NVCC does not think it will work if it is passed clcache.exe or sccache.exe
+ # as the host compiler, which means that builds with CC=cl.exe won't work.
+ # Best to just feed it whatever the actual cl.exe is as the host compiler.
+ set(CUDA_HOST_COMPILER "cl.exe" CACHE FILEPATH "Host side compiler used by NVCC")
else()
set(CUDA_HOST_COMPILER "${CMAKE_C_COMPILER}"
CACHE FILEPATH "Host side compiler used by NVCC")
@@ -522,7 +582,7 @@ else()
endif()
# Propagate the host flags to the host compiler via -Xcompiler
-option(CUDA_PROPAGATE_HOST_FLAGS "Propage C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON)
+option(CUDA_PROPAGATE_HOST_FLAGS "Propagate C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON)
# Enable CUDA_SEPARABLE_COMPILATION
option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled. Requires CUDA 5.0+" OFF)
@@ -543,19 +603,17 @@ mark_as_advanced(
CUDA_SEPARABLE_COMPILATION
)
-# Makefile and similar generators don't define CMAKE_CONFIGURATION_TYPES, so we
-# need to add another entry for the CMAKE_BUILD_TYPE. We also need to add the
-# standerd set of 4 build types (Debug, MinSizeRel, Release, and RelWithDebInfo)
-# for completeness. We need run this loop in order to accomodate the addition
-# of extra configuration types. Duplicate entries will be removed by
-# REMOVE_DUPLICATES.
+# Single config generators like Makefiles or Ninja don't usually have
+# CMAKE_CONFIGURATION_TYPES defined (but note that it can be defined if set by
+# projects or developers). Even CMAKE_BUILD_TYPE might not be defined for
+# single config generators (and should not be defined for multi-config
+# generators). To ensure we get a complete superset of all possible
+# configurations, we combine CMAKE_CONFIGURATION_TYPES, CMAKE_BUILD_TYPE and
+# all of the standard configurations, then weed out duplicates with
+# list(REMOVE_DUPLICATES). Looping over the unique set then ensures we have
+# each configuration-specific set of nvcc flags defined and marked as advanced.
set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo)
list(REMOVE_DUPLICATES CUDA_configuration_types)
-foreach(config ${CUDA_configuration_types})
- string(TOUPPER ${config} config_upper)
- set(CUDA_NVCC_FLAGS_${config_upper} "" CACHE STRING "Semi-colon delimit multiple arguments.")
- mark_as_advanced(CUDA_NVCC_FLAGS_${config_upper})
-endforeach()
###############################################################################
###############################################################################
@@ -589,7 +647,8 @@ macro(cuda_unset_include_and_libraries)
unset(CUDA_npps_LIBRARY CACHE)
unset(CUDA_nvcuvenc_LIBRARY CACHE)
unset(CUDA_nvcuvid_LIBRARY CACHE)
- unset(CUDA_USE_STATIC_CUDA_RUNTIME CACHE)
+ unset(CUDA_nvToolsExt_LIBRARY CACHE)
+ unset(CUDA_OpenCL_LIBRARY CACHE)
unset(CUDA_GPU_DETECT_OUTPUT CACHE)
endmacro()
@@ -632,8 +691,7 @@ if(NOT CUDA_TOOLKIT_ROOT_DIR AND NOT CMAKE_CROSSCOMPILING)
find_path(CUDA_TOOLKIT_ROOT_DIR
NAMES nvcc nvcc.exe
PATHS /opt/cuda/bin
- /usr/local/bin
- /usr/local/cuda/bin
+ PATH_SUFFIXES cuda/bin
DOC "Toolkit location."
)
@@ -679,7 +737,11 @@ if(CMAKE_CROSSCOMPILING)
# add known CUDA targetr root path to the set of directories we search for programs, libraries and headers
set( CMAKE_FIND_ROOT_PATH "${CUDA_TOOLKIT_TARGET_DIR};${CMAKE_FIND_ROOT_PATH}")
macro( cuda_find_host_program )
- find_host_program( ${ARGN} )
+ if (COMMAND find_host_program)
+ find_host_program( ${ARGN} )
+ else()
+ find_program( ${ARGN} )
+ endif()
endmacro()
else()
# for non-cross-compile, find_host_program == find_program and CUDA_TOOLKIT_TARGET_DIR == CUDA_TOOLKIT_ROOT_DIR
@@ -691,16 +753,20 @@ endif()
# CUDA_NVCC_EXECUTABLE
-cuda_find_host_program(CUDA_NVCC_EXECUTABLE
- NAMES nvcc
- PATHS "${CUDA_TOOLKIT_ROOT_DIR}"
- ENV CUDA_PATH
- ENV CUDA_BIN_PATH
- PATH_SUFFIXES bin bin64
- NO_DEFAULT_PATH
- )
-# Search default search paths, after we search our own set of paths.
-cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc)
+if(DEFINED ENV{CUDA_NVCC_EXECUTABLE})
+ set(CUDA_NVCC_EXECUTABLE "$ENV{CUDA_NVCC_EXECUTABLE}" CACHE FILEPATH "The CUDA compiler")
+else()
+ cuda_find_host_program(CUDA_NVCC_EXECUTABLE
+ NAMES nvcc
+ PATHS "${CUDA_TOOLKIT_ROOT_DIR}"
+ ENV CUDA_PATH
+ ENV CUDA_BIN_PATH
+ PATH_SUFFIXES bin bin64
+ NO_DEFAULT_PATH
+ )
+ # Search default search paths, after we search our own set of paths.
+ cuda_find_host_program(CUDA_NVCC_EXECUTABLE nvcc)
+endif()
mark_as_advanced(CUDA_NVCC_EXECUTABLE)
if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION)
@@ -798,12 +864,17 @@ endif()
if(CUDA_cudart_static_LIBRARY)
# If static cudart available, use it by default, but provide a user-visible option to disable it.
option(CUDA_USE_STATIC_CUDA_RUNTIME "Use the static version of the CUDA runtime library if available" ON)
- set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY)
else()
# If not available, silently disable the option.
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "")
+endif()
+
+if(CUDA_USE_STATIC_CUDA_RUNTIME)
+ set(CUDA_CUDART_LIBRARY_VAR CUDA_cudart_static_LIBRARY)
+else()
set(CUDA_CUDART_LIBRARY_VAR CUDA_CUDART_LIBRARY)
endif()
+
if(NOT CUDA_VERSION VERSION_LESS "5.0")
cuda_find_library_local_first(CUDA_cudadevrt_LIBRARY cudadevrt "\"cudadevrt\" library")
mark_as_advanced(CUDA_cudadevrt_LIBRARY)
@@ -811,11 +882,7 @@ endif()
if(CUDA_USE_STATIC_CUDA_RUNTIME)
if(UNIX)
- # Check for the dependent libraries. Here we look for pthreads.
- if (DEFINED CMAKE_THREAD_PREFER_PTHREAD)
- set(_cuda_cmake_thread_prefer_pthread ${CMAKE_THREAD_PREFER_PTHREAD})
- endif()
- set(CMAKE_THREAD_PREFER_PTHREAD 1)
+ # Check for the dependent libraries.
# Many of the FindXYZ CMake comes with makes use of try_compile with int main(){return 0;}
# as the source file. Unfortunately this causes a warning with -Wstrict-prototypes and
@@ -826,13 +893,6 @@ if(CUDA_USE_STATIC_CUDA_RUNTIME)
find_package(Threads REQUIRED)
set(CMAKE_C_FLAGS ${_cuda_cmake_c_flags})
- if (DEFINED _cuda_cmake_thread_prefer_pthread)
- set(CMAKE_THREAD_PREFER_PTHREAD ${_cuda_cmake_thread_prefer_pthread})
- unset(_cuda_cmake_thread_prefer_pthread)
- else()
- unset(CMAKE_THREAD_PREFER_PTHREAD)
- endif()
-
if(NOT APPLE)
#On Linux, you must link against librt when using the static cuda runtime.
find_library(CUDA_rt_LIBRARY rt)
@@ -915,9 +975,33 @@ if(NOT CUDA_VERSION VERSION_LESS "3.2")
find_cuda_helper_libs(nvcuvid)
endif()
endif()
-if(CUDA_VERSION VERSION_GREATER "5.0")
+if(CUDA_VERSION VERSION_GREATER "5.0" AND CUDA_VERSION VERSION_LESS "9.2")
+ # In CUDA 9.2 cublas_device was deprecated
find_cuda_helper_libs(cublas_device)
- # In CUDA 5.5 NPP was splitted onto 3 separate libraries.
+endif()
+
+if(NOT CUDA_VERSION VERSION_LESS "5.0")
+ find_cuda_helper_libs(nvToolsExt)
+ find_cuda_helper_libs(OpenCL)
+endif()
+
+if(NOT CUDA_VERSION VERSION_LESS "9.0")
+ # In CUDA 9.0 NPP was nppi was removed
+ find_cuda_helper_libs(nppc)
+ find_cuda_helper_libs(nppial)
+ find_cuda_helper_libs(nppicc)
+ find_cuda_helper_libs(nppicom)
+ find_cuda_helper_libs(nppidei)
+ find_cuda_helper_libs(nppif)
+ find_cuda_helper_libs(nppig)
+ find_cuda_helper_libs(nppim)
+ find_cuda_helper_libs(nppist)
+ find_cuda_helper_libs(nppisu)
+ find_cuda_helper_libs(nppitc)
+ find_cuda_helper_libs(npps)
+ set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}")
+elseif(CUDA_VERSION VERSION_GREATER "5.0")
+ # In CUDA 5.5 NPP was split into 3 separate libraries.
find_cuda_helper_libs(nppc)
find_cuda_helper_libs(nppi)
find_cuda_helper_libs(npps)
@@ -1255,11 +1339,11 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
endif()
# This needs to be passed in at this stage, because VS needs to fill out the
- # value of VCInstallDir from within VS. Note that CCBIN is only used if
+ # various macros from within VS. Note that CCBIN is only used if
# -ccbin or --compiler-bindir isn't used and CUDA_HOST_COMPILER matches
- # $(VCInstallDir)/bin.
+ # _CUDA_MSVC_HOST_COMPILER
if(CMAKE_GENERATOR MATCHES "Visual Studio")
- set(ccbin_flags -D "\"CCBIN:PATH=$(VCInstallDir)bin\"" )
+ set(ccbin_flags -D "\"CCBIN:PATH=${_CUDA_MSVC_HOST_COMPILER}\"" )
else()
set(ccbin_flags)
endif()
@@ -1378,7 +1462,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
if( "${_cuda_host_flags}" MATCHES "-std=c\\+\\+11")
# Add the c++11 flag to nvcc if it isn't already present. Note that we only look at
# the main flag instead of the configuration specific flags.
- if( NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std;c\\+\\+11" )
+ if( NOT "${CUDA_NVCC_FLAGS}" MATCHES "-std=c\\+\\+11" )
list(APPEND nvcc_flags --std c++11)
endif()
string(REGEX REPLACE "[-]+std=c\\+\\+11" "" _cuda_host_flags "${_cuda_host_flags}")
@@ -1499,7 +1583,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
# Bring in the dependencies. Creates a variable CUDA_NVCC_DEPEND #######
cuda_include_nvcc_dependencies(${cmake_dependency_file})
- # Convience string for output ###########################################
+ # Convenience string for output #########################################
if(CUDA_BUILD_EMULATION)
set(cuda_build_type "Emulation")
else()
@@ -1698,6 +1782,7 @@ function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options
COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} -dlink ${object_files} -o ${output_file}
${flags}
COMMENT "Building NVCC intermediate link file ${output_file_relative_path}"
+ COMMAND_EXPAND_LISTS
${_verbatim}
)
else()
@@ -1708,6 +1793,7 @@ function(CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS output_file cuda_target options
COMMAND ${CMAKE_COMMAND} -E echo "Building NVCC intermediate link file ${output_file_relative_path}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${output_file_dir}"
COMMAND ${CUDA_NVCC_EXECUTABLE} ${nvcc_flags} ${flags} -dlink ${object_files} -o "${output_file}"
+ COMMAND_EXPAND_LISTS
${_verbatim}
)
endif()
@@ -1908,9 +1994,9 @@ endmacro()
###############################################################################
###############################################################################
macro(CUDA_BUILD_CLEAN_TARGET)
- # Call this after you add all your CUDA targets, and you will get a convience
- # target. You should also make clean after running this target to get the
- # build system to generate all the code again.
+ # Call this after you add all your CUDA targets, and you will get a
+ # convenience target. You should also make clean after running this target
+ # to get the build system to generate all the code again.
set(cuda_clean_target_name clean_cuda_depends)
if (CMAKE_GENERATOR MATCHES "Visual Studio")
diff --git a/Modules/FindCUDA/make2cmake.cmake b/Modules/FindCUDA/make2cmake.cmake
index 7b5389ec5..580f24a40 100644
--- a/Modules/FindCUDA/make2cmake.cmake
+++ b/Modules/FindCUDA/make2cmake.cmake
@@ -40,7 +40,7 @@
# verbose:BOOL=<> OFF: Be as quiet as possible (default)
# ON : Extra output
#
-# input_file:FILEPATH=<> Path to dependecy file in makefile format
+# input_file:FILEPATH=<> Path to dependency file in makefile format
#
# output_file:FILEPATH=<> Path to file with dependencies in CMake readable variable
#
diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake
index 25f2f72a2..af15d55e5 100644
--- a/Modules/FindCUDA/run_nvcc.cmake
+++ b/Modules/FindCUDA/run_nvcc.cmake
@@ -50,6 +50,8 @@
# generated_cubin_file:STRING=<> File to generate. This argument must be passed
# in if build_cubin is true.
+cmake_policy(PUSH)
+cmake_policy(SET CMP0007 NEW)
if(NOT generated_file)
message(FATAL_ERROR "You must specify generated_file on the command line")
endif()
@@ -73,8 +75,9 @@ set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@") # path
set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@) # list
@CUDA_NVCC_FLAGS_CONFIG@
set(nvcc_flags @nvcc_flags@) # list
-set(CUDA_NVCC_INCLUDE_DIRS "@CUDA_NVCC_INCLUDE_DIRS@") # list (needs to be in quotes to handle spaces properly).
-set(CUDA_NVCC_COMPILE_DEFINITIONS [==[@CUDA_NVCC_COMPILE_DEFINITIONS@]==]) # list (needs to be in quotes to handle spaces properly).
+set(CUDA_NVCC_INCLUDE_DIRS [==[@CUDA_NVCC_INCLUDE_DIRS@]==]) # list (needs to be in lua quotes to address backslashes)
+string(REPLACE "\\" "/" CUDA_NVCC_INCLUDE_DIRS "${CUDA_NVCC_INCLUDE_DIRS}")
+set(CUDA_NVCC_COMPILE_DEFINITIONS [==[@CUDA_NVCC_COMPILE_DEFINITIONS@]==]) # list (needs to be in lua quotes see #16510 ).
set(format_flag "@format_flag@") # string
set(cuda_language_flag @cuda_language_flag@) # list
@@ -123,7 +126,7 @@ list(APPEND CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS_${build_configuration}})
list( FIND CUDA_NVCC_FLAGS "-ccbin" ccbin_found0 )
list( FIND CUDA_NVCC_FLAGS "--compiler-bindir" ccbin_found1 )
if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER )
- if (CUDA_HOST_COMPILER STREQUAL "$(VCInstallDir)bin" AND DEFINED CCBIN)
+ if (CUDA_HOST_COMPILER STREQUAL "@_CUDA_MSVC_HOST_COMPILER@" AND DEFINED CCBIN)
set(CCBIN -ccbin "${CCBIN}")
else()
set(CCBIN -ccbin "${CUDA_HOST_COMPILER}")
@@ -179,18 +182,13 @@ cuda_execute_process(
set(depends_CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}")
set(CUDA_VERSION @CUDA_VERSION@)
if(CUDA_VERSION VERSION_LESS "3.0")
- cmake_policy(PUSH)
- # CMake policy 0007 NEW states that empty list elements are not
- # ignored. I'm just setting it to avoid the warning that's printed.
- cmake_policy(SET CMP0007 NEW)
- # Note that this will remove all occurances of -G.
+ # Note that this will remove all occurrences of -G.
list(REMOVE_ITEM depends_CUDA_NVCC_FLAGS "-G")
- cmake_policy(POP)
endif()
# nvcc doesn't define __CUDACC__ for some reason when generating dependency files. This
# can cause incorrect dependencies when #including files based on this macro which is
-# defined in the generating passes of nvcc invokation. We will go ahead and manually
+# defined in the generating passes of nvcc invocation. We will go ahead and manually
# define this for now until a future version fixes this bug.
set(CUDACC_DEFINE -D__CUDACC__)
@@ -304,3 +302,5 @@ if( build_cubin )
)
endif()
+
+cmake_policy(POP)
diff --git a/Modules/FindCUDA/select_compute_arch.cmake b/Modules/FindCUDA/select_compute_arch.cmake
index 8fb44d80a..7ddb70969 100644
--- a/Modules/FindCUDA/select_compute_arch.cmake
+++ b/Modules/FindCUDA/select_compute_arch.cmake
@@ -5,9 +5,9 @@
# - "Auto" detects local machine GPU compute arch at runtime.
# - "Common" and "All" cover common and entire subsets of architectures
# ARCH_AND_PTX : NAME | NUM.NUM | NUM.NUM(NUM.NUM) | NUM.NUM+PTX
-# NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal
+# NAME: Fermi Kepler Maxwell Kepler+Tegra Kepler+Tesla Maxwell+Tegra Pascal Volta Turing
# NUM: Any number. Only those pairs are currently accepted by NVCC though:
-# 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2
+# 2.0 2.1 3.0 3.2 3.5 3.7 5.0 5.2 5.3 6.0 6.2 7.0 7.2 7.5
# Returns LIST of flags to be added to CUDA_NVCC_FLAGS in ${out_variable}
# Additionally, sets ${out_variable}_readable to the resulting numeric list
# Example:
@@ -17,25 +17,68 @@
# More info on CUDA architectures: https://en.wikipedia.org/wiki/CUDA
#
+if(CMAKE_CUDA_COMPILER_LOADED) # CUDA as a language
+ if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA"
+ AND CMAKE_CUDA_COMPILER_VERSION MATCHES "^([0-9]+\\.[0-9]+)")
+ set(CUDA_VERSION "${CMAKE_MATCH_1}")
+ endif()
+endif()
+
+# See: https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#gpu-feature-list
+
# This list will be used for CUDA_ARCH_NAME = All option
set(CUDA_KNOWN_GPU_ARCHITECTURES "Fermi" "Kepler" "Maxwell")
# This list will be used for CUDA_ARCH_NAME = Common option (enabled by default)
set(CUDA_COMMON_GPU_ARCHITECTURES "3.0" "3.5" "5.0")
-if (CUDA_VERSION VERSION_GREATER "6.5")
+if(CUDA_VERSION VERSION_LESS "7.0")
+ set(CUDA_LIMIT_GPU_ARCHITECTURE "5.2")
+endif()
+
+# This list is used to filter CUDA archs when autodetecting
+set(CUDA_ALL_GPU_ARCHITECTURES "3.0" "3.2" "3.5" "5.0")
+
+if(CUDA_VERSION VERSION_GREATER_EQUAL "7.0")
list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Kepler+Tegra" "Kepler+Tesla" "Maxwell+Tegra")
list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "5.2")
-endif ()
-if (CUDA_VERSION VERSION_GREATER "7.5")
+ if(CUDA_VERSION VERSION_LESS "8.0")
+ list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "5.2+PTX")
+ set(CUDA_LIMIT_GPU_ARCHITECTURE "6.0")
+ endif()
+endif()
+
+if(CUDA_VERSION VERSION_GREATER_EQUAL "8.0")
list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Pascal")
- list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "6.0" "6.1" "6.1+PTX")
-else()
- list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "5.2+PTX")
+ list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "6.0" "6.1")
+ list(APPEND CUDA_ALL_GPU_ARCHITECTURES "6.0" "6.1" "6.2")
+
+ if(CUDA_VERSION VERSION_LESS "9.0")
+ list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "6.1+PTX")
+ set(CUDA_LIMIT_GPU_ARCHITECTURE "7.0")
+ endif()
endif ()
+if(CUDA_VERSION VERSION_GREATER_EQUAL "9.0")
+ list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Volta")
+ list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "7.0" "7.0+PTX")
+ list(APPEND CUDA_ALL_GPU_ARCHITECTURES "7.0" "7.0+PTX" "7.2" "7.2+PTX")
+
+ if(CUDA_VERSION VERSION_LESS "10.0")
+ set(CUDA_LIMIT_GPU_ARCHITECTURE "8.0")
+ endif()
+endif()
+
+if(CUDA_VERSION VERSION_GREATER_EQUAL "10.0")
+ list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Turing")
+ list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "7.5" "7.5+PTX")
+ list(APPEND CUDA_ALL_GPU_ARCHITECTURES "7.5" "7.5+PTX")
+ if(CUDA_VERSION VERSION_LESS "11.0")
+ set(CUDA_LIMIT_GPU_ARCHITECTURE "9.0")
+ endif()
+endif()
################################################################################################
# A function for automatic detection of GPUs installed (if autodetection is enabled)
@@ -44,7 +87,11 @@ endif ()
#
function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE)
if(NOT CUDA_GPU_DETECT_OUTPUT)
- set(file ${PROJECT_BINARY_DIR}/detect_cuda_compute_capabilities.cpp)
+ if(CMAKE_CUDA_COMPILER_LOADED) # CUDA as a language
+ set(file "${PROJECT_BINARY_DIR}/detect_cuda_compute_capabilities.cu")
+ else()
+ set(file "${PROJECT_BINARY_DIR}/detect_cuda_compute_capabilities.cpp")
+ endif()
file(WRITE ${file} ""
"#include <cuda_runtime.h>\n"
@@ -63,10 +110,18 @@ function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE)
" return 0;\n"
"}\n")
- try_run(run_result compile_result ${PROJECT_BINARY_DIR} ${file}
- CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CUDA_INCLUDE_DIRS}"
- LINK_LIBRARIES ${CUDA_LIBRARIES}
- RUN_OUTPUT_VARIABLE compute_capabilities)
+ if(CMAKE_CUDA_COMPILER_LOADED) # CUDA as a language
+ try_run(run_result compile_result ${PROJECT_BINARY_DIR} ${file}
+ RUN_OUTPUT_VARIABLE compute_capabilities)
+ else()
+ try_run(run_result compile_result ${PROJECT_BINARY_DIR} ${file}
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${CUDA_INCLUDE_DIRS}"
+ LINK_LIBRARIES ${CUDA_LIBRARIES}
+ RUN_OUTPUT_VARIABLE compute_capabilities)
+ endif()
+
+ # Filter unrelated content out of the output.
+ string(REGEX MATCHALL "[0-9]+\\.[0-9]+" compute_capabilities "${compute_capabilities}")
if(run_result EQUAL 0)
string(REPLACE "2.1" "2.1(2.0)" compute_capabilities "${compute_capabilities}")
@@ -79,7 +134,19 @@ function(CUDA_DETECT_INSTALLED_GPUS OUT_VARIABLE)
message(STATUS "Automatic GPU detection failed. Building for common architectures.")
set(${OUT_VARIABLE} ${CUDA_COMMON_GPU_ARCHITECTURES} PARENT_SCOPE)
else()
- set(${OUT_VARIABLE} ${CUDA_GPU_DETECT_OUTPUT} PARENT_SCOPE)
+ # Filter based on CUDA version supported archs
+ set(CUDA_GPU_DETECT_OUTPUT_FILTERED "")
+ separate_arguments(CUDA_GPU_DETECT_OUTPUT)
+ foreach(ITEM IN ITEMS ${CUDA_GPU_DETECT_OUTPUT})
+ if(CUDA_LIMIT_GPU_ARCHITECTURE AND ITEM VERSION_GREATER_EQUAL CUDA_LIMIT_GPU_ARCHITECTURE)
+ list(GET CUDA_COMMON_GPU_ARCHITECTURES -1 NEWITEM)
+ string(APPEND CUDA_GPU_DETECT_OUTPUT_FILTERED " ${NEWITEM}")
+ else()
+ string(APPEND CUDA_GPU_DETECT_OUTPUT_FILTERED " ${ITEM}")
+ endif()
+ endforeach()
+
+ set(${OUT_VARIABLE} ${CUDA_GPU_DETECT_OUTPUT_FILTERED} PARENT_SCOPE)
endif()
endfunction()
@@ -141,6 +208,12 @@ function(CUDA_SELECT_NVCC_ARCH_FLAGS out_variable)
elseif(${arch_name} STREQUAL "Pascal")
set(arch_bin 6.0 6.1)
set(arch_ptx 6.1)
+ elseif(${arch_name} STREQUAL "Volta")
+ set(arch_bin 7.0 7.0)
+ set(arch_ptx 7.0)
+ elseif(${arch_name} STREQUAL "Turing")
+ set(arch_bin 7.5)
+ set(arch_ptx 7.5)
else()
message(SEND_ERROR "Unknown CUDA Architecture Name ${arch_name} in CUDA_SELECT_NVCC_ARCH_FLAGS")
endif()
diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake
index f4bcc36a9..aeebc842e 100644
--- a/Modules/FindCURL.cmake
+++ b/Modules/FindCURL.cmake
@@ -1,38 +1,87 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindCURL
-# --------
-#
-# Find curl
-#
-# Find the native CURL headers and libraries.
-#
-# ::
-#
-# CURL_INCLUDE_DIRS - where to find curl/curl.h, etc.
-# CURL_LIBRARIES - List of libraries when using curl.
-# CURL_FOUND - True if curl found.
-# CURL_VERSION_STRING - the version of curl found (since CMake 2.8.8)
+#[=======================================================================[.rst:
+FindCURL
+--------
+
+Find the native CURL headers and libraries.
+
+This module accept optional COMPONENTS to check supported features and
+protocols::
+
+ PROTOCOLS: ICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP LDAPS POP3
+ POP3S RTMP RTSP SCP SFTP SMB SMBS SMTP SMTPS TELNET TFTP
+ FEATURES: SSL IPv6 UnixSockets libz AsynchDNS IDN GSS-API PSL SPNEGO
+ Kerberos NTLM NTLM_WB TLS-SRP HTTP2 HTTPS-proxy
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``CURL::libcurl``, if
+curl has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+``CURL_FOUND``
+ "True" if ``curl`` found.
+
+``CURL_INCLUDE_DIRS``
+ where to find ``curl``/``curl.h``, etc.
+
+``CURL_LIBRARIES``
+ List of libraries when using ``curl``.
+
+``CURL_VERSION_STRING``
+ The version of ``curl`` found.
+#]=======================================================================]
+
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+ pkg_check_modules(PC_CURL QUIET libcurl)
+ if(PC_CURL_FOUND)
+ set(CURL_VERSION_STRING ${PC_CURL_VERSION})
+ pkg_get_variable(CURL_SUPPORTED_PROTOCOLS libcurl supported_protocols)
+ pkg_get_variable(CURL_SUPPORTED_FEATURES libcurl supported_features)
+ endif()
+endif()
# Look for the header file.
-find_path(CURL_INCLUDE_DIR NAMES curl/curl.h)
+find_path(CURL_INCLUDE_DIR
+ NAMES curl/curl.h
+ HINTS ${PC_CURL_INCLUDE_DIRS})
mark_as_advanced(CURL_INCLUDE_DIR)
-# Look for the library (sorted from most current/relevant entry to least).
-find_library(CURL_LIBRARY NAMES
- curl
- # Windows MSVC prebuilts:
- curllib
- libcurl_imp
- curllib_static
- # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip):
- libcurl
-)
-mark_as_advanced(CURL_LIBRARY)
-
-if(CURL_INCLUDE_DIR)
+if(NOT CURL_LIBRARY)
+ # Look for the library (sorted from most current/relevant entry to least).
+ find_library(CURL_LIBRARY_RELEASE NAMES
+ curl
+ # Windows MSVC prebuilts:
+ curllib
+ libcurl_imp
+ curllib_static
+ # Windows older "Win32 - MSVC" prebuilts (libcurl.lib, e.g. libcurl-7.15.5-win32-msvc.zip):
+ libcurl
+ HINTS ${PC_CURL_LIBRARY_DIRS}
+ )
+ mark_as_advanced(CURL_LIBRARY_RELEASE)
+
+ find_library(CURL_LIBRARY_DEBUG NAMES
+ # Windows MSVC CMake builds in debug configuration on vcpkg:
+ libcurl-d_imp
+ libcurl-d
+ HINTS ${PC_CURL_LIBRARY_DIRS}
+ )
+ mark_as_advanced(CURL_LIBRARY_DEBUG)
+
+ include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
+ select_library_configurations(CURL)
+endif()
+
+if(CURL_INCLUDE_DIR AND NOT CURL_VERSION_STRING)
foreach(_curl_version_header curlver.h curl.h)
if(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}")
file(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"")
@@ -44,12 +93,85 @@ if(CURL_INCLUDE_DIR)
endforeach()
endif()
+if(CURL_FIND_COMPONENTS)
+ set(CURL_KNOWN_PROTOCOLS ICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP LDAPS POP3 POP3S RTMP RTSP SCP SFTP SMB SMBS SMTP SMTPS TELNET TFTP)
+ set(CURL_KNOWN_FEATURES SSL IPv6 UnixSockets libz AsynchDNS IDN GSS-API PSL SPNEGO Kerberos NTLM NTLM_WB TLS-SRP HTTP2 HTTPS-proxy)
+ foreach(component IN LISTS CURL_KNOWN_PROTOCOLS CURL_KNOWN_FEATURES)
+ set(CURL_${component}_FOUND FALSE)
+ endforeach()
+ if(NOT PC_CURL_FOUND)
+ find_program(CURL_CONFIG_EXECUTABLE NAMES curl-config)
+ if(CURL_CONFIG_EXECUTABLE)
+ execute_process(COMMAND ${CURL_CONFIG_EXECUTABLE} --version
+ OUTPUT_VARIABLE CURL_CONFIG_VERSION_STRING
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND ${CURL_CONFIG_EXECUTABLE} --feature
+ OUTPUT_VARIABLE CURL_CONFIG_FEATURES_STRING
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REPLACE "\n" ";" CURL_SUPPORTED_FEATURES "${CURL_CONFIG_FEATURES_STRING}")
+ execute_process(COMMAND ${CURL_CONFIG_EXECUTABLE} --protocols
+ OUTPUT_VARIABLE CURL_CONFIG_PROTOCOLS_STRING
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REPLACE "\n" ";" CURL_SUPPORTED_PROTOCOLS "${CURL_CONFIG_PROTOCOLS_STRING}")
+ endif()
+
+ endif()
+ foreach(component IN LISTS CURL_FIND_COMPONENTS)
+ list(FIND CURL_KNOWN_PROTOCOLS ${component} _found)
+ if(_found)
+ list(FIND CURL_SUPPORTED_PROTOCOLS ${component} _found)
+ if(_found)
+ set(CURL_${component}_FOUND TRUE)
+ elseif(CURL_FIND_REQUIRED)
+ message(FATAL_ERROR "CURL: Required protocol ${component} is not found")
+ endif()
+ else()
+ list(FIND CURL_SUPPORTED_FEATURES ${component} _found)
+ if(_found)
+ set(CURL_${component}_FOUND TRUE)
+ elseif(CURL_FIND_REQUIRED)
+ message(FATAL_ERROR "CURL: Required feature ${component} is not found")
+ endif()
+ endif()
+ endforeach()
+endif()
+
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL
+find_package_handle_standard_args(CURL
REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR
- VERSION_VAR CURL_VERSION_STRING)
+ VERSION_VAR CURL_VERSION_STRING
+ HANDLE_COMPONENTS)
if(CURL_FOUND)
set(CURL_LIBRARIES ${CURL_LIBRARY})
set(CURL_INCLUDE_DIRS ${CURL_INCLUDE_DIR})
+
+ if(NOT TARGET CURL::libcurl)
+ add_library(CURL::libcurl UNKNOWN IMPORTED)
+ set_target_properties(CURL::libcurl PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}")
+
+ if(EXISTS "${CURL_LIBRARY}")
+ set_target_properties(CURL::libcurl PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${CURL_LIBRARY}")
+ endif()
+ if(CURL_LIBRARY_RELEASE)
+ set_property(TARGET CURL::libcurl APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(CURL::libcurl PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION_RELEASE "${CURL_LIBRARY_RELEASE}")
+ endif()
+ if(CURL_LIBRARY_DEBUG)
+ set_property(TARGET CURL::libcurl APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(CURL::libcurl PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION_DEBUG "${CURL_LIBRARY_DEBUG}")
+ endif()
+ endif()
endif()
diff --git a/Modules/FindCVS.cmake b/Modules/FindCVS.cmake
index d59dfb097..f81980039 100644
--- a/Modules/FindCVS.cmake
+++ b/Modules/FindCVS.cmake
@@ -1,27 +1,28 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindCVS
-# -------
-#
-#
-#
-# The module defines the following variables:
-#
-# ::
-#
-# CVS_EXECUTABLE - path to cvs command line client
-# CVS_FOUND - true if the command line client was found
-#
-# Example usage:
-#
-# ::
-#
-# find_package(CVS)
-# if(CVS_FOUND)
-# message("CVS found: ${CVS_EXECUTABLE}")
-# endif()
+#[=======================================================================[.rst:
+FindCVS
+-------
+
+Find the Concurrent Versions System (CVS).
+
+The module defines the following variables:
+
+::
+
+ CVS_EXECUTABLE - path to cvs command line client
+ CVS_FOUND - true if the command line client was found
+
+Example usage:
+
+::
+
+ find_package(CVS)
+ if(CVS_FOUND)
+ message("CVS found: ${CVS_EXECUTABLE}")
+ endif()
+#]=======================================================================]
# CVSNT
diff --git a/Modules/FindCoin3D.cmake b/Modules/FindCoin3D.cmake
index f11903d6a..301e70bd6 100644
--- a/Modules/FindCoin3D.cmake
+++ b/Modules/FindCoin3D.cmake
@@ -1,22 +1,23 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindCoin3D
-# ----------
-#
-# Find Coin3D (Open Inventor)
-#
-# Coin3D is an implementation of the Open Inventor API. It provides
-# data structures and algorithms for 3D visualization.
-#
-# This module defines the following variables
-#
-# ::
-#
-# COIN3D_FOUND - system has Coin3D - Open Inventor
-# COIN3D_INCLUDE_DIRS - where the Inventor include directory can be found
-# COIN3D_LIBRARIES - Link to this to use Coin3D
+#[=======================================================================[.rst:
+FindCoin3D
+----------
+
+Find Coin3D (Open Inventor)
+
+Coin3D is an implementation of the Open Inventor API. It provides
+data structures and algorithms for 3D visualization.
+
+This module defines the following variables
+
+::
+
+ COIN3D_FOUND - system has Coin3D - Open Inventor
+ COIN3D_INCLUDE_DIRS - where the Inventor include directory can be found
+ COIN3D_LIBRARIES - Link to this to use Coin3D
+#]=======================================================================]
if (WIN32)
if (CYGWIN)
diff --git a/Modules/FindCups.cmake b/Modules/FindCups.cmake
index 13d3b98d6..4e8232d07 100644
--- a/Modules/FindCups.cmake
+++ b/Modules/FindCups.cmake
@@ -1,22 +1,43 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindCups
-# --------
-#
-# Try to find the Cups printing system
-#
-# Once done this will define
-#
-# ::
-#
-# CUPS_FOUND - system has Cups
-# CUPS_INCLUDE_DIR - the Cups include directory
-# CUPS_LIBRARIES - Libraries needed to use Cups
-# CUPS_VERSION_STRING - version of Cups found (since CMake 2.8.8)
-# Set CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE to TRUE if you need a version which
-# features this function (i.e. at least 1.1.19)
+#[=======================================================================[.rst:
+FindCups
+--------
+
+Find the Common UNIX Printing System (CUPS).
+
+Set ``CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE`` to ``TRUE`` if you need a version which
+features this function (i.e. at least ``1.1.19``)
+
+Imported targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``Cups::Cups``, if Cups has
+been found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``CUPS_FOUND``
+ true if CUPS headers and libraries were found
+``CUPS_INCLUDE_DIRS``
+ the directory containing the Cups headers
+``CUPS_LIBRARIES``
+ the libraries to link against to use CUPS.
+``CUPS_VERSION_STRING``
+ the version of CUPS found (since CMake 2.8.8)
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``CUPS_INCLUDE_DIR``
+ the directory containing the Cups headers
+#]=======================================================================]
find_path(CUPS_INCLUDE_DIR cups/cups.h )
@@ -65,3 +86,13 @@ else ()
endif ()
mark_as_advanced(CUPS_INCLUDE_DIR CUPS_LIBRARIES)
+
+if (CUPS_FOUND)
+ set(CUPS_INCLUDE_DIRS "${CUPS_INCLUDE_DIR}")
+ if (NOT TARGET Cups::Cups)
+ add_library(Cups::Cups INTERFACE IMPORTED)
+ set_target_properties(Cups::Cups PROPERTIES
+ INTERFACE_LINK_LIBRARIES "${CUPS_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${CUPS_INCLUDE_DIR}")
+ endif ()
+endif ()
diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake
index 4365e996e..e3e7273be 100644
--- a/Modules/FindCurses.cmake
+++ b/Modules/FindCurses.cmake
@@ -1,50 +1,68 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindCurses
-# ----------
-#
-# Find the curses or ncurses include file and library.
-#
-# Result Variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the following variables:
-#
-# ``CURSES_FOUND``
-# True if Curses is found.
-# ``CURSES_INCLUDE_DIRS``
-# The include directories needed to use Curses.
-# ``CURSES_LIBRARIES``
-# The libraries needed to use Curses.
-# ``CURSES_HAVE_CURSES_H``
-# True if curses.h is available.
-# ``CURSES_HAVE_NCURSES_H``
-# True if ncurses.h is available.
-# ``CURSES_HAVE_NCURSES_NCURSES_H``
-# True if ``ncurses/ncurses.h`` is available.
-# ``CURSES_HAVE_NCURSES_CURSES_H``
-# True if ``ncurses/curses.h`` is available.
-#
-# Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the
-# ``find_package(Curses)`` call if NCurses functionality is required.
-#
-# Backward Compatibility
-# ^^^^^^^^^^^^^^^^^^^^^^
-#
-# The following variable are provided for backward compatibility:
-#
-# ``CURSES_INCLUDE_DIR``
-# Path to Curses include. Use ``CURSES_INCLUDE_DIRS`` instead.
-# ``CURSES_LIBRARY``
-# Path to Curses library. Use ``CURSES_LIBRARIES`` instead.
+#[=======================================================================[.rst:
+FindCurses
+----------
+
+Find the curses or ncurses include file and library.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+``CURSES_FOUND``
+ True if Curses is found.
+``CURSES_INCLUDE_DIRS``
+ The include directories needed to use Curses.
+``CURSES_LIBRARIES``
+ The libraries needed to use Curses.
+``CURSES_CFLAGS``
+ Parameters which ought be given to C/C++ compilers when using Curses.
+``CURSES_HAVE_CURSES_H``
+ True if curses.h is available.
+``CURSES_HAVE_NCURSES_H``
+ True if ncurses.h is available.
+``CURSES_HAVE_NCURSES_NCURSES_H``
+ True if ``ncurses/ncurses.h`` is available.
+``CURSES_HAVE_NCURSES_CURSES_H``
+ True if ``ncurses/curses.h`` is available.
+
+Set ``CURSES_NEED_NCURSES`` to ``TRUE`` before the
+``find_package(Curses)`` call if NCurses functionality is required.
+Set ``CURSES_NEED_WIDE`` to ``TRUE`` before the
+``find_package(Curses)`` call if unicode functionality is required.
+
+Backward Compatibility
+^^^^^^^^^^^^^^^^^^^^^^
+
+The following variable are provided for backward compatibility:
+
+``CURSES_INCLUDE_DIR``
+ Path to Curses include. Use ``CURSES_INCLUDE_DIRS`` instead.
+``CURSES_LIBRARY``
+ Path to Curses library. Use ``CURSES_LIBRARIES`` instead.
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
-find_library(CURSES_CURSES_LIBRARY NAMES curses )
+# we don't know anything about cursesw, so only ncurses
+# may be ncursesw
+if(NOT CURSES_NEED_WIDE)
+ set(NCURSES_LIBRARY_NAME "ncurses")
+ set(CURSES_FORM_LIBRARY_NAME "form")
+else()
+ set(NCURSES_LIBRARY_NAME "ncursesw")
+ set(CURSES_FORM_LIBRARY_NAME "formw")
+ # Also, if we are searching for wide curses - we are actually searching
+ # for ncurses, we don't know about any other unicode version.
+ set(CURSES_NEED_NCURSES TRUE)
+endif()
+
+find_library(CURSES_CURSES_LIBRARY NAMES curses)
-find_library(CURSES_NCURSES_LIBRARY NAMES ncurses )
+find_library(CURSES_NCURSES_LIBRARY NAMES "${NCURSES_LIBRARY_NAME}" )
set(CURSES_USE_NCURSES FALSE)
if(CURSES_NCURSES_LIBRARY AND ((NOT CURSES_CURSES_LIBRARY) OR CURSES_NEED_NCURSES))
@@ -55,8 +73,14 @@ endif()
# message. Cygwin is an ncurses package, so force ncurses on
# cygwin if the curses.h is missing
if(CYGWIN)
- if(NOT EXISTS /usr/include/curses.h)
- set(CURSES_USE_NCURSES TRUE)
+ if (CURSES_NEED_WIDE)
+ if(NOT EXISTS /usr/include/ncursesw/curses.h)
+ set(CURSES_USE_NCURSES TRUE)
+ endif()
+ else()
+ if(NOT EXISTS /usr/include/curses.h)
+ set(CURSES_USE_NCURSES TRUE)
+ endif()
endif()
endif()
@@ -96,18 +120,35 @@ if(CURSES_USE_NCURSES)
# Use CURSES_NCURSES_INCLUDE_PATH if set, for compatibility.
if(CURSES_NCURSES_INCLUDE_PATH)
+ if (CURSES_NEED_WIDE)
+ find_path(CURSES_INCLUDE_PATH
+ NAMES ncursesw/ncurses.h ncursesw/curses.h ncursesw.h cursesw.h
+ PATHS ${CURSES_NCURSES_INCLUDE_PATH}
+ NO_DEFAULT_PATH
+ )
+ else()
+ find_path(CURSES_INCLUDE_PATH
+ NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h
+ PATHS ${CURSES_NCURSES_INCLUDE_PATH}
+ NO_DEFAULT_PATH
+ )
+ endif()
+ endif()
+
+ if (CURSES_NEED_WIDE)
+ set(CURSES_TINFO_LIBRARY_NAME tinfow)
+ find_path(CURSES_INCLUDE_PATH
+ NAMES ncursesw/ncurses.h ncursesw/curses.h ncursesw.h cursesw.h
+ HINTS "${_cursesParentDir}/include"
+ )
+ else()
+ set(CURSES_TINFO_LIBRARY_NAME tinfo)
find_path(CURSES_INCLUDE_PATH
NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h
- PATHS ${CURSES_NCURSES_INCLUDE_PATH}
- NO_DEFAULT_PATH
+ HINTS "${_cursesParentDir}/include"
)
endif()
- find_path(CURSES_INCLUDE_PATH
- NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h
- HINTS "${_cursesParentDir}/include"
- )
-
# Previous versions of FindCurses provided these values.
if(NOT DEFINED CURSES_LIBRARY)
set(CURSES_LIBRARY "${CURSES_NCURSES_LIBRARY}")
@@ -116,17 +157,21 @@ if(CURSES_USE_NCURSES)
CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}"
cbreak "" CURSES_NCURSES_HAS_CBREAK)
if(NOT CURSES_NCURSES_HAS_CBREAK)
- find_library(CURSES_EXTRA_LIBRARY tinfo HINTS "${_cursesLibDir}")
- find_library(CURSES_EXTRA_LIBRARY tinfo )
+ find_library(CURSES_EXTRA_LIBRARY "${CURSES_TINFO_LIBRARY_NAME}" HINTS "${_cursesLibDir}")
+ find_library(CURSES_EXTRA_LIBRARY "${CURSES_TINFO_LIBRARY_NAME}" )
endif()
else()
get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH)
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
- find_path(CURSES_INCLUDE_PATH
- NAMES curses.h
- HINTS "${_cursesParentDir}/include"
- )
+ #We can't find anything with CURSES_NEED_WIDE because we know
+ #only about ncursesw unicode curses version
+ if(NOT CURSES_NEED_WIDE)
+ find_path(CURSES_INCLUDE_PATH
+ NAMES curses.h
+ HINTS "${_cursesParentDir}/include"
+ )
+ endif()
# Previous versions of FindCurses provided these values.
if(NOT DEFINED CURSES_CURSES_H_PATH)
@@ -139,36 +184,49 @@ endif()
# Report whether each possible header name exists in the include directory.
if(NOT DEFINED CURSES_HAVE_NCURSES_NCURSES_H)
- if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h")
+ if(CURSES_NEED_WIDE)
+ if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h")
+ set(CURSES_HAVE_NCURSES_NCURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/ncurses.h")
+ endif()
+ elseif(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h")
set(CURSES_HAVE_NCURSES_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses/ncurses.h")
- else()
+ endif()
+ if(NOT DEFINED CURSES_HAVE_NCURSES_NCURSES_H)
set(CURSES_HAVE_NCURSES_NCURSES_H "CURSES_HAVE_NCURSES_NCURSES_H-NOTFOUND")
endif()
endif()
if(NOT DEFINED CURSES_HAVE_NCURSES_CURSES_H)
- if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/curses.h")
+ if(CURSES_NEED_WIDE)
+ if(EXISTS "${CURSES_INCLUDE_PATH}/ncursesw/curses.h")
+ set(CURSES_HAVE_NCURSES_CURSES_H "${CURSES_INCLUDE_PATH}/ncursesw/curses.h")
+ endif()
+ elseif(EXISTS "${CURSES_INCLUDE_PATH}/ncurses/curses.h")
set(CURSES_HAVE_NCURSES_CURSES_H "${CURSES_INCLUDE_PATH}/ncurses/curses.h")
- else()
+ endif()
+ if(NOT DEFINED CURSES_HAVE_NCURSES_CURSES_H)
set(CURSES_HAVE_NCURSES_CURSES_H "CURSES_HAVE_NCURSES_CURSES_H-NOTFOUND")
endif()
endif()
-if(NOT DEFINED CURSES_HAVE_NCURSES_H)
- if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses.h")
- set(CURSES_HAVE_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses.h")
- else()
- set(CURSES_HAVE_NCURSES_H "CURSES_HAVE_NCURSES_H-NOTFOUND")
+if(NOT CURSES_NEED_WIDE)
+ #ncursesw can't be found for this paths
+ if(NOT DEFINED CURSES_HAVE_NCURSES_H)
+ if(EXISTS "${CURSES_INCLUDE_PATH}/ncurses.h")
+ set(CURSES_HAVE_NCURSES_H "${CURSES_INCLUDE_PATH}/ncurses.h")
+ else()
+ set(CURSES_HAVE_NCURSES_H "CURSES_HAVE_NCURSES_H-NOTFOUND")
+ endif()
endif()
-endif()
-if(NOT DEFINED CURSES_HAVE_CURSES_H)
- if(EXISTS "${CURSES_INCLUDE_PATH}/curses.h")
- set(CURSES_HAVE_CURSES_H "${CURSES_INCLUDE_PATH}/curses.h")
- else()
- set(CURSES_HAVE_CURSES_H "CURSES_HAVE_CURSES_H-NOTFOUND")
+ if(NOT DEFINED CURSES_HAVE_CURSES_H)
+ if(EXISTS "${CURSES_INCLUDE_PATH}/curses.h")
+ set(CURSES_HAVE_CURSES_H "${CURSES_INCLUDE_PATH}/curses.h")
+ else()
+ set(CURSES_HAVE_CURSES_H "CURSES_HAVE_CURSES_H-NOTFOUND")
+ endif()
endif()
endif()
-find_library(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}")
-find_library(CURSES_FORM_LIBRARY form )
+find_library(CURSES_FORM_LIBRARY "${CURSES_FORM_LIBRARY_NAME}" HINTS "${_cursesLibDir}")
+find_library(CURSES_FORM_LIBRARY "${CURSES_FORM_LIBRARY_NAME}" )
# Previous versions of FindCurses provided these values.
if(NOT DEFINED FORM_LIBRARY)
@@ -186,10 +244,16 @@ if(CURSES_FORM_LIBRARY)
set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_FORM_LIBRARY})
endif()
-# Provide the *_INCLUDE_DIRS result.
+# Provide the *_INCLUDE_DIRS and *_CFLAGS results.
set(CURSES_INCLUDE_DIRS ${CURSES_INCLUDE_PATH})
set(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH}) # compatibility
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+ pkg_check_modules(NCURSES QUIET ${NCURSES_LIBRARY_NAME})
+ set(CURSES_CFLAGS ${NCURSES_CFLAGS_OTHER})
+endif()
+
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG
CURSES_LIBRARY CURSES_INCLUDE_PATH)
@@ -199,4 +263,5 @@ mark_as_advanced(
CURSES_CURSES_LIBRARY
CURSES_NCURSES_LIBRARY
CURSES_EXTRA_LIBRARY
+ CURSES_FORM_LIBRARY
)
diff --git a/Modules/FindCxxTest.cmake b/Modules/FindCxxTest.cmake
index 9ba1ff3e9..3fc0e938a 100644
--- a/Modules/FindCxxTest.cmake
+++ b/Modules/FindCxxTest.cmake
@@ -1,142 +1,143 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindCxxTest
-# -----------
-#
-# Find CxxTest
-#
-# Find the CxxTest suite and declare a helper macro for creating unit
-# tests and integrating them with CTest. For more details on CxxTest
-# see http://cxxtest.tigris.org
-#
-# INPUT Variables
-#
-# ::
-#
-# CXXTEST_USE_PYTHON [deprecated since 1.3]
-# Only used in the case both Python & Perl
-# are detected on the system to control
-# which CxxTest code generator is used.
-# Valid only for CxxTest version 3.
-#
-#
-#
-# ::
-#
-# NOTE: In older versions of this Find Module,
-# this variable controlled if the Python test
-# generator was used instead of the Perl one,
-# regardless of which scripting language the
-# user had installed.
-#
-#
-#
-# ::
-#
-# CXXTEST_TESTGEN_ARGS (since CMake 2.8.3)
-# Specify a list of options to pass to the CxxTest code
-# generator. If not defined, --error-printer is
-# passed.
-#
-#
-#
-# OUTPUT Variables
-#
-# ::
-#
-# CXXTEST_FOUND
-# True if the CxxTest framework was found
-# CXXTEST_INCLUDE_DIRS
-# Where to find the CxxTest include directory
-# CXXTEST_PERL_TESTGEN_EXECUTABLE
-# The perl-based test generator
-# CXXTEST_PYTHON_TESTGEN_EXECUTABLE
-# The python-based test generator
-# CXXTEST_TESTGEN_EXECUTABLE (since CMake 2.8.3)
-# The test generator that is actually used (chosen using user preferences
-# and interpreters found in the system)
-# CXXTEST_TESTGEN_INTERPRETER (since CMake 2.8.3)
-# The full path to the Perl or Python executable on the system, on
-# platforms where the script cannot be executed using its shebang line.
-#
-#
-#
-# MACROS for optional use by CMake users:
-#
-# ::
-#
-# CXXTEST_ADD_TEST(<test_name> <gen_source_file> <input_files_to_testgen...>)
-# Creates a CxxTest runner and adds it to the CTest testing suite
-# Parameters:
-# test_name The name of the test
-# gen_source_file The generated source filename to be
-# generated by CxxTest
-# input_files_to_testgen The list of header files containing the
-# CxxTest::TestSuite's to be included in
-# this runner
-#
-#
-#
-# ::
-#
-# #==============
-# Example Usage:
-#
-#
-#
-# ::
-#
-# find_package(CxxTest)
-# if(CXXTEST_FOUND)
-# include_directories(${CXXTEST_INCLUDE_DIR})
-# enable_testing()
-#
-#
-#
-# ::
-#
-# CXXTEST_ADD_TEST(unittest_foo foo_test.cc
-# ${CMAKE_CURRENT_SOURCE_DIR}/foo_test.h)
-# target_link_libraries(unittest_foo foo) # as needed
-# endif()
-#
-#
-#
-# ::
-#
-# This will (if CxxTest is found):
-# 1. Invoke the testgen executable to autogenerate foo_test.cc in the
-# binary tree from "foo_test.h" in the current source directory.
-# 2. Create an executable and test called unittest_foo.
-#
-#
-#
-# ::
-#
-# #=============
-# Example foo_test.h:
-#
-#
-#
-# ::
-#
-# #include <cxxtest/TestSuite.h>
-#
-#
-#
-# ::
-#
-# class MyTestSuite : public CxxTest::TestSuite
-# {
-# public:
-# void testAddition( void )
-# {
-# TS_ASSERT( 1 + 1 > 1 );
-# TS_ASSERT_EQUALS( 1 + 1, 2 );
-# }
-# };
+#[=======================================================================[.rst:
+FindCxxTest
+-----------
+
+Find CxxTest unit testing framework.
+
+Find the CxxTest suite and declare a helper macro for creating unit
+tests and integrating them with CTest. For more details on CxxTest
+see http://cxxtest.tigris.org
+
+INPUT Variables
+
+::
+
+ CXXTEST_USE_PYTHON [deprecated since 1.3]
+ Only used in the case both Python & Perl
+ are detected on the system to control
+ which CxxTest code generator is used.
+ Valid only for CxxTest version 3.
+
+
+
+::
+
+ NOTE: In older versions of this Find Module,
+ this variable controlled if the Python test
+ generator was used instead of the Perl one,
+ regardless of which scripting language the
+ user had installed.
+
+
+
+::
+
+ CXXTEST_TESTGEN_ARGS (since CMake 2.8.3)
+ Specify a list of options to pass to the CxxTest code
+ generator. If not defined, --error-printer is
+ passed.
+
+
+
+OUTPUT Variables
+
+::
+
+ CXXTEST_FOUND
+ True if the CxxTest framework was found
+ CXXTEST_INCLUDE_DIRS
+ Where to find the CxxTest include directory
+ CXXTEST_PERL_TESTGEN_EXECUTABLE
+ The perl-based test generator
+ CXXTEST_PYTHON_TESTGEN_EXECUTABLE
+ The python-based test generator
+ CXXTEST_TESTGEN_EXECUTABLE (since CMake 2.8.3)
+ The test generator that is actually used (chosen using user preferences
+ and interpreters found in the system)
+ CXXTEST_TESTGEN_INTERPRETER (since CMake 2.8.3)
+ The full path to the Perl or Python executable on the system, on
+ platforms where the script cannot be executed using its shebang line.
+
+
+
+MACROS for optional use by CMake users:
+
+::
+
+ CXXTEST_ADD_TEST(<test_name> <gen_source_file> <input_files_to_testgen...>)
+ Creates a CxxTest runner and adds it to the CTest testing suite
+ Parameters:
+ test_name The name of the test
+ gen_source_file The generated source filename to be
+ generated by CxxTest
+ input_files_to_testgen The list of header files containing the
+ CxxTest::TestSuite's to be included in
+ this runner
+
+
+
+::
+
+ #==============
+ Example Usage:
+
+
+
+::
+
+ find_package(CxxTest)
+ if(CXXTEST_FOUND)
+ include_directories(${CXXTEST_INCLUDE_DIR})
+ enable_testing()
+
+
+
+::
+
+ CXXTEST_ADD_TEST(unittest_foo foo_test.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/foo_test.h)
+ target_link_libraries(unittest_foo foo) # as needed
+ endif()
+
+
+
+::
+
+ This will (if CxxTest is found):
+ 1. Invoke the testgen executable to autogenerate foo_test.cc in the
+ binary tree from "foo_test.h" in the current source directory.
+ 2. Create an executable and test called unittest_foo.
+
+
+
+::
+
+ #=============
+ Example foo_test.h:
+
+
+
+::
+
+ #include <cxxtest/TestSuite.h>
+
+
+
+::
+
+ class MyTestSuite : public CxxTest::TestSuite
+ {
+ public:
+ void testAddition( void )
+ {
+ TS_ASSERT( 1 + 1 > 1 );
+ TS_ASSERT_EQUALS( 1 + 1, 2 );
+ }
+ };
+#]=======================================================================]
# Version 1.4 (11/18/10) (CMake 2.8.4)
# Issue 11384: Added support to the CXX_ADD_TEST macro so header
@@ -145,7 +146,7 @@
#
# Version 1.3 (8/19/10) (CMake 2.8.3)
# Included patch by Simone Rossetto to check if either Python or Perl
-# are present in the system. Whichever intepreter that is detected
+# are present in the system. Whichever interpreter that is detected
# is now used to run the test generator program. If both interpreters
# are detected, the CXXTEST_USE_PYTHON variable is obeyed.
#
@@ -193,10 +194,10 @@ endmacro()
# main()
#=============================================================
if(NOT DEFINED CXXTEST_TESTGEN_ARGS)
- set(CXXTEST_TESTGEN_ARGS --error-printer)
+ set(CXXTEST_TESTGEN_ARGS --error-printer)
endif()
-find_package(PythonInterp QUIET)
+find_package(Python QUIET)
find_package(Perl QUIET)
find_path(CXXTEST_INCLUDE_DIR cxxtest/TestSuite.h)
@@ -206,41 +207,41 @@ find_program(CXXTEST_PYTHON_TESTGEN_EXECUTABLE
find_program(CXXTEST_PERL_TESTGEN_EXECUTABLE cxxtestgen.pl
PATHS ${CXXTEST_INCLUDE_DIR})
-if(PYTHONINTERP_FOUND OR PERL_FOUND)
- include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-
- if(PYTHONINTERP_FOUND AND (CXXTEST_USE_PYTHON OR NOT PERL_FOUND OR NOT DEFINED CXXTEST_USE_PYTHON))
- set(CXXTEST_TESTGEN_EXECUTABLE ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE})
- execute_process(COMMAND ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE} --version
- OUTPUT_VARIABLE _CXXTEST_OUT ERROR_VARIABLE _CXXTEST_OUT RESULT_VARIABLE _CXXTEST_RESULT)
- if(_CXXTEST_RESULT EQUAL 0)
- set(CXXTEST_TESTGEN_INTERPRETER "")
- else()
- set(CXXTEST_TESTGEN_INTERPRETER ${PYTHON_EXECUTABLE})
- endif()
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG
- CXXTEST_INCLUDE_DIR CXXTEST_PYTHON_TESTGEN_EXECUTABLE)
-
- elseif(PERL_FOUND)
- set(CXXTEST_TESTGEN_EXECUTABLE ${CXXTEST_PERL_TESTGEN_EXECUTABLE})
- set(CXXTEST_TESTGEN_INTERPRETER ${PERL_EXECUTABLE})
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG
- CXXTEST_INCLUDE_DIR CXXTEST_PERL_TESTGEN_EXECUTABLE)
- endif()
-
- if(CXXTEST_FOUND)
- set(CXXTEST_INCLUDE_DIRS ${CXXTEST_INCLUDE_DIR})
- endif()
+if(PYTHON_FOUND OR PERL_FOUND)
+ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+
+ if(PYTHON_FOUND AND (CXXTEST_USE_PYTHON OR NOT PERL_FOUND OR NOT DEFINED CXXTEST_USE_PYTHON))
+ set(CXXTEST_TESTGEN_EXECUTABLE ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE})
+ execute_process(COMMAND ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE} --version
+ OUTPUT_VARIABLE _CXXTEST_OUT ERROR_VARIABLE _CXXTEST_OUT RESULT_VARIABLE _CXXTEST_RESULT)
+ if(_CXXTEST_RESULT EQUAL 0)
+ set(CXXTEST_TESTGEN_INTERPRETER "")
+ else()
+ set(CXXTEST_TESTGEN_INTERPRETER ${Python_EXECUTABLE})
+ endif()
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG
+ CXXTEST_INCLUDE_DIR CXXTEST_PYTHON_TESTGEN_EXECUTABLE)
+
+ elseif(PERL_FOUND)
+ set(CXXTEST_TESTGEN_EXECUTABLE ${CXXTEST_PERL_TESTGEN_EXECUTABLE})
+ set(CXXTEST_TESTGEN_INTERPRETER ${PERL_EXECUTABLE})
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG
+ CXXTEST_INCLUDE_DIR CXXTEST_PERL_TESTGEN_EXECUTABLE)
+ endif()
+
+ if(CXXTEST_FOUND)
+ set(CXXTEST_INCLUDE_DIRS ${CXXTEST_INCLUDE_DIR})
+ endif()
else()
- set(CXXTEST_FOUND false)
- if(NOT CxxTest_FIND_QUIETLY)
- if(CxxTest_FIND_REQUIRED)
- message(FATAL_ERROR "Neither Python nor Perl found, cannot use CxxTest, aborting!")
- else()
- message(STATUS "Neither Python nor Perl found, CxxTest will not be used.")
- endif()
- endif()
+ set(CXXTEST_FOUND false)
+ if(NOT CxxTest_FIND_QUIETLY)
+ if(CxxTest_FIND_REQUIRED)
+ message(FATAL_ERROR "Neither Python nor Perl found, cannot use CxxTest, aborting!")
+ else()
+ message(STATUS "Neither Python nor Perl found, CxxTest will not be used.")
+ endif()
+ endif()
endif()
diff --git a/Modules/FindCygwin.cmake b/Modules/FindCygwin.cmake
index c6913da17..5bbc802a0 100644
--- a/Modules/FindCygwin.cmake
+++ b/Modules/FindCygwin.cmake
@@ -1,11 +1,13 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindCygwin
-# ----------
-#
-# this module looks for Cygwin
+#[=======================================================================[.rst:
+FindCygwin
+----------
+
+Find Cygwin, a POSIX-compatible environment that runs natively
+on Microsoft Windows
+#]=======================================================================]
if (WIN32)
if(CYGWIN_INSTALL_PATH)
@@ -13,10 +15,12 @@ if (WIN32)
endif()
find_program(CYGWIN_BAT
- cygwin.bat
- "C:/Cygwin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Cygwin\\setup;rootdir]"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\/;native]"
+ NAMES cygwin.bat
+ PATHS
+ "C:/Cygwin"
+ "C:/Cygwin64"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Cygwin\\setup;rootdir]"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\/;native]"
)
get_filename_component(CYGWIN_INSTALL_PATH "${CYGWIN_BAT}" DIRECTORY)
mark_as_advanced(CYGWIN_BAT)
diff --git a/Modules/FindDCMTK.cmake b/Modules/FindDCMTK.cmake
index 0d86e8e0a..d48de0896 100644
--- a/Modules/FindDCMTK.cmake
+++ b/Modules/FindDCMTK.cmake
@@ -1,82 +1,83 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindDCMTK
-# ---------
-#
-# Find DCMTK libraries and applications
-#
-# The module defines the following variables::
-#
-# DCMTK_INCLUDE_DIRS - Directories to include to use DCMTK
-# DCMTK_LIBRARIES - Files to link against to use DCMTK
-# DCMTK_FOUND - If false, don't try to use DCMTK
-# DCMTK_DIR - (optional) Source directory for DCMTK
-#
-# Compatibility
-# ^^^^^^^^^^^^^
-#
-# This module is able to find a version of DCMTK that does or does not export
-# a *DCMTKConfig.cmake* file. It applies a two step process:
-#
-# * Step 1: Attempt to find DCMTK version providing a *DCMTKConfig.cmake* file.
-# * Step 2: If step 1 failed, rely on *FindDCMTK.cmake* to set `DCMTK_*` variables details below.
-#
-#
-# `Recent DCMTK
-# <http://git.dcmtk.org/web?p=dcmtk.git;a=commit;h=662ae187c493c6b9a73dd5e3875372cebd0c11fe>`_
-# provides a *DCMTKConfig.cmake* :manual:`package configuration file
-# <cmake-packages(7)>`. To exclusively use the package configuration file
-# (recommended when possible), pass the `NO_MODULE` option to
-# :command:`find_package`. For example, `find_package(DCMTK NO_MODULE)`.
-# This requires official DCMTK snapshot *3.6.1_20140617* or newer.
-#
-#
-# Until all clients update to the more recent DCMTK, build systems will need
-# to support different versions of DCMTK.
-#
-# On any given system, the following combinations of DCMTK versions could be
-# considered:
-#
-# +--------+---------------------+-----------------------+-------------------+
-# | | SYSTEM DCMTK | LOCAL DCMTK | Supported ? |
-# +--------+---------------------+-----------------------+-------------------+
-# | Case A | NA | [ ] DCMTKConfig | YES |
-# +--------+---------------------+-----------------------+-------------------+
-# | Case B | NA | [X] DCMTKConfig | YES |
-# +--------+---------------------+-----------------------+-------------------+
-# | Case C | [ ] DCMTKConfig | NA | YES |
-# +--------+---------------------+-----------------------+-------------------+
-# | Case D | [X] DCMTKConfig | NA | YES |
-# +--------+---------------------+-----------------------+-------------------+
-# | Case E | [ ] DCMTKConfig | [ ] DCMTKConfig | YES (*) |
-# +--------+---------------------+-----------------------+-------------------+
-# | Case F | [X] DCMTKConfig | [ ] DCMTKConfig | NO |
-# +--------+---------------------+-----------------------+-------------------+
-# | Case G | [ ] DCMTKConfig | [X] DCMTKConfig | YES |
-# +--------+---------------------+-----------------------+-------------------+
-# | Case H | [X] DCMTKConfig | [X] DCMTKConfig | YES |
-# +--------+---------------------+-----------------------+-------------------+
-#
-# (*) See Troubleshooting section.
-#
-# Legend:
-#
-# NA ...............: Means that no System or Local DCMTK is available
-#
-# [ ] DCMTKConfig ..: Means that the version of DCMTK does NOT export a DCMTKConfig.cmake file.
-#
-# [X] DCMTKConfig ..: Means that the version of DCMTK exports a DCMTKConfig.cmake file.
-#
-#
-# Troubleshooting
-# ^^^^^^^^^^^^^^^
-#
-# What to do if my project finds a different version of DCMTK?
-#
-# Remove DCMTK entry from the CMake cache per :command:`find_package`
-# documentation.
+#[=======================================================================[.rst:
+FindDCMTK
+---------
+
+Find DICOM ToolKit (DCMTK) libraries and applications
+
+The module defines the following variables::
+
+ DCMTK_INCLUDE_DIRS - Directories to include to use DCMTK
+ DCMTK_LIBRARIES - Files to link against to use DCMTK
+ DCMTK_FOUND - If false, don't try to use DCMTK
+ DCMTK_DIR - (optional) Source directory for DCMTK
+
+Compatibility
+^^^^^^^^^^^^^
+
+This module is able to find a version of DCMTK that does or does not export
+a *DCMTKConfig.cmake* file. It applies a two step process:
+
+* Step 1: Attempt to find DCMTK version providing a *DCMTKConfig.cmake* file.
+* Step 2: If step 1 failed, rely on *FindDCMTK.cmake* to set `DCMTK_*` variables details below.
+
+
+`Recent DCMTK
+<http://git.dcmtk.org/web?p=dcmtk.git;a=commit;h=662ae187c493c6b9a73dd5e3875372cebd0c11fe>`_
+provides a *DCMTKConfig.cmake* :manual:`package configuration file
+<cmake-packages(7)>`. To exclusively use the package configuration file
+(recommended when possible), pass the `NO_MODULE` option to
+:command:`find_package`. For example, `find_package(DCMTK NO_MODULE)`.
+This requires official DCMTK snapshot *3.6.1_20140617* or newer.
+
+
+Until all clients update to the more recent DCMTK, build systems will need
+to support different versions of DCMTK.
+
+On any given system, the following combinations of DCMTK versions could be
+considered:
+
++--------+---------------------+-----------------------+-------------------+
+| | SYSTEM DCMTK | LOCAL DCMTK | Supported ? |
++--------+---------------------+-----------------------+-------------------+
+| Case A | NA | [ ] DCMTKConfig | YES |
++--------+---------------------+-----------------------+-------------------+
+| Case B | NA | [X] DCMTKConfig | YES |
++--------+---------------------+-----------------------+-------------------+
+| Case C | [ ] DCMTKConfig | NA | YES |
++--------+---------------------+-----------------------+-------------------+
+| Case D | [X] DCMTKConfig | NA | YES |
++--------+---------------------+-----------------------+-------------------+
+| Case E | [ ] DCMTKConfig | [ ] DCMTKConfig | YES (*) |
++--------+---------------------+-----------------------+-------------------+
+| Case F | [X] DCMTKConfig | [ ] DCMTKConfig | NO |
++--------+---------------------+-----------------------+-------------------+
+| Case G | [ ] DCMTKConfig | [X] DCMTKConfig | YES |
++--------+---------------------+-----------------------+-------------------+
+| Case H | [X] DCMTKConfig | [X] DCMTKConfig | YES |
++--------+---------------------+-----------------------+-------------------+
+
+ (*) See Troubleshooting section.
+
+Legend:
+
+ NA ...............: Means that no System or Local DCMTK is available
+
+ [ ] DCMTKConfig ..: Means that the version of DCMTK does NOT export a DCMTKConfig.cmake file.
+
+ [X] DCMTKConfig ..: Means that the version of DCMTK exports a DCMTKConfig.cmake file.
+
+
+Troubleshooting
+^^^^^^^^^^^^^^^
+
+What to do if my project finds a different version of DCMTK?
+
+Remove DCMTK entry from the CMake cache per :command:`find_package`
+documentation.
+#]=======================================================================]
#
# Written for VXL by Amitha Perera.
@@ -199,7 +200,6 @@ if(DCMTK_oflog_LIBRARY_RELEASE OR DCMTK_oflog_LIBRARY_DEBUG)
# Hack - Not having a DCMTKConfig.cmake file to read the settings from, we will attempt to
# find the library in all cases.
# Ideally, pthread library should be discovered only if DCMTK_WITH_THREADS is enabled.
- set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads)
endif()
@@ -217,7 +217,7 @@ if(EXISTS ${DCMTK_DIR}/CMakeCache.txt)
if(NOT EXISTS ${EXTDCMTK_SOURCE_DIR})
message(FATAL_ERROR
"DCMTK build directory references
-nonexistant DCMTK source directory ${EXTDCMTK_SOURCE_DIR}")
+nonexistent DCMTK source directory ${EXTDCMTK_SOURCE_DIR}")
endif()
endif()
@@ -301,7 +301,7 @@ endif()
# Compatibility: This variable is deprecated
set(DCMTK_INCLUDE_DIR ${DCMTK_INCLUDE_DIRS})
-include(FindPackageHandleStandardArgs)
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(DCMTK
REQUIRED_VARS ${DCMTK_INCLUDE_DIR_NAMES} DCMTK_LIBRARIES
FAIL_MESSAGE "Please set DCMTK_DIR and re-run configure")
@@ -309,20 +309,14 @@ find_package_handle_standard_args(DCMTK
# Workaround bug in packaging of DCMTK 3.6.0 on Debian.
# See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=637687
if(DCMTK_FOUND AND UNIX AND NOT APPLE)
- include(CheckCXXSourceCompiles)
+ include(${CMAKE_CURRENT_LIST_DIR}/CheckIncludeFiles.cmake)
set(CMAKE_REQUIRED_FLAGS )
set(CMAKE_REQUIRED_DEFINITIONS )
set(CMAKE_REQUIRED_INCLUDES ${DCMTK_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${DCMTK_LIBRARIES})
set(CMAKE_REQUIRED_QUIET ${DCMTK_FIND_QUIETLY})
- check_cxx_source_compiles("#include <dcmtk/config/osconfig.h>\n#include <dcmtk/ofstd/ofstream.h>\nint main(int,char*[]){return 0;}"
- DCMTK_HAVE_CONFIG_H_OPTIONAL
- )
+ check_include_files("dcmtk/config/osconfig.h;dcmtk/ofstd/ofstream.h" DCMTK_HAVE_CONFIG_H_OPTIONAL LANGUAGE CXX)
if(NOT DCMTK_HAVE_CONFIG_H_OPTIONAL)
set(DCMTK_DEFINITIONS "HAVE_CONFIG_H")
endif()
endif()
-
-if(NOT DCMTK_FIND_QUIETLY)
- message(STATUS "Trying to find DCMTK relying on FindDCMTK.cmake - ok")
-endif()
diff --git a/Modules/FindDart.cmake b/Modules/FindDart.cmake
index acd4ef62d..04925783b 100644
--- a/Modules/FindDart.cmake
+++ b/Modules/FindDart.cmake
@@ -1,14 +1,15 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindDart
-# --------
-#
-# Find DART
-#
-# This module looks for the dart testing software and sets DART_ROOT to
-# point to where it found it.
+#[=======================================================================[.rst:
+FindDart
+--------
+
+Find DART
+
+This module looks for the dart testing software and sets DART_ROOT to
+point to where it found it.
+#]=======================================================================]
find_path(DART_ROOT README.INSTALL
HINTS
diff --git a/Modules/FindDevIL.cmake b/Modules/FindDevIL.cmake
index f6c8e3f24..998494365 100644
--- a/Modules/FindDevIL.cmake
+++ b/Modules/FindDevIL.cmake
@@ -1,35 +1,36 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindDevIL
-# ---------
-#
-#
-#
-# This module locates the developer's image library.
-# http://openil.sourceforge.net/
-#
-# This module sets:
-#
-# ::
-#
-# IL_LIBRARIES - the name of the IL library. These include the full path to
-# the core DevIL library. This one has to be linked into the
-# application.
-# ILU_LIBRARIES - the name of the ILU library. Again, the full path. This
-# library is for filters and effects, not actual loading. It
-# doesn't have to be linked if the functionality it provides
-# is not used.
-# ILUT_LIBRARIES - the name of the ILUT library. Full path. This part of the
-# library interfaces with OpenGL. It is not strictly needed
-# in applications.
-# IL_INCLUDE_DIR - where to find the il.h, ilu.h and ilut.h files.
-# DevIL_FOUND - this is set to TRUE if all the above variables were set.
-# This will be set to false if ILU or ILUT are not found,
-# even if they are not needed. In most systems, if one
-# library is found all the others are as well. That's the
-# way the DevIL developers release it.
+#[=======================================================================[.rst:
+FindDevIL
+---------
+
+
+
+This module locates the developer's image library.
+http://openil.sourceforge.net/
+
+This module sets:
+
+::
+
+ IL_LIBRARIES - the name of the IL library. These include the full path to
+ the core DevIL library. This one has to be linked into the
+ application.
+ ILU_LIBRARIES - the name of the ILU library. Again, the full path. This
+ library is for filters and effects, not actual loading. It
+ doesn't have to be linked if the functionality it provides
+ is not used.
+ ILUT_LIBRARIES - the name of the ILUT library. Full path. This part of the
+ library interfaces with OpenGL. It is not strictly needed
+ in applications.
+ IL_INCLUDE_DIR - where to find the il.h, ilu.h and ilut.h files.
+ DevIL_FOUND - this is set to TRUE if all the above variables were set.
+ This will be set to false if ILU or ILUT are not found,
+ even if they are not needed. In most systems, if one
+ library is found all the others are as well. That's the
+ way the DevIL developers release it.
+#]=======================================================================]
# TODO: Add version support.
# Tested under Linux and Windows (MSVC)
@@ -70,5 +71,5 @@ find_library(ILU_LIBRARIES
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DevIL DEFAULT_MSG
IL_LIBRARIES ILU_LIBRARIES
IL_INCLUDE_DIR)
-# provide legacy variable for compatiblity
+# provide legacy variable for compatibility
set(IL_FOUND ${DevIL_FOUND})
diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake
index 46bf340dd..faa03f918 100644
--- a/Modules/FindDoxygen.cmake
+++ b/Modules/FindDoxygen.cmake
@@ -69,6 +69,8 @@ Functions
doxygen_add_docs(targetName
[filesOrDirs...]
+ [ALL]
+ [USE_STAMP_FILE]
[WORKING_DIRECTORY dir]
[COMMENT comment])
@@ -91,6 +93,20 @@ Functions
the :command:`add_custom_target` command used to create the custom target
internally.
+ If ``ALL`` is set, the target will be added to the default build target.
+
+ If ``USE_STAMP_FILE`` is set, the custom command defined by this function will
+ create a stamp file with the name ``<targetName>.stamp`` in the current
+ binary directory whenever doxygen is re-run. With this option present, all
+ items in ``<filesOrDirs>`` must be files (i.e. no directories, symlinks or
+ wildcards) and each of the files must exist at the time
+ ``doxygen_add_docs()`` is called. An error will be raised if any of the
+ items listed is missing or is not a file when ``USE_STAMP_FILE`` is given.
+ A dependency will be created on each of the files so that doxygen will only
+ be re-run if one of the files is updated. Without the ``USE_STAMP_FILE``
+ option, doxygen will always be re-run if the ``<targetName>`` target is built
+ regardless of whether anything listed in ``<filesOrDirs>`` has changed.
+
The contents of the generated ``Doxyfile`` can be customized by setting CMake
variables before calling ``doxygen_add_docs()``. Any variable with a name of
the form ``DOXYGEN_<tag>`` will have its value substituted for the
@@ -244,7 +260,7 @@ required form if set.
TAGFILES
TCL_SUBST
-The following single value Doxygen options would be quoted automatically
+The following single value Doxygen options will be quoted automatically
if they contain at least one space:
::
@@ -292,6 +308,36 @@ if they contain at least one space:
WARN_LOGFILE
XML_OUTPUT
+There are situations where it may be undesirable for a particular config option
+to be automatically quoted by ``doxygen_add_docs()``, such as ``ALIASES`` which
+may need to include its own embedded quoting. The ``DOXYGEN_VERBATIM_VARS``
+variable can be used to specify a list of Doxygen variables (including the
+leading ``DOXYGEN_`` prefix) which should not be quoted. The project is then
+responsible for ensuring that those variables' values make sense when placed
+directly in the Doxygen input file. In the case of list variables, list items
+are still separated by spaces, it is only the automatic quoting that is
+skipped. For example, the following allows ``doxygen_add_docs()`` to apply
+quoting to ``DOXYGEN_PROJECT_BRIEF``, but not each item in the
+``DOXYGEN_ALIASES`` list (:ref:`bracket syntax <Bracket Argument>` can also
+be used to make working with embedded quotes easier):
+
+.. code-block:: cmake
+
+ set(DOXYGEN_PROJECT_BRIEF "String with spaces")
+ set(DOXYGEN_ALIASES
+ [[somealias="@some_command param"]]
+ "anotherAlias=@foobar"
+ )
+ set(DOXYGEN_VERBATIM_VARS DOXYGEN_ALIASES)
+
+The resultant ``Doxyfile`` will contain the following lines:
+
+.. code-block:: text
+
+ PROJECT_BRIEF = "String with spaces"
+ ALIASES = somealias="@some_command param" anotherAlias=@foobar
+
+
Deprecated Result Variables
^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -331,12 +377,15 @@ Deprecated Hint Variables
.. variable:: DOXYGEN_SKIP_DOT
- This variable has no any effect for component form of ``find_package``.
+ This variable has no effect for the component form of ``find_package``.
In backward compatibility mode (i.e. without components list) it prevents
the finder module from searching for Graphviz's ``dot`` utility.
#]=======================================================================]
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
# For backwards compatibility support
if(Doxygen_FIND_QUIETLY)
set(DOXYGEN_FIND_QUIETLY TRUE)
@@ -381,6 +430,8 @@ macro(_Doxygen_find_doxygen)
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\doxygen_is1;Inno Setup: App Path]/bin"
/Applications/Doxygen.app/Contents/Resources
/Applications/Doxygen.app/Contents/MacOS
+ /Applications/Utilities/Doxygen.app/Contents/Resources
+ /Applications/Utilities/Doxygen.app/Contents/MacOS
DOC "Doxygen documentation generation tool (http://www.doxygen.org)"
)
mark_as_advanced(DOXYGEN_EXECUTABLE)
@@ -447,12 +498,18 @@ endmacro()
# Find Graphviz Dot...
#
macro(_Doxygen_find_dot)
- set(_x86 "(x86)")
- file(
- GLOB _Doxygen_GRAPHVIZ_BIN_DIRS
- "$ENV{ProgramFiles}/Graphviz*/bin"
- "$ENV{ProgramFiles${_x86}}/Graphviz*/bin"
- )
+ if(WIN32)
+ set(_x86 "(x86)")
+ file(
+ GLOB _Doxygen_GRAPHVIZ_BIN_DIRS
+ "$ENV{ProgramFiles}/Graphviz*/bin"
+ "$ENV{ProgramFiles${_x86}}/Graphviz*/bin"
+ )
+ unset(_x86)
+ else()
+ set(_Doxygen_GRAPHVIZ_BIN_DIRS "")
+ endif()
+
find_program(
DOXYGEN_DOT_EXECUTABLE
NAMES dot
@@ -462,8 +519,11 @@ macro(_Doxygen_find_dot)
"C:/Program Files/ATT/Graphviz/bin"
[HKEY_LOCAL_MACHINE\\SOFTWARE\\ATT\\Graphviz;InstallPath]/bin
/Applications/Graphviz.app/Contents/MacOS
+ /Applications/Utilities/Graphviz.app/Contents/MacOS
/Applications/Doxygen.app/Contents/Resources
/Applications/Doxygen.app/Contents/MacOS
+ /Applications/Utilities/Doxygen.app/Contents/Resources
+ /Applications/Utilities/Doxygen.app/Contents/MacOS
DOC "Dot tool for use with Doxygen"
)
mark_as_advanced(DOXYGEN_DOT_EXECUTABLE)
@@ -488,7 +548,6 @@ macro(_Doxygen_find_dot)
endif()
unset(_Doxygen_GRAPHVIZ_BIN_DIRS)
- unset(_x86)
endmacro()
#
@@ -667,7 +726,9 @@ if(TARGET Doxygen::doxygen)
if(_line MATCHES "([A-Z][A-Z0-9_]+)( *=)(.*)")
set(_key "${CMAKE_MATCH_1}")
set(_eql "${CMAKE_MATCH_2}")
- string(REPLACE ";" "\\\n" _value "${CMAKE_MATCH_3}")
+ set(_value "${CMAKE_MATCH_3}")
+ string(REPLACE "\\" "\\\\" _value "${_value}")
+ string(REPLACE ";" "\\\n" _value "${_value}")
list(APPEND _Doxygen_tpl_params "${_key}${_eql}${_value}")
endif()
endforeach()
@@ -716,12 +777,15 @@ endif()
function(doxygen_quote_value VARIABLE)
# Quote a value of the given variable if:
- # - variable parameter was really given
- # - a variable it points is defined
- # - a value doesn't quoted already
- # - and it has spaces
+ # - VARIABLE parameter was really given
+ # - the variable it names is defined and is not present in the list
+ # specified by DOXYGEN_VERBATIM_VARS (if set)
+ # - the value of the named variable isn't already quoted
+ # - the value has spaces
if(VARIABLE AND DEFINED ${VARIABLE} AND
- NOT ${VARIABLE} MATCHES "^\".* .*\"$" AND ${VARIABLE} MATCHES " ")
+ NOT ${VARIABLE} MATCHES "^\".* .*\"$" AND ${VARIABLE} MATCHES " " AND
+ NOT (DEFINED DOXYGEN_VERBATIM_VARS AND
+ "${VARIABLE}" IN_LIST DOXYGEN_VERBATIM_VARS))
set(${VARIABLE} "\"${${VARIABLE}}\"" PARENT_SCOPE)
endif()
endfunction()
@@ -730,8 +794,18 @@ function(doxygen_list_to_quoted_strings LIST_VARIABLE)
if(LIST_VARIABLE AND DEFINED ${LIST_VARIABLE})
unset(_inputs)
unset(_sep)
+ unset(_verbatim)
+ # Have to test if list items should be treated as verbatim here
+ # because we lose the variable name when we pass just one list item
+ # to doxygen_quote_value() below
+ if(DEFINED DOXYGEN_VERBATIM_VARS AND
+ "${LIST_VARIABLE}" IN_LIST DOXYGEN_VERBATIM_VARS)
+ set(_verbatim True)
+ endif()
foreach(_in IN LISTS ${LIST_VARIABLE})
- doxygen_quote_value(_in)
+ if(NOT _verbatim)
+ doxygen_quote_value(_in)
+ endif()
string(APPEND _inputs "${_sep}${_in}")
set(_sep " ")
endforeach()
@@ -740,7 +814,7 @@ function(doxygen_list_to_quoted_strings LIST_VARIABLE)
endfunction()
function(doxygen_add_docs targetName)
- set(_options)
+ set(_options ALL USE_STAMP_FILE)
set(_one_value_args WORKING_DIRECTORY COMMENT)
set(_multi_value_args)
cmake_parse_arguments(_args
@@ -832,7 +906,11 @@ doxygen_add_docs() for target ${targetName}")
# and Lucent Bell Labs. The other options in this section have no
# effect if this option is set to NO.
# Doxygen's default value is: NO.
- set(DOXYGEN_HAVE_DOT ${DOXYGEN_DOT_FOUND})
+ if(Doxygen_dot_FOUND)
+ set(DOXYGEN_HAVE_DOT "YES")
+ else()
+ set(DOXYGEN_HAVE_DOT "NO")
+ endif()
endif()
if(NOT DEFINED DOXYGEN_DOT_MULTI_TARGETS)
@@ -909,13 +987,14 @@ doxygen_add_docs() for target ${targetName}")
"${DOXYGEN_OUTPUT_DIRECTORY}/${DOXYGEN_HTML_OUTPUT}")
endif()
set_property(DIRECTORY APPEND PROPERTY
- ADDITIONAL_MAKE_CLEAN_FILES "${_args_clean_html_dir}")
+ ADDITIONAL_CLEAN_FILES "${_args_clean_html_dir}")
endif()
# Build up a list of files we can identify from the inputs so we can list
- # them as SOURCES in the custom target (makes them display in IDEs). We
- # must do this before we transform the various DOXYGEN_... variables below
- # because we need to process DOXYGEN_INPUT as a list first.
+ # them as DEPENDS and SOURCES in the custom command/target (the latter
+ # makes them display in IDEs). This must be done before we transform the
+ # various DOXYGEN_... variables below because we need to process
+ # DOXYGEN_INPUT as a list first.
unset(_sources)
foreach(_item IN LISTS DOXYGEN_INPUT)
get_filename_component(_abs_item "${_item}" ABSOLUTE
@@ -924,11 +1003,13 @@ doxygen_add_docs() for target ${targetName}")
NOT IS_DIRECTORY "${_abs_item}" AND
NOT IS_SYMLINK "${_abs_item}")
list(APPEND _sources "${_abs_item}")
+ elseif(_args_USE_STAMP_FILE)
+ message(FATAL_ERROR "Source does not exist or is not a file:\n"
+ " ${_abs_item}\n"
+ "Only existing files may be specified when the "
+ "USE_STAMP_FILE option is given.")
endif()
endforeach()
- if(_sources)
- list(INSERT _sources 0 SOURCES)
- endif()
# Transform known list type options into space separated strings.
set(_doxygen_list_options
@@ -1037,14 +1118,41 @@ doxygen_add_docs() for target ${targetName}")
set(_target_doxyfile "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.${targetName}")
configure_file("${_doxyfile_template}" "${_target_doxyfile}")
- # Add the target
- add_custom_target( ${targetName} VERBATIM
- COMMAND ${CMAKE_COMMAND} -E make_directory ${_original_doxygen_output_dir}
- COMMAND "${DOXYGEN_EXECUTABLE}" "${_target_doxyfile}"
- WORKING_DIRECTORY "${_args_WORKING_DIRECTORY}"
- DEPENDS "${_target_doxyfile}"
- COMMENT "${_args_COMMENT}"
- ${_sources}
- )
+ unset(_all)
+ if(${_args_ALL})
+ set(_all ALL)
+ endif()
+
+ # Only create the stamp file if asked to. If we don't create it,
+ # the target will always be considered out-of-date.
+ if(_args_USE_STAMP_FILE)
+ set(__stamp_file "${CMAKE_CURRENT_BINARY_DIR}/${targetName}.stamp")
+ add_custom_command(
+ VERBATIM
+ OUTPUT ${__stamp_file}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${_original_doxygen_output_dir}
+ COMMAND "${DOXYGEN_EXECUTABLE}" "${_target_doxyfile}"
+ COMMAND ${CMAKE_COMMAND} -E touch ${__stamp_file}
+ WORKING_DIRECTORY "${_args_WORKING_DIRECTORY}"
+ DEPENDS "${_target_doxyfile}" ${_sources}
+ COMMENT "${_args_COMMENT}"
+ )
+ add_custom_target(${targetName} ${_all}
+ DEPENDS ${__stamp_file}
+ SOURCES ${_sources}
+ )
+ unset(__stamp_file)
+ else()
+ add_custom_target( ${targetName} ${_all} VERBATIM
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${_original_doxygen_output_dir}
+ COMMAND "${DOXYGEN_EXECUTABLE}" "${_target_doxyfile}"
+ WORKING_DIRECTORY "${_args_WORKING_DIRECTORY}"
+ DEPENDS "${_target_doxyfile}" ${_sources}
+ COMMENT "${_args_COMMENT}"
+ SOURCES ${_sources}
+ )
+ endif()
endfunction()
+
+cmake_policy(POP)
diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake
index 09963fcda..15b419a61 100644
--- a/Modules/FindEXPAT.cmake
+++ b/Modules/FindEXPAT.cmake
@@ -1,19 +1,34 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindEXPAT
-# ---------
-#
-# Find expat
-#
-# Find the native EXPAT headers and libraries.
-#
-# ::
-#
-# EXPAT_INCLUDE_DIRS - where to find expat.h, etc.
-# EXPAT_LIBRARIES - List of libraries when using expat.
-# EXPAT_FOUND - True if expat found.
+#[=======================================================================[.rst:
+FindEXPAT
+---------
+
+Find the native Expat headers and library.
+Expat is a stream-oriented XML parser library written in C.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` targets:
+
+``EXPAT::EXPAT``
+ The Expat ``expat`` library, if found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``EXPAT_INCLUDE_DIRS``
+ where to find expat.h, etc.
+``EXPAT_LIBRARIES``
+ the libraries to link against to use Expat.
+``EXPAT_FOUND``
+ true if the Expat headers and libraries were found.
+
+#]=======================================================================]
find_package(PkgConfig QUIET)
@@ -49,10 +64,18 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT
REQUIRED_VARS EXPAT_LIBRARY EXPAT_INCLUDE_DIR
VERSION_VAR EXPAT_VERSION_STRING)
-# Copy the results to the output variables.
+# Copy the results to the output variables and target.
if(EXPAT_FOUND)
set(EXPAT_LIBRARIES ${EXPAT_LIBRARY})
set(EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIR})
+
+ if(NOT TARGET EXPAT::EXPAT)
+ add_library(EXPAT::EXPAT UNKNOWN IMPORTED)
+ set_target_properties(EXPAT::EXPAT PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${EXPAT_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${EXPAT_INCLUDE_DIRS}")
+ endif()
endif()
mark_as_advanced(EXPAT_INCLUDE_DIR EXPAT_LIBRARY)
diff --git a/Modules/FindEnvModules.cmake b/Modules/FindEnvModules.cmake
new file mode 100644
index 000000000..4dd5116cd
--- /dev/null
+++ b/Modules/FindEnvModules.cmake
@@ -0,0 +1,333 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindEnvModules
+--------------
+
+Locate an environment module implementation and make commands available to
+CMake scripts to use them. This is compatible with both Lua-based Lmod
+and TCL-based EnvironmentModules.
+
+This module is intended for the use case of setting up the compiler and library
+environment within a :ref:`CTest Script <CTest Script>` (``ctest -S``). It can
+also be used in a :ref:`CMake Script <Script Processing Mode>` (``cmake -P``).
+
+.. note::
+
+ The loaded environment will not survive past the end of the calling process.
+ Do not use this module in project code (``CMakeLists.txt`` files) to load
+ a compiler environment; it will not be available during the build. Instead
+ load the environment manually before running CMake or using the generated
+ build system.
+
+Example Usage
+^^^^^^^^^^^^^
+
+.. code-block:: cmake
+
+ set(CTEST_BUILD_NAME "CrayLinux-CrayPE-Cray-dynamic")
+ set(CTEST_BUILD_CONFIGURATION Release)
+ set(CTEST_BUILD_FLAGS "-k -j8")
+ set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
+
+ ...
+
+ find_package(EnvModules REQUIRED)
+
+ env_module(purge)
+ env_module(load modules)
+ env_module(load craype)
+ env_module(load PrgEnv-cray)
+ env_module(load craype-knl)
+ env_module(load cray-mpich)
+ env_module(load cray-libsci)
+
+ set(ENV{CRAYPE_LINK_TYPE} dynamic)
+
+ ...
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``EnvModules_FOUND``
+ True if a compatible environment modules framework was found.
+
+Cache Variables
+^^^^^^^^^^^^^^^
+
+The following cache variable will be set:
+
+``EnvModules_COMMAND``
+ The low level module command to use. Currently supported
+ implementations are the Lua based Lmod and TCL based EnvironmentModules.
+
+Environment Variables
+^^^^^^^^^^^^^^^^^^^^^
+
+``ENV{MODULESHOME}``
+ Usually set by the module environment implementation, used as a hint to
+ locate the module command to execute.
+
+Provided Functions
+^^^^^^^^^^^^^^^^^^
+
+This defines the following CMake functions for interacting with environment
+modules:
+
+.. command:: env_module
+
+ Execute an aribitrary module command:
+
+ .. code-block:: cmake
+
+ env_module(cmd arg1 ... argN)
+ env_module(
+ COMMAND cmd arg1 ... argN
+ [OUTPUT_VARIABLE <out-var>]
+ [RESULT_VARIABLE <ret-var>]
+ )
+
+ The options are:
+
+ ``cmd arg1 ... argN``
+ The module sub-command and arguments to execute as if they were
+ passed directly to the module command in your shell environment.
+
+ ``OUTPUT_VARIABLE <out-var>``
+ The standard output from executing the module command.
+
+ ``RESULT_VARIABLE <ret-var>``
+ The return code from executing the module command.
+
+.. command:: env_module_swap
+
+ Swap one module for another:
+
+ .. code-block:: cmake
+
+ env_module_swap(out_mod in_mod
+ [OUTPUT_VARIABLE <out-var>]
+ [RESULT_VARIABLE <ret-var>]
+ )
+
+ This is functionally equivalent to the ``module swap out_mod in_mod`` shell
+ command. The options are:
+
+ ``OUTPUT_VARIABLE <out-var>``
+ The standard output from executing the module command.
+
+ ``RESULT_VARIABLE <ret-var>``
+ The return code from executing the module command.
+
+.. command:: env_module_list
+
+ Retrieve the list of currently loaded modules:
+
+ .. code-block:: cmake
+
+ env_module_list(<out-var>)
+
+ This is functionally equivalent to the ``module list`` shell command.
+ The result is stored in ``<out-var>`` as a properly formatted CMake
+ :ref:`semicolon-separated list <CMake Language Lists>` variable.
+
+.. command:: env_module_avail
+
+ Retrieve the list of available modules:
+
+ .. code-block:: cmake
+
+ env_module_avail([<mod-prefix>] <out-var>)
+
+ This is functionally equivalent to the ``module avail <mod-prefix>`` shell
+ command. The result is stored in ``<out-var>`` as a properly formatted
+ CMake :ref:`semicolon-separated list <CMake Language Lists>` variable.
+
+#]=======================================================================]
+
+function(env_module)
+ if(NOT EnvModules_COMMAND)
+ message(FATAL_ERROR "Failed to process module command. EnvModules_COMMAND not found")
+ return()
+ endif()
+
+ set(options)
+ set(oneValueArgs OUTPUT_VARIABLE RESULT_VARIABLE)
+ set(multiValueArgs COMMAND)
+ cmake_parse_arguments(MOD_ARGS
+ "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV}
+ )
+ if(NOT MOD_ARGS_COMMAND)
+ # If no explicit command argument was given, then treat the calling syntax
+ # as: module(cmd args...)
+ set(exec_cmd ${ARGV})
+ else()
+ set(exec_cmd ${MOD_ARGS_COMMAND})
+ endif()
+
+ if(MOD_ARGS_OUTPUT_VARIABLE)
+ set(err_var_args ERROR_VARIABLE err_var)
+ endif()
+
+ execute_process(
+ COMMAND mktemp -t module.cmake.XXXXXXXXXXXX
+ OUTPUT_VARIABLE tempfile_name
+ )
+ string(STRIP "${tempfile_name}" tempfile_name)
+
+ # If the $MODULESHOME/init/cmake file exists then assume that the CMake
+ # "shell" functionality exits
+ if(EXISTS "$ENV{MODULESHOME}/init/cmake")
+ execute_process(
+ COMMAND ${EnvModules_COMMAND} cmake ${exec_cmd}
+ OUTPUT_FILE ${tempfile_name}
+ ${err_var_args}
+ RESULT_VARIABLE ret_var
+ )
+
+ else() # fallback to the sh shell and manually convert to CMake
+ execute_process(
+ COMMAND ${EnvModules_COMMAND} sh ${exec_cmd}
+ OUTPUT_VARIABLE out_var
+ ${err_var_args}
+ RESULT_VARIABLE ret_var
+ )
+ endif()
+
+ # If we executed successfully then process and cleanup the temp file
+ if(ret_var EQUAL 0)
+ # No CMake shell so we need to process the sh output into CMake code
+ if(NOT EXISTS "$ENV{MODULESHOME}/init/cmake")
+ file(WRITE ${tempfile_name} "")
+ string(REPLACE "\n" ";" out_var "${out_var}")
+ foreach(sh_cmd IN LISTS out_var)
+ if(sh_cmd MATCHES "^ *unset *([^ ]*)")
+ set(cmake_cmd "unset(ENV{${CMAKE_MATCH_1}})")
+ elseif(sh_cmd MATCHES "^ *export *([^ ]*)")
+ set(cmake_cmd "set(ENV{${CMAKE_MATCH_1}} \"\${${CMAKE_MATCH_1}}\")")
+ elseif(sh_cmd MATCHES " *([^ =]*) *= *(.*)")
+ set(var_name "${CMAKE_MATCH_1}")
+ set(var_value "${CMAKE_MATCH_2}")
+ if(var_value MATCHES "^\"(.*[^\\])\"")
+ # If it's in quotes, take the value as is
+ set(var_value "${CMAKE_MATCH_1}")
+ else()
+ # Otherwise, strip trailing spaces
+ string(REGEX REPLACE "([^\\])? +$" "\\1" var_value "${var_value}")
+ endif()
+ string(REPLACE "\\ " " " var_value "${var_value}")
+ set(cmake_cmd "set(${var_name} \"${var_value}\")")
+ else()
+ continue()
+ endif()
+ file(APPEND ${tempfile_name} "${cmake_cmd}\n")
+ endforeach()
+ endif()
+
+ # Process the change in environment variables
+ include(${tempfile_name})
+ file(REMOVE ${tempfile_name})
+ endif()
+
+ # Push the output back out to the calling scope
+ if(MOD_ARGS_OUTPUT_VARIABLE)
+ set(${MOD_ARGS_OUTPUT_VARIABLE} "${err_var}" PARENT_SCOPE)
+ endif()
+ if(MOD_ARGS_RESULT_VARIABLE)
+ set(${MOD_ARGS_RESULT_VARIABLE} ${ret_var} PARENT_SCOPE)
+ endif()
+endfunction(env_module)
+
+#------------------------------------------------------------------------------
+function(env_module_swap out_mod in_mod)
+ set(options)
+ set(oneValueArgs OUTPUT_VARIABLE RESULT_VARIABLE)
+ set(multiValueArgs)
+
+ cmake_parse_arguments(MOD_ARGS
+ "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV}
+ )
+
+ env_module(COMMAND -t swap ${out_mod} ${in_mod}
+ OUTPUT_VARIABLE tmp_out
+ RETURN_VARIABLE tmp_ret
+ )
+
+ if(MOD_ARGS_OUTPUT_VARIABLE)
+ set(${MOD_ARGS_OUTPUT_VARIABLE} "${err_var}" PARENT_SCOPE)
+ endif()
+ if(MOD_ARGS_RESULT_VARIABLE)
+ set(${MOD_ARGS_RESULT_VARIABLE} ${tmp_ret} PARENT_SCOPE)
+ endif()
+endfunction()
+
+#------------------------------------------------------------------------------
+function(env_module_list out_var)
+ cmake_policy(SET CMP0007 NEW)
+ env_module(COMMAND -t list OUTPUT_VARIABLE tmp_out)
+
+ # Convert output into a CMake list
+ string(REPLACE "\n" ";" ${out_var} "${tmp_out}")
+
+ # Remove title headers and empty entries
+ list(REMOVE_ITEM ${out_var} "No modules loaded")
+ if(${out_var})
+ list(FILTER ${out_var} EXCLUDE REGEX "^(.*:)?$")
+ endif()
+ list(FILTER ${out_var} EXCLUDE REGEX "^(.*:)?$")
+
+ set(${out_var} ${${out_var}} PARENT_SCOPE)
+endfunction()
+
+#------------------------------------------------------------------------------
+function(env_module_avail)
+ cmake_policy(SET CMP0007 NEW)
+
+ if(ARGC EQUAL 1)
+ set(mod_prefix)
+ set(out_var ${ARGV0})
+ elseif(ARGC EQUAL 2)
+ set(mod_prefix ${ARGV0})
+ set(out_var ${ARGV1})
+ else()
+ message(FATAL_ERROR "Usage: env_module_avail([mod_prefix] out_var)")
+ endif()
+ env_module(COMMAND -t avail ${mod_prefix} OUTPUT_VARIABLE tmp_out)
+
+ # Convert output into a CMake list
+ string(REPLACE "\n" ";" tmp_out "${tmp_out}")
+
+ set(${out_var})
+ foreach(MOD IN LISTS tmp_out)
+ # Remove directory entries and empty values
+ if(MOD MATCHES "^(.*:)?$")
+ continue()
+ endif()
+
+ # Convert default modules
+ if(MOD MATCHES "^(.*)/$" ) # "foo/"
+ list(APPEND ${out_var} ${CMAKE_MATCH_1})
+ elseif(MOD MATCHES "^((.*)/.*)\\(default\\)$") # "foo/1.2.3(default)"
+ list(APPEND ${out_var} ${CMAKE_MATCH_2})
+ list(APPEND ${out_var} ${CMAKE_MATCH_1})
+ else()
+ list(APPEND ${out_var} ${MOD})
+ endif()
+ endforeach()
+
+ set(${out_var} ${${out_var}} PARENT_SCOPE)
+endfunction()
+
+#------------------------------------------------------------------------------
+# Make sure we know where the underlying module command is
+find_program(EnvModules_COMMAND
+ NAMES lmod modulecmd
+ HINTS ENV MODULESHOME
+ PATH_SUFFIXES libexec
+)
+
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+find_package_handle_standard_args(EnvModules DEFAULT_MSG EnvModules_COMMAND)
diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake
index fef7fb474..d22b7ec67 100644
--- a/Modules/FindFLEX.cmake
+++ b/Modules/FindFLEX.cmake
@@ -1,100 +1,103 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindFLEX
-# --------
-#
-# Find flex executable and provides a macro to generate custom build rules
-#
-#
-#
-# The module defines the following variables:
-#
-# ::
-#
-# FLEX_FOUND - true is flex executable is found
-# FLEX_EXECUTABLE - the path to the flex executable
-# FLEX_VERSION - the version of flex
-# FLEX_LIBRARIES - The flex libraries
-# FLEX_INCLUDE_DIRS - The path to the flex headers
-#
-#
-#
-# The minimum required version of flex can be specified using the
-# standard syntax, e.g. find_package(FLEX 2.5.13)
-#
-#
-#
-# If flex is found on the system, the module provides the macro:
-#
-# ::
-#
-# FLEX_TARGET(Name FlexInput FlexOutput
-# [COMPILE_FLAGS <string>]
-# [DEFINES_FILE <string>]
-# )
-#
-# which creates a custom command to generate the <FlexOutput> file from
-# the <FlexInput> file. If COMPILE_FLAGS option is specified, the next
-# parameter is added to the flex command line. If flex is configured to
-# output a header file, the DEFINES_FILE option may be used to specify its
-# name. Name is an alias used to get details of this custom command.
-# Indeed the macro defines the following variables:
-#
-# ::
-#
-# FLEX_${Name}_DEFINED - true is the macro ran successfully
-# FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an
-# alias for FlexOutput
-# FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput}
-# FLEX_${Name}_OUTPUT_HEADER - the header flex output, if any.
-#
-#
-#
-# Flex scanners oftenly use tokens defined by Bison: the code generated
-# by Flex depends of the header generated by Bison. This module also
-# defines a macro:
-#
-# ::
-#
-# ADD_FLEX_BISON_DEPENDENCY(FlexTarget BisonTarget)
-#
-# which adds the required dependency between a scanner and a parser
-# where <FlexTarget> and <BisonTarget> are the first parameters of
-# respectively FLEX_TARGET and BISON_TARGET macros.
-#
-# ::
-#
-# ====================================================================
-# Example:
-#
-#
-#
-# ::
-#
-# find_package(BISON)
-# find_package(FLEX)
-#
-#
-#
-# ::
-#
-# BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp)
-# FLEX_TARGET(MyScanner lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp)
-# ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser)
-#
-#
-#
-# ::
-#
-# include_directories(${CMAKE_CURRENT_BINARY_DIR})
-# add_executable(Foo
-# Foo.cc
-# ${BISON_MyParser_OUTPUTS}
-# ${FLEX_MyScanner_OUTPUTS}
-# )
-# ====================================================================
+#[=======================================================================[.rst:
+FindFLEX
+--------
+
+Find Fast Lexical Analyzer (Flex) executable and provides a macro
+to generate custom build rules
+
+
+
+The module defines the following variables:
+
+::
+
+ FLEX_FOUND - True is flex executable is found
+ FLEX_EXECUTABLE - the path to the flex executable
+ FLEX_VERSION - the version of flex
+ FLEX_LIBRARIES - The flex libraries
+ FLEX_INCLUDE_DIRS - The path to the flex headers
+
+
+
+The minimum required version of flex can be specified using the
+standard syntax, e.g. :command:`find_package(FLEX 2.5.13)`
+
+
+
+If flex is found on the system, the module provides the macro:
+
+::
+
+ FLEX_TARGET(Name FlexInput FlexOutput
+ [COMPILE_FLAGS <string>]
+ [DEFINES_FILE <string>]
+ )
+
+which creates a custom command to generate the ``FlexOutput`` file from
+the ``FlexInput`` file. If ``COMPILE_FLAGS`` option is specified, the next
+parameter is added to the flex command line. If flex is configured to
+output a header file, the ``DEFINES_FILE`` option may be used to specify its
+name. Name is an alias used to get details of this custom command.
+Indeed the macro defines the following variables:
+
+::
+
+ FLEX_${Name}_DEFINED - true is the macro ran successfully
+ FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an
+ alias for FlexOutput
+ FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput}
+ FLEX_${Name}_OUTPUT_HEADER - the header flex output, if any.
+
+
+
+Flex scanners often use tokens defined by Bison: the code generated
+by Flex depends of the header generated by Bison. This module also
+defines a macro:
+
+::
+
+ ADD_FLEX_BISON_DEPENDENCY(FlexTarget BisonTarget)
+
+which adds the required dependency between a scanner and a parser
+where ``FlexTarget`` and ``BisonTarget`` are the first parameters of
+respectively ``FLEX_TARGET`` and ``BISON_TARGET`` macros.
+
+::
+
+ ====================================================================
+ Example:
+
+
+
+::
+
+ find_package(BISON)
+ find_package(FLEX)
+
+
+
+::
+
+ BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp)
+ FLEX_TARGET(MyScanner lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.cpp)
+ ADD_FLEX_BISON_DEPENDENCY(MyScanner MyParser)
+
+
+
+::
+
+ include_directories(${CMAKE_CURRENT_BINARY_DIR})
+ add_executable(Foo
+ Foo.cc
+ ${BISON_MyParser_OUTPUTS}
+ ${FLEX_MyScanner_OUTPUTS}
+ )
+ target_link_libraries(Foo ${FLEX_LIBRARIES})
+ ====================================================================
+#]=======================================================================]
find_program(FLEX_EXECUTABLE NAMES flex win_flex DOC "path to the flex executable")
mark_as_advanced(FLEX_EXECUTABLE)
diff --git a/Modules/FindFLTK.cmake b/Modules/FindFLTK.cmake
index e6bd3c98b..e273642b5 100644
--- a/Modules/FindFLTK.cmake
+++ b/Modules/FindFLTK.cmake
@@ -1,61 +1,83 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindFLTK
-# --------
-#
-# Find the native FLTK includes and library
-#
-#
-#
-# By default FindFLTK.cmake will search for all of the FLTK components
-# and add them to the FLTK_LIBRARIES variable.
-#
-# ::
-#
-# You can limit the components which get placed in FLTK_LIBRARIES by
-# defining one or more of the following three options:
-#
-#
-#
-# ::
-#
-# FLTK_SKIP_OPENGL, set to true to disable searching for opengl and
-# the FLTK GL library
-# FLTK_SKIP_FORMS, set to true to disable searching for fltk_forms
-# FLTK_SKIP_IMAGES, set to true to disable searching for fltk_images
-#
-#
-#
-# ::
-#
-# FLTK_SKIP_FLUID, set to true if the fluid binary need not be present
-# at build time
-#
-#
-#
-# The following variables will be defined:
-#
-# ::
-#
-# FLTK_FOUND, True if all components not skipped were found
-# FLTK_INCLUDE_DIR, where to find include files
-# FLTK_LIBRARIES, list of fltk libraries you should link against
-# FLTK_FLUID_EXECUTABLE, where to find the Fluid tool
-# FLTK_WRAP_UI, This enables the FLTK_WRAP_UI command
-#
-#
-#
-# The following cache variables are assigned but should not be used.
-# See the FLTK_LIBRARIES variable instead.
-#
-# ::
-#
-# FLTK_BASE_LIBRARY = the full path to fltk.lib
-# FLTK_GL_LIBRARY = the full path to fltk_gl.lib
-# FLTK_FORMS_LIBRARY = the full path to fltk_forms.lib
-# FLTK_IMAGES_LIBRARY = the full path to fltk_images.lib
+#[=======================================================================[.rst:
+FindFLTK
+--------
+
+Find the Fast Light Toolkit (FLTK) library
+
+Input Variables
+^^^^^^^^^^^^^^^
+
+By default this module will search for all of the FLTK components and
+add them to the ``FLTK_LIBRARIES`` variable. You can limit the components
+which get placed in ``FLTK_LIBRARIES`` by defining one or more of the
+following three options:
+
+``FLTK_SKIP_OPENGL``
+ Set to true to disable searching for the FLTK GL library
+
+``FLTK_SKIP_FORMS``
+ Set to true to disable searching for the FLTK Forms library
+
+``FLTK_SKIP_IMAGES``
+ Set to true to disable searching for the FLTK Images library
+
+FLTK is composed also by a binary tool. You can set the following option:
+
+``FLTK_SKIP_FLUID``
+ Set to true to not look for the FLUID binary
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+The following variables will be defined:
+
+``FLTK_FOUND``
+ True if all components not skipped were found
+
+``FLTK_INCLUDE_DIR``
+ Path to the include directory for FLTK header files
+
+``FLTK_LIBRARIES``
+ List of the FLTK libraries found
+
+``FLTK_FLUID_EXECUTABLE``
+ Path to the FLUID binary tool
+
+``FLTK_WRAP_UI``
+ True if FLUID is found, used to enable the FLTK_WRAP_UI command
+
+Cache Variables
+^^^^^^^^^^^^^^^
+
+The following cache variables are also available to set or use:
+
+``FLTK_BASE_LIBRARY_RELEASE``
+ The FLTK base library (optimized)
+
+``FLTK_BASE_LIBRARY_DEBUG``
+ The FLTK base library (debug)
+
+``FLTK_GL_LIBRARY_RELEASE``
+ The FLTK GL library (optimized)
+
+``FLTK_GL_LIBRARY_DEBUG``
+ The FLTK GL library (debug)
+
+``FLTK_FORMS_LIBRARY_RELEASE``
+ The FLTK Forms library (optimized)
+
+``FLTK_FORMS_LIBRARY_DEBUG``
+ The FLTK Forms library (debug)
+
+``FLTK_IMAGES_LIBRARY_RELEASE``
+ The FLTK Images protobuf library (optimized)
+
+``FLTK_IMAGES_LIBRARY_DEBUG``
+ The FLTK Images library (debug)
+#]=======================================================================]
if(NOT FLTK_SKIP_OPENGL)
find_package(OpenGL)
@@ -114,177 +136,183 @@ if(NOT FLTK_DIR)
# Look in places relative to the system executable search path.
${FLTK_DIR_SEARCH}
- PATHS
- # Look in standard UNIX install locations.
- /usr/local/lib/fltk
- /usr/lib/fltk
- /usr/local/fltk
- /usr/X11R6/include
+ PATH_SUFFIXES
+ fltk
+ fltk/include
+ lib/fltk
+ lib/fltk/include
# Help the user find it if we cannot.
DOC "The ${FLTK_DIR_STRING}"
)
endif()
- # Check if FLTK was built using CMake
- if(EXISTS ${FLTK_DIR}/FLTKConfig.cmake)
- set(FLTK_BUILT_WITH_CMAKE 1)
- endif()
-
- if(FLTK_BUILT_WITH_CMAKE)
- set(FLTK_FOUND 1)
- include(${FLTK_DIR}/FLTKConfig.cmake)
+# Check if FLTK was built using CMake
+if(EXISTS ${FLTK_DIR}/FLTKConfig.cmake)
+ set(FLTK_BUILT_WITH_CMAKE 1)
+endif()
- # Fluid
- if(FLUID_COMMAND)
- set(FLTK_FLUID_EXECUTABLE ${FLUID_COMMAND} CACHE FILEPATH "Fluid executable")
- else()
- find_program(FLTK_FLUID_EXECUTABLE fluid PATHS
- ${FLTK_EXECUTABLE_DIRS}
- ${FLTK_EXECUTABLE_DIRS}/RelWithDebInfo
- ${FLTK_EXECUTABLE_DIRS}/Debug
- ${FLTK_EXECUTABLE_DIRS}/Release
- NO_SYSTEM_PATH)
- endif()
- # mark_as_advanced(FLTK_FLUID_EXECUTABLE)
-
- set(FLTK_INCLUDE_DIR ${FLTK_DIR})
- link_directories(${FLTK_LIBRARY_DIRS})
-
- set(FLTK_BASE_LIBRARY fltk)
- set(FLTK_GL_LIBRARY fltk_gl)
- set(FLTK_FORMS_LIBRARY fltk_forms)
- set(FLTK_IMAGES_LIBRARY fltk_images)
-
- # Add the extra libraries
- load_cache(${FLTK_DIR}
- READ_WITH_PREFIX
- FL FLTK_USE_SYSTEM_JPEG
- FL FLTK_USE_SYSTEM_PNG
- FL FLTK_USE_SYSTEM_ZLIB
- )
-
- set(FLTK_IMAGES_LIBS "")
- if(FLFLTK_USE_SYSTEM_JPEG)
- set(FLTK_IMAGES_LIBS ${FLTK_IMAGES_LIBS} fltk_jpeg)
- endif()
- if(FLFLTK_USE_SYSTEM_PNG)
- set(FLTK_IMAGES_LIBS ${FLTK_IMAGES_LIBS} fltk_png)
- endif()
- if(FLFLTK_USE_SYSTEM_ZLIB)
- set(FLTK_IMAGES_LIBS ${FLTK_IMAGES_LIBS} fltk_zlib)
- endif()
- set(FLTK_IMAGES_LIBS "${FLTK_IMAGES_LIBS}" CACHE INTERNAL
- "Extra libraries for fltk_images library.")
+if(FLTK_BUILT_WITH_CMAKE)
+ set(FLTK_FOUND 1)
+ include(${FLTK_DIR}/FLTKConfig.cmake)
+ # Fluid
+ if(FLUID_COMMAND)
+ set(FLTK_FLUID_EXECUTABLE ${FLUID_COMMAND} CACHE FILEPATH "Fluid executable")
else()
+ find_program(FLTK_FLUID_EXECUTABLE fluid PATHS
+ ${FLTK_EXECUTABLE_DIRS}
+ ${FLTK_EXECUTABLE_DIRS}/RelWithDebInfo
+ ${FLTK_EXECUTABLE_DIRS}/Debug
+ ${FLTK_EXECUTABLE_DIRS}/Release
+ NO_SYSTEM_PATH)
+ endif()
+ # mark_as_advanced(FLTK_FLUID_EXECUTABLE)
+
+ set(FLTK_INCLUDE_DIR ${FLTK_DIR})
+ link_directories(${FLTK_LIBRARY_DIRS})
+
+ set(FLTK_BASE_LIBRARY fltk)
+ set(FLTK_GL_LIBRARY fltk_gl)
+ set(FLTK_FORMS_LIBRARY fltk_forms)
+ set(FLTK_IMAGES_LIBRARY fltk_images)
+
+ # Add the extra libraries
+ load_cache(${FLTK_DIR}
+ READ_WITH_PREFIX
+ FL FLTK_USE_SYSTEM_JPEG
+ FL FLTK_USE_SYSTEM_PNG
+ FL FLTK_USE_SYSTEM_ZLIB
+ )
- # if FLTK was not built using CMake
- # Find fluid executable.
- find_program(FLTK_FLUID_EXECUTABLE fluid ${FLTK_INCLUDE_DIR}/fluid)
-
- # Use location of fluid to help find everything else.
- set(FLTK_INCLUDE_SEARCH_PATH "")
- set(FLTK_LIBRARY_SEARCH_PATH "")
- if(FLTK_FLUID_EXECUTABLE)
- get_filename_component(FLTK_BIN_DIR "${FLTK_FLUID_EXECUTABLE}" PATH)
- set(FLTK_INCLUDE_SEARCH_PATH ${FLTK_INCLUDE_SEARCH_PATH}
- ${FLTK_BIN_DIR}/../include ${FLTK_BIN_DIR}/..)
- set(FLTK_LIBRARY_SEARCH_PATH ${FLTK_LIBRARY_SEARCH_PATH}
- ${FLTK_BIN_DIR}/../lib)
- set(FLTK_WRAP_UI 1)
- endif()
+ set(FLTK_IMAGES_LIBS "")
+ if(FLFLTK_USE_SYSTEM_JPEG)
+ set(FLTK_IMAGES_LIBS ${FLTK_IMAGES_LIBS} fltk_jpeg)
+ endif()
+ if(FLFLTK_USE_SYSTEM_PNG)
+ set(FLTK_IMAGES_LIBS ${FLTK_IMAGES_LIBS} fltk_png)
+ endif()
+ if(FLFLTK_USE_SYSTEM_ZLIB)
+ set(FLTK_IMAGES_LIBS ${FLTK_IMAGES_LIBS} fltk_zlib)
+ endif()
+ set(FLTK_IMAGES_LIBS "${FLTK_IMAGES_LIBS}" CACHE INTERNAL
+ "Extra libraries for fltk_images library.")
- #
- # Try to find FLTK include dir using fltk-config
- #
- if(UNIX)
- # Use fltk-config to generate a list of possible include directories
- find_program(FLTK_CONFIG_SCRIPT fltk-config PATHS ${FLTK_BIN_DIR})
- if(FLTK_CONFIG_SCRIPT)
- if(NOT FLTK_INCLUDE_DIR)
- exec_program(${FLTK_CONFIG_SCRIPT} ARGS --cxxflags OUTPUT_VARIABLE FLTK_CXXFLAGS)
- if(FLTK_CXXFLAGS)
- string(REGEX MATCHALL "-I[^ ]*" _fltk_temp_dirs ${FLTK_CXXFLAGS})
- string(REPLACE "-I" "" _fltk_temp_dirs "${_fltk_temp_dirs}")
- foreach(_dir ${_fltk_temp_dirs})
- string(STRIP ${_dir} _output)
- list(APPEND _FLTK_POSSIBLE_INCLUDE_DIRS ${_output})
- endforeach()
- endif()
- endif()
- endif()
- endif()
+else()
+ # if FLTK was not built using CMake
+ # Find fluid executable.
+ find_program(FLTK_FLUID_EXECUTABLE fluid ${FLTK_INCLUDE_DIR}/fluid)
+
+ # Use location of fluid to help find everything else.
+ set(FLTK_INCLUDE_SEARCH_PATH "")
+ set(FLTK_LIBRARY_SEARCH_PATH "")
+ if(FLTK_FLUID_EXECUTABLE)
+ get_filename_component(FLTK_BIN_DIR "${FLTK_FLUID_EXECUTABLE}" PATH)
set(FLTK_INCLUDE_SEARCH_PATH ${FLTK_INCLUDE_SEARCH_PATH}
- /usr/local/fltk
- /usr/X11R6/include
- ${_FLTK_POSSIBLE_INCLUDE_DIRS}
- )
-
- find_path(FLTK_INCLUDE_DIR
- NAMES FL/Fl.h FL/Fl.H # fltk 1.1.9 has Fl.H (#8376)
- PATHS ${FLTK_INCLUDE_SEARCH_PATH})
-
- #
- # Try to find FLTK library
- if(UNIX)
- if(FLTK_CONFIG_SCRIPT)
- exec_program(${FLTK_CONFIG_SCRIPT} ARGS --libs OUTPUT_VARIABLE _FLTK_POSSIBLE_LIBS)
- if(_FLTK_POSSIBLE_LIBS)
- get_filename_component(_FLTK_POSSIBLE_LIBRARY_DIR ${_FLTK_POSSIBLE_LIBS} PATH)
+ ${FLTK_BIN_DIR}/../include ${FLTK_BIN_DIR}/..)
+ set(FLTK_LIBRARY_SEARCH_PATH ${FLTK_LIBRARY_SEARCH_PATH}
+ ${FLTK_BIN_DIR}/../lib)
+ set(FLTK_WRAP_UI 1)
+ endif()
+
+ #
+ # Try to find FLTK include dir using fltk-config
+ #
+ if(UNIX)
+ # Use fltk-config to generate a list of possible include directories
+ find_program(FLTK_CONFIG_SCRIPT fltk-config PATHS ${FLTK_BIN_DIR})
+ if(FLTK_CONFIG_SCRIPT)
+ if(NOT FLTK_INCLUDE_DIR)
+ exec_program(${FLTK_CONFIG_SCRIPT} ARGS --cxxflags OUTPUT_VARIABLE FLTK_CXXFLAGS)
+ if(FLTK_CXXFLAGS)
+ string(REGEX MATCHALL "-I[^ ]*" _fltk_temp_dirs ${FLTK_CXXFLAGS})
+ string(REPLACE "-I" "" _fltk_temp_dirs "${_fltk_temp_dirs}")
+ foreach(_dir ${_fltk_temp_dirs})
+ string(STRIP ${_dir} _output)
+ list(APPEND _FLTK_POSSIBLE_INCLUDE_DIRS ${_output})
+ endforeach()
endif()
endif()
endif()
+ endif()
- set(FLTK_LIBRARY_SEARCH_PATH ${FLTK_LIBRARY_SEARCH_PATH}
- /usr/local/fltk/lib
- /usr/X11R6/lib
- ${FLTK_INCLUDE_DIR}/lib
- ${_FLTK_POSSIBLE_LIBRARY_DIR}
- )
-
- find_library(FLTK_BASE_LIBRARY NAMES fltk fltkd
- PATHS ${FLTK_LIBRARY_SEARCH_PATH})
- find_library(FLTK_GL_LIBRARY NAMES fltkgl fltkgld fltk_gl
- PATHS ${FLTK_LIBRARY_SEARCH_PATH})
- find_library(FLTK_FORMS_LIBRARY NAMES fltkforms fltkformsd fltk_forms
- PATHS ${FLTK_LIBRARY_SEARCH_PATH})
- find_library(FLTK_IMAGES_LIBRARY NAMES fltkimages fltkimagesd fltk_images
- PATHS ${FLTK_LIBRARY_SEARCH_PATH})
-
- # Find the extra libraries needed for the fltk_images library.
- if(UNIX)
- if(FLTK_CONFIG_SCRIPT)
- exec_program(${FLTK_CONFIG_SCRIPT} ARGS --use-images --ldflags
- OUTPUT_VARIABLE FLTK_IMAGES_LDFLAGS)
- set(FLTK_LIBS_EXTRACT_REGEX ".*-lfltk_images (.*) -lfltk.*")
- if("${FLTK_IMAGES_LDFLAGS}" MATCHES "${FLTK_LIBS_EXTRACT_REGEX}")
- string(REGEX REPLACE " +" ";" FLTK_IMAGES_LIBS "${CMAKE_MATCH_1}")
- # The EXEC_PROGRAM will not be inherited into subdirectories from
- # the file that originally included this module. Save the answer.
- set(FLTK_IMAGES_LIBS "${FLTK_IMAGES_LIBS}" CACHE INTERNAL
- "Extra libraries for fltk_images library.")
- endif()
+ list(APPEND FLTK_INCLUDE_SEARCH_PATH ${_FLTK_POSSIBLE_INCLUDE_DIRS})
+
+ find_path(FLTK_INCLUDE_DIR
+ NAMES FL/Fl.h FL/Fl.H # fltk 1.1.9 has Fl.H (#8376)
+ PATH_SUFFIXES fltk fltk/include
+ PATHS ${FLTK_INCLUDE_SEARCH_PATH})
+
+ #
+ # Try to find FLTK library
+ if(UNIX)
+ if(FLTK_CONFIG_SCRIPT)
+ exec_program(${FLTK_CONFIG_SCRIPT} ARGS --libs OUTPUT_VARIABLE _FLTK_POSSIBLE_LIBS)
+ if(_FLTK_POSSIBLE_LIBS)
+ get_filename_component(_FLTK_POSSIBLE_LIBRARY_DIR ${_FLTK_POSSIBLE_LIBS} PATH)
endif()
endif()
-
endif()
- # Append all of the required libraries together (by default, everything)
- set(FLTK_LIBRARIES)
- if(NOT FLTK_SKIP_IMAGES)
- list(APPEND FLTK_LIBRARIES ${FLTK_IMAGES_LIBRARY})
+ list(APPEND FLTK_LIBRARY_SEARCH_PATH ${FLTK_INCLUDE_DIR}/lib ${_FLTK_POSSIBLE_LIBRARY_DIR})
+
+ include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
+
+ # Allow libraries to be set manually
+ if(NOT FLTK_BASE_LIBRARY)
+ find_library(FLTK_BASE_LIBRARY_RELEASE NAMES fltk PATHS ${FLTK_LIBRARY_SEARCH_PATH} PATH_SUFFIXES fltk fltk/lib)
+ find_library(FLTK_BASE_LIBRARY_DEBUG NAMES fltkd PATHS ${FLTK_LIBRARY_SEARCH_PATH} PATH_SUFFIXES fltk fltk/lib)
+ select_library_configurations(FLTK_BASE)
+ endif()
+ if(NOT FLTK_GL_LIBRARY)
+ find_library(FLTK_GL_LIBRARY_RELEASE NAMES fltkgl fltk_gl PATHS ${FLTK_LIBRARY_SEARCH_PATH} PATH_SUFFIXES fltk fltk/lib)
+ find_library(FLTK_GL_LIBRARY_DEBUG NAMES fltkgld fltk_gld PATHS ${FLTK_LIBRARY_SEARCH_PATH} PATH_SUFFIXES fltk fltk/lib)
+ select_library_configurations(FLTK_GL)
endif()
- if(NOT FLTK_SKIP_FORMS)
- list(APPEND FLTK_LIBRARIES ${FLTK_FORMS_LIBRARY})
+ if(NOT FLTK_FORMS_LIBRARY)
+ find_library(FLTK_FORMS_LIBRARY_RELEASE NAMES fltkforms fltk_forms PATHS ${FLTK_LIBRARY_SEARCH_PATH} PATH_SUFFIXES fltk fltk/lib)
+ find_library(FLTK_FORMS_LIBRARY_DEBUG NAMES fltkformsd fltk_formsd PATHS ${FLTK_LIBRARY_SEARCH_PATH} PATH_SUFFIXES fltk fltk/lib)
+ select_library_configurations(FLTK_FORMS)
endif()
- if(NOT FLTK_SKIP_OPENGL)
- list(APPEND FLTK_LIBRARIES ${FLTK_GL_LIBRARY} ${OPENGL_gl_LIBRARY})
- list(APPEND FLTK_INCLUDE_DIR ${OPENGL_INCLUDE_DIR})
- list(REMOVE_DUPLICATES FLTK_INCLUDE_DIR)
+ if(NOT FLTK_IMAGES_LIBRARY)
+ find_library(FLTK_IMAGES_LIBRARY_RELEASE NAMES fltkimages fltk_images PATHS ${FLTK_LIBRARY_SEARCH_PATH} PATH_SUFFIXES fltk fltk/lib)
+ find_library(FLTK_IMAGES_LIBRARY_DEBUG NAMES fltkimagesd fltk_imagesd PATHS ${FLTK_LIBRARY_SEARCH_PATH} PATH_SUFFIXES fltk fltk/lib)
+ select_library_configurations(FLTK_IMAGES)
+ endif()
+
+ # Find the extra libraries needed for the fltk_images library.
+ if(UNIX)
+ if(FLTK_CONFIG_SCRIPT)
+ exec_program(${FLTK_CONFIG_SCRIPT} ARGS --use-images --ldflags
+ OUTPUT_VARIABLE FLTK_IMAGES_LDFLAGS)
+ set(FLTK_LIBS_EXTRACT_REGEX ".*-lfltk_images (.*) -lfltk.*")
+ if("${FLTK_IMAGES_LDFLAGS}" MATCHES "${FLTK_LIBS_EXTRACT_REGEX}")
+ string(REGEX REPLACE " +" ";" FLTK_IMAGES_LIBS "${CMAKE_MATCH_1}")
+ # The EXEC_PROGRAM will not be inherited into subdirectories from
+ # the file that originally included this module. Save the answer.
+ set(FLTK_IMAGES_LIBS "${FLTK_IMAGES_LIBS}" CACHE INTERNAL
+ "Extra libraries for fltk_images library.")
+ endif()
+ endif()
endif()
- list(APPEND FLTK_LIBRARIES ${FLTK_BASE_LIBRARY})
+
+endif()
+
+# Append all of the required libraries together (by default, everything)
+set(FLTK_LIBRARIES)
+if(NOT FLTK_SKIP_IMAGES)
+ list(APPEND FLTK_LIBRARIES ${FLTK_IMAGES_LIBRARY})
+endif()
+if(NOT FLTK_SKIP_FORMS)
+ list(APPEND FLTK_LIBRARIES ${FLTK_FORMS_LIBRARY})
+endif()
+if(NOT FLTK_SKIP_OPENGL)
+ list(APPEND FLTK_LIBRARIES ${FLTK_GL_LIBRARY} ${OPENGL_gl_LIBRARY})
+ list(APPEND FLTK_INCLUDE_DIR ${OPENGL_INCLUDE_DIR})
+ list(REMOVE_DUPLICATES FLTK_INCLUDE_DIR)
+endif()
+list(APPEND FLTK_LIBRARIES ${FLTK_BASE_LIBRARY})
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
if(FLTK_SKIP_FLUID)
@@ -306,4 +334,3 @@ if(FLTK_FOUND)
set (FLTK_FLUID_EXE ${FLTK_FLUID_EXECUTABLE})
set (FLTK_LIBRARY ${FLTK_LIBRARIES})
endif()
-
diff --git a/Modules/FindFLTK2.cmake b/Modules/FindFLTK2.cmake
index a43e5ff27..a43f7a475 100644
--- a/Modules/FindFLTK2.cmake
+++ b/Modules/FindFLTK2.cmake
@@ -1,29 +1,30 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindFLTK2
-# ---------
-#
-# Find the native FLTK2 includes and library
-#
-# The following settings are defined
-#
-# ::
-#
-# FLTK2_FLUID_EXECUTABLE, where to find the Fluid tool
-# FLTK2_WRAP_UI, This enables the FLTK2_WRAP_UI command
-# FLTK2_INCLUDE_DIR, where to find include files
-# FLTK2_LIBRARIES, list of fltk2 libraries
-# FLTK2_FOUND, Don't use FLTK2 if false.
-#
-# The following settings should not be used in general.
-#
-# ::
-#
-# FLTK2_BASE_LIBRARY = the full path to fltk2.lib
-# FLTK2_GL_LIBRARY = the full path to fltk2_gl.lib
-# FLTK2_IMAGES_LIBRARY = the full path to fltk2_images.lib
+#[=======================================================================[.rst:
+FindFLTK2
+---------
+
+Find the native FLTK 2.0 includes and library
+
+The following settings are defined
+
+::
+
+ FLTK2_FLUID_EXECUTABLE, where to find the Fluid tool
+ FLTK2_WRAP_UI, This enables the FLTK2_WRAP_UI command
+ FLTK2_INCLUDE_DIR, where to find include files
+ FLTK2_LIBRARIES, list of fltk2 libraries
+ FLTK2_FOUND, Don't use FLTK2 if false.
+
+The following settings should not be used in general.
+
+::
+
+ FLTK2_BASE_LIBRARY = the full path to fltk2.lib
+ FLTK2_GL_LIBRARY = the full path to fltk2_gl.lib
+ FLTK2_IMAGES_LIBRARY = the full path to fltk2_images.lib
+#]=======================================================================]
set (FLTK2_DIR $ENV{FLTK2_DIR} )
@@ -80,11 +81,11 @@ if(NOT FLTK2_DIR)
# Look in places relative to the system executable search path.
${FLTK2_DIR_SEARCH}
- # Look in standard UNIX install locations.
- /usr/local/lib/fltk2
- /usr/lib/fltk2
- /usr/local/fltk2
- /usr/X11R6/include
+ PATH_SUFFIXES
+ fltk2
+ fltk2/include
+ lib/fltk2
+ lib/fltk2/include
# Help the user find it if we cannot.
DOC "The ${FLTK2_DIR_STRING}"
@@ -175,25 +176,16 @@ if(FLTK2_DIR)
set(FLTK2_WRAP_UI 1)
endif()
- set(FLTK2_INCLUDE_SEARCH_PATH ${FLTK2_INCLUDE_SEARCH_PATH}
- /usr/local/fltk2
- /usr/X11R6/include
- )
+ find_path(FLTK2_INCLUDE_DIR fltk/run.h ${FLTK2_INCLUDE_SEARCH_PATH} PATH_SUFFIXES fltk2 fltk2/include)
- find_path(FLTK2_INCLUDE_DIR fltk/run.h ${FLTK2_INCLUDE_SEARCH_PATH})
-
- set(FLTK2_LIBRARY_SEARCH_PATH ${FLTK2_LIBRARY_SEARCH_PATH}
- /usr/local/fltk2/lib
- /usr/X11R6/lib
- ${FLTK2_INCLUDE_DIR}/lib
- )
+ list(APPEND FLTK2_LIBRARY_SEARCH_PATH ${FLTK2_INCLUDE_DIR}/lib)
find_library(FLTK2_BASE_LIBRARY NAMES fltk2
- PATHS ${FLTK2_LIBRARY_SEARCH_PATH})
+ PATHS ${FLTK2_LIBRARY_SEARCH_PATH} PATH_SUFFIXES fltk2 fltk2/lib)
find_library(FLTK2_GL_LIBRARY NAMES fltk2_gl
- PATHS ${FLTK2_LIBRARY_SEARCH_PATH})
+ PATHS ${FLTK2_LIBRARY_SEARCH_PATH} PATH_SUFFIXES fltk2 fltk2/lib)
find_library(FLTK2_IMAGES_LIBRARY NAMES fltk2_images
- PATHS ${FLTK2_LIBRARY_SEARCH_PATH})
+ PATHS ${FLTK2_LIBRARY_SEARCH_PATH} PATH_SUFFIXES fltk2 fltk2/lib)
# Find the extra libraries needed for the fltk_images library.
if(UNIX)
@@ -251,4 +243,3 @@ else()
endif()
endif()
endif()
-
diff --git a/Modules/FindFontconfig.cmake b/Modules/FindFontconfig.cmake
new file mode 100644
index 000000000..a6f0180b3
--- /dev/null
+++ b/Modules/FindFontconfig.cmake
@@ -0,0 +1,101 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindFontconfig
+--------------
+
+Find Fontconfig headers and library.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+``Fontconfig::Fontconfig``
+ The Fontconfig library, if found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This will define the following variables in your project:
+
+``Fontconfig_FOUND``
+ true if (the requested version of) Fontconfig is available.
+``Fontconfig_VERSION``
+ the version of Fontconfig.
+``Fontconfig_LIBRARIES``
+ the libraries to link against to use Fontconfig.
+``Fontconfig_INCLUDE_DIRS``
+ where to find the Fontconfig headers.
+``Fontconfig_COMPILE_OPTIONS``
+ this should be passed to target_compile_options(), if the
+ target is not used for linking
+
+#]=======================================================================]
+
+
+# use pkg-config to get the directories and then use these values
+# in the FIND_PATH() and FIND_LIBRARY() calls
+find_package(PkgConfig QUIET)
+pkg_check_modules(PKG_FONTCONFIG QUIET fontconfig)
+set(Fontconfig_COMPILE_OPTIONS ${PKG_FONTCONFIG_CFLAGS_OTHER})
+set(Fontconfig_VERSION ${PKG_FONTCONFIG_VERSION})
+
+find_path( Fontconfig_INCLUDE_DIR
+ NAMES
+ fontconfig/fontconfig.h
+ HINTS
+ ${PKG_FONTCONFIG_INCLUDE_DIRS}
+ /usr/X11/include
+)
+
+find_library( Fontconfig_LIBRARY
+ NAMES
+ fontconfig
+ PATHS
+ ${PKG_FONTCONFIG_LIBRARY_DIRS}
+)
+
+if (Fontconfig_INCLUDE_DIR AND NOT Fontconfig_VERSION)
+ file(STRINGS ${Fontconfig_INCLUDE_DIR}/fontconfig/fontconfig.h _contents REGEX "^#define[ \t]+FC_[A-Z]+[ \t]+[0-9]+$")
+ unset(Fontconfig_VERSION)
+ foreach(VPART MAJOR MINOR REVISION)
+ foreach(VLINE ${_contents})
+ if(VLINE MATCHES "^#define[\t ]+FC_${VPART}[\t ]+([0-9]+)$")
+ set(Fontconfig_VERSION_PART "${CMAKE_MATCH_1}")
+ if(Fontconfig_VERSION)
+ string(APPEND Fontconfig_VERSION ".${Fontconfig_VERSION_PART}")
+ else()
+ set(Fontconfig_VERSION "${Fontconfig_VERSION_PART}")
+ endif()
+ endif()
+ endforeach()
+ endforeach()
+endif ()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Fontconfig
+ FOUND_VAR
+ Fontconfig_FOUND
+ REQUIRED_VARS
+ Fontconfig_LIBRARY
+ Fontconfig_INCLUDE_DIR
+ VERSION_VAR
+ Fontconfig_VERSION
+)
+
+
+if(Fontconfig_FOUND AND NOT TARGET Fontconfig::Fontconfig)
+ add_library(Fontconfig::Fontconfig UNKNOWN IMPORTED)
+ set_target_properties(Fontconfig::Fontconfig PROPERTIES
+ IMPORTED_LOCATION "${Fontconfig_LIBRARY}"
+ INTERFACE_COMPILE_OPTIONS "${Fontconfig_COMPILE_OPTIONS}"
+ INTERFACE_INCLUDE_DIRECTORIES "${Fontconfig_INCLUDE_DIR}"
+ )
+endif()
+
+mark_as_advanced(Fontconfig_LIBRARY Fontconfig_INCLUDE_DIR)
+
+if(Fontconfig_FOUND)
+ set(Fontconfig_LIBRARIES ${Fontconfig_LIBRARY})
+ set(Fontconfig_INCLUDE_DIRS ${Fontconfig_INCLUDE_DIR})
+endif()
diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake
index 9ea77df1d..3e6a177dc 100644
--- a/Modules/FindFreetype.cmake
+++ b/Modules/FindFreetype.cmake
@@ -1,28 +1,46 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindFreetype
-# ------------
-#
-# Locate FreeType library
-#
-# This module defines
-#
-# ::
-#
-# FREETYPE_LIBRARIES, the library to link against
-# FREETYPE_FOUND, if false, do not try to link to FREETYPE
-# FREETYPE_INCLUDE_DIRS, where to find headers.
-# FREETYPE_VERSION_STRING, the version of freetype found (since CMake 2.8.8)
-# This is the concatenation of the paths:
-# FREETYPE_INCLUDE_DIR_ft2build
-# FREETYPE_INCLUDE_DIR_freetype2
-#
-#
-#
-# $FREETYPE_DIR is an environment variable that would correspond to the
-# ./configure --prefix=$FREETYPE_DIR used in building FREETYPE.
+#[=======================================================================[.rst:
+FindFreetype
+------------
+
+Find the FreeType font renderer includes and library.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` target:
+
+``Freetype::Freetype``
+ The Freetype ``freetype`` library, if found
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``FREETYPE_FOUND``
+ true if the Freetype headers and libraries were found
+``FREETYPE_INCLUDE_DIRS``
+ directories containing the Freetype headers. This is the
+ concatenation of the variables:
+
+ ``FREETYPE_INCLUDE_DIR_ft2build``
+ directory holding the main Freetype API configuration header
+ ``FREETYPE_INCLUDE_DIR_freetype2``
+ directory holding Freetype public headers
+``FREETYPE_LIBRARIES``
+ the library to link against
+``FREETYPE_VERSION_STRING``
+ the version of freetype found (since CMake 2.8.8)
+
+Hints
+^^^^^
+
+The user may set the environment variable ``FREETYPE_DIR`` to the root
+directory of a Freetype installation.
+#]=======================================================================]
# Created by Eric Wing.
# Modifications by Alexander Neundorf.
@@ -46,10 +64,6 @@ set(FREETYPE_FIND_ARGS
HINTS
ENV FREETYPE_DIR
PATHS
- /usr/X11R6
- /usr/local/X11R6
- /usr/local/X11
- /usr/freeware
ENV GTKMM_BASEPATH
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
@@ -98,6 +112,9 @@ if(NOT FREETYPE_LIBRARY)
)
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
select_library_configurations(FREETYPE)
+else()
+ # on Windows, ensure paths are in canonical format (forward slahes):
+ file(TO_CMAKE_PATH "${FREETYPE_LIBRARY}" FREETYPE_LIBRARY)
endif()
unset(FREETYPE_FIND_ARGS)
@@ -150,3 +167,33 @@ mark_as_advanced(
FREETYPE_INCLUDE_DIR_freetype2
FREETYPE_INCLUDE_DIR_ft2build
)
+
+if(Freetype_FOUND)
+ if(NOT TARGET Freetype::Freetype)
+ add_library(Freetype::Freetype UNKNOWN IMPORTED)
+ set_target_properties(Freetype::Freetype PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${FREETYPE_INCLUDE_DIRS}")
+
+ if(FREETYPE_LIBRARY_RELEASE)
+ set_property(TARGET Freetype::Freetype APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(Freetype::Freetype PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
+ IMPORTED_LOCATION_RELEASE "${FREETYPE_LIBRARY_RELEASE}")
+ endif()
+
+ if(FREETYPE_LIBRARY_DEBUG)
+ set_property(TARGET Freetype::Freetype APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(Freetype::Freetype PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
+ IMPORTED_LOCATION_DEBUG "${FREETYPE_LIBRARY_DEBUG}")
+ endif()
+
+ if(NOT FREETYPE_LIBRARY_RELEASE AND NOT FREETYPE_LIBRARY_DEBUG)
+ set_target_properties(Freetype::Freetype PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${FREETYPE_LIBRARY}")
+ endif()
+ endif()
+endif()
diff --git a/Modules/FindGCCXML.cmake b/Modules/FindGCCXML.cmake
index 1f8d738f8..e6c7f2434 100644
--- a/Modules/FindGCCXML.cmake
+++ b/Modules/FindGCCXML.cmake
@@ -1,19 +1,20 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGCCXML
-# ----------
-#
-# Find the GCC-XML front-end executable.
-#
-#
-#
-# This module will define the following variables:
-#
-# ::
-#
-# GCCXML - the GCC-XML front-end executable.
+#[=======================================================================[.rst:
+FindGCCXML
+----------
+
+Find the GCC-XML front-end executable.
+
+
+
+This module will define the following variables:
+
+::
+
+ GCCXML - the GCC-XML front-end executable.
+#]=======================================================================]
find_program(GCCXML
NAMES gccxml
diff --git a/Modules/FindGDAL.cmake b/Modules/FindGDAL.cmake
index 0cce9cb9f..fde84d488 100644
--- a/Modules/FindGDAL.cmake
+++ b/Modules/FindGDAL.cmake
@@ -1,31 +1,49 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGDAL
-# --------
-#
-#
-#
-# Locate gdal
-#
-# This module accepts the following environment variables:
-#
-# ::
-#
-# GDAL_DIR or GDAL_ROOT - Specify the location of GDAL
-#
-#
-#
-# This module defines the following CMake variables:
-#
-# ::
-#
-# GDAL_FOUND - True if libgdal is found
-# GDAL_LIBRARY - A variable pointing to the GDAL library
-# GDAL_INCLUDE_DIR - Where to find the headers
+#[=======================================================================[.rst:
+FindGDAL
+--------
+
+Find Geospatial Data Abstraction Library (GDAL).
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``GDAL::GDAL``
+if GDAL has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``GDAL_FOUND``
+ True if GDAL is found.
+``GDAL_INCLUDE_DIRS``
+ Include directories for GDAL headers.
+``GDAL_LIBRARIES``
+ Libraries to link to GDAL.
+``GDAL_VERSION``
+ The version of GDAL found.
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``GDAL_LIBRARY``
+ The libgdal library file.
+``GDAL_INCLUDE_DIR``
+ The directory containing ``gdal.h``.
+
+Hints
+^^^^^
+
+Set ``GDAL_DIR`` or ``GDAL_ROOT`` in the environment to specify the
+GDAL installation prefix.
+#]=======================================================================]
-#
# $GDALDIR is an environment variable that would
# correspond to the ./configure --prefix=$GDAL_DIR
# used in building gdal.
@@ -50,13 +68,6 @@ find_path(GDAL_INCLUDE_DIR gdal.h
include/gdal
include/GDAL
include
- PATHS
- ~/Library/Frameworks/gdal.framework/Headers
- /Library/Frameworks/gdal.framework/Headers
- /sw # Fink
- /opt/local # DarwinPorts
- /opt/csw # Blastwave
- /opt
)
if(UNIX)
@@ -69,20 +80,53 @@ if(UNIX)
ENV GDAL_DIR
ENV GDAL_ROOT
PATH_SUFFIXES bin
- PATHS
- /sw # Fink
- /opt/local # DarwinPorts
- /opt/csw # Blastwave
- /opt
)
if(GDAL_CONFIG)
exec_program(${GDAL_CONFIG} ARGS --libs OUTPUT_VARIABLE GDAL_CONFIG_LIBS)
+
if(GDAL_CONFIG_LIBS)
- string(REGEX MATCHALL "-l[^ ]+" _gdal_dashl ${GDAL_CONFIG_LIBS})
- string(REPLACE "-l" "" _gdal_lib "${_gdal_dashl}")
- string(REGEX MATCHALL "-L[^ ]+" _gdal_dashL ${GDAL_CONFIG_LIBS})
- string(REPLACE "-L" "" _gdal_libpath "${_gdal_dashL}")
+ # treat the output as a command line and split it up
+ separate_arguments(args NATIVE_COMMAND "${GDAL_CONFIG_LIBS}")
+
+ # only consider libraries whose name matches this pattern
+ set(name_pattern "[gG][dD][aA][lL]")
+
+ # consider each entry as a possible library path, name, or parent directory
+ foreach(arg IN LISTS args)
+ # library name
+ if("${arg}" MATCHES "^-l(.*)$")
+ set(lib "${CMAKE_MATCH_1}")
+
+ # only consider libraries whose name matches the expected pattern
+ if("${lib}" MATCHES "${name_pattern}")
+ list(APPEND _gdal_lib "${lib}")
+ endif()
+ # library search path
+ elseif("${arg}" MATCHES "^-L(.*)$")
+ list(APPEND _gdal_libpath "${CMAKE_MATCH_1}")
+ # assume this is a full path to a library
+ elseif(IS_ABSOLUTE "${arg}" AND EXISTS "${arg}")
+ # extract the file name
+ get_filename_component(lib "${arg}" NAME)
+
+ # only consider libraries whose name matches the expected pattern
+ if(NOT "${lib}" MATCHES "${name_pattern}")
+ continue()
+ endif()
+
+ # extract the file directory
+ get_filename_component(dir "${arg}" DIRECTORY)
+
+ # remove library prefixes/suffixes
+ string(REGEX REPLACE "^(${CMAKE_SHARED_LIBRARY_PREFIX}|${CMAKE_STATIC_LIBRARY_PREFIX})" "" lib "${lib}")
+ string(REGEX REPLACE "(${CMAKE_SHARED_LIBRARY_SUFFIX}|${CMAKE_STATIC_LIBRARY_SUFFIX})$" "" lib "${lib}")
+
+ # use the file name and directory as hints
+ list(APPEND _gdal_libpath "${dir}")
+ list(APPEND _gdal_lib "${lib}")
+ endif()
+ endforeach()
endif()
endif()
endif()
@@ -94,16 +138,28 @@ find_library(GDAL_LIBRARY
ENV GDAL_ROOT
${_gdal_libpath}
PATH_SUFFIXES lib
- PATHS
- /sw
- /opt/local
- /opt/csw
- /opt
- /usr/freeware
)
+if (EXISTS "${GDAL_INCLUDE_DIR}/gdal_version.h")
+ file(STRINGS "${GDAL_INCLUDE_DIR}/gdal_version.h" _gdal_version
+ REGEX "GDAL_RELEASE_NAME")
+ string(REGEX REPLACE ".*\"\(.*\)\"" "\\1" GDAL_VERSION "${_gdal_version}")
+ unset(_gdal_version)
+else ()
+ set(GDAL_VERSION GDAL_VERSION-NOTFOUND)
+endif ()
+
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(GDAL DEFAULT_MSG GDAL_LIBRARY GDAL_INCLUDE_DIR)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GDAL
+ VERSION_VAR GDAL_VERSION
+ REQUIRED_VARS GDAL_LIBRARY GDAL_INCLUDE_DIR)
+
+if (GDAL_FOUND AND NOT TARGET GDAL::GDAL)
+ add_library(GDAL::GDAL UNKNOWN IMPORTED)
+ set_target_properties(GDAL::GDAL PROPERTIES
+ IMPORTED_LOCATION "${GDAL_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${GDAL_INCLUDE_DIR}")
+endif ()
set(GDAL_LIBRARIES ${GDAL_LIBRARY})
set(GDAL_INCLUDE_DIRS ${GDAL_INCLUDE_DIR})
diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake
index 0843d5fda..d5a143e81 100644
--- a/Modules/FindGIF.cmake
+++ b/Modules/FindGIF.cmake
@@ -1,28 +1,50 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGIF
-# -------
-#
-# This finds the GIF library (giflib)
-#
-# The module defines the following variables:
-#
-# ``GIF_FOUND``
-# True if giflib was found
-# ``GIF_LIBRARIES``
-# Libraries to link to in order to use giflib
-# ``GIF_INCLUDE_DIR``
-# where to find the headers
-# ``GIF_VERSION``
-# 3, 4 or a full version string (eg 5.1.4) for versions >= 4.1.6
-#
-# The minimum required version of giflib can be specified using the
-# standard syntax, e.g. find_package(GIF 4)
-#
-# $GIF_DIR is an environment variable that would correspond to the
-# ./configure --prefix=$GIF_DIR
+#[=======================================================================[.rst:
+FindGIF
+-------
+
+This finds the Graphics Interchange Format (GIF) library (``giflib``)
+
+Imported targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` target:
+
+``GIF::GIF``
+ The ``giflib`` library, if found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``GIF_FOUND``
+ If false, do not try to use GIF.
+``GIF_INCLUDE_DIRS``
+ where to find gif_lib.h, etc.
+``GIF_LIBRARIES``
+ the libraries needed to use GIF.
+``GIF_VERSION``
+ 3, 4 or a full version string (eg 5.1.4) for versions >= 4.1.6.
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``GIF_INCLUDE_DIR``
+ where to find the GIF headers.
+``GIF_LIBRARY``
+ where to find the GIF library.
+
+Hints
+^^^^^
+
+``GIF_DIR`` is an environment variable that would correspond to the
+``./configure --prefix=$GIF_DIR``.
+#]=======================================================================]
# Created by Eric Wing.
# Modifications by Alexander Neundorf, Ben Campbell
@@ -31,9 +53,6 @@ find_path(GIF_INCLUDE_DIR gif_lib.h
HINTS
ENV GIF_DIR
PATH_SUFFIXES include
- PATHS
- ~/Library/Frameworks
- /usr/freeware
)
# the gif library can have many names :-/
@@ -44,14 +63,8 @@ find_library(GIF_LIBRARY
HINTS
ENV GIF_DIR
PATH_SUFFIXES lib
- PATHS
- ~/Library/Frameworks
- /usr/freeware
)
-# see readme.txt
-set(GIF_LIBRARIES ${GIF_LIBRARY})
-
# Very basic version detection.
# The GIF_LIB_VERSION string in gif_lib.h seems to be unreliable, since it seems
# to be always " Version 2.0, " in versions 3.x of giflib.
@@ -95,4 +108,20 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GIF REQUIRED_VARS GIF_LIBRARY GIF_INCLUDE_DIR
VERSION_VAR GIF_VERSION )
+if(GIF_FOUND)
+ set(GIF_INCLUDE_DIRS "${GIF_INCLUDE_DIR}")
+ set(GIF_LIBRARIES ${GIF_LIBRARY})
+
+ if(NOT TARGET GIF::GIF)
+ add_library(GIF::GIF UNKNOWN IMPORTED)
+ set_target_properties(GIF::GIF PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${GIF_INCLUDE_DIRS}")
+ if(EXISTS "${GIF_LIBRARY}")
+ set_target_properties(GIF::GIF PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${GIF_LIBRARY}")
+ endif()
+ endif()
+endif()
+
mark_as_advanced(GIF_INCLUDE_DIR GIF_LIBRARY)
diff --git a/Modules/FindGLEW.cmake b/Modules/FindGLEW.cmake
index 11e872446..bd6981964 100644
--- a/Modules/FindGLEW.cmake
+++ b/Modules/FindGLEW.cmake
@@ -1,69 +1,342 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGLEW
-# --------
-#
-# Find the OpenGL Extension Wrangler Library (GLEW)
-#
-# IMPORTED Targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the :prop_tgt:`IMPORTED` target ``GLEW::GLEW``,
-# if GLEW has been found.
-#
-# Result Variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the following variables:
-#
-# ::
-#
-# GLEW_INCLUDE_DIRS - include directories for GLEW
-# GLEW_LIBRARIES - libraries to link against GLEW
-# GLEW_FOUND - true if GLEW has been found and can be used
+#[=======================================================================[.rst:
+FindGLEW
+--------
-find_path(GLEW_INCLUDE_DIR GL/glew.h)
+Find the OpenGL Extension Wrangler Library (GLEW)
+
+Input Variables
+^^^^^^^^^^^^^^^
+
+The following variables may be set to influence this module’s behavior:
+
+``GLEW_USE_STATIC_LIBS``
+ to find and create :prop_tgt:`IMPORTED` target for static linkage.
+
+``GLEW_VERBOSE``
+ to output a detailed log of this module.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :ref:`Imported Targets <Imported Targets>`:
-if(NOT GLEW_LIBRARY)
- find_library(GLEW_LIBRARY_RELEASE NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64 libx32)
- find_library(GLEW_LIBRARY_DEBUG NAMES GLEWd glew32d glewd PATH_SUFFIXES lib64)
- include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
- select_library_configurations(GLEW)
-endif ()
+``GLEW::glew``
+ The GLEW shared library.
+``GLEW::glew_s``
+ The GLEW static library, if ``GLEW_USE_STATIC_LIBS`` is set to ``TRUE``.
+``GLEW::GLEW``
+ Duplicates either ``GLEW::glew`` or ``GLEW::glew_s`` based on availability.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+``GLEW_INCLUDE_DIRS``
+ include directories for GLEW
+``GLEW_LIBRARIES``
+ libraries to link against GLEW
+``GLEW_SHARED_LIBRARIES``
+ libraries to link against shared GLEW
+``GLEW_STATIC_LIBRARIES``
+ libraries to link against static GLEW
+``GLEW_FOUND``
+ true if GLEW has been found and can be used
+``GLEW_VERSION``
+ GLEW version
+``GLEW_VERSION_MAJOR``
+ GLEW major version
+``GLEW_VERSION_MINOR``
+ GLEW minor version
+``GLEW_VERSION_MICRO``
+ GLEW micro version
+
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-find_package_handle_standard_args(GLEW
- REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY)
+
+find_package(GLEW CONFIG QUIET)
if(GLEW_FOUND)
- set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR})
+ find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_CONFIG)
+ return()
+endif()
- if(NOT GLEW_LIBRARIES)
- set(GLEW_LIBRARIES ${GLEW_LIBRARY})
+if(GLEW_VERBOSE)
+ message(STATUS "FindGLEW: did not find GLEW CMake config file. Searching for libraries.")
+endif()
+
+if(APPLE)
+ find_package(OpenGL QUIET)
+
+ if(OpenGL_FOUND)
+ if(GLEW_VERBOSE)
+ message(STATUS "FindGLEW: Found OpenGL Framework.")
+ message(STATUS "FindGLEW: OPENGL_LIBRARIES: ${OPENGL_LIBRARIES}")
+ endif()
+ else()
+ if(GLEW_VERBOSE)
+ message(STATUS "FindGLEW: could not find GLEW library.")
+ endif()
+ return()
endif()
+endif()
+
- if (NOT TARGET GLEW::GLEW)
- add_library(GLEW::GLEW UNKNOWN IMPORTED)
- set_target_properties(GLEW::GLEW PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}")
+function(__glew_set_find_library_suffix shared_or_static)
+ if((UNIX AND NOT APPLE) AND "${shared_or_static}" MATCHES "SHARED")
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" PARENT_SCOPE)
+ elseif((UNIX AND NOT APPLE) AND "${shared_or_static}" MATCHES "STATIC")
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" PARENT_SCOPE)
+ elseif(APPLE AND "${shared_or_static}" MATCHES "SHARED")
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib;.so" PARENT_SCOPE)
+ elseif(APPLE AND "${shared_or_static}" MATCHES "STATIC")
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" PARENT_SCOPE)
+ elseif(WIN32 AND "${shared_or_static}" MATCHES "SHARED")
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" PARENT_SCOPE)
+ elseif(WIN32 AND "${shared_or_static}" MATCHES "STATIC")
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll.a" PARENT_SCOPE)
+ endif()
+
+ if(GLEW_VERBOSE)
+ message(STATUS "FindGLEW: CMAKE_FIND_LIBRARY_SUFFIXES for ${shared_or_static}: ${CMAKE_FIND_LIBRARY_SUFFIXES}")
+ endif()
+endfunction()
+
+
+if(GLEW_VERBOSE)
+ if(DEFINED GLEW_USE_STATIC_LIBS)
+ message(STATUS "FindGLEW: GLEW_USE_STATIC_LIBS: ${GLEW_USE_STATIC_LIBS}.")
+ else()
+ message(STATUS "FindGLEW: GLEW_USE_STATIC_LIBS is undefined. Treated as FALSE.")
+ endif()
+endif()
+
+find_path(GLEW_INCLUDE_DIR GL/glew.h)
+mark_as_advanced(GLEW_INCLUDE_DIR)
+
+set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR})
+
+if(GLEW_VERBOSE)
+ message(STATUS "FindGLEW: GLEW_INCLUDE_DIR: ${GLEW_INCLUDE_DIR}")
+ message(STATUS "FindGLEW: GLEW_INCLUDE_DIRS: ${GLEW_INCLUDE_DIRS}")
+endif()
+
+if("${CMAKE_GENERATOR_PLATFORM}" MATCHES "x64" OR "${CMAKE_GENERATOR}" MATCHES "Win64")
+ set(_arch "x64")
+else()
+ set(_arch "Win32")
+endif()
+
+
+set(__GLEW_CURRENT_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
+
+__glew_set_find_library_suffix(SHARED)
+
+find_library(GLEW_SHARED_LIBRARY_RELEASE
+ NAMES GLEW glew glew32
+ PATH_SUFFIXES lib lib64 libx32 lib/Release/${_arch}
+ PATHS ENV GLEW_ROOT)
+
+find_library(GLEW_SHARED_LIBRARY_DEBUG
+ NAMES GLEWd glewd glew32d
+ PATH_SUFFIXES lib lib64
+ PATHS ENV GLEW_ROOT)
+
+
+__glew_set_find_library_suffix(STATIC)
+
+find_library(GLEW_STATIC_LIBRARY_RELEASE
+ NAMES GLEW glew glew32s
+ PATH_SUFFIXES lib lib64 libx32 lib/Release/${_arch}
+ PATHS ENV GLEW_ROOT)
+
+find_library(GLEW_STATIC_LIBRARY_DEBUG
+ NAMES GLEWds glewds glew32ds
+ PATH_SUFFIXES lib lib64
+ PATHS ENV GLEW_ROOT)
+
+set(CMAKE_FIND_LIBRARY_SUFFIXES ${__GLEW_CURRENT_FIND_LIBRARY_SUFFIXES})
+unset(__GLEW_CURRENT_FIND_LIBRARY_SUFFIXES)
+
+include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
+
+select_library_configurations(GLEW_SHARED)
+select_library_configurations(GLEW_STATIC)
+
+if(NOT GLEW_USE_STATIC_LIBS)
+ set(GLEW_LIBRARIES ${GLEW_SHARED_LIBRARY})
+else()
+ set(GLEW_LIBRARIES ${GLEW_STATIC_LIBRARY})
+endif()
+
+
+if(GLEW_VERBOSE)
+ message(STATUS "FindGLEW: GLEW_SHARED_LIBRARY_RELEASE: ${GLEW_SHARED_LIBRARY_RELEASE}")
+ message(STATUS "FindGLEW: GLEW_STATIC_LIBRARY_RELEASE: ${GLEW_STATIC_LIBRARY_RELEASE}")
+ message(STATUS "FindGLEW: GLEW_SHARED_LIBRARY_DEBUG: ${GLEW_SHARED_LIBRARY_DEBUG}")
+ message(STATUS "FindGLEW: GLEW_STATIC_LIBRARY_DEBUG: ${GLEW_STATIC_LIBRARY_DEBUG}")
+ message(STATUS "FindGLEW: GLEW_SHARED_LIBRARY: ${GLEW_SHARED_LIBRARY}")
+ message(STATUS "FindGLEW: GLEW_STATIC_LIBRARY: ${GLEW_STATIC_LIBRARY}")
+ message(STATUS "FindGLEW: GLEW_LIBRARIES: ${GLEW_LIBRARIES}")
+endif()
- if(GLEW_LIBRARY_RELEASE)
- set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
- set_target_properties(GLEW::GLEW PROPERTIES IMPORTED_LOCATION_RELEASE "${GLEW_LIBRARY_RELEASE}")
+
+# Read version from GL/glew.h file
+if(EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h")
+ file(STRINGS "${GLEW_INCLUDE_DIR}/GL/glew.h" _contents REGEX "^VERSION_.+ [0-9]+")
+ if(_contents)
+ string(REGEX REPLACE ".*VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" GLEW_VERSION_MAJOR "${_contents}")
+ string(REGEX REPLACE ".*VERSION_MINOR[ \t]+([0-9]+).*" "\\1" GLEW_VERSION_MINOR "${_contents}")
+ string(REGEX REPLACE ".*VERSION_MICRO[ \t]+([0-9]+).*" "\\1" GLEW_VERSION_MICRO "${_contents}")
+ set(GLEW_VERSION "${GLEW_VERSION_MAJOR}.${GLEW_VERSION_MINOR}.${GLEW_VERSION_MICRO}")
+ endif()
+endif()
+
+if(GLEW_VERBOSE)
+ message(STATUS "FindGLEW: GLEW_VERSION_MAJOR: ${GLEW_VERSION_MAJOR}")
+ message(STATUS "FindGLEW: GLEW_VERSION_MINOR: ${GLEW_VERSION_MINOR}")
+ message(STATUS "FindGLEW: GLEW_VERSION_MICRO: ${GLEW_VERSION_MICRO}")
+ message(STATUS "FindGLEW: GLEW_VERSION: ${GLEW_VERSION}")
+endif()
+
+find_package_handle_standard_args(GLEW
+ REQUIRED_VARS GLEW_INCLUDE_DIRS GLEW_LIBRARIES
+ VERSION_VAR GLEW_VERSION)
+
+if(NOT GLEW_FOUND)
+ if(GLEW_VERBOSE)
+ message(STATUS "FindGLEW: could not find GLEW library.")
+ endif()
+ return()
+endif()
+
+
+if(NOT TARGET GLEW::glew AND NOT GLEW_USE_STATIC_LIBS)
+ if(GLEW_VERBOSE)
+ message(STATUS "FindGLEW: Creating GLEW::glew imported target.")
+ endif()
+
+ add_library(GLEW::glew UNKNOWN IMPORTED)
+
+ set_target_properties(GLEW::glew
+ PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}")
+
+ if(APPLE)
+ set_target_properties(GLEW::glew
+ PROPERTIES INTERFACE_LINK_LIBRARIES OpenGL::GL)
+ endif()
+
+ if(GLEW_SHARED_LIBRARY_RELEASE)
+ set_property(TARGET GLEW::glew
+ APPEND
+ PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+
+ set_target_properties(GLEW::glew
+ PROPERTIES IMPORTED_LOCATION_RELEASE "${GLEW_SHARED_LIBRARY_RELEASE}")
+ endif()
+
+ if(GLEW_SHARED_LIBRARY_DEBUG)
+ set_property(TARGET GLEW::glew
+ APPEND
+ PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
+
+ set_target_properties(GLEW::glew
+ PROPERTIES IMPORTED_LOCATION_DEBUG "${GLEW_SHARED_LIBRARY_DEBUG}")
+ endif()
+
+elseif(NOT TARGET GLEW::glew_s AND GLEW_USE_STATIC_LIBS)
+ if(GLEW_VERBOSE)
+ message(STATUS "FindGLEW: Creating GLEW::glew_s imported target.")
+ endif()
+
+ add_library(GLEW::glew_s UNKNOWN IMPORTED)
+
+ set_target_properties(GLEW::glew_s
+ PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}")
+
+ if(APPLE)
+ set_target_properties(GLEW::glew_s
+ PROPERTIES INTERFACE_LINK_LIBRARIES OpenGL::GL)
+ endif()
+
+ if(GLEW_STATIC_LIBRARY_RELEASE)
+ set_property(TARGET GLEW::glew_s
+ APPEND
+ PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+
+ set_target_properties(GLEW::glew_s
+ PROPERTIES IMPORTED_LOCATION_RELEASE "${GLEW_STATIC_LIBRARY_RELEASE}")
+ endif()
+
+ if(GLEW_STATIC_LIBRARY_DEBUG)
+ set_property(TARGET GLEW::glew_s
+ APPEND
+ PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
+
+ set_target_properties(GLEW::glew_s
+ PROPERTIES IMPORTED_LOCATION_DEBUG "${GLEW_STATIC_LIBRARY_DEBUG}")
+ endif()
+endif()
+
+if(NOT TARGET GLEW::GLEW)
+ if(GLEW_VERBOSE)
+ message(STATUS "FindGLEW: Creating GLEW::GLEW imported target.")
+ endif()
+
+ add_library(GLEW::GLEW UNKNOWN IMPORTED)
+
+ set_target_properties(GLEW::GLEW
+ PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}")
+
+ if(APPLE)
+ set_target_properties(GLEW::GLEW
+ PROPERTIES INTERFACE_LINK_LIBRARIES OpenGL::GL)
+ endif()
+
+ if(TARGET GLEW::glew)
+ if(GLEW_SHARED_LIBRARY_RELEASE)
+ set_property(TARGET GLEW::GLEW
+ APPEND
+ PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+
+ set_target_properties(GLEW::GLEW
+ PROPERTIES IMPORTED_LOCATION_RELEASE "${GLEW_SHARED_LIBRARY_RELEASE}")
endif()
- if(GLEW_LIBRARY_DEBUG)
- set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
- set_target_properties(GLEW::GLEW PROPERTIES IMPORTED_LOCATION_DEBUG "${GLEW_LIBRARY_DEBUG}")
+ if(GLEW_SHARED_LIBRARY_DEBUG)
+ set_property(TARGET GLEW::GLEW
+ APPEND
+ PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
+
+ set_target_properties(GLEW::GLEW
+ PROPERTIES IMPORTED_LOCATION_DEBUG "${GLEW_SHARED_LIBRARY_DEBUG}")
endif()
- if(NOT GLEW_LIBRARY_RELEASE AND NOT GLEW_LIBRARY_DEBUG)
- set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_LOCATION "${GLEW_LIBRARY}")
+ elseif(TARGET GLEW::glew_s)
+ if(GLEW_STATIC_LIBRARY_RELEASE)
+ set_property(TARGET GLEW::GLEW
+ APPEND
+ PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+
+ set_target_properties(GLEW::GLEW
+ PROPERTIES IMPORTED_LOCATION_RELEASE "${GLEW_STATIC_LIBRARY_RELEASE}")
endif()
+
+ if(GLEW_STATIC_LIBRARY_DEBUG AND GLEW_USE_STATIC_LIBS)
+ set_property(TARGET GLEW::GLEW
+ APPEND
+ PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
+
+ set_target_properties(GLEW::GLEW
+ PROPERTIES IMPORTED_LOCATION_DEBUG "${GLEW_STATIC_LIBRARY_DEBUG}")
+ endif()
+
+ elseif(GLEW_VERBOSE)
+ message(WARNING "FindGLEW: no `GLEW::glew` or `GLEW::glew_s` target was created. Something went wrong in FindGLEW target creation.")
endif()
endif()
-
-mark_as_advanced(GLEW_INCLUDE_DIR)
diff --git a/Modules/FindGLU.cmake b/Modules/FindGLU.cmake
index dbec6d1cb..98928059c 100644
--- a/Modules/FindGLU.cmake
+++ b/Modules/FindGLU.cmake
@@ -15,4 +15,3 @@ if (OPENGL_GLU_FOUND)
set (GLU_LIBRARY ${OPENGL_LIBRARIES})
set (GLU_INCLUDE_PATH ${OPENGL_INCLUDE_DIR})
endif ()
-
diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake
index 88d4b2918..a22bf5bca 100644
--- a/Modules/FindGLUT.cmake
+++ b/Modules/FindGLUT.cmake
@@ -1,53 +1,64 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGLUT
-# --------
-#
-# try to find glut library and include files.
-#
-# IMPORTED Targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the :prop_tgt:`IMPORTED` targets:
-#
-# ``GLUT::GLUT``
-# Defined if the system has GLUT.
-#
-# Result Variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module sets the following variables:
-#
-# ::
-#
-# GLUT_INCLUDE_DIR, where to find GL/glut.h, etc.
-# GLUT_LIBRARIES, the libraries to link against
-# GLUT_FOUND, If false, do not try to use GLUT.
-#
-# Also defined, but not for general use are:
-#
-# ::
-#
-# GLUT_glut_LIBRARY = the full path to the glut library.
-# GLUT_Xmu_LIBRARY = the full path to the Xmu library.
-# GLUT_Xi_LIBRARY = the full path to the Xi Library.
+#[=======================================================================[.rst:
+FindGLUT
+--------
+
+Find OpenGL Utility Toolkit (GLUT) library and include files.
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines the :prop_tgt:`IMPORTED` targets:
+
+``GLUT::GLUT``
+ Defined if the system has GLUT.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module sets the following variables:
+
+::
+
+ GLUT_INCLUDE_DIR, where to find GL/glut.h, etc.
+ GLUT_LIBRARIES, the libraries to link against
+ GLUT_FOUND, If false, do not try to use GLUT.
+
+Also defined, but not for general use are:
+
+::
+
+ GLUT_glut_LIBRARY = the full path to the glut library.
+ GLUT_Xmu_LIBRARY = the full path to the Xmu library.
+ GLUT_Xi_LIBRARY = the full path to the Xi Library.
+#]=======================================================================]
+
+include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
if (WIN32)
find_path( GLUT_INCLUDE_DIR NAMES GL/glut.h
PATHS ${GLUT_ROOT_PATH}/include )
- find_library( GLUT_glut_LIBRARY NAMES glut glut32 freeglut
+ find_library( GLUT_glut_LIBRARY_RELEASE NAMES glut glut32 freeglut
PATHS
${OPENGL_LIBRARY_DIR}
${GLUT_ROOT_PATH}/Release
)
+ find_library( GLUT_glut_LIBRARY_DEBUG NAMES freeglutd
+ PATHS
+ ${OPENGL_LIBRARY_DIR}
+ ${GLUT_ROOT_PATH}/Debug
+ )
+ mark_as_advanced(GLUT_glut_LIBRARY_RELEASE GLUT_glut_LIBRARY_DEBUG)
+ select_library_configurations(GLUT_glut)
else ()
if (APPLE)
find_path(GLUT_INCLUDE_DIR glut.h ${OPENGL_LIBRARY_DIR})
find_library(GLUT_glut_LIBRARY GLUT DOC "GLUT library for OSX")
find_library(GLUT_cocoa_LIBRARY Cocoa DOC "Cocoa framework for OSX")
+ mark_as_advanced(GLUT_glut_LIBRARY GLUT_cocoa_LIBRARY)
if(GLUT_cocoa_LIBRARY AND NOT TARGET GLUT::Cocoa)
add_library(GLUT::Cocoa UNKNOWN IMPORTED)
@@ -72,10 +83,12 @@ else ()
find_library( GLUT_Xi_LIBRARY Xi
/usr/openwin/lib
)
+ mark_as_advanced(GLUT_Xi_LIBRARY)
find_library( GLUT_Xmu_LIBRARY Xmu
/usr/openwin/lib
)
+ mark_as_advanced(GLUT_Xmu_LIBRARY)
if(GLUT_Xi_LIBRARY AND NOT TARGET GLUT::Xi)
add_library(GLUT::Xi UNKNOWN IMPORTED)
@@ -104,6 +117,7 @@ else ()
/usr/openwin/lib
${_GLUT_glut_LIB_DIR}
)
+ mark_as_advanced(GLUT_glut_LIBRARY)
unset(_GLUT_INC_DIR)
unset(_GLUT_glut_LIB_DIR)
@@ -135,8 +149,24 @@ if (GLUT_FOUND)
set_target_properties(GLUT::GLUT PROPERTIES
IMPORTED_LOCATION "${GLUT_glut_LIBRARY}/${CMAKE_MATCH_1}")
else()
- set_target_properties(GLUT::GLUT PROPERTIES
- IMPORTED_LOCATION "${GLUT_glut_LIBRARY}")
+ if(GLUT_glut_LIBRARY_RELEASE)
+ set_property(TARGET GLUT::GLUT APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(GLUT::GLUT PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${GLUT_glut_LIBRARY_RELEASE}")
+ endif()
+
+ if(GLUT_glut_LIBRARY_DEBUG)
+ set_property(TARGET GLUT::GLUT APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(GLUT::GLUT PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${GLUT_glut_LIBRARY_DEBUG}")
+ endif()
+
+ if(NOT GLUT_glut_LIBRARY_RELEASE AND NOT GLUT_glut_LIBRARY_DEBUG)
+ set_property(TARGET GLUT::GLUT APPEND PROPERTY
+ IMPORTED_LOCATION "${GLUT_glut_LIBRARY}")
+ endif()
endif()
if(TARGET GLUT::Xmu)
@@ -160,9 +190,4 @@ if (GLUT_FOUND)
set (GLUT_INCLUDE_PATH ${GLUT_INCLUDE_DIR})
endif()
-mark_as_advanced(
- GLUT_INCLUDE_DIR
- GLUT_glut_LIBRARY
- GLUT_Xmu_LIBRARY
- GLUT_Xi_LIBRARY
- )
+mark_as_advanced(GLUT_INCLUDE_DIR)
diff --git a/Modules/FindGSL.cmake b/Modules/FindGSL.cmake
index 8d10b6ce5..da1b3c4e4 100644
--- a/Modules/FindGSL.cmake
+++ b/Modules/FindGSL.cmake
@@ -1,60 +1,61 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGSL
-# --------
-#
-# Find the native GSL includes and libraries.
-#
-# The GNU Scientific Library (GSL) is a numerical library for C and C++
-# programmers. It is free software under the GNU General Public
-# License.
-#
-# Imported Targets
-# ^^^^^^^^^^^^^^^^
-#
-# If GSL is found, this module defines the following :prop_tgt:`IMPORTED`
-# targets::
-#
-# GSL::gsl - The main GSL library.
-# GSL::gslcblas - The CBLAS support library used by GSL.
-#
-# Result Variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module will set the following variables in your project::
-#
-# GSL_FOUND - True if GSL found on the local system
-# GSL_INCLUDE_DIRS - Location of GSL header files.
-# GSL_LIBRARIES - The GSL libraries.
-# GSL_VERSION - The version of the discovered GSL install.
-#
-# Hints
-# ^^^^^
-#
-# Set ``GSL_ROOT_DIR`` to a directory that contains a GSL installation.
-#
-# This script expects to find libraries at ``$GSL_ROOT_DIR/lib`` and the GSL
-# headers at ``$GSL_ROOT_DIR/include/gsl``. The library directory may
-# optionally provide Release and Debug folders. If available, the libraries
-# named ``gsld``, ``gslblasd`` or ``cblasd`` are recognized as debug libraries.
-# For Unix-like systems, this script will use ``$GSL_ROOT_DIR/bin/gsl-config``
-# (if found) to aid in the discovery of GSL.
-#
-# Cache Variables
-# ^^^^^^^^^^^^^^^
-#
-# This module may set the following variables depending on platform and type
-# of GSL installation discovered. These variables may optionally be set to
-# help this module find the correct files::
-#
-# GSL_CBLAS_LIBRARY - Location of the GSL CBLAS library.
-# GSL_CBLAS_LIBRARY_DEBUG - Location of the debug GSL CBLAS library (if any).
-# GSL_CONFIG_EXECUTABLE - Location of the ``gsl-config`` script (if any).
-# GSL_LIBRARY - Location of the GSL library.
-# GSL_LIBRARY_DEBUG - Location of the debug GSL library (if any).
-#
+#[=======================================================================[.rst:
+FindGSL
+--------
+
+Find the native GNU Scientific Library (GSL) includes and libraries.
+
+The GNU Scientific Library (GSL) is a numerical library for C and C++
+programmers. It is free software under the GNU General Public
+License.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+If GSL is found, this module defines the following :prop_tgt:`IMPORTED`
+targets::
+
+ GSL::gsl - The main GSL library.
+ GSL::gslcblas - The CBLAS support library used by GSL.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project::
+
+ GSL_FOUND - True if GSL found on the local system
+ GSL_INCLUDE_DIRS - Location of GSL header files.
+ GSL_LIBRARIES - The GSL libraries.
+ GSL_VERSION - The version of the discovered GSL install.
+
+Hints
+^^^^^
+
+Set ``GSL_ROOT_DIR`` to a directory that contains a GSL installation.
+
+This script expects to find libraries at ``$GSL_ROOT_DIR/lib`` and the GSL
+headers at ``$GSL_ROOT_DIR/include/gsl``. The library directory may
+optionally provide Release and Debug folders. If available, the libraries
+named ``gsld``, ``gslblasd`` or ``cblasd`` are recognized as debug libraries.
+For Unix-like systems, this script will use ``$GSL_ROOT_DIR/bin/gsl-config``
+(if found) to aid in the discovery of GSL.
+
+Cache Variables
+^^^^^^^^^^^^^^^
+
+This module may set the following variables depending on platform and type
+of GSL installation discovered. These variables may optionally be set to
+help this module find the correct files::
+
+ GSL_CBLAS_LIBRARY - Location of the GSL CBLAS library.
+ GSL_CBLAS_LIBRARY_DEBUG - Location of the debug GSL CBLAS library (if any).
+ GSL_CONFIG_EXECUTABLE - Location of the ``gsl-config`` script (if any).
+ GSL_LIBRARY - Location of the GSL library.
+ GSL_LIBRARY_DEBUG - Location of the debug GSL library (if any).
+
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
diff --git a/Modules/FindGTK.cmake b/Modules/FindGTK.cmake
index 8a89cda6b..552b19a5f 100644
--- a/Modules/FindGTK.cmake
+++ b/Modules/FindGTK.cmake
@@ -1,18 +1,19 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGTK
-# -------
-#
-# try to find GTK (and glib) and GTKGLArea
-#
-# ::
-#
-# GTK_INCLUDE_DIR - Directories to include to use GTK
-# GTK_LIBRARIES - Files to link against to use GTK
-# GTK_FOUND - GTK was found
-# GTK_GL_FOUND - GTK's GL features were found
+#[=======================================================================[.rst:
+FindGTK
+-------
+
+Find GTK, glib and GTKGLArea
+
+::
+
+ GTK_INCLUDE_DIR - Directories to include to use GTK
+ GTK_LIBRARIES - Files to link against to use GTK
+ GTK_FOUND - GTK was found
+ GTK_GL_FOUND - GTK's GL features were found
+#]=======================================================================]
# don't even bother under WIN32
if(UNIX)
@@ -31,20 +32,17 @@ if(UNIX)
# - Atanas Georgiev <atanas@cs.columbia.edu>
find_path( GTK_glibconfig_INCLUDE_PATH NAMES glibconfig.h
+ PATH_SUFFIXES glib/include lib/glib/include include/glib12
PATHS
/usr/openwin/share/include
- /usr/local/include/glib12
- /usr/lib/glib/include
- /usr/local/lib/glib/include
/opt/gnome/include
/opt/gnome/lib/glib/include
)
find_path( GTK_glib_INCLUDE_PATH NAMES glib.h
- PATH_SUFFIXES gtk-1.2 glib-1.2 glib12
+ PATH_SUFFIXES gtk-1.2 glib-1.2 glib12 glib/include lib/glib/include
PATHS
/usr/openwin/share/include
- /usr/lib/glib/include
/opt/gnome/include
)
@@ -153,6 +151,3 @@ if(UNIX)
)
endif()
-
-
-
diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake
index b87b9f3ab..83091f3d8 100644
--- a/Modules/FindGTK2.cmake
+++ b/Modules/FindGTK2.cmake
@@ -1,102 +1,101 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGTK2
-# --------
-#
-# FindGTK2.cmake
-#
-# This module can find the GTK2 widget libraries and several of its
-# other optional components like gtkmm, glade, and glademm.
-#
-# NOTE: If you intend to use version checking, CMake 2.6.2 or later is
-#
-# ::
-#
-# required.
-#
-#
-#
-# Specify one or more of the following components as you call this find
-# module. See example below.
-#
-# ::
-#
-# gtk
-# gtkmm
-# glade
-# glademm
-#
-#
-#
-# The following variables will be defined for your use
-#
-# ::
-#
-# GTK2_FOUND - Were all of your specified components found?
-# GTK2_INCLUDE_DIRS - All include directories
-# GTK2_LIBRARIES - All libraries
-# GTK2_TARGETS - All imported targets
-# GTK2_DEFINITIONS - Additional compiler flags
-#
-#
-#
-# ::
-#
-# GTK2_VERSION - The version of GTK2 found (x.y.z)
-# GTK2_MAJOR_VERSION - The major version of GTK2
-# GTK2_MINOR_VERSION - The minor version of GTK2
-# GTK2_PATCH_VERSION - The patch version of GTK2
-#
-#
-#
-# Optional variables you can define prior to calling this module:
-#
-# ::
-#
-# GTK2_DEBUG - Enables verbose debugging of the module
-# GTK2_ADDITIONAL_SUFFIXES - Allows defining additional directories to
-# search for include files
-#
-#
-#
-# ================= Example Usage:
-#
-# ::
-#
-# Call find_package() once, here are some examples to pick from:
-#
-#
-#
-# ::
-#
-# Require GTK 2.6 or later
-# find_package(GTK2 2.6 REQUIRED gtk)
-#
-#
-#
-# ::
-#
-# Require GTK 2.10 or later and Glade
-# find_package(GTK2 2.10 REQUIRED gtk glade)
-#
-#
-#
-# ::
-#
-# Search for GTK/GTKMM 2.8 or later
-# find_package(GTK2 2.8 COMPONENTS gtk gtkmm)
-#
-#
-#
-# ::
-#
-# if(GTK2_FOUND)
-# include_directories(${GTK2_INCLUDE_DIRS})
-# add_executable(mygui mygui.cc)
-# target_link_libraries(mygui ${GTK2_LIBRARIES})
-# endif()
+#[=======================================================================[.rst:
+FindGTK2
+--------
+
+Find the GTK2 widget libraries and several of its
+other optional components like ``gtkmm``, ``glade``, and ``glademm``.
+
+NOTE: If you intend to use version checking, CMake 2.6.2 or later is
+
+::
+
+ required.
+
+
+
+Specify one or more of the following components as you call this find
+module. See example below.
+
+::
+
+ gtk
+ gtkmm
+ glade
+ glademm
+
+
+
+The following variables will be defined for your use
+
+::
+
+ GTK2_FOUND - Were all of your specified components found?
+ GTK2_INCLUDE_DIRS - All include directories
+ GTK2_LIBRARIES - All libraries
+ GTK2_TARGETS - All imported targets
+ GTK2_DEFINITIONS - Additional compiler flags
+
+
+
+::
+
+ GTK2_VERSION - The version of GTK2 found (x.y.z)
+ GTK2_MAJOR_VERSION - The major version of GTK2
+ GTK2_MINOR_VERSION - The minor version of GTK2
+ GTK2_PATCH_VERSION - The patch version of GTK2
+
+
+
+Optional variables you can define prior to calling this module:
+
+::
+
+ GTK2_DEBUG - Enables verbose debugging of the module
+ GTK2_ADDITIONAL_SUFFIXES - Allows defining additional directories to
+ search for include files
+
+
+
+================= Example Usage:
+
+::
+
+ Call find_package() once, here are some examples to pick from:
+
+
+
+::
+
+ Require GTK 2.6 or later
+ find_package(GTK2 2.6 REQUIRED gtk)
+
+
+
+::
+
+ Require GTK 2.10 or later and Glade
+ find_package(GTK2 2.10 REQUIRED gtk glade)
+
+
+
+::
+
+ Search for GTK/GTKMM 2.8 or later
+ find_package(GTK2 2.8 COMPONENTS gtk gtkmm)
+
+
+
+::
+
+ if(GTK2_FOUND)
+ include_directories(${GTK2_INCLUDE_DIRS})
+ add_executable(mygui mygui.cc)
+ target_link_libraries(mygui ${GTK2_LIBRARIES})
+ endif()
+#]=======================================================================]
# Version 1.6 (CMake 3.0)
# * Create targets for each library
@@ -260,6 +259,7 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr)
gtkmm-2.4
libglade-2.0
libglademm-2.4
+ harfbuzz
pango-1.0
pangomm-1.4
sigc++-2.0
@@ -298,15 +298,11 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr)
/usr/libx32
/usr/lib64
/usr/lib
- /usr/X11R6/include
- /usr/X11R6/lib
/opt/gnome/include
/opt/gnome/lib
/opt/openwin/include
/usr/openwin/lib
- /sw/include
/sw/lib
- /opt/local/include
/opt/local/lib
/usr/pkg/lib
/usr/pkg/include/glib
@@ -354,13 +350,9 @@ function(_GTK2_FIND_LIBRARY _var _lib _expand_vc _append_version)
if(_expand_vc AND MSVC)
# Add vc80/vc90/vc100 midfixes
- if(MSVC_VERSION EQUAL 1400)
- set(_library ${_library}-vc80)
- elseif(MSVC_VERSION EQUAL 1500)
- set(_library ${_library}-vc90)
- elseif(MSVC_VERSION EQUAL 1600)
- set(_library ${_library}-vc100)
- elseif(MSVC_VERSION EQUAL 1700)
+ if(MSVC_TOOLSET_VERSION LESS 110)
+ set(_library ${_library}-vc${MSVC_TOOLSET_VERSION})
+ else()
# Up to gtkmm-win 2.22.0-2 there are no vc110 libraries but vc100 can be used
set(_library ${_library}-vc100)
endif()
@@ -420,7 +412,6 @@ function(_GTK2_FIND_LIBRARY _var _lib _expand_vc _append_version)
PATHS
/opt/gnome/lib
/usr/openwin/lib
- /sw/lib
$ENV{GTKMM_BASEPATH}/lib
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
@@ -721,6 +712,8 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
_GTK2_FIND_LIBRARY (PANGO pango false true)
_GTK2_ADD_TARGET (PANGO GTK2_DEPENDS gobject glib)
+ _GTK2_FIND_INCLUDE_DIR(HARFBUZZ hb.h)
+
_GTK2_FIND_LIBRARY (PANGOCAIRO pangocairo false true)
_GTK2_ADD_TARGET (PANGOCAIRO GTK2_DEPENDS pango cairo gobject glib)
@@ -957,5 +950,5 @@ else()
endif()
if(GTK2_INCLUDE_DIRS)
- list(REMOVE_DUPLICATES GTK2_INCLUDE_DIRS)
+ list(REMOVE_DUPLICATES GTK2_INCLUDE_DIRS)
endif()
diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake
index c4b4535ff..e015a9840 100644
--- a/Modules/FindGTest.cmake
+++ b/Modules/FindGTest.cmake
@@ -1,81 +1,82 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGTest
-# ---------
-#
-# Locate the Google C++ Testing Framework.
-#
-# Imported targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the following :prop_tgt:`IMPORTED` targets:
-#
-# ``GTest::GTest``
-# The Google Test ``gtest`` library, if found; adds Thread::Thread
-# automatically
-# ``GTest::Main``
-# The Google Test ``gtest_main`` library, if found
-#
-#
-# Result variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module will set the following variables in your project:
-#
-# ``GTEST_FOUND``
-# Found the Google Testing framework
-# ``GTEST_INCLUDE_DIRS``
-# the directory containing the Google Test headers
-#
-# The library variables below are set as normal variables. These
-# contain debug/optimized keywords when a debugging library is found.
-#
-# ``GTEST_LIBRARIES``
-# The Google Test ``gtest`` library; note it also requires linking
-# with an appropriate thread library
-# ``GTEST_MAIN_LIBRARIES``
-# The Google Test ``gtest_main`` library
-# ``GTEST_BOTH_LIBRARIES``
-# Both ``gtest`` and ``gtest_main``
-#
-# Cache variables
-# ^^^^^^^^^^^^^^^
-#
-# The following cache variables may also be set:
-#
-# ``GTEST_ROOT``
-# The root directory of the Google Test installation (may also be
-# set as an environment variable)
-# ``GTEST_MSVC_SEARCH``
-# If compiling with MSVC, this variable can be set to ``MT`` or
-# ``MD`` (the default) to enable searching a GTest build tree
-#
-#
-# Example usage
-# ^^^^^^^^^^^^^
-#
-# ::
-#
-# enable_testing()
-# find_package(GTest REQUIRED)
-#
-# add_executable(foo foo.cc)
-# target_link_libraries(foo GTest::GTest GTest::Main)
-#
-# add_test(AllTestsInFoo foo)
-#
-#
-# Deeper integration with CTest
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# See :module:`GoogleTest` for information on the :command:`gtest_add_tests`
-# command.
+#[=======================================================================[.rst:
+FindGTest
+---------
+
+Locate the Google C++ Testing Framework.
+
+Imported targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` targets:
+
+``GTest::GTest``
+ The Google Test ``gtest`` library, if found; adds Thread::Thread
+ automatically
+``GTest::Main``
+ The Google Test ``gtest_main`` library, if found
+
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``GTEST_FOUND``
+ Found the Google Testing framework
+``GTEST_INCLUDE_DIRS``
+ the directory containing the Google Test headers
+
+The library variables below are set as normal variables. These
+contain debug/optimized keywords when a debugging library is found.
+
+``GTEST_LIBRARIES``
+ The Google Test ``gtest`` library; note it also requires linking
+ with an appropriate thread library
+``GTEST_MAIN_LIBRARIES``
+ The Google Test ``gtest_main`` library
+``GTEST_BOTH_LIBRARIES``
+ Both ``gtest`` and ``gtest_main``
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``GTEST_ROOT``
+ The root directory of the Google Test installation (may also be
+ set as an environment variable)
+``GTEST_MSVC_SEARCH``
+ If compiling with MSVC, this variable can be set to ``MT`` or
+ ``MD`` (the default) to enable searching a GTest build tree
+
+
+Example usage
+^^^^^^^^^^^^^
+
+::
+
+ enable_testing()
+ find_package(GTest REQUIRED)
+
+ add_executable(foo foo.cc)
+ target_link_libraries(foo GTest::GTest GTest::Main)
+
+ add_test(AllTestsInFoo foo)
+
+
+Deeper integration with CTest
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+See :module:`GoogleTest` for information on the :command:`gtest_add_tests`
+and :command:`gtest_discover_tests` commands.
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/GoogleTest.cmake)
-function(_gtest_append_debugs _endvar _library)
+function(__gtest_append_debugs _endvar _library)
if(${_library} AND ${_library}_DEBUG)
set(_output optimized ${${_library}} debug ${${_library}_DEBUG})
else()
@@ -84,7 +85,7 @@ function(_gtest_append_debugs _endvar _library)
set(${_endvar} ${_output} PARENT_SCOPE)
endfunction()
-function(_gtest_find_library _name)
+function(__gtest_find_library _name)
find_library(${_name}
NAMES ${ARGN}
HINTS
@@ -95,6 +96,56 @@ function(_gtest_find_library _name)
mark_as_advanced(${_name})
endfunction()
+macro(__gtest_determine_windows_library_type _var)
+ if(EXISTS "${${_var}}")
+ file(TO_NATIVE_PATH "${${_var}}" _lib_path)
+ get_filename_component(_name "${${_var}}" NAME_WE)
+ file(STRINGS "${${_var}}" _match REGEX "${_name}\\.dll" LIMIT_COUNT 1)
+ if(NOT _match STREQUAL "")
+ set(${_var}_TYPE SHARED PARENT_SCOPE)
+ else()
+ set(${_var}_TYPE UNKNOWN PARENT_SCOPE)
+ endif()
+ return()
+ endif()
+endmacro()
+
+function(__gtest_determine_library_type _var)
+ if(WIN32)
+ # For now, at least, only Windows really needs to know the library type
+ __gtest_determine_windows_library_type(${_var})
+ __gtest_determine_windows_library_type(${_var}_RELEASE)
+ __gtest_determine_windows_library_type(${_var}_DEBUG)
+ endif()
+ # If we get here, no determination was made from the above checks
+ set(${_var}_TYPE UNKNOWN PARENT_SCOPE)
+endfunction()
+
+function(__gtest_import_library _target _var _config)
+ if(_config)
+ set(_config_suffix "_${_config}")
+ else()
+ set(_config_suffix "")
+ endif()
+
+ set(_lib "${${_var}${_config_suffix}}")
+ if(EXISTS "${_lib}")
+ if(_config)
+ set_property(TARGET ${_target} APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS ${_config})
+ endif()
+ set_target_properties(${_target} PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES${_config_suffix} "CXX")
+ if(WIN32 AND ${_var}_TYPE STREQUAL SHARED)
+ set_target_properties(${_target} PROPERTIES
+ IMPORTED_IMPLIB${_config_suffix} "${_lib}")
+ else()
+ set_target_properties(${_target} PROPERTIES
+ IMPORTED_LOCATION${_config_suffix} "${_lib}")
+ endif()
+ endif()
+endfunction()
+
#
if(NOT DEFINED GTEST_MSVC_SEARCH)
@@ -109,6 +160,10 @@ if(MSVC)
msvc/gtest-md/Release
msvc/x64/Debug
msvc/x64/Release
+ msvc/2010/gtest-md/Win32-Debug
+ msvc/2010/gtest-md/Win32-Release
+ msvc/2010/gtest-md/x64-Debug
+ msvc/2010/gtest-md/x64-Release
)
elseif(GTEST_MSVC_SEARCH STREQUAL "MT")
list(APPEND _gtest_libpath_suffixes
@@ -116,6 +171,10 @@ if(MSVC)
msvc/gtest/Release
msvc/x64/Debug
msvc/x64/Release
+ msvc/2010/gtest/Win32-Debug
+ msvc/2010/gtest/Win32-Release
+ msvc/2010/gtest/x64-Debug
+ msvc/2010/gtest/x64-Release
)
endif()
endif()
@@ -131,15 +190,15 @@ mark_as_advanced(GTEST_INCLUDE_DIR)
if(MSVC AND GTEST_MSVC_SEARCH STREQUAL "MD")
# The provided /MD project files for Google Test add -md suffixes to the
# library names.
- _gtest_find_library(GTEST_LIBRARY gtest-md gtest)
- _gtest_find_library(GTEST_LIBRARY_DEBUG gtest-mdd gtestd)
- _gtest_find_library(GTEST_MAIN_LIBRARY gtest_main-md gtest_main)
- _gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_main-mdd gtest_maind)
+ __gtest_find_library(GTEST_LIBRARY gtest-md gtest)
+ __gtest_find_library(GTEST_LIBRARY_DEBUG gtest-mdd gtestd)
+ __gtest_find_library(GTEST_MAIN_LIBRARY gtest_main-md gtest_main)
+ __gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_main-mdd gtest_maind)
else()
- _gtest_find_library(GTEST_LIBRARY gtest)
- _gtest_find_library(GTEST_LIBRARY_DEBUG gtestd)
- _gtest_find_library(GTEST_MAIN_LIBRARY gtest_main)
- _gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_maind)
+ __gtest_find_library(GTEST_LIBRARY gtest)
+ __gtest_find_library(GTEST_LIBRARY_DEBUG gtestd)
+ __gtest_find_library(GTEST_MAIN_LIBRARY gtest_main)
+ __gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_maind)
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
@@ -147,63 +206,38 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTest DEFAULT_MSG GTEST_LIBRARY GTEST_INCLUDE_
if(GTEST_FOUND)
set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIR})
- _gtest_append_debugs(GTEST_LIBRARIES GTEST_LIBRARY)
- _gtest_append_debugs(GTEST_MAIN_LIBRARIES GTEST_MAIN_LIBRARY)
+ __gtest_append_debugs(GTEST_LIBRARIES GTEST_LIBRARY)
+ __gtest_append_debugs(GTEST_MAIN_LIBRARIES GTEST_MAIN_LIBRARY)
set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
- include(CMakeFindDependencyMacro)
- find_dependency(Threads)
+ find_package(Threads QUIET)
if(NOT TARGET GTest::GTest)
- add_library(GTest::GTest UNKNOWN IMPORTED)
- set_target_properties(GTest::GTest PROPERTIES
- INTERFACE_LINK_LIBRARIES "Threads::Threads")
- if(GTEST_INCLUDE_DIRS)
- set_target_properties(GTest::GTest PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIRS}")
- endif()
- if(EXISTS "${GTEST_LIBRARY}")
+ __gtest_determine_library_type(GTEST_LIBRARY)
+ add_library(GTest::GTest ${GTEST_LIBRARY_TYPE} IMPORTED)
+ if(TARGET Threads::Threads)
set_target_properties(GTest::GTest PROPERTIES
- IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
- IMPORTED_LOCATION "${GTEST_LIBRARY}")
+ INTERFACE_LINK_LIBRARIES Threads::Threads)
endif()
- if(EXISTS "${GTEST_LIBRARY_RELEASE}")
- set_property(TARGET GTest::GTest APPEND PROPERTY
- IMPORTED_CONFIGURATIONS RELEASE)
+ if(GTEST_LIBRARY_TYPE STREQUAL "SHARED")
set_target_properties(GTest::GTest PROPERTIES
- IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
- IMPORTED_LOCATION_RELEASE "${GTEST_LIBRARY_RELEASE}")
+ INTERFACE_COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1")
endif()
- if(EXISTS "${GTEST_LIBRARY_DEBUG}")
- set_property(TARGET GTest::GTest APPEND PROPERTY
- IMPORTED_CONFIGURATIONS DEBUG)
+ if(GTEST_INCLUDE_DIRS)
set_target_properties(GTest::GTest PROPERTIES
- IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
- IMPORTED_LOCATION_DEBUG "${GTEST_LIBRARY_DEBUG}")
+ INTERFACE_INCLUDE_DIRECTORIES "${GTEST_INCLUDE_DIRS}")
endif()
- endif()
- if(NOT TARGET GTest::Main)
- add_library(GTest::Main UNKNOWN IMPORTED)
- set_target_properties(GTest::Main PROPERTIES
- INTERFACE_LINK_LIBRARIES "GTest::GTest")
- if(EXISTS "${GTEST_MAIN_LIBRARY}")
- set_target_properties(GTest::Main PROPERTIES
- IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
- IMPORTED_LOCATION "${GTEST_MAIN_LIBRARY}")
- endif()
- if(EXISTS "${GTEST_MAIN_LIBRARY_RELEASE}")
- set_property(TARGET GTest::Main APPEND PROPERTY
- IMPORTED_CONFIGURATIONS RELEASE)
- set_target_properties(GTest::Main PROPERTIES
- IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX"
- IMPORTED_LOCATION_RELEASE "${GTEST_MAIN_LIBRARY_RELEASE}")
- endif()
- if(EXISTS "${GTEST_MAIN_LIBRARY_DEBUG}")
- set_property(TARGET GTest::Main APPEND PROPERTY
- IMPORTED_CONFIGURATIONS DEBUG)
- set_target_properties(GTest::Main PROPERTIES
- IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
- IMPORTED_LOCATION_DEBUG "${GTEST_MAIN_LIBRARY_DEBUG}")
- endif()
+ __gtest_import_library(GTest::GTest GTEST_LIBRARY "")
+ __gtest_import_library(GTest::GTest GTEST_LIBRARY "RELEASE")
+ __gtest_import_library(GTest::GTest GTEST_LIBRARY "DEBUG")
+ endif()
+ if(NOT TARGET GTest::Main)
+ __gtest_determine_library_type(GTEST_MAIN_LIBRARY)
+ add_library(GTest::Main ${GTEST_MAIN_LIBRARY_TYPE} IMPORTED)
+ set_target_properties(GTest::Main PROPERTIES
+ INTERFACE_LINK_LIBRARIES "GTest::GTest")
+ __gtest_import_library(GTest::Main GTEST_MAIN_LIBRARY "")
+ __gtest_import_library(GTest::Main GTEST_MAIN_LIBRARY "RELEASE")
+ __gtest_import_library(GTest::Main GTEST_MAIN_LIBRARY "DEBUG")
endif()
endif()
diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake
index 803550715..213ad13de 100644
--- a/Modules/FindGettext.cmake
+++ b/Modules/FindGettext.cmake
@@ -1,75 +1,80 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGettext
-# -----------
-#
-# Find GNU gettext tools
-#
-# This module looks for the GNU gettext tools. This module defines the
-# following values:
-#
-# ::
-#
-# GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool.
-# GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool.
-# GETTEXT_FOUND: True if gettext has been found.
-# GETTEXT_VERSION_STRING: the version of gettext found (since CMake 2.8.8)
-#
-#
-#
-# Additionally it provides the following macros:
-#
-# GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN )
-#
-# ::
-#
-# This will create a target "translations" which will convert the
-# given input po files into the binary output mo file. If the
-# ALL option is used, the translations will also be created when
-# building the default target.
-#
-# GETTEXT_PROCESS_POT_FILE( <potfile> [ALL] [INSTALL_DESTINATION <destdir>]
-# LANGUAGES <lang1> <lang2> ... )
-#
-# ::
-#
-# Process the given pot file to mo files.
-# If INSTALL_DESTINATION is given then automatically install rules will
-# be created, the language subdirectory will be taken into account
-# (by default use share/locale/).
-# If ALL is specified, the pot file is processed when building the all traget.
-# It creates a custom target "potfile".
-#
-# GETTEXT_PROCESS_PO_FILES( <lang> [ALL] [INSTALL_DESTINATION <dir>]
-# PO_FILES <po1> <po2> ... )
-#
-# ::
-#
-# Process the given po files to mo files for the given language.
-# If INSTALL_DESTINATION is given then automatically install rules will
-# be created, the language subdirectory will be taken into account
-# (by default use share/locale/).
-# If ALL is specified, the po files are processed when building the all traget.
-# It creates a custom target "pofiles".
-#
-# .. note::
-# If you wish to use the Gettext library (libintl), use :module:`FindIntl`.
+#[=======================================================================[.rst:
+FindGettext
+-----------
+
+Find GNU gettext tools
+
+This module looks for the GNU gettext tools. This module defines the
+following values:
+
+::
+
+ GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool.
+ GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool.
+ GETTEXT_FOUND: True if gettext has been found.
+ GETTEXT_VERSION_STRING: the version of gettext found (since CMake 2.8.8)
+
+
+
+Additionally it provides the following macros:
+
+GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN )
+
+::
+
+ This will create a target "translations" which will convert the
+ given input po files into the binary output mo file. If the
+ ALL option is used, the translations will also be created when
+ building the default target.
+
+GETTEXT_PROCESS_POT_FILE( <potfile> [ALL] [INSTALL_DESTINATION <destdir>]
+LANGUAGES <lang1> <lang2> ... )
+
+::
+
+ Process the given pot file to mo files.
+ If INSTALL_DESTINATION is given then automatically install rules will
+ be created, the language subdirectory will be taken into account
+ (by default use share/locale/).
+ If ALL is specified, the pot file is processed when building the all traget.
+ It creates a custom target "potfile".
+
+GETTEXT_PROCESS_PO_FILES( <lang> [ALL] [INSTALL_DESTINATION <dir>]
+PO_FILES <po1> <po2> ... )
+
+::
+
+ Process the given po files to mo files for the given language.
+ If INSTALL_DESTINATION is given then automatically install rules will
+ be created, the language subdirectory will be taken into account
+ (by default use share/locale/).
+ If ALL is specified, the po files are processed when building the all traget.
+ It creates a custom target "pofiles".
+
+.. note::
+ If you wish to use the Gettext library (libintl), use :module:`FindIntl`.
+#]=======================================================================]
find_program(GETTEXT_MSGMERGE_EXECUTABLE msgmerge)
find_program(GETTEXT_MSGFMT_EXECUTABLE msgfmt)
if(GETTEXT_MSGMERGE_EXECUTABLE)
- execute_process(COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --version
+ execute_process(COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --version
OUTPUT_VARIABLE gettext_version
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (gettext_version MATCHES "^msgmerge \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
- set(GETTEXT_VERSION_STRING "${CMAKE_MATCH_1}")
- endif()
- unset(gettext_version)
+ get_filename_component(msgmerge_name ${GETTEXT_MSGMERGE_EXECUTABLE} NAME)
+ get_filename_component(msgmerge_namewe ${GETTEXT_MSGMERGE_EXECUTABLE} NAME_WE)
+ if (gettext_version MATCHES "^(${msgmerge_name}|${msgmerge_namewe}) \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
+ set(GETTEXT_VERSION_STRING "${CMAKE_MATCH_2}")
+ endif()
+ unset(gettext_version)
+ unset(msgmerge_name)
+ unset(msgmerge_namewe)
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
@@ -78,150 +83,150 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext
VERSION_VAR GETTEXT_VERSION_STRING)
function(_GETTEXT_GET_UNIQUE_TARGET_NAME _name _unique_name)
- set(propertyName "_GETTEXT_UNIQUE_COUNTER_${_name}")
- get_property(currentCounter GLOBAL PROPERTY "${propertyName}")
- if(NOT currentCounter)
- set(currentCounter 1)
- endif()
- set(${_unique_name} "${_name}_${currentCounter}" PARENT_SCOPE)
- math(EXPR currentCounter "${currentCounter} + 1")
- set_property(GLOBAL PROPERTY ${propertyName} ${currentCounter} )
+ set(propertyName "_GETTEXT_UNIQUE_COUNTER_${_name}")
+ get_property(currentCounter GLOBAL PROPERTY "${propertyName}")
+ if(NOT currentCounter)
+ set(currentCounter 1)
+ endif()
+ set(${_unique_name} "${_name}_${currentCounter}" PARENT_SCOPE)
+ math(EXPR currentCounter "${currentCounter} + 1")
+ set_property(GLOBAL PROPERTY ${propertyName} ${currentCounter} )
endfunction()
macro(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg)
- # make it a real variable, so we can modify it here
- set(_firstPoFile "${_firstPoFileArg}")
-
- set(_gmoFiles)
- get_filename_component(_potName ${_potFile} NAME)
- string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
- get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
-
- set(_addToAll)
- if(${_firstPoFile} STREQUAL "ALL")
- set(_addToAll "ALL")
- set(_firstPoFile)
- endif()
-
- foreach (_currentPoFile ${_firstPoFile} ${ARGN})
- get_filename_component(_absFile ${_currentPoFile} ABSOLUTE)
- get_filename_component(_abs_PATH ${_absFile} PATH)
- get_filename_component(_lang ${_absFile} NAME_WE)
- set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
-
- add_custom_command(
- OUTPUT ${_gmoFile}
- COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
- COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
- DEPENDS ${_absPotFile} ${_absFile}
- )
-
- install(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
- set(_gmoFiles ${_gmoFiles} ${_gmoFile})
-
- endforeach ()
-
- if(NOT TARGET translations)
- add_custom_target(translations)
- endif()
+ # make it a real variable, so we can modify it here
+ set(_firstPoFile "${_firstPoFileArg}")
+
+ set(_gmoFiles)
+ get_filename_component(_potName ${_potFile} NAME)
+ string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
+ get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
+
+ set(_addToAll)
+ if(${_firstPoFile} STREQUAL "ALL")
+ set(_addToAll "ALL")
+ set(_firstPoFile)
+ endif()
+
+ foreach (_currentPoFile ${_firstPoFile} ${ARGN})
+ get_filename_component(_absFile ${_currentPoFile} ABSOLUTE)
+ get_filename_component(_abs_PATH ${_absFile} PATH)
+ get_filename_component(_lang ${_absFile} NAME_WE)
+ set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
+
+ add_custom_command(
+ OUTPUT ${_gmoFile}
+ COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile}
+ COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile}
+ DEPENDS ${_absPotFile} ${_absFile}
+ )
+
+ install(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
+ set(_gmoFiles ${_gmoFiles} ${_gmoFile})
+
+ endforeach ()
+
+ if(NOT TARGET translations)
+ add_custom_target(translations)
+ endif()
_GETTEXT_GET_UNIQUE_TARGET_NAME(translations uniqueTargetName)
- add_custom_target(${uniqueTargetName} ${_addToAll} DEPENDS ${_gmoFiles})
+ add_custom_target(${uniqueTargetName} ${_addToAll} DEPENDS ${_gmoFiles})
- add_dependencies(translations ${uniqueTargetName})
+ add_dependencies(translations ${uniqueTargetName})
endmacro()
function(GETTEXT_PROCESS_POT_FILE _potFile)
- set(_gmoFiles)
- set(_options ALL)
- set(_oneValueArgs INSTALL_DESTINATION)
- set(_multiValueArgs LANGUAGES)
-
- CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
-
- get_filename_component(_potName ${_potFile} NAME)
- string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
- get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
-
- foreach (_lang ${_parsedArguments_LANGUAGES})
- set(_poFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.po")
- set(_gmoFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo")
-
- add_custom_command(
- OUTPUT "${_poFile}"
- COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_poFile} ${_absPotFile}
- DEPENDS ${_absPotFile}
- )
-
- add_custom_command(
- OUTPUT "${_gmoFile}"
- COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_poFile}
- DEPENDS ${_absPotFile} ${_poFile}
- )
-
- if(_parsedArguments_INSTALL_DESTINATION)
- install(FILES ${_gmoFile} DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
- endif()
- list(APPEND _gmoFiles ${_gmoFile})
- endforeach ()
+ set(_gmoFiles)
+ set(_options ALL)
+ set(_oneValueArgs INSTALL_DESTINATION)
+ set(_multiValueArgs LANGUAGES)
+
+ CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
+
+ get_filename_component(_potName ${_potFile} NAME)
+ string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName})
+ get_filename_component(_absPotFile ${_potFile} ABSOLUTE)
+
+ foreach (_lang ${_parsedArguments_LANGUAGES})
+ set(_poFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.po")
+ set(_gmoFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo")
+
+ add_custom_command(
+ OUTPUT "${_poFile}"
+ COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_poFile} ${_absPotFile}
+ DEPENDS ${_absPotFile}
+ )
+
+ add_custom_command(
+ OUTPUT "${_gmoFile}"
+ COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_poFile}
+ DEPENDS ${_absPotFile} ${_poFile}
+ )
+
+ if(_parsedArguments_INSTALL_DESTINATION)
+ install(FILES ${_gmoFile} DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
+ endif()
+ list(APPEND _gmoFiles ${_gmoFile})
+ endforeach ()
if(NOT TARGET potfiles)
- add_custom_target(potfiles)
+ add_custom_target(potfiles)
endif()
_GETTEXT_GET_UNIQUE_TARGET_NAME( potfiles uniqueTargetName)
- if(_parsedArguments_ALL)
- add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
- else()
- add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
- endif()
+ if(_parsedArguments_ALL)
+ add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
+ else()
+ add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
+ endif()
- add_dependencies(potfiles ${uniqueTargetName})
+ add_dependencies(potfiles ${uniqueTargetName})
endfunction()
function(GETTEXT_PROCESS_PO_FILES _lang)
- set(_options ALL)
- set(_oneValueArgs INSTALL_DESTINATION)
- set(_multiValueArgs PO_FILES)
- set(_gmoFiles)
-
- CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
-
- foreach(_current_PO_FILE ${_parsedArguments_PO_FILES})
- get_filename_component(_name ${_current_PO_FILE} NAME)
- string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name})
- set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo)
- add_custom_command(OUTPUT ${_gmoFile}
- COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- DEPENDS ${_current_PO_FILE}
- )
-
- if(_parsedArguments_INSTALL_DESTINATION)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/ RENAME ${_basename}.mo)
- endif()
- list(APPEND _gmoFiles ${_gmoFile})
- endforeach()
+ set(_options ALL)
+ set(_oneValueArgs INSTALL_DESTINATION)
+ set(_multiValueArgs PO_FILES)
+ set(_gmoFiles)
+
+ CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})
+
+ foreach(_current_PO_FILE ${_parsedArguments_PO_FILES})
+ get_filename_component(_name ${_current_PO_FILE} NAME)
+ string(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name})
+ set(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo)
+ add_custom_command(OUTPUT ${_gmoFile}
+ COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ DEPENDS ${_current_PO_FILE}
+ )
+
+ if(_parsedArguments_INSTALL_DESTINATION)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/ RENAME ${_basename}.mo)
+ endif()
+ list(APPEND _gmoFiles ${_gmoFile})
+ endforeach()
if(NOT TARGET pofiles)
- add_custom_target(pofiles)
+ add_custom_target(pofiles)
endif()
_GETTEXT_GET_UNIQUE_TARGET_NAME( pofiles uniqueTargetName)
- if(_parsedArguments_ALL)
- add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
- else()
- add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
- endif()
+ if(_parsedArguments_ALL)
+ add_custom_target(${uniqueTargetName} ALL DEPENDS ${_gmoFiles})
+ else()
+ add_custom_target(${uniqueTargetName} DEPENDS ${_gmoFiles})
+ endif()
- add_dependencies(pofiles ${uniqueTargetName})
+ add_dependencies(pofiles ${uniqueTargetName})
endfunction()
diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake
index fae31eb83..3491cdcc2 100644
--- a/Modules/FindGit.cmake
+++ b/Modules/FindGit.cmake
@@ -1,27 +1,34 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGit
-# -------
-#
-# The module defines the following variables:
-#
-# ``GIT_EXECUTABLE``
-# Path to Git command-line client.
-# ``Git_FOUND``, ``GIT_FOUND``
-# True if the Git command-line client was found.
-# ``GIT_VERSION_STRING``
-# The version of Git found.
-#
-# Example usage:
-#
-# .. code-block:: cmake
-#
-# find_package(Git)
-# if(Git_FOUND)
-# message("Git found: ${GIT_EXECUTABLE}")
-# endif()
+#[=======================================================================[.rst:
+FindGit
+-------
+
+The module defines the following ``IMPORTED`` targets (when
+:prop_gbl:`CMAKE_ROLE` is ``PROJECT``):
+
+``Git::Git``
+ Executable of the Git command-line client.
+
+The module defines the following variables:
+
+``GIT_EXECUTABLE``
+ Path to Git command-line client.
+``Git_FOUND``, ``GIT_FOUND``
+ True if the Git command-line client was found.
+``GIT_VERSION_STRING``
+ The version of Git found.
+
+Example usage:
+
+.. code-block:: cmake
+
+ find_package(Git)
+ if(Git_FOUND)
+ message("Git found: ${GIT_EXECUTABLE}")
+ endif()
+#]=======================================================================]
# Look for 'git' or 'eg' (easy git)
#
@@ -77,6 +84,12 @@ if(GIT_EXECUTABLE)
string(REPLACE "git version " "" GIT_VERSION_STRING "${git_version}")
endif()
unset(git_version)
+
+ get_property(_findgit_role GLOBAL PROPERTY CMAKE_ROLE)
+ if(_findgit_role STREQUAL "PROJECT" AND NOT TARGET Git::Git)
+ add_executable(Git::Git IMPORTED)
+ set_property(TARGET Git::Git PROPERTY IMPORTED_LOCATION "${GIT_EXECUTABLE}")
+ endif()
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
diff --git a/Modules/FindGnuTLS.cmake b/Modules/FindGnuTLS.cmake
index 1a97d99ea..819f00012 100644
--- a/Modules/FindGnuTLS.cmake
+++ b/Modules/FindGnuTLS.cmake
@@ -1,52 +1,64 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGnuTLS
-# ----------
-#
-# Try to find the GNU Transport Layer Security library (gnutls)
-#
-#
-#
-# Once done this will define
-#
-# ::
-#
-# GNUTLS_FOUND - System has gnutls
-# GNUTLS_INCLUDE_DIR - The gnutls include directory
-# GNUTLS_LIBRARIES - The libraries needed to use gnutls
-# GNUTLS_DEFINITIONS - Compiler switches required for using gnutls
+#[=======================================================================[.rst:
+FindGnuTLS
+----------
+
+Find the GNU Transport Layer Security library (gnutls)
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``GnuTLS::GnuTLS``, if
+gnutls has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+``GNUTLS_FOUND``
+ System has gnutls
+``GNUTLS_INCLUDE_DIR``
+ The gnutls include directory
+``GNUTLS_LIBRARIES``
+ The libraries needed to use gnutls
+``GNUTLS_DEFINITIONS``
+ Compiler switches required for using gnutls
+``GNUTLS_VERSION``
+ version of gnutls.
+#]=======================================================================]
# Note that this doesn't try to find the gnutls-extra package.
if (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARY)
- # in cache already
- set(gnutls_FIND_QUIETLY TRUE)
+ # in cache already
+ set(gnutls_FIND_QUIETLY TRUE)
endif ()
if (NOT WIN32)
- # try using pkg-config to get the directories and then use these values
- # in the find_path() and find_library() calls
- # also fills in GNUTLS_DEFINITIONS, although that isn't normally useful
- find_package(PkgConfig QUIET)
- PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls)
- set(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER})
- set(GNUTLS_VERSION_STRING ${PC_GNUTLS_VERSION})
+ # try using pkg-config to get the directories and then use these values
+ # in the find_path() and find_library() calls
+ # also fills in GNUTLS_DEFINITIONS, although that isn't normally useful
+ find_package(PkgConfig QUIET)
+ PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls)
+ set(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER})
+ set(GNUTLS_VERSION ${PC_GNUTLS_VERSION})
+ # keep for backward compatibility
+ set(GNUTLS_VERSION_STRING ${PC_GNUTLS_VERSION})
endif ()
find_path(GNUTLS_INCLUDE_DIR gnutls/gnutls.h
- HINTS
- ${PC_GNUTLS_INCLUDEDIR}
- ${PC_GNUTLS_INCLUDE_DIRS}
- )
+ HINTS
+ ${PC_GNUTLS_INCLUDEDIR}
+ ${PC_GNUTLS_INCLUDE_DIRS}
+ )
find_library(GNUTLS_LIBRARY NAMES gnutls libgnutls
- HINTS
- ${PC_GNUTLS_LIBDIR}
- ${PC_GNUTLS_LIBRARY_DIRS}
- )
+ HINTS
+ ${PC_GNUTLS_LIBDIR}
+ ${PC_GNUTLS_LIBRARY_DIRS}
+ )
mark_as_advanced(GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY)
@@ -56,6 +68,15 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS
VERSION_VAR GNUTLS_VERSION_STRING)
if(GNUTLS_FOUND)
- set(GNUTLS_LIBRARIES ${GNUTLS_LIBRARY})
- set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR})
+ set(GNUTLS_LIBRARIES ${GNUTLS_LIBRARY})
+ set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR})
+
+ if(NOT TARGET GnuTLS::GnuTLS)
+ add_library(GnuTLS::GnuTLS UNKNOWN IMPORTED)
+ set_target_properties(GnuTLS::GnuTLS PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${GNUTLS_INCLUDE_DIRS}"
+ INTERFACE_COMPILE_DEFINITIONS "${GNUTLS_DEFINITIONS}"
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${GNUTLS_LIBRARIES}")
+ endif()
endif()
diff --git a/Modules/FindGnuplot.cmake b/Modules/FindGnuplot.cmake
index aa4cd6c26..ca2467d68 100644
--- a/Modules/FindGnuplot.cmake
+++ b/Modules/FindGnuplot.cmake
@@ -1,25 +1,26 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindGnuplot
-# -----------
-#
-# this module looks for gnuplot
-#
-#
-#
-# Once done this will define
-#
-# ::
-#
-# GNUPLOT_FOUND - system has Gnuplot
-# GNUPLOT_EXECUTABLE - the Gnuplot executable
-# GNUPLOT_VERSION_STRING - the version of Gnuplot found (since CMake 2.8.8)
-#
-#
-#
-# GNUPLOT_VERSION_STRING will not work for old versions like 3.7.1.
+#[=======================================================================[.rst:
+FindGnuplot
+-----------
+
+this module looks for gnuplot
+
+
+
+Once done this will define
+
+::
+
+ GNUPLOT_FOUND - system has Gnuplot
+ GNUPLOT_EXECUTABLE - the Gnuplot executable
+ GNUPLOT_VERSION_STRING - the version of Gnuplot found (since CMake 2.8.8)
+
+
+
+GNUPLOT_VERSION_STRING will not work for old versions like 3.7.1.
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake)
diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake
index 5962c5bd4..b4884185d 100644
--- a/Modules/FindHDF5.cmake
+++ b/Modules/FindHDF5.cmake
@@ -1,109 +1,131 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindHDF5
-# --------
-#
-# Find HDF5, a library for reading and writing self describing array data.
-#
-#
-#
-# This module invokes the HDF5 wrapper compiler that should be installed
-# alongside HDF5. Depending upon the HDF5 Configuration, the wrapper
-# compiler is called either h5cc or h5pcc. If this succeeds, the module
-# will then call the compiler with the -show argument to see what flags
-# are used when compiling an HDF5 client application.
-#
-# The module will optionally accept the COMPONENTS argument. If no
-# COMPONENTS are specified, then the find module will default to finding
-# only the HDF5 C library. If one or more COMPONENTS are specified, the
-# module will attempt to find the language bindings for the specified
-# components. The only valid components are C, CXX, Fortran, HL, and
-# Fortran_HL. If the COMPONENTS argument is not given, the module will
-# attempt to find only the C bindings.
-#
-# On UNIX systems, this module will read the variable
-# HDF5_USE_STATIC_LIBRARIES to determine whether or not to prefer a
-# static link to a dynamic link for HDF5 and all of it's dependencies.
-# To use this feature, make sure that the HDF5_USE_STATIC_LIBRARIES
-# variable is set before the call to find_package.
-#
-# To provide the module with a hint about where to find your HDF5
-# installation, you can set the environment variable HDF5_ROOT. The
-# Find module will then look in this path when searching for HDF5
-# executables, paths, and libraries.
-#
-# Both the serial and parallel HDF5 wrappers are considered and the first
-# directory to contain either one will be used. In the event that both appear
-# in the same directory the serial version is preferentially selected. This
-# behavior can be reversed by setting the variable HDF5_PREFER_PARALLEL to
-# true.
-#
-# In addition to finding the includes and libraries required to compile
-# an HDF5 client application, this module also makes an effort to find
-# tools that come with the HDF5 distribution that may be useful for
-# regression testing.
-#
-# This module will define the following variables:
-#
-# ::
-#
-# HDF5_FOUND - true if HDF5 was found on the system
-# HDF5_VERSION - HDF5 version in format Major.Minor.Release
-# HDF5_INCLUDE_DIRS - Location of the hdf5 includes
-# HDF5_INCLUDE_DIR - Location of the hdf5 includes (deprecated)
-# HDF5_DEFINITIONS - Required compiler definitions for HDF5
-# HDF5_LIBRARIES - Required libraries for all requested bindings
-# HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API for all
-# bindings, if the HL component is enabled
-#
-# Available components are: C CXX Fortran and HL. For each enabled language
-# binding, a corresponding HDF5_${LANG}_LIBRARIES variable, and potentially
-# HDF5_${LANG}_DEFINITIONS, will be defined.
-# If the HL component is enabled, then an HDF5_${LANG}_HL_LIBRARIES will
-# also be defined. With all components enabled, the following variables will be defined:
-#
-# ::
-#
-# HDF5_C_DEFINITIONS -- Required compiler definitions for HDF5 C bindings
-# HDF5_CXX_DEFINITIONS -- Required compiler definitions for HDF5 C++ bindings
-# HDF5_Fortran_DEFINITIONS -- Required compiler definitions for HDF5 Fortran bindings
-# HDF5_C_INCLUDE_DIRS -- Required include directories for HDF5 C bindings
-# HDF5_CXX_INCLUDE_DIRS -- Required include directories for HDF5 C++ bindings
-# HDF5_Fortran_INCLUDE_DIRS -- Required include directories for HDF5 Fortran bindings
-# HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings
-# HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings
-# HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings
-# HDF5_C_HL_LIBRARIES - Required libraries for the high level C bindings
-# HDF5_CXX_HL_LIBRARIES - Required libraries for the high level C++ bindings
-# HDF5_Fortran_HL_LIBRARIES - Required libraries for the high level Fortran
-# bindings.
-#
-# HDF5_IS_PARALLEL - Whether or not HDF5 was found with parallel IO support
-# HDF5_C_COMPILER_EXECUTABLE - the path to the HDF5 C wrapper compiler
-# HDF5_CXX_COMPILER_EXECUTABLE - the path to the HDF5 C++ wrapper compiler
-# HDF5_Fortran_COMPILER_EXECUTABLE - the path to the HDF5 Fortran wrapper compiler
-# HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C compiler
-# which is also the HDF5 wrapper
-# HDF5_CXX_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary C++
-# compiler which is also
-# the HDF5 wrapper
-# HDF5_Fortran_COMPILER_EXECUTABLE_NO_INTERROGATE - path to the primary
-# Fortran compiler which
-# is also the HDF5 wrapper
-# HDF5_DIFF_EXECUTABLE - the path to the HDF5 dataset comparison tool
-#
-# The following variable can be set to guide the search for HDF5 libraries and includes:
-#
-# ``HDF5_ROOT``
-# Specify the path to the HDF5 installation to use.
-#
-# ``HDF5_FIND_DEBUG``
-# Set to a true value to get some extra debugging output.
-#
-# ``HDF5_NO_FIND_PACKAGE_CONFIG_FILE``
-# Set to a true value to skip trying to find ``hdf5-config.cmake``.
+#[=======================================================================[.rst:
+FindHDF5
+--------
+
+Find Hierarchical Data Format (HDF5), a library for reading and writing
+self describing array data.
+
+
+This module invokes the ``HDF5`` wrapper compiler that should be installed
+alongside ``HDF5``. Depending upon the ``HDF5`` Configuration, the wrapper
+compiler is called either ``h5cc`` or ``h5pcc``. If this succeeds, the module
+will then call the compiler with the show argument to see what flags
+are used when compiling an ``HDF5`` client application.
+
+The module will optionally accept the ``COMPONENTS`` argument. If no
+``COMPONENTS`` are specified, then the find module will default to finding
+only the ``HDF5`` C library. If one or more ``COMPONENTS`` are specified, the
+module will attempt to find the language bindings for the specified
+components. The only valid components are ``C``, ``CXX``, ``Fortran``, ``HL``,
+and ``Fortran_HL``. If the ``COMPONENTS`` argument is not given, the module will
+attempt to find only the C bindings.
+
+This module will read the variable
+``HDF5_USE_STATIC_LIBRARIES`` to determine whether or not to prefer a
+static link to a dynamic link for ``HDF5`` and all of it's dependencies.
+To use this feature, make sure that the ``HDF5_USE_STATIC_LIBRARIES``
+variable is set before the call to find_package.
+
+To provide the module with a hint about where to find your ``HDF5``
+installation, you can set the environment variable ``HDF5_ROOT``. The
+Find module will then look in this path when searching for ``HDF5``
+executables, paths, and libraries.
+
+Both the serial and parallel ``HDF5`` wrappers are considered and the first
+directory to contain either one will be used. In the event that both appear
+in the same directory the serial version is preferentially selected. This
+behavior can be reversed by setting the variable ``HDF5_PREFER_PARALLEL`` to
+``True``.
+
+In addition to finding the includes and libraries required to compile
+an ``HDF5`` client application, this module also makes an effort to find
+tools that come with the ``HDF5`` distribution that may be useful for
+regression testing.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``HDF5_FOUND``
+ HDF5 was found on the system
+``HDF5_VERSION``
+ HDF5 library version
+``HDF5_INCLUDE_DIRS``
+ Location of the HDF5 header files
+``HDF5_DEFINITIONS``
+ Required compiler definitions for HDF5
+``HDF5_LIBRARIES``
+ Required libraries for all requested bindings
+``HDF5_HL_LIBRARIES``
+ Required libraries for the HDF5 high level API for all bindings,
+ if the ``HL`` component is enabled
+
+Available components are: ``C`` ``CXX`` ``Fortran`` and ``HL``.
+For each enabled language binding, a corresponding ``HDF5_${LANG}_LIBRARIES``
+variable, and potentially ``HDF5_${LANG}_DEFINITIONS``, will be defined.
+If the ``HL`` component is enabled, then an ``HDF5_${LANG}_HL_LIBRARIES`` will
+also be defined. With all components enabled, the following variables will be defined:
+
+``HDF5_C_DEFINITIONS``
+ Required compiler definitions for HDF5 C bindings
+``HDF5_CXX_DEFINITIONS``
+ Required compiler definitions for HDF5 C++ bindings
+``HDF5_Fortran_DEFINITIONS``
+ Required compiler definitions for HDF5 Fortran bindings
+``HDF5_C_INCLUDE_DIRS``
+ Required include directories for HDF5 C bindings
+``HDF5_CXX_INCLUDE_DIRS``
+ Required include directories for HDF5 C++ bindings
+``HDF5_Fortran_INCLUDE_DIRS``
+ Required include directories for HDF5 Fortran bindings
+``HDF5_C_LIBRARIES``
+ Required libraries for the HDF5 C bindings
+``HDF5_CXX_LIBRARIES``
+ Required libraries for the HDF5 C++ bindings
+``HDF5_Fortran_LIBRARIES``
+ Required libraries for the HDF5 Fortran bindings
+``HDF5_C_HL_LIBRARIES``
+ Required libraries for the high level C bindings
+``HDF5_CXX_HL_LIBRARIES``
+ Required libraries for the high level C++ bindings
+``HDF5_Fortran_HL_LIBRARIES``
+ Required libraries for the high level Fortran bindings.
+
+``HDF5_IS_PARALLEL``
+ HDF5 library has parallel IO support
+``HDF5_C_COMPILER_EXECUTABLE``
+ path to the HDF5 C wrapper compiler
+``HDF5_CXX_COMPILER_EXECUTABLE``
+ path to the HDF5 C++ wrapper compiler
+``HDF5_Fortran_COMPILER_EXECUTABLE``
+ path to the HDF5 Fortran wrapper compiler
+``HDF5_C_COMPILER_EXECUTABLE_NO_INTERROGATE``
+ path to the primary C compiler which is also the HDF5 wrapper
+``HDF5_CXX_COMPILER_EXECUTABLE_NO_INTERROGATE``
+ path to the primary C++ compiler which is also the HDF5 wrapper
+``HDF5_Fortran_COMPILER_EXECUTABLE_NO_INTERROGATE``
+ path to the primary Fortran compiler which is also the HDF5 wrapper
+``HDF5_DIFF_EXECUTABLE``
+ path to the HDF5 dataset comparison tool
+
+Hints
+^^^^^
+
+The following variable can be set to guide the search for HDF5 libraries and includes:
+
+``HDF5_ROOT``
+ Specify the path to the HDF5 installation to use.
+
+``HDF5_FIND_DEBUG``
+ Set ``true`` to get extra debugging output.
+
+``HDF5_NO_FIND_PACKAGE_CONFIG_FILE``
+ Set ``true`` to skip trying to find ``hdf5-config.cmake``.
+#]=======================================================================]
# This module is maintained by Will Dicharry <wdicharry@stellarscience.com>.
@@ -187,8 +209,16 @@ function(_HDF5_test_regular_compiler_C success version is_parallel)
file(WRITE ${test_file}
"#include <hdf5.h>\n"
"#include <hdf5_hl.h>\n"
- "int main(void) {\n"
- " char const* info_ver = \"INFO\" \":\" H5_VERSION;\n"
+ "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n"
+ "#ifdef H5_HAVE_PARALLEL\n"
+ "const char* info_parallel = \"INFO\" \":\" \"PARALLEL\";\n"
+ "#endif\n"
+ "int main(int argc, char **argv) {\n"
+ " int require = 0;\n"
+ " require += info_ver[argc];\n"
+ "#ifdef H5_HAVE_PARALLEL\n"
+ " require += info_parallel[argc];\n"
+ "#endif\n"
" hid_t fid;\n"
" fid = H5Fcreate(\"foo.h5\",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);\n"
" return 0;\n"
@@ -198,24 +228,19 @@ function(_HDF5_test_regular_compiler_C success version is_parallel)
)
endif()
if(${success})
- file(STRINGS ${scratch_directory}/compiler_has_h5_c INFO_VER
- REGEX "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?"
+ file(STRINGS ${scratch_directory}/compiler_has_h5_c INFO_STRINGS
+ REGEX "^INFO:"
)
string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?"
- INFO_VER "${INFO_VER}"
+ INFO_VER "${INFO_STRINGS}"
)
set(${version} ${CMAKE_MATCH_1})
if(CMAKE_MATCH_3)
- set(${version} ${HDF5_CXX_VERSION}.${CMAKE_MATCH_3})
+ set(${version} ${HDF5_C_VERSION}.${CMAKE_MATCH_3})
endif()
set(${version} ${${version}} PARENT_SCOPE)
- execute_process(COMMAND ${CMAKE_C_COMPILER} -showconfig
- OUTPUT_VARIABLE config_output
- ERROR_VARIABLE config_error
- RESULT_VARIABLE config_result
- )
- if(config_output MATCHES "Parallel HDF5: yes")
+ if(INFO_STRINGS MATCHES "INFO:PARALLEL")
set(${is_parallel} TRUE PARENT_SCOPE)
else()
set(${is_parallel} FALSE PARENT_SCOPE)
@@ -233,8 +258,16 @@ function(_HDF5_test_regular_compiler_CXX success version is_parallel)
"#ifndef H5_NO_NAMESPACE\n"
"using namespace H5;\n"
"#endif\n"
+ "const char* info_ver = \"INFO\" \":\" H5_VERSION;\n"
+ "#ifdef H5_HAVE_PARALLEL\n"
+ "const char* info_parallel = \"INFO\" \":\" \"PARALLEL\";\n"
+ "#endif\n"
"int main(int argc, char **argv) {\n"
- " char const* info_ver = \"INFO\" \":\" H5_VERSION;\n"
+ " int require = 0;\n"
+ " require += info_ver[argc];\n"
+ "#ifdef H5_HAVE_PARALLEL\n"
+ " require += info_parallel[argc];\n"
+ "#endif\n"
" H5File file(\"foo.h5\", H5F_ACC_TRUNC);\n"
" return 0;\n"
"}")
@@ -243,11 +276,11 @@ function(_HDF5_test_regular_compiler_CXX success version is_parallel)
)
endif()
if(${success})
- file(STRINGS ${scratch_directory}/compiler_has_h5_cxx INFO_VER
- REGEX "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?"
+ file(STRINGS ${scratch_directory}/compiler_has_h5_cxx INFO_STRINGS
+ REGEX "^INFO:"
)
string(REGEX MATCH "^INFO:([0-9]+\\.[0-9]+\\.[0-9]+)(-patch([0-9]+))?"
- INFO_VER "${INFO_VER}"
+ INFO_VER "${INFO_STRINGS}"
)
set(${version} ${CMAKE_MATCH_1})
if(CMAKE_MATCH_3)
@@ -255,12 +288,7 @@ function(_HDF5_test_regular_compiler_CXX success version is_parallel)
endif()
set(${version} ${${version}} PARENT_SCOPE)
- execute_process(COMMAND ${CMAKE_CXX_COMPILER} -showconfig
- OUTPUT_VARIABLE config_output
- ERROR_VARIABLE config_error
- RESULT_VARIABLE config_result
- )
- if(config_output MATCHES "Parallel HDF5: yes")
+ if(INFO_STRINGS MATCHES "INFO:PARALLEL")
set(${is_parallel} TRUE PARENT_SCOPE)
else()
set(${is_parallel} FALSE PARENT_SCOPE)
@@ -315,20 +343,22 @@ macro( _HDF5_invoke_compiler language output return_value version is_parallel)
elseif("${language}" STREQUAL "Fortran")
set(test_file ${scratch_dir}/cmake_hdf5_test.f90)
endif()
- exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE}
- ARGS -show ${lib_type_args} ${test_file}
- OUTPUT_VARIABLE ${output}
- RETURN_VALUE ${return_value}
- )
+ execute_process(
+ COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -show ${lib_type_args} ${test_file}
+ OUTPUT_VARIABLE ${output}
+ ERROR_VARIABLE ${output}
+ RESULT_VARIABLE ${return_value}
+ )
if(NOT ${${return_value}} EQUAL 0)
message(STATUS
"Unable to determine HDF5 ${language} flags from HDF5 wrapper.")
endif()
- exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE}
- ARGS -showconfig
- OUTPUT_VARIABLE config_output
- RETURN_VALUE config_return
- )
+ execute_process(
+ COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -showconfig
+ OUTPUT_VARIABLE config_output
+ ERROR_VARIABLE config_output
+ RESULT_VARIABLE config_return
+ )
if(NOT ${return_value} EQUAL 0)
message( STATUS
"Unable to determine HDF5 ${language} version from HDF5 wrapper.")
@@ -390,6 +420,45 @@ macro( _HDF5_parse_compile_line
endforeach()
endmacro()
+# Select a preferred imported configuration from a target
+function(_HDF5_select_imported_config target imported_conf)
+ # We will first assign the value to a local variable _imported_conf, then assign
+ # it to the function argument at the end.
+ get_target_property(_imported_conf ${target} MAP_IMPORTED_CONFIG_${CMAKE_BUILD_TYPE})
+ if (NOT _imported_conf)
+ # Get available imported configurations by examining target properties
+ get_target_property(_imported_conf ${target} IMPORTED_CONFIGURATIONS)
+ if(HDF5_FIND_DEBUG)
+ message(STATUS "Found imported configurations: ${_imported_conf}")
+ endif()
+ # Find the imported configuration that we prefer.
+ # We do this by making list of configurations in order of preference,
+ # starting with ${CMAKE_BUILD_TYPE} and ending with the first imported_conf
+ set(_preferred_confs ${CMAKE_BUILD_TYPE})
+ list(GET _imported_conf 0 _fallback_conf)
+ list(APPEND _preferred_confs RELWITHDEBINFO RELEASE DEBUG ${_fallback_conf})
+ if(HDF5_FIND_DEBUG)
+ message(STATUS "Start search through imported configurations in the following order: ${_preferred_confs}")
+ endif()
+ # Now find the first of these that is present in imported_conf
+ cmake_policy(PUSH)
+ cmake_policy(SET CMP0057 NEW) # support IN_LISTS
+ foreach (_conf IN LISTS _preferred_confs)
+ if (${_conf} IN_LIST _imported_conf)
+ set(_imported_conf ${_conf})
+ break()
+ endif()
+ endforeach()
+ cmake_policy(POP)
+ endif()
+ if(HDF5_FIND_DEBUG)
+ message(STATUS "Selected imported configuration: ${_imported_conf}")
+ endif()
+ # assign value to function argument
+ set(${imported_conf} ${_imported_conf} PARENT_SCOPE)
+endfunction()
+
+
if(NOT HDF5_ROOT)
set(HDF5_ROOT $ENV{HDF5_ROOT})
endif()
@@ -434,7 +503,7 @@ if(NOT HDF5_FOUND AND NOT HDF5_NO_FIND_PACKAGE_CONFIG_FILE)
#if we detect that occurrence clear the suffix
if(_suffix AND NOT TARGET ${HDF5_${_lang}_TARGET}${_suffix})
if(NOT TARGET ${HDF5_${_lang}_TARGET})
- #cant find this component with or without the suffix
+ #can't find this component with or without the suffix
#so bail out, and let the following locate HDF5
set(HDF5_FOUND FALSE)
break()
@@ -446,30 +515,39 @@ if(NOT HDF5_FOUND AND NOT HDF5_NO_FIND_PACKAGE_CONFIG_FILE)
message(STATUS "Trying to get properties of target ${HDF5_${_lang}_TARGET}${_suffix}")
endif()
# Find library for this target. Complicated as on Windows with a DLL, we need to search for the import-lib.
- get_target_property(_imported_conf ${HDF5_${_lang}_TARGET}${_suffix} IMPORTED_CONFIGURATIONS)
- get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} IMPORTED_IMPLIB_${_imported_conf} )
- if (NOT _lang_location)
+ _HDF5_select_imported_config(${HDF5_${_lang}_TARGET}${_suffix} _hdf5_imported_conf)
+ get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} IMPORTED_IMPLIB_${_hdf5_imported_conf} )
+ if (NOT _hdf5_lang_location)
# no import lib, just try LOCATION
- get_target_property(_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION)
+ get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION_${_hdf5_imported_conf})
+ if (NOT _hdf5_lang_location)
+ get_target_property(_hdf5_lang_location ${HDF5_${_lang}_TARGET}${_suffix} LOCATION)
+ endif()
endif()
- if( _lang_location )
- set(HDF5_${_lang}_LIBRARY ${_lang_location})
+ if( _hdf5_lang_location )
+ set(HDF5_${_lang}_LIBRARY ${_hdf5_lang_location})
list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix})
set(HDF5_${_lang}_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix})
set(HDF5_${_lang}_FOUND True)
endif()
if(FIND_HL)
- get_target_property(__lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} IMPORTED_IMPLIB_${_imported_conf} )
- if (NOT _lang_hl_location)
- get_target_property(_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION)
+ get_target_property(__lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} IMPORTED_IMPLIB_${_hdf5_imported_conf} )
+ if (NOT _hdf5_lang_hl_location)
+ get_target_property(_hdf5_lang_hl_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION_${_hdf5_imported_conf})
+ if (NOT _hdf5_hl_lang_location)
+ get_target_property(_hdf5_hl_lang_location ${HDF5_${_lang}_HL_TARGET}${_suffix} LOCATION)
+ endif()
endif()
- if( _lang_hl_location )
- set(HDF5_${_lang}_HL_LIBRARY ${_lang_hl_location})
- list(APPEND HDF5_HL_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix})
- set(HDF5_${_lang}_HL_LIBRARIES ${HDF5_${_lang}_TARGET}${_suffix})
+ if( _hdf5_lang_hl_location )
+ set(HDF5_${_lang}_HL_LIBRARY ${_hdf5_lang_hl_location})
+ list(APPEND HDF5_HL_LIBRARIES ${HDF5_${_lang}_HL_TARGET}${_suffix})
+ set(HDF5_${_lang}_HL_LIBRARIES ${HDF5_${_lang}_HL_TARGET}${_suffix})
set(HDF5_HL_FOUND True)
endif()
+ unset(_hdf5_lang_hl_location)
endif()
+ unset(_hdf5_imported_conf)
+ unset(_hdf5_lang_location)
endforeach()
endif()
endif()
@@ -545,8 +623,12 @@ if(NOT HDF5_FOUND)
if("x${L}" MATCHES "hdf5")
# hdf5 library
set(_HDF5_SEARCH_OPTS_LOCAL ${_HDF5_SEARCH_OPTS})
- if(UNIX AND HDF5_USE_STATIC_LIBRARIES)
- set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a)
+ if(HDF5_USE_STATIC_LIBRARIES)
+ if(WIN32)
+ set(_HDF5_SEARCH_NAMES_LOCAL lib${L})
+ else()
+ set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a)
+ endif()
endif()
else()
# external library
@@ -573,8 +655,12 @@ if(NOT HDF5_FOUND)
if("x${L}" MATCHES "hdf5")
# hdf5 library
set(_HDF5_SEARCH_OPTS_LOCAL ${_HDF5_SEARCH_OPTS})
- if(UNIX AND HDF5_USE_STATIC_LIBRARIES)
- set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a)
+ if(HDF5_USE_STATIC_LIBRARIES)
+ if(WIN32)
+ set(_HDF5_SEARCH_NAMES_LOCAL lib${L})
+ else()
+ set(_HDF5_SEARCH_NAMES_LOCAL lib${L}.a)
+ endif()
endif()
else()
# external library
@@ -675,7 +761,7 @@ mark_as_advanced( HDF5_DIFF_EXECUTABLE )
if( NOT HDF5_FOUND )
# seed the initial lists of libraries to find with items we know we need
set(HDF5_C_LIBRARY_NAMES hdf5)
- set(HDF5_C_HL_LIBRARY_NAMES hdf5_hl)
+ set(HDF5_C_HL_LIBRARY_NAMES hdf5_hl ${HDF5_C_LIBRARY_NAMES} )
set(HDF5_CXX_LIBRARY_NAMES hdf5_cpp ${HDF5_C_LIBRARY_NAMES})
set(HDF5_CXX_HL_LIBRARY_NAMES hdf5_hl_cpp ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_CXX_LIBRARY_NAMES})
@@ -686,7 +772,7 @@ if( NOT HDF5_FOUND )
foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS)
# find the HDF5 include directories
if("${__lang}" STREQUAL "Fortran")
- set(HDF5_INCLUDE_FILENAME hdf5.mod)
+ set(HDF5_INCLUDE_FILENAME hdf5.mod HDF5.mod)
elseif("${__lang}" STREQUAL "CXX")
set(HDF5_INCLUDE_FILENAME H5Cpp.h)
else()
@@ -706,19 +792,22 @@ if( NOT HDF5_FOUND )
# find the HDF5 libraries
foreach(LIB IN LISTS HDF5_${__lang}_LIBRARY_NAMES)
- if(UNIX AND HDF5_USE_STATIC_LIBRARIES)
+ if(HDF5_USE_STATIC_LIBRARIES)
# According to bug 1643 on the CMake bug tracker, this is the
# preferred method for searching for a static library.
# See https://gitlab.kitware.com/cmake/cmake/issues/1643. We search
# first for the full static library name, but fall back to a
# generic search on the name if the static search fails.
set( THIS_LIBRARY_SEARCH_DEBUG
- lib${LIB}d.a lib${LIB}_debug.a ${LIB}d ${LIB}_debug
- lib${LIB}d-static.a lib${LIB}_debug-static.a ${LIB}d-static ${LIB}_debug-static )
- set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} lib${LIB}-static.a ${LIB}-static)
+ lib${LIB}d.a lib${LIB}_debug.a lib${LIB}d lib${LIB}_D lib${LIB}_debug
+ lib${LIB}d-static.a lib${LIB}_debug-static.a ${LIB}d-static ${LIB}_D-static ${LIB}_debug-static )
+ set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a lib${LIB} lib${LIB}-static.a ${LIB}-static)
else()
- set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_debug ${LIB}d-shared ${LIB}_debug-shared)
+ set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_D ${LIB}_debug ${LIB}d-shared ${LIB}_D-shared ${LIB}_debug-shared)
set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared)
+ if(WIN32)
+ list(APPEND HDF5_DEFINITIONS "-DH5_BUILT_AS_DYNAMIC_LIB")
+ endif()
endif()
find_library(HDF5_${LIB}_LIBRARY_DEBUG
NAMES ${THIS_LIBRARY_SEARCH_DEBUG}
@@ -743,18 +832,18 @@ if( NOT HDF5_FOUND )
if(FIND_HL)
foreach(LIB IN LISTS HDF5_${__lang}_HL_LIBRARY_NAMES)
- if(UNIX AND HDF5_USE_STATIC_LIBRARIES)
+ if(HDF5_USE_STATIC_LIBRARIES)
# According to bug 1643 on the CMake bug tracker, this is the
# preferred method for searching for a static library.
# See https://gitlab.kitware.com/cmake/cmake/issues/1643. We search
# first for the full static library name, but fall back to a
# generic search on the name if the static search fails.
set( THIS_LIBRARY_SEARCH_DEBUG
- lib${LIB}d.a lib${LIB}_debug.a ${LIB}d ${LIB}_debug
- lib${LIB}d-static.a lib${LIB}_debug-static.a ${LIB}d-static ${LIB}_debug-static )
- set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} lib${LIB}-static.a ${LIB}-static)
+ lib${LIB}d.a lib${LIB}_debug.a lib${LIB}d lib${LIB}_D lib${LIB}_debug
+ lib${LIB}d-static.a lib${LIB}_debug-static.a lib${LIB}d-static lib${LIB}_D-static lib${LIB}_debug-static )
+ set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a lib${LIB} lib${LIB}-static.a lib${LIB}-static)
else()
- set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_debug ${LIB}d-shared ${LIB}_debug-shared)
+ set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ${LIB}_D ${LIB}_debug ${LIB}d-shared ${LIB}_D-shared ${LIB}_debug-shared)
set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ${LIB}-shared)
endif()
find_library(HDF5_${LIB}_LIBRARY_DEBUG
@@ -780,6 +869,7 @@ if( NOT HDF5_FOUND )
set(HDF5_HL_FOUND True)
endif()
+ _HDF5_remove_duplicates_from_beginning(HDF5_DEFINITIONS)
_HDF5_remove_duplicates_from_beginning(HDF5_INCLUDE_DIRS)
_HDF5_remove_duplicates_from_beginning(HDF5_LIBRARIES)
_HDF5_remove_duplicates_from_beginning(HDF5_HL_LIBRARIES)
@@ -855,11 +945,14 @@ if (HDF5_FIND_DEBUG)
message(STATUS "HDF5_DEFINITIONS: ${HDF5_DEFINITIONS}")
message(STATUS "HDF5_INCLUDE_DIRS: ${HDF5_INCLUDE_DIRS}")
message(STATUS "HDF5_LIBRARIES: ${HDF5_LIBRARIES}")
+ message(STATUS "HDF5_HL_LIBRARIES: ${HDF5_HL_LIBRARIES}")
foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS)
message(STATUS "HDF5_${__lang}_DEFINITIONS: ${HDF5_${__lang}_DEFINITIONS}")
message(STATUS "HDF5_${__lang}_INCLUDE_DIR: ${HDF5_${__lang}_INCLUDE_DIR}")
message(STATUS "HDF5_${__lang}_INCLUDE_DIRS: ${HDF5_${__lang}_INCLUDE_DIRS}")
message(STATUS "HDF5_${__lang}_LIBRARY: ${HDF5_${__lang}_LIBRARY}")
message(STATUS "HDF5_${__lang}_LIBRARIES: ${HDF5_${__lang}_LIBRARIES}")
+ message(STATUS "HDF5_${__lang}_HL_LIBRARY: ${HDF5_${__lang}_HL_LIBRARY}")
+ message(STATUS "HDF5_${__lang}_HL_LIBRARIES: ${HDF5_${__lang}_HL_LIBRARIES}")
endforeach()
endif()
diff --git a/Modules/FindHSPELL.cmake b/Modules/FindHSPELL.cmake
index bb0e2f08e..9724d2cf1 100644
--- a/Modules/FindHSPELL.cmake
+++ b/Modules/FindHSPELL.cmake
@@ -1,28 +1,29 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindHSPELL
-# ----------
-#
-# Try to find Hspell
-#
-# Once done this will define
-#
-# ::
-#
-# HSPELL_FOUND - system has Hspell
-# HSPELL_INCLUDE_DIR - the Hspell include directory
-# HSPELL_LIBRARIES - The libraries needed to use Hspell
-# HSPELL_DEFINITIONS - Compiler switches required for using Hspell
-#
-#
-#
-# ::
-#
-# HSPELL_VERSION_STRING - The version of Hspell found (x.y)
-# HSPELL_MAJOR_VERSION - the major version of Hspell
-# HSPELL_MINOR_VERSION - The minor version of Hspell
+#[=======================================================================[.rst:
+FindHSPELL
+----------
+
+Try to find Hebrew spell-checker (Hspell) and morphology engine.
+
+Once done this will define
+
+::
+
+ HSPELL_FOUND - system has Hspell
+ HSPELL_INCLUDE_DIR - the Hspell include directory
+ HSPELL_LIBRARIES - The libraries needed to use Hspell
+ HSPELL_DEFINITIONS - Compiler switches required for using Hspell
+
+
+
+::
+
+ HSPELL_VERSION_STRING - The version of Hspell found (x.y)
+ HSPELL_MAJOR_VERSION - the major version of Hspell
+ HSPELL_MINOR_VERSION - The minor version of Hspell
+#]=======================================================================]
find_path(HSPELL_INCLUDE_DIR hspell.h)
diff --git a/Modules/FindHTMLHelp.cmake b/Modules/FindHTMLHelp.cmake
index 84e2458af..a11ad4d69 100644
--- a/Modules/FindHTMLHelp.cmake
+++ b/Modules/FindHTMLHelp.cmake
@@ -1,45 +1,46 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindHTMLHelp
-# ------------
-#
-# This module looks for Microsoft HTML Help Compiler
-#
-# It defines:
-#
-# ::
-#
-# HTML_HELP_COMPILER : full path to the Compiler (hhc.exe)
-# HTML_HELP_INCLUDE_PATH : include path to the API (htmlhelp.h)
-# HTML_HELP_LIBRARY : full path to the library (htmlhelp.lib)
+#[=======================================================================[.rst:
+FindHTMLHelp
+------------
+
+This module looks for Microsoft HTML Help Compiler
+
+It defines:
+
+::
+
+ HTML_HELP_COMPILER : full path to the Compiler (hhc.exe)
+ HTML_HELP_INCLUDE_PATH : include path to the API (htmlhelp.h)
+ HTML_HELP_LIBRARY : full path to the library (htmlhelp.lib)
+#]=======================================================================]
if(WIN32)
find_program(HTML_HELP_COMPILER
- hhc
- "[HKEY_CURRENT_USER\\Software\\Microsoft\\HTML Help Workshop;InstallDir]"
- "$ENV{ProgramFiles}/HTML Help Workshop"
- "C:/Program Files/HTML Help Workshop"
+ NAMES hhc
+ PATHS
+ "[HKEY_CURRENT_USER\\Software\\Microsoft\\HTML Help Workshop;InstallDir]"
+ PATH_SUFFIXES "HTML Help Workshop"
)
get_filename_component(HTML_HELP_COMPILER_PATH "${HTML_HELP_COMPILER}" PATH)
find_path(HTML_HELP_INCLUDE_PATH
- htmlhelp.h
- "${HTML_HELP_COMPILER_PATH}/include"
- "[HKEY_CURRENT_USER\\Software\\Microsoft\\HTML Help Workshop;InstallDir]/include"
- "$ENV{ProgramFiles}/HTML Help Workshop/include"
- "C:/Program Files/HTML Help Workshop/include"
+ NAMES htmlhelp.h
+ PATHS
+ "${HTML_HELP_COMPILER_PATH}/include"
+ "[HKEY_CURRENT_USER\\Software\\Microsoft\\HTML Help Workshop;InstallDir]/include"
+ PATH_SUFFIXES "HTML Help Workshop/include"
)
find_library(HTML_HELP_LIBRARY
- htmlhelp
- "${HTML_HELP_COMPILER_PATH}/lib"
- "[HKEY_CURRENT_USER\\Software\\Microsoft\\HTML Help Workshop;InstallDir]/lib"
- "$ENV{ProgramFiles}/HTML Help Workshop/lib"
- "C:/Program Files/HTML Help Workshop/lib"
+ NAMES htmlhelp
+ PATHS
+ "${HTML_HELP_COMPILER_PATH}/lib"
+ "[HKEY_CURRENT_USER\\Software\\Microsoft\\HTML Help Workshop;InstallDir]/lib"
+ PATH_SUFFIXES "HTML Help Workshop/lib"
)
mark_as_advanced(
diff --git a/Modules/FindHg.cmake b/Modules/FindHg.cmake
index 8aa553e79..1358363d2 100644
--- a/Modules/FindHg.cmake
+++ b/Modules/FindHg.cmake
@@ -1,45 +1,46 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindHg
-# ------
-#
-# Extract information from a mercurial working copy.
-#
-# The module defines the following variables:
-#
-# ::
-#
-# HG_EXECUTABLE - path to mercurial command line client (hg)
-# HG_FOUND - true if the command line client was found
-# HG_VERSION_STRING - the version of mercurial found
-#
-# If the command line client executable is found the following macro is defined:
-#
-# ::
-#
-# HG_WC_INFO(<dir> <var-prefix>)
-#
-# Hg_WC_INFO extracts information of a mercurial working copy
-# at a given location. This macro defines the following variables:
-#
-# ::
-#
-# <var-prefix>_WC_CHANGESET - current changeset
-# <var-prefix>_WC_REVISION - current revision
-#
-# Example usage:
-#
-# ::
-#
-# find_package(Hg)
-# if(HG_FOUND)
-# message("hg found: ${HG_EXECUTABLE}")
-# HG_WC_INFO(${PROJECT_SOURCE_DIR} Project)
-# message("Current revision is ${Project_WC_REVISION}")
-# message("Current changeset is ${Project_WC_CHANGESET}")
-# endif()
+#[=======================================================================[.rst:
+FindHg
+------
+
+Extract information from a mercurial working copy.
+
+The module defines the following variables:
+
+::
+
+ HG_EXECUTABLE - path to mercurial command line client (hg)
+ HG_FOUND - true if the command line client was found
+ HG_VERSION_STRING - the version of mercurial found
+
+If the command line client executable is found the following macro is defined:
+
+::
+
+ HG_WC_INFO(<dir> <var-prefix>)
+
+Hg_WC_INFO extracts information of a mercurial working copy
+at a given location. This macro defines the following variables:
+
+::
+
+ <var-prefix>_WC_CHANGESET - current changeset
+ <var-prefix>_WC_REVISION - current revision
+
+Example usage:
+
+::
+
+ find_package(Hg)
+ if(HG_FOUND)
+ message("hg found: ${HG_EXECUTABLE}")
+ HG_WC_INFO(${PROJECT_SOURCE_DIR} Project)
+ message("Current revision is ${Project_WC_REVISION}")
+ message("Current changeset is ${Project_WC_CHANGESET}")
+ endif()
+#]=======================================================================]
find_program(HG_EXECUTABLE
NAMES hg
diff --git a/Modules/FindICU.cmake b/Modules/FindICU.cmake
index 5210f0806..38081f5fa 100644
--- a/Modules/FindICU.cmake
+++ b/Modules/FindICU.cmake
@@ -1,84 +1,90 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindICU
-# -------
-#
-# Find the International Components for Unicode (ICU) libraries and
-# programs.
-#
-# This module supports multiple components.
-# Components can include any of: ``data``, ``i18n``, ``io``, ``le``,
-# ``lx``, ``test``, ``tu`` and ``uc``.
-#
-# Note that on Windows ``data`` is named ``dt`` and ``i18n`` is named
-# ``in``; any of the names may be used, and the appropriate
-# platform-specific library name will be automatically selected.
-#
-# This module reports information about the ICU installation in
-# several variables. General variables::
-#
-# ICU_VERSION - ICU release version
-# ICU_FOUND - true if the main programs and libraries were found
-# ICU_LIBRARIES - component libraries to be linked
-# ICU_INCLUDE_DIRS - the directories containing the ICU headers
-#
-# Imported targets::
-#
-# ICU::<C>
-#
-# Where ``<C>`` is the name of an ICU component, for example
-# ``ICU::i18n``.
-#
-# ICU programs are reported in::
-#
-# ICU_GENCNVAL_EXECUTABLE - path to gencnval executable
-# ICU_ICUINFO_EXECUTABLE - path to icuinfo executable
-# ICU_GENBRK_EXECUTABLE - path to genbrk executable
-# ICU_ICU-CONFIG_EXECUTABLE - path to icu-config executable
-# ICU_GENRB_EXECUTABLE - path to genrb executable
-# ICU_GENDICT_EXECUTABLE - path to gendict executable
-# ICU_DERB_EXECUTABLE - path to derb executable
-# ICU_PKGDATA_EXECUTABLE - path to pkgdata executable
-# ICU_UCONV_EXECUTABLE - path to uconv executable
-# ICU_GENCFU_EXECUTABLE - path to gencfu executable
-# ICU_MAKECONV_EXECUTABLE - path to makeconv executable
-# ICU_GENNORM2_EXECUTABLE - path to gennorm2 executable
-# ICU_GENCCODE_EXECUTABLE - path to genccode executable
-# ICU_GENSPREP_EXECUTABLE - path to gensprep executable
-# ICU_ICUPKG_EXECUTABLE - path to icupkg executable
-# ICU_GENCMN_EXECUTABLE - path to gencmn executable
-#
-# ICU component libraries are reported in::
-#
-# ICU_<C>_FOUND - ON if component was found
-# ICU_<C>_LIBRARIES - libraries for component
-#
-# Note that ``<C>`` is the uppercased name of the component.
-#
-# This module reads hints about search results from::
-#
-# ICU_ROOT - the root of the ICU installation
-#
-# The environment variable ``ICU_ROOT`` may also be used; the
-# ICU_ROOT variable takes precedence.
-#
-# The following cache variables may also be set::
-#
-# ICU_<P>_EXECUTABLE - the path to executable <P>
-# ICU_INCLUDE_DIR - the directory containing the ICU headers
-# ICU_<C>_LIBRARY - the library for component <C>
-#
-# .. note::
-#
-# In most cases none of the above variables will require setting,
-# unless multiple ICU versions are available and a specific version
-# is required.
-#
-# Other variables one may set to control this module are::
-#
-# ICU_DEBUG - Set to ON to enable debug output from FindICU.
+#[=======================================================================[.rst:
+FindICU
+-------
+
+Find the International Components for Unicode (ICU) libraries and
+programs.
+
+This module supports multiple components.
+Components can include any of: ``data``, ``i18n``, ``io``, ``le``,
+``lx``, ``test``, ``tu`` and ``uc``.
+
+Note that on Windows ``data`` is named ``dt`` and ``i18n`` is named
+``in``; any of the names may be used, and the appropriate
+platform-specific library name will be automatically selected.
+
+This module reports information about the ICU installation in
+several variables. General variables::
+
+ ICU_VERSION - ICU release version
+ ICU_FOUND - true if the main programs and libraries were found
+ ICU_LIBRARIES - component libraries to be linked
+ ICU_INCLUDE_DIRS - the directories containing the ICU headers
+
+Imported targets::
+
+ ICU::<C>
+
+Where ``<C>`` is the name of an ICU component, for example
+``ICU::i18n``.
+
+ICU programs are reported in::
+
+ ICU_GENCNVAL_EXECUTABLE - path to gencnval executable
+ ICU_ICUINFO_EXECUTABLE - path to icuinfo executable
+ ICU_GENBRK_EXECUTABLE - path to genbrk executable
+ ICU_ICU-CONFIG_EXECUTABLE - path to icu-config executable
+ ICU_GENRB_EXECUTABLE - path to genrb executable
+ ICU_GENDICT_EXECUTABLE - path to gendict executable
+ ICU_DERB_EXECUTABLE - path to derb executable
+ ICU_PKGDATA_EXECUTABLE - path to pkgdata executable
+ ICU_UCONV_EXECUTABLE - path to uconv executable
+ ICU_GENCFU_EXECUTABLE - path to gencfu executable
+ ICU_MAKECONV_EXECUTABLE - path to makeconv executable
+ ICU_GENNORM2_EXECUTABLE - path to gennorm2 executable
+ ICU_GENCCODE_EXECUTABLE - path to genccode executable
+ ICU_GENSPREP_EXECUTABLE - path to gensprep executable
+ ICU_ICUPKG_EXECUTABLE - path to icupkg executable
+ ICU_GENCMN_EXECUTABLE - path to gencmn executable
+
+ICU component libraries are reported in::
+
+ ICU_<C>_FOUND - ON if component was found
+ ICU_<C>_LIBRARIES - libraries for component
+
+ICU datafiles are reported in::
+
+ ICU_MAKEFILE_INC - Makefile.inc
+ ICU_PKGDATA_INC - pkgdata.inc
+
+Note that ``<C>`` is the uppercased name of the component.
+
+This module reads hints about search results from::
+
+ ICU_ROOT - the root of the ICU installation
+
+The environment variable ``ICU_ROOT`` may also be used; the
+ICU_ROOT variable takes precedence.
+
+The following cache variables may also be set::
+
+ ICU_<P>_EXECUTABLE - the path to executable <P>
+ ICU_INCLUDE_DIR - the directory containing the ICU headers
+ ICU_<C>_LIBRARY - the library for component <C>
+
+.. note::
+
+ In most cases none of the above variables will require setting,
+ unless multiple ICU versions are available and a specific version
+ is required.
+
+Other variables one may set to control this module are::
+
+ ICU_DEBUG - Set to ON to enable debug output from FindICU.
+#]=======================================================================]
# Written by Roger Leigh <rleigh@codelibre.net>
@@ -100,6 +106,10 @@ set(icu_programs
icupkg
gencmn)
+set(icu_data
+ Makefile.inc
+ pkgdata.inc)
+
# The ICU checks are contained in a function due to the large number
# of temporary variables needed.
function(_ICU_FIND)
@@ -116,32 +126,8 @@ function(_ICU_FIND)
endif()
endif()
- if(CMAKE_SIZEOF_VOID_P EQUAL 8)
- # 64-bit binary directory
- set(_bin64 "bin64")
- # 64-bit library directory
- set(_lib64 "lib64")
- endif()
-
- # Generic 64-bit and 32-bit directories
- list(APPEND icu_binary_suffixes "${_bin64}" "bin")
- list(APPEND icu_library_suffixes "${_lib64}" "lib")
- list(APPEND icu_include_suffixes "include")
-
- # Find all ICU programs
- foreach(program ${icu_programs})
- string(TOUPPER "${program}" program_upcase)
- set(cache_var "ICU_${program_upcase}_EXECUTABLE")
- set(program_var "ICU_${program_upcase}_EXECUTABLE")
- find_program("${cache_var}" "${program}"
- HINTS ${icu_roots}
- PATH_SUFFIXES ${icu_binary_suffixes}
- DOC "ICU ${program} executable")
- mark_as_advanced(cache_var)
- set("${program_var}" "${${cache_var}}" PARENT_SCOPE)
- endforeach()
-
# Find include directory
+ list(APPEND icu_include_suffixes "include")
find_path(ICU_INCLUDE_DIR
NAMES "unicode/utypes.h"
HINTS ${icu_roots}
@@ -156,13 +142,45 @@ function(_ICU_FIND)
string(REGEX REPLACE "^#define[\t ]+U_ICU_VERSION[\t ]+\"([^ \\n]*)\".*"
"\\1" icu_version_string "${icu_header_str}")
+ set(ICU_VERSION "${icu_version_string}")
set(ICU_VERSION "${icu_version_string}" PARENT_SCOPE)
unset(icu_header_str)
unset(icu_version_string)
endif()
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ # 64-bit binary directory
+ set(_bin64 "bin64")
+ # 64-bit library directory
+ set(_lib64 "lib64")
+ endif()
+
+
+ # Find all ICU programs
+ list(APPEND icu_binary_suffixes "${_bin64}" "bin" "sbin")
+ foreach(program ${icu_programs})
+ string(TOUPPER "${program}" program_upcase)
+ set(cache_var "ICU_${program_upcase}_EXECUTABLE")
+ set(program_var "ICU_${program_upcase}_EXECUTABLE")
+ find_program("${cache_var}"
+ NAMES "${program}"
+ HINTS ${icu_roots}
+ PATH_SUFFIXES ${icu_binary_suffixes}
+ DOC "ICU ${program} executable"
+ NO_PACKAGE_ROOT_PATH
+ )
+ mark_as_advanced(cache_var)
+ set("${program_var}" "${${cache_var}}" PARENT_SCOPE)
+ endforeach()
+
# Find all ICU libraries
+ list(APPEND icu_library_suffixes "${_lib64}" "lib")
set(ICU_REQUIRED_LIBS_FOUND ON)
+ set(static_prefix )
+ # static icu libraries compiled with MSVC have the prefix 's'
+ if(MSVC)
+ set(static_prefix "s")
+ endif()
foreach(component ${ICU_FIND_COMPONENTS})
string(TOUPPER "${component}" component_upcase)
set(component_cache "ICU_${component_upcase}_LIBRARY")
@@ -197,14 +215,34 @@ function(_ICU_FIND)
list(APPEND component_debug_libnames "icui18nd")
endif()
- find_library("${component_cache_release}" ${component_libnames}
+ if(static_prefix)
+ unset(static_component_libnames)
+ unset(static_component_debug_libnames)
+ foreach(component_libname ${component_libnames})
+ list(APPEND static_component_libnames
+ ${static_prefix}${component_libname})
+ endforeach()
+ foreach(component_libname ${component_debug_libnames})
+ list(APPEND static_component_debug_libnames
+ ${static_prefix}${component_libname})
+ endforeach()
+ list(APPEND component_libnames ${static_component_libnames})
+ list(APPEND component_debug_libnames ${static_component_debug_libnames})
+ endif()
+ find_library("${component_cache_release}"
+ NAMES ${component_libnames}
HINTS ${icu_roots}
PATH_SUFFIXES ${icu_library_suffixes}
- DOC "ICU ${component} library (release)")
- find_library("${component_cache_debug}" ${component_debug_libnames}
+ DOC "ICU ${component} library (release)"
+ NO_PACKAGE_ROOT_PATH
+ )
+ find_library("${component_cache_debug}"
+ NAMES ${component_debug_libnames}
HINTS ${icu_roots}
PATH_SUFFIXES ${icu_library_suffixes}
- DOC "ICU ${component} library (debug)")
+ DOC "ICU ${component} library (debug)"
+ NO_PACKAGE_ROOT_PATH
+ )
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
select_library_configurations(ICU_${component_upcase})
mark_as_advanced("${component_cache_release}" "${component_cache_debug}")
@@ -233,6 +271,33 @@ function(_ICU_FIND)
set(_ICU_REQUIRED_LIBS_FOUND "${ICU_REQUIRED_LIBS_FOUND}" PARENT_SCOPE)
set(ICU_LIBRARY "${ICU_LIBRARY}" PARENT_SCOPE)
+ # Find all ICU data files
+ if(CMAKE_LIBRARY_ARCHITECTURE)
+ list(APPEND icu_data_suffixes
+ "${_lib64}/${CMAKE_LIBRARY_ARCHITECTURE}/icu/${ICU_VERSION}"
+ "lib/${CMAKE_LIBRARY_ARCHITECTURE}/icu/${ICU_VERSION}"
+ "${_lib64}/${CMAKE_LIBRARY_ARCHITECTURE}/icu"
+ "lib/${CMAKE_LIBRARY_ARCHITECTURE}/icu")
+ endif()
+ list(APPEND icu_data_suffixes
+ "${_lib64}/icu/${ICU_VERSION}"
+ "lib/icu/${ICU_VERSION}"
+ "${_lib64}/icu"
+ "lib/icu")
+ foreach(data ${icu_data})
+ string(TOUPPER "${data}" data_upcase)
+ string(REPLACE "." "_" data_upcase "${data_upcase}")
+ set(cache_var "ICU_${data_upcase}")
+ set(data_var "ICU_${data_upcase}")
+ find_file("${cache_var}"
+ NAMES "${data}"
+ HINTS ${icu_roots}
+ PATH_SUFFIXES ${icu_data_suffixes}
+ DOC "ICU ${data} data file")
+ mark_as_advanced(cache_var)
+ set("${data_var}" "${${cache_var}}" PARENT_SCOPE)
+ endforeach()
+
if(NOT ICU_FIND_QUIETLY)
if(ICU_LIBS_FOUND)
message(STATUS "Found the following ICU libraries:")
@@ -308,6 +373,10 @@ if(ICU_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
IMPORTED_LOCATION_DEBUG "${${_ICU_component_cache_debug}}")
endif()
+ if(CMAKE_DL_LIBS AND _ICU_component STREQUAL "uc")
+ set_target_properties(${_ICU_imported_target} PROPERTIES
+ INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}")
+ endif()
endif()
endif()
unset(_ICU_component_upcase)
@@ -334,6 +403,15 @@ if(ICU_DEBUG)
unset(program_lib)
endforeach()
+ foreach(data IN LISTS icu_data)
+ string(TOUPPER "${data}" data_upcase)
+ string(REPLACE "." "_" data_upcase "${data_upcase}")
+ set(data_lib "ICU_${data_upcase}")
+ message(STATUS "${data} data: ${${data_lib}}")
+ unset(data_upcase)
+ unset(data_lib)
+ endforeach()
+
foreach(component IN LISTS ICU_FIND_COMPONENTS)
string(TOUPPER "${component}" component_upcase)
set(component_lib "ICU_${component_upcase}_LIBRARIES")
diff --git a/Modules/FindIce.cmake b/Modules/FindIce.cmake
index e0286ee2c..5ce2b42d9 100644
--- a/Modules/FindIce.cmake
+++ b/Modules/FindIce.cmake
@@ -1,135 +1,215 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindIce
-# -------
-#
-# Find the ZeroC Internet Communication Engine (ICE) programs,
-# libraries and datafiles.
-#
-# This module supports multiple components.
-# Components can include any of: ``Freeze``, ``Glacier2``, ``Ice``,
-# ``IceBox``, ``IceDB``, ``IceGrid``, ``IcePatch``, ``IceSSL``,
-# ``IceStorm``, ``IceUtil``, ``IceXML``, or ``Slice``.
-#
-# This module reports information about the Ice installation in
-# several variables. General variables::
-#
-# Ice_VERSION - Ice release version
-# Ice_FOUND - true if the main programs and libraries were found
-# Ice_LIBRARIES - component libraries to be linked
-# Ice_INCLUDE_DIRS - the directories containing the Ice headers
-# Ice_SLICE_DIRS - the directories containing the Ice slice interface
-# definitions
-#
-# Imported targets::
-#
-# Ice::<C>
-#
-# Where ``<C>`` is the name of an Ice component, for example
-# ``Ice::Glacier2``.
-#
-# Ice slice programs are reported in::
-#
-# Ice_SLICE2CPP_EXECUTABLE - path to slice2cpp executable
-# Ice_SLICE2CS_EXECUTABLE - path to slice2cs executable
-# Ice_SLICE2FREEZEJ_EXECUTABLE - path to slice2freezej executable
-# Ice_SLICE2FREEZE_EXECUTABLE - path to slice2freeze executable
-# Ice_SLICE2HTML_EXECUTABLE - path to slice2html executable
-# Ice_SLICE2JAVA_EXECUTABLE - path to slice2java executable
-# Ice_SLICE2JS_EXECUTABLE - path to slice2js executable
-# Ice_SLICE2PHP_EXECUTABLE - path to slice2php executable
-# Ice_SLICE2PY_EXECUTABLE - path to slice2py executable
-# Ice_SLICE2RB_EXECUTABLE - path to slice2rb executable
-#
-# Ice programs are reported in::
-#
-# Ice_GLACIER2ROUTER_EXECUTABLE - path to glacier2router executable
-# Ice_ICEBOX_EXECUTABLE - path to icebox executable
-# Ice_ICEBOXADMIN_EXECUTABLE - path to iceboxadmin executable
-# Ice_ICEBOXD_EXECUTABLE - path to iceboxd executable
-# Ice_ICEBOXNET_EXECUTABLE - path to iceboxnet executable
-# Ice_ICEGRIDADMIN_EXECUTABLE - path to icegridadmin executable
-# Ice_ICEGRIDNODE_EXECUTABLE - path to icegridnode executable
-# Ice_ICEGRIDNODED_EXECUTABLE - path to icegridnoded executable
-# Ice_ICEGRIDREGISTRY_EXECUTABLE - path to icegridregistry executable
-# Ice_ICEGRIDREGISTRYD_EXECUTABLE - path to icegridregistryd executable
-# Ice_ICEPATCH2CALC_EXECUTABLE - path to icepatch2calc executable
-# Ice_ICEPATCH2CLIENT_EXECUTABLE - path to icepatch2client executable
-# Ice_ICEPATCH2SERVER_EXECUTABLE - path to icepatch2server executable
-# Ice_ICESERVICEINSTALL_EXECUTABLE - path to iceserviceinstall executable
-# Ice_ICESTORMADMIN_EXECUTABLE - path to icestormadmin executable
-# Ice_ICESTORMMIGRATE_EXECUTABLE - path to icestormmigrate executable
-#
-# Ice db programs (Windows only; standard system versions on all other
-# platforms) are reported in::
-#
-# Ice_DB_ARCHIVE_EXECUTABLE - path to db_archive executable
-# Ice_DB_CHECKPOINT_EXECUTABLE - path to db_checkpoint executable
-# Ice_DB_DEADLOCK_EXECUTABLE - path to db_deadlock executable
-# Ice_DB_DUMP_EXECUTABLE - path to db_dump executable
-# Ice_DB_HOTBACKUP_EXECUTABLE - path to db_hotbackup executable
-# Ice_DB_LOAD_EXECUTABLE - path to db_load executable
-# Ice_DB_LOG_VERIFY_EXECUTABLE - path to db_log_verify executable
-# Ice_DB_PRINTLOG_EXECUTABLE - path to db_printlog executable
-# Ice_DB_RECOVER_EXECUTABLE - path to db_recover executable
-# Ice_DB_STAT_EXECUTABLE - path to db_stat executable
-# Ice_DB_TUNER_EXECUTABLE - path to db_tuner executable
-# Ice_DB_UPGRADE_EXECUTABLE - path to db_upgrade executable
-# Ice_DB_VERIFY_EXECUTABLE - path to db_verify executable
-# Ice_DUMPDB_EXECUTABLE - path to dumpdb executable
-# Ice_TRANSFORMDB_EXECUTABLE - path to transformdb executable
-#
-# Ice component libraries are reported in::
-#
-# Ice_<C>_FOUND - ON if component was found
-# Ice_<C>_LIBRARIES - libraries for component
-#
-# Note that ``<C>`` is the uppercased name of the component.
-#
-# This module reads hints about search results from::
-#
-# Ice_HOME - the root of the Ice installation
-#
-# The environment variable ``ICE_HOME`` may also be used; the
-# Ice_HOME variable takes precedence.
-#
-# The following cache variables may also be set::
-#
-# Ice_<P>_EXECUTABLE - the path to executable <P>
-# Ice_INCLUDE_DIR - the directory containing the Ice headers
-# Ice_SLICE_DIR - the directory containing the Ice slice interface
-# definitions
-# Ice_<C>_LIBRARY - the library for component <C>
-#
-# .. note::
-#
-# In most cases none of the above variables will require setting,
-# unless multiple Ice versions are available and a specific version
-# is required. On Windows, the most recent version of Ice will be
-# found through the registry. On Unix, the programs, headers and
-# libraries will usually be in standard locations, but Ice_SLICE_DIRS
-# might not be automatically detected (commonly known locations are
-# searched). All the other variables are defaulted using Ice_HOME,
-# if set. It's possible to set Ice_HOME and selectively specify
-# alternative locations for the other components; this might be
-# required for e.g. newer versions of Visual Studio if the
-# heuristics are not sufficient to identify the correct programs and
-# libraries for the specific Visual Studio version.
-#
-# Other variables one may set to control this module are::
-#
-# Ice_DEBUG - Set to ON to enable debug output from FindIce.
+#[=======================================================================[.rst:
+FindIce
+-------
+
+Find the ZeroC Internet Communication Engine (ICE) programs,
+libraries and datafiles.
+
+This module supports multiple components.
+Components can include any of: ``Freeze``, ``Glacier2``, ``Ice``,
+``IceBox``, ``IceDB``, ``IceDiscovery``, ``IceGrid``,
+``IceLocatorDiscovery``, ``IcePatch``, ``IceSSL``, ``IceStorm``,
+``IceUtil``, ``IceXML``, or ``Slice``.
+
+Ice 3.7 and later also include C++11-specific components:
+``Glacier2++11``, ``Ice++11``, ``IceBox++11``, ``IceDiscovery++11``
+``IceGrid``, ``IceLocatorDiscovery++11``, ``IceSSL++11``,
+``IceStorm++11``
+
+Note that the set of supported components is Ice version-specific.
+
+This module reports information about the Ice installation in
+several variables. General variables::
+
+ Ice_VERSION - Ice release version
+ Ice_FOUND - true if the main programs and libraries were found
+ Ice_LIBRARIES - component libraries to be linked
+ Ice_INCLUDE_DIRS - the directories containing the Ice headers
+ Ice_SLICE_DIRS - the directories containing the Ice slice interface
+ definitions
+
+Imported targets::
+
+ Ice::<C>
+
+Where ``<C>`` is the name of an Ice component, for example
+``Ice::Glacier2`` or ``Ice++11``.
+
+Ice slice programs are reported in::
+
+ Ice_SLICE2CONFLUENCE_EXECUTABLE - path to slice2confluence executable
+ Ice_SLICE2CPP_EXECUTABLE - path to slice2cpp executable
+ Ice_SLICE2CS_EXECUTABLE - path to slice2cs executable
+ Ice_SLICE2FREEZEJ_EXECUTABLE - path to slice2freezej executable
+ Ice_SLICE2FREEZE_EXECUTABLE - path to slice2freeze executable
+ Ice_SLICE2HTML_EXECUTABLE - path to slice2html executable
+ Ice_SLICE2JAVA_EXECUTABLE - path to slice2java executable
+ Ice_SLICE2JS_EXECUTABLE - path to slice2js executable
+ Ice_SLICE2MATLAB_EXECUTABLE - path to slice2matlab executable
+ Ice_SLICE2OBJC_EXECUTABLE - path to slice2objc executable
+ Ice_SLICE2PHP_EXECUTABLE - path to slice2php executable
+ Ice_SLICE2PY_EXECUTABLE - path to slice2py executable
+ Ice_SLICE2RB_EXECUTABLE - path to slice2rb executable
+
+Ice programs are reported in::
+
+ Ice_GLACIER2ROUTER_EXECUTABLE - path to glacier2router executable
+ Ice_ICEBOX_EXECUTABLE - path to icebox executable
+ Ice_ICEBOXXX11_EXECUTABLE - path to icebox++11 executable
+ Ice_ICEBOXADMIN_EXECUTABLE - path to iceboxadmin executable
+ Ice_ICEBOXD_EXECUTABLE - path to iceboxd executable
+ Ice_ICEBOXNET_EXECUTABLE - path to iceboxnet executable
+ Ice_ICEBRIDGE_EXECUTABLE - path to icebridge executable
+ Ice_ICEGRIDADMIN_EXECUTABLE - path to icegridadmin executable
+ Ice_ICEGRIDDB_EXECUTABLE - path to icegriddb executable
+ Ice_ICEGRIDNODE_EXECUTABLE - path to icegridnode executable
+ Ice_ICEGRIDNODED_EXECUTABLE - path to icegridnoded executable
+ Ice_ICEGRIDREGISTRY_EXECUTABLE - path to icegridregistry executable
+ Ice_ICEGRIDREGISTRYD_EXECUTABLE - path to icegridregistryd executable
+ Ice_ICEPATCH2CALC_EXECUTABLE - path to icepatch2calc executable
+ Ice_ICEPATCH2CLIENT_EXECUTABLE - path to icepatch2client executable
+ Ice_ICEPATCH2SERVER_EXECUTABLE - path to icepatch2server executable
+ Ice_ICESERVICEINSTALL_EXECUTABLE - path to iceserviceinstall executable
+ Ice_ICESTORMADMIN_EXECUTABLE - path to icestormadmin executable
+ Ice_ICESTORMDB_EXECUTABLE - path to icestormdb executable
+ Ice_ICESTORMMIGRATE_EXECUTABLE - path to icestormmigrate executable
+
+Ice db programs (Windows only; standard system versions on all other
+platforms) are reported in::
+
+ Ice_DB_ARCHIVE_EXECUTABLE - path to db_archive executable
+ Ice_DB_CHECKPOINT_EXECUTABLE - path to db_checkpoint executable
+ Ice_DB_DEADLOCK_EXECUTABLE - path to db_deadlock executable
+ Ice_DB_DUMP_EXECUTABLE - path to db_dump executable
+ Ice_DB_HOTBACKUP_EXECUTABLE - path to db_hotbackup executable
+ Ice_DB_LOAD_EXECUTABLE - path to db_load executable
+ Ice_DB_LOG_VERIFY_EXECUTABLE - path to db_log_verify executable
+ Ice_DB_PRINTLOG_EXECUTABLE - path to db_printlog executable
+ Ice_DB_RECOVER_EXECUTABLE - path to db_recover executable
+ Ice_DB_STAT_EXECUTABLE - path to db_stat executable
+ Ice_DB_TUNER_EXECUTABLE - path to db_tuner executable
+ Ice_DB_UPGRADE_EXECUTABLE - path to db_upgrade executable
+ Ice_DB_VERIFY_EXECUTABLE - path to db_verify executable
+ Ice_DUMPDB_EXECUTABLE - path to dumpdb executable
+ Ice_TRANSFORMDB_EXECUTABLE - path to transformdb executable
+
+Ice component libraries are reported in::
+
+ Ice_<C>_FOUND - ON if component was found
+ Ice_<C>_LIBRARIES - libraries for component
+
+Note that ``<C>`` is the uppercased name of the component.
+
+This module reads hints about search results from::
+
+ Ice_HOME - the root of the Ice installation
+
+The environment variable ``ICE_HOME`` may also be used; the
+Ice_HOME variable takes precedence.
+
+.. note::
+ On Windows, Ice 3.7.0 and later provide libraries via the NuGet
+ package manager. Appropriate NuGet packages will be searched for
+ using ``CMAKE_PREFIX_PATH``, or alternatively ``Ice_HOME`` may be
+ set to the location of a specific NuGet package to restrict the
+ search.
+
+The following cache variables may also be set::
+
+ Ice_<P>_EXECUTABLE - the path to executable <P>
+ Ice_INCLUDE_DIR - the directory containing the Ice headers
+ Ice_SLICE_DIR - the directory containing the Ice slice interface
+ definitions
+ Ice_<C>_LIBRARY - the library for component <C>
+
+.. note::
+
+ In most cases none of the above variables will require setting,
+ unless multiple Ice versions are available and a specific version
+ is required. On Windows, the most recent version of Ice will be
+ found through the registry. On Unix, the programs, headers and
+ libraries will usually be in standard locations, but Ice_SLICE_DIRS
+ might not be automatically detected (commonly known locations are
+ searched). All the other variables are defaulted using Ice_HOME,
+ if set. It's possible to set Ice_HOME and selectively specify
+ alternative locations for the other components; this might be
+ required for e.g. newer versions of Visual Studio if the
+ heuristics are not sufficient to identify the correct programs and
+ libraries for the specific Visual Studio version.
+
+Other variables one may set to control this module are::
+
+ Ice_DEBUG - Set to ON to enable debug output from FindIce.
+#]=======================================================================]
# Written by Roger Leigh <rleigh@codelibre.net>
+ set(_Ice_db_programs
+ db_archive
+ db_checkpoint
+ db_deadlock
+ db_dump
+ db_hotbackup
+ db_load
+ db_log_verify
+ db_printlog
+ db_recover
+ db_stat
+ db_tuner
+ db_upgrade
+ db_verify
+ dumpdb
+ transformdb)
+
+ set(_Ice_programs
+ glacier2router
+ icebox
+ icebox++11
+ iceboxadmin
+ iceboxd
+ iceboxnet
+ icebridge
+ icegridadmin
+ icegriddb
+ icegridnode
+ icegridnoded
+ icegridregistry
+ icegridregistryd
+ icepatch2calc
+ icepatch2client
+ icepatch2server
+ iceserviceinstall
+ icestormadmin
+ icestormdb
+ icestormmigrate)
+
+ set(_Ice_slice_programs
+ slice2confluence
+ slice2cpp
+ slice2cs
+ slice2freezej
+ slice2freeze
+ slice2html
+ slice2java
+ slice2js
+ slice2matlab
+ slice2objc
+ slice2php
+ slice2py
+ slice2rb)
+
+
# The Ice checks are contained in a function due to the large number
# of temporary variables needed.
function(_Ice_FIND)
# Released versions of Ice, including generic short forms
set(ice_versions
3
+ 3.7
+ 3.7.0
3.6
3.6.3
3.6.2
@@ -146,6 +226,14 @@ function(_Ice_FIND)
3.3.1
3.3.0)
+ foreach(ver ${ice_versions})
+ string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\$" two_digit_version_match "${ver}")
+ if(two_digit_version_match)
+ string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\$" "\\1\\2" two_digit_version "${ver}")
+ list(APPEND ice_suffix_versions "${two_digit_version}")
+ endif()
+ endforeach()
+
# Set up search paths, taking compiler into account. Search Ice_HOME,
# with ICE_HOME in the environment as a fallback if unset.
if(Ice_HOME)
@@ -159,52 +247,79 @@ function(_Ice_FIND)
endif()
endif()
+ set(_bin "bin/Win32")
+ set(_lib "lib/Win32")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(_bin "bin/x64")
+ set(_lib "lib/x64")
# 64-bit path suffix
set(_x64 "/x64")
# 64-bit library directory
set(_lib64 "lib64")
endif()
- if(MSVC_VERSION)
- # VS 8.0
- if(NOT MSVC_VERSION VERSION_LESS 1400 AND MSVC_VERSION VERSION_LESS 1500)
- set(vcver "vc80")
- set(vcyear "2005")
- # VS 9.0
- elseif(NOT MSVC_VERSION VERSION_LESS 1500 AND MSVC_VERSION VERSION_LESS 1600)
- set(vcver "vc90")
+ unset(vcvers)
+ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
+ if(MSVC_TOOLSET_VERSION GREATER_EQUAL 141)
+ set(vcvers "141;140")
+ elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 100)
+ set(vcvers "${MSVC_TOOLSET_VERSION}")
+ elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 90)
+ set(vcvers "${MSVC_TOOLSET_VERSION}")
set(vcyear "2008")
- # VS 10.0
- elseif(NOT MSVC_VERSION VERSION_LESS 1600 AND MSVC_VERSION VERSION_LESS 1700)
- set(vcver "vc100")
- # VS 11.0
- elseif(NOT MSVC_VERSION VERSION_LESS 1700 AND MSVC_VERSION VERSION_LESS 1800)
- set(vcver "vc110")
- # VS 12.0
- elseif(NOT MSVC_VERSION VERSION_LESS 1800 AND MSVC_VERSION VERSION_LESS 1900)
- set(vcver "vc120")
- # VS 14.0
- elseif(NOT MSVC_VERSION VERSION_LESS 1900 AND MSVC_VERSION VERSION_LESS 2000)
- set(vcver "vc140")
+ elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 80)
+ set(vcvers "${MSVC_TOOLSET_VERSION}")
+ set(vcyear "2005")
+ else() # Unknown version
+ set(vcvers Unknown)
endif()
endif()
# For compatibility with ZeroC Windows builds.
- if(vcver)
- # Earlier Ice (3.3) builds don't use vcnnn subdirectories, but are harmless to check.
- list(APPEND ice_binary_suffixes "bin/${vcver}${_x64}" "bin/${vcver}")
- list(APPEND ice_library_suffixes "lib/${vcver}${_x64}" "lib/${vcver}")
+ if(vcvers)
+ list(APPEND ice_binary_suffixes "build/native/${_bin}/Release" "tools")
+ list(APPEND ice_debug_library_suffixes "build/native/${_lib}/Debug")
+ list(APPEND ice_release_library_suffixes "build/native/${_lib}/Release")
+ foreach(vcver IN LISTS vcvers)
+ # Earlier Ice (3.3) builds don't use vcnnn subdirectories, but are harmless to check.
+ list(APPEND ice_binary_suffixes "bin/vc${vcver}${_x64}" "bin/vc${vcver}")
+ list(APPEND ice_debug_library_suffixes "lib/vc${vcver}${_x64}" "lib/vc${vcver}")
+ list(APPEND ice_release_library_suffixes "lib/vc${vcver}${_x64}" "lib/vc${vcver}")
+ endforeach()
endif()
# Generic 64-bit and 32-bit directories
list(APPEND ice_binary_suffixes "bin${_x64}" "bin")
- list(APPEND ice_library_suffixes "libx32" "${_lib64}" "lib${_x64}" "lib")
+ list(APPEND ice_debug_library_suffixes "libx32" "${_lib64}" "lib${_x64}" "lib")
+ list(APPEND ice_release_library_suffixes "libx32" "${_lib64}" "lib${_x64}" "lib")
+ if(vcvers)
+ list(APPEND ice_include_suffixes "build/native/include")
+ endif()
list(APPEND ice_include_suffixes "include")
list(APPEND ice_slice_suffixes "slice")
# On Windows, look in the registry for install locations. Different
# versions of Ice install support different compiler versions.
- if(vcver)
+ if(vcvers)
+ foreach(ice_version ${ice_versions})
+ foreach(vcver IN LISTS vcvers)
+ list(APPEND ice_nuget_dirs "zeroc.ice.v${vcver}.${ice_version}")
+ list(APPEND freeze_nuget_dirs "zeroc.freeze.v${vcver}.${ice_version}")
+ endforeach()
+ endforeach()
+ find_path(Ice_NUGET_DIR
+ NAMES "tools/slice2cpp.exe"
+ PATH_SUFFIXES ${ice_nuget_dirs}
+ DOC "Ice NuGet directory")
+ if(Ice_NUGET_DIR)
+ list(APPEND ice_roots "${Ice_NUGET_DIR}")
+ endif()
+ find_path(Freeze_NUGET_DIR
+ NAMES "tools/slice2freeze.exe"
+ PATH_SUFFIXES ${freeze_nuget_dirs}
+ DOC "Freeze NuGet directory")
+ if(Freeze_NUGET_DIR)
+ list(APPEND ice_roots "${Freeze_NUGET_DIR}")
+ endif()
foreach(ice_version ${ice_versions})
# Ice 3.3 releases use a Visual Studio year suffix and value is
# enclosed in double quotes, though only the leading quote is
@@ -239,55 +354,8 @@ function(_Ice_FIND)
endforeach()
endif()
- set(db_programs
- db_archive
- db_checkpoint
- db_deadlock
- db_dump
- db_hotbackup
- db_load
- db_log_verify
- db_printlog
- db_recover
- db_stat
- db_tuner
- db_upgrade
- db_verify
- dumpdb
- transformdb)
-
- set(ice_programs
- glacier2router
- icebox
- iceboxadmin
- iceboxd
- iceboxnet
- icegridadmin
- icegridnode
- icegridnoded
- icegridregistry
- icegridregistryd
- icepatch2calc
- icepatch2client
- icepatch2server
- iceserviceinstall
- icestormadmin
- icestormmigrate)
-
- set(slice_programs
- slice2cpp
- slice2cs
- slice2freezej
- slice2freeze
- slice2html
- slice2java
- slice2js
- slice2php
- slice2py
- slice2rb)
-
# Find all Ice programs
- foreach(program ${db_programs} ${ice_programs} ${slice_programs})
+ foreach(program ${_Ice_db_programs} ${_Ice_programs} ${_Ice_slice_programs})
string(TOUPPER "${program}" program_upcase)
set(cache_var "Ice_${program_upcase}_EXECUTABLE")
set(program_var "Ice_${program_upcase}_EXECUTABLE")
@@ -329,6 +397,13 @@ function(_Ice_FIND)
DOC "Ice include directory")
set(Ice_INCLUDE_DIR "${Ice_INCLUDE_DIR}" PARENT_SCOPE)
+ find_path(Freeze_INCLUDE_DIR
+ NAMES "Freeze/Freeze.h"
+ HINTS ${ice_roots}
+ PATH_SUFFIXES ${ice_include_suffixes}
+ DOC "Freeze include directory")
+ set(Freeze_INCLUDE_DIR "${Freeze_INCLUDE_DIR}" PARENT_SCOPE)
+
# In common use on Linux, MacOS X (homebrew) and FreeBSD; prefer
# version-specific dir
list(APPEND ice_slice_paths
@@ -336,6 +411,7 @@ function(_Ice_FIND)
list(APPEND ice_slice_suffixes
"Ice-${Ice_VERSION_SLICE2CPP_FULL}/slice"
"Ice-${Ice_VERSION_SLICE2CPP_SHORT}/slice"
+ "ice/slice"
Ice)
# Find slice directory
@@ -356,13 +432,39 @@ function(_Ice_FIND)
set(component_cache_release "${component_cache}_RELEASE")
set(component_cache_debug "${component_cache}_DEBUG")
set(component_found "${component_upcase}_FOUND")
- find_library("${component_cache_release}" "${component}"
+ set(component_library "${component}")
+ unset(component_library_release_names)
+ unset(component_library_debug_names)
+ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
+ string(REGEX MATCH ".+\\+\\+11$" component_library_cpp11 "${component_library}")
+ if(component_library_cpp11)
+ string(REGEX REPLACE "^(.+)(\\+\\+11)$" "\\1" component_library "${component_library}")
+ endif()
+ foreach(suffix_ver ${ice_suffix_versions})
+ set(_name "${component_library}${suffix_ver}")
+ if(component_library_cpp11)
+ string(APPEND _name "++11")
+ endif()
+ list(APPEND component_library_debug_names "${_name}d")
+ list(APPEND component_library_release_names "${_name}")
+ endforeach()
+ set(_name "${component_library}")
+ if(component_library_cpp11)
+ string(APPEND _name "++11")
+ endif()
+ list(APPEND component_library_debug_names "${_name}d")
+ list(APPEND component_library_release_names "${_name}")
+ else()
+ list(APPEND component_library_debug_names "${component_library}d")
+ list(APPEND component_library_release_names "${component_library}")
+ endif()
+ find_library("${component_cache_release}" ${component_library_release_names}
HINTS ${ice_roots}
- PATH_SUFFIXES ${ice_library_suffixes}
+ PATH_SUFFIXES ${ice_release_library_suffixes}
DOC "Ice ${component} library (release)")
- find_library("${component_cache_debug}" "${component}d"
+ find_library("${component_cache_debug}" ${component_library_debug_names}
HINTS ${ice_roots}
- PATH_SUFFIXES ${ice_library_suffixes}
+ PATH_SUFFIXES ${ice_debug_library_suffixes}
DOC "Ice ${component} library (debug)")
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
select_library_configurations(Ice_${component_upcase})
@@ -410,9 +512,14 @@ function(_Ice_FIND)
if(Ice_DEBUG)
message(STATUS "--------FindIce.cmake search debug--------")
message(STATUS "ICE binary path search order: ${ice_roots}")
+ message(STATUS "ICE binary suffixes: ${ice_binary_suffixes}")
message(STATUS "ICE include path search order: ${ice_roots}")
+ message(STATUS "ICE include suffixes: ${ice_include_suffixes}")
message(STATUS "ICE slice path search order: ${ice_roots} ${ice_slice_paths}")
+ message(STATUS "ICE slice suffixes: ${ice_slice_suffixes}")
message(STATUS "ICE library path search order: ${ice_roots}")
+ message(STATUS "ICE debug library suffixes: ${ice_debug_library_suffixes}")
+ message(STATUS "ICE release library suffixes: ${ice_release_library_suffixes}")
message(STATUS "----------------")
endif()
endfunction()
@@ -434,6 +541,9 @@ unset(_Ice_REQUIRED_LIBS_FOUND)
if(Ice_FOUND)
set(Ice_INCLUDE_DIRS "${Ice_INCLUDE_DIR}")
+ if (Freeze_INCLUDE_DIR)
+ list(APPEND Ice_INCLUDE_DIRS "${Freeze_INCLUDE_DIR}")
+ endif()
set(Ice_SLICE_DIRS "${Ice_SLICE_DIR}")
set(Ice_LIBRARIES "${Ice_LIBRARY}")
foreach(_Ice_component ${Ice_FIND_COMPONENTS})
@@ -448,10 +558,8 @@ if(Ice_FOUND)
set("${_Ice_component_lib}" "${${_Ice_component_cache}}")
if(NOT TARGET ${_Ice_imported_target})
add_library(${_Ice_imported_target} UNKNOWN IMPORTED)
- if()
- set_target_properties(${_Ice_imported_target} PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${Ice_INCLUDE_DIR}")
- endif()
+ set_target_properties(${_Ice_imported_target} PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${Ice_INCLUDE_DIRS}")
if(EXISTS "${${_Ice_component_cache}}")
set_target_properties(${_Ice_imported_target} PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
@@ -488,50 +596,13 @@ if(Ice_DEBUG)
message(STATUS "Ice_INCLUDE_DIR directory: ${Ice_INCLUDE_DIR}")
message(STATUS "Ice_SLICE_DIR directory: ${Ice_SLICE_DIR}")
message(STATUS "Ice_LIBRARIES: ${Ice_LIBRARIES}")
+ message(STATUS "Freeze_INCLUDE_DIR directory: ${Freeze_INCLUDE_DIR}")
+ message(STATUS "Ice_INCLUDE_DIRS directory: ${Ice_INCLUDE_DIRS}")
- message(STATUS "slice2cpp executable: ${Ice_SLICE2CPP_EXECUTABLE}")
- message(STATUS "slice2cs executable: ${Ice_SLICE2CS_EXECUTABLE}")
- message(STATUS "slice2freezej executable: ${Ice_SLICE2FREEZEJ_EXECUTABLE}")
- message(STATUS "slice2freeze executable: ${Ice_SLICE2FREEZE_EXECUTABLE}")
- message(STATUS "slice2html executable: ${Ice_SLICE2HTML_EXECUTABLE}")
- message(STATUS "slice2java executable: ${Ice_SLICE2JAVA_EXECUTABLE}")
- message(STATUS "slice2js executable: ${Ice_SLICE2JS_EXECUTABLE}")
- message(STATUS "slice2php executable: ${Ice_SLICE2PHP_EXECUTABLE}")
- message(STATUS "slice2py executable: ${Ice_SLICE2PY_EXECUTABLE}")
- message(STATUS "slice2rb executable: ${Ice_SLICE2RB_EXECUTABLE}")
- message(STATUS "glacier2router executable: ${Ice_GLACIER2ROUTER_EXECUTABLE}")
-
- message(STATUS "icebox executable: ${Ice_ICEBOX_EXECUTABLE}")
- message(STATUS "iceboxadmin executable: ${Ice_ICEBOXADMIN_EXECUTABLE}")
- message(STATUS "iceboxd executable: ${Ice_ICEBOXD_EXECUTABLE}")
- message(STATUS "iceboxnet executable: ${Ice_ICEBOXNET_EXECUTABLE}")
- message(STATUS "icegridadmin executable: ${Ice_ICEGRIDADMIN_EXECUTABLE}")
- message(STATUS "icegridnode executable: ${Ice_ICEGRIDNODE_EXECUTABLE}")
- message(STATUS "icegridnoded executable: ${Ice_ICEGRIDNODED_EXECUTABLE}")
- message(STATUS "icegridregistry executable: ${Ice_ICEGRIDREGISTRY_EXECUTABLE}")
- message(STATUS "icegridregistryd executable: ${Ice_ICEGRIDREGISTRYD_EXECUTABLE}")
- message(STATUS "icepatch2calc executable: ${Ice_ICEPATCH2CALC_EXECUTABLE}")
- message(STATUS "icepatch2client executable: ${Ice_ICEPATCH2CLIENT_EXECUTABLE}")
- message(STATUS "icepatch2server executable: ${Ice_ICEPATCH2SERVER_EXECUTABLE}")
- message(STATUS "iceserviceinstall executable: ${Ice_ICESERVICEINSTALL_EXECUTABLE}")
- message(STATUS "icestormadmin executable: ${Ice_ICESTORMADMIN_EXECUTABLE}")
- message(STATUS "icestormmigrate executable: ${Ice_ICESTORMMIGRATE_EXECUTABLE}")
-
- message(STATUS "db_archive executable: ${Ice_DB_ARCHIVE_EXECUTABLE}")
- message(STATUS "db_checkpoint executable: ${Ice_DB_CHECKPOINT_EXECUTABLE}")
- message(STATUS "db_deadlock executable: ${Ice_DB_DEADLOCK_EXECUTABLE}")
- message(STATUS "db_dump executable: ${Ice_DB_DUMP_EXECUTABLE}")
- message(STATUS "db_hotbackup executable: ${Ice_DB_HOTBACKUP_EXECUTABLE}")
- message(STATUS "db_load executable: ${Ice_DB_LOAD_EXECUTABLE}")
- message(STATUS "db_log_verify executable: ${Ice_DB_LOG_VERIFY_EXECUTABLE}")
- message(STATUS "db_printlog executable: ${Ice_DB_PRINTLOG_EXECUTABLE}")
- message(STATUS "db_recover executable: ${Ice_DB_RECOVER_EXECUTABLE}")
- message(STATUS "db_stat executable: ${Ice_DB_STAT_EXECUTABLE}")
- message(STATUS "db_tuner executable: ${Ice_DB_TUNER_EXECUTABLE}")
- message(STATUS "db_upgrade executable: ${Ice_DB_UPGRADE_EXECUTABLE}")
- message(STATUS "db_verify executable: ${Ice_DB_VERIFY_EXECUTABLE}")
- message(STATUS "dumpdb executable: ${Ice_DUMPDB_EXECUTABLE}")
- message(STATUS "transformdb executable: ${Ice_TRANSFORMDB_EXECUTABLE}")
+ foreach(program ${_Ice_db_programs} ${_Ice_programs} ${_Ice_slice_programs})
+ string(TOUPPER "${program}" program_upcase)
+ message(STATUS "${program} executable: ${Ice_${program_upcase}_EXECUTABLE}")
+ endforeach()
foreach(component ${Ice_FIND_COMPONENTS})
string(TOUPPER "${component}" component_upcase)
@@ -542,3 +613,7 @@ if(Ice_DEBUG)
endforeach()
message(STATUS "----------------")
endif()
+
+unset(_Ice_db_programs)
+unset(_Ice_programs)
+unset(_Ice_slice_programs)
diff --git a/Modules/FindIconv.cmake b/Modules/FindIconv.cmake
new file mode 100644
index 000000000..bf20f6f7e
--- /dev/null
+++ b/Modules/FindIconv.cmake
@@ -0,0 +1,133 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindIconv
+---------
+
+This module finds the ``iconv()`` POSIX.1 functions on the system.
+These functions might be provided in the regular C library or externally
+in the form of an additional library.
+
+The following variables are provided to indicate iconv support:
+
+.. variable:: Iconv_FOUND
+
+ Variable indicating if the iconv support was found.
+
+.. variable:: Iconv_INCLUDE_DIRS
+
+ The directories containing the iconv headers.
+
+.. variable:: Iconv_LIBRARIES
+
+ The iconv libraries to be linked.
+
+.. variable:: Iconv_IS_BUILT_IN
+
+ A variable indicating whether iconv support is stemming from the
+ C library or not. Even if the C library provides `iconv()`, the presence of
+ an external `libiconv` implementation might lead to this being false.
+
+Additionally, the following :prop_tgt:`IMPORTED` target is being provided:
+
+.. variable:: Iconv::Iconv
+
+ Imported target for using iconv.
+
+The following cache variables may also be set:
+
+.. variable:: Iconv_INCLUDE_DIR
+
+ The directory containing the iconv headers.
+
+.. variable:: Iconv_LIBRARY
+
+ The iconv library (if not implicitly given in the C library).
+
+.. note::
+ On POSIX platforms, iconv might be part of the C library and the cache
+ variables ``Iconv_INCLUDE_DIR`` and ``Iconv_LIBRARY`` might be empty.
+
+#]=======================================================================]
+
+include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+if(CMAKE_C_COMPILER_LOADED)
+ include(${CMAKE_CURRENT_LIST_DIR}/CheckCSourceCompiles.cmake)
+elseif(CMAKE_CXX_COMPILER_LOADED)
+ include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXSourceCompiles.cmake)
+else()
+ # If neither C nor CXX are loaded, implicit iconv makes no sense.
+ set(Iconv_IS_BUILT_IN FALSE)
+endif()
+
+# iconv can only be provided in libc on a POSIX system.
+# If any cache variable is already set, we'll skip this test.
+if(NOT DEFINED Iconv_IS_BUILT_IN)
+ if(UNIX AND NOT DEFINED Iconv_INCLUDE_DIR AND NOT DEFINED Iconv_LIBRARY)
+ cmake_push_check_state(RESET)
+ # We always suppress the message here: Otherwise on supported systems
+ # not having iconv in their C library (e.g. those using libiconv)
+ # would always display a confusing "Looking for iconv - not found" message
+ set(CMAKE_FIND_QUIETLY TRUE)
+ # The following code will not work, but it's sufficient to see if it compiles.
+ # Note: libiconv will define the iconv functions as macros, so CheckSymbolExists
+ # will not yield correct results.
+ set(Iconv_IMPLICIT_TEST_CODE
+ "
+ #include <stddef.h>
+ #include <iconv.h>
+ int main() {
+ char *a, *b;
+ size_t i, j;
+ iconv_t ic;
+ ic = iconv_open(\"to\", \"from\");
+ iconv(ic, &a, &i, &b, &j);
+ iconv_close(ic);
+ }
+ "
+ )
+ if(CMAKE_C_COMPILER_LOADED)
+ check_c_source_compiles("${Iconv_IMPLICIT_TEST_CODE}" Iconv_IS_BUILT_IN)
+ else()
+ check_cxx_source_compiles("${Iconv_IMPLICIT_TEST_CODE}" Iconv_IS_BUILT_IN)
+ endif()
+ cmake_pop_check_state()
+ else()
+ set(Iconv_IS_BUILT_IN FALSE)
+ endif()
+endif()
+
+if(NOT Iconv_IS_BUILT_IN)
+ find_path(Iconv_INCLUDE_DIR
+ NAMES "iconv.h"
+ DOC "iconv include directory")
+ set(Iconv_LIBRARY_NAMES "iconv" "libiconv")
+else()
+ set(Iconv_INCLUDE_DIR "" CACHE FILEPATH "iconv include directory")
+ set(Iconv_LIBRARY_NAMES "c")
+endif()
+
+find_library(Iconv_LIBRARY
+ NAMES ${Iconv_LIBRARY_NAMES}
+ DOC "iconv library (potentially the C library)")
+
+mark_as_advanced(Iconv_INCLUDE_DIR)
+mark_as_advanced(Iconv_LIBRARY)
+
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+if(NOT Iconv_IS_BUILT_IN)
+ find_package_handle_standard_args(Iconv REQUIRED_VARS Iconv_LIBRARY Iconv_INCLUDE_DIR)
+else()
+ find_package_handle_standard_args(Iconv REQUIRED_VARS Iconv_LIBRARY)
+endif()
+
+if(Iconv_FOUND)
+ set(Iconv_INCLUDE_DIRS "${Iconv_INCLUDE_DIR}")
+ set(Iconv_LIBRARIES "${Iconv_LIBRARY}")
+ if(NOT TARGET Iconv::Iconv)
+ add_library(Iconv::Iconv INTERFACE IMPORTED)
+ endif()
+ set_property(TARGET Iconv::Iconv PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${Iconv_INCLUDE_DIRS}")
+ set_property(TARGET Iconv::Iconv PROPERTY INTERFACE_LINK_LIBRARIES "${Iconv_LIBRARIES}")
+endif()
diff --git a/Modules/FindIcotool.cmake b/Modules/FindIcotool.cmake
index 26e95a0fa..d19c14579 100644
--- a/Modules/FindIcotool.cmake
+++ b/Modules/FindIcotool.cmake
@@ -1,20 +1,21 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindIcotool
-# -----------
-#
-# Find icotool
-#
-# This module looks for icotool. This module defines the following
-# values:
-#
-# ::
-#
-# ICOTOOL_EXECUTABLE: the full path to the icotool tool.
-# ICOTOOL_FOUND: True if icotool has been found.
-# ICOTOOL_VERSION_STRING: the version of icotool found.
+#[=======================================================================[.rst:
+FindIcotool
+-----------
+
+Find icotool
+
+This module looks for icotool. Convert and create Win32 icon and cursor files.
+This module defines the following values:
+
+::
+
+ ICOTOOL_EXECUTABLE: the full path to the icotool tool.
+ ICOTOOL_FOUND: True if icotool has been found.
+ ICOTOOL_VERSION_STRING: the version of icotool found.
+#]=======================================================================]
find_program(ICOTOOL_EXECUTABLE
icotool
diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake
index 7d5534bc2..8bf5123b7 100644
--- a/Modules/FindImageMagick.cmake
+++ b/Modules/FindImageMagick.cmake
@@ -1,87 +1,88 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindImageMagick
-# ---------------
-#
-# Find the ImageMagick binary suite.
-#
-# This module will search for a set of ImageMagick tools specified as
-# components in the FIND_PACKAGE call. Typical components include, but
-# are not limited to (future versions of ImageMagick might have
-# additional components not listed here):
-#
-# ::
-#
-# animate
-# compare
-# composite
-# conjure
-# convert
-# display
-# identify
-# import
-# mogrify
-# montage
-# stream
-#
-#
-#
-# If no component is specified in the FIND_PACKAGE call, then it only
-# searches for the ImageMagick executable directory. This code defines
-# the following variables:
-#
-# ::
-#
-# ImageMagick_FOUND - TRUE if all components are found.
-# ImageMagick_EXECUTABLE_DIR - Full path to executables directory.
-# ImageMagick_<component>_FOUND - TRUE if <component> is found.
-# ImageMagick_<component>_EXECUTABLE - Full path to <component> executable.
-# ImageMagick_VERSION_STRING - the version of ImageMagick found
-# (since CMake 2.8.8)
-#
-#
-#
-# ImageMagick_VERSION_STRING will not work for old versions like 5.2.3.
-#
-# There are also components for the following ImageMagick APIs:
-#
-# ::
-#
-# Magick++
-# MagickWand
-# MagickCore
-#
-#
-#
-# For these components the following variables are set:
-#
-# ::
-#
-# ImageMagick_FOUND - TRUE if all components are found.
-# ImageMagick_INCLUDE_DIRS - Full paths to all include dirs.
-# ImageMagick_LIBRARIES - Full paths to all libraries.
-# ImageMagick_<component>_FOUND - TRUE if <component> is found.
-# ImageMagick_<component>_INCLUDE_DIRS - Full path to <component> include dirs.
-# ImageMagick_<component>_LIBRARIES - Full path to <component> libraries.
-#
-#
-#
-# Example Usages:
-#
-# ::
-#
-# find_package(ImageMagick)
-# find_package(ImageMagick COMPONENTS convert)
-# find_package(ImageMagick COMPONENTS convert mogrify display)
-# find_package(ImageMagick COMPONENTS Magick++)
-# find_package(ImageMagick COMPONENTS Magick++ convert)
-#
-#
-#
-# Note that the standard FIND_PACKAGE features are supported (i.e.,
-# QUIET, REQUIRED, etc.).
+#[=======================================================================[.rst:
+FindImageMagick
+---------------
+
+Find ImageMagick binary suite.
+
+This module will search for a set of ImageMagick tools specified as
+components in the :command:`find_package` call. Typical components include,
+but are not limited to (future versions of ImageMagick might have
+additional components not listed here):
+
+::
+
+ animate
+ compare
+ composite
+ conjure
+ convert
+ display
+ identify
+ import
+ mogrify
+ montage
+ stream
+
+
+
+If no component is specified in the :command:`find_package` call, then it only
+searches for the ImageMagick executable directory. This code defines
+the following variables:
+
+::
+
+ ImageMagick_FOUND - TRUE if all components are found.
+ ImageMagick_EXECUTABLE_DIR - Full path to executables directory.
+ ImageMagick_<component>_FOUND - TRUE if <component> is found.
+ ImageMagick_<component>_EXECUTABLE - Full path to <component> executable.
+ ImageMagick_VERSION_STRING - the version of ImageMagick found
+ (since CMake 2.8.8)
+
+
+
+``ImageMagick_VERSION_STRING`` will not work for old versions like 5.2.3.
+
+There are also components for the following ImageMagick APIs:
+
+::
+
+ Magick++
+ MagickWand
+ MagickCore
+
+
+
+For these components the following variables are set:
+
+::
+
+ ImageMagick_FOUND - TRUE if all components are found.
+ ImageMagick_INCLUDE_DIRS - Full paths to all include dirs.
+ ImageMagick_LIBRARIES - Full paths to all libraries.
+ ImageMagick_<component>_FOUND - TRUE if <component> is found.
+ ImageMagick_<component>_INCLUDE_DIRS - Full path to <component> include dirs.
+ ImageMagick_<component>_LIBRARIES - Full path to <component> libraries.
+
+
+
+Example Usages:
+
+::
+
+ find_package(ImageMagick)
+ find_package(ImageMagick COMPONENTS convert)
+ find_package(ImageMagick COMPONENTS convert mogrify display)
+ find_package(ImageMagick COMPONENTS Magick++)
+ find_package(ImageMagick COMPONENTS Magick++ convert)
+
+
+
+Note that the standard :command:`find_package` features are supported (i.e.,
+``QUIET``, ``REQUIRED``, etc.).
+#]=======================================================================]
find_package(PkgConfig QUIET)
@@ -104,6 +105,7 @@ function(FIND_IMAGEMAGICK_API component header)
PATH_SUFFIXES
ImageMagick ImageMagick-6 ImageMagick-7
DOC "Path to the ImageMagick arch-independent include dir."
+ NO_DEFAULT_PATH
)
find_path(ImageMagick_${component}_ARCH_INCLUDE_DIR
NAMES magick/magick-baseconfig.h
@@ -116,6 +118,7 @@ function(FIND_IMAGEMAGICK_API component header)
PATH_SUFFIXES
ImageMagick ImageMagick-6 ImageMagick-7
DOC "Path to the ImageMagick arch-specific include dir."
+ NO_DEFAULT_PATH
)
find_library(ImageMagick_${component}_LIBRARY
NAMES ${ARGN}
@@ -125,6 +128,7 @@ function(FIND_IMAGEMAGICK_API component header)
PATHS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]/lib"
DOC "Path to the ImageMagick Magick++ library."
+ NO_DEFAULT_PATH
)
# old version have only indep dir
@@ -196,24 +200,33 @@ foreach(component ${ImageMagick_FIND_COMPONENTS}
if(component STREQUAL "Magick++")
FIND_IMAGEMAGICK_API(Magick++ Magick++.h
Magick++ CORE_RL_Magick++_
+ Magick++-6 Magick++-7
Magick++-Q8 Magick++-Q16 Magick++-Q16HDRI Magick++-Q8HDRI
+ Magick++-6.Q64 Magick++-6.Q32 Magick++-6.Q64HDRI Magick++-6.Q32HDRI
Magick++-6.Q16 Magick++-6.Q8 Magick++-6.Q16HDRI Magick++-6.Q8HDRI
+ Magick++-7.Q64 Magick++-7.Q32 Magick++-7.Q64HDRI Magick++-7.Q32HDRI
Magick++-7.Q16 Magick++-7.Q8 Magick++-7.Q16HDRI Magick++-7.Q8HDRI
)
list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_Magick++_LIBRARY)
elseif(component STREQUAL "MagickWand")
FIND_IMAGEMAGICK_API(MagickWand "wand/MagickWand.h;MagickWand/MagickWand.h"
- Wand MagickWand CORE_RL_wand_
+ Wand MagickWand CORE_RL_wand_ CORE_RL_MagickWand_
+ MagickWand-6 MagickWand-7
MagickWand-Q16 MagickWand-Q8 MagickWand-Q16HDRI MagickWand-Q8HDRI
+ MagickWand-6.Q64 MagickWand-6.Q32 MagickWand-6.Q64HDRI MagickWand-6.Q32HDRI
MagickWand-6.Q16 MagickWand-6.Q8 MagickWand-6.Q16HDRI MagickWand-6.Q8HDRI
+ MagickWand-7.Q64 MagickWand-7.Q32 MagickWand-7.Q64HDRI MagickWand-7.Q32HDRI
MagickWand-7.Q16 MagickWand-7.Q8 MagickWand-7.Q16HDRI MagickWand-7.Q8HDRI
)
list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_MagickWand_LIBRARY)
elseif(component STREQUAL "MagickCore")
FIND_IMAGEMAGICK_API(MagickCore "magick/MagickCore.h;MagickCore/MagickCore.h"
- Magick MagickCore CORE_RL_magick_
+ Magick MagickCore CORE_RL_magick_ CORE_RL_MagickCore_
+ MagickCore-6 MagickCore-7
MagickCore-Q16 MagickCore-Q8 MagickCore-Q16HDRI MagickCore-Q8HDRI
+ MagickCore-6.Q64 MagickCore-6.Q32 MagickCore-6.Q64HDRI MagickCore-6.Q32HDRI
MagickCore-6.Q16 MagickCore-6.Q8 MagickCore-6.Q16HDRI MagickCore-6.Q8HDRI
+ MagickCore-7.Q64 MagickCore-7.Q32 MagickCore-7.Q64HDRI MagickCore-7.Q32HDRI
MagickCore-7.Q16 MagickCore-7.Q8 MagickCore-7.Q16HDRI MagickCore-7.Q8HDRI
)
list(APPEND ImageMagick_REQUIRED_VARS ImageMagick_MagickCore_LIBRARY)
diff --git a/Modules/FindIntl.cmake b/Modules/FindIntl.cmake
index f887721d6..3818d45ec 100644
--- a/Modules/FindIntl.cmake
+++ b/Modules/FindIntl.cmake
@@ -1,33 +1,34 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindIntl
-# --------
-#
-# Find the Gettext libintl headers and libraries.
-#
-# This module reports information about the Gettext libintl
-# installation in several variables. General variables::
-#
-# Intl_FOUND - true if the libintl headers and libraries were found
-# Intl_INCLUDE_DIRS - the directory containing the libintl headers
-# Intl_LIBRARIES - libintl libraries to be linked
-#
-# The following cache variables may also be set::
-#
-# Intl_INCLUDE_DIR - the directory containing the libintl headers
-# Intl_LIBRARY - the libintl library (if any)
-#
-# .. note::
-# On some platforms, such as Linux with GNU libc, the gettext
-# functions are present in the C standard library and libintl
-# is not required. ``Intl_LIBRARIES`` will be empty in this
-# case.
-#
-# .. note::
-# If you wish to use the Gettext tools (``msgmerge``,
-# ``msgfmt``, etc.), use :module:`FindGettext`.
+#[=======================================================================[.rst:
+FindIntl
+--------
+
+Find the Gettext libintl headers and libraries.
+
+This module reports information about the Gettext libintl
+installation in several variables. General variables::
+
+ Intl_FOUND - true if the libintl headers and libraries were found
+ Intl_INCLUDE_DIRS - the directory containing the libintl headers
+ Intl_LIBRARIES - libintl libraries to be linked
+
+The following cache variables may also be set::
+
+ Intl_INCLUDE_DIR - the directory containing the libintl headers
+ Intl_LIBRARY - the libintl library (if any)
+
+.. note::
+ On some platforms, such as Linux with GNU libc, the gettext
+ functions are present in the C standard library and libintl
+ is not required. ``Intl_LIBRARIES`` will be empty in this
+ case.
+
+.. note::
+ If you wish to use the Gettext tools (``msgmerge``,
+ ``msgfmt``, etc.), use :module:`FindGettext`.
+#]=======================================================================]
# Written by Roger Leigh <rleigh@codelibre.net>
diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake
index cebba10f0..3a5bd311c 100644
--- a/Modules/FindJNI.cmake
+++ b/Modules/FindJNI.cmake
@@ -1,31 +1,51 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindJNI
-# -------
-#
-# Find JNI java libraries.
-#
-# This module finds if Java is installed and determines where the
-# include files and libraries are. It also determines what the name of
-# the library is. The caller may set variable JAVA_HOME to specify a
-# Java installation prefix explicitly.
-#
-# This module sets the following result variables:
-#
-# ::
-#
-# JNI_INCLUDE_DIRS = the include dirs to use
-# JNI_LIBRARIES = the libraries to use
-# JNI_FOUND = TRUE if JNI headers and libraries were found.
-# JAVA_AWT_LIBRARY = the path to the jawt library
-# JAVA_JVM_LIBRARY = the path to the jvm library
-# JAVA_INCLUDE_PATH = the include path to jni.h
-# JAVA_INCLUDE_PATH2 = the include path to jni_md.h
-# JAVA_AWT_INCLUDE_PATH = the include path to jawt.h
-
-# Expand {libarch} occurences to java_libarch subdirectory(-ies) and set ${_var}
+#[=======================================================================[.rst:
+FindJNI
+-------
+
+Find Java Native Interface (JNI) libraries.
+
+JNI enables Java code running in a Java Virtual Machine (JVM) to call
+and be called by native applications and libraries written in other
+languages such as C, C++.
+
+This module finds if Java is installed and determines where the
+include files and libraries are. It also determines what the name of
+the library is. The caller may set variable ``JAVA_HOME`` to specify a
+Java installation prefix explicitly.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module sets the following result variables:
+
+``JNI_INCLUDE_DIRS``
+ the include dirs to use
+``JNI_LIBRARIES``
+ the libraries to use (JAWT and JVM)
+``JNI_FOUND``
+ TRUE if JNI headers and libraries were found.
+
+Cache Variables
+^^^^^^^^^^^^^^^
+
+The following cache variables are also available to set or use:
+
+``JAVA_AWT_LIBRARY``
+ the path to the Java AWT Native Interface (JAWT) library
+``JAVA_JVM_LIBRARY``
+ the path to the Java Virtual Machine (JVM) library
+``JAVA_INCLUDE_PATH``
+ the include path to jni.h
+``JAVA_INCLUDE_PATH2``
+ the include path to jni_md.h and jniport.h
+``JAVA_AWT_INCLUDE_PATH``
+ the include path to jawt.h
+#]=======================================================================]
+
+# Expand {libarch} occurrences to java_libarch subdirectory(-ies) and set ${_var}
macro(java_append_library_directories _var)
# Determine java arch-specific library subdir
# Mostly based on openjdk/jdk/make/common/shared/Platform.gmk as of openjdk
@@ -46,8 +66,11 @@ macro(java_append_library_directories _var)
set(_java_libarch "arm" "aarch32")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
# mips* machines are bi-endian mostly so processor does not tell
- # endianess of the underlying system.
- set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb" "mips64" "mips64el" "mipsn32" "mipsn32el")
+ # endianness of the underlying system.
+ set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}"
+ "mips" "mipsel" "mipseb" "mipsr6" "mipsr6el"
+ "mips64" "mips64el" "mips64r6" "mips64r6el"
+ "mipsn32" "mipsn32el" "mipsn32r6" "mipsn32r6el")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64le")
set(_java_libarch "ppc64" "ppc64le")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
@@ -117,49 +140,102 @@ if(_JAVA_HOME)
${_JAVA_HOME}
)
endif()
-get_filename_component(java_install_version
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME)
-list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib"
- )
-JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
- /usr/lib
- /usr/local/lib
- /usr/lib/jvm/java/lib
- /usr/lib/java/jre/lib/{libarch}
- /usr/lib/jvm/jre/lib/{libarch}
- /usr/local/lib/java/jre/lib/{libarch}
- /usr/local/share/java/jre/lib/{libarch}
- /usr/lib/j2sdk1.4-sun/jre/lib/{libarch}
- /usr/lib/j2sdk1.5-sun/jre/lib/{libarch}
- /opt/sun-jdk-1.5.0.04/jre/lib/{libarch}
- /usr/lib/jvm/java-6-sun/jre/lib/{libarch}
- /usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch}
- /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch} # can this one be removed according to #8821 ? Alex
- /usr/lib/jvm/java-6-openjdk/jre/lib/{libarch}
- /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/{libarch} # fedora
+if (WIN32)
+ set (_JNI_HINTS)
+ execute_process(COMMAND REG QUERY HKLM\\SOFTWARE\\JavaSoft\\JDK
+ RESULT_VARIABLE _JNI_RESULT
+ OUTPUT_VARIABLE _JNI_VERSIONS
+ ERROR_QUIET)
+ if (NOT _JNI_RESULT)
+ string (REGEX MATCHALL "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\JavaSoft\\\\JDK\\\\[0-9.]+" _JNI_VERSIONS "${_JNI_VERSIONS}")
+ if (_JNI_VERSIONS)
+ # sort versions. Most recent first
+ ## handle version 9 apart from other versions to get correct ordering
+ set (_JNI_V9 ${_JNI_VERSIONS})
+ list (FILTER _JNI_VERSIONS EXCLUDE REGEX "JDK\\\\9")
+ list (SORT _JNI_VERSIONS)
+ list (REVERSE _JNI_VERSIONS)
+ list (FILTER _JNI_V9 INCLUDE REGEX "JDK\\\\9")
+ list (SORT _JNI_V9)
+ list (REVERSE _JNI_V9)
+ list (APPEND _JNI_VERSIONS ${_JNI_V9})
+ foreach (_JNI_HINT IN LISTS _JNI_VERSIONS)
+ list(APPEND _JNI_HINTS "[${_JNI_HINT};JavaHome]")
+ endforeach()
+ endif()
+ endif()
+
+ foreach (_JNI_HINT IN LISTS _JNI_HINTS)
+ list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES "${_JNI_HINT}/lib")
+ endforeach()
+
+ get_filename_component(java_install_version
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME)
+
+ list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/lib"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/lib"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.7;JavaHome]/lib"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.6;JavaHome]/lib"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/lib"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib"
+ )
+endif()
+
+set(_JNI_JAVA_DIRECTORIES_BASE
+ /usr/lib/jvm/java
+ /usr/lib/java
+ /usr/lib/jvm
+ /usr/local/lib/java
+ /usr/local/share/java
+ /usr/lib/j2sdk1.4-sun
+ /usr/lib/j2sdk1.5-sun
+ /opt/sun-jdk-1.5.0.04
+ /usr/lib/jvm/java-6-sun
+ /usr/lib/jvm/java-1.5.0-sun
+ /usr/lib/jvm/java-6-sun-1.6.0.00 # can this one be removed according to #8821 ? Alex
+ /usr/lib/jvm/java-6-openjdk
+ /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0 # fedora
# Debian specific paths for default JVM
- /usr/lib/jvm/default-java/jre/lib/{libarch}
- /usr/lib/jvm/default-java/jre/lib
- /usr/lib/jvm/default-java/lib
+ /usr/lib/jvm/default-java
# Arch Linux specific paths for default JVM
- /usr/lib/jvm/default/jre/lib/{libarch}
- /usr/lib/jvm/default/lib/{libarch}
+ /usr/lib/jvm/default
# Ubuntu specific paths for default JVM
- /usr/lib/jvm/java-8-openjdk-{libarch}/jre/lib/{libarch} # Ubuntu 15.10
- /usr/lib/jvm/java-7-openjdk-{libarch}/jre/lib/{libarch} # Ubuntu 15.10
- /usr/lib/jvm/java-6-openjdk-{libarch}/jre/lib/{libarch} # Ubuntu 15.10
+ /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
+ /usr/lib/jvm/java-6-openjdk-{libarch} # Ubuntu 15.10
# OpenBSD specific paths for default JVM
- /usr/local/jdk-1.7.0/jre/lib/{libarch}
- /usr/local/jre-1.7.0/lib/{libarch}
- /usr/local/jdk-1.6.0/jre/lib/{libarch}
- /usr/local/jre-1.6.0/lib/{libarch}
+ /usr/local/jdk-1.7.0
+ /usr/local/jre-1.7.0
+ /usr/local/jdk-1.6.0
+ /usr/local/jre-1.6.0
# SuSE specific paths for default JVM
- /usr/lib64/jvm/java/jre/lib/{libarch}
- /usr/lib64/jvm/jre/lib/{libarch}
+ /usr/lib64/jvm/java
+ /usr/lib64/jvm/jre
+ )
+
+set(_JNI_JAVA_AWT_LIBRARY_TRIES)
+set(_JNI_JAVA_INCLUDE_TRIES)
+
+foreach(_java_dir IN LISTS _JNI_JAVA_DIRECTORIES_BASE)
+ list(APPEND _JNI_JAVA_AWT_LIBRARY_TRIES
+ ${_java_dir}/jre/lib/{libarch}
+ ${_java_dir}/jre/lib
+ ${_java_dir}/lib/{libarch}
+ ${_java_dir}/lib
+ ${_java_dir}
+ )
+ list(APPEND _JNI_JAVA_INCLUDE_TRIES
+ ${_java_dir}/include
+ )
+endforeach()
+
+JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
+ ${_JNI_JAVA_AWT_LIBRARY_TRIES}
)
set(JAVA_JVM_LIBRARY_DIRECTORIES)
@@ -178,38 +254,24 @@ set(JAVA_AWT_INCLUDE_DIRECTORIES)
if(_JAVA_HOME)
list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES ${_JAVA_HOME}/include)
endif()
-list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
-)
+if (WIN32)
+ foreach (_JNI_HINT IN LISTS _JNI_HINTS)
+ list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES "${_JNI_HINT}/include")
+ endforeach()
+ list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.7;JavaHome]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.6;JavaHome]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
+ )
+endif()
JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_INCLUDE_DIRECTORIES
- /usr/include
- /usr/local/include
- /usr/lib/java/include
- /usr/local/lib/java/include
- /usr/lib/jvm/java/include
- /usr/lib/jvm/java-6-sun/include
- /usr/lib/jvm/java-1.5.0-sun/include
- /usr/lib/jvm/java-6-sun-1.6.0.00/include # can this one be removed according to #8821 ? Alex
- /usr/lib/jvm/java-6-openjdk/include
- /usr/lib/jvm/java-8-openjdk-{libarch}/include # ubuntu 15.10
- /usr/lib/jvm/java-7-openjdk-{libarch}/include # ubuntu 15.10
- /usr/lib/jvm/java-6-openjdk-{libarch}/include # ubuntu 15.10
- /usr/local/share/java/include
- /usr/lib/j2sdk1.4-sun/include
- /usr/lib/j2sdk1.5-sun/include
- /opt/sun-jdk-1.5.0.04/include
- # Debian specific path for default JVM
- /usr/lib/jvm/default-java/include
- # Arch specific path for default JVM
- /usr/lib/jvm/default/include
- # OpenBSD specific path for default JVM
- /usr/local/jdk-1.7.0/include
- /usr/local/jdk-1.6.0/include
- # SuSE specific paths for default JVM
- /usr/lib64/jvm/java/include
+ ${_JNI_JAVA_INCLUDE_TRIES}
)
foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
@@ -331,4 +393,3 @@ set(JNI_INCLUDE_DIRS
${JAVA_INCLUDE_PATH2}
${JAVA_AWT_INCLUDE_PATH}
)
-
diff --git a/Modules/FindJPEG.cmake b/Modules/FindJPEG.cmake
index e233714e0..0bb698979 100644
--- a/Modules/FindJPEG.cmake
+++ b/Modules/FindJPEG.cmake
@@ -1,42 +1,136 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindJPEG
-# --------
-#
-# Find JPEG
-#
-# Find the native JPEG includes and library This module defines
-#
-# ::
-#
-# JPEG_INCLUDE_DIR, where to find jpeglib.h, etc.
-# JPEG_LIBRARIES, the libraries needed to use JPEG.
-# JPEG_FOUND, If false, do not try to use JPEG.
-#
-# also defined, but not for general use are
-#
-# ::
-#
-# JPEG_LIBRARY, where to find the JPEG library.
+#[=======================================================================[.rst:
+FindJPEG
+--------
+
+Find the Joint Photographic Experts Group (JPEG) library (``libjpeg``)
+
+Imported targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` targets:
+
+``JPEG::JPEG``
+ The JPEG library, if found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``JPEG_FOUND``
+ If false, do not try to use JPEG.
+``JPEG_INCLUDE_DIRS``
+ where to find jpeglib.h, etc.
+``JPEG_LIBRARIES``
+ the libraries needed to use JPEG.
+``JPEG_VERSION``
+ the version of the JPEG library found
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``JPEG_INCLUDE_DIRS``
+ where to find jpeglib.h, etc.
+``JPEG_LIBRARY_RELEASE``
+ where to find the JPEG library (optimized).
+``JPEG_LIBRARY_DEBUG``
+ where to find the JPEG library (debug).
+
+Obsolete variables
+^^^^^^^^^^^^^^^^^^
+
+``JPEG_INCLUDE_DIR``
+ where to find jpeglib.h, etc. (same as JPEG_INCLUDE_DIRS)
+``JPEG_LIBRARY``
+ where to find the JPEG library.
+#]=======================================================================]
find_path(JPEG_INCLUDE_DIR jpeglib.h)
-set(JPEG_NAMES ${JPEG_NAMES} jpeg libjpeg)
-find_library(JPEG_LIBRARY NAMES ${JPEG_NAMES} )
+set(jpeg_names ${JPEG_NAMES} jpeg jpeg-static libjpeg libjpeg-static)
+foreach(name ${jpeg_names})
+ list(APPEND jpeg_names_debug "${name}d")
+endforeach()
+
+if(NOT JPEG_LIBRARY)
+ find_library(JPEG_LIBRARY_RELEASE NAMES ${jpeg_names})
+ find_library(JPEG_LIBRARY_DEBUG NAMES ${jpeg_names_debug})
+ include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
+ select_library_configurations(JPEG)
+ mark_as_advanced(JPEG_LIBRARY_RELEASE JPEG_LIBRARY_DEBUG)
+endif()
+unset(jpeg_names)
+unset(jpeg_names_debug)
+
+if(JPEG_INCLUDE_DIR)
+ file(GLOB _JPEG_CONFIG_HEADERS_FEDORA "${JPEG_INCLUDE_DIR}/jconfig*.h")
+ file(GLOB _JPEG_CONFIG_HEADERS_DEBIAN "${JPEG_INCLUDE_DIR}/*/jconfig.h")
+ set(_JPEG_CONFIG_HEADERS
+ "${JPEG_INCLUDE_DIR}/jpeglib.h"
+ ${_JPEG_CONFIG_HEADERS_FEDORA}
+ ${_JPEG_CONFIG_HEADERS_DEBIAN})
+ foreach (_JPEG_CONFIG_HEADER IN LISTS _JPEG_CONFIG_HEADERS)
+ if (NOT EXISTS "${_JPEG_CONFIG_HEADER}")
+ continue ()
+ endif ()
+ file(STRINGS "${_JPEG_CONFIG_HEADER}"
+ jpeg_lib_version REGEX "^#define[\t ]+JPEG_LIB_VERSION[\t ]+.*")
+
+ if (NOT jpeg_lib_version)
+ continue ()
+ endif ()
+
+ string(REGEX REPLACE "^#define[\t ]+JPEG_LIB_VERSION[\t ]+([0-9]+).*"
+ "\\1" JPEG_VERSION "${jpeg_lib_version}")
+ break ()
+ endforeach ()
+ unset(jpeg_lib_version)
+ unset(_JPEG_CONFIG_HEADER)
+ unset(_JPEG_CONFIG_HEADERS)
+ unset(_JPEG_CONFIG_HEADERS_FEDORA)
+ unset(_JPEG_CONFIG_HEADERS_DEBIAN)
+endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(JPEG DEFAULT_MSG JPEG_LIBRARY JPEG_INCLUDE_DIR)
+find_package_handle_standard_args(JPEG
+ REQUIRED_VARS JPEG_LIBRARY JPEG_INCLUDE_DIR
+ VERSION_VAR JPEG_VERSION)
if(JPEG_FOUND)
set(JPEG_LIBRARIES ${JPEG_LIBRARY})
-endif()
+ set(JPEG_INCLUDE_DIRS "${JPEG_INCLUDE_DIR}")
-# Deprecated declarations.
-set (NATIVE_JPEG_INCLUDE_PATH ${JPEG_INCLUDE_DIR} )
-if(JPEG_LIBRARY)
- get_filename_component (NATIVE_JPEG_LIB_PATH ${JPEG_LIBRARY} PATH)
+ if(NOT TARGET JPEG::JPEG)
+ add_library(JPEG::JPEG UNKNOWN IMPORTED)
+ if(JPEG_INCLUDE_DIRS)
+ set_target_properties(JPEG::JPEG PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${JPEG_INCLUDE_DIRS}")
+ endif()
+ if(EXISTS "${JPEG_LIBRARY}")
+ set_target_properties(JPEG::JPEG PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${JPEG_LIBRARY}")
+ endif()
+ if(EXISTS "${JPEG_LIBRARY_RELEASE}")
+ set_property(TARGET JPEG::JPEG APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(JPEG::JPEG PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
+ IMPORTED_LOCATION_RELEASE "${JPEG_LIBRARY_RELEASE}")
+ endif()
+ if(EXISTS "${JPEG_LIBRARY_DEBUG}")
+ set_property(TARGET JPEG::JPEG APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(JPEG::JPEG PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
+ IMPORTED_LOCATION_DEBUG "${JPEG_LIBRARY_DEBUG}")
+ endif()
+ endif()
endif()
-mark_as_advanced(JPEG_LIBRARY JPEG_INCLUDE_DIR )
+mark_as_advanced(JPEG_LIBRARY JPEG_INCLUDE_DIR)
diff --git a/Modules/FindJasper.cmake b/Modules/FindJasper.cmake
index db766576b..729a50350 100644
--- a/Modules/FindJasper.cmake
+++ b/Modules/FindJasper.cmake
@@ -1,20 +1,21 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindJasper
-# ----------
-#
-# Try to find the Jasper JPEG2000 library
-#
-# Once done this will define
-#
-# ::
-#
-# JASPER_FOUND - system has Jasper
-# JASPER_INCLUDE_DIR - the Jasper include directory
-# JASPER_LIBRARIES - the libraries needed to use Jasper
-# JASPER_VERSION_STRING - the version of Jasper found (since CMake 2.8.8)
+#[=======================================================================[.rst:
+FindJasper
+----------
+
+Try to find the Jasper JPEG2000 library
+
+Once done this will define
+
+::
+
+ JASPER_FOUND - system has Jasper
+ JASPER_INCLUDE_DIR - the Jasper include directory
+ JASPER_LIBRARIES - the libraries needed to use Jasper
+ JASPER_VERSION_STRING - the version of Jasper found (since CMake 2.8.8)
+#]=======================================================================]
find_path(JASPER_INCLUDE_DIR jasper/jasper.h)
@@ -40,7 +41,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Jasper
VERSION_VAR JASPER_VERSION_STRING)
if (JASPER_FOUND)
- set(JASPER_LIBRARIES ${JASPER_LIBRARIES} ${JPEG_LIBRARIES} )
+ set(JASPER_LIBRARIES ${JASPER_LIBRARIES} ${JPEG_LIBRARIES} )
endif ()
mark_as_advanced(JASPER_INCLUDE_DIR)
diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake
index eb2242bf5..945df3c98 100644
--- a/Modules/FindJava.cmake
+++ b/Modules/FindJava.cmake
@@ -1,74 +1,80 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindJava
-# --------
-#
-# Find Java
-#
-# This module finds if Java is installed and determines where the
-# include files and libraries are. The caller may set variable JAVA_HOME
-# to specify a Java installation prefix explicitly.
-#
-# See also the :module:`FindJNI` module to find Java development tools.
-#
-# Specify one or more of the following components as you call this find module. See example below.
-#
-# ::
-#
-# Runtime = User just want to execute some Java byte-compiled
-# Development = Development tools (java, javac, javah and javadoc), includes Runtime component
-# IdlJ = idl compiler for Java
-# JarSigner = signer tool for jar
-#
-#
-# This module sets the following result variables:
-#
-# ::
-#
-# Java_JAVA_EXECUTABLE = the full path to the Java runtime
-# Java_JAVAC_EXECUTABLE = the full path to the Java compiler
-# Java_JAVAH_EXECUTABLE = the full path to the Java header generator
-# Java_JAVADOC_EXECUTABLE = the full path to the Java documentation generator
-# Java_IDLJ_EXECUTABLE = the full path to the Java idl compiler
-# Java_JAR_EXECUTABLE = the full path to the Java archiver
-# Java_JARSIGNER_EXECUTABLE = the full path to the Java jar signer
-# Java_VERSION_STRING = Version of java found, eg. 1.6.0_12
-# Java_VERSION_MAJOR = The major version of the package found.
-# Java_VERSION_MINOR = The minor version of the package found.
-# Java_VERSION_PATCH = The patch version of the package found.
-# Java_VERSION_TWEAK = The tweak version of the package found (after '_')
-# Java_VERSION = This is set to: $major.$minor.$patch(.$tweak)
-#
-#
-#
-# The minimum required version of Java can be specified using the
-# standard CMake syntax, e.g. find_package(Java 1.5)
-#
-# NOTE: ${Java_VERSION} and ${Java_VERSION_STRING} are not guaranteed to
-# be identical. For example some java version may return:
-# Java_VERSION_STRING = 1.5.0_17 and Java_VERSION = 1.5.0.17
-#
-# another example is the Java OEM, with: Java_VERSION_STRING = 1.6.0-oem
-# and Java_VERSION = 1.6.0
-#
-# For these components the following variables are set:
-#
-# ::
-#
-# Java_FOUND - TRUE if all components are found.
-# Java_<component>_FOUND - TRUE if <component> is found.
-#
-#
-#
-# Example Usages:
-#
-# ::
-#
-# find_package(Java)
-# find_package(Java COMPONENTS Runtime)
-# find_package(Java COMPONENTS Development)
+#[=======================================================================[.rst:
+FindJava
+--------
+
+Find Java
+
+This module finds if Java is installed and determines where the
+include files and libraries are. The caller may set variable ``JAVA_HOME``
+to specify a Java installation prefix explicitly.
+
+See also the :module:`FindJNI` module to find Java Native Interface (JNI).
+
+Specify one or more of the following components as you call this find module. See example below.
+
+::
+
+ Runtime = Java Runtime Environment used to execute Java byte-compiled applications
+ Development = Development tools (java, javac, javah, jar and javadoc), includes Runtime component
+ IdlJ = Interface Description Language (IDL) to Java compiler
+ JarSigner = Signer and verifier tool for Java Archive (JAR) files
+
+
+This module sets the following result variables:
+
+::
+
+ Java_JAVA_EXECUTABLE = the full path to the Java runtime
+ Java_JAVAC_EXECUTABLE = the full path to the Java compiler
+ Java_JAVAH_EXECUTABLE = the full path to the Java header generator
+ Java_JAVADOC_EXECUTABLE = the full path to the Java documentation generator
+ Java_IDLJ_EXECUTABLE = the full path to the Java idl compiler
+ Java_JAR_EXECUTABLE = the full path to the Java archiver
+ Java_JARSIGNER_EXECUTABLE = the full path to the Java jar signer
+ Java_VERSION_STRING = Version of java found, eg. 1.6.0_12
+ Java_VERSION_MAJOR = The major version of the package found.
+ Java_VERSION_MINOR = The minor version of the package found.
+ Java_VERSION_PATCH = The patch version of the package found.
+ Java_VERSION_TWEAK = The tweak version of the package found (after '_')
+ Java_VERSION = This is set to: $major[.$minor[.$patch[.$tweak]]]
+
+
+
+The minimum required version of Java can be specified using the
+:command:`find_package` syntax, e.g.
+
+.. code-block:: cmake
+
+ find_package(Java 1.8)
+
+NOTE: ``${Java_VERSION}`` and ``${Java_VERSION_STRING}`` are not guaranteed to
+be identical. For example some java version may return:
+``Java_VERSION_STRING = 1.8.0_17`` and ``Java_VERSION = 1.8.0.17``
+
+another example is the Java OEM, with: ``Java_VERSION_STRING = 1.8.0-oem``
+and ``Java_VERSION = 1.8.0``
+
+For these components the following variables are set:
+
+::
+
+ Java_FOUND - TRUE if all components are found.
+ Java_<component>_FOUND - TRUE if <component> is found.
+
+
+
+Example Usages:
+
+::
+
+ find_package(Java)
+ find_package(Java 1.8 REQUIRED)
+ find_package(Java COMPONENTS Runtime)
+ find_package(Java COMPONENTS Development)
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindJavaCommon.cmake)
@@ -77,8 +83,37 @@ set(_JAVA_HINTS)
if(_JAVA_HOME)
list(APPEND _JAVA_HINTS ${_JAVA_HOME}/bin)
endif()
-list(APPEND _JAVA_HINTS
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\2.0;JavaHome]/bin"
+if (WIN32)
+ macro (_JAVA_GET_INSTALLED_VERSIONS _KIND)
+ execute_process(COMMAND REG QUERY HKLM\\SOFTWARE\\JavaSoft\\${_KIND}
+ RESULT_VARIABLE _JAVA_RESULT
+ OUTPUT_VARIABLE _JAVA_VERSIONS
+ ERROR_QUIET)
+ if (NOT _JAVA_RESULT)
+ string (REGEX MATCHALL "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\JavaSoft\\\\${_KIND}\\\\[0-9.]+" _JAVA_VERSIONS "${_JAVA_VERSIONS}")
+ if (_JAVA_VERSIONS)
+ # sort versions. Most recent first
+ ## handle version 9 apart from other versions to get correct ordering
+ set (_JAVA_V9 ${_JAVA_VERSIONS})
+ list (FILTER _JAVA_VERSIONS EXCLUDE REGEX "${_KIND}\\\\9")
+ list (SORT _JAVA_VERSIONS)
+ list (REVERSE _JAVA_VERSIONS)
+ list (FILTER _JAVA_V9 INCLUDE REGEX "${_KIND}\\\\9")
+ list (SORT _JAVA_V9)
+ list (REVERSE _JAVA_V9)
+ list (APPEND _JAVA_VERSIONS ${_JAVA_V9})
+ foreach (_JAVA_HINT IN LISTS _JAVA_VERSIONS)
+ list(APPEND _JAVA_HINTS "[${_JAVA_HINT};JavaHome]/bin")
+ endforeach()
+ endif()
+ endif()
+ endmacro()
+
+ # search for installed versions for version 9 and upper
+ _JAVA_GET_INSTALLED_VERSIONS("JDK")
+ _JAVA_GET_INSTALLED_VERSIONS("JRE")
+
+ list(APPEND _JAVA_HINTS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.7;JavaHome]/bin"
@@ -86,7 +121,6 @@ list(APPEND _JAVA_HINTS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\2.0;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.9;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.8;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.7;JavaHome]/bin"
@@ -95,6 +129,8 @@ list(APPEND _JAVA_HINTS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.4;JavaHome]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.3;JavaHome]/bin"
)
+endif()
+
# Hard-coded guesses should still go in PATHS. This ensures that the user
# environment can always override hard guesses.
set(_JAVA_PATHS
@@ -117,7 +153,7 @@ find_program(Java_JAVA_EXECUTABLE
)
if(Java_JAVA_EXECUTABLE)
- execute_process(COMMAND ${Java_JAVA_EXECUTABLE} -version
+ execute_process(COMMAND "${Java_JAVA_EXECUTABLE}" -version
RESULT_VARIABLE res
OUTPUT_VARIABLE var
ERROR_VARIABLE var # sun-java output to stderr
@@ -133,39 +169,72 @@ if(Java_JAVA_EXECUTABLE)
message( STATUS "Warning, could not run java -version")
endif()
else()
- # extract major/minor version and patch level from "java -version" output
- # Tested on linux using
- # 1. Sun / Sun OEM
- # 2. OpenJDK 1.6
- # 3. GCJ 1.5
- # 4. Kaffe 1.4.2
- # 5. OpenJDK 1.7.x on OpenBSD
- if(var MATCHES "java version \"([0-9]+\\.[0-9]+\\.[0-9_.]+.*)\"")
- # This is most likely Sun / OpenJDK, or maybe GCJ-java compat layer
+ # Extract version components (up to 4 levels) from "java -version" output.
+ set(_java_version_regex [[(([0-9]+)(\.([0-9]+)(\.([0-9]+)(_([0-9]+))?)?)?.*)]])
+ if(var MATCHES "java version \"${_java_version_regex}\"")
+ # Sun, GCJ, older OpenJDK
+ set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
+ set(Java_VERSION_MAJOR "${CMAKE_MATCH_2}")
+ if (CMAKE_MATCH_4)
+ set(Java_VERSION_MINOR "${CMAKE_MATCH_4}")
+ else()
+ set(Java_VERSION_MINOR 0)
+ endif()
+ if (CMAKE_MATCH_6)
+ set(Java_VERSION_PATCH "${CMAKE_MATCH_6}")
+ else()
+ set(Java_VERSION_PATCH 0)
+ endif()
+ set(Java_VERSION_TWEAK "${CMAKE_MATCH_8}")
+ elseif(var MATCHES "openjdk version \"${_java_version_regex}\"")
+ # OpenJDK
set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
+ set(Java_VERSION_MAJOR "${CMAKE_MATCH_2}")
+ if (CMAKE_MATCH_4)
+ set(Java_VERSION_MINOR "${CMAKE_MATCH_4}")
+ else()
+ set(Java_VERSION_MINOR 0)
+ endif()
+ if (CMAKE_MATCH_6)
+ set(Java_VERSION_PATCH "${CMAKE_MATCH_6}")
+ else()
+ set(Java_VERSION_PATCH 0)
+ endif()
+ set(Java_VERSION_TWEAK "${CMAKE_MATCH_8}")
elseif(var MATCHES "openjdk version \"([0-9]+)-[A-Za-z]+\"")
# OpenJDK 9 early access builds or locally built
set(Java_VERSION_STRING "1.${CMAKE_MATCH_1}.0")
- elseif(var MATCHES "java full version \"kaffe-([0-9]+\\.[0-9]+\\.[0-9_]+)\"")
+ set(Java_VERSION_MAJOR "1")
+ set(Java_VERSION_MINOR "${CMAKE_MATCH_1}")
+ set(Java_VERSION_PATCH "0")
+ set(Java_VERSION_TWEAK "")
+ elseif(var MATCHES "java full version \"kaffe-${_java_version_regex}\"")
# Kaffe style
set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
- elseif(var MATCHES "openjdk version \"([0-9]+\\.[0-9]+\\.[0-9_]+.*)\"")
- # OpenJDK ver 1.7.x on OpenBSD
- set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
+ set(Java_VERSION_MAJOR "${CMAKE_MATCH_2}")
+ set(Java_VERSION_MINOR "${CMAKE_MATCH_4}")
+ set(Java_VERSION_PATCH "${CMAKE_MATCH_6}")
+ set(Java_VERSION_TWEAK "${CMAKE_MATCH_8}")
else()
if(NOT Java_FIND_QUIETLY)
- message(WARNING "regex not supported: ${var}. Please report")
+ string(REPLACE "\n" "\n " ver_msg "\n${var}")
+ message(WARNING "Java version not recognized:${ver_msg}\nPlease report.")
endif()
+ set(Java_VERSION_STRING "")
+ set(Java_VERSION_MAJOR "")
+ set(Java_VERSION_MINOR "")
+ set(Java_VERSION_PATCH "")
+ set(Java_VERSION_TWEAK "")
endif()
- string( REGEX REPLACE "([0-9]+).*" "\\1" Java_VERSION_MAJOR "${Java_VERSION_STRING}" )
- string( REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" Java_VERSION_MINOR "${Java_VERSION_STRING}" )
- string( REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" Java_VERSION_PATCH "${Java_VERSION_STRING}" )
- # warning tweak version can be empty:
- string( REGEX REPLACE "[0-9]+\\.[0-9]+\\.[0-9]+[_\\.]?([0-9]*).*$" "\\1" Java_VERSION_TWEAK "${Java_VERSION_STRING}" )
- if( Java_VERSION_TWEAK STREQUAL "" ) # check case where tweak is not defined
- set(Java_VERSION ${Java_VERSION_MAJOR}.${Java_VERSION_MINOR}.${Java_VERSION_PATCH})
- else()
- set(Java_VERSION ${Java_VERSION_MAJOR}.${Java_VERSION_MINOR}.${Java_VERSION_PATCH}.${Java_VERSION_TWEAK})
+ set(Java_VERSION "${Java_VERSION_MAJOR}")
+ if(NOT "x${Java_VERSION}" STREQUAL "x")
+ foreach(c MINOR PATCH TWEAK)
+ if(NOT "x${Java_VERSION_${c}}" STREQUAL "x")
+ string(APPEND Java_VERSION ".${Java_VERSION_${c}}")
+ else()
+ break()
+ endif()
+ endforeach()
endif()
endif()
@@ -220,10 +289,18 @@ if(Java_FIND_COMPONENTS)
endif()
elseif(component STREQUAL "Development")
list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAVAC_EXECUTABLE
- Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
- if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE
- AND Java_JAVAH_EXECUTABLE AND Java_JAVADOC_EXECUTABLE)
- set(Java_Development_FOUND TRUE)
+ Java_JAR_EXECUTABLE Java_JAVADOC_EXECUTABLE)
+ if(Java_VERSION VERSION_LESS "10")
+ list(APPEND _JAVA_REQUIRED_VARS Java_JAVAH_EXECUTABLE)
+ if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE
+ AND Java_JAVAH_EXECUTABLE AND Java_JAR_EXECUTABLE AND Java_JAVADOC_EXECUTABLE)
+ set(Java_Development_FOUND TRUE)
+ endif()
+ else()
+ if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE
+ AND Java_JAR_EXECUTABLE AND Java_JAVADOC_EXECUTABLE)
+ set(Java_Development_FOUND TRUE)
+ endif()
endif()
elseif(component STREQUAL "IdlJ")
list(APPEND _JAVA_REQUIRED_VARS Java_IDLJ_EXECUTABLE)
@@ -251,11 +328,19 @@ if(Java_FIND_COMPONENTS)
endif()
else()
# Check for Development
- find_package_handle_standard_args(Java
- REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE
- Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE
- VERSION_VAR Java_VERSION
- )
+ if(Java_VERSION VERSION_LESS "10")
+ find_package_handle_standard_args(Java
+ REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE
+ Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE
+ VERSION_VAR Java_VERSION_STRING
+ )
+ else()
+ find_package_handle_standard_args(Java
+ REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE
+ Java_JAVADOC_EXECUTABLE
+ VERSION_VAR Java_VERSION_STRING
+ )
+ endif()
endif()
diff --git a/Modules/FindKDE3.cmake b/Modules/FindKDE3.cmake
index 03216a5c1..30ea5e62f 100644
--- a/Modules/FindKDE3.cmake
+++ b/Modules/FindKDE3.cmake
@@ -1,144 +1,145 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindKDE3
-# --------
-#
-# Find the KDE3 include and library dirs, KDE preprocessors and define a some macros
-#
-#
-#
-# This module defines the following variables:
-#
-# ``KDE3_DEFINITIONS``
-# compiler definitions required for compiling KDE software
-# ``KDE3_INCLUDE_DIR``
-# the KDE include directory
-# ``KDE3_INCLUDE_DIRS``
-# the KDE and the Qt include directory, for use with include_directories()
-# ``KDE3_LIB_DIR``
-# the directory where the KDE libraries are installed, for use with link_directories()
-# ``QT_AND_KDECORE_LIBS``
-# this contains both the Qt and the kdecore library
-# ``KDE3_DCOPIDL_EXECUTABLE``
-# the dcopidl executable
-# ``KDE3_DCOPIDL2CPP_EXECUTABLE``
-# the dcopidl2cpp executable
-# ``KDE3_KCFGC_EXECUTABLE``
-# the kconfig_compiler executable
-# ``KDE3_FOUND``
-# set to TRUE if all of the above has been found
-#
-# The following user adjustable options are provided:
-#
-# ``KDE3_BUILD_TESTS``
-# enable this to build KDE testcases
-#
-# It also adds the following macros (from KDE3Macros.cmake) SRCS_VAR is
-# always the variable which contains the list of source files for your
-# application or library.
-#
-# KDE3_AUTOMOC(file1 ... fileN)
-#
-# ::
-#
-# Call this if you want to have automatic moc file handling.
-# This means if you include "foo.moc" in the source file foo.cpp
-# a moc file for the header foo.h will be created automatically.
-# You can set the property SKIP_AUTOMAKE using set_source_files_properties()
-# to exclude some files in the list from being processed.
-#
-#
-#
-# KDE3_ADD_MOC_FILES(SRCS_VAR file1 ... fileN )
-#
-# ::
-#
-# If you don't use the KDE3_AUTOMOC() macro, for the files
-# listed here moc files will be created (named "foo.moc.cpp")
-#
-#
-#
-# KDE3_ADD_DCOP_SKELS(SRCS_VAR header1.h ... headerN.h )
-#
-# ::
-#
-# Use this to generate DCOP skeletions from the listed headers.
-#
-#
-#
-# KDE3_ADD_DCOP_STUBS(SRCS_VAR header1.h ... headerN.h )
-#
-# ::
-#
-# Use this to generate DCOP stubs from the listed headers.
-#
-#
-#
-# KDE3_ADD_UI_FILES(SRCS_VAR file1.ui ... fileN.ui )
-#
-# ::
-#
-# Use this to add the Qt designer ui files to your application/library.
-#
-#
-#
-# KDE3_ADD_KCFG_FILES(SRCS_VAR file1.kcfgc ... fileN.kcfgc )
-#
-# ::
-#
-# Use this to add KDE kconfig compiler files to your application/library.
-#
-#
-#
-# KDE3_INSTALL_LIBTOOL_FILE(target)
-#
-# ::
-#
-# This will create and install a simple libtool file for the given target.
-#
-#
-#
-# KDE3_ADD_EXECUTABLE(name file1 ... fileN )
-#
-# ::
-#
-# Currently identical to add_executable(), may provide some advanced
-# features in the future.
-#
-#
-#
-# KDE3_ADD_KPART(name [WITH_PREFIX] file1 ... fileN )
-#
-# ::
-#
-# Create a KDE plugin (KPart, kioslave, etc.) from the given source files.
-# If WITH_PREFIX is given, the resulting plugin will have the prefix "lib",
-# otherwise it won't.
-# It creates and installs an appropriate libtool la-file.
-#
-#
-#
-# KDE3_ADD_KDEINIT_EXECUTABLE(name file1 ... fileN )
-#
-# ::
-#
-# Create a KDE application in the form of a module loadable via kdeinit.
-# A library named kdeinit_<name> will be created and a small executable
-# which links to it.
-#
-#
-#
-# The option KDE3_ENABLE_FINAL to enable all-in-one compilation is no
-# longer supported.
-#
-#
-#
-# Author: Alexander Neundorf <neundorf@kde.org>
+#[=======================================================================[.rst:
+FindKDE3
+--------
+
+Find the KDE3 include and library dirs, KDE preprocessors and define a some macros
+
+
+
+This module defines the following variables:
+
+``KDE3_DEFINITIONS``
+ compiler definitions required for compiling KDE software
+``KDE3_INCLUDE_DIR``
+ the KDE include directory
+``KDE3_INCLUDE_DIRS``
+ the KDE and the Qt include directory, for use with include_directories()
+``KDE3_LIB_DIR``
+ the directory where the KDE libraries are installed, for use with link_directories()
+``QT_AND_KDECORE_LIBS``
+ this contains both the Qt and the kdecore library
+``KDE3_DCOPIDL_EXECUTABLE``
+ the dcopidl executable
+``KDE3_DCOPIDL2CPP_EXECUTABLE``
+ the dcopidl2cpp executable
+``KDE3_KCFGC_EXECUTABLE``
+ the kconfig_compiler executable
+``KDE3_FOUND``
+ set to TRUE if all of the above has been found
+
+The following user adjustable options are provided:
+
+``KDE3_BUILD_TESTS``
+ enable this to build KDE testcases
+
+It also adds the following macros (from ``KDE3Macros.cmake``) ``SRCS_VAR`` is
+always the variable which contains the list of source files for your
+application or library.
+
+KDE3_AUTOMOC(file1 ... fileN)
+
+::
+
+ Call this if you want to have automatic moc file handling.
+ This means if you include "foo.moc" in the source file foo.cpp
+ a moc file for the header foo.h will be created automatically.
+ You can set the property SKIP_AUTOMAKE using set_source_files_properties()
+ to exclude some files in the list from being processed.
+
+
+
+KDE3_ADD_MOC_FILES(SRCS_VAR file1 ... fileN )
+
+::
+
+ If you don't use the KDE3_AUTOMOC() macro, for the files
+ listed here moc files will be created (named "foo.moc.cpp")
+
+
+
+KDE3_ADD_DCOP_SKELS(SRCS_VAR header1.h ... headerN.h )
+
+::
+
+ Use this to generate DCOP skeletions from the listed headers.
+
+
+
+KDE3_ADD_DCOP_STUBS(SRCS_VAR header1.h ... headerN.h )
+
+::
+
+ Use this to generate DCOP stubs from the listed headers.
+
+
+
+KDE3_ADD_UI_FILES(SRCS_VAR file1.ui ... fileN.ui )
+
+::
+
+ Use this to add the Qt designer ui files to your application/library.
+
+
+
+KDE3_ADD_KCFG_FILES(SRCS_VAR file1.kcfgc ... fileN.kcfgc )
+
+::
+
+ Use this to add KDE kconfig compiler files to your application/library.
+
+
+
+KDE3_INSTALL_LIBTOOL_FILE(target)
+
+::
+
+ This will create and install a simple libtool file for the given target.
+
+
+
+KDE3_ADD_EXECUTABLE(name file1 ... fileN )
+
+::
+
+ Currently identical to add_executable(), may provide some advanced
+ features in the future.
+
+
+
+KDE3_ADD_KPART(name [WITH_PREFIX] file1 ... fileN )
+
+::
+
+ Create a KDE plugin (KPart, kioslave, etc.) from the given source files.
+ If WITH_PREFIX is given, the resulting plugin will have the prefix "lib",
+ otherwise it won't.
+ It creates and installs an appropriate libtool la-file.
+
+
+
+KDE3_ADD_KDEINIT_EXECUTABLE(name file1 ... fileN )
+
+::
+
+ Create a KDE application in the form of a module loadable via kdeinit.
+ A library named kdeinit_<name> will be created and a small executable
+ which links to it.
+
+
+
+The option KDE3_ENABLE_FINAL to enable all-in-one compilation is no
+longer supported.
+
+
+
+Author: Alexander Neundorf <neundorf@kde.org>
+#]=======================================================================]
if(NOT UNIX AND KDE3_FIND_REQUIRED)
- message(FATAL_ERROR "Compiling KDE3 applications and libraries under Windows is not supported")
+ message(FATAL_ERROR "Compiling KDE3 applications and libraries under Windows is not supported")
endif()
# If Qt4 has already been found, fail.
@@ -169,24 +170,24 @@ find_package(X11 ${_REQ_STRING_KDE3})
#now try to find some kde stuff
find_program(KDECONFIG_EXECUTABLE NAMES kde-config
HINTS
- $ENV{KDEDIR}/bin
- PATHS
- /opt/kde3/bin
- /opt/kde/bin
+ $ENV{KDEDIR}/bin
+ PATHS
+ /opt/kde3/bin
+ /opt/kde/bin
)
set(KDE3PREFIX)
if(KDECONFIG_EXECUTABLE)
- execute_process(COMMAND ${KDECONFIG_EXECUTABLE} --version
- OUTPUT_VARIABLE kde_config_version )
+ execute_process(COMMAND ${KDECONFIG_EXECUTABLE} --version
+ OUTPUT_VARIABLE kde_config_version )
- string(REGEX MATCH "KDE: .\\." kde_version "${kde_config_version}")
- if ("${kde_version}" MATCHES "KDE: 3\\.")
- execute_process(COMMAND ${KDECONFIG_EXECUTABLE} --prefix
- OUTPUT_VARIABLE kdedir )
- string(REPLACE "\n" "" KDE3PREFIX "${kdedir}")
+ string(REGEX MATCH "KDE: .\\." kde_version "${kde_config_version}")
+ if ("${kde_version}" MATCHES "KDE: 3\\.")
+ execute_process(COMMAND ${KDECONFIG_EXECUTABLE} --prefix
+ OUTPUT_VARIABLE kdedir )
+ string(REPLACE "\n" "" KDE3PREFIX "${kdedir}")
- endif ()
+ endif ()
endif()
@@ -195,23 +196,22 @@ endif()
# kpassdlg.h comes from kdeui and doesn't exist in KDE4 anymore
find_path(KDE3_INCLUDE_DIR kpassdlg.h
HINTS
- $ENV{KDEDIR}/include
- ${KDE3PREFIX}/include
+ $ENV{KDEDIR}/include
+ ${KDE3PREFIX}/include
PATHS
- /opt/kde3/include
- /opt/kde/include
- /usr/include/kde
- /usr/local/include/kde
+ /opt/kde3/include
+ /opt/kde/include
+ PATH_SUFFIXES include/kde
)
#now the KDE library directory
find_library(KDE3_KDECORE_LIBRARY NAMES kdecore
HINTS
- $ENV{KDEDIR}/lib
- ${KDE3PREFIX}/lib
+ $ENV{KDEDIR}/lib
+ ${KDE3PREFIX}/lib
PATHS
- /opt/kde3/lib
- /opt/kde/lib
+ /opt/kde3/lib
+ /opt/kde/lib
)
set(QT_AND_KDECORE_LIBS ${QT_LIBRARIES} ${KDE3_KDECORE_LIBRARY})
@@ -219,49 +219,49 @@ set(QT_AND_KDECORE_LIBS ${QT_LIBRARIES} ${KDE3_KDECORE_LIBRARY})
get_filename_component(KDE3_LIB_DIR ${KDE3_KDECORE_LIBRARY} PATH )
if(NOT KDE3_LIBTOOL_DIR)
- if(KDE3_KDECORE_LIBRARY MATCHES lib64)
- set(KDE3_LIBTOOL_DIR /lib64/kde3)
- elseif(KDE3_KDECORE_LIBRARY MATCHES libx32)
- set(KDE3_LIBTOOL_DIR /libx32/kde3)
- else()
- set(KDE3_LIBTOOL_DIR /lib/kde3)
- endif()
+ if(KDE3_KDECORE_LIBRARY MATCHES lib64)
+ set(KDE3_LIBTOOL_DIR /lib64/kde3)
+ elseif(KDE3_KDECORE_LIBRARY MATCHES libx32)
+ set(KDE3_LIBTOOL_DIR /libx32/kde3)
+ else()
+ set(KDE3_LIBTOOL_DIR /lib/kde3)
+ endif()
endif()
#now search for the dcop utilities
find_program(KDE3_DCOPIDL_EXECUTABLE NAMES dcopidl
HINTS
- $ENV{KDEDIR}/bin
- ${KDE3PREFIX}/bin
+ $ENV{KDEDIR}/bin
+ ${KDE3PREFIX}/bin
PATHS
- /opt/kde3/bin
- /opt/kde/bin
+ /opt/kde3/bin
+ /opt/kde/bin
)
find_program(KDE3_DCOPIDL2CPP_EXECUTABLE NAMES dcopidl2cpp
HINTS
- $ENV{KDEDIR}/bin
- ${KDE3PREFIX}/bin
+ $ENV{KDEDIR}/bin
+ ${KDE3PREFIX}/bin
PATHS
- /opt/kde3/bin
- /opt/kde/bin
+ /opt/kde3/bin
+ /opt/kde/bin
)
find_program(KDE3_KCFGC_EXECUTABLE NAMES kconfig_compiler
HINTS
- $ENV{KDEDIR}/bin
- ${KDE3PREFIX}/bin
+ $ENV{KDEDIR}/bin
+ ${KDE3PREFIX}/bin
PATHS
- /opt/kde3/bin
- /opt/kde/bin
+ /opt/kde3/bin
+ /opt/kde/bin
)
#SET KDE3_FOUND
if (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE)
- set(KDE3_FOUND TRUE)
+ set(KDE3_FOUND TRUE)
else ()
- set(KDE3_FOUND FALSE)
+ set(KDE3_FOUND FALSE)
endif ()
# add some KDE specific stuff
@@ -269,36 +269,36 @@ set(KDE3_DEFINITIONS -DQT_CLEAN_NAMESPACE -D_GNU_SOURCE)
# set compiler flags only if KDE3 has actually been found
if(KDE3_FOUND)
- set(_KDE3_USE_FLAGS FALSE)
- if(CMAKE_COMPILER_IS_GNUCXX)
- set(_KDE3_USE_FLAGS TRUE) # use flags for gnu compiler
- execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
- OUTPUT_VARIABLE out)
- # gnu gcc 2.96 does not work with flags
- # I guess 2.95 also doesn't then
- if("${out}" MATCHES "2.9[56]")
- set(_KDE3_USE_FLAGS FALSE)
- endif()
- endif()
-
- #only on linux, but NOT e.g. on FreeBSD:
- if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND _KDE3_USE_FLAGS)
- set (KDE3_DEFINITIONS ${KDE3_DEFINITIONS} -D_XOPEN_SOURCE=500 -D_BSD_SOURCE)
- set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
- set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-exceptions -fno-check-new -fno-common")
- endif()
-
- # works on FreeBSD, NOT tested on NetBSD and OpenBSD
- if (CMAKE_SYSTEM_NAME MATCHES BSD AND _KDE3_USE_FLAGS)
- set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
- set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common")
- endif ()
-
- # if no special buildtype is selected, add -O2 as default optimization
- if (NOT CMAKE_BUILD_TYPE AND _KDE3_USE_FLAGS)
- set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
- set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
- endif ()
+ set(_KDE3_USE_FLAGS FALSE)
+ if(CMAKE_COMPILER_IS_GNUCXX)
+ set(_KDE3_USE_FLAGS TRUE) # use flags for gnu compiler
+ execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
+ OUTPUT_VARIABLE out)
+ # gnu gcc 2.96 does not work with flags
+ # I guess 2.95 also doesn't then
+ if("${out}" MATCHES "2.9[56]")
+ set(_KDE3_USE_FLAGS FALSE)
+ endif()
+ endif()
+
+ #only on linux, but NOT e.g. on FreeBSD:
+ if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND _KDE3_USE_FLAGS)
+ set (KDE3_DEFINITIONS ${KDE3_DEFINITIONS} -D_XOPEN_SOURCE=500 -D_BSD_SOURCE)
+ set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-exceptions -fno-check-new -fno-common")
+ endif()
+
+ # works on FreeBSD, NOT tested on NetBSD and OpenBSD
+ if (CMAKE_SYSTEM_NAME MATCHES BSD AND _KDE3_USE_FLAGS)
+ set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common")
+ endif ()
+
+ # if no special buildtype is selected, add -O2 as default optimization
+ if (NOT CMAKE_BUILD_TYPE AND _KDE3_USE_FLAGS)
+ set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
+ set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
+ endif ()
#set(CMAKE_SHARED_LINKER_FLAGS "-avoid-version -module -Wl,--no-undefined -Wl,--allow-shlib-undefined")
#set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc")
@@ -311,51 +311,50 @@ include(${CMAKE_CURRENT_LIST_DIR}/KDE3Macros.cmake)
macro (KDE3_PRINT_RESULTS)
- if(KDE3_INCLUDE_DIR)
- message(STATUS "Found KDE3 include dir: ${KDE3_INCLUDE_DIR}")
- else()
- message(STATUS "Didn't find KDE3 headers")
- endif()
-
- if(KDE3_LIB_DIR)
- message(STATUS "Found KDE3 library dir: ${KDE3_LIB_DIR}")
- else()
- message(STATUS "Didn't find KDE3 core library")
- endif()
-
- if(KDE3_DCOPIDL_EXECUTABLE)
- message(STATUS "Found KDE3 dcopidl preprocessor: ${KDE3_DCOPIDL_EXECUTABLE}")
- else()
- message(STATUS "Didn't find the KDE3 dcopidl preprocessor")
- endif()
-
- if(KDE3_DCOPIDL2CPP_EXECUTABLE)
- message(STATUS "Found KDE3 dcopidl2cpp preprocessor: ${KDE3_DCOPIDL2CPP_EXECUTABLE}")
- else()
- message(STATUS "Didn't find the KDE3 dcopidl2cpp preprocessor")
- endif()
-
- if(KDE3_KCFGC_EXECUTABLE)
- message(STATUS "Found KDE3 kconfig_compiler preprocessor: ${KDE3_KCFGC_EXECUTABLE}")
- else()
- message(STATUS "Didn't find the KDE3 kconfig_compiler preprocessor")
- endif()
+ if(KDE3_INCLUDE_DIR)
+ message(STATUS "Found KDE3 include dir: ${KDE3_INCLUDE_DIR}")
+ else()
+ message(STATUS "Didn't find KDE3 headers")
+ endif()
+
+ if(KDE3_LIB_DIR)
+ message(STATUS "Found KDE3 library dir: ${KDE3_LIB_DIR}")
+ else()
+ message(STATUS "Didn't find KDE3 core library")
+ endif()
+
+ if(KDE3_DCOPIDL_EXECUTABLE)
+ message(STATUS "Found KDE3 dcopidl preprocessor: ${KDE3_DCOPIDL_EXECUTABLE}")
+ else()
+ message(STATUS "Didn't find the KDE3 dcopidl preprocessor")
+ endif()
+
+ if(KDE3_DCOPIDL2CPP_EXECUTABLE)
+ message(STATUS "Found KDE3 dcopidl2cpp preprocessor: ${KDE3_DCOPIDL2CPP_EXECUTABLE}")
+ else()
+ message(STATUS "Didn't find the KDE3 dcopidl2cpp preprocessor")
+ endif()
+
+ if(KDE3_KCFGC_EXECUTABLE)
+ message(STATUS "Found KDE3 kconfig_compiler preprocessor: ${KDE3_KCFGC_EXECUTABLE}")
+ else()
+ message(STATUS "Didn't find the KDE3 kconfig_compiler preprocessor")
+ endif()
endmacro ()
if (KDE3_FIND_REQUIRED AND NOT KDE3_FOUND)
- #bail out if something wasn't found
- KDE3_PRINT_RESULTS()
- message(FATAL_ERROR "Could NOT find everything required for compiling KDE 3 programs")
+ #bail out if something wasn't found
+ KDE3_PRINT_RESULTS()
+ message(FATAL_ERROR "Could NOT find everything required for compiling KDE 3 programs")
endif ()
if (NOT KDE3_FIND_QUIETLY)
- KDE3_PRINT_RESULTS()
+ KDE3_PRINT_RESULTS()
endif ()
#add the found Qt and KDE include directories to the current include path
set(KDE3_INCLUDE_DIRS ${QT_INCLUDE_DIR} ${KDE3_INCLUDE_DIR})
-
diff --git a/Modules/FindKDE4.cmake b/Modules/FindKDE4.cmake
index bb98e53bd..695e9ac90 100644
--- a/Modules/FindKDE4.cmake
+++ b/Modules/FindKDE4.cmake
@@ -1,29 +1,30 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindKDE4
-# --------
-#
-#
-#
-# Find KDE4 and provide all necessary variables and macros to compile
-# software for it. It looks for KDE 4 in the following directories in
-# the given order:
-#
-# ::
-#
-# CMAKE_INSTALL_PREFIX
-# KDEDIRS
-# /opt/kde4
-#
-#
-#
-# Please look in FindKDE4Internal.cmake and KDE4Macros.cmake for more
-# information. They are installed with the KDE 4 libraries in
-# $KDEDIRS/share/apps/cmake/modules/.
-#
-# Author: Alexander Neundorf <neundorf@kde.org>
+#[=======================================================================[.rst:
+FindKDE4
+--------
+
+
+
+Find KDE4 and provide all necessary variables and macros to compile
+software for it. It looks for KDE 4 in the following directories in
+the given order:
+
+::
+
+ CMAKE_INSTALL_PREFIX
+ KDEDIRS
+ /opt/kde4
+
+
+
+Please look in ``FindKDE4Internal.cmake`` and ``KDE4Macros.cmake`` for more
+information. They are installed with the KDE 4 libraries in
+$KDEDIRS/share/apps/cmake/modules/.
+
+Author: Alexander Neundorf <neundorf@kde.org>
+#]=======================================================================]
# If Qt3 has already been found, fail.
if(QT_QT_LIBRARY)
@@ -56,47 +57,47 @@ find_program(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config
)
if (NOT KDE4_KDECONFIG_EXECUTABLE)
- if (KDE4_FIND_REQUIRED)
- message(FATAL_ERROR "ERROR: Could not find KDE4 kde4-config")
- endif ()
+ if (KDE4_FIND_REQUIRED)
+ message(FATAL_ERROR "ERROR: Could not find KDE4 kde4-config")
+ endif ()
endif ()
# when cross compiling, KDE4_DATA_DIR may be already preset
if(NOT KDE4_DATA_DIR)
- if(CMAKE_CROSSCOMPILING)
- # when cross compiling, don't run kde4-config but use its location as install dir
- get_filename_component(KDE4_DATA_DIR "${KDE4_KDECONFIG_EXECUTABLE}" PATH)
- get_filename_component(KDE4_DATA_DIR "${KDE4_DATA_DIR}" PATH)
- else()
- # then ask kde4-config for the kde data dirs
-
- if(KDE4_KDECONFIG_EXECUTABLE)
- execute_process(COMMAND "${KDE4_KDECONFIG_EXECUTABLE}" --path data OUTPUT_VARIABLE _data_DIR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
- file(TO_CMAKE_PATH "${_data_DIR}" _data_DIR)
- # then check the data dirs for FindKDE4Internal.cmake
- find_path(KDE4_DATA_DIR cmake/modules/FindKDE4Internal.cmake HINTS ${_data_DIR})
- endif()
- endif()
+ if(CMAKE_CROSSCOMPILING)
+ # when cross compiling, don't run kde4-config but use its location as install dir
+ get_filename_component(KDE4_DATA_DIR "${KDE4_KDECONFIG_EXECUTABLE}" PATH)
+ get_filename_component(KDE4_DATA_DIR "${KDE4_DATA_DIR}" PATH)
+ else()
+ # then ask kde4-config for the kde data dirs
+
+ if(KDE4_KDECONFIG_EXECUTABLE)
+ execute_process(COMMAND "${KDE4_KDECONFIG_EXECUTABLE}" --path data OUTPUT_VARIABLE _data_DIR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
+ file(TO_CMAKE_PATH "${_data_DIR}" _data_DIR)
+ # then check the data dirs for FindKDE4Internal.cmake
+ find_path(KDE4_DATA_DIR cmake/modules/FindKDE4Internal.cmake HINTS ${_data_DIR})
+ endif()
+ endif()
endif()
# if it has been found...
if (KDE4_DATA_DIR)
- set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${KDE4_DATA_DIR}/cmake/modules)
+ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${KDE4_DATA_DIR}/cmake/modules)
- if (KDE4_FIND_QUIETLY)
- set(_quiet QUIET)
- endif ()
+ if (KDE4_FIND_QUIETLY)
+ set(_quiet QUIET)
+ endif ()
- if (KDE4_FIND_REQUIRED)
- set(_req REQUIRED)
- endif ()
+ if (KDE4_FIND_REQUIRED)
+ set(_req REQUIRED)
+ endif ()
- # use FindKDE4Internal.cmake to do the rest
- find_package(KDE4Internal ${_req} ${_quiet} NO_POLICY_SCOPE)
+ # use FindKDE4Internal.cmake to do the rest
+ find_package(KDE4Internal ${_req} ${_quiet} NO_POLICY_SCOPE)
else ()
- if (KDE4_FIND_REQUIRED)
- message(FATAL_ERROR "ERROR: cmake/modules/FindKDE4Internal.cmake not found in ${_data_DIR}")
- endif ()
+ if (KDE4_FIND_REQUIRED)
+ message(FATAL_ERROR "ERROR: cmake/modules/FindKDE4Internal.cmake not found in ${_data_DIR}")
+ endif ()
endif ()
diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake
index a451e6ccd..3cb365394 100644
--- a/Modules/FindLAPACK.cmake
+++ b/Modules/FindLAPACK.cmake
@@ -1,47 +1,76 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindLAPACK
-# ----------
-#
-# Find LAPACK library
-#
-# This module finds an installed fortran library that implements the
-# LAPACK linear-algebra interface (see http://www.netlib.org/lapack/).
-#
-# The approach follows that taken for the autoconf macro file,
-# acx_lapack.m4 (distributed at
-# http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html).
-#
-# This module sets the following variables:
-#
-# ::
-#
-# LAPACK_FOUND - set to true if a library implementing the LAPACK interface
-# is found
-# LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l
-# and -L).
-# LAPACK_LIBRARIES - uncached list of libraries (using full path name) to
-# link against to use LAPACK
-# LAPACK95_LIBRARIES - uncached list of libraries (using full path name) to
-# link against to use LAPACK95
-# LAPACK95_FOUND - set to true if a library implementing the LAPACK f95
-# interface is found
-# BLA_STATIC if set on this determines what kind of linkage we do (static)
-# BLA_VENDOR if set checks only the specified vendor, if not set checks
-# all the possibilities
-# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK
-#
-# List of vendors (BLA_VENDOR) valid in this module:
-#
-# * Intel(mkl)
-# * OpenBLAS
-# * ACML
-# * Apple
-# * NAS
-# * Generic
-#
+#[=======================================================================[.rst:
+FindLAPACK
+----------
+
+Find Linear Algebra PACKage (LAPACK) library
+
+This module finds an installed fortran library that implements the
+LAPACK linear-algebra interface (see http://www.netlib.org/lapack/).
+
+The approach follows that taken for the autoconf macro file,
+``acx_lapack.m4`` (distributed at
+http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html).
+
+Input Variables
+^^^^^^^^^^^^^^^
+
+The following variables may be set to influence this module's behavior:
+
+``BLA_STATIC``
+ if ``ON`` use static linkage
+
+``BLA_VENDOR``
+ If set, checks only the specified vendor, if not set checks all the
+ possibilities. List of vendors valid in this module:
+
+ * ``Intel10_32`` (intel mkl v10 32 bit)
+ * ``Intel10_64lp`` (intel mkl v10+ 64 bit, threaded code, lp64 model)
+ * ``Intel10_64lp_seq`` (intel mkl v10+ 64 bit, sequential code, lp64 model)
+ * ``Intel10_64ilp`` (intel mkl v10+ 64 bit, threaded code, ilp64 model)
+ * ``Intel10_64ilp_seq`` (intel mkl v10+ 64 bit, sequential code, ilp64 model)
+ * ``Intel`` (obsolete versions of mkl 32 and 64 bit)
+ * ``OpenBLAS``
+ * ``FLAME``
+ * ``ACML``
+ * ``Apple``
+ * ``NAS``
+ * ``Generic``
+
+``BLA_F95``
+ if ``ON`` tries to find BLAS95/LAPACK95
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+``LAPACK_FOUND``
+ library implementing the LAPACK interface is found
+``LAPACK_LINKER_FLAGS``
+ uncached list of required linker flags (excluding -l and -L).
+``LAPACK_LIBRARIES``
+ uncached list of libraries (using full path name) to link against
+ to use LAPACK
+``LAPACK95_LIBRARIES``
+ uncached list of libraries (using full path name) to link against
+ to use LAPACK95
+``LAPACK95_FOUND``
+ library implementing the LAPACK95 interface is found
+
+.. note::
+
+ C or CXX must be enabled to use Intel MKL
+
+ For example, to use Intel MKL libraries and/or Intel compiler:
+
+ .. code-block:: cmake
+
+ set(BLA_VENDOR Intel10_64lp)
+ find_package(LAPACK)
+#]=======================================================================]
set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
@@ -94,6 +123,9 @@ if (NOT _libdir)
set(_libdir ENV LD_LIBRARY_PATH)
endif ()
endif ()
+
+list(APPEND _libdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
+
foreach(_library ${_list})
set(_combined_name ${_combined_name}_${_library})
@@ -108,7 +140,7 @@ foreach(_library ${_list})
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif ()
else ()
- if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# for ubuntu's libblas3gf and liblapack3gf packages
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
endif ()
@@ -137,13 +169,16 @@ if(_libraries_work)
check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS)
endif ()
set(CMAKE_REQUIRED_LIBRARIES)
- mark_as_advanced(${_prefix}${_combined_name}_WORKS)
set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
endif()
if(_libraries_work)
- set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threads})
+ if("${_list}${_blas}" STREQUAL "")
+ set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
+ else()
+ set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threads})
+ endif()
else()
set(${LIBRARIES} FALSE)
endif()
@@ -173,6 +208,86 @@ if(BLAS_FOUND)
endif()
endif ()
+#intel lapack
+if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
+ if(NOT LAPACK_LIBRARIES)
+ if (NOT WIN32)
+ set(LAPACK_mkl_LM "-lm")
+ set(LAPACK_mkl_LDL "-ldl")
+ endif ()
+ if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED)
+ if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
+ find_PACKAGE(Threads)
+ else()
+ find_package(Threads REQUIRED)
+ endif()
+
+ if (BLA_VENDOR MATCHES "_64ilp")
+ set(LAPACK_mkl_ILP_MODE "ilp64")
+ else ()
+ set(LAPACK_mkl_ILP_MODE "lp64")
+ endif ()
+
+ set(LAPACK_SEARCH_LIBS "")
+
+ if (BLA_F95)
+ set(LAPACK_mkl_SEARCH_SYMBOL "cheev_f95")
+ set(_LIBRARIES LAPACK95_LIBRARIES)
+ set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES})
+
+ # old
+ list(APPEND LAPACK_SEARCH_LIBS
+ "mkl_lapack95")
+ # new >= 10.3
+ list(APPEND LAPACK_SEARCH_LIBS
+ "mkl_intel_c")
+ list(APPEND LAPACK_SEARCH_LIBS
+ "mkl_lapack95_${LAPACK_mkl_ILP_MODE}")
+ else()
+ set(LAPACK_mkl_SEARCH_SYMBOL "cheev")
+ set(_LIBRARIES LAPACK_LIBRARIES)
+ set(_BLAS_LIBRARIES ${BLAS_LIBRARIES})
+
+ # old
+ list(APPEND LAPACK_SEARCH_LIBS
+ "mkl_lapack")
+ endif()
+
+ # First try empty lapack libs
+ if (NOT ${_LIBRARIES})
+ check_lapack_libraries(
+ ${_LIBRARIES}
+ LAPACK
+ ${LAPACK_mkl_SEARCH_SYMBOL}
+ ""
+ ""
+ "${_BLAS_LIBRARIES}"
+ ""
+ )
+ endif ()
+ # Then try the search libs
+ foreach (IT ${LAPACK_SEARCH_LIBS})
+ if (NOT ${_LIBRARIES})
+ check_lapack_libraries(
+ ${_LIBRARIES}
+ LAPACK
+ ${LAPACK_mkl_SEARCH_SYMBOL}
+ ""
+ "${IT}"
+ "${_BLAS_LIBRARIES}"
+ "${CMAKE_THREAD_LIBS_INIT};${LAPACK_mkl_LM};${LAPACK_mkl_LDL}"
+ )
+ endif ()
+ endforeach ()
+
+ unset(LAPACK_mkl_ILP_MODE)
+ unset(LAPACK_mkl_SEARCH_SYMBOL)
+ unset(LAPACK_mkl_LM)
+ unset(LAPACK_mkl_LDL)
+ endif ()
+ endif()
+endif()
+
if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
@@ -201,27 +316,41 @@ if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")
endif()
endif ()
-#acml lapack
- if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All")
- if (BLAS_LIBRARIES MATCHES ".+acml.+")
- set (LAPACK_LIBRARIES ${BLAS_LIBRARIES})
- endif ()
- endif ()
-
-# Apple LAPACK library?
-if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
+if (BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All")
if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
- "Accelerate"
+ "flame"
"${BLAS_LIBRARIES}"
""
)
endif()
endif ()
+
+#acml lapack
+if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All")
+ if (BLAS_LIBRARIES MATCHES ".+acml.+")
+ set (LAPACK_LIBRARIES ${BLAS_LIBRARIES})
+ endif ()
+endif ()
+
+# Apple LAPACK library?
+if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
+ if(NOT LAPACK_LIBRARIES)
+ check_lapack_libraries(
+ LAPACK_LIBRARIES
+ LAPACK
+ cheev
+ ""
+ "Accelerate"
+ "${BLAS_LIBRARIES}"
+ ""
+ )
+ endif()
+endif ()
if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
if ( NOT LAPACK_LIBRARIES )
check_lapack_libraries(
@@ -251,123 +380,62 @@ if (BLA_VENDOR STREQUAL "Generic" OR
)
endif ()
endif ()
-#intel lapack
-if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
- if (NOT WIN32)
- set(LM "-lm")
- endif ()
- if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED)
- if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
- find_PACKAGE(Threads)
- else()
- find_package(Threads REQUIRED)
- endif()
-
- set(LAPACK_SEARCH_LIBS "")
-
- if (BLA_F95)
- set(LAPACK_mkl_SEARCH_SYMBOL "CHEEV")
- set(_LIBRARIES LAPACK95_LIBRARIES)
- set(_BLAS_LIBRARIES ${BLAS95_LIBRARIES})
-
- # old
- list(APPEND LAPACK_SEARCH_LIBS
- "mkl_lapack95")
- # new >= 10.3
- list(APPEND LAPACK_SEARCH_LIBS
- "mkl_intel_c")
- list(APPEND LAPACK_SEARCH_LIBS
- "mkl_intel_lp64")
- else()
- set(LAPACK_mkl_SEARCH_SYMBOL "cheev")
- set(_LIBRARIES LAPACK_LIBRARIES)
- set(_BLAS_LIBRARIES ${BLAS_LIBRARIES})
-
- # old
- list(APPEND LAPACK_SEARCH_LIBS
- "mkl_lapack")
- # new >= 10.3
- list(APPEND LAPACK_SEARCH_LIBS
- "mkl_gf_lp64")
- endif()
- # First try empty lapack libs
- if (NOT ${_LIBRARIES})
- check_lapack_libraries(
- ${_LIBRARIES}
- BLAS
- ${LAPACK_mkl_SEARCH_SYMBOL}
- ""
- ""
- "${_BLAS_LIBRARIES}"
- "${CMAKE_THREAD_LIBS_INIT};${LM}"
- )
- endif ()
- # Then try the search libs
- foreach (IT ${LAPACK_SEARCH_LIBS})
- if (NOT ${_LIBRARIES})
- check_lapack_libraries(
- ${_LIBRARIES}
- BLAS
- ${LAPACK_mkl_SEARCH_SYMBOL}
- ""
- "${IT}"
- "${_BLAS_LIBRARIES}"
- "${CMAKE_THREAD_LIBS_INIT};${LM}"
- )
- endif ()
- endforeach ()
- endif ()
-endif()
else()
message(STATUS "LAPACK requires BLAS")
endif()
if(BLA_F95)
- if(LAPACK95_LIBRARIES)
- set(LAPACK95_FOUND TRUE)
- else()
- set(LAPACK95_FOUND FALSE)
- endif()
- if(NOT LAPACK_FIND_QUIETLY)
- if(LAPACK95_FOUND)
- message(STATUS "A library with LAPACK95 API found.")
+ if(LAPACK95_LIBRARIES)
+ set(LAPACK95_FOUND TRUE)
else()
- if(LAPACK_FIND_REQUIRED)
- message(FATAL_ERROR
- "A required library with LAPACK95 API not found. Please specify library location."
- )
+ set(LAPACK95_FOUND FALSE)
+ endif()
+ if(NOT LAPACK_FIND_QUIETLY)
+ if(LAPACK95_FOUND)
+ message(STATUS "A library with LAPACK95 API found.")
else()
- message(STATUS
- "A library with LAPACK95 API not found. Please specify library location."
- )
+ if(LAPACK_FIND_REQUIRED)
+ message(FATAL_ERROR
+ "A required library with LAPACK95 API not found. Please specify library location."
+ )
+ else()
+ message(STATUS
+ "A library with LAPACK95 API not found. Please specify library location."
+ )
+ endif()
endif()
endif()
- endif()
- set(LAPACK_FOUND "${LAPACK95_FOUND}")
- set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}")
+ set(LAPACK_FOUND "${LAPACK95_FOUND}")
+ set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}")
else()
- if(LAPACK_LIBRARIES)
- set(LAPACK_FOUND TRUE)
- else()
- set(LAPACK_FOUND FALSE)
- endif()
-
- if(NOT LAPACK_FIND_QUIETLY)
- if(LAPACK_FOUND)
- message(STATUS "A library with LAPACK API found.")
+ if(LAPACK_LIBRARIES)
+ set(LAPACK_FOUND TRUE)
else()
- if(LAPACK_FIND_REQUIRED)
- message(FATAL_ERROR
- "A required library with LAPACK API not found. Please specify library location."
- )
+ set(LAPACK_FOUND FALSE)
+ endif()
+
+ if(NOT LAPACK_FIND_QUIETLY)
+ if(LAPACK_FOUND)
+ message(STATUS "A library with LAPACK API found.")
else()
- message(STATUS
- "A library with LAPACK API not found. Please specify library location."
- )
+ if(LAPACK_FIND_REQUIRED)
+ message(FATAL_ERROR
+ "A required library with LAPACK API not found. Please specify library location."
+ )
+ else()
+ message(STATUS
+ "A library with LAPACK API not found. Please specify library location."
+ )
+ endif()
endif()
endif()
- endif()
+endif()
+
+# On compilers that implicitly link LAPACK (such as ftn, cc, and CC on Cray HPC machines)
+# we used a placeholder for empty LAPACK_LIBRARIES to get through our logic above.
+if (LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
+ set(LAPACK_LIBRARIES "")
endif()
cmake_pop_check_state()
diff --git a/Modules/FindLATEX.cmake b/Modules/FindLATEX.cmake
index d1f4fa497..b0dad7da3 100644
--- a/Modules/FindLATEX.cmake
+++ b/Modules/FindLATEX.cmake
@@ -1,56 +1,57 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindLATEX
-# ---------
-#
-# Find Latex
-#
-# This module finds an installed Latex and determines the location
-# of the compiler. Additionally the module looks for Latex-related
-# software like BibTeX.
-#
-# This module sets the following result variables::
-#
-# LATEX_FOUND: whether found Latex and requested components
-# LATEX_<component>_FOUND: whether found <component>
-# LATEX_COMPILER: path to the LaTeX compiler
-# PDFLATEX_COMPILER: path to the PdfLaTeX compiler
-# XELATEX_COMPILER: path to the XeLaTeX compiler
-# LUALATEX_COMPILER: path to the LuaLaTeX compiler
-# BIBTEX_COMPILER: path to the BibTeX compiler
-# BIBER_COMPILER: path to the Biber compiler
-# MAKEINDEX_COMPILER: path to the MakeIndex compiler
-# XINDY_COMPILER: path to the xindy compiler
-# DVIPS_CONVERTER: path to the DVIPS converter
-# DVIPDF_CONVERTER: path to the DVIPDF converter
-# PS2PDF_CONVERTER: path to the PS2PDF converter
-# PDFTOPS_CONVERTER: path to the pdftops converter
-# LATEX2HTML_CONVERTER: path to the LaTeX2Html converter
-# HTLATEX_COMPILER: path to the htlatex compiler
-#
-# Possible components are::
-#
-# PDFLATEX
-# XELATEX
-# LUALATEX
-# BIBTEX
-# BIBER
-# MAKEINDEX
-# XINDY
-# DVIPS
-# DVIPDF
-# PS2PDF
-# PDFTOPS
-# LATEX2HTML
-# HTLATEX
-#
-# Example Usages::
-#
-# find_package(LATEX)
-# find_package(LATEX COMPONENTS PDFLATEX)
-# find_package(LATEX COMPONENTS BIBTEX PS2PDF)
+#[=======================================================================[.rst:
+FindLATEX
+---------
+
+Find LaTeX
+
+This module finds an installed LaTeX and determines the location
+of the compiler. Additionally the module looks for Latex-related
+software like BibTeX.
+
+This module sets the following result variables::
+
+ LATEX_FOUND: whether found Latex and requested components
+ LATEX_<component>_FOUND: whether found <component>
+ LATEX_COMPILER: path to the LaTeX compiler
+ PDFLATEX_COMPILER: path to the PdfLaTeX compiler
+ XELATEX_COMPILER: path to the XeLaTeX compiler
+ LUALATEX_COMPILER: path to the LuaLaTeX compiler
+ BIBTEX_COMPILER: path to the BibTeX compiler
+ BIBER_COMPILER: path to the Biber compiler
+ MAKEINDEX_COMPILER: path to the MakeIndex compiler
+ XINDY_COMPILER: path to the xindy compiler
+ DVIPS_CONVERTER: path to the DVIPS converter
+ DVIPDF_CONVERTER: path to the DVIPDF converter
+ PS2PDF_CONVERTER: path to the PS2PDF converter
+ PDFTOPS_CONVERTER: path to the pdftops converter
+ LATEX2HTML_CONVERTER: path to the LaTeX2Html converter
+ HTLATEX_COMPILER: path to the htlatex compiler
+
+Possible components are::
+
+ PDFLATEX
+ XELATEX
+ LUALATEX
+ BIBTEX
+ BIBER
+ MAKEINDEX
+ XINDY
+ DVIPS
+ DVIPDF
+ PS2PDF
+ PDFTOPS
+ LATEX2HTML
+ HTLATEX
+
+Example Usages::
+
+ find_package(LATEX)
+ find_package(LATEX COMPONENTS PDFLATEX)
+ find_package(LATEX COMPONENTS BIBTEX PS2PDF)
+#]=======================================================================]
if (WIN32)
# Try to find the MikTex binary path (look for its package manager).
@@ -170,7 +171,7 @@ find_program(XINDY_COMPILER
/usr/bin
)
if (XINDY_COMPILER)
- set(LATEX_XINDY_FOUND TRUE)
+ set(LATEX_XINDY_FOUND TRUE)
else()
set(LATEX_XINDY_FOUND FALSE)
endif()
diff --git a/Modules/FindLTTngUST.cmake b/Modules/FindLTTngUST.cmake
index 00d5e7aed..9cd17eb05 100644
--- a/Modules/FindLTTngUST.cmake
+++ b/Modules/FindLTTngUST.cmake
@@ -1,37 +1,39 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindLTTngUST
-# ------------
-#
-# This module finds the `LTTng-UST <http://lttng.org/>`__ library.
-#
-# Imported target
-# ^^^^^^^^^^^^^^^
-#
-# This module defines the following :prop_tgt:`IMPORTED` target:
-#
-# ``LTTng::UST``
-# The LTTng-UST library, if found
-#
-# Result variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module sets the following
-#
-# ``LTTNGUST_FOUND``
-# ``TRUE`` if system has LTTng-UST
-# ``LTTNGUST_INCLUDE_DIRS``
-# The LTTng-UST include directories
-# ``LTTNGUST_LIBRARIES``
-# The libraries needed to use LTTng-UST
-# ``LTTNGUST_VERSION_STRING``
-# The LTTng-UST version
-# ``LTTNGUST_HAS_TRACEF``
-# ``TRUE`` if the ``tracef()`` API is available in the system's LTTng-UST
-# ``LTTNGUST_HAS_TRACELOG``
-# ``TRUE`` if the ``tracelog()`` API is available in the system's LTTng-UST
+#[=======================================================================[.rst:
+FindLTTngUST
+------------
+
+Find
+`Linux Trace Toolkit Next Generation (LTTng-UST) <http://lttng.org/>`__ library.
+
+Imported target
+^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` target:
+
+``LTTng::UST``
+ The LTTng-UST library, if found
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module sets the following
+
+``LTTNGUST_FOUND``
+ ``TRUE`` if system has LTTng-UST
+``LTTNGUST_INCLUDE_DIRS``
+ The LTTng-UST include directories
+``LTTNGUST_LIBRARIES``
+ The libraries needed to use LTTng-UST
+``LTTNGUST_VERSION_STRING``
+ The LTTng-UST version
+``LTTNGUST_HAS_TRACEF``
+ ``TRUE`` if the ``tracef()`` API is available in the system's LTTng-UST
+``LTTNGUST_HAS_TRACELOG``
+ ``TRUE`` if the ``tracelog()`` API is available in the system's LTTng-UST
+#]=======================================================================]
find_path(LTTNGUST_INCLUDE_DIRS NAMES lttng/tracepoint.h)
find_library(LTTNGUST_LIBRARIES NAMES lttng-ust)
diff --git a/Modules/FindLibArchive.cmake b/Modules/FindLibArchive.cmake
index 38e512fa3..ef27b7dc0 100644
--- a/Modules/FindLibArchive.cmake
+++ b/Modules/FindLibArchive.cmake
@@ -1,20 +1,22 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindLibArchive
-# --------------
-#
-# Find libarchive library and headers
-#
-# The module defines the following variables:
-#
-# ::
-#
-# LibArchive_FOUND - true if libarchive was found
-# LibArchive_INCLUDE_DIRS - include search path
-# LibArchive_LIBRARIES - libraries to link
-# LibArchive_VERSION - libarchive 3-component version number
+#[=======================================================================[.rst:
+FindLibArchive
+--------------
+
+Find libarchive library and headers.
+Libarchive is multi-format archive and compression library.
+
+The module defines the following variables:
+
+::
+
+ LibArchive_FOUND - true if libarchive was found
+ LibArchive_INCLUDE_DIRS - include search path
+ LibArchive_LIBRARIES - libraries to link
+ LibArchive_VERSION - libarchive 3-component version number
+#]=======================================================================]
find_path(LibArchive_INCLUDE_DIR
NAMES archive.h
diff --git a/Modules/FindLibLZMA.cmake b/Modules/FindLibLZMA.cmake
index 8009bcfab..200d6bf8d 100644
--- a/Modules/FindLibLZMA.cmake
+++ b/Modules/FindLibLZMA.cmake
@@ -1,29 +1,55 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindLibLZMA
-# -----------
-#
-# Find LibLZMA
-#
-# Find LibLZMA headers and library
-#
-# ::
-#
-# LIBLZMA_FOUND - True if liblzma is found.
-# LIBLZMA_INCLUDE_DIRS - Directory where liblzma headers are located.
-# LIBLZMA_LIBRARIES - Lzma libraries to link against.
-# LIBLZMA_HAS_AUTO_DECODER - True if lzma_auto_decoder() is found (required).
-# LIBLZMA_HAS_EASY_ENCODER - True if lzma_easy_encoder() is found (required).
-# LIBLZMA_HAS_LZMA_PRESET - True if lzma_lzma_preset() is found (required).
-# LIBLZMA_VERSION_MAJOR - The major version of lzma
-# LIBLZMA_VERSION_MINOR - The minor version of lzma
-# LIBLZMA_VERSION_PATCH - The patch version of lzma
-# LIBLZMA_VERSION_STRING - version number as a string (ex: "5.0.3")
+#[=======================================================================[.rst:
+FindLibLZMA
+-----------
+
+Find LZMA compression algorithm headers and library.
+
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``LibLZMA::LibLZMA``, if
+liblzma has been found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``LIBLZMA_FOUND``
+ True if liblzma headers and library were found.
+``LIBLZMA_INCLUDE_DIRS``
+ Directory where liblzma headers are located.
+``LIBLZMA_LIBRARIES``
+ Lzma libraries to link against.
+``LIBLZMA_HAS_AUTO_DECODER``
+ True if lzma_auto_decoder() is found (required).
+``LIBLZMA_HAS_EASY_ENCODER``
+ True if lzma_easy_encoder() is found (required).
+``LIBLZMA_HAS_LZMA_PRESET``
+ True if lzma_lzma_preset() is found (required).
+``LIBLZMA_VERSION_MAJOR``
+ The major version of lzma
+``LIBLZMA_VERSION_MINOR``
+ The minor version of lzma
+``LIBLZMA_VERSION_PATCH``
+ The patch version of lzma
+``LIBLZMA_VERSION_STRING``
+ version number as a string (ex: "5.0.3")
+#]=======================================================================]
find_path(LIBLZMA_INCLUDE_DIR lzma.h )
-find_library(LIBLZMA_LIBRARY lzma)
+if(NOT LIBLZMA_LIBRARY)
+ find_library(LIBLZMA_LIBRARY_RELEASE NAMES lzma liblzma PATH_SUFFIXES lib)
+ find_library(LIBLZMA_LIBRARY_DEBUG NAMES lzmad liblzmad PATH_SUFFIXES lib)
+ include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
+ select_library_configurations(LIBLZMA)
+else()
+ file(TO_CMAKE_PATH "${LIBLZMA_LIBRARY}" LIBLZMA_LIBRARY)
+endif()
if(LIBLZMA_INCLUDE_DIR AND EXISTS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h")
file(STRINGS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h" LIBLZMA_HEADER_CONTENTS REGEX "#define LZMA_VERSION_[A-Z]+ [0-9]+")
@@ -40,27 +66,59 @@ endif()
# it can be found in http://tukaani.org/xz/
# Avoid using old codebase
if (LIBLZMA_LIBRARY)
- include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
- set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
- set(CMAKE_REQUIRED_QUIET ${LibLZMA_FIND_QUIETLY})
- CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER)
- CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER)
- CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET)
- set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
+ include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
+ set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
+ set(CMAKE_REQUIRED_QUIET ${LibLZMA_FIND_QUIETLY})
+ if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG)
+ set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY})
+ elseif(LIBLZMA_LIBRARY_RELEASE)
+ set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY_RELEASE})
+ elseif(LIBLZMA_LIBRARY_DEBUG)
+ set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY_DEBUG})
+ endif()
+ CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER)
+ CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER)
+ CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET)
+ unset(LIBLZMA_LIBRARY_check)
+ set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
endif ()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibLZMA REQUIRED_VARS LIBLZMA_INCLUDE_DIR
- LIBLZMA_LIBRARY
+find_package_handle_standard_args(LibLZMA REQUIRED_VARS LIBLZMA_LIBRARY
+ LIBLZMA_INCLUDE_DIR
LIBLZMA_HAS_AUTO_DECODER
LIBLZMA_HAS_EASY_ENCODER
LIBLZMA_HAS_LZMA_PRESET
VERSION_VAR LIBLZMA_VERSION_STRING
)
+mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY )
if (LIBLZMA_FOUND)
set(LIBLZMA_LIBRARIES ${LIBLZMA_LIBRARY})
set(LIBLZMA_INCLUDE_DIRS ${LIBLZMA_INCLUDE_DIR})
-endif ()
+ if(NOT TARGET LibLZMA::LibLZMA)
+ add_library(LibLZMA::LibLZMA UNKNOWN IMPORTED)
+ set_target_properties(LibLZMA::LibLZMA PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES ${LIBLZMA_INCLUDE_DIR}
+ IMPORTED_LINK_INTERFACE_LANGUAGES C)
-mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY )
+ if(LIBLZMA_LIBRARY_RELEASE)
+ set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(LibLZMA::LibLZMA PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${LIBLZMA_LIBRARY_RELEASE}")
+ endif()
+
+ if(LIBLZMA_LIBRARY_DEBUG)
+ set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(LibLZMA::LibLZMA PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${LIBLZMA_LIBRARY_DEBUG}")
+ endif()
+
+ if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG)
+ set_target_properties(LibLZMA::LibLZMA PROPERTIES
+ IMPORTED_LOCATION "${LIBLZMA_LIBRARY}")
+ endif()
+ endif()
+endif ()
diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake
index 613f927e2..da8bfe0d4 100644
--- a/Modules/FindLibXml2.cmake
+++ b/Modules/FindLibXml2.cmake
@@ -1,22 +1,48 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindLibXml2
-# -----------
-#
-# Try to find the LibXml2 xml processing library
-#
-# Once done this will define
-#
-# ::
-#
-# LIBXML2_FOUND - System has LibXml2
-# LIBXML2_INCLUDE_DIR - The LibXml2 include directory
-# LIBXML2_LIBRARIES - The libraries needed to use LibXml2
-# LIBXML2_DEFINITIONS - Compiler switches required for using LibXml2
-# LIBXML2_XMLLINT_EXECUTABLE - The XML checking tool xmllint coming with LibXml2
-# LIBXML2_VERSION_STRING - the version of LibXml2 found (since CMake 2.8.8)
+#[=======================================================================[.rst:
+FindLibXml2
+-----------
+
+Find the XML processing library (libxml2).
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``LibXml2::LibXml2``, if
+libxml2 has been found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``LibXml2_FOUND``
+ true if libxml2 headers and libraries were found
+``LIBXML2_INCLUDE_DIR``
+ the directory containing LibXml2 headers
+``LIBXML2_INCLUDE_DIRS``
+ list of the include directories needed to use LibXml2
+``LIBXML2_LIBRARIES``
+ LibXml2 libraries to be linked
+``LIBXML2_DEFINITIONS``
+ the compiler switches required for using LibXml2
+``LIBXML2_XMLLINT_EXECUTABLE``
+ path to the XML checking tool xmllint coming with LibXml2
+``LIBXML2_VERSION_STRING``
+ the version of LibXml2 found (since CMake 2.8.8)
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``LIBXML2_INCLUDE_DIR``
+ the directory containing LibXml2 headers
+``LIBXML2_LIBRARY``
+ path to the LibXml2 library
+#]=======================================================================]
# use pkg-config to get the directories and then use these values
# in the find_path() and find_library() calls
@@ -31,7 +57,14 @@ find_path(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h
PATH_SUFFIXES libxml2
)
-find_library(LIBXML2_LIBRARIES NAMES xml2 libxml2
+# CMake 3.9 and below used 'LIBXML2_LIBRARIES' as the name of
+# the cache entry storing the find_library result. Use the
+# value if it was set by the project or user.
+if(DEFINED LIBXML2_LIBRARIES AND NOT DEFINED LIBXML2_LIBRARY)
+ set(LIBXML2_LIBRARY ${LIBXML2_LIBRARIES})
+endif()
+
+find_library(LIBXML2_LIBRARY NAMES xml2 libxml2
HINTS
${PC_LIBXML_LIBDIR}
${PC_LIBXML_LIBRARY_DIRS}
@@ -52,9 +85,18 @@ elseif(LIBXML2_INCLUDE_DIR AND EXISTS "${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.
unset(libxml2_version_str)
endif()
+set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR} ${PC_LIBXML_INCLUDE_DIRS})
+set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY})
+
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2
- REQUIRED_VARS LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR
+ REQUIRED_VARS LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR
VERSION_VAR LIBXML2_VERSION_STRING)
-mark_as_advanced(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES LIBXML2_XMLLINT_EXECUTABLE)
+mark_as_advanced(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARY LIBXML2_XMLLINT_EXECUTABLE)
+
+if(LibXml2_FOUND AND NOT TARGET LibXml2::LibXml2)
+ add_library(LibXml2::LibXml2 UNKNOWN IMPORTED)
+ set_target_properties(LibXml2::LibXml2 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIRS}")
+ set_property(TARGET LibXml2::LibXml2 APPEND PROPERTY IMPORTED_LOCATION "${LIBXML2_LIBRARY}")
+endif()
diff --git a/Modules/FindLibXslt.cmake b/Modules/FindLibXslt.cmake
index abd1963d5..01a9d8be3 100644
--- a/Modules/FindLibXslt.cmake
+++ b/Modules/FindLibXslt.cmake
@@ -1,29 +1,31 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindLibXslt
-# -----------
-#
-# Try to find the LibXslt library
-#
-# Once done this will define
-#
-# ::
-#
-# LIBXSLT_FOUND - system has LibXslt
-# LIBXSLT_INCLUDE_DIR - the LibXslt include directory
-# LIBXSLT_LIBRARIES - Link these to LibXslt
-# LIBXSLT_DEFINITIONS - Compiler switches required for using LibXslt
-# LIBXSLT_VERSION_STRING - version of LibXslt found (since CMake 2.8.8)
-#
-# Additionally, the following two variables are set (but not required
-# for using xslt):
-#
-# ``LIBXSLT_EXSLT_LIBRARIES``
-# Link to these if you need to link against the exslt library.
-# ``LIBXSLT_XSLTPROC_EXECUTABLE``
-# Contains the full path to the xsltproc executable if found.
+#[=======================================================================[.rst:
+FindLibXslt
+-----------
+
+Find the XSL Transformations, Extensible Stylesheet Language
+Transformations (XSLT) library (LibXslt)
+
+Once done this will define
+
+::
+
+ LIBXSLT_FOUND - system has LibXslt
+ LIBXSLT_INCLUDE_DIR - the LibXslt include directory
+ LIBXSLT_LIBRARIES - Link these to LibXslt
+ LIBXSLT_DEFINITIONS - Compiler switches required for using LibXslt
+ LIBXSLT_VERSION_STRING - version of LibXslt found (since CMake 2.8.8)
+
+Additionally, the following two variables are set (but not required
+for using xslt):
+
+``LIBXSLT_EXSLT_LIBRARIES``
+ Link to these if you need to link against the exslt library.
+``LIBXSLT_XSLTPROC_EXECUTABLE``
+ Contains the full path to the xsltproc executable if found.
+#]=======================================================================]
# use pkg-config to get the directories and then use these values
# in the find_path() and find_library() calls
diff --git a/Modules/FindLibinput.cmake b/Modules/FindLibinput.cmake
new file mode 100644
index 000000000..c1fe45562
--- /dev/null
+++ b/Modules/FindLibinput.cmake
@@ -0,0 +1,82 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindLibinput
+------------
+
+Find libinput headers and library.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+``Libinput::Libinput``
+ The libinput library, if found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This will define the following variables in your project:
+
+``Libinput_FOUND``
+ true if (the requested version of) libinput is available.
+``Libinput_VERSION``
+ the version of libinput.
+``Libinput_LIBRARIES``
+ the libraries to link against to use libinput.
+``Libinput_INCLUDE_DIRS``
+ where to find the libinput headers.
+``Libinput_COMPILE_OPTIONS``
+ this should be passed to target_compile_options(), if the
+ target is not used for linking
+
+#]=======================================================================]
+
+
+# Use pkg-config to get the directories and then use these values
+# in the FIND_PATH() and FIND_LIBRARY() calls
+find_package(PkgConfig QUIET)
+pkg_check_modules(PKG_Libinput QUIET libinput)
+
+set(Libinput_COMPILE_OPTIONS ${PKG_Libinput_CFLAGS_OTHER})
+set(Libinput_VERSION ${PKG_Libinput_VERSION})
+
+find_path(Libinput_INCLUDE_DIR
+ NAMES
+ libinput.h
+ HINTS
+ ${PKG_Libinput_INCLUDE_DIRS}
+)
+find_library(Libinput_LIBRARY
+ NAMES
+ input
+ HINTS
+ ${PKG_Libinput_LIBRARY_DIRS}
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Libinput
+ FOUND_VAR
+ Libinput_FOUND
+ REQUIRED_VARS
+ Libinput_LIBRARY
+ Libinput_INCLUDE_DIR
+ VERSION_VAR
+ Libinput_VERSION
+)
+
+if(Libinput_FOUND AND NOT TARGET Libinput::Libinput)
+ add_library(Libinput::Libinput UNKNOWN IMPORTED)
+ set_target_properties(Libinput::Libinput PROPERTIES
+ IMPORTED_LOCATION "${Libinput_LIBRARY}"
+ INTERFACE_COMPILE_OPTIONS "${Libinput_COMPILE_OPTIONS}"
+ INTERFACE_INCLUDE_DIRECTORIES "${Libinput_INCLUDE_DIR}"
+ )
+endif()
+
+mark_as_advanced(Libinput_LIBRARY Libinput_INCLUDE_DIR)
+
+if(Libinput_FOUND)
+ set(Libinput_LIBRARIES ${Libinput_LIBRARY})
+ set(Libinput_INCLUDE_DIRS ${Libinput_INCLUDE_DIR})
+endif()
diff --git a/Modules/FindLua.cmake b/Modules/FindLua.cmake
index b59b9b3c6..caf9d69b2 100644
--- a/Modules/FindLua.cmake
+++ b/Modules/FindLua.cmake
@@ -1,47 +1,53 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindLua
-# -------
-#
-#
-#
-# Locate Lua library This module defines
-#
-# ::
-#
-# LUA_FOUND - if false, do not try to link to Lua
-# LUA_LIBRARIES - both lua and lualib
-# LUA_INCLUDE_DIR - where to find lua.h
-# LUA_VERSION_STRING - the version of Lua found
-# LUA_VERSION_MAJOR - the major version of Lua
-# LUA_VERSION_MINOR - the minor version of Lua
-# LUA_VERSION_PATCH - the patch version of Lua
-#
-#
-#
-# Note that the expected include convention is
-#
-# ::
-#
-# #include "lua.h"
-#
-# and not
-#
-# ::
-#
-# #include <lua/lua.h>
-#
-# This is because, the lua location is not standardized and may exist in
-# locations other than lua/
+#[=======================================================================[.rst:
+FindLua
+-------
+
+
+
+Locate Lua library.
+
+This module defines::
+
+::
+
+ LUA_FOUND - if false, do not try to link to Lua
+ LUA_LIBRARIES - both lua and lualib
+ LUA_INCLUDE_DIR - where to find lua.h
+ LUA_VERSION_STRING - the version of Lua found
+ LUA_VERSION_MAJOR - the major version of Lua
+ LUA_VERSION_MINOR - the minor version of Lua
+ LUA_VERSION_PATCH - the patch version of Lua
+
+
+
+Note that the expected include convention is
+
+::
+
+ #include "lua.h"
+
+and not
+
+::
+
+ #include <lua/lua.h>
+
+This is because, the lua location is not standardized and may exist in
+locations other than lua/
+#]=======================================================================]
+
+cmake_policy(PUSH) # Policies apply to functions at definition-time
+cmake_policy(SET CMP0012 NEW) # For while(TRUE)
unset(_lua_include_subdirs)
unset(_lua_library_names)
unset(_lua_append_versions)
# this is a function only to have all the variables inside go away automatically
-function(_lua_set_version_vars)
+function(_lua_get_versions)
set(LUA_VERSIONS5 5.3 5.2 5.1 5.0)
if (Lua_FIND_VERSION_EXACT)
@@ -59,6 +65,10 @@ function(_lua_set_version_vars)
list(APPEND _lua_append_versions ${subver})
endif ()
endforeach ()
+ # New version -> Search for it (heuristic only! Defines in include might have changed)
+ if (NOT _lua_append_versions)
+ set(_lua_append_versions ${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR})
+ endif()
endif ()
endif ()
else ()
@@ -66,125 +76,153 @@ function(_lua_set_version_vars)
set(_lua_append_versions ${LUA_VERSIONS5})
endif ()
- list(APPEND _lua_include_subdirs "include/lua" "include")
-
- foreach (ver IN LISTS _lua_append_versions)
- string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}")
- list(APPEND _lua_include_subdirs
- include/lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
- include/lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
- include/lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
- )
- endforeach ()
+ if (LUA_Debug)
+ message(STATUS "Considering following Lua versions: ${_lua_append_versions}")
+ endif()
- set(_lua_include_subdirs "${_lua_include_subdirs}" PARENT_SCOPE)
set(_lua_append_versions "${_lua_append_versions}" PARENT_SCOPE)
-endfunction(_lua_set_version_vars)
+endfunction()
-function(_lua_check_header_version _hdr_file)
- # At least 5.[012] have different ways to express the version
- # so all of them need to be tested. Lua 5.2 defines LUA_VERSION
- # and LUA_RELEASE as joined by the C preprocessor, so avoid those.
- file(STRINGS "${_hdr_file}" lua_version_strings
- REGEX "^#define[ \t]+LUA_(RELEASE[ \t]+\"Lua [0-9]|VERSION([ \t]+\"Lua [0-9]|_[MR])).*")
-
- string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MAJOR ";${lua_version_strings};")
- if (LUA_VERSION_MAJOR MATCHES "^[0-9]+$")
- string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MINOR ";${lua_version_strings};")
- string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_RELEASE[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_PATCH ";${lua_version_strings};")
- set(LUA_VERSION_STRING "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
- else ()
- string(REGEX REPLACE ".*;#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
- if (NOT LUA_VERSION_STRING MATCHES "^[0-9.]+$")
- string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
- endif ()
- string(REGEX REPLACE "^([0-9]+)\\.[0-9.]*$" "\\1" LUA_VERSION_MAJOR "${LUA_VERSION_STRING}")
- string(REGEX REPLACE "^[0-9]+\\.([0-9]+)[0-9.]*$" "\\1" LUA_VERSION_MINOR "${LUA_VERSION_STRING}")
- string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]).*" "\\1" LUA_VERSION_PATCH "${LUA_VERSION_STRING}")
- endif ()
- foreach (ver IN LISTS _lua_append_versions)
- if (ver STREQUAL "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
- set(LUA_VERSION_MAJOR ${LUA_VERSION_MAJOR} PARENT_SCOPE)
- set(LUA_VERSION_MINOR ${LUA_VERSION_MINOR} PARENT_SCOPE)
- set(LUA_VERSION_PATCH ${LUA_VERSION_PATCH} PARENT_SCOPE)
- set(LUA_VERSION_STRING ${LUA_VERSION_STRING} PARENT_SCOPE)
- return()
- endif ()
- endforeach ()
-endfunction(_lua_check_header_version)
+function(_lua_set_version_vars)
+ set(_lua_include_subdirs_raw "lua")
+
+ foreach (ver IN LISTS _lua_append_versions)
+ string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}")
+ list(APPEND _lua_include_subdirs_raw
+ lua${CMAKE_MATCH_1}${CMAKE_MATCH_2}
+ lua${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
+ lua-${CMAKE_MATCH_1}.${CMAKE_MATCH_2}
+ )
+ endforeach ()
-_lua_set_version_vars()
+ # Prepend "include/" to each path directly after the path
+ set(_lua_include_subdirs "include")
+ foreach (dir IN LISTS _lua_include_subdirs_raw)
+ list(APPEND _lua_include_subdirs "${dir}" "include/${dir}")
+ endforeach ()
-if (LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
- _lua_check_header_version("${LUA_INCLUDE_DIR}/lua.h")
-endif ()
+ set(_lua_include_subdirs "${_lua_include_subdirs}" PARENT_SCOPE)
+endfunction(_lua_set_version_vars)
-if (NOT LUA_VERSION_STRING)
+function(_lua_get_header_version)
+ unset(LUA_VERSION_STRING PARENT_SCOPE)
+ set(_hdr_file "${LUA_INCLUDE_DIR}/lua.h")
+
+ if (NOT EXISTS "${_hdr_file}")
+ return()
+ endif ()
+
+ # At least 5.[012] have different ways to express the version
+ # so all of them need to be tested. Lua 5.2 defines LUA_VERSION
+ # and LUA_RELEASE as joined by the C preprocessor, so avoid those.
+ file(STRINGS "${_hdr_file}" lua_version_strings
+ REGEX "^#define[ \t]+LUA_(RELEASE[ \t]+\"Lua [0-9]|VERSION([ \t]+\"Lua [0-9]|_[MR])).*")
+
+ string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MAJOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MAJOR ";${lua_version_strings};")
+ if (LUA_VERSION_MAJOR MATCHES "^[0-9]+$")
+ string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_MINOR[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_MINOR ";${lua_version_strings};")
+ string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION_RELEASE[ \t]+\"([0-9])\"[ \t]*;.*" "\\1" LUA_VERSION_PATCH ";${lua_version_strings};")
+ set(LUA_VERSION_STRING "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
+ else ()
+ string(REGEX REPLACE ".*;#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
+ if (NOT LUA_VERSION_STRING MATCHES "^[0-9.]+$")
+ string(REGEX REPLACE ".*;#define[ \t]+LUA_VERSION[ \t]+\"Lua ([0-9.]+)\"[ \t]*;.*" "\\1" LUA_VERSION_STRING ";${lua_version_strings};")
+ endif ()
+ string(REGEX REPLACE "^([0-9]+)\\.[0-9.]*$" "\\1" LUA_VERSION_MAJOR "${LUA_VERSION_STRING}")
+ string(REGEX REPLACE "^[0-9]+\\.([0-9]+)[0-9.]*$" "\\1" LUA_VERSION_MINOR "${LUA_VERSION_STRING}")
+ string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]).*" "\\1" LUA_VERSION_PATCH "${LUA_VERSION_STRING}")
+ endif ()
+ foreach (ver IN LISTS _lua_append_versions)
+ if (ver STREQUAL "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
+ set(LUA_VERSION_MAJOR ${LUA_VERSION_MAJOR} PARENT_SCOPE)
+ set(LUA_VERSION_MINOR ${LUA_VERSION_MINOR} PARENT_SCOPE)
+ set(LUA_VERSION_PATCH ${LUA_VERSION_PATCH} PARENT_SCOPE)
+ set(LUA_VERSION_STRING ${LUA_VERSION_STRING} PARENT_SCOPE)
+ return()
+ endif ()
+ endforeach ()
+endfunction(_lua_get_header_version)
+
+function(_lua_find_header)
+ _lua_set_version_vars()
+
+ # Initialize as local variable
+ set(CMAKE_IGNORE_PATH ${CMAKE_IGNORE_PATH})
+ while (TRUE)
+ # Find the next header to test. Check each possible subdir in order
+ # This prefers e.g. higher versions as they are earlier in the list
+ # It is also consistent with previous versions of FindLua
foreach (subdir IN LISTS _lua_include_subdirs)
- unset(LUA_INCLUDE_PREFIX CACHE)
- find_path(LUA_INCLUDE_PREFIX ${subdir}/lua.h
- HINTS
- ENV LUA_DIR
- PATHS
- ~/Library/Frameworks
- /Library/Frameworks
- /sw # Fink
- /opt/local # DarwinPorts
- /opt/csw # Blastwave
- /opt
+ find_path(LUA_INCLUDE_DIR lua.h
+ HINTS ENV LUA_DIR
+ PATH_SUFFIXES ${subdir}
)
- if (LUA_INCLUDE_PREFIX)
- _lua_check_header_version("${LUA_INCLUDE_PREFIX}/${subdir}/lua.h")
- if (LUA_VERSION_STRING)
- set(LUA_INCLUDE_DIR "${LUA_INCLUDE_PREFIX}/${subdir}")
- break()
- endif ()
- endif ()
- endforeach ()
-endif ()
-unset(_lua_include_subdirs)
+ if (LUA_INCLUDE_DIR)
+ break()
+ endif()
+ endforeach()
+ # Did not found header -> Fail
+ if (NOT LUA_INCLUDE_DIR)
+ return()
+ endif()
+ _lua_get_header_version()
+ # Found accepted version -> Ok
+ if (LUA_VERSION_STRING)
+ if (LUA_Debug)
+ message(STATUS "Found suitable version ${LUA_VERSION_STRING} in ${LUA_INCLUDE_DIR}/lua.h")
+ endif()
+ return()
+ endif()
+ # Found wrong version -> Ignore this path and retry
+ if (LUA_Debug)
+ message(STATUS "Ignoring unsuitable version in ${LUA_INCLUDE_DIR}")
+ endif()
+ list(APPEND CMAKE_IGNORE_PATH "${LUA_INCLUDE_DIR}")
+ unset(LUA_INCLUDE_DIR CACHE)
+ unset(LUA_INCLUDE_DIR)
+ unset(LUA_INCLUDE_DIR PARENT_SCOPE)
+ endwhile ()
+endfunction()
+
+_lua_get_versions()
+_lua_find_header()
+_lua_get_header_version()
unset(_lua_append_versions)
if (LUA_VERSION_STRING)
- set(_lua_library_names
- lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}
- lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}
- lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}
- lua.${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}
+ set(_lua_library_names
+ lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}
+ lua${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}
+ lua-${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}
+ lua.${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}
)
endif ()
find_library(LUA_LIBRARY
NAMES ${_lua_library_names} lua
+ NAMES_PER_DIR
HINTS
ENV LUA_DIR
PATH_SUFFIXES lib
- PATHS
- ~/Library/Frameworks
- /Library/Frameworks
- /sw
- /opt/local
- /opt/csw
- /opt
)
unset(_lua_library_names)
if (LUA_LIBRARY)
- # include the math library for Unix
- if (UNIX AND NOT APPLE AND NOT BEOS)
- find_library(LUA_MATH_LIBRARY m)
- set(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}")
-
- # include dl library for statically-linked Lua library
- get_filename_component(LUA_LIB_EXT ${LUA_LIBRARY} EXT)
- if(LUA_LIB_EXT STREQUAL CMAKE_STATIC_LIBRARY_SUFFIX)
- list(APPEND LUA_LIBRARIES ${CMAKE_DL_LIBS})
- endif()
-
- # For Windows and Mac, don't need to explicitly include the math library
- else ()
- set(LUA_LIBRARIES "${LUA_LIBRARY}")
- endif ()
+ # include the math library for Unix
+ if (UNIX AND NOT APPLE AND NOT BEOS)
+ find_library(LUA_MATH_LIBRARY m)
+ set(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}")
+
+ # include dl library for statically-linked Lua library
+ get_filename_component(LUA_LIB_EXT ${LUA_LIBRARY} EXT)
+ if(LUA_LIB_EXT STREQUAL CMAKE_STATIC_LIBRARY_SUFFIX)
+ list(APPEND LUA_LIBRARIES ${CMAKE_DL_LIBS})
+ endif()
+
+ # For Windows and Mac, don't need to explicitly include the math library
+ else ()
+ set(LUA_LIBRARIES "${LUA_LIBRARY}")
+ endif ()
endif ()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
@@ -195,3 +233,5 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua
VERSION_VAR LUA_VERSION_STRING)
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY LUA_MATH_LIBRARY)
+
+cmake_policy(POP)
diff --git a/Modules/FindLua50.cmake b/Modules/FindLua50.cmake
index 838ca6a88..0575caac6 100644
--- a/Modules/FindLua50.cmake
+++ b/Modules/FindLua50.cmake
@@ -1,36 +1,38 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindLua50
-# ---------
-#
-#
-#
-# Locate Lua library This module defines
-#
-# ::
-#
-# LUA50_FOUND, if false, do not try to link to Lua
-# LUA_LIBRARIES, both lua and lualib
-# LUA_INCLUDE_DIR, where to find lua.h and lualib.h (and probably lauxlib.h)
-#
-#
-#
-# Note that the expected include convention is
-#
-# ::
-#
-# #include "lua.h"
-#
-# and not
-#
-# ::
-#
-# #include <lua/lua.h>
-#
-# This is because, the lua location is not standardized and may exist in
-# locations other than lua/
+#[=======================================================================[.rst:
+FindLua50
+---------
+
+
+
+Locate Lua library.
+This module defines::
+
+::
+
+ LUA50_FOUND, if false, do not try to link to Lua
+ LUA_LIBRARIES, both lua and lualib
+ LUA_INCLUDE_DIR, where to find lua.h and lualib.h (and probably lauxlib.h)
+
+
+
+Note that the expected include convention is
+
+::
+
+ #include "lua.h"
+
+and not
+
+::
+
+ #include <lua/lua.h>
+
+This is because, the lua location is not standardized and may exist in
+locations other than lua/
+#]=======================================================================]
find_path(LUA_INCLUDE_DIR lua.h
HINTS
@@ -39,9 +41,6 @@ find_path(LUA_INCLUDE_DIR lua.h
PATHS
~/Library/Frameworks
/Library/Frameworks
- /sw # Fink
- /opt/local # DarwinPorts
- /opt/csw # Blastwave
/opt
)
@@ -53,9 +52,6 @@ find_library(LUA_LIBRARY_lua
PATHS
~/Library/Frameworks
/Library/Frameworks
- /sw
- /opt/local
- /opt/csw
/opt
)
@@ -71,19 +67,16 @@ else()
ENV LUA_DIR
PATH_SUFFIXES lib
PATHS
- /sw
- /opt/local
- /opt/csw
/opt
)
if(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua)
# include the math library for Unix
if(UNIX AND NOT APPLE)
find_library(MATH_LIBRARY_FOR_LUA m)
- set( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua};${MATH_LIBRARY_FOR_LUA}" CACHE STRING "This is the concatentation of lua and lualib libraries")
+ set( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua};${MATH_LIBRARY_FOR_LUA}" CACHE STRING "This is the concatenation of lua and lualib libraries")
# For Windows and Mac, don't need to explicitly include the math library
else()
- set( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua}" CACHE STRING "This is the concatentation of lua and lualib libraries")
+ set( LUA_LIBRARIES "${LUA_LIBRARY_lualib};${LUA_LIBRARY_lua}" CACHE STRING "This is the concatenation of lua and lualib libraries")
endif()
endif()
endif()
@@ -95,4 +88,3 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua50 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR)
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES)
-
diff --git a/Modules/FindLua51.cmake b/Modules/FindLua51.cmake
index f2b232216..283a3ebfc 100644
--- a/Modules/FindLua51.cmake
+++ b/Modules/FindLua51.cmake
@@ -1,37 +1,39 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindLua51
-# ---------
-#
-#
-#
-# Locate Lua library This module defines
-#
-# ::
-#
-# LUA51_FOUND, if false, do not try to link to Lua
-# LUA_LIBRARIES
-# LUA_INCLUDE_DIR, where to find lua.h
-# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
-#
-#
-#
-# Note that the expected include convention is
-#
-# ::
-#
-# #include "lua.h"
-#
-# and not
-#
-# ::
-#
-# #include <lua/lua.h>
-#
-# This is because, the lua location is not standardized and may exist in
-# locations other than lua/
+#[=======================================================================[.rst:
+FindLua51
+---------
+
+
+
+Locate Lua library.
+This module defines::
+
+::
+
+ LUA51_FOUND, if false, do not try to link to Lua
+ LUA_LIBRARIES
+ LUA_INCLUDE_DIR, where to find lua.h
+ LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
+
+
+
+Note that the expected include convention is
+
+::
+
+ #include "lua.h"
+
+and not
+
+::
+
+ #include <lua/lua.h>
+
+This is because, the lua location is not standardized and may exist in
+locations other than lua/
+#]=======================================================================]
find_path(LUA_INCLUDE_DIR lua.h
HINTS
@@ -40,9 +42,6 @@ find_path(LUA_INCLUDE_DIR lua.h
PATHS
~/Library/Frameworks
/Library/Frameworks
- /sw # Fink
- /opt/local # DarwinPorts
- /opt/csw # Blastwave
/opt
)
@@ -54,9 +53,6 @@ find_library(LUA_LIBRARY
PATHS
~/Library/Frameworks
/Library/Frameworks
- /sw
- /opt/local
- /opt/csw
/opt
)
@@ -86,4 +82,3 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51
VERSION_VAR LUA_VERSION_STRING)
mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
-
diff --git a/Modules/FindMFC.cmake b/Modules/FindMFC.cmake
index 5c2dbbf6c..e366619ce 100644
--- a/Modules/FindMFC.cmake
+++ b/Modules/FindMFC.cmake
@@ -1,20 +1,21 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindMFC
-# -------
-#
-# Find MFC on Windows
-#
-# Find the native MFC - i.e. decide if an application can link to the
-# MFC libraries.
-#
-# ::
-#
-# MFC_FOUND - Was MFC support found
-#
-# You don't need to include anything or link anything to use it.
+#[=======================================================================[.rst:
+FindMFC
+-------
+
+Find Microsoft Foundation Class Library (MFC) on Windows
+
+Find the native MFC - i.e. decide if an application can link to the
+MFC libraries.
+
+::
+
+ MFC_FOUND - Was MFC support found
+
+You don't need to include anything or link anything to use it.
+#]=======================================================================]
# Assume no MFC support
set(MFC_FOUND "NO")
@@ -31,6 +32,7 @@ if(MFC_ATTEMPT_TRY_COMPILE)
configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx)
message(STATUS "Looking for MFC")
+ # Try both shared and static as the root project may have set the /MT flag
try_compile(MFC_HAVE_MFC
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx
@@ -38,6 +40,16 @@ if(MFC_ATTEMPT_TRY_COMPILE)
-DCMAKE_MFC_FLAG:STRING=2
-DCOMPILE_DEFINITIONS:STRING=-D_AFXDLL
OUTPUT_VARIABLE OUTPUT)
+ if(NOT MFC_HAVE_MFC)
+ configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx)
+ try_compile(MFC_HAVE_MFC
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx
+ CMAKE_FLAGS
+ -DCMAKE_MFC_FLAG:STRING=1
+ OUTPUT_VARIABLE OUTPUT)
+ endif()
if(MFC_HAVE_MFC)
message(STATUS "Looking for MFC - found")
set(MFC_HAVE_MFC 1 CACHE INTERNAL "Have MFC?")
diff --git a/Modules/FindMPEG.cmake b/Modules/FindMPEG.cmake
index cd1b0214e..e5a80e389 100644
--- a/Modules/FindMPEG.cmake
+++ b/Modules/FindMPEG.cmake
@@ -1,44 +1,43 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindMPEG
-# --------
-#
-# Find the native MPEG includes and library
-#
-# This module defines
-#
-# ::
-#
-# MPEG_INCLUDE_DIR, where to find MPEG.h, etc.
-# MPEG_LIBRARIES, the libraries required to use MPEG.
-# MPEG_FOUND, If false, do not try to use MPEG.
-#
-# also defined, but not for general use are
-#
-# ::
-#
-# MPEG_mpeg2_LIBRARY, where to find the MPEG library.
-# MPEG_vo_LIBRARY, where to find the vo library.
-
-find_path(MPEG_INCLUDE_DIR mpeg2dec/include/video_out.h
- /usr/local/livid
-)
-
-find_library(MPEG_mpeg2_LIBRARY mpeg2
- /usr/local/livid/mpeg2dec/libmpeg2/.libs
-)
-
-find_library( MPEG_vo_LIBRARY vo
- /usr/local/livid/mpeg2dec/libvo/.libs
-)
+#[=======================================================================[.rst:
+FindMPEG
+--------
+
+Find the native MPEG includes and library
+
+This module defines
+
+::
+
+ MPEG_INCLUDE_DIR, where to find MPEG.h, etc.
+ MPEG_LIBRARIES, the libraries required to use MPEG.
+ MPEG_FOUND, If false, do not try to use MPEG.
+
+also defined, but not for general use are
+
+::
+
+ MPEG_mpeg2_LIBRARY, where to find the MPEG library.
+ MPEG_vo_LIBRARY, where to find the vo library.
+#]=======================================================================]
+
+find_path(MPEG_INCLUDE_DIR
+ NAMES mpeg2.h mpeg2dec/mpeg2.h mpeg2dec/include/video_out.h)
+
+find_library(MPEG_mpeg2_LIBRARY mpeg2)
+
+find_library(MPEG_vo_LIBRARY vo)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(MPEG DEFAULT_MSG MPEG_INCLUDE_DIR MPEG_mpeg2_LIBRARY MPEG_vo_LIBRARY)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(MPEG DEFAULT_MSG MPEG_mpeg2_LIBRARY MPEG_INCLUDE_DIR)
if(MPEG_FOUND)
- set( MPEG_LIBRARIES ${MPEG_mpeg2_LIBRARY} ${MPEG_vo_LIBRARY} )
+ set( MPEG_LIBRARIES ${MPEG_mpeg2_LIBRARY} )
+ if(MPEG_vo_LIBRARY)
+ list(APPEND MPEG2_LIBRARIES ${MPEG_vo_LIBRARY})
+ endif()
endif()
mark_as_advanced(MPEG_INCLUDE_DIR MPEG_mpeg2_LIBRARY MPEG_vo_LIBRARY)
diff --git a/Modules/FindMPEG2.cmake b/Modules/FindMPEG2.cmake
index 2c75d7b2e..763d86a85 100644
--- a/Modules/FindMPEG2.cmake
+++ b/Modules/FindMPEG2.cmake
@@ -1,50 +1,47 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindMPEG2
-# ---------
-#
-# Find the native MPEG2 includes and library
-#
-# This module defines
-#
-# ::
-#
-# MPEG2_INCLUDE_DIR, path to mpeg2dec/mpeg2.h, etc.
-# MPEG2_LIBRARIES, the libraries required to use MPEG2.
-# MPEG2_FOUND, If false, do not try to use MPEG2.
-#
-# also defined, but not for general use are
-#
-# ::
-#
-# MPEG2_mpeg2_LIBRARY, where to find the MPEG2 library.
-# MPEG2_vo_LIBRARY, where to find the vo library.
+#[=======================================================================[.rst:
+FindMPEG2
+---------
+
+Find the native MPEG2 includes and library
+
+This module defines
+
+::
+
+ MPEG2_INCLUDE_DIR, path to mpeg2dec/mpeg2.h, etc.
+ MPEG2_LIBRARIES, the libraries required to use MPEG2.
+ MPEG2_FOUND, If false, do not try to use MPEG2.
+
+also defined, but not for general use are
+
+::
+
+ MPEG2_mpeg2_LIBRARY, where to find the MPEG2 library.
+ MPEG2_vo_LIBRARY, where to find the vo library.
+#]=======================================================================]
find_path(MPEG2_INCLUDE_DIR
- NAMES mpeg2.h mpeg2dec/mpeg2.h
- PATHS /usr/local/livid
-)
+ NAMES mpeg2.h mpeg2dec/mpeg2.h)
-find_library(MPEG2_mpeg2_LIBRARY mpeg2
- /usr/local/livid/mpeg2dec/libmpeg2/.libs
-)
+find_library(MPEG2_mpeg2_LIBRARY mpeg2)
-find_library( MPEG2_vo_LIBRARY vo
- /usr/local/livid/mpeg2dec/libvo/.libs
-)
+find_library(MPEG2_vo_LIBRARY vo)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MPEG2 DEFAULT_MSG MPEG2_mpeg2_LIBRARY MPEG2_INCLUDE_DIR)
if(MPEG2_FOUND)
- set( MPEG2_LIBRARIES ${MPEG2_mpeg2_LIBRARY}
- ${MPEG2_vo_LIBRARY})
+ set(MPEG2_LIBRARIES ${MPEG2_mpeg2_LIBRARY})
+ if(MPEG2_vo_LIBRARY)
+ list(APPEND MPEG2_LIBRARIES ${MPEG2_vo_LIBRARY})
+ endif()
#some native mpeg2 installations will depend
#on libSDL, if found, add it in.
- include(${CMAKE_CURRENT_LIST_DIR}/FindSDL.cmake)
+ find_package(SDL)
if(SDL_FOUND)
set( MPEG2_LIBRARIES ${MPEG2_LIBRARIES} ${SDL_LIBRARY})
endif()
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 37f325572..d6cd799b3 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -1,143 +1,301 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindMPI
-# -------
-#
-# Find a Message Passing Interface (MPI) implementation
-#
-# The Message Passing Interface (MPI) is a library used to write
-# high-performance distributed-memory parallel applications, and is
-# typically deployed on a cluster. MPI is a standard interface (defined
-# by the MPI forum) for which many implementations are available.
-#
-# Variables
-# ^^^^^^^^^
-#
-# This module will set the following variables per language in your
-# project, where ``<lang>`` is one of C, CXX, or Fortran:
-#
-# ``MPI_<lang>_FOUND``
-# Variable indicating the MPI settings for ``<lang>`` were found.
-# ``MPI_<lang>_COMPILER``
-# MPI Compiler wrapper for ``<lang>``.
-# ``MPI_<lang>_COMPILE_FLAGS``
-# Compilation flags for MPI programs, separated by spaces.
-# This is *not* a :ref:`;-list <CMake Language Lists>`.
-# ``MPI_<lang>_INCLUDE_PATH``
-# Include path(s) for MPI header.
-# ``MPI_<lang>_LINK_FLAGS``
-# Linker flags for MPI programs.
-# ``MPI_<lang>_LIBRARIES``
-# All libraries to link MPI programs against.
-#
-# Additionally, the following :prop_tgt:`IMPORTED` targets are defined:
-#
-# ``MPI::MPI_<lang>``
-# Target for using MPI from ``<lang>``.
-#
-# Additionally, FindMPI sets the following variables for running MPI
-# programs from the command line:
-#
-# ``MPIEXEC``
-# Executable for running MPI programs, if provided.
-# ``MPIEXEC_NUMPROC_FLAG``
-# Flag to pass to ``MPIEXEC`` before giving it the number of processors to run on.
-# ``MPIEXEC_MAX_NUMPROCS``
-# Number of MPI processors to utilize. Defaults to the number
-# of processors detected on the host system.
-# ``MPIEXEC_PREFLAGS``
-# Flags to pass to ``MPIEXEC`` directly before the executable to run.
-# ``MPIEXEC_POSTFLAGS``
-# Flags to pass to ``MPIEXEC`` after other flags.
-#
-# Usage
-# ^^^^^
-#
-# To use this module, call ``find_package(MPI)``. If you are happy with the
-# auto-detected configuration for your language, then you're done. If
-# not, you have two options:
-#
-# 1. Set ``MPI_<lang>_COMPILER`` to the MPI wrapper (e.g. ``mpicc``) of your
-# choice and reconfigure. FindMPI will attempt to determine all the
-# necessary variables using *that* compiler's compile and link flags.
-# 2. If this fails, or if your MPI implementation does not come with
-# a compiler wrapper, then set both ``MPI_<lang>_LIBRARIES`` and
-# ``MPI_<lang>_INCLUDE_PATH``. You may also set any other variables
-# listed above, but these two are required. This will circumvent
-# autodetection entirely.
-#
-# When configuration is successful, ``MPI_<lang>_COMPILER`` will be set to
-# the compiler wrapper for ``<lang>``, if it was found. ``MPI_<lang>_FOUND``
-# and other variables above will be set if any MPI implementation was
-# found for ``<lang>``, regardless of whether a compiler was found.
-#
-# When using ``MPIEXEC`` to execute MPI applications, you should typically
-# use all of the ``MPIEXEC`` flags as follows:
-#
-# ::
-#
-# ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS}
-# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS
-#
-# where ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to
-# pass to the MPI program.
-#
-# Backward Compatibility
-# ^^^^^^^^^^^^^^^^^^^^^^
-#
-# For backward compatibility with older versions of FindMPI, these
-# variables are set, but deprecated:
-#
-# ::
-#
-# MPI_FOUND MPI_COMPILER MPI_LIBRARY
-# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_EXTRA_LIBRARY
-# MPI_LINK_FLAGS MPI_LIBRARIES
-#
-# In new projects, please use the ``MPI_<lang>_XXX`` equivalents.
+#[=======================================================================[.rst:
+FindMPI
+-------
+
+Find a Message Passing Interface (MPI) implementation.
+
+The Message Passing Interface (MPI) is a library used to write
+high-performance distributed-memory parallel applications, and is
+typically deployed on a cluster. MPI is a standard interface (defined
+by the MPI forum) for which many implementations are available.
+
+Variables for using MPI
+^^^^^^^^^^^^^^^^^^^^^^^
+
+The module exposes the components ``C``, ``CXX``, ``MPICXX`` and ``Fortran``.
+Each of these controls the various MPI languages to search for.
+The difference between ``CXX`` and ``MPICXX`` is that ``CXX`` refers to the
+MPI C API being usable from C++, whereas ``MPICXX`` refers to the MPI-2 C++ API
+that was removed again in MPI-3.
+
+Depending on the enabled components the following variables will be set:
+
+``MPI_FOUND``
+ Variable indicating that MPI settings for all requested languages have been found.
+ If no components are specified, this is true if MPI settings for all enabled languages
+ were detected. Note that the ``MPICXX`` component does not affect this variable.
+``MPI_VERSION``
+ Minimal version of MPI detected among the requested languages, or all enabled languages
+ if no components were specified.
+
+This module will set the following variables per language in your
+project, where ``<lang>`` is one of C, CXX, or Fortran:
+
+``MPI_<lang>_FOUND``
+ Variable indicating the MPI settings for ``<lang>`` were found and that
+ simple MPI test programs compile with the provided settings.
+``MPI_<lang>_COMPILER``
+ MPI compiler for ``<lang>`` if such a program exists.
+``MPI_<lang>_COMPILE_OPTIONS``
+ Compilation options for MPI programs in ``<lang>``, given as a :ref:`;-list <CMake Language Lists>`.
+``MPI_<lang>_COMPILE_DEFINITIONS``
+ Compilation definitions for MPI programs in ``<lang>``, given as a :ref:`;-list <CMake Language Lists>`.
+``MPI_<lang>_INCLUDE_DIRS``
+ Include path(s) for MPI header.
+``MPI_<lang>_LINK_FLAGS``
+ Linker flags for MPI programs.
+``MPI_<lang>_LIBRARIES``
+ All libraries to link MPI programs against.
+
+Additionally, the following :prop_tgt:`IMPORTED` targets are defined:
+
+``MPI::MPI_<lang>``
+ Target for using MPI from ``<lang>``.
+
+The following variables indicating which bindings are present will be defined:
+
+``MPI_MPICXX_FOUND``
+ Variable indicating whether the MPI-2 C++ bindings are present (introduced in MPI-2, removed with MPI-3).
+``MPI_Fortran_HAVE_F77_HEADER``
+ True if the Fortran 77 header ``mpif.h`` is available.
+``MPI_Fortran_HAVE_F90_MODULE``
+ True if the Fortran 90 module ``mpi`` can be used for accessing MPI (MPI-2 and higher only).
+``MPI_Fortran_HAVE_F08_MODULE``
+ True if the Fortran 2008 ``mpi_f08`` is available to MPI programs (MPI-3 and higher only).
+
+If possible, the MPI version will be determined by this module. The facilities to detect the MPI version
+were introduced with MPI-1.2, and therefore cannot be found for older MPI versions.
+
+``MPI_<lang>_VERSION_MAJOR``
+ Major version of MPI implemented for ``<lang>`` by the MPI distribution.
+``MPI_<lang>_VERSION_MINOR``
+ Minor version of MPI implemented for ``<lang>`` by the MPI distribution.
+``MPI_<lang>_VERSION``
+ MPI version implemented for ``<lang>`` by the MPI distribution.
+
+Note that there's no variable for the C bindings being accessible through ``mpi.h``, since the MPI standards
+always have required this binding to work in both C and C++ code.
+
+For running MPI programs, the module sets the following variables
+
+``MPIEXEC_EXECUTABLE``
+ Executable for running MPI programs, if such exists.
+``MPIEXEC_NUMPROC_FLAG``
+ Flag to pass to ``mpiexec`` before giving it the number of processors to run on.
+``MPIEXEC_MAX_NUMPROCS``
+ Number of MPI processors to utilize. Defaults to the number
+ of processors detected on the host system.
+``MPIEXEC_PREFLAGS``
+ Flags to pass to ``mpiexec`` directly before the executable to run.
+``MPIEXEC_POSTFLAGS``
+ Flags to pass to ``mpiexec`` after other flags.
+
+Variables for locating MPI
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This module performs a four step search for an MPI implementation:
+
+1. Search for ``MPIEXEC_EXECUTABLE`` and, if found, use its base directory.
+2. Check if the compiler has MPI support built-in. This is the case if the user passed a
+ compiler wrapper as ``CMAKE_<LANG>_COMPILER`` or if they're on a Cray system.
+3. Attempt to find an MPI compiler wrapper and determine the compiler information from it.
+4. Try to find an MPI implementation that does not ship such a wrapper by guessing settings.
+ Currently, only Microsoft MPI and MPICH2 on Windows are supported.
+
+For controlling the ``MPIEXEC_EXECUTABLE`` step, the following variables may be set:
+
+``MPIEXEC_EXECUTABLE``
+ Manually specify the location of ``mpiexec``.
+``MPI_HOME``
+ Specify the base directory of the MPI installation.
+``ENV{MPI_HOME}``
+ Environment variable to specify the base directory of the MPI installation.
+``ENV{I_MPI_ROOT}``
+ Environment variable to specify the base directory of the MPI installation.
+
+For controlling the compiler wrapper step, the following variables may be set:
+
+``MPI_<lang>_COMPILER``
+ Search for the specified compiler wrapper and use it.
+``MPI_<lang>_COMPILER_FLAGS``
+ Flags to pass to the MPI compiler wrapper during interrogation. Some compiler wrappers
+ support linking debug or tracing libraries if a specific flag is passed and this variable
+ may be used to obtain them.
+``MPI_COMPILER_FLAGS``
+ Used to initialize ``MPI_<lang>_COMPILER_FLAGS`` if no language specific flag has been given.
+ Empty by default.
+``MPI_EXECUTABLE_SUFFIX``
+ A suffix which is appended to all names that are being looked for. For instance you may set this
+ to ``.mpich`` or ``.openmpi`` to prefer the one or the other on Debian and its derivatives.
+
+In order to control the guessing step, the following variable may be set:
+
+``MPI_GUESS_LIBRARY_NAME``
+ Valid values are ``MSMPI`` and ``MPICH2``. If set, only the given library will be searched for.
+ By default, ``MSMPI`` will be preferred over ``MPICH2`` if both are available.
+ This also sets ``MPI_SKIP_COMPILER_WRAPPER`` to ``true``, which may be overridden.
+
+Each of the search steps may be skipped with the following control variables:
+
+``MPI_ASSUME_NO_BUILTIN_MPI``
+ If true, the module assumes that the compiler itself does not provide an MPI implementation and
+ skips to step 2.
+``MPI_SKIP_COMPILER_WRAPPER``
+ If true, no compiler wrapper will be searched for.
+``MPI_SKIP_GUESSING``
+ If true, the guessing step will be skipped.
+
+Additionally, the following control variable is available to change search behavior:
+
+``MPI_CXX_SKIP_MPICXX``
+ Add some definitions that will disable the MPI-2 C++ bindings.
+ Currently supported are MPICH, Open MPI, Platform MPI and derivatives thereof,
+ for example MVAPICH or Intel MPI.
+
+If the find procedure fails for a variable ``MPI_<lang>_WORKS``, then the settings detected by or passed to
+the module did not work and even a simple MPI test program failed to compile.
+
+If all of these parameters were not sufficient to find the right MPI implementation, a user may
+disable the entire autodetection process by specifying both a list of libraries in ``MPI_<lang>_LIBRARIES``
+and a list of include directories in ``MPI_<lang>_ADDITIONAL_INCLUDE_DIRS``.
+Any other variable may be set in addition to these two. The module will then validate the MPI settings and store the
+settings in the cache.
+
+Cache variables for MPI
+^^^^^^^^^^^^^^^^^^^^^^^
+
+The variable ``MPI_<lang>_INCLUDE_DIRS`` will be assembled from the following variables.
+For C and CXX:
+
+``MPI_<lang>_HEADER_DIR``
+ Location of the ``mpi.h`` header on disk.
+
+For Fortran:
+
+``MPI_Fortran_F77_HEADER_DIR``
+ Location of the Fortran 77 header ``mpif.h``, if it exists.
+``MPI_Fortran_MODULE_DIR``
+ Location of the ``mpi`` or ``mpi_f08`` modules, if available.
+
+For all languages the following variables are additionally considered:
+
+``MPI_<lang>_ADDITIONAL_INCLUDE_DIRS``
+ A :ref:`;-list <CMake Language Lists>` of paths needed in addition to the normal include directories.
+``MPI_<include_name>_INCLUDE_DIR``
+ Path variables for include folders referred to by ``<include_name>``.
+``MPI_<lang>_ADDITIONAL_INCLUDE_VARS``
+ A :ref:`;-list <CMake Language Lists>` of ``<include_name>`` that will be added to the include locations of ``<lang>``.
-include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+The variable ``MPI_<lang>_LIBRARIES`` will be assembled from the following variables:
-#
-# This part detects MPI compilers, attempting to wade through the mess of compiler names in
-# a sensible way.
-#
-# The compilers are detected in this order:
-#
-# 1. Try to find the most generic available MPI compiler, as this is usually set up by
-# cluster admins, e.g. if plain old mpicc is available, we'll use it and assume it's
-# the right compiler.
-#
-# 2. If a generic mpicc is NOT found, then we attempt to find one that matches
-# CMAKE_<lang>_COMPILER_ID. e.g. if you are using XL compilers, we'll try to find mpixlc
-# and company, but not mpiicc. This hopefully prevents toolchain mismatches.
-#
-# If you want to force a particular MPI compiler other than what we autodetect (e.g. if you
-# want to compile regular stuff with GNU and parallel stuff with Intel), you can always set
-# your favorite MPI_<lang>_COMPILER explicitly and this stuff will be ignored.
-#
+``MPI_<lib_name>_LIBRARY``
+ The location of a library called ``<lib_name>`` for use with MPI.
+``MPI_<lang>_LIB_NAMES``
+ A :ref:`;-list <CMake Language Lists>` of ``<lib_name>`` that will be added to the include locations of ``<lang>``.
+
+Usage of mpiexec
+^^^^^^^^^^^^^^^^
+
+When using ``MPIEXEC_EXECUTABLE`` to execute MPI applications, you should typically
+use all of the ``MPIEXEC_EXECUTABLE`` flags as follows:
+
+::
+
+ ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS}
+ ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS
+
+where ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to
+pass to the MPI program.
+
+Advanced variables for using MPI
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The module can perform some advanced feature detections upon explicit request.
+
+**Important notice:** The following checks cannot be performed without *executing* an MPI test program.
+Consider the special considerations for the behavior of :command:`try_run` during cross compilation.
+Moreover, running an MPI program can cause additional issues, like a firewall notification on some systems.
+You should only enable these detections if you absolutely need the information.
+
+If the following variables are set to true, the respective search will be performed:
+
+``MPI_DETERMINE_Fortran_CAPABILITIES``
+ Determine for all available Fortran bindings what the values of ``MPI_SUBARRAYS_SUPPORTED`` and
+ ``MPI_ASYNC_PROTECTS_NONBLOCKING`` are and make their values available as ``MPI_Fortran_<binding>_SUBARRAYS``
+ and ``MPI_Fortran_<binding>_ASYNCPROT``, where ``<binding>`` is one of ``F77_HEADER``, ``F90_MODULE`` and
+ ``F08_MODULE``.
+``MPI_DETERMINE_LIBRARY_VERSION``
+ For each language, find the output of ``MPI_Get_library_version`` and make it available as ``MPI_<lang>_LIBRARY_VERSION_STRING``.
+ This information is usually tied to the runtime component of an MPI implementation and might differ depending on ``<lang>``.
+ Note that the return value is entirely implementation defined. This information might be used to identify
+ the MPI vendor and for example pick the correct one of multiple third party binaries that matches the MPI vendor.
+
+Backward Compatibility
+^^^^^^^^^^^^^^^^^^^^^^
+
+For backward compatibility with older versions of FindMPI, these
+variables are set, but deprecated:
+
+::
-# Start out with the generic MPI compiler names, as these are most commonly used.
-set(_MPI_C_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r mpicc.bat)
-set(_MPI_CXX_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++
- mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r
- mpicxx.bat)
-set(_MPI_Fortran_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r
+ MPI_COMPILER MPI_LIBRARY MPI_EXTRA_LIBRARY
+ MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_LINK_FLAGS
+ MPI_LIBRARIES
+
+In new projects, please use the ``MPI_<lang>_XXX`` equivalents.
+Additionally, the following variables are deprecated:
+
+``MPI_<lang>_COMPILE_FLAGS``
+ Use ``MPI_<lang>_COMPILE_OPTIONS`` and ``MPI_<lang>_COMPILE_DEFINITIONS`` instead.
+``MPI_<lang>_INCLUDE_PATH``
+ For consumption use ``MPI_<lang>_INCLUDE_DIRS`` and for specifying folders use ``MPI_<lang>_ADDITIONAL_INCLUDE_DIRS`` instead.
+``MPIEXEC``
+ Use ``MPIEXEC_EXECUTABLE`` instead.
+#]=======================================================================]
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+
+# Generic compiler names
+set(_MPI_C_GENERIC_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r)
+set(_MPI_CXX_GENERIC_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++
+ mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r)
+set(_MPI_Fortran_GENERIC_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r
mpif90 mpif90_r mpf90 mpf90_r
- mpif77 mpif77_r mpf77 mpf77_r)
+ mpif77 mpif77_r mpf77 mpf77_r
+ mpifc)
# GNU compiler names
set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r)
-set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r)
+set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r mpigxx)
set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpgfortran_r
mpig77 mpig77_r mpg77 mpg77_r)
-# Intel MPI compiler names
-set(_MPI_Intel_C_COMPILER_NAMES mpiicc mpiicc.bat)
-set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++ mpiiCC mpiicpc.bat)
-set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77 mpiifort.bat)
+# Intel MPI compiler names on Windows
+if(WIN32)
+ list(APPEND _MPI_C_GENERIC_COMPILER_NAMES mpicc.bat)
+ list(APPEND _MPI_CXX_GENERIC_COMPILER_NAMES mpicxx.bat)
+ list(APPEND _MPI_Fortran_GENERIC_COMPILER_NAMES mpifc.bat)
+
+ # Intel MPI compiler names
+ set(_MPI_Intel_C_COMPILER_NAMES mpiicc.bat)
+ set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc.bat)
+ set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort.bat mpif77.bat mpif90.bat)
+
+ # Intel MPI compiler names for MSMPI
+ set(_MPI_MSVC_C_COMPILER_NAMES mpicl.bat)
+ set(_MPI_MSVC_CXX_COMPILER_NAMES mpicl.bat)
+else()
+ # Intel compiler names
+ set(_MPI_Intel_C_COMPILER_NAMES mpiicc)
+ set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++)
+ set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77)
+endif()
# PGI compiler names
set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc)
@@ -153,524 +311,1422 @@ set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95
mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r
mpixlf mpixlf_r mpxlf mpxlf_r)
-# append vendor-specific compilers to the list if we either don't know the compiler id,
-# or if we know it matches the regular compiler.
-foreach (lang C CXX Fortran)
- foreach (id GNU Intel PGI XL)
- if (NOT CMAKE_${lang}_COMPILER_ID OR CMAKE_${lang}_COMPILER_ID STREQUAL id)
- list(APPEND _MPI_${lang}_COMPILER_NAMES ${_MPI_${id}_${lang}_COMPILER_NAMES})
+# Prepend vendor-specific compiler wrappers to the list. If we don't know the compiler,
+# attempt all of them.
+# By attempting vendor-specific compiler names first, we should avoid situations where the compiler wrapper
+# stems from a proprietary MPI and won't know which compiler it's being used for. For instance, Intel MPI
+# controls its settings via the I_MPI_CC environment variables if the generic name is being used.
+# If we know which compiler we're working with, we can use the most specialized wrapper there is in order to
+# pick up the right settings for it.
+foreach (LANG IN ITEMS C CXX Fortran)
+ set(_MPI_${LANG}_COMPILER_NAMES "")
+ foreach (id IN ITEMS GNU Intel MSVC PGI XL)
+ if (NOT CMAKE_${LANG}_COMPILER_ID OR CMAKE_${LANG}_COMPILER_ID STREQUAL id)
+ foreach(_COMPILER_NAME IN LISTS _MPI_${id}_${LANG}_COMPILER_NAMES)
+ list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_COMPILER_NAME}${MPI_EXECUTABLE_SUFFIX})
+ endforeach()
endif()
- unset(_MPI_${id}_${lang}_COMPILER_NAMES) # clean up the namespace here
+ unset(_MPI_${id}_${LANG}_COMPILER_NAMES)
endforeach()
+ foreach(_COMPILER_NAME IN LISTS _MPI_${LANG}_GENERIC_COMPILER_NAMES)
+ list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_COMPILER_NAME}${MPI_EXECUTABLE_SUFFIX})
+ endforeach()
+ unset(_MPI_${LANG}_GENERIC_COMPILER_NAMES)
endforeach()
+# Names to try for mpiexec
+# Only mpiexec commands are guaranteed to behave as described in the standard,
+# mpirun commands are not covered by the standard in any way whatsoever.
+# lamexec is the executable for LAM/MPI, srun is for SLURM or Open MPI with SLURM support.
+# srun -n X <executable> is however a valid command, so it behaves 'like' mpiexec.
+set(_MPIEXEC_NAMES_BASE mpiexec mpiexec.hydra mpiexec.mpd mpirun lamexec srun)
-# Names to try for MPI exec
-set(_MPI_EXEC_NAMES mpiexec mpirun lamexec srun)
-
-# Grab the path to MPI from the registry if we're on windows.
-set(_MPI_PREFIX_PATH)
-if(WIN32)
- # MSMPI
- file(TO_CMAKE_PATH "$ENV{MSMPI_BIN}" msmpi_bin_path) # The default path ends with a '\' and doesn't mix with ';' when appending.
- list(APPEND _MPI_PREFIX_PATH "${msmpi_bin_path}")
- unset(msmpi_bin_path)
- list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MPI;InstallRoot]/Bin")
- list(APPEND _MPI_PREFIX_PATH "$ENV{MSMPI_INC}/..") # The SDK is installed separately from the runtime
- # MPICH
- list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/..")
- list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]")
- list(APPEND _MPI_PREFIX_PATH "$ENV{ProgramW6432}/MPICH2/")
-endif()
-
-# Build a list of prefixes to search for MPI.
-foreach(SystemPrefixDir ${CMAKE_SYSTEM_PREFIX_PATH})
- foreach(MpiPackageDir ${_MPI_PREFIX_PATH})
- if(EXISTS ${SystemPrefixDir}/${MpiPackageDir})
- list(APPEND _MPI_PREFIX_PATH "${SystemPrefixDir}/${MpiPackageDir}")
- endif()
- endforeach()
+unset(_MPIEXEC_NAMES)
+foreach(_MPIEXEC_NAME IN LISTS _MPIEXEC_NAMES_BASE)
+ list(APPEND _MPIEXEC_NAMES "${_MPIEXEC_NAME}${MPI_EXECUTABLE_SUFFIX}")
endforeach()
+unset(_MPIEXEC_NAMES_BASE)
-function (_mpi_check_compiler compiler options cmdvar resvar)
+function (_MPI_check_compiler LANG QUERY_FLAG OUTPUT_VARIABLE RESULT_VARIABLE)
+ if(DEFINED MPI_${LANG}_COMPILER_FLAGS)
+ separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_${LANG}_COMPILER_FLAGS}")
+ else()
+ separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_COMPILER_FLAGS}")
+ endif()
execute_process(
- COMMAND "${compiler}" ${options}
- OUTPUT_VARIABLE cmdline OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_VARIABLE cmdline ERROR_STRIP_TRAILING_WHITESPACE
- RESULT_VARIABLE success)
- # Intel MPI 5.0.1 will return a zero return code even when the
- # argument to the MPI compiler wrapper is unknown. Attempt to
- # catch this case.
- if(cmdline MATCHES "undefined reference" OR cmdline MATCHES "unrecognized")
- set(success 255 )
- endif()
- set(${cmdvar} "${cmdline}" PARENT_SCOPE)
- set(${resvar} "${success}" PARENT_SCOPE)
+ COMMAND ${MPI_${LANG}_COMPILER} ${_MPI_COMPILER_WRAPPER_OPTIONS} ${QUERY_FLAG}
+ OUTPUT_VARIABLE WRAPPER_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE WRAPPER_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE
+ RESULT_VARIABLE WRAPPER_RETURN)
+ # Some compiler wrappers will yield spurious zero return values, for example
+ # Intel MPI tolerates unknown arguments and if the MPI wrappers loads a shared
+ # library that has invalid or missing version information there would be warning
+ # messages emitted by ld.so in the compiler output. In either case, we'll treat
+ # the output as invalid.
+ if("${WRAPPER_OUTPUT}" MATCHES "undefined reference|unrecognized|need to set|no version information available|command not found")
+ set(WRAPPER_RETURN 255)
+ endif()
+ # Ensure that no error output might be passed upwards.
+ if(NOT WRAPPER_RETURN EQUAL 0)
+ unset(WRAPPER_OUTPUT)
+ else()
+ # Strip leading whitespace
+ string(REGEX REPLACE "^ +" "" WRAPPER_OUTPUT "${WRAPPER_OUTPUT}")
+ endif()
+ set(${OUTPUT_VARIABLE} "${WRAPPER_OUTPUT}" PARENT_SCOPE)
+ set(${RESULT_VARIABLE} "${WRAPPER_RETURN}" PARENT_SCOPE)
endfunction()
-#
-# interrogate_mpi_compiler(lang try_libs)
-#
-# Attempts to extract compiler and linker args from an MPI compiler. The arguments set
-# by this function are:
-#
-# MPI_<lang>_INCLUDE_PATH MPI_<lang>_LINK_FLAGS MPI_<lang>_FOUND
-# MPI_<lang>_COMPILE_FLAGS MPI_<lang>_LIBRARIES
-#
-# MPI_<lang>_COMPILER must be set beforehand to the absolute path to an MPI compiler for
-# <lang>. Additionally, MPI_<lang>_INCLUDE_PATH and MPI_<lang>_LIBRARIES may be set
-# to skip autodetection.
-#
-# If try_libs is TRUE, this will also attempt to find plain MPI libraries in the usual
-# way. In general, this is not as effective as interrogating the compilers, as it
-# ignores language-specific flags and libraries. However, some MPI implementations
-# (Windows implementations) do not have compiler wrappers, so this approach must be used.
-#
-function (interrogate_mpi_compiler lang try_libs)
- # MPI_${lang}_NO_INTERROGATE will be set to a compiler name when the *regular* compiler was
- # discovered to be the MPI compiler. This happens on machines like the Cray XE6 that use
- # modules to set cc, CC, and ftn to the MPI compilers. If the user force-sets another MPI
- # compiler, MPI_${lang}_COMPILER won't be equal to MPI_${lang}_NO_INTERROGATE, and we'll
- # inspect that compiler anew. This allows users to set new compilers w/o rm'ing cache.
- string(COMPARE NOTEQUAL "${MPI_${lang}_NO_INTERROGATE}" "${MPI_${lang}_COMPILER}" interrogate)
-
- # If MPI is set already in the cache, don't bother with interrogating the compiler.
- if (interrogate AND ((NOT MPI_${lang}_INCLUDE_PATH) OR (NOT MPI_${lang}_LIBRARIES)))
- if (MPI_${lang}_COMPILER)
- # Check whether the -showme:compile option works. This indicates that we have either OpenMPI
- # or a newer version of LAM-MPI, and implies that -showme:link will also work.
- _mpi_check_compiler("${MPI_${lang}_COMPILER}" "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN)
- if (MPI_COMPILER_RETURN EQUAL 0)
- # If we appear to have -showme:compile, then we should
- # also have -showme:link. Try it.
- execute_process(
- COMMAND ${MPI_${lang}_COMPILER} -showme:link
- OUTPUT_VARIABLE MPI_LINK_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_VARIABLE MPI_LINK_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE
- RESULT_VARIABLE MPI_COMPILER_RETURN)
-
- if (MPI_COMPILER_RETURN EQUAL 0)
- # We probably have -showme:incdirs and -showme:libdirs as well,
- # so grab that while we're at it.
- execute_process(
- COMMAND ${MPI_${lang}_COMPILER} -showme:incdirs
- OUTPUT_VARIABLE MPI_INCDIRS OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_VARIABLE MPI_INCDIRS ERROR_STRIP_TRAILING_WHITESPACE)
-
- execute_process(
- COMMAND ${MPI_${lang}_COMPILER} -showme:libdirs
- OUTPUT_VARIABLE MPI_LIBDIRS OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_VARIABLE MPI_LIBDIRS ERROR_STRIP_TRAILING_WHITESPACE)
+macro(_MPI_env_set_ifnot VAR VALUE)
+ if(NOT DEFINED ENV{${VAR}})
+ set(_MPI_${VAR}_WAS_SET FALSE)
+ set(ENV{${VAR}} ${${VALUE}})
+ else()
+ set(_MPI_${VAR}_WAS_SET TRUE)
+ endif()
+endmacro()
- else()
- # reset things here if something went wrong.
- set(MPI_COMPILE_CMDLINE)
- set(MPI_LINK_CMDLINE)
- endif()
- endif ()
+macro(_MPI_env_unset_ifnot VAR)
+ if(NOT _MPI_${VAR}_WAS_SET)
+ unset(ENV{${VAR}})
+ endif()
+endmacro()
+
+function (_MPI_interrogate_compiler LANG)
+ unset(MPI_COMPILE_CMDLINE)
+ unset(MPI_LINK_CMDLINE)
+
+ unset(MPI_COMPILE_OPTIONS_WORK)
+ unset(MPI_COMPILE_DEFINITIONS_WORK)
+ unset(MPI_INCLUDE_DIRS_WORK)
+ unset(MPI_LINK_FLAGS_WORK)
+ unset(MPI_LIB_NAMES_WORK)
+ unset(MPI_LIB_FULLPATHS_WORK)
+
+ # Define the MPICH and Intel MPI compiler variables to the compilers set in CMake.
+ # It's possible to have a per-compiler configuration in these MPI implementations and
+ # a particular MPICH derivate might check compiler interoperability.
+ # Intel MPI in particular does this with I_MPI_CHECK_COMPILER.
+ file(TO_NATIVE_PATH "${CMAKE_${LANG}_COMPILER}" _MPI_UNDERLAYING_COMPILER)
+ # On Windows, the Intel MPI batch scripts can only work with filnames - Full paths will break them.
+ # Due to the lack of other MPICH-based wrappers for Visual C++, we may treat this as default.
+ if(MSVC)
+ get_filename_component(_MPI_UNDERLAYING_COMPILER "${_MPI_UNDERLAYING_COMPILER}" NAME)
+ endif()
+ if("${LANG}" STREQUAL "C")
+ _MPI_env_set_ifnot(I_MPI_CC _MPI_UNDERLAYING_COMPILER)
+ _MPI_env_set_ifnot(MPICH_CC _MPI_UNDERLAYING_COMPILER)
+ elseif("${LANG}" STREQUAL "CXX")
+ _MPI_env_set_ifnot(I_MPI_CXX _MPI_UNDERLAYING_COMPILER)
+ _MPI_env_set_ifnot(MPICH_CXX _MPI_UNDERLAYING_COMPILER)
+ elseif("${LANG}" STREQUAL "Fortran")
+ _MPI_env_set_ifnot(I_MPI_FC _MPI_UNDERLAYING_COMPILER)
+ _MPI_env_set_ifnot(MPICH_FC _MPI_UNDERLAYING_COMPILER)
+ _MPI_env_set_ifnot(I_MPI_F77 _MPI_UNDERLAYING_COMPILER)
+ _MPI_env_set_ifnot(MPICH_F77 _MPI_UNDERLAYING_COMPILER)
+ _MPI_env_set_ifnot(I_MPI_F90 _MPI_UNDERLAYING_COMPILER)
+ _MPI_env_set_ifnot(MPICH_F90 _MPI_UNDERLAYING_COMPILER)
+ endif()
+
+ # Set these two variables for Intel MPI:
+ # - I_MPI_DEBUG_INFO_STRIP: It adds 'objcopy' lines to the compiler output. We support stripping them
+ # (see below), but if we can avoid them in the first place, we should.
+ # - I_MPI_FORT_BIND: By default Intel MPI makes the C/C++ compiler wrappers link Fortran bindings.
+ # This is so that mixed-language code doesn't require additional libraries when linking with mpicc.
+ # For our purposes, this makes little sense, since correct MPI usage from CMake already circumvenes this.
+ set(_MPI_ENV_VALUE "disable")
+ _MPI_env_set_ifnot(I_MPI_DEBUG_INFO_STRIP _MPI_ENV_VALUE)
+ _MPI_env_set_ifnot(I_MPI_FORT_BIND _MPI_ENV_VALUE)
+
+ # Check whether the -showme:compile option works. This indicates that we have either Open MPI
+ # or a newer version of LAM/MPI, and implies that -showme:link will also work.
+ # Open MPI also supports -show, but separates linker and compiler information
+ _MPI_check_compiler(${LANG} "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN)
+ if (MPI_COMPILER_RETURN EQUAL 0)
+ _MPI_check_compiler(${LANG} "-showme:link" MPI_LINK_CMDLINE MPI_COMPILER_RETURN)
+
+ if (NOT MPI_COMPILER_RETURN EQUAL 0)
+ unset(MPI_COMPILE_CMDLINE)
+ endif()
+ endif()
+
+ # MPICH and MVAPICH offer -compile-info and -link-info.
+ # For modern versions, both do the same as -show. However, for old versions, they do differ
+ # when called for mpicxx and mpif90 and it's necessary to use them over -show in order to find the
+ # removed MPI C++ bindings.
+ if (NOT MPI_COMPILER_RETURN EQUAL 0)
+ _MPI_check_compiler(${LANG} "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN)
+
+ if (MPI_COMPILER_RETURN EQUAL 0)
+ _MPI_check_compiler(${LANG} "-link-info" MPI_LINK_CMDLINE MPI_COMPILER_RETURN)
- # Older versions of LAM-MPI have "-showme". Try to find that.
if (NOT MPI_COMPILER_RETURN EQUAL 0)
- _mpi_check_compiler("${MPI_${lang}_COMPILER}" "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN)
+ unset(MPI_COMPILE_CMDLINE)
endif()
+ endif()
+ endif()
- # MVAPICH uses -compile-info and -link-info. Try them.
- if (NOT MPI_COMPILER_RETURN EQUAL 0)
- _mpi_check_compiler("${MPI_${lang}_COMPILER}" "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN)
-
- # If we have compile-info, also have link-info.
- if (MPI_COMPILER_RETURN EQUAL 0)
- execute_process(
- COMMAND ${MPI_${lang}_COMPILER} -link-info
- OUTPUT_VARIABLE MPI_LINK_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_VARIABLE MPI_LINK_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE
- RESULT_VARIABLE MPI_COMPILER_RETURN)
- endif()
+ # MPICH, MVAPICH2 and Intel MPI just use "-show". Open MPI also offers this, but the
+ # -showme commands are more specialized.
+ if (NOT MPI_COMPILER_RETURN EQUAL 0)
+ _MPI_check_compiler(${LANG} "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN)
+ endif()
- # make sure we got compile and link. Reset vars if something's wrong.
- if (NOT MPI_COMPILER_RETURN EQUAL 0)
- set(MPI_COMPILE_CMDLINE)
- set(MPI_LINK_CMDLINE)
+ # Older versions of LAM/MPI have "-showme". Open MPI also supports this.
+ # Unknown to MPICH, MVAPICH and Intel MPI.
+ if (NOT MPI_COMPILER_RETURN EQUAL 0)
+ _MPI_check_compiler(${LANG} "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN)
+ endif()
+
+ if (MPI_COMPILER_RETURN EQUAL 0 AND DEFINED MPI_COMPILE_CMDLINE)
+ # Intel MPI can be run with -compchk or I_MPI_CHECK_COMPILER set to 1.
+ # In this case, -show will be prepended with a line to the compiler checker. This is a script that performs
+ # compatibility checks and returns a non-zero exit code together with an error if something fails.
+ # It has to be called as "compchk.sh <arch> <compiler>". Here, <arch> is one out of 32 (i686), 64 (ia64) or 32e (x86_64).
+ # The compiler is identified by filename, and can be either the MPI compiler or the underlying compiler.
+ # NOTE: It is vital to run this script while the environment variables are set up, otherwise it can check the wrong compiler.
+ if("${MPI_COMPILE_CMDLINE}" MATCHES "^([^\" ]+/compchk.sh|\"[^\"]+/compchk.sh\") +([^ ]+)")
+ # Now CMAKE_MATCH_1 contains the path to the compchk.sh file and CMAKE_MATCH_2 the architecture flag.
+ unset(COMPILER_CHECKER_OUTPUT)
+ execute_process(
+ COMMAND ${CMAKE_MATCH_1} ${CMAKE_MATCH_2} ${MPI_${LANG}_COMPILER}
+ OUTPUT_VARIABLE COMPILER_CHECKER_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE COMPILER_CHECKER_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE
+ RESULT_VARIABLE MPI_COMPILER_RETURN)
+ # If it returned a non-zero value, the check below will fail and cause the interrogation to be aborted.
+ if(NOT MPI_COMPILER_RETURN EQUAL 0)
+ if(NOT MPI_FIND_QUIETLY)
+ message(STATUS "Intel MPI compiler check failed: ${COMPILER_CHECKER_OUTPUT}")
endif()
+ else()
+ # Since the check passed, we can remove the compchk.sh script.
+ string(REGEX REPLACE "^([^\" ]+|\"[^\"]+\")/compchk.sh.*\n" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}")
endif()
+ endif()
+ endif()
- # MPICH just uses "-show". Try it.
- if (NOT MPI_COMPILER_RETURN EQUAL 0)
- _mpi_check_compiler("${MPI_${lang}_COMPILER}" "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN)
+ # Revert changes to the environment made previously
+ if("${LANG}" STREQUAL "C")
+ _MPI_env_unset_ifnot(I_MPI_CC)
+ _MPI_env_unset_ifnot(MPICH_CC)
+ elseif("${LANG}" STREQUAL "CXX")
+ _MPI_env_unset_ifnot(I_MPI_CXX)
+ _MPI_env_unset_ifnot(MPICH_CXX)
+ elseif("${LANG}" STREQUAL "Fortran")
+ _MPI_env_unset_ifnot(I_MPI_FC)
+ _MPI_env_unset_ifnot(MPICH_FC)
+ _MPI_env_unset_ifnot(I_MPI_F77)
+ _MPI_env_unset_ifnot(MPICH_F77)
+ _MPI_env_unset_ifnot(I_MPI_F90)
+ _MPI_env_unset_ifnot(MPICH_F90)
+ endif()
+
+ _MPI_env_unset_ifnot(I_MPI_DEBUG_INFO_STRIP)
+ _MPI_env_unset_ifnot(I_MPI_FORT_BIND)
+
+ if (NOT (MPI_COMPILER_RETURN EQUAL 0) OR NOT (DEFINED MPI_COMPILE_CMDLINE))
+ # Cannot interrogate this compiler, so exit.
+ set(MPI_${LANG}_WRAPPER_FOUND FALSE PARENT_SCOPE)
+ return()
+ endif()
+ unset(MPI_COMPILER_RETURN)
+
+ # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE
+ # into MPI_LINK_CMDLINE, if we didn't find the link line.
+ if (NOT DEFINED MPI_LINK_CMDLINE)
+ set(MPI_LINK_CMDLINE "${MPI_COMPILE_CMDLINE}")
+ endif()
+
+ # Visual Studio parsers permit each flag prefixed by either / or -.
+ # We'll normalize this to the - syntax we use for CMake purposes anyways.
+ if(MSVC)
+ foreach(_MPI_VARIABLE IN ITEMS COMPILE LINK)
+ # The Intel MPI wrappers on Windows prefix their output with some copyright boilerplate.
+ # To prevent possible problems, we discard this text before proceeding with any further matching.
+ string(REGEX REPLACE "^[^ ]+ for the Intel\\(R\\) MPI Library [^\n]+ for Windows\\*\nCopyright\\(C\\) [^\n]+, Intel Corporation\\. All rights reserved\\.\n\n" ""
+ MPI_${_MPI_VARIABLE}_CMDLINE "${MPI_${_MPI_VARIABLE}_CMDLINE}")
+ string(REGEX REPLACE "(^| )/" "\\1-" MPI_${_MPI_VARIABLE}_CMDLINE "${MPI_${_MPI_VARIABLE}_CMDLINE}")
+ string(REPLACE "-libpath:" "-LIBPATH:" MPI_${_MPI_VARIABLE}_CMDLINE "${MPI_${_MPI_VARIABLE}_CMDLINE}")
+ endforeach()
+ endif()
+
+ # For MSVC and cl-compatible compilers, the keyword /link indicates a point after which
+ # everything following is passed to the linker. In this case, we drop all prior information
+ # from the link line and treat any unknown extra flags as linker flags.
+ set(_MPI_FILTERED_LINK_INFORMATION FALSE)
+ if(MSVC)
+ if(MPI_LINK_CMDLINE MATCHES " -(link|LINK) ")
+ string(REGEX REPLACE ".+-(link|LINK) +" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}")
+ set(_MPI_FILTERED_LINK_INFORMATION TRUE)
+ endif()
+ string(REGEX REPLACE " +-(link|LINK) .+" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}")
+ endif()
+
+ if(UNIX)
+ # At this point, we obtained some output from a compiler wrapper that works.
+ # We'll now try to parse it into variables with meaning to us.
+ if("${LANG}" STREQUAL "Fortran")
+ # If MPICH (and derivates) didn't recognize the Fortran compiler include flag during configuration,
+ # they'll return a set of three commands, consisting out of a symlink command for mpif.h,
+ # the actual compiler command and deletion of the created symlink.
+ # Especially with M(VA)PICH-1, this appears to happen erroneously, and therefore we should translate
+ # this output into an additional include directory and then drop it from the output.
+ if("${MPI_COMPILE_CMDLINE}" MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h")
+ get_filename_component(MPI_INCLUDE_DIRS_WORK "${CMAKE_MATCH_1}" DIRECTORY)
+ string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}")
+ string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}")
+ string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}")
+ string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}")
endif()
+ endif()
- if (MPI_COMPILER_RETURN EQUAL 0)
- # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE
- # into MPI_LINK_CMDLINE, if we didn't find the link line.
- if (NOT MPI_LINK_CMDLINE)
- set(MPI_LINK_CMDLINE ${MPI_COMPILE_CMDLINE})
- endif()
+ # If Intel MPI was configured for static linkage with -static_mpi, the wrapper will by default strip
+ # debug information from resulting binaries (see I_MPI_DEBUG_INFO_STRIP).
+ # Since we cannot process this information into CMake logic, we need to discard the resulting objcopy
+ # commands from the output.
+ string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}")
+ string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}")
+ endif()
+
+ # For Visual C++, extracting compiler options in a generic fashion isn't easy. However, no MPI implementation
+ # on Windows seems to require any specific ones, either.
+ if(NOT MSVC)
+ # Extract compile options from the compile command line.
+ string(REGEX MATCHALL "(^| )-f([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_OPTIONS "${MPI_COMPILE_CMDLINE}")
+
+ foreach(_MPI_COMPILE_OPTION IN LISTS MPI_ALL_COMPILE_OPTIONS)
+ string(REGEX REPLACE "^ " "" _MPI_COMPILE_OPTION "${_MPI_COMPILE_OPTION}")
+
+ # Ignore -fstack-protector directives: These occur on MPICH and MVAPICH when the libraries
+ # themselves were built with this flag. However, this flag is unrelated to using MPI, and
+ # we won't match the accompanying --param-ssp-size and -Wp,-D_FORTIFY_SOURCE flags and therefore
+ # produce inconsistent results with the regularly flags.
+ # Similarly, aliasing flags do not belong into our flag array.
+ if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f((no-|)(stack-protector|strict-aliasing)|PI[CE]|pi[ce])")
+ list(APPEND MPI_COMPILE_OPTIONS_WORK "${_MPI_COMPILE_OPTION}")
+ endif()
+ endforeach()
+ endif()
+
+ # For GNU-style compilers, it's possible to prefix includes and definitions with certain flags to pass them
+ # only to the preprocessor. For CMake purposes, we need to treat, but ignore such scopings.
+ # Note that we do not support spaces between the arguments, i.e. -Wp,-I -Wp,/opt/mympi will not be parsed
+ # correctly. This form does not seem to occur in any common MPI implementation, however.
+ if(NOT MSVC)
+ set(_MPI_PREPROCESSOR_FLAG_REGEX "(-Wp,|-Xpreprocessor )?")
+ else()
+ set(_MPI_PREPROCESSOR_FLAG_REGEX "")
+ endif()
+
+ # Same deal as above, for the definitions.
+ string(REGEX MATCHALL "(^| )${_MPI_PREPROCESSOR_FLAG_REGEX}-D *([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_DEFINITIONS "${MPI_COMPILE_CMDLINE}")
+
+ foreach(_MPI_COMPILE_DEFINITION IN LISTS MPI_ALL_COMPILE_DEFINITIONS)
+ string(REGEX REPLACE "^ ?${_MPI_PREPROCESSOR_FLAG_REGEX}-D *" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}")
+ string(REPLACE "\"" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}")
+ if(NOT "${_MPI_COMPILE_DEFINITION}" MATCHES "^_FORTIFY_SOURCE.*")
+ list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${_MPI_COMPILE_DEFINITION}")
+ endif()
+ endforeach()
+
+ # Extract include paths from compile command line
+ string(REGEX MATCHALL "(^| )${_MPI_PREPROCESSOR_FLAG_REGEX}${CMAKE_INCLUDE_FLAG_${LANG}} *([^\" ]+|\"[^\"]+\")"
+ MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}")
+
+ # If extracting failed to work, we'll try using -showme:incdirs.
+ # Unlike before, we do this without the environment variables set up, but since only MPICH derivates are affected by any of them, and
+ # -showme:... is only supported by Open MPI and LAM/MPI, this isn't a concern.
+ if (NOT MPI_ALL_INCLUDE_PATHS)
+ _MPI_check_compiler(${LANG} "-showme:incdirs" MPI_INCDIRS_CMDLINE MPI_INCDIRS_COMPILER_RETURN)
+ if(MPI_INCDIRS_COMPILER_RETURN)
+ separate_arguments(MPI_ALL_INCLUDE_PATHS NATIVE_COMMAND "${MPI_INCDIRS_CMDLINE}")
+ endif()
+ endif()
+
+ foreach(_MPI_INCLUDE_PATH IN LISTS MPI_ALL_INCLUDE_PATHS)
+ string(REGEX REPLACE "^ ?${_MPI_PREPROCESSOR_FLAG_REGEX}${CMAKE_INCLUDE_FLAG_${LANG}} *" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}")
+ string(REPLACE "\"" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}")
+ get_filename_component(_MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}" REALPATH)
+ list(APPEND MPI_INCLUDE_DIRS_WORK "${_MPI_INCLUDE_PATH}")
+ endforeach()
+
+ # The next step are linker flags and library directories. Here, we first take the flags given in raw -L or -LIBPATH: syntax.
+ string(REGEX MATCHALL "(^| )${CMAKE_LIBRARY_PATH_FLAG} *([^\" ]+|\"[^\"]+\")" MPI_DIRECT_LINK_PATHS "${MPI_LINK_CMDLINE}")
+ foreach(_MPI_LPATH IN LISTS MPI_DIRECT_LINK_PATHS)
+ string(REGEX REPLACE "(^| )${CMAKE_LIBRARY_PATH_FLAG} *" "" _MPI_LPATH "${_MPI_LPATH}")
+ list(APPEND MPI_ALL_LINK_PATHS "${_MPI_LPATH}")
+ endforeach()
+
+ # If the link commandline hasn't been filtered (e.g. when using MSVC and /link), we need to extract the relevant parts first.
+ if(NOT _MPI_FILTERED_LINK_INFORMATION)
+ string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker +)([^\" ]+|\"[^\"]+\")" MPI_LINK_FLAGS "${MPI_LINK_CMDLINE}")
+
+ # In this case, we could also find some indirectly given linker paths, e.g. prefixed by -Xlinker or -Wl,
+ # Since syntaxes like -Wl,-L -Wl,/my/path/to/lib are also valid, we parse these paths by first removing -Wl, and -Xlinker
+ # from the list of filtered flags and then parse the remainder of the output.
+ string(REGEX REPLACE "(-Wl,|-Xlinker +)" "" MPI_LINK_FLAGS_RAW "${MPI_LINK_FLAGS}")
+
+ # Now we can parse the leftover output. Note that spaces can now be handled since the above example would reduce to
+ # -L /my/path/to/lib and can be extracted correctly.
+ string(REGEX MATCHALL "^(${CMAKE_LIBRARY_PATH_FLAG},? *|--library-path=)([^\" ]+|\"[^\"]+\")"
+ MPI_INDIRECT_LINK_PATHS "${MPI_LINK_FLAGS_RAW}")
+
+ foreach(_MPI_LPATH IN LISTS MPI_INDIRECT_LINK_PATHS)
+ string(REGEX REPLACE "^(${CMAKE_LIBRARY_PATH_FLAG},? *|--library-path=)" "" _MPI_LPATH "${_MPI_LPATH}")
+ list(APPEND MPI_ALL_LINK_PATHS "${_MPI_LPATH}")
+ endforeach()
+
+ # We need to remove the flags we extracted from the linker flag list now.
+ string(REGEX REPLACE "(^| )(-Wl,|-Xlinker +)(${CMAKE_LIBRARY_PATH_FLAG},? *(-Wl,|-Xlinker +)?|--library-path=)([^\" ]+|\"[^\"]+\")" ""
+ MPI_LINK_CMDLINE_FILTERED "${MPI_LINK_CMDLINE}")
+
+ # Some MPI implementations pass on options they themselves were built with. Since -z,noexecstack is a common
+ # hardening, we should strip it. In general, the -z options should be undesirable.
+ string(REGEX REPLACE "(^| )-Wl,-z(,[^ ]+| +-Wl,[^ ]+)" "" MPI_LINK_CMDLINE_FILTERED "${MPI_LINK_CMDLINE_FILTERED}")
+ string(REGEX REPLACE "(^| )-Xlinker +-z +-Xlinker +[^ ]+" "" MPI_LINK_CMDLINE_FILTERED "${MPI_LINK_CMDLINE_FILTERED}")
+
+ # We only consider options of the form -Wl or -Xlinker:
+ string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker +)([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE_FILTERED}")
+
+ # As a next step, we assemble the linker flags extracted in a preliminary flags string
+ foreach(_MPI_LINK_FLAG IN LISTS MPI_ALL_LINK_FLAGS)
+ string(STRIP "${_MPI_LINK_FLAG}" _MPI_LINK_FLAG)
+ if (MPI_LINK_FLAGS_WORK)
+ string(APPEND MPI_LINK_FLAGS_WORK " ${_MPI_LINK_FLAG}")
else()
- message(STATUS "Unable to determine MPI from MPI driver ${MPI_${lang}_COMPILER}")
- set(MPI_COMPILE_CMDLINE)
- set(MPI_LINK_CMDLINE)
+ set(MPI_LINK_FLAGS_WORK "${_MPI_LINK_FLAG}")
endif()
+ endforeach()
+ else()
+ # In the filtered case, we obtain the link time flags by just stripping the library paths.
+ string(REGEX REPLACE "(^| )${CMAKE_LIBRARY_PATH_FLAG} *([^\" ]+|\"[^\"]+\")" "" MPI_LINK_CMDLINE_FILTERED "${MPI_LINK_CMDLINE}")
+ endif()
- # Here, we're done with the interrogation part, and we'll try to extract args we care
- # about from what we learned from the compiler wrapper scripts.
+ # If we failed to extract any linker paths, we'll try using the -showme:libdirs option with the MPI compiler.
+ # This will return a list of folders, not a set of flags!
+ if (NOT MPI_ALL_LINK_PATHS)
+ _MPI_check_compiler(${LANG} "-showme:libdirs" MPI_LIBDIRS_CMDLINE MPI_LIBDIRS_COMPILER_RETURN)
+ if(MPI_LIBDIRS_COMPILER_RETURN)
+ separate_arguments(MPI_ALL_LINK_PATHS NATIVE_COMMAND "${MPI_LIBDIRS_CMDLINE}")
+ endif()
+ endif()
- # If interrogation came back with something, extract our variable from the MPI command line
- if (MPI_COMPILE_CMDLINE OR MPI_LINK_CMDLINE)
- # Extract compile flags from the compile command line.
- string(REGEX MATCHALL "(^| )-[Df]([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}")
- set(MPI_COMPILE_FLAGS_WORK)
+ # We need to remove potential quotes and convert the paths to CMake syntax while resolving them, too.
+ foreach(_MPI_LPATH IN LISTS MPI_ALL_LINK_PATHS)
+ string(REPLACE "\"" "" _MPI_LPATH "${_MPI_LPATH}")
+ get_filename_component(_MPI_LPATH "${_MPI_LPATH}" REALPATH)
+ list(APPEND MPI_LINK_DIRECTORIES_WORK "${_MPI_LPATH}")
+ endforeach()
- foreach(FLAG ${MPI_ALL_COMPILE_FLAGS})
- string(REGEX REPLACE "^ " "" FLAG ${FLAG})
- if (MPI_COMPILE_FLAGS_WORK)
- string(APPEND MPI_COMPILE_FLAGS_WORK " ${FLAG}")
- else()
- set(MPI_COMPILE_FLAGS_WORK ${FLAG})
- endif()
- endforeach()
+ # Extract the set of libraries to link against from the link command line
+ # This only makes sense if CMAKE_LINK_LIBRARY_FLAG is defined, i.e. a -lxxxx syntax is supported by the compiler.
+ if(CMAKE_LINK_LIBRARY_FLAG)
+ string(REGEX MATCHALL "(^| )${CMAKE_LINK_LIBRARY_FLAG}([^\" ]+|\"[^\"]+\")"
+ MPI_LIBNAMES "${MPI_LINK_CMDLINE}")
+
+ foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES)
+ string(REGEX REPLACE "^ ?${CMAKE_LINK_LIBRARY_FLAG}" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}")
+ string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}")
+ list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}")
+ endforeach()
+ endif()
- # Extract include paths from compile command line
- string(REGEX MATCHALL "(^| )-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}")
- set(MPI_INCLUDE_PATH_WORK)
+ # Treat linker objects given by full path, for example static libraries, import libraries
+ # or shared libraries if there aren't any import libraries in use on the system.
+ # Note that we do not consider CMAKE_<TYPE>_LIBRARY_PREFIX intentionally here: The linker will for a given file
+ # decide how to link it based on file type, not based on a prefix like 'lib'.
+ set(_MPI_LIB_SUFFIX_REGEX "${CMAKE_STATIC_LIBRARY_SUFFIX}")
+ if(DEFINED CMAKE_IMPORT_LIBRARY_SUFFIX)
+ if(NOT ("${CMAKE_IMPORT_LIBRARY_SUFFIX}" STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}"))
+ string(APPEND _MPI_SUFFIX_REGEX "|${CMAKE_IMPORT_LIBRARY_SUFFIX}")
+ endif()
+ else()
+ string(APPEND _MPI_LIB_SUFFIX_REGEX "|${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ endif()
+ set(_MPI_LIB_NAME_REGEX "(([^\" ]+(${_MPI_LIB_SUFFIX_REGEX}))|(\"[^\"]+(${_MPI_LIB_SUFFIX_REGEX})\"))( +|$)")
+ string(REPLACE "." "\\." _MPI_LIB_NAME_REGEX "${_MPI_LIB_NAME_REGEX}")
+
+ string(REGEX MATCHALL "${_MPI_LIB_NAME_REGEX}" MPI_LIBNAMES "${MPI_LINK_CMDLINE}")
+ foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES)
+ string(REGEX REPLACE "^ +\"?|\"? +$" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}")
+ get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY)
+ if(NOT "${_MPI_LIB_PATH}" STREQUAL "")
+ list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}")
+ else()
+ list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}")
+ endif()
+ endforeach()
- foreach(IPATH ${MPI_ALL_INCLUDE_PATHS})
- string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH})
- string(REPLACE "//" "/" IPATH ${IPATH})
- string(REPLACE "\"" "" IPATH ${IPATH})
- file(TO_CMAKE_PATH "${IPATH}" IPATH)
- list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH})
- endforeach()
+ # Save the explicitly given link directories
+ set(MPI_LINK_DIRECTORIES_LEFTOVER "${MPI_LINK_DIRECTORIES_WORK}")
- # try using showme:incdirs if extracting didn't work.
- if (NOT MPI_INCLUDE_PATH_WORK)
- set(MPI_INCLUDE_PATH_WORK ${MPI_INCDIRS})
- separate_arguments(MPI_INCLUDE_PATH_WORK)
- endif()
+ # An MPI compiler wrapper could have its MPI libraries in the implictly
+ # linked directories of the compiler itself.
+ if(DEFINED CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES)
+ list(APPEND MPI_LINK_DIRECTORIES_WORK "${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}")
+ endif()
- # If all else fails, just search for mpi.h in the normal include paths.
- if (NOT MPI_INCLUDE_PATH_WORK)
- set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
- find_path(MPI_HEADER_PATH mpi.h
- HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH}
- PATH_SUFFIXES include)
- set(MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH})
- endif()
+ # Determine full path names for all of the libraries that one needs
+ # to link against in an MPI program
+ unset(MPI_PLAIN_LIB_NAMES_WORK)
+ foreach(_MPI_LIB_NAME IN LISTS MPI_LIB_NAMES_WORK)
+ get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_NAME}" NAME_WE)
+ list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}")
+ find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY
+ NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}"
+ HINTS ${MPI_LINK_DIRECTORIES_WORK}
+ DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI"
+ )
+ mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY)
+ # Remove the directory from the remainder list.
+ if(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY)
+ get_filename_component(_MPI_TAKEN_DIRECTORY "${MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY}" DIRECTORY)
+ list(REMOVE_ITEM MPI_LINK_DIRECTORIES_LEFTOVER "${_MPI_TAKEN_DIRECTORY}")
+ endif()
+ endforeach()
- # Extract linker paths from the link command line
- string(REGEX MATCHALL "(^| |-Wl,)(-L|/LIBPATH:)([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}")
- set(MPI_LINK_PATH)
- foreach(LPATH ${MPI_ALL_LINK_PATHS})
- string(REGEX REPLACE "^(| |-Wl,)(-L|/LIBPATH:)" "" LPATH ${LPATH})
- string(REPLACE "//" "/" LPATH ${LPATH})
- list(APPEND MPI_LINK_PATH ${LPATH})
- endforeach()
+ # Add the link directories given explicitly that we haven't used back as linker directories.
+ if(NOT WIN32)
+ foreach(_MPI_LINK_DIRECTORY IN LISTS MPI_LINK_DIRECTORIES_LEFTOVER)
+ file(TO_NATIVE_PATH "${_MPI_LINK_DIRECTORY}" _MPI_LINK_DIRECTORY_ACTUAL)
+ string(FIND "${_MPI_LINK_DIRECTORY_ACTUAL}" " " _MPI_LINK_DIRECTORY_CONTAINS_SPACE)
+ if(NOT _MPI_LINK_DIRECTORY_CONTAINS_SPACE EQUAL -1)
+ set(_MPI_LINK_DIRECTORY_ACTUAL "\"${_MPI_LINK_DIRECTORY_ACTUAL}\"")
+ endif()
+ if(MPI_LINK_FLAGS_WORK)
+ string(APPEND MPI_LINK_FLAGS_WORK " ${CMAKE_LIBRARY_PATH_FLAG}${_MPI_LINK_DIRECTORY_ACTUAL}")
+ else()
+ set(MPI_LINK_FLAGS_WORK "${CMAKE_LIBRARY_PATH_FLAG}${_MPI_LINK_DIRECTORY_ACTUAL}")
+ endif()
+ endforeach()
+ endif()
- # try using showme:libdirs if extracting didn't work.
- if (NOT MPI_LINK_PATH)
- set(MPI_LINK_PATH ${MPI_LIBDIRS})
- separate_arguments(MPI_LINK_PATH)
- endif()
+ # Deal with the libraries given with full path next
+ unset(MPI_DIRECT_LIB_NAMES_WORK)
+ foreach(_MPI_LIB_FULLPATH IN LISTS MPI_LIB_FULLPATHS_WORK)
+ get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME_WE)
+ list(APPEND MPI_DIRECT_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}")
+ set(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY "${_MPI_LIB_FULLPATH}" CACHE FILEPATH "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI")
+ mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY)
+ endforeach()
+ # Directly linked objects should be linked first in case some generic linker flags are needed for them.
+ if(MPI_DIRECT_LIB_NAMES_WORK)
+ set(MPI_PLAIN_LIB_NAMES_WORK "${MPI_DIRECT_LIB_NAMES_WORK};${MPI_PLAIN_LIB_NAMES_WORK}")
+ endif()
- # Extract linker flags from the link command line
- string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker )([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}")
- set(MPI_LINK_FLAGS_WORK)
- foreach(FLAG ${MPI_ALL_LINK_FLAGS})
- string(REGEX REPLACE "^ " "" FLAG ${FLAG})
- if (MPI_LINK_FLAGS_WORK)
- string(APPEND MPI_LINK_FLAGS_WORK " ${FLAG}")
- else()
- set(MPI_LINK_FLAGS_WORK ${FLAG})
- endif()
- endforeach()
+ # MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to
+ # link it in that case. -lpthread is covered by the normal library treatment on the other hand.
+ if("${MPI_COMPILE_CMDLINE}" MATCHES "-pthread")
+ list(APPEND MPI_COMPILE_OPTIONS_WORK "-pthread")
+ if(MPI_LINK_FLAGS_WORK)
+ string(APPEND MPI_LINK_FLAGS_WORK " -pthread")
+ else()
+ set(MPI_LINK_FLAGS_WORK "-pthread")
+ endif()
+ endif()
- # Extract the set of libraries to link against from the link command
- # line
- string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}")
- if(WIN32)
- # The intel wrappers on windows link against static versions of the MPI libraries.
- # The static libraries are simply listed on the command line without -l.
- # For instance: " icl ... impi.lib "
- string(REGEX MATCHALL "(^| )([^\" ]+)\\.lib" tmp "${MPI_LINK_CMDLINE}")
- list(APPEND MPI_LIBNAMES ${tmp})
+ if(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS)
+ list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS}")
+ endif()
+ if(MPI_${LANG}_EXTRA_COMPILE_OPTIONS)
+ list(APPEND MPI_COMPILE_OPTIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_OPTIONS}")
+ endif()
+ if(MPI_${LANG}_EXTRA_LIB_NAMES)
+ list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${MPI_${LANG}_EXTRA_LIB_NAMES}")
+ endif()
+
+ # If we found MPI, set up all of the appropriate cache entries
+ if(NOT MPI_${LANG}_COMPILE_OPTIONS)
+ set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_COMPILE_OPTIONS_WORK} CACHE STRING "MPI ${LANG} compilation options" FORCE)
+ endif()
+ if(NOT MPI_${LANG}_COMPILE_DEFINITIONS)
+ set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_COMPILE_DEFINITIONS_WORK} CACHE STRING "MPI ${LANG} compilation definitions" FORCE)
+ endif()
+ if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
+ set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_INCLUDE_DIRS_WORK} CACHE STRING "MPI ${LANG} additional include directories" FORCE)
+ endif()
+ if(NOT MPI_${LANG}_LINK_FLAGS)
+ set(MPI_${LANG}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${LANG} linker flags" FORCE)
+ endif()
+ if(NOT MPI_${LANG}_LIB_NAMES)
+ set(MPI_${LANG}_LIB_NAMES ${MPI_PLAIN_LIB_NAMES_WORK} CACHE STRING "MPI ${LANG} libraries to link against" FORCE)
+ endif()
+ set(MPI_${LANG}_WRAPPER_FOUND TRUE PARENT_SCOPE)
+endfunction()
+
+function(_MPI_guess_settings LANG)
+ set(MPI_GUESS_FOUND FALSE)
+ # Currently only MSMPI and MPICH2 on Windows are supported, so we can skip this search if we're not targeting that.
+ if(WIN32)
+ # MSMPI
+
+ # The environment variables MSMPI_INC and MSMPILIB32/64 are the only ways of locating the MSMPI_SDK,
+ # which is installed separately from the runtime. Thus it's possible to have mpiexec but not MPI headers
+ # or import libraries and vice versa.
+ if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MSMPI")
+ # We first attempt to locate the msmpi.lib. Should be find it, we'll assume that the MPI present is indeed
+ # Microsoft MPI.
+ if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
+ set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB64}")
+ set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x64")
+ else()
+ set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB32}")
+ set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x86")
+ endif()
+
+ find_library(MPI_msmpi_LIBRARY
+ NAMES msmpi
+ HINTS ${MPI_MSMPI_LIB_PATH}
+ DOC "Location of the msmpi library for Microsoft MPI")
+ mark_as_advanced(MPI_msmpi_LIBRARY)
+
+ if(MPI_msmpi_LIBRARY)
+ # Next, we attempt to locate the MPI header. Note that for Fortran we know that mpif.h is a way
+ # MSMPI can be used and therefore that header has to be present.
+ if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
+ get_filename_component(MPI_MSMPI_INC_DIR "$ENV{MSMPI_INC}" REALPATH)
+ set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MSMPI_INC_DIR}" CACHE STRING "MPI ${LANG} additional include directories" FORCE)
+ unset(MPI_MSMPI_INC_DIR)
endif()
- # add the compiler implicit directories because some compilers
- # such as the intel compiler have libraries that show up
- # in the showme list that can only be found in the implicit
- # link directories of the compiler.
- if (DEFINED CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES)
- string(APPEND MPI_LINK_PATH
- ";${CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES}")
- endif ()
-
- # Determine full path names for all of the libraries that one needs
- # to link against in an MPI program
- foreach(LIB ${MPI_LIBNAMES})
- string(REGEX REPLACE "^ ?-l" "" LIB ${LIB})
- if(WIN32)
- string(REGEX REPLACE "\\.lib$" "" LIB ${LIB})
+ # For MSMPI, one can compile the MPI module by building the mpi.f90 shipped with the MSMPI SDK,
+ # thus it might be present or provided by the user. Figuring out which is supported is done later on.
+ # The PGI Fortran compiler for instance ships a prebuilt set of modules in its own include folder.
+ # Should a user be employing PGI or have built its own set and provided it via cache variables, the
+ # splitting routine would have located the module files.
+
+ # For C and C++, we're done here (MSMPI does not ship the MPI-2 C++ bindings) - however, for Fortran
+ # we need some extra library to glue Fortran support together:
+ # MSMPI ships 2-4 Fortran libraries, each for different Fortran compiler behaviors. The library names
+ # ending with a c are using the cdecl calling convention, whereas those ending with an s are for Fortran
+ # implementations using stdcall. Therefore, the 64-bit MSMPI only ships those ending in 'c', whereas the 32-bit
+ # has both variants available.
+ # The second difference is the last but one letter, if it's an e(nd), the length of a string argument is
+ # passed by the Fortran compiler after all other arguments on the parameter list, if it's an m(ixed),
+ # it's passed immediately after the string address.
+
+ # To summarize:
+ # - msmpifec: CHARACTER length passed after the parameter list and using cdecl calling convention
+ # - msmpifmc: CHARACTER length passed directly after string address and using cdecl calling convention
+ # - msmpifes: CHARACTER length passed after the parameter list and using stdcall calling convention
+ # - msmpifms: CHARACTER length passed directly after string address and using stdcall calling convention
+ # 32-bit MSMPI ships all four libraries, 64-bit MSMPI ships only the first two.
+
+ # As is, Intel Fortran and PGI Fortran both use the 'ec' variant of the calling convention, whereas
+ # the old Compaq Visual Fortran compiler defaulted to the 'ms' version. It's possible to make Intel Fortran
+ # use the CVF calling convention using /iface:cvf, but we assume - and this is also assumed in FortranCInterface -
+ # this isn't the case. It's also possible to make CVF use the 'ec' variant, using /iface=(cref,nomixed_str_len_arg).
+
+ # Our strategy is now to locate all libraries, but enter msmpifec into the LIB_NAMES array.
+ # Should this not be adequate it's a straightforward way for a user to change the LIB_NAMES array and
+ # have his library found. Still, this should not be necessary outside of exceptional cases, as reasoned.
+ if ("${LANG}" STREQUAL "Fortran")
+ set(MPI_MSMPI_CALLINGCONVS c)
+ if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
+ list(APPEND MPI_MSMPI_CALLINGCONVS s)
endif()
- string(STRIP ${LIB} LIB)
- # MPI_LIB is cached by find_library, but we don't want that. Clear it first.
- set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
- find_library(MPI_LIB NAMES ${LIB} HINTS ${MPI_LINK_PATH})
-
- if (MPI_LIB)
- list(APPEND MPI_LIBRARIES_WORK ${MPI_LIB})
- elseif (NOT MPI_FIND_QUIETLY)
- message(WARNING "Unable to find MPI library ${LIB}")
+ foreach(mpistrlenpos IN ITEMS e m)
+ foreach(mpicallingconv IN LISTS MPI_MSMPI_CALLINGCONVS)
+ find_library(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY
+ NAMES msmpif${mpistrlenpos}${mpicallingconv}
+ HINTS "${MPI_MSMPI_LIB_PATH}"
+ DOC "Location of the msmpi${mpistrlenpos}${mpicallingconv} library for Microsoft MPI")
+ mark_as_advanced(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY)
+ endforeach()
+ endforeach()
+ if(NOT MPI_${LANG}_LIB_NAMES)
+ set(MPI_${LANG}_LIB_NAMES "msmpi;msmpifec" CACHE STRING "MPI ${LANG} libraries to link against" FORCE)
endif()
- endforeach()
- # Sanity check MPI_LIBRARIES to make sure there are enough libraries
- list(LENGTH MPI_LIBRARIES_WORK MPI_NUMLIBS)
- list(LENGTH MPI_LIBNAMES MPI_NUMLIBS_EXPECTED)
- if (NOT MPI_NUMLIBS EQUAL MPI_NUMLIBS_EXPECTED)
- set(MPI_LIBRARIES_WORK "MPI_${lang}_LIBRARIES-NOTFOUND")
+ # At this point we're *not* done. MSMPI requires an additional include file for Fortran giving the value
+ # of MPI_AINT. This file is called mpifptr.h located in the x64 and x86 subfolders, respectively.
+ find_path(MPI_mpifptr_INCLUDE_DIR
+ NAMES "mpifptr.h"
+ HINTS "${MPI_MSMPI_INC_PATH_EXTRA}"
+ DOC "Location of the mpifptr.h extra header for Microsoft MPI")
+ if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
+ set(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS "mpifptr" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI_<name>_INCLUDE_DIR." FORCE)
+ endif()
+ mark_as_advanced(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS MPI_mpifptr_INCLUDE_DIR)
+ else()
+ if(NOT MPI_${LANG}_LIB_NAMES)
+ set(MPI_${LANG}_LIB_NAMES "msmpi" CACHE STRING "MPI ${LANG} libraries to link against" FORCE)
+ endif()
endif()
- endif()
+ mark_as_advanced(MPI_${LANG}_LIB_NAMES)
+ set(MPI_GUESS_FOUND TRUE)
- elseif(try_libs)
- # If we didn't have an MPI compiler script to interrogate, attempt to find everything
- # with plain old find functions. This is nasty because MPI implementations have LOTS of
- # different library names, so this section isn't going to be very generic. We need to
- # make sure it works for MS MPI, though, since there are no compiler wrappers for that.
- find_path(MPI_HEADER_PATH mpi.h
- HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH}
- PATH_SUFFIXES include Inc)
- set(MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH})
-
- # Decide between 32-bit and 64-bit libraries for Microsoft's MPI
- if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
- set(MS_MPI_ARCH_DIR x64)
- set(MS_MPI_ARCH_DIR2 amd64)
- else()
- set(MS_MPI_ARCH_DIR x86)
- set(MS_MPI_ARCH_DIR2 i386)
+ if(_MPIEXEC_NOT_GIVEN)
+ unset(MPIEXEC_EXECUTABLE CACHE)
+ endif()
+
+ find_program(MPIEXEC_EXECUTABLE
+ NAMES mpiexec
+ HINTS $ENV{MSMPI_BIN} "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MPI;InstallRoot]/Bin"
+ DOC "Executable for running MPI programs.")
endif()
+ endif()
+
+ # At this point there's not many MPIs that we could still consider.
+ # OpenMPI 1.6.x and below supported Windows, but these ship compiler wrappers that still work.
+ # The only other relevant MPI implementation without a wrapper is MPICH2, which had Windows support in 1.4.1p1 and older.
+ if(NOT MPI_GUESS_FOUND AND (NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MPICH2"))
+ set(MPI_MPICH_PREFIX_PATHS
+ "$ENV{ProgramW6432}/MPICH2/lib"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/../lib"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]/lib"
+ )
- set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
- find_library(MPI_LIB
- NAMES mpi mpich mpich2 msmpi
- HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH}
- PATH_SUFFIXES lib lib/${MS_MPI_ARCH_DIR} Lib Lib/${MS_MPI_ARCH_DIR} Lib/${MS_MPI_ARCH_DIR2})
- set(MPI_LIBRARIES_WORK ${MPI_LIB})
-
- # Right now, we only know about the extra libs for C++.
- # We could add Fortran here (as there is usually libfmpich, etc.), but
- # this really only has to work with MS MPI on Windows.
- # Assume that other MPI's are covered by the compiler wrappers.
- if (${lang} STREQUAL CXX)
- set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
- find_library(MPI_LIB
- NAMES mpi++ mpicxx cxx mpi_cxx
- HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH}
- PATH_SUFFIXES lib)
- if (MPI_LIBRARIES_WORK AND MPI_LIB)
- list(APPEND MPI_LIBRARIES_WORK ${MPI_LIB})
+ # All of C, C++ and Fortran will need mpi.lib, so we'll look for this first
+ find_library(MPI_mpi_LIBRARY
+ NAMES mpi
+ HINTS ${MPI_MPICH_PREFIX_PATHS})
+ mark_as_advanced(MPI_mpi_LIBRARY)
+ # If we found mpi.lib, we detect the rest of MPICH2
+ if(MPI_mpi_LIBRARY)
+ set(MPI_MPICH_LIB_NAMES "mpi")
+ # If MPI-2 C++ bindings are requested, we need to locate cxx.lib as well.
+ # Otherwise, MPICH_SKIP_MPICXX will be defined and these bindings aren't needed.
+ if("${LANG}" STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX)
+ find_library(MPI_cxx_LIBRARY
+ NAMES cxx
+ HINTS ${MPI_MPICH_PREFIX_PATHS})
+ mark_as_advanced(MPI_cxx_LIBRARY)
+ list(APPEND MPI_MPICH_LIB_NAMES "cxx")
+ # For Fortran, MPICH2 provides three different libraries:
+ # fmpich2.lib which uses uppercase symbols and cdecl,
+ # fmpich2s.lib which uses uppercase symbols and stdcall (32-bit only),
+ # fmpich2g.lib which uses lowercase symbols with double underscores and cdecl.
+ # fmpich2s.lib would be useful for Compaq Visual Fortran, fmpich2g.lib has to be used with GNU g77 and is also
+ # provided in the form of an .a archive for MinGW and Cygwin. From our perspective, fmpich2.lib is the only one
+ # we need to try, and if it doesn't work with the given Fortran compiler we'd find out later on during validation
+ elseif("${LANG}" STREQUAL "Fortran")
+ find_library(MPI_fmpich2_LIBRARY
+ NAMES fmpich2
+ HINTS ${MPI_MPICH_PREFIX_PATHS})
+ find_library(MPI_fmpich2s_LIBRARY
+ NAMES fmpich2s
+ HINTS ${MPI_MPICH_PREFIX_PATHS})
+ find_library(MPI_fmpich2g_LIBRARY
+ NAMES fmpich2g
+ HINTS ${MPI_MPICH_PREFIX_PATHS})
+ mark_as_advanced(MPI_fmpich2_LIBRARY MPI_fmpich2s_LIBRARY MPI_fmpich2g_LIBRARY)
+ list(APPEND MPI_MPICH_LIB_NAMES "fmpich2")
+ endif()
+
+ if(NOT MPI_${LANG}_LIB_NAMES)
+ set(MPI_${LANG}_LIB_NAMES "${MPI_MPICH_LIB_NAMES}" CACHE STRING "MPI ${LANG} libraries to link against" FORCE)
+ endif()
+ unset(MPI_MPICH_LIB_NAMES)
+
+ if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
+ # For MPICH2, the include folder would be in ../include relative to the library folder.
+ get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_mpi_LIBRARY}" DIRECTORY)
+ get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_MPICH_ROOT_DIR}" DIRECTORY)
+ if(IS_DIRECTORY "${MPI_MPICH_ROOT_DIR}/include")
+ set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MPICH_ROOT_DIR}/include" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI_<name>_INCLUDE_DIR." FORCE)
+ endif()
+ unset(MPI_MPICH_ROOT_DIR)
+ endif()
+ set(MPI_GUESS_FOUND TRUE)
+
+ if(_MPIEXEC_NOT_GIVEN)
+ unset(MPIEXEC_EXECUTABLE CACHE)
endif()
- endif()
- if (NOT MPI_LIBRARIES_WORK)
- set(MPI_LIBRARIES_WORK "MPI_${lang}_LIBRARIES-NOTFOUND")
+ find_program(MPIEXEC_EXECUTABLE
+ NAMES ${_MPIEXEC_NAMES}
+ HINTS "$ENV{ProgramW6432}/MPICH2/bin"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]/bin"
+ DOC "Executable for running MPI programs.")
endif()
+ unset(MPI_MPICH_PREFIX_PATHS)
endif()
+ endif()
+ set(MPI_${LANG}_GUESS_FOUND "${MPI_GUESS_FOUND}" PARENT_SCOPE)
+endfunction()
- # If we found MPI, set up all of the appropriate cache entries
- set(MPI_${lang}_COMPILE_FLAGS ${MPI_COMPILE_FLAGS_WORK} CACHE STRING "MPI ${lang} compilation flags" FORCE)
- set(MPI_${lang}_INCLUDE_PATH ${MPI_INCLUDE_PATH_WORK} CACHE STRING "MPI ${lang} include path" FORCE)
- set(MPI_${lang}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${lang} linking flags" FORCE)
- set(MPI_${lang}_LIBRARIES ${MPI_LIBRARIES_WORK} CACHE STRING "MPI ${lang} libraries to link against" FORCE)
- mark_as_advanced(MPI_${lang}_COMPILE_FLAGS MPI_${lang}_INCLUDE_PATH MPI_${lang}_LINK_FLAGS MPI_${lang}_LIBRARIES)
+function(_MPI_adjust_compile_definitions LANG)
+ if("${LANG}" STREQUAL "CXX")
+ # To disable the C++ bindings, we need to pass some definitions since the mpi.h header has to deal with both C and C++
+ # bindings in MPI-2.
+ if(MPI_CXX_SKIP_MPICXX AND NOT MPI_${LANG}_COMPILE_DEFINITIONS MATCHES "SKIP_MPICXX")
+ # MPICH_SKIP_MPICXX is being used in MPICH and derivatives like MVAPICH or Intel MPI
+ # OMPI_SKIP_MPICXX is being used in Open MPI
+ # _MPICC_H is being used for IBM Platform MPI
+ list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX" "OMPI_SKIP_MPICXX" "_MPICC_H")
+ set(MPI_${LANG}_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}" CACHE STRING "MPI ${LANG} compilation definitions" FORCE)
+ endif()
+ endif()
+endfunction()
- # clear out our temporary lib/header detection variable here.
- set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI lib detection" FORCE)
- set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI header detection" FORCE)
+macro(_MPI_assemble_libraries LANG)
+ set(MPI_${LANG}_LIBRARIES "")
+ # Only for libraries do we need to check whether the compiler's linking stage is separate.
+ if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS_IMPLICIT)
+ foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES)
+ list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY})
+ endforeach()
endif()
+endmacro()
- # finally set a found variable for each MPI language
- if (MPI_${lang}_INCLUDE_PATH AND MPI_${lang}_LIBRARIES)
- set(MPI_${lang}_FOUND TRUE PARENT_SCOPE)
+macro(_MPI_assemble_include_dirs LANG)
+ if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
+ set(MPI_${LANG}_INCLUDE_DIRS "")
else()
- set(MPI_${lang}_FOUND FALSE PARENT_SCOPE)
+ set(MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}")
+ if("${LANG}" MATCHES "(C|CXX)")
+ if(MPI_${LANG}_HEADER_DIR)
+ list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}")
+ endif()
+ else() # Fortran
+ if(MPI_${LANG}_F77_HEADER_DIR)
+ list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_F77_HEADER_DIR}")
+ endif()
+ if(MPI_${LANG}_MODULE_DIR AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS)
+ list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}")
+ endif()
+ endif()
+ if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
+ foreach(MPI_ADDITIONAL_INC_DIR IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
+ list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${MPI_ADDITIONAL_INC_DIR}_INCLUDE_DIR}")
+ endforeach()
+ endif()
+ endif()
+endmacro()
+
+function(_MPI_split_include_dirs LANG)
+ if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
+ return()
+ endif()
+ # Backwards compatibility: Search INCLUDE_PATH if given.
+ if(MPI_${LANG}_INCLUDE_PATH)
+ list(APPEND MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_INCLUDE_PATH}")
+ endif()
+
+ # We try to find the headers/modules among those paths (and system paths)
+ # For C/C++, we just need to have a look for mpi.h.
+ if("${LANG}" MATCHES "(C|CXX)")
+ find_path(MPI_${LANG}_HEADER_DIR "mpi.h"
+ HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}
+ )
+ mark_as_advanced(MPI_${LANG}_HEADER_DIR)
+ if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
+ list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}")
+ endif()
+ # Fortran is more complicated here: An implementation could provide
+ # any of the Fortran 77/90/2008 APIs for MPI. For example, MSMPI
+ # only provides Fortran 77 and - if mpi.f90 is built - potentially
+ # a Fortran 90 module.
+ elseif("${LANG}" STREQUAL "Fortran")
+ find_path(MPI_${LANG}_F77_HEADER_DIR "mpif.h"
+ HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}
+ )
+ find_path(MPI_${LANG}_MODULE_DIR
+ NAMES "mpi.mod" "mpi_f08.mod"
+ HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}
+ )
+ if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
+ list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS
+ "${MPI_${LANG}_F77_HEADER_DIR}"
+ "${MPI_${LANG}_MODULE_DIR}"
+ )
+ endif()
+ mark_as_advanced(MPI_${LANG}_F77_HEADER_DIR MPI_${LANG}_MODULE_DIR)
+ endif()
+ # Remove duplicates and default system directories from the list.
+ if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
+ list(REMOVE_DUPLICATES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
+ foreach(MPI_IMPLICIT_INC_DIR IN LISTS CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES)
+ list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_IMPLICIT_INC_DIR})
+ endforeach()
endif()
+ set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories" FORCE)
endfunction()
+macro(_MPI_create_imported_target LANG)
+ if(NOT TARGET MPI::MPI_${LANG})
+ add_library(MPI::MPI_${LANG} INTERFACE IMPORTED)
+ endif()
+
+ # When this is consumed for compiling CUDA, use '-Xcompiler' to wrap '-pthread'.
+ string(REPLACE "-pthread" "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler >-pthread"
+ _MPI_${LANG}_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}")
+ set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${_MPI_${LANG}_COMPILE_OPTIONS}")
+ unset(_MPI_${LANG}_COMPILE_OPTIONS)
+
+ set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}")
-# This function attempts to compile with the regular compiler, to see if MPI programs
-# work with it. This is a last ditch attempt after we've tried interrogating mpicc and
-# friends, and after we've tried to find generic libraries. Works on machines like
-# Cray XE6, where the modules environment changes what MPI version cc, CC, and ftn use.
-function(try_regular_compiler lang success)
- set(scratch_directory ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY})
- if (${lang} STREQUAL Fortran)
- set(test_file ${scratch_directory}/cmake_mpi_test.f90)
- file(WRITE ${test_file}
- "program hello\n"
- "include 'mpif.h'\n"
- "integer ierror\n"
- "call MPI_INIT(ierror)\n"
- "call MPI_FINALIZE(ierror)\n"
- "end\n")
+ if(MPI_${LANG}_LINK_FLAGS)
+ set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_OPTIONS "SHELL:${MPI_${LANG}_LINK_FLAGS}")
+ endif()
+ # If the compiler links MPI implicitly, no libraries will be found as they're contained within
+ # CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES already.
+ if(MPI_${LANG}_LIBRARIES)
+ set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LIBRARIES}")
+ endif()
+ # Given the new design of FindMPI, INCLUDE_DIRS will always be located, even under implicit linking.
+ set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MPI_${LANG}_INCLUDE_DIRS}")
+endmacro()
+
+function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY SUPPRESS_ERRORS)
+ set(WORK_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI")
+ set(SRC_DIR "${CMAKE_ROOT}/Modules/FindMPI")
+ set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI/${MPI_TEST_FILE_NAME}_${LANG}.bin")
+ unset(MPI_TEST_COMPILE_DEFINITIONS)
+ if("${LANG}" STREQUAL "Fortran")
+ if("${MODE}" STREQUAL "F90_MODULE")
+ set(MPI_Fortran_INCLUDE_LINE "use mpi\n implicit none")
+ elseif("${MODE}" STREQUAL "F08_MODULE")
+ set(MPI_Fortran_INCLUDE_LINE "use mpi_f08\n implicit none")
+ else() # F77 header
+ set(MPI_Fortran_INCLUDE_LINE "implicit none\n include 'mpif.h'")
+ endif()
+ configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90" @ONLY)
+ set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90")
+ elseif("${LANG}" STREQUAL "CXX")
+ configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp" COPYONLY)
+ set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp")
+ if("${MODE}" STREQUAL "TEST_MPICXX")
+ set(MPI_TEST_COMPILE_DEFINITIONS TEST_MPI_MPICXX)
+ endif()
+ else() # C
+ set(MPI_TEST_SOURCE_FILE "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c")
+ endif()
+ if(RUN_BINARY)
+ try_run(MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}
+ "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}"
+ COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS}
+ LINK_LIBRARIES MPI::MPI_${LANG}
+ RUN_OUTPUT_VARIABLE MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}
+ COMPILE_OUTPUT_VARIABLE _MPI_TRY_${MPI_TEST_FILE_NAME}_${MODE}_OUTPUT)
+ set(MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} "${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}" PARENT_SCOPE)
else()
- if (${lang} STREQUAL CXX)
- set(test_file ${scratch_directory}/cmake_mpi_test.cpp)
- else()
- set(test_file ${scratch_directory}/cmake_mpi_test.c)
- endif()
- file(WRITE ${test_file}
- "#include <mpi.h>\n"
- "int main(int argc, char **argv) {\n"
- " MPI_Init(&argc, &argv);\n"
- " MPI_Finalize();\n"
- "}\n")
- endif()
- try_compile(compiler_has_mpi ${scratch_directory} ${test_file})
- if (compiler_has_mpi)
- set(MPI_${lang}_NO_INTERROGATE ${CMAKE_${lang}_COMPILER} CACHE STRING "Whether to interrogate MPI ${lang} compiler" FORCE)
- set(MPI_${lang}_COMPILER ${CMAKE_${lang}_COMPILER} CACHE STRING "MPI ${lang} compiler" FORCE)
- set(MPI_${lang}_COMPILE_FLAGS "" CACHE STRING "MPI ${lang} compilation flags" FORCE)
- set(MPI_${lang}_INCLUDE_PATH "" CACHE STRING "MPI ${lang} include path" FORCE)
- set(MPI_${lang}_LINK_FLAGS "" CACHE STRING "MPI ${lang} linking flags" FORCE)
- set(MPI_${lang}_LIBRARIES "" CACHE STRING "MPI ${lang} libraries to link against" FORCE)
- endif()
- set(${success} ${compiler_has_mpi} PARENT_SCOPE)
- unset(compiler_has_mpi CACHE)
+ try_compile(MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}
+ "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}"
+ COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS}
+ LINK_LIBRARIES MPI::MPI_${LANG}
+ COPY_FILE "${BIN_FILE}"
+ OUTPUT_VARIABLE _MPI_TRY_${MPI_TEST_FILE_NAME}_${MODE}_OUTPUT)
+ endif()
+ if(NOT SUPPRESS_ERRORS)
+ if(NOT MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE})
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "The MPI test ${MPI_TEST_FILE_NAME} for ${LANG} in mode ${MODE} failed to compile with the following output:\n${_MPI_TRY_${MPI_TEST_FILE_NAME}_${MODE}_OUTPUT}\n\n")
+ elseif(DEFINED MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} AND MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE})
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "The MPI test ${MPI_TEST_FILE_NAME} for ${LANG} in mode ${MODE} failed to run with the following output:\n${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}\n\n")
+ endif()
+ endif()
endfunction()
-# End definitions, commence real work here.
+macro(_MPI_check_lang_works LANG SUPPRESS_ERRORS)
+ # For Fortran we may have by the MPI-3 standard an implementation that provides:
+ # - the mpi_f08 module
+ # - *both*, the mpi module and 'mpif.h'
+ # Since older MPI standards (MPI-1) did not define anything but 'mpif.h', we need to check all three individually.
+ if( NOT MPI_${LANG}_WORKS )
+ if("${LANG}" STREQUAL "Fortran")
+ set(MPI_Fortran_INTEGER_LINE "(kind=MPI_INTEGER_KIND)")
+ _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER FALSE ${SUPPRESS_ERRORS})
+ _MPI_try_staged_settings(${LANG} test_mpi F90_MODULE FALSE ${SUPPRESS_ERRORS})
+ _MPI_try_staged_settings(${LANG} test_mpi F08_MODULE FALSE ${SUPPRESS_ERRORS})
+
+ set(MPI_${LANG}_WORKS FALSE)
+
+ foreach(mpimethod IN ITEMS F77_HEADER F08_MODULE F90_MODULE)
+ if(MPI_RESULT_${LANG}_test_mpi_${mpimethod})
+ set(MPI_${LANG}_WORKS TRUE)
+ set(MPI_${LANG}_HAVE_${mpimethod} TRUE)
+ else()
+ set(MPI_${LANG}_HAVE_${mpimethod} FALSE)
+ endif()
+ endforeach()
+ # MPI-1 versions had no MPI_INTGER_KIND defined, so we need to try without it.
+ # However, MPI-1 also did not define the Fortran 90 and 08 modules, so we only try the F77 header.
+ unset(MPI_Fortran_INTEGER_LINE)
+ if(NOT MPI_${LANG}_WORKS)
+ _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER_NOKIND FALSE ${SUPPRESS_ERRORS})
+ if(MPI_RESULT_${LANG}_test_mpi_F77_HEADER_NOKIND)
+ set(MPI_${LANG}_WORKS TRUE)
+ set(MPI_${LANG}_HAVE_F77_HEADER TRUE)
+ endif()
+ endif()
+ else()
+ _MPI_try_staged_settings(${LANG} test_mpi normal FALSE ${SUPPRESS_ERRORS})
+ # If 'test_mpi' built correctly, we've found valid MPI settings. There might not be MPI-2 C++ support, but there can't
+ # be MPI-2 C++ support without the C bindings being present, so checking for them is sufficient.
+ set(MPI_${LANG}_WORKS "${MPI_RESULT_${LANG}_test_mpi_normal}")
+ endif()
+ endif()
+endmacro()
+
+# Some systems install various MPI implementations in separate folders in some MPI prefix
+# This macro enumerates all such subfolders and adds them to the list of hints that will be searched.
+macro(MPI_search_mpi_prefix_folder PREFIX_FOLDER)
+ if(EXISTS "${PREFIX_FOLDER}")
+ file(GLOB _MPI_folder_children RELATIVE "${PREFIX_FOLDER}" "${PREFIX_FOLDER}/*")
+ foreach(_MPI_folder_child IN LISTS _MPI_folder_children)
+ if(IS_DIRECTORY "${PREFIX_FOLDER}/${_MPI_folder_child}")
+ list(APPEND MPI_HINT_DIRS "${PREFIX_FOLDER}/${_MPI_folder_child}")
+ endif()
+ endforeach()
+ endif()
+endmacro()
+
+set(MPI_HINT_DIRS ${MPI_HOME} $ENV{MPI_HOME} $ENV{I_MPI_ROOT})
+if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
+ # SUSE Linux Enterprise Server stores its MPI implementations under /usr/lib64/mpi/gcc/<name>
+ # We enumerate the subfolders and append each as a prefix
+ MPI_search_mpi_prefix_folder("/usr/lib64/mpi/gcc")
+elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "FreeBSD")
+ # FreeBSD ships mpich under the normal system paths - but available openmpi implementations
+ # will be found in /usr/local/mpi/<name>
+ MPI_search_mpi_prefix_folder("/usr/local/mpi")
+endif()
+
+# Most MPI distributions have some form of mpiexec or mpirun which gives us something we can look for.
+# The MPI standard does not mandate the existence of either, but instead only makes requirements if a distribution
+# ships an mpiexec program (mpirun executables are not regulated by the standard).
-# Most mpi distros have some form of mpiexec which gives us something we can reliably look for.
-find_program(MPIEXEC
- NAMES ${_MPI_EXEC_NAMES}
- HINTS ${MPI_HOME} $ENV{MPI_HOME}
- PATHS ${_MPI_PREFIX_PATH}
- PATH_SUFFIXES bin
+# We defer searching for mpiexec binaries belonging to guesses until later. By doing so, mismatches between mpiexec
+# and the MPI we found should be reduced.
+if(NOT MPIEXEC_EXECUTABLE)
+ set(_MPIEXEC_NOT_GIVEN TRUE)
+else()
+ set(_MPIEXEC_NOT_GIVEN FALSE)
+endif()
+
+find_program(MPIEXEC_EXECUTABLE
+ NAMES ${_MPIEXEC_NAMES}
+ PATH_SUFFIXES bin sbin
+ HINTS ${MPI_HINT_DIRS}
DOC "Executable for running MPI programs.")
# call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin).
# This gives us a fairly reliable base directory to search for /bin /lib and /include from.
-get_filename_component(_MPI_BASE_DIR "${MPIEXEC}" PATH)
+get_filename_component(_MPI_BASE_DIR "${MPIEXEC_EXECUTABLE}" PATH)
get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH)
# According to the MPI standard, section 8.8 -n is a guaranteed, and the only guaranteed way to
# launch an MPI process using mpiexec if such a program exists.
-set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the number of processes for MPIEXEC; the next option will be the number of processes.")
-set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by MPIEXEC.")
-set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will come after all flags given to MPIEXEC.")
-
-# Set the number of processes to the processor count and the previous default
-# of 2 if that couldn't be determined.
-include(${CMAKE_CURRENT_LIST_DIR}/ProcessorCount.cmake)
-ProcessorCount(_MPIEXEC_NUMPROCS)
-if("${_MPIEXEC_NUMPROCS}" EQUAL "0")
- set(_MPIEXEC_NUMPROCS 2)
-endif()
-set(MPIEXEC_MAX_NUMPROCS "${_MPIEXEC_NUMPROCS}" CACHE STRING "Maximum number of processors available to run MPI applications.")
-unset(_MPIEXEC_NUMPROCS)
-mark_as_advanced(MPIEXEC MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS)
+set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the number of processes for mpiexec; the next option will be the number of processes.")
+set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by mpiexec.")
+set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will be placed after all flags passed to mpiexec.")
+# Set the number of processes to the physical processor count
+cmake_host_system_information(RESULT _MPIEXEC_NUMPROCS QUERY NUMBER_OF_PHYSICAL_CORES)
+set(MPIEXEC_MAX_NUMPROCS "${_MPIEXEC_NUMPROCS}" CACHE STRING "Maximum number of processors available to run MPI applications.")
+unset(_MPIEXEC_NUMPROCS)
+mark_as_advanced(MPIEXEC_EXECUTABLE MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS)
#=============================================================================
# Backward compatibility input hacks. Propagate the FindMPI hints to C and
# CXX if the respective new versions are not defined. Translate the old
-# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${lang}_LIBRARIES.
+# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${LANG}_LIBRARIES.
#
# Once we find the new variables, we translate them back into their old
# equivalents below.
-foreach (lang C CXX)
- # Old input variables.
- set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS)
+if(NOT MPI_IGNORE_LEGACY_VARIABLES)
+ foreach (LANG IN ITEMS C CXX)
+ # Old input variables.
+ set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS)
+
+ # Set new vars based on their old equivalents, if the new versions are not already set.
+ foreach (var ${_MPI_OLD_INPUT_VARS})
+ if (NOT MPI_${LANG}_${var} AND MPI_${var})
+ set(MPI_${LANG}_${var} "${MPI_${var}}")
+ endif()
+ endforeach()
+
+ # Chop the old compile flags into options and definitions
- # Set new vars based on their old equivalents, if the new versions are not already set.
- foreach (var ${_MPI_OLD_INPUT_VARS})
- if (NOT MPI_${lang}_${var} AND MPI_${var})
- set(MPI_${lang}_${var} "${MPI_${var}}")
+ unset(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS)
+ unset(MPI_${LANG}_EXTRA_COMPILE_OPTIONS)
+ if(MPI_${LANG}_COMPILE_FLAGS)
+ separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}")
+ foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS)
+ if("${_MPI_FLAG}" MATCHES "^ *-D([^ ]+)")
+ list(APPEND MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}")
+ else()
+ list(APPEND MPI_${LANG}_EXTRA_COMPILE_OPTIONS "${_MPI_FLAG}")
+ endif()
+ endforeach()
+ unset(MPI_SEPARATE_FLAGS)
endif()
- endforeach()
- # Special handling for MPI_LIBRARY and MPI_EXTRA_LIBRARY, which we nixed in the
- # new FindMPI. These need to be merged into MPI_<lang>_LIBRARIES
- if (NOT MPI_${lang}_LIBRARIES AND (MPI_LIBRARY OR MPI_EXTRA_LIBRARY))
- set(MPI_${lang}_LIBRARIES ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY})
- endif()
-endforeach()
+ # If a list of libraries was given, we'll split it into new-style cache variables
+ unset(MPI_${LANG}_EXTRA_LIB_NAMES)
+ if(NOT MPI_${LANG}_LIB_NAMES)
+ foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY)
+ if(_MPI_LIB)
+ get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE)
+ get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME)
+ get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY)
+ list(APPEND MPI_${LANG}_EXTRA_LIB_NAMES "${_MPI_PLAIN_LIB_NAME}")
+ find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY
+ NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}"
+ HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB}
+ DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI"
+ )
+ mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY)
+ endif()
+ endforeach()
+ endif()
+ endforeach()
+endif()
#=============================================================================
+unset(MPI_VERSION)
+unset(MPI_VERSION_MAJOR)
+unset(MPI_VERSION_MINOR)
+
+unset(_MPI_MIN_VERSION)
+
+# If the user specified a library name we assume they prefer that library over a wrapper. If not, they can disable skipping manually.
+if(NOT DEFINED MPI_SKIP_COMPILER_WRAPPER AND MPI_GUESS_LIBRARY_NAME)
+ set(MPI_SKIP_COMPILER_WRAPPER TRUE)
+endif()
# This loop finds the compilers and sends them off for interrogation.
-foreach (lang C CXX Fortran)
- if (CMAKE_${lang}_COMPILER_WORKS)
- # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler.
- if (MPI_${lang}_COMPILER)
- if (NOT IS_ABSOLUTE "${MPI_${lang}_COMPILER}")
- # Get rid of our default list of names and just search for the name the user wants.
- set(_MPI_${lang}_COMPILER_NAMES ${MPI_${lang}_COMPILER})
- set(MPI_${lang}_COMPILER "MPI_${lang}_COMPILER-NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
- endif()
- # If the user specifies a compiler, we don't want to try to search libraries either.
- set(try_libs FALSE)
+foreach(LANG IN ITEMS C CXX Fortran)
+ if(CMAKE_${LANG}_COMPILER_LOADED)
+ if(NOT MPI_FIND_COMPONENTS)
+ set(_MPI_FIND_${LANG} TRUE)
+ elseif( ${LANG} IN_LIST MPI_FIND_COMPONENTS)
+ set(_MPI_FIND_${LANG} TRUE)
+ elseif( ${LANG} STREQUAL CXX AND NOT MPI_CXX_SKIP_MPICXX AND MPICXX IN_LIST MPI_FIND_COMPONENTS )
+ set(_MPI_FIND_${LANG} TRUE)
else()
- set(try_libs TRUE)
+ set(_MPI_FIND_${LANG} FALSE)
+ endif()
+ else()
+ set(_MPI_FIND_${LANG} FALSE)
+ endif()
+ if(_MPI_FIND_${LANG})
+ if( ${LANG} STREQUAL CXX AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS )
+ set(MPI_CXX_SKIP_MPICXX FALSE CACHE BOOL "If true, the MPI-2 C++ bindings are disabled using definitions.")
+ mark_as_advanced(MPI_CXX_SKIP_MPICXX)
endif()
+ if(NOT (MPI_${LANG}_LIB_NAMES AND (MPI_${LANG}_INCLUDE_PATH OR MPI_${LANG}_INCLUDE_DIRS OR MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)))
+ set(MPI_${LANG}_TRIED_IMPLICIT FALSE)
+ set(MPI_${LANG}_WORKS_IMPLICIT FALSE)
+ if(NOT MPI_${LANG}_COMPILER AND NOT MPI_ASSUME_NO_BUILTIN_MPI)
+ # Should the imported targets be empty, we effectively try whether the compiler supports MPI on its own, which is the case on e.g.
+ # Cray PrgEnv.
+ _MPI_create_imported_target(${LANG})
+ _MPI_check_lang_works(${LANG} TRUE)
+
+ # If the compiler can build MPI code on its own, it functions as an MPI compiler and we'll set the variable to point to it.
+ if(MPI_${LANG}_WORKS)
+ set(MPI_${LANG}_COMPILER "${CMAKE_${LANG}_COMPILER}" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE)
+ set(MPI_${LANG}_WORKS_IMPLICIT TRUE)
+ endif()
+ set(MPI_${LANG}_TRIED_IMPLICIT TRUE)
+ endif()
- find_program(MPI_${lang}_COMPILER
- NAMES ${_MPI_${lang}_COMPILER_NAMES}
- HINTS ${_MPI_BASE_DIR}/bin
- PATHS ${_MPI_PREFIX_PATH}
- )
- interrogate_mpi_compiler(${lang} ${try_libs})
- mark_as_advanced(MPI_${lang}_COMPILER)
+ if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS)
+ set(MPI_${LANG}_WRAPPER_FOUND FALSE)
+ set(MPI_PINNED_COMPILER FALSE)
+
+ if(NOT MPI_SKIP_COMPILER_WRAPPER)
+ if(MPI_${LANG}_COMPILER)
+ # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler.
+ if (NOT IS_ABSOLUTE "${MPI_${LANG}_COMPILER}")
+ # Get rid of our default list of names and just search for the name the user wants.
+ set(_MPI_${LANG}_COMPILER_NAMES "${MPI_${LANG}_COMPILER}")
+ unset(MPI_${LANG}_COMPILER CACHE)
+ endif()
+ # If the user specifies a compiler, we don't want to try to search libraries either.
+ set(MPI_PINNED_COMPILER TRUE)
+ endif()
+
+ # If we have an MPI base directory, we'll try all compiler names in that one first.
+ # This should prevent mixing different MPI environments
+ if(_MPI_BASE_DIR)
+ find_program(MPI_${LANG}_COMPILER
+ NAMES ${_MPI_${LANG}_COMPILER_NAMES}
+ PATH_SUFFIXES bin sbin
+ HINTS ${_MPI_BASE_DIR}
+ NO_DEFAULT_PATH
+ DOC "MPI compiler for ${LANG}"
+ )
+ endif()
- # last ditch try -- if nothing works so far, just try running the regular compiler and
- # see if we can create an MPI executable.
- set(regular_compiler_worked 0)
- if (NOT MPI_${lang}_LIBRARIES OR NOT MPI_${lang}_INCLUDE_PATH)
- try_regular_compiler(${lang} regular_compiler_worked)
+ # If the base directory did not help (for example because the mpiexec isn't in the same directory as the compilers),
+ # we shall try searching in the default paths.
+ find_program(MPI_${LANG}_COMPILER
+ NAMES ${_MPI_${LANG}_COMPILER_NAMES}
+ PATH_SUFFIXES bin sbin
+ DOC "MPI compiler for ${LANG}"
+ )
+
+ if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
+ set(MPI_PINNED_COMPILER TRUE)
+
+ # If we haven't made the implicit compiler test yet, perform it now.
+ if(NOT MPI_${LANG}_TRIED_IMPLICIT)
+ _MPI_create_imported_target(${LANG})
+ _MPI_check_lang_works(${LANG} TRUE)
+ endif()
+
+ # Should the MPI compiler not work implicitly for MPI, still interrogate it.
+ # Otherwise, MPI compilers for which CMake has separate linking stages, e.g. Intel MPI on Windows where link.exe is being used
+ # directly during linkage instead of CMAKE_<LANG>_COMPILER will not work.
+ if(NOT MPI_${LANG}_WORKS)
+ set(MPI_${LANG}_WORKS_IMPLICIT FALSE)
+ _MPI_interrogate_compiler(${LANG})
+ else()
+ set(MPI_${LANG}_WORKS_IMPLICIT TRUE)
+ endif()
+ elseif(MPI_${LANG}_COMPILER)
+ _MPI_interrogate_compiler(${LANG})
+ endif()
+ endif()
+
+ if(NOT MPI_PINNED_COMPILER AND NOT MPI_${LANG}_WRAPPER_FOUND)
+ # If MPI_PINNED_COMPILER wasn't given, and the MPI compiler we potentially found didn't work, we withdraw it.
+ set(MPI_${LANG}_COMPILER "MPI_${LANG}_COMPILER-NOTFOUND" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE)
+ if(NOT MPI_SKIP_GUESSING)
+ # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the
+ # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI.
+ if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND)
+ set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" )
+ set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" )
+ set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories")
+ set(MPI_${LANG}_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING "MPI ${LANG} linker flags" )
+ set(MPI_${LANG}_LIB_NAMES ${MPI_C_LIB_NAMES} CACHE STRING "MPI ${LANG} libraries to link against" )
+ else()
+ _MPI_guess_settings(${LANG})
+ endif()
+ endif()
+ endif()
+ endif()
endif()
- set(MPI_${lang}_FIND_QUIETLY ${MPI_FIND_QUIETLY})
- set(MPI_${lang}_FIND_REQUIRED ${MPI_FIND_REQUIRED})
- set(MPI_${lang}_FIND_VERSION ${MPI_FIND_VERSION})
- set(MPI_${lang}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT})
+ _MPI_split_include_dirs(${LANG})
+ _MPI_assemble_include_dirs(${LANG})
+ _MPI_assemble_libraries(${LANG})
- if (regular_compiler_worked)
- find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_COMPILER)
- else()
- find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_LIBRARIES MPI_${lang}_INCLUDE_PATH)
+ _MPI_adjust_compile_definitions(${LANG})
+ # We always create imported targets even if they're empty
+ _MPI_create_imported_target(${LANG})
+
+ if(NOT MPI_${LANG}_WORKS)
+ _MPI_check_lang_works(${LANG} FALSE)
+ endif()
+
+ # Next, we'll initialize the MPI variables that have not been previously set.
+ set(MPI_${LANG}_COMPILE_OPTIONS "" CACHE STRING "MPI ${LANG} compilation flags" )
+ set(MPI_${LANG}_COMPILE_DEFINITIONS "" CACHE STRING "MPI ${LANG} compilation definitions" )
+ set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "MPI ${LANG} additional include directories")
+ set(MPI_${LANG}_LINK_FLAGS "" CACHE STRING "MPI ${LANG} linker flags" )
+ if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER)
+ set(MPI_${LANG}_LIB_NAMES "" CACHE STRING "MPI ${LANG} libraries to link against" )
endif()
+ mark_as_advanced(MPI_${LANG}_COMPILE_OPTIONS MPI_${LANG}_COMPILE_DEFINITIONS MPI_${LANG}_LINK_FLAGS
+ MPI_${LANG}_LIB_NAMES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS MPI_${LANG}_COMPILER)
+
+ # If we've found MPI, then we'll perform additional analysis: Determine the MPI version, MPI library version, supported
+ # MPI APIs (i.e. MPI-2 C++ bindings). For Fortran we also need to find specific parameters if we're under MPI-3.
+ if(MPI_${LANG}_WORKS)
+ if("${LANG}" STREQUAL "CXX" AND NOT DEFINED MPI_MPICXX_FOUND)
+ if(NOT MPI_CXX_SKIP_MPICXX AND NOT MPI_CXX_VALIDATE_SKIP_MPICXX)
+ _MPI_try_staged_settings(${LANG} test_mpi MPICXX FALSE FALSE)
+ if(MPI_RESULT_${LANG}_test_mpi_MPICXX)
+ set(MPI_MPICXX_FOUND TRUE)
+ else()
+ set(MPI_MPICXX_FOUND FALSE)
+ endif()
+ else()
+ set(MPI_MPICXX_FOUND FALSE)
+ endif()
+ endif()
+
+ # At this point, we know the bindings present but not the MPI version or anything else.
+ if(NOT DEFINED MPI_${LANG}_VERSION)
+ unset(MPI_${LANG}_VERSION_MAJOR)
+ unset(MPI_${LANG}_VERSION_MINOR)
+ endif()
+ set(MPI_BIN_FOLDER ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI)
+
+ # For Fortran, we'll want to use the most modern MPI binding to test capabilities other than the
+ # Fortran parameters, since those depend on the method of consumption.
+ # For C++, we can always use the C bindings, and should do so, since the C++ bindings do not exist in MPI-3
+ # whereas the C bindings do, and the C++ bindings never offered any feature advantage over their C counterparts.
+ if("${LANG}" STREQUAL "Fortran")
+ if(MPI_${LANG}_HAVE_F08_MODULE)
+ set(MPI_${LANG}_HIGHEST_METHOD F08_MODULE)
+ elseif(MPI_${LANG}_HAVE_F90_MODULE)
+ set(MPI_${LANG}_HIGHEST_METHOD F90_MODULE)
+ else()
+ set(MPI_${LANG}_HIGHEST_METHOD F77_HEADER)
+ endif()
- if(MPI_${lang}_FOUND)
- if(NOT TARGET MPI::MPI_${lang})
- add_library(MPI::MPI_${lang} INTERFACE IMPORTED)
+ # Another difference between C and Fortran is that we can't use the preprocessor to determine whether MPI_VERSION
+ # and MPI_SUBVERSION are provided. These defines did not exist in MPI 1.0 and 1.1 and therefore might not
+ # exist. For C/C++, test_mpi.c will handle the MPI_VERSION extraction, but for Fortran, we need mpiver.f90.
+ if(NOT DEFINED MPI_${LANG}_VERSION)
+ _MPI_try_staged_settings(${LANG} mpiver ${MPI_${LANG}_HIGHEST_METHOD} FALSE FALSE)
+ if(MPI_RESULT_${LANG}_mpiver_${MPI_${LANG}_HIGHEST_METHOD})
+ file(STRINGS ${MPI_BIN_FOLDER}/mpiver_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER")
+ if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*")
+ set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}")
+ set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}")
+ set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}")
+ endif()
+ endif()
+ endif()
+
+ # Finally, we want to find out which capabilities a given interface supports, compare the MPI-3 standard.
+ # This is determined by interface specific parameters MPI_SUBARRAYS_SUPPORTED and MPI_ASYNC_PROTECTS_NONBLOCKING
+ # and might vary between the different methods of consumption.
+ if(MPI_DETERMINE_Fortran_CAPABILITIES AND NOT MPI_Fortran_CAPABILITIES_DETERMINED)
+ foreach(mpimethod IN ITEMS F08_MODULE F90_MODULE F77_HEADER)
+ if(MPI_${LANG}_HAVE_${mpimethod})
+ set(MPI_${LANG}_${mpimethod}_SUBARRAYS FALSE)
+ set(MPI_${LANG}_${mpimethod}_ASYNCPROT FALSE)
+ _MPI_try_staged_settings(${LANG} fortranparam_mpi ${mpimethod} TRUE FALSE)
+ if(MPI_RESULT_${LANG}_fortranparam_mpi_${mpimethod} AND
+ NOT "${MPI_RUN_RESULT_${LANG}_fortranparam_mpi_${mpimethod}}" STREQUAL "FAILED_TO_RUN")
+ if("${MPI_RUN_OUTPUT_${LANG}_fortranparam_mpi_${mpimethod}}" MATCHES
+ ".*INFO:SUBARRAYS\\[ *([TF]) *\\]-ASYNCPROT\\[ *([TF]) *\\].*")
+ if("${CMAKE_MATCH_1}" STREQUAL "T")
+ set(MPI_${LANG}_${mpimethod}_SUBARRAYS TRUE)
+ endif()
+ if("${CMAKE_MATCH_2}" STREQUAL "T")
+ set(MPI_${LANG}_${mpimethod}_ASYNCPROT TRUE)
+ endif()
+ endif()
+ endif()
+ endif()
+ endforeach()
+ set(MPI_Fortran_CAPABILITIES_DETERMINED TRUE)
+ endif()
+ else()
+ set(MPI_${LANG}_HIGHEST_METHOD normal)
+
+ # By the MPI-2 standard, MPI_VERSION and MPI_SUBVERSION are valid for both C and C++ bindings.
+ if(NOT DEFINED MPI_${LANG}_VERSION)
+ file(STRINGS ${MPI_BIN_FOLDER}/test_mpi_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER")
+ if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*")
+ set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}")
+ set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}")
+ set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}")
+ endif()
+ endif()
endif()
- if(MPI_${lang}_COMPILE_FLAGS)
- separate_arguments(_MPI_${lang}_COMPILE_OPTIONS NATIVE_COMMAND "${MPI_${lang}_COMPILE_FLAGS}")
- set_property(TARGET MPI::MPI_${lang} PROPERTY
- INTERFACE_COMPILE_OPTIONS "${_MPI_${lang}_COMPILE_OPTIONS}")
+
+ unset(MPI_BIN_FOLDER)
+
+ # At this point, we have dealt with determining the MPI version and parameters for each Fortran method available.
+ # The one remaining issue is to determine which MPI library is installed.
+ # Determining the version and vendor of the MPI library is only possible via MPI_Get_library_version() at runtime,
+ # and therefore we cannot do this while cross-compiling (a user may still define MPI_<lang>_LIBRARY_VERSION_STRING
+ # themselves and we'll attempt splitting it, which is equivalent to provide the try_run output).
+ # It's also worth noting that the installed version string can depend on the language, or on the system the binary
+ # runs on if MPI is not statically linked.
+ if(MPI_DETERMINE_LIBRARY_VERSION AND NOT MPI_${LANG}_LIBRARY_VERSION_STRING)
+ _MPI_try_staged_settings(${LANG} libver_mpi ${MPI_${LANG}_HIGHEST_METHOD} TRUE FALSE)
+ if(MPI_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD} AND
+ "${MPI_RUN_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" EQUAL "0")
+ string(STRIP "${MPI_RUN_OUTPUT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}"
+ MPI_${LANG}_LIBRARY_VERSION_STRING)
+ else()
+ set(MPI_${LANG}_LIBRARY_VERSION_STRING "NOTFOUND")
+ endif()
endif()
+ endif()
- unset(_MPI_${lang}_LINK_LINE)
- if(MPI_${lang}_LINK_FLAGS)
- list(APPEND _MPI_${lang}_LINK_LINE "${MPI_${lang}_LINK_FLAGS}")
+ set(MPI_${LANG}_FIND_QUIETLY ${MPI_FIND_QUIETLY})
+ set(MPI_${LANG}_FIND_VERSION ${MPI_FIND_VERSION})
+ set(MPI_${LANG}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT})
+
+ unset(MPI_${LANG}_REQUIRED_VARS)
+ if (NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
+ foreach(mpilibname IN LISTS MPI_${LANG}_LIB_NAMES)
+ list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpilibname}_LIBRARY")
+ endforeach()
+ list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_LIB_NAMES")
+ if("${LANG}" STREQUAL "Fortran")
+ # For Fortran we only need one of the module or header directories to have *some* support for MPI.
+ if(NOT MPI_${LANG}_MODULE_DIR)
+ list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_F77_HEADER_DIR")
+ endif()
+ if(NOT MPI_${LANG}_F77_HEADER_DIR)
+ list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_MODULE_DIR")
+ endif()
+ else()
+ list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_HEADER_DIR")
+ endif()
+ if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
+ foreach(mpiincvar IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
+ list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpiincvar}_INCLUDE_DIR")
+ endforeach()
+ endif()
+ # Append the works variable now. If the settings did not work, this will show up properly.
+ list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS")
+ else()
+ # If the compiler worked implicitly, use its path as output.
+ # Should the compiler variable be set, we also require it to work.
+ list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_COMPILER")
+ if(MPI_${LANG}_COMPILER)
+ list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS")
endif()
- list(APPEND _MPI_${lang}_LINK_LINE "${MPI_${lang}_LIBRARIES}")
- set_property(TARGET MPI::MPI_${lang} PROPERTY
- INTERFACE_LINK_LIBRARIES "${_MPI_${lang}_LINK_LINE}")
+ endif()
+ find_package_handle_standard_args(MPI_${LANG} REQUIRED_VARS ${MPI_${LANG}_REQUIRED_VARS}
+ VERSION_VAR MPI_${LANG}_VERSION)
- set_property(TARGET MPI::MPI_${lang} PROPERTY
- INTERFACE_INCLUDE_DIRECTORIES "${MPI_${lang}_INCLUDE_PATH}")
+ if(DEFINED MPI_${LANG}_VERSION)
+ if(NOT _MPI_MIN_VERSION OR _MPI_MIN_VERSION VERSION_GREATER MPI_${LANG}_VERSION)
+ set(_MPI_MIN_VERSION MPI_${LANG}_VERSION)
+ endif()
endif()
endif()
endforeach()
+unset(_MPI_REQ_VARS)
+foreach(LANG IN ITEMS C CXX Fortran)
+ if((NOT MPI_FIND_COMPONENTS AND CMAKE_${LANG}_COMPILER_LOADED) OR LANG IN_LIST MPI_FIND_COMPONENTS)
+ list(APPEND _MPI_REQ_VARS "MPI_${LANG}_FOUND")
+ endif()
+endforeach()
+
+if(MPICXX IN_LIST MPI_FIND_COMPONENTS)
+ list(APPEND _MPI_REQ_VARS "MPI_MPICXX_FOUND")
+endif()
+
+find_package_handle_standard_args(MPI
+ REQUIRED_VARS ${_MPI_REQ_VARS}
+ VERSION_VAR ${_MPI_MIN_VERSION}
+ HANDLE_COMPONENTS)
#=============================================================================
# More backward compatibility stuff
-#
-# Bare MPI sans ${lang} vars are set to CXX then C, depending on what was found.
+
+# For compatibility reasons, we also define MPIEXEC
+set(MPIEXEC "${MPIEXEC_EXECUTABLE}")
+
+# Copy over MPI_<LANG>_INCLUDE_PATH from the assembled INCLUDE_DIRS.
+foreach(LANG IN ITEMS C CXX Fortran)
+ if(MPI_${LANG}_FOUND)
+ set(MPI_${LANG}_INCLUDE_PATH "${MPI_${LANG}_INCLUDE_DIRS}")
+ unset(MPI_${LANG}_COMPILE_FLAGS)
+ if(MPI_${LANG}_COMPILE_OPTIONS)
+ list(JOIN MPI_${LANG}_COMPILE_OPTIONS " " MPI_${LANG}_COMPILE_FLAGS)
+ endif()
+ if(MPI_${LANG}_COMPILE_DEFINITIONS)
+ foreach(_MPI_DEF IN LISTS MPI_${LANG}_COMPILE_DEFINITIONS)
+ string(APPEND MPI_${LANG}_COMPILE_FLAGS " -D${_MPI_DEF}")
+ endforeach()
+ endif()
+ endif()
+endforeach()
+
+# Bare MPI sans ${LANG} vars are set to CXX then C, depending on what was found.
# This mimics the behavior of the old language-oblivious FindMPI.
-set(_MPI_OLD_VARS FOUND COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES)
+set(_MPI_OLD_VARS COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES)
if (MPI_CXX_FOUND)
foreach (var ${_MPI_OLD_VARS})
set(MPI_${var} ${MPI_CXX_${var}})
@@ -679,28 +1735,27 @@ elseif (MPI_C_FOUND)
foreach (var ${_MPI_OLD_VARS})
set(MPI_${var} ${MPI_C_${var}})
endforeach()
-else()
- # Note that we might still have found Fortran, but you'll need to use MPI_Fortran_FOUND
- set(MPI_FOUND FALSE)
endif()
# Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and MPI_EXTRA_LIBRARY, and set them in cache.
if (MPI_LIBRARIES)
list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK)
- set(MPI_LIBRARY ${MPI_LIBRARY_WORK} CACHE FILEPATH "MPI library to link against" FORCE)
+ set(MPI_LIBRARY "${MPI_LIBRARY_WORK}")
+ unset(MPI_LIBRARY_WORK)
else()
- set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND" CACHE FILEPATH "MPI library to link against" FORCE)
+ set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND")
endif()
list(LENGTH MPI_LIBRARIES MPI_NUMLIBS)
if (MPI_NUMLIBS GREATER 1)
- set(MPI_EXTRA_LIBRARY_WORK ${MPI_LIBRARIES})
+ set(MPI_EXTRA_LIBRARY_WORK "${MPI_LIBRARIES}")
list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0)
- set(MPI_EXTRA_LIBRARY ${MPI_EXTRA_LIBRARY_WORK} CACHE STRING "Extra MPI libraries to link against" FORCE)
+ set(MPI_EXTRA_LIBRARY "${MPI_EXTRA_LIBRARY_WORK}")
+ unset(MPI_EXTRA_LIBRARY_WORK)
else()
- set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND" CACHE STRING "Extra MPI libraries to link against" FORCE)
+ set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND")
endif()
-mark_as_advanced(MPI_LIBRARY MPI_EXTRA_LIBRARY)
+set(MPI_IGNORE_LEGACY_VARIABLES TRUE)
#=============================================================================
# unset these vars to cleanup namespace
@@ -708,5 +1763,7 @@ unset(_MPI_OLD_VARS)
unset(_MPI_PREFIX_PATH)
unset(_MPI_BASE_DIR)
foreach (lang C CXX Fortran)
- unset(_MPI_${lang}_COMPILER_NAMES)
+ unset(_MPI_${LANG}_COMPILER_NAMES)
endforeach()
+
+cmake_policy(POP)
diff --git a/Modules/FindMPI/fortranparam_mpi.f90.in b/Modules/FindMPI/fortranparam_mpi.f90.in
new file mode 100644
index 000000000..30f912c62
--- /dev/null
+++ b/Modules/FindMPI/fortranparam_mpi.f90.in
@@ -0,0 +1,4 @@
+ program mpi_ver
+ @MPI_Fortran_INCLUDE_LINE@
+ print *, 'INFO:SUBARRAYS[', MPI_SUBARRAYS_SUPPORTED, ']-ASYNCPROT[', MPI_ASYNC_PROTECTS_NONBLOCKING, ']'
+ end program mpi_ver
diff --git a/Modules/FindMPI/libver_mpi.c b/Modules/FindMPI/libver_mpi.c
new file mode 100644
index 000000000..d89328a01
--- /dev/null
+++ b/Modules/FindMPI/libver_mpi.c
@@ -0,0 +1,20 @@
+#include <mpi.h>
+
+#ifdef __cplusplus
+# include <cstdio>
+#else
+# include <stdio.h>
+#endif
+
+int main(int argc, char* argv[])
+{
+ char mpilibver_str[MPI_MAX_LIBRARY_VERSION_STRING];
+ int mpilibver_len;
+ MPI_Get_library_version(mpilibver_str, &mpilibver_len);
+#ifdef __cplusplus
+ std::puts(mpilibver_str);
+#else
+ puts(mpilibver_str);
+#endif
+ return 0;
+}
diff --git a/Modules/FindMPI/libver_mpi.f90.in b/Modules/FindMPI/libver_mpi.f90.in
new file mode 100644
index 000000000..793858716
--- /dev/null
+++ b/Modules/FindMPI/libver_mpi.f90.in
@@ -0,0 +1,7 @@
+ program mpi_ver
+ @MPI_Fortran_INCLUDE_LINE@
+ character(len=MPI_MAX_LIBRARY_VERSION_STRING) :: mpilibver_str
+ integer(kind=MPI_INTEGER_KIND) :: ierror, reslen
+ call MPI_GET_LIBRARY_VERSION(mpilibver_str, reslen, ierror)
+ print *, mpilibver_str
+ end program mpi_ver
diff --git a/Modules/FindMPI/mpiver.f90.in b/Modules/FindMPI/mpiver.f90.in
new file mode 100644
index 000000000..a25452385
--- /dev/null
+++ b/Modules/FindMPI/mpiver.f90.in
@@ -0,0 +1,10 @@
+ program mpi_ver
+ @MPI_Fortran_INCLUDE_LINE@
+ integer(kind=kind(MPI_VERSION)), parameter :: zero = ichar('0')
+ character, dimension(17), parameter :: mpiver_str =&
+ (/ 'I', 'N', 'F', 'O', ':', 'M', 'P', 'I', '-', 'V', 'E', 'R', '[', &
+ char(zero + MPI_VERSION), &
+ '.', &
+ char(zero + MPI_SUBVERSION), ']' /)
+ print *, mpiver_str
+ end program mpi_ver
diff --git a/Modules/FindMPI/test_mpi.c b/Modules/FindMPI/test_mpi.c
new file mode 100644
index 000000000..7c96d54a8
--- /dev/null
+++ b/Modules/FindMPI/test_mpi.c
@@ -0,0 +1,38 @@
+#include <mpi.h>
+
+#ifdef __cplusplus
+# include <cstdio>
+#else
+# include <stdio.h>
+#endif
+
+#if defined(MPI_VERSION) && defined(MPI_SUBVERSION)
+const char mpiver_str[] = { 'I', 'N',
+ 'F', 'O',
+ ':', 'M',
+ 'P', 'I',
+ '-', 'V',
+ 'E', 'R',
+ '[', ('0' + MPI_VERSION),
+ '.', ('0' + MPI_SUBVERSION),
+ ']', '\0' };
+#endif
+
+int main(int argc, char* argv[])
+{
+#if defined(MPI_VERSION) && defined(MPI_SUBVERSION)
+# ifdef __cplusplus
+ std::puts(mpiver_str);
+# else
+ puts(mpiver_str);
+# endif
+#endif
+#ifdef TEST_MPI_MPICXX
+ MPI::MPI_Init(&argc, &argv);
+ MPI::MPI_Finalize();
+#else
+ MPI_Init(&argc, &argv);
+ MPI_Finalize();
+#endif
+ return 0;
+}
diff --git a/Modules/FindMPI/test_mpi.f90.in b/Modules/FindMPI/test_mpi.f90.in
new file mode 100644
index 000000000..4d43a04d6
--- /dev/null
+++ b/Modules/FindMPI/test_mpi.f90.in
@@ -0,0 +1,6 @@
+ program hello
+ @MPI_Fortran_INCLUDE_LINE@
+ integer@MPI_Fortran_INTEGER_LINE@ ierror
+ call MPI_INIT(ierror)
+ call MPI_FINALIZE(ierror)
+ end program
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 80bcda36b..92ee729e0 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -1,219 +1,235 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindMatlab
-# ----------
-#
-# Finds Matlab installations and provides Matlab tools and libraries to cmake.
-#
-# This package first intention is to find the libraries associated with Matlab
-# in order to be able to build Matlab extensions (mex files). It can also be
-# used:
-#
-# * run specific commands in Matlab
-# * declare Matlab unit test
-# * retrieve various information from Matlab (mex extensions, versions and
-# release queries, ...)
-#
-# The module supports the following components:
-#
-# * ``MX_LIBRARY``, ``ENG_LIBRARY`` and ``MAT_LIBRARY``: respectively the MX,
-# ENG and MAT libraries of Matlab
-# * ``MAIN_PROGRAM`` the Matlab binary program.
-# * ``MEX_COMPILER`` the MEX compiler.
-# * ``SIMULINK`` the Simulink environment.
-#
-# .. note::
-#
-# The version given to the :command:`find_package` directive is the Matlab
-# **version**, which should not be confused with the Matlab *release* name
-# (eg. `R2014`).
-# The :command:`matlab_get_version_from_release_name` and
-# :command:`matlab_get_release_name_from_version` allow a mapping
-# from the release name to the version.
-#
-# The variable :variable:`Matlab_ROOT_DIR` may be specified in order to give
-# the path of the desired Matlab version. Otherwise, the behaviour is platform
-# specific:
-#
-# * Windows: The installed versions of Matlab are retrieved from the
-# Windows registry
-# * OS X: The installed versions of Matlab are given by the MATLAB
-# paths in ``/Application``. If no such application is found, it falls back
-# to the one that might be accessible from the PATH.
-# * Unix: The desired Matlab should be accessible from the PATH.
-#
-# Additional information is provided when :variable:`MATLAB_FIND_DEBUG` is set.
-# When a Matlab binary is found automatically and the ``MATLAB_VERSION``
-# is not given, the version is queried from Matlab directly.
-# On Windows, it can make a window running Matlab appear.
-#
-# The mapping of the release names and the version of Matlab is performed by
-# defining pairs (name, version). The variable
-# :variable:`MATLAB_ADDITIONAL_VERSIONS` may be provided before the call to
-# the :command:`find_package` in order to handle additional versions.
-#
-# A Matlab scripts can be added to the set of tests using the
-# :command:`matlab_add_unit_test`. By default, the Matlab unit test framework
-# will be used (>= 2013a) to run this script, but regular ``.m`` files
-# returning an exit code can be used as well (0 indicating a success).
-#
-# Module Input Variables
-# ^^^^^^^^^^^^^^^^^^^^^^
-#
-# Users or projects may set the following variables to configure the module
-# behaviour:
-#
-# :variable:`Matlab_ROOT_DIR`
-# the root of the Matlab installation.
-# :variable:`MATLAB_FIND_DEBUG`
-# outputs debug information
-# :variable:`MATLAB_ADDITIONAL_VERSIONS`
-# additional versions of Matlab for the automatic retrieval of the installed
-# versions.
-#
-# Variables defined by the module
-# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-#
-# Result variables
-# """"""""""""""""
-#
-# ``Matlab_FOUND``
-# ``TRUE`` if the Matlab installation is found, ``FALSE``
-# otherwise. All variable below are defined if Matlab is found.
-# ``Matlab_ROOT_DIR``
-# the final root of the Matlab installation determined by the FindMatlab
-# module.
-# ``Matlab_MAIN_PROGRAM``
-# the Matlab binary program. Available only if the component ``MAIN_PROGRAM``
-# is given in the :command:`find_package` directive.
-# ``Matlab_INCLUDE_DIRS``
-# the path of the Matlab libraries headers
-# ``Matlab_MEX_LIBRARY``
-# library for mex, always available.
-# ``Matlab_MX_LIBRARY``
-# mx library of Matlab (arrays). Available only if the component
-# ``MX_LIBRARY`` has been requested.
-# ``Matlab_ENG_LIBRARY``
-# Matlab engine library. Available only if the component ``ENG_LIBRARY``
-# is requested.
-# ``Matlab_MAT_LIBRARY``
-# Matlab matrix library. Available only if the component ``MAT_LIBRARY``
-# is requested.
-# ``Matlab_LIBRARIES``
-# the whole set of libraries of Matlab
-# ``Matlab_MEX_COMPILER``
-# the mex compiler of Matlab. Currently not used.
-# Available only if the component ``MEX_COMPILER`` is asked
-#
-# Cached variables
-# """"""""""""""""
-#
-# ``Matlab_MEX_EXTENSION``
-# the extension of the mex files for the current platform (given by Matlab).
-# ``Matlab_ROOT_DIR``
-# the location of the root of the Matlab installation found. If this value
-# is changed by the user, the result variables are recomputed.
-#
-# Provided macros
-# ^^^^^^^^^^^^^^^
-#
-# :command:`matlab_get_version_from_release_name`
-# returns the version from the release name
-# :command:`matlab_get_release_name_from_version`
-# returns the release name from the Matlab version
-#
-# Provided functions
-# ^^^^^^^^^^^^^^^^^^
-#
-# :command:`matlab_add_mex`
-# adds a target compiling a MEX file.
-# :command:`matlab_add_unit_test`
-# adds a Matlab unit test file as a test to the project.
-# :command:`matlab_extract_all_installed_versions_from_registry`
-# parses the registry for all Matlab versions. Available on Windows only.
-# The part of the registry parsed is dependent on the host processor
-# :command:`matlab_get_all_valid_matlab_roots_from_registry`
-# returns all the possible Matlab paths, according to a previously
-# given list. Only the existing/accessible paths are kept. This is mainly
-# useful for the searching all possible Matlab installation.
-# :command:`matlab_get_mex_suffix`
-# returns the suffix to be used for the mex files
-# (platform/architecture dependent)
-# :command:`matlab_get_version_from_matlab_run`
-# returns the version of Matlab, given the full directory of the Matlab
-# program.
-#
-#
-# Known issues
-# ^^^^^^^^^^^^
-#
-# **Symbol clash in a MEX target**
-# By default, every symbols inside a MEX
-# file defined with the command :command:`matlab_add_mex` have hidden
-# visibility, except for the entry point. This is the default behaviour of
-# the MEX compiler, which lowers the risk of symbol collision between the
-# libraries shipped with Matlab, and the libraries to which the MEX file is
-# linking to. This is also the default on Windows platforms.
-#
-# However, this is not sufficient in certain case, where for instance your
-# MEX file is linking against libraries that are already loaded by Matlab,
-# even if those libraries have different SONAMES.
-# A possible solution is to hide the symbols of the libraries to which the
-# MEX target is linking to. This can be achieved in GNU GCC compilers with
-# the linker option ``-Wl,--exclude-libs,ALL``.
-#
-# **Tests using GPU resources**
-# in case your MEX file is using the GPU and
-# in order to be able to run unit tests on this MEX file, the GPU resources
-# should be properly released by Matlab. A possible solution is to make
-# Matlab aware of the use of the GPU resources in the session, which can be
-# performed by a command such as ``D = gpuDevice()`` at the beginning of
-# the test script (or via a fixture).
-#
-#
-# Reference
-# ^^^^^^^^^
-#
-# .. variable:: Matlab_ROOT_DIR
-#
-# The root folder of the Matlab installation. If set before the call to
-# :command:`find_package`, the module will look for the components in that
-# path. If not set, then an automatic search of Matlab
-# will be performed. If set, it should point to a valid version of Matlab.
-#
-# .. variable:: MATLAB_FIND_DEBUG
-#
-# If set, the lookup of Matlab and the intermediate configuration steps are
-# outputted to the console.
-#
-# .. variable:: MATLAB_ADDITIONAL_VERSIONS
-#
-# If set, specifies additional versions of Matlab that may be looked for.
-# The variable should be a list of strings, organised by pairs of release
-# name and versions, such as follows::
-#
-# set(MATLAB_ADDITIONAL_VERSIONS
-# "release_name1=corresponding_version1"
-# "release_name2=corresponding_version2"
-# ...
-# )
-#
-# Example::
-#
-# set(MATLAB_ADDITIONAL_VERSIONS
-# "R2013b=8.2"
-# "R2013a=8.1"
-# "R2012b=8.0")
-#
-# The order of entries in this list matters when several versions of
-# Matlab are installed. The priority is set according to the ordering in
-# this list.
+#[=======================================================================[.rst:
+FindMatlab
+----------
+
+Finds Matlab or Matlab Compiler Runtime (MCR) and provides Matlab tools,
+libraries and compilers to CMake.
+
+This package primary purpose is to find the libraries associated with Matlab
+or the MCR in order to be able to build Matlab extensions (mex files). It
+can also be used:
+
+* to run specific commands in Matlab in case Matlab is available
+* for declaring Matlab unit test
+* to retrieve various information from Matlab (mex extensions, versions and
+ release queries, ...)
+
+The module supports the following components:
+
+* ``ENG_LIBRARY`` and ``MAT_LIBRARY``: respectively the ``ENG`` and ``MAT``
+ libraries of Matlab
+* ``MAIN_PROGRAM`` the Matlab binary program. Note that this component is not
+ available on the MCR version, and will yield an error if the MCR is found
+ instead of the regular Matlab installation.
+* ``MEX_COMPILER`` the MEX compiler.
+* ``MCC_COMPILER`` the MCC compiler, included with the Matlab Compiler add-on.
+* ``SIMULINK`` the Simulink environment.
+
+.. note::
+
+ The version given to the :command:`find_package` directive is the Matlab
+ **version**, which should not be confused with the Matlab *release* name
+ (eg. `R2014`).
+ The :command:`matlab_get_version_from_release_name` and
+ :command:`matlab_get_release_name_from_version` provide a mapping
+ between the release name and the version.
+
+The variable :variable:`Matlab_ROOT_DIR` may be specified in order to give
+the path of the desired Matlab version. Otherwise, the behaviour is platform
+specific:
+
+* Windows: The installed versions of Matlab/MCR are retrieved from the
+ Windows registry
+* OS X: The installed versions of Matlab/MCR are given by the MATLAB
+ default installation paths in ``/Application``. If no such application is
+ found, it falls back to the one that might be accessible from the ``PATH``.
+* Unix: The desired Matlab should be accessible from the ``PATH``. This does
+ not work for MCR installation and :variable:`Matlab_ROOT_DIR` should be
+ specified on this platform.
+
+Additional information is provided when :variable:`MATLAB_FIND_DEBUG` is set.
+When a Matlab/MCR installation is found automatically and the ``MATLAB_VERSION``
+is not given, the version is queried from Matlab directly (on Windows this
+may pop up a Matlab window) or from the MCR installation.
+
+The mapping of the release names and the version of Matlab is performed by
+defining pairs (name, version). The variable
+:variable:`MATLAB_ADDITIONAL_VERSIONS` may be provided before the call to
+the :command:`find_package` in order to handle additional versions.
+
+A Matlab scripts can be added to the set of tests using the
+:command:`matlab_add_unit_test`. By default, the Matlab unit test framework
+will be used (>= 2013a) to run this script, but regular ``.m`` files
+returning an exit code can be used as well (0 indicating a success).
+
+Module Input Variables
+^^^^^^^^^^^^^^^^^^^^^^
+
+Users or projects may set the following variables to configure the module
+behaviour:
+
+:variable:`Matlab_ROOT_DIR`
+ the root of the Matlab installation.
+:variable:`MATLAB_FIND_DEBUG`
+ outputs debug information
+:variable:`MATLAB_ADDITIONAL_VERSIONS`
+ additional versions of Matlab for the automatic retrieval of the installed
+ versions.
+
+Variables defined by the module
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Result variables
+""""""""""""""""
+
+``Matlab_FOUND``
+ ``TRUE`` if the Matlab installation is found, ``FALSE``
+ otherwise. All variable below are defined if Matlab is found.
+``Matlab_ROOT_DIR``
+ the final root of the Matlab installation determined by the FindMatlab
+ module.
+``Matlab_MAIN_PROGRAM``
+ the Matlab binary program. Available only if the component ``MAIN_PROGRAM``
+ is given in the :command:`find_package` directive.
+``Matlab_INCLUDE_DIRS``
+ the path of the Matlab libraries headers
+``Matlab_MEX_LIBRARY``
+ library for mex, always available.
+``Matlab_MX_LIBRARY``
+ mx library of Matlab (arrays), always available.
+``Matlab_ENG_LIBRARY``
+ Matlab engine library. Available only if the component ``ENG_LIBRARY``
+ is requested.
+``Matlab_MAT_LIBRARY``
+ Matlab matrix library. Available only if the component ``MAT_LIBRARY``
+ is requested.
+``Matlab_ENGINE_LIBRARY``
+ Matlab C++ engine library, always available for R2018a and newer.
+``Matlab_DATAARRAY_LIBRARY``
+ Matlab C++ data array library, always available for R2018a and newer.
+``Matlab_LIBRARIES``
+ the whole set of libraries of Matlab
+``Matlab_MEX_COMPILER``
+ the mex compiler of Matlab. Currently not used.
+ Available only if the component ``MEX_COMPILER`` is requested.
+``Matlab_MCC_COMPILER``
+ the mcc compiler of Matlab. Included with the Matlab Compiler add-on.
+ Available only if the component ``MCC_COMPILER`` is requested.
+
+Cached variables
+""""""""""""""""
+
+``Matlab_MEX_EXTENSION``
+ the extension of the mex files for the current platform (given by Matlab).
+``Matlab_ROOT_DIR``
+ the location of the root of the Matlab installation found. If this value
+ is changed by the user, the result variables are recomputed.
+
+Provided macros
+^^^^^^^^^^^^^^^
+
+:command:`matlab_get_version_from_release_name`
+ returns the version from the release name
+:command:`matlab_get_release_name_from_version`
+ returns the release name from the Matlab version
+
+Provided functions
+^^^^^^^^^^^^^^^^^^
+
+:command:`matlab_add_mex`
+ adds a target compiling a MEX file.
+:command:`matlab_add_unit_test`
+ adds a Matlab unit test file as a test to the project.
+:command:`matlab_extract_all_installed_versions_from_registry`
+ parses the registry for all Matlab versions. Available on Windows only.
+ The part of the registry parsed is dependent on the host processor
+:command:`matlab_get_all_valid_matlab_roots_from_registry`
+ returns all the possible Matlab or MCR paths, according to a previously
+ given list. Only the existing/accessible paths are kept. This is mainly
+ useful for the searching all possible Matlab installation.
+:command:`matlab_get_mex_suffix`
+ returns the suffix to be used for the mex files
+ (platform/architecture dependent)
+:command:`matlab_get_version_from_matlab_run`
+ returns the version of Matlab/MCR, given the full directory of the Matlab/MCR
+ installation path.
+
+
+Known issues
+^^^^^^^^^^^^
+
+**Symbol clash in a MEX target**
+ By default, every symbols inside a MEX
+ file defined with the command :command:`matlab_add_mex` have hidden
+ visibility, except for the entry point. This is the default behaviour of
+ the MEX compiler, which lowers the risk of symbol collision between the
+ libraries shipped with Matlab, and the libraries to which the MEX file is
+ linking to. This is also the default on Windows platforms.
+
+ However, this is not sufficient in certain case, where for instance your
+ MEX file is linking against libraries that are already loaded by Matlab,
+ even if those libraries have different SONAMES.
+ A possible solution is to hide the symbols of the libraries to which the
+ MEX target is linking to. This can be achieved in GNU GCC compilers with
+ the linker option ``-Wl,--exclude-libs,ALL``.
+
+**Tests using GPU resources**
+ in case your MEX file is using the GPU and
+ in order to be able to run unit tests on this MEX file, the GPU resources
+ should be properly released by Matlab. A possible solution is to make
+ Matlab aware of the use of the GPU resources in the session, which can be
+ performed by a command such as ``D = gpuDevice()`` at the beginning of
+ the test script (or via a fixture).
+
+
+Reference
+^^^^^^^^^
+
+.. variable:: Matlab_ROOT_DIR
+
+ The root folder of the Matlab installation. If set before the call to
+ :command:`find_package`, the module will look for the components in that
+ path. If not set, then an automatic search of Matlab
+ will be performed. If set, it should point to a valid version of Matlab.
+
+.. variable:: MATLAB_FIND_DEBUG
+
+ If set, the lookup of Matlab and the intermediate configuration steps are
+ outputted to the console.
+
+.. variable:: MATLAB_ADDITIONAL_VERSIONS
+
+ If set, specifies additional versions of Matlab that may be looked for.
+ The variable should be a list of strings, organised by pairs of release
+ name and versions, such as follows::
+
+ set(MATLAB_ADDITIONAL_VERSIONS
+ "release_name1=corresponding_version1"
+ "release_name2=corresponding_version2"
+ ...
+ )
+
+ Example::
+
+ set(MATLAB_ADDITIONAL_VERSIONS
+ "R2013b=8.2"
+ "R2013a=8.1"
+ "R2012b=8.0")
+
+ The order of entries in this list matters when several versions of
+ Matlab are installed. The priority is set according to the ordering in
+ this list.
+#]=======================================================================]
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
set(_FindMatlab_SELF_DIR "${CMAKE_CURRENT_LIST_DIR}")
-include(FindPackageHandleStandardArgs)
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
include(CheckCXXCompilerFlag)
include(CheckCCompilerFlag)
@@ -225,6 +241,11 @@ if(NOT MATLAB_ADDITIONAL_VERSIONS)
endif()
set(MATLAB_VERSIONS_MAPPING
+ "R2019b=9.7"
+ "R2019a=9.6"
+ "R2018b=9.5"
+ "R2018a=9.4"
+ "R2017b=9.3"
"R2017a=9.2"
"R2016b=9.1"
"R2016a=9.0"
@@ -236,7 +257,6 @@ set(MATLAB_VERSIONS_MAPPING
"R2013a=8.1"
"R2012b=8.0"
"R2012a=7.14"
-
"R2011b=7.13"
"R2011a=7.12"
"R2010b=7.11"
@@ -252,11 +272,12 @@ if(NOT EXISTS "${_matlab_temporary_folder}")
file(MAKE_DIRECTORY "${_matlab_temporary_folder}")
endif()
-#.rst:
-# .. command:: matlab_get_version_from_release_name
-#
-# Returns the version of Matlab (17.58) from a release name (R2017k)
-macro (matlab_get_version_from_release_name release_name version_name)
+#[=======================================================================[.rst:
+.. command:: matlab_get_version_from_release_name
+
+ Returns the version of Matlab (17.58) from a release name (R2017k)
+#]=======================================================================]
+macro(matlab_get_version_from_release_name release_name version_name)
string(REGEX MATCHALL "${release_name}=([0-9]+\\.?[0-9]*)" _matched ${MATLAB_VERSIONS_MAPPING})
@@ -264,7 +285,7 @@ macro (matlab_get_version_from_release_name release_name version_name)
if(NOT _matched STREQUAL "")
set(${version_name} ${CMAKE_MATCH_1})
else()
- message(WARNING "The release name ${release_name} is not registered")
+ message(WARNING "[MATLAB] The release name ${release_name} is not registered")
endif()
unset(_matched)
@@ -274,11 +295,12 @@ endmacro()
-#.rst:
-# .. command:: matlab_get_release_name_from_version
-#
-# Returns the release name (R2017k) from the version of Matlab (17.58)
-macro (matlab_get_release_name_from_version version release_name)
+#[=======================================================================[.rst:
+.. command:: matlab_get_release_name_from_version
+
+ Returns the release name (R2017k) from the version of Matlab (17.58)
+#]=======================================================================]
+macro(matlab_get_release_name_from_version version release_name)
set(${release_name} "")
foreach(_var IN LISTS MATLAB_VERSIONS_MAPPING)
@@ -292,7 +314,7 @@ macro (matlab_get_release_name_from_version version release_name)
unset(_var)
unset(_matched)
if(${release_name} STREQUAL "")
- message(WARNING "The version ${version} is not registered")
+ message(WARNING "[MATLAB] The version ${version} is not registered")
endif()
endmacro()
@@ -334,69 +356,74 @@ macro(matlab_get_supported_versions list_versions)
endmacro()
-#.rst:
-# .. command:: matlab_extract_all_installed_versions_from_registry
-#
-# This function parses the registry and founds the Matlab versions that are
-# installed. The found versions are returned in `matlab_versions`.
-# Set `win64` to `TRUE` if the 64 bit version of Matlab should be looked for
-# The returned list contains all versions under
-# ``HKLM\\SOFTWARE\\Mathworks\\MATLAB`` or an empty list in case an error
-# occurred (or nothing found).
-#
-# .. note::
-#
-# Only the versions are provided. No check is made over the existence of the
-# installation referenced in the registry,
-#
+#[=======================================================================[.rst:
+.. command:: matlab_extract_all_installed_versions_from_registry
+
+ This function parses the registry and founds the Matlab versions that are
+ installed. The found versions are returned in `matlab_versions`.
+ Set `win64` to `TRUE` if the 64 bit version of Matlab should be looked for
+ The returned list contains all versions under
+ ``HKLM\\SOFTWARE\\Mathworks\\MATLAB`` and
+ ``HKLM\\SOFTWARE\\Mathworks\\MATLAB Runtime`` or an empty list in case an
+ error occurred (or nothing found).
+
+ .. note::
+
+ Only the versions are provided. No check is made over the existence of the
+ installation referenced in the registry,
+
+#]=======================================================================]
function(matlab_extract_all_installed_versions_from_registry win64 matlab_versions)
if(NOT CMAKE_HOST_WIN32)
- message(FATAL_ERROR "This macro can only be called by a windows host (call to reg.exe")
+ message(FATAL_ERROR "[MATLAB] This macro can only be called by a windows host (call to reg.exe)")
endif()
-
- if(${win64} AND ${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "64")
+ if(${win64} AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "64")
set(APPEND_REG "/reg:64")
else()
set(APPEND_REG "/reg:32")
endif()
- # /reg:64 should be added on 64 bits capable OSs in order to enable the
- # redirection of 64 bits applications
- execute_process(
- COMMAND reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Mathworks\\MATLAB /f * /k ${APPEND_REG}
- RESULT_VARIABLE resultMatlab
- OUTPUT_VARIABLE varMatlab
- ERROR_VARIABLE errMatlab
- INPUT_FILE NUL
- )
+ set(matlabs_from_registry)
+ foreach(_installation_type IN ITEMS "MATLAB" "MATLAB Runtime")
- set(matlabs_from_registry)
- if(${resultMatlab} EQUAL 0)
+ # /reg:64 should be added on 64 bits capable OSs in order to enable the
+ # redirection of 64 bits applications
+ execute_process(
+ COMMAND reg query HKEY_LOCAL_MACHINE\\SOFTWARE\\Mathworks\\${_installation_type} /f * /k ${APPEND_REG}
+ RESULT_VARIABLE resultMatlab
+ OUTPUT_VARIABLE varMatlab
+ ERROR_VARIABLE errMatlab
+ INPUT_FILE NUL
+ )
- string(
- REGEX MATCHALL "MATLAB\\\\([0-9]+(\\.[0-9]+)?)"
- matlab_versions_regex ${varMatlab})
- foreach(match IN LISTS matlab_versions_regex)
- string(
- REGEX MATCH "MATLAB\\\\(([0-9]+)(\\.([0-9]+))?)"
- current_match ${match})
+ if(resultMatlab EQUAL 0)
- set(_matlab_current_version ${CMAKE_MATCH_1})
- set(current_matlab_version_major ${CMAKE_MATCH_2})
- set(current_matlab_version_minor ${CMAKE_MATCH_4})
- if(NOT current_matlab_version_minor)
- set(current_matlab_version_minor "0")
- endif()
+ string(
+ REGEX MATCHALL "MATLAB\\\\([0-9]+(\\.[0-9]+)?)"
+ matlab_versions_regex ${varMatlab})
+
+ foreach(match IN LISTS matlab_versions_regex)
+ string(
+ REGEX MATCH "MATLAB\\\\(([0-9]+)(\\.([0-9]+))?)"
+ current_match ${match})
+
+ set(_matlab_current_version ${CMAKE_MATCH_1})
+ set(current_matlab_version_major ${CMAKE_MATCH_2})
+ set(current_matlab_version_minor ${CMAKE_MATCH_4})
+ if(NOT current_matlab_version_minor)
+ set(current_matlab_version_minor "0")
+ endif()
- list(APPEND matlabs_from_registry ${_matlab_current_version})
- unset(_matlab_current_version)
- endforeach(match)
+ list(APPEND matlabs_from_registry ${_matlab_current_version})
+ unset(_matlab_current_version)
+ endforeach()
- endif()
+ endif()
+ endforeach()
if(matlabs_from_registry)
list(REMOVE_DUPLICATES matlabs_from_registry)
@@ -441,7 +468,6 @@ macro(extract_matlab_versions_from_registry_brute_force matlab_versions)
# list(APPEND matlab_supported_versions MATLAB_ADDITIONAL_VERSIONS)
# endif()
-
# we order from more recent to older
if(matlab_supported_versions)
list(REMOVE_DUPLICATES matlab_supported_versions)
@@ -449,40 +475,40 @@ macro(extract_matlab_versions_from_registry_brute_force matlab_versions)
list(REVERSE matlab_supported_versions)
endif()
-
set(${matlab_versions} ${matlab_supported_versions})
+endmacro()
-endmacro()
+#[=======================================================================[.rst:
+.. command:: matlab_get_all_valid_matlab_roots_from_registry
+
+ Populates the Matlab root with valid versions of Matlab or
+ Matlab Runtime (MCR).
+ The returned matlab_roots is organized in triplets
+ ``(type,version_number,matlab_root_path)``, where ``type``
+ indicates either ``MATLAB`` or ``MCR``.
+
+ ::
+ matlab_get_all_valid_matlab_roots_from_registry(
+ matlab_versions
+ matlab_roots)
-#.rst:
-# .. command:: matlab_get_all_valid_matlab_roots_from_registry
-#
-# Populates the Matlab root with valid versions of Matlab.
-# The returned matlab_roots is organized in pairs
-# ``(version_number,matlab_root_path)``.
-#
-# ::
-#
-# matlab_get_all_valid_matlab_roots_from_registry(
-# matlab_versions
-# matlab_roots)
-#
-# ``matlab_versions``
-# the versions of each of the Matlab installations
-# ``matlab_roots``
-# the location of each of the Matlab installations
+ ``matlab_versions``
+ the versions of each of the Matlab or MCR installations
+ ``matlab_roots``
+ the location of each of the Matlab or MCR installations
+#]=======================================================================]
function(matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_roots)
# The matlab_versions comes either from
# extract_matlab_versions_from_registry_brute_force or
# matlab_extract_all_installed_versions_from_registry.
-
set(_matlab_roots_list )
+ # check for Matlab installations
foreach(_matlab_current_version ${matlab_versions})
get_filename_component(
current_MATLAB_ROOT
@@ -490,32 +516,47 @@ function(matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_
ABSOLUTE)
if(EXISTS ${current_MATLAB_ROOT})
- list(APPEND _matlab_roots_list ${_matlab_current_version} ${current_MATLAB_ROOT})
+ list(APPEND _matlab_roots_list "MATLAB" ${_matlab_current_version} ${current_MATLAB_ROOT})
+ endif()
+
+ endforeach()
+
+ # Check for MCR installations
+ foreach(_matlab_current_version ${matlab_versions})
+ get_filename_component(
+ current_MATLAB_ROOT
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB Runtime\\${_matlab_current_version};MATLABROOT]"
+ ABSOLUTE)
+
+ # remove the dot
+ string(REPLACE "." "" _matlab_current_version_without_dot "${_matlab_current_version}")
+
+ if(EXISTS ${current_MATLAB_ROOT})
+ list(APPEND _matlab_roots_list "MCR" ${_matlab_current_version} "${current_MATLAB_ROOT}/v${_matlab_current_version_without_dot}")
endif()
- endforeach(_matlab_current_version)
- unset(_matlab_current_version)
+ endforeach()
set(${matlab_roots} ${_matlab_roots_list} PARENT_SCOPE)
- unset(_matlab_roots_list)
endfunction()
-#.rst:
-# .. command:: matlab_get_mex_suffix
-#
-# Returns the extension of the mex files (the suffixes).
-# This function should not be called before the appropriate Matlab root has
-# been found.
-#
-# ::
-#
-# matlab_get_mex_suffix(
-# matlab_root
-# mex_suffix)
-#
-# ``matlab_root``
-# the root of the Matlab installation
-# ``mex_suffix``
-# the variable name in which the suffix will be returned.
+#[=======================================================================[.rst:
+.. command:: matlab_get_mex_suffix
+
+ Returns the extension of the mex files (the suffixes).
+ This function should not be called before the appropriate Matlab root has
+ been found.
+
+ ::
+
+ matlab_get_mex_suffix(
+ matlab_root
+ mex_suffix)
+
+ ``matlab_root``
+ the root of the Matlab/MCR installation
+ ``mex_suffix``
+ the variable name in which the suffix will be returned.
+#]=======================================================================]
function(matlab_get_mex_suffix matlab_root mex_suffix)
# todo setup the extension properly. Currently I do not know if this is
@@ -548,7 +589,9 @@ function(matlab_get_mex_suffix matlab_root mex_suffix)
)
endif()
endforeach(current_mexext_suffix)
-
+ if(MATLAB_FIND_DEBUG)
+ message(STATUS "[MATLAB] Determining mex files extensions from '${matlab_root}/bin' with program '${Matlab_MEXEXTENSIONS_PROG}'")
+ endif()
# the program has been found?
if((NOT Matlab_MEXEXTENSIONS_PROG) OR (NOT EXISTS ${Matlab_MEXEXTENSIONS_PROG}))
@@ -568,12 +611,39 @@ function(matlab_get_mex_suffix matlab_root mex_suffix)
set(devnull INPUT_FILE NUL)
endif()
+ if(WIN32)
+ # this environment variable is used to determine the arch on Windows
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(ENV{MATLAB_ARCH} "win64")
+ else()
+ set(ENV{MATLAB_ARCH} "win32")
+ endif()
+ endif()
+
+ # this is the preferred way. If this does not work properly (eg. MCR on Windows), then we use our own knowledge
execute_process(
COMMAND ${Matlab_MEXEXTENSIONS_PROG}
OUTPUT_VARIABLE _matlab_mex_extension
ERROR_VARIABLE _matlab_mex_extension_error
+ OUTPUT_STRIP_TRAILING_WHITESPACE
${devnull})
- string(STRIP ${_matlab_mex_extension} _matlab_mex_extension)
+ unset(ENV{MATLAB_ARCH})
+
+ if(_matlab_mex_extension_error)
+ if(WIN32)
+ # this is only for intel architecture
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(_matlab_mex_extension "mexw64")
+ else()
+ set(_matlab_mex_extension "mexw32")
+ endif()
+ endif()
+ endif()
+
+ string(STRIP "${_matlab_mex_extension}" _matlab_mex_extension)
+ if(MATLAB_FIND_DEBUG)
+ message(STATUS "[MATLAB] '${Matlab_MEXEXTENSIONS_PROG}' : determined extension '${_matlab_mex_extension}' and error string is '${_matlab_mex_extension_error}'")
+ endif()
unset(Matlab_MEXEXTENSIONS_PROG CACHE)
set(${mex_suffix} ${_matlab_mex_extension} PARENT_SCOPE)
@@ -582,27 +652,28 @@ endfunction()
-#.rst:
-# .. command:: matlab_get_version_from_matlab_run
-#
-# This function runs Matlab program specified on arguments and extracts its
-# version.
-#
-# ::
-#
-# matlab_get_version_from_matlab_run(
-# matlab_binary_path
-# matlab_list_versions)
-#
-# ``matlab_binary_path``
-# the location of the `matlab` binary executable
-# ``matlab_list_versions``
-# the version extracted from Matlab
+#[=======================================================================[.rst:
+.. command:: matlab_get_version_from_matlab_run
+
+ This function runs Matlab program specified on arguments and extracts its
+ version. If the path provided for the Matlab installation points to an MCR
+ installation, the version is extracted from the installed files.
+
+ ::
+
+ matlab_get_version_from_matlab_run(
+ matlab_binary_path
+ matlab_list_versions)
+
+ ``matlab_binary_path``
+ the location of the `matlab` binary executable
+ ``matlab_list_versions``
+ the version extracted from Matlab
+#]=======================================================================]
function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_versions)
set(${matlab_list_versions} "" PARENT_SCOPE)
-
if(MATLAB_FIND_DEBUG)
message(STATUS "[MATLAB] Determining the version of Matlab from ${matlab_binary_program}")
endif()
@@ -644,7 +715,7 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve
${devnull}
)
- if("${_matlab_result_version_call}" MATCHES "timeout")
+ if(_matlab_result_version_call MATCHES "timeout")
if(MATLAB_FIND_DEBUG)
message(WARNING "[MATLAB] Unable to determine the version of Matlab."
" Matlab call timed out after 120 seconds.")
@@ -669,7 +740,7 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve
file(REMOVE "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp")
set(index -1)
- string(FIND ${_matlab_version_from_cmd} "ans" index)
+ string(FIND "${_matlab_version_from_cmd}" "ans" index)
if(index EQUAL -1)
if(MATLAB_FIND_DEBUG)
@@ -679,14 +750,14 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve
else()
set(matlab_list_of_all_versions_tmp)
- string(SUBSTRING ${_matlab_version_from_cmd} ${index} -1 substring_ans)
+ string(SUBSTRING "${_matlab_version_from_cmd}" ${index} -1 substring_ans)
string(
- REGEX MATCHALL "ans[\r\n\t ]*=[\r\n\t ]*([0-9]+(\\.[0-9]+)?)"
+ REGEX MATCHALL "ans[\r\n\t ]*=[\r\n\t ]*'?([0-9]+(\\.[0-9]+)?)"
matlab_versions_regex
${substring_ans})
foreach(match IN LISTS matlab_versions_regex)
string(
- REGEX MATCH "ans[\r\n\t ]*=[\r\n\t ]*(([0-9]+)(\\.([0-9]+))?)"
+ REGEX MATCH "ans[\r\n\t ]*=[\r\n\t ]*'?(([0-9]+)(\\.([0-9]+))?)"
current_match ${match})
list(APPEND matlab_list_of_all_versions_tmp ${CMAKE_MATCH_1})
@@ -700,74 +771,77 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve
endfunction()
-#.rst:
-# .. command:: matlab_add_unit_test
-#
-# Adds a Matlab unit test to the test set of cmake/ctest.
-# This command requires the component ``MAIN_PROGRAM``.
-# The unit test uses the Matlab unittest framework (default, available
-# starting Matlab 2013b+) except if the option ``NO_UNITTEST_FRAMEWORK``
-# is given.
-#
-# The function expects one Matlab test script file to be given.
-# In the case ``NO_UNITTEST_FRAMEWORK`` is given, the unittest script file
-# should contain the script to be run, plus an exit command with the exit
-# value. This exit value will be passed to the ctest framework (0 success,
-# non 0 failure). Additional arguments accepted by :command:`add_test` can be
-# passed through ``TEST_ARGS`` (eg. ``CONFIGURATION <config> ...``).
-#
-# ::
-#
-# matlab_add_unit_test(
-# NAME <name>
-# UNITTEST_FILE matlab_file_containing_unittest.m
-# [CUSTOM_MATLAB_COMMAND matlab_command_to_run_as_test]
-# [UNITTEST_PRECOMMAND matlab_command_to_run]
-# [TIMEOUT timeout]
-# [ADDITIONAL_PATH path1 [path2 ...]]
-# [MATLAB_ADDITIONAL_STARTUP_OPTIONS option1 [option2 ...]]
-# [TEST_ARGS arg1 [arg2 ...]]
-# [NO_UNITTEST_FRAMEWORK]
-# )
-#
-# The function arguments are:
-#
-# ``NAME``
-# name of the unittest in ctest.
-# ``UNITTEST_FILE``
-# the matlab unittest file. Its path will be automatically
-# added to the Matlab path.
-# ``CUSTOM_MATLAB_COMMAND``
-# Matlab script command to run as the test.
-# If this is not set, then the following is run:
-# ``runtests('matlab_file_name'), exit(max([ans(1,:).Failed]))``
-# where ``matlab_file_name`` is the ``UNITTEST_FILE`` without the extension.
-# ``UNITTEST_PRECOMMAND``
-# Matlab script command to be ran before the file
-# containing the test (eg. GPU device initialisation based on CMake
-# variables).
-# ``TIMEOUT``
-# the test timeout in seconds. Defaults to 180 seconds as the
-# Matlab unit test may hang.
-# ``ADDITIONAL_PATH``
-# a list of paths to add to the Matlab path prior to
-# running the unit test.
-# ``MATLAB_ADDITIONAL_STARTUP_OPTIONS``
-# a list of additional option in order
-# to run Matlab from the command line.
-# ``-nosplash -nodesktop -nodisplay`` are always added.
-# ``TEST_ARGS``
-# Additional options provided to the add_test command. These
-# options are added to the default options (eg. "CONFIGURATIONS Release")
-# ``NO_UNITTEST_FRAMEWORK``
-# when set, indicates that the test should not
-# use the unittest framework of Matlab (available for versions >= R2013a).
-# ``WORKING_DIRECTORY``
-# This will be the working directory for the test. If specified it will
-# also be the output directory used for the log file of the test run.
-# If not specifed the temporary directory ``${CMAKE_BINARY_DIR}/Matlab`` will
-# be used as the working directory and the log location.
-#
+#[=======================================================================[.rst:
+.. command:: matlab_add_unit_test
+
+ Adds a Matlab unit test to the test set of cmake/ctest.
+ This command requires the component ``MAIN_PROGRAM`` and hence is not
+ available for an MCR installation.
+
+ The unit test uses the Matlab unittest framework (default, available
+ starting Matlab 2013b+) except if the option ``NO_UNITTEST_FRAMEWORK``
+ is given.
+
+ The function expects one Matlab test script file to be given.
+ In the case ``NO_UNITTEST_FRAMEWORK`` is given, the unittest script file
+ should contain the script to be run, plus an exit command with the exit
+ value. This exit value will be passed to the ctest framework (0 success,
+ non 0 failure). Additional arguments accepted by :command:`add_test` can be
+ passed through ``TEST_ARGS`` (eg. ``CONFIGURATION <config> ...``).
+
+ ::
+
+ matlab_add_unit_test(
+ NAME <name>
+ UNITTEST_FILE matlab_file_containing_unittest.m
+ [CUSTOM_TEST_COMMAND matlab_command_to_run_as_test]
+ [UNITTEST_PRECOMMAND matlab_command_to_run]
+ [TIMEOUT timeout]
+ [ADDITIONAL_PATH path1 [path2 ...]]
+ [MATLAB_ADDITIONAL_STARTUP_OPTIONS option1 [option2 ...]]
+ [TEST_ARGS arg1 [arg2 ...]]
+ [NO_UNITTEST_FRAMEWORK]
+ )
+
+ The function arguments are:
+
+ ``NAME``
+ name of the unittest in ctest.
+ ``UNITTEST_FILE``
+ the matlab unittest file. Its path will be automatically
+ added to the Matlab path.
+ ``CUSTOM_TEST_COMMAND``
+ Matlab script command to run as the test.
+ If this is not set, then the following is run:
+ ``runtests('matlab_file_name'), exit(max([ans(1,:).Failed]))``
+ where ``matlab_file_name`` is the ``UNITTEST_FILE`` without the extension.
+ ``UNITTEST_PRECOMMAND``
+ Matlab script command to be ran before the file
+ containing the test (eg. GPU device initialisation based on CMake
+ variables).
+ ``TIMEOUT``
+ the test timeout in seconds. Defaults to 180 seconds as the
+ Matlab unit test may hang.
+ ``ADDITIONAL_PATH``
+ a list of paths to add to the Matlab path prior to
+ running the unit test.
+ ``MATLAB_ADDITIONAL_STARTUP_OPTIONS``
+ a list of additional option in order
+ to run Matlab from the command line.
+ ``-nosplash -nodesktop -nodisplay`` are always added.
+ ``TEST_ARGS``
+ Additional options provided to the add_test command. These
+ options are added to the default options (eg. "CONFIGURATIONS Release")
+ ``NO_UNITTEST_FRAMEWORK``
+ when set, indicates that the test should not
+ use the unittest framework of Matlab (available for versions >= R2013a).
+ ``WORKING_DIRECTORY``
+ This will be the working directory for the test. If specified it will
+ also be the output directory used for the log file of the test run.
+ If not specified the temporary directory ``${CMAKE_BINARY_DIR}/Matlab`` will
+ be used as the working directory and the log location.
+
+#]=======================================================================]
function(matlab_add_unit_test)
if(NOT Matlab_MAIN_PROGRAM)
@@ -806,58 +880,70 @@ function(matlab_add_unit_test)
endfunction()
-#.rst:
-# .. command:: matlab_add_mex
-#
-# Adds a Matlab MEX target.
-# This commands compiles the given sources with the current tool-chain in
-# order to produce a MEX file. The final name of the produced output may be
-# specified, as well as additional link libraries, and a documentation entry
-# for the MEX file. Remaining arguments of the call are passed to the
-# :command:`add_library` or :command:`add_executable` command.
-#
-# ::
-#
-# matlab_add_mex(
-# NAME <name>
-# [EXECUTABLE | MODULE | SHARED]
-# SRC src1 [src2 ...]
-# [OUTPUT_NAME output_name]
-# [DOCUMENTATION file.txt]
-# [LINK_TO target1 target2 ...]
-# [...]
-# )
-#
-# ``NAME``
-# name of the target.
-# ``SRC``
-# list of source files.
-# ``LINK_TO``
-# a list of additional link dependencies. The target links to ``libmex``
-# by default. If ``Matlab_MX_LIBRARY`` is defined, it also
-# links to ``libmx``.
-# ``OUTPUT_NAME``
-# if given, overrides the default name. The default name is
-# the name of the target without any prefix and
-# with ``Matlab_MEX_EXTENSION`` suffix.
-# ``DOCUMENTATION``
-# if given, the file ``file.txt`` will be considered as
-# being the documentation file for the MEX file. This file is copied into
-# the same folder without any processing, with the same name as the final
-# mex file, and with extension `.m`. In that case, typing ``help <name>``
-# in Matlab prints the documentation contained in this file.
-# ``MODULE`` or ``SHARED`` may be given to specify the type of library to be
-# created. ``EXECUTABLE`` may be given to create an executable instead of
-# a library. If no type is given explicitly, the type is ``SHARED``.
-#
-# The documentation file is not processed and should be in the following
-# format:
-#
-# ::
-#
-# % This is the documentation
-# function ret = mex_target_output_name(input1)
-#
+#[=======================================================================[.rst:
+.. command:: matlab_add_mex
+
+ Adds a Matlab MEX target.
+ This commands compiles the given sources with the current tool-chain in
+ order to produce a MEX file. The final name of the produced output may be
+ specified, as well as additional link libraries, and a documentation entry
+ for the MEX file. Remaining arguments of the call are passed to the
+ :command:`add_library` or :command:`add_executable` command.
+
+ ::
+
+ matlab_add_mex(
+ NAME <name>
+ [EXECUTABLE | MODULE | SHARED]
+ SRC src1 [src2 ...]
+ [OUTPUT_NAME output_name]
+ [DOCUMENTATION file.txt]
+ [LINK_TO target1 target2 ...]
+ [R2017b | R2018a]
+ [EXCLUDE_FROM_ALL]
+ [...]
+ )
+
+ ``NAME``
+ name of the target.
+ ``SRC``
+ list of source files.
+ ``LINK_TO``
+ a list of additional link dependencies. The target links to ``libmex``
+ and ``libmx`` by default.
+ ``OUTPUT_NAME``
+ if given, overrides the default name. The default name is
+ the name of the target without any prefix and
+ with ``Matlab_MEX_EXTENSION`` suffix.
+ ``DOCUMENTATION``
+ if given, the file ``file.txt`` will be considered as
+ being the documentation file for the MEX file. This file is copied into
+ the same folder without any processing, with the same name as the final
+ mex file, and with extension `.m`. In that case, typing ``help <name>``
+ in Matlab prints the documentation contained in this file.
+ ``R2017b`` or ``R2018a`` may be given to specify the version of the C API
+ to use: ``R2017b`` specifies the traditional (separate complex) C API,
+ and corresponds to the ``-R2017b`` flag for the `mex` command. ``R2018a``
+ specifies the new interleaved complex C API, and corresponds to the
+ ``-R2018a`` flag for the `mex` command. Ignored if MATLAB version prior
+ to R2018a. Defaults to ``R2017b``.
+ ``MODULE`` or ``SHARED`` may be given to specify the type of library to be
+ created. ``EXECUTABLE`` may be given to create an executable instead of
+ a library. If no type is given explicitly, the type is ``SHARED``.
+ ``EXCLUDE_FROM_ALL``
+ This option has the same meaning as for :prop_tgt:`EXCLUDE_FROM_ALL` and
+ is forwarded to :command:`add_library` or :command:`add_executable`
+ commands.
+
+ The documentation file is not processed and should be in the following
+ format:
+
+ ::
+
+ % This is the documentation
+ function ret = mex_target_output_name(input1)
+
+#]=======================================================================]
function(matlab_add_mex)
if(NOT WIN32)
@@ -874,7 +960,7 @@ function(matlab_add_mex)
endif()
- set(options EXECUTABLE MODULE SHARED)
+ set(options EXECUTABLE MODULE SHARED R2017b R2018a EXCLUDE_FROM_ALL)
set(oneValueArgs NAME DOCUMENTATION OUTPUT_NAME)
set(multiValueArgs LINK_TO SRC)
@@ -889,9 +975,40 @@ function(matlab_add_mex)
set(${prefix}_OUTPUT_NAME ${${prefix}_NAME})
endif()
+ if(NOT Matlab_VERSION_STRING VERSION_LESS "9.1") # For 9.1 (R2016b) and newer, add version source file
+ # Add the correct version file depending on which languages are enabled in the project
+ if(CMAKE_C_COMPILER_LOADED)
+ # If C is enabled, use the .c file as it will work fine also with C++
+ set(MEX_VERSION_FILE "${Matlab_ROOT_DIR}/extern/version/c_mexapi_version.c")
+ elseif(CMAKE_CXX_COMPILER_LOADED)
+ # If C is not enabled, check if CXX is enabled and use the .cpp file
+ # to avoid that the .c file is silently ignored
+ set(MEX_VERSION_FILE "${Matlab_ROOT_DIR}/extern/version/cpp_mexapi_version.cpp")
+ else()
+ # If neither C or CXX is enabled, warn because we cannot add the source.
+ # TODO: add support for fortran mex files
+ message(WARNING "[MATLAB] matlab_add_mex requires that at least C or CXX are enabled languages")
+ endif()
+ endif()
+
+ if(NOT Matlab_VERSION_STRING VERSION_LESS "9.4") # For 9.4 (R2018a) and newer, add API macro
+ if(${${prefix}_R2018a})
+ set(MEX_API_MACRO "MATLAB_DEFAULT_RELEASE=R2018a")
+ else()
+ set(MEX_API_MACRO "MATLAB_DEFAULT_RELEASE=R2017b")
+ endif()
+ endif()
+
+ set(_option_EXCLUDE_FROM_ALL)
+ if(${prefix}_EXCLUDE_FROM_ALL)
+ set(_option_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL")
+ endif()
+
if(${prefix}_EXECUTABLE)
add_executable(${${prefix}_NAME}
+ ${_option_EXCLUDE_FROM_ALL}
${${prefix}_SRC}
+ ${MEX_VERSION_FILE}
${${prefix}_DOCUMENTATION}
${${prefix}_UNPARSED_ARGUMENTS})
else()
@@ -903,24 +1020,27 @@ function(matlab_add_mex)
add_library(${${prefix}_NAME}
${type}
+ ${_option_EXCLUDE_FROM_ALL}
${${prefix}_SRC}
+ ${MEX_VERSION_FILE}
${${prefix}_DOCUMENTATION}
${${prefix}_UNPARSED_ARGUMENTS})
endif()
target_include_directories(${${prefix}_NAME} PRIVATE ${Matlab_INCLUDE_DIRS})
- if(DEFINED Matlab_MX_LIBRARY)
- target_link_libraries(${${prefix}_NAME} ${Matlab_MX_LIBRARY})
+ if(Matlab_HAS_CPP_API)
+ target_link_libraries(${${prefix}_NAME} ${Matlab_ENGINE_LIBRARY} ${Matlab_DATAARRAY_LIBRARY})
endif()
- target_link_libraries(${${prefix}_NAME} ${Matlab_MEX_LIBRARY} ${${prefix}_LINK_TO})
+ target_link_libraries(${${prefix}_NAME} ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} ${${prefix}_LINK_TO})
set_target_properties(${${prefix}_NAME}
PROPERTIES
PREFIX ""
OUTPUT_NAME ${${prefix}_OUTPUT_NAME}
SUFFIX ".${Matlab_MEX_EXTENSION}")
+ target_compile_definitions(${${prefix}_NAME} PRIVATE ${MEX_API_MACRO} MATLAB_MEX_FILE)
# documentation
if(NOT ${${prefix}_DOCUMENTATION} STREQUAL "")
@@ -929,74 +1049,85 @@ function(matlab_add_mex)
TARGET ${${prefix}_NAME}
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${${prefix}_DOCUMENTATION} $<TARGET_FILE_DIR:${${prefix}_NAME}>/${output_name}.m
- COMMENT "Copy ${${prefix}_NAME} documentation file into the output folder"
+ COMMENT "[MATLAB] Copy ${${prefix}_NAME} documentation file into the output folder"
)
endif() # documentation
# entry point in the mex file + taking care of visibility and symbol clashes.
if(WIN32)
+
+ if (MSVC)
+
+ set(_link_flags "${_link_flags} /EXPORT:mexFunction")
+ if(NOT Matlab_VERSION_STRING VERSION_LESS "9.1") # For 9.1 (R2016b) and newer, export version
+ set(_link_flags "${_link_flags} /EXPORT:mexfilerequiredapiversion")
+ endif()
+
+ set_property(TARGET ${${prefix}_NAME} APPEND PROPERTY LINK_FLAGS ${_link_flags})
+
+ endif() # No other compiler currently supported on Windows.
+
set_target_properties(${${prefix}_NAME}
PROPERTIES
DEFINE_SYMBOL "DLL_EXPORT_SYM=__declspec(dllexport)")
+
else()
- if(HAS_MINUS_PTHREAD AND NOT APPLE)
- # Apparently, compiling with -pthread generated the proper link flags
- # and some defines at compilation
- target_compile_options(${${prefix}_NAME} PRIVATE "-pthread")
+ if(Matlab_VERSION_STRING VERSION_LESS "9.1") # For versions prior to 9.1 (R2016b)
+ set(_ver_map_files ${Matlab_EXTERN_LIBRARY_DIR}/mexFunction.map)
+ else() # For 9.1 (R2016b) and newer
+ set(_ver_map_files ${Matlab_EXTERN_LIBRARY_DIR}/c_exportsmexfileversion.map)
endif()
+ if(NOT Matlab_VERSION_STRING VERSION_LESS "9.5") # For 9.5 (R2018b) (and newer?)
+ target_compile_options(${${prefix}_NAME} PRIVATE "-fvisibility=default")
+ # This one is weird, it might be a bug in <mex.h> for R2018b. When compiling with
+ # -fvisibility=hidden, the symbol `mexFunction` cannot be exported. Reading the
+ # source code for <mex.h>, it seems that the preprocessor macro `MW_NEEDS_VERSION_H`
+ # needs to be defined for `__attribute__((visibility("default")))` to be added
+ # in front of the declaration of `mexFunction`. In previous versions of MATLAB this
+ # was not the case, there `DLL_EXPORT_SYM` needed to be defined.
+ # Adding `-fvisibility=hidden` to the `mex` command causes the build to fail.
+ # TODO: Check that this is still necessary in R2019a when it comes out.
+ endif()
- # if we do not do that, the symbols linked from eg. boost remain weak and
- # then clash with the ones defined in the matlab process. So by default
- # the symbols are hidden.
- # This also means that for shared libraries (like MEX), the entry point
- # should be explicitly declared with default visibility, otherwise Matlab
- # cannot find the entry point.
- # Note that this is particularly meaningful if the MEX wrapper itself
- # contains symbols that are clashing with Matlab (that are compiled in the
- # MEX file). In order to propagate the visibility options to the libraries
- # to which the MEX file is linked against, the -Wl,--exclude-libs,ALL
- # option should also be specified.
+ if(APPLE)
- set_target_properties(${${prefix}_NAME}
- PROPERTIES
- CXX_VISIBILITY_PRESET "hidden"
- C_VISIBILITY_PRESET "hidden"
- VISIBILITY_INLINES_HIDDEN ON
- )
+ if(Matlab_HAS_CPP_API)
+ list(APPEND _ver_map_files ${Matlab_EXTERN_LIBRARY_DIR}/cppMexFunction.map) # This one doesn't exist on Linux
+ set(_link_flags "${_link_flags} -Wl,-U,_mexCreateMexFunction -Wl,-U,_mexDestroyMexFunction -Wl,-U,_mexFunctionAdapter")
+ # On MacOS, the MEX command adds the above, without it the link breaks
+ # because we indiscriminately use "cppMexFunction.map" even for C API MEX-files.
+ endif()
+
+ set(_export_flag_name -exported_symbols_list)
+
+ else() # Linux
+
+ if(HAS_MINUS_PTHREAD)
+ # Apparently, compiling with -pthread generated the proper link flags
+ # and some defines at compilation
+ target_compile_options(${${prefix}_NAME} PRIVATE "-pthread")
+ endif()
- # get_target_property(
- # _previous_link_flags
- # ${${prefix}_NAME}
- # LINK_FLAGS)
- # if(NOT _previous_link_flags)
- # set(_previous_link_flags)
- # endif()
-
- # if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
- # set_target_properties(${${prefix}_NAME}
- # PROPERTIES
- # LINK_FLAGS "${_previous_link_flags} -Wl,--exclude-libs,ALL"
- # # -Wl,--version-script=${_FindMatlab_SELF_DIR}/MatlabLinuxVisibility.map"
- # )
- # elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- # # in this case, all other symbols become hidden.
- # set_target_properties(${${prefix}_NAME}
- # PROPERTIES
- # LINK_FLAGS "${_previous_link_flags} -Wl,-exported_symbol,_mexFunction"
- # #-Wl,-exported_symbols_list,${_FindMatlab_SELF_DIR}/MatlabOSXVisilibity.map"
- # )
- # endif()
+ set(_link_flags "${_link_flags} -Wl,--as-needed")
+ set(_export_flag_name --version-script)
+ endif()
+ foreach(_file ${_ver_map_files})
+ set(_link_flags "${_link_flags} -Wl,${_export_flag_name},${_file}")
+ endforeach()
+
+ # The `mex` command doesn't add this define. It is specified here in order
+ # to export the symbol in case the client code decides to hide its symbols
set_target_properties(${${prefix}_NAME}
PROPERTIES
- DEFINE_SYMBOL "DLL_EXPORT_SYM=__attribute__ ((visibility (\"default\")))"
+ DEFINE_SYMBOL "DLL_EXPORT_SYM=__attribute__((visibility(\"default\")))"
+ LINK_FLAGS "${_link_flags}"
)
-
endif()
endfunction()
@@ -1005,190 +1136,225 @@ endfunction()
# (internal)
# Used to get the version of matlab, using caching. This basically transforms the
# output of the root list, with possible unknown version, to a version
-#
-function(_Matlab_get_version_from_root matlab_root matlab_known_version matlab_final_version)
+# This can possibly run Matlab for extracting the version.
+function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_version matlab_final_version)
- # if the version is not trivial, we query matlab for that
+ # if the version is not trivial, we query matlab (if not MCR) for that
# we keep track of the location of matlab that induced this version
#if(NOT DEFINED Matlab_PROG_VERSION_STRING_AUTO_DETECT)
# set(Matlab_PROG_VERSION_STRING_AUTO_DETECT "" CACHE INTERNAL "internal matlab location for the discovered version")
#endif()
- if(NOT ${matlab_known_version} STREQUAL "NOTFOUND")
+ if(NOT matlab_known_version STREQUAL "NOTFOUND")
# the version is known, we just return it
set(${matlab_final_version} ${matlab_known_version} PARENT_SCOPE)
set(Matlab_VERSION_STRING_INTERNAL ${matlab_known_version} CACHE INTERNAL "Matlab version (automatically determined)" FORCE)
return()
endif()
- #
- set(_matlab_current_program ${Matlab_MAIN_PROGRAM})
-
- # do we already have a matlab program?
- if(NOT _matlab_current_program)
-
- set(_find_matlab_options)
- if(matlab_root AND EXISTS ${matlab_root})
- set(_find_matlab_options PATHS ${matlab_root} ${matlab_root}/bin NO_DEFAULT_PATH)
+ if(matlab_or_mcr STREQUAL "UNKNOWN")
+ if(MATLAB_FIND_DEBUG)
+ message(WARNING "[MATLAB] Determining Matlab or MCR")
endif()
- find_program(
- _matlab_current_program
- matlab
- ${_find_matlab_options}
- DOC "Matlab main program"
- )
- endif()
+ if(EXISTS "${matlab_root}/appdata/version.xml")
+ # we inspect the application version.xml file that contains the product information
+ file(STRINGS "${matlab_root}/appdata/version.xml" productinfo_string NEWLINE_CONSUME)
+ string(REGEX MATCH "<installedProductData.*displayedString=\"([a-zA-Z ]+)\".*/>"
+ product_reg_match
+ ${productinfo_string}
+ )
+
+ # default fallback to Matlab
+ set(matlab_or_mcr "MATLAB")
+ if(NOT CMAKE_MATCH_1 STREQUAL "")
+ string(TOLOWER "${CMAKE_MATCH_1}" product_reg_match)
+
+ if(product_reg_match STREQUAL "matlab runtime")
+ set(matlab_or_mcr "MCR")
+ endif()
+ endif()
+ endif()
- if(NOT _matlab_current_program OR NOT EXISTS ${_matlab_current_program})
- # if not found, clear the dependent variables
if(MATLAB_FIND_DEBUG)
- message(WARNING "[MATLAB] Cannot find the main matlab program under ${matlab_root}")
+ message(WARNING "[MATLAB] '${matlab_root}' contains the '${matlab_or_mcr}'")
endif()
- set(Matlab_PROG_VERSION_STRING_AUTO_DETECT "" CACHE INTERNAL "internal matlab location for the discovered version" FORCE)
- set(Matlab_VERSION_STRING_INTERNAL "" CACHE INTERNAL "internal matlab location for the discovered version" FORCE)
- unset(_matlab_current_program)
- unset(_matlab_current_program CACHE)
- return()
endif()
- # full real path for path comparison
- get_filename_component(_matlab_main_real_path_tmp "${_matlab_current_program}" REALPATH)
- unset(_matlab_current_program)
- unset(_matlab_current_program CACHE)
-
- # is it the same as the previous one?
- if(_matlab_main_real_path_tmp STREQUAL Matlab_PROG_VERSION_STRING_AUTO_DETECT)
- set(${matlab_final_version} ${Matlab_VERSION_STRING_INTERNAL} PARENT_SCOPE)
- return()
- endif()
+ # UNKNOWN is the default behaviour in case we
+ # - have an erroneous matlab_root
+ # - have an initial 'UNKNOWN'
+ if(matlab_or_mcr STREQUAL "MATLAB" OR matlab_or_mcr STREQUAL "UNKNOWN")
+ # MATLAB versions
+ set(_matlab_current_program ${Matlab_MAIN_PROGRAM})
- # update the location of the program
- set(Matlab_PROG_VERSION_STRING_AUTO_DETECT ${_matlab_main_real_path_tmp} CACHE INTERNAL "internal matlab location for the discovered version" FORCE)
+ # do we already have a matlab program?
+ if(NOT _matlab_current_program)
- set(matlab_list_of_all_versions)
- matlab_get_version_from_matlab_run("${Matlab_PROG_VERSION_STRING_AUTO_DETECT}" matlab_list_of_all_versions)
+ set(_find_matlab_options)
+ if(matlab_root AND EXISTS ${matlab_root})
+ set(_find_matlab_options PATHS ${matlab_root} ${matlab_root}/bin NO_DEFAULT_PATH)
+ endif()
- list(LENGTH matlab_list_of_all_versions list_of_all_versions_length)
- if(${list_of_all_versions_length} GREATER 0)
- list(GET matlab_list_of_all_versions 0 _matlab_version_tmp)
- else()
- set(_matlab_version_tmp "unknown")
- endif()
+ find_program(
+ _matlab_current_program
+ matlab
+ ${_find_matlab_options}
+ DOC "Matlab main program"
+ )
+ endif()
- # set the version into the cache
- set(Matlab_VERSION_STRING_INTERNAL ${_matlab_version_tmp} CACHE INTERNAL "Matlab version (automatically determined)" FORCE)
+ if(NOT _matlab_current_program OR NOT EXISTS ${_matlab_current_program})
+ # if not found, clear the dependent variables
+ if(MATLAB_FIND_DEBUG)
+ message(WARNING "[MATLAB] Cannot find the main matlab program under ${matlab_root}")
+ endif()
+ set(Matlab_PROG_VERSION_STRING_AUTO_DETECT "" CACHE INTERNAL "internal matlab location for the discovered version" FORCE)
+ set(Matlab_VERSION_STRING_INTERNAL "" CACHE INTERNAL "internal matlab location for the discovered version" FORCE)
+ unset(_matlab_current_program)
+ unset(_matlab_current_program CACHE)
+ return()
+ endif()
- # warning, just in case several versions found (should not happen)
- if((${list_of_all_versions_length} GREATER 1) AND MATLAB_FIND_DEBUG)
- message(WARNING "[MATLAB] Found several versions, taking the first one (versions found ${matlab_list_of_all_versions})")
- endif()
+ # full real path for path comparison
+ get_filename_component(_matlab_main_real_path_tmp "${_matlab_current_program}" REALPATH)
+ unset(_matlab_current_program)
+ unset(_matlab_current_program CACHE)
- # return the updated value
- set(${matlab_final_version} ${Matlab_VERSION_STRING_INTERNAL} PARENT_SCOPE)
+ # is it the same as the previous one?
+ if(_matlab_main_real_path_tmp STREQUAL Matlab_PROG_VERSION_STRING_AUTO_DETECT)
+ set(${matlab_final_version} ${Matlab_VERSION_STRING_INTERNAL} PARENT_SCOPE)
+ return()
+ endif()
-endfunction()
+ # update the location of the program
+ set(Matlab_PROG_VERSION_STRING_AUTO_DETECT
+ ${_matlab_main_real_path_tmp}
+ CACHE INTERNAL "internal matlab location for the discovered version" FORCE)
+ set(matlab_list_of_all_versions)
+ matlab_get_version_from_matlab_run("${Matlab_PROG_VERSION_STRING_AUTO_DETECT}" matlab_list_of_all_versions)
+ list(LENGTH matlab_list_of_all_versions list_of_all_versions_length)
+ if(list_of_all_versions_length GREATER 0)
+ list(GET matlab_list_of_all_versions 0 _matlab_version_tmp)
+ else()
+ set(_matlab_version_tmp "unknown")
+ endif()
+ # set the version into the cache
+ set(Matlab_VERSION_STRING_INTERNAL ${_matlab_version_tmp} CACHE INTERNAL "Matlab version (automatically determined)" FORCE)
+ # warning, just in case several versions found (should not happen)
+ if((list_of_all_versions_length GREATER 1) AND MATLAB_FIND_DEBUG)
+ message(WARNING "[MATLAB] Found several versions, taking the first one (versions found ${matlab_list_of_all_versions})")
+ endif()
+ # return the updated value
+ set(${matlab_final_version} ${Matlab_VERSION_STRING_INTERNAL} PARENT_SCOPE)
+ elseif(EXISTS "${matlab_root}/VersionInfo.xml")
+ # MCR
+ # we cannot run anything in order to extract the version. We assume that the file
+ # VersionInfo.xml exists under the MatlabRoot, we look for it and extract the version from there
+ set(_matlab_version_tmp "unknown")
+ file(STRINGS "${matlab_root}/VersionInfo.xml" versioninfo_string NEWLINE_CONSUME)
+ if(versioninfo_string)
+ # parses "<version>9.2.0.538062</version>"
+ string(REGEX MATCH "<version>(.*)</version>"
+ version_reg_match
+ ${versioninfo_string}
+ )
-# ###################################
-# Exploring the possible Matlab_ROOTS
+ if(CMAKE_MATCH_1 MATCHES "(([0-9])\\.([0-9]))[\\.0-9]*")
+ set(_matlab_version_tmp "${CMAKE_MATCH_1}")
+ endif()
+ endif()
+ set(${matlab_final_version} "${_matlab_version_tmp}" PARENT_SCOPE)
+ set(Matlab_VERSION_STRING_INTERNAL
+ "${_matlab_version_tmp}"
+ CACHE INTERNAL "Matlab (MCR) version (automatically determined)"
+ FORCE)
+ endif() # Matlab or MCR
-# this variable will get all Matlab installations found in the current system.
-set(_matlab_possible_roots)
+endfunction()
+# Utility function for finding Matlab or MCR on Win32
+function(_Matlab_find_instances_win32 matlab_roots)
+ # On WIN32, we look for Matlab installation in the registry
+ # if unsuccessful, we look for all known revision and filter the existing
+ # ones.
-if(Matlab_ROOT_DIR)
- # if the user specifies a possible root, we keep this one
+ # testing if we are able to extract the needed information from the registry
+ set(_matlab_versions_from_registry)
- if(NOT EXISTS ${Matlab_ROOT_DIR})
- # if Matlab_ROOT_DIR specified but erroneous
- if(MATLAB_FIND_DEBUG)
- message(WARNING "[MATLAB] the specified path for Matlab_ROOT_DIR does not exist (${Matlab_ROOT_DIR})")
- endif()
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(_matlab_win64 ON)
else()
- # NOTFOUND indicates the code below to search for the version automatically
- if("${Matlab_VERSION_STRING_INTERNAL}" STREQUAL "")
- list(APPEND _matlab_possible_roots "NOTFOUND" ${Matlab_ROOT_DIR}) # empty version
- else()
- list(APPEND _matlab_possible_roots ${Matlab_VERSION_STRING_INTERNAL} ${Matlab_ROOT_DIR}) # cached version
- endif()
+ set(_matlab_win64 OFF)
endif()
+ matlab_extract_all_installed_versions_from_registry(_matlab_win64 _matlab_versions_from_registry)
-else()
+ # the returned list is empty, doing the search on all known versions
+ if(NOT _matlab_versions_from_registry)
+ if(MATLAB_FIND_DEBUG)
+ message(STATUS "[MATLAB] Search for Matlab from the registry unsuccessful, testing all supported versions")
+ endif()
+ extract_matlab_versions_from_registry_brute_force(_matlab_versions_from_registry)
+ endif()
- # if the user does not specify the possible installation root, we look for
- # one installation using the appropriate heuristics
+ # filtering the results with the registry keys
+ matlab_get_all_valid_matlab_roots_from_registry("${_matlab_versions_from_registry}" _matlab_possible_roots)
+ set(${matlab_roots} ${_matlab_possible_roots} PARENT_SCOPE)
- if(WIN32)
+endfunction()
- # On WIN32, we look for Matlab installation in the registry
- # if unsuccessful, we look for all known revision and filter the existing
- # ones.
+# Utility function for finding Matlab or MCR on OSX
+function(_Matlab_find_instances_osx matlab_roots)
- # testing if we are able to extract the needed information from the registry
- set(_matlab_versions_from_registry)
- matlab_extract_all_installed_versions_from_registry(CMAKE_CL_64 _matlab_versions_from_registry)
+ set(_matlab_possible_roots)
+ # on mac, we look for the /Application paths
+ # this corresponds to the behaviour on Windows. On Linux, we do not have
+ # any other guess.
+ matlab_get_supported_releases(_matlab_releases)
+ if(MATLAB_FIND_DEBUG)
+ message(STATUS "[MATLAB] Matlab supported versions ${_matlab_releases}. If more version should be supported "
+ "the variable MATLAB_ADDITIONAL_VERSIONS can be set according to the documentation")
+ endif()
- # the returned list is empty, doing the search on all known versions
- if(NOT _matlab_versions_from_registry)
+ foreach(_matlab_current_release IN LISTS _matlab_releases)
+ matlab_get_version_from_release_name("${_matlab_current_release}" _matlab_current_version)
+ string(REPLACE "." "" _matlab_current_version_without_dot "${_matlab_current_version}")
+ set(_matlab_base_path "/Applications/MATLAB_${_matlab_current_release}.app")
+ # Check Matlab, has precedence over MCR
+ if(EXISTS ${_matlab_base_path})
if(MATLAB_FIND_DEBUG)
- message(STATUS "[MATLAB] Search for Matlab from the registry unsuccessful, testing all supported versions")
+ message(STATUS "[MATLAB] Found version ${_matlab_current_release} (${_matlab_current_version}) in ${_matlab_base_path}")
endif()
-
- extract_matlab_versions_from_registry_brute_force(_matlab_versions_from_registry)
+ list(APPEND _matlab_possible_roots "MATLAB" ${_matlab_current_version} ${_matlab_base_path})
endif()
- # filtering the results with the registry keys
- matlab_get_all_valid_matlab_roots_from_registry("${_matlab_versions_from_registry}" _matlab_possible_roots)
- unset(_matlab_versions_from_registry)
-
- elseif(APPLE)
-
- # on mac, we look for the /Application paths
- # this corresponds to the behaviour on Windows. On Linux, we do not have
- # any other guess.
- matlab_get_supported_releases(_matlab_releases)
- if(MATLAB_FIND_DEBUG)
- message(STATUS "[MATLAB] Matlab supported versions ${_matlab_releases}. If more version should be supported "
- "the variable MATLAB_ADDITIONAL_VERSIONS can be set according to the documentation")
- endif()
-
- foreach(_matlab_current_release IN LISTS _matlab_releases)
- set(_matlab_full_string "/Applications/MATLAB_${_matlab_current_release}.app")
- if(EXISTS ${_matlab_full_string})
- set(_matlab_current_version)
- matlab_get_version_from_release_name("${_matlab_current_release}" _matlab_current_version)
- if(MATLAB_FIND_DEBUG)
- message(STATUS "[MATLAB] Found version ${_matlab_current_release} (${_matlab_current_version}) in ${_matlab_full_string}")
- endif()
- list(APPEND _matlab_possible_roots ${_matlab_current_version} ${_matlab_full_string})
- unset(_matlab_current_version)
+ # Checks MCR
+ set(_mcr_path "/Applications/MATLAB/MATLAB_Runtime/v${_matlab_current_version_without_dot}")
+ if(EXISTS "${_mcr_path}")
+ if(MATLAB_FIND_DEBUG)
+ message(STATUS "[MATLAB] Found MCR version ${_matlab_current_release} (${_matlab_current_version}) in ${_mcr_path}")
endif()
+ list(APPEND _matlab_possible_roots "MCR" ${_matlab_current_version} ${_mcr_path})
+ endif()
- unset(_matlab_full_string)
- endforeach(_matlab_current_release)
-
- unset(_matlab_current_release)
- unset(_matlab_releases)
-
- endif()
+ endforeach()
+ set(${matlab_roots} ${_matlab_possible_roots} PARENT_SCOPE)
-endif()
+endfunction()
+# Utility function for finding Matlab or MCR from the PATH
+function(_Matlab_find_instances_from_path matlab_roots)
-
-list(LENGTH _matlab_possible_roots _numbers_of_matlab_roots)
-if(_numbers_of_matlab_roots EQUAL 0)
- # if we have not found anything, we fall back on the PATH
-
+ set(_matlab_possible_roots)
# At this point, we have no other choice than trying to find it from PATH.
# If set by the user, this wont change
@@ -1196,7 +1362,6 @@ if(_numbers_of_matlab_roots EQUAL 0)
_matlab_main_tmp
NAMES matlab)
-
if(_matlab_main_tmp)
# we then populate the list of roots, with empty version
if(MATLAB_FIND_DEBUG)
@@ -1211,18 +1376,89 @@ if(_numbers_of_matlab_roots EQUAL 0)
get_filename_component(_matlab_current_location "${_matlab_current_location}" DIRECTORY)
get_filename_component(_matlab_current_location "${_matlab_current_location}" DIRECTORY) # Matlab should be in bin
- list(APPEND _matlab_possible_roots "NOTFOUND" ${_matlab_current_location})
+ # We found the Matlab program
+ list(APPEND _matlab_possible_roots "MATLAB" "NOTFOUND" ${_matlab_current_location})
+
+ # we remove this from the CACHE
+ unset(_matlab_main_tmp CACHE)
+ else()
+ find_program(
+ _matlab_mex_tmp
+ NAMES mex)
+ if(_matlab_mex_tmp)
+ # we then populate the list of roots, with empty version
+ if(MATLAB_FIND_DEBUG)
+ message(STATUS "[MATLAB] mex compiler found from PATH: ${_matlab_mex_tmp}")
+ endif()
+
+ # resolve symlinks
+ get_filename_component(_mex_current_location "${_matlab_mex_tmp}" REALPATH)
+
+ # get the directory (the command below has to be run twice)
+ # this will be the matlab root
+ get_filename_component(_mex_current_location "${_mex_current_location}" DIRECTORY)
+ get_filename_component(_mex_current_location "${_mex_current_location}" DIRECTORY) # Matlab Runtime mex compiler should be in bin
+
+ # We found the Matlab program
+ list(APPEND _matlab_possible_roots "MCR" "NOTFOUND" ${_mex_current_location})
+
+ unset(_matlab_mex_tmp CACHE)
+ else()
+ if(MATLAB_FIND_DEBUG)
+ message(STATUS "[MATLAB] mex compiler not found")
+ endif()
+ endif()
- unset(_matlab_current_location)
endif()
- unset(_matlab_main_tmp CACHE)
-endif()
+ set(${matlab_roots} ${_matlab_possible_roots} PARENT_SCOPE)
+endfunction()
+
+
+# ###################################
+# Exploring the possible Matlab_ROOTS
+
+# this variable will get all Matlab installations found in the current system.
+set(_matlab_possible_roots)
+
+if(Matlab_ROOT_DIR)
+ # if the user specifies a possible root, we keep this one
+ if(NOT EXISTS "${Matlab_ROOT_DIR}")
+ # if Matlab_ROOT_DIR specified but erroneous
+ if(MATLAB_FIND_DEBUG)
+ message(WARNING "[MATLAB] the specified path for Matlab_ROOT_DIR does not exist (${Matlab_ROOT_DIR})")
+ endif()
+ else()
+ # NOTFOUND indicates the code below to search for the version automatically
+ if("${Matlab_VERSION_STRING_INTERNAL}" STREQUAL "")
+ list(APPEND _matlab_possible_roots "UNKNOWN" "NOTFOUND" ${Matlab_ROOT_DIR}) # empty version, empty MCR/Matlab indication
+ else()
+ list(APPEND _matlab_possible_roots "UNKNOWN" ${Matlab_VERSION_STRING_INTERNAL} ${Matlab_ROOT_DIR}) # cached version
+ endif()
+ endif()
+else()
+ # if the user does not specify the possible installation root, we look for
+ # one installation using the appropriate heuristics.
+ # There is apparently no standard way on Linux.
+ if(CMAKE_HOST_WIN32)
+ _Matlab_find_instances_win32(_matlab_possible_roots_win32)
+ list(APPEND _matlab_possible_roots ${_matlab_possible_roots_win32})
+ elseif(APPLE)
+ _Matlab_find_instances_osx(_matlab_possible_roots_osx)
+ list(APPEND _matlab_possible_roots ${_matlab_possible_roots_osx})
+ endif()
+endif()
+list(LENGTH _matlab_possible_roots _numbers_of_matlab_roots)
+if(_numbers_of_matlab_roots EQUAL 0)
+ # if we have not found anything, we fall back on the PATH
+ _Matlab_find_instances_from_path(_matlab_possible_roots)
+endif()
+
if(MATLAB_FIND_DEBUG)
message(STATUS "[MATLAB] Matlab root folders are ${_matlab_possible_roots}")
@@ -1235,14 +1471,30 @@ endif()
# take the first possible Matlab root
list(LENGTH _matlab_possible_roots _numbers_of_matlab_roots)
set(Matlab_VERSION_STRING "NOTFOUND")
+set(Matlab_Or_MCR "UNKNOWN")
if(_numbers_of_matlab_roots GREATER 0)
- list(GET _matlab_possible_roots 0 Matlab_VERSION_STRING)
- list(GET _matlab_possible_roots 1 Matlab_ROOT_DIR)
+ if(Matlab_FIND_VERSION_EXACT)
+ list(FIND _matlab_possible_roots ${Matlab_FIND_VERSION} _list_index)
+ if(_list_index LESS 0)
+ set(_list_index 1)
+ endif()
+
+ math(EXPR _matlab_or_mcr_index "${_list_index} - 1")
+ math(EXPR _matlab_root_dir_index "${_list_index} + 1")
- # adding a warning in case of ambiguity
- if(_numbers_of_matlab_roots GREATER 2 AND MATLAB_FIND_DEBUG)
- message(WARNING "[MATLAB] Found several distributions of Matlab. Setting the current version to ${Matlab_VERSION_STRING} (located ${Matlab_ROOT_DIR})."
- " If this is not the desired behaviour, provide the -DMatlab_ROOT_DIR=... on the command line")
+ list(GET _matlab_possible_roots ${_matlab_or_mcr_index} Matlab_Or_MCR)
+ list(GET _matlab_possible_roots ${_list_index} Matlab_VERSION_STRING)
+ list(GET _matlab_possible_roots ${_matlab_root_dir_index} Matlab_ROOT_DIR)
+ else()
+ list(GET _matlab_possible_roots 0 Matlab_Or_MCR)
+ list(GET _matlab_possible_roots 1 Matlab_VERSION_STRING)
+ list(GET _matlab_possible_roots 2 Matlab_ROOT_DIR)
+
+ # adding a warning in case of ambiguity
+ if(_numbers_of_matlab_roots GREATER 3 AND MATLAB_FIND_DEBUG)
+ message(WARNING "[MATLAB] Found several distributions of Matlab. Setting the current version to ${Matlab_VERSION_STRING} (located ${Matlab_ROOT_DIR})."
+ " If this is not the desired behaviour, use the EXACT keyword or provide the -DMatlab_ROOT_DIR=... on the command line")
+ endif()
endif()
endif()
@@ -1253,13 +1505,17 @@ if(DEFINED Matlab_ROOT_DIR_LAST_CACHED)
if(NOT Matlab_ROOT_DIR_LAST_CACHED STREQUAL Matlab_ROOT_DIR)
set(_Matlab_cached_vars
+ Matlab_VERSION_STRING
Matlab_INCLUDE_DIRS
Matlab_MEX_LIBRARY
Matlab_MEX_COMPILER
+ Matlab_MCC_COMPILER
Matlab_MAIN_PROGRAM
Matlab_MX_LIBRARY
Matlab_ENG_LIBRARY
Matlab_MAT_LIBRARY
+ Matlab_ENGINE_LIBRARY
+ Matlab_DATAARRAY_LIBRARY
Matlab_MEX_EXTENSION
Matlab_SIMULINK_INCLUDE_DIR
@@ -1267,7 +1523,7 @@ if(DEFINED Matlab_ROOT_DIR_LAST_CACHED)
Matlab_MEXEXTENSIONS_PROG
Matlab_ROOT_DIR_LAST_CACHED
#Matlab_PROG_VERSION_STRING_AUTO_DETECT
- Matlab_VERSION_STRING_INTERNAL
+ #Matlab_VERSION_STRING_INTERNAL
)
foreach(_var IN LISTS _Matlab_cached_vars)
if(DEFINED ${_var})
@@ -1283,18 +1539,20 @@ set(Matlab_ROOT_DIR ${Matlab_ROOT_DIR} CACHE PATH "Matlab installation root path
# Fix the version, in case this one is NOTFOUND
_Matlab_get_version_from_root(
"${Matlab_ROOT_DIR}"
+ "${Matlab_Or_MCR}"
${Matlab_VERSION_STRING}
Matlab_VERSION_STRING
)
-
-
-
if(MATLAB_FIND_DEBUG)
message(STATUS "[MATLAB] Current version is ${Matlab_VERSION_STRING} located ${Matlab_ROOT_DIR}")
endif()
-
+# MATLAB 9.4 (R2018a) and newer have a new C++ API
+# This API pulls additional required libraries.
+if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.4")
+ set(Matlab_HAS_CPP_API 1)
+endif()
if(Matlab_ROOT_DIR)
file(TO_CMAKE_PATH ${Matlab_ROOT_DIR} Matlab_ROOT_DIR)
@@ -1333,6 +1591,8 @@ set(Matlab_BINARIES_DIR
${Matlab_ROOT_DIR}/bin/${_matlab_bin_prefix}${_matlab_current_suffix})
set(Matlab_EXTERN_LIBRARY_DIR
${Matlab_ROOT_DIR}/extern/lib/${_matlab_bin_prefix}${_matlab_current_suffix})
+set(Matlab_EXTERN_BINARIES_DIR
+ ${Matlab_ROOT_DIR}/extern/bin/${_matlab_bin_prefix}${_matlab_current_suffix})
if(WIN32)
if(MINGW)
@@ -1342,7 +1602,7 @@ if(WIN32)
endif()
set(_matlab_lib_prefix_for_search "lib")
else()
- set(_matlab_lib_dir_for_search ${Matlab_BINARIES_DIR})
+ set(_matlab_lib_dir_for_search ${Matlab_BINARIES_DIR} ${Matlab_EXTERN_BINARIES_DIR})
set(_matlab_lib_prefix_for_search "lib")
endif()
@@ -1376,6 +1636,10 @@ endfunction()
set(_matlab_required_variables)
+# Order is as follow:
+# - unconditionally required libraries/headers first
+# - then library components
+# - then program components
# the MEX library/header are required
find_path(
@@ -1393,7 +1657,6 @@ _Matlab_find_library(
PATHS ${_matlab_lib_dir_for_search}
NO_DEFAULT_PATH
)
-
list(APPEND _matlab_required_variables Matlab_MEX_LIBRARY)
# the MEX extension is required
@@ -1402,57 +1665,53 @@ list(APPEND _matlab_required_variables Matlab_MEX_EXTENSION)
# the matlab root is required
list(APPEND _matlab_required_variables Matlab_ROOT_DIR)
-# component Mex Compiler
-list(FIND Matlab_FIND_COMPONENTS MEX_COMPILER _matlab_find_mex_compiler)
-if(_matlab_find_mex_compiler GREATER -1)
- find_program(
- Matlab_MEX_COMPILER
- "mex"
- PATHS ${Matlab_BINARIES_DIR}
- DOC "Matlab MEX compiler"
- NO_DEFAULT_PATH
- )
- if(Matlab_MEX_COMPILER)
- set(Matlab_MEX_COMPILER_FOUND TRUE)
- endif()
+# The MX library is required
+_Matlab_find_library(
+ ${_matlab_lib_prefix_for_search}
+ Matlab_MX_LIBRARY
+ mx
+ PATHS ${_matlab_lib_dir_for_search}
+ NO_DEFAULT_PATH
+)
+list(APPEND _matlab_required_variables Matlab_MX_LIBRARY)
+if(Matlab_MX_LIBRARY)
+ set(Matlab_MX_LIBRARY_FOUND TRUE)
endif()
-unset(_matlab_find_mex_compiler)
-# component Matlab program
-list(FIND Matlab_FIND_COMPONENTS MAIN_PROGRAM _matlab_find_matlab_program)
-if(_matlab_find_matlab_program GREATER -1)
- find_program(
- Matlab_MAIN_PROGRAM
- matlab
- PATHS ${Matlab_ROOT_DIR} ${Matlab_ROOT_DIR}/bin
- DOC "Matlab main program"
+if(Matlab_HAS_CPP_API)
+
+ # The MatlabEngine library is required for R2018a+
+ _Matlab_find_library(
+ ${_matlab_lib_prefix_for_search}
+ Matlab_ENGINE_LIBRARY
+ MatlabEngine
+ PATHS ${_matlab_lib_dir_for_search}
+ DOC "MatlabEngine Library"
NO_DEFAULT_PATH
)
- if(Matlab_MAIN_PROGRAM)
- set(Matlab_MAIN_PROGRAM_FOUND TRUE)
+ list(APPEND _matlab_required_variables Matlab_ENGINE_LIBRARY)
+ if(Matlab_ENGINE_LIBRARY)
+ set(Matlab_ENGINE_LIBRARY_FOUND TRUE)
endif()
-endif()
-unset(_matlab_find_matlab_program)
-# Component MX library
-list(FIND Matlab_FIND_COMPONENTS MX_LIBRARY _matlab_find_mx)
-if(_matlab_find_mx GREATER -1)
+ # The MatlabDataArray library is required for R2018a+
_Matlab_find_library(
${_matlab_lib_prefix_for_search}
- Matlab_MX_LIBRARY
- mx
+ Matlab_DATAARRAY_LIBRARY
+ MatlabDataArray
PATHS ${_matlab_lib_dir_for_search}
+ DOC "MatlabDataArray Library"
NO_DEFAULT_PATH
)
- if(Matlab_MX_LIBRARY)
- set(Matlab_MX_LIBRARY_FOUND TRUE)
+ list(APPEND _matlab_required_variables Matlab_DATAARRAY_LIBRARY)
+ if(Matlab_DATAARRAY_LIBRARY)
+ set(Matlab_DATAARRAY_LIBRARY_FOUND TRUE)
endif()
+
endif()
-unset(_matlab_find_mx)
# Component ENG library
-list(FIND Matlab_FIND_COMPONENTS ENG_LIBRARY _matlab_find_eng)
-if(_matlab_find_eng GREATER -1)
+if("ENG_LIBRARY" IN_LIST Matlab_FIND_COMPONENTS)
_Matlab_find_library(
${_matlab_lib_prefix_for_search}
Matlab_ENG_LIBRARY
@@ -1464,11 +1723,9 @@ if(_matlab_find_eng GREATER -1)
set(Matlab_ENG_LIBRARY_FOUND TRUE)
endif()
endif()
-unset(_matlab_find_eng)
# Component MAT library
-list(FIND Matlab_FIND_COMPONENTS MAT_LIBRARY _matlab_find_mat)
-if(_matlab_find_mat GREATER -1)
+if("MAT_LIBRARY" IN_LIST Matlab_FIND_COMPONENTS)
_Matlab_find_library(
${_matlab_lib_prefix_for_search}
Matlab_MAT_LIBRARY
@@ -1480,11 +1737,9 @@ if(_matlab_find_mat GREATER -1)
set(Matlab_MAT_LIBRARY_FOUND TRUE)
endif()
endif()
-unset(_matlab_find_mat)
# Component Simulink
-list(FIND Matlab_FIND_COMPONENTS SIMULINK _matlab_find_simulink)
-if(_matlab_find_simulink GREATER -1)
+if("SIMULINK" IN_LIST Matlab_FIND_COMPONENTS)
find_path(
Matlab_SIMULINK_INCLUDE_DIR
simstruc.h
@@ -1496,11 +1751,53 @@ if(_matlab_find_simulink GREATER -1)
list(APPEND Matlab_INCLUDE_DIRS "${Matlab_SIMULINK_INCLUDE_DIR}")
endif()
endif()
-unset(_matlab_find_simulink)
-unset(_matlab_lib_dir_for_search)
+# component Matlab program
+if("MAIN_PROGRAM" IN_LIST Matlab_FIND_COMPONENTS)
+ find_program(
+ Matlab_MAIN_PROGRAM
+ matlab
+ PATHS ${Matlab_ROOT_DIR} ${Matlab_ROOT_DIR}/bin
+ DOC "Matlab main program"
+ NO_DEFAULT_PATH
+ )
+ if(Matlab_MAIN_PROGRAM)
+ set(Matlab_MAIN_PROGRAM_FOUND TRUE)
+ endif()
+endif()
+
+# component Mex Compiler
+if("MEX_COMPILER" IN_LIST Matlab_FIND_COMPONENTS)
+ find_program(
+ Matlab_MEX_COMPILER
+ "mex"
+ PATHS ${Matlab_BINARIES_DIR}
+ DOC "Matlab MEX compiler"
+ NO_DEFAULT_PATH
+ )
+ if(Matlab_MEX_COMPILER)
+ set(Matlab_MEX_COMPILER_FOUND TRUE)
+ endif()
+endif()
-set(Matlab_LIBRARIES ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} ${Matlab_ENG_LIBRARY} ${Matlab_MAT_LIBRARY})
+# component MCC Compiler
+if("MCC_COMPILER" IN_LIST Matlab_FIND_COMPONENTS)
+ find_program(
+ Matlab_MCC_COMPILER
+ "mcc"
+ PATHS ${Matlab_BINARIES_DIR}
+ DOC "Matlab MCC compiler"
+ NO_DEFAULT_PATH
+ )
+ if(Matlab_MCC_COMPILER)
+ set(Matlab_MCC_COMPILER_FOUND TRUE)
+ endif()
+endif()
+
+set(Matlab_LIBRARIES
+ ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY}
+ ${Matlab_ENG_LIBRARY} ${Matlab_MAT_LIBRARY}
+ ${Matlab_DATAARRAY_LIBRARY} ${Matlab_ENGINE_LIBRARY})
find_package_handle_standard_args(
Matlab
@@ -1522,6 +1819,8 @@ if(Matlab_INCLUDE_DIRS AND Matlab_LIBRARIES)
Matlab_MEX_LIBRARY
Matlab_MX_LIBRARY
Matlab_ENG_LIBRARY
+ Matlab_ENGINE_LIBRARY
+ Matlab_DATAARRAY_LIBRARY
Matlab_MAT_LIBRARY
Matlab_INCLUDE_DIRS
Matlab_FOUND
@@ -1530,3 +1829,5 @@ if(Matlab_INCLUDE_DIRS AND Matlab_LIBRARIES)
Matlab_MEX_EXTENSION
)
endif()
+
+cmake_policy(POP)
diff --git a/Modules/FindMotif.cmake b/Modules/FindMotif.cmake
index 7304d957c..4f7080a44 100644
--- a/Modules/FindMotif.cmake
+++ b/Modules/FindMotif.cmake
@@ -1,19 +1,20 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindMotif
-# ---------
-#
-# Try to find Motif (or lesstif)
-#
-# Once done this will define:
-#
-# ::
-#
-# MOTIF_FOUND - system has MOTIF
-# MOTIF_INCLUDE_DIR - include paths to use Motif
-# MOTIF_LIBRARIES - Link these to use Motif
+#[=======================================================================[.rst:
+FindMotif
+---------
+
+Try to find Motif (or lesstif)
+
+Once done this will define:
+
+::
+
+ MOTIF_FOUND - system has MOTIF
+ MOTIF_INCLUDE_DIR - include paths to use Motif
+ MOTIF_LIBRARIES - Link these to use Motif
+#]=======================================================================]
set(MOTIF_FOUND 0)
diff --git a/Modules/FindODBC.cmake b/Modules/FindODBC.cmake
new file mode 100644
index 000000000..3f710dbb9
--- /dev/null
+++ b/Modules/FindODBC.cmake
@@ -0,0 +1,231 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindODBC
+--------
+
+Find an Open Database Connectivity (ODBC) include directory and library.
+
+On Windows, when building with Visual Studio, this module assumes the ODBC
+library is provided by the available Windows SDK.
+
+On Unix, this module allows to search for ODBC library provided by
+unixODBC or iODBC implementations of ODBC API.
+This module reads hint about location of the config program:
+
+.. variable:: ODBC_CONFIG
+
+ Location of odbc_config or iodbc-config program
+
+Otherwise, this module tries to find the config program,
+first from unixODBC, then from iODBC.
+If no config program found, this module searches for ODBC header
+and library in list of known locations.
+
+Imported targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` targets:
+
+.. variable:: ODBC::ODBC
+
+ Imported target for using the ODBC library, if found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+.. variable:: ODBC_FOUND
+
+ Set to true if ODBC library found, otherwise false or undefined.
+
+.. variable:: ODBC_INCLUDE_DIRS
+
+ Paths to include directories listed in one variable for use by ODBC client.
+ May be empty on Windows, where the include directory corresponding to the
+ expected Windows SDK is already available in the compilation environment.
+
+.. variable:: ODBC_LIBRARIES
+
+ Paths to libraries to linked against to use ODBC.
+ May just a library name on Windows, where the library directory corresponding
+ to the expected Windows SDK is already available in the compilation environment.
+
+.. variable:: ODBC_CONFIG
+
+ Path to unixODBC or iODBC config program, if found or specified.
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+For users who wish to edit and control the module behavior, this module
+reads hints about search locations from the following variables:
+
+.. variable:: ODBC_INCLUDE_DIR
+
+ Path to ODBC include directory with ``sql.h`` header.
+
+.. variable:: ODBC_LIBRARY
+
+ Path to ODBC library to be linked.
+
+These variables should not be used directly by project code.
+
+Limitations
+^^^^^^^^^^^
+
+On Windows, this module does not search for iODBC.
+On Unix, there is no way to prefer unixODBC over iODBC, or vice versa,
+other than providing the config program location using the ``ODBC_CONFIG``.
+This module does not allow to search for a specific ODBC driver.
+
+#]=======================================================================]
+
+# Define lists used internally
+set(_odbc_include_paths)
+set(_odbc_lib_paths)
+set(_odbc_lib_names)
+set(_odbc_required_libs_names)
+
+### Try Windows Kits ##########################################################
+if(WIN32)
+ # List names of ODBC libraries on Windows
+ if(NOT MINGW)
+ set(ODBC_LIBRARY odbc32.lib)
+ else()
+ set(ODBC_LIBRARY libodbc32.a)
+ endif()
+ set(_odbc_lib_names odbc32;)
+
+ # List additional libraries required to use ODBC library
+ if(MSVC OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
+ set(_odbc_required_libs_names odbccp32;ws2_32)
+ elseif(MINGW)
+ set(_odbc_required_libs_names odbccp32)
+ endif()
+endif()
+
+### Try unixODBC or iODBC config program ######################################
+if (UNIX)
+ find_program(ODBC_CONFIG
+ NAMES odbc_config iodbc-config
+ DOC "Path to unixODBC or iODBC config program")
+ mark_as_advanced(ODBC_CONFIG)
+endif()
+
+if (UNIX AND ODBC_CONFIG)
+ # unixODBC and iODBC accept unified command line options
+ execute_process(COMMAND ${ODBC_CONFIG} --cflags
+ OUTPUT_VARIABLE _cflags OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND ${ODBC_CONFIG} --libs
+ OUTPUT_VARIABLE _libs OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ # Collect paths of include directories from CFLAGS
+ separate_arguments(_cflags NATIVE_COMMAND "${_cflags}")
+ foreach(arg IN LISTS _cflags)
+ if("${arg}" MATCHES "^-I(.*)$")
+ list(APPEND _odbc_include_paths "${CMAKE_MATCH_1}")
+ endif()
+ endforeach()
+ unset(_cflags)
+
+ # Collect paths of library names and directories from LIBS
+ separate_arguments(_libs NATIVE_COMMAND "${_libs}")
+ foreach(arg IN LISTS _libs)
+ if("${arg}" MATCHES "^-L(.*)$")
+ list(APPEND _odbc_lib_paths "${CMAKE_MATCH_1}")
+ elseif("${arg}" MATCHES "^-l(.*)$")
+ set(_lib_name ${CMAKE_MATCH_1})
+ string(REGEX MATCH "odbc" _is_odbc ${_lib_name})
+ if(_is_odbc)
+ list(APPEND _odbc_lib_names ${_lib_name})
+ else()
+ list(APPEND _odbc_required_libs_names ${_lib_name})
+ endif()
+ unset(_lib_name)
+ endif()
+ endforeach()
+ unset(_libs)
+endif()
+
+### Try unixODBC or iODBC in include/lib filesystems ##########################
+if (UNIX AND NOT ODBC_CONFIG)
+ # List names of both ODBC libraries, unixODBC and iODBC
+ set(_odbc_lib_names odbc;iodbc;unixodbc;)
+endif()
+
+### Find include directories ##################################################
+find_path(ODBC_INCLUDE_DIR
+ NAMES sql.h
+ PATHS ${_odbc_include_paths})
+
+if(NOT ODBC_INCLUDE_DIR AND WIN32)
+ set(ODBC_INCLUDE_DIR "")
+endif()
+
+### Find libraries ############################################################
+if(NOT ODBC_LIBRARY)
+ find_library(ODBC_LIBRARY
+ NAMES ${_odbc_lib_names}
+ PATHS ${_odbc_lib_paths}
+ PATH_SUFFIXES odbc)
+
+ foreach(_lib IN LISTS _odbc_required_libs_names)
+ find_library(_lib_path
+ NAMES ${_lib}
+ PATHS ${_odbc_lib_paths} # system parths or collected from ODBC_CONFIG
+ PATH_SUFFIXES odbc)
+ if(_lib_path)
+ list(APPEND _odbc_required_libs_paths ${_lib_path})
+ endif()
+ unset(_lib_path CACHE)
+ endforeach()
+endif()
+
+# Unset internal lists as no longer used
+unset(_odbc_include_paths)
+unset(_odbc_lib_paths)
+unset(_odbc_lib_names)
+unset(_odbc_required_libs_names)
+
+### Set result variables ######################################################
+set(_odbc_required_vars ODBC_LIBRARY)
+if(NOT WIN32)
+ list(APPEND _odbc_required_vars ODBC_INCLUDE_DIR)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(ODBC DEFAULT_MSG ${_odbc_required_vars})
+
+unset(_odbc_required_vars)
+
+mark_as_advanced(ODBC_LIBRARY ODBC_INCLUDE_DIR)
+
+set(ODBC_INCLUDE_DIRS ${ODBC_INCLUDE_DIR})
+list(APPEND ODBC_LIBRARIES ${ODBC_LIBRARY})
+list(APPEND ODBC_LIBRARIES ${_odbc_required_libs_paths})
+
+### Import targets ############################################################
+if(ODBC_FOUND)
+ if(NOT TARGET ODBC::ODBC)
+ if(IS_ABSOLUTE "${ODBC_LIBRARY}")
+ add_library(ODBC::ODBC UNKNOWN IMPORTED)
+ set_target_properties(ODBC::ODBC PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${ODBC_LIBRARY}")
+ else()
+ add_library(ODBC::ODBC INTERFACE IMPORTED)
+ set_target_properties(ODBC::ODBC PROPERTIES
+ IMPORTED_LIBNAME "${ODBC_LIBRARY}")
+ endif()
+ set_target_properties(ODBC::ODBC PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${ODBC_INCLUDE_DIR}")
+
+ if(_odbc_required_libs_paths)
+ set_property(TARGET ODBC::ODBC APPEND PROPERTY
+ INTERFACE_LINK_LIBRARIES "${_odbc_required_libs_paths}")
+ endif()
+ endif()
+endif()
+
+unset(_odbc_required_libs_paths)
diff --git a/Modules/FindOpenACC.cmake b/Modules/FindOpenACC.cmake
new file mode 100644
index 000000000..743e0e2f0
--- /dev/null
+++ b/Modules/FindOpenACC.cmake
@@ -0,0 +1,283 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindOpenACC
+-----------
+
+Detect OpenACC support by the compiler.
+
+This module can be used to detect OpenACC support in a compiler.
+If the compiler supports OpenACC, the flags required to compile with
+OpenACC support are returned in variables for the different languages.
+Currently, only PGI, GNU and Cray compilers are supported.
+
+Variables
+^^^^^^^^^
+
+This module will set the following variables per language in your
+project, where ``<lang>`` is one of C, CXX, or Fortran:
+
+``OpenACC_<lang>_FOUND``
+ Variable indicating if OpenACC support for ``<lang>`` was detected.
+``OpenACC_<lang>_FLAGS``
+ OpenACC compiler flags for ``<lang>``, separated by spaces.
+``OpenACC_<lang>_OPTIONS``
+ OpenACC compiler flags for ``<lang>``, as a list. Suitable for usage
+ with target_compile_options or target_link_options.
+
+Additionally, the module provides :prop_tgt:`IMPORTED` targets:
+
+``OpenACC::OpenACC_<lang>``
+ Target for using OpenACC from ``<lang>``.
+
+The module will also try to provide the OpenACC version variables:
+
+``OpenACC_<lang>_SPEC_DATE``
+ Date of the OpenACC specification implemented by the ``<lang>`` compiler.
+``OpenACC_<lang>_VERSION_MAJOR``
+ Major version of OpenACC implemented by the ``<lang>`` compiler.
+``OpenACC_<lang>_VERSION_MINOR``
+ Minor version of OpenACC implemented by the ``<lang>`` compiler.
+``OpenACC_<lang>_VERSION``
+ OpenACC version implemented by the ``<lang>`` compiler.
+
+The specification date is formatted as given in the OpenACC standard:
+``yyyymm`` where ``yyyy`` and ``mm`` represents the year and month of
+the OpenACC specification implemented by the ``<lang>`` compiler.
+
+Input Variables
+^^^^^^^^^^^^^^^
+
+``OpenACC_ACCEL_TARGET=<target>``
+If set, will the correct target accelerator flag set to the <target> will
+be returned with OpenACC_<lang>_FLAGS.
+#]=======================================================================]
+
+set(OpenACC_C_CXX_TEST_SOURCE
+"
+int main(){
+#ifdef _OPENACC
+ return 0;
+#else
+ breaks_on_purpose
+#endif
+}
+"
+)
+set(OpenACC_Fortran_TEST_SOURCE
+"
+program test
+#ifndef _OPENACC
+ breaks_on_purpose
+#endif
+endprogram test
+"
+)
+set(OpenACC_C_CXX_CHECK_VERSION_SOURCE
+"
+#include <stdio.h>
+const char accver_str[] = { 'I', 'N', 'F', 'O', ':', 'O', 'p', 'e', 'n', 'A',
+ 'C', 'C', '-', 'd', 'a', 't', 'e', '[',
+ ('0' + ((_OPENACC/100000)%10)),
+ ('0' + ((_OPENACC/10000)%10)),
+ ('0' + ((_OPENACC/1000)%10)),
+ ('0' + ((_OPENACC/100)%10)),
+ ('0' + ((_OPENACC/10)%10)),
+ ('0' + ((_OPENACC/1)%10)),
+ ']', '\\0' };
+int main()
+{
+ puts(accver_str);
+ return 0;
+}
+")
+set(OpenACC_Fortran_CHECK_VERSION_SOURCE
+"
+ program acc_ver
+ implicit none
+ integer, parameter :: zero = ichar('0')
+ character, dimension(25), parameter :: accver_str =&
+ (/ 'I', 'N', 'F', 'O', ':', 'O', 'p', 'e', 'n', 'A', 'C', 'C', '-',&
+ 'd', 'a', 't', 'e', '[',&
+ char(zero + mod(_OPENACC/100000, 10)),&
+ char(zero + mod(_OPENACC/10000, 10)),&
+ char(zero + mod(_OPENACC/1000, 10)),&
+ char(zero + mod(_OPENACC/100, 10)),&
+ char(zero + mod(_OPENACC/10, 10)),&
+ char(zero + mod(_OPENACC/1, 10)), ']' /)
+ print *, accver_str
+ end program acc_ver
+"
+)
+
+
+function(_OPENACC_WRITE_SOURCE_FILE LANG SRC_FILE_CONTENT_VAR SRC_FILE_NAME SRC_FILE_FULLPATH)
+ set(WORK_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenACC)
+ if("${LANG}" STREQUAL "C")
+ set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.c")
+ file(WRITE "${SRC_FILE}" "${OpenACC_C_CXX_${SRC_FILE_CONTENT_VAR}}")
+ elseif("${LANG}" STREQUAL "CXX")
+ set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.cpp")
+ file(WRITE "${SRC_FILE}" "${OpenACC_C_CXX_${SRC_FILE_CONTENT_VAR}}")
+ elseif("${LANG}" STREQUAL "Fortran")
+ set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.F90")
+ file(WRITE "${SRC_FILE}_in" "${OpenACC_Fortran_${SRC_FILE_CONTENT_VAR}}")
+ configure_file("${SRC_FILE}_in" "${SRC_FILE}" @ONLY)
+ endif()
+ set(${SRC_FILE_FULLPATH} "${SRC_FILE}" PARENT_SCOPE)
+endfunction()
+
+
+function(_OPENACC_GET_FLAGS_CANDIDATE LANG FLAG_VAR)
+ set(ACC_FLAG_PGI "-acc")
+ set(ACC_FLAG_GNU "-fopenacc")
+ set(ACC_FLAG_Cray "-h acc")
+
+ if(DEFINED ACC_FLAG_${CMAKE_${LANG}_COMPILER_ID})
+ set("${FLAG_VAR}" "${ACC_FLAG_${CMAKE_${LANG}_COMPILER_ID}}" PARENT_SCOPE)
+ else()
+ # Fall back to a few common flags.
+ set("${FLAG_VAR}" ${ACC_FLAG_GNU} ${ACC_FLAG_PGI})
+ endif()
+
+endfunction()
+
+
+function(_OPENACC_GET_ACCEL_TARGET_FLAG LANG TARGET FLAG_VAR)
+ # Find target accelerator flags.
+ set(ACC_TARGET_FLAG_PGI "-ta")
+ if(DEFINED ACC_TARGET_FLAG_${CMAKE_${LANG}_COMPILER_ID})
+ set("${FLAG_VAR}" "${ACC_TARGET_FLAG_${CMAKE_${LANG}_COMPILER_ID}}=${TARGET}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+
+function(_OPENACC_GET_VERBOSE_FLAG LANG FLAG_VAR)
+ # Find compiler's verbose flag for OpenACC.
+ set(ACC_VERBOSE_FLAG_PGI "-Minfo=accel")
+ if(DEFINED ACC_VERBOSE_FLAG_${CMAKE_${LANG}_COMPILER_ID})
+ set("${FLAG_VAR}" "${ACC_VERBOSE_FLAG_${CMAKE_${LANG}_COMPILER_ID}}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+
+function(_OPENACC_GET_FLAGS LANG FLAG_VAR)
+ set(FLAG_CANDIDATES "")
+ _OPENACC_GET_FLAGS_CANDIDATE("${LANG}" FLAG_CANDIDATES)
+ _OPENACC_WRITE_SOURCE_FILE("${LANG}" "TEST_SOURCE" OpenACCTryFlag _OPENACC_TEST_SRC)
+
+ foreach(FLAG IN LISTS FLAG_CANDIDATES)
+ try_compile(OpenACC_FLAG_TEST_RESULT ${CMAKE_BINARY_DIR} ${_OPENACC_TEST_SRC}
+ CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${FLAG}"
+ OUTPUT_VARIABLE OpenACC_TRY_COMPILE_OUTPUT
+ )
+ if(OpenACC_FLAG_TEST_RESULT)
+ set("${FLAG_VAR}" "${FLAG}")
+ if(DEFINED OpenACC_ACCEL_TARGET)
+ _OPENACC_GET_ACCEL_TARGET_FLAG("${LANG}" "${OpenACC_ACCEL_TARGET}" TARGET_FLAG)
+ string(APPEND "${FLAG_VAR}" " ${TARGET_FLAG}")
+ endif()
+
+ if(CMAKE_VERBOSE_MAKEFILE)
+ # -Minfo=accel prints out OpenACC's messages on optimizations.
+ _OPENACC_GET_VERBOSE_FLAG("${LANG}" OpenACC_VERBOSE_FLAG)
+ string(APPEND "${FLAG_VAR}" " ${OpenACC_VERBOSE_FLAG}")
+ endif()
+ set("${FLAG_VAR}" "${${FLAG_VAR}}" PARENT_SCOPE)
+ break()
+ endif()
+ endforeach()
+
+endfunction()
+
+
+function(_OPENACC_GET_SPEC_DATE LANG SPEC_DATE)
+ _OPENACC_WRITE_SOURCE_FILE("${LANG}" "CHECK_VERSION_SOURCE" OpenACCCheckVersion _OPENACC_TEST_SRC)
+
+ set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenACC/accver_${LANG}.bin")
+ try_compile(OpenACC_SPECTEST_${LANG} "${CMAKE_BINARY_DIR}" "${_OPENACC_TEST_SRC}"
+ CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenACC_${LANG}_FLAGS}"
+ COPY_FILE ${BIN_FILE}
+ OUTPUT_VARIABLE OUTPUT)
+
+ if(${OpenACC_SPECTEST_${LANG}})
+ file(STRINGS ${BIN_FILE} specstr LIMIT_COUNT 1 REGEX "INFO:OpenACC-date")
+ set(regex_spec_date ".*INFO:OpenACC-date\\[0*([^]]*)\\].*")
+ if("${specstr}" MATCHES "${regex_spec_date}")
+ set(${SPEC_DATE} "${CMAKE_MATCH_1}" PARENT_SCOPE)
+ endif()
+ endif()
+endfunction()
+
+
+macro(_OPENACC_SET_VERSION_BY_SPEC_DATE LANG)
+ set(OpenACC_SPEC_DATE_MAP
+ # Combined versions, 2.5 onwards
+ "201510=2.5"
+ # 2013 08 is the corrected version.
+ "201308=2.0"
+ "201306=2.0"
+ "201111=1.0"
+ )
+
+ string(REGEX MATCHALL "${OpenACC_${LANG}_SPEC_DATE}=([0-9]+)\\.([0-9]+)" _version_match "${OpenACC_SPEC_DATE_MAP}")
+ if(NOT _version_match STREQUAL "")
+ set(OpenACC_${LANG}_VERSION_MAJOR ${CMAKE_MATCH_1})
+ set(OpenACC_${LANG}_VERSION_MINOR ${CMAKE_MATCH_2})
+ set(OpenACC_${LANG}_VERSION "${OpenACC_${LANG}_VERSION_MAJOR}.${OpenACC_${LANG}_VERSION_MINOR}")
+ else()
+ unset(OpenACC_${LANG}_VERSION_MAJOR)
+ unset(OpenACC_${LANG}_VERSION_MINOR)
+ unset(OpenACC_${LANG}_VERSION)
+ endif()
+ unset(_version_match)
+ unset(OpenACC_SPEC_DATE_MAP)
+endmacro()
+
+
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+foreach (LANG IN ITEMS C CXX Fortran)
+ if(CMAKE_${LANG}_COMPILER_LOADED)
+ set(OpenACC_${LANG}_FIND_QUIETLY ${OpenACC_FIND_QUIETLY})
+ set(OpenACC_${LANG}_FIND_REQUIRED ${OpenACC_FIND_REQUIRED})
+ set(OpenACC_${LANG}_FIND_VERSION ${OpenACC_FIND_VERSION})
+ set(OpenACC_${LANG}_FIND_VERSION_EXACT ${OpenACC_FIND_VERSION_EXACT})
+
+ if(NOT DEFINED OpenACC_${LANG}_FLAGS)
+ _OPENACC_GET_FLAGS("${LANG}" OpenACC_${LANG}_FLAGS)
+ endif()
+ if(NOT DEFINED OpenACC_${LANG}_OPTIONS)
+ separate_arguments(OpenACC_${LANG}_OPTIONS NATIVE_COMMAND "${OpenACC_${LANG}_FLAGS}")
+ endif()
+ _OPENACC_GET_SPEC_DATE("${LANG}" OpenACC_${LANG}_SPEC_DATE)
+ _OPENACC_SET_VERSION_BY_SPEC_DATE("${LANG}")
+
+ find_package_handle_standard_args(OpenACC_${LANG}
+ REQUIRED_VARS OpenACC_${LANG}_FLAGS
+ VERSION_VAR OpenACC_${LANG}_VERSION
+ )
+ endif()
+endforeach()
+
+foreach (LANG IN ITEMS C CXX Fortran)
+ if(OpenACC_${LANG}_FOUND AND NOT TARGET OpenACC::OpenACC_${LANG})
+ add_library(OpenACC::OpenACC_${LANG} INTERFACE IMPORTED)
+ endif()
+ if(OpenACC_${LANG}_LIBRARIES)
+ set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY
+ INTERFACE_LINK_LIBRARIES "${OpenACC_${LANG}_LIBRARIES}")
+ endif()
+ if(OpenACC_${LANG}_FLAGS)
+ set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY
+ INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:${LANG}>:${OpenACC_${LANG}_OPTIONS}>")
+ set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY
+ INTERFACE_LINK_OPTIONS "$<$<COMPILE_LANGUAGE:${LANG}>:${OpenACC_${LANG}_OPTIONS}>")
+ unset(_OpenACC_${LANG}_OPTIONS)
+ endif()
+endforeach()
+
+unset(OpenACC_C_CXX_TEST_SOURCE)
+unset(OpenACC_Fortran_TEST_SOURCE)
+unset(OpenACC_C_CXX_CHECK_VERSION_SOURCE)
+unset(OpenACC_Fortran_CHECK_VERSION_SOURCE)
diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake
index c3d202ee8..27dcaf5e9 100644
--- a/Modules/FindOpenAL.cmake
+++ b/Modules/FindOpenAL.cmake
@@ -1,21 +1,22 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindOpenAL
-# ----------
-#
-#
-#
-# Locate OpenAL This module defines OPENAL_LIBRARY OPENAL_FOUND, if
-# false, do not try to link to OpenAL OPENAL_INCLUDE_DIR, where to find
-# the headers
-#
-# $OPENALDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OPENALDIR used in building OpenAL.
-#
-# Created by Eric Wing. This was influenced by the FindSDL.cmake
-# module.
+#[=======================================================================[.rst:
+FindOpenAL
+----------
+
+
+Finds Open Audio Library (OpenAL).
+This module defines ``OPENAL_LIBRARY OPENAL_FOUND``, if
+false, do not try to link to OpenAL ``OPENAL_INCLUDE_DIR``, where to find
+the headers.
+
+``$OPENALDIR`` is an environment variable that would correspond to the
+``./configure --prefix=$OPENALDIR`` used in building OpenAL.
+
+Created by Eric Wing. This was influenced by the ``FindSDL.cmake``
+module.
+#]=======================================================================]
# This makes the presumption that you are include al.h like
# #include "al.h"
@@ -58,13 +59,10 @@
find_path(OPENAL_INCLUDE_DIR al.h
HINTS
ENV OPENALDIR
- PATH_SUFFIXES include/AL include/OpenAL include
+ PATH_SUFFIXES include/AL include/OpenAL include AL OpenAL
PATHS
~/Library/Frameworks
/Library/Frameworks
- /sw # Fink
- /opt/local # DarwinPorts
- /opt/csw # Blastwave
/opt
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir]
)
@@ -83,9 +81,6 @@ find_library(OPENAL_LIBRARY
PATHS
~/Library/Frameworks
/Library/Frameworks
- /sw
- /opt/local
- /opt/csw
/opt
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir]
)
diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake
index b8a7d822f..9891724e4 100644
--- a/Modules/FindOpenCL.cmake
+++ b/Modules/FindOpenCL.cmake
@@ -1,35 +1,36 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindOpenCL
-# ----------
-#
-# Try to find OpenCL
-#
-# IMPORTED Targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines :prop_tgt:`IMPORTED` target ``OpenCL::OpenCL``, if
-# OpenCL has been found.
-#
-# Result Variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the following variables::
-#
-# OpenCL_FOUND - True if OpenCL was found
-# OpenCL_INCLUDE_DIRS - include directories for OpenCL
-# OpenCL_LIBRARIES - link against this library to use OpenCL
-# OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2)
-# OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation
-# OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation
-#
-# The module will also define two cache variables::
-#
-# OpenCL_INCLUDE_DIR - the OpenCL include directory
-# OpenCL_LIBRARY - the path to the OpenCL library
-#
+#[=======================================================================[.rst:
+FindOpenCL
+----------
+
+Finds Open Computing Language (OpenCL)
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``OpenCL::OpenCL``, if
+OpenCL has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables::
+
+ OpenCL_FOUND - True if OpenCL was found
+ OpenCL_INCLUDE_DIRS - include directories for OpenCL
+ OpenCL_LIBRARIES - link against this library to use OpenCL
+ OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2)
+ OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation
+ OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation
+
+The module will also define two cache variables::
+
+ OpenCL_INCLUDE_DIR - the OpenCL include directory
+ OpenCL_LIBRARY - the path to the OpenCL library
+
+#]=======================================================================]
function(_FIND_OPENCL_VERSION)
include(CheckSymbolExists)
@@ -37,7 +38,7 @@ function(_FIND_OPENCL_VERSION)
set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY})
CMAKE_PUSH_CHECK_STATE()
- foreach(VERSION "2_0" "1_2" "1_1" "1_0")
+ foreach(VERSION "2_2" "2_1" "2_0" "1_2" "1_1" "1_0")
set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}")
if(APPLE)
@@ -76,6 +77,7 @@ find_path(OpenCL_INCLUDE_DIR
ENV NVSDKCOMPUTE_ROOT
ENV CUDA_PATH
ENV ATISTREAMSDKROOT
+ ENV OCL_ROOT
PATH_SUFFIXES
include
OpenCL/common/inc
@@ -94,6 +96,7 @@ if(WIN32)
ENV CUDA_PATH
ENV NVSDKCOMPUTE_ROOT
ENV ATISTREAMSDKROOT
+ ENV OCL_ROOT
PATH_SUFFIXES
"AMD APP/lib/x86"
lib/x86
@@ -109,6 +112,7 @@ if(WIN32)
ENV CUDA_PATH
ENV NVSDKCOMPUTE_ROOT
ENV ATISTREAMSDKROOT
+ ENV OCL_ROOT
PATH_SUFFIXES
"AMD APP/lib/x86_64"
lib/x86_64
@@ -116,13 +120,27 @@ if(WIN32)
OpenCL/common/lib/x64)
endif()
else()
- find_library(OpenCL_LIBRARY
- NAMES OpenCL
- PATHS
- ENV AMDAPPSDKROOT
- PATH_SUFFIXES
- lib/x86_64
- lib/x64)
+ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ find_library(OpenCL_LIBRARY
+ NAMES OpenCL
+ PATHS
+ ENV AMDAPPSDKROOT
+ ENV CUDA_PATH
+ PATH_SUFFIXES
+ lib/x86
+ lib)
+ elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ find_library(OpenCL_LIBRARY
+ NAMES OpenCL
+ PATHS
+ ENV AMDAPPSDKROOT
+ ENV CUDA_PATH
+ PATH_SUFFIXES
+ lib/x86_64
+ lib/x64
+ lib
+ lib64)
+ endif()
endif()
set(OpenCL_LIBRARIES ${OpenCL_LIBRARY})
diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake
index af83fb735..23bb001de 100644
--- a/Modules/FindOpenGL.cmake
+++ b/Modules/FindOpenGL.cmake
@@ -1,62 +1,140 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindOpenGL
-# ----------
-#
-# FindModule for OpenGL and GLU.
-#
-# IMPORTED Targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the :prop_tgt:`IMPORTED` targets:
-#
-# ``OpenGL::GL``
-# Defined if the system has OpenGL.
-# ``OpenGL::GLU``
-# Defined if the system has GLU.
-#
-# Result Variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module sets the following variables:
-#
-# ``OPENGL_FOUND``
-# True, if the system has OpenGL.
-# ``OPENGL_XMESA_FOUND``
-# True, if the system has XMESA.
-# ``OPENGL_GLU_FOUND``
-# True, if the system has GLU.
-# ``OPENGL_INCLUDE_DIR``
-# Path to the OpenGL include directory.
-# ``OPENGL_LIBRARIES``
-# Paths to the OpenGL and GLU libraries.
-#
-# If you want to use just GL you can use these values:
-#
-# ``OPENGL_gl_LIBRARY``
-# Path to the OpenGL library.
-# ``OPENGL_glu_LIBRARY``
-# Path to the GLU library.
-#
-# OSX Specific
-# ^^^^^^^^^^^^
-#
-# On OSX default to using the framework version of OpenGL. People will
-# have to change the cache values of OPENGL_glu_LIBRARY and
-# OPENGL_gl_LIBRARY to use OpenGL with X11 on OSX.
+#[=======================================================================[.rst:
+FindOpenGL
+----------
+FindModule for OpenGL and OpenGL Utility Library (GLU).
+
+Optional COMPONENTS
+^^^^^^^^^^^^^^^^^^^
+
+This module respects several optional COMPONENTS: ``EGL``, ``GLX``, and
+``OpenGL``. There are corresponding import targets for each of these flags.
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines the :prop_tgt:`IMPORTED` targets:
+
+``OpenGL::GL``
+ Defined to the platform-specific OpenGL libraries if the system has OpenGL.
+``OpenGL::OpenGL``
+ Defined to libOpenGL if the system is GLVND-based.
+``OpenGL::GLU``
+ Defined if the system has OpenGL Utility Library (GLU).
+``OpenGL::GLX``
+ Defined if the system has OpenGL Extension to the X Window System (GLX).
+``OpenGL::EGL``
+ Defined if the system has EGL.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module sets the following variables:
+
+``OPENGL_FOUND``
+ True, if the system has OpenGL and all components are found.
+``OPENGL_XMESA_FOUND``
+ True, if the system has XMESA.
+``OPENGL_GLU_FOUND``
+ True, if the system has GLU.
+``OpenGL_OpenGL_FOUND``
+ True, if the system has an OpenGL library.
+``OpenGL_GLX_FOUND``
+ True, if the system has GLX.
+``OpenGL_EGL_FOUND``
+ True, if the system has EGL.
+``OPENGL_INCLUDE_DIR``
+ Path to the OpenGL include directory.
+``OPENGL_EGL_INCLUDE_DIRS``
+ Path to the EGL include directory.
+``OPENGL_LIBRARIES``
+ Paths to the OpenGL library, windowing system libraries, and GLU libraries.
+ On Linux, this assumes GLX and is never correct for EGL-based targets.
+ Clients are encouraged to use the ``OpenGL::*`` import targets instead.
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``OPENGL_egl_LIBRARY``
+ Path to the EGL library.
+``OPENGL_glu_LIBRARY``
+ Path to the GLU library.
+``OPENGL_glx_LIBRARY``
+ Path to the GLVND 'GLX' library.
+``OPENGL_opengl_LIBRARY``
+ Path to the GLVND 'OpenGL' library
+``OPENGL_gl_LIBRARY``
+ Path to the OpenGL library. New code should prefer the ``OpenGL::*`` import
+ targets.
+
+Linux-specific
+^^^^^^^^^^^^^^
+
+Some Linux systems utilize GLVND as a new ABI for OpenGL. GLVND separates
+context libraries from OpenGL itself; OpenGL lives in "libOpenGL", and
+contexts are defined in "libGLX" or "libEGL". GLVND is currently the only way
+to get OpenGL 3+ functionality via EGL in a manner portable across vendors.
+Projects may use GLVND explicitly with target ``OpenGL::OpenGL`` and either
+``OpenGL::GLX`` or ``OpenGL::EGL``.
+
+Projects may use the ``OpenGL::GL`` target (or ``OPENGL_LIBRARIES`` variable)
+to use legacy GL interfaces. These will use the legacy GL library located
+by ``OPENGL_gl_LIBRARY``, if available. If ``OPENGL_gl_LIBRARY`` is empty or
+not found and GLVND is available, the ``OpenGL::GL`` target will use GLVND
+``OpenGL::OpenGL`` and ``OpenGL::GLX`` (and the ``OPENGL_LIBRARIES``
+variable will use the corresponding libraries). Thus, for non-EGL-based
+Linux targets, the ``OpenGL::GL`` target is most portable.
+
+A ``OpenGL_GL_PREFERENCE`` variable may be set to specify the preferred way
+to provide legacy GL interfaces in case multiple choices are available.
+The value may be one of:
+
+``GLVND``
+ If the GLVND OpenGL and GLX libraries are available, prefer them.
+ This forces ``OPENGL_gl_LIBRARY`` to be empty.
+ This is the default if components were requested (since components
+ correspond to GLVND libraries) or if policy :policy:`CMP0072` is
+ set to ``NEW``.
+
+``LEGACY``
+ Prefer to use the legacy libGL library, if available.
+ This is the default if no components were requested and
+ policy :policy:`CMP0072` is not set to ``NEW``.
+
+For EGL targets the client must rely on GLVND support on the user's system.
+Linking should use the ``OpenGL::OpenGL OpenGL::EGL`` targets. Using GLES*
+libraries is theoretically possible in place of ``OpenGL::OpenGL``, but this
+module does not currently support that; contributions welcome.
+
+``OPENGL_egl_LIBRARY`` and ``OPENGL_EGL_INCLUDE_DIRS`` are defined in the case of
+GLVND. For non-GLVND Linux and other systems these are left undefined.
+
+macOS-Specific
+^^^^^^^^^^^^^^
+
+On OSX FindOpenGL defaults to using the framework version of OpenGL. People
+will have to change the cache values of OPENGL_glu_LIBRARY and
+OPENGL_gl_LIBRARY to use OpenGL with X11 on OSX.
+#]=======================================================================]
set(_OpenGL_REQUIRED_VARS OPENGL_gl_LIBRARY)
-if (CYGWIN)
+# Provide OPENGL_USE_<C> variables for each component.
+foreach(component ${OpenGL_FIND_COMPONENTS})
+ string(TOUPPER ${component} _COMPONENT)
+ set(OPENGL_USE_${_COMPONENT} 1)
+endforeach()
+if (CYGWIN)
find_path(OPENGL_INCLUDE_DIR GL/gl.h )
list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
find_library(OPENGL_gl_LIBRARY opengl32 )
-
find_library(OPENGL_glu_LIBRARY glu32 )
elseif (WIN32)
@@ -70,7 +148,6 @@ elseif (WIN32)
endif()
elseif (APPLE)
-
# The OpenGL.framework provides both gl and glu
find_library(OPENGL_gl_LIBRARY OpenGL DOC "OpenGL library for OS X")
find_library(OPENGL_glu_LIBRARY OpenGL DOC
@@ -104,29 +181,168 @@ else()
# fail since the compiler finds the Mesa headers but NVidia's library.
# Make sure the NVIDIA directory comes BEFORE the others.
# - Atanas Georgiev <atanas@cs.columbia.edu>
-
find_path(OPENGL_INCLUDE_DIR GL/gl.h
/usr/share/doc/NVIDIA_GLX-1.0/include
/usr/openwin/share/include
- /opt/graphics/OpenGL/include /usr/X11R6/include
+ /opt/graphics/OpenGL/include
${_OPENGL_INCLUDE_PATH}
)
- list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
-
+ find_path(OPENGL_GLX_INCLUDE_DIR GL/glx.h ${_OPENGL_INCLUDE_PATH})
+ find_path(OPENGL_EGL_INCLUDE_DIR EGL/egl.h ${_OPENGL_INCLUDE_PATH})
find_path(OPENGL_xmesa_INCLUDE_DIR GL/xmesa.h
/usr/share/doc/NVIDIA_GLX-1.0/include
/usr/openwin/share/include
- /opt/graphics/OpenGL/include /usr/X11R6/include
+ /opt/graphics/OpenGL/include
+ )
+
+ # Search for the GLVND libraries. We do this regardless of COMPONENTS; we'll
+ # take into account the COMPONENTS logic later.
+ find_library(OPENGL_opengl_LIBRARY
+ NAMES OpenGL
+ PATHS ${_OPENGL_LIB_PATH}
+ )
+
+ find_library(OPENGL_glx_LIBRARY
+ NAMES GLX
+ PATHS ${_OPENGL_LIB_PATH}
+ PATH_SUFFIXES libglvnd
)
- find_library(OPENGL_gl_LIBRARY
- NAMES GL MesaGL
- PATHS /opt/graphics/OpenGL/lib
+ find_library(OPENGL_egl_LIBRARY
+ NAMES EGL
+ PATHS ${_OPENGL_LIB_PATH}
+ PATH_SUFFIXES libglvnd
+ )
+
+ find_library(OPENGL_glu_LIBRARY
+ NAMES GLU MesaGLU
+ PATHS ${OPENGL_gl_LIBRARY}
+ /opt/graphics/OpenGL/lib
/usr/openwin/lib
- /usr/shlib /usr/X11R6/lib
- ${_OPENGL_LIB_PATH}
+ /usr/shlib
)
+ set(_OpenGL_GL_POLICY_WARN 0)
+ if(NOT DEFINED OpenGL_GL_PREFERENCE)
+ set(OpenGL_GL_PREFERENCE "")
+ endif()
+ if(NOT OpenGL_GL_PREFERENCE STREQUAL "")
+ # A preference has been explicitly specified.
+ if(NOT OpenGL_GL_PREFERENCE MATCHES "^(GLVND|LEGACY)$")
+ message(FATAL_ERROR
+ "OpenGL_GL_PREFERENCE value '${OpenGL_GL_PREFERENCE}' not recognized. "
+ "Allowed values are 'GLVND' and 'LEGACY'."
+ )
+ endif()
+ elseif(OpenGL_FIND_COMPONENTS)
+ # No preference was explicitly specified, but the caller did request
+ # at least one GLVND component. Prefer GLVND for legacy GL.
+ set(OpenGL_GL_PREFERENCE "GLVND")
+ else()
+ # No preference was explicitly specified and no GLVND components were
+ # requested. Use a policy to choose the default.
+ cmake_policy(GET CMP0072 _OpenGL_GL_POLICY)
+ if("x${_OpenGL_GL_POLICY}x" STREQUAL "xNEWx")
+ set(OpenGL_GL_PREFERENCE "GLVND")
+ else()
+ set(OpenGL_GL_PREFERENCE "LEGACY")
+ if("x${_OpenGL_GL_POLICY}x" STREQUAL "xx")
+ set(_OpenGL_GL_POLICY_WARN 1)
+ endif()
+ endif()
+ unset(_OpenGL_GL_POLICY)
+ endif()
+
+ if("x${OpenGL_GL_PREFERENCE}x" STREQUAL "xGLVNDx" AND OPENGL_opengl_LIBRARY AND OPENGL_glx_LIBRARY)
+ # We can provide legacy GL using GLVND libraries.
+ # Do not use any legacy GL library.
+ set(OPENGL_gl_LIBRARY "")
+ else()
+ # We cannot provide legacy GL using GLVND libraries.
+ # Search for the legacy GL library.
+ find_library(OPENGL_gl_LIBRARY
+ NAMES GL MesaGL
+ PATHS /opt/graphics/OpenGL/lib
+ /usr/openwin/lib
+ /usr/shlib
+ ${_OPENGL_LIB_PATH}
+ PATH_SUFFIXES libglvnd
+ )
+ endif()
+
+ if(_OpenGL_GL_POLICY_WARN AND OPENGL_gl_LIBRARY AND OPENGL_opengl_LIBRARY AND OPENGL_glx_LIBRARY)
+ cmake_policy(GET_WARNING CMP0072 _cmp0072_warning)
+ message(AUTHOR_WARNING
+ "${_cmp0072_warning}\n"
+ "FindOpenGL found both a legacy GL library:\n"
+ " OPENGL_gl_LIBRARY: ${OPENGL_gl_LIBRARY}\n"
+ "and GLVND libraries for OpenGL and GLX:\n"
+ " OPENGL_opengl_LIBRARY: ${OPENGL_opengl_LIBRARY}\n"
+ " OPENGL_glx_LIBRARY: ${OPENGL_glx_LIBRARY}\n"
+ "OpenGL_GL_PREFERENCE has not been set to \"GLVND\" or \"LEGACY\", so for "
+ "compatibility with CMake 3.10 and below the legacy GL library will be used."
+ )
+ endif()
+ unset(_OpenGL_GL_POLICY_WARN)
+
+ # FPHSA cannot handle "this OR that is required", so we conditionally set what
+ # it must look for. First clear any previous config we might have done:
+ set(_OpenGL_REQUIRED_VARS)
+
+ # now we append the libraries as appropriate. The complicated logic
+ # basically comes down to "use libOpenGL when we can, and add in specific
+ # context mechanisms when requested, or we need them to preserve the previous
+ # default where glx is always available."
+ if((NOT OPENGL_USE_EGL AND
+ NOT OPENGL_opengl_LIBRARY AND
+ OPENGL_glx_LIBRARY AND
+ NOT OPENGL_gl_LIBRARY) OR
+ (NOT OPENGL_USE_EGL AND
+ NOT OPENGL_glx_LIBRARY AND
+ NOT OPENGL_gl_LIBRARY) OR
+ (NOT OPENGL_USE_EGL AND
+ OPENGL_opengl_LIBRARY AND
+ OPENGL_glx_LIBRARY) OR
+ ( OPENGL_USE_EGL))
+ list(APPEND _OpenGL_REQUIRED_VARS OPENGL_opengl_LIBRARY)
+ endif()
+
+ # GLVND GLX library. Preferred when available.
+ if((NOT OPENGL_USE_OPENGL AND
+ NOT OPENGL_USE_GLX AND
+ NOT OPENGL_USE_EGL AND
+ NOT OPENGL_glx_LIBRARY AND
+ NOT OPENGL_gl_LIBRARY) OR
+ ( OPENGL_USE_GLX AND
+ NOT OPENGL_USE_EGL AND
+ NOT OPENGL_glx_LIBRARY AND
+ NOT OPENGL_gl_LIBRARY) OR
+ (NOT OPENGL_USE_EGL AND
+ OPENGL_opengl_LIBRARY AND
+ OPENGL_glx_LIBRARY) OR
+ (OPENGL_USE_GLX AND OPENGL_USE_EGL))
+ list(APPEND _OpenGL_REQUIRED_VARS OPENGL_glx_LIBRARY)
+ endif()
+
+ # GLVND EGL library.
+ if(OPENGL_USE_EGL)
+ list(APPEND _OpenGL_REQUIRED_VARS OPENGL_egl_LIBRARY)
+ endif()
+
+ # Old-style "libGL" library: used as a fallback when GLVND isn't available.
+ if((NOT OPENGL_USE_EGL AND
+ NOT OPENGL_opengl_LIBRARY AND
+ OPENGL_glx_LIBRARY AND
+ OPENGL_gl_LIBRARY) OR
+ (NOT OPENGL_USE_EGL AND
+ NOT OPENGL_glx_LIBRARY AND
+ OPENGL_gl_LIBRARY))
+ list(APPEND _OpenGL_REQUIRED_VARS OPENGL_gl_LIBRARY)
+ endif()
+
+ # We always need the 'gl.h' include dir.
+ list(APPEND _OpenGL_REQUIRED_VARS OPENGL_INCLUDE_DIR)
+
unset(_OPENGL_INCLUDE_PATH)
unset(_OPENGL_LIB_PATH)
@@ -135,44 +351,91 @@ else()
PATHS ${OPENGL_gl_LIBRARY}
/opt/graphics/OpenGL/lib
/usr/openwin/lib
- /usr/shlib /usr/X11R6/lib
+ /usr/shlib
)
-
endif ()
-if(OPENGL_gl_LIBRARY)
+if(OPENGL_xmesa_INCLUDE_DIR)
+ set( OPENGL_XMESA_FOUND "YES" )
+else()
+ set( OPENGL_XMESA_FOUND "NO" )
+endif()
- if(OPENGL_xmesa_INCLUDE_DIR)
- set( OPENGL_XMESA_FOUND "YES" )
- else()
- set( OPENGL_XMESA_FOUND "NO" )
- endif()
+if(OPENGL_glu_LIBRARY)
+ set( OPENGL_GLU_FOUND "YES" )
+else()
+ set( OPENGL_GLU_FOUND "NO" )
+endif()
- set( OPENGL_LIBRARIES ${OPENGL_gl_LIBRARY} ${OPENGL_LIBRARIES})
- if(OPENGL_glu_LIBRARY)
- set( OPENGL_GLU_FOUND "YES" )
- if(NOT "${OPENGL_glu_LIBRARY}" STREQUAL "${OPENGL_gl_LIBRARY}")
- set( OPENGL_LIBRARIES ${OPENGL_glu_LIBRARY} ${OPENGL_LIBRARIES} )
- endif()
- else()
- set( OPENGL_GLU_FOUND "NO" )
- endif()
+# OpenGL_OpenGL_FOUND is a bit unique in that it is okay if /either/ libOpenGL
+# or libGL is found.
+# Using libGL with libEGL is never okay, though; we handle that case later.
+if(NOT OPENGL_opengl_LIBRARY AND NOT OPENGL_gl_LIBRARY)
+ set(OpenGL_OpenGL_FOUND FALSE)
+else()
+ set(OpenGL_OpenGL_FOUND TRUE)
+endif()
- # This deprecated setting is for backward compatibility with CMake1.4
- set (OPENGL_LIBRARY ${OPENGL_LIBRARIES})
+if(OPENGL_glx_LIBRARY AND OPENGL_GLX_INCLUDE_DIR)
+ set(OpenGL_GLX_FOUND TRUE)
+else()
+ set(OpenGL_GLX_FOUND FALSE)
+endif()
+if(OPENGL_egl_LIBRARY AND OPENGL_EGL_INCLUDE_DIR)
+ set(OpenGL_EGL_FOUND TRUE)
+else()
+ set(OpenGL_EGL_FOUND FALSE)
endif()
-# This deprecated setting is for backward compatibility with CMake1.4
-set(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR})
+# User-visible names should be plural.
+if(OPENGL_EGL_INCLUDE_DIR)
+ set(OPENGL_EGL_INCLUDE_DIRS ${OPENGL_EGL_INCLUDE_DIR})
+endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL REQUIRED_VARS ${_OpenGL_REQUIRED_VARS})
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenGL REQUIRED_VARS ${_OpenGL_REQUIRED_VARS}
+ HANDLE_COMPONENTS)
unset(_OpenGL_REQUIRED_VARS)
# OpenGL:: targets
if(OPENGL_FOUND)
- if(NOT TARGET OpenGL::GL)
+ # ::OpenGL is a GLVND library, and thus Linux-only: we don't bother checking
+ # for a framework version of this library.
+ if(OPENGL_opengl_LIBRARY AND NOT TARGET OpenGL::OpenGL)
+ if(IS_ABSOLUTE "${OPENGL_opengl_LIBRARY}")
+ add_library(OpenGL::OpenGL UNKNOWN IMPORTED)
+ set_target_properties(OpenGL::OpenGL PROPERTIES IMPORTED_LOCATION
+ "${OPENGL_opengl_LIBRARY}")
+ else()
+ add_library(OpenGL::OpenGL INTERFACE IMPORTED)
+ set_target_properties(OpenGL::OpenGL PROPERTIES IMPORTED_LIBNAME
+ "${OPENGL_opengl_LIBRARY}")
+ endif()
+ set_target_properties(OpenGL::OpenGL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
+ "${OPENGL_INCLUDE_DIR}")
+ endif()
+
+ # ::GLX is a GLVND library, and thus Linux-only: we don't bother checking
+ # for a framework version of this library.
+ if(OpenGL_GLX_FOUND AND NOT TARGET OpenGL::GLX)
+ if(IS_ABSOLUTE "${OPENGL_glx_LIBRARY}")
+ add_library(OpenGL::GLX UNKNOWN IMPORTED)
+ set_target_properties(OpenGL::GLX PROPERTIES IMPORTED_LOCATION
+ "${OPENGL_glx_LIBRARY}")
+ else()
+ add_library(OpenGL::GLX INTERFACE IMPORTED)
+ set_target_properties(OpenGL::GLX PROPERTIES IMPORTED_LIBNAME
+ "${OPENGL_glx_LIBRARY}")
+ endif()
+ set_target_properties(OpenGL::GLX PROPERTIES INTERFACE_LINK_LIBRARIES
+ OpenGL::OpenGL)
+ set_target_properties(OpenGL::GLX PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
+ "${OPENGL_GLX_INCLUDE_DIR}")
+ endif()
+
+ if(OPENGL_gl_LIBRARY AND NOT TARGET OpenGL::GL)
+ # A legacy GL library is available, so use it for the legacy GL target.
if(IS_ABSOLUTE "${OPENGL_gl_LIBRARY}")
add_library(OpenGL::GL UNKNOWN IMPORTED)
if(OPENGL_gl_LIBRARY MATCHES "/([^/]+)\\.framework$")
@@ -193,6 +456,38 @@ if(OPENGL_FOUND)
endif()
set_target_properties(OpenGL::GL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}")
+ elseif(NOT TARGET OpenGL::GL AND TARGET OpenGL::OpenGL AND TARGET OpenGL::GLX)
+ # A legacy GL library is not available, but we can provide the legacy GL
+ # target using GLVND OpenGL+GLX.
+ add_library(OpenGL::GL INTERFACE IMPORTED)
+ set_target_properties(OpenGL::GL PROPERTIES INTERFACE_LINK_LIBRARIES
+ OpenGL::OpenGL)
+ set_property(TARGET OpenGL::GL APPEND PROPERTY INTERFACE_LINK_LIBRARIES
+ OpenGL::GLX)
+ set_target_properties(OpenGL::GL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
+ "${OPENGL_INCLUDE_DIR}")
+ endif()
+
+ # ::EGL is a GLVND library, and thus Linux-only: we don't bother checking
+ # for a framework version of this library.
+ # Note we test for OpenGL::OpenGL as a target. When this module is updated to
+ # support GLES, we would additionally want to check for the hypothetical GLES
+ # target and enable EGL if either ::GLES or ::OpenGL is created.
+ if(TARGET OpenGL::OpenGL AND OpenGL_EGL_FOUND AND NOT TARGET OpenGL::EGL)
+ if(IS_ABSOLUTE "${OPENGL_egl_LIBRARY}")
+ add_library(OpenGL::EGL UNKNOWN IMPORTED)
+ set_target_properties(OpenGL::EGL PROPERTIES IMPORTED_LOCATION
+ "${OPENGL_egl_LIBRARY}")
+ else()
+ add_library(OpenGL::EGL INTERFACE IMPORTED)
+ set_target_properties(OpenGL::EGL PROPERTIES IMPORTED_LIBNAME
+ "${OPENGL_egl_LIBRARY}")
+ endif()
+ set_target_properties(OpenGL::EGL PROPERTIES INTERFACE_LINK_LIBRARIES
+ OpenGL::OpenGL)
+ # Note that EGL's include directory is different from OpenGL/GLX's!
+ set_target_properties(OpenGL::EGL PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
+ "${OPENGL_EGL_INCLUDE_DIR}")
endif()
if(OPENGL_GLU_FOUND AND NOT TARGET OpenGL::GLU)
@@ -217,11 +512,34 @@ if(OPENGL_FOUND)
set_target_properties(OpenGL::GLU PROPERTIES
INTERFACE_LINK_LIBRARIES OpenGL::GL)
endif()
+
+ # OPENGL_LIBRARIES mirrors OpenGL::GL's logic ...
+ if(OPENGL_gl_LIBRARY)
+ set(OPENGL_LIBRARIES ${OPENGL_gl_LIBRARY})
+ elseif(TARGET OpenGL::OpenGL AND TARGET OpenGL::GLX)
+ set(OPENGL_LIBRARIES ${OPENGL_opengl_LIBRARY} ${OPENGL_glx_LIBRARY})
+ else()
+ set(OPENGL_LIBRARIES "")
+ endif()
+ # ... and also includes GLU, if available.
+ if(TARGET OpenGL::GLU)
+ list(APPEND OPENGL_LIBRARIES ${OPENGL_glu_LIBRARY})
+ endif()
endif()
+# This deprecated setting is for backward compatibility with CMake1.4
+set(OPENGL_LIBRARY ${OPENGL_LIBRARIES})
+# This deprecated setting is for backward compatibility with CMake1.4
+set(OPENGL_INCLUDE_PATH ${OPENGL_INCLUDE_DIR})
+
mark_as_advanced(
OPENGL_INCLUDE_DIR
OPENGL_xmesa_INCLUDE_DIR
+ OPENGL_egl_LIBRARY
OPENGL_glu_LIBRARY
+ OPENGL_glx_LIBRARY
OPENGL_gl_LIBRARY
+ OPENGL_opengl_LIBRARY
+ OPENGL_EGL_INCLUDE_DIR
+ OPENGL_GLX_INCLUDE_DIR
)
diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake
index ee74a1afe..90d1c3e92 100644
--- a/Modules/FindOpenMP.cmake
+++ b/Modules/FindOpenMP.cmake
@@ -1,77 +1,94 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindOpenMP
-# ----------
-#
-# Finds OpenMP support
-#
-# This module can be used to detect OpenMP support in a compiler. If
-# the compiler supports OpenMP, the flags required to compile with
-# OpenMP support are returned in variables for the different languages.
-# The variables may be empty if the compiler does not need a special
-# flag to support OpenMP.
-#
-# Variables
-# ^^^^^^^^^
-#
-# This module will set the following variables per language in your
-# project, where ``<lang>`` is one of C, CXX, or Fortran:
-#
-# ``OpenMP_<lang>_FOUND``
-# Variable indicating if OpenMP support for ``<lang>`` was detected.
-# ``OpenMP_<lang>_FLAGS``
-# OpenMP compiler flags for ``<lang>``, separated by spaces.
-#
-# For linking with OpenMP code written in ``<lang>``, the following
-# variables are provided:
-#
-# ``OpenMP_<lang>_LIB_NAMES``
-# :ref:`;-list <CMake Language Lists>` of libraries for OpenMP programs for ``<lang>``.
-# ``OpenMP_<libname>_LIBRARY``
-# Location of the individual libraries needed for OpenMP support in ``<lang>``.
-# ``OpenMP_<lang>_LIBRARIES``
-# A list of libraries needed to link with OpenMP code written in ``<lang>``.
-#
-# Additionally, the module provides :prop_tgt:`IMPORTED` targets:
-#
-# ``OpenMP::OpenMP_<lang>``
-# Target for using OpenMP from ``<lang>``.
-#
-# Specifically for Fortran, the module sets the following variables:
-#
-# ``OpenMP_Fortran_HAVE_OMPLIB_HEADER``
-# Boolean indicating if OpenMP is accessible through ``omp_lib.h``.
-# ``OpenMP_Fortran_HAVE_OMPLIB_MODULE``
-# Boolean indicating if OpenMP is accessible through the ``omp_lib`` Fortran module.
-#
-# The module will also try to provide the OpenMP version variables:
-#
-# ``OpenMP_<lang>_SPEC_DATE``
-# Date of the OpenMP specification implemented by the ``<lang>`` compiler.
-# ``OpenMP_<lang>_VERSION_MAJOR``
-# Major version of OpenMP implemented by the ``<lang>`` compiler.
-# ``OpenMP_<lang>_VERSION_MINOR``
-# Minor version of OpenMP implemented by the ``<lang>`` compiler.
-# ``OpenMP_<lang>_VERSION``
-# OpenMP version implemented by the ``<lang>`` compiler.
-#
-# The specification date is formatted as given in the OpenMP standard:
-# ``yyyymm`` where ``yyyy`` and ``mm`` represents the year and month of
-# the OpenMP specification implemented by the ``<lang>`` compiler.
-#
-# Backward Compatibility
-# ^^^^^^^^^^^^^^^^^^^^^^
-#
-# For backward compatibility with older versions of FindOpenMP, these
-# variables are set, but deprecated::
-#
-# OpenMP_FOUND
-#
-# In new projects, please use the ``OpenMP_<lang>_XXX`` equivalents.
+#[=======================================================================[.rst:
+FindOpenMP
+----------
+
+Finds Open Multi-Processing (OpenMP) support.
+
+This module can be used to detect OpenMP support in a compiler. If
+the compiler supports OpenMP, the flags required to compile with
+OpenMP support are returned in variables for the different languages.
+The variables may be empty if the compiler does not need a special
+flag to support OpenMP.
+
+Variables
+^^^^^^^^^
+
+The module exposes the components ``C``, ``CXX``, and ``Fortran``.
+Each of these controls the various languages to search OpenMP support for.
+
+Depending on the enabled components the following variables will be set:
+
+``OpenMP_FOUND``
+ Variable indicating that OpenMP flags for all requested languages have been found.
+ If no components are specified, this is true if OpenMP settings for all enabled languages
+ were detected.
+``OpenMP_VERSION``
+ Minimal version of the OpenMP standard detected among the requested languages,
+ or all enabled languages if no components were specified.
+
+This module will set the following variables per language in your
+project, where ``<lang>`` is one of C, CXX, or Fortran:
+
+``OpenMP_<lang>_FOUND``
+ Variable indicating if OpenMP support for ``<lang>`` was detected.
+``OpenMP_<lang>_FLAGS``
+ OpenMP compiler flags for ``<lang>``, separated by spaces.
+``OpenMP_<lang>_INCLUDE_DIRS``
+ Directories that must be added to the header search path for ``<lang>``
+ when using OpenMP.
+
+For linking with OpenMP code written in ``<lang>``, the following
+variables are provided:
+
+``OpenMP_<lang>_LIB_NAMES``
+ :ref:`;-list <CMake Language Lists>` of libraries for OpenMP programs for ``<lang>``.
+``OpenMP_<libname>_LIBRARY``
+ Location of the individual libraries needed for OpenMP support in ``<lang>``.
+``OpenMP_<lang>_LIBRARIES``
+ A list of libraries needed to link with OpenMP code written in ``<lang>``.
+
+Additionally, the module provides :prop_tgt:`IMPORTED` targets:
+
+``OpenMP::OpenMP_<lang>``
+ Target for using OpenMP from ``<lang>``.
+
+Specifically for Fortran, the module sets the following variables:
+
+``OpenMP_Fortran_HAVE_OMPLIB_HEADER``
+ Boolean indicating if OpenMP is accessible through ``omp_lib.h``.
+``OpenMP_Fortran_HAVE_OMPLIB_MODULE``
+ Boolean indicating if OpenMP is accessible through the ``omp_lib`` Fortran module.
+
+The module will also try to provide the OpenMP version variables:
+
+``OpenMP_<lang>_SPEC_DATE``
+ Date of the OpenMP specification implemented by the ``<lang>`` compiler.
+``OpenMP_<lang>_VERSION_MAJOR``
+ Major version of OpenMP implemented by the ``<lang>`` compiler.
+``OpenMP_<lang>_VERSION_MINOR``
+ Minor version of OpenMP implemented by the ``<lang>`` compiler.
+``OpenMP_<lang>_VERSION``
+ OpenMP version implemented by the ``<lang>`` compiler.
+
+The specification date is formatted as given in the OpenMP standard:
+``yyyymm`` where ``yyyy`` and ``mm`` represents the year and month of
+the OpenMP specification implemented by the ``<lang>`` compiler.
+
+For some compilers, it may be necessary to add a header search path to find
+the relevant OpenMP headers. This location may be language-specific. Where
+this is needed, the module may attempt to find the location, but it can be
+provided directly by setting the ``OpenMP_<lang>_INCLUDE_DIR`` cache variable.
+Note that this variable is an _input_ control to the module. Project code
+should use the ``OpenMP_<lang>_INCLUDE_DIRS`` _output_ variable if it needs
+to know what include directories are needed.
+#]=======================================================================]
cmake_policy(PUSH)
+cmake_policy(SET CMP0012 NEW) # if() recognizes numbers and booleans
+cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced
cmake_policy(SET CMP0057 NEW) # if IN_LIST
function(_OPENMP_FLAG_CANDIDATES LANG)
@@ -80,6 +97,7 @@ function(_OPENMP_FLAG_CANDIDATES LANG)
set(OMP_FLAG_GNU "-fopenmp")
set(OMP_FLAG_Clang "-fopenmp=libomp" "-fopenmp=libiomp5" "-fopenmp")
+ set(OMP_FLAG_AppleClang "-Xclang -fopenmp")
set(OMP_FLAG_HP "+Oopenmp")
if(WIN32)
set(OMP_FLAG_Intel "-Qopenmp")
@@ -89,16 +107,16 @@ function(_OPENMP_FLAG_CANDIDATES LANG)
else()
set(OMP_FLAG_Intel "-qopenmp")
endif()
- set(OMP_FLAG_MIPSpro "-mp")
set(OMP_FLAG_MSVC "-openmp")
set(OMP_FLAG_PathScale "-openmp")
set(OMP_FLAG_NAG "-openmp")
set(OMP_FLAG_Absoft "-openmp")
set(OMP_FLAG_PGI "-mp")
+ set(OMP_FLAG_Flang "-fopenmp")
set(OMP_FLAG_SunPro "-xopenmp")
set(OMP_FLAG_XL "-qsmp=omp")
- # Cray compiles with OpenMP automatically
- set(OMP_FLAG_Cray " ")
+ # Cray compiler activate OpenMP with -h omp, which is enabled by default.
+ set(OMP_FLAG_Cray " " "-h omp")
# If we know the correct flags, use those
if(DEFINED OMP_FLAG_${CMAKE_${LANG}_COMPILER_ID})
@@ -117,8 +135,13 @@ endfunction()
set(OpenMP_C_CXX_TEST_SOURCE
"
#include <omp.h>
-int main() {
-#ifndef _OPENMP
+int main(void) {
+#ifdef _OPENMP
+ omp_get_max_threads();
+ return 0;
+#elif defined(__HIP_DEVICE_COMPILE__)
+ return 0;
+#else
breaks_on_purpose
#endif
}
@@ -155,20 +178,29 @@ function(_OPENMP_WRITE_SOURCE_FILE LANG SRC_FILE_CONTENT_VAR SRC_FILE_NAME SRC_F
set(${SRC_FILE_FULLPATH} "${SRC_FILE}" PARENT_SCOPE)
endfunction()
-include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseImplicitLinkInfo.cmake)
function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR)
_OPENMP_FLAG_CANDIDATES("${LANG}")
_OPENMP_WRITE_SOURCE_FILE("${LANG}" "TEST_SOURCE" OpenMPTryFlag _OPENMP_TEST_SRC)
+ unset(OpenMP_VERBOSE_COMPILE_OPTIONS)
+ separate_arguments(OpenMP_VERBOSE_OPTIONS NATIVE_COMMAND "${CMAKE_${LANG}_VERBOSE_FLAG}")
+ foreach(_VERBOSE_OPTION IN LISTS OpenMP_VERBOSE_OPTIONS)
+ if(NOT _VERBOSE_OPTION MATCHES "^-Wl,")
+ list(APPEND OpenMP_VERBOSE_COMPILE_OPTIONS ${_VERBOSE_OPTION})
+ endif()
+ endforeach()
+
foreach(OPENMP_FLAG IN LISTS OpenMP_${LANG}_FLAG_CANDIDATES)
set(OPENMP_FLAGS_TEST "${OPENMP_FLAG}")
- if(CMAKE_${LANG}_VERBOSE_FLAG)
- string(APPEND OPENMP_FLAGS_TEST " ${CMAKE_${LANG}_VERBOSE_FLAG}")
+ if(OpenMP_VERBOSE_COMPILE_OPTIONS)
+ string(APPEND OPENMP_FLAGS_TEST " ${OpenMP_VERBOSE_COMPILE_OPTIONS}")
endif()
string(REGEX REPLACE "[-/=+]" "" OPENMP_PLAIN_FLAG "${OPENMP_FLAG}")
try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC}
CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}"
+ LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG}
OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT
)
@@ -197,34 +229,85 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR)
unset(_OPENMP_LIB_NAMES)
foreach(_OPENMP_IMPLICIT_LIB IN LISTS OpenMP_${LANG}_IMPLICIT_LIBRARIES)
- if(NOT "${_OPENMP_IMPLICIT_LIB}" IN_LIST CMAKE_${LANG}_IMPLICIT_LINK_LIBRARIES)
- find_library(OpenMP_${_OPENMP_IMPLICIT_LIB}_LIBRARY
- NAMES "${_OPENMP_IMPLICIT_LIB}"
- HINTS ${OpenMP_${LANG}_IMPLICIT_LINK_DIRS}
- )
- mark_as_advanced(OpenMP_${_OPENMP_IMPLICIT_LIB}_LIBRARY)
- list(APPEND _OPENMP_LIB_NAMES ${_OPENMP_IMPLICIT_LIB})
+ get_filename_component(_OPENMP_IMPLICIT_LIB_DIR "${_OPENMP_IMPLICIT_LIB}" DIRECTORY)
+ get_filename_component(_OPENMP_IMPLICIT_LIB_NAME "${_OPENMP_IMPLICIT_LIB}" NAME)
+ get_filename_component(_OPENMP_IMPLICIT_LIB_PLAIN "${_OPENMP_IMPLICIT_LIB}" NAME_WE)
+ string(REGEX REPLACE "([][+.*?()^$])" "\\\\\\1" _OPENMP_IMPLICIT_LIB_PLAIN_ESC "${_OPENMP_IMPLICIT_LIB_PLAIN}")
+ string(REGEX REPLACE "([][+.*?()^$])" "\\\\\\1" _OPENMP_IMPLICIT_LIB_PATH_ESC "${_OPENMP_IMPLICIT_LIB}")
+ if(NOT ( "${_OPENMP_IMPLICIT_LIB}" IN_LIST CMAKE_${LANG}_IMPLICIT_LINK_LIBRARIES
+ OR "${CMAKE_${LANG}_STANDARD_LIBRARIES}" MATCHES "(^| )(-Wl,)?(-l)?(${_OPENMP_IMPLICIT_LIB_PLAIN_ESC}|${_OPENMP_IMPLICIT_LIB_PATH_ESC})( |$)"
+ OR "${CMAKE_${LANG}_LINK_EXECUTABLE}" MATCHES "(^| )(-Wl,)?(-l)?(${_OPENMP_IMPLICIT_LIB_PLAIN_ESC}|${_OPENMP_IMPLICIT_LIB_PATH_ESC})( |$)" ) )
+ if(_OPENMP_IMPLICIT_LIB_DIR)
+ set(OpenMP_${_OPENMP_IMPLICIT_LIB_PLAIN}_LIBRARY "${_OPENMP_IMPLICIT_LIB}" CACHE FILEPATH
+ "Path to the ${_OPENMP_IMPLICIT_LIB_PLAIN} library for OpenMP")
+ else()
+ find_library(OpenMP_${_OPENMP_IMPLICIT_LIB_PLAIN}_LIBRARY
+ NAMES "${_OPENMP_IMPLICIT_LIB_NAME}"
+ DOC "Path to the ${_OPENMP_IMPLICIT_LIB_PLAIN} library for OpenMP"
+ HINTS ${OpenMP_${LANG}_IMPLICIT_LINK_DIRS}
+ CMAKE_FIND_ROOT_PATH_BOTH
+ NO_DEFAULT_PATH
+ )
+ endif()
+ mark_as_advanced(OpenMP_${_OPENMP_IMPLICIT_LIB_PLAIN}_LIBRARY)
+ list(APPEND _OPENMP_LIB_NAMES ${_OPENMP_IMPLICIT_LIB_PLAIN})
endif()
endforeach()
set("${OPENMP_LIB_NAMES_VAR}" "${_OPENMP_LIB_NAMES}" PARENT_SCOPE)
else()
- # The Intel compiler on windows has no verbose mode, so we need to treat it explicitly
- if("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "Intel" AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
- set("${OPENMP_LIB_NAMES_VAR}" "libiomp5md" PARENT_SCOPE)
- find_library(OpenMP_libiomp5md_LIBRARY
- NAMES "libiomp5md"
- HINTS ${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}
- )
- mark_as_advanced(OpenMP_libiomp5md_LIBRARY)
- else()
- set("${OPENMP_LIB_NAMES_VAR}" "" PARENT_SCOPE)
- endif()
+ # We do not know how to extract implicit OpenMP libraries for this compiler.
+ # Assume that it handles them automatically, e.g. the Intel Compiler on
+ # Windows should put the dependency in its object files.
+ set("${OPENMP_LIB_NAMES_VAR}" "" PARENT_SCOPE)
endif()
break()
+ elseif(CMAKE_${LANG}_COMPILER_ID STREQUAL "AppleClang"
+ AND CMAKE_${LANG}_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0")
+
+ # Check for separate OpenMP library on AppleClang 7+
+ find_library(OpenMP_libomp_LIBRARY
+ NAMES omp gomp iomp5
+ HINTS ${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}
+ )
+ mark_as_advanced(OpenMP_libomp_LIBRARY)
+
+ if(OpenMP_libomp_LIBRARY)
+ # Try without specifying include directory first. We only want to
+ # explicitly add a search path if the header can't be found on the
+ # default header search path already.
+ try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC}
+ CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}"
+ LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY}
+ OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT
+ )
+ if(NOT OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG})
+ find_path(OpenMP_${LANG}_INCLUDE_DIR omp.h)
+ mark_as_advanced(OpenMP_${LANG}_INCLUDE_DIR)
+ set(OpenMP_${LANG}_INCLUDE_DIR "${OpenMP_${LANG}_INCLUDE_DIR}" PARENT_SCOPE)
+ if(OpenMP_${LANG}_INCLUDE_DIR)
+ try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC}
+ CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}"
+ "-DINCLUDE_DIRECTORIES:STRING=${OpenMP_${LANG}_INCLUDE_DIR}"
+ LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY}
+ OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT
+ )
+ endif()
+ endif()
+ if(OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG})
+ set("${OPENMP_FLAG_VAR}" "${OPENMP_FLAG}" PARENT_SCOPE)
+ set("${OPENMP_LIB_NAMES_VAR}" "libomp" PARENT_SCOPE)
+ break()
+ endif()
+ endif()
+ else()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Detecting ${LANG} OpenMP failed with the following output:\n${OpenMP_TRY_COMPILE_OUTPUT}\n\n")
endif()
set("${OPENMP_LIB_NAMES_VAR}" "NOTFOUND" PARENT_SCOPE)
set("${OPENMP_FLAG_VAR}" "NOTFOUND" PARENT_SCOPE)
endforeach()
+
+ unset(OpenMP_VERBOSE_COMPILE_OPTIONS)
endfunction()
set(OpenMP_C_CXX_CHECK_VERSION_SOURCE
@@ -240,9 +323,10 @@ const char ompver_str[] = { 'I', 'N', 'F', 'O', ':', 'O', 'p', 'e', 'n', 'M',
('0' + ((_OPENMP/10)%10)),
('0' + ((_OPENMP/1)%10)),
']', '\\0' };
-int main()
+int main(void)
{
puts(ompver_str);
+ return 0;
}
")
@@ -268,11 +352,17 @@ set(OpenMP_Fortran_CHECK_VERSION_SOURCE
function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE)
_OPENMP_WRITE_SOURCE_FILE("${LANG}" "CHECK_VERSION_SOURCE" OpenMPCheckVersion _OPENMP_TEST_SRC)
+ unset(_includeDirFlags)
+ if(OpenMP_${LANG}_INCLUDE_DIR)
+ set(_includeDirFlags "-DINCLUDE_DIRECTORIES:STRING=${OpenMP_${LANG}_INCLUDE_DIR}")
+ endif()
+
set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP/ompver_${LANG}.bin")
string(REGEX REPLACE "[-/=+]" "" OPENMP_PLAIN_FLAG "${OPENMP_FLAG}")
try_compile(OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG} "${CMAKE_BINARY_DIR}" "${_OPENMP_TEST_SRC}"
- CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}"
- COPY_FILE ${BIN_FILE})
+ CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}" ${_includeDirFlags}
+ COPY_FILE ${BIN_FILE}
+ OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT)
if(${OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG}})
file(STRINGS ${BIN_FILE} specstr LIMIT_COUNT 1 REGEX "INFO:OpenMP-date")
@@ -280,12 +370,18 @@ function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE)
if("${specstr}" MATCHES "${regex_spec_date}")
set(${SPEC_DATE} "${CMAKE_MATCH_1}" PARENT_SCOPE)
endif()
+ else()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Detecting ${LANG} OpenMP version failed with the following output:\n${OpenMP_TRY_COMPILE_OUTPUT}\n\n")
endif()
endfunction()
macro(_OPENMP_SET_VERSION_BY_SPEC_DATE LANG)
set(OpenMP_SPEC_DATE_MAP
+ # Preview versions
+ "201611=5.0" # OpenMP 5.0 preview 1
# Combined versions, 2.5 onwards
+ "201811=5.0"
"201511=4.5"
"201307=4.0"
"201107=3.1"
@@ -302,8 +398,15 @@ macro(_OPENMP_SET_VERSION_BY_SPEC_DATE LANG)
# Fortran version 1.0
"199710=1.0"
)
+ if(MSVC)
+ list(APPEND OpenMP_SPEC_DATE_MAP "2019=2.0")
+ endif()
- string(REGEX MATCHALL "${OpenMP_${LANG}_SPEC_DATE}=([0-9]+)\\.([0-9]+)" _version_match "${OpenMP_SPEC_DATE_MAP}")
+ if(OpenMP_${LANG}_SPEC_DATE)
+ string(REGEX MATCHALL "${OpenMP_${LANG}_SPEC_DATE}=([0-9]+)\\.([0-9]+)" _version_match "${OpenMP_SPEC_DATE_MAP}")
+ else()
+ set(_version_match "")
+ endif()
if(NOT _version_match STREQUAL "")
set(OpenMP_${LANG}_VERSION_MAJOR ${CMAKE_MATCH_1})
set(OpenMP_${LANG}_VERSION_MINOR ${CMAKE_MATCH_2})
@@ -372,19 +475,25 @@ if(CMAKE_Fortran_COMPILER_LOADED)
endif()
endif()
-set(OPENMP_FOUND TRUE)
+if(NOT OpenMP_FIND_COMPONENTS)
+ set(OpenMP_FINDLIST C CXX Fortran)
+else()
+ set(OpenMP_FINDLIST ${OpenMP_FIND_COMPONENTS})
+endif()
-foreach(LANG IN ITEMS C CXX Fortran)
+unset(_OpenMP_MIN_VERSION)
+
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+
+foreach(LANG IN LISTS OpenMP_FINDLIST)
if(CMAKE_${LANG}_COMPILER_LOADED)
- if (NOT OpenMP_${LANG}_SPEC_DATE)
+ if (NOT OpenMP_${LANG}_SPEC_DATE AND OpenMP_${LANG}_FLAGS)
_OPENMP_GET_SPEC_DATE("${LANG}" OpenMP_${LANG}_SPEC_DATE_INTERNAL)
set(OpenMP_${LANG}_SPEC_DATE "${OpenMP_${LANG}_SPEC_DATE_INTERNAL}" CACHE
INTERNAL "${LANG} compiler's OpenMP specification date")
_OPENMP_SET_VERSION_BY_SPEC_DATE("${LANG}")
endif()
- include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-
set(OpenMP_${LANG}_FIND_QUIETLY ${OpenMP_FIND_QUIETLY})
set(OpenMP_${LANG}_FIND_REQUIRED ${OpenMP_FIND_REQUIRED})
set(OpenMP_${LANG}_FIND_VERSION ${OpenMP_FIND_VERSION})
@@ -405,10 +514,20 @@ foreach(LANG IN ITEMS C CXX Fortran)
)
if(OpenMP_${LANG}_FOUND)
+ if(DEFINED OpenMP_${LANG}_VERSION)
+ if(NOT _OpenMP_MIN_VERSION OR _OpenMP_MIN_VERSION VERSION_GREATER OpenMP_${LANG}_VERSION)
+ set(_OpenMP_MIN_VERSION OpenMP_${LANG}_VERSION)
+ endif()
+ endif()
set(OpenMP_${LANG}_LIBRARIES "")
foreach(_OPENMP_IMPLICIT_LIB IN LISTS OpenMP_${LANG}_LIB_NAMES)
list(APPEND OpenMP_${LANG}_LIBRARIES "${OpenMP_${_OPENMP_IMPLICIT_LIB}_LIBRARY}")
endforeach()
+ if(OpenMP_${LANG}_INCLUDE_DIR)
+ set(OpenMP_${LANG}_INCLUDE_DIRS ${OpenMP_${LANG}_INCLUDE_DIR})
+ else()
+ set(OpenMP_${LANG}_INCLUDE_DIRS "")
+ endif()
if(NOT TARGET OpenMP::OpenMP_${LANG})
add_library(OpenMP::OpenMP_${LANG} INTERFACE IMPORTED)
@@ -416,20 +535,34 @@ foreach(LANG IN ITEMS C CXX Fortran)
if(OpenMP_${LANG}_FLAGS)
separate_arguments(_OpenMP_${LANG}_OPTIONS NATIVE_COMMAND "${OpenMP_${LANG}_FLAGS}")
set_property(TARGET OpenMP::OpenMP_${LANG} PROPERTY
- INTERFACE_COMPILE_OPTIONS "${_OpenMP_${LANG}_OPTIONS}")
+ INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:${LANG}>:${_OpenMP_${LANG}_OPTIONS}>")
unset(_OpenMP_${LANG}_OPTIONS)
endif()
+ if(OpenMP_${LANG}_INCLUDE_DIRS)
+ set_property(TARGET OpenMP::OpenMP_${LANG} PROPERTY
+ INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${OpenMP_${LANG}_INCLUDE_DIRS}>")
+ endif()
if(OpenMP_${LANG}_LIBRARIES)
set_property(TARGET OpenMP::OpenMP_${LANG} PROPERTY
INTERFACE_LINK_LIBRARIES "${OpenMP_${LANG}_LIBRARIES}")
endif()
- else()
- set(OPENMP_FOUND FALSE)
endif()
endif()
endforeach()
-set(OpenMP_FOUND ${OPENMP_FOUND})
+unset(_OpenMP_REQ_VARS)
+foreach(LANG IN ITEMS C CXX Fortran)
+ if((NOT OpenMP_FIND_COMPONENTS AND CMAKE_${LANG}_COMPILER_LOADED) OR LANG IN_LIST OpenMP_FIND_COMPONENTS)
+ list(APPEND _OpenMP_REQ_VARS "OpenMP_${LANG}_FOUND")
+ endif()
+endforeach()
+
+find_package_handle_standard_args(OpenMP
+ REQUIRED_VARS ${_OpenMP_REQ_VARS}
+ VERSION_VAR ${_OpenMP_MIN_VERSION}
+ HANDLE_COMPONENTS)
+
+set(OPENMP_FOUND ${OpenMP_FOUND})
if(CMAKE_Fortran_COMPILER_LOADED AND OpenMP_Fortran_FOUND)
if(NOT DEFINED OpenMP_Fortran_HAVE_OMPLIB_MODULE)
diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake
index f32eb501d..478a5923d 100644
--- a/Modules/FindOpenSSL.cmake
+++ b/Modules/FindOpenSSL.cmake
@@ -1,46 +1,84 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindOpenSSL
-# -----------
-#
-# Find the OpenSSL encryption library.
-#
-# Imported Targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the following :prop_tgt:`IMPORTED` targets:
-#
-# ``OpenSSL::SSL``
-# The OpenSSL ``ssl`` library, if found.
-# ``OpenSSL::Crypto``
-# The OpenSSL ``crypto`` library, if found.
-#
-# Result Variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module will set the following variables in your project:
-#
-# ``OPENSSL_FOUND``
-# System has the OpenSSL library.
-# ``OPENSSL_INCLUDE_DIR``
-# The OpenSSL include directory.
-# ``OPENSSL_CRYPTO_LIBRARY``
-# The OpenSSL crypto library.
-# ``OPENSSL_SSL_LIBRARY``
-# The OpenSSL SSL library.
-# ``OPENSSL_LIBRARIES``
-# All OpenSSL libraries.
-# ``OPENSSL_VERSION``
-# This is set to ``$major.$minor.$revision$patch`` (e.g. ``0.9.8s``).
-#
-# Hints
-# ^^^^^
-#
-# Set ``OPENSSL_ROOT_DIR`` to the root directory of an OpenSSL installation.
-# Set ``OPENSSL_USE_STATIC_LIBS`` to ``TRUE`` to look for static libraries.
-# Set ``OPENSSL_MSVC_STATIC_RT`` set ``TRUE`` to choose the MT version of the lib.
+#[=======================================================================[.rst:
+FindOpenSSL
+-----------
+
+Find the OpenSSL encryption library.
+
+Optional COMPONENTS
+^^^^^^^^^^^^^^^^^^^
+
+This module supports two optional COMPONENTS: ``Crypto`` and ``SSL``. Both
+components have associated imported targets, as described below.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` targets:
+
+``OpenSSL::SSL``
+ The OpenSSL ``ssl`` library, if found.
+``OpenSSL::Crypto``
+ The OpenSSL ``crypto`` library, if found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``OPENSSL_FOUND``
+ System has the OpenSSL library. If no components are requested it only
+ requires the crypto library.
+``OPENSSL_INCLUDE_DIR``
+ The OpenSSL include directory.
+``OPENSSL_CRYPTO_LIBRARY``
+ The OpenSSL crypto library.
+``OPENSSL_CRYPTO_LIBRARIES``
+ The OpenSSL crypto library and its dependencies.
+``OPENSSL_SSL_LIBRARY``
+ The OpenSSL SSL library.
+``OPENSSL_SSL_LIBRARIES``
+ The OpenSSL SSL library and its dependencies.
+``OPENSSL_LIBRARIES``
+ All OpenSSL libraries and their dependencies.
+``OPENSSL_VERSION``
+ This is set to ``$major.$minor.$revision$patch`` (e.g. ``0.9.8s``).
+
+Hints
+^^^^^
+
+Set ``OPENSSL_ROOT_DIR`` to the root directory of an OpenSSL installation.
+Set ``OPENSSL_USE_STATIC_LIBS`` to ``TRUE`` to look for static libraries.
+Set ``OPENSSL_MSVC_STATIC_RT`` set ``TRUE`` to choose the MT version of the lib.
+#]=======================================================================]
+
+macro(_OpenSSL_test_and_find_dependencies ssl_library crypto_library)
+ if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND
+ (("${ssl_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$") OR
+ ("${crypto_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")))
+ set(_OpenSSL_has_dependencies TRUE)
+ find_package(Threads)
+ else()
+ set(_OpenSSL_has_dependencies FALSE)
+ endif()
+endmacro()
+
+function(_OpenSSL_add_dependencies libraries_var)
+ if(CMAKE_THREAD_LIBS_INIT)
+ list(APPEND ${libraries_var} ${CMAKE_THREAD_LIBS_INIT})
+ endif()
+ list(APPEND ${libraries_var} ${CMAKE_DL_LIBS})
+ set(${libraries_var} ${${libraries_var}} PARENT_SCOPE)
+endfunction()
+
+function(_OpenSSL_target_add_dependencies target)
+ if(_OpenSSL_has_dependencies)
+ set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads )
+ set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} )
+ endif()
+endfunction()
if (UNIX)
find_package(PkgConfig QUIET)
@@ -110,7 +148,7 @@ if(WIN32 AND NOT CYGWIN)
# * MTd for static-debug
# Implementation details:
- # We are using the libraries located in the VC subdir instead of the parent directory eventhough :
+ # We are using the libraries located in the VC subdir instead of the parent directory even though :
# libeay32MD.lib is identical to ../libeay32.lib, and
# ssleay32MD.lib is identical to ../ssleay32.lib
# enable OPENSSL_USE_STATIC_LIBS to use the static libs located in lib/VC/static
@@ -149,6 +187,7 @@ if(WIN32 AND NOT CYGWIN)
libcryptod
libeay32${_OPENSSL_MSVC_RT_MODE}d
libeay32d
+ cryptod
NAMES_PER_DIR
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
@@ -176,6 +215,7 @@ if(WIN32 AND NOT CYGWIN)
libssld
ssleay32${_OPENSSL_MSVC_RT_MODE}d
ssleay32d
+ ssld
NAMES_PER_DIR
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
@@ -296,10 +336,16 @@ else()
mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY)
- # compat defines
- set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY})
- set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
+endif()
+set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY})
+set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
+set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES} )
+_OpenSSL_test_and_find_dependencies("${OPENSSL_SSL_LIBRARY}" "${OPENSSL_CRYPTO_LIBRARY}")
+if(_OpenSSL_has_dependencies)
+ _OpenSSL_add_dependencies( OPENSSL_SSL_LIBRARIES )
+ _OpenSSL_add_dependencies( OPENSSL_CRYPTO_LIBRARIES )
+ _OpenSSL_add_dependencies( OPENSSL_LIBRARIES )
endif()
function(from_hex HEX DEC)
@@ -369,28 +415,45 @@ if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
endif ()
endif ()
-include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+foreach(_comp IN LISTS OpenSSL_FIND_COMPONENTS)
+ if(_comp STREQUAL "Crypto")
+ if(EXISTS "${OPENSSL_INCLUDE_DIR}" AND
+ (EXISTS "${OPENSSL_CRYPTO_LIBRARY}" OR
+ EXISTS "${LIB_EAY_LIBRARY_DEBUG}" OR
+ EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
+ )
+ set(OpenSSL_${_comp}_FOUND TRUE)
+ else()
+ set(OpenSSL_${_comp}_FOUND FALSE)
+ endif()
+ elseif(_comp STREQUAL "SSL")
+ if(EXISTS "${OPENSSL_INCLUDE_DIR}" AND
+ (EXISTS "${OPENSSL_SSL_LIBRARY}" OR
+ EXISTS "${SSL_EAY_LIBRARY_DEBUG}" OR
+ EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
+ )
+ set(OpenSSL_${_comp}_FOUND TRUE)
+ else()
+ set(OpenSSL_${_comp}_FOUND FALSE)
+ endif()
+ else()
+ message(WARNING "${_comp} is not a valid OpenSSL component")
+ set(OpenSSL_${_comp}_FOUND FALSE)
+ endif()
+endforeach()
+unset(_comp)
-set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} )
-
-if (OPENSSL_VERSION)
- find_package_handle_standard_args(OpenSSL
- REQUIRED_VARS
- #OPENSSL_SSL_LIBRARY # FIXME: require based on a component request?
- OPENSSL_CRYPTO_LIBRARY
- OPENSSL_INCLUDE_DIR
- VERSION_VAR
- OPENSSL_VERSION
- FAIL_MESSAGE
- "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
- )
-else ()
- find_package_handle_standard_args(OpenSSL "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
- #OPENSSL_SSL_LIBRARY # FIXME: require based on a component request?
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+find_package_handle_standard_args(OpenSSL
+ REQUIRED_VARS
OPENSSL_CRYPTO_LIBRARY
OPENSSL_INCLUDE_DIR
- )
-endif ()
+ VERSION_VAR
+ OPENSSL_VERSION
+ HANDLE_COMPONENTS
+ FAIL_MESSAGE
+ "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
+)
mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)
@@ -422,7 +485,9 @@ if(OPENSSL_FOUND)
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${LIB_EAY_LIBRARY_DEBUG}")
endif()
+ _OpenSSL_target_add_dependencies(OpenSSL::Crypto)
endif()
+
if(NOT TARGET OpenSSL::SSL AND
(EXISTS "${OPENSSL_SSL_LIBRARY}" OR
EXISTS "${SSL_EAY_LIBRARY_DEBUG}" OR
@@ -454,6 +519,7 @@ if(OPENSSL_FOUND)
set_target_properties(OpenSSL::SSL PROPERTIES
INTERFACE_LINK_LIBRARIES OpenSSL::Crypto)
endif()
+ _OpenSSL_target_add_dependencies(OpenSSL::SSL)
endif()
endif()
diff --git a/Modules/FindOpenSceneGraph.cmake b/Modules/FindOpenSceneGraph.cmake
index 425aa4581..27909bcea 100644
--- a/Modules/FindOpenSceneGraph.cmake
+++ b/Modules/FindOpenSceneGraph.cmake
@@ -1,102 +1,105 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindOpenSceneGraph
-# ------------------
-#
-# Find OpenSceneGraph
-#
-# This module searches for the OpenSceneGraph core "osg" library as well
-# as OpenThreads, and whatever additional COMPONENTS (nodekits) that you
-# specify.
-#
-# ::
-#
-# See http://www.openscenegraph.org
-#
-#
-#
-# NOTE: To use this module effectively you must either require CMake >=
-# 2.6.3 with cmake_minimum_required(VERSION 2.6.3) or download and place
-# FindOpenThreads.cmake, Findosg_functions.cmake, Findosg.cmake, and
-# Find<etc>.cmake files into your CMAKE_MODULE_PATH.
-#
-# ==================================
-#
-# This module accepts the following variables (note mixed case)
-#
-# ::
-#
-# OpenSceneGraph_DEBUG - Enable debugging output
-#
-#
-#
-# ::
-#
-# OpenSceneGraph_MARK_AS_ADVANCED - Mark cache variables as advanced
-# automatically
-#
-#
-#
-# The following environment variables are also respected for finding the
-# OSG and it's various components. CMAKE_PREFIX_PATH can also be used
-# for this (see find_library() CMake documentation).
-#
-# ``<MODULE>_DIR``
-# (where MODULE is of the form "OSGVOLUME" and there is a FindosgVolume.cmake file)
-# ``OSG_DIR``
-# ..
-# ``OSGDIR``
-# ..
-# ``OSG_ROOT``
-# ..
-#
-#
-# [CMake 2.8.10]: The CMake variable OSG_DIR can now be used as well to
-# influence detection, instead of needing to specify an environment
-# variable.
-#
-# This module defines the following output variables:
-#
-# ::
-#
-# OPENSCENEGRAPH_FOUND - Was the OSG and all of the specified components found?
-#
-#
-#
-# ::
-#
-# OPENSCENEGRAPH_VERSION - The version of the OSG which was found
-#
-#
-#
-# ::
-#
-# OPENSCENEGRAPH_INCLUDE_DIRS - Where to find the headers
-#
-#
-#
-# ::
-#
-# OPENSCENEGRAPH_LIBRARIES - The OSG libraries
-#
-#
-#
-# ================================== Example Usage:
-#
-# ::
-#
-# find_package(OpenSceneGraph 2.0.0 REQUIRED osgDB osgUtil)
-# # libOpenThreads & libosg automatically searched
-# include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
-#
-#
-#
-# ::
-#
-# add_executable(foo foo.cc)
-# target_link_libraries(foo ${OPENSCENEGRAPH_LIBRARIES})
+#[=======================================================================[.rst:
+FindOpenSceneGraph
+------------------
+
+Find OpenSceneGraph (3D graphics application programming interface)
+
+This module searches for the OpenSceneGraph core "osg" library as well
+as :module:`FindOpenThreads`, and whatever additional ``COMPONENTS``
+(nodekits) that you specify.
+
+::
+
+ See http://www.openscenegraph.org
+
+
+
+NOTE: To use this module effectively you must either require ``CMake >=
+2.6.3`` with :command:`cmake_minimum_required(VERSION 2.6.3)` or download
+and place :module:`FindOpenThreads`, :module:`Findosg` functions,
+:module:`Findosg` and ``Find<etc>.cmake`` files into your
+:variable:`CMAKE_MODULE_PATH`.
+
+==================================
+
+This module accepts the following variables (note mixed case)
+
+::
+
+ OpenSceneGraph_DEBUG - Enable debugging output
+
+
+
+::
+
+ OpenSceneGraph_MARK_AS_ADVANCED - Mark cache variables as advanced
+ automatically
+
+
+
+The following environment variables are also respected for finding the
+OSG and it's various components. :variable:`CMAKE_PREFIX_PATH` can also be
+used for this (see :command:`find_library` CMake documentation).
+
+``<MODULE>_DIR``
+ (where ``MODULE`` is of the form "OSGVOLUME" and there is
+ a :module:`FindosgVolume`.cmake` file)
+``OSG_DIR``
+ ..
+``OSGDIR``
+ ..
+``OSG_ROOT``
+ ..
+
+
+[CMake 2.8.10]: The CMake variable ``OSG_DIR`` can now be used as well to
+influence detection, instead of needing to specify an environment
+variable.
+
+This module defines the following output variables:
+
+::
+
+ OPENSCENEGRAPH_FOUND - Was the OSG and all of the specified components found?
+
+
+
+::
+
+ OPENSCENEGRAPH_VERSION - The version of the OSG which was found
+
+
+
+::
+
+ OPENSCENEGRAPH_INCLUDE_DIRS - Where to find the headers
+
+
+
+::
+
+ OPENSCENEGRAPH_LIBRARIES - The OSG libraries
+
+
+
+================================== Example Usage:
+
+::
+
+ find_package(OpenSceneGraph 2.0.0 REQUIRED osgDB osgUtil)
+ # libOpenThreads & libosg automatically searched
+ include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
+
+
+
+::
+
+ add_executable(foo foo.cc)
+ target_link_libraries(foo ${OPENSCENEGRAPH_LIBRARIES})
+#]=======================================================================]
#
# Naming convention:
diff --git a/Modules/FindOpenThreads.cmake b/Modules/FindOpenThreads.cmake
index 54804b87d..bc45eea7b 100644
--- a/Modules/FindOpenThreads.cmake
+++ b/Modules/FindOpenThreads.cmake
@@ -1,30 +1,31 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindOpenThreads
-# ---------------
-#
-#
-#
-# OpenThreads is a C++ based threading library. Its largest userbase
-# seems to OpenSceneGraph so you might notice I accept OSGDIR as an
-# environment path. I consider this part of the Findosg* suite used to
-# find OpenSceneGraph components. Each component is separate and you
-# must opt in to each module.
-#
-# Locate OpenThreads This module defines OPENTHREADS_LIBRARY
-# OPENTHREADS_FOUND, if false, do not try to link to OpenThreads
-# OPENTHREADS_INCLUDE_DIR, where to find the headers
-#
-# $OPENTHREADS_DIR is an environment variable that would correspond to
-# the ./configure --prefix=$OPENTHREADS_DIR used in building osg.
-#
-# [CMake 2.8.10]: The CMake variables OPENTHREADS_DIR or OSG_DIR can now
-# be used as well to influence detection, instead of needing to specify
-# an environment variable.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindOpenThreads
+---------------
+
+
+
+OpenThreads is a C++ based threading library. Its largest userbase
+seems to OpenSceneGraph so you might notice I accept OSGDIR as an
+environment path. I consider this part of the Findosg* suite used to
+find OpenSceneGraph components. Each component is separate and you
+must opt in to each module.
+
+Locate OpenThreads This module defines OPENTHREADS_LIBRARY
+OPENTHREADS_FOUND, if false, do not try to link to OpenThreads
+OPENTHREADS_INCLUDE_DIR, where to find the headers
+
+$OPENTHREADS_DIR is an environment variable that would correspond to
+the ./configure --prefix=$OPENTHREADS_DIR used in building osg.
+
+[CMake 2.8.10]: The CMake variables OPENTHREADS_DIR or OSG_DIR can now
+be used as well to influence detection, instead of needing to specify
+an environment variable.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <OpenThreads/Thread>
@@ -47,6 +48,8 @@
# standard install paths.
# Explicit -DVAR=value arguments should still be able to override everything.
+include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
+
find_path(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
HINTS
ENV OPENTHREADS_INCLUDE_DIR
@@ -58,17 +61,11 @@ find_path(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread
ENV OSG_ROOT
${OPENTHREADS_DIR}
${OSG_DIR}
- PATHS
- /sw # Fink
- /opt/local # DarwinPorts
- /opt/csw # Blastwave
- /opt
- /usr/freeware
PATH_SUFFIXES include
)
-find_library(OPENTHREADS_LIBRARY
+find_library(OPENTHREADS_LIBRARY_RELEASE
NAMES OpenThreads OpenThreadsWin32
HINTS
ENV OPENTHREADS_LIBRARY_DIR
@@ -80,12 +77,6 @@ find_library(OPENTHREADS_LIBRARY
ENV OSG_ROOT
${OPENTHREADS_DIR}
${OSG_DIR}
- PATHS
- /sw
- /opt/local
- /opt/csw
- /opt
- /usr/freeware
PATH_SUFFIXES lib
)
@@ -102,22 +93,10 @@ find_library(OPENTHREADS_LIBRARY_DEBUG
ENV OSG_ROOT
${OPENTHREADS_DIR}
${OSG_DIR}
- PATHS
- /sw
- /opt/local
- /opt/csw
- /opt
- /usr/freeware
PATH_SUFFIXES lib
)
-if(OPENTHREADS_LIBRARY_DEBUG)
- set(OPENTHREADS_LIBRARIES
- optimized ${OPENTHREADS_LIBRARY}
- debug ${OPENTHREADS_LIBRARY_DEBUG})
-else()
- set(OPENTHREADS_LIBRARIES ${OPENTHREADS_LIBRARY})
-endif()
+select_library_configurations(OPENTHREADS)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenThreads DEFAULT_MSG
diff --git a/Modules/FindPHP4.cmake b/Modules/FindPHP4.cmake
index 426453bd4..34b4adb01 100644
--- a/Modules/FindPHP4.cmake
+++ b/Modules/FindPHP4.cmake
@@ -1,20 +1,21 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindPHP4
-# --------
-#
-# Find PHP4
-#
-# This module finds if PHP4 is installed and determines where the
-# include files and libraries are. It also determines what the name of
-# the library is. This code sets the following variables:
-#
-# ::
-#
-# PHP4_INCLUDE_PATH = path to where php.h can be found
-# PHP4_EXECUTABLE = full path to the php4 binary
+#[=======================================================================[.rst:
+FindPHP4
+--------
+
+Find PHP4
+
+This module finds if PHP4 is installed and determines where the
+include files and libraries are. It also determines what the name of
+the library is. This code sets the following variables:
+
+::
+
+ PHP4_INCLUDE_PATH = path to where php.h can be found
+ PHP4_EXECUTABLE = full path to the php4 binary
+#]=======================================================================]
set(PHP4_POSSIBLE_INCLUDE_PATHS
/usr/include/php4
diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake
index dceb6bcc5..bd400c74c 100644
--- a/Modules/FindPNG.cmake
+++ b/Modules/FindPNG.cmake
@@ -1,49 +1,50 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindPNG
-# -------
-#
-# Find libpng, the official reference library for the PNG image format.
-#
-# Imported targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the following :prop_tgt:`IMPORTED` target:
-#
-# ``PNG::PNG``
-# The libpng library, if found.
-#
-# Result variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module will set the following variables in your project:
-#
-# ``PNG_INCLUDE_DIRS``
-# where to find png.h, etc.
-# ``PNG_LIBRARIES``
-# the libraries to link against to use PNG.
-# ``PNG_DEFINITIONS``
-# You should add_definitions(${PNG_DEFINITIONS}) before compiling code
-# that includes png library files.
-# ``PNG_FOUND``
-# If false, do not try to use PNG.
-# ``PNG_VERSION_STRING``
-# the version of the PNG library found (since CMake 2.8.8)
-#
-# Obsolete variables
-# ^^^^^^^^^^^^^^^^^^
-#
-# The following variables may also be set, for backwards compatibility:
-#
-# ``PNG_LIBRARY``
-# where to find the PNG library.
-# ``PNG_INCLUDE_DIR``
-# where to find the PNG headers (same as PNG_INCLUDE_DIRS)
-#
-# Since PNG depends on the ZLib compression library, none of the above
-# will be defined unless ZLib can be found.
+#[=======================================================================[.rst:
+FindPNG
+-------
+
+Find libpng, the official reference library for the PNG image format.
+
+Imported targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` target:
+
+``PNG::PNG``
+ The libpng library, if found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``PNG_INCLUDE_DIRS``
+ where to find png.h, etc.
+``PNG_LIBRARIES``
+ the libraries to link against to use PNG.
+``PNG_DEFINITIONS``
+ You should add_definitions(${PNG_DEFINITIONS}) before compiling code
+ that includes png library files.
+``PNG_FOUND``
+ If false, do not try to use PNG.
+``PNG_VERSION_STRING``
+ the version of the PNG library found (since CMake 2.8.8)
+
+Obsolete variables
+^^^^^^^^^^^^^^^^^^
+
+The following variables may also be set, for backwards compatibility:
+
+``PNG_LIBRARY``
+ where to find the PNG library.
+``PNG_INCLUDE_DIR``
+ where to find the PNG headers (same as PNG_INCLUDE_DIRS)
+
+Since PNG depends on the ZLib compression library, none of the above
+will be defined unless ZLib can be found.
+#]=======================================================================]
if(PNG_FIND_QUIETLY)
set(_FIND_ZLIB_ARG QUIET)
@@ -51,9 +52,7 @@ endif()
find_package(ZLIB ${_FIND_ZLIB_ARG})
if(ZLIB_FOUND)
- find_path(PNG_PNG_INCLUDE_DIR png.h
- /usr/local/include/libpng # OpenBSD
- )
+ find_path(PNG_PNG_INCLUDE_DIR png.h PATH_SUFFIXES include/libpng)
list(APPEND PNG_NAMES png libpng)
unset(PNG_NAMES_DEBUG)
@@ -70,8 +69,8 @@ if(ZLIB_FOUND)
unset(_PNG_VERSION_SUFFIX_MIN)
endif ()
foreach(v IN LISTS _PNG_VERSION_SUFFIXES)
- list(APPEND PNG_NAMES png${v} libpng${v})
- list(APPEND PNG_NAMES_DEBUG png${v}d libpng${v}d)
+ list(APPEND PNG_NAMES png${v} libpng${v} libpng${v}_static)
+ list(APPEND PNG_NAMES_DEBUG png${v}d libpng${v}d libpng${v}_staticd)
endforeach()
unset(_PNG_VERSION_SUFFIXES)
# For compatibility with versions prior to this multi-config search, honor
@@ -101,13 +100,14 @@ if(ZLIB_FOUND)
# No need to define PNG_USE_DLL here, because it's default for Cygwin.
else()
set (PNG_DEFINITIONS -DPNG_STATIC)
+ set(_PNG_COMPILE_DEFINITIONS PNG_STATIC)
endif()
endif ()
if(NOT TARGET PNG::PNG)
add_library(PNG::PNG UNKNOWN IMPORTED)
set_target_properties(PNG::PNG PROPERTIES
- INTERFACE_COMPILE_DEFINITIONS "${PNG_DEFINITIONS}"
+ INTERFACE_COMPILE_DEFINITIONS "${_PNG_COMPILE_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${PNG_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
if(EXISTS "${PNG_LIBRARY}")
@@ -130,6 +130,8 @@ if(ZLIB_FOUND)
IMPORTED_LOCATION_DEBUG "${PNG_LIBRARY_DEBUG}")
endif()
endif()
+
+ unset(_PNG_COMPILE_DEFINITIONS)
endif ()
if (PNG_PNG_INCLUDE_DIR AND EXISTS "${PNG_PNG_INCLUDE_DIR}/png.h")
diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake
index b851a90ff..d824ee828 100644
--- a/Modules/FindPackageHandleStandardArgs.cmake
+++ b/Modules/FindPackageHandleStandardArgs.cmake
@@ -27,6 +27,7 @@ valid filepaths.
[VERSION_VAR <version-var>]
[HANDLE_COMPONENTS]
[CONFIG_MODE]
+ [REASON_FAILURE_MESSAGE <reason-failure-message>]
[FAIL_MESSAGE <custom-failure-message>]
)
@@ -81,6 +82,10 @@ valid filepaths.
will automatically check whether the package configuration file
was found.
+ ``REASON_FAILURE_MESSAGE <reason-failure-message>``
+ Specify a custom message of the reason for the failure which will be
+ appended to the default generated message.
+
``FAIL_MESSAGE <custom-failure-message>``
Specify a custom failure message instead of using the default
generated message. Not recommended.
@@ -133,11 +138,15 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake)
# internal helper macro
macro(_FPHSA_FAILURE_MESSAGE _msg)
+ set (__msg "${_msg}")
+ if (FPHSA_REASON_FAILURE_MESSAGE)
+ string(APPEND __msg "\n Reason given by package: ${FPHSA_REASON_FAILURE_MESSAGE}\n")
+ endif()
if (${_NAME}_FIND_REQUIRED)
- message(FATAL_ERROR "${_msg}")
+ message(FATAL_ERROR "${__msg}")
else ()
if (NOT ${_NAME}_FIND_QUIETLY)
- message(STATUS "${_msg}")
+ message(STATUS "${__msg}")
endif ()
endif ()
endmacro()
@@ -145,7 +154,7 @@ endmacro()
# internal helper macro to generate the failure message when used in CONFIG_MODE:
macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE)
- # <name>_CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found:
+ # <PackageName>_CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found:
if(${_NAME}_CONFIG)
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing:${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})")
else()
@@ -158,12 +167,18 @@ macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE)
foreach(currentConfigIndex RANGE ${configsCount})
list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename)
list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version)
- string(APPEND configsText " ${filename} (version ${version})\n")
+ string(APPEND configsText "\n ${filename} (version ${version})")
endforeach()
if (${_NAME}_NOT_FOUND_MESSAGE)
- string(APPEND configsText " Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n")
+ if (FPHSA_REASON_FAILURE_MESSAGE)
+ string(PREPEND FPHSA_REASON_FAILURE_MESSAGE "${${_NAME}_NOT_FOUND_MESSAGE}\n ")
+ else()
+ set(FPHSA_REASON_FAILURE_MESSAGE "${${_NAME}_NOT_FOUND_MESSAGE}")
+ endif()
+ else()
+ string(APPEND configsText "\n")
endif()
- _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}")
+ _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:${configsText}")
else()
# Simple case: No Config-file was found at all:
@@ -175,11 +190,12 @@ endmacro()
function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
-# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in
-# new extended or in the "old" mode:
+# Set up the arguments for `cmake_parse_arguments`.
set(options CONFIG_MODE HANDLE_COMPONENTS)
- set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR)
+ set(oneValueArgs FAIL_MESSAGE REASON_FAILURE_MESSAGE VERSION_VAR FOUND_VAR)
set(multiValueArgs REQUIRED_VARS)
+
+# Check whether we are in 'simple' or 'extended' mode:
set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} )
list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX)
@@ -188,8 +204,7 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
set(FPHSA_REQUIRED_VARS ${ARGN})
set(FPHSA_VERSION_VAR)
else()
-
- CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
+ cmake_parse_arguments(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
if(FPHSA_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"")
@@ -198,6 +213,18 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
if(NOT FPHSA_FAIL_MESSAGE)
set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG")
endif()
+
+ # In config-mode, we rely on the variable <PackageName>_CONFIG, which is set by find_package()
+ # when it successfully found the config-file, including version checking:
+ if(FPHSA_CONFIG_MODE)
+ list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG)
+ list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS)
+ set(FPHSA_VERSION_VAR ${_NAME}_VERSION)
+ endif()
+
+ if(NOT FPHSA_REQUIRED_VARS)
+ message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()")
+ endif()
endif()
# now that we collected all arguments, process them
@@ -206,18 +233,6 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}")
endif()
- # In config-mode, we rely on the variable <package>_CONFIG, which is set by find_package()
- # when it successfully found the config-file, including version checking:
- if(FPHSA_CONFIG_MODE)
- list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG)
- list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS)
- set(FPHSA_VERSION_VAR ${_NAME}_VERSION)
- endif()
-
- if(NOT FPHSA_REQUIRED_VARS)
- message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()")
- endif()
-
list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR)
string(TOUPPER ${_NAME} _NAME_UPPER)
@@ -264,14 +279,14 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
if(${_NAME}_${comp}_FOUND)
if(NOT DEFINED FOUND_COMPONENTS_MSG)
- set(FOUND_COMPONENTS_MSG "found components: ")
+ set(FOUND_COMPONENTS_MSG "found components:")
endif()
string(APPEND FOUND_COMPONENTS_MSG " ${comp}")
else()
if(NOT DEFINED MISSING_COMPONENTS_MSG)
- set(MISSING_COMPONENTS_MSG "missing components: ")
+ set(MISSING_COMPONENTS_MSG "missing components:")
endif()
string(APPEND MISSING_COMPONENTS_MSG " ${comp}")
@@ -289,15 +304,15 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
# version handling:
set(VERSION_MSG "")
set(VERSION_OK TRUE)
- set(VERSION ${${FPHSA_VERSION_VAR}})
# check with DEFINED here as the requested or found version may be "0"
if (DEFINED ${_NAME}_FIND_VERSION)
if(DEFINED ${FPHSA_VERSION_VAR})
+ set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}})
if(${_NAME}_FIND_VERSION_EXACT) # exact version required
# count the dots in the version string
- string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${VERSION}")
+ string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${_FOUND_VERSION}")
# add one dot because there is one dot more than there are components
string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS)
if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT)
@@ -312,31 +327,31 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
else ()
set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*")
endif ()
- string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${VERSION}")
+ string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${_FOUND_VERSION}")
unset(_VERSION_REGEX)
if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD)
- set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
+ set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
set(VERSION_OK FALSE)
else ()
- set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
+ set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")")
endif ()
unset(_VERSION_HEAD)
else ()
- if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL VERSION)
- set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
+ if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _FOUND_VERSION)
+ set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
set(VERSION_OK FALSE)
else ()
- set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
+ set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")")
endif ()
endif ()
unset(_VERSION_DOTS)
else() # minimum version specified:
- if (${_NAME}_FIND_VERSION VERSION_GREATER VERSION)
- set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
+ if (${_NAME}_FIND_VERSION VERSION_GREATER _FOUND_VERSION)
+ set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
set(VERSION_OK FALSE)
else ()
- set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")")
+ set(VERSION_MSG "(found suitable version \"${_FOUND_VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")")
endif ()
endif()
@@ -351,13 +366,14 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
endif()
else ()
- if(VERSION)
- set(VERSION_MSG "(found version \"${VERSION}\")")
+ # Check with DEFINED as the found version may be 0.
+ if(DEFINED ${FPHSA_VERSION_VAR})
+ set(VERSION_MSG "(found version \"${${FPHSA_VERSION_VAR}}\")")
endif()
endif ()
if(VERSION_OK)
- string(APPEND DETAILS "[v${VERSION}(${${_NAME}_FIND_VERSION})]")
+ string(APPEND DETAILS "[v${${FPHSA_VERSION_VAR}}(${${_NAME}_FIND_VERSION})]")
else()
set(${_NAME}_FOUND FALSE)
endif()
diff --git a/Modules/FindPackageMessage.cmake b/Modules/FindPackageMessage.cmake
index 6821cee4f..0628b9816 100644
--- a/Modules/FindPackageMessage.cmake
+++ b/Modules/FindPackageMessage.cmake
@@ -1,35 +1,36 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindPackageMessage
-# ------------------
-#
-#
-#
-# FIND_PACKAGE_MESSAGE(<name> "message for user" "find result details")
-#
-# This macro is intended to be used in FindXXX.cmake modules files. It
-# will print a message once for each unique find result. This is useful
-# for telling the user where a package was found. The first argument
-# specifies the name (XXX) of the package. The second argument
-# specifies the message to display. The third argument lists details
-# about the find result so that if they change the message will be
-# displayed again. The macro also obeys the QUIET argument to the
-# find_package command.
-#
-# Example:
-#
-# ::
-#
-# if(X11_FOUND)
-# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}"
-# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]")
-# else()
-# ...
-# endif()
-
-function(FIND_PACKAGE_MESSAGE pkg msg details)
+#[=======================================================================[.rst:
+FindPackageMessage
+------------------
+
+.. code-block:: cmake
+
+ find_package_message(<name> "message for user" "find result details")
+
+This function is intended to be used in FindXXX.cmake modules files.
+It will print a message once for each unique find result. This is
+useful for telling the user where a package was found. The first
+argument specifies the name (XXX) of the package. The second argument
+specifies the message to display. The third argument lists details
+about the find result so that if they change the message will be
+displayed again. The macro also obeys the QUIET argument to the
+find_package command.
+
+Example:
+
+.. code-block:: cmake
+
+ if(X11_FOUND)
+ find_package_message(X11 "Found X11: ${X11_X11_LIB}"
+ "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]")
+ else()
+ ...
+ endif()
+#]=======================================================================]
+
+function(find_package_message pkg msg details)
# Avoid printing a message repeatedly for the same find result.
if(NOT ${pkg}_FIND_QUIETLY)
string(REPLACE "\n" "" details "${details}")
diff --git a/Modules/FindPatch.cmake b/Modules/FindPatch.cmake
new file mode 100644
index 000000000..49988395b
--- /dev/null
+++ b/Modules/FindPatch.cmake
@@ -0,0 +1,69 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindPatch
+---------
+
+The module defines the following variables:
+
+``Patch_EXECUTABLE``
+ Path to patch command-line executable.
+``Patch_FOUND``
+ True if the patch command-line executable was found.
+
+The following :prop_tgt:`IMPORTED` targets are also defined:
+
+``Patch::patch``
+ The command-line executable.
+
+Example usage:
+
+.. code-block:: cmake
+
+ find_package(Patch)
+ if(Patch_FOUND)
+ message("Patch found: ${Patch_EXECUTABLE}")
+ endif()
+#]=======================================================================]
+
+set(_doc "Patch command line executable")
+set(_patch_path )
+
+if(CMAKE_HOST_WIN32)
+ set(_patch_path
+ "$ENV{LOCALAPPDATA}/Programs/Git/bin"
+ "$ENV{LOCALAPPDATA}/Programs/Git/usr/bin"
+ "$ENV{APPDATA}/Programs/Git/bin"
+ "$ENV{APPDATA}/Programs/Git/usr/bin"
+ )
+endif()
+
+# First search the PATH
+find_program(Patch_EXECUTABLE
+ NAME patch
+ PATHS ${_patch_path}
+ DOC ${_doc}
+ )
+
+if(CMAKE_HOST_WIN32)
+ # Now look for installations in Git/ directories under typical installation
+ # prefixes on Windows.
+ find_program(Patch_EXECUTABLE
+ NAMES patch
+ PATH_SUFFIXES Git/usr/bin Git/bin GnuWin32/bin
+ DOC ${_doc}
+ )
+endif()
+
+if(Patch_EXECUTABLE AND NOT TARGET Patch::patch)
+ add_executable(Patch::patch IMPORTED)
+ set_property(TARGET Patch::patch PROPERTY IMPORTED_LOCATION ${Patch_EXECUTABLE})
+endif()
+
+unset(_patch_path)
+unset(_doc)
+
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+find_package_handle_standard_args(Patch
+ REQUIRED_VARS Patch_EXECUTABLE)
diff --git a/Modules/FindPerl.cmake b/Modules/FindPerl.cmake
index 423fc6987..fd120bf8e 100644
--- a/Modules/FindPerl.cmake
+++ b/Modules/FindPerl.cmake
@@ -1,19 +1,20 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindPerl
-# --------
-#
-# Find perl
-#
-# this module looks for Perl
-#
-# ::
-#
-# PERL_EXECUTABLE - the full path to perl
-# PERL_FOUND - If false, don't attempt to use perl.
-# PERL_VERSION_STRING - version of perl found (since CMake 2.8.8)
+#[=======================================================================[.rst:
+FindPerl
+--------
+
+Find perl
+
+this module looks for Perl
+
+::
+
+ PERL_EXECUTABLE - the full path to perl
+ PERL_FOUND - If false, don't attempt to use perl.
+ PERL_VERSION_STRING - version of perl found (since CMake 2.8.8)
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake)
@@ -28,6 +29,7 @@ if(WIN32)
NAME)
set(PERL_POSSIBLE_BIN_PATHS ${PERL_POSSIBLE_BIN_PATHS}
"C:/Perl/bin"
+ "C:/Strawberry/perl/bin"
[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActivePerl\\${ActivePerl_CurrentVersion}]/bin
)
endif()
diff --git a/Modules/FindPerlLibs.cmake b/Modules/FindPerlLibs.cmake
index e01e75e2d..7e27f3188 100644
--- a/Modules/FindPerlLibs.cmake
+++ b/Modules/FindPerlLibs.cmake
@@ -1,224 +1,126 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindPerlLibs
-# ------------
-#
-# Find Perl libraries
-#
-# This module finds if PERL is installed and determines where the
-# include files and libraries are. It also determines what the name of
-# the library is. This code sets the following variables:
-#
-# ::
-#
-# PERLLIBS_FOUND = True if perl.h & libperl were found
-# PERL_INCLUDE_PATH = path to where perl.h is found
-# PERL_LIBRARY = path to libperl
-# PERL_EXECUTABLE = full path to the perl binary
-#
-#
-#
-# The minimum required version of Perl can be specified using the
-# standard syntax, e.g. find_package(PerlLibs 6.0)
-#
-# ::
-#
-# The following variables are also available if needed
-# (introduced after CMake 2.6.4)
-#
-#
-#
-# ::
-#
-# PERL_SITESEARCH = path to the sitesearch install dir
-# PERL_SITELIB = path to the sitelib install directory
-# PERL_VENDORARCH = path to the vendor arch install directory
-# PERL_VENDORLIB = path to the vendor lib install directory
-# PERL_ARCHLIB = path to the arch lib install directory
-# PERL_PRIVLIB = path to the priv lib install directory
-# PERL_EXTRA_C_FLAGS = Compilation flags used to build perl
+#[=======================================================================[.rst:
+FindPerlLibs
+------------
+
+Find Perl libraries
+
+This module finds if PERL is installed and determines where the
+include files and libraries are. It also determines what the name of
+the library is. This code sets the following variables:
+
+::
+
+ PERLLIBS_FOUND = True if perl.h & libperl were found
+ PERL_INCLUDE_PATH = path to where perl.h is found
+ PERL_LIBRARY = path to libperl
+ PERL_EXECUTABLE = full path to the perl binary
+
+
+
+The minimum required version of Perl can be specified using the
+standard syntax, e.g. find_package(PerlLibs 6.0)
+
+::
+
+ The following variables are also available if needed
+ (introduced after CMake 2.6.4)
+
+
+
+::
+
+ PERL_SITESEARCH = path to the sitesearch install dir (-V:installsitesearch)
+ PERL_SITEARCH = path to the sitelib install directory (-V:installsitearch)
+ PERL_SITELIB = path to the sitelib install directory (-V:installsitelib)
+ PERL_VENDORARCH = path to the vendor arch install directory (-V:installvendorarch)
+ PERL_VENDORLIB = path to the vendor lib install directory (-V:installvendorlib)
+ PERL_ARCHLIB = path to the core arch lib install directory (-V:archlib)
+ PERL_PRIVLIB = path to the core priv lib install directory (-V:privlib)
+ PERL_UPDATE_ARCHLIB = path to the update arch lib install directory (-V:installarchlib)
+ PERL_UPDATE_PRIVLIB = path to the update priv lib install directory (-V:installprivlib)
+ PERL_EXTRA_C_FLAGS = Compilation flags used to build perl
+#]=======================================================================]
# find the perl executable
include(${CMAKE_CURRENT_LIST_DIR}/FindPerl.cmake)
if (PERL_EXECUTABLE)
- ### PERL_PREFIX
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:prefix
- OUTPUT_VARIABLE
- PERL_PREFIX_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_PREFIX_RESULT_VARIABLE
- )
- if (NOT PERL_PREFIX_RESULT_VARIABLE)
- string(REGEX REPLACE "prefix='([^']+)'.*" "\\1" PERL_PREFIX ${PERL_PREFIX_OUTPUT_VARIABLE})
- endif ()
+ function (perl_get_info _pgi_info tag)
+ cmake_parse_arguments(_PGI "IS_PATH" "" "" ${ARGN})
- ### PERL_ARCHNAME
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:archname
- OUTPUT_VARIABLE
- PERL_ARCHNAME_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_ARCHNAME_RESULT_VARIABLE
- )
- if (NOT PERL_ARCHNAME_RESULT_VARIABLE)
- string(REGEX REPLACE "archname='([^']+)'.*" "\\1" PERL_ARCHNAME ${PERL_ARCHNAME_OUTPUT_VARIABLE})
- endif ()
+ set (${_pgi_info} NOTFOUND PARENT_SCOPE)
+ execute_process(COMMAND "${PERL_EXECUTABLE}" -V:${tag}
+ OUTPUT_VARIABLE result
+ RESULT_VARIABLE status)
+ if (NOT status)
+ string(REGEX REPLACE "${tag}='([^']*)'.*" "\\1" result "${result}")
+ if (_PGI_IS_PATH)
+ file(TO_CMAKE_PATH "${result}" result)
+ endif()
+ set (${_pgi_info} "${result}" PARENT_SCOPE)
+ endif ()
+ endfunction()
+
+ ### PERL_PREFIX
+ perl_get_info(PERL_PREFIX prefix IS_PATH)
+
+ ### PERL_ARCHNAME
+ perl_get_info(PERL_ARCHNAME archname)
### PERL_EXTRA_C_FLAGS
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:cppflags
- OUTPUT_VARIABLE
- PERL_CPPFLAGS_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_CPPFLAGS_RESULT_VARIABLE
- )
- if (NOT PERL_CPPFLAGS_RESULT_VARIABLE)
- string(REGEX REPLACE "cppflags='([^']+)'.*" "\\1" PERL_EXTRA_C_FLAGS ${PERL_CPPFLAGS_OUTPUT_VARIABLE})
- endif ()
+ perl_get_info(PERL_EXTRA_C_FLAGS cppflags)
### PERL_SITESEARCH
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:installsitesearch
- OUTPUT_VARIABLE
- PERL_SITESEARCH_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_SITESEARCH_RESULT_VARIABLE
- )
- if (NOT PERL_SITESEARCH_RESULT_VARIABLE)
- string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_SITESEARCH ${PERL_SITESEARCH_OUTPUT_VARIABLE})
- file(TO_CMAKE_PATH "${PERL_SITESEARCH}" PERL_SITESEARCH)
- endif ()
+ perl_get_info(PERL_SITESEARCH installsitesearch IS_PATH)
+
+ ### PERL_SITEARCH
+ perl_get_info(PERL_SITEARCH installsitearch IS_PATH)
### PERL_SITELIB
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:installsitelib
- OUTPUT_VARIABLE
- PERL_SITELIB_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_SITELIB_RESULT_VARIABLE
- )
- if (NOT PERL_SITELIB_RESULT_VARIABLE)
- string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_SITELIB ${PERL_SITELIB_OUTPUT_VARIABLE})
- file(TO_CMAKE_PATH "${PERL_SITELIB}" PERL_SITELIB)
- endif ()
+ perl_get_info(PERL_SITELIB installsitelib IS_PATH)
### PERL_VENDORARCH
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:installvendorarch
- OUTPUT_VARIABLE
- PERL_VENDORARCH_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_VENDORARCH_RESULT_VARIABLE
- )
- if (NOT PERL_VENDORARCH_RESULT_VARIABLE)
- string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_VENDORARCH ${PERL_VENDORARCH_OUTPUT_VARIABLE})
- file(TO_CMAKE_PATH "${PERL_VENDORARCH}" PERL_VENDORARCH)
- endif ()
+ perl_get_info(PERL_VENDORARCH installvendorarch IS_PATH)
### PERL_VENDORLIB
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:installvendorlib
- OUTPUT_VARIABLE
- PERL_VENDORLIB_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_VENDORLIB_RESULT_VARIABLE
- )
- if (NOT PERL_VENDORLIB_RESULT_VARIABLE)
- string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_VENDORLIB ${PERL_VENDORLIB_OUTPUT_VARIABLE})
- file(TO_CMAKE_PATH "${PERL_VENDORLIB}" PERL_VENDORLIB)
- endif ()
-
- macro(perl_adjust_darwin_lib_variable varname)
- string( TOUPPER PERL_${varname} FINDPERL_VARNAME )
- string( TOLOWER install${varname} PERL_VARNAME )
-
- if (NOT PERL_MINUSV_OUTPUT_VARIABLE)
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V
- OUTPUT_VARIABLE
- PERL_MINUSV_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_MINUSV_RESULT_VARIABLE
- )
- endif()
-
- if (NOT PERL_MINUSV_RESULT_VARIABLE)
- string(REGEX MATCH "(${PERL_VARNAME}.*points? to the Updates directory)"
- PERL_NEEDS_ADJUSTMENT ${PERL_MINUSV_OUTPUT_VARIABLE})
-
- if (PERL_NEEDS_ADJUSTMENT)
- string(REGEX REPLACE "(.*)/Updates/" "/System/\\1/" ${FINDPERL_VARNAME} ${${FINDPERL_VARNAME}})
- endif ()
-
- endif ()
- endmacro()
+ perl_get_info(PERL_VENDORLIB installvendorlib IS_PATH)
### PERL_ARCHLIB
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:installarchlib
- OUTPUT_VARIABLE
- PERL_ARCHLIB_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_ARCHLIB_RESULT_VARIABLE
- )
- if (NOT PERL_ARCHLIB_RESULT_VARIABLE)
- string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_ARCHLIB ${PERL_ARCHLIB_OUTPUT_VARIABLE})
- perl_adjust_darwin_lib_variable( ARCHLIB )
- file(TO_CMAKE_PATH "${PERL_ARCHLIB}" PERL_ARCHLIB)
- endif ()
+ perl_get_info(PERL_ARCHLIB archlib IS_PATH)
### PERL_PRIVLIB
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:installprivlib
- OUTPUT_VARIABLE
- PERL_PRIVLIB_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_PRIVLIB_RESULT_VARIABLE
- )
- if (NOT PERL_PRIVLIB_RESULT_VARIABLE)
- string(REGEX REPLACE "install[a-z]+='([^']+)'.*" "\\1" PERL_PRIVLIB ${PERL_PRIVLIB_OUTPUT_VARIABLE})
- perl_adjust_darwin_lib_variable( PRIVLIB )
- file(TO_CMAKE_PATH "${PERL_PRIVLIB}" PERL_PRIVLIB)
- endif ()
+ perl_get_info(PERL_PRIVLIB privlib IS_PATH)
+
+ ### PERL_UPDATE_ARCHLIB
+ perl_get_info(PERL_UPDATE_ARCHLIB installarchlib IS_PATH)
+
+ ### PERL_UPDATE_PRIVLIB
+ perl_get_info(PERL_UPDATE_PRIVLIB installprivlib IS_PATH)
### PERL_POSSIBLE_LIBRARY_NAMES
- execute_process(
- COMMAND
- ${PERL_EXECUTABLE} -V:libperl
- OUTPUT_VARIABLE
- PERL_LIBRARY_OUTPUT_VARIABLE
- RESULT_VARIABLE
- PERL_LIBRARY_RESULT_VARIABLE
- )
- if (NOT PERL_LIBRARY_RESULT_VARIABLE)
- string(REGEX REPLACE "libperl='([^']+)'.*" "\\1" PERL_POSSIBLE_LIBRARY_NAMES ${PERL_LIBRARY_OUTPUT_VARIABLE})
- else ()
+ perl_get_info(PERL_POSSIBLE_LIBRARY_NAMES libperl)
+ if (NOT PERL_POSSIBLE_LIBRARY_NAMES)
set(PERL_POSSIBLE_LIBRARY_NAMES perl${PERL_VERSION_STRING} perl)
- endif ()
+ endif()
+ if (CMAKE_SYSTEM_NAME MATCHES "MSYS|CYGWIN")
+ # on MSYS and CYGWIN environments, current perl -V:libperl gives shared library name
+ # rather than the import library. So, extends possible library names
+ list (APPEND PERL_POSSIBLE_LIBRARY_NAMES perl)
+ endif()
### PERL_INCLUDE_PATH
find_path(PERL_INCLUDE_PATH
NAMES
perl.h
PATHS
- ${PERL_ARCHLIB}/CORE
+ "${PERL_UPDATE_ARCHLIB}/CORE"
+ "${PERL_ARCHLIB}/CORE"
/usr/lib/perl5/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE
/usr/lib/perl/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE
/usr/lib/perl5/${PERL_VERSION_STRING}/CORE
@@ -230,7 +132,8 @@ if (PERL_EXECUTABLE)
NAMES
${PERL_POSSIBLE_LIBRARY_NAMES}
PATHS
- ${PERL_ARCHLIB}/CORE
+ "${PERL_UPDATE_ARCHLIB}/CORE"
+ "${PERL_ARCHLIB}/CORE"
/usr/lib/perl5/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE
/usr/lib/perl/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE
/usr/lib/perl5/${PERL_VERSION_STRING}/CORE
diff --git a/Modules/FindPhysFS.cmake b/Modules/FindPhysFS.cmake
index cfe9b0f19..a32f83aae 100644
--- a/Modules/FindPhysFS.cmake
+++ b/Modules/FindPhysFS.cmake
@@ -1,20 +1,21 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindPhysFS
-# ----------
-#
-#
-#
-# Locate PhysFS library This module defines PHYSFS_LIBRARY, the name of
-# the library to link against PHYSFS_FOUND, if false, do not try to link
-# to PHYSFS PHYSFS_INCLUDE_DIR, where to find physfs.h
-#
-# $PHYSFSDIR is an environment variable that would correspond to the
-# ./configure --prefix=$PHYSFSDIR used in building PHYSFS.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindPhysFS
+----------
+
+
+
+Locate PhysFS library This module defines PHYSFS_LIBRARY, the name of
+the library to link against PHYSFS_FOUND, if false, do not try to link
+to PHYSFS PHYSFS_INCLUDE_DIR, where to find physfs.h
+
+$PHYSFSDIR is an environment variable that would correspond to the
+./configure --prefix=$PHYSFSDIR used in building PHYSFS.
+
+Created by Eric Wing.
+#]=======================================================================]
find_path(PHYSFS_INCLUDE_DIR physfs.h
HINTS
@@ -23,9 +24,6 @@ find_path(PHYSFS_INCLUDE_DIR physfs.h
PATHS
~/Library/Frameworks
/Library/Frameworks
- /sw # Fink
- /opt/local # DarwinPorts
- /opt/csw # Blastwave
/opt
)
@@ -37,9 +35,6 @@ find_library(PHYSFS_LIBRARY
PATHS
~/Library/Frameworks
/Library/Frameworks
- /sw
- /opt/local
- /opt/csw
/opt
)
diff --git a/Modules/FindPike.cmake b/Modules/FindPike.cmake
index dff55a480..b78db2adb 100644
--- a/Modules/FindPike.cmake
+++ b/Modules/FindPike.cmake
@@ -1,30 +1,28 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindPike
-# --------
-#
-# Find Pike
-#
-# This module finds if PIKE is installed and determines where the
-# include files and libraries are. It also determines what the name of
-# the library is. This code sets the following variables:
-#
-# ::
-#
-# PIKE_INCLUDE_PATH = path to where program.h is found
-# PIKE_EXECUTABLE = full path to the pike binary
-
-file(GLOB PIKE_POSSIBLE_INCLUDE_PATHS
- /usr/include/pike/*
- /usr/local/include/pike/*)
+#[=======================================================================[.rst:
+FindPike
+--------
+
+Find Pike
+
+This module finds if PIKE is installed and determines where the
+include files and libraries are. It also determines what the name of
+the library is. This code sets the following variables:
+
+::
+
+ PIKE_INCLUDE_PATH = path to where program.h is found
+ PIKE_EXECUTABLE = full path to the pike binary
+#]=======================================================================]
find_path(PIKE_INCLUDE_PATH program.h
- ${PIKE_POSSIBLE_INCLUDE_PATHS})
+ ${PIKE_POSSIBLE_INCLUDE_PATHS}
+ PATH_SUFFIXES include/pike8.0/pike include/pike7.8/pike include/pike7.4/pike)
find_program(PIKE_EXECUTABLE
- NAMES pike7.4
+ NAMES pike8.0 pike 7.8 pike7.4
)
mark_as_advanced(
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index a5357fa1c..5162a44b3 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -1,19 +1,24 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindPkgConfig
-# -------------
-#
-# A `pkg-config` module for CMake.
-#
-# Finds the ``pkg-config`` executable and add the
-# :command:`pkg_check_modules` and :command:`pkg_search_module`
-# commands.
-#
-# In order to find the ``pkg-config`` executable, it uses the
-# :variable:`PKG_CONFIG_EXECUTABLE` variable or the ``PKG_CONFIG``
-# environment variable first.
+#[========================================[.rst:
+FindPkgConfig
+-------------
+
+A ``pkg-config`` module for CMake.
+
+Finds the ``pkg-config`` executable and adds the :command:`pkg_get_variable`,
+:command:`pkg_check_modules` and :command:`pkg_search_module` commands. The
+following variables will also be set:
+
+``PKG_CONFIG_FOUND``
+ if pkg-config executable was found
+``PKG_CONFIG_EXECUTABLE``
+ pathname of the pkg-config program
+``PKG_CONFIG_VERSION_STRING``
+ version of pkg-config (since CMake 2.8.8)
+
+#]========================================]
### Common stuff ####
set(PKG_CONFIG_VERSION 1)
@@ -79,23 +84,8 @@ macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp)
endif()
endmacro()
-#[========================================[.rst:
-.. command:: pkg_get_variable
-
- Retrieves the value of a variable from a package::
-
- pkg_get_variable(<RESULT> <MODULE> <VARIABLE>)
-
- If multiple values are returned variable will contain a
- :ref:`;-list <CMake Language Lists>`.
-
- For example:
-
- .. code-block:: cmake
-
- pkg_get_variable(GI_GIRDIR gobject-introspection-1.0 girdir)
-#]========================================]
-function (pkg_get_variable result pkg variable)
+# Internal version of pkg_get_variable; expects PKG_CONFIG_PATH to already be set
+function (_pkg_get_variable result pkg variable)
_pkgconfig_invoke("${pkg}" "prefix" "result" "" "--variable=${variable}")
set("${result}"
"${prefix_result}"
@@ -110,12 +100,13 @@ macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp)
endmacro()
# Splits given arguments into options and a package list
-macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path _imp_target)
+macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global)
set(${_is_req} 0)
set(${_is_silent} 0)
set(${_no_cmake_path} 0)
set(${_no_cmake_environment_path} 0)
set(${_imp_target} 0)
+ set(${_imp_target_global} 0)
if(DEFINED PKG_CONFIG_USE_CMAKE_PREFIX_PATH)
if(NOT PKG_CONFIG_USE_CMAKE_PREFIX_PATH)
set(${_no_cmake_path} 1)
@@ -142,14 +133,22 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma
if (_pkg STREQUAL "IMPORTED_TARGET")
set(${_imp_target} 1)
endif()
+ if (_pkg STREQUAL "GLOBAL")
+ set(${_imp_target_global} 1)
+ endif()
endforeach()
+ if (${_imp_target_global} AND NOT ${_imp_target})
+ message(SEND_ERROR "the argument GLOBAL may only be used together with IMPORTED_TARGET")
+ endif()
+
set(${_result} ${ARGN})
list(REMOVE_ITEM ${_result} "REQUIRED")
list(REMOVE_ITEM ${_result} "QUIET")
list(REMOVE_ITEM ${_result} "NO_CMAKE_PATH")
list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH")
list(REMOVE_ITEM ${_result} "IMPORTED_TARGET")
+ list(REMOVE_ITEM ${_result} "GLOBAL")
endmacro()
# Add the content of a variable or an environment variable to a list of
@@ -179,26 +178,24 @@ endfunction()
# scan the LDFLAGS returned by pkg-config for library directories and
# libraries, figure out the absolute paths of that libraries in the
-# given directories, and create an imported target from them
-function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_path)
+# given directories
+function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path)
unset(_libs)
unset(_find_opts)
# set the options that are used as long as the .pc file does not provide a library
# path to look into
if(_no_cmake_path)
- set(_find_opts "NO_CMAKE_PATH")
+ list(APPEND _find_opts "NO_CMAKE_PATH")
endif()
if(_no_cmake_environment_path)
- string(APPEND _find_opts " NO_CMAKE_ENVIRONMENT_PATH")
+ list(APPEND _find_opts "NO_CMAKE_ENVIRONMENT_PATH")
endif()
unset(_search_paths)
foreach (flag IN LISTS ${_prefix}_LDFLAGS)
if (flag MATCHES "^-L(.*)")
- # only look into the given paths from now on
list(APPEND _search_paths ${CMAKE_MATCH_1})
- set(_find_opts HINTS ${_search_paths} NO_DEFAULT_PATH)
continue()
endif()
if (flag MATCHES "^-l(.*)")
@@ -207,25 +204,49 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat
continue()
endif()
+ if(_search_paths)
+ # Firstly search in -L paths
+ find_library(pkgcfg_lib_${_prefix}_${_pkg_search}
+ NAMES ${_pkg_search}
+ HINTS ${_search_paths} NO_DEFAULT_PATH)
+ endif()
find_library(pkgcfg_lib_${_prefix}_${_pkg_search}
NAMES ${_pkg_search}
${_find_opts})
- list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}")
+ mark_as_advanced(pkgcfg_lib_${_prefix}_${_pkg_search})
+ if(pkgcfg_lib_${_prefix}_${_pkg_search})
+ list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}")
+ else()
+ list(APPEND _libs ${_pkg_search})
+ endif()
endforeach()
+ set(${_prefix}_LINK_LIBRARIES "${_libs}" PARENT_SCOPE)
+endfunction()
+
+# create an imported target from all the information returned by pkg-config
+function(_pkg_create_imp_target _prefix _imp_target_global)
# only create the target if it is linkable, i.e. no executables
if (NOT TARGET PkgConfig::${_prefix}
- AND ( ${_prefix}_INCLUDE_DIRS OR _libs OR ${_prefix}_CFLAGS_OTHER ))
- add_library(PkgConfig::${_prefix} INTERFACE IMPORTED)
+ AND ( ${_prefix}_INCLUDE_DIRS OR ${_prefix}_LINK_LIBRARIES OR ${_prefix}_LDFLAGS_OTHER OR ${_prefix}_CFLAGS_OTHER ))
+ if(${_imp_target_global})
+ set(_global_opt "GLOBAL")
+ else()
+ unset(_global_opt)
+ endif()
+ add_library(PkgConfig::${_prefix} INTERFACE IMPORTED ${_global_opt})
- unset(_props)
if(${_prefix}_INCLUDE_DIRS)
set_property(TARGET PkgConfig::${_prefix} PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${${_prefix}_INCLUDE_DIRS}")
endif()
- if(_libs)
+ if(${_prefix}_LINK_LIBRARIES)
+ set_property(TARGET PkgConfig::${_prefix} PROPERTY
+ INTERFACE_LINK_LIBRARIES "${${_prefix}_LINK_LIBRARIES}")
+ endif()
+ if(${_prefix}_LDFLAGS_OTHER)
set_property(TARGET PkgConfig::${_prefix} PROPERTY
- INTERFACE_LINK_LIBRARIES "${_libs}")
+ INTERFACE_LINK_OPTIONS "${${_prefix}_LDFLAGS_OTHER}")
endif()
if(${_prefix}_CFLAGS_OTHER)
set_property(TARGET PkgConfig::${_prefix} PROPERTY
@@ -234,13 +255,119 @@ function(_pkg_create_imp_target _prefix _no_cmake_path _no_cmake_environment_pat
endif()
endfunction()
+# recalculate the dynamic output
+# this is a macro and not a function so the result of _pkg_find_libs is automatically propagated
+macro(_pkg_recalculate _prefix _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global)
+ _pkg_find_libs(${_prefix} ${_no_cmake_path} ${_no_cmake_environment_path})
+ if(${_imp_target})
+ _pkg_create_imp_target(${_prefix} ${_imp_target_global})
+ endif()
+endmacro()
+
###
-macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _prefix)
+macro(_pkg_set_path_internal)
+ set(_extra_paths)
+
+ if(NOT _no_cmake_path)
+ _pkgconfig_add_extra_path(_extra_paths CMAKE_PREFIX_PATH)
+ _pkgconfig_add_extra_path(_extra_paths CMAKE_FRAMEWORK_PATH)
+ _pkgconfig_add_extra_path(_extra_paths CMAKE_APPBUNDLE_PATH)
+ endif()
+
+ if(NOT _no_cmake_environment_path)
+ _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_PREFIX_PATH)
+ _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_FRAMEWORK_PATH)
+ _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_APPBUNDLE_PATH)
+ endif()
+
+ if(NOT _extra_paths STREQUAL "")
+ # Save the PKG_CONFIG_PATH environment variable, and add paths
+ # from the CMAKE_PREFIX_PATH variables
+ set(_pkgconfig_path_old "$ENV{PKG_CONFIG_PATH}")
+ set(_pkgconfig_path "${_pkgconfig_path_old}")
+ if(NOT _pkgconfig_path STREQUAL "")
+ file(TO_CMAKE_PATH "${_pkgconfig_path}" _pkgconfig_path)
+ endif()
+
+ # Create a list of the possible pkgconfig subfolder (depending on
+ # the system
+ set(_lib_dirs)
+ if(NOT DEFINED CMAKE_SYSTEM_NAME
+ OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
+ AND NOT CMAKE_CROSSCOMPILING))
+ if(EXISTS "/etc/debian_version") # is this a debian system ?
+ if(CMAKE_LIBRARY_ARCHITECTURE)
+ list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig")
+ endif()
+ else()
+ # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties
+ get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS)
+ if(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
+ list(APPEND _lib_dirs "lib32/pkgconfig")
+ endif()
+ get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
+ if(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
+ list(APPEND _lib_dirs "lib64/pkgconfig")
+ endif()
+ get_property(uselibx32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIBX32_PATHS)
+ if(uselibx32 AND CMAKE_INTERNAL_PLATFORM_ABI STREQUAL "ELF X32")
+ list(APPEND _lib_dirs "libx32/pkgconfig")
+ endif()
+ endif()
+ endif()
+ if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT CMAKE_CROSSCOMPILING)
+ list(APPEND _lib_dirs "libdata/pkgconfig")
+ endif()
+ list(APPEND _lib_dirs "lib/pkgconfig")
+ list(APPEND _lib_dirs "share/pkgconfig")
+
+ # Check if directories exist and eventually append them to the
+ # pkgconfig path list
+ foreach(_prefix_dir ${_extra_paths})
+ foreach(_lib_dir ${_lib_dirs})
+ if(EXISTS "${_prefix_dir}/${_lib_dir}")
+ list(APPEND _pkgconfig_path "${_prefix_dir}/${_lib_dir}")
+ list(REMOVE_DUPLICATES _pkgconfig_path)
+ endif()
+ endforeach()
+ endforeach()
+
+ # Prepare and set the environment variable
+ if(NOT _pkgconfig_path STREQUAL "")
+ # remove empty values from the list
+ list(REMOVE_ITEM _pkgconfig_path "")
+ file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path)
+ if(UNIX)
+ string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}")
+ string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}")
+ endif()
+ set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path}")
+ endif()
+
+ # Unset variables
+ unset(_lib_dirs)
+ unset(_pkgconfig_path)
+ endif()
+endmacro()
+
+macro(_pkg_restore_path_internal)
+ if(NOT _extra_paths STREQUAL "")
+ # Restore the environment variable
+ set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path_old}")
+ endif()
+
+ unset(_extra_paths)
+ unset(_pkgconfig_path_old)
+endmacro()
+
+###
+macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _prefix)
_pkgconfig_unset(${_prefix}_FOUND)
_pkgconfig_unset(${_prefix}_VERSION)
_pkgconfig_unset(${_prefix}_PREFIX)
_pkgconfig_unset(${_prefix}_INCLUDEDIR)
_pkgconfig_unset(${_prefix}_LIBDIR)
+ _pkgconfig_unset(${_prefix}_MODULE_NAME)
_pkgconfig_unset(${_prefix}_LIBS)
_pkgconfig_unset(${_prefix}_LIBS_L)
_pkgconfig_unset(${_prefix}_LIBS_PATHS)
@@ -274,92 +401,14 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
set(_pkg_check_modules_packages)
set(_pkg_check_modules_failed)
- set(_extra_paths)
-
- if(NOT _no_cmake_path)
- _pkgconfig_add_extra_path(_extra_paths CMAKE_PREFIX_PATH)
- _pkgconfig_add_extra_path(_extra_paths CMAKE_FRAMEWORK_PATH)
- _pkgconfig_add_extra_path(_extra_paths CMAKE_APPBUNDLE_PATH)
- endif()
-
- if(NOT _no_cmake_environment_path)
- _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_PREFIX_PATH)
- _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_FRAMEWORK_PATH)
- _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_APPBUNDLE_PATH)
- endif()
-
- if(NOT "${_extra_paths}" STREQUAL "")
- # Save the PKG_CONFIG_PATH environment variable, and add paths
- # from the CMAKE_PREFIX_PATH variables
- set(_pkgconfig_path_old "$ENV{PKG_CONFIG_PATH}")
- set(_pkgconfig_path "${_pkgconfig_path_old}")
- if(NOT "${_pkgconfig_path}" STREQUAL "")
- file(TO_CMAKE_PATH "${_pkgconfig_path}" _pkgconfig_path)
- endif()
-
- # Create a list of the possible pkgconfig subfolder (depending on
- # the system
- set(_lib_dirs)
- if(NOT DEFINED CMAKE_SYSTEM_NAME
- OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
- AND NOT CMAKE_CROSSCOMPILING))
- if(EXISTS "/etc/debian_version") # is this a debian system ?
- if(CMAKE_LIBRARY_ARCHITECTURE)
- list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig")
- endif()
- else()
- # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties
- get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS)
- if(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
- list(APPEND _lib_dirs "lib32/pkgconfig")
- endif()
- get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
- if(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
- list(APPEND _lib_dirs "lib64/pkgconfig")
- endif()
- get_property(uselibx32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIBX32_PATHS)
- if(uselibx32 AND CMAKE_INTERNAL_PLATFORM_ABI STREQUAL "ELF X32")
- list(APPEND _lib_dirs "libx32/pkgconfig")
- endif()
- endif()
- endif()
- list(APPEND _lib_dirs "lib/pkgconfig")
- list(APPEND _lib_dirs "share/pkgconfig")
-
- # Check if directories exist and eventually append them to the
- # pkgconfig path list
- foreach(_prefix_dir ${_extra_paths})
- foreach(_lib_dir ${_lib_dirs})
- if(EXISTS "${_prefix_dir}/${_lib_dir}")
- list(APPEND _pkgconfig_path "${_prefix_dir}/${_lib_dir}")
- list(REMOVE_DUPLICATES _pkgconfig_path)
- endif()
- endforeach()
- endforeach()
-
- # Prepare and set the environment variable
- if(NOT "${_pkgconfig_path}" STREQUAL "")
- # remove empty values from the list
- list(REMOVE_ITEM _pkgconfig_path "")
- file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path)
- if(UNIX)
- string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}")
- string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}")
- endif()
- set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path}")
- endif()
-
- # Unset variables
- unset(_lib_dirs)
- unset(_pkgconfig_path)
- endif()
+ _pkg_set_path_internal()
# iterate through module list and check whether they exist and match the required version
foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list})
set(_pkg_check_modules_exist_query)
# check whether version is given
- if (_pkg_check_modules_pkg MATCHES "(.*[^><])(>=|=|<=)(.*)")
+ if (_pkg_check_modules_pkg MATCHES "(.*[^><])(=|[><]=?)(.*)")
set(_pkg_check_modules_pkg_name "${CMAKE_MATCH_1}")
set(_pkg_check_modules_pkg_op "${CMAKE_MATCH_2}")
set(_pkg_check_modules_pkg_ver "${CMAKE_MATCH_3}")
@@ -377,9 +426,11 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
list(APPEND _pkg_check_modules_packages "${_pkg_check_modules_pkg_name}")
# create the final query which is of the format:
+ # * <pkg-name> > <version>
# * <pkg-name> >= <version>
# * <pkg-name> = <version>
# * <pkg-name> <= <version>
+ # * <pkg-name> < <version>
# * --exists <pkg-name>
list(APPEND _pkg_check_modules_exist_query --print-errors --short-errors)
if (_pkg_check_modules_pkg_op)
@@ -434,6 +485,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
foreach (variable IN ITEMS PREFIX INCLUDEDIR LIBDIR)
_pkgconfig_set("${_pkg_check_prefix}_${variable}" "${${_pkg_check_prefix}_${variable}}")
endforeach ()
+ _pkgconfig_set("${_pkg_check_prefix}_MODULE_NAME" "${_pkg_check_modules_pkg}")
if (NOT ${_is_silent})
message(STATUS " Found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}")
@@ -450,18 +502,10 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags )
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other )
- if (_imp_target)
- _pkg_create_imp_target("${_prefix}" _no_cmake_path _no_cmake_environment_path)
- endif()
- endif()
-
- if(NOT "${_extra_paths}" STREQUAL "")
- # Restore the environment variable
- set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path_old}")
+ _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global})
endif()
- unset(_extra_paths)
- unset(_pkgconfig_path_old)
+ _pkg_restore_path_internal()
else()
if (${_is_required})
message(SEND_ERROR "pkg-config tool not found")
@@ -469,130 +513,143 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma
endif()
endmacro()
-###
-### User visible macros start here
-###
#[========================================[.rst:
.. command:: pkg_check_modules
- Checks for all the given modules. ::
+ Checks for all the given modules, setting a variety of result variables in
+ the calling scope.
- pkg_check_modules(<PREFIX> [REQUIRED] [QUIET]
- [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH]
- [IMPORTED_TARGET]
- <MODULE> [<MODULE>]*)
-
-
- When the ``REQUIRED`` argument was set, macros will fail with an error
- when module(s) could not be found.
-
- When the ``QUIET`` argument is set, no status messages will be printed.
-
- By default, if :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or
- later, or if :variable:`PKG_CONFIG_USE_CMAKE_PREFIX_PATH` is set, the
- :variable:`CMAKE_PREFIX_PATH`, :variable:`CMAKE_FRAMEWORK_PATH`, and
- :variable:`CMAKE_APPBUNDLE_PATH` cache and environment variables will
- be added to ``pkg-config`` search path.
- The ``NO_CMAKE_PATH`` and ``NO_CMAKE_ENVIRONMENT_PATH`` arguments
- disable this behavior for the cache variables and the environment
- variables, respectively.
- The ``IMPORTED_TARGET`` argument will create an imported target named
- PkgConfig::<PREFIX>> that can be passed directly as an argument to
- :command:`target_link_libraries`.
-
- It sets the following variables: ::
-
- PKG_CONFIG_FOUND ... if pkg-config executable was found
- PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program
- PKG_CONFIG_VERSION_STRING ... the version of the pkg-config program found
- (since CMake 2.8.8)
-
- For the following variables two sets of values exist; first one is the
- common one and has the given PREFIX. The second set contains flags
- which are given out when ``pkg-config`` was called with the ``--static``
- option. ::
-
- <XPREFIX>_FOUND ... set to 1 if module(s) exist
- <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l')
- <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L')
- <XPREFIX>_LDFLAGS ... all required linker flags
- <XPREFIX>_LDFLAGS_OTHER ... all other linker flags
- <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I')
- <XPREFIX>_CFLAGS ... all required cflags
- <XPREFIX>_CFLAGS_OTHER ... the other compiler flags
-
- ::
-
- <XPREFIX> = <PREFIX> for common case
- <XPREFIX> = <PREFIX>_STATIC for static linking
-
- Every variable containing multiple values will be a
- :ref:`;-list <CMake Language Lists>`.
-
- There are some special variables whose prefix depends on the count of
- given modules. When there is only one module, <PREFIX> stays
- unchanged. When there are multiple modules, the prefix will be
- changed to <PREFIX>_<MODNAME>: ::
-
- <XPREFIX>_VERSION ... version of the module
- <XPREFIX>_PREFIX ... prefix-directory of the module
- <XPREFIX>_INCLUDEDIR ... include-dir of the module
- <XPREFIX>_LIBDIR ... lib-dir of the module
-
- ::
-
- <XPREFIX> = <PREFIX> when |MODULES| == 1, else
- <XPREFIX> = <PREFIX>_<MODNAME>
-
- A <MODULE> parameter can have the following formats: ::
+ .. code-block:: cmake
- {MODNAME} ... matches any version
- {MODNAME}>={VERSION} ... at least version <VERSION> is required
- {MODNAME}={VERSION} ... exactly version <VERSION> is required
- {MODNAME}<={VERSION} ... modules must not be newer than <VERSION>
+ pkg_check_modules(<prefix>
+ [REQUIRED] [QUIET]
+ [NO_CMAKE_PATH]
+ [NO_CMAKE_ENVIRONMENT_PATH]
+ [IMPORTED_TARGET [GLOBAL]]
+ <moduleSpec> [<moduleSpec>...])
+
+ When the ``REQUIRED`` argument is given, the command will fail with an error
+ if module(s) could not be found.
+
+ When the ``QUIET`` argument is given, no status messages will be printed.
+
+ By default, if :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or
+ later, or if :variable:`PKG_CONFIG_USE_CMAKE_PREFIX_PATH` is set to a
+ boolean ``True`` value, then the :variable:`CMAKE_PREFIX_PATH`,
+ :variable:`CMAKE_FRAMEWORK_PATH`, and :variable:`CMAKE_APPBUNDLE_PATH` cache
+ and environment variables will be added to the ``pkg-config`` search path.
+ The ``NO_CMAKE_PATH`` and ``NO_CMAKE_ENVIRONMENT_PATH`` arguments
+ disable this behavior for the cache variables and environment variables
+ respectively.
+
+ The ``IMPORTED_TARGET`` argument will create an imported target named
+ ``PkgConfig::<prefix>`` that can be passed directly as an argument to
+ :command:`target_link_libraries`. The ``GLOBAL`` argument will make the
+ imported target available in global scope.
+
+ Each ``<moduleSpec>`` can be either a bare module name or it can be a
+ module name with a version constraint (operators ``=``, ``<``, ``>``,
+ ``<=`` and ``>=`` are supported). The following are examples for a module
+ named ``foo`` with various constraints:
+
+ - ``foo`` matches any version.
+ - ``foo<2`` only matches versions before 2.
+ - ``foo>=3.1`` matches any version from 3.1 or later.
+ - ``foo=1.2.3`` requires that foo must be exactly version 1.2.3.
+
+ The following variables may be set upon return. Two sets of values exist:
+ One for the common case (``<XXX> = <prefix>``) and another for the
+ information ``pkg-config`` provides when called with the ``--static``
+ option (``<XXX> = <prefix>_STATIC``).
+
+ ``<XXX>_FOUND``
+ set to 1 if module(s) exist
+ ``<XXX>_LIBRARIES``
+ only the libraries (without the '-l')
+ ``<XXX>_LINK_LIBRARIES``
+ the libraries and their absolute paths
+ ``<XXX>_LIBRARY_DIRS``
+ the paths of the libraries (without the '-L')
+ ``<XXX>_LDFLAGS``
+ all required linker flags
+ ``<XXX>_LDFLAGS_OTHER``
+ all other linker flags
+ ``<XXX>_INCLUDE_DIRS``
+ the '-I' preprocessor flags (without the '-I')
+ ``<XXX>_CFLAGS``
+ all required cflags
+ ``<XXX>_CFLAGS_OTHER``
+ the other compiler flags
+
+ All but ``<XXX>_FOUND`` may be a :ref:`;-list <CMake Language Lists>` if the
+ associated variable returned from ``pkg-config`` has multiple values.
+
+ There are some special variables whose prefix depends on the number of
+ ``<moduleSpec>`` given. When there is only one ``<moduleSpec>``,
+ ``<YYY>`` will simply be ``<prefix>``, but if two or more ``<moduleSpec>``
+ items are given, ``<YYY>`` will be ``<prefix>_<moduleName>``.
+
+ ``<YYY>_VERSION``
+ version of the module
+ ``<YYY>_PREFIX``
+ prefix directory of the module
+ ``<YYY>_INCLUDEDIR``
+ include directory of the module
+ ``<YYY>_LIBDIR``
+ lib directory of the module
+
+ Examples:
- Examples
+ .. code-block:: cmake
- .. code-block:: cmake
+ pkg_check_modules (GLIB2 glib-2.0)
- pkg_check_modules (GLIB2 glib-2.0)
+ Looks for any version of glib2. If found, the output variable
+ ``GLIB2_VERSION`` will hold the actual version found.
- .. code-block:: cmake
+ .. code-block:: cmake
- pkg_check_modules (GLIB2 glib-2.0>=2.10)
+ pkg_check_modules (GLIB2 glib-2.0>=2.10)
- Requires at least version 2.10 of glib2 and defines e.g.
- ``GLIB2_VERSION=2.10.3``
+ Looks for at least version 2.10 of glib2. If found, the output variable
+ ``GLIB2_VERSION`` will hold the actual version found.
- .. code-block:: cmake
+ .. code-block:: cmake
- pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0)
+ pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0)
- Requires both glib2 and gtk2, and defines e.g.
- ``FOO_glib-2.0_VERSION=2.10.3`` and ``FOO_gtk+-2.0_VERSION=2.8.20``
+ Looks for both glib2-2.0 (at least version 2.10) and any version of
+ gtk2+-2.0. Only if both are found will ``FOO`` be considered found.
+ The ``FOO_glib-2.0_VERSION`` and ``FOO_gtk+-2.0_VERSION`` variables will be
+ set to their respective found module versions.
- .. code-block:: cmake
+ .. code-block:: cmake
pkg_check_modules (XRENDER REQUIRED xrender)
- Defines for example::
+ Requires any version of ``xrender``. Example output variables set by a
+ successful call::
- XRENDER_LIBRARIES=Xrender;X11``
- XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp
+ XRENDER_LIBRARIES=Xrender;X11
+ XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp
#]========================================]
macro(pkg_check_modules _prefix _module0)
- _pkgconfig_parse_options(_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target "${_module0}" ${ARGN})
+ _pkgconfig_parse_options(_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global "${_module0}" ${ARGN})
# check cached value
- if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND OR NOT "${__pkg_config_arguments_${_prefix}}" STREQUAL "${_module0};${ARGN}")
- _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} "${_prefix}" ${_pkg_modules})
+ if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND OR
+ (NOT "${ARGN}" STREQUAL "" AND NOT "${__pkg_config_arguments_${_prefix}}" STREQUAL "${_module0};${ARGN}") OR
+ ( "${ARGN}" STREQUAL "" AND NOT "${__pkg_config_arguments_${_prefix}}" STREQUAL "${_module0}"))
+ _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} "${_prefix}" ${_pkg_modules})
_pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
if (${_prefix}_FOUND)
_pkgconfig_set(__pkg_config_arguments_${_prefix} "${_module0};${ARGN}")
endif()
- elseif (${_prefix}_FOUND AND ${_imp_target})
- _pkg_create_imp_target("${_prefix}" _no_cmake_path _no_cmake_environment_path)
+ else()
+ if (${_prefix}_FOUND)
+ _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global})
+ endif()
endif()
endmacro()
@@ -600,22 +657,31 @@ endmacro()
#[========================================[.rst:
.. command:: pkg_search_module
- Same as :command:`pkg_check_modules`, but instead it checks for given
- modules and uses the first working one. ::
+ The behavior of this command is the same as :command:`pkg_check_modules`,
+ except that rather than checking for all the specified modules, it searches
+ for just the first successful match.
+
+ .. code-block:: cmake
- pkg_search_module(<PREFIX> [REQUIRED] [QUIET]
- [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH]
- [IMPORTED_TARGET]
- <MODULE> [<MODULE>]*)
+ pkg_search_module(<prefix>
+ [REQUIRED] [QUIET]
+ [NO_CMAKE_PATH]
+ [NO_CMAKE_ENVIRONMENT_PATH]
+ [IMPORTED_TARGET [GLOBAL]]
+ <moduleSpec> [<moduleSpec>...])
- Examples
+ If a module is found, the ``<prefix>_MODULE_NAME`` variable will contain the
+ name of the matching module. This variable can be used if you need to run
+ :command:`pkg_get_variable`.
- .. code-block:: cmake
+ Example:
- pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2)
+ .. code-block:: cmake
+
+ pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2)
#]========================================]
macro(pkg_search_module _prefix _module0)
- _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target "${_module0}" ${ARGN})
+ _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global "${_module0}" ${ARGN})
# check cached value
if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND)
set(_pkg_modules_found 0)
@@ -627,11 +693,12 @@ macro(pkg_search_module _prefix _module0)
# iterate through all modules and stop at the first working one.
foreach(_pkg_alt ${_pkg_modules_alt})
if(NOT _pkg_modules_found)
- _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} "${_prefix}" "${_pkg_alt}")
+ _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} "${_prefix}" "${_pkg_alt}")
endif()
if (${_prefix}_FOUND)
set(_pkg_modules_found 1)
+ break()
endif()
endforeach()
@@ -642,28 +709,61 @@ macro(pkg_search_module _prefix _module0)
endif()
_pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
- elseif (${_prefix}_FOUND AND ${_imp_target})
- _pkg_create_imp_target("${_prefix}" _no_cmake_path _no_cmake_environment_path)
+ elseif (${_prefix}_FOUND)
+ _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global})
endif()
endmacro()
+#[========================================[.rst:
+.. command:: pkg_get_variable
+
+ Retrieves the value of a pkg-config variable ``varName`` and stores it in the
+ result variable ``resultVar`` in the calling scope.
+
+ .. code-block:: cmake
+
+ pkg_get_variable(<resultVar> <moduleName> <varName>)
+
+ If ``pkg-config`` returns multiple values for the specified variable,
+ ``resultVar`` will contain a :ref:`;-list <CMake Language Lists>`.
+
+ For example:
+
+ .. code-block:: cmake
+
+ pkg_get_variable(GI_GIRDIR gobject-introspection-1.0 girdir)
+#]========================================]
+function (pkg_get_variable result pkg variable)
+ _pkg_set_path_internal()
+ _pkgconfig_invoke("${pkg}" "prefix" "result" "" "--variable=${variable}")
+ set("${result}"
+ "${prefix_result}"
+ PARENT_SCOPE)
+ _pkg_restore_path_internal()
+endfunction ()
+
#[========================================[.rst:
-.. variable:: PKG_CONFIG_EXECUTABLE
+Variables Affecting Behavior
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Path to the pkg-config executable.
+.. variable:: PKG_CONFIG_EXECUTABLE
+ This can be set to the path of the pkg-config executable. If not provided,
+ it will be set by the module as a result of calling :command:`find_program`
+ internally. The ``PKG_CONFIG`` environment variable can be used as a hint.
.. variable:: PKG_CONFIG_USE_CMAKE_PREFIX_PATH
- Whether :command:`pkg_check_modules` and :command:`pkg_search_module`
- should add the paths in :variable:`CMAKE_PREFIX_PATH`,
- :variable:`CMAKE_FRAMEWORK_PATH`, and :variable:`CMAKE_APPBUNDLE_PATH`
- cache and environment variables to ``pkg-config`` search path.
+ Specifies whether :command:`pkg_check_modules` and
+ :command:`pkg_search_module` should add the paths in the
+ :variable:`CMAKE_PREFIX_PATH`, :variable:`CMAKE_FRAMEWORK_PATH` and
+ :variable:`CMAKE_APPBUNDLE_PATH` cache and environment variables to the
+ ``pkg-config`` search path.
- If this variable is not set, this behavior is enabled by default if
- :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or later, disabled
- otherwise.
+ If this variable is not set, this behavior is enabled by default if
+ :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or later, disabled
+ otherwise.
#]========================================]
diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake
index 9e2194ce4..1927aa4b8 100644
--- a/Modules/FindPostgreSQL.cmake
+++ b/Modules/FindPostgreSQL.cmake
@@ -1,20 +1,34 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindPostgreSQL
-# --------------
-#
-# Find the PostgreSQL installation.
-#
-# This module defines
-#
-# ::
-#
-# PostgreSQL_LIBRARIES - the PostgreSQL libraries needed for linking
-# PostgreSQL_INCLUDE_DIRS - the directories of the PostgreSQL headers
-# PostgreSQL_LIBRARY_DIRS - the link directories for PostgreSQL libraries
-# PostgreSQL_VERSION_STRING - the version of PostgreSQL found (since CMake 2.8.8)
+#[=======================================================================[.rst:
+FindPostgreSQL
+--------------
+
+Find the PostgreSQL installation.
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``PostgreSQL::PostgreSQL``
+if PostgreSQL has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``PostgreSQL_FOUND``
+ True if PostgreSQL is found.
+``PostgreSQL_LIBRARIES``
+ the PostgreSQL libraries needed for linking
+``PostgreSQL_INCLUDE_DIRS``
+ the directories of the PostgreSQL headers
+``PostgreSQL_LIBRARY_DIRS``
+ the link directories for PostgreSQL libraries
+``PostgreSQL_VERSION_STRING``
+ the version of PostgreSQL found
+#]=======================================================================]
# ----------------------------------------------------------------------------
# History:
@@ -23,11 +37,11 @@
# ----------------------------------------------------------------------------
# Note:
# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the
-# version mumber of the implementation of PostgreSQL.
+# version number of the implementation of PostgreSQL.
# In Windows the default installation of PostgreSQL uses that as part of the path.
# E.g C:\Program Files\PostgreSQL\8.4.
# Currently, the following version numbers are known to this module:
-# "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0"
+# "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0"
#
# To use this variable just do something like this:
# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4")
@@ -48,6 +62,8 @@
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
# PostgreSQL_LIBRARIES - The PostgreSQL libraries.
#
+# The ``PostgreSQL::PostgreSQL`` imported target is also created.
+#
# ----------------------------------------------------------------------------
# If you have installed PostgreSQL in a non-standard location.
# (Please note that in the following comments, it is assumed that <Your Path>
@@ -71,7 +87,7 @@ set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to wher
set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS}
- "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")
+ "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")
# Define additional search paths for root directories.
set( PostgreSQL_ROOT_DIRECTORIES
@@ -89,10 +105,14 @@ foreach(suffix ${PostgreSQL_KNOWN_VERSIONS})
endif()
if(UNIX)
list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES
+ "postgresql${suffix}"
"pgsql-${suffix}/lib")
list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES
+ "postgresql${suffix}"
+ "postgresql/${suffix}"
"pgsql-${suffix}/include")
list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES
+ "postgresql${suffix}/server"
"postgresql/${suffix}/server"
"pgsql-${suffix}/include/server")
endif()
@@ -139,17 +159,38 @@ if ( WIN32 )
set (PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND})
endif()
-find_library(PostgreSQL_LIBRARY
- NAMES ${PostgreSQL_LIBRARY_TO_FIND}
- PATHS
- ${PostgreSQL_ROOT_DIRECTORIES}
- PATH_SUFFIXES
- lib
- ${PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES}
- # Help the user find it if we cannot.
- DOC "The ${PostgreSQL_LIBRARY_DIR_MESSAGE}"
-)
-get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH)
+function(__postgresql_find_library _name)
+ find_library(${_name}
+ NAMES ${ARGN}
+ PATHS
+ ${PostgreSQL_ROOT_DIRECTORIES}
+ PATH_SUFFIXES
+ lib
+ ${PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES}
+ # Help the user find it if we cannot.
+ DOC "The ${PostgreSQL_LIBRARY_DIR_MESSAGE}"
+ )
+endfunction()
+
+# For compatibility with versions prior to this multi-config search, honor
+# any PostgreSQL_LIBRARY that is already specified and skip the search.
+if(PostgreSQL_LIBRARY)
+ set(PostgreSQL_LIBRARIES "${PostgreSQL_LIBRARY}")
+ get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY}" PATH)
+else()
+ __postgresql_find_library(PostgreSQL_LIBRARY_RELEASE ${PostgreSQL_LIBRARY_TO_FIND})
+ __postgresql_find_library(PostgreSQL_LIBRARY_DEBUG ${PostgreSQL_LIBRARY_TO_FIND}d)
+ include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
+ select_library_configurations(PostgreSQL)
+ mark_as_advanced(PostgreSQL_LIBRARY_RELEASE PostgreSQL_LIBRARY_DEBUG)
+ if(PostgreSQL_LIBRARY_RELEASE)
+ get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_RELEASE}" PATH)
+ elseif(PostgreSQL_LIBRARY_DEBUG)
+ get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_DEBUG}" PATH)
+ else()
+ set(PostgreSQL_LIBRARY_DIR "")
+ endif()
+endif()
if (PostgreSQL_INCLUDE_DIR)
# Some platforms include multiple pg_config.hs for multi-lib configurations
@@ -159,14 +200,45 @@ if (PostgreSQL_INCLUDE_DIR)
foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS})
if(EXISTS "${_PG_CONFIG_HEADER}")
file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str
- REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
+ REGEX "^#define[\t ]+PG_VERSION_NUM[\t ]+.*")
if(pgsql_version_str)
- string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*"
- "\\1" PostgreSQL_VERSION_STRING "${pgsql_version_str}")
+ string(REGEX REPLACE "^#define[\t ]+PG_VERSION_NUM[\t ]+([0-9]*).*"
+ "\\1" _PostgreSQL_VERSION_NUM "${pgsql_version_str}")
break()
endif()
endif()
endforeach()
+ if (_PostgreSQL_VERSION_NUM)
+ # 9.x and older encoding
+ if (_PostgreSQL_VERSION_NUM LESS 100000)
+ math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000")
+ math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000 / 100")
+ math(EXPR _PostgreSQL_patch_version "${_PostgreSQL_VERSION_NUM} % 100")
+ set(PostgreSQL_VERSION_STRING "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}.${_PostgreSQL_patch_version}")
+ unset(_PostgreSQL_major_version)
+ unset(_PostgreSQL_minor_version)
+ unset(_PostgreSQL_patch_version)
+ else ()
+ math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000")
+ math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000")
+ set(PostgreSQL_VERSION_STRING "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}")
+ unset(_PostgreSQL_major_version)
+ unset(_PostgreSQL_minor_version)
+ endif ()
+ else ()
+ foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS})
+ if(EXISTS "${_PG_CONFIG_HEADER}")
+ file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str
+ REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
+ if(pgsql_version_str)
+ string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*"
+ "\\1" PostgreSQL_VERSION_STRING "${pgsql_version_str}")
+ break()
+ endif()
+ endif()
+ endforeach()
+ endif ()
+ unset(_PostgreSQL_VERSION_NUM)
unset(pgsql_version_str)
endif()
@@ -177,11 +249,36 @@ find_package_handle_standard_args(PostgreSQL
VERSION_VAR PostgreSQL_VERSION_STRING)
set(PostgreSQL_FOUND ${POSTGRESQL_FOUND})
+function(__postgresql_import_library _target _var _config)
+ if(_config)
+ set(_config_suffix "_${_config}")
+ else()
+ set(_config_suffix "")
+ endif()
+
+ set(_lib "${${_var}${_config_suffix}}")
+ if(EXISTS "${_lib}")
+ if(_config)
+ set_property(TARGET ${_target} APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS ${_config})
+ endif()
+ set_target_properties(${_target} PROPERTIES
+ IMPORTED_LOCATION${_config_suffix} "${_lib}")
+ endif()
+endfunction()
+
# Now try to get the include and library path.
if(PostgreSQL_FOUND)
+ if (NOT TARGET PostgreSQL::PostgreSQL)
+ add_library(PostgreSQL::PostgreSQL UNKNOWN IMPORTED)
+ set_target_properties(PostgreSQL::PostgreSQL PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${PostgreSQL_INCLUDE_DIR};${PostgreSQL_TYPE_INCLUDE_DIR}")
+ __postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "")
+ __postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "RELEASE")
+ __postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "DEBUG")
+ endif ()
set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ${PostgreSQL_TYPE_INCLUDE_DIR} )
set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} )
- set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY})
endif()
-mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR PostgreSQL_LIBRARY )
+mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR)
diff --git a/Modules/FindProducer.cmake b/Modules/FindProducer.cmake
index 500c8edf6..65495b5ba 100644
--- a/Modules/FindProducer.cmake
+++ b/Modules/FindProducer.cmake
@@ -1,35 +1,36 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindProducer
-# ------------
-#
-#
-#
-# Though Producer isn't directly part of OpenSceneGraph, its primary
-# user is OSG so I consider this part of the Findosg* suite used to find
-# OpenSceneGraph components. You'll notice that I accept OSGDIR as an
-# environment path.
-#
-# Each component is separate and you must opt in to each module. You
-# must also opt into OpenGL (and OpenThreads?) as these modules won't do
-# it for you. This is to allow you control over your own system piece
-# by piece in case you need to opt out of certain components or change
-# the Find behavior for a particular module (perhaps because the default
-# FindOpenGL.cmake module doesn't work with your system as an example).
-# If you want to use a more convenient module that includes everything,
-# use the FindOpenSceneGraph.cmake instead of the Findosg*.cmake
-# modules.
-#
-# Locate Producer This module defines PRODUCER_LIBRARY PRODUCER_FOUND,
-# if false, do not try to link to Producer PRODUCER_INCLUDE_DIR, where
-# to find the headers
-#
-# $PRODUCER_DIR is an environment variable that would correspond to the
-# ./configure --prefix=$PRODUCER_DIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindProducer
+------------
+
+
+
+Though Producer isn't directly part of OpenSceneGraph, its primary
+user is OSG so I consider this part of the Findosg* suite used to find
+OpenSceneGraph components. You'll notice that I accept OSGDIR as an
+environment path.
+
+Each component is separate and you must opt in to each module. You
+must also opt into OpenGL (and OpenThreads?) as these modules won't do
+it for you. This is to allow you control over your own system piece
+by piece in case you need to opt out of certain components or change
+the Find behavior for a particular module (perhaps because the default
+FindOpenGL.cmake module doesn't work with your system as an example).
+If you want to use a more convenient module that includes everything,
+use the FindOpenSceneGraph.cmake instead of the Findosg*.cmake
+modules.
+
+Locate Producer This module defines PRODUCER_LIBRARY PRODUCER_FOUND,
+if false, do not try to link to Producer PRODUCER_INCLUDE_DIR, where
+to find the headers
+
+$PRODUCER_DIR is an environment variable that would correspond to the
+./configure --prefix=$PRODUCER_DIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <Producer/CameraGroup>
@@ -44,12 +45,9 @@ find_path(PRODUCER_INCLUDE_DIR Producer/CameraGroup
PATHS
~/Library/Frameworks
/Library/Frameworks
- /sw/include # Fink
- /opt/local/include # DarwinPorts
- /opt/csw/include # Blastwave
- /opt/include
- [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/include
- [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include
+ /opt
+ [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]
+ [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]
)
find_library(PRODUCER_LIBRARY
@@ -60,9 +58,6 @@ find_library(PRODUCER_LIBRARY
ENV OSGDIR
PATH_SUFFIXES lib
PATHS
- /sw
- /opt/local
- /opt/csw
/opt
)
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 33262f3d6..2d4596580 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -1,187 +1,295 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindProtobuf
-# ------------
-#
-# Locate and configure the Google Protocol Buffers library.
-#
-# The following variables can be set and are optional:
-#
-# ``Protobuf_SRC_ROOT_FOLDER``
-# When compiling with MSVC, if this cache variable is set
-# the protobuf-default VS project build locations
-# (vsprojects/Debug and vsprojects/Release
-# or vsprojects/x64/Debug and vsprojects/x64/Release)
-# will be searched for libraries and binaries.
-# ``Protobuf_IMPORT_DIRS``
-# List of additional directories to be searched for
-# imported .proto files.
-# ``Protobuf_DEBUG``
-# Show debug messages.
-# ``Protobuf_USE_STATIC_LIBS``
-# Set to ON to force the use of the static libraries.
-# Default is OFF.
-#
-# Defines the following variables:
-#
-# ``Protobuf_FOUND``
-# Found the Google Protocol Buffers library
-# (libprotobuf & header files)
-# ``Protobuf_VERSION``
-# Version of package found.
-# ``Protobuf_INCLUDE_DIRS``
-# Include directories for Google Protocol Buffers
-# ``Protobuf_LIBRARIES``
-# The protobuf libraries
-# ``Protobuf_PROTOC_LIBRARIES``
-# The protoc libraries
-# ``Protobuf_LITE_LIBRARIES``
-# The protobuf-lite libraries
-#
-# The following :prop_tgt:`IMPORTED` targets are also defined:
-#
-# ``protobuf::libprotobuf``
-# The protobuf library.
-# ``protobuf::libprotobuf-lite``
-# The protobuf lite library.
-# ``protobuf::libprotoc``
-# The protoc library.
-#
-# The following cache variables are also available to set or use:
-#
-# ``Protobuf_LIBRARY``
-# The protobuf library
-# ``Protobuf_PROTOC_LIBRARY``
-# The protoc library
-# ``Protobuf_INCLUDE_DIR``
-# The include directory for protocol buffers
-# ``Protobuf_PROTOC_EXECUTABLE``
-# The protoc compiler
-# ``Protobuf_LIBRARY_DEBUG``
-# The protobuf library (debug)
-# ``Protobuf_PROTOC_LIBRARY_DEBUG``
-# The protoc library (debug)
-# ``Protobuf_LITE_LIBRARY``
-# The protobuf lite library
-# ``Protobuf_LITE_LIBRARY_DEBUG``
-# The protobuf lite library (debug)
-#
-# Example:
-#
-# .. code-block:: cmake
-#
-# find_package(Protobuf REQUIRED)
-# include_directories(${Protobuf_INCLUDE_DIRS})
-# include_directories(${CMAKE_CURRENT_BINARY_DIR})
-# protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS foo.proto)
-# protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS EXPORT_MACRO DLL_EXPORT foo.proto)
-# protobuf_generate_python(PROTO_PY foo.proto)
-# add_executable(bar bar.cc ${PROTO_SRCS} ${PROTO_HDRS})
-# target_link_libraries(bar ${Protobuf_LIBRARIES})
-#
-# .. note::
-# The ``protobuf_generate_cpp`` and ``protobuf_generate_python``
-# functions and :command:`add_executable` or :command:`add_library`
-# calls only work properly within the same directory.
-#
-# .. command:: protobuf_generate_cpp
-#
-# Add custom commands to process ``.proto`` files to C++::
-#
-# protobuf_generate_cpp (<SRCS> <HDRS> [EXPORT_MACRO <MACRO>] [<ARGN>...])
-#
-# ``SRCS``
-# Variable to define with autogenerated source files
-# ``HDRS``
-# Variable to define with autogenerated header files
-# ``EXPORT_MACRO``
-# is a macro which should expand to ``__declspec(dllexport)`` or
-# ``__declspec(dllimport)`` depending on what is being compiled.
-# ``ARGN``
-# ``.proto`` files
-#
-# .. command:: protobuf_generate_python
-#
-# Add custom commands to process ``.proto`` files to Python::
-#
-# protobuf_generate_python (<PY> [<ARGN>...])
-#
-# ``PY``
-# Variable to define with autogenerated Python files
-# ``ARGN``
-# ``.proto`` filess
+#[=======================================================================[.rst:
+FindProtobuf
+------------
+
+Locate and configure the Google Protocol Buffers library.
+
+The following variables can be set and are optional:
+
+``Protobuf_SRC_ROOT_FOLDER``
+ When compiling with MSVC, if this cache variable is set
+ the protobuf-default VS project build locations
+ (vsprojects/Debug and vsprojects/Release
+ or vsprojects/x64/Debug and vsprojects/x64/Release)
+ will be searched for libraries and binaries.
+``Protobuf_IMPORT_DIRS``
+ List of additional directories to be searched for
+ imported .proto files.
+``Protobuf_DEBUG``
+ Show debug messages.
+``Protobuf_USE_STATIC_LIBS``
+ Set to ON to force the use of the static libraries.
+ Default is OFF.
+
+Defines the following variables:
+
+``Protobuf_FOUND``
+ Found the Google Protocol Buffers library
+ (libprotobuf & header files)
+``Protobuf_VERSION``
+ Version of package found.
+``Protobuf_INCLUDE_DIRS``
+ Include directories for Google Protocol Buffers
+``Protobuf_LIBRARIES``
+ The protobuf libraries
+``Protobuf_PROTOC_LIBRARIES``
+ The protoc libraries
+``Protobuf_LITE_LIBRARIES``
+ The protobuf-lite libraries
+
+The following :prop_tgt:`IMPORTED` targets are also defined:
+
+``protobuf::libprotobuf``
+ The protobuf library.
+``protobuf::libprotobuf-lite``
+ The protobuf lite library.
+``protobuf::libprotoc``
+ The protoc library.
+``protobuf::protoc``
+ The protoc compiler.
+
+The following cache variables are also available to set or use:
+
+``Protobuf_LIBRARY``
+ The protobuf library
+``Protobuf_PROTOC_LIBRARY``
+ The protoc library
+``Protobuf_INCLUDE_DIR``
+ The include directory for protocol buffers
+``Protobuf_PROTOC_EXECUTABLE``
+ The protoc compiler
+``Protobuf_LIBRARY_DEBUG``
+ The protobuf library (debug)
+``Protobuf_PROTOC_LIBRARY_DEBUG``
+ The protoc library (debug)
+``Protobuf_LITE_LIBRARY``
+ The protobuf lite library
+``Protobuf_LITE_LIBRARY_DEBUG``
+ The protobuf lite library (debug)
+
+Example:
+
+.. code-block:: cmake
+
+ find_package(Protobuf REQUIRED)
+ include_directories(${Protobuf_INCLUDE_DIRS})
+ include_directories(${CMAKE_CURRENT_BINARY_DIR})
+ protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS foo.proto)
+ protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS EXPORT_MACRO DLL_EXPORT foo.proto)
+ protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS DESCRIPTORS PROTO_DESCS foo.proto)
+ protobuf_generate_python(PROTO_PY foo.proto)
+ add_executable(bar bar.cc ${PROTO_SRCS} ${PROTO_HDRS})
+ target_link_libraries(bar ${Protobuf_LIBRARIES})
+
+.. note::
+ The ``protobuf_generate_cpp`` and ``protobuf_generate_python``
+ functions and :command:`add_executable` or :command:`add_library`
+ calls only work properly within the same directory.
+
+.. command:: protobuf_generate_cpp
+
+ Add custom commands to process ``.proto`` files to C++::
+
+ protobuf_generate_cpp (<SRCS> <HDRS>
+ [DESCRIPTORS <DESC>] [EXPORT_MACRO <MACRO>] [<ARGN>...])
+
+ ``SRCS``
+ Variable to define with autogenerated source files
+ ``HDRS``
+ Variable to define with autogenerated header files
+ ``DESCRIPTORS``
+ Variable to define with autogenerated descriptor files, if requested.
+ ``EXPORT_MACRO``
+ is a macro which should expand to ``__declspec(dllexport)`` or
+ ``__declspec(dllimport)`` depending on what is being compiled.
+ ``ARGN``
+ ``.proto`` files
+
+.. command:: protobuf_generate_python
+
+ Add custom commands to process ``.proto`` files to Python::
+
+ protobuf_generate_python (<PY> [<ARGN>...])
+
+ ``PY``
+ Variable to define with autogenerated Python files
+ ``ARGN``
+ ``.proto`` filess
+#]=======================================================================]
+
+function(protobuf_generate)
+ set(_options APPEND_PATH DESCRIPTORS)
+ set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR)
+ if(COMMAND target_sources)
+ list(APPEND _singleargs TARGET)
+ endif()
+ set(_multiargs PROTOS IMPORT_DIRS GENERATE_EXTENSIONS)
-function(PROTOBUF_GENERATE_CPP SRCS HDRS)
- cmake_parse_arguments(protobuf "" "EXPORT_MACRO" "" ${ARGN})
+ cmake_parse_arguments(protobuf_generate "${_options}" "${_singleargs}" "${_multiargs}" "${ARGN}")
- set(PROTO_FILES "${protobuf_UNPARSED_ARGUMENTS}")
- if(NOT PROTO_FILES)
- message(SEND_ERROR "Error: PROTOBUF_GENERATE_CPP() called without any proto files")
+ if(NOT protobuf_generate_PROTOS AND NOT protobuf_generate_TARGET)
+ message(SEND_ERROR "Error: protobuf_generate called without any targets or source files")
return()
endif()
- if(protobuf_EXPORT_MACRO)
- set(DLL_EXPORT_DECL "dllexport_decl=${protobuf_EXPORT_MACRO}:")
+ if(NOT protobuf_generate_OUT_VAR AND NOT protobuf_generate_TARGET)
+ message(SEND_ERROR "Error: protobuf_generate called without a target or output variable")
+ return()
endif()
- if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
+ if(NOT protobuf_generate_LANGUAGE)
+ set(protobuf_generate_LANGUAGE cpp)
+ endif()
+ string(TOLOWER ${protobuf_generate_LANGUAGE} protobuf_generate_LANGUAGE)
+
+ if(NOT protobuf_generate_PROTOC_OUT_DIR)
+ set(protobuf_generate_PROTOC_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
+ endif()
+
+ if(protobuf_generate_EXPORT_MACRO AND protobuf_generate_LANGUAGE STREQUAL cpp)
+ set(_dll_export_decl "dllexport_decl=${protobuf_generate_EXPORT_MACRO}:")
+ endif()
+
+ if(NOT protobuf_generate_GENERATE_EXTENSIONS)
+ if(protobuf_generate_LANGUAGE STREQUAL cpp)
+ set(protobuf_generate_GENERATE_EXTENSIONS .pb.h .pb.cc)
+ elseif(protobuf_generate_LANGUAGE STREQUAL python)
+ set(protobuf_generate_GENERATE_EXTENSIONS _pb2.py)
+ else()
+ message(SEND_ERROR "Error: protobuf_generate given unknown Language ${LANGUAGE}, please provide a value for GENERATE_EXTENSIONS")
+ return()
+ endif()
+ endif()
+
+ if(protobuf_generate_TARGET)
+ get_target_property(_source_list ${protobuf_generate_TARGET} SOURCES)
+ foreach(_file ${_source_list})
+ if(_file MATCHES "proto$")
+ list(APPEND protobuf_generate_PROTOS ${_file})
+ endif()
+ endforeach()
+ endif()
+
+ if(NOT protobuf_generate_PROTOS)
+ message(SEND_ERROR "Error: protobuf_generate could not find any .proto files")
+ return()
+ endif()
+
+ if(protobuf_generate_APPEND_PATH)
# Create an include path for each file specified
- foreach(FIL ${PROTO_FILES})
- get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
- get_filename_component(ABS_PATH ${ABS_FIL} PATH)
- list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
+ foreach(_file ${protobuf_generate_PROTOS})
+ get_filename_component(_abs_file ${_file} ABSOLUTE)
+ get_filename_component(_abs_path ${_abs_file} PATH)
+ list(FIND _protobuf_include_path ${_abs_path} _contains_already)
if(${_contains_already} EQUAL -1)
- list(APPEND _protobuf_include_path -I ${ABS_PATH})
+ list(APPEND _protobuf_include_path -I ${_abs_path})
endif()
endforeach()
else()
set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
endif()
+ foreach(DIR ${protobuf_generate_IMPORT_DIRS})
+ get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
+ list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
+ if(${_contains_already} EQUAL -1)
+ list(APPEND _protobuf_include_path -I ${ABS_PATH})
+ endif()
+ endforeach()
+
+ set(_generated_srcs_all)
+ foreach(_proto ${protobuf_generate_PROTOS})
+ get_filename_component(_abs_file ${_proto} ABSOLUTE)
+ get_filename_component(_abs_dir ${_abs_file} DIRECTORY)
+ get_filename_component(_basename ${_proto} NAME_WE)
+ file(RELATIVE_PATH _rel_dir ${CMAKE_CURRENT_SOURCE_DIR} ${_abs_dir})
+
+ set(_possible_rel_dir)
+ if (NOT protobuf_generate_APPEND_PATH)
+ set(_possible_rel_dir ${_rel_dir}/)
+ endif()
+
+ set(_generated_srcs)
+ foreach(_ext ${protobuf_generate_GENERATE_EXTENSIONS})
+ list(APPEND _generated_srcs "${protobuf_generate_PROTOC_OUT_DIR}/${_possible_rel_dir}${_basename}${_ext}")
+ endforeach()
+
+ if(protobuf_generate_DESCRIPTORS AND protobuf_generate_LANGUAGE STREQUAL cpp)
+ set(_descriptor_file "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.desc")
+ set(_dll_desc_out "--descriptor_set_out=${_descriptor_file}")
+ list(APPEND _generated_srcs ${_descriptor_file})
+ endif()
+ list(APPEND _generated_srcs_all ${_generated_srcs})
+
+ add_custom_command(
+ OUTPUT ${_generated_srcs}
+ COMMAND protobuf::protoc
+ ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_dll_desc_out} ${_protobuf_include_path} ${_abs_file}
+ DEPENDS ${_abs_file} protobuf::protoc
+ COMMENT "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}"
+ VERBATIM )
+ endforeach()
+
+ set_source_files_properties(${_generated_srcs_all} PROPERTIES GENERATED TRUE)
+ if(protobuf_generate_OUT_VAR)
+ set(${protobuf_generate_OUT_VAR} ${_generated_srcs_all} PARENT_SCOPE)
+ endif()
+ if(protobuf_generate_TARGET)
+ target_sources(${protobuf_generate_TARGET} PRIVATE ${_generated_srcs_all})
+ endif()
+endfunction()
+
+function(PROTOBUF_GENERATE_CPP SRCS HDRS)
+ cmake_parse_arguments(protobuf_generate_cpp "" "EXPORT_MACRO;DESCRIPTORS" "" ${ARGN})
+
+ set(_proto_files "${protobuf_generate_cpp_UNPARSED_ARGUMENTS}")
+ if(NOT _proto_files)
+ message(SEND_ERROR "Error: PROTOBUF_GENERATE_CPP() called without any proto files")
+ return()
+ endif()
+
+ if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
+ set(_append_arg APPEND_PATH)
+ endif()
+
+ if(protobuf_generate_cpp_DESCRIPTORS)
+ set(_descriptors DESCRIPTORS)
+ endif()
+
if(DEFINED PROTOBUF_IMPORT_DIRS AND NOT DEFINED Protobuf_IMPORT_DIRS)
set(Protobuf_IMPORT_DIRS "${PROTOBUF_IMPORT_DIRS}")
endif()
if(DEFINED Protobuf_IMPORT_DIRS)
- foreach(DIR ${Protobuf_IMPORT_DIRS})
- get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
- list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
- if(${_contains_already} EQUAL -1)
- list(APPEND _protobuf_include_path -I ${ABS_PATH})
- endif()
- endforeach()
+ set(_import_arg IMPORT_DIRS ${Protobuf_IMPORT_DIRS})
endif()
+ set(_outvar)
+ protobuf_generate(${_append_arg} ${_descriptors} LANGUAGE cpp EXPORT_MACRO ${protobuf_generate_cpp_EXPORT_MACRO} OUT_VAR _outvar ${_import_arg} PROTOS ${_proto_files})
+
set(${SRCS})
set(${HDRS})
- foreach(FIL ${PROTO_FILES})
- get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
- get_filename_component(FIL_WE ${FIL} NAME_WE)
- if(NOT PROTOBUF_GENERATE_CPP_APPEND_PATH)
- get_filename_component(FIL_DIR ${FIL} DIRECTORY)
- if(FIL_DIR)
- set(FIL_WE "${FIL_DIR}/${FIL_WE}")
- endif()
- endif()
-
- list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
- list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")
+ if(protobuf_generate_cpp_DESCRIPTORS)
+ set(${protobuf_generate_cpp_DESCRIPTORS})
+ endif()
- add_custom_command(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
- "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
- COMMAND ${Protobuf_PROTOC_EXECUTABLE}
- ARGS "--cpp_out=${DLL_EXPORT_DECL}${CMAKE_CURRENT_BINARY_DIR}" ${_protobuf_include_path} ${ABS_FIL}
- DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE}
- COMMENT "Running C++ protocol buffer compiler on ${FIL}"
- VERBATIM )
+ foreach(_file ${_outvar})
+ if(_file MATCHES "cc$")
+ list(APPEND ${SRCS} ${_file})
+ elseif(_file MATCHES "desc$")
+ list(APPEND ${protobuf_generate_cpp_DESCRIPTORS} ${_file})
+ else()
+ list(APPEND ${HDRS} ${_file})
+ endif()
endforeach()
-
- set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
+ if(protobuf_generate_cpp_DESCRIPTORS)
+ set(${protobuf_generate_cpp_DESCRIPTORS} "${${protobuf_generate_cpp_DESCRIPTORS}}" PARENT_SCOPE)
+ endif()
endfunction()
function(PROTOBUF_GENERATE_PYTHON SRCS)
@@ -191,17 +299,7 @@ function(PROTOBUF_GENERATE_PYTHON SRCS)
endif()
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
- # Create an include path for each file specified
- foreach(FIL ${ARGN})
- get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
- get_filename_component(ABS_PATH ${ABS_FIL} PATH)
- list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
- if(${_contains_already} EQUAL -1)
- list(APPEND _protobuf_include_path -I ${ABS_PATH})
- endif()
- endforeach()
- else()
- set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
+ set(_append_arg APPEND_PATH)
endif()
if(DEFINED PROTOBUF_IMPORT_DIRS AND NOT DEFINED Protobuf_IMPORT_DIRS)
@@ -209,36 +307,12 @@ function(PROTOBUF_GENERATE_PYTHON SRCS)
endif()
if(DEFINED Protobuf_IMPORT_DIRS)
- foreach(DIR ${Protobuf_IMPORT_DIRS})
- get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
- list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
- if(${_contains_already} EQUAL -1)
- list(APPEND _protobuf_include_path -I ${ABS_PATH})
- endif()
- endforeach()
+ set(_import_arg IMPORT_DIRS ${Protobuf_IMPORT_DIRS})
endif()
- set(${SRCS})
- foreach(FIL ${ARGN})
- get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
- get_filename_component(FIL_WE ${FIL} NAME_WE)
- if(NOT PROTOBUF_GENERATE_CPP_APPEND_PATH)
- get_filename_component(FIL_DIR ${FIL} DIRECTORY)
- if(FIL_DIR)
- set(FIL_WE "${FIL_DIR}/${FIL_WE}")
- endif()
- endif()
-
- list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py")
- add_custom_command(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py"
- COMMAND ${Protobuf_PROTOC_EXECUTABLE} --python_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
- DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE}
- COMMENT "Running Python protocol buffer compiler on ${FIL}"
- VERBATIM )
- endforeach()
-
- set(${SRCS} ${${SRCS}} PARENT_SCOPE)
+ set(_outvar)
+ protobuf_generate(${_append_arg} LANGUAGE python OUT_VAR _outvar ${_import_arg} PROTOS ${ARGN})
+ set(${SRCS} ${_outvar} PARENT_SCOPE)
endfunction()
@@ -311,21 +385,16 @@ function(_protobuf_find_libraries name filename)
mark_as_advanced(${name}_LIBRARY_DEBUG)
select_library_configurations(${name})
+
+ if(UNIX AND Threads_FOUND)
+ list(APPEND ${name}_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
+ endif()
+
set(${name}_LIBRARY "${${name}_LIBRARY}" PARENT_SCOPE)
set(${name}_LIBRARIES "${${name}_LIBRARIES}" PARENT_SCOPE)
endif()
endfunction()
-# Internal function: find threads library
-function(_protobuf_find_threads)
- set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
- find_package(Threads)
- if(Threads_FOUND)
- list(APPEND Protobuf_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
- set(Protobuf_LIBRARIES "${Protobuf_LIBRARIES}" PARENT_SCOPE)
- endif()
-endfunction()
-
#
# Main.
#
@@ -346,6 +415,11 @@ if(MSVC)
find_path(Protobuf_SRC_ROOT_FOLDER protobuf.pc.in)
endif()
+if(UNIX)
+ # Protobuf headers may depend on threading.
+ find_package(Threads QUIET)
+endif()
+
# The Protobuf library
_protobuf_find_libraries(Protobuf protobuf)
#DOC "The Google Protocol Buffers RELEASE Library"
@@ -360,10 +434,6 @@ if(MSVC)
set(CMAKE_FIND_LIBRARY_PREFIXES "${Protobuf_ORIG_FIND_LIBRARY_PREFIXES}")
endif()
-if(UNIX)
- _protobuf_find_threads()
-endif()
-
# Find the include directory
find_path(Protobuf_INCLUDE_DIR
google/protobuf/service.h
@@ -451,6 +521,20 @@ if(Protobuf_INCLUDE_DIR)
set_target_properties(protobuf::libprotobuf PROPERTIES
IMPORTED_LOCATION_DEBUG "${Protobuf_LIBRARY_DEBUG}")
endif()
+ if (Protobuf_VERSION VERSION_GREATER_EQUAL "3.6")
+ set_property(TARGET protobuf::libprotobuf APPEND PROPERTY
+ INTERFACE_COMPILE_FEATURES cxx_std_11
+ )
+ endif()
+ if (MSVC AND NOT Protobuf_USE_STATIC_LIBS)
+ set_property(TARGET protobuf::libprotobuf APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS "PROTOBUF_USE_DLLS"
+ )
+ endif()
+ if(UNIX AND TARGET Threads::Threads)
+ set_property(TARGET protobuf::libprotobuf APPEND PROPERTY
+ INTERFACE_LINK_LIBRARIES Threads::Threads)
+ endif()
endif()
endif()
@@ -475,6 +559,15 @@ if(Protobuf_INCLUDE_DIR)
set_target_properties(protobuf::libprotobuf-lite PROPERTIES
IMPORTED_LOCATION_DEBUG "${Protobuf_LITE_LIBRARY_DEBUG}")
endif()
+ if (MSVC AND NOT Protobuf_USE_STATIC_LIBS)
+ set_property(TARGET protobuf::libprotobuf-lite APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS "PROTOBUF_USE_DLLS"
+ )
+ endif()
+ if(UNIX AND TARGET Threads::Threads)
+ set_property(TARGET protobuf::libprotobuf-lite APPEND PROPERTY
+ INTERFACE_LINK_LIBRARIES Threads::Threads)
+ endif()
endif()
endif()
@@ -499,6 +592,30 @@ if(Protobuf_INCLUDE_DIR)
set_target_properties(protobuf::libprotoc PROPERTIES
IMPORTED_LOCATION_DEBUG "${Protobuf_PROTOC_LIBRARY_DEBUG}")
endif()
+ if (Protobuf_VERSION VERSION_GREATER_EQUAL "3.6")
+ set_property(TARGET protobuf::libprotoc APPEND PROPERTY
+ INTERFACE_COMPILE_FEATURES cxx_std_11
+ )
+ endif()
+ if (MSVC AND NOT Protobuf_USE_STATIC_LIBS)
+ set_property(TARGET protobuf::libprotoc APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS "PROTOBUF_USE_DLLS"
+ )
+ endif()
+ if(UNIX AND TARGET Threads::Threads)
+ set_property(TARGET protobuf::libprotoc APPEND PROPERTY
+ INTERFACE_LINK_LIBRARIES Threads::Threads)
+ endif()
+ endif()
+ endif()
+
+ if(Protobuf_PROTOC_EXECUTABLE)
+ if(NOT TARGET protobuf::protoc)
+ add_executable(protobuf::protoc IMPORTED)
+ if(EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
+ set_target_properties(protobuf::protoc PROPERTIES
+ IMPORTED_LOCATION "${Protobuf_PROTOC_EXECUTABLE}")
+ endif()
endif()
endif()
endif()
diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake
new file mode 100644
index 000000000..2bdfaf393
--- /dev/null
+++ b/Modules/FindPython.cmake
@@ -0,0 +1,359 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindPython
+----------
+
+Find Python interpreter, compiler and development environment (include
+directories and libraries).
+
+The following components are supported:
+
+* ``Interpreter``: search for Python interpreter.
+* ``Compiler``: search for Python compiler. Only offered by IronPython.
+* ``Development``: search for development artifacts (include directories and
+ libraries).
+* ``NumPy``: search for NumPy include directories.
+
+If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed.
+
+To ensure consistent versions between components ``Interpreter``, ``Compiler``,
+``Development`` and ``NumPy``, specify all components at the same time::
+
+ find_package (Python COMPONENTS Interpreter Development)
+
+This module looks preferably for version 3 of Python. If not found, version 2
+is searched.
+To manage concurrent versions 3 and 2 of Python, use :module:`FindPython3` and
+:module:`FindPython2` modules rather than this one.
+
+.. note::
+
+ If components ``Interpreter`` and ``Development`` are both specified, this
+ module search only for interpreter with same platform architecture as the one
+ defined by ``CMake`` configuration. This contraint does not apply if only
+ ``Interpreter`` component is specified.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :ref:`Imported Targets <Imported Targets>`
+(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``):
+
+``Python::Interpreter``
+ Python interpreter. Target defined if component ``Interpreter`` is found.
+``Python::Compiler``
+ Python compiler. Target defined if component ``Compiler`` is found.
+``Python::Python``
+ Python library for Python embedding. Target defined if component
+ ``Development`` is found.
+``Python::Module``
+ Python library for Python module. Target defined if component ``Development``
+ is found.
+``Python::NumPy``
+ NumPy Python library. Target defined if component ``NumPy`` is found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project
+(see :ref:`Standard Variable Names <CMake Developer Standard Variable Names>`):
+
+``Python_FOUND``
+ System has the Python requested components.
+``Python_Interpreter_FOUND``
+ System has the Python interpreter.
+``Python_EXECUTABLE``
+ Path to the Python interpreter.
+``Python_INTERPRETER_ID``
+ A short string unique to the interpreter. Possible values include:
+ * Python
+ * ActivePython
+ * Anaconda
+ * Canopy
+ * IronPython
+``Python_STDLIB``
+ Standard platform independent installation directory.
+
+ Information returned by
+ ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``.
+``Python_STDARCH``
+ Standard platform dependent installation directory.
+
+ Information returned by
+ ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``.
+``Python_SITELIB``
+ Third-party platform independent installation directory.
+
+ Information returned by
+ ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``.
+``Python_SITEARCH``
+ Third-party platform dependent installation directory.
+
+ Information returned by
+ ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``.
+``Python_Compiler_FOUND``
+ System has the Python compiler.
+``Python_COMPILER``
+ Path to the Python compiler. Only offered by IronPython.
+``Python_COMPILER_ID``
+ A short string unique to the compiler. Possible values include:
+ * IronPython
+``Python_Development_FOUND``
+ System has the Python development artifacts.
+``Python_INCLUDE_DIRS``
+ The Python include directories.
+``Python_LIBRARIES``
+ The Python libraries.
+``Python_LIBRARY_DIRS``
+ The Python library directories.
+``Python_RUNTIME_LIBRARY_DIRS``
+ The Python runtime library directories.
+``Python_VERSION``
+ Python version.
+``Python_VERSION_MAJOR``
+ Python major version.
+``Python_VERSION_MINOR``
+ Python minor version.
+``Python_VERSION_PATCH``
+ Python patch version.
+``Python_NumPy_FOUND``
+ System has the NumPy.
+``Python_NumPy_INCLUDE_DIRS``
+ The NumPy include directries.
+``Python_NumPy_VERSION``
+ The NumPy version.
+
+Hints
+^^^^^
+
+``Python_ROOT_DIR``
+ Define the root directory of a Python installation.
+
+``Python_USE_STATIC_LIBS``
+ * If not defined, search for shared libraries and static libraries in that
+ order.
+ * If set to TRUE, search **only** for static libraries.
+ * If set to FALSE, search **only** for shared libraries.
+
+``Python_FIND_ABI``
+ This variable defines which ABIs, as defined in
+ `PEP 3149 <https://www.python.org/dev/peps/pep-3149/>`_, should be searched.
+
+ .. note::
+
+ This hint will be honored only when searched for ``Python`` version 3.
+
+ .. note::
+
+ If ``Python_FIND_ABI`` is not defined, any ABI will be searched.
+
+ The ``Python_FIND_ABI`` variable is a 3-tuple specifying, in that order,
+ ``pydebug`` (``d``), ``pymalloc`` (``m``) and ``unicode`` (``u``) flags.
+ Each element can be set to one of the following:
+
+ * ``ON``: Corresponding flag is selected.
+ * ``OFF``: Corresponding flag is not selected.
+ * ``ANY``: The two posibilties (``ON`` and ``OFF``) will be searched.
+
+ From this 3-tuple, various ABIs will be searched starting from the most
+ specialized to the most general. Moreover, ``debug`` versions will be
+ searched **after** ``non-debug`` ones.
+
+ For example, if we have::
+
+ set (Python_FIND_ABI "ON" "ANY" "ANY")
+
+ The following flags combinations will be appended, in that order, to the
+ artifact names: ``dmu``, ``dm``, ``du``, and ``d``.
+
+ And to search any possible ABIs::
+
+ set (Python_FIND_ABI "ANY" "ANY" "ANY")
+
+ The following combinations, in that order, will be used: ``mu``, ``m``,
+ ``u``, ``<empty>``, ``dmu``, ``dm``, ``du`` and ``d``.
+
+ .. note::
+
+ This hint is useful only on ``POSIX`` systems. So, on ``Windows`` systems,
+ when ``Python_FIND_ABI`` is defined, ``Python`` distributions from
+ `python.org <https://www.python.org/>`_ will be found only if value for
+ each flag is ``OFF`` or ``ANY``.
+
+``Python_FIND_STRATEGY``
+ This variable defines how lookup will be done.
+ The ``Python_FIND_STRATEGY`` variable can be set to empty or one of the
+ following:
+
+ * ``VERSION``: Try to find the most recent version in all specified
+ locations.
+ This is the default if policy :policy:`CMP0094` is undefined or set to
+ ``OLD``.
+ * ``LOCATION``: Stops lookup as soon as a version satisfying version
+ constraints is founded.
+ This is the default if policy :policy:`CMP0094` is set to ``NEW``.
+
+``Python_FIND_REGISTRY``
+ On Windows the ``Python_FIND_REGISTRY`` variable determine the order
+ of preference between registry and environment variables.
+ the ``Python_FIND_REGISTRY`` variable can be set to empty or one of the
+ following:
+
+ * ``FIRST``: Try to use registry before environment variables.
+ This is the default.
+ * ``LAST``: Try to use registry after environment variables.
+ * ``NEVER``: Never try to use registry.
+
+``Python_FIND_FRAMEWORK``
+ On macOS the ``Python_FIND_FRAMEWORK`` variable determine the order of
+ preference between Apple-style and unix-style package components.
+ This variable can be set to empty or take same values as
+ :variable:`CMAKE_FIND_FRAMEWORK` variable.
+
+ .. note::
+
+ Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
+
+ If ``Python_FIND_FRAMEWORK`` is not defined, :variable:`CMAKE_FIND_FRAMEWORK`
+ variable will be used, if any.
+
+``Python_FIND_VIRTUALENV``
+ This variable defines the handling of virtual environments. It is meaningfull
+ only when a virtual environment is active (i.e. the ``activate`` script has
+ been evaluated). In this case, it takes precedence over
+ ``Python_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` variables.
+ The ``Python_FIND_VIRTUALENV`` variable can be set to empty or one of the
+ following:
+
+ * ``FIRST``: The virtual environment is used before any other standard
+ paths to look-up for the interpreter. This is the default.
+ * ``ONLY``: Only the virtual environment is used to look-up for the
+ interpreter.
+ * ``STANDARD``: The virtual environment is not used to look-up for the
+ interpreter. In this case, variable ``Python_FIND_REGISTRY`` (Windows)
+ or ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or
+ ``NEVER`` to select preferably the interpreter from the virtual
+ environment.
+
+ .. note::
+
+ If the component ``Development`` is requested, it is **strongly**
+ recommended to also include the component ``Interpreter`` to get expected
+ result.
+
+Artifacts Specification
+^^^^^^^^^^^^^^^^^^^^^^^
+
+To solve special cases, it is possible to specify directly the artifacts by
+setting the following variables:
+
+``Python_EXECUTABLE``
+ The path to the interpreter.
+
+``Python_COMPILER``
+ The path to the compiler.
+
+``Python_LIBRARY``
+ The path to the library. It will be used to compute the
+ variables ``Python_LIBRARIES``, ``Python_LIBRAY_DIRS`` and
+ ``Python_RUNTIME_LIBRARY_DIRS``.
+
+``Python_INCLUDE_DIR``
+ The path to the directory of the ``Python`` headers. It will be used to
+ compute the variable ``Python_INCLUDE_DIRS``.
+
+``Python_NumPy_INCLUDE_DIR``
+ The path to the directory of the ``NumPy`` headers. It will be used to
+ compute the variable ``Python_NumPy_INCLUDE_DIRS``.
+
+.. note::
+
+ All paths must be absolute. Any artifact specified with a relative path
+ will be ignored.
+
+.. note::
+
+ When an artifact is specified, all ``HINTS`` will be ignored and no search
+ will be performed for this artifact.
+
+ If more than one artifact is specified, it is the user's responsability to
+ ensure the consistency of the various artifacts.
+
+Commands
+^^^^^^^^
+
+This module defines the command ``Python_add_library`` (when
+:prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as
+:command:`add_library` and adds a dependency to target ``Python::Python`` or,
+when library type is ``MODULE``, to target ``Python::Module`` and takes care of
+Python module naming rules::
+
+ Python_add_library (my_module MODULE src1.cpp)
+
+If library type is not specified, ``MODULE`` is assumed.
+#]=======================================================================]
+
+
+set (_PYTHON_PREFIX Python)
+
+if (DEFINED Python_FIND_VERSION)
+ set (_Python_REQUIRED_VERSION_MAJOR ${Python_FIND_VERSION_MAJOR})
+
+ include (${CMAKE_CURRENT_LIST_DIR}/FindPython/Support.cmake)
+else()
+ # iterate over versions in quiet and NOT required modes to avoid multiple
+ # "Found" messages and prematurally failure.
+ set (_Python_QUIETLY ${Python_FIND_QUIETLY})
+ set (_Python_REQUIRED ${Python_FIND_REQUIRED})
+ set (Python_FIND_QUIETLY TRUE)
+ set (Python_FIND_REQUIRED FALSE)
+
+ set (_Python_REQUIRED_VERSIONS 3 2)
+ set (_Python_REQUIRED_VERSION_LAST 2)
+
+ unset (_Python_INPUT_VARS)
+ foreach (_Python_ITEM IN ITEMS Python_EXECUTABLE Python_COMPILER Python_LIBRARY
+ Python_INCLUDE_DIR Python_NumPy_INCLUDE_DIR)
+ if (NOT DEFINED ${_Python_ITEM})
+ list (APPEND _Python_INPUT_VARS ${_Python_ITEM})
+ endif()
+ endforeach()
+
+ foreach (_Python_REQUIRED_VERSION_MAJOR IN LISTS _Python_REQUIRED_VERSIONS)
+ set (Python_FIND_VERSION ${_Python_REQUIRED_VERSION_MAJOR})
+ include (${CMAKE_CURRENT_LIST_DIR}/FindPython/Support.cmake)
+ if (Python_FOUND OR
+ _Python_REQUIRED_VERSION_MAJOR EQUAL _Python_REQUIRED_VERSION_LAST)
+ break()
+ endif()
+ # clean-up INPUT variables not set by the user
+ foreach (_Python_ITEM IN LISTS _Python_INPUT_VARS)
+ unset (${_Python_ITEM})
+ endforeach()
+ # clean-up some CACHE variables to ensure look-up restart from scratch
+ foreach (_Python_ITEM IN LISTS _Python_CACHED_VARS)
+ unset (${_Python_ITEM} CACHE)
+ endforeach()
+ endforeach()
+
+ unset (Python_FIND_VERSION)
+
+ set (Python_FIND_QUIETLY ${_Python_QUIETLY})
+ set (Python_FIND_REQUIRED ${_Python_REQUIRED})
+ if (Python_FIND_REQUIRED OR NOT Python_FIND_QUIETLY)
+ # call again validation command to get "Found" or error message
+ find_package_handle_standard_args (Python HANDLE_COMPONENTS
+ REQUIRED_VARS ${_Python_REQUIRED_VARS}
+ VERSION_VAR Python_VERSION)
+ endif()
+endif()
+
+if (COMMAND __Python_add_library)
+ macro (Python_add_library)
+ __Python_add_library (Python ${ARGV})
+ endmacro()
+endif()
+
+unset (_PYTHON_PREFIX)
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
new file mode 100644
index 000000000..219a88583
--- /dev/null
+++ b/Modules/FindPython/Support.cmake
@@ -0,0 +1,2384 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#
+# This file is a "template" file used by various FindPython modules.
+#
+
+cmake_policy (GET CMP0094 _${_PYTHON_PREFIX}_LOOKUP_POLICY)
+
+cmake_policy (VERSION 3.7)
+
+if (_${_PYTHON_PREFIX}_LOOKUP_POLICY)
+ cmake_policy (SET CMP0094 ${_${_PYTHON_PREFIX}_LOOKUP_POLICY})
+endif()
+
+#
+# Initial configuration
+#
+if (NOT DEFINED _PYTHON_PREFIX)
+ message (FATAL_ERROR "FindPython: INTERNAL ERROR")
+endif()
+if (NOT DEFINED _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
+ message (FATAL_ERROR "FindPython: INTERNAL ERROR")
+endif()
+if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL 3)
+ set(_${_PYTHON_PREFIX}_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
+elseif (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL 2)
+ set(_${_PYTHON_PREFIX}_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
+else()
+ message (FATAL_ERROR "FindPython: INTERNAL ERROR")
+endif()
+
+get_property(_${_PYTHON_PREFIX}_CMAKE_ROLE GLOBAL PROPERTY CMAKE_ROLE)
+
+
+#
+# helper commands
+#
+macro (_PYTHON_DISPLAY_FAILURE _PYTHON_MSG)
+ if (${_PYTHON_PREFIX}_FIND_REQUIRED)
+ message (FATAL_ERROR "${_PYTHON_MSG}")
+ else()
+ if (NOT ${_PYTHON_PREFIX}_FIND_QUIETLY)
+ message(STATUS "${_PYTHON_MSG}")
+ endif ()
+ endif()
+
+ set (${_PYTHON_PREFIX}_FOUND FALSE)
+ string (TOUPPER "${_PYTHON_PREFIX}" _${_PYTHON_PREFIX}_UPPER_PREFIX)
+ set (${_PYTHON_UPPER_PREFIX}_FOUND FALSE)
+ return()
+endmacro()
+
+
+macro (_PYTHON_FIND_FRAMEWORKS)
+ set (${_PYTHON_PREFIX}_FRAMEWORKS)
+ if (CMAKE_HOST_APPLE OR APPLE)
+ set (_pff_frameworks ${CMAKE_FRAMEWORK_PATH}
+ $ENV{CMAKE_FRAMEWORK_PATH}
+ ~/Library/Frameworks
+ /usr/local/Frameworks
+ ${CMAKE_SYSTEM_FRAMEWORK_PATH})
+ list (REMOVE_DUPLICATES _pff_frameworks)
+ foreach (_pff_framework IN LISTS _pff_frameworks)
+ if (EXISTS ${_pff_framework}/Python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}.framework)
+ list (APPEND ${_PYTHON_PREFIX}_FRAMEWORKS ${_pff_framework}/Python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}.framework)
+ endif()
+ if (EXISTS ${_pff_framework}/Python.framework)
+ list (APPEND ${_PYTHON_PREFIX}_FRAMEWORKS ${_pff_framework}/Python.framework)
+ endif()
+ endforeach()
+ unset (_pff_frameworks)
+ unset (_pff_framework)
+ endif()
+endmacro()
+
+function (_PYTHON_GET_FRAMEWORKS _PYTHON_PGF_FRAMEWORK_PATHS _PYTHON_VERSION)
+ set (_PYTHON_FRAMEWORK_PATHS)
+ foreach (_PYTHON_FRAMEWORK IN LISTS ${_PYTHON_PREFIX}_FRAMEWORKS)
+ list (APPEND _PYTHON_FRAMEWORK_PATHS
+ "${_PYTHON_FRAMEWORK}/Versions/${_PYTHON_VERSION}")
+ endforeach()
+ set (${_PYTHON_PGF_FRAMEWORK_PATHS} ${_PYTHON_FRAMEWORK_PATHS} PARENT_SCOPE)
+endfunction()
+
+function (_PYTHON_GET_REGISTRIES _PYTHON_PGR_REGISTRY_PATHS _PYTHON_VERSION)
+ string (REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${_PYTHON_VERSION})
+ set (${_PYTHON_PGR_REGISTRY_PATHS}
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_PYTHON_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_PYTHON_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_PYTHON_VERSION}\\InstallPath]
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_PYTHON_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_PYTHON_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_PYTHON_VERSION}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_PYTHON_VERSION}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_PYTHON_VERSION}\\InstallPath]
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_PYTHON_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH}\\InstallPath]
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\ContinuumAnalytics\\Anaconda${_PYTHON_VERSION_NO_DOTS}-${_${_PYTHON_PREFIX}_ARCH2}\\InstallPath]
+ PARENT_SCOPE)
+endfunction()
+
+
+function (_PYTHON_GET_ABIFLAGS _PGABIFLAGS)
+ set (abiflags)
+ list (GET _${_PYTHON_PREFIX}_FIND_ABI 0 pydebug)
+ list (GET _${_PYTHON_PREFIX}_FIND_ABI 1 pymalloc)
+ list (GET _${_PYTHON_PREFIX}_FIND_ABI 2 unicode)
+
+ if (pymalloc STREQUAL "ANY" AND unicode STREQUAL "ANY")
+ set (abiflags "mu" "m" "u" "")
+ elseif (pymalloc STREQUAL "ANY" AND unicode STREQUAL "ON")
+ set (abiflags "mu" "u")
+ elseif (pymalloc STREQUAL "ANY" AND unicode STREQUAL "OFF")
+ set (abiflags "m" "")
+ elseif (pymalloc STREQUAL "ON" AND unicode STREQUAL "ANY")
+ set (abiflags "mu" "m")
+ elseif (pymalloc STREQUAL "ON" AND unicode STREQUAL "ON")
+ set (abiflags "mu")
+ elseif (pymalloc STREQUAL "ON" AND unicode STREQUAL "OFF")
+ set (abiflags "m")
+ elseif (pymalloc STREQUAL "ON" AND unicode STREQUAL "ANY")
+ set (abiflags "u" "")
+ elseif (pymalloc STREQUAL "OFF" AND unicode STREQUAL "ON")
+ set (abiflags "u")
+ endif()
+
+ if (pydebug STREQUAL "ON")
+ if (abiflags)
+ list (TRANSFORM abiflags PREPEND "d")
+ else()
+ set (abiflags "d")
+ endif()
+ elseif (pydebug STREQUAL "ANY")
+ if (abiflags)
+ set (flags "${abiflags}")
+ list (TRANSFORM flags PREPEND "d")
+ list (APPEND abiflags "${flags}")
+ else()
+ set (abiflags "" "d")
+ endif()
+ endif()
+
+ set (${_PGABIFLAGS} "${abiflags}" PARENT_SCOPE)
+endfunction()
+
+function (_PYTHON_GET_PATH_SUFFIXES _PYTHON_PGPS_PATH_SUFFIXES)
+ cmake_parse_arguments (PARSE_ARGV 1 _PGPS "LIBRARY;INCLUDE" "VERSION" "")
+
+ if (DEFINED _${_PYTHON_PREFIX}_ABIFLAGS)
+ set (abi "${_${_PYTHON_PREFIX}_ABIFLAGS}")
+ else()
+ set (abi "mu" "m" "u" "")
+ endif()
+
+ set (path_suffixes)
+ if (_PGPS_LIBRARY)
+ if (CMAKE_LIBRARY_ARCHITECTURE)
+ list (APPEND path_suffixes lib/${CMAKE_LIBRARY_ARCHITECTURE})
+ endif()
+ list (APPEND path_suffixes lib libs)
+
+ if (CMAKE_LIBRARY_ARCHITECTURE)
+ set (suffixes "${abi}")
+ if (suffixes)
+ list (TRANSFORM suffixes PREPEND "lib/python${_PGPS_VERSION}/config-${_PGPS_VERSION}")
+ list (TRANSFORM suffixes APPEND "-${CMAKE_LIBRARY_ARCHITECTURE}")
+ else()
+ set (suffixes "lib/python${_PGPS_VERSION}/config-${_PGPS_VERSION}-${CMAKE_LIBRARY_ARCHITECTURE}")
+ endif()
+ list (APPEND path_suffixes ${suffixes})
+ endif()
+ set (suffixes "${abi}")
+ if (suffixes)
+ list (TRANSFORM suffixes PREPEND "lib/python${_PGPS_VERSION}/config-${_PGPS_VERSION}")
+ else()
+ set (suffixes "lib/python${_PGPS_VERSION}/config-${_PGPS_VERSION}")
+ endif()
+ list (APPEND path_suffixes ${suffixes})
+ elseif (_PGPS_INCLUDE)
+ set (suffixes "${abi}")
+ if (suffixes)
+ list (TRANSFORM suffixes PREPEND "include/python${_PGPS_VERSION}")
+ else()
+ set (suffixes "include/python${_PGPS_VERSION}")
+ endif()
+ list (APPEND path_suffixes ${suffixes} include)
+ endif()
+
+ set (${_PYTHON_PGPS_PATH_SUFFIXES} ${path_suffixes} PARENT_SCOPE)
+endfunction()
+
+function (_PYTHON_GET_NAMES _PYTHON_PGN_NAMES)
+ cmake_parse_arguments (PARSE_ARGV 1 _PGN "POSIX;EXECUTABLE;CONFIG;LIBRARY;WIN32;DEBUG" "VERSION" "")
+
+ set (names)
+
+ if (_PGN_WIN32)
+ string (REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${_PGN_VERSION})
+
+ set (name python${_PYTHON_VERSION_NO_DOTS})
+ if (_PGN_DEBUG)
+ string (APPEND name "_d")
+ endif()
+
+ list (APPEND names "${name}")
+ endif()
+
+ if (_PGN_POSIX)
+ if (DEFINED _${_PYTHON_PREFIX}_ABIFLAGS)
+ set (abi "${_${_PYTHON_PREFIX}_ABIFLAGS}")
+ else()
+ if (_PGN_EXECUTABLE OR _PGN_CONFIG)
+ set (abi "")
+ else()
+ set (abi "mu" "m" "u" "")
+ endif()
+ endif()
+
+ if (abi)
+ if (_PGN_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE)
+ set (abinames "${abi}")
+ list (TRANSFORM abinames PREPEND "${CMAKE_LIBRARY_ARCHITECTURE}-python${_PGN_VERSION}")
+ list (TRANSFORM abinames APPEND "-config")
+ list (APPEND names ${abinames})
+ endif()
+ set (abinames "${abi}")
+ list (TRANSFORM abinames PREPEND "python${_PGN_VERSION}")
+ if (_PGN_CONFIG)
+ list (TRANSFORM abinames APPEND "-config")
+ endif()
+ list (APPEND names ${abinames})
+ else()
+ if (_PGN_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE)
+ set (abinames "${CMAKE_LIBRARY_ARCHITECTURE}-python${_PGN_VERSION}")
+ endif()
+ list (APPEND abinames "python${_PGN_VERSION}")
+ if (_PGN_CONFIG)
+ list (TRANSFORM abinames APPEND "-config")
+ endif()
+ list (APPEND names ${abinames})
+ endif()
+ endif()
+
+ set (${_PYTHON_PGN_NAMES} ${names} PARENT_SCOPE)
+endfunction()
+
+function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME)
+ unset (${_PYTHON_PGCV_VALUE} PARENT_SCOPE)
+
+ if (NOT NAME MATCHES "^(PREFIX|ABIFLAGS|CONFIGDIR|INCLUDES|LIBS)$")
+ return()
+ endif()
+
+ if (_${_PYTHON_PREFIX}_CONFIG)
+ set (config_flag "--${NAME}")
+ string (TOLOWER "${config_flag}" config_flag)
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" ${config_flag}
+ RESULT_VARIABLE _result
+ OUTPUT_VARIABLE _values
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_result)
+ unset (_values)
+ else()
+ if (NAME STREQUAL "INCLUDES")
+ # do some clean-up
+ string (REGEX MATCHALL "(-I|-iwithsysroot)[ ]*[^ ]+" _values "${_values}")
+ string (REGEX REPLACE "(-I|-iwithsysroot)[ ]*" "" _values "${_values}")
+ list (REMOVE_DUPLICATES _values)
+ endif()
+ endif()
+ endif()
+
+ if (_${_PYTHON_PREFIX}_EXECUTABLE AND NOT CMAKE_CROSSCOMPILING)
+ if (NAME STREQUAL "PREFIX")
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(';'.join([sysconfig.PREFIX,sysconfig.EXEC_PREFIX,sysconfig.BASE_EXEC_PREFIX]))"
+ RESULT_VARIABLE _result
+ OUTPUT_VARIABLE _values
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_result)
+ unset (_values)
+ else()
+ list (REMOVE_DUPLICATES _values)
+ endif()
+ elseif (NAME STREQUAL "INCLUDES")
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(';'.join([sysconfig.get_python_inc(plat_specific=True),sysconfig.get_python_inc(plat_specific=False)]))"
+ RESULT_VARIABLE _result
+ OUTPUT_VARIABLE _values
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_result)
+ unset (_values)
+ endif()
+ else()
+ set (config_flag "${NAME}")
+ if (NAME STREQUAL "CONFIGDIR")
+ set (config_flag "LIBPL")
+ endif()
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_config_var('${config_flag}'))"
+ RESULT_VARIABLE _result
+ OUTPUT_VARIABLE _values
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_result)
+ unset (_values)
+ endif()
+ endif()
+ endif()
+
+ if (config_flag STREQUAL "ABIFLAGS")
+ set (${_PYTHON_PGCV_VALUE} "${_values}" PARENT_SCOPE)
+ return()
+ endif()
+
+ if (NOT _values OR _values STREQUAL "None")
+ return()
+ endif()
+
+ if (NAME STREQUAL "LIBS")
+ # do some clean-up
+ string (REGEX MATCHALL "-(l|framework)[ ]*[^ ]+" _values "${_values}")
+ # remove elements relative to python library itself
+ list (FILTER _values EXCLUDE REGEX "-lpython")
+ list (REMOVE_DUPLICATES _values)
+ endif()
+
+ set (${_PYTHON_PGCV_VALUE} "${_values}" PARENT_SCOPE)
+endfunction()
+
+function (_PYTHON_GET_VERSION)
+ cmake_parse_arguments (PARSE_ARGV 0 _PGV "LIBRARY;INCLUDE" "PREFIX" "")
+
+ unset (${_PGV_PREFIX}VERSION PARENT_SCOPE)
+ unset (${_PGV_PREFIX}VERSION_MAJOR PARENT_SCOPE)
+ unset (${_PGV_PREFIX}VERSION_MINOR PARENT_SCOPE)
+ unset (${_PGV_PREFIX}VERSION_PATCH PARENT_SCOPE)
+ unset (${_PGV_PREFIX}ABI PARENT_SCOPE)
+
+ if (_PGV_LIBRARY)
+ # retrieve version and abi from library name
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ # extract version from library name
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])([0-9]+)")
+ set (${_PGV_PREFIX}VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}ABI "" PARENT_SCOPE)
+ elseif (_${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "python([23])\\.([0-9]+)([dmu]*)")
+ set (${_PGV_PREFIX}VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}ABI "${CMAKE_MATCH_3}" PARENT_SCOPE)
+ endif()
+ endif()
+ else()
+ if (_${_PYTHON_PREFIX}_INCLUDE_DIR)
+ # retrieve version from header file
+ file (STRINGS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}/patchlevel.h" version
+ REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"")
+ string (REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1"
+ version "${version}")
+ string (REGEX MATCHALL "[0-9]+" versions "${version}")
+ list (GET versions 0 version_major)
+ list (GET versions 1 version_minor)
+ list (GET versions 2 version_patch)
+
+ set (${_PGV_PREFIX}VERSION "${version_major}.${version_minor}" PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION_MAJOR ${version_major} PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION_MINOR ${version_minor} PARENT_SCOPE)
+ set (${_PGV_PREFIX}VERSION_PATCH ${version_patch} PARENT_SCOPE)
+
+ # compute ABI flags
+ if (version_major VERSION_GREATER 2)
+ file (STRINGS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}/pyconfig.h" config REGEX "(Py_DEBUG|WITH_PYMALLOC|Py_UNICODE_SIZE|MS_WIN32)")
+ set (abi)
+ if (config MATCHES "#[ ]*define[ ]+MS_WIN32")
+ # ABI not used on Windows
+ set (abi "")
+ else()
+ if (config MATCHES "#[ ]*define[ ]+Py_DEBUG[ ]+1")
+ string (APPEND abi "d")
+ endif()
+ if (config MATCHES "#[ ]*define[ ]+WITH_PYMALLOC[ ]+1")
+ string (APPEND abi "m")
+ endif()
+ if (config MATCHES "#[ ]*define[ ]+Py_UNICODE_SIZE[ ]+4")
+ string (APPEND abi "u")
+ endif()
+ set (${_PGV_PREFIX}ABI "${abi}" PARENT_SCOPE)
+ endif()
+ else()
+ # ABI not supported
+ set (${_PGV_PREFIX}ABI "" PARENT_SCOPE)
+ endif()
+ endif()
+ endif()
+endfunction()
+
+
+function (_PYTHON_VALIDATE_INTERPRETER)
+ if (NOT _${_PYTHON_PREFIX}_EXECUTABLE)
+ return()
+ endif()
+
+ cmake_parse_arguments (PARSE_ARGV 0 _PVI "EXACT;CHECK_EXISTS" "" "")
+ if (_PVI_UNPARSED_ARGUMENTS)
+ set (expected_version ${_PVI_UNPARSED_ARGUMENTS})
+ else()
+ unset (expected_version)
+ endif()
+
+ if (_PVI_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_EXECUTABLE}")
+ # interpreter does not exist anymore
+ set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND")
+ return()
+ endif()
+
+ # validate ABI compatibility
+ if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI)
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
+ "import sys; sys.stdout.write(sys.abiflags)"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE abi
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (result)
+ # assume ABI is not supported
+ set (abi "")
+ endif()
+ if (NOT abi IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS)
+ # incompatible ABI
+ set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND")
+ return()
+ endif()
+ endif()
+
+ get_filename_component (python_name "${_${_PYTHON_PREFIX}_EXECUTABLE}" NAME)
+
+ if (expected_version AND NOT python_name STREQUAL "python${expected_version}${abi}${CMAKE_EXECUTABLE_SUFFIX}")
+ # executable found must have a specific version
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
+ "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:2]]))"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE version
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (result OR (_PVI_EXACT AND NOT version VERSION_EQUAL expected_version) OR (version VERSION_LESS expected_version))
+ # interpreter not usable or has wrong major version
+ set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND")
+ return()
+ endif()
+ else()
+ if (NOT python_name STREQUAL "python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}${CMAKE_EXECUTABLE_SUFFIX}")
+ # executable found do not have version in name
+ # ensure major version is OK
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
+ "import sys; sys.stdout.write(str(sys.version_info[0]))"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE version
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (result OR NOT version EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
+ # interpreter not usable or has wrong major version
+ set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND")
+ return()
+ endif()
+ endif()
+ endif()
+
+ if (CMAKE_SIZEOF_VOID_P AND "Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
+ AND NOT CMAKE_CROSSCOMPILING)
+ # In this case, interpreter must have same architecture as environment
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
+ "import sys, struct; sys.stdout.write(str(struct.calcsize(\"P\")))"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE size
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (result OR NOT size EQUAL CMAKE_SIZEOF_VOID_P)
+ # interpreter not usable or has wrong architecture
+ set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "_${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND")
+ return()
+ endif()
+ endif()
+endfunction()
+
+
+function (_PYTHON_VALIDATE_COMPILER expected_version)
+ if (NOT _${_PYTHON_PREFIX}_COMPILER)
+ return()
+ endif()
+
+ cmake_parse_arguments (_PVC "EXACT;CHECK_EXISTS" "" "" ${ARGN})
+ if (_PVC_UNPARSED_ARGUMENTS)
+ set (major_version FALSE)
+ set (expected_version ${_PVC_UNPARSED_ARGUMENTS})
+ else()
+ set (major_version TRUE)
+ set (expected_version ${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR})
+ set (_PVC_EXACT TRUE)
+ endif()
+
+ if (_PVC_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_COMPILER}")
+ # Compiler does not exist anymore
+ set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "_${_PYTHON_PREFIX}_COMPILER-NOTFOUND")
+ return()
+ endif()
+
+ # retrieve python environment version from compiler
+ set (working_dir "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/PythonCompilerVersion.dir")
+ if (major_version)
+ # check only major version
+ file (WRITE "${working_dir}/version.py" "import sys; sys.stdout.write(str(sys.version_info[0]))")
+ else()
+ file (WRITE "${working_dir}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:2]]))\n")
+ endif()
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_COMPILER}" /target:exe /embed "${working_dir}/version.py"
+ WORKING_DIRECTORY "${working_dir}"
+ OUTPUT_QUIET
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process (COMMAND "${working_dir}/version"
+ WORKING_DIRECTORY "${working_dir}"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE version
+ ERROR_QUIET)
+ file (REMOVE_RECURSE "${_${_PYTHON_PREFIX}_VERSION_DIR}")
+
+ if (result OR (_PVC_EXACT AND NOT version VERSION_EQUAL expected_version) OR (version VERSION_LESS expected_version))
+ # Compiler not usable or has wrong version
+ set_property (CACHE _${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "_${_PYTHON_PREFIX}_COMPILER-NOTFOUND")
+ endif()
+endfunction()
+
+
+function (_PYTHON_VALIDATE_LIBRARY)
+ if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ return()
+ endif()
+
+ cmake_parse_arguments (PARSE_ARGV 0 _PVL "EXACT;CHECK_EXISTS" "" "")
+ if (_PVL_UNPARSED_ARGUMENTS)
+ set (expected_version ${_PVL_UNPARSED_ARGUMENTS})
+ else()
+ unset (expected_version)
+ endif()
+
+ if (_PVL_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}")
+ # library does not exist anymore
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND")
+ if (WIN32)
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_DEBUG PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_DEBUG-NOTFOUND")
+ endif()
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ return()
+ endif()
+
+ # retrieve version and abi from library name
+ _python_get_version (LIBRARY PREFIX lib_)
+
+ if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT lib_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS)
+ # incompatible ABI
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND")
+ else()
+ if (expected_version)
+ if ((_PVL_EXACT AND NOT lib_VERSION VERSION_EQUAL expected_version) OR (lib_VERSION VERSION_LESS expected_version))
+ # library has wrong version
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND")
+ endif()
+ else()
+ if (NOT lib_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
+ # library has wrong major version
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND")
+ endif()
+ endif()
+ endif()
+
+ if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ if (WIN32)
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_DEBUG PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_DEBUG-NOTFOUND")
+ endif()
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ endif()
+endfunction()
+
+
+function (_PYTHON_VALIDATE_INCLUDE_DIR)
+ if (NOT _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ return()
+ endif()
+
+ cmake_parse_arguments (PARSE_ARGV 0 _PVID "EXACT;CHECK_EXISTS" "" "")
+ if (_PVID_UNPARSED_ARGUMENTS)
+ set (expected_version ${_PVID_UNPARSED_ARGUMENTS})
+ else()
+ unset (expected_version)
+ endif()
+
+ if (_PVID_CHECK_EXISTS AND NOT EXISTS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}")
+ # include file does not exist anymore
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ return()
+ endif()
+
+ # retrieve version from header file
+ _python_get_version (INCLUDE PREFIX inc_)
+
+ if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT inc_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS)
+ # incompatible ABI
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ else()
+ if (expected_version)
+ if ((_PVID_EXACT AND NOT inc_VERSION VERSION_EQUAL expected_version) OR (inc_VERSION VERSION_LESS expected_version))
+ # include dir has wrong version
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ endif()
+ else()
+ if (NOT inc_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
+ # include dir has wrong major version
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ endif()
+ endif()
+ endif()
+endfunction()
+
+
+function (_PYTHON_FIND_RUNTIME_LIBRARY _PYTHON_LIB)
+ string (REPLACE "_RUNTIME" "" _PYTHON_LIB "${_PYTHON_LIB}")
+ # look at runtime part on systems supporting it
+ if (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR
+ (CMAKE_SYSTEM_NAME MATCHES "MSYS|CYGWIN"
+ AND ${_PYTHON_LIB} MATCHES "${CMAKE_IMPORT_LIBRARY_SUFFIX}$"))
+ set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX})
+ # MSYS has a special syntax for runtime libraries
+ if (CMAKE_SYSTEM_NAME MATCHES "MSYS")
+ list (APPEND CMAKE_FIND_LIBRARY_PREFIXES "msys-")
+ endif()
+ find_library (${ARGV})
+ endif()
+endfunction()
+
+
+function (_PYTHON_SET_LIBRARY_DIRS _PYTHON_SLD_RESULT)
+ unset (_PYTHON_DIRS)
+ set (_PYTHON_LIBS ${ARGN})
+ foreach (_PYTHON_LIB IN LISTS _PYTHON_LIBS)
+ if (${_PYTHON_LIB})
+ get_filename_component (_PYTHON_DIR "${${_PYTHON_LIB}}" DIRECTORY)
+ list (APPEND _PYTHON_DIRS "${_PYTHON_DIR}")
+ endif()
+ endforeach()
+ if (_PYTHON_DIRS)
+ list (REMOVE_DUPLICATES _PYTHON_DIRS)
+ endif()
+ set (${_PYTHON_SLD_RESULT} ${_PYTHON_DIRS} PARENT_SCOPE)
+endfunction()
+
+
+# If major version is specified, it must be the same as internal major version
+if (DEFINED ${_PYTHON_PREFIX}_FIND_VERSION_MAJOR
+ AND NOT ${_PYTHON_PREFIX}_FIND_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
+ _python_display_failure ("Could NOT find ${_PYTHON_PREFIX}: Wrong major version specified is \"${${_PYTHON_PREFIX}_FIND_VERSION_MAJOR}\", but expected major version is \"${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}\"")
+endif()
+
+
+# handle components
+if (NOT ${_PYTHON_PREFIX}_FIND_COMPONENTS)
+ set (${_PYTHON_PREFIX}_FIND_COMPONENTS Interpreter)
+ set (${_PYTHON_PREFIX}_FIND_REQUIRED_Interpreter TRUE)
+endif()
+if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
+ list (APPEND ${_PYTHON_PREFIX}_FIND_COMPONENTS "Interpreter" "Development")
+ list (REMOVE_DUPLICATES ${_PYTHON_PREFIX}_FIND_COMPONENTS)
+endif()
+foreach (_${_PYTHON_PREFIX}_COMPONENT IN ITEMS Interpreter Compiler Development NumPy)
+ set (${_PYTHON_PREFIX}_${_${_PYTHON_PREFIX}_COMPONENT}_FOUND FALSE)
+endforeach()
+unset (_${_PYTHON_PREFIX}_FIND_VERSIONS)
+
+# Set versions to search
+## default: search any version
+set (_${_PYTHON_PREFIX}_FIND_VERSIONS ${_${_PYTHON_PREFIX}_VERSIONS})
+
+if (${_PYTHON_PREFIX}_FIND_VERSION_COUNT GREATER 1)
+ if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT)
+ set (_${_PYTHON_PREFIX}_FIND_VERSIONS ${${_PYTHON_PREFIX}_FIND_VERSION_MAJOR}.${${_PYTHON_PREFIX}_FIND_VERSION_MINOR})
+ else()
+ unset (_${_PYTHON_PREFIX}_FIND_VERSIONS)
+ # add all compatible versions
+ foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_VERSIONS)
+ if (_${_PYTHON_PREFIX}_VERSION VERSION_GREATER_EQUAL ${_PYTHON_PREFIX}_FIND_VERSION)
+ list (APPEND _${_PYTHON_PREFIX}_FIND_VERSIONS ${_${_PYTHON_PREFIX}_VERSION})
+ endif()
+ endforeach()
+ endif()
+endif()
+
+# Set ABIs to search
+## default: search any ABI
+if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_LESS 3)
+ # ABI not supported
+ unset (_${_PYTHON_PREFIX}_FIND_ABI)
+ set (_${_PYTHON_PREFIX}_ABIFLAGS "")
+else()
+ unset (_${_PYTHON_PREFIX}_FIND_ABI)
+ unset (_${_PYTHON_PREFIX}_ABIFLAGS)
+ if (DEFINED ${_PYTHON_PREFIX}_FIND_ABI)
+ # normalization
+ string (TOUPPER "${${_PYTHON_PREFIX}_FIND_ABI}" _${_PYTHON_PREFIX}_FIND_ABI)
+ list (TRANSFORM _${_PYTHON_PREFIX}_FIND_ABI REPLACE "^(TRUE|Y(ES)?|1)$" "ON")
+ list (TRANSFORM _${_PYTHON_PREFIX}_FIND_ABI REPLACE "^(FALSE|N(O)?|0)$" "OFF")
+ if (NOT _${_PYTHON_PREFIX}_FIND_ABI MATCHES "^(ON|OFF|ANY);(ON|OFF|ANY);(ON|OFF|ANY)$")
+ message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_ABI}: invalid value for '${_PYTHON_PREFIX}_FIND_ABI'. Ignore it")
+ unset (_${_PYTHON_PREFIX}_FIND_ABI)
+ endif()
+ _python_get_abiflags (_${_PYTHON_PREFIX}_ABIFLAGS)
+ endif()
+endif()
+
+# Define lookup strategy
+if (_${_PYTHON_PREFIX}_LOOKUP_POLICY STREQUAL "NEW")
+ set (_${_PYTHON_PREFIX}_FIND_STRATEGY "LOCATION")
+else()
+ set (_${_PYTHON_PREFIX}_FIND_STRATEGY "VERSION")
+endif()
+if (DEFINED ${_PYTHON_PREFIX}_FIND_STRATEGY)
+ if (NOT ${_PYTHON_PREFIX}_FIND_STRATEGY MATCHES "^(VERSION|LOCATION)$")
+ message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_STRATEGY}: invalid value for '${_PYTHON_PREFIX}_FIND_STRATEGY'. 'VERSION' or 'LOCATION' expected.")
+ set (_${_PYTHON_PREFIX}_FIND_STRATEGY "VERSION")
+ else()
+ set (_${_PYTHON_PREFIX}_FIND_STRATEGY "${${_PYTHON_PREFIX}_FIND_STRATEGY}")
+ endif()
+endif()
+
+# Python and Anaconda distributions: define which architectures can be used
+if (CMAKE_SIZEOF_VOID_P)
+ # In this case, search only for 64bit or 32bit
+ math (EXPR _${_PYTHON_PREFIX}_ARCH "${CMAKE_SIZEOF_VOID_P} * 8")
+ set (_${_PYTHON_PREFIX}_ARCH2 ${_${_PYTHON_PREFIX}_ARCH})
+else()
+ # architecture unknown, search for both 64bit and 32bit
+ set (_${_PYTHON_PREFIX}_ARCH 64)
+ set (_${_PYTHON_PREFIX}_ARCH2 32)
+endif()
+
+# IronPython support
+if (CMAKE_SIZEOF_VOID_P)
+ # In this case, search only for 64bit or 32bit
+ math (EXPR _${_PYTHON_PREFIX}_ARCH "${CMAKE_SIZEOF_VOID_P} * 8")
+ set (_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES ipy${_${_PYTHON_PREFIX}_ARCH} ipy)
+else()
+ # architecture unknown, search for natural interpreter
+ set (_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES ipy)
+endif()
+set (_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES net45 net40)
+
+# Apple frameworks handling
+_python_find_frameworks ()
+
+set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK "FIRST")
+
+if (DEFINED ${_PYTHON_PREFIX}_FIND_FRAMEWORK)
+ if (NOT ${_PYTHON_PREFIX}_FIND_FRAMEWORK MATCHES "^(FIRST|LAST|NEVER)$")
+ message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_FRAMEWORK}: invalid value for '${_PYTHON_PREFIX}_FIND_FRAMEWORK'. 'FIRST', 'LAST' or 'NEVER' expected. 'FIRST' will be used instead.")
+ else()
+ set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK ${${_PYTHON_PREFIX}_FIND_FRAMEWORK})
+ endif()
+elseif (DEFINED CMAKE_FIND_FRAMEWORK)
+ if (CMAKE_FIND_FRAMEWORK STREQUAL "ONLY")
+ message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: CMAKE_FIND_FRAMEWORK: 'ONLY' value is not supported. 'FIRST' will be used instead.")
+ elseif (NOT CMAKE_FIND_FRAMEWORK MATCHES "^(FIRST|LAST|NEVER)$")
+ message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${CMAKE_FIND_FRAMEWORK}: invalid value for 'CMAKE_FIND_FRAMEWORK'. 'FIRST', 'LAST' or 'NEVER' expected. 'FIRST' will be used instead.")
+ else()
+ set (_${_PYTHON_PREFIX}_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
+ endif()
+endif()
+
+# Save CMAKE_FIND_APPBUNDLE
+if (DEFINED CMAKE_FIND_APPBUNDLE)
+ set (_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE})
+else()
+ unset (_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE)
+endif()
+# To avoid app bundle lookup
+set (CMAKE_FIND_APPBUNDLE "NEVER")
+
+# Save CMAKE_FIND_FRAMEWORK
+if (DEFINED CMAKE_FIND_FRAMEWORK)
+ set (_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
+else()
+ unset (_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK)
+endif()
+# To avoid framework lookup
+set (CMAKE_FIND_FRAMEWORK "NEVER")
+
+# Windows Registry handling
+if (DEFINED ${_PYTHON_PREFIX}_FIND_REGISTRY)
+ if (NOT ${_PYTHON_PREFIX}_FIND_REGISTRY MATCHES "^(FIRST|LAST|NEVER)$")
+ message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_REGISTRY}: invalid value for '${_PYTHON_PREFIX}_FIND_REGISTRY'. 'FIRST', 'LAST' or 'NEVER' expected. 'FIRST' will be used instead.")
+ set (_${_PYTHON_PREFIX}_FIND_REGISTRY "FIRST")
+ else()
+ set (_${_PYTHON_PREFIX}_FIND_REGISTRY ${${_PYTHON_PREFIX}_FIND_REGISTRY})
+ endif()
+else()
+ set (_${_PYTHON_PREFIX}_FIND_REGISTRY "FIRST")
+endif()
+
+# virtual environments handling
+if (DEFINED ENV{VIRTUAL_ENV})
+ if (DEFINED ${_PYTHON_PREFIX}_FIND_VIRTUALENV)
+ if (NOT ${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY|STANDARD)$")
+ message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_VIRTUALENV}: invalid value for '${_PYTHON_PREFIX}_FIND_VIRTUALENV'. 'FIRST', 'ONLY' or 'STANDARD' expected. 'FIRST' will be used instead.")
+ set (_${_PYTHON_PREFIX}_FIND_VIRTUALENV "FIRST")
+ else()
+ set (_${_PYTHON_PREFIX}_FIND_VIRTUALENV ${${_PYTHON_PREFIX}_FIND_VIRTUALENV})
+ endif()
+ else()
+ set (_${_PYTHON_PREFIX}_FIND_VIRTUALENV FIRST)
+ endif()
+else()
+ set (_${_PYTHON_PREFIX}_FIND_VIRTUALENV STANDARD)
+endif()
+
+
+# Compute search signature
+# This signature will be used to check validity of cached variables on new search
+set (_${_PYTHON_PREFIX}_SIGNATURE "${${_PYTHON_PREFIX}_ROOT_DIR}:${${_PYTHON_PREFIX}_FIND_STRATEGY}:${${_PYTHON_PREFIX}_FIND_VIRTUALENV}")
+if (NOT WIN32)
+ string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${${_PYTHON_PREFIX}_USE_STATIC_LIBS}:")
+endif()
+if (CMAKE_HOST_APPLE)
+ string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${${_PYTHON_PREFIX}_FIND_FRAMEWORK}")
+endif()
+if (CMAKE_HOST_WIN32)
+ string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${${_PYTHON_PREFIX}_FIND_REGISTRY}")
+endif()
+
+
+unset (_${_PYTHON_PREFIX}_REQUIRED_VARS)
+unset (_${_PYTHON_PREFIX}_CACHED_VARS)
+
+
+# first step, search for the interpreter
+if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
+ list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_EXECUTABLE)
+ if (${_PYTHON_PREFIX}_FIND_REQUIRED_Interpreter)
+ list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_EXECUTABLE)
+ endif()
+
+ if (DEFINED ${_PYTHON_PREFIX}_EXECUTABLE
+ AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_EXECUTABLE}")
+ set (_${_PYTHON_PREFIX}_EXECUTABLE "${${_PYTHON_PREFIX}_EXECUTABLE}" CACHE INTERNAL "")
+ elseif (DEFINED _${_PYTHON_PREFIX}_EXECUTABLE)
+ # compute interpreter signature and check validity of definition
+ string (MD5 __${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_EXECUTABLE}")
+ if (__${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE)
+ # check version validity
+ if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT)
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS)
+ else()
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS)
+ endif()
+ else()
+ unset (_${_PYTHON_PREFIX}_EXECUTABLE CACHE)
+ unset (_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE CACHE)
+ endif()
+ endif()
+
+ if (NOT _${_PYTHON_PREFIX}_EXECUTABLE)
+ set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
+
+ if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION")
+ unset (_${_PYTHON_PREFIX}_NAMES)
+ unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
+ unset (_${_PYTHON_PREFIX}_REGISTRY_PATHS)
+
+ foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ # build all executable names
+ _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX EXECUTABLE)
+ list (APPEND _${_PYTHON_PREFIX}_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES})
+
+ # Framework Paths
+ _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+ list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS})
+
+ # Registry Paths
+ _python_get_registries (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+ list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS}
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath])
+ endforeach()
+ list (APPEND _${_PYTHON_PREFIX}_NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python)
+
+ while (TRUE)
+ # Virtual environments handling
+ if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ENV VIRTUAL_ENV
+ PATH_SUFFIXES bin Scripts
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ if (NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY")
+ break()
+ endif()
+ endif()
+
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ endif()
+ # Windows registry
+ if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ endif()
+
+ # try using HINTS
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ # try using standard paths
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+ NAMES_PER_DIR
+ PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES})
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ NAMES_PER_DIR
+ PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_DEFAULT_PATH)
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ endif()
+ # Windows registry
+ if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+ NAMES_PER_DIR
+ PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_DEFAULT_PATH)
+ _python_validate_interpreter (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ endif()
+
+ break()
+ endwhile()
+ else()
+ # look-up for various versions and locations
+ foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ _python_get_names (_${_PYTHON_PREFIX}_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX EXECUTABLE)
+ list (APPEND _${_PYTHON_PREFIX}_NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
+ python)
+
+ _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+ _python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+
+ # Virtual environments handling
+ if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ENV VIRTUAL_ENV
+ PATH_SUFFIXES bin Scripts
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY")
+ continue()
+ endif()
+ endif()
+
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
+
+ # Windows registry
+ if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+ PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
+
+ _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+
+ # try using HINTS
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ # try using standard paths.
+ # NAMES_PER_DIR is not defined on purpose to have a chance to find
+ # expected version.
+ # For example, typical systems have 'python' for version 2.* and 'python3'
+ # for version 3.*. So looking for names per dir will find, potentially,
+ # systematically 'python' (i.e. version 2) even if version 3 is searched.
+ if (CMAKE_HOST_WIN32)
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ python
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES})
+ else()
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES})
+ endif()
+ _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ NAMES_PER_DIR
+ PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_DEFAULT_PATH)
+ endif()
+
+ # Windows registry
+ if (CMAKE_HOST_WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES ${_${_PYTHON_PREFIX}_NAMES}
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}
+ NAMES_PER_DIR
+ PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+ PATH_SUFFIXES bin ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_DEFAULT_PATH)
+ endif()
+
+ _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ break()
+ endif()
+ endforeach()
+
+ if (NOT _${_PYTHON_PREFIX}_EXECUTABLE AND
+ NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY")
+ # No specific version found. Retry with generic names and standard paths.
+ # NAMES_PER_DIR is not defined on purpose to have a chance to find
+ # expected version.
+ # For example, typical systems have 'python' for version 2.* and 'python3'
+ # for version 3.*. So looking for names per dir will find, potentially,
+ # systematically 'python' (i.e. version 2) even if version 3 is searched.
+ find_program (_${_PYTHON_PREFIX}_EXECUTABLE
+ NAMES python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}
+ python
+ ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES})
+ _python_validate_interpreter ()
+ endif()
+ endif()
+ endif()
+
+ set (${_PYTHON_PREFIX}_EXECUTABLE "${_${_PYTHON_PREFIX}_EXECUTABLE}")
+
+ # retrieve exact version of executable found
+ if (_${_PYTHON_PREFIX}_EXECUTABLE)
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
+ "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]]))"
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE ${_PYTHON_PREFIX}_VERSION
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (NOT _${_PYTHON_PREFIX}_RESULT)
+ set (_${_PYTHON_PREFIX}_EXECUTABLE_USABLE TRUE)
+ string (REGEX MATCHALL "[0-9]+" _${_PYTHON_PREFIX}_VERSIONS "${${_PYTHON_PREFIX}_VERSION}")
+ list (GET _${_PYTHON_PREFIX}_VERSIONS 0 ${_PYTHON_PREFIX}_VERSION_MAJOR)
+ list (GET _${_PYTHON_PREFIX}_VERSIONS 1 ${_PYTHON_PREFIX}_VERSION_MINOR)
+ list (GET _${_PYTHON_PREFIX}_VERSIONS 2 ${_PYTHON_PREFIX}_VERSION_PATCH)
+ else()
+ # Interpreter is not usable
+ set (_${_PYTHON_PREFIX}_EXECUTABLE_USABLE FALSE)
+ unset (${_PYTHON_PREFIX}_VERSION)
+ endif()
+ endif()
+
+ if (_${_PYTHON_PREFIX}_EXECUTABLE AND _${_PYTHON_PREFIX}_EXECUTABLE_USABLE
+ AND ${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
+ set (${_PYTHON_PREFIX}_Interpreter_FOUND TRUE)
+ # Use interpreter version and ABI for future searches to ensure consistency
+ set (_${_PYTHON_PREFIX}_FIND_VERSIONS ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR})
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.abiflags)"
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE _${_PYTHON_PREFIX}_ABIFLAGS
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_${_PYTHON_PREFIX}_RESULT)
+ # assunme ABI is not supported
+ set (_${_PYTHON_PREFIX}_ABIFLAGS "")
+ endif()
+ endif()
+
+ if (${_PYTHON_PREFIX}_Interpreter_FOUND)
+ # compute and save interpreter signature
+ string (MD5 __${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_EXECUTABLE}")
+ set (_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${__${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}" CACHE INTERNAL "")
+
+ if (NOT CMAKE_SIZEOF_VOID_P)
+ # determine interpreter architecture
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; print(sys.maxsize > 2**32)"
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE ${_PYTHON_PREFIX}_IS64BIT
+ ERROR_VARIABLE ${_PYTHON_PREFIX}_IS64BIT)
+ if (NOT _${_PYTHON_PREFIX}_RESULT)
+ if (${_PYTHON_PREFIX}_IS64BIT)
+ set (_${_PYTHON_PREFIX}_ARCH 64)
+ set (_${_PYTHON_PREFIX}_ARCH2 64)
+ else()
+ set (_${_PYTHON_PREFIX}_ARCH 32)
+ set (_${_PYTHON_PREFIX}_ARCH2 32)
+ endif()
+ endif()
+ endif()
+
+ # retrieve interpreter identity
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -V
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE ${_PYTHON_PREFIX}_INTERPRETER_ID
+ ERROR_VARIABLE ${_PYTHON_PREFIX}_INTERPRETER_ID)
+ if (NOT _${_PYTHON_PREFIX}_RESULT)
+ if (${_PYTHON_PREFIX}_INTERPRETER_ID MATCHES "Anaconda")
+ set (${_PYTHON_PREFIX}_INTERPRETER_ID "Anaconda")
+ elseif (${_PYTHON_PREFIX}_INTERPRETER_ID MATCHES "Enthought")
+ set (${_PYTHON_PREFIX}_INTERPRETER_ID "Canopy")
+ else()
+ string (REGEX REPLACE "^([^ ]+).*" "\\1" ${_PYTHON_PREFIX}_INTERPRETER_ID "${${_PYTHON_PREFIX}_INTERPRETER_ID}")
+ if (${_PYTHON_PREFIX}_INTERPRETER_ID STREQUAL "Python")
+ # try to get a more precise ID
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; print(sys.copyright)"
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE ${_PYTHON_PREFIX}_COPYRIGHT
+ ERROR_QUIET)
+ if (${_PYTHON_PREFIX}_COPYRIGHT MATCHES "ActiveState")
+ set (${_PYTHON_PREFIX}_INTERPRETER_ID "ActivePython")
+ endif()
+ endif()
+ endif()
+ else()
+ set (${_PYTHON_PREFIX}_INTERPRETER_ID Python)
+ endif()
+
+ # retrieve various package installation directories
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig;sys.stdout.write(';'.join([sysconfig.get_python_lib(plat_specific=False,standard_lib=True),sysconfig.get_python_lib(plat_specific=True,standard_lib=True),sysconfig.get_python_lib(plat_specific=False,standard_lib=False),sysconfig.get_python_lib(plat_specific=True,standard_lib=False)]))"
+
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE _${_PYTHON_PREFIX}_LIBPATHS
+ ERROR_QUIET)
+ if (NOT _${_PYTHON_PREFIX}_RESULT)
+ list (GET _${_PYTHON_PREFIX}_LIBPATHS 0 ${_PYTHON_PREFIX}_STDLIB)
+ list (GET _${_PYTHON_PREFIX}_LIBPATHS 1 ${_PYTHON_PREFIX}_STDARCH)
+ list (GET _${_PYTHON_PREFIX}_LIBPATHS 2 ${_PYTHON_PREFIX}_SITELIB)
+ list (GET _${_PYTHON_PREFIX}_LIBPATHS 3 ${_PYTHON_PREFIX}_SITEARCH)
+ else()
+ unset (${_PYTHON_PREFIX}_STDLIB)
+ unset (${_PYTHON_PREFIX}_STDARCH)
+ unset (${_PYTHON_PREFIX}_SITELIB)
+ unset (${_PYTHON_PREFIX}_SITEARCH)
+ endif()
+ else()
+ unset (_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE CACHE)
+ unset (${_PYTHON_PREFIX}_INTERPRETER_ID)
+ endif()
+
+ mark_as_advanced (_${_PYTHON_PREFIX}_EXECUTABLE
+ _${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE)
+endif()
+
+
+# second step, search for compiler (IronPython)
+if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
+ list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_COMPILER)
+ if (${_PYTHON_PREFIX}_FIND_REQUIRED_Compiler)
+ list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_COMPILER)
+ endif()
+
+ if (DEFINED ${_PYTHON_PREFIX}_COMPILER
+ AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_COMPILER}")
+ set (_${_PYTHON_PREFIX}_COMPILER "${${_PYTHON_PREFIX}_COMPILER}" CACHE INTERNAL "")
+ elseif (DEFINED _${_PYTHON_PREFIX}_COMPILER)
+ # compute compiler signature and check validity of definition
+ string (MD5 __${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_COMPILER}")
+ if (__${_PYTHON_PREFIX}_COMPILER_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_COMPILER_SIGNATURE)
+ # check version validity
+ if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT)
+ _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS)
+ else()
+ _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS)
+ endif()
+ else()
+ unset (_${_PYTHON_PREFIX}_COMPILER CACHE)
+ unset (_${_PYTHON_PREFIX}_COMPILER_SIGNATURE CACHE)
+ endif()
+ endif()
+
+ if (NOT _${_PYTHON_PREFIX}_COMPILER)
+ # IronPython specific artifacts
+ # If IronPython interpreter is found, use its path
+ unset (_${_PYTHON_PREFIX}_IRON_ROOT)
+ if (${_PYTHON_PREFIX}_Interpreter_FOUND AND ${_PYTHON_PREFIX}_INTERPRETER_ID STREQUAL "IronPython")
+ get_filename_component (_${_PYTHON_PREFIX}_IRON_ROOT "${${_PYTHON_PREFIX}_EXECUTABLE}" DIRECTORY)
+ endif()
+
+ if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION")
+ set (_${_PYTHON_PREFIX}_REGISTRY_PATHS)
+
+ foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ # Registry Paths
+ list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath])
+ endforeach()
+
+ while (TRUE)
+ if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_COMPILER
+ NAMES ipyc
+ HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_COMPILER)
+ break()
+ endif()
+ endif()
+
+ find_program (_${_PYTHON_PREFIX}_COMPILER
+ NAMES ipyc
+ HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ _python_validate_compiler (${${_PYTHON_PREFIX}_FIND_VERSION})
+ if (_${_PYTHON_PREFIX}_COMPILER)
+ break()
+ endif()
+
+ if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_COMPILER
+ NAMES ipyc
+ PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_DEFAULT_PATH)
+ endif()
+
+ break()
+ endwhile()
+ else()
+ # try using root dir and registry
+ foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_COMPILER
+ NAMES ipyc
+ HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_COMPILER)
+ break()
+ endif()
+ endif()
+
+ find_program (_${_PYTHON_PREFIX}_COMPILER
+ NAMES ipyc
+ HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_COMPILER)
+ break()
+ endif()
+
+ if (_${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_COMPILER
+ NAMES ipyc
+ PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\IronPython\\${_${_PYTHON_PREFIX}_VERSION}\\InstallPath]
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES}
+ NO_DEFAULT_PATH)
+ _python_validate_compiler (${_${_PYTHON_PREFIX}_VERSION} EXACT)
+ if (_${_PYTHON_PREFIX}_COMPILER)
+ break()
+ endif()
+ endif()
+ endforeach()
+
+ # no specific version found, re-try in standard paths
+ find_program (_${_PYTHON_PREFIX}_COMPILER
+ NAMES ipyc
+ HINTS ${_${_PYTHON_PREFIX}_IRON_ROOT} ${_${_PYTHON_PREFIX}_HINTS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_IRON_PYTHON_PATH_SUFFIXES})
+ endif()
+ endif()
+
+ set (${_PYTHON_PREFIX}_COMPILER "${_${_PYTHON_PREFIX}_COMPILER}")
+
+ if (_${_PYTHON_PREFIX}_COMPILER)
+ # retrieve python environment version from compiler
+ set (_${_PYTHON_PREFIX}_VERSION_DIR "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/PythonCompilerVersion.dir")
+ file (WRITE "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py" "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]]))\n")
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_COMPILER}" /target:exe /embed "${_${_PYTHON_PREFIX}_VERSION_DIR}/version.py"
+ WORKING_DIRECTORY "${_${_PYTHON_PREFIX}_VERSION_DIR}"
+ OUTPUT_QUIET
+ ERROR_QUIET)
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_VERSION_DIR}/version"
+ WORKING_DIRECTORY "${_${_PYTHON_PREFIX}_VERSION_DIR}"
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE _${_PYTHON_PREFIX}_VERSION
+ ERROR_QUIET)
+ if (NOT _${_PYTHON_PREFIX}_RESULT)
+ set (_${_PYTHON_PREFIX}_COMPILER_USABLE TRUE)
+ string (REGEX MATCHALL "[0-9]+" _${_PYTHON_PREFIX}_VERSIONS "${_${_PYTHON_PREFIX}_VERSION}")
+ list (GET _${_PYTHON_PREFIX}_VERSIONS 0 _${_PYTHON_PREFIX}_VERSION_MAJOR)
+ list (GET _${_PYTHON_PREFIX}_VERSIONS 1 _${_PYTHON_PREFIX}_VERSION_MINOR)
+ list (GET _${_PYTHON_PREFIX}_VERSIONS 2 _${_PYTHON_PREFIX}_VERSION_PATCH)
+
+ if (NOT ${_PYTHON_PREFIX}_Interpreter_FOUND)
+ # set public version information
+ set (${_PYTHON_PREFIX}_VERSION ${_${_PYTHON_PREFIX}_VERSION})
+ set (${_PYTHON_PREFIX}_VERSION_MAJOR ${_${_PYTHON_PREFIX}_VERSION_MAJOR})
+ set (${_PYTHON_PREFIX}_VERSION_MINOR ${_${_PYTHON_PREFIX}_VERSION_MINOR})
+ set (${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_VERSION_PATCH})
+ endif()
+ else()
+ # compiler not usable
+ set (_${_PYTHON_PREFIX}_COMPILER_USABLE FALSE)
+ endif()
+ file (REMOVE_RECURSE "${_${_PYTHON_PREFIX}_VERSION_DIR}")
+ endif()
+
+ if (_${_PYTHON_PREFIX}_COMPILER AND _${_PYTHON_PREFIX}_COMPILER_USABLE)
+ if (${_PYTHON_PREFIX}_Interpreter_FOUND)
+ # Compiler must be compatible with interpreter
+ if (${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR} VERSION_EQUAL ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR})
+ set (${_PYTHON_PREFIX}_Compiler_FOUND TRUE)
+ endif()
+ elseif (${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
+ set (${_PYTHON_PREFIX}_Compiler_FOUND TRUE)
+ # Use compiler version for future searches to ensure consistency
+ set (_${_PYTHON_PREFIX}_FIND_VERSIONS ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR})
+ endif()
+ endif()
+
+ if (${_PYTHON_PREFIX}_Compiler_FOUND)
+ # compute and save compiler signature
+ string (MD5 __${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_COMPILER}")
+ set (_${_PYTHON_PREFIX}_COMPILER_SIGNATURE "${__${_PYTHON_PREFIX}_COMPILER_SIGNATURE}" CACHE INTERNAL "")
+
+ set (${_PYTHON_PREFIX}_COMPILER_ID IronPython)
+ else()
+ unset (_${_PYTHON_PREFIX}_COMPILER_SIGNATURE CACHE)
+ unset (${_PYTHON_PREFIX}_COMPILER_ID)
+ endif()
+
+ mark_as_advanced (_${_PYTHON_PREFIX}_COMPILER
+ _${_PYTHON_PREFIX}_COMPILER_SIGNATURE)
+endif()
+
+
+# third step, search for the development artifacts
+## Development environment is not compatible with IronPython interpreter
+if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
+ AND NOT ${_PYTHON_PREFIX}_INTERPRETER_ID STREQUAL "IronPython")
+ list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE
+ _${_PYTHON_PREFIX}_LIBRARY_DEBUG
+ ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG
+ _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ if (${_PYTHON_PREFIX}_FIND_REQUIRED_Development)
+ list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_LIBRARIES
+ ${_PYTHON_PREFIX}_INCLUDE_DIRS)
+ endif()
+
+ if (DEFINED _${_PYTHON_PREFIX}_LIBRARY_RELEASE OR DEFINED _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ # compute development signature and check validity of definition
+ string (MD5 __${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}:${_${_PYTHON_PREFIX}_INCLUDE_DIR}")
+ if (WIN32 AND NOT DEFINED _${_PYTHON_PREFIX}_LIBRARY_DEBUG)
+ set (_${_PYTHON_PREFIX}_LIBRARY_DEBUG "_${_PYTHON_PREFIX}_LIBRARY_DEBUG-NOTFOUND" CACHE INTERNAL "")
+ endif()
+ if (NOT DEFINED _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ set (_${_PYTHON_PREFIX}_INCLUDE_DIR "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND" CACHE INTERNAL "")
+ endif()
+ if (__${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE)
+ # check version validity
+ if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT)
+ _python_validate_library (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS)
+ _python_validate_include_dir (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS)
+ else()
+ _python_validate_library (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS)
+ _python_validate_include_dir (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS)
+ endif()
+ else()
+ unset (_${_PYTHON_PREFIX}_LIBRARY_RELEASE CACHE)
+ unset (_${_PYTHON_PREFIX}_LIBRARY_DEBUG CACHE)
+ unset (_${_PYTHON_PREFIX}_INCLUDE_DIR CACHE)
+ unset (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE CACHE)
+ endif()
+ endif()
+ if (DEFINED ${_PYTHON_PREFIX}_LIBRARY
+ AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_LIBRARY}")
+ set (_${_PYTHON_PREFIX}_LIBRARY_RELEASE "${${_PYTHON_PREFIX}_LIBRARY}" CACHE INTERNAL "")
+ unset (_${_PYTHON_PREFIX}_LIBRARY_DEBUG CACHE)
+ unset (_${_PYTHON_PREFIX}_INCLUDE_DIR CACHE)
+ endif()
+ if (DEFINED ${_PYTHON_PREFIX}_INCLUDE_DIR
+ AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_INCLUDE_DIR}")
+ set (_${_PYTHON_PREFIX}_INCLUDE_DIR "${${_PYTHON_PREFIX}_INCLUDE_DIR}" CACHE INTERNAL "")
+ endif()
+
+ # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
+ unset (_${_PYTHON_PREFIX}_CMAKE_FIND_LIBRARY_SUFFIXES)
+ if (DEFINED ${_PYTHON_PREFIX}_USE_STATIC_LIBS AND NOT WIN32)
+ set(_${_PYTHON_PREFIX}_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ if(${_PYTHON_PREFIX}_USE_STATIC_LIBS)
+ set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
+ else()
+ list (REMOVE_ITEM CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
+ endif()
+ endif()
+
+ if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE OR NOT _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ # if python interpreter is found, use it to look-up for artifacts
+ # to ensure consistency between interpreter and development environments.
+ # If not, try to locate a compatible config tool
+ if (NOT ${_PYTHON_PREFIX}_Interpreter_FOUND OR CMAKE_CROSSCOMPILING)
+ set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
+ unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS)
+ if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
+ set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV)
+ endif()
+ unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
+
+ if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION")
+ set (_${_PYTHON_PREFIX}_CONFIG_NAMES)
+
+ foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG)
+ list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES})
+
+ # Framework Paths
+ _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+ list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS})
+ endforeach()
+
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_CONFIG
+ NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
+
+ find_program (_${_PYTHON_PREFIX}_CONFIG
+ NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ PATH_SUFFIXES bin)
+
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_CONFIG
+ NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
+ NAMES_PER_DIR
+ PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_DEFAULT_PATH)
+ endif()
+
+ if (_${_PYTHON_PREFIX}_CONFIG)
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --help
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE __${_PYTHON_PREFIX}_HELP
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_${_PYTHON_PREFIX}_RESULT)
+ # assume config tool is not usable
+ unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ endif()
+ endif()
+
+ if (_${_PYTHON_PREFIX}_CONFIG)
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE __${_PYTHON_PREFIX}_ABIFLAGS
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_${_PYTHON_PREFIX}_RESULT)
+ # assume ABI is not supported
+ set (__${_PYTHON_PREFIX}_ABIFLAGS "")
+ endif()
+ if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT __${_PYTHON_PREFIX}_ABIFLAGS IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS)
+ # Wrong ABI
+ unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ endif()
+ endif()
+
+ if (_${_PYTHON_PREFIX}_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE)
+ # check that config tool match library architecture
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --configdir
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE _${_PYTHON_PREFIX}_CONFIGDIR
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_${_PYTHON_PREFIX}_RESULT)
+ unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ else()
+ string(FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT)
+ if (_${_PYTHON_PREFIX}_RESULT EQUAL -1)
+ unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ endif()
+ endif()
+ endif()
+ else()
+ foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ # try to use pythonX.Y-config tool
+ _python_get_names (_${_PYTHON_PREFIX}_CONFIG_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG)
+
+ # Framework Paths
+ _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+ find_program (_${_PYTHON_PREFIX}_CONFIG
+ NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
+
+ find_program (_${_PYTHON_PREFIX}_CONFIG
+ NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ PATH_SUFFIXES bin)
+
+ # Apple frameworks handling
+ if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+ find_program (_${_PYTHON_PREFIX}_CONFIG
+ NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES}
+ NAMES_PER_DIR
+ PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES bin
+ NO_DEFAULT_PATH)
+ endif()
+
+ unset (_${_PYTHON_PREFIX}_CONFIG_NAMES)
+
+ if (_${_PYTHON_PREFIX}_CONFIG)
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --help
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE __${_PYTHON_PREFIX}_HELP
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_${_PYTHON_PREFIX}_RESULT)
+ # assume config tool is not usable
+ unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ endif()
+ endif()
+
+ if (NOT _${_PYTHON_PREFIX}_CONFIG)
+ continue()
+ endif()
+
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE __${_PYTHON_PREFIX}_ABIFLAGS
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_${_PYTHON_PREFIX}_RESULT)
+ # assume ABI is not supported
+ set (__${_PYTHON_PREFIX}_ABIFLAGS "")
+ endif()
+ if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT __${_PYTHON_PREFIX}_ABIFLAGS IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS)
+ # Wrong ABI
+ unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ continue()
+ endif()
+
+ if (_${_PYTHON_PREFIX}_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE)
+ # check that config tool match library architecture
+ execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --configdir
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE _${_PYTHON_PREFIX}_CONFIGDIR
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if (_${_PYTHON_PREFIX}_RESULT)
+ unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ continue()
+ endif()
+ string (FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT)
+ if (_${_PYTHON_PREFIX}_RESULT EQUAL -1)
+ unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
+ continue()
+ endif()
+ endif()
+
+ if (_${_PYTHON_PREFIX}_CONFIG)
+ break()
+ endif()
+ endforeach()
+ endif()
+ endif()
+ endif()
+
+ if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ if ((${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT CMAKE_CROSSCOMPILING) OR _${_PYTHON_PREFIX}_CONFIG)
+ # retrieve root install directory
+ _python_get_config_var (_${_PYTHON_PREFIX}_PREFIX PREFIX)
+
+ # enforce current ABI
+ _python_get_config_var (_${_PYTHON_PREFIX}_ABIFLAGS ABIFLAGS)
+
+ set (_${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_PREFIX}")
+
+ # retrieve library
+ ## compute some paths and artifact names
+ if (_${_PYTHON_PREFIX}_CONFIG)
+ string (REGEX REPLACE "^.+python([0-9.]+)[a-z]*-config" "\\1" _${_PYTHON_PREFIX}_VERSION "${_${_PYTHON_PREFIX}_CONFIG}")
+ else()
+ set (_${_PYTHON_PREFIX}_VERSION "${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}")
+ endif()
+ _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_VERSION} LIBRARY)
+ _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 POSIX LIBRARY)
+
+ _python_get_config_var (_${_PYTHON_PREFIX}_CONFIGDIR CONFIGDIR)
+ list (APPEND _${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_CONFIGDIR}")
+
+ list (APPEND _${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
+
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
+
+ # Rely on HINTS and standard paths if interpreter or config tool failed to locate artifacts
+ if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
+
+ unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS)
+ if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
+ set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV)
+ endif()
+
+ if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION")
+ unset (_${_PYTHON_PREFIX}_LIB_NAMES)
+ unset (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG)
+ unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
+ unset (_${_PYTHON_PREFIX}_REGISTRY_PATHS)
+ unset (_${_PYTHON_PREFIX}_PATH_SUFFIXES)
+
+ foreach (_${_PYTHON_PREFIX}_LIB_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ # library names
+ _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 POSIX LIBRARY)
+ list (APPEND _${_PYTHON_PREFIX}_LIB_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES})
+ _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 DEBUG)
+ list (APPEND _${_PYTHON_PREFIX}_LIB_NAMES_DEBUG ${_${_PYTHON_PREFIX}_VERSION_NAMES})
+
+ # Framework Paths
+ _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION})
+ list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS})
+
+ # Registry Paths
+ _python_get_registries (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION})
+ list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS})
+
+ # Paths suffixes
+ _python_get_path_suffixes (_${_PYTHON_PREFIX}_VERSION_PATHS VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY)
+ list (APPEND _${_PYTHON_PREFIX}_PATH_SUFFIXES ${_${_PYTHON_PREFIX}_VERSION_PATHS})
+ endforeach()
+
+ if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
+
+ if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
+
+ # search in HINTS locations
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+
+ if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+ set (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS})
+ else()
+ unset (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
+ endif()
+
+ if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
+ set (__${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS})
+ else()
+ unset (__${_PYTHON_PREFIX}_REGISTRY_PATHS)
+ endif()
+
+ # search in all default paths
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
+ NAMES_PER_DIR
+ PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ ${__${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES})
+ else()
+ foreach (_${_PYTHON_PREFIX}_LIB_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS)
+ _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 POSIX LIBRARY)
+ _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} WIN32 DEBUG)
+
+ _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION})
+ _python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION})
+
+ _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY)
+
+ if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
+
+ if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
+
+ # search in HINTS locations
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
+ NAMES_PER_DIR
+ HINTS ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+
+ if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+ set (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS})
+ else()
+ unset (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
+ endif()
+
+ if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
+ set (__${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS})
+ else()
+ unset (__${_PYTHON_PREFIX}_REGISTRY_PATHS)
+ endif()
+
+ # search in all default paths
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
+ NAMES_PER_DIR
+ PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ ${__${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES})
+
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ break()
+ endif()
+ endforeach()
+ endif()
+ endif()
+ endif()
+
+ # finalize library version information
+ _python_get_version (LIBRARY PREFIX _${_PYTHON_PREFIX}_)
+
+ set (${_PYTHON_PREFIX}_LIBRARY_RELEASE "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" CACHE FILEPATH "Path to a library." FORCE)
+
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND NOT EXISTS "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}")
+ set_property (CACHE _${_PYTHON_PREFIX}_LIBRARY_RELEASE PROPERTY VALUE "_${_PYTHON_PREFIX}_LIBRARY_RELEASE-NOTFOUND")
+ endif()
+
+ set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
+
+ if (WIN32 AND _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ # search for debug library
+ # use release library location as a hint
+ _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 DEBUG)
+ get_filename_component (_${_PYTHON_PREFIX}_PATH "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY)
+ find_library (_${_PYTHON_PREFIX}_LIBRARY_DEBUG
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG}
+ NAMES_PER_DIR
+ HINTS "${_${_PYTHON_PREFIX}_PATH}" ${_${_PYTHON_PREFIX}_HINTS}
+ NO_DEFAULT_PATH)
+ endif()
+
+ # retrieve runtime libraries
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE)
+ _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 POSIX LIBRARY)
+ get_filename_component (_${_PYTHON_PREFIX}_PATH "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY)
+ get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY)
+ _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES}
+ NAMES_PER_DIR
+ HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS}
+ PATH_SUFFIXES bin)
+ endif()
+ if (_${_PYTHON_PREFIX}_LIBRARY_DEBUG)
+ _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_VERSION} WIN32 DEBUG)
+ get_filename_component (_${_PYTHON_PREFIX}_PATH "${_${_PYTHON_PREFIX}_LIBRARY_DEBUG}" DIRECTORY)
+ get_filename_component (_${_PYTHON_PREFIX}_PATH2 "${_${_PYTHON_PREFIX}_PATH}" DIRECTORY)
+ _python_find_runtime_library (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG
+ NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG}
+ NAMES_PER_DIR
+ HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS}
+ PATH_SUFFIXES bin)
+ endif()
+
+ # Don't search for include dir if no library was founded
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND NOT _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ if ((${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT CMAKE_CROSSCOMPILING) OR _${_PYTHON_PREFIX}_CONFIG)
+ _python_get_config_var (_${_PYTHON_PREFIX}_INCLUDE_DIRS INCLUDES)
+
+ find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR
+ NAMES Python.h
+ HINTS ${_${_PYTHON_PREFIX}_INCLUDE_DIRS}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
+
+ # Rely on HINTS and standard paths if interpreter or config tool failed to locate artifacts
+ if (NOT _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS)
+ if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$")
+ set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV)
+ endif()
+ unset (_${_PYTHON_PREFIX}_INCLUDE_HINTS)
+
+ # Use the library's install prefix as a hint
+ if (${_${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+/Frameworks/Python.framework/Versions/[0-9.]+)")
+ list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}")
+ elseif (${_${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+)/lib(64|32)?/python[0-9.]+/config")
+ list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}")
+ elseif (DEFINED CMAKE_LIBRARY_ARCHITECTURE AND ${_${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+)/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
+ list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}")
+ else()
+ # assume library is in a directory under root
+ get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY)
+ get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${_${_PYTHON_PREFIX}_PREFIX}" DIRECTORY)
+ list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${_${_PYTHON_PREFIX}_PREFIX}")
+ endif()
+
+ _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+ _python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION})
+ _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_VERSION} INCLUDE)
+
+ if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST")
+ find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR
+ NAMES Python.h
+ HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
+
+ if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "FIRST")
+ find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR
+ NAMES Python.h
+ HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${_${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
+
+ if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST")
+ set (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS})
+ else()
+ unset (__${_PYTHON_PREFIX}_FRAMEWORK_PATHS)
+ endif()
+
+ if (WIN32 AND _${_PYTHON_PREFIX}_FIND_REGISTRY STREQUAL "LAST")
+ set (__${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS})
+ else()
+ unset (__${_PYTHON_PREFIX}_REGISTRY_PATHS)
+ endif()
+
+ find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR
+ NAMES Python.h
+ HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS}
+ PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS}
+ ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS}
+ ${__${_PYTHON_PREFIX}_REGISTRY_PATHS}
+ PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES}
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH)
+ endif()
+
+ # search header file in standard locations
+ find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR
+ NAMES Python.h)
+ endif()
+
+ set (${_PYTHON_PREFIX}_INCLUDE_DIRS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}")
+
+ if (_${_PYTHON_PREFIX}_INCLUDE_DIR AND NOT EXISTS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}")
+ set_property (CACHE _${_PYTHON_PREFIX}_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND")
+ endif()
+
+ if (_${_PYTHON_PREFIX}_INCLUDE_DIR)
+ # retrieve version from header file
+ _python_get_version (INCLUDE PREFIX _${_PYTHON_PREFIX}_INC_)
+
+ # update versioning
+ if (_${_PYTHON_PREFIX}_INC_VERSION VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION})
+ set (_${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_INC_VERSION_PATCH})
+ endif()
+ endif()
+
+ if (NOT ${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT ${_PYTHON_PREFIX}_Compiler_FOUND)
+ # set public version information
+ set (${_PYTHON_PREFIX}_VERSION ${_${_PYTHON_PREFIX}_VERSION})
+ set (${_PYTHON_PREFIX}_VERSION_MAJOR ${_${_PYTHON_PREFIX}_VERSION_MAJOR})
+ set (${_PYTHON_PREFIX}_VERSION_MINOR ${_${_PYTHON_PREFIX}_VERSION_MINOR})
+ set (${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_VERSION_PATCH})
+ endif()
+
+ # define public variables
+ set (${_PYTHON_PREFIX}_LIBRARY_DEBUG "${_${_PYTHON_PREFIX}_LIBRARY_DEBUG}" CACHE FILEPATH "Path to a library." FORCE)
+
+ include (${CMAKE_CURRENT_LIST_DIR}/../SelectLibraryConfigurations.cmake)
+ select_library_configurations (${_PYTHON_PREFIX})
+ if (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE)
+ set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE}")
+ elseif (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)
+ set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG}")
+ else()
+ set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY "${_PYTHON_PREFIX}_RUNTIME_LIBRARY-NOTFOUND")
+ endif()
+
+ _python_set_library_dirs (${_PYTHON_PREFIX}_LIBRARY_DIRS
+ ${_PYTHON_PREFIX}_LIBRARY_RELEASE ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
+ if (UNIX)
+ if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$")
+ set (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DIRS ${${_PYTHON_PREFIX}_LIBRARY_DIRS})
+ endif()
+ else()
+ _python_set_library_dirs (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DIRS
+ ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)
+ endif()
+
+ if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND _${_PYTHON_PREFIX}_INCLUDE_DIR)
+ if (${_PYTHON_PREFIX}_Interpreter_FOUND OR ${_PYTHON_PREFIX}_Compiler_FOUND)
+ # development environment must be compatible with interpreter/compiler
+ if (${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR} VERSION_EQUAL ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}
+ AND ${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR} VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR})
+ set (${_PYTHON_PREFIX}_Development_FOUND TRUE)
+ endif()
+ elseif (${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR
+ AND ${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR} VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR})
+ set (${_PYTHON_PREFIX}_Development_FOUND TRUE)
+ endif()
+ if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND
+ (NOT _${_PYTHON_PREFIX}_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS
+ OR NOT _${_PYTHON_PREFIX}_INC_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS))
+ set (${_PYTHON_PREFIX}_Development_FOUND FALSE)
+ endif()
+ endif()
+
+ if (${_PYTHON_PREFIX}_Development_FOUND)
+ # compute and save development signature
+ string (MD5 __${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}:${_${_PYTHON_PREFIX}_INCLUDE_DIR}")
+ set (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${__${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}" CACHE INTERNAL "")
+ else()
+ unset (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE CACHE)
+ endif()
+
+ # Restore the original find library ordering
+ if (DEFINED _${_PYTHON_PREFIX}_CMAKE_FIND_LIBRARY_SUFFIXES)
+ set (CMAKE_FIND_LIBRARY_SUFFIXES ${_${_PYTHON_PREFIX}_CMAKE_FIND_LIBRARY_SUFFIXES})
+ endif()
+
+ mark_as_advanced (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
+ _${_PYTHON_PREFIX}_LIBRARY_DEBUG
+ ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE
+ ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG
+ _${_PYTHON_PREFIX}_INCLUDE_DIR
+ _${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE)
+endif()
+
+if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Interpreter_FOUND)
+ list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
+ if (${_PYTHON_PREFIX}_FIND_REQUIRED_NumPy)
+ list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS)
+ endif()
+
+ if (DEFINED ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR
+ AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
+ set (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}" CACHE INTERNAL "")
+ elseif (DEFINED _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
+ # compute numpy signature. Depends on interpreter and development signatures
+ string (MD5 __${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}:${_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}:${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
+ if (NOT __${_PYTHON_PREFIX}_NUMPY_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_NUMPY_SIGNATURE
+ OR NOT EXISTS "${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
+ unset (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR CACHE)
+ unset (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE CACHE)
+ endif()
+ endif()
+
+ if (NOT _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
+ execute_process(
+ COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c
+ "from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n"
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE _${_PYTHON_PREFIX}_NumPy_PATH
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if (NOT _${_PYTHON_PREFIX}_RESULT)
+ find_path (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR
+ NAMES "numpy/arrayobject.h" "numpy/numpyconfig.h"
+ HINTS "${_${_PYTHON_PREFIX}_NumPy_PATH}"
+ NO_DEFAULT_PATH)
+ endif()
+ endif()
+
+ set (${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS "${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
+
+ if(_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR AND NOT EXISTS "${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
+ set_property (CACHE _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR PROPERTY VALUE "_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR-NOTFOUND")
+ endif()
+
+ if (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
+ execute_process (
+ COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c
+ "from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept:pass\n"
+ RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
+ OUTPUT_VARIABLE _${_PYTHON_PREFIX}_NumPy_VERSION)
+ if (NOT _${_PYTHON_PREFIX}_RESULT)
+ set (${_PYTHON_PREFIX}_NumPy_VERSION "${_${_PYTHON_PREFIX}_NumPy_VERSION}")
+ else()
+ unset (${_PYTHON_PREFIX}_NumPy_VERSION)
+ endif()
+
+ # final step: set NumPy founded only if Development component is founded as well
+ set(${_PYTHON_PREFIX}_NumPy_FOUND ${${_PYTHON_PREFIX}_Development_FOUND})
+ else()
+ set (${_PYTHON_PREFIX}_NumPy_FOUND FALSE)
+ endif()
+
+ if (${_PYTHON_PREFIX}_NumPy_FOUND)
+ # compute and save numpy signature
+ string (MD5 __${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}:${_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}:${${_PYTHON_PREFIX}_NumPyINCLUDE_DIR}")
+ set (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${__${_PYTHON_PREFIX}_NUMPY_SIGNATURE}" CACHE INTERNAL "")
+ else()
+ unset (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE CACHE)
+ endif()
+
+ mark_as_advanced (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
+endif()
+
+# final validation
+if (${_PYTHON_PREFIX}_VERSION_MAJOR AND
+ NOT ${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
+ _python_display_failure ("Could NOT find ${_PYTHON_PREFIX}: Found unsuitable major version \"${${_PYTHON_PREFIX}_VERSION_MAJOR}\", but required major version is exact version \"${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}\"")
+endif()
+
+include (${CMAKE_CURRENT_LIST_DIR}/../FindPackageHandleStandardArgs.cmake)
+find_package_handle_standard_args (${_PYTHON_PREFIX}
+ REQUIRED_VARS ${_${_PYTHON_PREFIX}_REQUIRED_VARS}
+ VERSION_VAR ${_PYTHON_PREFIX}_VERSION
+ HANDLE_COMPONENTS)
+
+# Create imported targets and helper functions
+if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT")
+ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
+ AND ${_PYTHON_PREFIX}_Interpreter_FOUND
+ AND NOT TARGET ${_PYTHON_PREFIX}::Interpreter)
+ add_executable (${_PYTHON_PREFIX}::Interpreter IMPORTED)
+ set_property (TARGET ${_PYTHON_PREFIX}::Interpreter
+ PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_EXECUTABLE}")
+ endif()
+
+ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
+ AND ${_PYTHON_PREFIX}_Compiler_FOUND
+ AND NOT TARGET ${_PYTHON_PREFIX}::Compiler)
+ add_executable (${_PYTHON_PREFIX}::Compiler IMPORTED)
+ set_property (TARGET ${_PYTHON_PREFIX}::Compiler
+ PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_COMPILER}")
+ endif()
+
+ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
+ AND ${_PYTHON_PREFIX}_Development_FOUND)
+
+ macro (__PYTHON_IMPORT_LIBRARY __name)
+ if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$"
+ OR ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE)
+ set (_${_PYTHON_PREFIX}_LIBRARY_TYPE SHARED)
+ else()
+ set (_${_PYTHON_PREFIX}_LIBRARY_TYPE STATIC)
+ endif()
+
+ if (NOT TARGET ${__name})
+ add_library (${__name} ${_${_PYTHON_PREFIX}_LIBRARY_TYPE} IMPORTED)
+ endif()
+
+ set_property (TARGET ${__name}
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIRS}")
+
+ if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE)
+ # System manage shared libraries in two parts: import and runtime
+ if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
+ set_property (TARGET ${__name} PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG)
+ set_target_properties (${__name}
+ PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
+ IMPORTED_IMPLIB_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}"
+ IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE}")
+ set_target_properties (${__name}
+ PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
+ IMPORTED_IMPLIB_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}"
+ IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG}")
+ else()
+ set_target_properties (${__name}
+ PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_IMPLIB "${${_PYTHON_PREFIX}_LIBRARY}"
+ IMPORTED_LOCATION "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY}")
+ endif()
+ else()
+ if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG)
+ set_property (TARGET ${__name} PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG)
+ set_target_properties (${__name}
+ PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
+ IMPORTED_LOCATION_RELEASE "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}")
+ set_target_properties (${__name}
+ PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
+ IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_LIBRARY_DEBUG}")
+ else()
+ set_target_properties (${__name}
+ PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${${_PYTHON_PREFIX}_LIBRARY}")
+ endif()
+ endif()
+
+ if (_${_PYTHON_PREFIX}_LIBRARY_TYPE STREQUAL "STATIC")
+ # extend link information with dependent libraries
+ _python_get_config_var (_${_PYTHON_PREFIX}_LINK_LIBRARIES LIBS)
+ if (_${_PYTHON_PREFIX}_LINK_LIBRARIES)
+ set_property (TARGET ${__name}
+ PROPERTY INTERFACE_LINK_LIBRARIES ${_${_PYTHON_PREFIX}_LINK_LIBRARIES})
+ endif()
+ endif()
+ endmacro()
+
+ __python_import_library (${_PYTHON_PREFIX}::Python)
+
+ if (CMAKE_SYSTEM_NAME MATCHES "^(Windows.*|CYGWIN|MSYS)$")
+ # On Windows/CYGWIN/MSYS, Python::Module is the same as Python::Python
+ # but ALIAS cannot be used because the imported library is not GLOBAL.
+ __python_import_library (${_PYTHON_PREFIX}::Module)
+ else()
+ if (NOT TARGET ${_PYTHON_PREFIX}::Module )
+ add_library (${_PYTHON_PREFIX}::Module INTERFACE IMPORTED)
+ endif()
+ set_property (TARGET ${_PYTHON_PREFIX}::Module
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIRS}")
+
+ # When available, enforce shared library generation with undefined symbols
+ if (APPLE)
+ set_property (TARGET ${_PYTHON_PREFIX}::Module
+ PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-undefined,dynamic_lookup")
+ endif()
+ if (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ set_property (TARGET ${_PYTHON_PREFIX}::Module
+ PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-z,nodefs")
+ endif()
+ if (CMAKE_SYSTEM_NAME STREQUAL "AIX")
+ set_property (TARGET ${_PYTHON_PREFIX}::Module
+ PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-b,erok")
+ endif()
+ endif()
+
+ #
+ # PYTHON_ADD_LIBRARY (<name> [STATIC|SHARED|MODULE] src1 src2 ... srcN)
+ # It is used to build modules for python.
+ #
+ function (__${_PYTHON_PREFIX}_ADD_LIBRARY prefix name)
+ cmake_parse_arguments (PARSE_ARGV 2 PYTHON_ADD_LIBRARY
+ "STATIC;SHARED;MODULE" "" "")
+
+ unset (type)
+ if (NOT (PYTHON_ADD_LIBRARY_STATIC
+ OR PYTHON_ADD_LIBRARY_SHARED
+ OR PYTHON_ADD_LIBRARY_MODULE))
+ set (type MODULE)
+ endif()
+ add_library (${name} ${type} ${ARGN})
+
+ get_property (type TARGET ${name} PROPERTY TYPE)
+
+ if (type STREQUAL "MODULE_LIBRARY")
+ target_link_libraries (${name} PRIVATE ${prefix}::Module)
+ # customize library name to follow module name rules
+ set_property (TARGET ${name} PROPERTY PREFIX "")
+ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ set_property (TARGET ${name} PROPERTY SUFFIX ".pyd")
+ endif()
+ else()
+ target_link_libraries (${name} PRIVATE ${prefix}::Python)
+ endif()
+ endfunction()
+ endif()
+
+ if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_NumPy_FOUND
+ AND NOT TARGET ${_PYTHON_PREFIX}::NumPy AND TARGET ${_PYTHON_PREFIX}::Module)
+ add_library (${_PYTHON_PREFIX}::NumPy INTERFACE IMPORTED)
+ set_property (TARGET ${_PYTHON_PREFIX}::NumPy
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS}")
+ target_link_libraries (${_PYTHON_PREFIX}::NumPy INTERFACE ${_PYTHON_PREFIX}::Module)
+ endif()
+endif()
+
+# final clean-up
+
+# Restore CMAKE_FIND_APPBUNDLE
+if (DEFINED _${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE)
+ set (CMAKE_FIND_APPBUNDLE ${_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE})
+ unset (_${_PYTHON_PREFIX}_CMAKE_FIND_APPBUNDLE)
+else()
+ unset (CMAKE_FIND_APPBUNDLE)
+endif()
+# Restore CMAKE_FIND_FRAMEWORK
+if (DEFINED _${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK)
+ set (CMAKE_FIND_FRAMEWORK ${_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK})
+ unset (_${_PYTHON_PREFIX}_CMAKE_FIND_FRAMEWORK)
+else()
+ unset (CMAKE_FIND_FRAMEWORK)
+endif()
+
+unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake
new file mode 100644
index 000000000..3cc7d5679
--- /dev/null
+++ b/Modules/FindPython2.cmake
@@ -0,0 +1,267 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindPython2
+-----------
+
+Find Python 2 interpreter, compiler and development environment (include
+directories and libraries).
+
+The following components are supported:
+
+* ``Interpreter``: search for Python 2 interpreter
+* ``Compiler``: search for Python 2 compiler. Only offered by IronPython.
+* ``Development``: search for development artifacts (include directories and
+ libraries)
+* ``NumPy``: search for NumPy include directories.
+
+If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed.
+
+To ensure consistent versions between components ``Interpreter``, ``Compiler``,
+``Development`` and ``NumPy``, specify all components at the same time::
+
+ find_package (Python2 COMPONENTS Interpreter Development)
+
+This module looks only for version 2 of Python. This module can be used
+concurrently with :module:`FindPython3` module to use both Python versions.
+
+The :module:`FindPython` module can be used if Python version does not matter
+for you.
+
+.. note::
+
+ If components ``Interpreter`` and ``Development`` are both specified, this
+ module search only for interpreter with same platform architecture as the one
+ defined by ``CMake`` configuration. This contraint does not apply if only
+ ``Interpreter`` component is specified.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :ref:`Imported Targets <Imported Targets>`
+(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``):
+
+``Python2::Interpreter``
+ Python 2 interpreter. Target defined if component ``Interpreter`` is found.
+``Python2::Compiler``
+ Python 2 compiler. Target defined if component ``Compiler`` is found.
+``Python2::Python``
+ Python 2 library for Python embedding. Target defined if component
+ ``Development`` is found.
+``Python2::Module``
+ Python 2 library for Python module. Target defined if component
+ ``Development`` is found.
+``Python2::NumPy``
+ NumPy library for Python 2. Target defined if component ``NumPy`` is found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project
+(see :ref:`Standard Variable Names <CMake Developer Standard Variable Names>`):
+
+``Python2_FOUND``
+ System has the Python 2 requested components.
+``Python2_Interpreter_FOUND``
+ System has the Python 2 interpreter.
+``Python2_EXECUTABLE``
+ Path to the Python 2 interpreter.
+``Python2_INTERPRETER_ID``
+ A short string unique to the interpreter. Possible values include:
+ * Python
+ * ActivePython
+ * Anaconda
+ * Canopy
+ * IronPython
+``Python2_STDLIB``
+ Standard platform independent installation directory.
+
+ Information returned by
+ ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``.
+``Python2_STDARCH``
+ Standard platform dependent installation directory.
+
+ Information returned by
+ ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``.
+``Python2_SITELIB``
+ Third-party platform independent installation directory.
+
+ Information returned by
+ ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``.
+``Python2_SITEARCH``
+ Third-party platform dependent installation directory.
+
+ Information returned by
+ ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``.
+``Python2_Compiler_FOUND``
+ System has the Python 2 compiler.
+``Python2_COMPILER``
+ Path to the Python 2 compiler. Only offered by IronPython.
+``Python2_COMPILER_ID``
+ A short string unique to the compiler. Possible values include:
+ * IronPython
+``Python2_Development_FOUND``
+ System has the Python 2 development artifacts.
+``Python2_INCLUDE_DIRS``
+ The Python 2 include directories.
+``Python2_LIBRARIES``
+ The Python 2 libraries.
+``Python2_LIBRARY_DIRS``
+ The Python 2 library directories.
+``Python2_RUNTIME_LIBRARY_DIRS``
+ The Python 2 runtime library directories.
+``Python2_VERSION``
+ Python 2 version.
+``Python2_VERSION_MAJOR``
+ Python 2 major version.
+``Python2_VERSION_MINOR``
+ Python 2 minor version.
+``Python2_VERSION_PATCH``
+ Python 2 patch version.
+``Python2_NumPy_FOUND``
+ System has the NumPy.
+``Python2_NumPy_INCLUDE_DIRS``
+ The NumPy include directries.
+``Python2_NumPy_VERSION``
+ The NumPy version.
+
+Hints
+^^^^^
+
+``Python2_ROOT_DIR``
+ Define the root directory of a Python 2 installation.
+
+``Python2_USE_STATIC_LIBS``
+ * If not defined, search for shared libraries and static libraries in that
+ order.
+ * If set to TRUE, search **only** for static libraries.
+ * If set to FALSE, search **only** for shared libraries.
+
+``Python2_FIND_STRATEGY``
+ This variable defines how lookup will be done.
+ The ``Python2_FIND_STRATEGY`` variable can be set to empty or one of the
+ following:
+
+ * ``VERSION``: Try to find the most recent version in all specified
+ locations.
+ This is the default if policy :policy:`CMP0094` is undefined or set to
+ ``OLD``.
+ * ``LOCATION``: Stops lookup as soon as a version satisfying version
+ constraints is founded.
+ This is the default if policy :policy:`CMP0094` is set to ``NEW``.
+
+``Python2_FIND_REGISTRY``
+ On Windows the ``Python2_FIND_REGISTRY`` variable determine the order
+ of preference between registry and environment variables.
+ the ``Python2_FIND_REGISTRY`` variable can be set to empty or one of the
+ following:
+
+ * ``FIRST``: Try to use registry before environment variables.
+ This is the default.
+ * ``LAST``: Try to use registry after environment variables.
+ * ``NEVER``: Never try to use registry.
+
+``Python2_FIND_FRAMEWORK``
+ On macOS the ``Python2_FIND_FRAMEWORK`` variable determine the order of
+ preference between Apple-style and unix-style package components.
+ This variable can be set to empty or take same values as
+ :variable:`CMAKE_FIND_FRAMEWORK` variable.
+
+ .. note::
+
+ Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
+
+ If ``Python2_FIND_FRAMEWORK`` is not defined, :variable:`CMAKE_FIND_FRAMEWORK`
+ variable will be used, if any.
+
+``Python2_FIND_VIRTUALENV``
+ This variable defines the handling of virtual environments. It is meaningfull
+ only when a virtual environment is active (i.e. the ``activate`` script has
+ been evaluated). In this case, it takes precedence over
+ ``Python2_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` variables.
+ The ``Python2_FIND_VIRTUALENV`` variable can be set to empty or one of the
+ following:
+
+ * ``FIRST``: The virtual environment is used before any other standard
+ paths to look-up for the interpreter. This is the default.
+ * ``ONLY``: Only the virtual environment is used to look-up for the
+ interpreter.
+ * ``STANDARD``: The virtual environment is not used to look-up for the
+ interpreter. In this case, variable ``Python2_FIND_REGISTRY`` (Windows)
+ or ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or
+ ``NEVER`` to select preferably the interpreter from the virtual
+ environment.
+
+ .. note::
+
+ If the component ``Development`` is requested, it is **strongly**
+ recommended to also include the component ``Interpreter`` to get expected
+ result.
+
+Artifacts Specification
+^^^^^^^^^^^^^^^^^^^^^^^
+
+To solve special cases, it is possible to specify directly the artifacts by
+setting the following variables:
+
+``Python2_EXECUTABLE``
+ The path to the interpreter.
+
+``Python2_COMPILER``
+ The path to the compiler.
+
+``Python2_LIBRARY``
+ The path to the library. It will be used to compute the
+ variables ``Python2_LIBRARIES``, ``Python2_LIBRAY_DIRS`` and
+ ``Python2_RUNTIME_LIBRARY_DIRS``.
+
+``Python2_INCLUDE_DIR``
+ The path to the directory of the ``Python`` headers. It will be used to
+ compute the variable ``Python2_INCLUDE_DIRS``.
+
+``Python2_NumPy_INCLUDE_DIR``
+ The path to the directory of the ``NumPy`` headers. It will be used to
+ compute the variable ``Python2_NumPy_INCLUDE_DIRS``.
+
+.. note::
+
+ All paths must be absolute. Any artifact specified with a relative path
+ will be ignored.
+
+.. note::
+
+ When an artifact is specified, all ``HINTS`` will be ignored and no search
+ will be performed for this artifact.
+
+ If more than one artifact is specified, it is the user's responsability to
+ ensure the consistency of the various artifacts.
+
+Commands
+^^^^^^^^
+
+This module defines the command ``Python_add_library`` (when
+:prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as
+:command:`add_library` and adds a dependency to target ``Python2::Python`` or,
+when library type is ``MODULE``, to target ``Python2::Module`` and takes care
+of Python module naming rules::
+
+ Python2_add_library (my_module MODULE src1.cpp)
+
+If library type is not specified, ``MODULE`` is assumed.
+#]=======================================================================]
+
+
+set (_PYTHON_PREFIX Python2)
+
+set (_Python2_REQUIRED_VERSION_MAJOR 2)
+
+include (${CMAKE_CURRENT_LIST_DIR}/FindPython/Support.cmake)
+
+if (COMMAND __Python2_add_library)
+ macro (Python2_add_library)
+ __Python2_add_library (Python2 ${ARGV})
+ endmacro()
+endif()
+
+unset (_PYTHON_PREFIX)
diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake
new file mode 100644
index 000000000..066d0df6a
--- /dev/null
+++ b/Modules/FindPython3.cmake
@@ -0,0 +1,308 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindPython3
+-----------
+
+Find Python 3 interpreter, compiler and development environment (include
+directories and libraries).
+
+The following components are supported:
+
+* ``Interpreter``: search for Python 3 interpreter
+* ``Compiler``: search for Python 3 compiler. Only offered by IronPython.
+* ``Development``: search for development artifacts (include directories and
+ libraries)
+* ``NumPy``: search for NumPy include directories.
+
+If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed.
+
+To ensure consistent versions between components ``Interpreter``, ``Compiler``,
+``Development`` and ``NumPy``, specify all components at the same time::
+
+ find_package (Python3 COMPONENTS Interpreter Development)
+
+This module looks only for version 3 of Python. This module can be used
+concurrently with :module:`FindPython2` module to use both Python versions.
+
+The :module:`FindPython` module can be used if Python version does not matter
+for you.
+
+.. note::
+
+ If components ``Interpreter`` and ``Development`` are both specified, this
+ module search only for interpreter with same platform architecture as the one
+ defined by ``CMake`` configuration. This contraint does not apply if only
+ ``Interpreter`` component is specified.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :ref:`Imported Targets <Imported Targets>`
+(when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``):
+
+``Python3::Interpreter``
+ Python 3 interpreter. Target defined if component ``Interpreter`` is found.
+``Python3::Compiler``
+ Python 3 compiler. Target defined if component ``Compiler`` is found.
+``Python3::Python``
+ Python 3 library for Python embedding. Target defined if component
+ ``Development`` is found.
+``Python3::Module``
+ Python 3 library for Python module. Target defined if component
+ ``Development`` is found.
+``Python3::NumPy``
+ NumPy library for Python 3. Target defined if component ``NumPy`` is found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project
+(see :ref:`Standard Variable Names <CMake Developer Standard Variable Names>`):
+
+``Python3_FOUND``
+ System has the Python 3 requested components.
+``Python3_Interpreter_FOUND``
+ System has the Python 3 interpreter.
+``Python3_EXECUTABLE``
+ Path to the Python 3 interpreter.
+``Python3_INTERPRETER_ID``
+ A short string unique to the interpreter. Possible values include:
+ * Python
+ * ActivePython
+ * Anaconda
+ * Canopy
+ * IronPython
+``Python3_STDLIB``
+ Standard platform independent installation directory.
+
+ Information returned by
+ ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``.
+``Python3_STDARCH``
+ Standard platform dependent installation directory.
+
+ Information returned by
+ ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``.
+``Python3_SITELIB``
+ Third-party platform independent installation directory.
+
+ Information returned by
+ ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``.
+``Python3_SITEARCH``
+ Third-party platform dependent installation directory.
+
+ Information returned by
+ ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``.
+``Python3_Compiler_FOUND``
+ System has the Python 3 compiler.
+``Python3_COMPILER``
+ Path to the Python 3 compiler. Only offered by IronPython.
+``Python3_COMPILER_ID``
+ A short string unique to the compiler. Possible values include:
+ * IronPython
+``Python3_Development_FOUND``
+ System has the Python 3 development artifacts.
+``Python3_INCLUDE_DIRS``
+ The Python 3 include directories.
+``Python3_LIBRARIES``
+ The Python 3 libraries.
+``Python3_LIBRARY_DIRS``
+ The Python 3 library directories.
+``Python3_RUNTIME_LIBRARY_DIRS``
+ The Python 3 runtime library directories.
+``Python3_VERSION``
+ Python 3 version.
+``Python3_VERSION_MAJOR``
+ Python 3 major version.
+``Python3_VERSION_MINOR``
+ Python 3 minor version.
+``Python3_VERSION_PATCH``
+ Python 3 patch version.
+``Python3_NumPy_FOUND``
+ System has the NumPy.
+``Python3_NumPy_INCLUDE_DIRS``
+ The NumPy include directries.
+``Python3_NumPy_VERSION``
+ The NumPy version.
+
+Hints
+^^^^^
+
+``Python3_ROOT_DIR``
+ Define the root directory of a Python 3 installation.
+
+``Python3_USE_STATIC_LIBS``
+ * If not defined, search for shared libraries and static libraries in that
+ order.
+ * If set to TRUE, search **only** for static libraries.
+ * If set to FALSE, search **only** for shared libraries.
+
+``Python3_FIND_ABI``
+ This variable defines which ABIs, as defined in
+ `PEP 3149 <https://www.python.org/dev/peps/pep-3149/>`_, should be searched.
+
+ .. note::
+
+ If ``Python3_FIND_ABI`` is not defined, any ABI will be searched.
+
+ The ``Python3_FIND_ABI`` variable is a 3-tuple specifying, in that order,
+ ``pydebug`` (``d``), ``pymalloc`` (``m``) and ``unicode`` (``u``) flags.
+ Each element can be set to one of the following:
+
+ * ``ON``: Corresponding flag is selected.
+ * ``OFF``: Corresponding flag is not selected.
+ * ``ANY``: The two posibilties (``ON`` and ``OFF``) will be searched.
+
+ From this 3-tuple, various ABIs will be searched starting from the most
+ specialized to the most general. Moreover, ``debug`` versions will be
+ searched **after** ``non-debug`` ones.
+
+ For example, if we have::
+
+ set (Python3_FIND_ABI "ON" "ANY" "ANY")
+
+ The following flags combinations will be appended, in that order, to the
+ artifact names: ``dmu``, ``dm``, ``du``, and ``d``.
+
+ And to search any possible ABIs::
+
+ set (Python3_FIND_ABI "ANY" "ANY" "ANY")
+
+ The following combinations, in that order, will be used: ``mu``, ``m``,
+ ``u``, ``<empty>``, ``dmu``, ``dm``, ``du`` and ``d``.
+
+ .. note::
+
+ This hint is useful only on ``POSIX`` systems. So, on ``Windows`` systems,
+ when ``Python3_FIND_ABI`` is defined, ``Python`` distributions from
+ `python.org <https://www.python.org/>`_ will be found only if value for
+ each flag is ``OFF`` or ``ANY``.
+
+``Python3_FIND_STRATEGY``
+ This variable defines how lookup will be done.
+ The ``Python3_FIND_STRATEGY`` variable can be set to empty or one of the
+ following:
+
+ * ``VERSION``: Try to find the most recent version in all specified
+ locations.
+ This is the default if policy :policy:`CMP0094` is undefined or set to
+ ``OLD``.
+ * ``LOCATION``: Stops lookup as soon as a version satisfying version
+ constraints is founded.
+ This is the default if policy :policy:`CMP0094` is set to ``NEW``.
+
+``Python3_FIND_REGISTRY``
+ On Windows the ``Python3_FIND_REGISTRY`` variable determine the order
+ of preference between registry and environment variables.
+ The ``Python3_FIND_REGISTRY`` variable can be set to empty or one of the
+ following:
+
+ * ``FIRST``: Try to use registry before environment variables.
+ This is the default.
+ * ``LAST``: Try to use registry after environment variables.
+ * ``NEVER``: Never try to use registry.
+
+``Python3_FIND_FRAMEWORK``
+ On macOS the ``Python3_FIND_FRAMEWORK`` variable determine the order of
+ preference between Apple-style and unix-style package components.
+ This variable can be set to empty or take same values as
+ :variable:`CMAKE_FIND_FRAMEWORK` variable.
+
+ .. note::
+
+ Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
+
+ If ``Python3_FIND_FRAMEWORK`` is not defined, :variable:`CMAKE_FIND_FRAMEWORK`
+ variable will be used, if any.
+
+``Python3_FIND_VIRTUALENV``
+ This variable defines the handling of virtual environments. It is meaningfull
+ only when a virtual environment is active (i.e. the ``activate`` script has
+ been evaluated). In this case, it takes precedence over
+ ``Python3_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` variables.
+ The ``Python3_FIND_VIRTUALENV`` variable can be set to empty or one of the
+ following:
+
+ * ``FIRST``: The virtual environment is used before any other standard
+ paths to look-up for the interpreter. This is the default.
+ * ``ONLY``: Only the virtual environment is used to look-up for the
+ interpreter.
+ * ``STANDARD``: The virtual environment is not used to look-up for the
+ interpreter. In this case, variable ``Python3_FIND_REGISTRY`` (Windows)
+ or ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or
+ ``NEVER`` to select preferably the interpreter from the virtual
+ environment.
+
+ .. note::
+
+ If the component ``Development`` is requested, it is **strongly**
+ recommended to also include the component ``Interpreter`` to get expected
+ result.
+
+Artifacts Specification
+^^^^^^^^^^^^^^^^^^^^^^^
+
+To solve special cases, it is possible to specify directly the artifacts by
+setting the following variables:
+
+``Python3_EXECUTABLE``
+ The path to the interpreter.
+
+``Python3_COMPILER``
+ The path to the compiler.
+
+``Python3_LIBRARY``
+ The path to the library. It will be used to compute the
+ variables ``Python3_LIBRARIES``, ``Python3_LIBRAY_DIRS`` and
+ ``Python3_RUNTIME_LIBRARY_DIRS``.
+
+``Python3_INCLUDE_DIR``
+ The path to the directory of the ``Python`` headers. It will be used to
+ compute the variable ``Python3_INCLUDE_DIRS``.
+
+``Python3_NumPy_INCLUDE_DIR``
+ The path to the directory of the ``NumPy`` headers. It will be used to
+ compute the variable ``Python3_NumPy_INCLUDE_DIRS``.
+
+.. note::
+
+ All paths must be absolute. Any artifact specified with a relative path
+ will be ignored.
+
+.. note::
+
+ When an artifact is specified, all ``HINTS`` will be ignored and no search
+ will be performed for this artifact.
+
+ If more than one artifact is specified, it is the user's responsability to
+ ensure the consistency of the various artifacts.
+
+Commands
+^^^^^^^^
+
+This module defines the command ``Python_add_library`` (when
+:prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as
+:command:`add_library` and adds a dependency to target ``Python3::Python`` or,
+when library type is ``MODULE``, to target ``Python3::Module`` and takes care
+of Python module naming rules::
+
+ Python3_add_library (my_module MODULE src1.cpp)
+
+If library type is not specified, ``MODULE`` is assumed.
+#]=======================================================================]
+
+
+set (_PYTHON_PREFIX Python3)
+
+set (_Python3_REQUIRED_VERSION_MAJOR 3)
+
+include (${CMAKE_CURRENT_LIST_DIR}/FindPython/Support.cmake)
+
+if (COMMAND __Python3_add_library)
+ macro (Python3_add_library)
+ __Python3_add_library (Python3 ${ARGV})
+ endmacro()
+endif()
+
+unset (_PYTHON_PREFIX)
diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake
index 64b98a879..1e01a99cb 100644
--- a/Modules/FindPythonInterp.cmake
+++ b/Modules/FindPythonInterp.cmake
@@ -1,46 +1,60 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindPythonInterp
-# ----------------
-#
-# Find python interpreter
-#
-# This module finds if Python interpreter is installed and determines
-# where the executables are. This code sets the following variables:
-#
-# ::
-#
-# PYTHONINTERP_FOUND - Was the Python executable found
-# PYTHON_EXECUTABLE - path to the Python interpreter
-#
-#
-#
-# ::
-#
-# PYTHON_VERSION_STRING - Python version found e.g. 2.5.2
-# PYTHON_VERSION_MAJOR - Python major version found e.g. 2
-# PYTHON_VERSION_MINOR - Python minor version found e.g. 5
-# PYTHON_VERSION_PATCH - Python patch version found e.g. 2
-#
-#
-#
-# The Python_ADDITIONAL_VERSIONS variable can be used to specify a list
-# of version numbers that should be taken into account when searching
-# for Python. You need to set this variable before calling
-# find_package(PythonInterp).
-#
-# If calling both ``find_package(PythonInterp)`` and
-# ``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to
-# get the currently active Python version by default with a consistent version
-# of PYTHON_LIBRARIES.
+#[=======================================================================[.rst:
+FindPythonInterp
+----------------
+
+.. deprecated:: 3.12
+
+ Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` instead.
+
+Find python interpreter
+
+This module finds if Python interpreter is installed and determines
+where the executables are. This code sets the following variables:
+
+::
+
+ PYTHONINTERP_FOUND - Was the Python executable found
+ PYTHON_EXECUTABLE - path to the Python interpreter
+
+
+
+::
+
+ PYTHON_VERSION_STRING - Python version found e.g. 2.5.2
+ PYTHON_VERSION_MAJOR - Python major version found e.g. 2
+ PYTHON_VERSION_MINOR - Python minor version found e.g. 5
+ PYTHON_VERSION_PATCH - Python patch version found e.g. 2
+
+
+
+The Python_ADDITIONAL_VERSIONS variable can be used to specify a list
+of version numbers that should be taken into account when searching
+for Python. You need to set this variable before calling
+find_package(PythonInterp).
+
+If calling both ``find_package(PythonInterp)`` and
+``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to
+get the currently active Python version by default with a consistent version
+of PYTHON_LIBRARIES.
+
+.. note::
+
+ A call to ``find_package(PythonInterp ${V})`` for python version ``V``
+ may find a ``python`` executable with no version suffix. In this case
+ no attempt is made to avoid python executables from other versions.
+ Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython`
+ instead.
+
+#]=======================================================================]
unset(_Python_NAMES)
set(_PYTHON1_VERSIONS 1.6 1.5)
set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
-set(_PYTHON3_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
+set(_PYTHON3_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
if(PythonInterp_FIND_VERSION)
if(PythonInterp_FIND_VERSION_COUNT GREATER 1)
@@ -100,6 +114,9 @@ if(NOT PYTHON_EXECUTABLE)
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-32\\InstallPath]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-64\\InstallPath]
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-32\\InstallPath]
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-64\\InstallPath]
)
endforeach()
endif()
@@ -122,7 +139,9 @@ if(PYTHON_EXECUTABLE)
endif()
else()
# sys.version predates sys.version_info, so use that
- execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.version)"
+ # sys.version was first documented for Python 1.5, so assume version 1.4
+ # if retrieving sys.version fails.
+ execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "try: import sys; sys.stdout.write(sys.version)\nexcept: sys.stdout.write(\"1.4.0\")"
OUTPUT_VARIABLE _VERSION
RESULT_VARIABLE _PYTHON_VERSION_RESULT
ERROR_QUIET)
@@ -136,12 +155,10 @@ if(PYTHON_EXECUTABLE)
set(PYTHON_VERSION_PATCH "0")
endif()
else()
- # sys.version was first documented for Python 1.5, so assume
- # this is older.
- set(PYTHON_VERSION_STRING "1.4")
- set(PYTHON_VERSION_MAJOR "1")
- set(PYTHON_VERSION_MINOR "4")
- set(PYTHON_VERSION_PATCH "0")
+ unset(PYTHON_VERSION_STRING)
+ unset(PYTHON_VERSION_MAJOR)
+ unset(PYTHON_VERSION_MINOR)
+ unset(PYTHON_VERSION_PATCH)
endif()
endif()
unset(_PYTHON_VERSION_RESULT)
diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake
index 63ec9a84e..d3ec7beec 100644
--- a/Modules/FindPythonLibs.cmake
+++ b/Modules/FindPythonLibs.cmake
@@ -1,44 +1,49 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindPythonLibs
-# --------------
-#
-# Find python libraries
-#
-# This module finds if Python is installed and determines where the
-# include files and libraries are. It also determines what the name of
-# the library is. This code sets the following variables:
-#
-# ::
-#
-# PYTHONLIBS_FOUND - have the Python libs been found
-# PYTHON_LIBRARIES - path to the python library
-# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated)
-# PYTHON_INCLUDE_DIRS - path to where Python.h is found
-# PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated)
-# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8)
-#
-#
-#
-# The Python_ADDITIONAL_VERSIONS variable can be used to specify a list
-# of version numbers that should be taken into account when searching
-# for Python. You need to set this variable before calling
-# find_package(PythonLibs).
-#
-# If you'd like to specify the installation of Python to use, you should
-# modify the following cache variables:
-#
-# ::
-#
-# PYTHON_LIBRARY - path to the python library
-# PYTHON_INCLUDE_DIR - path to where Python.h is found
-#
-# If calling both ``find_package(PythonInterp)`` and
-# ``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to
-# get the currently active Python version by default with a consistent version
-# of PYTHON_LIBRARIES.
+#[=======================================================================[.rst:
+FindPythonLibs
+--------------
+
+.. deprecated:: 3.12
+
+ Use :module:`FindPython3`, :module:`FindPython2` or :module:`FindPython` instead.
+
+Find python libraries
+
+This module finds if Python is installed and determines where the
+include files and libraries are. It also determines what the name of
+the library is. This code sets the following variables:
+
+::
+
+ PYTHONLIBS_FOUND - have the Python libs been found
+ PYTHON_LIBRARIES - path to the python library
+ PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated)
+ PYTHON_INCLUDE_DIRS - path to where Python.h is found
+ PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated)
+ PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8)
+
+
+
+The Python_ADDITIONAL_VERSIONS variable can be used to specify a list
+of version numbers that should be taken into account when searching
+for Python. You need to set this variable before calling
+find_package(PythonLibs).
+
+If you'd like to specify the installation of Python to use, you should
+modify the following cache variables:
+
+::
+
+ PYTHON_LIBRARY - path to the python library
+ PYTHON_INCLUDE_DIR - path to where Python.h is found
+
+If calling both ``find_package(PythonInterp)`` and
+``find_package(PythonLibs)``, call ``find_package(PythonInterp)`` first to
+get the currently active Python version by default with a consistent version
+of PYTHON_LIBRARIES.
+#]=======================================================================]
# Use the executable's path as a hint
set(_Python_LIBRARY_PATH_HINT)
@@ -74,7 +79,7 @@ set(CMAKE_FIND_FRAMEWORK LAST)
set(_PYTHON1_VERSIONS 1.6 1.5)
set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
-set(_PYTHON3_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
+set(_PYTHON3_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
if(PythonLibs_FIND_VERSION)
if(PythonLibs_FIND_VERSION_COUNT GREATER 1)
@@ -117,17 +122,54 @@ unset(_PYTHON1_VERSIONS)
unset(_PYTHON2_VERSIONS)
unset(_PYTHON3_VERSIONS)
+# Python distribution: define which architectures can be used
+if (CMAKE_SIZEOF_VOID_P)
+ # In this case, search only for 64bit or 32bit
+ math (EXPR _PYTHON_ARCH "${CMAKE_SIZEOF_VOID_P} * 8")
+ set (_PYTHON_ARCH2 _PYTHON_PREFIX_ARCH})
+else()
+ if (PYTHON_EXECUTABLE)
+ # determine interpreter architecture
+ execute_process (COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; print(sys.maxsize > 2**32)"
+ RESULT_VARIABLE _PYTHON_RESULT
+ OUTPUT_VARIABLE _PYTHON_IS64BIT
+ ERROR_VARIABLE _PYTHON_IS64BIT)
+ if (NOT _PYTHON_RESULT)
+ if (_PYTHON_IS64BIT)
+ set (_PYTHON_ARCH 64)
+ set (_PYTHON_ARCH2 64)
+ else()
+ set (_PYTHON_ARCH 32)
+ set (_PYTHON_ARCH2 32)
+ endif()
+ endif()
+ else()
+ # architecture unknown, search for both 64bit and 32bit
+ set (_PYTHON_ARCH 64)
+ set (_PYTHON_ARCH2 32)
+ endif()
+endif()
+
foreach(_CURRENT_VERSION ${_Python_VERSIONS})
string(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION})
if(WIN32)
find_library(PYTHON_DEBUG_LIBRARY
NAMES python${_CURRENT_VERSION_NO_DOTS}_d python
+ NAMES_PER_DIR
HINTS ${_Python_LIBRARY_PATH_HINT}
PATHS
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs/Debug
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs/Debug
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs/Debug
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs/Debug
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs
)
endif()
@@ -145,20 +187,22 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS})
python${_CURRENT_VERSION}m
python${_CURRENT_VERSION}u
python${_CURRENT_VERSION}
+ NAMES_PER_DIR
HINTS
${_Python_LIBRARY_PATH_HINT}
PATHS
${PYTHON_FRAMEWORK_LIBRARIES}
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
- # Avoid finding the .dll in the PATH. We want the .lib.
- NO_SYSTEM_ENVIRONMENT_PATH
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/libs
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/libs
)
# Look for the static library in the Python config directory
find_library(PYTHON_LIBRARY
NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION}
- # Avoid finding the .dll in the PATH. We want the .lib.
- NO_SYSTEM_ENVIRONMENT_PATH
+ NAMES_PER_DIR
# This is where the static library is usually located
PATH_SUFFIXES python${_CURRENT_VERSION}/config
)
@@ -198,7 +242,11 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS})
PATHS
${PYTHON_FRAMEWORK_INCLUDES}
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/include
+ [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/include
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH}\\InstallPath]/include
+ [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}-${_PYTHON_ARCH2}\\InstallPath]/include
PATH_SUFFIXES
python${_CURRENT_VERSION}mu
python${_CURRENT_VERSION}m
diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake
index 4d8aea92e..d6a06628e 100644
--- a/Modules/FindQt.cmake
+++ b/Modules/FindQt.cmake
@@ -1,37 +1,46 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindQt
-# ------
-#
-# Searches for all installed versions of Qt.
-#
-# This should only be used if your project can work with multiple
-# versions of Qt. If not, you should just directly use FindQt4 or
-# FindQt3. If multiple versions of Qt are found on the machine, then
-# The user must set the option DESIRED_QT_VERSION to the version they
-# want to use. If only one version of qt is found on the machine, then
-# the DESIRED_QT_VERSION is set to that version and the matching FindQt3
-# or FindQt4 module is included. Once the user sets DESIRED_QT_VERSION,
-# then the FindQt3 or FindQt4 module is included.
-#
-# This module can only detect and switch between Qt versions 3 and 4. It
-# cannot handle Qt5 or any later versions.
-#
-# ::
-#
-# QT_REQUIRED if this is set to TRUE then if CMake can
-# not find Qt4 or Qt3 an error is raised
-# and a message is sent to the user.
-#
-#
-#
-# ::
-#
-# DESIRED_QT_VERSION OPTION is created
-# QT4_INSTALLED is set to TRUE if qt4 is found.
-# QT3_INSTALLED is set to TRUE if qt3 is found.
+#[=======================================================================[.rst:
+FindQt
+------
+
+Searches for all installed versions of Qt3 or Qt4.
+
+This module cannot handle Qt5 or any later versions.
+For those, see :manual:`cmake-qt(7)`.
+
+This module exists for the :command:`find_package` command only if
+policy :policy:`CMP0084` is not set to ``NEW``.
+
+This module should only be used if your project can work with multiple
+versions of Qt. If not, you should just directly use FindQt4 or
+FindQt3. If multiple versions of Qt are found on the machine, then
+The user must set the option DESIRED_QT_VERSION to the version they
+want to use. If only one version of qt is found on the machine, then
+the DESIRED_QT_VERSION is set to that version and the matching FindQt3
+or FindQt4 module is included. Once the user sets DESIRED_QT_VERSION,
+then the FindQt3 or FindQt4 module is included.
+
+::
+
+ QT_REQUIRED if this is set to TRUE then if CMake can
+ not find Qt4 or Qt3 an error is raised
+ and a message is sent to the user.
+
+
+
+::
+
+ DESIRED_QT_VERSION OPTION is created
+ QT4_INSTALLED is set to TRUE if qt4 is found.
+ QT3_INSTALLED is set to TRUE if qt3 is found.
+#]=======================================================================]
+
+if(_findqt_testing)
+ set(_findqt_included TRUE)
+ return()
+endif()
# look for signs of qt3 installations
file(GLOB GLOB_TEMP_VAR /usr/lib*/qt-3*/bin/qmake /usr/lib*/qt3*/bin/qmake)
@@ -105,13 +114,11 @@ find_file( QT4_QGLOBAL_H_FILE qglobal.h
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/include/Qt"
${qt_headers}/Qt
$ENV{QTDIR}/include/Qt
- /usr/local/qt/include/Qt
- /usr/local/include/Qt
/usr/lib/qt/include/Qt
- /usr/include/Qt
/usr/share/qt4/include/Qt
/usr/local/include/X11/qt4/Qt
- C:/Progra~1/qt/include/Qt )
+ C:/Progra~1/qt/include/Qt
+ PATH_SUFFIXES qt/include/Qt include/Qt)
if(QT4_QGLOBAL_H_FILE)
set(QT4_INSTALLED TRUE)
@@ -125,14 +132,10 @@ find_file( QT3_QGLOBAL_H_FILE qglobal.h
C:/Qt/3.3.3Educational/include
$ENV{QTDIR}/include
/usr/include/qt3/Qt
- /usr/local/qt/include
- /usr/local/include
- /usr/lib/qt/include
- /usr/include
/usr/share/qt3/include
/usr/local/include/X11/qt3
C:/Progra~1/qt/include
- /usr/include/qt3 )
+ PATH_SUFFIXES qt/include include/qt3)
if(QT3_QGLOBAL_H_FILE)
set(QT3_INSTALLED TRUE)
diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake
index fa9f3a15c..563ed46ec 100644
--- a/Modules/FindQt3.cmake
+++ b/Modules/FindQt3.cmake
@@ -1,37 +1,38 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindQt3
-# -------
-#
-# Locate Qt include paths and libraries
-#
-# This module defines:
-#
-# ::
-#
-# QT_INCLUDE_DIR - where to find qt.h, etc.
-# QT_LIBRARIES - the libraries to link against to use Qt.
-# QT_DEFINITIONS - definitions to use when
-# compiling code that uses Qt.
-# QT_FOUND - If false, don't try to use Qt.
-# QT_VERSION_STRING - the version of Qt found
-#
-#
-#
-# If you need the multithreaded version of Qt, set QT_MT_REQUIRED to
-# TRUE
-#
-# Also defined, but not for general use are:
-#
-# ::
-#
-# QT_MOC_EXECUTABLE, where to find the moc tool.
-# QT_UIC_EXECUTABLE, where to find the uic tool.
-# QT_QT_LIBRARY, where to find the Qt library.
-# QT_QTMAIN_LIBRARY, where to find the qtmain
-# library. This is only required by Qt3 on Windows.
+#[=======================================================================[.rst:
+FindQt3
+-------
+
+Locate Qt include paths and libraries
+
+This module defines:
+
+::
+
+ QT_INCLUDE_DIR - where to find qt.h, etc.
+ QT_LIBRARIES - the libraries to link against to use Qt.
+ QT_DEFINITIONS - definitions to use when
+ compiling code that uses Qt.
+ QT_FOUND - If false, don't try to use Qt.
+ QT_VERSION_STRING - the version of Qt found
+
+
+
+If you need the multithreaded version of Qt, set QT_MT_REQUIRED to
+TRUE
+
+Also defined, but not for general use are:
+
+::
+
+ QT_MOC_EXECUTABLE, where to find the moc tool.
+ QT_UIC_EXECUTABLE, where to find the uic tool.
+ QT_QT_LIBRARY, where to find the Qt library.
+ QT_QTMAIN_LIBRARY, where to find the qtmain
+ library. This is only required by Qt3 on Windows.
+#]=======================================================================]
# These are around for backwards compatibility
# they will be set
@@ -61,14 +62,10 @@ find_path(QT_INCLUDE_DIR qt.h
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt"
$ENV{QTDIR}/include
${GLOB_PATHS}
- /usr/local/qt/include
- /usr/lib/qt/include
- /usr/lib/qt3/include
- /usr/include/qt
/usr/share/qt3/include
C:/Progra~1/qt/include
- /usr/include/qt3
/usr/local/include/X11/qt3
+ PATH_SUFFIXES lib/qt/include lib/qt3/include include/qt include/qt3 qt/include qt3/include
)
# if qglobal.h is not in the qt_include_dir then set
@@ -101,13 +98,10 @@ if (QT_MT_REQUIRED)
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]"
ENV QTDIR
${GLOB_PATHS_LIB}
- /usr/local/qt
- /usr/lib/qt
- /usr/lib/qt3
/usr/share/qt3
C:/Progra~1/qt
PATH_SUFFIXES
- lib
+ lib lib/qt lib/qt3 qt qt3 qt/lib qt3/lib
)
else ()
@@ -122,13 +116,10 @@ else ()
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]"
ENV QTDIR
${GLOB_PATHS_LIB}
- /usr/local/qt
- /usr/lib/qt
- /usr/lib/qt3
/usr/share/qt3
C:/Progra~1/qt/lib
PATH_SUFFIXES
- lib
+ lib lib/qt lib/qt3 qt qt3 qt/lib qt3/lib
)
endif ()
@@ -141,12 +132,10 @@ find_library(QT_QASSISTANTCLIENT_LIBRARY
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]"
ENV QTDIR
${GLOB_PATHS_LIB}
- /usr/local/qt
- /usr/lib/qt3
/usr/share/qt3
C:/Progra~1/qt
PATH_SUFFIXES
- lib
+ lib lib/qt lib/qt3 qt qt3 qt/lib qt3/lib
)
# Qt 3 should prefer QTDIR over the PATH
@@ -159,15 +148,10 @@ find_program(QT_MOC_EXECUTABLE
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt"
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt"
${GLOB_PATHS_BIN}
- /usr/local/lib/qt3
- /usr/local/qt
- /usr/lib/qt
- /usr/lib/qt3
/usr/share/qt3
C:/Progra~1/qt
- /usr/X11R6
PATH_SUFFIXES
- bin
+ bin lib/qt lib/qt3 qt qt3 qt/bin qt3/bin lib/qt/bin lib/qt3/bin
)
if(QT_MOC_EXECUTABLE)
@@ -184,14 +168,10 @@ find_program(QT_UIC_EXECUTABLE
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt"
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt"
${GLOB_PATHS_BIN}
- /usr/local/qt
- /usr/lib/qt
- /usr/lib/qt3
/usr/share/qt3
C:/Progra~1/qt
- /usr/X11R6
PATH_SUFFIXES
- bin
+ bin lib/qt lib/qt3 qt qt3 qt/bin qt3/bin lib/qt/bin lib/qt3/bin
)
if(QT_UIC_EXECUTABLE)
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake
index b0c49e564..399396802 100644
--- a/Modules/FindQt4.cmake
+++ b/Modules/FindQt4.cmake
@@ -1,304 +1,305 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindQt4
-# -------
-#
-# Finding and Using Qt4
-# ^^^^^^^^^^^^^^^^^^^^^
-#
-# This module can be used to find Qt4. The most important issue is that
-# the Qt4 qmake is available via the system path. This qmake is then
-# used to detect basically everything else. This module defines a
-# number of :prop_tgt:`IMPORTED` targets, macros and variables.
-#
-# Typical usage could be something like:
-#
-# .. code-block:: cmake
-#
-# set(CMAKE_AUTOMOC ON)
-# set(CMAKE_INCLUDE_CURRENT_DIR ON)
-# find_package(Qt4 4.4.3 REQUIRED QtGui QtXml)
-# add_executable(myexe main.cpp)
-# target_link_libraries(myexe Qt4::QtGui Qt4::QtXml)
-#
-# .. note::
-#
-# When using :prop_tgt:`IMPORTED` targets, the qtmain.lib static library is
-# automatically linked on Windows for :prop_tgt:`WIN32 <WIN32_EXECUTABLE>`
-# executables. To disable that globally, set the
-# ``QT4_NO_LINK_QTMAIN`` variable before finding Qt4. To disable that
-# for a particular executable, set the ``QT4_NO_LINK_QTMAIN`` target
-# property to ``TRUE`` on the executable.
-#
-# Qt Build Tools
-# ^^^^^^^^^^^^^^
-#
-# Qt relies on some bundled tools for code generation, such as ``moc`` for
-# meta-object code generation,``uic`` for widget layout and population,
-# and ``rcc`` for virtual filesystem content generation. These tools may be
-# automatically invoked by :manual:`cmake(1)` if the appropriate conditions
-# are met. See :manual:`cmake-qt(7)` for more.
-#
-# Qt Macros
-# ^^^^^^^^^
-#
-# In some cases it can be necessary or useful to invoke the Qt build tools in a
-# more-manual way. Several macros are available to add targets for such uses.
-#
-# ::
-#
-# macro QT4_WRAP_CPP(outfiles inputfile ... [TARGET tgt] OPTIONS ...)
-# create moc code from a list of files containing Qt class with
-# the Q_OBJECT declaration. Per-directory preprocessor definitions
-# are also added. If the <tgt> is specified, the
-# INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from
-# the <tgt> are passed to moc. Options may be given to moc, such as
-# those found when executing "moc -help".
-#
-#
-# ::
-#
-# macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...)
-# create code from a list of Qt designer ui files.
-# Options may be given to uic, such as those found
-# when executing "uic -help"
-#
-#
-# ::
-#
-# macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...)
-# create code from a list of Qt resource files.
-# Options may be given to rcc, such as those found
-# when executing "rcc -help"
-#
-#
-# ::
-#
-# macro QT4_GENERATE_MOC(inputfile outputfile [TARGET tgt])
-# creates a rule to run moc on infile and create outfile.
-# Use this if for some reason QT4_WRAP_CPP() isn't appropriate, e.g.
-# because you need a custom filename for the moc file or something
-# similar. If the <tgt> is specified, the
-# INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from
-# the <tgt> are passed to moc.
-#
-#
-# ::
-#
-# macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename)
-# Create the interface header and implementation files with the
-# given basename from the given interface xml file and add it to
-# the list of sources.
-#
-# You can pass additional parameters to the qdbusxml2cpp call by setting
-# properties on the input file:
-#
-# INCLUDE the given file will be included in the generate interface header
-#
-# CLASSNAME the generated class is named accordingly
-#
-# NO_NAMESPACE the generated class is not wrapped in a namespace
-#
-#
-# ::
-#
-# macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
-# Create the interface header and implementation files
-# for all listed interface xml files.
-# The basename will be automatically determined from the name
-# of the xml file.
-#
-# The source file properties described for
-# QT4_ADD_DBUS_INTERFACE also apply here.
-#
-#
-# ::
-#
-# macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname
-# [basename] [classname])
-# create a dbus adaptor (header and implementation file) from the xml file
-# describing the interface, and add it to the list of sources. The adaptor
-# forwards the calls to a parent class, defined in parentheader and named
-# parentclassname. The name of the generated files will be
-# <basename>adaptor.{cpp,h} where basename defaults to the basename of the
-# xml file.
-# If <classname> is provided, then it will be used as the classname of the
-# adaptor itself.
-#
-#
-# ::
-#
-# macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] OPTIONS ...)
-# generate the xml interface file from the given header.
-# If the optional argument interfacename is omitted, the name of the
-# interface file is constructed from the basename of the header with
-# the suffix .xml appended.
-# Options may be given to qdbuscpp2xml, such as those found when
-# executing "qdbuscpp2xml --help"
-#
-#
-# ::
-#
-# macro QT4_CREATE_TRANSLATION( qm_files directories ... sources ...
-# ts_files ... OPTIONS ...)
-# out: qm_files
-# in: directories sources ts_files
-# options: flags to pass to lupdate, such as -extensions to specify
-# extensions for a directory scan.
-# generates commands to create .ts (vie lupdate) and .qm
-# (via lrelease) - files from directories and/or sources. The ts files are
-# created and/or updated in the source tree (unless given with full paths).
-# The qm files are generated in the build tree.
-# Updating the translations can be done by adding the qm_files
-# to the source list of your library/executable, so they are
-# always updated, or by adding a custom target to control when
-# they get updated/generated.
-#
-#
-# ::
-#
-# macro QT4_ADD_TRANSLATION( qm_files ts_files ... )
-# out: qm_files
-# in: ts_files
-# generates commands to create .qm from .ts - files. The generated
-# filenames can be found in qm_files. The ts_files
-# must exist and are not updated in any way.
-#
-#
-# ::
-#
-# macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... [TARGET tgt])
-# The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead.
-# This macro is still experimental.
-# It can be used to have moc automatically handled.
-# So if you have the files foo.h and foo.cpp, and in foo.h a
-# a class uses the Q_OBJECT macro, moc has to run on it. If you don't
-# want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert
-# #include "foo.moc"
-# in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will
-# scan all listed files at cmake-time for such included moc files and if it
-# finds them cause a rule to be generated to run moc at build time on the
-# accompanying header file foo.h.
-# If a source file has the SKIP_AUTOMOC property set it will be ignored by
-# this macro.
-# If the <tgt> is specified, the INTERFACE_INCLUDE_DIRECTORIES and
-# INTERFACE_COMPILE_DEFINITIONS from the <tgt> are passed to moc.
-#
-#
-# ::
-#
-# function QT4_USE_MODULES( target [link_type] modules...)
-# This function is obsolete. Use target_link_libraries with IMPORTED targets
-# instead.
-# Make <target> use the <modules> from Qt. Using a Qt module means
-# to link to the library, add the relevant include directories for the
-# module, and add the relevant compiler defines for using the module.
-# Modules are roughly equivalent to components of Qt4, so usage would be
-# something like:
-# qt4_use_modules(myexe Core Gui Declarative)
-# to use QtCore, QtGui and QtDeclarative. The optional <link_type> argument
-# can be specified as either LINK_PUBLIC or LINK_PRIVATE to specify the
-# same argument to the target_link_libraries call.
-#
-#
-# IMPORTED Targets
-# ^^^^^^^^^^^^^^^^
-#
-# A particular Qt library may be used by using the corresponding
-# :prop_tgt:`IMPORTED` target with the :command:`target_link_libraries`
-# command:
-#
-# .. code-block:: cmake
-#
-# target_link_libraries(myexe Qt4::QtGui Qt4::QtXml)
-#
-# Using a target in this way causes :cmake(1)` to use the appropriate include
-# directories and compile definitions for the target when compiling ``myexe``.
-#
-# Targets are aware of their dependencies, so for example it is not necessary
-# to list ``Qt4::QtCore`` if another Qt library is listed, and it is not
-# necessary to list ``Qt4::QtGui`` if ``Qt4::QtDeclarative`` is listed.
-# Targets may be tested for existence in the usual way with the
-# :command:`if(TARGET)` command.
-#
-# The Qt toolkit may contain both debug and release libraries.
-# :manual:`cmake(1)` will choose the appropriate version based on the build
-# configuration.
-#
-# ``Qt4::QtCore``
-# The QtCore target
-# ``Qt4::QtGui``
-# The QtGui target
-# ``Qt4::Qt3Support``
-# The Qt3Support target
-# ``Qt4::QtAssistant``
-# The QtAssistant target
-# ``Qt4::QtAssistantClient``
-# The QtAssistantClient target
-# ``Qt4::QAxContainer``
-# The QAxContainer target (Windows only)
-# ``Qt4::QAxServer``
-# The QAxServer target (Windows only)
-# ``Qt4::QtDBus``
-# The QtDBus target
-# ``Qt4::QtDeclarative``
-# The QtDeclarative target
-# ``Qt4::QtDesigner``
-# The QtDesigner target
-# ``Qt4::QtDesignerComponents``
-# The QtDesignerComponents target
-# ``Qt4::QtHelp``
-# The QtHelp target
-# ``Qt4::QtMotif``
-# The QtMotif target
-# ``Qt4::QtMultimedia``
-# The QtMultimedia target
-# ``Qt4::QtNetwork``
-# The QtNetwork target
-# ``Qt4::QtNsPLugin``
-# The QtNsPLugin target
-# ``Qt4::QtOpenGL``
-# The QtOpenGL target
-# ``Qt4::QtScript``
-# The QtScript target
-# ``Qt4::QtScriptTools``
-# The QtScriptTools target
-# ``Qt4::QtSql``
-# The QtSql target
-# ``Qt4::QtSvg``
-# The QtSvg target
-# ``Qt4::QtTest``
-# The QtTest target
-# ``Qt4::QtUiTools``
-# The QtUiTools target
-# ``Qt4::QtWebKit``
-# The QtWebKit target
-# ``Qt4::QtXml``
-# The QtXml target
-# ``Qt4::QtXmlPatterns``
-# The QtXmlPatterns target
-# ``Qt4::phonon``
-# The phonon target
-#
-# Result Variables
-# ^^^^^^^^^^^^^^^^
-#
-# Below is a detailed list of variables that FindQt4.cmake sets.
-#
-# ``Qt4_FOUND``
-# If false, don't try to use Qt 4.
-# ``QT_FOUND``
-# If false, don't try to use Qt. This variable is for compatibility only.
-# ``QT4_FOUND``
-# If false, don't try to use Qt 4. This variable is for compatibility only.
-# ``QT_VERSION_MAJOR``
-# The major version of Qt found.
-# ``QT_VERSION_MINOR``
-# The minor version of Qt found.
-# ``QT_VERSION_PATCH``
-# The patch version of Qt found.
+#[=======================================================================[.rst:
+FindQt4
+-------
+
+Finding and Using Qt4
+^^^^^^^^^^^^^^^^^^^^^
+
+This module can be used to find Qt4. The most important issue is that
+the Qt4 qmake is available via the system path. This qmake is then
+used to detect basically everything else. This module defines a
+number of :prop_tgt:`IMPORTED` targets, macros and variables.
+
+Typical usage could be something like:
+
+.. code-block:: cmake
+
+ set(CMAKE_AUTOMOC ON)
+ set(CMAKE_INCLUDE_CURRENT_DIR ON)
+ find_package(Qt4 4.4.3 REQUIRED QtGui QtXml)
+ add_executable(myexe main.cpp)
+ target_link_libraries(myexe Qt4::QtGui Qt4::QtXml)
+
+.. note::
+
+ When using :prop_tgt:`IMPORTED` targets, the qtmain.lib static library is
+ automatically linked on Windows for :prop_tgt:`WIN32 <WIN32_EXECUTABLE>`
+ executables. To disable that globally, set the
+ ``QT4_NO_LINK_QTMAIN`` variable before finding Qt4. To disable that
+ for a particular executable, set the ``QT4_NO_LINK_QTMAIN`` target
+ property to ``TRUE`` on the executable.
+
+Qt Build Tools
+^^^^^^^^^^^^^^
+
+Qt relies on some bundled tools for code generation, such as ``moc`` for
+meta-object code generation,``uic`` for widget layout and population,
+and ``rcc`` for virtual filesystem content generation. These tools may be
+automatically invoked by :manual:`cmake(1)` if the appropriate conditions
+are met. See :manual:`cmake-qt(7)` for more.
+
+Qt Macros
+^^^^^^^^^
+
+In some cases it can be necessary or useful to invoke the Qt build tools in a
+more-manual way. Several macros are available to add targets for such uses.
+
+::
+
+ macro QT4_WRAP_CPP(outfiles inputfile ... [TARGET tgt] OPTIONS ...)
+ create moc code from a list of files containing Qt class with
+ the Q_OBJECT declaration. Per-directory preprocessor definitions
+ are also added. If the <tgt> is specified, the
+ INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from
+ the <tgt> are passed to moc. Options may be given to moc, such as
+ those found when executing "moc -help".
+
+
+::
+
+ macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...)
+ create code from a list of Qt designer ui files.
+ Options may be given to uic, such as those found
+ when executing "uic -help"
+
+
+::
+
+ macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...)
+ create code from a list of Qt resource files.
+ Options may be given to rcc, such as those found
+ when executing "rcc -help"
+
+
+::
+
+ macro QT4_GENERATE_MOC(inputfile outputfile [TARGET tgt])
+ creates a rule to run moc on infile and create outfile.
+ Use this if for some reason QT4_WRAP_CPP() isn't appropriate, e.g.
+ because you need a custom filename for the moc file or something
+ similar. If the <tgt> is specified, the
+ INTERFACE_INCLUDE_DIRECTORIES and INTERFACE_COMPILE_DEFINITIONS from
+ the <tgt> are passed to moc.
+
+
+::
+
+ macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename)
+ Create the interface header and implementation files with the
+ given basename from the given interface xml file and add it to
+ the list of sources.
+
+ You can pass additional parameters to the qdbusxml2cpp call by setting
+ properties on the input file:
+
+ INCLUDE the given file will be included in the generate interface header
+
+ CLASSNAME the generated class is named accordingly
+
+ NO_NAMESPACE the generated class is not wrapped in a namespace
+
+
+::
+
+ macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
+ Create the interface header and implementation files
+ for all listed interface xml files.
+ The basename will be automatically determined from the name
+ of the xml file.
+
+ The source file properties described for
+ QT4_ADD_DBUS_INTERFACE also apply here.
+
+
+::
+
+ macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname
+ [basename] [classname])
+ create a dbus adaptor (header and implementation file) from the xml file
+ describing the interface, and add it to the list of sources. The adaptor
+ forwards the calls to a parent class, defined in parentheader and named
+ parentclassname. The name of the generated files will be
+ <basename>adaptor.{cpp,h} where basename defaults to the basename of the
+ xml file.
+ If <classname> is provided, then it will be used as the classname of the
+ adaptor itself.
+
+
+::
+
+ macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] OPTIONS ...)
+ generate the xml interface file from the given header.
+ If the optional argument interfacename is omitted, the name of the
+ interface file is constructed from the basename of the header with
+ the suffix .xml appended.
+ Options may be given to qdbuscpp2xml, such as those found when
+ executing "qdbuscpp2xml --help"
+
+
+::
+
+ macro QT4_CREATE_TRANSLATION( qm_files directories ... sources ...
+ ts_files ... OPTIONS ...)
+ out: qm_files
+ in: directories sources ts_files
+ options: flags to pass to lupdate, such as -extensions to specify
+ extensions for a directory scan.
+ generates commands to create .ts (vie lupdate) and .qm
+ (via lrelease) - files from directories and/or sources. The ts files are
+ created and/or updated in the source tree (unless given with full paths).
+ The qm files are generated in the build tree.
+ Updating the translations can be done by adding the qm_files
+ to the source list of your library/executable, so they are
+ always updated, or by adding a custom target to control when
+ they get updated/generated.
+
+
+::
+
+ macro QT4_ADD_TRANSLATION( qm_files ts_files ... )
+ out: qm_files
+ in: ts_files
+ generates commands to create .qm from .ts - files. The generated
+ filenames can be found in qm_files. The ts_files
+ must exist and are not updated in any way.
+
+
+::
+
+ macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... [TARGET tgt])
+ The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead.
+ This macro is still experimental.
+ It can be used to have moc automatically handled.
+ So if you have the files foo.h and foo.cpp, and in foo.h a
+ a class uses the Q_OBJECT macro, moc has to run on it. If you don't
+ want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert
+ #include "foo.moc"
+ in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will
+ scan all listed files at cmake-time for such included moc files and if it
+ finds them cause a rule to be generated to run moc at build time on the
+ accompanying header file foo.h.
+ If a source file has the SKIP_AUTOMOC property set it will be ignored by
+ this macro.
+ If the <tgt> is specified, the INTERFACE_INCLUDE_DIRECTORIES and
+ INTERFACE_COMPILE_DEFINITIONS from the <tgt> are passed to moc.
+
+
+::
+
+ function QT4_USE_MODULES( target [link_type] modules...)
+ This function is obsolete. Use target_link_libraries with IMPORTED targets
+ instead.
+ Make <target> use the <modules> from Qt. Using a Qt module means
+ to link to the library, add the relevant include directories for the
+ module, and add the relevant compiler defines for using the module.
+ Modules are roughly equivalent to components of Qt4, so usage would be
+ something like:
+ qt4_use_modules(myexe Core Gui Declarative)
+ to use QtCore, QtGui and QtDeclarative. The optional <link_type> argument
+ can be specified as either LINK_PUBLIC or LINK_PRIVATE to specify the
+ same argument to the target_link_libraries call.
+
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+A particular Qt library may be used by using the corresponding
+:prop_tgt:`IMPORTED` target with the :command:`target_link_libraries`
+command:
+
+.. code-block:: cmake
+
+ target_link_libraries(myexe Qt4::QtGui Qt4::QtXml)
+
+Using a target in this way causes :cmake(1)` to use the appropriate include
+directories and compile definitions for the target when compiling ``myexe``.
+
+Targets are aware of their dependencies, so for example it is not necessary
+to list ``Qt4::QtCore`` if another Qt library is listed, and it is not
+necessary to list ``Qt4::QtGui`` if ``Qt4::QtDeclarative`` is listed.
+Targets may be tested for existence in the usual way with the
+:command:`if(TARGET)` command.
+
+The Qt toolkit may contain both debug and release libraries.
+:manual:`cmake(1)` will choose the appropriate version based on the build
+configuration.
+
+``Qt4::QtCore``
+ The QtCore target
+``Qt4::QtGui``
+ The QtGui target
+``Qt4::Qt3Support``
+ The Qt3Support target
+``Qt4::QtAssistant``
+ The QtAssistant target
+``Qt4::QtAssistantClient``
+ The QtAssistantClient target
+``Qt4::QAxContainer``
+ The QAxContainer target (Windows only)
+``Qt4::QAxServer``
+ The QAxServer target (Windows only)
+``Qt4::QtDBus``
+ The QtDBus target
+``Qt4::QtDeclarative``
+ The QtDeclarative target
+``Qt4::QtDesigner``
+ The QtDesigner target
+``Qt4::QtDesignerComponents``
+ The QtDesignerComponents target
+``Qt4::QtHelp``
+ The QtHelp target
+``Qt4::QtMotif``
+ The QtMotif target
+``Qt4::QtMultimedia``
+ The QtMultimedia target
+``Qt4::QtNetwork``
+ The QtNetwork target
+``Qt4::QtNsPLugin``
+ The QtNsPLugin target
+``Qt4::QtOpenGL``
+ The QtOpenGL target
+``Qt4::QtScript``
+ The QtScript target
+``Qt4::QtScriptTools``
+ The QtScriptTools target
+``Qt4::QtSql``
+ The QtSql target
+``Qt4::QtSvg``
+ The QtSvg target
+``Qt4::QtTest``
+ The QtTest target
+``Qt4::QtUiTools``
+ The QtUiTools target
+``Qt4::QtWebKit``
+ The QtWebKit target
+``Qt4::QtXml``
+ The QtXml target
+``Qt4::QtXmlPatterns``
+ The QtXmlPatterns target
+``Qt4::phonon``
+ The phonon target
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+ Below is a detailed list of variables that FindQt4.cmake sets.
+
+``Qt4_FOUND``
+ If false, don't try to use Qt 4.
+``QT_FOUND``
+ If false, don't try to use Qt. This variable is for compatibility only.
+``QT4_FOUND``
+ If false, don't try to use Qt 4. This variable is for compatibility only.
+``QT_VERSION_MAJOR``
+ The major version of Qt found.
+``QT_VERSION_MINOR``
+ The minor version of Qt found.
+``QT_VERSION_PATCH``
+ The patch version of Qt found.
+#]=======================================================================]
# Use find_package( Qt4 COMPONENTS ... ) to enable modules
if( Qt4_FIND_COMPONENTS )
@@ -355,19 +356,21 @@ macro (_QT4_ADJUST_LIB_VARS _camelCaseBasename)
if (QT_${basename}_LIBRARY_RELEASE)
set_property(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
- if(QT_USE_FRAMEWORKS)
- set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}/${_camelCaseBasename}" )
+ set(_location "${QT_${basename}_LIBRARY_RELEASE}")
+ if(QT_USE_FRAMEWORKS AND EXISTS ${_location}/${_camelCaseBasename})
+ set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${_location}/${_camelCaseBasename}" )
else()
- set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}" )
+ set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${_location}" )
endif()
endif ()
if (QT_${basename}_LIBRARY_DEBUG)
set_property(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
- if(QT_USE_FRAMEWORKS)
- set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}/${_camelCaseBasename}" )
+ set(_location "${QT_${basename}_LIBRARY_DEBUG}")
+ if(QT_USE_FRAMEWORKS AND EXISTS ${_location}/${_camelCaseBasename})
+ set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${_location}/${_camelCaseBasename}" )
else()
- set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}" )
+ set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${_location}" )
endif()
endif ()
set_property(TARGET Qt4::${_camelCaseBasename} PROPERTY
@@ -396,13 +399,14 @@ macro (_QT4_ADJUST_LIB_VARS _camelCaseBasename)
# if the release- as well as the debug-version of the library have been found:
if (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
- # if the generator supports configuration types then set
- # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
- if (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
+ # if the generator is multi-config or if CMAKE_BUILD_TYPE is set for
+ # single-config generators, set optimized and debug libraries
+ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if(_isMultiConfig OR CMAKE_BUILD_TYPE)
set(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
else()
- # if there are no configuration types and CMAKE_BUILD_TYPE has no value
- # then just use the release libraries
+ # For single-config generators where CMAKE_BUILD_TYPE has no value,
+ # just use the release libraries
set(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} )
endif()
set(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
@@ -544,15 +548,11 @@ if (QT_QMAKE_EXECUTABLE AND
if(NOT WIN32)
string(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}")
endif()
- set(qt_cross_paths)
- foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH})
- set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/mkspecs")
- endforeach()
- set(QT_MKSPECS_DIR NOTFOUND)
+
find_path(QT_MKSPECS_DIR NAMES qconfig.pri
- HINTS ${qt_cross_paths} ${qt_mkspecs_dirs}
- DOC "The location of the Qt mkspecs containing qconfig.pri"
- NO_CMAKE_FIND_ROOT_PATH)
+ HINTS ${qt_mkspecs_dirs}
+ PATH_SUFFIXES mkspecs share/qt4/mkspecs
+ DOC "The location of the Qt mkspecs containing qconfig.pri")
endif()
if(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri")
@@ -670,7 +670,7 @@ if (QT_QMAKE_EXECUTABLE AND
get_filename_component(qt_headers "${QT_QTCORE_INCLUDE_DIR}/../" ABSOLUTE)
set(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE)
endif()
- elseif()
+ else()
message("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_HEADERS as ${qt_headers}")
message("Warning: But QtCore couldn't be found. Qt must NOT be installed correctly.")
endif()
@@ -706,14 +706,15 @@ if (QT_QMAKE_EXECUTABLE AND
# ask qmake for the plugins directory
if (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR OR QT_QMAKE_CHANGED)
_qt4_query_qmake(QT_INSTALL_PLUGINS qt_plugins_dir)
- set(QT_PLUGINS_DIR NOTFOUND)
- foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH})
- set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/plugins")
- endforeach()
- find_path(QT_PLUGINS_DIR NAMES accessible imageformats sqldrivers codecs designer
- HINTS ${qt_cross_paths} ${qt_plugins_dir}
- DOC "The location of the Qt plugins"
- NO_CMAKE_FIND_ROOT_PATH)
+ if(CMAKE_CROSSCOMPILING OR NOT qt_plugins_dir)
+ find_path(QT_PLUGINS_DIR
+ NAMES accessible bearer codecs designer graphicssystems iconengines imageformats inputmethods qmltooling script sqldrivers
+ HINTS ${qt_plugins_dir}
+ PATH_SUFFIXES plugins lib/qt4/plugins
+ DOC "The location of the Qt plugins")
+ else()
+ set(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins")
+ endif()
endif ()
# ask qmake for the translations directory
@@ -725,18 +726,13 @@ if (QT_QMAKE_EXECUTABLE AND
# ask qmake for the imports directory
if (QT_LIBRARY_DIR AND NOT QT_IMPORTS_DIR OR QT_QMAKE_CHANGED)
_qt4_query_qmake(QT_INSTALL_IMPORTS qt_imports_dir)
- if(qt_imports_dir)
- set(QT_IMPORTS_DIR NOTFOUND)
- foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH})
- set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/imports")
- endforeach()
+ if(CMAKE_CROSSCOMPILING OR NOT qt_imports_dir)
find_path(QT_IMPORTS_DIR NAMES Qt
- HINTS ${qt_cross_paths} ${qt_imports_dir}
- DOC "The location of the Qt imports"
- NO_CMAKE_FIND_ROOT_PATH
- NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH)
- mark_as_advanced(QT_IMPORTS_DIR)
+ HINTS ${qt_imports_dir}
+ PATH_SUFFIXES imports lib/qt4/imports
+ DOC "The location of the Qt imports")
+ else()
+ set(QT_IMPORTS_DIR ${qt_imports_dir} CACHE PATH "The location of the Qt imports")
endif()
endif ()
diff --git a/Modules/FindQuickTime.cmake b/Modules/FindQuickTime.cmake
index 995d8826b..107486daa 100644
--- a/Modules/FindQuickTime.cmake
+++ b/Modules/FindQuickTime.cmake
@@ -1,20 +1,21 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindQuickTime
-# -------------
-#
-#
-#
-# Locate QuickTime This module defines QUICKTIME_LIBRARY
-# QUICKTIME_FOUND, if false, do not try to link to gdal
-# QUICKTIME_INCLUDE_DIR, where to find the headers
-#
-# $QUICKTIME_DIR is an environment variable that would correspond to the
-# ./configure --prefix=$QUICKTIME_DIR
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindQuickTime
+-------------
+
+
+
+Locate QuickTime This module defines QUICKTIME_LIBRARY
+QUICKTIME_FOUND, if false, do not try to link to gdal
+QUICKTIME_INCLUDE_DIR, where to find the headers
+
+$QUICKTIME_DIR is an environment variable that would correspond to the
+./configure --prefix=$QUICKTIME_DIR
+
+Created by Eric Wing.
+#]=======================================================================]
find_path(QUICKTIME_INCLUDE_DIR QuickTime/QuickTime.h QuickTime.h
HINTS
diff --git a/Modules/FindRTI.cmake b/Modules/FindRTI.cmake
index b2ef0761a..54d2bec9f 100644
--- a/Modules/FindRTI.cmake
+++ b/Modules/FindRTI.cmake
@@ -1,37 +1,38 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindRTI
-# -------
-#
-# Try to find M&S HLA RTI libraries
-#
-# This module finds if any HLA RTI is installed and locates the standard
-# RTI include files and libraries.
-#
-# RTI is a simulation infrastructure standardized by IEEE and SISO. It
-# has a well defined C++ API that assures that simulation applications
-# are independent on a particular RTI implementation.
-#
-# ::
-#
-# http://en.wikipedia.org/wiki/Run-Time_Infrastructure_(simulation)
-#
-#
-#
-# This code sets the following variables:
-#
-# ::
-#
-# RTI_INCLUDE_DIR = the directory where RTI includes file are found
-# RTI_LIBRARIES = The libraries to link against to use RTI
-# RTI_DEFINITIONS = -DRTI_USES_STD_FSTREAM
-# RTI_FOUND = Set to FALSE if any HLA RTI was not found
-#
-#
-#
-# Report problems to <certi-devel@nongnu.org>
+#[=======================================================================[.rst:
+FindRTI
+-------
+
+Try to find M&S HLA RTI libraries
+
+This module finds if any HLA RTI is installed and locates the standard
+RTI include files and libraries.
+
+RTI is a simulation infrastructure standardized by IEEE and SISO. It
+has a well defined C++ API that assures that simulation applications
+are independent on a particular RTI implementation.
+
+::
+
+ http://en.wikipedia.org/wiki/Run-Time_Infrastructure_(simulation)
+
+
+
+This code sets the following variables:
+
+::
+
+ RTI_INCLUDE_DIR = the directory where RTI includes file are found
+ RTI_LIBRARIES = The libraries to link against to use RTI
+ RTI_DEFINITIONS = -DRTI_USES_STD_FSTREAM
+ RTI_FOUND = Set to FALSE if any HLA RTI was not found
+
+
+
+Report problems to <certi-devel@nongnu.org>
+#]=======================================================================]
macro(RTI_MESSAGE_QUIETLY QUIET TYPE MSG)
if(NOT ${QUIET})
diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake
index a9f8d3545..7e01fbc98 100644
--- a/Modules/FindRuby.cmake
+++ b/Modules/FindRuby.cmake
@@ -1,37 +1,38 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindRuby
-# --------
-#
-# Find Ruby
-#
-# This module finds if Ruby is installed and determines where the
-# include files and libraries are. Ruby 1.8, 1.9, 2.0 and 2.1 are
-# supported.
-#
-# The minimum required version of Ruby can be specified using the
-# standard syntax, e.g. find_package(Ruby 1.8)
-#
-# It also determines what the name of the library is. This code sets
-# the following variables:
-#
-# ``RUBY_EXECUTABLE``
-# full path to the ruby binary
-# ``RUBY_INCLUDE_DIRS``
-# include dirs to be used when using the ruby library
-# ``RUBY_LIBRARY``
-# full path to the ruby library
-# ``RUBY_VERSION``
-# the version of ruby which was found, e.g. "1.8.7"
-# ``RUBY_FOUND``
-# set to true if ruby ws found successfully
-#
-# Also:
-#
-# ``RUBY_INCLUDE_PATH``
-# same as RUBY_INCLUDE_DIRS, only provided for compatibility reasons, don't use it
+#[=======================================================================[.rst:
+FindRuby
+--------
+
+Find Ruby
+
+This module finds if Ruby is installed and determines where the
+include files and libraries are. Ruby 1.8, 1.9, 2.0 and 2.1 are
+supported.
+
+The minimum required version of Ruby can be specified using the
+standard syntax, e.g. find_package(Ruby 1.8)
+
+It also determines what the name of the library is. This code sets
+the following variables:
+
+``RUBY_EXECUTABLE``
+ full path to the ruby binary
+``RUBY_INCLUDE_DIRS``
+ include dirs to be used when using the ruby library
+``RUBY_LIBRARY``
+ full path to the ruby library
+``RUBY_VERSION``
+ the version of ruby which was found, e.g. "1.8.7"
+``RUBY_FOUND``
+ set to true if ruby ws found successfully
+
+Also:
+
+``RUBY_INCLUDE_PATH``
+ same as RUBY_INCLUDE_DIRS, only provided for compatibility reasons, don't use it
+#]=======================================================================]
# RUBY_ARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"archdir"@:>@)'`
# RUBY_SITEARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitearchdir"@:>@)'`
@@ -48,17 +49,20 @@ set(_RUBY_POSSIBLE_EXECUTABLE_NAMES ruby)
# if 1.9 is required, don't look for ruby18 and ruby1.8, default to version 1.8
if(DEFINED Ruby_FIND_VERSION_MAJOR AND DEFINED Ruby_FIND_VERSION_MINOR)
- set(Ruby_FIND_VERSION_SHORT_NODOT "${Ruby_FIND_VERSION_MAJOR}${RUBY_FIND_VERSION_MINOR}")
- # we can't construct that if only major version is given
- set(_RUBY_POSSIBLE_EXECUTABLE_NAMES
- ruby${Ruby_FIND_VERSION_MAJOR}.${Ruby_FIND_VERSION_MINOR}
- ruby${Ruby_FIND_VERSION_MAJOR}${Ruby_FIND_VERSION_MINOR}
- ${_RUBY_POSSIBLE_EXECUTABLE_NAMES})
+ set(Ruby_FIND_VERSION_SHORT_NODOT "${Ruby_FIND_VERSION_MAJOR}${RUBY_FIND_VERSION_MINOR}")
+ # we can't construct that if only major version is given
+ set(_RUBY_POSSIBLE_EXECUTABLE_NAMES
+ ruby${Ruby_FIND_VERSION_MAJOR}.${Ruby_FIND_VERSION_MINOR}
+ ruby${Ruby_FIND_VERSION_MAJOR}${Ruby_FIND_VERSION_MINOR}
+ ${_RUBY_POSSIBLE_EXECUTABLE_NAMES})
else()
- set(Ruby_FIND_VERSION_SHORT_NODOT "18")
+ set(Ruby_FIND_VERSION_SHORT_NODOT "18")
endif()
if(NOT Ruby_FIND_VERSION_EXACT)
+ list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.4 ruby24)
+ list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.3 ruby23)
+ list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.2 ruby22)
list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.1 ruby21)
list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.0 ruby20)
list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby1.9 ruby19)
@@ -90,115 +94,131 @@ if(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR)
# query the ruby version
- _RUBY_CONFIG_VAR("MAJOR" RUBY_VERSION_MAJOR)
- _RUBY_CONFIG_VAR("MINOR" RUBY_VERSION_MINOR)
- _RUBY_CONFIG_VAR("TEENY" RUBY_VERSION_PATCH)
-
- # query the different directories
- _RUBY_CONFIG_VAR("archdir" RUBY_ARCH_DIR)
- _RUBY_CONFIG_VAR("arch" RUBY_ARCH)
- _RUBY_CONFIG_VAR("rubyhdrdir" RUBY_HDR_DIR)
- _RUBY_CONFIG_VAR("rubyarchhdrdir" RUBY_ARCHHDR_DIR)
- _RUBY_CONFIG_VAR("libdir" RUBY_POSSIBLE_LIB_DIR)
- _RUBY_CONFIG_VAR("rubylibdir" RUBY_RUBY_LIB_DIR)
-
- # site_ruby
- _RUBY_CONFIG_VAR("sitearchdir" RUBY_SITEARCH_DIR)
- _RUBY_CONFIG_VAR("sitelibdir" RUBY_SITELIB_DIR)
-
- # vendor_ruby available ?
- execute_process(COMMAND ${RUBY_EXECUTABLE} -r vendor-specific -e "print 'true'"
- OUTPUT_VARIABLE RUBY_HAS_VENDOR_RUBY ERROR_QUIET)
-
- if(RUBY_HAS_VENDOR_RUBY)
- _RUBY_CONFIG_VAR("vendorlibdir" RUBY_VENDORLIB_DIR)
- _RUBY_CONFIG_VAR("vendorarchdir" RUBY_VENDORARCH_DIR)
- endif()
-
- # save the results in the cache so we don't have to run ruby the next time again
- set(RUBY_VERSION_MAJOR ${RUBY_VERSION_MAJOR} CACHE PATH "The Ruby major version" FORCE)
- set(RUBY_VERSION_MINOR ${RUBY_VERSION_MINOR} CACHE PATH "The Ruby minor version" FORCE)
- set(RUBY_VERSION_PATCH ${RUBY_VERSION_PATCH} CACHE PATH "The Ruby patch version" FORCE)
- set(RUBY_ARCH_DIR ${RUBY_ARCH_DIR} CACHE PATH "The Ruby arch dir" FORCE)
- set(RUBY_HDR_DIR ${RUBY_HDR_DIR} CACHE PATH "The Ruby header dir (1.9+)" FORCE)
- set(RUBY_ARCHHDR_DIR ${RUBY_ARCHHDR_DIR} CACHE PATH "The Ruby arch header dir (2.0+)" FORCE)
- set(RUBY_POSSIBLE_LIB_DIR ${RUBY_POSSIBLE_LIB_DIR} CACHE PATH "The Ruby lib dir" FORCE)
- set(RUBY_RUBY_LIB_DIR ${RUBY_RUBY_LIB_DIR} CACHE PATH "The Ruby ruby-lib dir" FORCE)
- set(RUBY_SITEARCH_DIR ${RUBY_SITEARCH_DIR} CACHE PATH "The Ruby site arch dir" FORCE)
- set(RUBY_SITELIB_DIR ${RUBY_SITELIB_DIR} CACHE PATH "The Ruby site lib dir" FORCE)
- set(RUBY_HAS_VENDOR_RUBY ${RUBY_HAS_VENDOR_RUBY} CACHE BOOL "Vendor Ruby is available" FORCE)
- set(RUBY_VENDORARCH_DIR ${RUBY_VENDORARCH_DIR} CACHE PATH "The Ruby vendor arch dir" FORCE)
- set(RUBY_VENDORLIB_DIR ${RUBY_VENDORLIB_DIR} CACHE PATH "The Ruby vendor lib dir" FORCE)
-
- mark_as_advanced(
- RUBY_ARCH_DIR
- RUBY_ARCH
- RUBY_HDR_DIR
- RUBY_ARCHHDR_DIR
- RUBY_POSSIBLE_LIB_DIR
- RUBY_RUBY_LIB_DIR
- RUBY_SITEARCH_DIR
- RUBY_SITELIB_DIR
- RUBY_HAS_VENDOR_RUBY
- RUBY_VENDORARCH_DIR
- RUBY_VENDORLIB_DIR
- RUBY_VERSION_MAJOR
- RUBY_VERSION_MINOR
- RUBY_VERSION_PATCH
- )
+ _RUBY_CONFIG_VAR("MAJOR" RUBY_VERSION_MAJOR)
+ _RUBY_CONFIG_VAR("MINOR" RUBY_VERSION_MINOR)
+ _RUBY_CONFIG_VAR("TEENY" RUBY_VERSION_PATCH)
+
+ # query the different directories
+ _RUBY_CONFIG_VAR("archdir" RUBY_ARCH_DIR)
+ _RUBY_CONFIG_VAR("arch" RUBY_ARCH)
+ _RUBY_CONFIG_VAR("rubyhdrdir" RUBY_HDR_DIR)
+ _RUBY_CONFIG_VAR("rubyarchhdrdir" RUBY_ARCHHDR_DIR)
+ _RUBY_CONFIG_VAR("libdir" RUBY_POSSIBLE_LIB_DIR)
+ _RUBY_CONFIG_VAR("rubylibdir" RUBY_RUBY_LIB_DIR)
+
+ # site_ruby
+ _RUBY_CONFIG_VAR("sitearchdir" RUBY_SITEARCH_DIR)
+ _RUBY_CONFIG_VAR("sitelibdir" RUBY_SITELIB_DIR)
+
+ # vendor_ruby available ?
+ execute_process(COMMAND ${RUBY_EXECUTABLE} -r vendor-specific -e "print 'true'"
+ OUTPUT_VARIABLE RUBY_HAS_VENDOR_RUBY ERROR_QUIET)
+
+ if(RUBY_HAS_VENDOR_RUBY)
+ _RUBY_CONFIG_VAR("vendorlibdir" RUBY_VENDORLIB_DIR)
+ _RUBY_CONFIG_VAR("vendorarchdir" RUBY_VENDORARCH_DIR)
+ endif()
+
+ # save the results in the cache so we don't have to run ruby the next time again
+ set(RUBY_VERSION_MAJOR ${RUBY_VERSION_MAJOR} CACHE PATH "The Ruby major version" FORCE)
+ set(RUBY_VERSION_MINOR ${RUBY_VERSION_MINOR} CACHE PATH "The Ruby minor version" FORCE)
+ set(RUBY_VERSION_PATCH ${RUBY_VERSION_PATCH} CACHE PATH "The Ruby patch version" FORCE)
+ set(RUBY_ARCH_DIR ${RUBY_ARCH_DIR} CACHE PATH "The Ruby arch dir" FORCE)
+ set(RUBY_HDR_DIR ${RUBY_HDR_DIR} CACHE PATH "The Ruby header dir (1.9+)" FORCE)
+ set(RUBY_ARCHHDR_DIR ${RUBY_ARCHHDR_DIR} CACHE PATH "The Ruby arch header dir (2.0+)" FORCE)
+ set(RUBY_POSSIBLE_LIB_DIR ${RUBY_POSSIBLE_LIB_DIR} CACHE PATH "The Ruby lib dir" FORCE)
+ set(RUBY_RUBY_LIB_DIR ${RUBY_RUBY_LIB_DIR} CACHE PATH "The Ruby ruby-lib dir" FORCE)
+ set(RUBY_SITEARCH_DIR ${RUBY_SITEARCH_DIR} CACHE PATH "The Ruby site arch dir" FORCE)
+ set(RUBY_SITELIB_DIR ${RUBY_SITELIB_DIR} CACHE PATH "The Ruby site lib dir" FORCE)
+ set(RUBY_HAS_VENDOR_RUBY ${RUBY_HAS_VENDOR_RUBY} CACHE BOOL "Vendor Ruby is available" FORCE)
+ set(RUBY_VENDORARCH_DIR ${RUBY_VENDORARCH_DIR} CACHE PATH "The Ruby vendor arch dir" FORCE)
+ set(RUBY_VENDORLIB_DIR ${RUBY_VENDORLIB_DIR} CACHE PATH "The Ruby vendor lib dir" FORCE)
+
+ mark_as_advanced(
+ RUBY_ARCH_DIR
+ RUBY_ARCH
+ RUBY_HDR_DIR
+ RUBY_ARCHHDR_DIR
+ RUBY_POSSIBLE_LIB_DIR
+ RUBY_RUBY_LIB_DIR
+ RUBY_SITEARCH_DIR
+ RUBY_SITELIB_DIR
+ RUBY_HAS_VENDOR_RUBY
+ RUBY_VENDORARCH_DIR
+ RUBY_VENDORLIB_DIR
+ RUBY_VERSION_MAJOR
+ RUBY_VERSION_MINOR
+ RUBY_VERSION_PATCH
+ )
endif()
# In case RUBY_EXECUTABLE could not be executed (e.g. cross compiling)
# try to detect which version we found. This is not too good.
if(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR)
- # by default assume 1.8.0
- set(RUBY_VERSION_MAJOR 1)
- set(RUBY_VERSION_MINOR 8)
- set(RUBY_VERSION_PATCH 0)
- # check whether we found 1.9.x
- if(${RUBY_EXECUTABLE} MATCHES "ruby1.?9")
- set(RUBY_VERSION_MAJOR 1)
- set(RUBY_VERSION_MINOR 9)
- endif()
- # check whether we found 2.0.x
- if(${RUBY_EXECUTABLE} MATCHES "ruby2.?0")
- set(RUBY_VERSION_MAJOR 2)
- set(RUBY_VERSION_MINOR 0)
- endif()
- # check whether we found 2.1.x
- if(${RUBY_EXECUTABLE} MATCHES "ruby2.?1")
- set(RUBY_VERSION_MAJOR 2)
- set(RUBY_VERSION_MINOR 1)
- endif()
+ # by default assume 1.8.0
+ set(RUBY_VERSION_MAJOR 1)
+ set(RUBY_VERSION_MINOR 8)
+ set(RUBY_VERSION_PATCH 0)
+ # check whether we found 1.9.x
+ if(${RUBY_EXECUTABLE} MATCHES "ruby1\\.?9")
+ set(RUBY_VERSION_MAJOR 1)
+ set(RUBY_VERSION_MINOR 9)
+ endif()
+ # check whether we found 2.0.x
+ if(${RUBY_EXECUTABLE} MATCHES "ruby2\\.?0")
+ set(RUBY_VERSION_MAJOR 2)
+ set(RUBY_VERSION_MINOR 0)
+ endif()
+ # check whether we found 2.1.x
+ if(${RUBY_EXECUTABLE} MATCHES "ruby2\\.?1")
+ set(RUBY_VERSION_MAJOR 2)
+ set(RUBY_VERSION_MINOR 1)
+ endif()
+ # check whether we found 2.2.x
+ if(${RUBY_EXECUTABLE} MATCHES "ruby2\\.?2")
+ set(RUBY_VERSION_MAJOR 2)
+ set(RUBY_VERSION_MINOR 2)
+ endif()
+ # check whether we found 2.3.x
+ if(${RUBY_EXECUTABLE} MATCHES "ruby2\\.?3")
+ set(RUBY_VERSION_MAJOR 2)
+ set(RUBY_VERSION_MINOR 3)
+ endif()
+ # check whether we found 2.4.x
+ if(${RUBY_EXECUTABLE} MATCHES "ruby2\\.?4")
+ set(RUBY_VERSION_MAJOR 2)
+ set(RUBY_VERSION_MINOR 4)
+ endif()
endif()
if(RUBY_VERSION_MAJOR)
- set(RUBY_VERSION "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.${RUBY_VERSION_PATCH}")
- set(_RUBY_VERSION_SHORT "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}")
- set(_RUBY_VERSION_SHORT_NODOT "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}")
- set(_RUBY_NODOT_VERSION "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}${RUBY_VERSION_PATCH}")
+ set(RUBY_VERSION "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.${RUBY_VERSION_PATCH}")
+ set(_RUBY_VERSION_SHORT "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}")
+ set(_RUBY_VERSION_SHORT_NODOT "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}")
+ set(_RUBY_NODOT_VERSION "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}${RUBY_VERSION_PATCH}")
endif()
find_path(RUBY_INCLUDE_DIR
- NAMES ruby.h
- HINTS
- ${RUBY_HDR_DIR}
- ${RUBY_ARCH_DIR}
- /usr/lib/ruby/${_RUBY_VERSION_SHORT}/i586-linux-gnu/ )
+ NAMES ruby.h
+ HINTS
+ ${RUBY_HDR_DIR}
+ ${RUBY_ARCH_DIR}
+ /usr/lib/ruby/${_RUBY_VERSION_SHORT}/i586-linux-gnu/
+)
set(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIR} )
# if ruby > 1.8 is required or if ruby > 1.8 was found, search for the config.h dir
if( "${Ruby_FIND_VERSION_SHORT_NODOT}" GREATER 18 OR "${_RUBY_VERSION_SHORT_NODOT}" GREATER 18 OR RUBY_HDR_DIR)
- find_path(RUBY_CONFIG_INCLUDE_DIR
- NAMES ruby/config.h config.h
- HINTS
- ${RUBY_HDR_DIR}/${RUBY_ARCH}
- ${RUBY_ARCH_DIR}
- ${RUBY_ARCHHDR_DIR}
- )
-
- set(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIRS} ${RUBY_CONFIG_INCLUDE_DIR} )
+ find_path(RUBY_CONFIG_INCLUDE_DIR
+ NAMES ruby/config.h config.h
+ HINTS
+ ${RUBY_HDR_DIR}/${RUBY_ARCH}
+ ${RUBY_ARCH_DIR}
+ ${RUBY_ARCHHDR_DIR}
+ )
+
+ set(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIRS} ${RUBY_CONFIG_INCLUDE_DIR} )
endif()
@@ -206,33 +226,33 @@ endif()
set(_RUBY_POSSIBLE_LIB_NAMES ruby ruby-static ruby${_RUBY_VERSION_SHORT} ruby${_RUBY_VERSION_SHORT_NODOT} ruby-${_RUBY_VERSION_SHORT} ruby-${RUBY_VERSION})
if(WIN32)
- set( _RUBY_MSVC_RUNTIME "" )
- if( MSVC_VERSION EQUAL 1200 )
- set( _RUBY_MSVC_RUNTIME "60" )
- endif()
- if( MSVC_VERSION EQUAL 1300 )
- set( _RUBY_MSVC_RUNTIME "70" )
- endif()
- if( MSVC_VERSION EQUAL 1310 )
- set( _RUBY_MSVC_RUNTIME "71" )
- endif()
- if( MSVC_VERSION EQUAL 1400 )
- set( _RUBY_MSVC_RUNTIME "80" )
- endif()
- if( MSVC_VERSION EQUAL 1500 )
- set( _RUBY_MSVC_RUNTIME "90" )
- endif()
-
- set(_RUBY_ARCH_PREFIX "")
- if(CMAKE_SIZEOF_VOID_P EQUAL 8)
- set(_RUBY_ARCH_PREFIX "x64-")
- endif()
-
- list(APPEND _RUBY_POSSIBLE_LIB_NAMES
- "${_RUBY_ARCH_PREFIX}msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}"
- "${_RUBY_ARCH_PREFIX}msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}-static"
- "${_RUBY_ARCH_PREFIX}msvcrt-ruby${_RUBY_NODOT_VERSION}"
- "${_RUBY_ARCH_PREFIX}msvcrt-ruby${_RUBY_NODOT_VERSION}-static" )
+ set( _RUBY_MSVC_RUNTIME "" )
+ if( MSVC_VERSION EQUAL 1200 )
+ set( _RUBY_MSVC_RUNTIME "60" )
+ endif()
+ if( MSVC_VERSION EQUAL 1300 )
+ set( _RUBY_MSVC_RUNTIME "70" )
+ endif()
+ if( MSVC_VERSION EQUAL 1310 )
+ set( _RUBY_MSVC_RUNTIME "71" )
+ endif()
+ if( MSVC_VERSION EQUAL 1400 )
+ set( _RUBY_MSVC_RUNTIME "80" )
+ endif()
+ if( MSVC_VERSION EQUAL 1500 )
+ set( _RUBY_MSVC_RUNTIME "90" )
+ endif()
+
+ set(_RUBY_ARCH_PREFIX "")
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(_RUBY_ARCH_PREFIX "x64-")
+ endif()
+
+ list(APPEND _RUBY_POSSIBLE_LIB_NAMES
+ "${_RUBY_ARCH_PREFIX}msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}"
+ "${_RUBY_ARCH_PREFIX}msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}-static"
+ "${_RUBY_ARCH_PREFIX}msvcrt-ruby${_RUBY_NODOT_VERSION}"
+ "${_RUBY_ARCH_PREFIX}msvcrt-ruby${_RUBY_NODOT_VERSION}-static" )
endif()
find_library(RUBY_LIBRARY NAMES ${_RUBY_POSSIBLE_LIB_NAMES} HINTS ${RUBY_POSSIBLE_LIB_DIR} )
@@ -240,23 +260,23 @@ find_library(RUBY_LIBRARY NAMES ${_RUBY_POSSIBLE_LIB_NAMES} HINTS ${RUBY_POSSIBL
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
set(_RUBY_REQUIRED_VARS RUBY_EXECUTABLE RUBY_INCLUDE_DIR RUBY_LIBRARY)
if(_RUBY_VERSION_SHORT_NODOT GREATER 18)
- list(APPEND _RUBY_REQUIRED_VARS RUBY_CONFIG_INCLUDE_DIR)
+ list(APPEND _RUBY_REQUIRED_VARS RUBY_CONFIG_INCLUDE_DIR)
endif()
if(_RUBY_DEBUG_OUTPUT)
- message(STATUS "--------FindRuby.cmake debug------------")
- message(STATUS "_RUBY_POSSIBLE_EXECUTABLE_NAMES: ${_RUBY_POSSIBLE_EXECUTABLE_NAMES}")
- message(STATUS "_RUBY_POSSIBLE_LIB_NAMES: ${_RUBY_POSSIBLE_LIB_NAMES}")
- message(STATUS "RUBY_ARCH_DIR: ${RUBY_ARCH_DIR}")
- message(STATUS "RUBY_HDR_DIR: ${RUBY_HDR_DIR}")
- message(STATUS "RUBY_POSSIBLE_LIB_DIR: ${RUBY_POSSIBLE_LIB_DIR}")
- message(STATUS "Found RUBY_VERSION: \"${RUBY_VERSION}\" , short: \"${_RUBY_VERSION_SHORT}\", nodot: \"${_RUBY_VERSION_SHORT_NODOT}\"")
- message(STATUS "_RUBY_REQUIRED_VARS: ${_RUBY_REQUIRED_VARS}")
- message(STATUS "RUBY_EXECUTABLE: ${RUBY_EXECUTABLE}")
- message(STATUS "RUBY_LIBRARY: ${RUBY_LIBRARY}")
- message(STATUS "RUBY_INCLUDE_DIR: ${RUBY_INCLUDE_DIR}")
- message(STATUS "RUBY_CONFIG_INCLUDE_DIR: ${RUBY_CONFIG_INCLUDE_DIR}")
- message(STATUS "--------------------")
+ message(STATUS "--------FindRuby.cmake debug------------")
+ message(STATUS "_RUBY_POSSIBLE_EXECUTABLE_NAMES: ${_RUBY_POSSIBLE_EXECUTABLE_NAMES}")
+ message(STATUS "_RUBY_POSSIBLE_LIB_NAMES: ${_RUBY_POSSIBLE_LIB_NAMES}")
+ message(STATUS "RUBY_ARCH_DIR: ${RUBY_ARCH_DIR}")
+ message(STATUS "RUBY_HDR_DIR: ${RUBY_HDR_DIR}")
+ message(STATUS "RUBY_POSSIBLE_LIB_DIR: ${RUBY_POSSIBLE_LIB_DIR}")
+ message(STATUS "Found RUBY_VERSION: \"${RUBY_VERSION}\" , short: \"${_RUBY_VERSION_SHORT}\", nodot: \"${_RUBY_VERSION_SHORT_NODOT}\"")
+ message(STATUS "_RUBY_REQUIRED_VARS: ${_RUBY_REQUIRED_VARS}")
+ message(STATUS "RUBY_EXECUTABLE: ${RUBY_EXECUTABLE}")
+ message(STATUS "RUBY_LIBRARY: ${RUBY_LIBRARY}")
+ message(STATUS "RUBY_INCLUDE_DIR: ${RUBY_INCLUDE_DIR}")
+ message(STATUS "RUBY_CONFIG_INCLUDE_DIR: ${RUBY_CONFIG_INCLUDE_DIR}")
+ message(STATUS "--------------------")
endif()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ruby REQUIRED_VARS ${_RUBY_REQUIRED_VARS}
diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake
index 341001897..8d793a975 100644
--- a/Modules/FindSDL.cmake
+++ b/Modules/FindSDL.cmake
@@ -1,75 +1,76 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindSDL
-# -------
-#
-# Locate SDL library
-#
-# This module defines
-#
-# ::
-#
-# SDL_LIBRARY, the name of the library to link against
-# SDL_FOUND, if false, do not try to link to SDL
-# SDL_INCLUDE_DIR, where to find SDL.h
-# SDL_VERSION_STRING, human-readable string containing the version of SDL
-#
-#
-#
-# This module responds to the flag:
-#
-# ::
-#
-# SDL_BUILDING_LIBRARY
-# If this is defined, then no SDL_main will be linked in because
-# only applications need main().
-# Otherwise, it is assumed you are building an application and this
-# module will attempt to locate and set the proper link flags
-# as part of the returned SDL_LIBRARY variable.
-#
-#
-#
-# Don't forget to include SDLmain.h and SDLmain.m your project for the
-# OS X framework based version. (Other versions link to -lSDLmain which
-# this module will try to find on your behalf.) Also for OS X, this
-# module will automatically add the -framework Cocoa on your behalf.
-#
-#
-#
-# Additional Note: If you see an empty SDL_LIBRARY_TEMP in your
-# configuration and no SDL_LIBRARY, it means CMake did not find your SDL
-# library (SDL.dll, libsdl.so, SDL.framework, etc). Set
-# SDL_LIBRARY_TEMP to point to your SDL library, and configure again.
-# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this
-# value as appropriate. These values are used to generate the final
-# SDL_LIBRARY variable, but when these values are unset, SDL_LIBRARY
-# does not get created.
-#
-#
-#
-# $SDLDIR is an environment variable that would correspond to the
-# ./configure --prefix=$SDLDIR used in building SDL. l.e.galup 9-20-02
-#
-# Modified by Eric Wing. Added code to assist with automated building
-# by using environmental variables and providing a more
-# controlled/consistent search behavior. Added new modifications to
-# recognize OS X frameworks and additional Unix paths (FreeBSD, etc).
-# Also corrected the header search path to follow "proper" SDL
-# guidelines. Added a search for SDLmain which is needed by some
-# platforms. Added a search for threads which is needed by some
-# platforms. Added needed compile switches for MinGW.
-#
-# On OSX, this will prefer the Framework version (if found) over others.
-# People will have to manually change the cache values of SDL_LIBRARY to
-# override this selection or set the CMake environment
-# CMAKE_INCLUDE_PATH to modify the search paths.
-#
-# Note that the header path has changed from SDL/SDL.h to just SDL.h
-# This needed to change because "proper" SDL convention is #include
-# "SDL.h", not <SDL/SDL.h>. This is done for portability reasons
-# because not all systems place things in SDL/ (see FreeBSD).
+#[=======================================================================[.rst:
+FindSDL
+-------
+
+Locate SDL library
+
+This module defines
+
+::
+
+ SDL_LIBRARY, the name of the library to link against
+ SDL_FOUND, if false, do not try to link to SDL
+ SDL_INCLUDE_DIR, where to find SDL.h
+ SDL_VERSION_STRING, human-readable string containing the version of SDL
+
+
+
+This module responds to the flag:
+
+::
+
+ SDL_BUILDING_LIBRARY
+ If this is defined, then no SDL_main will be linked in because
+ only applications need main().
+ Otherwise, it is assumed you are building an application and this
+ module will attempt to locate and set the proper link flags
+ as part of the returned SDL_LIBRARY variable.
+
+
+
+Don't forget to include SDLmain.h and SDLmain.m your project for the
+OS X framework based version. (Other versions link to -lSDLmain which
+this module will try to find on your behalf.) Also for OS X, this
+module will automatically add the -framework Cocoa on your behalf.
+
+
+
+Additional Note: If you see an empty SDL_LIBRARY_TEMP in your
+configuration and no SDL_LIBRARY, it means CMake did not find your SDL
+library (SDL.dll, libsdl.so, SDL.framework, etc). Set
+SDL_LIBRARY_TEMP to point to your SDL library, and configure again.
+Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this
+value as appropriate. These values are used to generate the final
+SDL_LIBRARY variable, but when these values are unset, SDL_LIBRARY
+does not get created.
+
+
+
+$SDLDIR is an environment variable that would correspond to the
+./configure --prefix=$SDLDIR used in building SDL. l.e.galup 9-20-02
+
+Modified by Eric Wing. Added code to assist with automated building
+by using environmental variables and providing a more
+controlled/consistent search behavior. Added new modifications to
+recognize OS X frameworks and additional Unix paths (FreeBSD, etc).
+Also corrected the header search path to follow "proper" SDL
+guidelines. Added a search for SDLmain which is needed by some
+platforms. Added a search for threads which is needed by some
+platforms. Added needed compile switches for MinGW.
+
+On OSX, this will prefer the Framework version (if found) over others.
+People will have to manually change the cache values of SDL_LIBRARY to
+override this selection or set the CMake environment
+CMAKE_INCLUDE_PATH to modify the search paths.
+
+Note that the header path has changed from SDL/SDL.h to just SDL.h
+This needed to change because "proper" SDL convention is #include
+"SDL.h", not <SDL/SDL.h>. This is done for portability reasons
+because not all systems place things in SDL/ (see FreeBSD).
+#]=======================================================================]
find_path(SDL_INCLUDE_DIR SDL.h
HINTS
@@ -111,9 +112,6 @@ if(NOT SDL_BUILDING_LIBRARY)
ENV SDLDIR
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
PATHS
- /sw
- /opt/local
- /opt/csw
/opt
)
endif()
diff --git a/Modules/FindSDL_image.cmake b/Modules/FindSDL_image.cmake
index 8cdaa7a05..e687b4983 100644
--- a/Modules/FindSDL_image.cmake
+++ b/Modules/FindSDL_image.cmake
@@ -1,40 +1,41 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindSDL_image
-# -------------
-#
-# Locate SDL_image library
-#
-# This module defines:
-#
-# ::
-#
-# SDL_IMAGE_LIBRARIES, the name of the library to link against
-# SDL_IMAGE_INCLUDE_DIRS, where to find the headers
-# SDL_IMAGE_FOUND, if false, do not try to link against
-# SDL_IMAGE_VERSION_STRING - human-readable string containing the
-# version of SDL_image
-#
-#
-#
-# For backward compatibility the following variables are also set:
-#
-# ::
-#
-# SDLIMAGE_LIBRARY (same value as SDL_IMAGE_LIBRARIES)
-# SDLIMAGE_INCLUDE_DIR (same value as SDL_IMAGE_INCLUDE_DIRS)
-# SDLIMAGE_FOUND (same value as SDL_IMAGE_FOUND)
-#
-#
-#
-# $SDLDIR is an environment variable that would correspond to the
-# ./configure --prefix=$SDLDIR used in building SDL.
-#
-# Created by Eric Wing. This was influenced by the FindSDL.cmake
-# module, but with modifications to recognize OS X frameworks and
-# additional Unix paths (FreeBSD, etc).
+#[=======================================================================[.rst:
+FindSDL_image
+-------------
+
+Locate SDL_image library
+
+This module defines:
+
+::
+
+ SDL_IMAGE_LIBRARIES, the name of the library to link against
+ SDL_IMAGE_INCLUDE_DIRS, where to find the headers
+ SDL_IMAGE_FOUND, if false, do not try to link against
+ SDL_IMAGE_VERSION_STRING - human-readable string containing the
+ version of SDL_image
+
+
+
+For backward compatibility the following variables are also set:
+
+::
+
+ SDLIMAGE_LIBRARY (same value as SDL_IMAGE_LIBRARIES)
+ SDLIMAGE_INCLUDE_DIR (same value as SDL_IMAGE_INCLUDE_DIRS)
+ SDLIMAGE_FOUND (same value as SDL_IMAGE_FOUND)
+
+
+
+$SDLDIR is an environment variable that would correspond to the
+./configure --prefix=$SDLDIR used in building SDL.
+
+Created by Eric Wing. This was influenced by the FindSDL.cmake
+module, but with modifications to recognize OS X frameworks and
+additional Unix paths (FreeBSD, etc).
+#]=======================================================================]
if(NOT SDL_IMAGE_INCLUDE_DIR AND SDLIMAGE_INCLUDE_DIR)
set(SDL_IMAGE_INCLUDE_DIR ${SDLIMAGE_INCLUDE_DIR} CACHE PATH "directory cache
diff --git a/Modules/FindSDL_mixer.cmake b/Modules/FindSDL_mixer.cmake
index 35233d121..315400a30 100644
--- a/Modules/FindSDL_mixer.cmake
+++ b/Modules/FindSDL_mixer.cmake
@@ -1,40 +1,41 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindSDL_mixer
-# -------------
-#
-# Locate SDL_mixer library
-#
-# This module defines:
-#
-# ::
-#
-# SDL_MIXER_LIBRARIES, the name of the library to link against
-# SDL_MIXER_INCLUDE_DIRS, where to find the headers
-# SDL_MIXER_FOUND, if false, do not try to link against
-# SDL_MIXER_VERSION_STRING - human-readable string containing the
-# version of SDL_mixer
-#
-#
-#
-# For backward compatibility the following variables are also set:
-#
-# ::
-#
-# SDLMIXER_LIBRARY (same value as SDL_MIXER_LIBRARIES)
-# SDLMIXER_INCLUDE_DIR (same value as SDL_MIXER_INCLUDE_DIRS)
-# SDLMIXER_FOUND (same value as SDL_MIXER_FOUND)
-#
-#
-#
-# $SDLDIR is an environment variable that would correspond to the
-# ./configure --prefix=$SDLDIR used in building SDL.
-#
-# Created by Eric Wing. This was influenced by the FindSDL.cmake
-# module, but with modifications to recognize OS X frameworks and
-# additional Unix paths (FreeBSD, etc).
+#[=======================================================================[.rst:
+FindSDL_mixer
+-------------
+
+Locate SDL_mixer library
+
+This module defines:
+
+::
+
+ SDL_MIXER_LIBRARIES, the name of the library to link against
+ SDL_MIXER_INCLUDE_DIRS, where to find the headers
+ SDL_MIXER_FOUND, if false, do not try to link against
+ SDL_MIXER_VERSION_STRING - human-readable string containing the
+ version of SDL_mixer
+
+
+
+For backward compatibility the following variables are also set:
+
+::
+
+ SDLMIXER_LIBRARY (same value as SDL_MIXER_LIBRARIES)
+ SDLMIXER_INCLUDE_DIR (same value as SDL_MIXER_INCLUDE_DIRS)
+ SDLMIXER_FOUND (same value as SDL_MIXER_FOUND)
+
+
+
+$SDLDIR is an environment variable that would correspond to the
+./configure --prefix=$SDLDIR used in building SDL.
+
+Created by Eric Wing. This was influenced by the FindSDL.cmake
+module, but with modifications to recognize OS X frameworks and
+additional Unix paths (FreeBSD, etc).
+#]=======================================================================]
if(NOT SDL_MIXER_INCLUDE_DIR AND SDLMIXER_INCLUDE_DIR)
set(SDL_MIXER_INCLUDE_DIR ${SDLMIXER_INCLUDE_DIR} CACHE PATH "directory cache
diff --git a/Modules/FindSDL_net.cmake b/Modules/FindSDL_net.cmake
index b40694668..28cb4d6c2 100644
--- a/Modules/FindSDL_net.cmake
+++ b/Modules/FindSDL_net.cmake
@@ -1,39 +1,40 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindSDL_net
-# -----------
-#
-# Locate SDL_net library
-#
-# This module defines:
-#
-# ::
-#
-# SDL_NET_LIBRARIES, the name of the library to link against
-# SDL_NET_INCLUDE_DIRS, where to find the headers
-# SDL_NET_FOUND, if false, do not try to link against
-# SDL_NET_VERSION_STRING - human-readable string containing the version of SDL_net
-#
-#
-#
-# For backward compatibility the following variables are also set:
-#
-# ::
-#
-# SDLNET_LIBRARY (same value as SDL_NET_LIBRARIES)
-# SDLNET_INCLUDE_DIR (same value as SDL_NET_INCLUDE_DIRS)
-# SDLNET_FOUND (same value as SDL_NET_FOUND)
-#
-#
-#
-# $SDLDIR is an environment variable that would correspond to the
-# ./configure --prefix=$SDLDIR used in building SDL.
-#
-# Created by Eric Wing. This was influenced by the FindSDL.cmake
-# module, but with modifications to recognize OS X frameworks and
-# additional Unix paths (FreeBSD, etc).
+#[=======================================================================[.rst:
+FindSDL_net
+-----------
+
+Locate SDL_net library
+
+This module defines:
+
+::
+
+ SDL_NET_LIBRARIES, the name of the library to link against
+ SDL_NET_INCLUDE_DIRS, where to find the headers
+ SDL_NET_FOUND, if false, do not try to link against
+ SDL_NET_VERSION_STRING - human-readable string containing the version of SDL_net
+
+
+
+For backward compatibility the following variables are also set:
+
+::
+
+ SDLNET_LIBRARY (same value as SDL_NET_LIBRARIES)
+ SDLNET_INCLUDE_DIR (same value as SDL_NET_INCLUDE_DIRS)
+ SDLNET_FOUND (same value as SDL_NET_FOUND)
+
+
+
+$SDLDIR is an environment variable that would correspond to the
+./configure --prefix=$SDLDIR used in building SDL.
+
+Created by Eric Wing. This was influenced by the FindSDL.cmake
+module, but with modifications to recognize OS X frameworks and
+additional Unix paths (FreeBSD, etc).
+#]=======================================================================]
if(NOT SDL_NET_INCLUDE_DIR AND SDLNET_INCLUDE_DIR)
set(SDL_NET_INCLUDE_DIR ${SDLNET_INCLUDE_DIR} CACHE PATH "directory cache
diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake
index cf33a4c2c..8d2f9f8fc 100644
--- a/Modules/FindSDL_sound.cmake
+++ b/Modules/FindSDL_sound.cmake
@@ -1,84 +1,85 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindSDL_sound
-# -------------
-#
-# Locates the SDL_sound library
-#
-#
-#
-# This module depends on SDL being found and must be called AFTER
-# FindSDL.cmake is called.
-#
-# This module defines
-#
-# ::
-#
-# SDL_SOUND_INCLUDE_DIR, where to find SDL_sound.h
-# SDL_SOUND_FOUND, if false, do not try to link to SDL_sound
-# SDL_SOUND_LIBRARIES, this contains the list of libraries that you need
-# to link against.
-# SDL_SOUND_EXTRAS, this is an optional variable for you to add your own
-# flags to SDL_SOUND_LIBRARIES. This is prepended to SDL_SOUND_LIBRARIES.
-# This is available mostly for cases this module failed to anticipate for
-# and you must add additional flags. This is marked as ADVANCED.
-# SDL_SOUND_VERSION_STRING, human-readable string containing the
-# version of SDL_sound
-#
-#
-#
-# This module also defines (but you shouldn't need to use directly)
-#
-# ::
-#
-# SDL_SOUND_LIBRARY, the name of just the SDL_sound library you would link
-# against. Use SDL_SOUND_LIBRARIES for you link instructions and not this one.
-#
-# And might define the following as needed
-#
-# ::
-#
-# MIKMOD_LIBRARY
-# MODPLUG_LIBRARY
-# OGG_LIBRARY
-# VORBIS_LIBRARY
-# SMPEG_LIBRARY
-# FLAC_LIBRARY
-# SPEEX_LIBRARY
-#
-#
-#
-# Typically, you should not use these variables directly, and you should
-# use SDL_SOUND_LIBRARIES which contains SDL_SOUND_LIBRARY and the other
-# audio libraries (if needed) to successfully compile on your system.
-#
-# Created by Eric Wing. This module is a bit more complicated than the
-# other FindSDL* family modules. The reason is that SDL_sound can be
-# compiled in a large variety of different ways which are independent of
-# platform. SDL_sound may dynamically link against other 3rd party
-# libraries to get additional codec support, such as Ogg Vorbis, SMPEG,
-# ModPlug, MikMod, FLAC, Speex, and potentially others. Under some
-# circumstances which I don't fully understand, there seems to be a
-# requirement that dependent libraries of libraries you use must also be
-# explicitly linked against in order to successfully compile. SDL_sound
-# does not currently have any system in place to know how it was
-# compiled. So this CMake module does the hard work in trying to
-# discover which 3rd party libraries are required for building (if any).
-# This module uses a brute force approach to create a test program that
-# uses SDL_sound, and then tries to build it. If the build fails, it
-# parses the error output for known symbol names to figure out which
-# libraries are needed.
-#
-# Responds to the $SDLDIR and $SDLSOUNDDIR environmental variable that
-# would correspond to the ./configure --prefix=$SDLDIR used in building
-# SDL.
-#
-# On OSX, this will prefer the Framework version (if found) over others.
-# People will have to manually change the cache values of SDL_LIBRARY to
-# override this selectionor set the CMake environment CMAKE_INCLUDE_PATH
-# to modify the search paths.
+#[=======================================================================[.rst:
+FindSDL_sound
+-------------
+
+Locates the SDL_sound library
+
+
+
+This module depends on SDL being found and must be called AFTER
+FindSDL.cmake is called.
+
+This module defines
+
+::
+
+ SDL_SOUND_INCLUDE_DIR, where to find SDL_sound.h
+ SDL_SOUND_FOUND, if false, do not try to link to SDL_sound
+ SDL_SOUND_LIBRARIES, this contains the list of libraries that you need
+ to link against.
+ SDL_SOUND_EXTRAS, this is an optional variable for you to add your own
+ flags to SDL_SOUND_LIBRARIES. This is prepended to SDL_SOUND_LIBRARIES.
+ This is available mostly for cases this module failed to anticipate for
+ and you must add additional flags. This is marked as ADVANCED.
+ SDL_SOUND_VERSION_STRING, human-readable string containing the
+ version of SDL_sound
+
+
+
+This module also defines (but you shouldn't need to use directly)
+
+::
+
+ SDL_SOUND_LIBRARY, the name of just the SDL_sound library you would link
+ against. Use SDL_SOUND_LIBRARIES for you link instructions and not this one.
+
+And might define the following as needed
+
+::
+
+ MIKMOD_LIBRARY
+ MODPLUG_LIBRARY
+ OGG_LIBRARY
+ VORBIS_LIBRARY
+ SMPEG_LIBRARY
+ FLAC_LIBRARY
+ SPEEX_LIBRARY
+
+
+
+Typically, you should not use these variables directly, and you should
+use SDL_SOUND_LIBRARIES which contains SDL_SOUND_LIBRARY and the other
+audio libraries (if needed) to successfully compile on your system.
+
+Created by Eric Wing. This module is a bit more complicated than the
+other FindSDL* family modules. The reason is that SDL_sound can be
+compiled in a large variety of different ways which are independent of
+platform. SDL_sound may dynamically link against other 3rd party
+libraries to get additional codec support, such as Ogg Vorbis, SMPEG,
+ModPlug, MikMod, FLAC, Speex, and potentially others. Under some
+circumstances which I don't fully understand, there seems to be a
+requirement that dependent libraries of libraries you use must also be
+explicitly linked against in order to successfully compile. SDL_sound
+does not currently have any system in place to know how it was
+compiled. So this CMake module does the hard work in trying to
+discover which 3rd party libraries are required for building (if any).
+This module uses a brute force approach to create a test program that
+uses SDL_sound, and then tries to build it. If the build fails, it
+parses the error output for known symbol names to figure out which
+libraries are needed.
+
+Responds to the $SDLDIR and $SDLSOUNDDIR environmental variable that
+would correspond to the ./configure --prefix=$SDLDIR used in building
+SDL.
+
+On OSX, this will prefer the Framework version (if found) over others.
+People will have to manually change the cache values of SDL_LIBRARY to
+override this selectionor set the CMake environment CMAKE_INCLUDE_PATH
+to modify the search paths.
+#]=======================================================================]
set(SDL_SOUND_EXTRAS "" CACHE STRING "SDL_sound extra flags")
mark_as_advanced(SDL_SOUND_EXTRAS)
@@ -151,226 +152,199 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
SDL_Quit();
return 0;
}"
- )
-
- # Calling
- # target_link_libraries(DetermineSoundLibs "${SDL_SOUND_LIBRARY} ${SDL_LIBRARY})
- # causes problems when SDL_LIBRARY looks like
- # /Library/Frameworks/SDL.framework;-framework Cocoa
- # The ;-framework Cocoa seems to be confusing CMake once the OS X
- # framework support was added. I was told that breaking up the list
- # would fix the problem.
- set(TMP_TRY_LIBS)
- foreach(lib ${SDL_SOUND_LIBRARY} ${SDL_LIBRARY})
- string(APPEND TMP_TRY_LIBS " \"${lib}\"")
- endforeach()
-
- # message("TMP_TRY_LIBS ${TMP_TRY_LIBS}")
-
- # Write the CMakeLists.txt and test project
- # Weird, this is still sketchy. If I don't quote the variables
- # in the TARGET_LINK_LIBRARIES, I seem to loose everything
- # in the SDL_LIBRARY string after the "-framework".
- # But if I quote the stuff in INCLUDE_DIRECTORIES, it doesn't work.
- file(WRITE ${PROJECT_BINARY_DIR}/CMakeTmp/CMakeLists.txt
- "cmake_minimum_required(VERSION ${CMAKE_VERSION})
- project(DetermineSoundLibs)
- include_directories(${SDL_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
- add_executable(DetermineSoundLibs DetermineSoundLibs.c)
- target_link_libraries(DetermineSoundLibs ${TMP_TRY_LIBS})"
- )
-
- try_compile(
- MY_RESULT
- ${PROJECT_BINARY_DIR}/CMakeTmp
- ${PROJECT_BINARY_DIR}/CMakeTmp
- DetermineSoundLibs
- OUTPUT_VARIABLE MY_OUTPUT
- )
-
- # message("${MY_RESULT}")
- # message(${MY_OUTPUT})
-
- if(NOT MY_RESULT)
-
- # I expect that MPGLIB, VOC, WAV, AIFF, and SHN are compiled in statically.
- # I think Timidity is also compiled in statically.
- # I've never had to explcitly link against Quicktime, so I'll skip that for now.
-
- set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARY})
-
- # Find MikMod
- if("${MY_OUTPUT}" MATCHES "MikMod_")
- find_library(MIKMOD_LIBRARY
- NAMES libmikmod-coreaudio mikmod
- PATHS
- ENV MIKMODDIR
- ENV SDLSOUNDDIR
- ENV SDLDIR
- /sw
- /opt/local
- /opt/csw
- /opt
- PATH_SUFFIXES
- lib
- )
- if(MIKMOD_LIBRARY)
- set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${MIKMOD_LIBRARY})
- endif(MIKMOD_LIBRARY)
- endif("${MY_OUTPUT}" MATCHES "MikMod_")
-
- # Find ModPlug
- if("${MY_OUTPUT}" MATCHES "MODPLUG_")
- find_library(MODPLUG_LIBRARY
- NAMES modplug
- PATHS
- ENV MODPLUGDIR
- ENV SDLSOUNDDIR
- ENV SDLDIR
- /sw
- /opt/local
- /opt/csw
- /opt
- PATH_SUFFIXES
- lib
- )
- if(MODPLUG_LIBRARY)
- set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${MODPLUG_LIBRARY})
- endif()
- endif()
-
-
- # Find Ogg and Vorbis
- if("${MY_OUTPUT}" MATCHES "ov_")
- find_library(VORBIS_LIBRARY
- NAMES vorbis Vorbis VORBIS
- PATHS
- ENV VORBISDIR
- ENV OGGDIR
- ENV SDLSOUNDDIR
- ENV SDLDIR
- /sw
- /opt/local
- /opt/csw
- /opt
- PATH_SUFFIXES
- lib
- )
- if(VORBIS_LIBRARY)
- set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${VORBIS_LIBRARY})
- endif()
-
- find_library(OGG_LIBRARY
- NAMES ogg Ogg OGG
- PATHS
- ENV OGGDIR
- ENV VORBISDIR
- ENV SDLSOUNDDIR
- ENV SDLDIR
- /sw
- /opt/local
- /opt/csw
- /opt
- PATH_SUFFIXES
- lib
- )
- if(OGG_LIBRARY)
- set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${OGG_LIBRARY})
- endif()
- endif()
-
-
- # Find SMPEG
- if("${MY_OUTPUT}" MATCHES "SMPEG_")
- find_library(SMPEG_LIBRARY
- NAMES smpeg SMPEG Smpeg SMpeg
- PATHS
- ENV SMPEGDIR
- ENV SDLSOUNDDIR
- ENV SDLDIR
- /sw
- /opt/local
- /opt/csw
- /opt
- PATH_SUFFIXES
- lib
- )
- if(SMPEG_LIBRARY)
- set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${SMPEG_LIBRARY})
- endif()
- endif()
-
-
- # Find FLAC
- if("${MY_OUTPUT}" MATCHES "FLAC_")
- find_library(FLAC_LIBRARY
- NAMES flac FLAC
- PATHS
- ENV FLACDIR
- ENV SDLSOUNDDIR
- ENV SDLDIR
- /sw
- /opt/local
- /opt/csw
- /opt
- PATH_SUFFIXES
- lib
- )
- if(FLAC_LIBRARY)
- set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${FLAC_LIBRARY})
- endif()
- endif()
-
-
- # Hmmm...Speex seems to depend on Ogg. This might be a problem if
- # the TRY_COMPILE attempt gets blocked at SPEEX before it can pull
- # in the Ogg symbols. I'm not sure if I should duplicate the ogg stuff
- # above for here or if two ogg entries will screw up things.
- if("${MY_OUTPUT}" MATCHES "speex_")
- find_library(SPEEX_LIBRARY
- NAMES speex SPEEX
- PATHS
- ENV SPEEXDIR
- ENV SDLSOUNDDIR
- ENV SDLDIR
- /sw
- /opt/local
- /opt/csw
- /opt
- PATH_SUFFIXES
- lib
+ )
+
+ # Calling
+ # target_link_libraries(DetermineSoundLibs "${SDL_SOUND_LIBRARY} ${SDL_LIBRARY})
+ # causes problems when SDL_LIBRARY looks like
+ # /Library/Frameworks/SDL.framework;-framework Cocoa
+ # The ;-framework Cocoa seems to be confusing CMake once the OS X
+ # framework support was added. I was told that breaking up the list
+ # would fix the problem.
+ set(TMP_TRY_LIBS)
+ foreach(lib ${SDL_SOUND_LIBRARY} ${SDL_LIBRARY})
+ string(APPEND TMP_TRY_LIBS " \"${lib}\"")
+ endforeach()
+
+
+ # Write the CMakeLists.txt and test project
+ # Weird, this is still sketchy. If I don't quote the variables
+ # in the TARGET_LINK_LIBRARIES, I seem to loose everything
+ # in the SDL_LIBRARY string after the "-framework".
+ # But if I quote the stuff in INCLUDE_DIRECTORIES, it doesn't work.
+ file(WRITE ${PROJECT_BINARY_DIR}/CMakeTmp/CMakeLists.txt
+ "cmake_minimum_required(VERSION ${CMAKE_VERSION})
+ project(DetermineSoundLibs)
+ include_directories(${SDL_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
+ add_executable(DetermineSoundLibs DetermineSoundLibs.c)
+ target_link_libraries(DetermineSoundLibs ${TMP_TRY_LIBS})"
+ )
+
+ try_compile(
+ MY_RESULT
+ ${PROJECT_BINARY_DIR}/CMakeTmp
+ ${PROJECT_BINARY_DIR}/CMakeTmp
+ DetermineSoundLibs
+ OUTPUT_VARIABLE MY_OUTPUT
+ )
+
+
+ if(NOT MY_RESULT)
+
+ # I expect that MPGLIB, VOC, WAV, AIFF, and SHN are compiled in statically.
+ # I think Timidity is also compiled in statically.
+ # I've never had to explcitly link against Quicktime, so I'll skip that for now.
+
+ set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARY})
+
+ # Find MikMod
+ if("${MY_OUTPUT}" MATCHES "MikMod_")
+ find_library(MIKMOD_LIBRARY
+ NAMES libmikmod-coreaudio mikmod
+ PATHS
+ ENV MIKMODDIR
+ ENV SDLSOUNDDIR
+ ENV SDLDIR
+ /opt
+ PATH_SUFFIXES
+ lib
+ )
+ if(MIKMOD_LIBRARY)
+ set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${MIKMOD_LIBRARY})
+ endif(MIKMOD_LIBRARY)
+ endif("${MY_OUTPUT}" MATCHES "MikMod_")
+
+ # Find ModPlug
+ if("${MY_OUTPUT}" MATCHES "MODPLUG_")
+ find_library(MODPLUG_LIBRARY
+ NAMES modplug
+ PATHS
+ ENV MODPLUGDIR
+ ENV SDLSOUNDDIR
+ ENV SDLDIR
+ /opt
+ PATH_SUFFIXES
+ lib
+ )
+ if(MODPLUG_LIBRARY)
+ set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${MODPLUG_LIBRARY})
+ endif()
+ endif()
+
+
+ # Find Ogg and Vorbis
+ if("${MY_OUTPUT}" MATCHES "ov_")
+ find_library(VORBIS_LIBRARY
+ NAMES vorbis Vorbis VORBIS
+ PATHS
+ ENV VORBISDIR
+ ENV OGGDIR
+ ENV SDLSOUNDDIR
+ ENV SDLDIR
+ /opt
+ PATH_SUFFIXES
+ lib
+ )
+ if(VORBIS_LIBRARY)
+ set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${VORBIS_LIBRARY})
+ endif()
+
+ find_library(OGG_LIBRARY
+ NAMES ogg Ogg OGG
+ PATHS
+ ENV OGGDIR
+ ENV VORBISDIR
+ ENV SDLSOUNDDIR
+ ENV SDLDIR
+ /opt
+ PATH_SUFFIXES
+ lib
)
- if(SPEEX_LIBRARY)
- set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${SPEEX_LIBRARY})
- endif()
-
- # Find OGG (needed for Speex)
- # We might have already found Ogg for Vorbis, so skip it if so.
- if(NOT OGG_LIBRARY)
- find_library(OGG_LIBRARY
- NAMES ogg Ogg OGG
- PATHS
- ENV OGGDIR
- ENV VORBISDIR
- ENV SPEEXDIR
- ENV SDLSOUNDDIR
- ENV SDLDIR
- /sw
- /opt/local
- /opt/csw
- /opt
- PATH_SUFFIXES lib
- )
- if(OGG_LIBRARY)
- set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${OGG_LIBRARY})
- endif()
- endif()
- endif()
-
- set(SDL_SOUND_LIBRARIES ${SDL_SOUND_EXTRAS} ${SDL_SOUND_LIBRARIES_TMP})
- else()
- set(SDL_SOUND_LIBRARIES ${SDL_SOUND_EXTRAS} ${SDL_SOUND_LIBRARY})
- endif()
+ if(OGG_LIBRARY)
+ set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${OGG_LIBRARY})
+ endif()
+ endif()
+
+
+ # Find SMPEG
+ if("${MY_OUTPUT}" MATCHES "SMPEG_")
+ find_library(SMPEG_LIBRARY
+ NAMES smpeg SMPEG Smpeg SMpeg
+ PATHS
+ ENV SMPEGDIR
+ ENV SDLSOUNDDIR
+ ENV SDLDIR
+ /opt
+ PATH_SUFFIXES
+ lib
+ )
+ if(SMPEG_LIBRARY)
+ set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${SMPEG_LIBRARY})
+ endif()
+ endif()
+
+
+ # Find FLAC
+ if("${MY_OUTPUT}" MATCHES "FLAC_")
+ find_library(FLAC_LIBRARY
+ NAMES flac FLAC
+ PATHS
+ ENV FLACDIR
+ ENV SDLSOUNDDIR
+ ENV SDLDIR
+ /opt
+ PATH_SUFFIXES
+ lib
+ )
+ if(FLAC_LIBRARY)
+ set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${FLAC_LIBRARY})
+ endif()
+ endif()
+
+
+ # Hmmm...Speex seems to depend on Ogg. This might be a problem if
+ # the TRY_COMPILE attempt gets blocked at SPEEX before it can pull
+ # in the Ogg symbols. I'm not sure if I should duplicate the ogg stuff
+ # above for here or if two ogg entries will screw up things.
+ if("${MY_OUTPUT}" MATCHES "speex_")
+ find_library(SPEEX_LIBRARY
+ NAMES speex SPEEX
+ PATHS
+ ENV SPEEXDIR
+ ENV SDLSOUNDDIR
+ ENV SDLDIR
+ /opt
+ PATH_SUFFIXES
+ lib
+ )
+ if(SPEEX_LIBRARY)
+ set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${SPEEX_LIBRARY})
+ endif()
+
+ # Find OGG (needed for Speex)
+ # We might have already found Ogg for Vorbis, so skip it if so.
+ if(NOT OGG_LIBRARY)
+ find_library(OGG_LIBRARY
+ NAMES ogg Ogg OGG
+ PATHS
+ ENV OGGDIR
+ ENV VORBISDIR
+ ENV SPEEXDIR
+ ENV SDLSOUNDDIR
+ ENV SDLDIR
+ /opt
+ PATH_SUFFIXES lib
+ )
+ if(OGG_LIBRARY)
+ set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${OGG_LIBRARY})
+ endif()
+ endif()
+ endif()
+
+ set(SDL_SOUND_LIBRARIES ${SDL_SOUND_EXTRAS} ${SDL_SOUND_LIBRARIES_TMP})
+ else()
+ set(SDL_SOUND_LIBRARIES ${SDL_SOUND_EXTRAS} ${SDL_SOUND_LIBRARY})
+ endif()
endif()
if(SDL_SOUND_INCLUDE_DIR AND EXISTS "${SDL_SOUND_INCLUDE_DIR}/SDL_sound.h")
diff --git a/Modules/FindSDL_ttf.cmake b/Modules/FindSDL_ttf.cmake
index aa705f226..d5721da0a 100644
--- a/Modules/FindSDL_ttf.cmake
+++ b/Modules/FindSDL_ttf.cmake
@@ -1,39 +1,40 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindSDL_ttf
-# -----------
-#
-# Locate SDL_ttf library
-#
-# This module defines:
-#
-# ::
-#
-# SDL_TTF_LIBRARIES, the name of the library to link against
-# SDL_TTF_INCLUDE_DIRS, where to find the headers
-# SDL_TTF_FOUND, if false, do not try to link against
-# SDL_TTF_VERSION_STRING - human-readable string containing the version of SDL_ttf
-#
-#
-#
-# For backward compatibility the following variables are also set:
-#
-# ::
-#
-# SDLTTF_LIBRARY (same value as SDL_TTF_LIBRARIES)
-# SDLTTF_INCLUDE_DIR (same value as SDL_TTF_INCLUDE_DIRS)
-# SDLTTF_FOUND (same value as SDL_TTF_FOUND)
-#
-#
-#
-# $SDLDIR is an environment variable that would correspond to the
-# ./configure --prefix=$SDLDIR used in building SDL.
-#
-# Created by Eric Wing. This was influenced by the FindSDL.cmake
-# module, but with modifications to recognize OS X frameworks and
-# additional Unix paths (FreeBSD, etc).
+#[=======================================================================[.rst:
+FindSDL_ttf
+-----------
+
+Locate SDL_ttf library
+
+This module defines:
+
+::
+
+ SDL_TTF_LIBRARIES, the name of the library to link against
+ SDL_TTF_INCLUDE_DIRS, where to find the headers
+ SDL_TTF_FOUND, if false, do not try to link against
+ SDL_TTF_VERSION_STRING - human-readable string containing the version of SDL_ttf
+
+
+
+For backward compatibility the following variables are also set:
+
+::
+
+ SDLTTF_LIBRARY (same value as SDL_TTF_LIBRARIES)
+ SDLTTF_INCLUDE_DIR (same value as SDL_TTF_INCLUDE_DIRS)
+ SDLTTF_FOUND (same value as SDL_TTF_FOUND)
+
+
+
+$SDLDIR is an environment variable that would correspond to the
+./configure --prefix=$SDLDIR used in building SDL.
+
+Created by Eric Wing. This was influenced by the FindSDL.cmake
+module, but with modifications to recognize OS X frameworks and
+additional Unix paths (FreeBSD, etc).
+#]=======================================================================]
if(NOT SDL_TTF_INCLUDE_DIR AND SDLTTF_INCLUDE_DIR)
set(SDL_TTF_INCLUDE_DIR ${SDLTTF_INCLUDE_DIR} CACHE PATH "directory cache
diff --git a/Modules/FindSQLite3.cmake b/Modules/FindSQLite3.cmake
new file mode 100644
index 000000000..374d7af6c
--- /dev/null
+++ b/Modules/FindSQLite3.cmake
@@ -0,0 +1,66 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindSQLite3
+-----------
+
+Find the SQLite libraries, v3
+
+IMPORTED targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` target:
+
+``SQLite::SQLite3``
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables if found:
+
+``SQLite3_INCLUDE_DIRS``
+ where to find sqlite3.h, etc.
+``SQLite3_LIBRARIES``
+ the libraries to link against to use SQLite3.
+``SQLite3_VERSION``
+ version of the SQLite3 library found
+``SQLite3_FOUND``
+ TRUE if found
+
+#]=======================================================================]
+
+# Look for the necessary header
+find_path(SQLite3_INCLUDE_DIR NAMES sqlite3.h)
+mark_as_advanced(SQLite3_INCLUDE_DIR)
+
+# Look for the necessary library
+find_library(SQLite3_LIBRARY NAMES sqlite3 sqlite)
+mark_as_advanced(SQLite3_LIBRARY)
+
+# Extract version information from the header file
+if(SQLite3_INCLUDE_DIR)
+ file(STRINGS ${SQLite3_INCLUDE_DIR}/sqlite3.h _ver_line
+ REGEX "^#define SQLITE_VERSION *\"[0-9]+\\.[0-9]+\\.[0-9]+\""
+ LIMIT_COUNT 1)
+ string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+"
+ SQLite3_VERSION "${_ver_line}")
+ unset(_ver_line)
+endif()
+
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+find_package_handle_standard_args(SQLite3
+ REQUIRED_VARS SQLite3_INCLUDE_DIR SQLite3_LIBRARY
+ VERSION_VAR SQLite3_VERSION)
+
+# Create the imported target
+if(SQLite3_FOUND)
+ set(SQLite3_INCLUDE_DIRS ${SQLite3_INCLUDE_DIR})
+ set(SQLite3_LIBRARIES ${SQLite3_LIBRARY})
+ if(NOT TARGET SQLite::SQLite3)
+ add_library(SQLite::SQLite3 UNKNOWN IMPORTED)
+ set_target_properties(SQLite::SQLite3 PROPERTIES
+ IMPORTED_LOCATION "${SQLite3_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}")
+ endif()
+endif()
diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake
index 92c032f6a..ae6ae56f7 100644
--- a/Modules/FindSWIG.cmake
+++ b/Modules/FindSWIG.cmake
@@ -1,31 +1,32 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindSWIG
-# --------
-#
-# Find SWIG
-#
-# This module finds an installed SWIG. It sets the following variables:
-#
-# ::
-#
-# SWIG_FOUND - set to true if SWIG is found
-# SWIG_DIR - the directory where swig is installed
-# SWIG_EXECUTABLE - the path to the swig executable
-# SWIG_VERSION - the version number of the swig executable
-#
-#
-#
-# The minimum required version of SWIG can be specified using the
-# standard syntax, e.g. find_package(SWIG 1.1)
-#
-# All information is collected from the SWIG_EXECUTABLE so the version
-# to be found can be changed from the command line by means of setting
-# SWIG_EXECUTABLE
+#[=======================================================================[.rst:
+FindSWIG
+--------
-find_program(SWIG_EXECUTABLE NAMES swig3.0 swig2.0 swig)
+Find Simplified Wrapper and Interface Generator (SWIG)
+
+This module finds an installed SWIG. It sets the following variables:
+
+::
+
+ SWIG_FOUND - set to "True" if SWIG is found
+ SWIG_DIR - the directory where swig is installed
+ SWIG_EXECUTABLE - the path to the swig executable
+ SWIG_VERSION - the version number of the swig executable
+
+
+
+The minimum required version of SWIG can be specified using the
+standard syntax, e.g. :command:`find_package(SWIG 1.1)`
+
+All information is collected from the ``SWIG_EXECUTABLE``, so the version
+to be found can be changed from the command line by means of setting
+``SWIG_EXECUTABLE``
+#]=======================================================================]
+
+find_program(SWIG_EXECUTABLE NAMES swig4.0 swig3.0 swig2.0 swig)
if(SWIG_EXECUTABLE)
execute_process(COMMAND ${SWIG_EXECUTABLE} -swiglib
@@ -63,4 +64,4 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SWIG REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR
VERSION_VAR SWIG_VERSION )
-mark_as_advanced(SWIG_DIR SWIG_VERSION)
+mark_as_advanced(SWIG_DIR SWIG_VERSION SWIG_EXECUTABLE)
diff --git a/Modules/FindSelfPackers.cmake b/Modules/FindSelfPackers.cmake
index 01d064139..1abbcbd7a 100644
--- a/Modules/FindSelfPackers.cmake
+++ b/Modules/FindSelfPackers.cmake
@@ -1,38 +1,31 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindSelfPackers
-# ---------------
-#
-# Find upx
-#
-# This module looks for some executable packers (i.e. software that
-# compress executables or shared libs into on-the-fly self-extracting
-# executables or shared libs. Examples:
-#
-# ::
-#
-# UPX: http://wildsau.idv.uni-linz.ac.at/mfx/upx.html
+#[=======================================================================[.rst:
+FindSelfPackers
+---------------
+
+Find upx
+
+This module looks for some executable packers (i.e. software that
+compress executables or shared libs into on-the-fly self-extracting
+executables or shared libs. Examples:
+
+::
+
+ UPX: http://wildsau.idv.uni-linz.ac.at/mfx/upx.html
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake)
find_program(SELF_PACKER_FOR_EXECUTABLE
upx
${CYGWIN_INSTALL_PATH}/bin
- /bin
- /usr/bin
- /usr/local/bin
- /sbin
)
find_program(SELF_PACKER_FOR_SHARED_LIB
upx
${CYGWIN_INSTALL_PATH}/bin
- /bin
- /usr/bin
- /usr/local/bin
- /sbin
)
mark_as_advanced(
diff --git a/Modules/FindSquish.cmake b/Modules/FindSquish.cmake
index 09bdf1ff9..7d495059a 100644
--- a/Modules/FindSquish.cmake
+++ b/Modules/FindSquish.cmake
@@ -1,123 +1,124 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindSquish
-# ----------
-#
-# -- Typical Use
-#
-#
-#
-# This module can be used to find Squish. Currently Squish versions 3
-# and 4 are supported.
-#
-# ::
-#
-# SQUISH_FOUND If false, don't try to use Squish
-# SQUISH_VERSION The full version of Squish found
-# SQUISH_VERSION_MAJOR The major version of Squish found
-# SQUISH_VERSION_MINOR The minor version of Squish found
-# SQUISH_VERSION_PATCH The patch version of Squish found
-#
-#
-#
-# ::
-#
-# SQUISH_INSTALL_DIR The Squish installation directory
-# (containing bin, lib, etc)
-# SQUISH_SERVER_EXECUTABLE The squishserver executable
-# SQUISH_CLIENT_EXECUTABLE The squishrunner executable
-#
-#
-#
-# ::
-#
-# SQUISH_INSTALL_DIR_FOUND Was the install directory found?
-# SQUISH_SERVER_EXECUTABLE_FOUND Was the server executable found?
-# SQUISH_CLIENT_EXECUTABLE_FOUND Was the client executable found?
-#
-#
-#
-# It provides the function squish_v4_add_test() for adding a squish test
-# to cmake using Squish 4.x:
-#
-# ::
-#
-# squish_v4_add_test(cmakeTestName
-# AUT targetName SUITE suiteName TEST squishTestName
-# [SETTINGSGROUP group] [PRE_COMMAND command] [POST_COMMAND command] )
-#
-#
-#
-# The arguments have the following meaning:
-#
-# ``cmakeTestName``
-# this will be used as the first argument for add_test()
-# ``AUT targetName``
-# the name of the cmake target which will be used as AUT, i.e. the
-# executable which will be tested.
-# ``SUITE suiteName``
-# this is either the full path to the squish suite, or just the
-# last directory of the suite, i.e. the suite name. In this case
-# the CMakeLists.txt which calls squish_add_test() must be located
-# in the parent directory of the suite directory.
-# ``TEST squishTestName``
-# the name of the squish test, i.e. the name of the subdirectory
-# of the test inside the suite directory.
-# ``SETTINGSGROUP group``
-# if specified, the given settings group will be used for executing the test.
-# If not specified, the groupname will be "CTest_<username>"
-# ``PRE_COMMAND command``
-# if specified, the given command will be executed before starting the squish test.
-# ``POST_COMMAND command``
-# same as PRE_COMMAND, but after the squish test has been executed.
-#
-#
-#
-# ::
-#
-# enable_testing()
-# find_package(Squish 4.0)
-# if (SQUISH_FOUND)
-# squish_v4_add_test(myTestName
-# AUT myApp
-# SUITE ${CMAKE_SOURCE_DIR}/tests/mySuite
-# TEST someSquishTest
-# SETTINGSGROUP myGroup
-# )
-# endif ()
-#
-#
-#
-#
-#
-# For users of Squish version 3.x the macro squish_v3_add_test() is
-# provided:
-#
-# ::
-#
-# squish_v3_add_test(testName applicationUnderTest testCase envVars testWrapper)
-# Use this macro to add a test using Squish 3.x.
-#
-#
-#
-# ::
-#
-# enable_testing()
-# find_package(Squish)
-# if (SQUISH_FOUND)
-# squish_v3_add_test(myTestName myApplication testCase envVars testWrapper)
-# endif ()
-#
-#
-#
-# macro SQUISH_ADD_TEST(testName applicationUnderTest testCase envVars
-# testWrapper)
-#
-# ::
-#
-# This is deprecated. Use SQUISH_V3_ADD_TEST() if you are using Squish 3.x instead.
+#[=======================================================================[.rst:
+FindSquish
+----------
+
+-- Typical Use
+
+
+
+This module can be used to find Squish. Currently Squish versions 3
+and 4 are supported.
+
+::
+
+ SQUISH_FOUND If false, don't try to use Squish
+ SQUISH_VERSION The full version of Squish found
+ SQUISH_VERSION_MAJOR The major version of Squish found
+ SQUISH_VERSION_MINOR The minor version of Squish found
+ SQUISH_VERSION_PATCH The patch version of Squish found
+
+
+
+::
+
+ SQUISH_INSTALL_DIR The Squish installation directory
+ (containing bin, lib, etc)
+ SQUISH_SERVER_EXECUTABLE The squishserver executable
+ SQUISH_CLIENT_EXECUTABLE The squishrunner executable
+
+
+
+::
+
+ SQUISH_INSTALL_DIR_FOUND Was the install directory found?
+ SQUISH_SERVER_EXECUTABLE_FOUND Was the server executable found?
+ SQUISH_CLIENT_EXECUTABLE_FOUND Was the client executable found?
+
+
+
+It provides the function squish_v4_add_test() for adding a squish test
+to cmake using Squish 4.x:
+
+::
+
+ squish_v4_add_test(cmakeTestName
+ AUT targetName SUITE suiteName TEST squishTestName
+ [SETTINGSGROUP group] [PRE_COMMAND command] [POST_COMMAND command] )
+
+
+
+The arguments have the following meaning:
+
+``cmakeTestName``
+ this will be used as the first argument for add_test()
+``AUT targetName``
+ the name of the cmake target which will be used as AUT, i.e. the
+ executable which will be tested.
+``SUITE suiteName``
+ this is either the full path to the squish suite, or just the
+ last directory of the suite, i.e. the suite name. In this case
+ the CMakeLists.txt which calls squish_add_test() must be located
+ in the parent directory of the suite directory.
+``TEST squishTestName``
+ the name of the squish test, i.e. the name of the subdirectory
+ of the test inside the suite directory.
+``SETTINGSGROUP group``
+ if specified, the given settings group will be used for executing the test.
+ If not specified, the groupname will be "CTest_<username>"
+``PRE_COMMAND command``
+ if specified, the given command will be executed before starting the squish test.
+``POST_COMMAND command``
+ same as PRE_COMMAND, but after the squish test has been executed.
+
+
+
+::
+
+ enable_testing()
+ find_package(Squish 4.0)
+ if (SQUISH_FOUND)
+ squish_v4_add_test(myTestName
+ AUT myApp
+ SUITE ${CMAKE_SOURCE_DIR}/tests/mySuite
+ TEST someSquishTest
+ SETTINGSGROUP myGroup
+ )
+ endif ()
+
+
+
+
+
+For users of Squish version 3.x the macro squish_v3_add_test() is
+provided:
+
+::
+
+ squish_v3_add_test(testName applicationUnderTest testCase envVars testWrapper)
+ Use this macro to add a test using Squish 3.x.
+
+
+
+::
+
+ enable_testing()
+ find_package(Squish)
+ if (SQUISH_FOUND)
+ squish_v3_add_test(myTestName myApplication testCase envVars testWrapper)
+ endif ()
+
+
+
+macro SQUISH_ADD_TEST(testName applicationUnderTest testCase envVars
+testWrapper)
+
+::
+
+ This is deprecated. Use SQUISH_V3_ADD_TEST() if you are using Squish 3.x instead.
+#]=======================================================================]
set(SQUISH_INSTALL_DIR_STRING "Directory containing the bin, doc, and lib directories for Squish; this should be the root of the installation directory.")
set(SQUISH_SERVER_EXECUTABLE_STRING "The squishserver executable program.")
@@ -144,9 +145,6 @@ if(NOT SQUISH_INSTALL_DIR)
# Look in places relative to the system executable search path.
${SQUISH_INSTALL_DIR_SEARCH}
- # Look in standard UNIX install locations.
- #/usr/local/squish
-
DOC "The ${SQUISH_INSTALL_DIR_STRING}"
)
endif()
diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake
index 537d3b241..ce280e277 100644
--- a/Modules/FindSubversion.cmake
+++ b/Modules/FindSubversion.cmake
@@ -1,65 +1,69 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindSubversion
-# --------------
-#
-# Extract information from a subversion working copy
-#
-# The module defines the following variables:
-#
-# ::
-#
-# Subversion_SVN_EXECUTABLE - path to svn command line client
-# Subversion_VERSION_SVN - version of svn command line client
-# Subversion_FOUND - true if the command line client was found
-# SUBVERSION_FOUND - same as Subversion_FOUND, set for compatibility reasons
-#
-#
-#
-# The minimum required version of Subversion can be specified using the
-# standard syntax, e.g. find_package(Subversion 1.4)
-#
-# If the command line client executable is found two macros are defined:
-#
-# ::
-#
-# Subversion_WC_INFO(<dir> <var-prefix>)
-# Subversion_WC_LOG(<dir> <var-prefix>)
-#
-# Subversion_WC_INFO extracts information of a subversion working copy
-# at a given location. This macro defines the following variables:
-#
-# ::
-#
-# <var-prefix>_WC_URL - url of the repository (at <dir>)
-# <var-prefix>_WC_ROOT - root url of the repository
-# <var-prefix>_WC_REVISION - current revision
-# <var-prefix>_WC_LAST_CHANGED_AUTHOR - author of last commit
-# <var-prefix>_WC_LAST_CHANGED_DATE - date of last commit
-# <var-prefix>_WC_LAST_CHANGED_REV - revision of last commit
-# <var-prefix>_WC_INFO - output of command `svn info <dir>'
-#
-# Subversion_WC_LOG retrieves the log message of the base revision of a
-# subversion working copy at a given location. This macro defines the
-# variable:
-#
-# ::
-#
-# <var-prefix>_LAST_CHANGED_LOG - last log of base revision
-#
-# Example usage:
-#
-# ::
-#
-# find_package(Subversion)
-# if(SUBVERSION_FOUND)
-# Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project)
-# message("Current revision is ${Project_WC_REVISION}")
-# Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project)
-# message("Last changed log is ${Project_LAST_CHANGED_LOG}")
-# endif()
+#[=======================================================================[.rst:
+FindSubversion
+--------------
+
+Extract information from a subversion working copy
+
+The module defines the following variables:
+
+::
+
+ Subversion_SVN_EXECUTABLE - path to svn command line client
+ Subversion_VERSION_SVN - version of svn command line client
+ Subversion_FOUND - true if the command line client was found
+ SUBVERSION_FOUND - same as Subversion_FOUND, set for compatibility reasons
+
+
+
+The minimum required version of Subversion can be specified using the
+standard syntax, e.g. ``find_package(Subversion 1.4)``.
+
+If the command line client executable is found two macros are defined:
+
+::
+
+ Subversion_WC_INFO(<dir> <var-prefix> [IGNORE_SVN_FAILURE])
+ Subversion_WC_LOG(<dir> <var-prefix>)
+
+``Subversion_WC_INFO`` extracts information of a subversion working copy at a
+given location. This macro defines the following variables if running
+Subversion's ``info`` command on ``<dir>`` succeeds; otherwise a
+``SEND_ERROR`` message is generated. The error can be ignored by providing the
+``IGNORE_SVN_FAILURE`` option, which causes these variables to remain
+undefined.
+
+::
+
+ <var-prefix>_WC_URL - url of the repository (at <dir>)
+ <var-prefix>_WC_ROOT - root url of the repository
+ <var-prefix>_WC_REVISION - current revision
+ <var-prefix>_WC_LAST_CHANGED_AUTHOR - author of last commit
+ <var-prefix>_WC_LAST_CHANGED_DATE - date of last commit
+ <var-prefix>_WC_LAST_CHANGED_REV - revision of last commit
+ <var-prefix>_WC_INFO - output of command `svn info <dir>'
+
+``Subversion_WC_LOG`` retrieves the log message of the base revision of a
+subversion working copy at a given location. This macro defines the variable:
+
+::
+
+ <var-prefix>_LAST_CHANGED_LOG - last log of base revision
+
+Example usage:
+
+::
+
+ find_package(Subversion)
+ if(SUBVERSION_FOUND)
+ Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project)
+ message("Current revision is ${Project_WC_REVISION}")
+ Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project)
+ message("Last changed log is ${Project_LAST_CHANGED_LOG}")
+ endif()
+#]=======================================================================]
find_program(Subversion_SVN_EXECUTABLE svn
PATHS
@@ -84,6 +88,14 @@ if(Subversion_SVN_EXECUTABLE)
"\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}")
macro(Subversion_WC_INFO dir prefix)
+
+ cmake_parse_arguments(
+ "Subversion_WC_INFO"
+ "IGNORE_SVN_FAILURE"
+ "" ""
+ ${ARGN}
+ )
+
# the subversion commands should be executed with the C locale, otherwise
# the message (which are parsed) may be translated, Alex
set(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}")
@@ -95,10 +107,7 @@ if(Subversion_SVN_EXECUTABLE)
RESULT_VARIABLE Subversion_svn_info_result
OUTPUT_STRIP_TRAILING_WHITESPACE)
- if(NOT ${Subversion_svn_info_result} EQUAL 0)
- message(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}")
- else()
-
+ if(${Subversion_svn_info_result} EQUAL 0)
string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*"
"\\2" ${prefix}_WC_URL "${${prefix}_WC_INFO}")
string(REGEX REPLACE "^(.*\n)?Repository Root: ([^\n]+).*"
@@ -111,7 +120,8 @@ if(Subversion_SVN_EXECUTABLE)
"\\2" ${prefix}_WC_LAST_CHANGED_REV "${${prefix}_WC_INFO}")
string(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*"
"\\2" ${prefix}_WC_LAST_CHANGED_DATE "${${prefix}_WC_INFO}")
-
+ elseif(NOT Subversion_WC_INFO_IGNORE_SVN_FAILURE)
+ message(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}")
endif()
# restore the previous LC_ALL
diff --git a/Modules/FindTCL.cmake b/Modules/FindTCL.cmake
index b6e24a36d..be47c39a0 100644
--- a/Modules/FindTCL.cmake
+++ b/Modules/FindTCL.cmake
@@ -1,48 +1,49 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindTCL
-# -------
-#
-# TK_INTERNAL_PATH was removed.
-#
-# This module finds if Tcl is installed and determines where the include
-# files and libraries are. It also determines what the name of the
-# library is. This code sets the following variables:
-#
-# ::
-#
-# TCL_FOUND = Tcl was found
-# TK_FOUND = Tk was found
-# TCLTK_FOUND = Tcl and Tk were found
-# TCL_LIBRARY = path to Tcl library (tcl tcl80)
-# TCL_INCLUDE_PATH = path to where tcl.h can be found
-# TCL_TCLSH = path to tclsh binary (tcl tcl80)
-# TK_LIBRARY = path to Tk library (tk tk80 etc)
-# TK_INCLUDE_PATH = path to where tk.h can be found
-# TK_WISH = full path to the wish executable
-#
-#
-#
-# In an effort to remove some clutter and clear up some issues for
-# people who are not necessarily Tcl/Tk gurus/developpers, some
-# variables were moved or removed. Changes compared to CMake 2.4 are:
-#
-# ::
-#
-# => they were only useful for people writing Tcl/Tk extensions.
-# => these libs are not packaged by default with Tcl/Tk distributions.
-# Even when Tcl/Tk is built from source, several flavors of debug libs
-# are created and there is no real reason to pick a single one
-# specifically (say, amongst tcl84g, tcl84gs, or tcl84sgx).
-# Let's leave that choice to the user by allowing him to assign
-# TCL_LIBRARY to any Tcl library, debug or not.
-# => this ended up being only a Win32 variable, and there is a lot of
-# confusion regarding the location of this file in an installed Tcl/Tk
-# tree anyway (see 8.5 for example). If you need the internal path at
-# this point it is safer you ask directly where the *source* tree is
-# and dig from there.
+#[=======================================================================[.rst:
+FindTCL
+-------
+
+TK_INTERNAL_PATH was removed.
+
+This module finds if Tcl is installed and determines where the include
+files and libraries are. It also determines what the name of the
+library is. This code sets the following variables:
+
+::
+
+ TCL_FOUND = Tcl was found
+ TK_FOUND = Tk was found
+ TCLTK_FOUND = Tcl and Tk were found
+ TCL_LIBRARY = path to Tcl library (tcl tcl80)
+ TCL_INCLUDE_PATH = path to where tcl.h can be found
+ TCL_TCLSH = path to tclsh binary (tcl tcl80)
+ TK_LIBRARY = path to Tk library (tk tk80 etc)
+ TK_INCLUDE_PATH = path to where tk.h can be found
+ TK_WISH = full path to the wish executable
+
+
+
+In an effort to remove some clutter and clear up some issues for
+people who are not necessarily Tcl/Tk gurus/developers, some
+variables were moved or removed. Changes compared to CMake 2.4 are:
+
+::
+
+ => they were only useful for people writing Tcl/Tk extensions.
+ => these libs are not packaged by default with Tcl/Tk distributions.
+ Even when Tcl/Tk is built from source, several flavors of debug libs
+ are created and there is no real reason to pick a single one
+ specifically (say, amongst tcl84g, tcl84gs, or tcl84sgx).
+ Let's leave that choice to the user by allowing him to assign
+ TCL_LIBRARY to any Tcl library, debug or not.
+ => this ended up being only a Win32 variable, and there is a lot of
+ confusion regarding the location of this file in an installed Tcl/Tk
+ tree anyway (see 8.5 for example). If you need the internal path at
+ this point it is safer you ask directly where the *source* tree is
+ and dig from there.
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindFrameworks.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/FindTclsh.cmake)
@@ -82,11 +83,18 @@ set(TCLTK_POSSIBLE_LIB_PATHS
"${TK_LIBRARY_PATH}"
"${TCL_TCLSH_PATH_PARENT}/lib"
"${TK_WISH_PATH_PARENT}/lib"
- /usr/local/lib/tcl/tcl8.5
- /usr/local/lib/tcl/tk8.5
- /usr/local/lib/tcl/tcl8.4
- /usr/local/lib/tcl/tk8.4
- )
+)
+
+set(TCLTK_POSSIBLE_LIB_PATH_SUFFIXES
+ lib/tcl/tcl8.7
+ lib/tcl/tk8.7
+ lib/tcl/tcl8.6
+ lib/tcl/tk8.6
+ lib/tcl/tcl8.5
+ lib/tcl/tk8.5
+ lib/tcl/tcl8.4
+ lib/tcl/tk8.4
+)
if(WIN32)
get_filename_component(
@@ -111,26 +119,30 @@ find_library(TCL_LIBRARY
NAMES
tcl
tcl${TCL_LIBRARY_VERSION} tcl${TCL_TCLSH_VERSION} tcl${TK_WISH_VERSION}
- tcl86 tcl8.6
+ tcl87 tcl8.7 tcl87t tcl8.7t
+ tcl86 tcl8.6 tcl86t tcl8.6t
tcl85 tcl8.5
tcl84 tcl8.4
tcl83 tcl8.3
tcl82 tcl8.2
tcl80 tcl8.0
PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+ PATH_SUFFIXES ${TCLTK_POSSIBLE_LIB_PATH_SUFFIXES}
)
find_library(TK_LIBRARY
NAMES
tk
tk${TK_LIBRARY_VERSION} tk${TCL_TCLSH_VERSION} tk${TK_WISH_VERSION}
- tk86 tk8.6
+ tk87 tk8.7 tk87t tk8.7t
+ tk86 tk8.6 tk86t tk8.6t
tk85 tk8.5
tk84 tk8.4
tk83 tk8.3
tk82 tk8.2
tk80 tk8.0
PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+ PATH_SUFFIXES ${TCLTK_POSSIBLE_LIB_PATH_SUFFIXES}
)
CMAKE_FIND_FRAMEWORKS(Tcl)
@@ -164,20 +176,22 @@ set(TCLTK_POSSIBLE_INCLUDE_PATHS
${TK_FRAMEWORK_INCLUDES}
"${TCL_TCLSH_PATH_PARENT}/include"
"${TK_WISH_PATH_PARENT}/include"
- /usr/include/tcl${TK_LIBRARY_VERSION}
- /usr/include/tcl${TCL_LIBRARY_VERSION}
- /usr/include/tcl8.6
- /usr/include/tcl8.5
- /usr/include/tcl8.4
- /usr/include/tcl8.3
- /usr/include/tcl8.2
- /usr/include/tcl8.0
- /usr/local/include/tcl8.6
- /usr/local/include/tk8.6
- /usr/local/include/tcl8.5
- /usr/local/include/tk8.5
- /usr/local/include/tcl8.4
- /usr/local/include/tk8.4
+ )
+
+set(TCLTK_POSSIBLE_INCLUDE_PATH_SUFFIXES
+ include/tcl${TK_LIBRARY_VERSION}
+ include/tcl${TCL_LIBRARY_VERSION}
+ include/tcl8.7
+ include/tk8.7
+ include/tcl8.6
+ include/tk8.6
+ include/tcl8.5
+ include/tk8.5
+ include/tcl8.4
+ include/tk8.4
+ include/tcl8.3
+ include/tcl8.2
+ include/tcl8.0
)
if(WIN32)
@@ -198,11 +212,13 @@ endif()
find_path(TCL_INCLUDE_PATH
NAMES tcl.h
HINTS ${TCLTK_POSSIBLE_INCLUDE_PATHS}
+ PATH_SUFFIXES ${TCLTK_POSSIBLE_INCLUDE_PATH_SUFFIXES}
)
find_path(TK_INCLUDE_PATH
NAMES tk.h
HINTS ${TCLTK_POSSIBLE_INCLUDE_PATHS}
+ PATH_SUFFIXES ${TCLTK_POSSIBLE_INCLUDE_PATH_SUFFIXES}
)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake
index b622ca61c..00a3a415a 100644
--- a/Modules/FindTIFF.cmake
+++ b/Modules/FindTIFF.cmake
@@ -1,43 +1,44 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindTIFF
-# --------
-#
-# Find the TIFF library (libtiff).
-#
-# Imported targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the following :prop_tgt:`IMPORTED` targets:
-#
-# ``TIFF::TIFF``
-# The TIFF library, if found.
-#
-# Result variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module will set the following variables in your project:
-#
-# ``TIFF_FOUND``
-# true if the TIFF headers and libraries were found
-# ``TIFF_INCLUDE_DIR``
-# the directory containing the TIFF headers
-# ``TIFF_INCLUDE_DIRS``
-# the directory containing the TIFF headers
-# ``TIFF_LIBRARIES``
-# TIFF libraries to be linked
-#
-# Cache variables
-# ^^^^^^^^^^^^^^^
-#
-# The following cache variables may also be set:
-#
-# ``TIFF_INCLUDE_DIR``
-# the directory containing the TIFF headers
-# ``TIFF_LIBRARY``
-# the path to the TIFF library
+#[=======================================================================[.rst:
+FindTIFF
+--------
+
+Find the TIFF library (``libtiff``).
+
+Imported targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` targets:
+
+``TIFF::TIFF``
+ The TIFF library, if found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``TIFF_FOUND``
+ true if the TIFF headers and libraries were found
+``TIFF_INCLUDE_DIR``
+ the directory containing the TIFF headers
+``TIFF_INCLUDE_DIRS``
+ the directory containing the TIFF headers
+``TIFF_LIBRARIES``
+ TIFF libraries to be linked
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``TIFF_INCLUDE_DIR``
+ the directory containing the TIFF headers
+``TIFF_LIBRARY``
+ the path to the TIFF library
+#]=======================================================================]
find_path(TIFF_INCLUDE_DIR tiff.h)
diff --git a/Modules/FindTclStub.cmake b/Modules/FindTclStub.cmake
index 9711bd6f8..8f634809e 100644
--- a/Modules/FindTclStub.cmake
+++ b/Modules/FindTclStub.cmake
@@ -1,48 +1,49 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindTclStub
-# -----------
-#
-# TCL_STUB_LIBRARY_DEBUG and TK_STUB_LIBRARY_DEBUG were removed.
-#
-# This module finds Tcl stub libraries. It first finds Tcl include
-# files and libraries by calling FindTCL.cmake. How to Use the Tcl
-# Stubs Library:
-#
-# ::
-#
-# http://tcl.activestate.com/doc/howto/stubs.html
-#
-# Using Stub Libraries:
-#
-# ::
-#
-# http://safari.oreilly.com/0130385603/ch48lev1sec3
-#
-# This code sets the following variables:
-#
-# ::
-#
-# TCL_STUB_LIBRARY = path to Tcl stub library
-# TK_STUB_LIBRARY = path to Tk stub library
-# TTK_STUB_LIBRARY = path to ttk stub library
-#
-#
-#
-# In an effort to remove some clutter and clear up some issues for
-# people who are not necessarily Tcl/Tk gurus/developpers, some
-# variables were moved or removed. Changes compared to CMake 2.4 are:
-#
-# ::
-#
-# => these libs are not packaged by default with Tcl/Tk distributions.
-# Even when Tcl/Tk is built from source, several flavors of debug libs
-# are created and there is no real reason to pick a single one
-# specifically (say, amongst tclstub84g, tclstub84gs, or tclstub84sgx).
-# Let's leave that choice to the user by allowing him to assign
-# TCL_STUB_LIBRARY to any Tcl library, debug or not.
+#[=======================================================================[.rst:
+FindTclStub
+-----------
+
+TCL_STUB_LIBRARY_DEBUG and TK_STUB_LIBRARY_DEBUG were removed.
+
+This module finds Tcl stub libraries. It first finds Tcl include
+files and libraries by calling FindTCL.cmake. How to Use the Tcl
+Stubs Library:
+
+::
+
+ http://tcl.activestate.com/doc/howto/stubs.html
+
+Using Stub Libraries:
+
+::
+
+ http://safari.oreilly.com/0130385603/ch48lev1sec3
+
+This code sets the following variables:
+
+::
+
+ TCL_STUB_LIBRARY = path to Tcl stub library
+ TK_STUB_LIBRARY = path to Tk stub library
+ TTK_STUB_LIBRARY = path to ttk stub library
+
+
+
+In an effort to remove some clutter and clear up some issues for
+people who are not necessarily Tcl/Tk gurus/developers, some
+variables were moved or removed. Changes compared to CMake 2.4 are:
+
+::
+
+ => these libs are not packaged by default with Tcl/Tk distributions.
+ Even when Tcl/Tk is built from source, several flavors of debug libs
+ are created and there is no real reason to pick a single one
+ specifically (say, amongst tclstub84g, tclstub84gs, or tclstub84sgx).
+ Let's leave that choice to the user by allowing him to assign
+ TCL_STUB_LIBRARY to any Tcl library, debug or not.
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/FindTCL.cmake)
@@ -101,6 +102,7 @@ find_library(TCL_STUB_LIBRARY
NAMES
tclstub
tclstub${TK_LIBRARY_VERSION} tclstub${TCL_TCLSH_VERSION} tclstub${TK_WISH_VERSION}
+ tclstub87 tclstub8.7
tclstub86 tclstub8.6
tclstub85 tclstub8.5
tclstub84 tclstub8.4
@@ -114,6 +116,7 @@ find_library(TK_STUB_LIBRARY
NAMES
tkstub
tkstub${TCL_LIBRARY_VERSION} tkstub${TCL_TCLSH_VERSION} tkstub${TK_WISH_VERSION}
+ tkstub87 tkstub8.7
tkstub86 tkstub8.6
tkstub85 tkstub8.5
tkstub84 tkstub8.4
diff --git a/Modules/FindTclsh.cmake b/Modules/FindTclsh.cmake
index 9fcb41cb4..82be473b1 100644
--- a/Modules/FindTclsh.cmake
+++ b/Modules/FindTclsh.cmake
@@ -1,23 +1,24 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindTclsh
-# ---------
-#
-# Find tclsh
-#
-# This module finds if TCL is installed and determines where the include
-# files and libraries are. It also determines what the name of the
-# library is. This code sets the following variables:
-#
-# ::
-#
-# TCLSH_FOUND = TRUE if tclsh has been found
-# TCL_TCLSH = the path to the tclsh executable
-#
-# In cygwin, look for the cygwin version first. Don't look for it later
-# to avoid finding the cygwin version on a Win32 build.
+#[=======================================================================[.rst:
+FindTclsh
+---------
+
+Find tclsh
+
+This module finds if TCL is installed and determines where the include
+files and libraries are. It also determines what the name of the
+library is. This code sets the following variables:
+
+::
+
+ TCLSH_FOUND = TRUE if tclsh has been found
+ TCL_TCLSH = the path to the tclsh executable
+
+In cygwin, look for the cygwin version first. Don't look for it later
+to avoid finding the cygwin version on a Win32 build.
+#]=======================================================================]
if(CYGWIN)
find_program(TCL_TCLSH NAMES cygtclsh83 cygtclsh80)
@@ -68,6 +69,7 @@ endif()
set(TCL_TCLSH_NAMES
tclsh
tclsh${TCL_LIBRARY_VERSION} tclsh${TK_LIBRARY_VERSION} tclsh${TK_WISH_VERSION}
+ tclsh87 tclsh8.7
tclsh86 tclsh8.6
tclsh85 tclsh8.5
tclsh84 tclsh8.4
@@ -82,11 +84,11 @@ find_program(TCL_TCLSH
)
if(TCL_TCLSH)
- execute_process(COMMAND "${CMAKE_COMMAND}" -E echo puts "\$tcl_version"
- COMMAND "${TCL_TCLSH}"
- OUTPUT_VARIABLE TCLSH_VERSION_STRING
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE)
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E echo puts "\$tcl_version"
+ COMMAND "${TCL_TCLSH}"
+ OUTPUT_VARIABLE TCLSH_VERSION_STRING
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index 2c6a58beb..b0c91b2ac 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -1,64 +1,75 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindThreads
-# -----------
-#
-# This module determines the thread library of the system.
-#
-# The following variables are set
-#
-# ::
-#
-# CMAKE_THREAD_LIBS_INIT - the thread library
-# CMAKE_USE_SPROC_INIT - are we using sproc?
-# CMAKE_USE_WIN32_THREADS_INIT - using WIN32 threads?
-# CMAKE_USE_PTHREADS_INIT - are we using pthreads
-# CMAKE_HP_PTHREADS_INIT - are we using hp pthreads
-#
-# The following import target is created
-#
-# ::
-#
-# Threads::Threads
-#
-# For systems with multiple thread libraries, caller can set
-#
-# ::
-#
-# CMAKE_THREAD_PREFER_PTHREAD
-#
-# If the use of the -pthread compiler and linker flag is preferred then the
-# caller can set
-#
-# ::
-#
-# THREADS_PREFER_PTHREAD_FLAG
-#
-# Please note that the compiler flag can only be used with the imported
-# target. Use of both the imported target as well as this switch is highly
-# recommended for new code.
+#[=======================================================================[.rst:
+FindThreads
+-----------
+
+This module determines the thread library of the system.
+
+The following variables are set
+
+::
+
+ CMAKE_THREAD_LIBS_INIT - the thread library
+ CMAKE_USE_WIN32_THREADS_INIT - using WIN32 threads?
+ CMAKE_USE_PTHREADS_INIT - are we using pthreads
+ CMAKE_HP_PTHREADS_INIT - are we using hp pthreads
+
+The following import target is created
+
+::
+
+ Threads::Threads
+
+If the use of the -pthread compiler and linker flag is preferred then the
+caller can set
+
+::
+
+ THREADS_PREFER_PTHREAD_FLAG
+
+The compiler flag can only be used with the imported
+target. Use of both the imported target as well as this switch is highly
+recommended for new code.
+#]=======================================================================]
include (CheckLibraryExists)
-include (CheckSymbolExists)
set(Threads_FOUND FALSE)
set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
set(CMAKE_REQUIRED_QUIET ${Threads_FIND_QUIETLY})
if(CMAKE_C_COMPILER_LOADED)
include (CheckIncludeFile)
+ include (CheckCSourceCompiles)
elseif(CMAKE_CXX_COMPILER_LOADED)
include (CheckIncludeFileCXX)
+ include (CheckCXXSourceCompiles)
else()
message(FATAL_ERROR "FindThreads only works if either C or CXX language is enabled")
endif()
-# Do we have sproc?
-if(CMAKE_SYSTEM_NAME MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD)
- include (CheckIncludeFiles)
- CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h" CMAKE_HAVE_SPROC_H)
-endif()
+# simple pthread test code
+set(PTHREAD_C_CXX_TEST_SOURCE [====[
+#include <pthread.h>
+
+void* test_func(void* data)
+{
+ return data;
+}
+
+int main(void)
+{
+ pthread_t thread;
+ pthread_create(&thread, NULL, test_func, NULL);
+ pthread_detach(thread);
+ pthread_join(thread, NULL);
+ pthread_atfork(NULL, NULL, NULL);
+ pthread_exit(NULL);
+
+ return 0;
+}
+]====])
# Internal helper macro.
# Do NOT even think about using it outside of this file!
@@ -86,23 +97,16 @@ macro(_check_pthreads_flag)
set(_threads_src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindThreads/CheckForPthreads.cxx)
configure_file(${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c "${_threads_src}" COPYONLY)
endif()
- try_run(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG
+ try_compile(THREADS_HAVE_PTHREAD_ARG
${CMAKE_BINARY_DIR}
${_threads_src}
CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread
- COMPILE_OUTPUT_VARIABLE OUTPUT)
+ OUTPUT_VARIABLE OUTPUT)
unset(_threads_src)
if(THREADS_HAVE_PTHREAD_ARG)
- if(THREADS_PTHREAD_ARG STREQUAL "2")
- set(Threads_FOUND TRUE)
- message(STATUS "Check if compiler accepts -pthread - yes")
- else()
- message(STATUS "Check if compiler accepts -pthread - no")
- file(APPEND
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining if compiler accepts -pthread returned ${THREADS_PTHREAD_ARG} instead of 2. The compiler had the following output:\n${OUTPUT}\n\n")
- endif()
+ set(Threads_FOUND TRUE)
+ message(STATUS "Check if compiler accepts -pthread - yes")
else()
message(STATUS "Check if compiler accepts -pthread - no")
file(APPEND
@@ -119,53 +123,57 @@ macro(_check_pthreads_flag)
endif()
endmacro()
-if(CMAKE_HAVE_SPROC_H AND NOT CMAKE_THREAD_PREFER_PTHREAD)
- # We have sproc
- set(CMAKE_USE_SPROC_INIT 1)
+# Do we have pthreads?
+if(CMAKE_C_COMPILER_LOADED)
+ CHECK_INCLUDE_FILE("pthread.h" CMAKE_HAVE_PTHREAD_H)
else()
- # Do we have pthreads?
- if(CMAKE_C_COMPILER_LOADED)
- CHECK_INCLUDE_FILE("pthread.h" CMAKE_HAVE_PTHREAD_H)
- else()
- CHECK_INCLUDE_FILE_CXX("pthread.h" CMAKE_HAVE_PTHREAD_H)
- endif()
- if(CMAKE_HAVE_PTHREAD_H)
-
- #
- # We have pthread.h
- # Let's check for the library now.
- #
- set(CMAKE_HAVE_THREADS_LIBRARY)
- if(NOT THREADS_HAVE_PTHREAD_ARG)
- # Check if pthread functions are in normal C library
- CHECK_SYMBOL_EXISTS(pthread_create pthread.h CMAKE_HAVE_LIBC_CREATE)
- if(CMAKE_HAVE_LIBC_CREATE)
- set(CMAKE_THREAD_LIBS_INIT "")
- set(CMAKE_HAVE_THREADS_LIBRARY 1)
- set(Threads_FOUND TRUE)
- else()
+ CHECK_INCLUDE_FILE_CXX("pthread.h" CMAKE_HAVE_PTHREAD_H)
+endif()
- # Check for -pthread first if enabled. This is the recommended
- # way, but not backwards compatible as one must also pass -pthread
- # as compiler flag then.
- if (THREADS_PREFER_PTHREAD_FLAG)
- _check_pthreads_flag()
- endif ()
-
- _check_threads_lib(pthreads pthread_create CMAKE_HAVE_PTHREADS_CREATE)
- _check_threads_lib(pthread pthread_create CMAKE_HAVE_PTHREAD_CREATE)
- if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
- # On sun also check for -lthread
- _check_threads_lib(thread thr_create CMAKE_HAVE_THR_CREATE)
- endif()
+if(CMAKE_HAVE_PTHREAD_H)
+ #
+ # We have pthread.h
+ # Let's check for the library now.
+ #
+ set(CMAKE_HAVE_THREADS_LIBRARY)
+ if(NOT THREADS_HAVE_PTHREAD_ARG)
+ # Check if pthread functions are in normal C library.
+ # We list some pthread functions in PTHREAD_C_CXX_TEST_SOURCE test code.
+ # If the pthread functions already exist in C library, we could just use
+ # them instead of linking to the additional pthread library.
+ if(CMAKE_C_COMPILER_LOADED)
+ CHECK_C_SOURCE_COMPILES("${PTHREAD_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_PTHREAD)
+ elseif(CMAKE_CXX_COMPILER_LOADED)
+ CHECK_CXX_SOURCE_COMPILES("${PTHREAD_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_PTHREAD)
+ endif()
+ if(CMAKE_HAVE_LIBC_PTHREAD)
+ set(CMAKE_THREAD_LIBS_INIT "")
+ set(CMAKE_HAVE_THREADS_LIBRARY 1)
+ set(Threads_FOUND TRUE)
+ else()
+ # Check for -pthread first if enabled. This is the recommended
+ # way, but not backwards compatible as one must also pass -pthread
+ # as compiler flag then.
+ if (THREADS_PREFER_PTHREAD_FLAG)
+ _check_pthreads_flag()
+ endif ()
+
+ if(CMAKE_SYSTEM MATCHES "GHS-MULTI")
+ _check_threads_lib(posix pthread_create CMAKE_HAVE_PTHREADS_CREATE)
+ endif()
+ _check_threads_lib(pthreads pthread_create CMAKE_HAVE_PTHREADS_CREATE)
+ _check_threads_lib(pthread pthread_create CMAKE_HAVE_PTHREAD_CREATE)
+ if(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+ # On sun also check for -lthread
+ _check_threads_lib(thread thr_create CMAKE_HAVE_THR_CREATE)
endif()
endif()
-
- _check_pthreads_flag()
endif()
+
+ _check_pthreads_flag()
endif()
-if(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_CREATE)
+if(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_PTHREAD)
set(CMAKE_USE_PTHREADS_INIT 1)
set(Threads_FOUND TRUE)
endif()
@@ -215,7 +223,9 @@ if(THREADS_FOUND AND NOT TARGET Threads::Threads)
add_library(Threads::Threads INTERFACE IMPORTED)
if(THREADS_HAVE_PTHREAD_ARG)
- set_property(TARGET Threads::Threads PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread")
+ set_property(TARGET Threads::Threads
+ PROPERTY INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:-Xcompiler -pthread>"
+ "$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:-pthread>")
endif()
if(CMAKE_THREAD_LIBS_INIT)
diff --git a/Modules/FindUnixCommands.cmake b/Modules/FindUnixCommands.cmake
index d2b6a4d7f..2513f5c29 100644
--- a/Modules/FindUnixCommands.cmake
+++ b/Modules/FindUnixCommands.cmake
@@ -1,24 +1,22 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindUnixCommands
-# ----------------
-#
-# Find Unix commands, including the ones from Cygwin
-#
-# This module looks for the Unix commands bash, cp, gzip, mv, rm, and tar
-# and stores the result in the variables BASH, CP, GZIP, MV, RM, and TAR.
+#[=======================================================================[.rst:
+FindUnixCommands
+----------------
+
+Find Unix commands, including the ones from Cygwin
+
+This module looks for the Unix commands ``bash``, ``cp``, ``gzip``,
+``mv``, ``rm``, and ``tar`` and stores the result in the variables
+``BASH``, ``CP``, ``GZIP``, ``MV``, ``RM``, and ``TAR``.
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake)
find_program(BASH
bash
${CYGWIN_INSTALL_PATH}/bin
- /bin
- /usr/bin
- /usr/local/bin
- /sbin
)
mark_as_advanced(
BASH
@@ -27,10 +25,6 @@ mark_as_advanced(
find_program(CP
cp
${CYGWIN_INSTALL_PATH}/bin
- /bin
- /usr/bin
- /usr/local/bin
- /sbin
)
mark_as_advanced(
CP
@@ -39,10 +33,6 @@ mark_as_advanced(
find_program(GZIP
gzip
${CYGWIN_INSTALL_PATH}/bin
- /bin
- /usr/bin
- /usr/local/bin
- /sbin
)
mark_as_advanced(
GZIP
@@ -51,10 +41,6 @@ mark_as_advanced(
find_program(MV
mv
${CYGWIN_INSTALL_PATH}/bin
- /bin
- /usr/bin
- /usr/local/bin
- /sbin
)
mark_as_advanced(
MV
@@ -63,10 +49,6 @@ mark_as_advanced(
find_program(RM
rm
${CYGWIN_INSTALL_PATH}/bin
- /bin
- /usr/bin
- /usr/local/bin
- /sbin
)
mark_as_advanced(
RM
@@ -78,10 +60,6 @@ find_program(TAR
gtar
PATH
${CYGWIN_INSTALL_PATH}/bin
- /bin
- /usr/bin
- /usr/local/bin
- /sbin
)
mark_as_advanced(
TAR
diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake
index 1f4c8ade9..55da55f76 100644
--- a/Modules/FindVulkan.cmake
+++ b/Modules/FindVulkan.cmake
@@ -1,32 +1,34 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindVulkan
-# ----------
-#
-# Try to find Vulkan
-#
-# IMPORTED Targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines :prop_tgt:`IMPORTED` target ``Vulkan::Vulkan``, if
-# Vulkan has been found.
-#
-# Result Variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the following variables::
-#
-# Vulkan_FOUND - True if Vulkan was found
-# Vulkan_INCLUDE_DIRS - include directories for Vulkan
-# Vulkan_LIBRARIES - link against this library to use Vulkan
-#
-# The module will also define two cache variables::
-#
-# Vulkan_INCLUDE_DIR - the Vulkan include directory
-# Vulkan_LIBRARY - the path to the Vulkan library
-#
+#[=======================================================================[.rst:
+FindVulkan
+----------
+
+Find Vulkan, which is a low-overhead, cross-platform 3D graphics
+and computing API.
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``Vulkan::Vulkan``, if
+Vulkan has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables::
+
+ Vulkan_FOUND - "True" if Vulkan was found
+ Vulkan_INCLUDE_DIRS - include directories for Vulkan
+ Vulkan_LIBRARIES - link against this library to use Vulkan
+
+The module will also define two cache variables::
+
+ Vulkan_INCLUDE_DIR - the Vulkan include directory
+ Vulkan_LIBRARY - the path to the Vulkan library
+
+#]=======================================================================]
if(WIN32)
find_path(Vulkan_INCLUDE_DIR
@@ -65,7 +67,7 @@ endif()
set(Vulkan_LIBRARIES ${Vulkan_LIBRARY})
set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR})
-include(FindPackageHandleStandardArgs)
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(Vulkan
DEFAULT_MSG
Vulkan_LIBRARY Vulkan_INCLUDE_DIR)
diff --git a/Modules/FindWget.cmake b/Modules/FindWget.cmake
index 4fcb2fa37..bd01ec201 100644
--- a/Modules/FindWget.cmake
+++ b/Modules/FindWget.cmake
@@ -1,18 +1,19 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindWget
-# --------
-#
-# Find wget
-#
-# This module looks for wget. This module defines the following values:
-#
-# ::
-#
-# WGET_EXECUTABLE: the full path to the wget tool.
-# WGET_FOUND: True if wget has been found.
+#[=======================================================================[.rst:
+FindWget
+--------
+
+Find wget
+
+This module looks for wget. This module defines the following values:
+
+::
+
+ WGET_EXECUTABLE: the full path to the wget tool.
+ WGET_FOUND: True if wget has been found.
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake)
diff --git a/Modules/FindWish.cmake b/Modules/FindWish.cmake
index b64b04138..b332bde9b 100644
--- a/Modules/FindWish.cmake
+++ b/Modules/FindWish.cmake
@@ -1,23 +1,24 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindWish
-# --------
-#
-# Find wish installation
-#
-# This module finds if TCL is installed and determines where the include
-# files and libraries are. It also determines what the name of the
-# library is. This code sets the following variables:
-#
-# ::
-#
-# TK_WISH = the path to the wish executable
-#
-#
-#
-# if UNIX is defined, then it will look for the cygwin version first
+#[=======================================================================[.rst:
+FindWish
+--------
+
+Find wish installation
+
+This module finds if TCL is installed and determines where the include
+files and libraries are. It also determines what the name of the
+library is. This code sets the following variables:
+
+::
+
+ TK_WISH = the path to the wish executable
+
+
+
+if UNIX is defined, then it will look for the cygwin version first
+#]=======================================================================]
if(UNIX)
find_program(TK_WISH cygwish80 )
diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake
index f7dfc8257..b28dd125d 100644
--- a/Modules/FindX11.cmake
+++ b/Modules/FindX11.cmake
@@ -1,58 +1,59 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindX11
-# -------
-#
-# Find X11 installation
-#
-# Try to find X11 on UNIX systems. The following values are defined
-#
-# ::
-#
-# X11_FOUND - True if X11 is available
-# X11_INCLUDE_DIR - include directories to use X11
-# X11_LIBRARIES - link against these to use X11
-#
-# and also the following more fine grained variables:
-#
-# ::
-#
-# X11_ICE_INCLUDE_PATH, X11_ICE_LIB, X11_ICE_FOUND
-# X11_SM_INCLUDE_PATH, X11_SM_LIB, X11_SM_FOUND
-# X11_X11_INCLUDE_PATH, X11_X11_LIB
-# X11_Xaccessrules_INCLUDE_PATH, X11_Xaccess_FOUND
-# X11_Xaccessstr_INCLUDE_PATH, X11_Xaccess_FOUND
-# X11_Xau_INCLUDE_PATH, X11_Xau_LIB, X11_Xau_FOUND
-# X11_Xcomposite_INCLUDE_PATH, X11_Xcomposite_LIB, X11_Xcomposite_FOUND
-# X11_Xcursor_INCLUDE_PATH, X11_Xcursor_LIB, X11_Xcursor_FOUND
-# X11_Xdamage_INCLUDE_PATH, X11_Xdamage_LIB, X11_Xdamage_FOUND
-# X11_Xdmcp_INCLUDE_PATH, X11_Xdmcp_LIB, X11_Xdmcp_FOUND
-# X11_Xext_LIB, X11_Xext_FOUND
-# 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_xf86misc_INCLUDE_PATH, X11_Xxf86misc_LIB, X11_xf86misc_FOUND
-# X11_xf86vmode_INCLUDE_PATH, X11_Xxf86vm_LIB X11_xf86vmode_FOUND
-# X11_Xfixes_INCLUDE_PATH, X11_Xfixes_LIB, X11_Xfixes_FOUND
-# X11_Xft_INCLUDE_PATH, X11_Xft_LIB, X11_Xft_FOUND
-# X11_Xi_INCLUDE_PATH, X11_Xi_LIB, X11_Xi_FOUND
-# X11_Xinerama_INCLUDE_PATH, X11_Xinerama_LIB, X11_Xinerama_FOUND
-# X11_Xinput_INCLUDE_PATH, X11_Xinput_LIB, X11_Xinput_FOUND
-# X11_Xkb_INCLUDE_PATH, X11_Xkb_FOUND
-# X11_Xkblib_INCLUDE_PATH, X11_Xkb_FOUND
-# X11_Xkbfile_INCLUDE_PATH, X11_Xkbfile_LIB, X11_Xkbfile_FOUND
-# X11_Xmu_INCLUDE_PATH, X11_Xmu_LIB, X11_Xmu_FOUND
-# X11_Xpm_INCLUDE_PATH, X11_Xpm_LIB, X11_Xpm_FOUND
-# X11_XTest_INCLUDE_PATH, X11_XTest_LIB, X11_XTest_FOUND
-# X11_Xrandr_INCLUDE_PATH, X11_Xrandr_LIB, X11_Xrandr_FOUND
-# X11_Xrender_INCLUDE_PATH, X11_Xrender_LIB, X11_Xrender_FOUND
-# X11_Xscreensaver_INCLUDE_PATH, X11_Xscreensaver_LIB, X11_Xscreensaver_FOUND
-# X11_Xt_INCLUDE_PATH, X11_Xt_LIB, X11_Xt_FOUND
-# X11_Xutil_INCLUDE_PATH, X11_Xutil_FOUND
-# X11_Xv_INCLUDE_PATH, X11_Xv_LIB, X11_Xv_FOUND
-# X11_XSync_INCLUDE_PATH, (in X11_Xext_LIB), X11_XSync_FOUND
+#[=======================================================================[.rst:
+FindX11
+-------
+
+Find X11 installation
+
+Try to find X11 on UNIX systems. The following values are defined
+
+::
+
+ X11_FOUND - True if X11 is available
+ X11_INCLUDE_DIR - include directories to use X11
+ X11_LIBRARIES - link against these to use X11
+
+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_Xaccessrules_INCLUDE_PATH,
+ X11_Xaccessstr_INCLUDE_PATH, X11_Xaccess_FOUND
+ X11_Xau_INCLUDE_PATH, X11_Xau_LIB, X11_Xau_FOUND, X11::Xau
+ 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_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
+#]=======================================================================]
if (UNIX)
set(X11_FOUND 0)
@@ -97,31 +98,38 @@ if (UNIX)
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})
find_path(X11_Xdmcp_INCLUDE_PATH X11/Xdmcp.h ${X11_INC_SEARCH_PATH})
+ find_path(X11_Xext_INCLUDE_PATH X11/extensions/Xext.h ${X11_INC_SEARCH_PATH})
find_path(X11_dpms_INCLUDE_PATH X11/extensions/dpms.h ${X11_INC_SEARCH_PATH})
- find_path(X11_xf86misc_INCLUDE_PATH X11/extensions/xf86misc.h ${X11_INC_SEARCH_PATH})
- find_path(X11_xf86vmode_INCLUDE_PATH X11/extensions/xf86vmode.h ${X11_INC_SEARCH_PATH})
+ find_path(X11_Xxf86misc_INCLUDE_PATH X11/extensions/xf86misc.h ${X11_INC_SEARCH_PATH})
+ find_path(X11_Xxf86vm_INCLUDE_PATH X11/extensions/xf86vmode.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xfixes_INCLUDE_PATH X11/extensions/Xfixes.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xft_INCLUDE_PATH X11/Xft/Xft.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xi_INCLUDE_PATH X11/extensions/XInput.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xinerama_INCLUDE_PATH X11/extensions/Xinerama.h ${X11_INC_SEARCH_PATH})
- find_path(X11_Xinput_INCLUDE_PATH X11/extensions/XInput.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xkb_INCLUDE_PATH X11/extensions/XKB.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xkblib_INCLUDE_PATH X11/XKBlib.h ${X11_INC_SEARCH_PATH})
- find_path(X11_Xkbfile_INCLUDE_PATH X11/extensions/XKBfile.h ${X11_INC_SEARCH_PATH})
+ find_path(X11_xkbfile_INCLUDE_PATH X11/extensions/XKBfile.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xmu_INCLUDE_PATH X11/Xmu/Xmu.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xpm_INCLUDE_PATH X11/xpm.h ${X11_INC_SEARCH_PATH})
- find_path(X11_XTest_INCLUDE_PATH X11/extensions/XTest.h ${X11_INC_SEARCH_PATH})
+ find_path(X11_Xtst_INCLUDE_PATH X11/extensions/XTest.h ${X11_INC_SEARCH_PATH})
find_path(X11_XShm_INCLUDE_PATH X11/extensions/XShm.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xrandr_INCLUDE_PATH X11/extensions/Xrandr.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xrender_INCLUDE_PATH X11/extensions/Xrender.h ${X11_INC_SEARCH_PATH})
find_path(X11_XRes_INCLUDE_PATH X11/extensions/XRes.h ${X11_INC_SEARCH_PATH})
- find_path(X11_Xscreensaver_INCLUDE_PATH X11/extensions/scrnsaver.h ${X11_INC_SEARCH_PATH})
+ find_path(X11_Xss_INCLUDE_PATH X11/extensions/scrnsaver.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xshape_INCLUDE_PATH X11/extensions/shape.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xutil_INCLUDE_PATH X11/Xutil.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xt_INCLUDE_PATH X11/Intrinsic.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xv_INCLUDE_PATH X11/extensions/Xvlib.h ${X11_INC_SEARCH_PATH})
find_path(X11_XSync_INCLUDE_PATH X11/extensions/sync.h ${X11_INC_SEARCH_PATH})
+ # Backwards compatibility.
+ set(X11_Xinput_INCLUDE_PATH "${X11_Xi_INCLUDE_PATH}")
+ set(X11_xf86misc_INCLUDE_PATH "${X11_Xxf86misc_INCLUDE_PATH}")
+ set(X11_xf86vmode_INCLUDE_PATH "${X11_Xxf8vm_INCLUDE_PATH}")
+ set(X11_Xkbfile_INCLUDE_PATH "${X11_xkbfile_INCLUDE_PATH}")
+ set(X11_XTest_INCLUDE_PATH "${X11_Xtst_INCLUDE_PATH}")
+ set(X11_Xscreensaver_INCLUDE_PATH "${X11_Xss_INCLUDE_PATH}")
find_library(X11_X11_LIB X11 ${X11_LIB_SEARCH_PATH})
@@ -138,20 +146,25 @@ if (UNIX)
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_Xinput_LIB Xi ${X11_LIB_SEARCH_PATH})
- find_library(X11_Xkbfile_LIB xkbfile ${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_Xscreensaver_LIB Xss ${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_XTest_LIB Xtst ${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}")
+ set(X11_Xkbfile_LIB "${X11_xkbfile_LIB}")
+ set(X11_XTest_LIB "${X11_Xtst_LIB}")
+ set(X11_Xscreensaver_LIB "${X11_Xss_LIB}")
+
set(X11_LIBRARY_DIR "")
if(X11_X11_LIB)
get_filename_component(X11_LIBRARY_DIR ${X11_X11_LIB} PATH)
@@ -159,31 +172,31 @@ if (UNIX)
set(X11_INCLUDE_DIR) # start with empty list
if(X11_X11_INCLUDE_PATH)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_X11_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_X11_INCLUDE_PATH})
endif()
if(X11_Xlib_INCLUDE_PATH)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xlib_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xlib_INCLUDE_PATH})
endif()
if(X11_Xutil_INCLUDE_PATH)
set(X11_Xutil_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xutil_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xutil_INCLUDE_PATH})
endif()
if(X11_Xshape_INCLUDE_PATH)
set(X11_Xshape_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xshape_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xshape_INCLUDE_PATH})
endif()
set(X11_LIBRARIES) # start with empty list
if(X11_X11_LIB)
- set(X11_LIBRARIES ${X11_LIBRARIES} ${X11_X11_LIB})
+ list(APPEND X11_LIBRARIES ${X11_X11_LIB})
endif()
if(X11_Xext_LIB)
set(X11_Xext_FOUND TRUE)
- set(X11_LIBRARIES ${X11_LIBRARIES} ${X11_Xext_LIB})
+ list(APPEND X11_LIBRARIES ${X11_Xext_LIB})
endif()
if(X11_Xt_LIB AND X11_Xt_INCLUDE_PATH)
@@ -191,13 +204,17 @@ if (UNIX)
endif()
if(X11_Xft_LIB AND X11_Xft_INCLUDE_PATH)
- set(X11_Xft_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xft_INCLUDE_PATH})
+ find_package(Freetype QUIET)
+ find_package(Fontconfig QUIET)
+ if (FREETYPE_FOUND AND Fontconfig_FOUND)
+ set(X11_Xft_FOUND TRUE)
+ endif ()
+ list(APPEND X11_INCLUDE_DIR ${X11_Xft_INCLUDE_PATH})
endif()
if(X11_Xv_LIB AND X11_Xv_INCLUDE_PATH)
set(X11_Xv_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xv_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xv_INCLUDE_PATH})
endif()
if (X11_Xau_LIB AND X11_Xau_INCLUDE_PATH)
@@ -206,118 +223,124 @@ if (UNIX)
if (X11_Xdmcp_INCLUDE_PATH AND X11_Xdmcp_LIB)
set(X11_Xdmcp_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xdmcp_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xdmcp_INCLUDE_PATH})
endif ()
if (X11_Xaccessrules_INCLUDE_PATH AND X11_Xaccessstr_INCLUDE_PATH)
set(X11_Xaccess_FOUND TRUE)
set(X11_Xaccess_INCLUDE_PATH ${X11_Xaccessstr_INCLUDE_PATH})
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xaccess_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xaccess_INCLUDE_PATH})
endif ()
if (X11_Xpm_INCLUDE_PATH AND X11_Xpm_LIB)
set(X11_Xpm_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xpm_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xpm_INCLUDE_PATH})
endif ()
if (X11_Xcomposite_INCLUDE_PATH AND X11_Xcomposite_LIB)
set(X11_Xcomposite_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xcomposite_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xcomposite_INCLUDE_PATH})
endif ()
if (X11_Xdamage_INCLUDE_PATH AND X11_Xdamage_LIB)
set(X11_Xdamage_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xdamage_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xdamage_INCLUDE_PATH})
endif ()
if (X11_XShm_INCLUDE_PATH)
set(X11_XShm_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_XShm_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_XShm_INCLUDE_PATH})
endif ()
- if (X11_XTest_INCLUDE_PATH AND X11_XTest_LIB)
+ if (X11_Xtst_INCLUDE_PATH AND X11_Xtst_LIB)
+ set(X11_Xtst_FOUND TRUE)
+ # Backwards compatibility.
set(X11_XTest_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_XTest_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xtst_INCLUDE_PATH})
endif ()
if (X11_Xi_INCLUDE_PATH AND X11_Xi_LIB)
set(X11_Xi_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xi_INCLUDE_PATH})
+ # Backwards compatibility.
+ set(X11_Xinput_FOUND TRUE)
+ list(APPEND X11_INCLUDE_DIR ${X11_Xi_INCLUDE_PATH})
endif ()
if (X11_Xinerama_INCLUDE_PATH AND X11_Xinerama_LIB)
set(X11_Xinerama_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xinerama_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xinerama_INCLUDE_PATH})
endif ()
if (X11_Xfixes_INCLUDE_PATH AND X11_Xfixes_LIB)
set(X11_Xfixes_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xfixes_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xfixes_INCLUDE_PATH})
endif ()
if (X11_Xrender_INCLUDE_PATH AND X11_Xrender_LIB)
set(X11_Xrender_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xrender_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xrender_INCLUDE_PATH})
endif ()
if (X11_XRes_INCLUDE_PATH AND X11_XRes_LIB)
set(X11_XRes_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_XRes_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_XRes_INCLUDE_PATH})
endif ()
if (X11_Xrandr_INCLUDE_PATH AND X11_Xrandr_LIB)
set(X11_Xrandr_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xrandr_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xrandr_INCLUDE_PATH})
endif ()
- if (X11_xf86misc_INCLUDE_PATH AND X11_Xxf86misc_LIB)
+ if (X11_Xxf86misc_INCLUDE_PATH AND X11_Xxf86misc_LIB)
+ set(X11_Xxf86misc_FOUND TRUE)
+ # Backwards compatibility.
set(X11_xf86misc_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_xf86misc_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xxf86misc_INCLUDE_PATH})
endif ()
- if (X11_xf86vmode_INCLUDE_PATH AND X11_Xxf86vm_LIB)
+ if (X11_Xxf86vm_INCLUDE_PATH AND X11_Xxf86vm_LIB)
+ set(X11_Xxf86vm_FOUND TRUE)
+ # Backwards compatibility.
set(X11_xf86vmode_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_xf86vmode_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xxf86vm_INCLUDE_PATH})
endif ()
if (X11_Xcursor_INCLUDE_PATH AND X11_Xcursor_LIB)
set(X11_Xcursor_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xcursor_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xcursor_INCLUDE_PATH})
endif ()
- if (X11_Xscreensaver_INCLUDE_PATH AND X11_Xscreensaver_LIB)
+ if (X11_Xss_INCLUDE_PATH AND X11_Xss_LIB)
+ set(X11_Xss_FOUND TRUE)
set(X11_Xscreensaver_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xscreensaver_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xss_INCLUDE_PATH})
endif ()
if (X11_dpms_INCLUDE_PATH)
set(X11_dpms_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_dpms_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_dpms_INCLUDE_PATH})
endif ()
if (X11_Xkb_INCLUDE_PATH AND X11_Xkblib_INCLUDE_PATH AND X11_Xlib_INCLUDE_PATH)
set(X11_Xkb_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xkb_INCLUDE_PATH} )
+ list(APPEND X11_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH} )
endif ()
- if (X11_Xkbfile_INCLUDE_PATH AND X11_Xkbfile_LIB AND X11_Xlib_INCLUDE_PATH)
+ if (X11_xkbfile_INCLUDE_PATH AND X11_xkbfile_LIB AND X11_Xlib_INCLUDE_PATH)
+ set(X11_xkbfile_FOUND TRUE)
+ # Backwards compatibility.
set(X11_Xkbfile_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xkbfile_INCLUDE_PATH} )
+ list(APPEND X11_INCLUDE_DIR ${X11_xkbfile_INCLUDE_PATH} )
endif ()
if (X11_Xmu_INCLUDE_PATH AND X11_Xmu_LIB)
set(X11_Xmu_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xmu_INCLUDE_PATH})
- endif ()
-
- if (X11_Xinput_INCLUDE_PATH AND X11_Xinput_LIB)
- set(X11_Xinput_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xinput_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_Xmu_INCLUDE_PATH})
endif ()
if (X11_XSync_INCLUDE_PATH)
set(X11_XSync_FOUND TRUE)
- set(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_XSync_INCLUDE_PATH})
+ list(APPEND X11_INCLUDE_DIR ${X11_XSync_INCLUDE_PATH})
endif ()
if(X11_ICE_LIB AND X11_ICE_INCLUDE_PATH)
@@ -339,6 +362,11 @@ if (UNIX)
set(X11_FOUND 1)
endif ()
+ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+ find_package_handle_standard_args(X11
+ REQUIRED_VARS X11_X11_INCLUDE_PATH X11_X11_LIB
+ HANDLE_COMPONENTS)
+
if(X11_FOUND)
include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
@@ -351,69 +379,69 @@ if (UNIX)
set(X11_X_EXTRA_LIBS "")
# See if XOpenDisplay in X11 works by itself.
- CHECK_LIBRARY_EXISTS("${X11_LIBRARIES}" "XOpenDisplay" "${X11_LIBRARY_DIR}" X11_LIB_X11_SOLO)
+ check_library_exists("${X11_LIBRARIES}" "XOpenDisplay" "${X11_LIBRARY_DIR}" X11_LIB_X11_SOLO)
if(NOT X11_LIB_X11_SOLO)
# Find library needed for dnet_ntoa.
- CHECK_LIBRARY_EXISTS("dnet" "dnet_ntoa" "" X11_LIB_DNET_HAS_DNET_NTOA)
+ check_library_exists("dnet" "dnet_ntoa" "" X11_LIB_DNET_HAS_DNET_NTOA)
if (X11_LIB_DNET_HAS_DNET_NTOA)
- set (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -ldnet)
+ list(APPEND X11_X_EXTRA_LIBS -ldnet)
else ()
- CHECK_LIBRARY_EXISTS("dnet_stub" "dnet_ntoa" "" X11_LIB_DNET_STUB_HAS_DNET_NTOA)
+ check_library_exists("dnet_stub" "dnet_ntoa" "" X11_LIB_DNET_STUB_HAS_DNET_NTOA)
if (X11_LIB_DNET_STUB_HAS_DNET_NTOA)
- set (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -ldnet_stub)
+ list(APPEND X11_X_EXTRA_LIBS -ldnet_stub)
endif ()
endif ()
endif()
# Find library needed for gethostbyname.
- CHECK_FUNCTION_EXISTS("gethostbyname" CMAKE_HAVE_GETHOSTBYNAME)
+ check_function_exists("gethostbyname" CMAKE_HAVE_GETHOSTBYNAME)
if(NOT CMAKE_HAVE_GETHOSTBYNAME)
- CHECK_LIBRARY_EXISTS("nsl" "gethostbyname" "" CMAKE_LIB_NSL_HAS_GETHOSTBYNAME)
+ check_library_exists("nsl" "gethostbyname" "" CMAKE_LIB_NSL_HAS_GETHOSTBYNAME)
if (CMAKE_LIB_NSL_HAS_GETHOSTBYNAME)
- set (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lnsl)
+ list(APPEND X11_X_EXTRA_LIBS -lnsl)
else ()
- CHECK_LIBRARY_EXISTS("bsd" "gethostbyname" "" CMAKE_LIB_BSD_HAS_GETHOSTBYNAME)
+ check_library_exists("bsd" "gethostbyname" "" CMAKE_LIB_BSD_HAS_GETHOSTBYNAME)
if (CMAKE_LIB_BSD_HAS_GETHOSTBYNAME)
- set (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lbsd)
+ list(APPEND X11_X_EXTRA_LIBS -lbsd)
endif ()
endif ()
endif()
# Find library needed for connect.
- CHECK_FUNCTION_EXISTS("connect" CMAKE_HAVE_CONNECT)
+ check_function_exists("connect" CMAKE_HAVE_CONNECT)
if(NOT CMAKE_HAVE_CONNECT)
- CHECK_LIBRARY_EXISTS("socket" "connect" "" CMAKE_LIB_SOCKET_HAS_CONNECT)
+ check_library_exists("socket" "connect" "" CMAKE_LIB_SOCKET_HAS_CONNECT)
if (CMAKE_LIB_SOCKET_HAS_CONNECT)
- set (X11_X_EXTRA_LIBS -lsocket ${X11_X_EXTRA_LIBS})
+ list(INSERT X11_X_EXTRA_LIBS 0 -lsocket)
endif ()
endif()
# Find library needed for remove.
- CHECK_FUNCTION_EXISTS("remove" CMAKE_HAVE_REMOVE)
+ check_function_exists("remove" CMAKE_HAVE_REMOVE)
if(NOT CMAKE_HAVE_REMOVE)
- CHECK_LIBRARY_EXISTS("posix" "remove" "" CMAKE_LIB_POSIX_HAS_REMOVE)
+ check_library_exists("posix" "remove" "" CMAKE_LIB_POSIX_HAS_REMOVE)
if (CMAKE_LIB_POSIX_HAS_REMOVE)
- set (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lposix)
+ list(APPEND X11_X_EXTRA_LIBS -lposix)
endif ()
endif()
# Find library needed for shmat.
- CHECK_FUNCTION_EXISTS("shmat" CMAKE_HAVE_SHMAT)
+ check_function_exists("shmat" CMAKE_HAVE_SHMAT)
if(NOT CMAKE_HAVE_SHMAT)
- CHECK_LIBRARY_EXISTS("ipc" "shmat" "" CMAKE_LIB_IPS_HAS_SHMAT)
+ check_library_exists("ipc" "shmat" "" CMAKE_LIB_IPS_HAS_SHMAT)
if (CMAKE_LIB_IPS_HAS_SHMAT)
- set (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lipc)
+ list(APPEND X11_X_EXTRA_LIBS -lipc)
endif ()
endif()
endif()
if (X11_ICE_FOUND)
- CHECK_LIBRARY_EXISTS("ICE" "IceConnectionNumber" "${X11_LIBRARY_DIR}"
+ check_library_exists("ICE" "IceConnectionNumber" "${X11_LIBRARY_DIR}"
CMAKE_LIB_ICE_HAS_ICECONNECTIONNUMBER)
if(CMAKE_LIB_ICE_HAS_ICECONNECTIONNUMBER)
set (X11_X_PRE_LIBS ${X11_ICE_LIB})
if(X11_SM_LIB)
- set (X11_X_PRE_LIBS ${X11_SM_LIB} ${X11_X_PRE_LIBS})
+ list(INSERT X11_X_PRE_LIBS 0 ${X11_SM_LIB})
endif()
endif()
endif ()
@@ -421,18 +449,222 @@ if (UNIX)
# Build the final list of libraries.
set(X11_LIBRARIES ${X11_X_PRE_LIBS} ${X11_LIBRARIES} ${X11_X_EXTRA_LIBS})
- include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake)
- FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}"
- "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]")
- else ()
- if (X11_FIND_REQUIRED)
- message(FATAL_ERROR "Could not find X11")
+ if (NOT TARGET X11::X11)
+ add_library(X11::X11 UNKNOWN IMPORTED)
+ set_target_properties(X11::X11 PROPERTIES
+ IMPORTED_LOCATION "${X11_X11_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_X11_INCLUDE_PATH}")
endif ()
endif ()
+ if (X11_ICE_FOUND AND NOT TARGET X11::ICE)
+ add_library(X11::ICE UNKNOWN IMPORTED)
+ set_target_properties(X11::ICE PROPERTIES
+ IMPORTED_LOCATION "${X11_ICE_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_ICE_INCLUDE_PATH}")
+ endif ()
+
+ if (X11_SM_FOUND AND NOT TARGET X11::SM)
+ add_library(X11::SM UNKNOWN IMPORTED)
+ set_target_properties(X11::SM PROPERTIES
+ IMPORTED_LOCATION "${X11_SM_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_SM_INCLUDE_PATH}")
+ endif ()
+
+ if (X11_Xau_FOUND AND NOT TARGET X11::Xau)
+ add_library(X11::Xau UNKNOWN IMPORTED)
+ set_target_properties(X11::Xau PROPERTIES
+ IMPORTED_LOCATION "${X11_Xau_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xau_INCLUDE_PATH}")
+ endif ()
+
+ if (X11_Xcomposite_FOUND AND NOT TARGET X11::Xcomposite)
+ add_library(X11::Xcomposite UNKNOWN IMPORTED)
+ set_target_properties(X11::Xcomposite PROPERTIES
+ IMPORTED_LOCATION "${X11_Xcomposite_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xcomposite_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::X11")
+ endif ()
+
+ if (X11_Xcursor_FOUND AND NOT TARGET X11::Xcursor)
+ add_library(X11::Xcursor UNKNOWN IMPORTED)
+ set_target_properties(X11::Xcursor PROPERTIES
+ IMPORTED_LOCATION "${X11_Xcursor_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xcursor_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::Xrender;X11::Xfixes;X11::X11")
+ endif ()
+
+ if (X11_Xdamage_FOUND AND NOT TARGET X11::Xdamage)
+ add_library(X11::Xdamage UNKNOWN IMPORTED)
+ set_target_properties(X11::Xdamage PROPERTIES
+ IMPORTED_LOCATION "${X11_Xdamage_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xdamage_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::Xfixes;X11::X11")
+ endif ()
+
+ if (X11_Xdmcp_FOUND AND NOT TARGET X11::Xdmcp)
+ add_library(X11::Xdmcp UNKNOWN IMPORTED)
+ set_target_properties(X11::Xdmcp PROPERTIES
+ IMPORTED_LOCATION "${X11_Xdmcp_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xdmcp_INCLUDE_PATH}")
+ endif ()
+
+ if (X11_Xext_FOUND AND NOT TARGET X11::Xext)
+ add_library(X11::Xext UNKNOWN IMPORTED)
+ set_target_properties(X11::Xext PROPERTIES
+ IMPORTED_LOCATION "${X11_Xext_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xext_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::X11")
+ endif ()
+
+ if (X11_Xxf86misc_FOUND AND NOT TARGET X11::Xxf86misc)
+ add_library(X11::Xxf86misc UNKNOWN IMPORTED)
+ set_target_properties(X11::Xxf86misc PROPERTIES
+ IMPORTED_LOCATION "${X11_Xxf86misc_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xxf86misc_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::X11;X11::Xext")
+ endif ()
+
+ if (X11_Xxf86vm_FOUND AND NOT TARGET X11::Xxf86vm)
+ add_library(X11::Xxf86vm UNKNOWN IMPORTED)
+ set_target_properties(X11::Xxf86vm PROPERTIES
+ IMPORTED_LOCATION "${X11_Xxf86vm_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xxf86vm_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::X11;X11::Xext")
+ endif ()
+
+ if (X11_Xfixes_FOUND AND NOT TARGET X11::Xfixes)
+ add_library(X11::Xfixes UNKNOWN IMPORTED)
+ set_target_properties(X11::Xfixes PROPERTIES
+ IMPORTED_LOCATION "${X11_Xfixes_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xfixes_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::X11")
+ endif ()
+
+ if (X11_Xft_FOUND AND NOT TARGET X11::Xft)
+ add_library(X11::Xft UNKNOWN IMPORTED)
+ set_target_properties(X11::Xft PROPERTIES
+ IMPORTED_LOCATION "${X11_Xft_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xft_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::Xrender;X11::X11;Fontconfig::Fontconfig;Freetype::Freetype")
+ endif ()
+
+ if (X11_Xi_FOUND AND NOT TARGET X11::Xi)
+ add_library(X11::Xi UNKNOWN IMPORTED)
+ set_target_properties(X11::Xi PROPERTIES
+ IMPORTED_LOCATION "${X11_Xi_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xi_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::Xext;X11::X11")
+ endif ()
+
+ if (X11_Xinerama_FOUND AND NOT TARGET X11::Xinerama)
+ add_library(X11::Xinerama UNKNOWN IMPORTED)
+ set_target_properties(X11::Xinerama PROPERTIES
+ IMPORTED_LOCATION "${X11_Xinerama_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xinerama_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::Xext;X11::X11")
+ endif ()
+
+ if (X11_Xkb_FOUND AND NOT TARGET X11::Xkb)
+ add_library(X11::Xkb INTERFACE IMPORTED)
+ set_target_properties(X11::Xkb PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xkb_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::X11")
+ endif ()
+
+ if (X11_xkbfile_FOUND AND NOT TARGET X11::xkbfile)
+ add_library(X11::xkbfile UNKNOWN IMPORTED)
+ set_target_properties(X11::xkbfile PROPERTIES
+ IMPORTED_LOCATION "${X11_xkbfile_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_xkbfile_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::X11")
+ endif ()
+
+ if (X11_Xmu_FOUND AND NOT TARGET X11::Xmu)
+ add_library(X11::Xmu UNKNOWN IMPORTED)
+ set_target_properties(X11::Xmu PROPERTIES
+ IMPORTED_LOCATION "${X11_Xmu_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xmu_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::Xt;X11::Xext;X11::X11")
+ endif ()
+
+ if (X11_Xpm_FOUND AND NOT TARGET X11::Xpm)
+ add_library(X11::Xpm UNKNOWN IMPORTED)
+ set_target_properties(X11::Xpm PROPERTIES
+ IMPORTED_LOCATION "${X11_Xpm_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xpm_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::X11")
+ endif ()
+
+ if (X11_Xtst_FOUND AND NOT TARGET X11::Xtst)
+ add_library(X11::Xtst UNKNOWN IMPORTED)
+ set_target_properties(X11::Xtst PROPERTIES
+ IMPORTED_LOCATION "${X11_Xtst_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xtst_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::Xi;X11::Xext;X11::X11")
+ endif ()
+
+ if (X11_Xrandr_FOUND AND NOT TARGET X11::Xrandr)
+ add_library(X11::Xrandr UNKNOWN IMPORTED)
+ set_target_properties(X11::Xrandr PROPERTIES
+ IMPORTED_LOCATION "${X11_Xrandr_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xrandr_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::Xrender;X11::Xext;X11::X11")
+ endif ()
+
+ if (X11_Xrender_FOUND AND NOT TARGET X11::Xrender)
+ add_library(X11::Xrender UNKNOWN IMPORTED)
+ set_target_properties(X11::Xrender PROPERTIES
+ IMPORTED_LOCATION "${X11_Xrender_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xrender_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::X11")
+ endif ()
+
+ if (X11_XRes_FOUND AND NOT TARGET X11::XRes)
+ add_library(X11::XRes UNKNOWN IMPORTED)
+ set_target_properties(X11::XRes PROPERTIES
+ IMPORTED_LOCATION "${X11_XRes_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_XRes_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::Xext;X11::X11")
+ endif ()
+
+ if (X11_Xss_FOUND AND NOT TARGET X11::Xss)
+ add_library(X11::Xss UNKNOWN IMPORTED)
+ set_target_properties(X11::Xss PROPERTIES
+ IMPORTED_LOCATION "${X11_Xss_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xss_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::Xext;X11::X11")
+ endif ()
+
+ if (X11_Xt_FOUND AND NOT TARGET X11::Xt)
+ add_library(X11::Xt UNKNOWN IMPORTED)
+ set_target_properties(X11::Xt PROPERTIES
+ IMPORTED_LOCATION "${X11_Xt_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xt_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::ICE;X11::SM;X11::X11")
+ endif ()
+
+ if (X11_Xutil_FOUND AND NOT TARGET X11::Xutil)
+ add_library(X11::Xutil INTERFACE IMPORTED)
+ set_target_properties(X11::Xutil PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xutil_INCLUDE_PATH}"
+ # libX11 contains the implementations for functions in the Xutil.h
+ # header.
+ INTERFACE_LINK_LIBRARIES "X11::X11")
+ endif ()
+
+ if (X11_Xv_FOUND AND NOT TARGET X11::Xv)
+ add_library(X11::Xv UNKNOWN IMPORTED)
+ set_target_properties(X11::Xv PROPERTIES
+ IMPORTED_LOCATION "${X11_Xv_LIB}"
+ INTERFACE_INCLUDE_DIRECTORIES "${X11_Xv_INCLUDE_PATH}"
+ INTERFACE_LINK_LIBRARIES "X11::Xext;X11::X11")
+ endif ()
+
mark_as_advanced(
X11_X11_INCLUDE_PATH
X11_X11_LIB
+ X11_Xext_INCLUDE_PATH
X11_Xext_LIB
X11_Xau_LIB
X11_Xau_INCLUDE_PATH
@@ -440,7 +672,6 @@ if (UNIX)
X11_Xutil_INCLUDE_PATH
X11_Xcomposite_INCLUDE_PATH
X11_Xcomposite_LIB
- X11_Xaccess_INCLUDE_PATH
X11_Xfixes_LIB
X11_Xfixes_INCLUDE_PATH
X11_Xrandr_LIB
@@ -452,15 +683,15 @@ if (UNIX)
X11_XRes_LIB
X11_XRes_INCLUDE_PATH
X11_Xxf86misc_LIB
- X11_xf86misc_INCLUDE_PATH
+ X11_Xxf86misc_INCLUDE_PATH
X11_Xxf86vm_LIB
- X11_xf86vmode_INCLUDE_PATH
+ X11_Xxf86vm_INCLUDE_PATH
X11_Xi_LIB
X11_Xi_INCLUDE_PATH
X11_Xinerama_LIB
X11_Xinerama_INCLUDE_PATH
- X11_XTest_LIB
- X11_XTest_INCLUDE_PATH
+ X11_Xtst_LIB
+ X11_Xtst_INCLUDE_PATH
X11_Xcursor_LIB
X11_Xcursor_INCLUDE_PATH
X11_dpms_INCLUDE_PATH
@@ -473,16 +704,14 @@ if (UNIX)
X11_Xdmcp_INCLUDE_PATH
X11_Xkb_INCLUDE_PATH
X11_Xkblib_INCLUDE_PATH
- X11_Xkbfile_INCLUDE_PATH
- X11_Xkbfile_LIB
+ X11_xkbfile_INCLUDE_PATH
+ X11_xkbfile_LIB
X11_Xmu_INCLUDE_PATH
X11_Xmu_LIB
- X11_Xscreensaver_INCLUDE_PATH
- X11_Xscreensaver_LIB
+ X11_Xss_INCLUDE_PATH
+ X11_Xss_LIB
X11_Xpm_INCLUDE_PATH
X11_Xpm_LIB
- X11_Xinput_LIB
- X11_Xinput_INCLUDE_PATH
X11_Xft_LIB
X11_Xft_INCLUDE_PATH
X11_Xshape_INCLUDE_PATH
@@ -498,5 +727,3 @@ if (UNIX)
set(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_SAVE})
set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
endif ()
-
-# X11_FIND_REQUIRED_<component> could be checked too
diff --git a/Modules/FindXCTest.cmake b/Modules/FindXCTest.cmake
index ffdf677cc..15721e184 100644
--- a/Modules/FindXCTest.cmake
+++ b/Modules/FindXCTest.cmake
@@ -61,6 +61,22 @@ The following variables are set by including this module:
#]=======================================================================]
+set(_PRESERVED_CMAKE_FIND_ROOT_PATH "${CMAKE_FIND_ROOT_PATH}")
+
+if(CMAKE_EFFECTIVE_SYSTEM_NAME STREQUAL "Apple"
+ AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ # Non-macos systems set the CMAKE_FIND_ROOT_PATH_MODE to "ONLY" which
+ # restricts the search paths too much to find XCTest.framework. In
+ # contrast to the regular system frameworks which reside within the
+ # SDK direectory the XCTest framework is located in the respective
+ # platform directory which is not added to the CMAKE_FIND_ROOT_PATH
+ # (only to CMAKE_SYSTEM_FRAMEWORK_PATH) and therefore not searched.
+ #
+ # Until this is properly addressed, temporaily add the platform
+ # directory to CMAKE_FIND_ROOT_PATH.
+ list(APPEND CMAKE_FIND_ROOT_PATH "${_CMAKE_OSX_SYSROOT_PATH}/../..")
+endif()
+
find_path(XCTest_INCLUDE_DIR
NAMES "XCTest/XCTest.h"
DOC "XCTest include directory")
@@ -71,6 +87,9 @@ find_library(XCTest_LIBRARY
DOC "XCTest Framework library")
mark_as_advanced(XCTest_LIBRARY)
+set(CMAKE_FIND_ROOT_PATH "${_PRESERVED_CMAKE_FIND_ROOT_PATH}")
+unset(_PRESERVED_CMAKE_FIND_ROOT_PATH)
+
execute_process(
COMMAND xcrun --find xctest
OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -136,7 +155,7 @@ function(xctest_add_bundle target testee)
XCODE_ATTRIBUTE_TEST_HOST "$<TARGET_FILE:${testee}>")
if(NOT XCODE_VERSION VERSION_LESS 7.3)
set_target_properties(${target} PROPERTIES
- LIBRARY_OUTPUT_DIRECTORY "$<TARGET_FILE_DIR:${testee}>/../PlugIns")
+ LIBRARY_OUTPUT_DIRECTORY "$<TARGET_BUNDLE_CONTENT_DIR:${testee}>/PlugIns")
endif()
else(XCODE)
target_link_libraries(${target}
@@ -183,7 +202,7 @@ function(xctest_add_test name bundle)
add_test(
NAME ${name}
- COMMAND ${XCTest_EXECUTABLE} $<TARGET_LINKER_FILE_DIR:${bundle}>/../..)
+ COMMAND ${XCTest_EXECUTABLE} $<TARGET_BUNDLE_DIR:${bundle}>)
# point loader to testee in case rpath is disabled
diff --git a/Modules/FindXMLRPC.cmake b/Modules/FindXMLRPC.cmake
index f0b258397..69e6df22b 100644
--- a/Modules/FindXMLRPC.cmake
+++ b/Modules/FindXMLRPC.cmake
@@ -1,35 +1,36 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindXMLRPC
-# ----------
-#
-# Find xmlrpc
-#
-# Find the native XMLRPC headers and libraries.
-#
-# ::
-#
-# XMLRPC_INCLUDE_DIRS - where to find xmlrpc.h, etc.
-# XMLRPC_LIBRARIES - List of libraries when using xmlrpc.
-# XMLRPC_FOUND - True if xmlrpc found.
-#
-# XMLRPC modules may be specified as components for this find module.
-# Modules may be listed by running "xmlrpc-c-config". Modules include:
-#
-# ::
-#
-# c++ C++ wrapper code
-# libwww-client libwww-based client
-# cgi-server CGI-based server
-# abyss-server ABYSS-based server
-#
-# Typical usage:
-#
-# ::
-#
-# find_package(XMLRPC REQUIRED libwww-client)
+#[=======================================================================[.rst:
+FindXMLRPC
+----------
+
+Find xmlrpc
+
+Find the native XMLRPC headers and libraries.
+
+::
+
+ XMLRPC_INCLUDE_DIRS - where to find xmlrpc.h, etc.
+ XMLRPC_LIBRARIES - List of libraries when using xmlrpc.
+ XMLRPC_FOUND - True if xmlrpc found.
+
+XMLRPC modules may be specified as components for this find module.
+Modules may be listed by running "xmlrpc-c-config". Modules include:
+
+::
+
+ c++ C++ wrapper code
+ libwww-client libwww-based client
+ cgi-server CGI-based server
+ abyss-server ABYSS-based server
+
+Typical usage:
+
+::
+
+ find_package(XMLRPC REQUIRED libwww-client)
+#]=======================================================================]
# First find the config script from which to obtain other values.
find_program(XMLRPC_C_CONFIG NAMES xmlrpc-c-config)
@@ -43,20 +44,12 @@ endif()
# Lookup the include directories needed for the components requested.
if(XMLRPC_C_FOUND)
- # Use the newer EXECUTE_PROCESS command if it is available.
- if(COMMAND EXECUTE_PROCESS)
- execute_process(
- COMMAND ${XMLRPC_C_CONFIG} ${XMLRPC_FIND_COMPONENTS} --cflags
- OUTPUT_VARIABLE XMLRPC_C_CONFIG_CFLAGS
- OUTPUT_STRIP_TRAILING_WHITESPACE
- RESULT_VARIABLE XMLRPC_C_CONFIG_RESULT
- )
- else()
- exec_program(${XMLRPC_C_CONFIG} ARGS "${XMLRPC_FIND_COMPONENTS} --cflags"
- OUTPUT_VARIABLE XMLRPC_C_CONFIG_CFLAGS
- RETURN_VALUE XMLRPC_C_CONFIG_RESULT
- )
- endif()
+ execute_process(
+ COMMAND ${XMLRPC_C_CONFIG} ${XMLRPC_FIND_COMPONENTS} --cflags
+ OUTPUT_VARIABLE XMLRPC_C_CONFIG_CFLAGS
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ RESULT_VARIABLE XMLRPC_C_CONFIG_RESULT
+ )
# Parse the include flags.
if("${XMLRPC_C_CONFIG_RESULT}" STREQUAL "0")
@@ -65,6 +58,7 @@ if(XMLRPC_C_FOUND)
XMLRPC_C_CONFIG_CFLAGS "${XMLRPC_C_CONFIG_CFLAGS}")
# Look for -I options.
+ # FIXME: Use these as hints to a find_path call to find the headers.
set(XMLRPC_INCLUDE_DIRS)
foreach(flag ${XMLRPC_C_CONFIG_CFLAGS})
if("${flag}" MATCHES "^-I(.+)")
@@ -80,20 +74,12 @@ endif()
# Lookup the libraries needed for the components requested.
if(XMLRPC_C_FOUND)
- # Use the newer EXECUTE_PROCESS command if it is available.
- if(COMMAND EXECUTE_PROCESS)
- execute_process(
- COMMAND ${XMLRPC_C_CONFIG} ${XMLRPC_FIND_COMPONENTS} --libs
- OUTPUT_VARIABLE XMLRPC_C_CONFIG_LIBS
- OUTPUT_STRIP_TRAILING_WHITESPACE
- RESULT_VARIABLE XMLRPC_C_CONFIG_RESULT
- )
- else()
- exec_program(${XMLRPC_C_CONFIG} ARGS "${XMLRPC_FIND_COMPONENTS} --libs"
- OUTPUT_VARIABLE XMLRPC_C_CONFIG_LIBS
- RETURN_VALUE XMLRPC_C_CONFIG_RESULT
- )
- endif()
+ execute_process(
+ COMMAND ${XMLRPC_C_CONFIG} ${XMLRPC_FIND_COMPONENTS} --libs
+ OUTPUT_VARIABLE XMLRPC_C_CONFIG_LIBS
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ RESULT_VARIABLE XMLRPC_C_CONFIG_RESULT
+ )
# Parse the library names and directories.
if("${XMLRPC_C_CONFIG_RESULT}" STREQUAL "0")
@@ -139,5 +125,5 @@ endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
XMLRPC
- REQUIRED_VARS XMLRPC_C_FOUND XMLRPC_LIBRARIES XMLRPC_INCLUDE_DIRS
+ REQUIRED_VARS XMLRPC_C_FOUND XMLRPC_LIBRARIES
FAIL_MESSAGE "XMLRPC was not found. Make sure the entries XMLRPC_* are set.")
diff --git a/Modules/FindXalanC.cmake b/Modules/FindXalanC.cmake
index 1951b49e1..3adaa44d3 100644
--- a/Modules/FindXalanC.cmake
+++ b/Modules/FindXalanC.cmake
@@ -1,45 +1,46 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindXalanC
-# -----------
-#
-# Find the Apache Xalan-C++ XSL transform processor headers and libraries.
-#
-# Imported targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the following :prop_tgt:`IMPORTED` targets:
-#
-# ``XalanC::XalanC``
-# The Xalan-C++ ``xalan-c`` library, if found.
-#
-# Result variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module will set the following variables in your project:
-#
-# ``XalanC_FOUND``
-# true if the Xalan headers and libraries were found
-# ``XalanC_VERSION``
-# Xalan release version
-# ``XalanC_INCLUDE_DIRS``
-# the directory containing the Xalan headers; note
-# ``XercesC_INCLUDE_DIRS`` is also required
-# ``XalanC_LIBRARIES``
-# Xalan libraries to be linked; note ``XercesC_LIBRARIES`` is also
-# required
-#
-# Cache variables
-# ^^^^^^^^^^^^^^^
-#
-# The following cache variables may also be set:
-#
-# ``XalanC_INCLUDE_DIR``
-# the directory containing the Xalan headers
-# ``XalanC_LIBRARY``
-# the Xalan library
+#[=======================================================================[.rst:
+FindXalanC
+-----------
+
+Find the Apache Xalan-C++ XSL transform processor headers and libraries.
+
+Imported targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` targets:
+
+``XalanC::XalanC``
+ The Xalan-C++ ``xalan-c`` library, if found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``XalanC_FOUND``
+ true if the Xalan headers and libraries were found
+``XalanC_VERSION``
+ Xalan release version
+``XalanC_INCLUDE_DIRS``
+ the directory containing the Xalan headers; note
+ ``XercesC_INCLUDE_DIRS`` is also required
+``XalanC_LIBRARIES``
+ Xalan libraries to be linked; note ``XercesC_LIBRARIES`` is also
+ required
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``XalanC_INCLUDE_DIR``
+ the directory containing the Xalan headers
+``XalanC_LIBRARY``
+ the Xalan library
+#]=======================================================================]
# Written by Roger Leigh <rleigh@codelibre.net>
@@ -75,7 +76,7 @@ find_path(XalanC_INCLUDE_DIR
DOC "Xalan-C++ include directory")
mark_as_advanced(XalanC_INCLUDE_DIR)
-if(XalanC_INCLUDE_DIR)
+if(XalanC_INCLUDE_DIR AND EXISTS "${XalanC_INCLUDE_DIR}/xalanc/Include/XalanVersion.hpp")
_XalanC_GET_VERSION("${XalanC_INCLUDE_DIR}/xalanc/Include/XalanVersion.hpp")
endif()
diff --git a/Modules/FindXercesC.cmake b/Modules/FindXercesC.cmake
index 51e68d599..47bfd6288 100644
--- a/Modules/FindXercesC.cmake
+++ b/Modules/FindXercesC.cmake
@@ -1,43 +1,44 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindXercesC
-# -----------
-#
-# Find the Apache Xerces-C++ validating XML parser headers and libraries.
-#
-# Imported targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the following :prop_tgt:`IMPORTED` targets:
-#
-# ``XercesC::XercesC``
-# The Xerces-C++ ``xerces-c`` library, if found.
-#
-# Result variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module will set the following variables in your project:
-#
-# ``XercesC_FOUND``
-# true if the Xerces headers and libraries were found
-# ``XercesC_VERSION``
-# Xerces release version
-# ``XercesC_INCLUDE_DIRS``
-# the directory containing the Xerces headers
-# ``XercesC_LIBRARIES``
-# Xerces libraries to be linked
-#
-# Cache variables
-# ^^^^^^^^^^^^^^^
-#
-# The following cache variables may also be set:
-#
-# ``XercesC_INCLUDE_DIR``
-# the directory containing the Xerces headers
-# ``XercesC_LIBRARY``
-# the Xerces library
+#[=======================================================================[.rst:
+FindXercesC
+-----------
+
+Find the Apache Xerces-C++ validating XML parser headers and libraries.
+
+Imported targets
+^^^^^^^^^^^^^^^^
+
+This module defines the following :prop_tgt:`IMPORTED` targets:
+
+``XercesC::XercesC``
+ The Xerces-C++ ``xerces-c`` library, if found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``XercesC_FOUND``
+ true if the Xerces headers and libraries were found
+``XercesC_VERSION``
+ Xerces release version
+``XercesC_INCLUDE_DIRS``
+ the directory containing the Xerces headers
+``XercesC_LIBRARIES``
+ Xerces libraries to be linked
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``XercesC_INCLUDE_DIR``
+ the directory containing the Xerces headers
+``XercesC_LIBRARY``
+ the Xerces library
+#]=======================================================================]
# Written by Roger Leigh <rleigh@codelibre.net>
@@ -59,6 +60,9 @@ function(_XercesC_GET_VERSION version_hdr)
endif()
set(XercesC_VERSION "${XercesC_MAJOR}.${XercesC_MINOR}.${XercesC_PATCH}" PARENT_SCOPE)
+ set(XercesC_VERSION_MAJOR "${XercesC_MAJOR}" PARENT_SCOPE)
+ set(XercesC_VERSION_MINOR "${XercesC_MINOR}" PARENT_SCOPE)
+ set(XercesC_VERSION_PATCH "${XercesC_PATCH}" PARENT_SCOPE)
else()
message(FATAL_ERROR "Include file ${version_hdr} does not exist or does not contain expected version information")
endif()
@@ -70,22 +74,26 @@ find_path(XercesC_INCLUDE_DIR
DOC "Xerces-C++ include directory")
mark_as_advanced(XercesC_INCLUDE_DIR)
+if(XercesC_INCLUDE_DIR AND EXISTS "${XercesC_INCLUDE_DIR}/xercesc/util/XercesVersion.hpp")
+ _XercesC_GET_VERSION("${XercesC_INCLUDE_DIR}/xercesc/util/XercesVersion.hpp")
+endif()
+
if(NOT XercesC_LIBRARY)
# Find all XercesC libraries
find_library(XercesC_LIBRARY_RELEASE
- NAMES "xerces-c" "xerces-c_3"
+ NAMES "xerces-c" "xerces-c_${XercesC_VERSION_MAJOR}"
DOC "Xerces-C++ libraries (release)")
find_library(XercesC_LIBRARY_DEBUG
- NAMES "xerces-cd" "xerces-c_3D" "xerces-c_3_1D"
+ NAMES "xerces-cd" "xerces-c_${XercesC_VERSION_MAJOR}D" "xerces-c_${XercesC_VERSION_MAJOR}_${XercesC_VERSION_MINOR}D"
DOC "Xerces-C++ libraries (debug)")
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
select_library_configurations(XercesC)
mark_as_advanced(XercesC_LIBRARY_RELEASE XercesC_LIBRARY_DEBUG)
endif()
-if(XercesC_INCLUDE_DIR)
- _XercesC_GET_VERSION("${XercesC_INCLUDE_DIR}/xercesc/util/XercesVersion.hpp")
-endif()
+unset(XercesC_VERSION_MAJOR)
+unset(XercesC_VERSION_MINOR)
+unset(XercesC_VERSION_PATCH)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(XercesC
diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake
index 406599949..79e2313d5 100644
--- a/Modules/FindZLIB.cmake
+++ b/Modules/FindZLIB.cmake
@@ -1,53 +1,54 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindZLIB
-# --------
-#
-# Find the native ZLIB includes and library.
-#
-# IMPORTED Targets
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines :prop_tgt:`IMPORTED` target ``ZLIB::ZLIB``, if
-# ZLIB has been found.
-#
-# Result Variables
-# ^^^^^^^^^^^^^^^^
-#
-# This module defines the following variables:
-#
-# ::
-#
-# ZLIB_INCLUDE_DIRS - where to find zlib.h, etc.
-# ZLIB_LIBRARIES - List of libraries when using zlib.
-# ZLIB_FOUND - True if zlib found.
-#
-# ::
-#
-# ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
-# ZLIB_VERSION_MAJOR - The major version of zlib
-# ZLIB_VERSION_MINOR - The minor version of zlib
-# ZLIB_VERSION_PATCH - The patch version of zlib
-# ZLIB_VERSION_TWEAK - The tweak version of zlib
-#
-# Backward Compatibility
-# ^^^^^^^^^^^^^^^^^^^^^^
-#
-# The following variable are provided for backward compatibility
-#
-# ::
-#
-# ZLIB_MAJOR_VERSION - The major version of zlib
-# ZLIB_MINOR_VERSION - The minor version of zlib
-# ZLIB_PATCH_VERSION - The patch version of zlib
-#
-# Hints
-# ^^^^^
-#
-# A user may set ``ZLIB_ROOT`` to a zlib installation root to tell this
-# module where to look.
+#[=======================================================================[.rst:
+FindZLIB
+--------
+
+Find the native ZLIB includes and library.
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``ZLIB::ZLIB``, if
+ZLIB has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+::
+
+ ZLIB_INCLUDE_DIRS - where to find zlib.h, etc.
+ ZLIB_LIBRARIES - List of libraries when using zlib.
+ ZLIB_FOUND - True if zlib found.
+
+::
+
+ ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
+ ZLIB_VERSION_MAJOR - The major version of zlib
+ ZLIB_VERSION_MINOR - The minor version of zlib
+ ZLIB_VERSION_PATCH - The patch version of zlib
+ ZLIB_VERSION_TWEAK - The tweak version of zlib
+
+Backward Compatibility
+^^^^^^^^^^^^^^^^^^^^^^
+
+The following variable are provided for backward compatibility
+
+::
+
+ ZLIB_MAJOR_VERSION - The major version of zlib
+ ZLIB_MINOR_VERSION - The minor version of zlib
+ ZLIB_PATCH_VERSION - The patch version of zlib
+
+Hints
+^^^^^
+
+A user may set ``ZLIB_ROOT`` to a zlib installation root to tell this
+module where to look.
+#]=======================================================================]
set(_ZLIB_SEARCHES)
@@ -58,14 +59,16 @@ if(ZLIB_ROOT)
endif()
# Normal search.
+set(_ZLIB_x86 "(x86)")
set(_ZLIB_SEARCH_NORMAL
- PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]"
- "$ENV{PROGRAMFILES}/zlib"
- )
+ PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]"
+ "$ENV{ProgramFiles}/zlib"
+ "$ENV{ProgramFiles${_ZLIB_x86}}/zlib")
+unset(_ZLIB_x86)
list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL)
-set(ZLIB_NAMES z zlib zdll zlib1)
-set(ZLIB_NAMES_DEBUG zlibd zlibd1)
+set(ZLIB_NAMES z zlib zdll zlib1 zlibstatic)
+set(ZLIB_NAMES_DEBUG zd zlibd zdlld zlibd1 zlib1d zlibstaticd)
# Try each search configuration.
foreach(search ${_ZLIB_SEARCHES})
@@ -75,8 +78,8 @@ endforeach()
# Allow ZLIB_LIBRARY to be set manually, as the location of the zlib library
if(NOT ZLIB_LIBRARY)
foreach(search ${_ZLIB_SEARCHES})
- find_library(ZLIB_LIBRARY_RELEASE NAMES ${ZLIB_NAMES} ${${search}} PATH_SUFFIXES lib)
- find_library(ZLIB_LIBRARY_DEBUG NAMES ${ZLIB_NAMES_DEBUG} ${${search}} PATH_SUFFIXES lib)
+ find_library(ZLIB_LIBRARY_RELEASE NAMES ${ZLIB_NAMES} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib)
+ find_library(ZLIB_LIBRARY_DEBUG NAMES ${ZLIB_NAMES_DEBUG} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib)
endforeach()
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
diff --git a/Modules/Findosg.cmake b/Modules/Findosg.cmake
index 474ea82b5..027f315cd 100644
--- a/Modules/Findosg.cmake
+++ b/Modules/Findosg.cmake
@@ -1,42 +1,41 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# Findosg
-# -------
-#
-#
-#
-#
-#
-# NOTE: It is highly recommended that you use the new
-# FindOpenSceneGraph.cmake introduced in CMake 2.6.3 and not use this
-# Find module directly.
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osg This module defines
-#
-# OSG_FOUND - Was the Osg found? OSG_INCLUDE_DIR - Where to find the
-# headers OSG_LIBRARIES - The libraries to link against for the OSG (use
-# this)
-#
-# OSG_LIBRARY - The OSG library OSG_LIBRARY_DEBUG - The OSG debug
-# library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+Findosg
+-------
+
+
+
+NOTE: It is highly recommended that you use the new
+FindOpenSceneGraph.cmake introduced in CMake 2.6.3 and not use this
+Find module directly.
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osg This module defines
+
+OSG_FOUND - Was the Osg found? OSG_INCLUDE_DIR - Where to find the
+headers OSG_LIBRARIES - The libraries to link against for the OSG (use
+this)
+
+OSG_LIBRARY - The OSG library OSG_LIBRARY_DEBUG - The OSG debug
+library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgAnimation.cmake b/Modules/FindosgAnimation.cmake
index 5b26b6485..65e301649 100644
--- a/Modules/FindosgAnimation.cmake
+++ b/Modules/FindosgAnimation.cmake
@@ -1,36 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgAnimation
-# ----------------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgAnimation This module defines
-#
-# OSGANIMATION_FOUND - Was osgAnimation found? OSGANIMATION_INCLUDE_DIR
-# - Where to find the headers OSGANIMATION_LIBRARIES - The libraries to
-# link against for the OSG (use this)
-#
-# OSGANIMATION_LIBRARY - The OSG library OSGANIMATION_LIBRARY_DEBUG -
-# The OSG debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgAnimation
+----------------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgAnimation This module defines
+
+OSGANIMATION_FOUND - Was osgAnimation found? OSGANIMATION_INCLUDE_DIR
+- Where to find the headers OSGANIMATION_LIBRARIES - The libraries to
+link against for the OSG (use this)
+
+OSGANIMATION_LIBRARY - The OSG library OSGANIMATION_LIBRARY_DEBUG -
+The OSG debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgDB.cmake b/Modules/FindosgDB.cmake
index 6ddf53ce0..a28f65007 100644
--- a/Modules/FindosgDB.cmake
+++ b/Modules/FindosgDB.cmake
@@ -1,36 +1,45 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgDB
-# ---------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgDB This module defines
-#
-# OSGDB_FOUND - Was osgDB found? OSGDB_INCLUDE_DIR - Where to find the
-# headers OSGDB_LIBRARIES - The libraries to link against for the osgDB
-# (use this)
-#
-# OSGDB_LIBRARY - The osgDB library OSGDB_LIBRARY_DEBUG - The osgDB
-# debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgDB
+---------
+
+
+
+This is part of the ``Findosg*`` suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default :module:`FindOpenGL` module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+:module:`FindOpenSceneGraph` instead of the ``Findosg*.cmake`` modules.
+
+Locate osgDB This module defines:
+
+``OSGDB_FOUND``
+ Was osgDB found?
+
+``OSGDB_INCLUDE_DIR``
+ Where to find the headers
+
+``OSGDB_LIBRARIES``
+ The libraries to link against for the osgDB
+
+``OSGDB_LIBRARY``
+ The osgDB library
+
+``OSGDB_LIBRARY_DEBUG``
+ The osgDB debug library
+
+``$OSGDIR`` is an environment variable that would correspond to::
+
+ ./configure --prefix=$OSGDIR used in building osg.
+
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgFX.cmake b/Modules/FindosgFX.cmake
index e4bc276d7..438fab7d5 100644
--- a/Modules/FindosgFX.cmake
+++ b/Modules/FindosgFX.cmake
@@ -1,36 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgFX
-# ---------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgFX This module defines
-#
-# OSGFX_FOUND - Was osgFX found? OSGFX_INCLUDE_DIR - Where to find the
-# headers OSGFX_LIBRARIES - The libraries to link against for the osgFX
-# (use this)
-#
-# OSGFX_LIBRARY - The osgFX library OSGFX_LIBRARY_DEBUG - The osgFX
-# debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgFX
+---------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgFX This module defines
+
+OSGFX_FOUND - Was osgFX found? OSGFX_INCLUDE_DIR - Where to find the
+headers OSGFX_LIBRARIES - The libraries to link against for the osgFX
+(use this)
+
+OSGFX_LIBRARY - The osgFX library OSGFX_LIBRARY_DEBUG - The osgFX
+debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgGA.cmake b/Modules/FindosgGA.cmake
index 97adeb7af..7b6ef30a2 100644
--- a/Modules/FindosgGA.cmake
+++ b/Modules/FindosgGA.cmake
@@ -1,36 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgGA
-# ---------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgGA This module defines
-#
-# OSGGA_FOUND - Was osgGA found? OSGGA_INCLUDE_DIR - Where to find the
-# headers OSGGA_LIBRARIES - The libraries to link against for the osgGA
-# (use this)
-#
-# OSGGA_LIBRARY - The osgGA library OSGGA_LIBRARY_DEBUG - The osgGA
-# debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgGA
+---------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgGA This module defines
+
+OSGGA_FOUND - Was osgGA found? OSGGA_INCLUDE_DIR - Where to find the
+headers OSGGA_LIBRARIES - The libraries to link against for the osgGA
+(use this)
+
+OSGGA_LIBRARY - The osgGA library OSGGA_LIBRARY_DEBUG - The osgGA
+debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgIntrospection.cmake b/Modules/FindosgIntrospection.cmake
index e735942c3..625e4c26e 100644
--- a/Modules/FindosgIntrospection.cmake
+++ b/Modules/FindosgIntrospection.cmake
@@ -1,37 +1,38 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgIntrospection
-# --------------------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgINTROSPECTION This module defines
-#
-# OSGINTROSPECTION_FOUND - Was osgIntrospection found?
-# OSGINTROSPECTION_INCLUDE_DIR - Where to find the headers
-# OSGINTROSPECTION_LIBRARIES - The libraries to link for
-# osgIntrospection (use this)
-#
-# OSGINTROSPECTION_LIBRARY - The osgIntrospection library
-# OSGINTROSPECTION_LIBRARY_DEBUG - The osgIntrospection debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgIntrospection
+--------------------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgINTROSPECTION This module defines
+
+OSGINTROSPECTION_FOUND - Was osgIntrospection found?
+OSGINTROSPECTION_INCLUDE_DIR - Where to find the headers
+OSGINTROSPECTION_LIBRARIES - The libraries to link for
+osgIntrospection (use this)
+
+OSGINTROSPECTION_LIBRARY - The osgIntrospection library
+OSGINTROSPECTION_LIBRARY_DEBUG - The osgIntrospection debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgManipulator.cmake b/Modules/FindosgManipulator.cmake
index b88f1a414..857ff5d57 100644
--- a/Modules/FindosgManipulator.cmake
+++ b/Modules/FindosgManipulator.cmake
@@ -1,37 +1,38 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgManipulator
-# ------------------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgManipulator This module defines
-#
-# OSGMANIPULATOR_FOUND - Was osgManipulator found?
-# OSGMANIPULATOR_INCLUDE_DIR - Where to find the headers
-# OSGMANIPULATOR_LIBRARIES - The libraries to link for osgManipulator
-# (use this)
-#
-# OSGMANIPULATOR_LIBRARY - The osgManipulator library
-# OSGMANIPULATOR_LIBRARY_DEBUG - The osgManipulator debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgManipulator
+------------------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgManipulator This module defines
+
+OSGMANIPULATOR_FOUND - Was osgManipulator found?
+OSGMANIPULATOR_INCLUDE_DIR - Where to find the headers
+OSGMANIPULATOR_LIBRARIES - The libraries to link for osgManipulator
+(use this)
+
+OSGMANIPULATOR_LIBRARY - The osgManipulator library
+OSGMANIPULATOR_LIBRARY_DEBUG - The osgManipulator debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgParticle.cmake b/Modules/FindosgParticle.cmake
index 059746a61..91a30dc7e 100644
--- a/Modules/FindosgParticle.cmake
+++ b/Modules/FindosgParticle.cmake
@@ -1,36 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgParticle
-# ---------------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgParticle This module defines
-#
-# OSGPARTICLE_FOUND - Was osgParticle found? OSGPARTICLE_INCLUDE_DIR -
-# Where to find the headers OSGPARTICLE_LIBRARIES - The libraries to
-# link for osgParticle (use this)
-#
-# OSGPARTICLE_LIBRARY - The osgParticle library
-# OSGPARTICLE_LIBRARY_DEBUG - The osgParticle debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgParticle
+---------------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgParticle This module defines
+
+OSGPARTICLE_FOUND - Was osgParticle found? OSGPARTICLE_INCLUDE_DIR -
+Where to find the headers OSGPARTICLE_LIBRARIES - The libraries to
+link for osgParticle (use this)
+
+OSGPARTICLE_LIBRARY - The osgParticle library
+OSGPARTICLE_LIBRARY_DEBUG - The osgParticle debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgPresentation.cmake b/Modules/FindosgPresentation.cmake
index 84a410526..eae75d638 100644
--- a/Modules/FindosgPresentation.cmake
+++ b/Modules/FindosgPresentation.cmake
@@ -1,38 +1,39 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgPresentation
-# -------------------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgPresentation This module defines
-#
-# OSGPRESENTATION_FOUND - Was osgPresentation found?
-# OSGPRESENTATION_INCLUDE_DIR - Where to find the headers
-# OSGPRESENTATION_LIBRARIES - The libraries to link for osgPresentation
-# (use this)
-#
-# OSGPRESENTATION_LIBRARY - The osgPresentation library
-# OSGPRESENTATION_LIBRARY_DEBUG - The osgPresentation debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing. Modified to work with osgPresentation by Robert
-# Osfield, January 2012.
+#[=======================================================================[.rst:
+FindosgPresentation
+-------------------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgPresentation This module defines
+
+OSGPRESENTATION_FOUND - Was osgPresentation found?
+OSGPRESENTATION_INCLUDE_DIR - Where to find the headers
+OSGPRESENTATION_LIBRARIES - The libraries to link for osgPresentation
+(use this)
+
+OSGPRESENTATION_LIBRARY - The osgPresentation library
+OSGPRESENTATION_LIBRARY_DEBUG - The osgPresentation debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing. Modified to work with osgPresentation by Robert
+Osfield, January 2012.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgProducer.cmake b/Modules/FindosgProducer.cmake
index e5700bfc4..33b9f7311 100644
--- a/Modules/FindosgProducer.cmake
+++ b/Modules/FindosgProducer.cmake
@@ -1,36 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgProducer
-# ---------------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgProducer This module defines
-#
-# OSGPRODUCER_FOUND - Was osgProducer found? OSGPRODUCER_INCLUDE_DIR -
-# Where to find the headers OSGPRODUCER_LIBRARIES - The libraries to
-# link for osgProducer (use this)
-#
-# OSGPRODUCER_LIBRARY - The osgProducer library
-# OSGPRODUCER_LIBRARY_DEBUG - The osgProducer debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgProducer
+---------------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgProducer This module defines
+
+OSGPRODUCER_FOUND - Was osgProducer found? OSGPRODUCER_INCLUDE_DIR -
+Where to find the headers OSGPRODUCER_LIBRARIES - The libraries to
+link for osgProducer (use this)
+
+OSGPRODUCER_LIBRARY - The osgProducer library
+OSGPRODUCER_LIBRARY_DEBUG - The osgProducer debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgQt.cmake b/Modules/FindosgQt.cmake
index 04a2393e5..cf356303c 100644
--- a/Modules/FindosgQt.cmake
+++ b/Modules/FindosgQt.cmake
@@ -1,36 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgQt
-# ---------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgQt This module defines
-#
-# OSGQT_FOUND - Was osgQt found? OSGQT_INCLUDE_DIR - Where to find the
-# headers OSGQT_LIBRARIES - The libraries to link for osgQt (use this)
-#
-# OSGQT_LIBRARY - The osgQt library OSGQT_LIBRARY_DEBUG - The osgQt
-# debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing. Modified to work with osgQt by Robert Osfield,
-# January 2012.
+#[=======================================================================[.rst:
+FindosgQt
+---------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgQt This module defines
+
+OSGQT_FOUND - Was osgQt found? OSGQT_INCLUDE_DIR - Where to find the
+headers OSGQT_LIBRARIES - The libraries to link for osgQt (use this)
+
+OSGQT_LIBRARY - The osgQt library OSGQT_LIBRARY_DEBUG - The osgQt
+debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing. Modified to work with osgQt by Robert Osfield,
+January 2012.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgShadow.cmake b/Modules/FindosgShadow.cmake
index 0a7ba2379..0049c4e1d 100644
--- a/Modules/FindosgShadow.cmake
+++ b/Modules/FindosgShadow.cmake
@@ -1,36 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgShadow
-# -------------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgShadow This module defines
-#
-# OSGSHADOW_FOUND - Was osgShadow found? OSGSHADOW_INCLUDE_DIR - Where
-# to find the headers OSGSHADOW_LIBRARIES - The libraries to link for
-# osgShadow (use this)
-#
-# OSGSHADOW_LIBRARY - The osgShadow library OSGSHADOW_LIBRARY_DEBUG -
-# The osgShadow debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgShadow
+-------------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgShadow This module defines
+
+OSGSHADOW_FOUND - Was osgShadow found? OSGSHADOW_INCLUDE_DIR - Where
+to find the headers OSGSHADOW_LIBRARIES - The libraries to link for
+osgShadow (use this)
+
+OSGSHADOW_LIBRARY - The osgShadow library OSGSHADOW_LIBRARY_DEBUG -
+The osgShadow debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgSim.cmake b/Modules/FindosgSim.cmake
index 15426a273..43ba54211 100644
--- a/Modules/FindosgSim.cmake
+++ b/Modules/FindosgSim.cmake
@@ -1,36 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgSim
-# ----------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgSim This module defines
-#
-# OSGSIM_FOUND - Was osgSim found? OSGSIM_INCLUDE_DIR - Where to find
-# the headers OSGSIM_LIBRARIES - The libraries to link for osgSim (use
-# this)
-#
-# OSGSIM_LIBRARY - The osgSim library OSGSIM_LIBRARY_DEBUG - The osgSim
-# debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgSim
+----------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgSim This module defines
+
+OSGSIM_FOUND - Was osgSim found? OSGSIM_INCLUDE_DIR - Where to find
+the headers OSGSIM_LIBRARIES - The libraries to link for osgSim (use
+this)
+
+OSGSIM_LIBRARY - The osgSim library OSGSIM_LIBRARY_DEBUG - The osgSim
+debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgTerrain.cmake b/Modules/FindosgTerrain.cmake
index 04eae1450..c6f5b690a 100644
--- a/Modules/FindosgTerrain.cmake
+++ b/Modules/FindosgTerrain.cmake
@@ -1,36 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgTerrain
-# --------------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgTerrain This module defines
-#
-# OSGTERRAIN_FOUND - Was osgTerrain found? OSGTERRAIN_INCLUDE_DIR -
-# Where to find the headers OSGTERRAIN_LIBRARIES - The libraries to link
-# for osgTerrain (use this)
-#
-# OSGTERRAIN_LIBRARY - The osgTerrain library OSGTERRAIN_LIBRARY_DEBUG -
-# The osgTerrain debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgTerrain
+--------------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgTerrain This module defines
+
+OSGTERRAIN_FOUND - Was osgTerrain found? OSGTERRAIN_INCLUDE_DIR -
+Where to find the headers OSGTERRAIN_LIBRARIES - The libraries to link
+for osgTerrain (use this)
+
+OSGTERRAIN_LIBRARY - The osgTerrain library OSGTERRAIN_LIBRARY_DEBUG -
+The osgTerrain debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgText.cmake b/Modules/FindosgText.cmake
index 1e2d9fdfd..fd3c2324f 100644
--- a/Modules/FindosgText.cmake
+++ b/Modules/FindosgText.cmake
@@ -1,36 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgText
-# -----------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgText This module defines
-#
-# OSGTEXT_FOUND - Was osgText found? OSGTEXT_INCLUDE_DIR - Where to find
-# the headers OSGTEXT_LIBRARIES - The libraries to link for osgText (use
-# this)
-#
-# OSGTEXT_LIBRARY - The osgText library OSGTEXT_LIBRARY_DEBUG - The
-# osgText debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgText
+-----------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgText This module defines
+
+OSGTEXT_FOUND - Was osgText found? OSGTEXT_INCLUDE_DIR - Where to find
+the headers OSGTEXT_LIBRARIES - The libraries to link for osgText (use
+this)
+
+OSGTEXT_LIBRARY - The osgText library OSGTEXT_LIBRARY_DEBUG - The
+osgText debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgUtil.cmake b/Modules/FindosgUtil.cmake
index 13e0b803e..e84727aef 100644
--- a/Modules/FindosgUtil.cmake
+++ b/Modules/FindosgUtil.cmake
@@ -1,36 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgUtil
-# -----------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgUtil This module defines
-#
-# OSGUTIL_FOUND - Was osgUtil found? OSGUTIL_INCLUDE_DIR - Where to find
-# the headers OSGUTIL_LIBRARIES - The libraries to link for osgUtil (use
-# this)
-#
-# OSGUTIL_LIBRARY - The osgUtil library OSGUTIL_LIBRARY_DEBUG - The
-# osgUtil debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgUtil
+-----------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgUtil This module defines
+
+OSGUTIL_FOUND - Was osgUtil found? OSGUTIL_INCLUDE_DIR - Where to find
+the headers OSGUTIL_LIBRARIES - The libraries to link for osgUtil (use
+this)
+
+OSGUTIL_LIBRARY - The osgUtil library OSGUTIL_LIBRARY_DEBUG - The
+osgUtil debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgViewer.cmake b/Modules/FindosgViewer.cmake
index a91c49c14..2174357ec 100644
--- a/Modules/FindosgViewer.cmake
+++ b/Modules/FindosgViewer.cmake
@@ -1,36 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgViewer
-# -------------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgViewer This module defines
-#
-# OSGVIEWER_FOUND - Was osgViewer found? OSGVIEWER_INCLUDE_DIR - Where
-# to find the headers OSGVIEWER_LIBRARIES - The libraries to link for
-# osgViewer (use this)
-#
-# OSGVIEWER_LIBRARY - The osgViewer library OSGVIEWER_LIBRARY_DEBUG -
-# The osgViewer debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgViewer
+-------------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgViewer This module defines
+
+OSGVIEWER_FOUND - Was osgViewer found? OSGVIEWER_INCLUDE_DIR - Where
+to find the headers OSGVIEWER_LIBRARIES - The libraries to link for
+osgViewer (use this)
+
+OSGVIEWER_LIBRARY - The osgViewer library OSGVIEWER_LIBRARY_DEBUG -
+The osgViewer debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgVolume.cmake b/Modules/FindosgVolume.cmake
index 1178ed37d..35defef6b 100644
--- a/Modules/FindosgVolume.cmake
+++ b/Modules/FindosgVolume.cmake
@@ -1,36 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgVolume
-# -------------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgVolume This module defines
-#
-# OSGVOLUME_FOUND - Was osgVolume found? OSGVOLUME_INCLUDE_DIR - Where
-# to find the headers OSGVOLUME_LIBRARIES - The libraries to link for
-# osgVolume (use this)
-#
-# OSGVOLUME_LIBRARY - The osgVolume library OSGVOLUME_LIBRARY_DEBUG -
-# The osgVolume debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# Created by Eric Wing.
+#[=======================================================================[.rst:
+FindosgVolume
+-------------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgVolume This module defines
+
+OSGVOLUME_FOUND - Was osgVolume found? OSGVOLUME_INCLUDE_DIR - Where
+to find the headers OSGVOLUME_LIBRARIES - The libraries to link for
+osgVolume (use this)
+
+OSGVOLUME_LIBRARY - The osgVolume library OSGVOLUME_LIBRARY_DEBUG -
+The osgVolume debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+Created by Eric Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/FindosgWidget.cmake b/Modules/FindosgWidget.cmake
index 78999ec3f..c7aae448e 100644
--- a/Modules/FindosgWidget.cmake
+++ b/Modules/FindosgWidget.cmake
@@ -1,37 +1,38 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindosgWidget
-# -------------
-#
-#
-#
-# This is part of the Findosg* suite used to find OpenSceneGraph
-# components. Each component is separate and you must opt in to each
-# module. You must also opt into OpenGL and OpenThreads (and Producer
-# if needed) as these modules won't do it for you. This is to allow you
-# control over your own system piece by piece in case you need to opt
-# out of certain components or change the Find behavior for a particular
-# module (perhaps because the default FindOpenGL.cmake module doesn't
-# work with your system as an example). If you want to use a more
-# convenient module that includes everything, use the
-# FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
-#
-# Locate osgWidget This module defines
-#
-# OSGWIDGET_FOUND - Was osgWidget found? OSGWIDGET_INCLUDE_DIR - Where
-# to find the headers OSGWIDGET_LIBRARIES - The libraries to link for
-# osgWidget (use this)
-#
-# OSGWIDGET_LIBRARY - The osgWidget library OSGWIDGET_LIBRARY_DEBUG -
-# The osgWidget debug library
-#
-# $OSGDIR is an environment variable that would correspond to the
-# ./configure --prefix=$OSGDIR used in building osg.
-#
-# FindosgWidget.cmake tweaked from Findosg* suite as created by Eric
-# Wing.
+#[=======================================================================[.rst:
+FindosgWidget
+-------------
+
+
+
+This is part of the Findosg* suite used to find OpenSceneGraph
+components. Each component is separate and you must opt in to each
+module. You must also opt into OpenGL and OpenThreads (and Producer
+if needed) as these modules won't do it for you. This is to allow you
+control over your own system piece by piece in case you need to opt
+out of certain components or change the Find behavior for a particular
+module (perhaps because the default FindOpenGL.cmake module doesn't
+work with your system as an example). If you want to use a more
+convenient module that includes everything, use the
+FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules.
+
+Locate osgWidget This module defines
+
+OSGWIDGET_FOUND - Was osgWidget found? OSGWIDGET_INCLUDE_DIR - Where
+to find the headers OSGWIDGET_LIBRARIES - The libraries to link for
+osgWidget (use this)
+
+OSGWIDGET_LIBRARY - The osgWidget library OSGWIDGET_LIBRARY_DEBUG -
+The osgWidget debug library
+
+$OSGDIR is an environment variable that would correspond to the
+./configure --prefix=$OSGDIR used in building osg.
+
+FindosgWidget.cmake tweaked from Findosg* suite as created by Eric
+Wing.
+#]=======================================================================]
# Header files are presumed to be included like
# #include <osg/PositionAttitudeTransform>
diff --git a/Modules/Findosg_functions.cmake b/Modules/Findosg_functions.cmake
index c81c4485e..563b6bd7a 100644
--- a/Modules/Findosg_functions.cmake
+++ b/Modules/Findosg_functions.cmake
@@ -1,41 +1,38 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# Findosg_functions
-# -----------------
-#
-#
-#
-#
-#
-# This CMake file contains two macros to assist with searching for OSG
-# libraries and nodekits. Please see FindOpenSceneGraph.cmake for full
-# documentation.
+#[=======================================================================[.rst:
+Findosg_functions
+-----------------
+
+
+
+
+
+This CMake file contains two macros to assist with searching for OSG
+libraries and nodekits. Please see FindOpenSceneGraph.cmake for full
+documentation.
+#]=======================================================================]
+
+include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
#
# OSG_FIND_PATH
#
function(OSG_FIND_PATH module header)
- string(TOUPPER ${module} module_uc)
-
- # Try the user's environment request before anything else.
- find_path(${module_uc}_INCLUDE_DIR ${header}
- HINTS
- ENV ${module_uc}_DIR
- ENV OSG_DIR
- ENV OSGDIR
- ENV OSG_ROOT
- ${${module_uc}_DIR}
- ${OSG_DIR}
- PATH_SUFFIXES include
- PATHS
- /sw # Fink
- /opt/local # DarwinPorts
- /opt/csw # Blastwave
- /opt
- /usr/freeware
- )
+ string(TOUPPER ${module} module_uc)
+
+ # Try the user's environment request before anything else.
+ find_path(${module_uc}_INCLUDE_DIR ${header}
+ HINTS
+ ENV ${module_uc}_DIR
+ ENV OSG_DIR
+ ENV OSGDIR
+ ENV OSG_ROOT
+ ${${module_uc}_DIR}
+ ${OSG_DIR}
+ PATH_SUFFIXES include
+ )
endfunction()
@@ -43,56 +40,38 @@ endfunction()
# OSG_FIND_LIBRARY
#
function(OSG_FIND_LIBRARY module library)
- string(TOUPPER ${module} module_uc)
-
- find_library(${module_uc}_LIBRARY
- NAMES ${library}
- HINTS
- ENV ${module_uc}_DIR
- ENV OSG_DIR
- ENV OSGDIR
- ENV OSG_ROOT
- ${${module_uc}_DIR}
- ${OSG_DIR}
- PATH_SUFFIXES lib
- PATHS
- /sw # Fink
- /opt/local # DarwinPorts
- /opt/csw # Blastwave
- /opt
- /usr/freeware
- )
-
- find_library(${module_uc}_LIBRARY_DEBUG
- NAMES ${library}d
- HINTS
- ENV ${module_uc}_DIR
- ENV OSG_DIR
- ENV OSGDIR
- ENV OSG_ROOT
- ${${module_uc}_DIR}
- ${OSG_DIR}
- PATH_SUFFIXES lib
- PATHS
- /sw # Fink
- /opt/local # DarwinPorts
- /opt/csw # Blastwave
- /opt
- /usr/freeware
- )
-
- if(NOT ${module_uc}_LIBRARY_DEBUG)
- # They don't have a debug library
- set(${module_uc}_LIBRARY_DEBUG ${${module_uc}_LIBRARY} PARENT_SCOPE)
- set(${module_uc}_LIBRARIES ${${module_uc}_LIBRARY} PARENT_SCOPE)
- else()
- # They really have a FOO_LIBRARY_DEBUG
- set(${module_uc}_LIBRARIES
- optimized ${${module_uc}_LIBRARY}
- debug ${${module_uc}_LIBRARY_DEBUG}
- PARENT_SCOPE
- )
- endif()
+ string(TOUPPER ${module} module_uc)
+
+ find_library(${module_uc}_LIBRARY_RELEASE
+ NAMES ${library}
+ HINTS
+ ENV ${module_uc}_DIR
+ ENV OSG_DIR
+ ENV OSGDIR
+ ENV OSG_ROOT
+ ${${module_uc}_DIR}
+ ${OSG_DIR}
+ PATH_SUFFIXES lib
+ )
+
+ find_library(${module_uc}_LIBRARY_DEBUG
+ NAMES ${library}d
+ HINTS
+ ENV ${module_uc}_DIR
+ ENV OSG_DIR
+ ENV OSGDIR
+ ENV OSG_ROOT
+ ${${module_uc}_DIR}
+ ${OSG_DIR}
+ PATH_SUFFIXES lib
+ )
+
+ select_library_configurations(${module_uc})
+
+ # the variables set by select_library_configurations go out of scope
+ # here, so we need to set them again
+ set(${module_uc}_LIBRARY ${${module_uc}_LIBRARY} PARENT_SCOPE)
+ set(${module_uc}_LIBRARIES ${${module_uc}_LIBRARIES} PARENT_SCOPE)
endfunction()
#
@@ -100,8 +79,8 @@ endfunction()
# Just a convenience function for calling MARK_AS_ADVANCED
#
function(OSG_MARK_AS_ADVANCED _module)
- string(TOUPPER ${_module} _module_UC)
- mark_as_advanced(${_module_UC}_INCLUDE_DIR)
- mark_as_advanced(${_module_UC}_LIBRARY)
- mark_as_advanced(${_module_UC}_LIBRARY_DEBUG)
+ string(TOUPPER ${_module} _module_UC)
+ mark_as_advanced(${_module_UC}_INCLUDE_DIR)
+ mark_as_advanced(${_module_UC}_LIBRARY)
+ mark_as_advanced(${_module_UC}_LIBRARY_DEBUG)
endfunction()
diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake
index af4daf061..93ac51dee 100644
--- a/Modules/FindwxWidgets.cmake
+++ b/Modules/FindwxWidgets.cmake
@@ -1,111 +1,112 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindwxWidgets
-# -------------
-#
-# Find a wxWidgets (a.k.a., wxWindows) installation.
-#
-# This module finds if wxWidgets is installed and selects a default
-# configuration to use. wxWidgets is a modular library. To specify the
-# modules that you will use, you need to name them as components to the
-# package:
-#
-# find_package(wxWidgets COMPONENTS core base ...)
-#
-# There are two search branches: a windows style and a unix style. For
-# windows, the following variables are searched for and set to defaults
-# in case of multiple choices. Change them if the defaults are not
-# desired (i.e., these are the only variables you should change to
-# select a configuration):
-#
-# ::
-#
-# wxWidgets_ROOT_DIR - Base wxWidgets directory
-# (e.g., C:/wxWidgets-2.6.3).
-# wxWidgets_LIB_DIR - Path to wxWidgets libraries
-# (e.g., C:/wxWidgets-2.6.3/lib/vc_lib).
-# wxWidgets_CONFIGURATION - Configuration to use
-# (e.g., msw, mswd, mswu, mswunivud, etc.)
-# wxWidgets_EXCLUDE_COMMON_LIBRARIES
-# - Set to TRUE to exclude linking of
-# commonly required libs (e.g., png tiff
-# jpeg zlib regex expat).
-#
-#
-#
-# For unix style it uses the wx-config utility. You can select between
-# debug/release, unicode/ansi, universal/non-universal, and
-# static/shared in the QtDialog or ccmake interfaces by turning ON/OFF
-# the following variables:
-#
-# ::
-#
-# wxWidgets_USE_DEBUG
-# wxWidgets_USE_UNICODE
-# wxWidgets_USE_UNIVERSAL
-# wxWidgets_USE_STATIC
-#
-#
-#
-# There is also a wxWidgets_CONFIG_OPTIONS variable for all other
-# options that need to be passed to the wx-config utility. For example,
-# to use the base toolkit found in the /usr/local path, set the variable
-# (before calling the FIND_PACKAGE command) as such:
-#
-# ::
-#
-# set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr)
-#
-#
-#
-# The following are set after the configuration is done for both windows
-# and unix style:
-#
-# ::
-#
-# wxWidgets_FOUND - Set to TRUE if wxWidgets was found.
-# wxWidgets_INCLUDE_DIRS - Include directories for WIN32
-# i.e., where to find "wx/wx.h" and
-# "wx/setup.h"; possibly empty for unices.
-# wxWidgets_LIBRARIES - Path to the wxWidgets libraries.
-# wxWidgets_LIBRARY_DIRS - compile time link dirs, useful for
-# rpath on UNIX. Typically an empty string
-# in WIN32 environment.
-# wxWidgets_DEFINITIONS - Contains defines required to compile/link
-# against WX, e.g. WXUSINGDLL
-# wxWidgets_DEFINITIONS_DEBUG- Contains defines required to compile/link
-# against WX debug builds, e.g. __WXDEBUG__
-# wxWidgets_CXX_FLAGS - Include dirs and compiler flags for
-# unices, empty on WIN32. Essentially
-# "`wx-config --cxxflags`".
-# wxWidgets_USE_FILE - Convenience include file.
-#
-#
-#
-# Sample usage:
-#
-# ::
-#
-# # Note that for MinGW users the order of libs is important!
-# find_package(wxWidgets COMPONENTS net gl core base)
-# if(wxWidgets_FOUND)
-# include(${wxWidgets_USE_FILE})
-# # and for each of your dependent executable/library targets:
-# target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
-# endif()
-#
-#
-#
-# If wxWidgets is required (i.e., not an optional part):
-#
-# ::
-#
-# find_package(wxWidgets REQUIRED net gl core base)
-# include(${wxWidgets_USE_FILE})
-# # and for each of your dependent executable/library targets:
-# target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
+#[=======================================================================[.rst:
+FindwxWidgets
+-------------
+
+Find a wxWidgets (a.k.a., wxWindows) installation.
+
+This module finds if wxWidgets is installed and selects a default
+configuration to use. wxWidgets is a modular library. To specify the
+modules that you will use, you need to name them as components to the
+package:
+
+find_package(wxWidgets COMPONENTS core base ... OPTIONAL_COMPONENTS net ...)
+
+There are two search branches: a windows style and a unix style. For
+windows, the following variables are searched for and set to defaults
+in case of multiple choices. Change them if the defaults are not
+desired (i.e., these are the only variables you should change to
+select a configuration):
+
+::
+
+ wxWidgets_ROOT_DIR - Base wxWidgets directory
+ (e.g., C:/wxWidgets-2.6.3).
+ wxWidgets_LIB_DIR - Path to wxWidgets libraries
+ (e.g., C:/wxWidgets-2.6.3/lib/vc_lib).
+ wxWidgets_CONFIGURATION - Configuration to use
+ (e.g., msw, mswd, mswu, mswunivud, etc.)
+ wxWidgets_EXCLUDE_COMMON_LIBRARIES
+ - Set to TRUE to exclude linking of
+ commonly required libs (e.g., png tiff
+ jpeg zlib regex expat).
+
+
+
+For unix style it uses the wx-config utility. You can select between
+debug/release, unicode/ansi, universal/non-universal, and
+static/shared in the QtDialog or ccmake interfaces by turning ON/OFF
+the following variables:
+
+::
+
+ wxWidgets_USE_DEBUG
+ wxWidgets_USE_UNICODE
+ wxWidgets_USE_UNIVERSAL
+ wxWidgets_USE_STATIC
+
+
+
+There is also a wxWidgets_CONFIG_OPTIONS variable for all other
+options that need to be passed to the wx-config utility. For example,
+to use the base toolkit found in the /usr/local path, set the variable
+(before calling the FIND_PACKAGE command) as such:
+
+::
+
+ set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr)
+
+
+
+The following are set after the configuration is done for both windows
+and unix style:
+
+::
+
+ wxWidgets_FOUND - Set to TRUE if wxWidgets was found.
+ wxWidgets_INCLUDE_DIRS - Include directories for WIN32
+ i.e., where to find "wx/wx.h" and
+ "wx/setup.h"; possibly empty for unices.
+ wxWidgets_LIBRARIES - Path to the wxWidgets libraries.
+ wxWidgets_LIBRARY_DIRS - compile time link dirs, useful for
+ rpath on UNIX. Typically an empty string
+ in WIN32 environment.
+ wxWidgets_DEFINITIONS - Contains defines required to compile/link
+ against WX, e.g. WXUSINGDLL
+ wxWidgets_DEFINITIONS_DEBUG- Contains defines required to compile/link
+ against WX debug builds, e.g. __WXDEBUG__
+ wxWidgets_CXX_FLAGS - Include dirs and compiler flags for
+ unices, empty on WIN32. Essentially
+ "`wx-config --cxxflags`".
+ wxWidgets_USE_FILE - Convenience include file.
+
+
+
+Sample usage:
+
+::
+
+ # Note that for MinGW users the order of libs is important!
+ find_package(wxWidgets COMPONENTS gl core base OPTIONAL_COMPONENTS net)
+ if(wxWidgets_FOUND)
+ include(${wxWidgets_USE_FILE})
+ # and for each of your dependent executable/library targets:
+ target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
+ endif()
+
+
+
+If wxWidgets is required (i.e., not an optional part):
+
+::
+
+ find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net)
+ include(${wxWidgets_USE_FILE})
+ # and for each of your dependent executable/library targets:
+ target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
+#]=======================================================================]
#
# FIXME: check this and provide a correct sample usage...
@@ -242,22 +243,24 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
#-------------------------------------------------------------------
#
# Get filename components for a configuration. For example,
- # if _CONFIGURATION = mswunivud, then _UNV=univ, _UCD=u _DBG=d
- # if _CONFIGURATION = mswu, then _UNV="", _UCD=u _DBG=""
+ # if _CONFIGURATION = mswunivud, then _PF="msw", _UNV=univ, _UCD=u _DBG=d
+ # if _CONFIGURATION = mswu, then _PF="msw", _UNV="", _UCD=u _DBG=""
#
- macro(WX_GET_NAME_COMPONENTS _CONFIGURATION _UNV _UCD _DBG)
+ macro(WX_GET_NAME_COMPONENTS _CONFIGURATION _PF _UNV _UCD _DBG)
+ DBG_MSG_V(${_CONFIGURATION})
string(REGEX MATCH "univ" ${_UNV} "${_CONFIGURATION}")
- string(REGEX REPLACE "msw.*(u)[d]*$" "u" ${_UCD} "${_CONFIGURATION}")
+ string(REGEX REPLACE "[msw|qt].*(u)[d]*$" "u" ${_UCD} "${_CONFIGURATION}")
if(${_UCD} STREQUAL ${_CONFIGURATION})
set(${_UCD} "")
endif()
string(REGEX MATCH "d$" ${_DBG} "${_CONFIGURATION}")
+ string(REGEX MATCH "^[msw|qt]*" ${_PF} "${_CONFIGURATION}")
endmacro()
#
# Find libraries associated to a configuration.
#
- macro(WX_FIND_LIBS _UNV _UCD _DBG)
+ macro(WX_FIND_LIBS _PF _UNV _UCD _DBG)
DBG_MSG_V("m_unv = ${_UNV}")
DBG_MSG_V("m_ucd = ${_UCD}")
DBG_MSG_V("m_dbg = ${_DBG}")
@@ -309,13 +312,13 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
# Find wxWidgets monolithic library.
find_library(WX_mono${_DBG}
NAMES
- wxmsw${_UNV}31${_UCD}${_DBG}
- wxmsw${_UNV}30${_UCD}${_DBG}
- wxmsw${_UNV}29${_UCD}${_DBG}
- wxmsw${_UNV}28${_UCD}${_DBG}
- wxmsw${_UNV}27${_UCD}${_DBG}
- wxmsw${_UNV}26${_UCD}${_DBG}
- wxmsw${_UNV}25${_UCD}${_DBG}
+ wx${_PF}${_UNV}31${_UCD}${_DBG}
+ wx${_PF}${_UNV}30${_UCD}${_DBG}
+ wx${_PF}${_UNV}29${_UCD}${_DBG}
+ wx${_PF}${_UNV}28${_UCD}${_DBG}
+ wx${_PF}${_UNV}27${_UCD}${_DBG}
+ wx${_PF}${_UNV}26${_UCD}${_DBG}
+ wx${_PF}${_UNV}25${_UCD}${_DBG}
PATHS ${WX_LIB_DIR}
NO_DEFAULT_PATH
)
@@ -326,13 +329,13 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
stc ribbon propgrid webview)
find_library(WX_${LIB}${_DBG}
NAMES
- wxmsw${_UNV}31${_UCD}${_DBG}_${LIB}
- wxmsw${_UNV}30${_UCD}${_DBG}_${LIB}
- wxmsw${_UNV}29${_UCD}${_DBG}_${LIB}
- wxmsw${_UNV}28${_UCD}${_DBG}_${LIB}
- wxmsw${_UNV}27${_UCD}${_DBG}_${LIB}
- wxmsw${_UNV}26${_UCD}${_DBG}_${LIB}
- wxmsw${_UNV}25${_UCD}${_DBG}_${LIB}
+ wx${_PF}${_UNV}31${_UCD}${_DBG}_${LIB}
+ wx${_PF}${_UNV}30${_UCD}${_DBG}_${LIB}
+ wx${_PF}${_UNV}29${_UCD}${_DBG}_${LIB}
+ wx${_PF}${_UNV}28${_UCD}${_DBG}_${LIB}
+ wx${_PF}${_UNV}27${_UCD}${_DBG}_${LIB}
+ wx${_PF}${_UNV}26${_UCD}${_DBG}_${LIB}
+ wx${_PF}${_UNV}25${_UCD}${_DBG}_${LIB}
PATHS ${WX_LIB_DIR}
NO_DEFAULT_PATH
)
@@ -396,6 +399,9 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
list(APPEND wxWidgets_LIBRARIES
debug ${WX_${LIB}d} optimized ${WX_${LIB}}
)
+ set(wxWidgets_${LIB}_FOUND TRUE)
+ elseif(NOT wxWidgets_FIND_REQUIRED_${LIB})
+ DBG_MSG_V("- ignored optional missing WX_${LIB}=${WX_${LIB}} or WX_${LIB}d=${WX_${LIB}d}")
else()
DBG_MSG_V("- not found due to missing WX_${LIB}=${WX_${LIB}} or WX_${LIB}d=${WX_${LIB}d}")
set(wxWidgets_FOUND FALSE)
@@ -408,9 +414,11 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
if(WX_${LIB}${_DBG})
DBG_MSG_V("Found ${LIB}${_DBG}")
list(APPEND wxWidgets_LIBRARIES ${WX_${LIB}${_DBG}})
+ set(wxWidgets_${LIB}_FOUND TRUE)
+ elseif(NOT wxWidgets_FIND_REQUIRED_${LIB})
+ DBG_MSG_V("- ignored optional missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}")
else()
- DBG_MSG_V(
- "- not found due to missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}")
+ DBG_MSG_V("- not found due to missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}")
set(wxWidgets_FOUND FALSE)
endif()
endforeach()
@@ -423,7 +431,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
list(APPEND wxWidgets_LIBRARIES opengl32 glu32)
endif()
- list(APPEND wxWidgets_LIBRARIES winmm comctl32 oleacc rpcrt4 shlwapi version wsock32)
+ list(APPEND wxWidgets_LIBRARIES winmm comctl32 uuid oleacc uxtheme rpcrt4 shlwapi version wsock32)
endmacro()
#-------------------------------------------------------------------
@@ -498,19 +506,9 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
set(_WX_TOOL gcc)
elseif(MSVC)
set(_WX_TOOL vc)
- if(MSVC_VERSION EQUAL 1910)
- set(_WX_TOOLVER 141)
- elseif(MSVC_VERSION EQUAL 1900)
- set(_WX_TOOLVER 140)
- elseif(MSVC_VERSION EQUAL 1800)
- set(_WX_TOOLVER 120)
- elseif(MSVC_VERSION EQUAL 1700)
- set(_WX_TOOLVER 110)
- elseif(MSVC_VERSION EQUAL 1600)
- set(_WX_TOOLVER 100)
- elseif(MSVC_VERSION EQUAL 1500)
- set(_WX_TOOLVER 90)
- endif()
+ set(_WX_TOOLVER ${MSVC_TOOLSET_VERSION})
+ # support for a lib/vc14x_x64_dll/ path from wxW 3.1.3 distribution
+ string(REGEX REPLACE ".$" "x" _WX_TOOLVERx ${_WX_TOOLVER})
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_WX_ARCH _x64)
endif()
@@ -518,6 +516,8 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
if(BUILD_SHARED_LIBS)
find_path(wxWidgets_LIB_DIR
NAMES
+ qtu/wx/setup.h
+ qtud/wx/setup.h
msw/wx/setup.h
mswd/wx/setup.h
mswu/wx/setup.h
@@ -527,9 +527,15 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
mswunivu/wx/setup.h
mswunivud/wx/setup.h
PATHS
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}_xp${_WX_ARCH}_dll # prefer shared
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_dll # prefer shared
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}_xp${_WX_ARCH}_dll # prefer shared
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}${_WX_ARCH}_dll # prefer shared
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_dll # prefer shared
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}_xp${_WX_ARCH}_lib
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_lib
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}_xp${_WX_ARCH}_lib
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}${_WX_ARCH}_lib
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_lib
DOC "Path to wxWidgets libraries"
NO_DEFAULT_PATH
@@ -537,6 +543,8 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
else()
find_path(wxWidgets_LIB_DIR
NAMES
+ qtu/wx/setup.h
+ qtud/wx/setup.h
msw/wx/setup.h
mswd/wx/setup.h
mswu/wx/setup.h
@@ -546,9 +554,15 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
mswunivu/wx/setup.h
mswunivud/wx/setup.h
PATHS
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}_xp${_WX_ARCH}_lib # prefer static
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_lib # prefer static
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}_xp${_WX_ARCH}_lib # prefer static
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}${_WX_ARCH}_lib # prefer static
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_lib # prefer static
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}_xp${_WX_ARCH}_dll
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVER}${_WX_ARCH}_dll
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}_xp${_WX_ARCH}_dll
+ ${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_TOOLVERx}${_WX_ARCH}_dll
${WX_ROOT_DIR}/lib/${_WX_TOOL}${_WX_ARCH}_dll
DOC "Path to wxWidgets libraries"
NO_DEFAULT_PATH
@@ -573,7 +587,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
endif()
# Search for available configuration types.
- foreach(CFG mswunivud mswunivd mswud mswd mswunivu mswuniv mswu msw)
+ foreach(CFG mswunivud mswunivd mswud mswd mswunivu mswuniv mswu msw qt qtd qtu qtud)
set(WX_${CFG}_FOUND FALSE)
if(EXISTS ${WX_LIB_DIR}/${CFG})
list(APPEND WX_CONFIGURATION_LIST ${CFG})
@@ -613,7 +627,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
endif()
# Get configuration parameters from the name.
- WX_GET_NAME_COMPONENTS(${wxWidgets_CONFIGURATION} UNV UCD DBG)
+ WX_GET_NAME_COMPONENTS(${wxWidgets_CONFIGURATION} PF UNV UCD DBG)
# Set wxWidgets lib setup include directory.
if(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h)
@@ -633,9 +647,9 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
endif()
# Find wxWidgets libraries.
- WX_FIND_LIBS("${UNV}" "${UCD}" "${DBG}")
+ WX_FIND_LIBS("${PF}" "${UNV}" "${UCD}" "${DBG}")
if(WX_USE_REL_AND_DBG)
- WX_FIND_LIBS("${UNV}" "${UCD}" "d")
+ WX_FIND_LIBS("${PF}" "${UNV}" "${UCD}" "d")
endif()
# Settings for requested libs (i.e., include dir, libraries, etc.).
@@ -747,7 +761,7 @@ else()
#-----------------------------------------------------------------
# Support cross-compiling, only search in the target platform.
find_program(wxWidgets_CONFIG_EXECUTABLE
- NAMES wx-config wx-config-3.1 wx-config-3.0 wx-config-2.9 wx-config-2.8
+ NAMES $ENV{WX_CONFIG} wx-config wx-config-3.1 wx-config-3.0 wx-config-2.9 wx-config-2.8
DOC "Location of wxWidgets library configuration provider binary (wx-config)."
ONLY_CMAKE_FIND_ROOT_PATH
)
@@ -778,28 +792,24 @@ else()
)
if(RET EQUAL 0)
string(STRIP "${wxWidgets_CXX_FLAGS}" wxWidgets_CXX_FLAGS)
- separate_arguments(wxWidgets_CXX_FLAGS)
+ separate_arguments(wxWidgets_CXX_FLAGS_LIST NATIVE_COMMAND "${wxWidgets_CXX_FLAGS}")
DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
- # parse definitions from cxxflags;
- # drop -D* from CXXFLAGS and the -D prefix
- string(REGEX MATCHALL "-D[^;]+"
- wxWidgets_DEFINITIONS "${wxWidgets_CXX_FLAGS}")
- string(REGEX REPLACE "-D[^;]+(;|$)" ""
- wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")
- string(REGEX REPLACE ";$" ""
- wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")
- string(REPLACE "-D" ""
- wxWidgets_DEFINITIONS "${wxWidgets_DEFINITIONS}")
-
- # parse include dirs from cxxflags; drop -I prefix
- string(REGEX MATCHALL "-I[^;]+"
- wxWidgets_INCLUDE_DIRS "${wxWidgets_CXX_FLAGS}")
- string(REGEX REPLACE "-I[^;]+;" ""
- wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}")
- string(REPLACE "-I" ""
- wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}")
+ # parse definitions and include dirs from cxxflags
+ # drop the -D and -I prefixes
+ set(wxWidgets_CXX_FLAGS)
+ foreach(arg IN LISTS wxWidgets_CXX_FLAGS_LIST)
+ if("${arg}" MATCHES "^-I(.*)$")
+ # include directory
+ list(APPEND wxWidgets_INCLUDE_DIRS "${CMAKE_MATCH_1}")
+ elseif("${arg}" MATCHES "^-D(.*)$")
+ # compile definition
+ list(APPEND wxWidgets_DEFINITIONS "${CMAKE_MATCH_1}")
+ else()
+ list(APPEND wxWidgets_CXX_FLAGS "${arg}")
+ endif()
+ endforeach()
DBG_MSG_V("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}")
DBG_MSG_V("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}")
@@ -815,11 +825,24 @@ else()
# - NOTE: wx-config doesn't verify that the libs requested exist
# it just produces the names. Maybe a TRY_COMPILE would
# be useful here...
- string(REPLACE ";" ","
- wxWidgets_FIND_COMPONENTS "${wxWidgets_FIND_COMPONENTS}")
+ unset(_cmp_req)
+ unset(_cmp_opt)
+ foreach(_cmp IN LISTS wxWidgets_FIND_COMPONENTS)
+ if(wxWidgets_FIND_REQUIRED_${_cmp})
+ list(APPEND _cmp_req "${_cmp}")
+ else()
+ list(APPEND _cmp_opt "${_cmp}")
+ endif()
+ endforeach()
+ DBG_MSG_V("wxWidgets required components : ${_cmp_req}")
+ DBG_MSG_V("wxWidgets optional components : ${_cmp_opt}")
+ if(DEFINED _cmp_opt)
+ string(REPLACE ";" "," _cmp_opt "--optional-libs ${_cmp_opt}")
+ endif()
+ string(REPLACE ";" "," _cmp_req "${_cmp_req}")
execute_process(
COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
- ${wxWidgets_SELECT_OPTIONS} --libs ${wxWidgets_FIND_COMPONENTS}
+ ${wxWidgets_SELECT_OPTIONS} --libs ${_cmp_req} ${_cmp_opt}
OUTPUT_VARIABLE wxWidgets_LIBRARIES
RESULT_VARIABLE RET
ERROR_QUIET
@@ -829,6 +852,8 @@ else()
separate_arguments(wxWidgets_LIBRARIES)
string(REPLACE "-framework;" "-framework "
wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
+ string(REPLACE "-weak_framework;" "-weak_framework "
+ wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
string(REPLACE "-arch;" "-arch "
wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
string(REPLACE "-isysroot;" "-isysroot "
@@ -837,7 +862,7 @@ else()
# extract linkdirs (-L) for rpath (i.e., LINK_DIRECTORIES)
string(REGEX MATCHALL "-L[^;]+"
wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARIES}")
- string(REPLACE "-L" ""
+ string(REGEX REPLACE "-L([^;]+)" "\\1"
wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARY_DIRS}")
DBG_MSG_V("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}")
@@ -845,8 +870,10 @@ else()
else()
set(wxWidgets_FOUND FALSE)
- DBG_MSG("${wxWidgets_CONFIG_EXECUTABLE} --libs ${wxWidgets_FIND_COMPONENTS} FAILED with RET=${RET}")
+ DBG_MSG("${wxWidgets_CONFIG_EXECUTABLE} --libs ${_cmp_req} ${_cmp_opt} FAILED with RET=${RET}")
endif()
+ unset(_cmp_req)
+ unset(_cmp_opt)
endif()
# When using wx-config in MSYS, the include paths are UNIX style paths which may or may
@@ -875,6 +902,26 @@ else()
set(wxWidgets_INCLUDE_DIRS ${_tmp_path})
separate_arguments(wxWidgets_INCLUDE_DIRS)
list(REMOVE_ITEM wxWidgets_INCLUDE_DIRS "")
+
+ set(_tmp_path "")
+ foreach(_path ${wxWidgets_LIBRARY_DIRS})
+ execute_process(
+ COMMAND cygpath -w ${_path}
+ OUTPUT_VARIABLE _native_path
+ RESULT_VARIABLE _retv
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+ )
+ if(_retv EQUAL 0)
+ file(TO_CMAKE_PATH ${_native_path} _native_path)
+ DBG_MSG_V("Path ${_path} converted to ${_native_path}")
+ string(APPEND _tmp_path " ${_native_path}")
+ endif()
+ endforeach()
+ DBG_MSG("Setting wxWidgets_LIBRARY_DIRS = ${_tmp_path}")
+ set(wxWidgets_LIBRARY_DIRS ${_tmp_path})
+ separate_arguments(wxWidgets_LIBRARY_DIRS)
+ list(REMOVE_ITEM wxWidgets_LIBRARY_DIRS "")
endif()
unset(_cygpath_exe CACHE)
endif()
@@ -915,16 +962,18 @@ if (_wx_lib_missing)
endif()
unset(_wx_lib_missing)
-# Check if a specfic version was requested by find_package().
+# Check if a specific version was requested by find_package().
if(wxWidgets_FOUND)
- find_file(_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH)
- dbg_msg("_filename: ${_filename}")
+ unset(_wx_filename)
+ find_file(_wx_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH)
+ dbg_msg("_wx_filename: ${_wx_filename}")
- if(NOT _filename)
+ if(NOT _wx_filename)
message(FATAL_ERROR "wxWidgets wx/version.h file not found in ${wxWidgets_INCLUDE_DIRS}.")
endif()
- file(READ ${_filename} _wx_version_h)
+ file(READ "${_wx_filename}" _wx_version_h)
+ unset(_wx_filename CACHE)
string(REGEX REPLACE "^(.*\n)?#define +wxMAJOR_VERSION +([0-9]+).*"
"\\2" wxWidgets_VERSION_MAJOR "${_wx_version_h}" )
@@ -950,10 +999,18 @@ DBG_MSG("wxWidgets_USE_FILE : ${wxWidgets_USE_FILE}")
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+# FIXME: set wxWidgets_<comp>_FOUND for wx-config branch
+# and use HANDLE_COMPONENTS on Unix too
+if(wxWidgets_FIND_STYLE STREQUAL "win32")
+ set(wxWidgets_HANDLE_COMPONENTS "HANDLE_COMPONENTS")
+endif()
+
find_package_handle_standard_args(wxWidgets
REQUIRED_VARS wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS
VERSION_VAR wxWidgets_VERSION_STRING
+ ${wxWidgets_HANDLE_COMPONENTS}
)
+unset(wxWidgets_HANDLE_COMPONENTS)
#=====================================================================
# Macros for use in wxWidgets apps.
@@ -964,8 +1021,9 @@ find_package_handle_standard_args(wxWidgets
#=====================================================================
# Resource file compiler.
-find_program(wxWidgets_wxrc_EXECUTABLE wxrc
- ${wxWidgets_ROOT_DIR}/utils/wxrc/vc_msw
+find_program(wxWidgets_wxrc_EXECUTABLE
+ NAMES $ENV{WXRC_CMD} wxrc
+ PATHS ${wxWidgets_ROOT_DIR}/utils/wxrc/vc_msw
DOC "Location of wxWidgets resource file compiler binary (wxrc)"
)
diff --git a/Modules/FindwxWindows.cmake b/Modules/FindwxWindows.cmake
index 76eb6be47..35840f5f9 100644
--- a/Modules/FindwxWindows.cmake
+++ b/Modules/FindwxWindows.cmake
@@ -1,84 +1,87 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# FindwxWindows
-# -------------
-#
-# Find wxWindows (wxWidgets) installation
-#
-# This module finds if wxWindows/wxWidgets is installed and determines
-# where the include files and libraries are. It also determines what
-# the name of the library is. Please note this file is DEPRECATED and
-# replaced by FindwxWidgets.cmake. This code sets the following
-# variables:
-#
-# ::
-#
-# WXWINDOWS_FOUND = system has WxWindows
-# WXWINDOWS_LIBRARIES = path to the wxWindows libraries
-# on Unix/Linux with additional
-# linker flags from
-# "wx-config --libs"
-# CMAKE_WXWINDOWS_CXX_FLAGS = Compiler flags for wxWindows,
-# essentially "`wx-config --cxxflags`"
-# on Linux
-# WXWINDOWS_INCLUDE_DIR = where to find "wx/wx.h" and "wx/setup.h"
-# WXWINDOWS_LINK_DIRECTORIES = link directories, useful for rpath on
-# Unix
-# WXWINDOWS_DEFINITIONS = extra defines
-#
-#
-#
-# OPTIONS If you need OpenGL support please
-#
-# ::
-#
-# set(WXWINDOWS_USE_GL 1)
-#
-# in your CMakeLists.txt *before* you include this file.
-#
-# ::
-#
-# HAVE_ISYSTEM - true required to replace -I by -isystem on g++
-#
-#
-#
-# For convenience include Use_wxWindows.cmake in your project's
-# CMakeLists.txt using
-# include(${CMAKE_CURRENT_LIST_DIR}/Use_wxWindows.cmake).
-#
-# USAGE
-#
-# ::
-#
-# set(WXWINDOWS_USE_GL 1)
-# find_package(wxWindows)
-#
-#
-#
-# NOTES wxWidgets 2.6.x is supported for monolithic builds e.g.
-# compiled in wx/build/msw dir as:
-#
-# ::
-#
-# nmake -f makefile.vc BUILD=debug SHARED=0 USE_OPENGL=1 MONOLITHIC=1
-#
-#
-#
-# DEPRECATED
-#
-# ::
-#
-# CMAKE_WX_CAN_COMPILE
-# WXWINDOWS_LIBRARY
-# CMAKE_WX_CXX_FLAGS
-# WXWINDOWS_INCLUDE_PATH
-#
-#
-#
-# AUTHOR Jan Woetzel <http://www.mip.informatik.uni-kiel.de/~jw>
-# (07/2003-01/2006)
+#[=======================================================================[.rst:
+FindwxWindows
+-------------
+
+.. deprecated:: 3.0
+
+ Replaced by :module:`FindwxWidgets`.
+
+Find wxWindows (wxWidgets) installation
+
+This module finds if wxWindows/wxWidgets is installed and determines
+where the include files and libraries are. It also determines what
+the name of the library is. This code sets the following variables:
+
+::
+
+ WXWINDOWS_FOUND = system has WxWindows
+ WXWINDOWS_LIBRARIES = path to the wxWindows libraries
+ on Unix/Linux with additional
+ linker flags from
+ "wx-config --libs"
+ CMAKE_WXWINDOWS_CXX_FLAGS = Compiler flags for wxWindows,
+ essentially "`wx-config --cxxflags`"
+ on Linux
+ WXWINDOWS_INCLUDE_DIR = where to find "wx/wx.h" and "wx/setup.h"
+ WXWINDOWS_LINK_DIRECTORIES = link directories, useful for rpath on
+ Unix
+ WXWINDOWS_DEFINITIONS = extra defines
+
+
+
+OPTIONS If you need OpenGL support please
+
+::
+
+ set(WXWINDOWS_USE_GL 1)
+
+in your CMakeLists.txt *before* you include this file.
+
+::
+
+ HAVE_ISYSTEM - true required to replace -I by -isystem on g++
+
+
+
+For convenience include Use_wxWindows.cmake in your project's
+CMakeLists.txt using
+include(${CMAKE_CURRENT_LIST_DIR}/Use_wxWindows.cmake).
+
+USAGE
+
+::
+
+ set(WXWINDOWS_USE_GL 1)
+ find_package(wxWindows)
+
+
+
+NOTES wxWidgets 2.6.x is supported for monolithic builds e.g.
+compiled in wx/build/msw dir as:
+
+::
+
+ nmake -f makefile.vc BUILD=debug SHARED=0 USE_OPENGL=1 MONOLITHIC=1
+
+
+
+DEPRECATED
+
+::
+
+ CMAKE_WX_CAN_COMPILE
+ WXWINDOWS_LIBRARY
+ CMAKE_WX_CXX_FLAGS
+ WXWINDOWS_INCLUDE_PATH
+
+
+
+AUTHOR Jan Woetzel <http://www.mip.informatik.uni-kiel.de/~jw>
+(07/2003-01/2006)
+#]=======================================================================]
# ------------------------------------------------------------------
#
@@ -390,7 +393,7 @@ if(WIN32_STYLE_FIND)
if (NOT WXWINDOWS_USE_SHARED_LIBS)
set(WXWINDOWS_LIBRARIES ${WXWINDOWS_LIBRARIES}
- ## these ones dont seem required, in particular ctl3d32 is not neccesary (Jan Woetzel 07/2003)
+ ## these ones don't seem required, in particular ctl3d32 is not necessary (Jan Woetzel 07/2003)
# ctl3d32
debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_ZLIB} optimized ${WXWINDOWS_STATIC_LIBRARY_ZLIB}
debug ${WXWINDOWS_STATIC_DEBUG_LIBRARY_REGEX} optimized ${WXWINDOWS_STATIC_LIBRARY_REGEX}
@@ -546,7 +549,7 @@ if(WIN32_STYLE_FIND)
endif()
- ## not neccessary in wxWindows 2.4.1 and 2.6.2
+ ## not necessary in wxWindows 2.4.1 and 2.6.2
## but it may fix a previous bug, see
## http://lists.wxwindows.org/cgi-bin/ezmlm-cgi?8:mss:37574:200305:mpdioeneabobmgjenoap
option(WXWINDOWS_SET_DEFINITIONS "Set additional defines for wxWindows" OFF)
@@ -617,7 +620,8 @@ else()
# wx-config should be in your path anyhow, usually no need to set WXWIN or
# search in ../wx or ../../wx
- find_program(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE wx-config
+ find_program(CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE
+ NAMES $ENV{WX_CONFIG} wx-config
HINTS
ENV WXWIN
$ENV{WXWIN}/bin
diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt
index e3b81d7c3..381080bba 100644
--- a/Modules/FortranCInterface/CMakeLists.txt
+++ b/Modules/FortranCInterface/CMakeLists.txt
@@ -15,11 +15,11 @@ int main() { return 0; }
# List manglings of global symbol names to try.
set(global_symbols
my_sub # VisualAge
- my_sub_ # GNU, Intel, HP, SunPro, MIPSpro, PGI
+ my_sub_ # GNU, Intel, HP, SunPro, PGI
my_sub__ # GNU g77
MY_SUB # Intel on Windows
mysub # VisualAge
- mysub_ # GNU, Intel, HP, SunPro, MIPSpro, PGI
+ mysub_ # GNU, Intel, HP, SunPro, PGI
MYSUB # Intel on Windows
${FortranCInterface_GLOBAL_SYMBOLS}
)
@@ -48,7 +48,6 @@ set(module_symbols
list(REMOVE_DUPLICATES module_symbols)
# Note that some compiler manglings cannot be invoked from C:
-# MIPSpro uses "MY_SUB.in.MY_MODULE"
# SunPro uses "my_module.my_sub_"
# PathScale uses "MY_SUB.in.MY_MODULE"
diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake
index 64bd09e68..f95e6e2c5 100644
--- a/Modules/GNUInstallDirs.cmake
+++ b/Modules/GNUInstallDirs.cmake
@@ -1,127 +1,131 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# GNUInstallDirs
-# --------------
-#
-# Define GNU standard installation directories
-#
-# Provides install directory variables as defined by the
-# `GNU Coding Standards`_.
-#
-# .. _`GNU Coding Standards`: https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
-#
-# Result Variables
-# ^^^^^^^^^^^^^^^^
-#
-# Inclusion of this module defines the following variables:
-#
-# ``CMAKE_INSTALL_<dir>``
-#
-# Destination for files of a given type. This value may be passed to
-# the ``DESTINATION`` options of :command:`install` commands for the
-# corresponding file type.
-#
-# ``CMAKE_INSTALL_FULL_<dir>``
-#
-# The absolute path generated from the corresponding ``CMAKE_INSTALL_<dir>``
-# value. If the value is not already an absolute path, an absolute path
-# is constructed typically by prepending the value of the
-# :variable:`CMAKE_INSTALL_PREFIX` variable. However, there are some
-# `special cases`_ as documented below.
-#
-# where ``<dir>`` is one of:
-#
-# ``BINDIR``
-# user executables (``bin``)
-# ``SBINDIR``
-# system admin executables (``sbin``)
-# ``LIBEXECDIR``
-# program executables (``libexec``)
-# ``SYSCONFDIR``
-# read-only single-machine data (``etc``)
-# ``SHAREDSTATEDIR``
-# modifiable architecture-independent data (``com``)
-# ``LOCALSTATEDIR``
-# modifiable single-machine data (``var``)
-# ``RUNSTATEDIR``
-# run-time variable data (``LOCALSTATEDIR/run``)
-# ``LIBDIR``
-# object code libraries (``lib`` or ``lib64``
-# or ``lib/<multiarch-tuple>`` on Debian)
-# ``INCLUDEDIR``
-# C header files (``include``)
-# ``OLDINCLUDEDIR``
-# C header files for non-gcc (``/usr/include``)
-# ``DATAROOTDIR``
-# read-only architecture-independent data root (``share``)
-# ``DATADIR``
-# read-only architecture-independent data (``DATAROOTDIR``)
-# ``INFODIR``
-# info documentation (``DATAROOTDIR/info``)
-# ``LOCALEDIR``
-# locale-dependent data (``DATAROOTDIR/locale``)
-# ``MANDIR``
-# man documentation (``DATAROOTDIR/man``)
-# ``DOCDIR``
-# documentation root (``DATAROOTDIR/doc/PROJECT_NAME``)
-#
-# If the includer does not define a value the above-shown default will be
-# used and the value will appear in the cache for editing by the user.
-#
-# Special Cases
-# ^^^^^^^^^^^^^
-#
-# The following values of :variable:`CMAKE_INSTALL_PREFIX` are special:
-#
-# ``/``
-#
-# For ``<dir>`` other than the ``SYSCONFDIR``, ``LOCALSTATEDIR`` and
-# ``RUNSTATEDIR``, the value of ``CMAKE_INSTALL_<dir>`` is prefixed
-# with ``usr/`` if it is not user-specified as an absolute path.
-# For example, the ``INCLUDEDIR`` value ``include`` becomes ``usr/include``.
-# This is required by the `GNU Coding Standards`_, which state:
-#
-# When building the complete GNU system, the prefix will be empty
-# and ``/usr`` will be a symbolic link to ``/``.
-#
-# ``/usr``
-#
-# For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or
-# ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by
-# prepending just ``/`` to the value of ``CMAKE_INSTALL_<dir>``
-# if it is not user-specified as an absolute path.
-# For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc``.
-# This is required by the `GNU Coding Standards`_.
-#
-# ``/opt/...``
-#
-# For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or
-# ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by
-# *appending* the prefix to the value of ``CMAKE_INSTALL_<dir>``
-# if it is not user-specified as an absolute path.
-# For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc/opt/...``.
-# This is defined by the `Filesystem Hierarchy Standard`_.
-#
-# .. _`Filesystem Hierarchy Standard`: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html
-#
-# Macros
-# ^^^^^^
-#
-# .. command:: GNUInstallDirs_get_absolute_install_dir
-#
-# ::
-#
-# GNUInstallDirs_get_absolute_install_dir(absvar var)
-#
-# Set the given variable ``absvar`` to the absolute path contained
-# within the variable ``var``. This is to allow the computation of an
-# absolute path, accounting for all the special cases documented
-# above. While this macro is used to compute the various
-# ``CMAKE_INSTALL_FULL_<dir>`` variables, it is exposed publicly to
-# allow users who create additional path variables to also compute
-# absolute paths where necessary, using the same logic.
+#[=======================================================================[.rst:
+GNUInstallDirs
+--------------
+
+Define GNU standard installation directories
+
+Provides install directory variables as defined by the
+`GNU Coding Standards`_.
+
+.. _`GNU Coding Standards`: https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+Inclusion of this module defines the following variables:
+
+``CMAKE_INSTALL_<dir>``
+
+ Destination for files of a given type. This value may be passed to
+ the ``DESTINATION`` options of :command:`install` commands for the
+ corresponding file type.
+
+``CMAKE_INSTALL_FULL_<dir>``
+
+ The absolute path generated from the corresponding ``CMAKE_INSTALL_<dir>``
+ value. If the value is not already an absolute path, an absolute path
+ is constructed typically by prepending the value of the
+ :variable:`CMAKE_INSTALL_PREFIX` variable. However, there are some
+ `special cases`_ as documented below.
+
+where ``<dir>`` is one of:
+
+``BINDIR``
+ user executables (``bin``)
+``SBINDIR``
+ system admin executables (``sbin``)
+``LIBEXECDIR``
+ program executables (``libexec``)
+``SYSCONFDIR``
+ read-only single-machine data (``etc``)
+``SHAREDSTATEDIR``
+ modifiable architecture-independent data (``com``)
+``LOCALSTATEDIR``
+ modifiable single-machine data (``var``)
+``RUNSTATEDIR``
+ run-time variable data (``LOCALSTATEDIR/run``)
+``LIBDIR``
+ object code libraries (``lib`` or ``lib64``
+ or ``lib/<multiarch-tuple>`` on Debian)
+``INCLUDEDIR``
+ C header files (``include``)
+``OLDINCLUDEDIR``
+ C header files for non-gcc (``/usr/include``)
+``DATAROOTDIR``
+ read-only architecture-independent data root (``share``)
+``DATADIR``
+ read-only architecture-independent data (``DATAROOTDIR``)
+``INFODIR``
+ info documentation (``DATAROOTDIR/info``)
+``LOCALEDIR``
+ locale-dependent data (``DATAROOTDIR/locale``)
+``MANDIR``
+ man documentation (``DATAROOTDIR/man``)
+``DOCDIR``
+ documentation root (``DATAROOTDIR/doc/PROJECT_NAME``)
+
+If the includer does not define a value the above-shown default will be
+used and the value will appear in the cache for editing by the user.
+
+Special Cases
+^^^^^^^^^^^^^
+
+The following values of :variable:`CMAKE_INSTALL_PREFIX` are special:
+
+``/``
+
+ For ``<dir>`` other than the ``SYSCONFDIR``, ``LOCALSTATEDIR`` and
+ ``RUNSTATEDIR``, the value of ``CMAKE_INSTALL_<dir>`` is prefixed
+ with ``usr/`` if it is not user-specified as an absolute path.
+ For example, the ``INCLUDEDIR`` value ``include`` becomes ``usr/include``.
+ This is required by the `GNU Coding Standards`_, which state:
+
+ When building the complete GNU system, the prefix will be empty
+ and ``/usr`` will be a symbolic link to ``/``.
+
+``/usr``
+
+ For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or
+ ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by
+ prepending just ``/`` to the value of ``CMAKE_INSTALL_<dir>``
+ if it is not user-specified as an absolute path.
+ For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc``.
+ This is required by the `GNU Coding Standards`_.
+
+``/opt/...``
+
+ For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or
+ ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by
+ *appending* the prefix to the value of ``CMAKE_INSTALL_<dir>``
+ if it is not user-specified as an absolute path.
+ For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc/opt/...``.
+ This is defined by the `Filesystem Hierarchy Standard`_.
+
+.. _`Filesystem Hierarchy Standard`: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html
+
+Macros
+^^^^^^
+
+.. command:: GNUInstallDirs_get_absolute_install_dir
+
+ ::
+
+ GNUInstallDirs_get_absolute_install_dir(absvar var)
+
+ Set the given variable ``absvar`` to the absolute path contained
+ within the variable ``var``. This is to allow the computation of an
+ absolute path, accounting for all the special cases documented
+ above. While this macro is used to compute the various
+ ``CMAKE_INSTALL_FULL_<dir>`` variables, it is exposed publicly to
+ allow users who create additional path variables to also compute
+ absolute paths where necessary, using the same logic.
+#]=======================================================================]
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced
# Convert a cache variable to PATH type
@@ -202,7 +206,7 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set
# - we are on Linux system but NOT cross-compiling
# - we are NOT on debian
# - we are on a 64 bits system
- # reason is: amd64 ABI: http://www.x86-64.org/documentation/abi.pdf
+ # reason is: amd64 ABI: https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI
# For Debian with multiarch, use 'lib/${CMAKE_LIBRARY_ARCHITECTURE}' if
# CMAKE_LIBRARY_ARCHITECTURE is set (which contains e.g. "i386-linux-gnu"
# and CMAKE_INSTALL_PREFIX is "/usr"
@@ -218,7 +222,8 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set
# updated to the new default, unless the user explicitly changed it.
endif()
if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
- AND NOT CMAKE_CROSSCOMPILING)
+ AND NOT CMAKE_CROSSCOMPILING
+ AND NOT EXISTS "/etc/arch-release")
if (EXISTS "/etc/debian_version") # is this a debian system ?
if(CMAKE_LIBRARY_ARCHITECTURE)
if("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/?$")
@@ -273,14 +278,18 @@ _GNUInstallDirs_cache_path(CMAKE_INSTALL_DATAROOTDIR "share"
_GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}"
"Read-only architecture-independent data (DATAROOTDIR)")
-if(CMAKE_SYSTEM_NAME MATCHES "^(.*BSD|DragonFly)$")
+if(CMAKE_SYSTEM_NAME MATCHES "^(([^kF].*)?BSD|DragonFly)$")
_GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_INFODIR "info"
"Info documentation (info)")
- _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_MANDIR "man"
- "Man documentation (man)")
else()
_GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_INFODIR "${CMAKE_INSTALL_DATAROOTDIR}/info"
"Info documentation (DATAROOTDIR/info)")
+endif()
+
+if(CMAKE_SYSTEM_NAME MATCHES "^(([^k].*)?BSD|DragonFly)$")
+ _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_MANDIR "man"
+ "Man documentation (man)")
+else()
_GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man"
"Man documentation (DATAROOTDIR/man)")
endif()
@@ -371,3 +380,5 @@ foreach(dir
)
GNUInstallDirs_get_absolute_install_dir(CMAKE_INSTALL_FULL_${dir} CMAKE_INSTALL_${dir})
endforeach()
+
+cmake_policy(POP)
diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake
index 4573c2e77..e4481f66d 100644
--- a/Modules/GenerateExportHeader.cmake
+++ b/Modules/GenerateExportHeader.cmake
@@ -1,189 +1,192 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# GenerateExportHeader
-# --------------------
-#
-# Function for generation of export macros for libraries
-#
-# This module provides the function GENERATE_EXPORT_HEADER().
-#
-# The ``GENERATE_EXPORT_HEADER`` function can be used to generate a file
-# suitable for preprocessor inclusion which contains EXPORT macros to be
-# used in library classes::
-#
-# GENERATE_EXPORT_HEADER( LIBRARY_TARGET
-# [BASE_NAME <base_name>]
-# [EXPORT_MACRO_NAME <export_macro_name>]
-# [EXPORT_FILE_NAME <export_file_name>]
-# [DEPRECATED_MACRO_NAME <deprecated_macro_name>]
-# [NO_EXPORT_MACRO_NAME <no_export_macro_name>]
-# [STATIC_DEFINE <static_define>]
-# [NO_DEPRECATED_MACRO_NAME <no_deprecated_macro_name>]
-# [DEFINE_NO_DEPRECATED]
-# [PREFIX_NAME <prefix_name>]
-# [CUSTOM_CONTENT_FROM_VARIABLE <variable>]
-# )
-#
-#
-# The target properties :prop_tgt:`CXX_VISIBILITY_PRESET <<LANG>_VISIBILITY_PRESET>`
-# and :prop_tgt:`VISIBILITY_INLINES_HIDDEN` can be used to add the appropriate
-# compile flags for targets. See the documentation of those target properties,
-# and the convenience variables
-# :variable:`CMAKE_CXX_VISIBILITY_PRESET <CMAKE_<LANG>_VISIBILITY_PRESET>` and
-# :variable:`CMAKE_VISIBILITY_INLINES_HIDDEN`.
-#
-# By default ``GENERATE_EXPORT_HEADER()`` generates macro names in a file
-# name determined by the name of the library. This means that in the
-# simplest case, users of ``GenerateExportHeader`` will be equivalent to:
-#
-# .. code-block:: cmake
-#
-# set(CMAKE_CXX_VISIBILITY_PRESET hidden)
-# set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
-# add_library(somelib someclass.cpp)
-# generate_export_header(somelib)
-# install(TARGETS somelib DESTINATION ${LIBRARY_INSTALL_DIR})
-# install(FILES
-# someclass.h
-# ${PROJECT_BINARY_DIR}/somelib_export.h DESTINATION ${INCLUDE_INSTALL_DIR}
-# )
-#
-#
-# And in the ABI header files:
-#
-# .. code-block:: c++
-#
-# #include "somelib_export.h"
-# class SOMELIB_EXPORT SomeClass {
-# ...
-# };
-#
-#
-# The CMake fragment will generate a file in the
-# ``${CMAKE_CURRENT_BINARY_DIR}`` called ``somelib_export.h`` containing the
-# macros ``SOMELIB_EXPORT``, ``SOMELIB_NO_EXPORT``, ``SOMELIB_DEPRECATED``,
-# ``SOMELIB_DEPRECATED_EXPORT`` and ``SOMELIB_DEPRECATED_NO_EXPORT``.
-# They will be followed by content taken from the variable specified by
-# the ``CUSTOM_CONTENT_FROM_VARIABLE`` option, if any.
-# The resulting file should be installed with other headers in the library.
-#
-# The ``BASE_NAME`` argument can be used to override the file name and the
-# names used for the macros:
-#
-# .. code-block:: cmake
-#
-# add_library(somelib someclass.cpp)
-# generate_export_header(somelib
-# BASE_NAME other_name
-# )
-#
-#
-# Generates a file called ``other_name_export.h`` containing the macros
-# ``OTHER_NAME_EXPORT``, ``OTHER_NAME_NO_EXPORT`` and ``OTHER_NAME_DEPRECATED``
-# etc.
-#
-# The ``BASE_NAME`` may be overridden by specifying other options in the
-# function. For example:
-#
-# .. code-block:: cmake
-#
-# add_library(somelib someclass.cpp)
-# generate_export_header(somelib
-# EXPORT_MACRO_NAME OTHER_NAME_EXPORT
-# )
-#
-#
-# creates the macro ``OTHER_NAME_EXPORT`` instead of ``SOMELIB_EXPORT``, but
-# other macros and the generated file name is as default:
-#
-# .. code-block:: cmake
-#
-# add_library(somelib someclass.cpp)
-# generate_export_header(somelib
-# DEPRECATED_MACRO_NAME KDE_DEPRECATED
-# )
-#
-#
-# creates the macro ``KDE_DEPRECATED`` instead of ``SOMELIB_DEPRECATED``.
-#
-# If ``LIBRARY_TARGET`` is a static library, macros are defined without
-# values.
-#
-# If the same sources are used to create both a shared and a static
-# library, the uppercased symbol ``${BASE_NAME}_STATIC_DEFINE`` should be
-# used when building the static library:
-#
-# .. code-block:: cmake
-#
-# add_library(shared_variant SHARED ${lib_SRCS})
-# add_library(static_variant ${lib_SRCS})
-# generate_export_header(shared_variant BASE_NAME libshared_and_static)
-# set_target_properties(static_variant PROPERTIES
-# COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE)
-#
-# This will cause the export macros to expand to nothing when building
-# the static library.
-#
-# If ``DEFINE_NO_DEPRECATED`` is specified, then a macro
-# ``${BASE_NAME}_NO_DEPRECATED`` will be defined This macro can be used to
-# remove deprecated code from preprocessor output:
-#
-# .. code-block:: cmake
-#
-# option(EXCLUDE_DEPRECATED "Exclude deprecated parts of the library" FALSE)
-# if (EXCLUDE_DEPRECATED)
-# set(NO_BUILD_DEPRECATED DEFINE_NO_DEPRECATED)
-# endif()
-# generate_export_header(somelib ${NO_BUILD_DEPRECATED})
-#
-#
-# And then in somelib:
-#
-# .. code-block:: c++
-#
-# class SOMELIB_EXPORT SomeClass
-# {
-# public:
-# #ifndef SOMELIB_NO_DEPRECATED
-# SOMELIB_DEPRECATED void oldMethod();
-# #endif
-# };
-#
-# .. code-block:: c++
-#
-# #ifndef SOMELIB_NO_DEPRECATED
-# void SomeClass::oldMethod() { }
-# #endif
-#
-#
-# If ``PREFIX_NAME`` is specified, the argument will be used as a prefix to
-# all generated macros.
-#
-# For example:
-#
-# .. code-block:: cmake
-#
-# generate_export_header(somelib PREFIX_NAME VTK_)
-#
-# Generates the macros ``VTK_SOMELIB_EXPORT`` etc.
-#
-# ::
-#
-# ADD_COMPILER_EXPORT_FLAGS( [<output_variable>] )
-#
-# The ``ADD_COMPILER_EXPORT_FLAGS`` function adds ``-fvisibility=hidden`` to
-# :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` if supported, and is a no-op
-# on Windows which does not need extra compiler flags for exporting support.
-# You may optionally pass a single argument to ``ADD_COMPILER_EXPORT_FLAGS``
-# that will be populated with the ``CXX_FLAGS`` required to enable visibility
-# support for the compiler/architecture in use.
-#
-# This function is deprecated. Set the target properties
-# :prop_tgt:`CXX_VISIBILITY_PRESET <<LANG>_VISIBILITY_PRESET>` and
-# :prop_tgt:`VISIBILITY_INLINES_HIDDEN` instead.
+#[=======================================================================[.rst:
+GenerateExportHeader
+--------------------
+Function for generation of export macros for libraries
+
+This module provides the function ``GENERATE_EXPORT_HEADER()``.
+
+The ``GENERATE_EXPORT_HEADER`` function can be used to generate a file
+suitable for preprocessor inclusion which contains EXPORT macros to be
+used in library classes::
+
+ GENERATE_EXPORT_HEADER( LIBRARY_TARGET
+ [BASE_NAME <base_name>]
+ [EXPORT_MACRO_NAME <export_macro_name>]
+ [EXPORT_FILE_NAME <export_file_name>]
+ [DEPRECATED_MACRO_NAME <deprecated_macro_name>]
+ [NO_EXPORT_MACRO_NAME <no_export_macro_name>]
+ [INCLUDE_GUARD_NAME <include_guard_name>]
+ [STATIC_DEFINE <static_define>]
+ [NO_DEPRECATED_MACRO_NAME <no_deprecated_macro_name>]
+ [DEFINE_NO_DEPRECATED]
+ [PREFIX_NAME <prefix_name>]
+ [CUSTOM_CONTENT_FROM_VARIABLE <variable>]
+ )
+
+
+The target properties :prop_tgt:`CXX_VISIBILITY_PRESET <<LANG>_VISIBILITY_PRESET>`
+and :prop_tgt:`VISIBILITY_INLINES_HIDDEN` can be used to add the appropriate
+compile flags for targets. See the documentation of those target properties,
+and the convenience variables
+:variable:`CMAKE_CXX_VISIBILITY_PRESET <CMAKE_<LANG>_VISIBILITY_PRESET>` and
+:variable:`CMAKE_VISIBILITY_INLINES_HIDDEN`.
+
+By default ``GENERATE_EXPORT_HEADER()`` generates macro names in a file
+name determined by the name of the library. This means that in the
+simplest case, users of ``GenerateExportHeader`` will be equivalent to:
+
+.. code-block:: cmake
+
+ set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+ set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
+ add_library(somelib someclass.cpp)
+ generate_export_header(somelib)
+ install(TARGETS somelib DESTINATION ${LIBRARY_INSTALL_DIR})
+ install(FILES
+ someclass.h
+ ${PROJECT_BINARY_DIR}/somelib_export.h DESTINATION ${INCLUDE_INSTALL_DIR}
+ )
+
+
+And in the ABI header files:
+
+.. code-block:: c++
+
+ #include "somelib_export.h"
+ class SOMELIB_EXPORT SomeClass {
+ ...
+ };
+
+
+The CMake fragment will generate a file in the
+``${CMAKE_CURRENT_BINARY_DIR}`` called ``somelib_export.h`` containing the
+macros ``SOMELIB_EXPORT``, ``SOMELIB_NO_EXPORT``, ``SOMELIB_DEPRECATED``,
+``SOMELIB_DEPRECATED_EXPORT`` and ``SOMELIB_DEPRECATED_NO_EXPORT``.
+They will be followed by content taken from the variable specified by
+the ``CUSTOM_CONTENT_FROM_VARIABLE`` option, if any.
+The resulting file should be installed with other headers in the library.
+
+The ``BASE_NAME`` argument can be used to override the file name and the
+names used for the macros:
+
+.. code-block:: cmake
+
+ add_library(somelib someclass.cpp)
+ generate_export_header(somelib
+ BASE_NAME other_name
+ )
+
+
+Generates a file called ``other_name_export.h`` containing the macros
+``OTHER_NAME_EXPORT``, ``OTHER_NAME_NO_EXPORT`` and ``OTHER_NAME_DEPRECATED``
+etc.
+
+The ``BASE_NAME`` may be overridden by specifying other options in the
+function. For example:
+
+.. code-block:: cmake
+
+ add_library(somelib someclass.cpp)
+ generate_export_header(somelib
+ EXPORT_MACRO_NAME OTHER_NAME_EXPORT
+ )
+
+
+creates the macro ``OTHER_NAME_EXPORT`` instead of ``SOMELIB_EXPORT``, but
+other macros and the generated file name is as default:
+
+.. code-block:: cmake
+
+ add_library(somelib someclass.cpp)
+ generate_export_header(somelib
+ DEPRECATED_MACRO_NAME KDE_DEPRECATED
+ )
+
+
+creates the macro ``KDE_DEPRECATED`` instead of ``SOMELIB_DEPRECATED``.
+
+If ``LIBRARY_TARGET`` is a static library, macros are defined without
+values.
+
+If the same sources are used to create both a shared and a static
+library, the uppercased symbol ``${BASE_NAME}_STATIC_DEFINE`` should be
+used when building the static library:
+
+.. code-block:: cmake
+
+ add_library(shared_variant SHARED ${lib_SRCS})
+ add_library(static_variant ${lib_SRCS})
+ generate_export_header(shared_variant BASE_NAME libshared_and_static)
+ set_target_properties(static_variant PROPERTIES
+ COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE)
+
+This will cause the export macros to expand to nothing when building
+the static library.
+
+If ``DEFINE_NO_DEPRECATED`` is specified, then a macro
+``${BASE_NAME}_NO_DEPRECATED`` will be defined This macro can be used to
+remove deprecated code from preprocessor output:
+
+.. code-block:: cmake
+
+ option(EXCLUDE_DEPRECATED "Exclude deprecated parts of the library" FALSE)
+ if (EXCLUDE_DEPRECATED)
+ set(NO_BUILD_DEPRECATED DEFINE_NO_DEPRECATED)
+ endif()
+ generate_export_header(somelib ${NO_BUILD_DEPRECATED})
+
+
+And then in somelib:
+
+.. code-block:: c++
+
+ class SOMELIB_EXPORT SomeClass
+ {
+ public:
+ #ifndef SOMELIB_NO_DEPRECATED
+ SOMELIB_DEPRECATED void oldMethod();
+ #endif
+ };
+
+.. code-block:: c++
+
+ #ifndef SOMELIB_NO_DEPRECATED
+ void SomeClass::oldMethod() { }
+ #endif
+
+
+If ``PREFIX_NAME`` is specified, the argument will be used as a prefix to
+all generated macros.
+
+For example:
+
+.. code-block:: cmake
+
+ generate_export_header(somelib PREFIX_NAME VTK_)
+
+Generates the macros ``VTK_SOMELIB_EXPORT`` etc.
+
+::
+
+ ADD_COMPILER_EXPORT_FLAGS( [<output_variable>] )
+
+The ``ADD_COMPILER_EXPORT_FLAGS`` function adds ``-fvisibility=hidden`` to
+:variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>` if supported, and is a no-op
+on Windows which does not need extra compiler flags for exporting support.
+You may optionally pass a single argument to ``ADD_COMPILER_EXPORT_FLAGS``
+that will be populated with the ``CXX_FLAGS`` required to enable visibility
+support for the compiler/architecture in use.
+
+This function is deprecated. Set the target properties
+:prop_tgt:`CXX_VISIBILITY_PRESET <<LANG>_VISIBILITY_PRESET>` and
+:prop_tgt:`VISIBILITY_INLINES_HIDDEN` instead.
+#]=======================================================================]
+
+include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
# TODO: Install this macro separately?
@@ -193,6 +196,13 @@ macro(_check_cxx_compiler_attribute _ATTRIBUTE _RESULT)
)
endmacro()
+# TODO: Install this macro separately?
+macro(_check_c_compiler_attribute _ATTRIBUTE _RESULT)
+ check_c_source_compiles("${_ATTRIBUTE} int somefunc() { return 0; }
+ int main() { return somefunc();}" ${_RESULT}
+ )
+endmacro()
+
macro(_test_compiler_hidden_visibility)
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.2")
@@ -212,9 +222,15 @@ macro(_test_compiler_hidden_visibility)
AND NOT CMAKE_CXX_COMPILER_ID MATCHES XL
AND NOT CMAKE_CXX_COMPILER_ID MATCHES PGI
AND NOT CMAKE_CXX_COMPILER_ID MATCHES Watcom)
- check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY)
- check_cxx_compiler_flag(-fvisibility-inlines-hidden
- COMPILER_HAS_HIDDEN_INLINE_VISIBILITY)
+ if (CMAKE_CXX_COMPILER_LOADED)
+ check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY)
+ check_cxx_compiler_flag(-fvisibility-inlines-hidden
+ COMPILER_HAS_HIDDEN_INLINE_VISIBILITY)
+ else()
+ check_c_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY)
+ check_c_compiler_flag(-fvisibility-inlines-hidden
+ COMPILER_HAS_HIDDEN_INLINE_VISIBILITY)
+ endif()
endif()
endmacro()
@@ -231,14 +247,27 @@ macro(_test_compiler_has_deprecated)
set(COMPILER_HAS_DEPRECATED "" CACHE INTERNAL
"Compiler support for a deprecated attribute")
else()
- _check_cxx_compiler_attribute("__attribute__((__deprecated__))"
- COMPILER_HAS_DEPRECATED_ATTR)
- if(COMPILER_HAS_DEPRECATED_ATTR)
- set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED_ATTR}"
- CACHE INTERNAL "Compiler support for a deprecated attribute")
+ if (CMAKE_CXX_COMPILER_LOADED)
+ _check_cxx_compiler_attribute("__attribute__((__deprecated__))"
+ COMPILER_HAS_DEPRECATED_ATTR)
+ if(COMPILER_HAS_DEPRECATED_ATTR)
+ set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED_ATTR}"
+ CACHE INTERNAL "Compiler support for a deprecated attribute")
+ else()
+ _check_cxx_compiler_attribute("__declspec(deprecated)"
+ COMPILER_HAS_DEPRECATED)
+ endif()
else()
- _check_cxx_compiler_attribute("__declspec(deprecated)"
- COMPILER_HAS_DEPRECATED)
+ _check_c_compiler_attribute("__attribute__((__deprecated__))"
+ COMPILER_HAS_DEPRECATED_ATTR)
+ if(COMPILER_HAS_DEPRECATED_ATTR)
+ set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED_ATTR}"
+ CACHE INTERNAL "Compiler support for a deprecated attribute")
+ else()
+ _check_c_compiler_attribute("__declspec(deprecated)"
+ COMPILER_HAS_DEPRECATED)
+ endif()
+
endif()
endif()
endmacro()
@@ -277,7 +306,7 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY)
set(options DEFINE_NO_DEPRECATED)
set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME
DEPRECATED_MACRO_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE
- NO_DEPRECATED_MACRO_NAME CUSTOM_CONTENT_FROM_VARIABLE)
+ NO_DEPRECATED_MACRO_NAME CUSTOM_CONTENT_FROM_VARIABLE INCLUDE_GUARD_NAME)
set(multiValueArgs)
cmake_parse_arguments(_GEH "${options}" "${oneValueArgs}" "${multiValueArgs}"
@@ -341,7 +370,11 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY)
endif()
string(MAKE_C_IDENTIFIER ${NO_DEPRECATED_MACRO_NAME} NO_DEPRECATED_MACRO_NAME)
- set(INCLUDE_GUARD_NAME "${EXPORT_MACRO_NAME}_H")
+ if(_GEH_INCLUDE_GUARD_NAME)
+ set(INCLUDE_GUARD_NAME ${_GEH_INCLUDE_GUARD_NAME})
+ else()
+ set(INCLUDE_GUARD_NAME "${EXPORT_MACRO_NAME}_H")
+ endif()
get_target_property(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY} DEFINE_SYMBOL)
diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake
index 4e52cb300..57ae44675 100644
--- a/Modules/GetPrerequisites.cmake
+++ b/Modules/GetPrerequisites.cmake
@@ -1,181 +1,183 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# GetPrerequisites
-# ----------------
-#
-# Functions to analyze and list executable file prerequisites.
-#
-# This module provides functions to list the .dll, .dylib or .so files
-# that an executable or shared library file depends on. (Its
-# prerequisites.)
-#
-# It uses various tools to obtain the list of required shared library
-# files:
-#
-# ::
-#
-# dumpbin (Windows)
-# objdump (MinGW on Windows)
-# ldd (Linux/Unix)
-# otool (Mac OSX)
-#
-# The following functions are provided by this module:
-#
-# ::
-#
-# get_prerequisites
-# list_prerequisites
-# list_prerequisites_by_glob
-# gp_append_unique
-# is_file_executable
-# gp_item_default_embedded_path
-# (projects can override with gp_item_default_embedded_path_override)
-# gp_resolve_item
-# (projects can override with gp_resolve_item_override)
-# gp_resolved_file_type
-# (projects can override with gp_resolved_file_type_override)
-# gp_file_type
-#
-# Requires CMake 2.6 or greater because it uses function, break, return
-# and PARENT_SCOPE.
-#
-# ::
-#
-# GET_PREREQUISITES(<target> <prerequisites_var> <exclude_system> <recurse>
-# <exepath> <dirs> [<rpaths>])
-#
-# Get the list of shared library files required by <target>. The list
-# in the variable named <prerequisites_var> should be empty on first
-# entry to this function. On exit, <prerequisites_var> will contain the
-# list of required shared library files.
-#
-# <target> is the full path to an executable file. <prerequisites_var>
-# is the name of a CMake variable to contain the results.
-# <exclude_system> must be 0 or 1 indicating whether to include or
-# exclude "system" prerequisites. If <recurse> is set to 1 all
-# prerequisites will be found recursively, if set to 0 only direct
-# prerequisites are listed. <exepath> is the path to the top level
-# executable used for @executable_path replacment on the Mac. <dirs> is
-# a list of paths where libraries might be found: these paths are
-# searched first when a target without any path info is given. Then
-# standard system locations are also searched: PATH, Framework
-# locations, /usr/lib...
-#
-# ::
-#
-# LIST_PREREQUISITES(<target> [<recurse> [<exclude_system> [<verbose>]]])
-#
-# Print a message listing the prerequisites of <target>.
-#
-# <target> is the name of a shared library or executable target or the
-# full path to a shared library or executable file. If <recurse> is set
-# to 1 all prerequisites will be found recursively, if set to 0 only
-# direct prerequisites are listed. <exclude_system> must be 0 or 1
-# indicating whether to include or exclude "system" prerequisites. With
-# <verbose> set to 0 only the full path names of the prerequisites are
-# printed, set to 1 extra informatin will be displayed.
-#
-# ::
-#
-# LIST_PREREQUISITES_BY_GLOB(<glob_arg> <glob_exp>)
-#
-# Print the prerequisites of shared library and executable files
-# matching a globbing pattern. <glob_arg> is GLOB or GLOB_RECURSE and
-# <glob_exp> is a globbing expression used with "file(GLOB" or
-# "file(GLOB_RECURSE" to retrieve a list of matching files. If a
-# matching file is executable, its prerequisites are listed.
-#
-# Any additional (optional) arguments provided are passed along as the
-# optional arguments to the list_prerequisites calls.
-#
-# ::
-#
-# GP_APPEND_UNIQUE(<list_var> <value>)
-#
-# Append <value> to the list variable <list_var> only if the value is
-# not already in the list.
-#
-# ::
-#
-# IS_FILE_EXECUTABLE(<file> <result_var>)
-#
-# Return 1 in <result_var> if <file> is a binary executable, 0
-# otherwise.
-#
-# ::
-#
-# GP_ITEM_DEFAULT_EMBEDDED_PATH(<item> <default_embedded_path_var>)
-#
-# Return the path that others should refer to the item by when the item
-# is embedded inside a bundle.
-#
-# Override on a per-project basis by providing a project-specific
-# gp_item_default_embedded_path_override function.
-#
-# ::
-#
-# GP_RESOLVE_ITEM(<context> <item> <exepath> <dirs> <resolved_item_var>
-# [<rpaths>])
-#
-# Resolve an item into an existing full path file.
-#
-# Override on a per-project basis by providing a project-specific
-# gp_resolve_item_override function.
-#
-# ::
-#
-# GP_RESOLVED_FILE_TYPE(<original_file> <file> <exepath> <dirs> <type_var>
-# [<rpaths>])
-#
-# Return the type of <file> with respect to <original_file>. String
-# describing type of prerequisite is returned in variable named
-# <type_var>.
-#
-# Use <exepath> and <dirs> if necessary to resolve non-absolute <file>
-# values -- but only for non-embedded items.
-#
-# Possible types are:
-#
-# ::
-#
-# system
-# local
-# embedded
-# other
-#
-# Override on a per-project basis by providing a project-specific
-# gp_resolved_file_type_override function.
-#
-# ::
-#
-# GP_FILE_TYPE(<original_file> <file> <type_var>)
-#
-# Return the type of <file> with respect to <original_file>. String
-# describing type of prerequisite is returned in variable named
-# <type_var>.
-#
-# Possible types are:
-#
-# ::
-#
-# system
-# local
-# embedded
-# other
+#[=======================================================================[.rst:
+GetPrerequisites
+----------------
-function(gp_append_unique list_var value)
- set(contains 0)
+.. deprecated:: 3.16
- foreach(item ${${list_var}})
- if(item STREQUAL "${value}")
- set(contains 1)
- break()
- endif()
- endforeach()
+ Use :command:`file(GET_RUNTIME_DEPENDENCIES)` instead.
+
+Functions to analyze and list executable file prerequisites.
+
+This module provides functions to list the .dll, .dylib or .so files
+that an executable or shared library file depends on. (Its
+prerequisites.)
+
+It uses various tools to obtain the list of required shared library
+files:
+
+::
+
+ dumpbin (Windows)
+ objdump (MinGW on Windows)
+ ldd (Linux/Unix)
+ otool (Mac OSX)
+
+The following functions are provided by this module:
- if(NOT contains)
+::
+
+ get_prerequisites
+ list_prerequisites
+ list_prerequisites_by_glob
+ gp_append_unique
+ is_file_executable
+ gp_item_default_embedded_path
+ (projects can override with gp_item_default_embedded_path_override)
+ gp_resolve_item
+ (projects can override with gp_resolve_item_override)
+ gp_resolved_file_type
+ (projects can override with gp_resolved_file_type_override)
+ gp_file_type
+
+Requires CMake 2.6 or greater because it uses function, break, return
+and PARENT_SCOPE.
+
+::
+
+ GET_PREREQUISITES(<target> <prerequisites_var> <exclude_system> <recurse>
+ <exepath> <dirs> [<rpaths>])
+
+Get the list of shared library files required by <target>. The list
+in the variable named <prerequisites_var> should be empty on first
+entry to this function. On exit, <prerequisites_var> will contain the
+list of required shared library files.
+
+<target> is the full path to an executable file. <prerequisites_var>
+is the name of a CMake variable to contain the results.
+<exclude_system> must be 0 or 1 indicating whether to include or
+exclude "system" prerequisites. If <recurse> is set to 1 all
+prerequisites will be found recursively, if set to 0 only direct
+prerequisites are listed. <exepath> is the path to the top level
+executable used for @executable_path replacment on the Mac. <dirs> is
+a list of paths where libraries might be found: these paths are
+searched first when a target without any path info is given. Then
+standard system locations are also searched: PATH, Framework
+locations, /usr/lib...
+
+The variable GET_PREREQUISITES_VERBOSE can be set to true to enable verbose
+output.
+
+::
+
+ LIST_PREREQUISITES(<target> [<recurse> [<exclude_system> [<verbose>]]])
+
+Print a message listing the prerequisites of <target>.
+
+<target> is the name of a shared library or executable target or the
+full path to a shared library or executable file. If <recurse> is set
+to 1 all prerequisites will be found recursively, if set to 0 only
+direct prerequisites are listed. <exclude_system> must be 0 or 1
+indicating whether to include or exclude "system" prerequisites. With
+<verbose> set to 0 only the full path names of the prerequisites are
+printed, set to 1 extra informatin will be displayed.
+
+::
+
+ LIST_PREREQUISITES_BY_GLOB(<glob_arg> <glob_exp>)
+
+Print the prerequisites of shared library and executable files
+matching a globbing pattern. <glob_arg> is GLOB or GLOB_RECURSE and
+<glob_exp> is a globbing expression used with "file(GLOB" or
+"file(GLOB_RECURSE" to retrieve a list of matching files. If a
+matching file is executable, its prerequisites are listed.
+
+Any additional (optional) arguments provided are passed along as the
+optional arguments to the list_prerequisites calls.
+
+::
+
+ GP_APPEND_UNIQUE(<list_var> <value>)
+
+Append <value> to the list variable <list_var> only if the value is
+not already in the list.
+
+::
+
+ IS_FILE_EXECUTABLE(<file> <result_var>)
+
+Return 1 in <result_var> if <file> is a binary executable, 0
+otherwise.
+
+::
+
+ GP_ITEM_DEFAULT_EMBEDDED_PATH(<item> <default_embedded_path_var>)
+
+Return the path that others should refer to the item by when the item
+is embedded inside a bundle.
+
+Override on a per-project basis by providing a project-specific
+gp_item_default_embedded_path_override function.
+
+::
+
+ GP_RESOLVE_ITEM(<context> <item> <exepath> <dirs> <resolved_item_var>
+ [<rpaths>])
+
+Resolve an item into an existing full path file.
+
+Override on a per-project basis by providing a project-specific
+gp_resolve_item_override function.
+
+::
+
+ GP_RESOLVED_FILE_TYPE(<original_file> <file> <exepath> <dirs> <type_var>
+ [<rpaths>])
+
+Return the type of <file> with respect to <original_file>. String
+describing type of prerequisite is returned in variable named
+<type_var>.
+
+Use <exepath> and <dirs> if necessary to resolve non-absolute <file>
+values -- but only for non-embedded items.
+
+Possible types are:
+
+::
+
+ system
+ local
+ embedded
+ other
+
+Override on a per-project basis by providing a project-specific
+gp_resolved_file_type_override function.
+
+::
+
+ GP_FILE_TYPE(<original_file> <file> <type_var>)
+
+Return the type of <file> with respect to <original_file>. String
+describing type of prerequisite is returned in variable named
+<type_var>.
+
+Possible types are:
+
+::
+
+ system
+ local
+ embedded
+ other
+#]=======================================================================]
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
+function(gp_append_unique list_var value)
+ if(NOT value IN_LIST ${list_var})
set(${list_var} ${${list_var}} "${value}" PARENT_SCOPE)
endif()
endfunction()
@@ -275,7 +277,6 @@ function(gp_item_default_embedded_path item default_embedded_path_var)
# as the executable by default:
#
set(path "@executable_path")
- set(overridden 0)
# On the Mac, relative to the executable depending on the type
# of the thing we are embedding:
@@ -294,20 +295,11 @@ function(gp_item_default_embedded_path item default_embedded_path_var)
#
set(path "@executable_path/../../Contents/MacOS")
- # Embed .dylibs right next to the main bundle executable:
+ # Embed frameworks and .dylibs in the embedded "Frameworks" directory
+ # (sibling of MacOS):
#
- if(item MATCHES "\\.dylib$")
- set(path "@executable_path/../MacOS")
- set(overridden 1)
- endif()
-
- # Embed frameworks in the embedded "Frameworks" directory (sibling of MacOS):
- #
- if(NOT overridden)
- if(item MATCHES "[^/]+\\.framework/")
- set(path "@executable_path/../Frameworks")
- set(overridden 1)
- endif()
+ if(item MATCHES "[^/]+\\.framework/" OR item MATCHES "\\.dylib$")
+ set(path "@executable_path/../Frameworks")
endif()
endif()
@@ -653,12 +645,24 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
set(rpaths "")
endif()
+ if(GET_PREREQUISITES_VERBOSE)
+ set(verbose 1)
+ endif()
+
if(NOT IS_ABSOLUTE "${target}")
message("warning: target '${target}' is not absolute...")
endif()
if(NOT EXISTS "${target}")
message("warning: target '${target}' does not exist...")
+ return()
+ endif()
+
+ # Check for a script by extension (.bat,.sh,...) or if the file starts with "#!" (shebang)
+ file(READ ${target} file_contents LIMIT 5)
+ if(target MATCHES "\\.(bat|c?sh|bash|ksh|cmd)$" OR file_contents MATCHES "^#!")
+ message(STATUS "GetPrequisites(${target}) : ignoring script file")
+ # Clear var
set(${prerequisites_var} "" PARENT_SCOPE)
return()
endif()
@@ -688,8 +692,6 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
"$ENV{VS71COMNTOOLS}/../../VC7/bin"
"C:/Program Files/Microsoft Visual Studio .NET 2003/VC7/BIN"
"C:/Program Files (x86)/Microsoft Visual Studio .NET 2003/VC7/BIN"
- "/usr/local/bin"
- "/usr/bin"
)
# <setup-gp_tool-vars>
@@ -708,7 +710,9 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
find_program(gp_dumpbin "dumpbin" PATHS ${gp_cmd_paths})
if(gp_dumpbin)
set(gp_tool "dumpbin")
- else() # Try harder. Maybe we're on MinGW
+ elseif(CMAKE_OBJDUMP) # Try harder. Maybe we're on MinGW
+ set(gp_tool "${CMAKE_OBJDUMP}")
+ else()
set(gp_tool "objdump")
endif()
endif()
@@ -723,25 +727,25 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
set(gp_cmd_maybe_filter) # optional command to pre-filter gp_tool results
- if(gp_tool STREQUAL "ldd")
+ if(gp_tool MATCHES "ldd$")
set(gp_cmd_args "")
- set(gp_regex "^[\t ]*[^\t ]+ => ([^\t\(]+) .*${eol_char}$")
+ set(gp_regex "^[\t ]*[^\t ]+ =>[\t ]+([^\t\(]+)( \(.+\))?${eol_char}$")
set(gp_regex_error "not found${eol_char}$")
set(gp_regex_fallback "^[\t ]*([^\t ]+) => ([^\t ]+).*${eol_char}$")
set(gp_regex_cmp_count 1)
- elseif(gp_tool STREQUAL "otool")
+ elseif(gp_tool MATCHES "otool$")
set(gp_cmd_args "-L")
set(gp_regex "^\t([^\t]+) \\(compatibility version ([0-9]+.[0-9]+.[0-9]+), current version ([0-9]+.[0-9]+.[0-9]+)\\)${eol_char}$")
set(gp_regex_error "")
set(gp_regex_fallback "")
set(gp_regex_cmp_count 3)
- elseif(gp_tool STREQUAL "dumpbin")
+ elseif(gp_tool MATCHES "dumpbin$")
set(gp_cmd_args "/dependents")
set(gp_regex "^ ([^ ].*[Dd][Ll][Ll])${eol_char}$")
set(gp_regex_error "")
set(gp_regex_fallback "")
set(gp_regex_cmp_count 1)
- elseif(gp_tool STREQUAL "objdump")
+ elseif(gp_tool MATCHES "objdump$")
set(gp_cmd_args "-p")
set(gp_regex "^\t*DLL Name: (.*\\.[Dd][Ll][Ll])${eol_char}$")
set(gp_regex_error "")
@@ -764,7 +768,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
endif()
- if(gp_tool STREQUAL "dumpbin")
+ if(gp_tool MATCHES "dumpbin$")
# When running dumpbin, it also needs the "Common7/IDE" directory in the
# PATH. It will already be in the PATH if being run from a Visual Studio
# command prompt. Add it to the PATH here in case we are running from a
@@ -793,7 +797,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
#
# </setup-gp_tool-vars>
- if(gp_tool STREQUAL "ldd")
+ if(gp_tool MATCHES "ldd$")
set(old_ld_env "$ENV{LD_LIBRARY_PATH}")
set(new_ld_env "${exepath}")
foreach(dir ${dirs})
@@ -818,7 +822,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
ERROR_VARIABLE gp_ev
)
- if(gp_tool STREQUAL "dumpbin")
+ if(gp_tool MATCHES "dumpbin$")
# Exclude delay load dependencies under windows (they are listed in dumpbin output after the message below)
string(FIND "${gp_cmd_ov}" "Image has the following delay load dependencies" gp_delayload_pos)
if (${gp_delayload_pos} GREATER -1)
@@ -832,7 +836,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
endif()
if(NOT gp_rv STREQUAL "0")
- if(gp_tool STREQUAL "dumpbin")
+ if(gp_tool MATCHES "dumpbin$")
# dumpbin error messages seem to go to stdout
message(FATAL_ERROR "${gp_cmd} failed: ${gp_rv}\n${gp_ev}\n${gp_cmd_ov}")
else()
@@ -840,7 +844,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
endif()
endif()
- if(gp_tool STREQUAL "ldd")
+ if(gp_tool MATCHES "ldd$")
set(ENV{LD_LIBRARY_PATH} "${old_ld_env}")
endif()
@@ -860,9 +864,9 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
# check for install id and remove it from list, since otool -L can include a
# reference to itself
set(gp_install_id)
- if(gp_tool STREQUAL "otool")
+ if(gp_tool MATCHES "otool$")
execute_process(
- COMMAND otool -D ${target}
+ COMMAND ${gp_cmd} -D ${target}
RESULT_VARIABLE otool_rv
OUTPUT_VARIABLE gp_install_id_ov
ERROR_VARIABLE otool_ev
@@ -1039,3 +1043,5 @@ function(list_prerequisites_by_glob glob_arg glob_exp)
endif()
endforeach()
endfunction()
+
+cmake_policy(POP)
diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake
index 7415e0681..a5bb86360 100644
--- a/Modules/GoogleTest.cmake
+++ b/Modules/GoogleTest.cmake
@@ -5,7 +5,33 @@
GoogleTest
----------
-This module defines functions to help use the Google Test infrastructure.
+This module defines functions to help use the Google Test infrastructure. Two
+mechanisms for adding tests are provided. :command:`gtest_add_tests` has been
+around for some time, originally via ``find_package(GTest)``.
+:command:`gtest_discover_tests` was introduced in CMake 3.10.
+
+The (older) :command:`gtest_add_tests` scans source files to identify tests.
+This is usually effective, with some caveats, including in cross-compiling
+environments, and makes setting additional properties on tests more convenient.
+However, its handling of parameterized tests is less comprehensive, and it
+requires re-running CMake to detect changes to the list of tests.
+
+The (newer) :command:`gtest_discover_tests` discovers tests by asking the
+compiled test executable to enumerate its tests. This is more robust and
+provides better handling of parameterized tests, and does not require CMake
+to be re-run when tests change. However, it may not work in a cross-compiling
+environment, and setting test properties is less convenient.
+
+More details can be found in the documentation of the respective functions.
+
+Both commands are intended to replace use of :command:`add_test` to register
+tests, and will create a separate CTest test for each Google Test test case.
+Note that this is in some cases less efficient, as common set-up and tear-down
+logic cannot be shared by multiple test cases executing in the same instance.
+However, it provides more fine-grained pass/fail information to CTest, which is
+usually considered as more beneficial. By default, the CTest test name is the
+same as the Google Test name (i.e. ``suite.testcase``); see also
+``TEST_PREFIX`` and ``TEST_SUFFIX``.
.. command:: gtest_add_tests
@@ -22,12 +48,25 @@ This module defines functions to help use the Google Test infrastructure.
[TEST_LIST outVar]
)
+ ``gtest_add_tests`` attempts to identify tests by scanning source files.
+ Although this is generally effective, it uses only a basic regular expression
+ match, which can be defeated by atypical test declarations, and is unable to
+ fully "split" parameterized tests. Additionally, it requires that CMake be
+ re-run to discover any newly added, removed or renamed tests (by default,
+ this means that CMake is re-run when any test source file is changed, but see
+ ``SKIP_DEPENDENCY``). However, it has the advantage of declaring tests at
+ CMake time, which somewhat simplifies setting additional properties on tests,
+ and always works in a cross-compiling environment.
+
+ The options are:
+
``TARGET target``
- This must be a known CMake target. CMake will substitute the location of
- the built executable when running the test.
+ Specifies the Google Test executable, which must be a known CMake
+ executable target. CMake will substitute the location of the built
+ executable when running the test.
``SOURCES src1...``
- When provided, only the listed files will be scanned for test cases. If
+ When provided, only the listed files will be scanned for test cases. If
this option is not given, the :prop_tgt:`SOURCES` property of the
specified ``target`` will be used to obtain the list of sources.
@@ -35,31 +74,30 @@ This module defines functions to help use the Google Test infrastructure.
Any extra arguments to pass on the command line to each test case.
``WORKING_DIRECTORY dir``
- Specifies the directory in which to run the discovered test cases. If this
+ Specifies the directory in which to run the discovered test cases. If this
option is not provided, the current binary directory is used.
``TEST_PREFIX prefix``
- Allows the specified ``prefix`` to be prepended to the name of each
- discovered test case. This can be useful when the same source files are
- being used in multiple calls to ``gtest_add_test()`` but with different
- ``EXTRA_ARGS``.
+ Specifies a ``prefix`` to be prepended to the name of each discovered test
+ case. This can be useful when the same source files are being used in
+ multiple calls to ``gtest_add_test()`` but with different ``EXTRA_ARGS``.
``TEST_SUFFIX suffix``
Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of
- every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` can be
- specified.
+ every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may
+ be specified.
``SKIP_DEPENDENCY``
Normally, the function creates a dependency which will cause CMake to be
- re-run if any of the sources being scanned are changed. This is to ensure
- that the list of discovered tests is updated. If this behavior is not
+ re-run if any of the sources being scanned are changed. This is to ensure
+ that the list of discovered tests is updated. If this behavior is not
desired (as may be the case while actually writing the test cases), this
option can be used to prevent the dependency from being added.
``TEST_LIST outVar``
The variable named by ``outVar`` will be populated in the calling scope
- with the list of discovered test cases. This allows the caller to do things
- like manipulate test properties of the discovered tests.
+ with the list of discovered test cases. This allows the caller to do
+ things like manipulate test properties of the discovered tests.
.. code-block:: cmake
@@ -77,7 +115,7 @@ This module defines functions to help use the Google Test infrastructure.
set_tests_properties(${noArgsTests} PROPERTIES TIMEOUT 10)
set_tests_properties(${withArgsTests} PROPERTIES TIMEOUT 20)
- For backward compatibility reasons, the following form is also supported::
+ For backward compatibility, the following form is also supported::
gtest_add_tests(exe args files...)
@@ -99,8 +137,112 @@ This module defines functions to help use the Google Test infrastructure.
add_executable(FooTest FooUnitTest.cxx)
gtest_add_tests(FooTest "${FooTestArgs}" AUTO)
+.. command:: gtest_discover_tests
+
+ Automatically add tests with CTest by querying the compiled test executable
+ for available tests::
+
+ gtest_discover_tests(target
+ [EXTRA_ARGS arg1...]
+ [WORKING_DIRECTORY dir]
+ [TEST_PREFIX prefix]
+ [TEST_SUFFIX suffix]
+ [NO_PRETTY_TYPES] [NO_PRETTY_VALUES]
+ [PROPERTIES name1 value1...]
+ [TEST_LIST var]
+ [DISCOVERY_TIMEOUT seconds]
+ )
+
+ ``gtest_discover_tests`` sets up a post-build command on the test executable
+ that generates the list of tests by parsing the output from running the test
+ with the ``--gtest_list_tests`` argument. Compared to the source parsing
+ approach of :command:`gtest_add_tests`, this ensures that the full list of
+ tests, including instantiations of parameterized tests, is obtained. Since
+ test discovery occurs at build time, it is not necessary to re-run CMake when
+ the list of tests changes.
+ However, it requires that :prop_tgt:`CROSSCOMPILING_EMULATOR` is properly set
+ in order to function in a cross-compiling environment.
+
+ Additionally, setting properties on tests is somewhat less convenient, since
+ the tests are not available at CMake time. Additional test properties may be
+ assigned to the set of tests as a whole using the ``PROPERTIES`` option. If
+ more fine-grained test control is needed, custom content may be provided
+ through an external CTest script using the :prop_dir:`TEST_INCLUDE_FILES`
+ directory property. The set of discovered tests is made accessible to such a
+ script via the ``<target>_TESTS`` variable.
+
+ The options are:
+
+ ``target``
+ Specifies the Google Test executable, which must be a known CMake
+ executable target. CMake will substitute the location of the built
+ executable when running the test.
+
+ ``EXTRA_ARGS arg1...``
+ Any extra arguments to pass on the command line to each test case.
+
+ ``WORKING_DIRECTORY dir``
+ Specifies the directory in which to run the discovered test cases. If this
+ option is not provided, the current binary directory is used.
+
+ ``TEST_PREFIX prefix``
+ Specifies a ``prefix`` to be prepended to the name of each discovered test
+ case. This can be useful when the same test executable is being used in
+ multiple calls to ``gtest_discover_tests()`` but with different
+ ``EXTRA_ARGS``.
+
+ ``TEST_SUFFIX suffix``
+ Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of
+ every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may
+ be specified.
+
+ ``NO_PRETTY_TYPES``
+ By default, the type index of type-parameterized tests is replaced by the
+ actual type name in the CTest test name. If this behavior is undesirable
+ (e.g. because the type names are unwieldy), this option will suppress this
+ behavior.
+
+ ``NO_PRETTY_VALUES``
+ By default, the value index of value-parameterized tests is replaced by the
+ actual value in the CTest test name. If this behavior is undesirable
+ (e.g. because the value strings are unwieldy), this option will suppress
+ this behavior.
+
+ ``PROPERTIES name1 value1...``
+ Specifies additional properties to be set on all tests discovered by this
+ invocation of ``gtest_discover_tests``.
+
+ ``TEST_LIST var``
+ Make the list of tests available in the variable ``var``, rather than the
+ default ``<target>_TESTS``. This can be useful when the same test
+ executable is being used in multiple calls to ``gtest_discover_tests()``.
+ Note that this variable is only available in CTest.
+
+ ``DISCOVERY_TIMEOUT num``
+ Specifies how long (in seconds) CMake will wait for the test to enumerate
+ available tests. If the test takes longer than this, discovery (and your
+ build) will fail. Most test executables will enumerate their tests very
+ quickly, but under some exceptional circumstances, a test may require a
+ longer timeout. The default is 5. See also the ``TIMEOUT`` option of
+ :command:`execute_process`.
+
+ .. note::
+
+ In CMake versions 3.10.1 and 3.10.2, this option was called ``TIMEOUT``.
+ This clashed with the ``TIMEOUT`` test property, which is one of the
+ common properties that would be set with the ``PROPERTIES`` keyword,
+ usually leading to legal but unintended behavior. The keyword was
+ changed to ``DISCOVERY_TIMEOUT`` in CMake 3.10.3 to address this
+ problem. The ambiguous behavior of the ``TIMEOUT`` keyword in 3.10.1
+ and 3.10.2 has not been preserved.
+
#]=======================================================================]
+# Save project's policies
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
+#------------------------------------------------------------------------------
function(gtest_add_tests)
if (ARGC LESS 1)
@@ -166,7 +308,7 @@ function(gtest_add_tests)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${source})
endif()
file(READ "${source}" contents)
- string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
+ string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests "${contents}")
foreach(hit ${found_tests})
string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit})
@@ -224,3 +366,98 @@ function(gtest_add_tests)
endif()
endfunction()
+
+#------------------------------------------------------------------------------
+function(gtest_discover_tests TARGET)
+ cmake_parse_arguments(
+ ""
+ "NO_PRETTY_TYPES;NO_PRETTY_VALUES"
+ "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;DISCOVERY_TIMEOUT"
+ "EXTRA_ARGS;PROPERTIES"
+ ${ARGN}
+ )
+
+ if(NOT _WORKING_DIRECTORY)
+ set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
+ endif()
+ if(NOT _TEST_LIST)
+ set(_TEST_LIST ${TARGET}_TESTS)
+ endif()
+ if(NOT _DISCOVERY_TIMEOUT)
+ set(_DISCOVERY_TIMEOUT 5)
+ endif()
+
+ get_property(
+ has_counter
+ TARGET ${TARGET}
+ PROPERTY CTEST_DISCOVERED_TEST_COUNTER
+ SET
+ )
+ if(has_counter)
+ get_property(
+ counter
+ TARGET ${TARGET}
+ PROPERTY CTEST_DISCOVERED_TEST_COUNTER
+ )
+ math(EXPR counter "${counter} + 1")
+ else()
+ set(counter 1)
+ endif()
+ set_property(
+ TARGET ${TARGET}
+ PROPERTY CTEST_DISCOVERED_TEST_COUNTER
+ ${counter}
+ )
+
+ # Define rule to generate test list for aforementioned test executable
+ set(ctest_file_base "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}[${counter}]")
+ set(ctest_include_file "${ctest_file_base}_include.cmake")
+ set(ctest_tests_file "${ctest_file_base}_tests.cmake")
+ get_property(crosscompiling_emulator
+ TARGET ${TARGET}
+ PROPERTY CROSSCOMPILING_EMULATOR
+ )
+ add_custom_command(
+ TARGET ${TARGET} POST_BUILD
+ BYPRODUCTS "${ctest_tests_file}"
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_TARGET=${TARGET}"
+ -D "TEST_EXECUTABLE=$<TARGET_FILE:${TARGET}>"
+ -D "TEST_EXECUTOR=${crosscompiling_emulator}"
+ -D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}"
+ -D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}"
+ -D "TEST_PROPERTIES=${_PROPERTIES}"
+ -D "TEST_PREFIX=${_TEST_PREFIX}"
+ -D "TEST_SUFFIX=${_TEST_SUFFIX}"
+ -D "NO_PRETTY_TYPES=${_NO_PRETTY_TYPES}"
+ -D "NO_PRETTY_VALUES=${_NO_PRETTY_VALUES}"
+ -D "TEST_LIST=${_TEST_LIST}"
+ -D "CTEST_FILE=${ctest_tests_file}"
+ -D "TEST_DISCOVERY_TIMEOUT=${_DISCOVERY_TIMEOUT}"
+ -P "${_GOOGLETEST_DISCOVER_TESTS_SCRIPT}"
+ VERBATIM
+ )
+
+ file(WRITE "${ctest_include_file}"
+ "if(EXISTS \"${ctest_tests_file}\")\n"
+ " include(\"${ctest_tests_file}\")\n"
+ "else()\n"
+ " add_test(${TARGET}_NOT_BUILT ${TARGET}_NOT_BUILT)\n"
+ "endif()\n"
+ )
+
+ # Add discovered tests to directory TEST_INCLUDE_FILES
+ set_property(DIRECTORY
+ APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}"
+ )
+
+endfunction()
+
+###############################################################################
+
+set(_GOOGLETEST_DISCOVER_TESTS_SCRIPT
+ ${CMAKE_CURRENT_LIST_DIR}/GoogleTestAddTests.cmake
+)
+
+# Restore project's policies
+cmake_policy(POP)
diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake
new file mode 100644
index 000000000..4abbbecf7
--- /dev/null
+++ b/Modules/GoogleTestAddTests.cmake
@@ -0,0 +1,106 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+set(prefix "${TEST_PREFIX}")
+set(suffix "${TEST_SUFFIX}")
+set(extra_args ${TEST_EXTRA_ARGS})
+set(properties ${TEST_PROPERTIES})
+set(script)
+set(suite)
+set(tests)
+
+function(add_command NAME)
+ set(_args "")
+ foreach(_arg ${ARGN})
+ if(_arg MATCHES "[^-./:a-zA-Z0-9_]")
+ set(_args "${_args} [==[${_arg}]==]")
+ else()
+ set(_args "${_args} ${_arg}")
+ endif()
+ endforeach()
+ set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE)
+endfunction()
+
+# Run test executable to get list of available tests
+if(NOT EXISTS "${TEST_EXECUTABLE}")
+ message(FATAL_ERROR
+ "Specified test executable does not exist.\n"
+ " Path: '${TEST_EXECUTABLE}'"
+ )
+endif()
+execute_process(
+ COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" --gtest_list_tests
+ WORKING_DIRECTORY "${TEST_WORKING_DIR}"
+ TIMEOUT ${TEST_DISCOVERY_TIMEOUT}
+ OUTPUT_VARIABLE output
+ RESULT_VARIABLE result
+)
+if(NOT ${result} EQUAL 0)
+ string(REPLACE "\n" "\n " output "${output}")
+ message(FATAL_ERROR
+ "Error running test executable.\n"
+ " Path: '${TEST_EXECUTABLE}'\n"
+ " Result: ${result}\n"
+ " Output:\n"
+ " ${output}\n"
+ )
+endif()
+
+string(REPLACE "\n" ";" output "${output}")
+
+# Parse output
+foreach(line ${output})
+ # Skip header
+ if(NOT line MATCHES "gtest_main\\.cc")
+ # Do we have a module name or a test name?
+ if(NOT line MATCHES "^ ")
+ # Module; remove trailing '.' to get just the name...
+ string(REGEX REPLACE "\\.( *#.*)?" "" suite "${line}")
+ if(line MATCHES "#" AND NOT NO_PRETTY_TYPES)
+ string(REGEX REPLACE "/[0-9]\\.+ +#.*= +" "/" pretty_suite "${line}")
+ else()
+ set(pretty_suite "${suite}")
+ endif()
+ string(REGEX REPLACE "^DISABLED_" "" pretty_suite "${pretty_suite}")
+ else()
+ # Test name; strip spaces and comments to get just the name...
+ string(REGEX REPLACE " +" "" test "${line}")
+ if(test MATCHES "#" AND NOT NO_PRETTY_VALUES)
+ string(REGEX REPLACE "/[0-9]+#GetParam..=" "/" pretty_test "${test}")
+ else()
+ string(REGEX REPLACE "#.*" "" pretty_test "${test}")
+ endif()
+ string(REGEX REPLACE "^DISABLED_" "" pretty_test "${pretty_test}")
+ string(REGEX REPLACE "#.*" "" test "${test}")
+ # ...and add to script
+ add_command(add_test
+ "${prefix}${pretty_suite}.${pretty_test}${suffix}"
+ ${TEST_EXECUTOR}
+ "${TEST_EXECUTABLE}"
+ "--gtest_filter=${suite}.${test}"
+ "--gtest_also_run_disabled_tests"
+ ${extra_args}
+ )
+ if(suite MATCHES "^DISABLED" OR test MATCHES "^DISABLED")
+ add_command(set_tests_properties
+ "${prefix}${pretty_suite}.${pretty_test}${suffix}"
+ PROPERTIES DISABLED TRUE
+ )
+ endif()
+ add_command(set_tests_properties
+ "${prefix}${pretty_suite}.${pretty_test}${suffix}"
+ PROPERTIES
+ WORKING_DIRECTORY "${TEST_WORKING_DIR}"
+ ${properties}
+ )
+ list(APPEND tests "${prefix}${pretty_suite}.${pretty_test}${suffix}")
+ endif()
+ endif()
+endforeach()
+
+# Create a list of all discovered tests, which users may use to e.g. set
+# properties on the tests
+add_command(set ${TEST_LIST} ${tests})
+
+# Write CTest script
+file(WRITE "${CTEST_FILE}" "${script}")
diff --git a/Modules/ITKCompatibility.cmake b/Modules/ITKCompatibility.cmake
index fef065381..7d211b61e 100644
--- a/Modules/ITKCompatibility.cmake
+++ b/Modules/ITKCompatibility.cmake
@@ -2,6 +2,6 @@
# file Copyright.txt or https://cmake.org/licensing for details.
-# work around an old bug in ITK prior to verison 3.0
+# work around an old bug in ITK prior to version 3.0
set(TIFF_RIGHT_VERSION 1)
diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake
index 4e8713a08..04687b9ea 100644
--- a/Modules/InstallRequiredSystemLibraries.cmake
+++ b/Modules/InstallRequiredSystemLibraries.cmake
@@ -1,60 +1,94 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# InstallRequiredSystemLibraries
-# ------------------------------
-#
-# Include this module to search for compiler-provided system runtime
-# libraries and add install rules for them. Some optional variables
-# may be set prior to including the module to adjust behavior:
-#
-# ``CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS``
-# Specify additional runtime libraries that may not be detected.
-# After inclusion any detected libraries will be appended to this.
-#
-# ``CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP``
-# Set to TRUE to skip calling the :command:`install(PROGRAMS)` command to
-# allow the includer to specify its own install rule, using the value of
-# ``CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS`` to get the list of libraries.
-#
-# ``CMAKE_INSTALL_DEBUG_LIBRARIES``
-# Set to TRUE to install the debug runtime libraries when available
-# with MSVC tools.
-#
-# ``CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY``
-# Set to TRUE to install only the debug runtime libraries with MSVC
-# tools even if the release runtime libraries are also available.
-#
-# ``CMAKE_INSTALL_UCRT_LIBRARIES``
-# Set to TRUE to install the Windows Universal CRT libraries for
-# app-local deployment (e.g. to Windows XP). This is meaningful
-# only with MSVC from Visual Studio 2015 or higher.
-#
-# One may set a ``CMAKE_WINDOWS_KITS_10_DIR`` *environment variable*
-# to an absolute path to tell CMake to look for Windows 10 SDKs in
-# a custom location. The specified directory is expected to contain
-# ``Redist/ucrt/DLLs/*`` directories.
-#
-# ``CMAKE_INSTALL_MFC_LIBRARIES``
-# Set to TRUE to install the MSVC MFC runtime libraries.
-#
-# ``CMAKE_INSTALL_OPENMP_LIBRARIES``
-# Set to TRUE to install the MSVC OpenMP runtime libraries
-#
-# ``CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION``
-# Specify the :command:`install(PROGRAMS)` command ``DESTINATION``
-# option. If not specified, the default is ``bin`` on Windows
-# and ``lib`` elsewhere.
-#
-# ``CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS``
-# Set to TRUE to disable warnings about required library files that
-# do not exist. (For example, Visual Studio Express editions may
-# not provide the redistributable files.)
-#
-# ``CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT``
-# Specify the :command:`install(PROGRAMS)` command ``COMPONENT``
-# option. If not specified, no such option will be used.
+#[=======================================================================[.rst:
+InstallRequiredSystemLibraries
+------------------------------
+
+Include this module to search for compiler-provided system runtime
+libraries and add install rules for them. Some optional variables
+may be set prior to including the module to adjust behavior:
+
+``CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS``
+ Specify additional runtime libraries that may not be detected.
+ After inclusion any detected libraries will be appended to this.
+
+``CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP``
+ Set to TRUE to skip calling the :command:`install(PROGRAMS)` command to
+ allow the includer to specify its own install rule, using the value of
+ ``CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS`` to get the list of libraries.
+
+``CMAKE_INSTALL_DEBUG_LIBRARIES``
+ Set to TRUE to install the debug runtime libraries when available
+ with MSVC tools.
+
+``CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY``
+ Set to TRUE to install only the debug runtime libraries with MSVC
+ tools even if the release runtime libraries are also available.
+
+``CMAKE_INSTALL_UCRT_LIBRARIES``
+ Set to TRUE to install the Windows Universal CRT libraries for
+ app-local deployment (e.g. to Windows XP). This is meaningful
+ only with MSVC from Visual Studio 2015 or higher.
+
+ One may set a ``CMAKE_WINDOWS_KITS_10_DIR`` *environment variable*
+ to an absolute path to tell CMake to look for Windows 10 SDKs in
+ a custom location. The specified directory is expected to contain
+ ``Redist/ucrt/DLLs/*`` directories.
+
+``CMAKE_INSTALL_MFC_LIBRARIES``
+ Set to TRUE to install the MSVC MFC runtime libraries.
+
+``CMAKE_INSTALL_OPENMP_LIBRARIES``
+ Set to TRUE to install the MSVC OpenMP runtime libraries
+
+``CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION``
+ Specify the :command:`install(PROGRAMS)` command ``DESTINATION``
+ option. If not specified, the default is ``bin`` on Windows
+ and ``lib`` elsewhere.
+
+``CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS``
+ Set to TRUE to disable warnings about required library files that
+ do not exist. (For example, Visual Studio Express editions may
+ not provide the redistributable files.)
+
+``CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT``
+ Specify the :command:`install(PROGRAMS)` command ``COMPONENT``
+ option. If not specified, no such option will be used.
+#]=======================================================================]
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced
+
+set(_IRSL_HAVE_Intel FALSE)
+set(_IRSL_HAVE_MSVC FALSE)
+foreach(LANG IN ITEMS C CXX Fortran)
+ if("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "Intel")
+ if(NOT _IRSL_HAVE_Intel)
+ get_filename_component(_Intel_basedir "${CMAKE_${LANG}_COMPILER}" PATH)
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(_Intel_archdir intel64)
+ else()
+ set(_Intel_archdir x86)
+ endif()
+ set(_Intel_compiler_ver ${CMAKE_${LANG}_COMPILER_VERSION})
+ if(WIN32)
+ get_filename_component(_Intel_redistdir "${_Intel_basedir}/../../redist/${_Intel_archdir}/compiler" ABSOLUTE)
+ elseif(APPLE)
+ get_filename_component(_Intel_redistdir "${_Intel_basedir}/../../compiler/lib" ABSOLUTE)
+ else()
+ if(EXISTS "${_Intel_basedir}/../lib/${_Intel_archdir}_lin")
+ get_filename_component(_Intel_redistdir "${_Intel_basedir}/../lib/${_Intel_archdir}" ABSOLUTE)
+ else()
+ get_filename_component(_Intel_redistdir "${_Intel_basedir}/../../compiler/lib/${_Intel_archdir}_lin" ABSOLUTE)
+ endif()
+ endif()
+ set(_IRSL_HAVE_Intel TRUE)
+ endif()
+ elseif("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "MSVC")
+ set(_IRSL_HAVE_MSVC TRUE)
+ endif()
+endforeach()
if(MSVC)
file(TO_CMAKE_PATH "$ENV{SYSTEMROOT}" SYSTEMROOT)
@@ -88,9 +122,7 @@ if(MSVC)
)
endif()
- if(MSVC_VERSION EQUAL 1400)
- set(MSVC_REDIST_NAME VC80)
-
+ if(MSVC_TOOLSET_VERSION EQUAL 80)
# Find the runtime library redistribution directory.
get_filename_component(msvc_install_dir
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]" ABSOLUTE)
@@ -130,9 +162,7 @@ if(MSVC)
endif()
endif()
- if(MSVC_VERSION EQUAL 1500)
- set(MSVC_REDIST_NAME VC90)
-
+ if(MSVC_TOOLSET_VERSION EQUAL 90)
# Find the runtime library redistribution directory.
get_filename_component(msvc_install_dir
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0;InstallDir]" ABSOLUTE)
@@ -176,34 +206,39 @@ if(MSVC)
endif()
set(MSVC_REDIST_NAME "")
- set(_MSVCRT_DLL_VERSION "")
- set(_MSVCRT_IDE_VERSION "")
+ set(_MSVC_DLL_VERSION "")
+ set(_MSVC_IDE_VERSION "")
if(MSVC_VERSION GREATER_EQUAL 2000)
message(WARNING "MSVC ${MSVC_VERSION} not yet supported.")
- elseif(MSVC_VERSION GREATER_EQUAL 1911)
+ elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 143)
+ message(WARNING "MSVC toolset v${MSVC_TOOLSET_VERSION} not yet supported.")
+ elseif(MSVC_TOOLSET_VERSION EQUAL 142)
+ set(MSVC_REDIST_NAME VC142)
+ set(_MSVC_DLL_VERSION 140)
+ set(_MSVC_IDE_VERSION 16)
+ if(MSVC_VERSION EQUAL 1920)
+ # VS2019 named this differently prior to update 1.
+ set(MSVC_REDIST_NAME VC141)
+ endif()
+ elseif(MSVC_TOOLSET_VERSION EQUAL 141)
set(MSVC_REDIST_NAME VC141)
- set(_MSVCRT_DLL_VERSION 140)
- set(_MSVCRT_IDE_VERSION 15)
- elseif(MSVC_VERSION EQUAL 1910)
- set(MSVC_REDIST_NAME VC150)
- set(_MSVCRT_DLL_VERSION 140)
- set(_MSVCRT_IDE_VERSION 15)
- elseif(MSVC_VERSION EQUAL 1900)
- set(MSVC_REDIST_NAME VC140)
- set(_MSVCRT_DLL_VERSION 140)
- set(_MSVCRT_IDE_VERSION 14)
- elseif(MSVC_VERSION EQUAL 1800)
- set(MSVC_REDIST_NAME VC120)
- set(_MSVCRT_DLL_VERSION 120)
- set(_MSVCRT_IDE_VERSION 12)
- elseif(MSVC_VERSION EQUAL 1700)
- set(MSVC_REDIST_NAME VC110)
- set(_MSVCRT_DLL_VERSION 110)
- set(_MSVCRT_IDE_VERSION 11)
- elseif(MSVC_VERSION EQUAL 1600)
- set(MSVC_REDIST_NAME VC100)
- set(_MSVCRT_DLL_VERSION 100)
- set(_MSVCRT_IDE_VERSION 10)
+ set(_MSVC_DLL_VERSION 140)
+ set(_MSVC_IDE_VERSION 15)
+ if(MSVC_VERSION EQUAL 1910)
+ # VS2017 named this differently prior to update 3.
+ set(MSVC_REDIST_NAME VC150)
+ endif()
+ elseif(MSVC_TOOLSET_VERSION)
+ set(MSVC_REDIST_NAME VC${MSVC_TOOLSET_VERSION})
+ math(EXPR _MSVC_DLL_VERSION "${MSVC_TOOLSET_VERSION} / 10 * 10")
+ math(EXPR _MSVC_IDE_VERSION "${MSVC_TOOLSET_VERSION} / 10")
+ endif()
+
+ set(_MSVCRT_DLL_VERSION "")
+ set(_MSVCRT_IDE_VERSION "")
+ if(_MSVC_IDE_VERSION GREATER_EQUAL 10)
+ set(_MSVCRT_DLL_VERSION "${_MSVC_DLL_VERSION}")
+ set(_MSVCRT_IDE_VERSION "${_MSVC_IDE_VERSION}")
endif()
if(_MSVCRT_DLL_VERSION)
@@ -216,10 +251,19 @@ if(MSVC)
endif()
if(NOT vs VERSION_LESS 15)
set(_vs_redist_paths "")
- cmake_host_system_information(RESULT _vs_dir QUERY VS_${vs}_DIR) # undocumented query
- if(IS_DIRECTORY "${_vs_dir}")
- file(GLOB _vs_redist_paths "${_vs_dir}/VC/Redist/MSVC/*")
- endif()
+ # The toolset and its redistributables may come with any VS version 15 or newer.
+ set(_MSVC_IDE_VERSIONS 16 15)
+ foreach(_vs_ver ${_MSVC_IDE_VERSIONS})
+ set(_vs_glob_redist_paths "")
+ cmake_host_system_information(RESULT _vs_dir QUERY VS_${_vs_ver}_DIR) # undocumented query
+ if(IS_DIRECTORY "${_vs_dir}")
+ file(GLOB _vs_glob_redist_paths "${_vs_dir}/VC/Redist/MSVC/*")
+ list(REVERSE _vs_glob_redist_paths)
+ list(APPEND _vs_redist_paths ${_vs_glob_redist_paths})
+ endif()
+ unset(_vs_glob_redist_paths)
+ endforeach()
+ unset(_MSVC_IDE_VERSIONS)
unset(_vs_dir)
else()
get_filename_component(_vs_dir
@@ -244,6 +288,16 @@ if(MSVC)
"${MSVC_CRT_DIR}/msvcp${v}.dll"
)
if(NOT vs VERSION_LESS 14)
+ foreach(crt
+ "${MSVC_CRT_DIR}/msvcp${v}_1.dll"
+ "${MSVC_CRT_DIR}/msvcp${v}_2.dll"
+ "${MSVC_CRT_DIR}/msvcp${v}_codecvt_ids.dll"
+ "${MSVC_CRT_DIR}/vcruntime${v}_1.dll"
+ )
+ if(EXISTS "${crt}")
+ list(APPEND __install__libs "${crt}")
+ endif()
+ endforeach()
list(APPEND __install__libs
"${MSVC_CRT_DIR}/vcruntime${v}.dll"
"${MSVC_CRT_DIR}/concrt${v}.dll"
@@ -262,6 +316,16 @@ if(MSVC)
"${MSVC_CRT_DIR}/msvcp${v}d.dll"
)
if(NOT vs VERSION_LESS 14)
+ foreach(crt
+ "${MSVC_CRT_DIR}/msvcp${v}_1d.dll"
+ "${MSVC_CRT_DIR}/msvcp${v}_2d.dll"
+ "${MSVC_CRT_DIR}/msvcp${v}d_codecvt_ids.dll"
+ "${MSVC_CRT_DIR}/vcruntime${v}_1d.dll"
+ )
+ if(EXISTS "${crt}")
+ list(APPEND __install__libs "${crt}")
+ endif()
+ endforeach()
list(APPEND __install__libs
"${MSVC_CRT_DIR}/vcruntime${v}d.dll"
"${MSVC_CRT_DIR}/concrt${v}d.dll"
@@ -276,7 +340,15 @@ if(MSVC)
get_filename_component(windows_kits_dir
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" ABSOLUTE)
set(programfilesx86 "ProgramFiles(x86)")
- find_path(WINDOWS_KITS_DIR NAMES Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll
+ if(";${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION};$ENV{UCRTVersion};$ENV{WindowsSDKVersion};" MATCHES [=[;(10\.[0-9.]+)[;\]]=])
+ set(__ucrt_version "${CMAKE_MATCH_1}/")
+ else()
+ set(__ucrt_version "")
+ endif()
+ find_path(WINDOWS_KITS_DIR
+ NAMES
+ Redist/${__ucrt_version}ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll
+ Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll
PATHS
$ENV{CMAKE_WINDOWS_KITS_10_DIR}
"${windows_kits_dir}"
@@ -287,11 +359,19 @@ if(MSVC)
# Glob the list of UCRT DLLs.
if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
- file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/*.dll")
+ if(EXISTS "${WINDOWS_KITS_DIR}/Redist/${__ucrt_version}ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll")
+ file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/Redist/${__ucrt_version}ucrt/DLLs/${CMAKE_MSVC_ARCH}/*.dll")
+ else()
+ file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/*.dll")
+ endif()
list(APPEND __install__libs ${__ucrt_dlls})
endif()
if(CMAKE_INSTALL_DEBUG_LIBRARIES)
- file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/bin/${CMAKE_MSVC_ARCH}/ucrt/*.dll")
+ if(EXISTS "${WINDOWS_KITS_DIR}/bin/${__ucrt_version}${CMAKE_MSVC_ARCH}/ucrt/ucrtbased.dll")
+ file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/bin/${__ucrt_version}${CMAKE_MSVC_ARCH}/ucrt/*.dll")
+ else()
+ file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/bin/${CMAKE_MSVC_ARCH}/ucrt/*.dll")
+ endif()
list(APPEND __install__libs ${__ucrt_dlls})
endif()
endif()
@@ -336,7 +416,7 @@ if(MSVC)
)
endif()
- # include the language dll's for vs8 as well as the actuall dll's
+ # include the language dll's for vs8 as well as the actual dll's
set(MSVC_MFCLOC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.MFCLOC")
# Install the manifest that allows DLLs to be loaded from the
# directory containing the executable.
@@ -380,7 +460,7 @@ if(MSVC)
)
endif()
- # include the language dll's for vs9 as well as the actuall dll's
+ # include the language dll's for vs9 as well as the actual dll's
set(MSVC_MFCLOC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.MFCLOC")
# Install the manifest that allows DLLs to be loaded from the
# directory containing the executable.
@@ -400,23 +480,9 @@ if(MSVC)
set(_MFC_DLL_VERSION "")
set(_MFC_IDE_VERSION "")
- if(MSVC_VERSION GREATER_EQUAL 2000)
- # Version not yet supported.
- elseif(MSVC_VERSION GREATER_EQUAL 1910)
- set(_MFC_DLL_VERSION 140)
- set(_MFC_IDE_VERSION 15)
- elseif(MSVC_VERSION EQUAL 1900)
- set(_MFC_DLL_VERSION 140)
- set(_MFC_IDE_VERSION 14)
- elseif(MSVC_VERSION EQUAL 1800)
- set(_MFC_DLL_VERSION 120)
- set(_MFC_IDE_VERSION 12)
- elseif(MSVC_VERSION EQUAL 1700)
- set(_MFC_DLL_VERSION 110)
- set(_MFC_IDE_VERSION 11)
- elseif(MSVC_VERSION EQUAL 1600)
- set(_MFC_DLL_VERSION 100)
- set(_MFC_IDE_VERSION 10)
+ if(_MSVC_IDE_VERSION GREATER_EQUAL 10)
+ set(_MFC_DLL_VERSION ${_MSVC_DLL_VERSION})
+ set(_MFC_IDE_VERSION ${_MSVC_IDE_VERSION})
endif()
if(_MFC_DLL_VERSION)
@@ -448,6 +514,10 @@ if(MSVC)
if("${v}" LESS 12 OR EXISTS "${MSVC_MFC_DIR}/mfc${v}d.dll")
set(__install__libs ${__install__libs}
"${MSVC_MFC_DIR}/mfc${v}d.dll"
+ )
+ endif()
+ if("${v}" LESS 12 OR EXISTS "${MSVC_MFC_DIR}/mfcm${v}d.dll")
+ set(__install__libs ${__install__libs}
"${MSVC_MFC_DIR}/mfcm${v}d.dll"
)
endif()
@@ -462,12 +532,16 @@ if(MSVC)
if("${v}" LESS 12 OR EXISTS "${MSVC_MFC_DIR}/mfc${v}.dll")
set(__install__libs ${__install__libs}
"${MSVC_MFC_DIR}/mfc${v}.dll"
+ )
+ endif()
+ if("${v}" LESS 12 OR EXISTS "${MSVC_MFC_DIR}/mfcm${v}.dll")
+ set(__install__libs ${__install__libs}
"${MSVC_MFC_DIR}/mfcm${v}.dll"
)
endif()
endif()
- # include the language dll's as well as the actuall dll's
+ # include the language dll's as well as the actual dll's
set(MSVC_MFCLOC_DIR "${MSVC_REDIST_MFC_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFCLOC")
set(__install__libs ${__install__libs}
"${MSVC_MFCLOC_DIR}/mfc${v}chs.dll"
@@ -486,33 +560,9 @@ if(MSVC)
# MSVC 8 was the first version with OpenMP
# Furthermore, there is no debug version of this
- if(CMAKE_INSTALL_OPENMP_LIBRARIES)
- set(_MSOMP_DLL_VERSION "")
- set(_MSOMP_IDE_VERSION "")
- if(MSVC_VERSION GREATER_EQUAL 2000)
- # Version not yet supported.
- elseif(MSVC_VERSION GREATER_EQUAL 1910)
- set(_MSOMP_DLL_VERSION 140)
- set(_MSOMP_IDE_VERSION 15)
- elseif(MSVC_VERSION EQUAL 1900)
- set(_MSOMP_DLL_VERSION 140)
- set(_MSOMP_IDE_VERSION 14)
- elseif(MSVC_VERSION EQUAL 1800)
- set(_MSOMP_DLL_VERSION 120)
- set(_MSOMP_IDE_VERSION 12)
- elseif(MSVC_VERSION EQUAL 1700)
- set(_MSOMP_DLL_VERSION 110)
- set(_MSOMP_IDE_VERSION 11)
- elseif(MSVC_VERSION EQUAL 1600)
- set(_MSOMP_DLL_VERSION 100)
- set(_MSOMP_IDE_VERSION 10)
- elseif(MSVC_VERSION EQUAL 1500)
- set(_MSOMP_DLL_VERSION 90)
- set(_MSOMP_IDE_VERSION 9)
- elseif(MSVC_VERSION EQUAL 1400)
- set(_MSOMP_DLL_VERSION 80)
- set(_MSOMP_IDE_VERSION 8)
- endif()
+ if(CMAKE_INSTALL_OPENMP_LIBRARIES AND _IRSL_HAVE_MSVC)
+ set(_MSOMP_DLL_VERSION ${_MSVC_DLL_VERSION})
+ set(_MSOMP_IDE_VERSION ${_MSVC_IDE_VERSION})
if(_MSOMP_DLL_VERSION)
set(v "${_MSOMP_DLL_VERSION}")
@@ -545,6 +595,119 @@ if(MSVC)
endforeach()
endif()
+if(_IRSL_HAVE_Intel)
+ unset(__install_libs)
+ if(CMAKE_INSTALL_OPENMP_LIBRARIES)
+ if(WIN32)
+ list(APPEND __install_libs "${_Intel_redistdir}/libiomp5md.dll" "${_Intel_redistdir}/libiompstubs5md.dll")
+ elseif(APPLE)
+ list(APPEND __install_libs "${_Intel_redistdir}/libiomp5.dylib" "${_Intel_redistdir}/libiompstubs5.dylib")
+ else()
+ list(APPEND __install_libs "${_Intel_redistdir}/libiomp5.so" "${_Intel_redistdir}/libiompstubs5.so")
+ if(_Intel_compiler_ver VERSION_LESS 17)
+ list(APPEND __install_libs "${_Intel_redistdir}/libomp_db.so")
+ endif()
+ if(_Intel_compiler_ver VERSION_LESS 13)
+ list(APPEND __install_libs "${_Intel_redistdir}/libiompprof5.so")
+ endif()
+ endif()
+ endif()
+ if(WIN32)
+ set(__install_dirs "${_Intel_redistdir}/1033")
+ if(EXISTS "${_Intel_redistdir}/1041")
+ list(APPEND __install_dirs "${_Intel_redistdir}/1041")
+ endif()
+ if(_Intel_compiler_ver VERSION_LESS 18)
+ list(APPEND __install_dirs "${_Intel_redistdir}/irml" "${_Intel_redistdir}/irml_c")
+ endif()
+ foreach(__Intel_lib IN ITEMS cilkrts20.dll libchkp.dll libioffload_host.dll libirngmd.dll
+ libmmd.dll libmmdd.dll libmpx.dll liboffload.dll svml_dispmd.dll)
+
+ list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
+ endforeach()
+ if(CMAKE_C_COMPILER_ID STREQUAL Intel OR CMAKE_CXX_COMPILER_ID STREQUAL Intel)
+ list(APPEND __install_libs "${_Intel_redistdir}/libgfxoffload.dll")
+ endif()
+ if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
+ foreach(__Intel_lib IN ITEMS ifdlg100.dll libicaf.dll libifcoremd.dll libifcoremdd.dll libifcorert.dll libifcorertd.dll libifportmd.dll)
+
+ list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
+ endforeach()
+ endif()
+ elseif(APPLE)
+ foreach(__Intel_lib IN ITEMS libchkp.dylib libcilkrts.5.dylib libcilkrts.dylib libimf.dylib libintlc.dylib libirc.dylib libirng.dylib libsvml.dylib)
+ list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
+ endforeach()
+ if(CMAKE_C_COMPILER_ID STREQUAL Intel OR CMAKE_CXX_COMPILER_ID STREQUAL Intel)
+ if(_Intel_compiler_ver VERSION_LESS 17)
+ list(APPEND __install_libs "${_Intel_redistdir}/libistrconv.dylib")
+ endif()
+ endif()
+ if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
+ foreach(__Intel_lib IN ITEMS libifcore.dylib libifcoremt.dylib libifport.dylib libifportmt.dylib)
+
+ list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
+ endforeach()
+ endif()
+ else()
+ foreach(__Intel_lib IN ITEMS libchkp.so libcilkrts.so libcilkrts.so.5 libimf.so libintlc.so libintlc.so.5 libirc.so libpdbx.so libpdbx.so.5 libsvml.so)
+
+ list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
+ endforeach()
+ if(_Intel_compiler_ver VERSION_GREATER_EQUAL 13)
+ foreach(__Intel_lib IN ITEMS libirng.so liboffload.so liboffload.so.5)
+
+ list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
+ endforeach()
+ endif()
+ if(CMAKE_C_COMPILER_ID STREQUAL Intel OR CMAKE_CXX_COMPILER_ID STREQUAL Intel)
+ set(__install_dirs "${_Intel_redistdir}/irml")
+ list(APPEND __install_libs "${_Intel_redistdir}/cilk_db.so")
+ if(_Intel_compiler_ver VERSION_GREATER_EQUAL 15)
+ list(APPEND __install_libs "${_Intel_redistdir}/libistrconv.so" "${_Intel_redistdir}/libgfxoffload.so")
+ endif()
+ endif()
+ if(_Intel_compiler_ver VERSION_GREATER_EQUAL 16)
+ foreach(__Intel_lib IN ITEMS libioffload_host.so libioffload_host.so.5 libioffload_target.so libioffload_target.so.5 libmpx.so offload_main)
+
+ list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
+ endforeach()
+ endif()
+ if(_Intel_compiler_ver VERSION_LESS 15)
+ foreach(__Intel_lib IN ITEMS libcxaguard.so libcxaguard.so.5)
+
+ list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
+ endforeach()
+ endif()
+ if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
+ foreach(__Intel_lib IN ITEMS libicaf.so libifcore.so libifcore.so.5 libifcoremt.so libifcoremt.so.5 libifport.so libifport.so.5)
+
+ list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
+ endforeach()
+ endif()
+ endif()
+
+ foreach(lib IN LISTS __install_libs)
+ if(EXISTS ${lib})
+ list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${lib})
+ else()
+ if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
+ message(WARNING "system runtime library file does not exist: '${lib}'")
+ endif()
+ endif()
+ endforeach()
+
+ foreach(dir IN LISTS __install_dirs)
+ if(EXISTS ${dir})
+ list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_DIRECTORIES ${dir})
+ else()
+ if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
+ message(WARNING "system runtime library file does not exist: '${dir}'")
+ endif()
+ endif()
+ endforeach()
+endif()
+
if(WATCOM)
get_filename_component( CompilerPath ${CMAKE_C_COMPILER} PATH )
if(CMAKE_C_COMPILER_VERSION)
@@ -598,5 +761,12 @@ if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION}
${_CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT}
)
+
+ install(DIRECTORY ${CMAKE_INSTALL_SYSTEM_RUNTIME_DIRECTORIES}
+ DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION}
+ ${_CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT}
+ )
endif()
endif()
+
+cmake_policy(POP)
diff --git a/Modules/Internal/CMakeCheckCompilerFlag.cmake b/Modules/Internal/CMakeCheckCompilerFlag.cmake
new file mode 100644
index 000000000..9c8dfb617
--- /dev/null
+++ b/Modules/Internal/CMakeCheckCompilerFlag.cmake
@@ -0,0 +1,158 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=[
+
+NOTE: This function is used internally by CMake. Projects should not include
+ this file directly.
+
+The cmake_check_compiler_flag() function can be used to compile and link a
+source file to check whether a specific compiler or linker flag is supported.
+The function does not use the try_compile() command so as to avoid infinite
+recursion. It may not work for all platforms or toolchains, the caller is
+responsible for ensuring it is only called in valid situations.
+
+ cmake_check_compiler_flag(<lang> <flag> <result>
+ [SRC_EXT <ext>] [COMMAND_PATTERN <pattern>]
+ [FAIL_REGEX <regex> ...]
+ [OUTPUT_VARIABLE <output>])
+
+Parameters:
+ <lang> - Language to check.
+ <flag> - The flag to add to the compile/link command line.
+ <result> - Boolean output variable. It will be stored in the cache as an
+ internal variable and if true, will cause future tests that assign
+ to that variable to be bypassed.
+
+Optional parameters:
+ SRC_EXT - Overrides the extension of the source file used for the
+ check. Defaults are 'c' (C), 'cxx' (CXX), 'F' (Fortran).
+ COMMAND_PATTERN - Pattern to be used for the command line. The default is
+ '<FLAG> -o <OUTPUT> <SOURCE>'
+ FAIL_REGEX - List of additional regular expressions that, if matched by
+ the output, give a failed result for the check. A common
+ set of regular expressions will be included in addition to
+ those given by FAIL_REGEX.
+ OUTPUT_VARIABLE - Set <output> variable with details about any error.
+#]=]
+
+include_guard(GLOBAL)
+include(CMakeCheckCompilerFlagCommonPatterns)
+
+function(CMAKE_CHECK_COMPILER_FLAG lang flag result)
+ # Cache results between runs similar to check_<lang>_source_compiles()
+ if(DEFINED ${result})
+ return()
+ endif()
+
+ set(comment "Is the '${flag}' option(s) supported")
+ string(REPLACE ";" " " comment "${comment}")
+
+ if (NOT lang MATCHES "^(C|CXX|Fortran|ASM)$")
+ # other possible languages are not supported
+ # log message to keep trace of this problem...
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Function 'CMAKE_CHECK_COMPILER_FLAG' called with unsupported language: ${lang}\n")
+ set(${result} FALSE CACHE INTERNAL ${comment})
+ return()
+ endif()
+ if (lang STREQUAL "ASM")
+ # assume ASM compiler is a multi-language compiler, so supports C language as well
+ set(check_lang C)
+ else()
+ set(check_lang ${lang})
+ endif()
+
+ cmake_parse_arguments(CCCF "" "SRC_EXT;COMMAND_PATTERN;OUTPUT_VARIABLE" "FAIL_REGEX" ${ARGN})
+
+ if (NOT CCCF_COMMAND_PATTERN)
+ set (CCCF_COMMAND_PATTERN "<FLAG> -o <OUTPUT> <SOURCE>")
+ endif()
+
+ list (APPEND CCCF_FAIL_REGEX "argument unused during compilation") # clang
+ if (check_lang STREQUAL "C")
+ list(APPEND CCCF_FAIL_REGEX
+ "command line option .* is valid for .* but not for C") # GNU
+ elseif(check_lang STREQUAL "CXX")
+ list(APPEND CCCF_FAIL_REGEX
+ "command line option .* is valid for .* but not for C\\+\\+") # GNU
+ elseif(check_lang STREQUAL "Fortran")
+ list(APPEND CCCF_FAIL_REGEX
+ "command line option .* is valid for .* but not for Fortran") # GNU
+ endif()
+
+ # Add patterns for common errors
+ check_compiler_flag_common_patterns(COMPILER_FLAG_COMMON_PATTERNS)
+ foreach(arg IN LISTS COMPILER_FLAG_COMMON_PATTERNS)
+ if(arg MATCHES "^FAIL_REGEX$")
+ continue()
+ endif()
+ list(APPEND CCCF_FAIL_REGEX "${arg}")
+ endforeach()
+
+ if(NOT CCCF_SRC_EXT)
+ if (check_lang STREQUAL "C")
+ set(CCCF_SRC_EXT c)
+ elseif(check_lang STREQUAL "CXX")
+ set(CCCF_SRC_EXT cxx)
+ elseif(check_lang STREQUAL "Fortran")
+ set(CCCF_SRC_EXT F)
+ endif()
+ endif()
+
+ if (CCCF_OUTPUT_VARIABLE)
+ unset(${CCCF_OUTPUT_VARIABLE} PARENT_SCOPE)
+ endif()
+
+ # Compute the directory in which to run the test.
+ set(COMPILER_FLAG_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp")
+ # Compute source and output files.
+ set(COMPILER_FLAG_SRC
+ "${COMPILER_FLAG_DIR}/CompilerFlag${lang}.${CCCF_SRC_EXT}")
+ if(check_lang STREQUAL "Fortran")
+ file(WRITE "${COMPILER_FLAG_SRC}"
+ " program simple\n end program simple\n")
+ else()
+ file(WRITE "${COMPILER_FLAG_SRC}" "int main (void)\n{ return 0; }\n")
+ endif()
+ get_filename_component(COMPILER_FLAG_EXE "${COMPILER_FLAG_SRC}" NAME_WE)
+ string(APPEND COMPILER_FLAG_EXE "${CMAKE_EXECUTABLE_SUFFIX}")
+
+ # Build command line
+ separate_arguments(CCCF_COMMAND_PATTERN UNIX_COMMAND
+ "${CCCF_COMMAND_PATTERN}")
+ list(TRANSFORM CCCF_COMMAND_PATTERN REPLACE "<SOURCE>" "${COMPILER_FLAG_SRC}")
+ list(TRANSFORM CCCF_COMMAND_PATTERN REPLACE "<OUTPUT>" "${COMPILER_FLAG_EXE}")
+ list(TRANSFORM CCCF_COMMAND_PATTERN REPLACE "<FLAG>" "${flag}")
+
+ execute_process(
+ COMMAND "${CMAKE_COMMAND}" -E env LC_ALL=C LC_MESSAGES=C LANG=C
+ "${CMAKE_${lang}_COMPILER}" ${CCCF_COMMAND_PATTERN}
+ WORKING_DIRECTORY "${COMPILER_FLAG_DIR}"
+ OUTPUT_VARIABLE COMPILER_FLAG_OUTPUT
+ ERROR_VARIABLE COMPILER_FLAG_OUTPUT
+ RESULT_VARIABLE COMPILER_FLAG_RESULT)
+
+ # Record result in the cache so we can avoid re-testing every CMake run
+ if (COMPILER_FLAG_RESULT)
+ set(${result} FALSE CACHE INTERNAL ${comment})
+ else()
+ foreach(regex IN LISTS CCCF_FAIL_REGEX)
+ if(COMPILER_FLAG_OUTPUT MATCHES "${regex}")
+ set(${result} FALSE CACHE INTERNAL ${comment})
+ endif()
+ endforeach()
+ endif()
+ if (DEFINED ${result})
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if the ${flag} option "
+ "is supported for ${lang} language failed with the following output:\n"
+ "${COMPILER_FLAG_OUTPUT}\n")
+ if (CCCF_OUTPUT_VARIABLE)
+ set(${CCCF_OUTPUT_VARIABLE} "${COMPILER_FLAG_OUTPUT}" PARENT_SCOPE)
+ endif()
+ return()
+ endif()
+
+ set(${result} TRUE CACHE INTERNAL ${comment})
+endfunction()
diff --git a/Modules/CPack.DS_Store.in b/Modules/Internal/CPack/CPack.DS_Store.in
index 5be0eeb18..5be0eeb18 100644
--- a/Modules/CPack.DS_Store.in
+++ b/Modules/Internal/CPack/CPack.DS_Store.in
Binary files differ
diff --git a/Modules/CPack.Description.plist.in b/Modules/Internal/CPack/CPack.Description.plist.in
index 3d1147686..3d1147686 100644
--- a/Modules/CPack.Description.plist.in
+++ b/Modules/Internal/CPack/CPack.Description.plist.in
diff --git a/Modules/CPack.Info.plist.in b/Modules/Internal/CPack/CPack.Info.plist.in
index 6e325001c..6e325001c 100644
--- a/Modules/CPack.Info.plist.in
+++ b/Modules/Internal/CPack/CPack.Info.plist.in
diff --git a/Modules/Internal/CPack/CPack.NuGet.nuspec.in b/Modules/Internal/CPack/CPack.NuGet.nuspec.in
new file mode 100644
index 000000000..b7beb5de0
--- /dev/null
+++ b/Modules/Internal/CPack/CPack.NuGet.nuspec.in
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
+ <metadata>
+ <!-- Required elements-->
+ <id>@CPACK_NUGET_PACKAGE_NAME@</id>
+ <version>@CPACK_NUGET_PACKAGE_VERSION@</version>
+ <description>@CPACK_NUGET_PACKAGE_DESCRIPTION@</description>
+ <authors>@CPACK_NUGET_PACKAGE_AUTHORS@</authors>
+
+ <!-- Optional elements -->
+ @_CPACK_NUGET_TITLE_TAG@
+ @_CPACK_NUGET_OWNERS_TAG@
+ @_CPACK_NUGET_PROJECTURL_TAG@
+ @_CPACK_NUGET_LICENSEURL_TAG@
+ @_CPACK_NUGET_ICONURL_TAG@
+ @_CPACK_NUGET_REQUIRELICENSEACCEPTANCE_TAG@
+ @_CPACK_NUGET_SUMMARY_TAG@
+ @_CPACK_NUGET_RELEASENOTES_TAG@
+ @_CPACK_NUGET_COPYRIGHT_TAG@
+ @_CPACK_NUGET_TAGS_TAG@
+ @_CPACK_NUGET_DEPENDENCIES_TAG@
+ </metadata>
+ @_CPACK_NUGET_FILES_TAG@
+</package>
diff --git a/Modules/CPack.OSXScriptLauncher.in b/Modules/Internal/CPack/CPack.OSXScriptLauncher.in
index c71586046..c71586046 100755..100644
--- a/Modules/CPack.OSXScriptLauncher.in
+++ b/Modules/Internal/CPack/CPack.OSXScriptLauncher.in
Binary files differ
diff --git a/Modules/CPack.OSXScriptLauncher.rsrc.in b/Modules/Internal/CPack/CPack.OSXScriptLauncher.rsrc.in
index 5f5f17a1c..5f5f17a1c 100644
--- a/Modules/CPack.OSXScriptLauncher.rsrc.in
+++ b/Modules/Internal/CPack/CPack.OSXScriptLauncher.rsrc.in
Binary files differ
diff --git a/Modules/CPack.OSXX11.Info.plist.in b/Modules/Internal/CPack/CPack.OSXX11.Info.plist.in
index 23a1483b7..23a1483b7 100644
--- a/Modules/CPack.OSXX11.Info.plist.in
+++ b/Modules/Internal/CPack/CPack.OSXX11.Info.plist.in
diff --git a/Modules/CPack.OSXX11.main.scpt.in b/Modules/Internal/CPack/CPack.OSXX11.main.scpt.in
index de30ea11b..de30ea11b 100644
--- a/Modules/CPack.OSXX11.main.scpt.in
+++ b/Modules/Internal/CPack/CPack.OSXX11.main.scpt.in
Binary files differ
diff --git a/Modules/CPack.RuntimeScript.in b/Modules/Internal/CPack/CPack.RuntimeScript.in
index f27444fd9..f27444fd9 100755
--- a/Modules/CPack.RuntimeScript.in
+++ b/Modules/Internal/CPack/CPack.RuntimeScript.in
diff --git a/Modules/Internal/CPack/CPack.STGZ_Header.sh.in b/Modules/Internal/CPack/CPack.STGZ_Header.sh.in
new file mode 100755
index 000000000..a857aa584
--- /dev/null
+++ b/Modules/Internal/CPack/CPack.STGZ_Header.sh.in
@@ -0,0 +1,149 @@
+#!/bin/sh
+
+# Display usage
+cpack_usage()
+{
+ cat <<EOF
+Usage: $0 [options]
+Options: [defaults in brackets after descriptions]
+ --help print this message
+ --version print cmake installer version
+ --prefix=dir directory in which to install
+ --include-subdir include the @CPACK_PACKAGE_FILE_NAME@ subdirectory
+ --exclude-subdir exclude the @CPACK_PACKAGE_FILE_NAME@ subdirectory
+ --skip-license accept license
+EOF
+ exit 1
+}
+
+cpack_echo_exit()
+{
+ echo $1
+ exit 1
+}
+
+# Display version
+cpack_version()
+{
+ echo "@CPACK_PACKAGE_NAME@ Installer Version: @CPACK_PACKAGE_VERSION@, Copyright (c) @CPACK_PACKAGE_VENDOR@"
+}
+
+# Helper function to fix windows paths.
+cpack_fix_slashes ()
+{
+ echo "$1" | sed 's/\\/\//g'
+}
+
+interactive=TRUE
+cpack_skip_license=FALSE
+cpack_include_subdir=""
+for a in "$@CPACK_AT_SIGN@"; do
+ if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
+ cpack_prefix_dir=`echo $a | sed "s/^--prefix=//"`
+ cpack_prefix_dir=`cpack_fix_slashes "${cpack_prefix_dir}"`
+ fi
+ if echo $a | grep "^--help" > /dev/null 2> /dev/null; then
+ cpack_usage
+ fi
+ if echo $a | grep "^--version" > /dev/null 2> /dev/null; then
+ cpack_version
+ exit 2
+ fi
+ if echo $a | grep "^--include-subdir" > /dev/null 2> /dev/null; then
+ cpack_include_subdir=TRUE
+ fi
+ if echo $a | grep "^--exclude-subdir" > /dev/null 2> /dev/null; then
+ cpack_include_subdir=FALSE
+ fi
+ if echo $a | grep "^--skip-license" > /dev/null 2> /dev/null; then
+ cpack_skip_license=TRUE
+ fi
+done
+
+if [ "x${cpack_include_subdir}x" != "xx" -o "x${cpack_skip_license}x" = "xTRUEx" ]
+then
+ interactive=FALSE
+fi
+
+cpack_version
+echo "This is a self-extracting archive."
+toplevel="`pwd`"
+if [ "x${cpack_prefix_dir}x" != "xx" ]
+then
+ toplevel="${cpack_prefix_dir}"
+fi
+
+echo "The archive will be extracted to: ${toplevel}"
+
+if [ "x${interactive}x" = "xTRUEx" ]
+then
+ echo ""
+ echo "If you want to stop extracting, please press <ctrl-C>."
+
+ if [ "x${cpack_skip_license}x" != "xTRUEx" ]
+ then
+ more << '____cpack__here_doc____'
+@CPACK_RESOURCE_FILE_LICENSE_CONTENT@
+____cpack__here_doc____
+ echo
+ while true
+ do
+ echo "Do you accept the license? [yn]: "
+ read line leftover
+ case ${line} in
+ y* | Y*)
+ cpack_license_accepted=TRUE
+ break;;
+ n* | N* | q* | Q* | e* | E*)
+ echo "License not accepted. Exiting ..."
+ exit 1;;
+ esac
+ done
+ fi
+
+ if [ "x${cpack_include_subdir}x" = "xx" ]
+ then
+ echo "By default the @CPACK_PACKAGE_NAME@ will be installed in:"
+ echo " \"${toplevel}/@CPACK_PACKAGE_FILE_NAME@\""
+ echo "Do you want to include the subdirectory @CPACK_PACKAGE_FILE_NAME@?"
+ echo "Saying no will install in: \"${toplevel}\" [Yn]: "
+ read line leftover
+ cpack_include_subdir=TRUE
+ case ${line} in
+ n* | N*)
+ cpack_include_subdir=FALSE
+ esac
+ fi
+fi
+
+if [ "x${cpack_include_subdir}x" = "xTRUEx" ]
+then
+ toplevel="${toplevel}/@CPACK_PACKAGE_FILE_NAME@"
+ mkdir -p "${toplevel}"
+fi
+echo
+echo "Using target directory: ${toplevel}"
+echo "Extracting, please wait..."
+echo ""
+
+# take the archive portion of this file and pipe it to tar
+# the NUMERIC parameter in this command should be one more
+# than the number of lines in this header file
+# there are tails which don't understand the "-n" argument, e.g. on SunOS
+# OTOH there are tails which complain when not using the "-n" argument (e.g. GNU)
+# so at first try to tail some file to see if tail fails if used with "-n"
+# if so, don't use "-n"
+use_new_tail_syntax="-n"
+tail $use_new_tail_syntax +1 "$0" > /dev/null 2> /dev/null || use_new_tail_syntax=""
+
+extractor="pax -r"
+command -v pax > /dev/null 2> /dev/null || extractor="tar xf -"
+
+tail $use_new_tail_syntax +###CPACK_HEADER_LENGTH### "$0" | gunzip | (cd "${toplevel}" && ${extractor}) || cpack_echo_exit "Problem unpacking the @CPACK_PACKAGE_FILE_NAME@"
+
+echo "Unpacking finished successfully"
+
+exit 0
+#-----------------------------------------------------------
+# Start of TAR.GZ file
+#-----------------------------------------------------------;
diff --git a/Modules/CPack.VolumeIcon.icns.in b/Modules/Internal/CPack/CPack.VolumeIcon.icns.in
index c59217eae..c59217eae 100644
--- a/Modules/CPack.VolumeIcon.icns.in
+++ b/Modules/Internal/CPack/CPack.VolumeIcon.icns.in
Binary files differ
diff --git a/Modules/Internal/CPack/CPack.background.png.in b/Modules/Internal/CPack/CPack.background.png.in
new file mode 100644
index 000000000..a32ab3762
--- /dev/null
+++ b/Modules/Internal/CPack/CPack.background.png.in
Binary files differ
diff --git a/Modules/CPack.distribution.dist.in b/Modules/Internal/CPack/CPack.distribution.dist.in
index f20e66c17..f20e66c17 100644
--- a/Modules/CPack.distribution.dist.in
+++ b/Modules/Internal/CPack/CPack.distribution.dist.in
diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake
new file mode 100644
index 000000000..97906cad0
--- /dev/null
+++ b/Modules/Internal/CPack/CPackDeb.cmake
@@ -0,0 +1,766 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# CPack script for creating Debian package
+# Author: Mathieu Malaterre
+#
+# http://wiki.debian.org/HowToPackageForDebian
+
+if(CMAKE_BINARY_DIR)
+ message(FATAL_ERROR "CPackDeb.cmake may only be used by CPack internally.")
+endif()
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
+function(cpack_deb_variable_fallback OUTPUT_VAR_NAME)
+ set(FALLBACK_VAR_NAMES ${ARGN})
+
+ foreach(variable_name IN LISTS FALLBACK_VAR_NAMES)
+ if(${variable_name})
+ set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE)
+ break()
+ endif()
+ endforeach()
+endfunction()
+
+function(get_component_package_name var component)
+ string(TOUPPER "${component}" component_upcase)
+ if(CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME)
+ string(TOLOWER "${CPACK_DEBIAN_${component_upcase}_PACKAGE_NAME}" package_name)
+ else()
+ string(TOLOWER "${CPACK_DEBIAN_PACKAGE_NAME}-${component}" package_name)
+ endif()
+
+ set("${var}" "${package_name}" PARENT_SCOPE)
+endfunction()
+
+#extract library name and version for given shared object
+function(extract_so_info shared_object libname version)
+ if(READELF_EXECUTABLE)
+ execute_process(COMMAND "${READELF_EXECUTABLE}" -d "${shared_object}"
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE output
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(result EQUAL 0)
+ string(REGEX MATCH "\\(?SONAME\\)?[^\n]*\\[([^\n]+)\\.so\\.([^\n]*)\\]" soname "${output}")
+ set(${libname} "${CMAKE_MATCH_1}" PARENT_SCOPE)
+ set(${version} "${CMAKE_MATCH_2}" PARENT_SCOPE)
+ else()
+ message(WARNING "Error running readelf for \"${shared_object}\"")
+ endif()
+ else()
+ message(FATAL_ERROR "Readelf utility is not available.")
+ endif()
+endfunction()
+
+function(cpack_deb_check_description SUMMARY LINES RESULT_VARIABLE)
+ set(_result TRUE)
+
+ # Get the summary line
+ if(NOT SUMMARY MATCHES "^[^\\s].*$")
+ set(_result FALSE)
+ set(${RESULT_VARIABLE} ${_result} PARENT_SCOPE)
+ return()
+ endif()
+
+ foreach(_line IN LISTS LINES)
+ if(NOT _line MATCHES "^ +[^ ]+.*$")
+ set(_result FALSE)
+ break()
+ endif()
+ endforeach()
+
+ set(${RESULT_VARIABLE} ${_result} PARENT_SCOPE)
+endfunction()
+
+function(cpack_deb_format_package_description TEXT OUTPUT_VAR)
+ # Turn the possible multi-line string into a list
+ string(UUID uuid NAMESPACE 00000000-0000-0000-0000-000000000000 TYPE SHA1)
+ string(REPLACE ";" "${uuid}" _text "${TEXT}")
+ string(REPLACE "\n" ";" _lines "${_text}")
+ list(POP_FRONT _lines _summary)
+
+ # Check if reformatting required
+ cpack_deb_check_description("${_summary}" "${_lines}" _result)
+ if(_result)
+ # Ok, no formatting required
+ set(${OUTPUT_VAR} "${TEXT}" PARENT_SCOPE)
+ return()
+ endif()
+
+ # Format the summary line
+ string(STRIP "${_summary}" _summary)
+
+ # Make sure the rest formatted properly
+ set(_result)
+ foreach(_line IN LISTS _lines)
+ string(STRIP "${_line}" _line_strip)
+ if(NOT _line_strip)
+ # Replace empty lines w/ a _single full stop character_
+ set(_line " .")
+ else()
+ # Prepend the normal lines w/ a single space.
+ # If the line already starts w/ at least one space,
+ # it'll become _verbatim_ (assuming it supposed to be
+ # verbatim in the original text).
+ string(PREPEND _line " ")
+ endif()
+ list(APPEND _result "${_line}")
+ endforeach()
+
+ list(PREPEND _result "${_summary}")
+ list(JOIN _result "\n" _result)
+ string(REPLACE "${uuid}" ";" _result "${_result}")
+ set(${OUTPUT_VAR} "${_result}" PARENT_SCOPE)
+endfunction()
+
+function(cpack_deb_prepare_package_vars)
+ # CPACK_DEBIAN_PACKAGE_SHLIBDEPS
+ # If specify OFF, only user depends are used
+ if(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
+ set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF)
+ endif()
+
+ set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_PATH}")
+ set(DBGSYMDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_PATH}-dbgsym")
+ file(REMOVE_RECURSE "${DBGSYMDIR}")
+
+ # per component automatic discover: some of the component might not have
+ # binaries.
+ if(CPACK_DEB_PACKAGE_COMPONENT)
+ string(TOUPPER "${CPACK_DEB_PACKAGE_COMPONENT}" _local_component_name)
+ set(_component_shlibdeps_var "CPACK_DEBIAN_${_local_component_name}_PACKAGE_SHLIBDEPS")
+
+ # if set, overrides the global configuration
+ if(DEFINED ${_component_shlibdeps_var})
+ set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS "${${_component_shlibdeps_var}}")
+ if(CPACK_DEBIAN_PACKAGE_DEBUG)
+ message("CPackDeb Debug: component '${CPACK_DEB_PACKAGE_COMPONENT}' dpkg-shlibdeps set to ${CPACK_DEBIAN_PACKAGE_SHLIBDEPS}")
+ endif()
+ endif()
+ endif()
+
+ cpack_deb_variable_fallback("CPACK_DEBIAN_DEBUGINFO_PACKAGE"
+ "CPACK_DEBIAN_${_local_component_name}_DEBUGINFO_PACKAGE"
+ "CPACK_DEBIAN_DEBUGINFO_PACKAGE")
+ if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OR CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS OR CPACK_DEBIAN_DEBUGINFO_PACKAGE)
+ # Generating binary list - Get type of all install files
+ file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false RELATIVE "${WDIR}" "${WDIR}/*")
+
+ find_program(FILE_EXECUTABLE file)
+ if(NOT FILE_EXECUTABLE)
+ message(FATAL_ERROR "CPackDeb: file utility is not available. CPACK_DEBIAN_PACKAGE_SHLIBDEPS and CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS options are not available.")
+ endif()
+
+ # get file info so that we can determine if file is executable or not
+ unset(CPACK_DEB_INSTALL_FILES)
+ foreach(FILE_ IN LISTS FILE_PATHS_)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E env LC_ALL=C ${FILE_EXECUTABLE} "./${FILE_}"
+ WORKING_DIRECTORY "${WDIR}"
+ RESULT_VARIABLE FILE_RESULT_
+ OUTPUT_VARIABLE INSTALL_FILE_)
+ if(NOT FILE_RESULT_ EQUAL 0)
+ message(FATAL_ERROR "CPackDeb: execution of command: '${FILE_EXECUTABLE} ./${FILE_}' failed with exit code: ${FILE_RESULT_}")
+ endif()
+ list(APPEND CPACK_DEB_INSTALL_FILES "${INSTALL_FILE_}")
+ endforeach()
+
+ # Only dynamically linked ELF files are included
+ # Extract only file name infront of ":"
+ foreach(_FILE IN LISTS CPACK_DEB_INSTALL_FILES)
+ if(_FILE MATCHES "ELF.*dynamically linked")
+ string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
+ list(APPEND CPACK_DEB_BINARY_FILES "${CMAKE_MATCH_1}")
+ set(CONTAINS_EXECUTABLE_FILES_ TRUE)
+ endif()
+ if(_FILE MATCHES "ELF.*shared object")
+ string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
+ list(APPEND CPACK_DEB_SHARED_OBJECT_FILES "${CMAKE_MATCH_1}")
+ endif()
+ if(_FILE MATCHES "ELF.*not stripped")
+ string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
+ list(APPEND CPACK_DEB_UNSTRIPPED_FILES "${CMAKE_MATCH_1}")
+ endif()
+ endforeach()
+ endif()
+
+ find_program(READELF_EXECUTABLE NAMES readelf)
+
+ if(CPACK_DEBIAN_DEBUGINFO_PACKAGE AND CPACK_DEB_UNSTRIPPED_FILES)
+ find_program(OBJCOPY_EXECUTABLE NAMES objcopy)
+
+ if(NOT OBJCOPY_EXECUTABLE)
+ message(FATAL_ERROR "debuginfo packages require the objcopy tool")
+ endif()
+ if(NOT READELF_EXECUTABLE)
+ message(FATAL_ERROR "debuginfo packages require the readelf tool")
+ endif()
+
+ file(RELATIVE_PATH _DBGSYM_ROOT "${CPACK_TEMPORARY_DIRECTORY}" "${DBGSYMDIR}")
+ foreach(_FILE IN LISTS CPACK_DEB_UNSTRIPPED_FILES)
+
+ # Get the file's Build ID
+ execute_process(COMMAND env LC_ALL=C ${READELF_EXECUTABLE} -n "${_FILE}"
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ OUTPUT_VARIABLE READELF_OUTPUT
+ RESULT_VARIABLE READELF_RESULT
+ ERROR_VARIABLE READELF_ERROR
+ OUTPUT_STRIP_TRAILING_WHITESPACE )
+ if(NOT READELF_RESULT EQUAL 0)
+ message(FATAL_ERROR "CPackDeb: readelf: '${READELF_ERROR}';\n"
+ "executed command: '${READELF_EXECUTABLE} -n ${_FILE}'")
+ endif()
+ if(READELF_OUTPUT MATCHES "Build ID: ([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z]*)")
+ set(_BUILD_ID_START ${CMAKE_MATCH_1})
+ set(_BUILD_ID_REMAINING ${CMAKE_MATCH_2})
+ list(APPEND BUILD_IDS ${_BUILD_ID_START}${_BUILD_ID_REMAINING})
+ else()
+ message(FATAL_ERROR "Unable to determine Build ID for ${_FILE}")
+ endif()
+
+ # Split out the debug symbols from the binaries
+ set(_FILE_DBGSYM ${_DBGSYM_ROOT}/usr/lib/debug/.build-id/${_BUILD_ID_START}/${_BUILD_ID_REMAINING}.debug)
+ get_filename_component(_OUT_DIR "${_FILE_DBGSYM}" DIRECTORY)
+ file(MAKE_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}/${_OUT_DIR}")
+ execute_process(COMMAND ${OBJCOPY_EXECUTABLE} --only-keep-debug "${_FILE}" "${_FILE_DBGSYM}"
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ OUTPUT_VARIABLE OBJCOPY_OUTPUT
+ RESULT_VARIABLE OBJCOPY_RESULT
+ ERROR_VARIABLE OBJCOPY_ERROR
+ OUTPUT_STRIP_TRAILING_WHITESPACE )
+ if(NOT OBJCOPY_RESULT EQUAL 0)
+ message(FATAL_ERROR "CPackDeb: objcopy: '${OBJCOPY_ERROR}';\n"
+ "executed command: '${OBJCOPY_EXECUTABLE} --only-keep-debug ${_FILE} ${_FILE_DBGSYM}'")
+ endif()
+ execute_process(COMMAND ${OBJCOPY_EXECUTABLE} --strip-unneeded ${_FILE}
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ OUTPUT_VARIABLE OBJCOPY_OUTPUT
+ RESULT_VARIABLE OBJCOPY_RESULT
+ ERROR_VARIABLE OBJCOPY_ERROR
+ OUTPUT_STRIP_TRAILING_WHITESPACE )
+ if(NOT OBJCOPY_RESULT EQUAL 0)
+ message(FATAL_ERROR "CPackDeb: objcopy: '${OBJCOPY_ERROR}';\n"
+ "executed command: '${OBJCOPY_EXECUTABLE} --strip-debug ${_FILE}'")
+ endif()
+ execute_process(COMMAND ${OBJCOPY_EXECUTABLE} --add-gnu-debuglink=${_FILE_DBGSYM} ${_FILE}
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ OUTPUT_VARIABLE OBJCOPY_OUTPUT
+ RESULT_VARIABLE OBJCOPY_RESULT
+ ERROR_VARIABLE OBJCOPY_ERROR
+ OUTPUT_STRIP_TRAILING_WHITESPACE )
+ if(NOT OBJCOPY_RESULT EQUAL 0)
+ message(FATAL_ERROR "CPackDeb: objcopy: '${OBJCOPY_ERROR}';\n"
+ "executed command: '${OBJCOPY_EXECUTABLE} --add-gnu-debuglink=${_FILE_DBGSYM} ${_FILE}'")
+ endif()
+ endforeach()
+ endif()
+
+ if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
+ # dpkg-shlibdeps is a Debian utility for generating dependency list
+ find_program(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps)
+
+ if(SHLIBDEPS_EXECUTABLE)
+ # Check version of the dpkg-shlibdeps tool using CPackDEB method
+ execute_process(COMMAND ${CMAKE_COMMAND} -E env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --version
+ OUTPUT_VARIABLE _TMP_VERSION
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(_TMP_VERSION MATCHES "dpkg-shlibdeps version ([0-9]+\\.[0-9]+\\.[0-9]+)")
+ set(SHLIBDEPS_EXECUTABLE_VERSION "${CMAKE_MATCH_1}")
+ else()
+ unset(SHLIBDEPS_EXECUTABLE_VERSION)
+ endif()
+
+ if(CPACK_DEBIAN_PACKAGE_DEBUG)
+ message("CPackDeb Debug: dpkg-shlibdeps --version output is '${_TMP_VERSION}'")
+ message("CPackDeb Debug: dpkg-shlibdeps version is <${SHLIBDEPS_EXECUTABLE_VERSION}>")
+ endif()
+
+ if(CONTAINS_EXECUTABLE_FILES_)
+ message("CPackDeb: - Generating dependency list")
+
+ # Create blank control file for running dpkg-shlibdeps
+ # There might be some other way to invoke dpkg-shlibdeps without creating this file
+ # but standard debian package should not have anything that can collide with this file or directory
+ file(MAKE_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY}/debian)
+ file(WRITE ${CPACK_TEMPORARY_DIRECTORY}/debian/control "")
+
+ # Create a DEBIAN directory so that dpkg-shlibdeps can find the package dir when resolving $ORIGIN.
+ file(MAKE_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN")
+
+ # Add --ignore-missing-info if the tool supports it
+ execute_process(COMMAND ${CMAKE_COMMAND} -E env LC_ALL=C ${SHLIBDEPS_EXECUTABLE} --help
+ OUTPUT_VARIABLE _TMP_HELP
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(_TMP_HELP MATCHES "--ignore-missing-info")
+ set(IGNORE_MISSING_INFO_FLAG "--ignore-missing-info")
+ endif()
+
+ # Execute dpkg-shlibdeps
+ # --ignore-missing-info : allow dpkg-shlibdeps to run even if some libs do not belong to a package
+ # -O : print to STDOUT
+ execute_process(COMMAND ${SHLIBDEPS_EXECUTABLE} ${IGNORE_MISSING_INFO_FLAG} -O ${CPACK_DEB_BINARY_FILES}
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ OUTPUT_VARIABLE SHLIBDEPS_OUTPUT
+ RESULT_VARIABLE SHLIBDEPS_RESULT
+ ERROR_VARIABLE SHLIBDEPS_ERROR
+ OUTPUT_STRIP_TRAILING_WHITESPACE )
+ if(CPACK_DEBIAN_PACKAGE_DEBUG)
+ # dpkg-shlibdeps will throw some warnings if some input files are not binary
+ message( "CPackDeb Debug: dpkg-shlibdeps warnings \n${SHLIBDEPS_ERROR}")
+ endif()
+ if(NOT SHLIBDEPS_RESULT EQUAL 0)
+ message(FATAL_ERROR "CPackDeb: dpkg-shlibdeps: '${SHLIBDEPS_ERROR}';\n"
+ "executed command: '${SHLIBDEPS_EXECUTABLE} ${IGNORE_MISSING_INFO_FLAG} -O ${CPACK_DEB_BINARY_FILES}';\n"
+ "found files: '${INSTALL_FILE_}';\n"
+ "files info: '${CPACK_DEB_INSTALL_FILES}';\n"
+ "binary files: '${CPACK_DEB_BINARY_FILES}'")
+ endif()
+
+ #Get rid of prefix generated by dpkg-shlibdeps
+ string(REGEX REPLACE "^.*Depends=" "" CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS "${SHLIBDEPS_OUTPUT}")
+
+ if(CPACK_DEBIAN_PACKAGE_DEBUG)
+ message("CPackDeb Debug: Found dependency: ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS} from output ${SHLIBDEPS_OUTPUT}")
+ endif()
+
+ # Remove blank control file
+ # Might not be safe if package actual contain file or directory named debian
+ file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/debian")
+
+ # remove temporary directory that was created only for dpkg-shlibdeps execution
+ file(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/DEBIAN")
+ else()
+ if(CPACK_DEBIAN_PACKAGE_DEBUG)
+ message(AUTHOR_WARNING "CPackDeb Debug: Using only user-provided depends because package does not contain executable files that link to shared libraries.")
+ endif()
+ endif()
+ else()
+ message("CPackDeb: Using only user-provided dependencies because dpkg-shlibdeps is not found.")
+ endif()
+
+ else()
+ if(CPACK_DEBIAN_PACKAGE_DEBUG)
+ message("CPackDeb Debug: Using only user-provided dependencies")
+ endif()
+ endif()
+
+ # Let's define the control file found in debian package:
+
+ # Binary package:
+ # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles
+
+ # DEBIAN/control
+ # debian policy enforce lower case for package name
+ # Package: (mandatory)
+ if(NOT CPACK_DEBIAN_PACKAGE_NAME)
+ string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
+ endif()
+
+ # Version: (mandatory)
+ if(NOT CPACK_DEBIAN_PACKAGE_VERSION)
+ if(NOT CPACK_PACKAGE_VERSION)
+ message(FATAL_ERROR "CPackDeb: Debian package requires a package version")
+ endif()
+ set(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
+ endif()
+
+ if(DEFINED CPACK_DEBIAN_PACKAGE_RELEASE OR DEFINED CPACK_DEBIAN_PACKAGE_EPOCH)
+ # only test the version format if CPACK_DEBIAN_PACKAGE_RELEASE or
+ # CPACK_DEBIAN_PACKAGE_EPOCH is set
+ if(NOT CPACK_DEBIAN_PACKAGE_VERSION MATCHES "^[0-9][A-Za-z0-9.+~-]*$")
+ message(FATAL_ERROR
+ "CPackDeb: Debian package version must confirm to \"^[0-9][A-Za-z0-9.+~-]*$\" regex!")
+ endif()
+ else()
+ # before CMake 3.10 version format was not tested so only warn to preserve
+ # backward compatibility
+ if(NOT CPACK_DEBIAN_PACKAGE_VERSION MATCHES "^([0-9]+:)?[0-9][A-Za-z0-9.+~-]*$")
+ message(AUTHOR_WARNING
+ "CPackDeb: Debian package versioning ([<epoch>:]<version>[-<release>])"
+ " should confirm to \"^([0-9]+:)?[0-9][A-Za-z0-9.+~-]*$\" regex in"
+ " order to satisfy Debian packaging rules.")
+ endif()
+ endif()
+
+ if(CPACK_DEBIAN_PACKAGE_RELEASE)
+ if(NOT CPACK_DEBIAN_PACKAGE_RELEASE MATCHES "^[A-Za-z0-9.+~]+$")
+ message(FATAL_ERROR
+ "CPackDeb: Debian package release must confirm to \"^[A-Za-z0-9.+~]+$\" regex!")
+ endif()
+ string(APPEND CPACK_DEBIAN_PACKAGE_VERSION
+ "-${CPACK_DEBIAN_PACKAGE_RELEASE}")
+ elseif(DEFINED CPACK_DEBIAN_PACKAGE_EPOCH)
+ # only test the version format if CPACK_DEBIAN_PACKAGE_RELEASE or
+ # CPACK_DEBIAN_PACKAGE_EPOCH is set - versions CPack/Deb generator before
+ # CMake 3.10 did not check for version format so we have to preserve
+ # backward compatibility
+ if(CPACK_DEBIAN_PACKAGE_VERSION MATCHES ".*-.*")
+ message(FATAL_ERROR
+ "CPackDeb: Debian package version must not contain hyphens when CPACK_DEBIAN_PACKAGE_RELEASE is not provided!")
+ endif()
+ endif()
+
+ if(CPACK_DEBIAN_PACKAGE_EPOCH)
+ if(NOT CPACK_DEBIAN_PACKAGE_EPOCH MATCHES "^[0-9]+$")
+ message(FATAL_ERROR
+ "CPackDeb: Debian package epoch must confirm to \"^[0-9]+$\" regex!")
+ endif()
+ set(CPACK_DEBIAN_PACKAGE_VERSION
+ "${CPACK_DEBIAN_PACKAGE_EPOCH}:${CPACK_DEBIAN_PACKAGE_VERSION}")
+ endif()
+
+ # Architecture: (mandatory)
+ if(CPACK_DEB_PACKAGE_COMPONENT AND CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE)
+ set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_${_local_component_name}_PACKAGE_ARCHITECTURE}")
+ elseif(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
+ # There is no such thing as i686 architecture on debian, you should use i386 instead
+ # $ dpkg --print-architecture
+ find_program(DPKG_CMD dpkg)
+ if(NOT DPKG_CMD)
+ message(STATUS "CPackDeb: Can not find dpkg in your path, default to i386.")
+ set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
+ endif()
+ execute_process(COMMAND "${DPKG_CMD}" --print-architecture
+ OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ endif()
+
+ # Source: (optional)
+ # in case several packages are constructed from a unique source
+ # (multipackaging), the source may be indicated as well.
+ # The source might contain a version if the generated package
+ # version is different from the source version
+ if(NOT CPACK_DEBIAN_PACKAGE_SOURCE)
+ set(CPACK_DEBIAN_PACKAGE_SOURCE "")
+ endif()
+
+ # have a look at get_property(result GLOBAL PROPERTY ENABLED_FEATURES),
+ # this returns the successful find_package() calls, maybe this can help
+ # Depends:
+ # You should set: DEBIAN_PACKAGE_DEPENDS
+ # TODO: automate 'objdump -p | grep NEEDED'
+
+ # if per-component variable, overrides the global CPACK_DEBIAN_PACKAGE_${variable_type_}
+ # automatic dependency discovery will be performed afterwards.
+ if(CPACK_DEB_PACKAGE_COMPONENT)
+ foreach(value_type_ IN ITEMS DEPENDS RECOMMENDS SUGGESTS PREDEPENDS ENHANCES BREAKS CONFLICTS PROVIDES REPLACES SOURCE SECTION PRIORITY NAME)
+ set(_component_var "CPACK_DEBIAN_${_local_component_name}_PACKAGE_${value_type_}")
+
+ # if set, overrides the global variable
+ if(DEFINED ${_component_var})
+ set(CPACK_DEBIAN_PACKAGE_${value_type_} "${${_component_var}}")
+ if(CPACK_DEBIAN_PACKAGE_DEBUG)
+ message("CPackDeb Debug: component '${_local_component_name}' ${value_type_} "
+ "value set to '${CPACK_DEBIAN_PACKAGE_${value_type_}}'")
+ endif()
+ endif()
+ endforeach()
+
+ if(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS)
+ unset(COMPONENT_DEPENDS)
+ foreach(_PACK IN LISTS CPACK_COMPONENT_${_local_component_name}_DEPENDS)
+ get_component_package_name(_PACK_NAME "${_PACK}")
+ list(PREPEND COMPONENT_DEPENDS "${_PACK_NAME} (= ${CPACK_DEBIAN_PACKAGE_VERSION})")
+ endforeach()
+ list(JOIN COMPONENT_DEPENDS ", " COMPONENT_DEPENDS)
+ if(COMPONENT_DEPENDS)
+ list(PREPEND CPACK_DEBIAN_PACKAGE_DEPENDS ${COMPONENT_DEPENDS})
+ list(JOIN CPACK_DEBIAN_PACKAGE_DEPENDS ", " CPACK_DEBIAN_PACKAGE_DEPENDS)
+ endif()
+ endif()
+ endif()
+
+ # at this point, the CPACK_DEBIAN_PACKAGE_DEPENDS is properly set
+ # to the minimal dependency of the package
+ # Append automatically discovered dependencies .
+ if(CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS)
+ list(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS})
+ list(JOIN CPACK_DEBIAN_PACKAGE_DEPENDS ", " CPACK_DEBIAN_PACKAGE_DEPENDS)
+ endif()
+
+ if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
+ message(STATUS "CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.")
+ endif()
+
+ # Maintainer: (mandatory)
+ if(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER)
+ if(NOT CPACK_PACKAGE_CONTACT)
+ message(FATAL_ERROR "CPackDeb: Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER")
+ endif()
+ set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
+ endif()
+
+ # Description: (mandatory)
+ # Try package description first
+ if(CPACK_USED_DEFAULT_PACKAGE_DESCRIPTION_FILE)
+ set(_desc_fallback)
+ else()
+ set(_desc_fallback "CPACK_PACKAGE_DESCRIPTION")
+ endif()
+ if(CPACK_DEB_PACKAGE_COMPONENT)
+ cpack_deb_variable_fallback("CPACK_DEBIAN_PACKAGE_DESCRIPTION"
+ "CPACK_DEBIAN_${_local_component_name}_DESCRIPTION"
+ "CPACK_COMPONENT_${_local_component_name}_DESCRIPTION")
+ else()
+ cpack_deb_variable_fallback("CPACK_DEBIAN_PACKAGE_DESCRIPTION"
+ "CPACK_DEBIAN_PACKAGE_DESCRIPTION"
+ ${_desc_fallback})
+ endif()
+
+ # Still no description? ... and description file has set ...
+ if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION
+ AND CPACK_PACKAGE_DESCRIPTION_FILE
+ AND NOT CPACK_PACKAGE_DESCRIPTION_FILE STREQUAL CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE)
+ # Read `CPACK_PACKAGE_DESCRIPTION_FILE` then...
+ file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_DEBIAN_PACKAGE_DESCRIPTION)
+ endif()
+
+ # Still no description? #2
+ if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION)
+ # Try to get `CPACK_PACKAGE_DESCRIPTION_SUMMARY` as the last hope
+ if(CPACK_PACKAGE_DESCRIPTION_SUMMARY)
+ set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
+ else()
+ # Giving up! Report an error...
+ set(_description_failure_message
+ "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION")
+ if(CPACK_DEB_PACKAGE_COMPONENT)
+ string(APPEND _description_failure_message
+ " or CPACK_DEBIAN_${_local_component_name}_DESCRIPTION")
+ endif()
+ message(FATAL_ERROR _description_failure_message)
+ endif()
+
+ # Ok, description has set. According to the `Debian Policy Manual`_ the frist
+ # line is a pacakge summary. Try to get it as well...
+ # See also: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description
+ elseif(CPACK_PACKAGE_DESCRIPTION_SUMMARY AND
+ NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY STREQUAL CPACK_DEFAULT_PACKAGE_DESCRIPTION_SUMMARY)
+ # Merge summary w/ the detailed description
+ string(PREPEND CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}\n")
+ endif()
+ # assert(CPACK_DEBIAN_PACKAGE_DESCRIPTION)
+
+ # Make sure description is properly formatted
+ cpack_deb_format_package_description(
+ "${CPACK_DEBIAN_PACKAGE_DESCRIPTION}"
+ CPACK_DEBIAN_PACKAGE_DESCRIPTION
+ )
+
+ # Homepage: (optional)
+ if(NOT CPACK_DEBIAN_PACKAGE_HOMEPAGE AND CMAKE_PROJECT_HOMEPAGE_URL)
+ set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CMAKE_PROJECT_HOMEPAGE_URL}")
+ endif()
+
+ # Section: (recommended)
+ if(NOT CPACK_DEBIAN_PACKAGE_SECTION)
+ set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
+ endif()
+
+ # Priority: (recommended)
+ if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
+ set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
+ endif()
+
+ if(CPACK_DEBIAN_ARCHIVE_TYPE)
+ if(CPACK_DEBIAN_ARCHIVE_TYPE STREQUAL "paxr")
+ message(DEPRECATION "CPACK_DEBIAN_ARCHIVE_TYPE set to old and invalid "
+ "type 'paxr', mapping to 'gnutar'")
+ set(CPACK_DEBIAN_ARCHIVE_TYPE "gnutar")
+ elseif(NOT CPACK_DEBIAN_ARCHIVE_TYPE STREQUAL "gnutar")
+ message(FATAL_ERROR "CPACK_DEBIAN_ARCHIVE_TYPE set to unsupported"
+ "type ${CPACK_DEBIAN_ARCHIVE_TYPE}")
+ endif()
+ else()
+ set(CPACK_DEBIAN_ARCHIVE_TYPE "gnutar")
+ endif()
+
+ # Compression: (recommended)
+ if(NOT CPACK_DEBIAN_COMPRESSION_TYPE)
+ set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip")
+ endif()
+
+ # Recommends:
+ # You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS
+
+ # Suggests:
+ # You should set: CPACK_DEBIAN_PACKAGE_SUGGESTS
+
+ # CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
+ # This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive)
+ # Typical examples are:
+ # - conffiles
+ # - postinst
+ # - postrm
+ # - prerm
+ # Usage:
+ # set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
+ # "${CMAKE_CURRENT_SOURCE_DIR}/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
+
+ # Are we packaging components ?
+ if(CPACK_DEB_PACKAGE_COMPONENT)
+ # override values with per component version if set
+ foreach(VAR_NAME_ IN ITEMS PACKAGE_CONTROL_EXTRA PACKAGE_CONTROL_STRICT_PERMISSION)
+ if(CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_})
+ set(CPACK_DEBIAN_${VAR_NAME_} "${CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_}}")
+ endif()
+ endforeach()
+ get_component_package_name(CPACK_DEBIAN_PACKAGE_NAME ${_local_component_name})
+ endif()
+
+ if(NOT CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY)
+ set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY "=")
+ endif()
+
+ unset(CPACK_DEBIAN_PACKAGE_SHLIBS_LIST)
+
+ if(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS)
+ if(READELF_EXECUTABLE)
+ foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES)
+ extract_so_info("${_FILE}" libname soversion)
+ if(libname AND DEFINED soversion)
+ list(APPEND CPACK_DEBIAN_PACKAGE_SHLIBS_LIST
+ "${libname} ${soversion} ${CPACK_DEBIAN_PACKAGE_NAME} (${CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY} ${CPACK_DEBIAN_PACKAGE_VERSION})")
+ else()
+ message(AUTHOR_WARNING "Shared library '${_FILE}' is missing soname or soversion. Library will not be added to DEBIAN/shlibs control file.")
+ endif()
+ endforeach()
+ list(JOIN CPACK_DEBIAN_PACKAGE_SHLIBS_LIST "\n" CPACK_DEBIAN_PACKAGE_SHLIBS_LIST)
+ else()
+ message(FATAL_ERROR "Readelf utility is not available. CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS option is not available.")
+ endif()
+ endif()
+
+ # add ldconfig call in default postrm and postint
+ set(CPACK_ADD_LDCONFIG_CALL 0)
+ foreach(_FILE IN LISTS CPACK_DEB_SHARED_OBJECT_FILES)
+ get_filename_component(_DIR ${_FILE} DIRECTORY)
+ # all files in CPACK_DEB_SHARED_OBJECT_FILES have dot at the beginning
+ if(_DIR STREQUAL "./lib" OR _DIR STREQUAL "./usr/lib")
+ set(CPACK_ADD_LDCONFIG_CALL 1)
+ endif()
+ endforeach()
+
+ if(CPACK_ADD_LDCONFIG_CALL)
+ set(CPACK_DEBIAN_GENERATE_POSTINST 1)
+ set(CPACK_DEBIAN_GENERATE_POSTRM 1)
+ foreach(f IN LISTS PACKAGE_CONTROL_EXTRA)
+ get_filename_component(n "${f}" NAME)
+ if(n STREQUAL "postinst")
+ set(CPACK_DEBIAN_GENERATE_POSTINST 0)
+ endif()
+ if(n STREQUAL "postrm")
+ set(CPACK_DEBIAN_GENERATE_POSTRM 0)
+ endif()
+ endforeach()
+ else()
+ set(CPACK_DEBIAN_GENERATE_POSTINST 0)
+ set(CPACK_DEBIAN_GENERATE_POSTRM 0)
+ endif()
+
+ cpack_deb_variable_fallback("CPACK_DEBIAN_FILE_NAME"
+ "CPACK_DEBIAN_${_local_component_name}_FILE_NAME"
+ "CPACK_DEBIAN_FILE_NAME")
+ if(CPACK_DEBIAN_FILE_NAME)
+ if(CPACK_DEBIAN_FILE_NAME STREQUAL "DEB-DEFAULT")
+ # Patch package file name to be in correct debian format:
+ # <foo>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
+ set(CPACK_OUTPUT_FILE_NAME
+ "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
+ set(CPACK_DBGSYM_OUTPUT_FILE_NAME
+ "${CPACK_DEBIAN_PACKAGE_NAME}-dbgsym_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.ddeb")
+ else()
+ if(NOT CPACK_DEBIAN_FILE_NAME MATCHES ".*\\.(deb|ipk)")
+ message(FATAL_ERROR "'${CPACK_DEBIAN_FILE_NAME}' is not a valid DEB package file name as it must end with '.deb' or '.ipk'!")
+ endif()
+
+ set(CPACK_OUTPUT_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}")
+ string(REGEX REPLACE "\.deb$" "-dbgsym.ddeb" CPACK_DBGSYM_OUTPUT_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}")
+ endif()
+
+ set(CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_OUTPUT_FILE_NAME}")
+ get_filename_component(BINARY_DIR "${CPACK_OUTPUT_FILE_PATH}" DIRECTORY)
+ set(CPACK_OUTPUT_FILE_PATH "${BINARY_DIR}/${CPACK_OUTPUT_FILE_NAME}")
+ else()
+ # back compatibility - don't change the name
+ string(REGEX REPLACE "\.deb$" "-dbgsym.ddeb" CPACK_DBGSYM_OUTPUT_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}")
+ endif()
+
+ # Print out some debug information if we were asked for that
+ if(CPACK_DEBIAN_PACKAGE_DEBUG)
+ message("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY = '${CPACK_TOPLEVEL_DIRECTORY}'")
+ message("CPackDeb:Debug: CPACK_TOPLEVEL_TAG = '${CPACK_TOPLEVEL_TAG}'")
+ message("CPackDeb:Debug: CPACK_TEMPORARY_DIRECTORY = '${CPACK_TEMPORARY_DIRECTORY}'")
+ message("CPackDeb:Debug: CPACK_OUTPUT_FILE_NAME = '${CPACK_OUTPUT_FILE_NAME}'")
+ message("CPackDeb:Debug: CPACK_OUTPUT_FILE_PATH = '${CPACK_OUTPUT_FILE_PATH}'")
+ message("CPackDeb:Debug: CPACK_PACKAGE_FILE_NAME = '${CPACK_PACKAGE_FILE_NAME}'")
+ message("CPackDeb:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = '${CPACK_PACKAGE_INSTALL_DIRECTORY}'")
+ message("CPackDeb:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = '${CPACK_TEMPORARY_PACKAGE_FILE_NAME}'")
+ message("CPackDeb:Debug: CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION = '${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}'")
+ message("CPackDeb:Debug: CPACK_DEBIAN_PACKAGE_SOURCE = '${CPACK_DEBIAN_PACKAGE_SOURCE}'")
+ endif()
+
+ # For debian source packages:
+ # debian/control
+ # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-sourcecontrolfiles
+
+ # .dsc
+ # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-debiansourcecontrolfiles
+
+ # Builds-Depends:
+ #if(NOT CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS)
+ # set(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS
+ # "debhelper (>> 5.0.0), libncurses5-dev, tcl8.4"
+ # )
+ #endif()
+
+ # move variables to parent scope so that they may be used to create debian package
+ set(GEN_CPACK_OUTPUT_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}" PARENT_SCOPE)
+ set(GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME "${CPACK_TEMPORARY_PACKAGE_FILE_NAME}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_DEBIAN_PACKAGE_VERSION}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_SECTION "${CPACK_DEBIAN_PACKAGE_SECTION}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_PRIORITY "${CPACK_DEBIAN_PACKAGE_PRIORITY}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_DEBIAN_PACKAGE_MAINTAINER}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_DEBIAN_PACKAGE_DESCRIPTION}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_ARCHIVE_TYPE "${CPACK_DEBIAN_ARCHIVE_TYPE}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_COMPRESSION_TYPE "${CPACK_DEBIAN_COMPRESSION_TYPE}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS "${CPACK_DEBIAN_PACKAGE_RECOMMENDS}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS "${CPACK_DEBIAN_PACKAGE_SUGGESTS}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_DEBIAN_PACKAGE_HOMEPAGE}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS "${CPACK_DEBIAN_PACKAGE_PREDEPENDS}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_ENHANCES "${CPACK_DEBIAN_PACKAGE_ENHANCES}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_BREAKS "${CPACK_DEBIAN_PACKAGE_BREAKS}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS "${CPACK_DEBIAN_PACKAGE_CONFLICTS}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_PROVIDES "${CPACK_DEBIAN_PACKAGE_PROVIDES}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_REPLACES "${CPACK_DEBIAN_PACKAGE_REPLACES}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_SHLIBS "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION
+ "${CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_PACKAGE_SOURCE
+ "${CPACK_DEBIAN_PACKAGE_SOURCE}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_GENERATE_POSTINST "${CPACK_DEBIAN_GENERATE_POSTINST}" PARENT_SCOPE)
+ set(GEN_CPACK_DEBIAN_GENERATE_POSTRM "${CPACK_DEBIAN_GENERATE_POSTRM}" PARENT_SCOPE)
+ set(GEN_WDIR "${WDIR}" PARENT_SCOPE)
+
+ set(GEN_CPACK_DEBIAN_DEBUGINFO_PACKAGE "${CPACK_DEBIAN_DEBUGINFO_PACKAGE}" PARENT_SCOPE)
+ if(BUILD_IDS)
+ set(GEN_DBGSYMDIR "${DBGSYMDIR}" PARENT_SCOPE)
+ set(GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME "${CPACK_DBGSYM_OUTPUT_FILE_NAME}" PARENT_SCOPE)
+ list(JOIN BUILD_IDS " " BUILD_IDS)
+ set(GEN_BUILD_IDS "${BUILD_IDS}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+cpack_deb_prepare_package_vars()
+
+cmake_policy(POP)
diff --git a/Modules/Internal/CPack/CPackExternal.cmake b/Modules/Internal/CPack/CPackExternal.cmake
new file mode 100644
index 000000000..e4d055a2d
--- /dev/null
+++ b/Modules/Internal/CPack/CPackExternal.cmake
@@ -0,0 +1,53 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+if(NOT "${CPACK_EXTERNAL_REQUESTED_VERSIONS}" STREQUAL "")
+ unset(_found_major)
+
+ foreach(_req_version IN LISTS CPACK_EXTERNAL_REQUESTED_VERSIONS)
+ if(_req_version MATCHES "^([0-9]+)\\.([0-9]+)$")
+ set(_req_major "${CMAKE_MATCH_1}")
+ set(_req_minor "${CMAKE_MATCH_2}")
+
+ foreach(_known_version IN LISTS CPACK_EXTERNAL_KNOWN_VERSIONS)
+ string(REGEX MATCH
+ "^([0-9]+)\\.([0-9]+)$"
+ _known_version_dummy
+ "${_known_version}"
+ )
+
+ set(_known_major "${CMAKE_MATCH_1}")
+ set(_known_minor "${CMAKE_MATCH_2}")
+
+ if(_req_major EQUAL _known_major AND NOT _known_minor LESS _req_minor)
+ set(_found_major "${_known_major}")
+ set(_found_minor "${_known_minor}")
+ break()
+ endif()
+ endforeach()
+
+ if(DEFINED _found_major)
+ break()
+ endif()
+ endif()
+ endforeach()
+
+ if(DEFINED _found_major)
+ set(CPACK_EXTERNAL_SELECTED_MAJOR "${_found_major}")
+ set(CPACK_EXTERNAL_SELECTED_MINOR "${_found_minor}")
+ set(CPACK_EXTERNAL_SELECTED_VERSION "${_found_major}.${_found_minor}")
+ else()
+ message(FATAL_ERROR
+ "Could not find a suitable version in CPACK_EXTERNAL_REQUESTED_VERSIONS"
+ )
+ endif()
+else()
+ list(GET CPACK_EXTERNAL_KNOWN_VERSIONS 0 CPACK_EXTERNAL_SELECTED_VERSION)
+ string(REGEX MATCH
+ "^([0-9]+)\\.([0-9]+)$"
+ _dummy
+ "${CPACK_EXTERNAL_SELECTED_VERSION}"
+ )
+ set(CPACK_EXTERNAL_SELECTED_MAJOR "${CMAKE_MATCH_1}")
+ set(CPACK_EXTERNAL_SELECTED_MINOR "${CMAKE_MATCH_2}")
+endif()
diff --git a/Modules/Internal/CPack/CPackFreeBSD.cmake b/Modules/Internal/CPack/CPackFreeBSD.cmake
new file mode 100644
index 000000000..16f906cac
--- /dev/null
+++ b/Modules/Internal/CPack/CPackFreeBSD.cmake
@@ -0,0 +1,107 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+if(CMAKE_BINARY_DIR)
+ message(FATAL_ERROR "CPackFreeBSD.cmake may only be used by CPack internally.")
+endif()
+
+if(NOT UNIX)
+ message(FATAL_ERROR "CPackFreeBSD.cmake may only be used under UNIX.")
+endif()
+
+
+###
+#
+# These bits are copied from the Debian packaging file; slightly modified.
+# They are used for filling in FreeBSD-packaging variables that can take
+# on values from elsewhere -- e.g. the package description may as well be
+# copied from Debian.
+#
+function(_cpack_freebsd_fallback_var OUTPUT_VAR_NAME)
+ set(FALLBACK_VAR_NAMES ${ARGN})
+
+ set(VALUE "${${OUTPUT_VAR_NAME}}")
+ if(VALUE)
+ return()
+ endif()
+
+ foreach(variable_name IN LISTS FALLBACK_VAR_NAMES)
+ if(${variable_name})
+ set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE)
+ set(VALUE "${${variable_name}}")
+ break()
+ endif()
+ endforeach()
+ if(NOT VALUE)
+ message(WARNING "Variable ${OUTPUT_VAR_NAME} could not be given a fallback value from any variable ${FALLBACK_VAR_NAMES}.")
+ endif()
+endfunction()
+
+function(check_required_var VAR_NAME)
+ if(NOT ${VAR_NAME})
+ message(FATAL_ERROR "Variable ${VAR_NAME} is not set.")
+ endif()
+endfunction()
+
+set(_cpack_freebsd_fallback_origin "misc/bogus")
+
+_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_NAME"
+ "CPACK_PACKAGE_NAME"
+ "CMAKE_PROJECT_NAME"
+ )
+
+set(_cpack_freebsd_fallback_www "http://example.com/?pkg=${CPACK_FREEBSD_PACKAGE_NAME}")
+
+_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_COMMENT"
+ "CPACK_PACKAGE_DESCRIPTION_SUMMARY"
+ )
+
+# TODO: maybe read the PACKAGE_DESCRIPTION file for the longer
+# FreeBSD pkg-descr?
+_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_DESCRIPTION"
+ "CPACK_DEBIAN_PACKAGE_DESCRIPTION"
+ "CPACK_PACKAGE_DESCRIPTION_SUMMARY"
+ "PACKAGE_DESCRIPTION"
+ )
+
+# There's really only one homepage for a project, so
+# re-use the Debian setting if it's there.
+_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_WWW"
+ "CMAKE_PROJECT_HOMEPAGE_URL"
+ "CPACK_DEBIAN_PACKAGE_HOMEPAGE"
+ "_cpack_freebsd_fallback_www"
+ )
+
+_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_VERSION"
+ "CMAKE_PROJECT_VERSION"
+ "${CMAKE_PROJECT_NAME}_VERSION"
+ "PROJECT_VERSION"
+ "CPACK_PACKAGE_VERSION"
+ "CPACK_PACKAGE_VERSION"
+ )
+
+_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_MAINTAINER"
+ "CPACK_PACKAGE_CONTACT"
+ )
+
+_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_LICENSE"
+ "CPACK_RPM_PACKAGE_LICENSE"
+ )
+
+_cpack_freebsd_fallback_var("CPACK_FREEBSD_PACKAGE_ORIGIN"
+ "_cpack_freebsd_fallback_origin"
+ )
+
+if(NOT CPACK_FREEBSD_PACKAGE_CATEGORIES)
+ string(REGEX REPLACE "/.*" "" CPACK_FREEBSD_PACKAGE_CATEGORIES ${CPACK_FREEBSD_PACKAGE_ORIGIN})
+endif()
+
+check_required_var("CPACK_FREEBSD_PACKAGE_NAME")
+check_required_var("CPACK_FREEBSD_PACKAGE_ORIGIN")
+check_required_var("CPACK_FREEBSD_PACKAGE_VERSION")
+check_required_var("CPACK_FREEBSD_PACKAGE_MAINTAINER")
+check_required_var("CPACK_FREEBSD_PACKAGE_COMMENT")
+check_required_var("CPACK_FREEBSD_PACKAGE_DESCRIPTION")
+check_required_var("CPACK_FREEBSD_PACKAGE_WWW")
+check_required_var("CPACK_FREEBSD_PACKAGE_LICENSE")
diff --git a/Modules/Internal/CPack/CPackNuGet.cmake b/Modules/Internal/CPack/CPackNuGet.cmake
new file mode 100644
index 000000000..82053b221
--- /dev/null
+++ b/Modules/Internal/CPack/CPackNuGet.cmake
@@ -0,0 +1,363 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# Author: Alex Turbov
+
+if(CMAKE_BINARY_DIR)
+ message(FATAL_ERROR "CPackNuGet.cmake may only be used by CPack internally.")
+endif()
+
+function(_cpack_nuget_debug)
+ if(CPACK_NUGET_PACKAGE_DEBUG)
+ message("CPackNuGet:Debug: " ${ARGN})
+ endif()
+endfunction()
+
+function(_cpack_nuget_debug_var NAME)
+ if(CPACK_NUGET_PACKAGE_DEBUG)
+ message("CPackNuGet:Debug: ${NAME}=`${${NAME}}`")
+ endif()
+endfunction()
+
+function(_cpack_nuget_variable_fallback OUTPUT_VAR_NAME NUGET_VAR_NAME)
+ if(ARGN)
+ list(JOIN ARGN "`, `" _va_args)
+ set(_va_args ", ARGN: `${_va_args}`")
+ endif()
+ _cpack_nuget_debug(
+ "_cpack_nuget_variable_fallback: "
+ "OUTPUT_VAR_NAME=`${OUTPUT_VAR_NAME}`, "
+ "NUGET_VAR_NAME=`${NUGET_VAR_NAME}`"
+ "${_va_args}"
+ )
+
+ set(_options USE_CDATA)
+ set(_one_value_args LIST_GLUE)
+ set(_multi_value_args FALLBACK_VARS)
+ cmake_parse_arguments(PARSE_ARGV 0 _args "${_options}" "${_one_value_args}" "${_multi_value_args}")
+
+ if(CPACK_NUGET_PACKAGE_COMPONENT)
+ string(
+ TOUPPER "${CPACK_NUGET_PACKAGE_COMPONENT}"
+ CPACK_NUGET_PACKAGE_COMPONENT_UPPER
+ )
+ endif()
+
+ if(CPACK_NUGET_PACKAGE_COMPONENT
+ AND CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT}_PACKAGE_${NUGET_VAR_NAME}
+ )
+ set(
+ _result
+ "${CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT}_PACKAGE_${NUGET_VAR_NAME}}"
+ )
+ _cpack_nuget_debug(
+ " CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT}_PACKAGE_${NUGET_VAR_NAME}: "
+ "OUTPUT_VAR_NAME->${OUTPUT_VAR_NAME}=`${_result}`"
+ )
+
+ elseif(CPACK_NUGET_PACKAGE_COMPONENT_UPPER
+ AND CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_PACKAGE_${NUGET_VAR_NAME}
+ )
+ set(
+ _result
+ "${CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_PACKAGE_${NUGET_VAR_NAME}}"
+ )
+ _cpack_nuget_debug(
+ " CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_PACKAGE_${NUGET_VAR_NAME}: "
+ "OUTPUT_VAR_NAME->${OUTPUT_VAR_NAME}=`${_result}`"
+ )
+
+ elseif(CPACK_NUGET_PACKAGE_${NUGET_VAR_NAME})
+ set(_result "${CPACK_NUGET_PACKAGE_${NUGET_VAR_NAME}}")
+ _cpack_nuget_debug(
+ " CPACK_NUGET_PACKAGE_${NUGET_VAR_NAME}: "
+ "OUTPUT_VAR_NAME->${OUTPUT_VAR_NAME}=`${_result}`"
+ )
+
+ else()
+ foreach(_var IN LISTS _args_FALLBACK_VARS)
+ _cpack_nuget_debug(" Fallback: ${_var} ...")
+ if(${_var})
+ _cpack_nuget_debug(" ${_var}=`${${_var}}`")
+ set(_result "${${_var}}")
+ _cpack_nuget_debug(
+ " ${_var}: OUTPUT_VAR_NAME->${OUTPUT_VAR_NAME}=`${_result}`"
+ )
+ break()
+ endif()
+ endforeach()
+ endif()
+
+ if(_result)
+ if(_args_USE_CDATA)
+ set(_value_before "<![CDATA[")
+ set(_value_after "]]>")
+ endif()
+
+ list(LENGTH _result _result_len)
+ if(_result_len GREATER 1 AND _args_LIST_GLUE)
+ list(JOIN _result "${_args_LIST_GLUE}" _result)
+ endif()
+
+ set(${OUTPUT_VAR_NAME} "${_value_before}${_result}${_value_after}" PARENT_SCOPE)
+ endif()
+
+endfunction()
+
+function(_cpack_nuget_variable_fallback_and_wrap_into_element ELEMENT NUGET_VAR_NAME)
+ set(_options)
+ set(_one_value_args)
+ set(_multi_value_args FALLBACK_VARS)
+ cmake_parse_arguments(PARSE_ARGV 0 _args "${_options}" "${_one_value_args}" "${_multi_value_args}")
+
+ _cpack_nuget_variable_fallback(_value ${NUGET_VAR_NAME} ${ARGN} USE_CDATA)
+
+ if(_value)
+ string(TOUPPER "${ELEMENT}" _ELEMENT_UP)
+ set(
+ _CPACK_NUGET_${_ELEMENT_UP}_TAG
+ "<${ELEMENT}>${_value}</${ELEMENT}>"
+ PARENT_SCOPE
+ )
+ endif()
+endfunction()
+
+# Print some debug info
+_cpack_nuget_debug("---[CPack NuGet Input Variables]---")
+_cpack_nuget_debug_var(CPACK_PACKAGE_NAME)
+_cpack_nuget_debug_var(CPACK_PACKAGE_VERSION)
+_cpack_nuget_debug_var(CPACK_TOPLEVEL_TAG)
+_cpack_nuget_debug_var(CPACK_TOPLEVEL_DIRECTORY)
+_cpack_nuget_debug_var(CPACK_TEMPORARY_DIRECTORY)
+_cpack_nuget_debug_var(CPACK_NUGET_GROUPS)
+if(CPACK_NUGET_GROUPS)
+ foreach(_group IN LISTS CPACK_NUGET_GROUPS)
+ string(MAKE_C_IDENTIFIER "${_group}" _group_up)
+ string(TOUPPER "${_group_up}" _group_up)
+ _cpack_nuget_debug_var(CPACK_NUGET_${_group_up}_GROUP_COMPONENTS)
+ endforeach()
+endif()
+_cpack_nuget_debug_var(CPACK_NUGET_COMPONENTS)
+_cpack_nuget_debug_var(CPACK_NUGET_ALL_IN_ONE)
+_cpack_nuget_debug_var(CPACK_NUGET_ORDINAL_MONOLITIC)
+_cpack_nuget_debug("-----------------------------------")
+
+function(_cpack_nuget_render_spec)
+ # Make a variable w/ upper-cased component name
+ if(CPACK_NUGET_PACKAGE_COMPONENT)
+ string(TOUPPER "${CPACK_NUGET_PACKAGE_COMPONENT}" CPACK_NUGET_PACKAGE_COMPONENT_UPPER)
+ endif()
+
+ # Set mandatory variables (not wrapped into XML elements)
+ # https://docs.microsoft.com/en-us/nuget/reference/nuspec#required-metadata-elements
+ if(CPACK_NUGET_PACKAGE_COMPONENT)
+ if(CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME)
+ set(
+ CPACK_NUGET_PACKAGE_NAME
+ "${CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME}"
+ )
+ elseif(NOT CPACK_NUGET_PACKAGE_COMPONENT STREQUAL "Unspecified")
+ set(
+ CPACK_NUGET_PACKAGE_NAME
+ "${CPACK_PACKAGE_NAME}.${CPACK_NUGET_PACKAGE_COMPONENT}"
+ )
+ else()
+ set(CPACK_NUGET_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
+ endif()
+ elseif(NOT CPACK_NUGET_PACKAGE_NAME)
+ set(CPACK_NUGET_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
+ endif()
+
+ _cpack_nuget_variable_fallback(
+ CPACK_NUGET_PACKAGE_VERSION VERSION
+ FALLBACK_VARS
+ CPACK_PACKAGE_VERSION
+ )
+ _cpack_nuget_variable_fallback(
+ CPACK_NUGET_PACKAGE_DESCRIPTION DESCRIPTION
+ FALLBACK_VARS
+ CPACK_COMPONENT_${CPACK_NUGET_PACKAGE_COMPONENT}_DESCRIPTION
+ CPACK_COMPONENT_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_DESCRIPTION
+ CPACK_COMPONENT_GROUP_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_DESCRIPTION
+ CPACK_PACKAGE_DESCRIPTION
+ USE_CDATA
+ )
+ _cpack_nuget_variable_fallback(
+ CPACK_NUGET_PACKAGE_AUTHORS AUTHORS
+ FALLBACK_VARS
+ CPACK_PACKAGE_VENDOR
+ USE_CDATA
+ LIST_GLUE ","
+ )
+
+ # Set optional variables (wrapped into XML elements)
+ # https://docs.microsoft.com/en-us/nuget/reference/nuspec#optional-metadata-elements
+ _cpack_nuget_variable_fallback_and_wrap_into_element(
+ title
+ TITLE
+ FALLBACK_VARS
+ CPACK_COMPONENT_${CPACK_NUGET_PACKAGE_COMPONENT}_DISPLAY_NAME
+ CPACK_COMPONENT_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_DISPLAY_NAME
+ CPACK_COMPONENT_GROUP_${CPACK_NUGET_PACKAGE_COMPONENT_UPPER}_DISPLAY_NAME
+ )
+ _cpack_nuget_variable_fallback_and_wrap_into_element(owners OWNERS LIST_GLUE ",")
+ _cpack_nuget_variable_fallback_and_wrap_into_element(
+ projectUrl
+ HOMEPAGE_URL
+ FALLBACK_VARS
+ CPACK_PACKAGE_HOMEPAGE_URL
+ )
+ _cpack_nuget_variable_fallback_and_wrap_into_element(licenseUrl LICENSEURL)
+ _cpack_nuget_variable_fallback_and_wrap_into_element(iconUrl ICONURL)
+ _cpack_nuget_variable_fallback_and_wrap_into_element(
+ summary DESCRIPTION_SUMMARY
+ FALLBACK_VARS
+ CPACK_PACKAGE_DESCRIPTION_SUMMARY
+ )
+ if(CPACK_NUGET_PACKAGE_REQUIRE_LICENSE_ACCEPTANCE)
+ set(
+ _CPACK_NUGET_REQUIRELICENSEACCEPTANCE_TAG
+ "<requireLicenseAcceptance>true</requireLicenseAcceptance>"
+ )
+ endif()
+ _cpack_nuget_variable_fallback_and_wrap_into_element(releaseNotes RELEASE_NOTES)
+ _cpack_nuget_variable_fallback_and_wrap_into_element(copyright COPYRIGHT)
+ _cpack_nuget_variable_fallback_and_wrap_into_element(tags TAGS LIST_GLUE " ")
+
+ # Handle dependencies
+ _cpack_nuget_variable_fallback(_deps DEPENDENCIES)
+ set(_collected_deps)
+ foreach(_dep IN LISTS _deps)
+ _cpack_nuget_debug(" checking dependency `${_dep}`")
+
+ string(MAKE_C_IDENTIFIER "${_dep}" _dep_id)
+
+ _cpack_nuget_variable_fallback(_ver DEPENDENCIES_${_dep_id}_VERSION)
+
+ if(NOT _ver)
+ string(TOUPPER "${_dep_id}" _dep_id)
+ _cpack_nuget_variable_fallback(_ver DEPENDENCIES_${_dep_id}_VERSION)
+ endif()
+
+ if(_ver)
+ _cpack_nuget_debug(" got `${_dep}` dependency version ${_ver}")
+ list(APPEND _collected_deps "<dependency id=\"${_dep}\" version=\"${_ver}\" />")
+ endif()
+ endforeach()
+
+ # Render deps into the variable
+ if(_collected_deps)
+ set(_CPACK_NUGET_DEPENDENCIES_TAG "<dependencies>\n")
+ foreach(_line IN LISTS _collected_deps)
+ string(
+ APPEND _CPACK_NUGET_DEPENDENCIES_TAG
+ " ${_line}\n"
+ )
+ endforeach()
+ string(APPEND _CPACK_NUGET_DEPENDENCIES_TAG " </dependencies>")
+ endif()
+
+ # Render the spec file
+ # NOTE The spec filename doesn't matter. Being included into a package,
+ # NuGet will name it properly.
+ _cpack_nuget_debug("Rendering `${CPACK_TEMPORARY_DIRECTORY}/CPack.NuGet.nuspec` file...")
+ configure_file(
+ "${CMAKE_ROOT}/Modules/Internal/CPack/CPack.NuGet.nuspec.in"
+ "${CPACK_TEMPORARY_DIRECTORY}/CPack.NuGet.nuspec"
+ @ONLY
+ )
+endfunction()
+
+function(_cpack_nuget_make_files_tag)
+ set(_files)
+ foreach(_comp IN LISTS ARGN)
+ string(APPEND _files " <file src=\"${_comp}\\**\" target=\".\" />\n")
+ endforeach()
+ set(_CPACK_NUGET_FILES_TAG "<files>\n${_files} </files>" PARENT_SCOPE)
+endfunction()
+
+find_program(NUGET_EXECUTABLE nuget)
+_cpack_nuget_debug_var(NUGET_EXECUTABLE)
+if(NOT NUGET_EXECUTABLE)
+ message(FATAL_ERROR "NuGet executable not found")
+endif()
+
+# Add details for debug run
+if(CPACK_NUGET_PACKAGE_DEBUG)
+ list(APPEND CPACK_NUGET_PACK_ADDITIONAL_OPTIONS "-Verbosity" "detailed")
+endif()
+
+# Case one: ordinal all-in-one package
+if(CPACK_NUGET_ORDINAL_MONOLITIC)
+ # This variable `CPACK_NUGET_ALL_IN_ONE` set by C++ code:
+ # Meaning to pack all installed files into a single package
+ _cpack_nuget_debug("---[Making an ordinal monolitic package]---")
+ _cpack_nuget_render_spec()
+ execute_process(
+ COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS}
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ )
+
+elseif(CPACK_NUGET_ALL_IN_ONE)
+ # This variable `CPACK_NUGET_ALL_IN_ONE` set by C++ code:
+ # Meaning to pack all installed components into a single package
+ _cpack_nuget_debug("---[Making a monolitic package from installed components]---")
+
+ # Prepare the `files` element which include files from several components
+ _cpack_nuget_make_files_tag(${CPACK_NUGET_COMPONENTS})
+ _cpack_nuget_render_spec()
+ execute_process(
+ COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS}
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ )
+
+else()
+ # Is there any grouped component?
+ if(CPACK_NUGET_GROUPS)
+ _cpack_nuget_debug("---[Making grouped component(s) package(s)]---")
+ foreach(_group IN LISTS CPACK_NUGET_GROUPS)
+ _cpack_nuget_debug("Starting to make the package for group `${_group}`")
+ string(MAKE_C_IDENTIFIER "${_group}" _group_up)
+ string(TOUPPER "${_group_up}" _group_up)
+
+ # Render a spec file which includes all components in the current group
+ unset(_CPACK_NUGET_FILES_TAG)
+ _cpack_nuget_make_files_tag(${CPACK_NUGET_${_group_up}_GROUP_COMPONENTS})
+ # Temporary set `CPACK_NUGET_PACKAGE_COMPONENT` to the group name
+ # to properly collect various per group settings
+ set(CPACK_NUGET_PACKAGE_COMPONENT ${_group})
+ _cpack_nuget_render_spec()
+ unset(CPACK_NUGET_PACKAGE_COMPONENT)
+ execute_process(
+ COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS}
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ )
+ endforeach()
+ endif()
+ # Is there any single component package needed?
+ if(CPACK_NUGET_COMPONENTS)
+ _cpack_nuget_debug("---[Making single-component(s) package(s)]---")
+ foreach(_comp IN LISTS CPACK_NUGET_COMPONENTS)
+ _cpack_nuget_debug("Starting to make the package for component `${_comp}`")
+ # Render a spec file which includes only given component
+ unset(_CPACK_NUGET_FILES_TAG)
+ _cpack_nuget_make_files_tag(${_comp})
+ # Temporary set `CPACK_NUGET_PACKAGE_COMPONENT` to the current
+ # component name to properly collect various per group settings
+ set(CPACK_NUGET_PACKAGE_COMPONENT ${_comp})
+ _cpack_nuget_render_spec()
+ unset(CPACK_NUGET_PACKAGE_COMPONENT)
+ execute_process(
+ COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS}
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ )
+ endforeach()
+ endif()
+endif()
+
+file(GLOB_RECURSE GEN_CPACK_OUTPUT_FILES "${CPACK_TEMPORARY_DIRECTORY}/*.nupkg")
+if(NOT GEN_CPACK_OUTPUT_FILES)
+ message(FATAL_ERROR "NuGet package was not generated at `${CPACK_TEMPORARY_DIRECTORY}`!")
+endif()
+
+_cpack_nuget_debug("Generated files: ${GEN_CPACK_OUTPUT_FILES}")
diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake
new file mode 100644
index 000000000..ffb24e2d9
--- /dev/null
+++ b/Modules/Internal/CPack/CPackRPM.cmake
@@ -0,0 +1,1881 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# Author: Eric Noulard with the help of Alexander Neundorf.
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
+function(get_file_permissions FILE RETURN_VAR)
+ execute_process(COMMAND ls -l ${FILE}
+ OUTPUT_VARIABLE permissions_
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ string(REPLACE " " ";" permissions_ "${permissions_}")
+ list(GET permissions_ 0 permissions_)
+
+ unset(text_notation_)
+ set(any_chars_ ".")
+ foreach(PERMISSION_TYPE "OWNER" "GROUP" "WORLD")
+ if(permissions_ MATCHES "${any_chars_}r.*")
+ list(APPEND text_notation_ "${PERMISSION_TYPE}_READ")
+ endif()
+ string(APPEND any_chars_ ".")
+ if(permissions_ MATCHES "${any_chars_}w.*")
+ list(APPEND text_notation_ "${PERMISSION_TYPE}_WRITE")
+ endif()
+ string(APPEND any_chars_ ".")
+ if(permissions_ MATCHES "${any_chars_}x.*")
+ list(APPEND text_notation_ "${PERMISSION_TYPE}_EXECUTE")
+ endif()
+ endforeach()
+
+ set(${RETURN_VAR} "${text_notation_}" PARENT_SCOPE)
+endfunction()
+
+function(get_unix_permissions_octal_notation PERMISSIONS_VAR RETURN_VAR)
+ set(PERMISSIONS ${${PERMISSIONS_VAR}})
+ list(LENGTH PERMISSIONS PERM_LEN_PRE)
+ list(REMOVE_DUPLICATES PERMISSIONS)
+ list(LENGTH PERMISSIONS PERM_LEN_POST)
+
+ if(NOT ${PERM_LEN_PRE} EQUAL ${PERM_LEN_POST})
+ message(FATAL_ERROR "${PERMISSIONS_VAR} contains duplicate values.")
+ endif()
+
+ foreach(PERMISSION_TYPE "OWNER" "GROUP" "WORLD")
+ set(${PERMISSION_TYPE}_PERMISSIONS 0)
+
+ foreach(PERMISSION ${PERMISSIONS})
+ if("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_READ")
+ math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 4")
+ elseif("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_WRITE")
+ math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 2")
+ elseif("${PERMISSION}" STREQUAL "${PERMISSION_TYPE}_EXECUTE")
+ math(EXPR ${PERMISSION_TYPE}_PERMISSIONS "${${PERMISSION_TYPE}_PERMISSIONS} + 1")
+ elseif(PERMISSION MATCHES "${PERMISSION_TYPE}.*")
+ message(FATAL_ERROR "${PERMISSIONS_VAR} contains invalid values.")
+ endif()
+ endforeach()
+ endforeach()
+
+ set(${RETURN_VAR} "${OWNER_PERMISSIONS}${GROUP_PERMISSIONS}${WORLD_PERMISSIONS}" PARENT_SCOPE)
+endfunction()
+
+function(cpack_rpm_exact_regex regex_var string)
+ string(REGEX REPLACE "([][+.*()^])" "\\\\\\1" regex "${string}")
+ set("${regex_var}" "${regex}" PARENT_SCOPE)
+endfunction()
+
+function(cpack_rpm_prepare_relocation_paths)
+ # set appropriate prefix, remove possible trailing slash and convert backslashes to slashes
+ if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX)
+ file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX}" PATH_PREFIX)
+ elseif(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_PREFIX)
+ file(TO_CMAKE_PATH "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_PREFIX}" PATH_PREFIX)
+ else()
+ file(TO_CMAKE_PATH "${CPACK_PACKAGING_INSTALL_PREFIX}" PATH_PREFIX)
+ endif()
+
+ set(RPM_RELOCATION_PATHS "${CPACK_RPM_RELOCATION_PATHS}")
+ list(REMOVE_DUPLICATES RPM_RELOCATION_PATHS)
+
+ # set base path prefix
+ if(EXISTS "${WDIR}/${PATH_PREFIX}")
+ if(NOT CPACK_RPM_NO_INSTALL_PREFIX_RELOCATION AND
+ NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT}_INSTALL_PREFIX_RELOCATION AND
+ NOT CPACK_RPM_NO_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_INSTALL_PREFIX_RELOCATION)
+ string(APPEND TMP_RPM_PREFIXES "Prefix: ${PATH_PREFIX}\n")
+ list(APPEND RPM_USED_PACKAGE_PREFIXES "${PATH_PREFIX}")
+
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: removing '${PATH_PREFIX}' from relocation paths")
+ endif()
+ endif()
+ endif()
+
+ # set other path prefixes
+ foreach(RELOCATION_PATH ${RPM_RELOCATION_PATHS})
+ if(IS_ABSOLUTE "${RELOCATION_PATH}")
+ set(PREPARED_RELOCATION_PATH "${RELOCATION_PATH}")
+ elseif(PATH_PREFIX STREQUAL "/")
+ # don't prefix path with a second slash as "//" is treated as network path
+ # by get_filename_component() so it remains in path even inside rpm
+ # package where it may cause problems with relocation
+ set(PREPARED_RELOCATION_PATH "/${RELOCATION_PATH}")
+ else()
+ set(PREPARED_RELOCATION_PATH "${PATH_PREFIX}/${RELOCATION_PATH}")
+ endif()
+
+ # handle cases where path contains extra slashes (e.g. /a//b/ instead of
+ # /a/b)
+ get_filename_component(PREPARED_RELOCATION_PATH
+ "${PREPARED_RELOCATION_PATH}" ABSOLUTE)
+
+ if(EXISTS "${WDIR}/${PREPARED_RELOCATION_PATH}")
+ string(APPEND TMP_RPM_PREFIXES "Prefix: ${PREPARED_RELOCATION_PATH}\n")
+ list(APPEND RPM_USED_PACKAGE_PREFIXES "${PREPARED_RELOCATION_PATH}")
+ endif()
+ endforeach()
+
+ # warn about all the paths that are not relocatable
+ file(GLOB_RECURSE FILE_PATHS_ "${WDIR}/*")
+ foreach(TMP_PATH ${FILE_PATHS_})
+ string(LENGTH "${WDIR}" WDIR_LEN)
+ string(SUBSTRING "${TMP_PATH}" ${WDIR_LEN} -1 TMP_PATH)
+ unset(TMP_PATH_FOUND_)
+
+ foreach(RELOCATION_PATH ${RPM_USED_PACKAGE_PREFIXES})
+ file(RELATIVE_PATH REL_PATH_ "${RELOCATION_PATH}" "${TMP_PATH}")
+ string(SUBSTRING "${REL_PATH_}" 0 2 PREFIX_)
+
+ if(NOT "${PREFIX_}" STREQUAL "..")
+ set(TPM_PATH_FOUND_ TRUE)
+ break()
+ endif()
+ endforeach()
+
+ if(NOT TPM_PATH_FOUND_)
+ message(AUTHOR_WARNING "CPackRPM:Warning: Path ${TMP_PATH} is not on one of the relocatable paths! Package will be partially relocatable.")
+ endif()
+ endforeach()
+
+ set(RPM_USED_PACKAGE_PREFIXES "${RPM_USED_PACKAGE_PREFIXES}" PARENT_SCOPE)
+ set(TMP_RPM_PREFIXES "${TMP_RPM_PREFIXES}" PARENT_SCOPE)
+endfunction()
+
+function(cpack_rpm_prepare_content_list)
+ # get files list
+ file(GLOB_RECURSE CPACK_RPM_INSTALL_FILES LIST_DIRECTORIES true RELATIVE "${WDIR}" "${WDIR}/*")
+ set(CPACK_RPM_INSTALL_FILES "/${CPACK_RPM_INSTALL_FILES}")
+ string(REPLACE ";" ";/" CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}")
+
+ # if we are creating a relocatable package, omit parent directories of
+ # CPACK_RPM_PACKAGE_PREFIX. This is achieved by building a "filter list"
+ # which is passed to the find command that generates the content-list
+ if(CPACK_RPM_PACKAGE_RELOCATABLE)
+ # get a list of the elements in CPACK_RPM_PACKAGE_PREFIXES that are
+ # destinct parent paths of other relocation paths and remove the
+ # final element (so the install-prefix dir itself is not omitted
+ # from the RPM's content-list)
+ list(SORT RPM_USED_PACKAGE_PREFIXES)
+ set(_DISTINCT_PATH "NOT_SET")
+ foreach(_RPM_RELOCATION_PREFIX ${RPM_USED_PACKAGE_PREFIXES})
+ if(NOT "${_RPM_RELOCATION_PREFIX}" MATCHES "${_DISTINCT_PATH}/.*")
+ set(_DISTINCT_PATH "${_RPM_RELOCATION_PREFIX}")
+
+ string(REPLACE "/" ";" _CPACK_RPM_PACKAGE_PREFIX_ELEMS " ${_RPM_RELOCATION_PREFIX}")
+ list(REMOVE_AT _CPACK_RPM_PACKAGE_PREFIX_ELEMS -1)
+ unset(_TMP_LIST)
+ # Now generate all of the parent dirs of the relocation path
+ foreach(_PREFIX_PATH_ELEM ${_CPACK_RPM_PACKAGE_PREFIX_ELEMS})
+ list(APPEND _TMP_LIST "${_PREFIX_PATH_ELEM}")
+ string(REPLACE ";" "/" _OMIT_DIR "${_TMP_LIST}")
+ separate_arguments(_OMIT_DIR)
+ list(APPEND _RPM_DIRS_TO_OMIT ${_OMIT_DIR})
+ endforeach()
+ endif()
+ endforeach()
+ endif()
+
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: Initial list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}")
+ endif()
+
+ if(NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST)
+ set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /etc /etc/init.d /usr /usr/bin
+ /usr/include /usr/lib /usr/libx32 /usr/lib64
+ /usr/share /usr/share/aclocal /usr/share/doc )
+ if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION)
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: Adding ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION} to builtin omit list.")
+ endif()
+ list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST "${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION}")
+ endif()
+ endif()
+
+ if(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST)
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST= ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST}")
+ endif()
+ list(APPEND _RPM_DIRS_TO_OMIT ${CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST})
+ endif()
+
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: Final list of path to OMIT in RPM: ${_RPM_DIRS_TO_OMIT}")
+ endif()
+
+ list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES ${_RPM_DIRS_TO_OMIT})
+
+ # add man paths that will be compressed
+ # (copied from /usr/lib/rpm/brp-compress - script that does the actual
+ # compressing)
+ list(APPEND MAN_LOCATIONS "/usr/man/man.*" "/usr/man/.*/man.*" "/usr/info.*"
+ "/usr/share/man/man.*" "/usr/share/man/.*/man.*" "/usr/share/info.*"
+ "/usr/kerberos/man.*" "/usr/X11R6/man/man.*" "/usr/lib/perl5/man/man.*"
+ "/usr/share/doc/.*/man/man.*" "/usr/lib/.*/man/man.*")
+
+ if(CPACK_RPM_ADDITIONAL_MAN_DIRS)
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: CPACK_RPM_ADDITIONAL_MAN_DIRS= ${CPACK_RPM_ADDITIONAL_MAN_DIRS}")
+ endif()
+ list(APPEND MAN_LOCATIONS ${CPACK_RPM_ADDITIONAL_MAN_DIRS})
+ endif()
+
+ foreach(PACK_LOCATION IN LISTS CPACK_RPM_INSTALL_FILES)
+ foreach(MAN_LOCATION IN LISTS MAN_LOCATIONS)
+ # man pages are files inside a certain location
+ if(PACK_LOCATION MATCHES "${MAN_LOCATION}/"
+ AND NOT IS_DIRECTORY "${WDIR}${PACK_LOCATION}"
+ AND NOT IS_SYMLINK "${WDIR}${PACK_LOCATION}")
+ list(FIND CPACK_RPM_INSTALL_FILES "${PACK_LOCATION}" INDEX)
+ # insert file location that covers compressed man pages
+ # even if using a wildcard causes duplicates as those are
+ # handled by RPM and we still keep the same file list
+ # in spec file - wildcard only represents file type (e.g. .gz)
+ list(INSERT CPACK_RPM_INSTALL_FILES ${INDEX} "${PACK_LOCATION}*")
+ # remove file location that doesn't cover compressed man pages
+ math(EXPR INDEX ${INDEX}+1)
+ list(REMOVE_AT CPACK_RPM_INSTALL_FILES ${INDEX})
+
+ break()
+ endif()
+ endforeach()
+ endforeach()
+
+ set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}" PARENT_SCOPE)
+endfunction()
+
+function(cpack_rpm_symlink_get_relocation_prefixes LOCATION PACKAGE_PREFIXES RETURN_VARIABLE)
+ foreach(PKG_PREFIX IN LISTS PACKAGE_PREFIXES)
+ string(REGEX MATCH "^${PKG_PREFIX}/.*" FOUND_ "${LOCATION}")
+ if(FOUND_)
+ list(APPEND TMP_PREFIXES "${PKG_PREFIX}")
+ endif()
+ endforeach()
+
+ set(${RETURN_VARIABLE} "${TMP_PREFIXES}" PARENT_SCOPE)
+endfunction()
+
+function(cpack_rpm_symlink_create_relocation_script PACKAGE_PREFIXES)
+ list(LENGTH PACKAGE_PREFIXES LAST_INDEX)
+ set(SORTED_PACKAGE_PREFIXES "${PACKAGE_PREFIXES}")
+ list(SORT SORTED_PACKAGE_PREFIXES)
+ list(REVERSE SORTED_PACKAGE_PREFIXES)
+ math(EXPR LAST_INDEX ${LAST_INDEX}-1)
+
+ foreach(SYMLINK_INDEX RANGE ${LAST_INDEX})
+ list(GET SORTED_PACKAGE_PREFIXES ${SYMLINK_INDEX} SRC_PATH)
+ list(FIND PACKAGE_PREFIXES "${SRC_PATH}" SYMLINK_INDEX) # reverse magic
+ string(LENGTH "${SRC_PATH}" SRC_PATH_LEN)
+
+ set(PARTS_CNT 0)
+ set(SCRIPT_PART "if [ \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}\" != \"${SRC_PATH}\" ]; then\n")
+
+ # both paths relocated
+ foreach(POINT_INDEX RANGE ${LAST_INDEX})
+ list(GET SORTED_PACKAGE_PREFIXES ${POINT_INDEX} POINT_PATH)
+ list(FIND PACKAGE_PREFIXES "${POINT_PATH}" POINT_INDEX) # reverse magic
+ string(LENGTH "${POINT_PATH}" POINT_PATH_LEN)
+
+ if(_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX})
+ if("${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}")
+ set(INDENT "")
+ else()
+ string(APPEND SCRIPT_PART " if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n")
+ set(INDENT " ")
+ endif()
+
+ foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX})
+ math(EXPR PARTS_CNT ${PARTS_CNT}+1)
+
+ math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1)
+ list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR)
+ string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX)
+
+ math(EXPR SRC_PATH_END ${SPLIT_INDEX}-${SRC_PATH_LEN})
+ string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${SRC_PATH_LEN} ${SRC_PATH_END} SYMLINK_)
+
+ math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1+${POINT_PATH_LEN})
+ string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_)
+
+ string(APPEND SCRIPT_PART " ${INDENT}if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n")
+ string(APPEND SCRIPT_PART " ${INDENT}ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n")
+ string(APPEND SCRIPT_PART " ${INDENT}CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n")
+ string(APPEND SCRIPT_PART " ${INDENT}fi\n")
+ endforeach()
+
+ if(NOT "${SYMLINK_INDEX}" EQUAL "${POINT_INDEX}")
+ string(APPEND SCRIPT_PART " fi\n")
+ endif()
+ endif()
+ endforeach()
+
+ # source path relocated
+ if(_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X)
+ foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X)
+ math(EXPR PARTS_CNT ${PARTS_CNT}+1)
+
+ math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1)
+ list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR)
+ string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX)
+
+ math(EXPR SRC_PATH_END ${SPLIT_INDEX}-${SRC_PATH_LEN})
+ string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${SRC_PATH_LEN} ${SRC_PATH_END} SYMLINK_)
+
+ math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1)
+ string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_)
+
+ string(APPEND SCRIPT_PART " if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n")
+ string(APPEND SCRIPT_PART " ln -s \"${POINT_}\" \"$RPM_INSTALL_PREFIX${SYMLINK_INDEX}${SYMLINK_}\"\n")
+ string(APPEND SCRIPT_PART " CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n")
+ string(APPEND SCRIPT_PART " fi\n")
+ endforeach()
+ endif()
+
+ if(PARTS_CNT)
+ set(SCRIPT "${SCRIPT_PART}")
+ string(APPEND SCRIPT "fi\n")
+ endif()
+ endforeach()
+
+ # point path relocated
+ foreach(POINT_INDEX RANGE ${LAST_INDEX})
+ list(GET SORTED_PACKAGE_PREFIXES ${POINT_INDEX} POINT_PATH)
+ list(FIND PACKAGE_PREFIXES "${POINT_PATH}" POINT_INDEX) # reverse magic
+ string(LENGTH "${POINT_PATH}" POINT_PATH_LEN)
+
+ if(_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX})
+ string(APPEND SCRIPT "if [ \"$RPM_INSTALL_PREFIX${POINT_INDEX}\" != \"${POINT_PATH}\" ]; then\n")
+
+ foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX})
+ math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1)
+ list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR)
+ string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX)
+
+ string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} 0 ${SPLIT_INDEX} SYMLINK_)
+
+ math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1+${POINT_PATH_LEN})
+ string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_)
+
+ string(APPEND SCRIPT " if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n")
+ string(APPEND SCRIPT " ln -s \"$RPM_INSTALL_PREFIX${POINT_INDEX}${POINT_}\" \"${SYMLINK_}\"\n")
+ string(APPEND SCRIPT " CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}=true\n")
+ string(APPEND SCRIPT " fi\n")
+ endforeach()
+
+ string(APPEND SCRIPT "fi\n")
+ endif()
+ endforeach()
+
+ # no path relocated
+ if(_RPM_RELOCATION_SCRIPT_X_X)
+ foreach(RELOCATION_NO IN LISTS _RPM_RELOCATION_SCRIPT_X_X)
+ math(EXPR RELOCATION_INDEX ${RELOCATION_NO}-1)
+ list(GET _RPM_RELOCATION_SCRIPT_PAIRS ${RELOCATION_INDEX} RELOCATION_SCRIPT_PAIR)
+ string(FIND "${RELOCATION_SCRIPT_PAIR}" ":" SPLIT_INDEX)
+
+ string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} 0 ${SPLIT_INDEX} SYMLINK_)
+
+ math(EXPR POINT_PATH_START ${SPLIT_INDEX}+1)
+ string(SUBSTRING ${RELOCATION_SCRIPT_PAIR} ${POINT_PATH_START} -1 POINT_)
+
+ string(APPEND SCRIPT "if [ -z \"$CPACK_RPM_RELOCATED_SYMLINK_${RELOCATION_INDEX}\" ]; then\n")
+ string(APPEND SCRIPT " ln -s \"${POINT_}\" \"${SYMLINK_}\"\n")
+ string(APPEND SCRIPT "fi\n")
+ endforeach()
+ endif()
+
+ set(RPM_SYMLINK_POSTINSTALL "${SCRIPT}" PARENT_SCOPE)
+endfunction()
+
+function(cpack_rpm_symlink_add_for_relocation_script PACKAGE_PREFIXES SYMLINK SYMLINK_RELOCATION_PATHS POINT POINT_RELOCATION_PATHS)
+ list(LENGTH SYMLINK_RELOCATION_PATHS SYMLINK_PATHS_COUTN)
+ list(LENGTH POINT_RELOCATION_PATHS POINT_PATHS_COUNT)
+
+ list(APPEND _RPM_RELOCATION_SCRIPT_PAIRS "${SYMLINK}:${POINT}")
+ list(LENGTH _RPM_RELOCATION_SCRIPT_PAIRS PAIR_NO)
+
+ if(SYMLINK_PATHS_COUTN)
+ foreach(SYMLINK_RELOC_PATH IN LISTS SYMLINK_RELOCATION_PATHS)
+ list(FIND PACKAGE_PREFIXES "${SYMLINK_RELOC_PATH}" SYMLINK_INDEX)
+
+ # source path relocated
+ list(APPEND _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X "${PAIR_NO}")
+ list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_X")
+
+ foreach(POINT_RELOC_PATH IN LISTS POINT_RELOCATION_PATHS)
+ list(FIND PACKAGE_PREFIXES "${POINT_RELOC_PATH}" POINT_INDEX)
+
+ # both paths relocated
+ list(APPEND _RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX} "${PAIR_NO}")
+ list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_${SYMLINK_INDEX}_${POINT_INDEX}")
+
+ # point path relocated
+ list(APPEND _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX} "${PAIR_NO}")
+ list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}")
+ endforeach()
+ endforeach()
+ elseif(POINT_PATHS_COUNT)
+ foreach(POINT_RELOC_PATH IN LISTS POINT_RELOCATION_PATHS)
+ list(FIND PACKAGE_PREFIXES "${POINT_RELOC_PATH}" POINT_INDEX)
+
+ # point path relocated
+ list(APPEND _RPM_RELOCATION_SCRIPT_X_${POINT_INDEX} "${PAIR_NO}")
+ list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_${POINT_INDEX}")
+ endforeach()
+ endif()
+
+ # no path relocated
+ list(APPEND _RPM_RELOCATION_SCRIPT_X_X "${PAIR_NO}")
+ list(APPEND RELOCATION_VARS "_RPM_RELOCATION_SCRIPT_X_X")
+
+ # place variables into parent scope
+ foreach(VAR IN LISTS RELOCATION_VARS)
+ set(${VAR} "${${VAR}}" PARENT_SCOPE)
+ endforeach()
+ set(_RPM_RELOCATION_SCRIPT_PAIRS "${_RPM_RELOCATION_SCRIPT_PAIRS}" PARENT_SCOPE)
+ set(REQUIRES_SYMLINK_RELOCATION_SCRIPT "true" PARENT_SCOPE)
+ set(DIRECTIVE "%ghost " PARENT_SCOPE)
+endfunction()
+
+function(cpack_rpm_prepare_install_files INSTALL_FILES_LIST WDIR PACKAGE_PREFIXES IS_RELOCATABLE)
+ # Prepend directories in ${CPACK_RPM_INSTALL_FILES} with %dir
+ # This is necessary to avoid duplicate files since rpmbuild does
+ # recursion on its own when encountering a pathname which is a directory
+ # which is not flagged as %dir
+ string(STRIP "${INSTALL_FILES_LIST}" INSTALL_FILES_LIST)
+ string(REPLACE "\n" ";" INSTALL_FILES_LIST
+ "${INSTALL_FILES_LIST}")
+ string(REPLACE "\"" "" INSTALL_FILES_LIST
+ "${INSTALL_FILES_LIST}")
+ string(LENGTH "${WDIR}" WDR_LEN_)
+
+ list(SORT INSTALL_FILES_LIST) # make file order consistent on all platforms
+
+ foreach(F IN LISTS INSTALL_FILES_LIST)
+ unset(DIRECTIVE)
+
+ if(IS_SYMLINK "${WDIR}/${F}")
+ if(IS_RELOCATABLE)
+ # check that symlink has relocatable format
+ get_filename_component(SYMLINK_LOCATION_ "${WDIR}/${F}" DIRECTORY)
+ execute_process(COMMAND ls -la "${WDIR}/${F}"
+ WORKING_DIRECTORY "${WDIR}"
+ OUTPUT_VARIABLE SYMLINK_POINT_
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ string(FIND "${SYMLINK_POINT_}" "->" SYMLINK_POINT_INDEX_ REVERSE)
+ math(EXPR SYMLINK_POINT_INDEX_ ${SYMLINK_POINT_INDEX_}+3)
+ string(LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_)
+
+ # get destination path
+ string(SUBSTRING "${SYMLINK_POINT_}" ${SYMLINK_POINT_INDEX_} ${SYMLINK_POINT_LENGTH_} SYMLINK_POINT_)
+
+ # check if path is relative or absolute
+ string(SUBSTRING "${SYMLINK_POINT_}" 0 1 SYMLINK_IS_ABSOLUTE_)
+
+ if(${SYMLINK_IS_ABSOLUTE_} STREQUAL "/")
+ # prevent absolute paths from having /../ or /./ section inside of them
+ get_filename_component(SYMLINK_POINT_ "${SYMLINK_POINT_}" ABSOLUTE)
+ else()
+ # handle relative path
+ get_filename_component(SYMLINK_POINT_ "${SYMLINK_LOCATION_}/${SYMLINK_POINT_}" ABSOLUTE)
+ endif()
+
+ # recalculate path length after conversion to canonical form
+ string(LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_)
+
+ cpack_rpm_exact_regex(IN_SYMLINK_POINT_REGEX "${WDIR}")
+ string(APPEND IN_SYMLINK_POINT_REGEX "/.*")
+ if(SYMLINK_POINT_ MATCHES "${IN_SYMLINK_POINT_REGEX}")
+ # only symlinks that are pointing inside the packaging structure should be checked for relocation
+ string(SUBSTRING "${SYMLINK_POINT_}" ${WDR_LEN_} -1 SYMLINK_POINT_WD_)
+ cpack_rpm_symlink_get_relocation_prefixes("${F}" "${PACKAGE_PREFIXES}" "SYMLINK_RELOCATIONS")
+ cpack_rpm_symlink_get_relocation_prefixes("${SYMLINK_POINT_WD_}" "${PACKAGE_PREFIXES}" "POINT_RELOCATIONS")
+
+ list(LENGTH SYMLINK_RELOCATIONS SYMLINK_RELOCATIONS_COUNT)
+ list(LENGTH POINT_RELOCATIONS POINT_RELOCATIONS_COUNT)
+ else()
+ # location pointed to is outside WDR so it should be treated as a permanent symlink
+ set(SYMLINK_POINT_WD_ "${SYMLINK_POINT_}")
+
+ unset(SYMLINK_RELOCATIONS)
+ unset(POINT_RELOCATIONS)
+ unset(SYMLINK_RELOCATIONS_COUNT)
+ unset(POINT_RELOCATIONS_COUNT)
+
+ message(AUTHOR_WARNING "CPackRPM:Warning: Symbolic link '${F}' points to location that is outside packaging path! Link will possibly not be relocatable.")
+ endif()
+
+ if(SYMLINK_RELOCATIONS_COUNT AND POINT_RELOCATIONS_COUNT)
+ # find matching
+ foreach(SYMLINK_RELOCATION_PREFIX IN LISTS SYMLINK_RELOCATIONS)
+ list(FIND POINT_RELOCATIONS "${SYMLINK_RELOCATION_PREFIX}" FOUND_INDEX)
+ if(NOT ${FOUND_INDEX} EQUAL -1)
+ break()
+ endif()
+ endforeach()
+
+ if(NOT ${FOUND_INDEX} EQUAL -1)
+ # symlinks have the same subpath
+ if(${SYMLINK_RELOCATIONS_COUNT} EQUAL 1 AND ${POINT_RELOCATIONS_COUNT} EQUAL 1)
+ # permanent symlink
+ get_filename_component(SYMLINK_LOCATION_ "${F}" DIRECTORY)
+ file(RELATIVE_PATH FINAL_PATH_ ${SYMLINK_LOCATION_} ${SYMLINK_POINT_WD_})
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${FINAL_PATH_}" "${WDIR}/${F}")
+ else()
+ # relocation subpaths
+ cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}"
+ "${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}")
+ endif()
+ else()
+ # not on the same relocation path
+ cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}"
+ "${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}")
+ endif()
+ elseif(POINT_RELOCATIONS_COUNT)
+ # point is relocatable
+ cpack_rpm_symlink_add_for_relocation_script("${PACKAGE_PREFIXES}" "${F}" "${SYMLINK_RELOCATIONS}"
+ "${SYMLINK_POINT_WD_}" "${POINT_RELOCATIONS}")
+ else()
+ # is not relocatable or points to non relocatable path - permanent symlink
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${SYMLINK_POINT_WD_}" "${WDIR}/${F}")
+ endif()
+ endif()
+ elseif(IS_DIRECTORY "${WDIR}/${F}")
+ set(DIRECTIVE "%dir ")
+ endif()
+
+ string(APPEND INSTALL_FILES "${DIRECTIVE}\"${F}\"\n")
+ endforeach()
+
+ if(REQUIRES_SYMLINK_RELOCATION_SCRIPT)
+ cpack_rpm_symlink_create_relocation_script("${PACKAGE_PREFIXES}")
+ endif()
+
+ set(RPM_SYMLINK_POSTINSTALL "${RPM_SYMLINK_POSTINSTALL}" PARENT_SCOPE)
+ set(CPACK_RPM_INSTALL_FILES "${INSTALL_FILES}" PARENT_SCOPE)
+endfunction()
+
+if(CMAKE_BINARY_DIR)
+ message(FATAL_ERROR "CPackRPM.cmake may only be used by CPack internally.")
+endif()
+
+if(NOT UNIX)
+ message(FATAL_ERROR "CPackRPM.cmake may only be used under UNIX.")
+endif()
+
+# We need to check if the binaries were compiled with debug symbols
+# because without them the package will be useless
+function(cpack_rpm_debugsymbol_check INSTALL_FILES WORKING_DIR)
+ if(NOT CPACK_BUILD_SOURCE_DIRS)
+ message(FATAL_ERROR "CPackRPM: CPACK_BUILD_SOURCE_DIRS variable is not set!"
+ " Required for debuginfo packaging. See documentation of"
+ " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.")
+ endif()
+
+ # With objdump we should check the debug symbols
+ find_program(OBJDUMP_EXECUTABLE objdump)
+ if(NOT OBJDUMP_EXECUTABLE)
+ message(FATAL_ERROR "CPackRPM: objdump binary could not be found!"
+ " Required for debuginfo packaging. See documentation of"
+ " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.")
+ endif()
+
+ # With debugedit we prepare source files list
+ find_program(DEBUGEDIT_EXECUTABLE debugedit "/usr/lib/rpm/")
+ if(NOT DEBUGEDIT_EXECUTABLE)
+ message(FATAL_ERROR "CPackRPM: debugedit binary could not be found!"
+ " Required for debuginfo packaging. See documentation of"
+ " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.")
+ endif()
+
+ unset(mkdir_list_)
+ unset(cp_list_)
+ unset(additional_sources_)
+
+ foreach(F IN LISTS INSTALL_FILES)
+ if(IS_DIRECTORY "${WORKING_DIR}/${F}" OR IS_SYMLINK "${WORKING_DIR}/${F}")
+ continue()
+ endif()
+
+ execute_process(COMMAND "${OBJDUMP_EXECUTABLE}" -h ${WORKING_DIR}/${F}
+ WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}"
+ RESULT_VARIABLE OBJDUMP_EXEC_RESULT
+ OUTPUT_VARIABLE OBJDUMP_OUT
+ ERROR_QUIET)
+ # Check if the given file is an executable or not
+ if(NOT OBJDUMP_EXEC_RESULT)
+ string(FIND "${OBJDUMP_OUT}" "debug" FIND_RESULT)
+ if(FIND_RESULT GREATER -1)
+ set(index_ 0)
+ foreach(source_dir_ IN LISTS CPACK_BUILD_SOURCE_DIRS)
+ string(LENGTH "${source_dir_}" source_dir_len_)
+ string(LENGTH "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}" debuginfo_dir_len)
+ if(source_dir_len_ LESS debuginfo_dir_len)
+ message(FATAL_ERROR "CPackRPM: source dir path '${source_dir_}' is"
+ " shorter than debuginfo sources dir path '${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}'!"
+ " Source dir path must be longer than debuginfo sources dir path."
+ " Set CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX variable to a shorter value"
+ " or make source dir path longer."
+ " Required for debuginfo packaging. See documentation of"
+ " CPACK_RPM_DEBUGINFO_PACKAGE variable for details.")
+ endif()
+
+ file(REMOVE "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list")
+ execute_process(COMMAND "${DEBUGEDIT_EXECUTABLE}" -b "${source_dir_}" -d "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}" -i -l "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list" "${WORKING_DIR}/${F}"
+ RESULT_VARIABLE res_
+ OUTPUT_VARIABLE opt_
+ ERROR_VARIABLE err_
+ )
+
+ file(STRINGS
+ "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}/debugsources_add.list"
+ sources_)
+ list(REMOVE_DUPLICATES sources_)
+
+ foreach(source_ IN LISTS sources_)
+ if(EXISTS "${source_dir_}/${source_}" AND NOT IS_DIRECTORY "${source_dir_}/${source_}")
+ get_filename_component(path_part_ "${source_}" DIRECTORY)
+ list(APPEND mkdir_list_ "%{buildroot}${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${path_part_}")
+ list(APPEND cp_list_ "cp \"${source_dir_}/${source_}\" \"%{buildroot}${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${path_part_}\"")
+
+ list(APPEND additional_sources_ "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}/src_${index_}/${source_}")
+ endif()
+ endforeach()
+
+ math(EXPR index_ "${index_} + 1")
+ endforeach()
+ else()
+ message(WARNING "CPackRPM: File: ${F} does not contain debug symbols. They will possibly be missing from debuginfo package!")
+ endif()
+
+ get_file_permissions("${WORKING_DIR}/${F}" permissions_)
+ if(NOT "USER_EXECUTE" IN_LIST permissions_ AND
+ NOT "GROUP_EXECUTE" IN_LIST permissions_ AND
+ NOT "WORLD_EXECUTE" IN_LIST permissions_)
+ if(CPACK_RPM_INSTALL_WITH_EXEC)
+ execute_process(COMMAND chmod a+x ${WORKING_DIR}/${F}
+ RESULT_VARIABLE res_
+ ERROR_VARIABLE err_
+ OUTPUT_QUIET)
+
+ if(res_)
+ message(FATAL_ERROR "CPackRPM: could not apply execute permissions "
+ "requested by CPACK_RPM_INSTALL_WITH_EXEC variable on "
+ "'${WORKING_DIR}/${F}'! Reason: '${err_}'")
+ endif()
+ else()
+ message(AUTHOR_WARNING "CPackRPM: File: ${WORKING_DIR}/${F} does not "
+ "have execute permissions. Debuginfo symbols will not be extracted"
+ "! Missing debuginfo may cause packaging failure. Consider setting "
+ "execute permissions or setting 'CPACK_RPM_INSTALL_WITH_EXEC' "
+ "variable.")
+ endif()
+ endif()
+ endif()
+ endforeach()
+
+ list(LENGTH mkdir_list_ len_)
+ if(len_)
+ list(REMOVE_DUPLICATES mkdir_list_)
+ unset(TMP_RPM_DEBUGINFO_INSTALL)
+ foreach(part_ IN LISTS mkdir_list_)
+ string(APPEND TMP_RPM_DEBUGINFO_INSTALL "mkdir -p \"${part_}\"\n")
+ endforeach()
+ endif()
+
+ list(LENGTH cp_list_ len_)
+ if(len_)
+ list(REMOVE_DUPLICATES cp_list_)
+ foreach(part_ IN LISTS cp_list_)
+ string(APPEND TMP_RPM_DEBUGINFO_INSTALL "${part_}\n")
+ endforeach()
+ endif()
+
+ if(NOT DEFINED CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS)
+ set(CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS /usr /usr/src /usr/src/debug)
+ if(CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION)
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: Adding ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION} to builtin omit list.")
+ endif()
+ list(APPEND CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS "${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS_ADDITION}")
+ endif()
+ endif()
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS= ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS}")
+ endif()
+
+ list(LENGTH additional_sources_ len_)
+ if(len_)
+ list(REMOVE_DUPLICATES additional_sources_)
+ unset(additional_sources_all_)
+ foreach(source_ IN LISTS additional_sources_)
+ string(REPLACE "/" ";" split_source_ " ${source_}")
+ list(REMOVE_AT split_source_ 0)
+ unset(tmp_path_)
+ # Now generate all segments of the path
+ foreach(segment_ IN LISTS split_source_)
+ string(APPEND tmp_path_ "/${segment_}")
+ list(APPEND additional_sources_all_ "${tmp_path_}")
+ endforeach()
+ endforeach()
+
+ list(REMOVE_DUPLICATES additional_sources_all_)
+ list(REMOVE_ITEM additional_sources_all_
+ ${CPACK_RPM_DEBUGINFO_EXCLUDE_DIRS})
+
+ unset(TMP_DEBUGINFO_ADDITIONAL_SOURCES)
+ foreach(source_ IN LISTS additional_sources_all_)
+ string(APPEND TMP_DEBUGINFO_ADDITIONAL_SOURCES "${source_}\n")
+ endforeach()
+ endif()
+
+ set(TMP_RPM_DEBUGINFO_INSTALL "${TMP_RPM_DEBUGINFO_INSTALL}" PARENT_SCOPE)
+ set(TMP_DEBUGINFO_ADDITIONAL_SOURCES "${TMP_DEBUGINFO_ADDITIONAL_SOURCES}"
+ PARENT_SCOPE)
+endfunction()
+
+function(cpack_rpm_variable_fallback OUTPUT_VAR_NAME)
+ set(FALLBACK_VAR_NAMES ${ARGN})
+
+ foreach(variable_name IN LISTS FALLBACK_VAR_NAMES)
+ if(${variable_name})
+ set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE)
+ break()
+ endif()
+ endforeach()
+endfunction()
+
+function(cpack_rpm_generate_package)
+ # rpmbuild is the basic command for building RPM package
+ # it may be a simple (symbolic) link to rpm command.
+ find_program(RPMBUILD_EXECUTABLE rpmbuild)
+
+ # Check version of the rpmbuild tool this would be easier to
+ # track bugs with users and CPackRPM debug mode.
+ # We may use RPM version in order to check for available version dependent features
+ if(RPMBUILD_EXECUTABLE)
+ execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --version
+ OUTPUT_VARIABLE _TMP_VERSION
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX REPLACE "^.* " ""
+ RPMBUILD_EXECUTABLE_VERSION
+ ${_TMP_VERSION})
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: rpmbuild version is <${RPMBUILD_EXECUTABLE_VERSION}>")
+ endif()
+ endif()
+
+ if(NOT RPMBUILD_EXECUTABLE)
+ message(FATAL_ERROR "RPM package requires rpmbuild executable")
+ endif()
+
+ # Display lsb_release output if DEBUG mode enable
+ # This will help to diagnose problem with CPackRPM
+ # because we will know on which kind of Linux we are
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ find_program(LSB_RELEASE_EXECUTABLE lsb_release)
+ if(LSB_RELEASE_EXECUTABLE)
+ execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -a
+ OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX REPLACE "\n" ", "
+ LSB_RELEASE_OUTPUT
+ ${_TMP_LSB_RELEASE_OUTPUT})
+ else ()
+ set(LSB_RELEASE_OUTPUT "lsb_release not installed/found!")
+ endif()
+ message("CPackRPM:Debug: LSB_RELEASE = ${LSB_RELEASE_OUTPUT}")
+ endif()
+
+ # We may use RPM version in the future in order
+ # to shut down warning about space in buildtree
+ # some recent RPM version should support space in different places.
+ # not checked [yet].
+ if(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*")
+ message(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.")
+ endif()
+
+ # If rpmbuild is found
+ # we try to discover alien since we may be on non RPM distro like Debian.
+ # In this case we may try to to use more advanced features
+ # like generating RPM directly from DEB using alien.
+ # FIXME feature not finished (yet)
+ find_program(ALIEN_EXECUTABLE alien)
+ if(ALIEN_EXECUTABLE)
+ message(STATUS "alien found, we may be on a Debian based distro.")
+ endif()
+
+ # Are we packaging components ?
+ if(CPACK_RPM_PACKAGE_COMPONENT)
+ string(TOUPPER ${CPACK_RPM_PACKAGE_COMPONENT} CPACK_RPM_PACKAGE_COMPONENT_UPPER)
+ endif()
+
+ set(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}")
+
+ #
+ # Use user-defined RPM specific variables value
+ # or generate reasonable default value from
+ # CPACK_xxx generic values.
+ # The variables comes from the needed (mandatory or not)
+ # values found in the RPM specification file aka ".spec" file.
+ # The variables which may/should be defined are:
+ #
+
+ # CPACK_RPM_PACKAGE_SUMMARY (mandatory)
+
+ if(CPACK_RPM_PACKAGE_COMPONENT)
+ cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_SUMMARY"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_SUMMARY"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_SUMMARY")
+ endif()
+
+ if(NOT CPACK_RPM_PACKAGE_SUMMARY)
+ if(CPACK_PACKAGE_DESCRIPTION_SUMMARY)
+ set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
+ else()
+ # if neither var is defined lets use the name as summary
+ string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY)
+ endif()
+ endif()
+
+ if(NOT CPACK_RPM_PACKAGE_URL AND CMAKE_PROJECT_HOMEPAGE_URL)
+ set(CPACK_RPM_PACKAGE_URL "${CMAKE_PROJECT_HOMEPAGE_URL}")
+ endif()
+
+ # CPACK_RPM_PACKAGE_NAME (mandatory)
+ if(NOT CPACK_RPM_PACKAGE_NAME)
+ string(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME)
+ endif()
+
+ if(CPACK_RPM_PACKAGE_COMPONENT)
+ string(TOUPPER "${CPACK_RPM_MAIN_COMPONENT}"
+ CPACK_RPM_MAIN_COMPONENT_UPPER)
+
+ if(NOT CPACK_RPM_MAIN_COMPONENT_UPPER STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER)
+ string(APPEND CPACK_RPM_PACKAGE_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}")
+
+ cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_NAME"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_NAME"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_NAME")
+ endif()
+ endif()
+
+ # CPACK_RPM_PACKAGE_VERSION (mandatory)
+ if(NOT CPACK_RPM_PACKAGE_VERSION)
+ if(NOT CPACK_PACKAGE_VERSION)
+ message(FATAL_ERROR "RPM package requires a package version")
+ endif()
+ set(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
+ endif()
+ # Replace '-' in version with '_'
+ # '-' character is an Illegal RPM version character
+ # it is illegal because it is used to separate
+ # RPM "Version" from RPM "Release"
+ string(REPLACE "-" "_" CPACK_RPM_PACKAGE_VERSION ${CPACK_RPM_PACKAGE_VERSION})
+
+ # CPACK_RPM_PACKAGE_ARCHITECTURE (mandatory)
+ if(NOT CPACK_RPM_PACKAGE_ARCHITECTURE)
+ execute_process(COMMAND uname "-m"
+ OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ else()
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
+ endif()
+ endif()
+
+ if(CPACK_RPM_PACKAGE_COMPONENT)
+ cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_ARCHITECTURE"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_ARCHITECTURE"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_ARCHITECTURE")
+
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: using component build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
+ endif()
+ endif()
+
+ if(${CPACK_RPM_PACKAGE_ARCHITECTURE} STREQUAL "noarch")
+ set(TMP_RPM_BUILDARCH "Buildarch: ${CPACK_RPM_PACKAGE_ARCHITECTURE}")
+ else()
+ set(TMP_RPM_BUILDARCH "")
+ endif()
+
+ # CPACK_RPM_PACKAGE_RELEASE
+ # The RPM release is the numbering of the RPM package ITSELF
+ # this is the version of the PACKAGING and NOT the version
+ # of the CONTENT of the package.
+ # You may well need to generate a new RPM package release
+ # without changing the version of the packaged software.
+ # This is the case when the packaging is buggy (not) the software :=)
+ # If not set, 1 is a good candidate
+ if(NOT CPACK_RPM_PACKAGE_RELEASE)
+ set(CPACK_RPM_PACKAGE_RELEASE "1")
+ endif()
+
+ if(CPACK_RPM_PACKAGE_RELEASE_DIST)
+ string(APPEND CPACK_RPM_PACKAGE_RELEASE "%{?dist}")
+ endif()
+
+ # CPACK_RPM_PACKAGE_LICENSE
+ if(NOT CPACK_RPM_PACKAGE_LICENSE)
+ set(CPACK_RPM_PACKAGE_LICENSE "unknown")
+ endif()
+
+ # CPACK_RPM_PACKAGE_GROUP
+ if(CPACK_RPM_PACKAGE_COMPONENT)
+ cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_GROUP"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_GROUP"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_GROUP")
+ endif()
+
+ if(NOT CPACK_RPM_PACKAGE_GROUP)
+ set(CPACK_RPM_PACKAGE_GROUP "unknown")
+ endif()
+
+ # CPACK_RPM_PACKAGE_VENDOR
+ if(NOT CPACK_RPM_PACKAGE_VENDOR)
+ if(CPACK_PACKAGE_VENDOR)
+ set(CPACK_RPM_PACKAGE_VENDOR "${CPACK_PACKAGE_VENDOR}")
+ else()
+ set(CPACK_RPM_PACKAGE_VENDOR "unknown")
+ endif()
+ endif()
+
+ # CPACK_RPM_PACKAGE_SOURCE
+ # The name of the source tarball in case we generate a source RPM
+
+ # CPACK_RPM_PACKAGE_DESCRIPTION
+ # The variable content may be either
+ # - explicitly given by the user or
+ # - filled with the content of CPACK_PACKAGE_DESCRIPTION_FILE
+ # if it is defined
+ # - set to a default value
+ #
+
+ if(CPACK_RPM_PACKAGE_COMPONENT)
+ cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_DESCRIPTION"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_DESCRIPTION"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_DESCRIPTION"
+ "CPACK_COMPONENT_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DESCRIPTION")
+ endif()
+
+ if(NOT CPACK_RPM_PACKAGE_DESCRIPTION)
+ if(CPACK_PACKAGE_DESCRIPTION_FILE)
+ file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_RPM_PACKAGE_DESCRIPTION)
+ else ()
+ set(CPACK_RPM_PACKAGE_DESCRIPTION "no package description available")
+ endif ()
+ endif ()
+
+ # CPACK_RPM_COMPRESSION_TYPE
+ #
+ if (CPACK_RPM_COMPRESSION_TYPE)
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: User Specified RPM compression type: ${CPACK_RPM_COMPRESSION_TYPE}")
+ endif()
+ if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma")
+ set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.lzdio")
+ endif()
+ if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz")
+ set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7.xzdio")
+ endif()
+ if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2")
+ set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.bzdio")
+ endif()
+ if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip")
+ set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.gzdio")
+ endif()
+ else()
+ set(CPACK_RPM_COMPRESSION_TYPE_TMP "")
+ endif()
+
+ if(NOT CPACK_RPM_PACKAGE_SOURCES)
+ if(CPACK_PACKAGE_RELOCATABLE OR CPACK_RPM_PACKAGE_RELOCATABLE)
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: Trying to build a relocatable package")
+ endif()
+ if(CPACK_SET_DESTDIR AND (NOT CPACK_SET_DESTDIR STREQUAL "I_ON"))
+ message("CPackRPM:Warning: CPACK_SET_DESTDIR is set (=${CPACK_SET_DESTDIR}) while requesting a relocatable package (CPACK_RPM_PACKAGE_RELOCATABLE is set): this is not supported, the package won't be relocatable.")
+ set(CPACK_RPM_PACKAGE_RELOCATABLE FALSE)
+ else()
+ set(CPACK_RPM_PACKAGE_PREFIX ${CPACK_PACKAGING_INSTALL_PREFIX}) # kept for back compatibility (provided external RPM spec files)
+ cpack_rpm_prepare_relocation_paths()
+ set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE)
+ endif()
+ endif()
+ else()
+ if(CPACK_RPM_PACKAGE_COMPONENT)
+ message(FATAL_ERROR "CPACK_RPM_PACKAGE_SOURCES parameter can not be used"
+ " in combination with CPACK_RPM_PACKAGE_COMPONENT parameter!")
+ endif()
+
+ set(CPACK_RPM_PACKAGE_RELOCATABLE FALSE) # disable relocatable option if building source RPM
+ endif()
+
+ execute_process(
+ COMMAND "${RPMBUILD_EXECUTABLE}" --querytags
+ OUTPUT_VARIABLE RPMBUILD_TAG_LIST
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REPLACE "\n" ";" RPMBUILD_TAG_LIST "${RPMBUILD_TAG_LIST}")
+
+ if(CPACK_RPM_PACKAGE_EPOCH)
+ set(TMP_RPM_EPOCH "Epoch: ${CPACK_RPM_PACKAGE_EPOCH}")
+ endif()
+
+ # Check if additional fields for RPM spec header are given
+ # There may be some COMPONENT specific variables as well
+ # If component specific var is not provided we use the global one
+ # for each component
+ foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN)
+
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}")
+ endif()
+
+ if(CPACK_RPM_PACKAGE_COMPONENT)
+ cpack_rpm_variable_fallback("CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_PACKAGE_${_RPM_SPEC_HEADER}")
+ endif()
+
+ if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER})
+ # Prefix can be replaced by Prefixes but the old version still works so we'll ignore it for now
+ # Requires* is a special case because it gets transformed to Requires(pre/post/preun/postun)
+ # Auto* is a special case because the tags can not be queried by querytags rpmbuild flag
+ set(special_case_tags_ PREFIX REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN AUTOPROV AUTOREQ AUTOREQPROV)
+ if(NOT _RPM_SPEC_HEADER IN_LIST RPMBUILD_TAG_LIST AND NOT _RPM_SPEC_HEADER IN_LIST special_case_tags_)
+ message(AUTHOR_WARNING "CPackRPM:Warning: ${_RPM_SPEC_HEADER} not "
+ "supported in provided rpmbuild. Tag will not be used.")
+ continue()
+ endif()
+
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}")
+ endif()
+
+ set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}})
+ endif()
+
+ # Treat the RPM Spec keyword iff it has been properly defined
+ if(DEFINED CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP)
+ # Transform NAME --> Name e.g. PROVIDES --> Provides
+ # The Upper-case first letter and lowercase tail is the
+ # appropriate value required in the final RPM spec file.
+ string(SUBSTRING ${_RPM_SPEC_HEADER} 1 -1 _PACKAGE_HEADER_TAIL)
+ string(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL)
+ string(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME)
+ string(APPEND _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_TAIL}")
+ # The following keywords require parentheses around the "pre" or "post" suffix in the final RPM spec file.
+ set(SCRIPTS_REQUIREMENTS_LIST REQUIRES_PRE REQUIRES_POST REQUIRES_PREUN REQUIRES_POSTUN)
+ list(FIND SCRIPTS_REQUIREMENTS_LIST ${_RPM_SPEC_HEADER} IS_SCRIPTS_REQUIREMENT_FOUND)
+ if(NOT ${IS_SCRIPTS_REQUIREMENT_FOUND} EQUAL -1)
+ string(REPLACE "_" "(" _PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}")
+ string(APPEND _PACKAGE_HEADER_NAME ")")
+ endif()
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}")
+ endif()
+ set(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}")
+ unset(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP)
+ endif()
+ endforeach()
+
+ # CPACK_RPM_SPEC_INSTALL_POST
+ # May be used to define a RPM post intallation script
+ # for example setting it to "/bin/true" may prevent
+ # rpmbuild from stripping binaries.
+ if(CPACK_RPM_SPEC_INSTALL_POST)
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: User defined CPACK_RPM_SPEC_INSTALL_POST = ${CPACK_RPM_SPEC_INSTALL_POST}")
+ endif()
+ set(TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}")
+ endif()
+
+ # CPACK_RPM_POST_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE)
+ # CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE)
+ # May be used to embed a post (un)installation script in the spec file.
+ # The referred script file(s) will be read and directly
+ # put after the %post or %postun section
+ # ----------------------------------------------------------------
+ # CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE)
+ # CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE)
+ # May be used to embed a pre (un)installation script in the spec file.
+ # The referred script file(s) will be read and directly
+ # put after the %pre or %preun section
+ foreach(RPM_SCRIPT_FILE_TYPE_ "INSTALL" "UNINSTALL")
+ foreach(RPM_SCRIPT_FILE_TIME_ "PRE" "POST")
+ set("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE"
+ "${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE}")
+
+ if(CPACK_RPM_PACKAGE_COMPONENT)
+ cpack_rpm_variable_fallback("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE")
+ endif()
+
+ # Handle file if it has been specified
+ if(CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE)
+ if(EXISTS ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE})
+ file(READ ${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}
+ "CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}")
+ else()
+ message("CPackRPM:Warning: CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE <${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE}> does not exists - ignoring")
+ endif()
+ else()
+ # reset SPEC var value if no file has been specified
+ # (either globally or component-wise)
+ set("CPACK_RPM_SPEC_${RPM_SCRIPT_FILE_TIME_}${RPM_SCRIPT_FILE_TYPE_}" "")
+ endif()
+ endforeach()
+ endforeach()
+
+ # CPACK_RPM_CHANGELOG_FILE
+ # May be used to embed a changelog in the spec file.
+ # The referred file will be read and directly put after the %changelog section
+ if(CPACK_RPM_CHANGELOG_FILE)
+ if(EXISTS ${CPACK_RPM_CHANGELOG_FILE})
+ file(READ ${CPACK_RPM_CHANGELOG_FILE} CPACK_RPM_SPEC_CHANGELOG)
+ else()
+ message(SEND_ERROR "CPackRPM:Warning: CPACK_RPM_CHANGELOG_FILE <${CPACK_RPM_CHANGELOG_FILE}> does not exists - ignoring")
+ endif()
+ else()
+ set(CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Eric Noulard <eric.noulard@gmail.com> - ${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}\n Generated by CPack RPM (no Changelog file were provided)")
+ endif()
+
+ # CPACK_RPM_SPEC_MORE_DEFINE
+ # This is a generated spec rpm file spaceholder
+ if(CPACK_RPM_SPEC_MORE_DEFINE)
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: User defined more define spec line specified:\n ${CPACK_RPM_SPEC_MORE_DEFINE}")
+ endif()
+ endif()
+
+ # Now we may create the RPM build tree structure
+ set(CPACK_RPM_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}")
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}")
+ endif()
+ # Prepare RPM build tree
+ file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR})
+ file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/tmp)
+ file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/BUILD)
+ file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/RPMS)
+ file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SOURCES)
+ file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SPECS)
+ file(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/SRPMS)
+
+ # it seems rpmbuild can't handle spaces in the path
+ # neither escaping (as below) nor putting quotes around the path seem to help
+ #string(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}")
+ set(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}")
+
+ cpack_rpm_prepare_content_list()
+
+ # In component case, put CPACK_ABSOLUTE_DESTINATION_FILES_<COMPONENT>
+ # into CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL
+ # otherwise, put CPACK_ABSOLUTE_DESTINATION_FILES
+ # This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL handling
+ if(CPACK_RPM_PACKAGE_COMPONENT)
+ if(CPACK_ABSOLUTE_DESTINATION_FILES)
+ cpack_rpm_variable_fallback("COMPONENT_FILES_TAG"
+ "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}"
+ "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}")
+ set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${${COMPONENT_FILES_TAG}}")
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>")
+ message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}")
+ endif()
+ endif()
+ else()
+ if(CPACK_ABSOLUTE_DESTINATION_FILES)
+ set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${CPACK_ABSOLUTE_DESTINATION_FILES}")
+ endif()
+ endif()
+
+ # In component case, set CPACK_RPM_USER_FILELIST_INTERNAL with CPACK_RPM_<COMPONENT>_USER_FILELIST.
+ set(CPACK_RPM_USER_FILELIST_INTERNAL "")
+ if(CPACK_RPM_PACKAGE_COMPONENT)
+ cpack_rpm_variable_fallback("CPACK_RPM_USER_FILELIST_INTERNAL"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_FILELIST")
+
+ if(CPACK_RPM_PACKAGE_DEBUG AND CPACK_RPM_USER_FILELIST_INTERNAL)
+ message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>")
+ message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}")
+ endif()
+ elseif(CPACK_RPM_USER_FILELIST)
+ set(CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}")
+ endif()
+
+ # Handle user specified file line list in CPACK_RPM_USER_FILELIST_INTERNAL
+ # Remove those files from CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL
+ # or CPACK_RPM_INSTALL_FILES,
+ # hence it must be done before these auto-generated lists are processed.
+ if(CPACK_RPM_USER_FILELIST_INTERNAL)
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>")
+ endif()
+
+ # Create CMake list from CPACK_RPM_INSTALL_FILES
+ string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST)
+ string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST
+ "${CPACK_RPM_INSTALL_FILES_LIST}")
+ string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST
+ "${CPACK_RPM_INSTALL_FILES_LIST}")
+
+ set(CPACK_RPM_USER_INSTALL_FILES "")
+ foreach(F IN LISTS CPACK_RPM_USER_FILELIST_INTERNAL)
+ string(REGEX REPLACE "%[A-Za-z]+(\\([^()]*\\))? " "" F_PATH ${F})
+ string(REGEX MATCH "(%[A-Za-z]+(\\([^()]*\\))? )*" F_PREFIX ${F})
+ string(STRIP ${F_PREFIX} F_PREFIX)
+
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: F_PREFIX=<${F_PREFIX}>, F_PATH=<${F_PATH}>")
+ endif()
+ if(F_PREFIX)
+ string(APPEND F_PREFIX " ")
+ endif()
+ # Rebuild the user list file
+ string(APPEND CPACK_RPM_USER_INSTALL_FILES "${F_PREFIX}\"${F_PATH}\"\n")
+
+ # Remove from CPACK_RPM_INSTALL_FILES and CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL
+ list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${F_PATH})
+ # ABSOLUTE destination files list may not exists at all
+ if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL)
+ list(REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${F_PATH})
+ endif()
+ endforeach()
+
+ # Rebuild CPACK_RPM_INSTALL_FILES
+ set(CPACK_RPM_INSTALL_FILES "")
+ foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST)
+ string(APPEND CPACK_RPM_INSTALL_FILES "\"${F}\"\n")
+ endforeach()
+ else()
+ set(CPACK_RPM_USER_INSTALL_FILES "")
+ endif()
+
+ if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL)
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: Handling Absolute Destination Files: ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}")
+ endif()
+ # Remove trailing space
+ string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST)
+ # Transform endline separated - string into CMake List
+ string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}")
+ # Remove unnecessary quotes
+ string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}")
+ # Remove ABSOLUTE install file from INSTALL FILE LIST
+ list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL})
+ # Rebuild INSTALL_FILES
+ set(CPACK_RPM_INSTALL_FILES "")
+ foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST)
+ string(APPEND CPACK_RPM_INSTALL_FILES "\"${F}\"\n")
+ endforeach()
+ # Build ABSOLUTE_INSTALL_FILES
+ set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "")
+ foreach(F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL)
+ string(APPEND CPACK_RPM_ABSOLUTE_INSTALL_FILES "%config \"${F}\"\n")
+ endforeach()
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: CPACK_RPM_ABSOLUTE_INSTALL_FILES=${CPACK_RPM_ABSOLUTE_INSTALL_FILES}")
+ message("CPackRPM:Debug: CPACK_RPM_INSTALL_FILES=${CPACK_RPM_INSTALL_FILES}")
+ endif()
+ else()
+ # reset vars in order to avoid leakage of value(s) from one component to another
+ set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "")
+ endif()
+
+ cpack_rpm_variable_fallback("CPACK_RPM_DEBUGINFO_PACKAGE"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_DEBUGINFO_PACKAGE"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEBUGINFO_PACKAGE"
+ "CPACK_RPM_DEBUGINFO_PACKAGE")
+ if(CPACK_RPM_DEBUGINFO_PACKAGE OR (CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND NOT GENERATE_SPEC_PARTS))
+ cpack_rpm_variable_fallback("CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_BUILD_SOURCE_DIRS_PREFIX"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_BUILD_SOURCE_DIRS_PREFIX"
+ "CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX")
+ if(NOT CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX)
+ set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}")
+ endif()
+
+ # handle cases where path contains extra slashes (e.g. /a//b/ instead of
+ # /a/b)
+ get_filename_component(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX
+ "${CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX}" ABSOLUTE)
+
+ if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND GENERATE_SPEC_PARTS)
+ file(WRITE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}.files"
+ "${CPACK_RPM_INSTALL_FILES}")
+ else()
+ if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND CPACK_RPM_PACKAGE_COMPONENT)
+ # this part is only required by components packaging - with monolithic
+ # packages we can be certain that there are no other components present
+ # so CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE is a noop
+ if(CPACK_RPM_DEBUGINFO_PACKAGE)
+ # only add current package files to debuginfo list if debuginfo
+ # generation is enabled for current package
+ string(STRIP "${CPACK_RPM_INSTALL_FILES}" install_files_)
+ string(REPLACE "\n" ";" install_files_ "${install_files_}")
+ string(REPLACE "\"" "" install_files_ "${install_files_}")
+ else()
+ unset(install_files_)
+ endif()
+
+ file(GLOB files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.files")
+
+ foreach(f_ IN LISTS files_)
+ file(READ "${f_}" tmp_)
+ string(APPEND install_files_ ";${tmp_}")
+ endforeach()
+
+ # if there were other components/groups so we need to move files from them
+ # to current component otherwise those files won't be found
+ file(GLOB components_ LIST_DIRECTORIES true RELATIVE
+ "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}"
+ "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/*")
+ foreach(component_ IN LISTS components_)
+ string(TOUPPER "${component_}" component_dir_upper_)
+ if(component_dir_upper_ STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER)
+ # skip current component
+ continue()
+ endif()
+
+ file(GLOB_RECURSE files_for_move_ LIST_DIRECTORIES false RELATIVE
+ "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}"
+ "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/*")
+
+ foreach(f_ IN LISTS files_for_move_)
+ get_filename_component(dir_path_ "${f_}" DIRECTORY)
+ set(src_file_
+ "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/${f_}")
+
+ # check that we are not overriding an existing file that doesn't
+ # match the file that we want to copy
+ if(EXISTS "${src_file_}" AND EXISTS "${WDIR}/${f_}")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E compare_files "${src_file_}" "${WDIR}/${f_}"
+ RESULT_VARIABLE res_
+ )
+ if(res_)
+ message(FATAL_ERROR "CPackRPM:Error: File on path '${WDIR}/${f_}'"
+ " already exists but is a different than the one in component"
+ " '${component_}'! Packages will not be generated.")
+ endif()
+ endif()
+
+ file(MAKE_DIRECTORY "${WDIR}/${dir_path_}")
+ file(RENAME "${src_file_}"
+ "${WDIR}/${f_}")
+ endforeach()
+ endforeach()
+
+ cpack_rpm_debugsymbol_check("${install_files_}" "${WDIR}")
+ else()
+ string(STRIP "${CPACK_RPM_INSTALL_FILES}" install_files_)
+ string(REPLACE "\n" ";" install_files_ "${install_files_}")
+ string(REPLACE "\"" "" install_files_ "${install_files_}")
+
+ cpack_rpm_debugsymbol_check("${install_files_}" "${WDIR}")
+ endif()
+
+ if(TMP_DEBUGINFO_ADDITIONAL_SOURCES)
+ set(TMP_RPM_DEBUGINFO "
+# Modified version of %%debug_package macro
+# defined in /usr/lib/rpm/macros as that one
+# can't handle injection of extra source files.
+%ifnarch noarch
+%global __debug_package 1
+%package debuginfo
+Summary: Debug information for package %{name}
+Group: Development/Debug
+AutoReqProv: 0
+%description debuginfo
+This package provides debug information for package %{name}.
+Debug information is useful when developing applications that use this
+package or when debugging this package.
+%files debuginfo -f debugfiles.list
+%defattr(-,root,root)
+${TMP_DEBUGINFO_ADDITIONAL_SOURCES}
+%endif
+")
+ elseif(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE)
+ message(AUTHOR_WARNING "CPackRPM:Warning: debuginfo package was requested"
+ " but will not be generated as no source files were found!")
+ else()
+ message(AUTHOR_WARNING "CPackRPM:Warning: debuginfo package was requested"
+ " but will not be generated as no source files were found! Component: '"
+ "${CPACK_RPM_PACKAGE_COMPONENT}'.")
+ endif()
+ endif()
+ endif()
+
+ # Prepare install files
+ cpack_rpm_prepare_install_files(
+ "${CPACK_RPM_INSTALL_FILES}"
+ "${WDIR}"
+ "${RPM_USED_PACKAGE_PREFIXES}"
+ "${CPACK_RPM_PACKAGE_RELOCATABLE}"
+ )
+
+ # set default user and group
+ foreach(_PERM_TYPE "USER" "GROUP")
+ if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE})
+ set(TMP_DEFAULT_${_PERM_TYPE} "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}}")
+ elseif(CPACK_RPM_DEFAULT_${_PERM_TYPE})
+ set(TMP_DEFAULT_${_PERM_TYPE} "${CPACK_RPM_DEFAULT_${_PERM_TYPE}}")
+ else()
+ set(TMP_DEFAULT_${_PERM_TYPE} "root")
+ endif()
+ endforeach()
+
+ # set default file and dir permissions
+ foreach(_PERM_TYPE "FILE" "DIR")
+ if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS)
+ get_unix_permissions_octal_notation("CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS" "TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
+ set(_PERMISSIONS_VAR "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
+ elseif(CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS)
+ get_unix_permissions_octal_notation("CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS" "TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
+ set(_PERMISSIONS_VAR "CPACK_RPM_DEFAULT_${_PERM_TYPE}_PERMISSIONS")
+ else()
+ set(TMP_DEFAULT_${_PERM_TYPE}_PERMISSIONS "-")
+ endif()
+ endforeach()
+
+ # The name of the final spec file to be used by rpmbuild
+ set(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}.spec")
+
+ # Print out some debug information if we were asked for that
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}")
+ message("CPackRPM:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}")
+ message("CPackRPM:Debug: CPACK_TEMPORARY_DIRECTORY = ${CPACK_TEMPORARY_DIRECTORY}")
+ message("CPackRPM:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}")
+ message("CPackRPM:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}")
+ message("CPackRPM:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}")
+ message("CPackRPM:Debug: CPACK_RPM_BINARY_SPECFILE = ${CPACK_RPM_BINARY_SPECFILE}")
+ message("CPackRPM:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}")
+ message("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}")
+ endif()
+
+ #
+ # USER generated/provided spec file handling.
+ #
+
+ # We can have a component specific spec file.
+ if(CPACK_RPM_PACKAGE_COMPONENT)
+ cpack_rpm_variable_fallback("CPACK_RPM_USER_BINARY_SPECFILE"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_BINARY_SPECFILE"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_USER_BINARY_SPECFILE")
+ endif()
+
+ cpack_rpm_variable_fallback("CPACK_RPM_FILE_NAME"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_FILE_NAME"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_FILE_NAME"
+ "CPACK_RPM_FILE_NAME")
+ if(NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT")
+ if(CPACK_RPM_FILE_NAME)
+ if(NOT CPACK_RPM_FILE_NAME MATCHES ".*\\.rpm")
+ message(FATAL_ERROR "'${CPACK_RPM_FILE_NAME}' is not a valid RPM package file name as it must end with '.rpm'!")
+ endif()
+ else()
+ # old file name format for back compatibility
+ string(TOUPPER "${CPACK_RPM_MAIN_COMPONENT}"
+ CPACK_RPM_MAIN_COMPONENT_UPPER)
+
+ if(CPACK_RPM_MAIN_COMPONENT_UPPER STREQUAL CPACK_RPM_PACKAGE_COMPONENT_UPPER)
+ # this is the main component so ignore the component filename part
+ set(CPACK_RPM_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}.rpm")
+ else()
+ set(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}")
+ endif()
+ endif()
+ # else example:
+ #set(CPACK_RPM_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}-${CPACK_RPM_PACKAGE_ARCHITECTURE}.rpm")
+
+ if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE AND GENERATE_SPEC_PARTS)
+ string(TOLOWER "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm" expected_filename_)
+
+ file(WRITE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}.rpm_name"
+ "${expected_filename_};${CPACK_RPM_FILE_NAME}")
+ elseif(NOT CPACK_RPM_DEBUGINFO_PACKAGE)
+ set(FILE_NAME_DEFINE "%define _rpmfilename ${CPACK_RPM_FILE_NAME}")
+ endif()
+ endif()
+
+ if(CPACK_RPM_PACKAGE_SOURCES) # source rpm
+ set(archive_name_ "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}")
+
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar "cfvz" "${CPACK_RPM_DIRECTORY}/SOURCES/${archive_name_}.tar.gz" "${CPACK_PACKAGE_FILE_NAME}"
+ WORKING_DIRECTORY ${CPACK_RPM_DIRECTORY}
+ )
+ set(TMP_RPM_SOURCE "Source: ${archive_name_}.tar.gz")
+
+ if(CPACK_RPM_BUILDREQUIRES)
+ set(TMP_RPM_BUILD_REQUIRES "BuildRequires: ${CPACK_RPM_BUILDREQUIRES}")
+ endif()
+
+ # Disable debuginfo packages - srpm generates invalid packages due to
+ # releasing control to cpack to generate binary packages.
+ # Note however that this doesn't prevent cpack to generate debuginfo
+ # packages when run from srpm with --rebuild.
+ set(TMP_RPM_DISABLE_DEBUGINFO "%define debug_package %{nil}")
+
+ if(NOT CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX)
+ set(CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX "/")
+ endif()
+
+ set(TMP_RPM_BUILD
+ "
+%build
+mkdir cpack_rpm_build_dir
+cd cpack_rpm_build_dir
+'${CMAKE_COMMAND}' ${CPACK_RPM_SOURCE_PKG_BUILD_PARAMS} -DCPACK_PACKAGING_INSTALL_PREFIX=${CPACK_RPM_SOURCE_PKG_PACKAGING_INSTALL_PREFIX} ../${CPACK_PACKAGE_FILE_NAME}
+make %{?_smp_mflags}" # %{?_smp_mflags} -> -j option
+ )
+ set(TMP_RPM_INSTALL
+ "
+cd cpack_rpm_build_dir
+cpack -G RPM
+mv *.rpm %_rpmdir"
+ )
+ set(TMP_RPM_PREP "%setup -c")
+
+ set(RPMBUILD_FLAGS "-bs")
+
+ file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in
+ "# Restore old style debuginfo creation for rpm >= 4.14.
+%undefine _debugsource_packages
+%undefine _debuginfo_subpackages
+
+# -*- rpm-spec -*-
+BuildRoot: %_topdir/\@CPACK_PACKAGE_FILE_NAME\@
+Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@
+Name: \@CPACK_RPM_PACKAGE_NAME\@
+Version: \@CPACK_RPM_PACKAGE_VERSION\@
+Release: \@CPACK_RPM_PACKAGE_RELEASE\@
+License: \@CPACK_RPM_PACKAGE_LICENSE\@
+Group: \@CPACK_RPM_PACKAGE_GROUP\@
+Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@
+
+\@TMP_RPM_SOURCE\@
+\@TMP_RPM_BUILD_REQUIRES\@
+\@TMP_RPM_BUILDARCH\@
+\@TMP_RPM_PREFIXES\@
+
+\@TMP_RPM_DISABLE_DEBUGINFO\@
+
+%define _rpmdir %_topdir/RPMS
+%define _srcrpmdir %_topdir/SRPMS
+\@FILE_NAME_DEFINE\@
+%define _unpackaged_files_terminate_build 0
+\@TMP_RPM_SPEC_INSTALL_POST\@
+\@CPACK_RPM_SPEC_MORE_DEFINE\@
+\@CPACK_RPM_COMPRESSION_TYPE_TMP\@
+
+%description
+\@CPACK_RPM_PACKAGE_DESCRIPTION\@
+
+# This is a shortcutted spec file generated by CMake RPM generator
+# we skip _install step because CPack does that for us.
+# We do only save CPack installed tree in _prepr
+# and then restore it in build.
+%prep
+\@TMP_RPM_PREP\@
+
+\@TMP_RPM_BUILD\@
+
+#p build
+
+%install
+\@TMP_RPM_INSTALL\@
+
+%clean
+
+%changelog
+\@CPACK_RPM_SPEC_CHANGELOG\@
+"
+ )
+
+ elseif(GENERATE_SPEC_PARTS) # binary rpm with single debuginfo package
+ file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in
+ "# -*- rpm-spec -*-
+%package -n \@CPACK_RPM_PACKAGE_NAME\@
+Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@
+Version: \@CPACK_RPM_PACKAGE_VERSION\@
+Release: \@CPACK_RPM_PACKAGE_RELEASE\@
+License: \@CPACK_RPM_PACKAGE_LICENSE\@
+Group: \@CPACK_RPM_PACKAGE_GROUP\@
+Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@
+
+\@TMP_RPM_URL\@
+\@TMP_RPM_REQUIRES\@
+\@TMP_RPM_REQUIRES_PRE\@
+\@TMP_RPM_REQUIRES_POST\@
+\@TMP_RPM_REQUIRES_PREUN\@
+\@TMP_RPM_REQUIRES_POSTUN\@
+\@TMP_RPM_PROVIDES\@
+\@TMP_RPM_OBSOLETES\@
+\@TMP_RPM_CONFLICTS\@
+\@TMP_RPM_SUGGESTS\@
+\@TMP_RPM_AUTOPROV\@
+\@TMP_RPM_AUTOREQ\@
+\@TMP_RPM_AUTOREQPROV\@
+\@TMP_RPM_BUILDARCH\@
+\@TMP_RPM_PREFIXES\@
+\@TMP_RPM_EPOCH\@
+
+%description -n \@CPACK_RPM_PACKAGE_NAME\@
+\@CPACK_RPM_PACKAGE_DESCRIPTION\@
+
+%files -n \@CPACK_RPM_PACKAGE_NAME\@
+%defattr(\@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@)
+\@CPACK_RPM_INSTALL_FILES\@
+\@CPACK_RPM_ABSOLUTE_INSTALL_FILES\@
+\@CPACK_RPM_USER_INSTALL_FILES\@
+"
+ )
+
+ else() # binary rpm
+ if(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE)
+ # find generated spec file and take its name
+ file(GLOB spec_files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.spec")
+
+ foreach(f_ IN LISTS spec_files_)
+ file(READ "${f_}" tmp_)
+ string(APPEND TMP_OTHER_COMPONENTS "\n${tmp_}\n")
+ endforeach()
+ endif()
+
+ # We should generate a USER spec file template:
+ # - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE
+ # - or the user did not provide one : NOT CPACK_RPM_USER_BINARY_SPECFILE
+ set(RPMBUILD_FLAGS "-bb")
+ if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE)
+
+ file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in
+ "# Restore old style debuginfo creation for rpm >= 4.14.
+%undefine _debugsource_packages
+%undefine _debuginfo_subpackages
+
+# -*- rpm-spec -*-
+BuildRoot: %_topdir/\@CPACK_PACKAGE_FILE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH\@
+Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@
+Name: \@CPACK_RPM_PACKAGE_NAME\@
+Version: \@CPACK_RPM_PACKAGE_VERSION\@
+Release: \@CPACK_RPM_PACKAGE_RELEASE\@
+License: \@CPACK_RPM_PACKAGE_LICENSE\@
+Group: \@CPACK_RPM_PACKAGE_GROUP\@
+Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@
+
+\@TMP_RPM_URL\@
+\@TMP_RPM_REQUIRES\@
+\@TMP_RPM_REQUIRES_PRE\@
+\@TMP_RPM_REQUIRES_POST\@
+\@TMP_RPM_REQUIRES_PREUN\@
+\@TMP_RPM_REQUIRES_POSTUN\@
+\@TMP_RPM_PROVIDES\@
+\@TMP_RPM_OBSOLETES\@
+\@TMP_RPM_CONFLICTS\@
+\@TMP_RPM_SUGGESTS\@
+\@TMP_RPM_AUTOPROV\@
+\@TMP_RPM_AUTOREQ\@
+\@TMP_RPM_AUTOREQPROV\@
+\@TMP_RPM_BUILDARCH\@
+\@TMP_RPM_PREFIXES\@
+\@TMP_RPM_EPOCH\@
+
+\@TMP_RPM_DEBUGINFO\@
+
+%define _rpmdir %_topdir/RPMS
+%define _srcrpmdir %_topdir/SRPMS
+\@FILE_NAME_DEFINE\@
+%define _unpackaged_files_terminate_build 0
+\@TMP_RPM_SPEC_INSTALL_POST\@
+\@CPACK_RPM_SPEC_MORE_DEFINE\@
+\@CPACK_RPM_COMPRESSION_TYPE_TMP\@
+
+%description
+\@CPACK_RPM_PACKAGE_DESCRIPTION\@
+
+# This is a shortcutted spec file generated by CMake RPM generator
+# we skip _install step because CPack does that for us.
+# We do only save CPack installed tree in _prepr
+# and then restore it in build.
+%prep
+mv $RPM_BUILD_ROOT %_topdir/tmpBBroot
+
+%install
+if [ -e $RPM_BUILD_ROOT ];
+then
+ rm -rf $RPM_BUILD_ROOT
+fi
+mv %_topdir/tmpBBroot $RPM_BUILD_ROOT
+
+\@TMP_RPM_DEBUGINFO_INSTALL\@
+
+%clean
+
+%post
+\@RPM_SYMLINK_POSTINSTALL\@
+\@CPACK_RPM_SPEC_POSTINSTALL\@
+
+%postun
+\@CPACK_RPM_SPEC_POSTUNINSTALL\@
+
+%pre
+\@CPACK_RPM_SPEC_PREINSTALL\@
+
+%preun
+\@CPACK_RPM_SPEC_PREUNINSTALL\@
+
+%files
+%defattr(\@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@)
+\@CPACK_RPM_INSTALL_FILES\@
+\@CPACK_RPM_ABSOLUTE_INSTALL_FILES\@
+\@CPACK_RPM_USER_INSTALL_FILES\@
+
+%changelog
+\@CPACK_RPM_SPEC_CHANGELOG\@
+
+\@TMP_OTHER_COMPONENTS\@
+"
+ )
+ endif()
+
+ # Stop here if we were asked to only generate a template USER spec file
+ # The generated file may then be used as a template by user who wants
+ # to customize their own spec file.
+ if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE)
+ message(FATAL_ERROR "CPackRPM: STOP here Generated USER binary spec file template is: ${CPACK_RPM_BINARY_SPECFILE}.in")
+ endif()
+ endif()
+
+ # After that we may either use a user provided spec file
+ # or generate one using appropriate variables value.
+ if(CPACK_RPM_USER_BINARY_SPECFILE)
+ # User may have specified SPECFILE just use it
+ message("CPackRPM: Will use USER specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}")
+ # The user provided file is processed for @var replacement
+ configure_file(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY)
+ else()
+ # No User specified spec file, will use the generated spec file
+ message("CPackRPM: Will use GENERATED spec file: ${CPACK_RPM_BINARY_SPECFILE}")
+ # Note the just created file is processed for @var replacement
+ configure_file(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY)
+ endif()
+
+ if(NOT GENERATE_SPEC_PARTS) # generate package
+ if(RPMBUILD_EXECUTABLE)
+ # Now call rpmbuild using the SPECFILE
+ execute_process(
+ COMMAND "${RPMBUILD_EXECUTABLE}" ${RPMBUILD_FLAGS}
+ --define "_topdir ${CPACK_RPM_DIRECTORY}"
+ --buildroot "%_topdir/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
+ --target "${CPACK_RPM_PACKAGE_ARCHITECTURE}"
+ "${CPACK_RPM_BINARY_SPECFILE}"
+ WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}"
+ RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT
+ ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err"
+ OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out")
+ if(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT)
+ file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err RPMBUILDERR)
+ file(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out RPMBUILDOUT)
+ message("CPackRPM:Debug: You may consult rpmbuild logs in: ")
+ message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.err")
+ message("CPackRPM:Debug: *** ${RPMBUILDERR} ***")
+ message("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_NAME}.out")
+ message("CPackRPM:Debug: *** ${RPMBUILDOUT} ***")
+ endif()
+ else()
+ if(ALIEN_EXECUTABLE)
+ message(FATAL_ERROR "RPM packaging through alien not done (yet)")
+ endif()
+ endif()
+
+ # find generated rpm files and take their names
+ file(GLOB_RECURSE GENERATED_FILES "${CPACK_RPM_DIRECTORY}/RPMS/*.rpm"
+ "${CPACK_RPM_DIRECTORY}/SRPMS/*.rpm")
+
+ if(NOT GENERATED_FILES)
+ message(FATAL_ERROR "RPM package was not generated! ${CPACK_RPM_DIRECTORY}")
+ endif()
+
+ unset(expected_filenames_)
+ unset(filenames_)
+ if(CPACK_RPM_DEBUGINFO_PACKAGE AND NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT")
+ list(APPEND expected_filenames_
+ "${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.*\\.rpm")
+ list(APPEND filenames_ "${CPACK_RPM_FILE_NAME}")
+ endif()
+
+ if(CPACK_RPM_DEBUGINFO_PACKAGE)
+ cpack_rpm_variable_fallback("CPACK_RPM_DEBUGINFO_FILE_NAME"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_DEBUGINFO_FILE_NAME"
+ "CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT_UPPER}_DEBUGINFO_FILE_NAME"
+ "CPACK_RPM_DEBUGINFO_FILE_NAME")
+
+ if(CPACK_RPM_DEBUGINFO_FILE_NAME AND
+ NOT CPACK_RPM_DEBUGINFO_FILE_NAME STREQUAL "RPM-DEFAULT")
+ list(APPEND expected_filenames_
+ "${CPACK_RPM_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}.*\\.rpm")
+ string(REPLACE "@cpack_component@" "${CPACK_RPM_PACKAGE_COMPONENT}"
+ CPACK_RPM_DEBUGINFO_FILE_NAME "${CPACK_RPM_DEBUGINFO_FILE_NAME}")
+ list(APPEND filenames_ "${CPACK_RPM_DEBUGINFO_FILE_NAME}")
+ endif()
+ endif()
+
+ # check if other files have to be renamed
+ file(GLOB rename_files_ "${CPACK_RPM_DIRECTORY}/SPECS/*.rpm_name")
+ if(rename_files_)
+ foreach(f_ IN LISTS rename_files_)
+ file(READ "${f_}" tmp_)
+ list(GET tmp_ 0 efn_)
+ list(APPEND expected_filenames_ "${efn_}")
+ list(GET tmp_ 1 fn_)
+ list(APPEND filenames_ "${fn_}")
+ endforeach()
+ endif()
+
+ if(expected_filenames_)
+ foreach(F IN LISTS GENERATED_FILES)
+ unset(matched_)
+ foreach(expected_ IN LISTS expected_filenames_)
+ if(F MATCHES ".*/${expected_}")
+ list(FIND expected_filenames_ "${expected_}" idx_)
+ list(GET filenames_ ${idx_} filename_)
+ get_filename_component(FILE_PATH "${F}" DIRECTORY)
+ file(RENAME "${F}" "${FILE_PATH}/${filename_}")
+ list(APPEND new_files_list_ "${FILE_PATH}/${filename_}")
+ set(matched_ "YES")
+
+ break()
+ endif()
+ endforeach()
+
+ if(NOT matched_)
+ list(APPEND new_files_list_ "${F}")
+ endif()
+ endforeach()
+
+ set(GENERATED_FILES "${new_files_list_}")
+ endif()
+ endif()
+
+ set(GEN_CPACK_OUTPUT_FILES "${GENERATED_FILES}" PARENT_SCOPE)
+
+ if(CPACK_RPM_PACKAGE_DEBUG)
+ message("CPackRPM:Debug: GEN_CPACK_OUTPUT_FILES = ${GENERATED_FILES}")
+ endif()
+endfunction()
+
+cpack_rpm_generate_package()
+
+cmake_policy(POP)
diff --git a/Modules/Internal/CPack/CPackWIX.cmake b/Modules/Internal/CPack/CPackWIX.cmake
new file mode 100644
index 000000000..d1875f23c
--- /dev/null
+++ b/Modules/Internal/CPack/CPackWIX.cmake
@@ -0,0 +1,20 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+if(NOT CPACK_WIX_ROOT)
+ string(REPLACE "\\" "/" CPACK_WIX_ROOT "$ENV{WIX}")
+endif()
+
+find_program(CPACK_WIX_CANDLE_EXECUTABLE candle
+ PATHS "${CPACK_WIX_ROOT}" PATH_SUFFIXES "bin")
+
+if(NOT CPACK_WIX_CANDLE_EXECUTABLE)
+ message(FATAL_ERROR "Could not find the WiX candle executable.")
+endif()
+
+find_program(CPACK_WIX_LIGHT_EXECUTABLE light
+ PATHS "${CPACK_WIX_ROOT}" PATH_SUFFIXES "bin")
+
+if(NOT CPACK_WIX_LIGHT_EXECUTABLE)
+ message(FATAL_ERROR "Could not find the WiX light executable.")
+endif()
diff --git a/Modules/Internal/CPack/CPackZIP.cmake b/Modules/Internal/CPack/CPackZIP.cmake
new file mode 100644
index 000000000..f619de400
--- /dev/null
+++ b/Modules/Internal/CPack/CPackZIP.cmake
@@ -0,0 +1,30 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+if(CMAKE_BINARY_DIR)
+ message(FATAL_ERROR "CPackZIP.cmake may only be used by CPack internally.")
+endif()
+
+find_program(ZIP_EXECUTABLE wzzip PATHS "$ENV{ProgramFiles}/WinZip")
+if(ZIP_EXECUTABLE)
+ set(CPACK_ZIP_COMMAND "\"${ZIP_EXECUTABLE}\" -P \"<ARCHIVE>\" @<FILELIST>")
+ set(CPACK_ZIP_NEED_QUOTES TRUE)
+endif()
+
+if(NOT ZIP_EXECUTABLE)
+ find_program(ZIP_EXECUTABLE 7z PATHS "$ENV{ProgramFiles}/7-Zip")
+ if(ZIP_EXECUTABLE)
+ set(CPACK_ZIP_COMMAND "\"${ZIP_EXECUTABLE}\" a -tzip \"<ARCHIVE>\" @<FILELIST>")
+ set(CPACK_ZIP_NEED_QUOTES TRUE)
+ endif()
+endif()
+
+if(NOT ZIP_EXECUTABLE)
+ find_package(Cygwin)
+ find_program(ZIP_EXECUTABLE zip PATHS "${CYGWIN_INSTALL_PATH}/bin")
+ if(ZIP_EXECUTABLE)
+ set(CPACK_ZIP_COMMAND "\"${ZIP_EXECUTABLE}\" -r \"<ARCHIVE>\" . -i@<FILELIST>")
+ set(CPACK_ZIP_NEED_QUOTES FALSE)
+ endif()
+endif()
diff --git a/Modules/NSIS.InstallOptions.ini.in b/Modules/Internal/CPack/NSIS.InstallOptions.ini.in
index d92d77959..d92d77959 100644
--- a/Modules/NSIS.InstallOptions.ini.in
+++ b/Modules/Internal/CPack/NSIS.InstallOptions.ini.in
diff --git a/Modules/Internal/CPack/NSIS.template.in b/Modules/Internal/CPack/NSIS.template.in
new file mode 100644
index 000000000..f75ae7836
--- /dev/null
+++ b/Modules/Internal/CPack/NSIS.template.in
@@ -0,0 +1,972 @@
+; CPack install script designed for a nmake build
+
+;--------------------------------
+; You must define these values
+
+ !define VERSION "@CPACK_PACKAGE_VERSION@"
+ !define PATCH "@CPACK_PACKAGE_VERSION_PATCH@"
+ !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
+
+;--------------------------------
+;Variables
+
+ Var MUI_TEMP
+ Var STARTMENU_FOLDER
+ Var SV_ALLUSERS
+ Var START_MENU
+ Var DO_NOT_ADD_TO_PATH
+ Var ADD_TO_PATH_ALL_USERS
+ Var ADD_TO_PATH_CURRENT_USER
+ Var INSTALL_DESKTOP
+ Var IS_DEFAULT_INSTALLDIR
+;--------------------------------
+;Include Modern UI
+
+ !include "MUI.nsh"
+
+ ;Default installation folder
+ InstallDir "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
+
+;--------------------------------
+;General
+
+ ;Name and file
+ Name "@CPACK_NSIS_PACKAGE_NAME@"
+ OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
+
+ ;Set compression
+ SetCompressor @CPACK_NSIS_COMPRESSOR@
+
+ ;Require administrator access
+ RequestExecutionLevel admin
+
+@CPACK_NSIS_DEFINES@
+
+ !include Sections.nsh
+
+;--- Component support macros: ---
+; The code for the add/remove functionality is from:
+; http://nsis.sourceforge.net/Add/Remove_Functionality
+; It has been modified slightly and extended to provide
+; inter-component dependencies.
+Var AR_SecFlags
+Var AR_RegFlags
+@CPACK_NSIS_SECTION_SELECTED_VARS@
+
+; Loads the "selected" flag for the section named SecName into the
+; variable VarName.
+!macro LoadSectionSelectedIntoVar SecName VarName
+ SectionGetFlags ${${SecName}} $${VarName}
+ IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits
+!macroend
+
+; Loads the value of a variable... can we get around this?
+!macro LoadVar VarName
+ IntOp $R0 0 + $${VarName}
+!macroend
+
+; Sets the value of a variable
+!macro StoreVar VarName IntValue
+ IntOp $${VarName} 0 + ${IntValue}
+!macroend
+
+!macro InitSection SecName
+ ; This macro reads component installed flag from the registry and
+ ;changes checked state of the section on the components page.
+ ;Input: section index constant name specified in Section command.
+
+ ClearErrors
+ ;Reading component status from registry
+ ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" "Installed"
+ IfErrors "default_${SecName}"
+ ;Status will stay default if registry value not found
+ ;(component was never installed)
+ IntOp $AR_RegFlags $AR_RegFlags & ${SF_SELECTED} ;Turn off all other bits
+ SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading default section flags
+ IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE ;Turn lowest (enabled) bit off
+ IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags ;Change lowest bit
+
+ ; Note whether this component was installed before
+ !insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags
+ IntOp $R0 $AR_RegFlags & $AR_RegFlags
+
+ ;Writing modified flags
+ SectionSetFlags ${${SecName}} $AR_SecFlags
+
+ "default_${SecName}:"
+ !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
+!macroend
+
+!macro FinishSection SecName
+ ; This macro reads section flag set by user and removes the section
+ ;if it is not selected.
+ ;Then it writes component installed flag to registry
+ ;Input: section index constant name specified in Section command.
+
+ SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags
+ ;Checking lowest bit:
+ IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED}
+ IntCmp $AR_SecFlags 1 "leave_${SecName}"
+ ;Section is not selected:
+ ;Calling Section uninstall macro and writing zero installed flag
+ !insertmacro "Remove_${${SecName}}"
+ WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \
+ "Installed" 0
+ Goto "exit_${SecName}"
+
+ "leave_${SecName}:"
+ ;Section is selected:
+ WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \
+ "Installed" 1
+
+ "exit_${SecName}:"
+!macroend
+
+!macro RemoveSection_CPack SecName
+ ; This macro is used to call section's Remove_... macro
+ ;from the uninstaller.
+ ;Input: section index constant name specified in Section command.
+
+ !insertmacro "Remove_${${SecName}}"
+!macroend
+
+; Determine whether the selection of SecName changed
+!macro MaybeSelectionChanged SecName
+ !insertmacro LoadVar ${SecName}_selected
+ SectionGetFlags ${${SecName}} $R1
+ IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits
+
+ ; See if the status has changed:
+ IntCmp $R0 $R1 "${SecName}_unchanged"
+ !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
+
+ IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected"
+ !insertmacro "Deselect_required_by_${SecName}"
+ goto "${SecName}_unchanged"
+
+ "${SecName}_was_selected:"
+ !insertmacro "Select_${SecName}_depends"
+
+ "${SecName}_unchanged:"
+!macroend
+;--- End of Add/Remove macros ---
+
+;--------------------------------
+;Interface Settings
+
+ !define MUI_HEADERIMAGE
+ !define MUI_ABORTWARNING
+
+;----------------------------------------
+; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02"
+;----------------------------------------
+!verbose 3
+!include "WinMessages.NSH"
+!verbose 4
+;====================================================
+; get_NT_environment
+; Returns: the selected environment
+; Output : head of the stack
+;====================================================
+!macro select_NT_profile UN
+Function ${UN}select_NT_profile
+ StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 environment_single
+ DetailPrint "Selected environment for all users"
+ Push "all"
+ Return
+ environment_single:
+ DetailPrint "Selected environment for current user only."
+ Push "current"
+ Return
+FunctionEnd
+!macroend
+!insertmacro select_NT_profile ""
+!insertmacro select_NT_profile "un."
+;----------------------------------------------------
+!define NT_current_env 'HKCU "Environment"'
+!define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
+
+!ifndef WriteEnvStr_RegKey
+ !ifdef ALL_USERS
+ !define WriteEnvStr_RegKey \
+ 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
+ !else
+ !define WriteEnvStr_RegKey 'HKCU "Environment"'
+ !endif
+!endif
+
+; AddToPath - Adds the given dir to the search path.
+; Input - head of the stack
+; Note - Win9x systems requires reboot
+
+Function AddToPath
+ Exch $0
+ Push $1
+ Push $2
+ Push $3
+
+ # don't add if the path doesn't exist
+ IfFileExists "$0\*.*" "" AddToPath_done
+
+ ReadEnvStr $1 PATH
+ ; if the path is too long for a NSIS variable NSIS will return a 0
+ ; length string. If we find that, then warn and skip any path
+ ; modification as it will trash the existing path.
+ StrLen $2 $1
+ IntCmp $2 0 CheckPathLength_ShowPathWarning CheckPathLength_Done CheckPathLength_Done
+ CheckPathLength_ShowPathWarning:
+ Messagebox MB_OK|MB_ICONEXCLAMATION "Warning! PATH too long installer unable to modify PATH!"
+ Goto AddToPath_done
+ CheckPathLength_Done:
+ Push "$1;"
+ Push "$0;"
+ Call StrStr
+ Pop $2
+ StrCmp $2 "" "" AddToPath_done
+ Push "$1;"
+ Push "$0\;"
+ Call StrStr
+ Pop $2
+ StrCmp $2 "" "" AddToPath_done
+ GetFullPathName /SHORT $3 $0
+ Push "$1;"
+ Push "$3;"
+ Call StrStr
+ Pop $2
+ StrCmp $2 "" "" AddToPath_done
+ Push "$1;"
+ Push "$3\;"
+ Call StrStr
+ Pop $2
+ StrCmp $2 "" "" AddToPath_done
+
+ Call IsNT
+ Pop $1
+ StrCmp $1 1 AddToPath_NT
+ ; Not on NT
+ StrCpy $1 $WINDIR 2
+ FileOpen $1 "$1\autoexec.bat" a
+ FileSeek $1 -1 END
+ FileReadByte $1 $2
+ IntCmp $2 26 0 +2 +2 # DOS EOF
+ FileSeek $1 -1 END # write over EOF
+ FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
+ FileClose $1
+ SetRebootFlag true
+ Goto AddToPath_done
+
+ AddToPath_NT:
+ StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey
+ ReadRegStr $1 ${NT_current_env} "PATH"
+ Goto DoTrim
+ ReadAllKey:
+ ReadRegStr $1 ${NT_all_env} "PATH"
+ DoTrim:
+ StrCmp $1 "" AddToPath_NTdoIt
+ Push $1
+ Call Trim
+ Pop $1
+ StrCpy $0 "$1;$0"
+ AddToPath_NTdoIt:
+ StrCmp $ADD_TO_PATH_ALL_USERS "1" WriteAllKey
+ WriteRegExpandStr ${NT_current_env} "PATH" $0
+ Goto DoSend
+ WriteAllKey:
+ WriteRegExpandStr ${NT_all_env} "PATH" $0
+ DoSend:
+ SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
+
+ AddToPath_done:
+ Pop $3
+ Pop $2
+ Pop $1
+ Pop $0
+FunctionEnd
+
+
+; RemoveFromPath - Remove a given dir from the path
+; Input: head of the stack
+
+Function un.RemoveFromPath
+ Exch $0
+ Push $1
+ Push $2
+ Push $3
+ Push $4
+ Push $5
+ Push $6
+
+ IntFmt $6 "%c" 26 # DOS EOF
+
+ Call un.IsNT
+ Pop $1
+ StrCmp $1 1 unRemoveFromPath_NT
+ ; Not on NT
+ StrCpy $1 $WINDIR 2
+ FileOpen $1 "$1\autoexec.bat" r
+ GetTempFileName $4
+ FileOpen $2 $4 w
+ GetFullPathName /SHORT $0 $0
+ StrCpy $0 "SET PATH=%PATH%;$0"
+ Goto unRemoveFromPath_dosLoop
+
+ unRemoveFromPath_dosLoop:
+ FileRead $1 $3
+ StrCpy $5 $3 1 -1 # read last char
+ StrCmp $5 $6 0 +2 # if DOS EOF
+ StrCpy $3 $3 -1 # remove DOS EOF so we can compare
+ StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
+ StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
+ StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
+ StrCmp $3 "" unRemoveFromPath_dosLoopEnd
+ FileWrite $2 $3
+ Goto unRemoveFromPath_dosLoop
+ unRemoveFromPath_dosLoopRemoveLine:
+ SetRebootFlag true
+ Goto unRemoveFromPath_dosLoop
+
+ unRemoveFromPath_dosLoopEnd:
+ FileClose $2
+ FileClose $1
+ StrCpy $1 $WINDIR 2
+ Delete "$1\autoexec.bat"
+ CopyFiles /SILENT $4 "$1\autoexec.bat"
+ Delete $4
+ Goto unRemoveFromPath_done
+
+ unRemoveFromPath_NT:
+ StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey
+ ReadRegStr $1 ${NT_current_env} "PATH"
+ Goto unDoTrim
+ unReadAllKey:
+ ReadRegStr $1 ${NT_all_env} "PATH"
+ unDoTrim:
+ StrCpy $5 $1 1 -1 # copy last char
+ StrCmp $5 ";" +2 # if last char != ;
+ StrCpy $1 "$1;" # append ;
+ Push $1
+ Push "$0;"
+ Call un.StrStr ; Find `$0;` in $1
+ Pop $2 ; pos of our dir
+ StrCmp $2 "" unRemoveFromPath_done
+ ; else, it is in path
+ # $0 - path to add
+ # $1 - path var
+ StrLen $3 "$0;"
+ StrLen $4 $2
+ StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
+ StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
+ StrCpy $3 $5$6
+
+ StrCpy $5 $3 1 -1 # copy last char
+ StrCmp $5 ";" 0 +2 # if last char == ;
+ StrCpy $3 $3 -1 # remove last char
+
+ StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey
+ WriteRegExpandStr ${NT_current_env} "PATH" $3
+ Goto unDoSend
+ unWriteAllKey:
+ WriteRegExpandStr ${NT_all_env} "PATH" $3
+ unDoSend:
+ SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
+
+ unRemoveFromPath_done:
+ Pop $6
+ Pop $5
+ Pop $4
+ Pop $3
+ Pop $2
+ Pop $1
+ Pop $0
+FunctionEnd
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Uninstall sutff
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+###########################################
+# Utility Functions #
+###########################################
+
+;====================================================
+; IsNT - Returns 1 if the current system is NT, 0
+; otherwise.
+; Output: head of the stack
+;====================================================
+; IsNT
+; no input
+; output, top of the stack = 1 if NT or 0 if not
+;
+; Usage:
+; Call IsNT
+; Pop $R0
+; ($R0 at this point is 1 or 0)
+
+!macro IsNT un
+Function ${un}IsNT
+ Push $0
+ ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
+ StrCmp $0 "" 0 IsNT_yes
+ ; we are not NT.
+ Pop $0
+ Push 0
+ Return
+
+ IsNT_yes:
+ ; NT!!!
+ Pop $0
+ Push 1
+FunctionEnd
+!macroend
+!insertmacro IsNT ""
+!insertmacro IsNT "un."
+
+; StrStr
+; input, top of stack = string to search for
+; top of stack-1 = string to search in
+; output, top of stack (replaces with the portion of the string remaining)
+; modifies no other variables.
+;
+; Usage:
+; Push "this is a long ass string"
+; Push "ass"
+; Call StrStr
+; Pop $R0
+; ($R0 at this point is "ass string")
+
+!macro StrStr un
+Function ${un}StrStr
+Exch $R1 ; st=haystack,old$R1, $R1=needle
+ Exch ; st=old$R1,haystack
+ Exch $R2 ; st=old$R1,old$R2, $R2=haystack
+ Push $R3
+ Push $R4
+ Push $R5
+ StrLen $R3 $R1
+ StrCpy $R4 0
+ ; $R1=needle
+ ; $R2=haystack
+ ; $R3=len(needle)
+ ; $R4=cnt
+ ; $R5=tmp
+ loop:
+ StrCpy $R5 $R2 $R3 $R4
+ StrCmp $R5 $R1 done
+ StrCmp $R5 "" done
+ IntOp $R4 $R4 + 1
+ Goto loop
+done:
+ StrCpy $R1 $R2 "" $R4
+ Pop $R5
+ Pop $R4
+ Pop $R3
+ Pop $R2
+ Exch $R1
+FunctionEnd
+!macroend
+!insertmacro StrStr ""
+!insertmacro StrStr "un."
+
+Function Trim ; Added by Pelaca
+ Exch $R1
+ Push $R2
+Loop:
+ StrCpy $R2 "$R1" 1 -1
+ StrCmp "$R2" " " RTrim
+ StrCmp "$R2" "$\n" RTrim
+ StrCmp "$R2" "$\r" RTrim
+ StrCmp "$R2" ";" RTrim
+ GoTo Done
+RTrim:
+ StrCpy $R1 "$R1" -1
+ Goto Loop
+Done:
+ Pop $R2
+ Exch $R1
+FunctionEnd
+
+Function ConditionalAddToRegisty
+ Pop $0
+ Pop $1
+ StrCmp "$0" "" ConditionalAddToRegisty_EmptyString
+ WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" \
+ "$1" "$0"
+ ;MessageBox MB_OK "Set Registry: '$1' to '$0'"
+ DetailPrint "Set install registry entry: '$1' to '$0'"
+ ConditionalAddToRegisty_EmptyString:
+FunctionEnd
+
+;--------------------------------
+
+!ifdef CPACK_USES_DOWNLOAD
+Function DownloadFile
+ IfFileExists $INSTDIR\* +2
+ CreateDirectory $INSTDIR
+ Pop $0
+
+ ; Skip if already downloaded
+ IfFileExists $INSTDIR\$0 0 +2
+ Return
+
+ StrCpy $1 "@CPACK_DOWNLOAD_SITE@"
+
+ try_again:
+ NSISdl::download "$1/$0" "$INSTDIR\$0"
+
+ Pop $1
+ StrCmp $1 "success" success
+ StrCmp $1 "Cancelled" cancel
+ MessageBox MB_OK "Download failed: $1"
+ cancel:
+ Return
+ success:
+FunctionEnd
+!endif
+
+;--------------------------------
+; Installation types
+@CPACK_NSIS_INSTALLATION_TYPES@
+
+;--------------------------------
+; Component sections
+@CPACK_NSIS_COMPONENT_SECTIONS@
+
+;--------------------------------
+; Define some macro setting for the gui
+@CPACK_NSIS_INSTALLER_MUI_ICON_CODE@
+@CPACK_NSIS_INSTALLER_ICON_CODE@
+@CPACK_NSIS_INSTALLER_MUI_WELCOMEFINISH_CODE@
+@CPACK_NSIS_INSTALLER_MUI_UNWELCOMEFINISH_CODE@
+@CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@
+@CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@
+
+;--------------------------------
+;Pages
+ !insertmacro MUI_PAGE_WELCOME
+
+ !insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@"
+ Page custom InstallOptionsPage
+ !insertmacro MUI_PAGE_DIRECTORY
+
+ ;Start Menu Folder Page Configuration
+ !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
+ !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
+ !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
+ !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
+
+ @CPACK_NSIS_PAGE_COMPONENTS@
+
+ !insertmacro MUI_PAGE_INSTFILES
+ !insertmacro MUI_PAGE_FINISH
+
+ !insertmacro MUI_UNPAGE_CONFIRM
+ !insertmacro MUI_UNPAGE_INSTFILES
+
+;--------------------------------
+;Languages
+
+ !insertmacro MUI_LANGUAGE "English" ;first language is the default language
+ !insertmacro MUI_LANGUAGE "Albanian"
+ !insertmacro MUI_LANGUAGE "Arabic"
+ !insertmacro MUI_LANGUAGE "Basque"
+ !insertmacro MUI_LANGUAGE "Belarusian"
+ !insertmacro MUI_LANGUAGE "Bosnian"
+ !insertmacro MUI_LANGUAGE "Breton"
+ !insertmacro MUI_LANGUAGE "Bulgarian"
+ !insertmacro MUI_LANGUAGE "Croatian"
+ !insertmacro MUI_LANGUAGE "Czech"
+ !insertmacro MUI_LANGUAGE "Danish"
+ !insertmacro MUI_LANGUAGE "Dutch"
+ !insertmacro MUI_LANGUAGE "Estonian"
+ !insertmacro MUI_LANGUAGE "Farsi"
+ !insertmacro MUI_LANGUAGE "Finnish"
+ !insertmacro MUI_LANGUAGE "French"
+ !insertmacro MUI_LANGUAGE "German"
+ !insertmacro MUI_LANGUAGE "Greek"
+ !insertmacro MUI_LANGUAGE "Hebrew"
+ !insertmacro MUI_LANGUAGE "Hungarian"
+ !insertmacro MUI_LANGUAGE "Icelandic"
+ !insertmacro MUI_LANGUAGE "Indonesian"
+ !insertmacro MUI_LANGUAGE "Irish"
+ !insertmacro MUI_LANGUAGE "Italian"
+ !insertmacro MUI_LANGUAGE "Japanese"
+ !insertmacro MUI_LANGUAGE "Korean"
+ !insertmacro MUI_LANGUAGE "Kurdish"
+ !insertmacro MUI_LANGUAGE "Latvian"
+ !insertmacro MUI_LANGUAGE "Lithuanian"
+ !insertmacro MUI_LANGUAGE "Luxembourgish"
+ !insertmacro MUI_LANGUAGE "Macedonian"
+ !insertmacro MUI_LANGUAGE "Malay"
+ !insertmacro MUI_LANGUAGE "Mongolian"
+ !insertmacro MUI_LANGUAGE "Norwegian"
+ !insertmacro MUI_LANGUAGE "Polish"
+ !insertmacro MUI_LANGUAGE "Portuguese"
+ !insertmacro MUI_LANGUAGE "PortugueseBR"
+ !insertmacro MUI_LANGUAGE "Romanian"
+ !insertmacro MUI_LANGUAGE "Russian"
+ !insertmacro MUI_LANGUAGE "Serbian"
+ !insertmacro MUI_LANGUAGE "SerbianLatin"
+ !insertmacro MUI_LANGUAGE "SimpChinese"
+ !insertmacro MUI_LANGUAGE "Slovak"
+ !insertmacro MUI_LANGUAGE "Slovenian"
+ !insertmacro MUI_LANGUAGE "Spanish"
+ !insertmacro MUI_LANGUAGE "Swedish"
+ !insertmacro MUI_LANGUAGE "Thai"
+ !insertmacro MUI_LANGUAGE "TradChinese"
+ !insertmacro MUI_LANGUAGE "Turkish"
+ !insertmacro MUI_LANGUAGE "Ukrainian"
+ !insertmacro MUI_LANGUAGE "Welsh"
+
+
+;--------------------------------
+;Reserve Files
+
+ ;These files should be inserted before other files in the data block
+ ;Keep these lines before any File command
+ ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
+
+ ReserveFile "NSIS.InstallOptions.ini"
+ !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
+
+;--------------------------------
+;Installer Sections
+
+Section "-Core installation"
+ ;Use the entire tree produced by the INSTALL target. Keep the
+ ;list of directories here in sync with the RMDir commands below.
+ SetOutPath "$INSTDIR"
+ @CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@
+ @CPACK_NSIS_FULL_INSTALL@
+
+ ;Store installation folder
+ WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
+
+ ;Create uninstaller
+ WriteUninstaller "$INSTDIR\Uninstall.exe"
+ Push "DisplayName"
+ Push "@CPACK_NSIS_DISPLAY_NAME@"
+ Call ConditionalAddToRegisty
+ Push "DisplayVersion"
+ Push "@CPACK_PACKAGE_VERSION@"
+ Call ConditionalAddToRegisty
+ Push "Publisher"
+ Push "@CPACK_PACKAGE_VENDOR@"
+ Call ConditionalAddToRegisty
+ Push "UninstallString"
+ Push "$INSTDIR\Uninstall.exe"
+ Call ConditionalAddToRegisty
+ Push "NoRepair"
+ Push "1"
+ Call ConditionalAddToRegisty
+
+ !ifdef CPACK_NSIS_ADD_REMOVE
+ ;Create add/remove functionality
+ Push "ModifyPath"
+ Push "$INSTDIR\AddRemove.exe"
+ Call ConditionalAddToRegisty
+ !else
+ Push "NoModify"
+ Push "1"
+ Call ConditionalAddToRegisty
+ !endif
+
+ ; Optional registration
+ Push "DisplayIcon"
+ Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
+ Call ConditionalAddToRegisty
+ Push "HelpLink"
+ Push "@CPACK_NSIS_HELP_LINK@"
+ Call ConditionalAddToRegisty
+ Push "URLInfoAbout"
+ Push "@CPACK_NSIS_URL_INFO_ABOUT@"
+ Call ConditionalAddToRegisty
+ Push "Contact"
+ Push "@CPACK_NSIS_CONTACT@"
+ Call ConditionalAddToRegisty
+ !insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State"
+ !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
+
+ ;Create shortcuts
+ CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
+@CPACK_NSIS_CREATE_ICONS@
+@CPACK_NSIS_CREATE_ICONS_EXTRA@
+ CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
+
+ ;Read a value from an InstallOptions INI file
+ !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State"
+ !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State"
+ !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State"
+
+ ; Write special uninstall registry entries
+ Push "StartMenu"
+ Push "$STARTMENU_FOLDER"
+ Call ConditionalAddToRegisty
+ Push "DoNotAddToPath"
+ Push "$DO_NOT_ADD_TO_PATH"
+ Call ConditionalAddToRegisty
+ Push "AddToPathAllUsers"
+ Push "$ADD_TO_PATH_ALL_USERS"
+ Call ConditionalAddToRegisty
+ Push "AddToPathCurrentUser"
+ Push "$ADD_TO_PATH_CURRENT_USER"
+ Call ConditionalAddToRegisty
+ Push "InstallToDesktop"
+ Push "$INSTALL_DESKTOP"
+ Call ConditionalAddToRegisty
+
+ !insertmacro MUI_STARTMENU_WRITE_END
+
+@CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
+
+SectionEnd
+
+Section "-Add to path"
+ Push $INSTDIR\bin
+ StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath
+ StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0
+ Call AddToPath
+ doNotAddToPath:
+SectionEnd
+
+;--------------------------------
+; Create custom pages
+Function InstallOptionsPage
+ !insertmacro MUI_HEADER_TEXT "Install Options" "Choose options for installing @CPACK_NSIS_PACKAGE_NAME@"
+ !insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
+
+FunctionEnd
+
+;--------------------------------
+; determine admin versus local install
+Function un.onInit
+
+ ClearErrors
+ UserInfo::GetName
+ IfErrors noLM
+ Pop $0
+ UserInfo::GetAccountType
+ Pop $1
+ StrCmp $1 "Admin" 0 +3
+ SetShellVarContext all
+ ;MessageBox MB_OK 'User "$0" is in the Admin group'
+ Goto done
+ StrCmp $1 "Power" 0 +3
+ SetShellVarContext all
+ ;MessageBox MB_OK 'User "$0" is in the Power Users group'
+ Goto done
+
+ noLM:
+ ;Get installation folder from registry if available
+
+ done:
+
+FunctionEnd
+
+;--- Add/Remove callback functions: ---
+!macro SectionList MacroName
+ ;This macro used to perform operation on multiple sections.
+ ;List all of your components in following manner here.
+@CPACK_NSIS_COMPONENT_SECTION_LIST@
+!macroend
+
+Section -FinishComponents
+ ;Removes unselected components and writes component status to registry
+ !insertmacro SectionList "FinishSection"
+
+!ifdef CPACK_NSIS_ADD_REMOVE
+ ; Get the name of the installer executable
+ System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
+ StrCpy $R3 $R0
+
+ ; Strip off the last 13 characters, to see if we have AddRemove.exe
+ StrLen $R1 $R0
+ IntOp $R1 $R0 - 13
+ StrCpy $R2 $R0 13 $R1
+ StrCmp $R2 "AddRemove.exe" addremove_installed
+
+ ; We're not running AddRemove.exe, so install it
+ CopyFiles $R3 $INSTDIR\AddRemove.exe
+
+ addremove_installed:
+!endif
+SectionEnd
+;--- End of Add/Remove callback functions ---
+
+;--------------------------------
+; Component dependencies
+Function .onSelChange
+ !insertmacro SectionList MaybeSelectionChanged
+FunctionEnd
+
+;--------------------------------
+;Uninstaller Section
+
+Section "Uninstall"
+ ReadRegStr $START_MENU SHCTX \
+ "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu"
+ ;MessageBox MB_OK "Start menu is in: $START_MENU"
+ ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \
+ "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "DoNotAddToPath"
+ ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \
+ "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathAllUsers"
+ ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \
+ "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathCurrentUser"
+ ;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS"
+ ReadRegStr $INSTALL_DESKTOP SHCTX \
+ "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "InstallToDesktop"
+ ;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP "
+
+@CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@
+
+ ;Remove files we installed.
+ ;Keep the list of directories here in sync with the File commands above.
+@CPACK_NSIS_DELETE_FILES@
+@CPACK_NSIS_DELETE_DIRECTORIES@
+
+!ifdef CPACK_NSIS_ADD_REMOVE
+ ;Remove the add/remove program
+ Delete "$INSTDIR\AddRemove.exe"
+!endif
+
+ ;Remove the uninstaller itself.
+ Delete "$INSTDIR\Uninstall.exe"
+ DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
+
+ ;Remove the installation directory if it is empty.
+ RMDir "$INSTDIR"
+
+ ; Remove the registry entries.
+ DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
+
+ ; Removes all optional components
+ !insertmacro SectionList "RemoveSection_CPack"
+
+ !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
+
+ Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
+@CPACK_NSIS_DELETE_ICONS@
+@CPACK_NSIS_DELETE_ICONS_EXTRA@
+
+ ;Delete empty start menu parent directories
+ StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
+
+ startMenuDeleteLoop:
+ ClearErrors
+ RMDir $MUI_TEMP
+ GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
+
+ IfErrors startMenuDeleteLoopDone
+
+ StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop
+ startMenuDeleteLoopDone:
+
+ ; If the user changed the shortcut, then untinstall may not work. This should
+ ; try to fix it.
+ StrCpy $MUI_TEMP "$START_MENU"
+ Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
+@CPACK_NSIS_DELETE_ICONS_EXTRA@
+
+ ;Delete empty start menu parent directories
+ StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
+
+ secondStartMenuDeleteLoop:
+ ClearErrors
+ RMDir $MUI_TEMP
+ GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
+
+ IfErrors secondStartMenuDeleteLoopDone
+
+ StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop
+ secondStartMenuDeleteLoopDone:
+
+ DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
+
+ Push $INSTDIR\bin
+ StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0
+ Call un.RemoveFromPath
+ doNotRemoveFromPath:
+SectionEnd
+
+;--------------------------------
+; determine admin versus local install
+; Is install for "AllUsers" or "JustMe"?
+; Default to "JustMe" - set to "AllUsers" if admin or on Win9x
+; This function is used for the very first "custom page" of the installer.
+; This custom page does not show up visibly, but it executes prior to the
+; first visible page and sets up $INSTDIR properly...
+; Choose different default installation folder based on SV_ALLUSERS...
+; "Program Files" for AllUsers, "My Documents" for JustMe...
+
+Function .onInit
+ StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst
+
+ ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString"
+ StrCmp $0 "" inst
+
+ MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
+ "@CPACK_NSIS_PACKAGE_NAME@ is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \
+ /SD IDYES IDYES uninst IDNO inst
+ Abort
+
+;Run the uninstaller
+uninst:
+ ClearErrors
+ StrLen $2 "\Uninstall.exe"
+ StrCpy $3 $0 -$2 # remove "\Uninstall.exe" from UninstallString to get path
+ ExecWait '"$0" /S _?=$3' ;Do not copy the uninstaller to a temp file
+
+ IfErrors uninst_failed inst
+uninst_failed:
+ MessageBox MB_OK|MB_ICONSTOP "Uninstall failed."
+ Abort
+
+
+inst:
+ ; Reads components status for registry
+ !insertmacro SectionList "InitSection"
+
+ ; check to see if /D has been used to change
+ ; the install directory by comparing it to the
+ ; install directory that is expected to be the
+ ; default
+ StrCpy $IS_DEFAULT_INSTALLDIR 0
+ StrCmp "$INSTDIR" "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2
+ StrCpy $IS_DEFAULT_INSTALLDIR 1
+
+ StrCpy $SV_ALLUSERS "JustMe"
+ ; if default install dir then change the default
+ ; if it is installed for JustMe
+ StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
+ StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
+
+ ClearErrors
+ UserInfo::GetName
+ IfErrors noLM
+ Pop $0
+ UserInfo::GetAccountType
+ Pop $1
+ StrCmp $1 "Admin" 0 +4
+ SetShellVarContext all
+ ;MessageBox MB_OK 'User "$0" is in the Admin group'
+ StrCpy $SV_ALLUSERS "AllUsers"
+ Goto done
+ StrCmp $1 "Power" 0 +4
+ SetShellVarContext all
+ ;MessageBox MB_OK 'User "$0" is in the Power Users group'
+ StrCpy $SV_ALLUSERS "AllUsers"
+ Goto done
+
+ noLM:
+ StrCpy $SV_ALLUSERS "AllUsers"
+ ;Get installation folder from registry if available
+
+ done:
+ StrCmp $SV_ALLUSERS "AllUsers" 0 +3
+ StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
+ StrCpy $INSTDIR "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
+
+ StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage
+ !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
+
+ noOptionsPage:
+FunctionEnd
diff --git a/Modules/WIX.template.in b/Modules/Internal/CPack/WIX.template.in
index c4fc83afa..c4fc83afa 100644
--- a/Modules/WIX.template.in
+++ b/Modules/Internal/CPack/WIX.template.in
diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake
index de336e708..75be473f3 100644
--- a/Modules/Internal/FeatureTesting.cmake
+++ b/Modules/Internal/FeatureTesting.cmake
@@ -71,10 +71,35 @@ endmacro()
macro(_record_compiler_features_c std)
list(APPEND CMAKE_C${std}_COMPILE_FEATURES c_std_${std})
- _record_compiler_features(C "${CMAKE_C${std}_STANDARD_COMPILE_OPTION}" CMAKE_C${std}_COMPILE_FEATURES)
+
+ get_property(lang_level_has_features GLOBAL PROPERTY CMAKE_C${std}_KNOWN_FEATURES)
+ if(lang_level_has_features)
+ _record_compiler_features(C "${CMAKE_C${std}_STANDARD_COMPILE_OPTION}" CMAKE_C${std}_COMPILE_FEATURES)
+ endif()
+ unset(lang_level_has_features)
endmacro()
macro(_record_compiler_features_cxx std)
list(APPEND CMAKE_CXX${std}_COMPILE_FEATURES cxx_std_${std})
- _record_compiler_features(CXX "${CMAKE_CXX${std}_STANDARD_COMPILE_OPTION}" CMAKE_CXX${std}_COMPILE_FEATURES)
+
+ get_property(lang_level_has_features GLOBAL PROPERTY CMAKE_CXX${std}_KNOWN_FEATURES)
+ if(lang_level_has_features)
+ _record_compiler_features(CXX "${CMAKE_CXX${std}_STANDARD_COMPILE_OPTION}" CMAKE_CXX${std}_COMPILE_FEATURES)
+ endif()
+ unset(lang_level_has_features)
+endmacro()
+
+macro(_has_compiler_features lang level compile_flags feature_list)
+ # presume all known features are supported
+ get_property(known_features GLOBAL PROPERTY CMAKE_${lang}${level}_KNOWN_FEATURES)
+ list(APPEND ${feature_list} ${known_features})
+endmacro()
+
+macro(_has_compiler_features_c std)
+ list(APPEND CMAKE_C${std}_COMPILE_FEATURES c_std_${std})
+ _has_compiler_features(C ${std} "${CMAKE_C${std}_STANDARD_COMPILE_OPTION}" CMAKE_C${std}_COMPILE_FEATURES)
+endmacro()
+macro(_has_compiler_features_cxx std)
+ list(APPEND CMAKE_CXX${std}_COMPILE_FEATURES cxx_std_${std})
+ _has_compiler_features(CXX ${std} "${CMAKE_CXX${std}_STANDARD_COMPILE_OPTION}" CMAKE_CXX${std}_COMPILE_FEATURES)
endmacro()
diff --git a/Modules/KDE3Macros.cmake b/Modules/KDE3Macros.cmake
index b3f31ed62..1c353ba84 100644
--- a/Modules/KDE3Macros.cmake
+++ b/Modules/KDE3Macros.cmake
@@ -26,105 +26,106 @@ include(AddFileDependencies)
#create the kidl and skeletion file for dcop stuff
#usage: KDE_ADD_COP_SKELS(foo_SRCS ${dcop_headers})
macro(KDE3_ADD_DCOP_SKELS _sources)
- foreach (_current_FILE ${ARGN})
+ foreach (_current_FILE ${ARGN})
- get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE)
- get_filename_component(_basename ${_tmp_FILE} NAME_WE)
+ get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE)
+ get_filename_component(_basename ${_tmp_FILE} NAME_WE)
- set(_skel ${CMAKE_CURRENT_BINARY_DIR}/${_basename}_skel.cpp)
- set(_kidl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.kidl)
+ set(_skel ${CMAKE_CURRENT_BINARY_DIR}/${_basename}_skel.cpp)
+ set(_kidl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.kidl)
- if (NOT HAVE_${_basename}_KIDL_RULE)
- set(HAVE_${_basename}_KIDL_RULE ON)
+ if (NOT HAVE_${_basename}_KIDL_RULE)
+ set(HAVE_${_basename}_KIDL_RULE ON)
- add_custom_command(OUTPUT ${_kidl}
- COMMAND ${KDE3_DCOPIDL_EXECUTABLE}
- ARGS ${_tmp_FILE} > ${_kidl}
- DEPENDS ${_tmp_FILE}
- )
+ add_custom_command(OUTPUT ${_kidl}
+ COMMAND ${KDE3_DCOPIDL_EXECUTABLE}
+ ARGS ${_tmp_FILE} > ${_kidl}
+ DEPENDS ${_tmp_FILE}
+ )
- endif ()
+ endif ()
- if (NOT HAVE_${_basename}_SKEL_RULE)
- set(HAVE_${_basename}_SKEL_RULE ON)
+ if (NOT HAVE_${_basename}_SKEL_RULE)
+ set(HAVE_${_basename}_SKEL_RULE ON)
- add_custom_command(OUTPUT ${_skel}
- COMMAND ${KDE3_DCOPIDL2CPP_EXECUTABLE}
- ARGS --c++-suffix cpp --no-signals --no-stub ${_kidl}
- DEPENDS ${_kidl}
- )
+ add_custom_command(OUTPUT ${_skel}
+ COMMAND ${KDE3_DCOPIDL2CPP_EXECUTABLE}
+ ARGS --c++-suffix cpp --no-signals --no-stub ${_kidl}
+ DEPENDS ${_kidl}
+ )
- endif ()
+ endif ()
- set(${_sources} ${${_sources}} ${_skel})
+ set(${_sources} ${${_sources}} ${_skel})
- endforeach ()
+ endforeach ()
endmacro()
macro(KDE3_ADD_DCOP_STUBS _sources)
- foreach (_current_FILE ${ARGN})
+ foreach (_current_FILE ${ARGN})
- get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE)
+ get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE)
- get_filename_component(_basename ${_tmp_FILE} NAME_WE)
+ get_filename_component(_basename ${_tmp_FILE} NAME_WE)
- set(_stub_CPP ${CMAKE_CURRENT_BINARY_DIR}/${_basename}_stub.cpp)
- set(_kidl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.kidl)
+ set(_stub_CPP ${CMAKE_CURRENT_BINARY_DIR}/${_basename}_stub.cpp)
+ set(_kidl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.kidl)
- if (NOT HAVE_${_basename}_KIDL_RULE)
- set(HAVE_${_basename}_KIDL_RULE ON)
+ if (NOT HAVE_${_basename}_KIDL_RULE)
+ set(HAVE_${_basename}_KIDL_RULE ON)
- add_custom_command(OUTPUT ${_kidl}
- COMMAND ${KDE3_DCOPIDL_EXECUTABLE}
- ARGS ${_tmp_FILE} > ${_kidl}
- DEPENDS ${_tmp_FILE}
- )
+ add_custom_command(OUTPUT ${_kidl}
+ COMMAND ${KDE3_DCOPIDL_EXECUTABLE}
+ ARGS ${_tmp_FILE} > ${_kidl}
+ DEPENDS ${_tmp_FILE}
+ )
- endif ()
+ endif ()
- if (NOT HAVE_${_basename}_STUB_RULE)
- set(HAVE_${_basename}_STUB_RULE ON)
+ if (NOT HAVE_${_basename}_STUB_RULE)
+ set(HAVE_${_basename}_STUB_RULE ON)
- add_custom_command(OUTPUT ${_stub_CPP}
- COMMAND ${KDE3_DCOPIDL2CPP_EXECUTABLE}
- ARGS --c++-suffix cpp --no-signals --no-skel ${_kidl}
- DEPENDS ${_kidl}
- )
+ add_custom_command(OUTPUT ${_stub_CPP}
+ COMMAND ${KDE3_DCOPIDL2CPP_EXECUTABLE}
+ ARGS --c++-suffix cpp --no-signals --no-skel ${_kidl}
+ DEPENDS ${_kidl}
+ )
- endif ()
+ endif ()
- set(${_sources} ${${_sources}} ${_stub_CPP})
+ set(${_sources} ${${_sources}} ${_stub_CPP})
- endforeach ()
+ endforeach ()
endmacro()
macro(KDE3_ADD_KCFG_FILES _sources)
- foreach (_current_FILE ${ARGN})
+ foreach (_current_FILE ${ARGN})
- get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE)
+ get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE)
- get_filename_component(_basename ${_tmp_FILE} NAME_WE)
+ get_filename_component(_basename ${_tmp_FILE} NAME_WE)
- file(READ ${_tmp_FILE} _contents)
- string(REGEX REPLACE "^(.*\n)?File=([^\n]+)\n.*$" "\\2" _kcfg_FILE "${_contents}")
+ file(READ ${_tmp_FILE} _contents)
+ string(REGEX REPLACE "^(.*\n)?File=([^\n]+)\n.*$" "\\2" _kcfg_FILE "${_contents}")
- set(_src_FILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
- set(_header_FILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
+ set(_src_FILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
+ set(_header_FILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
- add_custom_command(OUTPUT ${_src_FILE}
- COMMAND ${KDE3_KCFGC_EXECUTABLE}
- ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${_kcfg_FILE} ${_tmp_FILE}
- DEPENDS ${_tmp_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/${_kcfg_FILE} )
+ add_custom_command(OUTPUT ${_src_FILE}
+ COMMAND ${KDE3_KCFGC_EXECUTABLE}
+ ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${_kcfg_FILE} ${_tmp_FILE}
+ DEPENDS ${_tmp_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/${_kcfg_FILE}
+ )
- set(${_sources} ${${_sources}} ${_src_FILE})
+ set(${_sources} ${${_sources}} ${_src_FILE})
- endforeach ()
+ endforeach ()
endmacro()
@@ -132,22 +133,22 @@ endmacro()
#create the moc files and add them to the list of sources
#usage: KDE_ADD_MOC_FILES(foo_SRCS ${moc_headers})
macro(KDE3_ADD_MOC_FILES _sources)
- foreach (_current_FILE ${ARGN})
+ foreach (_current_FILE ${ARGN})
- get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE)
+ get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE)
- get_filename_component(_basename ${_tmp_FILE} NAME_WE)
- set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc.cpp)
+ get_filename_component(_basename ${_tmp_FILE} NAME_WE)
+ set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc.cpp)
- add_custom_command(OUTPUT ${_moc}
- COMMAND ${QT_MOC_EXECUTABLE}
- ARGS ${_tmp_FILE} -o ${_moc}
- DEPENDS ${_tmp_FILE}
- )
+ add_custom_command(OUTPUT ${_moc}
+ COMMAND ${QT_MOC_EXECUTABLE}
+ ARGS ${_tmp_FILE} -o ${_moc}
+ DEPENDS ${_tmp_FILE}
+ )
- set(${_sources} ${${_sources}} ${_moc})
+ set(${_sources} ${${_sources}} ${_moc})
- endforeach ()
+ endforeach ()
endmacro()
@@ -156,186 +157,186 @@ get_filename_component( KDE3_MODULE_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
#create the implementation files from the ui files and add them to the list of sources
#usage: KDE_ADD_UI_FILES(foo_SRCS ${ui_files})
macro(KDE3_ADD_UI_FILES _sources )
- foreach (_current_FILE ${ARGN})
-
- get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE)
-
- get_filename_component(_basename ${_tmp_FILE} NAME_WE)
- set(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
- set(_src ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
- set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc.cpp)
-
- add_custom_command(OUTPUT ${_header}
- COMMAND ${QT_UIC_EXECUTABLE}
- ARGS -L ${KDE3_LIB_DIR}/kde3/plugins/designer -nounload -o ${_header} ${CMAKE_CURRENT_SOURCE_DIR}/${_current_FILE}
- DEPENDS ${_tmp_FILE}
- )
-
- add_custom_command(OUTPUT ${_src}
- COMMAND ${CMAKE_COMMAND}
- ARGS
- -DKDE_UIC_PLUGIN_DIR:FILEPATH=${KDE3_LIB_DIR}/kde3/plugins/designer
- -DKDE_UIC_EXECUTABLE:FILEPATH=${QT_UIC_EXECUTABLE}
- -DKDE_UIC_FILE:FILEPATH=${_tmp_FILE}
- -DKDE_UIC_CPP_FILE:FILEPATH=${_src}
- -DKDE_UIC_H_FILE:FILEPATH=${_header}
- -P ${KDE3_MODULE_DIR}/kde3uic.cmake
- DEPENDS ${_header}
- )
-
- add_custom_command(OUTPUT ${_moc}
- COMMAND ${QT_MOC_EXECUTABLE}
- ARGS ${_header} -o ${_moc}
- DEPENDS ${_header}
- )
-
- set(${_sources} ${${_sources}} ${_src} ${_moc} )
-
- endforeach ()
+ foreach (_current_FILE ${ARGN})
+
+ get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE)
+
+ get_filename_component(_basename ${_tmp_FILE} NAME_WE)
+ set(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
+ set(_src ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
+ set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc.cpp)
+
+ add_custom_command(OUTPUT ${_header}
+ COMMAND ${QT_UIC_EXECUTABLE}
+ ARGS -L ${KDE3_LIB_DIR}/kde3/plugins/designer -nounload -o ${_header} ${CMAKE_CURRENT_SOURCE_DIR}/${_current_FILE}
+ DEPENDS ${_tmp_FILE}
+ )
+
+ add_custom_command(OUTPUT ${_src}
+ COMMAND ${CMAKE_COMMAND}
+ ARGS
+ -DKDE_UIC_PLUGIN_DIR:FILEPATH=${KDE3_LIB_DIR}/kde3/plugins/designer
+ -DKDE_UIC_EXECUTABLE:FILEPATH=${QT_UIC_EXECUTABLE}
+ -DKDE_UIC_FILE:FILEPATH=${_tmp_FILE}
+ -DKDE_UIC_CPP_FILE:FILEPATH=${_src}
+ -DKDE_UIC_H_FILE:FILEPATH=${_header}
+ -P ${KDE3_MODULE_DIR}/kde3uic.cmake
+ DEPENDS ${_header}
+ )
+
+ add_custom_command(OUTPUT ${_moc}
+ COMMAND ${QT_MOC_EXECUTABLE}
+ ARGS ${_header} -o ${_moc}
+ DEPENDS ${_header}
+ )
+
+ set(${_sources} ${${_sources}} ${_src} ${_moc} )
+
+ endforeach ()
endmacro()
macro(KDE3_AUTOMOC)
- set(_matching_FILES )
- foreach (_current_FILE ${ARGN})
+ set(_matching_FILES )
+ foreach (_current_FILE ${ARGN})
- get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
+ get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
- # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
- # here. this is required to make bouic work correctly:
- # we need to add generated .cpp files to the sources (to compile them),
- # but we cannot let automoc handle them, as the .cpp files don't exist yet when
- # cmake is run for the very first time on them -> however the .cpp files might
- # exist at a later run. at that time we need to skip them, so that we don't add two
- # different rules for the same moc file
- get_source_file_property(_skip ${_abs_FILE} SKIP_AUTOMOC)
+ # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
+ # here. this is required to make bouic work correctly:
+ # we need to add generated .cpp files to the sources (to compile them),
+ # but we cannot let automoc handle them, as the .cpp files don't exist yet when
+ # cmake is run for the very first time on them -> however the .cpp files might
+ # exist at a later run. at that time we need to skip them, so that we don't add two
+ # different rules for the same moc file
+ get_source_file_property(_skip ${_abs_FILE} SKIP_AUTOMOC)
- if (EXISTS ${_abs_FILE} AND NOT _skip)
+ if (EXISTS ${_abs_FILE} AND NOT _skip)
- file(STRINGS ${_abs_FILE} _match REGEX "#include +[^ ]+\\.moc[\">]")
+ file(STRINGS ${_abs_FILE} _match REGEX "#include +[^ ]+\\.moc[\">]")
- get_filename_component(_abs_PATH ${_abs_FILE} PATH)
+ get_filename_component(_abs_PATH ${_abs_FILE} PATH)
- foreach (_current_MOC_INC IN LISTS _match)
- string(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
+ foreach (_current_MOC_INC IN LISTS _match)
+ string(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
- get_filename_component(_basename ${_current_MOC} NAME_WE)
-# set(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
- set(_header ${_abs_PATH}/${_basename}.h)
- set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
+ get_filename_component(_basename ${_current_MOC} NAME_WE)
+# set(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
+ set(_header ${_abs_PATH}/${_basename}.h)
+ set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
- add_custom_command(OUTPUT ${_moc}
- COMMAND ${QT_MOC_EXECUTABLE}
- ARGS ${_header} -o ${_moc}
- DEPENDS ${_header}
- )
+ add_custom_command(OUTPUT ${_moc}
+ COMMAND ${QT_MOC_EXECUTABLE}
+ ARGS ${_header} -o ${_moc}
+ DEPENDS ${_header}
+ )
- ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
+ ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
- endforeach ()
- unset(_match)
- unset(_header)
- unset(_moc)
- endif ()
- endforeach ()
+ endforeach ()
+ unset(_match)
+ unset(_header)
+ unset(_moc)
+ endif ()
+ endforeach ()
endmacro()
# only used internally by KDE3_INSTALL_ICONS
macro (_KDE3_ADD_ICON_INSTALL_RULE _install_SCRIPT _install_PATH _group _orig_NAME _install_NAME)
- # if the string doesn't match the pattern, the result is the full string, so all three have the same content
- if (NOT ${_group} STREQUAL ${_install_NAME} )
- set(_icon_GROUP "actions")
+ # if the string doesn't match the pattern, the result is the full string, so all three have the same content
+ if (NOT ${_group} STREQUAL ${_install_NAME} )
+ set(_icon_GROUP "actions")
- if (${_group} STREQUAL "mime")
- set(_icon_GROUP "mimetypes")
- endif ()
+ if (${_group} STREQUAL "mime")
+ set(_icon_GROUP "mimetypes")
+ endif ()
- if (${_group} STREQUAL "filesys")
- set(_icon_GROUP "filesystems")
- endif ()
+ if (${_group} STREQUAL "filesys")
+ set(_icon_GROUP "filesystems")
+ endif ()
- if (${_group} STREQUAL "device")
- set(_icon_GROUP "devices")
- endif ()
+ if (${_group} STREQUAL "device")
+ set(_icon_GROUP "devices")
+ endif ()
- if (${_group} STREQUAL "app")
- set(_icon_GROUP "apps")
- endif ()
+ if (${_group} STREQUAL "app")
+ set(_icon_GROUP "apps")
+ endif ()
- if (${_group} STREQUAL "action")
- set(_icon_GROUP "actions")
- endif ()
+ if (${_group} STREQUAL "action")
+ set(_icon_GROUP "actions")
+ endif ()
-# message(STATUS "icon: ${_current_ICON} size: ${_size} group: ${_group} name: ${_name}" )
- install(FILES ${_orig_NAME} DESTINATION ${_install_PATH}/${_icon_GROUP}/ RENAME ${_install_NAME} )
- endif ()
+ # message(STATUS "icon: ${_current_ICON} size: ${_size} group: ${_group} name: ${_name}" )
+ install(FILES ${_orig_NAME} DESTINATION ${_install_PATH}/${_icon_GROUP}/ RENAME ${_install_NAME} )
+ endif ()
endmacro ()
macro (KDE3_INSTALL_ICONS _theme )
- set(_defaultpath "${CMAKE_INSTALL_PREFIX}/share/icons")
- # first the png icons
- file(GLOB _icons *.png)
- foreach (_current_ICON ${_icons} )
- string(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\1" _size "${_current_ICON}")
- string(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\2" _group "${_current_ICON}")
- string(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\3" _name "${_current_ICON}")
- _KDE3_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake
- ${_defaultpath}/${_theme}/${_size}x${_size}
- ${_group} ${_current_ICON} ${_name})
- endforeach ()
-
- # and now the svg icons
- file(GLOB _icons *.svgz)
- foreach (_current_ICON ${_icons} )
- string(REGEX REPLACE "^.*/crsc\\-([a-z]+)\\-(.+\\.svgz)$" "\\1" _group "${_current_ICON}")
- string(REGEX REPLACE "^.*/crsc\\-([a-z]+)\\-(.+\\.svgz)$" "\\2" _name "${_current_ICON}")
- _KDE3_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake
- ${_defaultpath}/${_theme}/scalable
- ${_group} ${_current_ICON} ${_name})
- endforeach ()
+ set(_defaultpath "${CMAKE_INSTALL_PREFIX}/share/icons")
+ # first the png icons
+ file(GLOB _icons *.png)
+ foreach (_current_ICON ${_icons} )
+ string(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\1" _size "${_current_ICON}")
+ string(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\2" _group "${_current_ICON}")
+ string(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\3" _name "${_current_ICON}")
+ _KDE3_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake
+ ${_defaultpath}/${_theme}/${_size}x${_size}
+ ${_group} ${_current_ICON} ${_name})
+ endforeach ()
+
+ # and now the svg icons
+ file(GLOB _icons *.svgz)
+ foreach (_current_ICON ${_icons} )
+ string(REGEX REPLACE "^.*/crsc\\-([a-z]+)\\-(.+\\.svgz)$" "\\1" _group "${_current_ICON}")
+ string(REGEX REPLACE "^.*/crsc\\-([a-z]+)\\-(.+\\.svgz)$" "\\2" _name "${_current_ICON}")
+ _KDE3_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake
+ ${_defaultpath}/${_theme}/scalable
+ ${_group} ${_current_ICON} ${_name})
+ endforeach ()
endmacro ()
macro(KDE3_INSTALL_LIBTOOL_FILE _target)
- get_target_property(_target_location ${_target} LOCATION)
-
- get_filename_component(_laname ${_target_location} NAME_WE)
- get_filename_component(_soname ${_target_location} NAME)
- set(_laname ${CMAKE_CURRENT_BINARY_DIR}/${_laname}.la)
-
- file(WRITE ${_laname} "# ${_laname} - a libtool library file, generated by cmake \n")
- file(APPEND ${_laname} "# The name that we can dlopen(3).\n")
- file(APPEND ${_laname} "dlname='${_soname}'\n")
- file(APPEND ${_laname} "# Names of this library\n")
- if(CYGWIN)
- file(APPEND ${_laname} "library_names='${_soname}'\n")
- else()
- file(APPEND ${_laname} "library_names='${_soname} ${_soname} ${_soname}'\n")
- endif()
- file(APPEND ${_laname} "# The name of the static archive\n")
- file(APPEND ${_laname} "old_library=''\n")
- file(APPEND ${_laname} "# Libraries that this one depends upon.\n")
- file(APPEND ${_laname} "dependency_libs=''\n")
+ get_target_property(_target_location ${_target} LOCATION)
+
+ get_filename_component(_laname ${_target_location} NAME_WE)
+ get_filename_component(_soname ${_target_location} NAME)
+ set(_laname ${CMAKE_CURRENT_BINARY_DIR}/${_laname}.la)
+
+ file(WRITE ${_laname} "# ${_laname} - a libtool library file, generated by cmake \n")
+ file(APPEND ${_laname} "# The name that we can dlopen(3).\n")
+ file(APPEND ${_laname} "dlname='${_soname}'\n")
+ file(APPEND ${_laname} "# Names of this library\n")
+ if(CYGWIN)
+ file(APPEND ${_laname} "library_names='${_soname}'\n")
+ else()
+ file(APPEND ${_laname} "library_names='${_soname} ${_soname} ${_soname}'\n")
+ endif()
+ file(APPEND ${_laname} "# The name of the static archive\n")
+ file(APPEND ${_laname} "old_library=''\n")
+ file(APPEND ${_laname} "# Libraries that this one depends upon.\n")
+ file(APPEND ${_laname} "dependency_libs=''\n")
# file(APPEND ${_laname} "dependency_libs='${${_target}_LIB_DEPENDS}'\n")
- file(APPEND ${_laname} "# Version information.\ncurrent=0\nage=0\nrevision=0\n")
- file(APPEND ${_laname} "# Is this an already installed library?\ninstalled=yes\n")
- file(APPEND ${_laname} "# Should we warn about portability when linking against -modules?\nshouldnotlink=yes\n")
- file(APPEND ${_laname} "# Files to dlopen/dlpreopen\ndlopen=''\ndlpreopen=''\n")
- file(APPEND ${_laname} "# Directory that this library needs to be installed in:\n")
- file(APPEND ${_laname} "libdir='${CMAKE_INSTALL_PREFIX}/lib/kde3'\n")
-
- install_files(${KDE3_LIBTOOL_DIR} FILES ${_laname})
+ file(APPEND ${_laname} "# Version information.\ncurrent=0\nage=0\nrevision=0\n")
+ file(APPEND ${_laname} "# Is this an already installed library?\ninstalled=yes\n")
+ file(APPEND ${_laname} "# Should we warn about portability when linking against -modules?\nshouldnotlink=yes\n")
+ file(APPEND ${_laname} "# Files to dlopen/dlpreopen\ndlopen=''\ndlpreopen=''\n")
+ file(APPEND ${_laname} "# Directory that this library needs to be installed in:\n")
+ file(APPEND ${_laname} "libdir='${CMAKE_INSTALL_PREFIX}/lib/kde3'\n")
+
+ install_files(${KDE3_LIBTOOL_DIR} FILES ${_laname})
endmacro()
macro(KDE3_CREATE_FINAL_FILE _filename)
- file(WRITE ${_filename} "//autogenerated file\n")
- foreach (_current_FILE ${ARGN})
- file(APPEND ${_filename} "#include \"${_current_FILE}\"\n")
- endforeach ()
+ file(WRITE ${_filename} "//autogenerated file\n")
+ foreach (_current_FILE ${ARGN})
+ file(APPEND ${_filename} "#include \"${_current_FILE}\"\n")
+ endforeach ()
endmacro()
@@ -346,24 +347,24 @@ option(KDE3_BUILD_TESTS "Build the tests")
macro(KDE3_ADD_KPART _target_NAME _with_PREFIX)
#is the first argument is "WITH_PREFIX" then keep the standard "lib" prefix, otherwise SET the prefix empty
- if (${_with_PREFIX} STREQUAL "WITH_PREFIX")
- set(_first_SRC)
- else ()
- set(_first_SRC ${_with_PREFIX})
- endif ()
+ if (${_with_PREFIX} STREQUAL "WITH_PREFIX")
+ set(_first_SRC)
+ else ()
+ set(_first_SRC ${_with_PREFIX})
+ endif ()
# if (KDE3_ENABLE_FINAL)
# KDE3_CREATE_FINAL_FILE(${_target_NAME}_final.cpp ${_first_SRC} ${ARGN})
# add_library(${_target_NAME} MODULE ${_target_NAME}_final.cpp)
# else ()
- add_library(${_target_NAME} MODULE ${_first_SRC} ${ARGN})
+ add_library(${_target_NAME} MODULE ${_first_SRC} ${ARGN})
# endif ()
- if(_first_SRC)
- set_target_properties(${_target_NAME} PROPERTIES PREFIX "")
- endif()
+ if(_first_SRC)
+ set_target_properties(${_target_NAME} PROPERTIES PREFIX "")
+ endif()
- KDE3_INSTALL_LIBTOOL_FILE(${_target_NAME})
+ KDE3_INSTALL_LIBTOOL_FILE(${_target_NAME})
endmacro()
@@ -374,13 +375,13 @@ macro(KDE3_ADD_KDEINIT_EXECUTABLE _target_NAME )
# KDE3_CREATE_FINAL_FILE(${_target_NAME}_final.cpp ${ARGN})
# add_library(kdeinit_${_target_NAME} SHARED ${_target_NAME}_final.cpp)
# else ()
- add_library(kdeinit_${_target_NAME} SHARED ${ARGN} )
+ add_library(kdeinit_${_target_NAME} SHARED ${ARGN} )
# endif ()
- configure_file(${KDE3_MODULE_DIR}/kde3init_dummy.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp)
+ configure_file(${KDE3_MODULE_DIR}/kde3init_dummy.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp)
- add_executable( ${_target_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp )
- target_link_libraries( ${_target_NAME} kdeinit_${_target_NAME} )
+ add_executable( ${_target_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp )
+ target_link_libraries( ${_target_NAME} kdeinit_${_target_NAME} )
endmacro()
@@ -391,7 +392,7 @@ macro(KDE3_ADD_EXECUTABLE _target_NAME )
# KDE3_CREATE_FINAL_FILE(${_target_NAME}_final.cpp ${ARGN})
# add_executable(${_target_NAME} ${_target_NAME}_final.cpp)
# else ()
- add_executable(${_target_NAME} ${ARGN} )
+ add_executable(${_target_NAME} ${ARGN} )
# endif ()
endmacro()
diff --git a/Modules/MacroAddFileDependencies.cmake b/Modules/MacroAddFileDependencies.cmake
index db2681478..ca60b5702 100644
--- a/Modules/MacroAddFileDependencies.cmake
+++ b/Modules/MacroAddFileDependencies.cmake
@@ -1,29 +1,30 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# MacroAddFileDependencies
-# ------------------------
-#
-# MACRO_ADD_FILE_DEPENDENCIES(<_file> depend_files...)
-#
-# Using the macro MACRO_ADD_FILE_DEPENDENCIES() is discouraged. There
-# are usually better ways to specify the correct dependencies.
-#
-# MACRO_ADD_FILE_DEPENDENCIES(<_file> depend_files...) is just a
-# convenience wrapper around the OBJECT_DEPENDS source file property.
-# You can just use set_property(SOURCE <file> APPEND PROPERTY
-# OBJECT_DEPENDS depend_files) instead.
+#[=======================================================================[.rst:
+MacroAddFileDependencies
+------------------------
+
+MACRO_ADD_FILE_DEPENDENCIES(<_file> depend_files...)
+
+Using the macro MACRO_ADD_FILE_DEPENDENCIES() is discouraged. There
+are usually better ways to specify the correct dependencies.
+
+MACRO_ADD_FILE_DEPENDENCIES(<_file> depend_files...) is just a
+convenience wrapper around the OBJECT_DEPENDS source file property.
+You can just use set_property(SOURCE <file> APPEND PROPERTY
+OBJECT_DEPENDS depend_files) instead.
+#]=======================================================================]
macro (MACRO_ADD_FILE_DEPENDENCIES _file)
- get_source_file_property(_deps ${_file} OBJECT_DEPENDS)
- if (_deps)
- set(_deps ${_deps} ${ARGN})
- else ()
- set(_deps ${ARGN})
- endif ()
+ get_source_file_property(_deps ${_file} OBJECT_DEPENDS)
+ if (_deps)
+ set(_deps ${_deps} ${ARGN})
+ else ()
+ set(_deps ${ARGN})
+ endif ()
- set_source_files_properties(${_file} PROPERTIES OBJECT_DEPENDS "${_deps}")
+ set_source_files_properties(${_file} PROPERTIES OBJECT_DEPENDS "${_deps}")
endmacro ()
diff --git a/Modules/MatlabTestsRedirect.cmake b/Modules/MatlabTestsRedirect.cmake
index 64d580db6..fc36fc3b4 100644
--- a/Modules/MatlabTestsRedirect.cmake
+++ b/Modules/MatlabTestsRedirect.cmake
@@ -55,11 +55,12 @@ endif()
if(no_unittest_framework)
- set(unittest_to_run "try, ${unittest_file_to_run_name}, catch err, disp('An exception has been thrown during the execution'), disp(err), disp(err.stack), exit(1), end, exit(0)")
+ set(unittest_to_run "${unittest_file_to_run_name}")
endif()
+set(command_to_run "try, ${unittest_to_run}, catch err, disp('An exception has been thrown during the execution'), disp(err), disp(err.stack), exit(1), end, exit(0)")
set(Matlab_SCRIPT_TO_RUN
- "addpath(${concat_string}); ${cmd_to_run_before_test}; ${unittest_to_run}"
+ "addpath(${concat_string}); ${cmd_to_run_before_test}; ${command_to_run}"
)
# if the working directory is not specified then default
# to the output_directory because the log file will go there
diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in
deleted file mode 100644
index 9001888da..000000000
--- a/Modules/NSIS.template.in
+++ /dev/null
@@ -1,972 +0,0 @@
-; CPack install script designed for a nmake build
-
-;--------------------------------
-; You must define these values
-
- !define VERSION "@CPACK_PACKAGE_VERSION@"
- !define PATCH "@CPACK_PACKAGE_VERSION_PATCH@"
- !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@"
-
-;--------------------------------
-;Variables
-
- Var MUI_TEMP
- Var STARTMENU_FOLDER
- Var SV_ALLUSERS
- Var START_MENU
- Var DO_NOT_ADD_TO_PATH
- Var ADD_TO_PATH_ALL_USERS
- Var ADD_TO_PATH_CURRENT_USER
- Var INSTALL_DESKTOP
- Var IS_DEFAULT_INSTALLDIR
-;--------------------------------
-;Include Modern UI
-
- !include "MUI.nsh"
-
- ;Default installation folder
- InstallDir "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
-
-;--------------------------------
-;General
-
- ;Name and file
- Name "@CPACK_NSIS_PACKAGE_NAME@"
- OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
-
- ;Set compression
- SetCompressor @CPACK_NSIS_COMPRESSOR@
-
- ;Require administrator access
- RequestExecutionLevel admin
-
-@CPACK_NSIS_DEFINES@
-
- !include Sections.nsh
-
-;--- Component support macros: ---
-; The code for the add/remove functionality is from:
-; http://nsis.sourceforge.net/Add/Remove_Functionality
-; It has been modified slightly and extended to provide
-; inter-component dependencies.
-Var AR_SecFlags
-Var AR_RegFlags
-@CPACK_NSIS_SECTION_SELECTED_VARS@
-
-; Loads the "selected" flag for the section named SecName into the
-; variable VarName.
-!macro LoadSectionSelectedIntoVar SecName VarName
- SectionGetFlags ${${SecName}} $${VarName}
- IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits
-!macroend
-
-; Loads the value of a variable... can we get around this?
-!macro LoadVar VarName
- IntOp $R0 0 + $${VarName}
-!macroend
-
-; Sets the value of a variable
-!macro StoreVar VarName IntValue
- IntOp $${VarName} 0 + ${IntValue}
-!macroend
-
-!macro InitSection SecName
- ; This macro reads component installed flag from the registry and
- ;changes checked state of the section on the components page.
- ;Input: section index constant name specified in Section command.
-
- ClearErrors
- ;Reading component status from registry
- ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" "Installed"
- IfErrors "default_${SecName}"
- ;Status will stay default if registry value not found
- ;(component was never installed)
- IntOp $AR_RegFlags $AR_RegFlags & ${SF_SELECTED} ;Turn off all other bits
- SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading default section flags
- IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE ;Turn lowest (enabled) bit off
- IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags ;Change lowest bit
-
- ; Note whether this component was installed before
- !insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags
- IntOp $R0 $AR_RegFlags & $AR_RegFlags
-
- ;Writing modified flags
- SectionSetFlags ${${SecName}} $AR_SecFlags
-
- "default_${SecName}:"
- !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
-!macroend
-
-!macro FinishSection SecName
- ; This macro reads section flag set by user and removes the section
- ;if it is not selected.
- ;Then it writes component installed flag to registry
- ;Input: section index constant name specified in Section command.
-
- SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags
- ;Checking lowest bit:
- IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED}
- IntCmp $AR_SecFlags 1 "leave_${SecName}"
- ;Section is not selected:
- ;Calling Section uninstall macro and writing zero installed flag
- !insertmacro "Remove_${${SecName}}"
- WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \
- "Installed" 0
- Goto "exit_${SecName}"
-
- "leave_${SecName}:"
- ;Section is selected:
- WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \
- "Installed" 1
-
- "exit_${SecName}:"
-!macroend
-
-!macro RemoveSection_CPack SecName
- ; This macro is used to call section's Remove_... macro
- ;from the uninstaller.
- ;Input: section index constant name specified in Section command.
-
- !insertmacro "Remove_${${SecName}}"
-!macroend
-
-; Determine whether the selection of SecName changed
-!macro MaybeSelectionChanged SecName
- !insertmacro LoadVar ${SecName}_selected
- SectionGetFlags ${${SecName}} $R1
- IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits
-
- ; See if the status has changed:
- IntCmp $R0 $R1 "${SecName}_unchanged"
- !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected
-
- IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected"
- !insertmacro "Deselect_required_by_${SecName}"
- goto "${SecName}_unchanged"
-
- "${SecName}_was_selected:"
- !insertmacro "Select_${SecName}_depends"
-
- "${SecName}_unchanged:"
-!macroend
-;--- End of Add/Remove macros ---
-
-;--------------------------------
-;Interface Settings
-
- !define MUI_HEADERIMAGE
- !define MUI_ABORTWARNING
-
-;----------------------------------------
-; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02"
-;----------------------------------------
-!verbose 3
-!include "WinMessages.NSH"
-!verbose 4
-;====================================================
-; get_NT_environment
-; Returns: the selected environment
-; Output : head of the stack
-;====================================================
-!macro select_NT_profile UN
-Function ${UN}select_NT_profile
- StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 environment_single
- DetailPrint "Selected environment for all users"
- Push "all"
- Return
- environment_single:
- DetailPrint "Selected environment for current user only."
- Push "current"
- Return
-FunctionEnd
-!macroend
-!insertmacro select_NT_profile ""
-!insertmacro select_NT_profile "un."
-;----------------------------------------------------
-!define NT_current_env 'HKCU "Environment"'
-!define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
-
-!ifndef WriteEnvStr_RegKey
- !ifdef ALL_USERS
- !define WriteEnvStr_RegKey \
- 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
- !else
- !define WriteEnvStr_RegKey 'HKCU "Environment"'
- !endif
-!endif
-
-; AddToPath - Adds the given dir to the search path.
-; Input - head of the stack
-; Note - Win9x systems requires reboot
-
-Function AddToPath
- Exch $0
- Push $1
- Push $2
- Push $3
-
- # don't add if the path doesn't exist
- IfFileExists "$0\*.*" "" AddToPath_done
-
- ReadEnvStr $1 PATH
- ; if the path is too long for a NSIS variable NSIS will return a 0
- ; length string. If we find that, then warn and skip any path
- ; modification as it will trash the existing path.
- StrLen $2 $1
- IntCmp $2 0 CheckPathLength_ShowPathWarning CheckPathLength_Done CheckPathLength_Done
- CheckPathLength_ShowPathWarning:
- Messagebox MB_OK|MB_ICONEXCLAMATION "Warning! PATH too long installer unable to modify PATH!"
- Goto AddToPath_done
- CheckPathLength_Done:
- Push "$1;"
- Push "$0;"
- Call StrStr
- Pop $2
- StrCmp $2 "" "" AddToPath_done
- Push "$1;"
- Push "$0\;"
- Call StrStr
- Pop $2
- StrCmp $2 "" "" AddToPath_done
- GetFullPathName /SHORT $3 $0
- Push "$1;"
- Push "$3;"
- Call StrStr
- Pop $2
- StrCmp $2 "" "" AddToPath_done
- Push "$1;"
- Push "$3\;"
- Call StrStr
- Pop $2
- StrCmp $2 "" "" AddToPath_done
-
- Call IsNT
- Pop $1
- StrCmp $1 1 AddToPath_NT
- ; Not on NT
- StrCpy $1 $WINDIR 2
- FileOpen $1 "$1\autoexec.bat" a
- FileSeek $1 -1 END
- FileReadByte $1 $2
- IntCmp $2 26 0 +2 +2 # DOS EOF
- FileSeek $1 -1 END # write over EOF
- FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
- FileClose $1
- SetRebootFlag true
- Goto AddToPath_done
-
- AddToPath_NT:
- StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey
- ReadRegStr $1 ${NT_current_env} "PATH"
- Goto DoTrim
- ReadAllKey:
- ReadRegStr $1 ${NT_all_env} "PATH"
- DoTrim:
- StrCmp $1 "" AddToPath_NTdoIt
- Push $1
- Call Trim
- Pop $1
- StrCpy $0 "$1;$0"
- AddToPath_NTdoIt:
- StrCmp $ADD_TO_PATH_ALL_USERS "1" WriteAllKey
- WriteRegExpandStr ${NT_current_env} "PATH" $0
- Goto DoSend
- WriteAllKey:
- WriteRegExpandStr ${NT_all_env} "PATH" $0
- DoSend:
- SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
-
- AddToPath_done:
- Pop $3
- Pop $2
- Pop $1
- Pop $0
-FunctionEnd
-
-
-; RemoveFromPath - Remove a given dir from the path
-; Input: head of the stack
-
-Function un.RemoveFromPath
- Exch $0
- Push $1
- Push $2
- Push $3
- Push $4
- Push $5
- Push $6
-
- IntFmt $6 "%c" 26 # DOS EOF
-
- Call un.IsNT
- Pop $1
- StrCmp $1 1 unRemoveFromPath_NT
- ; Not on NT
- StrCpy $1 $WINDIR 2
- FileOpen $1 "$1\autoexec.bat" r
- GetTempFileName $4
- FileOpen $2 $4 w
- GetFullPathName /SHORT $0 $0
- StrCpy $0 "SET PATH=%PATH%;$0"
- Goto unRemoveFromPath_dosLoop
-
- unRemoveFromPath_dosLoop:
- FileRead $1 $3
- StrCpy $5 $3 1 -1 # read last char
- StrCmp $5 $6 0 +2 # if DOS EOF
- StrCpy $3 $3 -1 # remove DOS EOF so we can compare
- StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
- StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
- StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
- StrCmp $3 "" unRemoveFromPath_dosLoopEnd
- FileWrite $2 $3
- Goto unRemoveFromPath_dosLoop
- unRemoveFromPath_dosLoopRemoveLine:
- SetRebootFlag true
- Goto unRemoveFromPath_dosLoop
-
- unRemoveFromPath_dosLoopEnd:
- FileClose $2
- FileClose $1
- StrCpy $1 $WINDIR 2
- Delete "$1\autoexec.bat"
- CopyFiles /SILENT $4 "$1\autoexec.bat"
- Delete $4
- Goto unRemoveFromPath_done
-
- unRemoveFromPath_NT:
- StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey
- ReadRegStr $1 ${NT_current_env} "PATH"
- Goto unDoTrim
- unReadAllKey:
- ReadRegStr $1 ${NT_all_env} "PATH"
- unDoTrim:
- StrCpy $5 $1 1 -1 # copy last char
- StrCmp $5 ";" +2 # if last char != ;
- StrCpy $1 "$1;" # append ;
- Push $1
- Push "$0;"
- Call un.StrStr ; Find `$0;` in $1
- Pop $2 ; pos of our dir
- StrCmp $2 "" unRemoveFromPath_done
- ; else, it is in path
- # $0 - path to add
- # $1 - path var
- StrLen $3 "$0;"
- StrLen $4 $2
- StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
- StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
- StrCpy $3 $5$6
-
- StrCpy $5 $3 1 -1 # copy last char
- StrCmp $5 ";" 0 +2 # if last char == ;
- StrCpy $3 $3 -1 # remove last char
-
- StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey
- WriteRegExpandStr ${NT_current_env} "PATH" $3
- Goto unDoSend
- unWriteAllKey:
- WriteRegExpandStr ${NT_all_env} "PATH" $3
- unDoSend:
- SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
-
- unRemoveFromPath_done:
- Pop $6
- Pop $5
- Pop $4
- Pop $3
- Pop $2
- Pop $1
- Pop $0
-FunctionEnd
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-; Uninstall sutff
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-###########################################
-# Utility Functions #
-###########################################
-
-;====================================================
-; IsNT - Returns 1 if the current system is NT, 0
-; otherwise.
-; Output: head of the stack
-;====================================================
-; IsNT
-; no input
-; output, top of the stack = 1 if NT or 0 if not
-;
-; Usage:
-; Call IsNT
-; Pop $R0
-; ($R0 at this point is 1 or 0)
-
-!macro IsNT un
-Function ${un}IsNT
- Push $0
- ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
- StrCmp $0 "" 0 IsNT_yes
- ; we are not NT.
- Pop $0
- Push 0
- Return
-
- IsNT_yes:
- ; NT!!!
- Pop $0
- Push 1
-FunctionEnd
-!macroend
-!insertmacro IsNT ""
-!insertmacro IsNT "un."
-
-; StrStr
-; input, top of stack = string to search for
-; top of stack-1 = string to search in
-; output, top of stack (replaces with the portion of the string remaining)
-; modifies no other variables.
-;
-; Usage:
-; Push "this is a long ass string"
-; Push "ass"
-; Call StrStr
-; Pop $R0
-; ($R0 at this point is "ass string")
-
-!macro StrStr un
-Function ${un}StrStr
-Exch $R1 ; st=haystack,old$R1, $R1=needle
- Exch ; st=old$R1,haystack
- Exch $R2 ; st=old$R1,old$R2, $R2=haystack
- Push $R3
- Push $R4
- Push $R5
- StrLen $R3 $R1
- StrCpy $R4 0
- ; $R1=needle
- ; $R2=haystack
- ; $R3=len(needle)
- ; $R4=cnt
- ; $R5=tmp
- loop:
- StrCpy $R5 $R2 $R3 $R4
- StrCmp $R5 $R1 done
- StrCmp $R5 "" done
- IntOp $R4 $R4 + 1
- Goto loop
-done:
- StrCpy $R1 $R2 "" $R4
- Pop $R5
- Pop $R4
- Pop $R3
- Pop $R2
- Exch $R1
-FunctionEnd
-!macroend
-!insertmacro StrStr ""
-!insertmacro StrStr "un."
-
-Function Trim ; Added by Pelaca
- Exch $R1
- Push $R2
-Loop:
- StrCpy $R2 "$R1" 1 -1
- StrCmp "$R2" " " RTrim
- StrCmp "$R2" "$\n" RTrim
- StrCmp "$R2" "$\r" RTrim
- StrCmp "$R2" ";" RTrim
- GoTo Done
-RTrim:
- StrCpy $R1 "$R1" -1
- Goto Loop
-Done:
- Pop $R2
- Exch $R1
-FunctionEnd
-
-Function ConditionalAddToRegisty
- Pop $0
- Pop $1
- StrCmp "$0" "" ConditionalAddToRegisty_EmptyString
- WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" \
- "$1" "$0"
- ;MessageBox MB_OK "Set Registry: '$1' to '$0'"
- DetailPrint "Set install registry entry: '$1' to '$0'"
- ConditionalAddToRegisty_EmptyString:
-FunctionEnd
-
-;--------------------------------
-
-!ifdef CPACK_USES_DOWNLOAD
-Function DownloadFile
- IfFileExists $INSTDIR\* +2
- CreateDirectory $INSTDIR
- Pop $0
-
- ; Skip if already downloaded
- IfFileExists $INSTDIR\$0 0 +2
- Return
-
- StrCpy $1 "@CPACK_DOWNLOAD_SITE@"
-
- try_again:
- NSISdl::download "$1/$0" "$INSTDIR\$0"
-
- Pop $1
- StrCmp $1 "success" success
- StrCmp $1 "Cancelled" cancel
- MessageBox MB_OK "Download failed: $1"
- cancel:
- Return
- success:
-FunctionEnd
-!endif
-
-;--------------------------------
-; Installation types
-@CPACK_NSIS_INSTALLATION_TYPES@
-
-;--------------------------------
-; Component sections
-@CPACK_NSIS_COMPONENT_SECTIONS@
-
-;--------------------------------
-; Define some macro setting for the gui
-@CPACK_NSIS_INSTALLER_MUI_ICON_CODE@
-@CPACK_NSIS_INSTALLER_ICON_CODE@
-@CPACK_NSIS_INSTALLER_MUI_WELCOMEFINISH_CODE@
-@CPACK_NSIS_INSTALLER_MUI_UNWELCOMEFINISH_CODE@
-@CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@
-@CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@
-
-;--------------------------------
-;Pages
- !insertmacro MUI_PAGE_WELCOME
-
- !insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@"
- Page custom InstallOptionsPage
- !insertmacro MUI_PAGE_DIRECTORY
-
- ;Start Menu Folder Page Configuration
- !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
- !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
- !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
- !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
-
- @CPACK_NSIS_PAGE_COMPONENTS@
-
- !insertmacro MUI_PAGE_INSTFILES
- !insertmacro MUI_PAGE_FINISH
-
- !insertmacro MUI_UNPAGE_CONFIRM
- !insertmacro MUI_UNPAGE_INSTFILES
-
-;--------------------------------
-;Languages
-
- !insertmacro MUI_LANGUAGE "English" ;first language is the default language
- !insertmacro MUI_LANGUAGE "Albanian"
- !insertmacro MUI_LANGUAGE "Arabic"
- !insertmacro MUI_LANGUAGE "Basque"
- !insertmacro MUI_LANGUAGE "Belarusian"
- !insertmacro MUI_LANGUAGE "Bosnian"
- !insertmacro MUI_LANGUAGE "Breton"
- !insertmacro MUI_LANGUAGE "Bulgarian"
- !insertmacro MUI_LANGUAGE "Croatian"
- !insertmacro MUI_LANGUAGE "Czech"
- !insertmacro MUI_LANGUAGE "Danish"
- !insertmacro MUI_LANGUAGE "Dutch"
- !insertmacro MUI_LANGUAGE "Estonian"
- !insertmacro MUI_LANGUAGE "Farsi"
- !insertmacro MUI_LANGUAGE "Finnish"
- !insertmacro MUI_LANGUAGE "French"
- !insertmacro MUI_LANGUAGE "German"
- !insertmacro MUI_LANGUAGE "Greek"
- !insertmacro MUI_LANGUAGE "Hebrew"
- !insertmacro MUI_LANGUAGE "Hungarian"
- !insertmacro MUI_LANGUAGE "Icelandic"
- !insertmacro MUI_LANGUAGE "Indonesian"
- !insertmacro MUI_LANGUAGE "Irish"
- !insertmacro MUI_LANGUAGE "Italian"
- !insertmacro MUI_LANGUAGE "Japanese"
- !insertmacro MUI_LANGUAGE "Korean"
- !insertmacro MUI_LANGUAGE "Kurdish"
- !insertmacro MUI_LANGUAGE "Latvian"
- !insertmacro MUI_LANGUAGE "Lithuanian"
- !insertmacro MUI_LANGUAGE "Luxembourgish"
- !insertmacro MUI_LANGUAGE "Macedonian"
- !insertmacro MUI_LANGUAGE "Malay"
- !insertmacro MUI_LANGUAGE "Mongolian"
- !insertmacro MUI_LANGUAGE "Norwegian"
- !insertmacro MUI_LANGUAGE "Polish"
- !insertmacro MUI_LANGUAGE "Portuguese"
- !insertmacro MUI_LANGUAGE "PortugueseBR"
- !insertmacro MUI_LANGUAGE "Romanian"
- !insertmacro MUI_LANGUAGE "Russian"
- !insertmacro MUI_LANGUAGE "Serbian"
- !insertmacro MUI_LANGUAGE "SerbianLatin"
- !insertmacro MUI_LANGUAGE "SimpChinese"
- !insertmacro MUI_LANGUAGE "Slovak"
- !insertmacro MUI_LANGUAGE "Slovenian"
- !insertmacro MUI_LANGUAGE "Spanish"
- !insertmacro MUI_LANGUAGE "Swedish"
- !insertmacro MUI_LANGUAGE "Thai"
- !insertmacro MUI_LANGUAGE "TradChinese"
- !insertmacro MUI_LANGUAGE "Turkish"
- !insertmacro MUI_LANGUAGE "Ukrainian"
- !insertmacro MUI_LANGUAGE "Welsh"
-
-
-;--------------------------------
-;Reserve Files
-
- ;These files should be inserted before other files in the data block
- ;Keep these lines before any File command
- ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
-
- ReserveFile "NSIS.InstallOptions.ini"
- !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
-
-;--------------------------------
-;Installer Sections
-
-Section "-Core installation"
- ;Use the entire tree produced by the INSTALL target. Keep the
- ;list of directories here in sync with the RMDir commands below.
- SetOutPath "$INSTDIR"
- @CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@
- @CPACK_NSIS_FULL_INSTALL@
-
- ;Store installation folder
- WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
-
- ;Create uninstaller
- WriteUninstaller "$INSTDIR\Uninstall.exe"
- Push "DisplayName"
- Push "@CPACK_NSIS_DISPLAY_NAME@"
- Call ConditionalAddToRegisty
- Push "DisplayVersion"
- Push "@CPACK_PACKAGE_VERSION@"
- Call ConditionalAddToRegisty
- Push "Publisher"
- Push "@CPACK_PACKAGE_VENDOR@"
- Call ConditionalAddToRegisty
- Push "UninstallString"
- Push "$INSTDIR\Uninstall.exe"
- Call ConditionalAddToRegisty
- Push "NoRepair"
- Push "1"
- Call ConditionalAddToRegisty
-
- !ifdef CPACK_NSIS_ADD_REMOVE
- ;Create add/remove functionality
- Push "ModifyPath"
- Push "$INSTDIR\AddRemove.exe"
- Call ConditionalAddToRegisty
- !else
- Push "NoModify"
- Push "1"
- Call ConditionalAddToRegisty
- !endif
-
- ; Optional registration
- Push "DisplayIcon"
- Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@"
- Call ConditionalAddToRegisty
- Push "HelpLink"
- Push "@CPACK_NSIS_HELP_LINK@"
- Call ConditionalAddToRegisty
- Push "URLInfoAbout"
- Push "@CPACK_NSIS_URL_INFO_ABOUT@"
- Call ConditionalAddToRegisty
- Push "Contact"
- Push "@CPACK_NSIS_CONTACT@"
- Call ConditionalAddToRegisty
- !insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State"
- !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
-
- ;Create shortcuts
- CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
-@CPACK_NSIS_CREATE_ICONS@
-@CPACK_NSIS_CREATE_ICONS_EXTRA@
- CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
-
- ;Read a value from an InstallOptions INI file
- !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State"
- !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State"
- !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State"
-
- ; Write special uninstall registry entries
- Push "StartMenu"
- Push "$STARTMENU_FOLDER"
- Call ConditionalAddToRegisty
- Push "DoNotAddToPath"
- Push "$DO_NOT_ADD_TO_PATH"
- Call ConditionalAddToRegisty
- Push "AddToPathAllUsers"
- Push "$ADD_TO_PATH_ALL_USERS"
- Call ConditionalAddToRegisty
- Push "AddToPathCurrentUser"
- Push "$ADD_TO_PATH_CURRENT_USER"
- Call ConditionalAddToRegisty
- Push "InstallToDesktop"
- Push "$INSTALL_DESKTOP"
- Call ConditionalAddToRegisty
-
- !insertmacro MUI_STARTMENU_WRITE_END
-
-@CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
-
-SectionEnd
-
-Section "-Add to path"
- Push $INSTDIR\bin
- StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath
- StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0
- Call AddToPath
- doNotAddToPath:
-SectionEnd
-
-;--------------------------------
-; Create custom pages
-Function InstallOptionsPage
- !insertmacro MUI_HEADER_TEXT "Install Options" "Choose options for installing @CPACK_NSIS_PACKAGE_NAME@"
- !insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini"
-
-FunctionEnd
-
-;--------------------------------
-; determine admin versus local install
-Function un.onInit
-
- ClearErrors
- UserInfo::GetName
- IfErrors noLM
- Pop $0
- UserInfo::GetAccountType
- Pop $1
- StrCmp $1 "Admin" 0 +3
- SetShellVarContext all
- ;MessageBox MB_OK 'User "$0" is in the Admin group'
- Goto done
- StrCmp $1 "Power" 0 +3
- SetShellVarContext all
- ;MessageBox MB_OK 'User "$0" is in the Power Users group'
- Goto done
-
- noLM:
- ;Get installation folder from registry if available
-
- done:
-
-FunctionEnd
-
-;--- Add/Remove callback functions: ---
-!macro SectionList MacroName
- ;This macro used to perform operation on multiple sections.
- ;List all of your components in following manner here.
-@CPACK_NSIS_COMPONENT_SECTION_LIST@
-!macroend
-
-Section -FinishComponents
- ;Removes unselected components and writes component status to registry
- !insertmacro SectionList "FinishSection"
-
-!ifdef CPACK_NSIS_ADD_REMOVE
- ; Get the name of the installer executable
- System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1'
- StrCpy $R3 $R0
-
- ; Strip off the last 13 characters, to see if we have AddRemove.exe
- StrLen $R1 $R0
- IntOp $R1 $R0 - 13
- StrCpy $R2 $R0 13 $R1
- StrCmp $R2 "AddRemove.exe" addremove_installed
-
- ; We're not running AddRemove.exe, so install it
- CopyFiles $R3 $INSTDIR\AddRemove.exe
-
- addremove_installed:
-!endif
-SectionEnd
-;--- End of Add/Remove callback functions ---
-
-;--------------------------------
-; Component dependencies
-Function .onSelChange
- !insertmacro SectionList MaybeSelectionChanged
-FunctionEnd
-
-;--------------------------------
-;Uninstaller Section
-
-Section "Uninstall"
- ReadRegStr $START_MENU SHCTX \
- "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu"
- ;MessageBox MB_OK "Start menu is in: $START_MENU"
- ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \
- "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "DoNotAddToPath"
- ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \
- "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathAllUsers"
- ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \
- "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathCurrentUser"
- ;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS"
- ReadRegStr $INSTALL_DESKTOP SHCTX \
- "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "InstallToDesktop"
- ;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP "
-
-@CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@
-
- ;Remove files we installed.
- ;Keep the list of directories here in sync with the File commands above.
-@CPACK_NSIS_DELETE_FILES@
-@CPACK_NSIS_DELETE_DIRECTORIES@
-
-!ifdef CPACK_NSIS_ADD_REMOVE
- ;Remove the add/remove program
- Delete "$INSTDIR\AddRemove.exe"
-!endif
-
- ;Remove the uninstaller itself.
- Delete "$INSTDIR\Uninstall.exe"
- DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
-
- ;Remove the installation directory if it is empty.
- RMDir "$INSTDIR"
-
- ; Remove the registry entries.
- DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
-
- ; Removes all optional components
- !insertmacro SectionList "RemoveSection_CPack"
-
- !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
-
- Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
-@CPACK_NSIS_DELETE_ICONS@
-@CPACK_NSIS_DELETE_ICONS_EXTRA@
-
- ;Delete empty start menu parent diretories
- StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
-
- startMenuDeleteLoop:
- ClearErrors
- RMDir $MUI_TEMP
- GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
-
- IfErrors startMenuDeleteLoopDone
-
- StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop
- startMenuDeleteLoopDone:
-
- ; If the user changed the shortcut, then untinstall may not work. This should
- ; try to fix it.
- StrCpy $MUI_TEMP "$START_MENU"
- Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
-@CPACK_NSIS_DELETE_ICONS_EXTRA@
-
- ;Delete empty start menu parent diretories
- StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
-
- secondStartMenuDeleteLoop:
- ClearErrors
- RMDir $MUI_TEMP
- GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
-
- IfErrors secondStartMenuDeleteLoopDone
-
- StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop
- secondStartMenuDeleteLoopDone:
-
- DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
-
- Push $INSTDIR\bin
- StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0
- Call un.RemoveFromPath
- doNotRemoveFromPath:
-SectionEnd
-
-;--------------------------------
-; determine admin versus local install
-; Is install for "AllUsers" or "JustMe"?
-; Default to "JustMe" - set to "AllUsers" if admin or on Win9x
-; This function is used for the very first "custom page" of the installer.
-; This custom page does not show up visibly, but it executes prior to the
-; first visible page and sets up $INSTDIR properly...
-; Choose different default installation folder based on SV_ALLUSERS...
-; "Program Files" for AllUsers, "My Documents" for JustMe...
-
-Function .onInit
- StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst
-
- ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString"
- StrCmp $0 "" inst
-
- MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
- "@CPACK_NSIS_PACKAGE_NAME@ is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \
- /SD IDYES IDYES uninst IDNO inst
- Abort
-
-;Run the uninstaller
-uninst:
- ClearErrors
- StrLen $2 "\Uninstall.exe"
- StrCpy $3 $0 -$2 # remove "\Uninstall.exe" from UninstallString to get path
- ExecWait '"$0" /S _?=$3' ;Do not copy the uninstaller to a temp file
-
- IfErrors uninst_failed inst
-uninst_failed:
- MessageBox MB_OK|MB_ICONSTOP "Uninstall failed."
- Abort
-
-
-inst:
- ; Reads components status for registry
- !insertmacro SectionList "InitSection"
-
- ; check to see if /D has been used to change
- ; the install directory by comparing it to the
- ; install directory that is expected to be the
- ; default
- StrCpy $IS_DEFAULT_INSTALLDIR 0
- StrCmp "$INSTDIR" "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2
- StrCpy $IS_DEFAULT_INSTALLDIR 1
-
- StrCpy $SV_ALLUSERS "JustMe"
- ; if default install dir then change the default
- ; if it is installed for JustMe
- StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
- StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
-
- ClearErrors
- UserInfo::GetName
- IfErrors noLM
- Pop $0
- UserInfo::GetAccountType
- Pop $1
- StrCmp $1 "Admin" 0 +4
- SetShellVarContext all
- ;MessageBox MB_OK 'User "$0" is in the Admin group'
- StrCpy $SV_ALLUSERS "AllUsers"
- Goto done
- StrCmp $1 "Power" 0 +4
- SetShellVarContext all
- ;MessageBox MB_OK 'User "$0" is in the Power Users group'
- StrCpy $SV_ALLUSERS "AllUsers"
- Goto done
-
- noLM:
- StrCpy $SV_ALLUSERS "AllUsers"
- ;Get installation folder from registry if available
-
- done:
- StrCmp $SV_ALLUSERS "AllUsers" 0 +3
- StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2
- StrCpy $INSTDIR "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
-
- StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage
- !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini"
-
- noOptionsPage:
-FunctionEnd
diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake
index 7f08c4a35..61d213ae4 100644
--- a/Modules/Platform/AIX-GNU.cmake
+++ b/Modules/Platform/AIX-GNU.cmake
@@ -8,21 +8,26 @@ if(__AIX_COMPILER_GNU)
endif()
set(__AIX_COMPILER_GNU 1)
-#
-# By default, runtime linking is enabled. All shared objects specified on the command line
-# will be listed, even if there are no symbols referenced, in the output file.
-string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " -Wl,-brtl")
-string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " -Wl,-brtl")
-string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -Wl,-brtl")
-
-
macro(__aix_compiler_gnu lang)
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:")
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":")
- string(APPEND CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS " -Wl,-G,-bnoipath")
- set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall")
+ string(APPEND CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS " -Wl,-bnoipath")
+ set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") # CMP0065 old behavior
set(CMAKE_${lang}_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH 1)
set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath")
- unset(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY)
+ if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 7 OR CMAKE_SYSTEM_VERSION VERSION_LESS 7.1)
+ unset(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY)
+ endif()
+
+ # Construct the export list ourselves to pass only the object files so
+ # that we export only the symbols actually provided by the sources.
+ set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
+ "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/objects.exp <OBJECTS>"
+ "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
+ )
+
+ set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS
+ "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -l . <OBJECTS>"
+ "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<TARGET_IMPLIB> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
endmacro()
diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake
index b3078fffb..2a67c4fed 100644
--- a/Modules/Platform/AIX-XL.cmake
+++ b/Modules/Platform/AIX-XL.cmake
@@ -8,21 +8,34 @@ if(__AIX_COMPILER_XL)
endif()
set(__AIX_COMPILER_XL 1)
-#
-# By default, runtime linking is enabled. All shared objects specified on the command line
-# will be listed, even if there are no symbols referenced, in the output file.
-string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " -Wl,-brtl")
-string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " -Wl,-brtl")
-string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -Wl,-brtl")
-
-
macro(__aix_compiler_xl lang)
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:")
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":")
- set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-G -Wl,-bnoipath") # -shared
- set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall")
+ string(APPEND CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS " -Wl,-bnoipath")
+ set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-bexpall") # CMP0065 old behavior
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS " ")
set(CMAKE_SHARED_MODULE_${lang}_FLAGS " ")
set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath")
+
+ set(_OBJECTS " <OBJECTS>")
+ if(DEFINED CMAKE_XL_CreateExportList AND CMAKE_XL_CreateExportList STREQUAL "")
+ # Prior to CMake 3.16, CMAKE_XL_CreateExportList held the path to the XL CreateExportList tool.
+ # Users could set it to an empty value to skip automatic exports in favor of manual -bE: flags.
+ # Preserve that behavior for compatibility (even though it was undocumented).
+ set(_OBJECTS "")
+ endif()
+
+ # Construct the export list ourselves to pass only the object files so
+ # that we export only the symbols actually provided by the sources.
+ set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
+ "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <OBJECT_DIR>/objects.exp${_OBJECTS}"
+ "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
+ )
+
+ set(CMAKE_${lang}_LINK_EXECUTABLE_WITH_EXPORTS
+ "\"${CMAKE_ROOT}/Modules/Platform/AIX/ExportImportList\" -o <TARGET_IMPLIB> -l . <OBJECTS>"
+ "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> -Wl,-bE:<TARGET_IMPLIB> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
+
+ unset(_OBJECTS)
endmacro()
diff --git a/Modules/Platform/AIX-XLClang-C.cmake b/Modules/Platform/AIX-XLClang-C.cmake
new file mode 100644
index 000000000..f0bedc5d8
--- /dev/null
+++ b/Modules/Platform/AIX-XLClang-C.cmake
@@ -0,0 +1,2 @@
+include(Platform/AIX-XLClang)
+__aix_compiler_xlclang(C)
diff --git a/Modules/Platform/AIX-XLClang-CXX.cmake b/Modules/Platform/AIX-XLClang-CXX.cmake
new file mode 100644
index 000000000..cceb5769c
--- /dev/null
+++ b/Modules/Platform/AIX-XLClang-CXX.cmake
@@ -0,0 +1,2 @@
+include(Platform/AIX-XLClang)
+__aix_compiler_xlclang(CXX)
diff --git a/Modules/Platform/AIX-XLClang.cmake b/Modules/Platform/AIX-XLClang.cmake
new file mode 100644
index 000000000..c9320950e
--- /dev/null
+++ b/Modules/Platform/AIX-XLClang.cmake
@@ -0,0 +1,15 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+# This module is shared by multiple languages; use include blocker.
+if(__AIX_COMPILER_XLCLANG)
+ return()
+endif()
+set(__AIX_COMPILER_XLCLANG 1)
+
+include(Platform/AIX-XL)
+
+macro(__aix_compiler_xlclang lang)
+ __aix_compiler_xl(${lang})
+endmacro()
diff --git a/Modules/Platform/AIX.cmake b/Modules/Platform/AIX.cmake
index 551a995aa..03cef51af 100644
--- a/Modules/Platform/AIX.cmake
+++ b/Modules/Platform/AIX.cmake
@@ -1,5 +1,7 @@
set(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so
+set(CMAKE_AIX_IMPORT_FILE_PREFIX "")
+set(CMAKE_AIX_IMPORT_FILE_SUFFIX ".imp")
set(CMAKE_DL_LIBS "-lld")
# RPATH support on AIX is called libpath. By default the runtime
diff --git a/Modules/Platform/AIX/ExportImportList b/Modules/Platform/AIX/ExportImportList
new file mode 100755
index 000000000..4f67ef546
--- /dev/null
+++ b/Modules/Platform/AIX/ExportImportList
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# This script is internal to CMake and meant only to be
+# invoked by CMake-generated build systems on AIX.
+
+usage='usage: ExportImportList -o <out-file> [-l <lib>] [--] <objects>...'
+
+die() {
+ echo "$@" 1>&2; exit 1
+}
+
+# Process command-line arguments.
+out=''
+lib=''
+while test "$#" != 0; do
+ case "$1" in
+ -l) shift; lib="$1" ;;
+ -o) shift; out="$1" ;;
+ --) shift; break ;;
+ -*) die "$usage" ;;
+ *) break ;;
+ esac
+ shift
+done
+test -n "$out" || die "$usage"
+
+# Collect symbols exported from all object files.
+out_tmp="$out.tmp$$"
+trap 'rm -f "$out_tmp"' EXIT INT TERM
+for f in "$@"; do
+ dump -tov -X 32_64 "$f" |
+ awk '
+ BEGIN {
+ V["EXPORTED"]=" export"
+ V["PROTECTED"]=" protected"
+ }
+ /^\[[0-9]+\]\tm +[^ ]+ +\.(text|data|bss) +[^ ]+ +(extern|weak) +(EXPORTED|PROTECTED| ) / {
+ if (!match($NF,/^(\.|__sinit|__sterm|__[0-9]+__)/)) {
+ print $NF V[$(NF-1)]
+ }
+ }
+ '
+done > "$out_tmp"
+
+# Generate the export/import file.
+{
+ if test -n "$lib"; then
+ echo "#! $lib"
+ fi
+ sort -u "$out_tmp"
+} > "$out"
diff --git a/Modules/Platform/Android-Clang-CXX.cmake b/Modules/Platform/Android-Clang-CXX.cmake
index 711183645..85d508880 100644
--- a/Modules/Platform/Android-Clang-CXX.cmake
+++ b/Modules/Platform/Android-Clang-CXX.cmake
@@ -1,2 +1,9 @@
include(Platform/Android-Clang)
__android_compiler_clang(CXX)
+if(_ANDROID_STL_NOSTDLIBXX)
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6)
+ string(APPEND CMAKE_CXX_STANDARD_LIBRARIES " -nostdlib++")
+ else()
+ string(APPEND CMAKE_CXX_STANDARD_LIBRARIES " -nodefaultlibs -lgcc -lc -lm -ldl")
+ endif()
+endif()
diff --git a/Modules/Platform/Android-Clang.cmake b/Modules/Platform/Android-Clang.cmake
index f739ab1ef..847178fbd 100644
--- a/Modules/Platform/Android-Clang.cmake
+++ b/Modules/Platform/Android-Clang.cmake
@@ -40,5 +40,9 @@ macro(__android_compiler_clang lang)
endif()
if(NOT CMAKE_${lang}_COMPILER_TARGET)
set(CMAKE_${lang}_COMPILER_TARGET "${_ANDROID_ABI_CLANG_TARGET}")
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ string(APPEND CMAKE_${lang}_COMPILER_TARGET "${CMAKE_SYSTEM_VERSION}")
+ endif()
+ list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "--target=${CMAKE_${lang}_COMPILER_TARGET}")
endif()
endmacro()
diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake
index 80a8f410d..1affcd0da 100644
--- a/Modules/Platform/Android-Common.cmake
+++ b/Modules/Platform/Android-Common.cmake
@@ -32,8 +32,10 @@ if(CMAKE_ANDROID_NDK)
)
endif()
unset(_ANDROID_STL_TYPE_FOUND)
- else()
+ elseif(IS_DIRECTORY ${CMAKE_ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++)
set(CMAKE_ANDROID_STL_TYPE "gnustl_static")
+ else()
+ set(CMAKE_ANDROID_STL_TYPE "c++_static")
endif()
unset(_ANDROID_STL_TYPES)
@@ -45,7 +47,41 @@ if(CMAKE_ANDROID_NDK)
endif()
if(CMAKE_ANDROID_STL_TYPE)
- if(CMAKE_ANDROID_NDK)
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ if(CMAKE_ANDROID_STL_TYPE STREQUAL "system")
+ set(_ANDROID_STL_EXCEPTIONS 0)
+ set(_ANDROID_STL_RTTI 0)
+ macro(__android_stl lang)
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " -stdlib=libstdc++")
+ endmacro()
+ elseif(CMAKE_ANDROID_STL_TYPE STREQUAL "c++_static")
+ set(_ANDROID_STL_EXCEPTIONS 1)
+ set(_ANDROID_STL_RTTI 1)
+ macro(__android_stl lang)
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " -stdlib=libc++")
+ string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " -static-libstdc++")
+ endmacro()
+ elseif(CMAKE_ANDROID_STL_TYPE STREQUAL "c++_shared")
+ set(_ANDROID_STL_EXCEPTIONS 1)
+ set(_ANDROID_STL_RTTI 1)
+ macro(__android_stl lang)
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " -stdlib=libc++")
+ endmacro()
+ elseif(CMAKE_ANDROID_STL_TYPE STREQUAL "none")
+ set(_ANDROID_STL_RTTI 0)
+ set(_ANDROID_STL_EXCEPTIONS 0)
+ macro(__android_stl lang)
+ # FIXME: Add a way to add project-wide language-specific compile-only flags.
+ set(CMAKE_CXX_COMPILE_OBJECT
+ "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE> -nostdinc++")
+ string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " -nostdlib++")
+ endmacro()
+ else()
+ message(FATAL_ERROR
+ "Android: STL '${CMAKE_ANDROID_STL_TYPE}' not supported by this NDK."
+ )
+ endif()
+ elseif(CMAKE_ANDROID_NDK)
macro(__android_stl_inc lang dir req)
if(EXISTS "${dir}")
@@ -150,6 +186,10 @@ macro(__android_compiler_common lang)
__android_stl(CXX)
endif()
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " -latomic -lm")
+ endif()
+
# <ndk>/build/core/definitions.mk appends the sysroot's include directory
# explicitly at the end of the command-line include path so that it
# precedes the toolchain's builtin include directories. This is
@@ -159,7 +199,7 @@ macro(__android_compiler_common lang)
#
# Do not do this for a standalone toolchain because it is already
# tied to a specific API version.
- if(CMAKE_ANDROID_NDK)
+ if(CMAKE_ANDROID_NDK AND NOT CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
if(CMAKE_SYSROOT_COMPILE)
set(_cmake_sysroot_compile "${CMAKE_SYSROOT_COMPILE}")
else()
@@ -168,7 +208,7 @@ macro(__android_compiler_common lang)
if(NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES
"${_cmake_sysroot_compile}/usr/include"
- "${_cmake_sysroot_compile}/usr/include/${CMAKE_ANDROID_ARCH_HEADER_TRIPLE}"
+ "${_cmake_sysroot_compile}/usr/include/${CMAKE_ANDROID_ARCH_TRIPLE}"
)
else()
list(APPEND CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES "${_cmake_sysroot_compile}/usr/include")
diff --git a/Modules/Platform/Android-Determine.cmake b/Modules/Platform/Android-Determine.cmake
index add1dc1f7..e7c1b48a9 100644
--- a/Modules/Platform/Android-Determine.cmake
+++ b/Modules/Platform/Android-Determine.cmake
@@ -18,6 +18,9 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1)
return()
endif()
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
+
# If the user provided CMAKE_SYSROOT for us, extract information from it.
set(_ANDROID_SYSROOT_NDK "")
set(_ANDROID_SYSROOT_API "")
@@ -195,32 +198,66 @@ if(NOT CMAKE_SYSTEM_VERSION MATCHES "^[0-9]+$")
message(FATAL_ERROR "Android: The API specified by CMAKE_SYSTEM_VERSION='${CMAKE_SYSTEM_VERSION}' is not an integer.")
endif()
+if(CMAKE_ANDROID_NDK)
+ # Identify the host platform.
+ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "darwin-x86_64")
+ else()
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "darwin-x86")
+ endif()
+ elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "linux-x86_64")
+ else()
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "linux-x86")
+ endif()
+ elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
+ if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "windows-x86_64")
+ else()
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "windows")
+ endif()
+ else()
+ message(FATAL_ERROR "Android: Builds hosted on '${CMAKE_HOST_SYSTEM_NAME}' not supported.")
+ endif()
+
+ # Look for a unified toolchain/sysroot provided with the NDK.
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}")
+ if(NOT IS_DIRECTORY "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/sysroot")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "")
+ endif()
+else()
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG "")
+ set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED "")
+endif()
+
# https://developer.android.com/ndk/guides/abis.html
set(_ANDROID_ABI_arm64-v8a_PROC "aarch64")
set(_ANDROID_ABI_arm64-v8a_ARCH "arm64")
-set(_ANDROID_ABI_arm64-v8a_HEADER "aarch64-linux-android")
+set(_ANDROID_ABI_arm64-v8a_TRIPLE "aarch64-linux-android")
set(_ANDROID_ABI_armeabi-v7a_PROC "armv7-a")
set(_ANDROID_ABI_armeabi-v7a_ARCH "arm")
-set(_ANDROID_ABI_armeabi-v7a_HEADER "arm-linux-androideabi")
+set(_ANDROID_ABI_armeabi-v7a_TRIPLE "arm-linux-androideabi")
set(_ANDROID_ABI_armeabi-v6_PROC "armv6")
set(_ANDROID_ABI_armeabi-v6_ARCH "arm")
-set(_ANDROID_ABI_armeabi-v6_HEADER "arm-linux-androideabi")
+set(_ANDROID_ABI_armeabi-v6_TRIPLE "arm-linux-androideabi")
set(_ANDROID_ABI_armeabi_PROC "armv5te")
set(_ANDROID_ABI_armeabi_ARCH "arm")
-set(_ANDROID_ABI_armeabi_HEADER "arm-linux-androideabi")
+set(_ANDROID_ABI_armeabi_TRIPLE "arm-linux-androideabi")
set(_ANDROID_ABI_mips_PROC "mips")
set(_ANDROID_ABI_mips_ARCH "mips")
-set(_ANDROID_ABI_mips_HEADER "mipsel-linux-android")
+set(_ANDROID_ABI_mips_TRIPLE "mipsel-linux-android")
set(_ANDROID_ABI_mips64_PROC "mips64")
set(_ANDROID_ABI_mips64_ARCH "mips64")
-set(_ANDROID_ABI_mips64_HEADER "mips64el-linux-android")
+set(_ANDROID_ABI_mips64_TRIPLE "mips64el-linux-android")
set(_ANDROID_ABI_x86_PROC "i686")
set(_ANDROID_ABI_x86_ARCH "x86")
-set(_ANDROID_ABI_x86_HEADER "i686-linux-android")
+set(_ANDROID_ABI_x86_TRIPLE "i686-linux-android")
set(_ANDROID_ABI_x86_64_PROC "x86_64")
set(_ANDROID_ABI_x86_64_ARCH "x86_64")
-set(_ANDROID_ABI_x86_64_HEADER "x86_64-linux-android")
+set(_ANDROID_ABI_x86_64_TRIPLE "x86_64-linux-android")
set(_ANDROID_PROC_aarch64_ARCH_ABI "arm64-v8a")
set(_ANDROID_PROC_armv7-a_ARCH_ABI "armeabi-v7a")
@@ -261,7 +298,40 @@ if(NOT CMAKE_ANDROID_ARCH_ABI)
else()
# https://developer.android.com/ndk/guides/application_mk.html
# Default is the oldest ARM ABI.
- set(CMAKE_ANDROID_ARCH_ABI "armeabi")
+
+ # Lookup the available ABIs among all toolchains.
+ set(_ANDROID_ABIS "")
+ file(GLOB _ANDROID_CONFIG_MKS
+ "${CMAKE_ANDROID_NDK}/build/core/toolchains/*/config.mk"
+ "${CMAKE_ANDROID_NDK}/toolchains/*/config.mk"
+ )
+ foreach(config_mk IN LISTS _ANDROID_CONFIG_MKS)
+ file(STRINGS "${config_mk}" _ANDROID_TOOL_ABIS REGEX "^TOOLCHAIN_ABIS :=")
+ string(REPLACE "TOOLCHAIN_ABIS :=" "" _ANDROID_TOOL_ABIS "${_ANDROID_TOOL_ABIS}")
+ separate_arguments(_ANDROID_TOOL_ABIS UNIX_COMMAND "${_ANDROID_TOOL_ABIS}")
+ list(APPEND _ANDROID_ABIS ${_ANDROID_TOOL_ABIS})
+ unset(_ANDROID_TOOL_ABIS)
+ endforeach()
+ unset(_ANDROID_CONFIG_MKS)
+
+ # Choose the oldest among the available arm ABIs.
+ if(_ANDROID_ABIS)
+ list(REMOVE_DUPLICATES _ANDROID_ABIS)
+ cmake_policy(PUSH)
+ cmake_policy(SET CMP0057 NEW)
+ foreach(abi armeabi armeabi-v7a arm64-v8a)
+ if("${abi}" IN_LIST _ANDROID_ABIS)
+ set(CMAKE_ANDROID_ARCH_ABI "${abi}")
+ break()
+ endif()
+ endforeach()
+ cmake_policy(POP)
+ endif()
+ unset(_ANDROID_ABIS)
+
+ if(NOT CMAKE_ANDROID_ARCH_ABI)
+ set(CMAKE_ANDROID_ARCH_ABI "armeabi")
+ endif()
endif()
endif()
set(CMAKE_ANDROID_ARCH "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_ARCH}")
@@ -272,7 +342,7 @@ if(_ANDROID_SYSROOT_ARCH AND NOT "x${_ANDROID_SYSROOT_ARCH}" STREQUAL "x${CMAKE_
"does not match architecture '${CMAKE_ANDROID_ARCH}' for the ABI '${CMAKE_ANDROID_ARCH_ABI}'."
)
endif()
-set(CMAKE_ANDROID_ARCH_HEADER_TRIPLE "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_HEADER}")
+set(CMAKE_ANDROID_ARCH_TRIPLE "${_ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_TRIPLE}")
# Select a processor.
if(NOT CMAKE_SYSTEM_PROCESSOR)
@@ -285,7 +355,7 @@ if(NOT _ANDROID_ABI_${CMAKE_ANDROID_ARCH_ABI}_PROC STREQUAL CMAKE_SYSTEM_PROCESS
endif()
if(CMAKE_ANDROID_NDK AND NOT DEFINED CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
- if(IS_DIRECTORY "${CMAKE_ANDROID_NDK}/sysroot/usr/include/${CMAKE_ANDROID_ARCH_HEADER_TRIPLE}")
+ if(IS_DIRECTORY "${CMAKE_ANDROID_NDK}/sysroot/usr/include/${CMAKE_ANDROID_ARCH_TRIPLE}")
# Unified headers exist so we use them by default.
set(CMAKE_ANDROID_NDK_DEPRECATED_HEADERS 0)
else()
@@ -304,8 +374,10 @@ set(CMAKE_ANDROID_ARCH_ABI \"${CMAKE_ANDROID_ARCH_ABI}\")
if(CMAKE_ANDROID_NDK)
string(APPEND CMAKE_SYSTEM_CUSTOM_CODE
- "set(CMAKE_ANDROID_ARCH_HEADER_TRIPLE \"${CMAKE_ANDROID_ARCH_HEADER_TRIPLE}\")\n"
+ "set(CMAKE_ANDROID_ARCH_TRIPLE \"${CMAKE_ANDROID_ARCH_TRIPLE}\")\n"
"set(CMAKE_ANDROID_NDK_DEPRECATED_HEADERS \"${CMAKE_ANDROID_NDK_DEPRECATED_HEADERS}\")\n"
+ "set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG \"${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}\")\n"
+ "set(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED \"${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}\")\n"
)
endif()
@@ -338,3 +410,5 @@ endif()
# Report the chosen architecture.
message(STATUS "Android: Targeting API '${CMAKE_SYSTEM_VERSION}' with architecture '${CMAKE_ANDROID_ARCH}', ABI '${CMAKE_ANDROID_ARCH_ABI}', and processor '${CMAKE_SYSTEM_PROCESSOR}'")
+
+cmake_policy(POP)
diff --git a/Modules/Platform/Android-GNU-CXX.cmake b/Modules/Platform/Android-GNU-CXX.cmake
index 41279d1f7..d30d0ff4e 100644
--- a/Modules/Platform/Android-GNU-CXX.cmake
+++ b/Modules/Platform/Android-GNU-CXX.cmake
@@ -1,2 +1,5 @@
include(Platform/Android-GNU)
__android_compiler_gnu(CXX)
+if(_ANDROID_STL_NOSTDLIBXX)
+ string(APPEND CMAKE_CXX_STANDARD_LIBRARIES " -nodefaultlibs -lgcc -lc -lm -ldl")
+endif()
diff --git a/Modules/Platform/Android-Initialize.cmake b/Modules/Platform/Android-Initialize.cmake
index a434f90ea..a5d282085 100644
--- a/Modules/Platform/Android-Initialize.cmake
+++ b/Modules/Platform/Android-Initialize.cmake
@@ -17,6 +17,13 @@ if(CMAKE_SYSTEM_VERSION EQUAL 1)
return()
endif()
+set(CMAKE_BUILD_TYPE_INIT Debug)
+
+# Skip sysroot selection if the NDK has a unified toolchain.
+if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ return()
+endif()
+
if(NOT CMAKE_SYSROOT)
if(CMAKE_ANDROID_NDK)
set(CMAKE_SYSROOT "${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}/arch-${CMAKE_ANDROID_ARCH}")
@@ -40,5 +47,3 @@ else()
"Android: No CMAKE_SYSROOT was selected."
)
endif()
-
-set(CMAKE_BUILD_TYPE_INIT Debug)
diff --git a/Modules/Platform/Android.cmake b/Modules/Platform/Android.cmake
index 3d69733bb..f08f84176 100644
--- a/Modules/Platform/Android.cmake
+++ b/Modules/Platform/Android.cmake
@@ -2,9 +2,11 @@ include(Platform/Linux)
set(ANDROID 1)
-# Android has soname, but binary names must end in ".so" so we cannot append
-# a version number. Also we cannot portably represent symlinks on the host.
-set(CMAKE_PLATFORM_NO_VERSIONED_SONAME 1)
+# Conventionally Android does not use versioned soname
+# But in modern versions it is acceptable
+if(NOT DEFINED CMAKE_PLATFORM_NO_VERSIONED_SONAME)
+ set(CMAKE_PLATFORM_NO_VERSIONED_SONAME 1)
+endif()
# Android reportedly ignores RPATH, and we cannot predict the install
# location anyway.
diff --git a/Modules/Platform/Android/Determine-Compiler-NDK.cmake b/Modules/Platform/Android/Determine-Compiler-NDK.cmake
index 064992514..f56e1d5e5 100644
--- a/Modules/Platform/Android/Determine-Compiler-NDK.cmake
+++ b/Modules/Platform/Android/Determine-Compiler-NDK.cmake
@@ -1,6 +1,32 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
+# In Android NDK r19 and above there is a single clang toolchain.
+if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
+ if(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION AND NOT CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION STREQUAL "clang")
+ message(FATAL_ERROR
+ "Android: The CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION value '${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}' "
+ "is not supported by this NDK. It must be 'clang' or not set at all."
+ )
+ endif()
+ message(STATUS "Android: Selected unified Clang toolchain")
+ set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "clang")
+ set(_ANDROID_TOOL_C_COMPILER "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/clang${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_MACHINE "${CMAKE_ANDROID_ARCH_TRIPLE}")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "")
+ set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN "")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/${CMAKE_ANDROID_ARCH_TRIPLE}-")
+ set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_CXX_COMPILER "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/clang++${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_MACHINE "${CMAKE_ANDROID_ARCH_TRIPLE}")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_VERSION "")
+ set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED}/bin/${CMAKE_ANDROID_ARCH_TRIPLE}-")
+ set(_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}")
+ set(_CMAKE_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_ARCH_TRIPLE}-")
+ return()
+endif()
+
# In Android NDK releases there is build system toolchain selection logic in
# these files:
#
@@ -35,7 +61,18 @@ elseif(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION)
endif()
set(_ANDROID_TOOL_PATTERNS "*-${CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION}")
else()
- set(_ANDROID_TOOL_PATTERNS "*-[0-9].[0-9]")
+ # If we can find any gcc toolchains then use one by default.
+ # Otherwise we look for clang toolchains (e.g. NDK r18+).
+ file(GLOB _ANDROID_CONFIG_MKS_FOR_GCC
+ "${CMAKE_ANDROID_NDK}/build/core/toolchains/*-[0-9].[0-9]/config.mk"
+ "${CMAKE_ANDROID_NDK}/toolchains/*-[0-9].[0-9]/config.mk"
+ )
+ if(_ANDROID_CONFIG_MKS_FOR_GCC)
+ set(_ANDROID_TOOL_PATTERNS "*-[0-9].[0-9]")
+ else()
+ set(_ANDROID_TOOL_PATTERNS "*-clang")
+ endif()
+ unset(_ANDROID_CONFIG_MKS_FOR_GCC)
endif()
set(_ANDROID_CONFIG_MK_PATTERNS)
foreach(base "build/core/toolchains" "toolchains")
@@ -184,40 +221,16 @@ if(NOT _ANDROID_TOOL_PREFIX AND "${_ANDROID_TOOL_NAME}" MATCHES "^(.*-)[0-9.]+$"
set(_ANDROID_TOOL_PREFIX "${CMAKE_MATCH_1}")
endif()
-# Identify the host platform.
-if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
- if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
- set(_ANDROID_HOST_DIR "darwin-x86_64")
- else()
- set(_ANDROID_HOST_DIR "darwin-x86")
- endif()
-elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
- if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
- set(_ANDROID_HOST_DIR "linux-x86_64")
- else()
- set(_ANDROID_HOST_DIR "linux-x86")
- endif()
-elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
- if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64")
- set(_ANDROID_HOST_DIR "windows-x86_64")
- else()
- set(_ANDROID_HOST_DIR "windows")
- endif()
-else()
- message(FATAL_ERROR "Android: Builds hosted on '${CMAKE_HOST_SYSTEM_NAME}' not supported.")
-endif()
-
# Help CMakeFindBinUtils locate things.
set(_CMAKE_TOOLCHAIN_PREFIX "${_ANDROID_TOOL_PREFIX}")
-set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "${_ANDROID_HOST_DIR}")
set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "${_ANDROID_TOOL_VERS_NDK}")
# _ANDROID_TOOL_PREFIX should now match `gcc -dumpmachine`.
string(REGEX REPLACE "-$" "" _ANDROID_TOOL_C_TOOLCHAIN_MACHINE "${_ANDROID_TOOL_PREFIX}")
set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "${_ANDROID_TOOL_VERS}")
-set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${_ANDROID_HOST_DIR}/bin/${_ANDROID_TOOL_PREFIX}")
+set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}/bin/${_ANDROID_TOOL_PREFIX}")
set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "${_ANDROID_HOST_EXT}")
set(_ANDROID_TOOL_CXX_TOOLCHAIN_MACHINE "${_ANDROID_TOOL_C_TOOLCHAIN_MACHINE}")
@@ -227,9 +240,9 @@ set(_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX "${_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX}")
if(_ANDROID_TOOL_CLANG_NAME)
message(STATUS "Android: Selected Clang toolchain '${_ANDROID_TOOL_CLANG_NAME}' with GCC toolchain '${_ANDROID_TOOL_NAME}'")
- set(_ANDROID_TOOL_C_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${_ANDROID_HOST_DIR}/bin/clang${_ANDROID_HOST_EXT}")
- set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN ${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${_ANDROID_HOST_DIR})
- set(_ANDROID_TOOL_CXX_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${_ANDROID_HOST_DIR}/bin/clang++${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_C_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}/bin/clang${_ANDROID_HOST_EXT}")
+ set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN ${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_NAME}/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG})
+ set(_ANDROID_TOOL_CXX_COMPILER "${CMAKE_ANDROID_NDK}/toolchains/${_ANDROID_TOOL_LLVM_NAME}/prebuilt/${CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG}/bin/clang++${_ANDROID_HOST_EXT}")
set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "${_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN}")
else()
message(STATUS "Android: Selected GCC toolchain '${_ANDROID_TOOL_NAME}'")
@@ -256,4 +269,3 @@ unset(_ANDROID_TOOL_PREFIX)
unset(_ANDROID_TOOL_CLANG_NAME)
unset(_ANDROID_TOOL_CLANG_VERS)
unset(_ANDROID_TOOL_LLVM_NAME)
-unset(_ANDROID_HOST_DIR)
diff --git a/Modules/Platform/Android/Determine-Compiler-Standalone.cmake b/Modules/Platform/Android/Determine-Compiler-Standalone.cmake
index 4c1ac1fe4..5095aff50 100644
--- a/Modules/Platform/Android/Determine-Compiler-Standalone.cmake
+++ b/Modules/Platform/Android/Determine-Compiler-Standalone.cmake
@@ -62,5 +62,4 @@ else()
set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "")
endif()
-set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "")
set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "")
diff --git a/Modules/Platform/Android/Determine-Compiler.cmake b/Modules/Platform/Android/Determine-Compiler.cmake
index a03ebcc29..5c6b97b8b 100644
--- a/Modules/Platform/Android/Determine-Compiler.cmake
+++ b/Modules/Platform/Android/Determine-Compiler.cmake
@@ -40,7 +40,6 @@ if(CMAKE_ANDROID_NDK)
elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
include(Platform/Android/Determine-Compiler-Standalone)
else()
- set(_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG "")
set(_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION "")
set(_ANDROID_TOOL_C_COMPILER "")
set(_ANDROID_TOOL_C_TOOLCHAIN_MACHINE "")
@@ -65,7 +64,6 @@ macro(__android_determine_compiler lang)
# Save the Android-specific information in CMake${lang}Compiler.cmake.
set(CMAKE_${lang}_COMPILER_CUSTOM_CODE "
-set(CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG \"${_ANDROID_TOOL_NDK_TOOLCHAIN_HOST_TAG}\")
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION \"${_ANDROID_TOOL_NDK_TOOLCHAIN_VERSION}\")
set(CMAKE_${lang}_ANDROID_TOOLCHAIN_MACHINE \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_MACHINE}\")
set(CMAKE_${lang}_ANDROID_TOOLCHAIN_VERSION \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_VERSION}\")
diff --git a/Modules/Platform/Android/abi-common.cmake b/Modules/Platform/Android/abi-common.cmake
index 10fb8972d..b01ef6144 100644
--- a/Modules/Platform/Android/abi-common.cmake
+++ b/Modules/Platform/Android/abi-common.cmake
@@ -3,7 +3,7 @@ string(APPEND _ANDROID_ABI_INIT_CFLAGS
" -no-canonical-prefixes"
)
-if(CMAKE_ANDROID_NDK AND NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
+if(CMAKE_ANDROID_NDK AND NOT CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED AND NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
string(APPEND _ANDROID_ABI_INIT_CFLAGS " -D__ANDROID_API__=${CMAKE_SYSTEM_VERSION}")
endif()
@@ -12,9 +12,25 @@ if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
-if(CMAKE_POSITION_INDEPENDENT_CODE)
- string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -fPIE -pie")
+cmake_policy(GET CMP0083 _CMP0083)
+if(_CMP0083 STREQUAL NEW)
+ # PIE Flags are managed by compiler configuration files
+ if(CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL 16)
+ # ensure PIE flags are passed to the linker
+ set(CMAKE_C_LINK_PIE_SUPPORTED YES CACHE INTERNAL "PIE (C)")
+ set(CMAKE_CXX_LINK_PIE_SUPPORTED YES CACHE INTERNAL "PIE (CXX)")
+ if(CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL 21)
+ # no PIE executable are no longer supported
+ set(CMAKE_C_LINK_NO_PIE_SUPPORTED NO CACHE INTERNAL "NO_PIE (C)")
+ set(CMAKE_CXX_LINK_NO_PIE_SUPPORTED NO CACHE INTERNAL "NO_PIE (CXX)")
+ endif()
+ endif()
+else()
+ if(CMAKE_POSITION_INDEPENDENT_CODE)
+ string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -fPIE -pie")
+ endif()
endif()
+unset(_CMP0083)
string(APPEND _ANDROID_ABI_INIT_EXE_LDFLAGS " -Wl,--gc-sections")
diff --git a/Modules/Platform/Android/ndk-stl-c++.cmake b/Modules/Platform/Android/ndk-stl-c++.cmake
index a12411c78..1cafd1fd7 100644
--- a/Modules/Platform/Android/ndk-stl-c++.cmake
+++ b/Modules/Platform/Android/ndk-stl-c++.cmake
@@ -1,6 +1,7 @@
# <ndk>/sources/cxx-stl/llvm-libc++/Android.mk
set(_ANDROID_STL_RTTI 1)
set(_ANDROID_STL_EXCEPTIONS 1)
+set(_ANDROID_STL_NOSTDLIBXX 1)
macro(__android_stl_cxx lang filename)
# Add the include directory.
if(EXISTS "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libcxx/include/cstddef")
diff --git a/Modules/Platform/Android/ndk-stl-gabi++.cmake b/Modules/Platform/Android/ndk-stl-gabi++.cmake
index 850a47a99..d3b9e45af 100644
--- a/Modules/Platform/Android/ndk-stl-gabi++.cmake
+++ b/Modules/Platform/Android/ndk-stl-gabi++.cmake
@@ -1,6 +1,7 @@
# <ndk>/sources/cxx-stl/gabi++/Android.mk
set(_ANDROID_STL_RTTI 1)
set(_ANDROID_STL_EXCEPTIONS 1)
+set(_ANDROID_STL_NOSTDLIBXX 1)
macro(__android_stl_gabixx lang filename)
__android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/gabi++/include" 1)
__android_stl_lib(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/gabi++/libs/${CMAKE_ANDROID_ARCH_ABI}/${filename}" 1)
diff --git a/Modules/Platform/Android/ndk-stl-gnustl.cmake b/Modules/Platform/Android/ndk-stl-gnustl.cmake
index b3226ee0e..46cedc601 100644
--- a/Modules/Platform/Android/ndk-stl-gnustl.cmake
+++ b/Modules/Platform/Android/ndk-stl-gnustl.cmake
@@ -1,6 +1,7 @@
# <ndk>/sources/cxx-stl/gnu-libstdc++/Android.mk
set(_ANDROID_STL_RTTI 1)
set(_ANDROID_STL_EXCEPTIONS 1)
+set(_ANDROID_STL_NOSTDLIBXX 1)
macro(__android_stl_gnustl lang filename)
__android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${CMAKE_${lang}_ANDROID_TOOLCHAIN_VERSION}/include" 1)
__android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${CMAKE_${lang}_ANDROID_TOOLCHAIN_VERSION}/libs/${CMAKE_ANDROID_ARCH_ABI}/include" 1)
diff --git a/Modules/Platform/Android/ndk-stl-none.cmake b/Modules/Platform/Android/ndk-stl-none.cmake
index 9049c91de..45122f71a 100644
--- a/Modules/Platform/Android/ndk-stl-none.cmake
+++ b/Modules/Platform/Android/ndk-stl-none.cmake
@@ -1,2 +1,3 @@
+set(_ANDROID_STL_NOSTDLIBXX 1)
macro(__android_stl lang)
endmacro()
diff --git a/Modules/Platform/Android/ndk-stl-stlport.cmake b/Modules/Platform/Android/ndk-stl-stlport.cmake
index eab6b945c..efad33bdc 100644
--- a/Modules/Platform/Android/ndk-stl-stlport.cmake
+++ b/Modules/Platform/Android/ndk-stl-stlport.cmake
@@ -1,6 +1,7 @@
# <ndk>/sources/cxx-stl/stlport/Android.mk
set(_ANDROID_STL_RTTI 1)
set(_ANDROID_STL_EXCEPTIONS 1)
+set(_ANDROID_STL_NOSTDLIBXX 0)
macro(__android_stl_stlport lang filename)
__android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/stlport/stlport" 1)
__android_stl_lib(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/stlport/libs/${CMAKE_ANDROID_ARCH_ABI}/${filename}" 1)
diff --git a/Modules/Platform/Android/ndk-stl-system.cmake b/Modules/Platform/Android/ndk-stl-system.cmake
index dd554fe30..7d86a40ae 100644
--- a/Modules/Platform/Android/ndk-stl-system.cmake
+++ b/Modules/Platform/Android/ndk-stl-system.cmake
@@ -1,6 +1,7 @@
# <ndk>/android-ndk-r11c/sources/cxx-stl/system/Android.mk
set(_ANDROID_STL_RTTI 0)
set(_ANDROID_STL_EXCEPTIONS 0)
+set(_ANDROID_STL_NOSTDLIBXX 0)
macro(__android_stl lang)
__android_stl_inc(${lang} "${CMAKE_ANDROID_NDK}/sources/cxx-stl/system/include" 1)
endmacro()
diff --git a/Modules/Platform/Darwin-Absoft-Fortran.cmake b/Modules/Platform/Apple-Absoft-Fortran.cmake
index 8caa2026c..8caa2026c 100644
--- a/Modules/Platform/Darwin-Absoft-Fortran.cmake
+++ b/Modules/Platform/Apple-Absoft-Fortran.cmake
diff --git a/Modules/Platform/Apple-Apple-Swift.cmake b/Modules/Platform/Apple-Apple-Swift.cmake
new file mode 100644
index 000000000..7ca3e36e9
--- /dev/null
+++ b/Modules/Platform/Apple-Apple-Swift.cmake
@@ -0,0 +1 @@
+set(CMAKE_Swift_SYSROOT_FLAG "-sdk")
diff --git a/Modules/Platform/Apple-AppleClang-C.cmake b/Modules/Platform/Apple-AppleClang-C.cmake
new file mode 100644
index 000000000..f45ccf413
--- /dev/null
+++ b/Modules/Platform/Apple-AppleClang-C.cmake
@@ -0,0 +1,6 @@
+include(Platform/Apple-Clang-C)
+if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2)
+ set(CMAKE_C_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
+else()
+ unset(CMAKE_C_SYSTEM_FRAMEWORK_SEARCH_FLAG)
+endif()
diff --git a/Modules/Platform/Apple-AppleClang-CXX.cmake b/Modules/Platform/Apple-AppleClang-CXX.cmake
new file mode 100644
index 000000000..1128204cf
--- /dev/null
+++ b/Modules/Platform/Apple-AppleClang-CXX.cmake
@@ -0,0 +1,6 @@
+include(Platform/Apple-Clang-CXX)
+if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.2)
+ set(CMAKE_CXX_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
+else()
+ unset(CMAKE_CXX_SYSTEM_FRAMEWORK_SEARCH_FLAG)
+endif()
diff --git a/Modules/Platform/Apple-AppleClang-OBJC.cmake b/Modules/Platform/Apple-AppleClang-OBJC.cmake
new file mode 100644
index 000000000..b78edb1b7
--- /dev/null
+++ b/Modules/Platform/Apple-AppleClang-OBJC.cmake
@@ -0,0 +1,6 @@
+include(Platform/Apple-Clang-OBJC)
+if(NOT CMAKE_OBJC_COMPILER_VERSION VERSION_LESS 4.2)
+ set(CMAKE_OBJC_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
+else()
+ unset(CMAKE_OBJC_SYSTEM_FRAMEWORK_SEARCH_FLAG)
+endif()
diff --git a/Modules/Platform/Apple-AppleClang-OBJCXX.cmake b/Modules/Platform/Apple-AppleClang-OBJCXX.cmake
new file mode 100644
index 000000000..ed172f13d
--- /dev/null
+++ b/Modules/Platform/Apple-AppleClang-OBJCXX.cmake
@@ -0,0 +1,6 @@
+include(Platform/Apple-Clang-OBJCXX)
+if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 4.2)
+ set(CMAKE_OBJCXX_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
+else()
+ unset(CMAKE_OBJCXX_SYSTEM_FRAMEWORK_SEARCH_FLAG)
+endif()
diff --git a/Modules/Platform/Apple-Clang-ASM.cmake b/Modules/Platform/Apple-Clang-ASM.cmake
new file mode 100644
index 000000000..935cce97a
--- /dev/null
+++ b/Modules/Platform/Apple-Clang-ASM.cmake
@@ -0,0 +1,2 @@
+include(Platform/Apple-Clang)
+__apple_compiler_clang(ASM)
diff --git a/Modules/Platform/Apple-Clang-C.cmake b/Modules/Platform/Apple-Clang-C.cmake
new file mode 100644
index 000000000..4d0dc8294
--- /dev/null
+++ b/Modules/Platform/Apple-Clang-C.cmake
@@ -0,0 +1,2 @@
+include(Platform/Apple-Clang)
+__apple_compiler_clang(C)
diff --git a/Modules/Platform/Apple-Clang-CXX.cmake b/Modules/Platform/Apple-Clang-CXX.cmake
new file mode 100644
index 000000000..6c1ddc104
--- /dev/null
+++ b/Modules/Platform/Apple-Clang-CXX.cmake
@@ -0,0 +1,2 @@
+include(Platform/Apple-Clang)
+__apple_compiler_clang(CXX)
diff --git a/Modules/Platform/Apple-Clang-OBJC.cmake b/Modules/Platform/Apple-Clang-OBJC.cmake
new file mode 100644
index 000000000..63cd8468c
--- /dev/null
+++ b/Modules/Platform/Apple-Clang-OBJC.cmake
@@ -0,0 +1,2 @@
+include(Platform/Apple-Clang)
+__apple_compiler_clang(OBJC)
diff --git a/Modules/Platform/Apple-Clang-OBJCXX.cmake b/Modules/Platform/Apple-Clang-OBJCXX.cmake
new file mode 100644
index 000000000..28fc3529d
--- /dev/null
+++ b/Modules/Platform/Apple-Clang-OBJCXX.cmake
@@ -0,0 +1,2 @@
+include(Platform/Apple-Clang)
+__apple_compiler_clang(OBJCXX)
diff --git a/Modules/Platform/Apple-Clang.cmake b/Modules/Platform/Apple-Clang.cmake
new file mode 100644
index 000000000..0681bfb05
--- /dev/null
+++ b/Modules/Platform/Apple-Clang.cmake
@@ -0,0 +1,32 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+# This module is shared by multiple languages; use include blocker.
+include_guard()
+
+macro(__apple_compiler_clang lang)
+ set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output
+ set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
+ set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
+ set(CMAKE_${lang}_SYSROOT_FLAG "-isysroot")
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
+ if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.2)
+ set(CMAKE_${lang}_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
+ endif()
+ if(_CMAKE_OSX_SYSROOT_PATH MATCHES "/iPhoneOS")
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-miphoneos-version-min=")
+ elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/iPhoneSimulator")
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mios-simulator-version-min=")
+ elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/AppleTVOS")
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mtvos-version-min=")
+ elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/AppleTVSimulator")
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mtvos-simulator-version-min=")
+ elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/WatchOS")
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mwatchos-version-min=")
+ elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/WatchSimulator")
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mwatchos-simulator-version-min=")
+ else()
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
+ endif()
+endmacro()
diff --git a/Modules/Platform/Apple-GNU-C.cmake b/Modules/Platform/Apple-GNU-C.cmake
new file mode 100644
index 000000000..5481c99d8
--- /dev/null
+++ b/Modules/Platform/Apple-GNU-C.cmake
@@ -0,0 +1,4 @@
+include(Platform/Apple-GNU)
+__apple_compiler_gnu(C)
+cmake_gnu_set_sysroot_flag(C)
+cmake_gnu_set_osx_deployment_target_flag(C)
diff --git a/Modules/Platform/Apple-GNU-CXX.cmake b/Modules/Platform/Apple-GNU-CXX.cmake
new file mode 100644
index 000000000..727f72641
--- /dev/null
+++ b/Modules/Platform/Apple-GNU-CXX.cmake
@@ -0,0 +1,4 @@
+include(Platform/Apple-GNU)
+__apple_compiler_gnu(CXX)
+cmake_gnu_set_sysroot_flag(CXX)
+cmake_gnu_set_osx_deployment_target_flag(CXX)
diff --git a/Modules/Platform/Apple-GNU-Fortran.cmake b/Modules/Platform/Apple-GNU-Fortran.cmake
new file mode 100644
index 000000000..2f53603cb
--- /dev/null
+++ b/Modules/Platform/Apple-GNU-Fortran.cmake
@@ -0,0 +1,10 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+include(Platform/Apple-GNU)
+__apple_compiler_gnu(Fortran)
+cmake_gnu_set_sysroot_flag(Fortran)
+cmake_gnu_set_osx_deployment_target_flag(Fortran)
+
+set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
+set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-current_version ")
diff --git a/Modules/Platform/Apple-GNU-OBJC.cmake b/Modules/Platform/Apple-GNU-OBJC.cmake
new file mode 100644
index 000000000..aa8b33f24
--- /dev/null
+++ b/Modules/Platform/Apple-GNU-OBJC.cmake
@@ -0,0 +1,4 @@
+include(Platform/Apple-GNU)
+__apple_compiler_gnu(OBJC)
+cmake_gnu_set_sysroot_flag(OBJC)
+cmake_gnu_set_osx_deployment_target_flag(OBJC)
diff --git a/Modules/Platform/Apple-GNU-OBJCXX.cmake b/Modules/Platform/Apple-GNU-OBJCXX.cmake
new file mode 100644
index 000000000..919e11d92
--- /dev/null
+++ b/Modules/Platform/Apple-GNU-OBJCXX.cmake
@@ -0,0 +1,4 @@
+include(Platform/Apple-GNU)
+__apple_compiler_gnu(OBJCXX)
+cmake_gnu_set_sysroot_flag(OBJCXX)
+cmake_gnu_set_osx_deployment_target_flag(OBJCXX)
diff --git a/Modules/Platform/Apple-GNU.cmake b/Modules/Platform/Apple-GNU.cmake
new file mode 100644
index 000000000..0eb816831
--- /dev/null
+++ b/Modules/Platform/Apple-GNU.cmake
@@ -0,0 +1,57 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+# This module is shared by multiple languages; use include blocker.
+include_guard()
+
+macro(__apple_compiler_gnu lang)
+ set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output
+ # GNU does not have -shared on OS X
+ set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
+ set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
+
+ if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.3)
+ set(CMAKE_${lang}_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
+ endif()
+endmacro()
+
+macro(cmake_gnu_set_sysroot_flag lang)
+ if(NOT DEFINED CMAKE_${lang}_SYSROOT_FLAG)
+ set(_doc "${lang} compiler has -isysroot")
+ message(STATUS "Checking whether ${_doc}")
+ execute_process(
+ COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help"
+ OUTPUT_VARIABLE _gcc_help
+ ERROR_VARIABLE _gcc_help
+ )
+ if("${_gcc_help}" MATCHES "isysroot")
+ message(STATUS "Checking whether ${_doc} - yes")
+ set(CMAKE_${lang}_SYSROOT_FLAG "-isysroot")
+ else()
+ message(STATUS "Checking whether ${_doc} - no")
+ set(CMAKE_${lang}_SYSROOT_FLAG "")
+ endif()
+ set(CMAKE_${lang}_SYSROOT_FLAG_CODE "set(CMAKE_${lang}_SYSROOT_FLAG \"${CMAKE_${lang}_SYSROOT_FLAG}\")")
+ endif()
+endmacro()
+
+macro(cmake_gnu_set_osx_deployment_target_flag lang)
+ if(NOT DEFINED CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG)
+ set(_doc "${lang} compiler supports OSX deployment target flag")
+ message(STATUS "Checking whether ${_doc}")
+ execute_process(
+ COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help"
+ OUTPUT_VARIABLE _gcc_help
+ ERROR_VARIABLE _gcc_help
+ )
+ if("${_gcc_help}" MATCHES "macosx-version-min")
+ message(STATUS "Checking whether ${_doc} - yes")
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
+ else()
+ message(STATUS "Checking whether ${_doc} - no")
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "")
+ endif()
+ set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG_CODE "set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG \"${CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG}\")")
+ endif()
+endmacro()
diff --git a/Modules/Platform/Apple-Intel-C.cmake b/Modules/Platform/Apple-Intel-C.cmake
new file mode 100644
index 000000000..95bb270d3
--- /dev/null
+++ b/Modules/Platform/Apple-Intel-C.cmake
@@ -0,0 +1,2 @@
+include(Platform/Apple-Intel)
+__apple_compiler_intel(C)
diff --git a/Modules/Platform/Apple-Intel-CXX.cmake b/Modules/Platform/Apple-Intel-CXX.cmake
new file mode 100644
index 000000000..b87e512df
--- /dev/null
+++ b/Modules/Platform/Apple-Intel-CXX.cmake
@@ -0,0 +1,2 @@
+include(Platform/Apple-Intel)
+__apple_compiler_intel(CXX)
diff --git a/Modules/Platform/Apple-Intel-Fortran.cmake b/Modules/Platform/Apple-Intel-Fortran.cmake
new file mode 100644
index 000000000..e54e23762
--- /dev/null
+++ b/Modules/Platform/Apple-Intel-Fortran.cmake
@@ -0,0 +1,8 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+include(Platform/Apple-Intel)
+__apple_compiler_intel(Fortran)
+
+set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
+set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-current_version ")
diff --git a/Modules/Platform/Apple-Intel.cmake b/Modules/Platform/Apple-Intel.cmake
new file mode 100644
index 000000000..a854be996
--- /dev/null
+++ b/Modules/Platform/Apple-Intel.cmake
@@ -0,0 +1,19 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+# This module is shared by multiple languages; use include blocker.
+include_guard()
+
+macro(__apple_compiler_intel lang)
+ set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output
+ set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
+ set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
+
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,")
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",")
+
+ if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 12.0)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
+ endif()
+endmacro()
diff --git a/Modules/Platform/Darwin-NAG-Fortran.cmake b/Modules/Platform/Apple-NAG-Fortran.cmake
index 8d3e741c1..8d3e741c1 100644
--- a/Modules/Platform/Darwin-NAG-Fortran.cmake
+++ b/Modules/Platform/Apple-NAG-Fortran.cmake
diff --git a/Modules/Platform/Apple-NVIDIA-CUDA.cmake b/Modules/Platform/Apple-NVIDIA-CUDA.cmake
new file mode 100644
index 000000000..bec394839
--- /dev/null
+++ b/Modules/Platform/Apple-NVIDIA-CUDA.cmake
@@ -0,0 +1,19 @@
+include(Platform/Darwin)
+
+set(__IMPLICT_LINKS )
+foreach(dir ${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES})
+ string(APPEND __IMPLICT_LINKS " -L\"${dir}\"")
+endforeach()
+foreach(lib ${CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES})
+ if(${lib} MATCHES "/")
+ string(APPEND __IMPLICT_LINKS " \"${lib}\"")
+ else()
+ string(APPEND __IMPLICT_LINKS " -l${lib}")
+ endif()
+endforeach()
+
+set(CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS "-shared -Wl,-headerpad_max_install_names")
+set(CMAKE_SHARED_MODULE_CREATE_CUDA_FLAGS "-shared -Wl,-headerpad_max_install_names")
+
+set(CMAKE_CUDA_CREATE_SHARED_LIBRARY "<CMAKE_CUDA_HOST_LINK_LAUNCHER> <CMAKE_SHARED_LIBRARY_CUDA_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>${__IMPLICT_LINKS}")
+set(CMAKE_CUDA_CREATE_SHARED_MODULE "<CMAKE_CUDA_HOST_LINK_LAUNCHER> <CMAKE_SHARED_LIBRARY_CUDA_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CUDA_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>${__IMPLICT_LINKS}")
diff --git a/Modules/Platform/Apple-PGI-C.cmake b/Modules/Platform/Apple-PGI-C.cmake
new file mode 100644
index 000000000..1e117247b
--- /dev/null
+++ b/Modules/Platform/Apple-PGI-C.cmake
@@ -0,0 +1,2 @@
+include(Platform/Apple-PGI)
+__apple_compiler_pgi(C)
diff --git a/Modules/Platform/Apple-PGI-CXX.cmake b/Modules/Platform/Apple-PGI-CXX.cmake
new file mode 100644
index 000000000..aa5daf7dd
--- /dev/null
+++ b/Modules/Platform/Apple-PGI-CXX.cmake
@@ -0,0 +1,2 @@
+include(Platform/Apple-PGI)
+__apple_compiler_pgi(CXX)
diff --git a/Modules/Platform/Apple-PGI-Fortran.cmake b/Modules/Platform/Apple-PGI-Fortran.cmake
new file mode 100644
index 000000000..1e3e4b1a7
--- /dev/null
+++ b/Modules/Platform/Apple-PGI-Fortran.cmake
@@ -0,0 +1,2 @@
+include(Platform/Apple-PGI)
+__apple_compiler_pgi(Fortran)
diff --git a/Modules/Platform/Apple-PGI.cmake b/Modules/Platform/Apple-PGI.cmake
new file mode 100644
index 000000000..8d343b7d1
--- /dev/null
+++ b/Modules/Platform/Apple-PGI.cmake
@@ -0,0 +1,11 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# This module is shared by multiple languages; use include blocker.
+include_guard()
+
+macro(__apple_compiler_pgi lang)
+ set(CMAKE_${lang}_OSX_COMPATIBILITY_VERSION_FLAG "-Wl,-compatibility_version,")
+ set(CMAKE_${lang}_OSX_CURRENT_VERSION_FLAG "-Wl,-current_version,")
+ set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-install_name")
+endmacro()
diff --git a/Modules/Platform/Apple-VisualAge-C.cmake b/Modules/Platform/Apple-VisualAge-C.cmake
new file mode 100644
index 000000000..7fa603231
--- /dev/null
+++ b/Modules/Platform/Apple-VisualAge-C.cmake
@@ -0,0 +1 @@
+include(Platform/Apple-XL-C)
diff --git a/Modules/Platform/Apple-VisualAge-CXX.cmake b/Modules/Platform/Apple-VisualAge-CXX.cmake
new file mode 100644
index 000000000..12dd34740
--- /dev/null
+++ b/Modules/Platform/Apple-VisualAge-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Apple-XL-CXX)
diff --git a/Modules/Platform/Apple-XL-C.cmake b/Modules/Platform/Apple-XL-C.cmake
new file mode 100644
index 000000000..e4fc3dd25
--- /dev/null
+++ b/Modules/Platform/Apple-XL-C.cmake
@@ -0,0 +1,7 @@
+set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle")
+
+# Enable shared library versioning.
+set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-install_name")
+
+# -qhalt=e = Halt on error messages (rather than just severe errors)
+string(APPEND CMAKE_C_FLAGS_INIT " -qhalt=e")
diff --git a/Modules/Platform/Apple-XL-CXX.cmake b/Modules/Platform/Apple-XL-CXX.cmake
new file mode 100644
index 000000000..ea330c8cf
--- /dev/null
+++ b/Modules/Platform/Apple-XL-CXX.cmake
@@ -0,0 +1,7 @@
+set(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS "-bundle")
+
+# Enable shared library versioning.
+set(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-install_name")
+
+# -qhalt=e = Halt on error messages (rather than just severe errors)
+string(APPEND CMAKE_C_FLAGS_INIT " -qhalt=e")
diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake
index 784c8c676..ca90712dc 100644
--- a/Modules/Platform/CYGWIN-GNU.cmake
+++ b/Modules/Platform/CYGWIN-GNU.cmake
@@ -27,6 +27,9 @@ macro(__cygwin_compiler_gnu lang)
# No -fPIC on cygwin
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "")
+ set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "")
# Initialize C link type selection flags. These flags are used when
diff --git a/Modules/Platform/CrayLinuxEnvironment.cmake b/Modules/Platform/CrayLinuxEnvironment.cmake
index a1a3d3f10..f2aaf3f71 100644
--- a/Modules/Platform/CrayLinuxEnvironment.cmake
+++ b/Modules/Platform/CrayLinuxEnvironment.cmake
@@ -1,6 +1,5 @@
-# Compute Node Linux doesn't quite work the same as native Linux so all of this
-# needs to be custom. We use the variables defined through Cray's environment
-# modules to set up the right paths for things.
+# CrayLinuxEnvironment: loaded by users cross-compiling on a Cray front-end
+# node by specifying "-DCMAKE_SYSTEM_NAME=CrayLinuxEnvironment" to cmake
set(UNIX 1)
@@ -30,13 +29,6 @@ endif()
# Note: this may need to change in the future with 64-bit ARM
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
-set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
-set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
-set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
-set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
-
-set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
-
# Don't override shared lib support if it's already been set and possibly
# overridden elsewhere by the CrayPrgEnv module
if(NOT CMAKE_FIND_LIBRARY_SUFFIXES)
@@ -44,12 +36,9 @@ if(NOT CMAKE_FIND_LIBRARY_SUFFIXES)
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
endif()
-set(CMAKE_DL_LIBS dl)
+# The rest of this file is based on UnixPaths.cmake, adjusted for Cray
-# Note: Much of this is pulled from UnixPaths.cmake but adjusted to the Cray
-# environment accordingly
-
-# Get the install directory of the running cmake to the search directories
+# add the install directory of the running cmake to the search directories
# CMAKE_ROOT is CMAKE_INSTALL_PREFIX/share/cmake, so we need to go two levels up
get_filename_component(__cmake_install_dir "${CMAKE_ROOT}" PATH)
get_filename_component(__cmake_install_dir "${__cmake_install_dir}" PATH)
@@ -81,7 +70,6 @@ if (NOT CMAKE_FIND_NO_INSTALL_PREFIX)
endif()
list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
- $ENV{SYSROOT_DIR}/usr/include
$ENV{SYSROOT_DIR}/usr/include/X11
)
list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
@@ -95,57 +83,5 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
$ENV{SYSROOT_DIR}/lib64
)
-# Compute the intersection of several lists
-function(__cray_list_intersect OUTPUT INPUT0)
- if(ARGC EQUAL 2)
- list(APPEND ${OUTPUT} ${${INPUT0}})
- else()
- foreach(I IN LISTS ${INPUT0})
- set(__is_common 1)
- foreach(L IN LISTS ARGN)
- list(FIND ${L} "${I}" __idx)
- if(__idx EQUAL -1)
- set(__is_common 0)
- break()
- endif()
- endforeach()
- if(__is_common)
- list(APPEND ${OUTPUT} "${I}")
- endif()
- endforeach()
- endif()
- set(${OUTPUT} ${${OUTPUT}} PARENT_SCOPE)
-endfunction()
-
-macro(__list_clean_dupes var)
- if(${var})
- list(REMOVE_DUPLICATES ${var})
- endif()
-endmacro()
-
-get_property(__langs GLOBAL PROPERTY ENABLED_LANGUAGES)
-set(__cray_inc_path_vars)
-set(__cray_lib_path_vars)
-foreach(__lang IN LISTS __langs)
- list(APPEND __cray_inc_path_vars CMAKE_${__lang}_IMPLICIT_INCLUDE_DIRECTORIES)
- list(APPEND __cray_lib_path_vars CMAKE_${__lang}_IMPLICIT_LINK_DIRECTORIES)
-endforeach()
-if(__cray_inc_path_vars)
- __cray_list_intersect(__cray_implicit_include_dirs ${__cray_inc_path_vars})
- if(__cray_implicit_include_dirs)
- list(INSERT CMAKE_SYSTEM_INCLUDE_PATH 0 ${__cray_implicit_include_dirs})
- endif()
-endif()
-if(__cray_lib_path_vars)
- __cray_list_intersect(__cray_implicit_library_dirs ${__cray_lib_path_vars})
- if(__cray_implicit_library_dirs)
- list(INSERT CMAKE_SYSTEM_LIBRARY_PATH 0 ${__cray_implicit_library_dirs})
- endif()
-endif()
-__list_clean_dupes(CMAKE_SYSTEM_PREFIX_PATH)
-__list_clean_dupes(CMAKE_SYSTEM_INCLUDE_PATH)
-__list_clean_dupes(CMAKE_SYSTEM_LIBRARY_PATH)
-__list_clean_dupes(CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES)
-
# Enable use of lib64 search path variants by default.
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
diff --git a/Modules/Platform/Darwin-AppleClang-C.cmake b/Modules/Platform/Darwin-AppleClang-C.cmake
deleted file mode 100644
index 3216b2909..000000000
--- a/Modules/Platform/Darwin-AppleClang-C.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-include(Platform/Darwin-Clang-C)
-if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.2)
- set(CMAKE_C_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
-else()
- unset(CMAKE_C_SYSTEM_FRAMEWORK_SEARCH_FLAG)
-endif()
diff --git a/Modules/Platform/Darwin-AppleClang-CXX.cmake b/Modules/Platform/Darwin-AppleClang-CXX.cmake
deleted file mode 100644
index 3fedf8c07..000000000
--- a/Modules/Platform/Darwin-AppleClang-CXX.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-include(Platform/Darwin-Clang-CXX)
-if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.2)
- set(CMAKE_CXX_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
-else()
- unset(CMAKE_CXX_SYSTEM_FRAMEWORK_SEARCH_FLAG)
-endif()
diff --git a/Modules/Platform/Darwin-Clang-C.cmake b/Modules/Platform/Darwin-Clang-C.cmake
deleted file mode 100644
index 0a1502ea9..000000000
--- a/Modules/Platform/Darwin-Clang-C.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-include(Platform/Darwin-Clang)
-__darwin_compiler_clang(C)
diff --git a/Modules/Platform/Darwin-Clang-CXX.cmake b/Modules/Platform/Darwin-Clang-CXX.cmake
deleted file mode 100644
index f8e8d888e..000000000
--- a/Modules/Platform/Darwin-Clang-CXX.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-include(Platform/Darwin-Clang)
-__darwin_compiler_clang(CXX)
diff --git a/Modules/Platform/Darwin-Clang.cmake b/Modules/Platform/Darwin-Clang.cmake
deleted file mode 100644
index a6661a849..000000000
--- a/Modules/Platform/Darwin-Clang.cmake
+++ /dev/null
@@ -1,20 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-
-# This module is shared by multiple languages; use include blocker.
-if(__DARWIN_COMPILER_CLANG)
- return()
-endif()
-set(__DARWIN_COMPILER_CLANG 1)
-
-macro(__darwin_compiler_clang lang)
- set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output
- set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
- set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
- set(CMAKE_${lang}_SYSROOT_FLAG "-isysroot")
- set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
- if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.2)
- set(CMAKE_${lang}_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
- endif()
-endmacro()
diff --git a/Modules/Platform/Darwin-GNU-C.cmake b/Modules/Platform/Darwin-GNU-C.cmake
deleted file mode 100644
index efdfd0014..000000000
--- a/Modules/Platform/Darwin-GNU-C.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-include(Platform/Darwin-GNU)
-__darwin_compiler_gnu(C)
-cmake_gnu_set_sysroot_flag(C)
-cmake_gnu_set_osx_deployment_target_flag(C)
diff --git a/Modules/Platform/Darwin-GNU-CXX.cmake b/Modules/Platform/Darwin-GNU-CXX.cmake
deleted file mode 100644
index e3c2ea7c5..000000000
--- a/Modules/Platform/Darwin-GNU-CXX.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-include(Platform/Darwin-GNU)
-__darwin_compiler_gnu(CXX)
-cmake_gnu_set_sysroot_flag(CXX)
-cmake_gnu_set_osx_deployment_target_flag(CXX)
diff --git a/Modules/Platform/Darwin-GNU-Fortran.cmake b/Modules/Platform/Darwin-GNU-Fortran.cmake
deleted file mode 100644
index 568d79b0c..000000000
--- a/Modules/Platform/Darwin-GNU-Fortran.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-include(Platform/Darwin-GNU)
-__darwin_compiler_gnu(Fortran)
-cmake_gnu_set_sysroot_flag(Fortran)
-cmake_gnu_set_osx_deployment_target_flag(Fortran)
-
-set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
-set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-current_version ")
diff --git a/Modules/Platform/Darwin-GNU.cmake b/Modules/Platform/Darwin-GNU.cmake
deleted file mode 100644
index 9f9ef01cb..000000000
--- a/Modules/Platform/Darwin-GNU.cmake
+++ /dev/null
@@ -1,60 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-
-# This module is shared by multiple languages; use include blocker.
-if(__DARWIN_COMPILER_GNU)
- return()
-endif()
-set(__DARWIN_COMPILER_GNU 1)
-
-macro(__darwin_compiler_gnu lang)
- set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output
- # GNU does not have -shared on OS X
- set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
- set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
-
- if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.3)
- set(CMAKE_${lang}_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
- endif()
-endmacro()
-
-macro(cmake_gnu_set_sysroot_flag lang)
- if(NOT DEFINED CMAKE_${lang}_SYSROOT_FLAG)
- set(_doc "${lang} compiler has -isysroot")
- message(STATUS "Checking whether ${_doc}")
- execute_process(
- COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help"
- OUTPUT_VARIABLE _gcc_help
- ERROR_VARIABLE _gcc_help
- )
- if("${_gcc_help}" MATCHES "isysroot")
- message(STATUS "Checking whether ${_doc} - yes")
- set(CMAKE_${lang}_SYSROOT_FLAG "-isysroot")
- else()
- message(STATUS "Checking whether ${_doc} - no")
- set(CMAKE_${lang}_SYSROOT_FLAG "")
- endif()
- set(CMAKE_${lang}_SYSROOT_FLAG_CODE "set(CMAKE_${lang}_SYSROOT_FLAG \"${CMAKE_${lang}_SYSROOT_FLAG}\")")
- endif()
-endmacro()
-
-macro(cmake_gnu_set_osx_deployment_target_flag lang)
- if(NOT DEFINED CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG)
- set(_doc "${lang} compiler supports OSX deployment target flag")
- message(STATUS "Checking whether ${_doc}")
- execute_process(
- COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help"
- OUTPUT_VARIABLE _gcc_help
- ERROR_VARIABLE _gcc_help
- )
- if("${_gcc_help}" MATCHES "macosx-version-min")
- message(STATUS "Checking whether ${_doc} - yes")
- set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
- else()
- message(STATUS "Checking whether ${_doc} - no")
- set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "")
- endif()
- set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG_CODE "set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG \"${CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG}\")")
- endif()
-endmacro()
diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake
index b539e457d..2d797f68f 100644
--- a/Modules/Platform/Darwin-Initialize.cmake
+++ b/Modules/Platform/Darwin-Initialize.cmake
@@ -20,6 +20,10 @@ execute_process(COMMAND sw_vers -productVersion
set(CMAKE_OSX_ARCHITECTURES "$ENV{CMAKE_OSX_ARCHITECTURES}" CACHE STRING
"Build architectures for OSX")
+# macOS, iOS, tvOS, and watchOS should lookup compilers from
+# Platform/Apple-${CMAKE_CXX_COMPILER_ID}-<LANG>
+set(CMAKE_EFFECTIVE_SYSTEM_NAME "Apple")
+
#----------------------------------------------------------------------------
# _CURRENT_OSX_VERSION - as a two-component string: 10.5, 10.6, ...
#
@@ -30,7 +34,7 @@ string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*$" "\\1"
# CMAKE_OSX_DEPLOYMENT_TARGET
# Set cache variable - end user may change this during ccmake or cmake-gui configure.
-if(_CURRENT_OSX_VERSION VERSION_GREATER 10.3)
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND _CURRENT_OSX_VERSION VERSION_GREATER 10.3)
set(CMAKE_OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}" CACHE STRING
"Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value.")
endif()
@@ -45,6 +49,12 @@ elseif(NOT "x$ENV{SDKROOT}" STREQUAL "x" AND
(NOT "x$ENV{SDKROOT}" MATCHES "/" OR IS_DIRECTORY "$ENV{SDKROOT}"))
# Use the value of SDKROOT from the environment.
set(_CMAKE_OSX_SYSROOT_DEFAULT "$ENV{SDKROOT}")
+elseif(CMAKE_SYSTEM_NAME STREQUAL iOS)
+ set(_CMAKE_OSX_SYSROOT_DEFAULT "iphoneos")
+elseif(CMAKE_SYSTEM_NAME STREQUAL tvOS)
+ set(_CMAKE_OSX_SYSROOT_DEFAULT "appletvos")
+elseif(CMAKE_SYSTEM_NAME STREQUAL watchOS)
+ set(_CMAKE_OSX_SYSROOT_DEFAULT "watchos")
elseif("${CMAKE_GENERATOR}" MATCHES Xcode
OR CMAKE_OSX_DEPLOYMENT_TARGET
OR CMAKE_OSX_ARCHITECTURES MATCHES "[^;]"
diff --git a/Modules/Platform/Darwin-Intel-C.cmake b/Modules/Platform/Darwin-Intel-C.cmake
deleted file mode 100644
index 81c630f4a..000000000
--- a/Modules/Platform/Darwin-Intel-C.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-include(Platform/Darwin-Intel)
-__darwin_compiler_intel(C)
diff --git a/Modules/Platform/Darwin-Intel-CXX.cmake b/Modules/Platform/Darwin-Intel-CXX.cmake
deleted file mode 100644
index 90ae53be3..000000000
--- a/Modules/Platform/Darwin-Intel-CXX.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-include(Platform/Darwin-Intel)
-__darwin_compiler_intel(CXX)
diff --git a/Modules/Platform/Darwin-Intel-Fortran.cmake b/Modules/Platform/Darwin-Intel-Fortran.cmake
deleted file mode 100644
index 2299da9ce..000000000
--- a/Modules/Platform/Darwin-Intel-Fortran.cmake
+++ /dev/null
@@ -1,8 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-include(Platform/Darwin-Intel)
-__darwin_compiler_intel(Fortran)
-
-set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
-set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-current_version ")
diff --git a/Modules/Platform/Darwin-Intel.cmake b/Modules/Platform/Darwin-Intel.cmake
deleted file mode 100644
index dd33cec4b..000000000
--- a/Modules/Platform/Darwin-Intel.cmake
+++ /dev/null
@@ -1,19 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-
-# This module is shared by multiple languages; use include blocker.
-if(__DARWIN_COMPILER_INTEL)
- return()
-endif()
-set(__DARWIN_COMPILER_INTEL 1)
-
-macro(__darwin_compiler_intel lang)
- set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output
- set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
- set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
-
- if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 12.0)
- set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
- endif()
-endmacro()
diff --git a/Modules/Platform/Darwin-PGI-C.cmake b/Modules/Platform/Darwin-PGI-C.cmake
deleted file mode 100644
index 790919b08..000000000
--- a/Modules/Platform/Darwin-PGI-C.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-include(Platform/Darwin-PGI)
-__darwin_compiler_pgi(C)
diff --git a/Modules/Platform/Darwin-PGI-CXX.cmake b/Modules/Platform/Darwin-PGI-CXX.cmake
deleted file mode 100644
index ceaed7152..000000000
--- a/Modules/Platform/Darwin-PGI-CXX.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-include(Platform/Darwin-PGI)
-__darwin_compiler_pgi(CXX)
diff --git a/Modules/Platform/Darwin-PGI-Fortran.cmake b/Modules/Platform/Darwin-PGI-Fortran.cmake
deleted file mode 100644
index 146807ba9..000000000
--- a/Modules/Platform/Darwin-PGI-Fortran.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-include(Platform/Darwin-PGI)
-__darwin_compiler_pgi(Fortran)
diff --git a/Modules/Platform/Darwin-PGI.cmake b/Modules/Platform/Darwin-PGI.cmake
deleted file mode 100644
index 04479a897..000000000
--- a/Modules/Platform/Darwin-PGI.cmake
+++ /dev/null
@@ -1,14 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-# This module is shared by multiple languages; use include blocker.
-if(__DARWIN_COMPILER_PGI)
- return()
-endif()
-set(__DARWIN_COMPILER_PGI 1)
-
-macro(__darwin_compiler_pgi lang)
- set(CMAKE_${lang}_OSX_COMPATIBILITY_VERSION_FLAG "-Wl,-compatibility_version,")
- set(CMAKE_${lang}_OSX_CURRENT_VERSION_FLAG "-Wl,-current_version,")
- set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-install_name")
-endmacro()
diff --git a/Modules/Platform/Darwin-VisualAge-C.cmake b/Modules/Platform/Darwin-VisualAge-C.cmake
deleted file mode 100644
index 859914f86..000000000
--- a/Modules/Platform/Darwin-VisualAge-C.cmake
+++ /dev/null
@@ -1 +0,0 @@
-include(Platform/Darwin-XL-C)
diff --git a/Modules/Platform/Darwin-VisualAge-CXX.cmake b/Modules/Platform/Darwin-VisualAge-CXX.cmake
deleted file mode 100644
index 46c1005df..000000000
--- a/Modules/Platform/Darwin-VisualAge-CXX.cmake
+++ /dev/null
@@ -1 +0,0 @@
-include(Platform/Darwin-XL-CXX)
diff --git a/Modules/Platform/Darwin-XL-C.cmake b/Modules/Platform/Darwin-XL-C.cmake
deleted file mode 100644
index 2aeb132d1..000000000
--- a/Modules/Platform/Darwin-XL-C.cmake
+++ /dev/null
@@ -1,8 +0,0 @@
-set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-qmkshrobj")
-set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle")
-
-# Enable shared library versioning.
-set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-install_name")
-
-# -qhalt=e = Halt on error messages (rather than just severe errors)
-string(APPEND CMAKE_C_FLAGS_INIT " -qhalt=e")
diff --git a/Modules/Platform/Darwin-XL-CXX.cmake b/Modules/Platform/Darwin-XL-CXX.cmake
deleted file mode 100644
index f8e1906a8..000000000
--- a/Modules/Platform/Darwin-XL-CXX.cmake
+++ /dev/null
@@ -1,8 +0,0 @@
-set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-qmkshrobj")
-set(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS "-bundle")
-
-# Enable shared library versioning.
-set(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-install_name")
-
-# -qhalt=e = Halt on error messages (rather than just severe errors)
-string(APPEND CMAKE_C_FLAGS_INIT " -qhalt=e")
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index 727baa6e1..e5a57b59f 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -1,5 +1,22 @@
set(APPLE 1)
+if(CMAKE_SYSTEM_NAME STREQUAL "iOS" OR CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
+ if(NOT DEFINED CMAKE_MACOSX_BUNDLE)
+ set(CMAKE_MACOSX_BUNDLE ON)
+ endif()
+
+ list(APPEND CMAKE_FIND_ROOT_PATH "${_CMAKE_OSX_SYSROOT_PATH}")
+ if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+ endif()
+ if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+ endif()
+ if(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
+ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
+ endif()
+endif()
+
# Darwin versions:
# 6.x == Mac OSX 10.2 (Jaguar)
# 7.x == Mac OSX 10.3 (Panther)
@@ -35,24 +52,21 @@ if("${DARWIN_MAJOR_VERSION}" GREATER 8)
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
endif()
-set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
-set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
-set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
-set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
+foreach(lang C CXX OBJC OBJCXX)
+ set(CMAKE_${lang}_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
+ set(CMAKE_${lang}_OSX_CURRENT_VERSION_FLAG "-current_version ")
+ set(CMAKE_${lang}_LINK_FLAGS "-Wl,-headerpad_max_install_names")
-set(CMAKE_C_LINK_FLAGS "-Wl,-headerpad_max_install_names")
-set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names")
+ if(HAVE_FLAG_SEARCH_PATHS_FIRST)
+ set(CMAKE_${lang}_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_${lang}_LINK_FLAGS}")
+ endif()
-if(HAVE_FLAG_SEARCH_PATHS_FIRST)
- set(CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
- set(CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
-endif()
+ set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
+ set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
+ set(CMAKE_SHARED_MODULE_LOADER_${lang}_FLAG "-Wl,-bundle_loader,")
+endforeach()
set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
-set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
-set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names")
-set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
-set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a")
# hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree
@@ -67,12 +81,6 @@ endif()
# Enable shared library versioning.
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name")
-# Xcode does not support -isystem yet.
-if(XCODE)
- set(CMAKE_INCLUDE_SYSTEM_FLAG_C)
- set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX)
-endif()
-
if("${_CURRENT_OSX_VERSION}" VERSION_LESS "10.5")
# Need to list dependent shared libraries on link line. When building
# with -isysroot (for universal binaries), the linker always looks for
@@ -81,32 +89,25 @@ if("${_CURRENT_OSX_VERSION}" VERSION_LESS "10.5")
set(CMAKE_LINK_DEPENDENT_LIBRARY_FILES 1)
endif()
-set(CMAKE_C_CREATE_SHARED_LIBRARY
- "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
-set(CMAKE_CXX_CREATE_SHARED_LIBRARY
- "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
-set(CMAKE_Fortran_CREATE_SHARED_LIBRARY
- "<CMAKE_Fortran_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
-
-set(CMAKE_CXX_CREATE_SHARED_MODULE
- "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
+foreach(lang C CXX Fortran OBJC OBJCXX)
+ # Xcode does not support -isystem yet.
+ if(XCODE)
+ set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang})
+ endif()
-set(CMAKE_C_CREATE_SHARED_MODULE
- "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CREATE_C_FLAGS> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
+ set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
+ "<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
-set(CMAKE_Fortran_CREATE_SHARED_MODULE
- "<CMAKE_Fortran_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CREATE_Fortran_FLAGS> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
+ set(CMAKE_${lang}_CREATE_SHARED_MODULE
+ "<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS> <LINK_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
-set(CMAKE_C_CREATE_MACOSX_FRAMEWORK
- "<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
-set(CMAKE_CXX_CREATE_MACOSX_FRAMEWORK
- "<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
+ set(CMAKE_${lang}_CREATE_MACOSX_FRAMEWORK
+ "<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
-# Set default framework search path flag for languages known to use a
-# preprocessor that may find headers in frameworks.
-set(CMAKE_C_FRAMEWORK_SEARCH_FLAG -F)
-set(CMAKE_CXX_FRAMEWORK_SEARCH_FLAG -F)
-set(CMAKE_Fortran_FRAMEWORK_SEARCH_FLAG -F)
+ # Set default framework search path flag for languages known to use a
+ # preprocessor that may find headers in frameworks.
+ set(CMAKE_${lang}_FRAMEWORK_SEARCH_FLAG -F)
+endforeach()
# default to searching for frameworks first
if(NOT DEFINED CMAKE_FIND_FRAMEWORK)
@@ -156,6 +157,10 @@ if(_CMAKE_OSX_SYSROOT_PATH)
endif()
endforeach()
endif()
+if (OSX_DEVELOPER_ROOT AND EXISTS "${OSX_DEVELOPER_ROOT}/Library/Frameworks")
+ list(APPEND CMAKE_SYSTEM_FRAMEWORK_PATH
+ ${OSX_DEVELOPER_ROOT}/Library/Frameworks)
+endif()
list(APPEND CMAKE_SYSTEM_FRAMEWORK_PATH
/Library/Frameworks
/Network/Library/Frameworks
@@ -205,8 +210,8 @@ unset(_apps_paths)
include(Platform/UnixPaths)
if(_CMAKE_OSX_SYSROOT_PATH AND EXISTS ${_CMAKE_OSX_SYSROOT_PATH}/usr/include)
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${_CMAKE_OSX_SYSROOT_PATH}/usr)
- foreach(lang C CXX)
- list(APPEND CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES ${_CMAKE_OSX_SYSROOT_PATH}/usr/include)
+ foreach(lang C CXX OBJC OBJCXX)
+ list(APPEND _CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT ${_CMAKE_OSX_SYSROOT_PATH}/usr/include)
endforeach()
endif()
list(APPEND CMAKE_SYSTEM_PREFIX_PATH
diff --git a/Modules/Platform/DragonFly.cmake b/Modules/Platform/DragonFly.cmake
index c22677b9d..12e5f3ccc 100644
--- a/Modules/Platform/DragonFly.cmake
+++ b/Modules/Platform/DragonFly.cmake
@@ -3,3 +3,7 @@
# see http://archive.netbsd.se/?ml=dfbsd-users&a=2007-07&m=4678361
include(Platform/FreeBSD)
+
+# DragonFly BSD requires -z origin to enable $ORIGIN expansion in RPATH.
+# This is not required for FreeBSD since 10.2-RELEASE.
+set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-z,origin,-rpath,")
diff --git a/Modules/Platform/FreeBSD-Determine-CXX.cmake b/Modules/Platform/FreeBSD-Determine-CXX.cmake
new file mode 100644
index 000000000..b594daeb0
--- /dev/null
+++ b/Modules/Platform/FreeBSD-Determine-CXX.cmake
@@ -0,0 +1,3 @@
+if(NOT CMAKE_CXX_COMPILER_NAMES)
+ set(CMAKE_CXX_COMPILER_NAMES c++)
+endif()
diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake
index ce4d3ce49..4a4c00dc4 100644
--- a/Modules/Platform/FreeBSD.cmake
+++ b/Modules/Platform/FreeBSD.cmake
@@ -1,11 +1,14 @@
set(CMAKE_DL_LIBS "")
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE")
+# PIE link options are managed in Compiler/<compiler>.cmake file
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty
+# Does not require -z origin since 10.2-RELEASE
+set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN")
set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,")
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
diff --git a/Modules/Platform/Fuchsia.cmake b/Modules/Platform/Fuchsia.cmake
index 896da7bfb..4b1380506 100644
--- a/Modules/Platform/Fuchsia.cmake
+++ b/Modules/Platform/Fuchsia.cmake
@@ -3,6 +3,9 @@ set(FUCHSIA 1)
set(CMAKE_DL_LIBS "")
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE")
+set(_CMAKE_C_PIE_MAY_BE_SUPPORTED_BY_LINKER YES)
+set(CMAKE_C_LINK_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE} "-pie")
+set(CMAKE_C_LINK_OPTIONS_NO_PIE "-no-pie")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
diff --git a/Modules/Platform/GHS-MULTI-Determine.cmake b/Modules/Platform/GHS-MULTI-Determine.cmake
new file mode 100644
index 000000000..349d90657
--- /dev/null
+++ b/Modules/Platform/GHS-MULTI-Determine.cmake
@@ -0,0 +1,56 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#Setup Green Hills MULTI specific compilation information
+
+if(CMAKE_HOST_UNIX)
+ set(GHS_OS_ROOT "/usr/ghs" CACHE PATH "GHS platform OS search root directory")
+else()
+ set(GHS_OS_ROOT "C:/ghs" CACHE PATH "GHS platform OS search root directory")
+endif()
+mark_as_advanced(GHS_OS_ROOT)
+
+set(GHS_OS_DIR "NOTFOUND" CACHE PATH "GHS platform OS directory")
+mark_as_advanced(GHS_OS_DIR)
+
+set(GHS_OS_DIR_OPTION "-os_dir " CACHE STRING "GHS compiler OS option")
+mark_as_advanced(GHS_OS_DIR_OPTION)
+
+#set GHS_OS_DIR if not set by user
+if(NOT GHS_OS_DIR)
+ if(EXISTS ${GHS_OS_ROOT})
+
+ #get all directories in root directory
+ FILE(GLOB GHS_CANDIDATE_OS_DIRS
+ LIST_DIRECTORIES true RELATIVE ${GHS_OS_ROOT} ${GHS_OS_ROOT}/*)
+ FILE(GLOB GHS_CANDIDATE_OS_FILES
+ LIST_DIRECTORIES false RELATIVE ${GHS_OS_ROOT} ${GHS_OS_ROOT}/*)
+ if(GHS_CANDIDATE_OS_FILES)
+ list(REMOVE_ITEM GHS_CANDIDATE_OS_DIRS ${GHS_CANDIDATE_OS_FILES})
+ endif ()
+
+ #filter based on platform name
+ if(GHS_TARGET_PLATFORM MATCHES "integrity")
+ list(FILTER GHS_CANDIDATE_OS_DIRS INCLUDE REGEX "int[0-9][0-9][0-9][0-9a-z]")
+ else() #fall-back for standalone
+ unset(GHS_CANDIDATE_OS_DIRS)
+ set(GHS_OS_DIR "IGNORE")
+ endif()
+
+ if(GHS_CANDIDATE_OS_DIRS)
+ list(SORT GHS_CANDIDATE_OS_DIRS)
+ list(GET GHS_CANDIDATE_OS_DIRS -1 GHS_OS_DIR)
+ string(CONCAT GHS_OS_DIR ${GHS_OS_ROOT} "/" ${GHS_OS_DIR})
+ endif()
+
+ #update cache with new value
+ set(GHS_OS_DIR "${GHS_OS_DIR}" CACHE PATH "GHS platform OS directory" FORCE)
+ endif()
+endif()
+
+set(GHS_BSP_NAME "IGNORE" CACHE STRING "BSP name")
+
+set(GHS_CUSTOMIZATION "" CACHE FILEPATH "optional GHS customization")
+mark_as_advanced(GHS_CUSTOMIZATION)
+set(GHS_GPJ_MACROS "" CACHE STRING "optional GHS macros generated in the .gpjs for legacy reasons")
+mark_as_advanced(GHS_GPJ_MACROS)
diff --git a/Modules/Platform/GHS-MULTI-Initialize.cmake b/Modules/Platform/GHS-MULTI-Initialize.cmake
deleted file mode 100644
index fcda6f6c4..000000000
--- a/Modules/Platform/GHS-MULTI-Initialize.cmake
+++ /dev/null
@@ -1,41 +0,0 @@
-# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
-# file Copyright.txt or https://cmake.org/licensing for details.
-
-
-#Setup Greenhills MULTI specific compilation information
-
-if (NOT GHS_INT_DIRECTORY)
- #Assume the C:/ghs/int#### directory that is latest is preferred
- set(GHS_EXPECTED_ROOT "C:/ghs")
- if (EXISTS ${GHS_EXPECTED_ROOT})
- FILE(GLOB GHS_CANDIDATE_INT_DIRS RELATIVE
- ${GHS_EXPECTED_ROOT} ${GHS_EXPECTED_ROOT}/*)
- string(REGEX MATCHALL "int[0-9][0-9][0-9][0-9]" GHS_CANDIDATE_INT_DIRS
- ${GHS_CANDIDATE_INT_DIRS})
- if (GHS_CANDIDATE_INT_DIRS)
- list(SORT GHS_CANDIDATE_INT_DIRS)
- list(GET GHS_CANDIDATE_INT_DIRS -1 GHS_INT_DIRECTORY)
- string(CONCAT GHS_INT_DIRECTORY ${GHS_EXPECTED_ROOT} "/"
- ${GHS_INT_DIRECTORY})
- endif ()
- endif ()
-
- #Try to look for known registry values
- if (NOT GHS_INT_DIRECTORY)
- find_path(GHS_INT_DIRECTORY INTEGRITY.ld PATHS
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\GreenHillsSoftware6433c345;InstallLocation]" #int1122
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\GreenHillsSoftware289b6625;InstallLocation]" #int1104
- )
- endif ()
-
- set(GHS_INT_DIRECTORY ${GHS_INT_DIRECTORY} CACHE PATH
- "Path to integrity directory")
-endif ()
-
-set(GHS_OS_DIR ${GHS_INT_DIRECTORY} CACHE PATH "OS directory")
-set(GHS_PRIMARY_TARGET "arm_integrity.tgt" CACHE STRING "target for compilation")
-set(GHS_BSP_NAME "simarm" CACHE STRING "BSP name")
-set(GHS_CUSTOMIZATION "" CACHE FILEPATH "optional GHS customization")
-mark_as_advanced(GHS_CUSTOMIZATION)
-set(GHS_GPJ_MACROS "" CACHE STRING "optional GHS macros generated in the .gpjs for legacy reasons")
-mark_as_advanced(GHS_GPJ_MACROS)
diff --git a/Modules/Platform/GNU.cmake b/Modules/Platform/GNU.cmake
index e8c3b657b..fac29a8fa 100644
--- a/Modules/Platform/GNU.cmake
+++ b/Modules/Platform/GNU.cmake
@@ -8,6 +8,33 @@ set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,")
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
+# Debian policy requires that shared libraries be installed without
+# executable permission. Fedora policy requires that shared libraries
+# be installed with the executable permission. Since the native tools
+# create shared libraries with execute permission in the first place a
+# reasonable policy seems to be to install with execute permission by
+# default. In order to support debian packages we provide an option
+# here. The option default is based on the current distribution, but
+# packagers can set it explicitly on the command line.
+if(DEFINED CMAKE_INSTALL_SO_NO_EXE)
+ # Store the decision variable in the cache. This preserves any
+ # setting the user provides on the command line.
+ set(CMAKE_INSTALL_SO_NO_EXE "${CMAKE_INSTALL_SO_NO_EXE}" CACHE INTERNAL
+ "Install .so files without execute permission.")
+else()
+ # Store the decision variable as an internal cache entry to avoid
+ # checking the platform every time. This option is advanced enough
+ # that only package maintainers should need to adjust it. They are
+ # capable of providing a setting on the command line.
+ if(EXISTS "/etc/debian_version")
+ set(CMAKE_INSTALL_SO_NO_EXE 1 CACHE INTERNAL
+ "Install .so files without execute permission.")
+ else()
+ set(CMAKE_INSTALL_SO_NO_EXE 0 CACHE INTERNAL
+ "Install .so files without execute permission.")
+ endif()
+endif()
+
set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-gnu[a-z0-9_]*")
include(Platform/UnixPaths)
diff --git a/Modules/Platform/GNUtoMS_lib.bat.in b/Modules/Platform/GNUtoMS_lib.bat.in
index 2da920ab0..8613be359 100644
--- a/Modules/Platform/GNUtoMS_lib.bat.in
+++ b/Modules/Platform/GNUtoMS_lib.bat.in
@@ -1,3 +1,4 @@
@echo off
+set VSCMD_START_DIR=.
call "@CMAKE_GNUtoMS_BAT@"
lib /machine:"@CMAKE_GNUtoMS_ARCH@" %*
diff --git a/Modules/Platform/Generic-ADSP-C.cmake b/Modules/Platform/Generic-ADSP-C.cmake
index de1cee298..c8597cda7 100644
--- a/Modules/Platform/Generic-ADSP-C.cmake
+++ b/Modules/Platform/Generic-ADSP-C.cmake
@@ -9,6 +9,9 @@ string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " ")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " ")
string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO_INIT " ")
+set(CMAKE_C_LINKER_WRAPPER_FLAG "-flags-link" " ")
+set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",")
+
set(CMAKE_C_CREATE_STATIC_LIBRARY
"<CMAKE_C_COMPILER> -build-lib -proc ${ADSP_PROCESSOR} -si-revision ${ADSP_PROCESSOR_SILICIUM_REVISION} -o <TARGET> <CMAKE_C_LINK_FLAGS> <OBJECTS>")
@@ -17,4 +20,3 @@ set(CMAKE_C_LINK_EXECUTABLE
set(CMAKE_C_CREATE_SHARED_LIBRARY)
set(CMAKE_C_CREATE_MODULE_LIBRARY)
-
diff --git a/Modules/Platform/Generic-ADSP-CXX.cmake b/Modules/Platform/Generic-ADSP-CXX.cmake
index 0cde8f2e6..d76bb66bd 100644
--- a/Modules/Platform/Generic-ADSP-CXX.cmake
+++ b/Modules/Platform/Generic-ADSP-CXX.cmake
@@ -7,6 +7,9 @@ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " ")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " ")
string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT " ")
+set(CMAKE_CXX_LINKER_WRAPPER_FLAG "-flags-link" " ")
+set(CMAKE_CXX_LINKER_WRAPPER_FLAG_SEP ",")
+
set(CMAKE_CXX_CREATE_STATIC_LIBRARY
"<CMAKE_CXX_COMPILER> -build-lib -proc ${ADSP_PROCESSOR} -si-revision ${ADSP_PROCESSOR_SILICIUM_REVISION} -o <TARGET> <CMAKE_CXX_LINK_FLAGS> <OBJECTS>")
@@ -15,4 +18,3 @@ set(CMAKE_CXX_LINK_EXECUTABLE
set(CMAKE_CXX_CREATE_SHARED_LIBRARY)
set(CMAKE_CXX_CREATE_MODULE_LIBRARY)
-
diff --git a/Modules/Platform/Generic-SDCC-C.cmake b/Modules/Platform/Generic-SDCC-C.cmake
index bbefe193e..aef4abf17 100644
--- a/Modules/Platform/Generic-SDCC-C.cmake
+++ b/Modules/Platform/Generic-SDCC-C.cmake
@@ -37,11 +37,13 @@ if(NOT DEFINED CMAKE_EXE_LINKER_FLAGS_INIT)
set (CMAKE_EXE_LINKER_FLAGS_INIT --model-small)
endif()
+set(CMAKE_C_LINKER_WRAPPER_FLAG "-Wl" ",")
+
# compile a C file into an object file
set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
# link object files to an executable
-set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <OBJECTS> --out-fmt-ihx -o <TARGET> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>")
+set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <OBJECTS> -o <TARGET> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>")
# needs sdcc 2.7.0 + sddclib from cvs
set(CMAKE_C_CREATE_STATIC_LIBRARY
@@ -51,4 +53,3 @@ set(CMAKE_C_CREATE_STATIC_LIBRARY
# not supported by sdcc
set(CMAKE_C_CREATE_SHARED_LIBRARY "")
set(CMAKE_C_CREATE_MODULE_LIBRARY "")
-
diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake
index dfc2664d3..7e0af6166 100644
--- a/Modules/Platform/Haiku.cmake
+++ b/Modules/Platform/Haiku.cmake
@@ -11,6 +11,7 @@ set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
+set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN")
set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,")
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
diff --git a/Modules/Platform/IRIX.cmake b/Modules/Platform/IRIX.cmake
deleted file mode 100644
index 12b0f3774..000000000
--- a/Modules/Platform/IRIX.cmake
+++ /dev/null
@@ -1,53 +0,0 @@
-set(CMAKE_DL_LIBS "")
-set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -rdata_shared")
-set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath
-set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty
-if(NOT CMAKE_COMPILER_IS_GNUCXX)
- set(CMAKE_CXX_CREATE_STATIC_LIBRARY
- "<CMAKE_CXX_COMPILER> -ar -o <TARGET> <OBJECTS>")
- set (CMAKE_CXX_FLAGS_INIT "")
- set (CMAKE_CXX_FLAGS_DEBUG_INIT "-g")
- set (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-O3 -DNDEBUG")
- set (CMAKE_CXX_FLAGS_RELEASE_INIT "-O2 -DNDEBUG")
- set (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2")
- set (CMAKE_C_FLAGS_INIT "")
-endif()
-# set flags for gcc support
-include(Platform/UnixPaths)
-
-if(NOT CMAKE_COMPILER_IS_GNUCC)
- set (CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
- set (CMAKE_C_CREATE_ASSEMBLY_SOURCE
- "<CMAKE_C_COMPILER> <FLAGS> -S <SOURCE>"
- "mv `basename \"<SOURCE>\" | sed 's/\\.[^./]*$$//'`.s <ASSEMBLY_SOURCE>"
- )
-endif()
-
-if(NOT CMAKE_COMPILER_IS_GNUCXX)
- set (CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
- set (CMAKE_CXX_CREATE_ASSEMBLY_SOURCE
- "<CMAKE_CXX_COMPILER> <FLAGS> -S <SOURCE>"
- "mv `basename \"<SOURCE>\" | sed 's/\\.[^./]*$$//'`.s <ASSEMBLY_SOURCE>"
- )
-endif()
-
-if(NOT CMAKE_COMPILER_IS_GNUG77)
- set (CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE "<CMAKE_Fortran_COMPILER> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
- set (CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE
- "<CMAKE_Fortran_COMPILER> <FLAGS> -S <SOURCE>"
- "mv `basename \"<SOURCE>\" | sed 's/\\.[^./]*$$//'`.s <ASSEMBLY_SOURCE>"
- )
-endif()
-
-# Initialize C link type selection flags. These flags are used when
-# building a shared library, shared module, or executable that links
-# to other libraries to select whether to use the static or shared
-# versions of the libraries.
-foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
- set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-Bstatic")
- set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-Bdynamic")
-endforeach()
-
-# The IRIX linker needs to find transitive shared library dependencies
-# in the -L path.
-set(CMAKE_LINK_DEPENDENT_LIBRARY_DIRS 1)
diff --git a/Modules/Platform/IRIX64.cmake b/Modules/Platform/IRIX64.cmake
deleted file mode 100644
index ee9b96e89..000000000
--- a/Modules/Platform/IRIX64.cmake
+++ /dev/null
@@ -1,73 +0,0 @@
-set(CMAKE_DL_LIBS "")
-set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -rdata_shared")
-set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath
-set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") # : or empty
-set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
-if(NOT CMAKE_COMPILER_IS_GNUCC)
- # Set default flags init.
- set(CMAKE_C_FLAGS_INIT "")
- set(CMAKE_CXX_FLAGS_INIT "")
- set(CMAKE_Fortran_FLAGS_INIT "")
- set(CMAKE_EXE_LINKER_FLAGS_INIT "")
- set(CMAKE_SHARED_LINKER_FLAGS_INIT "")
- set(CMAKE_MODULE_LINKER_FLAGS_INIT "")
-
- # If no -o32, -n32, or -64 flag is given, set a reasonable default.
- if("$ENV{CFLAGS} $ENV{CXXFLAGS} $ENV{LDFLAGS}" MATCHES "-([no]32|64)")
- else()
- # Check if this is a 64-bit CMake.
- if(CMAKE_FILE_SELF MATCHES "^CMAKE_FILE_SELF$")
- exec_program(file ARGS ${CMAKE_COMMAND} OUTPUT_VARIABLE CMAKE_FILE_SELF)
- set(CMAKE_FILE_SELF "${CMAKE_FILE_SELF}" CACHE INTERNAL
- "Output of file command on ${CMAKE_COMMAND}.")
- endif()
-
- # Set initial flags to match cmake executable.
- if(CMAKE_FILE_SELF MATCHES " 64-bit ")
- set(CMAKE_C_FLAGS_INIT "-64")
- set(CMAKE_CXX_FLAGS_INIT "-64")
- set(CMAKE_Fortran_FLAGS_INIT "-64")
- set(CMAKE_EXE_LINKER_FLAGS_INIT "-64")
- set(CMAKE_SHARED_LINKER_FLAGS_INIT "-64")
- set(CMAKE_MODULE_LINKER_FLAGS_INIT "-64")
- endif()
- endif()
-
- # Set remaining defaults.
- set(CMAKE_CXX_CREATE_STATIC_LIBRARY
- "<CMAKE_CXX_COMPILER> -ar -o <TARGET> <OBJECTS>")
- set (CMAKE_CXX_FLAGS_DEBUG_INIT "-g")
- set (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-O3 -DNDEBUG")
- set (CMAKE_CXX_FLAGS_RELEASE_INIT "-O2 -DNDEBUG")
- set (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2")
-endif()
-include(Platform/UnixPaths)
-
-if(NOT CMAKE_COMPILER_IS_GNUCC)
- set (CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
- set (CMAKE_C_CREATE_ASSEMBLY_SOURCE
- "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE>"
- "mv `basename \"<SOURCE>\" | sed 's/\\.[^./]*$$//'`.s <ASSEMBLY_SOURCE>"
- )
-endif()
-
-if(NOT CMAKE_COMPILER_IS_GNUCXX)
- set (CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
- set (CMAKE_CXX_CREATE_ASSEMBLY_SOURCE
- "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE>"
- "mv `basename \"<SOURCE>\" | sed 's/\\.[^./]*$$//'`.s <ASSEMBLY_SOURCE>"
- )
-endif()
-
-# Initialize C link type selection flags. These flags are used when
-# building a shared library, shared module, or executable that links
-# to other libraries to select whether to use the static or shared
-# versions of the libraries.
-foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
- set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-Bstatic")
- set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-Bdynamic")
-endforeach()
-
-# The IRIX linker needs to find transitive shared library dependencies
-# in the -L path.
-set(CMAKE_LINK_DEPENDENT_LIBRARY_DIRS 1)
diff --git a/Modules/Platform/Linux-GNU.cmake b/Modules/Platform/Linux-GNU.cmake
index ce30a26a5..6878254ee 100644
--- a/Modules/Platform/Linux-GNU.cmake
+++ b/Modules/Platform/Linux-GNU.cmake
@@ -12,5 +12,4 @@ macro(__linux_compiler_gnu lang)
# We pass this for historical reasons. Projects may have
# executables that use dlopen but do not set ENABLE_EXPORTS.
set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic")
- set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
endmacro()
diff --git a/Modules/Platform/Linux-Intel.cmake b/Modules/Platform/Linux-Intel.cmake
index ee9aac26a..3b5ca59ca 100644
--- a/Modules/Platform/Linux-Intel.cmake
+++ b/Modules/Platform/Linux-Intel.cmake
@@ -23,6 +23,12 @@ endif()
macro(__linux_compiler_intel lang)
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
+ set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
+ if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 13.0)
+ set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER YES)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie")
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie")
+ endif()
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared")
@@ -30,6 +36,9 @@ macro(__linux_compiler_intel lang)
# executables that use dlopen but do not set ENABLE_EXPORTS.
set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic")
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,")
+ set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",")
+
set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
if(XIAR)
diff --git a/Modules/Platform/Linux-PGI.cmake b/Modules/Platform/Linux-PGI.cmake
index db032c292..034165454 100644
--- a/Modules/Platform/Linux-PGI.cmake
+++ b/Modules/Platform/Linux-PGI.cmake
@@ -12,6 +12,9 @@ macro(__linux_compiler_pgi lang)
# Shared library compile and link flags.
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "")
+ set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC")
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared")
set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS " ")
diff --git a/Modules/Platform/Linux-XL-C.cmake b/Modules/Platform/Linux-XL-C.cmake
index d595e44f7..ef0c52bce 100644
--- a/Modules/Platform/Linux-XL-C.cmake
+++ b/Modules/Platform/Linux-XL-C.cmake
@@ -1,2 +1 @@
-set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-qmkshrobj")
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-export-dynamic")
diff --git a/Modules/Platform/Linux-XL-CXX.cmake b/Modules/Platform/Linux-XL-CXX.cmake
index 5ceb25591..aa57d6e6c 100644
--- a/Modules/Platform/Linux-XL-CXX.cmake
+++ b/Modules/Platform/Linux-XL-CXX.cmake
@@ -1,2 +1 @@
-set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-qmkshrobj")
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-Wl,-export-dynamic")
diff --git a/Modules/Platform/Linux-XL-Fortran.cmake b/Modules/Platform/Linux-XL-Fortran.cmake
index a87899131..d9b4c2d6e 100644
--- a/Modules/Platform/Linux-XL-Fortran.cmake
+++ b/Modules/Platform/Linux-XL-Fortran.cmake
@@ -1,2 +1 @@
-set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-qmkshrobj")
set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-Wl,-export-dynamic")
diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake
index 1f8c1b4c1..b5d5464ea 100644
--- a/Modules/Platform/Linux.cmake
+++ b/Modules/Platform/Linux.cmake
@@ -1,6 +1,7 @@
set(CMAKE_DL_LIBS "dl")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
+set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN")
set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,")
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
diff --git a/Modules/Platform/Midipix.cmake b/Modules/Platform/Midipix.cmake
new file mode 100644
index 000000000..54a156b4d
--- /dev/null
+++ b/Modules/Platform/Midipix.cmake
@@ -0,0 +1 @@
+include(Platform/UnixPaths)
diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake
index 1004eb310..d99cb4a77 100644
--- a/Modules/Platform/NetBSD.cmake
+++ b/Modules/Platform/NetBSD.cmake
@@ -1,11 +1,13 @@
set(CMAKE_DL_LIBS "")
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE")
+# PIE link options are managed in Compiler/<compiler>.cmake file
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty
+set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN")
set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,")
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
diff --git a/Modules/Platform/OpenBSD.cmake b/Modules/Platform/OpenBSD.cmake
index 6466a0a01..97e2a6a83 100644
--- a/Modules/Platform/OpenBSD.cmake
+++ b/Modules/Platform/OpenBSD.cmake
@@ -15,6 +15,10 @@ if(NOT CMAKE_PLATFORM_RUNTIME_PATH)
"${LDCONFIG_HINTS}")
endif()
+# OpenBSD requires -z origin to enable $ORIGIN expansion in RPATH.
+# This is not required for NetBSD.
+set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-z,origin,-rpath,")
+
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_OPENBSD_VERSIONING 1)
# OpenBSD has no multilib
diff --git a/Modules/Platform/SINIX.cmake b/Modules/Platform/SINIX.cmake
index c37a113d3..e3b0a0516 100644
--- a/Modules/Platform/SINIX.cmake
+++ b/Modules/Platform/SINIX.cmake
@@ -1,4 +1,7 @@
set(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC)
set(CMAKE_C_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_C_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
+set(CMAKE_C_LINK_OPTIONS_PIE "")
+set(CMAKE_C_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC")
include(Platform/UnixPaths)
diff --git a/Modules/Platform/SunOS-Clang-C.cmake b/Modules/Platform/SunOS-Clang-C.cmake
new file mode 100644
index 000000000..f06eb8fff
--- /dev/null
+++ b/Modules/Platform/SunOS-Clang-C.cmake
@@ -0,0 +1 @@
+include(Platform/SunOS-GNU-C)
diff --git a/Modules/Platform/SunOS-Clang-CXX.cmake b/Modules/Platform/SunOS-Clang-CXX.cmake
new file mode 100644
index 000000000..869182c08
--- /dev/null
+++ b/Modules/Platform/SunOS-Clang-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/SunOS-GNU-CXX)
diff --git a/Modules/Platform/SunOS-GNU.cmake b/Modules/Platform/SunOS-GNU.cmake
index 485f23533..47334d6cb 100644
--- a/Modules/Platform/SunOS-GNU.cmake
+++ b/Modules/Platform/SunOS-GNU.cmake
@@ -11,6 +11,7 @@ set(__SUNOS_COMPILER_GNU 1)
macro(__sunos_compiler_gnu lang)
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-R")
set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":")
+ set(CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN "\$ORIGIN")
set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-h")
# Initialize C link type selection flags. These flags are used when
diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake
index e19e89a27..78eccf706 100644
--- a/Modules/Platform/SunOS.cmake
+++ b/Modules/Platform/SunOS.cmake
@@ -1,10 +1,10 @@
if(CMAKE_SYSTEM MATCHES "SunOS-4")
- set(CMAKE_C_COMPILE_OPTIONS_PIC "-PIC")
- set(CMAKE_C_COMPILE_OPTIONS_PIE "-PIE")
- set(CMAKE_SHARED_LIBRARY_C_FLAGS "-PIC")
- set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-r")
- set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-R")
- set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
+ set(CMAKE_C_COMPILE_OPTIONS_PIC "-PIC")
+ set(CMAKE_C_COMPILE_OPTIONS_PIE "-PIE")
+ set(CMAKE_SHARED_LIBRARY_C_FLAGS "-PIC")
+ set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-r")
+ set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-R")
+ set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
endif()
include(Platform/UnixPaths)
diff --git a/Modules/Platform/UNIX_SV.cmake b/Modules/Platform/UNIX_SV.cmake
index 1ec96aea2..bd1ffce3a 100644
--- a/Modules/Platform/UNIX_SV.cmake
+++ b/Modules/Platform/UNIX_SV.cmake
@@ -1,5 +1,8 @@
set(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC)
set(CMAKE_C_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_C_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
+set(CMAKE_C_LINK_OPTIONS_PIE "")
+set(CMAKE_C_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC")
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-Bexport")
include(Platform/UnixPaths)
diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake
index 5687653cf..97f744d52 100644
--- a/Modules/Platform/UnixPaths.cmake
+++ b/Modules/Platform/UnixPaths.cmake
@@ -63,12 +63,28 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
/lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib64
)
-list(APPEND CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES
- /usr/include
+if(CMAKE_SYSROOT_COMPILE)
+ set(_cmake_sysroot_compile "${CMAKE_SYSROOT_COMPILE}")
+else()
+ set(_cmake_sysroot_compile "${CMAKE_SYSROOT}")
+endif()
+
+# Default per-language values. These may be later replaced after
+# parsing the implicit directory information from compiler output.
+set(_CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES_INIT
+ ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}
+ "${_cmake_sysroot_compile}/usr/include"
)
-list(APPEND CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES
- /usr/include
+set(_CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES_INIT
+ ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}
+ "${_cmake_sysroot_compile}/usr/include"
)
+set(_CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES_INIT
+ ${CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES}
+ "${_cmake_sysroot_compile}/usr/include"
+ )
+
+unset(_cmake_sysroot_compile)
# Enable use of lib32 and lib64 search path variants by default.
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
diff --git a/Modules/Platform/UnixWare.cmake b/Modules/Platform/UnixWare.cmake
index e649bd2a4..94888d9c0 100644
--- a/Modules/Platform/UnixWare.cmake
+++ b/Modules/Platform/UnixWare.cmake
@@ -1,5 +1,8 @@
set(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC)
set(CMAKE_C_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_C_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
+set(CMAKE_C_LINK_OPTIONS_PIE "")
+set(CMAKE_C_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC")
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-Wl,-Bexport")
include(Platform/UnixPaths)
diff --git a/Modules/Platform/Windows-Clang-CXX.cmake b/Modules/Platform/Windows-Clang-CXX.cmake
index 2c3688a36..f1d40f265 100644
--- a/Modules/Platform/Windows-Clang-CXX.cmake
+++ b/Modules/Platform/Windows-Clang-CXX.cmake
@@ -1,2 +1,3 @@
include(Platform/Windows-Clang)
+set(_COMPILE_CXX_MSVC " -TP")
__windows_compiler_clang(CXX)
diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake
index bcfda93cd..02864c6b3 100644
--- a/Modules/Platform/Windows-Clang.cmake
+++ b/Modules/Platform/Windows-Clang.cmake
@@ -8,12 +8,147 @@ if(__WINDOWS_CLANG)
endif()
set(__WINDOWS_CLANG 1)
+macro(__windows_compiler_clang_gnu lang)
+ set(CMAKE_LIBRARY_PATH_FLAG "-L")
+ set(CMAKE_LINK_LIBRARY_FLAG "-l")
+
+ set(CMAKE_IMPORT_LIBRARY_PREFIX "")
+ set(CMAKE_SHARED_LIBRARY_PREFIX "")
+ set(CMAKE_SHARED_MODULE_PREFIX "")
+ set(CMAKE_STATIC_LIBRARY_PREFIX "")
+ set(CMAKE_EXECUTABLE_SUFFIX ".exe")
+ set(CMAKE_IMPORT_LIBRARY_SUFFIX ".lib")
+ set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
+ set(CMAKE_SHARED_MODULE_SUFFIX ".dll")
+ set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib")
+ set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <OBJECT> -MF <DEPFILE>")
+
+ set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a" ".lib")
+ set(CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS 1)
+ set (CMAKE_LINK_DEF_FILE_FLAG "-Xlinker /DEF:")
+
+ if("${CMAKE_${lang}_SIMULATE_VERSION}" MATCHES "^([0-9]+)\\.([0-9]+)")
+ math(EXPR MSVC_VERSION "${CMAKE_MATCH_1}*100 + ${CMAKE_MATCH_2}")
+ endif()
+
+ # No -fPIC on Windows
+ set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "")
+ set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
+ set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "")
+
+ set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1)
+ set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 1)
+ set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1)
+
+ set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-flto")
+ set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
+ set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
+ set(CMAKE_${lang}_ARCHIVE_CREATE_IPO "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_APPEND_IPO "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_FINISH_IPO "<CMAKE_RANLIB> <TARGET>")
+
+ # Create archiving rules to support large object file lists for static libraries.
+ set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
+ set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
+ "<CMAKE_${lang}_COMPILER> -fuse-ld=lld-link -nostartfiles -nostdlib <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <OBJECTS> <LINK_LIBRARIES>")
+ set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY})
+ set(CMAKE_${lang}_LINK_EXECUTABLE
+ "<CMAKE_${lang}_COMPILER> -fuse-ld=lld-link -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
+
+ set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmt)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -D_DLL -D_MT -Xclang --dependent-lib=msvcrt)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -D_DEBUG -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmtd)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd)
+
+ if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT)
+ set(__ADDED_FLAGS "")
+ set(__ADDED_FLAGS_DEBUG "")
+ else()
+ set(__ADDED_FLAGS_DEBUG "-D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd")
+ set(__ADDED_FLAGS "-D_DLL -D_MT -Xclang --dependent-lib=msvcrt")
+ endif()
+
+ string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -Xclang -gcodeview -O0 ${__ADDED_FLAGS_DEBUG}")
+ string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG ${__ADDED_FLAGS}")
+ string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG ${__ADDED_FLAGS}")
+ string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG -Xclang -gcodeview ${__ADDED_FLAGS}")
+ set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
+
+ set(CMAKE_PCH_EXTENSION .pch)
+ set(CMAKE_PCH_PROLOGUE "#pragma clang system_header")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE>)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER>)
+
+ unset(__ADDED_FLAGS)
+ unset(__ADDED_FLAGS_DEBUG)
+ string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER)
+ set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames")
+
+ enable_language(RC)
+endmacro()
+
if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
- include(Platform/Windows-MSVC)
- macro(__windows_compiler_clang lang)
- __windows_compiler_msvc(${lang})
- endmacro()
+
+ if ( DEFINED CMAKE_C_COMPILER_ID AND DEFINED CMAKE_CXX_COMPILER_ID
+ AND NOT "x${CMAKE_C_COMPILER_ID}" STREQUAL "x${CMAKE_CXX_COMPILER_ID}")
+ message(FATAL_ERROR "The current configuration mixes Clang and MSVC or "
+ "some other CL compatible compiler tool. This is not supported. "
+ "Use either clang or MSVC as both C and C++ compilers.")
+ endif()
+
+ if ( DEFINED CMAKE_C_COMPILER_FRONTEND_VARIANT AND DEFINED CMAKE_CXX_COMPILER_FRONTEND_VARIANT
+ AND NOT "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}")
+ message(FATAL_ERROR "The current configuration uses the Clang compiler "
+ "tool with mixed frontend variants, both the GNU and in MSVC CL "
+ "like variants. This is not supported. Use either clang/clang++ "
+ "or clang-cl as both C and C++ compilers.")
+ endif()
+
+ if(NOT CMAKE_RC_COMPILER_INIT)
+ # Check if rc is already in the path
+ # This may happen in cases where the user is already in a visual studio environment when CMake is invoked
+ find_program(__RC_COMPILER_PATH NAMES rc)
+
+ # Default to rc if it's available, otherwise fall back to llvm-rc
+ if(__RC_COMPILER_PATH)
+ set(CMAKE_RC_COMPILER_INIT rc)
+ else()
+ set(CMAKE_RC_COMPILER_INIT llvm-rc)
+ endif()
+
+ unset(__RC_COMPILER_PATH CACHE)
+ endif()
+
+ if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" )
+ include(Platform/Windows-MSVC)
+
+ macro(__windows_compiler_clang lang)
+ set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}")
+ __windows_compiler_msvc(${lang})
+ endmacro()
+ else()
+ cmake_policy(GET CMP0091 __WINDOWS_CLANG_CMP0091)
+ if(__WINDOWS_CLANG_CMP0091 STREQUAL "NEW")
+ set(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
+ else()
+ set(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "")
+ endif()
+ unset(__WINDOWS_CLANG_CMP0091)
+
+ set(CMAKE_BUILD_TYPE_INIT Debug)
+
+ macro(__windows_compiler_clang lang)
+ __windows_compiler_clang_gnu(${lang})
+ endmacro()
+ endif()
+
else()
include(Platform/Windows-GNU)
macro(__windows_compiler_clang lang)
diff --git a/Modules/Platform/Windows-Embarcadero.cmake b/Modules/Platform/Windows-Embarcadero.cmake
index f8e1c9e56..370b56ea9 100644
--- a/Modules/Platform/Windows-Embarcadero.cmake
+++ b/Modules/Platform/Windows-Embarcadero.cmake
@@ -76,6 +76,8 @@ macro(__embarcadero_language lang)
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "${_tD}") # ... while this is a space separated string.
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1)
+ set (CMAKE_${lang}_LINKER_WRAPPER_FLAG "-l")
+
# compile a source file into an object file
# place <DEFINES> outside the response file because Borland refuses
# to parse quotes from the response file.
@@ -117,6 +119,13 @@ macro(__embarcadero_language lang)
"tlib ${CMAKE_START_TEMP_FILE}/p512 <LINK_FLAGS> /a <TARGET_QUOTED> <OBJECTS>${CMAKE_END_TEMP_FILE}"
)
+ # Precompile Headers
+ if (EMBARCADERO)
+ set(CMAKE_PCH_EXTENSION .pch)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE>)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER>)
+ endif()
+
# Initial configuration flags.
string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_tM}")
string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -Od -v")
diff --git a/Modules/Platform/Windows-Flang-Fortran.cmake b/Modules/Platform/Windows-Flang-Fortran.cmake
new file mode 100644
index 000000000..c4420f7cd
--- /dev/null
+++ b/Modules/Platform/Windows-Flang-Fortran.cmake
@@ -0,0 +1,8 @@
+include(Platform/Windows-MSVC)
+__windows_compiler_msvc(Fortran)
+set(CMAKE_Fortran_COMPILE_OBJECT "<CMAKE_Fortran_COMPILER> ${_COMPILE_Fortran} <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
+
+set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang --dependent-lib=libcmt)
+set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -Xclang --dependent-lib=msvcrt)
+set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -Xclang --dependent-lib=libcmtd)
+set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -Xclang --dependent-lib=msvcrtd)
diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake
index cfb325b9d..6bf245c1a 100644
--- a/Modules/Platform/Windows-GNU.cmake
+++ b/Modules/Platform/Windows-GNU.cmake
@@ -72,6 +72,9 @@ macro(__windows_compiler_gnu lang)
# No -fPIC on Windows
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "")
+ set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "")
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE})
@@ -149,7 +152,7 @@ macro(__windows_compiler_gnu_abi lang)
# Query the VS Installer tool for locations of VS 2017 and above.
set(_vs_installer_paths "")
- foreach(vs RANGE 15 15 -1) # change the first number to the largest supported version
+ foreach(vs RANGE 16 15 -1) # change the first number to the largest supported version
cmake_host_system_information(RESULT _vs_dir QUERY VS_${vs}_DIR)
if(_vs_dir)
list(APPEND _vs_installer_paths "${_vs_dir}/VC/Auxiliary/Build")
diff --git a/Modules/Platform/Windows-Intel-C.cmake b/Modules/Platform/Windows-Intel-C.cmake
index 767fec541..06d8f50ff 100644
--- a/Modules/Platform/Windows-Intel-C.cmake
+++ b/Modules/Platform/Windows-Intel-C.cmake
@@ -1,2 +1,4 @@
include(Platform/Windows-Intel)
__windows_compiler_intel(C)
+set(CMAKE_NINJA_DEPTYPE_C intel) # special value handled by CMake
+set(CMAKE_DEPFILE_FLAGS_C "-QMMD -QMT <OBJECT> -QMF <DEPFILE>")
diff --git a/Modules/Platform/Windows-Intel-CXX.cmake b/Modules/Platform/Windows-Intel-CXX.cmake
index 84cd303ec..666de6ee4 100644
--- a/Modules/Platform/Windows-Intel-CXX.cmake
+++ b/Modules/Platform/Windows-Intel-CXX.cmake
@@ -1,3 +1,5 @@
include(Platform/Windows-Intel)
set(_COMPILE_CXX " /TP")
__windows_compiler_intel(CXX)
+set(CMAKE_NINJA_DEPTYPE_CXX intel) # special value handled by CMake
+set(CMAKE_DEPFILE_FLAGS_CXX "-QMMD -QMT <OBJECT> -QMF <DEPFILE>")
diff --git a/Modules/Platform/Windows-Intel-Fortran.cmake b/Modules/Platform/Windows-Intel-Fortran.cmake
index 3981a092b..e3804fb86 100644
--- a/Modules/Platform/Windows-Intel-Fortran.cmake
+++ b/Modules/Platform/Windows-Intel-Fortran.cmake
@@ -4,8 +4,41 @@ set(_COMPILE_Fortran " /fpp")
set(CMAKE_Fortran_MODDIR_FLAG "-module:")
set(CMAKE_Fortran_STANDARD_LIBRARIES_INIT "user32.lib")
__windows_compiler_intel(Fortran)
-string(APPEND CMAKE_Fortran_FLAGS_INIT " /W1 /nologo /fpp /libs:dll /threads")
-string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " /Od /debug:full /dbglibs")
+if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT)
+ set(_LIBSDLL "")
+ set(_DBGLIBS "")
+ set(_THREADS "")
+else()
+ set(_LIBSDLL " /libs:dll")
+ set(_DBGLIBS " /dbglibs")
+ set(_THREADS " /threads")
+endif()
+
+cmake_policy(GET CMP0092 _cmp0092)
+if(NOT _cmp0092 STREQUAL "NEW")
+ string(APPEND CMAKE_Fortran_FLAGS_INIT " /W1")
+endif()
+unset(_cmp0092)
+
+string(APPEND CMAKE_Fortran_FLAGS_INIT " /nologo /fpp${_LIBSDLL}${_THREADS}")
+string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " /Od /debug:full${_DBGLIBS}")
string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " /O1 /DNDEBUG")
string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " /O2 /DNDEBUG")
string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT " /O2 /debug:full /DNDEBUG")
+unset(_LIBSDLL)
+unset(_DBGLIBS)
+unset(_THREADS)
+
+set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -threads -libs:static)
+set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -threads -libs:dll)
+set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -threads -libs:static -dbglibs)
+set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -threads -libs:dll -dbglibs)
+
+# Intel Fortran for Windows supports single-threaded RTL but it is
+# not implemented by the Visual Studio integration.
+if(NOT CMAKE_GENERATOR MATCHES "Visual Studio")
+ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_SingleThreaded -libs:static)
+ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_SingleThreadedDLL -libs:dll)
+ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_SingleThreadedDebug -libs:static -dbglibs)
+ set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_SingleThreadedDebugDLL -libs:dll -dbglibs)
+endif()
diff --git a/Modules/Platform/Windows-Intel.cmake b/Modules/Platform/Windows-Intel.cmake
index ba31001ea..96b1760ab 100644
--- a/Modules/Platform/Windows-Intel.cmake
+++ b/Modules/Platform/Windows-Intel.cmake
@@ -11,7 +11,7 @@ set(__WINDOWS_INTEL 1)
include(Platform/Windows-MSVC)
macro(__windows_compiler_intel lang)
__windows_compiler_msvc(${lang})
- string(REPLACE "<CMAKE_LINKER> /lib" "lib" CMAKE_${lang}_CREATE_STATIC_LIBRARY "${CMAKE_${lang}_CREATE_STATIC_LIBRARY}")
+ string(REPLACE "<CMAKE_LINKER> /lib" "xilib" CMAKE_${lang}_CREATE_STATIC_LIBRARY "${CMAKE_${lang}_CREATE_STATIC_LIBRARY}")
foreach(rule CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE)
string(REPLACE "<CMAKE_LINKER>" "xilink" CMAKE_${lang}_${rule} "${CMAKE_${lang}_${rule}}")
endforeach()
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index cfe6e1c21..34f5d03d4 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -17,7 +17,7 @@ set(MSVC 1)
# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun)
# hardcode CMAKE_LINKER here to link, so it behaves as it did before, Alex
if(NOT DEFINED CMAKE_LINKER)
- set(CMAKE_LINKER link)
+ set(CMAKE_LINKER link)
endif()
if(CMAKE_VERBOSE_MAKEFILE)
@@ -48,7 +48,11 @@ else()
endif()
if(NOT MSVC_VERSION)
- if(CMAKE_C_SIMULATE_VERSION)
+ if("x${CMAKE_C_COMPILER_ID}" STREQUAL "xMSVC")
+ set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
+ elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
+ set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
+ elseif(CMAKE_C_SIMULATE_VERSION)
set(_compiler_version ${CMAKE_C_SIMULATE_VERSION})
elseif(CMAKE_CXX_SIMULATE_VERSION)
set(_compiler_version ${CMAKE_CXX_SIMULATE_VERSION})
@@ -67,6 +71,34 @@ if(NOT MSVC_VERSION)
message(FATAL_ERROR "MSVC compiler version not detected properly: ${_compiler_version}")
endif()
+ if(MSVC_VERSION GREATER_EQUAL 1920)
+ # VS 2019 or greater
+ set(MSVC_TOOLSET_VERSION 142)
+ elseif(MSVC_VERSION GREATER_EQUAL 1910)
+ # VS 2017 or greater
+ set(MSVC_TOOLSET_VERSION 141)
+ elseif(MSVC_VERSION EQUAL 1900)
+ # VS 2015
+ set(MSVC_TOOLSET_VERSION 140)
+ elseif(MSVC_VERSION EQUAL 1800)
+ # VS 2013
+ set(MSVC_TOOLSET_VERSION 120)
+ elseif(MSVC_VERSION EQUAL 1700)
+ # VS 2012
+ set(MSVC_TOOLSET_VERSION 110)
+ elseif(MSVC_VERSION EQUAL 1600)
+ # VS 2010
+ set(MSVC_TOOLSET_VERSION 100)
+ elseif(MSVC_VERSION EQUAL 1500)
+ # VS 2008
+ set(MSVC_TOOLSET_VERSION 90)
+ elseif(MSVC_VERSION EQUAL 1400)
+ # VS 2005
+ set(MSVC_TOOLSET_VERSION 80)
+ else()
+ # We don't support MSVC_TOOLSET_VERSION for earlier compiler.
+ endif()
+
set(MSVC10)
set(MSVC11)
set(MSVC12)
@@ -122,7 +154,9 @@ set(CMAKE_BUILD_TYPE_INIT Debug)
# Compute an architecture family from the architecture id.
foreach(lang C CXX)
set(_MSVC_${lang}_ARCHITECTURE_FAMILY "${MSVC_${lang}_ARCHITECTURE_ID}")
- if(_MSVC_${lang}_ARCHITECTURE_FAMILY MATCHES "^ARM")
+ if(_MSVC_${lang}_ARCHITECTURE_FAMILY MATCHES "^ARM64")
+ set(_MSVC_${lang}_ARCHITECTURE_FAMILY "ARM64")
+ elseif(_MSVC_${lang}_ARCHITECTURE_FAMILY MATCHES "^ARM")
set(_MSVC_${lang}_ARCHITECTURE_FAMILY "ARM")
elseif(_MSVC_${lang}_ARCHITECTURE_FAMILY MATCHES "^SH")
set(_MSVC_${lang}_ARCHITECTURE_FAMILY "SHx")
@@ -175,7 +209,7 @@ elseif(WINDOWS_PHONE OR WINDOWS_STORE)
set(CMAKE_C_STANDARD_LIBRARIES_INIT "WindowsApp.lib")
elseif(WINDOWS_PHONE)
set(CMAKE_C_STANDARD_LIBRARIES_INIT "WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib")
- elseif(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM")
+ elseif(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM64" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM64")
set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib")
else()
set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib")
@@ -183,10 +217,10 @@ elseif(WINDOWS_PHONE OR WINDOWS_STORE)
else()
set(_PLATFORM_DEFINES "/DWIN32")
- if(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM")
+ if(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM" OR _MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM64" OR _MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM64")
set(CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib")
elseif(MSVC_VERSION GREATER 1310)
- if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "(v[0-9]+_clang_.*|LLVM-vs[0-9]+.*)")
+ if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*")
# Clang/C2 in MSVC14 Update 1 seems to not support -fsantinize (yet?)
# set(_RTC1 "-fsantinize=memory,safe-stack")
set(_FLAGS_CXX " -frtti -fexceptions")
@@ -215,6 +249,8 @@ set (CMAKE_LINK_DEF_FILE_FLAG "/DEF:")
if(MSVC_C_ARCHITECTURE_ID)
if(MSVC_C_ARCHITECTURE_ID MATCHES "^ARMV.I")
set(_MACHINE_ARCH_FLAG "/machine:THUMB")
+ elseif(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM64")
+ set(_MACHINE_ARCH_FLAG "/machine:ARM64")
elseif(_MSVC_C_ARCHITECTURE_FAMILY STREQUAL "ARM")
set(_MACHINE_ARCH_FLAG "/machine:ARM")
else()
@@ -223,6 +259,8 @@ if(MSVC_C_ARCHITECTURE_ID)
elseif(MSVC_CXX_ARCHITECTURE_ID)
if(MSVC_CXX_ARCHITECTURE_ID MATCHES "^ARMV.I")
set(_MACHINE_ARCH_FLAG "/machine:THUMB")
+ elseif(_MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM64")
+ set(_MACHINE_ARCH_FLAG "/machine:ARM64")
elseif(_MSVC_CXX_ARCHITECTURE_FAMILY STREQUAL "ARM")
set(_MACHINE_ARCH_FLAG "/machine:ARM")
else()
@@ -260,11 +298,19 @@ endforeach()
string(APPEND CMAKE_STATIC_LINKER_FLAGS_INIT " ${_MACHINE_ARCH_FLAG}")
unset(_MACHINE_ARCH_FLAG)
+cmake_policy(GET CMP0091 __WINDOWS_MSVC_CMP0091)
+if(__WINDOWS_MSVC_CMP0091 STREQUAL "NEW")
+ set(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
+else()
+ set(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "")
+endif()
+unset(__WINDOWS_MSVC_CMP0091)
+
macro(__windows_compiler_msvc lang)
if(NOT MSVC_VERSION LESS 1400)
# for 2005 make sure the manifest is put in the dll with mt
- set(_CMAKE_VS_LINK_DLL "<CMAKE_COMMAND> -E vs_link_dll --intdir=<OBJECT_DIR> --manifests <MANIFESTS> -- ")
- set(_CMAKE_VS_LINK_EXE "<CMAKE_COMMAND> -E vs_link_exe --intdir=<OBJECT_DIR> --manifests <MANIFESTS> -- ")
+ set(_CMAKE_VS_LINK_DLL "<CMAKE_COMMAND> -E vs_link_dll --intdir=<OBJECT_DIR> --rc=<CMAKE_RC_COMPILER> --mt=<CMAKE_MT> --manifests <MANIFESTS> -- ")
+ set(_CMAKE_VS_LINK_EXE "<CMAKE_COMMAND> -E vs_link_exe --intdir=<OBJECT_DIR> --rc=<CMAKE_RC_COMPILER> --mt=<CMAKE_MT> --manifests <MANIFESTS> -- ")
endif()
set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
"${_CMAKE_VS_LINK_DLL}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /dll /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <LINK_FLAGS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
@@ -283,37 +329,115 @@ macro(__windows_compiler_msvc lang)
set(CMAKE_${lang}_LINK_EXECUTABLE
"${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}")
+ set(CMAKE_PCH_EXTENSION .pch)
+ set(CMAKE_LINK_PCH ON)
+ if(MSVC_VERSION GREATER_EQUAL 1910)
+ # VS 2017 or greater
+ if (NOT ${CMAKE_${lang}_COMPILER_ID} STREQUAL "Clang")
+ set(CMAKE_PCH_PROLOGUE "#pragma system_header")
+ else()
+ set(CMAKE_PCH_PROLOGUE "#pragma clang system_header")
+ endif()
+ endif()
+ if (NOT ${CMAKE_${lang}_COMPILER_ID} STREQUAL "Clang")
+ set(CMAKE_PCH_COPY_COMPILE_PDB ON)
+ endif()
+ set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH /Yu<PCH_HEADER> /Fp<PCH_FILE> /FI<PCH_HEADER>)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH /Yc<PCH_HEADER> /Fp<PCH_FILE> /FI<PCH_HEADER>)
+
+ if("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC")
+ set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
+ set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
+
+ set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "/GL")
+ set(CMAKE_${lang}_LINK_OPTIONS_IPO "/INCREMENTAL:NO" "/LTCG")
+ string(REPLACE "<LINK_FLAGS> " "/LTCG <LINK_FLAGS> "
+ CMAKE_${lang}_CREATE_STATIC_LIBRARY_IPO "${CMAKE_${lang}_CREATE_STATIC_LIBRARY}")
+ elseif("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xClang" OR
+ "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xFlang")
+ set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
+ set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
+
+ # '-flto=thin' available since Clang 3.9 and Xcode 8
+ # * http://clang.llvm.org/docs/ThinLTO.html#clang-llvm
+ # * https://trac.macports.org/wiki/XcodeVersionInfo
+ set(_CMAKE_LTO_THIN TRUE)
+ if(CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.9)
+ set(_CMAKE_LTO_THIN FALSE)
+ endif()
+
+ if(_CMAKE_LTO_THIN)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-flto=thin")
+ else()
+ set(CMAKE_${lang}_COMPILE_OPTIONS_IPO "-flto")
+ endif()
+ endif()
+
if("x${lang}" STREQUAL "xC" OR
"x${lang}" STREQUAL "xCXX")
- if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "(v[0-9]+_clang_.*|LLVM-vs[0-9]+.*)")
+ if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT)
+ set(_MDd "")
+ set(_MD "")
+ else()
+ set(_MDd " /MDd")
+ set(_MD " /MD")
+ endif()
+
+ cmake_policy(GET CMP0092 _cmp0092)
+ if(_cmp0092 STREQUAL "NEW")
+ set(_W3 "")
+ set(_Wall "")
+ else()
+ set(_W3 " /W3")
+ set(_Wall " -Wall")
+ endif()
+ unset(_cmp0092)
+
+ if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*")
# note: MSVC 14 2015 Update 1 sets -fno-ms-compatibility by default, but this does not allow one to compile many projects
# that include MS's own headers. CMake itself is affected project too.
- string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} -fms-extensions -fms-compatibility -D_WINDOWS -Wall${_FLAGS_${lang}}")
- string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " /MDd -gline-tables-only -fno-inline -O0 ${_RTC1}")
- string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " /MD -O2 -DNDEBUG")
- string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " /MD -gline-tables-only -O2 -fno-inline -DNDEBUG")
- string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " /MD -DNDEBUG") # TODO: Add '-Os' once VS generator maps it properly for Clang
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} -fms-extensions -fms-compatibility -D_WINDOWS${_Wall}${_FLAGS_${lang}}")
+ string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT "${_MDd} -gline-tables-only -fno-inline -O0 ${_RTC1}")
+ string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT "${_MD} -O2 -DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "${_MD} -gline-tables-only -O2 -fno-inline -DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "${_MD} -DNDEBUG") # TODO: Add '-Os' once VS generator maps it properly for Clang
else()
- string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3${_FLAGS_${lang}}")
- string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " /MDd /Zi /Ob0 /Od ${_RTC1}")
- string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " /MD /O2 /Ob2 /DNDEBUG")
- string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " /MD /Zi /O2 /Ob1 /DNDEBUG")
- string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " /MD /O1 /Ob1 /DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS${_W3}${_FLAGS_${lang}}")
+ string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT "${_MDd} /Zi /Ob0 /Od ${_RTC1}")
+ string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT "${_MD} /O2 /Ob2 /DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "${_MD} /Zi /O2 /Ob1 /DNDEBUG")
+ string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "${_MD} /O1 /Ob1 /DNDEBUG")
endif()
+ unset(_Wall)
+ unset(_W3)
+ unset(_MDd)
+ unset(_MD)
+
+ set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -MT)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -MD)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -MTd)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -MDd)
endif()
set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON)
set(CMAKE_NINJA_DEPTYPE_${lang} msvc)
+ __windows_compiler_msvc_enable_rc("${_PLATFORM_DEFINES} ${_PLATFORM_DEFINES_${lang}}")
+endmacro()
+macro(__windows_compiler_msvc_enable_rc flags)
if(NOT CMAKE_RC_COMPILER_INIT)
set(CMAKE_RC_COMPILER_INIT rc)
endif()
if(NOT CMAKE_RC_FLAGS_INIT)
- string(APPEND CMAKE_RC_FLAGS_INIT " ${_PLATFORM_DEFINES} ${_PLATFORM_DEFINES_${lang}}")
+ # llvm-rc fails when flags are specified with /D and no space after
+ string(REPLACE " /D" " -D" fixed_flags " ${flags}")
+ string(APPEND CMAKE_RC_FLAGS_INIT " ${fixed_flags}")
endif()
if(NOT CMAKE_RC_FLAGS_DEBUG_INIT)
- string(APPEND CMAKE_RC_FLAGS_DEBUG_INIT " /D_DEBUG")
+ string(APPEND CMAKE_RC_FLAGS_DEBUG_INIT " -D_DEBUG")
endif()
enable_language(RC)
- set(CMAKE_NINJA_CMCLDEPS_RC 1)
+ if(NOT DEFINED CMAKE_NINJA_CMCLDEPS_RC)
+ set(CMAKE_NINJA_CMCLDEPS_RC 1)
+ endif()
endmacro()
diff --git a/Modules/Platform/Windows-NMcl.cmake b/Modules/Platform/Windows-NMcl.cmake
deleted file mode 100644
index 7add0b060..000000000
--- a/Modules/Platform/Windows-NMcl.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-# this is for the numega compiler which is really a front
-# end for visual studio, but adds memory checking code.
-
-include(Platform/Windows-cl)
diff --git a/Modules/Platform/Windows-NVIDIA-CUDA.cmake b/Modules/Platform/Windows-NVIDIA-CUDA.cmake
index 970c2c6d1..94d77b961 100644
--- a/Modules/Platform/Windows-NVIDIA-CUDA.cmake
+++ b/Modules/Platform/Windows-NVIDIA-CUDA.cmake
@@ -15,10 +15,10 @@ foreach(lib ${CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES})
string(APPEND __IMPLICT_LINKS " \"${lib}\"")
endforeach()
set(CMAKE_CUDA_LINK_EXECUTABLE
- "<CMAKE_CUDA_HOST_LINK_LAUNCHER> <CMAKE_CUDA_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <LINK_LIBRARIES>${__IMPLICT_LINKS}")
+ "<CMAKE_CUDA_HOST_LINK_LAUNCHER> <LINK_FLAGS> <OBJECTS> /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <LINK_LIBRARIES>${__IMPLICT_LINKS}")
-set(_CMAKE_VS_LINK_DLL "<CMAKE_COMMAND> -E vs_link_dll --intdir=<OBJECT_DIR> --manifests <MANIFESTS> -- ")
-set(_CMAKE_VS_LINK_EXE "<CMAKE_COMMAND> -E vs_link_exe --intdir=<OBJECT_DIR> --manifests <MANIFESTS> -- ")
+set(_CMAKE_VS_LINK_DLL "<CMAKE_COMMAND> -E vs_link_dll --intdir=<OBJECT_DIR> --rc=<CMAKE_RC_COMPILER> --mt=<CMAKE_MT> --manifests <MANIFESTS> -- ")
+set(_CMAKE_VS_LINK_EXE "<CMAKE_COMMAND> -E vs_link_exe --intdir=<OBJECT_DIR> --rc=<CMAKE_RC_COMPILER> --mt=<CMAKE_MT> --manifests <MANIFESTS> -- ")
set(CMAKE_CUDA_CREATE_SHARED_LIBRARY
"${_CMAKE_VS_LINK_DLL}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /dll /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <LINK_FLAGS> <LINK_LIBRARIES>${__IMPLICT_LINKS} ${CMAKE_END_TEMP_FILE}")
@@ -26,7 +26,7 @@ set(CMAKE_CUDA_CREATE_SHARED_MODULE ${CMAKE_CUDA_CREATE_SHARED_LIBRARY})
set(CMAKE_CUDA_CREATE_STATIC_LIBRARY "<CMAKE_LINKER> /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ")
set(CMAKE_CUDA_LINKER_SUPPORTS_PDB ON)
set(CMAKE_CUDA_LINK_EXECUTABLE
- "${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <CMAKE_CUDA_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${__IMPLICT_LINKS} ${CMAKE_END_TEMP_FILE}")
+ "${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <LINK_FLAGS> <LINK_LIBRARIES>${__IMPLICT_LINKS} ${CMAKE_END_TEMP_FILE}")
unset(_CMAKE_VS_LINK_EXE)
unset(_CMAKE_VS_LINK_EXE)
@@ -36,19 +36,60 @@ else()
set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "")
endif()
+# Add implicit host link directories that contain device libraries
+# to the device link line.
+set(__IMPLICT_DLINK_DIRS ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
+if(__IMPLICT_DLINK_DIRS)
+ list(REMOVE_ITEM __IMPLICT_DLINK_DIRS ${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES})
+endif()
+set(__IMPLICT_DLINK_FLAGS )
+foreach(dir ${__IMPLICT_DLINK_DIRS})
+ if(EXISTS "${dir}/curand_static.lib")
+ string(APPEND __IMPLICT_DLINK_FLAGS " -L\"${dir}\"")
+ endif()
+endforeach()
+unset(__IMPLICT_DLINK_DIRS)
+
set(CMAKE_CUDA_DEVICE_LINK_LIBRARY
- "<CMAKE_CUDA_COMPILER> <CMAKE_CUDA_LINK_FLAGS> <LANGUAGE_COMPILE_FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
+ "<CMAKE_CUDA_COMPILER> <LANGUAGE_COMPILE_FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}")
set(CMAKE_CUDA_DEVICE_LINK_EXECUTABLE
- "<CMAKE_CUDA_COMPILER> <FLAGS> <CMAKE_CUDA_LINK_FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS")
+ "<CMAKE_CUDA_COMPILER> <FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}")
unset(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS)
+unset(__IMPLICT_DLINK_FLAGS)
string(REPLACE "/D" "-D" _PLATFORM_DEFINES_CUDA "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_CXX}")
-string(APPEND CMAKE_CUDA_FLAGS_INIT " ${PLATFORM_DEFINES_CUDA} -D_WINDOWS -Xcompiler=\"/W3${_FLAGS_CXX}\"")
-string(APPEND CMAKE_CUDA_FLAGS_DEBUG_INIT " -Xcompiler=\"-MDd -Zi -Ob0 -Od ${_RTC1}\"")
-string(APPEND CMAKE_CUDA_FLAGS_RELEASE_INIT " -Xcompiler=\"-MD -O2 -Ob2\" -DNDEBUG")
-string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -Xcompiler=\"-MD -Zi -O2 -Ob1\" -DNDEBUG")
-string(APPEND CMAKE_CUDA_FLAGS_MINSIZEREL_INIT " -Xcompiler=\"-MD -O1 -Ob1\" -DNDEBUG")
+if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT)
+ set(_MDd "")
+ set(_MD "")
+else()
+ set(_MDd "-MDd ")
+ set(_MD "-MD ")
+endif()
+
+cmake_policy(GET CMP0092 _cmp0092)
+if(_cmp0092 STREQUAL "NEW")
+ set(_W3 "")
+else()
+ set(_W3 "/W3")
+endif()
+unset(_cmp0092)
+
+string(APPEND CMAKE_CUDA_FLAGS_INIT " ${PLATFORM_DEFINES_CUDA} -D_WINDOWS -Xcompiler=\"${_W3}${_FLAGS_CXX}\"")
+string(APPEND CMAKE_CUDA_FLAGS_DEBUG_INIT " -Xcompiler=\"${_MDd}-Zi -Ob0 -Od ${_RTC1}\"")
+string(APPEND CMAKE_CUDA_FLAGS_RELEASE_INIT " -Xcompiler=\"${_MD}-O2 -Ob2\" -DNDEBUG")
+string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -Xcompiler=\"${_MD}-Zi -O2 -Ob1\" -DNDEBUG")
+string(APPEND CMAKE_CUDA_FLAGS_MINSIZEREL_INIT " -Xcompiler=\"${_MD}-O1 -Ob1\" -DNDEBUG")
+unset(_W3)
+unset(_MDd)
+unset(_MD)
+
+set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xcompiler=-MT)
+set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -Xcompiler=-MD)
+set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -Xcompiler=-MTd)
+set(CMAKE_CUDA_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -Xcompiler=-MDd)
set(CMAKE_CUDA_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}")
+
+__windows_compiler_msvc_enable_rc("${_PLATFORM_DEFINES} ${_PLATFORM_DEFINES_CXX}")
diff --git a/Modules/Platform/Windows-OpenWatcom.cmake b/Modules/Platform/Windows-OpenWatcom.cmake
index d38d61666..76cd28bee 100644
--- a/Modules/Platform/Windows-OpenWatcom.cmake
+++ b/Modules/Platform/Windows-OpenWatcom.cmake
@@ -10,7 +10,7 @@ set(__WINDOWS_OPENWATCOM 1)
set(CMAKE_LIBRARY_PATH_FLAG "libpath ")
set(CMAKE_LINK_LIBRARY_FLAG "library ")
-set(CMAKE_LINK_LIBRARY_FILE_FLAG "library")
+set(CMAKE_LINK_LIBRARY_FILE_FLAG "library ")
if(CMAKE_VERBOSE_MAKEFILE)
set(CMAKE_WCL_QUIET)
diff --git a/Modules/Platform/Windows-df.cmake b/Modules/Platform/Windows-df.cmake
index c59be457e..f94891427 100644
--- a/Modules/Platform/Windows-df.cmake
+++ b/Modules/Platform/Windows-df.cmake
@@ -30,9 +30,6 @@ set(CMAKE_Fortran_LINK_EXECUTABLE
set(CMAKE_CREATE_WIN32_EXE /winapp)
set(CMAKE_CREATE_CONSOLE_EXE )
-if(CMAKE_GENERATOR MATCHES "Visual Studio 8")
- set (CMAKE_NO_BUILD_TYPE 1)
-endif()
# does the compiler support pdbtype and is it the newer compiler
set(CMAKE_BUILD_TYPE_INIT Debug)
diff --git a/Modules/Platform/WindowsPhone-Clang-C.cmake b/Modules/Platform/WindowsPhone-Clang-C.cmake
new file mode 100644
index 000000000..6e38572cd
--- /dev/null
+++ b/Modules/Platform/WindowsPhone-Clang-C.cmake
@@ -0,0 +1 @@
+include(Platform/Windows-Clang-C)
diff --git a/Modules/Platform/WindowsPhone-Clang-CXX.cmake b/Modules/Platform/WindowsPhone-Clang-CXX.cmake
new file mode 100644
index 000000000..bf47978c4
--- /dev/null
+++ b/Modules/Platform/WindowsPhone-Clang-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Windows-Clang-CXX)
diff --git a/Modules/Platform/WindowsPhone-GNU-C.cmake b/Modules/Platform/WindowsPhone-GNU-C.cmake
new file mode 100644
index 000000000..ff6acd56d
--- /dev/null
+++ b/Modules/Platform/WindowsPhone-GNU-C.cmake
@@ -0,0 +1 @@
+include(Platform/Windows-GNU-C)
diff --git a/Modules/Platform/WindowsPhone-GNU-CXX.cmake b/Modules/Platform/WindowsPhone-GNU-CXX.cmake
new file mode 100644
index 000000000..6adab6af3
--- /dev/null
+++ b/Modules/Platform/WindowsPhone-GNU-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Windows-GNU-CXX)
diff --git a/Modules/Platform/WindowsStore-Clang-C.cmake b/Modules/Platform/WindowsStore-Clang-C.cmake
new file mode 100644
index 000000000..6e38572cd
--- /dev/null
+++ b/Modules/Platform/WindowsStore-Clang-C.cmake
@@ -0,0 +1 @@
+include(Platform/Windows-Clang-C)
diff --git a/Modules/Platform/WindowsStore-Clang-CXX.cmake b/Modules/Platform/WindowsStore-Clang-CXX.cmake
new file mode 100644
index 000000000..bf47978c4
--- /dev/null
+++ b/Modules/Platform/WindowsStore-Clang-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Windows-Clang-CXX)
diff --git a/Modules/Platform/WindowsStore-GNU-C.cmake b/Modules/Platform/WindowsStore-GNU-C.cmake
new file mode 100644
index 000000000..ff6acd56d
--- /dev/null
+++ b/Modules/Platform/WindowsStore-GNU-C.cmake
@@ -0,0 +1 @@
+include(Platform/Windows-GNU-C)
diff --git a/Modules/Platform/WindowsStore-GNU-CXX.cmake b/Modules/Platform/WindowsStore-GNU-CXX.cmake
new file mode 100644
index 000000000..6adab6af3
--- /dev/null
+++ b/Modules/Platform/WindowsStore-GNU-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Windows-GNU-CXX)
diff --git a/Modules/Platform/iOS-Determine-CXX.cmake b/Modules/Platform/iOS-Determine-CXX.cmake
new file mode 100644
index 000000000..ac80fa62d
--- /dev/null
+++ b/Modules/Platform/iOS-Determine-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin-Determine-CXX)
diff --git a/Modules/Platform/iOS-Initialize.cmake b/Modules/Platform/iOS-Initialize.cmake
new file mode 100644
index 000000000..301ca4cbd
--- /dev/null
+++ b/Modules/Platform/iOS-Initialize.cmake
@@ -0,0 +1,9 @@
+include(Platform/Darwin-Initialize)
+
+if(NOT _CMAKE_OSX_SYSROOT_PATH MATCHES "/iPhone(OS|Simulator)")
+ message(FATAL_ERROR "${CMAKE_OSX_SYSROOT} is not an iOS SDK")
+endif()
+
+set(IOS 1)
+
+set(_CMAKE_FEATURE_DETECTION_TARGET_TYPE STATIC_LIBRARY)
diff --git a/Modules/Platform/iOS.cmake b/Modules/Platform/iOS.cmake
new file mode 100644
index 000000000..850ddc241
--- /dev/null
+++ b/Modules/Platform/iOS.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin)
diff --git a/Modules/Platform/tvOS-Determine-CXX.cmake b/Modules/Platform/tvOS-Determine-CXX.cmake
new file mode 100644
index 000000000..ac80fa62d
--- /dev/null
+++ b/Modules/Platform/tvOS-Determine-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin-Determine-CXX)
diff --git a/Modules/Platform/tvOS-Initialize.cmake b/Modules/Platform/tvOS-Initialize.cmake
new file mode 100644
index 000000000..6834c8031
--- /dev/null
+++ b/Modules/Platform/tvOS-Initialize.cmake
@@ -0,0 +1,7 @@
+include(Platform/Darwin-Initialize)
+
+if(NOT _CMAKE_OSX_SYSROOT_PATH MATCHES "/AppleTV(OS|Simulator)")
+ message(FATAL_ERROR "${CMAKE_OSX_SYSROOT} is not an tvOS SDK")
+endif()
+
+set(_CMAKE_FEATURE_DETECTION_TARGET_TYPE STATIC_LIBRARY)
diff --git a/Modules/Platform/tvOS.cmake b/Modules/Platform/tvOS.cmake
new file mode 100644
index 000000000..850ddc241
--- /dev/null
+++ b/Modules/Platform/tvOS.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin)
diff --git a/Modules/Platform/watchOS-Determine-CXX.cmake b/Modules/Platform/watchOS-Determine-CXX.cmake
new file mode 100644
index 000000000..ac80fa62d
--- /dev/null
+++ b/Modules/Platform/watchOS-Determine-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin-Determine-CXX)
diff --git a/Modules/Platform/watchOS-Initialize.cmake b/Modules/Platform/watchOS-Initialize.cmake
new file mode 100644
index 000000000..2f396d394
--- /dev/null
+++ b/Modules/Platform/watchOS-Initialize.cmake
@@ -0,0 +1,7 @@
+include(Platform/Darwin-Initialize)
+
+if(NOT _CMAKE_OSX_SYSROOT_PATH MATCHES "/Watch(OS|Simulator)")
+ message(FATAL_ERROR "${CMAKE_OSX_SYSROOT} is not an watchOS SDK")
+endif()
+
+set(_CMAKE_FEATURE_DETECTION_TARGET_TYPE STATIC_LIBRARY)
diff --git a/Modules/Platform/watchOS.cmake b/Modules/Platform/watchOS.cmake
new file mode 100644
index 000000000..850ddc241
--- /dev/null
+++ b/Modules/Platform/watchOS.cmake
@@ -0,0 +1 @@
+include(Platform/Darwin)
diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake
index 772a6150e..43ec889b6 100644
--- a/Modules/ProcessorCount.cmake
+++ b/Modules/ProcessorCount.cmake
@@ -1,44 +1,45 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# ProcessorCount
-# --------------
-#
-# ProcessorCount(var)
-#
-# Determine the number of processors/cores and save value in ${var}
-#
-# Sets the variable named ${var} to the number of physical cores
-# available on the machine if the information can be determined.
-# Otherwise it is set to 0. Currently this functionality is implemented
-# for AIX, cygwin, FreeBSD, HPUX, IRIX, Linux, Mac OS X, QNX, Sun and
-# Windows.
-#
-# This function is guaranteed to return a positive integer (>=1) if it
-# succeeds. It returns 0 if there's a problem determining the processor
-# count.
-#
-# Example use, in a ctest -S dashboard script:
-#
-# ::
-#
-# include(ProcessorCount)
-# ProcessorCount(N)
-# if(NOT N EQUAL 0)
-# set(CTEST_BUILD_FLAGS -j${N})
-# set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N})
-# endif()
-#
-#
-#
-# This function is intended to offer an approximation of the value of
-# the number of compute cores available on the current machine, such
-# that you may use that value for parallel building and parallel
-# testing. It is meant to help utilize as much of the machine as seems
-# reasonable. Of course, knowledge of what else might be running on the
-# machine simultaneously should be used when deciding whether to request
-# a machine's full capacity all for yourself.
+#[=======================================================================[.rst:
+ProcessorCount
+--------------
+
+ProcessorCount(var)
+
+Determine the number of processors/cores and save value in ${var}
+
+Sets the variable named ${var} to the number of physical cores
+available on the machine if the information can be determined.
+Otherwise it is set to 0. Currently this functionality is implemented
+for AIX, cygwin, FreeBSD, HPUX, Linux, macOS, QNX, Sun and
+Windows.
+
+This function is guaranteed to return a positive integer (>=1) if it
+succeeds. It returns 0 if there's a problem determining the processor
+count.
+
+Example use, in a ctest -S dashboard script:
+
+::
+
+ include(ProcessorCount)
+ ProcessorCount(N)
+ if(NOT N EQUAL 0)
+ set(CTEST_BUILD_FLAGS -j${N})
+ set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N})
+ endif()
+
+
+
+This function is intended to offer an approximation of the value of
+the number of compute cores available on the current machine, such
+that you may use that value for parallel building and parallel
+testing. It is meant to help utilize as much of the machine as seems
+reasonable. Of course, knowledge of what else might be running on the
+machine simultaneously should be used when deciding whether to request
+a machine's full capacity all for yourself.
+#]=======================================================================]
# A more reliable way might be to compile a small C program that uses the CPUID
# instruction, but that again requires compiler support or compiling assembler
@@ -69,6 +70,20 @@ function(ProcessorCount var)
endif()
if(NOT count)
+ # Linux (systems with nproc):
+ # Prefer nproc to getconf if available as getconf may return the host CPU count in Linux containers
+ find_program(ProcessorCount_cmd_nproc nproc)
+ mark_as_advanced(ProcessorCount_cmd_nproc)
+ if(ProcessorCount_cmd_nproc)
+ execute_process(COMMAND ${ProcessorCount_cmd_nproc}
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ OUTPUT_VARIABLE count)
+ #message("ProcessorCount: trying nproc '${ProcessorCount_cmd_nproc}'")
+ endif()
+ endif()
+
+ if(NOT count)
# Linux (systems with getconf):
find_program(ProcessorCount_cmd_getconf getconf)
mark_as_advanced(ProcessorCount_cmd_getconf)
@@ -114,22 +129,6 @@ function(ProcessorCount var)
endif()
if(NOT count)
- # IRIX (systems with hinv):
- find_program(ProcessorCount_cmd_hinv hinv
- PATHS /sbin)
- mark_as_advanced(ProcessorCount_cmd_hinv)
- if(ProcessorCount_cmd_hinv)
- execute_process(COMMAND ${ProcessorCount_cmd_hinv}
- ERROR_QUIET
- OUTPUT_STRIP_TRAILING_WHITESPACE
- OUTPUT_VARIABLE hinv_output)
- string(REGEX MATCHALL "([0-9]+) .* Processors" procs "${hinv_output}")
- set(count "${CMAKE_MATCH_1}")
- #message("ProcessorCount: trying hinv '${ProcessorCount_cmd_hinv}'")
- endif()
- endif()
-
- if(NOT count)
# AIX (systems with lsconf):
find_program(ProcessorCount_cmd_lsconf lsconf
PATHS /usr/sbin)
@@ -169,9 +168,13 @@ function(ProcessorCount var)
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE psrinfo_output)
- string(REGEX MATCH "([0-9]+) virtual processor" procs "${psrinfo_output}")
- set(count "${CMAKE_MATCH_1}")
- #message("ProcessorCount: trying psrinfo -p -v '${ProcessorCount_cmd_prvinfo}'")
+ string(REGEX MATCHALL "has [0-9]+ virtual processor" procs "${psrinfo_output}")
+ set(count "")
+ foreach(proc ${procs})
+ string(REGEX MATCH "has ([0-9]+) virtual" res ${proc})
+ math(EXPR count "${count} + ${CMAKE_MATCH_1}")
+ endforeach()
+ #message("ProcessorCount: trying '${ProcessorCount_cmd_psrinfo}' -p -v")
else()
# Sun (systems where uname -X emits "NumCPU" in its output):
find_program(ProcessorCount_cmd_uname uname)
diff --git a/Modules/Qt4ConfigDependentSettings.cmake b/Modules/Qt4ConfigDependentSettings.cmake
index e21ecf42e..4699ecdad 100644
--- a/Modules/Qt4ConfigDependentSettings.cmake
+++ b/Modules/Qt4ConfigDependentSettings.cmake
@@ -1,13 +1,14 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# Qt4ConfigDependentSettings
-# --------------------------
-#
-#
-#
-# This file is included by FindQt4.cmake, don't include it directly.
+#[=======================================================================[.rst:
+Qt4ConfigDependentSettings
+--------------------------
+
+
+
+This file is included by FindQt4.cmake, don't include it directly.
+#]=======================================================================]
###############################################
#
@@ -255,7 +256,6 @@ if(Q_WS_X11)
# X11 libraries Qt always depends on
set(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xext_LIB} ${X11_X11_LIB})
- set(CMAKE_THREAD_PREFER_PTHREAD 1)
find_package(Threads)
if(CMAKE_USE_PTHREADS_INIT)
set(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${CMAKE_THREAD_LIBS_INIT})
diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake
index 047891866..33cacf10b 100644
--- a/Modules/Qt4Macros.cmake
+++ b/Modules/Qt4Macros.cmake
@@ -1,13 +1,14 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# Qt4Macros
-# ---------
-#
-#
-#
-# This file is included by FindQt4.cmake, don't include it directly.
+#[=======================================================================[.rst:
+Qt4Macros
+---------
+
+
+
+This file is included by FindQt4.cmake, don't include it directly.
+#]=======================================================================]
######################################
#
@@ -139,19 +140,20 @@ endfunction ()
macro (QT4_GENERATE_MOC infile outfile )
-# get include dirs and flags
- QT4_GET_MOC_FLAGS(moc_flags)
- get_filename_component(abs_infile ${infile} ABSOLUTE)
- set(_outfile "${outfile}")
- if(NOT IS_ABSOLUTE "${outfile}")
- set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
- endif()
-
- if (${ARGC} GREATER 3 AND "x${ARGV2}" STREQUAL "xTARGET")
- set(moc_target ${ARGV3})
- endif()
- QT4_CREATE_MOC_COMMAND(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}")
- set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file
+ # get include dirs and flags
+ QT4_GET_MOC_FLAGS(moc_flags)
+ get_filename_component(abs_infile ${infile} ABSOLUTE)
+ set(_outfile "${outfile}")
+ if(NOT IS_ABSOLUTE "${outfile}")
+ set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
+ endif()
+
+ if (${ARGC} GREATER 3 AND "x${ARGV2}" STREQUAL "xTARGET")
+ set(moc_target ${ARGV3})
+ endif()
+ QT4_CREATE_MOC_COMMAND(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}")
+ set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file
+ set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file
endmacro ()
@@ -166,6 +168,8 @@ macro (QT4_WRAP_CPP outfiles )
get_filename_component(it ${it} ABSOLUTE)
QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile)
QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}")
+ set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file
+ set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file
set(${outfiles} ${${outfiles}} ${outfile})
endforeach()
@@ -185,6 +189,8 @@ macro (QT4_WRAP_UI outfiles )
COMMAND Qt4::uic
ARGS ${ui_options} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile} VERBATIM)
+ set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file
+ set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file
set(${outfiles} ${${outfiles}} ${outfile})
endforeach ()
@@ -233,6 +239,8 @@ macro (QT4_ADD_RESOURCES outfiles )
ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile}
MAIN_DEPENDENCY ${infile}
DEPENDS ${_RC_DEPENDS} "${out_depends}" VERBATIM)
+ set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file
+ set_property(SOURCE ${outfile} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file
set(${outfiles} ${${outfiles}} ${outfile})
endforeach ()
@@ -245,19 +253,19 @@ macro(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
set(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp")
set(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc")
- get_source_file_property(_nonamespace ${_interface} NO_NAMESPACE)
+ get_property(_nonamespace SOURCE ${_interface} PROPERTY NO_NAMESPACE)
if(_nonamespace)
set(_params -N -m)
else()
set(_params -m)
endif()
- get_source_file_property(_classname ${_interface} CLASSNAME)
+ get_property(_classname SOURCE ${_interface} PROPERTY CLASSNAME)
if(_classname)
set(_params ${_params} -c ${_classname})
endif()
- get_source_file_property(_include ${_interface} INCLUDE)
+ get_property(_include SOURCE ${_interface} PROPERTY INCLUDE)
if(_include)
set(_params ${_params} -i ${_include})
endif()
@@ -266,7 +274,8 @@ macro(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
COMMAND Qt4::qdbusxml2cpp ${_params} -p ${_basename} ${_infile}
DEPENDS ${_infile} VERBATIM)
- set_source_files_properties("${_impl}" PROPERTIES SKIP_AUTOMOC TRUE)
+ set_property(SOURCE ${_impl} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file
+ set_property(SOURCE ${_impl} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file
QT4_GENERATE_MOC("${_header}" "${_moc}")
@@ -350,7 +359,8 @@ macro(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optional
endif()
QT4_GENERATE_MOC("${_header}" "${_moc}")
- set_source_files_properties("${_impl}" PROPERTIES SKIP_AUTOMOC TRUE)
+ set_property(SOURCE ${_impl} PROPERTY SKIP_AUTOMOC TRUE) # don't run automoc on this file
+ set_property(SOURCE ${_impl} PROPERTY SKIP_AUTOUIC TRUE) # don't run autouic on this file
MACRO_ADD_FILE_DEPENDENCIES("${_impl}" "${_moc}")
list(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}")
@@ -374,7 +384,7 @@ macro(QT4_AUTOMOC)
# cmake is run for the very first time on them -> however the .cpp files might
# exist at a later run. at that time we need to skip them, so that we don't add two
# different rules for the same moc file
- get_source_file_property(_skip ${_abs_FILE} SKIP_AUTOMOC)
+ get_property(_skip SOURCE ${_abs_FILE} PROPERTY SKIP_AUTOMOC)
if ( NOT _skip AND EXISTS ${_abs_FILE} )
@@ -404,49 +414,49 @@ endmacro()
macro(QT4_CREATE_TRANSLATION _qm_files)
- QT4_EXTRACT_OPTIONS(_lupdate_files _lupdate_options _lupdate_target ${ARGN})
- set(_my_sources)
- set(_my_dirs)
- set(_my_tsfiles)
- set(_ts_pro)
- foreach (_file ${_lupdate_files})
- get_filename_component(_ext ${_file} EXT)
- get_filename_component(_abs_FILE ${_file} ABSOLUTE)
- if(_ext MATCHES "ts")
- list(APPEND _my_tsfiles ${_abs_FILE})
- else()
- if(NOT _ext)
- list(APPEND _my_dirs ${_abs_FILE})
- else()
- list(APPEND _my_sources ${_abs_FILE})
- endif()
- endif()
- endforeach()
- foreach(_ts_file ${_my_tsfiles})
- if(_my_sources)
- # make a .pro file to call lupdate on, so we don't make our commands too
- # long for some systems
- get_filename_component(_ts_name ${_ts_file} NAME_WE)
- set(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro)
- set(_pro_srcs)
- foreach(_pro_src ${_my_sources})
- string(APPEND _pro_srcs " \\\n \"${_pro_src}\"")
- endforeach()
- set(_pro_includes)
- get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
- list(REMOVE_DUPLICATES _inc_DIRS)
- foreach(_pro_include ${_inc_DIRS})
- get_filename_component(_abs_include "${_pro_include}" ABSOLUTE)
- string(APPEND _pro_includes " \\\n \"${_abs_include}\"")
- endforeach()
- file(GENERATE OUTPUT ${_ts_pro} CONTENT "SOURCES =${_pro_srcs}\nINCLUDEPATH =${_pro_includes}\n")
- endif()
- add_custom_command(OUTPUT ${_ts_file}
+ QT4_EXTRACT_OPTIONS(_lupdate_files _lupdate_options _lupdate_target ${ARGN})
+ set(_my_sources)
+ set(_my_dirs)
+ set(_my_tsfiles)
+ set(_ts_pro)
+ foreach (_file ${_lupdate_files})
+ get_filename_component(_ext ${_file} EXT)
+ get_filename_component(_abs_FILE ${_file} ABSOLUTE)
+ if(_ext MATCHES "ts")
+ list(APPEND _my_tsfiles ${_abs_FILE})
+ else()
+ if(NOT _ext)
+ list(APPEND _my_dirs ${_abs_FILE})
+ else()
+ list(APPEND _my_sources ${_abs_FILE})
+ endif()
+ endif()
+ endforeach()
+ foreach(_ts_file ${_my_tsfiles})
+ if(_my_sources)
+ # make a .pro file to call lupdate on, so we don't make our commands too
+ # long for some systems
+ get_filename_component(_ts_name ${_ts_file} NAME_WE)
+ set(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro)
+ set(_pro_srcs)
+ foreach(_pro_src ${_my_sources})
+ string(APPEND _pro_srcs " \\\n \"${_pro_src}\"")
+ endforeach()
+ set(_pro_includes)
+ get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
+ list(REMOVE_DUPLICATES _inc_DIRS)
+ foreach(_pro_include ${_inc_DIRS})
+ get_filename_component(_abs_include "${_pro_include}" ABSOLUTE)
+ string(APPEND _pro_includes " \\\n \"${_abs_include}\"")
+ endforeach()
+ file(GENERATE OUTPUT ${_ts_pro} CONTENT "SOURCES =${_pro_srcs}\nINCLUDEPATH =${_pro_includes}\n")
+ endif()
+ add_custom_command(OUTPUT ${_ts_file}
COMMAND Qt4::lupdate
ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file}
DEPENDS ${_my_sources} ${_ts_pro} VERBATIM)
- endforeach()
- QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles})
+ endforeach()
+ QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles})
endmacro()
@@ -454,7 +464,7 @@ macro(QT4_ADD_TRANSLATION _qm_files)
foreach (_current_FILE ${ARGN})
get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
get_filename_component(qm ${_abs_FILE} NAME_WE)
- get_source_file_property(output_location ${_abs_FILE} OUTPUT_LOCATION)
+ get_property(output_location SOURCE ${_abs_FILE} PROPERTY OUTPUT_LOCATION)
if(output_location)
file(MAKE_DIRECTORY "${output_location}")
set(qm "${output_location}/${qm}.qm")
diff --git a/Modules/SelectLibraryConfigurations.cmake b/Modules/SelectLibraryConfigurations.cmake
index dce6f9926..4c0e9a8c0 100644
--- a/Modules/SelectLibraryConfigurations.cmake
+++ b/Modules/SelectLibraryConfigurations.cmake
@@ -1,36 +1,45 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# SelectLibraryConfigurations
-# ---------------------------
-#
-#
-#
-# select_library_configurations( basename )
-#
-# This macro takes a library base name as an argument, and will choose
-# good values for basename_LIBRARY, basename_LIBRARIES,
-# basename_LIBRARY_DEBUG, and basename_LIBRARY_RELEASE depending on what
-# has been found and set. If only basename_LIBRARY_RELEASE is defined,
-# basename_LIBRARY will be set to the release value, and
-# basename_LIBRARY_DEBUG will be set to basename_LIBRARY_DEBUG-NOTFOUND.
-# If only basename_LIBRARY_DEBUG is defined, then basename_LIBRARY will
-# take the debug value, and basename_LIBRARY_RELEASE will be set to
-# basename_LIBRARY_RELEASE-NOTFOUND.
-#
-# If the generator supports configuration types, then basename_LIBRARY
-# and basename_LIBRARIES will be set with debug and optimized flags
-# specifying the library to be used for the given configuration. If no
-# build type has been set or the generator in use does not support
-# configuration types, then basename_LIBRARY and basename_LIBRARIES will
-# take only the release value, or the debug value if the release one is
-# not set.
+#[=======================================================================[.rst:
+SelectLibraryConfigurations
+---------------------------
+
+.. code-block:: cmake
+
+ select_library_configurations(basename)
+
+This macro takes a library base name as an argument, and will choose
+good values for the variables
+
+::
+
+ basename_LIBRARY
+ basename_LIBRARIES
+ basename_LIBRARY_DEBUG
+ basename_LIBRARY_RELEASE
+
+depending on what has been found and set.
+
+If only ``basename_LIBRARY_RELEASE`` is defined, ``basename_LIBRARY`` will
+be set to the release value, and ``basename_LIBRARY_DEBUG`` will be set
+to ``basename_LIBRARY_DEBUG-NOTFOUND``. If only ``basename_LIBRARY_DEBUG``
+is defined, then ``basename_LIBRARY`` will take the debug value, and
+``basename_LIBRARY_RELEASE`` will be set to ``basename_LIBRARY_RELEASE-NOTFOUND``.
+
+If the generator supports configuration types, then ``basename_LIBRARY``
+and ``basename_LIBRARIES`` will be set with debug and optimized flags
+specifying the library to be used for the given configuration. If no
+build type has been set or the generator in use does not support
+configuration types, then ``basename_LIBRARY`` and ``basename_LIBRARIES``
+will take only the release value, or the debug value if the release one
+is not set.
+#]=======================================================================]
# This macro was adapted from the FindQt4 CMake module and is maintained by Will
# Dicharry <wdicharry@stellarscience.com>.
-macro( select_library_configurations basename )
+macro(select_library_configurations basename)
if(NOT ${basename}_LIBRARY_RELEASE)
set(${basename}_LIBRARY_RELEASE "${basename}_LIBRARY_RELEASE-NOTFOUND" CACHE FILEPATH "Path to a library.")
endif()
@@ -38,11 +47,12 @@ macro( select_library_configurations basename )
set(${basename}_LIBRARY_DEBUG "${basename}_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to a library.")
endif()
+ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND
NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE AND
- ( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) )
- # if the generator supports configuration types or CMAKE_BUILD_TYPE
- # is set, then set optimized and debug options.
+ ( _isMultiConfig OR CMAKE_BUILD_TYPE ) )
+ # if the generator is multi-config or if CMAKE_BUILD_TYPE is set for
+ # single-config generators, set optimized and debug libraries
set( ${basename}_LIBRARY "" )
foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE )
list( APPEND ${basename}_LIBRARY optimized "${_libname}" )
diff --git a/Modules/Squish4RunTestCase.bat b/Modules/Squish4RunTestCase.bat
index ad1cc8c3b..c6582085a 100755
--- a/Modules/Squish4RunTestCase.bat
+++ b/Modules/Squish4RunTestCase.bat
@@ -1,24 +1,24 @@
-set SQUISHSERVER=%1
-set SQUISHRUNNER=%2
-set TESTSUITE=%3
-set TESTCASE=%4
-set AUT=%5
-set AUTDIR=%6
-set SETTINGSGROUP=%7
-
-%SQUISHSERVER% --stop
-
-echo "Adding AUT... %SQUISHSERVER% --config addAUT %AUT% %AUTDIR%"
-%SQUISHSERVER% --config addAUT "%AUT%" "%AUTDIR%"
-
-echo "Starting the squish server... %SQUISHSERVER%"
-start /B %SQUISHSERVER%
-
-echo "Running the test case...%SQUISHRUNNER% --testsuite %TESTSUITE% --testcase %TESTCASE%"
-%SQUISHRUNNER% --testsuite "%TESTSUITE%" --testcase "%TESTCASE%"
-set returnValue=%ERRORLEVEL%
-
-echo "Stopping the squish server... %SQUISHSERVER% --stop"
-%SQUISHSERVER% --stop
-
-exit /B %returnValue%
+set SQUISHSERVER=%1
+set SQUISHRUNNER=%2
+set TESTSUITE=%3
+set TESTCASE=%4
+set AUT=%5
+set AUTDIR=%6
+set SETTINGSGROUP=%7
+
+%SQUISHSERVER% --stop
+
+echo "Adding AUT... %SQUISHSERVER% --config addAUT %AUT% %AUTDIR%"
+%SQUISHSERVER% --config addAUT "%AUT%" "%AUTDIR%"
+
+echo "Starting the squish server... %SQUISHSERVER%"
+start /B %SQUISHSERVER%
+
+echo "Running the test case...%SQUISHRUNNER% --testsuite %TESTSUITE% --testcase %TESTCASE%"
+%SQUISHRUNNER% --testsuite "%TESTSUITE%" --testcase "%TESTCASE%"
+set returnValue=%ERRORLEVEL%
+
+echo "Stopping the squish server... %SQUISHSERVER% --stop"
+%SQUISHSERVER% --stop
+
+exit /B %returnValue%
diff --git a/Modules/SquishTestScript.cmake b/Modules/SquishTestScript.cmake
index cfdfaec1b..2a80be56f 100644
--- a/Modules/SquishTestScript.cmake
+++ b/Modules/SquishTestScript.cmake
@@ -1,21 +1,22 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# SquishTestScript
-# ----------------
-#
-#
-#
-#
-#
-# This script launches a GUI test using Squish. You should not call the
-# script directly; instead, you should access it via the SQUISH_ADD_TEST
-# macro that is defined in FindSquish.cmake.
-#
-# This script starts the Squish server, launches the test on the client,
-# and finally stops the squish server. If any of these steps fail
-# (including if the tests do not pass) then a fatal error is raised.
+#[=======================================================================[.rst:
+SquishTestScript
+----------------
+
+
+
+
+
+This script launches a GUI test using Squish. You should not call the
+script directly; instead, you should access it via the SQUISH_ADD_TEST
+macro that is defined in FindSquish.cmake.
+
+This script starts the Squish server, launches the test on the client,
+and finally stops the squish server. If any of these steps fail
+(including if the tests do not pass) then a fatal error is raised.
+#]=======================================================================]
# print out the variable that we are using
message(STATUS "squish_aut='${squish_aut}'")
@@ -34,7 +35,7 @@ message(STATUS "squish_settingsgroup='${squish_settingsgroup}'")
message(STATUS "squish_pre_command='${squish_pre_command}'")
message(STATUS "squish_post_command='${squish_post_command}'")
-# parse enviornment variables
+# parse environment variables
foreach(i ${squish_env_vars})
message(STATUS "parsing env var key/value pair ${i}")
string(REGEX MATCH "([^=]*)=(.*)" squish_env_name ${i})
diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake
index cc627d016..0c6e188c0 100644
--- a/Modules/TestBigEndian.cmake
+++ b/Modules/TestBigEndian.cmake
@@ -1,18 +1,21 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# TestBigEndian
-# -------------
-#
-# Define macro to determine endian type
-#
-# Check if the system is big endian or little endian
-#
-# ::
-#
-# TEST_BIG_ENDIAN(VARIABLE)
-# VARIABLE - variable to store the result to
+#[=======================================================================[.rst:
+TestBigEndian
+-------------
+
+Define macro to determine endian type
+
+Check if the system is big endian or little endian
+
+::
+
+ TEST_BIG_ENDIAN(VARIABLE)
+ VARIABLE - variable to store the result to
+#]=======================================================================]
+
+include(CheckTypeSize)
macro(TEST_BIG_ENDIAN VARIABLE)
if(NOT DEFINED HAVE_${VARIABLE})
@@ -27,8 +30,6 @@ macro(TEST_BIG_ENDIAN VARIABLE)
message(FATAL_ERROR "TEST_BIG_ENDIAN needs either C or CXX language enabled")
endif()
- include(CheckTypeSize)
-
CHECK_TYPE_SIZE("unsigned short" CMAKE_SIZEOF_UNSIGNED_SHORT LANGUAGE ${_test_language})
if(CMAKE_SIZEOF_UNSIGNED_SHORT EQUAL 2)
message(STATUS "Using unsigned short")
diff --git a/Modules/TestCXXAcceptsFlag.cmake b/Modules/TestCXXAcceptsFlag.cmake
index 10019ec68..92a362e2f 100644
--- a/Modules/TestCXXAcceptsFlag.cmake
+++ b/Modules/TestCXXAcceptsFlag.cmake
@@ -1,22 +1,25 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# TestCXXAcceptsFlag
-# ------------------
-#
-# Deprecated. See :module:`CheckCXXCompilerFlag`.
-#
-# Check if the CXX compiler accepts a flag.
-#
-# .. code-block:: cmake
-#
-# CHECK_CXX_ACCEPTS_FLAG(<flags> <variable>)
-#
-# ``<flags>``
-# the flags to try
-# ``<variable>``
-# variable to store the result
+#[=======================================================================[.rst:
+TestCXXAcceptsFlag
+------------------
+
+.. deprecated:: 3.0
+
+ See :module:`CheckCXXCompilerFlag`.
+
+Check if the CXX compiler accepts a flag.
+
+.. code-block:: cmake
+
+ CHECK_CXX_ACCEPTS_FLAG(<flags> <variable>)
+
+``<flags>``
+ the flags to try
+``<variable>``
+ variable to store the result
+#]=======================================================================]
macro(CHECK_CXX_ACCEPTS_FLAG FLAGS VARIABLE)
if(NOT DEFINED ${VARIABLE})
diff --git a/Modules/TestForANSIForScope.cmake b/Modules/TestForANSIForScope.cmake
index 7d2aad61b..272e4ec8b 100644
--- a/Modules/TestForANSIForScope.cmake
+++ b/Modules/TestForANSIForScope.cmake
@@ -1,18 +1,19 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# TestForANSIForScope
-# -------------------
-#
-# Check for ANSI for scope support
-#
-# Check if the compiler restricts the scope of variables declared in a
-# for-init-statement to the loop body.
-#
-# ::
-#
-# CMAKE_NO_ANSI_FOR_SCOPE - holds result
+#[=======================================================================[.rst:
+TestForANSIForScope
+-------------------
+
+Check for ANSI for scope support
+
+Check if the compiler restricts the scope of variables declared in a
+for-init-statement to the loop body.
+
+::
+
+ CMAKE_NO_ANSI_FOR_SCOPE - holds result
+#]=======================================================================]
if(NOT DEFINED CMAKE_ANSI_FOR_SCOPE)
message(STATUS "Check for ANSI scope")
diff --git a/Modules/TestForANSIStreamHeaders.cmake b/Modules/TestForANSIStreamHeaders.cmake
index e890c677f..e532a71b7 100644
--- a/Modules/TestForANSIStreamHeaders.cmake
+++ b/Modules/TestForANSIStreamHeaders.cmake
@@ -1,18 +1,19 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# TestForANSIStreamHeaders
-# ------------------------
-#
-# Test for compiler support of ANSI stream headers iostream, etc.
-#
-# check if the compiler supports the standard ANSI iostream header
-# (without the .h)
-#
-# ::
-#
-# CMAKE_NO_ANSI_STREAM_HEADERS - defined by the results
+#[=======================================================================[.rst:
+TestForANSIStreamHeaders
+------------------------
+
+Test for compiler support of ANSI stream headers iostream, etc.
+
+check if the compiler supports the standard ANSI iostream header
+(without the .h)
+
+::
+
+ CMAKE_NO_ANSI_STREAM_HEADERS - defined by the results
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/CheckIncludeFileCXX.cmake)
diff --git a/Modules/TestForSSTREAM.cmake b/Modules/TestForSSTREAM.cmake
index 0bfbfbbbd..e70df00ab 100644
--- a/Modules/TestForSSTREAM.cmake
+++ b/Modules/TestForSSTREAM.cmake
@@ -1,17 +1,18 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# TestForSSTREAM
-# --------------
-#
-# Test for compiler support of ANSI sstream header
-#
-# check if the compiler supports the standard ANSI sstream header
-#
-# ::
-#
-# CMAKE_NO_ANSI_STRING_STREAM - defined by the results
+#[=======================================================================[.rst:
+TestForSSTREAM
+--------------
+
+Test for compiler support of ANSI sstream header
+
+check if the compiler supports the standard ANSI sstream header
+
+::
+
+ CMAKE_NO_ANSI_STRING_STREAM - defined by the results
+#]=======================================================================]
if(NOT DEFINED CMAKE_HAS_ANSI_STRING_STREAM)
message(STATUS "Check for sstream")
diff --git a/Modules/TestForSTDNamespace.cmake b/Modules/TestForSTDNamespace.cmake
index 3ae80c744..703e631eb 100644
--- a/Modules/TestForSTDNamespace.cmake
+++ b/Modules/TestForSTDNamespace.cmake
@@ -1,17 +1,18 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# TestForSTDNamespace
-# -------------------
-#
-# Test for std:: namespace support
-#
-# check if the compiler supports std:: on stl classes
-#
-# ::
-#
-# CMAKE_NO_STD_NAMESPACE - defined by the results
+#[=======================================================================[.rst:
+TestForSTDNamespace
+-------------------
+
+Test for std:: namespace support
+
+check if the compiler supports std:: on stl classes
+
+::
+
+ CMAKE_NO_STD_NAMESPACE - defined by the results
+#]=======================================================================]
if(NOT DEFINED CMAKE_STD_NAMESPACE)
message(STATUS "Check for STD namespace")
diff --git a/Modules/UseEcos.cmake b/Modules/UseEcos.cmake
index 942bc38bb..60324b1bd 100644
--- a/Modules/UseEcos.cmake
+++ b/Modules/UseEcos.cmake
@@ -1,68 +1,69 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# UseEcos
-# -------
-#
-# This module defines variables and macros required to build eCos application.
-#
-# This file contains the following macros:
-# ECOS_ADD_INCLUDE_DIRECTORIES() - add the eCos include dirs
-# ECOS_ADD_EXECUTABLE(name source1 ... sourceN ) - create an eCos
-# executable ECOS_ADJUST_DIRECTORY(VAR source1 ... sourceN ) - adjusts
-# the path of the source files and puts the result into VAR
-#
-# Macros for selecting the toolchain: ECOS_USE_ARM_ELF_TOOLS() - enable
-# the ARM ELF toolchain for the directory where it is called
-# ECOS_USE_I386_ELF_TOOLS() - enable the i386 ELF toolchain for the
-# directory where it is called ECOS_USE_PPC_EABI_TOOLS() - enable the
-# PowerPC toolchain for the directory where it is called
-#
-# It contains the following variables: ECOS_DEFINITIONS
-# ECOSCONFIG_EXECUTABLE ECOS_CONFIG_FILE - defaults to ecos.ecc, if your
-# eCos configuration file has a different name, adjust this variable for
-# internal use only:
-#
-# ::
-#
-# ECOS_ADD_TARGET_LIB
+#[=======================================================================[.rst:
+UseEcos
+-------
+
+This module defines variables and macros required to build eCos application.
+
+This file contains the following macros:
+ECOS_ADD_INCLUDE_DIRECTORIES() - add the eCos include dirs
+ECOS_ADD_EXECUTABLE(name source1 ... sourceN ) - create an eCos
+executable ECOS_ADJUST_DIRECTORY(VAR source1 ... sourceN ) - adjusts
+the path of the source files and puts the result into VAR
+
+Macros for selecting the toolchain: ECOS_USE_ARM_ELF_TOOLS() - enable
+the ARM ELF toolchain for the directory where it is called
+ECOS_USE_I386_ELF_TOOLS() - enable the i386 ELF toolchain for the
+directory where it is called ECOS_USE_PPC_EABI_TOOLS() - enable the
+PowerPC toolchain for the directory where it is called
+
+It contains the following variables: ECOS_DEFINITIONS
+ECOSCONFIG_EXECUTABLE ECOS_CONFIG_FILE - defaults to ecos.ecc, if your
+eCos configuration file has a different name, adjust this variable for
+internal use only:
+
+::
+
+ ECOS_ADD_TARGET_LIB
+#]=======================================================================]
# first check that ecosconfig is available
find_program(ECOSCONFIG_EXECUTABLE NAMES ecosconfig)
if(NOT ECOSCONFIG_EXECUTABLE)
- message(SEND_ERROR "ecosconfig was not found. Either include it in the system path or set it manually using ccmake.")
+ message(SEND_ERROR "ecosconfig was not found. Either include it in the system path or set it manually using ccmake.")
else()
- message(STATUS "Found ecosconfig: ${ECOSCONFIG_EXECUTABLE}")
+ message(STATUS "Found ecosconfig: ${ECOSCONFIG_EXECUTABLE}")
endif()
# check that ECOS_REPOSITORY is set correctly
if (NOT EXISTS $ENV{ECOS_REPOSITORY}/ecos.db)
- message(SEND_ERROR "The environment variable ECOS_REPOSITORY is not set correctly. Set it to the directory which contains the file ecos.db")
+ message(SEND_ERROR "The environment variable ECOS_REPOSITORY is not set correctly. Set it to the directory which contains the file ecos.db")
else ()
- message(STATUS "ECOS_REPOSITORY is set to $ENV{ECOS_REPOSITORY}")
+ message(STATUS "ECOS_REPOSITORY is set to $ENV{ECOS_REPOSITORY}")
endif ()
# check that tclsh (coming with TCL) is available, otherwise ecosconfig doesn't work
find_package(Tclsh)
if (NOT TCL_TCLSH)
- message(SEND_ERROR "The TCL tclsh was not found. Please install TCL, it is required for building eCos applications.")
+ message(SEND_ERROR "The TCL tclsh was not found. Please install TCL, it is required for building eCos applications.")
else ()
- message(STATUS "tlcsh found: ${TCL_TCLSH}")
+ message(STATUS "tlcsh found: ${TCL_TCLSH}")
endif ()
#add the globale include-diretories
#usage: ECOS_ADD_INCLUDE_DIRECTORIES()
macro(ECOS_ADD_INCLUDE_DIRECTORIES)
#check for ProjectSources.txt one level higher
- if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../ProjectSources.txt)
- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
- else ()
- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/)
- endif ()
+ if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../ProjectSources.txt)
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../)
+ else ()
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/)
+ endif ()
#the ecos include directory
- include_directories(${CMAKE_CURRENT_BINARY_DIR}/ecos/install/include/)
+ include_directories(${CMAKE_CURRENT_BINARY_DIR}/ecos/install/include/)
endmacro()
@@ -70,47 +71,47 @@ endmacro()
#we want to compile for the xscale processor, in this case the following macro has to be called
#usage: ECOS_USE_ARM_ELF_TOOLS()
macro (ECOS_USE_ARM_ELF_TOOLS)
- set(CMAKE_CXX_COMPILER "arm-elf-c++")
- set(CMAKE_COMPILER_IS_GNUCXX 1)
- set(CMAKE_C_COMPILER "arm-elf-gcc")
- set(CMAKE_AR "arm-elf-ar")
- set(CMAKE_RANLIB "arm-elf-ranlib")
+ set(CMAKE_CXX_COMPILER "arm-elf-c++")
+ set(CMAKE_COMPILER_IS_GNUCXX 1)
+ set(CMAKE_C_COMPILER "arm-elf-gcc")
+ set(CMAKE_AR "arm-elf-ar")
+ set(CMAKE_RANLIB "arm-elf-ranlib")
#for linking
- set(ECOS_LD_MCPU "-mcpu=xscale")
+ set(ECOS_LD_MCPU "-mcpu=xscale")
#for compiling
- add_definitions(-mcpu=xscale -mapcs-frame)
+ add_definitions(-mcpu=xscale -mapcs-frame)
#for the obj-tools
- set(ECOS_ARCH_PREFIX "arm-elf-")
+ set(ECOS_ARCH_PREFIX "arm-elf-")
endmacro ()
#usage: ECOS_USE_PPC_EABI_TOOLS()
macro (ECOS_USE_PPC_EABI_TOOLS)
- set(CMAKE_CXX_COMPILER "powerpc-eabi-c++")
- set(CMAKE_COMPILER_IS_GNUCXX 1)
- set(CMAKE_C_COMPILER "powerpc-eabi-gcc")
- set(CMAKE_AR "powerpc-eabi-ar")
- set(CMAKE_RANLIB "powerpc-eabi-ranlib")
+ set(CMAKE_CXX_COMPILER "powerpc-eabi-c++")
+ set(CMAKE_COMPILER_IS_GNUCXX 1)
+ set(CMAKE_C_COMPILER "powerpc-eabi-gcc")
+ set(CMAKE_AR "powerpc-eabi-ar")
+ set(CMAKE_RANLIB "powerpc-eabi-ranlib")
#for linking
- set(ECOS_LD_MCPU "")
+ set(ECOS_LD_MCPU "")
#for compiling
- add_definitions()
+ add_definitions()
#for the obj-tools
- set(ECOS_ARCH_PREFIX "powerpc-eabi-")
+ set(ECOS_ARCH_PREFIX "powerpc-eabi-")
endmacro ()
#usage: ECOS_USE_I386_ELF_TOOLS()
macro (ECOS_USE_I386_ELF_TOOLS)
- set(CMAKE_CXX_COMPILER "i386-elf-c++")
- set(CMAKE_COMPILER_IS_GNUCXX 1)
- set(CMAKE_C_COMPILER "i386-elf-gcc")
- set(CMAKE_AR "i386-elf-ar")
- set(CMAKE_RANLIB "i386-elf-ranlib")
+ set(CMAKE_CXX_COMPILER "i386-elf-c++")
+ set(CMAKE_COMPILER_IS_GNUCXX 1)
+ set(CMAKE_C_COMPILER "i386-elf-gcc")
+ set(CMAKE_AR "i386-elf-ar")
+ set(CMAKE_RANLIB "i386-elf-ranlib")
#for linking
- set(ECOS_LD_MCPU "")
+ set(ECOS_LD_MCPU "")
#for compiling
- add_definitions()
+ add_definitions()
#for the obj-tools
- set(ECOS_ARCH_PREFIX "i386-elf-")
+ set(ECOS_ARCH_PREFIX "i386-elf-")
endmacro ()
@@ -121,13 +122,13 @@ endmacro ()
#followed by all source files
#usage: ECOS_ADJUST_DIRECTORY(adjusted_SRCS ${my_srcs})
macro(ECOS_ADJUST_DIRECTORY _target_FILES )
- foreach (_current_FILE ${ARGN})
- get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
+ foreach (_current_FILE ${ARGN})
+ get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
if (NOT ${_abs_FILE} STREQUAL ${_current_FILE})
- get_filename_component(_abs_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../${_current_FILE} ABSOLUTE)
+ get_filename_component(_abs_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../${_current_FILE} ABSOLUTE)
endif ()
- list(APPEND ${_target_FILES} ${_abs_FILE})
- endforeach ()
+ list(APPEND ${_target_FILES} ${_abs_FILE})
+ endforeach ()
endmacro()
# the default ecos config file name
@@ -138,29 +139,29 @@ set(ECOS_CONFIG_FILE ecos.ecc)
#adds the command for compiling ecos
macro(ECOS_ADD_TARGET_LIB)
# when building out-of-source, create the ecos/ subdir
- if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/ecos)
- file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ecos)
- endif()
+ if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/ecos)
+ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ecos)
+ endif()
#sources depend on target.ld
- set_source_files_properties(
- ${ARGN}
- PROPERTIES
- OBJECT_DEPENDS
- ${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib/target.ld
- )
-
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib/target.ld
- COMMAND sh -c \"make -C ${CMAKE_CURRENT_BINARY_DIR}/ecos || exit -1\; if [ -e ${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib/target.ld ] \; then touch ${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib/target.ld\; fi\"
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ecos/makefile
- )
-
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ecos/makefile
- COMMAND sh -c \" cd ${CMAKE_CURRENT_BINARY_DIR}/ecos\; ${ECOSCONFIG_EXECUTABLE} --config=${CMAKE_CURRENT_SOURCE_DIR}/ecos/${ECOS_CONFIG_FILE} tree || exit -1\;\"
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ecos/${ECOS_CONFIG_FILE}
- )
-
- add_custom_target( ecos make -C ${CMAKE_CURRENT_BINARY_DIR}/ecos/ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ecos/makefile )
+ set_source_files_properties(
+ ${ARGN}
+ PROPERTIES
+ OBJECT_DEPENDS
+ ${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib/target.ld
+ )
+
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib/target.ld
+ COMMAND sh -c \"make -C ${CMAKE_CURRENT_BINARY_DIR}/ecos || exit -1\; if [ -e ${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib/target.ld ] \; then touch ${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib/target.ld\; fi\"
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ecos/makefile
+ )
+
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ecos/makefile
+ COMMAND sh -c \" cd ${CMAKE_CURRENT_BINARY_DIR}/ecos\; ${ECOSCONFIG_EXECUTABLE} --config=${CMAKE_CURRENT_SOURCE_DIR}/ecos/${ECOS_CONFIG_FILE} tree || exit -1\;\"
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ecos/${ECOS_CONFIG_FILE}
+ )
+
+ add_custom_target( ecos make -C ${CMAKE_CURRENT_BINARY_DIR}/ecos/ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ecos/makefile )
endmacro()
# get the directory of the current file, used later on in the file
@@ -172,64 +173,64 @@ get_filename_component( ECOS_CMAKE_MODULE_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
#has been adjusted beforehand by calling ECOS_ADJUST_DIRECTORY()
#usage: ECOS_ADD_EXECUTABLE(my_app ${adjusted_SRCS})
macro(ECOS_ADD_EXECUTABLE _exe_NAME )
- #definitions, valid for all ecos projects
- #the optimization and "-g" for debugging has to be enabled
- #in the project-specific CMakeLists.txt
- add_definitions(-D__ECOS__=1 -D__ECOS=1)
- set(ECOS_DEFINITIONS -Wall -Wno-long-long -pipe -fno-builtin)
+ #definitions, valid for all ecos projects
+ #the optimization and "-g" for debugging has to be enabled
+ #in the project-specific CMakeLists.txt
+ add_definitions(-D__ECOS__=1 -D__ECOS=1)
+ set(ECOS_DEFINITIONS -Wall -Wno-long-long -pipe -fno-builtin)
#the executable depends on ecos target.ld
- ECOS_ADD_TARGET_LIB(${ARGN})
+ ECOS_ADD_TARGET_LIB(${ARGN})
-# when using nmake makefiles, the custom buildtype supresses the default cl.exe flags
+# when using nmake makefiles, the custom buildtype suppresses the default cl.exe flags
# and the rules for creating objects are adjusted for gcc
- set(CMAKE_BUILD_TYPE CUSTOM_ECOS_BUILD)
- set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
- set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
+ set(CMAKE_BUILD_TYPE CUSTOM_ECOS_BUILD)
+ set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
+ set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
# special link commands for ecos-executables
- set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <OBJECTS> -o <TARGET> ${_ecos_EXTRA_LIBS} -nostdlib -nostartfiles -L${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib -Ttarget.ld ${ECOS_LD_MCPU}")
- set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <CMAKE_C_LINK_FLAGS> <OBJECTS> -o <TARGET> ${_ecos_EXTRA_LIBS} -nostdlib -nostartfiles -L${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib -Ttarget.ld ${ECOS_LD_MCPU}")
+ set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <OBJECTS> -o <TARGET> ${_ecos_EXTRA_LIBS} -nostdlib -nostartfiles -L${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib -Ttarget.ld ${ECOS_LD_MCPU}")
+ set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <CMAKE_C_LINK_FLAGS> <OBJECTS> -o <TARGET> ${_ecos_EXTRA_LIBS} -nostdlib -nostartfiles -L${CMAKE_CURRENT_BINARY_DIR}/ecos/install/lib -Ttarget.ld ${ECOS_LD_MCPU}")
# some strict compiler flags
- set (CMAKE_C_FLAGS "-Wstrict-prototypes")
- set (CMAKE_CXX_FLAGS "-Woverloaded-virtual -fno-rtti -Wctor-dtor-privacy -fno-strict-aliasing -fno-exceptions")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes")
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -fno-rtti -Wctor-dtor-privacy -fno-strict-aliasing -fno-exceptions")
- add_executable(${_exe_NAME} ${ARGN})
- set_target_properties(${_exe_NAME} PROPERTIES SUFFIX ".elf")
+ add_executable(${_exe_NAME} ${ARGN})
+ set_target_properties(${_exe_NAME} PROPERTIES SUFFIX ".elf")
#create a binary file
- add_custom_command(
- TARGET ${_exe_NAME}
- POST_BUILD
- COMMAND ${ECOS_ARCH_PREFIX}objcopy
- ARGS -O binary ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.elf ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.bin
- )
+ add_custom_command(
+ TARGET ${_exe_NAME}
+ POST_BUILD
+ COMMAND ${ECOS_ARCH_PREFIX}objcopy
+ ARGS -O binary ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.elf ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.bin
+ )
#and an srec file
- add_custom_command(
- TARGET ${_exe_NAME}
- POST_BUILD
- COMMAND ${ECOS_ARCH_PREFIX}objcopy
- ARGS -O srec ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.elf ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.srec
- )
+ add_custom_command(
+ TARGET ${_exe_NAME}
+ POST_BUILD
+ COMMAND ${ECOS_ARCH_PREFIX}objcopy
+ ARGS -O srec ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.elf ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.srec
+ )
#add the created files to the clean-files
- set_directory_properties(
- PROPERTIES
- ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.bin;${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.srec;${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst;"
- )
-
- add_custom_target(ecosclean ${CMAKE_COMMAND} -DECOS_DIR=${CMAKE_CURRENT_BINARY_DIR}/ecos/ -P ${ECOS_CMAKE_MODULE_DIR}/ecos_clean.cmake )
- add_custom_target(normalclean ${CMAKE_MAKE_PROGRAM} clean WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
- add_dependencies (ecosclean normalclean)
-
-
- add_custom_target( listing
- COMMAND echo -e \"\\n--- Symbols sorted by address ---\\n\" > ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst
- COMMAND ${ECOS_ARCH_PREFIX}nm -S -C -n ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.elf >> ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst
- COMMAND echo -e \"\\n--- Symbols sorted by size ---\\n\" >> ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst
- COMMAND ${ECOS_ARCH_PREFIX}nm -S -C -r --size-sort ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.elf >> ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst
- COMMAND echo -e \"\\n--- Full assembly listing ---\\n\" >> ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst
- COMMAND ${ECOS_ARCH_PREFIX}objdump -S -x -d -C ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.elf >> ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst )
+ set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.bin"
+ "${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.srec"
+ "${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst")
+
+ add_custom_target(ecosclean ${CMAKE_COMMAND} -DECOS_DIR=${CMAKE_CURRENT_BINARY_DIR}/ecos/ -P ${ECOS_CMAKE_MODULE_DIR}/ecos_clean.cmake )
+ add_custom_target(normalclean ${CMAKE_MAKE_PROGRAM} clean WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ add_dependencies (ecosclean normalclean)
+
+
+ add_custom_target( listing
+ COMMAND echo -e \"\\n--- Symbols sorted by address ---\\n\" > ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst
+ COMMAND ${ECOS_ARCH_PREFIX}nm -S -C -n ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.elf >> ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst
+ COMMAND echo -e \"\\n--- Symbols sorted by size ---\\n\" >> ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst
+ COMMAND ${ECOS_ARCH_PREFIX}nm -S -C -r --size-sort ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.elf >> ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst
+ COMMAND echo -e \"\\n--- Full assembly listing ---\\n\" >> ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst
+ COMMAND ${ECOS_ARCH_PREFIX}objdump -S -x -d -C ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.elf >> ${CMAKE_CURRENT_BINARY_DIR}/${_exe_NAME}.lst )
endmacro()
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake
index 11828757b..07984885b 100644
--- a/Modules/UseJava.cmake
+++ b/Modules/UseJava.cmake
@@ -1,409 +1,374 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# UseJava
-# -------
-#
-# Use Module for Java
-#
-# This file provides functions for Java. It is assumed that
-# FindJava.cmake has already been loaded. See FindJava.cmake for
-# information on how to load Java into your CMake project.
-#
-# ::
-#
-# add_jar(target_name
-# [SOURCES] source1 [source2 ...] [resource1 ...]
-# [INCLUDE_JARS jar1 [jar2 ...]]
-# [ENTRY_POINT entry]
-# [VERSION version]
-# [OUTPUT_NAME name]
-# [OUTPUT_DIR dir]
-# )
-#
-# This command creates a <target_name>.jar. It compiles the given
-# source files (source) and adds the given resource files (resource) to
-# the jar file. Source files can be java files or listing files
-# (prefixed by '@'). If only resource files are given then just a jar file
-# is created. The list of include jars are added to the classpath when
-# compiling the java sources and also to the dependencies of the target.
-# INCLUDE_JARS also accepts other target names created by add_jar. For
-# backwards compatibility, jar files listed as sources are ignored (as
-# they have been since the first version of this module).
-#
-# The default OUTPUT_DIR can also be changed by setting the variable
-# CMAKE_JAVA_TARGET_OUTPUT_DIR.
-#
-# Additional instructions:
-#
-# ::
-#
-# To add compile flags to the target you can set these flags with
-# the following variable:
-#
-#
-#
-# ::
-#
-# set(CMAKE_JAVA_COMPILE_FLAGS -nowarn)
-#
-#
-#
-# ::
-#
-# To add a path or a jar file to the class path you can do this
-# with the CMAKE_JAVA_INCLUDE_PATH variable.
-#
-#
-#
-# ::
-#
-# set(CMAKE_JAVA_INCLUDE_PATH /usr/share/java/shibboleet.jar)
-#
-#
-#
-# ::
-#
-# To use a different output name for the target you can set it with:
-#
-#
-#
-# ::
-#
-# add_jar(foobar foobar.java OUTPUT_NAME shibboleet.jar)
-#
-#
-#
-# ::
-#
-# To use a different output directory than CMAKE_CURRENT_BINARY_DIR
-# you can set it with:
-#
-#
-#
-# ::
-#
-# add_jar(foobar foobar.java OUTPUT_DIR ${PROJECT_BINARY_DIR}/bin)
-#
-#
-#
-# ::
-#
-# To define an entry point in your jar you can set it with the ENTRY_POINT
-# named argument:
-#
-#
-#
-# ::
-#
-# add_jar(example ENTRY_POINT com/examples/MyProject/Main)
-#
-#
-#
-# ::
-#
-# To define a custom manifest for the jar, you can set it with the manifest
-# named argument:
-#
-#
-#
-# ::
-#
-# add_jar(example MANIFEST /path/to/manifest)
-#
-#
-#
-# ::
-#
-# To add a VERSION to the target output name you can set it using
-# the VERSION named argument to add_jar. This will create a jar file with the
-# name shibboleet-1.0.0.jar and will create a symlink shibboleet.jar
-# pointing to the jar with the version information.
-#
-#
-#
-# ::
-#
-# add_jar(shibboleet shibbotleet.java VERSION 1.2.0)
-#
-#
-#
-# ::
-#
-# If the target is a JNI library, utilize the following commands to
-# create a JNI symbolic link:
-#
-#
-#
-# ::
-#
-# set(CMAKE_JNI_TARGET TRUE)
-# add_jar(shibboleet shibbotleet.java VERSION 1.2.0)
-# install_jar(shibboleet ${LIB_INSTALL_DIR}/shibboleet)
-# install_jni_symlink(shibboleet ${JAVA_LIB_INSTALL_DIR})
-#
-#
-#
-# ::
-#
-# If a single target needs to produce more than one jar from its
-# java source code, to prevent the accumulation of duplicate class
-# files in subsequent jars, set/reset CMAKE_JAR_CLASSES_PREFIX prior
-# to calling the add_jar() function:
-#
-#
-#
-# ::
-#
-# set(CMAKE_JAR_CLASSES_PREFIX com/redhat/foo)
-# add_jar(foo foo.java)
-#
-#
-#
-# ::
-#
-# set(CMAKE_JAR_CLASSES_PREFIX com/redhat/bar)
-# add_jar(bar bar.java)
-#
-#
-#
-# Target Properties:
-#
-# ::
-#
-# The add_jar() function sets some target properties. You can get these
-# properties with the
-# get_property(TARGET <target_name> PROPERTY <propery_name>)
-# command.
-#
-#
-#
-# ::
-#
-# INSTALL_FILES The files which should be installed. This is used by
-# install_jar().
-# JNI_SYMLINK The JNI symlink which should be installed.
-# This is used by install_jni_symlink().
-# JAR_FILE The location of the jar file so that you can include
-# it.
-# CLASSDIR The directory where the class files can be found. For
-# example to use them with javah.
-#
-# ::
-#
-# find_jar(<VAR>
-# name | NAMES name1 [name2 ...]
-# [PATHS path1 [path2 ... ENV var]]
-# [VERSIONS version1 [version2]]
-# [DOC "cache documentation string"]
-# )
-#
-# This command is used to find a full path to the named jar. A cache
-# entry named by <VAR> is created to stor the result of this command.
-# If the full path to a jar is found the result is stored in the
-# variable and the search will not repeated unless the variable is
-# cleared. If nothing is found, the result will be <VAR>-NOTFOUND, and
-# the search will be attempted again next time find_jar is invoked with
-# the same variable. The name of the full path to a file that is
-# searched for is specified by the names listed after NAMES argument.
-# Additional search locations can be specified after the PATHS argument.
-# If you require special a version of a jar file you can specify it with
-# the VERSIONS argument. The argument after DOC will be used for the
-# documentation string in the cache.
-#
-# ::
-#
-# install_jar(target_name destination)
-# install_jar(target_name DESTINATION destination [COMPONENT component])
-#
-# This command installs the TARGET_NAME files to the given DESTINATION.
-# It should be called in the same scope as add_jar() or it will fail.
-#
-# Target Properties:
-#
-# ::
-#
-# The install_jar() function sets the INSTALL_DESTINATION target property
-# on jars so installed. This property holds the DESTINATION as described
-# above, and is used by install_jar_exports(). You can get this property
-# with the
-# get_property(TARGET <target_name> PROPERTY INSTALL_DESTINATION)
-# command.
-#
-#
-#
-# ::
-#
-# install_jni_symlink(target_name destination)
-# install_jni_symlink(target_name DESTINATION destination [COMPONENT component])
-#
-# This command installs the TARGET_NAME JNI symlinks to the given
-# DESTINATION. It should be called in the same scope as add_jar() or it
-# will fail.
-#
-# ::
-#
-# install_jar_exports(TARGETS jars...
-# [NAMESPACE <namespace>]
-# FILE <filename>
-# DESTINATION <dir> [COMPONENT <component>])
-#
-# This command installs a target export file ``<filename>`` for the named jar
-# targets to the given ``DESTINATION``. Its function is similar to that of
-# :command:`install(EXPORTS ...)`.
-#
-# ::
-#
-# export_jars(TARGETS jars...
-# [NAMESPACE <namespace>]
-# FILE <filename>)
-#
-# This command writes a target export file ``<filename>`` for the named jar
-# targets. Its function is similar to that of :command:`export(...)`.
-#
-# ::
-#
-# create_javadoc(<VAR>
-# PACKAGES pkg1 [pkg2 ...]
-# [SOURCEPATH <sourcepath>]
-# [CLASSPATH <classpath>]
-# [INSTALLPATH <install path>]
-# [DOCTITLE "the documentation title"]
-# [WINDOWTITLE "the title of the document"]
-# [AUTHOR TRUE|FALSE]
-# [USE TRUE|FALSE]
-# [VERSION TRUE|FALSE]
-# )
-#
-# Create java documentation based on files or packages. For more
-# details please read the javadoc manpage.
-#
-# There are two main signatures for create_javadoc. The first signature
-# works with package names on a path with source files:
-#
-# ::
-#
-# Example:
-# create_javadoc(my_example_doc
-# PACKAGES com.exmaple.foo com.example.bar
-# SOURCEPATH "${CMAKE_CURRENT_SOURCE_DIR}"
-# CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
-# WINDOWTITLE "My example"
-# DOCTITLE "<h1>My example</h1>"
-# AUTHOR TRUE
-# USE TRUE
-# VERSION TRUE
-# )
-#
-#
-#
-# The second signature for create_javadoc works on a given list of
-# files.
-#
-# ::
-#
-# create_javadoc(<VAR>
-# FILES file1 [file2 ...]
-# [CLASSPATH <classpath>]
-# [INSTALLPATH <install path>]
-# [DOCTITLE "the documentation title"]
-# [WINDOWTITLE "the title of the document"]
-# [AUTHOR TRUE|FALSE]
-# [USE TRUE|FALSE]
-# [VERSION TRUE|FALSE]
-# )
-#
-#
-#
-# Example:
-#
-# ::
-#
-# create_javadoc(my_example_doc
-# FILES ${example_SRCS}
-# CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
-# WINDOWTITLE "My example"
-# DOCTITLE "<h1>My example</h1>"
-# AUTHOR TRUE
-# USE TRUE
-# VERSION TRUE
-# )
-#
-#
-#
-# Both signatures share most of the options. These options are the same
-# as what you can find in the javadoc manpage. Please look at the
-# manpage for CLASSPATH, DOCTITLE, WINDOWTITLE, AUTHOR, USE and VERSION.
-#
-# The documentation will be by default installed to
-#
-# ::
-#
-# ${CMAKE_INSTALL_PREFIX}/share/javadoc/<VAR>
-#
-#
-#
-# if you don't set the INSTALLPATH.
-#
-# ::
-#
-# create_javah(TARGET <target>
-# GENERATED_FILES <VAR>
-# CLASSES <class>...
-# [CLASSPATH <classpath>...]
-# [DEPENDS <depend>...]
-# [OUTPUT_NAME <path>|OUTPUT_DIR <path>]
-# )
-#
-# Create C header files from java classes. These files provide the connective glue
-# that allow your Java and C code to interact.
-#
-# There are two main signatures for create_javah. The first signature
-# returns generated files through variable specified by GENERATED_FILES option:
-#
-# ::
-#
-# Example:
-# Create_javah(GENERATED_FILES files_headers
-# CLASSES org.cmake.HelloWorld
-# CLASSPATH hello.jar
-# )
-#
-#
-#
-# The second signature for create_javah creates a target which encapsulates
-# header files generation.
-#
-# ::
-#
-# Example:
-# Create_javah(TARGET target_headers
-# CLASSES org.cmake.HelloWorld
-# CLASSPATH hello.jar
-# )
-#
-#
-#
-# Both signatures share same options.
-#
-# ``CLASSES <class>...``
-# Specifies Java classes used to generate headers.
-#
-# ``CLASSPATH <classpath>...``
-# Specifies various paths to look up classes. Here .class files, jar files or targets
-# created by command add_jar can be used.
-#
-# ``DEPENDS <depend>...``
-# Targets on which the javah target depends
-#
-# ``OUTPUT_NAME <path>``
-# Concatenates the resulting header files for all the classes listed by option CLASSES
-# into <path>. Same behavior as option '-o' of javah tool.
-#
-# ``OUTPUT_DIR <path>``
-# Sets the directory where the header files will be generated. Same behavior as option
-# '-d' of javah tool. If not specified, ${CMAKE_CURRENT_BINARY_DIR} is used as output directory.
+#[=======================================================================[.rst:
+UseJava
+-------
+
+Use Module for Java
+
+This file provides functions for Java. It is assumed that
+:module:`FindJava` has already been loaded. See :module:`FindJava` for
+information on how to load Java into your CMake project.
+
+Creating And Installing JARs
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. code-block:: cmake
+
+ add_jar(<target_name>
+ [SOURCES] <source1> [<source2>...] [<resource1>...]
+ [INCLUDE_JARS <jar1> [<jar2>...]]
+ [ENTRY_POINT <entry>]
+ [VERSION <version>]
+ [OUTPUT_NAME <name>]
+ [OUTPUT_DIR <dir>]
+ [GENERATE_NATIVE_HEADERS <target> [DESTINATION <dir>]]
+ )
+
+This command creates a ``<target_name>.jar``. It compiles the given
+``<source>`` files and adds the given ``<resource>`` files to
+the jar file. Source files can be java files or listing files
+(prefixed by ``@``). If only resource files are given then just a jar file
+is created. The list of ``INCLUDE_JARS`` are added to the classpath when
+compiling the java sources and also to the dependencies of the target.
+``INCLUDE_JARS`` also accepts other target names created by ``add_jar()``.
+For backwards compatibility, jar files listed as sources are ignored (as
+they have been since the first version of this module).
+
+The default ``OUTPUT_DIR`` can also be changed by setting the variable
+``CMAKE_JAVA_TARGET_OUTPUT_DIR``.
+
+Optionally, using option ``GENERATE_NATIVE_HEADERS``, native header files can
+be generated for methods declared as native. These files provide the
+connective glue that allow your Java and C code to interact. An INTERFACE
+target will be created for an easy usage of generated files. Sub-option
+``DESTINATION`` can be used to specify the output directory for generated
+header files.
+
+``GENERATE_NATIVE_HEADERS`` option requires, at least, version 1.8 of the JDK.
+
+The ``add_jar()`` function sets the following target properties on
+``<target_name>``:
+
+``INSTALL_FILES``
+ The files which should be installed. This is used by ``install_jar()``.
+``JNI_SYMLINK``
+ The JNI symlink which should be installed. This is used by
+ ``install_jni_symlink()``.
+``JAR_FILE``
+ The location of the jar file so that you can include it.
+``CLASSDIR``
+ The directory where the class files can be found. For example to use them
+ with ``javah``.
+
+.. code-block:: cmake
+
+ install_jar(<target_name> <destination>)
+ install_jar(<target_name> DESTINATION <destination> [COMPONENT <component>])
+
+This command installs the ``<target_name>`` files to the given
+``<destination>``. It should be called in the same scope as ``add_jar()`` or
+it will fail.
+
+The ``install_jar()`` function sets the ``INSTALL_DESTINATION`` target
+property on jars so installed. This property holds the ``<destination>`` as
+described above, and is used by ``install_jar_exports()``. You can get this
+information with :command:`get_property` and the ``INSTALL_DESTINATION``
+property key.
+
+.. code-block:: cmake
+
+ install_jni_symlink(<target_name> <destination>)
+ install_jni_symlink(<target_name> DESTINATION <destination> [COMPONENT <component>])
+
+This command installs the ``<target_name>`` JNI symlinks to the given
+``<destination>``. It should be called in the same scope as ``add_jar()`` or
+it will fail.
+
+.. code-block:: cmake
+
+ install_jar_exports(TARGETS <jars>...
+ [NAMESPACE <namespace>]
+ FILE <filename>
+ DESTINATION <destination> [COMPONENT <component>])
+
+This command installs a target export file ``<filename>`` for the named jar
+targets to the given ``<destination>`` directory. Its function is similar to
+that of :command:`install(EXPORTS)`.
+
+.. code-block:: cmake
+
+ export_jars(TARGETS <jars>...
+ [NAMESPACE <namespace>]
+ FILE <filename>)
+
+This command writes a target export file ``<filename>`` for the named ``<jars>``
+targets. Its function is similar to that of :command:`export`.
+
+
+Examples
+""""""""
+
+To add compile flags to the target you can set these flags with the following
+variable:
+
+.. code-block:: cmake
+
+ set(CMAKE_JAVA_COMPILE_FLAGS -nowarn)
+
+
+To add a path or a jar file to the class path you can do this with the
+``CMAKE_JAVA_INCLUDE_PATH`` variable.
+
+.. code-block:: cmake
+
+ set(CMAKE_JAVA_INCLUDE_PATH /usr/share/java/shibboleet.jar)
+
+To use a different output name for the target you can set it with:
+
+.. code-block:: cmake
+
+ add_jar(foobar foobar.java OUTPUT_NAME shibboleet.jar)
+
+To use a different output directory than ``CMAKE_CURRENT_BINARY_DIR`` you can
+set it with:
+
+.. code-block:: cmake
+
+ add_jar(foobar foobar.java OUTPUT_DIR ${PROJECT_BINARY_DIR}/bin)
+
+To define an entry point in your jar you can set it with the ``ENTRY_POINT``
+named argument:
+
+.. code-block:: cmake
+
+ add_jar(example ENTRY_POINT com/examples/MyProject/Main)
+
+To define a custom manifest for the jar, you can set it with the ``MANIFEST``
+named argument:
+
+.. code-block:: cmake
+
+ add_jar(example MANIFEST /path/to/manifest)
+
+To add a version to the target output name you can set it using the ``VERSION``
+named argument to ``add_jar()``. The following example will create a jar file
+with the name ``shibboleet-1.0.0.jar`` and will create a symlink
+``shibboleet.jar`` pointing to the jar with the version information.
+
+.. code-block:: cmake
+
+ add_jar(shibboleet shibbotleet.java VERSION 1.2.0)
+
+If the target is a JNI library, utilize the following commands to
+create a JNI symbolic link:
+
+.. code-block:: cmake
+
+ set(CMAKE_JNI_TARGET TRUE)
+ add_jar(shibboleet shibbotleet.java VERSION 1.2.0)
+ install_jar(shibboleet ${LIB_INSTALL_DIR}/shibboleet)
+ install_jni_symlink(shibboleet ${JAVA_LIB_INSTALL_DIR})
+
+If a single target needs to produce more than one jar from its
+java source code, to prevent the accumulation of duplicate class
+files in subsequent jars, set/reset ``CMAKE_JAR_CLASSES_PREFIX`` prior
+to calling the ``add_jar()`` function:
+
+.. code-block:: cmake
+
+ set(CMAKE_JAR_CLASSES_PREFIX com/redhat/foo)
+ add_jar(foo foo.java)
+
+ set(CMAKE_JAR_CLASSES_PREFIX com/redhat/bar)
+ add_jar(bar bar.java)
+
+For an optimum usage of option ``GENERATE_NATIVE_HEADERS``, it is recommended to
+include module JNI before any call to ``add_jar()``. The produced target for
+native headers can then be used to compile C/C++ sources with the
+:command:`target_link_libraries` command.
+
+.. code-block:: cmake
+
+ find_package(JNI)
+ add_jar(foo foo.java GENERATE_NATIVE_HEADERS foo-native)
+ add_library(bar bar.cpp)
+ target_link_libraries(bar PRIVATE foo-native)
+
+
+Finding JARs
+^^^^^^^^^^^^
+
+.. code-block:: cmake
+
+ find_jar(<VAR>
+ <name> | NAMES <name1> [<name2>...]
+ [PATHS <path1> [<path2>... ENV <var>]]
+ [VERSIONS <version1> [<version2>]]
+ [DOC "cache documentation string"]
+ )
+
+This command is used to find a full path to the named jar. A cache
+entry named by ``<VAR>`` is created to store the result of this command.
+If the full path to a jar is found the result is stored in the
+variable and the search will not repeated unless the variable is
+cleared. If nothing is found, the result will be ``<VAR>-NOTFOUND``, and
+the search will be attempted again next time ``find_jar()`` is invoked with
+the same variable. The name of the full path to a file that is
+searched for is specified by the names listed after ``NAMES`` argument.
+Additional search locations can be specified after the ``PATHS`` argument.
+If you require special a version of a jar file you can specify it with
+the ``VERSIONS`` argument. The argument after ``DOC`` will be used for the
+documentation string in the cache.
+
+
+Javadoc
+^^^^^^^
+
+The ``create_javadoc()`` command can be used to create java documentation
+based on files or packages. For more details please read the javadoc manpage.
+
+There are two main signatures for ``create_javadoc()``. The first signature
+works with package names on a path with source files.
+
+.. code-block:: cmake
+
+ create_javadoc(<VAR>
+ PACKAGES <pkg1> [<pkg2>...]
+ [SOURCEPATH <sourcepath>]
+ [CLASSPATH <classpath>]
+ [INSTALLPATH <install path>]
+ [DOCTITLE "the documentation title"]
+ [WINDOWTITLE "the title of the document"]
+ [AUTHOR TRUE|FALSE]
+ [USE TRUE|FALSE]
+ [VERSION TRUE|FALSE]
+ )
+
+For example:
+
+.. code-block:: cmake
+
+ create_javadoc(my_example_doc
+ PACKAGES com.example.foo com.example.bar
+ SOURCEPATH "${CMAKE_CURRENT_SOURCE_DIR}"
+ CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
+ WINDOWTITLE "My example"
+ DOCTITLE "<h1>My example</h1>"
+ AUTHOR TRUE
+ USE TRUE
+ VERSION TRUE
+ )
+
+The second signature for ``create_javadoc()`` works on a given list of
+files.
+
+.. code-block:: cmake
+
+ create_javadoc(<VAR>
+ FILES <file1> [<file2>...]
+ [CLASSPATH <classpath>]
+ [INSTALLPATH <install path>]
+ [DOCTITLE "the documentation title"]
+ [WINDOWTITLE "the title of the document"]
+ [AUTHOR TRUE|FALSE]
+ [USE TRUE|FALSE]
+ [VERSION TRUE|FALSE]
+ )
+
+For example:
+
+.. code-block:: cmake
+
+ create_javadoc(my_example_doc
+ FILES ${example_SRCS}
+ CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
+ WINDOWTITLE "My example"
+ DOCTITLE "<h1>My example</h1>"
+ AUTHOR TRUE
+ USE TRUE
+ VERSION TRUE
+ )
+
+Both signatures share most of the options. These options are the same
+as what you can find in the javadoc manpage. Please look at the
+manpage for ``CLASSPATH``, ``DOCTITLE``, ``WINDOWTITLE``, ``AUTHOR``, ``USE``
+and ``VERSION``.
+
+If you don't set the ``INSTALLPATH``, then by default the documentation will
+be installed to :
+
+::
+
+ ${CMAKE_INSTALL_PREFIX}/share/javadoc/<VAR>
+
+
+Header Generation
+^^^^^^^^^^^^^^^^^
+
+.. code-block:: cmake
+
+ create_javah(TARGET <target> | GENERATED_FILES <VAR>
+ CLASSES <class>...
+ [CLASSPATH <classpath>...]
+ [DEPENDS <depend>...]
+ [OUTPUT_NAME <path>|OUTPUT_DIR <path>]
+ )
+
+Create C header files from java classes. These files provide the connective glue
+that allow your Java and C code to interact.
+
+.. deprecated:: 3.11
+
+.. note::
+
+ This command will no longer be supported starting with version 10 of the JDK
+ due to the `suppression of javah tool <http://openjdk.java.net/jeps/313>`_.
+ The ``add_jar(GENERATE_NATIVE_HEADERS)`` command should be used instead.
+
+There are two main signatures for ``create_javah()``. The first signature
+returns generated files through variable specified by the ``GENERATED_FILES``
+option. For example:
+
+.. code-block:: cmake
+
+ create_javah(GENERATED_FILES files_headers
+ CLASSES org.cmake.HelloWorld
+ CLASSPATH hello.jar
+ )
+
+The second signature for ``create_javah()`` creates a target which encapsulates
+header files generation. E.g.
+
+.. code-block:: cmake
+
+ create_javah(TARGET target_headers
+ CLASSES org.cmake.HelloWorld
+ CLASSPATH hello.jar
+ )
+
+Both signatures share same options.
+
+``CLASSES <class>...``
+ Specifies Java classes used to generate headers.
+
+``CLASSPATH <classpath>...``
+ Specifies various paths to look up classes. Here .class files, jar files or
+ targets created by command add_jar can be used.
+
+``DEPENDS <depend>...``
+ Targets on which the javah target depends.
+
+``OUTPUT_NAME <path>``
+ Concatenates the resulting header files for all the classes listed by option
+ ``CLASSES`` into ``<path>``. Same behavior as option ``-o`` of javah tool.
+
+``OUTPUT_DIR <path>``
+ Sets the directory where the header files will be generated. Same behavior
+ as option ``-d`` of javah tool. If not specified,
+ :variable:`CMAKE_CURRENT_BINARY_DIR` is used as the output directory.
+#]=======================================================================]
function (__java_copy_file src dest comment)
add_custom_command(
@@ -416,7 +381,7 @@ function (__java_copy_file src dest comment)
endfunction ()
function(__java_lcat VAR)
- foreach(_line ${ARGN})
+ foreach(_line IN LISTS ARGN)
string(APPEND ${VAR} "${_line}\n")
endforeach()
@@ -448,7 +413,7 @@ function(add_jar _TARGET_NAME)
cmake_parse_arguments(_add_jar
""
"VERSION;OUTPUT_DIR;OUTPUT_NAME;ENTRY_POINT;MANIFEST"
- "SOURCES;INCLUDE_JARS"
+ "SOURCES;INCLUDE_JARS;GENERATE_NATIVE_HEADERS"
${ARGN}
)
@@ -481,6 +446,8 @@ function(add_jar _TARGET_NAME)
else()
get_filename_component(_add_jar_OUTPUT_DIR ${_add_jar_OUTPUT_DIR} ABSOLUTE)
endif()
+ # ensure output directory exists
+ file (MAKE_DIRECTORY "${_add_jar_OUTPUT_DIR}")
if (_add_jar_ENTRY_POINT)
set(_ENTRY_POINT_OPTION e)
@@ -492,6 +459,31 @@ function(add_jar _TARGET_NAME)
get_filename_component (_MANIFEST_VALUE "${_add_jar_MANIFEST}" ABSOLUTE)
endif ()
+ unset (_GENERATE_NATIVE_HEADERS)
+ if (_add_jar_GENERATE_NATIVE_HEADERS)
+ # Raise an error if JDK version is less than 1.8 because javac -h is not supported
+ # by earlier versions.
+ if (Java_VERSION VERSION_LESS 1.8)
+ message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS is not supported with this version of Java.")
+ endif()
+ cmake_parse_arguments (_add_jar_GENERATE_NATIVE_HEADERS "" "DESTINATION" "" ${_add_jar_GENERATE_NATIVE_HEADERS})
+ if (NOT _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS)
+ message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS: missing required argument.")
+ endif()
+ list (LENGTH _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS length)
+ if (length GREATER 1)
+ list (REMOVE_AT _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS 0)
+ message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS: ${_add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS}: unexpected argument(s).")
+ endif()
+ if (NOT _add_jar_GENERATE_NATIVE_HEADERS_DESTINATION)
+ set (_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir/native_headers")
+ endif()
+
+ set (_GENERATE_NATIVE_HEADERS_TARGET ${_add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS})
+ set (_GENERATE_NATIVE_HEADERS_OUTPUT_DIR "${_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION}")
+ set (_GENERATE_NATIVE_HEADERS -h "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}")
+ endif()
+
if (LIBRARY_OUTPUT_PATH)
set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
else ()
@@ -511,11 +503,11 @@ function(add_jar _TARGET_NAME)
set(CMAKE_JAVA_INCLUDE_FLAG_SEP ":")
endif()
- foreach (JAVA_INCLUDE_DIR ${CMAKE_JAVA_INCLUDE_PATH})
+ foreach (JAVA_INCLUDE_DIR IN LISTS CMAKE_JAVA_INCLUDE_PATH)
string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}")
endforeach()
- set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${_add_jar_OUTPUT_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir")
+ set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir")
set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}.jar")
if (_add_jar_OUTPUT_NAME AND _add_jar_VERSION)
@@ -535,7 +527,7 @@ function(add_jar _TARGET_NAME)
set(_JAVA_COMPILE_DEPENDS)
set(_JAVA_RESOURCE_FILES)
set(_JAVA_RESOURCE_FILES_RELATIVE)
- foreach(_JAVA_SOURCE_FILE ${_JAVA_SOURCE_FILES})
+ foreach(_JAVA_SOURCE_FILE IN LISTS _JAVA_SOURCE_FILES)
get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT)
get_filename_component(_JAVA_FILE ${_JAVA_SOURCE_FILE} NAME_WE)
get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH)
@@ -546,11 +538,11 @@ function(add_jar _TARGET_NAME)
list(APPEND _JAVA_COMPILE_FILELISTS ${_JAVA_FULL})
elseif (_JAVA_EXT MATCHES ".java")
- file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${_add_jar_OUTPUT_DIR} ${_JAVA_FULL})
+ file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_CURRENT_BINARY_DIR} ${_JAVA_FULL})
file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL})
string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN)
string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN)
- if (${_BIN_LEN} LESS ${_SRC_LEN})
+ if (_BIN_LEN LESS _SRC_LEN)
set(_JAVA_REL_PATH ${_JAVA_REL_BINARY_PATH})
else ()
set(_JAVA_REL_PATH ${_JAVA_REL_SOURCE_PATH})
@@ -580,14 +572,14 @@ function(add_jar _TARGET_NAME)
endif ()
endforeach()
- foreach(_JAVA_INCLUDE_JAR ${_add_jar_INCLUDE_JARS})
+ foreach(_JAVA_INCLUDE_JAR IN LISTS _add_jar_INCLUDE_JARS)
if (TARGET ${_JAVA_INCLUDE_JAR})
get_target_property(_JAVA_JAR_PATH ${_JAVA_INCLUDE_JAR} JAR_FILE)
if (_JAVA_JAR_PATH)
string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_JAR_PATH}")
list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_JAR_PATH})
list(APPEND _JAVA_DEPENDS ${_JAVA_INCLUDE_JAR})
- list(APPEND _JAVA_COMPILE_DEPENDS ${_JAVA_INCLUDE_JAR})
+ list(APPEND _JAVA_COMPILE_DEPENDS ${_JAVA_JAR_PATH})
else ()
message(SEND_ERROR "add_jar: INCLUDE_JARS target ${_JAVA_INCLUDE_JAR} is not a jar")
endif ()
@@ -623,6 +615,7 @@ function(add_jar _TARGET_NAME)
${CMAKE_JAVA_COMPILE_FLAGS}
-classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}"
-d ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
+ ${_GENERATE_NATIVE_HEADERS}
${_JAVA_SOURCES_FILELISTS}
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_FILELISTS} ${_JAVA_COMPILE_DEPENDS}
@@ -647,7 +640,7 @@ function(add_jar _TARGET_NAME)
# create the jar file
set(_JAVA_JAR_OUTPUT_PATH
- ${_add_jar_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_NAME})
+ "${_add_jar_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_NAME}")
if (CMAKE_JNI_TARGET)
add_custom_command(
OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
@@ -733,6 +726,18 @@ function(add_jar _TARGET_NAME)
${CMAKE_JAVA_CLASS_OUTPUT_PATH}
)
+ if (_GENERATE_NATIVE_HEADERS)
+ # create an INTERFACE library encapsulating include directory for generated headers
+ add_library (${_GENERATE_NATIVE_HEADERS_TARGET} INTERFACE)
+ target_include_directories (${_GENERATE_NATIVE_HEADERS_TARGET} INTERFACE
+ "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}"
+ ${JNI_INCLUDE_DIRS})
+ # this INTERFACE library depends on jar generation
+ add_dependencies (${_GENERATE_NATIVE_HEADERS_TARGET} ${_TARGET_NAME})
+
+ set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES
+ "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}")
+ endif()
endfunction()
function(INSTALL_JAR _TARGET_NAME)
@@ -834,15 +839,15 @@ function (find_jar VARIABLE)
set(_state "name")
- foreach (arg ${ARGN})
- if (${_state} STREQUAL "name")
- if (${arg} STREQUAL "VERSIONS")
+ foreach (arg IN LISTS ARGN)
+ if (_state STREQUAL "name")
+ if (arg STREQUAL "VERSIONS")
set(_state "versions")
- elseif (${arg} STREQUAL "NAMES")
+ elseif (arg STREQUAL "NAMES")
set(_state "names")
- elseif (${arg} STREQUAL "PATHS")
+ elseif (arg STREQUAL "PATHS")
set(_state "paths")
- elseif (${arg} STREQUAL "DOC")
+ elseif (arg STREQUAL "DOC")
set(_state "doc")
else ()
set(_jar_names ${arg})
@@ -850,22 +855,22 @@ function (find_jar VARIABLE)
set(_jar_doc "Finding ${arg} jar")
endif ()
endif ()
- elseif (${_state} STREQUAL "versions")
- if (${arg} STREQUAL "NAMES")
+ elseif (_state STREQUAL "versions")
+ if (arg STREQUAL "NAMES")
set(_state "names")
- elseif (${arg} STREQUAL "PATHS")
+ elseif (arg STREQUAL "PATHS")
set(_state "paths")
- elseif (${arg} STREQUAL "DOC")
+ elseif (arg STREQUAL "DOC")
set(_state "doc")
else ()
set(_jar_versions ${_jar_versions} ${arg})
endif ()
- elseif (${_state} STREQUAL "names")
- if (${arg} STREQUAL "VERSIONS")
+ elseif (_state STREQUAL "names")
+ if (arg STREQUAL "VERSIONS")
set(_state "versions")
- elseif (${arg} STREQUAL "PATHS")
+ elseif (arg STREQUAL "PATHS")
set(_state "paths")
- elseif (${arg} STREQUAL "DOC")
+ elseif (arg STREQUAL "DOC")
set(_state "doc")
else ()
set(_jar_names ${_jar_names} ${arg})
@@ -873,22 +878,22 @@ function (find_jar VARIABLE)
set(_jar_doc "Finding ${arg} jar")
endif ()
endif ()
- elseif (${_state} STREQUAL "paths")
- if (${arg} STREQUAL "VERSIONS")
+ elseif (_state STREQUAL "paths")
+ if (arg STREQUAL "VERSIONS")
set(_state "versions")
- elseif (${arg} STREQUAL "NAMES")
+ elseif (arg STREQUAL "NAMES")
set(_state "names")
- elseif (${arg} STREQUAL "DOC")
+ elseif (arg STREQUAL "DOC")
set(_state "doc")
else ()
set(_jar_paths ${_jar_paths} ${arg})
endif ()
- elseif (${_state} STREQUAL "doc")
- if (${arg} STREQUAL "VERSIONS")
+ elseif (_state STREQUAL "doc")
+ if (arg STREQUAL "VERSIONS")
set(_state "versions")
- elseif (${arg} STREQUAL "NAMES")
+ elseif (arg STREQUAL "NAMES")
set(_state "names")
- elseif (${arg} STREQUAL "PATHS")
+ elseif (arg STREQUAL "PATHS")
set(_state "paths")
else ()
set(_jar_doc ${arg})
@@ -900,8 +905,8 @@ function (find_jar VARIABLE)
message(FATAL_ERROR "find_jar: No name to search for given")
endif ()
- foreach (jar_name ${_jar_names})
- foreach (version ${_jar_versions})
+ foreach (jar_name IN LISTS _jar_names)
+ foreach (version IN LISTS _jar_versions)
set(_jar_files ${_jar_files} ${jar_name}-${version}.jar)
endforeach ()
set(_jar_files ${_jar_files} ${jar_name}.jar)
@@ -928,252 +933,252 @@ function(create_javadoc _target)
set(_state "package")
- foreach (arg ${ARGN})
- if (${_state} STREQUAL "package")
- if (${arg} STREQUAL "PACKAGES")
+ foreach (arg IN LISTS ARGN)
+ if (_state STREQUAL "package")
+ if (arg STREQUAL "PACKAGES")
set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
+ elseif (arg STREQUAL "FILES")
set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
+ elseif (arg STREQUAL "SOURCEPATH")
set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
+ elseif (arg STREQUAL "CLASSPATH")
set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
+ elseif (arg STREQUAL "INSTALLPATH")
set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
+ elseif (arg STREQUAL "DOCTITLE")
set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
+ elseif (arg STREQUAL "WINDOWTITLE")
set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
+ elseif (arg STREQUAL "AUTHOR")
set(_state "author")
- elseif (${arg} STREQUAL "USE")
+ elseif (arg STREQUAL "USE")
set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
+ elseif (arg STREQUAL "VERSION")
set(_state "version")
else ()
set(_javadoc_packages ${arg})
set(_state "packages")
endif ()
- elseif (${_state} STREQUAL "packages")
- if (${arg} STREQUAL "FILES")
+ elseif (_state STREQUAL "packages")
+ if (arg STREQUAL "FILES")
set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
+ elseif (arg STREQUAL "SOURCEPATH")
set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
+ elseif (arg STREQUAL "CLASSPATH")
set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
+ elseif (arg STREQUAL "INSTALLPATH")
set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
+ elseif (arg STREQUAL "DOCTITLE")
set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
+ elseif (arg STREQUAL "WINDOWTITLE")
set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
+ elseif (arg STREQUAL "AUTHOR")
set(_state "author")
- elseif (${arg} STREQUAL "USE")
+ elseif (arg STREQUAL "USE")
set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
+ elseif (arg STREQUAL "VERSION")
set(_state "version")
else ()
list(APPEND _javadoc_packages ${arg})
endif ()
- elseif (${_state} STREQUAL "files")
- if (${arg} STREQUAL "PACKAGES")
+ elseif (_state STREQUAL "files")
+ if (arg STREQUAL "PACKAGES")
set(_state "packages")
- elseif (${arg} STREQUAL "SOURCEPATH")
+ elseif (arg STREQUAL "SOURCEPATH")
set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
+ elseif (arg STREQUAL "CLASSPATH")
set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
+ elseif (arg STREQUAL "INSTALLPATH")
set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
+ elseif (arg STREQUAL "DOCTITLE")
set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
+ elseif (arg STREQUAL "WINDOWTITLE")
set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
+ elseif (arg STREQUAL "AUTHOR")
set(_state "author")
- elseif (${arg} STREQUAL "USE")
+ elseif (arg STREQUAL "USE")
set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
+ elseif (arg STREQUAL "VERSION")
set(_state "version")
else ()
list(APPEND _javadoc_files ${arg})
endif ()
- elseif (${_state} STREQUAL "sourcepath")
- if (${arg} STREQUAL "PACKAGES")
+ elseif (_state STREQUAL "sourcepath")
+ if (arg STREQUAL "PACKAGES")
set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
+ elseif (arg STREQUAL "FILES")
set(_state "files")
- elseif (${arg} STREQUAL "CLASSPATH")
+ elseif (arg STREQUAL "CLASSPATH")
set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
+ elseif (arg STREQUAL "INSTALLPATH")
set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
+ elseif (arg STREQUAL "DOCTITLE")
set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
+ elseif (arg STREQUAL "WINDOWTITLE")
set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
+ elseif (arg STREQUAL "AUTHOR")
set(_state "author")
- elseif (${arg} STREQUAL "USE")
+ elseif (arg STREQUAL "USE")
set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
+ elseif (arg STREQUAL "VERSION")
set(_state "version")
else ()
list(APPEND _javadoc_sourcepath ${arg})
endif ()
- elseif (${_state} STREQUAL "classpath")
- if (${arg} STREQUAL "PACKAGES")
+ elseif (_state STREQUAL "classpath")
+ if (arg STREQUAL "PACKAGES")
set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
+ elseif (arg STREQUAL "FILES")
set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
+ elseif (arg STREQUAL "SOURCEPATH")
set(_state "sourcepath")
- elseif (${arg} STREQUAL "INSTALLPATH")
+ elseif (arg STREQUAL "INSTALLPATH")
set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
+ elseif (arg STREQUAL "DOCTITLE")
set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
+ elseif (arg STREQUAL "WINDOWTITLE")
set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
+ elseif (arg STREQUAL "AUTHOR")
set(_state "author")
- elseif (${arg} STREQUAL "USE")
+ elseif (arg STREQUAL "USE")
set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
+ elseif (arg STREQUAL "VERSION")
set(_state "version")
else ()
list(APPEND _javadoc_classpath ${arg})
endif ()
- elseif (${_state} STREQUAL "installpath")
- if (${arg} STREQUAL "PACKAGES")
+ elseif (_state STREQUAL "installpath")
+ if (arg STREQUAL "PACKAGES")
set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
+ elseif (arg STREQUAL "FILES")
set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
+ elseif (arg STREQUAL "SOURCEPATH")
set(_state "sourcepath")
- elseif (${arg} STREQUAL "DOCTITLE")
+ elseif (arg STREQUAL "DOCTITLE")
set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
+ elseif (arg STREQUAL "WINDOWTITLE")
set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
+ elseif (arg STREQUAL "AUTHOR")
set(_state "author")
- elseif (${arg} STREQUAL "USE")
+ elseif (arg STREQUAL "USE")
set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
+ elseif (arg STREQUAL "VERSION")
set(_state "version")
else ()
set(_javadoc_installpath ${arg})
endif ()
- elseif (${_state} STREQUAL "doctitle")
+ elseif (_state STREQUAL "doctitle")
if (${arg} STREQUAL "PACKAGES")
set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
+ elseif (arg STREQUAL "FILES")
set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
+ elseif (arg STREQUAL "SOURCEPATH")
set(_state "sourcepath")
- elseif (${arg} STREQUAL "INSTALLPATH")
+ elseif (arg STREQUAL "INSTALLPATH")
set(_state "installpath")
- elseif (${arg} STREQUAL "CLASSPATH")
+ elseif (arg STREQUAL "CLASSPATH")
set(_state "classpath")
- elseif (${arg} STREQUAL "WINDOWTITLE")
+ elseif (arg STREQUAL "WINDOWTITLE")
set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
+ elseif (arg STREQUAL "AUTHOR")
set(_state "author")
- elseif (${arg} STREQUAL "USE")
+ elseif (arg STREQUAL "USE")
set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
+ elseif (arg STREQUAL "VERSION")
set(_state "version")
else ()
set(_javadoc_doctitle ${arg})
endif ()
- elseif (${_state} STREQUAL "windowtitle")
+ elseif (_state STREQUAL "windowtitle")
if (${arg} STREQUAL "PACKAGES")
set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
+ elseif (arg STREQUAL "FILES")
set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
+ elseif (arg STREQUAL "SOURCEPATH")
set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
+ elseif (arg STREQUAL "CLASSPATH")
set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
+ elseif (arg STREQUAL "INSTALLPATH")
set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
+ elseif (arg STREQUAL "DOCTITLE")
set(_state "doctitle")
- elseif (${arg} STREQUAL "AUTHOR")
+ elseif (arg STREQUAL "AUTHOR")
set(_state "author")
- elseif (${arg} STREQUAL "USE")
+ elseif (arg STREQUAL "USE")
set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
+ elseif (arg STREQUAL "VERSION")
set(_state "version")
else ()
set(_javadoc_windowtitle ${arg})
endif ()
- elseif (${_state} STREQUAL "author")
- if (${arg} STREQUAL "PACKAGES")
+ elseif (_state STREQUAL "author")
+ if (arg STREQUAL "PACKAGES")
set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
+ elseif (arg STREQUAL "FILES")
set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
+ elseif (arg STREQUAL "SOURCEPATH")
set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
+ elseif (arg STREQUAL "CLASSPATH")
set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
+ elseif (arg STREQUAL "INSTALLPATH")
set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
+ elseif (arg STREQUAL "DOCTITLE")
set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
+ elseif (arg STREQUAL "WINDOWTITLE")
set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
+ elseif (arg STREQUAL "AUTHOR")
set(_state "author")
- elseif (${arg} STREQUAL "USE")
+ elseif (arg STREQUAL "USE")
set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
+ elseif (arg STREQUAL "VERSION")
set(_state "version")
else ()
set(_javadoc_author ${arg})
endif ()
- elseif (${_state} STREQUAL "use")
- if (${arg} STREQUAL "PACKAGES")
+ elseif (_state STREQUAL "use")
+ if (arg STREQUAL "PACKAGES")
set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
+ elseif (arg STREQUAL "FILES")
set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
+ elseif (arg STREQUAL "SOURCEPATH")
set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
+ elseif (arg STREQUAL "CLASSPATH")
set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
+ elseif (arg STREQUAL "INSTALLPATH")
set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
+ elseif (arg STREQUAL "DOCTITLE")
set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
+ elseif (arg STREQUAL "WINDOWTITLE")
set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
+ elseif (arg STREQUAL "AUTHOR")
set(_state "author")
- elseif (${arg} STREQUAL "USE")
+ elseif (arg STREQUAL "USE")
set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
+ elseif (arg STREQUAL "VERSION")
set(_state "version")
else ()
set(_javadoc_use ${arg})
endif ()
- elseif (${_state} STREQUAL "version")
- if (${arg} STREQUAL "PACKAGES")
+ elseif (_state STREQUAL "version")
+ if (arg STREQUAL "PACKAGES")
set(_state "packages")
- elseif (${arg} STREQUAL "FILES")
+ elseif (arg STREQUAL "FILES")
set(_state "files")
- elseif (${arg} STREQUAL "SOURCEPATH")
+ elseif (arg STREQUAL "SOURCEPATH")
set(_state "sourcepath")
- elseif (${arg} STREQUAL "CLASSPATH")
+ elseif (arg STREQUAL "CLASSPATH")
set(_state "classpath")
- elseif (${arg} STREQUAL "INSTALLPATH")
+ elseif (arg STREQUAL "INSTALLPATH")
set(_state "installpath")
- elseif (${arg} STREQUAL "DOCTITLE")
+ elseif (arg STREQUAL "DOCTITLE")
set(_state "doctitle")
- elseif (${arg} STREQUAL "WINDOWTITLE")
+ elseif (arg STREQUAL "WINDOWTITLE")
set(_state "windowtitle")
- elseif (${arg} STREQUAL "AUTHOR")
+ elseif (arg STREQUAL "AUTHOR")
set(_state "author")
- elseif (${arg} STREQUAL "USE")
+ elseif (arg STREQUAL "USE")
set(_state "use")
- elseif (${arg} STREQUAL "VERSION")
+ elseif (arg STREQUAL "VERSION")
set(_state "version")
else ()
set(_javadoc_version ${arg})
@@ -1186,7 +1191,7 @@ function(create_javadoc _target)
if (_javadoc_sourcepath)
set(_start TRUE)
- foreach(_path ${_javadoc_sourcepath})
+ foreach(_path IN LISTS _javadoc_sourcepath)
if (_start)
set(_sourcepath ${_path})
set(_start FALSE)
@@ -1199,7 +1204,7 @@ function(create_javadoc _target)
if (_javadoc_classpath)
set(_start TRUE)
- foreach(_path ${_javadoc_classpath})
+ foreach(_path IN LISTS _javadoc_classpath)
if (_start)
set(_classpath ${_path})
set(_start FALSE)
@@ -1244,6 +1249,12 @@ function(create_javadoc _target)
endfunction()
function (create_javah)
+ if (Java_VERSION VERSION_GREATER_EQUAL 10)
+ message (FATAL_ERROR "create_javah: not supported with this Java version. Use add_jar(GENERATE_NATIVE_HEADERS) instead.")
+ elseif (Java_VERSION VERSION_GREATER_EQUAL 1.8)
+ message (DEPRECATION "create_javah: this command will no longer be supported starting with version 10 of JDK. Update your project by using command add_jar(GENERATE_NATIVE_HEADERS) instead.")
+ endif()
+
cmake_parse_arguments(_create_javah
""
"TARGET;GENERATED_FILES;OUTPUT_NAME;OUTPUT_DIR"
@@ -1360,7 +1371,7 @@ function(export_jars)
# Set content of generated exports file
string(REPLACE ";" " " __targets__ "${_export_jars_TARGETS}")
set(__targetdefs__ "")
- foreach(_target ${_export_jars_TARGETS})
+ foreach(_target IN LISTS _export_jars_TARGETS)
get_target_property(_jarpath ${_target} JAR_FILE)
get_filename_component(_jarpath ${_jarpath} PATH)
__java_export_jar(__targetdefs__ ${_target} "${_jarpath}")
@@ -1398,7 +1409,7 @@ function(install_jar_exports)
endif()
# Determine relative path from installed export file to install prefix
- if(IS_ABSOLUTE ${_install_jar_exports_DESTINATION})
+ if(IS_ABSOLUTE "${_install_jar_exports_DESTINATION}")
file(RELATIVE_PATH _relpath
${_install_jar_exports_DESTINATION}
${CMAKE_INSTALL_PREFIX}
@@ -1417,7 +1428,7 @@ function(install_jar_exports)
# Set content of generated exports file
string(REPLACE ";" " " __targets__ "${_install_jar_exports_TARGETS}")
set(__targetdefs__ "set(_prefix \${CMAKE_CURRENT_LIST_DIR}/${_relpath})\n\n")
- foreach(_target ${_install_jar_exports_TARGETS})
+ foreach(_target IN LISTS _install_jar_exports_TARGETS)
get_target_property(_dir ${_target} INSTALL_DESTINATION)
__java_export_jar(__targetdefs__ ${_target} "\${_prefix}/${_dir}")
endforeach()
diff --git a/Modules/UseJavaClassFilelist.cmake b/Modules/UseJavaClassFilelist.cmake
index c2f9afa4f..1c4baa9d4 100644
--- a/Modules/UseJavaClassFilelist.cmake
+++ b/Modules/UseJavaClassFilelist.cmake
@@ -1,17 +1,18 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# UseJavaClassFilelist
-# --------------------
-#
-#
-#
-#
-#
-# This script create a list of compiled Java class files to be added to
-# a jar file. This avoids including cmake files which get created in
-# the binary directory.
+#[=======================================================================[.rst:
+UseJavaClassFilelist
+--------------------
+
+
+
+
+
+This script create a list of compiled Java class files to be added to
+a jar file. This avoids including cmake files which get created in
+the binary directory.
+#]=======================================================================]
if (CMAKE_JAVA_CLASS_OUTPUT_PATH)
if (EXISTS "${CMAKE_JAVA_CLASS_OUTPUT_PATH}")
diff --git a/Modules/UseJavaSymlinks.cmake b/Modules/UseJavaSymlinks.cmake
index 358b9ef5c..3969f54fa 100644
--- a/Modules/UseJavaSymlinks.cmake
+++ b/Modules/UseJavaSymlinks.cmake
@@ -1,15 +1,16 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# UseJavaSymlinks
-# ---------------
-#
-#
-#
-#
-#
-# Helper script for UseJava.cmake
+#[=======================================================================[.rst:
+UseJavaSymlinks
+---------------
+
+
+
+
+
+Helper script for UseJava.cmake
+#]=======================================================================]
if (UNIX AND _JAVA_TARGET_OUTPUT_LINK)
if (_JAVA_TARGET_OUTPUT_NAME)
diff --git a/Modules/UsePkgConfig.cmake b/Modules/UsePkgConfig.cmake
index 28618eb10..32d228dab 100644
--- a/Modules/UsePkgConfig.cmake
+++ b/Modules/UsePkgConfig.cmake
@@ -1,24 +1,25 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# UsePkgConfig
-# ------------
-#
-# Obsolete pkg-config module for CMake, use FindPkgConfig instead.
-#
-#
-#
-# This module defines the following macro:
-#
-# PKGCONFIG(package includedir libdir linkflags cflags)
-#
-# Calling PKGCONFIG will fill the desired information into the 4 given
-# arguments, e.g. PKGCONFIG(libart-2.0 LIBART_INCLUDE_DIR
-# LIBART_LINK_DIR LIBART_LINK_FLAGS LIBART_CFLAGS) if pkg-config was NOT
-# found or the specified software package doesn't exist, the variable
-# will be empty when the function returns, otherwise they will contain
-# the respective information
+#[=======================================================================[.rst:
+UsePkgConfig
+------------
+
+Obsolete pkg-config module for CMake, use FindPkgConfig instead.
+
+
+
+This module defines the following macro:
+
+PKGCONFIG(package includedir libdir linkflags cflags)
+
+Calling PKGCONFIG will fill the desired information into the 4 given
+arguments, e.g. PKGCONFIG(libart-2.0 LIBART_INCLUDE_DIR
+LIBART_LINK_DIR LIBART_LINK_FLAGS LIBART_CFLAGS) if pkg-config was NOT
+found or the specified software package doesn't exist, the variable
+will be empty when the function returns, otherwise they will contain
+the respective information
+#]=======================================================================]
find_program(PKGCONFIG_EXECUTABLE NAMES pkg-config )
diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake
index c8eab7766..8fec717c0 100644
--- a/Modules/UseQt4.cmake
+++ b/Modules/UseQt4.cmake
@@ -1,15 +1,16 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# UseQt4
-# ------
-#
-# Use Module for QT4
-#
-# Sets up C and C++ to use Qt 4. It is assumed that FindQt.cmake has
-# already been loaded. See FindQt.cmake for information on how to load
-# Qt 4 into your CMake project.
+#[=======================================================================[.rst:
+UseQt4
+------
+
+Use Module for QT4
+
+Sets up C and C++ to use Qt 4. It is assumed that :module:`FindQt` has
+already been loaded. See :module:`FindQt` for information on how to load
+Qt 4 into your CMake project.
+#]=======================================================================]
add_definitions(${QT_DEFINITIONS})
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)
@@ -104,4 +105,3 @@ foreach(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN
endif ()
endforeach()
-
diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index fc815ddf8..78522da6d 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -1,91 +1,299 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# UseSWIG
-# -------
-#
-# Defines the following macros for use with SWIG:
-#
-# ::
-#
-# SWIG_ADD_LIBRARY(<name>
-# [TYPE <SHARED|MODULE|STATIC|USE_BUILD_SHARED_LIBS>]
-# LANGUAGE <language>
-# SOURCES <file>...
-# )
-# - Define swig module with given name and specified language
-# SWIG_LINK_LIBRARIES(name [ libraries ])
-# - Link libraries to swig module
-#
-# Source files properties on module files can be set before the invocation
-# of the SWIG_ADD_LIBRARY macro to specify special behavior of SWIG.
-#
-# The source file property CPLUSPLUS calls SWIG in c++ mode, e.g.::
-#
-# set_property(SOURCE mymod.i PROPERTY CPLUSPLUS ON)
-# swig_add_library(mymod LANGUAGE python SOURCES mymod.i)
-#
-# The source file property SWIG_FLAGS adds custom flags to the SWIG executable.
-#
-# The source-file property SWIG_MODULE_NAME have to be provided to specify the actual
-# import name of the module in the target language if it cannot be scanned automatically
-# from source or different from the module file basename.::
-#
-# set_property(SOURCE mymod.i PROPERTY SWIG_MODULE_NAME mymod_realname)
-#
-# To get the name of the swig module target library, use: ${SWIG_MODULE_${name}_REAL_NAME}.
-#
-# Also some variables can be set to specify special behavior of SWIG.
-#
-# CMAKE_SWIG_FLAGS can be used to add special flags to all swig calls.
-#
-# CMAKE_SWIG_OUTDIR allows one to specify where to write
-# the language specific files (swig -outdir option).
-#
-# SWIG_OUTFILE_DIR allows one to specify where to write the output file
-# (swig -o option). If not specified, CMAKE_SWIG_OUTDIR is used.
-#
-# The name-specific variable SWIG_MODULE_<name>_EXTRA_DEPS may be used to specify extra
-# dependencies for the generated modules.
-#
-# If the source file generated by swig need some special flag you can use::
-#
-# set_source_files_properties( ${swig_generated_file_fullname}
-# PROPERTIES COMPILE_FLAGS "-bla")
+#[=======================================================================[.rst:
+UseSWIG
+-------
+
+This file provides support for ``SWIG``. It is assumed that :module:`FindSWIG`
+module has already been loaded.
+
+Defines the following command for use with ``SWIG``:
+
+.. command:: swig_add_library
+
+ Define swig module with given name and specified language::
+
+ swig_add_library(<name>
+ [TYPE <SHARED|MODULE|STATIC|USE_BUILD_SHARED_LIBS>]
+ LANGUAGE <language>
+ [NO_PROXY]
+ [OUTPUT_DIR <directory>]
+ [OUTFILE_DIR <directory>]
+ SOURCES <file>...
+ )
+
+ Targets created with the ``swig_add_library`` command have the same
+ capabilities as targets created with the :command:`add_library` command, so
+ those targets can be used with any command expecting a target (e.g.
+ :command:`target_link_libraries`).
+
+ .. note::
+
+ This command creates a target with the specified ``<name>`` when
+ policy :policy:`CMP0078` is set to ``NEW``. Otherwise, the legacy
+ behavior will choose a different target name and store it in the
+ ``SWIG_MODULE_<name>_REAL_NAME`` variable.
+
+ .. note::
+
+ For multi-config generators, this module does not support
+ configuration-specific files generated by ``SWIG``. All build
+ configurations must result in the same generated source file.
+
+ ``TYPE``
+ ``SHARED``, ``MODULE`` and ``STATIC`` have the same semantic as for the
+ :command:`add_library` command. If ``USE_BUILD_SHARED_LIBS`` is specified,
+ the library type will be ``STATIC`` or ``SHARED`` based on whether the
+ current value of the :variable:`BUILD_SHARED_LIBS` variable is ``ON``. If
+ no type is specified, ``MODULE`` will be used.
+
+ ``LANGUAGE``
+ Specify the target language.
+
+ ``NO_PROXY``
+ Prevent the generation of the wrapper layer (swig ``-noproxy`` option).
+
+ ``OUTPUT_DIR``
+ Specify where to write the language specific files (swig ``-outdir``
+ option). If not given, the ``CMAKE_SWIG_OUTDIR`` variable will be used.
+ If neither is specified, the default depends on the value of the
+ ``UseSWIG_MODULE_VERSION`` variable as follows:
+
+ * If ``UseSWIG_MODULE_VERSION`` is 1 or is undefined, output is written to
+ the :variable:`CMAKE_CURRENT_BINARY_DIR` directory.
+ * If ``UseSWIG_MODULE_VERSION`` is 2, a dedicated directory will be used.
+ The path of this directory can be retrieved from the
+ ``SWIG_SUPPORT_FILES_DIRECTORY`` target property.
+
+ ``OUTFILE_DIR``
+ Specify an output directory name where the generated source file will be
+ placed (swig -o option). If not specified, the ``SWIG_OUTFILE_DIR`` variable
+ will be used. If neither is specified, ``OUTPUT_DIR`` or
+ ``CMAKE_SWIG_OUTDIR`` is used instead.
+
+ ``SOURCES``
+ List of sources for the library. Files with extension ``.i`` will be
+ identified as sources for the ``SWIG`` tool. Other files will be handled in
+ the standard way. This behavior can be overriden by specifying the variable
+ ``SWIG_SOURCE_FILE_EXTENSIONS``.
+
+ .. note::
+
+ If ``UseSWIG_MODULE_VERSION`` is set to 2, it is **strongly** recommended
+ to use a dedicated directory unique to the target when either the
+ ``OUTPUT_DIR`` option or the ``CMAKE_SWIG_OUTDIR`` variable are specified.
+ The output directory contents are erased as part of the target build, so
+ to prevent interference between targets or losing other important files,
+ each target should have its own dedicated output directory.
+
+.. command:: swig_link_libraries
+
+ Link libraries to swig module::
+
+ swig_link_libraries(<name> <item>...)
+
+ This command has same capabilities as :command:`target_link_libraries`
+ command.
+
+ .. note::
+
+ If variable ``UseSWIG_TARGET_NAME_PREFERENCE`` is set to ``STANDARD``, this
+ command is deprecated and :command:`target_link_libraries` command must be
+ used instead.
+
+Source file properties on module files **must** be set before the invocation
+of the ``swig_add_library`` command to specify special behavior of SWIG and
+ensure generated files will receive the required settings.
+
+``CPLUSPLUS``
+ Call SWIG in c++ mode. For example:
+
+ .. code-block:: cmake
+
+ set_property(SOURCE mymod.i PROPERTY CPLUSPLUS ON)
+ swig_add_library(mymod LANGUAGE python SOURCES mymod.i)
+
+``INCLUDE_DIRECTORIES``, ``COMPILE_DEFINITIONS`` and ``COMPILE_OPTIONS``
+ Add custom flags to SWIG compiler and have same semantic as properties
+ :prop_sf:`INCLUDE_DIRECTORIES`, :prop_sf:`COMPILE_DEFINITIONS` and
+ :prop_sf:`COMPILE_OPTIONS`.
+
+``USE_TARGET_INCLUDE_DIRECTORIES``
+ If set to ``TRUE``, contents of target property
+ :prop_tgt:`INCLUDE_DIRECTORIES` will be forwarded to ``SWIG`` compiler.
+ If set to ``FALSE`` target property :prop_tgt:`INCLUDE_DIRECTORIES` will be
+ ignored. If not set, target property ``SWIG_USE_TARGET_INCLUDE_DIRECTORIES``
+ will be considered.
+
+``GENERATED_INCLUDE_DIRECTORIES``, ``GENERATED_COMPILE_DEFINITIONS`` and ``GENERATED_COMPILE_OPTIONS``
+ Add custom flags to the C/C++ generated source. They will fill, respectively,
+ properties :prop_sf:`INCLUDE_DIRECTORIES`, :prop_sf:`COMPILE_DEFINITIONS` and
+ :prop_sf:`COMPILE_OPTIONS` of generated C/C++ file.
+
+``DEPENDS``
+ Specify additional dependencies to the source file.
+
+``SWIG_MODULE_NAME``
+ Specify the actual import name of the module in the target language.
+ This is required if it cannot be scanned automatically from source
+ or different from the module file basename. For example:
+
+ .. code-block:: cmake
+
+ set_property(SOURCE mymod.i PROPERTY SWIG_MODULE_NAME mymod_realname)
+
+ .. note::
+
+ If policy :policy:`CMP0086` is set to ``NEW``, ``-module <module_name>``
+ is passed to ``SWIG`` compiler.
+
+Target library properties can be set to apply same configuration to all SWIG
+input files.
+
+``SWIG_INCLUDE_DIRECTORIES``, ``SWIG_COMPILE_DEFINITIONS`` and ``SWIG_COMPILE_OPTIONS``
+ These properties will be applied to all SWIG input files and have same
+ semantic as target properties :prop_tgt:`INCLUDE_DIRECTORIES`,
+ :prop_tgt:`COMPILE_DEFINITIONS` and :prop_tgt:`COMPILE_OPTIONS`.
+
+ .. code-block:: cmake
+
+ set (UseSWIG_TARGET_NAME_PREFERENCE STANDARD)
+ swig_add_library(mymod LANGUAGE python SOURCES mymod.i)
+ set_property(TARGET mymod PROPERTY SWIG_COMPILE_DEFINITIONS MY_DEF1 MY_DEF2)
+ set_property(TARGET mymod PROPERTY SWIG_COMPILE_OPTIONS -bla -blb)
+
+``SWIG_USE_TARGET_INCLUDE_DIRECTORIES``
+ If set to ``TRUE``, contents of target property
+ :prop_tgt:`INCLUDE_DIRECTORIES` will be forwarded to ``SWIG`` compiler.
+ If set to ``FALSE`` or not defined, target property
+ :prop_tgt:`INCLUDE_DIRECTORIES` will be ignored. This behavior can be
+ overridden by specifying source property ``USE_TARGET_INCLUDE_DIRECTORIES``.
+
+``SWIG_GENERATED_INCLUDE_DIRECTORIES``, ``SWIG_GENERATED_COMPILE_DEFINITIONS`` and ``SWIG_GENERATED_COMPILE_OPTIONS``
+ These properties will populate, respectively, properties
+ :prop_sf:`INCLUDE_DIRECTORIES`, :prop_sf:`COMPILE_DEFINITIONS` and
+ :prop_sf:`COMPILE_FLAGS` of all generated C/C++ files.
+
+``SWIG_DEPENDS``
+ Add dependencies to all SWIG input files.
+
+The following target properties are output properties and can be used to get
+information about support files generated by ``SWIG`` interface compilation.
+
+``SWIG_SUPPORT_FILES``
+ This output property list of wrapper files generated during SWIG compilation.
+
+ .. code-block:: cmake
+
+ set (UseSWIG_TARGET_NAME_PREFERENCE STANDARD)
+ swig_add_library(mymod LANGUAGE python SOURCES mymod.i)
+ get_property(support_files TARGET mymod PROPERTY SWIG_SUPPORT_FILES)
+
+ .. note::
+
+ Only most principal support files are listed. In case some advanced
+ features of ``SWIG`` are used (for example ``%template``), associated
+ support files may not be listed. Prefer to use the
+ ``SWIG_SUPPORT_FILES_DIRECTORY`` property to handle support files.
+
+``SWIG_SUPPORT_FILES_DIRECTORY``
+ This output property specifies the directory where support files will be
+ generated.
+
+Some variables can be set to customize the behavior of ``swig_add_library``
+as well as ``SWIG``:
+
+``UseSWIG_MODULE_VERSION``
+ Specify different behaviors for ``UseSWIG`` module.
+
+ * Set to 1 or undefined: Legacy behavior is applied.
+ * Set to 2: A new strategy is applied regarding support files: the output
+ directory of support files is erased before ``SWIG`` interface compilation.
+
+``CMAKE_SWIG_FLAGS``
+ Add flags to all swig calls.
+
+``CMAKE_SWIG_OUTDIR``
+ Specify where to write the language specific files (swig ``-outdir`` option).
+
+``SWIG_OUTFILE_DIR``
+ Specify an output directory name where the generated source file will be
+ placed. If not specified, ``CMAKE_SWIG_OUTDIR`` is used.
+
+``SWIG_MODULE_<name>_EXTRA_DEPS``
+ Specify extra dependencies for the generated module for ``<name>``.
+
+``SWIG_SOURCE_FILE_EXTENSIONS``
+ Specify a list of source file extensions to override the default
+ behavior of considering only ``.i`` files as sources for the ``SWIG``
+ tool. For example:
+
+ .. code-block:: cmake
+
+ set(SWIG_SOURCE_FILE_EXTENSIONS ".i" ".swg")
+#]=======================================================================]
+
+cmake_policy(GET CMP0078 target_name_policy)
+cmake_policy(GET CMP0086 module_name_policy)
+
+cmake_policy (VERSION 3.12)
+if (target_name_policy)
+ # respect user choice regarding CMP0078 policy
+ cmake_policy(SET CMP0078 ${target_name_policy})
+endif()
+if (module_name_policy)
+ # respect user choice regarding CMP0086 policy
+ cmake_policy(SET CMP0086 ${module_name_policy})
+endif()
+unset(target_name_policy)
+unset(module_name_policy)
set(SWIG_CXX_EXTENSION "cxx")
set(SWIG_EXTRA_LIBRARIES "")
set(SWIG_PYTHON_EXTRA_FILE_EXTENSIONS ".py")
set(SWIG_JAVA_EXTRA_FILE_EXTENSIONS ".java" "JNI.java")
+set(SWIG_CSHARP_EXTRA_FILE_EXTENSIONS ".cs" "PINVOKE.cs")
+
+set(SWIG_MANAGE_SUPPORT_FILES_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/UseSWIG/ManageSupportFiles.cmake")
+
+##
+## PRIVATE functions
+##
+function (__SWIG_COMPUTE_TIMESTAMP name language infile workingdir __timestamp)
+ get_filename_component(filename "${infile}" NAME_WE)
+ set(${__timestamp}
+ "${workingdir}/${filename}${language}.stamp" PARENT_SCOPE)
+ # get_filename_component(filename "${infile}" ABSOLUTE)
+ # string(UUID uuid NAMESPACE 9735D882-D2F8-4E1D-88C9-A0A4F1F6ECA4
+ # NAME ${name}-${language}-${filename} TYPE SHA1)
+ # set(${__timestamp} "${workingdir}/${uuid}.stamp" PARENT_SCOPE)
+endfunction()
#
# For given swig module initialize variables associated with it
#
macro(SWIG_MODULE_INITIALIZE name language)
- string(TOUPPER "${language}" swig_uppercase_language)
- string(TOLOWER "${language}" swig_lowercase_language)
- set(SWIG_MODULE_${name}_LANGUAGE "${swig_uppercase_language}")
- set(SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG "${swig_lowercase_language}")
+ string(TOUPPER "${language}" SWIG_MODULE_${name}_LANGUAGE)
+ string(TOLOWER "${language}" SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG)
- set(SWIG_MODULE_${name}_REAL_NAME "${name}")
- if (";${CMAKE_SWIG_FLAGS};" MATCHES ";-noproxy;")
+ if (NOT DEFINED SWIG_MODULE_${name}_NOPROXY)
+ set (SWIG_MODULE_${name}_NOPROXY FALSE)
+ endif()
+ if ("-noproxy" IN_LIST CMAKE_SWIG_FLAGS)
set (SWIG_MODULE_${name}_NOPROXY TRUE)
endif ()
- if("x${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "xUNKNOWN")
+
+ if (SWIG_MODULE_${name}_NOPROXY AND
+ NOT ("-noproxy" IN_LIST CMAKE_SWIG_FLAGS OR "-noproxy" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS))
+ list (APPEND SWIG_MODULE_${name}_EXTRA_FLAGS "-noproxy")
+ endif()
+ if(SWIG_MODULE_${name}_LANGUAGE STREQUAL "UNKNOWN")
message(FATAL_ERROR "SWIG Error: Language \"${language}\" not found")
- elseif("x${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "xPYTHON" AND NOT SWIG_MODULE_${name}_NOPROXY)
- # swig will produce a module.py containing an 'import _modulename' statement,
- # which implies having a corresponding _modulename.so (*NIX), _modulename.pyd (Win32),
- # unless the -noproxy flag is used
- set(SWIG_MODULE_${name}_REAL_NAME "_${name}")
- elseif("x${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "xPERL")
- set(SWIG_MODULE_${name}_EXTRA_FLAGS "-shadow")
- elseif("x${SWIG_MODULE_${name}_LANGUAGE}" STREQUAL "xCSHARP")
- # This makes sure that the name used in the generated DllImport
- # matches the library name created by CMake
- set(SWIG_MODULE_${name}_EXTRA_FLAGS "-dllimport;${name}")
+ elseif(SWIG_MODULE_${name}_LANGUAGE STREQUAL "PERL" AND
+ NOT "-shadow" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS)
+ list(APPEND SWIG_MODULE_${name}_EXTRA_FLAGS "-shadow")
endif()
endmacro()
@@ -94,79 +302,126 @@ endmacro()
# will be generated. This is internal swig macro.
#
-macro(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile)
- set(${outfiles} "")
- get_source_file_property(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename
- ${infile} SWIG_MODULE_NAME)
- if(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND")
+function(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile)
+ set(files)
+ get_source_file_property(module_basename
+ "${infile}" SWIG_MODULE_NAME)
+ if(NOT module_basename)
# try to get module name from "%module foo" syntax
- if ( EXISTS ${infile} )
- file ( STRINGS ${infile} _MODULE_NAME REGEX "[ ]*%module[ ]*[a-zA-Z0-9_]+.*" )
+ if ( EXISTS "${infile}" )
+ file ( STRINGS "${infile}" module_basename REGEX "[ ]*%module[ ]*[a-zA-Z0-9_]+.*" )
endif ()
- if ( _MODULE_NAME )
- string ( REGEX REPLACE "[ ]*%module[ ]*([a-zA-Z0-9_]+).*" "\\1" _MODULE_NAME "${_MODULE_NAME}" )
- set(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${_MODULE_NAME}")
+ if ( module_basename )
+ string ( REGEX REPLACE "[ ]*%module[ ]*([a-zA-Z0-9_]+).*" "\\1" module_basename "${module_basename}" )
else ()
# try to get module name from "%module (options=...) foo" syntax
- if ( EXISTS ${infile} )
- file ( STRINGS ${infile} _MODULE_NAME REGEX "[ ]*%module[ ]*\\(.*\\)[ ]*[a-zA-Z0-9_]+.*" )
+ if ( EXISTS "${infile}" )
+ file ( STRINGS "${infile}" module_basename REGEX "[ ]*%module[ ]*\\(.*\\)[ ]*[a-zA-Z0-9_]+.*" )
endif ()
- if ( _MODULE_NAME )
- string ( REGEX REPLACE "[ ]*%module[ ]*\\(.*\\)[ ]*([a-zA-Z0-9_]+).*" "\\1" _MODULE_NAME "${_MODULE_NAME}" )
- set(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${_MODULE_NAME}")
+ if ( module_basename )
+ string ( REGEX REPLACE "[ ]*%module[ ]*\\(.*\\)[ ]*([a-zA-Z0-9_]+).*" "\\1" module_basename "${module_basename}" )
else ()
# fallback to file basename
- get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename ${infile} NAME_WE)
+ get_filename_component(module_basename "${infile}" NAME_WE)
endif ()
endif ()
endif()
foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSIONS})
- set(extra_file "${generatedpath}/${SWIG_GET_EXTRA_OUTPUT_FILES_module_basename}${it}")
- list(APPEND ${outfiles} ${extra_file})
- # Treat extra outputs as plain files regardless of language.
- set_property(SOURCE "${extra_file}" PROPERTY LANGUAGE "")
+ set(extra_file "${generatedpath}/${module_basename}${it}")
+ if (extra_file MATCHES "\\.cs$" AND CMAKE_CSharp_COMPILER_LOADED)
+ set_source_files_properties(${extra_file} PROPERTIES LANGUAGE "CSharp")
+ else()
+ # Treat extra outputs as plain files regardless of language.
+ set_source_files_properties(${extra_file} PROPERTIES LANGUAGE "")
+ endif()
+ list(APPEND files "${extra_file}")
endforeach()
-endmacro()
+
+ set (${outfiles} ${files} PARENT_SCOPE)
+endfunction()
#
# Take swig (*.i) file and add proper custom commands for it
#
-macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
- set(swig_full_infile ${infile})
+function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
get_filename_component(swig_source_file_name_we "${infile}" NAME_WE)
- get_source_file_property(swig_source_file_generated ${infile} GENERATED)
- get_source_file_property(swig_source_file_cplusplus ${infile} CPLUSPLUS)
- get_source_file_property(swig_source_file_flags ${infile} SWIG_FLAGS)
- if("${swig_source_file_flags}" STREQUAL "NOTFOUND")
- set(swig_source_file_flags "")
- endif()
- get_filename_component(swig_source_file_fullname "${infile}" ABSOLUTE)
+ get_source_file_property(swig_source_file_cplusplus "${infile}" CPLUSPLUS)
# If CMAKE_SWIG_OUTDIR was specified then pass it to -outdir
if(CMAKE_SWIG_OUTDIR)
- set(swig_outdir ${CMAKE_SWIG_OUTDIR})
+ set(outdir ${CMAKE_SWIG_OUTDIR})
else()
- set(swig_outdir ${CMAKE_CURRENT_BINARY_DIR})
+ set(outdir ${CMAKE_CURRENT_BINARY_DIR})
endif()
if(SWIG_OUTFILE_DIR)
- set(swig_outfile_dir ${SWIG_OUTFILE_DIR})
+ set(outfiledir ${SWIG_OUTFILE_DIR})
else()
- set(swig_outfile_dir ${swig_outdir})
+ set(outfiledir ${outdir})
endif()
+ if(SWIG_WORKING_DIR)
+ set (workingdir "${SWIG_WORKING_DIR}")
+ else()
+ set(workingdir "${outdir}")
+ endif()
+
+ if(SWIG_TARGET_NAME)
+ set(target_name ${SWIG_TARGET_NAME})
+ else()
+ set(target_name ${name})
+ endif()
+
+ set (swig_source_file_flags ${CMAKE_SWIG_FLAGS})
+ # handle various swig compile flags properties
+ get_source_file_property (include_directories "${infile}" INCLUDE_DIRECTORIES)
+ if (include_directories)
+ list (APPEND swig_source_file_flags "$<$<BOOL:${include_directories}>:-I$<JOIN:${include_directories},$<SEMICOLON>-I>>")
+ endif()
+ set (property "$<TARGET_PROPERTY:${target_name},SWIG_INCLUDE_DIRECTORIES>")
+ list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-I$<JOIN:$<TARGET_GENEX_EVAL:${target_name},${property}>,$<SEMICOLON>-I>>")
+ set (property "$<TARGET_PROPERTY:${target_name},INCLUDE_DIRECTORIES>")
+ get_source_file_property(use_target_include_dirs "${infile}" USE_TARGET_INCLUDE_DIRECTORIES)
+ if (use_target_include_dirs)
+ list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-I$<JOIN:${property},$<SEMICOLON>-I>>")
+ elseif(use_target_include_dirs STREQUAL "NOTFOUND")
+ # not defined at source level, rely on target level
+ list (APPEND swig_source_file_flags "$<$<AND:$<BOOL:$<TARGET_PROPERTY:${target_name},SWIG_USE_TARGET_INCLUDE_DIRECTORIES>>,$<BOOL:${property}>>:-I$<JOIN:${property},$<SEMICOLON>-I>>")
+ endif()
+
+ set (property "$<TARGET_PROPERTY:${target_name},SWIG_COMPILE_DEFINITIONS>")
+ list (APPEND swig_source_file_flags "$<$<BOOL:${property}>:-D$<JOIN:$<TARGET_GENEX_EVAL:${target_name},${property}>,$<SEMICOLON>-D>>")
+ get_source_file_property (compile_definitions "${infile}" COMPILE_DEFINITIONS)
+ if (compile_definitions)
+ list (APPEND swig_source_file_flags "$<$<BOOL:${compile_definitions}>:-D$<JOIN:${compile_definitions},$<SEMICOLON>-D>>")
+ endif()
+
+ list (APPEND swig_source_file_flags "$<TARGET_GENEX_EVAL:${target_name},$<TARGET_PROPERTY:${target_name},SWIG_COMPILE_OPTIONS>>")
+ get_source_file_property (compile_options "${infile}" COMPILE_OPTIONS)
+ if (compile_options)
+ list (APPEND swig_source_file_flags ${compile_options})
+ endif()
+
+ # legacy support
+ get_source_file_property (swig_flags "${infile}" SWIG_FLAGS)
+ if (swig_flags)
+ list (APPEND swig_source_file_flags ${swig_flags})
+ endif()
+
+ get_filename_component(swig_source_file_fullname "${infile}" ABSOLUTE)
+
if (NOT SWIG_MODULE_${name}_NOPROXY)
SWIG_GET_EXTRA_OUTPUT_FILES(${SWIG_MODULE_${name}_LANGUAGE}
swig_extra_generated_files
- "${swig_outdir}"
+ "${outdir}"
"${swig_source_file_fullname}")
endif()
set(swig_generated_file_fullname
- "${swig_outfile_dir}/${swig_source_file_name_we}")
+ "${outfiledir}/${swig_source_file_name_we}")
# add the language into the name of the file (i.e. TCL_wrap)
# this allows for the same .i file to be wrapped into different languages
string(APPEND swig_generated_file_fullname
@@ -180,46 +435,129 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
".c")
endif()
- #message("Full path to source file: ${swig_source_file_fullname}")
- #message("Full path to the output file: ${swig_generated_file_fullname}")
- get_directory_property(cmake_include_directories INCLUDE_DIRECTORIES)
- list(REMOVE_DUPLICATES cmake_include_directories)
- set(swig_include_dirs)
- foreach(it ${cmake_include_directories})
- set(swig_include_dirs ${swig_include_dirs} "-I${it}")
- endforeach()
+ get_directory_property (cmake_include_directories INCLUDE_DIRECTORIES)
+ list (REMOVE_DUPLICATES cmake_include_directories)
+ set (swig_include_dirs)
+ if (cmake_include_directories)
+ set (swig_include_dirs "$<$<BOOL:${cmake_include_directories}>:-I$<JOIN:${cmake_include_directories},$<SEMICOLON>-I>>")
+ endif()
set(swig_special_flags)
# default is c, so add c++ flag if it is c++
if(swig_source_file_cplusplus)
- set(swig_special_flags ${swig_special_flags} "-c++")
+ list (APPEND swig_special_flags "-c++")
+ endif()
+
+ cmake_policy(GET CMP0086 module_name_policy)
+ if (module_name_policy STREQUAL "NEW")
+ get_source_file_property(module_name "${infile}" SWIG_MODULE_NAME)
+ if (module_name)
+ list (APPEND swig_special_flags "-module" "${module_name}")
+ endif()
+ else()
+ if (NOT module_name_policy)
+ cmake_policy(GET_WARNING CMP0086 _cmp0086_warning)
+ message(AUTHOR_WARNING "${_cmp0086_warning}\n")
+ endif()
+ endif()
+
+ set (swig_extra_flags)
+ if(SWIG_MODULE_${name}_LANGUAGE STREQUAL "CSHARP")
+ if(NOT ("-dllimport" IN_LIST swig_source_file_flags OR "-dllimport" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS))
+ # This makes sure that the name used in the generated DllImport
+ # matches the library name created by CMake
+ list (APPEND SWIG_MODULE_${name}_EXTRA_FLAGS "-dllimport" "$<TARGET_FILE_PREFIX:${target_name}>$<TARGET_FILE_BASE_NAME:${target_name}>")
+ endif()
+ endif()
+ if (SWIG_MODULE_${name}_LANGUAGE STREQUAL "PYTHON" AND NOT SWIG_MODULE_${name}_NOPROXY)
+ if(NOT ("-interface" IN_LIST swig_source_file_flags OR "-interface" IN_LIST SWIG_MODULE_${name}_EXTRA_FLAGS))
+ # This makes sure that the name used in the proxy code
+ # matches the library name created by CMake
+ list (APPEND SWIG_MODULE_${name}_EXTRA_FLAGS "-interface" "$<TARGET_FILE_PREFIX:${target_name}>$<TARGET_FILE_BASE_NAME:${target_name}>")
+ endif()
+ endif()
+ list (APPEND swig_extra_flags ${SWIG_MODULE_${name}_EXTRA_FLAGS})
+
+ # dependencies
+ set (swig_dependencies ${SWIG_MODULE_${name}_EXTRA_DEPS} $<TARGET_PROPERTY:${target_name},SWIG_DEPENDS>)
+ get_source_file_property(file_depends "${infile}" DEPENDS)
+ if (file_depends)
+ list (APPEND swig_dependencies ${file_depends})
endif()
- set(swig_extra_flags)
- if(SWIG_MODULE_${name}_EXTRA_FLAGS)
- set(swig_extra_flags ${swig_extra_flags} ${SWIG_MODULE_${name}_EXTRA_FLAGS})
+
+ if (UseSWIG_MODULE_VERSION VERSION_GREATER 1)
+ # as part of custom command, start by removing old generated files
+ # to ensure obsolete files do not stay
+ set (swig_file_outdir "${workingdir}/${swig_source_file_name_we}.files")
+ set (swig_cleanup_command COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_WORKING_DIRECTORY=${swig_file_outdir}" "-DSUPPORT_FILES_OUTPUT_DIRECTORY=${outdir}" -DACTION=CLEAN -P "${SWIG_MANAGE_SUPPORT_FILES_SCRIPT}")
+ set (swig_copy_command COMMAND "${CMAKE_COMMAND}" "-DSUPPORT_FILES_WORKING_DIRECTORY=${swig_file_outdir}" "-DSUPPORT_FILES_OUTPUT_DIRECTORY=${outdir}" -DACTION=COPY -P "${SWIG_MANAGE_SUPPORT_FILES_SCRIPT}")
+ else()
+ set (swig_file_outdir "${outdir}")
+ unset (swig_cleanup_command)
+ unset (swig_copy_command)
+ endif()
+
+ # IMPLICIT_DEPENDS below can not handle situations where a dependent file is
+ # removed. We need an extra step with timestamp and custom target, see #16830
+ # As this is needed only for Makefile generator do it conditionally
+ if(CMAKE_GENERATOR MATCHES "Make")
+ __swig_compute_timestamp(${name} ${SWIG_MODULE_${name}_LANGUAGE}
+ "${infile}" "${workingdir}" swig_generated_timestamp)
+ set(swig_custom_output "${swig_generated_timestamp}")
+ set(swig_custom_products
+ BYPRODUCTS "${swig_generated_file_fullname}" ${swig_extra_generated_files})
+ set(swig_timestamp_command
+ COMMAND ${CMAKE_COMMAND} -E touch "${swig_generated_timestamp}")
+ else()
+ set(swig_custom_output
+ "${swig_generated_file_fullname}" ${swig_extra_generated_files})
+ set(swig_custom_products)
+ set(swig_timestamp_command)
endif()
add_custom_command(
- OUTPUT "${swig_generated_file_fullname}" ${swig_extra_generated_files}
- # Let's create the ${swig_outdir} at execution time, in case dir contains $(OutDir)
- COMMAND ${CMAKE_COMMAND} -E make_directory ${swig_outdir}
- COMMAND "${SWIG_EXECUTABLE}"
- ARGS "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}"
- ${swig_source_file_flags}
- ${CMAKE_SWIG_FLAGS}
- -outdir ${swig_outdir}
+ OUTPUT ${swig_custom_output}
+ ${swig_custom_products}
+ ${swig_cleanup_command}
+ # Let's create the ${outdir} at execution time, in case dir contains $(OutDir)
+ COMMAND "${CMAKE_COMMAND}" -E make_directory ${outdir} ${outfiledir}
+ ${swig_timestamp_command}
+ COMMAND "${CMAKE_COMMAND}" -E env "SWIG_LIB=${SWIG_DIR}" "${SWIG_EXECUTABLE}"
+ "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}"
+ "${swig_source_file_flags}"
+ -outdir "${swig_file_outdir}"
${swig_special_flags}
${swig_extra_flags}
- ${swig_include_dirs}
+ "${swig_include_dirs}"
-o "${swig_generated_file_fullname}"
"${swig_source_file_fullname}"
+ ${swig_copy_command}
MAIN_DEPENDENCY "${swig_source_file_fullname}"
- DEPENDS ${SWIG_MODULE_${name}_EXTRA_DEPS}
+ DEPENDS ${swig_dependencies}
IMPLICIT_DEPENDS CXX "${swig_source_file_fullname}"
- COMMENT "Swig source")
+ COMMENT "Swig compile ${infile} for ${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}"
+ COMMAND_EXPAND_LISTS)
set_source_files_properties("${swig_generated_file_fullname}" ${swig_extra_generated_files}
PROPERTIES GENERATED 1)
- set(${outfiles} "${swig_generated_file_fullname}" ${swig_extra_generated_files})
-endmacro()
+
+ ## add all properties for generated file to various properties
+ get_property (include_directories SOURCE "${infile}" PROPERTY GENERATED_INCLUDE_DIRECTORIES)
+ set_property (SOURCE "${swig_generated_file_fullname}" PROPERTY INCLUDE_DIRECTORIES ${include_directories} $<TARGET_GENEX_EVAL:${target_name},$<TARGET_PROPERTY:${target_name},SWIG_GENERATED_INCLUDE_DIRECTORIES>>)
+
+ get_property (compile_definitions SOURCE "${infile}" PROPERTY GENERATED_COMPILE_DEFINITIONS)
+ set_property (SOURCE "${swig_generated_file_fullname}" PROPERTY COMPILE_DEFINITIONS $<TARGET_GENEX_EVAL:${target_name},$<TARGET_PROPERTY:${target_name},SWIG_GENERATED_COMPILE_DEFINITIONS>> ${compile_definitions})
+
+ get_property (compile_options SOURCE "${infile}" PROPERTY GENERATED_COMPILE_OPTIONS)
+ set_property (SOURCE "${swig_generated_file_fullname}" PROPERTY COMPILE_OPTIONS $<TARGET_GENEX_EVAL:${target_name},$<TARGET_PROPERTY:${target_name},SWIG_GENERATED_COMPILE_OPTIONS>> ${compile_options})
+
+ if (SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG MATCHES "php")
+ set_property (SOURCE "${swig_generated_file_fullname}" APPEND PROPERTY INCLUDE_DIRECTORIES "${outdir}")
+ endif()
+
+ set(${outfiles} "${swig_generated_file_fullname}" ${swig_extra_generated_files} PARENT_SCOPE)
+
+ # legacy support
+ set (swig_generated_file_fullname "${swig_generated_file_fullname}" PARENT_SCOPE)
+endfunction()
#
# Create Swig module
@@ -233,13 +571,19 @@ macro(SWIG_ADD_MODULE name language)
endmacro()
-macro(SWIG_ADD_LIBRARY name)
- set(options "")
+function(SWIG_ADD_LIBRARY name)
+ set(options NO_PROXY)
set(oneValueArgs LANGUAGE
- TYPE)
+ TYPE
+ OUTPUT_DIR
+ OUTFILE_DIR)
set(multiValueArgs SOURCES)
cmake_parse_arguments(_SAM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+ if (_SAM_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "SWIG_ADD_LIBRARY: ${_SAM_UNPARSED_ARGUMENTS}: unexpected arguments")
+ endif()
+
if(NOT DEFINED _SAM_LANGUAGE)
message(FATAL_ERROR "SWIG_ADD_LIBRARY: Missing LANGUAGE argument")
endif()
@@ -250,60 +594,169 @@ macro(SWIG_ADD_LIBRARY name)
if(NOT DEFINED _SAM_TYPE)
set(_SAM_TYPE MODULE)
- elseif("${_SAM_TYPE}" STREQUAL "USE_BUILD_SHARED_LIBS")
+ elseif(_SAM_TYPE STREQUAL "USE_BUILD_SHARED_LIBS")
unset(_SAM_TYPE)
endif()
+ cmake_policy(GET CMP0078 target_name_policy)
+ if (target_name_policy STREQUAL "NEW")
+ set (UseSWIG_TARGET_NAME_PREFERENCE STANDARD)
+ else()
+ if (NOT target_name_policy)
+ cmake_policy(GET_WARNING CMP0078 _cmp0078_warning)
+ message(AUTHOR_WARNING "${_cmp0078_warning}\n")
+ endif()
+ if (NOT DEFINED UseSWIG_TARGET_NAME_PREFERENCE)
+ set (UseSWIG_TARGET_NAME_PREFERENCE LEGACY)
+ elseif (NOT UseSWIG_TARGET_NAME_PREFERENCE MATCHES "^(LEGACY|STANDARD)$")
+ message (FATAL_ERROR "UseSWIG_TARGET_NAME_PREFERENCE: ${UseSWIG_TARGET_NAME_PREFERENCE}: invalid value. 'LEGACY' or 'STANDARD' is expected.")
+ endif()
+ endif()
+
+ if (NOT DEFINED UseSWIG_MODULE_VERSION)
+ set (UseSWIG_MODULE_VERSION 1)
+ elseif (NOT UseSWIG_MODULE_VERSION MATCHES "^(1|2)$")
+ message (FATAL_ERROR "UseSWIG_MODULE_VERSION: ${UseSWIG_MODULE_VERSION}: invalid value. 1 or 2 is expected.")
+ endif()
+
+ set (SWIG_MODULE_${name}_NOPROXY ${_SAM_NO_PROXY})
swig_module_initialize(${name} ${_SAM_LANGUAGE})
- set(swig_dot_i_sources)
- set(swig_other_sources)
- foreach(it ${_SAM_SOURCES})
- if(${it} MATCHES "\\.i$")
- set(swig_dot_i_sources ${swig_dot_i_sources} "${it}")
+ # compute real target name.
+ if (UseSWIG_TARGET_NAME_PREFERENCE STREQUAL "LEGACY" AND
+ SWIG_MODULE_${name}_LANGUAGE STREQUAL "PYTHON" AND NOT SWIG_MODULE_${name}_NOPROXY)
+ # swig will produce a module.py containing an 'import _modulename' statement,
+ # which implies having a corresponding _modulename.so (*NIX), _modulename.pyd (Win32),
+ # unless the -noproxy flag is used
+ set(target_name "_${name}")
+ else()
+ set(target_name "${name}")
+ endif()
+
+ if (TARGET ${target_name})
+ # a target with same name is already defined.
+ # call NOW add_library command to raise the most useful error message
+ add_library(${target_name})
+ return()
+ endif()
+
+ set (workingdir "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${target_name}.dir")
+ # set special variable to pass extra information to command SWIG_ADD_SOURCE_TO_MODULE
+ # which cannot be changed due to legacy compatibility
+ set (SWIG_WORKING_DIR "${workingdir}")
+ set (SWIG_TARGET_NAME "${target_name}")
+
+ set (outputdir "${_SAM_OUTPUT_DIR}")
+ if (NOT _SAM_OUTPUT_DIR)
+ if (CMAKE_SWIG_OUTDIR)
+ set (outputdir "${CMAKE_SWIG_OUTDIR}")
else()
- set(swig_other_sources ${swig_other_sources} "${it}")
+ if (UseSWIG_MODULE_VERSION VERSION_GREATER 1)
+ set (outputdir "${workingdir}/${_SAM_LANGUAGE}.files")
+ else()
+ set (outputdir "${CMAKE_CURRENT_BINARY_DIR}")
+ endif()
endif()
- endforeach()
+ endif()
+
+ set (outfiledir "${_SAM_OUTFILE_DIR}")
+ if(NOT _SAM_OUTFILE_DIR)
+ if (SWIG_OUTFILE_DIR)
+ set (outfiledir "${SWIG_OUTFILE_DIR}")
+ else()
+ if (_SAM_OUTPUT_DIR OR CMAKE_SWIG_OUTDIR)
+ set (outfiledir "${outputdir}")
+ else()
+ set (outfiledir "${workingdir}")
+ endif()
+ endif()
+ endif()
+ # set again, locally, predefined variables to ensure compatibility
+ # with command SWIG_ADD_SOURCE_TO_MODULE
+ set(CMAKE_SWIG_OUTDIR "${outputdir}")
+ set(SWIG_OUTFILE_DIR "${outfiledir}")
+
+ # See if the user has specified source extensions for swig files?
+ if (NOT DEFINED SWIG_SOURCE_FILE_EXTENSIONS)
+ # Assume the default (*.i) file extension for Swig source files
+ set(SWIG_SOURCE_FILE_EXTENSIONS ".i")
+ endif()
+
+ # Generate a regex out of file extensions.
+ string(REGEX REPLACE "([$^.*+?|()-])" "\\\\\\1" swig_source_ext_regex "${SWIG_SOURCE_FILE_EXTENSIONS}")
+ list (JOIN swig_source_ext_regex "|" swig_source_ext_regex)
+ string (PREPEND swig_source_ext_regex "(")
+ string (APPEND swig_source_ext_regex ")$")
+
+ set(swig_dot_i_sources ${_SAM_SOURCES})
+ list(FILTER swig_dot_i_sources INCLUDE REGEX ${swig_source_ext_regex})
+ if (NOT swig_dot_i_sources)
+ message(FATAL_ERROR "SWIG_ADD_LIBRARY: no SWIG interface files specified")
+ endif()
+ set(swig_other_sources ${_SAM_SOURCES})
+ list(REMOVE_ITEM swig_other_sources ${swig_dot_i_sources})
set(swig_generated_sources)
- foreach(it ${swig_dot_i_sources})
- SWIG_ADD_SOURCE_TO_MODULE(${name} swig_generated_source ${it})
- set(swig_generated_sources ${swig_generated_sources} "${swig_generated_source}")
+ set(swig_generated_timestamps)
+ foreach(swig_it IN LISTS swig_dot_i_sources)
+ SWIG_ADD_SOURCE_TO_MODULE(${name} swig_generated_source "${swig_it}")
+ list (APPEND swig_generated_sources "${swig_generated_source}")
+ if(CMAKE_GENERATOR MATCHES "Make")
+ __swig_compute_timestamp(${name} ${SWIG_MODULE_${name}_LANGUAGE} "${swig_it}"
+ "${workingdir}" swig_timestamp)
+ list (APPEND swig_generated_timestamps "${swig_timestamp}")
+ endif()
endforeach()
- get_directory_property(swig_extra_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
- set_directory_properties(PROPERTIES
- ADDITIONAL_MAKE_CLEAN_FILES "${swig_extra_clean_files};${swig_generated_sources}")
- add_library(${SWIG_MODULE_${name}_REAL_NAME}
+ set_property (DIRECTORY APPEND PROPERTY
+ ADDITIONAL_CLEAN_FILES ${swig_generated_sources} ${swig_generated_timestamps})
+ if (UseSWIG_MODULE_VERSION VERSION_GREATER 1)
+ set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${outputdir}")
+ endif()
+
+ add_library(${target_name}
${_SAM_TYPE}
${swig_generated_sources}
${swig_other_sources})
- if("${_SAM_TYPE}" STREQUAL "MODULE")
- set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES NO_SONAME ON)
+ if(CMAKE_GENERATOR MATCHES "Make")
+ # see IMPLICIT_DEPENDS above
+ add_custom_target(${name}_swig_compilation DEPENDS ${swig_generated_timestamps})
+ add_dependencies(${target_name} ${name}_swig_compilation)
+ endif()
+ if(_SAM_TYPE STREQUAL "MODULE")
+ set_target_properties(${target_name} PROPERTIES NO_SONAME ON)
endif()
string(TOLOWER "${_SAM_LANGUAGE}" swig_lowercase_language)
- if ("${swig_lowercase_language}" STREQUAL "octave")
- set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "")
- set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".oct")
- elseif ("${swig_lowercase_language}" STREQUAL "go")
- set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "")
- elseif ("${swig_lowercase_language}" STREQUAL "java")
+ if (swig_lowercase_language STREQUAL "octave")
+ set_target_properties(${target_name} PROPERTIES PREFIX "")
+ set_target_properties(${target_name} PROPERTIES SUFFIX ".oct")
+ elseif (swig_lowercase_language STREQUAL "go")
+ set_target_properties(${target_name} PROPERTIES PREFIX "")
+ elseif (swig_lowercase_language STREQUAL "java")
+ # In java you want:
+ # System.loadLibrary("LIBRARY");
+ # then JNI will look for a library whose name is platform dependent, namely
+ # MacOS : libLIBRARY.jnilib
+ # Windows: LIBRARY.dll
+ # Linux : libLIBRARY.so
if (APPLE)
- # In java you want:
- # System.loadLibrary("LIBRARY");
- # then JNI will look for a library whose name is platform dependent, namely
- # MacOS : libLIBRARY.jnilib
- # Windows: LIBRARY.dll
- # Linux : libLIBRARY.so
- set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".jnilib")
- endif ()
- elseif ("${swig_lowercase_language}" STREQUAL "lua")
- if("${_SAM_TYPE}" STREQUAL "MODULE")
- set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "")
+ set_target_properties (${target_name} PROPERTIES SUFFIX ".jnilib")
+ endif()
+ if ((WIN32 AND MINGW) OR CYGWIN OR CMAKE_SYSTEM_NAME STREQUAL MSYS)
+ set_target_properties(${target_name} PROPERTIES PREFIX "")
+ endif()
+ elseif (swig_lowercase_language STREQUAL "lua")
+ if(_SAM_TYPE STREQUAL "MODULE")
+ set_target_properties(${target_name} PROPERTIES PREFIX "")
+ endif()
+ elseif (swig_lowercase_language STREQUAL "python")
+ if (UseSWIG_TARGET_NAME_PREFERENCE STREQUAL "STANDARD" AND NOT SWIG_MODULE_${name}_NOPROXY)
+ # swig will produce a module.py containing an 'import _modulename' statement,
+ # which implies having a corresponding _modulename.so (*NIX), _modulename.pyd (Win32),
+ # unless the -noproxy flag is used
+ set_target_properties(${target_name} PROPERTIES PREFIX "_")
+ else()
+ set_target_properties(${target_name} PROPERTIES PREFIX "")
endif()
- elseif ("${swig_lowercase_language}" STREQUAL "python")
- # this is only needed for the python case where a _modulename.so is generated
- set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "")
# Python extension modules on Windows must have the extension ".pyd"
# instead of ".dll" as of Python 2.5. Older python versions do support
# this suffix.
@@ -313,34 +766,72 @@ macro(SWIG_ADD_LIBRARY name)
# .pyd is now the only filename extension that will be searched for.
# </quote>
if(WIN32 AND NOT CYGWIN)
- set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".pyd")
+ set_target_properties(${target_name} PROPERTIES SUFFIX ".pyd")
endif()
- elseif ("${swig_lowercase_language}" STREQUAL "r")
- set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "")
- elseif ("${swig_lowercase_language}" STREQUAL "ruby")
+ elseif (swig_lowercase_language STREQUAL "r")
+ set_target_properties(${target_name} PROPERTIES PREFIX "")
+ elseif (swig_lowercase_language STREQUAL "ruby")
# In ruby you want:
# require 'LIBRARY'
# then ruby will look for a library whose name is platform dependent, namely
# MacOS : LIBRARY.bundle
# Windows: LIBRARY.dll
# Linux : LIBRARY.so
- set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "")
+ set_target_properties (${target_name} PROPERTIES PREFIX "")
if (APPLE)
- set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".bundle")
+ set_target_properties (${target_name} PROPERTIES SUFFIX ".bundle")
+ endif ()
+ elseif (swig_lowercase_language STREQUAL "perl")
+ # assume empty prefix because we expect the module to be dynamically loaded
+ set_target_properties (${target_name} PROPERTIES PREFIX "")
+ if (APPLE)
+ set_target_properties (${target_name} PROPERTIES SUFFIX ".dylib")
endif ()
else()
# assume empty prefix because we expect the module to be dynamically loaded
- set_target_properties (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "")
+ set_target_properties (${target_name} PROPERTIES PREFIX "")
endif ()
-endmacro()
+
+ # target property SWIG_SUPPORT_FILES_DIRECTORY specify output directory of support files
+ set_property (TARGET ${target_name} PROPERTY SWIG_SUPPORT_FILES_DIRECTORY "${outputdir}")
+ # target property SWIG_SUPPORT_FILES lists principal proxy support files
+ if (NOT SWIG_MODULE_${name}_NOPROXY)
+ string(TOUPPER "${_SAM_LANGUAGE}" swig_uppercase_language)
+ set(swig_all_support_files)
+ foreach (swig_it IN LISTS SWIG_${swig_uppercase_language}_EXTRA_FILE_EXTENSIONS)
+ set (swig_support_files ${swig_generated_sources})
+ list (FILTER swig_support_files INCLUDE REGEX ".*${swig_it}$")
+ list(APPEND swig_all_support_files ${swig_support_files})
+ endforeach()
+ if (swig_all_support_files)
+ list(REMOVE_DUPLICATES swig_all_support_files)
+ endif()
+ set_property (TARGET ${target_name} PROPERTY SWIG_SUPPORT_FILES ${swig_all_support_files})
+ endif()
+
+ # to ensure legacy behavior, export some variables
+ set (SWIG_MODULE_${name}_LANGUAGE "${SWIG_MODULE_${name}_LANGUAGE}" PARENT_SCOPE)
+ set (SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG "${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" PARENT_SCOPE)
+ set (SWIG_MODULE_${name}_REAL_NAME "${target_name}" PARENT_SCOPE)
+ set (SWIG_MODULE_${name}_NOPROXY "${SWIG_MODULE_${name}_NOPROXY}" PARENT_SCOPE)
+ set (SWIG_MODULE_${name}_EXTRA_FLAGS "${SWIG_MODULE_${name}_EXTRA_FLAGS}" PARENT_SCOPE)
+ # the last one is a bit crazy but it is documented, so...
+ # NOTA: works as expected if only ONE input file is specified
+ set (swig_generated_file_fullname "${swig_generated_file_fullname}" PARENT_SCOPE)
+endfunction()
#
# Like TARGET_LINK_LIBRARIES but for swig modules
#
-macro(SWIG_LINK_LIBRARIES name)
- if(SWIG_MODULE_${name}_REAL_NAME)
- target_link_libraries(${SWIG_MODULE_${name}_REAL_NAME} ${ARGN})
+function(SWIG_LINK_LIBRARIES name)
+ if (UseSWIG_TARGET_NAME_PREFERENCE STREQUAL "STANDARD")
+ message(DEPRECATION "SWIG_LINK_LIBRARIES is deprecated. Use TARGET_LINK_LIBRARIES instead.")
+ target_link_libraries(${name} ${ARGN})
else()
- message(SEND_ERROR "Cannot find Swig library \"${name}\".")
+ if(SWIG_MODULE_${name}_REAL_NAME)
+ target_link_libraries(${SWIG_MODULE_${name}_REAL_NAME} ${ARGN})
+ else()
+ message(SEND_ERROR "Cannot find Swig library \"${name}\".")
+ endif()
endif()
-endmacro()
+endfunction()
diff --git a/Modules/UseSWIG/ManageSupportFiles.cmake b/Modules/UseSWIG/ManageSupportFiles.cmake
new file mode 100644
index 000000000..4a03900b7
--- /dev/null
+++ b/Modules/UseSWIG/ManageSupportFiles.cmake
@@ -0,0 +1,31 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+
+if (ACTION STREQUAL "CLEAN")
+ # Collect current list of generated files
+ file (GLOB files LIST_DIRECTORIES FALSE RELATIVE "${SUPPORT_FILES_WORKING_DIRECTORY}" "${SUPPORT_FILES_WORKING_DIRECTORY}/*")
+
+ if (files)
+ # clean-up the output directory
+ ## compute full paths
+ list (TRANSFORM files PREPEND "${SUPPORT_FILES_OUTPUT_DIRECTORY}/")
+ ## remove generated files from the output directory
+ file (REMOVE ${files})
+
+ # clean-up working directory
+ file (REMOVE_RECURSE "${SUPPORT_FILES_WORKING_DIRECTORY}")
+ endif()
+
+ file (MAKE_DIRECTORY "${SUPPORT_FILES_WORKING_DIRECTORY}")
+endif()
+
+if (ACTION STREQUAL "COPY")
+ # Collect current list of generated files
+ file (GLOB files LIST_DIRECTORIES FALSE "${SUPPORT_FILES_WORKING_DIRECTORY}/*")
+
+ if (files)
+ # copy files to the output directory
+ file (COPY ${files} DESTINATION "${SUPPORT_FILES_OUTPUT_DIRECTORY}")
+ endif()
+endif()
diff --git a/Modules/Use_wxWindows.cmake b/Modules/Use_wxWindows.cmake
index bd8cc01c1..782874c10 100644
--- a/Modules/Use_wxWindows.cmake
+++ b/Modules/Use_wxWindows.cmake
@@ -1,35 +1,37 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# Use_wxWindows
-# -------------
-#
-#
-#
-#
-# This convenience include finds if wxWindows is installed and set the
-# appropriate libs, incdirs, flags etc. author Jan Woetzel <jw -at-
-# mip.informatik.uni-kiel.de> (07/2003)
-#
-# USAGE:
-#
-# ::
-#
-# just include Use_wxWindows.cmake
-# in your projects CMakeLists.txt
-#
-# include( ${CMAKE_MODULE_PATH}/Use_wxWindows.cmake)
-#
-# ::
-#
-# if you are sure you need GL then
-#
-# set(WXWINDOWS_USE_GL 1)
-#
-# ::
-#
-# *before* you include this file.
+#[=======================================================================[.rst:
+Use_wxWindows
+-------------
+
+.. deprecated:: 2.8.10
+
+ Use ``find_package(wxWidgets)`` and ``include(${wxWidgets_USE_FILE})`` instead.
+
+This convenience include finds if wxWindows is installed and set the
+appropriate libs, incdirs, flags etc. author Jan Woetzel <jw -at-
+mip.informatik.uni-kiel.de> (07/2003)
+
+USAGE:
+
+::
+
+ just include Use_wxWindows.cmake
+ in your projects CMakeLists.txt
+
+include( ${CMAKE_MODULE_PATH}/Use_wxWindows.cmake)
+
+::
+
+ if you are sure you need GL then
+
+set(WXWINDOWS_USE_GL 1)
+
+::
+
+ *before* you include this file.
+#]=======================================================================]
# -----------------------------------------------------
# 16.Feb.2004: changed INCLUDE to FIND_PACKAGE to read from users own non-system CMAKE_MODULE_PATH (Jan Woetzel JW)
@@ -65,4 +67,3 @@ if(WXWINDOWS_FOUND)
else()
message(SEND_ERROR "wxWindows not found by Use_wxWindows.cmake")
endif()
-
diff --git a/Modules/UsewxWidgets.cmake b/Modules/UsewxWidgets.cmake
index a50d03d53..eed041021 100644
--- a/Modules/UsewxWidgets.cmake
+++ b/Modules/UsewxWidgets.cmake
@@ -1,41 +1,42 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# UsewxWidgets
-# ------------
-#
-# Convenience include for using wxWidgets library.
-#
-# Determines if wxWidgets was FOUND and sets the appropriate libs,
-# incdirs, flags, etc. INCLUDE_DIRECTORIES and LINK_DIRECTORIES are
-# called.
-#
-# USAGE
-#
-# ::
-#
-# # Note that for MinGW users the order of libs is important!
-# find_package(wxWidgets REQUIRED net gl core base)
-# include(${wxWidgets_USE_FILE})
-# # and for each of your dependent executable/library targets:
-# target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
-#
-#
-#
-# DEPRECATED
-#
-# ::
-#
-# LINK_LIBRARIES is not called in favor of adding dependencies per target.
-#
-#
-#
-# AUTHOR
-#
-# ::
-#
-# Jan Woetzel <jw -at- mip.informatik.uni-kiel.de>
+#[=======================================================================[.rst:
+UsewxWidgets
+------------
+
+Convenience include for using wxWidgets library.
+
+Determines if wxWidgets was FOUND and sets the appropriate libs,
+incdirs, flags, etc. INCLUDE_DIRECTORIES and LINK_DIRECTORIES are
+called.
+
+USAGE
+
+::
+
+ # Note that for MinGW users the order of libs is important!
+ find_package(wxWidgets REQUIRED net gl core base)
+ include(${wxWidgets_USE_FILE})
+ # and for each of your dependent executable/library targets:
+ target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES})
+
+
+
+DEPRECATED
+
+::
+
+ LINK_LIBRARIES is not called in favor of adding dependencies per target.
+
+
+
+AUTHOR
+
+::
+
+ Jan Woetzel <jw -at- mip.informatik.uni-kiel.de>
+#]=======================================================================]
# debug message and logging.
# comment these out for distribution
diff --git a/Modules/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake
index 7c9467ab3..45f9e587a 100644
--- a/Modules/WriteBasicConfigVersionFile.cmake
+++ b/Modules/WriteBasicConfigVersionFile.cmake
@@ -1,26 +1,29 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# WriteBasicConfigVersionFile
-# ---------------------------
-#
-#
-#
-# ::
-#
-# WRITE_BASIC_CONFIG_VERSION_FILE( filename
-# [VERSION major.minor.patch]
-# COMPATIBILITY (AnyNewerVersion|SameMajorVersion)
-# )
-#
-#
-#
-# Deprecated, see WRITE_BASIC_PACKAGE_VERSION_FILE(), it is identical.
+#[=======================================================================[.rst:
+WriteBasicConfigVersionFile
+---------------------------
+
+.. deprecated:: 3.0
+
+ Use the identical command :command:`write_basic_package_version_file()`
+ from module :module:`CMakePackageConfigHelpers`.
+
+::
+
+ WRITE_BASIC_CONFIG_VERSION_FILE( filename
+ [VERSION major.minor.patch]
+ COMPATIBILITY (AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion)
+ [ARCH_INDEPENDENT]
+ )
+
+
+#]=======================================================================]
function(WRITE_BASIC_CONFIG_VERSION_FILE _filename)
- set(options )
+ set(options ARCH_INDEPENDENT )
set(oneValueArgs VERSION COMPATIBILITY )
set(multiValueArgs )
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
index e7f991249..23d81b5fc 100644
--- a/Modules/WriteCompilerDetectionHeader.cmake
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -1,227 +1,236 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#.rst:
-# WriteCompilerDetectionHeader
-# ----------------------------
-#
-# This module provides the function write_compiler_detection_header().
-#
-# The ``WRITE_COMPILER_DETECTION_HEADER`` function can be used to generate
-# a file suitable for preprocessor inclusion which contains macros to be
-# used in source code::
-#
-# write_compiler_detection_header(
-# FILE <file>
-# PREFIX <prefix>
-# [OUTPUT_FILES_VAR <output_files_var> OUTPUT_DIR <output_dir>]
-# COMPILERS <compiler> [...]
-# FEATURES <feature> [...]
-# [VERSION <version>]
-# [PROLOG <prolog>]
-# [EPILOG <epilog>]
-# [ALLOW_UNKNOWN_COMPILERS]
-# [ALLOW_UNKNOWN_COMPILER_VERSIONS]
-# )
-#
-# The ``write_compiler_detection_header`` function generates the
-# file ``<file>`` with macros which all have the prefix ``<prefix>``.
-#
-# By default, all content is written directly to the ``<file>``. The
-# ``OUTPUT_FILES_VAR`` may be specified to cause the compiler-specific
-# content to be written to separate files. The separate files are then
-# available in the ``<output_files_var>`` and may be consumed by the caller
-# for installation for example. The ``OUTPUT_DIR`` specifies a relative
-# path from the main ``<file>`` to the compiler-specific files. For example:
-#
-# .. code-block:: cmake
-#
-# write_compiler_detection_header(
-# FILE climbingstats_compiler_detection.h
-# PREFIX ClimbingStats
-# OUTPUT_FILES_VAR support_files
-# OUTPUT_DIR compilers
-# COMPILERS GNU Clang MSVC Intel
-# FEATURES cxx_variadic_templates
-# )
-# install(FILES
-# ${CMAKE_CURRENT_BINARY_DIR}/climbingstats_compiler_detection.h
-# DESTINATION include
-# )
-# install(FILES
-# ${support_files}
-# DESTINATION include/compilers
-# )
-#
-#
-# ``VERSION`` may be used to specify the API version to be generated.
-# Future versions of CMake may introduce alternative APIs. A given
-# API is selected by any ``<version>`` value greater than or equal
-# to the version of CMake that introduced the given API and less
-# than the version of CMake that introduced its succeeding API.
-# The value of the :variable:`CMAKE_MINIMUM_REQUIRED_VERSION`
-# variable is used if no explicit version is specified.
-# (As of CMake version |release| there is only one API version.)
-#
-# ``PROLOG`` may be specified as text content to write at the start of the
-# header. ``EPILOG`` may be specified as text content to write at the end
-# of the header
-#
-# At least one ``<compiler>`` and one ``<feature>`` must be listed. Compilers
-# which are known to CMake, but not specified are detected and a preprocessor
-# ``#error`` is generated for them. A preprocessor macro matching
-# ``<PREFIX>_COMPILER_IS_<compiler>`` is generated for each compiler
-# known to CMake to contain the value ``0`` or ``1``.
-#
-# Possible compiler identifiers are documented with the
-# :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
-# Available features in this version of CMake are listed in the
-# :prop_gbl:`CMAKE_C_KNOWN_FEATURES` and
-# :prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` global properties.
-# The ``{c,cxx}_std_*`` meta-features are ignored if requested.
-#
-# See the :manual:`cmake-compile-features(7)` manual for information on
-# compile features.
-#
-# ``ALLOW_UNKNOWN_COMPILERS`` and ``ALLOW_UNKNOWN_COMPILER_VERSIONS`` cause
-# the module to generate conditions that treat unknown compilers as simply
-# lacking all features. Without these options the default behavior is to
-# generate a ``#error`` for unknown compilers.
-#
-# Feature Test Macros
-# ===================
-#
-# For each compiler, a preprocessor macro is generated matching
-# ``<PREFIX>_COMPILER_IS_<compiler>`` which has the content either ``0``
-# or ``1``, depending on the compiler in use. Preprocessor macros for
-# compiler version components are generated matching
-# ``<PREFIX>_COMPILER_VERSION_MAJOR`` ``<PREFIX>_COMPILER_VERSION_MINOR``
-# and ``<PREFIX>_COMPILER_VERSION_PATCH`` containing decimal values
-# for the corresponding compiler version components, if defined.
-#
-# A preprocessor test is generated based on the compiler version
-# denoting whether each feature is enabled. A preprocessor macro
-# matching ``<PREFIX>_COMPILER_<FEATURE>``, where ``<FEATURE>`` is the
-# upper-case ``<feature>`` name, is generated to contain the value
-# ``0`` or ``1`` depending on whether the compiler in use supports the
-# feature:
-#
-# .. code-block:: cmake
-#
-# write_compiler_detection_header(
-# FILE climbingstats_compiler_detection.h
-# PREFIX ClimbingStats
-# COMPILERS GNU Clang AppleClang MSVC Intel
-# FEATURES cxx_variadic_templates
-# )
-#
-# .. code-block:: c++
-#
-# #if ClimbingStats_COMPILER_CXX_VARIADIC_TEMPLATES
-# template<typename... T>
-# void someInterface(T t...) { /* ... */ }
-# #else
-# // Compatibility versions
-# template<typename T1>
-# void someInterface(T1 t1) { /* ... */ }
-# template<typename T1, typename T2>
-# void someInterface(T1 t1, T2 t2) { /* ... */ }
-# template<typename T1, typename T2, typename T3>
-# void someInterface(T1 t1, T2 t2, T3 t3) { /* ... */ }
-# #endif
-#
-# Symbol Macros
-# =============
-#
-# Some additional symbol-defines are created for particular features for
-# use as symbols which may be conditionally defined empty:
-#
-# .. code-block:: c++
-#
-# class MyClass ClimbingStats_FINAL
-# {
-# ClimbingStats_CONSTEXPR int someInterface() { return 42; }
-# };
-#
-# The ``ClimbingStats_FINAL`` macro will expand to ``final`` if the
-# compiler (and its flags) support the ``cxx_final`` feature, and the
-# ``ClimbingStats_CONSTEXPR`` macro will expand to ``constexpr``
-# if ``cxx_constexpr`` is supported.
-#
-# The following features generate corresponding symbol defines:
-#
-# ========================== =================================== =================
-# Feature Define Symbol
-# ========================== =================================== =================
-# ``c_restrict`` ``<PREFIX>_RESTRICT`` ``restrict``
-# ``cxx_constexpr`` ``<PREFIX>_CONSTEXPR`` ``constexpr``
-# ``cxx_deleted_functions`` ``<PREFIX>_DELETED_FUNCTION`` ``= delete``
-# ``cxx_extern_templates`` ``<PREFIX>_EXTERN_TEMPLATE`` ``extern``
-# ``cxx_final`` ``<PREFIX>_FINAL`` ``final``
-# ``cxx_noexcept`` ``<PREFIX>_NOEXCEPT`` ``noexcept``
-# ``cxx_noexcept`` ``<PREFIX>_NOEXCEPT_EXPR(X)`` ``noexcept(X)``
-# ``cxx_override`` ``<PREFIX>_OVERRIDE`` ``override``
-# ========================== =================================== =================
-#
-# Compatibility Implementation Macros
-# ===================================
-#
-# Some features are suitable for wrapping in a macro with a backward
-# compatibility implementation if the compiler does not support the feature.
-#
-# When the ``cxx_static_assert`` feature is not provided by the compiler,
-# a compatibility implementation is available via the
-# ``<PREFIX>_STATIC_ASSERT(COND)`` and
-# ``<PREFIX>_STATIC_ASSERT_MSG(COND, MSG)`` function-like macros. The macros
-# expand to ``static_assert`` where that compiler feature is available, and
-# to a compatibility implementation otherwise. In the first form, the
-# condition is stringified in the message field of ``static_assert``. In
-# the second form, the message ``MSG`` is passed to the message field of
-# ``static_assert``, or ignored if using the backward compatibility
-# implementation.
-#
-# The ``cxx_attribute_deprecated`` feature provides a macro definition
-# ``<PREFIX>_DEPRECATED``, which expands to either the standard
-# ``[[deprecated]]`` attribute or a compiler-specific decorator such
-# as ``__attribute__((__deprecated__))`` used by GNU compilers.
-#
-# The ``cxx_alignas`` feature provides a macro definition
-# ``<PREFIX>_ALIGNAS`` which expands to either the standard ``alignas``
-# decorator or a compiler-specific decorator such as
-# ``__attribute__ ((__aligned__))`` used by GNU compilers.
-#
-# The ``cxx_alignof`` feature provides a macro definition
-# ``<PREFIX>_ALIGNOF`` which expands to either the standard ``alignof``
-# decorator or a compiler-specific decorator such as ``__alignof__``
-# used by GNU compilers.
-#
-# ============================= ================================ =====================
-# Feature Define Symbol
-# ============================= ================================ =====================
-# ``cxx_alignas`` ``<PREFIX>_ALIGNAS`` ``alignas``
-# ``cxx_alignof`` ``<PREFIX>_ALIGNOF`` ``alignof``
-# ``cxx_nullptr`` ``<PREFIX>_NULLPTR`` ``nullptr``
-# ``cxx_static_assert`` ``<PREFIX>_STATIC_ASSERT`` ``static_assert``
-# ``cxx_static_assert`` ``<PREFIX>_STATIC_ASSERT_MSG`` ``static_assert``
-# ``cxx_attribute_deprecated`` ``<PREFIX>_DEPRECATED`` ``[[deprecated]]``
-# ``cxx_attribute_deprecated`` ``<PREFIX>_DEPRECATED_MSG`` ``[[deprecated]]``
-# ``cxx_thread_local`` ``<PREFIX>_THREAD_LOCAL`` ``thread_local``
-# ============================= ================================ =====================
-#
-# A use-case which arises with such deprecation macros is the deprecation
-# of an entire library. In that case, all public API in the library may
-# be decorated with the ``<PREFIX>_DEPRECATED`` macro. This results in
-# very noisy build output when building the library itself, so the macro
-# may be may be defined to empty in that case when building the deprecated
-# library:
-#
-# .. code-block:: cmake
-#
-# add_library(compat_support ${srcs})
-# target_compile_definitions(compat_support
-# PRIVATE
-# CompatSupport_DEPRECATED=
-# )
+#[=======================================================================[.rst:
+WriteCompilerDetectionHeader
+----------------------------
+
+This module provides the function ``write_compiler_detection_header()``.
+
+This function can be used to generate a file suitable for preprocessor
+inclusion which contains macros to be used in source code::
+
+ write_compiler_detection_header(
+ FILE <file>
+ PREFIX <prefix>
+ [OUTPUT_FILES_VAR <output_files_var> OUTPUT_DIR <output_dir>]
+ COMPILERS <compiler> [...]
+ FEATURES <feature> [...]
+ [BARE_FEATURES <feature> [...]]
+ [VERSION <version>]
+ [PROLOG <prolog>]
+ [EPILOG <epilog>]
+ [ALLOW_UNKNOWN_COMPILERS]
+ [ALLOW_UNKNOWN_COMPILER_VERSIONS]
+ )
+
+This generates the file ``<file>`` with macros which all have the prefix
+``<prefix>``.
+
+By default, all content is written directly to the ``<file>``. The
+``OUTPUT_FILES_VAR`` may be specified to cause the compiler-specific
+content to be written to separate files. The separate files are then
+available in the ``<output_files_var>`` and may be consumed by the caller
+for installation for example. The ``OUTPUT_DIR`` specifies a relative
+path from the main ``<file>`` to the compiler-specific files. For example:
+
+.. code-block:: cmake
+
+ write_compiler_detection_header(
+ FILE climbingstats_compiler_detection.h
+ PREFIX ClimbingStats
+ OUTPUT_FILES_VAR support_files
+ OUTPUT_DIR compilers
+ COMPILERS GNU Clang MSVC Intel
+ FEATURES cxx_variadic_templates
+ )
+ install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/climbingstats_compiler_detection.h
+ DESTINATION include
+ )
+ install(FILES
+ ${support_files}
+ DESTINATION include/compilers
+ )
+
+
+``VERSION`` may be used to specify the API version to be generated.
+Future versions of CMake may introduce alternative APIs. A given
+API is selected by any ``<version>`` value greater than or equal
+to the version of CMake that introduced the given API and less
+than the version of CMake that introduced its succeeding API.
+The value of the :variable:`CMAKE_MINIMUM_REQUIRED_VERSION`
+variable is used if no explicit version is specified.
+(As of CMake version |release| there is only one API version.)
+
+``PROLOG`` may be specified as text content to write at the start of the
+header. ``EPILOG`` may be specified as text content to write at the end
+of the header
+
+At least one ``<compiler>`` and one ``<feature>`` must be listed. Compilers
+which are known to CMake, but not specified are detected and a preprocessor
+``#error`` is generated for them. A preprocessor macro matching
+``<PREFIX>_COMPILER_IS_<compiler>`` is generated for each compiler
+known to CMake to contain the value ``0`` or ``1``.
+
+Possible compiler identifiers are documented with the
+:variable:`CMAKE_<LANG>_COMPILER_ID` variable.
+Available features in this version of CMake are listed in the
+:prop_gbl:`CMAKE_C_KNOWN_FEATURES` and
+:prop_gbl:`CMAKE_CXX_KNOWN_FEATURES` global properties.
+The ``{c,cxx}_std_*`` meta-features are ignored if requested.
+
+See the :manual:`cmake-compile-features(7)` manual for information on
+compile features.
+
+``BARE_FEATURES`` will define the compatibility macros with the name used in
+newer versions of the language standard, so the code can use the new feature
+name unconditionally.
+
+``ALLOW_UNKNOWN_COMPILERS`` and ``ALLOW_UNKNOWN_COMPILER_VERSIONS`` cause
+the module to generate conditions that treat unknown compilers as simply
+lacking all features. Without these options the default behavior is to
+generate a ``#error`` for unknown compilers and versions.
+
+Feature Test Macros
+===================
+
+For each compiler, a preprocessor macro is generated matching
+``<PREFIX>_COMPILER_IS_<compiler>`` which has the content either ``0``
+or ``1``, depending on the compiler in use. Preprocessor macros for
+compiler version components are generated matching
+``<PREFIX>_COMPILER_VERSION_MAJOR`` ``<PREFIX>_COMPILER_VERSION_MINOR``
+and ``<PREFIX>_COMPILER_VERSION_PATCH`` containing decimal values
+for the corresponding compiler version components, if defined.
+
+A preprocessor test is generated based on the compiler version
+denoting whether each feature is enabled. A preprocessor macro
+matching ``<PREFIX>_COMPILER_<FEATURE>``, where ``<FEATURE>`` is the
+upper-case ``<feature>`` name, is generated to contain the value
+``0`` or ``1`` depending on whether the compiler in use supports the
+feature:
+
+.. code-block:: cmake
+
+ write_compiler_detection_header(
+ FILE climbingstats_compiler_detection.h
+ PREFIX ClimbingStats
+ COMPILERS GNU Clang AppleClang MSVC Intel
+ FEATURES cxx_variadic_templates
+ )
+
+.. code-block:: c++
+
+ #if ClimbingStats_COMPILER_CXX_VARIADIC_TEMPLATES
+ template<typename... T>
+ void someInterface(T t...) { /* ... */ }
+ #else
+ // Compatibility versions
+ template<typename T1>
+ void someInterface(T1 t1) { /* ... */ }
+ template<typename T1, typename T2>
+ void someInterface(T1 t1, T2 t2) { /* ... */ }
+ template<typename T1, typename T2, typename T3>
+ void someInterface(T1 t1, T2 t2, T3 t3) { /* ... */ }
+ #endif
+
+Symbol Macros
+=============
+
+Some additional symbol-defines are created for particular features for
+use as symbols which may be conditionally defined empty:
+
+.. code-block:: c++
+
+ class MyClass ClimbingStats_FINAL
+ {
+ ClimbingStats_CONSTEXPR int someInterface() { return 42; }
+ };
+
+The ``ClimbingStats_FINAL`` macro will expand to ``final`` if the
+compiler (and its flags) support the ``cxx_final`` feature, and the
+``ClimbingStats_CONSTEXPR`` macro will expand to ``constexpr``
+if ``cxx_constexpr`` is supported.
+
+If ``BARE_FEATURES cxx_final`` was given as argument the ``final`` keyword
+will be defined for old compilers, too.
+
+The following features generate corresponding symbol defines and if they
+are available as ``BARE_FEATURES``:
+
+========================== =================================== ================= ======
+ Feature Define Symbol bare
+========================== =================================== ================= ======
+``c_restrict`` ``<PREFIX>_RESTRICT`` ``restrict`` yes
+``cxx_constexpr`` ``<PREFIX>_CONSTEXPR`` ``constexpr`` yes
+``cxx_deleted_functions`` ``<PREFIX>_DELETED_FUNCTION`` ``= delete``
+``cxx_extern_templates`` ``<PREFIX>_EXTERN_TEMPLATE`` ``extern``
+``cxx_final`` ``<PREFIX>_FINAL`` ``final`` yes
+``cxx_noexcept`` ``<PREFIX>_NOEXCEPT`` ``noexcept`` yes
+``cxx_noexcept`` ``<PREFIX>_NOEXCEPT_EXPR(X)`` ``noexcept(X)``
+``cxx_override`` ``<PREFIX>_OVERRIDE`` ``override`` yes
+========================== =================================== ================= ======
+
+Compatibility Implementation Macros
+===================================
+
+Some features are suitable for wrapping in a macro with a backward
+compatibility implementation if the compiler does not support the feature.
+
+When the ``cxx_static_assert`` feature is not provided by the compiler,
+a compatibility implementation is available via the
+``<PREFIX>_STATIC_ASSERT(COND)`` and
+``<PREFIX>_STATIC_ASSERT_MSG(COND, MSG)`` function-like macros. The macros
+expand to ``static_assert`` where that compiler feature is available, and
+to a compatibility implementation otherwise. In the first form, the
+condition is stringified in the message field of ``static_assert``. In
+the second form, the message ``MSG`` is passed to the message field of
+``static_assert``, or ignored if using the backward compatibility
+implementation.
+
+The ``cxx_attribute_deprecated`` feature provides a macro definition
+``<PREFIX>_DEPRECATED``, which expands to either the standard
+``[[deprecated]]`` attribute or a compiler-specific decorator such
+as ``__attribute__((__deprecated__))`` used by GNU compilers.
+
+The ``cxx_alignas`` feature provides a macro definition
+``<PREFIX>_ALIGNAS`` which expands to either the standard ``alignas``
+decorator or a compiler-specific decorator such as
+``__attribute__ ((__aligned__))`` used by GNU compilers.
+
+The ``cxx_alignof`` feature provides a macro definition
+``<PREFIX>_ALIGNOF`` which expands to either the standard ``alignof``
+decorator or a compiler-specific decorator such as ``__alignof__``
+used by GNU compilers.
+
+============================= ================================ ===================== ======
+ Feature Define Symbol bare
+============================= ================================ ===================== ======
+``cxx_alignas`` ``<PREFIX>_ALIGNAS`` ``alignas``
+``cxx_alignof`` ``<PREFIX>_ALIGNOF`` ``alignof``
+``cxx_nullptr`` ``<PREFIX>_NULLPTR`` ``nullptr`` yes
+``cxx_static_assert`` ``<PREFIX>_STATIC_ASSERT`` ``static_assert``
+``cxx_static_assert`` ``<PREFIX>_STATIC_ASSERT_MSG`` ``static_assert``
+``cxx_attribute_deprecated`` ``<PREFIX>_DEPRECATED`` ``[[deprecated]]``
+``cxx_attribute_deprecated`` ``<PREFIX>_DEPRECATED_MSG`` ``[[deprecated]]``
+``cxx_thread_local`` ``<PREFIX>_THREAD_LOCAL`` ``thread_local``
+============================= ================================ ===================== ======
+
+A use-case which arises with such deprecation macros is the deprecation
+of an entire library. In that case, all public API in the library may
+be decorated with the ``<PREFIX>_DEPRECATED`` macro. This results in
+very noisy build output when building the library itself, so the macro
+may be may be defined to empty in that case when building the deprecated
+library:
+
+.. code-block:: cmake
+
+ add_library(compat_support ${srcs})
+ target_compile_definitions(compat_support
+ PRIVATE
+ CompatSupport_DEPRECATED=
+ )
+#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/CMakeCompilerIdDetection.cmake)
@@ -252,6 +261,37 @@ macro(_simpledefine FEATURE_NAME FEATURE_TESTNAME FEATURE_STRING FEATURE_DEFAULT
endif()
endmacro()
+macro(_simplebaredefine FEATURE_NAME FEATURE_STRING FEATURE_DEFAULT_STRING)
+ if (feature STREQUAL "${FEATURE_NAME}")
+ string(APPEND file_content "
+# if !(defined(${def_name}) && ${def_name})
+# define ${FEATURE_STRING} ${FEATURE_DEFAULT_STRING}
+# endif
+\n")
+ endif()
+endmacro()
+
+function(_check_feature_lists C_FEATURE_VAR CXX_FEATURE_VAR)
+ foreach(feature ${ARGN})
+ if (feature MATCHES "^c_std_")
+ # ignored
+ elseif (feature MATCHES "^cxx_std_")
+ # ignored
+ elseif (feature MATCHES "^cxx_")
+ list(APPEND _langs CXX)
+ list(APPEND ${CXX_FEATURE_VAR} ${feature})
+ elseif (feature MATCHES "^c_")
+ list(APPEND _langs C)
+ list(APPEND ${C_FEATURE_VAR} ${feature})
+ else()
+ message(FATAL_ERROR "Unsupported feature ${feature}.")
+ endif()
+ endforeach()
+ set(${C_FEATURE_VAR} ${${C_FEATURE_VAR}} PARENT_SCOPE)
+ set(${CXX_FEATURE_VAR} ${${CXX_FEATURE_VAR}} PARENT_SCOPE)
+ set(_langs ${_langs} PARENT_SCOPE)
+endfunction()
+
function(write_compiler_detection_header
file_keyword file_arg
prefix_keyword prefix_arg
@@ -264,13 +304,13 @@ function(write_compiler_detection_header
endif()
set(options ALLOW_UNKNOWN_COMPILERS ALLOW_UNKNOWN_COMPILER_VERSIONS)
set(oneValueArgs VERSION EPILOG PROLOG OUTPUT_FILES_VAR OUTPUT_DIR)
- set(multiValueArgs COMPILERS FEATURES)
+ set(multiValueArgs COMPILERS FEATURES BARE_FEATURES)
cmake_parse_arguments(_WCD "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT _WCD_COMPILERS)
message(FATAL_ERROR "Invalid arguments. write_compiler_detection_header requires at least one compiler.")
endif()
- if (NOT _WCD_FEATURES)
+ if (NOT _WCD_FEATURES AND NOT _WCD_BARE_FEATURES)
message(FATAL_ERROR "Invalid arguments. write_compiler_detection_header requires at least one feature.")
endif()
@@ -377,21 +417,8 @@ function(write_compiler_detection_header
)\n")
endif()
- foreach(feature ${_WCD_FEATURES})
- if (feature MATCHES "^c_std_")
- # ignored
- elseif (feature MATCHES "^cxx_std_")
- # ignored
- elseif (feature MATCHES "^cxx_")
- list(APPEND _langs CXX)
- list(APPEND CXX_features ${feature})
- elseif (feature MATCHES "^c_")
- list(APPEND _langs C)
- list(APPEND C_features ${feature})
- else()
- message(FATAL_ERROR "Unsupported feature ${feature}.")
- endif()
- endforeach()
+ _check_feature_lists(C_features CXX_features ${_WCD_FEATURES})
+ _check_feature_lists(C_bare_features CXX_bare_features ${_WCD_BARE_FEATURES})
list(REMOVE_DUPLICATES _langs)
if(_WCD_OUTPUT_FILES_VAR)
@@ -557,7 +584,18 @@ template<> struct ${prefix_arg}StaticAssert<true>{};
# endif
\n")
endif()
- _simpledefine(cxx_nullptr NULLPTR nullptr 0)
+ if (feature STREQUAL cxx_nullptr)
+ set(def_value "${prefix_arg}_NULLPTR")
+ string(APPEND file_content "
+# if defined(${def_name}) && ${def_name}
+# define ${def_value} nullptr
+# elif ${prefix_arg}_COMPILER_IS_GNU
+# define ${def_value} __null
+# else
+# define ${def_value} 0
+# endif
+\n")
+ endif()
if (feature STREQUAL cxx_thread_local)
set(def_value "${prefix_arg}_THREAD_LOCAL")
string(APPEND file_content "
@@ -595,6 +633,29 @@ template<> struct ${prefix_arg}StaticAssert<true>{};
endif()
endforeach()
+ foreach(feature ${${_lang}_bare_features})
+ string(TOUPPER ${feature} feature_upper)
+ set(feature_PP "COMPILER_${feature_upper}")
+ set(def_name ${prefix_arg}_${feature_PP})
+ _simplebaredefine(c_restrict restrict "")
+ _simplebaredefine(cxx_constexpr constexpr "")
+ _simplebaredefine(cxx_final final "")
+ _simplebaredefine(cxx_override override "")
+ if (feature STREQUAL cxx_nullptr)
+ set(def_value "nullptr")
+ string(APPEND file_content "
+# if !(defined(${def_name}) && ${def_name})
+# if ${prefix_arg}_COMPILER_IS_GNU
+# define ${def_value} __null
+# else
+# define ${def_value} 0
+# endif
+# endif
+\n")
+ endif()
+ _simplebaredefine(cxx_noexcept noexcept "")
+ endforeach()
+
string(APPEND file_content "#endif\n")
endforeach()
diff --git a/Modules/ecos_clean.cmake b/Modules/ecos_clean.cmake
index 21126f624..480b1ce83 100644
--- a/Modules/ecos_clean.cmake
+++ b/Modules/ecos_clean.cmake
@@ -7,10 +7,10 @@ file(GLOB _files ${ECOS_DIR}/*)
# remove all directories, which consist of lower-case letters only
# this skips e.g. CVS/ and .subversion/
foreach(_entry ${_files})
- if(IS_DIRECTORY ${_entry})
- get_filename_component(dir ${_entry} NAME)
- if(${dir} MATCHES "^[a-z]+$")
- file(REMOVE_RECURSE ${_entry})
- endif()
- endif()
+ if(IS_DIRECTORY ${_entry})
+ get_filename_component(dir ${_entry} NAME)
+ if(${dir} MATCHES "^[a-z]+$")
+ file(REMOVE_RECURSE ${_entry})
+ endif()
+ endif()
endforeach()
diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in
index 9dd75bf56..c518b3d7a 100644
--- a/Modules/exportheader.cmake.in
+++ b/Modules/exportheader.cmake.in
@@ -39,4 +39,4 @@
# endif
#endif
@CUSTOM_CONTENT@
-#endif
+#endif /* @INCLUDE_GUARD_NAME@ */
diff --git a/Modules/readme.txt b/Modules/readme.txt
index 1e0c13b6a..a62947806 100644
--- a/Modules/readme.txt
+++ b/Modules/readme.txt
@@ -1,4 +1,4 @@
See the "Find Modules" section of the cmake-developer(7) manual page.
For more information about how to contribute modules to CMake, see this page:
-https://cmake.org/Wiki/CMake:Module_Maintainers
+https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/dev/Module-Maintainers
diff --git a/README.rst b/README.rst
index d5acd4a7c..5020d39bd 100644
--- a/README.rst
+++ b/README.rst
@@ -6,10 +6,12 @@ Introduction
CMake is a cross-platform, open-source build system generator.
For full documentation visit the `CMake Home Page`_ and the
-`CMake Documentation Page`_.
+`CMake Documentation Page`_. The `CMake Community Wiki`_ also
+references useful guides and recipes.
.. _`CMake Home Page`: https://cmake.org
-.. _`CMake Documentation Page`: https://cmake.org/cmake/help/documentation.html
+.. _`CMake Documentation Page`: https://cmake.org/documentation
+.. _`CMake Community Wiki`: https://gitlab.kitware.com/cmake/community/wikis/home
CMake is maintained and supported by `Kitware`_ and developed in
collaboration with a productive community of contributors.
@@ -36,14 +38,14 @@ Supported Platforms
* FreeBSD
* OpenBSD
* Solaris
-* HP-UX
+* AIX
Other UNIX-like operating systems may work too out of the box, if not
it should not be a major problem to port CMake to this platform.
-Subscribe and post to the `CMake Users List`_ to ask if others have
+Please post to the `CMake Discourse Forum`_ to ask if others have
had experience with the platform.
-.. _`CMake Users List`: https://cmake.org/mailman/listinfo/cmake
+.. _`CMake Discourse Forum`: https://discourse.cmake.org
Building CMake from Scratch
---------------------------
@@ -51,25 +53,43 @@ Building CMake from Scratch
UNIX/Mac OSX/MinGW/MSYS/Cygwin
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-You need to have a compiler and a make installed.
+You need to have a C++ compiler (supporting C++11) and a ``make`` installed.
Run the ``bootstrap`` script you find in the source directory of CMake.
You can use the ``--help`` option to see the supported options.
You may use the ``--prefix=<install_prefix>`` option to specify a custom
-installation directory for CMake. You can run the ``bootstrap`` script from
-within the CMake source directory or any other build directory of your
-choice. Once this has finished successfully, run ``make`` and
-``make install``. In summary::
+installation directory for CMake. Once this has finished successfully,
+run ``make`` and ``make install``.
- $ ./bootstrap && make && make install
+For example, if you simply want to build and install CMake from source,
+you can build directly in the source tree::
+
+ $ ./bootstrap && make && sudo make install
+
+Or, if you plan to develop CMake or otherwise run the test suite, create
+a separate build tree::
+
+ $ mkdir cmake-build && cd cmake-build
+ $ ../cmake-source/bootstrap && make
Windows
^^^^^^^
-You need to download and install a binary release of CMake in order to build
-CMake. You can get these releases from the `CMake Download Page`_ . Then
-proceed with the instructions below.
+There are two ways for building CMake under Windows:
+
+1. Compile with MSVC from VS 2015 or later.
+ You need to download and install a binary release of CMake. You can get
+ these releases from the `CMake Download Page`_. Then proceed with the
+ instructions below for `Building CMake with CMake`_.
+
+2. Bootstrap with MinGW under MSYS2.
+ Download and install `MSYS2`_. Then install the required build tools::
-.. _`CMake Download Page`: https://cmake.org/cmake/resources/software.html
+ $ pacman -S --needed git base-devel mingw-w64-x86_64-gcc
+
+ and bootstrap as above.
+
+.. _`CMake Download Page`: https://cmake.org/download
+.. _`MSYS2`: https://www.msys2.org/
Building CMake with CMake
-------------------------
@@ -79,7 +99,14 @@ run the installed CMake on the sources of this CMake with your preferred
options and generators. Then build it and install it.
For instructions how to do this, see documentation on `Running CMake`_.
-.. _`Running CMake`: https://cmake.org/cmake/help/runningcmake.html
+.. _`Running CMake`: https://cmake.org/runningcmake
+
+To build the documentation, install `Sphinx`_ and configure CMake with
+``-DSPHINX_HTML=ON`` and/or ``-DSPHINX_MAN=ON`` to enable the "html" or
+"man" builder. Add ``-DSPHINX_EXECUTABLE=/path/to/sphinx-build`` if the
+tool is not found automatically.
+
+.. _`Sphinx`: http://sphinx-doc.org
Reporting Bugs
==============
@@ -88,7 +115,7 @@ If you have found a bug:
1. If you have a patch, please read the `CONTRIBUTING.rst`_ document.
-2. Otherwise, please join the `CMake Users List`_ and ask about
+2. Otherwise, please post to the `CMake Discourse Forum`_ and ask about
the expected and observed behaviors to determine if it is really
a bug.
diff --git a/Source/.gitattributes b/Source/.gitattributes
index 0f829a368..d0aedc200 100644
--- a/Source/.gitattributes
+++ b/Source/.gitattributes
@@ -1,2 +1,4 @@
+CMakeVersion.cmake export-subst
+
# Do not format third-party sources.
-/kwsys/** -format.clang-format
+/kwsys/** -format.clang-format-6.0
diff --git a/Source/CMakeInstallDestinations.cmake b/Source/CMakeInstallDestinations.cmake
index 28f4e87ad..e82bec3cd 100644
--- a/Source/CMakeInstallDestinations.cmake
+++ b/Source/CMakeInstallDestinations.cmake
@@ -2,19 +2,22 @@
if(BEOS)
set(CMAKE_BIN_DIR_DEFAULT "bin") # HAIKU
set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # HAIKU
- set(CMAKE_MAN_DIR_DEFAULT "documentation/man") # HAIKU
set(CMAKE_DOC_DIR_DEFAULT "documentation/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # HAIKU
+ set(CMAKE_INFO_DIR_DEFAULT "documentation/info") # HAIKU
+ set(CMAKE_MAN_DIR_DEFAULT "documentation/man") # HAIKU
set(CMAKE_XDGDATA_DIR_DEFAULT "share") # HAIKU
elseif(CYGWIN)
set(CMAKE_BIN_DIR_DEFAULT "bin") # CYGWIN
set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION}") # CYGWIN
set(CMAKE_DOC_DIR_DEFAULT "share/doc/cmake-${CMake_VERSION}") # CYGWIN
+ set(CMAKE_INFO_DIR_DEFAULT "share/info") # CYGWIN
set(CMAKE_MAN_DIR_DEFAULT "share/man") # CYGWIN
set(CMAKE_XDGDATA_DIR_DEFAULT "share") # CYGWIN
else()
set(CMAKE_BIN_DIR_DEFAULT "bin") # OTHER
set(CMAKE_DATA_DIR_DEFAULT "share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # OTHER
set(CMAKE_DOC_DIR_DEFAULT "doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # OTHER
+ set(CMAKE_INFO_DIR_DEFAULT "info") # OTHER
set(CMAKE_MAN_DIR_DEFAULT "man") # OTHER
set(CMAKE_XDGDATA_DIR_DEFAULT "share") # OTHER
endif()
@@ -22,6 +25,7 @@ endif()
set(CMAKE_BIN_DIR_DESC "bin")
set(CMAKE_DATA_DIR_DESC "data")
set(CMAKE_DOC_DIR_DESC "docs")
+set(CMAKE_INFO_DIR_DESC "Info manual")
set(CMAKE_MAN_DIR_DESC "man pages")
set(CMAKE_XDGDATA_DIR_DESC "XDG specific files")
@@ -35,6 +39,7 @@ foreach(v
CMAKE_BIN_DIR
CMAKE_DATA_DIR
CMAKE_DOC_DIR
+ CMAKE_INFO_DIR
CMAKE_MAN_DIR
CMAKE_XDGDATA_DIR
)
diff --git a/Source/CMakeInstallSignTool.cmake.in b/Source/CMakeInstallSignTool.cmake.in
new file mode 100644
index 000000000..fca629c31
--- /dev/null
+++ b/Source/CMakeInstallSignTool.cmake.in
@@ -0,0 +1,51 @@
+# The signtool. Default to PATH.
+set(CMake_INSTALL_SIGNTOOL "@CMake_INSTALL_SIGNTOOL@")
+if(NOT CMake_INSTALL_SIGNTOOL)
+ set(CMake_INSTALL_SIGNTOOL signtool)
+endif()
+
+# Select a certificate by Subject Name. Default to automatic selection.
+set(CMake_INSTALL_SIGNTOOL_SUBJECT_NAME "@CMake_INSTALL_SIGNTOOL_SUBJECT_NAME@")
+if(CMake_INSTALL_SIGNTOOL_SUBJECT_NAME)
+ set(select_cert -n "${CMake_INSTALL_SIGNTOOL_SUBJECT_NAME}")
+else()
+ set(select_cert -a)
+endif()
+
+# Timestamp URL. Default to a common provider.
+set(CMake_INSTALL_SIGNTOOL_TIMESTAMP_URL "@CMake_INSTALL_SIGNTOOL_TIMESTAMP_URL@")
+if(NOT CMake_INSTALL_SIGNTOOL_TIMESTAMP_URL)
+ set(CMake_INSTALL_SIGNTOOL_TIMESTAMP_URL "http://timestamp.digicert.com")
+endif()
+
+# Glob files that need a signature.
+file(GLOB files "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/*.exe")
+
+# Sign all files at once.
+if(files)
+ # Run the signtool through 'cmd /c' to enable password prompt popup.
+ # Some providers have trouble when signtool is invoked with SW_HIDE.
+ set(cmd cmd /c "${CMake_INSTALL_SIGNTOOL}" sign -v ${select_cert})
+
+ # Sign with SHA-1 for Windows 7 and below.
+ execute_process(
+ COMMAND ${cmd} -t "${CMake_INSTALL_SIGNTOOL_TIMESTAMP_URL}" ${files}
+ RESULT_VARIABLE result
+ ERROR_VARIABLE stderr
+ )
+ if(NOT result EQUAL 0)
+ string(REPLACE "\n" "\n " stderr " ${stderr}")
+ message(WARNING "signtool failed:\n${stderr}")
+ endif()
+
+ # Sign with SHA-256 for Windows 8 and above.
+ execute_process(
+ COMMAND ${cmd} -tr "${CMake_INSTALL_SIGNTOOL_TIMESTAMP_URL}" -fd sha256 -td sha256 -as ${files}
+ RESULT_VARIABLE result
+ ERROR_VARIABLE stderr
+ )
+ if(NOT result EQUAL 0)
+ string(REPLACE "\n" "\n " stderr " ${stderr}")
+ message(WARNING "signtool failed:\n${stderr}")
+ endif()
+endif()
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 40403ca25..b1f7b29e5 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -31,6 +31,16 @@ else()
set(CMAKE_USE_ELF_PARSER)
endif()
+if(NOT CMake_DEFAULT_RECURSION_LIMIT)
+ if(DEFINED ENV{DASHBOARD_TEST_FROM_CTEST})
+ set(CMake_DEFAULT_RECURSION_LIMIT 100)
+ elseif(MINGW)
+ set(CMake_DEFAULT_RECURSION_LIMIT 400)
+ else()
+ set(CMake_DEFAULT_RECURSION_LIMIT 1000)
+ endif()
+endif()
+
if(APPLE)
set(CMAKE_USE_MACH_PARSER 1)
endif()
@@ -82,13 +92,9 @@ include_directories(
${CMAKE_ZLIB_INCLUDES}
${CMAKE_EXPAT_INCLUDES}
${CMAKE_TAR_INCLUDES}
- ${CMAKE_COMPRESS_INCLUDES}
${CMake_HAIKU_INCLUDE_DIRS}
)
-# let cmake know it is supposed to use it
-add_definitions(-DCMAKE_BUILD_WITH_CMAKE)
-
# Check if we can build the ELF parser.
if(CMAKE_USE_ELF_PARSER)
set(ELF_SRCS cmELF.h cmELF.cxx)
@@ -131,10 +137,39 @@ set(SRCS
LexerParser/cmListFileLexer.c
LexerParser/cmListFileLexer.in.l
+ cmAffinity.cxx
+ cmAffinity.h
+ cmAlgorithms.h
cmArchiveWrite.cxx
+ cmArgumentParser.cxx
+ cmArgumentParser.h
cmBase32.cxx
+ cmBinUtilsLinker.cxx
+ cmBinUtilsLinker.h
+ cmBinUtilsLinuxELFGetRuntimeDependenciesTool.cxx
+ cmBinUtilsLinuxELFGetRuntimeDependenciesTool.h
+ cmBinUtilsLinuxELFLinker.cxx
+ cmBinUtilsLinuxELFLinker.h
+ cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.cxx
+ cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.h
+ cmBinUtilsMacOSMachOGetRuntimeDependenciesTool.cxx
+ cmBinUtilsMacOSMachOGetRuntimeDependenciesTool.h
+ cmBinUtilsMacOSMachOLinker.cxx
+ cmBinUtilsMacOSMachOLinker.h
+ cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.cxx
+ cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.h
+ cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.cxx
+ cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.h
+ cmBinUtilsWindowsPEGetRuntimeDependenciesTool.cxx
+ cmBinUtilsWindowsPEGetRuntimeDependenciesTool.h
+ cmBinUtilsWindowsPELinker.cxx
+ cmBinUtilsWindowsPELinker.h
+ cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx
+ cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h
cmCacheManager.cxx
cmCacheManager.h
+ cmCheckCustomOutputs.h
+ cmCheckCustomOutputs.cxx
cmCLocaleEnvironmentScope.h
cmCLocaleEnvironmentScope.cxx
cmCommandArgumentParserHelper.cxx
@@ -158,6 +193,9 @@ set(SRCS
cmCustomCommand.h
cmCustomCommandGenerator.cxx
cmCustomCommandGenerator.h
+ cmCustomCommandLines.cxx
+ cmCustomCommandLines.h
+ cmCustomCommandTypes.h
cmDefinitions.cxx
cmDefinitions.h
cmDepends.cxx
@@ -191,8 +229,6 @@ set(SRCS
cmExportTryCompileFileGenerator.cxx
cmExportSet.h
cmExportSet.cxx
- cmExportSetMap.h
- cmExportSetMap.cxx
cmExternalMakefileProjectGenerator.cxx
cmExternalMakefileProjectGenerator.h
cmExtraCodeBlocksGenerator.cxx
@@ -205,6 +241,18 @@ set(SRCS
cmExtraKateGenerator.h
cmExtraSublimeTextGenerator.cxx
cmExtraSublimeTextGenerator.h
+ cmFileAPI.cxx
+ cmFileAPI.h
+ cmFileAPICache.cxx
+ cmFileAPICache.h
+ cmFileAPICodemodel.cxx
+ cmFileAPICodemodel.h
+ cmFileAPICMakeFiles.cxx
+ cmFileAPICMakeFiles.h
+ cmFileCopier.cxx
+ cmFileCopier.h
+ cmFileInstaller.cxx
+ cmFileInstaller.h
cmFileLock.cxx
cmFileLock.h
cmFileLockPool.cxx
@@ -213,9 +261,15 @@ set(SRCS
cmFileLockResult.h
cmFilePathChecksum.cxx
cmFilePathChecksum.h
- cmFileTimeComparison.cxx
- cmFileTimeComparison.h
+ cmFileTime.cxx
+ cmFileTime.h
+ cmFileTimeCache.cxx
+ cmFileTimeCache.h
+ cmFileTimes.cxx
+ cmFileTimes.h
cmFortranParserImpl.cxx
+ cmFSPermissions.cxx
+ cmFSPermissions.h
cmGeneratedFileStream.cxx
cmGeneratorExpressionContext.cxx
cmGeneratorExpressionContext.h
@@ -235,6 +289,8 @@ set(SRCS
cmGeneratorExpression.h
cmGeneratorTarget.cxx
cmGeneratorTarget.h
+ cmGetPipes.cxx
+ cmGetPipes.h
cmGlobalCommonGenerator.cxx
cmGlobalCommonGenerator.h
cmGlobalGenerator.cxx
@@ -242,6 +298,8 @@ set(SRCS
cmGlobalGeneratorFactory.h
cmGlobalUnixMakefileGenerator3.cxx
cmGlobalUnixMakefileGenerator3.h
+ cmGlobVerificationManager.cxx
+ cmGlobVerificationManager.h
cmGraphAdjacencyList.h
cmGraphVizWriter.cxx
cmGraphVizWriter.h
@@ -254,11 +312,18 @@ set(SRCS
cmInstallFilesGenerator.cxx
cmInstallScriptGenerator.h
cmInstallScriptGenerator.cxx
+ cmInstallSubdirectoryGenerator.h
+ cmInstallSubdirectoryGenerator.cxx
cmInstallTargetGenerator.h
cmInstallTargetGenerator.cxx
cmInstallDirectoryGenerator.h
cmInstallDirectoryGenerator.cxx
+ cmLDConfigLDConfigTool.cxx
+ cmLDConfigLDConfigTool.h
+ cmLDConfigTool.cxx
+ cmLDConfigTool.h
cmLinkedTree.h
+ cmLinkItem.cxx
cmLinkItem.h
cmLinkLineComputer.cxx
cmLinkLineComputer.h
@@ -281,6 +346,7 @@ set(SRCS
cmMakefileExecutableTargetGenerator.cxx
cmMakefileLibraryTargetGenerator.cxx
cmMakefileUtilityTargetGenerator.cxx
+ cmMessageType.h
cmMessenger.cxx
cmMessenger.h
cmMSVC60LinkLineComputer.cxx
@@ -299,7 +365,6 @@ set(SRCS
cmProcessOutput.h
cmProcessTools.cxx
cmProcessTools.h
- cmProperty.cxx
cmProperty.h
cmPropertyDefinition.cxx
cmPropertyDefinition.h
@@ -307,20 +372,29 @@ set(SRCS
cmPropertyDefinitionMap.h
cmPropertyMap.cxx
cmPropertyMap.h
- cmQtAutoGeneratorCommon.cxx
- cmQtAutoGeneratorCommon.h
- cmQtAutoGeneratorInitializer.cxx
- cmQtAutoGeneratorInitializer.h
- cmQtAutoGenerators.cxx
- cmQtAutoGenerators.h
+ cmQtAutoGen.cxx
+ cmQtAutoGen.h
+ cmQtAutoGenerator.cxx
+ cmQtAutoGenerator.h
+ cmQtAutoGenGlobalInitializer.cxx
+ cmQtAutoGenGlobalInitializer.h
+ cmQtAutoGenInitializer.cxx
+ cmQtAutoGenInitializer.h
+ cmQtAutoMocUic.cxx
+ cmQtAutoMocUic.h
+ cmQtAutoRcc.cxx
+ cmQtAutoRcc.h
cmRST.cxx
cmRST.h
+ cmRuntimeDependencyArchive.cxx
+ cmRuntimeDependencyArchive.h
cmScriptGenerator.h
cmScriptGenerator.cxx
cmSourceFile.cxx
cmSourceFile.h
cmSourceFileLocation.cxx
cmSourceFileLocation.h
+ cmSourceFileLocationKind.h
cmSourceGroup.cxx
cmSourceGroup.h
cmState.cxx
@@ -330,6 +404,8 @@ set(SRCS
cmStateSnapshot.cxx
cmStateSnapshot.h
cmStateTypes.h
+ cmStringAlgorithms.cxx
+ cmStringAlgorithms.h
cmSystemTools.cxx
cmSystemTools.h
cmTarget.cxx
@@ -342,10 +418,18 @@ set(SRCS
cmTestGenerator.cxx
cmTestGenerator.h
cmUuid.cxx
+ cmUVHandlePtr.cxx
+ cmUVHandlePtr.h
+ cmUVProcessChain.cxx
+ cmUVProcessChain.h
+ cmUVStreambuf.h
+ cmUVSignalHackRAII.h
cmVariableWatch.cxx
cmVariableWatch.h
cmVersion.cxx
cmVersion.h
+ cmWorkerPool.cxx
+ cmWorkerPool.h
cmWorkingDirectory.cxx
cmWorkingDirectory.h
cmXMLParser.cxx
@@ -361,8 +445,12 @@ set(SRCS
cmCommand.h
cmCommands.cxx
cmCommands.h
+ cmAddCompileDefinitionsCommand.cxx
+ cmAddCompileDefinitionsCommand.h
cmAddCompileOptionsCommand.cxx
cmAddCompileOptionsCommand.h
+ cmAddLinkOptionsCommand.cxx
+ cmAddLinkOptionsCommand.h
cmAddCustomCommandCommand.cxx
cmAddCustomCommandCommand.h
cmAddCustomTargetCommand.cxx
@@ -393,8 +481,6 @@ set(SRCS
cmCMakeMinimumRequired.h
cmCMakePolicyCommand.cxx
cmCMakePolicyCommand.h
- cmCommandArgumentsHelper.cxx
- cmCommandArgumentsHelper.h
cmConditionEvaluator.cxx
cmConditionEvaluator.h
cmConfigureFileCommand.cxx
@@ -407,8 +493,6 @@ set(SRCS
cmCreateTestSourceList.h
cmDefinePropertyCommand.cxx
cmDefinePropertyCommand.h
- cmDisallowedCommand.cxx
- cmDisallowedCommand.h
cmEnableLanguageCommand.cxx
cmEnableLanguageCommand.h
cmEnableTestingCommand.cxx
@@ -443,6 +527,8 @@ set(SRCS
cmFindProgramCommand.h
cmForEachCommand.cxx
cmForEachCommand.h
+ cmFunctionBlocker.cxx
+ cmFunctionBlocker.h
cmFunctionCommand.cxx
cmFunctionCommand.h
cmGetCMakePropertyCommand.cxx
@@ -469,6 +555,8 @@ set(SRCS
cmIncludeDirectoryCommand.h
cmIncludeExternalMSProjectCommand.cxx
cmIncludeExternalMSProjectCommand.h
+ cmIncludeGuardCommand.cxx
+ cmIncludeGuardCommand.h
cmIncludeRegularExpressionCommand.cxx
cmIncludeRegularExpressionCommand.h
cmInstallCommand.cxx
@@ -541,8 +629,13 @@ set(SRCS
cmSiteNameCommand.h
cmSourceGroupCommand.cxx
cmSourceGroupCommand.h
+ cmString.cxx
+ cmString.hxx
+ cmStringReplaceHelper.cxx
cmStringCommand.cxx
cmStringCommand.h
+ cmSubcommandTable.cxx
+ cmSubcommandTable.h
cmSubdirCommand.cxx
cmSubdirCommand.h
cmSubdirDependsCommand.cxx
@@ -555,8 +648,14 @@ set(SRCS
cmTargetCompileOptionsCommand.h
cmTargetIncludeDirectoriesCommand.cxx
cmTargetIncludeDirectoriesCommand.h
+ cmTargetLinkOptionsCommand.cxx
+ cmTargetLinkOptionsCommand.h
+ cmTargetLinkDirectoriesCommand.cxx
+ cmTargetLinkDirectoriesCommand.h
cmTargetLinkLibrariesCommand.cxx
cmTargetLinkLibrariesCommand.h
+ cmTargetPrecompileHeadersCommand.cxx
+ cmTargetPrecompileHeadersCommand.h
cmTargetPropCommandBase.cxx
cmTargetPropCommandBase.h
cmTargetSourcesCommand.cxx
@@ -567,8 +666,6 @@ set(SRCS
cmTryCompileCommand.h
cmTryRunCommand.cxx
cmTryRunCommand.h
- cmUnexpectedCommand.cxx
- cmUnexpectedCommand.h
cmUnsetCommand.cxx
cmUnsetCommand.h
cmUseMangledMesaCommand.cxx
@@ -584,23 +681,21 @@ set(SRCS
cmWriteFileCommand.cxx
cmWriteFileCommand.h
- cm_auto_ptr.hxx
+ cm_static_string_view.hxx
cm_get_date.h
cm_get_date.c
cm_utf8.h
cm_utf8.c
cm_codecvt.hxx
cm_codecvt.cxx
+
+ cmDuration.h
+ cmDuration.cxx
)
SET_PROPERTY(SOURCE cmProcessOutput.cxx APPEND PROPERTY COMPILE_DEFINITIONS
KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE})
-# Kdevelop only works on UNIX and not windows
-if(UNIX)
- set(SRCS ${SRCS} cmGlobalKdevelopGenerator.cxx)
-endif()
-
# Xcode only works on Apple
if(APPLE)
set(SRCS ${SRCS}
@@ -655,10 +750,10 @@ if (WIN32)
cmGlobalVisualStudio12Generator.cxx
cmGlobalVisualStudio14Generator.h
cmGlobalVisualStudio14Generator.cxx
- cmGlobalVisualStudio15Generator.h
- cmGlobalVisualStudio15Generator.cxx
cmGlobalVisualStudioGenerator.cxx
cmGlobalVisualStudioGenerator.h
+ cmGlobalVisualStudioVersionedGenerator.h
+ cmGlobalVisualStudioVersionedGenerator.cxx
cmIDEFlagTable.h
cmIDEOptions.cxx
cmIDEOptions.h
@@ -672,14 +767,6 @@ if (WIN32)
cmVisualStudioSlnParser.cxx
cmVisualStudioWCEPlatformParser.h
cmVisualStudioWCEPlatformParser.cxx
- cmGlobalGhsMultiGenerator.cxx
- cmGlobalGhsMultiGenerator.h
- cmLocalGhsMultiGenerator.cxx
- cmLocalGhsMultiGenerator.h
- cmGhsMultiTargetGenerator.cxx
- cmGhsMultiTargetGenerator.h
- cmGhsMultiGpj.cxx
- cmGhsMultiGpj.h
cmVSSetupHelper.cxx
cmVSSetupHelper.h
)
@@ -699,6 +786,22 @@ if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
)
endif()
+# GHS support
+# Works only for windows and linux
+if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(SRCS ${SRCS}
+ cmGlobalGhsMultiGenerator.cxx
+ cmGlobalGhsMultiGenerator.h
+ cmLocalGhsMultiGenerator.cxx
+ cmLocalGhsMultiGenerator.h
+ cmGhsMultiTargetGenerator.cxx
+ cmGhsMultiTargetGenerator.h
+ cmGhsMultiGpj.cxx
+ cmGhsMultiGpj.h
+ )
+endif()
+
+
# Ninja support
set(SRCS ${SRCS}
cmGlobalNinjaGenerator.cxx
@@ -714,6 +817,8 @@ set(SRCS ${SRCS}
cmNinjaUtilityTargetGenerator.h
cmNinjaLinkLineComputer.cxx
cmNinjaLinkLineComputer.h
+ cmNinjaLinkLineDeviceComputer.cxx
+ cmNinjaLinkLineDeviceComputer.h
)
# Temporary variable for tools targets
@@ -741,20 +846,22 @@ foreach(check
else()
set(CMake_${check} 0)
endif()
- set_property(SOURCE cmFileTimeComparison.cxx APPEND PROPERTY
+ set_property(SOURCE cmFileTime.cxx APPEND PROPERTY
COMPILE_DEFINITIONS CMake_${check}=${CMake_${check}})
endforeach()
# create a library used by the command line and the GUI
add_library(CMakeLib ${SRCS})
target_link_libraries(CMakeLib cmsys
+ ${CMAKE_STD_LIBRARY}
${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES}
- ${CMAKE_TAR_LIBRARIES} ${CMAKE_COMPRESS_LIBRARIES}
+ ${CMAKE_TAR_LIBRARIES}
${CMAKE_CURL_LIBRARIES}
${CMAKE_JSONCPP_LIBRARIES}
${CMAKE_LIBUV_LIBRARIES}
${CMAKE_LIBRHASH_LIBRARIES}
${CMake_KWIML_LIBRARIES}
+ ${CMAKE_THREAD_LIBS_INIT}
)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc")
@@ -766,9 +873,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc"
endif()
endif()
-# On Apple we need CoreFoundation
+# On Apple we need CoreFoundation and CoreServices
if(APPLE)
target_link_libraries(CMakeLib "-framework CoreFoundation")
+ target_link_libraries(CMakeLib "-framework CoreServices")
endif()
if(WIN32 AND NOT UNIX)
@@ -777,12 +885,13 @@ if(WIN32 AND NOT UNIX)
target_link_libraries(CMakeLib rpcrt4 crypt32)
endif()
+target_compile_definitions(CMakeLib PUBLIC ${CLANG_TIDY_DEFINITIONS})
+
#
# CTestLib
#
include_directories(
"${CMake_SOURCE_DIR}/Source/CTest"
- ${CMAKE_XMLRPC_INCLUDES}
${CMAKE_CURL_INCLUDES}
)
#
@@ -790,7 +899,7 @@ include_directories(
#
set(CTEST_SRCS cmCTest.cxx
CTest/cmProcess.cxx
- CTest/cmCTestBatchTestHandler.cxx
+ CTest/cmCTestBinPacker.cxx
CTest/cmCTestBuildAndTestHandler.cxx
CTest/cmCTestBuildCommand.cxx
CTest/cmCTestBuildHandler.cxx
@@ -810,11 +919,14 @@ set(CTEST_SRCS cmCTest.cxx
CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
CTest/cmCTestGenericHandler.cxx
CTest/cmCTestHandlerCommand.cxx
+ CTest/cmCTestResourceAllocator.cxx
+ CTest/cmCTestResourceSpec.cxx
CTest/cmCTestLaunch.cxx
CTest/cmCTestMemCheckCommand.cxx
CTest/cmCTestMemCheckHandler.cxx
CTest/cmCTestMultiProcessHandler.cxx
CTest/cmCTestReadCustomFilesCommand.cxx
+ CTest/cmCTestResourceGroupsLexerHelper.cxx
CTest/cmCTestRunScriptCommand.cxx
CTest/cmCTestRunTest.cxx
CTest/cmCTestScriptHandler.cxx
@@ -845,11 +957,15 @@ set(CTEST_SRCS cmCTest.cxx
CTest/cmCTestHG.h
CTest/cmCTestP4.cxx
CTest/cmCTestP4.h
+
+ LexerParser/cmCTestResourceGroupsLexer.cxx
+ LexerParser/cmCTestResourceGroupsLexer.h
+ LexerParser/cmCTestResourceGroupsLexer.in.l
)
# Build CTestLib
add_library(CTestLib ${CTEST_SRCS})
-target_link_libraries(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES} ${CMAKE_XMLRPC_LIBRARIES})
+target_link_libraries(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES})
#
# CPack
@@ -863,17 +979,14 @@ include_directories(
set(CPACK_SRCS
CPack/cmCPackArchiveGenerator.cxx
CPack/cmCPackComponentGroup.cxx
+ CPack/cmCPackDebGenerator.cxx
+ CPack/cmCPackExternalGenerator.cxx
CPack/cmCPackGeneratorFactory.cxx
CPack/cmCPackGenerator.cxx
CPack/cmCPackLog.cxx
CPack/cmCPackNSISGenerator.cxx
+ CPack/cmCPackNuGetGenerator.cxx
CPack/cmCPackSTGZGenerator.cxx
- CPack/cmCPackTGZGenerator.cxx
- CPack/cmCPackTXZGenerator.cxx
- CPack/cmCPackTarBZip2Generator.cxx
- CPack/cmCPackTarCompressGenerator.cxx
- CPack/cmCPackZIPGenerator.cxx
- CPack/cmCPack7zGenerator.cxx
)
# CPack IFW generator
set(CPACK_SRCS ${CPACK_SRCS}
@@ -896,15 +1009,48 @@ if(CYGWIN)
)
endif()
+option(CPACK_ENABLE_FREEBSD_PKG "Add FreeBSD pkg(8) generator to CPack." OFF)
+
if(UNIX)
set(CPACK_SRCS ${CPACK_SRCS}
- CPack/cmCPackDebGenerator.cxx
CPack/cmCPackRPMGenerator.cxx
)
+
+ # Optionally, try to use pkg(8)
+ if(CPACK_ENABLE_FREEBSD_PKG)
+ # On UNIX, you may find FreeBSD's pkg(8) and attendant
+ # library -- it can be used on FreeBSD, Dragonfly, NetBSD,
+ # OpenBSD and also Linux and OSX. Look for the header and
+ # the library; it's a warning on FreeBSD if they're not
+ # found, and informational on other platforms.
+ find_path(FREEBSD_PKG_INCLUDE_DIRS "pkg.h")
+ if(FREEBSD_PKG_INCLUDE_DIRS)
+ find_library(FREEBSD_PKG_LIBRARIES
+ pkg
+ DOC "FreeBSD pkg(8) library")
+ if(FREEBSD_PKG_LIBRARIES)
+ set(CPACK_SRCS ${CPACK_SRCS}
+ CPack/cmCPackFreeBSDGenerator.cxx
+ )
+ endif()
+ endif()
+
+ if (NOT FREEBSD_PKG_INCLUDE_DIRS OR NOT FREEBSD_PKG_LIBRARIES)
+ message(FATAL_ERROR "CPack needs libpkg(3) to produce FreeBSD packages natively.")
+ endif()
+ else()
+ set(FREEBSD_PKG_INCLUDE_DIRS NOTFOUND)
+ set(FREEBSD_PKG_LIBRARIES NOTFOUND)
+ endif()
endif()
-if(WIN32)
+if(CYGWIN)
+ find_package(LibUUID)
+endif()
+if(WIN32 OR (CYGWIN AND LibUUID_FOUND))
set(CPACK_SRCS ${CPACK_SRCS}
+ CPack/WiX/cmCMakeToWixPath.cxx
+ CPack/WiX/cmCMakeToWixPath.h
CPack/WiX/cmCPackWIXGenerator.cxx
CPack/WiX/cmCPackWIXGenerator.h
CPack/WiX/cmWIXAccessControlList.cxx
@@ -925,7 +1071,7 @@ if(WIN32)
CPack/WiX/cmWIXShortcut.h
CPack/WiX/cmWIXSourceWriter.cxx
CPack/WiX/cmWIXSourceWriter.h
- )
+ )
endif()
if(APPLE)
@@ -958,11 +1104,18 @@ if(APPLE)
"See CMakeFiles/CMakeError.log for details of the failure.")
endif()
endif()
+if(CYGWIN AND LibUUID_FOUND)
+ target_link_libraries(CPackLib ${LibUUID_LIBRARIES})
+ include_directories(CPackLib ${LibUUID_INCLUDE_DIRS})
+ set_property(SOURCE CPack/cmCPackGeneratorFactory.cxx PROPERTY COMPILE_DEFINITIONS HAVE_LIBUUID)
+endif()
+if(CPACK_ENABLE_FREEBSD_PKG AND FREEBSD_PKG_INCLUDE_DIRS AND FREEBSD_PKG_LIBRARIES)
+ target_link_libraries(CPackLib ${FREEBSD_PKG_LIBRARIES})
+ include_directories(${FREEBSD_PKG_INCLUDE_DIRS})
+ add_definitions(-DHAVE_FREEBSD_PKG)
+endif()
if(APPLE)
- add_executable(cmakexbuild cmakexbuild.cxx)
- list(APPEND _tools cmakexbuild)
- target_link_libraries(cmakexbuild CMakeLib)
add_executable(OSXScriptLauncher
CPack/OSXScriptLauncher.cxx)
target_link_libraries(OSXScriptLauncher cmsys)
@@ -974,18 +1127,19 @@ add_executable(cmake cmakemain.cxx cmcmd.cxx cmcmd.h ${MANIFEST_FILE})
list(APPEND _tools cmake)
target_link_libraries(cmake CMakeLib)
-if(CMake_ENABLE_SERVER_MODE)
- add_library(CMakeServerLib
- cmFileMonitor.cxx cmFileMonitor.h
- cmServer.cxx cmServer.h
- cmServerConnection.cxx cmServerConnection.h
- cmServerProtocol.cxx cmServerProtocol.h
- )
- target_link_libraries(CMakeServerLib CMakeLib)
- set_property(SOURCE cmcmd.cxx APPEND PROPERTY COMPILE_DEFINITIONS HAVE_SERVER_MODE=1)
-
- target_link_libraries(cmake CMakeServerLib)
-endif()
+add_library(CMakeServerLib
+ cmConnection.h cmConnection.cxx
+ cmFileMonitor.cxx cmFileMonitor.h
+ cmJsonObjectDictionary.h
+ cmJsonObjects.h
+ cmJsonObjects.cxx
+ cmPipeConnection.cxx cmPipeConnection.h
+ cmServer.cxx cmServer.h
+ cmServerConnection.cxx cmServerConnection.h
+ cmServerProtocol.cxx cmServerProtocol.h
+ )
+target_link_libraries(CMakeServerLib CMakeLib)
+target_link_libraries(cmake CMakeServerLib)
# Build CTest executable
add_executable(ctest ctest.cxx ${MANIFEST_FILE})
@@ -999,7 +1153,7 @@ target_link_libraries(cpack CPackLib)
# Curses GUI
if(BUILD_CursesDialog)
- include(${CMake_SOURCE_DIR}/Source/CursesDialog/CMakeLists.txt)
+ add_subdirectory(CursesDialog)
endif()
# Qt GUI
@@ -1011,6 +1165,34 @@ endif()
include (${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
include (${CMake_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
+if(WIN32)
+ # Compute the binary version that appears in the RC file. Version
+ # components in the RC file are 16-bit integers so we may have to
+ # split the patch component.
+ if(CMake_VERSION_PATCH MATCHES "^([0-9]+)([0-9][0-9][0-9][0-9])$")
+ set(CMake_RCVERSION_YEAR "${CMAKE_MATCH_1}")
+ set(CMake_RCVERSION_MONTH_DAY "${CMAKE_MATCH_2}")
+ string(REGEX REPLACE "^0+" "" CMake_RCVERSION_MONTH_DAY "${CMake_RCVERSION_MONTH_DAY}")
+ set(CMake_RCVERSION ${CMake_VERSION_MAJOR},${CMake_VERSION_MINOR},${CMake_RCVERSION_YEAR},${CMake_RCVERSION_MONTH_DAY})
+ unset(CMake_RCVERSION_MONTH_DAY)
+ unset(CMake_RCVERSION_YEAR)
+ else()
+ set(CMake_RCVERSION ${CMake_VERSION_MAJOR},${CMake_VERSION_MINOR},${CMake_VERSION_PATCH},0)
+ endif()
+ set(CMake_RCVERSION_STR ${CMake_VERSION})
+
+ # Add Windows executable version information.
+ configure_file("CMakeVersion.rc.in" "CMakeVersion.rc" @ONLY)
+
+ # We use a separate object library for this to work around a limitation of
+ # MinGW's windres tool with spaces in the path to the include directories.
+ add_library(CMakeVersion OBJECT "${CMAKE_CURRENT_BINARY_DIR}/CMakeVersion.rc")
+ set_property(TARGET CMakeVersion PROPERTY INCLUDE_DIRECTORIES "")
+ foreach(_tool ${_tools})
+ target_sources(${_tool} PRIVATE $<TARGET_OBJECTS:CMakeVersion>)
+ endforeach()
+endif()
+
# Install tools
foreach(_tool ${_tools})
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index ecf511607..23c0212f2 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,84 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
-set(CMake_VERSION_MINOR 9)
+set(CMake_VERSION_MINOR 16)
set(CMake_VERSION_PATCH 4)
#set(CMake_VERSION_RC 0)
+set(CMake_VERSION_IS_DIRTY 0)
+
+# Start with the full version number used in tags. It has no dev info.
+set(CMake_VERSION
+ "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
+if(DEFINED CMake_VERSION_RC)
+ set(CMake_VERSION "${CMake_VERSION}-rc${CMake_VERSION_RC}")
+endif()
+
+# Releases define a small patch level.
+if("${CMake_VERSION_PATCH}" VERSION_LESS 20000000)
+ set(CMake_VERSION_IS_RELEASE 1)
+else()
+ set(CMake_VERSION_IS_RELEASE 0)
+endif()
+
+if(NOT CMake_VERSION_NO_GIT)
+ # If this source was exported by 'git archive', use its commit info.
+ set(git_info [==[$Format:%h %s$]==])
+
+ # Otherwise, try to identify the current development source version.
+ if(NOT git_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]?[0-9a-f]?)[0-9a-f]* "
+ AND EXISTS ${CMake_SOURCE_DIR}/.git)
+ find_package(Git QUIET)
+ if(GIT_FOUND)
+ macro(_git)
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} ${ARGN}
+ WORKING_DIRECTORY ${CMake_SOURCE_DIR}
+ RESULT_VARIABLE _git_res
+ OUTPUT_VARIABLE _git_out OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE _git_err ERROR_STRIP_TRAILING_WHITESPACE
+ )
+ endmacro()
+ endif()
+ if(COMMAND _git)
+ # Get the commit checked out in this work tree.
+ _git(log -n 1 HEAD "--pretty=format:%h %s" --)
+ set(git_info "${_git_out}")
+ endif()
+ endif()
+
+ # Extract commit information if available.
+ if(git_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]?[0-9a-f]?)[0-9a-f]* (.*)$")
+ # Have commit information.
+ set(git_hash "${CMAKE_MATCH_1}")
+ set(git_subject "${CMAKE_MATCH_2}")
+
+ # If this is not the exact commit of a release, add dev info.
+ if(NOT "${git_subject}" MATCHES "^[Cc][Mm]ake ${CMake_VERSION}$")
+ set(CMake_VERSION "${CMake_VERSION}-g${git_hash}")
+ endif()
+
+ # If this is a work tree, check whether it is dirty.
+ if(COMMAND _git)
+ _git(update-index -q --refresh)
+ _git(diff-index --name-only HEAD --)
+ if(_git_out)
+ set(CMake_VERSION_IS_DIRTY 1)
+ endif()
+ endif()
+ else()
+ # No commit information.
+ if(NOT CMake_VERSION_IS_RELEASE)
+ # Generic development version.
+ set(CMake_VERSION "${CMake_VERSION}-git")
+ endif()
+ endif()
+endif()
+
+# Extract the version suffix component.
+if(CMake_VERSION MATCHES "-(.*)$")
+ set(CMake_VERSION_SUFFIX "${CMAKE_MATCH_1}")
+else()
+ set(CMake_VERSION_SUFFIX "")
+endif()
+if(CMake_VERSION_IS_DIRTY)
+ set(CMake_VERSION ${CMake_VERSION}-dirty)
+endif()
diff --git a/Source/CMakeVersion.rc.in b/Source/CMakeVersion.rc.in
new file mode 100644
index 000000000..762d9bb62
--- /dev/null
+++ b/Source/CMakeVersion.rc.in
@@ -0,0 +1,28 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+1 VERSIONINFO
+FILEVERSION @CMake_RCVERSION@
+PRODUCTVERSION @CMake_RCVERSION@
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904E4"
+ BEGIN
+ VALUE "FileVersion", "@CMake_RCVERSION_STR@\0"
+ VALUE "ProductVersion", "@CMake_RCVERSION_STR@\0"
+ END
+ END
+
+ BLOCK "VarFileInfo"
+ BEGIN
+ /* The following line should only be modified for localized versions. */
+ /* It consists of any number of WORD,WORD pairs, with each pair */
+ /* describing a language,codepage combination supported by the file. */
+ /* */
+ /* For example, a file might have values "0x409,1252" indicating that it */
+ /* supports English language (0x409) in the Windows ANSI codepage (1252). */
+
+ VALUE "Translation", 0x409, 1252
+ END
+END
diff --git a/Source/CMakeVersionCompute.cmake b/Source/CMakeVersionCompute.cmake
deleted file mode 100644
index d9218d731..000000000
--- a/Source/CMakeVersionCompute.cmake
+++ /dev/null
@@ -1,29 +0,0 @@
-# Load version number components.
-include(${CMake_SOURCE_DIR}/Source/CMakeVersion.cmake)
-
-# Releases define a small patch level.
-if("${CMake_VERSION_PATCH}" VERSION_LESS 20000000)
- set(CMake_VERSION_IS_DIRTY 0)
- set(CMake_VERSION_IS_RELEASE 1)
- set(CMake_VERSION_SOURCE "")
-else()
- set(CMake_VERSION_IS_DIRTY 0) # may be set to 1 by CMakeVersionSource
- set(CMake_VERSION_IS_RELEASE 0)
- include(${CMake_SOURCE_DIR}/Source/CMakeVersionSource.cmake)
-endif()
-
-# Compute the full version string.
-set(CMake_VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH})
-if(CMake_VERSION_SOURCE)
- set(CMake_VERSION_SUFFIX "${CMake_VERSION_SOURCE}")
-elseif(CMake_VERSION_RC)
- set(CMake_VERSION_SUFFIX "rc${CMake_VERSION_RC}")
-else()
- set(CMake_VERSION_SUFFIX "")
-endif()
-if(CMake_VERSION_SUFFIX)
- set(CMake_VERSION ${CMake_VERSION}-${CMake_VERSION_SUFFIX})
-endif()
-if(CMake_VERSION_IS_DIRTY)
- set(CMake_VERSION ${CMake_VERSION}-dirty)
-endif()
diff --git a/Source/CMakeVersionSource.cmake b/Source/CMakeVersionSource.cmake
deleted file mode 100644
index 5ea1de3f4..000000000
--- a/Source/CMakeVersionSource.cmake
+++ /dev/null
@@ -1,30 +0,0 @@
-# Try to identify the current development source version.
-set(CMake_VERSION_SOURCE "")
-if(EXISTS ${CMake_SOURCE_DIR}/.git/HEAD)
- find_program(GIT_EXECUTABLE NAMES git git.cmd)
- mark_as_advanced(GIT_EXECUTABLE)
- if(GIT_EXECUTABLE)
- execute_process(
- COMMAND ${GIT_EXECUTABLE} rev-parse --verify -q --short=4 HEAD
- OUTPUT_VARIABLE head
- OUTPUT_STRIP_TRAILING_WHITESPACE
- WORKING_DIRECTORY ${CMake_SOURCE_DIR}
- )
- if(head)
- set(CMake_VERSION_SOURCE "g${head}")
- execute_process(
- COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
- WORKING_DIRECTORY ${CMake_SOURCE_DIR}
- )
- execute_process(
- COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
- OUTPUT_VARIABLE dirty
- OUTPUT_STRIP_TRAILING_WHITESPACE
- WORKING_DIRECTORY ${CMake_SOURCE_DIR}
- )
- if(dirty)
- set(CMake_VERSION_IS_DIRTY 1)
- endif()
- endif()
- endif()
-endif()
diff --git a/Source/CPack/IFW/cmCPackIFWCommon.cxx b/Source/CPack/IFW/cmCPackIFWCommon.cxx
index e8f05bd50..9fa74be76 100644
--- a/Source/CPack/IFW/cmCPackIFWCommon.cxx
+++ b/Source/CPack/IFW/cmCPackIFWCommon.cxx
@@ -2,27 +2,29 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackIFWCommon.h"
+#include <cstddef>
+#include <sstream>
+#include <utility>
+#include <vector>
+
#include "cmCPackGenerator.h"
#include "cmCPackIFWGenerator.h"
#include "cmCPackLog.h" // IWYU pragma: keep
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTimestamp.h"
#include "cmVersionConfig.h"
#include "cmXMLWriter.h"
-#include <sstream>
-#include <utility>
-#include <vector>
-
cmCPackIFWCommon::cmCPackIFWCommon()
- : Generator(CM_NULLPTR)
+ : Generator(nullptr)
{
}
const char* cmCPackIFWCommon::GetOption(const std::string& op) const
{
return this->Generator ? this->Generator->cmCPackGenerator::GetOption(op)
- : CM_NULLPTR;
+ : nullptr;
}
bool cmCPackIFWCommon::IsOn(const std::string& op) const
@@ -77,8 +79,7 @@ bool cmCPackIFWCommon::IsVersionEqual(const char* version)
void cmCPackIFWCommon::ExpandListArgument(
const std::string& arg, std::map<std::string, std::string>& argsOut)
{
- std::vector<std::string> args;
- cmSystemTools::ExpandListArgument(arg, args, false);
+ std::vector<std::string> args = cmExpandedList(arg, false);
if (args.empty()) {
return;
}
@@ -99,8 +100,7 @@ void cmCPackIFWCommon::ExpandListArgument(
void cmCPackIFWCommon::ExpandListArgument(
const std::string& arg, std::multimap<std::string, std::string>& argsOut)
{
- std::vector<std::string> args;
- cmSystemTools::ExpandListArgument(arg, args, false);
+ std::vector<std::string> args = cmExpandedList(arg, false);
if (args.empty()) {
return;
}
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
index 226ea0a29..509ac6507 100644
--- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx
+++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
@@ -2,6 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackIFWGenerator.h"
+#include <sstream>
+#include <utility>
+
#include "cmCPackComponentGroup.h"
#include "cmCPackGenerator.h"
#include "cmCPackIFWCommon.h"
@@ -9,20 +12,17 @@
#include "cmCPackIFWPackage.h"
#include "cmCPackIFWRepository.h"
#include "cmCPackLog.h" // IWYU pragma: keep
+#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include <sstream>
-#include <utility>
-
cmCPackIFWGenerator::cmCPackIFWGenerator()
{
this->Generator = this;
}
-cmCPackIFWGenerator::~cmCPackIFWGenerator()
-{
-}
+cmCPackIFWGenerator::~cmCPackIFWGenerator() = default;
int cmCPackIFWGenerator::PackageFiles()
{
@@ -35,152 +35,202 @@ int cmCPackIFWGenerator::PackageFiles()
this->Installer.GeneratePackageFiles();
std::string ifwTLD = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- std::string ifwTmpFile = ifwTLD;
- ifwTmpFile += "/IFWOutput.log";
+ std::string ifwTmpFile = cmStrCat(ifwTLD, "/IFWOutput.log");
// Run repogen
if (!this->Installer.RemoteRepositories.empty()) {
- std::string ifwCmd = this->RepoGen;
+ std::vector<std::string> ifwCmd;
+ std::string ifwArg;
+
+ ifwCmd.emplace_back(this->RepoGen);
if (this->IsVersionLess("2.0.0")) {
- ifwCmd += " -c " + this->toplevel + "/config/config.xml";
+ ifwCmd.emplace_back("-c");
+ ifwCmd.emplace_back(this->toplevel + "/config/config.xml");
}
- ifwCmd += " -p " + this->toplevel + "/packages";
+ ifwCmd.emplace_back("-p");
+ ifwCmd.emplace_back(this->toplevel + "/packages");
if (!this->PkgsDirsVector.empty()) {
- for (std::vector<std::string>::iterator it =
- this->PkgsDirsVector.begin();
- it != this->PkgsDirsVector.end(); ++it) {
- ifwCmd += " -p " + *it;
+ for (std::string const& it : this->PkgsDirsVector) {
+ ifwCmd.emplace_back("-p");
+ ifwCmd.emplace_back(it);
+ }
+ }
+
+ if (!this->RepoDirsVector.empty()) {
+ if (!this->IsVersionLess("3.1")) {
+ for (std::string const& rd : this->RepoDirsVector) {
+ ifwCmd.emplace_back("--repository");
+ ifwCmd.emplace_back(rd);
+ }
+ } else {
+ cmCPackIFWLogger(WARNING,
+ "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" "
+ << "variable is set, but content will be skipped, "
+ << "because this feature available only since "
+ << "QtIFW 3.1. Please update your QtIFW instance."
+ << std::endl);
}
}
if (!this->OnlineOnly && !this->DownloadedPackages.empty()) {
- ifwCmd += " -i ";
- std::set<cmCPackIFWPackage*>::iterator it =
- this->DownloadedPackages.begin();
- ifwCmd += (*it)->Name;
+ ifwCmd.emplace_back("-i");
+ auto it = this->DownloadedPackages.begin();
+ ifwArg = (*it)->Name;
++it;
while (it != this->DownloadedPackages.end()) {
- ifwCmd += "," + (*it)->Name;
+ ifwArg += "," + (*it)->Name;
++it;
}
+ ifwCmd.emplace_back(ifwArg);
}
- ifwCmd += " " + this->toplevel + "/repository";
- cmCPackIFWLogger(VERBOSE, "Execute: " << ifwCmd << std::endl);
+ ifwCmd.emplace_back(this->toplevel + "/repository");
+ cmCPackIFWLogger(VERBOSE,
+ "Execute: " << cmSystemTools::PrintSingleCommand(ifwCmd)
+ << std::endl);
std::string output;
int retVal = 1;
cmCPackIFWLogger(OUTPUT, "- Generate repository" << std::endl);
- bool res = cmSystemTools::RunSingleCommand(ifwCmd.c_str(), &output,
- &output, &retVal, CM_NULLPTR,
- this->GeneratorVerbose, 0);
+ bool res = cmSystemTools::RunSingleCommand(
+ ifwCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
+ cmDuration::zero());
if (!res || retVal) {
- cmGeneratedFileStream ofs(ifwTmpFile.c_str());
- ofs << "# Run command: " << ifwCmd << std::endl
+ cmGeneratedFileStream ofs(ifwTmpFile);
+ ofs << "# Run command: " << cmSystemTools::PrintSingleCommand(ifwCmd)
+ << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
- cmCPackIFWLogger(ERROR, "Problem running IFW command: "
- << ifwCmd << std::endl
- << "Please check " << ifwTmpFile << " for errors"
- << std::endl);
+ cmCPackIFWLogger(
+ ERROR,
+ "Problem running IFW command: "
+ << cmSystemTools::PrintSingleCommand(ifwCmd) << std::endl
+ << "Please check \"" << ifwTmpFile << "\" for errors" << std::endl);
return 0;
}
if (!this->Repository.RepositoryUpdate.empty() &&
!this->Repository.PatchUpdatesXml()) {
- cmCPackIFWLogger(WARNING, "Problem patch IFW \"Updates\" "
- << "file: "
- << this->toplevel + "/repository/Updates.xml"
- << std::endl);
+ cmCPackIFWLogger(WARNING,
+ "Problem patch IFW \"Updates\" "
+ << "file: \"" << this->toplevel
+ << "/repository/Updates.xml\"" << std::endl);
}
- cmCPackIFWLogger(OUTPUT, "- repository: " << this->toplevel
- << "/repository generated"
- << std::endl);
+ cmCPackIFWLogger(OUTPUT,
+ "- repository: \"" << this->toplevel
+ << "/repository\" generated"
+ << std::endl);
}
// Run binary creator
{
- std::string ifwCmd = this->BinCreator;
- ifwCmd += " -c " + this->toplevel + "/config/config.xml";
+ std::vector<std::string> ifwCmd;
+ std::string ifwArg;
+
+ ifwCmd.emplace_back(this->BinCreator);
+
+ ifwCmd.emplace_back("-c");
+ ifwCmd.emplace_back(this->toplevel + "/config/config.xml");
if (!this->Installer.Resources.empty()) {
- ifwCmd += " -r ";
- std::vector<std::string>::iterator it =
- this->Installer.Resources.begin();
+ ifwCmd.emplace_back("-r");
+ auto it = this->Installer.Resources.begin();
std::string path = this->toplevel + "/resources/";
- ifwCmd += path + *it;
+ ifwArg = path + *it;
++it;
while (it != this->Installer.Resources.end()) {
- ifwCmd += "," + path + *it;
+ ifwArg += "," + path + *it;
++it;
}
+ ifwCmd.emplace_back(ifwArg);
}
- ifwCmd += " -p " + this->toplevel + "/packages";
+ ifwCmd.emplace_back("-p");
+ ifwCmd.emplace_back(this->toplevel + "/packages");
if (!this->PkgsDirsVector.empty()) {
- for (std::vector<std::string>::iterator it =
- this->PkgsDirsVector.begin();
- it != this->PkgsDirsVector.end(); ++it) {
- ifwCmd += " -p " + *it;
+ for (std::string const& it : this->PkgsDirsVector) {
+ ifwCmd.emplace_back("-p");
+ ifwCmd.emplace_back(it);
+ }
+ }
+
+ if (!this->RepoDirsVector.empty()) {
+ if (!this->IsVersionLess("3.1")) {
+ for (std::string const& rd : this->RepoDirsVector) {
+ ifwCmd.emplace_back("--repository");
+ ifwCmd.emplace_back(rd);
+ }
+ } else {
+ cmCPackIFWLogger(WARNING,
+ "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" "
+ << "variable is set, but content will be skipped, "
+ << "because this feature available only since "
+ << "QtIFW 3.1. Please update your QtIFW instance."
+ << std::endl);
}
}
if (this->OnlineOnly) {
- ifwCmd += " --online-only";
+ ifwCmd.emplace_back("--online-only");
} else if (!this->DownloadedPackages.empty() &&
!this->Installer.RemoteRepositories.empty()) {
- ifwCmd += " -e ";
- std::set<cmCPackIFWPackage*>::iterator it =
- this->DownloadedPackages.begin();
- ifwCmd += (*it)->Name;
+ ifwCmd.emplace_back("-e");
+ auto it = this->DownloadedPackages.begin();
+ ifwArg = (*it)->Name;
++it;
while (it != this->DownloadedPackages.end()) {
- ifwCmd += "," + (*it)->Name;
+ ifwArg += "," + (*it)->Name;
++it;
}
+ ifwCmd.emplace_back(ifwArg);
} else if (!this->DependentPackages.empty()) {
- ifwCmd += " -i ";
+ ifwCmd.emplace_back("-i");
+ ifwArg.clear();
// Binary
- std::set<cmCPackIFWPackage*>::iterator bit =
- this->BinaryPackages.begin();
+ auto bit = this->BinaryPackages.begin();
while (bit != this->BinaryPackages.end()) {
- ifwCmd += (*bit)->Name + ",";
+ ifwArg += (*bit)->Name + ",";
++bit;
}
// Depend
- DependenceMap::iterator it = this->DependentPackages.begin();
- ifwCmd += it->second.Name;
+ auto it = this->DependentPackages.begin();
+ ifwArg += it->second.Name;
++it;
while (it != this->DependentPackages.end()) {
- ifwCmd += "," + it->second.Name;
+ ifwArg += "," + it->second.Name;
++it;
}
+ ifwCmd.emplace_back(ifwArg);
}
// TODO: set correct name for multipackages
if (!this->packageFileNames.empty()) {
- ifwCmd += " " + this->packageFileNames[0];
+ ifwCmd.emplace_back(this->packageFileNames[0]);
} else {
- ifwCmd += " installer";
+ ifwCmd.emplace_back("installer" + this->OutputExtension);
}
- cmCPackIFWLogger(VERBOSE, "Execute: " << ifwCmd << std::endl);
+ cmCPackIFWLogger(VERBOSE,
+ "Execute: " << cmSystemTools::PrintSingleCommand(ifwCmd)
+ << std::endl);
std::string output;
int retVal = 1;
cmCPackIFWLogger(OUTPUT, "- Generate package" << std::endl);
- bool res = cmSystemTools::RunSingleCommand(ifwCmd.c_str(), &output,
- &output, &retVal, CM_NULLPTR,
- this->GeneratorVerbose, 0);
+ bool res = cmSystemTools::RunSingleCommand(
+ ifwCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
+ cmDuration::zero());
if (!res || retVal) {
- cmGeneratedFileStream ofs(ifwTmpFile.c_str());
- ofs << "# Run command: " << ifwCmd << std::endl
+ cmGeneratedFileStream ofs(ifwTmpFile);
+ ofs << "# Run command: " << cmSystemTools::PrintSingleCommand(ifwCmd)
+ << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
- cmCPackIFWLogger(ERROR, "Problem running IFW command: "
- << ifwCmd << std::endl
- << "Please check " << ifwTmpFile << " for errors"
- << std::endl);
+ cmCPackIFWLogger(
+ ERROR,
+ "Problem running IFW command: "
+ << cmSystemTools::PrintSingleCommand(ifwCmd) << std::endl
+ << "Please check \"" << ifwTmpFile << "\" for errors" << std::endl);
return 0;
}
}
@@ -205,7 +255,7 @@ const char* cmCPackIFWGenerator::GetPackagingInstallPrefix()
const char* cmCPackIFWGenerator::GetOutputExtension()
{
- return this->ExecutableSuffix.c_str();
+ return this->OutputExtension.c_str();
}
int cmCPackIFWGenerator::InitializeInternal()
@@ -224,15 +274,16 @@ int cmCPackIFWGenerator::InitializeInternal()
// Look 'binarycreator' executable (needs)
const char* BinCreatorStr = this->GetOption(BinCreatorOpt);
- if (!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr)) {
- this->BinCreator = "";
+ if (!BinCreatorStr || cmIsNOTFOUND(BinCreatorStr)) {
+ this->BinCreator.clear();
} else {
this->BinCreator = BinCreatorStr;
}
if (this->BinCreator.empty()) {
- cmCPackIFWLogger(ERROR, "Cannot find QtIFW compiler \"binarycreator\": "
- "likely it is not installed, or not in your PATH"
+ cmCPackIFWLogger(ERROR,
+ "Cannot find QtIFW compiler \"binarycreator\": "
+ "likely it is not installed, or not in your PATH"
<< std::endl);
return 0;
}
@@ -240,8 +291,8 @@ int cmCPackIFWGenerator::InitializeInternal()
// Look 'repogen' executable (optional)
const char* RepoGenStr = this->GetOption(RepoGenOpt);
- if (!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr)) {
- this->RepoGen = "";
+ if (!RepoGenStr || cmIsNOTFOUND(RepoGenStr)) {
+ this->RepoGen.clear();
} else {
this->RepoGen = RepoGenStr;
}
@@ -262,7 +313,14 @@ int cmCPackIFWGenerator::InitializeInternal()
// Additional packages dirs
this->PkgsDirsVector.clear();
if (const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) {
- cmSystemTools::ExpandListArgument(dirs, this->PkgsDirsVector);
+ cmExpandList(dirs, this->PkgsDirsVector);
+ }
+
+ // Additional repositories dirs
+ this->RepoDirsVector.clear();
+ if (const char* dirs =
+ this->GetOption("CPACK_IFW_REPOSITORIES_DIRECTORIES")) {
+ cmExpandList(dirs, this->RepoDirsVector);
}
// Installer
@@ -279,19 +337,17 @@ int cmCPackIFWGenerator::InitializeInternal()
// Repositories
if (const char* RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) {
- std::vector<std::string> RepoAllVector;
- cmSystemTools::ExpandListArgument(RepoAllStr, RepoAllVector);
- for (std::vector<std::string>::iterator rit = RepoAllVector.begin();
- rit != RepoAllVector.end(); ++rit) {
- this->GetRepository(*rit);
+ std::vector<std::string> RepoAllVector = cmExpandedList(RepoAllStr);
+ for (std::string const& r : RepoAllVector) {
+ this->GetRepository(r);
}
}
if (const char* ifwDownloadAll = this->GetOption("CPACK_IFW_DOWNLOAD_ALL")) {
- this->OnlineOnly = cmSystemTools::IsOn(ifwDownloadAll);
+ this->OnlineOnly = cmIsOn(ifwDownloadAll);
} else if (const char* cpackDownloadAll =
this->GetOption("CPACK_DOWNLOAD_ALL")) {
- this->OnlineOnly = cmSystemTools::IsOn(cpackDownloadAll);
+ this->OnlineOnly = cmIsOn(cpackDownloadAll);
} else {
this->OnlineOnly = false;
}
@@ -305,16 +361,29 @@ int cmCPackIFWGenerator::InitializeInternal()
}
// Executable suffix
- if (const char* optExeSuffix = this->GetOption("CMAKE_EXECUTABLE_SUFFIX")) {
- this->ExecutableSuffix = optExeSuffix;
- if (this->ExecutableSuffix.empty()) {
- std::string sysName(this->GetOption("CMAKE_SYSTEM_NAME"));
- if (sysName == "Linux") {
- this->ExecutableSuffix = ".run";
- }
- }
+ std::string exeSuffix(this->GetOption("CMAKE_EXECUTABLE_SUFFIX"));
+ std::string sysName(this->GetOption("CMAKE_SYSTEM_NAME"));
+ if (sysName == "Linux") {
+ this->ExecutableSuffix = ".run";
+ } else if (sysName == "Windows") {
+ this->ExecutableSuffix = ".exe";
+ } else if (sysName == "Darwin") {
+ this->ExecutableSuffix = ".app";
} else {
- this->ExecutableSuffix = this->cmCPackGenerator::GetOutputExtension();
+ this->ExecutableSuffix = exeSuffix;
+ }
+
+ // Output extension
+ if (const char* optOutExt =
+ this->GetOption("CPACK_IFW_PACKAGE_FILE_EXTENSION")) {
+ this->OutputExtension = optOutExt;
+ } else if (sysName == "Darwin") {
+ this->OutputExtension = ".dmg";
+ } else {
+ this->OutputExtension = this->ExecutableSuffix;
+ }
+ if (this->OutputExtension.empty()) {
+ this->OutputExtension = this->cmCPackGenerator::GetOutputExtension();
}
return this->Superclass::InitializeInternal();
@@ -337,7 +406,7 @@ std::string cmCPackIFWGenerator::GetComponentInstallDirNameSuffix(
cmCPackComponent* cmCPackIFWGenerator::GetComponent(
const std::string& projectName, const std::string& componentName)
{
- ComponentsMap::iterator cit = this->Components.find(componentName);
+ auto cit = this->Components.find(componentName);
if (cit != this->Components.end()) {
return &(cit->second);
}
@@ -349,7 +418,7 @@ cmCPackComponent* cmCPackIFWGenerator::GetComponent(
}
std::string name = this->GetComponentPackageName(component);
- PackagesMap::iterator pit = this->Packages.find(name);
+ auto pit = this->Packages.find(name);
if (pit != this->Packages.end()) {
return component;
}
@@ -370,7 +439,8 @@ cmCPackComponent* cmCPackIFWGenerator::GetComponent(
}
} else {
this->Packages.erase(name);
- cmCPackIFWLogger(ERROR, "Cannot configure package \""
+ cmCPackIFWLogger(ERROR,
+ "Cannot configure package \""
<< name << "\" for component \"" << component->Name
<< "\"" << std::endl);
}
@@ -388,7 +458,7 @@ cmCPackComponentGroup* cmCPackIFWGenerator::GetComponentGroup(
}
std::string name = this->GetGroupPackageName(group);
- PackagesMap::iterator pit = this->Packages.find(name);
+ auto pit = this->Packages.find(name);
if (pit != this->Packages.end()) {
return group;
}
@@ -405,7 +475,8 @@ cmCPackComponentGroup* cmCPackIFWGenerator::GetComponentGroup(
this->BinaryPackages.insert(package);
} else {
this->Packages.erase(name);
- cmCPackIFWLogger(ERROR, "Cannot configure package \""
+ cmCPackIFWLogger(ERROR,
+ "Cannot configure package \""
<< name << "\" for component group \"" << group->Name
<< "\"" << std::endl);
}
@@ -518,23 +589,21 @@ std::string cmCPackIFWGenerator::GetComponentPackageName(
cmCPackIFWPackage* cmCPackIFWGenerator::GetGroupPackage(
cmCPackComponentGroup* group) const
{
- std::map<cmCPackComponentGroup*, cmCPackIFWPackage*>::const_iterator pit =
- this->GroupPackages.find(group);
- return pit != this->GroupPackages.end() ? pit->second : CM_NULLPTR;
+ auto pit = this->GroupPackages.find(group);
+ return pit != this->GroupPackages.end() ? pit->second : nullptr;
}
cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage(
cmCPackComponent* component) const
{
- std::map<cmCPackComponent*, cmCPackIFWPackage*>::const_iterator pit =
- this->ComponentPackages.find(component);
- return pit != this->ComponentPackages.end() ? pit->second : CM_NULLPTR;
+ auto pit = this->ComponentPackages.find(component);
+ return pit != this->ComponentPackages.end() ? pit->second : nullptr;
}
cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository(
const std::string& repositoryName)
{
- RepositoriesMap::iterator rit = this->Repositories.find(repositoryName);
+ auto rit = this->Repositories.find(repositoryName);
if (rit != this->Repositories.end()) {
return &(rit->second);
}
@@ -550,8 +619,9 @@ cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository(
}
} else {
this->Repositories.erase(repositoryName);
- repository = CM_NULLPTR;
- cmCPackIFWLogger(WARNING, "Invalid repository \""
+ repository = nullptr;
+ cmCPackIFWLogger(WARNING,
+ "Invalid repository \""
<< repositoryName << "\""
<< " configuration. Repository will be skipped."
<< std::endl);
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.h b/Source/CPack/IFW/cmCPackIFWGenerator.h
index 8348ceeec..86a73c83f 100644
--- a/Source/CPack/IFW/cmCPackIFWGenerator.h
+++ b/Source/CPack/IFW/cmCPackIFWGenerator.h
@@ -5,6 +5,11 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+
#include "cmCPackComponentGroup.h"
#include "cmCPackGenerator.h"
#include "cmCPackIFWCommon.h"
@@ -12,27 +17,24 @@
#include "cmCPackIFWPackage.h"
#include "cmCPackIFWRepository.h"
-#include <map>
-#include <set>
-#include <string>
-#include <vector>
-
/** \class cmCPackIFWGenerator
* \brief A generator for Qt Installer Framework tools
*
* http://qt-project.org/doc/qtinstallerframework/index.html
*/
-class cmCPackIFWGenerator : public cmCPackGenerator, public cmCPackIFWCommon
+class cmCPackIFWGenerator
+ : public cmCPackGenerator
+ , public cmCPackIFWCommon
{
public:
cmCPackTypeMacro(cmCPackIFWGenerator, cmCPackGenerator);
- typedef std::map<std::string, cmCPackIFWPackage> PackagesMap;
- typedef std::map<std::string, cmCPackIFWRepository> RepositoriesMap;
- typedef std::map<std::string, cmCPackComponent> ComponentsMap;
- typedef std::map<std::string, cmCPackComponentGroup> ComponentGoupsMap;
- typedef std::map<std::string, cmCPackIFWPackage::DependenceStruct>
- DependenceMap;
+ using PackagesMap = std::map<std::string, cmCPackIFWPackage>;
+ using RepositoriesMap = std::map<std::string, cmCPackIFWRepository>;
+ using ComponentsMap = std::map<std::string, cmCPackComponent>;
+ using ComponentGoupsMap = std::map<std::string, cmCPackComponentGroup>;
+ using DependenceMap =
+ std::map<std::string, cmCPackIFWPackage::DependenceStruct>;
using cmCPackIFWCommon::GetOption;
using cmCPackIFWCommon::IsOn;
@@ -47,7 +49,7 @@ public:
/**
* Destruct IFW generator
*/
- ~cmCPackIFWGenerator() CM_OVERRIDE;
+ ~cmCPackIFWGenerator() override;
protected:
// cmCPackGenerator reimplementation
@@ -56,18 +58,18 @@ protected:
* @brief Initialize generator
* @return 0 on failure
*/
- int InitializeInternal() CM_OVERRIDE;
- int PackageFiles() CM_OVERRIDE;
- const char* GetPackagingInstallPrefix() CM_OVERRIDE;
+ int InitializeInternal() override;
+ int PackageFiles() override;
+ const char* GetPackagingInstallPrefix() override;
/**
- * @brief Extension of binary installer
- * @return Executable suffix or value from default implementation
+ * @brief Target binary extension
+ * @return Executable suffix or disk image format
*/
- const char* GetOutputExtension() CM_OVERRIDE;
+ const char* GetOutputExtension() override;
std::string GetComponentInstallDirNameSuffix(
- const std::string& componentName) CM_OVERRIDE;
+ const std::string& componentName) override;
/**
* @brief Get Component
@@ -79,7 +81,7 @@ protected:
* @return Pointer to component
*/
cmCPackComponent* GetComponent(const std::string& projectName,
- const std::string& componentName) CM_OVERRIDE;
+ const std::string& componentName) override;
/**
* @brief Get group of component
@@ -91,12 +93,12 @@ protected:
* @return Pointer to component group
*/
cmCPackComponentGroup* GetComponentGroup(
- const std::string& projectName, const std::string& groupName) CM_OVERRIDE;
+ const std::string& projectName, const std::string& groupName) override;
- enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() const
- CM_OVERRIDE;
- bool SupportsAbsoluteDestination() const CM_OVERRIDE;
- bool SupportsComponentInstallation() const CM_OVERRIDE;
+ enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir()
+ const override;
+ bool SupportsAbsoluteDestination() const override;
+ bool SupportsComponentInstallation() const override;
protected:
// Methods
@@ -143,10 +145,12 @@ private:
std::string BinCreator;
std::string FrameworkVersion;
std::string ExecutableSuffix;
+ std::string OutputExtension;
bool OnlineOnly;
bool ResolveDuplicateNames;
std::vector<std::string> PkgsDirsVector;
+ std::vector<std::string> RepoDirsVector;
};
#endif
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
index 288e924e5..4bad598e9 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
@@ -2,29 +2,29 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackIFWInstaller.h"
+#include <cstddef>
+#include <sstream>
+#include <utility>
+
#include "cmCPackIFWCommon.h"
#include "cmCPackIFWGenerator.h"
#include "cmCPackIFWPackage.h"
#include "cmCPackIFWRepository.h"
#include "cmCPackLog.h" // IWYU pragma: keep
#include "cmGeneratedFileStream.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmXMLParser.h"
#include "cmXMLWriter.h"
-#include <sstream>
-#include <stddef.h>
-#include <utility>
-
-cmCPackIFWInstaller::cmCPackIFWInstaller()
-{
-}
+cmCPackIFWInstaller::cmCPackIFWInstaller() = default;
void cmCPackIFWInstaller::printSkippedOptionWarning(
const std::string& optionName, const std::string& optionValue)
{
cmCPackIFWLogger(
- WARNING, "Option "
+ WARNING,
+ "Option "
<< optionName << " is set to \"" << optionValue
<< "\" but will be skipped because the specified file does not exist."
<< std::endl);
@@ -93,6 +93,15 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
}
}
+ // RemoveTargetDir
+ if (this->IsSetToOff("CPACK_IFW_PACKAGE_REMOVE_TARGET_DIR")) {
+ this->RemoveTargetDir = "false";
+ } else if (this->IsOn("CPACK_IFW_PACKAGE_REMOVE_TARGET_DIR")) {
+ this->RemoveTargetDir = "true";
+ } else {
+ this->RemoveTargetDir.clear();
+ }
+
// Logo
if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_LOGO")) {
if (cmSystemTools::FileExists(option)) {
@@ -137,12 +146,22 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
if (this->WizardStyle != "Modern" && this->WizardStyle != "Aero" &&
this->WizardStyle != "Mac" && this->WizardStyle != "Classic") {
cmCPackIFWLogger(
- WARNING, "Option CPACK_IFW_PACKAGE_WIZARD_STYLE has unknown value \""
+ WARNING,
+ "Option CPACK_IFW_PACKAGE_WIZARD_STYLE has unknown value \""
<< option << "\". Expected values are: Modern, Aero, Mac, Classic."
<< std::endl);
}
}
+ // StyleSheet
+ if (const char* option = this->GetOption("CPACK_IFW_PACKAGE_STYLE_SHEET")) {
+ if (cmSystemTools::FileExists(option)) {
+ this->StyleSheet = option;
+ } else {
+ this->printSkippedOptionWarning("CPACK_IFW_PACKAGE_STYLE_SHEET", option);
+ }
+ }
+
// WizardDefaultWidth
if (const char* option =
this->GetOption("CPACK_IFW_PACKAGE_WIZARD_DEFAULT_WIDTH")) {
@@ -174,8 +193,8 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
this->TargetDir = optIFW_TARGET_DIRECTORY;
} else if (const char* optPACKAGE_INSTALL_DIRECTORY =
this->GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY")) {
- this->TargetDir = "@ApplicationsDir@/";
- this->TargetDir += optPACKAGE_INSTALL_DIRECTORY;
+ this->TargetDir =
+ cmStrCat("@ApplicationsDir@/", optPACKAGE_INSTALL_DIRECTORY);
} else {
this->TargetDir = "@RootDir@/usr/local";
}
@@ -226,8 +245,7 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
if (const char* optIFW_PACKAGE_RESOURCES =
this->GetOption("CPACK_IFW_PACKAGE_RESOURCES")) {
this->Resources.clear();
- cmSystemTools::ExpandListArgument(optIFW_PACKAGE_RESOURCES,
- this->Resources);
+ cmExpandList(optIFW_PACKAGE_RESOURCES, this->Resources);
}
}
@@ -262,7 +280,7 @@ public:
std::string path, basePath;
protected:
- void StartElement(const std::string& name, const char** /*atts*/) CM_OVERRIDE
+ void StartElement(const std::string& name, const char** /*atts*/) override
{
this->file = name == "file";
if (file) {
@@ -270,21 +288,20 @@ protected:
}
}
- void CharacterDataHandler(const char* data, int length) CM_OVERRIDE
+ void CharacterDataHandler(const char* data, int length) override
{
if (this->file) {
std::string content(data, data + length);
- content = cmSystemTools::TrimWhitespace(content);
+ content = cmTrimWhitespace(content);
std::string source = this->basePath + "/" + content;
std::string destination = this->path + "/" + content;
- if (!cmSystemTools::CopyFileIfDifferent(source.data(),
- destination.data())) {
+ if (!cmSystemTools::CopyFileIfDifferent(source, destination)) {
this->hasErrors = true;
}
}
}
- void EndElement(const std::string& /*name*/) CM_OVERRIDE {}
+ void EndElement(const std::string& /*name*/) override {}
};
void cmCPackIFWInstaller::GenerateInstallerFile()
@@ -295,7 +312,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
}
// Output stream
- cmGeneratedFileStream fout((this->Directory + "/config/config.xml").data());
+ cmGeneratedFileStream fout(this->Directory + "/config/config.xml");
cmXMLWriter xout(fout);
xout.StartDocument();
@@ -373,6 +390,14 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
xout.Element("WizardStyle", this->WizardStyle);
}
+ // Stylesheet
+ if (!this->StyleSheet.empty()) {
+ std::string name = cmSystemTools::GetFilenameName(this->StyleSheet);
+ std::string path = this->Directory + "/config/" + name;
+ cmsys::SystemTools::CopyFileIfDifferent(this->StyleSheet, path);
+ xout.Element("StyleSheet", name);
+ }
+
// WizardDefaultWidth
if (!this->WizardDefaultWidth.empty()) {
xout.Element("WizardDefaultWidth", this->WizardDefaultWidth);
@@ -406,9 +431,8 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
// Remote repositories
if (!this->RemoteRepositories.empty()) {
xout.StartElement("RemoteRepositories");
- for (RepositoriesVector::iterator rit = this->RemoteRepositories.begin();
- rit != this->RemoteRepositories.end(); ++rit) {
- (*rit)->WriteRepositoryConfig(xout);
+ for (cmCPackIFWRepository* r : this->RemoteRepositories) {
+ r->WriteRepositoryConfig(xout);
}
xout.EndElement();
}
@@ -423,6 +447,10 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
xout.Element("MaintenanceToolIniFile", this->MaintenanceToolIniFile);
}
+ if (!this->RemoveTargetDir.empty()) {
+ xout.Element("RemoveTargetDir", this->RemoveTargetDir);
+ }
+
// Different allows
if (this->IsVersionLess("2.0")) {
// CPack IFW default policy
@@ -455,9 +483,10 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
std::string name = cmSystemTools::GetFilenameName(this->Resources[i]);
std::string path = this->Directory + "/resources/" + name;
cmsys::SystemTools::CopyFileIfDifferent(this->Resources[i], path);
- resources.push_back(name);
+ resources.push_back(std::move(name));
} else {
- cmCPackIFWLogger(WARNING, "Can't copy resources from \""
+ cmCPackIFWLogger(WARNING,
+ "Can't copy resources from \""
<< this->Resources[i]
<< "\". Resource will be skipped." << std::endl);
}
@@ -492,9 +521,8 @@ void cmCPackIFWInstaller::GeneratePackageFiles()
}
// Generate packages meta information
- for (PackagesMap::iterator pit = this->Packages.begin();
- pit != this->Packages.end(); ++pit) {
- cmCPackIFWPackage* package = pit->second;
+ for (auto& p : this->Packages) {
+ cmCPackIFWPackage* package = p.second;
package->GeneratePackageFile();
}
}
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.h b/Source/CPack/IFW/cmCPackIFWInstaller.h
index b635f4222..8b3f96af8 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.h
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.h
@@ -5,12 +5,12 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmCPackIFWCommon.h"
-
#include <map>
#include <string>
#include <vector>
+#include "cmCPackIFWCommon.h"
+
class cmCPackIFWPackage;
class cmCPackIFWRepository;
@@ -22,8 +22,8 @@ class cmCPackIFWInstaller : public cmCPackIFWCommon
public:
// Types
- typedef std::map<std::string, cmCPackIFWPackage*> PackagesMap;
- typedef std::vector<cmCPackIFWRepository*> RepositoriesVector;
+ using PackagesMap = std::map<std::string, cmCPackIFWPackage*>;
+ using RepositoriesVector = std::vector<cmCPackIFWRepository*>;
public:
// Constructor
@@ -72,6 +72,9 @@ public:
/// Wizard style name
std::string WizardStyle;
+ /// Filename for a style sheet
+ std::string StyleSheet;
+
/// Wizard width
std::string WizardDefaultWidth;
@@ -99,6 +102,10 @@ public:
/// Set to true if the installation path can contain non-ASCII characters
std::string AllowNonAsciiCharacters;
+ /// Set to false if the target directory should not be deleted when
+ /// uninstalling
+ std::string RemoveTargetDir;
+
/// Set to false if the installation path cannot contain space characters
std::string AllowSpaceInPath;
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx
index c5311c31c..9a9cd5678 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.cxx
+++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx
@@ -2,21 +2,22 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackIFWPackage.h"
+#include <cstddef>
+#include <map>
+#include <sstream>
+#include <utility>
+
#include "cmCPackComponentGroup.h"
#include "cmCPackIFWCommon.h"
#include "cmCPackIFWGenerator.h"
#include "cmCPackIFWInstaller.h"
#include "cmCPackLog.h" // IWYU pragma: keep
#include "cmGeneratedFileStream.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTimestamp.h"
#include "cmXMLWriter.h"
-#include <map>
-#include <sstream>
-#include <stddef.h>
-#include <utility>
-
//---------------------------------------------------------- CompareStruct ---
cmCPackIFWPackage::CompareStruct::CompareStruct()
: Type(cmCPackIFWPackage::CompareNone)
@@ -24,9 +25,7 @@ cmCPackIFWPackage::CompareStruct::CompareStruct()
}
//------------------------------------------------------- DependenceStruct ---
-cmCPackIFWPackage::DependenceStruct::DependenceStruct()
-{
-}
+cmCPackIFWPackage::DependenceStruct::DependenceStruct() = default;
cmCPackIFWPackage::DependenceStruct::DependenceStruct(
const std::string& dependence)
@@ -92,7 +91,7 @@ std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const
//------------------------------------------------------ cmCPackIFWPackage ---
cmCPackIFWPackage::cmCPackIFWPackage()
- : Installer(CM_NULLPTR)
+ : Installer(nullptr)
{
}
@@ -111,25 +110,25 @@ void cmCPackIFWPackage::DefaultConfiguration()
{
this->DisplayName.clear();
this->Description.clear();
- this->Version = "";
- this->ReleaseDate = "";
- this->Script = "";
+ this->Version.clear();
+ this->ReleaseDate.clear();
+ this->Script.clear();
this->Licenses.clear();
this->UserInterfaces.clear();
this->Translations.clear();
- this->SortingPriority = "";
- this->UpdateText = "";
- this->Default = "";
- this->Essential = "";
- this->Virtual = "";
- this->ForcedInstallation = "";
- this->RequiresAdminRights = "";
+ this->SortingPriority.clear();
+ this->UpdateText.clear();
+ this->Default.clear();
+ this->Essential.clear();
+ this->Virtual.clear();
+ this->ForcedInstallation.clear();
+ this->RequiresAdminRights.clear();
}
-// Defaul configuration (all in one package)
+// Default configuration (all in one package)
int cmCPackIFWPackage::ConfigureFromOptions()
{
- // Restore defaul configuration
+ // Restore default configuration
this->DefaultConfiguration();
// Name
@@ -168,7 +167,7 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
return 0;
}
- // Restore defaul configuration
+ // Restore default configuration
this->DefaultConfiguration();
std::string prefix = "CPACK_IFW_COMPONENT_" +
@@ -198,22 +197,20 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
// User interfaces
if (const char* option = this->GetOption(prefix + "USER_INTERFACES")) {
this->UserInterfaces.clear();
- cmSystemTools::ExpandListArgument(option, this->UserInterfaces);
+ cmExpandList(option, this->UserInterfaces);
}
// CMake dependencies
if (!component->Dependencies.empty()) {
- std::vector<cmCPackComponent*>::iterator dit;
- for (dit = component->Dependencies.begin();
- dit != component->Dependencies.end(); ++dit) {
- this->Dependencies.insert(this->Generator->ComponentPackages[*dit]);
+ for (cmCPackComponent* dep : component->Dependencies) {
+ this->Dependencies.insert(this->Generator->ComponentPackages[dep]);
}
}
// Licenses
if (const char* option = this->GetOption(prefix + "LICENSES")) {
this->Licenses.clear();
- cmSystemTools::ExpandListArgument(option, this->Licenses);
+ cmExpandList(option, this->Licenses);
if (this->Licenses.size() % 2 != 0) {
cmCPackIFWLogger(
WARNING,
@@ -228,7 +225,8 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
if (const char* option = this->GetOption(prefix + "PRIORITY")) {
this->SortingPriority = option;
cmCPackIFWLogger(
- WARNING, "The \"PRIORITY\" option is set "
+ WARNING,
+ "The \"PRIORITY\" option is set "
<< "for component \"" << component->Name << "\", but there option is "
<< "deprecated. Please use \"SORTING_PRIORITY\" option instead."
<< std::endl);
@@ -257,7 +255,7 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
return 0;
}
- // Restore defaul configuration
+ // Restore default configuration
this->DefaultConfiguration();
std::string prefix = "CPACK_IFW_COMPONENT_GROUP_" +
@@ -284,13 +282,13 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
// User interfaces
if (const char* option = this->GetOption(prefix + "USER_INTERFACES")) {
this->UserInterfaces.clear();
- cmSystemTools::ExpandListArgument(option, this->UserInterfaces);
+ cmExpandList(option, this->UserInterfaces);
}
// Licenses
if (const char* option = this->GetOption(prefix + "LICENSES")) {
this->Licenses.clear();
- cmSystemTools::ExpandListArgument(option, this->Licenses);
+ cmExpandList(option, this->Licenses);
if (this->Licenses.size() % 2 != 0) {
cmCPackIFWLogger(
WARNING,
@@ -305,7 +303,8 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
if (const char* option = this->GetOption(prefix + "PRIORITY")) {
this->SortingPriority = option;
cmCPackIFWLogger(
- WARNING, "The \"PRIORITY\" option is set "
+ WARNING,
+ "The \"PRIORITY\" option is set "
<< "for component group \"" << group->Name
<< "\", but there option is "
<< "deprecated. Please use \"SORTING_PRIORITY\" option instead."
@@ -359,7 +358,7 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
if (this->IsSetToEmpty(option)) {
this->DisplayName.clear();
} else if (const char* value = this->GetOption(option)) {
- this->ExpandListArgument(value, this->DisplayName);
+ cmCPackIFWPackage::ExpandListArgument(value, this->DisplayName);
}
// Description
@@ -367,7 +366,7 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
if (this->IsSetToEmpty(option)) {
this->Description.clear();
} else if (const char* value = this->GetOption(option)) {
- this->ExpandListArgument(value, this->Description);
+ cmCPackIFWPackage::ExpandListArgument(value, this->Description);
}
// Release date
@@ -400,22 +399,21 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
this->Translations.clear();
} else if (const char* value = this->GetOption(option)) {
this->Translations.clear();
- cmSystemTools::ExpandListArgument(value, this->Translations);
+ cmExpandList(value, this->Translations);
}
// QtIFW dependencies
std::vector<std::string> deps;
option = prefix + "DEPENDS";
if (const char* value = this->GetOption(option)) {
- cmSystemTools::ExpandListArgument(value, deps);
+ cmExpandList(value, deps);
}
option = prefix + "DEPENDENCIES";
if (const char* value = this->GetOption(option)) {
- cmSystemTools::ExpandListArgument(value, deps);
+ cmExpandList(value, deps);
}
- for (std::vector<std::string>::iterator dit = deps.begin();
- dit != deps.end(); ++dit) {
- DependenceStruct dep(*dit);
+ for (std::string const& d : deps) {
+ DependenceStruct dep(d);
if (this->Generator->Packages.count(dep.Name)) {
cmCPackIFWPackage& depPkg = this->Generator->Packages[dep.Name];
dep.Name = depPkg.Name;
@@ -433,11 +431,9 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
if (this->IsSetToEmpty(option)) {
this->AlienAutoDependOn.clear();
} else if (const char* value = this->GetOption(option)) {
- std::vector<std::string> depsOn;
- cmSystemTools::ExpandListArgument(value, depsOn);
- for (std::vector<std::string>::iterator dit = depsOn.begin();
- dit != depsOn.end(); ++dit) {
- DependenceStruct dep(*dit);
+ std::vector<std::string> depsOn = cmExpandedList(value);
+ for (std::string const& d : depsOn) {
+ DependenceStruct dep(d);
if (this->Generator->Packages.count(dep.Name)) {
cmCPackIFWPackage& depPkg = this->Generator->Packages[dep.Name];
dep.Name = depPkg.Name;
@@ -486,6 +482,15 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
this->ForcedInstallation = "false";
}
+ // Replaces
+ option = prefix + "REPLACES";
+ if (this->IsSetToEmpty(option)) {
+ this->Replaces.clear();
+ } else if (const char* value = this->GetOption(option)) {
+ this->Replaces.clear();
+ cmExpandList(value, this->Replaces);
+ }
+
// Requires admin rights
option = prefix + "REQUIRES_ADMIN_RIGHTS";
if (this->IsSetToEmpty(option)) {
@@ -496,6 +501,16 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
this->RequiresAdminRights = "false";
}
+ // Checkable
+ option = prefix + "CHECKABLE";
+ if (this->IsSetToEmpty(option)) {
+ this->Checkable.clear();
+ } else if (this->IsOn(option)) {
+ this->Checkable = "true";
+ } else if (this->IsSetToOff(option)) {
+ this->Checkable = "false";
+ }
+
return 1;
}
@@ -511,7 +526,7 @@ void cmCPackIFWPackage::GeneratePackageFile()
}
// Output stream
- cmGeneratedFileStream fout((this->Directory + "/meta/package.xml").data());
+ cmGeneratedFileStream fout(this->Directory + "/meta/package.xml");
cmXMLWriter xout(fout);
xout.StartDocument();
@@ -521,26 +536,22 @@ void cmCPackIFWPackage::GeneratePackageFile()
xout.StartElement("Package");
// DisplayName (with translations)
- for (std::map<std::string, std::string>::iterator it =
- this->DisplayName.begin();
- it != this->DisplayName.end(); ++it) {
+ for (auto const& dn : this->DisplayName) {
xout.StartElement("DisplayName");
- if (!it->first.empty()) {
- xout.Attribute("xml:lang", it->first);
+ if (!dn.first.empty()) {
+ xout.Attribute("xml:lang", dn.first);
}
- xout.Content(it->second);
+ xout.Content(dn.second);
xout.EndElement();
}
// Description (with translations)
- for (std::map<std::string, std::string>::iterator it =
- this->Description.begin();
- it != this->Description.end(); ++it) {
+ for (auto const& d : this->Description) {
xout.StartElement("Description");
- if (!it->first.empty()) {
- xout.Attribute("xml:lang", it->first);
+ if (!d.first.empty()) {
+ xout.Attribute("xml:lang", d.first);
}
- xout.Content(it->second);
+ xout.Content(d.second);
xout.EndElement();
}
@@ -568,51 +579,48 @@ void cmCPackIFWPackage::GeneratePackageFile()
// User Interfaces (copy to meta dir)
std::vector<std::string> userInterfaces = UserInterfaces;
- for (size_t i = 0; i < userInterfaces.size(); i++) {
- std::string name = cmSystemTools::GetFilenameName(userInterfaces[i]);
+ for (std::string& userInterface : userInterfaces) {
+ std::string name = cmSystemTools::GetFilenameName(userInterface);
std::string path = this->Directory + "/meta/" + name;
- cmsys::SystemTools::CopyFileIfDifferent(userInterfaces[i], path);
- userInterfaces[i] = name;
+ cmsys::SystemTools::CopyFileIfDifferent(userInterface, path);
+ userInterface = name;
}
if (!userInterfaces.empty()) {
xout.StartElement("UserInterfaces");
- for (size_t i = 0; i < userInterfaces.size(); i++) {
- xout.Element("UserInterface", userInterfaces[i]);
+ for (std::string const& userInterface : userInterfaces) {
+ xout.Element("UserInterface", userInterface);
}
xout.EndElement();
}
// Translations (copy to meta dir)
std::vector<std::string> translations = Translations;
- for (size_t i = 0; i < translations.size(); i++) {
- std::string name = cmSystemTools::GetFilenameName(translations[i]);
+ for (std::string& translation : translations) {
+ std::string name = cmSystemTools::GetFilenameName(translation);
std::string path = this->Directory + "/meta/" + name;
- cmsys::SystemTools::CopyFileIfDifferent(translations[i], path);
- translations[i] = name;
+ cmsys::SystemTools::CopyFileIfDifferent(translation, path);
+ translation = name;
}
if (!translations.empty()) {
xout.StartElement("Translations");
- for (size_t i = 0; i < translations.size(); i++) {
- xout.Element("Translation", translations[i]);
+ for (std::string const& translation : translations) {
+ xout.Element("Translation", translation);
}
xout.EndElement();
}
// Dependencies
std::set<DependenceStruct> compDepSet;
- for (std::set<DependenceStruct*>::iterator ait =
- this->AlienDependencies.begin();
- ait != this->AlienDependencies.end(); ++ait) {
- compDepSet.insert(*(*ait));
+ for (DependenceStruct* ad : this->AlienDependencies) {
+ compDepSet.insert(*ad);
}
- for (std::set<cmCPackIFWPackage*>::iterator it = this->Dependencies.begin();
- it != this->Dependencies.end(); ++it) {
- compDepSet.insert(DependenceStruct((*it)->Name));
+ for (cmCPackIFWPackage* d : this->Dependencies) {
+ compDepSet.insert(DependenceStruct(d->Name));
}
// Write dependencies
if (!compDepSet.empty()) {
std::ostringstream dependencies;
- std::set<DependenceStruct>::iterator it = compDepSet.begin();
+ auto it = compDepSet.begin();
dependencies << it->NameWithCompare();
++it;
while (it != compDepSet.end()) {
@@ -624,15 +632,13 @@ void cmCPackIFWPackage::GeneratePackageFile()
// Automatic dependency on
std::set<DependenceStruct> compAutoDepSet;
- for (std::set<DependenceStruct*>::iterator ait =
- this->AlienAutoDependOn.begin();
- ait != this->AlienAutoDependOn.end(); ++ait) {
- compAutoDepSet.insert(*(*ait));
+ for (DependenceStruct* aad : this->AlienAutoDependOn) {
+ compAutoDepSet.insert(*aad);
}
// Write automatic dependency on
if (!compAutoDepSet.empty()) {
std::ostringstream dependencies;
- std::set<DependenceStruct>::iterator it = compAutoDepSet.begin();
+ auto it = compAutoDepSet.begin();
dependencies << it->NameWithCompare();
++it;
while (it != compAutoDepSet.end()) {
@@ -665,6 +671,19 @@ void cmCPackIFWPackage::GeneratePackageFile()
xout.Element("ForcedInstallation", this->ForcedInstallation);
}
+ // Replaces
+ if (!this->Replaces.empty()) {
+ std::ostringstream replaces;
+ auto it = this->Replaces.begin();
+ replaces << *it;
+ ++it;
+ while (it != this->Replaces.end()) {
+ replaces << "," << *it;
+ ++it;
+ }
+ xout.Element("Replaces", replaces.str());
+ }
+
if (!this->RequiresAdminRights.empty()) {
xout.Element("RequiresAdminRights", this->RequiresAdminRights);
}
@@ -685,6 +704,11 @@ void cmCPackIFWPackage::GeneratePackageFile()
xout.Element("SortingPriority", this->SortingPriority);
}
+ // Checkable
+ if (!this->Checkable.empty()) {
+ xout.Element("Checkable", this->Checkable);
+ }
+
xout.EndElement();
xout.EndDocument();
}
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h
index cec59b03c..6a4a170a5 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.h
+++ b/Source/CPack/IFW/cmCPackIFWPackage.h
@@ -5,13 +5,13 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmCPackIFWCommon.h"
-
#include <map>
#include <set>
#include <string>
#include <vector>
+#include "cmCPackIFWCommon.h"
+
class cmCPackComponent;
class cmCPackComponentGroup;
class cmCPackIFWInstaller;
@@ -114,9 +114,15 @@ public:
/// Determines that the package must always be installed
std::string ForcedInstallation;
+ /// List of components to replace
+ std::vector<std::string> Replaces;
+
/// Package needs to be installed with elevated permissions
std::string RequiresAdminRights;
+ /// Set to false if you want to hide the checkbox for an item
+ std::string Checkable;
+
public:
// Internal implementation
diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx
index b115db057..a6965491e 100644
--- a/Source/CPack/IFW/cmCPackIFWRepository.cxx
+++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx
@@ -2,14 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackIFWRepository.h"
+#include <cstddef>
+
#include "cmCPackIFWGenerator.h"
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
#include "cmXMLParser.h"
#include "cmXMLWriter.h"
-#include <stddef.h>
-
cmCPackIFWRepository::cmCPackIFWRepository()
: Update(cmCPackIFWRepository::None)
{
@@ -62,49 +62,49 @@ bool cmCPackIFWRepository::ConfigureFromOptions()
if (const char* url = this->GetOption(prefix + "URL")) {
this->Url = url;
} else {
- this->Url = "";
+ this->Url.clear();
}
// Old url
if (const char* oldUrl = this->GetOption(prefix + "OLD_URL")) {
this->OldUrl = oldUrl;
} else {
- this->OldUrl = "";
+ this->OldUrl.clear();
}
// New url
if (const char* newUrl = this->GetOption(prefix + "NEW_URL")) {
this->NewUrl = newUrl;
} else {
- this->NewUrl = "";
+ this->NewUrl.clear();
}
// Enabled
if (this->IsOn(prefix + "DISABLED")) {
this->Enabled = "0";
} else {
- this->Enabled = "";
+ this->Enabled.clear();
}
// Username
if (const char* username = this->GetOption(prefix + "USERNAME")) {
this->Username = username;
} else {
- this->Username = "";
+ this->Username.clear();
}
// Password
if (const char* password = this->GetOption(prefix + "PASSWORD")) {
this->Password = password;
} else {
- this->Password = "";
+ this->Password.clear();
}
// DisplayName
if (const char* displayName = this->GetOption(prefix + "DISPLAY_NAME")) {
this->DisplayName = displayName;
} else {
- this->DisplayName = "";
+ this->DisplayName.clear();
}
return this->IsValid();
@@ -128,7 +128,7 @@ public:
bool patched;
protected:
- void StartElement(const std::string& name, const char** atts) CM_OVERRIDE
+ void StartElement(const std::string& name, const char** atts) override
{
this->xout.StartElement(name);
this->StartFragment(atts);
@@ -143,7 +143,7 @@ protected:
}
}
- void EndElement(const std::string& name) CM_OVERRIDE
+ void EndElement(const std::string& name) override
{
if (name == "Updates" && !this->patched) {
this->repository->WriteRepositoryUpdates(this->xout);
@@ -159,10 +159,10 @@ protected:
}
}
- void CharacterDataHandler(const char* data, int length) CM_OVERRIDE
+ void CharacterDataHandler(const char* data, int length) override
{
std::string content(data, data + length);
- if (content == "" || content == " " || content == " " ||
+ if (content.empty() || content == " " || content == " " ||
content == "\n") {
return;
}
@@ -183,7 +183,7 @@ bool cmCPackIFWRepository::PatchUpdatesXml()
this->Directory + "/repository/UpdatesPatch.xml";
// Output stream
- cmGeneratedFileStream fout(updatesPatchXml.data());
+ cmGeneratedFileStream fout(updatesPatchXml);
cmXMLWriter xout(fout);
xout.StartDocument();
@@ -200,7 +200,7 @@ bool cmCPackIFWRepository::PatchUpdatesXml()
fout.Close();
- return cmSystemTools::RenameFile(updatesPatchXml.data(), updatesXml.data());
+ return cmSystemTools::RenameFile(updatesPatchXml, updatesXml);
}
void cmCPackIFWRepository::WriteRepositoryConfig(cmXMLWriter& xout)
@@ -279,9 +279,8 @@ void cmCPackIFWRepository::WriteRepositoryUpdates(cmXMLWriter& xout)
{
if (!this->RepositoryUpdate.empty()) {
xout.StartElement("RepositoryUpdate");
- for (RepositoriesVector::iterator rit = this->RepositoryUpdate.begin();
- rit != this->RepositoryUpdate.end(); ++rit) {
- (*rit)->WriteRepositoryUpdate(xout);
+ for (cmCPackIFWRepository* r : this->RepositoryUpdate) {
+ r->WriteRepositoryUpdate(xout);
}
xout.EndElement();
}
diff --git a/Source/CPack/IFW/cmCPackIFWRepository.h b/Source/CPack/IFW/cmCPackIFWRepository.h
index 227cfae7a..c29398124 100644
--- a/Source/CPack/IFW/cmCPackIFWRepository.h
+++ b/Source/CPack/IFW/cmCPackIFWRepository.h
@@ -5,11 +5,11 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmCPackIFWCommon.h"
-
#include <string>
#include <vector>
+#include "cmCPackIFWCommon.h"
+
class cmXMLWriter;
/** \class cmCPackIFWRepository
@@ -28,7 +28,7 @@ public:
Replace
};
- typedef std::vector<cmCPackIFWRepository*> RepositoriesVector;
+ using RepositoriesVector = std::vector<cmCPackIFWRepository*>;
public:
// Constructor
diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx
index b48bf1214..21d27a02d 100644
--- a/Source/CPack/OSXScriptLauncher.cxx
+++ b/Source/CPack/OSXScriptLauncher.cxx
@@ -1,15 +1,16 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmsys/FStream.hxx"
-#include "cmsys/Process.h"
-#include "cmsys/SystemTools.hxx"
+#include <cstddef>
#include <iostream>
-#include <stddef.h>
#include <string>
#include <vector>
#include <CoreFoundation/CoreFoundation.h>
+#include "cmsys/FStream.hxx"
+#include "cmsys/Process.h"
+#include "cmsys/SystemTools.hxx"
+
// For the PATH_MAX constant
#include <sys/syslimits.h>
@@ -34,7 +35,7 @@ int main(int argc, char* argv[])
}
fileName = CFSTR("RuntimeScript");
if (!(scriptFileURL =
- CFBundleCopyResourceURL(appBundle, fileName, NULL, NULL))) {
+ CFBundleCopyResourceURL(appBundle, fileName, nullptr, nullptr))) {
DebugError("CFBundleCopyResourceURL failed");
return 1;
}
@@ -46,8 +47,7 @@ int main(int argc, char* argv[])
// get the file system path of the url as a cstring
// in an encoding suitable for posix apis
- if (CFURLGetFileSystemRepresentation(scriptFileURL, true, path, PATH_MAX) ==
- false) {
+ if (!CFURLGetFileSystemRepresentation(scriptFileURL, true, path, PATH_MAX)) {
DebugError("CFURLGetFileSystemRepresentation failed");
return 1;
}
@@ -71,10 +71,10 @@ int main(int argc, char* argv[])
for (cc = 1; cc < argc; ++cc) {
args.push_back(argv[cc]);
}
- args.push_back(0);
+ args.push_back(nullptr);
cmsysProcess* cp = cmsysProcess_New();
- cmsysProcess_SetCommand(cp, &*args.begin());
+ cmsysProcess_SetCommand(cp, args.data());
cmsysProcess_SetWorkingDirectory(cp, scriptDirectory.c_str());
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
cmsysProcess_SetTimeout(cp, 0);
@@ -83,7 +83,7 @@ int main(int argc, char* argv[])
std::vector<char> tempOutput;
char* data;
int length;
- while (cmsysProcess_WaitForData(cp, &data, &length, 0)) {
+ while (cmsysProcess_WaitForData(cp, &data, &length, nullptr)) {
// Translate NULL characters in the output into valid text.
for (int i = 0; i < length; ++i) {
if (data[i] == '\0') {
@@ -93,7 +93,7 @@ int main(int argc, char* argv[])
std::cout.write(data, length);
}
- cmsysProcess_WaitForExit(cp, 0);
+ cmsysProcess_WaitForExit(cp, nullptr);
bool result = true;
if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) {
diff --git a/Source/CPack/WiX/cmCMakeToWixPath.cxx b/Source/CPack/WiX/cmCMakeToWixPath.cxx
new file mode 100644
index 000000000..87385011a
--- /dev/null
+++ b/Source/CPack/WiX/cmCMakeToWixPath.cxx
@@ -0,0 +1,39 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmCMakeToWixPath.h"
+
+#include <string>
+#include <vector>
+
+#include "cmStringAlgorithms.h"
+
+#ifdef __CYGWIN__
+# include <sys/cygwin.h>
+std::string CMakeToWixPath(const std::string& cygpath)
+{
+ std::vector<char> winpath_chars;
+ ssize_t winpath_size;
+
+ // Get the required buffer size.
+ winpath_size =
+ cygwin_conv_path(CCP_POSIX_TO_WIN_A, cygpath.c_str(), nullptr, 0);
+ if (winpath_size <= 0) {
+ return cygpath;
+ }
+
+ winpath_chars.assign(static_cast<size_t>(winpath_size) + 1, '\0');
+
+ winpath_size = cygwin_conv_path(CCP_POSIX_TO_WIN_A, cygpath.c_str(),
+ winpath_chars.data(), winpath_size);
+ if (winpath_size < 0) {
+ return cygpath;
+ }
+
+ return cmTrimWhitespace(winpath_chars.data());
+}
+#else
+std::string CMakeToWixPath(const std::string& path)
+{
+ return path;
+}
+#endif
diff --git a/Source/CPack/WiX/cmCMakeToWixPath.h b/Source/CPack/WiX/cmCMakeToWixPath.h
new file mode 100644
index 000000000..8bb9e0408
--- /dev/null
+++ b/Source/CPack/WiX/cmCMakeToWixPath.h
@@ -0,0 +1,12 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmCMakeToWixPath_h
+#define cmCMakeToWixPath_h
+
+#include "cmConfigure.h" //IWYU pragma: keep
+
+#include <string>
+
+std::string CMakeToWixPath(const std::string& cygpath);
+
+#endif // cmCMakeToWixPath_h
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 274dfd0ce..e71a38fd2 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -2,27 +2,37 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackWIXGenerator.h"
+#include <algorithm>
+
+#include <cm/string_view>
+
+#include "cmsys/Directory.hxx"
+#include "cmsys/Encoding.hxx"
+#include "cmsys/FStream.hxx"
+#include "cmsys/SystemTools.hxx"
+
+#include "cmAlgorithms.h"
#include "cmCPackComponentGroup.h"
#include "cmCPackLog.h"
#include "cmCryptoHash.h"
#include "cmGeneratedFileStream.h"
#include "cmInstalledFile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmUuid.h"
-#include <algorithm>
-
#include "cmWIXDirectoriesSourceWriter.h"
#include "cmWIXFeaturesSourceWriter.h"
#include "cmWIXFilesSourceWriter.h"
#include "cmWIXRichTextFormatWriter.h"
#include "cmWIXSourceWriter.h"
-#include "cmsys/Directory.hxx"
-#include "cmsys/Encoding.hxx"
-#include "cmsys/FStream.hxx"
-#include "cmsys/SystemTools.hxx"
+#ifdef _WIN32
+# include <rpc.h> // for GUID generation (windows only)
+#else
+# include <uuid/uuid.h> // for GUID generation (libuuid)
+#endif
-#include <rpc.h> // for GUID generation
+#include "cmCMakeToWixPath.h"
cmCPackWIXGenerator::cmCPackWIXGenerator()
: Patch(0)
@@ -49,15 +59,14 @@ bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command)
{
std::string logFileName = this->CPackTopLevel + "/wix.log";
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Running WiX command: " << command
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Running WiX command: " << command << std::endl);
std::string output;
int returnValue = 0;
- bool status = cmSystemTools::RunSingleCommand(command.c_str(), &output,
- &output, &returnValue, 0,
- cmSystemTools::OUTPUT_NONE);
+ bool status = cmSystemTools::RunSingleCommand(
+ command, &output, &output, &returnValue, 0, cmSystemTools::OUTPUT_NONE);
cmsys::ofstream logFile(logFileName.c_str(), std::ios::app);
logFile << command << std::endl;
@@ -65,8 +74,9 @@ bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command)
logFile.close();
if (!status || returnValue) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running WiX candle. "
- "Please check '"
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem running WiX candle. "
+ "Please check '"
<< logFileName << "' for errors." << std::endl);
return false;
@@ -89,9 +99,12 @@ bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile,
command << " -arch " << GetArchitecture();
command << " -out " << QuotePath(objectFile);
- for (extension_set_t::const_iterator i = CandleExtensions.begin();
- i != CandleExtensions.end(); ++i) {
- command << " -ext " << QuotePath(*i);
+ for (std::string const& ext : CandleExtensions) {
+ command << " -ext " << QuotePath(ext);
+ }
+
+ if (sourceFile.rfind(this->CPackTopLevel, 0) != 0) {
+ command << " " << QuotePath("-I" + this->CPackTopLevel);
}
AddCustomFlags("CPACK_WIX_CANDLE_EXTRA_FLAGS", command);
@@ -111,11 +124,10 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
std::ostringstream command;
command << QuotePath(executable);
command << " -nologo";
- command << " -out " << QuotePath(packageFileNames.at(0));
+ command << " -out " << QuotePath(CMakeToWixPath(packageFileNames.at(0)));
- for (extension_set_t::const_iterator i = this->LightExtensions.begin();
- i != this->LightExtensions.end(); ++i) {
- command << " -ext " << QuotePath(*i);
+ for (std::string const& ext : this->LightExtensions) {
+ command << " -ext " << QuotePath(ext);
}
const char* const cultures = GetOption("CPACK_WIX_CULTURES");
@@ -133,8 +145,8 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
int cmCPackWIXGenerator::PackageFiles()
{
if (!PackageFilesImpl() || cmSystemTools::GetErrorOccuredFlag()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Fatal WiX Generator Error"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Fatal WiX Generator Error" << std::endl);
return false;
}
@@ -143,9 +155,9 @@ int cmCPackWIXGenerator::PackageFiles()
bool cmCPackWIXGenerator::InitializeWiXConfiguration()
{
- if (!ReadListFile("CPackWIX.cmake")) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while executing CPackWIX.cmake"
- << std::endl);
+ if (!ReadListFile("Internal/CPack/CPackWIX.cmake")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error while executing CPackWIX.cmake" << std::endl);
return false;
}
@@ -162,12 +174,13 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
std::string guid = GenerateGUID();
SetOption("CPACK_WIX_UPGRADE_GUID", guid.c_str());
- cmCPackLogger(
- cmCPackLog::LOG_WARNING, "CPACK_WIX_UPGRADE_GUID implicitly set to "
- << guid << " . "
- "Please refer to the documentation on how and why "
- "you might want to set this explicitly."
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_WARNING,
+ "CPACK_WIX_UPGRADE_GUID implicitly set to "
+ << guid
+ << " . "
+ "Please refer to the documentation on how and why "
+ "you might want to set this explicitly."
+ << std::endl);
}
if (!RequireOption("CPACK_TOPLEVEL_DIRECTORY", this->CPackTopLevel)) {
@@ -216,11 +229,10 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE");
if (patchFilePath) {
- std::vector<std::string> patchFilePaths;
- cmSystemTools::ExpandListArgument(patchFilePath, patchFilePaths);
+ std::vector<std::string> patchFilePaths = cmExpandedList(patchFilePath);
- for (size_t i = 0; i < patchFilePaths.size(); ++i) {
- if (!this->Patch->LoadFragments(patchFilePaths[i])) {
+ for (std::string const& p : patchFilePaths) {
+ if (!this->Patch->LoadFragments(p)) {
return false;
}
}
@@ -228,7 +240,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
// if install folder is supposed to be set absolutely, the default
// component guid "*" cannot be used
- if (cmSystemTools::IsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"))) {
+ if (cmIsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"))) {
this->ComponentGuidType = cmWIXSourceWriter::CMAKE_GENERATED_GUID;
}
@@ -254,9 +266,7 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
std::set<std::string> usedBaseNames;
std::ostringstream objectFiles;
- for (size_t i = 0; i < this->WixSources.size(); ++i) {
- std::string const& sourceFilename = this->WixSources[i];
-
+ for (std::string const& sourceFilename : this->WixSources) {
std::string baseName =
cmSystemTools::GetFilenameWithoutLastExtension(sourceFilename);
@@ -274,11 +284,12 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
std::string objectFilename =
this->CPackTopLevel + "/" + uniqueBaseName + ".wixobj";
- if (!RunCandleCommand(sourceFilename, objectFilename)) {
+ if (!RunCandleCommand(CMakeToWixPath(sourceFilename),
+ CMakeToWixPath(objectFilename))) {
return false;
}
- objectFiles << " " << QuotePath(objectFilename);
+ objectFiles << " " << QuotePath(CMakeToWixPath(objectFilename));
}
AppendUserSuppliedExtraObjects(objectFiles);
@@ -292,7 +303,7 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraSources()
if (!cpackWixExtraSources)
return;
- cmSystemTools::ExpandListArgument(cpackWixExtraSources, this->WixSources);
+ cmExpandList(cpackWixExtraSources, this->WixSources);
}
void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
@@ -301,13 +312,11 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
if (!cpackWixExtraObjects)
return;
- std::vector<std::string> expandedExtraObjects;
+ std::vector<std::string> expandedExtraObjects =
+ cmExpandedList(cpackWixExtraObjects);
- cmSystemTools::ExpandListArgument(cpackWixExtraObjects,
- expandedExtraObjects);
-
- for (size_t i = 0; i < expandedExtraObjects.size(); ++i) {
- stream << " " << QuotePath(expandedExtraObjects[i]);
+ for (std::string const& obj : expandedExtraObjects) {
+ stream << " " << QuotePath(obj);
}
}
@@ -324,10 +333,10 @@ void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
CopyDefinition(includeFile, "CPACK_PACKAGE_VENDOR");
CopyDefinition(includeFile, "CPACK_PACKAGE_NAME");
CopyDefinition(includeFile, "CPACK_PACKAGE_VERSION");
- CopyDefinition(includeFile, "CPACK_WIX_LICENSE_RTF");
- CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_ICON");
- CopyDefinition(includeFile, "CPACK_WIX_UI_BANNER");
- CopyDefinition(includeFile, "CPACK_WIX_UI_DIALOG");
+ CopyDefinition(includeFile, "CPACK_WIX_LICENSE_RTF", DefinitionType::PATH);
+ CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_ICON", DefinitionType::PATH);
+ CopyDefinition(includeFile, "CPACK_WIX_UI_BANNER", DefinitionType::PATH);
+ CopyDefinition(includeFile, "CPACK_WIX_UI_DIALOG", DefinitionType::PATH);
SetOptionIfNotSet("CPACK_WIX_PROGRAM_MENU_FOLDER",
GetOption("CPACK_PACKAGE_NAME"));
CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER");
@@ -345,9 +354,7 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
std::string prefix = "CPACK_WIX_PROPERTY_";
std::vector<std::string> options = GetOptions();
- for (size_t i = 0; i < options.size(); ++i) {
- std::string const& name = options[i];
-
+ for (std::string const& name : options) {
if (name.length() > prefix.length() &&
name.substr(0, prefix.length()) == prefix) {
std::string id = name.substr(prefix.length());
@@ -369,8 +376,9 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
includeFile.AddAttribute("Id", "FindInstallLocation");
includeFile.AddAttribute("Root", "HKLM");
includeFile.AddAttribute(
- "Key", "Software\\Microsoft\\Windows\\"
- "CurrentVersion\\Uninstall\\[WIX_UPGRADE_DETECTED]");
+ "Key",
+ "Software\\Microsoft\\Windows\\"
+ "CurrentVersion\\Uninstall\\[WIX_UPGRADE_DETECTED]");
includeFile.AddAttribute("Name", "InstallLocation");
includeFile.AddAttribute("Type", "raw");
includeFile.EndElement("RegistrySearch");
@@ -396,11 +404,16 @@ void cmCPackWIXGenerator::CreateWiXProductFragmentIncludeFile()
}
void cmCPackWIXGenerator::CopyDefinition(cmWIXSourceWriter& source,
- std::string const& name)
+ std::string const& name,
+ DefinitionType type)
{
const char* value = GetOption(name.c_str());
if (value) {
- AddDefinition(source, name, value);
+ if (type == DefinitionType::PATH) {
+ AddDefinition(source, name, CMakeToWixPath(value));
+ } else {
+ AddDefinition(source, name, value);
+ }
}
}
@@ -503,16 +516,12 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
globalShortcuts.AddShortcutTypes(emittedShortcutTypes);
} else {
- for (std::map<std::string, cmCPackComponent>::const_iterator i =
- this->Components.begin();
- i != this->Components.end(); ++i) {
- cmCPackComponent const& component = i->second;
+ for (auto const& i : this->Components) {
+ cmCPackComponent const& component = i.second;
- std::string componentPath = toplevel;
- componentPath += "/";
- componentPath += component.Name;
+ std::string componentPath = cmStrCat(toplevel, '/', component.Name);
- std::string componentFeatureId = "CM_C_" + component.Name;
+ std::string const componentFeatureId = "CM_C_" + component.Name;
cmWIXShortcuts featureShortcuts;
AddComponentsToFeature(componentPath, componentFeatureId,
@@ -529,9 +538,16 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
}
}
- bool emitUninstallShortcut =
- emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) !=
- emittedShortcutTypes.end();
+ bool emitUninstallShortcut = true;
+ const char* cpackWixProgramMenuFolder =
+ GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
+ if (cpackWixProgramMenuFolder &&
+ cm::string_view(cpackWixProgramMenuFolder) == ".") {
+ emitUninstallShortcut = false;
+ } else if (emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) ==
+ emittedShortcutTypes.end()) {
+ emitUninstallShortcut = false;
+ }
if (!CreateShortcuts(std::string(), "ProductFeature", globalShortcuts,
emitUninstallShortcut, fileDefinitions,
@@ -572,7 +588,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
std::string cmCPackWIXGenerator::GetRootFolderId() const
{
- if (cmSystemTools::IsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"))) {
+ if (cmIsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"))) {
return "";
}
@@ -608,9 +624,10 @@ bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs";
- if (!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath.c_str())) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed creating '"
- << mainSourceFilePath << "'' from template." << std::endl);
+ if (!ConfigureFile(wixTemplate, mainSourceFilePath)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Failed creating '" << mainSourceFilePath
+ << "'' from template." << std::endl);
return false;
}
@@ -623,19 +640,15 @@ bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
bool cmCPackWIXGenerator::CreateFeatureHierarchy(
cmWIXFeaturesSourceWriter& featureDefinitions)
{
- for (std::map<std::string, cmCPackComponentGroup>::const_iterator i =
- ComponentGroups.begin();
- i != ComponentGroups.end(); ++i) {
- cmCPackComponentGroup const& group = i->second;
+ for (auto const& i : ComponentGroups) {
+ cmCPackComponentGroup const& group = i.second;
if (group.ParentGroup == 0) {
featureDefinitions.EmitFeatureForComponentGroup(group, *this->Patch);
}
}
- for (std::map<std::string, cmCPackComponent>::const_iterator i =
- this->Components.begin();
- i != this->Components.end(); ++i) {
- cmCPackComponent const& component = i->second;
+ for (auto const& i : this->Components) {
+ cmCPackComponent const& component = i.second;
if (!component.Group) {
featureDefinitions.EmitFeatureForComponent(component, *this->Patch);
@@ -657,8 +670,7 @@ bool cmCPackWIXGenerator::AddComponentsToFeature(
std::vector<std::string> cpackPackageExecutablesList;
const char* cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES");
if (cpackPackageExecutables) {
- cmSystemTools::ExpandListArgument(cpackPackageExecutables,
- cpackPackageExecutablesList);
+ cmExpandList(cpackPackageExecutables, cpackPackageExecutablesList);
if (cpackPackageExecutablesList.size() % 2 != 0) {
cmCPackLogger(
cmCPackLog::LOG_ERROR,
@@ -673,8 +685,7 @@ bool cmCPackWIXGenerator::AddComponentsToFeature(
const char* cpackPackageDesktopLinks =
GetOption("CPACK_CREATE_DESKTOP_LINKS");
if (cpackPackageDesktopLinks) {
- cmSystemTools::ExpandListArgument(cpackPackageDesktopLinks,
- cpackPackageDesktopLinksList);
+ cmExpandList(cpackPackageDesktopLinks, cpackPackageDesktopLinksList);
}
AddDirectoryAndFileDefinitions(
@@ -730,9 +741,16 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
{
std::string directoryId;
switch (type) {
- case cmWIXShortcuts::START_MENU:
- directoryId = "PROGRAM_MENU_FOLDER";
- break;
+ case cmWIXShortcuts::START_MENU: {
+ const char* cpackWixProgramMenuFolder =
+ GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
+ if (cpackWixProgramMenuFolder &&
+ cm::string_view(cpackWixProgramMenuFolder) == ".") {
+ directoryId = "ProgramMenuFolder";
+ } else {
+ directoryId = "PROGRAM_MENU_FOLDER";
+ }
+ } break;
case cmWIXShortcuts::DESKTOP:
directoryId = "DesktopFolder";
break;
@@ -786,8 +804,13 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
fileDefinitions);
if (type == cmWIXShortcuts::START_MENU) {
- fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" +
- idSuffix);
+ const char* cpackWixProgramMenuFolder =
+ GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
+ if (cpackWixProgramMenuFolder &&
+ cm::string_view(cpackWixProgramMenuFolder) != ".") {
+ fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" +
+ idSuffix);
+ }
}
if (emitUninstallShortcut) {
@@ -937,9 +960,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions(
shortcut.workingDirectoryId = directoryId;
shortcuts.insert(cmWIXShortcuts::START_MENU, id, shortcut);
- if (!desktopExecutables.empty() &&
- std::find(desktopExecutables.begin(), desktopExecutables.end(),
- executableName) != desktopExecutables.end()) {
+ if (cmContains(desktopExecutables, executableName)) {
shortcuts.insert(cmWIXShortcuts::DESKTOP, id, shortcut);
}
}
@@ -957,8 +978,8 @@ bool cmCPackWIXGenerator::RequireOption(std::string const& name,
return true;
} else {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Required variable "
- << name << " not set" << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Required variable " << name << " not set" << std::endl);
return false;
}
@@ -978,6 +999,7 @@ std::string cmCPackWIXGenerator::GetArchitecture() const
std::string cmCPackWIXGenerator::GenerateGUID()
{
+#ifdef _WIN32
UUID guid;
UuidCreate(&guid);
@@ -987,6 +1009,14 @@ std::string cmCPackWIXGenerator::GenerateGUID()
std::string result =
cmsys::Encoding::ToNarrow(reinterpret_cast<wchar_t*>(tmp));
RpcStringFreeW(&tmp);
+#else
+ uuid_t guid;
+ char guid_ch[37] = { 0 };
+
+ uuid_generate(guid);
+ uuid_unparse(guid, guid_ch);
+ std::string result = guid_ch;
+#endif
return cmSystemTools::UpperCase(result);
}
@@ -1074,8 +1104,7 @@ std::string cmCPackWIXGenerator::CreateHashedId(
cmCryptoHash sha1(cmCryptoHash::AlgoSHA1);
std::string const hash = sha1.HashString(path);
- std::string identifier;
- identifier += hash.substr(0, 7) + "_";
+ std::string identifier = cmStrCat(cm::string_view(hash).substr(0, 7), '_');
const size_t maxFileNameLength = 52;
if (normalizedFilename.length() > maxFileNameLength) {
@@ -1120,8 +1149,7 @@ void cmCPackWIXGenerator::CollectExtensions(std::string const& variableName,
if (!variableContent)
return;
- std::vector<std::string> list;
- cmSystemTools::ExpandListArgument(variableContent, list);
+ std::vector<std::string> list = cmExpandedList(variableContent);
extensions.insert(list.begin(), list.end());
}
@@ -1132,12 +1160,10 @@ void cmCPackWIXGenerator::AddCustomFlags(std::string const& variableName,
if (!variableContent)
return;
- std::vector<std::string> list;
- cmSystemTools::ExpandListArgument(variableContent, list);
+ std::vector<std::string> list = cmExpandedList(variableContent);
- for (std::vector<std::string>::const_iterator i = list.begin();
- i != list.end(); ++i) {
- stream << " " << QuotePath(*i);
+ for (std::string const& i : list) {
+ stream << " " << QuotePath(i);
}
}
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h
index b2633a7f9..d1933483f 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.h
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.h
@@ -3,14 +3,13 @@
#ifndef cmCPackWIXGenerator_h
#define cmCPackWIXGenerator_h
-#include "cmCPackGenerator.h"
+#include <map>
+#include <string>
+#include "cmCPackGenerator.h"
#include "cmWIXPatch.h"
#include "cmWIXShortcut.h"
-#include <map>
-#include <string>
-
class cmWIXSourceWriter;
class cmWIXDirectoriesSourceWriter;
class cmWIXFilesSourceWriter;
@@ -28,25 +27,31 @@ public:
~cmCPackWIXGenerator();
protected:
- virtual int InitializeInternal();
+ int InitializeInternal() override;
- virtual int PackageFiles();
+ int PackageFiles() override;
- virtual const char* GetOutputExtension() { return ".msi"; }
+ const char* GetOutputExtension() override { return ".msi"; }
- virtual enum CPackSetDestdirSupport SupportsSetDestdir() const
+ enum CPackSetDestdirSupport SupportsSetDestdir() const override
{
return SETDESTDIR_UNSUPPORTED;
}
- virtual bool SupportsAbsoluteDestination() const { return false; }
+ bool SupportsAbsoluteDestination() const override { return false; }
- virtual bool SupportsComponentInstallation() const { return true; }
+ bool SupportsComponentInstallation() const override { return true; }
private:
- typedef std::map<std::string, std::string> id_map_t;
- typedef std::map<std::string, size_t> ambiguity_map_t;
- typedef std::set<std::string> extension_set_t;
+ using id_map_t = std::map<std::string, std::string>;
+ using ambiguity_map_t = std::map<std::string, size_t>;
+ using extension_set_t = std::set<std::string>;
+
+ enum class DefinitionType
+ {
+ STRING,
+ PATH
+ };
bool InitializeWiXConfiguration();
@@ -58,7 +63,8 @@ private:
void CreateWiXProductFragmentIncludeFile();
- void CopyDefinition(cmWIXSourceWriter& source, std::string const& name);
+ void CopyDefinition(cmWIXSourceWriter& source, std::string const& name,
+ DefinitionType type = DefinitionType::STRING);
void AddDefinition(cmWIXSourceWriter& source, std::string const& name,
std::string const& value);
diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx
index 744a93298..3668b4613 100644
--- a/Source/CPack/WiX/cmWIXAccessControlList.cxx
+++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx
@@ -3,7 +3,7 @@
#include "cmWIXAccessControlList.h"
#include "cmCPackGenerator.h"
-
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
cmWIXAccessControlList::cmWIXAccessControlList(
@@ -20,8 +20,8 @@ bool cmWIXAccessControlList::Apply()
std::vector<std::string> entries;
this->InstalledFile.GetPropertyAsList("CPACK_WIX_ACL", entries);
- for (size_t i = 0; i < entries.size(); ++i) {
- this->CreatePermissionElement(entries[i]);
+ for (std::string const& entry : entries) {
+ this->CreatePermissionElement(entry);
}
return true;
@@ -48,17 +48,15 @@ void cmWIXAccessControlList::CreatePermissionElement(std::string const& entry)
user = user_and_domain;
}
- std::vector<std::string> permissions =
- cmSystemTools::tokenize(permission_string, ",");
+ std::vector<std::string> permissions = cmTokenize(permission_string, ",");
this->SourceWriter.BeginElement("Permission");
this->SourceWriter.AddAttribute("User", user);
if (!domain.empty()) {
this->SourceWriter.AddAttribute("Domain", domain);
}
- for (size_t i = 0; i < permissions.size(); ++i) {
- this->EmitBooleanAttribute(entry,
- cmSystemTools::TrimWhitespace(permissions[i]));
+ for (std::string const& permission : permissions) {
+ this->EmitBooleanAttribute(entry, cmTrimWhitespace(permission));
}
this->SourceWriter.EndElement("Permission");
}
@@ -66,8 +64,9 @@ void cmWIXAccessControlList::CreatePermissionElement(std::string const& entry)
void cmWIXAccessControlList::ReportError(std::string const& entry,
std::string const& message)
{
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed processing ACL entry '"
- << entry << "': " << message << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Failed processing ACL entry '" << entry << "': " << message
+ << std::endl);
}
bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name)
diff --git a/Source/CPack/WiX/cmWIXAccessControlList.h b/Source/CPack/WiX/cmWIXAccessControlList.h
index 2a23f2f37..64f9a1382 100644
--- a/Source/CPack/WiX/cmWIXAccessControlList.h
+++ b/Source/CPack/WiX/cmWIXAccessControlList.h
@@ -3,10 +3,9 @@
#ifndef cmWIXAccessControlList_h
#define cmWIXAccessControlList_h
-#include "cmWIXSourceWriter.h"
-
#include "cmCPackLog.h"
#include "cmInstalledFile.h"
+#include "cmWIXSourceWriter.h"
class cmWIXAccessControlList
{
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
index 975dffb4f..0a83ca2c0 100644
--- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
@@ -14,10 +14,12 @@ void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
BeginElement("Directory");
AddAttribute("Id", "ProgramMenuFolder");
- BeginElement("Directory");
- AddAttribute("Id", "PROGRAM_MENU_FOLDER");
- AddAttribute("Name", startMenuFolder);
- EndElement("Directory");
+ if (startMenuFolder != ".") {
+ BeginElement("Directory");
+ AddAttribute("Id", "PROGRAM_MENU_FOLDER");
+ AddAttribute("Name", startMenuFolder);
+ EndElement("Directory");
+ }
EndElement("Directory");
}
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
index 8233331a3..a907d6d18 100644
--- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
@@ -3,11 +3,10 @@
#ifndef cmWIXDirectoriesSourceWriter_h
#define cmWIXDirectoriesSourceWriter_h
-#include "cmWIXSourceWriter.h"
+#include <string>
#include "cmCPackGenerator.h"
-
-#include <string>
+#include "cmWIXSourceWriter.h"
/** \class cmWIXDirectoriesSourceWriter
* \brief Helper class to generate directories.wxs
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
index 0be43776e..a7a064881 100644
--- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
@@ -46,16 +46,12 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
patch.ApplyFragment("CM_G_" + group.Name, *this);
- for (std::vector<cmCPackComponentGroup*>::const_iterator i =
- group.Subgroups.begin();
- i != group.Subgroups.end(); ++i) {
- EmitFeatureForComponentGroup(**i, patch);
+ for (cmCPackComponentGroup* subgroup : group.Subgroups) {
+ EmitFeatureForComponentGroup(*subgroup, patch);
}
- for (std::vector<cmCPackComponent*>::const_iterator i =
- group.Components.begin();
- i != group.Components.end(); ++i) {
- EmitFeatureForComponent(**i, patch);
+ for (cmCPackComponent* component : group.Components) {
+ EmitFeatureForComponent(*component, patch);
}
EndElement("Feature");
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
index e751ca719..e03e87bad 100644
--- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
@@ -3,11 +3,10 @@
#ifndef cmWIXFeaturesSourceWriter_h
#define cmWIXFeaturesSourceWriter_h
+#include "cmCPackGenerator.h"
#include "cmWIXPatch.h"
#include "cmWIXSourceWriter.h"
-#include "cmCPackGenerator.h"
-
/** \class cmWIXFeaturesSourceWriter
* \brief Helper class to generate features.wxs
*/
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
index b4cd1a3d6..c0d879a0c 100644
--- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
@@ -2,14 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmWIXFilesSourceWriter.h"
-#include "cmWIXAccessControlList.h"
+#include "cm_sys_stat.h"
+#include "cmCMakeToWixPath.h"
#include "cmInstalledFile.h"
-
#include "cmSystemTools.h"
#include "cmUuid.h"
-
-#include "cm_sys_stat.h"
+#include "cmWIXAccessControlList.h"
cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger,
std::string const& filename,
@@ -139,7 +138,7 @@ std::string cmWIXFilesSourceWriter::EmitComponentFile(
patch.ApplyFragment(componentId, *this);
BeginElement("File");
AddAttribute("Id", fileId);
- AddAttribute("Source", filePath);
+ AddAttribute("Source", CMakeToWixPath(filePath));
AddAttribute("KeyPath", "yes");
mode_t fileMode = 0;
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
index dc9c636d3..8cc98f52b 100644
--- a/Source/CPack/WiX/cmWIXFilesSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
@@ -3,12 +3,10 @@
#ifndef cmWIXFilesSourceWriter_h
#define cmWIXFilesSourceWriter_h
-#include "cmWIXSourceWriter.h"
-
+#include "cmCPackGenerator.h"
#include "cmWIXPatch.h"
#include "cmWIXShortcut.h"
-
-#include "cmCPackGenerator.h"
+#include "cmWIXSourceWriter.h"
/** \class cmWIXFilesSourceWriter
* \brief Helper class to generate files.wxs
diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx
index 287a644bb..ca232f94b 100644
--- a/Source/CPack/WiX/cmWIXPatch.cxx
+++ b/Source/CPack/WiX/cmWIXPatch.cxx
@@ -13,8 +13,9 @@ bool cmWIXPatch::LoadFragments(std::string const& patchFilePath)
{
cmWIXPatchParser parser(Fragments, Logger);
if (!parser.ParseFile(patchFilePath.c_str())) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed parsing XML patch file: '"
- << patchFilePath << "'" << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Failed parsing XML patch file: '" << patchFilePath << "'"
+ << std::endl);
return false;
}
@@ -29,10 +30,8 @@ void cmWIXPatch::ApplyFragment(std::string const& id,
return;
const cmWIXPatchElement& fragment = i->second;
- for (cmWIXPatchElement::attributes_t::const_iterator attr_i =
- fragment.attributes.begin();
- attr_i != fragment.attributes.end(); ++attr_i) {
- writer.AddAttribute(attr_i->first, attr_i->second);
+ for (auto const& attr : fragment.attributes) {
+ writer.AddAttribute(attr.first, attr.second);
}
this->ApplyElementChildren(fragment, writer);
@@ -42,11 +41,7 @@ void cmWIXPatch::ApplyFragment(std::string const& id,
void cmWIXPatch::ApplyElementChildren(const cmWIXPatchElement& element,
cmWIXSourceWriter& writer)
{
- for (cmWIXPatchElement::child_list_t::const_iterator j =
- element.children.begin();
- j != element.children.end(); ++j) {
- cmWIXPatchNode* node = *j;
-
+ for (cmWIXPatchNode* node : element.children) {
switch (node->type()) {
case cmWIXPatchNode::ELEMENT:
ApplyElement(dynamic_cast<const cmWIXPatchElement&>(*node), writer);
@@ -63,10 +58,8 @@ void cmWIXPatch::ApplyElement(const cmWIXPatchElement& element,
{
writer.BeginElement(element.name);
- for (cmWIXPatchElement::attributes_t::const_iterator i =
- element.attributes.begin();
- i != element.attributes.end(); ++i) {
- writer.AddAttribute(i->first, i->second);
+ for (auto const& attr : element.attributes) {
+ writer.AddAttribute(attr.first, attr.second);
}
this->ApplyElementChildren(element, writer);
@@ -77,14 +70,13 @@ void cmWIXPatch::ApplyElement(const cmWIXPatchElement& element,
bool cmWIXPatch::CheckForUnappliedFragments()
{
std::string fragmentList;
- for (cmWIXPatchParser::fragment_map_t::const_iterator i = Fragments.begin();
- i != Fragments.end(); ++i) {
+ for (auto const& fragment : Fragments) {
if (!fragmentList.empty()) {
fragmentList += ", ";
}
fragmentList += "'";
- fragmentList += i->first;
+ fragmentList += fragment.first;
fragmentList += "'";
}
diff --git a/Source/CPack/WiX/cmWIXPatch.h b/Source/CPack/WiX/cmWIXPatch.h
index a4c9e714d..31a60f4e8 100644
--- a/Source/CPack/WiX/cmWIXPatch.h
+++ b/Source/CPack/WiX/cmWIXPatch.h
@@ -3,11 +3,11 @@
#ifndef cmWIXPatch_h
#define cmWIXPatch_h
+#include <string>
+
#include "cmWIXPatchParser.h"
#include "cmWIXSourceWriter.h"
-#include <string>
-
/** \class cmWIXPatch
* \brief Class that maintains and applies patch fragments
*/
diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx
index 0dcc74ae0..fd9103bc1 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.cxx
+++ b/Source/CPack/WiX/cmWIXPatchParser.cxx
@@ -2,10 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmWIXPatchParser.h"
-#include "cmCPackGenerator.h"
-
#include "cm_expat.h"
+#include "cmCPackGenerator.h"
+
cmWIXPatchNode::Type cmWIXPatchText::type()
{
return cmWIXPatchNode::TEXT;
@@ -22,8 +22,8 @@ cmWIXPatchNode::~cmWIXPatchNode()
cmWIXPatchElement::~cmWIXPatchElement()
{
- for (child_list_t::iterator i = children.begin(); i != children.end(); ++i) {
- delete *i;
+ for (cmWIXPatchNode* child : children) {
+ delete child;
}
}
@@ -72,7 +72,7 @@ void cmWIXPatchParser::StartElement(const std::string& name, const char** atts)
void cmWIXPatchParser::StartFragment(const char** attributes)
{
- cmWIXPatchElement* new_element = CM_NULLPTR;
+ cmWIXPatchElement* new_element = nullptr;
/* find the id of for fragment */
for (size_t i = 0; attributes[i]; i += 2) {
const std::string key = attributes[i];
@@ -90,7 +90,7 @@ void cmWIXPatchParser::StartFragment(const char** attributes)
}
}
- /* add any additional attributes for the fragement */
+ /* add any additional attributes for the fragment */
if (!new_element) {
ReportValidationError("No 'Id' specified for 'CPackWixFragment' element");
} else {
diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h
index 52c7e3524..87dd89288 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.h
+++ b/Source/CPack/WiX/cmWIXPatchParser.h
@@ -3,13 +3,12 @@
#ifndef cmCPackWIXPatchParser_h
#define cmCPackWIXPatchParser_h
-#include "cmCPackLog.h"
-
-#include "cmXMLParser.h"
-
#include <map>
#include <vector>
+#include "cmCPackLog.h"
+#include "cmXMLParser.h"
+
struct cmWIXPatchNode
{
enum Type
@@ -36,8 +35,8 @@ struct cmWIXPatchElement : cmWIXPatchNode
~cmWIXPatchElement();
- typedef std::vector<cmWIXPatchNode*> child_list_t;
- typedef std::map<std::string, std::string> attributes_t;
+ using child_list_t = std::vector<cmWIXPatchNode*>;
+ using attributes_t = std::map<std::string, std::string>;
std::string name;
child_list_t children;
@@ -50,7 +49,7 @@ struct cmWIXPatchElement : cmWIXPatchNode
class cmWIXPatchParser : public cmXMLParser
{
public:
- typedef std::map<std::string, cmWIXPatchElement> fragment_map_t;
+ using fragment_map_t = std::map<std::string, cmWIXPatchElement>;
cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger);
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
index 2c99a2284..751f7dc3a 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
@@ -25,7 +25,7 @@ cmWIXRichTextFormatWriter::~cmWIXRichTextFormatWriter()
void cmWIXRichTextFormatWriter::AddText(std::string const& text)
{
- typedef unsigned char rtf_byte_t;
+ using rtf_byte_t = unsigned char;
for (size_t i = 0; i < text.size(); ++i) {
rtf_byte_t c = rtf_byte_t(text[i]);
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
index 30df87814..a879f3da9 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
@@ -3,11 +3,12 @@
#ifndef cmWIXRichTextFormatWriter_h
#define cmWIXRichTextFormatWriter_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmsys/FStream.hxx"
#include <string>
+#include "cmsys/FStream.hxx"
+
/** \class cmWIXRichtTextFormatWriter
* \brief Helper class to generate Rich Text Format (RTF) documents
* from plain text (e.g. for license and welcome text)
diff --git a/Source/CPack/WiX/cmWIXShortcut.cxx b/Source/CPack/WiX/cmWIXShortcut.cxx
index e5dea94c4..cd1988a1c 100644
--- a/Source/CPack/WiX/cmWIXShortcut.cxx
+++ b/Source/CPack/WiX/cmWIXShortcut.cxx
@@ -47,10 +47,9 @@ bool cmWIXShortcuts::EmitShortcuts(
return false;
}
- for (shortcut_id_map_t::const_iterator j = id_map.begin(); j != id_map.end();
- ++j) {
- std::string const& id = j->first;
- shortcut_list_t const& shortcutList = j->second;
+ for (auto const& j : id_map) {
+ std::string const& id = j.first;
+ shortcut_list_t const& shortcutList = j.second;
for (size_t shortcutListIndex = 0; shortcutListIndex < shortcutList.size();
++shortcutListIndex) {
@@ -68,9 +67,8 @@ bool cmWIXShortcuts::EmitShortcuts(
void cmWIXShortcuts::AddShortcutTypes(std::set<Type>& types)
{
- for (shortcut_type_map_t::const_iterator i = this->Shortcuts.begin();
- i != this->Shortcuts.end(); ++i) {
- types.insert(i->first);
+ for (auto const& shortcut : this->Shortcuts) {
+ types.insert(shortcut.first);
}
}
@@ -96,9 +94,9 @@ void cmWIXShortcuts::CreateFromProperty(std::string const& propertyName,
std::vector<std::string> list;
installedFile.GetPropertyAsList(propertyName, list);
- for (size_t i = 0; i < list.size(); ++i) {
+ for (std::string const& label : list) {
cmWIXShortcut shortcut;
- shortcut.label = list[i];
+ shortcut.label = label;
shortcut.workingDirectoryId = directoryId;
insert(type, id, shortcut);
}
diff --git a/Source/CPack/WiX/cmWIXShortcut.h b/Source/CPack/WiX/cmWIXShortcut.h
index 23ddc6a3f..c67baf369 100644
--- a/Source/CPack/WiX/cmWIXShortcut.h
+++ b/Source/CPack/WiX/cmWIXShortcut.h
@@ -3,13 +3,13 @@
#ifndef cmWIXShortcut_h
#define cmWIXShortcut_h
-#include "cmInstalledFile.h"
-
#include <map>
#include <set>
#include <string>
#include <vector>
+#include "cmInstalledFile.h"
+
class cmWIXFilesSourceWriter;
struct cmWIXShortcut
@@ -28,8 +28,8 @@ public:
STARTUP
};
- typedef std::vector<cmWIXShortcut> shortcut_list_t;
- typedef std::map<std::string, shortcut_list_t> shortcut_id_map_t;
+ using shortcut_list_t = std::vector<cmWIXShortcut>;
+ using shortcut_id_map_t = std::map<std::string, shortcut_list_t>;
void insert(Type type, std::string const& id, cmWIXShortcut const& shortcut);
@@ -46,7 +46,7 @@ public:
cmInstalledFile const& installedFile);
private:
- typedef std::map<Type, shortcut_id_map_t> shortcut_type_map_t;
+ using shortcut_type_map_t = std::map<Type, shortcut_id_map_t>;
void CreateFromProperty(std::string const& propertyName, Type type,
std::string const& id,
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx
index a86e28d1c..8e9bfdf3f 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx
@@ -2,12 +2,11 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmWIXSourceWriter.h"
-#include "cmCPackGenerator.h"
+#include <windows.h>
+#include "cmCPackGenerator.h"
#include "cmUuid.h"
-#include <windows.h>
-
cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
std::string const& filename,
GuidType componentGuidType,
@@ -32,7 +31,8 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
cmWIXSourceWriter::~cmWIXSourceWriter()
{
if (Elements.size() > 1) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, Elements.size() - 1
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ Elements.size() - 1
<< " WiX elements were still open when closing '"
<< SourceFilename << "'" << std::endl);
return;
@@ -65,7 +65,8 @@ void cmWIXSourceWriter::EndElement(std::string const& name)
}
if (Elements.back() != name) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "WiX element <"
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "WiX element <"
<< Elements.back() << "> can not be closed by </" << name
<< "> in '" << SourceFilename << "'" << std::endl);
return;
@@ -158,9 +159,7 @@ std::string cmWIXSourceWriter::EscapeAttributeValue(std::string const& value)
std::string result;
result.reserve(value.size());
- char c = 0;
- for (size_t i = 0; i < value.size(); ++i) {
- c = value[i];
+ for (char c : value) {
switch (c) {
case '<':
result += "&lt;";
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h
index 4af1ed6ed..8cc2070a8 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXSourceWriter.h
@@ -3,12 +3,12 @@
#ifndef cmWIXSourceWriter_h
#define cmWIXSourceWriter_h
-#include "cmCPackLog.h"
+#include <string>
+#include <vector>
#include "cmsys/FStream.hxx"
-#include <string>
-#include <vector>
+#include "cmCPackLog.h"
/** \class cmWIXSourceWriter
* \brief Helper class to generate XML WiX source files
diff --git a/Source/CPack/bills-comments.txt b/Source/CPack/bills-comments.txt
deleted file mode 100644
index c3b4ee8e7..000000000
--- a/Source/CPack/bills-comments.txt
+++ /dev/null
@@ -1,68 +0,0 @@
-cpack.cxx
-
-cmCPackGenerators -- creates cmCPackGenericGenerator's via NewGenerator
- - a cmCPackGenericGenerator factory
-
-
-cmCPackGenericGenerator::Initialize
- this->InitializeInternal
- CPACK_INCLUDE_TOPLEVEL_DIRECTORY = 0 turns off
-
-
-// binary package run
-cmCPackGenericGenerator::ProcessGenerator // DoPackage
- cmCPackGenericGenerator::PrepareNames -- sets a bunch of CPACK_vars
- cmCPackGenericGenerator::InstallProject
- run preinstall (make preinstall/fast)
- call ReadListFile(cmake_install.cmake)
- glob recurse in install directory to get list of files
- this->CompressFiles with the list of files
-
-
-// source package run
-cmCPackGenericGenerator::ProcessGenerator // DoPackage
- cmCPackGenericGenerator::PrepareNames -- sets a bunch of CPACK_vars
- cmCPackGenericGenerator::InstallProject -->
- if set CPACK_INSTALLED_DIRECTORIES
- glob the files in that directory
- copy those files to the tmp install directory _CPack something
- glob recurse in install directory to get list of files
- this->CompressFiles with the list of files
-
-
-cmCPackGenericGenerator::InstallProject is used for both source and binary
-packages. It is controled based on values set in CPACK_ variables.
-
-
-InstallProject
- 1. CPACK_INSTALL_COMMANDS - a list of commands used to install the package
-
- 2. CPACK_INSTALLED_DIRECTORIES - copy this directory to CPACK_TEMPORARY_DIRECTORY
-
- 3. CPACK_INSTALL_CMAKE_PROJECTS - a cmake install script
- - run make preinstall
- - run cmake_install.cmake
- - set CMAKE_INSTALL_PREFIX to the temp directory
- - CPACK_BUILD_CONFIG check this and set the BUILD_TYPE to it
- - ReadListFile on the install script cmake_install.cmake
- - run strip on the executables and libraries if CPACK_STRIP_FILES is TRUE
-
-Recommendations:
-
-rename cmCPackGenerators to cmCPackGeneratorFactory
-
-rename cmCPackGenericGenerator --> cmCPackGenerator
-
-rename cmCPackGenericGenerator::ProcessGenerator -> cmCPackGenerator::DoPackage
-
-
-break up cmCPackGenerator::InstallProject so it calls the following:
-
-// run user provided install commands
- cmCPackGenerator::RunInstallCommands();
-// copy entire directories that need no processing like source trees
- cmCPackGenerator::CopyPreInstalledDirectories();
-// run the cmake install scripts if provided
- cmCPackGenerator::RunCMakeInstallScripts()
-
--
diff --git a/Source/CPack/cmCPack7zGenerator.cxx b/Source/CPack/cmCPack7zGenerator.cxx
deleted file mode 100644
index f0c41a2a1..000000000
--- a/Source/CPack/cmCPack7zGenerator.cxx
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmCPack7zGenerator.h"
-
-#include "cmArchiveWrite.h"
-#include "cmCPackArchiveGenerator.h"
-
-cmCPack7zGenerator::cmCPack7zGenerator()
- : cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "7zip")
-{
-}
-
-cmCPack7zGenerator::~cmCPack7zGenerator()
-{
-}
diff --git a/Source/CPack/cmCPack7zGenerator.h b/Source/CPack/cmCPack7zGenerator.h
deleted file mode 100644
index 42a47810c..000000000
--- a/Source/CPack/cmCPack7zGenerator.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmCPack7zGenerator_h
-#define cmCPack7zGenerator_h
-
-#include "cmConfigure.h"
-
-#include "cmCPackArchiveGenerator.h"
-#include "cmCPackGenerator.h"
-
-/** \class cmCPack7zGenerator
- * \brief A generator for 7z files
- */
-class cmCPack7zGenerator : public cmCPackArchiveGenerator
-{
-public:
- cmCPackTypeMacro(cmCPack7zGenerator, cmCPackArchiveGenerator);
-
- /**
- * Construct generator
- */
- cmCPack7zGenerator();
- ~cmCPack7zGenerator() CM_OVERRIDE;
-
-protected:
- const char* GetOutputExtension() CM_OVERRIDE { return ".7z"; }
-};
-
-#endif
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx
index 575c94924..43f2946bd 100644
--- a/Source/CPack/cmCPackArchiveGenerator.cxx
+++ b/Source/CPack/cmCPackArchiveGenerator.cxx
@@ -2,29 +2,72 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackArchiveGenerator.h"
+#include <cstring>
+#include <map>
+#include <ostream>
+#include <utility>
+#include <vector>
+
#include "cmCPackComponentGroup.h"
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
#include "cmGeneratedFileStream.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
-#include <map>
-#include <ostream>
-#include <utility>
-#include <vector>
+cmCPackGenerator* cmCPackArchiveGenerator::Create7ZGenerator()
+{
+ return new cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "7zip",
+ ".7z");
+}
+
+cmCPackGenerator* cmCPackArchiveGenerator::CreateTBZ2Generator()
+{
+ return new cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, "paxr",
+ ".tar.bz2");
+}
+
+cmCPackGenerator* cmCPackArchiveGenerator::CreateTGZGenerator()
+{
+ return new cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, "paxr",
+ ".tar.gz");
+}
-cmCPackArchiveGenerator::cmCPackArchiveGenerator(cmArchiveWrite::Compress t,
- std::string const& format)
+cmCPackGenerator* cmCPackArchiveGenerator::CreateTXZGenerator()
{
- this->Compress = t;
- this->ArchiveFormat = format;
+ return new cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr",
+ ".tar.xz");
}
-cmCPackArchiveGenerator::~cmCPackArchiveGenerator()
+cmCPackGenerator* cmCPackArchiveGenerator::CreateTZGenerator()
{
+ return new cmCPackArchiveGenerator(cmArchiveWrite::CompressCompress, "paxr",
+ ".tar.Z");
}
+cmCPackGenerator* cmCPackArchiveGenerator::CreateTZSTGenerator()
+{
+ return new cmCPackArchiveGenerator(cmArchiveWrite::CompressZstd, "paxr",
+ ".tar.zst");
+}
+
+cmCPackGenerator* cmCPackArchiveGenerator::CreateZIPGenerator()
+{
+ return new cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "zip",
+ ".zip");
+}
+
+cmCPackArchiveGenerator::cmCPackArchiveGenerator(
+ cmArchiveWrite::Compress compress, std::string format, std::string extension)
+ : Compress(compress)
+ , ArchiveFormat(std::move(format))
+ , OutputExtension(std::move(extension))
+{
+}
+
+cmCPackArchiveGenerator::~cmCPackArchiveGenerator() = default;
+
std::string cmCPackArchiveGenerator::GetArchiveComponentFileName(
const std::string& component, bool isGroupName)
{
@@ -52,6 +95,7 @@ int cmCPackArchiveGenerator::InitializeInternal()
this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1");
return this->Superclass::InitializeInternal();
}
+
int cmCPackArchiveGenerator::addOneComponentToArchive(
cmArchiveWrite& archive, cmCPackComponent* component)
{
@@ -62,10 +106,16 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
localToplevel += "/" + component->Name;
// Change to local toplevel
cmWorkingDirectory workdir(localToplevel);
+ if (workdir.Failed()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Failed to change working directory to "
+ << localToplevel << " : "
+ << std::strerror(workdir.GetLastResult()) << std::endl);
+ return 0;
+ }
std::string filePrefix;
if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
- filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME");
- filePrefix += "/";
+ filePrefix = cmStrCat(this->GetOption("CPACK_PACKAGE_FILE_NAME"), '/');
}
const char* installPrefix =
this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
@@ -74,15 +124,14 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
filePrefix += installPrefix + 1;
filePrefix += "/";
}
- std::vector<std::string>::const_iterator fileIt;
- for (fileIt = component->Files.begin(); fileIt != component->Files.end();
- ++fileIt) {
- std::string rp = filePrefix + *fileIt;
+ for (std::string const& file : component->Files) {
+ std::string rp = filePrefix + file;
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file: " << rp << std::endl);
- archive.Add(rp, 0, CM_NULLPTR, false);
+ archive.Add(rp, 0, nullptr, false);
if (!archive) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "ERROR while packaging files: "
- << archive.GetError() << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "ERROR while packaging files: " << archive.GetError()
+ << std::endl);
return 0;
}
}
@@ -96,20 +145,23 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
*/
#define DECLARE_AND_OPEN_ARCHIVE(filename, archive) \
cmGeneratedFileStream gf; \
- gf.Open((filename).c_str(), false, true); \
+ gf.Open((filename), false, true); \
if (!GenerateHeader(&gf)) { \
cmCPackLogger(cmCPackLog::LOG_ERROR, \
- "Problem to generate Header for archive < " \
+ "Problem to generate Header for archive <" \
<< (filename) << ">." << std::endl); \
return 0; \
} \
cmArchiveWrite archive(gf, this->Compress, this->ArchiveFormat); \
- if (!(archive)) { \
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem to create archive < " \
- << (filename) << ">. ERROR =" << (archive).GetError() \
- << std::endl); \
- return 0; \
- }
+ do { \
+ if (!(archive)) { \
+ cmCPackLogger(cmCPackLog::LOG_ERROR, \
+ "Problem to create archive <" \
+ << (filename) << ">, ERROR = " << (archive).GetError() \
+ << std::endl); \
+ return 0; \
+ } \
+ } while (false)
int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
{
@@ -117,79 +169,72 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
if (!ignoreGroup) {
- std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
- for (compGIt = this->ComponentGroups.begin();
- compGIt != this->ComponentGroups.end(); ++compGIt) {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
- << compGIt->first << std::endl);
+ for (auto const& compG : this->ComponentGroups) {
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Packaging component group: " << compG.first << std::endl);
// Begin the archive for this group
std::string packageFileName = std::string(toplevel) + "/" +
- this->GetArchiveComponentFileName(compGIt->first, true);
+ this->GetArchiveComponentFileName(compG.first, true);
// open a block in order to automatically close archive
// at the end of the block
{
DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
// now iterate over the component of this group
- std::vector<cmCPackComponent*>::iterator compIt;
- for (compIt = (compGIt->second).Components.begin();
- compIt != (compGIt->second).Components.end(); ++compIt) {
+ for (cmCPackComponent* comp : (compG.second).Components) {
// Add the files of this component to the archive
- addOneComponentToArchive(archive, *compIt);
+ addOneComponentToArchive(archive, comp);
}
}
// add the generated package to package file names list
- packageFileNames.push_back(packageFileName);
+ packageFileNames.push_back(std::move(packageFileName));
}
// Handle Orphan components (components not belonging to any groups)
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
+ for (auto& comp : this->Components) {
// Does the component belong to a group?
- if (compIt->second.Group == CM_NULLPTR) {
+ if (comp.second.Group == nullptr) {
cmCPackLogger(
- cmCPackLog::LOG_VERBOSE, "Component <"
- << compIt->second.Name
+ cmCPackLog::LOG_VERBOSE,
+ "Component <"
+ << comp.second.Name
<< "> does not belong to any group, package it separately."
<< std::endl);
std::string localToplevel(
this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
std::string packageFileName = std::string(toplevel);
- localToplevel += "/" + compIt->first;
+ localToplevel += "/" + comp.first;
packageFileName +=
- "/" + this->GetArchiveComponentFileName(compIt->first, false);
+ "/" + this->GetArchiveComponentFileName(comp.first, false);
{
DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
// Add the files of this component to the archive
- addOneComponentToArchive(archive, &(compIt->second));
+ addOneComponentToArchive(archive, &(comp.second));
}
// add the generated package to package file names list
- packageFileNames.push_back(packageFileName);
+ packageFileNames.push_back(std::move(packageFileName));
}
}
}
// CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component
else {
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
+ for (auto& comp : this->Components) {
std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
std::string packageFileName = std::string(toplevel);
- localToplevel += "/" + compIt->first;
+ localToplevel += "/" + comp.first;
packageFileName +=
- "/" + this->GetArchiveComponentFileName(compIt->first, false);
+ "/" + this->GetArchiveComponentFileName(comp.first, false);
{
DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
// Add the files of this component to the archive
- addOneComponentToArchive(archive, &(compIt->second));
+ addOneComponentToArchive(archive, &(comp.second));
}
// add the generated package to package file names list
- packageFileNames.push_back(packageFileName);
+ packageFileNames.push_back(std::move(packageFileName));
}
}
return 1;
@@ -199,7 +244,7 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne()
{
// reset the package file names
packageFileNames.clear();
- packageFileNames.push_back(std::string(toplevel));
+ packageFileNames.emplace_back(toplevel);
packageFileNames[0] += "/";
if (this->IsSet("CPACK_ARCHIVE_FILE_NAME")) {
@@ -217,11 +262,9 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne()
DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive);
// The ALL COMPONENTS in ONE package case
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
+ for (auto& comp : this->Components) {
// Add the files of this component to the archive
- addOneComponentToArchive(archive, &(compIt->second));
+ addOneComponentToArchive(archive, &(comp.second));
}
// archive goes out of scope so it will finalized and closed.
@@ -249,17 +292,23 @@ int cmCPackArchiveGenerator::PackageFiles()
// CASE 3 : NON COMPONENT package.
DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive);
- std::vector<std::string>::const_iterator fileIt;
cmWorkingDirectory workdir(toplevel);
- for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
+ if (workdir.Failed()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Failed to change working directory to "
+ << toplevel << " : "
+ << std::strerror(workdir.GetLastResult()) << std::endl);
+ return 0;
+ }
+ for (std::string const& file : files) {
// Get the relative path to the file
- std::string rp =
- cmSystemTools::RelativePath(toplevel.c_str(), fileIt->c_str());
- archive.Add(rp, 0, CM_NULLPTR, false);
+ std::string rp = cmSystemTools::RelativePath(toplevel, file);
+ archive.Add(rp, 0, nullptr, false);
if (!archive) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< "
- << *fileIt << "> to archive <" << packageFileNames[0]
- << "> .ERROR =" << archive.GetError() << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem while adding file <"
+ << file << "> to archive <" << packageFileNames[0]
+ << ">, ERROR = " << archive.GetError() << std::endl);
return 0;
}
}
diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h
index e7116c466..8d677208f 100644
--- a/Source/CPack/cmCPackArchiveGenerator.h
+++ b/Source/CPack/cmCPackArchiveGenerator.h
@@ -3,14 +3,14 @@
#ifndef cmCPackArchiveGenerator_h
#define cmCPackArchiveGenerator_h
-#include "cmConfigure.h"
-
-#include "cmArchiveWrite.h"
-#include "cmCPackGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
+#include "cmArchiveWrite.h"
+#include "cmCPackGenerator.h"
+
class cmCPackComponent;
/** \class cmCPackArchiveGenerator
@@ -22,17 +22,26 @@ class cmCPackComponent;
class cmCPackArchiveGenerator : public cmCPackGenerator
{
public:
- typedef cmCPackGenerator Superclass;
+ using Superclass = cmCPackGenerator;
+
+ static cmCPackGenerator* Create7ZGenerator();
+ static cmCPackGenerator* CreateTBZ2Generator();
+ static cmCPackGenerator* CreateTGZGenerator();
+ static cmCPackGenerator* CreateTXZGenerator();
+ static cmCPackGenerator* CreateTZGenerator();
+ static cmCPackGenerator* CreateTZSTGenerator();
+ static cmCPackGenerator* CreateZIPGenerator();
/**
* Construct generator
*/
- cmCPackArchiveGenerator(cmArchiveWrite::Compress, std::string const& format);
- ~cmCPackArchiveGenerator() CM_OVERRIDE;
+ cmCPackArchiveGenerator(cmArchiveWrite::Compress t, std::string format,
+ std::string extension);
+ ~cmCPackArchiveGenerator() override;
// Used to add a header to the archive
virtual int GenerateHeader(std::ostream* os);
// component support
- bool SupportsComponentInstallation() const CM_OVERRIDE;
+ bool SupportsComponentInstallation() const override;
private:
// get archive component filename
@@ -40,7 +49,7 @@ private:
bool isGroupName);
protected:
- int InitializeInternal() CM_OVERRIDE;
+ int InitializeInternal() override;
/**
* Add the files belonging to the specified component
* to the provided (already opened) archive.
@@ -56,7 +65,7 @@ protected:
* method will call either PackageComponents or
* PackageComponentsAllInOne.
*/
- int PackageFiles() CM_OVERRIDE;
+ int PackageFiles() override;
/**
* The method used to package files when component
* install is used. This will create one
@@ -68,9 +77,19 @@ protected:
* components will be put in a single installer.
*/
int PackageComponentsAllInOne();
- const char* GetOutputExtension() CM_OVERRIDE = 0;
+
+private:
+ const char* GetNameOfClass() override { return "cmCPackArchiveGenerator"; }
+
+ const char* GetOutputExtension() override
+ {
+ return this->OutputExtension.c_str();
+ }
+
+private:
cmArchiveWrite::Compress Compress;
std::string ArchiveFormat;
+ std::string OutputExtension;
};
#endif
diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx
index d5389014a..4d5f43f9e 100644
--- a/Source/CPack/cmCPackBundleGenerator.cxx
+++ b/Source/CPack/cmCPackBundleGenerator.cxx
@@ -6,20 +6,17 @@
#include <vector>
#include "cmCPackLog.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-cmCPackBundleGenerator::cmCPackBundleGenerator()
-{
-}
+cmCPackBundleGenerator::cmCPackBundleGenerator() = default;
-cmCPackBundleGenerator::~cmCPackBundleGenerator()
-{
-}
+cmCPackBundleGenerator::~cmCPackBundleGenerator() = default;
int cmCPackBundleGenerator::InitializeInternal()
{
const char* name = this->GetOption("CPACK_BUNDLE_NAME");
- if (0 == name) {
+ if (nullptr == name) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_BUNDLE_NAME must be set to use the Bundle generator."
<< std::endl);
@@ -32,8 +29,8 @@ int cmCPackBundleGenerator::InitializeInternal()
"codesign", std::vector<std::string>(), false);
if (codesign_path.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate codesign command"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot locate codesign command" << std::endl);
return 0;
}
this->SetOptionIfNotSet("CPACK_COMMAND_CODESIGN", codesign_path.c_str());
@@ -44,9 +41,8 @@ int cmCPackBundleGenerator::InitializeInternal()
const char* cmCPackBundleGenerator::GetPackagingInstallPrefix()
{
- this->InstallPrefix = "/";
- this->InstallPrefix += this->GetOption("CPACK_BUNDLE_NAME");
- this->InstallPrefix += ".app/Contents/Resources";
+ this->InstallPrefix = cmStrCat('/', this->GetOption("CPACK_BUNDLE_NAME"),
+ ".app/Contents/Resources");
return this->InstallPrefix.c_str();
}
@@ -59,8 +55,8 @@ int cmCPackBundleGenerator::ConstructBundle()
? this->GetOption("CPACK_BUNDLE_NAME")
: "";
if (cpack_bundle_name.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_NAME must be set."
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_BUNDLE_NAME must be set." << std::endl);
return 0;
}
@@ -69,8 +65,8 @@ int cmCPackBundleGenerator::ConstructBundle()
? this->GetOption("CPACK_BUNDLE_PLIST")
: "";
if (cpack_bundle_plist.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_PLIST must be set."
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_BUNDLE_PLIST must be set." << std::endl);
return 0;
}
@@ -79,8 +75,8 @@ int cmCPackBundleGenerator::ConstructBundle()
? this->GetOption("CPACK_BUNDLE_ICON")
: "";
if (cpack_bundle_icon.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_ICON must be set."
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_BUNDLE_ICON must be set." << std::endl);
return 0;
}
@@ -93,11 +89,10 @@ int cmCPackBundleGenerator::ConstructBundle()
// The staging directory contains everything that will end-up inside the
// final disk image ...
- std::ostringstream staging;
- staging << toplevel;
+ std::string const staging = toplevel;
std::ostringstream contents;
- contents << staging.str() << "/" << cpack_bundle_name << ".app/"
+ contents << staging << "/" << cpack_bundle_name << ".app/"
<< "Contents";
std::ostringstream application;
@@ -194,9 +189,8 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
if (!cpack_apple_cert_app.empty()) {
std::string output;
std::string bundle_path;
- bundle_path = src_dir + "/";
- bundle_path += this->GetOption("CPACK_BUNDLE_NAME");
- bundle_path += ".app";
+ bundle_path =
+ cmStrCat(src_dir, '/', this->GetOption("CPACK_BUNDLE_NAME"), ".app");
// A list of additional files to sign, ie. frameworks and plugins.
const std::string sign_parameter =
@@ -209,12 +203,10 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES")
: "";
- std::vector<std::string> relFiles;
- cmSystemTools::ExpandListArgument(sign_files, relFiles);
+ std::vector<std::string> relFiles = cmExpandedList(sign_files);
// sign the files supplied by the user, ie. frameworks.
- for (std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it) {
+ for (auto const& file : relFiles) {
std::ostringstream temp_sign_file_cmd;
temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
temp_sign_file_cmd << " " << sign_parameter << " -s \""
@@ -223,11 +215,11 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
temp_sign_file_cmd << this->GetOption("CPACK_APPLE_BUNDLE_ID");
temp_sign_file_cmd << " \"";
temp_sign_file_cmd << bundle_path;
- temp_sign_file_cmd << *it << "\"";
+ temp_sign_file_cmd << file << "\"";
if (!this->RunCommand(temp_sign_file_cmd, &output)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error signing file:" << bundle_path << *it << std::endl
+ "Error signing file:" << bundle_path << file << std::endl
<< output << std::endl);
return 0;
@@ -270,8 +262,8 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
return 0;
}
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Application has been codesigned"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "- Application has been codesigned" << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
(this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")
? "with entitlement sandboxing"
diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h
index 861fe4b09..27bac3a5a 100644
--- a/Source/CPack/cmCPackBundleGenerator.h
+++ b/Source/CPack/cmCPackBundleGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmCPackBundleGenerator_h
#define cmCPackBundleGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
@@ -21,15 +21,15 @@ public:
cmCPackTypeMacro(cmCPackBundleGenerator, cmCPackDragNDropGenerator);
cmCPackBundleGenerator();
- virtual ~cmCPackBundleGenerator();
+ ~cmCPackBundleGenerator() override;
protected:
- int InitializeInternal() CM_OVERRIDE;
- const char* GetPackagingInstallPrefix() CM_OVERRIDE;
+ int InitializeInternal() override;
+ const char* GetPackagingInstallPrefix() override;
int ConstructBundle();
int SignBundle(const std::string& src_dir);
- int PackageFiles() CM_OVERRIDE;
- bool SupportsComponentInstallation() const CM_OVERRIDE;
+ int PackageFiles() override;
+ bool SupportsComponentInstallation() const override;
std::string InstallPrefix;
};
diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx
index e39398ad5..d40e5fcf8 100644
--- a/Source/CPack/cmCPackComponentGroup.cxx
+++ b/Source/CPack/cmCPackComponentGroup.cxx
@@ -2,10 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackComponentGroup.h"
-#include "cmSystemTools.h"
-
#include <string>
-#include <vector>
+
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
unsigned long cmCPackComponent::GetInstalledSize(
const std::string& installDir) const
@@ -14,11 +14,8 @@ unsigned long cmCPackComponent::GetInstalledSize(
return this->TotalSize;
}
- std::vector<std::string>::const_iterator fileIt;
- for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt) {
- std::string path = installDir;
- path += '/';
- path += *fileIt;
+ for (std::string const& file : this->Files) {
+ std::string path = cmStrCat(installDir, '/', file);
this->TotalSize += cmSystemTools::FileLength(path);
}
diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h
index 26d69ba68..bb980d77f 100644
--- a/Source/CPack/cmCPackComponentGroup.h
+++ b/Source/CPack/cmCPackComponentGroup.h
@@ -3,7 +3,7 @@
#ifndef cmCPackComponentGroup_h
#define cmCPackComponentGroup_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
@@ -36,7 +36,7 @@ class cmCPackComponent
{
public:
cmCPackComponent()
- : Group(CM_NULLPTR)
+ : Group(nullptr)
, IsRequired(true)
, IsHidden(false)
, IsDisabledByDefault(false)
@@ -114,7 +114,7 @@ class cmCPackComponentGroup
{
public:
cmCPackComponentGroup()
- : ParentGroup(CM_NULLPTR)
+ : ParentGroup(nullptr)
{
}
@@ -143,4 +143,29 @@ public:
std::vector<cmCPackComponentGroup*> Subgroups;
};
+/** \class cmCPackInstallCMakeProject
+ * \brief A single quadruplet from the CPACK_INSTALL_CMAKE_PROJECTS variable.
+ */
+class cmCPackInstallCMakeProject
+{
+public:
+ /// The directory of the CMake project.
+ std::string Directory;
+
+ /// The name of the CMake project.
+ std::string ProjectName;
+
+ /// The name of the component (or component set) to install.
+ std::string Component;
+
+ /// The subdirectory to install into.
+ std::string SubDirectory;
+
+ /// The list of installation types.
+ std::vector<cmCPackInstallationType*> InstallationTypes;
+
+ /// The list of components.
+ std::vector<cmCPackComponent*> Components;
+};
+
#endif
diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
index 2119f782b..b5abd5a6b 100644
--- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
+++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackCygwinBinaryGenerator.h"
+#include "cmsys/SystemTools.hxx"
+
#include "cmCPackLog.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
@@ -9,9 +11,8 @@
#include "cmSystemTools.h"
#include "cmake.h"
-#include "cmsys/SystemTools.hxx"
-
cmCPackCygwinBinaryGenerator::cmCPackCygwinBinaryGenerator()
+ : cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, "paxr", ".tar.bz2")
{
}
@@ -28,13 +29,11 @@ int cmCPackCygwinBinaryGenerator::InitializeInternal()
int cmCPackCygwinBinaryGenerator::PackageFiles()
{
- std::string packageName = this->GetOption("CPACK_PACKAGE_NAME");
- packageName += "-";
- packageName += this->GetOption("CPACK_PACKAGE_VERSION");
+ std::string packageName =
+ cmStrCat(this->GetOption("CPACK_PACKAGE_NAME"), '-',
+ this->GetOption("CPACK_PACKAGE_VERSION"));
packageName = cmsys::SystemTools::LowerCase(packageName);
- std::string manifest = "/usr/share/doc/";
- manifest += packageName;
- manifest += "/MANIFEST";
+ std::string manifest = cmStrCat("/usr/share/doc/", packageName, "/MANIFEST");
std::string manifestFile = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
// Create a MANIFEST file that contains all of the files in
// the tar file
@@ -44,10 +43,9 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
// to create the file before the super class is called
{
cmGeneratedFileStream ofs(manifestFile.c_str());
- for (std::vector<std::string>::const_iterator i = files.begin();
- i != files.end(); ++i) {
+ for (std::string const& file : files) {
// remove the temp dir and replace with /usr
- ofs << (*i).substr(tempdir.size()) << "\n";
+ ofs << file.substr(tempdir.size()) << "\n";
}
ofs << manifest << "\n";
}
diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.h b/Source/CPack/cmCPackCygwinBinaryGenerator.h
index 58e80bda7..47bd41e13 100644
--- a/Source/CPack/cmCPackCygwinBinaryGenerator.h
+++ b/Source/CPack/cmCPackCygwinBinaryGenerator.h
@@ -3,21 +3,21 @@
#ifndef cmCPackCygwinBinaryGenerator_h
#define cmCPackCygwinBinaryGenerator_h
-#include "cmCPackTarBZip2Generator.h"
+#include "cmCPackArchiveGenerator.h"
/** \class cmCPackCygwinBinaryGenerator
* \brief A generator for TarBZip2 files
*/
-class cmCPackCygwinBinaryGenerator : public cmCPackTarBZip2Generator
+class cmCPackCygwinBinaryGenerator : public cmCPackArchiveGenerator
{
public:
- cmCPackTypeMacro(cmCPackCygwinBinaryGenerator, cmCPackTarBZip2Generator);
+ cmCPackTypeMacro(cmCPackCygwinBinaryGenerator, cmCPackArchiveGenerator);
/**
* Construct generator
*/
cmCPackCygwinBinaryGenerator();
- virtual ~cmCPackCygwinBinaryGenerator();
+ ~cmCPackCygwinBinaryGenerator() override;
protected:
virtual int InitializeInternal();
diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.cxx b/Source/CPack/cmCPackCygwinSourceGenerator.cxx
index 2c289f668..64a88eba4 100644
--- a/Source/CPack/cmCPackCygwinSourceGenerator.cxx
+++ b/Source/CPack/cmCPackCygwinSourceGenerator.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackCygwinSourceGenerator.h"
+#include "cmsys/SystemTools.hxx"
+
#include "cmCPackLog.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
@@ -9,17 +11,17 @@
#include "cmSystemTools.h"
#include "cmake.h"
-#include "cmsys/SystemTools.hxx"
-
// Includes needed for implementation of RenameFile. This is not in
// system tools because it is not implemented robustly enough to move
// files across directories.
#ifdef _WIN32
-#include "cm_sys_stat.h"
-#include <windows.h>
+# include <windows.h>
+
+# include "cm_sys_stat.h"
#endif
cmCPackCygwinSourceGenerator::cmCPackCygwinSourceGenerator()
+ : cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, "paxr", ".tar.bz2")
{
}
@@ -37,15 +39,11 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
{
// Create a tar file of the sources
std::string packageDirFileName =
- this->GetOption("CPACK_TEMPORARY_DIRECTORY");
- packageDirFileName += ".tar.bz2";
+ cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), ".tar.bz2");
packageFileNames[0] = packageDirFileName;
std::string output;
- // skip one parent up to the cmCPackTarBZip2Generator
- // to create tar.bz2 file with the list of source
- // files
- this->Compress = cmArchiveWrite::CompressBZip2;
- if (!this->cmCPackTarBZip2Generator::PackageFiles()) {
+ // create tar.bz2 file with the list of source files
+ if (!this->cmCPackArchiveGenerator::PackageFiles()) {
return 0;
}
// Now create a tar file that contains the above .tar.bz2 file
@@ -73,7 +71,8 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
if (!cmSystemTools::CopyFileAlways(
this->GetOption("CPACK_CYGWIN_PATCH_FILE"),
this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: ["
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "problem copying: ["
<< this->GetOption("CPACK_CYGWIN_PATCH_FILE") << "]\nto\n["
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
return 0;
@@ -87,35 +86,36 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
if (!cmSystemTools::CopyFileAlways(
this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"),
this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: "
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "problem copying: "
<< this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT") << "\nto\n"
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
return 0;
}
- std::string outerTarFile = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
- outerTarFile += "-";
+ std::string outerTarFile =
+ cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), '-');
const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
if (!patch) {
- cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER"
+ cmCPackLogger(cmCPackLog::LOG_WARNING,
+ "CPACK_CYGWIN_PATCH_NUMBER"
<< " not specified, defaulting to 1\n");
patch = "1";
}
outerTarFile += patch;
outerTarFile += "-src.tar.bz2";
std::string tmpDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- std::string buildScript = tmpDir;
- buildScript += "/";
- buildScript += cmSystemTools::GetFilenameName(
- this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"));
- std::string patchFile = tmpDir;
- patchFile += "/";
- patchFile +=
- cmSystemTools::GetFilenameName(this->GetOption("CPACK_CYGWIN_PATCH_FILE"));
+ std::string buildScript =
+ cmStrCat(tmpDir, '/',
+ cmSystemTools::GetFilenameName(
+ this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT")));
+ std::string patchFile =
+ cmStrCat(tmpDir, '/',
+ cmSystemTools::GetFilenameName(
+ this->GetOption("CPACK_CYGWIN_PATCH_FILE")));
std::string file = cmSystemTools::GetFilenameName(compressOutFile);
- std::string sourceTar = cmSystemTools::GetFilenamePath(compressOutFile);
- sourceTar += "/";
- sourceTar += file;
+ std::string sourceTar =
+ cmStrCat(cmSystemTools::GetFilenamePath(compressOutFile), '/', file);
/* reset list of file to be packaged */
files.clear();
// a source release in cygwin should have the build script used
@@ -129,7 +129,7 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
packageFileNames[0] = outerTarFile;
/* update the toplevel dir */
toplevel = tmpDir;
- if (!this->cmCPackTarBZip2Generator::PackageFiles()) {
+ if (!this->cmCPackArchiveGenerator::PackageFiles()) {
return 0;
}
return 1;
@@ -137,8 +137,8 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
const char* cmCPackCygwinSourceGenerator::GetPackagingInstallPrefix()
{
- this->InstallPrefix = "/";
- this->InstallPrefix += this->GetOption("CPACK_PACKAGE_FILE_NAME");
+ this->InstallPrefix =
+ cmStrCat('/', this->GetOption("CPACK_PACKAGE_FILE_NAME"));
return this->InstallPrefix.c_str();
}
@@ -147,7 +147,8 @@ const char* cmCPackCygwinSourceGenerator::GetOutputExtension()
this->OutputExtension = "-";
const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
if (!patch) {
- cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER"
+ cmCPackLogger(cmCPackLog::LOG_WARNING,
+ "CPACK_CYGWIN_PATCH_NUMBER"
<< " not specified, defaulting to 1\n");
patch = "1";
}
diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.h b/Source/CPack/cmCPackCygwinSourceGenerator.h
index 896de1d3e..98d8f0ab7 100644
--- a/Source/CPack/cmCPackCygwinSourceGenerator.h
+++ b/Source/CPack/cmCPackCygwinSourceGenerator.h
@@ -3,21 +3,21 @@
#ifndef cmCPackCygwinSourceGenerator_h
#define cmCPackCygwinSourceGenerator_h
-#include "cmCPackTarBZip2Generator.h"
+#include "cmCPackArchiveGenerator.h"
/** \class cmCPackCygwinSourceGenerator
* \brief A generator for cygwin source files
*/
-class cmCPackCygwinSourceGenerator : public cmCPackTarBZip2Generator
+class cmCPackCygwinSourceGenerator : public cmCPackArchiveGenerator
{
public:
- cmCPackTypeMacro(cmCPackCygwinSourceGenerator, cmCPackTarBZip2Generator);
+ cmCPackTypeMacro(cmCPackCygwinSourceGenerator, cmCPackArchiveGenerator);
/**
* Construct generator
*/
cmCPackCygwinSourceGenerator();
- virtual ~cmCPackCygwinSourceGenerator();
+ ~cmCPackCygwinSourceGenerator() override;
protected:
const char* GetPackagingInstallPrefix();
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index af54fce33..5b7d8fb68 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -2,44 +2,444 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackDebGenerator.h"
+#include <cstring>
+#include <map>
+#include <ostream>
+#include <set>
+#include <utility>
+
+#include "cmsys/Glob.hxx"
+
+#include "cm_sys_stat.h"
+
#include "cmArchiveWrite.h"
#include "cmCPackComponentGroup.h"
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
+#include "cmCryptoHash.h"
#include "cmGeneratedFileStream.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_sys_stat.h"
-#include "cmsys/Glob.hxx"
-#include <limits.h>
-#include <map>
-#include <ostream>
-#include <set>
-#include <stdio.h>
-#include <string.h>
-#include <utility>
+namespace {
+
+class DebGenerator
+{
+public:
+ DebGenerator(cmCPackLog* logger, std::string outputName, std::string workDir,
+ std::string topLevelDir, std::string temporaryDir,
+ const char* debianCompressionType,
+ const char* debianArchiveType,
+ std::map<std::string, std::string> controlValues,
+ bool genShLibs, std::string shLibsFilename, bool genPostInst,
+ std::string postInst, bool genPostRm, std::string postRm,
+ const char* controlExtra, bool permissionStrctPolicy,
+ std::vector<std::string> packageFiles);
+
+ bool generate() const;
+
+private:
+ void generateDebianBinaryFile() const;
+ void generateControlFile() const;
+ bool generateDataTar() const;
+ std::string generateMD5File() const;
+ bool generateControlTar(std::string const& md5Filename) const;
+ bool generateDeb() const;
+
+ cmCPackLog* Logger;
+ const std::string OutputName;
+ const std::string WorkDir;
+ std::string CompressionSuffix;
+ const std::string TopLevelDir;
+ const std::string TemporaryDir;
+ const char* DebianArchiveType;
+ const std::map<std::string, std::string> ControlValues;
+ const bool GenShLibs;
+ const std::string ShLibsFilename;
+ const bool GenPostInst;
+ const std::string PostInst;
+ const bool GenPostRm;
+ const std::string PostRm;
+ const char* ControlExtra;
+ const bool PermissionStrictPolicy;
+ const std::vector<std::string> PackageFiles;
+ cmArchiveWrite::Compress TarCompressionType;
+};
+
+DebGenerator::DebGenerator(
+ cmCPackLog* logger, std::string outputName, std::string workDir,
+ std::string topLevelDir, std::string temporaryDir,
+ const char* debianCompressionType, const char* debianArchiveType,
+ std::map<std::string, std::string> controlValues, bool genShLibs,
+ std::string shLibsFilename, bool genPostInst, std::string postInst,
+ bool genPostRm, std::string postRm, const char* controlExtra,
+ bool permissionStrictPolicy, std::vector<std::string> packageFiles)
+ : Logger(logger)
+ , OutputName(std::move(outputName))
+ , WorkDir(std::move(workDir))
+ , TopLevelDir(std::move(topLevelDir))
+ , TemporaryDir(std::move(temporaryDir))
+ , DebianArchiveType(debianArchiveType ? debianArchiveType : "gnutar")
+ , ControlValues(std::move(controlValues))
+ , GenShLibs(genShLibs)
+ , ShLibsFilename(std::move(shLibsFilename))
+ , GenPostInst(genPostInst)
+ , PostInst(std::move(postInst))
+ , GenPostRm(genPostRm)
+ , PostRm(std::move(postRm))
+ , ControlExtra(controlExtra)
+ , PermissionStrictPolicy(permissionStrictPolicy)
+ , PackageFiles(std::move(packageFiles))
+{
+ if (!debianCompressionType) {
+ debianCompressionType = "gzip";
+ }
+
+ if (!strcmp(debianCompressionType, "lzma")) {
+ CompressionSuffix = ".lzma";
+ TarCompressionType = cmArchiveWrite::CompressLZMA;
+ } else if (!strcmp(debianCompressionType, "xz")) {
+ CompressionSuffix = ".xz";
+ TarCompressionType = cmArchiveWrite::CompressXZ;
+ } else if (!strcmp(debianCompressionType, "bzip2")) {
+ CompressionSuffix = ".bz2";
+ TarCompressionType = cmArchiveWrite::CompressBZip2;
+ } else if (!strcmp(debianCompressionType, "gzip")) {
+ CompressionSuffix = ".gz";
+ TarCompressionType = cmArchiveWrite::CompressGZip;
+ } else if (!strcmp(debianCompressionType, "none")) {
+ CompressionSuffix.clear();
+ TarCompressionType = cmArchiveWrite::CompressNone;
+ } else {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error unrecognized compression type: "
+ << debianCompressionType << std::endl);
+ }
+}
+
+bool DebGenerator::generate() const
+{
+ generateDebianBinaryFile();
+ generateControlFile();
+ if (!generateDataTar()) {
+ return false;
+ }
+ std::string md5Filename = generateMD5File();
+ if (!generateControlTar(md5Filename)) {
+ return false;
+ }
+ return generateDeb();
+}
+
+void DebGenerator::generateDebianBinaryFile() const
+{
+ // debian-binary file
+ const std::string dbfilename = WorkDir + "/debian-binary";
+ cmGeneratedFileStream out(dbfilename);
+ out << "2.0";
+ out << std::endl; // required for valid debian package
+}
+
+void DebGenerator::generateControlFile() const
+{
+ std::string ctlfilename = WorkDir + "/control";
+
+ cmGeneratedFileStream out(ctlfilename);
+ for (auto const& kv : ControlValues) {
+ out << kv.first << ": " << kv.second << "\n";
+ }
-// NOTE:
-// A debian package .deb is simply an 'ar' archive. The only subtle difference
-// is that debian uses the BSD ar style archive whereas most Linux distro have
-// a GNU ar.
-// See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=161593 for more info
-// Therefore we provide our own implementation of a BSD-ar:
-static int ar_append(const char* archive,
- const std::vector<std::string>& files);
+ unsigned long totalSize = 0;
+ {
+ std::string dirName = cmStrCat(TemporaryDir, '/');
+ for (std::string const& file : PackageFiles) {
+ totalSize += cmSystemTools::FileLength(file);
+ }
+ }
+ out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n";
+ out << std::endl;
+}
-cmCPackDebGenerator::cmCPackDebGenerator()
+bool DebGenerator::generateDataTar() const
{
+ std::string filename_data_tar = WorkDir + "/data.tar" + CompressionSuffix;
+ cmGeneratedFileStream fileStream_data_tar;
+ fileStream_data_tar.Open(filename_data_tar, false, true);
+ if (!fileStream_data_tar) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error opening the file \""
+ << filename_data_tar << "\" for writing" << std::endl);
+ return false;
+ }
+ cmArchiveWrite data_tar(fileStream_data_tar, TarCompressionType,
+ DebianArchiveType);
+
+ // uid/gid should be the one of the root user, and this root user has
+ // always uid/gid equal to 0.
+ data_tar.SetUIDAndGID(0u, 0u);
+ data_tar.SetUNAMEAndGNAME("root", "root");
+
+ // now add all directories which have to be compressed
+ // collect all top level install dirs for that
+ // e.g. /opt/bin/foo, /usr/bin/bar and /usr/bin/baz would
+ // give /usr and /opt
+ size_t topLevelLength = WorkDir.length();
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "WDIR: \"" << WorkDir << "\", length = " << topLevelLength
+ << std::endl);
+ std::set<std::string> orderedFiles;
+
+ // we have to reconstruct the parent folders as well
+
+ for (std::string currentPath : PackageFiles) {
+ while (currentPath != WorkDir) {
+ // the last one IS WorkDir, but we do not want this one:
+ // XXX/application/usr/bin/myprogram with GEN_WDIR=XXX/application
+ // should not add XXX/application
+ orderedFiles.insert(currentPath);
+ currentPath = cmSystemTools::CollapseFullPath("..", currentPath);
+ }
+ }
+
+ for (std::string const& file : orderedFiles) {
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "FILEIT: \"" << file << "\"" << std::endl);
+ std::string::size_type slashPos = file.find('/', topLevelLength + 1);
+ std::string relativeDir =
+ file.substr(topLevelLength, slashPos - topLevelLength);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "RELATIVEDIR: \"" << relativeDir << "\"" << std::endl);
+
+#ifdef WIN32
+ std::string mode_t_adt_filename = file + ":cmake_mode_t";
+ cmsys::ifstream permissionStream(mode_t_adt_filename.c_str());
+
+ mode_t permissions = 0;
+
+ if (permissionStream) {
+ permissionStream >> std::oct >> permissions;
+ }
+
+ if (permissions != 0) {
+ data_tar.SetPermissions(permissions);
+ } else if (cmSystemTools::FileIsDirectory(file)) {
+ data_tar.SetPermissions(0755);
+ } else {
+ data_tar.ClearPermissions();
+ }
+#endif
+
+ // do not recurse because the loop will do it
+ if (!data_tar.Add(file, topLevelLength, ".", false)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem adding file to tar:"
+ << std::endl
+ << "#top level directory: " << WorkDir << std::endl
+ << "#file: " << file << std::endl
+ << "#error:" << data_tar.GetError() << std::endl);
+ return false;
+ }
+ }
+ return true;
}
-cmCPackDebGenerator::~cmCPackDebGenerator()
+std::string DebGenerator::generateMD5File() const
{
+ std::string md5filename = WorkDir + "/md5sums";
+
+ cmGeneratedFileStream out(md5filename);
+
+ std::string topLevelWithTrailingSlash = cmStrCat(TemporaryDir, '/');
+ for (std::string const& file : PackageFiles) {
+ // hash only regular files
+ if (cmSystemTools::FileIsDirectory(file) ||
+ cmSystemTools::FileIsSymlink(file)) {
+ continue;
+ }
+
+ std::string output =
+ cmSystemTools::ComputeFileHash(file, cmCryptoHash::AlgoMD5);
+ if (output.empty()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem computing the md5 of " << file << std::endl);
+ }
+
+ output += " " + file + "\n";
+ // debian md5sums entries are like this:
+ // 014f3604694729f3bf19263bac599765 usr/bin/ccmake
+ // thus strip the full path (with the trailing slash)
+ cmSystemTools::ReplaceString(output, topLevelWithTrailingSlash.c_str(),
+ "");
+ out << output;
+ }
+ // each line contains a eol.
+ // Do not end the md5sum file with yet another (invalid)
+ return md5filename;
}
+bool DebGenerator::generateControlTar(std::string const& md5Filename) const
+{
+ std::string filename_control_tar = WorkDir + "/control.tar.gz";
+
+ cmGeneratedFileStream fileStream_control_tar;
+ fileStream_control_tar.Open(filename_control_tar, false, true);
+ if (!fileStream_control_tar) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error opening the file \""
+ << filename_control_tar << "\" for writing" << std::endl);
+ return false;
+ }
+ cmArchiveWrite control_tar(fileStream_control_tar,
+ cmArchiveWrite::CompressGZip, DebianArchiveType);
+
+ // sets permissions and uid/gid for the files
+ control_tar.SetUIDAndGID(0u, 0u);
+ control_tar.SetUNAMEAndGNAME("root", "root");
+
+ /* permissions are set according to
+ https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
+ and
+ https://lintian.debian.org/tags/control-file-has-bad-permissions.html
+ */
+ const mode_t permission644 = 0644;
+ const mode_t permissionExecute = 0111;
+ const mode_t permission755 = permission644 | permissionExecute;
+
+ // for md5sum and control (that we have generated here), we use 644
+ // (RW-R--R--)
+ // so that deb lintian doesn't warn about it
+ control_tar.SetPermissions(permission644);
+
+ // adds control and md5sums
+ if (!control_tar.Add(md5Filename, WorkDir.length(), ".") ||
+ !control_tar.Add(WorkDir + "/control", WorkDir.length(), ".")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error adding file to tar:"
+ << std::endl
+ << "#top level directory: " << WorkDir << std::endl
+ << "#file: \"control\" or \"md5sums\"" << std::endl
+ << "#error:" << control_tar.GetError() << std::endl);
+ return false;
+ }
+
+ // adds generated shlibs file
+ if (GenShLibs) {
+ if (!control_tar.Add(ShLibsFilename, WorkDir.length(), ".")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error adding file to tar:"
+ << std::endl
+ << "#top level directory: " << WorkDir << std::endl
+ << "#file: \"shlibs\"" << std::endl
+ << "#error:" << control_tar.GetError() << std::endl);
+ return false;
+ }
+ }
+
+ // adds LDCONFIG related files
+ if (GenPostInst) {
+ control_tar.SetPermissions(permission755);
+ if (!control_tar.Add(PostInst, WorkDir.length(), ".")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error adding file to tar:"
+ << std::endl
+ << "#top level directory: " << WorkDir << std::endl
+ << "#file: \"postinst\"" << std::endl
+ << "#error:" << control_tar.GetError() << std::endl);
+ return false;
+ }
+ control_tar.SetPermissions(permission644);
+ }
+
+ if (GenPostRm) {
+ control_tar.SetPermissions(permission755);
+ if (!control_tar.Add(PostRm, WorkDir.length(), ".")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error adding file to tar:"
+ << std::endl
+ << "#top level directory: " << WorkDir << std::endl
+ << "#file: \"postinst\"" << std::endl
+ << "#error:" << control_tar.GetError() << std::endl);
+ return false;
+ }
+ control_tar.SetPermissions(permission644);
+ }
+
+ // for the other files, we use
+ // -either the original permission on the files
+ // -either a permission strictly defined by the Debian policies
+ if (ControlExtra) {
+ // permissions are now controlled by the original file permissions
+
+ static const char* strictFiles[] = { "config", "postinst", "postrm",
+ "preinst", "prerm" };
+ std::set<std::string> setStrictFiles(
+ strictFiles, strictFiles + sizeof(strictFiles) / sizeof(strictFiles[0]));
+
+ // default
+ control_tar.ClearPermissions();
+
+ std::vector<std::string> controlExtraList = cmExpandedList(ControlExtra);
+ for (std::string const& i : controlExtraList) {
+ std::string filenamename = cmsys::SystemTools::GetFilenameName(i);
+ std::string localcopy = WorkDir + "/" + filenamename;
+
+ if (PermissionStrictPolicy) {
+ control_tar.SetPermissions(
+ setStrictFiles.count(filenamename) ? permission755 : permission644);
+ }
+
+ // if we can copy the file, it means it does exist, let's add it:
+ if (cmsys::SystemTools::CopyFileIfDifferent(i, localcopy)) {
+ control_tar.Add(localcopy, WorkDir.length(), ".");
+ }
+ }
+ }
+
+ return true;
+}
+
+bool DebGenerator::generateDeb() const
+{
+ // ar -r your-package-name.deb debian-binary control.tar.* data.tar.*
+ // A debian package .deb is simply an 'ar' archive. The only subtle
+ // difference is that debian uses the BSD ar style archive whereas most
+ // Linux distro have a GNU ar.
+ // See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=161593 for more info
+ std::string const outputPath = TopLevelDir + "/" + OutputName;
+ std::string const tlDir = WorkDir + "/";
+ cmGeneratedFileStream debStream;
+ debStream.Open(outputPath, false, true);
+ cmArchiveWrite deb(debStream, cmArchiveWrite::CompressNone, "arbsd");
+
+ // uid/gid should be the one of the root user, and this root user has
+ // always uid/gid equal to 0.
+ deb.SetUIDAndGID(0u, 0u);
+ deb.SetUNAMEAndGNAME("root", "root");
+
+ if (!deb.Add(tlDir + "debian-binary", tlDir.length()) ||
+ !deb.Add(tlDir + "control.tar.gz", tlDir.length()) ||
+ !deb.Add(tlDir + "data.tar" + CompressionSuffix, tlDir.length())) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error creating debian package:"
+ << std::endl
+ << "#top level directory: " << TopLevelDir << std::endl
+ << "#file: " << OutputName << std::endl
+ << "#error:" << deb.GetError() << std::endl);
+ return false;
+ }
+ return true;
+}
+
+} // end anonymous namespace
+
+cmCPackDebGenerator::cmCPackDebGenerator() = default;
+
+cmCPackDebGenerator::~cmCPackDebGenerator() = default;
+
int cmCPackDebGenerator::InitializeInternal()
{
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
- if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) {
+ if (cmIsOff(this->GetOption("CPACK_SET_DESTDIR"))) {
this->SetOption("CPACK_SET_DESTDIR", "I_ON");
}
return this->Superclass::InitializeInternal();
@@ -68,39 +468,65 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel,
// Tell CPackDeb.cmake the name of the component GROUP.
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT", packageName.c_str());
// Tell CPackDeb.cmake the path where the component is.
- std::string component_path = "/";
- component_path += packageName;
+ std::string component_path = cmStrCat('/', packageName);
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str());
- if (!this->ReadListFile("CPackDeb.cmake")) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake"
- << std::endl);
+ if (!this->ReadListFile("Internal/CPack/CPackDeb.cmake")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error while execution CPackDeb.cmake" << std::endl);
retval = 0;
return retval;
}
- cmsys::Glob gl;
- std::string findExpr(this->GetOption("GEN_WDIR"));
- findExpr += "/*";
- gl.RecurseOn();
- gl.SetRecurseListDirs(true);
- if (!gl.FindFiles(findExpr)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Cannot find any files in the installed directory"
- << std::endl);
- return 0;
+ { // Isolate globbing of binaries vs. dbgsyms
+ cmsys::Glob gl;
+ std::string findExpr(this->GetOption("GEN_WDIR"));
+ findExpr += "/*";
+ gl.RecurseOn();
+ gl.SetRecurseListDirs(true);
+ if (!gl.FindFiles(findExpr)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find any files in the installed directory"
+ << std::endl);
+ return 0;
+ }
+ packageFiles = gl.GetFiles();
}
- packageFiles = gl.GetFiles();
int res = createDeb();
if (res != 1) {
retval = 0;
}
// add the generated package to package file names list
- packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- packageFileName += "/";
- packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
- packageFileNames.push_back(packageFileName);
+ packageFileName = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/',
+ this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"));
+ packageFileNames.push_back(std::move(packageFileName));
+
+ if (this->IsOn("GEN_CPACK_DEBIAN_DEBUGINFO_PACKAGE")) {
+ cmsys::Glob gl;
+ std::string findExpr(this->GetOption("GEN_DBGSYMDIR"));
+ findExpr += "/*";
+ gl.RecurseOn();
+ gl.SetRecurseListDirs(true);
+ if (!gl.FindFiles(findExpr)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find any files in the installed directory"
+ << std::endl);
+ return 0;
+ }
+ packageFiles = gl.GetFiles();
+
+ res = createDbgsymDDeb();
+ if (res != 1) {
+ retval = 0;
+ }
+ // add the generated package to package file names list
+ packageFileName =
+ cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/',
+ this->GetOption("GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME"));
+ packageFileNames.push_back(std::move(packageFileName));
+ }
+
return retval;
}
@@ -115,37 +541,32 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
if (!ignoreGroup) {
- std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
- for (compGIt = this->ComponentGroups.begin();
- compGIt != this->ComponentGroups.end(); ++compGIt) {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
- << compGIt->first << std::endl);
+ for (auto const& compG : this->ComponentGroups) {
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Packaging component group: " << compG.first << std::endl);
// Begin the archive for this group
- retval &= PackageOnePack(initialTopLevel, compGIt->first);
+ retval &= PackageOnePack(initialTopLevel, compG.first);
}
// Handle Orphan components (components not belonging to any groups)
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
+ for (auto const& comp : this->Components) {
// Does the component belong to a group?
- if (compIt->second.Group == CM_NULLPTR) {
+ if (comp.second.Group == nullptr) {
cmCPackLogger(
- cmCPackLog::LOG_VERBOSE, "Component <"
- << compIt->second.Name
+ cmCPackLog::LOG_VERBOSE,
+ "Component <"
+ << comp.second.Name
<< "> does not belong to any group, package it separately."
<< std::endl);
// Begin the archive for this orphan component
- retval &= PackageOnePack(initialTopLevel, compIt->first);
+ retval &= PackageOnePack(initialTopLevel, comp.first);
}
}
}
// CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component
else {
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
- retval &= PackageOnePack(initialTopLevel, compIt->first);
+ for (auto const& comp : this->Components) {
+ retval &= PackageOnePack(initialTopLevel, comp.first);
}
}
return retval;
@@ -190,14 +611,13 @@ int cmCPackDebGenerator::PackageComponentsAllInOne(
if (!compInstDirName.empty()) {
// Tell CPackDeb.cmake the path where the component is.
- std::string component_path = "/";
- component_path += compInstDirName;
+ std::string component_path = cmStrCat('/', compInstDirName);
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str());
}
- if (!this->ReadListFile("CPackDeb.cmake")) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake"
- << std::endl);
+ if (!this->ReadListFile("Internal/CPack/CPackDeb.cmake")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error while execution CPackDeb.cmake" << std::endl);
retval = 0;
return retval;
}
@@ -220,10 +640,9 @@ int cmCPackDebGenerator::PackageComponentsAllInOne(
retval = 0;
}
// add the generated package to package file names list
- packageFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- packageFileName += "/";
- packageFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
- packageFileNames.push_back(packageFileName);
+ packageFileName = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/',
+ this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"));
+ packageFileNames.push_back(std::move(packageFileName));
return retval;
}
@@ -250,114 +669,81 @@ int cmCPackDebGenerator::PackageFiles()
int cmCPackDebGenerator::createDeb()
{
- // debian-binary file
- const std::string strGenWDIR(this->GetOption("GEN_WDIR"));
- const std::string dbfilename = strGenWDIR + "/debian-binary";
- { // the scope is needed for cmGeneratedFileStream
- cmGeneratedFileStream out(dbfilename.c_str());
- out << "2.0";
- out << std::endl; // required for valid debian package
- }
-
- // control file
- std::string ctlfilename = strGenWDIR + "/control";
+ std::map<std::string, std::string> controlValues;
// debian policy enforce lower case for package name
- // mandatory entries:
- std::string debian_pkg_name = cmsys::SystemTools::LowerCase(
+ controlValues["Package"] = cmsys::SystemTools::LowerCase(
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME"));
- const char* debian_pkg_version =
+ controlValues["Version"] =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_VERSION");
- const char* debian_pkg_section =
+ controlValues["Section"] =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SECTION");
- const char* debian_pkg_priority =
+ controlValues["Priority"] =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PRIORITY");
- const char* debian_pkg_arch =
+ controlValues["Architecture"] =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
- const char* maintainer =
+ controlValues["Maintainer"] =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
- const char* desc = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION");
+ controlValues["Description"] =
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION");
- // optional entries
+ const char* debian_pkg_source =
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
+ if (debian_pkg_source && *debian_pkg_source) {
+ controlValues["Source"] = debian_pkg_source;
+ }
const char* debian_pkg_dep =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DEPENDS");
+ if (debian_pkg_dep && *debian_pkg_dep) {
+ controlValues["Depends"] = debian_pkg_dep;
+ }
const char* debian_pkg_rec =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_RECOMMENDS");
+ if (debian_pkg_rec && *debian_pkg_rec) {
+ controlValues["Recommends"] = debian_pkg_rec;
+ }
const char* debian_pkg_sug =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SUGGESTS");
+ if (debian_pkg_sug && *debian_pkg_sug) {
+ controlValues["Suggests"] = debian_pkg_sug;
+ }
const char* debian_pkg_url =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_HOMEPAGE");
+ if (debian_pkg_url && *debian_pkg_url) {
+ controlValues["Homepage"] = debian_pkg_url;
+ }
const char* debian_pkg_predep =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PREDEPENDS");
+ if (debian_pkg_predep && *debian_pkg_predep) {
+ controlValues["Pre-Depends"] = debian_pkg_predep;
+ }
const char* debian_pkg_enhances =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ENHANCES");
+ if (debian_pkg_enhances && *debian_pkg_enhances) {
+ controlValues["Enhances"] = debian_pkg_enhances;
+ }
const char* debian_pkg_breaks =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_BREAKS");
+ if (debian_pkg_breaks && *debian_pkg_breaks) {
+ controlValues["Breaks"] = debian_pkg_breaks;
+ }
const char* debian_pkg_conflicts =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS");
+ if (debian_pkg_conflicts && *debian_pkg_conflicts) {
+ controlValues["Conflicts"] = debian_pkg_conflicts;
+ }
const char* debian_pkg_provides =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_PROVIDES");
+ if (debian_pkg_provides && *debian_pkg_provides) {
+ controlValues["Provides"] = debian_pkg_provides;
+ }
const char* debian_pkg_replaces =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_REPLACES");
- const char* debian_pkg_source =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
-
- { // the scope is needed for cmGeneratedFileStream
- cmGeneratedFileStream out(ctlfilename.c_str());
- out << "Package: " << debian_pkg_name << "\n";
- out << "Version: " << debian_pkg_version << "\n";
- out << "Section: " << debian_pkg_section << "\n";
- out << "Priority: " << debian_pkg_priority << "\n";
- out << "Architecture: " << debian_pkg_arch << "\n";
- if (debian_pkg_source && *debian_pkg_source) {
- out << "Source: " << debian_pkg_source << "\n";
- }
- if (debian_pkg_dep && *debian_pkg_dep) {
- out << "Depends: " << debian_pkg_dep << "\n";
- }
- if (debian_pkg_rec && *debian_pkg_rec) {
- out << "Recommends: " << debian_pkg_rec << "\n";
- }
- if (debian_pkg_sug && *debian_pkg_sug) {
- out << "Suggests: " << debian_pkg_sug << "\n";
- }
- if (debian_pkg_url && *debian_pkg_url) {
- out << "Homepage: " << debian_pkg_url << "\n";
- }
- if (debian_pkg_predep && *debian_pkg_predep) {
- out << "Pre-Depends: " << debian_pkg_predep << "\n";
- }
- if (debian_pkg_enhances && *debian_pkg_enhances) {
- out << "Enhances: " << debian_pkg_enhances << "\n";
- }
- if (debian_pkg_breaks && *debian_pkg_breaks) {
- out << "Breaks: " << debian_pkg_breaks << "\n";
- }
- if (debian_pkg_conflicts && *debian_pkg_conflicts) {
- out << "Conflicts: " << debian_pkg_conflicts << "\n";
- }
- if (debian_pkg_provides && *debian_pkg_provides) {
- out << "Provides: " << debian_pkg_provides << "\n";
- }
- if (debian_pkg_replaces && *debian_pkg_replaces) {
- out << "Replaces: " << debian_pkg_replaces << "\n";
- }
- unsigned long totalSize = 0;
- {
- std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
- dirName += '/';
- for (std::vector<std::string>::const_iterator fileIt =
- packageFiles.begin();
- fileIt != packageFiles.end(); ++fileIt) {
- totalSize += cmSystemTools::FileLength(*fileIt);
- }
- }
- out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n";
- out << "Maintainer: " << maintainer << "\n";
- out << "Description: " << desc << "\n";
- out << std::endl;
+ if (debian_pkg_replaces && *debian_pkg_replaces) {
+ controlValues["Replaces"] = debian_pkg_replaces;
}
+ const std::string strGenWDIR(this->GetOption("GEN_WDIR"));
const std::string shlibsfilename = strGenWDIR + "/shlibs";
const char* debian_pkg_shlibs =
@@ -365,7 +751,7 @@ int cmCPackDebGenerator::createDeb()
const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") &&
debian_pkg_shlibs && *debian_pkg_shlibs;
if (gen_shibs) {
- cmGeneratedFileStream out(shlibsfilename.c_str());
+ cmGeneratedFileStream out(shlibsfilename);
out << debian_pkg_shlibs;
out << std::endl;
}
@@ -373,7 +759,7 @@ int cmCPackDebGenerator::createDeb()
const std::string postinst = strGenWDIR + "/postinst";
const std::string postrm = strGenWDIR + "/postrm";
if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
- cmGeneratedFileStream out(postinst.c_str());
+ cmGeneratedFileStream out(postinst);
out << "#!/bin/sh\n\n"
"set -e\n\n"
"if [ \"$1\" = \"configure\" ]; then\n"
@@ -381,7 +767,7 @@ int cmCPackDebGenerator::createDeb()
"fi\n";
}
if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
- cmGeneratedFileStream out(postrm.c_str());
+ cmGeneratedFileStream out(postrm);
out << "#!/bin/sh\n\n"
"set -e\n\n"
"if [ \"$1\" = \"remove\" ]; then\n"
@@ -389,288 +775,74 @@ int cmCPackDebGenerator::createDeb()
"fi\n";
}
- cmArchiveWrite::Compress tar_compression_type = cmArchiveWrite::CompressGZip;
- const char* debian_compression_type =
- this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE");
- if (!debian_compression_type) {
- debian_compression_type = "gzip";
- }
-
- std::string compression_suffix;
- if (!strcmp(debian_compression_type, "lzma")) {
- compression_suffix = ".lzma";
- tar_compression_type = cmArchiveWrite::CompressLZMA;
- } else if (!strcmp(debian_compression_type, "xz")) {
- compression_suffix = ".xz";
- tar_compression_type = cmArchiveWrite::CompressXZ;
- } else if (!strcmp(debian_compression_type, "bzip2")) {
- compression_suffix = ".bz2";
- tar_compression_type = cmArchiveWrite::CompressBZip2;
- } else if (!strcmp(debian_compression_type, "gzip")) {
- compression_suffix = ".gz";
- tar_compression_type = cmArchiveWrite::CompressGZip;
- } else if (!strcmp(debian_compression_type, "none")) {
- compression_suffix = "";
- tar_compression_type = cmArchiveWrite::CompressNone;
- } else {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error unrecognized compression type: "
- << debian_compression_type << std::endl);
- }
+ DebGenerator gen(
+ Logger, this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"), strGenWDIR,
+ this->GetOption("CPACK_TOPLEVEL_DIRECTORY"),
+ this->GetOption("CPACK_TEMPORARY_DIRECTORY"),
+ this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE"),
+ this->GetOption("GEN_CPACK_DEBIAN_ARCHIVE_TYPE"), controlValues, gen_shibs,
+ shlibsfilename, this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST"), postinst,
+ this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM"), postrm,
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA"),
+ this->IsSet("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION"),
+ packageFiles);
- const char* debian_archive_type =
- this->GetOption("GEN_CPACK_DEBIAN_ARCHIVE_TYPE");
- if (!debian_archive_type) {
- debian_archive_type = "paxr";
+ if (!gen.generate()) {
+ return 0;
}
+ return 1;
+}
- std::string filename_data_tar =
- strGenWDIR + "/data.tar" + compression_suffix;
-
- // atomic file generation for data.tar
- {
- cmGeneratedFileStream fileStream_data_tar;
- fileStream_data_tar.Open(filename_data_tar.c_str(), false, true);
- if (!fileStream_data_tar) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \""
- << filename_data_tar << "\" for writing" << std::endl);
- return 0;
- }
- cmArchiveWrite data_tar(fileStream_data_tar, tar_compression_type,
- debian_archive_type);
-
- // uid/gid should be the one of the root user, and this root user has
- // always uid/gid equal to 0.
- data_tar.SetUIDAndGID(0u, 0u);
- data_tar.SetUNAMEAndGNAME("root", "root");
-
- // now add all directories which have to be compressed
- // collect all top level install dirs for that
- // e.g. /opt/bin/foo, /usr/bin/bar and /usr/bin/baz would
- // give /usr and /opt
- size_t topLevelLength = strGenWDIR.length();
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "WDIR: \""
- << strGenWDIR << "\", length = " << topLevelLength
- << std::endl);
- std::set<std::string> orderedFiles;
-
- // we have to reconstruct the parent folders as well
-
- for (std::vector<std::string>::const_iterator fileIt =
- packageFiles.begin();
- fileIt != packageFiles.end(); ++fileIt) {
- std::string currentPath = *fileIt;
- while (currentPath != strGenWDIR) {
- // the last one IS strGenWDIR, but we do not want this one:
- // XXX/application/usr/bin/myprogram with GEN_WDIR=XXX/application
- // should not add XXX/application
- orderedFiles.insert(currentPath);
- currentPath = cmSystemTools::CollapseCombinedPath(currentPath, "..");
- }
- }
-
- for (std::set<std::string>::const_iterator fileIt = orderedFiles.begin();
- fileIt != orderedFiles.end(); ++fileIt) {
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "FILEIT: \"" << *fileIt << "\""
- << std::endl);
- std::string::size_type slashPos = fileIt->find('/', topLevelLength + 1);
- std::string relativeDir =
- fileIt->substr(topLevelLength, slashPos - topLevelLength);
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \""
- << relativeDir << "\"" << std::endl);
-
- // do not recurse because the loop will do it
- if (!data_tar.Add(*fileIt, topLevelLength, ".", false)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem adding file to tar:"
- << std::endl
- << "#top level directory: " << strGenWDIR << std::endl
- << "#file: " << *fileIt << std::endl
- << "#error:" << data_tar.GetError() << std::endl);
- return 0;
- }
- }
- } // scope for file generation
-
- std::string md5filename = strGenWDIR + "/md5sums";
- {
- // the scope is needed for cmGeneratedFileStream
- cmGeneratedFileStream out(md5filename.c_str());
-
- std::string topLevelWithTrailingSlash =
- this->GetOption("CPACK_TEMPORARY_DIRECTORY");
- topLevelWithTrailingSlash += '/';
- for (std::vector<std::string>::const_iterator fileIt =
- packageFiles.begin();
- fileIt != packageFiles.end(); ++fileIt) {
- // hash only regular files
- if (cmSystemTools::FileIsDirectory(*fileIt) ||
- cmSystemTools::FileIsSymlink(*fileIt)) {
- continue;
- }
+int cmCPackDebGenerator::createDbgsymDDeb()
+{
+ // Packages containing debug symbols follow the same structure as .debs
+ // but have different metadata and content.
- char md5sum[33];
- if (!cmSystemTools::ComputeFileMD5(*fileIt, md5sum)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem computing the md5 of "
- << *fileIt << std::endl);
- }
+ std::map<std::string, std::string> controlValues;
+ // debian policy enforce lower case for package name
+ std::string packageNameLower = cmsys::SystemTools::LowerCase(
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME"));
+ const char* debian_pkg_version =
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_VERSION");
- md5sum[32] = 0;
+ controlValues["Package"] = packageNameLower + "-dbgsym";
+ controlValues["Package-Type"] = "ddeb";
+ controlValues["Version"] = debian_pkg_version;
+ controlValues["Auto-Built-Package"] = "debug-symbols";
+ controlValues["Depends"] = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_NAME") +
+ std::string(" (= ") + debian_pkg_version + ")";
+ controlValues["Section"] = "debug";
+ controlValues["Priority"] = "optional";
+ controlValues["Architecture"] =
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
+ controlValues["Maintainer"] =
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
+ controlValues["Description"] =
+ std::string("debug symbols for ") + packageNameLower;
- std::string output(md5sum);
- output += " " + *fileIt + "\n";
- // debian md5sums entries are like this:
- // 014f3604694729f3bf19263bac599765 usr/bin/ccmake
- // thus strip the full path (with the trailing slash)
- cmSystemTools::ReplaceString(output, topLevelWithTrailingSlash.c_str(),
- "");
- out << output;
- }
- // each line contains a eol.
- // Do not end the md5sum file with yet another (invalid)
+ const char* debian_pkg_source =
+ this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
+ if (debian_pkg_source && *debian_pkg_source) {
+ controlValues["Source"] = debian_pkg_source;
+ }
+ const char* debian_build_ids = this->GetOption("GEN_BUILD_IDS");
+ if (debian_build_ids && *debian_build_ids) {
+ controlValues["Build-Ids"] = debian_build_ids;
}
- std::string filename_control_tar = strGenWDIR + "/control.tar.gz";
- // atomic file generation for control.tar
- {
- cmGeneratedFileStream fileStream_control_tar;
- fileStream_control_tar.Open(filename_control_tar.c_str(), false, true);
- if (!fileStream_control_tar) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \""
- << filename_control_tar << "\" for writing"
- << std::endl);
- return 0;
- }
- cmArchiveWrite control_tar(fileStream_control_tar,
- cmArchiveWrite::CompressGZip,
- debian_archive_type);
-
- // sets permissions and uid/gid for the files
- control_tar.SetUIDAndGID(0u, 0u);
- control_tar.SetUNAMEAndGNAME("root", "root");
-
- /* permissions are set according to
- https://www.debian.org/doc/debian-policy/ch-files.html#s-permissions-owners
- and
- https://lintian.debian.org/tags/control-file-has-bad-permissions.html
- */
- const mode_t permission644 = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
- const mode_t permissionExecute = S_IXUSR | S_IXGRP | S_IXOTH;
- const mode_t permission755 = permission644 | permissionExecute;
-
- // for md5sum and control (that we have generated here), we use 644
- // (RW-R--R--)
- // so that deb lintian doesn't warn about it
- control_tar.SetPermissions(permission644);
-
- // adds control and md5sums
- if (!control_tar.Add(md5filename, strGenWDIR.length(), ".") ||
- !control_tar.Add(strGenWDIR + "/control", strGenWDIR.length(), ".")) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
- << std::endl
- << "#top level directory: " << strGenWDIR << std::endl
- << "#file: \"control\" or \"md5sums\"" << std::endl
- << "#error:" << control_tar.GetError() << std::endl);
- return 0;
- }
-
- // adds generated shlibs file
- if (gen_shibs) {
- if (!control_tar.Add(shlibsfilename, strGenWDIR.length(), ".")) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
- << std::endl
- << "#top level directory: " << strGenWDIR << std::endl
- << "#file: \"shlibs\"" << std::endl
- << "#error:" << control_tar.GetError() << std::endl);
- return 0;
- }
- }
+ DebGenerator gen(
+ Logger, this->GetOption("GEN_CPACK_DBGSYM_OUTPUT_FILE_NAME"),
+ this->GetOption("GEN_DBGSYMDIR"),
- // adds LDCONFIG related files
- if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
- control_tar.SetPermissions(permission755);
- if (!control_tar.Add(postinst, strGenWDIR.length(), ".")) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
- << std::endl
- << "#top level directory: " << strGenWDIR << std::endl
- << "#file: \"postinst\"" << std::endl
- << "#error:" << control_tar.GetError() << std::endl);
- return 0;
- }
- control_tar.SetPermissions(permission644);
- }
+ this->GetOption("CPACK_TOPLEVEL_DIRECTORY"),
+ this->GetOption("CPACK_TEMPORARY_DIRECTORY"),
+ this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE"),
+ this->GetOption("GEN_CPACK_DEBIAN_ARCHIVE_TYPE"), controlValues, false, "",
+ false, "", false, "", nullptr,
+ this->IsSet("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION"),
+ packageFiles);
- if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
- control_tar.SetPermissions(permission755);
- if (!control_tar.Add(postrm, strGenWDIR.length(), ".")) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
- << std::endl
- << "#top level directory: " << strGenWDIR << std::endl
- << "#file: \"postinst\"" << std::endl
- << "#error:" << control_tar.GetError() << std::endl);
- return 0;
- }
- control_tar.SetPermissions(permission644);
- }
-
- // for the other files, we use
- // -either the original permission on the files
- // -either a permission strictly defined by the Debian policies
- const char* controlExtra =
- this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA");
- if (controlExtra) {
- // permissions are now controlled by the original file permissions
-
- const bool permissionStrictPolicy =
- this->IsSet("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION");
-
- static const char* strictFiles[] = { "config", "postinst", "postrm",
- "preinst", "prerm" };
- std::set<std::string> setStrictFiles(
- strictFiles,
- strictFiles + sizeof(strictFiles) / sizeof(strictFiles[0]));
-
- // default
- control_tar.ClearPermissions();
-
- std::vector<std::string> controlExtraList;
- cmSystemTools::ExpandListArgument(controlExtra, controlExtraList);
- for (std::vector<std::string>::iterator i = controlExtraList.begin();
- i != controlExtraList.end(); ++i) {
- std::string filenamename = cmsys::SystemTools::GetFilenameName(*i);
- std::string localcopy = strGenWDIR + "/" + filenamename;
-
- if (permissionStrictPolicy) {
- control_tar.SetPermissions(setStrictFiles.count(filenamename)
- ? permission755
- : permission644);
- }
-
- // if we can copy the file, it means it does exist, let's add it:
- if (cmsys::SystemTools::CopyFileIfDifferent(*i, localcopy)) {
- control_tar.Add(localcopy, strGenWDIR.length(), ".");
- }
- }
- }
- }
-
- // ar -r your-package-name.deb debian-binary control.tar.* data.tar.*
- // since debian packages require BSD ar (most Linux distros and even
- // FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here.
- std::vector<std::string> arFiles;
- std::string topLevelString = strGenWDIR + "/";
- arFiles.push_back(topLevelString + "debian-binary");
- arFiles.push_back(topLevelString + "control.tar.gz");
- arFiles.push_back(topLevelString + "data.tar" + compression_suffix);
- std::string outputFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- outputFileName += "/";
- outputFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
- int res = ar_append(outputFileName.c_str(), arFiles);
- if (res != 0) {
- std::string tmpFile =
- this->GetOption("GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME");
- tmpFile += "/Deb.log";
- cmGeneratedFileStream ofs(tmpFile.c_str());
- ofs << "# Problem creating archive using: " << res << std::endl;
+ if (!gen.generate()) {
return 0;
}
return 1;
@@ -695,252 +867,8 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
// the current COMPONENT belongs to.
std::string groupVar =
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
- if (CM_NULLPTR != GetOption(groupVar)) {
+ if (nullptr != GetOption(groupVar)) {
return std::string(GetOption(groupVar));
}
return componentName;
}
-
-// The following code is taken from OpenBSD ar:
-// http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ar/
-// It has been slightly modified:
-// -return error codes instead exit() in functions
-// -use the stdio file I/O functions instead the file descriptor based ones
-// -merged into one cxx file
-// -no additional options supported
-// The coding style hasn't been modified.
-
-/*-
- * Copyright (c) 1990, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Hugh Smith at The University of Guelph.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#define ARMAG "!<arch>\n" /* ar "magic number" */
-#define SARMAG 8 /* strlen(ARMAG); */
-
-#define AR_EFMT1 "#1/" /* extended format #1 */
-#define ARFMAG "`\n"
-
-/* Header format strings. */
-#define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10lld%2s"
-#define HDR2 "%-16.16s%-12ld%-6u%-6u%-8o%-10lld%2s"
-
-struct ar_hdr
-{
- char ar_name[16]; /* name */
- char ar_date[12]; /* modification time */
- char ar_uid[6]; /* user id */
- char ar_gid[6]; /* group id */
- char ar_mode[8]; /* octal file permissions */
- char ar_size[10]; /* size in bytes */
- char ar_fmag[2]; /* consistency check */
-};
-
-/* Set up file copy. */
-#define SETCF(from, fromname, to, toname, pad) \
- { \
- cf.rFile = from; \
- cf.rname = fromname; \
- cf.wFile = to; \
- cf.wname = toname; \
- cf.flags = pad; \
- }
-
-/* File copy structure. */
-typedef struct
-{
- FILE* rFile; /* read file descriptor */
- const char* rname; /* read name */
- FILE* wFile; /* write file descriptor */
- const char* wname; /* write name */
-#define NOPAD 0x00 /* don't pad */
-#define WPAD 0x02 /* pad on writes */
- unsigned int flags; /* pad flags */
-} CF;
-
-/* misc.c */
-
-static const char* ar_rname(const char* path)
-{
- const char* ind = strrchr(path, '/');
- return (ind) ? ind + 1 : path;
-}
-
-/* archive.c */
-
-typedef struct ar_hdr HDR;
-static char ar_hb[sizeof(HDR) + 1]; /* real header */
-
-static size_t ar_already_written;
-
-/* copy_ar --
- * Copy size bytes from one file to another - taking care to handle the
- * extra byte (for odd size files) when reading archives and writing an
- * extra byte if necessary when adding files to archive. The length of
- * the object is the long name plus the object itself; the variable
- * already_written gets set if a long name was written.
- *
- * The padding is really unnecessary, and is almost certainly a remnant
- * of early archive formats where the header included binary data which
- * a PDP-11 required to start on an even byte boundary. (Or, perhaps,
- * because 16-bit word addressed copies were faster?) Anyhow, it should
- * have been ripped out long ago.
- */
-static int copy_ar(CF* cfp, off_t size)
-{
- static char pad = '\n';
- off_t sz = size;
- size_t nr, nw;
- char buf[8 * 1024];
-
- if (sz == 0) {
- return 0;
- }
-
- FILE* from = cfp->rFile;
- FILE* to = cfp->wFile;
- while (sz &&
- (nr = fread(buf, 1, sz < static_cast<off_t>(sizeof(buf))
- ? static_cast<size_t>(sz)
- : sizeof(buf),
- from)) > 0) {
- sz -= nr;
- for (size_t off = 0; off < nr; nr -= off, off += nw) {
- if ((nw = fwrite(buf + off, 1, nr, to)) < nr) {
- return -1;
- }
- }
- }
- if (sz) {
- return -2;
- }
-
- if (cfp->flags & WPAD && (size + ar_already_written) & 1 &&
- fwrite(&pad, 1, 1, to) != 1) {
- return -4;
- }
-
- return 0;
-}
-
-/* put_arobj -- Write an archive member to a file. */
-static int put_arobj(CF* cfp, struct stat* sb)
-{
- int result = 0;
- struct ar_hdr* hdr;
-
- /* If passed an sb structure, reading a file from disk. Get stat(2)
- * information, build a name and construct a header. (Files are named
- * by their last component in the archive.) */
- const char* name = ar_rname(cfp->rname);
- (void)stat(cfp->rname, sb);
-
- /* If not truncating names and the name is too long or contains
- * a space, use extended format 1. */
- size_t lname = strlen(name);
- uid_t uid = sb->st_uid;
- gid_t gid = sb->st_gid;
- if (uid > USHRT_MAX) {
- uid = USHRT_MAX;
- }
- if (gid > USHRT_MAX) {
- gid = USHRT_MAX;
- }
- if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) {
- (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, (long int)sb->st_mtime,
- (unsigned)uid, (unsigned)gid, (unsigned)sb->st_mode,
- (long long)sb->st_size + lname, ARFMAG);
- } else {
- lname = 0;
- (void)sprintf(ar_hb, HDR2, name, (long int)sb->st_mtime, (unsigned)uid,
- (unsigned)gid, (unsigned)sb->st_mode, (long long)sb->st_size,
- ARFMAG);
- }
- off_t size = sb->st_size;
-
- if (fwrite(ar_hb, 1, sizeof(HDR), cfp->wFile) != sizeof(HDR)) {
- return -1;
- }
-
- if (lname) {
- if (fwrite(name, 1, lname, cfp->wFile) != lname) {
- return -2;
- }
- ar_already_written = lname;
- }
- result = copy_ar(cfp, size);
- ar_already_written = 0;
- return result;
-}
-
-/* append.c */
-
-/* append --
- * Append files to the archive - modifies original archive or creates
- * a new archive if named archive does not exist.
- */
-static int ar_append(const char* archive,
- const std::vector<std::string>& files)
-{
- int eval = 0;
- FILE* aFile = cmSystemTools::Fopen(archive, "wb+");
- if (aFile != CM_NULLPTR) {
- fwrite(ARMAG, SARMAG, 1, aFile);
- if (fseek(aFile, 0, SEEK_END) != -1) {
- CF cf;
- struct stat sb;
- /* Read from disk, write to an archive; pad on write. */
- SETCF(CM_NULLPTR, CM_NULLPTR, aFile, archive, WPAD);
- for (std::vector<std::string>::const_iterator fileIt = files.begin();
- fileIt != files.end(); ++fileIt) {
- const char* filename = fileIt->c_str();
- FILE* file = cmSystemTools::Fopen(filename, "rb");
- if (file == CM_NULLPTR) {
- eval = -1;
- continue;
- }
- cf.rFile = file;
- cf.rname = filename;
- int result = put_arobj(&cf, &sb);
- (void)fclose(file);
- if (result != 0) {
- eval = -2;
- break;
- }
- }
- } else {
- eval = -3;
- }
- fclose(aFile);
- } else {
- eval = -4;
- }
- return eval;
-}
diff --git a/Source/CPack/cmCPackDebGenerator.h b/Source/CPack/cmCPackDebGenerator.h
index e7cde1145..ce77e0804 100644
--- a/Source/CPack/cmCPackDebGenerator.h
+++ b/Source/CPack/cmCPackDebGenerator.h
@@ -3,13 +3,13 @@
#ifndef cmCPackDebGenerator_h
#define cmCPackDebGenerator_h
-#include "cmConfigure.h"
-
-#include "cmCPackGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
+#include "cmCPackGenerator.h"
+
/** \class cmCPackDebGenerator
* \brief A generator for Debian packages
*
@@ -23,7 +23,7 @@ public:
* Construct generator
*/
cmCPackDebGenerator();
- ~cmCPackDebGenerator() CM_OVERRIDE;
+ ~cmCPackDebGenerator() override;
static bool CanGenerate()
{
@@ -40,7 +40,7 @@ public:
}
protected:
- int InitializeInternal() CM_OVERRIDE;
+ int InitializeInternal() override;
/**
* This method factors out the work done in component packaging case.
*/
@@ -57,14 +57,16 @@ protected:
* components will be put in a single installer.
*/
int PackageComponentsAllInOne(const std::string& compInstDirName);
- int PackageFiles() CM_OVERRIDE;
- const char* GetOutputExtension() CM_OVERRIDE { return ".deb"; }
- bool SupportsComponentInstallation() const CM_OVERRIDE;
+ int PackageFiles() override;
+ const char* GetOutputExtension() override { return ".deb"; }
+ bool SupportsComponentInstallation() const override;
std::string GetComponentInstallDirNameSuffix(
- const std::string& componentName) CM_OVERRIDE;
+ const std::string& componentName) override;
private:
int createDeb();
+ int createDbgsymDDeb();
+
std::vector<std::string> packageFiles;
};
diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index d26d5bc1a..ea7100708 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -2,25 +2,28 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackDragNDropGenerator.h"
-#include "cmCPackGenerator.h"
-#include "cmCPackLog.h"
-#include "cmGeneratedFileStream.h"
-#include "cmSystemTools.h"
-
-#include "cmsys/FStream.hxx"
-#include "cmsys/RegularExpression.hxx"
#include <algorithm>
+#include <cstdlib>
#include <iomanip>
#include <map>
-#include <stdlib.h>
#include <CoreFoundation/CoreFoundation.h>
+#include "cmsys/FStream.hxx"
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmCPackGenerator.h"
+#include "cmCPackLog.h"
+#include "cmDuration.h"
+#include "cmGeneratedFileStream.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
#ifdef HAVE_CoreServices
// For the old LocaleStringToLangAndRegionCodes() function, to convert
// to the old Script Manager RegionCode values needed for the 'LPic' data
// structure used for generating multi-lingual SLAs.
-#include <CoreServices/CoreServices.h>
+# include <CoreServices/CoreServices.h>
#endif
static const char* SLAHeader =
@@ -61,23 +64,21 @@ cmCPackDragNDropGenerator::cmCPackDragNDropGenerator()
this->componentPackageMethod = ONE_PACKAGE;
}
-cmCPackDragNDropGenerator::~cmCPackDragNDropGenerator()
-{
-}
+cmCPackDragNDropGenerator::~cmCPackDragNDropGenerator() = default;
int cmCPackDragNDropGenerator::InitializeInternal()
{
// Starting with Xcode 4.3, look in "/Applications/Xcode.app" first:
//
std::vector<std::string> paths;
- paths.push_back("/Applications/Xcode.app/Contents/Developer/Tools");
- paths.push_back("/Developer/Tools");
+ paths.emplace_back("/Applications/Xcode.app/Contents/Developer/Tools");
+ paths.emplace_back("/Developer/Tools");
const std::string hdiutil_path =
cmSystemTools::FindProgram("hdiutil", std::vector<std::string>(), false);
if (hdiutil_path.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate hdiutil command"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot locate hdiutil command" << std::endl);
return 0;
}
this->SetOptionIfNotSet("CPACK_COMMAND_HDIUTIL", hdiutil_path.c_str());
@@ -85,16 +86,16 @@ int cmCPackDragNDropGenerator::InitializeInternal()
const std::string setfile_path =
cmSystemTools::FindProgram("SetFile", paths, false);
if (setfile_path.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate SetFile command"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot locate SetFile command" << std::endl);
return 0;
}
this->SetOptionIfNotSet("CPACK_COMMAND_SETFILE", setfile_path.c_str());
const std::string rez_path = cmSystemTools::FindProgram("Rez", paths, false);
if (rez_path.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate Rez command"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot locate Rez command" << std::endl);
return 0;
}
this->SetOptionIfNotSet("CPACK_COMMAND_REZ", rez_path.c_str());
@@ -123,30 +124,31 @@ int cmCPackDragNDropGenerator::InitializeInternal()
return 0;
}
if (!cmSystemTools::FileExists(slaDirectory, false)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_DMG_SLA_DIR does not exist"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_DMG_SLA_DIR does not exist" << std::endl);
return 0;
}
- std::vector<std::string> languages;
- cmSystemTools::ExpandListArgument(
- this->GetOption("CPACK_DMG_SLA_LANGUAGES"), languages);
+ std::vector<std::string> languages =
+ cmExpandedList(this->GetOption("CPACK_DMG_SLA_LANGUAGES"));
if (languages.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_DMG_SLA_LANGUAGES set but empty" << std::endl);
return 0;
}
- for (size_t i = 0; i < languages.size(); ++i) {
- std::string license = slaDirectory + "/" + languages[i] + ".license.txt";
+ for (auto const& language : languages) {
+ std::string license = slaDirectory + "/" + language + ".license.txt";
if (!singleLicense && !cmSystemTools::FileExists(license)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing license file "
- << languages[i] << ".license.txt" << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Missing license file " << language << ".license.txt"
+ << std::endl);
return 0;
}
- std::string menu = slaDirectory + "/" + languages[i] + ".menu.txt";
+ std::string menu = slaDirectory + "/" + language + ".menu.txt";
if (!cmSystemTools::FileExists(menu)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing menu file "
- << languages[i] << ".menu.txt" << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Missing menu file " << language << ".menu.txt"
+ << std::endl);
return 0;
}
}
@@ -185,19 +187,17 @@ int cmCPackDragNDropGenerator::PackageFiles()
// loop to create dmg files
packageFileNames.clear();
- for (size_t i = 0; i < package_files.size(); i++) {
+ for (auto const& package_file : package_files) {
std::string full_package_name = std::string(toplevel) + std::string("/");
- if (package_files[i] == "ALL_IN_ONE") {
+ if (package_file == "ALL_IN_ONE") {
full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME");
} else {
- full_package_name += package_files[i];
+ full_package_name += package_file;
}
full_package_name += std::string(GetOutputExtension());
packageFileNames.push_back(full_package_name);
- std::string src_dir = toplevel;
- src_dir += "/";
- src_dir += package_files[i];
+ std::string src_dir = cmStrCat(toplevel, '/', package_file);
if (0 == this->CreateDMG(src_dir, full_package_name)) {
return 0;
@@ -209,10 +209,10 @@ int cmCPackDragNDropGenerator::PackageFiles()
bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source,
std::ostringstream& target)
{
- if (!cmSystemTools::CopyFileIfDifferent(source.str().c_str(),
- target.str().c_str())) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error copying "
- << source.str() << " to " << target.str() << std::endl);
+ if (!cmSystemTools::CopyFileIfDifferent(source.str(), target.str())) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error copying " << source.str() << " to " << target.str()
+ << std::endl);
return false;
}
@@ -226,14 +226,14 @@ bool cmCPackDragNDropGenerator::CreateEmptyFile(std::ostringstream& target,
cmsys::ofstream fout(target.str().c_str(), std::ios::out | std::ios::binary);
if (!fout) {
return false;
- } else {
- // Seek to desired size - 1 byte
- fout.seekp(size - 1, std::ios::beg);
- char byte = 0;
- // Write one byte to ensure file grows
- fout.write(&byte, 1);
}
+ // Seek to desired size - 1 byte
+ fout.seekp(size - 1, std::ios::beg);
+ char byte = 0;
+ // Write one byte to ensure file grows
+ fout.write(&byte, 1);
+
return true;
}
@@ -242,13 +242,13 @@ bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command,
{
int exit_code = 1;
- bool result =
- cmSystemTools::RunSingleCommand(command.str().c_str(), output, output,
- &exit_code, 0, this->GeneratorVerbose, 0);
+ bool result = cmSystemTools::RunSingleCommand(
+ command.str(), output, output, &exit_code, nullptr, this->GeneratorVerbose,
+ cmDuration::zero());
if (!result || exit_code) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error executing: " << command.str()
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error executing: " << command.str() << std::endl);
return false;
}
@@ -399,8 +399,8 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
std::ostringstream dummy_padding;
dummy_padding << staging.str() << "/.dummy-padding-file";
if (!this->CreateEmptyFile(dummy_padding, 1048576)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error creating dummy padding file."
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error creating dummy padding file." << std::endl);
return 0;
}
@@ -408,21 +408,25 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
}
// Create a temporary read-write disk image ...
- std::string temp_image = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- temp_image += "/temp.dmg";
+ std::string temp_image =
+ cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/temp.dmg");
+ std::string create_error;
std::ostringstream temp_image_command;
temp_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
temp_image_command << " create";
temp_image_command << " -ov";
temp_image_command << " -srcfolder \"" << staging.str() << "\"";
temp_image_command << " -volname \"" << cpack_dmg_volume_name << "\"";
+ temp_image_command << " -fs HFS+";
temp_image_command << " -format " << temp_image_format;
temp_image_command << " \"" << temp_image << "\"";
- if (!this->RunCommand(temp_image_command)) {
+ if (!this->RunCommand(temp_image_command, &create_error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error generating temporary disk image." << std::endl);
+ "Error generating temporary disk image." << std::endl
+ << create_error
+ << std::endl);
return 0;
}
@@ -448,28 +452,32 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
cmsys::RegularExpression mountpoint_regex(".*(/Volumes/[^\n]+)\n.*");
mountpoint_regex.find(attach_output.c_str());
std::string const temp_mount = mountpoint_regex.match(1);
+ std::string const temp_mount_name =
+ temp_mount.substr(sizeof("/Volumes/") - 1);
// Remove dummy padding file so we have enough space on RW image ...
std::ostringstream dummy_padding;
dummy_padding << temp_mount << "/.dummy-padding-file";
if (!cmSystemTools::RemoveFile(dummy_padding.str())) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error removing dummy padding file."
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error removing dummy padding file." << std::endl);
had_error = true;
}
// Optionally set the custom icon flag for the image ...
if (!had_error && !cpack_package_icon.empty()) {
+ std::string error;
std::ostringstream setfile_command;
setfile_command << this->GetOption("CPACK_COMMAND_SETFILE");
setfile_command << " -a C";
setfile_command << " \"" << temp_mount << "\"";
- if (!this->RunCommand(setfile_command)) {
+ if (!this->RunCommand(setfile_command, &error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error assigning custom icon to temporary disk image."
- << std::endl);
+ << std::endl
+ << error << std::endl);
had_error = true;
}
@@ -481,7 +489,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
std::ostringstream setup_script_command;
setup_script_command << "osascript"
<< " \"" << cpack_dmg_ds_store_setup_script << "\""
- << " \"" << cpack_dmg_volume_name << "\"";
+ << " \"" << temp_mount_name << "\"";
std::string error;
if (!this->RunCommand(setup_script_command, &error)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -513,15 +521,15 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
if (!cpack_license_file.empty() || !slaDirectory.empty()) {
// Use old hardcoded style if sla_dir is not set
bool oldStyle = slaDirectory.empty();
- std::string sla_r = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- sla_r += "/sla.r";
+ std::string sla_r =
+ cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/sla.r");
std::vector<std::string> languages;
if (!oldStyle) {
- cmSystemTools::ExpandListArgument(cpack_dmg_languages, languages);
+ cmExpandList(cpack_dmg_languages, languages);
}
- cmGeneratedFileStream ofs(sla_r.c_str());
+ cmGeneratedFileStream ofs(sla_r);
ofs << "#include <CoreServices/CoreServices.r>\n\n";
if (oldStyle) {
ofs << SLAHeader;
@@ -551,16 +559,18 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
header_data.push_back(languages.size());
for (size_t i = 0; i < languages.size(); ++i) {
CFStringRef language_cfstring = CFStringCreateWithCString(
- NULL, languages[i].c_str(), kCFStringEncodingUTF8);
+ nullptr, languages[i].c_str(), kCFStringEncodingUTF8);
CFStringRef iso_language =
CFLocaleCreateCanonicalLanguageIdentifierFromString(
- NULL, language_cfstring);
+ nullptr, language_cfstring);
if (!iso_language) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, languages[i]
- << " is not a recognized language" << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ languages[i] << " is not a recognized language"
+ << std::endl);
}
- char* iso_language_cstr = (char*)malloc(65);
- CFStringGetCString(iso_language, iso_language_cstr, 64,
+ char iso_language_cstr[65];
+ CFStringGetCString(iso_language, iso_language_cstr,
+ sizeof(iso_language_cstr) - 1,
kCFStringEncodingMacRoman);
LangCode lang = 0;
RegionCode region = 0;
@@ -573,11 +583,9 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
cmCPackLogger(cmCPackLog::LOG_ERROR,
"No language/region code available for "
<< iso_language_cstr << std::endl);
- free(iso_language_cstr);
return 0;
}
#ifdef HAVE_CoreServices
- free(iso_language_cstr);
header_data.push_back(region);
header_data.push_back(i);
header_data.push_back(0);
@@ -630,17 +638,18 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
ofs.Close();
if (have_write_license_error) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error writing license file to SLA."
- << std::endl
- << error << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error writing license file to SLA." << std::endl
+ << error
+ << std::endl);
return 0;
}
if (temp_image_format != "UDZO") {
temp_image_format = "UDZO";
// convert to UDZO to enable unflatten/flatten
- std::string temp_udzo = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- temp_udzo += "/temp-udzo.dmg";
+ std::string temp_udzo = cmStrCat(
+ this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/temp-udzo.dmg");
std::ostringstream udco_image_command;
udco_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
@@ -684,9 +693,9 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
embed_sla_command << "\"" << temp_image << "\"";
if (!this->RunCommand(embed_sla_command, &error)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding SLA." << std::endl
- << error
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error adding SLA." << std::endl
+ << error << std::endl);
return 0;
}
@@ -715,9 +724,13 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
final_image_command << " zlib-level=9";
final_image_command << " -o \"" << output_file << "\"";
- if (!this->RunCommand(final_image_command)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error compressing disk image."
- << std::endl);
+ std::string convert_error;
+
+ if (!this->RunCommand(final_image_command, &convert_error)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error compressing disk image." << std::endl
+ << convert_error
+ << std::endl);
return 0;
}
@@ -767,7 +780,8 @@ std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
bool cmCPackDragNDropGenerator::WriteLicense(
cmGeneratedFileStream& outputStream, int licenseNumber,
- std::string licenseLanguage, std::string licenseFile, std::string* error)
+ std::string licenseLanguage, const std::string& licenseFile,
+ std::string* error)
{
if (!licenseFile.empty() && !singleLicense) {
licenseNumber = 5002;
@@ -793,8 +807,8 @@ bool cmCPackDragNDropGenerator::WriteLicense(
if (!this->BreakLongLine(line, lines, error)) {
return false;
}
- for (size_t i = 0; i < lines.size(); ++i) {
- outputStream << " \"" << lines[i] << "\"\n";
+ for (auto const& l : lines) {
+ outputStream << " \"" << l << "\"\n";
}
}
outputStream << " \"\\n\"\n";
@@ -863,10 +877,11 @@ bool cmCPackDragNDropGenerator::BreakLongLine(const std::string& line,
size_t line_length = max_line_length;
if (i + line_length > line.size()) {
line_length = line.size() - i;
- } else
+ } else {
while (line_length > 0 && line[i + line_length - 1] != ' ') {
line_length = line_length - 1;
}
+ }
if (line_length == 0) {
*error = "Please make sure there are no words "
diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h
index ae2cc173f..f8c86c06d 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.h
+++ b/Source/CPack/cmCPackDragNDropGenerator.h
@@ -3,13 +3,14 @@
#ifndef cmCPackDragNDropGenerator_h
#define cmCPackDragNDropGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <sstream>
-#include <stddef.h>
#include <string>
#include <vector>
+#include <stddef.h>
+
#include "cmCPackGenerator.h"
class cmGeneratedFileStream;
@@ -23,32 +24,30 @@ public:
cmCPackTypeMacro(cmCPackDragNDropGenerator, cmCPackGenerator);
cmCPackDragNDropGenerator();
- virtual ~cmCPackDragNDropGenerator();
+ ~cmCPackDragNDropGenerator() override;
protected:
- int InitializeInternal() CM_OVERRIDE;
- const char* GetOutputExtension() CM_OVERRIDE;
- int PackageFiles() CM_OVERRIDE;
- bool SupportsComponentInstallation() const CM_OVERRIDE;
+ int InitializeInternal() override;
+ const char* GetOutputExtension() override;
+ int PackageFiles() override;
+ bool SupportsComponentInstallation() const override;
bool CopyFile(std::ostringstream& source, std::ostringstream& target);
bool CreateEmptyFile(std::ostringstream& target, size_t size);
bool RunCommand(std::ostringstream& command, std::string* output = 0);
std::string GetComponentInstallDirNameSuffix(
- const std::string& componentName) CM_OVERRIDE;
+ const std::string& componentName) override;
int CreateDMG(const std::string& src_dir, const std::string& output_file);
- std::string InstallPrefix;
-
private:
std::string slaDirectory;
bool singleLicense;
bool WriteLicense(cmGeneratedFileStream& outputStream, int licenseNumber,
- std::string licenseLanguage, std::string licenseFile,
- std::string* error);
+ std::string licenseLanguage,
+ const std::string& licenseFile, std::string* error);
bool BreakLongLine(const std::string& line, std::vector<std::string>& lines,
std::string* error);
void EscapeQuotesAndBackslashes(std::string& line);
diff --git a/Source/CPack/cmCPackExternalGenerator.cxx b/Source/CPack/cmCPackExternalGenerator.cxx
new file mode 100644
index 000000000..142eb6fbf
--- /dev/null
+++ b/Source/CPack/cmCPackExternalGenerator.cxx
@@ -0,0 +1,322 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmCPackExternalGenerator.h"
+
+#include <map>
+#include <utility>
+#include <vector>
+
+#include <cm/memory>
+
+#include "cmsys/FStream.hxx"
+
+#include "cm_jsoncpp_value.h"
+#include "cm_jsoncpp_writer.h"
+
+#include "cmCPackComponentGroup.h"
+#include "cmCPackLog.h"
+#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+int cmCPackExternalGenerator::InitializeInternal()
+{
+ this->SetOption("CPACK_EXTERNAL_KNOWN_VERSIONS", "1.0");
+
+ if (!this->ReadListFile("Internal/CPack/CPackExternal.cmake")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error while executing CPackExternal.cmake" << std::endl);
+ return 0;
+ }
+
+ std::string major = this->GetOption("CPACK_EXTERNAL_SELECTED_MAJOR");
+ if (major == "1") {
+ this->Generator = cm::make_unique<cmCPackExternalVersion1Generator>(this);
+ }
+
+ return this->Superclass::InitializeInternal();
+}
+
+int cmCPackExternalGenerator::PackageFiles()
+{
+ Json::StreamWriterBuilder builder;
+ builder["indentation"] = " ";
+
+ std::string filename = "package.json";
+ if (!this->packageFileNames.empty()) {
+ filename = this->packageFileNames[0];
+ }
+
+ cmsys::ofstream fout(filename.c_str());
+ std::unique_ptr<Json::StreamWriter> jout(builder.newStreamWriter());
+
+ Json::Value root(Json::objectValue);
+
+ if (!this->Generator->WriteToJSON(root)) {
+ return 0;
+ }
+
+ if (jout->write(root, &fout)) {
+ return 0;
+ }
+
+ const char* packageScript = this->GetOption("CPACK_EXTERNAL_PACKAGE_SCRIPT");
+ if (packageScript && *packageScript) {
+ if (!cmSystemTools::FileIsFullPath(packageScript)) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
+ "CPACK_EXTERNAL_PACKAGE_SCRIPT does not contain a full file path"
+ << std::endl);
+ return 0;
+ }
+
+ bool res = this->MakefileMap->ReadListFile(packageScript);
+
+ if (cmSystemTools::GetErrorOccuredFlag() || !res) {
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+bool cmCPackExternalGenerator::SupportsComponentInstallation() const
+{
+ return true;
+}
+
+int cmCPackExternalGenerator::InstallProjectViaInstallCommands(
+ bool setDestDir, const std::string& tempInstallDirectory)
+{
+ if (this->StagingEnabled()) {
+ return cmCPackGenerator::InstallProjectViaInstallCommands(
+ setDestDir, tempInstallDirectory);
+ }
+
+ return 1;
+}
+
+int cmCPackExternalGenerator::InstallProjectViaInstallScript(
+ bool setDestDir, const std::string& tempInstallDirectory)
+{
+ if (this->StagingEnabled()) {
+ return cmCPackGenerator::InstallProjectViaInstallScript(
+ setDestDir, tempInstallDirectory);
+ }
+
+ return 1;
+}
+
+int cmCPackExternalGenerator::InstallProjectViaInstalledDirectories(
+ bool setDestDir, const std::string& tempInstallDirectory,
+ const mode_t* default_dir_mode)
+{
+ if (this->StagingEnabled()) {
+ return cmCPackGenerator::InstallProjectViaInstalledDirectories(
+ setDestDir, tempInstallDirectory, default_dir_mode);
+ }
+
+ return 1;
+}
+
+int cmCPackExternalGenerator::RunPreinstallTarget(
+ const std::string& installProjectName, const std::string& installDirectory,
+ cmGlobalGenerator* globalGenerator, const std::string& buildConfig)
+{
+ if (this->StagingEnabled()) {
+ return cmCPackGenerator::RunPreinstallTarget(
+ installProjectName, installDirectory, globalGenerator, buildConfig);
+ }
+
+ return 1;
+}
+
+int cmCPackExternalGenerator::InstallCMakeProject(
+ bool setDestDir, const std::string& installDirectory,
+ const std::string& baseTempInstallDirectory, const mode_t* default_dir_mode,
+ const std::string& component, bool componentInstall,
+ const std::string& installSubDirectory, const std::string& buildConfig,
+ std::string& absoluteDestFiles)
+{
+ if (this->StagingEnabled()) {
+ return cmCPackGenerator::InstallCMakeProject(
+ setDestDir, installDirectory, baseTempInstallDirectory, default_dir_mode,
+ component, componentInstall, installSubDirectory, buildConfig,
+ absoluteDestFiles);
+ }
+
+ return 1;
+}
+
+bool cmCPackExternalGenerator::StagingEnabled() const
+{
+ return !cmIsOff(this->GetOption("CPACK_EXTERNAL_ENABLE_STAGING"));
+}
+
+cmCPackExternalGenerator::cmCPackExternalVersionGenerator::
+ cmCPackExternalVersionGenerator(cmCPackExternalGenerator* parent)
+ : Parent(parent)
+{
+}
+
+int cmCPackExternalGenerator::cmCPackExternalVersionGenerator::WriteVersion(
+ Json::Value& root)
+{
+ root["formatVersionMajor"] = this->GetVersionMajor();
+ root["formatVersionMinor"] = this->GetVersionMinor();
+
+ return 1;
+}
+
+int cmCPackExternalGenerator::cmCPackExternalVersionGenerator::WriteToJSON(
+ Json::Value& root)
+{
+ if (!this->WriteVersion(root)) {
+ return 0;
+ }
+
+ const char* packageName = this->Parent->GetOption("CPACK_PACKAGE_NAME");
+ if (packageName) {
+ root["packageName"] = packageName;
+ }
+
+ const char* packageVersion =
+ this->Parent->GetOption("CPACK_PACKAGE_VERSION");
+ if (packageVersion) {
+ root["packageVersion"] = packageVersion;
+ }
+
+ const char* packageDescriptionFile =
+ this->Parent->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE");
+ if (packageDescriptionFile) {
+ root["packageDescriptionFile"] = packageDescriptionFile;
+ }
+
+ const char* packageDescriptionSummary =
+ this->Parent->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY");
+ if (packageDescriptionSummary) {
+ root["packageDescriptionSummary"] = packageDescriptionSummary;
+ }
+
+ const char* buildConfigCstr = this->Parent->GetOption("CPACK_BUILD_CONFIG");
+ if (buildConfigCstr) {
+ root["buildConfig"] = buildConfigCstr;
+ }
+
+ const char* defaultDirectoryPermissions =
+ this->Parent->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS");
+ if (defaultDirectoryPermissions && *defaultDirectoryPermissions) {
+ root["defaultDirectoryPermissions"] = defaultDirectoryPermissions;
+ }
+ if (cmIsInternallyOn(this->Parent->GetOption("CPACK_SET_DESTDIR"))) {
+ root["setDestdir"] = true;
+ root["packagingInstallPrefix"] =
+ this->Parent->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
+ } else {
+ root["setDestdir"] = false;
+ }
+
+ root["stripFiles"] = !cmIsOff(this->Parent->GetOption("CPACK_STRIP_FILES"));
+ root["warnOnAbsoluteInstallDestination"] =
+ this->Parent->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION");
+ root["errorOnAbsoluteInstallDestination"] =
+ this->Parent->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION");
+
+ Json::Value& projects = root["projects"] = Json::Value(Json::arrayValue);
+ for (auto& project : this->Parent->CMakeProjects) {
+ Json::Value jsonProject(Json::objectValue);
+
+ jsonProject["projectName"] = project.ProjectName;
+ jsonProject["component"] = project.Component;
+ jsonProject["directory"] = project.Directory;
+ jsonProject["subDirectory"] = project.SubDirectory;
+
+ Json::Value& installationTypes = jsonProject["installationTypes"] =
+ Json::Value(Json::arrayValue);
+ for (auto& installationType : project.InstallationTypes) {
+ installationTypes.append(installationType->Name);
+ }
+
+ Json::Value& components = jsonProject["components"] =
+ Json::Value(Json::arrayValue);
+ for (auto& component : project.Components) {
+ components.append(component->Name);
+ }
+
+ projects.append(jsonProject);
+ }
+
+ Json::Value& installationTypes = root["installationTypes"] =
+ Json::Value(Json::objectValue);
+ for (auto& installationType : this->Parent->InstallationTypes) {
+ Json::Value& jsonInstallationType =
+ installationTypes[installationType.first] =
+ Json::Value(Json::objectValue);
+
+ jsonInstallationType["name"] = installationType.second.Name;
+ jsonInstallationType["displayName"] = installationType.second.DisplayName;
+ jsonInstallationType["index"] = installationType.second.Index;
+ }
+
+ Json::Value& components = root["components"] =
+ Json::Value(Json::objectValue);
+ for (auto& component : this->Parent->Components) {
+ Json::Value& jsonComponent = components[component.first] =
+ Json::Value(Json::objectValue);
+
+ jsonComponent["name"] = component.second.Name;
+ jsonComponent["displayName"] = component.second.DisplayName;
+ if (component.second.Group) {
+ jsonComponent["group"] = component.second.Group->Name;
+ }
+ jsonComponent["isRequired"] = component.second.IsRequired;
+ jsonComponent["isHidden"] = component.second.IsHidden;
+ jsonComponent["isDisabledByDefault"] =
+ component.second.IsDisabledByDefault;
+ jsonComponent["isDownloaded"] = component.second.IsDownloaded;
+ jsonComponent["description"] = component.second.Description;
+ jsonComponent["archiveFile"] = component.second.ArchiveFile;
+
+ Json::Value& cmpInstallationTypes = jsonComponent["installationTypes"] =
+ Json::Value(Json::arrayValue);
+ for (auto& installationType : component.second.InstallationTypes) {
+ cmpInstallationTypes.append(installationType->Name);
+ }
+
+ Json::Value& dependencies = jsonComponent["dependencies"] =
+ Json::Value(Json::arrayValue);
+ for (auto& dep : component.second.Dependencies) {
+ dependencies.append(dep->Name);
+ }
+ }
+
+ Json::Value& groups = root["componentGroups"] =
+ Json::Value(Json::objectValue);
+ for (auto& group : this->Parent->ComponentGroups) {
+ Json::Value& jsonGroup = groups[group.first] =
+ Json::Value(Json::objectValue);
+
+ jsonGroup["name"] = group.second.Name;
+ jsonGroup["displayName"] = group.second.DisplayName;
+ jsonGroup["description"] = group.second.Description;
+ jsonGroup["isBold"] = group.second.IsBold;
+ jsonGroup["isExpandedByDefault"] = group.second.IsExpandedByDefault;
+ if (group.second.ParentGroup) {
+ jsonGroup["parentGroup"] = group.second.ParentGroup->Name;
+ }
+
+ Json::Value& subgroups = jsonGroup["subgroups"] =
+ Json::Value(Json::arrayValue);
+ for (auto& subgroup : group.second.Subgroups) {
+ subgroups.append(subgroup->Name);
+ }
+
+ Json::Value& groupComponents = jsonGroup["components"] =
+ Json::Value(Json::arrayValue);
+ for (auto& component : group.second.Components) {
+ groupComponents.append(component->Name);
+ }
+ }
+
+ return 1;
+}
diff --git a/Source/CPack/cmCPackExternalGenerator.h b/Source/CPack/cmCPackExternalGenerator.h
new file mode 100644
index 000000000..80011fddd
--- /dev/null
+++ b/Source/CPack/cmCPackExternalGenerator.h
@@ -0,0 +1,90 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmCPackExternalGenerator_h
+#define cmCPackExternalGenerator_h
+
+#include <memory>
+#include <string>
+
+#include "cm_sys_stat.h"
+
+#include "cmCPackGenerator.h"
+
+class cmGlobalGenerator;
+namespace Json {
+class Value;
+}
+
+/** \class cmCPackExternalGenerator
+ * \brief A generator for CPack External packaging tools
+ */
+class cmCPackExternalGenerator : public cmCPackGenerator
+{
+public:
+ cmCPackTypeMacro(cmCPackExternalGenerator, cmCPackGenerator);
+
+ const char* GetOutputExtension() override { return ".json"; }
+
+protected:
+ int InitializeInternal() override;
+
+ int PackageFiles() override;
+
+ bool SupportsComponentInstallation() const override;
+
+ int InstallProjectViaInstallCommands(
+ bool setDestDir, const std::string& tempInstallDirectory) override;
+ int InstallProjectViaInstallScript(
+ bool setDestDir, const std::string& tempInstallDirectory) override;
+ int InstallProjectViaInstalledDirectories(
+ bool setDestDir, const std::string& tempInstallDirectory,
+ const mode_t* default_dir_mode) override;
+
+ int RunPreinstallTarget(const std::string& installProjectName,
+ const std::string& installDirectory,
+ cmGlobalGenerator* globalGenerator,
+ const std::string& buildConfig) override;
+ int InstallCMakeProject(bool setDestDir, const std::string& installDirectory,
+ const std::string& baseTempInstallDirectory,
+ const mode_t* default_dir_mode,
+ const std::string& component, bool componentInstall,
+ const std::string& installSubDirectory,
+ const std::string& buildConfig,
+ std::string& absoluteDestFiles) override;
+
+private:
+ bool StagingEnabled() const;
+
+ class cmCPackExternalVersionGenerator
+ {
+ public:
+ cmCPackExternalVersionGenerator(cmCPackExternalGenerator* parent);
+
+ virtual ~cmCPackExternalVersionGenerator() = default;
+
+ virtual int WriteToJSON(Json::Value& root);
+
+ protected:
+ virtual int GetVersionMajor() = 0;
+ virtual int GetVersionMinor() = 0;
+
+ int WriteVersion(Json::Value& root);
+
+ cmCPackExternalGenerator* Parent;
+ };
+
+ class cmCPackExternalVersion1Generator
+ : public cmCPackExternalVersionGenerator
+ {
+ public:
+ using cmCPackExternalVersionGenerator::cmCPackExternalVersionGenerator;
+
+ protected:
+ int GetVersionMajor() override { return 1; }
+ int GetVersionMinor() override { return 0; }
+ };
+
+ std::unique_ptr<cmCPackExternalVersionGenerator> Generator;
+};
+
+#endif
diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx
new file mode 100644
index 000000000..e3cc352fb
--- /dev/null
+++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx
@@ -0,0 +1,337 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmCPackFreeBSDGenerator.h"
+
+#include "cmArchiveWrite.h"
+#include "cmCPackArchiveGenerator.h"
+#include "cmCPackLog.h"
+#include "cmGeneratedFileStream.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+// Needed for ::open() and ::stat()
+#include <algorithm>
+#include <ostream>
+#include <utility>
+#include <vector>
+
+#include <fcntl.h>
+#include <pkg.h>
+
+#include <sys/stat.h>
+
+cmCPackFreeBSDGenerator::cmCPackFreeBSDGenerator()
+ : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr", ".txz")
+{
+}
+
+int cmCPackFreeBSDGenerator::InitializeInternal()
+{
+ this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr/local");
+ this->SetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
+ return this->Superclass::InitializeInternal();
+}
+
+cmCPackFreeBSDGenerator::~cmCPackFreeBSDGenerator() = default;
+
+// This is a wrapper, for use only in stream-based output,
+// that will output a string in UCL escaped fashion (in particular,
+// quotes and backslashes are escaped). The list of characters
+// to escape is taken from https://github.com/vstakhov/libucl
+// (which is the reference implementation pkg(8) refers to).
+class EscapeQuotes
+{
+public:
+ const std::string& value;
+
+ EscapeQuotes(const std::string& s)
+ : value(s)
+ {
+ }
+};
+
+// Output a string as "string" with escaping applied.
+cmGeneratedFileStream& operator<<(cmGeneratedFileStream& s,
+ const EscapeQuotes& v)
+{
+ s << '"';
+ for (char c : v.value) {
+ switch (c) {
+ case '\n':
+ s << "\\n";
+ break;
+ case '\r':
+ s << "\\r";
+ break;
+ case '\b':
+ s << "\\b";
+ break;
+ case '\t':
+ s << "\\t";
+ break;
+ case '\f':
+ s << "\\f";
+ break;
+ case '\\':
+ s << "\\\\";
+ break;
+ case '"':
+ s << "\\\"";
+ break;
+ default:
+ s << c;
+ break;
+ }
+ }
+ s << '"';
+ return s;
+}
+
+// The following classes are all helpers for writing out the UCL
+// manifest file (it also looks like JSON). ManifestKey just has
+// a (string-valued) key; subclasses add a specific kind of
+// value-type to the key, and implement write_value() to output
+// the corresponding UCL.
+class ManifestKey
+{
+public:
+ std::string key;
+
+ ManifestKey(std::string k)
+ : key(std::move(k))
+ {
+ }
+
+ virtual ~ManifestKey() = default;
+
+ // Output the value associated with this key to the stream @p s.
+ // Format is to be decided by subclasses.
+ virtual void write_value(cmGeneratedFileStream& s) const = 0;
+};
+
+// Basic string-value (e.g. "name": "cmake")
+class ManifestKeyValue : public ManifestKey
+{
+public:
+ std::string value;
+
+ ManifestKeyValue(const std::string& k, std::string v)
+ : ManifestKey(k)
+ , value(std::move(v))
+ {
+ }
+
+ void write_value(cmGeneratedFileStream& s) const override
+ {
+ s << EscapeQuotes(value);
+ }
+};
+
+// List-of-strings values (e.g. "licenses": ["GPLv2", "LGPLv2"])
+class ManifestKeyListValue : public ManifestKey
+{
+public:
+ using VList = std::vector<std::string>;
+ VList value;
+
+ ManifestKeyListValue(const std::string& k)
+ : ManifestKey(k)
+ {
+ }
+
+ ManifestKeyListValue& operator<<(const std::string& v)
+ {
+ value.push_back(v);
+ return *this;
+ }
+
+ ManifestKeyListValue& operator<<(const std::vector<std::string>& v)
+ {
+ for (std::string const& e : v) {
+ (*this) << e;
+ }
+ return *this;
+ }
+
+ void write_value(cmGeneratedFileStream& s) const override
+ {
+ bool with_comma = false;
+
+ s << '[';
+ for (std::string const& elem : value) {
+ s << (with_comma ? ',' : ' ');
+ s << EscapeQuotes(elem);
+ with_comma = true;
+ }
+ s << " ]";
+ }
+};
+
+// Deps: actually a dictionary, but we'll treat it as a
+// list so we only name the deps, and produce dictionary-
+// like output via write_value()
+class ManifestKeyDepsValue : public ManifestKeyListValue
+{
+public:
+ ManifestKeyDepsValue(const std::string& k)
+ : ManifestKeyListValue(k)
+ {
+ }
+
+ void write_value(cmGeneratedFileStream& s) const override
+ {
+ s << "{\n";
+ for (std::string const& elem : value) {
+ s << " \"" << elem << R"(": {"origin": ")" << elem << "\"},\n";
+ }
+ s << '}';
+ }
+};
+
+// Write one of the key-value classes (above) to the stream @p s
+cmGeneratedFileStream& operator<<(cmGeneratedFileStream& s,
+ const ManifestKey& v)
+{
+ s << '"' << v.key << "\": ";
+ v.write_value(s);
+ s << ",\n";
+ return s;
+}
+
+// Look up variable; if no value is set, returns an empty string;
+// basically a wrapper that handles the NULL-ptr return from GetOption().
+std::string cmCPackFreeBSDGenerator::var_lookup(const char* var_name)
+{
+ const char* pv = this->GetOption(var_name);
+ if (!pv) {
+ return std::string();
+ }
+ return pv;
+}
+
+// Produce UCL in the given @p manifest file for the common
+// manifest fields (common to the compact and regular formats),
+// by reading the CPACK_FREEBSD_* variables.
+void cmCPackFreeBSDGenerator::write_manifest_fields(
+ cmGeneratedFileStream& manifest)
+{
+ manifest << ManifestKeyValue("name",
+ var_lookup("CPACK_FREEBSD_PACKAGE_NAME"));
+ manifest << ManifestKeyValue("origin",
+ var_lookup("CPACK_FREEBSD_PACKAGE_ORIGIN"));
+ manifest << ManifestKeyValue("version",
+ var_lookup("CPACK_FREEBSD_PACKAGE_VERSION"));
+ manifest << ManifestKeyValue("maintainer",
+ var_lookup("CPACK_FREEBSD_PACKAGE_MAINTAINER"));
+ manifest << ManifestKeyValue("comment",
+ var_lookup("CPACK_FREEBSD_PACKAGE_COMMENT"));
+ manifest << ManifestKeyValue(
+ "desc", var_lookup("CPACK_FREEBSD_PACKAGE_DESCRIPTION"));
+ manifest << ManifestKeyValue("www", var_lookup("CPACK_FREEBSD_PACKAGE_WWW"));
+ std::vector<std::string> licenses =
+ cmExpandedList(var_lookup("CPACK_FREEBSD_PACKAGE_LICENSE"));
+ std::string licenselogic("single");
+ if (licenses.empty()) {
+ cmSystemTools::SetFatalErrorOccured();
+ } else if (licenses.size() > 1) {
+ licenselogic = var_lookup("CPACK_FREEBSD_PACKAGE_LICENSE_LOGIC");
+ }
+ manifest << ManifestKeyValue("licenselogic", licenselogic);
+ manifest << (ManifestKeyListValue("licenses") << licenses);
+ std::vector<std::string> categories =
+ cmExpandedList(var_lookup("CPACK_FREEBSD_PACKAGE_CATEGORIES"));
+ manifest << (ManifestKeyListValue("categories") << categories);
+ manifest << ManifestKeyValue("prefix", var_lookup("CMAKE_INSTALL_PREFIX"));
+ std::vector<std::string> deps =
+ cmExpandedList(var_lookup("CPACK_FREEBSD_PACKAGE_DEPS"));
+ if (!deps.empty()) {
+ manifest << (ManifestKeyDepsValue("deps") << deps);
+ }
+}
+
+// Package only actual files; others are ignored (in particular,
+// intermediate subdirectories are ignored).
+static bool ignore_file(const std::string& filename)
+{
+ struct stat statbuf;
+ return stat(filename.c_str(), &statbuf) < 0 ||
+ (statbuf.st_mode & S_IFMT) != S_IFREG;
+}
+
+// Write the given list of @p files to the manifest stream @p s,
+// as the UCL field "files" (which is dictionary-valued, to
+// associate filenames with hashes). All the files are transformed
+// to paths relative to @p toplevel, with a leading / (since the paths
+// in FreeBSD package files are supposed to be absolute).
+void write_manifest_files(cmGeneratedFileStream& s,
+ const std::string& toplevel,
+ const std::vector<std::string>& files)
+{
+ s << "\"files\": {\n";
+ for (std::string const& file : files) {
+ s << " \"/" << cmSystemTools::RelativePath(toplevel, file) << "\": \""
+ << "<sha256>"
+ << "\",\n";
+ }
+ s << " },\n";
+}
+
+int cmCPackFreeBSDGenerator::PackageFiles()
+{
+ if (!this->ReadListFile("Internal/CPack/CPackFreeBSD.cmake")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error while execution CPackFreeBSD.cmake" << std::endl);
+ return 0;
+ }
+
+ std::vector<std::string>::const_iterator fileIt;
+ std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
+ cmSystemTools::ChangeDirectory(toplevel);
+
+ files.erase(std::remove_if(files.begin(), files.end(), ignore_file),
+ files.end());
+
+ std::string manifestname = toplevel + "/+MANIFEST";
+ {
+ cmGeneratedFileStream manifest(manifestname);
+ manifest << "{\n";
+ write_manifest_fields(manifest);
+ write_manifest_files(manifest, toplevel, files);
+ manifest << "}\n";
+ }
+
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl);
+
+ if (WantsComponentInstallation()) {
+ // CASE 1 : COMPONENT ALL-IN-ONE package
+ // If ALL COMPONENTS in ONE package has been requested
+ // then the package file is unique and should be open here.
+ if (componentPackageMethod == ONE_PACKAGE) {
+ return PackageComponentsAllInOne();
+ }
+ // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
+ // There will be 1 package for each component group
+ // however one may require to ignore component group and
+ // in this case you'll get 1 package for each component.
+ return PackageComponents(componentPackageMethod ==
+ ONE_PACKAGE_PER_COMPONENT);
+ }
+
+ std::string output_dir = cmSystemTools::CollapseFullPath("../", toplevel);
+ pkg_create_from_manifest(output_dir.c_str(), ::TXZ, toplevel.c_str(),
+ manifestname.c_str(), nullptr);
+
+ std::string broken_suffix =
+ cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), ".txz");
+ for (std::string& name : packageFileNames) {
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Packagefile " << name << std::endl);
+ if (cmHasSuffix(name, broken_suffix)) {
+ name.replace(name.size() - broken_suffix.size(), std::string::npos,
+ ".txz");
+ break;
+ }
+ }
+
+ cmSystemTools::ChangeDirectory(dir);
+ return 1;
+}
diff --git a/Source/CPack/cmCPackFreeBSDGenerator.h b/Source/CPack/cmCPackFreeBSDGenerator.h
new file mode 100644
index 000000000..a18b72f62
--- /dev/null
+++ b/Source/CPack/cmCPackFreeBSDGenerator.h
@@ -0,0 +1,37 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmCPackFreeBSDGenerator_h
+#define cmCPackFreeBSDGenerator_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+
+#include "cmCPackArchiveGenerator.h"
+#include "cmCPackGenerator.h"
+
+class cmGeneratedFileStream;
+
+/** \class cmCPackFreeBSDGenerator
+ * \brief A generator for FreeBSD package files (TXZ with a manifest)
+ *
+ */
+class cmCPackFreeBSDGenerator : public cmCPackArchiveGenerator
+{
+public:
+ cmCPackTypeMacro(cmCPackFreeBSDGenerator, cmCPackArchiveGenerator);
+ /**
+ * Construct generator
+ */
+ cmCPackFreeBSDGenerator();
+ ~cmCPackFreeBSDGenerator() override;
+
+ int InitializeInternal() override;
+ int PackageFiles() override;
+
+protected:
+ std::string var_lookup(const char* var_name);
+ void write_manifest_fields(cmGeneratedFileStream&);
+};
+
+#endif
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index d8e2753cf..6698f3c11 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -2,49 +2,53 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackGenerator.h"
+#include <algorithm>
+#include <cstring>
+#include <memory>
+#include <utility>
+
#include "cmsys/FStream.hxx"
#include "cmsys/Glob.hxx"
#include "cmsys/RegularExpression.hxx"
-#include <algorithm>
-#include <utility>
#include "cmCPackComponentGroup.h"
#include "cmCPackLog.h"
#include "cmCryptoHash.h"
+#include "cmDuration.h"
+#include "cmFSPermissions.h"
+#include "cmFileTimes.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmState.h"
#include "cmStateSnapshot.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmVersion.h"
#include "cmWorkingDirectory.h"
#include "cmXMLSafe.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
#if defined(__HAIKU__)
-#include <FindDirectory.h>
-#include <StorageDefs.h>
+# include <FindDirectory.h>
+# include <StorageDefs.h>
#endif
cmCPackGenerator::cmCPackGenerator()
{
this->GeneratorVerbose = cmSystemTools::OUTPUT_NONE;
- this->MakefileMap = CM_NULLPTR;
- this->Logger = CM_NULLPTR;
+ this->MakefileMap = nullptr;
+ this->Logger = nullptr;
this->componentPackageMethod = ONE_PACKAGE_PER_GROUP;
}
cmCPackGenerator::~cmCPackGenerator()
{
- this->MakefileMap = CM_NULLPTR;
+ this->MakefileMap = nullptr;
}
-void cmCPackGeneratorProgress(const char* msg, float prog, void* ptr)
-{
- cmCPackGenerator* self = static_cast<cmCPackGenerator*>(ptr);
- self->DisplayVerboseOutput(msg, prog);
-}
-
-void cmCPackGenerator::DisplayVerboseOutput(const char* msg, float progress)
+void cmCPackGenerator::DisplayVerboseOutput(const std::string& msg,
+ float progress)
{
(void)progress;
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "" << msg << std::endl);
@@ -57,9 +61,10 @@ int cmCPackGenerator::PrepareNames()
// checks CPACK_SET_DESTDIR support
if (IsOn("CPACK_SET_DESTDIR")) {
if (SETDESTDIR_UNSUPPORTED == SupportsSetDestdir()) {
- cmCPackLogger(
- cmCPackLog::LOG_ERROR, "CPACK_SET_DESTDIR is set to ON but the '"
- << Name << "' generator does NOT support it." << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_SET_DESTDIR is set to ON but the '"
+ << Name << "' generator does NOT support it."
+ << std::endl);
return 0;
}
if (SETDESTDIR_SHOULD_NOT_BE_USED == SupportsSetDestdir()) {
@@ -70,8 +75,8 @@ int cmCPackGenerator::PrepareNames()
}
}
- std::string tempDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
- tempDirectory += "/_CPack_Packages/";
+ std::string tempDirectory =
+ cmStrCat(this->GetOption("CPACK_PACKAGE_DIRECTORY"), "/_CPack_Packages/");
const char* toplevelTag = this->GetOption("CPACK_TOPLEVEL_TAG");
if (toplevelTag) {
tempDirectory += toplevelTag;
@@ -88,8 +93,8 @@ int cmCPackGenerator::PrepareNames()
std::string outName = pfname;
tempDirectory += "/" + outName;
if (!this->GetOutputExtension()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "No output extension specified"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "No output extension specified" << std::endl);
return 0;
}
outName += this->GetOutputExtension();
@@ -120,9 +125,9 @@ int cmCPackGenerator::PrepareNames()
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl);
const char* descFileName = this->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE");
- if (descFileName) {
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for: " << descFileName
- << std::endl);
+ if (descFileName && !this->GetOption("CPACK_PACKAGE_DESCRIPTION")) {
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Look for: " << descFileName << std::endl);
if (!cmSystemTools::FileExists(descFileName)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find description file name: ["
@@ -144,7 +149,12 @@ int cmCPackGenerator::PrepareNames()
while (ifs && cmSystemTools::GetLineFromStream(ifs, line)) {
ostr << cmXMLSafe(line) << std::endl;
}
- this->SetOptionIfNotSet("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str());
+ this->SetOption("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str());
+ const char* defFileName =
+ this->GetOption("CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE");
+ if (defFileName && !strcmp(defFileName, descFileName)) {
+ this->SetOption("CPACK_USED_DEFAULT_PACKAGE_DESCRIPTION_FILE", "ON");
+ }
}
if (!this->GetOption("CPACK_PACKAGE_DESCRIPTION")) {
cmCPackLogger(
@@ -156,9 +166,10 @@ int cmCPackGenerator::PrepareNames()
}
const char* algoSignature = this->GetOption("CPACK_PACKAGE_CHECKSUM");
if (algoSignature) {
- if (cmCryptoHash::New(algoSignature).get() == CM_NULLPTR) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot recognize algorithm: "
- << algoSignature << std::endl);
+ if (!cmCryptoHash::New(algoSignature)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot recognize algorithm: " << algoSignature
+ << std::endl);
return 0;
}
}
@@ -176,15 +187,15 @@ int cmCPackGenerator::InstallProject()
std::string bareTempInstallDirectory =
this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
std::string tempInstallDirectoryStr = bareTempInstallDirectory;
- bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR")) |
- cmSystemTools::IsInternallyOn(this->GetOption("CPACK_SET_DESTDIR"));
+ bool setDestDir = cmIsOn(this->GetOption("CPACK_SET_DESTDIR")) |
+ cmIsInternallyOn(this->GetOption("CPACK_SET_DESTDIR"));
if (!setDestDir) {
tempInstallDirectoryStr += this->GetPackagingInstallPrefix();
}
const char* tempInstallDirectory = tempInstallDirectoryStr.c_str();
int res = 1;
- if (!cmsys::SystemTools::MakeDirectory(bareTempInstallDirectory.c_str())) {
+ if (!cmsys::SystemTools::MakeDirectory(bareTempInstallDirectory)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating temporary directory: "
<< (tempInstallDirectory ? tempInstallDirectory : "(NULL)")
@@ -193,14 +204,37 @@ int cmCPackGenerator::InstallProject()
}
if (setDestDir) {
- std::string destDir = "DESTDIR=";
- destDir += tempInstallDirectory;
+ std::string destDir = cmStrCat("DESTDIR=", tempInstallDirectory);
cmSystemTools::PutEnv(destDir);
} else {
// Make sure there is no destdir
cmSystemTools::PutEnv("DESTDIR=");
}
+ // prepare default created directory permissions
+ mode_t default_dir_mode_v = 0;
+ mode_t* default_dir_mode = nullptr;
+ const char* default_dir_install_permissions =
+ this->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS");
+ if (default_dir_install_permissions && *default_dir_install_permissions) {
+ std::vector<std::string> items =
+ cmExpandedList(default_dir_install_permissions);
+ for (const auto& arg : items) {
+ if (!cmFSPermissions::stringToModeT(arg, default_dir_mode_v)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Invalid permission value '"
+ << arg
+ << "'."
+ " CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS "
+ "value is invalid."
+ << std::endl);
+ return 0;
+ }
+ }
+
+ default_dir_mode = &default_dir_mode_v;
+ }
+
// If the CPackConfig file sets CPACK_INSTALL_COMMANDS then run them
// as listed
if (!this->InstallProjectViaInstallCommands(setDestDir,
@@ -208,7 +242,7 @@ int cmCPackGenerator::InstallProject()
return 0;
}
- // If the CPackConfig file sets CPACK_INSTALL_SCRIPT then run them
+ // If the CPackConfig file sets CPACK_INSTALL_SCRIPT(S) then run them
// as listed
if (!this->InstallProjectViaInstallScript(setDestDir,
tempInstallDirectory)) {
@@ -218,15 +252,15 @@ int cmCPackGenerator::InstallProject()
// If the CPackConfig file sets CPACK_INSTALLED_DIRECTORIES
// then glob it and copy it to CPACK_TEMPORARY_DIRECTORY
// This is used in Source packaging
- if (!this->InstallProjectViaInstalledDirectories(setDestDir,
- tempInstallDirectory)) {
+ if (!this->InstallProjectViaInstalledDirectories(
+ setDestDir, tempInstallDirectory, default_dir_mode)) {
return 0;
}
// If the project is a CMAKE project then run pre-install
// and then read the cmake_install script to run it
- if (!this->InstallProjectViaInstallCMakeProjects(setDestDir,
- bareTempInstallDirectory)) {
+ if (!this->InstallProjectViaInstallCMakeProjects(
+ setDestDir, bareTempInstallDirectory, default_dir_mode)) {
return 0;
}
@@ -243,31 +277,30 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
(void)setDestDir;
const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS");
if (installCommands && *installCommands) {
- std::string tempInstallDirectoryEnv = "CMAKE_INSTALL_PREFIX=";
- tempInstallDirectoryEnv += tempInstallDirectory;
+ std::string tempInstallDirectoryEnv =
+ cmStrCat("CMAKE_INSTALL_PREFIX=", tempInstallDirectory);
cmSystemTools::PutEnv(tempInstallDirectoryEnv);
- std::vector<std::string> installCommandsVector;
- cmSystemTools::ExpandListArgument(installCommands, installCommandsVector);
- std::vector<std::string>::iterator it;
- for (it = installCommandsVector.begin(); it != installCommandsVector.end();
- ++it) {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it << std::endl);
+ std::vector<std::string> installCommandsVector =
+ cmExpandedList(installCommands);
+ for (std::string const& ic : installCommandsVector) {
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ic << std::endl);
std::string output;
int retVal = 1;
- bool resB =
- cmSystemTools::RunSingleCommand(it->c_str(), &output, &output, &retVal,
- CM_NULLPTR, this->GeneratorVerbose, 0);
+ bool resB = cmSystemTools::RunSingleCommand(
+ ic, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
+ cmDuration::zero());
if (!resB || retVal) {
- std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- tmpFile += "/InstallOutput.log";
- cmGeneratedFileStream ofs(tmpFile.c_str());
- ofs << "# Run command: " << *it << std::endl
+ std::string tmpFile = cmStrCat(
+ this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/InstallOutput.log");
+ cmGeneratedFileStream ofs(tmpFile);
+ ofs << "# Run command: " << ic << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
- cmCPackLogger(
- cmCPackLog::LOG_ERROR, "Problem running install command: "
- << *it << std::endl
- << "Please check " << tmpFile << " for errors" << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem running install command: "
+ << ic << std::endl
+ << "Please check " << tmpFile << " for errors"
+ << std::endl);
return 0;
}
}
@@ -276,30 +309,27 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
}
int cmCPackGenerator::InstallProjectViaInstalledDirectories(
- bool setDestDir, const std::string& tempInstallDirectory)
+ bool setDestDir, const std::string& tempInstallDirectory,
+ const mode_t* default_dir_mode)
{
(void)setDestDir;
(void)tempInstallDirectory;
std::vector<cmsys::RegularExpression> ignoreFilesRegex;
const char* cpackIgnoreFiles = this->GetOption("CPACK_IGNORE_FILES");
if (cpackIgnoreFiles) {
- std::vector<std::string> ignoreFilesRegexString;
- cmSystemTools::ExpandListArgument(cpackIgnoreFiles,
- ignoreFilesRegexString);
- std::vector<std::string>::iterator it;
- for (it = ignoreFilesRegexString.begin();
- it != ignoreFilesRegexString.end(); ++it) {
+ std::vector<std::string> ignoreFilesRegexString =
+ cmExpandedList(cpackIgnoreFiles);
+ for (std::string const& ifr : ignoreFilesRegexString) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Create ignore files regex for: " << *it << std::endl);
- ignoreFilesRegex.push_back(it->c_str());
+ "Create ignore files regex for: " << ifr << std::endl);
+ ignoreFilesRegex.emplace_back(ifr);
}
}
const char* installDirectories =
this->GetOption("CPACK_INSTALLED_DIRECTORIES");
if (installDirectories && *installDirectories) {
- std::vector<std::string> installDirectoriesVector;
- cmSystemTools::ExpandListArgument(installDirectories,
- installDirectoriesVector);
+ std::vector<std::string> installDirectoriesVector =
+ cmExpandedList(installDirectories);
if (installDirectoriesVector.size() % 2 != 0) {
cmCPackLogger(
cmCPackLog::LOG_ERROR,
@@ -313,14 +343,13 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
const std::string& tempDir = tempInstallDirectory;
for (it = installDirectoriesVector.begin();
it != installDirectoriesVector.end(); ++it) {
- std::vector<std::pair<std::string, std::string> > symlinkedFiles;
+ std::vector<std::pair<std::string, std::string>> symlinkedFiles;
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
cmsys::Glob gl;
std::string top = *it;
it++;
std::string subdir = *it;
- std::string findExpr = top;
- findExpr += "/*";
+ std::string findExpr = cmStrCat(top, "/*");
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"- Install directory: " << top << std::endl);
gl.RecurseOn();
@@ -332,17 +361,14 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
return 0;
}
files = gl.GetFiles();
- std::vector<std::string>::iterator gfit;
- std::vector<cmsys::RegularExpression>::iterator regIt;
- for (gfit = files.begin(); gfit != files.end(); ++gfit) {
+ for (std::string const& gf : files) {
bool skip = false;
- std::string inFile = *gfit;
- if (cmSystemTools::FileIsDirectory(*gfit)) {
+ std::string inFile = gf;
+ if (cmSystemTools::FileIsDirectory(gf)) {
inFile += '/';
}
- for (regIt = ignoreFilesRegex.begin(); regIt != ignoreFilesRegex.end();
- ++regIt) {
- if (regIt->find(inFile.c_str())) {
+ for (cmsys::RegularExpression& reg : ignoreFilesRegex) {
+ if (reg.find(inFile)) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Ignore file: " << inFile << std::endl);
skip = true;
@@ -351,64 +377,71 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
if (skip) {
continue;
}
- std::string filePath = tempDir;
- filePath += "/" + subdir + "/" +
- cmSystemTools::RelativePath(top.c_str(), gfit->c_str());
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: "
- << inFile << " -> " << filePath << std::endl);
+ std::string filePath = cmStrCat(tempDir, '/', subdir, '/',
+ cmSystemTools::RelativePath(top, gf));
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Copy file: " << inFile << " -> " << filePath
+ << std::endl);
/* If the file is a symlink we will have to re-create it */
if (cmSystemTools::FileIsSymlink(inFile)) {
std::string targetFile;
std::string inFileRelative =
- cmSystemTools::RelativePath(top.c_str(), inFile.c_str());
+ cmSystemTools::RelativePath(top, inFile);
cmSystemTools::ReadSymlink(inFile, targetFile);
- symlinkedFiles.push_back(
- std::pair<std::string, std::string>(targetFile, inFileRelative));
+ symlinkedFiles.emplace_back(std::move(targetFile),
+ std::move(inFileRelative));
}
/* If it is not a symlink then do a plain copy */
- else if (!(cmSystemTools::CopyFileIfDifferent(inFile.c_str(),
- filePath.c_str()) &&
- cmSystemTools::CopyFileTime(inFile.c_str(),
- filePath.c_str()))) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: "
- << inFile << " -> " << filePath << std::endl);
+ else if (!(cmSystemTools::CopyFileIfDifferent(inFile, filePath) &&
+ cmFileTimes::Copy(inFile, filePath))) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem copying file: " << inFile << " -> "
+ << filePath << std::endl);
return 0;
}
}
/* rebuild symlinks in the installed tree */
if (!symlinkedFiles.empty()) {
- std::vector<std::pair<std::string, std::string> >::iterator
- symlinkedIt;
std::string curDir = cmSystemTools::GetCurrentWorkingDirectory();
- std::string goToDir = tempDir;
- goToDir += "/" + subdir;
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir
- << std::endl);
+ std::string goToDir = cmStrCat(tempDir, '/', subdir);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Change dir to: " << goToDir << std::endl);
cmWorkingDirectory workdir(goToDir);
- for (symlinkedIt = symlinkedFiles.begin();
- symlinkedIt != symlinkedFiles.end(); ++symlinkedIt) {
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: "
- << symlinkedIt->second << "--> "
- << symlinkedIt->first << std::endl);
+ if (workdir.Failed()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Failed to change working directory to "
+ << goToDir << " : "
+ << std::strerror(workdir.GetLastResult())
+ << std::endl);
+ return 0;
+ }
+ for (auto const& symlinked : symlinkedFiles) {
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Will create a symlink: " << symlinked.second << "--> "
+ << symlinked.first
+ << std::endl);
// make sure directory exists for symlink
std::string destDir =
- cmSystemTools::GetFilenamePath(symlinkedIt->second);
- if (!destDir.empty() && !cmSystemTools::MakeDirectory(destDir)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create dir: "
+ cmSystemTools::GetFilenamePath(symlinked.second);
+ if (!destDir.empty() &&
+ !cmSystemTools::MakeDirectory(destDir, default_dir_mode)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot create dir: "
<< destDir << "\nTrying to create symlink: "
- << symlinkedIt->second << "--> "
- << symlinkedIt->first << std::endl);
+ << symlinked.second << "--> " << symlinked.first
+ << std::endl);
}
- if (!cmSystemTools::CreateSymlink(symlinkedIt->first,
- symlinkedIt->second)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create symlink: "
- << symlinkedIt->second << "--> "
- << symlinkedIt->first << std::endl);
+ if (!cmSystemTools::CreateSymlink(symlinked.first,
+ symlinked.second)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot create symlink: "
+ << symlinked.second << "--> " << symlinked.first
+ << std::endl);
return 0;
}
}
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: " << curDir
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Going back to: " << curDir << std::endl);
}
}
}
@@ -418,16 +451,24 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
int cmCPackGenerator::InstallProjectViaInstallScript(
bool setDestDir, const std::string& tempInstallDirectory)
{
- const char* cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPT");
+ const char* cmakeScripts = this->GetOption("CPACK_INSTALL_SCRIPTS");
+ {
+ const char* const cmakeScript = this->GetOption("CPACK_INSTALL_SCRIPT");
+ if (cmakeScript && cmakeScripts) {
+ cmCPackLogger(
+ cmCPackLog::LOG_WARNING,
+ "Both CPACK_INSTALL_SCRIPTS and CPACK_INSTALL_SCRIPT are set, "
+ "the latter will be ignored."
+ << std::endl);
+ } else if (cmakeScript && !cmakeScripts) {
+ cmakeScripts = cmakeScript;
+ }
+ }
if (cmakeScripts && *cmakeScripts) {
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install scripts: " << cmakeScripts
- << std::endl);
- std::vector<std::string> cmakeScriptsVector;
- cmSystemTools::ExpandListArgument(cmakeScripts, cmakeScriptsVector);
- std::vector<std::string>::iterator it;
- for (it = cmakeScriptsVector.begin(); it != cmakeScriptsVector.end();
- ++it) {
- std::string installScript = *it;
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "- Install scripts: " << cmakeScripts << std::endl);
+ std::vector<std::string> cmakeScriptsVector = cmExpandedList(cmakeScripts);
+ for (std::string const& installScript : cmakeScriptsVector) {
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"- Install script: " << installScript << std::endl);
@@ -465,7 +506,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
tempInstallDirectory.c_str());
this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR",
tempInstallDirectory.c_str());
- int res = this->MakefileMap->ReadListFile(installScript.c_str());
+ bool res = this->MakefileMap->ReadListFile(installScript);
if (cmSystemTools::GetErrorOccuredFlag() || !res) {
return 0;
}
@@ -475,7 +516,8 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
}
int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
- bool setDestDir, const std::string& baseTempInstallDirectory)
+ bool setDestDir, const std::string& baseTempInstallDirectory,
+ const mode_t* default_dir_mode)
{
const char* cmakeProjects = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
const char* cmakeGenerator = this->GetOption("CPACK_CMAKE_GENERATOR");
@@ -489,8 +531,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
<< std::endl);
return 0;
}
- std::vector<std::string> cmakeProjectsVector;
- cmSystemTools::ExpandListArgument(cmakeProjects, cmakeProjectsVector);
+ std::vector<std::string> cmakeProjectsVector =
+ cmExpandedList(cmakeProjects);
std::vector<std::string>::iterator it;
for (it = cmakeProjectsVector.begin(); it != cmakeProjectsVector.end();
++it) {
@@ -510,10 +552,13 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
++it;
std::string installProjectName = *it;
++it;
- std::string installComponent = *it;
+ cmCPackInstallCMakeProject project;
+
+ project.Directory = installDirectory;
+ project.ProjectName = installProjectName;
+ project.Component = *it;
++it;
- std::string installSubDirectory = *it;
- std::string installFile = installDirectory + "/cmake_install.cmake";
+ project.SubDirectory = *it;
std::vector<std::string> componentsVector;
@@ -524,45 +569,61 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
* - the user did not request Monolithic install
* (this works at CPack time too)
*/
- if (this->SupportsComponentInstallation() &
+ if (this->SupportsComponentInstallation() &&
!(this->IsOn("CPACK_MONOLITHIC_INSTALL"))) {
// Determine the installation types for this project (if provided).
std::string installTypesVar = "CPACK_" +
- cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES";
+ cmSystemTools::UpperCase(project.Component) + "_INSTALL_TYPES";
const char* installTypes = this->GetOption(installTypesVar);
if (installTypes && *installTypes) {
- std::vector<std::string> installTypesVector;
- cmSystemTools::ExpandListArgument(installTypes, installTypesVector);
- std::vector<std::string>::iterator installTypeIt;
- for (installTypeIt = installTypesVector.begin();
- installTypeIt != installTypesVector.end(); ++installTypeIt) {
- this->GetInstallationType(installProjectName, *installTypeIt);
+ std::vector<std::string> installTypesVector =
+ cmExpandedList(installTypes);
+ for (std::string const& installType : installTypesVector) {
+ project.InstallationTypes.push_back(
+ this->GetInstallationType(project.ProjectName, installType));
}
}
// Determine the set of components that will be used in this project
std::string componentsVar =
- "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(installComponent);
+ "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(project.Component);
const char* components = this->GetOption(componentsVar);
if (components && *components) {
- cmSystemTools::ExpandListArgument(components, componentsVector);
- std::vector<std::string>::iterator compIt;
- for (compIt = componentsVector.begin();
- compIt != componentsVector.end(); ++compIt) {
- GetComponent(installProjectName, *compIt);
+ cmExpandList(components, componentsVector);
+ for (std::string const& comp : componentsVector) {
+ project.Components.push_back(
+ this->GetComponent(project.ProjectName, comp));
}
componentInstall = true;
}
}
if (componentsVector.empty()) {
- componentsVector.push_back(installComponent);
+ componentsVector.push_back(project.Component);
}
- const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG");
- std::string buildConfig = buildConfigCstr ? buildConfigCstr : "";
- cmGlobalGenerator* globalGenerator =
+ std::vector<std::string> buildConfigs;
+
+ // Try get configuration names given via `-C` CLI option
+ {
+ const char* const buildConfigCstr =
+ this->GetOption("CPACK_BUILD_CONFIG");
+ auto buildConfig = buildConfigCstr ? buildConfigCstr : std::string{};
+ cmExpandList(buildConfig, buildConfigs);
+ }
+
+ // Remove duplicates
+ std::sort(buildConfigs.begin(), buildConfigs.end());
+ buildConfigs.erase(std::unique(buildConfigs.begin(), buildConfigs.end()),
+ buildConfigs.end());
+
+ // Ensure we have at least one configuration.
+ if (buildConfigs.empty()) {
+ buildConfigs.emplace_back();
+ }
+
+ std::unique_ptr<cmGlobalGenerator> globalGenerator(
this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
- cmakeGenerator);
+ cmakeGenerator));
if (!globalGenerator) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Specified package generator not found. "
@@ -575,289 +636,317 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
// on windows.
cmSystemTools::SetForceUnixPaths(globalGenerator->GetForceUnixPaths());
- // Does this generator require pre-install?
- if (const char* preinstall =
- globalGenerator->GetPreinstallTargetName()) {
- std::string buildCommand = globalGenerator->GenerateCMakeBuildCommand(
- preinstall, buildConfig, "", false);
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Install command: " << buildCommand << std::endl);
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Run preinstall target for: "
- << installProjectName << std::endl);
- std::string output;
- int retVal = 1;
- bool resB = cmSystemTools::RunSingleCommand(
- buildCommand.c_str(), &output, &output, &retVal,
- installDirectory.c_str(), this->GeneratorVerbose, 0);
- if (!resB || retVal) {
- std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- tmpFile += "/PreinstallOutput.log";
- cmGeneratedFileStream ofs(tmpFile.c_str());
- ofs << "# Run command: " << buildCommand << std::endl
- << "# Directory: " << installDirectory << std::endl
- << "# Output:" << std::endl
- << output << std::endl;
- cmCPackLogger(
- cmCPackLog::LOG_ERROR, "Problem running install command: "
- << buildCommand << std::endl
- << "Please check " << tmpFile << " for errors" << std::endl);
+ // Run the installation for the selected build configurations
+ for (auto const& buildConfig : buildConfigs) {
+ if (!this->RunPreinstallTarget(project.ProjectName, project.Directory,
+ globalGenerator.get(), buildConfig)) {
return 0;
}
- }
- delete globalGenerator;
-
- cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "- Install project: " << installProjectName << std::endl);
-
- // Run the installation for each component
- std::vector<std::string>::iterator componentIt;
- for (componentIt = componentsVector.begin();
- componentIt != componentsVector.end(); ++componentIt) {
- std::string tempInstallDirectory = baseTempInstallDirectory;
- installComponent = *componentIt;
- if (componentInstall) {
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install component: "
- << installComponent << std::endl);
- }
- cmake cm(cmake::RoleScript);
- cm.SetHomeDirectory("");
- cm.SetHomeOutputDirectory("");
- cm.GetCurrentSnapshot().SetDefaultDefinitions();
- cm.AddCMakePaths();
- cm.SetProgressCallback(cmCPackGeneratorProgress, this);
- cmGlobalGenerator gg(&cm);
- CM_AUTO_PTR<cmMakefile> mf(
- new cmMakefile(&gg, cm.GetCurrentSnapshot()));
- if (!installSubDirectory.empty() && installSubDirectory != "/" &&
- installSubDirectory != ".") {
- tempInstallDirectory += installSubDirectory;
- }
- if (componentInstall) {
- tempInstallDirectory += "/";
- // Some CPack generators would rather chose
- // the local installation directory suffix.
- // Some (e.g. RPM) use
- // one install directory for each component **GROUP**
- // instead of the default
- // one install directory for each component.
- tempInstallDirectory +=
- GetComponentInstallDirNameSuffix(installComponent);
- if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
- tempInstallDirectory += "/";
- tempInstallDirectory += this->GetOption("CPACK_PACKAGE_FILE_NAME");
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "- Install project: " << project.ProjectName << " ["
+ << buildConfig << ']'
+ << std::endl);
+ // Run the installation for each component
+ for (std::string const& component : componentsVector) {
+ if (!this->InstallCMakeProject(
+ setDestDir, project.Directory, baseTempInstallDirectory,
+ default_dir_mode, component, componentInstall,
+ project.SubDirectory, buildConfig, absoluteDestFiles)) {
+ return 0;
}
}
+ }
- if (!setDestDir) {
- tempInstallDirectory += this->GetPackagingInstallPrefix();
- }
+ this->CMakeProjects.emplace_back(std::move(project));
+ }
+ }
+ this->SetOption("CPACK_ABSOLUTE_DESTINATION_FILES",
+ absoluteDestFiles.c_str());
+ return 1;
+}
- if (setDestDir) {
- // For DESTDIR based packaging, use the *project*
- // CMAKE_INSTALL_PREFIX underneath the tempInstallDirectory. The
- // value of the project's CMAKE_INSTALL_PREFIX is sent in here as
- // the value of the CPACK_INSTALL_PREFIX variable.
- //
- // If DESTDIR has been 'internally set ON' this means that
- // the underlying CPack specific generator did ask for that
- // In this case we may override CPACK_INSTALL_PREFIX with
- // CPACK_PACKAGING_INSTALL_PREFIX
- // I know this is tricky and awkward but it's the price for
- // CPACK_SET_DESTDIR backward compatibility.
- if (cmSystemTools::IsInternallyOn(
- this->GetOption("CPACK_SET_DESTDIR"))) {
- this->SetOption("CPACK_INSTALL_PREFIX",
- this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"));
- }
- std::string dir;
- if (this->GetOption("CPACK_INSTALL_PREFIX")) {
- dir += this->GetOption("CPACK_INSTALL_PREFIX");
- }
- mf->AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str());
+int cmCPackGenerator::RunPreinstallTarget(
+ const std::string& installProjectName, const std::string& installDirectory,
+ cmGlobalGenerator* globalGenerator, const std::string& buildConfig)
+{
+ // Does this generator require pre-install?
+ if (const char* preinstall = globalGenerator->GetPreinstallTargetName()) {
+ std::string buildCommand = globalGenerator->GenerateCMakeBuildCommand(
+ preinstall, buildConfig, "", false);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "- Install command: " << buildCommand << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "- Run preinstall target for: " << installProjectName
+ << std::endl);
+ std::string output;
+ int retVal = 1;
+ bool resB = cmSystemTools::RunSingleCommand(
+ buildCommand, &output, &output, &retVal, installDirectory.c_str(),
+ this->GeneratorVerbose, cmDuration::zero());
+ if (!resB || retVal) {
+ std::string tmpFile = cmStrCat(
+ this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/PreinstallOutput.log");
+ cmGeneratedFileStream ofs(tmpFile);
+ ofs << "# Run command: " << buildCommand << std::endl
+ << "# Directory: " << installDirectory << std::endl
+ << "# Output:" << std::endl
+ << output << std::endl;
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem running install command: "
+ << buildCommand << std::endl
+ << "Please check " << tmpFile << " for errors"
+ << std::endl);
+ return 0;
+ }
+ }
- cmCPackLogger(
- cmCPackLog::LOG_DEBUG,
- "- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf->AddDefinition)"
- << std::endl);
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'"
- << std::endl);
-
- // Make sure that DESTDIR + CPACK_INSTALL_PREFIX directory
- // exists:
- //
- if (cmSystemTools::StringStartsWith(dir.c_str(), "/")) {
- dir = tempInstallDirectory + dir;
- } else {
- dir = tempInstallDirectory + "/" + dir;
- }
- /*
- * We must re-set DESTDIR for each component
- * We must not add the CPACK_INSTALL_PREFIX part because
- * it will be added using the override of CMAKE_INSTALL_PREFIX
- * The main reason for this awkward trick is that
- * are using DESTDIR for 2 different reasons:
- * - Because it was asked by the CPack Generator or the user
- * using CPACK_SET_DESTDIR
- * - Because it was already used for component install
- * in order to put things in subdirs...
- */
- cmSystemTools::PutEnv(std::string("DESTDIR=") +
- tempInstallDirectory);
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "- Creating directory: '"
- << dir << "'" << std::endl);
-
- if (!cmsys::SystemTools::MakeDirectory(dir.c_str())) {
- cmCPackLogger(
- cmCPackLog::LOG_ERROR,
- "Problem creating temporary directory: " << dir << std::endl);
- return 0;
- }
- } else {
- mf->AddDefinition("CMAKE_INSTALL_PREFIX",
- tempInstallDirectory.c_str());
+ return 1;
+}
- if (!cmsys::SystemTools::MakeDirectory(
- tempInstallDirectory.c_str())) {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem creating temporary directory: "
- << tempInstallDirectory << std::endl);
- return 0;
- }
+int cmCPackGenerator::InstallCMakeProject(
+ bool setDestDir, const std::string& installDirectory,
+ const std::string& baseTempInstallDirectory, const mode_t* default_dir_mode,
+ const std::string& component, bool componentInstall,
+ const std::string& installSubDirectory, const std::string& buildConfig,
+ std::string& absoluteDestFiles)
+{
+ std::string tempInstallDirectory = baseTempInstallDirectory;
+ std::string installFile = installDirectory + "/cmake_install.cmake";
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Using non-DESTDIR install... (mf->AddDefinition)"
- << std::endl);
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "- Setting CMAKE_INSTALL_PREFIX to '"
- << tempInstallDirectory << "'" << std::endl);
- }
+ if (componentInstall) {
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "- Install component: " << component << std::endl);
+ }
- if (!buildConfig.empty()) {
- mf->AddDefinition("BUILD_TYPE", buildConfig.c_str());
- }
- std::string installComponentLowerCase =
- cmSystemTools::LowerCase(installComponent);
- if (installComponentLowerCase != "all") {
- mf->AddDefinition("CMAKE_INSTALL_COMPONENT",
- installComponent.c_str());
- }
+ cmake cm(cmake::RoleScript, cmState::CPack);
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
+ cm.GetCurrentSnapshot().SetDefaultDefinitions();
+ cm.AddCMakePaths();
+ cm.SetProgressCallback([this](const std::string& msg, float prog) {
+ this->DisplayVerboseOutput(msg, prog);
+ });
+ cm.SetTrace(this->Trace);
+ cm.SetTraceExpand(this->TraceExpand);
+ cmGlobalGenerator gg(&cm);
+ cmMakefile mf(&gg, cm.GetCurrentSnapshot());
+ if (!installSubDirectory.empty() && installSubDirectory != "/" &&
+ installSubDirectory != ".") {
+ tempInstallDirectory += installSubDirectory;
+ }
+ if (componentInstall) {
+ tempInstallDirectory += "/";
+ // Some CPack generators would rather chose
+ // the local installation directory suffix.
+ // Some (e.g. RPM) use
+ // one install directory for each component **GROUP**
+ // instead of the default
+ // one install directory for each component.
+ tempInstallDirectory += GetComponentInstallDirNameSuffix(component);
+ if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
+ tempInstallDirectory += "/";
+ tempInstallDirectory += this->GetOption("CPACK_PACKAGE_FILE_NAME");
+ }
+ }
- // strip on TRUE, ON, 1, one or several file names, but not on
- // FALSE, OFF, 0 and an empty string
- if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES"))) {
- mf->AddDefinition("CMAKE_INSTALL_DO_STRIP", "1");
- }
- // Remember the list of files before installation
- // of the current component (if we are in component install)
- const char* InstallPrefix = tempInstallDirectory.c_str();
- std::vector<std::string> filesBefore;
- std::string findExpr(InstallPrefix);
- if (componentInstall) {
- cmsys::Glob glB;
- findExpr += "/*";
- glB.RecurseOn();
- glB.SetRecurseListDirs(true);
- glB.FindFiles(findExpr);
- filesBefore = glB.GetFiles();
- std::sort(filesBefore.begin(), filesBefore.end());
- }
+ const char* default_dir_inst_permissions =
+ this->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS");
+ if (default_dir_inst_permissions && *default_dir_inst_permissions) {
+ mf.AddDefinition("CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS",
+ default_dir_inst_permissions);
+ }
- // If CPack was asked to warn on ABSOLUTE INSTALL DESTINATION
- // then forward request to cmake_install.cmake script
- if (this->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")) {
- mf->AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
- }
- // If current CPack generator does support
- // ABSOLUTE INSTALL DESTINATION or CPack has been asked for
- // then ask cmake_install.cmake script to error out
- // as soon as it occurs (before installing file)
- if (!SupportsAbsoluteDestination() ||
- this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) {
- mf->AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION",
- "1");
- }
- // do installation
- int res = mf->ReadListFile(installFile.c_str());
- // forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES
- // to CPack (may be used by generators like CPack RPM or DEB)
- // in order to transparently handle ABSOLUTE PATH
- if (mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) {
- mf->AddDefinition(
- "CPACK_ABSOLUTE_DESTINATION_FILES",
- mf->GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES"));
- }
+ if (!setDestDir) {
+ tempInstallDirectory += this->GetPackagingInstallPrefix();
+ }
- // Now rebuild the list of files after installation
- // of the current component (if we are in component install)
- if (componentInstall) {
- cmsys::Glob glA;
- glA.RecurseOn();
- glA.SetRecurseListDirs(true);
- glA.SetRecurseThroughSymlinks(false);
- glA.FindFiles(findExpr);
- std::vector<std::string> filesAfter = glA.GetFiles();
- std::sort(filesAfter.begin(), filesAfter.end());
- std::vector<std::string>::iterator diff;
- std::vector<std::string> result(filesAfter.size());
- diff = std::set_difference(filesAfter.begin(), filesAfter.end(),
- filesBefore.begin(), filesBefore.end(),
- result.begin());
-
- std::vector<std::string>::iterator fit;
- std::string localFileName;
- // Populate the File field of each component
- for (fit = result.begin(); fit != diff; ++fit) {
- localFileName =
- cmSystemTools::RelativePath(InstallPrefix, fit->c_str());
- localFileName =
- localFileName.substr(localFileName.find_first_not_of('/'));
- Components[installComponent].Files.push_back(localFileName);
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <"
- << localFileName << "> to component <"
- << installComponent << ">" << std::endl);
- }
- }
+ if (setDestDir) {
+ // For DESTDIR based packaging, use the *project*
+ // CMAKE_INSTALL_PREFIX underneath the tempInstallDirectory. The
+ // value of the project's CMAKE_INSTALL_PREFIX is sent in here as
+ // the value of the CPACK_INSTALL_PREFIX variable.
+ //
+ // If DESTDIR has been 'internally set ON' this means that
+ // the underlying CPack specific generator did ask for that
+ // In this case we may override CPACK_INSTALL_PREFIX with
+ // CPACK_PACKAGING_INSTALL_PREFIX
+ // I know this is tricky and awkward but it's the price for
+ // CPACK_SET_DESTDIR backward compatibility.
+ if (cmIsInternallyOn(this->GetOption("CPACK_SET_DESTDIR"))) {
+ this->SetOption("CPACK_INSTALL_PREFIX",
+ this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"));
+ }
+ std::string dir;
+ if (this->GetOption("CPACK_INSTALL_PREFIX")) {
+ dir += this->GetOption("CPACK_INSTALL_PREFIX");
+ }
+ mf.AddDefinition("CMAKE_INSTALL_PREFIX", dir);
- if (CM_NULLPTR !=
- mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
- if (!absoluteDestFiles.empty()) {
- absoluteDestFiles += ";";
- }
- absoluteDestFiles +=
- mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
- cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "Got some ABSOLUTE DESTINATION FILES: "
- << absoluteDestFiles << std::endl);
- // define component specific var
- if (componentInstall) {
- std::string absoluteDestFileComponent =
- std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" +
- GetComponentInstallDirNameSuffix(installComponent);
- if (CM_NULLPTR != this->GetOption(absoluteDestFileComponent)) {
- std::string absoluteDestFilesListComponent =
- this->GetOption(absoluteDestFileComponent);
- absoluteDestFilesListComponent += ";";
- absoluteDestFilesListComponent +=
- mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
- this->SetOption(absoluteDestFileComponent,
- absoluteDestFilesListComponent.c_str());
- } else {
- this->SetOption(
- absoluteDestFileComponent,
- mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
- }
- }
- }
- if (cmSystemTools::GetErrorOccuredFlag() || !res) {
- return 0;
- }
+ cmCPackLogger(
+ cmCPackLog::LOG_DEBUG,
+ "- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf.AddDefinition)"
+ << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'"
+ << std::endl);
+
+ // Make sure that DESTDIR + CPACK_INSTALL_PREFIX directory
+ // exists:
+ //
+ if (cmHasLiteralPrefix(dir, "/")) {
+ dir = tempInstallDirectory + dir;
+ } else {
+ dir = tempInstallDirectory + "/" + dir;
+ }
+ /*
+ * We must re-set DESTDIR for each component
+ * We must not add the CPACK_INSTALL_PREFIX part because
+ * it will be added using the override of CMAKE_INSTALL_PREFIX
+ * The main reason for this awkward trick is that
+ * are using DESTDIR for 2 different reasons:
+ * - Because it was asked by the CPack Generator or the user
+ * using CPACK_SET_DESTDIR
+ * - Because it was already used for component install
+ * in order to put things in subdirs...
+ */
+ cmSystemTools::PutEnv(std::string("DESTDIR=") + tempInstallDirectory);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "- Creating directory: '" << dir << "'" << std::endl);
+
+ if (!cmsys::SystemTools::MakeDirectory(dir, default_dir_mode)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem creating temporary directory: " << dir
+ << std::endl);
+ return 0;
+ }
+ } else {
+ mf.AddDefinition("CMAKE_INSTALL_PREFIX", tempInstallDirectory);
+
+ if (!cmsys::SystemTools::MakeDirectory(tempInstallDirectory,
+ default_dir_mode)) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem creating temporary directory: "
+ << tempInstallDirectory << std::endl);
+ return 0;
+ }
+
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "- Using non-DESTDIR install... (mf.AddDefinition)"
+ << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "- Setting CMAKE_INSTALL_PREFIX to '" << tempInstallDirectory
+ << "'" << std::endl);
+ }
+
+ if (!buildConfig.empty()) {
+ mf.AddDefinition("BUILD_TYPE", buildConfig);
+ }
+ std::string installComponentLowerCase = cmSystemTools::LowerCase(component);
+ if (installComponentLowerCase != "all") {
+ mf.AddDefinition("CMAKE_INSTALL_COMPONENT", component);
+ }
+
+ // strip on TRUE, ON, 1, one or several file names, but not on
+ // FALSE, OFF, 0 and an empty string
+ if (!cmIsOff(this->GetOption("CPACK_STRIP_FILES"))) {
+ mf.AddDefinition("CMAKE_INSTALL_DO_STRIP", "1");
+ }
+ // Remember the list of files before installation
+ // of the current component (if we are in component install)
+ std::string const& InstallPrefix = tempInstallDirectory;
+ std::vector<std::string> filesBefore;
+ std::string findExpr = tempInstallDirectory;
+ if (componentInstall) {
+ cmsys::Glob glB;
+ findExpr += "/*";
+ glB.RecurseOn();
+ glB.SetRecurseListDirs(true);
+ glB.FindFiles(findExpr);
+ filesBefore = glB.GetFiles();
+ std::sort(filesBefore.begin(), filesBefore.end());
+ }
+
+ // If CPack was asked to warn on ABSOLUTE INSTALL DESTINATION
+ // then forward request to cmake_install.cmake script
+ if (this->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION")) {
+ mf.AddDefinition("CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
+ }
+ // If current CPack generator does support
+ // ABSOLUTE INSTALL DESTINATION or CPack has been asked for
+ // then ask cmake_install.cmake script to error out
+ // as soon as it occurs (before installing file)
+ if (!SupportsAbsoluteDestination() ||
+ this->IsOn("CPACK_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION")) {
+ mf.AddDefinition("CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION", "1");
+ }
+ // do installation
+ bool res = mf.ReadListFile(installFile);
+ // forward definition of CMAKE_ABSOLUTE_DESTINATION_FILES
+ // to CPack (may be used by generators like CPack RPM or DEB)
+ // in order to transparently handle ABSOLUTE PATH
+ if (const char* def = mf.GetDefinition("CMAKE_ABSOLUTE_DESTINATION_FILES")) {
+ mf.AddDefinition("CPACK_ABSOLUTE_DESTINATION_FILES", def);
+ }
+
+ // Now rebuild the list of files after installation
+ // of the current component (if we are in component install)
+ if (componentInstall) {
+ cmsys::Glob glA;
+ glA.RecurseOn();
+ glA.SetRecurseListDirs(true);
+ glA.SetRecurseThroughSymlinks(false);
+ glA.FindFiles(findExpr);
+ std::vector<std::string> filesAfter = glA.GetFiles();
+ std::sort(filesAfter.begin(), filesAfter.end());
+ std::vector<std::string>::iterator diff;
+ std::vector<std::string> result(filesAfter.size());
+ diff = std::set_difference(filesAfter.begin(), filesAfter.end(),
+ filesBefore.begin(), filesBefore.end(),
+ result.begin());
+
+ std::vector<std::string>::iterator fit;
+ std::string localFileName;
+ // Populate the File field of each component
+ for (fit = result.begin(); fit != diff; ++fit) {
+ localFileName = cmSystemTools::RelativePath(InstallPrefix, *fit);
+ localFileName =
+ localFileName.substr(localFileName.find_first_not_of('/'));
+ Components[component].Files.push_back(localFileName);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Adding file <" << localFileName << "> to component <"
+ << component << ">" << std::endl);
+ }
+ }
+
+ if (nullptr != mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
+ if (!absoluteDestFiles.empty()) {
+ absoluteDestFiles += ";";
+ }
+ absoluteDestFiles += mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Got some ABSOLUTE DESTINATION FILES: " << absoluteDestFiles
+ << std::endl);
+ // define component specific var
+ if (componentInstall) {
+ std::string absoluteDestFileComponent =
+ std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + "_" +
+ GetComponentInstallDirNameSuffix(component);
+ if (nullptr != this->GetOption(absoluteDestFileComponent)) {
+ std::string absoluteDestFilesListComponent =
+ cmStrCat(this->GetOption(absoluteDestFileComponent), ';',
+ mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
+ this->SetOption(absoluteDestFileComponent,
+ absoluteDestFilesListComponent.c_str());
+ } else {
+ this->SetOption(absoluteDestFileComponent,
+ mf.GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
}
}
}
- this->SetOption("CPACK_ABSOLUTE_DESTINATION_FILES",
- absoluteDestFiles.c_str());
+ if (cmSystemTools::GetErrorOccuredFlag() || !res) {
+ return 0;
+ }
return 1;
}
@@ -865,7 +954,7 @@ bool cmCPackGenerator::ReadListFile(const char* moduleName)
{
bool retval;
std::string fullPath = this->MakefileMap->GetModulesFile(moduleName);
- retval = this->MakefileMap->ReadListFile(fullPath.c_str());
+ retval = this->MakefileMap->ReadListFile(fullPath);
// include FATAL_ERROR and ERROR in the return status
retval = retval && (!cmSystemTools::GetErrorOccuredFlag());
return retval;
@@ -887,16 +976,16 @@ void cmCPackGenerator::SetOption(const std::string& op, const char* value)
this->MakefileMap->RemoveDefinition(op);
return;
}
- cmCPackLogger(cmCPackLog::LOG_DEBUG, this->GetNameOfClass()
- << "::SetOption(" << op << ", " << value << ")"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ this->GetNameOfClass() << "::SetOption(" << op << ", " << value
+ << ")" << std::endl);
this->MakefileMap->AddDefinition(op, value);
}
int cmCPackGenerator::DoPackage()
{
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package using " << this->Name
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "Create package using " << this->Name << std::endl);
// Prepare CPack internal name and check
// values for many CPACK_xxx vars
@@ -909,13 +998,13 @@ int cmCPackGenerator::DoPackage()
return 0;
}
- if (cmSystemTools::IsOn(
- this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY"))) {
+ if (cmIsOn(this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY"))) {
const char* toplevelDirectory =
this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
if (cmSystemTools::FileExists(toplevelDirectory)) {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Remove toplevel directory: "
- << toplevelDirectory << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Remove toplevel directory: " << toplevelDirectory
+ << std::endl);
if (!cmSystemTools::RepeatedRemoveDirectory(toplevelDirectory)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem removing toplevel directory: "
@@ -924,8 +1013,8 @@ int cmCPackGenerator::DoPackage()
}
}
}
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "About to install project "
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "About to install project " << std::endl);
if (!this->InstallProject()) {
return 0;
@@ -938,8 +1027,7 @@ int cmCPackGenerator::DoPackage()
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
cmsys::Glob gl;
- std::string findExpr = tempDirectory;
- findExpr += "/*";
+ std::string findExpr = cmStrCat(tempDirectory, "/*");
gl.RecurseOn();
gl.SetRecurseListDirs(true);
gl.SetRecurseThroughSymlinks(false);
@@ -950,16 +1038,16 @@ int cmCPackGenerator::DoPackage()
}
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package" << std::endl);
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Package files to: "
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Package files to: "
<< (tempPackageFileName ? tempPackageFileName : "(NULL)")
<< std::endl);
if (cmSystemTools::FileExists(tempPackageFileName)) {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Remove old package file"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Remove old package file" << std::endl);
cmSystemTools::RemoveFile(tempPackageFileName);
}
- if (cmSystemTools::IsOn(
- this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) {
+ if (cmIsOn(this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) {
tempDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
}
@@ -972,17 +1060,25 @@ int cmCPackGenerator::DoPackage()
* may update this during PackageFiles.
* (either putting several names or updating the provided one)
*/
- packageFileNames.push_back(tempPackageFileName ? tempPackageFileName : "");
+ packageFileNames.emplace_back(tempPackageFileName ? tempPackageFileName
+ : "");
toplevel = tempDirectory;
- if (!this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory"
- << std::endl);
- return 0;
+ { // scope that enables package generators to run internal scripts with
+ // latest CMake policies enabled
+ cmMakefile::ScopePushPop pp{ this->MakefileMap };
+ this->MakefileMap->SetPolicyVersion(cmVersion::GetCMakeVersion(),
+ std::string());
+
+ if (!this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem compressing the directory" << std::endl);
+ return 0;
+ }
}
/* Prepare checksum algorithm*/
const char* algo = this->GetOption("CPACK_PACKAGE_CHECKSUM");
- CM_AUTO_PTR<cmCryptoHash> crypto = cmCryptoHash::New(algo ? algo : "");
+ std::unique_ptr<cmCryptoHash> crypto = cmCryptoHash::New(algo ? algo : "");
/*
* Copy the generated packages to final destination
@@ -990,46 +1086,49 @@ int cmCPackGenerator::DoPackage()
* - the initially provided name may have changed
* (because the specific generator did 'normalize' it)
*/
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copying final package(s) ["
- << packageFileNames.size() << "]:" << std::endl);
- std::vector<std::string>::iterator it;
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Copying final package(s) [" << packageFileNames.size()
+ << "]:" << std::endl);
/* now copy package one by one */
- for (it = packageFileNames.begin(); it != packageFileNames.end(); ++it) {
+ for (std::string const& pkgFileName : packageFileNames) {
std::string tmpPF(this->GetOption("CPACK_OUTPUT_FILE_PREFIX"));
- std::string filename(cmSystemTools::GetFilenameName(*it));
- tempPackageFileName = it->c_str();
+ std::string filename(cmSystemTools::GetFilenameName(pkgFileName));
+ tempPackageFileName = pkgFileName.c_str();
tmpPF += "/" + filename;
const char* packageFileName = tmpPF.c_str();
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy final package(s): "
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Copy final package(s): "
<< (tempPackageFileName ? tempPackageFileName : "(NULL)")
<< " to " << (packageFileName ? packageFileName : "(NULL)")
<< std::endl);
- if (!cmSystemTools::CopyFileIfDifferent(tempPackageFileName,
- packageFileName)) {
+ if (!cmSystemTools::CopyFileIfDifferent(pkgFileName, tmpPF)) {
cmCPackLogger(
- cmCPackLog::LOG_ERROR, "Problem copying the package: "
+ cmCPackLog::LOG_ERROR,
+ "Problem copying the package: "
<< (tempPackageFileName ? tempPackageFileName : "(NULL)") << " to "
<< (packageFileName ? packageFileName : "(NULL)") << std::endl);
return 0;
}
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- package: "
- << packageFileName << " generated." << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "- package: " << packageFileName << " generated."
+ << std::endl);
/* Generate checksum file */
- if (crypto.get() != CM_NULLPTR) {
+ if (crypto) {
std::string hashFile(this->GetOption("CPACK_OUTPUT_FILE_PREFIX"));
- hashFile +=
- "/" + filename.substr(0, filename.rfind(this->GetOutputExtension()));
+ hashFile += "/" + filename;
hashFile += "." + cmSystemTools::LowerCase(algo);
cmsys::ofstream outF(hashFile.c_str());
if (!outF) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create checksum file: "
- << hashFile << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot create checksum file: " << hashFile
+ << std::endl);
return 0;
}
outF << crypto->HashFile(packageFileName) << " " << filename << "\n";
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- checksum file: "
- << hashFile << " generated." << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "- checksum file: " << hashFile << " generated."
+ << std::endl);
}
}
@@ -1072,14 +1171,14 @@ bool cmCPackGenerator::IsSet(const std::string& name) const
bool cmCPackGenerator::IsOn(const std::string& name) const
{
- return cmSystemTools::IsOn(GetOption(name));
+ return cmIsOn(GetOption(name));
}
bool cmCPackGenerator::IsSetToOff(const std::string& op) const
{
const char* ret = this->MakefileMap->GetDefinition(op);
if (ret && *ret) {
- return cmSystemTools::IsOff(ret);
+ return cmIsOff(ret);
}
return false;
}
@@ -1124,8 +1223,7 @@ const char* cmCPackGenerator::GetInstallPath()
if (cmsys::SystemTools::GetEnv("ProgramFiles", prgfiles)) {
this->InstallPath = prgfiles;
} else if (cmsys::SystemTools::GetEnv("SystemDrive", sysDrive)) {
- this->InstallPath = sysDrive;
- this->InstallPath += "/Program Files";
+ this->InstallPath = cmStrCat(sysDrive, "/Program Files");
} else {
this->InstallPath = "c:/Program Files";
}
@@ -1149,7 +1247,8 @@ const char* cmCPackGenerator::GetInstallPath()
const char* cmCPackGenerator::GetPackagingInstallPrefix()
{
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "GetPackagingInstallPrefix: '"
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "GetPackagingInstallPrefix: '"
<< this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX") << "'"
<< std::endl);
@@ -1158,11 +1257,22 @@ const char* cmCPackGenerator::GetPackagingInstallPrefix()
std::string cmCPackGenerator::FindTemplate(const char* name)
{
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for template: "
- << (name ? name : "(NULL)") << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Look for template: " << (name ? name : "(NULL)")
+ << std::endl);
+ // Search CMAKE_MODULE_PATH for a custom template.
std::string ffile = this->MakefileMap->GetModulesFile(name);
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: " << ffile
- << std::endl);
+ if (ffile.empty()) {
+ // Fall back to our internal builtin default.
+ ffile = cmStrCat(cmSystemTools::GetCMakeRoot(), "/Modules/Internal/CPack/",
+ name);
+ cmSystemTools::ConvertToUnixSlashes(ffile);
+ if (!cmSystemTools::FileExists(ffile)) {
+ ffile.clear();
+ }
+ }
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Found template: " << ffile << std::endl);
return ffile;
}
@@ -1173,7 +1283,8 @@ bool cmCPackGenerator::ConfigureString(const std::string& inString,
return true;
}
-bool cmCPackGenerator::ConfigureFile(const char* inName, const char* outName,
+bool cmCPackGenerator::ConfigureFile(const std::string& inName,
+ const std::string& outName,
bool copyOnly /* = false */)
{
return this->MakefileMap->ConfigureFile(inName, outName, copyOnly, true,
@@ -1182,9 +1293,8 @@ bool cmCPackGenerator::ConfigureFile(const char* inName, const char* outName,
int cmCPackGenerator::CleanTemporaryDirectory()
{
- std::string tempInstallDirectoryWithPostfix =
+ std::string tempInstallDirectory =
this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
- const char* tempInstallDirectory = tempInstallDirectoryWithPostfix.c_str();
if (cmsys::SystemTools::FileExists(tempInstallDirectory)) {
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"- Clean temporary : " << tempInstallDirectory << std::endl);
@@ -1225,15 +1335,15 @@ int cmCPackGenerator::PrepareGroupingKind()
std::string groupingType;
// Second way to specify grouping
- if (CM_NULLPTR != this->GetOption("CPACK_COMPONENTS_GROUPING")) {
+ if (nullptr != this->GetOption("CPACK_COMPONENTS_GROUPING")) {
groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING");
}
if (!groupingType.empty()) {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
- << this->Name << "]"
- << " requested component grouping = " << groupingType
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "[" << this->Name << "]"
+ << " requested component grouping = " << groupingType
+ << std::endl);
if (groupingType == "ALL_COMPONENTS_IN_ONE") {
method = ONE_PACKAGE;
} else if (groupingType == "IGNORE") {
@@ -1242,11 +1352,11 @@ int cmCPackGenerator::PrepareGroupingKind()
method = ONE_PACKAGE_PER_GROUP;
} else {
cmCPackLogger(
- cmCPackLog::LOG_WARNING, "["
- << this->Name << "]"
- << " requested component grouping type <" << groupingType
- << "> UNKNOWN not in (ALL_COMPONENTS_IN_ONE,IGNORE,ONE_PER_GROUP)"
- << std::endl);
+ cmCPackLog::LOG_WARNING,
+ "[" << this->Name << "]"
+ << " requested component grouping type <" << groupingType
+ << "> UNKNOWN not in (ALL_COMPONENTS_IN_ONE,IGNORE,ONE_PER_GROUP)"
+ << std::endl);
}
}
@@ -1260,11 +1370,11 @@ int cmCPackGenerator::PrepareGroupingKind()
method = ONE_PACKAGE_PER_COMPONENT;
}
cmCPackLogger(
- cmCPackLog::LOG_WARNING, "["
- << this->Name << "]"
- << " One package per component group requested, "
- << "but NO component groups exist: Ignoring component group."
- << std::endl);
+ cmCPackLog::LOG_WARNING,
+ "[" << this->Name << "]"
+ << " One package per component group requested, "
+ << "but NO component groups exist: Ignoring component group."
+ << std::endl);
}
// if user specified packaging method, override the default packaging method
@@ -1275,10 +1385,10 @@ int cmCPackGenerator::PrepareGroupingKind()
const char* method_names[] = { "ALL_COMPONENTS_IN_ONE", "IGNORE_GROUPS",
"ONE_PER_GROUP" };
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
- << this->Name << "]"
- << " requested component grouping = "
- << method_names[componentPackageMethod] << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "[" << this->Name << "]"
+ << " requested component grouping = "
+ << method_names[componentPackageMethod] << std::endl);
return 1;
}
@@ -1341,7 +1451,8 @@ bool cmCPackGenerator::SupportsComponentInstallation() const
bool cmCPackGenerator::WantsComponentInstallation() const
{
- return (!IsOn("CPACK_MONOLITHIC_INSTALL") && SupportsComponentInstallation()
+ return (!IsOn("CPACK_MONOLITHIC_INSTALL") &&
+ SupportsComponentInstallation()
// check that we have at least one group or component
&& (!this->ComponentGroups.empty() || !this->Components.empty()));
}
@@ -1390,7 +1501,7 @@ cmCPackComponent* cmCPackGenerator::GetComponent(
component->IsRequired = this->IsOn(macroPrefix + "_REQUIRED");
component->IsDisabledByDefault = this->IsOn(macroPrefix + "_DISABLED");
component->IsDownloaded = this->IsOn(macroPrefix + "_DOWNLOADED") ||
- cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL"));
+ cmIsOn(this->GetOption("CPACK_DOWNLOAD_ALL"));
const char* archiveFile = this->GetOption(macroPrefix + "_ARCHIVE_FILE");
if (archiveFile && *archiveFile) {
@@ -1407,7 +1518,7 @@ cmCPackComponent* cmCPackGenerator::GetComponent(
component->Group = GetComponentGroup(projectName, groupName);
component->Group->Components.push_back(component);
} else {
- component->Group = CM_NULLPTR;
+ component->Group = nullptr;
}
const char* description = this->GetOption(macroPrefix + "_DESCRIPTION");
@@ -1418,25 +1529,20 @@ cmCPackComponent* cmCPackGenerator::GetComponent(
// Determine the installation types.
const char* installTypes = this->GetOption(macroPrefix + "_INSTALL_TYPES");
if (installTypes && *installTypes) {
- std::vector<std::string> installTypesVector;
- cmSystemTools::ExpandListArgument(installTypes, installTypesVector);
- std::vector<std::string>::iterator installTypesIt;
- for (installTypesIt = installTypesVector.begin();
- installTypesIt != installTypesVector.end(); ++installTypesIt) {
+ std::vector<std::string> installTypesVector =
+ cmExpandedList(installTypes);
+ for (std::string const& installType : installTypesVector) {
component->InstallationTypes.push_back(
- this->GetInstallationType(projectName, *installTypesIt));
+ this->GetInstallationType(projectName, installType));
}
}
// Determine the component dependencies.
const char* depends = this->GetOption(macroPrefix + "_DEPENDS");
if (depends && *depends) {
- std::vector<std::string> dependsVector;
- cmSystemTools::ExpandListArgument(depends, dependsVector);
- std::vector<std::string>::iterator dependIt;
- for (dependIt = dependsVector.begin(); dependIt != dependsVector.end();
- ++dependIt) {
- cmCPackComponent* child = GetComponent(projectName, *dependIt);
+ std::vector<std::string> dependsVector = cmExpandedList(depends);
+ for (std::string const& depend : dependsVector) {
+ cmCPackComponent* child = GetComponent(projectName, depend);
component->Dependencies.push_back(child);
child->ReverseDependencies.push_back(component);
}
@@ -1475,7 +1581,7 @@ cmCPackComponentGroup* cmCPackGenerator::GetComponentGroup(
group->ParentGroup = GetComponentGroup(projectName, parentGroupName);
group->ParentGroup->Subgroups.push_back(group);
} else {
- group->ParentGroup = CM_NULLPTR;
+ group->ParentGroup = nullptr;
}
}
return group;
diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h
index 45777fa05..33026c1d9 100644
--- a/Source/CPack/cmCPackGenerator.h
+++ b/Source/CPack/cmCPackGenerator.h
@@ -3,17 +3,20 @@
#ifndef cmCPackGenerator_h
#define cmCPackGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
#include <sstream>
#include <string>
#include <vector>
+#include "cm_sys_stat.h"
+
#include "cmCPackComponentGroup.h"
#include "cmSystemTools.h"
class cmCPackLog;
+class cmGlobalGenerator;
class cmInstalledFile;
class cmMakefile;
@@ -35,6 +38,16 @@ public:
}
/**
+ * Put underlying cmake scripts in trace mode.
+ */
+ void SetTrace(bool val) { this->Trace = val; }
+
+ /**
+ * Put underlying cmake scripts in expanded trace mode.
+ */
+ void SetTraceExpand(bool val) { this->TraceExpand = val; }
+
+ /**
* Returns true if the generator may work on this system.
* Rational:
* Some CPack generator may run on some host and may not on others
@@ -84,7 +97,7 @@ public:
void SetLogger(cmCPackLog* log) { this->Logger = log; }
//! Display verbose information via logger
- void DisplayVerboseOutput(const char* msg, float progress);
+ void DisplayVerboseOutput(const std::string& msg, float progress);
bool ReadListFile(const char* moduleName);
@@ -105,7 +118,7 @@ protected:
cmInstalledFile const* GetInstalledFile(std::string const& name) const;
virtual const char* GetOutputExtension() { return ".cpack"; }
- virtual const char* GetOutputPostfix() { return CM_NULLPTR; }
+ virtual const char* GetOutputPostfix() { return nullptr; }
/**
* Prepare requested grouping kind from CPACK_xxx vars
@@ -157,7 +170,8 @@ protected:
virtual const char* GetPackagingInstallPrefix();
virtual std::string FindTemplate(const char* name);
- virtual bool ConfigureFile(const char* inName, const char* outName,
+ virtual bool ConfigureFile(const std::string& inName,
+ const std::string& outName,
bool copyOnly = false);
virtual bool ConfigureString(const std::string& input, std::string& output);
virtual int InitializeInternal();
@@ -168,9 +182,22 @@ protected:
virtual int InstallProjectViaInstallScript(
bool setDestDir, const std::string& tempInstallDirectory);
virtual int InstallProjectViaInstalledDirectories(
- bool setDestDir, const std::string& tempInstallDirectory);
+ bool setDestDir, const std::string& tempInstallDirectory,
+ const mode_t* default_dir_mode);
virtual int InstallProjectViaInstallCMakeProjects(
- bool setDestDir, const std::string& tempInstallDirectory);
+ bool setDestDir, const std::string& tempInstallDirectory,
+ const mode_t* default_dir_mode);
+
+ virtual int RunPreinstallTarget(const std::string& installProjectName,
+ const std::string& installDirectory,
+ cmGlobalGenerator* globalGenerator,
+ const std::string& buildConfig);
+ virtual int InstallCMakeProject(
+ bool setDestDir, const std::string& installDirectory,
+ const std::string& baseTempInstallDirectory,
+ const mode_t* default_dir_mode, const std::string& component,
+ bool componentInstall, const std::string& installSubDirectory,
+ const std::string& buildConfig, std::string& absoluteDestFiles);
/**
* The various level of support of
@@ -258,6 +285,7 @@ protected:
*/
std::vector<std::string> files;
+ std::vector<cmCPackInstallCMakeProject> CMakeProjects;
std::map<std::string, cmCPackInstallationType> InstallationTypes;
/**
* The set of components.
@@ -292,14 +320,15 @@ protected:
ComponentPackageMethod componentPackageMethod;
cmCPackLog* Logger;
+ bool Trace;
+ bool TraceExpand;
-private:
cmMakefile* MakefileMap;
};
#define cmCPackTypeMacro(klass, superclass) \
- typedef superclass Superclass; \
- const char* GetNameOfClass() CM_OVERRIDE { return #klass; } \
+ using Superclass = superclass; \
+ const char* GetNameOfClass() override { return #klass; } \
static cmCPackGenerator* CreateGenerator() { return new klass; } \
class cmCPackTypeMacro_UseTrailingSemicolon
diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx
index 31f48c7e3..79e344be7 100644
--- a/Source/CPack/cmCPackGeneratorFactory.cxx
+++ b/Source/CPack/cmCPackGeneratorFactory.cxx
@@ -2,55 +2,61 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackGeneratorFactory.h"
-#include "cmConfigure.h"
#include <ostream>
#include <utility>
#include "IFW/cmCPackIFWGenerator.h"
-#include "cmAlgorithms.h"
-#include "cmCPack7zGenerator.h"
+#ifdef HAVE_FREEBSD_PKG
+# include "cmCPackFreeBSDGenerator.h"
+#endif
+#include "cmCPackArchiveGenerator.h"
+#include "cmCPackDebGenerator.h"
+#include "cmCPackExternalGenerator.h"
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
#include "cmCPackNSISGenerator.h"
+#include "cmCPackNuGetGenerator.h"
#include "cmCPackSTGZGenerator.h"
-#include "cmCPackTGZGenerator.h"
-#include "cmCPackTXZGenerator.h"
-#include "cmCPackTarBZip2Generator.h"
-#include "cmCPackTarCompressGenerator.h"
-#include "cmCPackZIPGenerator.h"
#ifdef __APPLE__
-#include "cmCPackBundleGenerator.h"
-#include "cmCPackDragNDropGenerator.h"
-#include "cmCPackOSXX11Generator.h"
-#include "cmCPackPackageMakerGenerator.h"
-#include "cmCPackProductBuildGenerator.h"
+# include "cmCPackBundleGenerator.h"
+# include "cmCPackDragNDropGenerator.h"
+# include "cmCPackOSXX11Generator.h"
+# include "cmCPackPackageMakerGenerator.h"
+# include "cmCPackProductBuildGenerator.h"
#endif
#ifdef __CYGWIN__
-#include "cmCPackCygwinBinaryGenerator.h"
-#include "cmCPackCygwinSourceGenerator.h"
+# include "cmCPackCygwinBinaryGenerator.h"
+# include "cmCPackCygwinSourceGenerator.h"
#endif
#if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \
!defined(__HAIKU__)
-#include "cmCPackDebGenerator.h"
-#include "cmCPackRPMGenerator.h"
+# include "cmCPackRPMGenerator.h"
#endif
-#ifdef _WIN32
-#include "WiX/cmCPackWIXGenerator.h"
+#if defined(_WIN32) || (defined(__CYGWIN__) && defined(HAVE_LIBUUID))
+# include "WiX/cmCPackWIXGenerator.h"
#endif
cmCPackGeneratorFactory::cmCPackGeneratorFactory()
{
- if (cmCPackTGZGenerator::CanGenerate()) {
+ if (cmCPackArchiveGenerator::CanGenerate()) {
+ this->RegisterGenerator("7Z", "7-Zip file format",
+ cmCPackArchiveGenerator::Create7ZGenerator);
+ this->RegisterGenerator("TBZ2", "Tar BZip2 compression",
+ cmCPackArchiveGenerator::CreateTBZ2Generator);
this->RegisterGenerator("TGZ", "Tar GZip compression",
- cmCPackTGZGenerator::CreateGenerator);
- }
- if (cmCPackTXZGenerator::CanGenerate()) {
+ cmCPackArchiveGenerator::CreateTGZGenerator);
this->RegisterGenerator("TXZ", "Tar XZ compression",
- cmCPackTXZGenerator::CreateGenerator);
+ cmCPackArchiveGenerator::CreateTXZGenerator);
+ this->RegisterGenerator("TZ", "Tar Compress compression",
+ cmCPackArchiveGenerator::CreateTZGenerator);
+ this->RegisterGenerator("TZST", "Tar Zstandard compression",
+ cmCPackArchiveGenerator::CreateTZSTGenerator);
+ this->RegisterGenerator("ZIP", "ZIP file format",
+ cmCPackArchiveGenerator::CreateZIPGenerator);
}
if (cmCPackSTGZGenerator::CanGenerate()) {
this->RegisterGenerator("STGZ", "Self extracting Tar GZip compression",
@@ -76,28 +82,23 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory()
cmCPackCygwinSourceGenerator::CreateGenerator);
}
#endif
-
- if (cmCPackZIPGenerator::CanGenerate()) {
- this->RegisterGenerator("ZIP", "ZIP file format",
- cmCPackZIPGenerator::CreateGenerator);
- }
- if (cmCPack7zGenerator::CanGenerate()) {
- this->RegisterGenerator("7Z", "7-Zip file format",
- cmCPack7zGenerator::CreateGenerator);
- }
-#ifdef _WIN32
+#if defined(_WIN32) || (defined(__CYGWIN__) && defined(HAVE_LIBUUID))
if (cmCPackWIXGenerator::CanGenerate()) {
this->RegisterGenerator("WIX", "MSI file format via WiX tools",
cmCPackWIXGenerator::CreateGenerator);
}
#endif
- if (cmCPackTarBZip2Generator::CanGenerate()) {
- this->RegisterGenerator("TBZ2", "Tar BZip2 compression",
- cmCPackTarBZip2Generator::CreateGenerator);
+ if (cmCPackDebGenerator::CanGenerate()) {
+ this->RegisterGenerator("DEB", "Debian packages",
+ cmCPackDebGenerator::CreateGenerator);
}
- if (cmCPackTarCompressGenerator::CanGenerate()) {
- this->RegisterGenerator("TZ", "Tar Compress compression",
- cmCPackTarCompressGenerator::CreateGenerator);
+ if (cmCPackNuGetGenerator::CanGenerate()) {
+ this->RegisterGenerator("NuGet", "NuGet packages",
+ cmCPackNuGetGenerator::CreateGenerator);
+ }
+ if (cmCPackExternalGenerator::CanGenerate()) {
+ this->RegisterGenerator("External", "CPack External packages",
+ cmCPackExternalGenerator::CreateGenerator);
}
#ifdef __APPLE__
if (cmCPackDragNDropGenerator::CanGenerate()) {
@@ -123,45 +124,34 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory()
#endif
#if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \
!defined(__HAIKU__)
- if (cmCPackDebGenerator::CanGenerate()) {
- this->RegisterGenerator("DEB", "Debian packages",
- cmCPackDebGenerator::CreateGenerator);
- }
if (cmCPackRPMGenerator::CanGenerate()) {
this->RegisterGenerator("RPM", "RPM packages",
cmCPackRPMGenerator::CreateGenerator);
}
#endif
+#ifdef HAVE_FREEBSD_PKG
+ if (cmCPackFreeBSDGenerator::CanGenerate()) {
+ this->RegisterGenerator("FREEBSD", "FreeBSD pkg(8) packages",
+ cmCPackFreeBSDGenerator::CreateGenerator);
+ }
+#endif
}
-cmCPackGeneratorFactory::~cmCPackGeneratorFactory()
-{
- cmDeleteAll(this->Generators);
-}
-
-cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(
+std::unique_ptr<cmCPackGenerator> cmCPackGeneratorFactory::NewGenerator(
const std::string& name)
{
- cmCPackGenerator* gen = this->NewGeneratorInternal(name);
+ auto it = this->GeneratorCreators.find(name);
+ if (it == this->GeneratorCreators.end()) {
+ return nullptr;
+ }
+ std::unique_ptr<cmCPackGenerator> gen(it->second());
if (!gen) {
- return CM_NULLPTR;
+ return nullptr;
}
- this->Generators.push_back(gen);
gen->SetLogger(this->Logger);
return gen;
}
-cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal(
- const std::string& name)
-{
- cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it =
- this->GeneratorCreators.find(name);
- if (it == this->GeneratorCreators.end()) {
- return CM_NULLPTR;
- }
- return (it->second)();
-}
-
void cmCPackGeneratorFactory::RegisterGenerator(
const std::string& name, const char* generatorDescription,
CreateGeneratorCall* createGenerator)
diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h
index 7f633e473..62b748423 100644
--- a/Source/CPack/cmCPackGeneratorFactory.h
+++ b/Source/CPack/cmCPackGeneratorFactory.h
@@ -6,8 +6,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
+#include <memory>
#include <string>
-#include <vector>
class cmCPackGenerator;
class cmCPackLog;
@@ -20,13 +20,11 @@ class cmCPackGeneratorFactory
{
public:
cmCPackGeneratorFactory();
- ~cmCPackGeneratorFactory();
//! Get the generator
- cmCPackGenerator* NewGenerator(const std::string& name);
- void DeleteGenerator(cmCPackGenerator* gen);
+ std::unique_ptr<cmCPackGenerator> NewGenerator(const std::string& name);
- typedef cmCPackGenerator* CreateGeneratorCall();
+ using CreateGeneratorCall = cmCPackGenerator*();
void RegisterGenerator(const std::string& name,
const char* generatorDescription,
@@ -34,17 +32,14 @@ public:
void SetLogger(cmCPackLog* logger) { this->Logger = logger; }
- typedef std::map<std::string, std::string> DescriptionsMap;
+ using DescriptionsMap = std::map<std::string, std::string>;
const DescriptionsMap& GetGeneratorsList() const
{
return this->GeneratorDescriptions;
}
private:
- cmCPackGenerator* NewGeneratorInternal(const std::string& name);
- std::vector<cmCPackGenerator*> Generators;
-
- typedef std::map<std::string, CreateGeneratorCall*> t_GeneratorCreatorsMap;
+ using t_GeneratorCreatorsMap = std::map<std::string, CreateGeneratorCall*>;
t_GeneratorCreatorsMap GeneratorCreators;
DescriptionsMap GeneratorDescriptions;
cmCPackLog* Logger;
diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx
index 5c7123959..ca675fdc8 100644
--- a/Source/CPack/cmCPackLog.cxx
+++ b/Source/CPack/cmCPackLog.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackLog.h"
-#include "cmConfigure.h"
#include <iostream>
#include "cmGeneratedFileStream.h"
@@ -19,13 +18,13 @@ cmCPackLog::cmCPackLog()
this->DefaultOutput = &std::cout;
this->DefaultError = &std::cerr;
- this->LogOutput = CM_NULLPTR;
+ this->LogOutput = nullptr;
this->LogOutputCleanup = false;
}
cmCPackLog::~cmCPackLog()
{
- this->SetLogOutputStream(CM_NULLPTR);
+ this->SetLogOutputStream(nullptr);
}
void cmCPackLog::SetLogOutputStream(std::ostream* os)
@@ -39,13 +38,13 @@ void cmCPackLog::SetLogOutputStream(std::ostream* os)
bool cmCPackLog::SetLogOutputFile(const char* fname)
{
- cmGeneratedFileStream* cg = CM_NULLPTR;
+ cmGeneratedFileStream* cg = nullptr;
if (fname) {
cg = new cmGeneratedFileStream(fname);
}
if (cg && !*cg) {
delete cg;
- cg = CM_NULLPTR;
+ cg = nullptr;
}
this->SetLogOutputStream(cg);
if (!cg) {
@@ -84,7 +83,7 @@ void cmCPackLog::Log(int tag, const char* file, int line, const char* msg,
if (!tagString.empty()) {
tagString += ",";
}
- tagString = "VERBOSE";
+ tagString += "VERBOSE";
}
}
if (tag & LOG_WARNING) {
@@ -94,7 +93,7 @@ void cmCPackLog::Log(int tag, const char* file, int line, const char* msg,
if (!tagString.empty()) {
tagString += ",";
}
- tagString = "WARNING";
+ tagString += "WARNING";
}
}
if (tag & LOG_ERROR) {
@@ -104,7 +103,7 @@ void cmCPackLog::Log(int tag, const char* file, int line, const char* msg,
if (!tagString.empty()) {
tagString += ",";
}
- tagString = "ERROR";
+ tagString += "ERROR";
}
}
if (tag & LOG_DEBUG && this->Debug) {
@@ -114,7 +113,7 @@ void cmCPackLog::Log(int tag, const char* file, int line, const char* msg,
if (!tagString.empty()) {
tagString += ",";
}
- tagString = "DEBUG";
+ tagString += "DEBUG";
}
useFileAndLine = true;
}
@@ -125,7 +124,7 @@ void cmCPackLog::Log(int tag, const char* file, int line, const char* msg,
if (!tagString.empty()) {
tagString += ",";
}
- tagString = "VERBOSE";
+ tagString += "VERBOSE";
}
}
if (this->Quiet) {
diff --git a/Source/CPack/cmCPackLog.h b/Source/CPack/cmCPackLog.h
index 10deda450..1cb16433c 100644
--- a/Source/CPack/cmCPackLog.h
+++ b/Source/CPack/cmCPackLog.h
@@ -6,9 +6,10 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <ostream>
-#include <string.h>
#include <string>
+#include <string.h>
+
#define cmCPack_Log(ctSelf, logType, msg) \
do { \
std::ostringstream cmCPackLog_msg; \
@@ -26,6 +27,9 @@ public:
cmCPackLog();
~cmCPackLog();
+ cmCPackLog(const cmCPackLog&) = delete;
+ cmCPackLog& operator=(const cmCPackLog&) = delete;
+
enum __log_tags
{
NOTAG = 0,
@@ -84,7 +88,7 @@ public:
bool SetLogOutputFile(const char* fname);
//! Set the various prefixes for the logging. SetPrefix sets the generic
- // prefix that overwrittes missing ones.
+ // prefix that overwrites missing ones.
void SetPrefix(std::string const& pfx) { this->Prefix = pfx; }
void SetOutputPrefix(std::string const& pfx) { this->OutputPrefix = pfx; }
void SetVerbosePrefix(std::string const& pfx) { this->VerbosePrefix = pfx; }
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index 9697a3832..9bf72dfb8 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -2,26 +2,30 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackNSISGenerator.h"
+#include <algorithm>
+#include <cstdlib>
+#include <cstring>
+#include <map>
+#include <sstream>
+#include <utility>
+
+#include "cmsys/Directory.hxx"
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmAlgorithms.h"
#include "cmCPackComponentGroup.h"
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
+#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmsys/Directory.hxx"
-#include "cmsys/RegularExpression.hxx"
-#include <algorithm>
-#include <map>
-#include <sstream>
-#include <stdlib.h>
-#include <string.h>
-#include <utility>
-
/* NSIS uses different command line syntax on Windows and others */
#ifdef _WIN32
-#define NSIS_OPT "/"
+# define NSIS_OPT "/"
#else
-#define NSIS_OPT "-"
+# define NSIS_OPT "-"
#endif
cmCPackNSISGenerator::cmCPackNSISGenerator(bool nsis64)
@@ -29,9 +33,7 @@ cmCPackNSISGenerator::cmCPackNSISGenerator(bool nsis64)
Nsis64 = nsis64;
}
-cmCPackNSISGenerator::~cmCPackNSISGenerator()
-{
-}
+cmCPackNSISGenerator::~cmCPackNSISGenerator() = default;
int cmCPackNSISGenerator::PackageFiles()
{
@@ -54,16 +56,13 @@ int cmCPackNSISGenerator::PackageFiles()
}
std::string nsisFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- std::string tmpFile = nsisFileName;
- tmpFile += "/NSISOutput.log";
+ std::string tmpFile = cmStrCat(nsisFileName, "/NSISOutput.log");
std::string nsisInstallOptions = nsisFileName + "/NSIS.InstallOptions.ini";
nsisFileName += "/project.nsi";
std::ostringstream str;
- std::vector<std::string>::const_iterator it;
- for (it = files.begin(); it != files.end(); ++it) {
+ for (std::string const& file : files) {
std::string outputDir = "$INSTDIR";
- std::string fileN =
- cmSystemTools::RelativePath(toplevel.c_str(), it->c_str());
+ std::string fileN = cmSystemTools::RelativePath(toplevel, file);
if (!this->Components.empty()) {
const std::string::size_type pos = fileN.find('/');
@@ -82,17 +81,15 @@ int cmCPackNSISGenerator::PackageFiles()
str << " Delete \"" << outputDir << "\\" << fileN << "\"" << std::endl;
}
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: " << str.str()
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Uninstall Files: " << str.str() << std::endl);
this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str());
std::vector<std::string> dirs;
this->GetListOfSubdirectories(toplevel.c_str(), dirs);
- std::vector<std::string>::const_iterator sit;
std::ostringstream dstr;
- for (sit = dirs.begin(); sit != dirs.end(); ++sit) {
+ for (std::string const& dir : dirs) {
std::string componentName;
- std::string fileN =
- cmSystemTools::RelativePath(toplevel.c_str(), sit->c_str());
+ std::string fileN = cmSystemTools::RelativePath(toplevel, dir);
if (fileN.empty()) {
continue;
}
@@ -117,15 +114,16 @@ int cmCPackNSISGenerator::PackageFiles()
dstr << " RMDir \"" << componentOutputDir << "\\" << fileN << "\""
<< std::endl;
if (!componentName.empty()) {
- this->Components[componentName].Directories.push_back(fileN);
+ this->Components[componentName].Directories.push_back(std::move(fileN));
}
}
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " << dstr.str()
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Uninstall Dirs: " << dstr.str() << std::endl);
this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str());
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
- << nsisInFileName << " to " << nsisFileName << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Configure file: " << nsisInFileName << " to " << nsisFileName
+ << std::endl);
if (this->IsSet("CPACK_NSIS_MUI_ICON") ||
this->IsSet("CPACK_NSIS_MUI_UNIICON")) {
std::string installerIconCode;
@@ -143,39 +141,34 @@ int cmCPackNSISGenerator::PackageFiles()
installerIconCode.c_str());
}
if (this->IsSet("CPACK_PACKAGE_ICON")) {
- std::string installerIconCode = "!define MUI_HEADERIMAGE_BITMAP \"";
- installerIconCode += this->GetOption("CPACK_PACKAGE_ICON");
- installerIconCode += "\"\n";
+ std::string installerIconCode =
+ cmStrCat("!define MUI_HEADERIMAGE_BITMAP \"",
+ this->GetOption("CPACK_PACKAGE_ICON"), "\"\n");
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_ICON_CODE",
installerIconCode.c_str());
}
if (this->IsSet("CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP")) {
- std::string installerBitmapCode =
- "!define MUI_WELCOMEFINISHPAGE_BITMAP \"";
- installerBitmapCode +=
- this->GetOption("CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP");
- installerBitmapCode += "\"\n";
+ std::string installerBitmapCode = cmStrCat(
+ "!define MUI_WELCOMEFINISHPAGE_BITMAP \"",
+ this->GetOption("CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP"), "\"\n");
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_WELCOMEFINISH_CODE",
installerBitmapCode.c_str());
}
if (this->IsSet("CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP")) {
- std::string installerBitmapCode =
- "!define MUI_UNWELCOMEFINISHPAGE_BITMAP \"";
- installerBitmapCode +=
- this->GetOption("CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP");
- installerBitmapCode += "\"\n";
+ std::string installerBitmapCode = cmStrCat(
+ "!define MUI_UNWELCOMEFINISHPAGE_BITMAP \"",
+ this->GetOption("CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP"), "\"\n");
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_UNWELCOMEFINISH_CODE",
installerBitmapCode.c_str());
}
if (this->IsSet("CPACK_NSIS_MUI_FINISHPAGE_RUN")) {
- std::string installerRunCode = "!define MUI_FINISHPAGE_RUN \"$INSTDIR\\";
- installerRunCode += this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY");
- installerRunCode += "\\";
- installerRunCode += this->GetOption("CPACK_NSIS_MUI_FINISHPAGE_RUN");
- installerRunCode += "\"\n";
+ std::string installerRunCode =
+ cmStrCat("!define MUI_FINISHPAGE_RUN \"$INSTDIR\\",
+ this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY"), '\\',
+ this->GetOption("CPACK_NSIS_MUI_FINISHPAGE_RUN"), "\"\n");
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE",
installerRunCode.c_str());
}
@@ -186,7 +179,7 @@ int cmCPackNSISGenerator::PackageFiles()
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC", "");
this->SetOptionIfNotSet("CPACK_NSIS_PAGE_COMPONENTS", "");
this->SetOptionIfNotSet("CPACK_NSIS_FULL_INSTALL",
- "File /r \"${INST_DIR}\\*.*\"");
+ R"(File /r "${INST_DIR}\*.*")");
this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTIONS", "");
this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTION_LIST", "");
this->SetOptionIfNotSet("CPACK_NSIS_SECTION_SELECTED_VARS", "");
@@ -205,65 +198,59 @@ int cmCPackNSISGenerator::PackageFiles()
// in a vector based on the indices, and print them in that order.
std::vector<cmCPackInstallationType*> installTypes(
this->InstallationTypes.size());
- std::map<std::string, cmCPackInstallationType>::iterator installTypeIt;
- for (installTypeIt = this->InstallationTypes.begin();
- installTypeIt != this->InstallationTypes.end(); ++installTypeIt) {
- installTypes[installTypeIt->second.Index - 1] = &installTypeIt->second;
- }
- std::vector<cmCPackInstallationType*>::iterator installTypeIt2;
- for (installTypeIt2 = installTypes.begin();
- installTypeIt2 != installTypes.end(); ++installTypeIt2) {
+ for (auto& installType : this->InstallationTypes) {
+ installTypes[installType.second.Index - 1] = &installType.second;
+ }
+ for (cmCPackInstallationType* installType : installTypes) {
installTypesCode += "InstType \"";
- installTypesCode += (*installTypeIt2)->DisplayName;
+ installTypesCode += installType->DisplayName;
installTypesCode += "\"\n";
}
// Create installation groups first
- std::map<std::string, cmCPackComponentGroup>::iterator groupIt;
- for (groupIt = this->ComponentGroups.begin();
- groupIt != this->ComponentGroups.end(); ++groupIt) {
- if (groupIt->second.ParentGroup == CM_NULLPTR) {
+ for (auto& group : this->ComponentGroups) {
+ if (group.second.ParentGroup == nullptr) {
componentCode +=
- this->CreateComponentGroupDescription(&groupIt->second, macrosOut);
+ this->CreateComponentGroupDescription(&group.second, macrosOut);
}
// Add the group description, if any.
- if (!groupIt->second.Description.empty()) {
+ if (!group.second.Description.empty()) {
groupDescriptions += " !insertmacro MUI_DESCRIPTION_TEXT ${" +
- groupIt->first + "} \"" +
- this->TranslateNewlines(groupIt->second.Description) + "\"\n";
+ group.first + "} \"" +
+ cmCPackNSISGenerator::TranslateNewlines(group.second.Description) +
+ "\"\n";
}
}
// Create the remaining components, which aren't associated with groups.
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
- if (compIt->second.Files.empty()) {
+ for (auto& comp : this->Components) {
+ if (comp.second.Files.empty()) {
// NSIS cannot cope with components that have no files.
continue;
}
anyDownloadedComponents =
- anyDownloadedComponents || compIt->second.IsDownloaded;
+ anyDownloadedComponents || comp.second.IsDownloaded;
- if (!compIt->second.Group) {
+ if (!comp.second.Group) {
componentCode +=
- this->CreateComponentDescription(&compIt->second, macrosOut);
+ this->CreateComponentDescription(&comp.second, macrosOut);
}
// Add this component to the various section lists.
- sectionList += " !insertmacro \"${MacroName}\" \"";
- sectionList += compIt->first;
+ sectionList += R"( !insertmacro "${MacroName}" ")";
+ sectionList += comp.first;
sectionList += "\"\n";
- selectedVarsList += "Var " + compIt->first + "_selected\n";
- selectedVarsList += "Var " + compIt->first + "_was_installed\n";
+ selectedVarsList += "Var " + comp.first + "_selected\n";
+ selectedVarsList += "Var " + comp.first + "_was_installed\n";
// Add the component description, if any.
- if (!compIt->second.Description.empty()) {
+ if (!comp.second.Description.empty()) {
componentDescriptions += " !insertmacro MUI_DESCRIPTION_TEXT ${" +
- compIt->first + "} \"" +
- this->TranslateNewlines(compIt->second.Description) + "\"\n";
+ comp.first + "} \"" +
+ cmCPackNSISGenerator::TranslateNewlines(comp.second.Description) +
+ "\"\n";
}
}
@@ -283,7 +270,7 @@ int cmCPackNSISGenerator::PackageFiles()
if (anyDownloadedComponents) {
defines += "!define CPACK_USES_DOWNLOAD\n";
- if (cmSystemTools::IsOn(this->GetOption("CPACK_ADD_REMOVE"))) {
+ if (cmIsOn(this->GetOption("CPACK_ADD_REMOVE"))) {
defines += "!define CPACK_NSIS_ADD_REMOVE\n";
}
}
@@ -302,27 +289,27 @@ int cmCPackNSISGenerator::PackageFiles()
this->SetOption("CPACK_NSIS_DEFINES", defines.c_str());
}
- this->ConfigureFile(nsisInInstallOptions.c_str(),
- nsisInstallOptions.c_str());
- this->ConfigureFile(nsisInFileName.c_str(), nsisFileName.c_str());
- std::string nsisCmd = "\"";
- nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM");
- nsisCmd += "\" \"" + nsisFileName + "\"";
+ this->ConfigureFile(nsisInInstallOptions, nsisInstallOptions);
+ this->ConfigureFile(nsisInFileName, nsisFileName);
+ std::string nsisCmd =
+ cmStrCat('"', this->GetOption("CPACK_INSTALLER_PROGRAM"), "\" \"",
+ nsisFileName, '"');
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd << std::endl);
std::string output;
int retVal = 1;
- bool res =
- cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &output, &retVal,
- CM_NULLPTR, this->GeneratorVerbose, 0);
+ bool res = cmSystemTools::RunSingleCommand(
+ nsisCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
+ cmDuration::zero());
if (!res || retVal) {
- cmGeneratedFileStream ofs(tmpFile.c_str());
+ cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << nsisCmd << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running NSIS command: "
- << nsisCmd << std::endl
- << "Please check " << tmpFile << " for errors"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem running NSIS command: " << nsisCmd << std::endl
+ << "Please check "
+ << tmpFile << " for errors"
+ << std::endl);
return 0;
}
return 1;
@@ -330,38 +317,40 @@ int cmCPackNSISGenerator::PackageFiles()
int cmCPackNSISGenerator::InitializeInternal()
{
- if (cmSystemTools::IsOn(
- this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) {
+ if (cmIsOn(this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) {
cmCPackLogger(
cmCPackLog::LOG_WARNING,
"NSIS Generator cannot work with CPACK_INCLUDE_TOPLEVEL_DIRECTORY set. "
"This option will be reset to 0 (for this generator only)."
<< std::endl);
- this->SetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", CM_NULLPTR);
+ this->SetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", nullptr);
}
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackNSISGenerator::Initialize()"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "cmCPackNSISGenerator::Initialize()" << std::endl);
std::vector<std::string> path;
std::string nsisPath;
bool gotRegValue = false;
#ifdef _WIN32
if (Nsis64) {
- if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode",
- nsisPath, cmsys::SystemTools::KeyWOW64_64)) {
+ if (!gotRegValue &&
+ cmsys::SystemTools::ReadRegistryValue(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath,
+ cmsys::SystemTools::KeyWOW64_64)) {
gotRegValue = true;
}
- if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath,
- cmsys::SystemTools::KeyWOW64_64)) {
+ if (!gotRegValue &&
+ cmsys::SystemTools::ReadRegistryValue(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath,
+ cmsys::SystemTools::KeyWOW64_64)) {
gotRegValue = true;
}
}
- if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode",
- nsisPath, cmsys::SystemTools::KeyWOW64_32)) {
+ if (!gotRegValue &&
+ cmsys::SystemTools::ReadRegistryValue(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath,
+ cmsys::SystemTools::KeyWOW64_32)) {
gotRegValue = true;
}
if (!gotRegValue &&
@@ -369,13 +358,15 @@ int cmCPackNSISGenerator::InitializeInternal()
"HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode", nsisPath)) {
gotRegValue = true;
}
- if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath,
- cmsys::SystemTools::KeyWOW64_32)) {
+ if (!gotRegValue &&
+ cmsys::SystemTools::ReadRegistryValue(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath,
+ cmsys::SystemTools::KeyWOW64_32)) {
gotRegValue = true;
}
- if (!gotRegValue && cmsys::SystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath)) {
+ if (!gotRegValue &&
+ cmsys::SystemTools::ReadRegistryValue(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath)) {
gotRegValue = true;
}
@@ -406,35 +397,35 @@ int cmCPackNSISGenerator::InitializeInternal()
}
std::string nsisCmd = "\"" + nsisPath + "\" " NSIS_OPT "VERSION";
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: " << nsisCmd
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Test NSIS version: " << nsisCmd << std::endl);
std::string output;
int retVal = 1;
- bool resS =
- cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &output, &retVal,
- CM_NULLPTR, this->GeneratorVerbose, 0);
+ bool resS = cmSystemTools::RunSingleCommand(
+ nsisCmd, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
+ cmDuration::zero());
cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)");
cmsys::RegularExpression versionRexCVS("v(.*)\\.cvs");
if (!resS || retVal ||
(!versionRex.find(output) && !versionRexCVS.find(output))) {
const char* topDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- std::string tmpFile = topDir ? topDir : ".";
- tmpFile += "/NSISOutput.log";
- cmGeneratedFileStream ofs(tmpFile.c_str());
+ std::string tmpFile = cmStrCat(topDir ? topDir : ".", "/NSISOutput.log");
+ cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << nsisCmd << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
- cmCPackLogger(
- cmCPackLog::LOG_ERROR, "Problem checking NSIS version with command: "
- << nsisCmd << std::endl
- << "Please check " << tmpFile << " for errors" << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem checking NSIS version with command: "
+ << nsisCmd << std::endl
+ << "Please check " << tmpFile << " for errors"
+ << std::endl);
return 0;
}
if (versionRex.find(output)) {
double nsisVersion = atof(versionRex.match(1).c_str());
double minNSISVersion = 2.09;
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: " << nsisVersion
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "NSIS Version: " << nsisVersion << std::endl);
if (nsisVersion < minNSISVersion) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPack requires NSIS Version 2.09 or greater. "
@@ -445,8 +436,8 @@ int cmCPackNSISGenerator::InitializeInternal()
}
if (versionRexCVS.find(output)) {
// No version check for NSIS cvs build
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: CVS "
- << versionRexCVS.match(1) << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "NSIS Version: CVS " << versionRexCVS.match(1) << std::endl);
}
this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str());
this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin");
@@ -458,19 +449,18 @@ int cmCPackNSISGenerator::InitializeInternal()
this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY");
std::vector<std::string> cpackPackageDesktopLinksVector;
if (cpackPackageDeskTopLinks) {
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: "
- << cpackPackageDeskTopLinks << std::endl);
-
- cmSystemTools::ExpandListArgument(cpackPackageDeskTopLinks,
- cpackPackageDesktopLinksVector);
- for (std::vector<std::string>::iterator i =
- cpackPackageDesktopLinksVector.begin();
- i != cpackPackageDesktopLinksVector.end(); ++i) {
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "CPACK_CREATE_DESKTOP_LINKS: " << cpackPackageDeskTopLinks
+ << std::endl);
+
+ cmExpandList(cpackPackageDeskTopLinks, cpackPackageDesktopLinksVector);
+ for (std::string const& cpdl : cpackPackageDesktopLinksVector) {
cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "CPACK_CREATE_DESKTOP_LINKS: " << *i << std::endl);
+ "CPACK_CREATE_DESKTOP_LINKS: " << cpdl << std::endl);
}
} else {
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: "
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "CPACK_CREATE_DESKTOP_LINKS: "
<< "not set" << std::endl);
}
@@ -478,11 +468,11 @@ int cmCPackNSISGenerator::InitializeInternal()
std::ostringstream deleteStr;
if (cpackPackageExecutables) {
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: "
- << cpackPackageExecutables << "." << std::endl);
- std::vector<std::string> cpackPackageExecutablesVector;
- cmSystemTools::ExpandListArgument(cpackPackageExecutables,
- cpackPackageExecutablesVector);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "The cpackPackageExecutables: " << cpackPackageExecutables
+ << "." << std::endl);
+ std::vector<std::string> cpackPackageExecutablesVector =
+ cmExpandedList(cpackPackageExecutables);
if (cpackPackageExecutablesVector.size() % 2 != 0) {
cmCPackLogger(
cmCPackLog::LOG_ERROR,
@@ -497,20 +487,17 @@ int cmCPackNSISGenerator::InitializeInternal()
std::string execName = *it;
++it;
std::string linkName = *it;
- str << " CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" << linkName
- << ".lnk\" \"$INSTDIR\\" << cpackNsisExecutablesDirectory << "\\"
+ str << R"( CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\)" << linkName
+ << R"(.lnk" "$INSTDIR\)" << cpackNsisExecutablesDirectory << "\\"
<< execName << ".exe\"" << std::endl;
- deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName
+ deleteStr << R"( Delete "$SMPROGRAMS\$MUI_TEMP\)" << linkName
<< ".lnk\"" << std::endl;
// see if CPACK_CREATE_DESKTOP_LINK_ExeName is on
// if so add a desktop link
- if (!cpackPackageDesktopLinksVector.empty() &&
- std::find(cpackPackageDesktopLinksVector.begin(),
- cpackPackageDesktopLinksVector.end(),
- execName) != cpackPackageDesktopLinksVector.end()) {
+ if (cmContains(cpackPackageDesktopLinksVector, execName)) {
str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
str << " CreateShortCut \"$DESKTOP\\" << linkName
- << ".lnk\" \"$INSTDIR\\" << cpackNsisExecutablesDirectory << "\\"
+ << R"(.lnk" "$INSTDIR\)" << cpackNsisExecutablesDirectory << "\\"
<< execName << ".exe\"" << std::endl;
deleteStr << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
deleteStr << " Delete \"$DESKTOP\\" << linkName << ".lnk\""
@@ -537,8 +524,8 @@ void cmCPackNSISGenerator::CreateMenuLinks(std::ostream& str,
}
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"The cpackMenuLinks: " << cpackMenuLinks << "." << std::endl);
- std::vector<std::string> cpackMenuLinksVector;
- cmSystemTools::ExpandListArgument(cpackMenuLinks, cpackMenuLinksVector);
+ std::vector<std::string> cpackMenuLinksVector =
+ cmExpandedList(cpackMenuLinks);
if (cpackMenuLinksVector.size() % 2 != 0) {
cmCPackLogger(
cmCPackLog::LOG_ERROR,
@@ -566,25 +553,24 @@ void cmCPackNSISGenerator::CreateMenuLinks(std::ostream& str,
++it;
std::string linkName = *it;
if (!url) {
- str << " CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" << linkName
- << ".lnk\" \"$INSTDIR\\" << sourceName << "\"" << std::endl;
- deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName
+ str << R"( CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\)" << linkName
+ << R"(.lnk" "$INSTDIR\)" << sourceName << "\"" << std::endl;
+ deleteStr << R"( Delete "$SMPROGRAMS\$MUI_TEMP\)" << linkName
<< ".lnk\"" << std::endl;
} else {
- str << " WriteINIStr \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" << linkName
- << ".url\" \"InternetShortcut\" \"URL\" \"" << sourceName << "\""
+ str << R"( WriteINIStr "$SMPROGRAMS\$STARTMENU_FOLDER\)" << linkName
+ << R"(.url" "InternetShortcut" "URL" ")" << sourceName << "\""
<< std::endl;
- deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName
+ deleteStr << R"( Delete "$SMPROGRAMS\$MUI_TEMP\)" << linkName
<< ".url\"" << std::endl;
}
// see if CPACK_CREATE_DESKTOP_LINK_ExeName is on
// if so add a desktop link
- std::string desktop = "CPACK_CREATE_DESKTOP_LINK_";
- desktop += linkName;
+ std::string desktop = cmStrCat("CPACK_CREATE_DESKTOP_LINK_", linkName);
if (this->IsSet(desktop)) {
str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
str << " CreateShortCut \"$DESKTOP\\" << linkName
- << ".lnk\" \"$INSTDIR\\" << sourceName << "\"" << std::endl;
+ << R"(.lnk" "$INSTDIR\)" << sourceName << "\"" << std::endl;
deleteStr << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
deleteStr << " Delete \"$DESKTOP\\" << linkName << ".lnk\""
<< std::endl;
@@ -610,7 +596,7 @@ bool cmCPackNSISGenerator::GetListOfSubdirectories(
}
}
}
- dirs.push_back(topdir);
+ dirs.emplace_back(topdir);
return true;
}
@@ -647,11 +633,9 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
componentCode += " SectionIn RO\n";
} else if (!component->InstallationTypes.empty()) {
std::ostringstream out;
- std::vector<cmCPackInstallationType*>::iterator installTypeIter;
- for (installTypeIter = component->InstallationTypes.begin();
- installTypeIter != component->InstallationTypes.end();
- ++installTypeIter) {
- out << " " << (*installTypeIter)->Index;
+ for (cmCPackInstallationType const* installType :
+ component->InstallationTypes) {
+ out << " " << installType->Index;
}
componentCode += " SectionIn" + out.str() + "\n";
}
@@ -664,8 +648,8 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
if (component->IsDownloaded) {
if (component->ArchiveFile.empty()) {
// Compute the name of the archive.
- std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
- packagesDir += ".dummy";
+ std::string packagesDir =
+ cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), ".dummy");
std::ostringstream out;
out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-"
<< component->Name << ".zip";
@@ -679,11 +663,11 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
if (userUploadDirectory && *userUploadDirectory) {
uploadDirectory = userUploadDirectory;
} else {
- uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
- uploadDirectory += "/CPackUploads";
+ uploadDirectory =
+ cmStrCat(this->GetOption("CPACK_PACKAGE_DIRECTORY"), "/CPackUploads");
}
- if (!cmSystemTools::FileExists(uploadDirectory.c_str())) {
- if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str())) {
+ if (!cmSystemTools::FileExists(uploadDirectory)) {
+ if (!cmSystemTools::MakeDirectory(uploadDirectory)) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Unable to create NSIS upload directory "
<< uploadDirectory << std::endl);
@@ -696,53 +680,49 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"- Building downloaded component archive: " << archiveFile
<< std::endl);
- if (cmSystemTools::FileExists(archiveFile.c_str(), true)) {
+ if (cmSystemTools::FileExists(archiveFile, true)) {
if (!cmSystemTools::RemoveFile(archiveFile)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Unable to remove archive file "
- << archiveFile << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Unable to remove archive file " << archiveFile
+ << std::endl);
return "";
}
}
// Find a ZIP program
if (!this->IsSet("ZIP_EXECUTABLE")) {
- this->ReadListFile("CPackZIP.cmake");
+ this->ReadListFile("Internal/CPack/CPackZIP.cmake");
if (!this->IsSet("ZIP_EXECUTABLE")) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Unable to find ZIP program"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Unable to find ZIP program" << std::endl);
return "";
}
}
// The directory where this component's files reside
- std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
- dirName += '/';
- dirName += component->Name;
- dirName += '/';
+ std::string dirName = cmStrCat(
+ this->GetOption("CPACK_TEMPORARY_DIRECTORY"), '/', component->Name, '/');
// Build the list of files to go into this archive, and determine the
// size of the installed component.
- std::string zipListFileName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
- zipListFileName += "/winZip.filelist";
- bool needQuotesInFile =
- cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES"));
+ std::string zipListFileName = cmStrCat(
+ this->GetOption("CPACK_TEMPORARY_DIRECTORY"), "/winZip.filelist");
+ bool needQuotesInFile = cmIsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES"));
unsigned long totalSize = 0;
{ // the scope is needed for cmGeneratedFileStream
- cmGeneratedFileStream out(zipListFileName.c_str());
- std::vector<std::string>::iterator fileIt;
- for (fileIt = component->Files.begin(); fileIt != component->Files.end();
- ++fileIt) {
+ cmGeneratedFileStream out(zipListFileName);
+ for (std::string const& file : component->Files) {
if (needQuotesInFile) {
out << "\"";
}
- out << *fileIt;
+ out << file;
if (needQuotesInFile) {
out << "\"";
}
out << std::endl;
- totalSize += cmSystemTools::FileLength(dirName + *fileIt);
+ totalSize += cmSystemTools::FileLength(dirName + file);
}
}
@@ -753,20 +733,21 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
zipListFileName.c_str());
std::string output;
int retVal = -1;
- int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &output,
- &retVal, dirName.c_str(),
- cmSystemTools::OUTPUT_NONE, 0);
+ int res = cmSystemTools::RunSingleCommand(
+ cmd, &output, &output, &retVal, dirName.c_str(),
+ cmSystemTools::OUTPUT_NONE, cmDuration::zero());
if (!res || retVal) {
- std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- tmpFile += "/CompressZip.log";
- cmGeneratedFileStream ofs(tmpFile.c_str());
+ std::string tmpFile = cmStrCat(
+ this->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);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem running zip command: " << cmd << std::endl
+ << "Please check "
+ << tmpFile << " for errors"
+ << std::endl);
return "";
}
@@ -798,17 +779,14 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
macrosOut << "!macro Remove_${" << component->Name << "}\n";
macrosOut << " IntCmp $" << component->Name << "_was_installed 0 noremove_"
<< component->Name << "\n";
- std::vector<std::string>::iterator pathIt;
std::string path;
- for (pathIt = component->Files.begin(); pathIt != component->Files.end();
- ++pathIt) {
- path = *pathIt;
+ for (std::string const& pathIt : component->Files) {
+ path = pathIt;
std::replace(path.begin(), path.end(), '/', '\\');
macrosOut << " Delete \"" << componentOutputDir << "\\" << path << "\"\n";
}
- for (pathIt = component->Directories.begin();
- pathIt != component->Directories.end(); ++pathIt) {
- path = *pathIt;
+ for (std::string const& pathIt : component->Directories) {
+ path = pathIt;
std::replace(path.begin(), path.end(), '/', '\\');
macrosOut << " RMDir \"" << componentOutputDir << "\\" << path << "\"\n";
}
@@ -841,17 +819,14 @@ std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription(
visited.insert(component);
std::ostringstream out;
- std::vector<cmCPackComponent*>::iterator dependIt;
- for (dependIt = component->Dependencies.begin();
- dependIt != component->Dependencies.end(); ++dependIt) {
+ for (cmCPackComponent* depend : component->Dependencies) {
// Write NSIS code to select this dependency
- out << " SectionGetFlags ${" << (*dependIt)->Name << "} $0\n";
+ out << " SectionGetFlags ${" << depend->Name << "} $0\n";
out << " IntOp $0 $0 | ${SF_SELECTED}\n";
- out << " SectionSetFlags ${" << (*dependIt)->Name << "} $0\n";
- out << " IntOp $" << (*dependIt)->Name
- << "_selected 0 + ${SF_SELECTED}\n";
+ out << " SectionSetFlags ${" << depend->Name << "} $0\n";
+ out << " IntOp $" << depend->Name << "_selected 0 + ${SF_SELECTED}\n";
// Recurse
- out << CreateSelectionDependenciesDescription(*dependIt, visited).c_str();
+ out << CreateSelectionDependenciesDescription(depend, visited).c_str();
}
return out.str();
@@ -867,19 +842,16 @@ std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription(
visited.insert(component);
std::ostringstream out;
- std::vector<cmCPackComponent*>::iterator dependIt;
- for (dependIt = component->ReverseDependencies.begin();
- dependIt != component->ReverseDependencies.end(); ++dependIt) {
+ for (cmCPackComponent* depend : component->ReverseDependencies) {
// Write NSIS code to deselect this dependency
- out << " SectionGetFlags ${" << (*dependIt)->Name << "} $0\n";
+ out << " SectionGetFlags ${" << depend->Name << "} $0\n";
out << " IntOp $1 ${SF_SELECTED} ~\n";
out << " IntOp $0 $0 & $1\n";
- out << " SectionSetFlags ${" << (*dependIt)->Name << "} $0\n";
- out << " IntOp $" << (*dependIt)->Name << "_selected 0 + 0\n";
+ out << " SectionSetFlags ${" << depend->Name << "} $0\n";
+ out << " IntOp $" << depend->Name << "_selected 0 + 0\n";
// Recurse
- out
- << CreateDeselectionDependenciesDescription(*dependIt, visited).c_str();
+ out << CreateDeselectionDependenciesDescription(depend, visited).c_str();
}
return out.str();
@@ -903,20 +875,16 @@ std::string cmCPackNSISGenerator::CreateComponentGroupDescription(
code += "\"" + group->DisplayName + "\" " + group->Name + "\n";
}
- std::vector<cmCPackComponentGroup*>::iterator groupIt;
- for (groupIt = group->Subgroups.begin(); groupIt != group->Subgroups.end();
- ++groupIt) {
- code += this->CreateComponentGroupDescription(*groupIt, macrosOut);
+ for (cmCPackComponentGroup* g : group->Subgroups) {
+ code += this->CreateComponentGroupDescription(g, macrosOut);
}
- std::vector<cmCPackComponent*>::iterator comp;
- for (comp = group->Components.begin(); comp != group->Components.end();
- ++comp) {
- if ((*comp)->Files.empty()) {
+ for (cmCPackComponent* comp : group->Components) {
+ if (comp->Files.empty()) {
continue;
}
- code += this->CreateComponentDescription(*comp, macrosOut);
+ code += this->CreateComponentDescription(comp, macrosOut);
}
code += "SectionGroupEnd\n";
return code;
diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h
index 77be3256d..0af37af50 100644
--- a/Source/CPack/cmCPackNSISGenerator.h
+++ b/Source/CPack/cmCPackNSISGenerator.h
@@ -3,15 +3,15 @@
#ifndef cmCPackNSISGenerator_h
#define cmCPackNSISGenerator_h
-#include "cmConfigure.h"
-
-#include "cmCPackGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <set>
#include <string>
#include <vector>
+#include "cmCPackGenerator.h"
+
class cmCPackComponent;
class cmCPackComponentGroup;
@@ -34,22 +34,22 @@ public:
* Construct generator
*/
cmCPackNSISGenerator(bool nsis64 = false);
- ~cmCPackNSISGenerator() CM_OVERRIDE;
+ ~cmCPackNSISGenerator() override;
protected:
- int InitializeInternal() CM_OVERRIDE;
+ int InitializeInternal() override;
void CreateMenuLinks(std::ostream& str, std::ostream& deleteStr);
- int PackageFiles() CM_OVERRIDE;
- const char* GetOutputExtension() CM_OVERRIDE { return ".exe"; }
- const char* GetOutputPostfix() CM_OVERRIDE { return "win32"; }
+ int PackageFiles() override;
+ const char* GetOutputExtension() override { return ".exe"; }
+ const char* GetOutputPostfix() override { return "win32"; }
bool GetListOfSubdirectories(const char* dir,
std::vector<std::string>& dirs);
- enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() const
- CM_OVERRIDE;
- bool SupportsAbsoluteDestination() const CM_OVERRIDE;
- bool SupportsComponentInstallation() const CM_OVERRIDE;
+ enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir()
+ const override;
+ bool SupportsAbsoluteDestination() const override;
+ bool SupportsComponentInstallation() const override;
/// Produce a string that contains the NSIS code to describe a
/// particular component. Any added macros will be emitted via
diff --git a/Source/CPack/cmCPackNuGetGenerator.cxx b/Source/CPack/cmCPackNuGetGenerator.cxx
new file mode 100644
index 000000000..60faecd0b
--- /dev/null
+++ b/Source/CPack/cmCPackNuGetGenerator.cxx
@@ -0,0 +1,141 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmCPackNuGetGenerator.h"
+
+#include <algorithm>
+#include <iterator>
+#include <map>
+#include <ostream>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "cmCPackComponentGroup.h"
+#include "cmCPackLog.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+bool cmCPackNuGetGenerator::SupportsComponentInstallation() const
+{
+ return IsOn("CPACK_NUGET_COMPONENT_INSTALL");
+}
+
+int cmCPackNuGetGenerator::PackageFiles()
+{
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl);
+
+ /* Reset package file name list it will be populated after the
+ * `CPackNuGet.cmake` run */
+ packageFileNames.clear();
+
+ /* Are we in the component packaging case */
+ if (WantsComponentInstallation()) {
+ if (componentPackageMethod == ONE_PACKAGE) {
+ // CASE 1 : COMPONENT ALL-IN-ONE package
+ // Meaning that all per-component pre-installed files
+ // goes into the single package.
+ this->SetOption("CPACK_NUGET_ALL_IN_ONE", "TRUE");
+ SetupGroupComponentVariables(true);
+ } else {
+ // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
+ // There will be 1 package for each component group
+ // however one may require to ignore component group and
+ // in this case you'll get 1 package for each component.
+ SetupGroupComponentVariables(componentPackageMethod ==
+ ONE_PACKAGE_PER_COMPONENT);
+ }
+ } else {
+ // CASE 3 : NON COMPONENT package.
+ this->SetOption("CPACK_NUGET_ORDINAL_MONOLITIC", "TRUE");
+ }
+
+ auto retval = this->ReadListFile("Internal/CPack/CPackNuGet.cmake");
+ if (retval) {
+ AddGeneratedPackageNames();
+ } else {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error while execution CPackNuGet.cmake" << std::endl);
+ }
+
+ return retval;
+}
+
+void cmCPackNuGetGenerator::SetupGroupComponentVariables(bool ignoreGroup)
+{
+ // The default behavior is to have one package by component group
+ // unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
+ if (!ignoreGroup) {
+ std::vector<std::string> groups;
+ for (auto const& compG : this->ComponentGroups) {
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Packaging component group: " << compG.first << std::endl);
+ groups.push_back(compG.first);
+ auto compGUp =
+ cmSystemTools::UpperCase(cmSystemTools::MakeCidentifier(compG.first));
+
+ // Collect components for this group
+ std::vector<std::string> components;
+ std::transform(begin(compG.second.Components),
+ end(compG.second.Components),
+ std::back_inserter(components),
+ [](cmCPackComponent const* comp) { return comp->Name; });
+ this->SetOption("CPACK_NUGET_" + compGUp + "_GROUP_COMPONENTS",
+ cmJoin(components, ";").c_str());
+ }
+ if (!groups.empty()) {
+ this->SetOption("CPACK_NUGET_GROUPS", cmJoin(groups, ";").c_str());
+ }
+
+ // Handle Orphan components (components not belonging to any groups)
+ std::vector<std::string> components;
+ for (auto const& comp : this->Components) {
+ // Does the component belong to a group?
+ if (comp.second.Group == nullptr) {
+ cmCPackLogger(
+ cmCPackLog::LOG_VERBOSE,
+ "Component <"
+ << comp.second.Name
+ << "> does not belong to any group, package it separately."
+ << std::endl);
+ components.push_back(comp.first);
+ }
+ }
+ if (!components.empty()) {
+ this->SetOption("CPACK_NUGET_COMPONENTS",
+ cmJoin(components, ";").c_str());
+ }
+
+ } else {
+ std::vector<std::string> components;
+ components.reserve(this->Components.size());
+ std::transform(begin(this->Components), end(this->Components),
+ std::back_inserter(components),
+ [](std::pair<std::string, cmCPackComponent> const& comp) {
+ return comp.first;
+ });
+ this->SetOption("CPACK_NUGET_COMPONENTS", cmJoin(components, ";").c_str());
+ }
+}
+
+void cmCPackNuGetGenerator::AddGeneratedPackageNames()
+{
+ const char* const files_list = this->GetOption("GEN_CPACK_OUTPUT_FILES");
+ if (!files_list) {
+ cmCPackLogger(
+ cmCPackLog::LOG_ERROR,
+ "Error while execution CPackNuGet.cmake: No NuGet package has generated"
+ << std::endl);
+ return;
+ }
+ // add the generated packages to package file names list
+ std::string fileNames{ files_list };
+ const char sep = ';';
+ std::string::size_type pos1 = 0;
+ std::string::size_type pos2 = fileNames.find(sep, pos1 + 1);
+ while (pos2 != std::string::npos) {
+ packageFileNames.push_back(fileNames.substr(pos1, pos2 - pos1));
+ pos1 = pos2 + 1;
+ pos2 = fileNames.find(sep, pos1 + 1);
+ }
+ packageFileNames.push_back(fileNames.substr(pos1, pos2 - pos1));
+}
diff --git a/Source/CPack/cmCPackNuGetGenerator.h b/Source/CPack/cmCPackNuGetGenerator.h
new file mode 100644
index 000000000..a59db2d04
--- /dev/null
+++ b/Source/CPack/cmCPackNuGetGenerator.h
@@ -0,0 +1,37 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmCPackNuGetGenerator_h
+#define cmCPackNuGetGenerator_h
+
+#include "cmCPackGenerator.h"
+
+/** \class cmCPackNuGetGenerator
+ * \brief A generator for RPM packages
+ */
+class cmCPackNuGetGenerator : public cmCPackGenerator
+{
+public:
+ cmCPackTypeMacro(cmCPackNuGetGenerator, cmCPackGenerator);
+
+ // NOTE In fact, it is possible to have NuGet not only for Windows...
+ // https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools
+ static bool CanGenerate() { return true; }
+
+protected:
+ bool SupportsComponentInstallation() const override;
+ int PackageFiles() override;
+
+ const char* GetOutputExtension() override { return ".nupkg"; }
+ bool SupportsAbsoluteDestination() const override { return false; }
+ /**
+ * The method used to prepare variables when component
+ * install is used.
+ */
+ void SetupGroupComponentVariables(bool ignoreGroup);
+ /**
+ * Populate \c packageFileNames vector of built packages.
+ */
+ void AddGeneratedPackageNames();
+};
+
+#endif
diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx
index 8ea88a87a..951c65f4d 100644
--- a/Source/CPack/cmCPackOSXX11Generator.cxx
+++ b/Source/CPack/cmCPackOSXX11Generator.cxx
@@ -4,19 +4,18 @@
#include <sstream>
+#include "cm_sys_stat.h"
+
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
+#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_sys_stat.h"
-cmCPackOSXX11Generator::cmCPackOSXX11Generator()
-{
-}
+cmCPackOSXX11Generator::cmCPackOSXX11Generator() = default;
-cmCPackOSXX11Generator::~cmCPackOSXX11Generator()
-{
-}
+cmCPackOSXX11Generator::~cmCPackOSXX11Generator() = default;
int cmCPackOSXX11Generator::PackageFiles()
{
@@ -26,13 +25,13 @@ int cmCPackOSXX11Generator::PackageFiles()
const char* cpackPackageExecutables =
this->GetOption("CPACK_PACKAGE_EXECUTABLES");
if (cpackPackageExecutables) {
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: "
- << cpackPackageExecutables << "." << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "The cpackPackageExecutables: " << cpackPackageExecutables
+ << "." << std::endl);
std::ostringstream str;
std::ostringstream deleteStr;
- std::vector<std::string> cpackPackageExecutablesVector;
- cmSystemTools::ExpandListArgument(cpackPackageExecutables,
- cpackPackageExecutablesVector);
+ std::vector<std::string> cpackPackageExecutablesVector =
+ cmExpandedList(cpackPackageExecutables);
if (cpackPackageExecutablesVector.size() % 2 != 0) {
cmCPackLogger(
cmCPackLog::LOG_ERROR,
@@ -57,16 +56,14 @@ int cmCPackOSXX11Generator::PackageFiles()
diskImageDirectory + "/.background";
// App bundle directories
- std::string packageDirFileName = toplevel;
- packageDirFileName += "/";
- packageDirFileName += this->GetOption("CPACK_PACKAGE_FILE_NAME");
- packageDirFileName += ".app";
+ std::string packageDirFileName = cmStrCat(
+ toplevel, '/', this->GetOption("CPACK_PACKAGE_FILE_NAME"), ".app");
std::string contentsDirectory = packageDirFileName + "/Contents";
std::string resourcesDirectory = contentsDirectory + "/Resources";
std::string appDirectory = contentsDirectory + "/MacOS";
std::string scriptDirectory = resourcesDirectory + "/Scripts";
- std::string resourceFileName = this->GetOption("CPACK_PACKAGE_FILE_NAME");
- resourceFileName += ".rsrc";
+ std::string resourceFileName =
+ cmStrCat(this->GetOption("CPACK_PACKAGE_FILE_NAME"), ".rsrc");
const char* dir = resourcesDirectory.c_str();
const char* appdir = appDirectory.c_str();
@@ -77,14 +74,15 @@ int cmCPackOSXX11Generator::PackageFiles()
if (iconFile) {
std::string iconFileName = cmsys::SystemTools::GetFilenameName(iconFile);
if (!cmSystemTools::FileExists(iconFile)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find icon file: "
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find icon file: "
<< iconFile
<< ". Please check CPACK_PACKAGE_ICON setting."
<< std::endl);
return 0;
}
std::string destFileName = resourcesDirectory + "/" + iconFileName;
- this->ConfigureFile(iconFile, destFileName.c_str(), true);
+ this->ConfigureFile(iconFile, destFileName, true);
this->SetOptionIfNotSet("CPACK_APPLE_GUI_ICON", iconFileName.c_str());
}
@@ -108,19 +106,16 @@ int cmCPackOSXX11Generator::PackageFiles()
!this->CopyResourcePlistFile("OSXScriptLauncher", appdir,
this->GetOption("CPACK_PACKAGE_FILE_NAME"),
true)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem copying the resource files" << std::endl);
return 0;
}
// Two of the files need to have execute permission, so ensure they do:
- std::string runTimeScript = dir;
- runTimeScript += "/";
- runTimeScript += "RuntimeScript";
+ std::string runTimeScript = cmStrCat(dir, "/RuntimeScript");
- std::string appScriptName = appdir;
- appScriptName += "/";
- appScriptName += this->GetOption("CPACK_PACKAGE_FILE_NAME");
+ std::string appScriptName =
+ cmStrCat(appdir, '/', this->GetOption("CPACK_PACKAGE_FILE_NAME"));
mode_t mode;
if (cmsys::SystemTools::GetPermissions(runTimeScript.c_str(), mode)) {
@@ -140,23 +135,24 @@ int cmCPackOSXX11Generator::PackageFiles()
}
std::string output;
- std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- tmpFile += "/hdiutilOutput.log";
+ std::string tmpFile = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"),
+ "/hdiutilOutput.log");
std::ostringstream dmgCmd;
dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
- << "\" create -ov -format UDZO -srcfolder \"" << diskImageDirectory
- << "\" \"" << packageFileNames[0] << "\"";
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress disk image using command: "
- << dmgCmd.str() << std::endl);
+ << "\" create -ov -fs HFS+ -format UDZO -srcfolder \""
+ << diskImageDirectory << "\" \"" << packageFileNames[0] << "\"";
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Compress disk image using command: " << dmgCmd.str()
+ << std::endl);
// since we get random dashboard failures with this one
// try running it more than once
int retVal = 1;
int numTries = 10;
bool res = false;
while (numTries > 0) {
- res =
- cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &output,
- &retVal, 0, this->GeneratorVerbose, 0);
+ res = cmSystemTools::RunSingleCommand(
+ dmgCmd.str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose,
+ cmDuration::zero());
if (res && !retVal) {
numTries = -1;
break;
@@ -165,11 +161,12 @@ int cmCPackOSXX11Generator::PackageFiles()
numTries--;
}
if (!res || retVal) {
- cmGeneratedFileStream ofs(tmpFile.c_str());
+ cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << dmgCmd.str() << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: "
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem running hdiutil command: "
<< dmgCmd.str() << std::endl
<< "Please check " << tmpFile << " for errors"
<< std::endl);
@@ -181,13 +178,13 @@ int cmCPackOSXX11Generator::PackageFiles()
int cmCPackOSXX11Generator::InitializeInternal()
{
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackOSXX11Generator::Initialize()"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "cmCPackOSXX11Generator::Initialize()" << std::endl);
std::vector<std::string> path;
std::string pkgPath = cmSystemTools::FindProgram("hdiutil", path, false);
if (pkgPath.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find hdiutil compiler" << std::endl);
return 0;
}
this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE",
@@ -227,15 +224,14 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name)
return false;
}
- std::string destFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- destFileName += "/Resources/";
- destFileName += name + ext;
+ std::string destFileName = cmStrCat(
+this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/Resources/", name, ext );
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
<< (inFileName ? inFileName : "(NULL)")
<< " to " << destFileName << std::endl);
- this->ConfigureFile(inFileName, destFileName.c_str());
+ this->ConfigureFile(inFileName, destFileName);
return true;
}
*/
@@ -244,9 +240,7 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile(
const std::string& name, const std::string& dir,
const char* outputFileName /* = 0 */, bool copyOnly /* = false */)
{
- std::string inFName = "CPack.";
- inFName += name;
- inFName += ".in";
+ std::string inFName = cmStrCat("CPack.", name, ".in");
std::string inFileName = this->FindTemplate(inFName.c_str());
if (inFileName.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -258,20 +252,19 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile(
outputFileName = name.c_str();
}
- std::string destFileName = dir;
- destFileName += "/";
- destFileName += outputFileName;
+ std::string destFileName = cmStrCat(dir, '/', outputFileName);
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
- << inFileName << " to " << destFileName << std::endl);
- this->ConfigureFile(inFileName.c_str(), destFileName.c_str(), copyOnly);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Configure file: " << inFileName << " to " << destFileName
+ << std::endl);
+ this->ConfigureFile(inFileName, destFileName, copyOnly);
return true;
}
const char* cmCPackOSXX11Generator::GetPackagingInstallPrefix()
{
- this->InstallPrefix = "/";
- this->InstallPrefix += this->GetOption("CPACK_PACKAGE_FILE_NAME");
- this->InstallPrefix += ".app/Contents/Resources";
+ this->InstallPrefix =
+ cmStrCat('/', this->GetOption("CPACK_PACKAGE_FILE_NAME"),
+ ".app/Contents/Resources");
return this->InstallPrefix.c_str();
}
diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h
index 0eebc6dd1..a6461c854 100644
--- a/Source/CPack/cmCPackOSXX11Generator.h
+++ b/Source/CPack/cmCPackOSXX11Generator.h
@@ -3,7 +3,7 @@
#ifndef cmCPackOSXX11Generator_h
#define cmCPackOSXX11Generator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
@@ -23,13 +23,13 @@ public:
* Construct generator
*/
cmCPackOSXX11Generator();
- virtual ~cmCPackOSXX11Generator();
+ ~cmCPackOSXX11Generator() override;
protected:
- virtual int InitializeInternal() CM_OVERRIDE;
- int PackageFiles() CM_OVERRIDE;
- const char* GetPackagingInstallPrefix() CM_OVERRIDE;
- const char* GetOutputExtension() CM_OVERRIDE { return ".dmg"; }
+ virtual int InitializeInternal() override;
+ int PackageFiles() override;
+ const char* GetPackagingInstallPrefix() override;
+ const char* GetOutputExtension() override { return ".dmg"; }
// bool CopyCreateResourceFile(const std::string& name,
// const std::string& dir);
diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx
index 70ae267fb..dae5ec9d4 100644
--- a/Source/CPack/cmCPackPKGGenerator.cxx
+++ b/Source/CPack/cmCPackPKGGenerator.cxx
@@ -7,6 +7,7 @@
#include "cmCPackComponentGroup.h"
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
@@ -15,9 +16,7 @@ cmCPackPKGGenerator::cmCPackPKGGenerator()
this->componentPackageMethod = ONE_PACKAGE;
}
-cmCPackPKGGenerator::~cmCPackPKGGenerator()
-{
-}
+cmCPackPKGGenerator::~cmCPackPKGGenerator() = default;
bool cmCPackPKGGenerator::SupportsComponentInstallation() const
{
@@ -26,8 +25,8 @@ bool cmCPackPKGGenerator::SupportsComponentInstallation() const
int cmCPackPKGGenerator::InitializeInternal()
{
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackPKGGenerator::Initialize()"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "cmCPackPKGGenerator::Initialize()" << std::endl);
return this->Superclass::InitializeInternal();
}
@@ -36,15 +35,15 @@ std::string cmCPackPKGGenerator::GetPackageName(
const cmCPackComponent& component)
{
if (component.ArchiveFile.empty()) {
- std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
- packagesDir += ".dummy";
+ std::string packagesDir =
+ cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), ".dummy");
std::ostringstream out;
out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-"
<< component.Name << ".pkg";
return out.str();
- } else {
- return component.ArchiveFile + ".pkg";
}
+
+ return component.ArchiveFile + ".pkg";
}
void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
@@ -52,13 +51,14 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
std::string distributionTemplate =
this->FindTemplate("CPack.distribution.dist.in");
if (distributionTemplate.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: "
- << distributionTemplate << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find input file: " << distributionTemplate
+ << std::endl);
return;
}
- std::string distributionFile = metapackageFile;
- distributionFile += "/Contents/distribution.dist";
+ std::string distributionFile =
+ cmStrCat(metapackageFile, "/Contents/distribution.dist");
// Create the choice outline, which provides a tree-based view of
// the components in their groups.
@@ -67,21 +67,17 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
xout.StartElement("choices-outline");
// Emit the outline for the groups
- std::map<std::string, cmCPackComponentGroup>::iterator groupIt;
- for (groupIt = this->ComponentGroups.begin();
- groupIt != this->ComponentGroups.end(); ++groupIt) {
- if (groupIt->second.ParentGroup == 0) {
- CreateChoiceOutline(groupIt->second, xout);
+ for (auto const& group : this->ComponentGroups) {
+ if (group.second.ParentGroup == nullptr) {
+ CreateChoiceOutline(group.second, xout);
}
}
// Emit the outline for the non-grouped components
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
- if (!compIt->second.Group) {
+ for (auto const& comp : this->Components) {
+ if (!comp.second.Group) {
xout.StartElement("line");
- xout.Attribute("choice", compIt->first + "Choice");
+ xout.Attribute("choice", comp.first + "Choice");
xout.Content(""); // Avoid self-closing tag.
xout.EndElement();
}
@@ -95,13 +91,11 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
xout.EndElement(); // choices-outline>
// Create the actual choices
- for (groupIt = this->ComponentGroups.begin();
- groupIt != this->ComponentGroups.end(); ++groupIt) {
- CreateChoice(groupIt->second, xout);
+ for (auto const& group : this->ComponentGroups) {
+ CreateChoice(group.second, xout);
}
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
- CreateChoice(compIt->second, xout);
+ for (auto const& comp : this->Components) {
+ CreateChoice(comp.second, xout);
}
if (!this->PostFlightComponent.Name.empty()) {
@@ -112,7 +106,7 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile)
// Create the distribution.dist file in the metapackage to turn it
// into a distribution package.
- this->ConfigureFile(distributionTemplate.c_str(), distributionFile.c_str());
+ this->ConfigureFile(distributionTemplate, distributionFile);
}
void cmCPackPKGGenerator::CreateChoiceOutline(
@@ -120,17 +114,13 @@ void cmCPackPKGGenerator::CreateChoiceOutline(
{
xout.StartElement("line");
xout.Attribute("choice", group.Name + "Choice");
- std::vector<cmCPackComponentGroup*>::const_iterator groupIt;
- for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end();
- ++groupIt) {
- CreateChoiceOutline(**groupIt, xout);
+ for (cmCPackComponentGroup* subgroup : group.Subgroups) {
+ CreateChoiceOutline(*subgroup, xout);
}
- std::vector<cmCPackComponent*>::const_iterator compIt;
- for (compIt = group.Components.begin(); compIt != group.Components.end();
- ++compIt) {
+ for (cmCPackComponent* comp : group.Components) {
xout.StartElement("line");
- xout.Attribute("choice", (*compIt)->Name + "Choice");
+ xout.Attribute("choice", comp->Name + "Choice");
xout.Content(""); // Avoid self-closing tag.
xout.EndElement();
}
@@ -155,12 +145,9 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponentGroup& group,
void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component,
cmXMLWriter& xout)
{
- std::string packageId = "com.";
- packageId += this->GetOption("CPACK_PACKAGE_VENDOR");
- packageId += '.';
- packageId += this->GetOption("CPACK_PACKAGE_NAME");
- packageId += '.';
- packageId += component.Name;
+ std::string packageId =
+ cmStrCat("com.", this->GetOption("CPACK_PACKAGE_VENDOR"), '.',
+ this->GetOption("CPACK_PACKAGE_NAME"), '.', component.Name);
xout.StartElement("choice");
xout.Attribute("id", component.Name + "Choice");
@@ -189,7 +176,7 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component,
// This way, selecting C will automatically select everything it depends
// on (B and A), while selecting something that depends on C--either D
// or E--will automatically cause C to get selected.
- std::ostringstream selected("my.choice.selected");
+ std::ostringstream selected("my.choice.selected", std::ios_base::ate);
std::set<const cmCPackComponent*> visited;
AddDependencyAttributes(component, visited, selected);
visited.clear();
@@ -203,14 +190,13 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component,
// Create a description of the package associated with this
// component.
- std::string relativePackageLocation = "Contents/Packages/";
- relativePackageLocation += this->GetPackageName(component);
+ std::string relativePackageLocation =
+ cmStrCat("Contents/Packages/", this->GetPackageName(component));
// Determine the installed size of the package.
- std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
- dirName += '/';
- dirName += component.Name;
- dirName += this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
+ std::string dirName =
+ cmStrCat(this->GetOption("CPACK_TEMPORARY_DIRECTORY"), '/', component.Name,
+ this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"));
unsigned long installedSize = component.GetInstalledSizeInKbytes(dirName);
xout.StartElement("pkg-ref");
@@ -224,7 +210,8 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component,
xout.Content(this->GetPackageName(component));
} else {
xout.Content("file:./");
- xout.Content(relativePackageLocation);
+ xout.Content(cmSystemTools::EncodeURL(relativePackageLocation,
+ /*escapeSlashes=*/false));
}
xout.EndElement(); // pkg-ref
}
@@ -238,11 +225,9 @@ void cmCPackPKGGenerator::AddDependencyAttributes(
}
visited.insert(&component);
- std::vector<cmCPackComponent*>::const_iterator dependIt;
- for (dependIt = component.Dependencies.begin();
- dependIt != component.Dependencies.end(); ++dependIt) {
- out << " && choices['" << (*dependIt)->Name << "Choice'].selected";
- AddDependencyAttributes(**dependIt, visited, out);
+ for (cmCPackComponent* depend : component.Dependencies) {
+ out << " && choices['" << depend->Name << "Choice'].selected";
+ AddDependencyAttributes(*depend, visited, out);
}
}
@@ -255,11 +240,9 @@ void cmCPackPKGGenerator::AddReverseDependencyAttributes(
}
visited.insert(&component);
- std::vector<cmCPackComponent*>::const_iterator dependIt;
- for (dependIt = component.ReverseDependencies.begin();
- dependIt != component.ReverseDependencies.end(); ++dependIt) {
- out << " || choices['" << (*dependIt)->Name << "Choice'].selected";
- AddReverseDependencyAttributes(**dependIt, visited, out);
+ for (cmCPackComponent* depend : component.ReverseDependencies) {
+ out << " || choices['" << depend->Name << "Choice'].selected";
+ AddReverseDependencyAttributes(*depend, visited, out);
}
}
@@ -270,32 +253,33 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name,
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
const char* inFileName = this->GetOption(cpackVar);
if (!inFileName) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: "
- << cpackVar.c_str()
- << " not specified. It should point to "
- << (!name.empty() ? name : "<empty>") << ".rtf, " << name
- << ".html, or " << name << ".txt file" << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPack option: " << cpackVar.c_str()
+ << " not specified. It should point to "
+ << (!name.empty() ? name : "<empty>")
+ << ".rtf, " << name << ".html, or " << name
+ << ".txt file" << std::endl);
return false;
}
if (!cmSystemTools::FileExists(inFileName)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find "
- << (!name.empty() ? name : "<empty>")
- << " resource file: " << inFileName << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find " << (!name.empty() ? name : "<empty>")
+ << " resource file: " << inFileName
+ << std::endl);
return false;
}
std::string ext = cmSystemTools::GetFilenameLastExtension(inFileName);
if (ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt") {
cmCPackLogger(
- cmCPackLog::LOG_ERROR, "Bad file extension specified: "
+ cmCPackLog::LOG_ERROR,
+ "Bad file extension specified: "
<< ext
<< ". Currently only .rtfd, .rtf, .html, and .txt files allowed."
<< std::endl);
return false;
}
- std::string destFileName = dirName;
- destFileName += '/';
- destFileName += name + ext;
+ std::string destFileName = cmStrCat(dirName, '/', name, ext);
// Set this so that distribution.dist gets the right name (without
// the path).
@@ -305,7 +289,7 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name,
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Configure file: " << (inFileName ? inFileName : "(NULL)")
<< " to " << destFileName << std::endl);
- this->ConfigureFile(inFileName, destFileName.c_str());
+ this->ConfigureFile(inFileName, destFileName);
return true;
}
@@ -316,9 +300,7 @@ bool cmCPackPKGGenerator::CopyResourcePlistFile(const std::string& name,
outName = name.c_str();
}
- std::string inFName = "CPack.";
- inFName += name;
- inFName += ".in";
+ std::string inFName = cmStrCat("CPack.", name, ".in");
std::string inFileName = this->FindTemplate(inFName.c_str());
if (inFileName.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -326,13 +308,13 @@ bool cmCPackPKGGenerator::CopyResourcePlistFile(const std::string& name,
return false;
}
- std::string destFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- destFileName += "/";
- destFileName += outName;
+ std::string destFileName =
+ cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/', outName);
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
- << inFileName << " to " << destFileName << std::endl);
- this->ConfigureFile(inFileName.c_str(), destFileName.c_str());
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Configure file: " << inFileName << " to " << destFileName
+ << std::endl);
+ this->ConfigureFile(inFileName, destFileName);
return true;
}
@@ -340,9 +322,7 @@ int cmCPackPKGGenerator::CopyInstallScript(const std::string& resdir,
const std::string& script,
const std::string& name)
{
- std::string dst = resdir;
- dst += "/";
- dst += name;
+ std::string dst = cmStrCat(resdir, '/', name);
cmSystemTools::CopyFileAlways(script, dst);
cmSystemTools::SetPermissions(dst.c_str(), 0777);
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
diff --git a/Source/CPack/cmCPackPKGGenerator.h b/Source/CPack/cmCPackPKGGenerator.h
index f873c5936..69286ffde 100644
--- a/Source/CPack/cmCPackPKGGenerator.h
+++ b/Source/CPack/cmCPackPKGGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmCPackPKGGenerator_h
#define cmCPackPKGGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <set>
#include <sstream>
@@ -27,13 +27,13 @@ public:
* Construct generator
*/
cmCPackPKGGenerator();
- virtual ~cmCPackPKGGenerator();
+ ~cmCPackPKGGenerator() override;
- bool SupportsComponentInstallation() const CM_OVERRIDE;
+ bool SupportsComponentInstallation() const override;
protected:
- int InitializeInternal() CM_OVERRIDE;
- const char* GetOutputPostfix() CM_OVERRIDE { return "darwin"; }
+ int InitializeInternal() override;
+ const char* GetOutputPostfix() override { return "darwin"; }
// Copies or creates the resource file with the given name to the
// package or package staging directory dirName. The variable
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx
index 8db7cfb3d..c5ba726d5 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.cxx
+++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx
@@ -2,18 +2,21 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackPackageMakerGenerator.h"
-#include "cmsys/FStream.hxx"
-#include "cmsys/RegularExpression.hxx"
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
+#include <cstdlib>
#include <map>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
#include <string>
+#include "cmsys/FStream.hxx"
+#include "cmsys/RegularExpression.hxx"
+
#include "cmCPackComponentGroup.h"
#include "cmCPackLog.h"
+#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
@@ -29,9 +32,7 @@ cmCPackPackageMakerGenerator::cmCPackPackageMakerGenerator()
this->PackageCompatibilityVersion = getVersion(10, 4);
}
-cmCPackPackageMakerGenerator::~cmCPackPackageMakerGenerator()
-{
-}
+cmCPackPackageMakerGenerator::~cmCPackPackageMakerGenerator() = default;
bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const
{
@@ -48,8 +49,8 @@ int cmCPackPackageMakerGenerator::PackageFiles()
this->GetOption("CPACK_TEMPORARY_DIRECTORY");
if (this->Components.empty()) {
packageDirFileName += ".pkg";
- resDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- resDir += "/Resources";
+ resDir =
+ cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), "/Resources");
} else {
packageDirFileName += ".mpkg";
if (!cmsys::SystemTools::MakeDirectory(packageDirFileName.c_str())) {
@@ -59,8 +60,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
return 0;
}
- resDir = packageDirFileName;
- resDir += "/Contents";
+ resDir = cmStrCat(packageDirFileName, "/Contents");
if (!cmsys::SystemTools::MakeDirectory(resDir.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"unable to create package subdirectory " << resDir
@@ -156,8 +156,8 @@ int cmCPackPackageMakerGenerator::PackageFiles()
if (!this->Components.empty()) {
// Create the directory where component packages will be built.
- std::string basePackageDir = packageDirFileName;
- basePackageDir += "/Contents/Packages";
+ std::string basePackageDir =
+ cmStrCat(packageDirFileName, "/Contents/Packages");
if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating component packages directory: "
@@ -173,8 +173,8 @@ int cmCPackPackageMakerGenerator::PackageFiles()
if (userUploadDirectory && *userUploadDirectory) {
uploadDirectory = userUploadDirectory;
} else {
- uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
- uploadDirectory += "/CPackUploads";
+ uploadDirectory =
+ cmStrCat(this->GetOption("CPACK_PACKAGE_DIRECTORY"), "/CPackUploads");
}
// Create packages for each component
@@ -233,9 +233,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
packageFile += '/';
packageFile += GetPackageName(compIt->second);
- std::string packageDir = toplevel;
- packageDir += '/';
- packageDir += compIt->first;
+ std::string packageDir = cmStrCat(toplevel, '/', compIt->first);
if (!this->GenerateComponentPackage(
packageFile.c_str(), packageDir.c_str(), compIt->second)) {
return 0;
@@ -250,8 +248,8 @@ int cmCPackPackageMakerGenerator::PackageFiles()
!this->CopyCreateResourceFile("Welcome", resDir) ||
!this->CopyResourcePlistFile("Info.plist") ||
!this->CopyResourcePlistFile("Description.plist")) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem copying the resource files" << std::endl);
return 0;
}
@@ -275,28 +273,29 @@ int cmCPackPackageMakerGenerator::PackageFiles()
if (this->PackageMakerVersion > 2.0) {
pkgCmd << " -v";
}
- if (!RunPackageMaker(pkgCmd.str().c_str(), packageDirFileName.c_str()))
+ if (!RunPackageMaker(pkgCmd.str().c_str(), packageDirFileName.c_str())) {
return 0;
+ }
} else {
// We have built the package in place. Generate the
// distribution.dist file to describe it for the installer.
WriteDistributionFile(packageDirFileName.c_str());
}
- std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- tmpFile += "/hdiutilOutput.log";
+ std::string tmpFile = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"),
+ "/hdiutilOutput.log");
std::ostringstream dmgCmd;
dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
- << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName
- << "\" \"" << packageFileNames[0] << "\"";
+ << "\" create -ov -fs HFS+ -format UDZO -srcfolder \""
+ << packageDirFileName << "\" \"" << packageFileNames[0] << "\"";
std::string output;
int retVal = 1;
int numTries = 10;
bool res = false;
while (numTries > 0) {
- res =
- cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &output,
- &retVal, 0, this->GeneratorVerbose, 0);
+ res = cmSystemTools::RunSingleCommand(
+ dmgCmd.str(), &output, &output, &retVal, nullptr, this->GeneratorVerbose,
+ cmDuration::zero());
if (res && !retVal) {
numTries = -1;
break;
@@ -305,11 +304,12 @@ int cmCPackPackageMakerGenerator::PackageFiles()
numTries--;
}
if (!res || retVal) {
- cmGeneratedFileStream ofs(tmpFile.c_str());
+ cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << dmgCmd.str() << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: "
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem running hdiutil command: "
<< dmgCmd.str() << std::endl
<< "Please check " << tmpFile << " for errors"
<< std::endl);
@@ -337,16 +337,16 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
// If found, save result in the CPACK_INSTALLER_PROGRAM variable.
std::vector<std::string> paths;
- paths.push_back("/Applications/Xcode.app/Contents/Applications"
- "/PackageMaker.app/Contents/MacOS");
- paths.push_back("/Applications/Utilities"
- "/PackageMaker.app/Contents/MacOS");
- paths.push_back("/Applications"
- "/PackageMaker.app/Contents/MacOS");
- paths.push_back("/Developer/Applications/Utilities"
- "/PackageMaker.app/Contents/MacOS");
- paths.push_back("/Developer/Applications"
- "/PackageMaker.app/Contents/MacOS");
+ paths.emplace_back("/Applications/Xcode.app/Contents/Applications"
+ "/PackageMaker.app/Contents/MacOS");
+ paths.emplace_back("/Applications/Utilities"
+ "/PackageMaker.app/Contents/MacOS");
+ paths.emplace_back("/Applications"
+ "/PackageMaker.app/Contents/MacOS");
+ paths.emplace_back("/Developer/Applications/Utilities"
+ "/PackageMaker.app/Contents/MacOS");
+ paths.emplace_back("/Developer/Applications"
+ "/PackageMaker.app/Contents/MacOS");
std::string pkgPath;
const char* inst_program = this->GetOption("CPACK_INSTALLER_PROGRAM");
@@ -355,8 +355,8 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
} else {
pkgPath = cmSystemTools::FindProgram("PackageMaker", paths, false);
if (pkgPath.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find PackageMaker compiler" << std::endl);
return 0;
}
this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
@@ -413,12 +413,13 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
}
this->PackageMakerVersion = atof(rexVersion.match(1).c_str());
if (this->PackageMakerVersion < 1.0) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Require PackageMaker 1.0 or higher"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Require PackageMaker 1.0 or higher" << std::endl);
return 0;
}
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "PackageMaker version is: "
- << this->PackageMakerVersion << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "PackageMaker version is: " << this->PackageMakerVersion
+ << std::endl);
// Determine the package compatibility version. If it wasn't
// specified by the user, we define it based on which features the
@@ -446,8 +447,8 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
std::vector<std::string> no_paths;
pkgPath = cmSystemTools::FindProgram("hdiutil", no_paths, false);
if (pkgPath.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find hdiutil compiler" << std::endl);
return 0;
}
this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM_DISK_IMAGE",
@@ -459,25 +460,27 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
bool cmCPackPackageMakerGenerator::RunPackageMaker(const char* command,
const char* packageFile)
{
- std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- tmpFile += "/PackageMakerOutput.log";
+ std::string tmpFile = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"),
+ "/PackageMakerOutput.log");
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl);
std::string output;
int retVal = 1;
bool res = cmSystemTools::RunSingleCommand(
- command, &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker"
- << std::endl);
+ command, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
+ cmDuration::zero());
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Done running package maker" << std::endl);
if (!res || retVal) {
- cmGeneratedFileStream ofs(tmpFile.c_str());
+ cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << command << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
- cmCPackLogger(
- cmCPackLog::LOG_ERROR, "Problem running PackageMaker command: "
- << command << std::endl
- << "Please check " << tmpFile << " for errors" << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem running PackageMaker command: "
+ << command << std::endl
+ << "Please check " << tmpFile << " for errors"
+ << std::endl);
return false;
}
// sometimes the command finishes but the directory is not yet
@@ -502,8 +505,9 @@ bool cmCPackPackageMakerGenerator::GenerateComponentPackage(
const char* packageFile, const char* packageDir,
const cmCPackComponent& component)
{
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Building component package: "
- << packageFile << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "- Building component package: " << packageFile
+ << std::endl);
// The command that will be used to run PackageMaker
std::ostringstream pkgCmd;
@@ -512,8 +516,9 @@ bool cmCPackPackageMakerGenerator::GenerateComponentPackage(
this->PackageMakerVersion < 3.0) {
// Create Description.plist and Info.plist files for normal Mac OS
// X packages, which work on Mac OS X 10.3 and newer.
- std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- descriptionFile += '/' + component.Name + "-Description.plist";
+ std::string descriptionFile =
+ cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"), '/',
+ component.Name, "-Description.plist");
cmsys::ofstream out(descriptionFile.c_str());
cmXMLWriter xout(out);
xout.StartDocument();
@@ -534,12 +539,10 @@ bool cmCPackPackageMakerGenerator::GenerateComponentPackage(
out.close();
// Create the Info.plist file for this component
- std::string moduleVersionSuffix = ".";
- moduleVersionSuffix += component.Name;
+ std::string moduleVersionSuffix = cmStrCat('.', component.Name);
this->SetOption("CPACK_MODULE_VERSION_SUFFIX",
moduleVersionSuffix.c_str());
- std::string infoFileName = component.Name;
- infoFileName += "-Info.plist";
+ std::string infoFileName = cmStrCat(component.Name, "-Info.plist");
if (!this->CopyResourcePlistFile("Info.plist", infoFileName.c_str())) {
return false;
}
@@ -556,12 +559,9 @@ bool cmCPackPackageMakerGenerator::GenerateComponentPackage(
// like normal packages, and can be downloaded by the installer
// on-the-fly in Mac OS X 10.5 or newer. Thus, we need to create
// flat packages when the packages will be downloaded on the fly.
- std::string pkgId = "com.";
- pkgId += this->GetOption("CPACK_PACKAGE_VENDOR");
- pkgId += '.';
- pkgId += this->GetOption("CPACK_PACKAGE_NAME");
- pkgId += '.';
- pkgId += component.Name;
+ std::string pkgId =
+ cmStrCat("com.", this->GetOption("CPACK_PACKAGE_VENDOR"), '.',
+ this->GetOption("CPACK_PACKAGE_NAME"), '.', component.Name);
pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
<< "\" --root \"" << packageDir << "\""
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h
index 62745152b..0575587d5 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.h
+++ b/Source/CPack/cmCPackPackageMakerGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmCPackPackageMakerGenerator_h
#define cmCPackPackageMakerGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include "cmCPackGenerator.h"
#include "cmCPackPKGGenerator.h"
@@ -25,13 +25,13 @@ public:
* Construct generator
*/
cmCPackPackageMakerGenerator();
- virtual ~cmCPackPackageMakerGenerator();
- bool SupportsComponentInstallation() const CM_OVERRIDE;
+ ~cmCPackPackageMakerGenerator() override;
+ bool SupportsComponentInstallation() const override;
protected:
- int InitializeInternal() CM_OVERRIDE;
- int PackageFiles() CM_OVERRIDE;
- const char* GetOutputExtension() CM_OVERRIDE { return ".dmg"; }
+ int InitializeInternal() override;
+ int PackageFiles() override;
+ const char* GetOutputExtension() override { return ".dmg"; }
// Run PackageMaker with the given command line, which will (if
// successful) produce the given package file. Returns true if
diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx
index 1389eaa5a..dae268c5c 100644
--- a/Source/CPack/cmCPackProductBuildGenerator.cxx
+++ b/Source/CPack/cmCPackProductBuildGenerator.cxx
@@ -2,13 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackProductBuildGenerator.h"
+#include <cstddef>
#include <map>
#include <sstream>
-#include <stddef.h>
#include "cmCPackComponentGroup.h"
#include "cmCPackLog.h"
+#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
cmCPackProductBuildGenerator::cmCPackProductBuildGenerator()
@@ -16,9 +18,7 @@ cmCPackProductBuildGenerator::cmCPackProductBuildGenerator()
this->componentPackageMethod = ONE_PACKAGE;
}
-cmCPackProductBuildGenerator::~cmCPackProductBuildGenerator()
-{
-}
+cmCPackProductBuildGenerator::~cmCPackProductBuildGenerator() = default;
int cmCPackProductBuildGenerator::PackageFiles()
{
@@ -29,8 +29,8 @@ int cmCPackProductBuildGenerator::PackageFiles()
this->GetOption("CPACK_TEMPORARY_DIRECTORY");
// Create the directory where component packages will be built.
- std::string basePackageDir = packageDirFileName;
- basePackageDir += "/Contents/Packages";
+ std::string basePackageDir =
+ cmStrCat(packageDirFileName, "/Contents/Packages");
if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating component packages directory: "
@@ -42,9 +42,7 @@ int cmCPackProductBuildGenerator::PackageFiles()
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) {
- std::string packageDir = toplevel;
- packageDir += '/';
- packageDir += compIt->first;
+ std::string packageDir = cmStrCat(toplevel, '/', compIt->first);
if (!this->GenerateComponentPackage(basePackageDir,
GetPackageName(compIt->second),
packageDir, &compIt->second)) {
@@ -54,7 +52,7 @@ int cmCPackProductBuildGenerator::PackageFiles()
} else {
if (!this->GenerateComponentPackage(basePackageDir,
this->GetOption("CPACK_PACKAGE_NAME"),
- toplevel, NULL)) {
+ toplevel, nullptr)) {
return 0;
}
}
@@ -66,8 +64,8 @@ int cmCPackProductBuildGenerator::PackageFiles()
this->GetOption("CPACK_PRODUCTBUILD_RESOURCES_DIR");
if (!cmSystemTools::CopyADirectory(userResDir, resDir)) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Problem copying the resource files" << std::endl);
return 0;
}
}
@@ -120,16 +118,16 @@ int cmCPackProductBuildGenerator::InitializeInternal()
std::string program =
cmSystemTools::FindProgram("pkgbuild", no_paths, false);
if (program.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find pkgbuild executable"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find pkgbuild executable" << std::endl);
return 0;
}
this->SetOptionIfNotSet("CPACK_COMMAND_PKGBUILD", program.c_str());
program = cmSystemTools::FindProgram("productbuild", no_paths, false);
if (program.empty()) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find productbuild executable"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot find productbuild executable" << std::endl);
return 0;
}
this->SetOptionIfNotSet("CPACK_COMMAND_PRODUCTBUILD", program.c_str());
@@ -139,18 +137,18 @@ int cmCPackProductBuildGenerator::InitializeInternal()
bool cmCPackProductBuildGenerator::RunProductBuild(const std::string& command)
{
- std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
- tmpFile += "/ProductBuildOutput.log";
+ std::string tmpFile = cmStrCat(this->GetOption("CPACK_TOPLEVEL_DIRECTORY"),
+ "/ProductBuildOutput.log");
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl);
- std::string output, error_output;
+ std::string output;
int retVal = 1;
- bool res =
- cmSystemTools::RunSingleCommand(command.c_str(), &output, &error_output,
- &retVal, 0, this->GeneratorVerbose, 0);
+ bool res = cmSystemTools::RunSingleCommand(
+ command, &output, &output, &retVal, nullptr, this->GeneratorVerbose,
+ cmDuration::zero());
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running command" << std::endl);
if (!res || retVal) {
- cmGeneratedFileStream ofs(tmpFile.c_str());
+ cmGeneratedFileStream ofs(tmpFile);
ofs << "# Run command: " << command << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
@@ -167,14 +165,13 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
const std::string& packageFileDir, const std::string& packageFileName,
const std::string& packageDir, const cmCPackComponent* component)
{
- std::string packageFile = packageFileDir;
- packageFile += '/';
- packageFile += packageFileName;
+ std::string packageFile = cmStrCat(packageFileDir, '/', packageFileName);
- cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Building component package: "
- << packageFile << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "- Building component package: " << packageFile
+ << std::endl);
- const char* comp_name = component ? component->Name.c_str() : NULL;
+ const char* comp_name = component ? component->Name.c_str() : nullptr;
const char* preflight = this->GetComponentScript("PREFLIGHT", comp_name);
const char* postflight = this->GetComponentScript("POSTFLIGHT", comp_name);
@@ -190,7 +187,7 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating installer directory: " << scriptDir
<< std::endl);
- return 0;
+ return false;
}
// if preflight, postflight, or postupgrade are set
@@ -206,10 +203,8 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
// The command that will be used to run ProductBuild
std::ostringstream pkgCmd;
- std::string pkgId = "com.";
- pkgId += this->GetOption("CPACK_PACKAGE_VENDOR");
- pkgId += '.';
- pkgId += this->GetOption("CPACK_PACKAGE_NAME");
+ std::string pkgId = cmStrCat("com.", this->GetOption("CPACK_PACKAGE_VENDOR"),
+ '.', this->GetOption("CPACK_PACKAGE_NAME"));
if (component) {
pkgId += '.';
pkgId += component->Name;
diff --git a/Source/CPack/cmCPackProductBuildGenerator.h b/Source/CPack/cmCPackProductBuildGenerator.h
index 12093a0e8..015fe4ace 100644
--- a/Source/CPack/cmCPackProductBuildGenerator.h
+++ b/Source/CPack/cmCPackProductBuildGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmCPackProductBuildGenerator_h
#define cmCPackProductBuildGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
@@ -25,12 +25,12 @@ public:
* Construct generator
*/
cmCPackProductBuildGenerator();
- virtual ~cmCPackProductBuildGenerator();
+ ~cmCPackProductBuildGenerator() override;
protected:
- int InitializeInternal() CM_OVERRIDE;
- int PackageFiles() CM_OVERRIDE;
- const char* GetOutputExtension() CM_OVERRIDE { return ".pkg"; }
+ int InitializeInternal() override;
+ int PackageFiles() override;
+ const char* GetOutputExtension() override { return ".pkg"; }
// Run ProductBuild with the given command line, which will (if
// successful) produce the given package file. Returns true if
diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx
index 8ec03c236..0c1cecf39 100644
--- a/Source/CPack/cmCPackRPMGenerator.cxx
+++ b/Source/CPack/cmCPackRPMGenerator.cxx
@@ -3,7 +3,7 @@
#include "cmCPackRPMGenerator.h"
#include <algorithm>
-#include <ctype.h>
+#include <cctype>
#include <map>
#include <ostream>
#include <utility>
@@ -12,20 +12,17 @@
#include "cmCPackComponentGroup.h"
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-cmCPackRPMGenerator::cmCPackRPMGenerator()
-{
-}
+cmCPackRPMGenerator::cmCPackRPMGenerator() = default;
-cmCPackRPMGenerator::~cmCPackRPMGenerator()
-{
-}
+cmCPackRPMGenerator::~cmCPackRPMGenerator() = default;
int cmCPackRPMGenerator::InitializeInternal()
{
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
- if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) {
+ if (cmIsOff(this->GetOption("CPACK_SET_DESTDIR"))) {
this->SetOption("CPACK_SET_DESTDIR", "I_ON");
}
/* Replace space in CPACK_PACKAGE_NAME in order to avoid
@@ -85,13 +82,12 @@ int cmCPackRPMGenerator::PackageOnePack(std::string const& initialToplevel,
// Tell CPackRPM.cmake the name of the component NAME.
this->SetOption("CPACK_RPM_PACKAGE_COMPONENT", packageName.c_str());
// Tell CPackRPM.cmake the path where the component is.
- std::string component_path = "/";
- component_path += packageName;
+ std::string component_path = cmStrCat('/', packageName);
this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str());
- if (!this->ReadListFile("CPackRPM.cmake")) {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake"
- << std::endl);
+ if (!this->ReadListFile("Internal/CPack/CPackRPM.cmake")) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error while execution CPackRPM.cmake" << std::endl);
retval = 0;
}
@@ -148,7 +144,7 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
for (compIt = this->Components.begin();
compIt != this->Components.end(); ++compIt) {
// Does the component belong to a group?
- if (compIt->second.Group == CM_NULLPTR) {
+ if (compIt->second.Group == nullptr) {
std::string component(compIt->first);
std::transform(component.begin(), component.end(),
component.begin(), ::toupper);
@@ -165,7 +161,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
}
if (shouldSet) {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Setting "
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Setting "
<< "CPACK_RPM_DEBUGINFO_PACKAGE because "
<< "CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE is set but "
<< " none of the "
@@ -187,8 +184,7 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
if (!ignoreGroup) {
- std::map<std::string, cmCPackComponentGroup>::iterator mainCompGIt =
- this->ComponentGroups.end();
+ auto mainCompGIt = this->ComponentGroups.end();
std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
for (compGIt = this->ComponentGroups.begin();
@@ -203,18 +199,18 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
continue;
}
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
- << compGIt->first << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Packaging component group: " << compGIt->first
+ << std::endl);
retval &= PackageOnePack(initialTopLevel, compGIt->first);
}
// Handle Orphan components (components not belonging to any groups)
- std::map<std::string, cmCPackComponent>::iterator mainCompIt =
- this->Components.end();
+ auto mainCompIt = this->Components.end();
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) {
// Does the component belong to a group?
- if (compIt->second.Group == CM_NULLPTR) {
+ if (compIt->second.Group == nullptr) {
std::string component(compIt->first);
std::transform(component.begin(), component.end(), component.begin(),
::toupper);
@@ -226,7 +222,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
}
cmCPackLogger(
- cmCPackLog::LOG_VERBOSE, "Component <"
+ cmCPackLog::LOG_VERBOSE,
+ "Component <"
<< compIt->second.Name
<< "> does not belong to any group, package it separately."
<< std::endl);
@@ -242,7 +239,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
} else if (mainCompIt != this->Components.end()) {
retval &= PackageOnePack(initialTopLevel, mainCompIt->first);
} else {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_RPM_MAIN_COMPONENT set"
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_RPM_MAIN_COMPONENT set"
<< " to non existing component.\n");
retval = 0;
}
@@ -251,8 +249,7 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
// CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component
else {
- std::map<std::string, cmCPackComponent>::iterator mainCompIt =
- this->Components.end();
+ auto mainCompIt = this->Components.end();
std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end();
@@ -276,7 +273,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
if (mainCompIt != this->Components.end()) {
retval &= PackageOnePack(initialTopLevel, mainCompIt->first);
} else {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_RPM_MAIN_COMPONENT set"
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "CPACK_RPM_MAIN_COMPONENT set"
<< " to non existing component.\n");
retval = 0;
}
@@ -290,8 +288,9 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
for (compGIt = this->ComponentGroups.begin();
compGIt != this->ComponentGroups.end(); ++compGIt) {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
- << compGIt->first << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Packaging component group: " << compGIt->first
+ << std::endl);
retval &= PackageOnePack(initialTopLevel, compGIt->first);
}
// Handle Orphan components (components not belonging to any groups)
@@ -299,9 +298,10 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) {
// Does the component belong to a group?
- if (compIt->second.Group == CM_NULLPTR) {
+ if (compIt->second.Group == nullptr) {
cmCPackLogger(
- cmCPackLog::LOG_VERBOSE, "Component <"
+ cmCPackLog::LOG_VERBOSE,
+ "Component <"
<< compIt->second.Name
<< "> does not belong to any group, package it separately."
<< std::endl);
@@ -320,7 +320,8 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
}
} else {
cmCPackLogger(
- cmCPackLog::LOG_ERROR, "CPACK_RPM_MAIN_COMPONENT not set but"
+ cmCPackLog::LOG_ERROR,
+ "CPACK_RPM_MAIN_COMPONENT not set but"
<< " it is mandatory with CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE"
<< " being set.\n");
retval = 0;
@@ -371,17 +372,16 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne(
if (!compInstDirName.empty()) {
// Tell CPackRPM.cmake the path where the component is.
- std::string component_path = "/";
- component_path += compInstDirName;
+ std::string component_path = cmStrCat('/', compInstDirName);
this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str());
}
- if (this->ReadListFile("CPackRPM.cmake")) {
+ if (this->ReadListFile("Internal/CPack/CPackRPM.cmake")) {
AddGeneratedPackageNames();
} else {
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake"
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error while execution CPackRPM.cmake" << std::endl);
retval = 0;
}
@@ -430,7 +430,7 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(
// the current COMPONENT belongs to.
std::string groupVar =
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
- if (CM_NULLPTR != GetOption(groupVar)) {
+ if (nullptr != GetOption(groupVar)) {
return std::string(GetOption(groupVar));
}
return componentName;
diff --git a/Source/CPack/cmCPackRPMGenerator.h b/Source/CPack/cmCPackRPMGenerator.h
index 52cfc13ed..075ce8458 100644
--- a/Source/CPack/cmCPackRPMGenerator.h
+++ b/Source/CPack/cmCPackRPMGenerator.h
@@ -3,12 +3,12 @@
#ifndef cmCPackRPMGenerator_h
#define cmCPackRPMGenerator_h
-#include "cmConfigure.h"
-
-#include "cmCPackGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include "cmCPackGenerator.h"
+
/** \class cmCPackRPMGenerator
* \brief A generator for RPM packages
* The idea of the CPack RPM generator is to use
@@ -26,7 +26,7 @@ public:
* Construct generator
*/
cmCPackRPMGenerator();
- ~cmCPackRPMGenerator() CM_OVERRIDE;
+ ~cmCPackRPMGenerator() override;
static bool CanGenerate()
{
@@ -43,8 +43,8 @@ public:
}
protected:
- int InitializeInternal() CM_OVERRIDE;
- int PackageFiles() CM_OVERRIDE;
+ int InitializeInternal() override;
+ int PackageFiles() override;
/**
* This method factors out the work done in component packaging case.
*/
@@ -61,10 +61,10 @@ protected:
* components will be put in a single installer.
*/
int PackageComponentsAllInOne(const std::string& compInstDirName);
- const char* GetOutputExtension() CM_OVERRIDE { return ".rpm"; }
- bool SupportsComponentInstallation() const CM_OVERRIDE;
+ const char* GetOutputExtension() override { return ".rpm"; }
+ bool SupportsComponentInstallation() const override;
std::string GetComponentInstallDirNameSuffix(
- const std::string& componentName) CM_OVERRIDE;
+ const std::string& componentName) override;
void AddGeneratedPackageNames();
};
diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx
index c54161426..a4a5e6fcd 100644
--- a/Source/CPack/cmCPackSTGZGenerator.cxx
+++ b/Source/CPack/cmCPackSTGZGenerator.cxx
@@ -2,24 +2,26 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackSTGZGenerator.h"
-#include "cmsys/FStream.hxx"
+#include <cstdio>
#include <sstream>
-#include <stdio.h>
#include <string>
#include <vector>
+#include "cmsys/FStream.hxx"
+
+#include "cm_sys_stat.h"
+
+#include "cmArchiveWrite.h"
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
#include "cmSystemTools.h"
-#include "cm_sys_stat.h"
cmCPackSTGZGenerator::cmCPackSTGZGenerator()
+ : cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, "paxr", ".sh")
{
}
-cmCPackSTGZGenerator::~cmCPackSTGZGenerator()
-{
-}
+cmCPackSTGZGenerator::~cmCPackSTGZGenerator() = default;
int cmCPackSTGZGenerator::InitializeInternal()
{
@@ -48,9 +50,8 @@ int cmCPackSTGZGenerator::PackageFiles()
* have generated several packages (component packaging)
* so we must iterate over generated packages.
*/
- for (std::vector<std::string>::iterator it = packageFileNames.begin();
- it != packageFileNames.end(); ++it) {
- retval &= cmSystemTools::SetPermissions((*it).c_str(),
+ for (std::string const& pfn : packageFileNames) {
+ retval &= cmSystemTools::SetPermissions(pfn.c_str(),
#if defined(_MSC_VER) || defined(__MINGW32__)
S_IREAD | S_IWRITE | S_IEXEC
#else
@@ -58,7 +59,7 @@ int cmCPackSTGZGenerator::PackageFiles()
S_IRGRP | S_IWGRP | S_IXGRP |
S_IROTH | S_IWOTH | S_IXOTH
#endif
- );
+ );
}
return retval;
}
@@ -102,8 +103,8 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
++ptr;
}
counter++;
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Number of lines: " << counter
- << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Number of lines: " << counter << std::endl);
char buffer[1024];
sprintf(buffer, "%d", counter);
cmSystemTools::ReplaceString(res, headerLengthTag, buffer);
diff --git a/Source/CPack/cmCPackSTGZGenerator.h b/Source/CPack/cmCPackSTGZGenerator.h
index 8304e8076..79d7035e1 100644
--- a/Source/CPack/cmCPackSTGZGenerator.h
+++ b/Source/CPack/cmCPackSTGZGenerator.h
@@ -3,33 +3,32 @@
#ifndef cmCPackSTGZGenerator_h
#define cmCPackSTGZGenerator_h
-#include "cmConfigure.h"
-
-#include "cmCPackGenerator.h"
-#include "cmCPackTGZGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
+#include "cmCPackArchiveGenerator.h"
+#include "cmCPackGenerator.h"
+
/** \class cmCPackSTGZGenerator
* \brief A generator for Self extractable TGZ files
*
*/
-class cmCPackSTGZGenerator : public cmCPackTGZGenerator
+class cmCPackSTGZGenerator : public cmCPackArchiveGenerator
{
public:
- cmCPackTypeMacro(cmCPackSTGZGenerator, cmCPackTGZGenerator);
+ cmCPackTypeMacro(cmCPackSTGZGenerator, cmCPackArchiveGenerator);
/**
* Construct generator
*/
cmCPackSTGZGenerator();
- ~cmCPackSTGZGenerator() CM_OVERRIDE;
+ ~cmCPackSTGZGenerator() override;
protected:
- int PackageFiles() CM_OVERRIDE;
- int InitializeInternal() CM_OVERRIDE;
- int GenerateHeader(std::ostream* os) CM_OVERRIDE;
- const char* GetOutputExtension() CM_OVERRIDE { return ".sh"; }
+ int PackageFiles() override;
+ int InitializeInternal() override;
+ int GenerateHeader(std::ostream* os) override;
};
#endif
diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx
deleted file mode 100644
index eaf8186fe..000000000
--- a/Source/CPack/cmCPackTGZGenerator.cxx
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmCPackTGZGenerator.h"
-
-#include "cmArchiveWrite.h"
-#include "cmCPackArchiveGenerator.h"
-
-cmCPackTGZGenerator::cmCPackTGZGenerator()
- : cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, "paxr")
-{
-}
-
-cmCPackTGZGenerator::~cmCPackTGZGenerator()
-{
-}
diff --git a/Source/CPack/cmCPackTGZGenerator.h b/Source/CPack/cmCPackTGZGenerator.h
deleted file mode 100644
index 9426b3a01..000000000
--- a/Source/CPack/cmCPackTGZGenerator.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmCPackTGZGenerator_h
-#define cmCPackTGZGenerator_h
-
-#include "cmConfigure.h"
-
-#include "cmCPackArchiveGenerator.h"
-#include "cmCPackGenerator.h"
-
-/** \class cmCPackTGZGenerator
- * \brief A generator for TGZ files
- *
- */
-class cmCPackTGZGenerator : public cmCPackArchiveGenerator
-{
-public:
- cmCPackTypeMacro(cmCPackTGZGenerator, cmCPackArchiveGenerator);
- /**
- * Construct generator
- */
- cmCPackTGZGenerator();
- ~cmCPackTGZGenerator() CM_OVERRIDE;
-
-protected:
- const char* GetOutputExtension() CM_OVERRIDE { return ".tar.gz"; }
-};
-
-#endif
diff --git a/Source/CPack/cmCPackTXZGenerator.cxx b/Source/CPack/cmCPackTXZGenerator.cxx
deleted file mode 100644
index e55e903e9..000000000
--- a/Source/CPack/cmCPackTXZGenerator.cxx
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmCPackTXZGenerator.h"
-
-#include "cmArchiveWrite.h"
-#include "cmCPackArchiveGenerator.h"
-
-cmCPackTXZGenerator::cmCPackTXZGenerator()
- : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr")
-{
-}
-
-cmCPackTXZGenerator::~cmCPackTXZGenerator()
-{
-}
diff --git a/Source/CPack/cmCPackTXZGenerator.h b/Source/CPack/cmCPackTXZGenerator.h
deleted file mode 100644
index 3b96e2d78..000000000
--- a/Source/CPack/cmCPackTXZGenerator.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmCPackTXZGenerator_h
-#define cmCPackTXZGenerator_h
-
-#include "cmConfigure.h"
-
-#include "cmCPackArchiveGenerator.h"
-#include "cmCPackGenerator.h"
-
-/** \class cmCPackTXZGenerator
- * \brief A generator for TXZ files
- *
- */
-class cmCPackTXZGenerator : public cmCPackArchiveGenerator
-{
-public:
- cmCPackTypeMacro(cmCPackTXZGenerator, cmCPackArchiveGenerator);
- /**
- * Construct generator
- */
- cmCPackTXZGenerator();
- ~cmCPackTXZGenerator() CM_OVERRIDE;
-
-protected:
- const char* GetOutputExtension() CM_OVERRIDE { return ".tar.xz"; }
-};
-
-#endif
diff --git a/Source/CPack/cmCPackTarBZip2Generator.cxx b/Source/CPack/cmCPackTarBZip2Generator.cxx
deleted file mode 100644
index c7a3dd429..000000000
--- a/Source/CPack/cmCPackTarBZip2Generator.cxx
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmCPackTarBZip2Generator.h"
-
-#include "cmArchiveWrite.h"
-#include "cmCPackArchiveGenerator.h"
-
-cmCPackTarBZip2Generator::cmCPackTarBZip2Generator()
- : cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, "paxr")
-{
-}
-
-cmCPackTarBZip2Generator::~cmCPackTarBZip2Generator()
-{
-}
diff --git a/Source/CPack/cmCPackTarBZip2Generator.h b/Source/CPack/cmCPackTarBZip2Generator.h
deleted file mode 100644
index 9b4b8f4ff..000000000
--- a/Source/CPack/cmCPackTarBZip2Generator.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmCPackTarBZip2Generator_h
-#define cmCPackTarBZip2Generator_h
-
-#include "cmConfigure.h"
-
-#include "cmCPackArchiveGenerator.h"
-#include "cmCPackGenerator.h"
-
-/** \class cmCPackTarBZip2Generator
- * \brief A generator for TarBZip2 files
- */
-class cmCPackTarBZip2Generator : public cmCPackArchiveGenerator
-{
-public:
- cmCPackTypeMacro(cmCPackTarBZip2Generator, cmCPackArchiveGenerator);
- /**
- * Construct generator
- */
- cmCPackTarBZip2Generator();
- ~cmCPackTarBZip2Generator() CM_OVERRIDE;
-
-protected:
- const char* GetOutputExtension() CM_OVERRIDE { return ".tar.bz2"; }
-};
-
-#endif
diff --git a/Source/CPack/cmCPackTarCompressGenerator.cxx b/Source/CPack/cmCPackTarCompressGenerator.cxx
deleted file mode 100644
index 0a7cd978c..000000000
--- a/Source/CPack/cmCPackTarCompressGenerator.cxx
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmCPackTarCompressGenerator.h"
-
-#include "cmArchiveWrite.h"
-#include "cmCPackArchiveGenerator.h"
-
-cmCPackTarCompressGenerator::cmCPackTarCompressGenerator()
- : cmCPackArchiveGenerator(cmArchiveWrite::CompressCompress, "paxr")
-{
-}
-
-cmCPackTarCompressGenerator::~cmCPackTarCompressGenerator()
-{
-}
diff --git a/Source/CPack/cmCPackTarCompressGenerator.h b/Source/CPack/cmCPackTarCompressGenerator.h
deleted file mode 100644
index 381d6eb2f..000000000
--- a/Source/CPack/cmCPackTarCompressGenerator.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmCPackTarCompressGenerator_h
-#define cmCPackTarCompressGenerator_h
-
-#include "cmConfigure.h"
-
-#include "cmCPackArchiveGenerator.h"
-#include "cmCPackGenerator.h"
-
-/** \class cmCPackTarCompressGenerator
- * \brief A generator for TarCompress files
- */
-class cmCPackTarCompressGenerator : public cmCPackArchiveGenerator
-{
-public:
- cmCPackTypeMacro(cmCPackTarCompressGenerator, cmCPackArchiveGenerator);
- /**
- * Construct generator
- */
- cmCPackTarCompressGenerator();
- ~cmCPackTarCompressGenerator() CM_OVERRIDE;
-
-protected:
- const char* GetOutputExtension() CM_OVERRIDE { return ".tar.Z"; }
-};
-
-#endif
diff --git a/Source/CPack/cmCPackZIPGenerator.cxx b/Source/CPack/cmCPackZIPGenerator.cxx
deleted file mode 100644
index 6b77c363d..000000000
--- a/Source/CPack/cmCPackZIPGenerator.cxx
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmCPackZIPGenerator.h"
-
-#include "cmArchiveWrite.h"
-#include "cmCPackArchiveGenerator.h"
-
-cmCPackZIPGenerator::cmCPackZIPGenerator()
- : cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "zip")
-{
-}
-
-cmCPackZIPGenerator::~cmCPackZIPGenerator()
-{
-}
diff --git a/Source/CPack/cmCPackZIPGenerator.h b/Source/CPack/cmCPackZIPGenerator.h
deleted file mode 100644
index 00c872029..000000000
--- a/Source/CPack/cmCPackZIPGenerator.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmCPackZIPGenerator_h
-#define cmCPackZIPGenerator_h
-
-#include "cmConfigure.h"
-
-#include "cmCPackArchiveGenerator.h"
-#include "cmCPackGenerator.h"
-
-/** \class cmCPackZIPGenerator
- * \brief A generator for ZIP files
- */
-class cmCPackZIPGenerator : public cmCPackArchiveGenerator
-{
-public:
- cmCPackTypeMacro(cmCPackZIPGenerator, cmCPackArchiveGenerator);
-
- /**
- * Construct generator
- */
- cmCPackZIPGenerator();
- ~cmCPackZIPGenerator() CM_OVERRIDE;
-
-protected:
- const char* GetOutputExtension() CM_OVERRIDE { return ".zip"; }
-};
-
-#endif
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index a44bc3d68..58956522f 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -1,55 +1,63 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmConfigure.h"
#include "cmsys/CommandLineArguments.hxx"
#include "cmsys/Encoding.hxx"
-#include <iostream>
-#include <map>
-#include <sstream>
-#include <stddef.h>
-#include <string>
-#include <utility>
-#include <vector>
-
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmsys/ConsoleBuf.hxx"
-#endif
#include "cmCPackGenerator.h"
#include "cmCPackGeneratorFactory.h"
#include "cmCPackLog.h"
#include "cmDocumentation.h"
#include "cmDocumentationEntry.h"
+#include "cmDocumentationFormatter.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmState.h"
#include "cmStateSnapshot.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
-static const char* cmDocumentationName[][2] = {
- { CM_NULLPTR, " cpack - Packaging driver provided by CMake." },
- { CM_NULLPTR, CM_NULLPTR }
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
+# include "cmsys/ConsoleBuf.hxx"
+#endif
+
+#include <cstddef>
+#include <iostream>
+#include <map>
+#include <memory>
+#include <sstream>
+#include <string>
+#include <utility>
+#include <vector>
+
+namespace {
+const char* cmDocumentationName[][2] = {
+ { nullptr, " cpack - Packaging driver provided by CMake." },
+ { nullptr, nullptr }
};
-static const char* cmDocumentationUsage[][2] = {
- { CM_NULLPTR, " cpack -G <generator> [options]" },
- { CM_NULLPTR, CM_NULLPTR }
+const char* cmDocumentationUsage[][2] = {
+ // clang-format off
+ { nullptr, " cpack [options]" },
+ { nullptr, nullptr }
+ // clang-format on
};
-static const char* cmDocumentationOptions[][2] = {
- { "-G <generator>", "Use the specified generator to generate package." },
+const char* cmDocumentationOptions[][2] = {
+ { "-G <generators>", "Override/define CPACK_GENERATOR" },
{ "-C <Configuration>", "Specify the project configuration" },
{ "-D <var>=<value>", "Set a CPack variable." },
- { "--config <config file>", "Specify the config file." },
- { "--verbose,-V", "enable verbose output" },
- { "--debug", "enable debug output (for CPack developers)" },
- { "-P <package name>", "override/define CPACK_PACKAGE_NAME" },
- { "-R <package version>", "override/define CPACK_PACKAGE_VERSION" },
- { "-B <package directory>", "override/define CPACK_PACKAGE_DIRECTORY" },
- { "--vendor <vendor name>", "override/define CPACK_PACKAGE_VENDOR" },
- { CM_NULLPTR, CM_NULLPTR }
+ { "--config <configFile>", "Specify the config file." },
+ { "--verbose,-V", "Enable verbose output" },
+ { "--trace", "Put underlying cmake scripts in trace mode." },
+ { "--trace-expand", "Put underlying cmake scripts in expanded trace mode." },
+ { "--debug", "Enable debug output (for CPack developers)" },
+ { "-P <packageName>", "Override/define CPACK_PACKAGE_NAME" },
+ { "-R <packageVersion>", "Override/define CPACK_PACKAGE_VERSION" },
+ { "-B <packageDirectory>", "Override/define CPACK_PACKAGE_DIRECTORY" },
+ { "--vendor <vendorName>", "Override/define CPACK_PACKAGE_VENDOR" },
+ { nullptr, nullptr }
};
int cpackUnknownArgument(const char* /*unused*/, void* /*unused*/)
@@ -59,7 +67,7 @@ int cpackUnknownArgument(const char* /*unused*/, void* /*unused*/)
struct cpackDefinitions
{
- typedef std::map<std::string, std::string> MapType;
+ using MapType = std::map<std::string, std::string>;
MapType Map;
cmCPackLog* Log;
};
@@ -77,17 +85,25 @@ int cpackDefinitionArgument(const char* argument, const char* cValue,
return 0;
}
std::string key = value.substr(0, pos);
- value = value.c_str() + pos + 1;
+ value = value.substr(pos + 1);
def->Map[key] = value;
- cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: "
- << key << " to \"" << value << "\"" << std::endl);
+ cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG,
+ "Set CPack variable: " << key << " to \"" << value << "\""
+ << std::endl);
return 1;
}
+void cpackProgressCallback(const std::string& message, float /*unused*/)
+{
+ std::cout << "-- " << message << std::endl;
+}
+} // namespace
+
// this is CPack.
int main(int argc, char const* const* argv)
{
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+ cmSystemTools::EnsureStdPipes();
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
// Replace streambuf so we can output Unicode to console
cmsys::ConsoleBuf::Manager consoleOut(std::cout);
consoleOut.SetUTF8Pipes();
@@ -99,6 +115,8 @@ int main(int argc, char const* const* argv)
argc = args.argc();
argv = args.argv();
+ cmSystemTools::EnableMSVCDebugHook();
+ cmSystemTools::InitializeLibUV();
cmSystemTools::FindCMakeResources(argv[0]);
cmCPackLog log;
@@ -107,8 +125,6 @@ int main(int argc, char const* const* argv)
log.SetOutputPrefix("CPack: ");
log.SetVerbosePrefix("CPack Verbose: ");
- cmSystemTools::EnableMSVCDebugHook();
-
if (cmSystemTools::GetCurrentWorkingDirectory().empty()) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Current working directory cannot be established."
@@ -120,6 +136,8 @@ int main(int argc, char const* const* argv)
bool help = false;
bool helpVersion = false;
bool verbose = false;
+ bool trace = false;
+ bool traceExpand = false;
bool debug = false;
std::string helpFull;
std::string helpMAN;
@@ -136,11 +154,11 @@ int main(int argc, char const* const* argv)
cpackDefinitions definitions;
definitions.Log = &log;
- cpackConfigFile = "";
+ cpackConfigFile.clear();
cmsys::CommandLineArguments arg;
arg.Initialize(argc, argv);
- typedef cmsys::CommandLineArguments argT;
+ using argT = cmsys::CommandLineArguments;
// Help arguments
arg.AddArgument("--help", argT::NO_ARGUMENT, &help, "CPack help");
arg.AddArgument("--help-full", argT::SPACE_ARGUMENT, &helpFull,
@@ -155,6 +173,10 @@ int main(int argc, char const* const* argv)
arg.AddArgument("--debug", argT::NO_ARGUMENT, &debug, "-V");
arg.AddArgument("--config", argT::SPACE_ARGUMENT, &cpackConfigFile,
"CPack configuration file");
+ arg.AddArgument("--trace", argT::NO_ARGUMENT, &trace,
+ "Put underlying cmake scripts in trace mode.");
+ arg.AddArgument("--trace-expand", argT::NO_ARGUMENT, &traceExpand,
+ "Put underlying cmake scripts in expanded trace mode.");
arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig,
"CPack build configuration");
arg.AddArgument("-G", argT::SPACE_ARGUMENT, &generator, "CPack generator");
@@ -188,27 +210,34 @@ int main(int argc, char const* const* argv)
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Read CPack config file: " << cpackConfigFile << std::endl);
- cmake cminst(cmake::RoleScript);
+ cmake cminst(cmake::RoleScript, cmState::CPack);
cminst.SetHomeDirectory("");
cminst.SetHomeOutputDirectory("");
+ cminst.SetProgressCallback(cpackProgressCallback);
cminst.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator cmgg(&cminst);
- CM_AUTO_PTR<cmMakefile> globalMF(
- new cmMakefile(&cmgg, cminst.GetCurrentSnapshot()));
+ cmMakefile globalMF(&cmgg, cminst.GetCurrentSnapshot());
#if defined(__CYGWIN__)
- globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
+ globalMF.AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
#endif
+ if (trace) {
+ cminst.SetTrace(true);
+ }
+ if (traceExpand) {
+ cminst.SetTrace(true);
+ cminst.SetTraceExpand(true);
+ }
+
bool cpackConfigFileSpecified = true;
if (cpackConfigFile.empty()) {
- cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory();
- cpackConfigFile += "/CPackConfig.cmake";
+ cpackConfigFile = cmStrCat(cmSystemTools::GetCurrentWorkingDirectory(),
+ "/CPackConfig.cmake");
cpackConfigFileSpecified = false;
}
cmCPackGeneratorFactory generators;
generators.SetLogger(&log);
- cmCPackGenerator* cpackGenerator = CM_NULLPTR;
cmDocumentation doc;
doc.addCPackStandardDocSections();
@@ -226,16 +255,16 @@ int main(int argc, char const* const* argv)
// find out which system cpack is running on, so it can setup the search
// paths, so FIND_XXX() commands can be used in scripts
std::string systemFile =
- globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
- if (!globalMF->ReadListFile(systemFile.c_str())) {
+ globalMF.GetModulesFile("CMakeDetermineSystem.cmake");
+ if (!globalMF.ReadListFile(systemFile)) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error reading CMakeDetermineSystem.cmake" << std::endl);
return 1;
}
systemFile =
- globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
- if (!globalMF->ReadListFile(systemFile.c_str())) {
+ globalMF.GetModulesFile("CMakeSystemSpecificInformation.cmake");
+ if (!globalMF.ReadListFile(systemFile)) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error reading CMakeSystemSpecificInformation.cmake"
<< std::endl);
@@ -243,15 +272,15 @@ int main(int argc, char const* const* argv)
}
if (!cpackBuildConfig.empty()) {
- globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
+ globalMF.AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig);
}
- if (cmSystemTools::FileExists(cpackConfigFile.c_str())) {
+ if (cmSystemTools::FileExists(cpackConfigFile)) {
cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Read CPack configuration file: " << cpackConfigFile
<< std::endl);
- if (!globalMF->ReadListFile(cpackConfigFile.c_str())) {
+ if (!globalMF.ReadListFile(cpackConfigFile)) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Problem reading CPack config file: \""
<< cpackConfigFile << "\"" << std::endl);
@@ -265,58 +294,49 @@ int main(int argc, char const* const* argv)
}
if (!generator.empty()) {
- globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str());
+ globalMF.AddDefinition("CPACK_GENERATOR", generator);
}
if (!cpackProjectName.empty()) {
- globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
+ globalMF.AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName);
}
if (!cpackProjectVersion.empty()) {
- globalMF->AddDefinition("CPACK_PACKAGE_VERSION",
- cpackProjectVersion.c_str());
+ globalMF.AddDefinition("CPACK_PACKAGE_VERSION", cpackProjectVersion);
}
if (!cpackProjectVendor.empty()) {
- globalMF->AddDefinition("CPACK_PACKAGE_VENDOR",
- cpackProjectVendor.c_str());
+ globalMF.AddDefinition("CPACK_PACKAGE_VENDOR", cpackProjectVendor);
}
// if this is not empty it has been set on the command line
// go for it. Command line override values set in config file.
if (!cpackProjectDirectory.empty()) {
- globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
- cpackProjectDirectory.c_str());
+ globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY", cpackProjectDirectory);
}
// The value has not been set on the command line
else {
// get a default value (current working directory)
cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory();
// use default value iff no value has been provided by the config file
- if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY")) {
- globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
- cpackProjectDirectory.c_str());
+ if (!globalMF.IsSet("CPACK_PACKAGE_DIRECTORY")) {
+ globalMF.AddDefinition("CPACK_PACKAGE_DIRECTORY",
+ cpackProjectDirectory);
}
}
- cpackDefinitions::MapType::iterator cdit;
- for (cdit = definitions.Map.begin(); cdit != definitions.Map.end();
- ++cdit) {
- globalMF->AddDefinition(cdit->first, cdit->second.c_str());
+ for (auto const& cd : definitions.Map) {
+ globalMF.AddDefinition(cd.first, cd.second);
}
- const char* cpackModulesPath =
- globalMF->GetDefinition("CPACK_MODULE_PATH");
+ const char* cpackModulesPath = globalMF.GetDefinition("CPACK_MODULE_PATH");
if (cpackModulesPath) {
- globalMF->AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath);
+ globalMF.AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath);
}
- const char* genList = globalMF->GetDefinition("CPACK_GENERATOR");
+ const char* genList = globalMF.GetDefinition("CPACK_GENERATOR");
if (!genList) {
- cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified"
- << std::endl);
+ cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
+ "CPack generator not specified" << std::endl);
} else {
- std::vector<std::string> generatorsVector;
- cmSystemTools::ExpandListArgument(genList, generatorsVector);
- std::vector<std::string>::iterator it;
- for (it = generatorsVector.begin(); it != generatorsVector.end(); ++it) {
- const char* gen = it->c_str();
- cmMakefile::ScopePushPop raii(globalMF.get());
- cmMakefile* mf = globalMF.get();
+ std::vector<std::string> generatorsVector = cmExpandedList(genList);
+ for (std::string const& gen : generatorsVector) {
+ cmMakefile::ScopePushPop raii(&globalMF);
+ cmMakefile* mf = &globalMF;
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Specified generator: " << gen << std::endl);
if (parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME")) {
@@ -340,13 +360,31 @@ int main(int argc, char const* const* argv)
parsed = 0;
}
if (parsed) {
- cpackGenerator = generators.NewGenerator(gen);
- if (!cpackGenerator) {
+ std::unique_ptr<cmCPackGenerator> cpackGenerator =
+ generators.NewGenerator(gen);
+ if (cpackGenerator) {
+ cpackGenerator->SetTrace(trace);
+ cpackGenerator->SetTraceExpand(traceExpand);
+ } else {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Cannot initialize CPack generator: " << gen
- << std::endl);
+ "Could not create CPack generator: " << gen
+ << std::endl);
+ // Print out all the valid generators
+ cmDocumentation generatorDocs;
+ std::vector<cmDocumentationEntry> v;
+ for (auto const& g : generators.GetGeneratorsList()) {
+ cmDocumentationEntry e;
+ e.Name = g.first;
+ e.Brief = g.second;
+ v.push_back(std::move(e));
+ }
+ generatorDocs.SetSection("Generators", v);
+ std::cerr << "\n";
+ generatorDocs.PrintDocumentation(cmDocumentation::ListGenerators,
+ std::cerr);
parsed = 0;
}
+
if (parsed && !cpackGenerator->Initialize(gen, mf)) {
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Cannot initialize the generator " << gen
@@ -355,21 +393,23 @@ int main(int argc, char const* const* argv)
}
if (!mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
+ !mf->GetDefinition("CPACK_INSTALL_SCRIPT") &&
!mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
!mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS")) {
cmCPack_Log(
&log, cmCPackLog::LOG_ERROR,
"Please specify build tree of the project that uses CMake "
"using CPACK_INSTALL_CMAKE_PROJECTS, specify "
- "CPACK_INSTALL_COMMANDS, or specify "
+ "CPACK_INSTALL_COMMANDS, CPACK_INSTALL_SCRIPT, or "
"CPACK_INSTALLED_DIRECTORIES."
<< std::endl);
parsed = 0;
}
if (parsed) {
const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
- cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
- << cpackGenerator->GetNameOfClass() << std::endl);
+ cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
+ "Use generator: " << cpackGenerator->GetNameOfClass()
+ << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"For project: " << projName << std::endl);
@@ -385,7 +425,7 @@ int main(int argc, char const* const* argv)
std::ostringstream ostr;
ostr << projVersionMajor << "." << projVersionMinor << "."
<< projVersionPatch;
- mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str().c_str());
+ mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str());
}
int res = cpackGenerator->DoPackage();
@@ -414,13 +454,11 @@ int main(int argc, char const* const* argv)
doc.PrependSection("Options", cmDocumentationOptions);
std::vector<cmDocumentationEntry> v;
- cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt;
- for (generatorIt = generators.GetGeneratorsList().begin();
- generatorIt != generators.GetGeneratorsList().end(); ++generatorIt) {
+ for (auto const& g : generators.GetGeneratorsList()) {
cmDocumentationEntry e;
- e.Name = generatorIt->first;
- e.Brief = generatorIt->second;
- v.push_back(e);
+ e.Name = g.first;
+ e.Brief = g.second;
+ v.push_back(std::move(e));
}
doc.SetSection("Generators", v);
diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx
index 94f39c265..8640c46f8 100644
--- a/Source/CTest/cmCTestBZR.cxx
+++ b/Source/CTest/cmCTestBZR.cxx
@@ -2,20 +2,23 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestBZR.h"
+#include <cstdlib>
+#include <list>
+#include <map>
+#include <ostream>
+#include <vector>
+
+#include "cmsys/RegularExpression.hxx"
+
+#include "cm_expat.h"
+
+#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestVC.h"
#include "cmProcessTools.h"
#include "cmSystemTools.h"
#include "cmXMLParser.h"
-#include "cm_expat.h"
-#include "cmsys/RegularExpression.hxx"
-#include <list>
-#include <map>
-#include <ostream>
-#include <stdlib.h>
-#include <vector>
-
extern "C" int cmBZRXMLParserUnknownEncodingHandler(void* /*unused*/,
const XML_Char* name,
XML_Encoding* info)
@@ -77,9 +80,7 @@ cmCTestBZR::cmCTestBZR(cmCTest* ct, std::ostream& log)
cmSystemTools::PutEnv("BZR_PROGRESS_BAR=none");
}
-cmCTestBZR::~cmCTestBZR()
-{
-}
+cmCTestBZR::~cmCTestBZR() = default;
class cmCTestBZR::InfoParser : public cmCTestVC::LineParser
{
@@ -98,7 +99,7 @@ private:
bool CheckOutFound;
cmsys::RegularExpression RegexCheckOut;
cmsys::RegularExpression RegexParent;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexCheckOut.find(this->Line)) {
this->BZR->URL = this->RegexCheckOut.match(1);
@@ -123,7 +124,7 @@ public:
private:
std::string& Rev;
cmsys::RegularExpression RegexRevno;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexRevno.find(this->Line)) {
this->Rev = this->RegexRevno.match(1);
@@ -136,13 +137,13 @@ std::string cmCTestBZR::LoadInfo()
{
// Run "bzr info" to get the repository info from the work tree.
const char* bzr = this->CommandLineTool.c_str();
- const char* bzr_info[] = { bzr, "info", CM_NULLPTR };
+ const char* bzr_info[] = { bzr, "info", nullptr };
InfoParser iout(this, "info-out> ");
OutputLogger ierr(this->Log, "info-err> ");
this->RunChild(bzr_info, &iout, &ierr);
// Run "bzr revno" to get the repository revision number from the work tree.
- const char* bzr_revno[] = { bzr, "revno", CM_NULLPTR };
+ const char* bzr_revno[] = { bzr, "revno", nullptr };
std::string rev;
RevnoParser rout(this, "revno-out> ", rev);
OutputLogger rerr(this->Log, "revno-err> ");
@@ -155,8 +156,9 @@ bool cmCTestBZR::NoteOldRevision()
{
this->OldRevision = this->LoadInfo();
this->Log << "Revision before update: " << this->OldRevision << "\n";
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
- << this->OldRevision << "\n");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " Old revision of repository is: " << this->OldRevision
+ << "\n");
this->PriorRev.Rev = this->OldRevision;
return true;
}
@@ -165,14 +167,16 @@ bool cmCTestBZR::NoteNewRevision()
{
this->NewRevision = this->LoadInfo();
this->Log << "Revision after update: " << this->NewRevision << "\n";
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
- << this->NewRevision << "\n");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " New revision of repository is: " << this->NewRevision
+ << "\n");
this->Log << "URL = " << this->URL << "\n";
return true;
}
-class cmCTestBZR::LogParser : public cmCTestVC::OutputLogger,
- private cmXMLParser
+class cmCTestBZR::LogParser
+ : public cmCTestVC::OutputLogger
+ , private cmXMLParser
{
public:
LogParser(cmCTestBZR* bzr, const char* prefix)
@@ -182,15 +186,15 @@ public:
{
this->InitializeParser();
}
- ~LogParser() CM_OVERRIDE { this->CleanupParser(); }
+ ~LogParser() override { this->CleanupParser(); }
- int InitializeParser() CM_OVERRIDE
+ int InitializeParser() override
{
int res = cmXMLParser::InitializeParser();
if (res) {
XML_SetUnknownEncodingHandler(static_cast<XML_Parser>(this->Parser),
cmBZRXMLParserUnknownEncodingHandler,
- CM_NULLPTR);
+ nullptr);
}
return res;
}
@@ -198,8 +202,8 @@ public:
private:
cmCTestBZR* BZR;
- typedef cmCTestBZR::Revision Revision;
- typedef cmCTestBZR::Change Change;
+ using Revision = cmCTestBZR::Revision;
+ using Change = cmCTestBZR::Change;
Revision Rev;
std::vector<Change> Changes;
Change CurChange;
@@ -207,14 +211,14 @@ private:
cmsys::RegularExpression EmailRegex;
- bool ProcessChunk(const char* data, int length) CM_OVERRIDE
+ bool ProcessChunk(const char* data, int length) override
{
this->OutputLogger::ProcessChunk(data, length);
this->ParseChunk(data, length);
return true;
}
- void StartElement(const std::string& name, const char** /*atts*/) CM_OVERRIDE
+ void StartElement(const std::string& name, const char** /*atts*/) override
{
this->CData.clear();
if (name == "log") {
@@ -239,12 +243,12 @@ private:
}
}
- void CharacterDataHandler(const char* data, int length) CM_OVERRIDE
+ void CharacterDataHandler(const char* data, int length) override
{
- this->CData.insert(this->CData.end(), data, data + length);
+ cmAppend(this->CData, data, data + length);
}
- void EndElement(const std::string& name) CM_OVERRIDE
+ void EndElement(const std::string& name) override
{
if (name == "log") {
this->BZR->DoRevision(this->Rev, this->Changes);
@@ -274,7 +278,7 @@ private:
this->CData.clear();
}
- void ReportError(int /*line*/, int /*column*/, const char* msg) CM_OVERRIDE
+ void ReportError(int /*line*/, int /*column*/, const char* msg) override
{
this->BZR->Log << "Error parsing bzr log xml: " << msg << "\n";
}
@@ -294,7 +298,7 @@ private:
cmCTestBZR* BZR;
cmsys::RegularExpression RegexUpdate;
- bool ProcessChunk(const char* first, int length) CM_OVERRIDE
+ bool ProcessChunk(const char* first, int length) override
{
bool last_is_new_line = (*first == '\r' || *first == '\n');
@@ -309,11 +313,11 @@ private:
// Hand this line to the subclass implementation.
if (!this->ProcessLine()) {
- this->Line = "";
+ this->Line.clear();
return false;
}
- this->Line = "";
+ this->Line.clear();
last_is_new_line = true;
}
} else {
@@ -325,7 +329,7 @@ private:
return true;
}
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexUpdate.find(this->Line)) {
this->DoPath(this->RegexUpdate.match(1)[0],
@@ -364,7 +368,7 @@ bool cmCTestBZR::UpdateImpl()
if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions");
}
- std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
+ std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
// TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
@@ -373,14 +377,13 @@ bool cmCTestBZR::UpdateImpl()
bzr_update.push_back(this->CommandLineTool.c_str());
bzr_update.push_back("pull");
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- bzr_update.push_back(ai->c_str());
+ for (std::string const& arg : args) {
+ bzr_update.push_back(arg.c_str());
}
bzr_update.push_back(this->URL.c_str());
- bzr_update.push_back(CM_NULLPTR);
+ bzr_update.push_back(nullptr);
// For some reason bzr uses stderr to display the update status.
OutputLogger out(this->Log, "pull-out> ");
@@ -408,8 +411,7 @@ bool cmCTestBZR::LoadRevisions()
// Run "bzr log" to get all global revisions of interest.
const char* bzr = this->CommandLineTool.c_str();
const char* bzr_log[] = {
- bzr, "log", "-v", "-r", revs.c_str(), "--xml", this->URL.c_str(),
- CM_NULLPTR
+ bzr, "log", "-v", "-r", revs.c_str(), "--xml", this->URL.c_str(), nullptr
};
{
LogParser out(this, "log-out> ");
@@ -433,7 +435,7 @@ public:
private:
cmCTestBZR* BZR;
cmsys::RegularExpression RegexStatus;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexStatus.find(this->Line)) {
this->DoPath(this->RegexStatus.match(1)[0],
@@ -467,7 +469,7 @@ bool cmCTestBZR::LoadModifications()
{
// Run "bzr status" which reports local modifications.
const char* bzr = this->CommandLineTool.c_str();
- const char* bzr_status[] = { bzr, "status", "-SV", CM_NULLPTR };
+ const char* bzr_status[] = { bzr, "status", "-SV", nullptr };
StatusParser out(this, "status-out> ");
OutputLogger err(this->Log, "status-err> ");
this->RunChild(bzr_status, &out, &err);
diff --git a/Source/CTest/cmCTestBZR.h b/Source/CTest/cmCTestBZR.h
index 2e8e88f95..d7c632128 100644
--- a/Source/CTest/cmCTestBZR.h
+++ b/Source/CTest/cmCTestBZR.h
@@ -3,13 +3,13 @@
#ifndef cmCTestBZR_h
#define cmCTestBZR_h
-#include "cmConfigure.h"
-
-#include "cmCTestGlobalVC.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
+#include "cmCTestGlobalVC.h"
+
class cmCTest;
/** \class cmCTestBZR
@@ -22,20 +22,20 @@ public:
/** Construct with a CTest instance and update log stream. */
cmCTestBZR(cmCTest* ctest, std::ostream& log);
- ~cmCTestBZR() CM_OVERRIDE;
+ ~cmCTestBZR() override;
private:
// Implement cmCTestVC internal API.
- bool NoteOldRevision() CM_OVERRIDE;
- bool NoteNewRevision() CM_OVERRIDE;
- bool UpdateImpl() CM_OVERRIDE;
+ bool NoteOldRevision() override;
+ bool NoteNewRevision() override;
+ bool UpdateImpl() override;
// URL of repository directory checked out in the working tree.
std::string URL;
std::string LoadInfo();
- bool LoadModifications() CM_OVERRIDE;
- bool LoadRevisions() CM_OVERRIDE;
+ bool LoadModifications() override;
+ bool LoadRevisions() override;
// Parsing helper classes.
class InfoParser;
diff --git a/Source/CTest/cmCTestBatchTestHandler.cxx b/Source/CTest/cmCTestBatchTestHandler.cxx
deleted file mode 100644
index beee53a13..000000000
--- a/Source/CTest/cmCTestBatchTestHandler.cxx
+++ /dev/null
@@ -1,125 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmCTestBatchTestHandler.h"
-
-#include "cmCTest.h"
-#include "cmCTestMultiProcessHandler.h"
-#include "cmCTestTestHandler.h"
-#include "cmProcess.h"
-#include "cmSystemTools.h"
-
-#include <map>
-#include <utility>
-#include <vector>
-
-cmCTestBatchTestHandler::~cmCTestBatchTestHandler()
-{
-}
-
-void cmCTestBatchTestHandler::RunTests()
-{
- this->WriteBatchScript();
- this->SubmitBatchScript();
-}
-
-void cmCTestBatchTestHandler::WriteBatchScript()
-{
- this->Script = this->CTest->GetBinaryDir() + "/Testing/CTestBatch.txt";
- cmsys::ofstream fout;
- fout.open(this->Script.c_str());
- fout << "#!/bin/sh\n";
-
- for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
- ++i) {
- this->WriteSrunArgs(i->first, fout);
- this->WriteTestCommand(i->first, fout);
- fout << "\n";
- }
- fout.flush();
- fout.close();
-}
-
-void cmCTestBatchTestHandler::WriteSrunArgs(int test, std::ostream& fout)
-{
- cmCTestTestHandler::cmCTestTestProperties* properties =
- this->Properties[test];
-
- fout << "srun ";
- // fout << "--jobid=" << test << " ";
- fout << "-J=" << properties->Name << " ";
-
- // Write dependency information
- /*if(!this->Tests[test].empty())
- {
- fout << "-P=afterany";
- for(TestSet::iterator i = this->Tests[test].begin();
- i != this->Tests[test].end(); ++i)
- {
- fout << ":" << *i;
- }
- fout << " ";
- }*/
- if (properties->RunSerial) {
- fout << "--exclusive ";
- }
- if (properties->Processors > 1) {
- fout << "-n" << properties->Processors << " ";
- }
-}
-
-void cmCTestBatchTestHandler::WriteTestCommand(int test, std::ostream& fout)
-{
- std::vector<std::string> args = this->Properties[test]->Args;
- std::vector<std::string> processArgs;
- std::string command;
-
- command = this->TestHandler->FindTheExecutable(args[1].c_str());
- command = cmSystemTools::ConvertToOutputPath(command.c_str());
-
- // Prepends memcheck args to our command string if this is a memcheck
- this->TestHandler->GenerateTestCommand(processArgs, test);
- processArgs.push_back(command);
-
- for (std::vector<std::string>::iterator arg = processArgs.begin();
- arg != processArgs.end(); ++arg) {
- fout << *arg << " ";
- }
-
- std::vector<std::string>::iterator i = args.begin();
- ++i; // the test name
- ++i; // the executable (command)
- if (args.size() > 2) {
- fout << "'";
- }
- while (i != args.end()) {
- fout << "\"" << *i << "\""; // args to the test executable
- ++i;
-
- if (i == args.end() && args.size() > 2) {
- fout << "'";
- }
- fout << " ";
- }
- // TODO ZACH build TestResult.FullCommandLine
- // this->TestResult.FullCommandLine = this->TestCommand;
-}
-
-void cmCTestBatchTestHandler::SubmitBatchScript()
-{
- cmProcess sbatch;
- std::vector<std::string> args;
- args.push_back(this->Script);
- args.push_back("-o");
- args.push_back(this->CTest->GetBinaryDir() + "/Testing/CTestBatch.txt");
-
- sbatch.SetCommand("sbatch");
- sbatch.SetCommandArguments(args);
- /*if(sbatch.StartProcess())
- {
- //success condition
- }
- else
- {
- //fail condition
- }*/
-}
diff --git a/Source/CTest/cmCTestBatchTestHandler.h b/Source/CTest/cmCTestBatchTestHandler.h
deleted file mode 100644
index 4a5dac1d6..000000000
--- a/Source/CTest/cmCTestBatchTestHandler.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmCTestBatchTestHandler_h
-#define cmCTestBatchTestHandler_h
-
-#include "cmConfigure.h"
-
-#include "cmCTestMultiProcessHandler.h"
-#include "cmsys/FStream.hxx"
-#include <string>
-
-/** \class cmCTestBatchTestHandler
- * \brief run parallel ctest
- *
- * cmCTestBatchTestHandler
- */
-class cmCTestBatchTestHandler : public cmCTestMultiProcessHandler
-{
-public:
- ~cmCTestBatchTestHandler() CM_OVERRIDE;
- void RunTests() CM_OVERRIDE;
-
-protected:
- void WriteBatchScript();
- void WriteSrunArgs(int test, std::ostream& fout);
- void WriteTestCommand(int test, std::ostream& fout);
-
- void SubmitBatchScript();
-
- std::string Script;
-};
-
-#endif
diff --git a/Source/CTest/cmCTestBinPacker.cxx b/Source/CTest/cmCTestBinPacker.cxx
new file mode 100644
index 000000000..e21b14dd7
--- /dev/null
+++ b/Source/CTest/cmCTestBinPacker.cxx
@@ -0,0 +1,203 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmCTestBinPacker.h"
+
+#include <algorithm>
+#include <utility>
+
+bool cmCTestBinPackerAllocation::operator==(
+ const cmCTestBinPackerAllocation& other) const
+{
+ return this->ProcessIndex == other.ProcessIndex &&
+ this->SlotsNeeded == other.SlotsNeeded && this->Id == other.Id;
+}
+
+bool cmCTestBinPackerAllocation::operator!=(
+ const cmCTestBinPackerAllocation& other) const
+{
+ return !(*this == other);
+}
+
+namespace {
+
+/*
+ * The following algorithm is used to do two things:
+ *
+ * 1) Determine if a test's resource requirements can fit within the resources
+ * present on the system, and
+ * 2) Do the actual allocation
+ *
+ * This algorithm performs a recursive search, looking for a bin pack that will
+ * fit the specified requirements. It has a template to specify different
+ * optimization strategies. If it ever runs out of room, it backtracks as far
+ * down the stack as it needs to and tries a different combination until no
+ * more combinations can be tried.
+ */
+template <typename AllocationStrategy>
+static bool AllocateCTestResources(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
+ const std::vector<std::string>& resourcesSorted, std::size_t currentIndex,
+ std::vector<cmCTestBinPackerAllocation*>& allocations)
+{
+ // Iterate through all large enough resources until we find a solution
+ std::size_t resourceIndex = 0;
+ while (resourceIndex < resourcesSorted.size()) {
+ auto const& resource = resources.at(resourcesSorted[resourceIndex]);
+ if (resource.Free() >=
+ static_cast<unsigned int>(allocations[currentIndex]->SlotsNeeded)) {
+ // Preemptively allocate the resource
+ allocations[currentIndex]->Id = resourcesSorted[resourceIndex];
+ if (currentIndex + 1 >= allocations.size()) {
+ // We have a solution
+ return true;
+ }
+
+ // Move the resource up the list until it is sorted again
+ auto resources2 = resources;
+ auto resourcesSorted2 = resourcesSorted;
+ resources2[resourcesSorted2[resourceIndex]].Locked +=
+ allocations[currentIndex]->SlotsNeeded;
+ AllocationStrategy::IncrementalSort(resources2, resourcesSorted2,
+ resourceIndex);
+
+ // Recurse one level deeper
+ if (AllocateCTestResources<AllocationStrategy>(
+ resources2, resourcesSorted2, currentIndex + 1, allocations)) {
+ return true;
+ }
+ }
+
+ // No solution found here, deallocate the resource and try the next one
+ allocations[currentIndex]->Id.clear();
+ auto freeSlots = resources.at(resourcesSorted.at(resourceIndex)).Free();
+ do {
+ ++resourceIndex;
+ } while (resourceIndex < resourcesSorted.size() &&
+ resources.at(resourcesSorted.at(resourceIndex)).Free() ==
+ freeSlots);
+ }
+
+ // No solution was found
+ return false;
+}
+
+template <typename AllocationStrategy>
+static bool AllocateCTestResources(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
+ std::vector<cmCTestBinPackerAllocation>& allocations)
+{
+ // Sort the resource requirements in descending order by slots needed
+ std::vector<cmCTestBinPackerAllocation*> allocationsPtr;
+ allocationsPtr.reserve(allocations.size());
+ for (auto& allocation : allocations) {
+ allocationsPtr.push_back(&allocation);
+ }
+ std::stable_sort(
+ allocationsPtr.rbegin(), allocationsPtr.rend(),
+ [](cmCTestBinPackerAllocation* a1, cmCTestBinPackerAllocation* a2) {
+ return a1->SlotsNeeded < a2->SlotsNeeded;
+ });
+
+ // Sort the resources according to sort strategy
+ std::vector<std::string> resourcesSorted;
+ resourcesSorted.reserve(resources.size());
+ for (auto const& res : resources) {
+ resourcesSorted.push_back(res.first);
+ }
+ AllocationStrategy::InitialSort(resources, resourcesSorted);
+
+ // Do the actual allocation
+ return AllocateCTestResources<AllocationStrategy>(
+ resources, resourcesSorted, std::size_t(0), allocationsPtr);
+}
+
+class RoundRobinAllocationStrategy
+{
+public:
+ static void InitialSort(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
+ std::vector<std::string>& resourcesSorted);
+
+ static void IncrementalSort(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
+ std::vector<std::string>& resourcesSorted, std::size_t lastAllocatedIndex);
+};
+
+void RoundRobinAllocationStrategy::InitialSort(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
+ std::vector<std::string>& resourcesSorted)
+{
+ std::stable_sort(
+ resourcesSorted.rbegin(), resourcesSorted.rend(),
+ [&resources](const std::string& id1, const std::string& id2) {
+ return resources.at(id1).Free() < resources.at(id2).Free();
+ });
+}
+
+void RoundRobinAllocationStrategy::IncrementalSort(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
+ std::vector<std::string>& resourcesSorted, std::size_t lastAllocatedIndex)
+{
+ auto tmp = resourcesSorted[lastAllocatedIndex];
+ std::size_t i = lastAllocatedIndex;
+ while (i < resourcesSorted.size() - 1 &&
+ resources.at(resourcesSorted[i + 1]).Free() >
+ resources.at(tmp).Free()) {
+ resourcesSorted[i] = resourcesSorted[i + 1];
+ ++i;
+ }
+ resourcesSorted[i] = tmp;
+}
+
+class BlockAllocationStrategy
+{
+public:
+ static void InitialSort(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
+ std::vector<std::string>& resourcesSorted);
+
+ static void IncrementalSort(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
+ std::vector<std::string>& resourcesSorted, std::size_t lastAllocatedIndex);
+};
+
+void BlockAllocationStrategy::InitialSort(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
+ std::vector<std::string>& resourcesSorted)
+{
+ std::stable_sort(
+ resourcesSorted.rbegin(), resourcesSorted.rend(),
+ [&resources](const std::string& id1, const std::string& id2) {
+ return resources.at(id1).Free() < resources.at(id2).Free();
+ });
+}
+
+void BlockAllocationStrategy::IncrementalSort(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>&,
+ std::vector<std::string>& resourcesSorted, std::size_t lastAllocatedIndex)
+{
+ auto tmp = resourcesSorted[lastAllocatedIndex];
+ std::size_t i = lastAllocatedIndex;
+ while (i > 0) {
+ resourcesSorted[i] = resourcesSorted[i - 1];
+ --i;
+ }
+ resourcesSorted[i] = tmp;
+}
+}
+
+bool cmAllocateCTestResourcesRoundRobin(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
+ std::vector<cmCTestBinPackerAllocation>& allocations)
+{
+ return AllocateCTestResources<RoundRobinAllocationStrategy>(resources,
+ allocations);
+}
+
+bool cmAllocateCTestResourcesBlock(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
+ std::vector<cmCTestBinPackerAllocation>& allocations)
+{
+ return AllocateCTestResources<BlockAllocationStrategy>(resources,
+ allocations);
+}
diff --git a/Source/CTest/cmCTestBinPacker.h b/Source/CTest/cmCTestBinPacker.h
new file mode 100644
index 000000000..ff02b8565
--- /dev/null
+++ b/Source/CTest/cmCTestBinPacker.h
@@ -0,0 +1,31 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmCTestBinPacker_h
+#define cmCTestBinPacker_h
+
+#include <cstddef>
+#include <map>
+#include <string>
+#include <vector>
+
+#include "cmCTestResourceAllocator.h"
+
+struct cmCTestBinPackerAllocation
+{
+ std::size_t ProcessIndex;
+ int SlotsNeeded;
+ std::string Id;
+
+ bool operator==(const cmCTestBinPackerAllocation& other) const;
+ bool operator!=(const cmCTestBinPackerAllocation& other) const;
+};
+
+bool cmAllocateCTestResourcesRoundRobin(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
+ std::vector<cmCTestBinPackerAllocation>& allocations);
+
+bool cmAllocateCTestResourcesBlock(
+ const std::map<std::string, cmCTestResourceAllocator::Resource>& resources,
+ std::vector<cmCTestBinPackerAllocation>& allocations);
+
+#endif
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index cc290715c..2ad661cf0 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -2,22 +2,29 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestBuildAndTestHandler.h"
+#include <chrono>
+#include <cstdlib>
+#include <cstring>
+#include <ratio>
+
+#include "cmsys/Process.h"
+
#include "cmCTest.h"
#include "cmCTestTestHandler.h"
#include "cmGlobalGenerator.h"
+#include "cmMakefile.h"
+#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
#include "cmake.h"
-#include "cmsys/Process.h"
-#include <stdlib.h>
-
cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler()
{
this->BuildTwoConfig = false;
this->BuildNoClean = false;
this->BuildNoCMake = false;
- this->Timeout = 0;
+ this->Timeout = cmDuration::zero();
}
void cmCTestBuildAndTestHandler::Initialize()
@@ -32,7 +39,7 @@ const char* cmCTestBuildAndTestHandler::GetOutput()
}
int cmCTestBuildAndTestHandler::ProcessHandler()
{
- this->Output = "";
+ this->Output.clear();
std::string output;
cmSystemTools::ResetErrorOccuredFlag();
int retv = this->RunCMakeAndTest(&this->Output);
@@ -45,27 +52,20 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
std::string& cmakeOutString,
cmake* cm)
{
- unsigned int k;
std::vector<std::string> args;
args.push_back(cmSystemTools::GetCMakeCommand());
args.push_back(this->SourceDir);
if (!this->BuildGenerator.empty()) {
- std::string generator = "-G";
- generator += this->BuildGenerator;
- args.push_back(generator);
+ args.push_back("-G" + this->BuildGenerator);
}
if (!this->BuildGeneratorPlatform.empty()) {
- std::string platform = "-A";
- platform += this->BuildGeneratorPlatform;
- args.push_back(platform);
+ args.push_back("-A" + this->BuildGeneratorPlatform);
}
if (!this->BuildGeneratorToolset.empty()) {
- std::string toolset = "-T";
- toolset += this->BuildGeneratorToolset;
- args.push_back(toolset);
+ args.push_back("-T" + this->BuildGeneratorToolset);
}
- const char* config = CM_NULLPTR;
+ const char* config = nullptr;
if (!this->CTest->GetConfigType().empty()) {
config = this->CTest->GetConfigType().c_str();
}
@@ -76,12 +76,16 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
#endif
if (config) {
- std::string btype = "-DCMAKE_BUILD_TYPE:STRING=" + std::string(config);
- args.push_back(btype);
+ args.push_back("-DCMAKE_BUILD_TYPE:STRING=" + std::string(config));
+ }
+ if (!this->BuildMakeProgram.empty() &&
+ (this->BuildGenerator.find("Make") != std::string::npos ||
+ this->BuildGenerator.find("Ninja") != std::string::npos)) {
+ args.push_back("-DCMAKE_MAKE_PROGRAM:FILEPATH=" + this->BuildMakeProgram);
}
- for (k = 0; k < this->BuildOptions.size(); ++k) {
- args.push_back(this->BuildOptions[k]);
+ for (std::string const& opt : this->BuildOptions) {
+ args.push_back(opt);
}
if (cm->Run(args) != 0) {
out << "Error: cmake execution failed\n";
@@ -112,27 +116,6 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
return 0;
}
-void CMakeMessageCallback(const char* m, const char* /*unused*/,
- bool& /*unused*/, void* s)
-{
- std::string* out = (std::string*)s;
- *out += m;
- *out += "\n";
-}
-
-void CMakeProgressCallback(const char* msg, float /*unused*/, void* s)
-{
- std::string* out = (std::string*)s;
- *out += msg;
- *out += "\n";
-}
-
-void CMakeOutputCallback(const char* m, size_t len, void* s)
-{
- std::string* out = (std::string*)s;
- out->append(m, len);
-}
-
class cmCTestBuildAndTestCaptureRAII
{
cmake& CM;
@@ -141,18 +124,35 @@ public:
cmCTestBuildAndTestCaptureRAII(cmake& cm, std::string& s)
: CM(cm)
{
- cmSystemTools::SetMessageCallback(CMakeMessageCallback, &s);
- cmSystemTools::SetStdoutCallback(CMakeOutputCallback, &s);
- cmSystemTools::SetStderrCallback(CMakeOutputCallback, &s);
- this->CM.SetProgressCallback(CMakeProgressCallback, &s);
+ cmSystemTools::SetMessageCallback(
+ [&s](const std::string& msg, const char* /*unused*/) {
+ s += msg;
+ s += "\n";
+ });
+
+ cmSystemTools::SetStdoutCallback([&s](std::string const& m) { s += m; });
+ cmSystemTools::SetStderrCallback([&s](std::string const& m) { s += m; });
+
+ this->CM.SetProgressCallback([&s](const std::string& msg, float prog) {
+ if (prog < 0) {
+ s += msg;
+ s += "\n";
+ }
+ });
}
+
~cmCTestBuildAndTestCaptureRAII()
{
- this->CM.SetProgressCallback(CM_NULLPTR, CM_NULLPTR);
- cmSystemTools::SetStderrCallback(CM_NULLPTR, CM_NULLPTR);
- cmSystemTools::SetStdoutCallback(CM_NULLPTR, CM_NULLPTR);
- cmSystemTools::SetMessageCallback(CM_NULLPTR, CM_NULLPTR);
+ this->CM.SetProgressCallback(nullptr);
+ cmSystemTools::SetStderrCallback(nullptr);
+ cmSystemTools::SetStdoutCallback(nullptr);
+ cmSystemTools::SetMessageCallback(nullptr);
}
+
+ cmCTestBuildAndTestCaptureRAII(const cmCTestBuildAndTestCaptureRAII&) =
+ delete;
+ cmCTestBuildAndTestCaptureRAII& operator=(
+ const cmCTestBuildAndTestCaptureRAII&) = delete;
};
int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
@@ -167,7 +167,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
return 1;
}
- cmake cm(cmake::RoleProject);
+ cmake cm(cmake::RoleProject, cmState::Project);
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
std::string cmakeOutString;
@@ -193,21 +193,36 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
// we need to honor the timeout specified, the timeout include cmake, build
// and test time
- double clock_start = cmSystemTools::GetTime();
+ auto clock_start = std::chrono::steady_clock::now();
// make sure the binary dir is there
out << "Internal cmake changing into directory: " << this->BinaryDir
<< std::endl;
if (!cmSystemTools::FileIsDirectory(this->BinaryDir)) {
- cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
+ cmSystemTools::MakeDirectory(this->BinaryDir);
}
cmWorkingDirectory workdir(this->BinaryDir);
+ if (workdir.Failed()) {
+ auto msg = "Failed to change working directory to " + this->BinaryDir +
+ " : " + std::strerror(workdir.GetLastResult()) + "\n";
+ if (outstring) {
+ *outstring = msg;
+ } else {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, msg);
+ }
+ return 1;
+ }
if (this->BuildNoCMake) {
// Make the generator available for the Build call below.
- cm.SetGlobalGenerator(cm.CreateGlobalGenerator(this->BuildGenerator));
- cm.SetGeneratorPlatform(this->BuildGeneratorPlatform);
- cm.SetGeneratorToolset(this->BuildGeneratorToolset);
+ cmGlobalGenerator* gen = cm.CreateGlobalGenerator(this->BuildGenerator);
+ cm.SetGlobalGenerator(gen);
+ if (!this->BuildGeneratorPlatform.empty()) {
+ cmMakefile mf(gen, cm.GetCurrentSnapshot());
+ if (!gen->SetGeneratorPlatform(this->BuildGeneratorPlatform, &mf)) {
+ return 1;
+ }
+ }
// Load the cache to make CMAKE_MAKE_PROGRAM available.
cm.LoadCache(this->BinaryDir);
@@ -219,16 +234,15 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
}
// do the build
- std::vector<std::string>::iterator tarIt;
if (this->BuildTargets.empty()) {
- this->BuildTargets.push_back("");
- }
- for (tarIt = this->BuildTargets.begin(); tarIt != this->BuildTargets.end();
- ++tarIt) {
- double remainingTime = 0;
- if (this->Timeout > 0) {
- remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start;
- if (remainingTime <= 0) {
+ this->BuildTargets.emplace_back();
+ }
+ for (std::string const& tar : this->BuildTargets) {
+ cmDuration remainingTime = std::chrono::seconds(0);
+ if (this->Timeout > cmDuration::zero()) {
+ remainingTime =
+ this->Timeout - (std::chrono::steady_clock::now() - clock_start);
+ if (remainingTime <= std::chrono::seconds(0)) {
if (outstring) {
*outstring = "--build-and-test timeout exceeded. ";
}
@@ -236,7 +250,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
}
}
std::string output;
- const char* config = CM_NULLPTR;
+ const char* config = nullptr;
if (!this->CTest->GetConfigType().empty()) {
config = this->CTest->GetConfigType().c_str();
}
@@ -249,9 +263,9 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
config = "Debug";
}
int retVal = cm.GetGlobalGenerator()->Build(
- this->SourceDir, this->BinaryDir, this->BuildProject, *tarIt, output,
- this->BuildMakeProgram, config, !this->BuildNoClean, false, false,
- remainingTime);
+ cmake::NO_BUILD_PARALLEL_LEVEL, this->SourceDir, this->BinaryDir,
+ this->BuildProject, { tar }, output, this->BuildMakeProgram, config,
+ !this->BuildNoClean, false, false, remainingTime);
out << output;
// if the build failed then return
if (retVal) {
@@ -277,9 +291,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
std::vector<std::string> extraPaths;
// if this->ExecutableDirectory is set try that as well
if (!this->ExecutableDirectory.empty()) {
- std::string tempPath = this->ExecutableDirectory;
- tempPath += "/";
- tempPath += this->TestCommand;
+ std::string tempPath =
+ cmStrCat(this->ExecutableDirectory, '/', this->TestCommand);
extraPaths.push_back(tempPath);
}
std::vector<std::string> failed;
@@ -287,13 +300,13 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
cmCTestTestHandler::FindExecutable(this->CTest, this->TestCommand.c_str(),
resultingConfig, extraPaths, failed);
- if (!cmSystemTools::FileExists(fullPath.c_str())) {
+ if (!cmSystemTools::FileExists(fullPath)) {
out << "Could not find path to executable, perhaps it was not built: "
<< this->TestCommand << "\n";
out << "tried to find it in these places:\n";
out << fullPath << "\n";
- for (unsigned int i = 0; i < failed.size(); ++i) {
- out << failed[i] << "\n";
+ for (std::string const& fail : failed) {
+ out << fail << "\n";
}
if (outstring) {
*outstring = out.str();
@@ -305,28 +318,38 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
std::vector<const char*> testCommand;
testCommand.push_back(fullPath.c_str());
- for (size_t k = 0; k < this->TestCommandArgs.size(); ++k) {
- testCommand.push_back(this->TestCommandArgs[k].c_str());
+ for (std::string const& testCommandArg : this->TestCommandArgs) {
+ testCommand.push_back(testCommandArg.c_str());
}
- testCommand.push_back(CM_NULLPTR);
+ testCommand.push_back(nullptr);
std::string outs;
int retval = 0;
// run the test from the this->BuildRunDir if set
if (!this->BuildRunDir.empty()) {
out << "Run test in directory: " << this->BuildRunDir << "\n";
- cmSystemTools::ChangeDirectory(this->BuildRunDir);
+ if (!workdir.SetDirectory(this->BuildRunDir)) {
+ out << "Failed to change working directory : "
+ << std::strerror(workdir.GetLastResult()) << "\n";
+ if (outstring) {
+ *outstring = out.str();
+ } else {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, out.str());
+ }
+ return 1;
+ }
}
out << "Running test command: \"" << fullPath << "\"";
- for (size_t k = 0; k < this->TestCommandArgs.size(); ++k) {
- out << " \"" << this->TestCommandArgs[k] << "\"";
+ for (std::string const& testCommandArg : this->TestCommandArgs) {
+ out << " \"" << testCommandArg << "\"";
}
out << "\n";
// how much time is remaining
- double remainingTime = 0;
- if (this->Timeout > 0) {
- remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start;
- if (remainingTime <= 0) {
+ cmDuration remainingTime = std::chrono::seconds(0);
+ if (this->Timeout > cmDuration::zero()) {
+ remainingTime =
+ this->Timeout - (std::chrono::steady_clock::now() - clock_start);
+ if (remainingTime <= std::chrono::seconds(0)) {
if (outstring) {
*outstring = "--build-and-test timeout exceeded. ";
}
@@ -334,8 +357,8 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
}
}
- int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval,
- CM_NULLPTR, remainingTime, CM_NULLPTR);
+ int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, nullptr,
+ remainingTime, nullptr);
if (runTestRes != cmsysProcess_State_Exited || retval != 0) {
out << "Test command failed: " << testCommand[0] << "\n";
@@ -364,7 +387,7 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
idx++;
this->BinaryDir = allArgs[idx];
// dir must exist before CollapseFullPath is called
- cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
+ cmSystemTools::MakeDirectory(this->BinaryDir);
this->BinaryDir = cmSystemTools::CollapseFullPath(this->BinaryDir);
this->SourceDir = cmSystemTools::CollapseFullPath(this->SourceDir);
} else {
@@ -394,7 +417,7 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
}
if (currentArg.find("--test-timeout", 0) == 0 && idx < allArgs.size() - 1) {
idx++;
- this->Timeout = atof(allArgs[idx].c_str());
+ this->Timeout = cmDuration(atof(allArgs[idx].c_str()));
}
if (currentArg == "--build-generator" && idx < allArgs.size() - 1) {
idx++;
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h
index 2e85e9fed..0c8a04079 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.h
+++ b/Source/CTest/cmCTestBuildAndTestHandler.h
@@ -3,15 +3,17 @@
#ifndef cmCTestBuildAndTestHandler_h
#define cmCTestBuildAndTestHandler_h
-#include "cmConfigure.h"
-
-#include "cmCTestGenericHandler.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <sstream>
-#include <stddef.h>
#include <string>
#include <vector>
+#include <stddef.h>
+
+#include "cmCTestGenericHandler.h"
+#include "cmDuration.h"
+
class cmake;
/** \class cmCTestBuildAndTestHandler
@@ -21,17 +23,17 @@ class cmake;
class cmCTestBuildAndTestHandler : public cmCTestGenericHandler
{
public:
- typedef cmCTestGenericHandler Superclass;
+ using Superclass = cmCTestGenericHandler;
/*
* The main entry point for this class
*/
- int ProcessHandler() CM_OVERRIDE;
+ int ProcessHandler() override;
//! Set all the build and test arguments
- int ProcessCommandLineArguments(const std::string& currentArg, size_t& idx,
- const std::vector<std::string>& allArgs)
- CM_OVERRIDE;
+ int ProcessCommandLineArguments(
+ const std::string& currentArg, size_t& idx,
+ const std::vector<std::string>& allArgs) override;
/*
* Get the output variable
@@ -40,10 +42,10 @@ public:
cmCTestBuildAndTestHandler();
- void Initialize() CM_OVERRIDE;
+ void Initialize() override;
protected:
- ///! Run CMake and build a test and then run it as a single test.
+ //! Run CMake and build a test and then run it as a single test.
int RunCMakeAndTest(std::string* output);
int RunCMake(std::string* outstring, std::ostringstream& out,
std::string& cmakeOutString, cmake* cm);
@@ -67,7 +69,7 @@ protected:
std::vector<std::string> TestCommandArgs;
std::vector<std::string> BuildTargets;
bool BuildNoCMake;
- double Timeout;
+ cmDuration Timeout;
};
#endif
diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx
index 4c8276007..18df2141e 100644
--- a/Source/CTest/cmCTestBuildCommand.cxx
+++ b/Source/CTest/cmCTestBuildCommand.cxx
@@ -2,48 +2,47 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestBuildCommand.h"
+#include <cstring>
+#include <sstream>
+
+#include "cm_static_string_view.hxx"
+
#include "cmCTest.h"
#include "cmCTestBuildHandler.h"
-#include "cmCTestGenericHandler.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
-#include <sstream>
-#include <string.h>
-
class cmExecutionStatus;
-cmCTestBuildCommand::cmCTestBuildCommand()
+void cmCTestBuildCommand::BindArguments()
{
- this->GlobalGenerator = CM_NULLPTR;
- this->Arguments[ctb_NUMBER_ERRORS] = "NUMBER_ERRORS";
- this->Arguments[ctb_NUMBER_WARNINGS] = "NUMBER_WARNINGS";
- this->Arguments[ctb_TARGET] = "TARGET";
- this->Arguments[ctb_CONFIGURATION] = "CONFIGURATION";
- this->Arguments[ctb_FLAGS] = "FLAGS";
- this->Arguments[ctb_PROJECT_NAME] = "PROJECT_NAME";
- this->Arguments[ctb_LAST] = CM_NULLPTR;
- this->Last = ctb_LAST;
+ this->cmCTestHandlerCommand::BindArguments();
+ this->Bind("NUMBER_ERRORS"_s, this->NumberErrors);
+ this->Bind("NUMBER_WARNINGS"_s, this->NumberWarnings);
+ this->Bind("TARGET"_s, this->Target);
+ this->Bind("CONFIGURATION"_s, this->Configuration);
+ this->Bind("FLAGS"_s, this->Flags);
+ this->Bind("PROJECT_NAME"_s, this->ProjectName);
}
cmCTestBuildCommand::~cmCTestBuildCommand()
{
if (this->GlobalGenerator) {
delete this->GlobalGenerator;
- this->GlobalGenerator = CM_NULLPTR;
+ this->GlobalGenerator = nullptr;
}
}
cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
{
- cmCTestGenericHandler* handler = this->CTest->GetInitializedHandler("build");
- if (!handler) {
- this->SetError("internal CTest error. Cannot instantiate build handler");
- return CM_NULLPTR;
- }
- this->Handler = (cmCTestBuildHandler*)handler;
+ cmCTestBuildHandler* handler = this->CTest->GetBuildHandler();
+ handler->Initialize();
+
+ this->Handler = handler;
const char* ctestBuildCommand =
this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");
@@ -53,10 +52,6 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
} else {
const char* cmakeGeneratorName =
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
- const char* cmakeProjectName =
- (this->Values[ctb_PROJECT_NAME] && *this->Values[ctb_PROJECT_NAME])
- ? this->Values[ctb_PROJECT_NAME]
- : this->Makefile->GetDefinition("CTEST_PROJECT_NAME");
// Build configuration is determined by: CONFIGURATION argument,
// or CTEST_BUILD_CONFIGURATION script variable, or
@@ -65,31 +60,27 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
//
const char* ctestBuildConfiguration =
this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION");
- const char* cmakeBuildConfiguration =
- (this->Values[ctb_CONFIGURATION] && *this->Values[ctb_CONFIGURATION])
- ? this->Values[ctb_CONFIGURATION]
+ const char* cmakeBuildConfiguration = !this->Configuration.empty()
+ ? this->Configuration.c_str()
: ((ctestBuildConfiguration && *ctestBuildConfiguration)
? ctestBuildConfiguration
: this->CTest->GetConfigType().c_str());
- const char* cmakeBuildAdditionalFlags =
- (this->Values[ctb_FLAGS] && *this->Values[ctb_FLAGS])
- ? this->Values[ctb_FLAGS]
+ const char* cmakeBuildAdditionalFlags = !this->Flags.empty()
+ ? this->Flags.c_str()
: this->Makefile->GetDefinition("CTEST_BUILD_FLAGS");
- const char* cmakeBuildTarget =
- (this->Values[ctb_TARGET] && *this->Values[ctb_TARGET])
- ? this->Values[ctb_TARGET]
+ const char* cmakeBuildTarget = !this->Target.empty()
+ ? this->Target.c_str()
: this->Makefile->GetDefinition("CTEST_BUILD_TARGET");
- if (cmakeGeneratorName && *cmakeGeneratorName && cmakeProjectName &&
- *cmakeProjectName) {
+ if (cmakeGeneratorName && *cmakeGeneratorName) {
if (!cmakeBuildConfiguration) {
cmakeBuildConfiguration = "Release";
}
if (this->GlobalGenerator) {
if (this->GlobalGenerator->GetName() != cmakeGeneratorName) {
delete this->GlobalGenerator;
- this->GlobalGenerator = CM_NULLPTR;
+ this->GlobalGenerator = nullptr;
}
}
if (!this->GlobalGenerator) {
@@ -97,16 +88,15 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
this->Makefile->GetCMakeInstance()->CreateGlobalGenerator(
cmakeGeneratorName);
if (!this->GlobalGenerator) {
- std::string e = "could not create generator named \"";
- e += cmakeGeneratorName;
- e += "\"";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e);
+ std::string e = cmStrCat("could not create generator named \"",
+ cmakeGeneratorName, '"');
+ this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e);
cmSystemTools::SetFatalErrorOccured();
- return CM_NULLPTR;
+ return nullptr;
}
}
if (strlen(cmakeBuildConfiguration) == 0) {
- const char* config = CM_NULLPTR;
+ const char* config = nullptr;
#ifdef CMAKE_INTDIR
config = CMAKE_INTDIR;
#endif
@@ -132,18 +122,11 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
/* clang-format off */
ostr << "has no project to build. If this is a "
"\"built with CMake\" project, verify that CTEST_CMAKE_GENERATOR "
- "and CTEST_PROJECT_NAME are set."
- "\n"
- "CTEST_PROJECT_NAME is usually set in CTestConfig.cmake. Verify "
- "that CTestConfig.cmake exists, or CTEST_PROJECT_NAME "
- "is set in the script, or PROJECT_NAME is passed as an argument "
- "to ctest_build."
- "\n"
- "Alternatively, set CTEST_BUILD_COMMAND to build the project "
+ "is set. Otherwise, set CTEST_BUILD_COMMAND to build the project "
"with a custom command line.";
/* clang-format on */
this->SetError(ostr.str());
- return CM_NULLPTR;
+ return nullptr;
}
}
@@ -153,6 +136,12 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
this->Quiet);
}
+ if (const char* labelsForSubprojects =
+ this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) {
+ this->CTest->SetCTestConfiguration("LabelsForSubprojects",
+ labelsForSubprojects, this->Quiet);
+ }
+
handler->SetQuiet(this->Quiet);
return handler;
}
@@ -161,18 +150,13 @@ bool cmCTestBuildCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
bool ret = cmCTestHandlerCommand::InitialPass(args, status);
- if (this->Values[ctb_NUMBER_ERRORS] && *this->Values[ctb_NUMBER_ERRORS]) {
- std::ostringstream str;
- str << this->Handler->GetTotalErrors();
- this->Makefile->AddDefinition(this->Values[ctb_NUMBER_ERRORS],
- str.str().c_str());
+ if (!this->NumberErrors.empty()) {
+ this->Makefile->AddDefinition(
+ this->NumberErrors, std::to_string(this->Handler->GetTotalErrors()));
}
- if (this->Values[ctb_NUMBER_WARNINGS] &&
- *this->Values[ctb_NUMBER_WARNINGS]) {
- std::ostringstream str;
- str << this->Handler->GetTotalWarnings();
- this->Makefile->AddDefinition(this->Values[ctb_NUMBER_WARNINGS],
- str.str().c_str());
+ if (!this->NumberWarnings.empty()) {
+ this->Makefile->AddDefinition(
+ this->NumberWarnings, std::to_string(this->Handler->GetTotalWarnings()));
}
return ret;
}
diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h
index 9cf6a9652..da00a43c6 100644
--- a/Source/CTest/cmCTestBuildCommand.h
+++ b/Source/CTest/cmCTestBuildCommand.h
@@ -3,16 +3,19 @@
#ifndef cmCTestBuildCommand_h
#define cmCTestBuildCommand_h
-#include "cmConfigure.h"
-
-#include "cmCTestHandlerCommand.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <utility>
#include <vector>
+#include <cm/memory>
+
+#include "cmCTestHandlerCommand.h"
+#include "cmCommand.h"
+
class cmCTestBuildHandler;
class cmCTestGenericHandler;
-class cmCommand;
class cmExecutionStatus;
class cmGlobalGenerator;
@@ -24,45 +27,40 @@ class cmGlobalGenerator;
class cmCTestBuildCommand : public cmCTestHandlerCommand
{
public:
- cmCTestBuildCommand();
- ~cmCTestBuildCommand() CM_OVERRIDE;
+ ~cmCTestBuildCommand() override;
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE
+ std::unique_ptr<cmCommand> Clone() override
{
- cmCTestBuildCommand* ni = new cmCTestBuildCommand;
+ auto ni = cm::make_unique<cmCTestBuildCommand>();
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
- return ni;
+ return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
* The name of the command as specified in CMakeList.txt.
*/
- std::string GetName() const CM_OVERRIDE { return "ctest_build"; }
+ std::string GetName() const override { return "ctest_build"; }
bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
+ cmExecutionStatus& status) override;
- cmGlobalGenerator* GlobalGenerator;
+ cmGlobalGenerator* GlobalGenerator = nullptr;
protected:
cmCTestBuildHandler* Handler;
- enum
- {
- ctb_BUILD = ct_LAST,
- ctb_NUMBER_ERRORS,
- ctb_NUMBER_WARNINGS,
- ctb_TARGET,
- ctb_CONFIGURATION,
- ctb_FLAGS,
- ctb_PROJECT_NAME,
- ctb_LAST
- };
+ void BindArguments() override;
+ cmCTestGenericHandler* InitializeHandler() override;
- cmCTestGenericHandler* InitializeHandler() CM_OVERRIDE;
+ std::string NumberErrors;
+ std::string NumberWarnings;
+ std::string Target;
+ std::string Configuration;
+ std::string Flags;
+ std::string ProjectName;
};
#endif
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index 18ef05c67..9cb5449d9 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -2,22 +2,27 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestBuildHandler.h"
+#include <cstdlib>
+#include <cstring>
+#include <set>
+#include <utility>
+
+#include "cmsys/Directory.hxx"
+#include "cmsys/FStream.hxx"
+#include "cmsys/Process.h"
+
#include "cmAlgorithms.h"
#include "cmCTest.h"
-#include "cmFileTimeComparison.h"
+#include "cmDuration.h"
+#include "cmFileTimeCache.h"
#include "cmGeneratedFileStream.h"
#include "cmMakefile.h"
#include "cmProcessOutput.h"
+#include "cmStringAlgorithms.h"
+#include "cmStringReplaceHelper.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
-#include "cmsys/Directory.hxx"
-#include "cmsys/FStream.hxx"
-#include "cmsys/Process.h"
-#include <set>
-#include <stdlib.h>
-#include <string.h>
-
static const char* cmCTestErrorMatches[] = {
"^[Bb]us [Ee]rror",
"^[Ss]egmentation [Vv]iolation",
@@ -30,13 +35,13 @@ static const char* cmCTestErrorMatches[] = {
"^Error: ",
"^Error ",
"[0-9] ERROR: ",
- "^\"[^\"]+\", line [0-9]+: [^Ww]",
+ R"(^"[^"]+", line [0-9]+: [^Ww])",
"^cc[^C]*CC: ERROR File = ([^,]+), Line = ([0-9]+)",
"^ld([^:])*:([ \\t])*ERROR([^:])*:",
- "^ild:([ \\t])*\\(undefined symbol\\)",
+ R"(^ild:([ \t])*\(undefined symbol\))",
"([^ :]+) : (error|fatal error|catastrophic error)",
"([^:]+): (Error:|error|undefined reference|multiply defined)",
- "([^:]+)\\(([^\\)]+)\\) ?: (error|fatal error|catastrophic error)",
+ R"(([^:]+)\(([^\)]+)\) ?: (error|fatal error|catastrophic error))",
"^fatal error C[0-9]+:",
": syntax error ",
"^collect2: ld returned 1 exit status",
@@ -48,14 +53,14 @@ static const char* cmCTestErrorMatches[] = {
"^CMake Error.*:",
":[ \\t]cannot find",
":[ \\t]can't find",
- ": \\*\\*\\* No rule to make target [`'].*\\'. Stop",
- ": \\*\\*\\* No targets specified and no makefile found",
+ R"(: \*\*\* No rule to make target [`'].*\'. Stop)",
+ R"(: \*\*\* No targets specified and no makefile found)",
": Invalid loader fixup for symbol",
": Invalid fixups exist",
": Can't find library for",
": internal link edit command failed",
": Unrecognized option [`'].*\\'",
- "\", line [0-9]+\\.[0-9]+: [0-9]+-[0-9]+ \\([^WI]\\)",
+ R"(", line [0-9]+\.[0-9]+: [0-9]+-[0-9]+ \([^WI]\))",
"ld: 0706-006 Cannot find or open library file: -l ",
"ild: \\(argument error\\) can't find library argument ::",
"^could not be found and will not be loaded.",
@@ -64,23 +69,24 @@ static const char* cmCTestErrorMatches[] = {
"ld: 0711-993 Error occurred while writing to the output file:",
"ld: fatal: ",
"final link failed:",
- "make: \\*\\*\\*.*Error",
- "make\\[.*\\]: \\*\\*\\*.*Error",
- "\\*\\*\\* Error code",
+ R"(make: \*\*\*.*Error)",
+ R"(make\[.*\]: \*\*\*.*Error)",
+ R"(\*\*\* Error code)",
"nternal error:",
- "Makefile:[0-9]+: \\*\\*\\* .* Stop\\.",
+ R"(Makefile:[0-9]+: \*\*\* .* Stop\.)",
": No such file or directory",
": Invalid argument",
"^The project cannot be built\\.",
"^\\[ERROR\\]",
"^Command .* failed with exit code",
- CM_NULLPTR
+ nullptr
};
static const char* cmCTestErrorExceptions[] = {
"instantiated from ",
"candidates are:",
": warning",
+ ": WARNING",
": \\(Warning\\)",
": note",
"Note:",
@@ -89,7 +95,7 @@ static const char* cmCTestErrorExceptions[] = {
":[ \\t]+Where:",
"([^ :]+):([0-9]+): Warning",
"------ Build started: .* ------",
- CM_NULLPTR
+ nullptr
};
static const char* cmCTestWarningMatches[] = {
@@ -98,29 +104,29 @@ static const char* cmCTestWarningMatches[] = {
"^cc[^C]*CC: WARNING File = ([^,]+), Line = ([0-9]+)",
"^ld([^:])*:([ \\t])*WARNING([^:])*:",
"([^:]+): warning ([0-9]+):",
- "^\"[^\"]+\", line [0-9]+: [Ww](arning|arnung)",
+ R"(^"[^"]+", line [0-9]+: [Ww](arning|arnung))",
"([^:]+): warning[ \\t]*[0-9]+[ \\t]*:",
"^(Warning|Warnung) ([0-9]+):",
"^(Warning|Warnung)[ :]",
"WARNING: ",
"([^ :]+) : warning",
"([^:]+): warning",
- "\", line [0-9]+\\.[0-9]+: [0-9]+-[0-9]+ \\([WI]\\)",
+ R"(", line [0-9]+\.[0-9]+: [0-9]+-[0-9]+ \([WI]\))",
"^cxx: Warning:",
".*file: .* has no symbols",
"([^ :]+):([0-9]+): (Warning|Warnung)",
"\\([0-9]*\\): remark #[0-9]*",
- "\".*\", line [0-9]+: remark\\([0-9]*\\):",
+ R"(".*", line [0-9]+: remark\([0-9]*\):)",
"cc-[0-9]* CC: REMARK File = .*, Line = [0-9]*",
"^CMake Warning.*:",
"^\\[WARNING\\]",
- CM_NULLPTR
+ nullptr
};
static const char* cmCTestWarningExceptions[] = {
- "/usr/.*/X11/Xlib\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration",
- "/usr/.*/X11/Xutil\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration",
- "/usr/.*/X11/XResource\\.h:[0-9]+: war.*: ANSI C\\+\\+ forbids declaration",
+ R"(/usr/.*/X11/Xlib\.h:[0-9]+: war.*: ANSI C\+\+ forbids declaration)",
+ R"(/usr/.*/X11/Xutil\.h:[0-9]+: war.*: ANSI C\+\+ forbids declaration)",
+ R"(/usr/.*/X11/XResource\.h:[0-9]+: war.*: ANSI C\+\+ forbids declaration)",
"WARNING 84 :",
"WARNING 47 :",
"makefile:",
@@ -134,7 +140,7 @@ static const char* cmCTestWarningExceptions[] = {
"ld32: WARNING 85: definition of dataKey in",
"cc: warning 422: Unknown option \"\\+b",
"_with_warning_C",
- CM_NULLPTR
+ nullptr
};
struct cmCTestBuildCompileErrorWarningRex
@@ -147,12 +153,12 @@ struct cmCTestBuildCompileErrorWarningRex
static cmCTestBuildCompileErrorWarningRex cmCTestWarningErrorFileLine[] = {
{ "^Warning W[0-9]+ ([a-zA-Z.\\:/0-9_+ ~-]+) ([0-9]+):", 1, 2 },
{ "^([a-zA-Z./0-9_+ ~-]+):([0-9]+):", 1, 2 },
- { "^([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
- { "^[0-9]+>([a-zA-Z.\\:/0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
+ { R"(^([a-zA-Z.\:/0-9_+ ~-]+)\(([0-9]+)\))", 1, 2 },
+ { R"(^[0-9]+>([a-zA-Z.\:/0-9_+ ~-]+)\(([0-9]+)\))", 1, 2 },
{ "^([a-zA-Z./0-9_+ ~-]+)\\(([0-9]+)\\)", 1, 2 },
{ "\"([a-zA-Z./0-9_+ ~-]+)\", line ([0-9]+)", 1, 2 },
{ "File = ([a-zA-Z./0-9_+ ~-]+), Line = ([0-9]+)", 1, 2 },
- { CM_NULLPTR, 0, 0 }
+ { nullptr, 0, 0 }
};
cmCTestBuildHandler::cmCTestBuildHandler()
@@ -171,8 +177,8 @@ cmCTestBuildHandler::cmCTestBuildHandler()
void cmCTestBuildHandler::Initialize()
{
this->Superclass::Initialize();
- this->StartBuild = "";
- this->EndBuild = "";
+ this->StartBuild.clear();
+ this->EndBuild.clear();
this->CustomErrorMatches.clear();
this->CustomErrorExceptions.clear();
this->CustomWarningMatches.clear();
@@ -190,8 +196,8 @@ void cmCTestBuildHandler::Initialize()
this->BuildOutputLogSize = 0;
this->CurrentProcessingLine.clear();
- this->SimplifySourceDir = "";
- this->SimplifyBuildDir = "";
+ this->SimplifySourceDir.clear();
+ this->SimplifyBuildDir.clear();
this->OutputLineCounter = 0;
this->ErrorsAndWarnings.clear();
this->LastErrorOrWarning = this->ErrorsAndWarnings.end();
@@ -243,13 +249,11 @@ void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile* mf)
// Record the user-specified custom warning rules.
if (const char* customWarningMatchers =
mf->GetDefinition("CTEST_CUSTOM_WARNING_MATCH")) {
- cmSystemTools::ExpandListArgument(customWarningMatchers,
- this->ReallyCustomWarningMatches);
+ cmExpandList(customWarningMatchers, this->ReallyCustomWarningMatches);
}
if (const char* customWarningExceptions =
mf->GetDefinition("CTEST_CUSTOM_WARNING_EXCEPTION")) {
- cmSystemTools::ExpandListArgument(customWarningExceptions,
- this->ReallyCustomWarningExceptions);
+ cmExpandList(customWarningExceptions, this->ReallyCustomWarningExceptions);
}
}
@@ -260,11 +264,11 @@ std::string cmCTestBuildHandler::GetMakeCommand()
"MakeCommand:" << makeCommand << "\n", this->Quiet);
std::string configType = this->CTest->GetConfigType();
- if (configType == "") {
+ if (configType.empty()) {
configType =
this->CTest->GetCTestConfiguration("DefaultCTestConfigurationType");
}
- if (configType == "") {
+ if (configType.empty()) {
configType = "Release";
}
@@ -282,7 +286,7 @@ int cmCTestBuildHandler::ProcessHandler()
this->Quiet);
// do we have time for this
- if (this->CTest->GetRemainingTimeAllowed() < 120) {
+ if (this->CTest->GetRemainingTimeAllowed() < std::chrono::minutes(2)) {
return 0;
}
@@ -294,10 +298,11 @@ int cmCTestBuildHandler::ProcessHandler()
cmCTestWarningErrorFileLine[entry].RegularExpressionString)) {
r.FileIndex = cmCTestWarningErrorFileLine[entry].FileIndex;
r.LineIndex = cmCTestWarningErrorFileLine[entry].LineIndex;
- this->ErrorWarningFileLineRegex.push_back(r);
+ this->ErrorWarningFileLineRegex.push_back(std::move(r));
} else {
cmCTestLog(
- this->CTest, ERROR_MESSAGE, "Problem Compiling regular expression: "
+ this->CTest, ERROR_MESSAGE,
+ "Problem Compiling regular expression: "
<< cmCTestWarningErrorFileLine[entry].RegularExpressionString
<< std::endl);
}
@@ -323,46 +328,48 @@ int cmCTestBuildHandler::ProcessHandler()
std::string const& useLaunchers =
this->CTest->GetCTestConfiguration("UseLaunchers");
- this->UseCTestLaunch = cmSystemTools::IsOn(useLaunchers.c_str());
+ this->UseCTestLaunch = cmIsOn(useLaunchers);
// Create a last build log
cmGeneratedFileStream ofs;
- double elapsed_time_start = cmSystemTools::GetTime();
+ auto elapsed_time_start = std::chrono::steady_clock::now();
if (!this->StartLogFile("Build", ofs)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build log file"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot create build log file" << std::endl);
}
// Create lists of regular expression strings for errors, error exceptions,
// warnings and warning exceptions.
std::vector<std::string>::size_type cc;
for (cc = 0; cmCTestErrorMatches[cc]; cc++) {
- this->CustomErrorMatches.push_back(cmCTestErrorMatches[cc]);
+ this->CustomErrorMatches.emplace_back(cmCTestErrorMatches[cc]);
}
for (cc = 0; cmCTestErrorExceptions[cc]; cc++) {
- this->CustomErrorExceptions.push_back(cmCTestErrorExceptions[cc]);
+ this->CustomErrorExceptions.emplace_back(cmCTestErrorExceptions[cc]);
}
for (cc = 0; cmCTestWarningMatches[cc]; cc++) {
- this->CustomWarningMatches.push_back(cmCTestWarningMatches[cc]);
+ this->CustomWarningMatches.emplace_back(cmCTestWarningMatches[cc]);
}
for (cc = 0; cmCTestWarningExceptions[cc]; cc++) {
- this->CustomWarningExceptions.push_back(cmCTestWarningExceptions[cc]);
+ this->CustomWarningExceptions.emplace_back(cmCTestWarningExceptions[cc]);
}
// Pre-compile regular expressions objects for all regular expressions
- std::vector<std::string>::iterator it;
#define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \
- regexes.clear(); \
- cmCTestOptionalLog(this->CTest, DEBUG, \
- this << "Add " #regexes << std::endl, this->Quiet); \
- for (it = (strings).begin(); it != (strings).end(); ++it) { \
+ do { \
+ regexes.clear(); \
cmCTestOptionalLog(this->CTest, DEBUG, \
- "Add " #strings ": " << *it << std::endl, \
- this->Quiet); \
- (regexes).push_back(it->c_str()); \
- }
+ this << "Add " #regexes << std::endl, this->Quiet); \
+ for (std::string const& s : (strings)) { \
+ cmCTestOptionalLog(this->CTest, DEBUG, \
+ "Add " #strings ": " << s << std::endl, \
+ this->Quiet); \
+ (regexes).emplace_back(s); \
+ } \
+ } while (false)
+
cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorMatches,
this->ErrorMatchRegex);
cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorExceptions,
@@ -373,16 +380,13 @@ int cmCTestBuildHandler::ProcessHandler()
this->WarningExceptionRegex);
// Determine source and binary tree substitutions to simplify the output.
- this->SimplifySourceDir = "";
- this->SimplifyBuildDir = "";
+ this->SimplifySourceDir.clear();
+ this->SimplifyBuildDir.clear();
if (this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20) {
std::string srcdir =
this->CTest->GetCTestConfiguration("SourceDirectory") + "/";
- std::string srcdirrep;
for (cc = srcdir.size() - 2; cc > 0; cc--) {
if (srcdir[cc] == '/') {
- srcdirrep = srcdir.c_str() + cc;
- srcdirrep = "/..." + srcdirrep;
srcdir = srcdir.substr(0, cc + 1);
break;
}
@@ -392,11 +396,8 @@ int cmCTestBuildHandler::ProcessHandler()
if (this->CTest->GetCTestConfiguration("BuildDirectory").size() > 20) {
std::string bindir =
this->CTest->GetCTestConfiguration("BuildDirectory") + "/";
- std::string bindirrep;
for (cc = bindir.size() - 2; cc > 0; cc--) {
if (bindir[cc] == '/') {
- bindirrep = bindir.c_str() + cc;
- bindirrep = "/..." + bindirrep;
bindir = bindir.substr(0, cc + 1);
break;
}
@@ -408,12 +409,15 @@ int cmCTestBuildHandler::ProcessHandler()
// Remember start build time
this->StartBuild = this->CTest->CurrentTime();
- this->StartBuildTime = cmSystemTools::GetTime();
+ this->StartBuildTime = std::chrono::system_clock::now();
+
+ cmStringReplaceHelper colorRemover("\x1b\\[[0-9;]*m", "", nullptr);
+ this->ColorRemover = &colorRemover;
int retVal = 0;
int res = cmsysProcess_State_Exited;
if (!this->CTest->GetShowOnly()) {
- res = this->RunMakeCommand(makeCommand.c_str(), &retVal,
- buildDirectory.c_str(), 0, ofs);
+ res = this->RunMakeCommand(makeCommand, &retVal, buildDirectory.c_str(), 0,
+ ofs);
} else {
cmCTestOptionalLog(this->CTest, DEBUG,
"Build with command: " << makeCommand << std::endl,
@@ -422,31 +426,29 @@ int cmCTestBuildHandler::ProcessHandler()
// Remember end build time and calculate elapsed time
this->EndBuild = this->CTest->CurrentTime();
- this->EndBuildTime = cmSystemTools::GetTime();
- double elapsed_build_time = cmSystemTools::GetTime() - elapsed_time_start;
+ this->EndBuildTime = std::chrono::system_clock::now();
+ auto elapsed_build_time =
+ std::chrono::steady_clock::now() - elapsed_time_start;
// Cleanups strings in the errors and warnings list.
- t_ErrorsAndWarningsVector::iterator evit;
if (!this->SimplifySourceDir.empty()) {
- for (evit = this->ErrorsAndWarnings.begin();
- evit != this->ErrorsAndWarnings.end(); ++evit) {
- cmSystemTools::ReplaceString(evit->Text, this->SimplifySourceDir.c_str(),
+ for (cmCTestBuildErrorWarning& evit : this->ErrorsAndWarnings) {
+ cmSystemTools::ReplaceString(evit.Text, this->SimplifySourceDir.c_str(),
"/.../");
- cmSystemTools::ReplaceString(evit->PreContext,
+ cmSystemTools::ReplaceString(evit.PreContext,
this->SimplifySourceDir.c_str(), "/.../");
- cmSystemTools::ReplaceString(evit->PostContext,
+ cmSystemTools::ReplaceString(evit.PostContext,
this->SimplifySourceDir.c_str(), "/.../");
}
}
if (!this->SimplifyBuildDir.empty()) {
- for (evit = this->ErrorsAndWarnings.begin();
- evit != this->ErrorsAndWarnings.end(); ++evit) {
- cmSystemTools::ReplaceString(evit->Text, this->SimplifyBuildDir.c_str(),
+ for (cmCTestBuildErrorWarning& evit : this->ErrorsAndWarnings) {
+ cmSystemTools::ReplaceString(evit.Text, this->SimplifyBuildDir.c_str(),
"/.../");
- cmSystemTools::ReplaceString(evit->PreContext,
+ cmSystemTools::ReplaceString(evit.PreContext,
this->SimplifyBuildDir.c_str(), "/.../");
- cmSystemTools::ReplaceString(evit->PostContext,
+ cmSystemTools::ReplaceString(evit.PostContext,
this->SimplifyBuildDir.c_str(), "/.../");
}
}
@@ -454,8 +456,8 @@ int cmCTestBuildHandler::ProcessHandler()
// Generate XML output
cmGeneratedFileStream xofs;
if (!this->StartResultingXML(cmCTest::PartBuild, "Build", xofs)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build XML file"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot create build XML file" << std::endl);
return -1;
}
cmXMLWriter xml(xofs);
@@ -468,19 +470,20 @@ int cmCTestBuildHandler::ProcessHandler()
this->GenerateXMLFooter(xml, elapsed_build_time);
if (res != cmsysProcess_State_Exited || retVal || this->TotalErrors > 0) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Error(s) when building project"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Error(s) when building project" << std::endl);
}
// Display message about number of errors and warnings
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " "
- << this->TotalErrors
- << (this->TotalErrors >= this->MaxErrors ? " or more" : "")
- << " Compiler errors" << std::endl);
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " "
- << this->TotalWarnings
- << (this->TotalWarnings >= this->MaxWarnings ? " or more" : "")
- << " Compiler warnings" << std::endl);
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " " << this->TotalErrors
+ << (this->TotalErrors >= this->MaxErrors ? " or more" : "")
+ << " Compiler errors" << std::endl);
+ cmCTestLog(
+ this->CTest, HANDLER_OUTPUT,
+ " " << this->TotalWarnings
+ << (this->TotalWarnings >= this->MaxWarnings ? " or more" : "")
+ << " Compiler warnings" << std::endl);
return retVal;
}
@@ -488,38 +491,34 @@ int cmCTestBuildHandler::ProcessHandler()
void cmCTestBuildHandler::GenerateXMLHeader(cmXMLWriter& xml)
{
this->CTest->StartXML(xml, this->AppendXML);
+ this->CTest->GenerateSubprojectsOutput(xml);
xml.StartElement("Build");
xml.Element("StartDateTime", this->StartBuild);
- xml.Element("StartBuildTime",
- static_cast<unsigned int>(this->StartBuildTime));
+ xml.Element("StartBuildTime", this->StartBuildTime);
xml.Element("BuildCommand", this->GetMakeCommand());
}
class cmCTestBuildHandler::FragmentCompare
{
public:
- FragmentCompare(cmFileTimeComparison* ftc)
+ FragmentCompare(cmFileTimeCache* ftc)
: FTC(ftc)
{
}
- FragmentCompare()
- : FTC(CM_NULLPTR)
- {
- }
+ FragmentCompare() = default;
bool operator()(std::string const& l, std::string const& r) const
{
// Order files by modification time. Use lexicographic order
// among files with the same time.
int result;
- if (this->FTC->FileTimeCompare(l.c_str(), r.c_str(), &result) &&
- result != 0) {
+ if (this->FTC->Compare(l, r, &result) && result != 0) {
return result < 0;
}
return l < r;
}
private:
- cmFileTimeComparison* FTC;
+ cmFileTimeCache* FTC = nullptr;
};
void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
@@ -529,9 +528,9 @@ void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
}
// Sort XML fragments in chronological order.
- cmFileTimeComparison ftc;
+ cmFileTimeCache ftc;
FragmentCompare fragmentCompare(&ftc);
- typedef std::set<std::string, FragmentCompare> Fragments;
+ using Fragments = std::set<std::string, FragmentCompare>;
Fragments fragments(fragmentCompare);
// only report the first 50 warnings and first 50 errors
@@ -555,9 +554,8 @@ void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
}
// Copy the fragments into the final XML file.
- for (Fragments::const_iterator fi = fragments.begin(); fi != fragments.end();
- ++fi) {
- xml.FragmentFile(fi->c_str());
+ for (std::string const& f : fragments) {
+ xml.FragmentFile(f.c_str());
}
}
@@ -572,8 +570,7 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
// make sure the source dir is in the correct case on windows
// via a call to collapse full path.
- srcdir = cmSystemTools::CollapseFullPath(srcdir);
- srcdir += "/";
+ srcdir = cmStrCat(cmSystemTools::CollapseFullPath(srcdir), '/');
for (it = ew.begin();
it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++) {
cmCTestBuildErrorWarning* cm = &(*it);
@@ -587,12 +584,11 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
xml.StartElement(cm->Error ? "Error" : "Warning");
xml.Element("BuildLogLine", cm->LogLine);
xml.Element("Text", cm->Text);
- std::vector<cmCTestCompileErrorWarningRex>::iterator rit;
- for (rit = this->ErrorWarningFileLineRegex.begin();
- rit != this->ErrorWarningFileLineRegex.end(); ++rit) {
- cmsys::RegularExpression* re = &rit->RegularExpression;
- if (re->find(cm->Text.c_str())) {
- cm->SourceFile = re->match(rit->FileIndex);
+ for (cmCTestCompileErrorWarningRex& rit :
+ this->ErrorWarningFileLineRegex) {
+ cmsys::RegularExpression* re = &rit.RegularExpression;
+ if (re->find(cm->Text)) {
+ cm->SourceFile = re->match(rit.FileIndex);
// At this point we need to make this->SourceFile relative to
// the source root of the project, so cvs links will work
cmSystemTools::ConvertToUnixSlashes(cm->SourceFile);
@@ -608,7 +604,7 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
cm->SourceFile = cmSystemTools::CollapseFullPath(cm->SourceFile);
cmSystemTools::ReplaceString(cm->SourceFile, srcdir.c_str(), "");
}
- cm->LineNumber = atoi(re->match(rit->LineIndex).c_str());
+ cm->LineNumber = atoi(re->match(rit.LineIndex).c_str());
break;
}
}
@@ -640,7 +636,7 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
}
void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
- double elapsed_build_time)
+ cmDuration elapsed_build_time)
{
xml.StartElement("Log");
xml.Attribute("Encoding", "base64");
@@ -648,9 +644,11 @@ void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
xml.EndElement(); // Log
xml.Element("EndDateTime", this->EndBuild);
- xml.Element("EndBuildTime", static_cast<unsigned int>(this->EndBuildTime));
- xml.Element("ElapsedMinutes",
- static_cast<int>(elapsed_build_time / 6) / 10.0);
+ xml.Element("EndBuildTime", this->EndBuildTime);
+ xml.Element(
+ "ElapsedMinutes",
+ std::chrono::duration_cast<std::chrono::minutes>(elapsed_build_time)
+ .count());
xml.EndElement(); // Build
this->CTest->EndXML(xml);
}
@@ -679,6 +677,8 @@ class cmCTestBuildHandler::LaunchHelper
public:
LaunchHelper(cmCTestBuildHandler* handler);
~LaunchHelper();
+ LaunchHelper(const LaunchHelper&) = delete;
+ LaunchHelper& operator=(const LaunchHelper&) = delete;
private:
cmCTestBuildHandler* Handler;
@@ -701,20 +701,17 @@ cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler)
} else {
// Compute a directory in which to store launcher fragments.
std::string& launchDir = this->Handler->CTestLaunchDir;
- launchDir = this->CTest->GetBinaryDir();
- launchDir += "/Testing/";
- launchDir += tag;
- launchDir += "/Build";
+ launchDir =
+ cmStrCat(this->CTest->GetBinaryDir(), "/Testing/", tag, "/Build");
// Clean out any existing launcher fragments.
cmSystemTools::RemoveADirectory(launchDir);
if (this->Handler->UseCTestLaunch) {
// Enable launcher fragments.
- cmSystemTools::MakeDirectory(launchDir.c_str());
+ cmSystemTools::MakeDirectory(launchDir);
this->WriteLauncherConfig();
- std::string launchEnv = "CTEST_LAUNCH_LOGS=";
- launchEnv += launchDir;
+ std::string launchEnv = cmStrCat("CTEST_LAUNCH_LOGS=", launchDir);
cmSystemTools::PutEnv(launchEnv);
}
}
@@ -740,9 +737,9 @@ void cmCTestBuildHandler::LaunchHelper::WriteLauncherConfig()
this->Handler->ReallyCustomWarningExceptions);
// Give some testing configuration information to the launcher.
- std::string fname = this->Handler->CTestLaunchDir;
- fname += "/CTestLaunchConfig.cmake";
- cmGeneratedFileStream fout(fname.c_str());
+ std::string fname =
+ cmStrCat(this->Handler->CTestLaunchDir, "/CTestLaunchConfig.cmake");
+ cmGeneratedFileStream fout(fname);
std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
fout << "set(CTEST_SOURCE_DIRECTORY \"" << srcdir << "\")\n";
}
@@ -753,20 +750,18 @@ void cmCTestBuildHandler::LaunchHelper::WriteScrapeMatchers(
if (matchers.empty()) {
return;
}
- std::string fname = this->Handler->CTestLaunchDir;
- fname += "/Custom";
- fname += purpose;
- fname += ".txt";
- cmGeneratedFileStream fout(fname.c_str());
- for (std::vector<std::string>::const_iterator mi = matchers.begin();
- mi != matchers.end(); ++mi) {
- fout << *mi << "\n";
+ std::string fname =
+ cmStrCat(this->Handler->CTestLaunchDir, "/Custom", purpose, ".txt");
+ cmGeneratedFileStream fout(fname);
+ for (std::string const& m : matchers) {
+ fout << m << "\n";
}
}
-int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
- const char* dir, int timeout,
- std::ostream& ofs, Encoding encoding)
+int cmCTestBuildHandler::RunMakeCommand(const std::string& command,
+ int* retVal, const char* dir,
+ int timeout, std::ostream& ofs,
+ Encoding encoding)
{
// First generate the command and arguments
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
@@ -776,18 +771,20 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
}
std::vector<const char*> argv;
- for (std::vector<std::string>::const_iterator a = args.begin();
- a != args.end(); ++a) {
- argv.push_back(a->c_str());
+ argv.reserve(args.size() + 1);
+ for (std::string const& arg : args) {
+ argv.push_back(arg.c_str());
}
- argv.push_back(CM_NULLPTR);
+ argv.push_back(nullptr);
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command:",
- this->Quiet);
- std::vector<const char*>::iterator ait;
- for (ait = argv.begin(); ait != argv.end() && *ait; ++ait) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Run command:", this->Quiet);
+ for (char const* arg : argv) {
+ if (!arg) {
+ break;
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " \"" << *ait << "\"", this->Quiet);
+ " \"" << arg << "\"", this->Quiet);
}
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
this->Quiet);
@@ -798,7 +795,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
// Now create process object
cmsysProcess* cp = cmsysProcess_New();
- cmsysProcess_SetCommand(cp, &*argv.begin());
+ cmsysProcess_SetCommand(cp, argv.data());
cmsysProcess_SetWorkingDirectory(cp, dir);
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
cmsysProcess_SetTimeout(cp, timeout);
@@ -813,7 +810,8 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
cmProcessOutput processOutput(encoding);
std::string strdata;
cmCTestOptionalLog(
- this->CTest, HANDLER_PROGRESS_OUTPUT, " Each symbol represents "
+ this->CTest, HANDLER_PROGRESS_OUTPUT,
+ " Each symbol represents "
<< tick_len << " bytes of output." << std::endl
<< (this->UseCTestLaunch
? ""
@@ -834,7 +832,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
// For every chunk of data
int res;
- while ((res = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR))) {
+ while ((res = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) {
// Replace '\0' with '\n', since '\0' does not really make sense. This is
// for Visual Studio output
for (int cc = 0; cc < length; ++cc) {
@@ -865,17 +863,18 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
&this->BuildProcessingQueue);
}
- this->ProcessBuffer(CM_NULLPTR, 0, tick, tick_len, ofs,
+ this->ProcessBuffer(nullptr, 0, tick, tick_len, ofs,
&this->BuildProcessingQueue);
- this->ProcessBuffer(CM_NULLPTR, 0, tick, tick_len, ofs,
+ this->ProcessBuffer(nullptr, 0, tick, tick_len, ofs,
&this->BuildProcessingErrorQueue);
- cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, " Size of output: "
+ cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
+ " Size of output: "
<< ((this->BuildOutputLogSize + 512) / 1024) << "K"
<< std::endl,
this->Quiet);
// Properly handle output of the build command
- cmsysProcess_WaitForExit(cp, CM_NULLPTR);
+ cmsysProcess_WaitForExit(cp, nullptr);
int result = cmsysProcess_GetState(cp);
if (result == cmsysProcess_State_Exited) {
@@ -891,13 +890,12 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
// dashboard.
cmCTestBuildErrorWarning errorwarning;
errorwarning.LogLine = 1;
- errorwarning.Text =
- "*** WARNING non-zero return value in ctest from: ";
- errorwarning.Text += argv[0];
- errorwarning.PreContext = "";
- errorwarning.PostContext = "";
+ errorwarning.Text = cmStrCat(
+ "*** WARNING non-zero return value in ctest from: ", argv[0]);
+ errorwarning.PreContext.clear();
+ errorwarning.PostContext.clear();
errorwarning.Error = false;
- this->ErrorsAndWarnings.push_back(errorwarning);
+ this->ErrorsAndWarnings.push_back(std::move(errorwarning));
this->TotalWarnings++;
}
}
@@ -915,15 +913,16 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, int* retVal,
// If there was an error running command, report that on the dashboard.
cmCTestBuildErrorWarning errorwarning;
errorwarning.LogLine = 1;
- errorwarning.Text = "*** ERROR executing: ";
- errorwarning.Text += cmsysProcess_GetErrorString(cp);
- errorwarning.PreContext = "";
- errorwarning.PostContext = "";
+ errorwarning.Text =
+ cmStrCat("*** ERROR executing: ", cmsysProcess_GetErrorString(cp));
+ errorwarning.PreContext.clear();
+ errorwarning.PostContext.clear();
errorwarning.Error = true;
- this->ErrorsAndWarnings.push_back(errorwarning);
+ this->ErrorsAndWarnings.push_back(std::move(errorwarning));
this->TotalErrors++;
- cmCTestLog(this->CTest, ERROR_MESSAGE, "There was an error: "
- << cmsysProcess_GetErrorString(cp) << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "There was an error: " << cmsysProcess_GetErrorString(cp)
+ << std::endl);
}
cmsysProcess_Delete(cp);
@@ -970,10 +969,9 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length,
if (it != queue->end()) {
// Create a contiguous array for the line
this->CurrentProcessingLine.clear();
- this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(),
- queue->begin(), it);
+ cmAppend(this->CurrentProcessingLine, queue->begin(), it);
this->CurrentProcessingLine.push_back(0);
- const char* line = &*this->CurrentProcessingLine.begin();
+ const char* line = this->CurrentProcessingLine.data();
// Process the line
int lineType = this->ProcessSingleLine(line);
@@ -1002,19 +1000,17 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length,
// This is an error or warning, so generate report
errorwarning.LogLine = static_cast<int>(this->OutputLineCounter + 1);
errorwarning.Text = line;
- errorwarning.PreContext = "";
- errorwarning.PostContext = "";
+ errorwarning.PreContext.clear();
+ errorwarning.PostContext.clear();
// Copy pre-context to report
- std::deque<std::string>::iterator pcit;
- for (pcit = this->PreContext.begin(); pcit != this->PreContext.end();
- ++pcit) {
- errorwarning.PreContext += *pcit + "\n";
+ for (std::string const& pc : this->PreContext) {
+ errorwarning.PreContext += pc + "\n";
}
this->PreContext.clear();
// Store report
- this->ErrorsAndWarnings.push_back(errorwarning);
+ this->ErrorsAndWarnings.push_back(std::move(errorwarning));
this->LastErrorOrWarning = this->ErrorsAndWarnings.end() - 1;
this->PostContextCount = 0;
} else {
@@ -1030,7 +1026,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length,
}
} else {
// Otherwise store pre-context for the next error
- this->PreContext.push_back(line);
+ this->PreContext.emplace_back(line);
if (this->PreContext.size() > this->MaxPreContext) {
this->PreContext.erase(this->PreContext.begin(),
this->PreContext.end() -
@@ -1052,7 +1048,8 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length,
this->LastTickChar, this->Quiet);
tickDisplayed = true;
if (tick % tick_line_len == 0 && tick > 0) {
- cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, " Size: "
+ cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT,
+ " Size: "
<< ((this->BuildOutputLogSize + 512) / 1024) << "K"
<< std::endl
<< " ",
@@ -1078,10 +1075,13 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
return b_REGULAR_LINE;
}
- cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << data << "]" << std::endl,
- this->Quiet);
+ // Ignore ANSI color codes when checking for errors and warnings.
+ std::string input(data);
+ std::string line;
+ this->ColorRemover->Replace(input, line);
- std::vector<cmsys::RegularExpression>::iterator it;
+ cmCTestOptionalLog(this->CTest, DEBUG, "Line: [" << line << "]" << std::endl,
+ this->Quiet);
int warningLine = 0;
int errorLine = 0;
@@ -1091,12 +1091,11 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
if (!this->ErrorQuotaReached) {
// Errors
int wrxCnt = 0;
- for (it = this->ErrorMatchRegex.begin(); it != this->ErrorMatchRegex.end();
- ++it) {
- if (it->find(data)) {
+ for (cmsys::RegularExpression& rx : this->ErrorMatchRegex) {
+ if (rx.find(line.c_str())) {
errorLine = 1;
cmCTestOptionalLog(this->CTest, DEBUG,
- " Error Line: " << data << " (matches: "
+ " Error Line: " << line << " (matches: "
<< this->CustomErrorMatches[wrxCnt]
<< ")" << std::endl,
this->Quiet);
@@ -1106,12 +1105,12 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
}
// Error exceptions
wrxCnt = 0;
- for (it = this->ErrorExceptionRegex.begin();
- it != this->ErrorExceptionRegex.end(); ++it) {
- if (it->find(data)) {
+ for (cmsys::RegularExpression& rx : this->ErrorExceptionRegex) {
+ if (rx.find(line.c_str())) {
errorLine = 0;
- cmCTestOptionalLog(this->CTest, DEBUG, " Not an error Line: "
- << data << " (matches: "
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ " Not an error Line: "
+ << line << " (matches: "
<< this->CustomErrorExceptions[wrxCnt] << ")"
<< std::endl,
this->Quiet);
@@ -1123,12 +1122,12 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
if (!this->WarningQuotaReached) {
// Warnings
int wrxCnt = 0;
- for (it = this->WarningMatchRegex.begin();
- it != this->WarningMatchRegex.end(); ++it) {
- if (it->find(data)) {
+ for (cmsys::RegularExpression& rx : this->WarningMatchRegex) {
+ if (rx.find(line.c_str())) {
warningLine = 1;
- cmCTestOptionalLog(this->CTest, DEBUG, " Warning Line: "
- << data << " (matches: "
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ " Warning Line: "
+ << line << " (matches: "
<< this->CustomWarningMatches[wrxCnt] << ")"
<< std::endl,
this->Quiet);
@@ -1139,12 +1138,12 @@ int cmCTestBuildHandler::ProcessSingleLine(const char* data)
wrxCnt = 0;
// Warning exceptions
- for (it = this->WarningExceptionRegex.begin();
- it != this->WarningExceptionRegex.end(); ++it) {
- if (it->find(data)) {
+ for (cmsys::RegularExpression& rx : this->WarningExceptionRegex) {
+ if (rx.find(line.c_str())) {
warningLine = 0;
- cmCTestOptionalLog(this->CTest, DEBUG, " Not a warning Line: "
- << data << " (matches: "
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ " Not a warning Line: "
+ << line << " (matches: "
<< this->CustomWarningExceptions[wrxCnt] << ")"
<< std::endl,
this->Quiet);
diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h
index ef3cddf1b..a5193f6e5 100644
--- a/Source/CTest/cmCTestBuildHandler.h
+++ b/Source/CTest/cmCTestBuildHandler.h
@@ -3,19 +3,24 @@
#ifndef cmCTestBuildHandler_h
#define cmCTestBuildHandler_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmCTestGenericHandler.h"
-
-#include "cmProcessOutput.h"
-#include "cmsys/RegularExpression.hxx"
+#include <chrono>
#include <deque>
#include <iosfwd>
-#include <stddef.h>
#include <string>
#include <vector>
+#include <stddef.h>
+
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmCTestGenericHandler.h"
+#include "cmDuration.h"
+#include "cmProcessOutput.h"
+
class cmMakefile;
+class cmStringReplaceHelper;
class cmXMLWriter;
/** \class cmCTestBuildHandler
@@ -25,22 +30,22 @@ class cmXMLWriter;
class cmCTestBuildHandler : public cmCTestGenericHandler
{
public:
- typedef cmCTestGenericHandler Superclass;
- typedef cmProcessOutput::Encoding Encoding;
+ using Superclass = cmCTestGenericHandler;
+ using Encoding = cmProcessOutput::Encoding;
/*
* The main entry point for this class
*/
- int ProcessHandler() CM_OVERRIDE;
+ int ProcessHandler() override;
cmCTestBuildHandler();
- void PopulateCustomVectors(cmMakefile* mf) CM_OVERRIDE;
+ void PopulateCustomVectors(cmMakefile* mf) override;
/**
* Initialize handler
*/
- void Initialize() CM_OVERRIDE;
+ void Initialize() override;
int GetTotalErrors() { return this->TotalErrors; }
int GetTotalWarnings() { return this->TotalWarnings; }
@@ -50,7 +55,7 @@ private:
//! Run command specialized for make and configure. Returns process status
// and retVal is return value or exception.
- int RunMakeCommand(const char* command, int* retVal, const char* dir,
+ int RunMakeCommand(const std::string& command, int* retVal, const char* dir,
int timeout, std::ostream& ofs,
Encoding encoding = cmProcessOutput::Auto);
@@ -86,14 +91,14 @@ private:
void GenerateXMLHeader(cmXMLWriter& xml);
void GenerateXMLLaunched(cmXMLWriter& xml);
void GenerateXMLLogScraped(cmXMLWriter& xml);
- void GenerateXMLFooter(cmXMLWriter& xml, double elapsed_build_time);
+ void GenerateXMLFooter(cmXMLWriter& xml, cmDuration elapsed_build_time);
bool IsLaunchedErrorFile(const char* fname);
bool IsLaunchedWarningFile(const char* fname);
std::string StartBuild;
std::string EndBuild;
- double StartBuildTime;
- double EndBuildTime;
+ std::chrono::system_clock::time_point StartBuildTime;
+ std::chrono::system_clock::time_point EndBuildTime;
std::vector<std::string> CustomErrorMatches;
std::vector<std::string> CustomErrorExceptions;
@@ -108,7 +113,7 @@ private:
std::vector<cmsys::RegularExpression> WarningMatchRegex;
std::vector<cmsys::RegularExpression> WarningExceptionRegex;
- typedef std::deque<char> t_BuildProcessingQueueType;
+ using t_BuildProcessingQueueType = std::deque<char>;
void ProcessBuffer(const char* data, size_t length, size_t& tick,
size_t tick_len, std::ostream& ofs,
@@ -123,7 +128,7 @@ private:
std::string SimplifySourceDir;
std::string SimplifyBuildDir;
size_t OutputLineCounter;
- typedef std::vector<cmCTestBuildErrorWarning> t_ErrorsAndWarningsVector;
+ using t_ErrorsAndWarningsVector = std::vector<cmCTestBuildErrorWarning>;
t_ErrorsAndWarningsVector ErrorsAndWarnings;
t_ErrorsAndWarningsVector::iterator LastErrorOrWarning;
size_t PostContextCount;
@@ -141,6 +146,9 @@ private:
int MaxErrors;
int MaxWarnings;
+ // Used to remove ANSI color codes before checking for errors and warnings.
+ cmStringReplaceHelper* ColorRemover;
+
bool UseCTestLaunch;
std::string CTestLaunchDir;
class LaunchHelper;
diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx
index fad360ba4..45ec39066 100644
--- a/Source/CTest/cmCTestCVS.cxx
+++ b/Source/CTest/cmCTestCVS.cxx
@@ -2,23 +2,25 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestCVS.h"
+#include <utility>
+
+#include <cm/string_view>
+
+#include "cmsys/FStream.hxx"
+#include "cmsys/RegularExpression.hxx"
+
#include "cmCTest.h"
#include "cmProcessTools.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
-#include "cmsys/FStream.hxx"
-#include "cmsys/RegularExpression.hxx"
-#include <utility>
-
cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log)
: cmCTestVC(ct, log)
{
}
-cmCTestCVS::~cmCTestCVS()
-{
-}
+cmCTestCVS::~cmCTestCVS() = default;
class cmCTestCVS::UpdateParser : public cmCTestVC::LineParser
{
@@ -46,7 +48,7 @@ private:
cmsys::RegularExpression RegexFileRemoved1;
cmsys::RegularExpression RegexFileRemoved2;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexFileUpdated.find(this->Line)) {
this->DoFile(PathUpdated, this->RegexFileUpdated.match(2));
@@ -80,7 +82,7 @@ bool cmCTestCVS::UpdateImpl()
opts = "-dP";
}
}
- std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
+ std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
// Specify the start time for nightly testing.
if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) {
@@ -92,11 +94,10 @@ bool cmCTestCVS::UpdateImpl()
cvs_update.push_back(this->CommandLineTool.c_str());
cvs_update.push_back("-z3");
cvs_update.push_back("update");
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- cvs_update.push_back(ai->c_str());
+ for (std::string const& arg : args) {
+ cvs_update.push_back(arg.c_str());
}
- cvs_update.push_back(CM_NULLPTR);
+ cvs_update.push_back(nullptr);
UpdateParser out(this, "up-out> ");
UpdateParser err(this, "up-err> ");
@@ -106,14 +107,14 @@ bool cmCTestCVS::UpdateImpl()
class cmCTestCVS::LogParser : public cmCTestVC::LineParser
{
public:
- typedef cmCTestCVS::Revision Revision;
+ using Revision = cmCTestCVS::Revision;
LogParser(cmCTestCVS* cvs, const char* prefix, std::vector<Revision>& revs)
: CVS(cvs)
, Revisions(revs)
, Section(SectionHeader)
{
- this->SetLog(&cvs->Log, prefix),
- this->RegexRevision.compile("^revision +([^ ]*) *$");
+ this->SetLog(&cvs->Log, prefix);
+ this->RegexRevision.compile("^revision +([^ ]*) *$");
this->RegexBranches.compile("^branches: .*$");
this->RegexPerson.compile("^date: +([^;]+); +author: +([^;]+);");
}
@@ -133,10 +134,11 @@ private:
SectionType Section;
Revision Rev;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
- if (this->Line == ("======================================="
- "======================================")) {
+ if (this->Line ==
+ ("======================================="
+ "======================================")) {
// This line ends the revision list.
if (this->Section == SectionRevisions) {
this->FinishRevision();
@@ -206,8 +208,7 @@ std::string cmCTestCVS::ComputeBranchFlag(std::string const& dir)
if (tagStream && cmSystemTools::GetLineFromStream(tagStream, tagLine) &&
tagLine.size() > 1 && tagLine[0] == 'T') {
// Use the branch specified in the tag file.
- std::string flag = "-r";
- flag += tagLine.substr(1);
+ std::string flag = cmStrCat("-r", cm::string_view(tagLine).substr(1));
return flag;
}
// Use the default branch.
@@ -221,8 +222,9 @@ void cmCTestCVS::LoadRevisions(std::string const& file, const char* branchFlag,
// Run "cvs log" to get revisions of this file on this branch.
const char* cvs = this->CommandLineTool.c_str();
- const char* cvs_log[] = { cvs, "log", "-N",
- branchFlag, file.c_str(), CM_NULLPTR };
+ const char* cvs_log[] = {
+ cvs, "log", "-N", branchFlag, file.c_str(), nullptr
+ };
LogParser out(this, "log-out> ", revisions);
OutputLogger err(this->Log, "log-err> ");
@@ -241,12 +243,12 @@ void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
// Load revisions and write an entry for each file in this directory.
std::vector<Revision> revisions;
- for (Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) {
- std::string full = path + slash + fi->first;
+ for (auto const& fi : dir) {
+ std::string full = path + slash + fi.first;
// Load two real or unknown revisions.
revisions.clear();
- if (fi->second != PathUpdated) {
+ if (fi.second != PathUpdated) {
// For local modifications the current rev is unknown and the
// prior rev is the latest from cvs.
revisions.push_back(this->Unknown);
@@ -255,8 +257,8 @@ void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
revisions.resize(2, this->Unknown);
// Write the entry for this file with these revisions.
- File f(fi->second, &revisions[0], &revisions[1]);
- this->WriteXMLEntry(xml, path, fi->first, full, f);
+ File f(fi.second, &revisions[0], &revisions[1]);
+ this->WriteXMLEntry(xml, path, fi.first, full, f);
}
xml.EndElement(); // Directory
}
@@ -268,10 +270,8 @@ bool cmCTestCVS::WriteXMLUpdates(cmXMLWriter& xml)
" "
<< std::flush);
- for (std::map<std::string, Directory>::const_iterator di =
- this->Dirs.begin();
- di != this->Dirs.end(); ++di) {
- this->WriteXMLDirectory(xml, di->first, di->second);
+ for (auto const& d : this->Dirs) {
+ this->WriteXMLDirectory(xml, d.first, d.second);
}
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
diff --git a/Source/CTest/cmCTestCVS.h b/Source/CTest/cmCTestCVS.h
index 1208cfad6..7d33d8f2d 100644
--- a/Source/CTest/cmCTestCVS.h
+++ b/Source/CTest/cmCTestCVS.h
@@ -3,15 +3,15 @@
#ifndef cmCTestCVS_h
#define cmCTestCVS_h
-#include "cmConfigure.h"
-
-#include "cmCTestVC.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
#include <string>
#include <vector>
+#include "cmCTestVC.h"
+
class cmCTest;
class cmXMLWriter;
@@ -25,12 +25,12 @@ public:
/** Construct with a CTest instance and update log stream. */
cmCTestCVS(cmCTest* ctest, std::ostream& log);
- ~cmCTestCVS() CM_OVERRIDE;
+ ~cmCTestCVS() override;
private:
// Implement cmCTestVC internal API.
- bool UpdateImpl() CM_OVERRIDE;
- bool WriteXMLUpdates(cmXMLWriter& xml) CM_OVERRIDE;
+ bool UpdateImpl() override;
+ bool WriteXMLUpdates(cmXMLWriter& xml) override;
// Update status for files in each directory.
class Directory : public std::map<std::string, PathStatus>
diff --git a/Source/CTest/cmCTestCommand.h b/Source/CTest/cmCTestCommand.h
index 6fc237aac..8efb4194c 100644
--- a/Source/CTest/cmCTestCommand.h
+++ b/Source/CTest/cmCTestCommand.h
@@ -20,8 +20,8 @@ class cmCTestCommand : public cmCommand
public:
cmCTestCommand()
{
- this->CTest = CM_NULLPTR;
- this->CTestScriptHandler = CM_NULLPTR;
+ this->CTest = nullptr;
+ this->CTestScriptHandler = nullptr;
}
cmCTest* CTest;
diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx
index 73e893df3..f2f42b4f2 100644
--- a/Source/CTest/cmCTestConfigureCommand.cxx
+++ b/Source/CTest/cmCTestConfigureCommand.cxx
@@ -2,30 +2,32 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestConfigureCommand.h"
+#include <cstring>
+#include <sstream>
+#include <vector>
+
+#include "cm_static_string_view.hxx"
+
#include "cmCTest.h"
-#include "cmCTestGenericHandler.h"
+#include "cmCTestConfigureHandler.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
-#include <sstream>
-#include <string.h>
-#include <vector>
-
-cmCTestConfigureCommand::cmCTestConfigureCommand()
+void cmCTestConfigureCommand::BindArguments()
{
- this->Arguments[ctc_OPTIONS] = "OPTIONS";
- this->Arguments[ctc_LAST] = CM_NULLPTR;
- this->Last = ctc_LAST;
+ this->cmCTestHandlerCommand::BindArguments();
+ this->Bind("OPTIONS"_s, this->Options);
}
cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
{
std::vector<std::string> options;
- if (this->Values[ctc_OPTIONS]) {
- cmSystemTools::ExpandListArgument(this->Values[ctc_OPTIONS], options);
+ if (!this->Options.empty()) {
+ cmExpandList(this->Options, options);
}
if (this->CTest->GetCTestConfiguration("BuildDirectory").empty()) {
@@ -33,7 +35,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
"Build directory not specified. Either use BUILD "
"argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY "
"variable");
- return CM_NULLPTR;
+ return nullptr;
}
const char* ctestConfigureCommand =
@@ -53,15 +55,15 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
"Source directory not specified. Either use SOURCE "
"argument to CTEST_CONFIGURE command or set CTEST_SOURCE_DIRECTORY "
"variable");
- return CM_NULLPTR;
+ return nullptr;
}
const std::string cmakelists_file = source_dir + "/CMakeLists.txt";
- if (!cmSystemTools::FileExists(cmakelists_file.c_str())) {
+ if (!cmSystemTools::FileExists(cmakelists_file)) {
std::ostringstream e;
e << "CMakeLists.txt file does not exist [" << cmakelists_file << "]";
this->SetError(e.str());
- return CM_NULLPTR;
+ return nullptr;
}
bool multiConfig = false;
@@ -75,22 +77,16 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
delete gg;
}
- std::string cmakeConfigureCommand = "\"";
- cmakeConfigureCommand += cmSystemTools::GetCMakeCommand();
- cmakeConfigureCommand += "\"";
-
- std::vector<std::string>::const_iterator it;
- std::string option;
- for (it = options.begin(); it != options.end(); ++it) {
- option = *it;
+ std::string cmakeConfigureCommand =
+ cmStrCat('"', cmSystemTools::GetCMakeCommand(), '"');
+ for (std::string const& option : options) {
cmakeConfigureCommand += " \"";
cmakeConfigureCommand += option;
cmakeConfigureCommand += "\"";
- if ((CM_NULLPTR != strstr(option.c_str(), "CMAKE_BUILD_TYPE=")) ||
- (CM_NULLPTR !=
- strstr(option.c_str(), "CMAKE_BUILD_TYPE:STRING="))) {
+ if ((nullptr != strstr(option.c_str(), "CMAKE_BUILD_TYPE=")) ||
+ (nullptr != strstr(option.c_str(), "CMAKE_BUILD_TYPE:STRING="))) {
cmakeBuildTypeInOptions = true;
}
}
@@ -137,17 +133,18 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
"Configure command is not specified. If this is a "
"\"built with CMake\" project, set CTEST_CMAKE_GENERATOR. If not, "
"set CTEST_CONFIGURE_COMMAND.");
- return CM_NULLPTR;
+ return nullptr;
}
}
- cmCTestGenericHandler* handler =
- this->CTest->GetInitializedHandler("configure");
- if (!handler) {
- this->SetError(
- "internal CTest error. Cannot instantiate configure handler");
- return CM_NULLPTR;
+ if (const char* labelsForSubprojects =
+ this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) {
+ this->CTest->SetCTestConfiguration("LabelsForSubprojects",
+ labelsForSubprojects, this->Quiet);
}
+
+ cmCTestConfigureHandler* handler = this->CTest->GetConfigureHandler();
+ handler->Initialize();
handler->SetQuiet(this->Quiet);
return handler;
}
diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h
index 917f5ab8b..3f5944af6 100644
--- a/Source/CTest/cmCTestConfigureCommand.h
+++ b/Source/CTest/cmCTestConfigureCommand.h
@@ -3,14 +3,17 @@
#ifndef cmCTestConfigureCommand_h
#define cmCTestConfigureCommand_h
-#include "cmConfigure.h"
-
-#include "cmCTestHandlerCommand.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <utility>
+
+#include <cm/memory>
+
+#include "cmCTestHandlerCommand.h"
+#include "cmCommand.h"
class cmCTestGenericHandler;
-class cmCommand;
/** \class cmCTestConfigure
* \brief Run a ctest script
@@ -20,33 +23,27 @@ class cmCommand;
class cmCTestConfigureCommand : public cmCTestHandlerCommand
{
public:
- cmCTestConfigureCommand();
-
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE
+ std::unique_ptr<cmCommand> Clone() override
{
- cmCTestConfigureCommand* ni = new cmCTestConfigureCommand;
+ auto ni = cm::make_unique<cmCTestConfigureCommand>();
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
- return ni;
+ return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
* The name of the command as specified in CMakeList.txt.
*/
- std::string GetName() const CM_OVERRIDE { return "ctest_configure"; }
+ std::string GetName() const override { return "ctest_configure"; }
protected:
- cmCTestGenericHandler* InitializeHandler() CM_OVERRIDE;
+ void BindArguments() override;
+ cmCTestGenericHandler* InitializeHandler() override;
- enum
- {
- ctc_FIRST = ct_LAST,
- ctc_OPTIONS,
- ctc_LAST
- };
+ std::string Options;
};
#endif
diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx
index 5d87f3fb4..914930e00 100644
--- a/Source/CTest/cmCTestConfigureHandler.cxx
+++ b/Source/CTest/cmCTestConfigureHandler.cxx
@@ -2,17 +2,16 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestConfigureHandler.h"
+#include <chrono>
+#include <ostream>
+#include <string>
+
#include "cmCTest.h"
+#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
-#include "cmSystemTools.h"
#include "cmXMLWriter.h"
-#include <ostream>
-#include <string>
-
-cmCTestConfigureHandler::cmCTestConfigureHandler()
-{
-}
+cmCTestConfigureHandler::cmCTestConfigureHandler() = default;
void cmCTestConfigureHandler::Initialize()
{
@@ -43,28 +42,28 @@ int cmCTestConfigureHandler::ProcessHandler()
return -1;
}
- double elapsed_time_start = cmSystemTools::GetTime();
+ auto elapsed_time_start = std::chrono::steady_clock::now();
std::string output;
int retVal = 0;
int res = 0;
if (!this->CTest->GetShowOnly()) {
cmGeneratedFileStream os;
if (!this->StartResultingXML(cmCTest::PartConfigure, "Configure", os)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open configure file"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot open configure file" << std::endl);
return 1;
}
std::string start_time = this->CTest->CurrentTime();
- unsigned int start_time_time =
- static_cast<unsigned int>(cmSystemTools::GetTime());
+ auto start_time_time = std::chrono::system_clock::now();
cmGeneratedFileStream ofs;
this->StartLogFile("Configure", ofs);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Configure with command: " << cCommand << std::endl,
this->Quiet);
- res = this->CTest->RunMakeCommand(cCommand.c_str(), output, &retVal,
- buildDirectory.c_str(), 0, ofs);
+ res = this->CTest->RunMakeCommand(cCommand, output, &retVal,
+ buildDirectory.c_str(),
+ cmDuration::zero(), ofs);
if (ofs) {
ofs.close();
@@ -73,6 +72,7 @@ int cmCTestConfigureHandler::ProcessHandler()
if (os) {
cmXMLWriter xml(os);
this->CTest->StartXML(xml, this->AppendXML);
+ this->CTest->GenerateSubprojectsOutput(xml);
xml.StartElement("Configure");
xml.Element("StartDateTime", start_time);
xml.Element("StartConfigureTime", start_time_time);
@@ -81,12 +81,11 @@ int cmCTestConfigureHandler::ProcessHandler()
xml.Element("Log", output);
xml.Element("ConfigureStatus", retVal);
xml.Element("EndDateTime", this->CTest->CurrentTime());
- xml.Element("EndConfigureTime",
- static_cast<unsigned int>(cmSystemTools::GetTime()));
- xml.Element(
- "ElapsedMinutes",
- static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
- 10.0);
+ xml.Element("EndConfigureTime", std::chrono::system_clock::now());
+ xml.Element("ElapsedMinutes",
+ std::chrono::duration_cast<std::chrono::minutes>(
+ std::chrono::steady_clock::now() - elapsed_time_start)
+ .count());
xml.EndElement(); // Configure
this->CTest->EndXML(xml);
}
diff --git a/Source/CTest/cmCTestConfigureHandler.h b/Source/CTest/cmCTestConfigureHandler.h
index 2b452829c..01fe8011e 100644
--- a/Source/CTest/cmCTestConfigureHandler.h
+++ b/Source/CTest/cmCTestConfigureHandler.h
@@ -3,7 +3,7 @@
#ifndef cmCTestConfigureHandler_h
#define cmCTestConfigureHandler_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include "cmCTestGenericHandler.h"
@@ -14,16 +14,16 @@
class cmCTestConfigureHandler : public cmCTestGenericHandler
{
public:
- typedef cmCTestGenericHandler Superclass;
+ using Superclass = cmCTestGenericHandler;
/*
* The main entry point for this class
*/
- int ProcessHandler() CM_OVERRIDE;
+ int ProcessHandler() override;
cmCTestConfigureHandler();
- void Initialize() CM_OVERRIDE;
+ void Initialize() override;
};
#endif
diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx
index 535da586d..d6e6be395 100644
--- a/Source/CTest/cmCTestCoverageCommand.cxx
+++ b/Source/CTest/cmCTestCoverageCommand.cxx
@@ -2,14 +2,27 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestCoverageCommand.h"
+#include <set>
+
+#include "cm_static_string_view.hxx"
+
+#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestCoverageHandler.h"
class cmCTestGenericHandler;
-cmCTestCoverageCommand::cmCTestCoverageCommand()
+void cmCTestCoverageCommand::BindArguments()
+{
+ this->cmCTestHandlerCommand::BindArguments();
+ this->Bind("LABELS"_s, this->Labels);
+}
+
+void cmCTestCoverageCommand::CheckArguments(
+ std::vector<std::string> const& keywords)
{
- this->LabelsMentioned = false;
+ this->LabelsMentioned =
+ !this->Labels.empty() || cmContains(keywords, "LABELS");
}
cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler()
@@ -19,43 +32,15 @@ cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler()
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS",
this->Quiet);
- cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>(
- this->CTest->GetInitializedHandler("coverage"));
- if (!handler) {
- this->SetError("internal CTest error. Cannot instantiate test handler");
- return CM_NULLPTR;
- }
+ cmCTestCoverageHandler* handler = this->CTest->GetCoverageHandler();
+ handler->Initialize();
// If a LABELS option was given, select only files with the labels.
if (this->LabelsMentioned) {
- handler->SetLabelFilter(this->Labels);
+ handler->SetLabelFilter(
+ std::set<std::string>(this->Labels.begin(), this->Labels.end()));
}
handler->SetQuiet(this->Quiet);
return handler;
}
-
-bool cmCTestCoverageCommand::CheckArgumentKeyword(std::string const& arg)
-{
- // Look for arguments specific to this command.
- if (arg == "LABELS") {
- this->ArgumentDoing = ArgumentDoingLabels;
- this->LabelsMentioned = true;
- return true;
- }
-
- // Look for other arguments.
- return this->Superclass::CheckArgumentKeyword(arg);
-}
-
-bool cmCTestCoverageCommand::CheckArgumentValue(std::string const& arg)
-{
- // Handle states specific to this command.
- if (this->ArgumentDoing == ArgumentDoingLabels) {
- this->Labels.insert(arg);
- return true;
- }
-
- // Look for other arguments.
- return this->Superclass::CheckArgumentValue(arg);
-}
diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h
index 78c4f61f6..76aaf46f8 100644
--- a/Source/CTest/cmCTestCoverageCommand.h
+++ b/Source/CTest/cmCTestCoverageCommand.h
@@ -3,15 +3,18 @@
#ifndef cmCTestCoverageCommand_h
#define cmCTestCoverageCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmCTestHandlerCommand.h"
-
-#include <set>
#include <string>
+#include <utility>
+#include <vector>
+
+#include <cm/memory>
+
+#include "cmCTestHandlerCommand.h"
+#include "cmCommand.h"
class cmCTestGenericHandler;
-class cmCommand;
/** \class cmCTestCoverage
* \brief Run a ctest script
@@ -21,40 +24,29 @@ class cmCommand;
class cmCTestCoverageCommand : public cmCTestHandlerCommand
{
public:
- cmCTestCoverageCommand();
-
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE
+ std::unique_ptr<cmCommand> Clone() override
{
- cmCTestCoverageCommand* ni = new cmCTestCoverageCommand;
+ auto ni = cm::make_unique<cmCTestCoverageCommand>();
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
- return ni;
+ return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
* The name of the command as specified in CMakeList.txt.
*/
- std::string GetName() const CM_OVERRIDE { return "ctest_coverage"; }
-
- typedef cmCTestHandlerCommand Superclass;
+ std::string GetName() const override { return "ctest_coverage"; }
protected:
- cmCTestGenericHandler* InitializeHandler() CM_OVERRIDE;
-
- bool CheckArgumentKeyword(std::string const& arg) CM_OVERRIDE;
- bool CheckArgumentValue(std::string const& arg) CM_OVERRIDE;
-
- enum
- {
- ArgumentDoingLabels = Superclass::ArgumentDoingLast1,
- ArgumentDoingLast2
- };
+ void BindArguments() override;
+ void CheckArguments(std::vector<std::string> const& keywords) override;
+ cmCTestGenericHandler* InitializeHandler() override;
bool LabelsMentioned;
- std::set<std::string> Labels;
+ std::vector<std::string> Labels;
};
#endif
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 28fae1c7e..4cd783fd6 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -2,7 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestCoverageHandler.h"
+#include <algorithm>
+#include <chrono>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <iomanip>
+#include <iterator>
+#include <sstream>
+#include <utility>
+
+#include "cmsys/FStream.hxx"
+#include "cmsys/Glob.hxx"
+#include "cmsys/Process.h"
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmAlgorithms.h"
#include "cmCTest.h"
+#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
#include "cmParseBlanketJSCoverage.h"
#include "cmParseCacheCoverage.h"
@@ -11,22 +28,10 @@
#include "cmParseGTMCoverage.h"
#include "cmParseJacocoCoverage.h"
#include "cmParsePHPCoverage.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
#include "cmXMLWriter.h"
-#include "cmake.h"
-
-#include "cmsys/FStream.hxx"
-#include "cmsys/Glob.hxx"
-#include "cmsys/Process.h"
-#include "cmsys/RegularExpression.hxx"
-#include <algorithm>
-#include <iomanip>
-#include <iterator>
-#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <utility>
class cmMakefile;
@@ -39,7 +44,7 @@ public:
{
this->Process = cmsysProcess_New();
this->PipeState = -1;
- this->TimeOut = -1;
+ this->TimeOut = cmDuration(-1);
}
~cmCTestRunProcess()
{
@@ -50,38 +55,37 @@ public:
}
cmsysProcess_Delete(this->Process);
}
+ cmCTestRunProcess(const cmCTestRunProcess&) = delete;
+ cmCTestRunProcess& operator=(const cmCTestRunProcess&) = delete;
void SetCommand(const char* command)
{
this->CommandLineStrings.clear();
- this->CommandLineStrings.push_back(command);
- ;
+ this->CommandLineStrings.emplace_back(command);
}
void AddArgument(const char* arg)
{
if (arg) {
- this->CommandLineStrings.push_back(arg);
+ this->CommandLineStrings.emplace_back(arg);
}
}
void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir; }
- void SetTimeout(double t) { this->TimeOut = t; }
+ void SetTimeout(cmDuration t) { this->TimeOut = t; }
bool StartProcess()
{
std::vector<const char*> args;
- for (std::vector<std::string>::iterator i =
- this->CommandLineStrings.begin();
- i != this->CommandLineStrings.end(); ++i) {
- args.push_back(i->c_str());
+ for (std::string const& cl : this->CommandLineStrings) {
+ args.push_back(cl.c_str());
}
- args.push_back(CM_NULLPTR); // null terminate
- cmsysProcess_SetCommand(this->Process, &*args.begin());
+ args.push_back(nullptr); // null terminate
+ cmsysProcess_SetCommand(this->Process, args.data());
if (!this->WorkingDirectory.empty()) {
cmsysProcess_SetWorkingDirectory(this->Process,
this->WorkingDirectory.c_str());
}
cmsysProcess_SetOption(this->Process, cmsysProcess_Option_HideWindow, 1);
- if (this->TimeOut != -1) {
- cmsysProcess_SetTimeout(this->Process, this->TimeOut);
+ if (this->TimeOut >= cmDuration::zero()) {
+ cmsysProcess_SetTimeout(this->Process, this->TimeOut.count());
}
cmsysProcess_Execute(this->Process);
this->PipeState = cmsysProcess_GetState(this->Process);
@@ -97,7 +101,7 @@ public:
{
cmsysProcess_SetPipeFile(this->Process, cmsysProcess_Pipe_STDERR, fname);
}
- int WaitForExit(double* timeout = CM_NULLPTR)
+ int WaitForExit(double* timeout = nullptr)
{
this->PipeState = cmsysProcess_WaitForExit(this->Process, timeout);
return this->PipeState;
@@ -109,12 +113,10 @@ private:
cmsysProcess* Process;
std::vector<std::string> CommandLineStrings;
std::string WorkingDirectory;
- double TimeOut;
+ cmDuration TimeOut;
};
-cmCTestCoverageHandler::cmCTestCoverageHandler()
-{
-}
+cmCTestCoverageHandler::cmCTestCoverageHandler() = default;
void cmCTestCoverageHandler::Initialize()
{
@@ -129,17 +131,15 @@ void cmCTestCoverageHandler::Initialize()
void cmCTestCoverageHandler::CleanCoverageLogFiles(std::ostream& log)
{
- std::string logGlob = this->CTest->GetCTestConfiguration("BuildDirectory");
- logGlob += "/Testing/";
- logGlob += this->CTest->GetCurrentTag();
- logGlob += "/CoverageLog*";
+ std::string logGlob =
+ cmStrCat(this->CTest->GetCTestConfiguration("BuildDirectory"), "/Testing/",
+ this->CTest->GetCurrentTag(), "/CoverageLog*");
cmsys::Glob gl;
gl.FindFiles(logGlob);
std::vector<std::string> const& files = gl.GetFiles();
- for (std::vector<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
- log << "Removing old coverage log: " << *fi << "\n";
- cmSystemTools::RemoveFile(*fi);
+ for (std::string const& f : files) {
+ log << "Removing old coverage log: " << f << "\n";
+ cmSystemTools::RemoveFile(f);
}
}
@@ -176,34 +176,31 @@ void cmCTestCoverageHandler::StartCoverageLogXML(cmXMLWriter& xml)
this->CTest->StartXML(xml, this->AppendXML);
xml.StartElement("CoverageLog");
xml.Element("StartDateTime", this->CTest->CurrentTime());
- xml.Element("StartTime",
- static_cast<unsigned int>(cmSystemTools::GetTime()));
+ xml.Element("StartTime", std::chrono::system_clock::now());
}
void cmCTestCoverageHandler::EndCoverageLogXML(cmXMLWriter& xml)
{
xml.Element("EndDateTime", this->CTest->CurrentTime());
- xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
+ xml.Element("EndTime", std::chrono::system_clock::now());
xml.EndElement(); // CoverageLog
this->CTest->EndXML(xml);
}
-bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
- const char* srcDir,
- const char* binDir)
+bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file,
+ std::string const& srcDir,
+ std::string const& binDir)
{
if (this->IsFilteredOut(file)) {
return false;
}
- std::vector<cmsys::RegularExpression>::iterator sit;
- for (sit = this->CustomCoverageExcludeRegex.begin();
- sit != this->CustomCoverageExcludeRegex.end(); ++sit) {
- if (sit->find(file)) {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " File "
- << file << " is excluded in CTestCustom.ctest"
- << std::endl;
- , this->Quiet);
+ for (cmsys::RegularExpression& rx : this->CustomCoverageExcludeRegex) {
+ if (rx.find(file)) {
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_VERBOSE_OUTPUT,
+ " File " << file << " is excluded in CTestCustom.ctest" << std::endl;
+ , this->Quiet);
return false;
}
}
@@ -230,7 +227,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
checkDir = fBinDir;
}
std::string ndc = cmSystemTools::FileExistsInParentDirectories(
- ".NoDartCoverage", fFile.c_str(), checkDir.c_str());
+ ".NoDartCoverage", fFile, checkDir);
if (!ndc.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Found: " << ndc << " so skip coverage of " << file
@@ -244,7 +241,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
// If it is the same as fileDir, then ignore, otherwise check.
std::string relPath;
if (!checkDir.empty()) {
- relPath = cmSystemTools::RelativePath(checkDir.c_str(), fFile.c_str());
+ relPath = cmSystemTools::RelativePath(checkDir, fFile);
} else {
relPath = fFile;
}
@@ -261,8 +258,8 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
return true;
}
- ndc = cmSystemTools::FileExistsInParentDirectories(
- ".NoDartCoverage", fFile.c_str(), checkDir.c_str());
+ ndc = cmSystemTools::FileExistsInParentDirectories(".NoDartCoverage", fFile,
+ checkDir);
if (!ndc.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Found: " << ndc << " so skip coverage of: " << file
@@ -281,13 +278,12 @@ int cmCTestCoverageHandler::ProcessHandler()
this->CTest->ClearSubmitFiles(cmCTest::PartCoverage);
int error = 0;
// do we have time for this
- if (this->CTest->GetRemainingTimeAllowed() < 120) {
+ if (this->CTest->GetRemainingTimeAllowed() < std::chrono::minutes(2)) {
return error;
}
std::string coverage_start_time = this->CTest->CurrentTime();
- unsigned int coverage_start_time_time =
- static_cast<unsigned int>(cmSystemTools::GetTime());
+ auto coverage_start_time_time = std::chrono::system_clock::now();
std::string sourceDir =
this->CTest->GetCTestConfiguration("SourceDirectory");
std::string binaryDir = this->CTest->GetCTestConfiguration("BuildDirectory");
@@ -295,13 +291,14 @@ int cmCTestCoverageHandler::ProcessHandler()
this->LoadLabels();
cmGeneratedFileStream ofs;
- double elapsed_time_start = cmSystemTools::GetTime();
+ auto elapsed_time_start = std::chrono::steady_clock::now();
if (!this->StartLogFile("Coverage", ofs)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot create LastCoverage.log file" << std::endl);
}
- ofs << "Performing coverage: " << elapsed_time_start << std::endl;
+ ofs << "Performing coverage: "
+ << elapsed_time_start.time_since_epoch().count() << std::endl;
this->CleanCoverageLogFiles(ofs);
cmSystemTools::ConvertToUnixSlashes(sourceDir);
@@ -319,11 +316,8 @@ int cmCTestCoverageHandler::ProcessHandler()
// setup the regex exclude stuff
this->CustomCoverageExcludeRegex.clear();
- std::vector<std::string>::iterator rexIt;
- for (rexIt = this->CustomCoverageExclude.begin();
- rexIt != this->CustomCoverageExclude.end(); ++rexIt) {
- this->CustomCoverageExcludeRegex.push_back(
- cmsys::RegularExpression(rexIt->c_str()));
+ for (std::string const& rex : this->CustomCoverageExclude) {
+ this->CustomCoverageExcludeRegex.emplace_back(rex);
}
if (this->HandleBullseyeCoverage(&cont)) {
@@ -396,8 +390,8 @@ int cmCTestCoverageHandler::ProcessHandler()
if (!this->StartResultingXML(cmCTest::PartCoverage, "Coverage",
covSumFile)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open coverage summary file."
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot open coverage summary file." << std::endl);
return -1;
}
covSumFile.setf(std::ios::fixed, std::ios::floatfield);
@@ -414,7 +408,6 @@ int cmCTestCoverageHandler::ProcessHandler()
return -1;
}
this->StartCoverageLogXML(covLogXML);
- cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator fileIterator;
int cnt = 0;
long total_tested = 0;
long total_untested = 0;
@@ -430,22 +423,22 @@ int cmCTestCoverageHandler::ProcessHandler()
std::vector<std::string> errorsWhileAccumulating;
file_count = 0;
- for (fileIterator = cont.TotalCoverage.begin();
- fileIterator != cont.TotalCoverage.end(); ++fileIterator) {
+ for (auto const& file : cont.TotalCoverage) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
this->Quiet);
file_count++;
if (file_count % 50 == 0) {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " processed: "
- << file_count << " out of "
- << cont.TotalCoverage.size() << std::endl,
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " processed: " << file_count << " out of "
+ << cont.TotalCoverage.size()
+ << std::endl,
this->Quiet);
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet);
}
- const std::string fullFileName = fileIterator->first;
- bool shouldIDoCoverage = this->ShouldIDoCoverage(
- fullFileName.c_str(), sourceDir.c_str(), binaryDir.c_str());
+ const std::string fullFileName = file.first;
+ bool shouldIDoCoverage =
+ this->ShouldIDoCoverage(fullFileName, sourceDir, binaryDir);
if (!shouldIDoCoverage) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
".NoDartCoverage found, so skip coverage check for: "
@@ -458,7 +451,7 @@ int cmCTestCoverageHandler::ProcessHandler()
"Process file: " << fullFileName << std::endl,
this->Quiet);
- if (!cmSystemTools::FileExists(fullFileName.c_str())) {
+ if (!cmSystemTools::FileExists(fullFileName)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find file: " << fullFileName << std::endl);
continue;
@@ -478,7 +471,7 @@ int cmCTestCoverageHandler::ProcessHandler()
std::string shortFileName =
this->CTest->GetShortPathToFile(fullFileName.c_str());
const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov =
- fileIterator->second;
+ file.second;
covLogXML.StartElement("File");
covLogXML.Attribute("Name", fileName);
covLogXML.Attribute("FullPath", shortFileName);
@@ -531,8 +524,9 @@ int cmCTestCoverageHandler::ProcessHandler()
float cper = 0;
float cmet = 0;
if (tested + untested > 0) {
- cper = (100 * SAFEDIV(static_cast<float>(tested),
- static_cast<float>(tested + untested)));
+ cper = (100 *
+ SAFEDIV(static_cast<float>(tested),
+ static_cast<float>(tested + untested)));
cmet = (SAFEDIV(static_cast<float>(tested + 10),
static_cast<float>(tested + untested + 10)));
}
@@ -554,14 +548,13 @@ int cmCTestCoverageHandler::ProcessHandler()
}
// Handle all the files in the extra coverage globs that have no cov data
- for (std::set<std::string>::iterator i = uncovered.begin();
- i != uncovered.end(); ++i) {
- std::string fileName = cmSystemTools::GetFilenameName(*i);
- std::string fullPath = cont.SourceDir + "/" + *i;
+ for (std::string const& u : uncovered) {
+ std::string fileName = cmSystemTools::GetFilenameName(u);
+ std::string fullPath = cont.SourceDir + "/" + u;
covLogXML.StartElement("File");
covLogXML.Attribute("Name", fileName);
- covLogXML.Attribute("FullPath", *i);
+ covLogXML.Attribute("FullPath", u);
covLogXML.StartElement("Report");
cmsys::ifstream ifs(fullPath.c_str());
@@ -577,7 +570,7 @@ int cmCTestCoverageHandler::ProcessHandler()
int untested = 0;
std::string line;
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Actually performing coverage for: " << *i << std::endl,
+ "Actually performing coverage for: " << u << std::endl,
this->Quiet);
while (cmSystemTools::GetLineFromStream(ifs, line)) {
covLogXML.StartElement("Line");
@@ -593,13 +586,13 @@ int cmCTestCoverageHandler::ProcessHandler()
total_untested += untested;
covSumXML.StartElement("File");
covSumXML.Attribute("Name", fileName);
- covSumXML.Attribute("FullPath", *i);
+ covSumXML.Attribute("FullPath", u);
covSumXML.Attribute("Covered", "true");
covSumXML.Element("LOCTested", 0);
covSumXML.Element("LOCUnTested", untested);
covSumXML.Element("PercentCoverage", 0);
covSumXML.Element("CoverageMetric", 0);
- this->WriteXMLLabels(covSumXML, *i);
+ this->WriteXMLLabels(covSumXML, u);
covSumXML.EndElement(); // File
}
@@ -610,10 +603,8 @@ int cmCTestCoverageHandler::ProcessHandler()
cmCTestLog(this->CTest, ERROR_MESSAGE, std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Error(s) while accumulating results:" << std::endl);
- std::vector<std::string>::iterator erIt;
- for (erIt = errorsWhileAccumulating.begin();
- erIt != errorsWhileAccumulating.end(); ++erIt) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, " " << *erIt << std::endl);
+ for (std::string const& er : errorsWhileAccumulating) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, " " << er << std::endl);
}
}
@@ -631,23 +622,22 @@ int cmCTestCoverageHandler::ProcessHandler()
covSumXML.Element("LOC", total_lines);
covSumXML.Element("PercentCoverage", percent_coverage);
covSumXML.Element("EndDateTime", end_time);
- covSumXML.Element("EndTime",
- static_cast<unsigned int>(cmSystemTools::GetTime()));
- covSumXML.Element(
- "ElapsedMinutes",
- static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
- 10.0);
+ covSumXML.Element("EndTime", std::chrono::system_clock::now());
+ covSumXML.Element("ElapsedMinutes",
+ std::chrono::duration_cast<std::chrono::minutes>(
+ std::chrono::steady_clock::now() - elapsed_time_start)
+ .count());
covSumXML.EndElement(); // Coverage
this->CTest->EndXML(covSumXML);
- cmCTestLog(this->CTest, HANDLER_OUTPUT, ""
- << std::endl
- << "\tCovered LOC: " << total_tested << std::endl
- << "\tNot covered LOC: " << total_untested << std::endl
- << "\tTotal LOC: " << total_lines << std::endl
- << "\tPercentage Coverage: "
- << std::setiosflags(std::ios::fixed) << std::setprecision(2)
- << (percent_coverage) << "%" << std::endl);
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ "" << std::endl
+ << "\tCovered LOC: " << total_tested << std::endl
+ << "\tNot covered LOC: " << total_untested << std::endl
+ << "\tTotal LOC: " << total_lines << std::endl
+ << "\tPercentage Coverage: "
+ << std::setiosflags(std::ios::fixed) << std::setprecision(2)
+ << (percent_coverage) << "%" << std::endl);
ofs << "\tCovered LOC: " << total_tested << std::endl
<< "\tNot covered LOC: " << total_untested << std::endl
@@ -670,17 +660,14 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile* mf)
this->CustomCoverageExclude);
this->CTest->PopulateCustomVector(mf, "CTEST_EXTRA_COVERAGE_GLOB",
this->ExtraCoverageGlobs);
- std::vector<std::string>::iterator it;
- for (it = this->CustomCoverageExclude.begin();
- it != this->CustomCoverageExclude.end(); ++it) {
+ for (std::string const& cce : this->CustomCoverageExclude) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Add coverage exclude: " << *it << std::endl,
+ " Add coverage exclude: " << cce << std::endl,
this->Quiet);
}
- for (it = this->ExtraCoverageGlobs.begin();
- it != this->ExtraCoverageGlobs.end(); ++it) {
+ for (std::string const& ecg : this->ExtraCoverageGlobs) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Add coverage glob: " << *it << std::endl,
+ " Add coverage glob: " << ecg << std::endl,
this->Quiet);
}
}
@@ -691,9 +678,9 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile* mf)
// Compare file names: fnc(fn1) == fnc(fn2) // fnc == file name compare
//
#ifdef _WIN32
-#define fnc(s) cmSystemTools::LowerCase(s)
+# define fnc(s) cmSystemTools::LowerCase(s)
#else
-#define fnc(s) s
+# define fnc(s) s
#endif
bool IsFileInDir(const std::string& infile, const std::string& indir)
@@ -733,7 +720,7 @@ int cmCTestCoverageHandler::HandleCoberturaCoverage(
// build the find file string with the directory from above
coverageXMLFile += "/coverage.xml";
- if (cmSystemTools::FileExists(coverageXMLFile.c_str())) {
+ if (cmSystemTools::FileExists(coverageXMLFile)) {
// If file exists, parse it
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Parsing Cobertura XML file: " << coverageXMLFile
@@ -756,7 +743,7 @@ int cmCTestCoverageHandler::HandleMumpsCoverage(
cmParseGTMCoverage cov(*cont, this->CTest);
std::string coverageFile =
this->CTest->GetBinaryDir() + "/gtm_coverage.mcov";
- if (cmSystemTools::FileExists(coverageFile.c_str())) {
+ if (cmSystemTools::FileExists(coverageFile)) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Parsing Cache Coverage: " << coverageFile << std::endl,
this->Quiet);
@@ -769,7 +756,7 @@ int cmCTestCoverageHandler::HandleMumpsCoverage(
this->Quiet);
cmParseCacheCoverage ccov(*cont, this->CTest);
coverageFile = this->CTest->GetBinaryDir() + "/cache_coverage.cmcov";
- if (cmSystemTools::FileExists(coverageFile.c_str())) {
+ if (cmSystemTools::FileExists(coverageFile)) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Parsing Cache Coverage: " << coverageFile << std::endl,
this->Quiet);
@@ -803,6 +790,9 @@ struct cmCTestCoverageHandlerLocale
cmSystemTools::UnsetEnv("LC_ALL");
}
}
+ cmCTestCoverageHandlerLocale(const cmCTestCoverageHandlerLocale&) = delete;
+ cmCTestCoverageHandlerLocale& operator=(
+ const cmCTestCoverageHandlerLocale&) = delete;
std::string lc_all;
};
@@ -825,15 +815,11 @@ int cmCTestCoverageHandler::HandleJacocoCoverage(
// ...and in the binary directory.
cmsys::Glob g2;
- std::vector<std::string> binFiles;
g2.SetRecurse(true);
std::string binaryDir = this->CTest->GetCTestConfiguration("BuildDirectory");
std::string binCoverageFile = binaryDir + "/*jacoco.xml";
g2.FindFiles(binCoverageFile);
- binFiles = g2.GetFiles();
- if (!binFiles.empty()) {
- files.insert(files.end(), binFiles.begin(), binFiles.end());
- }
+ cmAppend(files, g2.GetFiles());
if (!files.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -877,6 +863,24 @@ int cmCTestCoverageHandler::HandleDelphiCoverage(
return static_cast<int>(cont->TotalCoverage.size());
}
+static std::string joinCommandLine(const std::vector<std::string>& args)
+{
+ std::string ret;
+
+ for (std::string const& s : args) {
+ if (s.find(' ') == std::string::npos) {
+ ret += s + ' ';
+ } else {
+ ret += "\"" + s + "\" ";
+ }
+ }
+
+ // drop trailing whitespace
+ ret.erase(ret.size() - 1);
+
+ return ret;
+}
+
int cmCTestCoverageHandler::HandleBlanketJSCoverage(
cmCTestCoverageHandlerContainer* cont)
{
@@ -895,12 +899,12 @@ int cmCTestCoverageHandler::HandleBlanketJSCoverage(
// Blanket.js output. Check for the "node-jscoverage"
// string on the second line
std::string line;
- for (unsigned int fileEntry = 0; fileEntry < files.size(); fileEntry++) {
- cmsys::ifstream in(files[fileEntry].c_str());
+ for (std::string const& fileEntry : files) {
+ cmsys::ifstream in(fileEntry.c_str());
cmSystemTools::GetLineFromStream(in, line);
cmSystemTools::GetLineFromStream(in, line);
if (line.find("node-jscoverage") != std::string::npos) {
- blanketFiles.push_back(files[fileEntry]);
+ blanketFiles.push_back(fileEntry);
}
}
// Take all files with the node-jscoverage string and parse those
@@ -924,7 +928,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
std::string gcovCommand =
this->CTest->GetCTestConfiguration("CoverageCommand");
if (gcovCommand.empty()) {
- cmCTestLog(this->CTest, WARNING, "Could not find gcov." << std::endl);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Could not find gcov." << std::endl, this->Quiet);
return 0;
}
std::string gcovExtraFlags =
@@ -961,7 +966,6 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
std::vector<std::string> files;
this->FindGCovFiles(files);
- std::vector<std::string>::iterator it;
if (files.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -973,7 +977,12 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
std::string tempDir = testingDir + "/CoverageInfo";
- cmSystemTools::MakeDirectory(tempDir.c_str());
+ if (!cmSystemTools::MakeDirectory(tempDir)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unable to make directory: " << tempDir << std::endl);
+ cont->Error++;
+ return 0;
+ }
cmWorkingDirectory workdir(tempDir);
int gcovStyle = 0;
@@ -992,19 +1001,26 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
cmCTestCoverageHandlerLocale locale_C;
static_cast<void>(locale_C);
+ std::vector<std::string> basecovargs =
+ cmSystemTools::ParseArguments(gcovExtraFlags);
+ basecovargs.insert(basecovargs.begin(), gcovCommand);
+ basecovargs.emplace_back("-o");
+
// files is a list of *.da and *.gcda files with coverage data in them.
// These are binary files that you give as input to gcov so that it will
// give us text output we can analyze to summarize coverage.
//
- for (it = files.begin(); it != files.end(); ++it) {
+ for (std::string const& f : files) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
this->Quiet);
// Call gcov to get coverage data for this *.gcda file:
//
- std::string fileDir = cmSystemTools::GetFilenamePath(*it);
- std::string command = "\"" + gcovCommand + "\" " + gcovExtraFlags + " " +
- "-o \"" + fileDir + "\" " + "\"" + *it + "\"";
+ std::string fileDir = cmSystemTools::GetFilenamePath(f);
+ std::vector<std::string> covargs = basecovargs;
+ covargs.push_back(fileDir);
+ covargs.push_back(f);
+ const std::string command = joinCommandLine(covargs);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
command << std::endl, this->Quiet);
@@ -1014,23 +1030,24 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
int retVal = 0;
*cont->OFS << "* Run coverage for: " << fileDir << std::endl;
*cont->OFS << " Command: " << command << std::endl;
- int res =
- this->CTest->RunCommand(command.c_str(), &output, &errors, &retVal,
- tempDir.c_str(), 0 /*this->TimeOut*/);
+ int res = this->CTest->RunCommand(covargs, &output, &errors, &retVal,
+ tempDir.c_str(),
+ cmDuration::zero() /*this->TimeOut*/);
*cont->OFS << " Output: " << output << std::endl;
*cont->OFS << " Errors: " << errors << std::endl;
if (!res) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem running coverage on file: " << *it << std::endl);
+ "Problem running coverage on file: " << f << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Command produced error: " << errors << std::endl);
cont->Error++;
continue;
}
if (retVal != 0) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: "
- << retVal << " while processing: " << *it << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Coverage command returned: "
+ << retVal << " while processing: " << f << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Command produced error: " << cont->Error << std::endl);
}
@@ -1044,86 +1061,84 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
this->Quiet);
std::vector<std::string> lines;
- std::vector<std::string>::iterator line;
+ cmsys::SystemTools::Split(output, lines);
- cmSystemTools::Split(output.c_str(), lines);
-
- for (line = lines.begin(); line != lines.end(); ++line) {
+ for (std::string const& line : lines) {
std::string sourceFile;
std::string gcovFile;
cmCTestOptionalLog(this->CTest, DEBUG,
- "Line: [" << *line << "]" << std::endl, this->Quiet);
+ "Line: [" << line << "]" << std::endl, this->Quiet);
- if (line->empty()) {
+ if (line.empty()) {
// Ignore empty line; probably style 2
- } else if (st1re1.find(line->c_str())) {
+ } else if (st1re1.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 1;
}
if (gcovStyle != 1) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e1"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unknown gcov output style e1" << std::endl);
cont->Error++;
break;
}
- actualSourceFile = "";
+ actualSourceFile.clear();
sourceFile = st1re1.match(2);
- } else if (st1re2.find(line->c_str())) {
+ } else if (st1re2.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 1;
}
if (gcovStyle != 1) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e2"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unknown gcov output style e2" << std::endl);
cont->Error++;
break;
}
gcovFile = st1re2.match(1);
- } else if (st2re1.find(line->c_str())) {
+ } else if (st2re1.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
if (gcovStyle != 2) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e3"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unknown gcov output style e3" << std::endl);
cont->Error++;
break;
}
- actualSourceFile = "";
+ actualSourceFile.clear();
sourceFile = st2re1.match(1);
- } else if (st2re2.find(line->c_str())) {
+ } else if (st2re2.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
if (gcovStyle != 2) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e4"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unknown gcov output style e4" << std::endl);
cont->Error++;
break;
}
- } else if (st2re3.find(line->c_str())) {
+ } else if (st2re3.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
if (gcovStyle != 2) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e5"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unknown gcov output style e5" << std::endl);
cont->Error++;
break;
}
gcovFile = st2re3.match(2);
- } else if (st2re4.find(line->c_str())) {
+ } else if (st2re4.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
if (gcovStyle != 2) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e6"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unknown gcov output style e6" << std::endl);
cont->Error++;
break;
}
@@ -1132,42 +1147,45 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
"Warning: " << st2re4.match(1)
<< " had unexpected EOF" << std::endl,
this->Quiet);
- } else if (st2re5.find(line->c_str())) {
+ } else if (st2re5.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
if (gcovStyle != 2) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e7"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unknown gcov output style e7" << std::endl);
cont->Error++;
break;
}
- cmCTestOptionalLog(this->CTest, WARNING, "Warning: Cannot open file: "
- << st2re5.match(1) << std::endl,
+ cmCTestOptionalLog(this->CTest, WARNING,
+ "Warning: Cannot open file: " << st2re5.match(1)
+ << std::endl,
this->Quiet);
- } else if (st2re6.find(line->c_str())) {
+ } else if (st2re6.find(line)) {
if (gcovStyle == 0) {
gcovStyle = 2;
}
if (gcovStyle != 2) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output style e8"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unknown gcov output style e8" << std::endl);
cont->Error++;
break;
}
- cmCTestOptionalLog(this->CTest, WARNING, "Warning: File: "
- << st2re6.match(1) << " is newer than "
- << st2re6.match(2) << std::endl,
+ cmCTestOptionalLog(this->CTest, WARNING,
+ "Warning: File: " << st2re6.match(1)
+ << " is newer than "
+ << st2re6.match(2) << std::endl,
this->Quiet);
} else {
// gcov 4.7 can have output lines saying "No executable lines" and
// "Removing 'filename.gcov'"... Don't log those as "errors."
- if (*line != "No executable lines" &&
- !cmSystemTools::StringStartsWith(line->c_str(), "Removing ")) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output line: ["
- << *line << "]" << std::endl);
+ if (line != "No executable lines" &&
+ !cmHasLiteralPrefix(line, "Removing ")) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unknown gcov output line: [" << line << "]"
+ << std::endl);
cont->Error++;
// abort();
}
@@ -1235,11 +1253,11 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
}
}
- actualSourceFile = "";
+ actualSourceFile.clear();
}
if (!sourceFile.empty() && actualSourceFile.empty()) {
- gcovFile = "";
+ gcovFile.clear();
// Is it in the source dir or the binary dir?
//
@@ -1332,7 +1350,6 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
"Error while finding LCov files.\n");
return 0;
}
- std::vector<std::string>::iterator it;
if (files.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -1357,14 +1374,26 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
cmCTestCoverageHandlerLocale locale_C;
static_cast<void>(locale_C);
+ std::vector<std::string> covargs =
+ cmSystemTools::ParseArguments(lcovExtraFlags);
+ covargs.insert(covargs.begin(), lcovCommand);
+ const std::string command = joinCommandLine(covargs);
+
// In intel compiler we have to call codecov only once in each executable
// directory. It collects all *.dyn files to generate .dpi file.
- for (it = files.begin(); it != files.end(); ++it) {
+ for (std::string const& f : files) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
this->Quiet);
- std::string fileDir = cmSystemTools::GetFilenamePath(*it);
+ std::string fileDir = cmSystemTools::GetFilenamePath(f);
cmWorkingDirectory workdir(fileDir);
- std::string command = "\"" + lcovCommand + "\" " + lcovExtraFlags + " ";
+ if (workdir.Failed()) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unable to change working directory to "
+ << fileDir << " : "
+ << std::strerror(workdir.GetLastResult()) << std::endl);
+ cont->Error++;
+ continue;
+ }
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Current coverage dir: " << fileDir << std::endl,
@@ -1377,23 +1406,24 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
int retVal = 0;
*cont->OFS << "* Run coverage for: " << fileDir << std::endl;
*cont->OFS << " Command: " << command << std::endl;
- int res =
- this->CTest->RunCommand(command.c_str(), &output, &errors, &retVal,
- fileDir.c_str(), 0 /*this->TimeOut*/);
+ int res = this->CTest->RunCommand(covargs, &output, &errors, &retVal,
+ fileDir.c_str(),
+ cmDuration::zero() /*this->TimeOut*/);
*cont->OFS << " Output: " << output << std::endl;
*cont->OFS << " Errors: " << errors << std::endl;
if (!res) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem running coverage on file: " << *it << std::endl);
+ "Problem running coverage on file: " << f << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Command produced error: " << errors << std::endl);
cont->Error++;
continue;
}
if (retVal != 0) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: "
- << retVal << " while processing: " << *it << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Coverage command returned: "
+ << retVal << " while processing: " << f << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Command produced error: " << cont->Error << std::endl);
}
@@ -1407,15 +1437,13 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
this->Quiet);
std::vector<std::string> lines;
- std::vector<std::string>::iterator line;
-
- cmSystemTools::Split(output.c_str(), lines);
+ cmsys::SystemTools::Split(output, lines);
- for (line = lines.begin(); line != lines.end(); ++line) {
+ for (std::string const& line : lines) {
std::string sourceFile;
std::string lcovFile;
- if (line->empty()) {
+ if (line.empty()) {
// Ignore empty line
}
// Look for LCOV files in binary directory
@@ -1428,19 +1456,16 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
std::vector<std::string> lcovFiles;
dir = this->CTest->GetBinaryDir();
std::string daGlob;
- daGlob = dir;
- daGlob += "/*.LCOV";
+ daGlob = cmStrCat(dir, "/*.LCOV");
cmCTestOptionalLog(
this->CTest, HANDLER_VERBOSE_OUTPUT,
" looking for LCOV files in: " << daGlob << std::endl, this->Quiet);
gl.FindFiles(daGlob);
// Keep a list of all LCOV files
- lcovFiles.insert(lcovFiles.end(), gl.GetFiles().begin(),
- gl.GetFiles().end());
+ cmAppend(lcovFiles, gl.GetFiles());
- for (std::vector<std::string>::iterator a = lcovFiles.begin();
- a != lcovFiles.end(); ++a) {
- lcovFile = *a;
+ for (std::string const& file : lcovFiles) {
+ lcovFile = file;
cmsys::ifstream srcead(lcovFile.c_str());
if (!srcead) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
@@ -1462,10 +1487,9 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
sourceFile = srcname;
actualSourceFile = srcname;
- for (std::vector<std::string>::iterator t = lcovFiles.begin();
- t != lcovFiles.end(); ++t) {
+ for (std::string const& t : lcovFiles) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Found LCOV File: " << *t << std::endl,
+ "Found LCOV File: " << t << std::endl,
this->Quiet);
}
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -1537,7 +1561,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
}
}
- actualSourceFile = "";
+ actualSourceFile.clear();
}
}
}
@@ -1562,10 +1586,9 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files)
gl.RecurseOn();
gl.RecurseThroughSymlinksOff();
- for (LabelMapType::const_iterator lmi = this->TargetDirs.begin();
- lmi != this->TargetDirs.end(); ++lmi) {
+ for (auto const& lm : this->TargetDirs) {
// Skip targets containing no interesting labels.
- if (!this->IntersectsFilter(lmi->second)) {
+ if (!this->IntersectsFilter(lm.second)) {
continue;
}
@@ -1573,15 +1596,13 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files)
// support directory.
cmCTestOptionalLog(
this->CTest, HANDLER_VERBOSE_OUTPUT,
- " globbing for coverage in: " << lmi->first << std::endl, this->Quiet);
- std::string daGlob = lmi->first;
- daGlob += "/*.da";
+ " globbing for coverage in: " << lm.first << std::endl, this->Quiet);
+ std::string daGlob = cmStrCat(lm.first, "/*.da");
gl.FindFiles(daGlob);
- files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end());
- daGlob = lmi->first;
- daGlob += "/*.gcda";
+ cmAppend(files, gl.GetFiles());
+ daGlob = cmStrCat(lm.first, "/*.gcda");
gl.FindFiles(daGlob);
- files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end());
+ cmAppend(files, gl.GetFiles());
}
}
@@ -1593,6 +1614,12 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
gl.RecurseThroughSymlinksOff();
std::string buildDir = this->CTest->GetCTestConfiguration("BuildDirectory");
cmWorkingDirectory workdir(buildDir);
+ if (workdir.Failed()) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unable to change working directory to " << buildDir
+ << std::endl);
+ return false;
+ }
// Run profmerge to merge all *.dyn files into dpi files
if (!cmSystemTools::RunSingleCommand("profmerge")) {
@@ -1602,8 +1629,7 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
// DPI file should appear in build directory
std::string daGlob;
- daGlob = buildDir;
- daGlob += "/*.dpi";
+ daGlob = cmStrCat(buildDir, "/*.dpi");
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" looking for dpi files in: " << daGlob << std::endl,
this->Quiet);
@@ -1612,7 +1638,7 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
"Error while finding files matching " << daGlob << std::endl);
return false;
}
- files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end());
+ cmAppend(files, gl.GetFiles());
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Now searching in: " << daGlob << std::endl, this->Quiet);
return true;
@@ -1639,16 +1665,15 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
std::string tempDir = testingDir + "/CoverageInfo";
- cmSystemTools::MakeDirectory(tempDir.c_str());
+ cmSystemTools::MakeDirectory(tempDir);
- std::vector<std::string>::iterator fileIt;
int file_count = 0;
- for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
- std::string fileName = this->FindFile(cont, *fileIt);
+ for (std::string const& file : files) {
+ std::string fileName = this->FindFile(cont, file);
if (fileName.empty()) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find source Python file corresponding to: "
- << *fileIt << std::endl);
+ << file << std::endl);
continue;
}
@@ -1660,11 +1685,11 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
cmCTestCoverageHandlerContainer::SingleFileCoverageVector* vec =
&cont->TotalCoverage[actualSourceFile];
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " in file: " << *fileIt << std::endl, this->Quiet);
- cmsys::ifstream ifile(fileIt->c_str());
+ " in file: " << file << std::endl, this->Quiet);
+ cmsys::ifstream ifile(file.c_str());
if (!ifile) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot open file: " << *fileIt << std::endl);
+ "Cannot open file: " << file << std::endl);
} else {
long cnt = -1;
std::string nl;
@@ -1736,11 +1761,11 @@ std::string cmCTestCoverageHandler::FindFile(
cmSystemTools::GetFilenameWithoutLastExtension(fileName);
// First check in source and binary directory
std::string fullName = cont->SourceDir + "/" + fileNameNoE + ".py";
- if (cmSystemTools::FileExists(fullName.c_str())) {
+ if (cmSystemTools::FileExists(fullName)) {
return fullName;
}
fullName = cont->BinaryDir + "/" + fileNameNoE + ".py";
- if (cmSystemTools::FileExists(fullName.c_str())) {
+ if (cmSystemTools::FileExists(fullName)) {
return fullName;
}
return "";
@@ -1761,7 +1786,7 @@ const char* bullseyeHelp[] = {
" condition evaluated true or false, respectively.",
" * A k indicates a constant decision or condition.",
" * The slash / means this probe is excluded from summary results. ",
- CM_NULLPTR
+ nullptr
};
}
@@ -1789,8 +1814,9 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"run covbr: " << std::endl, this->Quiet);
- if (!this->RunBullseyeCommand(cont, "covbr", CM_NULLPTR, outputFile)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "error running covbr for."
+ if (!this->RunBullseyeCommand(cont, "covbr", nullptr, outputFile)) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "error running covbr for."
<< "\n");
return -1;
}
@@ -1805,9 +1831,8 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
return 0;
}
std::map<std::string, std::string> fileMap;
- std::vector<std::string>::iterator fp = filesFullPath.begin();
- for (std::vector<std::string>::iterator f = files.begin(); f != files.end();
- ++f, ++fp) {
+ auto fp = filesFullPath.begin();
+ for (auto f = files.begin(); f != files.end(); ++f, ++fp) {
fileMap[*f] = *fp;
}
@@ -1845,7 +1870,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
this->StartCoverageLogXML(covLogXML);
count++; // move on one
}
- std::map<std::string, std::string>::iterator i = fileMap.find(file);
+ auto i = fileMap.find(file);
// if the file should be covered write out the header for that file
if (i != fileMap.end()) {
// we have a new file so count it in the output
@@ -1862,7 +1887,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
covLogXML.StartElement("Report");
// write the bullseye header
line = 0;
- for (int k = 0; bullseyeHelp[k] != CM_NULLPTR; ++k) {
+ for (int k = 0; bullseyeHelp[k] != nullptr; ++k) {
covLogXML.StartElement("Line");
covLogXML.Attribute("Number", line);
covLogXML.Attribute("Count", -1);
@@ -1916,10 +1941,9 @@ int cmCTestCoverageHandler::RunBullseyeCommand(
cmCTestRunProcess runCoverageSrc;
runCoverageSrc.SetCommand(program.c_str());
runCoverageSrc.AddArgument(arg);
- std::string stdoutFile = cont->BinaryDir + "/Testing/Temporary/";
- stdoutFile += this->GetCTestInstance()->GetCurrentTag();
- stdoutFile += "-";
- stdoutFile += cmd;
+ std::string stdoutFile =
+ cmStrCat(cont->BinaryDir, "/Testing/Temporary/",
+ this->GetCTestInstance()->GetCurrentTag(), '-', cmd);
std::string stderrFile = stdoutFile;
stdoutFile += ".stdout";
stderrFile += ".stderr";
@@ -1954,17 +1978,16 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
cmXMLWriter xml(covSumFile);
if (!this->StartResultingXML(cmCTest::PartCoverage, "Coverage",
covSumFile)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open coverage summary file."
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot open coverage summary file." << std::endl);
return 0;
}
this->CTest->StartXML(xml, this->AppendXML);
- double elapsed_time_start = cmSystemTools::GetTime();
+ auto elapsed_time_start = std::chrono::steady_clock::now();
std::string coverage_start_time = this->CTest->CurrentTime();
xml.StartElement("Coverage");
xml.Element("StartDateTime", coverage_start_time);
- xml.Element("StartTime",
- static_cast<unsigned int>(cmSystemTools::GetTime()));
+ xml.Element("StartTime", std::chrono::system_clock::now());
std::string stdline;
std::string errline;
// expected output:
@@ -2007,15 +2030,13 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
}
std::string file = sourceFile;
coveredFileNames.insert(file);
- if (!cmSystemTools::FileIsFullPath(sourceFile.c_str())) {
+ if (!cmSystemTools::FileIsFullPath(sourceFile)) {
// file will be relative to the binary dir
- file = cont->BinaryDir;
- file += "/";
- file += sourceFile;
+ file = cmStrCat(cont->BinaryDir, '/', sourceFile);
}
file = cmSystemTools::CollapseFullPath(file);
- bool shouldIDoCoverage = this->ShouldIDoCoverage(
- file.c_str(), cont->SourceDir.c_str(), cont->BinaryDir.c_str());
+ bool shouldIDoCoverage =
+ this->ShouldIDoCoverage(file, cont->SourceDir, cont->BinaryDir);
if (!shouldIDoCoverage) {
cmCTestOptionalLog(
this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -2085,11 +2106,11 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
xml.Element("LOC", total_functions);
xml.Element("PercentCoverage", SAFEDIV(percent_coverage, number_files));
xml.Element("EndDateTime", end_time);
- xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
- xml.Element(
- "ElapsedMinutes",
- static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
- 10.0);
+ xml.Element("EndTime", std::chrono::system_clock::now());
+ xml.Element("ElapsedMinutes",
+ std::chrono::duration_cast<std::chrono::minutes>(
+ std::chrono::steady_clock::now() - elapsed_time_start)
+ .count());
xml.EndElement(); // Coverage
this->CTest->EndXML(xml);
@@ -2172,7 +2193,8 @@ bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine(
}
// should be at the end now
if (pos != std::string::npos) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing input : "
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Error parsing input : "
<< inputLine << " last pos not npos = " << pos << "\n");
}
return true;
@@ -2180,7 +2202,7 @@ bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine(
int cmCTestCoverageHandler::GetLabelId(std::string const& label)
{
- LabelIdMapType::iterator i = this->LabelIdMap.find(label);
+ auto i = this->LabelIdMap.find(label);
if (i == this->LabelIdMap.end()) {
int n = int(this->Labels.size());
this->Labels.push_back(label);
@@ -2192,9 +2214,8 @@ int cmCTestCoverageHandler::GetLabelId(std::string const& label)
void cmCTestCoverageHandler::LoadLabels()
{
- std::string fileList = this->CTest->GetBinaryDir();
- fileList += cmake::GetCMakeFilesDirectory();
- fileList += "/TargetDirectories.txt";
+ std::string fileList =
+ cmStrCat(this->CTest->GetBinaryDir(), "/CMakeFiles/TargetDirectories.txt");
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" target directory list [" << fileList << "]\n",
this->Quiet);
@@ -2208,8 +2229,7 @@ void cmCTestCoverageHandler::LoadLabels()
void cmCTestCoverageHandler::LoadLabels(const char* dir)
{
LabelSet& dirLabels = this->TargetDirs[dir];
- std::string fname = dir;
- fname += "/Labels.txt";
+ std::string fname = cmStrCat(dir, "/Labels.txt");
cmsys::ifstream fin(fname.c_str());
if (!fin) {
return;
@@ -2253,12 +2273,11 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir)
void cmCTestCoverageHandler::WriteXMLLabels(cmXMLWriter& xml,
std::string const& source)
{
- LabelMapType::const_iterator li = this->SourceLabels.find(source);
+ auto li = this->SourceLabels.find(source);
if (li != this->SourceLabels.end() && !li->second.empty()) {
xml.StartElement("Labels");
- for (LabelSet::const_iterator lsi = li->second.begin();
- lsi != li->second.end(); ++lsi) {
- xml.Element("Label", this->Labels[*lsi]);
+ for (auto const& ls : li->second) {
+ xml.Element("Label", this->Labels[ls]);
}
xml.EndElement(); // Labels
}
@@ -2268,9 +2287,8 @@ void cmCTestCoverageHandler::SetLabelFilter(
std::set<std::string> const& labels)
{
this->LabelFilter.clear();
- for (std::set<std::string>::const_iterator li = labels.begin();
- li != labels.end(); ++li) {
- this->LabelFilter.insert(this->GetLabelId(*li));
+ for (std::string const& l : labels) {
+ this->LabelFilter.insert(this->GetLabelId(l));
}
}
@@ -2298,7 +2316,7 @@ bool cmCTestCoverageHandler::IsFilteredOut(std::string const& source)
// The source is filtered out if it does not have any labels in
// common with the filter set.
std::string shortSrc = this->CTest->GetShortPathToFile(source.c_str());
- LabelMapType::const_iterator li = this->SourceLabels.find(shortSrc);
+ auto li = this->SourceLabels.find(shortSrc);
if (li != this->SourceLabels.end()) {
return !this->IntersectsFilter(li->second);
}
@@ -2310,29 +2328,23 @@ std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles(
{
std::set<std::string> extraMatches;
- for (std::vector<std::string>::iterator i = this->ExtraCoverageGlobs.begin();
- i != this->ExtraCoverageGlobs.end(); ++i) {
+ for (std::string const& ecg : this->ExtraCoverageGlobs) {
cmsys::Glob gl;
gl.RecurseOn();
gl.RecurseThroughSymlinksOff();
- std::string glob = cont->SourceDir + "/" + *i;
+ std::string glob = cont->SourceDir + "/" + ecg;
gl.FindFiles(glob);
std::vector<std::string> files = gl.GetFiles();
- for (std::vector<std::string>::iterator f = files.begin();
- f != files.end(); ++f) {
- if (this->ShouldIDoCoverage(f->c_str(), cont->SourceDir.c_str(),
- cont->BinaryDir.c_str())) {
- extraMatches.insert(this->CTest->GetShortPathToFile(f->c_str()));
+ for (std::string const& f : files) {
+ if (this->ShouldIDoCoverage(f, cont->SourceDir, cont->BinaryDir)) {
+ extraMatches.insert(this->CTest->GetShortPathToFile(f.c_str()));
}
}
}
if (!extraMatches.empty()) {
- for (cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator i =
- cont->TotalCoverage.begin();
- i != cont->TotalCoverage.end(); ++i) {
- std::string shortPath =
- this->CTest->GetShortPathToFile(i->first.c_str());
+ for (auto const& i : cont->TotalCoverage) {
+ std::string shortPath = this->CTest->GetShortPathToFile(i.first.c_str());
extraMatches.erase(shortPath);
}
}
diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h
index 933f60660..991b89d7b 100644
--- a/Source/CTest/cmCTestCoverageHandler.h
+++ b/Source/CTest/cmCTestCoverageHandler.h
@@ -3,17 +3,18 @@
#ifndef cmCTestCoverageHandler_h
#define cmCTestCoverageHandler_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmCTestGenericHandler.h"
-
-#include "cmsys/RegularExpression.hxx"
#include <iosfwd>
#include <map>
#include <set>
#include <string>
#include <vector>
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmCTestGenericHandler.h"
+
class cmGeneratedFileStream;
class cmMakefile;
class cmXMLWriter;
@@ -24,8 +25,8 @@ public:
int Error;
std::string SourceDir;
std::string BinaryDir;
- typedef std::vector<int> SingleFileCoverageVector;
- typedef std::map<std::string, SingleFileCoverageVector> TotalCoverageMap;
+ using SingleFileCoverageVector = std::vector<int>;
+ using TotalCoverageMap = std::map<std::string, SingleFileCoverageVector>;
TotalCoverageMap TotalCoverage;
std::ostream* OFS;
bool Quiet;
@@ -37,28 +38,28 @@ public:
class cmCTestCoverageHandler : public cmCTestGenericHandler
{
public:
- typedef cmCTestGenericHandler Superclass;
+ using Superclass = cmCTestGenericHandler;
/*
* The main entry point for this class
*/
- int ProcessHandler() CM_OVERRIDE;
+ int ProcessHandler() override;
cmCTestCoverageHandler();
- void Initialize() CM_OVERRIDE;
+ void Initialize() override;
/**
* This method is called when reading CTest custom file
*/
- void PopulateCustomVectors(cmMakefile* mf) CM_OVERRIDE;
+ void PopulateCustomVectors(cmMakefile* mf) override;
/** Report coverage only for sources with these labels. */
void SetLabelFilter(std::set<std::string> const& labels);
private:
- bool ShouldIDoCoverage(const char* file, const char* srcDir,
- const char* binDir);
+ bool ShouldIDoCoverage(std::string const& file, std::string const& srcDir,
+ std::string const& binDir);
void CleanCoverageLogFiles(std::ostream& log);
bool StartCoverageLogFile(cmGeneratedFileStream& ostr, int logFileCount);
void EndCoverageLogFile(cmGeneratedFileStream& ostr, int logFileCount);
@@ -128,12 +129,12 @@ private:
class LabelSet : public std::set<int>
{
};
- typedef std::map<std::string, LabelSet> LabelMapType;
+ using LabelMapType = std::map<std::string, LabelSet>;
LabelMapType SourceLabels;
LabelMapType TargetDirs;
// Map from label name to label id.
- typedef std::map<std::string, int> LabelIdMapType;
+ using LabelIdMapType = std::map<std::string, int>;
LabelIdMapType LabelIdMap;
std::vector<std::string> Labels;
int GetLabelId(std::string const& label);
diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx
index b80ea5ade..ccac832f0 100644
--- a/Source/CTest/cmCTestCurl.cxx
+++ b/Source/CTest/cmCTestCurl.cxx
@@ -2,13 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestCurl.h"
+#include <cstdio>
+#include <ostream>
+
+#include "cmAlgorithms.h"
#include "cmCTest.h"
+#include "cmCurl.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmConfigure.h"
-#include <ostream>
-#include <stdio.h>
-
cmCTestCurl::cmCTestCurl(cmCTest* ctest)
{
this->CTest = ctest;
@@ -42,32 +44,27 @@ namespace {
size_t curlWriteMemoryCallback(void* ptr, size_t size, size_t nmemb,
void* data)
{
- int realsize = (int)(size * nmemb);
-
- std::vector<char>* vec = static_cast<std::vector<char>*>(data);
+ int realsize = static_cast<int>(size * nmemb);
const char* chPtr = static_cast<char*>(ptr);
- vec->insert(vec->end(), chPtr, chPtr + realsize);
+ cmAppend(*static_cast<std::vector<char>*>(data), chPtr, chPtr + realsize);
return realsize;
}
size_t curlDebugCallback(CURL* /*unused*/, curl_infotype /*unused*/,
char* chPtr, size_t size, void* data)
{
- std::vector<char>* vec = static_cast<std::vector<char>*>(data);
- vec->insert(vec->end(), chPtr, chPtr + size);
-
+ cmAppend(*static_cast<std::vector<char>*>(data), chPtr, chPtr + size);
return size;
}
}
void cmCTestCurl::SetCurlOptions(std::vector<std::string> const& args)
{
- for (std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i) {
- if (*i == "CURLOPT_SSL_VERIFYPEER_OFF") {
+ for (std::string const& arg : args) {
+ if (arg == "CURLOPT_SSL_VERIFYPEER_OFF") {
this->VerifyPeerOff = true;
}
- if (*i == "CURLOPT_SSL_VERIFYHOST_OFF") {
+ if (arg == "CURLOPT_SSL_VERIFYHOST_OFF") {
this->VerifyHostOff = true;
}
}
@@ -78,6 +75,7 @@ bool cmCTestCurl::InitCurl()
if (!this->Curl) {
return false;
}
+ cmCurlSetCAInfo(this->Curl);
if (this->VerifyPeerOff) {
curl_easy_setopt(this->Curl, CURLOPT_SSL_VERIFYPEER, 0);
}
@@ -111,7 +109,7 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
std::string const& url, std::string const& fields,
std::string& response)
{
- response = "";
+ response.clear();
if (!this->InitCurl()) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Initialization of curl failed");
return false;
@@ -130,9 +128,7 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
return false;
}
// set the url
- std::string upload_url = url;
- upload_url += "?";
- upload_url += fields;
+ std::string upload_url = cmStrCat(url, '?', fields);
::curl_easy_setopt(this->Curl, CURLOPT_URL, upload_url.c_str());
// now specify which file to upload
::curl_easy_setopt(this->Curl, CURLOPT_INFILE, ftpfile);
@@ -145,20 +141,19 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
// Set Content-Type to satisfy fussy modsecurity rules.
struct curl_slist* headers =
- ::curl_slist_append(CM_NULLPTR, "Content-Type: text/xml");
+ ::curl_slist_append(nullptr, "Content-Type: text/xml");
// Add any additional headers that the user specified.
- for (std::vector<std::string>::const_iterator h = this->HttpHeaders.begin();
- h != this->HttpHeaders.end(); ++h) {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Add HTTP Header: \"" << *h << "\"" << std::endl,
+ for (std::string const& h : this->HttpHeaders) {
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ " Add HTTP Header: \"" << h << "\"" << std::endl,
this->Quiet);
- headers = ::curl_slist_append(headers, h->c_str());
+ headers = ::curl_slist_append(headers, h.c_str());
}
::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers);
std::vector<char> responseData;
std::vector<char> debugData;
- ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void*)&responseData);
- ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void*)&debugData);
+ ::curl_easy_setopt(this->Curl, CURLOPT_FILE, &responseData);
+ ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, &debugData);
::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
// Now run off and do what you've been told!
::curl_easy_perform(this->Curl);
@@ -178,7 +173,8 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
"Curl debug: [" << curlDebug << "]\n", this->Quiet);
}
if (response.empty()) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "No response from server.\n"
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "No response from server.\n"
<< curlDebug);
return false;
}
@@ -188,8 +184,9 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
bool cmCTestCurl::HttpRequest(std::string const& url,
std::string const& fields, std::string& response)
{
- response = "";
- cmCTestOptionalLog(this->CTest, DEBUG, "HttpRequest\n"
+ response.clear();
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "HttpRequest\n"
<< "url: " << url << "\n"
<< "fields " << fields << "\n",
this->Quiet);
@@ -207,20 +204,18 @@ bool cmCTestCurl::HttpRequest(std::string const& url,
::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
std::vector<char> responseData;
std::vector<char> debugData;
- ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void*)&responseData);
- ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void*)&debugData);
+ ::curl_easy_setopt(this->Curl, CURLOPT_FILE, &responseData);
+ ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, &debugData);
::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
// Add headers if any were specified.
- struct curl_slist* headers = CM_NULLPTR;
+ struct curl_slist* headers = nullptr;
if (!this->HttpHeaders.empty()) {
- for (std::vector<std::string>::const_iterator h =
- this->HttpHeaders.begin();
- h != this->HttpHeaders.end(); ++h) {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Add HTTP Header: \"" << *h << "\"" << std::endl,
+ for (std::string const& h : this->HttpHeaders) {
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ " Add HTTP Header: \"" << h << "\"" << std::endl,
this->Quiet);
- headers = ::curl_slist_append(headers, h->c_str());
+ headers = ::curl_slist_append(headers, h.c_str());
}
}
@@ -245,10 +240,10 @@ bool cmCTestCurl::HttpRequest(std::string const& url,
void cmCTestCurl::SetProxyType()
{
- this->HTTPProxy = "";
+ this->HTTPProxy.clear();
// this is the default
this->HTTPProxyType = CURLPROXY_HTTP;
- this->HTTPProxyAuth = "";
+ this->HTTPProxyAuth.clear();
if (cmSystemTools::GetEnv("HTTP_PROXY", this->HTTPProxy)) {
std::string port;
if (cmSystemTools::GetEnv("HTTP_PROXY_PORT", port)) {
diff --git a/Source/CTest/cmCTestCurl.h b/Source/CTest/cmCTestCurl.h
index 427a39232..9c5ba667e 100644
--- a/Source/CTest/cmCTestCurl.h
+++ b/Source/CTest/cmCTestCurl.h
@@ -5,10 +5,11 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cm_curl.h"
#include <string>
#include <vector>
+#include "cm_curl.h"
+
class cmCTest;
class cmCTestCurl
@@ -16,7 +17,9 @@ class cmCTestCurl
public:
cmCTestCurl(cmCTest*);
~cmCTestCurl();
- bool UploadFile(std::string const& url, std::string const& file,
+ cmCTestCurl(const cmCTestCurl&) = delete;
+ cmCTestCurl& operator=(const cmCTestCurl&) = delete;
+ bool UploadFile(std::string const& local_file, std::string const& url,
std::string const& fields, std::string& response);
bool HttpRequest(std::string const& url, std::string const& fields,
std::string& response);
diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
index f4531a1ee..051c117ca 100644
--- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
+++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
@@ -2,10 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestEmptyBinaryDirectoryCommand.h"
-#include "cmCTestScriptHandler.h"
-
#include <sstream>
+#include "cmCTestScriptHandler.h"
+
class cmExecutionStatus;
bool cmCTestEmptyBinaryDirectoryCommand::InitialPass(
diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
index 503ed234d..ac96a4e30 100644
--- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
+++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
@@ -3,14 +3,17 @@
#ifndef cmCTestEmptyBinaryDirectoryCommand_h
#define cmCTestEmptyBinaryDirectoryCommand_h
-#include "cmConfigure.h"
-
-#include "cmCTestCommand.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <utility>
#include <vector>
-class cmCommand;
+#include <cm/memory>
+
+#include "cmCTestCommand.h"
+#include "cmCommand.h"
+
class cmExecutionStatus;
/** \class cmCTestEmptyBinaryDirectory
@@ -27,13 +30,12 @@ public:
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE
+ std::unique_ptr<cmCommand> Clone() override
{
- cmCTestEmptyBinaryDirectoryCommand* ni =
- new cmCTestEmptyBinaryDirectoryCommand;
+ auto ni = cm::make_unique<cmCTestEmptyBinaryDirectoryCommand>();
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
- return ni;
+ return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
@@ -41,7 +43,7 @@ public:
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
+ cmExecutionStatus& status) override;
};
#endif
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index 230aedf3b..3f3c1074f 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -2,19 +2,20 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestGIT.h"
+#include <cctype>
+#include <cstdio>
+#include <cstdlib>
+#include <ctime>
+#include <vector>
+
#include "cmsys/FStream.hxx"
#include "cmsys/Process.h"
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <vector>
-#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestVC.h"
#include "cmProcessOutput.h"
#include "cmProcessTools.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
static unsigned int cmCTestGITVersion(unsigned int epic, unsigned int major,
@@ -31,9 +32,7 @@ cmCTestGIT::cmCTestGIT(cmCTest* ct, std::ostream& log)
this->CurrentGitVersion = 0;
}
-cmCTestGIT::~cmCTestGIT()
-{
-}
+cmCTestGIT::~cmCTestGIT() = default;
class cmCTestGIT::OneLineParser : public cmCTestVC::LineParser
{
@@ -46,7 +45,7 @@ public:
private:
std::string& Line1;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
// Only the first line is of interest.
this->Line1 = this->Line;
@@ -58,8 +57,8 @@ std::string cmCTestGIT::GetWorkingRevision()
{
// Run plumbing "git rev-list" to get work tree revision.
const char* git = this->CommandLineTool.c_str();
- const char* git_rev_list[] = { git, "rev-list", "-n", "1",
- "HEAD", "--", CM_NULLPTR };
+ const char* git_rev_list[] = { git, "rev-list", "-n", "1",
+ "HEAD", "--", nullptr };
std::string rev;
OneLineParser out(this, "rl-out> ", rev);
OutputLogger err(this->Log, "rl-err> ");
@@ -70,8 +69,9 @@ std::string cmCTestGIT::GetWorkingRevision()
bool cmCTestGIT::NoteOldRevision()
{
this->OldRevision = this->GetWorkingRevision();
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
- << this->OldRevision << "\n");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " Old revision of repository is: " << this->OldRevision
+ << "\n");
this->PriorRev.Rev = this->OldRevision;
return true;
}
@@ -79,8 +79,9 @@ bool cmCTestGIT::NoteOldRevision()
bool cmCTestGIT::NoteNewRevision()
{
this->NewRevision = this->GetWorkingRevision();
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
- << this->NewRevision << "\n");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " New revision of repository is: " << this->NewRevision
+ << "\n");
return true;
}
@@ -90,11 +91,11 @@ std::string cmCTestGIT::FindGitDir()
// Run "git rev-parse --git-dir" to locate the real .git directory.
const char* git = this->CommandLineTool.c_str();
- char const* git_rev_parse[] = { git, "rev-parse", "--git-dir", CM_NULLPTR };
+ char const* git_rev_parse[] = { git, "rev-parse", "--git-dir", nullptr };
std::string git_dir_line;
OneLineParser rev_parse_out(this, "rev-parse-out> ", git_dir_line);
OutputLogger rev_parse_err(this->Log, "rev-parse-err> ");
- if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err, CM_NULLPTR,
+ if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err, nullptr,
cmProcessOutput::UTF8)) {
git_dir = git_dir_line;
}
@@ -111,14 +112,14 @@ std::string cmCTestGIT::FindGitDir()
else if (git_dir[0] == '/') {
// Cygwin Git reports a full path that Cygwin understands, but we
// are a Windows application. Run "cygpath" to get Windows path.
- std::string cygpath_exe = cmSystemTools::GetFilenamePath(git);
- cygpath_exe += "/cygpath.exe";
- if (cmSystemTools::FileExists(cygpath_exe.c_str())) {
+ std::string cygpath_exe =
+ cmStrCat(cmSystemTools::GetFilenamePath(git), "/cygpath.exe");
+ if (cmSystemTools::FileExists(cygpath_exe)) {
char const* cygpath[] = { cygpath_exe.c_str(), "-w", git_dir.c_str(),
0 };
OneLineParser cygpath_out(this, "cygpath-out> ", git_dir_line);
OutputLogger cygpath_err(this->Log, "cygpath-err> ");
- if (this->RunChild(cygpath, &cygpath_out, &cygpath_err, CM_NULLPTR,
+ if (this->RunChild(cygpath, &cygpath_out, &cygpath_err, nullptr,
cmProcessOutput::UTF8)) {
git_dir = git_dir_line;
}
@@ -134,12 +135,11 @@ std::string cmCTestGIT::FindTopDir()
// Run "git rev-parse --show-cdup" to locate the top of the tree.
const char* git = this->CommandLineTool.c_str();
- char const* git_rev_parse[] = { git, "rev-parse", "--show-cdup",
- CM_NULLPTR };
+ char const* git_rev_parse[] = { git, "rev-parse", "--show-cdup", nullptr };
std::string cdup;
OneLineParser rev_parse_out(this, "rev-parse-out> ", cdup);
OutputLogger rev_parse_err(this->Log, "rev-parse-err> ");
- if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err, CM_NULLPTR,
+ if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err, nullptr,
cmProcessOutput::UTF8) &&
!cdup.empty()) {
top_dir += "/";
@@ -163,14 +163,13 @@ bool cmCTestGIT::UpdateByFetchAndReset()
if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("GITUpdateOptions");
}
- std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- git_fetch.push_back(ai->c_str());
+ std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
+ for (std::string const& arg : args) {
+ git_fetch.push_back(arg.c_str());
}
// Sentinel argument.
- git_fetch.push_back(CM_NULLPTR);
+ git_fetch.push_back(nullptr);
// Fetch upstream refs.
OutputLogger fetch_out(this->Log, "fetch-out> ");
@@ -205,8 +204,7 @@ bool cmCTestGIT::UpdateByFetchAndReset()
}
// Reset the local branch to point at that tracked from upstream.
- char const* git_reset[] = { git, "reset", "--hard", sha1.c_str(),
- CM_NULLPTR };
+ char const* git_reset[] = { git, "reset", "--hard", sha1.c_str(), nullptr };
OutputLogger reset_out(this->Log, "reset-out> ");
OutputLogger reset_err(this->Log, "reset-err> ");
return this->RunChild(&git_reset[0], &reset_out, &reset_err);
@@ -214,14 +212,13 @@ bool cmCTestGIT::UpdateByFetchAndReset()
bool cmCTestGIT::UpdateByCustom(std::string const& custom)
{
- std::vector<std::string> git_custom_command;
- cmSystemTools::ExpandListArgument(custom, git_custom_command, true);
+ std::vector<std::string> git_custom_command = cmExpandedList(custom, true);
std::vector<char const*> git_custom;
- for (std::vector<std::string>::const_iterator i = git_custom_command.begin();
- i != git_custom_command.end(); ++i) {
- git_custom.push_back(i->c_str());
+ git_custom.reserve(git_custom_command.size() + 1);
+ for (std::string const& i : git_custom_command) {
+ git_custom.push_back(i.c_str());
}
- git_custom.push_back(CM_NULLPTR);
+ git_custom.push_back(nullptr);
OutputLogger custom_out(this->Log, "custom-out> ");
OutputLogger custom_err(this->Log, "custom-err> ");
@@ -250,18 +247,18 @@ bool cmCTestGIT::UpdateImpl()
// Git < 1.6.5 did not support submodule --recursive
if (this->GetGitVersion() < cmCTestGITVersion(1, 6, 5, 0)) {
- recursive = CM_NULLPTR;
+ recursive = nullptr;
// No need to require >= 1.6.5 if there are no submodules.
- if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) {
+ if (cmSystemTools::FileExists(top_dir + "/.gitmodules")) {
this->Log << "Git < 1.6.5 cannot update submodules recursively\n";
}
}
// Git < 1.8.1 did not support sync --recursive
if (this->GetGitVersion() < cmCTestGITVersion(1, 8, 1, 0)) {
- sync_recursive = CM_NULLPTR;
+ sync_recursive = nullptr;
// No need to require >= 1.8.1 if there are no submodules.
- if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) {
+ if (cmSystemTools::FileExists(top_dir + "/.gitmodules")) {
this->Log << "Git < 1.8.1 cannot synchronize submodules recursively\n";
}
}
@@ -273,9 +270,8 @@ bool cmCTestGIT::UpdateImpl()
std::string init_submodules =
this->CTest->GetCTestConfiguration("GITInitSubmodules");
- if (cmSystemTools::IsOn(init_submodules.c_str())) {
- char const* git_submodule_init[] = { git, "submodule", "init",
- CM_NULLPTR };
+ if (cmIsOn(init_submodules)) {
+ char const* git_submodule_init[] = { git, "submodule", "init", nullptr };
ret = this->RunChild(git_submodule_init, &submodule_out, &submodule_err,
top_dir.c_str());
@@ -285,7 +281,7 @@ bool cmCTestGIT::UpdateImpl()
}
char const* git_submodule_sync[] = { git, "submodule", "sync",
- sync_recursive, CM_NULLPTR };
+ sync_recursive, nullptr };
ret = this->RunChild(git_submodule_sync, &submodule_out, &submodule_err,
top_dir.c_str());
@@ -294,7 +290,7 @@ bool cmCTestGIT::UpdateImpl()
}
char const* git_submodule[] = { git, "submodule", "update", recursive,
- CM_NULLPTR };
+ nullptr };
return this->RunChild(git_submodule, &submodule_out, &submodule_err,
top_dir.c_str());
}
@@ -303,7 +299,7 @@ unsigned int cmCTestGIT::GetGitVersion()
{
if (!this->CurrentGitVersion) {
const char* git = this->CommandLineTool.c_str();
- char const* git_version[] = { git, "--version", CM_NULLPTR };
+ char const* git_version[] = { git, "--version", nullptr };
std::string version;
OneLineParser version_out(this, "version-out> ", version);
OutputLogger version_err(this->Log, "version-err> ");
@@ -338,7 +334,7 @@ public:
this->SetLog(&git->Log, prefix);
}
- typedef cmCTestGIT::Change Change;
+ using Change = cmCTestGIT::Change;
std::vector<Change> Changes;
protected:
@@ -359,7 +355,7 @@ protected:
this->Changes.clear();
}
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->Line[0] == ':') {
this->DiffField = DiffFieldChange;
@@ -461,7 +457,7 @@ public:
}
private:
- typedef cmCTestGIT::Revision Revision;
+ using Revision = cmCTestGIT::Revision;
enum SectionType
{
SectionHeader,
@@ -477,15 +473,8 @@ private:
{
std::string Name;
std::string EMail;
- unsigned long Time;
- long TimeZone;
- Person()
- : Name()
- , EMail()
- , Time(0)
- , TimeZone(0)
- {
- }
+ unsigned long Time = 0;
+ long TimeZone = 0;
};
void ParsePerson(const char* str, Person& person)
@@ -513,11 +502,11 @@ private:
const char* email_last = *c ? c++ : c;
person.EMail.assign(email_first, email_last - email_first);
- person.Time = strtoul(c, (char**)&c, 10);
- person.TimeZone = strtol(c, (char**)&c, 10);
+ person.Time = strtoul(c, const_cast<char**>(&c), 10);
+ person.TimeZone = strtol(c, const_cast<char**>(&c), 10);
}
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->Line.empty()) {
if (this->Section == SectionBody && this->LineEnd == '\0') {
@@ -557,15 +546,15 @@ private:
void DoHeaderLine()
{
// Look for header fields that we need.
- if (cmHasLiteralPrefix(this->Line.c_str(), "commit ")) {
- this->Rev.Rev = this->Line.c_str() + 7;
- } else if (cmHasLiteralPrefix(this->Line.c_str(), "author ")) {
+ if (cmHasLiteralPrefix(this->Line, "commit ")) {
+ this->Rev.Rev = this->Line.substr(7);
+ } else if (cmHasLiteralPrefix(this->Line, "author ")) {
Person author;
this->ParsePerson(this->Line.c_str() + 7, author);
this->Rev.Author = author.Name;
this->Rev.EMail = author.EMail;
this->Rev.Date = this->FormatDateTime(author);
- } else if (cmHasLiteralPrefix(this->Line.c_str(), "committer ")) {
+ } else if (cmHasLiteralPrefix(this->Line, "committer ")) {
Person committer;
this->ParsePerson(this->Line.c_str() + 10, committer);
this->Rev.Committer = committer.Name;
@@ -615,13 +604,13 @@ bool cmCTestGIT::LoadRevisions()
std::string range = this->OldRevision + ".." + this->NewRevision;
const char* git = this->CommandLineTool.c_str();
const char* git_rev_list[] = { git, "rev-list", "--reverse",
- range.c_str(), "--", CM_NULLPTR };
+ range.c_str(), "--", nullptr };
const char* git_diff_tree[] = {
git, "diff-tree", "--stdin", "--always", "-z",
- "-r", "--pretty=raw", "--encoding=utf-8", CM_NULLPTR
+ "-r", "--pretty=raw", "--encoding=utf-8", nullptr
};
- this->Log << this->ComputeCommandLine(git_rev_list) << " | "
- << this->ComputeCommandLine(git_diff_tree) << "\n";
+ this->Log << cmCTestGIT::ComputeCommandLine(git_rev_list) << " | "
+ << cmCTestGIT::ComputeCommandLine(git_diff_tree) << "\n";
cmsysProcess* cp = cmsysProcess_New();
cmsysProcess_AddCommand(cp, git_rev_list);
@@ -630,7 +619,7 @@ bool cmCTestGIT::LoadRevisions()
CommitParser out(this, "dt-out> ");
OutputLogger err(this->Log, "dt-err> ");
- this->RunProcess(cp, &out, &err, cmProcessOutput::UTF8);
+ cmCTestGIT::RunProcess(cp, &out, &err, cmProcessOutput::UTF8);
// Send one extra zero-byte to terminate the last record.
out.Process("", 1);
@@ -645,23 +634,21 @@ bool cmCTestGIT::LoadModifications()
// Use 'git update-index' to refresh the index w.r.t. the work tree.
const char* git_update_index[] = { git, "update-index", "--refresh",
- CM_NULLPTR };
+ nullptr };
OutputLogger ui_out(this->Log, "ui-out> ");
OutputLogger ui_err(this->Log, "ui-err> ");
- this->RunChild(git_update_index, &ui_out, &ui_err, CM_NULLPTR,
+ this->RunChild(git_update_index, &ui_out, &ui_err, nullptr,
cmProcessOutput::UTF8);
// Use 'git diff-index' to get modified files.
const char* git_diff_index[] = { git, "diff-index", "-z",
- "HEAD", "--", CM_NULLPTR };
+ "HEAD", "--", nullptr };
DiffParser out(this, "di-out> ");
OutputLogger err(this->Log, "di-err> ");
- this->RunChild(git_diff_index, &out, &err, CM_NULLPTR,
- cmProcessOutput::UTF8);
+ this->RunChild(git_diff_index, &out, &err, nullptr, cmProcessOutput::UTF8);
- for (std::vector<Change>::const_iterator ci = out.Changes.begin();
- ci != out.Changes.end(); ++ci) {
- this->DoModification(PathModified, ci->Path);
+ for (Change const& c : out.Changes) {
+ this->DoModification(PathModified, c.Path);
}
return true;
}
diff --git a/Source/CTest/cmCTestGIT.h b/Source/CTest/cmCTestGIT.h
index 4bf8294e6..3103d8492 100644
--- a/Source/CTest/cmCTestGIT.h
+++ b/Source/CTest/cmCTestGIT.h
@@ -3,13 +3,13 @@
#ifndef cmCTestGIT_h
#define cmCTestGIT_h
-#include "cmConfigure.h"
-
-#include "cmCTestGlobalVC.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
+#include "cmCTestGlobalVC.h"
+
class cmCTest;
/** \class cmCTestGIT
@@ -22,15 +22,15 @@ public:
/** Construct with a CTest instance and update log stream. */
cmCTestGIT(cmCTest* ctest, std::ostream& log);
- ~cmCTestGIT() CM_OVERRIDE;
+ ~cmCTestGIT() override;
private:
unsigned int CurrentGitVersion;
unsigned int GetGitVersion();
std::string GetWorkingRevision();
- bool NoteOldRevision() CM_OVERRIDE;
- bool NoteNewRevision() CM_OVERRIDE;
- bool UpdateImpl() CM_OVERRIDE;
+ bool NoteOldRevision() override;
+ bool NoteNewRevision() override;
+ bool UpdateImpl() override;
std::string FindGitDir();
std::string FindTopDir();
@@ -39,8 +39,8 @@ private:
bool UpdateByCustom(std::string const& custom);
bool UpdateInternal();
- bool LoadRevisions() CM_OVERRIDE;
- bool LoadModifications() CM_OVERRIDE;
+ bool LoadRevisions() override;
+ bool LoadModifications() override;
// "public" needed by older Sun compilers
public:
diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx
index 19034c01b..cc0b4ed0c 100644
--- a/Source/CTest/cmCTestGenericHandler.cxx
+++ b/Source/CTest/cmCTestGenericHandler.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestGenericHandler.h"
-#include "cmConfigure.h"
#include <sstream>
#include <utility>
@@ -12,22 +11,19 @@
cmCTestGenericHandler::cmCTestGenericHandler()
{
this->HandlerVerbose = cmSystemTools::OUTPUT_NONE;
- this->CTest = CM_NULLPTR;
+ this->CTest = nullptr;
this->SubmitIndex = 0;
this->AppendXML = false;
this->Quiet = false;
this->TestLoad = 0;
}
-cmCTestGenericHandler::~cmCTestGenericHandler()
-{
-}
+cmCTestGenericHandler::~cmCTestGenericHandler() = default;
void cmCTestGenericHandler::SetOption(const std::string& op, const char* value)
{
if (!value) {
- cmCTestGenericHandler::t_StringToString::iterator remit =
- this->Options.find(op);
+ auto remit = this->Options.find(op);
if (remit != this->Options.end()) {
this->Options.erase(remit);
}
@@ -42,8 +38,7 @@ void cmCTestGenericHandler::SetPersistentOption(const std::string& op,
{
this->SetOption(op, value);
if (!value) {
- cmCTestGenericHandler::t_StringToString::iterator remit =
- this->PersistentOptions.find(op);
+ auto remit = this->PersistentOptions.find(op);
if (remit != this->PersistentOptions.end()) {
this->PersistentOptions.erase(remit);
}
@@ -58,19 +53,16 @@ void cmCTestGenericHandler::Initialize()
this->AppendXML = false;
this->TestLoad = 0;
this->Options.clear();
- t_StringToString::iterator it;
- for (it = this->PersistentOptions.begin();
- it != this->PersistentOptions.end(); ++it) {
- this->Options[it->first] = it->second;
+ for (auto const& po : this->PersistentOptions) {
+ this->Options[po.first] = po.second;
}
}
const char* cmCTestGenericHandler::GetOption(const std::string& op)
{
- cmCTestGenericHandler::t_StringToString::iterator remit =
- this->Options.find(op);
+ auto remit = this->Options.find(op);
if (remit == this->Options.end()) {
- return CM_NULLPTR;
+ return nullptr;
}
return remit->second.c_str();
}
@@ -103,8 +95,9 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part,
}
if (!this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), ostr.str(),
xofs, true)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create resulting XML file: "
- << ostr.str() << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot create resulting XML file: " << ostr.str()
+ << std::endl);
return false;
}
this->CTest->AddSubmitFile(part, ostr.str().c_str());
diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h
index e881252c9..94e541865 100644
--- a/Source/CTest/cmCTestGenericHandler.h
+++ b/Source/CTest/cmCTestGenericHandler.h
@@ -6,10 +6,11 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
-#include <stddef.h>
#include <string>
#include <vector>
+#include <stddef.h>
+
#include "cmCTest.h"
#include "cmSystemTools.h"
@@ -25,7 +26,7 @@ class cmCTestGenericHandler
{
public:
/**
- * If verbose then more informaiton is printed out
+ * If verbose then more information is printed out
*/
void SetVerbose(bool val)
{
@@ -71,7 +72,7 @@ public:
cmCTestGenericHandler();
virtual ~cmCTestGenericHandler();
- typedef std::map<std::string, std::string> t_StringToString;
+ using t_StringToString = std::map<std::string, std::string>;
void SetPersistentOption(const std::string& op, const char* value);
void SetOption(const std::string& op, const char* value);
diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx
index 25294b5ae..5f05efb33 100644
--- a/Source/CTest/cmCTestGlobalVC.cxx
+++ b/Source/CTest/cmCTestGlobalVC.cxx
@@ -2,22 +2,20 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestGlobalVC.h"
+#include <ostream>
+#include <utility>
+
#include "cmCTest.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
-#include <ostream>
-#include <utility>
-
cmCTestGlobalVC::cmCTestGlobalVC(cmCTest* ct, std::ostream& log)
: cmCTestVC(ct, log)
{
this->PriorRev = this->Unknown;
}
-cmCTestGlobalVC::~cmCTestGlobalVC()
-{
-}
+cmCTestGlobalVC::~cmCTestGlobalVC() = default;
const char* cmCTestGlobalVC::LocalPath(std::string const& path)
{
@@ -48,15 +46,14 @@ void cmCTestGlobalVC::DoRevision(Revision const& revision,
/* clang-format on */
// Update information about revisions of the changed files.
- for (std::vector<Change>::const_iterator ci = changes.begin();
- ci != changes.end(); ++ci) {
- if (const char* local = this->LocalPath(ci->Path)) {
+ for (Change const& c : changes) {
+ if (const char* local = this->LocalPath(c.Path)) {
std::string dir = cmSystemTools::GetFilenamePath(local);
std::string name = cmSystemTools::GetFilenameName(local);
File& file = this->Dirs[dir][name];
file.PriorRev = file.Rev ? file.Rev : &this->PriorRev;
file.Rev = &rev;
- this->Log << " " << ci->Action << " " << local << " "
+ this->Log << " " << c.Action << " " << local << " "
<< "\n";
}
}
@@ -83,9 +80,9 @@ void cmCTestGlobalVC::WriteXMLDirectory(cmXMLWriter& xml,
const char* slash = path.empty() ? "" : "/";
xml.StartElement("Directory");
xml.Element("Name", path);
- for (Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) {
- std::string full = path + slash + fi->first;
- this->WriteXMLEntry(xml, path, fi->first, full, fi->second);
+ for (auto const& f : dir) {
+ std::string const full = path + slash + f.first;
+ this->WriteXMLEntry(xml, path, f.first, full, f.second);
}
xml.EndElement(); // Directory
}
@@ -114,11 +111,14 @@ bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml)
this->WriteXMLGlobal(xml);
- for (std::map<std::string, Directory>::const_iterator di =
- this->Dirs.begin();
- di != this->Dirs.end(); ++di) {
- this->WriteXMLDirectory(xml, di->first, di->second);
+ for (auto const& d : this->Dirs) {
+ this->WriteXMLDirectory(xml, d.first, d.second);
}
return result;
}
+
+void cmCTestGlobalVC::SetNewRevision(std::string const& revision)
+{
+ this->NewRevision = revision;
+}
diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h
index a5273d3dd..ff86591ea 100644
--- a/Source/CTest/cmCTestGlobalVC.h
+++ b/Source/CTest/cmCTestGlobalVC.h
@@ -3,9 +3,7 @@
#ifndef cmCTestGlobalVC_h
#define cmCTestGlobalVC_h
-#include "cmConfigure.h"
-
-#include "cmCTestVC.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <list>
@@ -13,6 +11,8 @@
#include <string>
#include <vector>
+#include "cmCTestVC.h"
+
class cmCTest;
class cmXMLWriter;
@@ -26,11 +26,13 @@ public:
/** Construct with a CTest instance and update log stream. */
cmCTestGlobalVC(cmCTest* ctest, std::ostream& log);
- ~cmCTestGlobalVC() CM_OVERRIDE;
+ ~cmCTestGlobalVC() override;
protected:
// Implement cmCTestVC internal API.
- bool WriteXMLUpdates(cmXMLWriter& xml) CM_OVERRIDE;
+ bool WriteXMLUpdates(cmXMLWriter& xml) override;
+
+ void SetNewRevision(std::string const& revision) override;
/** Represent a vcs-reported action for one path in a revision. */
struct Change
diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx
index 49f9a6500..3265498c0 100644
--- a/Source/CTest/cmCTestHG.cxx
+++ b/Source/CTest/cmCTestHG.cxx
@@ -2,25 +2,25 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestHG.h"
+#include <ostream>
+#include <vector>
+
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestVC.h"
#include "cmProcessTools.h"
#include "cmSystemTools.h"
#include "cmXMLParser.h"
-#include "cmsys/RegularExpression.hxx"
-#include <ostream>
-#include <vector>
-
cmCTestHG::cmCTestHG(cmCTest* ct, std::ostream& log)
: cmCTestGlobalVC(ct, log)
{
this->PriorRev = this->Unknown;
}
-cmCTestHG::~cmCTestHG()
-{
-}
+cmCTestHG::~cmCTestHG() = default;
class cmCTestHG::IdentifyParser : public cmCTestVC::LineParser
{
@@ -36,7 +36,7 @@ private:
std::string& Rev;
cmsys::RegularExpression RegexIdentify;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexIdentify.find(this->Line)) {
this->Rev = this->RegexIdentify.match(1);
@@ -60,7 +60,7 @@ private:
cmCTestHG* HG;
cmsys::RegularExpression RegexStatus;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexStatus.find(this->Line)) {
this->DoPath(this->RegexStatus.match(1)[0], this->RegexStatus.match(2));
@@ -96,7 +96,7 @@ std::string cmCTestHG::GetWorkingRevision()
{
// Run plumbing "hg identify" to get work tree revision.
const char* hg = this->CommandLineTool.c_str();
- const char* hg_identify[] = { hg, "identify", "-i", CM_NULLPTR };
+ const char* hg_identify[] = { hg, "identify", "-i", nullptr };
std::string rev;
IdentifyParser out(this, "rev-out> ", rev);
OutputLogger err(this->Log, "rev-err> ");
@@ -107,8 +107,9 @@ std::string cmCTestHG::GetWorkingRevision()
bool cmCTestHG::NoteOldRevision()
{
this->OldRevision = this->GetWorkingRevision();
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
- << this->OldRevision << "\n");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " Old revision of repository is: " << this->OldRevision
+ << "\n");
this->PriorRev.Rev = this->OldRevision;
return true;
}
@@ -116,8 +117,9 @@ bool cmCTestHG::NoteOldRevision()
bool cmCTestHG::NoteNewRevision()
{
this->NewRevision = this->GetWorkingRevision();
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
- << this->NewRevision << "\n");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " New revision of repository is: " << this->NewRevision
+ << "\n");
return true;
}
@@ -126,7 +128,7 @@ bool cmCTestHG::UpdateImpl()
// Use "hg pull" followed by "hg update" to update the working tree.
{
const char* hg = this->CommandLineTool.c_str();
- const char* hg_pull[] = { hg, "pull", "-v", CM_NULLPTR };
+ const char* hg_pull[] = { hg, "pull", "-v", nullptr };
OutputLogger out(this->Log, "pull-out> ");
OutputLogger err(this->Log, "pull-err> ");
this->RunChild(&hg_pull[0], &out, &err);
@@ -144,22 +146,22 @@ bool cmCTestHG::UpdateImpl()
if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("HGUpdateOptions");
}
- std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- hg_update.push_back(ai->c_str());
+ std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
+ for (std::string const& arg : args) {
+ hg_update.push_back(arg.c_str());
}
// Sentinel argument.
- hg_update.push_back(CM_NULLPTR);
+ hg_update.push_back(nullptr);
OutputLogger out(this->Log, "update-out> ");
OutputLogger err(this->Log, "update-err> ");
return this->RunUpdateCommand(&hg_update[0], &out, &err);
}
-class cmCTestHG::LogParser : public cmCTestVC::OutputLogger,
- private cmXMLParser
+class cmCTestHG::LogParser
+ : public cmCTestVC::OutputLogger
+ , private cmXMLParser
{
public:
LogParser(cmCTestHG* hg, const char* prefix)
@@ -168,42 +170,44 @@ public:
{
this->InitializeParser();
}
- ~LogParser() CM_OVERRIDE { this->CleanupParser(); }
+ ~LogParser() override { this->CleanupParser(); }
+
private:
cmCTestHG* HG;
- typedef cmCTestHG::Revision Revision;
- typedef cmCTestHG::Change Change;
+ using Revision = cmCTestHG::Revision;
+ using Change = cmCTestHG::Change;
Revision Rev;
std::vector<Change> Changes;
Change CurChange;
std::vector<char> CData;
- bool ProcessChunk(const char* data, int length) CM_OVERRIDE
+ bool ProcessChunk(const char* data, int length) override
{
this->OutputLogger::ProcessChunk(data, length);
this->ParseChunk(data, length);
return true;
}
- void StartElement(const std::string& name, const char** atts) CM_OVERRIDE
+ void StartElement(const std::string& name, const char** atts) override
{
this->CData.clear();
if (name == "logentry") {
this->Rev = Revision();
- if (const char* rev = this->FindAttribute(atts, "revision")) {
+ if (const char* rev =
+ cmCTestHG::LogParser::FindAttribute(atts, "revision")) {
this->Rev.Rev = rev;
}
this->Changes.clear();
}
}
- void CharacterDataHandler(const char* data, int length) CM_OVERRIDE
+ void CharacterDataHandler(const char* data, int length) override
{
- this->CData.insert(this->CData.end(), data, data + length);
+ cmAppend(this->CData, data, data + length);
}
- void EndElement(const std::string& name) CM_OVERRIDE
+ void EndElement(const std::string& name) override
{
if (name == "logentry") {
this->HG->DoRevision(this->Rev, this->Changes);
@@ -217,25 +221,25 @@ private:
this->Rev.Log.assign(&this->CData[0], this->CData.size());
} else if (!this->CData.empty() && name == "files") {
std::vector<std::string> paths = this->SplitCData();
- for (unsigned int i = 0; i < paths.size(); ++i) {
+ for (std::string const& path : paths) {
// Updated by default, will be modified using file_adds and
// file_dels.
this->CurChange = Change('U');
- this->CurChange.Path = paths[i];
+ this->CurChange.Path = path;
this->Changes.push_back(this->CurChange);
}
} else if (!this->CData.empty() && name == "file_adds") {
std::string added_paths(this->CData.begin(), this->CData.end());
- for (unsigned int i = 0; i < this->Changes.size(); ++i) {
- if (added_paths.find(this->Changes[i].Path) != std::string::npos) {
- this->Changes[i].Action = 'A';
+ for (Change& change : this->Changes) {
+ if (added_paths.find(change.Path) != std::string::npos) {
+ change.Action = 'A';
}
}
} else if (!this->CData.empty() && name == "file_dels") {
std::string added_paths(this->CData.begin(), this->CData.end());
- for (unsigned int i = 0; i < this->Changes.size(); ++i) {
- if (added_paths.find(this->Changes[i].Path) != std::string::npos) {
- this->Changes[i].Action = 'D';
+ for (Change& change : this->Changes) {
+ if (added_paths.find(change.Path) != std::string::npos) {
+ change.Action = 'D';
}
}
}
@@ -246,19 +250,19 @@ private:
{
std::vector<std::string> output;
std::string currPath;
- for (unsigned int i = 0; i < this->CData.size(); ++i) {
- if (this->CData[i] != ' ') {
- currPath += this->CData[i];
+ for (char i : this->CData) {
+ if (i != ' ') {
+ currPath += i;
} else {
output.push_back(currPath);
- currPath = "";
+ currPath.clear();
}
}
output.push_back(currPath);
return output;
}
- void ReportError(int /*line*/, int /*column*/, const char* msg) CM_OVERRIDE
+ void ReportError(int /*line*/, int /*column*/, const char* msg) override
{
this->HG->Log << "Error parsing hg log xml: " << msg << "\n";
}
@@ -286,7 +290,7 @@ bool cmCTestHG::LoadRevisions()
"</logentry>\n";
const char* hg_log[] = {
hg, "log", "--removed", "-r", range.c_str(),
- "--template", hgXMLTemplate, CM_NULLPTR
+ "--template", hgXMLTemplate, nullptr
};
LogParser out(this, "log-out> ");
@@ -302,7 +306,7 @@ bool cmCTestHG::LoadModifications()
{
// Use 'hg status' to get modified files.
const char* hg = this->CommandLineTool.c_str();
- const char* hg_status[] = { hg, "status", CM_NULLPTR };
+ const char* hg_status[] = { hg, "status", nullptr };
StatusParser out(this, "status-out> ");
OutputLogger err(this->Log, "status-err> ");
this->RunChild(hg_status, &out, &err);
diff --git a/Source/CTest/cmCTestHG.h b/Source/CTest/cmCTestHG.h
index ec9eaffe8..2900139b4 100644
--- a/Source/CTest/cmCTestHG.h
+++ b/Source/CTest/cmCTestHG.h
@@ -3,13 +3,13 @@
#ifndef cmCTestHG_h
#define cmCTestHG_h
-#include "cmConfigure.h"
-
-#include "cmCTestGlobalVC.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
+#include "cmCTestGlobalVC.h"
+
class cmCTest;
/** \class cmCTestHG
@@ -22,16 +22,16 @@ public:
/** Construct with a CTest instance and update log stream. */
cmCTestHG(cmCTest* ctest, std::ostream& log);
- ~cmCTestHG() CM_OVERRIDE;
+ ~cmCTestHG() override;
private:
std::string GetWorkingRevision();
- bool NoteOldRevision() CM_OVERRIDE;
- bool NoteNewRevision() CM_OVERRIDE;
- bool UpdateImpl() CM_OVERRIDE;
+ bool NoteOldRevision() override;
+ bool NoteNewRevision() override;
+ bool UpdateImpl() override;
- bool LoadRevisions() CM_OVERRIDE;
- bool LoadModifications() CM_OVERRIDE;
+ bool LoadRevisions() override;
+ bool LoadModifications() override;
// Parsing helper classes.
class IdentifyParser;
diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx
index c99e450d0..b1034c9ff 100644
--- a/Source/CTest/cmCTestHandlerCommand.cxx
+++ b/Source/CTest/cmCTestHandlerCommand.cxx
@@ -2,35 +2,21 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestHandlerCommand.h"
+#include <algorithm>
+#include <cstdlib>
+#include <cstring>
+#include <sstream>
+
+#include "cm_static_string_view.hxx"
+
#include "cmCTest.h"
#include "cmCTestGenericHandler.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
-#include "cmake.h"
-
-#include <sstream>
-#include <stdlib.h>
-
-class cmExecutionStatus;
-
-cmCTestHandlerCommand::cmCTestHandlerCommand()
-{
- const size_t INIT_SIZE = 100;
- size_t cc;
- this->Arguments.reserve(INIT_SIZE);
- for (cc = 0; cc < INIT_SIZE; ++cc) {
- this->Arguments.push_back(CM_NULLPTR);
- }
- this->Arguments[ct_RETURN_VALUE] = "RETURN_VALUE";
- this->Arguments[ct_CAPTURE_CMAKE_ERROR] = "CAPTURE_CMAKE_ERROR";
- this->Arguments[ct_SOURCE] = "SOURCE";
- this->Arguments[ct_BUILD] = "BUILD";
- this->Arguments[ct_SUBMIT_INDEX] = "SUBMIT_INDEX";
- this->Last = ct_LAST;
- this->AppendXML = false;
- this->Quiet = false;
-}
namespace {
// class to save and restore the error state for ctest_* commands
@@ -75,6 +61,8 @@ public:
}
}
}
+ SaveRestoreErrorState(const SaveRestoreErrorState&) = delete;
+ SaveRestoreErrorState& operator=(const SaveRestoreErrorState&) = delete;
private:
bool InitialErrorState;
@@ -83,48 +71,46 @@ private:
}
bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& /*unused*/)
+ cmExecutionStatus& status)
{
// save error state and restore it if needed
SaveRestoreErrorState errorState;
// Allocate space for argument values.
- this->Values.clear();
- this->Values.resize(this->Last, CM_NULLPTR);
+ this->BindArguments();
// Process input arguments.
- this->ArgumentDoing = ArgumentDoingNone;
- // look at all arguments and do not short circuit on the first
- // bad one so that CAPTURE_CMAKE_ERROR can override setting the
- // global error state
- bool foundBadArgument = false;
- for (unsigned int i = 0; i < args.size(); ++i) {
- // Check this argument.
- if (!this->CheckArgumentKeyword(args[i]) &&
- !this->CheckArgumentValue(args[i])) {
- std::ostringstream e;
- e << "called with unknown argument \"" << args[i] << "\".";
- this->SetError(e.str());
- foundBadArgument = true;
- }
- // note bad argument
- if (this->ArgumentDoing == ArgumentDoingError) {
- foundBadArgument = true;
- }
+ std::vector<std::string> unparsedArguments;
+ std::vector<std::string> keywordsMissingValue;
+ std::vector<std::string> parsedKeywords;
+ this->Parse(args, &unparsedArguments, &keywordsMissingValue,
+ &parsedKeywords);
+ this->CheckArguments(keywordsMissingValue);
+
+ std::sort(parsedKeywords.begin(), parsedKeywords.end());
+ auto it = std::adjacent_find(parsedKeywords.begin(), parsedKeywords.end());
+ if (it != parsedKeywords.end()) {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Called with more than one value for ", *it));
+ }
+
+ bool const foundBadArgument = !unparsedArguments.empty();
+ if (foundBadArgument) {
+ this->SetError(cmStrCat("called with unknown argument \"",
+ unparsedArguments.front(), "\"."));
}
- bool capureCMakeError = (this->Values[ct_CAPTURE_CMAKE_ERROR] &&
- *this->Values[ct_CAPTURE_CMAKE_ERROR]);
+ bool const captureCMakeError = !this->CaptureCMakeError.empty();
// now that arguments are parsed check to see if there is a
// CAPTURE_CMAKE_ERROR specified let the errorState object know.
- if (capureCMakeError) {
+ if (captureCMakeError) {
errorState.CaptureCMakeError();
}
// if we found a bad argument then exit before running command
if (foundBadArgument) {
// store the cmake error
- if (capureCMakeError) {
- this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR],
- "-1");
- std::string const err = this->GetName() + " " + this->GetError();
+ if (captureCMakeError) {
+ this->Makefile->AddDefinition(this->CaptureCMakeError, "-1");
+ std::string const err = this->GetName() + " " + status.GetError();
if (!cmSystemTools::FindLastString(err.c_str(), "unknown error.")) {
cmCTestLog(this->CTest, ERROR_MESSAGE, err << " error from command\n");
}
@@ -145,29 +131,27 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
this->CTest->SetConfigType(ctestConfigType);
}
- if (this->Values[ct_BUILD]) {
+ if (!this->Build.empty()) {
this->CTest->SetCTestConfiguration(
- "BuildDirectory",
- cmSystemTools::CollapseFullPath(this->Values[ct_BUILD]).c_str(),
+ "BuildDirectory", cmSystemTools::CollapseFullPath(this->Build).c_str(),
this->Quiet);
} else {
- const char* bdir =
+ std::string const& bdir =
this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
- if (bdir) {
+ if (!bdir.empty()) {
this->CTest->SetCTestConfiguration(
"BuildDirectory", cmSystemTools::CollapseFullPath(bdir).c_str(),
this->Quiet);
} else {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "CTEST_BINARY_DIRECTORY not set"
- << std::endl;);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "CTEST_BINARY_DIRECTORY not set" << std::endl;);
}
}
- if (this->Values[ct_SOURCE]) {
- cmCTestLog(this->CTest, DEBUG, "Set source directory to: "
- << this->Values[ct_SOURCE] << std::endl);
+ if (!this->Source.empty()) {
+ cmCTestLog(this->CTest, DEBUG,
+ "Set source directory to: " << this->Source << std::endl);
this->CTest->SetCTestConfiguration(
- "SourceDirectory",
- cmSystemTools::CollapseFullPath(this->Values[ct_SOURCE]).c_str(),
+ "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source).c_str(),
this->Quiet);
} else {
this->CTest->SetCTestConfiguration(
@@ -186,13 +170,13 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl;);
cmCTestGenericHandler* handler = this->InitializeHandler();
if (!handler) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot instantiate test handler "
- << this->GetName() << std::endl);
- if (capureCMakeError) {
- this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR],
- "-1");
- const char* err = this->GetError();
- if (err && !cmSystemTools::FindLastString(err, "unknown error.")) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot instantiate test handler " << this->GetName()
+ << std::endl);
+ if (captureCMakeError) {
+ this->Makefile->AddDefinition(this->CaptureCMakeError, "-1");
+ std::string const& err = status.GetError();
+ if (!cmSystemTools::FindLastString(err.c_str(), "unknown error.")) {
cmCTestLog(this->CTest, ERROR_MESSAGE, err << " error from command\n");
}
return true;
@@ -200,48 +184,47 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
return false;
}
- handler->SetAppendXML(this->AppendXML);
+ handler->SetAppendXML(this->Append);
handler->PopulateCustomVectors(this->Makefile);
- if (this->Values[ct_SUBMIT_INDEX]) {
- if (!this->CTest->GetDropSiteCDash() &&
- this->CTest->GetDartVersion() <= 1) {
- cmCTestLog(
- this->CTest, ERROR_MESSAGE,
- "Dart before version 2.0 does not support collecting submissions."
- << std::endl
- << "Please upgrade the server to Dart 2 or higher, or do not use "
- "SUBMIT_INDEX."
- << std::endl);
- } else {
- handler->SetSubmitIndex(atoi(this->Values[ct_SUBMIT_INDEX]));
- }
+ if (!this->SubmitIndex.empty()) {
+ handler->SetSubmitIndex(atoi(this->SubmitIndex.c_str()));
}
cmWorkingDirectory workdir(
this->CTest->GetCTestConfiguration("BuildDirectory"));
+ if (workdir.Failed()) {
+ this->SetError("failed to change directory to " +
+ this->CTest->GetCTestConfiguration("BuildDirectory") +
+ " : " + std::strerror(workdir.GetLastResult()));
+ if (captureCMakeError) {
+ this->Makefile->AddDefinition(this->CaptureCMakeError, "-1");
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ this->GetName() << " " << status.GetError() << "\n");
+ // return success because failure is recorded in CAPTURE_CMAKE_ERROR
+ return true;
+ }
+ return false;
+ }
+
int res = handler->ProcessHandler();
- if (this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE]) {
- std::ostringstream str;
- str << res;
- this->Makefile->AddDefinition(this->Values[ct_RETURN_VALUE],
- str.str().c_str());
+ if (!this->ReturnValue.empty()) {
+ this->Makefile->AddDefinition(this->ReturnValue, std::to_string(res));
}
this->ProcessAdditionalValues(handler);
// log the error message if there was an error
- if (capureCMakeError) {
+ if (captureCMakeError) {
const char* returnString = "0";
if (cmSystemTools::GetErrorOccuredFlag()) {
returnString = "-1";
- const char* err = this->GetError();
+ std::string const& err = status.GetError();
// print out the error if it is not "unknown error" which means
// there was no message
- if (err && !cmSystemTools::FindLastString(err, "unknown error.")) {
+ if (!cmSystemTools::FindLastString(err.c_str(), "unknown error.")) {
cmCTestLog(this->CTest, ERROR_MESSAGE, err);
}
}
// store the captured cmake error state 0 or -1
- this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR],
- returnString);
+ this->Makefile->AddDefinition(this->CaptureCMakeError, returnString);
}
return true;
}
@@ -250,47 +233,17 @@ void cmCTestHandlerCommand::ProcessAdditionalValues(cmCTestGenericHandler*)
{
}
-bool cmCTestHandlerCommand::CheckArgumentKeyword(std::string const& arg)
+void cmCTestHandlerCommand::BindArguments()
{
- // Look for non-value arguments common to all commands.
- if (arg == "APPEND") {
- this->ArgumentDoing = ArgumentDoingNone;
- this->AppendXML = true;
- return true;
- }
- if (arg == "QUIET") {
- this->ArgumentDoing = ArgumentDoingNone;
- this->Quiet = true;
- return true;
- }
-
- // Check for a keyword in our argument/value table.
- for (unsigned int k = 0; k < this->Arguments.size(); ++k) {
- if (this->Arguments[k] && arg == this->Arguments[k]) {
- this->ArgumentDoing = ArgumentDoingKeyword;
- this->ArgumentIndex = k;
- return true;
- }
- }
- return false;
+ this->Bind("APPEND"_s, this->Append);
+ this->Bind("QUIET"_s, this->Quiet);
+ this->Bind("RETURN_VALUE"_s, this->ReturnValue);
+ this->Bind("CAPTURE_CMAKE_ERROR"_s, this->CaptureCMakeError);
+ this->Bind("SOURCE"_s, this->Source);
+ this->Bind("BUILD"_s, this->Build);
+ this->Bind("SUBMIT_INDEX"_s, this->SubmitIndex);
}
-bool cmCTestHandlerCommand::CheckArgumentValue(std::string const& arg)
+void cmCTestHandlerCommand::CheckArguments(std::vector<std::string> const&)
{
- if (this->ArgumentDoing == ArgumentDoingKeyword) {
- this->ArgumentDoing = ArgumentDoingNone;
- unsigned int k = this->ArgumentIndex;
- if (this->Values[k]) {
- std::ostringstream e;
- e << "Called with more than one value for " << this->Arguments[k];
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
- this->ArgumentDoing = ArgumentDoingError;
- return true;
- }
- this->Values[k] = arg.c_str();
- cmCTestLog(this->CTest, DEBUG, "Set " << this->Arguments[k] << " to "
- << arg << "\n");
- return true;
- }
- return false;
}
diff --git a/Source/CTest/cmCTestHandlerCommand.h b/Source/CTest/cmCTestHandlerCommand.h
index 0ea061225..a20d607e2 100644
--- a/Source/CTest/cmCTestHandlerCommand.h
+++ b/Source/CTest/cmCTestHandlerCommand.h
@@ -3,14 +3,14 @@
#ifndef cmCTestHandlerCommand_h
#define cmCTestHandlerCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmCTestCommand.h"
-
-#include <stddef.h>
#include <string>
#include <vector>
+#include "cmArgumentParser.h"
+#include "cmCTestCommand.h"
+
class cmCTestGenericHandler;
class cmExecutionStatus;
@@ -19,11 +19,11 @@ class cmExecutionStatus;
*
* cmCTestHandlerCommand defineds the command to test the project.
*/
-class cmCTestHandlerCommand : public cmCTestCommand
+class cmCTestHandlerCommand
+ : public cmCTestCommand
+ , public cmArgumentParser<void>
{
public:
- cmCTestHandlerCommand();
-
/**
* The name of the command as specified in CMakeList.txt.
*/
@@ -34,18 +34,7 @@ public:
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
- enum
- {
- ct_NONE,
- ct_RETURN_VALUE,
- ct_CAPTURE_CMAKE_ERROR,
- ct_BUILD,
- ct_SOURCE,
- ct_SUBMIT_INDEX,
- ct_LAST
- };
+ cmExecutionStatus& status) override;
protected:
virtual cmCTestGenericHandler* InitializeHandler() = 0;
@@ -53,25 +42,16 @@ protected:
virtual void ProcessAdditionalValues(cmCTestGenericHandler* handler);
// Command argument handling.
- virtual bool CheckArgumentKeyword(std::string const& arg);
- virtual bool CheckArgumentValue(std::string const& arg);
- enum
- {
- ArgumentDoingNone,
- ArgumentDoingError,
- ArgumentDoingKeyword,
- ArgumentDoingLast1
- };
- int ArgumentDoing;
- unsigned int ArgumentIndex;
-
- bool AppendXML;
- bool Quiet;
-
- std::string ReturnVariable;
- std::vector<const char*> Arguments;
- std::vector<const char*> Values;
- size_t Last;
+ virtual void BindArguments();
+ virtual void CheckArguments(std::vector<std::string> const& keywords);
+
+ bool Append = false;
+ bool Quiet = false;
+ std::string CaptureCMakeError;
+ std::string ReturnValue;
+ std::string Build;
+ std::string Source;
+ std::string SubmitIndex;
};
#define CTEST_COMMAND_APPEND_OPTION_DOCS \
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index 5b213518a..647f5fff9 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -2,36 +2,36 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestLaunch.h"
-#include "cmConfigure.h"
+#include <cstdlib>
+#include <cstring>
+#include <iostream>
#include "cmsys/FStream.hxx"
#include "cmsys/Process.h"
#include "cmsys/RegularExpression.hxx"
-#include <iostream>
-#include <stdlib.h>
-#include <string.h>
#include "cmCryptoHash.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmProcessOutput.h"
+#include "cmState.h"
#include "cmStateSnapshot.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
#ifdef _WIN32
-#include <fcntl.h> // for _O_BINARY
-#include <io.h> // for _setmode
-#include <stdio.h> // for std{out,err} and fileno
+# include <fcntl.h> // for _O_BINARY
+# include <io.h> // for _setmode
+# include <stdio.h> // for std{out,err} and fileno
#endif
cmCTestLaunch::cmCTestLaunch(int argc, const char* const* argv)
{
this->Passthru = true;
- this->Process = CM_NULLPTR;
+ this->Process = nullptr;
this->ExitCode = 1;
this->CWD = cmSystemTools::GetCurrentWorkingDirectory();
@@ -129,7 +129,7 @@ bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv)
return true;
}
this->RealArgC = 0;
- this->RealArgV = CM_NULLPTR;
+ this->RealArgV = nullptr;
std::cerr << "No launch/command separator ('--') found!\n";
return false;
}
@@ -147,7 +147,7 @@ void cmCTestLaunch::HandleRealArg(const char* arg)
return;
}
#endif
- this->RealArgs.push_back(arg);
+ this->RealArgs.emplace_back(arg);
}
void cmCTestLaunch::ComputeFileNames()
@@ -171,21 +171,14 @@ void cmCTestLaunch::ComputeFileNames()
cmCryptoHash md5(cmCryptoHash::AlgoMD5);
md5.Initialize();
md5.Append(this->CWD);
- for (std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
- ai != this->RealArgs.end(); ++ai) {
- md5.Append(*ai);
+ for (std::string const& realArg : this->RealArgs) {
+ md5.Append(realArg);
}
this->LogHash = md5.FinalizeHex();
// We store stdout and stderr in temporary log files.
- this->LogOut = this->LogDir;
- this->LogOut += "launch-";
- this->LogOut += this->LogHash;
- this->LogOut += "-out.txt";
- this->LogErr = this->LogDir;
- this->LogErr += "launch-";
- this->LogErr += this->LogHash;
- this->LogErr += "-err.txt";
+ this->LogOut = cmStrCat(this->LogDir, "launch-", this->LogHash, "-out.txt");
+ this->LogErr = cmStrCat(this->LogDir, "launch-", this->LogHash, "-err.txt");
}
void cmCTestLaunch::RunChild()
@@ -224,11 +217,11 @@ void cmCTestLaunch::RunChild()
// Record child stdout and stderr if necessary.
if (!this->Passthru) {
- char* data = CM_NULLPTR;
+ char* data = nullptr;
int length = 0;
cmProcessOutput processOutput;
std::string strdata;
- while (int p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) {
+ while (int p = cmsysProcess_WaitForData(cp, &data, &length, nullptr)) {
if (p == cmsysProcess_Pipe_STDOUT) {
processOutput.DecodeText(data, length, strdata, 1);
fout.write(strdata.c_str(), strdata.size());
@@ -254,7 +247,7 @@ void cmCTestLaunch::RunChild()
}
// Wait for the real command to finish.
- cmsysProcess_WaitForExit(cp, CM_NULLPTR);
+ cmsysProcess_WaitForExit(cp, nullptr);
this->ExitCode = cmsysProcess_GetExitValue(cp);
}
@@ -284,11 +277,8 @@ void cmCTestLaunch::LoadLabels()
}
// Labels are listed in per-target files.
- std::string fname = this->OptionBuildDir;
- fname += cmake::GetCMakeFilesDirectory();
- fname += "/";
- fname += this->OptionTargetName;
- fname += ".dir/Labels.txt";
+ std::string fname = cmStrCat(this->OptionBuildDir, "/CMakeFiles/",
+ this->OptionTargetName, ".dir/Labels.txt");
// We are interested in per-target labels for this source file.
std::string source = this->OptionSource;
@@ -310,7 +300,7 @@ void cmCTestLaunch::LoadLabels()
if (line[0] == ' ') {
// Label lines appear indented by one space.
if (inTarget || inSource) {
- this->Labels.insert(line.c_str() + 1);
+ this->Labels.insert(line.substr(1));
}
} else if (!this->OptionSource.empty() && !inSource) {
// Non-indented lines specify a source file name. The first one
@@ -342,36 +332,34 @@ bool cmCTestLaunch::IsError() const
void cmCTestLaunch::WriteXML()
{
// Name the xml file.
- std::string logXML = this->LogDir;
- logXML += this->IsError() ? "error-" : "warning-";
- logXML += this->LogHash;
- logXML += ".xml";
+ std::string logXML =
+ cmStrCat(this->LogDir, this->IsError() ? "error-" : "warning-",
+ this->LogHash, ".xml");
// Use cmGeneratedFileStream to atomically create the report file.
- cmGeneratedFileStream fxml(logXML.c_str());
+ cmGeneratedFileStream fxml(logXML);
cmXMLWriter xml(fxml, 2);
- xml.StartElement("Failure");
- xml.Attribute("type", this->IsError() ? "Error" : "Warning");
- this->WriteXMLAction(xml);
- this->WriteXMLCommand(xml);
- this->WriteXMLResult(xml);
- this->WriteXMLLabels(xml);
- xml.EndElement(); // Failure
+ cmXMLElement e2(xml, "Failure");
+ e2.Attribute("type", this->IsError() ? "Error" : "Warning");
+ this->WriteXMLAction(e2);
+ this->WriteXMLCommand(e2);
+ this->WriteXMLResult(e2);
+ this->WriteXMLLabels(e2);
}
-void cmCTestLaunch::WriteXMLAction(cmXMLWriter& xml)
+void cmCTestLaunch::WriteXMLAction(cmXMLElement& e2)
{
- xml.Comment("Meta-information about the build action");
- xml.StartElement("Action");
+ e2.Comment("Meta-information about the build action");
+ cmXMLElement e3(e2, "Action");
// TargetName
if (!this->OptionTargetName.empty()) {
- xml.Element("TargetName", this->OptionTargetName);
+ e3.Element("TargetName", this->OptionTargetName);
}
// Language
if (!this->OptionLanguage.empty()) {
- xml.Element("Language", this->OptionLanguage);
+ e3.Element("Language", this->OptionLanguage);
}
// SourceFile
@@ -380,23 +368,22 @@ void cmCTestLaunch::WriteXMLAction(cmXMLWriter& xml)
cmSystemTools::ConvertToUnixSlashes(source);
// If file is in source tree use its relative location.
- if (cmSystemTools::FileIsFullPath(this->SourceDir.c_str()) &&
- cmSystemTools::FileIsFullPath(source.c_str()) &&
+ if (cmSystemTools::FileIsFullPath(this->SourceDir) &&
+ cmSystemTools::FileIsFullPath(source) &&
cmSystemTools::IsSubDirectory(source, this->SourceDir)) {
- source =
- cmSystemTools::RelativePath(this->SourceDir.c_str(), source.c_str());
+ source = cmSystemTools::RelativePath(this->SourceDir, source);
}
- xml.Element("SourceFile", source);
+ e3.Element("SourceFile", source);
}
// OutputFile
if (!this->OptionOutput.empty()) {
- xml.Element("OutputFile", this->OptionOutput);
+ e3.Element("OutputFile", this->OptionOutput);
}
// OutputType
- const char* outputType = CM_NULLPTR;
+ const char* outputType = nullptr;
if (!this->OptionTargetType.empty()) {
if (this->OptionTargetType == "EXECUTABLE") {
outputType = "executable";
@@ -411,106 +398,99 @@ void cmCTestLaunch::WriteXMLAction(cmXMLWriter& xml)
outputType = "object file";
}
if (outputType) {
- xml.Element("OutputType", outputType);
+ e3.Element("OutputType", outputType);
}
-
- xml.EndElement(); // Action
}
-void cmCTestLaunch::WriteXMLCommand(cmXMLWriter& xml)
+void cmCTestLaunch::WriteXMLCommand(cmXMLElement& e2)
{
- xml.Comment("Details of command");
- xml.StartElement("Command");
+ e2.Comment("Details of command");
+ cmXMLElement e3(e2, "Command");
if (!this->CWD.empty()) {
- xml.Element("WorkingDirectory", this->CWD);
+ e3.Element("WorkingDirectory", this->CWD);
}
- for (std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
- ai != this->RealArgs.end(); ++ai) {
- xml.Element("Argument", *ai);
+ for (std::string const& realArg : this->RealArgs) {
+ e3.Element("Argument", realArg);
}
- xml.EndElement(); // Command
}
-void cmCTestLaunch::WriteXMLResult(cmXMLWriter& xml)
+void cmCTestLaunch::WriteXMLResult(cmXMLElement& e2)
{
- xml.Comment("Result of command");
- xml.StartElement("Result");
+ e2.Comment("Result of command");
+ cmXMLElement e3(e2, "Result");
// StdOut
- xml.StartElement("StdOut");
- this->DumpFileToXML(xml, this->LogOut);
- xml.EndElement(); // StdOut
+ this->DumpFileToXML(e3, "StdOut", this->LogOut);
// StdErr
- xml.StartElement("StdErr");
- this->DumpFileToXML(xml, this->LogErr);
- xml.EndElement(); // StdErr
+ this->DumpFileToXML(e3, "StdErr", this->LogErr);
// ExitCondition
- xml.StartElement("ExitCondition");
+ cmXMLElement e4(e3, "ExitCondition");
cmsysProcess* cp = this->Process;
switch (cmsysProcess_GetState(cp)) {
case cmsysProcess_State_Starting:
- xml.Content("No process has been executed");
+ e4.Content("No process has been executed");
break;
case cmsysProcess_State_Executing:
- xml.Content("The process is still executing");
+ e4.Content("The process is still executing");
break;
case cmsysProcess_State_Disowned:
- xml.Content("Disowned");
+ e4.Content("Disowned");
break;
case cmsysProcess_State_Killed:
- xml.Content("Killed by parent");
+ e4.Content("Killed by parent");
break;
case cmsysProcess_State_Expired:
- xml.Content("Killed when timeout expired");
+ e4.Content("Killed when timeout expired");
break;
case cmsysProcess_State_Exited:
- xml.Content(this->ExitCode);
+ e4.Content(this->ExitCode);
break;
case cmsysProcess_State_Exception:
- xml.Content("Terminated abnormally: ");
- xml.Content(cmsysProcess_GetExceptionString(cp));
+ e4.Content("Terminated abnormally: ");
+ e4.Content(cmsysProcess_GetExceptionString(cp));
break;
case cmsysProcess_State_Error:
- xml.Content("Error administrating child process: ");
- xml.Content(cmsysProcess_GetErrorString(cp));
+ e4.Content("Error administrating child process: ");
+ e4.Content(cmsysProcess_GetErrorString(cp));
break;
- };
- xml.EndElement(); // ExitCondition
-
- xml.EndElement(); // Result
+ }
}
-void cmCTestLaunch::WriteXMLLabels(cmXMLWriter& xml)
+void cmCTestLaunch::WriteXMLLabels(cmXMLElement& e2)
{
this->LoadLabels();
if (!this->Labels.empty()) {
- xml.Comment("Interested parties");
- xml.StartElement("Labels");
- for (std::set<std::string>::const_iterator li = this->Labels.begin();
- li != this->Labels.end(); ++li) {
- xml.Element("Label", *li);
+ e2.Comment("Interested parties");
+ cmXMLElement e3(e2, "Labels");
+ for (std::string const& label : this->Labels) {
+ e3.Element("Label", label);
}
- xml.EndElement(); // Labels
}
}
-void cmCTestLaunch::DumpFileToXML(cmXMLWriter& xml, std::string const& fname)
+void cmCTestLaunch::DumpFileToXML(cmXMLElement& e3, const char* tag,
+ std::string const& fname)
{
cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
std::string line;
const char* sep = "";
+ cmXMLElement e4(e3, tag);
while (cmSystemTools::GetLineFromStream(fin, line)) {
if (MatchesFilterPrefix(line)) {
continue;
}
-
- xml.Content(sep);
- xml.Content(line);
+ if (this->Match(line, this->RegexWarningSuppress)) {
+ line = cmStrCat("[CTest: warning suppressed] ", line);
+ } else if (this->Match(line, this->RegexWarning)) {
+ line = cmStrCat("[CTest: warning matched] ", line);
+ }
+ e4.Content(sep);
+ e4.Content(line);
sep = "\n";
}
}
@@ -545,9 +525,9 @@ void cmCTestLaunch::LoadScrapeRules()
// Common compiler warning formats. These are much simpler than the
// full log-scraping expressions because we do not need to extract
// file and line information.
- this->RegexWarning.push_back("(^|[ :])[Ww][Aa][Rr][Nn][Ii][Nn][Gg]");
- this->RegexWarning.push_back("(^|[ :])[Rr][Ee][Mm][Aa][Rr][Kk]");
- this->RegexWarning.push_back("(^|[ :])[Nn][Oo][Tt][Ee]");
+ this->RegexWarning.emplace_back("(^|[ :])[Ww][Aa][Rr][Nn][Ii][Nn][Gg]");
+ this->RegexWarning.emplace_back("(^|[ :])[Rr][Ee][Mm][Aa][Rr][Kk]");
+ this->RegexWarning.emplace_back("(^|[ :])[Nn][Oo][Tt][Ee]");
// Load custom match rules given to us by CTest.
this->LoadScrapeRules("Warning", this->RegexWarning);
@@ -557,15 +537,12 @@ void cmCTestLaunch::LoadScrapeRules()
void cmCTestLaunch::LoadScrapeRules(
const char* purpose, std::vector<cmsys::RegularExpression>& regexps)
{
- std::string fname = this->LogDir;
- fname += "Custom";
- fname += purpose;
- fname += ".txt";
+ std::string fname = cmStrCat(this->LogDir, "Custom", purpose, ".txt");
cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
std::string line;
cmsys::RegularExpression rex;
while (cmSystemTools::GetLineFromStream(fin, line)) {
- if (rex.compile(line.c_str())) {
+ if (rex.compile(line)) {
regexps.push_back(rex);
}
}
@@ -595,9 +572,8 @@ bool cmCTestLaunch::ScrapeLog(std::string const& fname)
bool cmCTestLaunch::Match(std::string const& line,
std::vector<cmsys::RegularExpression>& regexps)
{
- for (std::vector<cmsys::RegularExpression>::iterator ri = regexps.begin();
- ri != regexps.end(); ++ri) {
- if (ri->find(line.c_str())) {
+ for (cmsys::RegularExpression& r : regexps) {
+ if (r.find(line)) {
return true;
}
}
@@ -607,7 +583,7 @@ bool cmCTestLaunch::Match(std::string const& line,
bool cmCTestLaunch::MatchesFilterPrefix(std::string const& line) const
{
return !this->OptionFilterPrefix.empty() &&
- cmSystemTools::StringStartsWith(line, this->OptionFilterPrefix.c_str());
+ cmHasPrefix(line, this->OptionFilterPrefix);
}
int cmCTestLaunch::Main(int argc, const char* const argv[])
@@ -623,17 +599,15 @@ int cmCTestLaunch::Main(int argc, const char* const argv[])
void cmCTestLaunch::LoadConfig()
{
- cmake cm(cmake::RoleScript);
+ cmake cm(cmake::RoleScript, cmState::CTest);
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm);
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
- std::string fname = this->LogDir;
- fname += "CTestLaunchConfig.cmake";
- if (cmSystemTools::FileExists(fname.c_str()) &&
- mf->ReadListFile(fname.c_str())) {
- this->SourceDir = mf->GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
+ cmMakefile mf(&gg, cm.GetCurrentSnapshot());
+ std::string fname = cmStrCat(this->LogDir, "CTestLaunchConfig.cmake");
+ if (cmSystemTools::FileExists(fname) && mf.ReadListFile(fname)) {
+ this->SourceDir = mf.GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
cmSystemTools::ConvertToUnixSlashes(this->SourceDir);
}
}
diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h
index 29986ff60..79a7712aa 100644
--- a/Source/CTest/cmCTestLaunch.h
+++ b/Source/CTest/cmCTestLaunch.h
@@ -5,12 +5,13 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmsys/RegularExpression.hxx"
#include <set>
#include <string>
#include <vector>
-class cmXMLWriter;
+#include "cmsys/RegularExpression.hxx"
+
+class cmXMLElement;
/** \class cmCTestLaunch
* \brief Launcher for make rules to report results for ctest
@@ -28,6 +29,9 @@ private:
cmCTestLaunch(int argc, const char* const* argv);
~cmCTestLaunch();
+ cmCTestLaunch(const cmCTestLaunch&) = delete;
+ cmCTestLaunch& operator=(const cmCTestLaunch&) = delete;
+
// Run the real command.
int Run();
void RunChild();
@@ -89,11 +93,11 @@ private:
// Methods to generate the xml fragment.
void WriteXML();
- void WriteXMLAction(cmXMLWriter& xml);
- void WriteXMLCommand(cmXMLWriter& xml);
- void WriteXMLResult(cmXMLWriter& xml);
- void WriteXMLLabels(cmXMLWriter& xml);
- void DumpFileToXML(cmXMLWriter& xml, std::string const& fname);
+ void WriteXMLAction(cmXMLElement&);
+ void WriteXMLCommand(cmXMLElement&);
+ void WriteXMLResult(cmXMLElement&);
+ void WriteXMLLabels(cmXMLElement&);
+ void DumpFileToXML(cmXMLElement&, const char* tag, std::string const& fname);
// Configuration
void LoadConfig();
diff --git a/Source/CTest/cmCTestMemCheckCommand.cxx b/Source/CTest/cmCTestMemCheckCommand.cxx
index b9cae3bfe..39dec6d87 100644
--- a/Source/CTest/cmCTestMemCheckCommand.cxx
+++ b/Source/CTest/cmCTestMemCheckCommand.cxx
@@ -2,26 +2,22 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestMemCheckCommand.h"
-#include <sstream>
-#include <string>
-#include <vector>
+#include "cm_static_string_view.hxx"
#include "cmCTest.h"
-#include "cmCTestGenericHandler.h"
#include "cmCTestMemCheckHandler.h"
#include "cmMakefile.h"
-cmCTestMemCheckCommand::cmCTestMemCheckCommand()
+void cmCTestMemCheckCommand::BindArguments()
{
- this->Arguments[ctm_DEFECT_COUNT] = "DEFECT_COUNT";
- this->Arguments[ctm_LAST] = CM_NULLPTR;
- this->Last = ctm_LAST;
+ this->cmCTestTestCommand::BindArguments();
+ this->Bind("DEFECT_COUNT"_s, this->DefectCount);
}
cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler()
{
- cmCTestGenericHandler* handler =
- this->CTest->GetInitializedHandler("memcheck");
+ cmCTestMemCheckHandler* handler = this->CTest->GetMemCheckHandler();
+ handler->Initialize();
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "MemoryCheckType", "CTEST_MEMORYCHECK_TYPE", this->Quiet);
@@ -45,10 +41,10 @@ cmCTestGenericHandler* cmCTestMemCheckCommand::InitializeActualHandler()
void cmCTestMemCheckCommand::ProcessAdditionalValues(
cmCTestGenericHandler* handler)
{
- if (this->Values[ctm_DEFECT_COUNT] && *this->Values[ctm_DEFECT_COUNT]) {
- std::ostringstream str;
- str << static_cast<cmCTestMemCheckHandler*>(handler)->GetDefectCount();
- this->Makefile->AddDefinition(this->Values[ctm_DEFECT_COUNT],
- str.str().c_str());
+ if (!this->DefectCount.empty()) {
+ this->Makefile->AddDefinition(
+ this->DefectCount,
+ std::to_string(
+ static_cast<cmCTestMemCheckHandler*>(handler)->GetDefectCount()));
}
}
diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h
index fa595594a..8f4ffb89a 100644
--- a/Source/CTest/cmCTestMemCheckCommand.h
+++ b/Source/CTest/cmCTestMemCheckCommand.h
@@ -3,12 +3,17 @@
#ifndef cmCTestMemCheckCommand_h
#define cmCTestMemCheckCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+#include <utility>
+
+#include <cm/memory>
#include "cmCTestTestCommand.h"
+#include "cmCommand.h"
class cmCTestGenericHandler;
-class cmCommand;
/** \class cmCTestMemCheck
* \brief Run a ctest script
@@ -18,29 +23,25 @@ class cmCommand;
class cmCTestMemCheckCommand : public cmCTestTestCommand
{
public:
- cmCTestMemCheckCommand();
-
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE
+ std::unique_ptr<cmCommand> Clone() override
{
- cmCTestMemCheckCommand* ni = new cmCTestMemCheckCommand;
+ auto ni = cm::make_unique<cmCTestMemCheckCommand>();
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
- return ni;
+ return std::unique_ptr<cmCommand>(std::move(ni));
}
protected:
- cmCTestGenericHandler* InitializeActualHandler() CM_OVERRIDE;
+ void BindArguments() override;
- void ProcessAdditionalValues(cmCTestGenericHandler* handler) CM_OVERRIDE;
+ cmCTestGenericHandler* InitializeActualHandler() override;
- enum
- {
- ctm_DEFECT_COUNT = ctt_LAST,
- ctm_LAST
- };
+ void ProcessAdditionalValues(cmCTestGenericHandler* handler) override;
+
+ std::string DefectCount;
};
#endif
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index c35f0bc70..a5ec1ae81 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -2,17 +2,21 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestMemCheckHandler.h"
-#include "cmCTest.h"
-#include "cmSystemTools.h"
-#include "cmXMLParser.h"
-#include "cmXMLWriter.h"
+#include <chrono>
+#include <cstring>
+#include <iostream>
+#include <sstream>
+#include <utility>
#include "cmsys/FStream.hxx"
#include "cmsys/Glob.hxx"
#include "cmsys/RegularExpression.hxx"
-#include <iostream>
-#include <sstream>
-#include <string.h>
+
+#include "cmCTest.h"
+#include "cmDuration.h"
+#include "cmSystemTools.h"
+#include "cmXMLParser.h"
+#include "cmXMLWriter.h"
struct CatToErrorType
{
@@ -28,14 +32,15 @@ static CatToErrorType cmCTestMemCheckBoundsChecker[] = {
{ "Allocation Conflict", cmCTestMemCheckHandler::FMM },
{ "Bad Pointer Use", cmCTestMemCheckHandler::FMW },
{ "Dangling Pointer", cmCTestMemCheckHandler::FMR },
- { CM_NULLPTR, 0 }
+ { nullptr, 0 }
};
static void xmlReportError(int line, const char* msg, void* data)
{
- cmCTest* ctest = (cmCTest*)data;
- cmCTestLog(ctest, ERROR_MESSAGE, "Error parsing XML in stream at line "
- << line << ": " << msg << std::endl);
+ cmCTest* ctest = static_cast<cmCTest*>(data);
+ cmCTestLog(ctest, ERROR_MESSAGE,
+ "Error parsing XML in stream at line " << line << ": " << msg
+ << std::endl);
}
// parse the xml file containing the results of last BoundsChecker run
@@ -45,9 +50,9 @@ public:
cmBoundsCheckerParser(cmCTest* c)
{
this->CTest = c;
- this->SetErrorCallback(xmlReportError, (void*)c);
+ this->SetErrorCallback(xmlReportError, c);
}
- void StartElement(const std::string& name, const char** atts) CM_OVERRIDE
+ void StartElement(const std::string& name, const char** atts) override
{
if (name == "MemoryLeak" || name == "ResourceLeak") {
this->Errors.push_back(cmCTestMemCheckHandler::MLK);
@@ -58,23 +63,23 @@ public:
std::ostringstream ostr;
ostr << name << ":\n";
int i = 0;
- for (; atts[i] != CM_NULLPTR; i += 2) {
+ for (; atts[i] != nullptr; i += 2) {
ostr << " " << atts[i] << " - " << atts[i + 1] << "\n";
}
ostr << "\n";
this->Log += ostr.str();
}
- void EndElement(const std::string& /*name*/) CM_OVERRIDE {}
+ void EndElement(const std::string& /*name*/) override {}
const char* GetAttribute(const char* name, const char** atts)
{
int i = 0;
- for (; atts[i] != CM_NULLPTR; ++i) {
+ for (; atts[i] != nullptr; ++i) {
if (strcmp(name, atts[i]) == 0) {
return atts[i + 1];
}
}
- return CM_NULLPTR;
+ return nullptr;
}
void ParseError(const char** atts)
{
@@ -122,11 +127,11 @@ void cmCTestMemCheckHandler::Initialize()
this->LogWithPID = false;
this->CustomMaximumPassedTestOutputSize = 0;
this->CustomMaximumFailedTestOutputSize = 0;
- this->MemoryTester = "";
+ this->MemoryTester.clear();
this->MemoryTesterDynamicOptions.clear();
this->MemoryTesterOptions.clear();
this->MemoryTesterStyle = UNKNOWN;
- this->MemoryTesterOutputFile = "";
+ this->MemoryTesterOutputFile.clear();
this->DefectCount = 0;
}
@@ -157,15 +162,13 @@ int cmCTestMemCheckHandler::PostProcessHandler()
void cmCTestMemCheckHandler::GenerateTestCommand(
std::vector<std::string>& args, int test)
{
- std::vector<std::string>::size_type pp;
std::string index;
std::ostringstream stream;
std::string memcheckcommand =
- cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str());
+ cmSystemTools::ConvertToOutputPath(this->MemoryTester);
stream << test;
index = stream.str();
- for (pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp++) {
- std::string arg = this->MemoryTesterDynamicOptions[pp];
+ for (std::string arg : this->MemoryTesterDynamicOptions) {
std::string::size_type pos = arg.find("??");
if (pos != std::string::npos) {
arg.replace(pos, 2, index);
@@ -177,21 +180,21 @@ void cmCTestMemCheckHandler::GenerateTestCommand(
}
// Create a copy of the memory tester environment variable.
// This is used for memory testing programs that pass options
- // via environment varaibles.
+ // via environment variables.
std::string memTesterEnvironmentVariable =
this->MemoryTesterEnvironmentVariable;
- for (pp = 0; pp < this->MemoryTesterOptions.size(); pp++) {
+ for (std::string const& arg : this->MemoryTesterOptions) {
if (!memTesterEnvironmentVariable.empty()) {
// If we are using env to pass options, append all the options to
// this string with space separation.
- memTesterEnvironmentVariable += " " + this->MemoryTesterOptions[pp];
+ memTesterEnvironmentVariable += " " + arg;
}
// for regular options just add them to args and memcheckcommand
// which is just used for display
else {
- args.push_back(this->MemoryTesterOptions[pp]);
+ args.push_back(arg);
memcheckcommand += " \"";
- memcheckcommand += this->MemoryTesterOptions[pp];
+ memcheckcommand += arg;
memcheckcommand += "\"";
}
}
@@ -228,9 +231,9 @@ void cmCTestMemCheckHandler::InitializeResultsVectors()
// define the standard set of errors
//----------------------------------------------------------------------
static const char* cmCTestMemCheckResultStrings[] = {
- "ABR", "ABW", "ABWL", "COR", "EXU", "FFM", "FIM", "FMM",
- "FMR", "FMW", "FUM", "IPR", "IPW", "MAF", "MLK", "MPK",
- "NPR", "ODS", "PAR", "PLK", "UMC", "UMR", CM_NULLPTR
+ "ABR", "ABW", "ABWL", "COR", "EXU", "FFM", "FIM", "FMM",
+ "FMR", "FMW", "FUM", "IPR", "IPW", "MAF", "MLK", "MPK",
+ "NPR", "ODS", "PAR", "PLK", "UMC", "UMR", nullptr
};
static const char* cmCTestMemCheckResultLongStrings[] = {
"Threading Problem",
@@ -255,12 +258,12 @@ void cmCTestMemCheckHandler::InitializeResultsVectors()
"PLK",
"Uninitialized Memory Conditional",
"Uninitialized Memory Read",
- CM_NULLPTR
+ nullptr
};
this->GlobalResults.clear();
- for (int i = 0; cmCTestMemCheckResultStrings[i] != CM_NULLPTR; ++i) {
- this->ResultStrings.push_back(cmCTestMemCheckResultStrings[i]);
- this->ResultStringsLong.push_back(cmCTestMemCheckResultLongStrings[i]);
+ for (int i = 0; cmCTestMemCheckResultStrings[i] != nullptr; ++i) {
+ this->ResultStrings.emplace_back(cmCTestMemCheckResultStrings[i]);
+ this->ResultStringsLong.emplace_back(cmCTestMemCheckResultLongStrings[i]);
this->GlobalResults.push_back(0);
}
}
@@ -291,6 +294,7 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
return;
}
this->CTest->StartXML(xml, this->AppendXML);
+ this->CTest->GenerateSubprojectsOutput(xml);
xml.StartElement("DynamicAnalysis");
switch (this->MemoryTesterStyle) {
case cmCTestMemCheckHandler::VALGRIND:
@@ -325,9 +329,8 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
xml.Element("StartTestTime", this->StartTestTime);
xml.StartElement("TestList");
cmCTestMemCheckHandler::TestResultsVector::size_type cc;
- for (cc = 0; cc < this->TestResults.size(); cc++) {
- cmCTestTestResult* result = &this->TestResults[cc];
- std::string testPath = result->Path + "/" + result->Name;
+ for (cmCTestTestResult const& result : this->TestResults) {
+ std::string testPath = result.Path + "/" + result.Name;
xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str()));
}
xml.EndElement(); // TestList
@@ -335,12 +338,12 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
"-- Processing memory checking output:\n", this->Quiet);
size_t total = this->TestResults.size();
for (cc = 0; cc < this->TestResults.size(); cc++) {
- cmCTestTestResult* result = &this->TestResults[cc];
+ cmCTestTestResult const& result = this->TestResults[cc];
std::string memcheckstr;
std::vector<int> memcheckresults(this->ResultStrings.size(), 0);
- bool res = this->ProcessMemCheckOutput(result->Output, memcheckstr,
- memcheckresults);
- if (res && result->Status == cmCTestMemCheckHandler::COMPLETED) {
+ bool res =
+ this->ProcessMemCheckOutput(result.Output, memcheckstr, memcheckresults);
+ if (res && result.Status == cmCTestMemCheckHandler::COMPLETED) {
continue;
}
this->CleanTestOutput(
@@ -363,12 +366,12 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
xml.EndElement(); // Results
if (memoryErrors > 0) {
const int maxTestNameWidth = this->CTest->GetMaxTestNameWidth();
- std::string outname = result->Name + " ";
+ std::string outname = result.Name + " ";
outname.resize(maxTestNameWidth + 4, '.');
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, cc + 1
- << "/" << total << " MemCheck: #"
- << result->TestCount << ": " << outname
- << " Defects: " << memoryErrors << std::endl,
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ cc + 1 << "/" << total << " MemCheck: #"
+ << result.TestCount << ": " << outname
+ << " Defects: " << memoryErrors << std::endl,
this->Quiet);
}
xml.StartElement("Log");
@@ -410,8 +413,10 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
xml.Element("EndDateTime", this->EndTest);
xml.Element("EndTestTime", this->EndTestTime);
- xml.Element("ElapsedMinutes",
- static_cast<int>(this->ElapsedTestingTime / 6) / 10.0);
+ xml.Element(
+ "ElapsedMinutes",
+ std::chrono::duration_cast<std::chrono::minutes>(this->ElapsedTestingTime)
+ .count());
xml.EndElement(); // DynamicAnalysis
this->CTest->EndXML(xml);
@@ -419,11 +424,11 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
bool cmCTestMemCheckHandler::InitializeMemoryChecking()
{
- this->MemoryTesterEnvironmentVariable = "";
- this->MemoryTester = "";
+ this->MemoryTesterEnvironmentVariable.clear();
+ this->MemoryTester.clear();
// Setup the command
if (cmSystemTools::FileExists(
- this->CTest->GetCTestConfiguration("MemoryCheckCommand").c_str())) {
+ this->CTest->GetCTestConfiguration("MemoryCheckCommand"))) {
this->MemoryTester =
this->CTest->GetCTestConfiguration("MemoryCheckCommand");
std::string testerName =
@@ -440,17 +445,15 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
this->MemoryTesterStyle = cmCTestMemCheckHandler::UNKNOWN;
}
} else if (cmSystemTools::FileExists(
- this->CTest->GetCTestConfiguration("PurifyCommand").c_str())) {
+ this->CTest->GetCTestConfiguration("PurifyCommand"))) {
this->MemoryTester = this->CTest->GetCTestConfiguration("PurifyCommand");
this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY;
} else if (cmSystemTools::FileExists(
- this->CTest->GetCTestConfiguration("ValgrindCommand")
- .c_str())) {
+ this->CTest->GetCTestConfiguration("ValgrindCommand"))) {
this->MemoryTester = this->CTest->GetCTestConfiguration("ValgrindCommand");
this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
} else if (cmSystemTools::FileExists(
- this->CTest->GetCTestConfiguration("BoundsCheckerCommand")
- .c_str())) {
+ this->CTest->GetCTestConfiguration("BoundsCheckerCommand"))) {
this->MemoryTester =
this->CTest->GetCTestConfiguration("BoundsCheckerCommand");
this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER;
@@ -518,7 +521,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
this->CTest->GetCTestConfiguration("ValgrindCommandOptions");
}
this->MemoryTesterOptions =
- cmSystemTools::ParseArguments(memoryTesterOptions.c_str());
+ cmSystemTools::ParseArguments(memoryTesterOptions);
this->MemoryTesterOutputFile =
this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.??.log";
@@ -526,17 +529,16 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
switch (this->MemoryTesterStyle) {
case cmCTestMemCheckHandler::VALGRIND: {
if (this->MemoryTesterOptions.empty()) {
- this->MemoryTesterOptions.push_back("-q");
- this->MemoryTesterOptions.push_back("--tool=memcheck");
- this->MemoryTesterOptions.push_back("--leak-check=yes");
- this->MemoryTesterOptions.push_back("--show-reachable=yes");
- this->MemoryTesterOptions.push_back("--num-callers=50");
+ this->MemoryTesterOptions.emplace_back("-q");
+ this->MemoryTesterOptions.emplace_back("--tool=memcheck");
+ this->MemoryTesterOptions.emplace_back("--leak-check=yes");
+ this->MemoryTesterOptions.emplace_back("--show-reachable=yes");
+ this->MemoryTesterOptions.emplace_back("--num-callers=50");
}
if (!this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
.empty()) {
- if (!cmSystemTools::FileExists(
- this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
- .c_str())) {
+ if (!cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
+ "MemoryCheckSuppressionFile"))) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find memory checker suppression file: "
<< this->CTest->GetCTestConfiguration(
@@ -544,12 +546,12 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
<< std::endl);
return false;
}
- std::string suppressions = "--suppressions=" +
- this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile");
- this->MemoryTesterOptions.push_back(suppressions);
+ this->MemoryTesterOptions.push_back(
+ "--suppressions=" +
+ this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"));
}
- std::string outputFile = "--log-file=" + this->MemoryTesterOutputFile;
- this->MemoryTesterDynamicOptions.push_back(outputFile);
+ this->MemoryTesterDynamicOptions.push_back("--log-file=" +
+ this->MemoryTesterOutputFile);
break;
}
case cmCTestMemCheckHandler::PURIFY: {
@@ -557,9 +559,8 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
#ifdef _WIN32
if (this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
.size()) {
- if (!cmSystemTools::FileExists(
- this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile")
- .c_str())) {
+ if (!cmSystemTools::FileExists(this->CTest->GetCTestConfiguration(
+ "MemoryCheckSuppressionFile"))) {
cmCTestLog(
this->CTest, ERROR_MESSAGE,
"Cannot find memory checker suppression file: "
@@ -586,11 +587,11 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
std::string dpbdFile = this->CTest->GetBinaryDir() +
"/Testing/Temporary/MemoryChecker.??.DPbd";
this->BoundsCheckerDPBDFile = dpbdFile;
- this->MemoryTesterDynamicOptions.push_back("/B");
- this->MemoryTesterDynamicOptions.push_back(dpbdFile);
- this->MemoryTesterDynamicOptions.push_back("/X");
+ this->MemoryTesterDynamicOptions.emplace_back("/B");
+ this->MemoryTesterDynamicOptions.push_back(std::move(dpbdFile));
+ this->MemoryTesterDynamicOptions.emplace_back("/X");
this->MemoryTesterDynamicOptions.push_back(this->MemoryTesterOutputFile);
- this->MemoryTesterOptions.push_back("/M");
+ this->MemoryTesterOptions.emplace_back("/M");
break;
}
// these are almost the same but the env var used is different
@@ -604,8 +605,8 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
// The MemoryTesterDynamicOptions is setup with the -E env
// Then the MemoryTesterEnvironmentVariable gets the
// TSAN_OPTIONS string with the log_path in it.
- this->MemoryTesterDynamicOptions.push_back("-E");
- this->MemoryTesterDynamicOptions.push_back("env");
+ this->MemoryTesterDynamicOptions.emplace_back("-E");
+ this->MemoryTesterDynamicOptions.emplace_back("env");
std::string envVar;
std::string extraOptions;
std::string suppressionsOption;
@@ -725,15 +726,14 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
cmsys::RegularExpression leakWarning("(Direct|Indirect) leak of .*");
int defects = 0;
std::vector<std::string> lines;
- cmSystemTools::Split(str.c_str(), lines);
+ cmsys::SystemTools::Split(str, lines);
std::ostringstream ostr;
- log = "";
- for (std::vector<std::string>::iterator i = lines.begin(); i != lines.end();
- ++i) {
+ log.clear();
+ for (std::string const& l : lines) {
std::string resultFound;
- if (leakWarning.find(*i)) {
+ if (leakWarning.find(l)) {
resultFound = leakWarning.match(1) + " leak";
- } else if (sanitizerWarning.find(*i)) {
+ } else if (sanitizerWarning.find(l)) {
resultFound = sanitizerWarning.match(1);
}
if (!resultFound.empty()) {
@@ -746,7 +746,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
defects++;
ostr << "<b>" << this->ResultStrings[idx] << "</b> ";
}
- ostr << *i << std::endl;
+ ostr << l << std::endl;
}
log = ostr.str();
this->DefectCount += defects;
@@ -756,18 +756,17 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
const std::string& str, std::string& log, std::vector<int>& results)
{
std::vector<std::string> lines;
- cmSystemTools::Split(str.c_str(), lines);
+ cmsys::SystemTools::Split(str, lines);
std::ostringstream ostr;
- log = "";
+ log.clear();
cmsys::RegularExpression pfW("^\\[[WEI]\\] ([A-Z][A-Z][A-Z][A-Z]*): ");
int defects = 0;
- for (std::vector<std::string>::iterator i = lines.begin(); i != lines.end();
- ++i) {
+ for (std::string const& l : lines) {
std::vector<int>::size_type failure = this->ResultStrings.size();
- if (pfW.find(*i)) {
+ if (pfW.find(l)) {
std::vector<int>::size_type cc;
for (cc = 0; cc < this->ResultStrings.size(); cc++) {
if (pfW.match(1) == this->ResultStrings[cc]) {
@@ -776,8 +775,9 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
}
}
if (cc == this->ResultStrings.size()) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown Purify memory fault: "
- << pfW.match(1) << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unknown Purify memory fault: " << pfW.match(1)
+ << std::endl);
ostr << "*** Unknown Purify memory fault: " << pfW.match(1)
<< std::endl;
}
@@ -787,7 +787,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
results[failure]++;
defects++;
}
- ostr << *i << std::endl;
+ ostr << l << std::endl;
}
log = ostr.str();
@@ -799,7 +799,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
const std::string& str, std::string& log, std::vector<int>& results)
{
std::vector<std::string> lines;
- cmSystemTools::Split(str.c_str(), lines);
+ cmsys::SystemTools::Split(str, lines);
bool unlimitedOutput = false;
if (str.find("CTEST_FULL_OUTPUT") != std::string::npos ||
this->CustomMaximumFailedTestOutputSize == 0) {
@@ -809,16 +809,16 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
std::string::size_type cc;
std::ostringstream ostr;
- log = "";
+ log.clear();
int defects = 0;
cmsys::RegularExpression valgrindLine("^==[0-9][0-9]*==");
cmsys::RegularExpression vgFIM(
- "== .*Invalid free\\(\\) / delete / delete\\[\\]");
+ R"(== .*Invalid free\(\) / delete / delete\[\])");
cmsys::RegularExpression vgFMM(
- "== .*Mismatched free\\(\\) / delete / delete \\[\\]");
+ R"(== .*Mismatched free\(\) / delete / delete \[\])");
cmsys::RegularExpression vgMLK1(
"== .*[0-9,]+ bytes in [0-9,]+ blocks are definitely lost"
" in loss record [0-9,]+ of [0-9,]+");
@@ -848,7 +848,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is "
"locked by a different thread");
std::vector<std::string::size_type> nonValGrindOutput;
- double sttime = cmSystemTools::GetTime();
+ auto sttime = std::chrono::steady_clock::now();
cmCTestOptionalLog(this->CTest, DEBUG,
"Start test: " << lines.size() << std::endl, this->Quiet);
std::string::size_type totalOutputSize = 0;
@@ -907,11 +907,9 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
// Now put all all the non valgrind output into the test output
// This should be last in case it gets truncated by the output
// limiting code
- for (std::vector<std::string::size_type>::iterator i =
- nonValGrindOutput.begin();
- i != nonValGrindOutput.end(); ++i) {
- totalOutputSize += lines[*i].size();
- ostr << lines[*i] << std::endl;
+ for (std::string::size_type i : nonValGrindOutput) {
+ totalOutputSize += lines[i].size();
+ ostr << lines[i] << std::endl;
if (!unlimitedOutput &&
totalOutputSize >
static_cast<size_t>(this->CustomMaximumFailedTestOutputSize)) {
@@ -923,8 +921,11 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
break; // stop the copy of output if we are full
}
}
- cmCTestOptionalLog(this->CTest, DEBUG, "End test (elapsed: "
- << (cmSystemTools::GetTime() - sttime) << std::endl,
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "End test (elapsed: "
+ << cmDurationTo<unsigned int>(
+ std::chrono::steady_clock::now() - sttime)
+ << "s)" << std::endl,
this->Quiet);
log = ostr.str();
this->DefectCount += defects;
@@ -934,10 +935,10 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
const std::string& str, std::string& log, std::vector<int>& results)
{
- log = "";
- double sttime = cmSystemTools::GetTime();
+ log.clear();
+ auto sttime = std::chrono::steady_clock::now();
std::vector<std::string> lines;
- cmSystemTools::Split(str.c_str(), lines);
+ cmsys::SystemTools::Split(str, lines);
cmCTestOptionalLog(this->CTest, DEBUG,
"Start test: " << lines.size() << std::endl, this->Quiet);
std::vector<std::string>::size_type cc;
@@ -962,12 +963,15 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
}
}
int defects = 0;
- for (cc = 0; cc < parser.Errors.size(); ++cc) {
- results[parser.Errors[cc]]++;
+ for (int err : parser.Errors) {
+ results[err]++;
defects++;
}
- cmCTestOptionalLog(this->CTest, DEBUG, "End test (elapsed: "
- << (cmSystemTools::GetTime() - sttime) << std::endl,
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "End test (elapsed: "
+ << cmDurationTo<unsigned int>(
+ std::chrono::steady_clock::now() - sttime)
+ << "s)" << std::endl,
this->Quiet);
if (defects) {
// only put the output of Bounds Checker if there were
@@ -990,9 +994,8 @@ void cmCTestMemCheckHandler::PostProcessTest(cmCTestTestResult& res, int test)
} else {
std::vector<std::string> files;
this->TestOutputFileNames(test, files);
- for (std::vector<std::string>::iterator i = files.begin();
- i != files.end(); ++i) {
- this->AppendMemTesterOutput(res, *i);
+ for (std::string const& f : files) {
+ this->AppendMemTesterOutput(res, f);
}
}
}
@@ -1072,10 +1075,7 @@ void cmCTestMemCheckHandler::AppendMemTesterOutput(cmCTestTestResult& res,
void cmCTestMemCheckHandler::TestOutputFileNames(
int test, std::vector<std::string>& files)
{
- std::string index;
- std::ostringstream stream;
- stream << test;
- index = stream.str();
+ std::string index = std::to_string(test);
std::string ofile = this->MemoryTesterOutputFile;
std::string::size_type pos = ofile.find("??");
ofile.replace(pos, 2, index);
@@ -1085,16 +1085,16 @@ void cmCTestMemCheckHandler::TestOutputFileNames(
g.FindFiles(ofile);
if (g.GetFiles().empty()) {
std::string log = "Cannot find memory tester output file: " + ofile;
- cmCTestLog(this->CTest, ERROR_MESSAGE, log << std::endl);
- ofile = "";
+ cmCTestLog(this->CTest, WARNING, log << std::endl);
+ ofile.clear();
} else {
files = g.GetFiles();
return;
}
- } else if (!cmSystemTools::FileExists(ofile.c_str())) {
+ } else if (!cmSystemTools::FileExists(ofile)) {
std::string log = "Cannot find memory tester output file: " + ofile;
- cmCTestLog(this->CTest, ERROR_MESSAGE, log << std::endl);
- ofile = "";
+ cmCTestLog(this->CTest, WARNING, log << std::endl);
+ ofile.clear();
}
- files.push_back(ofile);
+ files.push_back(std::move(ofile));
}
diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h
index 333c2e2dd..eda65f7b9 100644
--- a/Source/CTest/cmCTestMemCheckHandler.h
+++ b/Source/CTest/cmCTestMemCheckHandler.h
@@ -3,13 +3,13 @@
#ifndef cmCTestMemCheckHandler_h
#define cmCTestMemCheckHandler_h
-#include "cmConfigure.h"
-
-#include "cmCTestTestHandler.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
+#include "cmCTestTestHandler.h"
+
class cmMakefile;
class cmXMLWriter;
@@ -22,21 +22,20 @@ class cmCTestMemCheckHandler : public cmCTestTestHandler
friend class cmCTestRunTest;
public:
- typedef cmCTestTestHandler Superclass;
+ using Superclass = cmCTestTestHandler;
- void PopulateCustomVectors(cmMakefile* mf) CM_OVERRIDE;
+ void PopulateCustomVectors(cmMakefile* mf) override;
cmCTestMemCheckHandler();
- void Initialize() CM_OVERRIDE;
+ void Initialize() override;
int GetDefectCount();
protected:
- int PreProcessHandler() CM_OVERRIDE;
- int PostProcessHandler() CM_OVERRIDE;
- void GenerateTestCommand(std::vector<std::string>& args,
- int test) CM_OVERRIDE;
+ int PreProcessHandler() override;
+ int PostProcessHandler() override;
+ void GenerateTestCommand(std::vector<std::string>& args, int test) override;
private:
enum
@@ -115,20 +114,20 @@ private:
// this type of checker
void InitializeResultsVectors();
- ///! Initialize memory checking subsystem.
+ //! Initialize memory checking subsystem.
bool InitializeMemoryChecking();
/**
* Generate the Dart compatible output
*/
- void GenerateDartOutput(cmXMLWriter& xml) CM_OVERRIDE;
+ void GenerateDartOutput(cmXMLWriter& xml) override;
std::vector<std::string> CustomPreMemCheck;
std::vector<std::string> CustomPostMemCheck;
//! Parse Valgrind/Purify/Bounds Checker result out of the output
// string. After running, log holds the output and results hold the
- // different memmory errors.
+ // different memory errors.
bool ProcessMemCheckOutput(const std::string& str, std::string& log,
std::vector<int>& results);
bool ProcessMemCheckValgrindOutput(const std::string& str, std::string& log,
@@ -144,11 +143,11 @@ private:
void PostProcessTest(cmCTestTestResult& res, int test);
void PostProcessBoundsCheckerTest(cmCTestTestResult& res, int test);
- ///! append MemoryTesterOutputFile to the test log
+ //! append MemoryTesterOutputFile to the test log
void AppendMemTesterOutput(cmCTestTestHandler::cmCTestTestResult& res,
std::string const& filename);
- ///! generate the output filename for the given test index
+ //! generate the output filename for the given test index
void TestOutputFileNames(int test, std::vector<std::string>& files);
};
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 2c16a0d1e..02d396ebd 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -2,24 +2,47 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestMultiProcessHandler.h"
-#include "cmCTest.h"
-#include "cmCTestRunTest.h"
-#include "cmCTestScriptHandler.h"
-#include "cmCTestTestHandler.h"
-#include "cmSystemTools.h"
-#include "cmWorkingDirectory.h"
-
-#include "cmsys/FStream.hxx"
-#include "cmsys/String.hxx"
-#include "cmsys/SystemInformation.hxx"
#include <algorithm>
+#include <cassert>
+#include <chrono>
+#include <cmath>
+#include <cstddef>
+#include <cstdlib>
+#include <cstring>
#include <iomanip>
+#include <iostream>
#include <list>
-#include <math.h>
+#include <memory>
#include <sstream>
#include <stack>
-#include <stdlib.h>
+#include <unordered_map>
#include <utility>
+#include <vector>
+
+#include "cmsys/FStream.hxx"
+#include "cmsys/SystemInformation.hxx"
+
+#include "cm_jsoncpp_value.h"
+#include "cm_jsoncpp_writer.h"
+#include "cm_uv.h"
+
+#include "cmAffinity.h"
+#include "cmAlgorithms.h"
+#include "cmCTest.h"
+#include "cmCTestBinPacker.h"
+#include "cmCTestRunTest.h"
+#include "cmCTestTestHandler.h"
+#include "cmDuration.h"
+#include "cmListFileCache.h"
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmUVSignalHackRAII.h" // IWYU pragma: keep
+#include "cmWorkingDirectory.h"
+
+namespace cmsys {
+class RegularExpression;
+}
class TestComparator
{
@@ -28,7 +51,6 @@ public:
: Handler(handler)
{
}
- ~TestComparator() {}
// Sorts tests in descending order of cost
bool operator()(int index1, int index2) const
@@ -45,16 +67,16 @@ cmCTestMultiProcessHandler::cmCTestMultiProcessHandler()
{
this->ParallelLevel = 1;
this->TestLoad = 0;
+ this->FakeLoadForTesting = 0;
this->Completed = 0;
this->RunningCount = 0;
- this->StopTimePassed = false;
+ this->ProcessorsAvailable = cmAffinity::GetProcessorsAvailable();
+ this->HaveAffinity = this->ProcessorsAvailable.size();
this->HasCycles = false;
this->SerialTestRunning = false;
}
-cmCTestMultiProcessHandler::~cmCTestMultiProcessHandler()
-{
-}
+cmCTestMultiProcessHandler::~cmCTestMultiProcessHandler() = default;
// Set the tests
void cmCTestMultiProcessHandler::SetTests(TestMap& tests,
@@ -64,10 +86,9 @@ void cmCTestMultiProcessHandler::SetTests(TestMap& tests,
this->Properties = properties;
this->Total = this->Tests.size();
// set test run map to false for all
- for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
- ++i) {
- this->TestRunningMap[i->first] = false;
- this->TestFinishMap[i->first] = false;
+ for (auto const& t : this->Tests) {
+ this->TestRunningMap[t.first] = false;
+ this->TestFinishMap[t.first] = false;
}
if (!this->CTest->GetShowOnly()) {
this->ReadCostData();
@@ -88,6 +109,15 @@ void cmCTestMultiProcessHandler::SetParallelLevel(size_t level)
void cmCTestMultiProcessHandler::SetTestLoad(unsigned long load)
{
this->TestLoad = load;
+
+ std::string fake_load_value;
+ if (cmSystemTools::GetEnv("__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING",
+ fake_load_value)) {
+ if (!cmStrToULong(fake_load_value, &this->FakeLoadForTesting)) {
+ cmSystemTools::Error("Failed to parse fake load value: " +
+ fake_load_value);
+ }
+ }
}
void cmCTestMultiProcessHandler::RunTests()
@@ -96,24 +126,43 @@ void cmCTestMultiProcessHandler::RunTests()
if (this->HasCycles) {
return;
}
+#ifdef CMAKE_UV_SIGNAL_HACK
+ cmUVSignalHackRAII hackRAII;
+#endif
this->TestHandler->SetMaxIndex(this->FindMaxIndex());
+
+ uv_loop_init(&this->Loop);
this->StartNextTests();
- while (!this->Tests.empty()) {
- if (this->StopTimePassed) {
- return;
- }
- this->CheckOutput();
- this->StartNextTests();
- }
- // let all running tests finish
- while (this->CheckOutput()) {
+ uv_run(&this->Loop, UV_RUN_DEFAULT);
+ uv_loop_close(&this->Loop);
+
+ if (!this->StopTimePassed) {
+ assert(this->Completed == this->Total);
+ assert(this->Tests.empty());
}
+ assert(this->AllResourcesAvailable());
+
this->MarkFinished();
this->UpdateCostData();
}
-void cmCTestMultiProcessHandler::StartTestProcess(int test)
+bool cmCTestMultiProcessHandler::StartTestProcess(int test)
{
+ if (this->HaveAffinity && this->Properties[test]->WantAffinity) {
+ size_t needProcessors = this->GetProcessorsUsed(test);
+ if (needProcessors > this->ProcessorsAvailable.size()) {
+ return false;
+ }
+ std::vector<size_t> affinity;
+ affinity.reserve(needProcessors);
+ for (size_t i = 0; i < needProcessors; ++i) {
+ auto p = this->ProcessorsAvailable.begin();
+ affinity.push_back(*p);
+ this->ProcessorsAvailable.erase(p);
+ }
+ this->Properties[test]->Affinity = std::move(affinity);
+ }
+
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"test " << test << "\n", this->Quiet);
this->TestRunningMap[test] = true; // mark the test as running
@@ -121,52 +170,179 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
this->EraseTest(test);
this->RunningCount += GetProcessorsUsed(test);
- cmCTestRunTest* testRun = new cmCTestRunTest(this->TestHandler);
+ cmCTestRunTest* testRun = new cmCTestRunTest(*this);
if (this->CTest->GetRepeatUntilFail()) {
testRun->SetRunUntilFailOn();
testRun->SetNumberOfRuns(this->CTest->GetTestRepeat());
}
testRun->SetIndex(test);
testRun->SetTestProperties(this->Properties[test]);
+ if (this->TestHandler->UseResourceSpec) {
+ testRun->SetUseAllocatedResources(true);
+ testRun->SetAllocatedResources(this->AllocatedResources[test]);
+ }
// Find any failed dependencies for this test. We assume the more common
// scenario has no failed tests, so make it the outer loop.
- for (std::vector<std::string>::const_iterator it = this->Failed->begin();
- it != this->Failed->end(); ++it) {
- if (this->Properties[test]->RequireSuccessDepends.find(*it) !=
- this->Properties[test]->RequireSuccessDepends.end()) {
- testRun->AddFailedDependency(*it);
+ for (std::string const& f : *this->Failed) {
+ if (cmContains(this->Properties[test]->RequireSuccessDepends, f)) {
+ testRun->AddFailedDependency(f);
}
}
+ // Always lock the resources we'll be using, even if we fail to set the
+ // working directory because FinishTestProcess() will try to unlock them
+ this->LockResources(test);
+
+ if (!this->TestsHaveSufficientResources[test]) {
+ testRun->StartFailure("Insufficient resources");
+ this->FinishTestProcess(testRun, false);
+ return false;
+ }
+
cmWorkingDirectory workdir(this->Properties[test]->Directory);
+ if (workdir.Failed()) {
+ testRun->StartFailure("Failed to change working directory to " +
+ this->Properties[test]->Directory + " : " +
+ std::strerror(workdir.GetLastResult()));
+ } else {
+ if (testRun->StartTest(this->Completed, this->Total)) {
+ // Ownership of 'testRun' has moved to another structure.
+ // When the test finishes, FinishTestProcess will be called.
+ return true;
+ }
+ }
- // Lock the resources we'll be using
- this->LockResources(test);
+ // Pass ownership of 'testRun'.
+ this->FinishTestProcess(testRun, false);
+ return false;
+}
- if (testRun->StartTest(this->Total)) {
- this->RunningTests.insert(testRun);
- } else if (testRun->IsStopTimePassed()) {
- this->StopTimePassed = true;
- delete testRun;
+bool cmCTestMultiProcessHandler::AllocateResources(int index)
+{
+ if (!this->TestHandler->UseResourceSpec) {
+ return true;
+ }
+
+ std::map<std::string, std::vector<cmCTestBinPackerAllocation>> allocations;
+ if (!this->TryAllocateResources(index, allocations)) {
+ return false;
+ }
+
+ auto& allocatedResources = this->AllocatedResources[index];
+ allocatedResources.resize(this->Properties[index]->ResourceGroups.size());
+ for (auto const& it : allocations) {
+ for (auto const& alloc : it.second) {
+ bool result = this->ResourceAllocator.AllocateResource(
+ it.first, alloc.Id, alloc.SlotsNeeded);
+ (void)result;
+ assert(result);
+ allocatedResources[alloc.ProcessIndex][it.first].push_back(
+ { alloc.Id, static_cast<unsigned int>(alloc.SlotsNeeded) });
+ }
+ }
+
+ return true;
+}
+
+bool cmCTestMultiProcessHandler::TryAllocateResources(
+ int index,
+ std::map<std::string, std::vector<cmCTestBinPackerAllocation>>& allocations)
+{
+ allocations.clear();
+
+ std::size_t processIndex = 0;
+ for (auto const& process : this->Properties[index]->ResourceGroups) {
+ for (auto const& requirement : process) {
+ for (int i = 0; i < requirement.UnitsNeeded; ++i) {
+ allocations[requirement.ResourceType].push_back(
+ { processIndex, requirement.SlotsNeeded, "" });
+ }
+ }
+ ++processIndex;
+ }
+
+ auto const& availableResources = this->ResourceAllocator.GetResources();
+ for (auto& it : allocations) {
+ if (!availableResources.count(it.first)) {
+ return false;
+ }
+ if (!cmAllocateCTestResourcesRoundRobin(availableResources.at(it.first),
+ it.second)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void cmCTestMultiProcessHandler::DeallocateResources(int index)
+{
+ if (!this->TestHandler->UseResourceSpec) {
return;
- } else {
+ }
- for (TestMap::iterator j = this->Tests.begin(); j != this->Tests.end();
- ++j) {
- j->second.erase(test);
+ {
+ auto& allocatedResources = this->AllocatedResources[index];
+ for (auto const& processAlloc : allocatedResources) {
+ for (auto const& it : processAlloc) {
+ auto resourceType = it.first;
+ for (auto const& it2 : it.second) {
+ bool success = this->ResourceAllocator.DeallocateResource(
+ resourceType, it2.Id, it2.Slots);
+ (void)success;
+ assert(success);
+ }
+ }
}
+ }
+ this->AllocatedResources.erase(index);
+}
- this->UnlockResources(test);
- this->Completed++;
- this->TestFinishMap[test] = true;
- this->TestRunningMap[test] = false;
- this->RunningCount -= GetProcessorsUsed(test);
- testRun->EndTest(this->Completed, this->Total, false);
- if (!this->Properties[test]->Disabled) {
- this->Failed->push_back(this->Properties[test]->Name);
+bool cmCTestMultiProcessHandler::AllResourcesAvailable()
+{
+ for (auto const& it : this->ResourceAllocator.GetResources()) {
+ for (auto const& it2 : it.second) {
+ if (it2.second.Locked != 0) {
+ return false;
+ }
}
- delete testRun;
+ }
+
+ return true;
+}
+
+void cmCTestMultiProcessHandler::CheckResourcesAvailable()
+{
+ for (auto test : this->SortedTests) {
+ std::map<std::string, std::vector<cmCTestBinPackerAllocation>> allocations;
+ this->TestsHaveSufficientResources[test] =
+ !this->TestHandler->UseResourceSpec ||
+ this->TryAllocateResources(test, allocations);
+ }
+}
+
+bool cmCTestMultiProcessHandler::CheckStopTimePassed()
+{
+ if (!this->StopTimePassed) {
+ std::chrono::system_clock::time_point stop_time =
+ this->CTest->GetStopTime();
+ if (stop_time != std::chrono::system_clock::time_point() &&
+ stop_time <= std::chrono::system_clock::now()) {
+ this->SetStopTimePassed();
+ }
+ }
+ return this->StopTimePassed;
+}
+
+void cmCTestMultiProcessHandler::SetStopTimePassed()
+{
+ if (!this->StopTimePassed) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "The stop time has been passed. "
+ "Stopping all tests."
+ << std::endl);
+ this->StopTimePassed = true;
}
}
@@ -183,10 +359,8 @@ void cmCTestMultiProcessHandler::LockResources(int index)
void cmCTestMultiProcessHandler::UnlockResources(int index)
{
- for (std::set<std::string>::iterator i =
- this->Properties[index]->LockedResources.begin();
- i != this->Properties[index]->LockedResources.end(); ++i) {
- this->LockedResources.erase(*i);
+ for (std::string const& i : this->Properties[index]->LockedResources) {
+ this->LockedResources.erase(i);
}
if (this->Properties[index]->RunSerial) {
this->SerialTestRunning = false;
@@ -208,6 +382,11 @@ inline size_t cmCTestMultiProcessHandler::GetProcessorsUsed(int test)
if (processors > this->ParallelLevel) {
processors = this->ParallelLevel;
}
+ // Cap tests that want affinity to the maximum affinity available.
+ if (this->HaveAffinity && processors > this->HaveAffinity &&
+ this->Properties[test]->WantAffinity) {
+ processors = this->HaveAffinity;
+ }
return processors;
}
@@ -219,27 +398,48 @@ std::string cmCTestMultiProcessHandler::GetName(int test)
bool cmCTestMultiProcessHandler::StartTest(int test)
{
// Check for locked resources
- for (std::set<std::string>::iterator i =
- this->Properties[test]->LockedResources.begin();
- i != this->Properties[test]->LockedResources.end(); ++i) {
- if (this->LockedResources.find(*i) != this->LockedResources.end()) {
+ for (std::string const& i : this->Properties[test]->LockedResources) {
+ if (cmContains(this->LockedResources, i)) {
return false;
}
}
+ // Allocate resources
+ if (this->TestsHaveSufficientResources[test] &&
+ !this->AllocateResources(test)) {
+ this->DeallocateResources(test);
+ return false;
+ }
+
// if there are no depends left then run this test
if (this->Tests[test].empty()) {
- this->StartTestProcess(test);
- return true;
+ return this->StartTestProcess(test);
}
// This test was not able to start because it is waiting
// on depends to run
+ this->DeallocateResources(test);
return false;
}
void cmCTestMultiProcessHandler::StartNextTests()
{
+ if (this->TestLoadRetryTimer.get() != nullptr) {
+ // This timer may be waiting to call StartNextTests again.
+ // Since we have been called it is no longer needed.
+ uv_timer_stop(this->TestLoadRetryTimer);
+ }
+
+ if (this->Tests.empty()) {
+ this->TestLoadRetryTimer.reset();
+ return;
+ }
+
+ if (this->CheckStopTimePassed()) {
+ return;
+ }
+
size_t numToStart = 0;
+
if (this->RunningCount < this->ParallelLevel) {
numToStart = this->ParallelLevel - this->RunningCount;
}
@@ -255,7 +455,6 @@ void cmCTestMultiProcessHandler::StartNextTests()
}
bool allTestsFailedTestLoadCheck = false;
- bool usedFakeLoadForTesting = false;
size_t minProcessorsRequired = this->ParallelLevel;
std::string testWithMinProcessors;
@@ -268,15 +467,11 @@ void cmCTestMultiProcessHandler::StartNextTests()
allTestsFailedTestLoadCheck = true;
// Check for a fake load average value used in testing.
- std::string fake_load_value;
- if (cmSystemTools::GetEnv("__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING",
- fake_load_value)) {
- usedFakeLoadForTesting = true;
- if (!cmSystemTools::StringToULong(fake_load_value.c_str(),
- &systemLoad)) {
- cmSystemTools::Error("Failed to parse fake load value: ",
- fake_load_value.c_str());
- }
+ if (this->FakeLoadForTesting > 0) {
+ systemLoad = this->FakeLoadForTesting;
+ // Drop the fake load for the next iteration to a value low enough
+ // that the next iteration will start tests.
+ this->FakeLoadForTesting = 1;
}
// If it's not set, look up the true load average.
else {
@@ -292,24 +487,24 @@ void cmCTestMultiProcessHandler::StartNextTests()
}
TestList copy = this->SortedTests;
- for (TestList::iterator test = copy.begin(); test != copy.end(); ++test) {
+ for (auto const& test : copy) {
// Take a nap if we're currently performing a RUN_SERIAL test.
if (this->SerialTestRunning) {
break;
}
// We can only start a RUN_SERIAL test if no other tests are also running.
- if (this->Properties[*test]->RunSerial && this->RunningCount > 0) {
+ if (this->Properties[test]->RunSerial && this->RunningCount > 0) {
continue;
}
- size_t processors = GetProcessorsUsed(*test);
+ size_t processors = GetProcessorsUsed(test);
bool testLoadOk = true;
if (this->TestLoad > 0) {
if (processors <= spareLoad) {
- cmCTestLog(this->CTest, DEBUG, "OK to run "
- << GetName(*test) << ", it requires " << processors
- << " procs & system load is: " << systemLoad
- << std::endl);
+ cmCTestLog(this->CTest, DEBUG,
+ "OK to run " << GetName(test) << ", it requires "
+ << processors << " procs & system load is: "
+ << systemLoad << std::endl);
allTestsFailedTestLoadCheck = false;
} else {
testLoadOk = false;
@@ -318,14 +513,10 @@ void cmCTestMultiProcessHandler::StartNextTests()
if (processors <= minProcessorsRequired) {
minProcessorsRequired = processors;
- testWithMinProcessors = GetName(*test);
+ testWithMinProcessors = GetName(test);
}
- if (testLoadOk && processors <= numToStart && this->StartTest(*test)) {
- if (this->StopTimePassed) {
- return;
- }
-
+ if (testLoadOk && processors <= numToStart && this->StartTest(test)) {
numToStart -= processors;
} else if (numToStart == 0) {
break;
@@ -333,10 +524,22 @@ void cmCTestMultiProcessHandler::StartNextTests()
}
if (allTestsFailedTestLoadCheck) {
+ // Find out whether there are any non RUN_SERIAL tests left, so that the
+ // correct warning may be displayed.
+ bool onlyRunSerialTestsLeft = true;
+ for (auto const& test : copy) {
+ if (!this->Properties[test]->RunSerial) {
+ onlyRunSerialTestsLeft = false;
+ }
+ }
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***** WAITING, ");
+
if (this->SerialTestRunning) {
cmCTestLog(this->CTest, HANDLER_OUTPUT,
"Waiting for RUN_SERIAL test to finish.");
+ } else if (onlyRunSerialTestsLeft) {
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ "Only RUN_SERIAL tests remain, awaiting available slot.");
} else {
/* clang-format off */
cmCTestLog(this->CTest, HANDLER_OUTPUT,
@@ -348,63 +551,70 @@ void cmCTestMultiProcessHandler::StartNextTests()
}
cmCTestLog(this->CTest, HANDLER_OUTPUT, "*****" << std::endl);
- if (usedFakeLoadForTesting) {
- // Break out of the infinite loop of waiting for our fake load
- // to come down.
- this->StopTimePassed = true;
- } else {
- // Wait between 1 and 5 seconds before trying again.
- cmCTestScriptHandler::SleepInSeconds(cmSystemTools::RandomSeed() % 5 +
- 1);
+ // Wait between 1 and 5 seconds before trying again.
+ unsigned int milliseconds = (cmSystemTools::RandomSeed() % 5 + 1) * 1000;
+ if (this->FakeLoadForTesting) {
+ milliseconds = 10;
}
+ if (this->TestLoadRetryTimer.get() == nullptr) {
+ this->TestLoadRetryTimer.init(this->Loop, this);
+ }
+ this->TestLoadRetryTimer.start(
+ &cmCTestMultiProcessHandler::OnTestLoadRetryCB, milliseconds, 0);
}
}
-bool cmCTestMultiProcessHandler::CheckOutput()
+void cmCTestMultiProcessHandler::OnTestLoadRetryCB(uv_timer_t* timer)
{
- // no more output we are done
- if (this->RunningTests.empty()) {
- return false;
+ auto self = static_cast<cmCTestMultiProcessHandler*>(timer->data);
+ self->StartNextTests();
+}
+
+void cmCTestMultiProcessHandler::FinishTestProcess(cmCTestRunTest* runner,
+ bool started)
+{
+ this->Completed++;
+
+ int test = runner->GetIndex();
+ auto properties = runner->GetTestProperties();
+
+ bool testResult = runner->EndTest(this->Completed, this->Total, started);
+ if (runner->TimedOutForStopTime()) {
+ this->SetStopTimePassed();
}
- std::vector<cmCTestRunTest*> finished;
- std::string out, err;
- for (std::set<cmCTestRunTest*>::const_iterator i =
- this->RunningTests.begin();
- i != this->RunningTests.end(); ++i) {
- cmCTestRunTest* p = *i;
- if (!p->CheckOutput()) {
- finished.push_back(p);
+ if (started) {
+ if (!this->StopTimePassed && runner->StartAgain(this->Completed)) {
+ this->Completed--; // remove the completed test because run again
+ return;
}
}
- for (std::vector<cmCTestRunTest*>::iterator i = finished.begin();
- i != finished.end(); ++i) {
- this->Completed++;
- cmCTestRunTest* p = *i;
- int test = p->GetIndex();
- bool testResult = p->EndTest(this->Completed, this->Total, true);
- if (p->StartAgain()) {
- this->Completed--; // remove the completed test because run again
- continue;
- }
- if (testResult) {
- this->Passed->push_back(p->GetTestProperties()->Name);
- } else {
- this->Failed->push_back(p->GetTestProperties()->Name);
- }
- for (TestMap::iterator j = this->Tests.begin(); j != this->Tests.end();
- ++j) {
- j->second.erase(test);
- }
- this->TestFinishMap[test] = true;
- this->TestRunningMap[test] = false;
- this->RunningTests.erase(p);
- this->WriteCheckpoint(test);
- this->UnlockResources(test);
- this->RunningCount -= GetProcessorsUsed(test);
- delete p;
+ if (testResult) {
+ this->Passed->push_back(properties->Name);
+ } else if (!properties->Disabled) {
+ this->Failed->push_back(properties->Name);
+ }
+
+ for (auto& t : this->Tests) {
+ t.second.erase(test);
+ }
+
+ this->TestFinishMap[test] = true;
+ this->TestRunningMap[test] = false;
+ this->WriteCheckpoint(test);
+ this->DeallocateResources(test);
+ this->UnlockResources(test);
+ this->RunningCount -= GetProcessorsUsed(test);
+
+ for (auto p : properties->Affinity) {
+ this->ProcessorsAvailable.insert(p);
+ }
+ properties->Affinity.clear();
+
+ delete runner;
+ if (started) {
+ this->StartNextTests();
}
- return true;
}
void cmCTestMultiProcessHandler::UpdateCostData()
@@ -416,7 +626,7 @@ void cmCTestMultiProcessHandler::UpdateCostData()
PropertiesMap temp = this->Properties;
- if (cmSystemTools::FileExists(fname.c_str())) {
+ if (cmSystemTools::FileExists(fname)) {
cmsys::ifstream fin;
fin.open(fname.c_str());
@@ -425,7 +635,7 @@ void cmCTestMultiProcessHandler::UpdateCostData()
if (line == "---") {
break;
}
- std::vector<cmsys::String> parts = cmSystemTools::SplitString(line, ' ');
+ std::vector<std::string> parts = cmSystemTools::SplitString(line, ' ');
// Format: <name> <previous_runs> <avg_cost>
if (parts.size() < 3) {
break;
@@ -451,26 +661,25 @@ void cmCTestMultiProcessHandler::UpdateCostData()
}
// Add all tests not previously listed in the file
- for (PropertiesMap::iterator i = temp.begin(); i != temp.end(); ++i) {
- fout << i->second->Name << " " << i->second->PreviousRuns << " "
- << i->second->Cost << "\n";
+ for (auto const& i : temp) {
+ fout << i.second->Name << " " << i.second->PreviousRuns << " "
+ << i.second->Cost << "\n";
}
// Write list of failed tests
fout << "---\n";
- for (std::vector<std::string>::iterator i = this->Failed->begin();
- i != this->Failed->end(); ++i) {
- fout << *i << "\n";
+ for (std::string const& f : *this->Failed) {
+ fout << f << "\n";
}
fout.close();
- cmSystemTools::RenameFile(tmpout.c_str(), fname.c_str());
+ cmSystemTools::RenameFile(tmpout, fname);
}
void cmCTestMultiProcessHandler::ReadCostData()
{
std::string fname = this->CTest->GetCostDataFile();
- if (cmSystemTools::FileExists(fname.c_str(), true)) {
+ if (cmSystemTools::FileExists(fname, true)) {
cmsys::ifstream fin;
fin.open(fname.c_str());
std::string line;
@@ -479,7 +688,7 @@ void cmCTestMultiProcessHandler::ReadCostData()
break;
}
- std::vector<cmsys::String> parts = cmSystemTools::SplitString(line, ' ');
+ std::vector<std::string> parts = cmSystemTools::SplitString(line, ' ');
// Probably an older version of the file, will be fixed next run
if (parts.size() < 3) {
@@ -505,7 +714,7 @@ void cmCTestMultiProcessHandler::ReadCostData()
}
// Next part of the file is the failed tests
while (std::getline(fin, line)) {
- if (line != "") {
+ if (!line.empty()) {
this->LastTestsFailed.push_back(line);
}
}
@@ -517,10 +726,9 @@ int cmCTestMultiProcessHandler::SearchByName(std::string const& name)
{
int index = -1;
- for (PropertiesMap::iterator i = this->Properties.begin();
- i != this->Properties.end(); ++i) {
- if (i->second->Name == name) {
- index = i->first;
+ for (auto const& p : this->Properties) {
+ if (p.second->Name == name) {
+ index = p.first;
}
}
return index;
@@ -540,21 +748,18 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
TestSet alreadySortedTests;
std::list<TestSet> priorityStack;
- priorityStack.push_back(TestSet());
+ priorityStack.emplace_back();
TestSet& topLevel = priorityStack.back();
// In parallel test runs add previously failed tests to the front
// of the cost list and queue other tests for further sorting
- for (TestMap::const_iterator i = this->Tests.begin(); i != this->Tests.end();
- ++i) {
- if (std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(),
- this->Properties[i->first]->Name) !=
- this->LastTestsFailed.end()) {
+ for (auto const& t : this->Tests) {
+ if (cmContains(this->LastTestsFailed, this->Properties[t.first]->Name)) {
// If the test failed last time, it should be run first.
- this->SortedTests.push_back(i->first);
- alreadySortedTests.insert(i->first);
+ this->SortedTests.push_back(t.first);
+ alreadySortedTests.insert(t.first);
} else {
- topLevel.insert(i->first);
+ topLevel.insert(t.first);
}
}
@@ -563,18 +768,16 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
// further dependencies exist.
while (!priorityStack.back().empty()) {
TestSet& previousSet = priorityStack.back();
- priorityStack.push_back(TestSet());
+ priorityStack.emplace_back();
TestSet& currentSet = priorityStack.back();
- for (TestSet::const_iterator i = previousSet.begin();
- i != previousSet.end(); ++i) {
- TestSet const& dependencies = this->Tests[*i];
+ for (auto const& i : previousSet) {
+ TestSet const& dependencies = this->Tests[i];
currentSet.insert(dependencies.begin(), dependencies.end());
}
- for (TestSet::const_iterator i = currentSet.begin(); i != currentSet.end();
- ++i) {
- previousSet.erase(*i);
+ for (auto const& i : currentSet) {
+ previousSet.erase(i);
}
}
@@ -583,22 +786,16 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
// Reverse iterate over the different dependency levels (deepest first).
// Sort tests within each level by COST and append them to the cost list.
- for (std::list<TestSet>::reverse_iterator i = priorityStack.rbegin();
- i != priorityStack.rend(); ++i) {
- TestSet const& currentSet = *i;
- TestComparator comp(this);
-
+ for (TestSet const& currentSet : cmReverseRange(priorityStack)) {
TestList sortedCopy;
-
- sortedCopy.insert(sortedCopy.end(), currentSet.begin(), currentSet.end());
-
- std::stable_sort(sortedCopy.begin(), sortedCopy.end(), comp);
-
- for (TestList::const_iterator j = sortedCopy.begin();
- j != sortedCopy.end(); ++j) {
- if (alreadySortedTests.find(*j) == alreadySortedTests.end()) {
- this->SortedTests.push_back(*j);
- alreadySortedTests.insert(*j);
+ cmAppend(sortedCopy, currentSet);
+ std::stable_sort(sortedCopy.begin(), sortedCopy.end(),
+ TestComparator(this));
+
+ for (auto const& j : sortedCopy) {
+ if (!cmContains(alreadySortedTests, j)) {
+ this->SortedTests.push_back(j);
+ alreadySortedTests.insert(j);
}
}
}
@@ -608,10 +805,9 @@ void cmCTestMultiProcessHandler::GetAllTestDependencies(int test,
TestList& dependencies)
{
TestSet const& dependencySet = this->Tests[test];
- for (TestSet::const_iterator i = dependencySet.begin();
- i != dependencySet.end(); ++i) {
- GetAllTestDependencies(*i, dependencies);
- dependencies.push_back(*i);
+ for (int i : dependencySet) {
+ GetAllTestDependencies(i, dependencies);
+ dependencies.push_back(i);
}
}
@@ -619,33 +815,25 @@ void cmCTestMultiProcessHandler::CreateSerialTestCostList()
{
TestList presortedList;
- for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
- ++i) {
- presortedList.push_back(i->first);
+ for (auto const& i : this->Tests) {
+ presortedList.push_back(i.first);
}
- TestComparator comp(this);
- std::stable_sort(presortedList.begin(), presortedList.end(), comp);
+ std::stable_sort(presortedList.begin(), presortedList.end(),
+ TestComparator(this));
TestSet alreadySortedTests;
- for (TestList::const_iterator i = presortedList.begin();
- i != presortedList.end(); ++i) {
- int test = *i;
-
- if (alreadySortedTests.find(test) != alreadySortedTests.end()) {
+ for (int test : presortedList) {
+ if (cmContains(alreadySortedTests, test)) {
continue;
}
TestList dependencies;
GetAllTestDependencies(test, dependencies);
- for (TestList::const_iterator j = dependencies.begin();
- j != dependencies.end(); ++j) {
- int testDependency = *j;
-
- if (alreadySortedTests.find(testDependency) ==
- alreadySortedTests.end()) {
+ for (int testDependency : dependencies) {
+ if (!cmContains(alreadySortedTests, testDependency)) {
alreadySortedTests.insert(testDependency);
this->SortedTests.push_back(testDependency);
}
@@ -673,32 +861,390 @@ void cmCTestMultiProcessHandler::MarkFinished()
cmSystemTools::RemoveFile(fname);
}
+static Json::Value DumpToJsonArray(const std::set<std::string>& values)
+{
+ Json::Value jsonArray = Json::arrayValue;
+ for (auto& it : values) {
+ jsonArray.append(it);
+ }
+ return jsonArray;
+}
+
+static Json::Value DumpToJsonArray(const std::vector<std::string>& values)
+{
+ Json::Value jsonArray = Json::arrayValue;
+ for (auto& it : values) {
+ jsonArray.append(it);
+ }
+ return jsonArray;
+}
+
+static Json::Value DumpRegExToJsonArray(
+ const std::vector<std::pair<cmsys::RegularExpression, std::string>>& values)
+{
+ Json::Value jsonArray = Json::arrayValue;
+ for (auto& it : values) {
+ jsonArray.append(it.second);
+ }
+ return jsonArray;
+}
+
+static Json::Value DumpMeasurementToJsonArray(
+ const std::map<std::string, std::string>& values)
+{
+ Json::Value jsonArray = Json::arrayValue;
+ for (auto& it : values) {
+ Json::Value measurement = Json::objectValue;
+ measurement["measurement"] = it.first;
+ measurement["value"] = it.second;
+ jsonArray.append(measurement);
+ }
+ return jsonArray;
+}
+
+static Json::Value DumpTimeoutAfterMatch(
+ cmCTestTestHandler::cmCTestTestProperties& testProperties)
+{
+ Json::Value timeoutAfterMatch = Json::objectValue;
+ timeoutAfterMatch["timeout"] = testProperties.AlternateTimeout.count();
+ timeoutAfterMatch["regex"] =
+ DumpRegExToJsonArray(testProperties.TimeoutRegularExpressions);
+ return timeoutAfterMatch;
+}
+
+static Json::Value DumpResourceGroupsToJsonArray(
+ const std::vector<
+ std::vector<cmCTestTestHandler::cmCTestTestResourceRequirement>>&
+ resourceGroups)
+{
+ Json::Value jsonResourceGroups = Json::arrayValue;
+ for (auto const& it : resourceGroups) {
+ Json::Value jsonResourceGroup = Json::objectValue;
+ Json::Value requirements = Json::arrayValue;
+ for (auto const& it2 : it) {
+ Json::Value res = Json::objectValue;
+ res[".type"] = it2.ResourceType;
+ // res[".units"] = it2.UnitsNeeded; // Intentionally commented out
+ res["slots"] = it2.SlotsNeeded;
+ requirements.append(res);
+ }
+ jsonResourceGroup["requirements"] = requirements;
+ jsonResourceGroups.append(jsonResourceGroup);
+ }
+ return jsonResourceGroups;
+}
+
+static Json::Value DumpCTestProperty(std::string const& name,
+ Json::Value value)
+{
+ Json::Value property = Json::objectValue;
+ property["name"] = name;
+ property["value"] = std::move(value);
+ return property;
+}
+
+static Json::Value DumpCTestProperties(
+ cmCTestTestHandler::cmCTestTestProperties& testProperties)
+{
+ Json::Value properties = Json::arrayValue;
+ if (!testProperties.AttachOnFail.empty()) {
+ properties.append(DumpCTestProperty(
+ "ATTACHED_FILES_ON_FAIL", DumpToJsonArray(testProperties.AttachOnFail)));
+ }
+ if (!testProperties.AttachedFiles.empty()) {
+ properties.append(DumpCTestProperty(
+ "ATTACHED_FILES", DumpToJsonArray(testProperties.AttachedFiles)));
+ }
+ if (testProperties.Cost != 0.0f) {
+ properties.append(
+ DumpCTestProperty("COST", static_cast<double>(testProperties.Cost)));
+ }
+ if (!testProperties.Depends.empty()) {
+ properties.append(
+ DumpCTestProperty("DEPENDS", DumpToJsonArray(testProperties.Depends)));
+ }
+ if (testProperties.Disabled) {
+ properties.append(DumpCTestProperty("DISABLED", testProperties.Disabled));
+ }
+ if (!testProperties.Environment.empty()) {
+ properties.append(DumpCTestProperty(
+ "ENVIRONMENT", DumpToJsonArray(testProperties.Environment)));
+ }
+ if (!testProperties.ErrorRegularExpressions.empty()) {
+ properties.append(DumpCTestProperty(
+ "FAIL_REGULAR_EXPRESSION",
+ DumpRegExToJsonArray(testProperties.ErrorRegularExpressions)));
+ }
+ if (!testProperties.SkipRegularExpressions.empty()) {
+ properties.append(DumpCTestProperty(
+ "SKIP_REGULAR_EXPRESSION",
+ DumpRegExToJsonArray(testProperties.SkipRegularExpressions)));
+ }
+ if (!testProperties.FixturesCleanup.empty()) {
+ properties.append(DumpCTestProperty(
+ "FIXTURES_CLEANUP", DumpToJsonArray(testProperties.FixturesCleanup)));
+ }
+ if (!testProperties.FixturesRequired.empty()) {
+ properties.append(DumpCTestProperty(
+ "FIXTURES_REQUIRED", DumpToJsonArray(testProperties.FixturesRequired)));
+ }
+ if (!testProperties.FixturesSetup.empty()) {
+ properties.append(DumpCTestProperty(
+ "FIXTURES_SETUP", DumpToJsonArray(testProperties.FixturesSetup)));
+ }
+ if (!testProperties.Labels.empty()) {
+ properties.append(
+ DumpCTestProperty("LABELS", DumpToJsonArray(testProperties.Labels)));
+ }
+ if (!testProperties.Measurements.empty()) {
+ properties.append(DumpCTestProperty(
+ "MEASUREMENT", DumpMeasurementToJsonArray(testProperties.Measurements)));
+ }
+ if (!testProperties.RequiredRegularExpressions.empty()) {
+ properties.append(DumpCTestProperty(
+ "PASS_REGULAR_EXPRESSION",
+ DumpRegExToJsonArray(testProperties.RequiredRegularExpressions)));
+ }
+ if (!testProperties.ResourceGroups.empty()) {
+ properties.append(DumpCTestProperty(
+ "RESOURCE_GROUPS",
+ DumpResourceGroupsToJsonArray(testProperties.ResourceGroups)));
+ }
+ if (testProperties.WantAffinity) {
+ properties.append(
+ DumpCTestProperty("PROCESSOR_AFFINITY", testProperties.WantAffinity));
+ }
+ if (testProperties.Processors != 1) {
+ properties.append(
+ DumpCTestProperty("PROCESSORS", testProperties.Processors));
+ }
+ if (!testProperties.RequiredFiles.empty()) {
+ properties.append(DumpCTestProperty(
+ "REQUIRED_FILES", DumpToJsonArray(testProperties.RequiredFiles)));
+ }
+ if (!testProperties.LockedResources.empty()) {
+ properties.append(DumpCTestProperty(
+ "RESOURCE_LOCK", DumpToJsonArray(testProperties.LockedResources)));
+ }
+ if (testProperties.RunSerial) {
+ properties.append(
+ DumpCTestProperty("RUN_SERIAL", testProperties.RunSerial));
+ }
+ if (testProperties.SkipReturnCode != -1) {
+ properties.append(
+ DumpCTestProperty("SKIP_RETURN_CODE", testProperties.SkipReturnCode));
+ }
+ if (testProperties.ExplicitTimeout) {
+ properties.append(
+ DumpCTestProperty("TIMEOUT", testProperties.Timeout.count()));
+ }
+ if (!testProperties.TimeoutRegularExpressions.empty()) {
+ properties.append(DumpCTestProperty(
+ "TIMEOUT_AFTER_MATCH", DumpTimeoutAfterMatch(testProperties)));
+ }
+ if (testProperties.WillFail) {
+ properties.append(DumpCTestProperty("WILL_FAIL", testProperties.WillFail));
+ }
+ if (!testProperties.Directory.empty()) {
+ properties.append(
+ DumpCTestProperty("WORKING_DIRECTORY", testProperties.Directory));
+ }
+ return properties;
+}
+
+class BacktraceData
+{
+ std::unordered_map<std::string, Json::ArrayIndex> CommandMap;
+ std::unordered_map<std::string, Json::ArrayIndex> FileMap;
+ std::unordered_map<cmListFileContext const*, Json::ArrayIndex> NodeMap;
+ Json::Value Commands = Json::arrayValue;
+ Json::Value Files = Json::arrayValue;
+ Json::Value Nodes = Json::arrayValue;
+
+ Json::ArrayIndex AddCommand(std::string const& command)
+ {
+ auto i = this->CommandMap.find(command);
+ if (i == this->CommandMap.end()) {
+ i = this->CommandMap.emplace(command, this->Commands.size()).first;
+ this->Commands.append(command);
+ }
+ return i->second;
+ }
+
+ Json::ArrayIndex AddFile(std::string const& file)
+ {
+ auto i = this->FileMap.find(file);
+ if (i == this->FileMap.end()) {
+ i = this->FileMap.emplace(file, this->Files.size()).first;
+ this->Files.append(file);
+ }
+ return i->second;
+ }
+
+public:
+ bool Add(cmListFileBacktrace const& bt, Json::ArrayIndex& index);
+ Json::Value Dump();
+};
+
+bool BacktraceData::Add(cmListFileBacktrace const& bt, Json::ArrayIndex& index)
+{
+ if (bt.Empty()) {
+ return false;
+ }
+ cmListFileContext const* top = &bt.Top();
+ auto found = this->NodeMap.find(top);
+ if (found != this->NodeMap.end()) {
+ index = found->second;
+ return true;
+ }
+ Json::Value entry = Json::objectValue;
+ entry["file"] = this->AddFile(top->FilePath);
+ if (top->Line) {
+ entry["line"] = static_cast<int>(top->Line);
+ }
+ if (!top->Name.empty()) {
+ entry["command"] = this->AddCommand(top->Name);
+ }
+ Json::ArrayIndex parent;
+ if (this->Add(bt.Pop(), parent)) {
+ entry["parent"] = parent;
+ }
+ index = this->NodeMap[top] = this->Nodes.size();
+ this->Nodes.append(std::move(entry)); // NOLINT(*)
+ return true;
+}
+
+Json::Value BacktraceData::Dump()
+{
+ Json::Value backtraceGraph;
+ this->CommandMap.clear();
+ this->FileMap.clear();
+ this->NodeMap.clear();
+ backtraceGraph["commands"] = std::move(this->Commands);
+ backtraceGraph["files"] = std::move(this->Files);
+ backtraceGraph["nodes"] = std::move(this->Nodes);
+ return backtraceGraph;
+}
+
+static void AddBacktrace(BacktraceData& backtraceGraph, Json::Value& object,
+ cmListFileBacktrace const& bt)
+{
+ Json::ArrayIndex backtrace;
+ if (backtraceGraph.Add(bt, backtrace)) {
+ object["backtrace"] = backtrace;
+ }
+}
+
+static Json::Value DumpCTestInfo(
+ cmCTestRunTest& testRun,
+ cmCTestTestHandler::cmCTestTestProperties& testProperties,
+ BacktraceData& backtraceGraph)
+{
+ Json::Value testInfo = Json::objectValue;
+ // test name should always be present
+ testInfo["name"] = testProperties.Name;
+ std::string const& config = testRun.GetCTest()->GetConfigType();
+ if (!config.empty()) {
+ testInfo["config"] = config;
+ }
+ std::string const& command = testRun.GetActualCommand();
+ if (!command.empty()) {
+ std::vector<std::string> commandAndArgs;
+ commandAndArgs.push_back(command);
+ const std::vector<std::string>& args = testRun.GetArguments();
+ if (!args.empty()) {
+ commandAndArgs.reserve(args.size() + 1);
+ cmAppend(commandAndArgs, args);
+ }
+ testInfo["command"] = DumpToJsonArray(commandAndArgs);
+ }
+ Json::Value properties = DumpCTestProperties(testProperties);
+ if (!properties.empty()) {
+ testInfo["properties"] = properties;
+ }
+ if (!testProperties.Backtrace.Empty()) {
+ AddBacktrace(backtraceGraph, testInfo, testProperties.Backtrace);
+ }
+ return testInfo;
+}
+
+static Json::Value DumpVersion(int major, int minor)
+{
+ Json::Value version = Json::objectValue;
+ version["major"] = major;
+ version["minor"] = minor;
+ return version;
+}
+
+void cmCTestMultiProcessHandler::PrintOutputAsJson()
+{
+ this->TestHandler->SetMaxIndex(this->FindMaxIndex());
+
+ Json::Value result = Json::objectValue;
+ result["kind"] = "ctestInfo";
+ result["version"] = DumpVersion(1, 0);
+
+ BacktraceData backtraceGraph;
+ Json::Value tests = Json::arrayValue;
+ for (auto& it : this->Properties) {
+ cmCTestTestHandler::cmCTestTestProperties& p = *it.second;
+
+ // Don't worry if this fails, we are only showing the test list, not
+ // running the tests
+ cmWorkingDirectory workdir(p.Directory);
+ cmCTestRunTest testRun(*this);
+ testRun.SetIndex(p.Index);
+ testRun.SetTestProperties(&p);
+ testRun.ComputeArguments();
+
+ // Skip tests not available in this configuration.
+ if (p.Args.size() >= 2 && p.Args[1] == "NOT_AVAILABLE") {
+ continue;
+ }
+
+ Json::Value testInfo = DumpCTestInfo(testRun, p, backtraceGraph);
+ tests.append(testInfo);
+ }
+ result["backtraceGraph"] = backtraceGraph.Dump();
+ result["tests"] = std::move(tests);
+
+ Json::StreamWriterBuilder builder;
+ builder["indentation"] = " ";
+ std::unique_ptr<Json::StreamWriter> jout(builder.newStreamWriter());
+ jout->write(result, &std::cout);
+}
+
// For ShowOnly mode
void cmCTestMultiProcessHandler::PrintTestList()
{
+ if (this->CTest->GetOutputAsJson()) {
+ PrintOutputAsJson();
+ return;
+ }
+
this->TestHandler->SetMaxIndex(this->FindMaxIndex());
int count = 0;
- for (PropertiesMap::iterator it = this->Properties.begin();
- it != this->Properties.end(); ++it) {
+ for (auto& it : this->Properties) {
count++;
- cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
+ cmCTestTestHandler::cmCTestTestProperties& p = *it.second;
+ // Don't worry if this fails, we are only showing the test list, not
+ // running the tests
cmWorkingDirectory workdir(p.Directory);
- cmCTestRunTest testRun(this->TestHandler);
+ cmCTestRunTest testRun(*this);
testRun.SetIndex(p.Index);
testRun.SetTestProperties(&p);
testRun.ComputeArguments(); // logs the command in verbose mode
if (!p.Labels.empty()) // print the labels
{
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Labels:",
- this->Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Labels:", this->Quiet);
}
- for (std::vector<std::string>::iterator label = p.Labels.begin();
- label != p.Labels.end(); ++label) {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " " << *label,
+ for (std::string const& label : p.Labels) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " " << label,
this->Quiet);
}
if (!p.Labels.empty()) // print the labels
@@ -729,7 +1275,8 @@ void cmCTestMultiProcessHandler::PrintTestList()
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl, this->Quiet);
}
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ std::endl
<< "Total Tests: " << this->Total << std::endl,
this->Quiet);
}
@@ -737,9 +1284,8 @@ void cmCTestMultiProcessHandler::PrintTestList()
void cmCTestMultiProcessHandler::PrintLabels()
{
std::set<std::string> allLabels;
- for (PropertiesMap::iterator it = this->Properties.begin();
- it != this->Properties.end(); ++it) {
- cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
+ for (auto& it : this->Properties) {
+ cmCTestTestHandler::cmCTestTestProperties& p = *it.second;
allLabels.insert(p.Labels.begin(), p.Labels.end());
}
@@ -750,10 +1296,9 @@ void cmCTestMultiProcessHandler::PrintLabels()
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
"No Labels Exist" << std::endl, this->Quiet);
}
- for (std::set<std::string>::iterator label = allLabels.begin();
- label != allLabels.end(); ++label) {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " " << *label << std::endl, this->Quiet);
+ for (std::string const& label : allLabels) {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " " << label << std::endl,
+ this->Quiet);
}
}
@@ -762,7 +1307,7 @@ void cmCTestMultiProcessHandler::CheckResume()
std::string fname =
this->CTest->GetBinaryDir() + "/Testing/Temporary/CTestCheckpoint.txt";
if (this->CTest->GetFailover()) {
- if (cmSystemTools::FileExists(fname.c_str(), true)) {
+ if (cmSystemTools::FileExists(fname, true)) {
*this->TestHandler->LogFile
<< "Resuming previously interrupted test set" << std::endl
<< "----------------------------------------------------------"
@@ -777,7 +1322,7 @@ void cmCTestMultiProcessHandler::CheckResume()
}
fin.close();
}
- } else if (cmSystemTools::FileExists(fname.c_str(), true)) {
+ } else if (cmSystemTools::FileExists(fname, true)) {
cmSystemTools::RemoveFile(fname);
}
}
@@ -794,10 +1339,9 @@ void cmCTestMultiProcessHandler::RemoveTest(int index)
int cmCTestMultiProcessHandler::FindMaxIndex()
{
int max = 0;
- cmCTestMultiProcessHandler::TestMap::iterator i = this->Tests.begin();
- for (; i != this->Tests.end(); ++i) {
- if (i->first > max) {
- max = i->first;
+ for (auto const& i : this->Tests) {
+ if (i.first > max) {
+ max = i.first;
}
}
return max;
@@ -809,10 +1353,9 @@ bool cmCTestMultiProcessHandler::CheckCycles()
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Checking test dependency graph..." << std::endl,
this->Quiet);
- for (TestMap::iterator it = this->Tests.begin(); it != this->Tests.end();
- ++it) {
+ for (auto const& it : this->Tests) {
// DFS from each element to itself
- int root = it->first;
+ int root = it.first;
std::set<int> visited;
std::stack<int> s;
s.push(root);
@@ -820,9 +1363,8 @@ bool cmCTestMultiProcessHandler::CheckCycles()
int test = s.top();
s.pop();
if (visited.insert(test).second) {
- for (TestSet::iterator d = this->Tests[test].begin();
- d != this->Tests[test].end(); ++d) {
- if (*d == root) {
+ for (auto const& d : this->Tests[test]) {
+ if (d == root) {
// cycle exists
cmCTestLog(
this->CTest, ERROR_MESSAGE,
@@ -832,7 +1374,7 @@ bool cmCTestMultiProcessHandler::CheckCycles()
<< "\".\nPlease fix the cycle and run ctest again.\n");
return false;
}
- s.push(*d);
+ s.push(d);
}
}
}
diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h
index dccc2c896..1db4bfdd1 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.h
+++ b/Source/CTest/cmCTestMultiProcessHandler.h
@@ -5,14 +5,22 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmCTestTestHandler.h"
#include <map>
#include <set>
-#include <stddef.h>
#include <string>
#include <vector>
+#include <stddef.h>
+
+#include "cm_uv.h"
+
+#include "cmCTestResourceAllocator.h"
+#include "cmCTestTestHandler.h"
+#include "cmUVHandlePtr.h"
+
class cmCTest;
+struct cmCTestBinPackerAllocation;
+class cmCTestResourceSpec;
class cmCTestRunTest;
/** \class cmCTestMultiProcessHandler
@@ -23,6 +31,7 @@ class cmCTestRunTest;
class cmCTestMultiProcessHandler
{
friend class TestComparator;
+ friend class cmCTestRunTest;
public:
struct TestSet : public std::set<int>
@@ -38,6 +47,11 @@ public:
: public std::map<int, cmCTestTestHandler::cmCTestTestProperties*>
{
};
+ struct ResourceAllocation
+ {
+ std::string Id;
+ unsigned int Slots;
+ };
cmCTestMultiProcessHandler();
virtual ~cmCTestMultiProcessHandler();
@@ -47,6 +61,7 @@ public:
void SetParallelLevel(size_t);
void SetTestLoad(unsigned long load);
virtual void RunTests();
+ void PrintOutputAsJson();
void PrintTestList();
void PrintLabels();
@@ -71,11 +86,19 @@ public:
cmCTestTestHandler* GetTestHandler() { return this->TestHandler; }
void SetQuiet(bool b) { this->Quiet = b; }
+
+ void InitResourceAllocator(const cmCTestResourceSpec& spec)
+ {
+ this->ResourceAllocator.InitializeFromResourceSpec(spec);
+ }
+
+ void CheckResourcesAvailable();
+
protected:
// Start the next test or tests as many as are allowed by
// ParallelLevel
void StartNextTests();
- void StartTestProcess(int test);
+ bool StartTestProcess(int test);
bool StartTest(int test);
// Mark the checkpoint for the given test
void WriteCheckpoint(int index);
@@ -95,9 +118,10 @@ protected:
// Removes the checkpoint file
void MarkFinished();
void EraseTest(int index);
- // Return true if there are still tests running
- // check all running processes for output and exit case
- bool CheckOutput();
+ void FinishTestProcess(cmCTestRunTest* runner, bool started);
+
+ static void OnTestLoadRetryCB(uv_timer_t* timer);
+
void RemoveTest(int index);
// Check if we need to resume an interrupted test set
void CheckResume();
@@ -107,8 +131,20 @@ protected:
inline size_t GetProcessorsUsed(int index);
std::string GetName(int index);
+ bool CheckStopTimePassed();
+ void SetStopTimePassed();
+
void LockResources(int index);
void UnlockResources(int index);
+
+ bool AllocateResources(int index);
+ bool TryAllocateResources(
+ int index,
+ std::map<std::string, std::vector<cmCTestBinPackerAllocation>>&
+ allocations);
+ void DeallocateResources(int index);
+ bool AllResourcesAvailable();
+
// map from test number to set of depend tests
TestMap Tests;
TestList SortedTests;
@@ -117,7 +153,9 @@ protected:
// Number of tests that are complete
size_t Completed;
size_t RunningCount;
- bool StopTimePassed;
+ std::set<size_t> ProcessorsAvailable;
+ size_t HaveAffinity;
+ bool StopTimePassed = false;
// list of test properties (indices concurrent to the test map)
PropertiesMap Properties;
std::map<int, bool> TestRunningMap;
@@ -127,10 +165,17 @@ protected:
std::vector<std::string>* Failed;
std::vector<std::string> LastTestsFailed;
std::set<std::string> LockedResources;
+ std::map<int,
+ std::vector<std::map<std::string, std::vector<ResourceAllocation>>>>
+ AllocatedResources;
+ std::map<int, bool> TestsHaveSufficientResources;
+ cmCTestResourceAllocator ResourceAllocator;
std::vector<cmCTestTestHandler::cmCTestTestResult>* TestResults;
size_t ParallelLevel; // max number of process that can be run at once
unsigned long TestLoad;
- std::set<cmCTestRunTest*> RunningTests; // current running tests
+ unsigned long FakeLoadForTesting;
+ uv_loop_t Loop;
+ cm::uv_timer_ptr TestLoadRetryTimer;
cmCTestTestHandler* TestHandler;
cmCTest* CTest;
bool HasCycles;
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index c80221634..e2063e178 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -2,26 +2,28 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestP4.h"
+#include <algorithm>
+#include <ctime>
+#include <ostream>
+#include <utility>
+
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestVC.h"
#include "cmProcessTools.h"
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmsys/RegularExpression.hxx"
-#include <algorithm>
-#include <ostream>
-#include <time.h>
-#include <utility>
-
cmCTestP4::cmCTestP4(cmCTest* ct, std::ostream& log)
: cmCTestGlobalVC(ct, log)
{
this->PriorRev = this->Unknown;
}
-cmCTestP4::~cmCTestP4()
-{
-}
+cmCTestP4::~cmCTestP4() = default;
class cmCTestP4::IdentifyParser : public cmCTestVC::LineParser
{
@@ -37,7 +39,7 @@ private:
std::string& Rev;
cmsys::RegularExpression RegexIdentify;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexIdentify.find(this->Line)) {
this->Rev = this->RegexIdentify.match(1);
@@ -61,7 +63,7 @@ private:
cmsys::RegularExpression RegexIdentify;
cmCTestP4* P4;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexIdentify.find(this->Line)) {
P4->ChangeLists.push_back(this->RegexIdentify.match(1));
@@ -84,7 +86,7 @@ private:
cmsys::RegularExpression RegexUser;
cmCTestP4* P4;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexUser.find(this->Line)) {
User NewUser;
@@ -127,7 +129,7 @@ private:
std::string CurrentPath;
cmsys::RegularExpression RegexDiff;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (!this->Line.empty() && this->Line[0] == '=' &&
this->RegexDiff.find(this->Line)) {
@@ -145,8 +147,7 @@ private:
cmCTestP4::User cmCTestP4::GetUserData(const std::string& username)
{
- std::map<std::string, cmCTestP4::User>::const_iterator it =
- Users.find(username);
+ auto it = Users.find(username);
if (it == Users.end()) {
std::vector<char const*> p4_users;
@@ -155,7 +156,7 @@ cmCTestP4::User cmCTestP4::GetUserData(const std::string& username)
p4_users.push_back("-m");
p4_users.push_back("1");
p4_users.push_back(username.c_str());
- p4_users.push_back(CM_NULLPTR);
+ p4_users.push_back(nullptr);
UserParser out(this, "users-out> ");
OutputLogger err(this->Log, "users-err> ");
@@ -195,7 +196,7 @@ public:
{
this->SetLog(&P4->Log, prefix);
this->RegexHeader.compile("^Change ([0-9]+) by (.+)@(.+) on (.*)$");
- this->RegexDiff.compile("^\\.\\.\\. (.*)#[0-9]+ ([^ ]+)$");
+ this->RegexDiff.compile(R"(^\.\.\. (.*)#[0-9]+ ([^ ]+)$)");
}
private:
@@ -203,8 +204,8 @@ private:
cmsys::RegularExpression RegexDiff;
cmCTestP4* P4;
- typedef cmCTestP4::Revision Revision;
- typedef cmCTestP4::Change Change;
+ using Revision = cmCTestP4::Revision;
+ using Change = cmCTestP4::Change;
std::vector<Change> Changes;
enum SectionType
{
@@ -217,7 +218,7 @@ private:
SectionType Section;
Revision Rev;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->Line.empty()) {
this->NextSection();
@@ -307,34 +308,30 @@ void cmCTestP4::SetP4Options(std::vector<char const*>& CommandOptions)
{
if (P4Options.empty()) {
const char* p4 = this->CommandLineTool.c_str();
- P4Options.push_back(p4);
+ P4Options.emplace_back(p4);
// The CTEST_P4_CLIENT variable sets the P4 client used when issuing
// Perforce commands, if it's different from the default one.
std::string client = this->CTest->GetCTestConfiguration("P4Client");
if (!client.empty()) {
- P4Options.push_back("-c");
+ P4Options.emplace_back("-c");
P4Options.push_back(client);
}
// Set the message language to be English, in case the P4 admin
// has localized them
- P4Options.push_back("-L");
- P4Options.push_back("en");
+ P4Options.emplace_back("-L");
+ P4Options.emplace_back("en");
// The CTEST_P4_OPTIONS variable adds additional Perforce command line
// options before the main command
std::string opts = this->CTest->GetCTestConfiguration("P4Options");
- std::vector<std::string> args =
- cmSystemTools::ParseArguments(opts.c_str());
-
- P4Options.insert(P4Options.end(), args.begin(), args.end());
+ cmAppend(P4Options, cmSystemTools::ParseArguments(opts));
}
CommandOptions.clear();
- for (std::vector<std::string>::iterator i = P4Options.begin();
- i != P4Options.end(); ++i) {
- CommandOptions.push_back(i->c_str());
+ for (std::string const& o : P4Options) {
+ CommandOptions.push_back(o.c_str());
}
}
@@ -350,7 +347,7 @@ std::string cmCTestP4::GetWorkingRevision()
std::string source = this->SourceDirectory + "/...#have";
p4_identify.push_back(source.c_str());
- p4_identify.push_back(CM_NULLPTR);
+ p4_identify.push_back(nullptr);
std::string rev;
IdentifyParser out(this, "p4_changes-out> ", rev);
@@ -373,8 +370,9 @@ bool cmCTestP4::NoteOldRevision()
{
this->OldRevision = this->GetWorkingRevision();
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " Old revision of repository is: "
- << this->OldRevision << "\n");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " Old revision of repository is: " << this->OldRevision
+ << "\n");
this->PriorRev.Rev = this->OldRevision;
return true;
}
@@ -383,8 +381,9 @@ bool cmCTestP4::NoteNewRevision()
{
this->NewRevision = this->GetWorkingRevision();
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " New revision of repository is: "
- << this->NewRevision << "\n");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " New revision of repository is: " << this->NewRevision
+ << "\n");
return true;
}
@@ -399,7 +398,8 @@ bool cmCTestP4::LoadRevisions()
// If any revision is unknown it means we couldn't contact the server.
// Do not process updates
if (this->OldRevision == "<unknown>" || this->NewRevision == "<unknown>") {
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " At least one of the revisions "
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " At least one of the revisions "
<< "is unknown. No repository changes will be reported.\n");
return false;
}
@@ -411,7 +411,7 @@ bool cmCTestP4::LoadRevisions()
p4_changes.push_back("changes");
p4_changes.push_back(range.c_str());
- p4_changes.push_back(CM_NULLPTR);
+ p4_changes.push_back(nullptr);
ChangesParser out(this, "p4_changes-out> ");
OutputLogger err(this->Log, "p4_changes-err> ");
@@ -425,13 +425,12 @@ bool cmCTestP4::LoadRevisions()
// p4 describe -s ...@1111111,2222222
std::vector<char const*> p4_describe;
- for (std::vector<std::string>::reverse_iterator i = ChangeLists.rbegin();
- i != ChangeLists.rend(); ++i) {
+ for (std::string const& i : cmReverseRange(ChangeLists)) {
SetP4Options(p4_describe);
p4_describe.push_back("describe");
p4_describe.push_back("-s");
- p4_describe.push_back(i->c_str());
- p4_describe.push_back(CM_NULLPTR);
+ p4_describe.push_back(i.c_str());
+ p4_describe.push_back(nullptr);
DescribeParser outDescribe(this, "p4_describe-out> ");
OutputLogger errDescribe(this->Log, "p4_describe-err> ");
@@ -451,7 +450,7 @@ bool cmCTestP4::LoadModifications()
p4_diff.push_back("-dn");
std::string source = this->SourceDirectory + "/...";
p4_diff.push_back(source.c_str());
- p4_diff.push_back(CM_NULLPTR);
+ p4_diff.push_back(nullptr);
DiffParser out(this, "p4_diff-out> ");
OutputLogger err(this->Log, "p4_diff-err> ");
@@ -461,15 +460,14 @@ bool cmCTestP4::LoadModifications()
bool cmCTestP4::UpdateCustom(const std::string& custom)
{
- std::vector<std::string> p4_custom_command;
- cmSystemTools::ExpandListArgument(custom, p4_custom_command, true);
+ std::vector<std::string> p4_custom_command = cmExpandedList(custom, true);
std::vector<char const*> p4_custom;
- for (std::vector<std::string>::const_iterator i = p4_custom_command.begin();
- i != p4_custom_command.end(); ++i) {
- p4_custom.push_back(i->c_str());
+ p4_custom.reserve(p4_custom_command.size() + 1);
+ for (std::string const& i : p4_custom_command) {
+ p4_custom.push_back(i.c_str());
}
- p4_custom.push_back(CM_NULLPTR);
+ p4_custom.push_back(nullptr);
OutputLogger custom_out(this->Log, "p4_customsync-out> ");
OutputLogger custom_err(this->Log, "p4_customsync-err> ");
@@ -501,10 +499,9 @@ bool cmCTestP4::UpdateImpl()
if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("P4UpdateOptions");
}
- std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- p4_sync.push_back(ai->c_str());
+ std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
+ for (std::string const& arg : args) {
+ p4_sync.push_back(arg.c_str());
}
std::string source = this->SourceDirectory + "/...";
@@ -520,7 +517,7 @@ bool cmCTestP4::UpdateImpl()
}
p4_sync.push_back(source.c_str());
- p4_sync.push_back(CM_NULLPTR);
+ p4_sync.push_back(nullptr);
OutputLogger out(this->Log, "p4_sync-out> ");
OutputLogger err(this->Log, "p4_sync-err> ");
diff --git a/Source/CTest/cmCTestP4.h b/Source/CTest/cmCTestP4.h
index e234efbfb..e19472ee8 100644
--- a/Source/CTest/cmCTestP4.h
+++ b/Source/CTest/cmCTestP4.h
@@ -3,15 +3,15 @@
#ifndef cmCTestP4_h
#define cmCTestP4_h
-#include "cmConfigure.h"
-
-#include "cmCTestGlobalVC.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
#include <string>
#include <vector>
+#include "cmCTestGlobalVC.h"
+
class cmCTest;
/** \class cmCTestP4
@@ -24,7 +24,7 @@ public:
/** Construct with a CTest instance and update log stream. */
cmCTestP4(cmCTest* ctest, std::ostream& log);
- ~cmCTestP4() CM_OVERRIDE;
+ ~cmCTestP4() override;
private:
std::vector<std::string> ChangeLists;
@@ -51,13 +51,13 @@ private:
void SetP4Options(std::vector<char const*>& options);
std::string GetWorkingRevision();
- bool NoteOldRevision() CM_OVERRIDE;
- bool NoteNewRevision() CM_OVERRIDE;
- bool UpdateImpl() CM_OVERRIDE;
+ bool NoteOldRevision() override;
+ bool NoteNewRevision() override;
+ bool UpdateImpl() override;
bool UpdateCustom(const std::string& custom);
- bool LoadRevisions() CM_OVERRIDE;
- bool LoadModifications() CM_OVERRIDE;
+ bool LoadRevisions() override;
+ bool LoadModifications() override;
class ChangesParser;
class DescribeParser;
diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.cxx b/Source/CTest/cmCTestReadCustomFilesCommand.cxx
index b21be872f..ed14d0688 100644
--- a/Source/CTest/cmCTestReadCustomFilesCommand.cxx
+++ b/Source/CTest/cmCTestReadCustomFilesCommand.cxx
@@ -14,9 +14,8 @@ bool cmCTestReadCustomFilesCommand::InitialPass(
return false;
}
- std::vector<std::string>::const_iterator dit;
- for (dit = args.begin(); dit != args.end(); ++dit) {
- this->CTest->ReadCustomConfigurationFileTree(dit->c_str(), this->Makefile);
+ for (std::string const& arg : args) {
+ this->CTest->ReadCustomConfigurationFileTree(arg.c_str(), this->Makefile);
}
return true;
diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h
index 5989fa0fc..cbb939030 100644
--- a/Source/CTest/cmCTestReadCustomFilesCommand.h
+++ b/Source/CTest/cmCTestReadCustomFilesCommand.h
@@ -3,14 +3,17 @@
#ifndef cmCTestReadCustomFilesCommand_h
#define cmCTestReadCustomFilesCommand_h
-#include "cmConfigure.h"
-
-#include "cmCTestCommand.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <utility>
#include <vector>
-class cmCommand;
+#include <cm/memory>
+
+#include "cmCTestCommand.h"
+#include "cmCommand.h"
+
class cmExecutionStatus;
/** \class cmCTestReadCustomFiles
@@ -27,11 +30,11 @@ public:
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE
+ std::unique_ptr<cmCommand> Clone() override
{
- cmCTestReadCustomFilesCommand* ni = new cmCTestReadCustomFilesCommand;
+ auto ni = cm::make_unique<cmCTestReadCustomFilesCommand>();
ni->CTest = this->CTest;
- return ni;
+ return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
@@ -39,7 +42,7 @@ public:
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
+ cmExecutionStatus& status) override;
};
#endif
diff --git a/Source/CTest/cmCTestResourceAllocator.cxx b/Source/CTest/cmCTestResourceAllocator.cxx
new file mode 100644
index 000000000..9d468a7f0
--- /dev/null
+++ b/Source/CTest/cmCTestResourceAllocator.cxx
@@ -0,0 +1,86 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmCTestResourceAllocator.h"
+
+#include <utility>
+#include <vector>
+
+#include "cmCTestResourceSpec.h"
+
+void cmCTestResourceAllocator::InitializeFromResourceSpec(
+ const cmCTestResourceSpec& spec)
+{
+ this->Resources.clear();
+
+ for (auto const& it : spec.LocalSocket.Resources) {
+ auto& res = this->Resources[it.first];
+ for (auto const& specRes : it.second) {
+ res[specRes.Id].Total = specRes.Capacity;
+ res[specRes.Id].Locked = 0;
+ }
+ }
+}
+
+const std::map<std::string,
+ std::map<std::string, cmCTestResourceAllocator::Resource>>&
+cmCTestResourceAllocator::GetResources() const
+{
+ return this->Resources;
+}
+
+bool cmCTestResourceAllocator::AllocateResource(const std::string& name,
+ const std::string& id,
+ unsigned int slots)
+{
+ auto it = this->Resources.find(name);
+ if (it == this->Resources.end()) {
+ return false;
+ }
+
+ auto resIt = it->second.find(id);
+ if (resIt == it->second.end()) {
+ return false;
+ }
+
+ if (resIt->second.Total < resIt->second.Locked + slots) {
+ return false;
+ }
+
+ resIt->second.Locked += slots;
+ return true;
+}
+
+bool cmCTestResourceAllocator::DeallocateResource(const std::string& name,
+ const std::string& id,
+ unsigned int slots)
+{
+ auto it = this->Resources.find(name);
+ if (it == this->Resources.end()) {
+ return false;
+ }
+
+ auto resIt = it->second.find(id);
+ if (resIt == it->second.end()) {
+ return false;
+ }
+
+ if (resIt->second.Locked < slots) {
+ return false;
+ }
+
+ resIt->second.Locked -= slots;
+ return true;
+}
+
+bool cmCTestResourceAllocator::Resource::operator==(
+ const Resource& other) const
+{
+ return this->Total == other.Total && this->Locked == other.Locked;
+}
+
+bool cmCTestResourceAllocator::Resource::operator!=(
+ const Resource& other) const
+{
+ return !(*this == other);
+}
diff --git a/Source/CTest/cmCTestResourceAllocator.h b/Source/CTest/cmCTestResourceAllocator.h
new file mode 100644
index 000000000..9f0b9c95a
--- /dev/null
+++ b/Source/CTest/cmCTestResourceAllocator.h
@@ -0,0 +1,39 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmCTestResourceAllocator_h
+#define cmCTestResourceAllocator_h
+
+#include <map>
+#include <string>
+
+class cmCTestResourceSpec;
+
+class cmCTestResourceAllocator
+{
+public:
+ struct Resource
+ {
+ unsigned int Total;
+ unsigned int Locked;
+
+ unsigned int Free() const { return this->Total - this->Locked; }
+
+ bool operator==(const Resource& other) const;
+ bool operator!=(const Resource& other) const;
+ };
+
+ void InitializeFromResourceSpec(const cmCTestResourceSpec& spec);
+
+ const std::map<std::string, std::map<std::string, Resource>>& GetResources()
+ const;
+
+ bool AllocateResource(const std::string& name, const std::string& id,
+ unsigned int slots);
+ bool DeallocateResource(const std::string& name, const std::string& id,
+ unsigned int slots);
+
+private:
+ std::map<std::string, std::map<std::string, Resource>> Resources;
+};
+
+#endif
diff --git a/Source/CTest/cmCTestResourceGroupsLexerHelper.cxx b/Source/CTest/cmCTestResourceGroupsLexerHelper.cxx
new file mode 100644
index 000000000..072af42f0
--- /dev/null
+++ b/Source/CTest/cmCTestResourceGroupsLexerHelper.cxx
@@ -0,0 +1,55 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmCTestResourceGroupsLexerHelper.h"
+
+#include "cmCTestResourceGroupsLexer.h"
+#include "cmCTestTestHandler.h"
+
+cmCTestResourceGroupsLexerHelper::cmCTestResourceGroupsLexerHelper(
+ std::vector<std::vector<cmCTestTestHandler::cmCTestTestResourceRequirement>>&
+ output)
+ : Output(output)
+{
+}
+
+bool cmCTestResourceGroupsLexerHelper::ParseString(const std::string& value)
+{
+ yyscan_t lexer;
+ cmCTestResourceGroups_yylex_init_extra(this, &lexer);
+
+ auto state = cmCTestResourceGroups_yy_scan_string(value.c_str(), lexer);
+ int retval = cmCTestResourceGroups_yylex(lexer);
+ cmCTestResourceGroups_yy_delete_buffer(state, lexer);
+
+ cmCTestResourceGroups_yylex_destroy(lexer);
+ return retval == 0;
+}
+
+void cmCTestResourceGroupsLexerHelper::SetProcessCount(unsigned int count)
+{
+ this->ProcessCount = count;
+}
+
+void cmCTestResourceGroupsLexerHelper::SetResourceType(const std::string& type)
+{
+ this->ResourceType = type;
+}
+
+void cmCTestResourceGroupsLexerHelper::SetNeededSlots(int count)
+{
+ this->NeededSlots = count;
+}
+
+void cmCTestResourceGroupsLexerHelper::WriteRequirement()
+{
+ this->Process.push_back({ this->ResourceType, this->NeededSlots, 1 });
+}
+
+void cmCTestResourceGroupsLexerHelper::WriteProcess()
+{
+ for (unsigned int i = 0; i < this->ProcessCount; ++i) {
+ this->Output.push_back(this->Process);
+ }
+ this->Process.clear();
+ this->ProcessCount = 1;
+}
diff --git a/Source/CTest/cmCTestResourceGroupsLexerHelper.h b/Source/CTest/cmCTestResourceGroupsLexerHelper.h
new file mode 100644
index 000000000..2cb6cb1c5
--- /dev/null
+++ b/Source/CTest/cmCTestResourceGroupsLexerHelper.h
@@ -0,0 +1,44 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmCTestResourceGroupsLexerHelper_h
+#define cmCTestResourceGroupsLexerHelper_h
+
+#include <string>
+#include <vector>
+
+#include "cmCTestTestHandler.h"
+
+class cmCTestResourceGroupsLexerHelper
+{
+public:
+ struct ParserType
+ {
+ };
+
+ cmCTestResourceGroupsLexerHelper(
+ std::vector<
+ std::vector<cmCTestTestHandler::cmCTestTestResourceRequirement>>&
+ output);
+ ~cmCTestResourceGroupsLexerHelper() = default;
+
+ bool ParseString(const std::string& value);
+
+ void SetProcessCount(unsigned int count);
+ void SetResourceType(const std::string& type);
+ void SetNeededSlots(int count);
+ void WriteRequirement();
+ void WriteProcess();
+
+private:
+ std::vector<std::vector<cmCTestTestHandler::cmCTestTestResourceRequirement>>&
+ Output;
+
+ unsigned int ProcessCount = 1;
+ std::string ResourceType;
+ int NeededSlots;
+ std::vector<cmCTestTestHandler::cmCTestTestResourceRequirement> Process;
+};
+
+#define YY_EXTRA_TYPE cmCTestResourceGroupsLexerHelper*
+
+#endif
diff --git a/Source/CTest/cmCTestResourceSpec.cxx b/Source/CTest/cmCTestResourceSpec.cxx
new file mode 100644
index 000000000..8f91efb45
--- /dev/null
+++ b/Source/CTest/cmCTestResourceSpec.cxx
@@ -0,0 +1,198 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmCTestResourceSpec.h"
+
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "cmsys/FStream.hxx"
+#include "cmsys/RegularExpression.hxx"
+
+#include "cm_jsoncpp_reader.h"
+#include "cm_jsoncpp_value.h"
+
+static const cmsys::RegularExpression IdentifierRegex{ "^[a-z_][a-z0-9_]*$" };
+static const cmsys::RegularExpression IdRegex{ "^[a-z0-9_]+$" };
+
+cmCTestResourceSpec::ReadFileResult cmCTestResourceSpec::ReadFromJSONFile(
+ const std::string& filename)
+{
+ cmsys::ifstream fin(filename.c_str());
+ if (!fin) {
+ return ReadFileResult::FILE_NOT_FOUND;
+ }
+
+ Json::Value root;
+ Json::CharReaderBuilder builder;
+ if (!Json::parseFromStream(builder, fin, &root, nullptr)) {
+ return ReadFileResult::JSON_PARSE_ERROR;
+ }
+
+ if (!root.isObject()) {
+ return ReadFileResult::INVALID_ROOT;
+ }
+
+ int majorVersion = 1;
+ int minorVersion = 0;
+ if (root.isMember("version")) {
+ auto const& version = root["version"];
+ if (version.isObject()) {
+ if (!version.isMember("major") || !version.isMember("minor")) {
+ return ReadFileResult::INVALID_VERSION;
+ }
+ auto const& major = version["major"];
+ auto const& minor = version["minor"];
+ if (!major.isInt() || !minor.isInt()) {
+ return ReadFileResult::INVALID_VERSION;
+ }
+ majorVersion = major.asInt();
+ minorVersion = minor.asInt();
+ } else {
+ return ReadFileResult::INVALID_VERSION;
+ }
+ } else {
+ return ReadFileResult::NO_VERSION;
+ }
+
+ if (majorVersion != 1 || minorVersion != 0) {
+ return ReadFileResult::UNSUPPORTED_VERSION;
+ }
+
+ auto const& local = root["local"];
+ if (!local.isArray()) {
+ return ReadFileResult::INVALID_SOCKET_SPEC;
+ }
+ if (local.size() > 1) {
+ return ReadFileResult::INVALID_SOCKET_SPEC;
+ }
+
+ if (local.empty()) {
+ this->LocalSocket.Resources.clear();
+ return ReadFileResult::READ_OK;
+ }
+
+ auto const& localSocket = local[0];
+ if (!localSocket.isObject()) {
+ return ReadFileResult::INVALID_SOCKET_SPEC;
+ }
+ std::map<std::string, std::vector<cmCTestResourceSpec::Resource>> resources;
+ cmsys::RegularExpressionMatch match;
+ for (auto const& key : localSocket.getMemberNames()) {
+ if (IdentifierRegex.find(key.c_str(), match)) {
+ auto const& value = localSocket[key];
+ auto& r = resources[key];
+ if (value.isArray()) {
+ for (auto const& item : value) {
+ if (item.isObject()) {
+ cmCTestResourceSpec::Resource resource;
+
+ if (!item.isMember("id")) {
+ return ReadFileResult::INVALID_RESOURCE;
+ }
+ auto const& id = item["id"];
+ if (!id.isString()) {
+ return ReadFileResult::INVALID_RESOURCE;
+ }
+ resource.Id = id.asString();
+ if (!IdRegex.find(resource.Id.c_str(), match)) {
+ return ReadFileResult::INVALID_RESOURCE;
+ }
+
+ if (item.isMember("slots")) {
+ auto const& capacity = item["slots"];
+ if (!capacity.isConvertibleTo(Json::uintValue)) {
+ return ReadFileResult::INVALID_RESOURCE;
+ }
+ resource.Capacity = capacity.asUInt();
+ } else {
+ resource.Capacity = 1;
+ }
+
+ r.push_back(resource);
+ } else {
+ return ReadFileResult::INVALID_RESOURCE;
+ }
+ }
+ } else {
+ return ReadFileResult::INVALID_RESOURCE_TYPE;
+ }
+ }
+ }
+
+ this->LocalSocket.Resources = std::move(resources);
+ return ReadFileResult::READ_OK;
+}
+
+const char* cmCTestResourceSpec::ResultToString(ReadFileResult result)
+{
+ switch (result) {
+ case ReadFileResult::READ_OK:
+ return "OK";
+
+ case ReadFileResult::FILE_NOT_FOUND:
+ return "File not found";
+
+ case ReadFileResult::JSON_PARSE_ERROR:
+ return "JSON parse error";
+
+ case ReadFileResult::INVALID_ROOT:
+ return "Invalid root object";
+
+ case ReadFileResult::NO_VERSION:
+ return "No version specified";
+
+ case ReadFileResult::INVALID_VERSION:
+ return "Invalid version object";
+
+ case ReadFileResult::UNSUPPORTED_VERSION:
+ return "Unsupported version";
+
+ case ReadFileResult::INVALID_SOCKET_SPEC:
+ return "Invalid socket object";
+
+ case ReadFileResult::INVALID_RESOURCE_TYPE:
+ return "Invalid resource type object";
+
+ case ReadFileResult::INVALID_RESOURCE:
+ return "Invalid resource object";
+
+ default:
+ return "Unknown";
+ }
+}
+
+bool cmCTestResourceSpec::operator==(const cmCTestResourceSpec& other) const
+{
+ return this->LocalSocket == other.LocalSocket;
+}
+
+bool cmCTestResourceSpec::operator!=(const cmCTestResourceSpec& other) const
+{
+ return !(*this == other);
+}
+
+bool cmCTestResourceSpec::Socket::operator==(
+ const cmCTestResourceSpec::Socket& other) const
+{
+ return this->Resources == other.Resources;
+}
+
+bool cmCTestResourceSpec::Socket::operator!=(
+ const cmCTestResourceSpec::Socket& other) const
+{
+ return !(*this == other);
+}
+
+bool cmCTestResourceSpec::Resource::operator==(
+ const cmCTestResourceSpec::Resource& other) const
+{
+ return this->Id == other.Id && this->Capacity == other.Capacity;
+}
+
+bool cmCTestResourceSpec::Resource::operator!=(
+ const cmCTestResourceSpec::Resource& other) const
+{
+ return !(*this == other);
+}
diff --git a/Source/CTest/cmCTestResourceSpec.h b/Source/CTest/cmCTestResourceSpec.h
new file mode 100644
index 000000000..cb242c050
--- /dev/null
+++ b/Source/CTest/cmCTestResourceSpec.h
@@ -0,0 +1,55 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmCTestResourceSpec_h
+#define cmCTestResourceSpec_h
+
+#include <map>
+#include <string>
+#include <vector>
+
+class cmCTestResourceSpec
+{
+public:
+ class Resource
+ {
+ public:
+ std::string Id;
+ unsigned int Capacity;
+
+ bool operator==(const Resource& other) const;
+ bool operator!=(const Resource& other) const;
+ };
+
+ class Socket
+ {
+ public:
+ std::map<std::string, std::vector<Resource>> Resources;
+
+ bool operator==(const Socket& other) const;
+ bool operator!=(const Socket& other) const;
+ };
+
+ Socket LocalSocket;
+
+ enum class ReadFileResult
+ {
+ READ_OK,
+ FILE_NOT_FOUND,
+ JSON_PARSE_ERROR,
+ INVALID_ROOT,
+ NO_VERSION,
+ INVALID_VERSION,
+ UNSUPPORTED_VERSION,
+ INVALID_SOCKET_SPEC, // Can't be INVALID_SOCKET due to a Windows macro
+ INVALID_RESOURCE_TYPE,
+ INVALID_RESOURCE,
+ };
+
+ ReadFileResult ReadFromJSONFile(const std::string& filename);
+ static const char* ResultToString(ReadFileResult result);
+
+ bool operator==(const cmCTestResourceSpec& other) const;
+ bool operator!=(const cmCTestResourceSpec& other) const;
+};
+
+#endif
diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx
index 238284a3f..f59ca57de 100644
--- a/Source/CTest/cmCTestRunScriptCommand.cxx
+++ b/Source/CTest/cmCTestRunScriptCommand.cxx
@@ -5,8 +5,6 @@
#include "cmCTestScriptHandler.h"
#include "cmMakefile.h"
-#include <sstream>
-
class cmExecutionStatus;
bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
@@ -39,10 +37,9 @@ bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
++i;
} else {
int ret;
- cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np, &ret);
- std::ostringstream str;
- str << ret;
- this->Makefile->AddDefinition(returnVariable, str.str().c_str());
+ cmCTestScriptHandler::RunScript(this->CTest, this->Makefile,
+ args[i].c_str(), !np, &ret);
+ this->Makefile->AddDefinition(returnVariable, std::to_string(ret));
}
}
return true;
diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h
index 9bd09659d..2d8bde19d 100644
--- a/Source/CTest/cmCTestRunScriptCommand.h
+++ b/Source/CTest/cmCTestRunScriptCommand.h
@@ -3,14 +3,17 @@
#ifndef cmCTestRunScriptCommand_h
#define cmCTestRunScriptCommand_h
-#include "cmConfigure.h"
-
-#include "cmCTestCommand.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <utility>
#include <vector>
-class cmCommand;
+#include <cm/memory>
+
+#include "cmCTestCommand.h"
+#include "cmCommand.h"
+
class cmExecutionStatus;
/** \class cmCTestRunScript
@@ -27,12 +30,12 @@ public:
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE
+ std::unique_ptr<cmCommand> Clone() override
{
- cmCTestRunScriptCommand* ni = new cmCTestRunScriptCommand;
+ auto ni = cm::make_unique<cmCTestRunScriptCommand>();
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
- return ni;
+ return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
@@ -40,7 +43,7 @@ public:
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
+ cmExecutionStatus& status) override;
};
#endif
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 0c4269e3d..3091050f3 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -2,273 +2,226 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestRunTest.h"
+#include <chrono>
+#include <cstddef>
+#include <cstdint>
+#include <cstdio>
+#include <cstring>
+#include <iomanip>
+#include <ratio>
+#include <sstream>
+#include <utility>
+
+#include <cm/memory>
+
+#include "cmsys/RegularExpression.hxx"
+
#include "cmCTest.h"
#include "cmCTestMemCheckHandler.h"
-#include "cmCTestTestHandler.h"
+#include "cmCTestMultiProcessHandler.h"
#include "cmProcess.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
-#include "cmConfigure.h"
-#include "cm_curl.h"
-#include "cm_zlib.h"
-#include "cmsys/Base64.h"
-#include "cmsys/Process.h"
-#include "cmsys/RegularExpression.hxx"
-#include <iomanip>
-#include <sstream>
-#include <stdio.h>
-#include <time.h>
-#include <utility>
-
-cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler)
+cmCTestRunTest::cmCTestRunTest(cmCTestMultiProcessHandler& multiHandler)
+ : MultiTestHandler(multiHandler)
{
- this->CTest = handler->CTest;
- this->TestHandler = handler;
- this->TestProcess = CM_NULLPTR;
- this->TestResult.ExecutionTime = 0;
+ this->CTest = multiHandler.CTest;
+ this->TestHandler = multiHandler.TestHandler;
+ this->TestResult.ExecutionTime = cmDuration::zero();
this->TestResult.ReturnValue = 0;
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
this->TestResult.TestCount = 0;
- this->TestResult.Properties = CM_NULLPTR;
- this->ProcessOutput = "";
- this->CompressedOutput = "";
- this->CompressionRatio = 2;
- this->StopTimePassed = false;
+ this->TestResult.Properties = nullptr;
this->NumberOfRunsLeft = 1; // default to 1 run of the test
this->RunUntilFail = false; // default to run the test once
this->RunAgain = false; // default to not having to run again
}
-cmCTestRunTest::~cmCTestRunTest()
+void cmCTestRunTest::CheckOutput(std::string const& line)
{
-}
-
-bool cmCTestRunTest::CheckOutput()
-{
- // Read lines for up to 0.1 seconds of total time.
- double timeout = 0.1;
- double timeEnd = cmSystemTools::GetTime() + timeout;
- std::string line;
- while ((timeout = timeEnd - cmSystemTools::GetTime(), timeout > 0)) {
- int p = this->TestProcess->GetNextOutputLine(line, timeout);
- if (p == cmsysProcess_Pipe_None) {
- // Process has terminated and all output read.
- return false;
- }
- if (p == cmsysProcess_Pipe_STDOUT) {
- // Store this line of output.
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
- << ": " << line << std::endl);
- this->ProcessOutput += line;
- this->ProcessOutput += "\n";
-
- // Check for TIMEOUT_AFTER_MATCH property.
- if (!this->TestProperties->TimeoutRegularExpressions.empty()) {
- std::vector<
- std::pair<cmsys::RegularExpression, std::string> >::iterator regIt;
- for (regIt = this->TestProperties->TimeoutRegularExpressions.begin();
- regIt != this->TestProperties->TimeoutRegularExpressions.end();
- ++regIt) {
- if (regIt->first.find(this->ProcessOutput.c_str())) {
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
- << ": "
- << "Test timeout changed to "
- << this->TestProperties->AlternateTimeout
- << std::endl);
- this->TestProcess->ResetStartTime();
- this->TestProcess->ChangeTimeout(
- this->TestProperties->AlternateTimeout);
- this->TestProperties->TimeoutRegularExpressions.clear();
- break;
- }
- }
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ this->GetIndex() << ": " << line << std::endl);
+ this->ProcessOutput += line;
+ this->ProcessOutput += "\n";
+
+ // Check for TIMEOUT_AFTER_MATCH property.
+ if (!this->TestProperties->TimeoutRegularExpressions.empty()) {
+ for (auto& reg : this->TestProperties->TimeoutRegularExpressions) {
+ if (reg.first.find(this->ProcessOutput)) {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ this->GetIndex()
+ << ": "
+ << "Test timeout changed to "
+ << std::chrono::duration_cast<std::chrono::seconds>(
+ this->TestProperties->AlternateTimeout)
+ .count()
+ << std::endl);
+ this->TestProcess->ResetStartTime();
+ this->TestProcess->ChangeTimeout(
+ this->TestProperties->AlternateTimeout);
+ this->TestProperties->TimeoutRegularExpressions.clear();
+ break;
}
- } else { // if(p == cmsysProcess_Pipe_Timeout)
- break;
}
}
- return true;
-}
-
-// Streamed compression of test output. The compressed data
-// is appended to this->CompressedOutput
-void cmCTestRunTest::CompressOutput()
-{
- int ret;
- z_stream strm;
-
- unsigned char* in = reinterpret_cast<unsigned char*>(
- const_cast<char*>(this->ProcessOutput.c_str()));
- // zlib makes the guarantee that this is the maximum output size
- int outSize = static_cast<int>(
- static_cast<double>(this->ProcessOutput.size()) * 1.001 + 13.0);
- unsigned char* out = new unsigned char[outSize];
-
- strm.zalloc = Z_NULL;
- strm.zfree = Z_NULL;
- strm.opaque = Z_NULL;
- ret = deflateInit(&strm, -1); // default compression level
- if (ret != Z_OK) {
- delete[] out;
- return;
- }
-
- strm.avail_in = static_cast<uInt>(this->ProcessOutput.size());
- strm.next_in = in;
- strm.avail_out = outSize;
- strm.next_out = out;
- ret = deflate(&strm, Z_FINISH);
-
- if (ret != Z_STREAM_END) {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Error during output compression. Sending uncompressed output."
- << std::endl);
- delete[] out;
- return;
- }
-
- (void)deflateEnd(&strm);
-
- unsigned char* encoded_buffer =
- new unsigned char[static_cast<int>(outSize * 1.5)];
-
- size_t rlen = cmsysBase64_Encode(out, strm.total_out, encoded_buffer, 1);
-
- this->CompressedOutput.clear();
- for (size_t i = 0; i < rlen; i++) {
- this->CompressedOutput += encoded_buffer[i];
- }
-
- if (strm.total_in) {
- this->CompressionRatio =
- static_cast<double>(strm.total_out) / static_cast<double>(strm.total_in);
- }
-
- delete[] encoded_buffer;
- delete[] out;
}
bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
{
- if ((!this->TestHandler->MemCheck &&
- this->CTest->ShouldCompressTestOutput()) ||
- (this->TestHandler->MemCheck &&
- this->CTest->ShouldCompressTestOutput())) {
- this->CompressOutput();
- }
-
this->WriteLogOutputTop(completed, total);
std::string reason;
bool passed = true;
- int res =
- started ? this->TestProcess->GetProcessStatus() : cmsysProcess_State_Error;
- int retVal = this->TestProcess->GetExitValue();
- std::vector<std::pair<cmsys::RegularExpression, std::string> >::iterator
- passIt;
+ cmProcess::State res =
+ started ? this->TestProcess->GetProcessStatus() : cmProcess::State::Error;
+ if (res != cmProcess::State::Expired) {
+ this->TimeoutIsForStopTime = false;
+ }
+ std::int64_t retVal = this->TestProcess->GetExitValue();
bool forceFail = false;
+ bool forceSkip = false;
bool skipped = false;
bool outputTestErrorsToConsole = false;
if (!this->TestProperties->RequiredRegularExpressions.empty() &&
this->FailedDependencies.empty()) {
bool found = false;
- for (passIt = this->TestProperties->RequiredRegularExpressions.begin();
- passIt != this->TestProperties->RequiredRegularExpressions.end();
- ++passIt) {
- if (passIt->first.find(this->ProcessOutput.c_str())) {
+ for (auto& pass : this->TestProperties->RequiredRegularExpressions) {
+ if (pass.first.find(this->ProcessOutput)) {
found = true;
- reason = "Required regular expression found.";
+ reason = cmStrCat("Required regular expression found. Regex=[",
+ pass.second, ']');
break;
}
}
if (!found) {
- reason = "Required regular expression not found.";
+ reason = "Required regular expression not found. Regex=[";
+ for (auto& pass : this->TestProperties->RequiredRegularExpressions) {
+ reason += pass.second;
+ reason += "\n";
+ }
+ reason += "]";
forceFail = true;
}
- reason += "Regex=[";
- for (passIt = this->TestProperties->RequiredRegularExpressions.begin();
- passIt != this->TestProperties->RequiredRegularExpressions.end();
- ++passIt) {
- reason += passIt->second;
- reason += "\n";
- }
- reason += "]";
}
if (!this->TestProperties->ErrorRegularExpressions.empty() &&
this->FailedDependencies.empty()) {
- for (passIt = this->TestProperties->ErrorRegularExpressions.begin();
- passIt != this->TestProperties->ErrorRegularExpressions.end();
- ++passIt) {
- if (passIt->first.find(this->ProcessOutput.c_str())) {
- reason = "Error regular expression found in output.";
- reason += " Regex=[";
- reason += passIt->second;
- reason += "]";
+ for (auto& fail : this->TestProperties->ErrorRegularExpressions) {
+ if (fail.first.find(this->ProcessOutput)) {
+ reason = cmStrCat("Error regular expression found in output. Regex=[",
+ fail.second, ']');
forceFail = true;
break;
}
}
}
- if (res == cmsysProcess_State_Exited) {
+ if (!this->TestProperties->SkipRegularExpressions.empty() &&
+ this->FailedDependencies.empty()) {
+ for (auto& skip : this->TestProperties->SkipRegularExpressions) {
+ if (skip.first.find(this->ProcessOutput)) {
+ reason = cmStrCat("Skip regular expression found in output. Regex=[",
+ skip.second, ']');
+ forceSkip = true;
+ break;
+ }
+ }
+ }
+ std::ostringstream outputStream;
+ if (res == cmProcess::State::Exited) {
bool success = !forceFail &&
(retVal == 0 ||
!this->TestProperties->RequiredRegularExpressions.empty());
- if (this->TestProperties->SkipReturnCode >= 0 &&
- this->TestProperties->SkipReturnCode == retVal) {
+ if ((this->TestProperties->SkipReturnCode >= 0 &&
+ this->TestProperties->SkipReturnCode == retVal) ||
+ forceSkip) {
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
std::ostringstream s;
- s << "SKIP_RETURN_CODE=" << this->TestProperties->SkipReturnCode;
+ if (forceSkip) {
+ s << "SKIP_REGULAR_EXPRESSION_MATCHED";
+ } else {
+ s << "SKIP_RETURN_CODE=" << this->TestProperties->SkipReturnCode;
+ }
this->TestResult.CompletionStatus = s.str();
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Skipped ");
skipped = true;
- } else if ((success && !this->TestProperties->WillFail) ||
- (!success && this->TestProperties->WillFail)) {
+ } else if (success != this->TestProperties->WillFail) {
this->TestResult.Status = cmCTestTestHandler::COMPLETED;
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " Passed ");
+ outputStream << " Passed ";
} else {
this->TestResult.Status = cmCTestTestHandler::FAILED;
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Failed " << reason);
- outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
+ outputStream << "***Failed " << reason;
+ outputTestErrorsToConsole =
+ this->CTest->GetOutputTestOutputOnTestFailure();
}
- } else if (res == cmsysProcess_State_Expired) {
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Timeout ");
+ } else if (res == cmProcess::State::Expired) {
+ outputStream << "***Timeout ";
this->TestResult.Status = cmCTestTestHandler::TIMEOUT;
- outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
- } else if (res == cmsysProcess_State_Exception) {
- outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Exception: ");
+ outputTestErrorsToConsole =
+ this->CTest->GetOutputTestOutputOnTestFailure();
+ } else if (res == cmProcess::State::Exception) {
+ outputTestErrorsToConsole =
+ this->CTest->GetOutputTestOutputOnTestFailure();
+ outputStream << "***Exception: ";
+ this->TestResult.ExceptionStatus =
+ this->TestProcess->GetExitExceptionString();
switch (this->TestProcess->GetExitException()) {
- case cmsysProcess_Exception_Fault:
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "SegFault");
+ case cmProcess::Exception::Fault:
+ outputStream << "SegFault";
this->TestResult.Status = cmCTestTestHandler::SEGFAULT;
break;
- case cmsysProcess_Exception_Illegal:
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "Illegal");
+ case cmProcess::Exception::Illegal:
+ outputStream << "Illegal";
this->TestResult.Status = cmCTestTestHandler::ILLEGAL;
break;
- case cmsysProcess_Exception_Interrupt:
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "Interrupt");
+ case cmProcess::Exception::Interrupt:
+ outputStream << "Interrupt";
this->TestResult.Status = cmCTestTestHandler::INTERRUPT;
break;
- case cmsysProcess_Exception_Numerical:
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "Numerical");
+ case cmProcess::Exception::Numerical:
+ outputStream << "Numerical";
this->TestResult.Status = cmCTestTestHandler::NUMERICAL;
break;
default:
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "Other");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ this->TestResult.ExceptionStatus);
this->TestResult.Status = cmCTestTestHandler::OTHER_FAULT;
}
} else if ("Disabled" == this->TestResult.CompletionStatus) {
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run (Disabled) ");
- } else // cmsysProcess_State_Error
+ outputStream << "***Not Run (Disabled) ";
+ } else // cmProcess::State::Error
{
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run ");
+ outputStream << "***Not Run ";
}
passed = this->TestResult.Status == cmCTestTestHandler::COMPLETED;
char buf[1024];
- sprintf(buf, "%6.2f sec", this->TestProcess->GetTotalTime());
- cmCTestLog(this->CTest, HANDLER_OUTPUT, buf << "\n");
+ sprintf(buf, "%6.2f sec", this->TestProcess->GetTotalTime().count());
+ outputStream << buf << "\n";
+
+ if (this->CTest->GetTestProgressOutput()) {
+ if (!passed) {
+ // If the test did not pass, reprint test name and error
+ std::string output = GetTestPrefix(completed, total);
+ std::string testName = this->TestProperties->Name;
+ const int maxTestNameWidth = this->CTest->GetMaxTestNameWidth();
+ testName.resize(maxTestNameWidth + 4, '.');
+
+ output += testName;
+ output += outputStream.str();
+ outputStream.str("");
+ outputStream.clear();
+ outputStream << output;
+ cmCTestLog(this->CTest, HANDLER_TEST_PROGRESS_OUTPUT, "\n"); // flush
+ }
+ if (completed == total) {
+ std::string testName =
+ GetTestPrefix(completed, total) + this->TestProperties->Name + "\n";
+ cmCTestLog(this->CTest, HANDLER_TEST_PROGRESS_OUTPUT, testName);
+ }
+ }
+ if (!this->CTest->GetTestProgressOutput() || !passed) {
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, outputStream.str());
+ }
if (outputTestErrorsToConsole) {
cmCTestLog(this->CTest, HANDLER_OUTPUT, this->ProcessOutput << std::endl);
@@ -278,11 +231,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
*this->TestHandler->LogFile << "Test time = " << buf << std::endl;
}
- // Set the working directory to the tests directory to process Dart files.
- {
- cmWorkingDirectory workdir(this->TestProperties->Directory);
- this->DartProcessing();
- }
+ this->DartProcessing();
// if this is doing MemCheck then all the output needs to be put into
// Output since that is what is parsed by cmCTestMemCheckHandler
@@ -303,12 +252,16 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
reasonType = "Test Fail Reason";
pass = false;
}
- double ttime = this->TestProcess->GetTotalTime();
- int hours = static_cast<int>(ttime / (60 * 60));
- int minutes = static_cast<int>(ttime / 60) % 60;
- int seconds = static_cast<int>(ttime) % 60;
+ auto ttime = this->TestProcess->GetTotalTime();
+ auto hours = std::chrono::duration_cast<std::chrono::hours>(ttime);
+ ttime -= hours;
+ auto minutes = std::chrono::duration_cast<std::chrono::minutes>(ttime);
+ ttime -= minutes;
+ auto seconds = std::chrono::duration_cast<std::chrono::seconds>(ttime);
char buffer[100];
- sprintf(buffer, "%02d:%02d:%02d", hours, minutes, seconds);
+ sprintf(buffer, "%02d:%02d:%02d", static_cast<unsigned>(hours.count()),
+ static_cast<unsigned>(minutes.count()),
+ static_cast<unsigned>(seconds.count()));
*this->TestHandler->LogFile
<< "----------------------------------------------------------"
<< std::endl;
@@ -334,10 +287,18 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
// if the test actually started and ran
// record the results in TestResult
if (started) {
- bool compress = !this->TestHandler->MemCheck &&
- this->CompressionRatio < 1 && this->CTest->ShouldCompressTestOutput();
+ std::string compressedOutput;
+ if (!this->TestHandler->MemCheck &&
+ this->CTest->ShouldCompressTestOutput()) {
+ std::string str = this->ProcessOutput;
+ if (this->CTest->CompressString(str)) {
+ compressedOutput = std::move(str);
+ }
+ }
+ bool compress = !compressedOutput.empty() &&
+ compressedOutput.length() < this->ProcessOutput.length();
this->TestResult.Output =
- compress ? this->CompressedOutput : this->ProcessOutput;
+ compress ? compressedOutput : this->ProcessOutput;
this->TestResult.CompressOutput = compress;
this->TestResult.ReturnValue = this->TestProcess->GetExitValue();
if (!skipped) {
@@ -352,11 +313,11 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
if (!this->NeedsToRerun()) {
this->TestHandler->TestResults.push_back(this->TestResult);
}
- delete this->TestProcess;
+ this->TestProcess.reset();
return passed || skipped;
}
-bool cmCTestRunTest::StartAgain()
+bool cmCTestRunTest::StartAgain(size_t completed)
{
if (!this->RunAgain) {
return false;
@@ -364,7 +325,14 @@ bool cmCTestRunTest::StartAgain()
this->RunAgain = false; // reset
// change to tests directory
cmWorkingDirectory workdir(this->TestProperties->Directory);
- this->StartTest(this->TotalNumberOfTests);
+ if (workdir.Failed()) {
+ this->StartFailure("Failed to change working directory to " +
+ this->TestProperties->Directory + " : " +
+ std::strerror(workdir.GetLastResult()));
+ return true;
+ }
+
+ this->StartTest(completed, this->TotalNumberOfTests);
return true;
}
@@ -388,7 +356,7 @@ void cmCTestRunTest::ComputeWeightedCost()
{
double prev = static_cast<double>(this->TestProperties->PreviousRuns);
double avgcost = static_cast<double>(this->TestProperties->Cost);
- double current = this->TestResult.ExecutionTime;
+ double current = this->TestResult.ExecutionTime.count();
if (this->TestResult.Status == cmCTestTestHandler::COMPLETED) {
this->TestProperties->Cost =
@@ -402,144 +370,210 @@ void cmCTestRunTest::MemCheckPostProcess()
if (!this->TestHandler->MemCheck) {
return;
}
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
- << ": process test output now: "
- << this->TestProperties->Name << " "
- << this->TestResult.Name << std::endl,
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ this->Index << ": process test output now: "
+ << this->TestProperties->Name << " "
+ << this->TestResult.Name << std::endl,
this->TestHandler->GetQuiet());
cmCTestMemCheckHandler* handler =
static_cast<cmCTestMemCheckHandler*>(this->TestHandler);
handler->PostProcessTest(this->TestResult, this->Index);
}
+void cmCTestRunTest::StartFailure(std::string const& output)
+{
+ // Still need to log the Start message so the test summary records our
+ // attempt to start this test
+ if (!this->CTest->GetTestProgressOutput()) {
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ std::setw(2 * getNumWidth(this->TotalNumberOfTests) + 8)
+ << "Start "
+ << std::setw(getNumWidth(this->TestHandler->GetMaxIndex()))
+ << this->TestProperties->Index << ": "
+ << this->TestProperties->Name << std::endl);
+ }
+
+ this->ProcessOutput.clear();
+ if (!output.empty()) {
+ *this->TestHandler->LogFile << output << std::endl;
+ cmCTestLog(this->CTest, ERROR_MESSAGE, output << std::endl);
+ }
+
+ this->TestResult.Properties = this->TestProperties;
+ this->TestResult.ExecutionTime = cmDuration::zero();
+ this->TestResult.CompressOutput = false;
+ this->TestResult.ReturnValue = -1;
+ this->TestResult.CompletionStatus = "Failed to start";
+ this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
+ this->TestResult.TestCount = this->TestProperties->Index;
+ this->TestResult.Name = this->TestProperties->Name;
+ this->TestResult.Path = this->TestProperties->Directory;
+ this->TestResult.Output = output;
+ this->TestResult.FullCommandLine.clear();
+ this->TestProcess = cm::make_unique<cmProcess>(*this);
+}
+
+std::string cmCTestRunTest::GetTestPrefix(size_t completed, size_t total) const
+{
+ std::ostringstream outputStream;
+ outputStream << std::setw(getNumWidth(total)) << completed << "/";
+ outputStream << std::setw(getNumWidth(total)) << total << " ";
+
+ if (this->TestHandler->MemCheck) {
+ outputStream << "MemCheck";
+ } else {
+ outputStream << "Test";
+ }
+
+ std::ostringstream indexStr;
+ indexStr << " #" << this->Index << ":";
+ outputStream << std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex()))
+ << indexStr.str();
+ outputStream << " ";
+
+ return outputStream.str();
+}
+
// Starts the execution of a test. Returns once it has started
-bool cmCTestRunTest::StartTest(size_t total)
+bool cmCTestRunTest::StartTest(size_t completed, size_t total)
{
this->TotalNumberOfTests = total; // save for rerun case
- cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(2 * getNumWidth(total) + 8)
- << "Start "
- << std::setw(getNumWidth(this->TestHandler->GetMaxIndex()))
- << this->TestProperties->Index << ": "
- << this->TestProperties->Name << std::endl);
+ if (!this->CTest->GetTestProgressOutput()) {
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ std::setw(2 * getNumWidth(total) + 8)
+ << "Start "
+ << std::setw(getNumWidth(this->TestHandler->GetMaxIndex()))
+ << this->TestProperties->Index << ": "
+ << this->TestProperties->Name << std::endl);
+ } else {
+ std::string testName =
+ GetTestPrefix(completed, total) + this->TestProperties->Name + "\n";
+ cmCTestLog(this->CTest, HANDLER_TEST_PROGRESS_OUTPUT, testName);
+ }
+
this->ProcessOutput.clear();
+ this->TestResult.Properties = this->TestProperties;
+ this->TestResult.ExecutionTime = cmDuration::zero();
+ this->TestResult.CompressOutput = false;
+ this->TestResult.ReturnValue = -1;
+ this->TestResult.TestCount = this->TestProperties->Index;
+ this->TestResult.Name = this->TestProperties->Name;
+ this->TestResult.Path = this->TestProperties->Directory;
+
// Return immediately if test is disabled
if (this->TestProperties->Disabled) {
- this->TestResult.Properties = this->TestProperties;
- this->TestResult.ExecutionTime = 0;
- this->TestResult.CompressOutput = false;
- this->TestResult.ReturnValue = -1;
this->TestResult.CompletionStatus = "Disabled";
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
- this->TestResult.TestCount = this->TestProperties->Index;
- this->TestResult.Name = this->TestProperties->Name;
- this->TestResult.Path = this->TestProperties->Directory;
- this->TestProcess = new cmProcess;
+ this->TestProcess = cm::make_unique<cmProcess>(*this);
this->TestResult.Output = "Disabled";
- this->TestResult.FullCommandLine = "";
+ this->TestResult.FullCommandLine.clear();
return false;
}
- this->ComputeArguments();
- std::vector<std::string>& args = this->TestProperties->Args;
- this->TestResult.Properties = this->TestProperties;
- this->TestResult.ExecutionTime = 0;
- this->TestResult.CompressOutput = false;
- this->TestResult.ReturnValue = -1;
this->TestResult.CompletionStatus = "Failed to start";
this->TestResult.Status = cmCTestTestHandler::BAD_COMMAND;
- this->TestResult.TestCount = this->TestProperties->Index;
- this->TestResult.Name = this->TestProperties->Name;
- this->TestResult.Path = this->TestProperties->Directory;
+ // Check for failed fixture dependencies before we even look at the command
+ // arguments because if we are not going to run the test, the command and
+ // its arguments are irrelevant. This matters for the case where a fixture
+ // dependency might be creating the executable we want to run.
if (!this->FailedDependencies.empty()) {
- this->TestProcess = new cmProcess;
+ this->TestProcess = cm::make_unique<cmProcess>(*this);
std::string msg = "Failed test dependencies:";
- for (std::set<std::string>::const_iterator it =
- this->FailedDependencies.begin();
- it != this->FailedDependencies.end(); ++it) {
- msg += " " + *it;
+ for (std::string const& failedDep : this->FailedDependencies) {
+ msg += " " + failedDep;
}
*this->TestHandler->LogFile << msg << std::endl;
cmCTestLog(this->CTest, HANDLER_OUTPUT, msg << std::endl);
this->TestResult.Output = msg;
- this->TestResult.FullCommandLine = "";
+ this->TestResult.FullCommandLine.clear();
this->TestResult.CompletionStatus = "Fixture dependency failed";
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
return false;
}
+ this->ComputeArguments();
+ std::vector<std::string>& args = this->TestProperties->Args;
if (args.size() >= 2 && args[1] == "NOT_AVAILABLE") {
- this->TestProcess = new cmProcess;
+ this->TestProcess = cm::make_unique<cmProcess>(*this);
std::string msg;
if (this->CTest->GetConfigType().empty()) {
- msg = "Test not available without configuration.";
- msg += " (Missing \"-C <config>\"?)";
+ msg = "Test not available without configuration. (Missing \"-C "
+ "<config>\"?)";
} else {
- msg = "Test not available in configuration \"";
- msg += this->CTest->GetConfigType();
- msg += "\".";
+ msg = cmStrCat("Test not available in configuration \"",
+ this->CTest->GetConfigType(), "\".");
}
*this->TestHandler->LogFile << msg << std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE, msg << std::endl);
this->TestResult.Output = msg;
- this->TestResult.FullCommandLine = "";
+ this->TestResult.FullCommandLine.clear();
this->TestResult.CompletionStatus = "Missing Configuration";
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
return false;
}
// Check if all required files exist
- for (std::vector<std::string>::iterator i =
- this->TestProperties->RequiredFiles.begin();
- i != this->TestProperties->RequiredFiles.end(); ++i) {
- std::string file = *i;
-
- if (!cmSystemTools::FileExists(file.c_str())) {
+ for (std::string const& file : this->TestProperties->RequiredFiles) {
+ if (!cmSystemTools::FileExists(file)) {
// Required file was not found
- this->TestProcess = new cmProcess;
+ this->TestProcess = cm::make_unique<cmProcess>(*this);
*this->TestHandler->LogFile << "Unable to find required file: " << file
<< std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Unable to find required file: " << file << std::endl);
this->TestResult.Output = "Unable to find required file: " + file;
- this->TestResult.FullCommandLine = "";
+ this->TestResult.FullCommandLine.clear();
this->TestResult.CompletionStatus = "Required Files Missing";
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
return false;
}
}
// log and return if we did not find the executable
- if (this->ActualCommand == "") {
+ if (this->ActualCommand.empty()) {
// if the command was not found create a TestResult object
// that has that information
- this->TestProcess = new cmProcess;
+ this->TestProcess = cm::make_unique<cmProcess>(*this);
*this->TestHandler->LogFile << "Unable to find executable: " << args[1]
<< std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Unable to find executable: " << args[1] << std::endl);
this->TestResult.Output = "Unable to find executable: " + args[1];
- this->TestResult.FullCommandLine = "";
+ this->TestResult.FullCommandLine.clear();
this->TestResult.CompletionStatus = "Unable to find executable";
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
return false;
}
this->StartTime = this->CTest->CurrentTime();
- double timeout = this->ResolveTimeout();
+ auto timeout = this->TestProperties->Timeout;
- if (this->StopTimePassed) {
- return false;
+ this->TimeoutIsForStopTime = false;
+ std::chrono::system_clock::time_point stop_time = this->CTest->GetStopTime();
+ if (stop_time != std::chrono::system_clock::time_point()) {
+ std::chrono::duration<double> stop_timeout =
+ (stop_time - std::chrono::system_clock::now()) % std::chrono::hours(24);
+
+ if (stop_timeout <= std::chrono::duration<double>::zero()) {
+ stop_timeout = std::chrono::duration<double>::zero();
+ }
+ if (timeout == std::chrono::duration<double>::zero() ||
+ stop_timeout < timeout) {
+ this->TimeoutIsForStopTime = true;
+ timeout = stop_timeout;
+ }
}
+
return this->ForkProcess(timeout, this->TestProperties->ExplicitTimeout,
- &this->TestProperties->Environment);
+ &this->TestProperties->Environment,
+ &this->TestProperties->Affinity);
}
void cmCTestRunTest::ComputeArguments()
{
- this->Arguments.clear(); // reset becaue this might be a rerun
- std::vector<std::string>::const_iterator j =
- this->TestProperties->Args.begin();
+ this->Arguments.clear(); // reset because this might be a rerun
+ auto j = this->TestProperties->Args.begin();
++j; // skip test name
// find the test executable
if (this->TestHandler->MemCheck) {
@@ -554,14 +588,13 @@ void cmCTestRunTest::ComputeArguments()
++j; // skip the executable (it will be actualCommand)
}
std::string testCommand =
- cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str());
+ cmSystemTools::ConvertToOutputPath(this->ActualCommand);
// Prepends memcheck args to our command string
this->TestHandler->GenerateTestCommand(this->Arguments, this->Index);
- for (std::vector<std::string>::iterator i = this->Arguments.begin();
- i != this->Arguments.end(); ++i) {
+ for (std::string const& arg : this->Arguments) {
testCommand += " \"";
- testCommand += *i;
+ testCommand += arg;
testCommand += "\"";
}
@@ -574,22 +607,21 @@ void cmCTestRunTest::ComputeArguments()
this->TestResult.FullCommandLine = testCommand;
// Print the test command in verbose mode
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ std::endl
<< this->Index << ": "
<< (this->TestHandler->MemCheck ? "MemCheck" : "Test")
<< " command: " << testCommand << std::endl);
// Print any test-specific env vars in verbose mode
if (!this->TestProperties->Environment.empty()) {
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
- << ": "
- << "Environment variables: " << std::endl);
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ this->Index << ": "
+ << "Environment variables: " << std::endl);
}
- for (std::vector<std::string>::const_iterator e =
- this->TestProperties->Environment.begin();
- e != this->TestProperties->Environment.end(); ++e) {
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": " << *e
- << std::endl);
+ for (std::string const& env : this->TestProperties->Environment) {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ this->Index << ": " << env << std::endl);
}
}
@@ -597,10 +629,10 @@ void cmCTestRunTest::DartProcessing()
{
if (!this->ProcessOutput.empty() &&
this->ProcessOutput.find("<DartMeasurement") != std::string::npos) {
- if (this->TestHandler->DartStuff.find(this->ProcessOutput.c_str())) {
+ if (this->TestHandler->DartStuff.find(this->ProcessOutput)) {
this->TestResult.DartString = this->TestHandler->DartStuff.match(1);
// keep searching and replacing until none are left
- while (this->TestHandler->DartStuff1.find(this->ProcessOutput.c_str())) {
+ while (this->TestHandler->DartStuff1.find(this->ProcessOutput)) {
// replace the exact match for the string
cmSystemTools::ReplaceString(
this->ProcessOutput, this->TestHandler->DartStuff1.match(1).c_str(),
@@ -610,97 +642,47 @@ void cmCTestRunTest::DartProcessing()
}
}
-double cmCTestRunTest::ResolveTimeout()
-{
- double timeout = this->TestProperties->Timeout;
-
- if (this->CTest->GetStopTime() == "") {
- return timeout;
- }
- struct tm* lctime;
- time_t current_time = time(CM_NULLPTR);
- lctime = gmtime(&current_time);
- int gm_hour = lctime->tm_hour;
- time_t gm_time = mktime(lctime);
- lctime = localtime(&current_time);
- int local_hour = lctime->tm_hour;
-
- int tzone_offset = local_hour - gm_hour;
- if (gm_time > current_time && gm_hour < local_hour) {
- // this means gm_time is on the next day
- tzone_offset -= 24;
- } else if (gm_time < current_time && gm_hour > local_hour) {
- // this means gm_time is on the previous day
- tzone_offset += 24;
- }
-
- tzone_offset *= 100;
- char buf[1024];
- // add todays year day and month to the time in str because
- // curl_getdate no longer assumes the day is today
- sprintf(buf, "%d%02d%02d %s %+05i", lctime->tm_year + 1900,
- lctime->tm_mon + 1, lctime->tm_mday,
- this->CTest->GetStopTime().c_str(), tzone_offset);
-
- time_t stop_time = curl_getdate(buf, &current_time);
- if (stop_time == -1) {
- return timeout;
- }
-
- // the stop time refers to the next day
- if (this->CTest->NextDayStopTime) {
- stop_time += 24 * 60 * 60;
- }
- int stop_timeout =
- static_cast<int>(stop_time - current_time) % (24 * 60 * 60);
- this->CTest->LastStopTimeout = stop_timeout;
-
- if (stop_timeout <= 0 || stop_timeout > this->CTest->LastStopTimeout) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "The stop time has been passed. "
- "Stopping all tests."
- << std::endl);
- this->StopTimePassed = true;
- return 0;
- }
- return timeout == 0 ? stop_timeout
- : (timeout < stop_timeout ? timeout : stop_timeout);
-}
-
-bool cmCTestRunTest::ForkProcess(double testTimeOut, bool explicitTimeout,
- std::vector<std::string>* environment)
+bool cmCTestRunTest::ForkProcess(cmDuration testTimeOut, bool explicitTimeout,
+ std::vector<std::string>* environment,
+ std::vector<size_t>* affinity)
{
- this->TestProcess = new cmProcess;
+ this->TestProcess = cm::make_unique<cmProcess>(*this);
this->TestProcess->SetId(this->Index);
- this->TestProcess->SetWorkingDirectory(
- this->TestProperties->Directory.c_str());
- this->TestProcess->SetCommand(this->ActualCommand.c_str());
+ this->TestProcess->SetWorkingDirectory(this->TestProperties->Directory);
+ this->TestProcess->SetCommand(this->ActualCommand);
this->TestProcess->SetCommandArguments(this->Arguments);
// determine how much time we have
- double timeout = this->CTest->GetRemainingTimeAllowed() - 120;
- if (this->CTest->GetTimeOut() > 0 && this->CTest->GetTimeOut() < timeout) {
+ cmDuration timeout = this->CTest->GetRemainingTimeAllowed();
+ if (timeout != cmCTest::MaxDuration()) {
+ timeout -= std::chrono::minutes(2);
+ }
+ if (this->CTest->GetTimeOut() > cmDuration::zero() &&
+ this->CTest->GetTimeOut() < timeout) {
timeout = this->CTest->GetTimeOut();
}
- if (testTimeOut > 0 &&
+ if (testTimeOut > cmDuration::zero() &&
testTimeOut < this->CTest->GetRemainingTimeAllowed()) {
timeout = testTimeOut;
}
// always have at least 1 second if we got to here
- if (timeout <= 0) {
- timeout = 1;
+ if (timeout <= cmDuration::zero()) {
+ timeout = std::chrono::seconds(1);
}
// handle timeout explicitly set to 0
- if (testTimeOut == 0 && explicitTimeout) {
- timeout = 0;
- }
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
- << ": "
- << "Test timeout computed to be: " << timeout << "\n",
+ if (testTimeOut == cmDuration::zero() && explicitTimeout) {
+ timeout = cmDuration::zero();
+ }
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ this->Index << ": "
+ << "Test timeout computed to be: "
+ << cmDurationTo<unsigned int>(timeout)
+ << "\n",
this->TestHandler->GetQuiet());
this->TestProcess->SetTimeout(timeout);
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmSystemTools::SaveRestoreEnvironment sre;
#endif
@@ -708,49 +690,89 @@ bool cmCTestRunTest::ForkProcess(double testTimeOut, bool explicitTimeout,
cmSystemTools::AppendEnv(*environment);
}
- return this->TestProcess->StartProcess();
+ if (this->UseAllocatedResources) {
+ this->SetupResourcesEnvironment();
+ } else {
+ cmSystemTools::UnsetEnv("CTEST_RESOURCE_GROUP_COUNT");
+ }
+
+ return this->TestProcess->StartProcess(this->MultiTestHandler.Loop,
+ affinity);
+}
+
+void cmCTestRunTest::SetupResourcesEnvironment()
+{
+ std::string processCount = "CTEST_RESOURCE_GROUP_COUNT=";
+ processCount += std::to_string(this->AllocatedResources.size());
+ cmSystemTools::PutEnv(processCount);
+
+ std::size_t i = 0;
+ for (auto const& process : this->AllocatedResources) {
+ std::string prefix = "CTEST_RESOURCE_GROUP_";
+ prefix += std::to_string(i);
+ std::string resourceList = prefix + '=';
+ prefix += '_';
+ bool firstType = true;
+ for (auto const& it : process) {
+ if (!firstType) {
+ resourceList += ',';
+ }
+ firstType = false;
+ auto resourceType = it.first;
+ resourceList += resourceType;
+ std::string var = prefix + cmSystemTools::UpperCase(resourceType) + '=';
+ bool firstName = true;
+ for (auto const& it2 : it.second) {
+ if (!firstName) {
+ var += ';';
+ }
+ firstName = false;
+ var += "id:" + it2.Id + ",slots:" + std::to_string(it2.Slots);
+ }
+ cmSystemTools::PutEnv(var);
+ }
+ cmSystemTools::PutEnv(resourceList);
+ ++i;
+ }
}
void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total)
{
- // if this is the last or only run of this test
- // then print out completed / total
+ std::ostringstream outputStream;
+
+ // If this is the last or only run of this test, or progress output is
+ // requested, then print out completed / total.
// Only issue is if a test fails and we are running until fail
// then it will never print out the completed / total, same would
// got for run until pass. Trick is when this is called we don't
// yet know if we are passing or failing.
- if (this->NumberOfRunsLeft == 1) {
- cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total))
- << completed << "/");
- cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total))
- << total << " ");
+ if (this->NumberOfRunsLeft == 1 || this->CTest->GetTestProgressOutput()) {
+ outputStream << std::setw(getNumWidth(total)) << completed << "/";
+ outputStream << std::setw(getNumWidth(total)) << total << " ";
}
// if this is one of several runs of a test just print blank space
// to keep things neat
else {
- cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total))
- << " "
- << " ");
- cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(getNumWidth(total))
- << " "
- << " ");
+ outputStream << std::setw(getNumWidth(total)) << " ";
+ outputStream << std::setw(getNumWidth(total)) << " ";
}
if (this->TestHandler->MemCheck) {
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "MemCheck");
+ outputStream << "MemCheck";
} else {
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "Test");
+ outputStream << "Test";
}
std::ostringstream indexStr;
indexStr << " #" << this->Index << ":";
- cmCTestLog(this->CTest, HANDLER_OUTPUT,
- std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex()))
- << indexStr.str());
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " ");
+ outputStream << std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex()))
+ << indexStr.str();
+ outputStream << " ";
+
const int maxTestNameWidth = this->CTest->GetMaxTestNameWidth();
std::string outname = this->TestProperties->Name + " ";
outname.resize(maxTestNameWidth + 4, '.');
+ outputStream << outname;
*this->TestHandler->LogFile << this->TestProperties->Index << "/"
<< this->TestHandler->TotalNumberOfTests
@@ -762,9 +784,8 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total)
<< std::endl;
*this->TestHandler->LogFile << "Command: \"" << this->ActualCommand << "\"";
- for (std::vector<std::string>::iterator i = this->Arguments.begin();
- i != this->Arguments.end(); ++i) {
- *this->TestHandler->LogFile << " \"" << *i << "\"";
+ for (std::string const& arg : this->Arguments) {
+ *this->TestHandler->LogFile << " \"" << arg << "\"";
}
*this->TestHandler->LogFile
<< std::endl
@@ -779,7 +800,15 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total)
*this->TestHandler->LogFile << this->ProcessOutput << "<end of output>"
<< std::endl;
- cmCTestLog(this->CTest, HANDLER_OUTPUT, outname.c_str());
- cmCTestLog(this->CTest, DEBUG, "Testing " << this->TestProperties->Name
- << " ... ");
+ if (!this->CTest->GetTestProgressOutput()) {
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, outputStream.str());
+ }
+
+ cmCTestLog(this->CTest, DEBUG,
+ "Testing " << this->TestProperties->Name << " ... ");
+}
+
+void cmCTestRunTest::FinalizeTest()
+{
+ this->MultiTestHandler.FinishTestProcess(this, true);
}
diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h
index d3bb2296f..f781c7ab0 100644
--- a/Source/CTest/cmCTestRunTest.h
+++ b/Source/CTest/cmCTestRunTest.h
@@ -5,15 +5,20 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <map>
+#include <memory>
#include <set>
-#include <stddef.h>
#include <string>
#include <vector>
+#include <stddef.h>
+
+#include "cmCTestMultiProcessHandler.h"
#include "cmCTestTestHandler.h"
+#include "cmDuration.h"
+#include "cmProcess.h"
class cmCTest;
-class cmProcess;
/** \class cmRunTest
* \brief represents a single test to be run
@@ -23,8 +28,7 @@ class cmProcess;
class cmCTestRunTest
{
public:
- cmCTestRunTest(cmCTestTestHandler* handler);
- ~cmCTestRunTest();
+ explicit cmCTestRunTest(cmCTestMultiProcessHandler& multiHandler);
void SetNumberOfRuns(int n) { this->NumberOfRunsLeft = n; }
void SetRunUntilFailOn() { this->RunUntilFail = true; }
@@ -49,21 +53,16 @@ public:
std::string GetProcessOutput() { return this->ProcessOutput; }
- bool IsStopTimePassed() { return this->StopTimePassed; }
-
cmCTestTestHandler::cmCTestTestResult GetTestResults()
{
return this->TestResult;
}
// Read and store output. Returns true if it must be called again.
- bool CheckOutput();
-
- // Compresses the output, writing to CompressedOutput
- void CompressOutput();
+ void CheckOutput(std::string const& line);
// launch the test process, return whether it started correctly
- bool StartTest(size_t total);
+ bool StartTest(size_t completed, size_t total);
// capture and report the test results
bool EndTest(size_t completed, size_t total, bool started);
// Called by ctest -N to log the command string
@@ -71,44 +70,68 @@ public:
void ComputeWeightedCost();
- bool StartAgain();
+ bool StartAgain(size_t completed);
+
+ void StartFailure(std::string const& output);
+
+ cmCTest* GetCTest() const { return this->CTest; }
+
+ std::string& GetActualCommand() { return this->ActualCommand; }
+
+ const std::vector<std::string>& GetArguments() { return this->Arguments; }
+
+ void FinalizeTest();
+
+ bool TimedOutForStopTime() const { return this->TimeoutIsForStopTime; }
+
+ void SetUseAllocatedResources(bool use)
+ {
+ this->UseAllocatedResources = use;
+ }
+ void SetAllocatedResources(
+ const std::vector<
+ std::map<std::string,
+ std::vector<cmCTestMultiProcessHandler::ResourceAllocation>>>&
+ resources)
+ {
+ this->AllocatedResources = resources;
+ }
private:
bool NeedsToRerun();
void DartProcessing();
void ExeNotFound(std::string exe);
- // Figures out a final timeout which is min(STOP_TIME, NOW+TIMEOUT)
- double ResolveTimeout();
- bool ForkProcess(double testTimeOut, bool explicitTimeout,
- std::vector<std::string>* environment);
+ bool ForkProcess(cmDuration testTimeOut, bool explicitTimeout,
+ std::vector<std::string>* environment,
+ std::vector<size_t>* affinity);
void WriteLogOutputTop(size_t completed, size_t total);
// Run post processing of the process output for MemCheck
void MemCheckPostProcess();
+ void SetupResourcesEnvironment();
+
+ // Returns "completed/total Test #Index: "
+ std::string GetTestPrefix(size_t completed, size_t total) const;
+
cmCTestTestHandler::cmCTestTestProperties* TestProperties;
+ bool TimeoutIsForStopTime = false;
// Pointer back to the "parent"; the handler that invoked this test run
cmCTestTestHandler* TestHandler;
cmCTest* CTest;
- cmProcess* TestProcess;
- // If the executable to run is ctest, don't create a new process;
- // just instantiate a new cmTest. (Can be disabled for a single test
- // if this option is set to false.)
- // bool OptimizeForCTest;
-
- bool UsePrefixCommand;
- std::string PrefixCommand;
-
+ std::unique_ptr<cmProcess> TestProcess;
std::string ProcessOutput;
- std::string CompressedOutput;
- double CompressionRatio;
// The test results
cmCTestTestHandler::cmCTestTestResult TestResult;
+ cmCTestMultiProcessHandler& MultiTestHandler;
int Index;
std::set<std::string> FailedDependencies;
std::string StartTime;
std::string ActualCommand;
std::vector<std::string> Arguments;
- bool StopTimePassed;
+ bool UseAllocatedResources = false;
+ std::vector<std::map<
+ std::string, std::vector<cmCTestMultiProcessHandler::ResourceAllocation>>>
+ AllocatedResources;
bool RunUntilFail;
int NumberOfRunsLeft;
bool RunAgain;
@@ -117,14 +140,12 @@ private:
inline int getNumWidth(size_t n)
{
- int numWidth = 1;
- if (n >= 10) {
- numWidth = 2;
- }
- if (n >= 100) {
- numWidth = 3;
+ int w = 1;
+ while (n >= 10) {
+ n /= 10;
+ ++w;
}
- return numWidth;
+ return w;
}
#endif
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index f60f78c21..34395c9fe 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -2,19 +2,22 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestSVN.h"
+#include <cstdlib>
+#include <cstring>
+#include <map>
+#include <ostream>
+
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestVC.h"
#include "cmProcessTools.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmXMLParser.h"
#include "cmXMLWriter.h"
-#include "cmsys/RegularExpression.hxx"
-#include <map>
-#include <ostream>
-#include <stdlib.h>
-#include <string.h>
-
struct cmCTestSVN::Revision : public cmCTestVC::Revision
{
cmCTestSVN::SVNInfo* SVNInfo;
@@ -26,9 +29,7 @@ cmCTestSVN::cmCTestSVN(cmCTest* ct, std::ostream& log)
this->PriorRev = this->Unknown;
}
-cmCTestSVN::~cmCTestSVN()
-{
-}
+cmCTestSVN::~cmCTestSVN() = default;
void cmCTestSVN::CleanupImpl()
{
@@ -59,7 +60,7 @@ private:
cmsys::RegularExpression RegexRev;
cmsys::RegularExpression RegexURL;
cmsys::RegularExpression RegexRoot;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexRev.find(this->Line)) {
this->Rev = this->RegexRev.match(1);
@@ -103,16 +104,14 @@ bool cmCTestSVN::NoteOldRevision()
return false;
}
- std::vector<SVNInfo>::iterator itbeg = this->Repositories.begin();
- std::vector<SVNInfo>::iterator itend = this->Repositories.end();
- for (; itbeg != itend; itbeg++) {
- SVNInfo& svninfo = *itbeg;
+ for (SVNInfo& svninfo : this->Repositories) {
svninfo.OldRevision = this->LoadInfo(svninfo);
this->Log << "Revision for repository '" << svninfo.LocalPath
<< "' before update: " << svninfo.OldRevision << "\n";
- cmCTestLog(
- this->CTest, HANDLER_OUTPUT, " Old revision of external repository '"
- << svninfo.LocalPath << "' is: " << svninfo.OldRevision << "\n");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " Old revision of external repository '"
+ << svninfo.LocalPath << "' is: " << svninfo.OldRevision
+ << "\n");
}
// Set the global old revision to the one of the root
@@ -127,16 +126,14 @@ bool cmCTestSVN::NoteNewRevision()
return false;
}
- std::vector<SVNInfo>::iterator itbeg = this->Repositories.begin();
- std::vector<SVNInfo>::iterator itend = this->Repositories.end();
- for (; itbeg != itend; itbeg++) {
- SVNInfo& svninfo = *itbeg;
+ for (SVNInfo& svninfo : this->Repositories) {
svninfo.NewRevision = this->LoadInfo(svninfo);
this->Log << "Revision for repository '" << svninfo.LocalPath
<< "' after update: " << svninfo.NewRevision << "\n";
- cmCTestLog(
- this->CTest, HANDLER_OUTPUT, " New revision of external repository '"
- << svninfo.LocalPath << "' is: " << svninfo.NewRevision << "\n");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " New revision of external repository '"
+ << svninfo.LocalPath << "' is: " << svninfo.NewRevision
+ << "\n");
// svninfo.Root = ""; // uncomment to test GuessBase
this->Log << "Repository '" << svninfo.LocalPath
@@ -148,9 +145,8 @@ bool cmCTestSVN::NoteNewRevision()
// the repository root.
if (!svninfo.Root.empty() &&
cmCTestSVNPathStarts(svninfo.URL, svninfo.Root)) {
- svninfo.Base =
- cmCTest::DecodeURL(svninfo.URL.substr(svninfo.Root.size()));
- svninfo.Base += "/";
+ svninfo.Base = cmStrCat(
+ cmCTest::DecodeURL(svninfo.URL.substr(svninfo.Root.size())), '/');
}
this->Log << "Repository '" << svninfo.LocalPath
<< "' Base = " << svninfo.Base << "\n";
@@ -174,7 +170,7 @@ void cmCTestSVN::GuessBase(SVNInfo& svninfo,
slash = svninfo.URL.find('/', slash + 1)) {
// If the URL suffix is a prefix of at least one path then it is the base.
std::string base = cmCTest::DecodeURL(svninfo.URL.substr(slash));
- for (std::vector<Change>::const_iterator ci = changes.begin();
+ for (auto ci = changes.begin();
svninfo.Base.empty() && ci != changes.end(); ++ci) {
if (cmCTestSVNPathStarts(ci->Path, base)) {
svninfo.Base = base;
@@ -205,7 +201,7 @@ private:
cmCTestSVN* SVN;
cmsys::RegularExpression RegexUpdate;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexUpdate.find(this->Line)) {
this->DoPath(this->RegexUpdate.match(1)[0],
@@ -248,7 +244,7 @@ bool cmCTestSVN::UpdateImpl()
if (opts.empty()) {
opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions");
}
- std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
+ std::vector<std::string> args = cmSystemTools::ParseArguments(opts);
// Specify the start time for nightly testing.
if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) {
@@ -257,9 +253,8 @@ bool cmCTestSVN::UpdateImpl()
std::vector<char const*> svn_update;
svn_update.push_back("update");
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- svn_update.push_back(ai->c_str());
+ for (std::string const& arg : args) {
+ svn_update.push_back(arg.c_str());
}
UpdateParser out(this, "up-out> ");
@@ -276,21 +271,18 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
std::vector<char const*> args;
args.push_back(this->CommandLineTool.c_str());
-
- args.insert(args.end(), parameters.begin(), parameters.end());
-
+ cmAppend(args, parameters);
args.push_back("--non-interactive");
std::string userOptions = this->CTest->GetCTestConfiguration("SVNOptions");
std::vector<std::string> parsedUserOptions =
- cmSystemTools::ParseArguments(userOptions.c_str());
- for (std::vector<std::string>::iterator i = parsedUserOptions.begin();
- i != parsedUserOptions.end(); ++i) {
- args.push_back(i->c_str());
+ cmSystemTools::ParseArguments(userOptions);
+ for (std::string const& opt : parsedUserOptions) {
+ args.push_back(opt.c_str());
}
- args.push_back(CM_NULLPTR);
+ args.push_back(nullptr);
if (strcmp(parameters[0], "update") == 0) {
return RunUpdateCommand(&args[0], out, err);
@@ -298,8 +290,9 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
return RunChild(&args[0], out, err);
}
-class cmCTestSVN::LogParser : public cmCTestVC::OutputLogger,
- private cmXMLParser
+class cmCTestSVN::LogParser
+ : public cmCTestVC::OutputLogger
+ , private cmXMLParser
{
public:
LogParser(cmCTestSVN* svn, const char* prefix, SVNInfo& svninfo)
@@ -309,49 +302,52 @@ public:
{
this->InitializeParser();
}
- ~LogParser() CM_OVERRIDE { this->CleanupParser(); }
+ ~LogParser() override { this->CleanupParser(); }
+
private:
cmCTestSVN* SVN;
cmCTestSVN::SVNInfo& SVNRepo;
- typedef cmCTestSVN::Revision Revision;
- typedef cmCTestSVN::Change Change;
+ using Revision = cmCTestSVN::Revision;
+ using Change = cmCTestSVN::Change;
Revision Rev;
std::vector<Change> Changes;
Change CurChange;
std::vector<char> CData;
- bool ProcessChunk(const char* data, int length) CM_OVERRIDE
+ bool ProcessChunk(const char* data, int length) override
{
this->OutputLogger::ProcessChunk(data, length);
this->ParseChunk(data, length);
return true;
}
- void StartElement(const std::string& name, const char** atts) CM_OVERRIDE
+ void StartElement(const std::string& name, const char** atts) override
{
this->CData.clear();
if (name == "logentry") {
this->Rev = Revision();
this->Rev.SVNInfo = &SVNRepo;
- if (const char* rev = this->FindAttribute(atts, "revision")) {
+ if (const char* rev =
+ cmCTestSVN::LogParser::FindAttribute(atts, "revision")) {
this->Rev.Rev = rev;
}
this->Changes.clear();
} else if (name == "path") {
this->CurChange = Change();
- if (const char* action = this->FindAttribute(atts, "action")) {
+ if (const char* action =
+ cmCTestSVN::LogParser::FindAttribute(atts, "action")) {
this->CurChange.Action = action[0];
}
}
}
- void CharacterDataHandler(const char* data, int length) CM_OVERRIDE
+ void CharacterDataHandler(const char* data, int length) override
{
- this->CData.insert(this->CData.end(), data, data + length);
+ cmAppend(this->CData, data, data + length);
}
- void EndElement(const std::string& name) CM_OVERRIDE
+ void EndElement(const std::string& name) override
{
if (name == "logentry") {
this->SVN->DoRevisionSVN(this->Rev, this->Changes);
@@ -370,7 +366,7 @@ private:
this->CData.clear();
}
- void ReportError(int /*line*/, int /*column*/, const char* msg) CM_OVERRIDE
+ void ReportError(int /*line*/, int /*column*/, const char* msg) override
{
this->SVN->Log << "Error parsing svn log xml: " << msg << "\n";
}
@@ -380,10 +376,7 @@ bool cmCTestSVN::LoadRevisions()
{
bool result = true;
// Get revisions for all the external repositories
- std::vector<SVNInfo>::iterator itbeg = this->Repositories.begin();
- std::vector<SVNInfo>::iterator itend = this->Repositories.end();
- for (; itbeg != itend; itbeg++) {
- SVNInfo& svninfo = *itbeg;
+ for (SVNInfo& svninfo : this->Repositories) {
result = this->LoadRevisions(svninfo) && result;
}
return result;
@@ -421,7 +414,7 @@ void cmCTestSVN::DoRevisionSVN(Revision const& revision,
// Ignore changes in the old revision for external repositories
if (revision.Rev == revision.SVNInfo->OldRevision &&
- revision.SVNInfo->LocalPath != "") {
+ !revision.SVNInfo->LocalPath.empty()) {
return;
}
@@ -441,7 +434,7 @@ public:
private:
cmCTestSVN* SVN;
cmsys::RegularExpression RegexStatus;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexStatus.find(this->Line)) {
this->DoPath(this->RegexStatus.match(1)[0],
@@ -507,7 +500,7 @@ public:
private:
cmCTestSVN* SVN;
cmsys::RegularExpression RegexExternal;
- bool ProcessLine() CM_OVERRIDE
+ bool ProcessLine() override
{
if (this->RegexExternal.find(this->Line)) {
this->DoPath(this->RegexExternal.match(1));
@@ -522,11 +515,11 @@ private:
if (path.size() > this->SVN->SourceDirectory.size() &&
strncmp(path.c_str(), this->SVN->SourceDirectory.c_str(),
this->SVN->SourceDirectory.size()) == 0) {
- local_path = path.c_str() + this->SVN->SourceDirectory.size() + 1;
+ local_path = path.substr(this->SVN->SourceDirectory.size() + 1);
} else {
local_path = path;
}
- this->SVN->Repositories.push_back(SVNInfo(local_path.c_str()));
+ this->SVN->Repositories.emplace_back(local_path);
}
};
@@ -537,7 +530,7 @@ bool cmCTestSVN::LoadRepositories()
}
// Info for root repository
- this->Repositories.push_back(SVNInfo(""));
+ this->Repositories.emplace_back();
this->RootInfo = &(this->Repositories.back());
// Run "svn status" to get the list of external repositories
@@ -561,7 +554,7 @@ std::string cmCTestSVN::SVNInfo::BuildLocalPath(std::string const& path) const
// Add path with base prefix removed
if (path.size() > this->Base.size() &&
strncmp(path.c_str(), this->Base.c_str(), this->Base.size()) == 0) {
- local_path += (path.c_str() + this->Base.size());
+ local_path += path.substr(this->Base.size());
} else {
local_path += path;
}
diff --git a/Source/CTest/cmCTestSVN.h b/Source/CTest/cmCTestSVN.h
index 46b077835..b74dc12b0 100644
--- a/Source/CTest/cmCTestSVN.h
+++ b/Source/CTest/cmCTestSVN.h
@@ -3,14 +3,15 @@
#ifndef cmCTestSVN_h
#define cmCTestSVN_h
-#include "cmConfigure.h"
-
-#include "cmCTestGlobalVC.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
+#include <list>
#include <string>
#include <vector>
+#include "cmCTestGlobalVC.h"
+
class cmCTest;
class cmXMLWriter;
@@ -24,14 +25,14 @@ public:
/** Construct with a CTest instance and update log stream. */
cmCTestSVN(cmCTest* ctest, std::ostream& log);
- ~cmCTestSVN() CM_OVERRIDE;
+ ~cmCTestSVN() override;
private:
// Implement cmCTestVC internal API.
- void CleanupImpl() CM_OVERRIDE;
- bool NoteOldRevision() CM_OVERRIDE;
- bool NoteNewRevision() CM_OVERRIDE;
- bool UpdateImpl() CM_OVERRIDE;
+ void CleanupImpl() override;
+ bool NoteOldRevision() override;
+ bool NoteNewRevision() override;
+ bool UpdateImpl() override;
bool RunSVNCommand(std::vector<char const*> const& parameters,
OutputParser* out, OutputParser* err);
@@ -40,7 +41,7 @@ private:
struct SVNInfo
{
- SVNInfo(const char* path)
+ SVNInfo(std::string const& path = std::string())
: LocalPath(path)
{
}
@@ -70,15 +71,16 @@ private:
friend struct Revision;
// Info of all the repositories (root, externals and nested ones).
- std::vector<SVNInfo> Repositories;
+ // Use std::list so the elements don't move in memory.
+ std::list<SVNInfo> Repositories;
// Pointer to the infos of the root repository.
SVNInfo* RootInfo;
std::string LoadInfo(SVNInfo& svninfo);
bool LoadRepositories();
- bool LoadModifications() CM_OVERRIDE;
- bool LoadRevisions() CM_OVERRIDE;
+ bool LoadModifications() override;
+ bool LoadRevisions() override;
bool LoadRevisions(SVNInfo& svninfo);
void GuessBase(SVNInfo& svninfo, std::vector<Change> const& changes);
@@ -86,7 +88,7 @@ private:
void DoRevisionSVN(Revision const& revision,
std::vector<Change> const& changes);
- void WriteXMLGlobal(cmXMLWriter& xml) CM_OVERRIDE;
+ void WriteXMLGlobal(cmXMLWriter& xml) override;
class ExternalParser;
// Parsing helper classes.
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 1d29dfac2..60facbdf5 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -2,15 +2,20 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestScriptHandler.h"
-#include "cmsys/Directory.hxx"
-#include "cmsys/Process.h"
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <map>
+#include <memory>
+#include <ratio>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <utility>
+#include <cm/memory>
+
+#include "cmsys/Directory.hxx"
+#include "cmsys/Process.h"
+
#include "cmCTest.h"
#include "cmCTestBuildCommand.h"
#include "cmCTestCommand.h"
@@ -26,62 +31,39 @@
#include "cmCTestTestCommand.h"
#include "cmCTestUpdateCommand.h"
#include "cmCTestUploadCommand.h"
-#include "cmFunctionBlocker.h"
+#include "cmCommand.h"
+#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
#ifdef _WIN32
-#include <windows.h>
+# include <windows.h>
#else
-#include <unistd.h>
+# include <unistd.h>
#endif
-class cmExecutionStatus;
-struct cmListFileFunction;
-
#define CTEST_INITIAL_CMAKE_OUTPUT_FILE_NAME "CTestInitialCMakeOutput.log"
-// used to keep elapsed time up to date
-class cmCTestScriptFunctionBlocker : public cmFunctionBlocker
-{
-public:
- cmCTestScriptFunctionBlocker() {}
- ~cmCTestScriptFunctionBlocker() CM_OVERRIDE {}
- bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
- cmExecutionStatus& /*status*/) CM_OVERRIDE;
- // virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
- // virtual void ScopeEnded(cmMakefile &mf);
-
- cmCTestScriptHandler* CTestScriptHandler;
-};
-
-// simply update the time and don't block anything
-bool cmCTestScriptFunctionBlocker::IsFunctionBlocked(
- const cmListFileFunction& /*lff*/, cmMakefile& /*mf*/,
- cmExecutionStatus& /*status*/)
-{
- this->CTestScriptHandler->UpdateElapsedTime();
- return false;
-}
-
cmCTestScriptHandler::cmCTestScriptHandler()
{
this->Backup = false;
this->EmptyBinDir = false;
this->EmptyBinDirOnce = false;
- this->Makefile = CM_NULLPTR;
- this->CMake = CM_NULLPTR;
- this->GlobalGenerator = CM_NULLPTR;
+ this->Makefile = nullptr;
+ this->ParentMakefile = nullptr;
+ this->CMake = nullptr;
+ this->GlobalGenerator = nullptr;
- this->ScriptStartTime = 0;
+ this->ScriptStartTime = std::chrono::steady_clock::time_point();
- // the *60 is becuase the settings are in minutes but GetTime is seconds
+ // the *60 is because the settings are in minutes but GetTime is seconds
this->MinimumInterval = 30 * 60;
this->ContinuousDuration = -1;
}
@@ -93,31 +75,32 @@ void cmCTestScriptHandler::Initialize()
this->EmptyBinDir = false;
this->EmptyBinDirOnce = false;
- this->SourceDir = "";
- this->BinaryDir = "";
- this->BackupSourceDir = "";
- this->BackupBinaryDir = "";
- this->CTestRoot = "";
- this->CVSCheckOut = "";
- this->CTestCmd = "";
- this->UpdateCmd = "";
- this->CTestEnv = "";
- this->InitialCache = "";
- this->CMakeCmd = "";
- this->CMOutFile = "";
+ this->SourceDir.clear();
+ this->BinaryDir.clear();
+ this->BackupSourceDir.clear();
+ this->BackupBinaryDir.clear();
+ this->CTestRoot.clear();
+ this->CVSCheckOut.clear();
+ this->CTestCmd.clear();
+ this->UpdateCmd.clear();
+ this->CTestEnv.clear();
+ this->InitialCache.clear();
+ this->CMakeCmd.clear();
+ this->CMOutFile.clear();
this->ExtraUpdates.clear();
this->MinimumInterval = 20 * 60;
this->ContinuousDuration = -1;
// what time in seconds did this script start running
- this->ScriptStartTime = 0;
+ this->ScriptStartTime = std::chrono::steady_clock::time_point();
delete this->Makefile;
- this->Makefile = CM_NULLPTR;
+ this->Makefile = nullptr;
+ this->ParentMakefile = nullptr;
delete this->GlobalGenerator;
- this->GlobalGenerator = CM_NULLPTR;
+ this->GlobalGenerator = nullptr;
delete this->CMake;
}
@@ -133,7 +116,7 @@ cmCTestScriptHandler::~cmCTestScriptHandler()
void cmCTestScriptHandler::AddConfigurationScript(const char* script,
bool pscope)
{
- this->ConfigurationScripts.push_back(script);
+ this->ConfigurationScripts.emplace_back(script);
this->ScriptProcessScope.push_back(pscope);
}
@@ -158,20 +141,19 @@ void cmCTestScriptHandler::UpdateElapsedTime()
{
if (this->Makefile) {
// set the current elapsed time
- char timeString[20];
- int itime = static_cast<unsigned int>(cmSystemTools::GetTime() -
- this->ScriptStartTime);
- sprintf(timeString, "%i", itime);
+ auto itime = cmDurationTo<unsigned int>(std::chrono::steady_clock::now() -
+ this->ScriptStartTime);
+ auto timeString = std::to_string(itime);
this->Makefile->AddDefinition("CTEST_ELAPSED_TIME", timeString);
}
}
-void cmCTestScriptHandler::AddCTestCommand(std::string const& name,
- cmCTestCommand* command)
+void cmCTestScriptHandler::AddCTestCommand(
+ std::string const& name, std::unique_ptr<cmCTestCommand> command)
{
command->CTest = this->CTest;
command->CTestScriptHandler = this;
- this->CMake->GetState()->AddBuiltinCommand(name, command);
+ this->CMake->GetState()->AddBuiltinCommand(name, std::move(command));
}
int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
@@ -183,8 +165,9 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
argv.push_back("-SR");
argv.push_back(total_script_arg.c_str());
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Executable for CTest is: "
- << cmSystemTools::GetCTestCommand() << "\n");
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Executable for CTest is: " << cmSystemTools::GetCTestCommand()
+ << "\n");
// now pass through all the other arguments
std::vector<std::string>& initArgs =
@@ -193,11 +176,11 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
for (size_t i = 1; i < initArgs.size(); ++i) {
argv.push_back(initArgs[i].c_str());
}
- argv.push_back(CM_NULLPTR);
+ argv.push_back(nullptr);
// Now create process object
cmsysProcess* cp = cmsysProcess_New();
- cmsysProcess_SetCommand(cp, &*argv.begin());
+ cmsysProcess_SetCommand(cp, argv.data());
// cmsysProcess_SetWorkingDirectory(cp, dir);
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
// cmsysProcess_SetTimeout(cp, timeout);
@@ -206,20 +189,22 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
std::vector<char> out;
std::vector<char> err;
std::string line;
- int pipe = cmSystemTools::WaitForLine(cp, line, 100.0, out, err);
+ int pipe =
+ cmSystemTools::WaitForLine(cp, line, std::chrono::seconds(100), out, err);
while (pipe != cmsysProcess_Pipe_None) {
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Output: " << line
- << "\n");
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Output: " << line << "\n");
if (pipe == cmsysProcess_Pipe_STDERR) {
cmCTestLog(this->CTest, ERROR_MESSAGE, line << "\n");
} else if (pipe == cmsysProcess_Pipe_STDOUT) {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, line << "\n");
}
- pipe = cmSystemTools::WaitForLine(cp, line, 100, out, err);
+ pipe = cmSystemTools::WaitForLine(cp, line, std::chrono::seconds(100), out,
+ err);
}
// Properly handle output of the build command
- cmsysProcess_WaitForExit(cp, CM_NULLPTR);
+ cmsysProcess_WaitForExit(cp, nullptr);
int result = cmsysProcess_GetState(cp);
int retVal = 0;
bool failed = false;
@@ -227,17 +212,19 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
retVal = cmsysProcess_GetExitValue(cp);
} else if (result == cmsysProcess_State_Exception) {
retVal = cmsysProcess_GetExitException(cp);
- cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was an exception: "
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "\tThere was an exception: "
<< cmsysProcess_GetExceptionString(cp) << " " << retVal
<< std::endl);
failed = true;
} else if (result == cmsysProcess_State_Expired) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was a timeout"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "\tThere was a timeout" << std::endl);
failed = true;
} else if (result == cmsysProcess_State_Error) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "\tError executing ctest: "
- << cmsysProcess_GetErrorString(cp) << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "\tError executing ctest: " << cmsysProcess_GetErrorString(cp)
+ << std::endl);
failed = true;
}
cmsysProcess_Delete(cp);
@@ -245,28 +232,18 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
std::ostringstream message;
message << "Error running command: [";
message << result << "] ";
- for (std::vector<const char*>::iterator i = argv.begin(); i != argv.end();
- ++i) {
- if (*i) {
- message << *i << " ";
+ for (const char* arg : argv) {
+ if (arg) {
+ message << arg << " ";
}
}
- cmCTestLog(this->CTest, ERROR_MESSAGE, message.str() << argv[0]
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ message.str() << argv[0] << std::endl);
return -1;
}
return retVal;
}
-static void ctestScriptProgressCallback(const char* m, float /*unused*/,
- void* cd)
-{
- cmCTest* ctest = static_cast<cmCTest*>(cd);
- if (m && *m) {
- cmCTestLog(ctest, HANDLER_OUTPUT, "-- " << m << std::endl);
- }
-}
-
void cmCTestScriptHandler::CreateCMake()
{
// create a cmake instance to read the configuration script
@@ -275,7 +252,7 @@ void cmCTestScriptHandler::CreateCMake()
delete this->GlobalGenerator;
delete this->Makefile;
}
- this->CMake = new cmake(cmake::RoleScript);
+ this->CMake = new cmake(cmake::RoleScript, cmState::CTest);
this->CMake->SetHomeDirectory("");
this->CMake->SetHomeOutputDirectory("");
this->CMake->GetCurrentSnapshot().SetDefaultDefinitions();
@@ -287,24 +264,40 @@ void cmCTestScriptHandler::CreateCMake()
snapshot.GetDirectory().SetCurrentSource(cwd);
snapshot.GetDirectory().SetCurrentBinary(cwd);
this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot);
+ if (this->ParentMakefile) {
+ this->Makefile->SetRecursionDepth(
+ this->ParentMakefile->GetRecursionDepth());
+ }
- this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest);
+ this->CMake->SetProgressCallback(
+ [this](const std::string& m, float /*unused*/) {
+ if (!m.empty()) {
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, "-- " << m << std::endl);
+ }
+ });
- this->AddCTestCommand("ctest_build", new cmCTestBuildCommand);
- this->AddCTestCommand("ctest_configure", new cmCTestConfigureCommand);
- this->AddCTestCommand("ctest_coverage", new cmCTestCoverageCommand);
+ this->AddCTestCommand("ctest_build", cm::make_unique<cmCTestBuildCommand>());
+ this->AddCTestCommand("ctest_configure",
+ cm::make_unique<cmCTestConfigureCommand>());
+ this->AddCTestCommand("ctest_coverage",
+ cm::make_unique<cmCTestCoverageCommand>());
this->AddCTestCommand("ctest_empty_binary_directory",
- new cmCTestEmptyBinaryDirectoryCommand);
- this->AddCTestCommand("ctest_memcheck", new cmCTestMemCheckCommand);
+ cm::make_unique<cmCTestEmptyBinaryDirectoryCommand>());
+ this->AddCTestCommand("ctest_memcheck",
+ cm::make_unique<cmCTestMemCheckCommand>());
this->AddCTestCommand("ctest_read_custom_files",
- new cmCTestReadCustomFilesCommand);
- this->AddCTestCommand("ctest_run_script", new cmCTestRunScriptCommand);
- this->AddCTestCommand("ctest_sleep", new cmCTestSleepCommand);
- this->AddCTestCommand("ctest_start", new cmCTestStartCommand);
- this->AddCTestCommand("ctest_submit", new cmCTestSubmitCommand);
- this->AddCTestCommand("ctest_test", new cmCTestTestCommand);
- this->AddCTestCommand("ctest_update", new cmCTestUpdateCommand);
- this->AddCTestCommand("ctest_upload", new cmCTestUploadCommand);
+ cm::make_unique<cmCTestReadCustomFilesCommand>());
+ this->AddCTestCommand("ctest_run_script",
+ cm::make_unique<cmCTestRunScriptCommand>());
+ this->AddCTestCommand("ctest_sleep", cm::make_unique<cmCTestSleepCommand>());
+ this->AddCTestCommand("ctest_start", cm::make_unique<cmCTestStartCommand>());
+ this->AddCTestCommand("ctest_submit",
+ cm::make_unique<cmCTestSubmitCommand>());
+ this->AddCTestCommand("ctest_test", cm::make_unique<cmCTestTestCommand>());
+ this->AddCTestCommand("ctest_update",
+ cm::make_unique<cmCTestUpdateCommand>());
+ this->AddCTestCommand("ctest_upload",
+ cm::make_unique<cmCTestUploadCommand>());
}
// this sets up some variables for the script to use, creates the required
@@ -325,8 +318,8 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
script_arg = total_script_arg.substr(comma_pos + 1);
}
// make sure the file exists
- if (!cmSystemTools::FileExists(script.c_str())) {
- cmSystemTools::Error("Cannot find file: ", script.c_str());
+ if (!cmSystemTools::FileExists(script)) {
+ cmSystemTools::Error("Cannot find file: " + script);
return 1;
}
@@ -335,30 +328,29 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
this->CreateCMake();
// set a variable with the path to the current script
- this->Makefile->AddDefinition(
- "CTEST_SCRIPT_DIRECTORY", cmSystemTools::GetFilenamePath(script).c_str());
- this->Makefile->AddDefinition(
- "CTEST_SCRIPT_NAME", cmSystemTools::GetFilenameName(script).c_str());
+ this->Makefile->AddDefinition("CTEST_SCRIPT_DIRECTORY",
+ cmSystemTools::GetFilenamePath(script));
+ this->Makefile->AddDefinition("CTEST_SCRIPT_NAME",
+ cmSystemTools::GetFilenameName(script));
this->Makefile->AddDefinition("CTEST_EXECUTABLE_NAME",
- cmSystemTools::GetCTestCommand().c_str());
+ cmSystemTools::GetCTestCommand());
this->Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME",
- cmSystemTools::GetCMakeCommand().c_str());
- this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", true);
+ cmSystemTools::GetCMakeCommand());
+ this->Makefile->AddDefinitionBool("CTEST_RUN_CURRENT_SCRIPT", true);
+ this->SetRunCurrentScript(true);
this->UpdateElapsedTime();
// add the script arg if defined
if (!script_arg.empty()) {
- this->Makefile->AddDefinition("CTEST_SCRIPT_ARG", script_arg.c_str());
+ this->Makefile->AddDefinition("CTEST_SCRIPT_ARG", script_arg);
}
#if defined(__CYGWIN__)
this->Makefile->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
#endif
- // always add a function blocker to update the elapsed time
- cmCTestScriptFunctionBlocker* f = new cmCTestScriptFunctionBlocker();
- f->CTestScriptHandler = this;
- this->Makefile->AddFunctionBlocker(f);
+ // set a callback function to update the elapsed time
+ this->Makefile->OnExecuteCommand([this] { this->UpdateElapsedTime(); });
/* Execute CTestScriptMode.cmake, which loads CMakeDetermineSystem and
CMakeSystemSpecificInformation, so
@@ -367,23 +359,22 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
ctest scripting easier. */
std::string systemFile =
this->Makefile->GetModulesFile("CTestScriptMode.cmake");
- if (!this->Makefile->ReadListFile(systemFile.c_str()) ||
+ if (!this->Makefile->ReadListFile(systemFile) ||
cmSystemTools::GetErrorOccuredFlag()) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:" << systemFile
- << "\n");
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Error in read:" << systemFile << "\n");
return 2;
}
// Add definitions of variables passed in on the command line:
const std::map<std::string, std::string>& defs =
this->CTest->GetDefinitions();
- for (std::map<std::string, std::string>::const_iterator it = defs.begin();
- it != defs.end(); ++it) {
- this->Makefile->AddDefinition(it->first, it->second.c_str());
+ for (auto const& d : defs) {
+ this->Makefile->AddDefinition(d.first, d.second);
}
// finally read in the script
- if (!this->Makefile->ReadListFile(script.c_str()) ||
+ if (!this->Makefile->ReadListFile(script) ||
cmSystemTools::GetErrorOccuredFlag()) {
// Reset the error flag so that it can run more than
// one script with an error when you use ctest_run_script.
@@ -394,7 +385,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
return 0;
}
-// extract variabels from the script to set ivars
+// extract variables from the script to set ivars
int cmCTestScriptHandler::ExtractVariables()
{
// Temporary variables
@@ -442,10 +433,11 @@ int cmCTestScriptHandler::ExtractVariables()
if (updateVal) {
if (this->UpdateCmd.empty()) {
cmSystemTools::Error(
- updateVar, " specified without specifying CTEST_CVS_COMMAND.");
+ std::string(updateVar) +
+ " specified without specifying CTEST_CVS_COMMAND.");
return 12;
}
- this->ExtraUpdates.push_back(updateVal);
+ this->ExtraUpdates.emplace_back(updateVal);
}
}
@@ -459,15 +451,16 @@ int cmCTestScriptHandler::ExtractVariables()
// make sure the required info is here
if (this->SourceDir.empty() || this->BinaryDir.empty() ||
this->CTestCmd.empty()) {
- std::string msg = "CTEST_SOURCE_DIRECTORY = ";
- msg += (!this->SourceDir.empty()) ? this->SourceDir.c_str() : "(Null)";
- msg += "\nCTEST_BINARY_DIRECTORY = ";
- msg += (!this->BinaryDir.empty()) ? this->BinaryDir.c_str() : "(Null)";
- msg += "\nCTEST_COMMAND = ";
- msg += (!this->CTestCmd.empty()) ? this->CTestCmd.c_str() : "(Null)";
+ std::string msg =
+ cmStrCat("CTEST_SOURCE_DIRECTORY = ",
+ (!this->SourceDir.empty()) ? this->SourceDir.c_str() : "(Null)",
+ "\nCTEST_BINARY_DIRECTORY = ",
+ (!this->BinaryDir.empty()) ? this->BinaryDir.c_str() : "(Null)",
+ "\nCTEST_COMMAND = ",
+ (!this->CTestCmd.empty()) ? this->CTestCmd.c_str() : "(Null)");
cmSystemTools::Error(
- "Some required settings in the configuration file were missing:\n",
- msg.c_str());
+ "Some required settings in the configuration file were missing:\n" +
+ msg);
return 4;
}
@@ -503,13 +496,13 @@ void cmCTestScriptHandler::SleepInSeconds(unsigned int secondsToWait)
int cmCTestScriptHandler::RunConfigurationScript(
const std::string& total_script_arg, bool pscope)
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmSystemTools::SaveRestoreEnvironment sre;
#endif
int result;
- this->ScriptStartTime = cmSystemTools::GetTime();
+ this->ScriptStartTime = std::chrono::steady_clock::now();
// read in the script
if (pscope) {
@@ -525,8 +518,9 @@ int cmCTestScriptHandler::RunConfigurationScript(
return result;
}
- // only run the curent script if we should
- if (this->Makefile && this->Makefile->IsOn("CTEST_RUN_CURRENT_SCRIPT")) {
+ // only run the current script if we should
+ if (this->Makefile && this->Makefile->IsOn("CTEST_RUN_CURRENT_SCRIPT") &&
+ this->ShouldRunCurrentScript) {
return this->RunCurrentScript();
}
return result;
@@ -537,7 +531,7 @@ int cmCTestScriptHandler::RunCurrentScript()
int result;
// do not run twice
- this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", false);
+ this->SetRunCurrentScript(false);
// no popup widows
cmSystemTools::SetRunCommandHideConsole(true);
@@ -550,32 +544,34 @@ int cmCTestScriptHandler::RunCurrentScript()
// set any environment variables
if (!this->CTestEnv.empty()) {
- std::vector<std::string> envArgs;
- cmSystemTools::ExpandListArgument(this->CTestEnv, envArgs);
+ std::vector<std::string> envArgs = cmExpandedList(this->CTestEnv);
cmSystemTools::AppendEnv(envArgs);
}
// now that we have done most of the error checking finally run the
// dashboard, we may be asked to repeatedly run this dashboard, such as
- // for a continuous, do we ned to run it more than once?
+ // for a continuous, do we need to run it more than once?
if (this->ContinuousDuration >= 0) {
this->UpdateElapsedTime();
- double ending_time = cmSystemTools::GetTime() + this->ContinuousDuration;
+ auto ending_time =
+ std::chrono::steady_clock::now() + cmDuration(this->ContinuousDuration);
if (this->EmptyBinDirOnce) {
this->EmptyBinDir = true;
}
do {
- double interval = cmSystemTools::GetTime();
+ auto startOfInterval = std::chrono::steady_clock::now();
result = this->RunConfigurationDashboard();
- interval = cmSystemTools::GetTime() - interval;
- if (interval < this->MinimumInterval) {
- this->SleepInSeconds(
- static_cast<unsigned int>(this->MinimumInterval - interval));
+ auto interval = std::chrono::steady_clock::now() - startOfInterval;
+ auto minimumInterval = cmDuration(this->MinimumInterval);
+ if (interval < minimumInterval) {
+ auto sleepTime =
+ cmDurationTo<unsigned int>(minimumInterval - interval);
+ this->SleepInSeconds(sleepTime);
}
if (this->EmptyBinDirOnce) {
this->EmptyBinDir = false;
}
- } while (cmSystemTools::GetTime() < ending_time);
+ } while (std::chrono::steady_clock::now() < ending_time);
}
// otherwise just run it once
else {
@@ -592,18 +588,17 @@ int cmCTestScriptHandler::CheckOutSourceDir()
int retVal;
bool res;
- if (!cmSystemTools::FileExists(this->SourceDir.c_str()) &&
+ if (!cmSystemTools::FileExists(this->SourceDir) &&
!this->CVSCheckOut.empty()) {
// we must now checkout the src dir
- output = "";
+ output.clear();
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Run cvs: " << this->CVSCheckOut << std::endl);
res = cmSystemTools::RunSingleCommand(
- this->CVSCheckOut.c_str(), &output, &output, &retVal,
- this->CTestRoot.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/);
+ this->CVSCheckOut, &output, &output, &retVal, this->CTestRoot.c_str(),
+ this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
if (!res || retVal != 0) {
- cmSystemTools::Error("Unable to perform cvs checkout:\n",
- output.c_str());
+ cmSystemTools::Error("Unable to perform cvs checkout:\n" + output);
return 6;
}
}
@@ -615,18 +610,16 @@ int cmCTestScriptHandler::BackupDirectories()
int retVal;
// compute the backup names
- this->BackupSourceDir = this->SourceDir;
- this->BackupSourceDir += "_CMakeBackup";
- this->BackupBinaryDir = this->BinaryDir;
- this->BackupBinaryDir += "_CMakeBackup";
+ this->BackupSourceDir = cmStrCat(this->SourceDir, "_CMakeBackup");
+ this->BackupBinaryDir = cmStrCat(this->BinaryDir, "_CMakeBackup");
// backup the binary and src directories if requested
if (this->Backup) {
// if for some reason those directories exist then first delete them
- if (cmSystemTools::FileExists(this->BackupSourceDir.c_str())) {
+ if (cmSystemTools::FileExists(this->BackupSourceDir)) {
cmSystemTools::RemoveADirectory(this->BackupSourceDir);
}
- if (cmSystemTools::FileExists(this->BackupBinaryDir.c_str())) {
+ if (cmSystemTools::FileExists(this->BackupBinaryDir)) {
cmSystemTools::RemoveADirectory(this->BackupBinaryDir);
}
@@ -654,24 +647,20 @@ int cmCTestScriptHandler::PerformExtraUpdates()
// do an initial cvs update as required
command = this->UpdateCmd;
- std::vector<std::string>::iterator it;
- for (it = this->ExtraUpdates.begin(); it != this->ExtraUpdates.end(); ++it) {
- std::vector<std::string> cvsArgs;
- cmSystemTools::ExpandListArgument(*it, cvsArgs);
+ for (std::string const& eu : this->ExtraUpdates) {
+ std::vector<std::string> cvsArgs = cmExpandedList(eu);
if (cvsArgs.size() == 2) {
- std::string fullCommand = command;
- fullCommand += " update ";
- fullCommand += cvsArgs[1];
- output = "";
+ std::string fullCommand = cmStrCat(command, " update ", cvsArgs[1]);
+ output.clear();
retVal = 0;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Run Update: " << fullCommand << std::endl);
res = cmSystemTools::RunSingleCommand(
- fullCommand.c_str(), &output, &output, &retVal, cvsArgs[0].c_str(),
- this->HandlerVerbose, 0 /*this->TimeOut*/);
+ fullCommand, &output, &output, &retVal, cvsArgs[0].c_str(),
+ this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
if (!res || retVal != 0) {
- cmSystemTools::Error("Unable to perform extra updates:\n", it->c_str(),
- "\nWith output:\n", output.c_str());
+ cmSystemTools::Error(cmStrCat("Unable to perform extra updates:\n", eu,
+ "\nWith output:\n", output));
return 0;
}
}
@@ -710,11 +699,11 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
}
// make sure the binary directory exists if it isn't the srcdir
- if (!cmSystemTools::FileExists(this->BinaryDir.c_str()) &&
+ if (!cmSystemTools::FileExists(this->BinaryDir) &&
this->SourceDir != this->BinaryDir) {
- if (!cmSystemTools::MakeDirectory(this->BinaryDir.c_str())) {
- cmSystemTools::Error("Unable to create the binary directory:\n",
- this->BinaryDir.c_str());
+ if (!cmSystemTools::MakeDirectory(this->BinaryDir)) {
+ cmSystemTools::Error("Unable to create the binary directory:\n" +
+ this->BinaryDir);
this->RestoreBackupDirectories();
return 7;
}
@@ -751,8 +740,8 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
// put the initial cache into the bin dir
if (!this->InitialCache.empty()) {
- if (!this->WriteInitialCache(this->BinaryDir.c_str(),
- this->InitialCache.c_str())) {
+ if (!cmCTestScriptHandler::WriteInitialCache(this->BinaryDir.c_str(),
+ this->InitialCache.c_str())) {
this->RestoreBackupDirectories();
return 9;
}
@@ -762,28 +751,26 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
int cmakeFailed = 0;
std::string cmakeFailedOuput;
if (!this->CMakeCmd.empty()) {
- command = this->CMakeCmd;
- command += " \"";
- command += this->SourceDir;
- output = "";
+ command = cmStrCat(this->CMakeCmd, " \"", this->SourceDir);
+ output.clear();
command += "\"";
retVal = 0;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Run cmake command: " << command << std::endl);
res = cmSystemTools::RunSingleCommand(
- command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(),
- this->HandlerVerbose, 0 /*this->TimeOut*/);
+ command, &output, &output, &retVal, this->BinaryDir.c_str(),
+ this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
if (!this->CMOutFile.empty()) {
std::string cmakeOutputFile = this->CMOutFile;
- if (!cmSystemTools::FileIsFullPath(cmakeOutputFile.c_str())) {
+ if (!cmSystemTools::FileIsFullPath(cmakeOutputFile)) {
cmakeOutputFile = this->BinaryDir + "/" + cmakeOutputFile;
}
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Write CMake output to file: " << cmakeOutputFile
<< std::endl);
- cmGeneratedFileStream fout(cmakeOutputFile.c_str());
+ cmGeneratedFileStream fout(cmakeOutputFile);
if (fout) {
fout << output.c_str();
} else {
@@ -800,18 +787,17 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
}
// run ctest, it may be more than one command in here
- std::vector<std::string> ctestCommands;
- cmSystemTools::ExpandListArgument(this->CTestCmd, ctestCommands);
+ std::vector<std::string> ctestCommands = cmExpandedList(this->CTestCmd);
// for each variable/argument do a putenv
- for (unsigned i = 0; i < ctestCommands.size(); ++i) {
- command = ctestCommands[i];
- output = "";
+ for (std::string const& ctestCommand : ctestCommands) {
+ command = ctestCommand;
+ output.clear();
retVal = 0;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Run ctest command: " << command << std::endl);
res = cmSystemTools::RunSingleCommand(
- command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(),
- this->HandlerVerbose, 0 /*this->TimeOut*/);
+ command, &output, &output, &retVal, this->BinaryDir.c_str(),
+ this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
// did something critical fail in ctest
if (!res || cmakeFailed || retVal & cmCTest::BUILD_ERRORS) {
@@ -833,7 +819,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
}
}
- // if all was succesful, delete the backup dirs to free up disk space
+ // if all was successful, delete the backup dirs to free up disk space
if (this->Backup) {
cmSystemTools::RemoveADirectory(this->BackupSourceDir);
cmSystemTools::RemoveADirectory(this->BackupBinaryDir);
@@ -845,14 +831,13 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
bool cmCTestScriptHandler::WriteInitialCache(const char* directory,
const char* text)
{
- std::string cacheFile = directory;
- cacheFile += "/CMakeCache.txt";
- cmGeneratedFileStream fout(cacheFile.c_str());
+ std::string cacheFile = cmStrCat(directory, "/CMakeCache.txt");
+ cmGeneratedFileStream fout(cacheFile);
if (!fout) {
return false;
}
- if (text != CM_NULLPTR) {
+ if (text != nullptr) {
fout.write(text, strlen(text));
}
@@ -870,10 +855,10 @@ void cmCTestScriptHandler::RestoreBackupDirectories()
// the backed up dirs
if (this->Backup) {
// if for some reason those directories exist then first delete them
- if (cmSystemTools::FileExists(this->SourceDir.c_str())) {
+ if (cmSystemTools::FileExists(this->SourceDir)) {
cmSystemTools::RemoveADirectory(this->SourceDir);
}
- if (cmSystemTools::FileExists(this->BinaryDir.c_str())) {
+ if (cmSystemTools::FileExists(this->BinaryDir)) {
cmSystemTools::RemoveADirectory(this->BinaryDir);
}
// rename the src and binary directories
@@ -882,11 +867,13 @@ void cmCTestScriptHandler::RestoreBackupDirectories()
}
}
-bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char* sname,
- bool InProcess, int* returnValue)
+bool cmCTestScriptHandler::RunScript(cmCTest* ctest, cmMakefile* mf,
+ const char* sname, bool InProcess,
+ int* returnValue)
{
cmCTestScriptHandler* sh = new cmCTestScriptHandler();
sh->SetCTestInstance(ctest);
+ sh->ParentMakefile = mf;
sh->AddConfigurationScript(sname, InProcess);
int res = sh->ProcessHandler();
if (returnValue) {
@@ -909,10 +896,9 @@ bool cmCTestScriptHandler::EmptyBinaryDirectory(const char* sname)
}
// try to avoid deleting directories that we shouldn't
- std::string check = sname;
- check += "/CMakeCache.txt";
+ std::string check = cmStrCat(sname, "/CMakeCache.txt");
- if (!cmSystemTools::FileExists(check.c_str())) {
+ if (!cmSystemTools::FileExists(check)) {
return false;
}
@@ -939,7 +925,7 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce(
continue;
}
- std::string fullPath = directoryPath + std::string("/") + path;
+ std::string fullPath = cmStrCat(directoryPath, "/", path);
bool isDirectory = cmSystemTools::FileIsDirectory(fullPath) &&
!cmSystemTools::FileIsSymlink(fullPath);
@@ -958,19 +944,26 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce(
return cmSystemTools::RemoveADirectory(directoryPath);
}
-double cmCTestScriptHandler::GetRemainingTimeAllowed()
+cmDuration cmCTestScriptHandler::GetRemainingTimeAllowed()
{
if (!this->Makefile) {
- return 1.0e7;
+ return cmCTest::MaxDuration();
}
const char* timelimitS = this->Makefile->GetDefinition("CTEST_TIME_LIMIT");
if (!timelimitS) {
- return 1.0e7;
+ return cmCTest::MaxDuration();
}
- double timelimit = atof(timelimitS);
+ auto timelimit = cmDuration(atof(timelimitS));
- return timelimit - cmSystemTools::GetTime() + this->ScriptStartTime;
+ auto duration = std::chrono::duration_cast<cmDuration>(
+ std::chrono::steady_clock::now() - this->ScriptStartTime);
+ return (timelimit - duration);
+}
+
+void cmCTestScriptHandler::SetRunCurrentScript(bool value)
+{
+ this->ShouldRunCurrentScript = value;
}
diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h
index 667870260..d0031990b 100644
--- a/Source/CTest/cmCTestScriptHandler.h
+++ b/Source/CTest/cmCTestScriptHandler.h
@@ -3,13 +3,16 @@
#ifndef cmCTestScriptHandler_h
#define cmCTestScriptHandler_h
-#include "cmConfigure.h"
-
-#include "cmCTestGenericHandler.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <chrono>
+#include <memory>
#include <string>
#include <vector>
+#include "cmCTestGenericHandler.h"
+#include "cmDuration.h"
+
class cmCTest;
class cmCTestCommand;
class cmGlobalGenerator;
@@ -55,7 +58,7 @@ class cmake;
class cmCTestScriptHandler : public cmCTestGenericHandler
{
public:
- typedef cmCTestGenericHandler Superclass;
+ using Superclass = cmCTestGenericHandler;
/**
* Add a script to run, and if is should run in the current process
@@ -65,13 +68,13 @@ public:
/**
* Run a dashboard using a specified confiuration script
*/
- int ProcessHandler() CM_OVERRIDE;
+ int ProcessHandler() override;
/*
* Run a script
*/
- static bool RunScript(cmCTest* ctest, const char* script, bool InProcess,
- int* returnValue);
+ static bool RunScript(cmCTest* ctest, cmMakefile* mf, const char* script,
+ bool InProcess, int* returnValue);
int RunCurrentScript();
/*
@@ -93,17 +96,20 @@ public:
/**
* Return the time remaianing that the script is allowed to run in
* seconds if the user has set the variable CTEST_TIME_LIMIT. If that has
- * not been set it returns 1e7 seconds
+ * not been set it returns a very large value.
*/
- double GetRemainingTimeAllowed();
+ cmDuration GetRemainingTimeAllowed();
cmCTestScriptHandler();
- ~cmCTestScriptHandler() CM_OVERRIDE;
+ ~cmCTestScriptHandler() override;
- void Initialize() CM_OVERRIDE;
+ void Initialize() override;
void CreateCMake();
cmake* GetCMake() { return this->CMake; }
+
+ void SetRunCurrentScript(bool value);
+
private:
// reads in a script
int ReadInScript(const std::string& total_script_arg);
@@ -126,7 +132,8 @@ private:
int RunConfigurationDashboard();
// Add ctest command
- void AddCTestCommand(std::string const& name, cmCTestCommand* command);
+ void AddCTestCommand(std::string const& name,
+ std::unique_ptr<cmCTestCommand> command);
// Try to remove the binary directory once
static bool TryToRemoveBinaryDirectoryOnce(const std::string& directoryPath);
@@ -134,6 +141,8 @@ private:
std::vector<std::string> ConfigurationScripts;
std::vector<bool> ScriptProcessScope;
+ bool ShouldRunCurrentScript;
+
bool Backup;
bool EmptyBinDir;
bool EmptyBinDirOnce;
@@ -156,9 +165,10 @@ private:
double ContinuousDuration;
// what time in seconds did this script start running
- double ScriptStartTime;
+ std::chrono::steady_clock::time_point ScriptStartTime;
cmMakefile* Makefile;
+ cmMakefile* ParentMakefile;
cmGlobalGenerator* GlobalGenerator;
cmake* CMake;
};
diff --git a/Source/CTest/cmCTestSleepCommand.cxx b/Source/CTest/cmCTestSleepCommand.cxx
index 2752cd370..623d3b69c 100644
--- a/Source/CTest/cmCTestSleepCommand.cxx
+++ b/Source/CTest/cmCTestSleepCommand.cxx
@@ -2,9 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestSleepCommand.h"
-#include "cmCTestScriptHandler.h"
+#include <cstdlib>
-#include <stdlib.h>
+#include "cmCTestScriptHandler.h"
class cmExecutionStatus;
diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h
index f0b5f1eeb..1c3b8a1e1 100644
--- a/Source/CTest/cmCTestSleepCommand.h
+++ b/Source/CTest/cmCTestSleepCommand.h
@@ -3,14 +3,17 @@
#ifndef cmCTestSleepCommand_h
#define cmCTestSleepCommand_h
-#include "cmConfigure.h"
-
-#include "cmCTestCommand.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <utility>
#include <vector>
-class cmCommand;
+#include <cm/memory>
+
+#include "cmCTestCommand.h"
+#include "cmCommand.h"
+
class cmExecutionStatus;
/** \class cmCTestSleep
@@ -27,12 +30,12 @@ public:
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE
+ std::unique_ptr<cmCommand> Clone() override
{
- cmCTestSleepCommand* ni = new cmCTestSleepCommand;
+ auto ni = cm::make_unique<cmCTestSleepCommand>();
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
- return ni;
+ return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
@@ -40,7 +43,7 @@ public:
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
+ cmExecutionStatus& status) override;
};
#endif
diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx
index 01a874b45..fe684062d 100644
--- a/Source/CTest/cmCTestStartCommand.cxx
+++ b/Source/CTest/cmCTestStartCommand.cxx
@@ -2,15 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestStartCommand.h"
+#include <cstddef>
+#include <sstream>
+
#include "cmCTest.h"
#include "cmCTestVC.h"
#include "cmGeneratedFileStream.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
-#include <sstream>
-#include <stddef.h>
-
class cmExecutionStatus;
cmCTestStartCommand::cmCTestStartCommand()
@@ -28,41 +28,43 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
}
size_t cnt = 0;
- const char* smodel = args[cnt].c_str();
- const char* src_dir = CM_NULLPTR;
- const char* bld_dir = CM_NULLPTR;
-
- cnt++;
+ const char* smodel = nullptr;
+ const char* src_dir = nullptr;
+ const char* bld_dir = nullptr;
- this->CTest->SetSpecificTrack(CM_NULLPTR);
- if (cnt < args.size() - 1) {
- if (args[cnt] == "TRACK") {
+ while (cnt < args.size()) {
+ if (args[cnt] == "GROUP" || args[cnt] == "TRACK") {
cnt++;
- this->CTest->SetSpecificTrack(args[cnt].c_str());
+ if (cnt >= args.size() || args[cnt] == "APPEND" ||
+ args[cnt] == "QUIET") {
+ std::ostringstream e;
+ e << args[cnt - 1] << " argument missing group name";
+ this->SetError(e.str());
+ return false;
+ }
+ this->CTest->SetSpecificGroup(args[cnt].c_str());
cnt++;
- }
- }
-
- if (cnt < args.size()) {
- if (args[cnt] == "APPEND") {
+ } else if (args[cnt] == "APPEND") {
cnt++;
this->CreateNewTag = false;
- }
- }
- if (cnt < args.size()) {
- if (args[cnt] == "QUIET") {
+ } else if (args[cnt] == "QUIET") {
cnt++;
this->Quiet = true;
- }
- }
-
- if (cnt < args.size()) {
- src_dir = args[cnt].c_str();
- cnt++;
- if (cnt < args.size()) {
+ } else if (!smodel) {
+ smodel = args[cnt].c_str();
+ cnt++;
+ } else if (!src_dir) {
+ src_dir = args[cnt].c_str();
+ cnt++;
+ } else if (!bld_dir) {
bld_dir = args[cnt].c_str();
+ cnt++;
+ } else {
+ this->SetError("Too many arguments");
+ return false;
}
}
+
if (!src_dir) {
src_dir = this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY");
}
@@ -79,6 +81,11 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
"as an argument or set CTEST_BINARY_DIRECTORY");
return false;
}
+ if (!smodel && this->CreateNewTag) {
+ this->SetError("no test model specified and APPEND not specified. Specify "
+ "either a test model or the APPEND argument");
+ return false;
+ }
cmSystemTools::AddKeepPath(src_dir);
cmSystemTools::AddKeepPath(bld_dir);
@@ -92,20 +99,31 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir.c_str(),
this->Quiet);
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model "
- << smodel << std::endl
- << " Source directory: " << src_dir << std::endl
- << " Build directory: " << bld_dir << std::endl,
- this->Quiet);
- const char* track = this->CTest->GetSpecificTrack();
- if (track) {
+ if (smodel) {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ "Run dashboard with model "
+ << smodel << std::endl
+ << " Source directory: " << src_dir << std::endl
+ << " Build directory: " << bld_dir << std::endl,
+ this->Quiet);
+ } else {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Track: " << track << std::endl, this->Quiet);
+ "Run dashboard with "
+ "to-be-determined model"
+ << std::endl
+ << " Source directory: " << src_dir << std::endl
+ << " Build directory: " << bld_dir << std::endl,
+ this->Quiet);
+ }
+ const char* group = this->CTest->GetSpecificGroup();
+ if (group) {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " Group: " << group << std::endl, this->Quiet);
}
// Log startup actions.
std::string startLogFile = binaryDir + "/Testing/Temporary/LastStart.log";
- cmGeneratedFileStream ofs(startLogFile.c_str());
+ cmGeneratedFileStream ofs(startLogFile);
if (!ofs) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot create log file: LastStart.log" << std::endl);
@@ -126,9 +144,14 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
return false;
}
- this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF");
+ this->CTest->SetRunCurrentScript(false);
this->CTest->SetSuppressUpdatingCTestConfiguration(true);
- int model = this->CTest->GetTestModelFromString(smodel);
+ int model;
+ if (smodel) {
+ model = cmCTest::GetTestModelFromString(smodel);
+ } else {
+ model = cmCTest::UNKNOWN;
+ }
this->CTest->SetTestModel(model);
this->CTest->SetProduceXML(true);
diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h
index b4943f92d..b30b1bb44 100644
--- a/Source/CTest/cmCTestStartCommand.h
+++ b/Source/CTest/cmCTestStartCommand.h
@@ -3,15 +3,18 @@
#ifndef cmCTestStartCommand_h
#define cmCTestStartCommand_h
-#include "cmConfigure.h"
-
-#include "cmCTestCommand.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
+#include <utility>
#include <vector>
-class cmCommand;
+#include <cm/memory>
+
+#include "cmCTestCommand.h"
+#include "cmCommand.h"
+
class cmExecutionStatus;
/** \class cmCTestStart
@@ -27,14 +30,14 @@ public:
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE
+ std::unique_ptr<cmCommand> Clone() override
{
- cmCTestStartCommand* ni = new cmCTestStartCommand;
+ auto ni = cm::make_unique<cmCTestStartCommand>();
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
ni->CreateNewTag = this->CreateNewTag;
ni->Quiet = this->Quiet;
- return ni;
+ return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
@@ -42,7 +45,7 @@ public:
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
+ cmExecutionStatus& status) override;
/**
* Will this invocation of ctest_start create a new TAG file?
diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx
index 409eb51fc..46b00b168 100644
--- a/Source/CTest/cmCTestSubmitCommand.cxx
+++ b/Source/CTest/cmCTestSubmitCommand.cxx
@@ -2,100 +2,81 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestSubmitCommand.h"
+#include <set>
+#include <sstream>
+#include <utility>
+
+#include <cm/memory>
+
+#include "cm_static_string_view.hxx"
+
+#include "cmAlgorithms.h"
#include "cmCTest.h"
-#include "cmCTestGenericHandler.h"
#include "cmCTestSubmitHandler.h"
+#include "cmCommand.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-
-#include <sstream>
class cmExecutionStatus;
-cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
+/**
+ * This is a virtual constructor for the command.
+ */
+std::unique_ptr<cmCommand> cmCTestSubmitCommand::Clone()
{
- const char* ctestDropMethod =
- this->Makefile->GetDefinition("CTEST_DROP_METHOD");
- const char* ctestDropSite = this->Makefile->GetDefinition("CTEST_DROP_SITE");
- const char* ctestDropLocation =
- this->Makefile->GetDefinition("CTEST_DROP_LOCATION");
- const char* ctestTriggerSite =
- this->Makefile->GetDefinition("CTEST_TRIGGER_SITE");
- bool ctestDropSiteCDash = this->Makefile->IsOn("CTEST_DROP_SITE_CDASH");
- const char* ctestProjectName =
- this->Makefile->GetDefinition("CTEST_PROJECT_NAME");
- if (!ctestDropMethod) {
- ctestDropMethod = "http";
- }
-
- if (!ctestDropSite) {
- // error: CDash requires CTEST_DROP_SITE definition
- // in CTestConfig.cmake
- }
- if (!ctestDropLocation) {
- // error: CDash requires CTEST_DROP_LOCATION definition
- // in CTestConfig.cmake
- }
- this->CTest->SetCTestConfiguration("ProjectName", ctestProjectName,
- this->Quiet);
- this->CTest->SetCTestConfiguration("DropMethod", ctestDropMethod,
- this->Quiet);
- this->CTest->SetCTestConfiguration("DropSite", ctestDropSite, this->Quiet);
- this->CTest->SetCTestConfiguration("DropLocation", ctestDropLocation,
- this->Quiet);
+ auto ni = cm::make_unique<cmCTestSubmitCommand>();
+ ni->CTest = this->CTest;
+ ni->CTestScriptHandler = this->CTestScriptHandler;
+ return std::unique_ptr<cmCommand>(std::move(ni));
+}
- this->CTest->SetCTestConfiguration(
- "IsCDash", ctestDropSiteCDash ? "TRUE" : "FALSE", this->Quiet);
+cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
+{
+ const char* submitURL = !this->SubmitURL.empty()
+ ? this->SubmitURL.c_str()
+ : this->Makefile->GetDefinition("CTEST_SUBMIT_URL");
- // Only propagate TriggerSite for non-CDash projects:
- //
- if (!ctestDropSiteCDash) {
- this->CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite,
- this->Quiet);
+ if (submitURL) {
+ this->CTest->SetCTestConfiguration("SubmitURL", submitURL, this->Quiet);
+ } else {
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "DropMethod", "CTEST_DROP_METHOD", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD",
+ this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "DropSite", "CTEST_DROP_SITE", this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "DropLocation", "CTEST_DROP_LOCATION", this->Quiet);
}
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "CurlOptions", "CTEST_CURL_OPTIONS", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(
- this->Makefile, "DropSiteUser", "CTEST_DROP_SITE_USER", this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(
- this->Makefile, "DropSitePassword", "CTEST_DROP_SITE_PASSWORD",
- this->Quiet);
- this->CTest->SetCTestConfigurationFromCMakeVariable(
- this->Makefile, "ScpCommand", "CTEST_SCP_COMMAND", this->Quiet);
const char* notesFilesVariable =
this->Makefile->GetDefinition("CTEST_NOTES_FILES");
if (notesFilesVariable) {
- std::vector<std::string> notesFiles;
- cmCTest::VectorOfStrings newNotesFiles;
- cmSystemTools::ExpandListArgument(notesFilesVariable, notesFiles);
- newNotesFiles.insert(newNotesFiles.end(), notesFiles.begin(),
- notesFiles.end());
- this->CTest->GenerateNotesFile(newNotesFiles);
+ std::vector<std::string> notesFiles = cmExpandedList(notesFilesVariable);
+ this->CTest->GenerateNotesFile(notesFiles);
}
const char* extraFilesVariable =
this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES");
if (extraFilesVariable) {
- std::vector<std::string> extraFiles;
- cmCTest::VectorOfStrings newExtraFiles;
- cmSystemTools::ExpandListArgument(extraFilesVariable, extraFiles);
- newExtraFiles.insert(newExtraFiles.end(), extraFiles.begin(),
- extraFiles.end());
- if (!this->CTest->SubmitExtraFiles(newExtraFiles)) {
+ std::vector<std::string> extraFiles = cmExpandedList(extraFilesVariable);
+ if (!this->CTest->SubmitExtraFiles(extraFiles)) {
this->SetError("problem submitting extra files.");
- return CM_NULLPTR;
+ return nullptr;
}
}
- cmCTestGenericHandler* handler =
- this->CTest->GetInitializedHandler("submit");
- if (!handler) {
- this->SetError("internal CTest error. Cannot instantiate submit handler");
- return CM_NULLPTR;
- }
+ cmCTestSubmitHandler* handler = this->CTest->GetSubmitHandler();
+ handler->Initialize();
// If no FILES or PARTS given, *all* PARTS are submitted by default.
//
@@ -117,38 +98,35 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
// But FILES with no PARTS mentioned should just submit the FILES
// without any of the default parts.
//
- std::set<cmCTest::Part> noParts;
- static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(noParts);
-
- static_cast<cmCTestSubmitHandler*>(handler)->SelectFiles(this->Files);
+ handler->SelectParts(std::set<cmCTest::Part>());
+ handler->SelectFiles(
+ std::set<std::string>(this->Files.begin(), this->Files.end()));
}
// If a PARTS option was given, select only the named parts for submission.
//
if (this->PartsMentioned) {
- static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(this->Parts);
+ auto parts =
+ cmMakeRange(this->Parts).transform([this](std::string const& arg) {
+ return this->CTest->GetPartFromName(arg.c_str());
+ });
+ handler->SelectParts(std::set<cmCTest::Part>(parts.begin(), parts.end()));
}
// Pass along any HTTPHEADER to the handler if this option was given.
if (!this->HttpHeaders.empty()) {
- static_cast<cmCTestSubmitHandler*>(handler)->SetHttpHeaders(
- this->HttpHeaders);
+ handler->SetHttpHeaders(this->HttpHeaders);
}
- static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
- "RetryDelay", this->RetryDelay.c_str());
- static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
- "RetryCount", this->RetryCount.c_str());
- static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
- "InternalTest", this->InternalTest ? "ON" : "OFF");
+ handler->SetOption("RetryDelay", this->RetryDelay.c_str());
+ handler->SetOption("RetryCount", this->RetryCount.c_str());
+ handler->SetOption("InternalTest", this->InternalTest ? "ON" : "OFF");
handler->SetQuiet(this->Quiet);
if (this->CDashUpload) {
- static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
- "CDashUploadFile", this->CDashUploadFile.c_str());
- static_cast<cmCTestSubmitHandler*>(handler)->SetOption(
- "CDashUploadType", this->CDashUploadType.c_str());
+ handler->SetOption("CDashUploadFile", this->CDashUploadFile.c_str());
+ handler->SetOption("CDashUploadType", this->CDashUploadType.c_str());
}
return handler;
}
@@ -157,117 +135,64 @@ bool cmCTestSubmitCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
this->CDashUpload = !args.empty() && args[0] == "CDASH_UPLOAD";
- return this->cmCTestHandlerCommand::InitialPass(args, status);
+
+ bool ret = this->cmCTestHandlerCommand::InitialPass(args, status);
+
+ if (!this->BuildID.empty()) {
+ this->Makefile->AddDefinition(this->BuildID, this->CTest->GetBuildID());
+ }
+
+ return ret;
}
-bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
+void cmCTestSubmitCommand::BindArguments()
{
if (this->CDashUpload) {
// Arguments specific to the CDASH_UPLOAD signature.
- if (arg == "CDASH_UPLOAD") {
- this->ArgumentDoing = ArgumentDoingCDashUpload;
- return true;
- }
-
- if (arg == "CDASH_UPLOAD_TYPE") {
- this->ArgumentDoing = ArgumentDoingCDashUploadType;
- return true;
- }
+ this->Bind("CDASH_UPLOAD", this->CDashUploadFile);
+ this->Bind("CDASH_UPLOAD_TYPE", this->CDashUploadType);
} else {
// Arguments that cannot be used with CDASH_UPLOAD.
- if (arg == "PARTS") {
- this->ArgumentDoing = ArgumentDoingParts;
- this->PartsMentioned = true;
- return true;
- }
-
- if (arg == "FILES") {
- this->ArgumentDoing = ArgumentDoingFiles;
- this->FilesMentioned = true;
- return true;
- }
+ this->Bind("PARTS"_s, this->Parts);
+ this->Bind("FILES"_s, this->Files);
}
// Arguments used by both modes.
- if (arg == "HTTPHEADER") {
- this->ArgumentDoing = ArgumentDoingHttpHeader;
- return true;
- }
-
- if (arg == "RETRY_COUNT") {
- this->ArgumentDoing = ArgumentDoingRetryCount;
- return true;
- }
-
- if (arg == "RETRY_DELAY") {
- this->ArgumentDoing = ArgumentDoingRetryDelay;
- return true;
- }
-
- if (arg == "INTERNAL_TEST_CHECKSUM") {
- this->InternalTest = true;
- return true;
- }
+ this->Bind("BUILD_ID"_s, this->BuildID);
+ this->Bind("HTTPHEADER"_s, this->HttpHeaders);
+ this->Bind("RETRY_COUNT"_s, this->RetryCount);
+ this->Bind("RETRY_DELAY"_s, this->RetryDelay);
+ this->Bind("SUBMIT_URL"_s, this->SubmitURL);
+ this->Bind("INTERNAL_TEST_CHECKSUM", this->InternalTest);
// Look for other arguments.
- return this->Superclass::CheckArgumentKeyword(arg);
+ this->cmCTestHandlerCommand::BindArguments();
}
-bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
+void cmCTestSubmitCommand::CheckArguments(
+ std::vector<std::string> const& keywords)
{
- // Handle states specific to this command.
- if (this->ArgumentDoing == ArgumentDoingParts) {
+ this->PartsMentioned = !this->Parts.empty() || cmContains(keywords, "PARTS");
+ this->FilesMentioned = !this->Files.empty() || cmContains(keywords, "FILES");
+
+ cmEraseIf(this->Parts, [this](std::string const& arg) -> bool {
cmCTest::Part p = this->CTest->GetPartFromName(arg.c_str());
- if (p != cmCTest::PartCount) {
- this->Parts.insert(p);
- } else {
+ if (p == cmCTest::PartCount) {
std::ostringstream e;
e << "Part name \"" << arg << "\" is invalid.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
- this->ArgumentDoing = ArgumentDoingError;
+ this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return true;
}
- return true;
- }
+ return false;
+ });
- if (this->ArgumentDoing == ArgumentDoingFiles) {
- if (cmSystemTools::FileExists(arg.c_str())) {
- this->Files.insert(arg);
- } else {
+ cmEraseIf(this->Files, [this](std::string const& arg) -> bool {
+ if (!cmSystemTools::FileExists(arg)) {
std::ostringstream e;
e << "File \"" << arg << "\" does not exist. Cannot submit "
<< "a non-existent file.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
- this->ArgumentDoing = ArgumentDoingError;
+ this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return true;
}
- return true;
- }
-
- if (this->ArgumentDoing == ArgumentDoingHttpHeader) {
- this->HttpHeaders.push_back(arg);
- return true;
- }
-
- if (this->ArgumentDoing == ArgumentDoingRetryCount) {
- this->RetryCount = arg;
- return true;
- }
-
- if (this->ArgumentDoing == ArgumentDoingRetryDelay) {
- this->RetryDelay = arg;
- return true;
- }
-
- if (this->ArgumentDoing == ArgumentDoingCDashUpload) {
- this->ArgumentDoing = ArgumentDoingNone;
- this->CDashUploadFile = arg;
- return true;
- }
-
- if (this->ArgumentDoing == ArgumentDoingCDashUploadType) {
- this->ArgumentDoing = ArgumentDoingNone;
- this->CDashUploadType = arg;
- return true;
- }
-
- // Look for other arguments.
- return this->Superclass::CheckArgumentValue(arg);
+ return false;
+ });
}
diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h
index cf65cdc8d..90607713b 100644
--- a/Source/CTest/cmCTestSubmitCommand.h
+++ b/Source/CTest/cmCTestSubmitCommand.h
@@ -3,17 +3,16 @@
#ifndef cmCTestSubmitCommand_h
#define cmCTestSubmitCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmCTest.h"
-#include "cmCTestHandlerCommand.h"
-
-#include <set>
+#include <memory>
#include <string>
#include <vector>
-class cmCTestGenericHandler;
+#include "cmCTestHandlerCommand.h"
+
class cmCommand;
+class cmCTestGenericHandler;
class cmExecutionStatus;
/** \class cmCTestSubmit
@@ -25,66 +24,36 @@ class cmExecutionStatus;
class cmCTestSubmitCommand : public cmCTestHandlerCommand
{
public:
- cmCTestSubmitCommand()
- {
- this->PartsMentioned = false;
- this->FilesMentioned = false;
- this->InternalTest = false;
- this->RetryCount = "";
- this->RetryDelay = "";
- this->CDashUpload = false;
- }
-
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE
- {
- cmCTestSubmitCommand* ni = new cmCTestSubmitCommand;
- ni->CTest = this->CTest;
- ni->CTestScriptHandler = this->CTestScriptHandler;
- return ni;
- }
+ std::unique_ptr<cmCommand> Clone() override;
bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
+ cmExecutionStatus& status) override;
/**
* The name of the command as specified in CMakeList.txt.
*/
- std::string GetName() const CM_OVERRIDE { return "ctest_submit"; }
-
- typedef cmCTestHandlerCommand Superclass;
+ std::string GetName() const override { return "ctest_submit"; }
protected:
- cmCTestGenericHandler* InitializeHandler() CM_OVERRIDE;
+ void BindArguments() override;
+ void CheckArguments(std::vector<std::string> const& keywords) override;
+ cmCTestGenericHandler* InitializeHandler() override;
- bool CheckArgumentKeyword(std::string const& arg) CM_OVERRIDE;
- bool CheckArgumentValue(std::string const& arg) CM_OVERRIDE;
+ bool CDashUpload = false;
+ bool FilesMentioned = false;
+ bool InternalTest = false;
+ bool PartsMentioned = false;
- enum
- {
- ArgumentDoingParts = Superclass::ArgumentDoingLast1,
- ArgumentDoingFiles,
- ArgumentDoingRetryDelay,
- ArgumentDoingRetryCount,
- ArgumentDoingCDashUpload,
- ArgumentDoingCDashUploadType,
- ArgumentDoingHttpHeader,
- ArgumentDoingLast2
- };
-
- bool PartsMentioned;
- std::set<cmCTest::Part> Parts;
- bool FilesMentioned;
- bool InternalTest;
- cmCTest::SetOfStrings Files;
- std::string RetryCount;
- std::string RetryDelay;
- bool CDashUpload;
+ std::string BuildID;
std::string CDashUploadFile;
std::string CDashUploadType;
+ std::string RetryCount;
+ std::string RetryDelay;
+ std::string SubmitURL;
+
+ std::vector<std::string> Files;
std::vector<std::string> HttpHeaders;
+ std::vector<std::string> Parts;
};
#endif
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 8d62fa156..2ac5af691 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -2,44 +2,36 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestSubmitHandler.h"
+#include <chrono>
+#include <cstdio>
+#include <cstdlib>
+#include <sstream>
+
#include "cm_curl.h"
#include "cm_jsoncpp_reader.h"
#include "cm_jsoncpp_value.h"
-#include "cmsys/Process.h"
-#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
+#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestCurl.h"
#include "cmCTestScriptHandler.h"
+#include "cmCryptoHash.h"
#include "cmCurl.h"
+#include "cmDuration.h"
#include "cmGeneratedFileStream.h"
-#include "cmProcessOutput.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmThirdParty.h"
-#include "cmWorkingDirectory.h"
#include "cmXMLParser.h"
#include "cmake.h"
-#if defined(CTEST_USE_XMLRPC)
-#include "cmVersion.h"
-#include "cm_sys_stat.h"
-#include "cm_xmlrpc.h"
-#endif
-
#define SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT 120
-typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar;
+using cmCTestSubmitHandlerVectorOfChar = std::vector<char>;
class cmCTestSubmitHandler::ResponseParser : public cmXMLParser
{
public:
- ResponseParser() { this->Status = STATUS_OK; }
- ~ResponseParser() CM_OVERRIDE {}
-
-public:
enum StatusType
{
STATUS_OK,
@@ -47,10 +39,11 @@ public:
STATUS_ERROR
};
- StatusType Status;
+ StatusType Status = STATUS_OK;
std::string Filename;
std::string MD5;
std::string Message;
+ std::string BuildID;
private:
std::vector<char> CurrentValue;
@@ -65,17 +58,17 @@ private:
}
void StartElement(const std::string& /*name*/,
- const char** /*atts*/) CM_OVERRIDE
+ const char** /*atts*/) override
{
this->CurrentValue.clear();
}
- void CharacterDataHandler(const char* data, int length) CM_OVERRIDE
+ void CharacterDataHandler(const char* data, int length) override
{
- this->CurrentValue.insert(this->CurrentValue.end(), data, data + length);
+ cmAppend(this->CurrentValue, data, data + length);
}
- void EndElement(const std::string& name) CM_OVERRIDE
+ void EndElement(const std::string& name) override
{
if (name == "status") {
std::string status = cmSystemTools::UpperCase(this->GetCurrentValue());
@@ -92,6 +85,8 @@ private:
this->MD5 = this->GetCurrentValue();
} else if (name == "message") {
this->Message = this->GetCurrentValue();
+ } else if (name == "buildId") {
+ this->BuildID = this->GetCurrentValue();
}
}
};
@@ -99,13 +94,10 @@ private:
static size_t cmCTestSubmitHandlerWriteMemoryCallback(void* ptr, size_t size,
size_t nmemb, void* data)
{
- int realsize = (int)(size * nmemb);
-
- cmCTestSubmitHandlerVectorOfChar* vec =
- static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
+ int realsize = static_cast<int>(size * nmemb);
const char* chPtr = static_cast<char*>(ptr);
- vec->insert(vec->end(), chPtr, chPtr + realsize);
-
+ cmAppend(*static_cast<cmCTestSubmitHandlerVectorOfChar*>(data), chPtr,
+ chPtr + realsize);
return realsize;
}
@@ -114,16 +106,12 @@ static size_t cmCTestSubmitHandlerCurlDebugCallback(CURL* /*unused*/,
char* chPtr, size_t size,
void* data)
{
- cmCTestSubmitHandlerVectorOfChar* vec =
- static_cast<cmCTestSubmitHandlerVectorOfChar*>(data);
- vec->insert(vec->end(), chPtr, chPtr + size);
-
+ cmAppend(*static_cast<cmCTestSubmitHandlerVectorOfChar*>(data), chPtr,
+ chPtr + size);
return size;
}
cmCTestSubmitHandler::cmCTestSubmitHandler()
- : HTTPProxy()
- , FTPProxy()
{
this->Initialize();
}
@@ -135,167 +123,19 @@ void cmCTestSubmitHandler::Initialize()
p = cmCTest::Part(p + 1)) {
this->SubmitPart[p] = true;
}
- this->CDash = false;
this->HasWarnings = false;
this->HasErrors = false;
this->Superclass::Initialize();
- this->HTTPProxy = "";
+ this->HTTPProxy.clear();
this->HTTPProxyType = 0;
- this->HTTPProxyAuth = "";
- this->FTPProxy = "";
- this->FTPProxyType = 0;
- this->LogFile = CM_NULLPTR;
+ this->HTTPProxyAuth.clear();
+ this->LogFile = nullptr;
this->Files.clear();
}
-bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url)
-{
- CURL* curl;
- CURLcode res;
- FILE* ftpfile;
- char error_buffer[1024];
-
- /* In windows, this will init the winsock stuff */
- ::curl_global_init(CURL_GLOBAL_ALL);
-
- cmCTest::SetOfStrings::const_iterator file;
- for (file = files.begin(); file != files.end(); ++file) {
- /* get a curl handle */
- curl = curl_easy_init();
- if (curl) {
- // Using proxy
- if (this->FTPProxyType > 0) {
- curl_easy_setopt(curl, CURLOPT_PROXY, this->FTPProxy.c_str());
- switch (this->FTPProxyType) {
- case 2:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
- break;
- case 3:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
- break;
- default:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
- }
- }
-
- // enable uploading
- ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
-
- // if there is little to no activity for too long stop submitting
- ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1);
- ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME,
- SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
-
- ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
-
- std::string local_file = *file;
- if (!cmSystemTools::FileExists(local_file.c_str())) {
- local_file = localprefix + "/" + *file;
- }
- std::string upload_as =
- url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file);
-
- if (!cmSystemTools::FileExists(local_file.c_str())) {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Cannot find file: " << local_file << std::endl);
- ::curl_easy_cleanup(curl);
- ::curl_global_cleanup();
- return false;
- }
- unsigned long filelen = cmSystemTools::FileLength(local_file);
-
- ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
- *this->LogFile << "\tUpload file: " << local_file << " to " << upload_as
- << std::endl;
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Upload file: " << local_file << " to "
- << upload_as << std::endl,
- this->Quiet);
-
- ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
-
- // specify target
- ::curl_easy_setopt(curl, CURLOPT_URL, upload_as.c_str());
-
- // now specify which file to upload
- ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
-
- // and give the size of the upload (optional)
- ::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast<long>(filelen));
-
- // and give curl the buffer for errors
- ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
-
- // specify handler for output
- ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
- cmCTestSubmitHandlerWriteMemoryCallback);
- ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
- cmCTestSubmitHandlerCurlDebugCallback);
-
- /* we pass our 'chunk' struct to the callback function */
- cmCTestSubmitHandlerVectorOfChar chunk;
- cmCTestSubmitHandlerVectorOfChar chunkDebug;
- ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
- ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
-
- // Now run off and do what you've been told!
- res = ::curl_easy_perform(curl);
-
- if (!chunk.empty()) {
- cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size())
- << "]" << std::endl,
- this->Quiet);
- }
- if (!chunkDebug.empty()) {
- cmCTestOptionalLog(
- this->CTest, DEBUG, "CURL debug output: ["
- << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
- << std::endl,
- this->Quiet);
- }
-
- fclose(ftpfile);
- if (res) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when uploading file: "
- << local_file << std::endl);
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Error message was: " << error_buffer << std::endl);
- *this->LogFile << " Error when uploading file: " << local_file
- << std::endl
- << " Error message was: " << error_buffer << std::endl
- << " Curl output was: ";
- // avoid dereference of empty vector
- if (!chunk.empty()) {
- *this->LogFile << cmCTestLogWrite(&*chunk.begin(), chunk.size());
- cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
- << std::endl);
- }
- *this->LogFile << std::endl;
- ::curl_easy_cleanup(curl);
- ::curl_global_cleanup();
- return false;
- }
- // always cleanup
- ::curl_easy_cleanup(curl);
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Uploaded: " + local_file << std::endl,
- this->Quiet);
- }
- }
- ::curl_global_cleanup();
- return true;
-}
-
-// Uploading files is simpler
-bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url)
+bool cmCTestSubmitHandler::SubmitUsingHTTP(
+ const std::string& localprefix, const std::vector<std::string>& files,
+ const std::string& remoteprefix, const std::string& url)
{
CURL* curl;
CURLcode res;
@@ -303,37 +143,31 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
char error_buffer[1024];
// Set Content-Type to satisfy fussy modsecurity rules.
struct curl_slist* headers =
- ::curl_slist_append(CM_NULLPTR, "Content-Type: text/xml");
+ ::curl_slist_append(nullptr, "Content-Type: text/xml");
// Add any additional headers that the user specified.
- for (std::vector<std::string>::const_iterator h = this->HttpHeaders.begin();
- h != this->HttpHeaders.end(); ++h) {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Add HTTP Header: \"" << *h << "\"" << std::endl,
+ for (std::string const& h : this->HttpHeaders) {
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ " Add HTTP Header: \"" << h << "\"" << std::endl,
this->Quiet);
- headers = ::curl_slist_append(headers, h->c_str());
+ headers = ::curl_slist_append(headers, h.c_str());
}
/* In windows, this will init the winsock stuff */
::curl_global_init(CURL_GLOBAL_ALL);
- std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
- std::vector<std::string> args;
- cmSystemTools::ExpandListArgument(curlopt, args);
+ std::vector<std::string> args = cmExpandedList(curlopt);
bool verifyPeerOff = false;
bool verifyHostOff = false;
- for (std::vector<std::string>::iterator i = args.begin(); i != args.end();
- ++i) {
- if (*i == "CURLOPT_SSL_VERIFYPEER_OFF") {
+ for (std::string const& arg : args) {
+ if (arg == "CURLOPT_SSL_VERIFYPEER_OFF") {
verifyPeerOff = true;
}
- if (*i == "CURLOPT_SSL_VERIFYHOST_OFF") {
+ if (arg == "CURLOPT_SSL_VERIFYHOST_OFF") {
verifyHostOff = true;
}
}
- std::string::size_type kk;
- cmCTest::SetOfStrings::const_iterator file;
- for (file = files.begin(); file != files.end(); ++file) {
+ for (std::string const& file : files) {
/* get a curl handle */
curl = curl_easy_init();
if (curl) {
@@ -388,53 +222,72 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
- std::string local_file = *file;
- if (!cmSystemTools::FileExists(local_file.c_str())) {
- local_file = localprefix + "/" + *file;
+ std::string local_file = file;
+ bool initialize_cdash_buildid = false;
+ if (!cmSystemTools::FileExists(local_file)) {
+ local_file = cmStrCat(localprefix, "/", file);
+ // If this file exists within the local Testing directory we assume
+ // that it will be associated with the current build in CDash.
+ initialize_cdash_buildid = true;
}
std::string remote_file =
- remoteprefix + cmSystemTools::GetFilenameName(*file);
+ remoteprefix + cmSystemTools::GetFilenameName(file);
*this->LogFile << "\tUpload file: " << local_file << " to "
<< remote_file << std::endl;
- std::string ofile;
- for (kk = 0; kk < remote_file.size(); kk++) {
- char c = remote_file[kk];
- char hexCh[4] = { 0, 0, 0, 0 };
- hexCh[0] = c;
- switch (c) {
- case '+':
- case '?':
- case '/':
- case '\\':
- case '&':
- case ' ':
- case '=':
- case '%':
- sprintf(hexCh, "%%%02X", (int)c);
- ofile.append(hexCh);
- break;
- default:
- ofile.append(hexCh);
+ std::string ofile = cmSystemTools::EncodeURL(remote_file);
+ std::string upload_as =
+ cmStrCat(url, ((url.find('?') == std::string::npos) ? '?' : '&'),
+ "FileName=", ofile);
+
+ if (initialize_cdash_buildid) {
+ // Provide extra arguments to CDash so that it can initialize and
+ // return a buildid.
+ cmCTestCurl ctest_curl(this->CTest);
+ upload_as += "&build=";
+ upload_as +=
+ ctest_curl.Escape(this->CTest->GetCTestConfiguration("BuildName"));
+ upload_as += "&site=";
+ upload_as +=
+ ctest_curl.Escape(this->CTest->GetCTestConfiguration("Site"));
+ upload_as += "&stamp=";
+ upload_as += ctest_curl.Escape(this->CTest->GetCurrentTag());
+ upload_as += "-";
+ upload_as += ctest_curl.Escape(this->CTest->GetTestModelString());
+ cmCTestScriptHandler* ch = this->CTest->GetScriptHandler();
+ cmake* cm = ch->GetCMake();
+ if (cm) {
+ const char* subproject =
+ cm->GetState()->GetGlobalProperty("SubProject");
+ if (subproject) {
+ upload_as += "&subproject=";
+ upload_as += ctest_curl.Escape(subproject);
+ }
}
}
- std::string upload_as = url +
- ((url.find('?') == std::string::npos) ? '?' : '&') + "FileName=" +
- ofile;
+
+ // Generate Done.xml right before it is submitted.
+ // The reason for this is two-fold:
+ // 1) It must be generated after some other part has been submitted
+ // so we have a buildId to refer to in its contents.
+ // 2) By generating Done.xml here its timestamp will be as late as
+ // possible. This gives us a more accurate record of how long the
+ // entire build took to complete.
+ if (file == "Done.xml") {
+ this->CTest->GenerateDoneFile();
+ }
upload_as += "&MD5=";
- if (cmSystemTools::IsOn(this->GetOption("InternalTest"))) {
+ if (cmIsOn(this->GetOption("InternalTest"))) {
upload_as += "bad_md5sum";
} else {
- char md5[33];
- cmSystemTools::ComputeFileMD5(local_file, md5);
- md5[32] = 0;
- upload_as += md5;
+ upload_as +=
+ cmSystemTools::ComputeFileHash(local_file, cmCryptoHash::AlgoMD5);
}
- if (!cmSystemTools::FileExists(local_file.c_str())) {
+ if (!cmSystemTools::FileExists(local_file)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
" Cannot find file: " << local_file << std::endl);
::curl_easy_cleanup(curl);
@@ -454,6 +307,10 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
// specify target
::curl_easy_setopt(curl, CURLOPT_URL, upload_as.c_str());
+ // CURLAUTH_BASIC is default, and here we allow additional methods,
+ // including more secure ones
+ ::curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
+
// now specify which file to upload
::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
@@ -472,23 +329,25 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
/* we pass our 'chunk' struct to the callback function */
cmCTestSubmitHandlerVectorOfChar chunk;
cmCTestSubmitHandlerVectorOfChar chunkDebug;
- ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
- ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
+ ::curl_easy_setopt(curl, CURLOPT_FILE, &chunk);
+ ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug);
// Now run off and do what you've been told!
res = ::curl_easy_perform(curl);
if (!chunk.empty()) {
- cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size())
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "CURL output: ["
+ << cmCTestLogWrite(chunk.data(), chunk.size())
<< "]" << std::endl,
this->Quiet);
this->ParseResponse(chunk);
}
if (!chunkDebug.empty()) {
cmCTestOptionalLog(
- this->CTest, DEBUG, "CURL debug output: ["
- << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
+ this->CTest, DEBUG,
+ "CURL debug output: ["
+ << cmCTestLogWrite(chunkDebug.data(), chunkDebug.size()) << "]"
<< std::endl,
this->Quiet);
}
@@ -496,30 +355,31 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
// If curl failed for any reason, or checksum fails, wait and retry
//
if (res != CURLE_OK || this->HasErrors) {
- std::string retryDelay = this->GetOption("RetryDelay") == CM_NULLPTR
+ std::string retryDelay = this->GetOption("RetryDelay") == nullptr
? ""
: this->GetOption("RetryDelay");
- std::string retryCount = this->GetOption("RetryCount") == CM_NULLPTR
+ std::string retryCount = this->GetOption("RetryCount") == nullptr
? ""
: this->GetOption("RetryCount");
- int delay = retryDelay == ""
- ? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryDelay")
- .c_str())
- : atoi(retryDelay.c_str());
- int count = retryCount == ""
+ auto delay = cmDuration(
+ retryDelay.empty()
+ ? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryDelay")
+ .c_str())
+ : atoi(retryDelay.c_str()));
+ int count = retryCount.empty()
? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryCount")
.c_str())
: atoi(retryCount.c_str());
for (int i = 0; i < count; i++) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Submit failed, waiting " << delay
+ " Submit failed, waiting " << delay.count()
<< " seconds...\n",
this->Quiet);
- double stop = cmSystemTools::GetTime() + delay;
- while (cmSystemTools::GetTime() < stop) {
+ auto stop = std::chrono::steady_clock::now() + delay;
+ while (std::chrono::steady_clock::now() < stop) {
cmSystemTools::Delay(100);
}
@@ -539,11 +399,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
res = ::curl_easy_perform(curl);
if (!chunk.empty()) {
- cmCTestOptionalLog(
- this->CTest, DEBUG, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
- << std::endl,
- this->Quiet);
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "CURL output: ["
+ << cmCTestLogWrite(chunk.data(), chunk.size())
+ << "]" << std::endl,
+ this->Quiet);
this->ParseResponse(chunk);
}
@@ -555,8 +415,9 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
fclose(ftpfile);
if (res) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when uploading file: "
- << local_file << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ " Error when uploading file: " << local_file
+ << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
" Error message was: " << error_buffer << std::endl);
*this->LogFile << " Error when uploading file: " << local_file
@@ -566,10 +427,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
// avoid deref of begin for zero size array
if (!chunk.empty()) {
*this->LogFile << " Curl output was: "
- << cmCTestLogWrite(&*chunk.begin(), chunk.size())
+ << cmCTestLogWrite(chunk.data(), chunk.size())
<< std::endl;
- cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "CURL output: ["
+ << cmCTestLogWrite(chunk.data(), chunk.size()) << "]"
<< std::endl);
}
::curl_easy_cleanup(curl);
@@ -605,6 +467,7 @@ void cmCTestSubmitHandler::ParseResponse(
" Submission failed: " << parser.Message << std::endl);
return;
}
+ this->CTest->SetBuildID(parser.BuildID);
}
output = cmSystemTools::UpperCase(output);
if (output.find("WARNING") != std::string::npos) {
@@ -615,395 +478,12 @@ void cmCTestSubmitHandler::ParseResponse(
}
if (this->HasWarnings || this->HasErrors) {
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " Server Response:\n"
- << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "\n");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " Server Response:\n"
+ << cmCTestLogWrite(chunk.data(), chunk.size()) << "\n");
}
}
-bool cmCTestSubmitHandler::TriggerUsingHTTP(const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url)
-{
- CURL* curl;
- char error_buffer[1024];
-
- /* In windows, this will init the winsock stuff */
- ::curl_global_init(CURL_GLOBAL_ALL);
-
- cmCTest::SetOfStrings::const_iterator file;
- for (file = files.begin(); file != files.end(); ++file) {
- /* get a curl handle */
- curl = curl_easy_init();
- if (curl) {
- // Using proxy
- if (this->HTTPProxyType > 0) {
- curl_easy_setopt(curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
- switch (this->HTTPProxyType) {
- case 2:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
- break;
- case 3:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
- break;
- default:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
- if (!this->HTTPProxyAuth.empty()) {
- curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
- this->HTTPProxyAuth.c_str());
- }
- }
- }
-
- ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
-
- // and give curl the buffer for errors
- ::curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, &error_buffer);
-
- // specify handler for output
- ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
- cmCTestSubmitHandlerWriteMemoryCallback);
- ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION,
- cmCTestSubmitHandlerCurlDebugCallback);
-
- /* we pass our 'chunk' struct to the callback function */
- cmCTestSubmitHandlerVectorOfChar chunk;
- cmCTestSubmitHandlerVectorOfChar chunkDebug;
- ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&chunk);
- ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
-
- std::string rfile = remoteprefix + cmSystemTools::GetFilenameName(*file);
- std::string ofile;
- std::string::iterator kk;
- for (kk = rfile.begin(); kk < rfile.end(); ++kk) {
- char c = *kk;
- char hexCh[4] = { 0, 0, 0, 0 };
- hexCh[0] = c;
- switch (c) {
- case '+':
- case '?':
- case '/':
- case '\\':
- case '&':
- case ' ':
- case '=':
- case '%':
- sprintf(hexCh, "%%%02X", (int)c);
- ofile.append(hexCh);
- break;
- default:
- ofile.append(hexCh);
- }
- }
- std::string turl = url +
- ((url.find('?') == std::string::npos) ? '?' : '&') + "xmlfile=" +
- ofile;
- *this->LogFile << "Trigger url: " << turl << std::endl;
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Trigger url: " << turl << std::endl, this->Quiet);
- curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- curl_easy_setopt(curl, CURLOPT_URL, turl.c_str());
- if (curl_easy_perform(curl)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Error when triggering: " << turl << std::endl);
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Error message was: " << error_buffer << std::endl);
- *this->LogFile << "\tTriggering failed with error: " << error_buffer
- << std::endl
- << " Error message was: " << error_buffer
- << std::endl;
- if (!chunk.empty()) {
- *this->LogFile << " Curl output was: "
- << cmCTestLogWrite(&*chunk.begin(), chunk.size())
- << std::endl;
- cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
- << std::endl);
- }
- ::curl_easy_cleanup(curl);
- ::curl_global_cleanup();
- return false;
- }
-
- if (!chunk.empty()) {
- cmCTestOptionalLog(this->CTest, DEBUG, "CURL output: ["
- << cmCTestLogWrite(&*chunk.begin(), chunk.size())
- << "]" << std::endl,
- this->Quiet);
- }
- if (!chunkDebug.empty()) {
- cmCTestOptionalLog(
- this->CTest, DEBUG, "CURL debug output: ["
- << cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
- << std::endl,
- this->Quiet);
- }
-
- // always cleanup
- ::curl_easy_cleanup(curl);
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl,
- this->Quiet);
- }
- }
- ::curl_global_cleanup();
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Dart server triggered..." << std::endl, this->Quiet);
- return true;
-}
-
-bool cmCTestSubmitHandler::SubmitUsingSCP(const std::string& scp_command,
- const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url)
-{
- if (scp_command.empty() || localprefix.empty() || files.empty() ||
- remoteprefix.empty() || url.empty()) {
- return false;
- }
-
- std::vector<const char*> argv;
- argv.push_back(scp_command.c_str()); // Scp command
- argv.push_back(scp_command.c_str()); // Dummy string for file
- argv.push_back(scp_command.c_str()); // Dummy string for remote url
- argv.push_back(CM_NULLPTR);
-
- cmsysProcess* cp = cmsysProcess_New();
- cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
- // cmsysProcess_SetTimeout(cp, timeout);
-
- int problems = 0;
-
- cmCTest::SetOfStrings::const_iterator file;
- for (file = files.begin(); file != files.end(); ++file) {
- int retVal;
-
- std::string lfname = localprefix;
- cmSystemTools::ConvertToUnixSlashes(lfname);
- lfname += "/" + *file;
- lfname = cmSystemTools::ConvertToOutputPath(lfname.c_str());
- argv[1] = lfname.c_str();
- std::string rfname = url + "/" + remoteprefix + *file;
- argv[2] = rfname.c_str();
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Execute \""
- << argv[0] << "\" \"" << argv[1] << "\" \"" << argv[2]
- << "\"" << std::endl,
- this->Quiet);
- *this->LogFile << "Execute \"" << argv[0] << "\" \"" << argv[1] << "\" \""
- << argv[2] << "\"" << std::endl;
-
- cmsysProcess_SetCommand(cp, &*argv.begin());
- cmsysProcess_Execute(cp);
- char* data;
- int length;
- cmProcessOutput processOutput;
- std::string strdata;
-
- while (cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) {
- processOutput.DecodeText(data, length, strdata);
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- cmCTestLogWrite(strdata.c_str(), strdata.size()),
- this->Quiet);
- }
- processOutput.DecodeText(std::string(), strdata);
- if (!strdata.empty()) {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- cmCTestLogWrite(strdata.c_str(), strdata.size()),
- this->Quiet);
- }
-
- cmsysProcess_WaitForExit(cp, CM_NULLPTR);
-
- int result = cmsysProcess_GetState(cp);
-
- if (result == cmsysProcess_State_Exited) {
- retVal = cmsysProcess_GetExitValue(cp);
- if (retVal != 0) {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "\tSCP returned: " << retVal << std::endl,
- this->Quiet);
- *this->LogFile << "\tSCP returned: " << retVal << std::endl;
- problems++;
- }
- } else if (result == cmsysProcess_State_Exception) {
- retVal = cmsysProcess_GetExitException(cp);
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "\tThere was an exception: " << retVal << std::endl);
- *this->LogFile << "\tThere was an exception: " << retVal << std::endl;
- problems++;
- } else if (result == cmsysProcess_State_Expired) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was a timeout"
- << std::endl);
- *this->LogFile << "\tThere was a timeout" << std::endl;
- problems++;
- } else if (result == cmsysProcess_State_Error) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "\tError executing SCP: "
- << cmsysProcess_GetErrorString(cp) << std::endl);
- *this->LogFile << "\tError executing SCP: "
- << cmsysProcess_GetErrorString(cp) << std::endl;
- problems++;
- }
- }
- cmsysProcess_Delete(cp);
- return problems == 0;
-}
-
-bool cmCTestSubmitHandler::SubmitUsingCP(const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& destination)
-{
- if (localprefix.empty() || files.empty() || remoteprefix.empty() ||
- destination.empty()) {
- /* clang-format off */
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Missing arguments for submit via cp:\n"
- << "\tlocalprefix: " << localprefix << "\n"
- << "\tNumber of files: " << files.size() << "\n"
- << "\tremoteprefix: " << remoteprefix << "\n"
- << "\tdestination: " << destination << std::endl);
- /* clang-format on */
- return false;
- }
-
- cmCTest::SetOfStrings::const_iterator file;
- for (file = files.begin(); file != files.end(); ++file) {
- std::string lfname = localprefix;
- cmSystemTools::ConvertToUnixSlashes(lfname);
- lfname += "/" + *file;
- std::string rfname = destination + "/" + remoteprefix + *file;
- cmSystemTools::CopyFileAlways(lfname, rfname);
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Copy file: "
- << lfname << " to " << rfname << std::endl,
- this->Quiet);
- }
- std::string tagDoneFile = destination + "/" + remoteprefix + "DONE";
- cmSystemTools::Touch(tagDoneFile, true);
- return true;
-}
-
-#if defined(CTEST_USE_XMLRPC)
-bool cmCTestSubmitHandler::SubmitUsingXMLRPC(
- const std::string& localprefix, const std::set<std::string>& files,
- const std::string& remoteprefix, const std::string& url)
-{
- xmlrpc_env env;
- char ctestString[] = "CTest";
- std::string ctestVersionString = cmVersion::GetCMakeVersion();
- char* ctestVersion = const_cast<char*>(ctestVersionString.c_str());
-
- std::string realURL = url + "/" + remoteprefix + "/Command/";
-
- /* Start up our XML-RPC client library. */
- xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, ctestString, ctestVersion);
-
- /* Initialize our error-handling environment. */
- xmlrpc_env_init(&env);
-
- /* Call the famous server at UserLand. */
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Submitting to: "
- << realURL << " (" << remoteprefix << ")" << std::endl,
- this->Quiet);
- cmCTest::SetOfStrings::const_iterator file;
- for (file = files.begin(); file != files.end(); ++file) {
- xmlrpc_value* result;
-
- std::string local_file = *file;
- if (!cmSystemTools::FileExists(local_file.c_str())) {
- local_file = localprefix + "/" + *file;
- }
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Submit file: " << local_file << std::endl,
- this->Quiet);
- struct stat st;
- if (::stat(local_file.c_str(), &st)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Cannot find file: " << local_file << std::endl);
- return false;
- }
-
- // off_t can be bigger than size_t. fread takes size_t.
- // make sure the file is not too big.
- if (static_cast<off_t>(static_cast<size_t>(st.st_size)) !=
- static_cast<off_t>(st.st_size)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, " File too big: " << local_file
- << std::endl);
- return false;
- }
- size_t fileSize = static_cast<size_t>(st.st_size);
- FILE* fp = cmsys::SystemTools::Fopen(local_file, "rb");
- if (!fp) {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Cannot open file: " << local_file << std::endl);
- return false;
- }
-
- unsigned char* fileBuffer = new unsigned char[fileSize];
- if (fread(fileBuffer, 1, fileSize, fp) != fileSize) {
- delete[] fileBuffer;
- fclose(fp);
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Cannot read file: " << local_file << std::endl);
- return false;
- }
- fclose(fp);
-
- char remoteCommand[] = "Submit.put";
- char* pRealURL = const_cast<char*>(realURL.c_str());
- result = xmlrpc_client_call(&env, pRealURL, remoteCommand, "(6)",
- fileBuffer, (xmlrpc_int32)fileSize);
-
- delete[] fileBuffer;
-
- if (env.fault_occurred) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, " Submission problem: "
- << env.fault_string << " (" << env.fault_code << ")"
- << std::endl);
- xmlrpc_env_clean(&env);
- xmlrpc_client_cleanup();
- return false;
- }
-
- /* Dispose of our result value. */
- xmlrpc_DECREF(result);
- }
-
- /* Clean up our error-handling environment. */
- xmlrpc_env_clean(&env);
-
- /* Shutdown our XML-RPC client library. */
- xmlrpc_client_cleanup();
- return true;
-}
-#else
-bool cmCTestSubmitHandler::SubmitUsingXMLRPC(
- std::string const& /*unused*/, std::set<std::string> const& /*unused*/,
- std::string const& /*unused*/, std::string const& /*unused*/)
-{
- return false;
-}
-#endif
-
-void cmCTestSubmitHandler::ConstructCDashURL(std::string& dropMethod,
- std::string& url)
-{
- dropMethod = this->CTest->GetCTestConfiguration("DropMethod");
- url = dropMethod;
- url += "://";
- if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
- url += this->CTest->GetCTestConfiguration("DropSiteUser");
- cmCTestOptionalLog(
- this->CTest, HANDLER_OUTPUT,
- this->CTest->GetCTestConfiguration("DropSiteUser").c_str(), this->Quiet);
- if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) {
- url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******", this->Quiet);
- }
- url += "@";
- }
- url += this->CTest->GetCTestConfiguration("DropSite") +
- this->CTest->GetCTestConfiguration("DropLocation");
-}
-
int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
std::string const& typeString)
{
@@ -1012,70 +492,75 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
return -1;
}
if (!cmSystemTools::FileExists(file)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Upload file not found: '"
- << file << "'\n");
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Upload file not found: '" << file << "'\n");
return -1;
}
cmCTestCurl curl(this->CTest);
curl.SetQuiet(this->Quiet);
std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
- std::vector<std::string> args;
- cmSystemTools::ExpandListArgument(curlopt, args);
+ std::vector<std::string> args = cmExpandedList(curlopt);
curl.SetCurlOptions(args);
curl.SetTimeOutSeconds(SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
curl.SetHttpHeaders(this->HttpHeaders);
- std::string dropMethod;
- std::string url;
- this->ConstructCDashURL(dropMethod, url);
- std::string::size_type pos = url.find("submit.php?");
- url = url.substr(0, pos + 10);
- if (!(dropMethod == "http" || dropMethod == "https")) {
+ std::string url = this->CTest->GetSubmitURL();
+ std::string fields;
+ std::string::size_type pos = url.find('?');
+ if (pos != std::string::npos) {
+ fields = url.substr(pos + 1);
+ url = url.substr(0, pos);
+ }
+ if (!cmHasLiteralPrefix(url, "http://") &&
+ !cmHasLiteralPrefix(url, "https://")) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Only http and https are supported for CDASH_UPLOAD\n");
return -1;
}
- bool internalTest = cmSystemTools::IsOn(this->GetOption("InternalTest"));
+ bool internalTest = cmIsOn(this->GetOption("InternalTest"));
// Get RETRY_COUNT and RETRY_DELAY values if they were set.
- std::string retryDelayString = this->GetOption("RetryDelay") == CM_NULLPTR
+ std::string retryDelayString = this->GetOption("RetryDelay") == nullptr
? ""
: this->GetOption("RetryDelay");
- std::string retryCountString = this->GetOption("RetryCount") == CM_NULLPTR
+ std::string retryCountString = this->GetOption("RetryCount") == nullptr
? ""
: this->GetOption("RetryCount");
- unsigned long retryDelay = 0;
- if (retryDelayString != "") {
- if (!cmSystemTools::StringToULong(retryDelayString.c_str(), &retryDelay)) {
- cmCTestLog(this->CTest, WARNING, "Invalid value for 'RETRY_DELAY' : "
- << retryDelayString << std::endl);
+ auto retryDelay = std::chrono::seconds(0);
+ if (!retryDelayString.empty()) {
+ unsigned long retryDelayValue = 0;
+ if (!cmStrToULong(retryDelayString, &retryDelayValue)) {
+ cmCTestLog(this->CTest, WARNING,
+ "Invalid value for 'RETRY_DELAY' : " << retryDelayString
+ << std::endl);
+ } else {
+ retryDelay = std::chrono::seconds(retryDelayValue);
}
}
unsigned long retryCount = 0;
- if (retryCountString != "") {
- if (!cmSystemTools::StringToULong(retryCountString.c_str(), &retryCount)) {
- cmCTestLog(this->CTest, WARNING, "Invalid value for 'RETRY_DELAY' : "
- << retryCountString << std::endl);
+ if (!retryCountString.empty()) {
+ if (!cmStrToULong(retryCountString, &retryCount)) {
+ cmCTestLog(this->CTest, WARNING,
+ "Invalid value for 'RETRY_DELAY' : " << retryCountString
+ << std::endl);
}
}
- char md5sum[33];
- md5sum[32] = 0;
- cmSystemTools::ComputeFileMD5(file, md5sum);
+ std::string md5sum =
+ cmSystemTools::ComputeFileHash(file, cmCryptoHash::AlgoMD5);
// 1. request the buildid and check to see if the file
// has already been uploaded
// TODO I added support for subproject. You would need to add
// a "&subproject=subprojectname" to the first POST.
- cmCTestScriptHandler* ch =
- static_cast<cmCTestScriptHandler*>(this->CTest->GetHandler("script"));
+ cmCTestScriptHandler* ch = this->CTest->GetScriptHandler();
cmake* cm = ch->GetCMake();
const char* subproject = cm->GetState()->GetGlobalProperty("SubProject");
// TODO: Encode values for a URL instead of trusting caller.
std::ostringstream str;
- str << "project="
- << curl.Escape(this->CTest->GetCTestConfiguration("ProjectName")) << "&";
if (subproject) {
str << "subproject=" << curl.Escape(subproject) << "&";
}
+ auto timeNow =
+ std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
str << "stamp=" << curl.Escape(this->CTest->GetCurrentTag()) << "-"
<< curl.Escape(this->CTest->GetTestModelString()) << "&"
<< "model=" << curl.Escape(this->CTest->GetTestModelString()) << "&"
@@ -1083,12 +568,20 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
<< curl.Escape(this->CTest->GetCTestConfiguration("BuildName")) << "&"
<< "site=" << curl.Escape(this->CTest->GetCTestConfiguration("Site"))
<< "&"
+ << "group=" << curl.Escape(this->CTest->GetTestModelString())
+ << "&"
+ // For now, we send both "track" and "group" to CDash in case we're
+ // submitting to an older instance that still expects the prior
+ // terminology.
<< "track=" << curl.Escape(this->CTest->GetTestModelString()) << "&"
- << "starttime=" << (int)cmSystemTools::GetTime() << "&"
- << "endtime=" << (int)cmSystemTools::GetTime() << "&"
+ << "starttime=" << timeNow << "&"
+ << "endtime=" << timeNow << "&"
<< "datafilesmd5[0]=" << md5sum << "&"
<< "type=" << curl.Escape(typeString);
- std::string fields = str.str();
+ if (!fields.empty()) {
+ fields += '&';
+ }
+ fields += str.str();
cmCTestOptionalLog(this->CTest, DEBUG,
"fields: " << fields << "\nurl:" << url
<< "\nfile: " << file << "\n",
@@ -1100,12 +593,12 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
// If request failed, wait and retry.
for (unsigned long i = 0; i < retryCount; i++) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Request failed, waiting " << retryDelay
+ " Request failed, waiting " << retryDelay.count()
<< " seconds...\n",
this->Quiet);
- double stop = cmSystemTools::GetTime() + static_cast<double>(retryDelay);
- while (cmSystemTools::GetTime() < stop) {
+ auto stop = std::chrono::steady_clock::now() + retryDelay;
+ while (std::chrono::steady_clock::now() < stop) {
cmSystemTools::Delay(100);
}
@@ -1121,7 +614,8 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
}
}
if (!internalTest && !requestSucceeded) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in HttpRequest\n"
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Error in HttpRequest\n"
<< response);
return -1;
}
@@ -1131,7 +625,8 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
Json::Value json;
Json::Reader reader;
if (!internalTest && !reader.parse(response, json)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "error parsing json string ["
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "error parsing json string ["
<< response << "]\n"
<< reader.getFormattedErrorMessages() << "\n");
return -1;
@@ -1174,12 +669,12 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
// If upload failed, wait and retry.
for (unsigned long i = 0; i < retryCount; i++) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Upload failed, waiting " << retryDelay
+ " Upload failed, waiting " << retryDelay.count()
<< " seconds...\n",
this->Quiet);
- double stop = cmSystemTools::GetTime() + static_cast<double>(retryDelay);
- while (cmSystemTools::GetTime() < stop) {
+ auto stop = std::chrono::steady_clock::now() + retryDelay;
+ while (std::chrono::steady_clock::now() < stop) {
cmSystemTools::Delay(100);
}
@@ -1198,12 +693,14 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
}
if (!uploadSucceeded) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "error uploading to CDash. "
- << file << " " << url << " " << fstr.str());
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "error uploading to CDash. " << file << " " << url << " "
+ << fstr.str());
return -1;
}
if (!reader.parse(response, json)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "error parsing json string ["
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "error parsing json string ["
<< response << "]\n"
<< reader.getFormattedErrorMessages() << "\n");
return -1;
@@ -1221,11 +718,6 @@ int cmCTestSubmitHandler::ProcessHandler()
if (cdashUploadFile && cdashUploadType) {
return this->HandleCDashUploadFile(cdashUploadFile, cdashUploadType);
}
- std::string iscdash = this->CTest->GetCTestConfiguration("IsCDash");
- // cdash does not need to trigger so just return true
- if (!iscdash.empty()) {
- this->CDash = true;
- }
const std::string& buildDirectory =
this->CTest->GetCTestConfiguration("BuildDirectory");
@@ -1263,46 +755,20 @@ int cmCTestSubmitHandler::ProcessHandler()
}
}
- if (getenv("FTP_PROXY")) {
- this->FTPProxyType = 1;
- this->FTPProxy = getenv("FTP_PROXY");
- if (getenv("FTP_PROXY_PORT")) {
- this->FTPProxy += ":";
- this->FTPProxy += getenv("FTP_PROXY_PORT");
- }
- if (getenv("FTP_PROXY_TYPE")) {
- std::string type = getenv("FTP_PROXY_TYPE");
- // HTTP/SOCKS4/SOCKS5
- if (type == "HTTP") {
- this->FTPProxyType = 1;
- } else if (type == "SOCKS4") {
- this->FTPProxyType = 2;
- } else if (type == "SOCKS5") {
- this->FTPProxyType = 3;
- }
- }
- }
-
if (!this->HTTPProxy.empty()) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
" Use HTTP Proxy: " << this->HTTPProxy << std::endl,
this->Quiet);
}
- if (!this->FTPProxy.empty()) {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Use FTP Proxy: " << this->FTPProxy << std::endl,
- this->Quiet);
- }
cmGeneratedFileStream ofs;
this->StartLogFile("Submit", ofs);
- cmCTest::SetOfStrings files;
+ std::vector<std::string> files;
std::string prefix = this->GetSubmitResultsPrefix();
if (!this->Files.empty()) {
// Submit the explicitly selected files:
- //
- files.insert(this->Files.begin(), this->Files.end());
+ cmAppend(files, this->Files);
}
// Add to the list of files to submit from any selected, existing parts:
@@ -1324,13 +790,11 @@ int cmCTestSubmitHandler::ProcessHandler()
cmCTestOptionalLog(this->CTest, DEBUG,
"Globbing for: " << gpath << std::endl, this->Quiet);
if (cmSystemTools::SimpleGlob(gpath, gfiles, 1)) {
- size_t cc;
- for (cc = 0; cc < gfiles.size(); cc++) {
- gfiles[cc] = gfiles[cc].substr(glen);
+ for (std::string& gfile : gfiles) {
+ gfile = gfile.substr(glen);
cmCTestOptionalLog(this->CTest, DEBUG,
- "Glob file: " << gfiles[cc] << std::endl,
- this->Quiet);
- this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfiles[cc].c_str());
+ "Glob file: " << gfile << std::endl, this->Quiet);
+ this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfile.c_str());
}
} else {
cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem globbing" << std::endl);
@@ -1350,234 +814,67 @@ int cmCTestSubmitHandler::ProcessHandler()
}
// Submit files from this part.
- std::vector<std::string> const& pfiles = this->CTest->GetSubmitFiles(p);
- files.insert(pfiles.begin(), pfiles.end());
+ cmAppend(files, this->CTest->GetSubmitFiles(p));
+ }
+
+ // Make sure files are unique, but preserve order.
+ {
+ // This endPos intermediate is needed to work around non-conformant C++11
+ // standard libraries that have erase(iterator,iterator) instead of
+ // erase(const_iterator,const_iterator).
+ size_t endPos = cmRemoveDuplicates(files) - files.cbegin();
+ files.erase(files.begin() + endPos, files.end());
+ }
+
+ // Submit Done.xml last
+ if (this->SubmitPart[cmCTest::PartDone]) {
+ files.emplace_back("Done.xml");
}
if (ofs) {
ofs << "Upload files:" << std::endl;
int cnt = 0;
- cmCTest::SetOfStrings::iterator it;
- for (it = files.begin(); it != files.end(); ++it) {
- ofs << cnt << "\t" << *it << std::endl;
+ for (std::string const& file : files) {
+ ofs << cnt << "\t" << file << std::endl;
cnt++;
}
}
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Submit files (using "
- << this->CTest->GetCTestConfiguration("DropMethod")
- << ")" << std::endl,
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Submit files\n",
this->Quiet);
- const char* specificTrack = this->CTest->GetSpecificTrack();
- if (specificTrack) {
+ const char* specificGroup = this->CTest->GetSpecificGroup();
+ if (specificGroup) {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Send to track: " << specificTrack << std::endl,
+ " Send to group: " << specificGroup << std::endl,
this->Quiet);
}
this->SetLogFile(&ofs);
- std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
-
- if (dropMethod == "" || dropMethod == "ftp") {
- ofs << "Using drop method: FTP" << std::endl;
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Using FTP submit method" << std::endl
- << " Drop site: ftp://",
- this->Quiet);
- std::string url = "ftp://";
- url += cmCTest::MakeURLSafe(
- this->CTest->GetCTestConfiguration("DropSiteUser")) +
- ":" + cmCTest::MakeURLSafe(
- this->CTest->GetCTestConfiguration("DropSitePassword")) +
- "@" + this->CTest->GetCTestConfiguration("DropSite") +
- cmCTest::MakeURLSafe(this->CTest->GetCTestConfiguration("DropLocation"));
- if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
- cmCTestOptionalLog(
- this->CTest, HANDLER_OUTPUT,
- this->CTest->GetCTestConfiguration("DropSiteUser").c_str(),
- this->Quiet);
- if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******",
- this->Quiet);
- }
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "@", this->Quiet);
- }
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- this->CTest->GetCTestConfiguration("DropSite")
- << this->CTest->GetCTestConfiguration("DropLocation")
- << std::endl,
- this->Quiet);
- if (!this->SubmitUsingFTP(buildDirectory + "/Testing/" +
- this->CTest->GetCurrentTag(),
- files, prefix, url)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Problems when submitting via FTP" << std::endl);
- ofs << " Problems when submitting via FTP" << std::endl;
- return -1;
- }
- if (!this->CDash) {
- cmCTestOptionalLog(
- this->CTest, HANDLER_OUTPUT, " Using HTTP trigger method"
- << std::endl
- << " Trigger site: "
- << this->CTest->GetCTestConfiguration("TriggerSite") << std::endl,
- this->Quiet);
- if (!this->TriggerUsingHTTP(
- files, prefix,
- this->CTest->GetCTestConfiguration("TriggerSite"))) {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Problems when triggering via HTTP" << std::endl);
- ofs << " Problems when triggering via HTTP" << std::endl;
- return -1;
- }
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Submission successful" << std::endl, this->Quiet);
- ofs << " Submission successful" << std::endl;
- return 0;
- }
- } else if (dropMethod == "http" || dropMethod == "https") {
- std::string url = dropMethod;
- url += "://";
- ofs << "Using drop method: " << dropMethod << std::endl;
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Using HTTP submit method" << std::endl
- << " Drop site:" << url,
- this->Quiet);
- if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
- url += this->CTest->GetCTestConfiguration("DropSiteUser");
- cmCTestOptionalLog(
- this->CTest, HANDLER_OUTPUT,
- this->CTest->GetCTestConfiguration("DropSiteUser").c_str(),
- this->Quiet);
- if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty()) {
- url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, ":******",
- this->Quiet);
- }
- url += "@";
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "@", this->Quiet);
- }
- url += this->CTest->GetCTestConfiguration("DropSite") +
- this->CTest->GetCTestConfiguration("DropLocation");
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- this->CTest->GetCTestConfiguration("DropSite")
- << this->CTest->GetCTestConfiguration("DropLocation")
- << std::endl,
- this->Quiet);
- if (!this->SubmitUsingHTTP(buildDirectory + "/Testing/" +
- this->CTest->GetCurrentTag(),
- files, prefix, url)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Problems when submitting via HTTP" << std::endl);
- ofs << " Problems when submitting via HTTP" << std::endl;
- return -1;
- }
- if (!this->CDash) {
- cmCTestOptionalLog(
- this->CTest, HANDLER_OUTPUT, " Using HTTP trigger method"
- << std::endl
- << " Trigger site: "
- << this->CTest->GetCTestConfiguration("TriggerSite") << std::endl,
- this->Quiet);
- if (!this->TriggerUsingHTTP(
- files, prefix,
- this->CTest->GetCTestConfiguration("TriggerSite"))) {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Problems when triggering via HTTP" << std::endl);
- ofs << " Problems when triggering via HTTP" << std::endl;
- return -1;
- }
- }
- if (this->HasErrors) {
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " Errors occurred during "
- "submission."
- << std::endl);
- ofs << " Errors occurred during submission. " << std::endl;
- } else {
- cmCTestOptionalLog(
- this->CTest, HANDLER_OUTPUT, " Submission successful"
- << (this->HasWarnings ? ", with warnings." : "") << std::endl,
- this->Quiet);
- ofs << " Submission successful"
- << (this->HasWarnings ? ", with warnings." : "") << std::endl;
- }
-
- return 0;
- } else if (dropMethod == "xmlrpc") {
-#if defined(CTEST_USE_XMLRPC)
- ofs << "Using drop method: XML-RPC" << std::endl;
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Using XML-RPC submit method" << std::endl,
- this->Quiet);
- std::string url = this->CTest->GetCTestConfiguration("DropSite");
- prefix = this->CTest->GetCTestConfiguration("DropLocation");
- if (!this->SubmitUsingXMLRPC(buildDirectory + "/Testing/" +
- this->CTest->GetCurrentTag(),
- files, prefix, url)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Problems when submitting via XML-RPC" << std::endl);
- ofs << " Problems when submitting via XML-RPC" << std::endl;
- return -1;
- }
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Submission successful" << std::endl, this->Quiet);
- ofs << " Submission successful" << std::endl;
- return 0;
-#else
+ std::string url = this->CTest->GetSubmitURL();
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " SubmitURL: " << url << '\n', this->Quiet);
+ if (!this->SubmitUsingHTTP(buildDirectory + "/Testing/" +
+ this->CTest->GetCurrentTag(),
+ files, prefix, url)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Submission method \"xmlrpc\" not compiled into CTest!"
- << std::endl);
+ " Problems when submitting via HTTP\n");
+ ofs << " Problems when submitting via HTTP\n";
return -1;
-#endif
- } else if (dropMethod == "scp") {
- std::string url;
- if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
- url += this->CTest->GetCTestConfiguration("DropSiteUser") + "@";
- }
- url += this->CTest->GetCTestConfiguration("DropSite") + ":" +
- this->CTest->GetCTestConfiguration("DropLocation");
-
- // change to the build directory so that we can uses a relative path
- // on windows since scp dosn't support "c:" a drive in the path
- cmWorkingDirectory workdir(buildDirectory);
-
- if (!this->SubmitUsingSCP(this->CTest->GetCTestConfiguration("ScpCommand"),
- "Testing/" + this->CTest->GetCurrentTag(), files,
- prefix, url)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Problems when submitting via SCP" << std::endl);
- ofs << " Problems when submitting via SCP" << std::endl;
- return -1;
- }
+ }
+ if (this->HasErrors) {
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " Errors occurred during submission.\n");
+ ofs << " Errors occurred during submission.\n";
+ } else {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Submission successful" << std::endl, this->Quiet);
- ofs << " Submission successful" << std::endl;
- return 0;
- } else if (dropMethod == "cp") {
- std::string location = this->CTest->GetCTestConfiguration("DropLocation");
-
- // change to the build directory so that we can uses a relative path
- // on windows since scp dosn't support "c:" a drive in the path
- cmWorkingDirectory workdir(buildDirectory);
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Change directory: " << buildDirectory << std::endl,
+ " Submission successful"
+ << (this->HasWarnings ? ", with warnings." : "")
+ << std::endl,
this->Quiet);
-
- if (!this->SubmitUsingCP("Testing/" + this->CTest->GetCurrentTag(), files,
- prefix, location)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- " Problems when submitting via CP" << std::endl);
- ofs << " Problems when submitting via cp" << std::endl;
- return -1;
- }
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- " Submission successful" << std::endl, this->Quiet);
- ofs << " Submission successful" << std::endl;
- return 0;
+ ofs << " Submission successful"
+ << (this->HasWarnings ? ", with warnings." : "") << std::endl;
}
- cmCTestLog(this->CTest, ERROR_MESSAGE, " Unknown submission method: \""
- << dropMethod << "\"" << std::endl);
- return -1;
+ return 0;
}
std::string cmCTestSubmitHandler::GetSubmitResultsPrefix()
@@ -1600,7 +897,7 @@ void cmCTestSubmitHandler::SelectParts(std::set<cmCTest::Part> const& parts)
}
}
-void cmCTestSubmitHandler::SelectFiles(cmCTest::SetOfStrings const& files)
+void cmCTestSubmitHandler::SelectFiles(std::set<std::string> const& files)
{
this->Files.insert(files.begin(), files.end());
}
diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h
index 2923f4f3d..304daaa98 100644
--- a/Source/CTest/cmCTestSubmitHandler.h
+++ b/Source/CTest/cmCTestSubmitHandler.h
@@ -3,16 +3,16 @@
#ifndef cmCTestSubmitHandler_h
#define cmCTestSubmitHandler_h
-#include "cmConfigure.h"
-
-#include "cmCTest.h"
-#include "cmCTestGenericHandler.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <set>
#include <string>
#include <vector>
+#include "cmCTest.h"
+#include "cmCTestGenericHandler.h"
+
/** \class cmCTestSubmitHandler
* \brief Helper class for CTest
*
@@ -22,23 +22,23 @@
class cmCTestSubmitHandler : public cmCTestGenericHandler
{
public:
- typedef cmCTestGenericHandler Superclass;
+ using Superclass = cmCTestGenericHandler;
cmCTestSubmitHandler();
- ~cmCTestSubmitHandler() CM_OVERRIDE { this->LogFile = CM_NULLPTR; }
+ ~cmCTestSubmitHandler() override { this->LogFile = nullptr; }
/*
* The main entry point for this class
*/
- int ProcessHandler() CM_OVERRIDE;
+ int ProcessHandler() override;
- void Initialize() CM_OVERRIDE;
+ void Initialize() override;
/** Specify a set of parts (by name) to submit. */
void SelectParts(std::set<cmCTest::Part> const& parts);
/** Specify a set of files to submit. */
- void SelectFiles(cmCTest::SetOfStrings const& files);
+ void SelectFiles(std::set<std::string> const& files);
// handle the cdash file upload protocol
int HandleCDashUploadFile(std::string const& file, std::string const& type);
@@ -48,40 +48,18 @@ public:
this->HttpHeaders = v;
}
- void ConstructCDashURL(std::string& dropMethod, std::string& url);
-
private:
void SetLogFile(std::ostream* ost) { this->LogFile = ost; }
/**
* Submit file using various ways
*/
- bool SubmitUsingFTP(const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix, const std::string& url);
bool SubmitUsingHTTP(const std::string& localprefix,
- const std::set<std::string>& files,
+ const std::vector<std::string>& files,
const std::string& remoteprefix,
const std::string& url);
- bool SubmitUsingSCP(const std::string& scp_command,
- const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix, const std::string& url);
-
- bool SubmitUsingCP(const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix, const std::string& url);
-
- bool TriggerUsingHTTP(const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url);
-
- bool SubmitUsingXMLRPC(const std::string& localprefix,
- const std::set<std::string>& files,
- const std::string& remoteprefix,
- const std::string& url);
- typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar;
+ using cmCTestSubmitHandlerVectorOfChar = std::vector<char>;
void ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk);
@@ -92,14 +70,11 @@ private:
std::string HTTPProxy;
int HTTPProxyType;
std::string HTTPProxyAuth;
- std::string FTPProxy;
- int FTPProxyType;
std::ostream* LogFile;
bool SubmitPart[cmCTest::PartCount];
- bool CDash;
bool HasWarnings;
bool HasErrors;
- cmCTest::SetOfStrings Files;
+ std::set<std::string> Files;
std::vector<std::string> HttpHeaders;
};
diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx
index 075b1403a..978421405 100644
--- a/Source/CTest/cmCTestTestCommand.cxx
+++ b/Source/CTest/cmCTestTestCommand.cxx
@@ -2,33 +2,37 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestTestCommand.h"
+#include <chrono>
+#include <cstdlib>
+#include <sstream>
+
+#include "cm_static_string_view.hxx"
+
#include "cmCTest.h"
#include "cmCTestGenericHandler.h"
+#include "cmCTestTestHandler.h"
+#include "cmDuration.h"
#include "cmMakefile.h"
-#include "cmSystemTools.h"
+#include "cmStringAlgorithms.h"
-#include <sstream>
-#include <stdlib.h>
-#include <vector>
-
-cmCTestTestCommand::cmCTestTestCommand()
+void cmCTestTestCommand::BindArguments()
{
- this->Arguments[ctt_START] = "START";
- this->Arguments[ctt_END] = "END";
- this->Arguments[ctt_STRIDE] = "STRIDE";
- this->Arguments[ctt_EXCLUDE] = "EXCLUDE";
- this->Arguments[ctt_INCLUDE] = "INCLUDE";
- this->Arguments[ctt_EXCLUDE_LABEL] = "EXCLUDE_LABEL";
- this->Arguments[ctt_INCLUDE_LABEL] = "INCLUDE_LABEL";
- this->Arguments[ctt_EXCLUDE_FIXTURE] = "EXCLUDE_FIXTURE";
- this->Arguments[ctt_EXCLUDE_FIXTURE_SETUP] = "EXCLUDE_FIXTURE_SETUP";
- this->Arguments[ctt_EXCLUDE_FIXTURE_CLEANUP] = "EXCLUDE_FIXTURE_CLEANUP";
- this->Arguments[ctt_PARALLEL_LEVEL] = "PARALLEL_LEVEL";
- this->Arguments[ctt_SCHEDULE_RANDOM] = "SCHEDULE_RANDOM";
- this->Arguments[ctt_STOP_TIME] = "STOP_TIME";
- this->Arguments[ctt_TEST_LOAD] = "TEST_LOAD";
- this->Arguments[ctt_LAST] = CM_NULLPTR;
- this->Last = ctt_LAST;
+ this->cmCTestHandlerCommand::BindArguments();
+ this->Bind("START"_s, this->Start);
+ this->Bind("END"_s, this->End);
+ this->Bind("STRIDE"_s, this->Stride);
+ this->Bind("EXCLUDE"_s, this->Exclude);
+ this->Bind("INCLUDE"_s, this->Include);
+ this->Bind("EXCLUDE_LABEL"_s, this->ExcludeLabel);
+ this->Bind("INCLUDE_LABEL"_s, this->IncludeLabel);
+ this->Bind("EXCLUDE_FIXTURE"_s, this->ExcludeFixture);
+ this->Bind("EXCLUDE_FIXTURE_SETUP"_s, this->ExcludeFixtureSetup);
+ this->Bind("EXCLUDE_FIXTURE_CLEANUP"_s, this->ExcludeFixtureCleanup);
+ this->Bind("PARALLEL_LEVEL"_s, this->ParallelLevel);
+ this->Bind("SCHEDULE_RANDOM"_s, this->ScheduleRandom);
+ this->Bind("STOP_TIME"_s, this->StopTime);
+ this->Bind("TEST_LOAD"_s, this->TestLoad);
+ this->Bind("RESOURCE_SPEC_FILE"_s, this->ResourceSpecFile);
}
cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
@@ -36,69 +40,59 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
const char* ctestTimeout =
this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT");
- double timeout;
+ cmDuration timeout;
if (ctestTimeout) {
- timeout = atof(ctestTimeout);
+ timeout = cmDuration(atof(ctestTimeout));
} else {
timeout = this->CTest->GetTimeOut();
- if (timeout <= 0) {
+ if (timeout <= cmDuration::zero()) {
// By default use timeout of 10 minutes
- timeout = 600;
+ timeout = std::chrono::minutes(10);
}
}
this->CTest->SetTimeOut(timeout);
cmCTestGenericHandler* handler = this->InitializeActualHandler();
- if (this->Values[ctt_START] || this->Values[ctt_END] ||
- this->Values[ctt_STRIDE]) {
- std::ostringstream testsToRunString;
- if (this->Values[ctt_START]) {
- testsToRunString << this->Values[ctt_START];
- }
- testsToRunString << ",";
- if (this->Values[ctt_END]) {
- testsToRunString << this->Values[ctt_END];
- }
- testsToRunString << ",";
- if (this->Values[ctt_STRIDE]) {
- testsToRunString << this->Values[ctt_STRIDE];
- }
- handler->SetOption("TestsToRunInformation",
- testsToRunString.str().c_str());
+ if (!this->Start.empty() || !this->End.empty() || !this->Stride.empty()) {
+ handler->SetOption(
+ "TestsToRunInformation",
+ cmStrCat(this->Start, ',', this->End, ',', this->Stride).c_str());
}
- if (this->Values[ctt_EXCLUDE]) {
- handler->SetOption("ExcludeRegularExpression", this->Values[ctt_EXCLUDE]);
+ if (!this->Exclude.empty()) {
+ handler->SetOption("ExcludeRegularExpression", this->Exclude.c_str());
}
- if (this->Values[ctt_INCLUDE]) {
- handler->SetOption("IncludeRegularExpression", this->Values[ctt_INCLUDE]);
+ if (!this->Include.empty()) {
+ handler->SetOption("IncludeRegularExpression", this->Include.c_str());
}
- if (this->Values[ctt_EXCLUDE_LABEL]) {
+ if (!this->ExcludeLabel.empty()) {
handler->SetOption("ExcludeLabelRegularExpression",
- this->Values[ctt_EXCLUDE_LABEL]);
+ this->ExcludeLabel.c_str());
}
- if (this->Values[ctt_INCLUDE_LABEL]) {
- handler->SetOption("LabelRegularExpression",
- this->Values[ctt_INCLUDE_LABEL]);
+ if (!this->IncludeLabel.empty()) {
+ handler->SetOption("LabelRegularExpression", this->IncludeLabel.c_str());
}
- if (this->Values[ctt_EXCLUDE_FIXTURE]) {
+ if (!this->ExcludeFixture.empty()) {
handler->SetOption("ExcludeFixtureRegularExpression",
- this->Values[ctt_EXCLUDE_FIXTURE]);
+ this->ExcludeFixture.c_str());
}
- if (this->Values[ctt_EXCLUDE_FIXTURE_SETUP]) {
+ if (!this->ExcludeFixtureSetup.empty()) {
handler->SetOption("ExcludeFixtureSetupRegularExpression",
- this->Values[ctt_EXCLUDE_FIXTURE_SETUP]);
+ this->ExcludeFixtureSetup.c_str());
}
- if (this->Values[ctt_EXCLUDE_FIXTURE_CLEANUP]) {
+ if (!this->ExcludeFixtureCleanup.empty()) {
handler->SetOption("ExcludeFixtureCleanupRegularExpression",
- this->Values[ctt_EXCLUDE_FIXTURE_CLEANUP]);
+ this->ExcludeFixtureCleanup.c_str());
+ }
+ if (!this->ParallelLevel.empty()) {
+ handler->SetOption("ParallelLevel", this->ParallelLevel.c_str());
}
- if (this->Values[ctt_PARALLEL_LEVEL]) {
- handler->SetOption("ParallelLevel", this->Values[ctt_PARALLEL_LEVEL]);
+ if (!this->ScheduleRandom.empty()) {
+ handler->SetOption("ScheduleRandom", this->ScheduleRandom.c_str());
}
- if (this->Values[ctt_SCHEDULE_RANDOM]) {
- handler->SetOption("ScheduleRandom", this->Values[ctt_SCHEDULE_RANDOM]);
+ if (!this->ResourceSpecFile.empty()) {
+ handler->SetOption("ResourceSpecFile", this->ResourceSpecFile.c_str());
}
- if (this->Values[ctt_STOP_TIME]) {
- this->CTest->SetStopTime(this->Values[ctt_STOP_TIME]);
+ if (!this->StopTime.empty()) {
+ this->CTest->SetStopTime(this->StopTime);
}
// Test load is determined by: TEST_LOAD argument,
@@ -106,29 +100,38 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
// command line argument... in that order.
unsigned long testLoad;
const char* ctestTestLoad = this->Makefile->GetDefinition("CTEST_TEST_LOAD");
- if (this->Values[ctt_TEST_LOAD] && *this->Values[ctt_TEST_LOAD]) {
- if (!cmSystemTools::StringToULong(this->Values[ctt_TEST_LOAD],
- &testLoad)) {
+ if (!this->TestLoad.empty()) {
+ if (!cmStrToULong(this->TestLoad.c_str(), &testLoad)) {
testLoad = 0;
- cmCTestLog(this->CTest, WARNING, "Invalid value for 'TEST_LOAD' : "
- << this->Values[ctt_TEST_LOAD] << std::endl);
+ cmCTestLog(this->CTest, WARNING,
+ "Invalid value for 'TEST_LOAD' : " << this->TestLoad
+ << std::endl);
}
} else if (ctestTestLoad && *ctestTestLoad) {
- if (!cmSystemTools::StringToULong(ctestTestLoad, &testLoad)) {
+ if (!cmStrToULong(ctestTestLoad, &testLoad)) {
testLoad = 0;
- cmCTestLog(this->CTest, WARNING, "Invalid value for 'CTEST_TEST_LOAD' : "
- << ctestTestLoad << std::endl);
+ cmCTestLog(this->CTest, WARNING,
+ "Invalid value for 'CTEST_TEST_LOAD' : " << ctestTestLoad
+ << std::endl);
}
} else {
testLoad = this->CTest->GetTestLoad();
}
handler->SetTestLoad(testLoad);
+ if (const char* labelsForSubprojects =
+ this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) {
+ this->CTest->SetCTestConfiguration("LabelsForSubprojects",
+ labelsForSubprojects, this->Quiet);
+ }
+
handler->SetQuiet(this->Quiet);
return handler;
}
cmCTestGenericHandler* cmCTestTestCommand::InitializeActualHandler()
{
- return this->CTest->GetInitializedHandler("test");
+ cmCTestTestHandler* handler = this->CTest->GetTestHandler();
+ handler->Initialize();
+ return handler;
}
diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h
index be7e7831f..4019694b2 100644
--- a/Source/CTest/cmCTestTestCommand.h
+++ b/Source/CTest/cmCTestTestCommand.h
@@ -3,14 +3,17 @@
#ifndef cmCTestTestCommand_h
#define cmCTestTestCommand_h
-#include "cmConfigure.h"
-
-#include "cmCTestHandlerCommand.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <utility>
+
+#include <cm/memory>
+
+#include "cmCTestHandlerCommand.h"
+#include "cmCommand.h"
class cmCTestGenericHandler;
-class cmCommand;
/** \class cmCTestTest
* \brief Run a ctest script
@@ -20,48 +23,42 @@ class cmCommand;
class cmCTestTestCommand : public cmCTestHandlerCommand
{
public:
- cmCTestTestCommand();
-
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE
+ std::unique_ptr<cmCommand> Clone() override
{
- cmCTestTestCommand* ni = new cmCTestTestCommand;
+ auto ni = cm::make_unique<cmCTestTestCommand>();
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
- return ni;
+ return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
* The name of the command as specified in CMakeList.txt.
*/
- std::string GetName() const CM_OVERRIDE { return "ctest_test"; }
+ std::string GetName() const override { return "ctest_test"; }
protected:
+ void BindArguments() override;
virtual cmCTestGenericHandler* InitializeActualHandler();
- cmCTestGenericHandler* InitializeHandler() CM_OVERRIDE;
+ cmCTestGenericHandler* InitializeHandler() override;
- enum
- {
- ctt_BUILD = ct_LAST,
- ctt_RETURN_VALUE,
- ctt_START,
- ctt_END,
- ctt_STRIDE,
- ctt_EXCLUDE,
- ctt_INCLUDE,
- ctt_EXCLUDE_LABEL,
- ctt_INCLUDE_LABEL,
- ctt_EXCLUDE_FIXTURE,
- ctt_EXCLUDE_FIXTURE_SETUP,
- ctt_EXCLUDE_FIXTURE_CLEANUP,
- ctt_PARALLEL_LEVEL,
- ctt_SCHEDULE_RANDOM,
- ctt_STOP_TIME,
- ctt_TEST_LOAD,
- ctt_LAST
- };
+ std::string Start;
+ std::string End;
+ std::string Stride;
+ std::string Exclude;
+ std::string Include;
+ std::string ExcludeLabel;
+ std::string IncludeLabel;
+ std::string ExcludeFixture;
+ std::string ExcludeFixtureSetup;
+ std::string ExcludeFixtureCleanup;
+ std::string ParallelLevel;
+ std::string ScheduleRandom;
+ std::string StopTime;
+ std::string TestLoad;
+ std::string ResourceSpecFile;
};
#endif
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 674be6052..c8bbb0b13 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -2,81 +2,93 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestTestHandler.h"
-#include "cmsys/Base64.h"
-#include "cmsys/Directory.hxx"
-#include "cmsys/FStream.hxx"
-#include "cmsys/RegularExpression.hxx"
#include <algorithm>
+#include <chrono>
+#include <cmath>
+#include <cstddef>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
#include <functional>
#include <iomanip>
#include <iterator>
#include <set>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
+#include <utility>
+
+#include <cm/memory>
+
+#include "cmsys/FStream.hxx"
+#include <cmsys/Base64.h>
+#include <cmsys/Directory.hxx>
+#include <cmsys/RegularExpression.hxx>
+
+#include "cm_utf8.h"
#include "cmAlgorithms.h"
#include "cmCTest.h"
-#include "cmCTestBatchTestHandler.h"
#include "cmCTestMultiProcessHandler.h"
-#include "cmCommand.h"
+#include "cmCTestResourceGroupsLexerHelper.h"
+#include "cmDuration.h"
+#include "cmExecutionStatus.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmState.h"
#include "cmStateSnapshot.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
#include "cmXMLWriter.h"
-#include "cm_auto_ptr.hxx"
-#include "cm_utf8.h"
#include "cmake.h"
-class cmExecutionStatus;
+namespace {
-class cmCTestSubdirCommand : public cmCommand
+class cmCTestCommand
{
public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE
+ cmCTestCommand(cmCTestTestHandler* testHandler)
+ : TestHandler(testHandler)
{
- cmCTestSubdirCommand* c = new cmCTestSubdirCommand;
- c->TestHandler = this->TestHandler;
- return c;
}
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& /*unused*/) CM_OVERRIDE;
+ virtual ~cmCTestCommand() = default;
+
+ bool operator()(std::vector<cmListFileArgument> const& args,
+ cmExecutionStatus& status)
+ {
+ cmMakefile& mf = status.GetMakefile();
+ std::vector<std::string> expandedArguments;
+ if (!mf.ExpandArguments(args, expandedArguments)) {
+ // There was an error expanding arguments. It was already
+ // reported, so we can skip this command without error.
+ return true;
+ }
+ return this->InitialPass(expandedArguments, status);
+ }
+
+ virtual bool InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus& status) = 0;
cmCTestTestHandler* TestHandler;
};
-bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& /*unused*/)
+bool cmCTestSubdirCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- std::vector<std::string>::const_iterator it;
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- for (it = args.begin(); it != args.end(); ++it) {
+ for (std::string const& arg : args) {
std::string fname;
- if (cmSystemTools::FileIsFullPath(it->c_str())) {
- fname = *it;
+ if (cmSystemTools::FileIsFullPath(arg)) {
+ fname = arg;
} else {
- fname = cwd;
- fname += "/";
- fname += *it;
+ fname = cmStrCat(cwd, '/', arg);
}
if (!cmSystemTools::FileIsDirectory(fname)) {
@@ -86,6 +98,11 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
bool readit = false;
{
cmWorkingDirectory workdir(fname);
+ if (workdir.Failed()) {
+ status.SetError("Failed to change directory to " + fname + " : " +
+ std::strerror(workdir.GetLastResult()));
+ return false;
+ }
const char* testFilename;
if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
// does the CTestTestfile.cmake exist ?
@@ -99,54 +116,28 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
}
fname += "/";
fname += testFilename;
- readit = this->Makefile->ReadDependentFile(fname.c_str());
+ readit = status.GetMakefile().ReadDependentFile(fname);
}
if (!readit) {
- std::string m = "Could not find include file: ";
- m += fname;
- this->SetError(m);
+ status.SetError(cmStrCat("Could not find include file: ", fname));
return false;
}
}
return true;
}
-class cmCTestAddSubdirectoryCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE
- {
- cmCTestAddSubdirectoryCommand* c = new cmCTestAddSubdirectoryCommand;
- c->TestHandler = this->TestHandler;
- return c;
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& /*unused*/) CM_OVERRIDE;
-
- cmCTestTestHandler* TestHandler;
-};
-
-bool cmCTestAddSubdirectoryCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus& /*unused*/)
+bool cmCTestAddSubdirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- std::string fname = cmSystemTools::GetCurrentWorkingDirectory();
- fname += "/";
- fname += args[0];
+ std::string fname =
+ cmStrCat(cmSystemTools::GetCurrentWorkingDirectory(), '/', args[0]);
- if (!cmSystemTools::FileExists(fname.c_str())) {
+ if (!cmSystemTools::FileExists(fname)) {
// No subdirectory? So what...
return true;
}
@@ -165,71 +156,49 @@ bool cmCTestAddSubdirectoryCommand::InitialPass(
}
fname += "/";
fname += testFilename;
- readit = this->Makefile->ReadDependentFile(fname.c_str());
+ readit = status.GetMakefile().ReadDependentFile(fname);
}
if (!readit) {
- std::string m = "Could not find include file: ";
- m += fname;
- this->SetError(m);
+ status.SetError(cmStrCat("Could not find include file: ", fname));
return false;
}
return true;
}
-class cmCTestAddTestCommand : public cmCommand
+class cmCTestAddTestCommand : public cmCTestCommand
{
public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE
- {
- cmCTestAddTestCommand* c = new cmCTestAddTestCommand;
- c->TestHandler = this->TestHandler;
- return c;
- }
+ using cmCTestCommand::cmCTestCommand;
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& /*args*/,
- cmExecutionStatus& /*unused*/) CM_OVERRIDE;
-
- cmCTestTestHandler* TestHandler;
+ cmExecutionStatus& /*unused*/) override;
};
bool cmCTestAddTestCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& /*unused*/)
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
return this->TestHandler->AddTest(args);
}
-class cmCTestSetTestsPropertiesCommand : public cmCommand
+class cmCTestSetTestsPropertiesCommand : public cmCTestCommand
{
public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE
- {
- cmCTestSetTestsPropertiesCommand* c = new cmCTestSetTestsPropertiesCommand;
- c->TestHandler = this->TestHandler;
- return c;
- }
+ using cmCTestCommand::cmCTestCommand;
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& /*args*/,
- cmExecutionStatus& /*unused*/) CM_OVERRIDE;
-
- cmCTestTestHandler* TestHandler;
+ cmExecutionStatus& /*unused*/) override;
};
bool cmCTestSetTestsPropertiesCommand::InitialPass(
@@ -238,6 +207,25 @@ bool cmCTestSetTestsPropertiesCommand::InitialPass(
return this->TestHandler->SetTestsProperties(args);
}
+class cmCTestSetDirectoryPropertiesCommand : public cmCTestCommand
+{
+public:
+ using cmCTestCommand::cmCTestCommand;
+
+ /**
+ * This is called when the command is first encountered in
+ * the CMakeLists.txt file.
+ */
+ bool InitialPass(std::vector<std::string> const& /*unused*/,
+ cmExecutionStatus& /*unused*/) override;
+};
+
+bool cmCTestSetDirectoryPropertiesCommand::InitialPass(
+ std::vector<std::string> const& args, cmExecutionStatus&)
+{
+ return this->TestHandler->SetDirectoryProperties(args);
+}
+
// get the next number in a string with numbers separated by ,
// pos is the start of the search and pos2 is the end of the search
// pos becomes pos2 after a call to GetNextNumber.
@@ -290,6 +278,8 @@ inline int GetNextRealNumber(std::string const& in, double& val,
return 0;
}
+} // namespace
+
cmCTestTestHandler::cmCTestTestHandler()
{
this->UseUnion = false;
@@ -299,13 +289,14 @@ cmCTestTestHandler::cmCTestTestHandler()
this->UseIncludeRegExpFlag = false;
this->UseExcludeRegExpFlag = false;
this->UseExcludeRegExpFirst = false;
+ this->UseResourceSpec = false;
this->CustomMaximumPassedTestOutputSize = 1 * 1024;
this->CustomMaximumFailedTestOutputSize = 300 * 1024;
this->MemCheck = false;
- this->LogFile = CM_NULLPTR;
+ this->LogFile = nullptr;
// regex to detect <DartMeasurement>...</DartMeasurement>
this->DartStuff.compile("(<DartMeasurement.*/DartMeasurement[a-zA-Z]*>)");
@@ -318,13 +309,13 @@ void cmCTestTestHandler::Initialize()
{
this->Superclass::Initialize();
- this->ElapsedTestingTime = -1;
+ this->ElapsedTestingTime = cmDuration();
this->TestResults.clear();
this->CustomTestsIgnore.clear();
- this->StartTest = "";
- this->EndTest = "";
+ this->StartTest.clear();
+ this->EndTest.clear();
this->CustomPreTest.clear();
this->CustomPostTest.clear();
@@ -340,13 +331,13 @@ void cmCTestTestHandler::Initialize()
this->UseExcludeRegExpFirst = false;
this->IncludeLabelRegularExpression = "";
this->ExcludeLabelRegularExpression = "";
- this->IncludeRegExp = "";
- this->ExcludeRegExp = "";
+ this->IncludeRegExp.clear();
+ this->ExcludeRegExp.clear();
this->ExcludeFixtureRegExp.clear();
this->ExcludeFixtureSetupRegExp.clear();
this->ExcludeFixtureCleanupRegExp.clear();
- TestsToRunString = "";
+ TestsToRunString.clear();
this->UseUnion = false;
this->TestList.clear();
}
@@ -387,14 +378,97 @@ int cmCTestTestHandler::PostProcessHandler()
return 1;
}
-// clearly it would be nice if this were broken up into a few smaller
-// functions and commented...
int cmCTestTestHandler::ProcessHandler()
{
+ if (!this->ProcessOptions()) {
+ return -1;
+ }
+
+ this->TestResults.clear();
+
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ (this->MemCheck ? "Memory check" : "Test")
+ << " project "
+ << cmSystemTools::GetCurrentWorkingDirectory()
+ << std::endl,
+ this->Quiet);
+ if (!this->PreProcessHandler()) {
+ return -1;
+ }
+
+ cmGeneratedFileStream mLogFile;
+ this->StartLogFile((this->MemCheck ? "DynamicAnalysis" : "Test"), mLogFile);
+ this->LogFile = &mLogFile;
+
+ std::vector<std::string> passed;
+ std::vector<std::string> failed;
+
+ // start the real time clock
+ auto clock_start = std::chrono::steady_clock::now();
+
+ this->ProcessDirectory(passed, failed);
+
+ auto clock_finish = std::chrono::steady_clock::now();
+
+ if (passed.size() + failed.size() == 0) {
+ if (!this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels()) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "No tests were found!!!" << std::endl);
+ }
+ } else {
+ if (this->HandlerVerbose && !passed.empty() &&
+ (this->UseIncludeRegExpFlag || this->UseExcludeRegExpFlag)) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ std::endl
+ << "The following tests passed:" << std::endl,
+ this->Quiet);
+ for (std::string const& j : passed) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "\t" << j << std::endl, this->Quiet);
+ }
+ }
+
+ SetOfTests resultsSet(this->TestResults.begin(), this->TestResults.end());
+ std::vector<cmCTestTestHandler::cmCTestTestResult> disabledTests;
+
+ for (cmCTestTestResult const& ft : resultsSet) {
+ if (cmHasLiteralPrefix(ft.CompletionStatus, "SKIP_") ||
+ ft.CompletionStatus == "Disabled") {
+ disabledTests.push_back(ft);
+ }
+ }
+
+ cmDuration durationInSecs = clock_finish - clock_start;
+ this->LogTestSummary(passed, failed, durationInSecs);
+
+ this->LogDisabledTests(disabledTests);
+
+ this->LogFailedTests(failed, resultsSet);
+ }
+
+ if (!this->GenerateXML()) {
+ return 1;
+ }
+
+ if (!this->PostProcessHandler()) {
+ this->LogFile = nullptr;
+ return -1;
+ }
+
+ if (!failed.empty()) {
+ this->LogFile = nullptr;
+ return -1;
+ }
+ this->LogFile = nullptr;
+ return 0;
+}
+
+bool cmCTestTestHandler::ProcessOptions()
+{
// Update internal data structure from generic one
this->SetTestsToRunInformation(this->GetOption("TestsToRunInformation"));
- this->SetUseUnion(cmSystemTools::IsOn(this->GetOption("UseUnion")));
- if (cmSystemTools::IsOn(this->GetOption("ScheduleRandom"))) {
+ this->SetUseUnion(cmIsOn(this->GetOption("UseUnion")));
+ if (cmIsOn(this->GetOption("ScheduleRandom"))) {
this->CTest->SetScheduleType("Random");
}
if (this->GetOption("ParallelLevel")) {
@@ -434,228 +508,225 @@ int cmCTestTestHandler::ProcessHandler()
if (val) {
this->ExcludeFixtureCleanupRegExp = val;
}
- this->SetRerunFailed(cmSystemTools::IsOn(this->GetOption("RerunFailed")));
-
- this->TestResults.clear();
-
- cmCTestOptionalLog(
- this->CTest, HANDLER_OUTPUT, (this->MemCheck ? "Memory check" : "Test")
- << " project " << cmSystemTools::GetCurrentWorkingDirectory()
- << std::endl,
- this->Quiet);
- if (!this->PreProcessHandler()) {
- return -1;
- }
-
- cmGeneratedFileStream mLogFile;
- this->StartLogFile((this->MemCheck ? "DynamicAnalysis" : "Test"), mLogFile);
- this->LogFile = &mLogFile;
-
- std::vector<std::string> passed;
- std::vector<std::string> failed;
- int total;
-
- // start the real time clock
- double clock_start, clock_finish;
- clock_start = cmSystemTools::GetTime();
+ this->SetRerunFailed(cmIsOn(this->GetOption("RerunFailed")));
- this->ProcessDirectory(passed, failed);
-
- clock_finish = cmSystemTools::GetTime();
-
- total = int(passed.size()) + int(failed.size());
-
- if (total == 0) {
- if (!this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels()) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "No tests were found!!!"
+ val = this->GetOption("ResourceSpecFile");
+ if (val) {
+ this->UseResourceSpec = true;
+ auto result = this->ResourceSpec.ReadFromJSONFile(val);
+ if (result != cmCTestResourceSpec::ReadFileResult::READ_OK) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Could not read/parse resource spec file "
+ << val << ": "
+ << cmCTestResourceSpec::ResultToString(result)
<< std::endl);
+ return false;
}
- } else {
- if (this->HandlerVerbose && !passed.empty() &&
- (this->UseIncludeRegExpFlag || this->UseExcludeRegExpFlag)) {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl
- << "The following tests passed:" << std::endl,
- this->Quiet);
- for (std::vector<std::string>::iterator j = passed.begin();
- j != passed.end(); ++j) {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "\t" << *j << std::endl, this->Quiet);
- }
- }
+ }
- typedef std::set<cmCTestTestHandler::cmCTestTestResult,
- cmCTestTestResultLess>
- SetOfTests;
- SetOfTests resultsSet(this->TestResults.begin(), this->TestResults.end());
- std::vector<cmCTestTestHandler::cmCTestTestResult> disabledTests;
+ return true;
+}
- for (SetOfTests::iterator ftit = resultsSet.begin();
- ftit != resultsSet.end(); ++ftit) {
- if (cmHasLiteralPrefix(ftit->CompletionStatus, "SKIP_RETURN_CODE=") ||
- ftit->CompletionStatus == "Disabled") {
- disabledTests.push_back(*ftit);
- }
- }
+void cmCTestTestHandler::LogTestSummary(const std::vector<std::string>& passed,
+ const std::vector<std::string>& failed,
+ const cmDuration& durationInSecs)
+{
+ std::size_t total = passed.size() + failed.size();
- float percent = float(passed.size()) * 100.0f / float(total);
- if (!failed.empty() && percent > 99) {
- percent = 99;
- }
+ float percent = float(passed.size()) * 100.0f / float(total);
+ if (!failed.empty() && percent > 99) {
+ percent = 99;
+ }
- cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl
- << static_cast<int>(percent + .5f) << "% tests passed, "
- << failed.size() << " tests failed out of " << total
- << std::endl);
- if (this->CTest->GetLabelSummary()) {
- this->PrintLabelSummary();
- }
- char realBuf[1024];
- sprintf(realBuf, "%6.2f sec", (double)(clock_finish - clock_start));
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
- "\nTotal Test time (real) = " << realBuf << "\n",
- this->Quiet);
+ std::string passColorCode;
+ std::string failedColorCode;
+ if (failed.empty()) {
+ passColorCode = this->CTest->GetColorCode(cmCTest::Color::GREEN);
+ } else {
+ failedColorCode = this->CTest->GetColorCode(cmCTest::Color::RED);
+ }
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ std::endl
+ << passColorCode << std::lround(percent) << "% tests passed"
+ << this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
+ << ", " << failedColorCode << failed.size() << " tests failed"
+ << this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
+ << " out of " << total << std::endl);
+ if ((!this->CTest->GetLabelsForSubprojects().empty() &&
+ this->CTest->GetSubprojectSummary())) {
+ this->PrintLabelOrSubprojectSummary(true);
+ }
+ if (this->CTest->GetLabelSummary()) {
+ this->PrintLabelOrSubprojectSummary(false);
+ }
+ char realBuf[1024];
+ sprintf(realBuf, "%6.2f sec", durationInSecs.count());
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ "\nTotal Test time (real) = " << realBuf << "\n",
+ this->Quiet);
+}
- if (!disabledTests.empty()) {
- cmGeneratedFileStream ofs;
- cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl
- << "The following tests did not run:" << std::endl);
- this->StartLogFile("TestsDisabled", ofs);
-
- const char* disabled_reason;
- for (std::vector<cmCTestTestHandler::cmCTestTestResult>::iterator dtit =
- disabledTests.begin();
- dtit != disabledTests.end(); ++dtit) {
- ofs << dtit->TestCount << ":" << dtit->Name << std::endl;
- if (dtit->CompletionStatus == "Disabled") {
- disabled_reason = "Disabled";
- } else {
- disabled_reason = "Skipped";
- }
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t"
- << std::setw(3) << dtit->TestCount << " - " << dtit->Name
- << " (" << disabled_reason << ")" << std::endl);
+void cmCTestTestHandler::LogDisabledTests(
+ const std::vector<cmCTestTestResult>& disabledTests)
+{
+ if (!disabledTests.empty()) {
+ cmGeneratedFileStream ofs;
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ std::endl
+ << "The following tests did not run:" << std::endl);
+ this->StartLogFile("TestsDisabled", ofs);
+
+ const char* disabled_reason;
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ this->CTest->GetColorCode(cmCTest::Color::BLUE));
+ for (cmCTestTestResult const& dt : disabledTests) {
+ ofs << dt.TestCount << ":" << dt.Name << std::endl;
+ if (dt.CompletionStatus == "Disabled") {
+ disabled_reason = "Disabled";
+ } else {
+ disabled_reason = "Skipped";
}
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ "\t" << std::setw(3) << dt.TestCount << " - " << dt.Name
+ << " (" << disabled_reason << ")" << std::endl);
}
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR));
+ }
+}
- if (!failed.empty()) {
- cmGeneratedFileStream ofs;
- cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl
- << "The following tests FAILED:" << std::endl);
- this->StartLogFile("TestsFailed", ofs);
-
- for (SetOfTests::iterator ftit = resultsSet.begin();
- ftit != resultsSet.end(); ++ftit) {
- if (ftit->Status != cmCTestTestHandler::COMPLETED &&
- !cmHasLiteralPrefix(ftit->CompletionStatus, "SKIP_RETURN_CODE=") &&
- ftit->CompletionStatus != "Disabled") {
- ofs << ftit->TestCount << ":" << ftit->Name << std::endl;
- cmCTestLog(
- this->CTest, HANDLER_OUTPUT, "\t"
- << std::setw(3) << ftit->TestCount << " - " << ftit->Name << " ("
- << this->GetTestStatus(ftit->Status) << ")" << std::endl);
+void cmCTestTestHandler::LogFailedTests(const std::vector<std::string>& failed,
+ const SetOfTests& resultsSet)
+{
+ if (!failed.empty()) {
+ cmGeneratedFileStream ofs;
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ std::endl
+ << "The following tests FAILED:" << std::endl);
+ this->StartLogFile("TestsFailed", ofs);
+
+ for (cmCTestTestResult const& ft : resultsSet) {
+ if (ft.Status != cmCTestTestHandler::COMPLETED &&
+ !cmHasLiteralPrefix(ft.CompletionStatus, "SKIP_") &&
+ ft.CompletionStatus != "Disabled") {
+ ofs << ft.TestCount << ":" << ft.Name << std::endl;
+ auto testColor = cmCTest::Color::RED;
+ if (this->GetTestStatus(ft) == "Not Run") {
+ testColor = cmCTest::Color::YELLOW;
}
+ cmCTestLog(
+ this->CTest, HANDLER_OUTPUT,
+ "\t" << this->CTest->GetColorCode(testColor) << std::setw(3)
+ << ft.TestCount << " - " << ft.Name << " ("
+ << this->GetTestStatus(ft) << ")"
+ << this->CTest->GetColorCode(cmCTest::Color::CLEAR_COLOR)
+ << std::endl);
}
}
}
+}
+bool cmCTestTestHandler::GenerateXML()
+{
if (this->CTest->GetProduceXML()) {
cmGeneratedFileStream xmlfile;
if (!this->StartResultingXML(
(this->MemCheck ? cmCTest::PartMemCheck : cmCTest::PartTest),
(this->MemCheck ? "DynamicAnalysis" : "Test"), xmlfile)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create "
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot create "
<< (this->MemCheck ? "memory check" : "testing")
<< " XML file" << std::endl);
- this->LogFile = CM_NULLPTR;
- return 1;
+ this->LogFile = nullptr;
+ return false;
}
cmXMLWriter xml(xmlfile);
this->GenerateDartOutput(xml);
}
- if (!this->PostProcessHandler()) {
- this->LogFile = CM_NULLPTR;
- return -1;
- }
-
- if (!failed.empty()) {
- this->LogFile = CM_NULLPTR;
- return -1;
- }
- this->LogFile = CM_NULLPTR;
- return 0;
+ return true;
}
-void cmCTestTestHandler::PrintLabelSummary()
+void cmCTestTestHandler::PrintLabelOrSubprojectSummary(bool doSubProject)
{
- cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin();
+ // collect subproject labels
+ std::vector<std::string> subprojects =
+ this->CTest->GetLabelsForSubprojects();
std::map<std::string, double> labelTimes;
std::map<std::string, int> labelCounts;
std::set<std::string> labels;
- // initialize maps
std::string::size_type maxlen = 0;
- for (; it != this->TestList.end(); ++it) {
- cmCTestTestProperties& p = *it;
- if (!p.Labels.empty()) {
- for (std::vector<std::string>::iterator l = p.Labels.begin();
- l != p.Labels.end(); ++l) {
- if ((*l).size() > maxlen) {
- maxlen = (*l).size();
+ // initialize maps
+ for (cmCTestTestProperties& p : this->TestList) {
+ for (std::string const& l : p.Labels) {
+ // first check to see if the current label is a subproject label
+ bool isSubprojectLabel = false;
+ auto subproject = std::find(subprojects.begin(), subprojects.end(), l);
+ if (subproject != subprojects.end()) {
+ isSubprojectLabel = true;
+ }
+ // if we are doing sub projects and this label is one, then use it
+ // if we are not doing sub projects and the label is not one use it
+ if (doSubProject == isSubprojectLabel) {
+ if (l.size() > maxlen) {
+ maxlen = l.size();
}
- labels.insert(*l);
- labelTimes[*l] = 0;
- labelCounts[*l] = 0;
+ labels.insert(l);
+ labelTimes[l] = 0;
+ labelCounts[l] = 0;
}
}
}
- cmCTestTestHandler::TestResultsVector::iterator ri =
- this->TestResults.begin();
// fill maps
- for (; ri != this->TestResults.end(); ++ri) {
- cmCTestTestResult& result = *ri;
+ for (cmCTestTestResult& result : this->TestResults) {
cmCTestTestProperties& p = *result.Properties;
- if (!p.Labels.empty()) {
- for (std::vector<std::string>::iterator l = p.Labels.begin();
- l != p.Labels.end(); ++l) {
- labelTimes[*l] += result.ExecutionTime;
- ++labelCounts[*l];
+ for (std::string const& l : p.Labels) {
+ // only use labels found in labels
+ if (cmContains(labels, l)) {
+ labelTimes[l] +=
+ result.ExecutionTime.count() * result.Properties->Processors;
+ ++labelCounts[l];
}
}
}
+ // if no labels are found return and print nothing
+ if (labels.empty()) {
+ return;
+ }
// now print times
- if (!labels.empty()) {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\nLabel Time Summary:",
- this->Quiet);
+ if (doSubProject) {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ "\nSubproject Time Summary:", this->Quiet);
+ } else {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ "\nLabel Time Summary:", this->Quiet);
}
- for (std::set<std::string>::const_iterator i = labels.begin();
- i != labels.end(); ++i) {
- std::string label = *i;
+ for (std::string const& i : labels) {
+ std::string label = i;
label.resize(maxlen + 3, ' ');
char buf[1024];
- sprintf(buf, "%6.2f sec", labelTimes[*i]);
+ sprintf(buf, "%6.2f sec*proc", labelTimes[i]);
std::ostringstream labelCountStr;
- labelCountStr << "(" << labelCounts[*i] << " test";
- if (labelCounts[*i] > 1) {
+ labelCountStr << "(" << labelCounts[i] << " test";
+ if (labelCounts[i] > 1) {
labelCountStr << "s";
}
labelCountStr << ")";
-
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n"
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ "\n"
<< label << " = " << buf << " "
<< labelCountStr.str(),
this->Quiet);
if (this->LogFile) {
- *this->LogFile << "\n" << *i << " = " << buf << "\n";
+ *this->LogFile << "\n" << i << " = " << buf << "\n";
}
}
- if (!labels.empty()) {
- if (this->LogFile) {
- *this->LogFile << "\n";
- }
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n", this->Quiet);
+ if (this->LogFile) {
+ *this->LogFile << "\n";
}
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n", this->Quiet);
}
void cmCTestTestHandler::CheckLabelFilterInclude(cmCTestTestProperties& it)
@@ -673,9 +744,8 @@ void cmCTestTestHandler::CheckLabelFilterInclude(cmCTestTestProperties& it)
// check to see if the label regular expression matches
bool found = false; // assume it does not match
// loop over all labels and look for match
- for (std::vector<std::string>::iterator l = it.Labels.begin();
- l != it.Labels.end(); ++l) {
- if (this->IncludeLabelRegularExpression.find(*l)) {
+ for (std::string const& l : it.Labels) {
+ if (this->IncludeLabelRegularExpression.find(l)) {
found = true;
}
}
@@ -699,9 +769,8 @@ void cmCTestTestHandler::CheckLabelFilterExclude(cmCTestTestProperties& it)
// check to see if the label regular expression matches
bool found = false; // assume it does not match
// loop over all labels and look for match
- for (std::vector<std::string>::iterator l = it.Labels.begin();
- l != it.Labels.end(); ++l) {
- if (this->ExcludeLabelRegularExpression.find(*l)) {
+ for (std::string const& l : it.Labels) {
+ if (this->ExcludeLabelRegularExpression.find(l)) {
found = true;
}
}
@@ -730,16 +799,15 @@ void cmCTestTestHandler::ComputeTestList()
cmCTestTestHandler::ListOfTests::size_type tmsize = this->TestList.size();
// how many tests are in based on RegExp?
int inREcnt = 0;
- cmCTestTestHandler::ListOfTests::iterator it;
- for (it = this->TestList.begin(); it != this->TestList.end(); it++) {
- this->CheckLabelFilter(*it);
- if (it->IsInBasedOnREOptions) {
+ for (cmCTestTestProperties& tp : this->TestList) {
+ this->CheckLabelFilter(tp);
+ if (tp.IsInBasedOnREOptions) {
inREcnt++;
}
}
// expand the test list based on the union flag
if (this->UseUnion) {
- this->ExpandTestsToRunInformation((int)tmsize);
+ this->ExpandTestsToRunInformation(static_cast<int>(tmsize));
} else {
this->ExpandTestsToRunInformation(inREcnt);
}
@@ -748,31 +816,28 @@ void cmCTestTestHandler::ComputeTestList()
inREcnt = 0;
std::string last_directory;
ListOfTests finalList;
- for (it = this->TestList.begin(); it != this->TestList.end(); it++) {
+ for (cmCTestTestProperties& tp : this->TestList) {
cnt++;
- if (it->IsInBasedOnREOptions) {
+ if (tp.IsInBasedOnREOptions) {
inREcnt++;
}
if (this->UseUnion) {
// if it is not in the list and not in the regexp then skip
- if ((!this->TestsToRun.empty() &&
- std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt) ==
- this->TestsToRun.end()) &&
- !it->IsInBasedOnREOptions) {
+ if ((!this->TestsToRun.empty() && !cmContains(this->TestsToRun, cnt)) &&
+ !tp.IsInBasedOnREOptions) {
continue;
}
} else {
// is this test in the list of tests to run? If not then skip it
if ((!this->TestsToRun.empty() &&
- std::find(this->TestsToRun.begin(), this->TestsToRun.end(),
- inREcnt) == this->TestsToRun.end()) ||
- !it->IsInBasedOnREOptions) {
+ !cmContains(this->TestsToRun, inREcnt)) ||
+ !tp.IsInBasedOnREOptions) {
continue;
}
}
- it->Index = cnt; // save the index into the test list for this test
- finalList.push_back(*it);
+ tp.Index = cnt; // save the index into the test list for this test
+ finalList.push_back(tp);
}
UpdateForFixtures(finalList);
@@ -789,21 +854,18 @@ void cmCTestTestHandler::ComputeTestListForRerunFailed()
{
this->ExpandTestsToRunInformationForRerunFailed();
- cmCTestTestHandler::ListOfTests::iterator it;
ListOfTests finalList;
int cnt = 0;
- for (it = this->TestList.begin(); it != this->TestList.end(); it++) {
+ for (cmCTestTestProperties& tp : this->TestList) {
cnt++;
// if this test is not in our list of tests to run, then skip it.
- if ((!this->TestsToRun.empty() &&
- std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt) ==
- this->TestsToRun.end())) {
+ if (!this->TestsToRun.empty() && !cmContains(this->TestsToRun, cnt)) {
continue;
}
- it->Index = cnt;
- finalList.push_back(*it);
+ tp.Index = cnt;
+ finalList.push_back(tp);
}
UpdateForFixtures(finalList);
@@ -847,34 +909,27 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
// Prepare some maps to help us find setup and cleanup tests for
// any given fixture
- typedef ListOfTests::const_iterator TestIterator;
- typedef std::multimap<std::string, TestIterator> FixtureDependencies;
- typedef FixtureDependencies::const_iterator FixtureDepsIterator;
+ using TestIterator = ListOfTests::const_iterator;
+ using FixtureDependencies = std::multimap<std::string, TestIterator>;
+ using FixtureDepsIterator = FixtureDependencies::const_iterator;
FixtureDependencies fixtureSetups;
FixtureDependencies fixtureCleanups;
- for (ListOfTests::const_iterator it = this->TestList.begin();
- it != this->TestList.end(); ++it) {
+ for (auto it = this->TestList.begin(); it != this->TestList.end(); ++it) {
const cmCTestTestProperties& p = *it;
- const std::set<std::string>& setups = p.FixturesSetup;
- for (std::set<std::string>::const_iterator depsIt = setups.begin();
- depsIt != setups.end(); ++depsIt) {
- fixtureSetups.insert(std::make_pair(*depsIt, it));
+ for (std::string const& deps : p.FixturesSetup) {
+ fixtureSetups.insert(std::make_pair(deps, it));
}
- const std::set<std::string>& cleanups = p.FixturesCleanup;
- for (std::set<std::string>::const_iterator depsIt = cleanups.begin();
- depsIt != cleanups.end(); ++depsIt) {
- fixtureCleanups.insert(std::make_pair(*depsIt, it));
+ for (std::string const& deps : p.FixturesCleanup) {
+ fixtureCleanups.insert(std::make_pair(deps, it));
}
}
// Prepare fast lookup of tests already included in our list of tests
std::set<std::string> addedTests;
- for (ListOfTests::const_iterator it = tests.begin(); it != tests.end();
- ++it) {
- const cmCTestTestProperties& p = *it;
+ for (cmCTestTestProperties const& p : tests) {
addedTests.insert(p.Name);
}
@@ -882,8 +937,8 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
// tests array for tests which require that fixture and tests which are
// setups for that fixture. They are needed at the end to populate
// dependencies of the cleanup tests in our final list of tests.
- std::map<std::string, std::vector<size_t> > fixtureRequirements;
- std::map<std::string, std::vector<size_t> > setupFixturesAdded;
+ std::map<std::string, std::vector<size_t>> fixtureRequirements;
+ std::map<std::string, std::vector<size_t>> setupFixturesAdded;
// Use integer index for iteration because we append to
// the tests vector as we go
@@ -908,10 +963,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
// Must copy the set of fixtures required because we may invalidate
// the tests array by appending to it
std::set<std::string> fixtures = tests[i].FixturesRequired;
- for (std::set<std::string>::const_iterator fixturesIt = fixtures.begin();
- fixturesIt != fixtures.end(); ++fixturesIt) {
-
- const std::string& requiredFixtureName = *fixturesIt;
+ for (std::string const& requiredFixtureName : fixtures) {
if (requiredFixtureName.empty()) {
continue;
}
@@ -924,12 +976,10 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
// cleanup tests depend on this test case later.
std::pair<FixtureDepsIterator, FixtureDepsIterator> setupRange =
fixtureSetups.equal_range(requiredFixtureName);
- for (FixtureDepsIterator sIt = setupRange.first;
- sIt != setupRange.second; ++sIt) {
+ for (auto sIt = setupRange.first; sIt != setupRange.second; ++sIt) {
const std::string& setupTestName = sIt->second->Name;
tests[i].RequireSuccessDepends.insert(setupTestName);
- if (std::find(tests[i].Depends.begin(), tests[i].Depends.end(),
- setupTestName) == tests[i].Depends.end()) {
+ if (!cmContains(tests[i].Depends, setupTestName)) {
tests[i].Depends.push_back(setupTestName);
}
}
@@ -949,8 +999,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
!excludeSetupRegex.find(requiredFixtureName)) {
std::pair<FixtureDepsIterator, FixtureDepsIterator> fixtureRange =
fixtureSetups.equal_range(requiredFixtureName);
- for (FixtureDepsIterator it = fixtureRange.first;
- it != fixtureRange.second; ++it) {
+ for (auto it = fixtureRange.first; it != fixtureRange.second; ++it) {
ListOfTests::const_iterator lotIt = it->second;
const cmCTestTestProperties& p = *lotIt;
@@ -981,8 +1030,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
!excludeCleanupRegex.find(requiredFixtureName)) {
std::pair<FixtureDepsIterator, FixtureDepsIterator> fixtureRange =
fixtureCleanups.equal_range(requiredFixtureName);
- for (FixtureDepsIterator it = fixtureRange.first;
- it != fixtureRange.second; ++it) {
+ for (auto it = fixtureRange.first; it != fixtureRange.second; ++it) {
ListOfTests::const_iterator lotIt = it->second;
const cmCTestTestProperties& p = *lotIt;
@@ -1010,11 +1058,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
}
// 2. Record all setup fixtures included in the final list of tests
- for (std::set<std::string>::const_iterator fixturesIt =
- tests[i].FixturesSetup.begin();
- fixturesIt != tests[i].FixturesSetup.end(); ++fixturesIt) {
-
- const std::string& setupFixtureName = *fixturesIt;
+ for (std::string const& setupFixtureName : tests[i].FixturesSetup) {
if (setupFixtureName.empty()) {
continue;
}
@@ -1028,25 +1072,18 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
// setup tests for that fixture. The latter is required to handle the
// pathological case where setup and cleanup tests are in the test set
// but no other test has that fixture as a requirement.
- for (ListOfTests::iterator tIt = tests.begin(); tIt != tests.end(); ++tIt) {
- cmCTestTestProperties& p = *tIt;
+ for (cmCTestTestProperties& p : tests) {
const std::set<std::string>& cleanups = p.FixturesCleanup;
- for (std::set<std::string>::const_iterator fIt = cleanups.begin();
- fIt != cleanups.end(); ++fIt) {
- const std::string& fixture = *fIt;
-
+ for (std::string const& fixture : cleanups) {
// This cleanup test could be part of the original test list that was
// passed in. It is then possible that no other test requires the
// fIt fixture, so we have to check for this.
- std::map<std::string, std::vector<size_t> >::const_iterator cIt =
- fixtureRequirements.find(fixture);
+ auto cIt = fixtureRequirements.find(fixture);
if (cIt != fixtureRequirements.end()) {
const std::vector<size_t>& indices = cIt->second;
- for (std::vector<size_t>::const_iterator indexIt = indices.begin();
- indexIt != indices.end(); ++indexIt) {
- const std::string& reqTestName = tests[*indexIt].Name;
- if (std::find(p.Depends.begin(), p.Depends.end(), reqTestName) ==
- p.Depends.end()) {
+ for (size_t index : indices) {
+ const std::string& reqTestName = tests[index].Name;
+ if (!cmContains(p.Depends, reqTestName)) {
p.Depends.push_back(reqTestName);
}
}
@@ -1057,11 +1094,9 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
cIt = setupFixturesAdded.find(fixture);
if (cIt != setupFixturesAdded.end()) {
const std::vector<size_t>& indices = cIt->second;
- for (std::vector<size_t>::const_iterator indexIt = indices.begin();
- indexIt != indices.end(); ++indexIt) {
- const std::string& setupTestName = tests[*indexIt].Name;
- if (std::find(p.Depends.begin(), p.Depends.end(), setupTestName) ==
- p.Depends.end()) {
+ for (size_t index : indices) {
+ const std::string& setupTestName = tests[index].Name;
+ if (!cmContains(p.Depends, setupTestName)) {
p.Depends.push_back(setupTestName);
}
}
@@ -1069,18 +1104,17 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
}
}
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Added "
- << fixtureTestsAdded
- << " tests to meet fixture requirements" << std::endl,
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Added " << fixtureTestsAdded
+ << " tests to meet fixture requirements"
+ << std::endl,
this->Quiet);
}
void cmCTestTestHandler::UpdateMaxTestNameWidth()
{
std::string::size_type max = this->CTest->GetMaxTestNameWidth();
- for (cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin();
- it != this->TestList.end(); it++) {
- cmCTestTestProperties& p = *it;
+ for (cmCTestTestProperties& p : this->TestList) {
if (max < p.Name.size()) {
max = p.Name.size();
}
@@ -1101,8 +1135,9 @@ bool cmCTestTestHandler::GetValue(const char* tag, int& value,
fin >> value;
ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
} else {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
- << tag << " found [" << line << "]" << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "parse error: missing tag: " << tag << " found [" << line << "]"
+ << std::endl);
ret = false;
}
return ret;
@@ -1118,8 +1153,9 @@ bool cmCTestTestHandler::GetValue(const char* tag, double& value,
fin >> value;
ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
} else {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
- << tag << " found [" << line << "]" << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "parse error: missing tag: " << tag << " found [" << line << "]"
+ << std::endl);
ret = false;
}
return ret;
@@ -1144,8 +1180,9 @@ bool cmCTestTestHandler::GetValue(const char* tag, bool& value,
#endif
ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
} else {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
- << tag << " found [" << line << "]" << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "parse error: missing tag: " << tag << " found [" << line << "]"
+ << std::endl);
ret = false;
}
return ret;
@@ -1161,8 +1198,9 @@ bool cmCTestTestHandler::GetValue(const char* tag, size_t& value,
fin >> value;
ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line
} else {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
- << tag << " found [" << line << "]" << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "parse error: missing tag: " << tag << " found [" << line << "]"
+ << std::endl);
ret = false;
}
return ret;
@@ -1177,8 +1215,9 @@ bool cmCTestTestHandler::GetValue(const char* tag, std::string& value,
if (line == tag) {
ret = cmSystemTools::GetLineFromStream(fin, value);
} else {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: "
- << tag << " found [" << line << "]" << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "parse error: missing tag: " << tag << " found [" << line << "]"
+ << std::endl);
ret = false;
}
return ret;
@@ -1189,12 +1228,10 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
{
this->ComputeTestList();
this->StartTest = this->CTest->CurrentTime();
- this->StartTestTime = static_cast<unsigned int>(cmSystemTools::GetTime());
- double elapsed_time_start = cmSystemTools::GetTime();
+ this->StartTestTime = std::chrono::system_clock::now();
+ auto elapsed_time_start = std::chrono::steady_clock::now();
- cmCTestMultiProcessHandler* parallel = this->CTest->GetBatchJobs()
- ? new cmCTestBatchTestHandler
- : new cmCTestMultiProcessHandler;
+ cmCTestMultiProcessHandler* parallel = new cmCTestMultiProcessHandler;
parallel->SetCTest(this->CTest);
parallel->SetParallelLevel(this->CTest->GetParallelLevel());
parallel->SetTestHandler(this);
@@ -1204,6 +1241,9 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
} else {
parallel->SetTestLoad(this->CTest->GetTestLoad());
}
+ if (this->UseResourceSpec) {
+ parallel->InitResourceAllocator(this->ResourceSpec);
+ }
*this->LogFile
<< "Start testing: " << this->CTest->CurrentTime() << std::endl
@@ -1215,41 +1255,39 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
bool randomSchedule = this->CTest->GetScheduleType() == "Random";
if (randomSchedule) {
- srand((unsigned)time(CM_NULLPTR));
+ srand(static_cast<unsigned>(time(nullptr)));
}
- for (ListOfTests::iterator it = this->TestList.begin();
- it != this->TestList.end(); ++it) {
- cmCTestTestProperties& p = *it;
+ for (cmCTestTestProperties& p : this->TestList) {
cmCTestMultiProcessHandler::TestSet depends;
if (randomSchedule) {
p.Cost = static_cast<float>(rand());
}
- if (p.Timeout == 0 && this->CTest->GetGlobalTimeout() != 0) {
+ if (p.Timeout == cmDuration::zero() &&
+ this->CTest->GetGlobalTimeout() != cmDuration::zero()) {
p.Timeout = this->CTest->GetGlobalTimeout();
}
if (!p.Depends.empty()) {
- for (std::vector<std::string>::iterator i = p.Depends.begin();
- i != p.Depends.end(); ++i) {
- for (ListOfTests::iterator it2 = this->TestList.begin();
- it2 != this->TestList.end(); ++it2) {
- if (it2->Name == *i) {
- depends.insert(it2->Index);
+ for (std::string const& i : p.Depends) {
+ for (cmCTestTestProperties const& it2 : this->TestList) {
+ if (it2.Name == i) {
+ depends.insert(it2.Index);
break; // break out of test loop as name can only match 1
}
}
}
}
- tests[it->Index] = depends;
- properties[it->Index] = &*it;
+ tests[p.Index] = depends;
+ properties[p.Index] = &p;
}
parallel->SetTests(tests, properties);
parallel->SetPassFailVectors(&passed, &failed);
this->TestResults.clear();
parallel->SetTestResults(&this->TestResults);
+ parallel->CheckResourcesAvailable();
if (this->CTest->ShouldPrintLabels()) {
parallel->PrintLabels();
@@ -1260,8 +1298,9 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
}
delete parallel;
this->EndTest = this->CTest->CurrentTime();
- this->EndTestTime = static_cast<unsigned int>(cmSystemTools::GetTime());
- this->ElapsedTestingTime = cmSystemTools::GetTime() - elapsed_time_start;
+ this->EndTestTime = std::chrono::system_clock::now();
+ this->ElapsedTestingTime =
+ std::chrono::steady_clock::now() - elapsed_time_start;
*this->LogFile << "End testing: " << this->CTest->CurrentTime() << std::endl;
}
@@ -1277,83 +1316,85 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
}
this->CTest->StartXML(xml, this->AppendXML);
+ this->CTest->GenerateSubprojectsOutput(xml);
xml.StartElement("Testing");
xml.Element("StartDateTime", this->StartTest);
xml.Element("StartTestTime", this->StartTestTime);
xml.StartElement("TestList");
- cmCTestTestHandler::TestResultsVector::size_type cc;
- for (cc = 0; cc < this->TestResults.size(); cc++) {
- cmCTestTestResult* result = &this->TestResults[cc];
- std::string testPath = result->Path + "/" + result->Name;
+ for (cmCTestTestResult const& result : this->TestResults) {
+ std::string testPath = result.Path + "/" + result.Name;
xml.Element("Test", this->CTest->GetShortPathToFile(testPath.c_str()));
}
xml.EndElement(); // TestList
- for (cc = 0; cc < this->TestResults.size(); cc++) {
- cmCTestTestResult* result = &this->TestResults[cc];
+ for (cmCTestTestResult& result : this->TestResults) {
this->WriteTestResultHeader(xml, result);
xml.StartElement("Results");
- if (result->Status != cmCTestTestHandler::NOT_RUN) {
- if (result->Status != cmCTestTestHandler::COMPLETED ||
- result->ReturnValue) {
+ if (result.Status != cmCTestTestHandler::NOT_RUN) {
+ if (result.Status != cmCTestTestHandler::COMPLETED ||
+ result.ReturnValue) {
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
xml.Attribute("name", "Exit Code");
- xml.Element("Value", this->GetTestStatus(result->Status));
+ xml.Element("Value", this->GetTestStatus(result));
xml.EndElement(); // NamedMeasurement
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
xml.Attribute("name", "Exit Value");
- xml.Element("Value", result->ReturnValue);
+ xml.Element("Value", result.ReturnValue);
xml.EndElement(); // NamedMeasurement
}
- this->GenerateRegressionImages(xml, result->DartString);
+ this->GenerateRegressionImages(xml, result.DartString);
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "numeric/double");
xml.Attribute("name", "Execution Time");
- xml.Element("Value", result->ExecutionTime);
+ xml.Element("Value", result.ExecutionTime.count());
xml.EndElement(); // NamedMeasurement
- if (!result->Reason.empty()) {
+ if (!result.Reason.empty()) {
const char* reasonType = "Pass Reason";
- if (result->Status != cmCTestTestHandler::COMPLETED) {
+ if (result.Status != cmCTestTestHandler::COMPLETED) {
reasonType = "Fail Reason";
}
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
xml.Attribute("name", reasonType);
- xml.Element("Value", result->Reason);
+ xml.Element("Value", result.Reason);
xml.EndElement(); // NamedMeasurement
}
}
xml.StartElement("NamedMeasurement");
+ xml.Attribute("type", "numeric/double");
+ xml.Attribute("name", "Processors");
+ xml.Element("Value", result.Properties->Processors);
+ xml.EndElement(); // NamedMeasurement
+
+ xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
xml.Attribute("name", "Completion Status");
- xml.Element("Value", result->CompletionStatus);
+ xml.Element("Value", result.CompletionStatus);
xml.EndElement(); // NamedMeasurement
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
xml.Attribute("name", "Command Line");
- xml.Element("Value", result->FullCommandLine);
+ xml.Element("Value", result.FullCommandLine);
xml.EndElement(); // NamedMeasurement
- std::map<std::string, std::string>::iterator measureIt;
- for (measureIt = result->Properties->Measurements.begin();
- measureIt != result->Properties->Measurements.end(); ++measureIt) {
+ for (auto const& measure : result.Properties->Measurements) {
xml.StartElement("NamedMeasurement");
xml.Attribute("type", "text/string");
- xml.Attribute("name", measureIt->first);
- xml.Element("Value", measureIt->second);
+ xml.Attribute("name", measure.first);
+ xml.Element("Value", measure.second);
xml.EndElement(); // NamedMeasurement
}
xml.StartElement("Measurement");
xml.StartElement("Value");
- if (result->CompressOutput) {
+ if (result.CompressOutput) {
xml.Attribute("encoding", "base64");
xml.Attribute("compression", "gzip");
}
- xml.Content(result->Output);
+ xml.Content(result.Output);
xml.EndElement(); // Value
xml.EndElement(); // Measurement
xml.EndElement(); // Results
@@ -1364,39 +1405,40 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
xml.Element("EndDateTime", this->EndTest);
xml.Element("EndTestTime", this->EndTestTime);
- xml.Element("ElapsedMinutes",
- static_cast<int>(this->ElapsedTestingTime / 6) / 10.0);
+ xml.Element(
+ "ElapsedMinutes",
+ std::chrono::duration_cast<std::chrono::minutes>(this->ElapsedTestingTime)
+ .count());
xml.EndElement(); // Testing
this->CTest->EndXML(xml);
}
void cmCTestTestHandler::WriteTestResultHeader(cmXMLWriter& xml,
- cmCTestTestResult* result)
+ cmCTestTestResult const& result)
{
xml.StartElement("Test");
- if (result->Status == cmCTestTestHandler::COMPLETED) {
+ if (result.Status == cmCTestTestHandler::COMPLETED) {
xml.Attribute("Status", "passed");
- } else if (result->Status == cmCTestTestHandler::NOT_RUN) {
+ } else if (result.Status == cmCTestTestHandler::NOT_RUN) {
xml.Attribute("Status", "notrun");
} else {
xml.Attribute("Status", "failed");
}
- std::string testPath = result->Path + "/" + result->Name;
- xml.Element("Name", result->Name);
- xml.Element("Path", this->CTest->GetShortPathToFile(result->Path.c_str()));
+ std::string testPath = result.Path + "/" + result.Name;
+ xml.Element("Name", result.Name);
+ xml.Element("Path", this->CTest->GetShortPathToFile(result.Path.c_str()));
xml.Element("FullName", this->CTest->GetShortPathToFile(testPath.c_str()));
- xml.Element("FullCommandLine", result->FullCommandLine);
+ xml.Element("FullCommandLine", result.FullCommandLine);
}
void cmCTestTestHandler::WriteTestResultFooter(cmXMLWriter& xml,
- cmCTestTestResult* result)
+ cmCTestTestResult const& result)
{
- if (!result->Properties->Labels.empty()) {
+ if (!result.Properties->Labels.empty()) {
xml.StartElement("Labels");
- std::vector<std::string> const& labels = result->Properties->Labels;
- for (std::vector<std::string>::const_iterator li = labels.begin();
- li != labels.end(); ++li) {
- xml.Element("Label", *li);
+ std::vector<std::string> const& labels = result.Properties->Labels;
+ for (std::string const& label : labels) {
+ xml.Element("Label", label);
}
xml.EndElement(); // Labels
}
@@ -1405,20 +1447,18 @@ void cmCTestTestHandler::WriteTestResultFooter(cmXMLWriter& xml,
}
void cmCTestTestHandler::AttachFiles(cmXMLWriter& xml,
- cmCTestTestResult* result)
+ cmCTestTestResult& result)
{
- if (result->Status != cmCTestTestHandler::COMPLETED &&
- !result->Properties->AttachOnFail.empty()) {
- result->Properties->AttachedFiles.insert(
- result->Properties->AttachedFiles.end(),
- result->Properties->AttachOnFail.begin(),
- result->Properties->AttachOnFail.end());
- }
- for (std::vector<std::string>::const_iterator file =
- result->Properties->AttachedFiles.begin();
- file != result->Properties->AttachedFiles.end(); ++file) {
- const std::string& base64 = this->CTest->Base64GzipEncodeFile(*file);
- std::string fname = cmSystemTools::GetFilenameName(*file);
+ if (result.Status != cmCTestTestHandler::COMPLETED &&
+ !result.Properties->AttachOnFail.empty()) {
+ result.Properties->AttachedFiles.insert(
+ result.Properties->AttachedFiles.end(),
+ result.Properties->AttachOnFail.begin(),
+ result.Properties->AttachOnFail.end());
+ }
+ for (std::string const& file : result.Properties->AttachedFiles) {
+ const std::string& base64 = this->CTest->Base64GzipEncodeFile(file);
+ std::string const fname = cmSystemTools::GetFilenameName(file);
xml.StartElement("NamedMeasurement");
xml.Attribute("name", "Attached File");
xml.Attribute("encoding", "base64");
@@ -1432,18 +1472,16 @@ void cmCTestTestHandler::AttachFiles(cmXMLWriter& xml,
int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec)
{
- std::vector<std::string>::iterator it;
- for (it = vec.begin(); it != vec.end(); ++it) {
+ for (std::string const& it : vec) {
int retVal = 0;
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Run command: " << *it << std::endl, this->Quiet);
- if (!cmSystemTools::RunSingleCommand(it->c_str(), CM_NULLPTR, CM_NULLPTR,
- &retVal, CM_NULLPTR,
- cmSystemTools::OUTPUT_MERGE
+ "Run command: " << it << std::endl, this->Quiet);
+ if (!cmSystemTools::RunSingleCommand(it, nullptr, nullptr, &retVal,
+ nullptr, cmSystemTools::OUTPUT_MERGE
/*this->Verbose*/) ||
retVal != 0) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem running command: " << *it << std::endl);
+ "Problem running command: " << it << std::endl);
return 0;
}
}
@@ -1476,55 +1514,37 @@ void cmCTestTestHandler::AddConfigurations(
}
tempPath = filepath + filename;
attempted.push_back(tempPath);
- attemptedConfigs.push_back("");
+ attemptedConfigs.emplace_back();
if (!ctest->GetConfigType().empty()) {
- tempPath = filepath;
- tempPath += ctest->GetConfigType();
- tempPath += "/";
- tempPath += filename;
+ tempPath = cmStrCat(filepath, ctest->GetConfigType(), '/', filename);
attempted.push_back(tempPath);
attemptedConfigs.push_back(ctest->GetConfigType());
// If the file is an OSX bundle then the configtype
// will be at the start of the path
- tempPath = ctest->GetConfigType();
- tempPath += "/";
- tempPath += filepath;
- tempPath += filename;
+ tempPath = cmStrCat(ctest->GetConfigType(), '/', filepath, filename);
attempted.push_back(tempPath);
attemptedConfigs.push_back(ctest->GetConfigType());
} else {
// no config specified - try some options...
- tempPath = filepath;
- tempPath += "Release/";
- tempPath += filename;
+ tempPath = cmStrCat(filepath, "Release/", filename);
attempted.push_back(tempPath);
- attemptedConfigs.push_back("Release");
- tempPath = filepath;
- tempPath += "Debug/";
- tempPath += filename;
+ attemptedConfigs.emplace_back("Release");
+ tempPath = cmStrCat(filepath, "Debug/", filename);
attempted.push_back(tempPath);
- attemptedConfigs.push_back("Debug");
- tempPath = filepath;
- tempPath += "MinSizeRel/";
- tempPath += filename;
+ attemptedConfigs.emplace_back("Debug");
+ tempPath = cmStrCat(filepath, "MinSizeRel/", filename);
attempted.push_back(tempPath);
- attemptedConfigs.push_back("MinSizeRel");
- tempPath = filepath;
- tempPath += "RelWithDebInfo/";
- tempPath += filename;
+ attemptedConfigs.emplace_back("MinSizeRel");
+ tempPath = cmStrCat(filepath, "RelWithDebInfo/", filename);
attempted.push_back(tempPath);
- attemptedConfigs.push_back("RelWithDebInfo");
- tempPath = filepath;
- tempPath += "Deployment/";
- tempPath += filename;
+ attemptedConfigs.emplace_back("RelWithDebInfo");
+ tempPath = cmStrCat(filepath, "Deployment/", filename);
attempted.push_back(tempPath);
- attemptedConfigs.push_back("Deployment");
- tempPath = filepath;
- tempPath += "Development/";
- tempPath += filename;
+ attemptedConfigs.emplace_back("Deployment");
+ tempPath = cmStrCat(filepath, "Development/", filename);
attempted.push_back(tempPath);
- attemptedConfigs.push_back("Deployment");
+ attemptedConfigs.emplace_back("Deployment");
}
}
@@ -1554,11 +1574,9 @@ std::string cmCTestTestHandler::FindExecutable(
// if extraPaths are provided and we were not passed a full path, try them,
// try any extra paths
if (filepath.empty()) {
- for (unsigned int i = 0; i < extraPaths.size(); ++i) {
- std::string filepathExtra =
- cmSystemTools::GetFilenamePath(extraPaths[i]);
- std::string filenameExtra =
- cmSystemTools::GetFilenameName(extraPaths[i]);
+ for (std::string const& extraPath : extraPaths) {
+ std::string filepathExtra = cmSystemTools::GetFilenamePath(extraPath);
+ std::string filenameExtra = cmSystemTools::GetFilenameName(extraPath);
cmCTestTestHandler::AddConfigurations(ctest, attempted, attemptedConfigs,
filepathExtra, filenameExtra);
}
@@ -1570,7 +1588,7 @@ std::string cmCTestTestHandler::FindExecutable(
// now look in the paths we specified above
for (unsigned int ai = 0; ai < attempted.size() && fullPath.empty(); ++ai) {
// first check without exe extension
- if (cmSystemTools::FileExists(attempted[ai].c_str()) &&
+ if (cmSystemTools::FileExists(attempted[ai]) &&
!cmSystemTools::FileIsDirectory(attempted[ai])) {
fullPath = cmSystemTools::CollapseFullPath(attempted[ai]);
resultingConfig = attemptedConfigs[ai];
@@ -1578,9 +1596,9 @@ std::string cmCTestTestHandler::FindExecutable(
// then try with the exe extension
else {
failed.push_back(attempted[ai]);
- tempPath = attempted[ai];
- tempPath += cmSystemTools::GetExecutableExtension();
- if (cmSystemTools::FileExists(tempPath.c_str()) &&
+ tempPath =
+ cmStrCat(attempted[ai], cmSystemTools::GetExecutableExtension());
+ if (cmSystemTools::FileExists(tempPath) &&
!cmSystemTools::FileIsDirectory(tempPath)) {
fullPath = cmSystemTools::CollapseFullPath(tempPath);
resultingConfig = attemptedConfigs[ai];
@@ -1593,25 +1611,33 @@ std::string cmCTestTestHandler::FindExecutable(
// if everything else failed, check the users path, but only if a full path
// wasn't specified
if (fullPath.empty() && filepath.empty()) {
- std::string path = cmSystemTools::FindProgram(filename.c_str());
- if (path != "") {
- resultingConfig = "";
+ std::string const path = cmSystemTools::FindProgram(filename.c_str());
+ if (!path.empty()) {
+ resultingConfig.clear();
return path;
}
}
if (fullPath.empty()) {
- cmCTestLog(ctest, HANDLER_OUTPUT, "Could not find executable "
+ cmCTestLog(ctest, HANDLER_OUTPUT,
+ "Could not find executable "
<< testCommand << "\n"
<< "Looked in the following places:\n");
- for (std::vector<std::string>::iterator i = failed.begin();
- i != failed.end(); ++i) {
- cmCTestLog(ctest, HANDLER_OUTPUT, *i << "\n");
+ for (std::string const& f : failed) {
+ cmCTestLog(ctest, HANDLER_OUTPUT, f << "\n");
}
}
return fullPath;
}
+bool cmCTestTestHandler::ParseResourceGroupsProperty(
+ const std::string& val,
+ std::vector<std::vector<cmCTestTestResourceRequirement>>& resourceGroups)
+{
+ cmCTestResourceGroupsLexerHelper lexer(resourceGroups);
+ return lexer.ParseString(val);
+}
+
void cmCTestTestHandler::GetListOfTests()
{
if (!this->IncludeLabelRegExp.empty()) {
@@ -1630,35 +1656,32 @@ void cmCTestTestHandler::GetListOfTests()
}
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Constructing a list of tests" << std::endl, this->Quiet);
- cmake cm(cmake::RoleScript);
+ cmake cm(cmake::RoleScript, cmState::CTest);
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm);
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
- mf->AddDefinition("CTEST_CONFIGURATION_TYPE",
- this->CTest->GetConfigType().c_str());
+ cmMakefile mf(&gg, cm.GetCurrentSnapshot());
+ mf.AddDefinition("CTEST_CONFIGURATION_TYPE", this->CTest->GetConfigType());
// Add handler for ADD_TEST
- cmCTestAddTestCommand* newCom1 = new cmCTestAddTestCommand;
- newCom1->TestHandler = this;
- cm.GetState()->AddBuiltinCommand("add_test", newCom1);
+ cm.GetState()->AddBuiltinCommand("add_test", cmCTestAddTestCommand(this));
// Add handler for SUBDIRS
- cmCTestSubdirCommand* newCom2 = new cmCTestSubdirCommand;
- newCom2->TestHandler = this;
- cm.GetState()->AddBuiltinCommand("subdirs", newCom2);
+ cm.GetState()->AddBuiltinCommand("subdirs", cmCTestSubdirCommand);
// Add handler for ADD_SUBDIRECTORY
- cmCTestAddSubdirectoryCommand* newCom3 = new cmCTestAddSubdirectoryCommand;
- newCom3->TestHandler = this;
- cm.GetState()->AddBuiltinCommand("add_subdirectory", newCom3);
+ cm.GetState()->AddBuiltinCommand("add_subdirectory",
+ cmCTestAddSubdirectoryCommand);
// Add handler for SET_TESTS_PROPERTIES
- cmCTestSetTestsPropertiesCommand* newCom4 =
- new cmCTestSetTestsPropertiesCommand;
- newCom4->TestHandler = this;
- cm.GetState()->AddBuiltinCommand("set_tests_properties", newCom4);
+ cm.GetState()->AddBuiltinCommand("set_tests_properties",
+ cmCTestSetTestsPropertiesCommand(this));
+
+ // Add handler for SET_DIRECTORY_PROPERTIES
+ cm.GetState()->RemoveBuiltinCommand("set_directory_properties");
+ cm.GetState()->AddBuiltinCommand("set_directory_properties",
+ cmCTestSetDirectoryPropertiesCommand(this));
const char* testFilename;
if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
@@ -1671,7 +1694,7 @@ void cmCTestTestHandler::GetListOfTests()
return;
}
- if (!mf->ReadListFile(testFilename)) {
+ if (!mf.ReadListFile(testFilename)) {
return;
}
if (cmSystemTools::GetErrorOccuredFlag()) {
@@ -1693,17 +1716,20 @@ void cmCTestTestHandler::UseExcludeRegExp()
this->UseExcludeRegExpFirst = !this->UseIncludeRegExpFlag;
}
-const char* cmCTestTestHandler::GetTestStatus(int status)
+std::string cmCTestTestHandler::GetTestStatus(cmCTestTestResult const& result)
{
static const char* statuses[] = { "Not Run", "Timeout", "SEGFAULT",
"ILLEGAL", "INTERRUPT", "NUMERICAL",
"OTHER_FAULT", "Failed", "BAD_COMMAND",
"Completed" };
-
+ int status = result.Status;
if (status < cmCTestTestHandler::NOT_RUN ||
status > cmCTestTestHandler::COMPLETED) {
return "No Status";
}
+ if (status == cmCTestTestHandler::OTHER_FAULT) {
+ return result.ExceptionStatus;
+ }
return statuses[status];
}
@@ -1762,8 +1788,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformation(size_t numTests)
std::sort(this->TestsToRun.begin(), this->TestsToRun.end(),
std::less<int>());
// remove duplicates
- std::vector<int>::iterator new_end =
- std::unique(this->TestsToRun.begin(), this->TestsToRun.end());
+ auto new_end = std::unique(this->TestsToRun.begin(), this->TestsToRun.end());
this->TestsToRun.erase(new_end, this->TestsToRun.end());
}
@@ -1774,8 +1799,8 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
cmsys::Directory directory;
if (directory.Load(dirName) == 0) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to read the contents of "
- << dirName << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Unable to read the contents of " << dirName << std::endl);
return;
}
@@ -1792,7 +1817,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
if (fileNameSubstring != pattern) {
continue;
}
- if (logName == "") {
+ if (logName.empty()) {
logName = fileName;
} else {
// if multiple matching logs were found we use the most recently
@@ -1808,10 +1833,10 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
std::string lastTestsFailedLog =
this->CTest->GetBinaryDir() + "/Testing/Temporary/" + logName;
- if (!cmSystemTools::FileExists(lastTestsFailedLog.c_str())) {
+ if (!cmSystemTools::FileExists(lastTestsFailedLog)) {
if (!this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels()) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, lastTestsFailedLog
- << " does not exist!" << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ lastTestsFailedLog << " does not exist!" << std::endl);
}
return;
}
@@ -1833,7 +1858,8 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
ifs.close();
} else if (!this->CTest->GetShowOnly() &&
!this->CTest->ShouldPrintLabels()) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem reading file: "
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Problem reading file: "
<< lastTestsFailedLog
<< " while generating list of previously failed tests."
<< std::endl);
@@ -1921,7 +1947,7 @@ void cmCTestTestHandler::GenerateRegressionImages(cmXMLWriter& xml,
} else if (measurementfile.find(cxml)) {
const std::string& filename =
cmCTest::CleanString(measurementfile.match(5));
- if (cmSystemTools::FileExists(filename.c_str())) {
+ if (cmSystemTools::FileExists(filename)) {
long len = cmSystemTools::FileLength(filename);
if (len == 0) {
std::string k1 = measurementfile.match(1);
@@ -1942,11 +1968,12 @@ void cmCTestTestHandler::GenerateRegressionImages(cmXMLWriter& xml,
xml.Element("Value", "Image " + filename + " is empty");
xml.EndElement();
} else {
- cmsys::ifstream ifs(filename.c_str(), std::ios::in
+ cmsys::ifstream ifs(filename.c_str(),
+ std::ios::in
#ifdef _WIN32
| std::ios::binary
#endif
- );
+ );
unsigned char* file_buffer = new unsigned char[len + 1];
ifs.read(reinterpret_cast<char*>(file_buffer), len);
unsigned char* encoded_buffer = new unsigned char[static_cast<int>(
@@ -1983,9 +2010,9 @@ void cmCTestTestHandler::GenerateRegressionImages(cmXMLWriter& xml,
xml.Attribute("text", "text/string");
xml.Element("Value", "File " + filename + " not found");
xml.EndElement();
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "File \""
- << filename << "\" not found." << std::endl,
- this->Quiet);
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_OUTPUT,
+ "File \"" << filename << "\" not found." << std::endl, this->Quiet);
}
cxml.erase(measurementfile.start(),
measurementfile.end() - measurementfile.start());
@@ -2086,134 +2113,156 @@ bool cmCTestTestHandler::SetTestsProperties(
break;
}
std::string val = *it;
- std::vector<std::string>::const_iterator tit;
- for (tit = tests.begin(); tit != tests.end(); ++tit) {
- cmCTestTestHandler::ListOfTests::iterator rtit;
- for (rtit = this->TestList.begin(); rtit != this->TestList.end();
- ++rtit) {
- if (*tit == rtit->Name) {
+ for (std::string const& t : tests) {
+ for (cmCTestTestProperties& rt : this->TestList) {
+ if (t == rt.Name) {
+ if (key == "_BACKTRACE_TRIPLES") {
+ std::vector<std::string> triples;
+ // allow empty args in the triples
+ cmExpandList(val, triples, true);
+
+ // Ensure we have complete triples otherwise the data is corrupt.
+ if (triples.size() % 3 == 0) {
+ cmState state;
+ rt.Backtrace = cmListFileBacktrace(state.CreateBaseSnapshot());
+
+ // 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) {
+ cmListFileContext fc;
+ fc.FilePath = triples[i - 3];
+ long line = 0;
+ if (!cmStrToLong(triples[i - 2], &line)) {
+ line = 0;
+ }
+ fc.Line = line;
+ fc.Name = triples[i - 1];
+ rt.Backtrace = rt.Backtrace.Push(fc);
+ }
+ }
+ }
if (key == "WILL_FAIL") {
- rtit->WillFail = cmSystemTools::IsOn(val.c_str());
+ rt.WillFail = cmIsOn(val);
}
if (key == "DISABLED") {
- rtit->Disabled = cmSystemTools::IsOn(val.c_str());
+ rt.Disabled = cmIsOn(val);
}
if (key == "ATTACHED_FILES") {
- cmSystemTools::ExpandListArgument(val, rtit->AttachedFiles);
+ cmExpandList(val, rt.AttachedFiles);
}
if (key == "ATTACHED_FILES_ON_FAIL") {
- cmSystemTools::ExpandListArgument(val, rtit->AttachOnFail);
+ cmExpandList(val, rt.AttachOnFail);
}
if (key == "RESOURCE_LOCK") {
- std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val, lval);
+ std::vector<std::string> lval = cmExpandedList(val);
- rtit->LockedResources.insert(lval.begin(), lval.end());
+ rt.LockedResources.insert(lval.begin(), lval.end());
}
if (key == "FIXTURES_SETUP") {
- std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val, lval);
+ std::vector<std::string> lval = cmExpandedList(val);
- rtit->FixturesSetup.insert(lval.begin(), lval.end());
+ rt.FixturesSetup.insert(lval.begin(), lval.end());
}
if (key == "FIXTURES_CLEANUP") {
- std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val, lval);
+ std::vector<std::string> lval = cmExpandedList(val);
- rtit->FixturesCleanup.insert(lval.begin(), lval.end());
+ rt.FixturesCleanup.insert(lval.begin(), lval.end());
}
if (key == "FIXTURES_REQUIRED") {
- std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val, lval);
+ std::vector<std::string> lval = cmExpandedList(val);
- rtit->FixturesRequired.insert(lval.begin(), lval.end());
+ rt.FixturesRequired.insert(lval.begin(), lval.end());
}
if (key == "TIMEOUT") {
- rtit->Timeout = atof(val.c_str());
- rtit->ExplicitTimeout = true;
+ rt.Timeout = cmDuration(atof(val.c_str()));
+ rt.ExplicitTimeout = true;
}
if (key == "COST") {
- rtit->Cost = static_cast<float>(atof(val.c_str()));
+ rt.Cost = static_cast<float>(atof(val.c_str()));
}
if (key == "REQUIRED_FILES") {
- cmSystemTools::ExpandListArgument(val, rtit->RequiredFiles);
+ cmExpandList(val, rt.RequiredFiles);
}
if (key == "RUN_SERIAL") {
- rtit->RunSerial = cmSystemTools::IsOn(val.c_str());
+ rt.RunSerial = cmIsOn(val);
}
if (key == "FAIL_REGULAR_EXPRESSION") {
- std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val, lval);
- std::vector<std::string>::iterator crit;
- for (crit = lval.begin(); crit != lval.end(); ++crit) {
- rtit->ErrorRegularExpressions.push_back(
- std::pair<cmsys::RegularExpression, std::string>(
- cmsys::RegularExpression(crit->c_str()),
- std::string(*crit)));
+ std::vector<std::string> lval = cmExpandedList(val);
+ for (std::string const& cr : lval) {
+ rt.ErrorRegularExpressions.emplace_back(cr, cr);
+ }
+ }
+ if (key == "SKIP_REGULAR_EXPRESSION") {
+ std::vector<std::string> lval = cmExpandedList(val);
+ for (std::string const& cr : lval) {
+ rt.SkipRegularExpressions.emplace_back(cr, cr);
}
}
if (key == "PROCESSORS") {
- rtit->Processors = atoi(val.c_str());
- if (rtit->Processors < 1) {
- rtit->Processors = 1;
+ rt.Processors = atoi(val.c_str());
+ if (rt.Processors < 1) {
+ rt.Processors = 1;
+ }
+ }
+ if (key == "PROCESSOR_AFFINITY") {
+ rt.WantAffinity = cmIsOn(val);
+ }
+ if (key == "RESOURCE_GROUPS") {
+ if (!ParseResourceGroupsProperty(val, rt.ResourceGroups)) {
+ return false;
}
}
if (key == "SKIP_RETURN_CODE") {
- rtit->SkipReturnCode = atoi(val.c_str());
- if (rtit->SkipReturnCode < 0 || rtit->SkipReturnCode > 255) {
- rtit->SkipReturnCode = -1;
+ rt.SkipReturnCode = atoi(val.c_str());
+ if (rt.SkipReturnCode < 0 || rt.SkipReturnCode > 255) {
+ rt.SkipReturnCode = -1;
}
}
if (key == "DEPENDS") {
- cmSystemTools::ExpandListArgument(val, rtit->Depends);
+ cmExpandList(val, rt.Depends);
}
if (key == "ENVIRONMENT") {
- cmSystemTools::ExpandListArgument(val, rtit->Environment);
+ cmExpandList(val, rt.Environment);
}
if (key == "LABELS") {
- cmSystemTools::ExpandListArgument(val, rtit->Labels);
+ std::vector<std::string> Labels = cmExpandedList(val);
+ rt.Labels.insert(rt.Labels.end(), Labels.begin(), Labels.end());
+ // sort the array
+ std::sort(rt.Labels.begin(), rt.Labels.end());
+ // remove duplicates
+ auto new_end = std::unique(rt.Labels.begin(), rt.Labels.end());
+ rt.Labels.erase(new_end, rt.Labels.end());
}
if (key == "MEASUREMENT") {
size_t pos = val.find_first_of('=');
if (pos != std::string::npos) {
std::string mKey = val.substr(0, pos);
- const char* mVal = val.c_str() + pos + 1;
- rtit->Measurements[mKey] = mVal;
+ std::string mVal = val.substr(pos + 1);
+ rt.Measurements[mKey] = std::move(mVal);
} else {
- rtit->Measurements[val] = "1";
+ rt.Measurements[val] = "1";
}
}
if (key == "PASS_REGULAR_EXPRESSION") {
- std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val, lval);
- std::vector<std::string>::iterator crit;
- for (crit = lval.begin(); crit != lval.end(); ++crit) {
- rtit->RequiredRegularExpressions.push_back(
- std::pair<cmsys::RegularExpression, std::string>(
- cmsys::RegularExpression(crit->c_str()),
- std::string(*crit)));
+ std::vector<std::string> lval = cmExpandedList(val);
+ for (std::string const& cr : lval) {
+ rt.RequiredRegularExpressions.emplace_back(cr, cr);
}
}
if (key == "WORKING_DIRECTORY") {
- rtit->Directory = val;
+ rt.Directory = val;
}
if (key == "TIMEOUT_AFTER_MATCH") {
- std::vector<std::string> propArgs;
- cmSystemTools::ExpandListArgument(val, propArgs);
+ std::vector<std::string> propArgs = cmExpandedList(val);
if (propArgs.size() != 2) {
cmCTestLog(this->CTest, WARNING,
"TIMEOUT_AFTER_MATCH expects two arguments, found "
<< propArgs.size() << std::endl);
} else {
- rtit->AlternateTimeout = atof(propArgs[0].c_str());
- std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(propArgs[1], lval);
- std::vector<std::string>::iterator crit;
- for (crit = lval.begin(); crit != lval.end(); ++crit) {
- rtit->TimeoutRegularExpressions.push_back(
- std::pair<cmsys::RegularExpression, std::string>(
- cmsys::RegularExpression(crit->c_str()),
- std::string(*crit)));
+ rt.AlternateTimeout = cmDuration(atof(propArgs[0].c_str()));
+ std::vector<std::string> lval = cmExpandedList(propArgs[1]);
+ for (std::string const& cr : lval) {
+ rt.TimeoutRegularExpressions.emplace_back(cr, cr);
}
}
}
@@ -2224,6 +2273,51 @@ bool cmCTestTestHandler::SetTestsProperties(
return true;
}
+bool cmCTestTestHandler::SetDirectoryProperties(
+ const std::vector<std::string>& args)
+{
+ std::vector<std::string>::const_iterator it;
+ std::vector<std::string> tests;
+ bool found = false;
+ for (it = args.begin(); it != args.end(); ++it) {
+ if (*it == "PROPERTIES") {
+ found = true;
+ break;
+ }
+ tests.push_back(*it);
+ }
+
+ if (!found) {
+ return false;
+ }
+ ++it; // skip PROPERTIES
+ for (; it != args.end(); ++it) {
+ std::string key = *it;
+ ++it;
+ if (it == args.end()) {
+ break;
+ }
+ std::string val = *it;
+ for (cmCTestTestProperties& rt : this->TestList) {
+ std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
+ if (cwd == rt.Directory) {
+ if (key == "LABELS") {
+ std::vector<std::string> DirectoryLabels = cmExpandedList(val);
+ rt.Labels.insert(rt.Labels.end(), DirectoryLabels.begin(),
+ DirectoryLabels.end());
+
+ // sort the array
+ std::sort(rt.Labels.begin(), rt.Labels.end());
+ // remove duplicates
+ auto new_end = std::unique(rt.Labels.begin(), rt.Labels.end());
+ rt.Labels.erase(new_end, rt.Labels.end());
+ }
+ }
+ }
+ }
+ return true;
+}
+
bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
{
const std::string& testname = args[0];
@@ -2231,7 +2325,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
this->Quiet);
if (this->UseExcludeRegExpFlag && this->UseExcludeRegExpFirst &&
- this->ExcludeTestsRegularExpression.find(testname.c_str())) {
+ this->ExcludeTestsRegularExpression.find(testname)) {
return true;
}
if (this->MemCheck) {
@@ -2278,19 +2372,34 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
test.WillFail = false;
test.Disabled = false;
test.RunSerial = false;
- test.Timeout = 0;
+ test.Timeout = cmDuration::zero();
test.ExplicitTimeout = false;
test.Cost = 0;
test.Processors = 1;
+ test.WantAffinity = false;
test.SkipReturnCode = -1;
test.PreviousRuns = 0;
if (this->UseIncludeRegExpFlag &&
- !this->IncludeTestsRegularExpression.find(testname.c_str())) {
+ !this->IncludeTestsRegularExpression.find(testname)) {
test.IsInBasedOnREOptions = false;
} else if (this->UseExcludeRegExpFlag && !this->UseExcludeRegExpFirst &&
- this->ExcludeTestsRegularExpression.find(testname.c_str())) {
+ this->ExcludeTestsRegularExpression.find(testname)) {
test.IsInBasedOnREOptions = false;
}
this->TestList.push_back(test);
return true;
}
+
+bool cmCTestTestHandler::cmCTestTestResourceRequirement::operator==(
+ const cmCTestTestResourceRequirement& other) const
+{
+ return this->ResourceType == other.ResourceType &&
+ this->SlotsNeeded == other.SlotsNeeded &&
+ this->UnitsNeeded == other.UnitsNeeded;
+}
+
+bool cmCTestTestHandler::cmCTestTestResourceRequirement::operator!=(
+ const cmCTestTestResourceRequirement& other) const
+{
+ return !(*this == other);
+}
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index 0edcb143a..eab75d0eb 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -3,19 +3,26 @@
#ifndef cmCTestTestHandler_h
#define cmCTestTestHandler_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmCTestGenericHandler.h"
-
-#include "cmsys/RegularExpression.hxx"
+#include <chrono>
+#include <cstdint>
#include <iosfwd>
#include <map>
#include <set>
-#include <stddef.h>
#include <string>
#include <utility>
#include <vector>
+#include <stddef.h>
+
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmCTestGenericHandler.h"
+#include "cmCTestResourceSpec.h"
+#include "cmDuration.h"
+#include "cmListFileCache.h"
+
class cmCTest;
class cmMakefile;
class cmXMLWriter;
@@ -28,18 +35,17 @@ class cmCTestTestHandler : public cmCTestGenericHandler
{
friend class cmCTestRunTest;
friend class cmCTestMultiProcessHandler;
- friend class cmCTestBatchTestHandler;
public:
- typedef cmCTestGenericHandler Superclass;
+ using Superclass = cmCTestGenericHandler;
/**
* The main entry point for this class
*/
- int ProcessHandler() CM_OVERRIDE;
+ int ProcessHandler() override;
/**
- * When both -R and -I are used should te resulting test list be the
+ * When both -R and -I are used should the resulting test list be the
* intersection or the union of the lists. By default it is the
* intersection.
*/
@@ -54,9 +60,9 @@ public:
/**
* This method is called when reading CTest custom file
*/
- void PopulateCustomVectors(cmMakefile* mf) CM_OVERRIDE;
+ void PopulateCustomVectors(cmMakefile* mf) override;
- ///! Control the use of the regular expresisons, call these methods to turn
+ //! Control the use of the regular expresisons, call these methods to turn
/// them on
void UseIncludeRegExp();
void UseExcludeRegExp();
@@ -75,7 +81,7 @@ public:
this->CustomMaximumFailedTestOutputSize = n;
}
- ///! pass the -I argument down
+ //! pass the -I argument down
void SetTestsToRunInformation(const char*);
cmCTestTestHandler();
@@ -90,7 +96,22 @@ public:
*/
bool SetTestsProperties(const std::vector<std::string>& args);
- void Initialize() CM_OVERRIDE;
+ /**
+ * Set directory properties
+ */
+ bool SetDirectoryProperties(const std::vector<std::string>& args);
+
+ void Initialize() override;
+
+ struct cmCTestTestResourceRequirement
+ {
+ std::string ResourceType;
+ int SlotsNeeded;
+ int UnitsNeeded;
+
+ bool operator==(const cmCTestTestResourceRequirement& other) const;
+ bool operator!=(const cmCTestTestResourceRequirement& other) const;
+ };
// NOTE: This struct is Saved/Restored
// in cmCTestTestHandler, if you add to this class
@@ -105,11 +126,13 @@ public:
std::vector<std::string> Depends;
std::vector<std::string> AttachedFiles;
std::vector<std::string> AttachOnFail;
- std::vector<std::pair<cmsys::RegularExpression, std::string> >
+ std::vector<std::pair<cmsys::RegularExpression, std::string>>
ErrorRegularExpressions;
- std::vector<std::pair<cmsys::RegularExpression, std::string> >
+ std::vector<std::pair<cmsys::RegularExpression, std::string>>
RequiredRegularExpressions;
- std::vector<std::pair<cmsys::RegularExpression, std::string> >
+ std::vector<std::pair<cmsys::RegularExpression, std::string>>
+ SkipRegularExpressions;
+ std::vector<std::pair<cmsys::RegularExpression, std::string>>
TimeoutRegularExpressions;
std::map<std::string, std::string> Measurements;
bool IsInBasedOnREOptions;
@@ -118,12 +141,14 @@ public:
float Cost;
int PreviousRuns;
bool RunSerial;
- double Timeout;
+ cmDuration Timeout;
bool ExplicitTimeout;
- double AlternateTimeout;
+ cmDuration AlternateTimeout;
int Index;
// Requested number of process slots
int Processors;
+ bool WantAffinity;
+ std::vector<size_t> Affinity;
// return code of test which will mark test as "not run"
int SkipReturnCode;
std::vector<std::string> Environment;
@@ -133,6 +158,9 @@ public:
std::set<std::string> FixturesCleanup;
std::set<std::string> FixturesRequired;
std::set<std::string> RequireSuccessDepends;
+ std::vector<std::vector<cmCTestTestResourceRequirement>> ResourceGroups;
+ // Private test generator properties used to track backtraces
+ cmListFileBacktrace Backtrace;
};
struct cmCTestTestResult
@@ -141,9 +169,10 @@ public:
std::string Path;
std::string Reason;
std::string FullCommandLine;
- double ExecutionTime;
- int ReturnValue;
+ cmDuration ExecutionTime;
+ std::int64_t ReturnValue;
int Status;
+ std::string ExceptionStatus;
bool CompressOutput;
std::string CompletionStatus;
std::string Output;
@@ -173,33 +202,51 @@ public:
std::vector<std::string>& extraPaths,
std::vector<std::string>& failed);
- typedef std::vector<cmCTestTestProperties> ListOfTests;
+ static bool ParseResourceGroupsProperty(
+ const std::string& val,
+ std::vector<std::vector<cmCTestTestResourceRequirement>>& resourceGroups);
+
+ using ListOfTests = std::vector<cmCTestTestProperties>;
protected:
+ using SetOfTests =
+ std::set<cmCTestTestHandler::cmCTestTestResult, cmCTestTestResultLess>;
+
// compute a final test list
virtual int PreProcessHandler();
virtual int PostProcessHandler();
virtual void GenerateTestCommand(std::vector<std::string>& args, int test);
int ExecuteCommands(std::vector<std::string>& vec);
- void WriteTestResultHeader(cmXMLWriter& xml, cmCTestTestResult* result);
- void WriteTestResultFooter(cmXMLWriter& xml, cmCTestTestResult* result);
+ bool ProcessOptions();
+ void LogTestSummary(const std::vector<std::string>& passed,
+ const std::vector<std::string>& failed,
+ const cmDuration& durationInSecs);
+ void LogDisabledTests(const std::vector<cmCTestTestResult>& disabledTests);
+ void LogFailedTests(const std::vector<std::string>& failed,
+ const SetOfTests& resultsSet);
+ bool GenerateXML();
+
+ void WriteTestResultHeader(cmXMLWriter& xml,
+ cmCTestTestResult const& result);
+ void WriteTestResultFooter(cmXMLWriter& xml,
+ cmCTestTestResult const& result);
// Write attached test files into the xml
- void AttachFiles(cmXMLWriter& xml, cmCTestTestResult* result);
+ void AttachFiles(cmXMLWriter& xml, cmCTestTestResult& result);
//! Clean test output to specified length
bool CleanTestOutput(std::string& output, size_t length);
- double ElapsedTestingTime;
+ cmDuration ElapsedTestingTime;
- typedef std::vector<cmCTestTestResult> TestResultsVector;
+ using TestResultsVector = std::vector<cmCTestTestResult>;
TestResultsVector TestResults;
std::vector<std::string> CustomTestsIgnore;
std::string StartTest;
std::string EndTest;
- unsigned int StartTestTime;
- unsigned int EndTestTime;
+ std::chrono::system_clock::time_point StartTestTime;
+ std::chrono::system_clock::time_point EndTestTime;
bool MemCheck;
int CustomMaximumPassedTestOutputSize;
int CustomMaximumFailedTestOutputSize;
@@ -226,7 +273,8 @@ private:
*/
virtual void GenerateDartOutput(cmXMLWriter& xml);
- void PrintLabelSummary();
+ void PrintLabelOrSubprojectSummary(bool isSubProject);
+
/**
* Run the tests for a directory and any subdirectories
*/
@@ -262,7 +310,7 @@ private:
*/
std::string FindTheExecutable(const char* exe);
- const char* GetTestStatus(int status);
+ std::string GetTestStatus(cmCTestTestResult const&);
void ExpandTestsToRunInformation(size_t numPossibleTests);
void ExpandTestsToRunInformationForRerunFailed();
@@ -288,6 +336,9 @@ private:
cmsys::RegularExpression IncludeTestsRegularExpression;
cmsys::RegularExpression ExcludeTestsRegularExpression;
+ bool UseResourceSpec;
+ cmCTestResourceSpec ResourceSpec;
+
void GenerateRegressionImages(cmXMLWriter& xml, const std::string& dart);
cmsys::RegularExpression DartStuff1;
void CheckLabelFilter(cmCTestTestProperties& it);
diff --git a/Source/CTest/cmCTestUpdateCommand.cxx b/Source/CTest/cmCTestUpdateCommand.cxx
index 8c037545f..673eb9ac1 100644
--- a/Source/CTest/cmCTestUpdateCommand.cxx
+++ b/Source/CTest/cmCTestUpdateCommand.cxx
@@ -3,18 +3,15 @@
#include "cmCTestUpdateCommand.h"
#include "cmCTest.h"
-#include "cmCTestGenericHandler.h"
+#include "cmCTestUpdateHandler.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
-#include <vector>
-
cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
{
- if (this->Values[ct_SOURCE]) {
+ if (!this->Source.empty()) {
this->CTest->SetCTestConfiguration(
- "SourceDirectory",
- cmSystemTools::CollapseFullPath(this->Values[ct_SOURCE]).c_str(),
+ "SourceDirectory", cmSystemTools::CollapseFullPath(this->Source).c_str(),
this->Quiet);
} else {
this->CTest->SetCTestConfiguration(
@@ -62,6 +59,9 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
this->Makefile, "UpdateVersionOnly", "CTEST_UPDATE_VERSION_ONLY",
this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(
+ this->Makefile, "UpdateVersionOverride", "CTEST_UPDATE_VERSION_OVERRIDE",
+ this->Quiet);
+ this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "HGCommand", "CTEST_HG_COMMAND", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS", this->Quiet);
@@ -74,16 +74,12 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
this->CTest->SetCTestConfigurationFromCMakeVariable(
this->Makefile, "P4Options", "CTEST_P4_OPTIONS", this->Quiet);
- cmCTestGenericHandler* handler =
- this->CTest->GetInitializedHandler("update");
- if (!handler) {
- this->SetError("internal CTest error. Cannot instantiate update handler");
- return CM_NULLPTR;
- }
+ cmCTestUpdateHandler* handler = this->CTest->GetUpdateHandler();
+ handler->Initialize();
handler->SetCommand(this);
if (source_dir.empty()) {
this->SetError("source directory not specified. Please use SOURCE tag");
- return CM_NULLPTR;
+ return nullptr;
}
handler->SetOption("SourceDirectory", source_dir.c_str());
handler->SetQuiet(this->Quiet);
diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h
index 3b8f0a641..5555c1637 100644
--- a/Source/CTest/cmCTestUpdateCommand.h
+++ b/Source/CTest/cmCTestUpdateCommand.h
@@ -3,14 +3,17 @@
#ifndef cmCTestUpdateCommand_h
#define cmCTestUpdateCommand_h
-#include "cmConfigure.h"
-
-#include "cmCTestHandlerCommand.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <utility>
+
+#include <cm/memory>
+
+#include "cmCTestHandlerCommand.h"
+#include "cmCommand.h"
class cmCTestGenericHandler;
-class cmCommand;
/** \class cmCTestUpdate
* \brief Run a ctest script
@@ -20,26 +23,24 @@ class cmCommand;
class cmCTestUpdateCommand : public cmCTestHandlerCommand
{
public:
- cmCTestUpdateCommand() {}
-
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE
+ std::unique_ptr<cmCommand> Clone() override
{
- cmCTestUpdateCommand* ni = new cmCTestUpdateCommand;
+ auto ni = cm::make_unique<cmCTestUpdateCommand>();
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
- return ni;
+ return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
* The name of the command as specified in CMakeList.txt.
*/
- std::string GetName() const CM_OVERRIDE { return "ctest_update"; }
+ std::string GetName() const override { return "ctest_update"; }
protected:
- cmCTestGenericHandler* InitializeHandler() CM_OVERRIDE;
+ cmCTestGenericHandler* InitializeHandler() override;
};
#endif
diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx
index e08a9b7bd..f30ba2bd2 100644
--- a/Source/CTest/cmCTestUpdateHandler.cxx
+++ b/Source/CTest/cmCTestUpdateHandler.cxx
@@ -2,6 +2,11 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestUpdateHandler.h"
+#include <chrono>
+#include <sstream>
+
+#include <cm/memory>
+
#include "cmCLocaleEnvironmentScope.h"
#include "cmCTest.h"
#include "cmCTestBZR.h"
@@ -12,13 +17,11 @@
#include "cmCTestSVN.h"
#include "cmCTestVC.h"
#include "cmGeneratedFileStream.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
#include "cmXMLWriter.h"
-#include "cm_auto_ptr.hxx"
-#include <sstream>
-
static const char* cmCTestUpdateHandlerUpdateStrings[] = {
"Unknown", "CVS", "SVN", "BZR", "GIT", "HG", "P4"
};
@@ -32,20 +35,19 @@ static const char* cmCTestUpdateHandlerUpdateToString(int type)
return cmCTestUpdateHandlerUpdateStrings[type];
}
-cmCTestUpdateHandler::cmCTestUpdateHandler()
-{
-}
+cmCTestUpdateHandler::cmCTestUpdateHandler() = default;
void cmCTestUpdateHandler::Initialize()
{
this->Superclass::Initialize();
- this->UpdateCommand = "";
+ this->UpdateCommand.clear();
this->UpdateType = e_CVS;
}
int cmCTestUpdateHandler::DetermineType(const char* cmd, const char* type)
{
- cmCTestOptionalLog(this->CTest, DEBUG, "Determine update type from command: "
+ cmCTestOptionalLog(this->CTest, DEBUG,
+ "Determine update type from command: "
<< cmd << " and type: " << type << std::endl,
this->Quiet);
if (type && *type) {
@@ -128,34 +130,35 @@ int cmCTestUpdateHandler::ProcessHandler()
return -1;
}
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Use "
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " Use "
<< cmCTestUpdateHandlerUpdateToString(this->UpdateType)
<< " repository type" << std::endl;
, this->Quiet);
// Create an object to interact with the VCS tool.
- CM_AUTO_PTR<cmCTestVC> vc;
+ std::unique_ptr<cmCTestVC> vc;
switch (this->UpdateType) {
case e_CVS:
- vc.reset(new cmCTestCVS(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestCVS>(this->CTest, ofs);
break;
case e_SVN:
- vc.reset(new cmCTestSVN(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestSVN>(this->CTest, ofs);
break;
case e_BZR:
- vc.reset(new cmCTestBZR(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestBZR>(this->CTest, ofs);
break;
case e_GIT:
- vc.reset(new cmCTestGIT(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestGIT>(this->CTest, ofs);
break;
case e_HG:
- vc.reset(new cmCTestHG(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestHG>(this->CTest, ofs);
break;
case e_P4:
- vc.reset(new cmCTestP4(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestP4>(this->CTest, ofs);
break;
default:
- vc.reset(new cmCTestVC(this->CTest, ofs));
+ vc = cm::make_unique<cmCTestVC>(this->CTest, ofs);
break;
}
vc->SetCommandLineTool(this->UpdateCommand);
@@ -169,14 +172,13 @@ int cmCTestUpdateHandler::ProcessHandler()
//
cmGeneratedFileStream os;
if (!this->StartResultingXML(cmCTest::PartUpdate, "Update", os)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open log file"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot open log file" << std::endl);
return -1;
}
std::string start_time = this->CTest->CurrentTime();
- unsigned int start_time_time =
- static_cast<unsigned int>(cmSystemTools::GetTime());
- double elapsed_time_start = cmSystemTools::GetTime();
+ auto start_time_time = std::chrono::system_clock::now();
+ auto elapsed_time_start = std::chrono::steady_clock::now();
bool updated = vc->Update();
std::string buildname =
@@ -190,13 +192,18 @@ int cmCTestUpdateHandler::ProcessHandler()
std::string("ctest-") + cmVersion::GetCMakeVersion());
xml.Element("Site", this->CTest->GetCTestConfiguration("Site"));
xml.Element("BuildName", buildname);
- xml.Element("BuildStamp", this->CTest->GetCurrentTag() + "-" +
+ xml.Element("BuildStamp",
+ this->CTest->GetCurrentTag() + "-" +
this->CTest->GetTestModelString());
xml.Element("StartDateTime", start_time);
xml.Element("StartTime", start_time_time);
xml.Element("UpdateCommand", vc->GetUpdateCommandLine());
xml.Element("UpdateType",
cmCTestUpdateHandlerUpdateToString(this->UpdateType));
+ std::string changeId = this->CTest->GetCTestConfiguration("ChangeId");
+ if (!changeId.empty()) {
+ xml.Element("ChangeId", changeId);
+ }
bool loadedMods = vc->WriteXML(xml);
@@ -208,9 +215,9 @@ int cmCTestUpdateHandler::ProcessHandler()
this->Quiet);
}
if (int numModified = vc->GetPathCount(cmCTestVC::PathModified)) {
- cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Found "
- << numModified << " locally modified files\n",
- this->Quiet);
+ cmCTestOptionalLog(
+ this->CTest, HANDLER_OUTPUT,
+ " Found " << numModified << " locally modified files\n", this->Quiet);
localModifications += numModified;
}
if (int numConflicting = vc->GetPathCount(cmCTestVC::PathConflicting)) {
@@ -223,11 +230,11 @@ int cmCTestUpdateHandler::ProcessHandler()
cmCTestOptionalLog(this->CTest, DEBUG, "End" << std::endl, this->Quiet);
std::string end_time = this->CTest->CurrentTime();
xml.Element("EndDateTime", end_time);
- xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
- xml.Element(
- "ElapsedMinutes",
- static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
- 10.0);
+ xml.Element("EndTime", std::chrono::system_clock::now());
+ xml.Element("ElapsedMinutes",
+ std::chrono::duration_cast<std::chrono::minutes>(
+ std::chrono::steady_clock::now() - elapsed_time_start)
+ .count());
xml.StartElement("UpdateReturnStatus");
if (localModifications) {
@@ -240,8 +247,9 @@ int cmCTestUpdateHandler::ProcessHandler()
if (!updated) {
xml.Content("Update command failed:\n");
xml.Content(vc->GetUpdateCommandLine());
- cmCTestLog(this->CTest, HANDLER_OUTPUT, " Update command failed: "
- << vc->GetUpdateCommandLine() << "\n");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " Update command failed: " << vc->GetUpdateCommandLine()
+ << "\n");
}
xml.EndElement(); // UpdateReturnStatus
xml.EndElement(); // Update
@@ -256,37 +264,31 @@ int cmCTestUpdateHandler::DetectVCS(const char* dir)
"Check directory: " << sourceDirectory << std::endl,
this->Quiet);
sourceDirectory += "/.svn";
- if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+ if (cmSystemTools::FileExists(sourceDirectory)) {
return cmCTestUpdateHandler::e_SVN;
}
- sourceDirectory = dir;
- sourceDirectory += "/CVS";
- if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+ sourceDirectory = cmStrCat(dir, "/CVS");
+ if (cmSystemTools::FileExists(sourceDirectory)) {
return cmCTestUpdateHandler::e_CVS;
}
- sourceDirectory = dir;
- sourceDirectory += "/.bzr";
- if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+ sourceDirectory = cmStrCat(dir, "/.bzr");
+ if (cmSystemTools::FileExists(sourceDirectory)) {
return cmCTestUpdateHandler::e_BZR;
}
- sourceDirectory = dir;
- sourceDirectory += "/.git";
- if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+ sourceDirectory = cmStrCat(dir, "/.git");
+ if (cmSystemTools::FileExists(sourceDirectory)) {
return cmCTestUpdateHandler::e_GIT;
}
- sourceDirectory = dir;
- sourceDirectory += "/.hg";
- if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+ sourceDirectory = cmStrCat(dir, "/.hg");
+ if (cmSystemTools::FileExists(sourceDirectory)) {
return cmCTestUpdateHandler::e_HG;
}
- sourceDirectory = dir;
- sourceDirectory += "/.p4";
- if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+ sourceDirectory = cmStrCat(dir, "/.p4");
+ if (cmSystemTools::FileExists(sourceDirectory)) {
return cmCTestUpdateHandler::e_P4;
}
- sourceDirectory = dir;
- sourceDirectory += "/.p4config";
- if (cmSystemTools::FileExists(sourceDirectory.c_str())) {
+ sourceDirectory = cmStrCat(dir, "/.p4config");
+ if (cmSystemTools::FileExists(sourceDirectory)) {
return cmCTestUpdateHandler::e_P4;
}
return cmCTestUpdateHandler::e_UNKNOWN;
@@ -309,7 +311,7 @@ bool cmCTestUpdateHandler::SelectVCS()
// If no update command was specified, lookup one for this VCS tool.
if (this->UpdateCommand.empty()) {
- const char* key = CM_NULLPTR;
+ const char* key = nullptr;
switch (this->UpdateType) {
case e_CVS:
key = "CVSCommand";
diff --git a/Source/CTest/cmCTestUpdateHandler.h b/Source/CTest/cmCTestUpdateHandler.h
index 0cd284421..afc0e3d80 100644
--- a/Source/CTest/cmCTestUpdateHandler.h
+++ b/Source/CTest/cmCTestUpdateHandler.h
@@ -3,14 +3,14 @@
#ifndef cmCTestUpdateHandler_h
#define cmCTestUpdateHandler_h
-#include "cmConfigure.h"
-
-#include "cmCTestGenericHandler.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <utility>
#include <vector>
+#include "cmCTestGenericHandler.h"
+
/** \class cmCTestUpdateHandler
* \brief A class that handles ctest -S invocations
*
@@ -18,12 +18,12 @@
class cmCTestUpdateHandler : public cmCTestGenericHandler
{
public:
- typedef cmCTestGenericHandler Superclass;
+ using Superclass = cmCTestGenericHandler;
/*
* The main entry point for this class
*/
- int ProcessHandler() CM_OVERRIDE;
+ int ProcessHandler() override;
cmCTestUpdateHandler();
@@ -42,7 +42,7 @@ public:
/**
* Initialize handler
*/
- void Initialize() CM_OVERRIDE;
+ void Initialize() override;
private:
// Some structures needed for update
diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx
index 717117a5f..d0e3848a0 100644
--- a/Source/CTest/cmCTestUploadCommand.cxx
+++ b/Source/CTest/cmCTestUploadCommand.cxx
@@ -2,67 +2,46 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestUploadCommand.h"
+#include <set>
#include <sstream>
#include <vector>
+#include "cm_static_string_view.hxx"
+
+#include "cmAlgorithms.h"
#include "cmCTest.h"
-#include "cmCTestGenericHandler.h"
#include "cmCTestUploadHandler.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler()
+void cmCTestUploadCommand::BindArguments()
{
- cmCTestGenericHandler* handler =
- this->CTest->GetInitializedHandler("upload");
- if (!handler) {
- this->SetError("internal CTest error. Cannot instantiate upload handler");
- return CM_NULLPTR;
- }
- static_cast<cmCTestUploadHandler*>(handler)->SetFiles(this->Files);
-
- handler->SetQuiet(this->Quiet);
- return handler;
+ this->Bind("FILES"_s, this->Files);
+ this->Bind("QUIET"_s, this->Quiet);
+ this->Bind("CAPTURE_CMAKE_ERROR"_s, this->CaptureCMakeError);
}
-bool cmCTestUploadCommand::CheckArgumentKeyword(std::string const& arg)
+void cmCTestUploadCommand::CheckArguments(std::vector<std::string> const&)
{
- if (arg == "FILES") {
- this->ArgumentDoing = ArgumentDoingFiles;
- return true;
- }
- if (arg == "QUIET") {
- this->ArgumentDoing = ArgumentDoingNone;
- this->Quiet = true;
- return true;
- }
- if (arg == "CAPTURE_CMAKE_ERROR") {
- this->ArgumentDoing = ArgumentDoingCaptureCMakeError;
- return true;
- }
- return false;
-}
-
-bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
-{
- if (this->ArgumentDoing == ArgumentDoingCaptureCMakeError) {
- this->Values[ct_CAPTURE_CMAKE_ERROR] = arg.c_str();
- return true;
- }
- if (this->ArgumentDoing == ArgumentDoingFiles) {
- if (cmSystemTools::FileExists(arg.c_str())) {
- this->Files.insert(arg);
+ cmEraseIf(this->Files, [this](std::string const& arg) -> bool {
+ if (!cmSystemTools::FileExists(arg)) {
+ std::ostringstream e;
+ e << "File \"" << arg << "\" does not exist. Cannot submit "
+ << "a non-existent file.";
+ this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
return true;
}
- std::ostringstream e;
- e << "File \"" << arg << "\" does not exist. Cannot submit "
- << "a non-existent file.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
- this->ArgumentDoing = ArgumentDoingError;
return false;
- }
+ });
+}
- // Look for other arguments.
- return this->Superclass::CheckArgumentValue(arg);
+cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler()
+{
+ cmCTestUploadHandler* handler = this->CTest->GetUploadHandler();
+ handler->Initialize();
+ handler->SetFiles(
+ std::set<std::string>(this->Files.begin(), this->Files.end()));
+ handler->SetQuiet(this->Quiet);
+ return handler;
}
diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h
index 6e721796a..8334a9e08 100644
--- a/Source/CTest/cmCTestUploadCommand.h
+++ b/Source/CTest/cmCTestUploadCommand.h
@@ -3,15 +3,18 @@
#ifndef cmCTestUploadCommand_h
#define cmCTestUploadCommand_h
-#include "cmConfigure.h"
-
-#include "cmCTest.h"
-#include "cmCTestHandlerCommand.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <utility>
+#include <vector>
+
+#include <cm/memory>
+
+#include "cmCTestHandlerCommand.h"
+#include "cmCommand.h"
class cmCTestGenericHandler;
-class cmCommand;
/** \class cmCTestUpload
* \brief Run a ctest script
@@ -22,40 +25,28 @@ class cmCommand;
class cmCTestUploadCommand : public cmCTestHandlerCommand
{
public:
- cmCTestUploadCommand() {}
-
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE
+ std::unique_ptr<cmCommand> Clone() override
{
- cmCTestUploadCommand* ni = new cmCTestUploadCommand;
+ auto ni = cm::make_unique<cmCTestUploadCommand>();
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
- return ni;
+ return std::unique_ptr<cmCommand>(std::move(ni));
}
/**
* The name of the command as specified in CMakeList.txt.
*/
- std::string GetName() const CM_OVERRIDE { return "ctest_upload"; }
-
- typedef cmCTestHandlerCommand Superclass;
+ std::string GetName() const override { return "ctest_upload"; }
protected:
- cmCTestGenericHandler* InitializeHandler() CM_OVERRIDE;
-
- bool CheckArgumentKeyword(std::string const& arg) CM_OVERRIDE;
- bool CheckArgumentValue(std::string const& arg) CM_OVERRIDE;
-
- enum
- {
- ArgumentDoingFiles = Superclass::ArgumentDoingLast1,
- ArgumentDoingCaptureCMakeError,
- ArgumentDoingLast2
- };
+ void BindArguments() override;
+ void CheckArguments(std::vector<std::string> const&) override;
+ cmCTestGenericHandler* InitializeHandler() override;
- cmCTest::SetOfStrings Files;
+ std::vector<std::string> Files;
};
#endif
diff --git a/Source/CTest/cmCTestUploadHandler.cxx b/Source/CTest/cmCTestUploadHandler.cxx
index 05a39840d..9d92aad03 100644
--- a/Source/CTest/cmCTestUploadHandler.cxx
+++ b/Source/CTest/cmCTestUploadHandler.cxx
@@ -2,14 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestUploadHandler.h"
+#include <ostream>
+#include <string>
+
+#include "cmCTest.h"
#include "cmGeneratedFileStream.h"
#include "cmVersion.h"
#include "cmXMLWriter.h"
-#include <ostream>
-#include <set>
-#include <string>
-
cmCTestUploadHandler::cmCTestUploadHandler()
{
this->Initialize();
@@ -21,7 +21,7 @@ void cmCTestUploadHandler::Initialize()
this->Files.clear();
}
-void cmCTestUploadHandler::SetFiles(const cmCTest::SetOfStrings& files)
+void cmCTestUploadHandler::SetFiles(std::set<std::string> const& files)
{
this->Files = files;
}
@@ -31,13 +31,12 @@ int cmCTestUploadHandler::ProcessHandler()
cmGeneratedFileStream ofs;
if (!this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), "Upload.xml",
ofs)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open Upload.xml file"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot open Upload.xml file" << std::endl);
return -1;
}
std::string buildname =
cmCTest::SafeBuildIdField(this->CTest->GetCTestConfiguration("BuildName"));
- cmCTest::SetOfStrings::const_iterator it;
cmXMLWriter xml(ofs);
xml.StartDocument();
@@ -47,22 +46,23 @@ int cmCTestUploadHandler::ProcessHandler()
"<file:///Dart/Source/Server/XSL/Build.xsl> \"");
xml.StartElement("Site");
xml.Attribute("BuildName", buildname);
- xml.Attribute("BuildStamp", this->CTest->GetCurrentTag() + "-" +
+ xml.Attribute("BuildStamp",
+ this->CTest->GetCurrentTag() + "-" +
this->CTest->GetTestModelString());
xml.Attribute("Name", this->CTest->GetCTestConfiguration("Site"));
xml.Attribute("Generator",
- std::string("ctest") + cmVersion::GetCMakeVersion());
+ std::string("ctest-") + cmVersion::GetCMakeVersion());
this->CTest->AddSiteProperties(xml);
xml.StartElement("Upload");
- for (it = this->Files.begin(); it != this->Files.end(); it++) {
+ for (std::string const& file : this->Files) {
cmCTestOptionalLog(this->CTest, OUTPUT,
- "\tUpload file: " << *it << std::endl, this->Quiet);
+ "\tUpload file: " << file << std::endl, this->Quiet);
xml.StartElement("File");
- xml.Attribute("filename", *it);
+ xml.Attribute("filename", file);
xml.StartElement("Content");
xml.Attribute("encoding", "base64");
- xml.Content(this->CTest->Base64EncodeFile(*it));
+ xml.Content(this->CTest->Base64EncodeFile(file));
xml.EndElement(); // Content
xml.EndElement(); // File
}
diff --git a/Source/CTest/cmCTestUploadHandler.h b/Source/CTest/cmCTestUploadHandler.h
index 1e8d3c801..dde14df16 100644
--- a/Source/CTest/cmCTestUploadHandler.h
+++ b/Source/CTest/cmCTestUploadHandler.h
@@ -3,9 +3,11 @@
#ifndef cmCTestUploadHandler_h
#define cmCTestUploadHandler_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <set>
+#include <string>
-#include "cmCTest.h"
#include "cmCTestGenericHandler.h"
/** \class cmCTestUploadHandler
@@ -17,23 +19,22 @@
class cmCTestUploadHandler : public cmCTestGenericHandler
{
public:
- typedef cmCTestGenericHandler Superclass;
+ using Superclass = cmCTestGenericHandler;
cmCTestUploadHandler();
- ~cmCTestUploadHandler() CM_OVERRIDE {}
/*
* The main entry point for this class
*/
- int ProcessHandler() CM_OVERRIDE;
+ int ProcessHandler() override;
- void Initialize() CM_OVERRIDE;
+ void Initialize() override;
/** Specify a set of files to submit. */
- void SetFiles(cmCTest::SetOfStrings const& files);
+ void SetFiles(std::set<std::string> const& files);
private:
- cmCTest::SetOfStrings Files;
+ std::set<std::string> Files;
};
#endif
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index fb2742e08..6026c69bb 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -2,16 +2,18 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestVC.h"
+#include <cstdio>
+#include <ctime>
+#include <sstream>
+#include <vector>
+
+#include "cmsys/Process.h"
+
#include "cmCTest.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
-#include "cmsys/Process.h"
-#include <sstream>
-#include <stdio.h>
-#include <time.h>
-#include <vector>
-
cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log)
: CTest(ct)
, Log(log)
@@ -24,9 +26,7 @@ cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log)
this->Unknown.Rev = "Unknown";
}
-cmCTestVC::~cmCTestVC()
-{
-}
+cmCTestVC::~cmCTestVC() = default;
void cmCTestVC::SetCommandLineTool(std::string const& tool)
{
@@ -47,7 +47,7 @@ bool cmCTestVC::InitialCheckout(const char* command)
std::string parent = cmSystemTools::GetFilenamePath(this->SourceDirectory);
cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Perform checkout in directory: " << parent << "\n");
- if (!cmSystemTools::MakeDirectory(parent.c_str())) {
+ if (!cmSystemTools::MakeDirectory(parent)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot create directory: " << parent << std::endl);
return false;
@@ -56,11 +56,11 @@ bool cmCTestVC::InitialCheckout(const char* command)
// Construct the initial checkout command line.
std::vector<std::string> args = cmSystemTools::ParseArguments(command);
std::vector<char const*> vc_co;
- for (std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai) {
- vc_co.push_back(ai->c_str());
+ vc_co.reserve(args.size() + 1);
+ for (std::string const& arg : args) {
+ vc_co.push_back(arg.c_str());
}
- vc_co.push_back(CM_NULLPTR);
+ vc_co.push_back(nullptr);
// Run the initial checkout command and log its output.
this->Log << "--- Begin Initial Checkout ---\n";
@@ -69,8 +69,8 @@ bool cmCTestVC::InitialCheckout(const char* command)
bool result = this->RunChild(&vc_co[0], &out, &err, parent.c_str());
this->Log << "--- End Initial Checkout ---\n";
if (!result) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Initial checkout failed!"
- << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Initial checkout failed!" << std::endl);
}
return result;
}
@@ -79,13 +79,13 @@ bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out,
OutputParser* err, const char* workDir,
Encoding encoding)
{
- this->Log << this->ComputeCommandLine(cmd) << "\n";
+ this->Log << cmCTestVC::ComputeCommandLine(cmd) << "\n";
cmsysProcess* cp = cmsysProcess_New();
cmsysProcess_SetCommand(cp, cmd);
workDir = workDir ? workDir : this->SourceDirectory.c_str();
cmsysProcess_SetWorkingDirectory(cp, workDir);
- this->RunProcess(cp, out, err, encoding);
+ cmCTestVC::RunProcess(cp, out, err, encoding);
int result = cmsysProcess_GetExitValue(cp);
cmsysProcess_Delete(cp);
return result == 0;
@@ -113,7 +113,7 @@ bool cmCTestVC::RunUpdateCommand(char const* const* cmd, OutputParser* out,
}
// Run the command.
- return this->RunChild(cmd, out, err, CM_NULLPTR, encoding);
+ return this->RunChild(cmd, out, err, nullptr, encoding);
}
std::string cmCTestVC::GetNightlyTime()
@@ -143,10 +143,18 @@ void cmCTestVC::CleanupImpl()
bool cmCTestVC::Update()
{
bool result = true;
+
+ // Use the explicitly specified version.
+ std::string versionOverride =
+ this->CTest->GetCTestConfiguration("UpdateVersionOverride");
+ if (!versionOverride.empty()) {
+ this->SetNewRevision(versionOverride);
+ return true;
+ }
+
// if update version only is on then do not actually update,
// just note the current version and finish
- if (!cmSystemTools::IsOn(
- this->CTest->GetCTestConfiguration("UpdateVersionOnly").c_str())) {
+ if (!cmIsOn(this->CTest->GetCTestConfiguration("UpdateVersionOnly"))) {
result = this->NoteOldRevision() && result;
this->Log << "--- Begin Update ---\n";
result = this->UpdateImpl() && result;
@@ -168,6 +176,11 @@ bool cmCTestVC::NoteNewRevision()
return true;
}
+void cmCTestVC::SetNewRevision(std::string const& /*unused*/)
+{
+ // We do nothing by default.
+}
+
bool cmCTestVC::UpdateImpl()
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
diff --git a/Source/CTest/cmCTestVC.h b/Source/CTest/cmCTestVC.h
index 6400bcda3..2a4765d28 100644
--- a/Source/CTest/cmCTestVC.h
+++ b/Source/CTest/cmCTestVC.h
@@ -3,7 +3,7 @@
#ifndef cmCTestVC_h
#define cmCTestVC_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
@@ -70,6 +70,7 @@ protected:
virtual bool NoteOldRevision();
virtual bool UpdateImpl();
virtual bool NoteNewRevision();
+ virtual void SetNewRevision(std::string const& revision);
virtual bool WriteXMLUpdates(cmXMLWriter& xml);
#if defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x510
@@ -100,8 +101,8 @@ protected:
Revision const* PriorRev;
File()
: Status(PathUpdated)
- , Rev(CM_NULLPTR)
- , PriorRev(CM_NULLPTR)
+ , Rev(nullptr)
+ , PriorRev(nullptr)
{
}
File(PathStatus status, Revision const* rev, Revision const* priorRev)
@@ -117,12 +118,12 @@ protected:
/** Run a command line and send output to given parsers. */
bool RunChild(char const* const* cmd, OutputParser* out, OutputParser* err,
- const char* workDir = CM_NULLPTR,
+ const char* workDir = nullptr,
Encoding encoding = cmProcessOutput::Auto);
/** Run VC update command line and send output to given parsers. */
bool RunUpdateCommand(char const* const* cmd, OutputParser* out,
- OutputParser* err = CM_NULLPTR,
+ OutputParser* err = nullptr,
Encoding encoding = cmProcessOutput::Auto);
/** Write xml element for one file. */
diff --git a/Source/CTest/cmParseBlanketJSCoverage.cxx b/Source/CTest/cmParseBlanketJSCoverage.cxx
index 83a7b75eb..409025f80 100644
--- a/Source/CTest/cmParseBlanketJSCoverage.cxx
+++ b/Source/CTest/cmParseBlanketJSCoverage.cxx
@@ -2,25 +2,26 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmParseBlanketJSCoverage.h"
+#include <cstdio>
+#include <cstdlib>
+
+#include "cmsys/FStream.hxx"
+
#include "cmCTest.h"
#include "cmCTestCoverageHandler.h"
#include "cmSystemTools.h"
-#include "cmsys/FStream.hxx"
-#include <stdio.h>
-#include <stdlib.h>
-
class cmParseBlanketJSCoverage::JSONParser
{
public:
- typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
- FileLinesType;
+ using FileLinesType =
+ cmCTestCoverageHandlerContainer::SingleFileCoverageVector;
JSONParser(cmCTestCoverageHandlerContainer& cont)
: Coverage(cont)
{
}
- virtual ~JSONParser() {}
+ virtual ~JSONParser() = default;
std::string getValue(std::string const& line, int type)
{
@@ -110,19 +111,18 @@ cmParseBlanketJSCoverage::cmParseBlanketJSCoverage(
{
}
-bool cmParseBlanketJSCoverage::LoadCoverageData(std::vector<std::string> files)
+bool cmParseBlanketJSCoverage::LoadCoverageData(
+ std::vector<std::string> const& files)
{
- size_t i = 0;
- std::string path;
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Found " << files.size() << " Files" << std::endl,
this->Coverage.Quiet);
- for (i = 0; i < files.size(); i++) {
+ for (std::string const& file : files) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Reading JSON File " << files[i] << std::endl,
+ "Reading JSON File " << file << std::endl,
this->Coverage.Quiet);
- if (!this->ReadJSONFile(files[i])) {
+ if (!this->ReadJSONFile(file)) {
return false;
}
}
diff --git a/Source/CTest/cmParseBlanketJSCoverage.h b/Source/CTest/cmParseBlanketJSCoverage.h
index 696121f21..cd1b225e5 100644
--- a/Source/CTest/cmParseBlanketJSCoverage.h
+++ b/Source/CTest/cmParseBlanketJSCoverage.h
@@ -29,7 +29,7 @@ class cmParseBlanketJSCoverage
public:
cmParseBlanketJSCoverage(cmCTestCoverageHandlerContainer& cont,
cmCTest* ctest);
- bool LoadCoverageData(std::vector<std::string> files);
+ bool LoadCoverageData(std::vector<std::string> const& files);
// Read the JSON output
bool ReadJSONFile(std::string const& file);
diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx
index 629010cf1..8c4da7577 100644
--- a/Source/CTest/cmParseCacheCoverage.cxx
+++ b/Source/CTest/cmParseCacheCoverage.cxx
@@ -1,15 +1,17 @@
#include "cmParseCacheCoverage.h"
-#include "cmCTest.h"
-#include "cmCTestCoverageHandler.h"
-#include "cmSystemTools.h"
+#include <cstdio>
+#include <cstdlib>
+#include <map>
+#include <utility>
#include "cmsys/Directory.hxx"
#include "cmsys/FStream.hxx"
-#include <map>
-#include <stdio.h>
-#include <stdlib.h>
-#include <utility>
+
+#include "cmCTest.h"
+#include "cmCTestCoverageHandler.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
cmParseCacheCoverage::cmParseCacheCoverage(
cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
@@ -30,9 +32,7 @@ bool cmParseCacheCoverage::LoadCoverageData(const char* d)
for (i = 0; i < numf; i++) {
std::string file = dir.GetFile(i);
if (file != "." && file != ".." && !cmSystemTools::FileIsDirectory(file)) {
- std::string path = d;
- path += "/";
- path += file;
+ std::string path = cmStrCat(d, '/', file);
if (cmSystemTools::GetFilenameLastExtension(path) == ".cmcov") {
if (!this->ReadCMCovFile(path.c_str())) {
return false;
@@ -48,15 +48,12 @@ void cmParseCacheCoverage::RemoveUnCoveredFiles()
{
// loop over the coverage data computed and remove all files
// that only have -1 or 0 for the lines.
- cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator ci =
- this->Coverage.TotalCoverage.begin();
+ auto ci = this->Coverage.TotalCoverage.begin();
while (ci != this->Coverage.TotalCoverage.end()) {
cmCTestCoverageHandlerContainer::SingleFileCoverageVector& v = ci->second;
bool nothing = true;
- for (cmCTestCoverageHandlerContainer::SingleFileCoverageVector::iterator
- i = v.begin();
- i != v.end(); ++i) {
- if (*i > 0) {
+ for (int i : v) {
+ if (i > 0) {
nothing = false;
break;
}
@@ -102,10 +99,11 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
std::string line;
std::vector<std::string> separateLine;
if (!cmSystemTools::GetLineFromStream(in, line)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Empty file : "
- << file << " referenced in this line of cmcov data:\n"
- "["
- << line << "]\n");
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Empty file : " << file
+ << " referenced in this line of cmcov data:\n"
+ "["
+ << line << "]\n");
return false;
}
separateLine.clear();
@@ -114,8 +112,9 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
separateLine[1] != "Line" || separateLine[2] != "RtnLine" ||
separateLine[3] != "Code") {
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Bad first line of cmcov file : " << file << " line:\n"
- "["
+ "Bad first line of cmcov file : " << file
+ << " line:\n"
+ "["
<< line << "]\n");
}
std::string routine;
@@ -130,8 +129,9 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
if (separateLine.size() < 4) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Bad line of cmcov file expected at least 4 found: "
- << separateLine.size() << " " << file << " line:\n"
- "["
+ << separateLine.size() << " " << file
+ << " line:\n"
+ "["
<< line << "]\n");
for (std::string::size_type i = 0; i < separateLine.size(); ++i) {
cmCTestLog(this->CTest, ERROR_MESSAGE, "" << separateLine[1] << " ");
@@ -148,7 +148,7 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Could not find mumps file for routine: " << routine
<< "\n");
- filepath = "";
+ filepath.clear();
continue; // move to next line
}
}
@@ -156,8 +156,8 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
else {
// Totals in arg 0 marks the end of a routine
if (separateLine[0].substr(0, 6) == "Totals") {
- routine = ""; // at the end of this routine
- filepath = "";
+ routine.clear(); // at the end of this routine
+ filepath.clear();
continue; // move to next line
}
}
diff --git a/Source/CTest/cmParseCacheCoverage.h b/Source/CTest/cmParseCacheCoverage.h
index 005d27258..e89b9e454 100644
--- a/Source/CTest/cmParseCacheCoverage.h
+++ b/Source/CTest/cmParseCacheCoverage.h
@@ -3,13 +3,13 @@
#ifndef cmParseCacheCoverage_h
#define cmParseCacheCoverage_h
-#include "cmConfigure.h"
-
-#include "cmParseMumpsCoverage.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
+#include "cmParseMumpsCoverage.h"
+
class cmCTest;
class cmCTestCoverageHandlerContainer;
@@ -26,7 +26,7 @@ public:
protected:
// implement virtual from parent
- bool LoadCoverageData(const char* dir) CM_OVERRIDE;
+ bool LoadCoverageData(const char* dir) override;
// remove files with no coverage
void RemoveUnCoveredFiles();
// Read a single mcov file
diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx
index ba55cd7b2..05da84e2e 100644
--- a/Source/CTest/cmParseCoberturaCoverage.cxx
+++ b/Source/CTest/cmParseCoberturaCoverage.cxx
@@ -1,34 +1,28 @@
#include "cmParseCoberturaCoverage.h"
+#include <cstdlib>
+#include <cstring>
+
+#include "cmsys/FStream.hxx"
+
#include "cmCTest.h"
#include "cmCTestCoverageHandler.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmXMLParser.h"
-#include "cmConfigure.h"
-#include "cmsys/FStream.hxx"
-#include <stdlib.h>
-#include <string.h>
-
class cmParseCoberturaCoverage::XMLParser : public cmXMLParser
{
public:
XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
- : CTest(ctest)
+ : FilePaths{ cont.SourceDir, cont.BinaryDir }
+ , CTest(ctest)
, Coverage(cont)
{
- this->InSources = false;
- this->InSource = false;
- this->SkipThisClass = false;
- this->FilePaths.push_back(this->Coverage.SourceDir);
- this->FilePaths.push_back(this->Coverage.BinaryDir);
- this->CurFileName = "";
}
- ~XMLParser() CM_OVERRIDE {}
-
protected:
- void EndElement(const std::string& name) CM_OVERRIDE
+ void EndElement(const std::string& name) override
{
if (name == "source") {
this->InSource = false;
@@ -39,7 +33,7 @@ protected:
}
}
- void CharacterDataHandler(const char* data, int length) CM_OVERRIDE
+ void CharacterDataHandler(const char* data, int length) override
{
std::string tmp;
tmp.insert(0, data, length);
@@ -51,7 +45,7 @@ protected:
}
}
- void StartElement(const std::string& name, const char** atts) CM_OVERRIDE
+ void StartElement(const std::string& name, const char** atts) override
{
std::string FoundSource;
std::string finalpath;
@@ -68,23 +62,23 @@ protected:
<< std::endl,
this->Coverage.Quiet);
std::string filename = atts[tagCount + 1];
- this->CurFileName = "";
+ this->CurFileName.clear();
// Check if this is an absolute path that falls within our
// source or binary directories.
- for (size_t i = 0; i < FilePaths.size(); i++) {
- if (filename.find(FilePaths[i]) == 0) {
+ for (std::string const& filePath : FilePaths) {
+ if (filename.find(filePath) == 0) {
this->CurFileName = filename;
break;
}
}
- if (this->CurFileName == "") {
+ if (this->CurFileName.empty()) {
// Check if this is a path that is relative to our source or
// binary directories.
- for (size_t i = 0; i < FilePaths.size(); i++) {
- finalpath = FilePaths[i] + "/" + filename;
- if (cmSystemTools::FileExists(finalpath.c_str())) {
+ for (std::string const& filePath : FilePaths) {
+ finalpath = cmStrCat(filePath, "/", filename);
+ if (cmSystemTools::FileExists(finalpath)) {
this->CurFileName = finalpath;
break;
}
@@ -92,9 +86,9 @@ protected:
}
cmsys::ifstream fin(this->CurFileName.c_str());
- if (this->CurFileName == "" || !fin) {
+ if (this->CurFileName.empty() || !fin) {
this->CurFileName =
- this->Coverage.BinaryDir + "/" + atts[tagCount + 1];
+ cmStrCat(this->Coverage.BinaryDir, "/", atts[tagCount + 1]);
fin.open(this->CurFileName.c_str());
if (!fin) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -145,12 +139,12 @@ protected:
}
private:
- bool InSources;
- bool InSource;
- bool SkipThisClass;
+ bool InSources = false;
+ bool InSource = false;
+ bool SkipThisClass = false;
std::vector<std::string> FilePaths;
- typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
- FileLinesType;
+ using FileLinesType =
+ cmCTestCoverageHandlerContainer::SingleFileCoverageVector;
cmCTest* CTest;
cmCTestCoverageHandlerContainer& Coverage;
std::string CurFileName;
diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx
index 4b781a6db..016e90c02 100644
--- a/Source/CTest/cmParseDelphiCoverage.cxx
+++ b/Source/CTest/cmParseDelphiCoverage.cxx
@@ -1,26 +1,27 @@
#include "cmParseDelphiCoverage.h"
-#include "cmCTest.h"
-#include "cmCTestCoverageHandler.h"
-#include "cmSystemTools.h"
+#include <cstdio>
+#include <cstdlib>
#include "cmsys/FStream.hxx"
#include "cmsys/Glob.hxx"
-#include <stdio.h>
-#include <stdlib.h>
+
+#include "cmCTest.h"
+#include "cmCTestCoverageHandler.h"
+#include "cmSystemTools.h"
class cmParseDelphiCoverage::HTMLParser
{
public:
- typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
- FileLinesType;
+ using FileLinesType =
+ cmCTestCoverageHandlerContainer::SingleFileCoverageVector;
HTMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
: CTest(ctest)
, Coverage(cont)
{
}
- virtual ~HTMLParser() {}
+ virtual ~HTMLParser() = default;
bool initializeDelphiFile(
std::string const& filename,
@@ -44,7 +45,7 @@ public:
// Check that the begin is the first non-space string on the line
if ((beginPos == line.find_first_not_of(' ')) &&
beginPos != std::string::npos) {
- beginSet.push_back("begin");
+ beginSet.emplace_back("begin");
coverageVector.push_back(-1);
continue;
}
@@ -71,7 +72,8 @@ public:
}
}
// Based up what was found, add a line to the coverageVector
- if (!beginSet.empty() && line != "" && !blockComFlag && !lineComFlag) {
+ if (!beginSet.empty() && !line.empty() && !blockComFlag &&
+ !lineComFlag) {
coverageVector.push_back(0);
} else {
coverageVector.push_back(-1);
@@ -107,8 +109,9 @@ public:
while (true) {
lastoffset = line.find('(', pos);
if (lastoffset == std::string::npos) {
- cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, endnamepos
- << "File not found " << lastoffset << std::endl,
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ endnamepos << "File not found " << lastoffset
+ << std::endl,
this->Coverage.Quiet);
return false;
}
diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx
index e4ee699c4..1dc5b7038 100644
--- a/Source/CTest/cmParseGTMCoverage.cxx
+++ b/Source/CTest/cmParseGTMCoverage.cxx
@@ -1,15 +1,17 @@
#include "cmParseGTMCoverage.h"
-#include "cmCTest.h"
-#include "cmCTestCoverageHandler.h"
-#include "cmSystemTools.h"
+#include <cstdio>
+#include <cstdlib>
+#include <map>
+#include <vector>
#include "cmsys/Directory.hxx"
#include "cmsys/FStream.hxx"
-#include <map>
-#include <stdio.h>
-#include <stdlib.h>
-#include <vector>
+
+#include "cmCTest.h"
+#include "cmCTestCoverageHandler.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
cmParseGTMCoverage::cmParseGTMCoverage(cmCTestCoverageHandlerContainer& cont,
cmCTest* ctest)
@@ -30,9 +32,7 @@ bool cmParseGTMCoverage::LoadCoverageData(const char* d)
for (i = 0; i < numf; i++) {
std::string file = dir.GetFile(i);
if (file != "." && file != ".." && !cmSystemTools::FileIsDirectory(file)) {
- std::string path = d;
- path += "/";
- path += file;
+ std::string path = cmStrCat(d, '/', file);
if (cmSystemTools::GetFilenameLastExtension(path) == ".mcov") {
if (!this->ReadMCovFile(path.c_str())) {
return false;
@@ -75,7 +75,8 @@ bool cmParseGTMCoverage::ReadMCovFile(const char* file)
this->Coverage.TotalCoverage[lastpath][lastoffset + linenumber] +=
count;
} else {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Can not find mumps file : "
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Can not find mumps file : "
<< lastroutine
<< " referenced in this line of mcov data:\n"
"["
@@ -85,6 +86,10 @@ bool cmParseGTMCoverage::ReadMCovFile(const char* file)
}
// Find the full path to the file
bool found = this->FindMumpsFile(routine, filepath);
+ if (!found && cmHasLiteralSuffix(routine, "%")) {
+ routine.erase(0, 1);
+ found = this->FindMumpsFile(routine, filepath);
+ }
if (found) {
int lineoffset = 0;
if (this->FindFunctionInMumpsFile(filepath, function, lineoffset)) {
@@ -93,7 +98,7 @@ bool cmParseGTMCoverage::ReadMCovFile(const char* file)
// This section accounts for lines that were previously marked
// as non-executable code (-1), if the parser comes back with
// a non-zero count, increase the count by 1 to push the line
- // into the executable code set in addtion to the count found.
+ // into the executable code set in addition to the count found.
if (coverageVector[lineoffset + linenumber] == -1 && count > 0) {
coverageVector[lineoffset + linenumber] += count + 1;
} else {
@@ -102,9 +107,11 @@ bool cmParseGTMCoverage::ReadMCovFile(const char* file)
lastoffset = lineoffset;
}
} else {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Can not find mumps file : "
- << routine << " referenced in this line of mcov data:\n"
- "["
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Can not find mumps file : "
+ << routine
+ << " referenced in this line of mcov data:\n"
+ "["
<< line << "]\n");
}
lastfunction = function;
@@ -144,8 +151,9 @@ bool cmParseGTMCoverage::FindFunctionInMumpsFile(std::string const& filepath,
linenum++; // move to next line count
}
lineoffset = 0;
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Could not find entry point : "
- << function << " in " << filepath << "\n");
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Could not find entry point : " << function << " in " << filepath
+ << "\n");
return false;
}
@@ -156,7 +164,7 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line,
{
// this method parses lines from the .mcov file
// each line has ^COVERAGE(...) in it, and there
- // are several varients of coverage lines:
+ // are several variants of coverage lines:
//
// ^COVERAGE("DIC11","PR1",0)="2:0:0:0"
// ( file , entry, line ) = "number_executed:timing_info"
@@ -182,14 +190,14 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line,
// save the argument into the argument vector
args.push_back(arg);
// start on a new argument
- arg = "";
+ arg.clear();
// if we are at the end of the ), then finish while loop
if (cur == ')') {
done = true;
}
} else {
- // all chars except ", (, and % get stored in the arg string
- if (cur != '\"' && cur != '(' && cur != '%') {
+ // all chars except " and ( get stored in the arg string
+ if (cur != '\"' && cur != '(') {
arg.append(1, line[pos]);
}
}
@@ -221,8 +229,8 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line,
}
// less then two arguments is an error
if (args.size() < 2) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing mcov line: ["
- << line << "]\n");
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Error parsing mcov line: [" << line << "]\n");
return false;
}
routine = args[0]; // the routine is the first argument
@@ -233,8 +241,8 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line,
// To avoid double counting of line 0 of each entry point,
// Don't count the lines that do not give an explicit line
// number.
- routine = "";
- function = "";
+ routine.clear();
+ function.clear();
} else {
// this is the format for this line
// ^COVERAGE("%RSEL","SRC",count)
diff --git a/Source/CTest/cmParseGTMCoverage.h b/Source/CTest/cmParseGTMCoverage.h
index c4949d416..fe0ae0bfd 100644
--- a/Source/CTest/cmParseGTMCoverage.h
+++ b/Source/CTest/cmParseGTMCoverage.h
@@ -3,12 +3,12 @@
#ifndef cmParseGTMCoverage_h
#define cmParseGTMCoverage_h
-#include "cmConfigure.h"
-
-#include "cmParseMumpsCoverage.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include "cmParseMumpsCoverage.h"
+
class cmCTest;
class cmCTestCoverageHandlerContainer;
@@ -25,7 +25,7 @@ public:
protected:
// implement virtual from parent
- bool LoadCoverageData(const char* dir) CM_OVERRIDE;
+ bool LoadCoverageData(const char* dir) override;
// Read a single mcov file
bool ReadMCovFile(const char* f);
// find out what line in a mumps file (filepath) the given entry point
diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx
index d15864a79..9cf30dfcb 100644
--- a/Source/CTest/cmParseJacocoCoverage.cxx
+++ b/Source/CTest/cmParseJacocoCoverage.cxx
@@ -1,18 +1,18 @@
#include "cmParseJacocoCoverage.h"
-#include "cmConfigure.h"
+#include <cstdlib>
+#include <cstring>
+
+#include "cmsys/Directory.hxx"
+#include "cmsys/FStream.hxx"
+#include "cmsys/Glob.hxx"
#include "cmCTest.h"
#include "cmCTestCoverageHandler.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmXMLParser.h"
-#include "cmsys/Directory.hxx"
-#include "cmsys/FStream.hxx"
-#include "cmsys/Glob.hxx"
-#include <stdlib.h>
-#include <string.h>
-
class cmParseJacocoCoverage::XMLParser : public cmXMLParser
{
public:
@@ -20,28 +20,25 @@ public:
: CTest(ctest)
, Coverage(cont)
{
- this->FilePath = "";
- this->PackagePath = "";
- this->PackageName = "";
}
- ~XMLParser() CM_OVERRIDE {}
-
protected:
- void EndElement(const std::string& /*name*/) CM_OVERRIDE {}
+ void EndElement(const std::string& /*name*/) override {}
- void StartElement(const std::string& name, const char** atts) CM_OVERRIDE
+ void StartElement(const std::string& name, const char** atts) override
{
if (name == "package") {
this->PackageName = atts[1];
- this->PackagePath = "";
+ this->PackagePath.clear();
} else if (name == "sourcefile") {
+ this->FilePath.clear();
std::string fileName = atts[1];
- if (this->PackagePath == "") {
+ if (this->PackagePath.empty()) {
if (!this->FindPackagePath(fileName)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: "
- << this->PackageName << "/" << fileName << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Cannot find file: " << this->PackageName << "/"
+ << fileName << std::endl);
this->Coverage.Error++;
return;
}
@@ -108,9 +105,7 @@ protected:
std::string const& baseDir)
{
// Search for the file in the baseDir and its subdirectories.
- std::string packageGlob = baseDir;
- packageGlob += "/";
- packageGlob += fileName;
+ std::string packageGlob = cmStrCat(baseDir, '/', fileName);
cmsys::Glob gl;
gl.RecurseOn();
gl.RecurseThroughSymlinksOn();
@@ -121,10 +116,9 @@ protected:
}
// Check if any of the locations found match our package.
- for (std::vector<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
- std::string dir = cmsys::SystemTools::GetParentDirectory(*fi);
- if (cmsys::SystemTools::StringEndsWith(dir, this->PackageName.c_str())) {
+ for (std::string const& f : files) {
+ std::string dir = cmsys::SystemTools::GetParentDirectory(f);
+ if (cmHasSuffix(dir, this->PackageName)) {
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Found package directory for " << fileName << ": "
<< dir << std::endl,
@@ -140,8 +134,8 @@ private:
std::string FilePath;
std::string PackagePath;
std::string PackageName;
- typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
- FileLinesType;
+ using FileLinesType =
+ cmCTestCoverageHandlerContainer::SingleFileCoverageVector;
cmCTest* CTest;
cmCTestCoverageHandlerContainer& Coverage;
};
diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx
index eb29f55c0..b16f1014a 100644
--- a/Source/CTest/cmParseMumpsCoverage.cxx
+++ b/Source/CTest/cmParseMumpsCoverage.cxx
@@ -1,17 +1,18 @@
#include "cmParseMumpsCoverage.h"
-#include "cmCTest.h"
-#include "cmCTestCoverageHandler.h"
-#include "cmSystemTools.h"
-
-#include "cmConfigure.h"
-#include "cmsys/FStream.hxx"
-#include "cmsys/Glob.hxx"
#include <map>
#include <string>
#include <utility>
#include <vector>
+#include "cmsys/FStream.hxx"
+#include "cmsys/Glob.hxx"
+
+#include "cmCTest.h"
+#include "cmCTestCoverageHandler.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
cmParseMumpsCoverage::cmParseMumpsCoverage(
cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
: Coverage(cont)
@@ -19,9 +20,7 @@ cmParseMumpsCoverage::cmParseMumpsCoverage(
{
}
-cmParseMumpsCoverage::~cmParseMumpsCoverage()
-{
-}
+cmParseMumpsCoverage::~cmParseMumpsCoverage() = default;
bool cmParseMumpsCoverage::ReadCoverageFile(const char* file)
{
@@ -110,17 +109,14 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d)
{
cmsys::Glob glob;
glob.RecurseOn();
- std::string pat = d;
- pat += "/*.m";
+ std::string pat = cmStrCat(d, "/*.m");
glob.FindFiles(pat);
- std::vector<std::string>& files = glob.GetFiles();
- std::vector<std::string>::iterator fileIt;
- for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
- std::string name = cmSystemTools::GetFilenameName(*fileIt);
- this->RoutineToDirectory[name.substr(0, name.size() - 2)] = *fileIt;
- // initialze each file, this is left out until CDash is fixed
+ for (std::string& file : glob.GetFiles()) {
+ std::string name = cmSystemTools::GetFilenameName(file);
+ this->RoutineToDirectory[name.substr(0, name.size() - 2)] = file;
+ // initialize each file, this is left out until CDash is fixed
// to handle large numbers of files
- this->InitializeMumpsFile(*fileIt);
+ this->InitializeMumpsFile(file);
}
return true;
}
@@ -128,15 +124,14 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d)
bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine,
std::string& filepath)
{
- std::map<std::string, std::string>::iterator i =
- this->RoutineToDirectory.find(routine);
+ auto i = this->RoutineToDirectory.find(routine);
if (i != this->RoutineToDirectory.end()) {
filepath = i->second;
return true;
}
// try some alternate names
- const char* tryname[] = { "GUX", "GTM", "ONT", CM_NULLPTR };
- for (int k = 0; tryname[k] != CM_NULLPTR; k++) {
+ const char* tryname[] = { "GUX", "GTM", "ONT", nullptr };
+ for (int k = 0; tryname[k] != nullptr; k++) {
std::string routine2 = routine + tryname[k];
i = this->RoutineToDirectory.find(routine2);
if (i != this->RoutineToDirectory.end()) {
diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx
index 761ebec65..a494b92b9 100644
--- a/Source/CTest/cmParsePHPCoverage.cxx
+++ b/Source/CTest/cmParsePHPCoverage.cxx
@@ -1,13 +1,15 @@
#include "cmParsePHPCoverage.h"
-#include "cmCTest.h"
-#include "cmCTestCoverageHandler.h"
-#include "cmSystemTools.h"
+#include <cstdlib>
+#include <cstring>
#include "cmsys/Directory.hxx"
#include "cmsys/FStream.hxx"
-#include <stdlib.h>
-#include <string.h>
+
+#include "cmCTest.h"
+#include "cmCTestCoverageHandler.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
/*
To setup coverage for php.
@@ -153,7 +155,8 @@ bool cmParsePHPCoverage::ReadFileInformation(std::istream& in)
delete[] s;
// read close quote
if (in.get(c) && c != '"') {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read close quote\n"
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "failed to read close quote\n"
<< "read [" << c << "]\n");
return false;
}
@@ -184,8 +187,8 @@ bool cmParsePHPCoverage::ReadPHPData(const char* file)
}
for (int i = 0; i < size; i++) {
if (!this->ReadFileInformation(in)) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "Failed to read file #" << i
- << "\n");
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Failed to read file #" << i << "\n");
return false;
}
in.get(c);
@@ -209,9 +212,7 @@ bool cmParsePHPCoverage::ReadPHPCoverageDirectory(const char* d)
for (i = 0; i < numf; i++) {
std::string file = dir.GetFile(i);
if (file != "." && file != ".." && !cmSystemTools::FileIsDirectory(file)) {
- std::string path = d;
- path += "/";
- path += file;
+ std::string path = cmStrCat(d, '/', file);
if (!this->ReadPHPData(path.c_str())) {
return false;
}
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index f4ec6da29..87f7147bc 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -2,26 +2,39 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmProcess.h"
-#include "cmConfigure.h"
-#include "cmProcessOutput.h"
-#include "cmSystemTools.h"
+#include <csignal>
#include <iostream>
+#include <string>
-cmProcess::cmProcess()
+#include "cmsys/Process.h"
+
+#include "cmAlgorithms.h"
+#include "cmCTest.h"
+#include "cmCTestRunTest.h"
+#include "cmCTestTestHandler.h"
+#include "cmGetPipes.h"
+#include "cmStringAlgorithms.h"
+#if defined(_WIN32)
+# include "cm_kwiml.h"
+#endif
+#include <utility>
+
+#define CM_PROCESS_BUF_SIZE 65536
+
+cmProcess::cmProcess(cmCTestRunTest& runner)
+ : Runner(runner)
+ , Conv(cmProcessOutput::UTF8, CM_PROCESS_BUF_SIZE)
{
- this->Process = CM_NULLPTR;
- this->Timeout = 0;
- this->TotalTime = 0;
+ this->Timeout = cmDuration::zero();
+ this->TotalTime = cmDuration::zero();
this->ExitValue = 0;
this->Id = 0;
- this->StartTime = 0;
+ this->StartTime = std::chrono::steady_clock::time_point();
}
-cmProcess::~cmProcess()
-{
- cmsysProcess_Delete(this->Process);
-}
-void cmProcess::SetCommand(const char* command)
+cmProcess::~cmProcess() = default;
+
+void cmProcess::SetCommand(std::string const& command)
{
this->Command = command;
}
@@ -31,32 +44,121 @@ void cmProcess::SetCommandArguments(std::vector<std::string> const& args)
this->Arguments = args;
}
-bool cmProcess::StartProcess()
+void cmProcess::SetWorkingDirectory(std::string const& dir)
{
+ this->WorkingDirectory = dir;
+}
+
+bool cmProcess::StartProcess(uv_loop_t& loop, std::vector<size_t>* affinity)
+{
+ this->ProcessState = cmProcess::State::Error;
if (this->Command.empty()) {
return false;
}
- this->StartTime = cmSystemTools::GetTime();
+ this->StartTime = std::chrono::steady_clock::now();
this->ProcessArgs.clear();
// put the command as arg0
this->ProcessArgs.push_back(this->Command.c_str());
// now put the command arguments in
- for (std::vector<std::string>::iterator i = this->Arguments.begin();
- i != this->Arguments.end(); ++i) {
- this->ProcessArgs.push_back(i->c_str());
+ for (std::string const& arg : this->Arguments) {
+ this->ProcessArgs.push_back(arg.c_str());
+ }
+ this->ProcessArgs.push_back(nullptr); // null terminate the list
+
+ cm::uv_timer_ptr timer;
+ int status = timer.init(loop, this);
+ if (status != 0) {
+ cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
+ "Error initializing timer: " << uv_strerror(status)
+ << std::endl);
+ return false;
+ }
+
+ cm::uv_pipe_ptr pipe_writer;
+ cm::uv_pipe_ptr pipe_reader;
+
+ pipe_writer.init(loop, 0);
+ pipe_reader.init(loop, 0, this);
+
+ int fds[2] = { -1, -1 };
+ status = cmGetPipes(fds);
+ if (status != 0) {
+ cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
+ "Error initializing pipe: " << uv_strerror(status)
+ << std::endl);
+ return false;
+ }
+
+ uv_pipe_open(pipe_reader, fds[0]);
+ uv_pipe_open(pipe_writer, fds[1]);
+
+ uv_stdio_container_t stdio[3];
+ stdio[0].flags = UV_INHERIT_FD;
+ stdio[0].data.fd = 0;
+ stdio[1].flags = UV_INHERIT_STREAM;
+ stdio[1].data.stream = pipe_writer;
+ stdio[2] = stdio[1];
+
+ uv_process_options_t options = uv_process_options_t();
+ options.file = this->Command.data();
+ options.args = const_cast<char**>(this->ProcessArgs.data());
+ options.stdio_count = 3; // in, out and err
+ options.exit_cb = &cmProcess::OnExitCB;
+ options.stdio = stdio;
+#if !defined(CMAKE_USE_SYSTEM_LIBUV)
+ std::vector<char> cpumask;
+ if (affinity && !affinity->empty()) {
+ cpumask.resize(static_cast<size_t>(uv_cpumask_size()), 0);
+ for (auto p : *affinity) {
+ cpumask[p] = 1;
+ }
+ options.cpumask = cpumask.data();
+ options.cpumask_size = cpumask.size();
+ } else {
+ options.cpumask = nullptr;
+ options.cpumask_size = 0;
+ }
+#else
+ static_cast<void>(affinity);
+#endif
+
+ status =
+ uv_read_start(pipe_reader, &cmProcess::OnAllocateCB, &cmProcess::OnReadCB);
+
+ if (status != 0) {
+ cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
+ "Error starting read events: " << uv_strerror(status)
+ << std::endl);
+ return false;
}
- this->ProcessArgs.push_back(CM_NULLPTR); // null terminate the list
- this->Process = cmsysProcess_New();
- cmsysProcess_SetCommand(this->Process, &*this->ProcessArgs.begin());
- if (!this->WorkingDirectory.empty()) {
- cmsysProcess_SetWorkingDirectory(this->Process,
- this->WorkingDirectory.c_str());
+
+ status = this->Process.spawn(loop, options, this);
+ if (status != 0) {
+ cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
+ "Process not started\n " << this->Command << "\n["
+ << uv_strerror(status) << "]\n");
+ return false;
+ }
+
+ this->PipeReader = std::move(pipe_reader);
+ this->Timer = std::move(timer);
+
+ this->StartTimer();
+
+ this->ProcessState = cmProcess::State::Executing;
+ return true;
+}
+
+void cmProcess::StartTimer()
+{
+ auto properties = this->Runner.GetTestProperties();
+ auto msec =
+ std::chrono::duration_cast<std::chrono::milliseconds>(this->Timeout);
+
+ if (msec != std::chrono::milliseconds(0) || !properties->ExplicitTimeout) {
+ this->Timer.start(&cmProcess::OnTimeoutCB,
+ static_cast<uint64_t>(msec.count()), 0);
}
- cmsysProcess_SetTimeout(this->Process, this->Timeout);
- cmsysProcess_SetOption(this->Process, cmsysProcess_Option_MergeOutput, 1);
- cmsysProcess_Execute(this->Process);
- return (cmsysProcess_GetState(this->Process) ==
- cmsysProcess_State_Executing);
}
bool cmProcess::Buffer::GetLine(std::string& line)
@@ -65,7 +167,7 @@ bool cmProcess::Buffer::GetLine(std::string& line)
for (size_type sz = this->size(); this->Last != sz; ++this->Last) {
if ((*this)[this->Last] == '\n' || (*this)[this->Last] == '\0') {
// Extract the range first..last as a line.
- const char* text = &*this->begin() + this->First;
+ const char* text = this->data() + this->First;
size_type length = this->Last - this->First;
while (length && text[length - 1] == '\r') {
length--;
@@ -95,7 +197,7 @@ bool cmProcess::Buffer::GetLast(std::string& line)
{
// Return the partial last line, if any.
if (!this->empty()) {
- line.assign(&*this->begin(), this->size());
+ line.assign(this->data(), this->size());
this->First = this->Last = 0;
this->clear();
return true;
@@ -103,140 +205,499 @@ bool cmProcess::Buffer::GetLast(std::string& line)
return false;
}
-int cmProcess::GetNextOutputLine(std::string& line, double timeout)
+void cmProcess::OnReadCB(uv_stream_t* stream, ssize_t nread,
+ const uv_buf_t* buf)
{
- cmProcessOutput processOutput(cmProcessOutput::UTF8);
- std::string strdata;
- for (;;) {
- // Look for lines already buffered.
- if (this->Output.GetLine(line)) {
- return cmsysProcess_Pipe_STDOUT;
- }
+ auto self = static_cast<cmProcess*>(stream->data);
+ self->OnRead(nread, buf);
+}
- // Check for more data from the process.
- char* data;
- int length;
- int p = cmsysProcess_WaitForData(this->Process, &data, &length, &timeout);
- if (p == cmsysProcess_Pipe_Timeout) {
- return cmsysProcess_Pipe_Timeout;
- }
- if (p == cmsysProcess_Pipe_STDOUT) {
- processOutput.DecodeText(data, length, strdata);
- this->Output.insert(this->Output.end(), strdata.begin(), strdata.end());
- } else { // p == cmsysProcess_Pipe_None
- // The process will provide no more data.
- break;
+void cmProcess::OnRead(ssize_t nread, const uv_buf_t* buf)
+{
+ std::string line;
+ if (nread > 0) {
+ std::string strdata;
+ this->Conv.DecodeText(buf->base, static_cast<size_t>(nread), strdata);
+ cmAppend(this->Output, strdata);
+
+ while (this->Output.GetLine(line)) {
+ this->Runner.CheckOutput(line);
+ line.clear();
}
+
+ return;
}
- processOutput.DecodeText(std::string(), strdata);
- if (!strdata.empty()) {
- this->Output.insert(this->Output.end(), strdata.begin(), strdata.end());
+
+ if (nread == 0) {
+ return;
+ }
+
+ // The process will provide no more data.
+ if (nread != UV_EOF) {
+ auto error = static_cast<int>(nread);
+ cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
+ "Error reading stream: " << uv_strerror(error) << std::endl);
}
// Look for partial last lines.
if (this->Output.GetLast(line)) {
- return cmsysProcess_Pipe_STDOUT;
+ this->Runner.CheckOutput(line);
}
- // No more data. Wait for process exit.
- if (!cmsysProcess_WaitForExit(this->Process, &timeout)) {
- return cmsysProcess_Pipe_Timeout;
+ this->ReadHandleClosed = true;
+ this->PipeReader.reset();
+ if (this->ProcessHandleClosed) {
+ uv_timer_stop(this->Timer);
+ this->Runner.FinalizeTest();
+ }
+}
+
+void cmProcess::OnAllocateCB(uv_handle_t* handle, size_t suggested_size,
+ uv_buf_t* buf)
+{
+ auto self = static_cast<cmProcess*>(handle->data);
+ self->OnAllocate(suggested_size, buf);
+}
+
+void cmProcess::OnAllocate(size_t /*suggested_size*/, uv_buf_t* buf)
+{
+ if (this->Buf.size() != CM_PROCESS_BUF_SIZE) {
+ this->Buf.resize(CM_PROCESS_BUF_SIZE);
+ }
+
+ *buf =
+ uv_buf_init(this->Buf.data(), static_cast<unsigned int>(this->Buf.size()));
+}
+
+void cmProcess::OnTimeoutCB(uv_timer_t* timer)
+{
+ auto self = static_cast<cmProcess*>(timer->data);
+ self->OnTimeout();
+}
+
+void cmProcess::OnTimeout()
+{
+ if (this->ProcessState != cmProcess::State::Executing) {
+ return;
+ }
+ this->ProcessState = cmProcess::State::Expired;
+ bool const was_still_reading = !this->ReadHandleClosed;
+ if (!this->ReadHandleClosed) {
+ this->ReadHandleClosed = true;
+ this->PipeReader.reset();
+ }
+ if (!this->ProcessHandleClosed) {
+ // Kill the child and let our on-exit handler finish the test.
+ cmsysProcess_KillPID(static_cast<unsigned long>(this->Process->pid));
+ } else if (was_still_reading) {
+ // Our on-exit handler already ran but did not finish the test
+ // because we were still reading output. We've just dropped
+ // our read handler, so we need to finish the test now.
+ this->Runner.FinalizeTest();
+ }
+}
+
+void cmProcess::OnExitCB(uv_process_t* process, int64_t exit_status,
+ int term_signal)
+{
+ auto self = static_cast<cmProcess*>(process->data);
+ self->OnExit(exit_status, term_signal);
+}
+
+void cmProcess::OnExit(int64_t exit_status, int term_signal)
+{
+ if (this->ProcessState != cmProcess::State::Expired) {
+ if (
+#if defined(_WIN32)
+ ((DWORD)exit_status & 0xF0000000) == 0xC0000000
+#else
+ term_signal != 0
+#endif
+ ) {
+ this->ProcessState = cmProcess::State::Exception;
+ } else {
+ this->ProcessState = cmProcess::State::Exited;
+ }
}
// Record exit information.
- this->ExitValue = cmsysProcess_GetExitValue(this->Process);
- this->TotalTime = cmSystemTools::GetTime() - this->StartTime;
+ this->ExitValue = exit_status;
+ this->Signal = term_signal;
+ this->TotalTime = std::chrono::steady_clock::now() - this->StartTime;
// Because of a processor clock scew the runtime may become slightly
// negative. If someone changed the system clock while the process was
// running this may be even more. Make sure not to report a negative
// duration here.
- if (this->TotalTime <= 0.0) {
- this->TotalTime = 0.0;
- }
- // std::cerr << "Time to run: " << this->TotalTime << "\n";
- return cmsysProcess_Pipe_None;
-}
-
-// return the process status
-int cmProcess::GetProcessStatus()
-{
- if (!this->Process) {
- return cmsysProcess_State_Exited;
- }
- return cmsysProcess_GetState(this->Process);
-}
-
-int cmProcess::ReportStatus()
-{
- int result = 1;
- switch (cmsysProcess_GetState(this->Process)) {
- case cmsysProcess_State_Starting: {
- std::cerr << "cmProcess: Never started " << this->Command
- << " process.\n";
- } break;
- case cmsysProcess_State_Error: {
- std::cerr << "cmProcess: Error executing " << this->Command
- << " process: " << cmsysProcess_GetErrorString(this->Process)
- << "\n";
- } break;
- case cmsysProcess_State_Exception: {
- std::cerr << "cmProcess: " << this->Command
- << " process exited with an exception: ";
- switch (cmsysProcess_GetExitException(this->Process)) {
- case cmsysProcess_Exception_None: {
- std::cerr << "None";
- } break;
- case cmsysProcess_Exception_Fault: {
- std::cerr << "Segmentation fault";
- } break;
- case cmsysProcess_Exception_Illegal: {
- std::cerr << "Illegal instruction";
- } break;
- case cmsysProcess_Exception_Interrupt: {
- std::cerr << "Interrupted by user";
- } break;
- case cmsysProcess_Exception_Numerical: {
- std::cerr << "Numerical exception";
- } break;
- case cmsysProcess_Exception_Other: {
- std::cerr << "Unknown";
- } break;
- }
- std::cerr << "\n";
- } break;
- case cmsysProcess_State_Executing: {
- std::cerr << "cmProcess: Never terminated " << this->Command
- << " process.\n";
- } break;
- case cmsysProcess_State_Exited: {
- result = cmsysProcess_GetExitValue(this->Process);
- std::cerr << "cmProcess: " << this->Command
- << " process exited with code " << result << "\n";
- } break;
- case cmsysProcess_State_Expired: {
- std::cerr << "cmProcess: killed " << this->Command
- << " process due to timeout.\n";
- } break;
- case cmsysProcess_State_Killed: {
- std::cerr << "cmProcess: killed " << this->Command << " process.\n";
- } break;
- }
- return result;
-}
-
-void cmProcess::ChangeTimeout(double t)
+ if (this->TotalTime <= cmDuration::zero()) {
+ this->TotalTime = cmDuration::zero();
+ }
+
+ this->ProcessHandleClosed = true;
+ if (this->ReadHandleClosed) {
+ uv_timer_stop(this->Timer);
+ this->Runner.FinalizeTest();
+ }
+}
+
+cmProcess::State cmProcess::GetProcessStatus()
+{
+ return this->ProcessState;
+}
+
+void cmProcess::ChangeTimeout(cmDuration t)
{
this->Timeout = t;
- cmsysProcess_SetTimeout(this->Process, this->Timeout);
+ this->StartTimer();
}
void cmProcess::ResetStartTime()
{
- cmsysProcess_ResetStartTime(this->Process);
- this->StartTime = cmSystemTools::GetTime();
+ this->StartTime = std::chrono::steady_clock::now();
}
-int cmProcess::GetExitException()
+cmProcess::Exception cmProcess::GetExitException()
{
- return cmsysProcess_GetExitException(this->Process);
+ auto exception = Exception::None;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ auto exit_code = (DWORD)this->ExitValue;
+ if ((exit_code & 0xF0000000) != 0xC0000000) {
+ return exception;
+ }
+
+ if (exit_code) {
+ switch (exit_code) {
+ case STATUS_DATATYPE_MISALIGNMENT:
+ case STATUS_ACCESS_VIOLATION:
+ case STATUS_IN_PAGE_ERROR:
+ case STATUS_INVALID_HANDLE:
+ case STATUS_NONCONTINUABLE_EXCEPTION:
+ case STATUS_INVALID_DISPOSITION:
+ case STATUS_ARRAY_BOUNDS_EXCEEDED:
+ case STATUS_STACK_OVERFLOW:
+ exception = Exception::Fault;
+ break;
+ case STATUS_FLOAT_DENORMAL_OPERAND:
+ case STATUS_FLOAT_DIVIDE_BY_ZERO:
+ case STATUS_FLOAT_INEXACT_RESULT:
+ case STATUS_FLOAT_INVALID_OPERATION:
+ case STATUS_FLOAT_OVERFLOW:
+ case STATUS_FLOAT_STACK_CHECK:
+ case STATUS_FLOAT_UNDERFLOW:
+# ifdef STATUS_FLOAT_MULTIPLE_FAULTS
+ case STATUS_FLOAT_MULTIPLE_FAULTS:
+# endif
+# ifdef STATUS_FLOAT_MULTIPLE_TRAPS
+ case STATUS_FLOAT_MULTIPLE_TRAPS:
+# endif
+ case STATUS_INTEGER_DIVIDE_BY_ZERO:
+ case STATUS_INTEGER_OVERFLOW:
+ exception = Exception::Numerical;
+ break;
+ case STATUS_CONTROL_C_EXIT:
+ exception = Exception::Interrupt;
+ break;
+ case STATUS_ILLEGAL_INSTRUCTION:
+ case STATUS_PRIVILEGED_INSTRUCTION:
+ exception = Exception::Illegal;
+ break;
+ default:
+ exception = Exception::Other;
+ }
+ }
+#else
+ if (this->Signal) {
+ switch (this->Signal) {
+ case SIGSEGV:
+ exception = Exception::Fault;
+ break;
+ case SIGFPE:
+ exception = Exception::Numerical;
+ break;
+ case SIGINT:
+ exception = Exception::Interrupt;
+ break;
+ case SIGILL:
+ exception = Exception::Illegal;
+ break;
+ default:
+ exception = Exception::Other;
+ }
+ }
+#endif
+ return exception;
+}
+
+std::string cmProcess::GetExitExceptionString()
+{
+ std::string exception_str;
+#if defined(_WIN32)
+ switch (this->ExitValue) {
+ case STATUS_CONTROL_C_EXIT:
+ exception_str = "User interrupt";
+ break;
+ case STATUS_FLOAT_DENORMAL_OPERAND:
+ exception_str = "Floating-point exception (denormal operand)";
+ break;
+ case STATUS_FLOAT_DIVIDE_BY_ZERO:
+ exception_str = "Divide-by-zero";
+ break;
+ case STATUS_FLOAT_INEXACT_RESULT:
+ exception_str = "Floating-point exception (inexact result)";
+ break;
+ case STATUS_FLOAT_INVALID_OPERATION:
+ exception_str = "Invalid floating-point operation";
+ break;
+ case STATUS_FLOAT_OVERFLOW:
+ exception_str = "Floating-point overflow";
+ break;
+ case STATUS_FLOAT_STACK_CHECK:
+ exception_str = "Floating-point stack check failed";
+ break;
+ case STATUS_FLOAT_UNDERFLOW:
+ exception_str = "Floating-point underflow";
+ break;
+# ifdef STATUS_FLOAT_MULTIPLE_FAULTS
+ case STATUS_FLOAT_MULTIPLE_FAULTS:
+ exception_str = "Floating-point exception (multiple faults)";
+ break;
+# endif
+# ifdef STATUS_FLOAT_MULTIPLE_TRAPS
+ case STATUS_FLOAT_MULTIPLE_TRAPS:
+ exception_str = "Floating-point exception (multiple traps)";
+ break;
+# endif
+ case STATUS_INTEGER_DIVIDE_BY_ZERO:
+ exception_str = "Integer divide-by-zero";
+ break;
+ case STATUS_INTEGER_OVERFLOW:
+ exception_str = "Integer overflow";
+ break;
+
+ case STATUS_DATATYPE_MISALIGNMENT:
+ exception_str = "Datatype misalignment";
+ break;
+ case STATUS_ACCESS_VIOLATION:
+ exception_str = "Access violation";
+ break;
+ case STATUS_IN_PAGE_ERROR:
+ exception_str = "In-page error";
+ break;
+ case STATUS_INVALID_HANDLE:
+ exception_str = "Invalid handle";
+ break;
+ case STATUS_NONCONTINUABLE_EXCEPTION:
+ exception_str = "Noncontinuable exception";
+ break;
+ case STATUS_INVALID_DISPOSITION:
+ exception_str = "Invalid disposition";
+ break;
+ case STATUS_ARRAY_BOUNDS_EXCEEDED:
+ exception_str = "Array bounds exceeded";
+ break;
+ case STATUS_STACK_OVERFLOW:
+ exception_str = "Stack overflow";
+ break;
+
+ case STATUS_ILLEGAL_INSTRUCTION:
+ exception_str = "Illegal instruction";
+ break;
+ case STATUS_PRIVILEGED_INSTRUCTION:
+ exception_str = "Privileged instruction";
+ break;
+ case STATUS_NO_MEMORY:
+ default:
+ char buf[1024];
+ const char* fmt = "Exit code 0x%" KWIML_INT_PRIx64 "\n";
+ _snprintf(buf, 1024, fmt, this->ExitValue);
+ exception_str.assign(buf);
+ }
+#else
+ switch (this->Signal) {
+# ifdef SIGSEGV
+ case SIGSEGV:
+ exception_str = "Segmentation fault";
+ break;
+# endif
+# ifdef SIGBUS
+# if !defined(SIGSEGV) || SIGBUS != SIGSEGV
+ case SIGBUS:
+ exception_str = "Bus error";
+ break;
+# endif
+# endif
+# ifdef SIGFPE
+ case SIGFPE:
+ exception_str = "Floating-point exception";
+ break;
+# endif
+# ifdef SIGILL
+ case SIGILL:
+ exception_str = "Illegal instruction";
+ break;
+# endif
+# ifdef SIGINT
+ case SIGINT:
+ exception_str = "User interrupt";
+ break;
+# endif
+# ifdef SIGABRT
+ case SIGABRT:
+ exception_str = "Child aborted";
+ break;
+# endif
+# ifdef SIGKILL
+ case SIGKILL:
+ exception_str = "Child killed";
+ break;
+# endif
+# ifdef SIGTERM
+ case SIGTERM:
+ exception_str = "Child terminated";
+ break;
+# endif
+# ifdef SIGHUP
+ case SIGHUP:
+ exception_str = "SIGHUP";
+ break;
+# endif
+# ifdef SIGQUIT
+ case SIGQUIT:
+ exception_str = "SIGQUIT";
+ break;
+# endif
+# ifdef SIGTRAP
+ case SIGTRAP:
+ exception_str = "SIGTRAP";
+ break;
+# endif
+# ifdef SIGIOT
+# if !defined(SIGABRT) || SIGIOT != SIGABRT
+ case SIGIOT:
+ exception_str = "SIGIOT";
+ break;
+# endif
+# endif
+# ifdef SIGUSR1
+ case SIGUSR1:
+ exception_str = "SIGUSR1";
+ break;
+# endif
+# ifdef SIGUSR2
+ case SIGUSR2:
+ exception_str = "SIGUSR2";
+ break;
+# endif
+# ifdef SIGPIPE
+ case SIGPIPE:
+ exception_str = "SIGPIPE";
+ break;
+# endif
+# ifdef SIGALRM
+ case SIGALRM:
+ exception_str = "SIGALRM";
+ break;
+# endif
+# ifdef SIGSTKFLT
+ case SIGSTKFLT:
+ exception_str = "SIGSTKFLT";
+ break;
+# endif
+# ifdef SIGCHLD
+ case SIGCHLD:
+ exception_str = "SIGCHLD";
+ break;
+# elif defined(SIGCLD)
+ case SIGCLD:
+ exception_str = "SIGCLD";
+ break;
+# endif
+# ifdef SIGCONT
+ case SIGCONT:
+ exception_str = "SIGCONT";
+ break;
+# endif
+# ifdef SIGSTOP
+ case SIGSTOP:
+ exception_str = "SIGSTOP";
+ break;
+# endif
+# ifdef SIGTSTP
+ case SIGTSTP:
+ exception_str = "SIGTSTP";
+ break;
+# endif
+# ifdef SIGTTIN
+ case SIGTTIN:
+ exception_str = "SIGTTIN";
+ break;
+# endif
+# ifdef SIGTTOU
+ case SIGTTOU:
+ exception_str = "SIGTTOU";
+ break;
+# endif
+# ifdef SIGURG
+ case SIGURG:
+ exception_str = "SIGURG";
+ break;
+# endif
+# ifdef SIGXCPU
+ case SIGXCPU:
+ exception_str = "SIGXCPU";
+ break;
+# endif
+# ifdef SIGXFSZ
+ case SIGXFSZ:
+ exception_str = "SIGXFSZ";
+ break;
+# endif
+# ifdef SIGVTALRM
+ case SIGVTALRM:
+ exception_str = "SIGVTALRM";
+ break;
+# endif
+# ifdef SIGPROF
+ case SIGPROF:
+ exception_str = "SIGPROF";
+ break;
+# endif
+# ifdef SIGWINCH
+ case SIGWINCH:
+ exception_str = "SIGWINCH";
+ break;
+# endif
+# ifdef SIGPOLL
+ case SIGPOLL:
+ exception_str = "SIGPOLL";
+ break;
+# endif
+# ifdef SIGIO
+# if !defined(SIGPOLL) || SIGIO != SIGPOLL
+ case SIGIO:
+ exception_str = "SIGIO";
+ break;
+# endif
+# endif
+# ifdef SIGPWR
+ case SIGPWR:
+ exception_str = "SIGPWR";
+ break;
+# endif
+# ifdef SIGSYS
+ case SIGSYS:
+ exception_str = "SIGSYS";
+ break;
+# endif
+# ifdef SIGUNUSED
+# if !defined(SIGSYS) || SIGUNUSED != SIGSYS
+ case SIGUNUSED:
+ exception_str = "SIGUNUSED";
+ break;
+# endif
+# endif
+ default:
+ exception_str = cmStrCat("Signal ", this->Signal);
+ }
+#endif
+ return exception_str;
}
diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h
index 86e905aca..2c24f2df0 100644
--- a/Source/CTest/cmProcess.h
+++ b/Source/CTest/cmProcess.h
@@ -5,10 +5,21 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmsys/Process.h"
+#include <chrono>
#include <string>
#include <vector>
+#include <stddef.h>
+#include <stdint.h>
+
+#include "cm_uv.h"
+
+#include "cmDuration.h"
+#include "cmProcessOutput.h"
+#include "cmUVHandlePtr.h"
+
+class cmCTestRunTest;
+
/** \class cmProcess
* \brief run a process with c++
*
@@ -17,41 +28,80 @@
class cmProcess
{
public:
- cmProcess();
+ explicit cmProcess(cmCTestRunTest& runner);
~cmProcess();
- const char* GetCommand() { return this->Command.c_str(); }
- void SetCommand(const char* command);
+ void SetCommand(std::string const& command);
void SetCommandArguments(std::vector<std::string> const& arg);
- void SetWorkingDirectory(const char* dir) { this->WorkingDirectory = dir; }
- void SetTimeout(double t) { this->Timeout = t; }
- void ChangeTimeout(double t);
+ void SetWorkingDirectory(std::string const& dir);
+ void SetTimeout(cmDuration t) { this->Timeout = t; }
+ void ChangeTimeout(cmDuration t);
void ResetStartTime();
// Return true if the process starts
- bool StartProcess();
+ bool StartProcess(uv_loop_t& loop, std::vector<size_t>* affinity);
- // return the process status
- int GetProcessStatus();
- // Report the status of the program
- int ReportStatus();
+ enum class State
+ {
+ Starting,
+ Error,
+ Exception,
+ Executing,
+ Exited,
+ Expired,
+ Killed,
+ Disowned
+ };
+
+ State GetProcessStatus();
int GetId() { return this->Id; }
void SetId(int id) { this->Id = id; }
- int GetExitValue() { return this->ExitValue; }
- double GetTotalTime() { return this->TotalTime; }
- int GetExitException();
- /**
- * Read one line of output but block for no more than timeout.
- * Returns:
- * cmsysProcess_Pipe_None = Process terminated and all output read
- * cmsysProcess_Pipe_STDOUT = Line came from stdout or stderr
- * cmsysProcess_Pipe_Timeout = Timeout expired while waiting
- */
- int GetNextOutputLine(std::string& line, double timeout);
+ int64_t GetExitValue() { return this->ExitValue; }
+ cmDuration GetTotalTime() { return this->TotalTime; }
+
+ enum class Exception
+ {
+ None,
+ Fault,
+ Illegal,
+ Interrupt,
+ Numerical,
+ Other
+ };
+
+ Exception GetExitException();
+ std::string GetExitExceptionString();
private:
- double Timeout;
- double StartTime;
- double TotalTime;
- cmsysProcess* Process;
+ cmDuration Timeout;
+ std::chrono::steady_clock::time_point StartTime;
+ cmDuration TotalTime;
+ bool ReadHandleClosed = false;
+ bool ProcessHandleClosed = false;
+
+ cm::uv_process_ptr Process;
+ cm::uv_pipe_ptr PipeReader;
+ cm::uv_timer_ptr Timer;
+ std::vector<char> Buf;
+
+ cmCTestRunTest& Runner;
+ cmProcessOutput Conv;
+ int Signal = 0;
+ cmProcess::State ProcessState = cmProcess::State::Starting;
+
+ static void OnExitCB(uv_process_t* process, int64_t exit_status,
+ int term_signal);
+ static void OnTimeoutCB(uv_timer_t* timer);
+ static void OnReadCB(uv_stream_t* stream, ssize_t nread,
+ const uv_buf_t* buf);
+ static void OnAllocateCB(uv_handle_t* handle, size_t suggested_size,
+ uv_buf_t* buf);
+
+ void OnExit(int64_t exit_status, int term_signal);
+ void OnTimeout();
+ void OnRead(ssize_t nread, const uv_buf_t* buf);
+ void OnAllocate(size_t suggested_size, uv_buf_t* buf);
+
+ void StartTimer();
+
class Buffer : public std::vector<char>
{
// Half-open index range of partial line already scanned.
@@ -73,7 +123,7 @@ private:
std::vector<std::string> Arguments;
std::vector<const char*> ProcessArgs;
int Id;
- int ExitValue;
+ int64_t ExitValue;
};
#endif
diff --git a/Source/Checks/Curses.cmake b/Source/Checks/Curses.cmake
new file mode 100644
index 000000000..2942b666a
--- /dev/null
+++ b/Source/Checks/Curses.cmake
@@ -0,0 +1,41 @@
+message(STATUS "Checking for curses support")
+
+# Try compiling a simple project using curses.
+# Pass in any cache entries that the user may have set.
+set(CMakeCheckCurses_ARGS "")
+foreach(v
+ CURSES_INCLUDE_PATH
+ CURSES_CURSES_LIBRARY
+ CURSES_NCURSES_LIBRARY
+ CURSES_EXTRA_LIBRARY
+ CURSES_FORM_LIBRARY
+ )
+ if(${v})
+ list(APPEND CMakeCheckCurses_ARGS -D${v}=${${v}})
+ endif()
+endforeach()
+file(REMOVE_RECURSE "${CMake_BINARY_DIR}/Source/Checks/Curses-build")
+try_compile(CMakeCheckCurses_COMPILED
+ ${CMake_BINARY_DIR}/Source/Checks/Curses-build
+ ${CMake_SOURCE_DIR}/Source/Checks/Curses
+ CheckCurses # project name
+ CheckCurses # target name
+ CMAKE_FLAGS
+ "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}"
+ ${CMakeCheckCurses_ARGS}
+ OUTPUT_VARIABLE CMakeCheckCurses_OUTPUT
+ )
+
+# Convert result from cache entry to normal variable.
+set(CMakeCheckCurses_COMPILED "${CMakeCheckCurses_COMPILED}")
+unset(CMakeCheckCurses_COMPILED CACHE)
+
+if(CMakeCheckCurses_COMPILED)
+ message(STATUS "Checking for curses support - Success")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Checking for curses support passed with the following output:\n${CMakeCheckCurses_OUTPUT}\n\n")
+else()
+ message(STATUS "Checking for curses support - Failed")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Checking for curses support failed with the following output:\n${CMakeCheckCurses_OUTPUT}\n\n")
+endif()
diff --git a/Source/Checks/Curses/CMakeLists.txt b/Source/Checks/Curses/CMakeLists.txt
new file mode 100644
index 000000000..17318a33b
--- /dev/null
+++ b/Source/Checks/Curses/CMakeLists.txt
@@ -0,0 +1,25 @@
+cmake_minimum_required(VERSION 3.1)
+if(POLICY CMP0060)
+ cmake_policy(SET CMP0060 NEW)
+endif()
+project(CheckCurses C)
+
+set(CURSES_NEED_NCURSES TRUE)
+find_package(Curses)
+if(NOT CURSES_FOUND)
+ return()
+endif()
+include_directories(${CURSES_INCLUDE_DIRS})
+add_executable(CheckCurses CheckCurses.c)
+target_link_libraries(CheckCurses ${CURSES_LIBRARIES})
+
+foreach(h
+ CURSES_HAVE_CURSES_H
+ CURSES_HAVE_NCURSES_H
+ CURSES_HAVE_NCURSES_NCURSES_H
+ CURSES_HAVE_NCURSES_CURSES_H
+ )
+ if(${h})
+ target_compile_definitions(CheckCurses PRIVATE ${h})
+ endif()
+endforeach()
diff --git a/Source/Checks/Curses/CheckCurses.c b/Source/Checks/Curses/CheckCurses.c
new file mode 100644
index 000000000..7d827e6bf
--- /dev/null
+++ b/Source/Checks/Curses/CheckCurses.c
@@ -0,0 +1,15 @@
+#if defined(CURSES_HAVE_NCURSES_H)
+# include <ncurses.h>
+#elif defined(CURSES_HAVE_NCURSES_NCURSES_H)
+# include <ncurses/ncurses.h>
+#elif defined(CURSES_HAVE_NCURSES_CURSES_H)
+# include <ncurses/curses.h>
+#else
+# include <curses.h>
+#endif
+
+int main()
+{
+ curses_version();
+ return 0;
+}
diff --git a/Source/Checks/cm_cxx14_check.cmake b/Source/Checks/cm_cxx14_check.cmake
new file mode 100644
index 000000000..38606b9c9
--- /dev/null
+++ b/Source/Checks/cm_cxx14_check.cmake
@@ -0,0 +1,36 @@
+set(CMake_CXX14_BROKEN 0)
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|PGI")
+ if(NOT CMAKE_CXX14_STANDARD_COMPILE_OPTION)
+ set(CMake_CXX14_WORKS 0)
+ endif()
+ if(NOT DEFINED CMake_CXX14_WORKS)
+ message(STATUS "Checking if compiler supports needed C++14 constructs")
+ try_compile(CMake_CXX14_WORKS
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_LIST_DIR}/cm_cxx14_check.cpp
+ CMAKE_FLAGS -DCMAKE_CXX_STANDARD=14
+ OUTPUT_VARIABLE OUTPUT
+ )
+ if(CMake_CXX14_WORKS AND "${OUTPUT}" MATCHES "error: no member named.*gets.*in the global namespace")
+ set_property(CACHE CMake_CXX14_WORKS PROPERTY VALUE 0)
+ endif()
+ if(CMake_CXX14_WORKS)
+ message(STATUS "Checking if compiler supports needed C++14 constructs - yes")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining if compiler supports needed C++14 constructs passed with the following output:\n"
+ "${OUTPUT}\n"
+ "\n"
+ )
+ else()
+ message(STATUS "Checking if compiler supports needed C++14 constructs - no")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if compiler supports needed C++14 constructs failed with the following output:\n"
+ "${OUTPUT}\n"
+ "\n"
+ )
+ endif()
+ endif()
+ if(NOT CMake_CXX14_WORKS)
+ set(CMake_CXX14_BROKEN 1)
+ endif()
+endif()
diff --git a/Source/Checks/cm_cxx14_check.cpp b/Source/Checks/cm_cxx14_check.cpp
new file mode 100644
index 000000000..fff36c916
--- /dev/null
+++ b/Source/Checks/cm_cxx14_check.cpp
@@ -0,0 +1,15 @@
+#include <cstdio>
+#include <iterator>
+#include <memory>
+
+int main()
+{
+ int a[] = { 0, 1, 2 };
+ auto ai = std::cbegin(a);
+
+ int b[] = { 2, 1, 0 };
+ auto bi = std::cend(b);
+
+ std::unique_ptr<int> u(new int(0));
+ return *u + *ai + *(bi - 1);
+}
diff --git a/Source/Checks/cm_cxx14_cstdio.cmake b/Source/Checks/cm_cxx14_cstdio.cmake
deleted file mode 100644
index 73f7e2ed5..000000000
--- a/Source/Checks/cm_cxx14_cstdio.cmake
+++ /dev/null
@@ -1,33 +0,0 @@
-set(CMake_CXX14_CSTDIO_BROKEN 0)
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND CMAKE_CXX14_STANDARD_COMPILE_OPTION)
- if(NOT DEFINED CMake_CXX14_CSTDIO_WORKS)
- message(STATUS "Checking if compiler supports C++14 cstdio")
- try_compile(CMake_CXX14_CSTDIO_WORKS
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_LIST_DIR}/cm_cxx14_cstdio.cpp
- CMAKE_FLAGS -DCMAKE_CXX_STANDARD=14
- OUTPUT_VARIABLE OUTPUT
- )
- if(CMake_CXX14_CSTDIO_WORKS AND "${OUTPUT}" MATCHES "error: no member named.*gets.*in the global namespace")
- set_property(CACHE CMake_CXX14_CSTDIO_WORKS PROPERTY VALUE 0)
- endif()
- if(CMake_CXX14_CSTDIO_WORKS)
- message(STATUS "Checking if compiler supports C++14 cstdio - yes")
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
- "Determining if compiler supports C++14 cstdio passed with the following output:\n"
- "${OUTPUT}\n"
- "\n"
- )
- else()
- message(STATUS "Checking if compiler supports C++14 cstdio - no")
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining if compiler supports C++14 cstdio failed with the following output:\n"
- "${OUTPUT}\n"
- "\n"
- )
- endif()
- endif()
- if(NOT CMake_CXX14_CSTDIO_WORKS)
- set(CMake_CXX14_CSTDIO_BROKEN 1)
- endif()
-endif()
diff --git a/Source/Checks/cm_cxx14_cstdio.cpp b/Source/Checks/cm_cxx14_cstdio.cpp
deleted file mode 100644
index f5806a9c6..000000000
--- a/Source/Checks/cm_cxx14_cstdio.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <cstdio>
-int main()
-{
- return 0;
-}
diff --git a/Source/Checks/cm_cxx17_check.cmake b/Source/Checks/cm_cxx17_check.cmake
new file mode 100644
index 000000000..4da2fd7ca
--- /dev/null
+++ b/Source/Checks/cm_cxx17_check.cmake
@@ -0,0 +1,36 @@
+set(CMake_CXX17_BROKEN 0)
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|PGI")
+ if(NOT CMAKE_CXX17_STANDARD_COMPILE_OPTION)
+ set(CMake_CXX17_WORKS 0)
+ endif()
+ if(NOT DEFINED CMake_CXX17_WORKS)
+ message(STATUS "Checking if compiler supports needed C++17 constructs")
+ try_compile(CMake_CXX17_WORKS
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_LIST_DIR}/cm_cxx17_check.cpp
+ CMAKE_FLAGS -DCMAKE_CXX_STANDARD=17
+ OUTPUT_VARIABLE OUTPUT
+ )
+ if(CMake_CXX17_WORKS AND "${OUTPUT}" MATCHES "error: no member named.*gets.*in the global namespace")
+ set_property(CACHE CMake_CXX17_WORKS PROPERTY VALUE 0)
+ endif()
+ if(CMake_CXX17_WORKS)
+ message(STATUS "Checking if compiler supports needed C++17 constructs - yes")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining if compiler supports needed C++17 constructs passed with the following output:\n"
+ "${OUTPUT}\n"
+ "\n"
+ )
+ else()
+ message(STATUS "Checking if compiler supports needed C++17 constructs - no")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if compiler supports needed C++17 constructs failed with the following output:\n"
+ "${OUTPUT}\n"
+ "\n"
+ )
+ endif()
+ endif()
+ if(NOT CMake_CXX17_WORKS)
+ set(CMake_CXX17_BROKEN 1)
+ endif()
+endif()
diff --git a/Source/Checks/cm_cxx17_check.cpp b/Source/Checks/cm_cxx17_check.cpp
new file mode 100644
index 000000000..29863b136
--- /dev/null
+++ b/Source/Checks/cm_cxx17_check.cpp
@@ -0,0 +1,34 @@
+#include <cstdio>
+#include <iterator>
+#include <memory>
+#include <optional>
+#include <unordered_map>
+
+#ifdef _MSC_VER
+# include <comdef.h>
+#endif
+
+int main()
+{
+ int a[] = { 0, 1, 2 };
+ auto ai = std::cbegin(a);
+
+ int b[] = { 2, 1, 0 };
+ auto bi = std::cend(b);
+
+ auto ci = std::size(a);
+
+ std::unique_ptr<int> u(new int(0));
+
+#ifdef _MSC_VER
+ // clang-cl has problems instantiating this constructor in C++17 mode
+ // error: indirection requires pointer operand ('const _GUID' invalid)
+ // return *_IID;
+ IUnknownPtr ptr{};
+ IDispatchPtr disp(ptr);
+#endif
+
+ std::optional<int> oi = 0;
+
+ return *u + *ai + *(bi - 1) + (3 - static_cast<int>(ci)) + oi.value();
+}
diff --git a/Source/Checks/cm_cxx_attribute_fallthrough.cxx b/Source/Checks/cm_cxx_attribute_fallthrough.cxx
deleted file mode 100644
index df43625a4..000000000
--- a/Source/Checks/cm_cxx_attribute_fallthrough.cxx
+++ /dev/null
@@ -1,11 +0,0 @@
-int main(int argc, char* argv[])
-{
- int i = 3;
- switch (argc) {
- case 1:
- i = 0;
- __attribute__((fallthrough));
- default:
- return i;
- }
-}
diff --git a/Source/Checks/cm_cxx_auto_ptr.cxx b/Source/Checks/cm_cxx_auto_ptr.cxx
deleted file mode 100644
index d3100fdc8..000000000
--- a/Source/Checks/cm_cxx_auto_ptr.cxx
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <memory>
-
-std::auto_ptr<int> get_auto_ptr()
-{
- std::auto_ptr<int> ptr;
- ptr = std::auto_ptr<int>(new int(0));
- return ptr;
-}
-
-int use_auto_ptr(std::auto_ptr<int> ptr)
-{
- return *ptr;
-}
-
-int main()
-{
- return use_auto_ptr(get_auto_ptr());
-}
diff --git a/Source/Checks/cm_cxx_eq_delete.cxx b/Source/Checks/cm_cxx_eq_delete.cxx
deleted file mode 100644
index 809e4cfcf..000000000
--- a/Source/Checks/cm_cxx_eq_delete.cxx
+++ /dev/null
@@ -1,14 +0,0 @@
-struct Foo
-{
- Foo() {}
- ~Foo() {}
- Foo(Foo const&) = delete;
- Foo& operator=(Foo const&) = delete;
- int test() const { return 0; }
-};
-
-int main()
-{
- Foo const foo;
- return foo.test();
-}
diff --git a/Source/Checks/cm_cxx_fallthrough.cxx b/Source/Checks/cm_cxx_fallthrough.cxx
deleted file mode 100644
index 7b35a5f29..000000000
--- a/Source/Checks/cm_cxx_fallthrough.cxx
+++ /dev/null
@@ -1,11 +0,0 @@
-int main(int argc, char* argv[])
-{
- int i = 3;
- switch (argc) {
- case 1:
- i = 0;
- [[fallthrough]];
- default:
- return i;
- }
-}
diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake
index 3b0802579..fb68ed78c 100644
--- a/Source/Checks/cm_cxx_features.cmake
+++ b/Source/Checks/cm_cxx_features.cmake
@@ -14,10 +14,20 @@ function(cm_check_cxx_feature name)
CMAKE_FLAGS ${maybe_cxx_standard}
OUTPUT_VARIABLE OUTPUT
)
+ set(check_output "${OUTPUT}")
# Filter out MSBuild output that looks like a warning.
- string(REGEX REPLACE " +0 Warning\\(s\\)" "" check_output "${OUTPUT}")
+ string(REGEX REPLACE " +0 Warning\\(s\\)" "" check_output "${check_output}")
+ # Filter out warnings caused by user flags.
+ string(REGEX REPLACE "[^\n]*warning:[^\n]*-Winvalid-command-line-argument[^\n]*" "" check_output "${check_output}")
+ # Filter out warnings caused by local configuration.
+ string(REGEX REPLACE "[^\n]*warning:[^\n]*directory not found for option[^\n]*" "" check_output "${check_output}")
+ string(REGEX REPLACE "[^\n]*warning:[^\n]*object file compiled with -mlong-branch which is no longer needed[^\n]*" "" check_output "${check_output}")
+ # Filter out other warnings unrelated to feature checks.
+ string(REGEX REPLACE "[^\n]*warning:[^\n]*sprintf\\(\\) is often misused, please use snprintf[^\n]*" "" check_output "${check_output}")
+ # Filter out xcodebuild warnings.
+ string(REGEX REPLACE "[^\n]* xcodebuild\\[[0-9]*:[0-9]*\\] warning: [^\n]*" "" check_output "${check_output}")
# If using the feature causes warnings, treat it as broken/unavailable.
- if(check_output MATCHES "[Ww]arning")
+ if(check_output MATCHES "(^|[ :])[Ww][Aa][Rr][Nn][Ii][Nn][Gg]")
set(CMake_HAVE_CXX_${FEATURE} OFF CACHE INTERNAL "TRY_COMPILE" FORCE)
endif()
if(CMake_HAVE_CXX_${FEATURE})
@@ -38,21 +48,8 @@ function(cm_check_cxx_feature name)
endif()
endfunction()
-cm_check_cxx_feature(auto_ptr)
-cm_check_cxx_feature(eq_delete)
-cm_check_cxx_feature(fallthrough)
-if(NOT CMake_HAVE_CXX_FALLTHROUGH)
- cm_check_cxx_feature(gnu_fallthrough)
- if(NOT CMake_HAVE_CXX_GNU_FALLTHROUGH)
- cm_check_cxx_feature(attribute_fallthrough)
- endif()
-endif()
cm_check_cxx_feature(make_unique)
if(CMake_HAVE_CXX_MAKE_UNIQUE)
set(CMake_HAVE_CXX_UNIQUE_PTR 1)
endif()
-cm_check_cxx_feature(nullptr)
-cm_check_cxx_feature(override)
cm_check_cxx_feature(unique_ptr)
-cm_check_cxx_feature(unordered_map)
-cm_check_cxx_feature(unordered_set)
diff --git a/Source/Checks/cm_cxx_gnu_fallthrough.cxx b/Source/Checks/cm_cxx_gnu_fallthrough.cxx
deleted file mode 100644
index 602109405..000000000
--- a/Source/Checks/cm_cxx_gnu_fallthrough.cxx
+++ /dev/null
@@ -1,11 +0,0 @@
-int main(int argc, char* argv[])
-{
- int i = 3;
- switch (argc) {
- case 1:
- i = 0;
- [[gnu::fallthrough]];
- default:
- return i;
- }
-}
diff --git a/Source/Checks/cm_cxx_nullptr.cxx b/Source/Checks/cm_cxx_nullptr.cxx
deleted file mode 100644
index 500684aee..000000000
--- a/Source/Checks/cm_cxx_nullptr.cxx
+++ /dev/null
@@ -1,14 +0,0 @@
-int test(int)
-{
- return -1;
-}
-
-int test(int*)
-{
- return 0;
-}
-
-int main()
-{
- return test(nullptr);
-}
diff --git a/Source/Checks/cm_cxx_override.cxx b/Source/Checks/cm_cxx_override.cxx
deleted file mode 100644
index 5a33fbb78..000000000
--- a/Source/Checks/cm_cxx_override.cxx
+++ /dev/null
@@ -1,24 +0,0 @@
-struct Foo
-{
- Foo() {}
- virtual ~Foo() {}
- virtual int test() const = 0;
-};
-
-struct Bar : Foo
-{
- Bar() {}
- ~Bar() override {}
- int test() const override { return 0; }
-};
-
-int test(Foo const& foo)
-{
- return foo.test();
-}
-
-int main()
-{
- Bar const bar;
- return test(bar);
-}
diff --git a/Source/Checks/cm_cxx_unordered_map.cxx b/Source/Checks/cm_cxx_unordered_map.cxx
deleted file mode 100644
index be3de252b..000000000
--- a/Source/Checks/cm_cxx_unordered_map.cxx
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unordered_map>
-int main()
-{
- std::unordered_map<int, int> map;
- map[0] = 0;
- return 0;
-}
diff --git a/Source/Checks/cm_cxx_unordered_set.cxx b/Source/Checks/cm_cxx_unordered_set.cxx
deleted file mode 100644
index de4bb7765..000000000
--- a/Source/Checks/cm_cxx_unordered_set.cxx
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unordered_set>
-int main()
-{
- std::unordered_set<int> set;
- set.insert(0);
- return 0;
-}
diff --git a/Source/CursesDialog/CMakeLists.txt b/Source/CursesDialog/CMakeLists.txt
index c5ac1f1a6..700971751 100644
--- a/Source/CursesDialog/CMakeLists.txt
+++ b/Source/CursesDialog/CMakeLists.txt
@@ -1,32 +1,28 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-set( CURSES_SRCS
- CursesDialog/cmCursesOptionsWidget
- CursesDialog/cmCursesBoolWidget
- CursesDialog/cmCursesCacheEntryComposite
- CursesDialog/cmCursesDummyWidget
- CursesDialog/cmCursesFilePathWidget
- CursesDialog/cmCursesForm
- CursesDialog/cmCursesLabelWidget
- CursesDialog/cmCursesLongMessageForm
- CursesDialog/cmCursesMainForm
- CursesDialog/cmCursesPathWidget
- CursesDialog/cmCursesStringWidget
- CursesDialog/cmCursesWidget
- CursesDialog/ccmake
- )
-
-if( NOT CMAKE_USE_SYSTEM_FORM )
- include_directories(${CMake_SOURCE_DIR}/Source/CursesDialog/form
- ${CMake_BINARY_DIR}/Source/CursesDialog/form)
-endif()
-include_directories(${CURSES_INCLUDE_PATH})
-
-
-add_executable(ccmake ${CURSES_SRCS} )
+add_executable(ccmake
+ ccmake.cxx
+ cmCursesBoolWidget.cxx
+ cmCursesCacheEntryComposite.cxx
+ cmCursesDummyWidget.cxx
+ cmCursesFilePathWidget.cxx
+ cmCursesForm.cxx
+ cmCursesLabelWidget.cxx
+ cmCursesLongMessageForm.cxx
+ cmCursesMainForm.cxx
+ cmCursesOptionsWidget.cxx
+ cmCursesPathWidget.cxx
+ cmCursesStringWidget.cxx
+ cmCursesWidget.cxx
+ )
+target_include_directories(ccmake PRIVATE ${CURSES_INCLUDE_PATH})
target_link_libraries(ccmake CMakeLib)
if(CMAKE_USE_SYSTEM_FORM)
+ find_path(CURSES_FORM_INCLUDE_DIR NAMES form.h HINTS ${CURSES_INCLUDE_PATH} ${CURSES_INCLUDE_PATH}/ncurses)
+ if(CURSES_FORM_INCLUDE_DIR)
+ target_include_directories(ccmake PRIVATE ${CURSES_FORM_INCLUDE_DIR})
+ endif()
target_link_libraries(ccmake
${CURSES_FORM_LIBRARY}
${CURSES_LIBRARY}
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index 28a0e95b9..9e9dfbd19 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -1,47 +1,50 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmConfigure.h"
+
+#include <csignal>
+#include <cstring>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "cmsys/Encoding.hxx"
#include "cmCursesForm.h"
#include "cmCursesMainForm.h"
#include "cmCursesStandardIncludes.h"
#include "cmDocumentation.h"
-#include "cmDocumentationEntry.h"
+#include "cmDocumentationEntry.h" // IWYU pragma: keep
+#include "cmState.h"
#include "cmSystemTools.h"
#include "cmake.h"
-#include "cmsys/Encoding.hxx"
-#include <iostream>
-#include <signal.h>
-#include <string.h>
-#include <string>
-#include <vector>
-
static const char* cmDocumentationName[][2] = {
- { CM_NULLPTR, " ccmake - Curses Interface for CMake." },
- { CM_NULLPTR, CM_NULLPTR }
+ { nullptr, " ccmake - Curses Interface for CMake." },
+ { nullptr, nullptr }
};
static const char* cmDocumentationUsage[][2] = {
- { CM_NULLPTR, " ccmake <path-to-source>\n"
- " ccmake <path-to-existing-build>" },
- { CM_NULLPTR,
+ { nullptr,
+ " ccmake <path-to-source>\n"
+ " ccmake <path-to-existing-build>" },
+ { nullptr,
"Specify a source directory to (re-)generate a build system for "
"it in the current working directory. Specify an existing build "
"directory to re-generate its build system." },
- { CM_NULLPTR, CM_NULLPTR }
+ { nullptr, nullptr }
};
static const char* cmDocumentationUsageNote[][2] = {
- { CM_NULLPTR, "Run 'ccmake --help' for more information." },
- { CM_NULLPTR, CM_NULLPTR }
+ { nullptr, "Run 'ccmake --help' for more information." },
+ { nullptr, nullptr }
};
-static const char* cmDocumentationOptions[]
- [2] = { CMAKE_STANDARD_OPTIONS_TABLE,
- { CM_NULLPTR, CM_NULLPTR } };
+static const char* cmDocumentationOptions[][2] = {
+ CMAKE_STANDARD_OPTIONS_TABLE,
+ { nullptr, nullptr }
+};
-cmCursesForm* cmCursesForm::CurrentForm = CM_NULLPTR;
+cmCursesForm* cmCursesForm::CurrentForm = nullptr;
extern "C" {
@@ -54,7 +57,8 @@ void onsig(int /*unused*/)
cbreak(); /* nl- or cr not needed */
keypad(stdscr, true); /* Use key symbols as KEY_DOWN */
refresh();
- int x, y;
+ int x;
+ int y;
getmaxyx(stdscr, y, x);
cmCursesForm::CurrentForm->Render(1, 1, x, y);
cmCursesForm::CurrentForm->UpdateStatusBar();
@@ -63,37 +67,31 @@ void onsig(int /*unused*/)
}
}
-void CMakeMessageHandler(const char* message, const char* title,
- bool& /*unused*/, void* clientData)
-{
- cmCursesForm* self = static_cast<cmCursesForm*>(clientData);
- self->AddError(message, title);
-}
-
int main(int argc, char const* const* argv)
{
+ cmSystemTools::EnsureStdPipes();
cmsys::Encoding::CommandLineArguments encoding_args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
argc = encoding_args.argc();
argv = encoding_args.argv();
+ cmSystemTools::InitializeLibUV();
cmSystemTools::FindCMakeResources(argv[0]);
cmDocumentation doc;
doc.addCMakeStandardDocSections();
if (doc.CheckOptions(argc, argv)) {
- cmake hcm(cmake::RoleInternal);
+ cmake hcm(cmake::RoleInternal, cmState::Unknown);
hcm.SetHomeDirectory("");
hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
- std::vector<cmDocumentationEntry> generators;
- hcm.GetGeneratorDocumentation(generators);
+ auto generators = hcm.GetGeneratorsDocumentation();
doc.SetName("ccmake");
doc.SetSection("Name", cmDocumentationName);
doc.SetSection("Usage", cmDocumentationUsage);
if (argc == 1) {
doc.AppendSection("Usage", cmDocumentationUsageNote);
}
- doc.SetSection("Generators", generators);
+ doc.AppendSection("Generators", generators);
doc.PrependSection("Options", cmDocumentationOptions);
return doc.PrintRequestedDocumentation(std::cout) ? 0 : 1;
}
@@ -106,7 +104,7 @@ int main(int argc, char const* const* argv)
if (strcmp(argv[j], "-debug") == 0) {
debug = true;
} else {
- args.push_back(argv[j]);
+ args.emplace_back(argv[j]);
}
}
@@ -131,7 +129,8 @@ int main(int argc, char const* const* argv)
signal(SIGWINCH, onsig);
- int x, y;
+ int x;
+ int y;
getmaxyx(stdscr, y, x);
if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
endwin();
@@ -154,7 +153,10 @@ int main(int argc, char const* const* argv)
return 1;
}
- cmSystemTools::SetMessageCallback(CMakeMessageHandler, myform);
+ cmSystemTools::SetMessageCallback(
+ [myform](const std::string& message, const char* title) {
+ myform->AddError(message, title);
+ });
cmCursesForm::CurrentForm = myform;
@@ -169,7 +171,7 @@ int main(int argc, char const* const* argv)
touchwin(stdscr);
endwin();
delete cmCursesForm::CurrentForm;
- cmCursesForm::CurrentForm = CM_NULLPTR;
+ cmCursesForm::CurrentForm = nullptr;
std::cout << std::endl << std::endl;
diff --git a/Source/CursesDialog/cmCursesBoolWidget.cxx b/Source/CursesDialog/cmCursesBoolWidget.cxx
index 80a5b5b9c..97b081128 100644
--- a/Source/CursesDialog/cmCursesBoolWidget.cxx
+++ b/Source/CursesDialog/cmCursesBoolWidget.cxx
@@ -2,11 +2,11 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCursesBoolWidget.h"
+#include <string>
+
#include "cmCursesWidget.h"
#include "cmStateTypes.h"
-#include <string>
-
cmCursesBoolWidget::cmCursesBoolWidget(int width, int height, int left,
int top)
: cmCursesWidget(width, height, left, top)
diff --git a/Source/CursesDialog/cmCursesBoolWidget.h b/Source/CursesDialog/cmCursesBoolWidget.h
index 90bcc2209..8c9625635 100644
--- a/Source/CursesDialog/cmCursesBoolWidget.h
+++ b/Source/CursesDialog/cmCursesBoolWidget.h
@@ -3,7 +3,7 @@
#ifndef cmCursesBoolWidget_h
#define cmCursesBoolWidget_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include "cmCursesStandardIncludes.h"
#include "cmCursesWidget.h"
@@ -12,16 +12,17 @@ class cmCursesMainForm;
class cmCursesBoolWidget : public cmCursesWidget
{
- CM_DISABLE_COPY(cmCursesBoolWidget)
-
public:
cmCursesBoolWidget(int width, int height, int left, int top);
+ cmCursesBoolWidget(cmCursesBoolWidget const&) = delete;
+ cmCursesBoolWidget& operator=(cmCursesBoolWidget const&) = delete;
+
// Description:
// Handle user input. Called by the container of this widget
// when this widget has focus. Returns true if the input was
// handled.
- bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) CM_OVERRIDE;
+ bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) override;
// Description:
// Set/Get the value (on/off).
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
index d071c9178..4d3131b07 100644
--- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
+++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
@@ -2,6 +2,12 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCursesCacheEntryComposite.h"
+#include <cassert>
+#include <utility>
+#include <vector>
+
+#include <cm/memory>
+
#include "cmCursesBoolWidget.h"
#include "cmCursesFilePathWidget.h"
#include "cmCursesLabelWidget.h"
@@ -11,11 +17,8 @@
#include "cmCursesWidget.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-
-#include <assert.h>
-#include <vector>
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
const std::string& key, int labelwidth, int entrywidth)
@@ -23,68 +26,70 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
, LabelWidth(labelwidth)
, EntryWidth(entrywidth)
{
- this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
- this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
- this->Entry = CM_NULLPTR;
- this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1);
+ this->Label =
+ cm::make_unique<cmCursesLabelWidget>(this->LabelWidth, 1, 1, 1, key);
+ this->IsNewLabel = cm::make_unique<cmCursesLabelWidget>(1, 1, 1, 1, " ");
+ this->Entry =
+ cm::make_unique<cmCursesStringWidget>(this->EntryWidth, 1, 1, 1);
}
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
- const std::string& key, cmake* cm, bool isNew, int labelwidth,
+ const std::string& key, cmState* state, bool isNew, int labelwidth,
int entrywidth)
: Key(key)
, LabelWidth(labelwidth)
, EntryWidth(entrywidth)
{
- this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
+ this->Label =
+ cm::make_unique<cmCursesLabelWidget>(this->LabelWidth, 1, 1, 1, key);
if (isNew) {
- this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, "*");
+ this->IsNewLabel = cm::make_unique<cmCursesLabelWidget>(1, 1, 1, 1, "*");
} else {
- this->IsNewLabel = new cmCursesLabelWidget(1, 1, 1, 1, " ");
+ this->IsNewLabel = cm::make_unique<cmCursesLabelWidget>(1, 1, 1, 1, " ");
}
- this->Entry = CM_NULLPTR;
- const char* value = cm->GetState()->GetCacheEntryValue(key);
+ const char* value = state->GetCacheEntryValue(key);
assert(value);
- switch (cm->GetState()->GetCacheEntryType(key)) {
- case cmStateEnums::BOOL:
- this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1);
- if (cmSystemTools::IsOn(value)) {
- static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(true);
- } else {
- static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(false);
- }
+ switch (state->GetCacheEntryType(key)) {
+ case cmStateEnums::BOOL: {
+ auto bw = cm::make_unique<cmCursesBoolWidget>(this->EntryWidth, 1, 1, 1);
+ bw->SetValueAsBool(cmIsOn(value));
+ this->Entry = std::move(bw);
break;
- case cmStateEnums::PATH:
- this->Entry = new cmCursesPathWidget(this->EntryWidth, 1, 1, 1);
- static_cast<cmCursesPathWidget*>(this->Entry)->SetString(value);
+ }
+ case cmStateEnums::PATH: {
+ auto pw = cm::make_unique<cmCursesPathWidget>(this->EntryWidth, 1, 1, 1);
+ pw->SetString(value);
+ this->Entry = std::move(pw);
break;
- case cmStateEnums::FILEPATH:
- this->Entry = new cmCursesFilePathWidget(this->EntryWidth, 1, 1, 1);
- static_cast<cmCursesFilePathWidget*>(this->Entry)->SetString(value);
+ }
+ case cmStateEnums::FILEPATH: {
+ auto fpw =
+ cm::make_unique<cmCursesFilePathWidget>(this->EntryWidth, 1, 1, 1);
+ fpw->SetString(value);
+ this->Entry = std::move(fpw);
break;
+ }
case cmStateEnums::STRING: {
- const char* stringsProp =
- cm->GetState()->GetCacheEntryProperty(key, "STRINGS");
+ const char* stringsProp = state->GetCacheEntryProperty(key, "STRINGS");
if (stringsProp) {
- cmCursesOptionsWidget* ow =
- new cmCursesOptionsWidget(this->EntryWidth, 1, 1, 1);
- this->Entry = ow;
- std::vector<std::string> options;
- cmSystemTools::ExpandListArgument(stringsProp, options);
- for (std::vector<std::string>::iterator si = options.begin();
- si != options.end(); ++si) {
- ow->AddOption(*si);
+ auto ow =
+ cm::make_unique<cmCursesOptionsWidget>(this->EntryWidth, 1, 1, 1);
+ for (std::string const& opt : cmExpandedList(stringsProp)) {
+ ow->AddOption(opt);
}
ow->SetOption(value);
+ this->Entry = std::move(ow);
} else {
- this->Entry = new cmCursesStringWidget(this->EntryWidth, 1, 1, 1);
- static_cast<cmCursesStringWidget*>(this->Entry)->SetString(value);
+ auto sw =
+ cm::make_unique<cmCursesStringWidget>(this->EntryWidth, 1, 1, 1);
+ sw->SetString(value);
+ this->Entry = std::move(sw);
}
break;
}
case cmStateEnums::UNINITIALIZED:
- cmSystemTools::Error("Found an undefined variable: ", key.c_str());
+ cmSystemTools::Error("Found an undefined variable: " + key);
break;
default:
// TODO : put warning message here
@@ -92,17 +97,12 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
}
}
-cmCursesCacheEntryComposite::~cmCursesCacheEntryComposite()
-{
- delete this->Label;
- delete this->IsNewLabel;
- delete this->Entry;
-}
+cmCursesCacheEntryComposite::~cmCursesCacheEntryComposite() = default;
const char* cmCursesCacheEntryComposite::GetValue()
{
if (this->Label) {
return this->Label->GetValue();
}
- return CM_NULLPTR;
+ return nullptr;
}
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h
index 3c500785d..a71136331 100644
--- a/Source/CursesDialog/cmCursesCacheEntryComposite.h
+++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h
@@ -3,32 +3,40 @@
#ifndef cmCursesCacheEntryComposite_h
#define cmCursesCacheEntryComposite_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <memory>
#include <string>
class cmCursesLabelWidget;
class cmCursesWidget;
-class cmake;
+class cmState;
class cmCursesCacheEntryComposite
{
- CM_DISABLE_COPY(cmCursesCacheEntryComposite)
-
public:
cmCursesCacheEntryComposite(const std::string& key, int labelwidth,
int entrywidth);
- cmCursesCacheEntryComposite(const std::string& key, cmake* cm, bool isNew,
- int labelwidth, int entrywidth);
+ cmCursesCacheEntryComposite(const std::string& key, cmState* state,
+ bool isNew, int labelwidth, int entrywidth);
~cmCursesCacheEntryComposite();
+
+ cmCursesCacheEntryComposite(cmCursesCacheEntryComposite const&) = delete;
+ cmCursesCacheEntryComposite& operator=(cmCursesCacheEntryComposite const&) =
+ delete;
+
+ cmCursesCacheEntryComposite(cmCursesCacheEntryComposite&&) = default;
+ cmCursesCacheEntryComposite& operator=(cmCursesCacheEntryComposite&&) =
+ default;
+
const char* GetValue();
friend class cmCursesMainForm;
protected:
- cmCursesLabelWidget* Label;
- cmCursesLabelWidget* IsNewLabel;
- cmCursesWidget* Entry;
+ std::unique_ptr<cmCursesLabelWidget> Label;
+ std::unique_ptr<cmCursesLabelWidget> IsNewLabel;
+ std::unique_ptr<cmCursesWidget> Entry;
std::string Key;
int LabelWidth;
int EntryWidth;
diff --git a/Source/CursesDialog/cmCursesDummyWidget.h b/Source/CursesDialog/cmCursesDummyWidget.h
index d9bb6babc..07b7288ab 100644
--- a/Source/CursesDialog/cmCursesDummyWidget.h
+++ b/Source/CursesDialog/cmCursesDummyWidget.h
@@ -3,7 +3,7 @@
#ifndef cmCursesDummyWidget_h
#define cmCursesDummyWidget_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include "cmCursesStandardIncludes.h"
#include "cmCursesWidget.h"
@@ -12,16 +12,17 @@ class cmCursesMainForm;
class cmCursesDummyWidget : public cmCursesWidget
{
- CM_DISABLE_COPY(cmCursesDummyWidget)
-
public:
cmCursesDummyWidget(int width, int height, int left, int top);
+ cmCursesDummyWidget(cmCursesDummyWidget const&) = delete;
+ cmCursesDummyWidget& operator=(cmCursesDummyWidget const&) = delete;
+
// Description:
// Handle user input. Called by the container of this widget
// when this widget has focus. Returns true if the input was
// handled.
- bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) CM_OVERRIDE;
+ bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) override;
};
#endif // cmCursesDummyWidget_h
diff --git a/Source/CursesDialog/cmCursesFilePathWidget.h b/Source/CursesDialog/cmCursesFilePathWidget.h
index 6ad535b99..3f71259d5 100644
--- a/Source/CursesDialog/cmCursesFilePathWidget.h
+++ b/Source/CursesDialog/cmCursesFilePathWidget.h
@@ -3,16 +3,17 @@
#ifndef cmCursesFilePathWidget_h
#define cmCursesFilePathWidget_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include "cmCursesPathWidget.h"
class cmCursesFilePathWidget : public cmCursesPathWidget
{
- CM_DISABLE_COPY(cmCursesFilePathWidget)
-
public:
cmCursesFilePathWidget(int width, int height, int left, int top);
+
+ cmCursesFilePathWidget(cmCursesFilePathWidget const&) = delete;
+ cmCursesFilePathWidget& operator=(cmCursesFilePathWidget const&) = delete;
};
#endif // cmCursesFilePathWidget_h
diff --git a/Source/CursesDialog/cmCursesForm.cxx b/Source/CursesDialog/cmCursesForm.cxx
index 06c1e9c70..bd65c4a08 100644
--- a/Source/CursesDialog/cmCursesForm.cxx
+++ b/Source/CursesDialog/cmCursesForm.cxx
@@ -7,7 +7,7 @@ bool cmCursesForm::Debug = false;
cmCursesForm::cmCursesForm()
{
- this->Form = CM_NULLPTR;
+ this->Form = nullptr;
}
cmCursesForm::~cmCursesForm()
@@ -15,7 +15,7 @@ cmCursesForm::~cmCursesForm()
if (this->Form) {
unpost_form(this->Form);
free_form(this->Form);
- this->Form = CM_NULLPTR;
+ this->Form = nullptr;
}
}
diff --git a/Source/CursesDialog/cmCursesForm.h b/Source/CursesDialog/cmCursesForm.h
index 553105c76..e3626e66a 100644
--- a/Source/CursesDialog/cmCursesForm.h
+++ b/Source/CursesDialog/cmCursesForm.h
@@ -3,20 +3,23 @@
#ifndef cmCursesForm_h
#define cmCursesForm_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmCursesStandardIncludes.h"
+#include <string>
#include "cmsys/FStream.hxx"
+#include "cmCursesStandardIncludes.h"
+
class cmCursesForm
{
- CM_DISABLE_COPY(cmCursesForm)
-
public:
cmCursesForm();
virtual ~cmCursesForm();
+ cmCursesForm(cmCursesForm const&) = delete;
+ cmCursesForm& operator=(cmCursesForm const&) = delete;
+
// Description:
// Handle user input.
virtual void HandleInput() = 0;
@@ -33,7 +36,7 @@ public:
// Description:
// During a CMake run, an error handle should add errors
// to be displayed afterwards.
- virtual void AddError(const char*, const char*) {}
+ virtual void AddError(const std::string&, const char*) {}
// Description:
// Turn debugging on. This will create ccmakelog.txt.
diff --git a/Source/CursesDialog/cmCursesLabelWidget.cxx b/Source/CursesDialog/cmCursesLabelWidget.cxx
index 1dfd4ce47..83aea5a2c 100644
--- a/Source/CursesDialog/cmCursesLabelWidget.cxx
+++ b/Source/CursesDialog/cmCursesLabelWidget.cxx
@@ -14,9 +14,7 @@ cmCursesLabelWidget::cmCursesLabelWidget(int width, int height, int left,
this->SetValue(name);
}
-cmCursesLabelWidget::~cmCursesLabelWidget()
-{
-}
+cmCursesLabelWidget::~cmCursesLabelWidget() = default;
bool cmCursesLabelWidget::HandleInput(int& /*key*/, cmCursesMainForm* /*fm*/,
WINDOW* /*w*/)
diff --git a/Source/CursesDialog/cmCursesLabelWidget.h b/Source/CursesDialog/cmCursesLabelWidget.h
index 267de7c8c..9e7568187 100644
--- a/Source/CursesDialog/cmCursesLabelWidget.h
+++ b/Source/CursesDialog/cmCursesLabelWidget.h
@@ -3,29 +3,30 @@
#ifndef cmCursesLabelWidget_h
#define cmCursesLabelWidget_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
#include "cmCursesStandardIncludes.h"
#include "cmCursesWidget.h"
-#include <string>
-
class cmCursesMainForm;
class cmCursesLabelWidget : public cmCursesWidget
{
- CM_DISABLE_COPY(cmCursesLabelWidget)
-
public:
cmCursesLabelWidget(int width, int height, int left, int top,
const std::string& name);
- ~cmCursesLabelWidget() CM_OVERRIDE;
+ ~cmCursesLabelWidget() override;
+
+ cmCursesLabelWidget(cmCursesLabelWidget const&) = delete;
+ cmCursesLabelWidget& operator=(cmCursesLabelWidget const&) = delete;
// Description:
// Handle user input. Called by the container of this widget
// when this widget has focus. Returns true if the input was
// handled
- bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) CM_OVERRIDE;
+ bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) override;
};
#endif // cmCursesLabelWidget_h
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx
index 7fb065d30..e2d8d06b4 100644
--- a/Source/CursesDialog/cmCursesLongMessageForm.cxx
+++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx
@@ -2,14 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCursesLongMessageForm.h"
+#include <cstdio>
+#include <cstring>
+
#include "cmCursesForm.h"
#include "cmCursesMainForm.h"
#include "cmCursesStandardIncludes.h"
#include "cmVersion.h"
-#include <stdio.h>
-#include <string.h>
-
inline int ctrl(int z)
{
return (z & 037);
@@ -19,15 +19,14 @@ cmCursesLongMessageForm::cmCursesLongMessageForm(
std::vector<std::string> const& messages, const char* title)
{
// Append all messages into on big string
- std::vector<std::string>::const_iterator it;
- for (it = messages.begin(); it != messages.end(); it++) {
- this->Messages += (*it);
+ for (std::string const& message : messages) {
+ this->Messages += message;
// Add one blank line after each message
this->Messages += "\n\n";
}
this->Title = title;
- this->Fields[0] = CM_NULLPTR;
- this->Fields[1] = CM_NULLPTR;
+ this->Fields[0] = nullptr;
+ this->Fields[1] = nullptr;
}
cmCursesLongMessageForm::~cmCursesLongMessageForm()
@@ -39,11 +38,12 @@ cmCursesLongMessageForm::~cmCursesLongMessageForm()
void cmCursesLongMessageForm::UpdateStatusBar()
{
- int x, y;
+ int x;
+ int y;
getmaxyx(stdscr, y, x);
char bar[cmCursesMainForm::MAX_WIDTH];
- size_t size = strlen(this->Title.c_str());
+ size_t size = this->Title.size();
if (size >= cmCursesMainForm::MAX_WIDTH) {
size = cmCursesMainForm::MAX_WIDTH - 1;
}
@@ -82,7 +82,8 @@ void cmCursesLongMessageForm::UpdateStatusBar()
void cmCursesLongMessageForm::PrintKeys()
{
- int x, y;
+ int x;
+ int y;
getmaxyx(stdscr, y, x);
if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
return;
@@ -99,13 +100,14 @@ void cmCursesLongMessageForm::PrintKeys()
void cmCursesLongMessageForm::Render(int /*left*/, int /*top*/, int /*width*/,
int /*height*/)
{
- int x, y;
+ int x;
+ int y;
getmaxyx(stdscr, y, x);
if (this->Form) {
unpost_form(this->Form);
free_form(this->Form);
- this->Form = CM_NULLPTR;
+ this->Form = nullptr;
}
const char* msg = this->Messages.c_str();
@@ -114,7 +116,7 @@ void cmCursesLongMessageForm::Render(int /*left*/, int /*top*/, int /*width*/,
if (this->Fields[0]) {
free_field(this->Fields[0]);
- this->Fields[0] = CM_NULLPTR;
+ this->Fields[0] = nullptr;
}
this->Fields[0] = new_field(y - 6, x - 2, 1, 1, 0, 0);
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.h b/Source/CursesDialog/cmCursesLongMessageForm.h
index cd8e0953a..42f9c710b 100644
--- a/Source/CursesDialog/cmCursesLongMessageForm.h
+++ b/Source/CursesDialog/cmCursesLongMessageForm.h
@@ -3,31 +3,32 @@
#ifndef cmCursesLongMessageForm_h
#define cmCursesLongMessageForm_h
-#include "cmConfigure.h"
-
-#include "cmCursesForm.h"
-#include "cmCursesStandardIncludes.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
+#include "cmCursesForm.h"
+#include "cmCursesStandardIncludes.h"
+
class cmCursesLongMessageForm : public cmCursesForm
{
- CM_DISABLE_COPY(cmCursesLongMessageForm)
-
public:
cmCursesLongMessageForm(std::vector<std::string> const& messages,
const char* title);
- ~cmCursesLongMessageForm() CM_OVERRIDE;
+ ~cmCursesLongMessageForm() override;
+
+ cmCursesLongMessageForm(cmCursesLongMessageForm const&) = delete;
+ cmCursesLongMessageForm& operator=(cmCursesLongMessageForm const&) = delete;
// Description:
// Handle user input.
- void HandleInput() CM_OVERRIDE;
+ void HandleInput() override;
// Description:
// Display form. Use a window of size width x height, starting
// at top, left.
- void Render(int left, int top, int width, int height) CM_OVERRIDE;
+ void Render(int left, int top, int width, int height) override;
// Description:
// This method should normally called only by the form.
@@ -37,7 +38,7 @@ public:
// Description:
// This method should normally called only by the form.
// The only exception is during a resize.
- void UpdateStatusBar() CM_OVERRIDE;
+ void UpdateStatusBar() override;
protected:
std::string Messages;
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 026320a1f..6b71e8a10 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -2,7 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCursesMainForm.h"
-#include "cmAlgorithms.h"
+#include <algorithm>
+#include <cstdio>
+#include <cstring>
+#include <utility>
+
+#include <cm/memory>
+
#include "cmCursesCacheEntryComposite.h"
#include "cmCursesDummyWidget.h"
#include "cmCursesForm.h"
@@ -13,44 +19,39 @@
#include "cmCursesWidget.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
#include "cmake.h"
-#include <stdio.h>
-#include <string.h>
-
inline int ctrl(int z)
{
return (z & 037);
}
-cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args,
+cmCursesMainForm::cmCursesMainForm(std::vector<std::string> args,
int initWidth)
- : Args(args)
+ : Args(std::move(args))
, InitialWidth(initWidth)
{
this->NumberOfPages = 0;
- this->Fields = CM_NULLPTR;
- this->Entries = CM_NULLPTR;
this->AdvancedMode = false;
this->NumberOfVisibleEntries = 0;
this->OkToGenerate = false;
- this->HelpMessage.push_back(
+ this->HelpMessage.emplace_back(
"Welcome to ccmake, curses based user interface for CMake.");
- this->HelpMessage.push_back("");
- this->HelpMessage.push_back(s_ConstHelpMessage);
- this->CMakeInstance = new cmake(cmake::RoleProject);
+ this->HelpMessage.emplace_back();
+ this->HelpMessage.emplace_back(s_ConstHelpMessage);
+ this->CMakeInstance =
+ cm::make_unique<cmake>(cmake::RoleProject, cmState::Project);
this->CMakeInstance->SetCMakeEditCommand(
cmSystemTools::GetCMakeCursesCommand());
// create the arguments for the cmake object
- std::string whereCMake = cmSystemTools::GetProgramPath(this->Args[0]);
- whereCMake += "/cmake";
+ std::string whereCMake =
+ cmStrCat(cmSystemTools::GetProgramPath(this->Args[0]), "/cmake");
this->Args[0] = whereCMake;
this->CMakeInstance->SetArgs(this->Args);
- this->SearchString = "";
- this->OldSearchString = "";
this->SearchMode = false;
}
@@ -59,36 +60,17 @@ cmCursesMainForm::~cmCursesMainForm()
if (this->Form) {
unpost_form(this->Form);
free_form(this->Form);
- this->Form = CM_NULLPTR;
- }
- delete[] this->Fields;
-
- // Clean-up composites
- if (this->Entries) {
- cmDeleteAll(*this->Entries);
- }
- delete this->Entries;
- if (this->CMakeInstance) {
- delete this->CMakeInstance;
- this->CMakeInstance = CM_NULLPTR;
+ this->Form = nullptr;
}
}
// See if a cache entry is in the list of entries in the ui.
bool cmCursesMainForm::LookForCacheEntry(const std::string& key)
{
- if (!this->Entries) {
- return false;
- }
-
- std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
- if (key == (*it)->Key) {
- return true;
- }
- }
-
- return false;
+ return std::any_of(this->Entries.begin(), this->Entries.end(),
+ [&key](cmCursesCacheEntryComposite const& entry) {
+ return key == entry.Key;
+ });
}
// Create new cmCursesCacheEntryComposite entries from the cache
@@ -96,19 +78,17 @@ void cmCursesMainForm::InitializeUI()
{
// Create a vector of cmCursesCacheEntryComposite's
// which contain labels, entries and new entry markers
- std::vector<cmCursesCacheEntryComposite*>* newEntries =
- new std::vector<cmCursesCacheEntryComposite*>;
+ std::vector<cmCursesCacheEntryComposite> newEntries;
std::vector<std::string> cacheKeys =
this->CMakeInstance->GetState()->GetCacheEntryKeys();
- newEntries->reserve(cacheKeys.size());
+ newEntries.reserve(cacheKeys.size());
// Count non-internal and non-static entries
int count = 0;
- for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it) {
+ for (std::string const& key : cacheKeys) {
cmStateEnums::CacheEntryType t =
- this->CMakeInstance->GetState()->GetCacheEntryType(*it);
+ this->CMakeInstance->GetState()->GetCacheEntryType(key);
if (t != cmStateEnums::INTERNAL && t != cmStateEnums::STATIC &&
t != cmStateEnums::UNINITIALIZED) {
++count;
@@ -117,58 +97,49 @@ void cmCursesMainForm::InitializeUI()
int entrywidth = this->InitialWidth - 35;
- cmCursesCacheEntryComposite* comp;
if (count == 0) {
// If cache is empty, display a label saying so and a
// dummy entry widget (does not respond to input)
- comp = new cmCursesCacheEntryComposite("EMPTY CACHE", 30, 30);
- comp->Entry = new cmCursesDummyWidget(1, 1, 1, 1);
- newEntries->push_back(comp);
+ cmCursesCacheEntryComposite comp("EMPTY CACHE", 30, 30);
+ comp.Entry = cm::make_unique<cmCursesDummyWidget>(1, 1, 1, 1);
+ newEntries.emplace_back(std::move(comp));
} else {
// Create the composites.
// First add entries which are new
- for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it) {
- std::string key = *it;
+ for (std::string const& key : cacheKeys) {
cmStateEnums::CacheEntryType t =
- this->CMakeInstance->GetState()->GetCacheEntryType(*it);
+ this->CMakeInstance->GetState()->GetCacheEntryType(key);
if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC ||
t == cmStateEnums::UNINITIALIZED) {
continue;
}
if (!this->LookForCacheEntry(key)) {
- newEntries->push_back(new cmCursesCacheEntryComposite(
- key, this->CMakeInstance, true, 30, entrywidth));
+ newEntries.emplace_back(key, this->CMakeInstance->GetState(), true, 30,
+ entrywidth);
this->OkToGenerate = false;
}
}
// then add entries which are old
- for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it) {
- std::string key = *it;
+ for (std::string const& key : cacheKeys) {
cmStateEnums::CacheEntryType t =
- this->CMakeInstance->GetState()->GetCacheEntryType(*it);
+ this->CMakeInstance->GetState()->GetCacheEntryType(key);
if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC ||
t == cmStateEnums::UNINITIALIZED) {
continue;
}
if (this->LookForCacheEntry(key)) {
- newEntries->push_back(new cmCursesCacheEntryComposite(
- key, this->CMakeInstance, false, 30, entrywidth));
+ newEntries.emplace_back(key, this->CMakeInstance->GetState(), false,
+ 30, entrywidth);
}
}
}
- // Clean old entries
- if (this->Entries) {
- cmDeleteAll(*this->Entries);
- }
- delete this->Entries;
- this->Entries = newEntries;
+ // Replace old entries
+ this->Entries = std::move(newEntries);
// Compute fields from composites
this->RePost();
@@ -180,21 +151,20 @@ void cmCursesMainForm::RePost()
if (this->Form) {
unpost_form(this->Form);
free_form(this->Form);
- this->Form = CM_NULLPTR;
+ this->Form = nullptr;
}
- delete[] this->Fields;
+ this->Fields.clear();
if (this->AdvancedMode) {
- this->NumberOfVisibleEntries = this->Entries->size();
+ this->NumberOfVisibleEntries = this->Entries.size();
} else {
// If normal mode, count only non-advanced entries
this->NumberOfVisibleEntries = 0;
- std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
+ for (cmCursesCacheEntryComposite& entry : this->Entries) {
const char* existingValue =
- this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
+ this->CMakeInstance->GetState()->GetCacheEntryValue(entry.GetValue());
bool advanced =
this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
- (*it)->GetValue(), "ADVANCED");
+ entry.GetValue(), "ADVANCED");
if (!existingValue || (!this->AdvancedMode && advanced)) {
continue;
}
@@ -207,39 +177,32 @@ void cmCursesMainForm::RePost()
}
// Assign the fields: 3 for each entry: label, new entry marker
// ('*' or ' ') and entry widget
- this->Fields = new FIELD*[3 * this->NumberOfVisibleEntries + 1];
- size_t cc;
- for (cc = 0; cc < 3 * this->NumberOfVisibleEntries + 1; cc++) {
- this->Fields[cc] = CM_NULLPTR;
- }
+ this->Fields.reserve(3 * this->NumberOfVisibleEntries + 1);
// Assign fields
- int j = 0;
- std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
+ for (cmCursesCacheEntryComposite& entry : this->Entries) {
const char* existingValue =
- this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
+ this->CMakeInstance->GetState()->GetCacheEntryValue(entry.GetValue());
bool advanced =
this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
- (*it)->GetValue(), "ADVANCED");
+ entry.GetValue(), "ADVANCED");
if (!existingValue || (!this->AdvancedMode && advanced)) {
continue;
}
- this->Fields[3 * j] = (*it)->Label->Field;
- this->Fields[3 * j + 1] = (*it)->IsNewLabel->Field;
- this->Fields[3 * j + 2] = (*it)->Entry->Field;
- j++;
+ this->Fields.push_back(entry.Label->Field);
+ this->Fields.push_back(entry.IsNewLabel->Field);
+ this->Fields.push_back(entry.Entry->Field);
}
// if no cache entries there should still be one dummy field
- if (j == 0) {
- it = this->Entries->begin();
- this->Fields[0] = (*it)->Label->Field;
- this->Fields[1] = (*it)->IsNewLabel->Field;
- this->Fields[2] = (*it)->Entry->Field;
+ if (this->Fields.empty()) {
+ const auto& front = this->Entries.front();
+ this->Fields.push_back(front.Label->Field);
+ this->Fields.push_back(front.IsNewLabel->Field);
+ this->Fields.push_back(front.Entry->Field);
this->NumberOfVisibleEntries = 1;
}
// Has to be null terminated.
- this->Fields[3 * this->NumberOfVisibleEntries] = CM_NULLPTR;
+ this->Fields.push_back(nullptr);
}
void cmCursesMainForm::Render(int left, int top, int width, int height)
@@ -259,7 +222,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
// Delete the previous form
unpost_form(this->Form);
free_form(this->Form);
- this->Form = CM_NULLPTR;
+ this->Form = nullptr;
}
// Wrong window size
@@ -272,17 +235,16 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
height -= 7;
if (this->AdvancedMode) {
- this->NumberOfVisibleEntries = this->Entries->size();
+ this->NumberOfVisibleEntries = this->Entries.size();
} else {
// If normal, display only non-advanced entries
this->NumberOfVisibleEntries = 0;
- std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
+ for (cmCursesCacheEntryComposite& entry : this->Entries) {
const char* existingValue =
- this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
+ this->CMakeInstance->GetState()->GetCacheEntryValue(entry.GetValue());
bool advanced =
this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
- (*it)->GetValue(), "ADVANCED");
+ entry.GetValue(), "ADVANCED");
if (!existingValue || (!this->AdvancedMode && advanced)) {
continue;
}
@@ -295,13 +257,12 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
if (height > 0) {
bool isNewPage;
int i = 0;
- std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
+ for (cmCursesCacheEntryComposite& entry : this->Entries) {
const char* existingValue =
- this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue());
+ this->CMakeInstance->GetState()->GetCacheEntryValue(entry.GetValue());
bool advanced =
this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool(
- (*it)->GetValue(), "ADVANCED");
+ entry.GetValue(), "ADVANCED");
if (!existingValue || (!this->AdvancedMode && advanced)) {
continue;
}
@@ -312,16 +273,16 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
if (isNewPage) {
this->NumberOfPages++;
}
- (*it)->Label->Move(left, top + row - 1, isNewPage);
- (*it)->IsNewLabel->Move(left + 32, top + row - 1, false);
- (*it)->Entry->Move(left + 33, top + row - 1, false);
- (*it)->Entry->SetPage(this->NumberOfPages);
+ entry.Label->Move(left, top + row - 1, isNewPage);
+ entry.IsNewLabel->Move(left + 32, top + row - 1, false);
+ entry.Entry->Move(left + 33, top + row - 1, false);
+ entry.Entry->SetPage(this->NumberOfPages);
i++;
}
}
// Post the form
- this->Form = new_form(this->Fields);
+ this->Form = new_form(this->Fields.data());
post_form(this->Form);
// Update toolbar
this->UpdateStatusBar();
@@ -333,7 +294,8 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
void cmCursesMainForm::PrintKeys(int process /* = 0 */)
{
- int x, y;
+ int x;
+ int y;
getmaxyx(stdscr, y, x);
if (x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth ||
y < cmCursesMainForm::MIN_HEIGHT) {
@@ -341,23 +303,21 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
}
// Give the current widget (if it exists), a chance to print keys
- cmCursesWidget* cw = CM_NULLPTR;
+ cmCursesWidget* cw = nullptr;
if (this->Form) {
FIELD* currentField = current_field(this->Form);
cw = reinterpret_cast<cmCursesWidget*>(field_userptr(currentField));
}
char fmt_s[] = "%s";
- if (cw == CM_NULLPTR || !cw->PrintKeys()) {
+ if (cw == nullptr || !cw->PrintKeys()) {
char firstLine[512] = "";
char secondLine[512] = "";
char thirdLine[512] = "";
if (process) {
- const char* clearLine =
- " ";
- strcpy(firstLine, clearLine);
- strcpy(secondLine, clearLine);
- strcpy(thirdLine, clearLine);
+ memset(firstLine, ' ', 68);
+ memset(secondLine, ' ', 68);
+ memset(thirdLine, ' ', 68);
} else {
if (this->OkToGenerate) {
sprintf(firstLine,
@@ -372,15 +332,16 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
sprintf(thirdLine, toggleKeyInstruction,
this->AdvancedMode ? "On" : "Off");
}
- sprintf(secondLine, "Press [h] for help "
- "Press [q] to quit without generating");
+ sprintf(secondLine,
+ "Press [h] for help "
+ "Press [q] to quit without generating");
}
curses_move(y - 4, 0);
char fmt[512] =
"Press [enter] to edit option Press [d] to delete an entry";
if (process) {
- strcpy(fmt, " ");
+ memset(fmt, ' ', 57);
}
printw(fmt_s, fmt);
curses_move(y - 3, 0);
@@ -405,7 +366,8 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
// on the status bar. Designed for a width of 80 chars.
void cmCursesMainForm::UpdateStatusBar(const char* message)
{
- int x, y;
+ int x;
+ int y;
getmaxyx(stdscr, y, x);
// If window size is too small, display error and return
if (x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth ||
@@ -413,9 +375,10 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
curses_clear();
curses_move(0, 0);
char fmt[] = "Window is too small. A size of at least %dx%d is required.";
- printw(fmt, (cmCursesMainForm::MIN_WIDTH < this->InitialWidth
- ? this->InitialWidth
- : cmCursesMainForm::MIN_WIDTH),
+ printw(fmt,
+ (cmCursesMainForm::MIN_WIDTH < this->InitialWidth
+ ? this->InitialWidth
+ : cmCursesMainForm::MIN_WIDTH),
cmCursesMainForm::MIN_HEIGHT);
touchwin(stdscr);
wrefresh(stdscr);
@@ -425,7 +388,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
// Get the key of the current entry
FIELD* cur = current_field(this->Form);
int findex = field_index(cur);
- cmCursesWidget* lbl = CM_NULLPTR;
+ cmCursesWidget* lbl = nullptr;
if (findex >= 0) {
lbl = reinterpret_cast<cmCursesWidget*>(
field_userptr(this->Fields[findex - 2]));
@@ -456,41 +419,27 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
// Join the key, help string and pad with spaces
// (or truncate) as necessary
char bar[cmCursesMainForm::MAX_WIDTH];
- size_t i, curFieldLen = strlen(curField);
+ size_t curFieldLen = strlen(curField);
size_t helpLen = strlen(help);
- size_t width;
- if (x < cmCursesMainForm::MAX_WIDTH) {
- width = x;
- } else {
- width = cmCursesMainForm::MAX_WIDTH;
- }
+ size_t width = std::min<size_t>(x, cmCursesMainForm::MAX_WIDTH);
if (message) {
curField = message;
curFieldLen = strlen(message);
+ strncpy(bar, curField, width);
if (curFieldLen < width) {
- strcpy(bar, curField);
- for (i = curFieldLen; i < width; ++i) {
- bar[i] = ' ';
- }
- } else {
- strncpy(bar, curField, width);
+ memset(bar + curFieldLen, ' ', width - curFieldLen);
}
} else {
- if (curFieldLen >= width) {
- strncpy(bar, curField, width);
- } else {
- strcpy(bar, curField);
+ strncpy(bar, curField, width);
+ if (curFieldLen < width) {
bar[curFieldLen] = ':';
bar[curFieldLen + 1] = ' ';
- if (curFieldLen + helpLen + 2 >= width) {
- strncpy(bar + curFieldLen + 2, help, width - curFieldLen - 2);
- } else {
- strcpy(bar + curFieldLen + 2, help);
- for (i = curFieldLen + helpLen + 2; i < width; ++i) {
- bar[i] = ' ';
- }
+ strncpy(bar + curFieldLen + 2, help, width - curFieldLen - 2);
+ if (curFieldLen + helpLen + 2 < width) {
+ memset(bar + curFieldLen + helpLen + 2, ' ',
+ width - (curFieldLen + helpLen + 2));
}
}
}
@@ -503,9 +452,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
char vertmp[128];
sprintf(vertmp, "CMake Version %s", cmVersion::GetCMakeVersion());
size_t sideSpace = (width - strlen(vertmp));
- for (i = 0; i < sideSpace; i++) {
- version[i] = ' ';
- }
+ memset(version, ' ', sideSpace);
sprintf(version + sideSpace, "%s", vertmp);
version[width] = '\0';
@@ -520,21 +467,17 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
pos_form_cursor(this->Form);
}
-void cmCursesMainForm::UpdateProgress(const char* msg, float prog, void* vp)
+void cmCursesMainForm::UpdateProgress(const std::string& msg, float prog)
{
- cmCursesMainForm* cm = static_cast<cmCursesMainForm*>(vp);
- if (!cm) {
- return;
- }
char tmp[1024];
const char* cmsg = tmp;
if (prog >= 0) {
- sprintf(tmp, "%s %i%%", msg, (int)(100 * prog));
+ sprintf(tmp, "%s %i%%", msg.c_str(), static_cast<int>(100 * prog));
} else {
- cmsg = msg;
+ cmsg = msg.c_str();
}
- cm->UpdateStatusBar(cmsg);
- cm->PrintKeys(1);
+ this->UpdateStatusBar(cmsg);
+ this->PrintKeys(1);
curses_move(1, 1);
touchwin(stdscr);
refresh();
@@ -542,7 +485,8 @@ void cmCursesMainForm::UpdateProgress(const char* msg, float prog, void* vp)
int cmCursesMainForm::Configure(int noconfigure)
{
- int xi, yi;
+ int xi;
+ int yi;
getmaxyx(stdscr, yi, xi);
curses_move(1, 1);
@@ -550,14 +494,16 @@ int cmCursesMainForm::Configure(int noconfigure)
this->PrintKeys(1);
touchwin(stdscr);
refresh();
- this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress,
- this);
+ this->CMakeInstance->SetProgressCallback(
+ [this](const std::string& msg, float prog) {
+ this->UpdateProgress(msg, prog);
+ });
// always save the current gui values to disk
this->FillCacheManagerFromUI();
this->CMakeInstance->SaveCache(
this->CMakeInstance->GetHomeOutputDirectory());
- this->LoadCache(CM_NULLPTR);
+ this->LoadCache(nullptr);
// Get rid of previous errors
this->Errors = std::vector<std::string>();
@@ -574,7 +520,7 @@ int cmCursesMainForm::Configure(int noconfigure)
} else {
retVal = this->CMakeInstance->Configure();
}
- this->CMakeInstance->SetProgressCallback(CM_NULLPTR, CM_NULLPTR);
+ this->CMakeInstance->SetProgressCallback(nullptr);
keypad(stdscr, true); /* Use key symbols as KEY_DOWN */
@@ -583,12 +529,14 @@ int cmCursesMainForm::Configure(int noconfigure)
if (cmSystemTools::GetErrorOccuredFlag()) {
this->OkToGenerate = false;
}
- int xx, yy;
+ int xx;
+ int yy;
getmaxyx(stdscr, yy, xx);
- cmCursesLongMessageForm* msgs = new cmCursesLongMessageForm(
- this->Errors, cmSystemTools::GetErrorOccuredFlag()
- ? "Errors occurred during the last pass."
- : "CMake produced the following output.");
+ cmCursesLongMessageForm* msgs =
+ new cmCursesLongMessageForm(this->Errors,
+ cmSystemTools::GetErrorOccuredFlag()
+ ? "Errors occurred during the last pass."
+ : "CMake produced the following output.");
// reset error condition
cmSystemTools::ResetErrorOccuredFlag();
CurrentForm = msgs;
@@ -611,7 +559,8 @@ int cmCursesMainForm::Configure(int noconfigure)
int cmCursesMainForm::Generate()
{
- int xi, yi;
+ int xi;
+ int yi;
getmaxyx(stdscr, yi, xi);
curses_move(1, 1);
@@ -619,8 +568,10 @@ int cmCursesMainForm::Generate()
this->PrintKeys(1);
touchwin(stdscr);
refresh();
- this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress,
- this);
+ this->CMakeInstance->SetProgressCallback(
+ [this](const std::string& msg, float prog) {
+ this->UpdateProgress(msg, prog);
+ });
// Get rid of previous errors
this->Errors = std::vector<std::string>();
@@ -628,7 +579,7 @@ int cmCursesMainForm::Generate()
// run the generate process
int retVal = this->CMakeInstance->Generate();
- this->CMakeInstance->SetProgressCallback(CM_NULLPTR, CM_NULLPTR);
+ this->CMakeInstance->SetProgressCallback(nullptr);
keypad(stdscr, true); /* Use key symbols as KEY_DOWN */
if (retVal != 0 || !this->Errors.empty()) {
@@ -638,7 +589,8 @@ int cmCursesMainForm::Generate()
}
// reset error condition
cmSystemTools::ResetErrorOccuredFlag();
- int xx, yy;
+ int xx;
+ int yy;
getmaxyx(stdscr, yy, xx);
const char* title = "Messages during last pass.";
if (cmSystemTools::GetErrorOccuredFlag()) {
@@ -664,9 +616,10 @@ int cmCursesMainForm::Generate()
return 0;
}
-void cmCursesMainForm::AddError(const char* message, const char* /*unused*/)
+void cmCursesMainForm::AddError(const std::string& message,
+ const char* /*unused*/)
{
- this->Errors.push_back(message);
+ this->Errors.emplace_back(message);
}
void cmCursesMainForm::RemoveEntry(const char* value)
@@ -675,28 +628,29 @@ void cmCursesMainForm::RemoveEntry(const char* value)
return;
}
- std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it) {
- const char* val = (*it)->GetValue();
- if (val && !strcmp(value, val)) {
- this->CMakeInstance->UnwatchUnusedCli(value);
- this->Entries->erase(it);
- break;
- }
+ auto removeIt =
+ std::find_if(this->Entries.begin(), this->Entries.end(),
+ [value](cmCursesCacheEntryComposite& entry) -> bool {
+ const char* val = entry.GetValue();
+ return val != nullptr && !strcmp(value, val);
+ });
+
+ if (removeIt != this->Entries.end()) {
+ this->CMakeInstance->UnwatchUnusedCli(value);
+ this->Entries.erase(removeIt);
}
}
// copy from the list box to the cache manager
void cmCursesMainForm::FillCacheManagerFromUI()
{
- size_t size = this->Entries->size();
- for (size_t i = 0; i < size; i++) {
- std::string cacheKey = (*this->Entries)[i]->Key;
+ for (cmCursesCacheEntryComposite& entry : this->Entries) {
+ const std::string& cacheKey = entry.Key;
const char* existingValue =
this->CMakeInstance->GetState()->GetCacheEntryValue(cacheKey);
if (existingValue) {
std::string oldValue = existingValue;
- std::string newValue = (*this->Entries)[i]->Entry->GetValue();
+ std::string newValue = entry.Entry->GetValue();
std::string fixedOldValue;
std::string fixedNewValue;
cmStateEnums::CacheEntryType t =
@@ -723,7 +677,7 @@ void cmCursesMainForm::FixValue(cmStateEnums::CacheEntryType type,
cmSystemTools::ConvertToUnixSlashes(out);
}
if (type == cmStateEnums::BOOL) {
- if (cmSystemTools::IsOff(out.c_str())) {
+ if (cmIsOff(out)) {
out = "OFF";
} else {
out = "ON";
@@ -733,7 +687,8 @@ void cmCursesMainForm::FixValue(cmStateEnums::CacheEntryType type,
void cmCursesMainForm::HandleInput()
{
- int x = 0, y = 0;
+ int x = 0;
+ int y = 0;
if (!this->Form) {
return;
@@ -781,7 +736,7 @@ void cmCursesMainForm::HandleInput()
this->JumpToCacheEntry(this->SearchString.c_str());
this->OldSearchString = this->SearchString;
}
- this->SearchString = "";
+ this->SearchString.clear();
}
/*
else if ( key == KEY_ESCAPE )
@@ -797,7 +752,7 @@ void cmCursesMainForm::HandleInput()
}
} else if (key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC) {
if (!this->SearchString.empty()) {
- this->SearchString.resize(this->SearchString.size() - 1);
+ this->SearchString.pop_back();
}
}
} else if (currentWidget && !this->SearchMode) {
@@ -877,7 +832,7 @@ void cmCursesMainForm::HandleInput()
cmCursesWidget* lbl = reinterpret_cast<cmCursesWidget*>(
field_userptr(this->Fields[findex - 2]));
const char* curField = lbl->GetValue();
- const char* helpString = CM_NULLPTR;
+ const char* helpString = nullptr;
const char* existingValue =
this->CMakeInstance->GetState()->GetCacheEntryValue(curField);
@@ -886,17 +841,9 @@ void cmCursesMainForm::HandleInput()
curField, "HELPSTRING");
}
if (helpString) {
- char* message = new char
- [strlen(curField) + strlen(helpString) +
- strlen(
- "Current option is: \n Help string for this option is: \n") +
- 10];
- sprintf(
- message,
- "Current option is: %s\nHelp string for this option is: %s\n",
- curField, helpString);
- this->HelpMessage[1] = message;
- delete[] message;
+ this->HelpMessage[1] =
+ cmStrCat("Current option is: ", curField, '\n',
+ "Help string for this option is: ", helpString, '\n');
} else {
this->HelpMessage[1] = "";
}
@@ -962,7 +909,7 @@ void cmCursesMainForm::HandleInput()
// (findex always corresponds to the value field)
FIELD* nextCur;
if (findex == 2) {
- nextCur = CM_NULLPTR;
+ nextCur = nullptr;
} else if (findex == 3 * this->NumberOfVisibleEntries - 1) {
nextCur = this->Fields[findex - 5];
} else {
@@ -992,17 +939,14 @@ void cmCursesMainForm::HandleInput()
if (nextCur) {
// make the next or prev. current field after deletion
- nextCur = CM_NULLPTR;
- std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end();
- ++it) {
- if (nextVal == (*it)->Key) {
- nextCur = (*it)->Entry->Field;
- }
- }
-
- if (nextCur) {
- set_current_field(this->Form, nextCur);
+ auto nextEntryIt = std::find_if(
+ this->Entries.begin(), this->Entries.end(),
+ [&nextVal](cmCursesCacheEntryComposite const& entry) {
+ return nextVal == entry.Key;
+ });
+
+ if (nextEntryIt != this->Entries.end()) {
+ set_current_field(this->Form, nextEntryIt->Entry->Field);
}
}
}
@@ -1041,7 +985,7 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr)
int findex = start_index;
for (;;) {
if (!str.empty()) {
- cmCursesWidget* lbl = CM_NULLPTR;
+ cmCursesWidget* lbl = nullptr;
if (findex >= 0) {
lbl = reinterpret_cast<cmCursesWidget*>(
field_userptr(this->Fields[findex - 2]));
diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h
index e35cf3ed7..b8769b7cf 100644
--- a/Source/CursesDialog/cmCursesMainForm.h
+++ b/Source/CursesDialog/cmCursesMainForm.h
@@ -3,17 +3,18 @@
#ifndef cmCursesMainForm_h
#define cmCursesMainForm_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <cstddef>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "cmCursesCacheEntryComposite.h"
#include "cmCursesForm.h"
#include "cmCursesStandardIncludes.h"
#include "cmStateTypes.h"
-#include <stddef.h>
-#include <string>
-#include <vector>
-
-class cmCursesCacheEntryComposite;
class cmake;
/** \class cmCursesMainForm
@@ -23,11 +24,12 @@ class cmake;
*/
class cmCursesMainForm : public cmCursesForm
{
- CM_DISABLE_COPY(cmCursesMainForm)
-
public:
- cmCursesMainForm(std::vector<std::string> const& args, int initwidth);
- ~cmCursesMainForm() CM_OVERRIDE;
+ cmCursesMainForm(std::vector<std::string> args, int initwidth);
+ ~cmCursesMainForm() override;
+
+ cmCursesMainForm(cmCursesMainForm const&) = delete;
+ cmCursesMainForm& operator=(cmCursesMainForm const&) = delete;
/**
* Set the widgets which represent the cache entries.
@@ -37,13 +39,13 @@ public:
/**
* Handle user input.
*/
- void HandleInput() CM_OVERRIDE;
+ void HandleInput() override;
/**
* Display form. Use a window of size width x height, starting
* at top, left.
*/
- void Render(int left, int top, int width, int height) CM_OVERRIDE;
+ void Render(int left, int top, int width, int height) override;
/**
* Returns true if an entry with the given key is in the
@@ -64,7 +66,7 @@ public:
* exception is during a resize. The optional argument specifies the
* string to be displayed in the status bar.
*/
- void UpdateStatusBar() CM_OVERRIDE { this->UpdateStatusBar(CM_NULLPTR); }
+ void UpdateStatusBar() override { this->UpdateStatusBar(nullptr); }
virtual void UpdateStatusBar(const char* message);
/**
@@ -80,7 +82,7 @@ public:
* During a CMake run, an error handle should add errors
* to be displayed afterwards.
*/
- void AddError(const char* message, const char* title) CM_OVERRIDE;
+ void AddError(const std::string& message, const char* title) override;
/**
* Used to do a configure. If argument is specified, it does only the check
@@ -101,8 +103,7 @@ public:
/**
* Progress callback
*/
- static void UpdateProgressOld(const char* msg, float prog, void*);
- static void UpdateProgress(const char* msg, float prog, void*);
+ void UpdateProgress(const std::string& msg, float prog);
protected:
// Copy the cache values from the user interface to the actual
@@ -122,10 +123,10 @@ protected:
void JumpToCacheEntry(const char* str);
// Copies of cache entries stored in the user interface
- std::vector<cmCursesCacheEntryComposite*>* Entries;
+ std::vector<cmCursesCacheEntryComposite> Entries;
// Errors produced during last run of cmake
std::vector<std::string> Errors;
- // Command line argumens to be passed to cmake each time
+ // Command line arguments to be passed to cmake each time
// it is run
std::vector<std::string> Args;
// Message displayed when user presses 'h'
@@ -136,11 +137,7 @@ protected:
static const char* s_ConstHelpMessage;
// Fields displayed. Includes labels, new entry markers, entries
- FIELD** Fields;
- // Where is source of current project
- std::string WhereSource;
- // Where is cmake executable
- std::string WhereCMake;
+ std::vector<FIELD*> Fields;
// Number of entries shown (depends on mode -normal or advanced-)
size_t NumberOfVisibleEntries;
bool AdvancedMode;
@@ -150,7 +147,7 @@ protected:
int NumberOfPages;
int InitialWidth;
- cmake* CMakeInstance;
+ std::unique_ptr<cmake> CMakeInstance;
std::string SearchString;
std::string OldSearchString;
diff --git a/Source/CursesDialog/cmCursesOptionsWidget.cxx b/Source/CursesDialog/cmCursesOptionsWidget.cxx
index d26a98f86..eb773ad0f 100644
--- a/Source/CursesDialog/cmCursesOptionsWidget.cxx
+++ b/Source/CursesDialog/cmCursesOptionsWidget.cxx
@@ -23,6 +23,9 @@ cmCursesOptionsWidget::cmCursesOptionsWidget(int width, int height, int left,
bool cmCursesOptionsWidget::HandleInput(int& key, cmCursesMainForm* /*fm*/,
WINDOW* w)
{
+ if (this->Options.empty()) {
+ return false;
+ }
switch (key) {
case 10: // 10 == enter
case KEY_ENTER:
@@ -75,9 +78,8 @@ void cmCursesOptionsWidget::SetOption(const std::string& value)
this->CurrentOption = 0; // default to 0 index
this->SetValue(value);
int index = 0;
- for (std::vector<std::string>::iterator i = this->Options.begin();
- i != this->Options.end(); ++i) {
- if (*i == value) {
+ for (auto const& opt : this->Options) {
+ if (opt == value) {
this->CurrentOption = index;
}
index++;
diff --git a/Source/CursesDialog/cmCursesOptionsWidget.h b/Source/CursesDialog/cmCursesOptionsWidget.h
index 7f4416f95..0de8e6407 100644
--- a/Source/CursesDialog/cmCursesOptionsWidget.h
+++ b/Source/CursesDialog/cmCursesOptionsWidget.h
@@ -3,28 +3,29 @@
#ifndef cmCursesOptionsWidget_h
#define cmCursesOptionsWidget_h
-#include "cmConfigure.h"
-
-#include "cmCursesStandardIncludes.h"
-#include "cmCursesWidget.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
+#include "cmCursesStandardIncludes.h"
+#include "cmCursesWidget.h"
+
class cmCursesMainForm;
class cmCursesOptionsWidget : public cmCursesWidget
{
- CM_DISABLE_COPY(cmCursesOptionsWidget)
-
public:
cmCursesOptionsWidget(int width, int height, int left, int top);
+ cmCursesOptionsWidget(cmCursesOptionsWidget const&) = delete;
+ cmCursesOptionsWidget& operator=(cmCursesOptionsWidget const&) = delete;
+
// Description:
// Handle user input. Called by the container of this widget
// when this widget has focus. Returns true if the input was
// handled.
- bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) CM_OVERRIDE;
+ bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) override;
void SetOption(const std::string&);
void AddOption(std::string const&);
void NextOption();
diff --git a/Source/CursesDialog/cmCursesPathWidget.cxx b/Source/CursesDialog/cmCursesPathWidget.cxx
index 05c3279c3..bb3808e89 100644
--- a/Source/CursesDialog/cmCursesPathWidget.cxx
+++ b/Source/CursesDialog/cmCursesPathWidget.cxx
@@ -2,13 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCursesPathWidget.h"
+#include <vector>
+
#include "cmCursesMainForm.h"
#include "cmCursesStringWidget.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
-#include <vector>
-
cmCursesPathWidget::cmCursesPathWidget(int width, int height, int left,
int top)
: cmCursesStringWidget(width, height, left, top)
diff --git a/Source/CursesDialog/cmCursesPathWidget.h b/Source/CursesDialog/cmCursesPathWidget.h
index ae6c16d02..fb365e9c5 100644
--- a/Source/CursesDialog/cmCursesPathWidget.h
+++ b/Source/CursesDialog/cmCursesPathWidget.h
@@ -3,29 +3,30 @@
#ifndef cmCursesPathWidget_h
#define cmCursesPathWidget_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
#include "cmCursesStandardIncludes.h"
#include "cmCursesStringWidget.h"
-#include <string>
-
class cmCursesMainForm;
class cmCursesPathWidget : public cmCursesStringWidget
{
- CM_DISABLE_COPY(cmCursesPathWidget)
-
public:
cmCursesPathWidget(int width, int height, int left, int top);
+ cmCursesPathWidget(cmCursesPathWidget const&) = delete;
+ cmCursesPathWidget& operator=(cmCursesPathWidget const&) = delete;
+
/**
* This method is called when different keys are pressed. The
* subclass can have a special implementation handler for this.
*/
- void OnTab(cmCursesMainForm* fm, WINDOW* w) CM_OVERRIDE;
- void OnReturn(cmCursesMainForm* fm, WINDOW* w) CM_OVERRIDE;
- void OnType(int& key, cmCursesMainForm* fm, WINDOW* w) CM_OVERRIDE;
+ void OnTab(cmCursesMainForm* fm, WINDOW* w) override;
+ void OnReturn(cmCursesMainForm* fm, WINDOW* w) override;
+ void OnType(int& key, cmCursesMainForm* fm, WINDOW* w) override;
protected:
std::string LastString;
diff --git a/Source/CursesDialog/cmCursesStandardIncludes.h b/Source/CursesDialog/cmCursesStandardIncludes.h
index 5c5950483..5b0ad5824 100644
--- a/Source/CursesDialog/cmCursesStandardIncludes.h
+++ b/Source/CursesDialog/cmCursesStandardIncludes.h
@@ -3,11 +3,16 @@
#ifndef cmCursesStandardIncludes_h
#define cmCursesStandardIncludes_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+
+// Record whether __attribute__ is currently defined. See purpose below.
+#ifndef __attribute__
+# define cm_no__attribute__
+#endif
#if defined(__hpux)
-#define _BOOL_DEFINED
-#include <sys/time.h>
+# define _BOOL_DEFINED
+# include <sys/time.h>
#endif
#include <form.h>
@@ -29,4 +34,12 @@ inline void curses_clear()
#undef erase
#undef clear
+// The curses headers on some platforms (e.g. Solaris) may
+// define __attribute__ as a macro. This breaks C++ headers
+// in some cases, so undefine it now.
+#if defined(cm_no__attribute__) && defined(__attribute__)
+# undef __attribute__
+#endif
+#undef cm_no__attribute__
+
#endif // cmCursesStandardIncludes_h
diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx
index ff189f01e..6296af20b 100644
--- a/Source/CursesDialog/cmCursesStringWidget.cxx
+++ b/Source/CursesDialog/cmCursesStringWidget.cxx
@@ -2,15 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCursesStringWidget.h"
+#include <cstdio>
+
#include "cmCursesForm.h"
#include "cmCursesMainForm.h"
#include "cmCursesStandardIncludes.h"
#include "cmCursesWidget.h"
#include "cmStateTypes.h"
-#include <stdio.h>
-#include <string.h>
-
inline int ctrl(int z)
{
return (z & 037);
@@ -35,13 +34,13 @@ void cmCursesStringWidget::OnTab(cmCursesMainForm* /*unused*/,
void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW* /*unused*/)
{
- FORM* form = fm->GetForm();
if (this->InEdit) {
cmCursesForm::LogMessage("String widget leaving edit.");
this->InEdit = false;
fm->PrintKeys();
- delete[] this->OriginalString;
+ this->OriginalString.clear();
// trick to force forms to update the field buffer
+ FORM* form = fm->GetForm();
form_driver(form, REQ_NEXT_FIELD);
form_driver(form, REQ_PREV_FIELD);
this->Done = true;
@@ -49,9 +48,7 @@ void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW* /*unused*/)
cmCursesForm::LogMessage("String widget entering edit.");
this->InEdit = true;
fm->PrintKeys();
- char* buf = field_buffer(this->Field, 0);
- this->OriginalString = new char[strlen(buf) + 1];
- strcpy(this->OriginalString, buf);
+ this->OriginalString = field_buffer(this->Field, 0);
}
}
@@ -64,7 +61,8 @@ void cmCursesStringWidget::OnType(int& key, cmCursesMainForm* fm,
bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
WINDOW* w)
{
- int x, y;
+ int x;
+ int y;
FORM* form = fm->GetForm();
// when not in edit mode, edit mode is entered by pressing enter or i (vim
@@ -74,7 +72,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
return false;
}
- this->OriginalString = CM_NULLPTR;
+ this->OriginalString.clear();
this->Done = false;
char debugMessage[128];
@@ -112,7 +110,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
key == ctrl('p') || key == KEY_NPAGE || key == ctrl('d') ||
key == KEY_PPAGE || key == ctrl('u')) {
this->InEdit = false;
- delete[] this->OriginalString;
+ this->OriginalString.clear();
// trick to force forms to update the field buffer
form_driver(form, REQ_NEXT_FIELD);
form_driver(form, REQ_PREV_FIELD);
@@ -124,7 +122,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
this->InEdit = false;
fm->PrintKeys();
this->SetString(this->OriginalString);
- delete[] this->OriginalString;
+ this->OriginalString.clear();
touchwin(w);
wrefresh(w);
return true;
@@ -179,32 +177,26 @@ const char* cmCursesStringWidget::GetValue()
bool cmCursesStringWidget::PrintKeys()
{
- int x, y;
+ int x;
+ int y;
getmaxyx(stdscr, y, x);
if (x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT) {
return false;
}
if (this->InEdit) {
char fmt_s[] = "%s";
- char firstLine[512];
// Clean the toolbar
- for (int i = 0; i < 512; i++) {
- firstLine[i] = ' ';
- }
- firstLine[511] = '\0';
curses_move(y - 4, 0);
- printw(fmt_s, firstLine);
- curses_move(y - 3, 0);
- printw(fmt_s, firstLine);
- curses_move(y - 2, 0);
- printw(fmt_s, firstLine);
- curses_move(y - 1, 0);
- printw(fmt_s, firstLine);
-
+ clrtoeol();
curses_move(y - 3, 0);
printw(fmt_s, "Editing option, press [enter] to confirm");
+ clrtoeol();
curses_move(y - 2, 0);
printw(fmt_s, " press [esc] to cancel");
+ clrtoeol();
+ curses_move(y - 1, 0);
+ clrtoeol();
+
return true;
}
return false;
diff --git a/Source/CursesDialog/cmCursesStringWidget.h b/Source/CursesDialog/cmCursesStringWidget.h
index 5eb33666d..ce06c6da7 100644
--- a/Source/CursesDialog/cmCursesStringWidget.h
+++ b/Source/CursesDialog/cmCursesStringWidget.h
@@ -3,13 +3,13 @@
#ifndef cmCursesStringWidget_h
#define cmCursesStringWidget_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
#include "cmCursesStandardIncludes.h"
#include "cmCursesWidget.h"
-#include <string>
-
class cmCursesMainForm;
/** \class cmCursesStringWidget
@@ -20,8 +20,6 @@ class cmCursesMainForm;
class cmCursesStringWidget : public cmCursesWidget
{
- CM_DISABLE_COPY(cmCursesStringWidget)
-
public:
cmCursesStringWidget(int width, int height, int left, int top);
@@ -30,14 +28,14 @@ public:
* when this widget has focus. Returns true if the input was
* handled.
*/
- bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) CM_OVERRIDE;
+ bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) override;
/**
* Set/Get the string.
*/
void SetString(const std::string& value);
const char* GetString();
- const char* GetValue() CM_OVERRIDE;
+ const char* GetValue() override;
/**
* Set/Get InEdit flag. Can be used to tell the widget to leave
@@ -59,12 +57,12 @@ public:
* in the toolbar and return true. Otherwise, return false
* and the parent widget will print.
*/
- bool PrintKeys() CM_OVERRIDE;
+ bool PrintKeys() override;
protected:
// true if the widget is in edit mode
bool InEdit;
- char* OriginalString;
+ std::string OriginalString;
bool Done;
};
diff --git a/Source/CursesDialog/cmCursesWidget.cxx b/Source/CursesDialog/cmCursesWidget.cxx
index 054f27e29..cc07411d4 100644
--- a/Source/CursesDialog/cmCursesWidget.cxx
+++ b/Source/CursesDialog/cmCursesWidget.cxx
@@ -14,7 +14,7 @@ cmCursesWidget::~cmCursesWidget()
{
if (this->Field) {
free_field(this->Field);
- this->Field = CM_NULLPTR;
+ this->Field = nullptr;
}
}
diff --git a/Source/CursesDialog/cmCursesWidget.h b/Source/CursesDialog/cmCursesWidget.h
index 3470d7096..9d03c6e42 100644
--- a/Source/CursesDialog/cmCursesWidget.h
+++ b/Source/CursesDialog/cmCursesWidget.h
@@ -3,23 +3,24 @@
#ifndef cmCursesWidget_h
#define cmCursesWidget_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
#include "cmCursesStandardIncludes.h"
#include "cmStateTypes.h"
-#include <string>
-
class cmCursesMainForm;
class cmCursesWidget
{
- CM_DISABLE_COPY(cmCursesWidget)
-
public:
cmCursesWidget(int width, int height, int left, int top);
virtual ~cmCursesWidget();
+ cmCursesWidget(cmCursesWidget const&) = delete;
+ cmCursesWidget& operator=(cmCursesWidget const&) = delete;
+
/**
* Handle user input. Called by the container of this widget
* when this widget has focus. Returns true if the input was
diff --git a/Source/CursesDialog/form/.gitattributes b/Source/CursesDialog/form/.gitattributes
index 62d728cf6..12ede74cd 100644
--- a/Source/CursesDialog/form/.gitattributes
+++ b/Source/CursesDialog/form/.gitattributes
@@ -1 +1 @@
-* -format.clang-format
+* -format.clang-format-6.0
diff --git a/Source/CursesDialog/form/CMakeLists.txt b/Source/CursesDialog/form/CMakeLists.txt
index 0677043a9..b468f5b31 100644
--- a/Source/CursesDialog/form/CMakeLists.txt
+++ b/Source/CursesDialog/form/CMakeLists.txt
@@ -3,12 +3,9 @@
project(CMAKE_FORM)
-include_regular_expression("^.*$")
-include_directories(${CURSES_INCLUDE_PATH} "${CMAKE_CURRENT_BINARY_DIR}")
-
configure_file(cmFormConfigure.h.in "${CMAKE_CURRENT_BINARY_DIR}/cmFormConfigure.h")
-set( FORM_SRCS
+add_library(cmForm
fld_arg.c
fld_attr.c
fld_current.c
@@ -49,10 +46,16 @@ set( FORM_SRCS
fty_num.c
fty_regex.c
)
-
-include_directories(${CMAKE_FORM_SOURCE_DIR})
-add_library(cmForm ${FORM_SRCS} )
+
+target_include_directories(cmForm
+ PUBLIC
+ ${CURSES_INCLUDE_PATH}
+ ${CMAKE_FORM_BINARY_DIR}
+ ${CMAKE_FORM_SOURCE_DIR}
+ )
+
target_link_libraries(cmForm ${CURSES_LIBRARY})
+
if(CURSES_EXTRA_LIBRARY)
target_link_libraries(cmForm ${CURSES_EXTRA_LIBRARY})
endif()
diff --git a/Source/CursesDialog/form/frm_post.c b/Source/CursesDialog/form/frm_post.c
index 924fe6a9e..fc0a35946 100644
--- a/Source/CursesDialog/form/frm_post.c
+++ b/Source/CursesDialog/form/frm_post.c
@@ -67,7 +67,7 @@ int post_form(FORM * form)
if ((form->cols > width) || (form->rows > height))
RETURN(E_NO_ROOM);
- /* reset form->curpage to an invald value. This forces Set_Form_Page
+ /* reset form->curpage to an invalid value. This forces Set_Form_Page
to do the page initialization which is required by post_form.
*/
page = form->curpage;
diff --git a/Source/LexerParser/.gitattributes b/Source/LexerParser/.gitattributes
index 47eedfb4b..bf7024978 100644
--- a/Source/LexerParser/.gitattributes
+++ b/Source/LexerParser/.gitattributes
@@ -2,6 +2,8 @@
/cmCommandArgumentLexer.h generated
/cmCommandArgumentParser.cxx generated
/cmCommandArgumentParserTokens.h generated
+/cmCTestResourceGroupsLexer.cxx generated
+/cmCTestResourceGroupsLexer.h generated
/cmDependsJavaLexer.cxx generated
/cmDependsJavaLexer.h generated
/cmDependsJavaParser.cxx generated
diff --git a/Source/LexerParser/cmCTestResourceGroupsLexer.cxx b/Source/LexerParser/cmCTestResourceGroupsLexer.cxx
new file mode 100644
index 000000000..de07c4693
--- /dev/null
+++ b/Source/LexerParser/cmCTestResourceGroupsLexer.cxx
@@ -0,0 +1,2224 @@
+#include "cmStandardLexer.h"
+
+#define FLEXINT_H 1
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 6
+#define YY_FLEX_SUBMINOR_VERSION 4
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+#ifdef yy_create_buffer
+#define cmCTestResourceGroups_yy_create_buffer_ALREADY_DEFINED
+#else
+#define yy_create_buffer cmCTestResourceGroups_yy_create_buffer
+#endif
+
+#ifdef yy_delete_buffer
+#define cmCTestResourceGroups_yy_delete_buffer_ALREADY_DEFINED
+#else
+#define yy_delete_buffer cmCTestResourceGroups_yy_delete_buffer
+#endif
+
+#ifdef yy_scan_buffer
+#define cmCTestResourceGroups_yy_scan_buffer_ALREADY_DEFINED
+#else
+#define yy_scan_buffer cmCTestResourceGroups_yy_scan_buffer
+#endif
+
+#ifdef yy_scan_string
+#define cmCTestResourceGroups_yy_scan_string_ALREADY_DEFINED
+#else
+#define yy_scan_string cmCTestResourceGroups_yy_scan_string
+#endif
+
+#ifdef yy_scan_bytes
+#define cmCTestResourceGroups_yy_scan_bytes_ALREADY_DEFINED
+#else
+#define yy_scan_bytes cmCTestResourceGroups_yy_scan_bytes
+#endif
+
+#ifdef yy_init_buffer
+#define cmCTestResourceGroups_yy_init_buffer_ALREADY_DEFINED
+#else
+#define yy_init_buffer cmCTestResourceGroups_yy_init_buffer
+#endif
+
+#ifdef yy_flush_buffer
+#define cmCTestResourceGroups_yy_flush_buffer_ALREADY_DEFINED
+#else
+#define yy_flush_buffer cmCTestResourceGroups_yy_flush_buffer
+#endif
+
+#ifdef yy_load_buffer_state
+#define cmCTestResourceGroups_yy_load_buffer_state_ALREADY_DEFINED
+#else
+#define yy_load_buffer_state cmCTestResourceGroups_yy_load_buffer_state
+#endif
+
+#ifdef yy_switch_to_buffer
+#define cmCTestResourceGroups_yy_switch_to_buffer_ALREADY_DEFINED
+#else
+#define yy_switch_to_buffer cmCTestResourceGroups_yy_switch_to_buffer
+#endif
+
+#ifdef yypush_buffer_state
+#define cmCTestResourceGroups_yypush_buffer_state_ALREADY_DEFINED
+#else
+#define yypush_buffer_state cmCTestResourceGroups_yypush_buffer_state
+#endif
+
+#ifdef yypop_buffer_state
+#define cmCTestResourceGroups_yypop_buffer_state_ALREADY_DEFINED
+#else
+#define yypop_buffer_state cmCTestResourceGroups_yypop_buffer_state
+#endif
+
+#ifdef yyensure_buffer_stack
+#define cmCTestResourceGroups_yyensure_buffer_stack_ALREADY_DEFINED
+#else
+#define yyensure_buffer_stack cmCTestResourceGroups_yyensure_buffer_stack
+#endif
+
+#ifdef yylex
+#define cmCTestResourceGroups_yylex_ALREADY_DEFINED
+#else
+#define yylex cmCTestResourceGroups_yylex
+#endif
+
+#ifdef yyrestart
+#define cmCTestResourceGroups_yyrestart_ALREADY_DEFINED
+#else
+#define yyrestart cmCTestResourceGroups_yyrestart
+#endif
+
+#ifdef yylex_init
+#define cmCTestResourceGroups_yylex_init_ALREADY_DEFINED
+#else
+#define yylex_init cmCTestResourceGroups_yylex_init
+#endif
+
+#ifdef yylex_init_extra
+#define cmCTestResourceGroups_yylex_init_extra_ALREADY_DEFINED
+#else
+#define yylex_init_extra cmCTestResourceGroups_yylex_init_extra
+#endif
+
+#ifdef yylex_destroy
+#define cmCTestResourceGroups_yylex_destroy_ALREADY_DEFINED
+#else
+#define yylex_destroy cmCTestResourceGroups_yylex_destroy
+#endif
+
+#ifdef yyget_debug
+#define cmCTestResourceGroups_yyget_debug_ALREADY_DEFINED
+#else
+#define yyget_debug cmCTestResourceGroups_yyget_debug
+#endif
+
+#ifdef yyset_debug
+#define cmCTestResourceGroups_yyset_debug_ALREADY_DEFINED
+#else
+#define yyset_debug cmCTestResourceGroups_yyset_debug
+#endif
+
+#ifdef yyget_extra
+#define cmCTestResourceGroups_yyget_extra_ALREADY_DEFINED
+#else
+#define yyget_extra cmCTestResourceGroups_yyget_extra
+#endif
+
+#ifdef yyset_extra
+#define cmCTestResourceGroups_yyset_extra_ALREADY_DEFINED
+#else
+#define yyset_extra cmCTestResourceGroups_yyset_extra
+#endif
+
+#ifdef yyget_in
+#define cmCTestResourceGroups_yyget_in_ALREADY_DEFINED
+#else
+#define yyget_in cmCTestResourceGroups_yyget_in
+#endif
+
+#ifdef yyset_in
+#define cmCTestResourceGroups_yyset_in_ALREADY_DEFINED
+#else
+#define yyset_in cmCTestResourceGroups_yyset_in
+#endif
+
+#ifdef yyget_out
+#define cmCTestResourceGroups_yyget_out_ALREADY_DEFINED
+#else
+#define yyget_out cmCTestResourceGroups_yyget_out
+#endif
+
+#ifdef yyset_out
+#define cmCTestResourceGroups_yyset_out_ALREADY_DEFINED
+#else
+#define yyset_out cmCTestResourceGroups_yyset_out
+#endif
+
+#ifdef yyget_leng
+#define cmCTestResourceGroups_yyget_leng_ALREADY_DEFINED
+#else
+#define yyget_leng cmCTestResourceGroups_yyget_leng
+#endif
+
+#ifdef yyget_text
+#define cmCTestResourceGroups_yyget_text_ALREADY_DEFINED
+#else
+#define yyget_text cmCTestResourceGroups_yyget_text
+#endif
+
+#ifdef yyget_lineno
+#define cmCTestResourceGroups_yyget_lineno_ALREADY_DEFINED
+#else
+#define yyget_lineno cmCTestResourceGroups_yyget_lineno
+#endif
+
+#ifdef yyset_lineno
+#define cmCTestResourceGroups_yyset_lineno_ALREADY_DEFINED
+#else
+#define yyset_lineno cmCTestResourceGroups_yyset_lineno
+#endif
+
+#ifdef yyget_column
+#define cmCTestResourceGroups_yyget_column_ALREADY_DEFINED
+#else
+#define yyget_column cmCTestResourceGroups_yyget_column
+#endif
+
+#ifdef yyset_column
+#define cmCTestResourceGroups_yyset_column_ALREADY_DEFINED
+#else
+#define yyset_column cmCTestResourceGroups_yyset_column
+#endif
+
+#ifdef yywrap
+#define cmCTestResourceGroups_yywrap_ALREADY_DEFINED
+#else
+#define yywrap cmCTestResourceGroups_yywrap
+#endif
+
+#ifdef yyalloc
+#define cmCTestResourceGroups_yyalloc_ALREADY_DEFINED
+#else
+#define yyalloc cmCTestResourceGroups_yyalloc
+#endif
+
+#ifdef yyrealloc
+#define cmCTestResourceGroups_yyrealloc_ALREADY_DEFINED
+#else
+#define yyrealloc cmCTestResourceGroups_yyrealloc
+#endif
+
+#ifdef yyfree
+#define cmCTestResourceGroups_yyfree_ALREADY_DEFINED
+#else
+#define yyfree cmCTestResourceGroups_yyfree
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#ifndef SIZE_MAX
+#define SIZE_MAX (~(size_t)0)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+/* begin standard C++ headers. */
+
+/* TODO: this is always defined, so inline it */
+#define yyconst const
+
+#if defined(__GNUC__) && __GNUC__ >= 3
+#define yynoreturn __attribute__((__noreturn__))
+#else
+#define yynoreturn
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an
+ * integer in range [0..255] for use as an array index.
+ */
+#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
+
+/* An opaque pointer. */
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void* yyscan_t;
+#endif
+
+/* For convenience, these vars (plus the bison vars far below)
+ are macros in the reentrant scanner. */
+#define yyin yyg->yyin_r
+#define yyout yyg->yyout_r
+#define yyextra yyg->yyextra_r
+#define yyleng yyg->yyleng_r
+#define yytext yyg->yytext_r
+#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
+#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
+#define yy_flex_debug yyg->yy_flex_debug_r
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN yyg->yy_start = 1 + 2 *
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((yyg->yy_start - 1) / 2)
+#define YYSTATE YY_START
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart( yyin , yyscanner )
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
+#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
+#endif
+
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+ #define YY_LESS_LINENO(n)
+ #define YY_LINENO_REWIND_TO(ptr)
+
+/* Return all but the first "n" matched characters back to the input stream. */
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = yyg->yy_hold_char; \
+ YY_RESTORE_YY_MORE_OFFSET \
+ yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+ } \
+ while ( 0 )
+#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ int yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via yyrestart()), so that the user can continue scanning by
+ * just pointing yyin at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
+ */
+#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
+ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
+ : NULL)
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
+
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+void yypop_buffer_state ( yyscan_t yyscanner );
+
+static void yyensure_buffer_stack ( yyscan_t yyscanner );
+static void yy_load_buffer_state ( yyscan_t yyscanner );
+static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
+#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)
+
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
+
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
+void yyfree ( void * , yyscan_t yyscanner );
+
+#define yy_new_buffer yy_create_buffer
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ yyensure_buffer_stack (yyscanner); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
+ }
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! YY_CURRENT_BUFFER ){\
+ yyensure_buffer_stack (yyscanner); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
+ }
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* Begin user sect3 */
+
+#define cmCTestResourceGroups_yywrap(yyscanner) (/*CONSTCOND*/1)
+#define YY_SKIP_YYWRAP
+typedef flex_uint8_t YY_CHAR;
+
+typedef int yy_state_type;
+
+#define yytext_ptr yytext_r
+
+static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
+static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner);
+static int yy_get_next_buffer ( yyscan_t yyscanner );
+static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+ yyg->yytext_ptr = yy_bp; \
+ yyleng = (int) (yy_cp - yy_bp); \
+ yyg->yy_hold_char = *yy_cp; \
+ *yy_cp = '\0'; \
+ yyg->yy_c_buf_p = yy_cp;
+#define YY_NUM_RULES 8
+#define YY_END_OF_BUFFER 9
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static const flex_int16_t yy_accept[29] =
+ { 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 9, 7, 2, 5, 7, 4, 6, 3,
+ 2, 5, 0, 1, 4, 6, 3, 0
+ } ;
+
+static const YY_CHAR yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 3, 1, 1, 1, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 5, 6, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 7, 1, 7, 7, 7, 7,
+
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+ } ;
+
+static const YY_CHAR yy_meta[8] =
+ { 0,
+ 1, 1, 1, 2, 2, 1, 2
+ } ;
+
+static const flex_int16_t yy_base[30] =
+ { 0,
+ 0, 0, 0, 0, 7, 0, 31, 12, 17, 0,
+ 0, 0, 34, 36, 29, 26, 26, 27, 23, 24,
+ 23, 20, 20, 36, 21, 16, 13, 36, 14
+ } ;
+
+static const flex_int16_t yy_def[30] =
+ { 0,
+ 28, 1, 1, 1, 28, 5, 1, 5, 5, 9,
+ 5, 5, 28, 28, 28, 28, 29, 28, 28, 28,
+ 28, 28, 29, 28, 28, 28, 28, 0, 28
+ } ;
+
+static const flex_int16_t yy_nxt[44] =
+ { 0,
+ 14, 14, 14, 15, 14, 16, 17, 14, 14, 18,
+ 14, 14, 19, 14, 14, 23, 27, 16, 17, 14,
+ 20, 26, 14, 25, 24, 22, 21, 27, 26, 25,
+ 24, 22, 21, 28, 14, 13, 28, 28, 28, 28,
+ 28, 28, 28
+ } ;
+
+static const flex_int16_t yy_chk[44] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 5, 5, 5,
+ 5, 5, 5, 5, 8, 29, 27, 8, 8, 9,
+ 9, 26, 9, 25, 23, 22, 21, 20, 19, 18,
+ 17, 16, 15, 13, 7, 28, 28, 28, 28, 28,
+ 28, 28, 28
+ } ;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+/*
+
+This file must be translated to C++ and modified to build everywhere.
+
+Run flex >= 2.6 like this:
+
+ flex --nounistd -DFLEXINT_H --noline --header-file=cmCTestResourceGroupsLexer.h -ocmCTestResourceGroupsLexer.cxx cmCTestResourceGroupsLexer.in.l
+
+Modify cmCTestResourceGroupsLexer.cxx:
+ - remove trailing whitespace: sed -i 's/\s*$//' cmCTestResourceGroupsLexer.h cmCTestResourceGroupsLexer.cxx
+ - remove blank lines at end of file: sed -i '${/^$/d;}' cmCTestResourceGroupsLexer.h cmCTestResourceGroupsLexer.cxx
+ - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmCTestResourceGroupsLexer.cxx
+
+*/
+
+/* IWYU pragma: no_forward_declare yyguts_t */
+
+#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+
+#include "cmCTestResourceGroupsLexerHelper.h"
+
+#include <string>
+
+#include <cstddef>
+
+/*--------------------------------------------------------------------------*/
+
+#define INITIAL 0
+#define RESOURCE_GROUPS_START 1
+#define RESOURCE_GROUPS_END 2
+#define RESOURCE_START 3
+#define RESOURCE_COUNT 4
+#define RESOURCE_END 5
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+/* Holds the entire state of the reentrant scanner. */
+struct yyguts_t
+ {
+
+ /* User-defined. Not touched by flex. */
+ YY_EXTRA_TYPE yyextra_r;
+
+ /* The rest are the same as the globals declared in the non-reentrant scanner. */
+ FILE *yyin_r, *yyout_r;
+ size_t yy_buffer_stack_top; /**< index of top of stack. */
+ size_t yy_buffer_stack_max; /**< capacity of stack. */
+ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
+ char yy_hold_char;
+ int yy_n_chars;
+ int yyleng_r;
+ char *yy_c_buf_p;
+ int yy_init;
+ int yy_start;
+ int yy_did_buffer_switch_on_eof;
+ int yy_start_stack_ptr;
+ int yy_start_stack_depth;
+ int *yy_start_stack;
+ yy_state_type yy_last_accepting_state;
+ char* yy_last_accepting_cpos;
+
+ int yylineno_r;
+ int yy_flex_debug_r;
+
+ char *yytext_r;
+ int yy_more_flag;
+ int yy_more_len;
+
+ }; /* end struct yyguts_t */
+
+static int yy_init_globals ( yyscan_t yyscanner );
+
+int yylex_init (yyscan_t* scanner);
+
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int yylex_destroy ( yyscan_t yyscanner );
+
+int yyget_debug ( yyscan_t yyscanner );
+
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
+
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
+
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
+
+FILE *yyget_in ( yyscan_t yyscanner );
+
+void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
+
+FILE *yyget_out ( yyscan_t yyscanner );
+
+void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
+
+ int yyget_leng ( yyscan_t yyscanner );
+
+char *yyget_text ( yyscan_t yyscanner );
+
+int yyget_lineno ( yyscan_t yyscanner );
+
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
+
+int yyget_column ( yyscan_t yyscanner );
+
+void yyset_column ( int _column_no , yyscan_t yyscanner );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap ( yyscan_t yyscanner );
+#else
+extern int yywrap ( yyscan_t yyscanner );
+#endif
+#endif
+
+#ifndef YY_NO_UNPUT
+
+ static void yyunput ( int c, char *buf_ptr , yyscan_t yyscanner);
+
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
+#endif
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int yyinput ( yyscan_t yyscanner );
+#else
+static int input ( yyscan_t yyscanner );
+#endif
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
+#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ { \
+ int c = '*'; \
+ int n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else \
+ { \
+ errno=0; \
+ while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(yyin); \
+ } \
+ }\
+\
+
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
+#endif
+
+/* end tables serialization structures and prototypes */
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int yylex (yyscan_t yyscanner);
+
+#define YY_DECL int yylex (yyscan_t yyscanner)
+#endif /* !YY_DECL */
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK /*LINTED*/break;
+#endif
+
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+/** The main scanner function which does all the work.
+ */
+YY_DECL
+{
+ yy_state_type yy_current_state;
+ char *yy_cp, *yy_bp;
+ int yy_act;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if ( !yyg->yy_init )
+ {
+ yyg->yy_init = 1;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! yyg->yy_start )
+ yyg->yy_start = 1; /* first start state */
+
+ if ( ! yyin )
+ yyin = stdin;
+
+ if ( ! yyout )
+ yyout = stdout;
+
+ if ( ! YY_CURRENT_BUFFER ) {
+ yyensure_buffer_stack (yyscanner);
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
+ }
+
+ yy_load_buffer_state( yyscanner );
+ }
+
+ {
+
+ while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = yyg->yy_c_buf_p;
+
+ /* Support of yytext. */
+ *yy_cp = yyg->yy_hold_char;
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = yyg->yy_start;
+yy_match:
+ do
+ {
+ YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
+ if ( yy_accept[yy_current_state] )
+ {
+ yyg->yy_last_accepting_state = yy_current_state;
+ yyg->yy_last_accepting_cpos = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 29 )
+ yy_c = yy_meta[yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
+ ++yy_cp;
+ }
+ while ( yy_base[yy_current_state] != 36 );
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+ if ( yy_act == 0 )
+ { /* have to back up */
+ yy_cp = yyg->yy_last_accepting_cpos;
+ yy_current_state = yyg->yy_last_accepting_state;
+ yy_act = yy_accept[yy_current_state];
+ }
+
+ YY_DO_BEFORE_ACTION;
+
+do_action: /* This label is used only to access EOF actions. */
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = yyg->yy_hold_char;
+ yy_cp = yyg->yy_last_accepting_cpos;
+ yy_current_state = yyg->yy_last_accepting_state;
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+{
+ BEGIN(RESOURCE_COUNT);
+ yyextra->SetResourceType(std::string(yytext, yyleng - 1));
+}
+ YY_BREAK
+case 2:
+YY_RULE_SETUP
+{
+ BEGIN(RESOURCE_GROUPS_END);
+ std::size_t len = yyleng;
+ yyextra->SetProcessCount(std::stoll(yytext, &len, 10));
+}
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+{
+ BEGIN(RESOURCE_END);
+ std::size_t len = yyleng;
+ yyextra->SetNeededSlots(std::stoll(yytext, &len, 10));
+ yyextra->WriteRequirement();
+}
+ YY_BREAK
+case 4:
+YY_RULE_SETUP
+{
+ BEGIN(RESOURCE_START);
+}
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+{
+ BEGIN(RESOURCE_GROUPS_START);
+}
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+{
+ BEGIN(RESOURCE_GROUPS_START);
+ yyextra->WriteProcess();
+}
+ YY_BREAK
+case YY_STATE_EOF(RESOURCE_START):
+case YY_STATE_EOF(RESOURCE_GROUPS_END):
+case YY_STATE_EOF(RESOURCE_END):
+{
+ yyextra->WriteProcess();
+ return 0;
+}
+ YY_BREAK
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(RESOURCE_GROUPS_START):
+{
+ return 0;
+}
+ YY_BREAK
+case YY_STATE_EOF(RESOURCE_COUNT):
+{
+ return 1;
+}
+ YY_BREAK
+case 7:
+/* rule 7 can match eol */
+YY_RULE_SETUP
+{
+ return 1;
+}
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+YY_FATAL_ERROR( "flex scanner jammed" );
+ YY_BREAK
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = yyg->yy_hold_char;
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed yyin at a new source and called
+ * yylex(). If so, then we have to assure
+ * consistency between YY_CURRENT_BUFFER and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( yyscanner );
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
+
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++yyg->yy_c_buf_p;
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = yyg->yy_c_buf_p;
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer( yyscanner ) )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ yyg->yy_did_buffer_switch_on_eof = 0;
+
+ if ( yywrap( yyscanner ) )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * yytext, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! yyg->yy_did_buffer_switch_on_eof )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ yyg->yy_c_buf_p =
+ yyg->yytext_ptr + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state( yyscanner );
+
+ yy_cp = yyg->yy_c_buf_p;
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ yyg->yy_c_buf_p =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
+
+ yy_current_state = yy_get_previous_state( yyscanner );
+
+ yy_cp = yyg->yy_c_buf_p;
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+ } /* end of user's declarations */
+} /* end of yylex */
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+static int yy_get_next_buffer (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ char *source = yyg->yytext_ptr;
+ int number_to_move, i;
+ int ret_val;
+
+ if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
+
+ else
+ {
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
+
+ int yy_c_buf_p_offset =
+ (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ yyrealloc( (void *) b->yy_ch_buf,
+ (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = NULL;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
+ number_to_move - 1;
+
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ yyg->yy_n_chars, num_to_read );
+
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+ }
+
+ if ( yyg->yy_n_chars == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ yyrestart( yyin , yyscanner);
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
+ (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ /* "- 2" to take care of EOB's */
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
+ }
+
+ yyg->yy_n_chars += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+ yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+
+ return ret_val;
+}
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+ static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
+{
+ yy_state_type yy_current_state;
+ char *yy_cp;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ yy_current_state = yyg->yy_start;
+
+ for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
+ {
+ YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ yyg->yy_last_accepting_state = yy_current_state;
+ yyg->yy_last_accepting_cpos = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 29 )
+ yy_c = yy_meta[yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
+ }
+
+ return yy_current_state;
+}
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
+{
+ int yy_is_jam;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
+ char *yy_cp = yyg->yy_c_buf_p;
+
+ YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ yyg->yy_last_accepting_state = yy_current_state;
+ yyg->yy_last_accepting_cpos = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 29 )
+ yy_c = yy_meta[yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
+ yy_is_jam = (yy_current_state == 28);
+
+ (void)yyg;
+ return yy_is_jam ? 0 : yy_current_state;
+}
+
+#ifndef YY_NO_UNPUT
+
+ static void yyunput (int c, char * yy_bp , yyscan_t yyscanner)
+{
+ char *yy_cp;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ yy_cp = yyg->yy_c_buf_p;
+
+ /* undo effects of setting up yytext */
+ *yy_cp = yyg->yy_hold_char;
+
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
+ { /* need to shift things up to make room */
+ /* +2 for EOB chars. */
+ int number_to_move = yyg->yy_n_chars + 2;
+ char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
+ char *source =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
+
+ while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ *--dest = *--source;
+
+ yy_cp += (int) (dest - source);
+ yy_bp += (int) (dest - source);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
+ yyg->yy_n_chars = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
+
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
+ YY_FATAL_ERROR( "flex scanner push-back overflow" );
+ }
+
+ *--yy_cp = (char) c;
+
+ yyg->yytext_ptr = yy_bp;
+ yyg->yy_hold_char = *yy_cp;
+ yyg->yy_c_buf_p = yy_cp;
+}
+
+#endif
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+ static int yyinput (yyscan_t yyscanner)
+#else
+ static int input (yyscan_t yyscanner)
+#endif
+
+{
+ int c;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
+
+ if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
+ /* This was really a NUL. */
+ *yyg->yy_c_buf_p = '\0';
+
+ else
+ { /* need more input */
+ int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
+ ++yyg->yy_c_buf_p;
+
+ switch ( yy_get_next_buffer( yyscanner ) )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ yyrestart( yyin , yyscanner);
+
+ /*FALLTHROUGH*/
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( yywrap( yyscanner ) )
+ return 0;
+
+ if ( ! yyg->yy_did_buffer_switch_on_eof )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput(yyscanner);
+#else
+ return input(yyscanner);
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
+ *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
+ yyg->yy_hold_char = *++yyg->yy_c_buf_p;
+
+ return c;
+}
+#endif /* ifndef YY_NO_INPUT */
+
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ * @param yyscanner The scanner object.
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void yyrestart (FILE * input_file , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if ( ! YY_CURRENT_BUFFER ){
+ yyensure_buffer_stack (yyscanner);
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
+ }
+
+ yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
+ yy_load_buffer_state( yyscanner );
+}
+
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ * @param yyscanner The scanner object.
+ */
+ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * yypop_buffer_state();
+ * yypush_buffer_state(new_buffer);
+ */
+ yyensure_buffer_stack (yyscanner);
+ if ( YY_CURRENT_BUFFER == new_buffer )
+ return;
+
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+ }
+
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ yy_load_buffer_state( yyscanner );
+
+ /* We don't actually know whether we did this switch during
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ yyg->yy_did_buffer_switch_on_eof = 1;
+}
+
+static void yy_load_buffer_state (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ yyg->yy_hold_char = *yyg->yy_c_buf_p;
+}
+
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ * @param yyscanner The scanner object.
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
+{
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ yy_init_buffer( b, file , yyscanner);
+
+ return b;
+}
+
+/** Destroy the buffer.
+ * @param b a buffer created with yy_create_buffer()
+ * @param yyscanner The scanner object.
+ */
+ void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if ( ! b )
+ return;
+
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ yyfree( (void *) b->yy_ch_buf , yyscanner );
+
+ yyfree( (void *) b , yyscanner );
+}
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a yyrestart() or at EOF.
+ */
+ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
+
+{
+ int oerrno = errno;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ yy_flush_buffer( b , yyscanner);
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+ /* If b is the current buffer, then yy_init_buffer was _probably_
+ * called from yyrestart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
+
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+
+ errno = oerrno;
+}
+
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ * @param yyscanner The scanner object.
+ */
+ void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == YY_CURRENT_BUFFER )
+ yy_load_buffer_state( yyscanner );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ * @param yyscanner The scanner object.
+ */
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ if (new_buffer == NULL)
+ return;
+
+ yyensure_buffer_stack(yyscanner);
+
+ /* This block is copied from yy_switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ yyg->yy_buffer_stack_top++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from yy_switch_to_buffer. */
+ yy_load_buffer_state( yyscanner );
+ yyg->yy_did_buffer_switch_on_eof = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ * @param yyscanner The scanner object.
+ */
+void yypop_buffer_state (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if (yyg->yy_buffer_stack_top > 0)
+ --yyg->yy_buffer_stack_top;
+
+ if (YY_CURRENT_BUFFER) {
+ yy_load_buffer_state( yyscanner );
+ yyg->yy_did_buffer_switch_on_eof = 1;
+ }
+}
+
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+static void yyensure_buffer_stack (yyscan_t yyscanner)
+{
+ yy_size_t num_to_alloc;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if (!yyg->yy_buffer_stack) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ , yyscanner);
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+
+ memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ yyg->yy_buffer_stack_max = num_to_alloc;
+ yyg->yy_buffer_stack_top = 0;
+ return;
+ }
+
+ if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
+
+ /* Increase the buffer to prepare for a possible push. */
+ yy_size_t grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
+ (yyg->yy_buffer_stack,
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ , yyscanner);
+ if ( ! yyg->yy_buffer_stack )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+
+ /* zero only the new slots.*/
+ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
+ yyg->yy_buffer_stack_max = num_to_alloc;
+ }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ * @param yyscanner The scanner object.
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
+{
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return NULL;
+
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+ b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = NULL;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ yy_switch_to_buffer( b , yyscanner );
+
+ return b;
+}
+
+/** Setup the input buffer state to scan a string. The next call to yylex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ * @param yyscanner The scanner object.
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * yy_scan_bytes() instead.
+ */
+YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
+{
+
+ return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
+}
+
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
+ * scan from a @e copy of @a bytes.
+ * @param yybytes the byte buffer to scan
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
+ * @param yyscanner The scanner object.
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner)
+{
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = (yy_size_t) (_yybytes_len + 2);
+ buf = (char *) yyalloc( n , yyscanner );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
+
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = yy_scan_buffer( buf, n , yyscanner);
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ (void)yyg;
+ fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ yytext[yyleng] = yyg->yy_hold_char; \
+ yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
+ yyg->yy_hold_char = *yyg->yy_c_buf_p; \
+ *yyg->yy_c_buf_p = '\0'; \
+ yyleng = yyless_macro_arg; \
+ } \
+ while ( 0 )
+
+/* Accessor methods (get/set functions) to struct members. */
+
+/** Get the user-defined data for this scanner.
+ * @param yyscanner The scanner object.
+ */
+YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yyextra;
+}
+
+/** Get the current line number.
+ * @param yyscanner The scanner object.
+ */
+int yyget_lineno (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if (! YY_CURRENT_BUFFER)
+ return 0;
+
+ return yylineno;
+}
+
+/** Get the current column number.
+ * @param yyscanner The scanner object.
+ */
+int yyget_column (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ if (! YY_CURRENT_BUFFER)
+ return 0;
+
+ return yycolumn;
+}
+
+/** Get the input stream.
+ * @param yyscanner The scanner object.
+ */
+FILE *yyget_in (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yyin;
+}
+
+/** Get the output stream.
+ * @param yyscanner The scanner object.
+ */
+FILE *yyget_out (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yyout;
+}
+
+/** Get the length of the current token.
+ * @param yyscanner The scanner object.
+ */
+int yyget_leng (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yyleng;
+}
+
+/** Get the current token.
+ * @param yyscanner The scanner object.
+ */
+
+char *yyget_text (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yytext;
+}
+
+/** Set the user-defined data. This data is never touched by the scanner.
+ * @param user_defined The data to be associated with this scanner.
+ * @param yyscanner The scanner object.
+ */
+void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yyextra = user_defined ;
+}
+
+/** Set the current line number.
+ * @param _line_number line number
+ * @param yyscanner The scanner object.
+ */
+void yyset_lineno (int _line_number , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ /* lineno is only valid if an input buffer exists. */
+ if (! YY_CURRENT_BUFFER )
+ YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
+
+ yylineno = _line_number;
+}
+
+/** Set the current column.
+ * @param _column_no column number
+ * @param yyscanner The scanner object.
+ */
+void yyset_column (int _column_no , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ /* column is only valid if an input buffer exists. */
+ if (! YY_CURRENT_BUFFER )
+ YY_FATAL_ERROR( "yyset_column called with no buffer" );
+
+ yycolumn = _column_no;
+}
+
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param _in_str A readable stream.
+ * @param yyscanner The scanner object.
+ * @see yy_switch_to_buffer
+ */
+void yyset_in (FILE * _in_str , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yyin = _in_str ;
+}
+
+void yyset_out (FILE * _out_str , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yyout = _out_str ;
+}
+
+int yyget_debug (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ return yy_flex_debug;
+}
+
+void yyset_debug (int _bdebug , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ yy_flex_debug = _bdebug ;
+}
+
+/* Accessor methods for yylval and yylloc */
+
+/* User-visible API */
+
+/* yylex_init is special because it creates the scanner itself, so it is
+ * the ONLY reentrant function that doesn't take the scanner as the last argument.
+ * That's why we explicitly handle the declaration, instead of using our macros.
+ */
+int yylex_init(yyscan_t* ptr_yy_globals)
+{
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ return yy_init_globals ( *ptr_yy_globals );
+}
+
+/* yylex_init_extra has the same functionality as yylex_init, but follows the
+ * convention of taking the scanner as the last argument. Note however, that
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
+ * is the reason, too, why this function also must handle its own declaration).
+ * The user defined value in the first argument will be available to yyalloc in
+ * the yyextra field.
+ */
+int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
+{
+ struct yyguts_t dummy_yyguts;
+
+ yyset_extra (yy_user_defined, &dummy_yyguts);
+
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in
+ yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ yyset_extra (yy_user_defined, *ptr_yy_globals);
+
+ return yy_init_globals ( *ptr_yy_globals );
+}
+
+static int yy_init_globals (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from yylex_destroy(), so don't allocate here.
+ */
+
+ yyg->yy_buffer_stack = NULL;
+ yyg->yy_buffer_stack_top = 0;
+ yyg->yy_buffer_stack_max = 0;
+ yyg->yy_c_buf_p = NULL;
+ yyg->yy_init = 0;
+ yyg->yy_start = 0;
+
+ yyg->yy_start_stack_ptr = 0;
+ yyg->yy_start_stack_depth = 0;
+ yyg->yy_start_stack = NULL;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ yyin = stdin;
+ yyout = stdout;
+#else
+ yyin = NULL;
+ yyout = NULL;
+#endif
+
+ /* For future reference: Set errno on error, since we are called by
+ * yylex_init()
+ */
+ return 0;
+}
+
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
+int yylex_destroy (yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ yypop_buffer_state(yyscanner);
+ }
+
+ /* Destroy the stack itself. */
+ yyfree(yyg->yy_buffer_stack , yyscanner);
+ yyg->yy_buffer_stack = NULL;
+
+ /* Destroy the start condition stack. */
+ yyfree( yyg->yy_start_stack , yyscanner );
+ yyg->yy_start_stack = NULL;
+
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * yylex() is called, initialization will occur. */
+ yy_init_globals( yyscanner);
+
+ /* Destroy the main struct (reentrant only). */
+ yyfree ( yyscanner , yyscanner );
+ yyscanner = NULL;
+ return 0;
+}
+
+/*
+ * Internal utility routines.
+ */
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ (void)yyg;
+
+ int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+}
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
+{
+ int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+}
+#endif
+
+void *yyalloc (yy_size_t size , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ (void)yyg;
+ return malloc(size);
+}
+
+void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ (void)yyg;
+
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return realloc(ptr, size);
+}
+
+void yyfree (void * ptr , yyscan_t yyscanner)
+{
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ (void)yyg;
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+/*--------------------------------------------------------------------------*/
+
+#endif /* __clang_analyzer__ */
diff --git a/Source/LexerParser/cmCTestResourceGroupsLexer.h b/Source/LexerParser/cmCTestResourceGroupsLexer.h
new file mode 100644
index 000000000..e323a5089
--- /dev/null
+++ b/Source/LexerParser/cmCTestResourceGroupsLexer.h
@@ -0,0 +1,692 @@
+#ifndef cmCTestResourceGroups_yyHEADER_H
+#define cmCTestResourceGroups_yyHEADER_H 1
+#define cmCTestResourceGroups_yyIN_HEADER 1
+
+#define FLEXINT_H 1
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 6
+#define YY_FLEX_SUBMINOR_VERSION 4
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+
+#ifdef yy_create_buffer
+#define cmCTestResourceGroups_yy_create_buffer_ALREADY_DEFINED
+#else
+#define yy_create_buffer cmCTestResourceGroups_yy_create_buffer
+#endif
+
+#ifdef yy_delete_buffer
+#define cmCTestResourceGroups_yy_delete_buffer_ALREADY_DEFINED
+#else
+#define yy_delete_buffer cmCTestResourceGroups_yy_delete_buffer
+#endif
+
+#ifdef yy_scan_buffer
+#define cmCTestResourceGroups_yy_scan_buffer_ALREADY_DEFINED
+#else
+#define yy_scan_buffer cmCTestResourceGroups_yy_scan_buffer
+#endif
+
+#ifdef yy_scan_string
+#define cmCTestResourceGroups_yy_scan_string_ALREADY_DEFINED
+#else
+#define yy_scan_string cmCTestResourceGroups_yy_scan_string
+#endif
+
+#ifdef yy_scan_bytes
+#define cmCTestResourceGroups_yy_scan_bytes_ALREADY_DEFINED
+#else
+#define yy_scan_bytes cmCTestResourceGroups_yy_scan_bytes
+#endif
+
+#ifdef yy_init_buffer
+#define cmCTestResourceGroups_yy_init_buffer_ALREADY_DEFINED
+#else
+#define yy_init_buffer cmCTestResourceGroups_yy_init_buffer
+#endif
+
+#ifdef yy_flush_buffer
+#define cmCTestResourceGroups_yy_flush_buffer_ALREADY_DEFINED
+#else
+#define yy_flush_buffer cmCTestResourceGroups_yy_flush_buffer
+#endif
+
+#ifdef yy_load_buffer_state
+#define cmCTestResourceGroups_yy_load_buffer_state_ALREADY_DEFINED
+#else
+#define yy_load_buffer_state cmCTestResourceGroups_yy_load_buffer_state
+#endif
+
+#ifdef yy_switch_to_buffer
+#define cmCTestResourceGroups_yy_switch_to_buffer_ALREADY_DEFINED
+#else
+#define yy_switch_to_buffer cmCTestResourceGroups_yy_switch_to_buffer
+#endif
+
+#ifdef yypush_buffer_state
+#define cmCTestResourceGroups_yypush_buffer_state_ALREADY_DEFINED
+#else
+#define yypush_buffer_state cmCTestResourceGroups_yypush_buffer_state
+#endif
+
+#ifdef yypop_buffer_state
+#define cmCTestResourceGroups_yypop_buffer_state_ALREADY_DEFINED
+#else
+#define yypop_buffer_state cmCTestResourceGroups_yypop_buffer_state
+#endif
+
+#ifdef yyensure_buffer_stack
+#define cmCTestResourceGroups_yyensure_buffer_stack_ALREADY_DEFINED
+#else
+#define yyensure_buffer_stack cmCTestResourceGroups_yyensure_buffer_stack
+#endif
+
+#ifdef yylex
+#define cmCTestResourceGroups_yylex_ALREADY_DEFINED
+#else
+#define yylex cmCTestResourceGroups_yylex
+#endif
+
+#ifdef yyrestart
+#define cmCTestResourceGroups_yyrestart_ALREADY_DEFINED
+#else
+#define yyrestart cmCTestResourceGroups_yyrestart
+#endif
+
+#ifdef yylex_init
+#define cmCTestResourceGroups_yylex_init_ALREADY_DEFINED
+#else
+#define yylex_init cmCTestResourceGroups_yylex_init
+#endif
+
+#ifdef yylex_init_extra
+#define cmCTestResourceGroups_yylex_init_extra_ALREADY_DEFINED
+#else
+#define yylex_init_extra cmCTestResourceGroups_yylex_init_extra
+#endif
+
+#ifdef yylex_destroy
+#define cmCTestResourceGroups_yylex_destroy_ALREADY_DEFINED
+#else
+#define yylex_destroy cmCTestResourceGroups_yylex_destroy
+#endif
+
+#ifdef yyget_debug
+#define cmCTestResourceGroups_yyget_debug_ALREADY_DEFINED
+#else
+#define yyget_debug cmCTestResourceGroups_yyget_debug
+#endif
+
+#ifdef yyset_debug
+#define cmCTestResourceGroups_yyset_debug_ALREADY_DEFINED
+#else
+#define yyset_debug cmCTestResourceGroups_yyset_debug
+#endif
+
+#ifdef yyget_extra
+#define cmCTestResourceGroups_yyget_extra_ALREADY_DEFINED
+#else
+#define yyget_extra cmCTestResourceGroups_yyget_extra
+#endif
+
+#ifdef yyset_extra
+#define cmCTestResourceGroups_yyset_extra_ALREADY_DEFINED
+#else
+#define yyset_extra cmCTestResourceGroups_yyset_extra
+#endif
+
+#ifdef yyget_in
+#define cmCTestResourceGroups_yyget_in_ALREADY_DEFINED
+#else
+#define yyget_in cmCTestResourceGroups_yyget_in
+#endif
+
+#ifdef yyset_in
+#define cmCTestResourceGroups_yyset_in_ALREADY_DEFINED
+#else
+#define yyset_in cmCTestResourceGroups_yyset_in
+#endif
+
+#ifdef yyget_out
+#define cmCTestResourceGroups_yyget_out_ALREADY_DEFINED
+#else
+#define yyget_out cmCTestResourceGroups_yyget_out
+#endif
+
+#ifdef yyset_out
+#define cmCTestResourceGroups_yyset_out_ALREADY_DEFINED
+#else
+#define yyset_out cmCTestResourceGroups_yyset_out
+#endif
+
+#ifdef yyget_leng
+#define cmCTestResourceGroups_yyget_leng_ALREADY_DEFINED
+#else
+#define yyget_leng cmCTestResourceGroups_yyget_leng
+#endif
+
+#ifdef yyget_text
+#define cmCTestResourceGroups_yyget_text_ALREADY_DEFINED
+#else
+#define yyget_text cmCTestResourceGroups_yyget_text
+#endif
+
+#ifdef yyget_lineno
+#define cmCTestResourceGroups_yyget_lineno_ALREADY_DEFINED
+#else
+#define yyget_lineno cmCTestResourceGroups_yyget_lineno
+#endif
+
+#ifdef yyset_lineno
+#define cmCTestResourceGroups_yyset_lineno_ALREADY_DEFINED
+#else
+#define yyset_lineno cmCTestResourceGroups_yyset_lineno
+#endif
+
+#ifdef yyget_column
+#define cmCTestResourceGroups_yyget_column_ALREADY_DEFINED
+#else
+#define yyget_column cmCTestResourceGroups_yyget_column
+#endif
+
+#ifdef yyset_column
+#define cmCTestResourceGroups_yyset_column_ALREADY_DEFINED
+#else
+#define yyset_column cmCTestResourceGroups_yyset_column
+#endif
+
+#ifdef yywrap
+#define cmCTestResourceGroups_yywrap_ALREADY_DEFINED
+#else
+#define yywrap cmCTestResourceGroups_yywrap
+#endif
+
+#ifdef yyalloc
+#define cmCTestResourceGroups_yyalloc_ALREADY_DEFINED
+#else
+#define yyalloc cmCTestResourceGroups_yyalloc
+#endif
+
+#ifdef yyrealloc
+#define cmCTestResourceGroups_yyrealloc_ALREADY_DEFINED
+#else
+#define yyrealloc cmCTestResourceGroups_yyrealloc
+#endif
+
+#ifdef yyfree
+#define cmCTestResourceGroups_yyfree_ALREADY_DEFINED
+#else
+#define yyfree cmCTestResourceGroups_yyfree
+#endif
+
+/* First, we deal with platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+/* end standard C headers. */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
+
+#ifndef SIZE_MAX
+#define SIZE_MAX (~(size_t)0)
+#endif
+
+#endif /* ! C99 */
+
+#endif /* ! FLEXINT_H */
+
+/* begin standard C++ headers. */
+
+/* TODO: this is always defined, so inline it */
+#define yyconst const
+
+#if defined(__GNUC__) && __GNUC__ >= 3
+#define yynoreturn __attribute__((__noreturn__))
+#else
+#define yynoreturn
+#endif
+
+/* An opaque pointer. */
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void* yyscan_t;
+#endif
+
+/* For convenience, these vars (plus the bison vars far below)
+ are macros in the reentrant scanner. */
+#define yyin yyg->yyin_r
+#define yyout yyg->yyout_r
+#define yyextra yyg->yyextra_r
+#define yyleng yyg->yyleng_r
+#define yytext yyg->yytext_r
+#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
+#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
+#define yy_flex_debug yyg->yy_flex_debug_r
+
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k.
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
+ * Ditto for the __ia64__ case accordingly.
+ */
+#define YY_BUF_SIZE 32768
+#else
+#define YY_BUF_SIZE 16384
+#endif /* __ia64__ */
+#endif
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
+
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ int yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+
+ };
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+void yypop_buffer_state ( yyscan_t yyscanner );
+
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
+
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
+void yyfree ( void * , yyscan_t yyscanner );
+
+/* Begin user sect3 */
+
+#define cmCTestResourceGroups_yywrap(yyscanner) (/*CONSTCOND*/1)
+#define YY_SKIP_YYWRAP
+
+#define yytext_ptr yytext_r
+
+#ifdef YY_HEADER_EXPORT_START_CONDITIONS
+#define INITIAL 0
+#define RESOURCE_GROUPS_START 1
+#define RESOURCE_GROUPS_END 2
+#define RESOURCE_START 3
+#define RESOURCE_COUNT 4
+#define RESOURCE_END 5
+
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+int yylex_init (yyscan_t* scanner);
+
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int yylex_destroy ( yyscan_t yyscanner );
+
+int yyget_debug ( yyscan_t yyscanner );
+
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
+
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
+
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
+
+FILE *yyget_in ( yyscan_t yyscanner );
+
+void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
+
+FILE *yyget_out ( yyscan_t yyscanner );
+
+void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
+
+ int yyget_leng ( yyscan_t yyscanner );
+
+char *yyget_text ( yyscan_t yyscanner );
+
+int yyget_lineno ( yyscan_t yyscanner );
+
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
+
+int yyget_column ( yyscan_t yyscanner );
+
+void yyset_column ( int _column_no , yyscan_t yyscanner );
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap ( yyscan_t yyscanner );
+#else
+extern int yywrap ( yyscan_t yyscanner );
+#endif
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
+#endif
+
+#ifndef YY_NO_INPUT
+
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#ifdef __ia64__
+/* On IA-64, the buffer size is 16k, not 8k */
+#define YY_READ_BUF_SIZE 16384
+#else
+#define YY_READ_BUF_SIZE 8192
+#endif /* __ia64__ */
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL_IS_OURS 1
+
+extern int yylex (yyscan_t yyscanner);
+
+#define YY_DECL int yylex (yyscan_t yyscanner)
+#endif /* !YY_DECL */
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+#undef YY_NEW_FILE
+#undef YY_FLUSH_BUFFER
+#undef yy_set_bol
+#undef yy_new_buffer
+#undef yy_set_interactive
+#undef YY_DO_BEFORE_ACTION
+
+#ifdef YY_DECL_IS_OURS
+#undef YY_DECL_IS_OURS
+#undef YY_DECL
+#endif
+
+#ifndef cmCTestResourceGroups_yy_create_buffer_ALREADY_DEFINED
+#undef yy_create_buffer
+#endif
+#ifndef cmCTestResourceGroups_yy_delete_buffer_ALREADY_DEFINED
+#undef yy_delete_buffer
+#endif
+#ifndef cmCTestResourceGroups_yy_scan_buffer_ALREADY_DEFINED
+#undef yy_scan_buffer
+#endif
+#ifndef cmCTestResourceGroups_yy_scan_string_ALREADY_DEFINED
+#undef yy_scan_string
+#endif
+#ifndef cmCTestResourceGroups_yy_scan_bytes_ALREADY_DEFINED
+#undef yy_scan_bytes
+#endif
+#ifndef cmCTestResourceGroups_yy_init_buffer_ALREADY_DEFINED
+#undef yy_init_buffer
+#endif
+#ifndef cmCTestResourceGroups_yy_flush_buffer_ALREADY_DEFINED
+#undef yy_flush_buffer
+#endif
+#ifndef cmCTestResourceGroups_yy_load_buffer_state_ALREADY_DEFINED
+#undef yy_load_buffer_state
+#endif
+#ifndef cmCTestResourceGroups_yy_switch_to_buffer_ALREADY_DEFINED
+#undef yy_switch_to_buffer
+#endif
+#ifndef cmCTestResourceGroups_yypush_buffer_state_ALREADY_DEFINED
+#undef yypush_buffer_state
+#endif
+#ifndef cmCTestResourceGroups_yypop_buffer_state_ALREADY_DEFINED
+#undef yypop_buffer_state
+#endif
+#ifndef cmCTestResourceGroups_yyensure_buffer_stack_ALREADY_DEFINED
+#undef yyensure_buffer_stack
+#endif
+#ifndef cmCTestResourceGroups_yylex_ALREADY_DEFINED
+#undef yylex
+#endif
+#ifndef cmCTestResourceGroups_yyrestart_ALREADY_DEFINED
+#undef yyrestart
+#endif
+#ifndef cmCTestResourceGroups_yylex_init_ALREADY_DEFINED
+#undef yylex_init
+#endif
+#ifndef cmCTestResourceGroups_yylex_init_extra_ALREADY_DEFINED
+#undef yylex_init_extra
+#endif
+#ifndef cmCTestResourceGroups_yylex_destroy_ALREADY_DEFINED
+#undef yylex_destroy
+#endif
+#ifndef cmCTestResourceGroups_yyget_debug_ALREADY_DEFINED
+#undef yyget_debug
+#endif
+#ifndef cmCTestResourceGroups_yyset_debug_ALREADY_DEFINED
+#undef yyset_debug
+#endif
+#ifndef cmCTestResourceGroups_yyget_extra_ALREADY_DEFINED
+#undef yyget_extra
+#endif
+#ifndef cmCTestResourceGroups_yyset_extra_ALREADY_DEFINED
+#undef yyset_extra
+#endif
+#ifndef cmCTestResourceGroups_yyget_in_ALREADY_DEFINED
+#undef yyget_in
+#endif
+#ifndef cmCTestResourceGroups_yyset_in_ALREADY_DEFINED
+#undef yyset_in
+#endif
+#ifndef cmCTestResourceGroups_yyget_out_ALREADY_DEFINED
+#undef yyget_out
+#endif
+#ifndef cmCTestResourceGroups_yyset_out_ALREADY_DEFINED
+#undef yyset_out
+#endif
+#ifndef cmCTestResourceGroups_yyget_leng_ALREADY_DEFINED
+#undef yyget_leng
+#endif
+#ifndef cmCTestResourceGroups_yyget_text_ALREADY_DEFINED
+#undef yyget_text
+#endif
+#ifndef cmCTestResourceGroups_yyget_lineno_ALREADY_DEFINED
+#undef yyget_lineno
+#endif
+#ifndef cmCTestResourceGroups_yyset_lineno_ALREADY_DEFINED
+#undef yyset_lineno
+#endif
+#ifndef cmCTestResourceGroups_yyget_column_ALREADY_DEFINED
+#undef yyget_column
+#endif
+#ifndef cmCTestResourceGroups_yyset_column_ALREADY_DEFINED
+#undef yyset_column
+#endif
+#ifndef cmCTestResourceGroups_yywrap_ALREADY_DEFINED
+#undef yywrap
+#endif
+#ifndef cmCTestResourceGroups_yyget_lval_ALREADY_DEFINED
+#undef yyget_lval
+#endif
+#ifndef cmCTestResourceGroups_yyset_lval_ALREADY_DEFINED
+#undef yyset_lval
+#endif
+#ifndef cmCTestResourceGroups_yyget_lloc_ALREADY_DEFINED
+#undef yyget_lloc
+#endif
+#ifndef cmCTestResourceGroups_yyset_lloc_ALREADY_DEFINED
+#undef yyset_lloc
+#endif
+#ifndef cmCTestResourceGroups_yyalloc_ALREADY_DEFINED
+#undef yyalloc
+#endif
+#ifndef cmCTestResourceGroups_yyrealloc_ALREADY_DEFINED
+#undef yyrealloc
+#endif
+#ifndef cmCTestResourceGroups_yyfree_ALREADY_DEFINED
+#undef yyfree
+#endif
+#ifndef cmCTestResourceGroups_yytext_ALREADY_DEFINED
+#undef yytext
+#endif
+#ifndef cmCTestResourceGroups_yyleng_ALREADY_DEFINED
+#undef yyleng
+#endif
+#ifndef cmCTestResourceGroups_yyin_ALREADY_DEFINED
+#undef yyin
+#endif
+#ifndef cmCTestResourceGroups_yyout_ALREADY_DEFINED
+#undef yyout
+#endif
+#ifndef cmCTestResourceGroups_yy_flex_debug_ALREADY_DEFINED
+#undef yy_flex_debug
+#endif
+#ifndef cmCTestResourceGroups_yylineno_ALREADY_DEFINED
+#undef yylineno
+#endif
+#ifndef cmCTestResourceGroups_yytables_fload_ALREADY_DEFINED
+#undef yytables_fload
+#endif
+#ifndef cmCTestResourceGroups_yytables_destroy_ALREADY_DEFINED
+#undef yytables_destroy
+#endif
+#ifndef cmCTestResourceGroups_yyTABLES_NAME_ALREADY_DEFINED
+#undef yyTABLES_NAME
+#endif
+
+#undef cmCTestResourceGroups_yyIN_HEADER
+#endif /* cmCTestResourceGroups_yyHEADER_H */
diff --git a/Source/LexerParser/cmCTestResourceGroupsLexer.in.l b/Source/LexerParser/cmCTestResourceGroupsLexer.in.l
new file mode 100644
index 000000000..2aabea48d
--- /dev/null
+++ b/Source/LexerParser/cmCTestResourceGroupsLexer.in.l
@@ -0,0 +1,102 @@
+%{
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+/*
+
+This file must be translated to C++ and modified to build everywhere.
+
+Run flex >= 2.6 like this:
+
+ flex --nounistd -DFLEXINT_H --noline --header-file=cmCTestResourceGroupsLexer.h -ocmCTestResourceGroupsLexer.cxx cmCTestResourceGroupsLexer.in.l
+
+Modify cmCTestResourceGroupsLexer.cxx:
+ - remove trailing whitespace: sed -i 's/\s*$//' cmCTestResourceGroupsLexer.h cmCTestResourceGroupsLexer.cxx
+ - remove blank lines at end of file: sed -i '${/^$/d;}' cmCTestResourceGroupsLexer.h cmCTestResourceGroupsLexer.cxx
+ - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmCTestResourceGroupsLexer.cxx
+
+*/
+
+/* IWYU pragma: no_forward_declare yyguts_t */
+
+#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+
+#include "cmCTestResourceGroupsLexerHelper.h"
+
+#include <string>
+
+#include <cstddef>
+
+/*--------------------------------------------------------------------------*/
+%}
+
+%option prefix="cmCTestResourceGroups_yy"
+
+%option reentrant
+%option noyywrap
+%option nodefault
+%pointer
+
+%s RESOURCE_GROUPS_START
+%s RESOURCE_GROUPS_END
+%s RESOURCE_START
+%s RESOURCE_COUNT
+%s RESOURCE_END
+
+NUMBER [0-9]+
+IDENTIFIER [a-z_][a-z0-9_]*
+
+%%
+
+<INITIAL,RESOURCE_GROUPS_START,RESOURCE_START>{IDENTIFIER}: {
+ BEGIN(RESOURCE_COUNT);
+ yyextra->SetResourceType(std::string(yytext, yyleng - 1));
+}
+
+<INITIAL,RESOURCE_GROUPS_START>{NUMBER} {
+ BEGIN(RESOURCE_GROUPS_END);
+ std::size_t len = yyleng;
+ yyextra->SetProcessCount(std::stoll(yytext, &len, 10));
+}
+
+<RESOURCE_COUNT>{NUMBER} {
+ BEGIN(RESOURCE_END);
+ std::size_t len = yyleng;
+ yyextra->SetNeededSlots(std::stoll(yytext, &len, 10));
+ yyextra->WriteRequirement();
+}
+
+<RESOURCE_GROUPS_END,RESOURCE_END>,+ {
+ BEGIN(RESOURCE_START);
+}
+
+<INITIAL,RESOURCE_GROUPS_START,RESOURCE_START>;+ {
+ BEGIN(RESOURCE_GROUPS_START);
+}
+
+<RESOURCE_GROUPS_END,RESOURCE_END>;+ {
+ BEGIN(RESOURCE_GROUPS_START);
+ yyextra->WriteProcess();
+}
+
+<RESOURCE_START,RESOURCE_GROUPS_END,RESOURCE_END><<EOF>> {
+ yyextra->WriteProcess();
+ return 0;
+}
+
+<INITIAL,RESOURCE_GROUPS_START><<EOF>> {
+ return 0;
+}
+
+<<EOF>> {
+ return 1;
+}
+
+.|\n {
+ return 1;
+}
+
+%%
+
+/*--------------------------------------------------------------------------*/
+
+#endif /* __clang_analyzer__ */
diff --git a/Source/LexerParser/cmCommandArgumentLexer.cxx b/Source/LexerParser/cmCommandArgumentLexer.cxx
index 12dce3758..58799123f 100644
--- a/Source/LexerParser/cmCommandArgumentLexer.cxx
+++ b/Source/LexerParser/cmCommandArgumentLexer.cxx
@@ -1,7 +1,4 @@
#include "cmStandardLexer.h"
-#line 2 "cmCommandArgumentLexer.cxx"
-
-#line 4 "cmCommandArgumentLexer.cxx"
#define FLEXINT_H 1
#define YY_INT_ALIGNED short int
@@ -11,11 +8,221 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
+#define YY_FLEX_SUBMINOR_VERSION 4
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
+#ifdef yy_create_buffer
+#define cmCommandArgument_yy_create_buffer_ALREADY_DEFINED
+#else
+#define yy_create_buffer cmCommandArgument_yy_create_buffer
+#endif
+
+#ifdef yy_delete_buffer
+#define cmCommandArgument_yy_delete_buffer_ALREADY_DEFINED
+#else
+#define yy_delete_buffer cmCommandArgument_yy_delete_buffer
+#endif
+
+#ifdef yy_scan_buffer
+#define cmCommandArgument_yy_scan_buffer_ALREADY_DEFINED
+#else
+#define yy_scan_buffer cmCommandArgument_yy_scan_buffer
+#endif
+
+#ifdef yy_scan_string
+#define cmCommandArgument_yy_scan_string_ALREADY_DEFINED
+#else
+#define yy_scan_string cmCommandArgument_yy_scan_string
+#endif
+
+#ifdef yy_scan_bytes
+#define cmCommandArgument_yy_scan_bytes_ALREADY_DEFINED
+#else
+#define yy_scan_bytes cmCommandArgument_yy_scan_bytes
+#endif
+
+#ifdef yy_init_buffer
+#define cmCommandArgument_yy_init_buffer_ALREADY_DEFINED
+#else
+#define yy_init_buffer cmCommandArgument_yy_init_buffer
+#endif
+
+#ifdef yy_flush_buffer
+#define cmCommandArgument_yy_flush_buffer_ALREADY_DEFINED
+#else
+#define yy_flush_buffer cmCommandArgument_yy_flush_buffer
+#endif
+
+#ifdef yy_load_buffer_state
+#define cmCommandArgument_yy_load_buffer_state_ALREADY_DEFINED
+#else
+#define yy_load_buffer_state cmCommandArgument_yy_load_buffer_state
+#endif
+
+#ifdef yy_switch_to_buffer
+#define cmCommandArgument_yy_switch_to_buffer_ALREADY_DEFINED
+#else
+#define yy_switch_to_buffer cmCommandArgument_yy_switch_to_buffer
+#endif
+
+#ifdef yypush_buffer_state
+#define cmCommandArgument_yypush_buffer_state_ALREADY_DEFINED
+#else
+#define yypush_buffer_state cmCommandArgument_yypush_buffer_state
+#endif
+
+#ifdef yypop_buffer_state
+#define cmCommandArgument_yypop_buffer_state_ALREADY_DEFINED
+#else
+#define yypop_buffer_state cmCommandArgument_yypop_buffer_state
+#endif
+
+#ifdef yyensure_buffer_stack
+#define cmCommandArgument_yyensure_buffer_stack_ALREADY_DEFINED
+#else
+#define yyensure_buffer_stack cmCommandArgument_yyensure_buffer_stack
+#endif
+
+#ifdef yylex
+#define cmCommandArgument_yylex_ALREADY_DEFINED
+#else
+#define yylex cmCommandArgument_yylex
+#endif
+
+#ifdef yyrestart
+#define cmCommandArgument_yyrestart_ALREADY_DEFINED
+#else
+#define yyrestart cmCommandArgument_yyrestart
+#endif
+
+#ifdef yylex_init
+#define cmCommandArgument_yylex_init_ALREADY_DEFINED
+#else
+#define yylex_init cmCommandArgument_yylex_init
+#endif
+
+#ifdef yylex_init_extra
+#define cmCommandArgument_yylex_init_extra_ALREADY_DEFINED
+#else
+#define yylex_init_extra cmCommandArgument_yylex_init_extra
+#endif
+
+#ifdef yylex_destroy
+#define cmCommandArgument_yylex_destroy_ALREADY_DEFINED
+#else
+#define yylex_destroy cmCommandArgument_yylex_destroy
+#endif
+
+#ifdef yyget_debug
+#define cmCommandArgument_yyget_debug_ALREADY_DEFINED
+#else
+#define yyget_debug cmCommandArgument_yyget_debug
+#endif
+
+#ifdef yyset_debug
+#define cmCommandArgument_yyset_debug_ALREADY_DEFINED
+#else
+#define yyset_debug cmCommandArgument_yyset_debug
+#endif
+
+#ifdef yyget_extra
+#define cmCommandArgument_yyget_extra_ALREADY_DEFINED
+#else
+#define yyget_extra cmCommandArgument_yyget_extra
+#endif
+
+#ifdef yyset_extra
+#define cmCommandArgument_yyset_extra_ALREADY_DEFINED
+#else
+#define yyset_extra cmCommandArgument_yyset_extra
+#endif
+
+#ifdef yyget_in
+#define cmCommandArgument_yyget_in_ALREADY_DEFINED
+#else
+#define yyget_in cmCommandArgument_yyget_in
+#endif
+
+#ifdef yyset_in
+#define cmCommandArgument_yyset_in_ALREADY_DEFINED
+#else
+#define yyset_in cmCommandArgument_yyset_in
+#endif
+
+#ifdef yyget_out
+#define cmCommandArgument_yyget_out_ALREADY_DEFINED
+#else
+#define yyget_out cmCommandArgument_yyget_out
+#endif
+
+#ifdef yyset_out
+#define cmCommandArgument_yyset_out_ALREADY_DEFINED
+#else
+#define yyset_out cmCommandArgument_yyset_out
+#endif
+
+#ifdef yyget_leng
+#define cmCommandArgument_yyget_leng_ALREADY_DEFINED
+#else
+#define yyget_leng cmCommandArgument_yyget_leng
+#endif
+
+#ifdef yyget_text
+#define cmCommandArgument_yyget_text_ALREADY_DEFINED
+#else
+#define yyget_text cmCommandArgument_yyget_text
+#endif
+
+#ifdef yyget_lineno
+#define cmCommandArgument_yyget_lineno_ALREADY_DEFINED
+#else
+#define yyget_lineno cmCommandArgument_yyget_lineno
+#endif
+
+#ifdef yyset_lineno
+#define cmCommandArgument_yyset_lineno_ALREADY_DEFINED
+#else
+#define yyset_lineno cmCommandArgument_yyset_lineno
+#endif
+
+#ifdef yyget_column
+#define cmCommandArgument_yyget_column_ALREADY_DEFINED
+#else
+#define yyget_column cmCommandArgument_yyget_column
+#endif
+
+#ifdef yyset_column
+#define cmCommandArgument_yyset_column_ALREADY_DEFINED
+#else
+#define yyset_column cmCommandArgument_yyset_column
+#endif
+
+#ifdef yywrap
+#define cmCommandArgument_yywrap_ALREADY_DEFINED
+#else
+#define yywrap cmCommandArgument_yywrap
+#endif
+
+#ifdef yyalloc
+#define cmCommandArgument_yyalloc_ALREADY_DEFINED
+#else
+#define yyalloc cmCommandArgument_yyalloc
+#endif
+
+#ifdef yyrealloc
+#define cmCommandArgument_yyrealloc_ALREADY_DEFINED
+#else
+#define yyrealloc cmCommandArgument_yyrealloc
+#endif
+
+#ifdef yyfree
+#define cmCommandArgument_yyfree_ALREADY_DEFINED
+#else
+#define yyfree cmCommandArgument_yyfree
+#endif
+
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
@@ -86,10 +293,16 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
+#ifndef SIZE_MAX
+#define SIZE_MAX (~(size_t)0)
+#endif
+
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */
+
/* TODO: this is always defined, so inline it */
#define yyconst const
@@ -102,12 +315,10 @@ typedef unsigned int flex_uint32_t;
/* Returned upon end-of-file. */
#define YY_NULL 0
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
+/* Promotes a possibly negative, possibly signed char to an
+ * integer in range [0..255] for use as an array index.
*/
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
@@ -131,20 +342,16 @@ typedef void* yyscan_t;
* definition of BEGIN.
*/
#define BEGIN yyg->yy_start = 1 + 2 *
-
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START ((yyg->yy_start - 1) / 2)
#define YYSTATE YY_START
-
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE cmCommandArgument_yyrestart(yyin ,yyscanner )
-
+#define YY_NEW_FILE yyrestart( yyin , yyscanner )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
@@ -194,7 +401,6 @@ typedef size_t yy_size_t;
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
-
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
#ifndef YY_STRUCT_YY_BUFFER_STATE
@@ -254,7 +460,7 @@ struct yy_buffer_state
* possible backing-up.
*
* When we actually see the EOF, we change the status to "new"
- * (via cmCommandArgument_yyrestart()), so that the user can continue scanning by
+ * (via yyrestart()), so that the user can continue scanning by
* just pointing yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
@@ -271,73 +477,67 @@ struct yy_buffer_state
#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
: NULL)
-
/* Same as previous macro, but useful when we know that the buffer stack is not
* NULL or when we need an lvalue. For internal use only.
*/
#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
-void cmCommandArgument_yyrestart (FILE *input_file ,yyscan_t yyscanner );
-void cmCommandArgument_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmCommandArgument_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
-void cmCommandArgument_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmCommandArgument_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmCommandArgument_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-void cmCommandArgument_yypop_buffer_state (yyscan_t yyscanner );
-
-static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner );
-static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner );
-static void cmCommandArgument_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+void yypop_buffer_state ( yyscan_t yyscanner );
-#define YY_FLUSH_BUFFER cmCommandArgument_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
+static void yyensure_buffer_stack ( yyscan_t yyscanner );
+static void yy_load_buffer_state ( yyscan_t yyscanner );
+static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
+#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)
-YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmCommandArgument_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmCommandArgument_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
-void *cmCommandArgument_yyalloc (yy_size_t ,yyscan_t yyscanner );
-void *cmCommandArgument_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
-void cmCommandArgument_yyfree (void * ,yyscan_t yyscanner );
-
-#define yy_new_buffer cmCommandArgument_yy_create_buffer
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
+void yyfree ( void * , yyscan_t yyscanner );
+#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
{ \
if ( ! YY_CURRENT_BUFFER ){ \
- cmCommandArgument_yyensure_buffer_stack (yyscanner); \
+ yyensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
- cmCommandArgument_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
-
#define yy_set_bol(at_bol) \
{ \
if ( ! YY_CURRENT_BUFFER ){\
- cmCommandArgument_yyensure_buffer_stack (yyscanner); \
+ yyensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
- cmCommandArgument_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
-
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
/* Begin user sect3 */
#define cmCommandArgument_yywrap(yyscanner) (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
-
-typedef unsigned char YY_CHAR;
+typedef flex_uint8_t YY_CHAR;
typedef int yy_state_type;
#define yytext_ptr yytext_r
-static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
-static int yy_get_next_buffer (yyscan_t yyscanner );
-static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner );
+static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
+static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner);
+static int yy_get_next_buffer ( yyscan_t yyscanner );
+static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
@@ -348,7 +548,6 @@ static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner );
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
-
#define YY_NUM_RULES 14
#define YY_END_OF_BUFFER 15
/* This struct is not used in this scanner,
@@ -358,14 +557,14 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[30] =
+static const flex_int16_t yy_accept[30] =
{ 0,
0, 0, 0, 0, 0, 0, 15, 9, 10, 7,
6, 14, 11, 5, 12, 13, 9, 0, 0, 4,
7, 0, 8, 2, 0, 3, 0, 1, 0
} ;
-static yyconst YY_CHAR yy_ec[256] =
+static const YY_CHAR yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -397,13 +596,13 @@ static yyconst YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
-static yyconst YY_CHAR yy_meta[12] =
+static const YY_CHAR yy_meta[12] =
{ 0,
1, 2, 3, 4, 3, 4, 4, 4, 3, 5,
3
} ;
-static yyconst flex_uint16_t yy_base[35] =
+static const flex_int16_t yy_base[35] =
{ 0,
0, 0, 31, 30, 29, 28, 36, 0, 6, 16,
0, 41, 41, 41, 0, 41, 0, 22, 22, 41,
@@ -411,7 +610,7 @@ static yyconst flex_uint16_t yy_base[35] =
21, 26, 9, 30
} ;
-static yyconst flex_int16_t yy_def[35] =
+static const flex_int16_t yy_def[35] =
{ 0,
29, 1, 1, 1, 1, 1, 29, 30, 31, 32,
33, 29, 29, 29, 34, 29, 30, 31, 18, 29,
@@ -419,7 +618,7 @@ static yyconst flex_int16_t yy_def[35] =
29, 29, 29, 29
} ;
-static yyconst flex_uint16_t yy_nxt[53] =
+static const flex_int16_t yy_nxt[53] =
{ 0,
8, 8, 9, 10, 11, 10, 10, 10, 12, 13,
14, 19, 22, 28, 27, 20, 17, 17, 17, 17,
@@ -429,7 +628,7 @@ static yyconst flex_uint16_t yy_nxt[53] =
29, 29
} ;
-static yyconst flex_int16_t yy_chk[53] =
+static const flex_int16_t yy_chk[53] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 9, 33, 27, 25, 9, 10, 10, 21, 21,
@@ -446,8 +645,6 @@ static yyconst flex_int16_t yy_chk[53] =
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
-#line 1 "cmCommandArgumentLexer.in.l"
-#line 2 "cmCommandArgumentLexer.in.l"
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
/*
@@ -456,32 +653,37 @@ This file must be translated to C++ and modified to build everywhere.
Run flex >= 2.6 like this:
- flex --nounistd -DFLEXINT_H --prefix=cmCommandArgument_yy --header-file=cmCommandArgumentLexer.h -ocmCommandArgumentLexer.cxx cmCommandArgumentLexer.in.l
+ flex --nounistd -DFLEXINT_H --noline --header-file=cmCommandArgumentLexer.h -ocmCommandArgumentLexer.cxx cmCommandArgumentLexer.in.l
Modify cmCommandArgumentLexer.cxx:
- - remove trailing whitespace: sed -i 's/\s*$//' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx
- - remove blank lines at end of file
- - #include "cmStandardLexer.h" at the top
- - add cast in cmCommandArgument_yy_scan_bytes for loop condition of _yybytes_len to size_t
+ - remove trailing whitespace: sed -i 's/\s*$//' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx
+ - remove blank lines at end of file: sed -i '${/^$/d;}' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx
+ - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmCommandArgumentLexer.cxx
*/
/* IWYU pragma: no_forward_declare yyguts_t */
+#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+
#include "cmCommandArgumentParserHelper.h"
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
- { result = yyextra->LexInput(buf, max_size); }
+ do { result = yyextra->LexInput(buf, max_size); } while (0)
/* Include the set of tokens from the parser. */
#include "cmCommandArgumentParserTokens.h"
-/*--------------------------------------------------------------------------*/
+static const char *DCURLYVariable = "${";
+static const char *RCURLYVariable = "}";
+static const char *ATVariable = "@";
+static const char *DOLLARVariable = "$";
+static const char *LCURLYVariable = "{";
+static const char *BSLASHVariable = "\\";
-
-#line 484 "cmCommandArgumentLexer.cxx"
+/*--------------------------------------------------------------------------*/
#define INITIAL 0
#define ESCAPES 1
@@ -525,44 +727,44 @@ struct yyguts_t
}; /* end struct yyguts_t */
-static int yy_init_globals (yyscan_t yyscanner );
+static int yy_init_globals ( yyscan_t yyscanner );
-int cmCommandArgument_yylex_init (yyscan_t* scanner);
+int yylex_init (yyscan_t* scanner);
-int cmCommandArgument_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
-int cmCommandArgument_yylex_destroy (yyscan_t yyscanner );
+int yylex_destroy ( yyscan_t yyscanner );
-int cmCommandArgument_yyget_debug (yyscan_t yyscanner );
+int yyget_debug ( yyscan_t yyscanner );
-void cmCommandArgument_yyset_debug (int debug_flag ,yyscan_t yyscanner );
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
-YY_EXTRA_TYPE cmCommandArgument_yyget_extra (yyscan_t yyscanner );
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
-void cmCommandArgument_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
-FILE *cmCommandArgument_yyget_in (yyscan_t yyscanner );
+FILE *yyget_in ( yyscan_t yyscanner );
-void cmCommandArgument_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
+void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
-FILE *cmCommandArgument_yyget_out (yyscan_t yyscanner );
+FILE *yyget_out ( yyscan_t yyscanner );
-void cmCommandArgument_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
+void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
- int cmCommandArgument_yyget_leng (yyscan_t yyscanner );
+ int yyget_leng ( yyscan_t yyscanner );
-char *cmCommandArgument_yyget_text (yyscan_t yyscanner );
+char *yyget_text ( yyscan_t yyscanner );
-int cmCommandArgument_yyget_lineno (yyscan_t yyscanner );
+int yyget_lineno ( yyscan_t yyscanner );
-void cmCommandArgument_yyset_lineno (int _line_number ,yyscan_t yyscanner );
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
-int cmCommandArgument_yyget_column (yyscan_t yyscanner );
+int yyget_column ( yyscan_t yyscanner );
-void cmCommandArgument_yyset_column (int _column_no ,yyscan_t yyscanner );
+void yyset_column ( int _column_no , yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -570,9 +772,9 @@ void cmCommandArgument_yyset_column (int _column_no ,yyscan_t yyscanner );
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int cmCommandArgument_yywrap (yyscan_t yyscanner );
+extern "C" int yywrap ( yyscan_t yyscanner );
#else
-extern int cmCommandArgument_yywrap (yyscan_t yyscanner );
+extern int yywrap ( yyscan_t yyscanner );
#endif
#endif
@@ -581,19 +783,18 @@ extern int cmCommandArgument_yywrap (yyscan_t yyscanner );
#endif
#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
-
#ifdef __cplusplus
-static int yyinput (yyscan_t yyscanner );
+static int yyinput ( yyscan_t yyscanner );
#else
-static int input (yyscan_t yyscanner );
+static int input ( yyscan_t yyscanner );
#endif
#endif
@@ -624,7 +825,7 @@ static int input (yyscan_t yyscanner );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
- size_t n; \
+ int n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@@ -637,7 +838,7 @@ static int input (yyscan_t yyscanner );
else \
{ \
errno=0; \
- while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
@@ -678,9 +879,9 @@ static int input (yyscan_t yyscanner );
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-extern int cmCommandArgument_yylex (yyscan_t yyscanner);
+extern int yylex (yyscan_t yyscanner);
-#define YY_DECL int cmCommandArgument_yylex (yyscan_t yyscanner)
+#define YY_DECL int yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */
/* Code executed at the beginning of each rule, after yytext and yyleng
@@ -725,19 +926,15 @@ YY_DECL
yyout = stdout;
if ( ! YY_CURRENT_BUFFER ) {
- cmCommandArgument_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
- cmCommandArgument_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
}
- cmCommandArgument_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
}
{
-#line 42 "cmCommandArgumentLexer.in.l"
-
-
-#line 740 "cmCommandArgumentLexer.cxx"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
@@ -765,9 +962,9 @@ yy_match:
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 30 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
while ( yy_base[yy_current_state] != 41 );
@@ -796,7 +993,6 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
-#line 44 "cmCommandArgumentLexer.in.l"
{
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2);
@@ -805,7 +1001,6 @@ YY_RULE_SETUP
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 50 "cmCommandArgumentLexer.in.l"
{
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2);
@@ -814,7 +1009,6 @@ YY_RULE_SETUP
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 56 "cmCommandArgumentLexer.in.l"
{
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2);
@@ -823,37 +1017,33 @@ YY_RULE_SETUP
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 62 "cmCommandArgumentLexer.in.l"
{
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->DCURLYVariable;
+ yylvalp->str = DCURLYVariable;
return cal_DCURLY;
}
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 69 "cmCommandArgumentLexer.in.l"
{
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->RCURLYVariable;
+ yylvalp->str = RCURLYVariable;
return cal_RCURLY;
}
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 76 "cmCommandArgumentLexer.in.l"
{
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->ATVariable;
+ yylvalp->str = ATVariable;
return cal_AT;
}
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 83 "cmCommandArgumentLexer.in.l"
{
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
@@ -862,7 +1052,6 @@ YY_RULE_SETUP
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 89 "cmCommandArgumentLexer.in.l"
{
if ( !yyextra->HandleEscapeSymbol(yylvalp, *(yytext+1)) )
{
@@ -874,7 +1063,6 @@ YY_RULE_SETUP
case 9:
/* rule 9 can match eol */
YY_RULE_SETUP
-#line 97 "cmCommandArgumentLexer.in.l"
{
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
@@ -883,46 +1071,40 @@ YY_RULE_SETUP
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 103 "cmCommandArgumentLexer.in.l"
{
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->DOLLARVariable;
+ yylvalp->str = DOLLARVariable;
return cal_DOLLAR;
}
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 109 "cmCommandArgumentLexer.in.l"
{
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->LCURLYVariable;
+ yylvalp->str = LCURLYVariable;
return cal_LCURLY;
}
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 115 "cmCommandArgumentLexer.in.l"
{
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->BSLASHVariable;
+ yylvalp->str = BSLASHVariable;
return cal_BSLASH;
}
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 121 "cmCommandArgumentLexer.in.l"
{
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->BSLASHVariable;
+ yylvalp->str = BSLASHVariable;
return cal_SYMBOL;
}
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 127 "cmCommandArgumentLexer.in.l"
ECHO;
YY_BREAK
-#line 925 "cmCommandArgumentLexer.cxx"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(ESCAPES):
case YY_STATE_EOF(NOESCAPES):
@@ -942,7 +1124,7 @@ case YY_STATE_EOF(NOESCAPES):
/* We're scanning a new file or input source. It's
* possible that this happened because the user
* just pointed yyin at a new source and called
- * cmCommandArgument_yylex(). If so, then we have to assure
+ * yylex(). If so, then we have to assure
* consistency between YY_CURRENT_BUFFER and our
* globals. Here is the right place to do so, because
* this is the first action (other than possibly a
@@ -1002,7 +1184,7 @@ case YY_STATE_EOF(NOESCAPES):
{
yyg->yy_did_buffer_switch_on_eof = 0;
- if ( cmCommandArgument_yywrap(yyscanner ) )
+ if ( yywrap( yyscanner ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
@@ -1056,7 +1238,7 @@ case YY_STATE_EOF(NOESCAPES):
} /* end of action switch */
} /* end of scanning one token */
} /* end of user's declarations */
-} /* end of cmCommandArgument_yylex */
+} /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer
*
@@ -1070,7 +1252,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = yyg->yytext_ptr;
- yy_size_t number_to_move, i;
+ int number_to_move, i;
int ret_val;
if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
@@ -1099,7 +1281,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
/* Try to read more data. */
/* First move last chars to start of buffer. */
- number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
+ number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@@ -1135,7 +1317,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
- cmCommandArgument_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
+ yyrealloc( (void *) b->yy_ch_buf,
+ (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
}
else
/* Can't grow it, we don't own it. */
@@ -1167,7 +1350,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
- cmCommandArgument_yyrestart(yyin ,yyscanner);
+ yyrestart( yyin , yyscanner);
}
else
@@ -1181,12 +1364,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
ret_val = EOB_ACT_CONTINUE_SCAN;
- if ((int) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cmCommandArgument_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
+ (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ /* "- 2" to take care of EOB's */
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
}
yyg->yy_n_chars += number_to_move;
@@ -1220,9 +1406,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 30 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
}
return yy_current_state;
@@ -1249,9 +1435,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 30 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 29);
(void)yyg;
@@ -1287,7 +1473,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
{ /* need more input */
- int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+ int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
++yyg->yy_c_buf_p;
switch ( yy_get_next_buffer( yyscanner ) )
@@ -1304,13 +1490,13 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
*/
/* Reset buffer status. */
- cmCommandArgument_yyrestart(yyin ,yyscanner);
+ yyrestart( yyin , yyscanner);
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
- if ( cmCommandArgument_yywrap(yyscanner ) )
+ if ( yywrap( yyscanner ) )
return 0;
if ( ! yyg->yy_did_buffer_switch_on_eof )
@@ -1342,34 +1528,34 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @note This function does not reset the start condition to @c INITIAL .
*/
- void cmCommandArgument_yyrestart (FILE * input_file , yyscan_t yyscanner)
+ void yyrestart (FILE * input_file , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! YY_CURRENT_BUFFER ){
- cmCommandArgument_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
- cmCommandArgument_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
}
- cmCommandArgument_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
- cmCommandArgument_yy_load_buffer_state(yyscanner );
+ yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
+ yy_load_buffer_state( yyscanner );
}
/** Switch to a different input buffer.
* @param new_buffer The new input buffer.
* @param yyscanner The scanner object.
*/
- void cmCommandArgument_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* TODO. We should be able to replace this entire function body
* with
- * cmCommandArgument_yypop_buffer_state();
- * cmCommandArgument_yypush_buffer_state(new_buffer);
+ * yypop_buffer_state();
+ * yypush_buffer_state(new_buffer);
*/
- cmCommandArgument_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
if ( YY_CURRENT_BUFFER == new_buffer )
return;
@@ -1382,17 +1568,17 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- cmCommandArgument_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
/* We don't actually know whether we did this switch during
- * EOF (cmCommandArgument_yywrap()) processing, but the only time this flag
- * is looked at is after cmCommandArgument_yywrap() is called, so it's safe
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
* to go ahead and always set it.
*/
yyg->yy_did_buffer_switch_on_eof = 1;
}
-static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner)
+static void yy_load_buffer_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
@@ -1407,35 +1593,35 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the allocated buffer state.
*/
- YY_BUFFER_STATE cmCommandArgument_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
+ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
- b = (YY_BUFFER_STATE) cmCommandArgument_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yy_create_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
- b->yy_buf_size = (yy_size_t)size;
+ b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
- b->yy_ch_buf = (char *) cmCommandArgument_yyalloc(b->yy_buf_size + 2 ,yyscanner );
+ b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yy_create_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
- cmCommandArgument_yy_init_buffer(b,file ,yyscanner);
+ yy_init_buffer( b, file , yyscanner);
return b;
}
/** Destroy the buffer.
- * @param b a buffer created with cmCommandArgument_yy_create_buffer()
+ * @param b a buffer created with yy_create_buffer()
* @param yyscanner The scanner object.
*/
- void cmCommandArgument_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+ void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -1446,28 +1632,28 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner)
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
- cmCommandArgument_yyfree((void *) b->yy_ch_buf ,yyscanner );
+ yyfree( (void *) b->yy_ch_buf , yyscanner );
- cmCommandArgument_yyfree((void *) b ,yyscanner );
+ yyfree( (void *) b , yyscanner );
}
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
- * such as during a cmCommandArgument_yyrestart() or at EOF.
+ * such as during a yyrestart() or at EOF.
*/
- static void cmCommandArgument_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
+ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
{
int oerrno = errno;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- cmCommandArgument_yy_flush_buffer(b ,yyscanner);
+ yy_flush_buffer( b , yyscanner);
b->yy_input_file = file;
b->yy_fill_buffer = 1;
- /* If b is the current buffer, then cmCommandArgument_yy_init_buffer was _probably_
- * called from cmCommandArgument_yyrestart() or through yy_get_next_buffer.
+ /* If b is the current buffer, then yy_init_buffer was _probably_
+ * called from yyrestart() or through yy_get_next_buffer.
* In that case, we don't want to reset the lineno or column.
*/
if (b != YY_CURRENT_BUFFER){
@@ -1484,7 +1670,7 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner)
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
* @param yyscanner The scanner object.
*/
- void cmCommandArgument_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+ void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! b )
@@ -1505,7 +1691,7 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner)
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
- cmCommandArgument_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
}
/** Pushes the new state onto the stack. The new state becomes
@@ -1514,15 +1700,15 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner)
* @param new_buffer The new state.
* @param yyscanner The scanner object.
*/
-void cmCommandArgument_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (new_buffer == NULL)
return;
- cmCommandArgument_yyensure_buffer_stack(yyscanner);
+ yyensure_buffer_stack(yyscanner);
- /* This block is copied from cmCommandArgument_yy_switch_to_buffer. */
+ /* This block is copied from yy_switch_to_buffer. */
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
@@ -1536,8 +1722,8 @@ void cmCommandArgument_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_
yyg->yy_buffer_stack_top++;
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- /* copied from cmCommandArgument_yy_switch_to_buffer. */
- cmCommandArgument_yy_load_buffer_state(yyscanner );
+ /* copied from yy_switch_to_buffer. */
+ yy_load_buffer_state( yyscanner );
yyg->yy_did_buffer_switch_on_eof = 1;
}
@@ -1545,19 +1731,19 @@ void cmCommandArgument_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_
* The next element becomes the new top.
* @param yyscanner The scanner object.
*/
-void cmCommandArgument_yypop_buffer_state (yyscan_t yyscanner)
+void yypop_buffer_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!YY_CURRENT_BUFFER)
return;
- cmCommandArgument_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
+ yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
YY_CURRENT_BUFFER_LVALUE = NULL;
if (yyg->yy_buffer_stack_top > 0)
--yyg->yy_buffer_stack_top;
if (YY_CURRENT_BUFFER) {
- cmCommandArgument_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
yyg->yy_did_buffer_switch_on_eof = 1;
}
}
@@ -1565,9 +1751,9 @@ void cmCommandArgument_yypop_buffer_state (yyscan_t yyscanner)
/* Allocates the stack if it does not exist.
* Guarantees space for at least one push.
*/
-static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner)
+static void yyensure_buffer_stack (yyscan_t yyscanner)
{
- int num_to_alloc;
+ yy_size_t num_to_alloc;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!yyg->yy_buffer_stack) {
@@ -1577,11 +1763,11 @@ static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner)
* immediate realloc on the next call.
*/
num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
- yyg->yy_buffer_stack = (struct yy_buffer_state**)cmCommandArgument_yyalloc
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
- YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yyensure_buffer_stack()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
@@ -1596,12 +1782,12 @@ static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner)
yy_size_t grow_size = 8 /* arbitrary grow size */;
num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
- yyg->yy_buffer_stack = (struct yy_buffer_state**)cmCommandArgument_yyrealloc
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
(yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
- YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yyensure_buffer_stack()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -1615,7 +1801,7 @@ static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
@@ -1625,11 +1811,11 @@ YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char * base, yy_size_t size
/* They forgot to leave room for the EOB's. */
return NULL;
- b = (YY_BUFFER_STATE) cmCommandArgument_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yy_scan_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = NULL;
@@ -1639,53 +1825,53 @@ YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char * base, yy_size_t size
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
- cmCommandArgument_yy_switch_to_buffer(b ,yyscanner );
+ yy_switch_to_buffer( b , yyscanner );
return b;
}
-/** Setup the input buffer state to scan a string. The next call to cmCommandArgument_yylex() will
+/** Setup the input buffer state to scan a string. The next call to yylex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
- * cmCommandArgument_yy_scan_bytes() instead.
+ * yy_scan_bytes() instead.
*/
-YY_BUFFER_STATE cmCommandArgument_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
{
- return cmCommandArgument_yy_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner);
+ return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
}
-/** Setup the input buffer state to scan the given bytes. The next call to cmCommandArgument_yylex() will
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE cmCommandArgument_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
- yy_size_t i;
+ int i;
/* Get memory for full buffer, including space for trailing EOB's. */
- n = (yy_size_t) _yybytes_len + 2;
- buf = (char *) cmCommandArgument_yyalloc(n ,yyscanner );
+ n = (yy_size_t) (_yybytes_len + 2);
+ buf = (char *) yyalloc( n , yyscanner );
if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yy_scan_bytes()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
- for ( i = 0; i < (size_t)_yybytes_len; ++i )
+ for ( i = 0; i < _yybytes_len; ++i )
buf[i] = yybytes[i];
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
- b = cmCommandArgument_yy_scan_buffer(buf,n ,yyscanner);
+ b = yy_scan_buffer( buf, n , yyscanner);
if ( ! b )
- YY_FATAL_ERROR( "bad buffer in cmCommandArgument_yy_scan_bytes()" );
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
/* It's okay to grow etc. this buffer, and we should throw it
* away when we're done.
@@ -1699,11 +1885,11 @@ YY_BUFFER_STATE cmCommandArgument_yy_scan_bytes (yyconst char * yybytes, int _
#define YY_EXIT_FAILURE 2
#endif
-static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
+static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
- (void) fprintf( stderr, "%s\n", msg );
+ fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
@@ -1729,7 +1915,7 @@ static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
/** Get the user-defined data for this scanner.
* @param yyscanner The scanner object.
*/
-YY_EXTRA_TYPE cmCommandArgument_yyget_extra (yyscan_t yyscanner)
+YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyextra;
@@ -1738,7 +1924,7 @@ YY_EXTRA_TYPE cmCommandArgument_yyget_extra (yyscan_t yyscanner)
/** Get the current line number.
* @param yyscanner The scanner object.
*/
-int cmCommandArgument_yyget_lineno (yyscan_t yyscanner)
+int yyget_lineno (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -1751,7 +1937,7 @@ int cmCommandArgument_yyget_lineno (yyscan_t yyscanner)
/** Get the current column number.
* @param yyscanner The scanner object.
*/
-int cmCommandArgument_yyget_column (yyscan_t yyscanner)
+int yyget_column (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -1764,7 +1950,7 @@ int cmCommandArgument_yyget_column (yyscan_t yyscanner)
/** Get the input stream.
* @param yyscanner The scanner object.
*/
-FILE *cmCommandArgument_yyget_in (yyscan_t yyscanner)
+FILE *yyget_in (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyin;
@@ -1773,7 +1959,7 @@ FILE *cmCommandArgument_yyget_in (yyscan_t yyscanner)
/** Get the output stream.
* @param yyscanner The scanner object.
*/
-FILE *cmCommandArgument_yyget_out (yyscan_t yyscanner)
+FILE *yyget_out (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyout;
@@ -1782,7 +1968,7 @@ FILE *cmCommandArgument_yyget_out (yyscan_t yyscanner)
/** Get the length of the current token.
* @param yyscanner The scanner object.
*/
-int cmCommandArgument_yyget_leng (yyscan_t yyscanner)
+int yyget_leng (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyleng;
@@ -1792,7 +1978,7 @@ int cmCommandArgument_yyget_leng (yyscan_t yyscanner)
* @param yyscanner The scanner object.
*/
-char *cmCommandArgument_yyget_text (yyscan_t yyscanner)
+char *yyget_text (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yytext;
@@ -1802,7 +1988,7 @@ char *cmCommandArgument_yyget_text (yyscan_t yyscanner)
* @param user_defined The data to be associated with this scanner.
* @param yyscanner The scanner object.
*/
-void cmCommandArgument_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
+void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyextra = user_defined ;
@@ -1812,13 +1998,13 @@ void cmCommandArgument_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yysca
* @param _line_number line number
* @param yyscanner The scanner object.
*/
-void cmCommandArgument_yyset_lineno (int _line_number , yyscan_t yyscanner)
+void yyset_lineno (int _line_number , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* lineno is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "cmCommandArgument_yyset_lineno called with no buffer" );
+ YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
yylineno = _line_number;
}
@@ -1827,13 +2013,13 @@ void cmCommandArgument_yyset_lineno (int _line_number , yyscan_t yyscanner)
* @param _column_no column number
* @param yyscanner The scanner object.
*/
-void cmCommandArgument_yyset_column (int _column_no , yyscan_t yyscanner)
+void yyset_column (int _column_no , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* column is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "cmCommandArgument_yyset_column called with no buffer" );
+ YY_FATAL_ERROR( "yyset_column called with no buffer" );
yycolumn = _column_no;
}
@@ -1842,27 +2028,27 @@ void cmCommandArgument_yyset_column (int _column_no , yyscan_t yyscanner)
* input buffer.
* @param _in_str A readable stream.
* @param yyscanner The scanner object.
- * @see cmCommandArgument_yy_switch_to_buffer
+ * @see yy_switch_to_buffer
*/
-void cmCommandArgument_yyset_in (FILE * _in_str , yyscan_t yyscanner)
+void yyset_in (FILE * _in_str , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyin = _in_str ;
}
-void cmCommandArgument_yyset_out (FILE * _out_str , yyscan_t yyscanner)
+void yyset_out (FILE * _out_str , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyout = _out_str ;
}
-int cmCommandArgument_yyget_debug (yyscan_t yyscanner)
+int yyget_debug (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yy_flex_debug;
}
-void cmCommandArgument_yyset_debug (int _bdebug , yyscan_t yyscanner)
+void yyset_debug (int _bdebug , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yy_flex_debug = _bdebug ;
@@ -1872,20 +2058,18 @@ void cmCommandArgument_yyset_debug (int _bdebug , yyscan_t yyscanner)
/* User-visible API */
-/* cmCommandArgument_yylex_init is special because it creates the scanner itself, so it is
+/* yylex_init is special because it creates the scanner itself, so it is
* the ONLY reentrant function that doesn't take the scanner as the last argument.
* That's why we explicitly handle the declaration, instead of using our macros.
*/
-
-int cmCommandArgument_yylex_init(yyscan_t* ptr_yy_globals)
-
+int yylex_init(yyscan_t* ptr_yy_globals)
{
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
- *ptr_yy_globals = (yyscan_t) cmCommandArgument_yyalloc ( sizeof( struct yyguts_t ), NULL );
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
@@ -1898,27 +2082,25 @@ int cmCommandArgument_yylex_init(yyscan_t* ptr_yy_globals)
return yy_init_globals ( *ptr_yy_globals );
}
-/* cmCommandArgument_yylex_init_extra has the same functionality as cmCommandArgument_yylex_init, but follows the
+/* yylex_init_extra has the same functionality as yylex_init, but follows the
* convention of taking the scanner as the last argument. Note however, that
* this is a *pointer* to a scanner, as it will be allocated by this call (and
* is the reason, too, why this function also must handle its own declaration).
- * The user defined value in the first argument will be available to cmCommandArgument_yyalloc in
+ * The user defined value in the first argument will be available to yyalloc in
* the yyextra field.
*/
-
-int cmCommandArgument_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
-
+int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
{
struct yyguts_t dummy_yyguts;
- cmCommandArgument_yyset_extra (yy_user_defined, &dummy_yyguts);
+ yyset_extra (yy_user_defined, &dummy_yyguts);
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
- *ptr_yy_globals = (yyscan_t) cmCommandArgument_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
@@ -1929,7 +2111,7 @@ int cmCommandArgument_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* p
yy_init_globals. Leave at 0x00 for releases. */
memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
- cmCommandArgument_yyset_extra (yy_user_defined, *ptr_yy_globals);
+ yyset_extra (yy_user_defined, *ptr_yy_globals);
return yy_init_globals ( *ptr_yy_globals );
}
@@ -1938,7 +2120,7 @@ static int yy_init_globals (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Initialization is the same as for the non-reentrant scanner.
- * This function is called from cmCommandArgument_yylex_destroy(), so don't allocate here.
+ * This function is called from yylex_destroy(), so don't allocate here.
*/
yyg->yy_buffer_stack = NULL;
@@ -1962,37 +2144,37 @@ static int yy_init_globals (yyscan_t yyscanner)
#endif
/* For future reference: Set errno on error, since we are called by
- * cmCommandArgument_yylex_init()
+ * yylex_init()
*/
return 0;
}
-/* cmCommandArgument_yylex_destroy is for both reentrant and non-reentrant scanners. */
-int cmCommandArgument_yylex_destroy (yyscan_t yyscanner)
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
+int yylex_destroy (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
- cmCommandArgument_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
+ yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
YY_CURRENT_BUFFER_LVALUE = NULL;
- cmCommandArgument_yypop_buffer_state(yyscanner);
+ yypop_buffer_state(yyscanner);
}
/* Destroy the stack itself. */
- cmCommandArgument_yyfree(yyg->yy_buffer_stack ,yyscanner);
+ yyfree(yyg->yy_buffer_stack , yyscanner);
yyg->yy_buffer_stack = NULL;
/* Destroy the start condition stack. */
- cmCommandArgument_yyfree(yyg->yy_start_stack ,yyscanner );
+ yyfree( yyg->yy_start_stack , yyscanner );
yyg->yy_start_stack = NULL;
/* Reset the globals. This is important in a non-reentrant scanner so the next time
- * cmCommandArgument_yylex() is called, initialization will occur. */
+ * yylex() is called, initialization will occur. */
yy_init_globals( yyscanner);
/* Destroy the main struct (reentrant only). */
- cmCommandArgument_yyfree ( yyscanner , yyscanner );
+ yyfree ( yyscanner , yyscanner );
yyscanner = NULL;
return 0;
}
@@ -2002,7 +2184,7 @@ int cmCommandArgument_yylex_destroy (yyscan_t yyscanner)
*/
#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
+static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
@@ -2014,7 +2196,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
+static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
{
int n;
for ( n = 0; s[n]; ++n )
@@ -2024,14 +2206,14 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
}
#endif
-void *cmCommandArgument_yyalloc (yy_size_t size , yyscan_t yyscanner)
+void *yyalloc (yy_size_t size , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
return malloc(size);
}
-void *cmCommandArgument_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
+void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
@@ -2046,19 +2228,15 @@ void *cmCommandArgument_yyrealloc (void * ptr, yy_size_t size , yyscan_t yysca
return realloc(ptr, size);
}
-void cmCommandArgument_yyfree (void * ptr , yyscan_t yyscanner)
+void yyfree (void * ptr , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
- free( (char *) ptr ); /* see cmCommandArgument_yyrealloc() for (char *) cast */
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"
-#line 127 "cmCommandArgumentLexer.in.l"
-
-
-
/*--------------------------------------------------------------------------*/
void cmCommandArgument_SetupEscapes(yyscan_t yyscanner, bool noEscapes)
{
@@ -2070,3 +2248,5 @@ void cmCommandArgument_SetupEscapes(yyscan_t yyscanner, bool noEscapes)
BEGIN(ESCAPES);
}
}
+
+#endif /* __clang_analyzer__ */
diff --git a/Source/LexerParser/cmCommandArgumentLexer.h b/Source/LexerParser/cmCommandArgumentLexer.h
index 82e87b557..567751349 100644
--- a/Source/LexerParser/cmCommandArgumentLexer.h
+++ b/Source/LexerParser/cmCommandArgumentLexer.h
@@ -2,10 +2,6 @@
#define cmCommandArgument_yyHEADER_H 1
#define cmCommandArgument_yyIN_HEADER 1
-#line 6 "cmCommandArgumentLexer.h"
-
-#line 8 "cmCommandArgumentLexer.h"
-
#define FLEXINT_H 1
#define YY_INT_ALIGNED short int
@@ -14,11 +10,221 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
+#define YY_FLEX_SUBMINOR_VERSION 4
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
+#ifdef yy_create_buffer
+#define cmCommandArgument_yy_create_buffer_ALREADY_DEFINED
+#else
+#define yy_create_buffer cmCommandArgument_yy_create_buffer
+#endif
+
+#ifdef yy_delete_buffer
+#define cmCommandArgument_yy_delete_buffer_ALREADY_DEFINED
+#else
+#define yy_delete_buffer cmCommandArgument_yy_delete_buffer
+#endif
+
+#ifdef yy_scan_buffer
+#define cmCommandArgument_yy_scan_buffer_ALREADY_DEFINED
+#else
+#define yy_scan_buffer cmCommandArgument_yy_scan_buffer
+#endif
+
+#ifdef yy_scan_string
+#define cmCommandArgument_yy_scan_string_ALREADY_DEFINED
+#else
+#define yy_scan_string cmCommandArgument_yy_scan_string
+#endif
+
+#ifdef yy_scan_bytes
+#define cmCommandArgument_yy_scan_bytes_ALREADY_DEFINED
+#else
+#define yy_scan_bytes cmCommandArgument_yy_scan_bytes
+#endif
+
+#ifdef yy_init_buffer
+#define cmCommandArgument_yy_init_buffer_ALREADY_DEFINED
+#else
+#define yy_init_buffer cmCommandArgument_yy_init_buffer
+#endif
+
+#ifdef yy_flush_buffer
+#define cmCommandArgument_yy_flush_buffer_ALREADY_DEFINED
+#else
+#define yy_flush_buffer cmCommandArgument_yy_flush_buffer
+#endif
+
+#ifdef yy_load_buffer_state
+#define cmCommandArgument_yy_load_buffer_state_ALREADY_DEFINED
+#else
+#define yy_load_buffer_state cmCommandArgument_yy_load_buffer_state
+#endif
+
+#ifdef yy_switch_to_buffer
+#define cmCommandArgument_yy_switch_to_buffer_ALREADY_DEFINED
+#else
+#define yy_switch_to_buffer cmCommandArgument_yy_switch_to_buffer
+#endif
+
+#ifdef yypush_buffer_state
+#define cmCommandArgument_yypush_buffer_state_ALREADY_DEFINED
+#else
+#define yypush_buffer_state cmCommandArgument_yypush_buffer_state
+#endif
+
+#ifdef yypop_buffer_state
+#define cmCommandArgument_yypop_buffer_state_ALREADY_DEFINED
+#else
+#define yypop_buffer_state cmCommandArgument_yypop_buffer_state
+#endif
+
+#ifdef yyensure_buffer_stack
+#define cmCommandArgument_yyensure_buffer_stack_ALREADY_DEFINED
+#else
+#define yyensure_buffer_stack cmCommandArgument_yyensure_buffer_stack
+#endif
+
+#ifdef yylex
+#define cmCommandArgument_yylex_ALREADY_DEFINED
+#else
+#define yylex cmCommandArgument_yylex
+#endif
+
+#ifdef yyrestart
+#define cmCommandArgument_yyrestart_ALREADY_DEFINED
+#else
+#define yyrestart cmCommandArgument_yyrestart
+#endif
+
+#ifdef yylex_init
+#define cmCommandArgument_yylex_init_ALREADY_DEFINED
+#else
+#define yylex_init cmCommandArgument_yylex_init
+#endif
+
+#ifdef yylex_init_extra
+#define cmCommandArgument_yylex_init_extra_ALREADY_DEFINED
+#else
+#define yylex_init_extra cmCommandArgument_yylex_init_extra
+#endif
+
+#ifdef yylex_destroy
+#define cmCommandArgument_yylex_destroy_ALREADY_DEFINED
+#else
+#define yylex_destroy cmCommandArgument_yylex_destroy
+#endif
+
+#ifdef yyget_debug
+#define cmCommandArgument_yyget_debug_ALREADY_DEFINED
+#else
+#define yyget_debug cmCommandArgument_yyget_debug
+#endif
+
+#ifdef yyset_debug
+#define cmCommandArgument_yyset_debug_ALREADY_DEFINED
+#else
+#define yyset_debug cmCommandArgument_yyset_debug
+#endif
+
+#ifdef yyget_extra
+#define cmCommandArgument_yyget_extra_ALREADY_DEFINED
+#else
+#define yyget_extra cmCommandArgument_yyget_extra
+#endif
+
+#ifdef yyset_extra
+#define cmCommandArgument_yyset_extra_ALREADY_DEFINED
+#else
+#define yyset_extra cmCommandArgument_yyset_extra
+#endif
+
+#ifdef yyget_in
+#define cmCommandArgument_yyget_in_ALREADY_DEFINED
+#else
+#define yyget_in cmCommandArgument_yyget_in
+#endif
+
+#ifdef yyset_in
+#define cmCommandArgument_yyset_in_ALREADY_DEFINED
+#else
+#define yyset_in cmCommandArgument_yyset_in
+#endif
+
+#ifdef yyget_out
+#define cmCommandArgument_yyget_out_ALREADY_DEFINED
+#else
+#define yyget_out cmCommandArgument_yyget_out
+#endif
+
+#ifdef yyset_out
+#define cmCommandArgument_yyset_out_ALREADY_DEFINED
+#else
+#define yyset_out cmCommandArgument_yyset_out
+#endif
+
+#ifdef yyget_leng
+#define cmCommandArgument_yyget_leng_ALREADY_DEFINED
+#else
+#define yyget_leng cmCommandArgument_yyget_leng
+#endif
+
+#ifdef yyget_text
+#define cmCommandArgument_yyget_text_ALREADY_DEFINED
+#else
+#define yyget_text cmCommandArgument_yyget_text
+#endif
+
+#ifdef yyget_lineno
+#define cmCommandArgument_yyget_lineno_ALREADY_DEFINED
+#else
+#define yyget_lineno cmCommandArgument_yyget_lineno
+#endif
+
+#ifdef yyset_lineno
+#define cmCommandArgument_yyset_lineno_ALREADY_DEFINED
+#else
+#define yyset_lineno cmCommandArgument_yyset_lineno
+#endif
+
+#ifdef yyget_column
+#define cmCommandArgument_yyget_column_ALREADY_DEFINED
+#else
+#define yyget_column cmCommandArgument_yyget_column
+#endif
+
+#ifdef yyset_column
+#define cmCommandArgument_yyset_column_ALREADY_DEFINED
+#else
+#define yyset_column cmCommandArgument_yyset_column
+#endif
+
+#ifdef yywrap
+#define cmCommandArgument_yywrap_ALREADY_DEFINED
+#else
+#define yywrap cmCommandArgument_yywrap
+#endif
+
+#ifdef yyalloc
+#define cmCommandArgument_yyalloc_ALREADY_DEFINED
+#else
+#define yyalloc cmCommandArgument_yyalloc
+#endif
+
+#ifdef yyrealloc
+#define cmCommandArgument_yyrealloc_ALREADY_DEFINED
+#else
+#define yyrealloc cmCommandArgument_yyrealloc
+#endif
+
+#ifdef yyfree
+#define cmCommandArgument_yyfree_ALREADY_DEFINED
+#else
+#define yyfree cmCommandArgument_yyfree
+#endif
+
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
@@ -89,10 +295,16 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
+#ifndef SIZE_MAX
+#define SIZE_MAX (~(size_t)0)
+#endif
+
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */
+
/* TODO: this is always defined, so inline it */
#define yyconst const
@@ -193,21 +405,21 @@ struct yy_buffer_state
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-void cmCommandArgument_yyrestart (FILE *input_file ,yyscan_t yyscanner );
-void cmCommandArgument_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmCommandArgument_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
-void cmCommandArgument_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmCommandArgument_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmCommandArgument_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-void cmCommandArgument_yypop_buffer_state (yyscan_t yyscanner );
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+void yypop_buffer_state ( yyscan_t yyscanner );
-YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmCommandArgument_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmCommandArgument_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
-void *cmCommandArgument_yyalloc (yy_size_t ,yyscan_t yyscanner );
-void *cmCommandArgument_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
-void cmCommandArgument_yyfree (void * ,yyscan_t yyscanner );
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
+void yyfree ( void * , yyscan_t yyscanner );
/* Begin user sect3 */
@@ -227,42 +439,42 @@ void cmCommandArgument_yyfree (void * ,yyscan_t yyscanner );
#define YY_EXTRA_TYPE void *
#endif
-int cmCommandArgument_yylex_init (yyscan_t* scanner);
+int yylex_init (yyscan_t* scanner);
-int cmCommandArgument_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
-int cmCommandArgument_yylex_destroy (yyscan_t yyscanner );
+int yylex_destroy ( yyscan_t yyscanner );
-int cmCommandArgument_yyget_debug (yyscan_t yyscanner );
+int yyget_debug ( yyscan_t yyscanner );
-void cmCommandArgument_yyset_debug (int debug_flag ,yyscan_t yyscanner );
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
-YY_EXTRA_TYPE cmCommandArgument_yyget_extra (yyscan_t yyscanner );
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
-void cmCommandArgument_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
-FILE *cmCommandArgument_yyget_in (yyscan_t yyscanner );
+FILE *yyget_in ( yyscan_t yyscanner );
-void cmCommandArgument_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
+void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
-FILE *cmCommandArgument_yyget_out (yyscan_t yyscanner );
+FILE *yyget_out ( yyscan_t yyscanner );
-void cmCommandArgument_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
+void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
- int cmCommandArgument_yyget_leng (yyscan_t yyscanner );
+ int yyget_leng ( yyscan_t yyscanner );
-char *cmCommandArgument_yyget_text (yyscan_t yyscanner );
+char *yyget_text ( yyscan_t yyscanner );
-int cmCommandArgument_yyget_lineno (yyscan_t yyscanner );
+int yyget_lineno ( yyscan_t yyscanner );
-void cmCommandArgument_yyset_lineno (int _line_number ,yyscan_t yyscanner );
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
-int cmCommandArgument_yyget_column (yyscan_t yyscanner );
+int yyget_column ( yyscan_t yyscanner );
-void cmCommandArgument_yyset_column (int _column_no ,yyscan_t yyscanner );
+void yyset_column ( int _column_no , yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -270,18 +482,18 @@ void cmCommandArgument_yyset_column (int _column_no ,yyscan_t yyscanner );
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int cmCommandArgument_yywrap (yyscan_t yyscanner );
+extern "C" int yywrap ( yyscan_t yyscanner );
#else
-extern int cmCommandArgument_yywrap (yyscan_t yyscanner );
+extern int yywrap ( yyscan_t yyscanner );
#endif
#endif
#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
@@ -309,9 +521,9 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-extern int cmCommandArgument_yylex (yyscan_t yyscanner);
+extern int yylex (yyscan_t yyscanner);
-#define YY_DECL int cmCommandArgument_yylex (yyscan_t yyscanner)
+#define YY_DECL int yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */
/* yy_get_previous_state - get the state just before the EOB char was reached */
@@ -328,9 +540,150 @@ extern int cmCommandArgument_yylex (yyscan_t yyscanner);
#undef YY_DECL
#endif
-#line 127 "cmCommandArgumentLexer.in.l"
-
+#ifndef cmCommandArgument_yy_create_buffer_ALREADY_DEFINED
+#undef yy_create_buffer
+#endif
+#ifndef cmCommandArgument_yy_delete_buffer_ALREADY_DEFINED
+#undef yy_delete_buffer
+#endif
+#ifndef cmCommandArgument_yy_scan_buffer_ALREADY_DEFINED
+#undef yy_scan_buffer
+#endif
+#ifndef cmCommandArgument_yy_scan_string_ALREADY_DEFINED
+#undef yy_scan_string
+#endif
+#ifndef cmCommandArgument_yy_scan_bytes_ALREADY_DEFINED
+#undef yy_scan_bytes
+#endif
+#ifndef cmCommandArgument_yy_init_buffer_ALREADY_DEFINED
+#undef yy_init_buffer
+#endif
+#ifndef cmCommandArgument_yy_flush_buffer_ALREADY_DEFINED
+#undef yy_flush_buffer
+#endif
+#ifndef cmCommandArgument_yy_load_buffer_state_ALREADY_DEFINED
+#undef yy_load_buffer_state
+#endif
+#ifndef cmCommandArgument_yy_switch_to_buffer_ALREADY_DEFINED
+#undef yy_switch_to_buffer
+#endif
+#ifndef cmCommandArgument_yypush_buffer_state_ALREADY_DEFINED
+#undef yypush_buffer_state
+#endif
+#ifndef cmCommandArgument_yypop_buffer_state_ALREADY_DEFINED
+#undef yypop_buffer_state
+#endif
+#ifndef cmCommandArgument_yyensure_buffer_stack_ALREADY_DEFINED
+#undef yyensure_buffer_stack
+#endif
+#ifndef cmCommandArgument_yylex_ALREADY_DEFINED
+#undef yylex
+#endif
+#ifndef cmCommandArgument_yyrestart_ALREADY_DEFINED
+#undef yyrestart
+#endif
+#ifndef cmCommandArgument_yylex_init_ALREADY_DEFINED
+#undef yylex_init
+#endif
+#ifndef cmCommandArgument_yylex_init_extra_ALREADY_DEFINED
+#undef yylex_init_extra
+#endif
+#ifndef cmCommandArgument_yylex_destroy_ALREADY_DEFINED
+#undef yylex_destroy
+#endif
+#ifndef cmCommandArgument_yyget_debug_ALREADY_DEFINED
+#undef yyget_debug
+#endif
+#ifndef cmCommandArgument_yyset_debug_ALREADY_DEFINED
+#undef yyset_debug
+#endif
+#ifndef cmCommandArgument_yyget_extra_ALREADY_DEFINED
+#undef yyget_extra
+#endif
+#ifndef cmCommandArgument_yyset_extra_ALREADY_DEFINED
+#undef yyset_extra
+#endif
+#ifndef cmCommandArgument_yyget_in_ALREADY_DEFINED
+#undef yyget_in
+#endif
+#ifndef cmCommandArgument_yyset_in_ALREADY_DEFINED
+#undef yyset_in
+#endif
+#ifndef cmCommandArgument_yyget_out_ALREADY_DEFINED
+#undef yyget_out
+#endif
+#ifndef cmCommandArgument_yyset_out_ALREADY_DEFINED
+#undef yyset_out
+#endif
+#ifndef cmCommandArgument_yyget_leng_ALREADY_DEFINED
+#undef yyget_leng
+#endif
+#ifndef cmCommandArgument_yyget_text_ALREADY_DEFINED
+#undef yyget_text
+#endif
+#ifndef cmCommandArgument_yyget_lineno_ALREADY_DEFINED
+#undef yyget_lineno
+#endif
+#ifndef cmCommandArgument_yyset_lineno_ALREADY_DEFINED
+#undef yyset_lineno
+#endif
+#ifndef cmCommandArgument_yyget_column_ALREADY_DEFINED
+#undef yyget_column
+#endif
+#ifndef cmCommandArgument_yyset_column_ALREADY_DEFINED
+#undef yyset_column
+#endif
+#ifndef cmCommandArgument_yywrap_ALREADY_DEFINED
+#undef yywrap
+#endif
+#ifndef cmCommandArgument_yyget_lval_ALREADY_DEFINED
+#undef yyget_lval
+#endif
+#ifndef cmCommandArgument_yyset_lval_ALREADY_DEFINED
+#undef yyset_lval
+#endif
+#ifndef cmCommandArgument_yyget_lloc_ALREADY_DEFINED
+#undef yyget_lloc
+#endif
+#ifndef cmCommandArgument_yyset_lloc_ALREADY_DEFINED
+#undef yyset_lloc
+#endif
+#ifndef cmCommandArgument_yyalloc_ALREADY_DEFINED
+#undef yyalloc
+#endif
+#ifndef cmCommandArgument_yyrealloc_ALREADY_DEFINED
+#undef yyrealloc
+#endif
+#ifndef cmCommandArgument_yyfree_ALREADY_DEFINED
+#undef yyfree
+#endif
+#ifndef cmCommandArgument_yytext_ALREADY_DEFINED
+#undef yytext
+#endif
+#ifndef cmCommandArgument_yyleng_ALREADY_DEFINED
+#undef yyleng
+#endif
+#ifndef cmCommandArgument_yyin_ALREADY_DEFINED
+#undef yyin
+#endif
+#ifndef cmCommandArgument_yyout_ALREADY_DEFINED
+#undef yyout
+#endif
+#ifndef cmCommandArgument_yy_flex_debug_ALREADY_DEFINED
+#undef yy_flex_debug
+#endif
+#ifndef cmCommandArgument_yylineno_ALREADY_DEFINED
+#undef yylineno
+#endif
+#ifndef cmCommandArgument_yytables_fload_ALREADY_DEFINED
+#undef yytables_fload
+#endif
+#ifndef cmCommandArgument_yytables_destroy_ALREADY_DEFINED
+#undef yytables_destroy
+#endif
+#ifndef cmCommandArgument_yyTABLES_NAME_ALREADY_DEFINED
+#undef yyTABLES_NAME
+#endif
-#line 335 "cmCommandArgumentLexer.h"
#undef cmCommandArgument_yyIN_HEADER
#endif /* cmCommandArgument_yyHEADER_H */
diff --git a/Source/LexerParser/cmCommandArgumentLexer.in.l b/Source/LexerParser/cmCommandArgumentLexer.in.l
index e3a80948c..010d54bf5 100644
--- a/Source/LexerParser/cmCommandArgumentLexer.in.l
+++ b/Source/LexerParser/cmCommandArgumentLexer.in.l
@@ -7,31 +7,41 @@ This file must be translated to C++ and modified to build everywhere.
Run flex >= 2.6 like this:
- flex --nounistd -DFLEXINT_H --prefix=cmCommandArgument_yy --header-file=cmCommandArgumentLexer.h -ocmCommandArgumentLexer.cxx cmCommandArgumentLexer.in.l
+ flex --nounistd -DFLEXINT_H --noline --header-file=cmCommandArgumentLexer.h -ocmCommandArgumentLexer.cxx cmCommandArgumentLexer.in.l
Modify cmCommandArgumentLexer.cxx:
- - remove trailing whitespace: sed -i 's/\s*$//' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx
- - remove blank lines at end of file
- - #include "cmStandardLexer.h" at the top
- - add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t
+ - remove trailing whitespace: sed -i 's/\s*$//' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx
+ - remove blank lines at end of file: sed -i '${/^$/d;}' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx
+ - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmCommandArgumentLexer.cxx
*/
/* IWYU pragma: no_forward_declare yyguts_t */
+#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+
#include "cmCommandArgumentParserHelper.h"
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
- { result = yyextra->LexInput(buf, max_size); }
+ do { result = yyextra->LexInput(buf, max_size); } while (0)
/* Include the set of tokens from the parser. */
#include "cmCommandArgumentParserTokens.h"
+static const char *DCURLYVariable = "${";
+static const char *RCURLYVariable = "}";
+static const char *ATVariable = "@";
+static const char *DOLLARVariable = "$";
+static const char *LCURLYVariable = "{";
+static const char *BSLASHVariable = "\\";
+
/*--------------------------------------------------------------------------*/
%}
+%option prefix="cmCommandArgument_yy"
+
%option reentrant
%option noyywrap
%option nounput
@@ -62,21 +72,21 @@ Modify cmCommandArgumentLexer.cxx:
"${" {
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->DCURLYVariable;
+ yylvalp->str = DCURLYVariable;
return cal_DCURLY;
}
"}" {
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->RCURLYVariable;
+ yylvalp->str = RCURLYVariable;
return cal_RCURLY;
}
"@" {
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->ATVariable;
+ yylvalp->str = ATVariable;
return cal_AT;
}
@@ -102,25 +112,25 @@ Modify cmCommandArgumentLexer.cxx:
"$" {
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->DOLLARVariable;
+ yylvalp->str = DOLLARVariable;
return cal_DOLLAR;
}
"{" {
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->LCURLYVariable;
+ yylvalp->str = LCURLYVariable;
return cal_LCURLY;
}
<ESCAPES>"\\" {
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->BSLASHVariable;
+ yylvalp->str = BSLASHVariable;
return cal_BSLASH;
}
<NOESCAPES>"\\" {
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
- yylvalp->str = yyextra->BSLASHVariable;
+ yylvalp->str = BSLASHVariable;
return cal_SYMBOL;
}
@@ -137,3 +147,5 @@ void cmCommandArgument_SetupEscapes(yyscan_t yyscanner, bool noEscapes)
BEGIN(ESCAPES);
}
}
+
+#endif /* __clang_analyzer__ */
diff --git a/Source/LexerParser/cmCommandArgumentParser.cxx b/Source/LexerParser/cmCommandArgumentParser.cxx
index aed0826c0..ae7fb42ea 100644
--- a/Source/LexerParser/cmCommandArgumentParser.cxx
+++ b/Source/LexerParser/cmCommandArgumentParser.cxx
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
+/* A Bison parser, made by GNU Bison 3.3.2. */
/* Bison implementation for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
+ Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -40,11 +41,14 @@
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
+/* Undocumented macros, especially those whose name start with YY_,
+ are private implementation details. Do not rely on them. */
+
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "3.0.4"
+#define YYBISON_VERSION "3.3.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -67,8 +71,8 @@
#define yynerrs cmCommandArgument_yynerrs
-/* Copy the first part of user declarations. */
-#line 1 "cmCommandArgumentParser.y" /* yacc.c:339 */
+/* First part of user prologue. */
+#line 1 "cmCommandArgumentParser.y" /* yacc.c:337 */
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
@@ -126,14 +130,20 @@ static void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message);
# pragma warning (disable: 4244) /* loss of precision */
# pragma warning (disable: 4702) /* unreachable code */
#endif
+#if defined(__GNUC__) && __GNUC__ >= 8
+# pragma GCC diagnostic ignored "-Wconversion"
+#endif
-#line 131 "cmCommandArgumentParser.cxx" /* yacc.c:339 */
-
+#line 138 "cmCommandArgumentParser.cxx" /* yacc.c:337 */
# ifndef YY_NULLPTR
-# if defined __cplusplus && 201103L <= __cplusplus
-# define YY_NULLPTR nullptr
+# if defined __cplusplus
+# if 201103L <= __cplusplus
+# define YY_NULLPTR nullptr
+# else
+# define YY_NULLPTR 0
+# endif
# else
-# define YY_NULLPTR 0
+# define YY_NULLPTR ((void*)0)
# endif
# endif
@@ -198,9 +208,7 @@ int cmCommandArgument_yyparse (yyscan_t yyscanner);
#endif /* !YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED */
-/* Copy the second part of user declarations. */
-#line 204 "cmCommandArgumentParser.cxx" /* yacc.c:358 */
#ifdef short
# undef short
@@ -221,13 +229,13 @@ typedef signed char yytype_int8;
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
-typedef unsigned short int yytype_uint16;
+typedef unsigned short yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
-typedef short int yytype_int16;
+typedef short yytype_int16;
#endif
#ifndef YYSIZE_T
@@ -239,7 +247,7 @@ typedef short int yytype_int16;
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
-# define YYSIZE_T unsigned int
+# define YYSIZE_T unsigned
# endif
#endif
@@ -275,15 +283,6 @@ typedef short int yytype_int16;
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
-#if !defined _Noreturn \
- && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
-# if defined _MSC_VER && 1200 <= _MSC_VER
-# define _Noreturn __declspec (noreturn)
-# else
-# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
-# endif
-#endif
-
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
@@ -291,7 +290,7 @@ typedef short int yytype_int16;
# define YYUSE(E) /* empty */
#endif
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
@@ -453,16 +452,16 @@ union yyalloc
/* YYNSTATES -- Number of states. */
#define YYNSTATES 33
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
- by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 269
+/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
+ as returned by yylex, with out-of-bounds checking. */
#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+ ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
- as returned by yylex, without out-of-bounds checking. */
+ as returned by yylex. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -498,9 +497,9 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
- 0, 96, 96, 102, 105, 110, 113, 118, 121, 126,
- 129, 132, 135, 138, 141, 146, 149, 152, 155, 160,
- 163, 168, 171, 176, 179
+ 0, 99, 99, 105, 108, 113, 116, 121, 124, 129,
+ 132, 135, 138, 141, 144, 149, 152, 155, 158, 163,
+ 166, 171, 174, 179, 182
};
#endif
@@ -630,22 +629,22 @@ static const yytype_uint8 yyr2[] =
#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (yylen); \
- yystate = *yyssp; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (yyscanner, YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (0)
+#define YYBACKUP(Token, Value) \
+ do \
+ if (yychar == YYEMPTY) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (yylen); \
+ yystate = *yyssp; \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (yyscanner, YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+ while (0)
/* Error token number */
#define YYTERROR 1
@@ -685,38 +684,38 @@ do { \
} while (0)
-/*----------------------------------------.
-| Print this symbol's value on YYOUTPUT. |
-`----------------------------------------*/
+/*-----------------------------------.
+| Print this symbol's value on YYO. |
+`-----------------------------------*/
static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
+yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
{
- FILE *yyo = yyoutput;
- YYUSE (yyo);
+ FILE *yyoutput = yyo;
+ YYUSE (yyoutput);
YYUSE (yyscanner);
if (!yyvaluep)
return;
# ifdef YYPRINT
if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+ YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
# endif
YYUSE (yytype);
}
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
+/*---------------------------.
+| Print this symbol on YYO. |
+`---------------------------*/
static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
+yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
{
- YYFPRINTF (yyoutput, "%s %s (",
+ YYFPRINTF (yyo, "%s %s (",
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
- yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner);
- YYFPRINTF (yyoutput, ")");
+ yy_symbol_value_print (yyo, yytype, yyvaluep, yyscanner);
+ YYFPRINTF (yyo, ")");
}
/*------------------------------------------------------------------.
@@ -750,7 +749,7 @@ do { \
static void
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner)
{
- unsigned long int yylno = yyrline[yyrule];
+ unsigned long yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
@@ -761,7 +760,7 @@ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, yyscan_t yysca
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
yystos[yyssp[yyi + 1 - yynrhs]],
- &(yyvsp[(yyi + 1) - (yynrhs)])
+ &yyvsp[(yyi + 1) - (yynrhs)]
, yyscanner);
YYFPRINTF (stderr, "\n");
}
@@ -865,7 +864,10 @@ yytnamerr (char *yyres, const char *yystr)
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
- /* Fall through. */
+ else
+ goto append;
+
+ append:
default:
if (yyres)
yyres[yyn] = *yyp;
@@ -883,7 +885,7 @@ yytnamerr (char *yyres, const char *yystr)
if (! yyres)
return yystrlen (yystr);
- return yystpcpy (yyres, yystr) - yyres;
+ return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
}
# endif
@@ -961,10 +963,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yyarg[yycount++] = yytname[yyx];
{
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
- if (! (yysize <= yysize1
- && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+ yysize = yysize1;
+ else
return 2;
- yysize = yysize1;
}
}
}
@@ -976,6 +978,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
case N: \
yyformat = S; \
break
+ default: /* Avoid compiler warnings. */
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
@@ -987,9 +990,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
{
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
- if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+ yysize = yysize1;
+ else
return 2;
- yysize = yysize1;
}
if (*yymsg_alloc < yysize)
@@ -1120,23 +1124,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
+
/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
+| yynewstate -- push a new state, which is found in yystate. |
`------------------------------------------------------------*/
- yynewstate:
+yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
- yysetstate:
- *yyssp = yystate;
+
+/*--------------------------------------------------------------------.
+| yynewstate -- set current state (the top of the stack) to yystate. |
+`--------------------------------------------------------------------*/
+yysetstate:
+ *yyssp = (yytype_int16) yystate;
if (yyss + yystacksize - 1 <= yyssp)
+#if !defined yyoverflow && !defined YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+#else
{
/* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
+ YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
-#ifdef yyoverflow
+# if defined yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
@@ -1152,14 +1164,10 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
-
yyss = yyss1;
yyvs = yyvs1;
}
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
+# else /* defined YYSTACK_RELOCATE */
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
@@ -1175,22 +1183,22 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
-# undef YYSTACK_RELOCATE
+# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
-#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
+ (unsigned long) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
+#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
@@ -1199,11 +1207,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
goto yybackup;
+
/*-----------.
| yybackup. |
`-----------*/
yybackup:
-
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
@@ -1276,7 +1284,7 @@ yydefault:
/*-----------------------------.
-| yyreduce -- Do a reduction. |
+| yyreduce -- do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
@@ -1297,192 +1305,192 @@ yyreduce:
switch (yyn)
{
case 2:
-#line 96 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 99 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = 0;
yyGetParser->SetResult((yyvsp[0].str));
}
-#line 1306 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1314 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 3:
-#line 102 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 105 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = (yyvsp[0].str);
}
-#line 1314 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1322 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 4:
-#line 105 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 108 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = yyGetParser->CombineUnions((yyvsp[-1].str), (yyvsp[0].str));
}
-#line 1322 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1330 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 5:
-#line 110 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 113 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = 0;
}
-#line 1330 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1338 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 6:
-#line 113 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 116 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = yyGetParser->CombineUnions((yyvsp[-1].str), (yyvsp[0].str));
}
-#line 1338 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1346 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 7:
-#line 118 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 121 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = (yyvsp[0].str);
}
-#line 1346 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1354 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 8:
-#line 121 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 124 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = (yyvsp[0].str);
}
-#line 1354 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1362 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 9:
-#line 126 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 129 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = (yyvsp[0].str);
}
-#line 1362 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1370 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 10:
-#line 129 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 132 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = (yyvsp[0].str);
}
-#line 1370 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1378 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 11:
-#line 132 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 135 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = (yyvsp[0].str);
}
-#line 1378 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1386 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 12:
-#line 135 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 138 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = (yyvsp[0].str);
}
-#line 1386 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1394 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 13:
-#line 138 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 141 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = (yyvsp[0].str);
}
-#line 1394 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1402 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 14:
-#line 141 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 144 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = (yyvsp[0].str);
}
-#line 1402 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1410 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 15:
-#line 146 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 149 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = yyGetParser->ExpandSpecialVariable((yyvsp[-2].str), (yyvsp[-1].str));
}
-#line 1410 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1418 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 16:
-#line 149 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 152 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = yyGetParser->ExpandSpecialVariable((yyvsp[-2].str), (yyvsp[-1].str));
}
-#line 1418 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1426 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 17:
-#line 152 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 155 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = yyGetParser->ExpandVariable((yyvsp[-1].str));
}
-#line 1426 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1434 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 18:
-#line 155 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 158 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = yyGetParser->ExpandVariableForAt((yyvsp[0].str));
}
-#line 1434 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1442 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 19:
-#line 160 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 163 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = (yyvsp[0].str);
}
-#line 1442 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1450 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 20:
-#line 163 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 166 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = (yyvsp[-1].str);
}
-#line 1450 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1458 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 21:
-#line 168 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 171 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = 0;
}
-#line 1458 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1466 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 22:
-#line 171 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 174 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = yyGetParser->CombineUnions((yyvsp[-1].str), (yyvsp[0].str));
}
-#line 1466 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1474 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 23:
-#line 176 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 179 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = (yyvsp[0].str);
}
-#line 1474 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1482 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
case 24:
-#line 179 "cmCommandArgumentParser.y" /* yacc.c:1646 */
+#line 182 "cmCommandArgumentParser.y" /* yacc.c:1652 */
{
(yyval.str) = (yyvsp[0].str);
}
-#line 1482 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1490 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
break;
-#line 1486 "cmCommandArgumentParser.cxx" /* yacc.c:1646 */
+#line 1494 "cmCommandArgumentParser.cxx" /* yacc.c:1652 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -1507,14 +1515,13 @@ yyreduce:
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
+ {
+ const int yylhs = yyr1[yyn] - YYNTOKENS;
+ const int yyi = yypgoto[yylhs] + *yyssp;
+ yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
+ ? yytable[yyi]
+ : yydefgoto[yylhs]);
+ }
goto yynewstate;
@@ -1598,12 +1605,10 @@ yyerrlab:
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
+ /* Pacify compilers when the user code never invokes YYERROR and the
+ label yyerrorlab therefore never appears in user code. */
+ if (0)
+ YYERROR;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
@@ -1666,6 +1671,7 @@ yyacceptlab:
yyresult = 0;
goto yyreturn;
+
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
@@ -1673,6 +1679,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
+
#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
@@ -1683,6 +1690,10 @@ yyexhaustedlab:
/* Fall through. */
#endif
+
+/*-----------------------------------------------------.
+| yyreturn -- parsing is finished, return the result. |
+`-----------------------------------------------------*/
yyreturn:
if (yychar != YYEMPTY)
{
@@ -1712,7 +1723,7 @@ yyreturn:
#endif
return yyresult;
}
-#line 184 "cmCommandArgumentParser.y" /* yacc.c:1906 */
+#line 187 "cmCommandArgumentParser.y" /* yacc.c:1918 */
/* End of grammar */
diff --git a/Source/LexerParser/cmCommandArgumentParser.y b/Source/LexerParser/cmCommandArgumentParser.y
index 55a88dffa..0c6aad547 100644
--- a/Source/LexerParser/cmCommandArgumentParser.y
+++ b/Source/LexerParser/cmCommandArgumentParser.y
@@ -55,6 +55,9 @@ static void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message);
# pragma warning (disable: 4244) /* loss of precision */
# pragma warning (disable: 4702) /* unreachable code */
#endif
+#if defined(__GNUC__) && __GNUC__ >= 8
+# pragma GCC diagnostic ignored "-Wconversion"
+#endif
%}
/* Generate a reentrant parser object. */
diff --git a/Source/LexerParser/cmCommandArgumentParserTokens.h b/Source/LexerParser/cmCommandArgumentParserTokens.h
index 3172182d7..56c9794f9 100644
--- a/Source/LexerParser/cmCommandArgumentParserTokens.h
+++ b/Source/LexerParser/cmCommandArgumentParserTokens.h
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
+/* A Bison parser, made by GNU Bison 3.3.2. */
/* Bison interface for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
+ Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,6 +31,9 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
+/* Undocumented macros, especially those whose name start with YY_,
+ are private implementation details. Do not rely on them. */
+
#ifndef YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED
# define YY_CMCOMMANDARGUMENT_YY_CMCOMMANDARGUMENTPARSERTOKENS_H_INCLUDED
/* Debug traces. */
diff --git a/Source/LexerParser/cmDependsJavaLexer.cxx b/Source/LexerParser/cmDependsJavaLexer.cxx
index 8159f47bb..d703e3c95 100644
--- a/Source/LexerParser/cmDependsJavaLexer.cxx
+++ b/Source/LexerParser/cmDependsJavaLexer.cxx
@@ -1,7 +1,4 @@
#include "cmStandardLexer.h"
-#line 2 "cmDependsJavaLexer.cxx"
-
-#line 4 "cmDependsJavaLexer.cxx"
#define FLEXINT_H 1
#define YY_INT_ALIGNED short int
@@ -11,11 +8,221 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
+#define YY_FLEX_SUBMINOR_VERSION 4
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
+#ifdef yy_create_buffer
+#define cmDependsJava_yy_create_buffer_ALREADY_DEFINED
+#else
+#define yy_create_buffer cmDependsJava_yy_create_buffer
+#endif
+
+#ifdef yy_delete_buffer
+#define cmDependsJava_yy_delete_buffer_ALREADY_DEFINED
+#else
+#define yy_delete_buffer cmDependsJava_yy_delete_buffer
+#endif
+
+#ifdef yy_scan_buffer
+#define cmDependsJava_yy_scan_buffer_ALREADY_DEFINED
+#else
+#define yy_scan_buffer cmDependsJava_yy_scan_buffer
+#endif
+
+#ifdef yy_scan_string
+#define cmDependsJava_yy_scan_string_ALREADY_DEFINED
+#else
+#define yy_scan_string cmDependsJava_yy_scan_string
+#endif
+
+#ifdef yy_scan_bytes
+#define cmDependsJava_yy_scan_bytes_ALREADY_DEFINED
+#else
+#define yy_scan_bytes cmDependsJava_yy_scan_bytes
+#endif
+
+#ifdef yy_init_buffer
+#define cmDependsJava_yy_init_buffer_ALREADY_DEFINED
+#else
+#define yy_init_buffer cmDependsJava_yy_init_buffer
+#endif
+
+#ifdef yy_flush_buffer
+#define cmDependsJava_yy_flush_buffer_ALREADY_DEFINED
+#else
+#define yy_flush_buffer cmDependsJava_yy_flush_buffer
+#endif
+
+#ifdef yy_load_buffer_state
+#define cmDependsJava_yy_load_buffer_state_ALREADY_DEFINED
+#else
+#define yy_load_buffer_state cmDependsJava_yy_load_buffer_state
+#endif
+
+#ifdef yy_switch_to_buffer
+#define cmDependsJava_yy_switch_to_buffer_ALREADY_DEFINED
+#else
+#define yy_switch_to_buffer cmDependsJava_yy_switch_to_buffer
+#endif
+
+#ifdef yypush_buffer_state
+#define cmDependsJava_yypush_buffer_state_ALREADY_DEFINED
+#else
+#define yypush_buffer_state cmDependsJava_yypush_buffer_state
+#endif
+
+#ifdef yypop_buffer_state
+#define cmDependsJava_yypop_buffer_state_ALREADY_DEFINED
+#else
+#define yypop_buffer_state cmDependsJava_yypop_buffer_state
+#endif
+
+#ifdef yyensure_buffer_stack
+#define cmDependsJava_yyensure_buffer_stack_ALREADY_DEFINED
+#else
+#define yyensure_buffer_stack cmDependsJava_yyensure_buffer_stack
+#endif
+
+#ifdef yylex
+#define cmDependsJava_yylex_ALREADY_DEFINED
+#else
+#define yylex cmDependsJava_yylex
+#endif
+
+#ifdef yyrestart
+#define cmDependsJava_yyrestart_ALREADY_DEFINED
+#else
+#define yyrestart cmDependsJava_yyrestart
+#endif
+
+#ifdef yylex_init
+#define cmDependsJava_yylex_init_ALREADY_DEFINED
+#else
+#define yylex_init cmDependsJava_yylex_init
+#endif
+
+#ifdef yylex_init_extra
+#define cmDependsJava_yylex_init_extra_ALREADY_DEFINED
+#else
+#define yylex_init_extra cmDependsJava_yylex_init_extra
+#endif
+
+#ifdef yylex_destroy
+#define cmDependsJava_yylex_destroy_ALREADY_DEFINED
+#else
+#define yylex_destroy cmDependsJava_yylex_destroy
+#endif
+
+#ifdef yyget_debug
+#define cmDependsJava_yyget_debug_ALREADY_DEFINED
+#else
+#define yyget_debug cmDependsJava_yyget_debug
+#endif
+
+#ifdef yyset_debug
+#define cmDependsJava_yyset_debug_ALREADY_DEFINED
+#else
+#define yyset_debug cmDependsJava_yyset_debug
+#endif
+
+#ifdef yyget_extra
+#define cmDependsJava_yyget_extra_ALREADY_DEFINED
+#else
+#define yyget_extra cmDependsJava_yyget_extra
+#endif
+
+#ifdef yyset_extra
+#define cmDependsJava_yyset_extra_ALREADY_DEFINED
+#else
+#define yyset_extra cmDependsJava_yyset_extra
+#endif
+
+#ifdef yyget_in
+#define cmDependsJava_yyget_in_ALREADY_DEFINED
+#else
+#define yyget_in cmDependsJava_yyget_in
+#endif
+
+#ifdef yyset_in
+#define cmDependsJava_yyset_in_ALREADY_DEFINED
+#else
+#define yyset_in cmDependsJava_yyset_in
+#endif
+
+#ifdef yyget_out
+#define cmDependsJava_yyget_out_ALREADY_DEFINED
+#else
+#define yyget_out cmDependsJava_yyget_out
+#endif
+
+#ifdef yyset_out
+#define cmDependsJava_yyset_out_ALREADY_DEFINED
+#else
+#define yyset_out cmDependsJava_yyset_out
+#endif
+
+#ifdef yyget_leng
+#define cmDependsJava_yyget_leng_ALREADY_DEFINED
+#else
+#define yyget_leng cmDependsJava_yyget_leng
+#endif
+
+#ifdef yyget_text
+#define cmDependsJava_yyget_text_ALREADY_DEFINED
+#else
+#define yyget_text cmDependsJava_yyget_text
+#endif
+
+#ifdef yyget_lineno
+#define cmDependsJava_yyget_lineno_ALREADY_DEFINED
+#else
+#define yyget_lineno cmDependsJava_yyget_lineno
+#endif
+
+#ifdef yyset_lineno
+#define cmDependsJava_yyset_lineno_ALREADY_DEFINED
+#else
+#define yyset_lineno cmDependsJava_yyset_lineno
+#endif
+
+#ifdef yyget_column
+#define cmDependsJava_yyget_column_ALREADY_DEFINED
+#else
+#define yyget_column cmDependsJava_yyget_column
+#endif
+
+#ifdef yyset_column
+#define cmDependsJava_yyset_column_ALREADY_DEFINED
+#else
+#define yyset_column cmDependsJava_yyset_column
+#endif
+
+#ifdef yywrap
+#define cmDependsJava_yywrap_ALREADY_DEFINED
+#else
+#define yywrap cmDependsJava_yywrap
+#endif
+
+#ifdef yyalloc
+#define cmDependsJava_yyalloc_ALREADY_DEFINED
+#else
+#define yyalloc cmDependsJava_yyalloc
+#endif
+
+#ifdef yyrealloc
+#define cmDependsJava_yyrealloc_ALREADY_DEFINED
+#else
+#define yyrealloc cmDependsJava_yyrealloc
+#endif
+
+#ifdef yyfree
+#define cmDependsJava_yyfree_ALREADY_DEFINED
+#else
+#define yyfree cmDependsJava_yyfree
+#endif
+
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
@@ -86,10 +293,16 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
+#ifndef SIZE_MAX
+#define SIZE_MAX (~(size_t)0)
+#endif
+
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */
+
/* TODO: this is always defined, so inline it */
#define yyconst const
@@ -102,12 +315,10 @@ typedef unsigned int flex_uint32_t;
/* Returned upon end-of-file. */
#define YY_NULL 0
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
+/* Promotes a possibly negative, possibly signed char to an
+ * integer in range [0..255] for use as an array index.
*/
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
@@ -131,20 +342,16 @@ typedef void* yyscan_t;
* definition of BEGIN.
*/
#define BEGIN yyg->yy_start = 1 + 2 *
-
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START ((yyg->yy_start - 1) / 2)
#define YYSTATE YY_START
-
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE cmDependsJava_yyrestart(yyin ,yyscanner )
-
+#define YY_NEW_FILE yyrestart( yyin , yyscanner )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
@@ -194,7 +401,6 @@ typedef size_t yy_size_t;
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
-
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
#ifndef YY_STRUCT_YY_BUFFER_STATE
@@ -254,7 +460,7 @@ struct yy_buffer_state
* possible backing-up.
*
* When we actually see the EOF, we change the status to "new"
- * (via cmDependsJava_yyrestart()), so that the user can continue scanning by
+ * (via yyrestart()), so that the user can continue scanning by
* just pointing yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
@@ -271,73 +477,67 @@ struct yy_buffer_state
#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
: NULL)
-
/* Same as previous macro, but useful when we know that the buffer stack is not
* NULL or when we need an lvalue. For internal use only.
*/
#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
-void cmDependsJava_yyrestart (FILE *input_file ,yyscan_t yyscanner );
-void cmDependsJava_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmDependsJava_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
-void cmDependsJava_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmDependsJava_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmDependsJava_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-void cmDependsJava_yypop_buffer_state (yyscan_t yyscanner );
-
-static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner );
-static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner );
-static void cmDependsJava_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
-
-#define YY_FLUSH_BUFFER cmDependsJava_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+void yypop_buffer_state ( yyscan_t yyscanner );
-YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmDependsJava_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmDependsJava_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+static void yyensure_buffer_stack ( yyscan_t yyscanner );
+static void yy_load_buffer_state ( yyscan_t yyscanner );
+static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
+#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)
-void *cmDependsJava_yyalloc (yy_size_t ,yyscan_t yyscanner );
-void *cmDependsJava_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
-void cmDependsJava_yyfree (void * ,yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
-#define yy_new_buffer cmDependsJava_yy_create_buffer
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
+void yyfree ( void * , yyscan_t yyscanner );
+#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
{ \
if ( ! YY_CURRENT_BUFFER ){ \
- cmDependsJava_yyensure_buffer_stack (yyscanner); \
+ yyensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
- cmDependsJava_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
-
#define yy_set_bol(at_bol) \
{ \
if ( ! YY_CURRENT_BUFFER ){\
- cmDependsJava_yyensure_buffer_stack (yyscanner); \
+ yyensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
- cmDependsJava_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
-
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
/* Begin user sect3 */
#define cmDependsJava_yywrap(yyscanner) (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
-
-typedef unsigned char YY_CHAR;
+typedef flex_uint8_t YY_CHAR;
typedef int yy_state_type;
#define yytext_ptr yytext_r
-static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
-static int yy_get_next_buffer (yyscan_t yyscanner );
-static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner );
+static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
+static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner);
+static int yy_get_next_buffer ( yyscan_t yyscanner );
+static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
@@ -348,7 +548,6 @@ static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner );
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
-
#define YY_NUM_RULES 111
#define YY_END_OF_BUFFER 112
/* This struct is not used in this scanner,
@@ -358,7 +557,7 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[327] =
+static const flex_int16_t yy_accept[327] =
{ 0,
0, 0, 0, 0, 0, 0, 112, 110, 109, 109,
77, 4, 73, 94, 60, 110, 93, 92, 105, 99,
@@ -398,7 +597,7 @@ static yyconst flex_int16_t yy_accept[327] =
27, 29, 107, 107, 45, 0
} ;
-static yyconst YY_CHAR yy_ec[256] =
+static const YY_CHAR yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 2, 2, 1, 1, 1, 1, 1, 1, 1,
@@ -430,7 +629,7 @@ static yyconst YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
-static yyconst YY_CHAR yy_meta[65] =
+static const YY_CHAR yy_meta[65] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
1, 1, 1, 1, 1, 1, 1, 3, 3, 3,
@@ -441,7 +640,7 @@ static yyconst YY_CHAR yy_meta[65] =
1, 1, 1, 1
} ;
-static yyconst flex_uint16_t yy_base[334] =
+static const flex_int16_t yy_base[334] =
{ 0,
0, 0, 401, 400, 62, 63, 411, 414, 414, 414,
386, 414, 414, 385, 61, 374, 414, 414, 383, 57,
@@ -482,7 +681,7 @@ static yyconst flex_uint16_t yy_base[334] =
232, 96, 235
} ;
-static yyconst flex_int16_t yy_def[334] =
+static const flex_int16_t yy_def[334] =
{ 0,
326, 1, 327, 327, 328, 328, 326, 326, 326, 326,
326, 326, 326, 326, 326, 329, 326, 326, 326, 326,
@@ -523,7 +722,7 @@ static yyconst flex_int16_t yy_def[334] =
326, 326, 326
} ;
-static yyconst flex_uint16_t yy_nxt[479] =
+static const flex_int16_t yy_nxt[479] =
{ 0,
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 26,
@@ -579,7 +778,7 @@ static yyconst flex_uint16_t yy_nxt[479] =
326, 326, 326, 326, 326, 326, 326, 326
} ;
-static yyconst flex_int16_t yy_chk[479] =
+static const flex_int16_t yy_chk[479] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -642,8 +841,6 @@ static yyconst flex_int16_t yy_chk[479] =
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
-#line 1 "cmDependsJavaLexer.in.l"
-#line 2 "cmDependsJavaLexer.in.l"
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
/*
@@ -652,18 +849,19 @@ This file must be translated to C++ and modified to build everywhere.
Run flex >= 2.6 like this:
- flex --nounistd -DFLEXINT_H --prefix=cmDependsJava_yy --header-file=cmDependsJavaLexer.h -ocmDependsJavaLexer.cxx cmDependsJavaLexer.in.l
+ flex --nounistd -DFLEXINT_H --noline --header-file=cmDependsJavaLexer.h -ocmDependsJavaLexer.cxx cmDependsJavaLexer.in.l
Modify cmDependsJavaLexer.cxx:
- - remove trailing whitespace: sed -i 's/\s*$//' cmDependsJavaLexer.h cmDependsJavaLexer.cxx
- - remove blank lines at end of file
- - #include "cmStandardLexer.h" at the top
- - add cast in cmDependsJava_yy_scan_bytes for loop condition of _yybytes_len to size_t
+ - remove trailing whitespace: sed -i 's/\s*$//' cmDependsJavaLexer.h cmDependsJavaLexer.cxx
+ - remove blank lines at end of file: sed -i '${/^$/d;}' cmDependsJavaLexer.h cmDependsJavaLexer.cxx
+ - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmDependsJavaLexer.cxx
*/
/* IWYU pragma: no_forward_declare yyguts_t */
+#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+
#include <iostream>
#include "cmDependsJavaParserHelper.h"
@@ -671,7 +869,7 @@ Modify cmDependsJavaLexer.cxx:
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
- { result = yyextra->LexInput(buf, max_size); }
+ do { result = yyextra->LexInput(buf, max_size); } while (0)
/* Include the set of tokens from the parser. */
#include "cmDependsJavaParserTokens.h"
@@ -682,9 +880,6 @@ Modify cmDependsJavaLexer.cxx:
/*--------------------------------------------------------------------------*/
-
-#line 686 "cmDependsJavaLexer.cxx"
-
#define INITIAL 0
#define comment 1
#define string 2
@@ -727,44 +922,44 @@ struct yyguts_t
}; /* end struct yyguts_t */
-static int yy_init_globals (yyscan_t yyscanner );
+static int yy_init_globals ( yyscan_t yyscanner );
-int cmDependsJava_yylex_init (yyscan_t* scanner);
+int yylex_init (yyscan_t* scanner);
-int cmDependsJava_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
-int cmDependsJava_yylex_destroy (yyscan_t yyscanner );
+int yylex_destroy ( yyscan_t yyscanner );
-int cmDependsJava_yyget_debug (yyscan_t yyscanner );
+int yyget_debug ( yyscan_t yyscanner );
-void cmDependsJava_yyset_debug (int debug_flag ,yyscan_t yyscanner );
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
-YY_EXTRA_TYPE cmDependsJava_yyget_extra (yyscan_t yyscanner );
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
-void cmDependsJava_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
-FILE *cmDependsJava_yyget_in (yyscan_t yyscanner );
+FILE *yyget_in ( yyscan_t yyscanner );
-void cmDependsJava_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
+void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
-FILE *cmDependsJava_yyget_out (yyscan_t yyscanner );
+FILE *yyget_out ( yyscan_t yyscanner );
-void cmDependsJava_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
+void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
- int cmDependsJava_yyget_leng (yyscan_t yyscanner );
+ int yyget_leng ( yyscan_t yyscanner );
-char *cmDependsJava_yyget_text (yyscan_t yyscanner );
+char *yyget_text ( yyscan_t yyscanner );
-int cmDependsJava_yyget_lineno (yyscan_t yyscanner );
+int yyget_lineno ( yyscan_t yyscanner );
-void cmDependsJava_yyset_lineno (int _line_number ,yyscan_t yyscanner );
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
-int cmDependsJava_yyget_column (yyscan_t yyscanner );
+int yyget_column ( yyscan_t yyscanner );
-void cmDependsJava_yyset_column (int _column_no ,yyscan_t yyscanner );
+void yyset_column ( int _column_no , yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -772,32 +967,31 @@ void cmDependsJava_yyset_column (int _column_no ,yyscan_t yyscanner );
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int cmDependsJava_yywrap (yyscan_t yyscanner );
+extern "C" int yywrap ( yyscan_t yyscanner );
#else
-extern int cmDependsJava_yywrap (yyscan_t yyscanner );
+extern int yywrap ( yyscan_t yyscanner );
#endif
#endif
#ifndef YY_NO_UNPUT
- static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner);
+ static void yyunput ( int c, char *buf_ptr , yyscan_t yyscanner);
#endif
#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
-
#ifdef __cplusplus
-static int yyinput (yyscan_t yyscanner );
+static int yyinput ( yyscan_t yyscanner );
#else
-static int input (yyscan_t yyscanner );
+static int input ( yyscan_t yyscanner );
#endif
#endif
@@ -828,7 +1022,7 @@ static int input (yyscan_t yyscanner );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
- size_t n; \
+ int n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@@ -841,7 +1035,7 @@ static int input (yyscan_t yyscanner );
else \
{ \
errno=0; \
- while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
@@ -882,9 +1076,9 @@ static int input (yyscan_t yyscanner );
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-extern int cmDependsJava_yylex (yyscan_t yyscanner);
+extern int yylex (yyscan_t yyscanner);
-#define YY_DECL int cmDependsJava_yylex (yyscan_t yyscanner)
+#define YY_DECL int yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */
/* Code executed at the beginning of each rule, after yytext and yyleng
@@ -929,18 +1123,15 @@ YY_DECL
yyout = stdout;
if ( ! YY_CURRENT_BUFFER ) {
- cmDependsJava_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
- cmDependsJava_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
}
- cmDependsJava_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
}
{
-#line 48 "cmDependsJavaLexer.in.l"
-
-#line 943 "cmDependsJavaLexer.cxx"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
@@ -968,9 +1159,9 @@ yy_match:
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 327 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
while ( yy_base[yy_current_state] != 414 );
@@ -999,539 +1190,432 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
-#line 49 "cmDependsJavaLexer.in.l"
{ BEGIN(comment); }
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 50 "cmDependsJavaLexer.in.l"
{ BEGIN(INITIAL); }
YY_BREAK
case 3:
/* rule 3 can match eol */
YY_RULE_SETUP
-#line 51 "cmDependsJavaLexer.in.l"
{}
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 53 "cmDependsJavaLexer.in.l"
{ BEGIN(string); }
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 54 "cmDependsJavaLexer.in.l"
{ BEGIN(INITIAL); return jp_STRINGLITERAL; }
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 55 "cmDependsJavaLexer.in.l"
{}
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 57 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_ABSTRACT; }
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 58 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_ASSERT; }
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 59 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_BOOLEAN_TYPE; }
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 60 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_BREAK; }
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 61 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_BYTE_TYPE; }
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 62 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_CASE; }
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 63 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_CATCH; }
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 64 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_CHAR_TYPE; }
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 65 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_CLASS; }
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 66 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_CONTINUE; }
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 67 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_DEFAULT; }
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 68 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_DO; }
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 69 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_DOUBLE_TYPE; }
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 70 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_ELSE; }
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 71 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_EXTENDS; }
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 72 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_FINAL; }
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 73 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_FINALLY; }
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 74 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_FLOAT_TYPE; }
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 75 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_FOR; }
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 76 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_IF; }
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 77 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_IMPLEMENTS; }
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 78 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_IMPORT; }
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 79 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_INSTANCEOF; }
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 80 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_INT_TYPE; }
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 81 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_INTERFACE; }
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 82 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_LONG_TYPE; }
YY_BREAK
case 33:
YY_RULE_SETUP
-#line 83 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_NATIVE; }
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 84 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_NEW; }
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 85 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_PACKAGE; }
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 86 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_PRIVATE; }
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 87 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_PROTECTED; }
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 88 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_PUBLIC; }
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 89 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_RETURN; }
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 90 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_SHORT_TYPE; }
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 91 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_STATIC; }
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 92 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_STRICTFP; }
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 93 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_SUPER; }
YY_BREAK
case 44:
YY_RULE_SETUP
-#line 94 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_SWITCH; }
YY_BREAK
case 45:
YY_RULE_SETUP
-#line 95 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_SYNCHRONIZED; }
YY_BREAK
case 46:
YY_RULE_SETUP
-#line 96 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_THIS; }
YY_BREAK
case 47:
YY_RULE_SETUP
-#line 97 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_THROW; }
YY_BREAK
case 48:
YY_RULE_SETUP
-#line 98 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_THROWS; }
YY_BREAK
case 49:
YY_RULE_SETUP
-#line 99 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_TRANSIENT; }
YY_BREAK
case 50:
YY_RULE_SETUP
-#line 100 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_TRY; }
YY_BREAK
case 51:
YY_RULE_SETUP
-#line 101 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_VOID; }
YY_BREAK
case 52:
YY_RULE_SETUP
-#line 102 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_VOLATILE; }
YY_BREAK
case 53:
YY_RULE_SETUP
-#line 103 "cmDependsJavaLexer.in.l"
{ KEYWORD; return jp_WHILE; }
YY_BREAK
case 54:
YY_RULE_SETUP
-#line 105 "cmDependsJavaLexer.in.l"
{ PRIMITIVE; return jp_BOOLEANLITERAL; }
YY_BREAK
case 55:
/* rule 55 can match eol */
YY_RULE_SETUP
-#line 106 "cmDependsJavaLexer.in.l"
{ PRIMITIVE; return jp_CHARACTERLITERAL; }
YY_BREAK
case 56:
YY_RULE_SETUP
-#line 107 "cmDependsJavaLexer.in.l"
{ PRIMITIVE; return jp_DECIMALINTEGERLITERAL; }
YY_BREAK
case 57:
YY_RULE_SETUP
-#line 108 "cmDependsJavaLexer.in.l"
{ PRIMITIVE; return jp_FLOATINGPOINTLITERAL; }
YY_BREAK
case 58:
YY_RULE_SETUP
-#line 109 "cmDependsJavaLexer.in.l"
{ PRIMITIVE; return jp_HEXINTEGERLITERAL; }
YY_BREAK
case 59:
YY_RULE_SETUP
-#line 110 "cmDependsJavaLexer.in.l"
{ PRIMITIVE; return jp_NULLLITERAL; }
YY_BREAK
case 60:
YY_RULE_SETUP
-#line 112 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_AND; }
YY_BREAK
case 61:
YY_RULE_SETUP
-#line 113 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_ANDAND; }
YY_BREAK
case 62:
YY_RULE_SETUP
-#line 114 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_ANDEQUALS; }
YY_BREAK
case 63:
YY_RULE_SETUP
-#line 115 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_BRACKETEND; }
YY_BREAK
case 64:
YY_RULE_SETUP
-#line 116 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_BRACKETSTART; }
YY_BREAK
case 65:
YY_RULE_SETUP
-#line 117 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_CARROT; }
YY_BREAK
case 66:
YY_RULE_SETUP
-#line 118 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_CARROTEQUALS; }
YY_BREAK
case 67:
YY_RULE_SETUP
-#line 119 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_COLON; }
YY_BREAK
case 68:
YY_RULE_SETUP
-#line 120 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_COMMA; }
YY_BREAK
case 69:
YY_RULE_SETUP
-#line 121 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_CURLYEND; }
YY_BREAK
case 70:
YY_RULE_SETUP
-#line 122 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_CURLYSTART; }
YY_BREAK
case 71:
YY_RULE_SETUP
-#line 123 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_DIVIDE; }
YY_BREAK
case 72:
YY_RULE_SETUP
-#line 124 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_DIVIDEEQUALS; }
YY_BREAK
case 73:
YY_RULE_SETUP
-#line 125 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_DOLLAR; }
YY_BREAK
case 74:
YY_RULE_SETUP
-#line 126 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_DOT; }
YY_BREAK
case 75:
YY_RULE_SETUP
-#line 127 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_EQUALS; }
YY_BREAK
case 76:
YY_RULE_SETUP
-#line 128 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_EQUALSEQUALS; }
YY_BREAK
case 77:
YY_RULE_SETUP
-#line 129 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_EXCLAMATION; }
YY_BREAK
case 78:
YY_RULE_SETUP
-#line 130 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_EXCLAMATIONEQUALS; }
YY_BREAK
case 79:
YY_RULE_SETUP
-#line 131 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_GREATER; }
YY_BREAK
case 80:
YY_RULE_SETUP
-#line 132 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_GTEQUALS; }
YY_BREAK
case 81:
YY_RULE_SETUP
-#line 133 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_GTGT; }
YY_BREAK
case 82:
YY_RULE_SETUP
-#line 134 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_GTGTEQUALS; }
YY_BREAK
case 83:
YY_RULE_SETUP
-#line 135 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_GTGTGT; }
YY_BREAK
case 84:
YY_RULE_SETUP
-#line 136 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_GTGTGTEQUALS; }
YY_BREAK
case 85:
YY_RULE_SETUP
-#line 137 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_LESLESEQUALS; }
YY_BREAK
case 86:
YY_RULE_SETUP
-#line 138 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_LESSTHAN; }
YY_BREAK
case 87:
YY_RULE_SETUP
-#line 139 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_LTEQUALS; }
YY_BREAK
case 88:
YY_RULE_SETUP
-#line 140 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_LTLT; }
YY_BREAK
case 89:
YY_RULE_SETUP
-#line 141 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_MINUS; }
YY_BREAK
case 90:
YY_RULE_SETUP
-#line 142 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_MINUSEQUALS; }
YY_BREAK
case 91:
YY_RULE_SETUP
-#line 143 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_MINUSMINUS; }
YY_BREAK
case 92:
YY_RULE_SETUP
-#line 144 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_PAREEND; }
YY_BREAK
case 93:
YY_RULE_SETUP
-#line 145 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_PARESTART; }
YY_BREAK
case 94:
YY_RULE_SETUP
-#line 146 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_PERCENT; }
YY_BREAK
case 95:
YY_RULE_SETUP
-#line 147 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_PERCENTEQUALS; }
YY_BREAK
case 96:
YY_RULE_SETUP
-#line 148 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_PIPE; }
YY_BREAK
case 97:
YY_RULE_SETUP
-#line 149 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_PIPEEQUALS; }
YY_BREAK
case 98:
YY_RULE_SETUP
-#line 150 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_PIPEPIPE; }
YY_BREAK
case 99:
YY_RULE_SETUP
-#line 151 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_PLUS; }
YY_BREAK
case 100:
YY_RULE_SETUP
-#line 152 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_PLUSEQUALS; }
YY_BREAK
case 101:
YY_RULE_SETUP
-#line 153 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_PLUSPLUS; }
YY_BREAK
case 102:
YY_RULE_SETUP
-#line 154 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_QUESTION; }
YY_BREAK
case 103:
YY_RULE_SETUP
-#line 155 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_SEMICOL; }
YY_BREAK
case 104:
YY_RULE_SETUP
-#line 156 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_TILDE; }
YY_BREAK
case 105:
YY_RULE_SETUP
-#line 157 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_TIMES; }
YY_BREAK
case 106:
YY_RULE_SETUP
-#line 158 "cmDependsJavaLexer.in.l"
{ SYMBOL; return jp_TIMESEQUALS; }
YY_BREAK
case 107:
YY_RULE_SETUP
-#line 160 "cmDependsJavaLexer.in.l"
{
yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
return jp_NAME;
@@ -1540,18 +1624,15 @@ YY_RULE_SETUP
case 108:
/* rule 108 can match eol */
YY_RULE_SETUP
-#line 165 "cmDependsJavaLexer.in.l"
{ }
YY_BREAK
case 109:
/* rule 109 can match eol */
YY_RULE_SETUP
-#line 166 "cmDependsJavaLexer.in.l"
{ }
YY_BREAK
case 110:
YY_RULE_SETUP
-#line 167 "cmDependsJavaLexer.in.l"
{
std::cerr << "Unknown character: " << yytext[0]
<< " (" << (int)yytext[0] << ")" << std::endl;
@@ -1561,10 +1642,8 @@ YY_RULE_SETUP
YY_BREAK
case 111:
YY_RULE_SETUP
-#line 174 "cmDependsJavaLexer.in.l"
ECHO;
YY_BREAK
-#line 1567 "cmDependsJavaLexer.cxx"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(comment):
case YY_STATE_EOF(string):
@@ -1584,7 +1663,7 @@ case YY_STATE_EOF(string):
/* We're scanning a new file or input source. It's
* possible that this happened because the user
* just pointed yyin at a new source and called
- * cmDependsJava_yylex(). If so, then we have to assure
+ * yylex(). If so, then we have to assure
* consistency between YY_CURRENT_BUFFER and our
* globals. Here is the right place to do so, because
* this is the first action (other than possibly a
@@ -1644,7 +1723,7 @@ case YY_STATE_EOF(string):
{
yyg->yy_did_buffer_switch_on_eof = 0;
- if ( cmDependsJava_yywrap(yyscanner ) )
+ if ( yywrap( yyscanner ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
@@ -1698,7 +1777,7 @@ case YY_STATE_EOF(string):
} /* end of action switch */
} /* end of scanning one token */
} /* end of user's declarations */
-} /* end of cmDependsJava_yylex */
+} /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer
*
@@ -1712,7 +1791,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = yyg->yytext_ptr;
- yy_size_t number_to_move, i;
+ int number_to_move, i;
int ret_val;
if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
@@ -1741,7 +1820,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
/* Try to read more data. */
/* First move last chars to start of buffer. */
- number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
+ number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@@ -1777,7 +1856,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
- cmDependsJava_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
+ yyrealloc( (void *) b->yy_ch_buf,
+ (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
}
else
/* Can't grow it, we don't own it. */
@@ -1809,7 +1889,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
- cmDependsJava_yyrestart(yyin ,yyscanner);
+ yyrestart( yyin , yyscanner);
}
else
@@ -1823,12 +1903,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
ret_val = EOB_ACT_CONTINUE_SCAN;
- if ((int) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cmDependsJava_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
+ (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ /* "- 2" to take care of EOB's */
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
}
yyg->yy_n_chars += number_to_move;
@@ -1862,9 +1945,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 327 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
}
return yy_current_state;
@@ -1891,9 +1974,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 327 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 326);
(void)yyg;
@@ -1967,7 +2050,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
{ /* need more input */
- int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+ int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
++yyg->yy_c_buf_p;
switch ( yy_get_next_buffer( yyscanner ) )
@@ -1984,13 +2067,13 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
*/
/* Reset buffer status. */
- cmDependsJava_yyrestart(yyin ,yyscanner);
+ yyrestart( yyin , yyscanner);
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
- if ( cmDependsJava_yywrap(yyscanner ) )
+ if ( yywrap( yyscanner ) )
return 0;
if ( ! yyg->yy_did_buffer_switch_on_eof )
@@ -2022,34 +2105,34 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @note This function does not reset the start condition to @c INITIAL .
*/
- void cmDependsJava_yyrestart (FILE * input_file , yyscan_t yyscanner)
+ void yyrestart (FILE * input_file , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! YY_CURRENT_BUFFER ){
- cmDependsJava_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
- cmDependsJava_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
}
- cmDependsJava_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
- cmDependsJava_yy_load_buffer_state(yyscanner );
+ yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
+ yy_load_buffer_state( yyscanner );
}
/** Switch to a different input buffer.
* @param new_buffer The new input buffer.
* @param yyscanner The scanner object.
*/
- void cmDependsJava_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* TODO. We should be able to replace this entire function body
* with
- * cmDependsJava_yypop_buffer_state();
- * cmDependsJava_yypush_buffer_state(new_buffer);
+ * yypop_buffer_state();
+ * yypush_buffer_state(new_buffer);
*/
- cmDependsJava_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
if ( YY_CURRENT_BUFFER == new_buffer )
return;
@@ -2062,17 +2145,17 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- cmDependsJava_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
/* We don't actually know whether we did this switch during
- * EOF (cmDependsJava_yywrap()) processing, but the only time this flag
- * is looked at is after cmDependsJava_yywrap() is called, so it's safe
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
* to go ahead and always set it.
*/
yyg->yy_did_buffer_switch_on_eof = 1;
}
-static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner)
+static void yy_load_buffer_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
@@ -2087,35 +2170,35 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the allocated buffer state.
*/
- YY_BUFFER_STATE cmDependsJava_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
+ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
- b = (YY_BUFFER_STATE) cmDependsJava_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yy_create_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
- b->yy_buf_size = (yy_size_t)size;
+ b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
- b->yy_ch_buf = (char *) cmDependsJava_yyalloc(b->yy_buf_size + 2 ,yyscanner );
+ b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yy_create_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
- cmDependsJava_yy_init_buffer(b,file ,yyscanner);
+ yy_init_buffer( b, file , yyscanner);
return b;
}
/** Destroy the buffer.
- * @param b a buffer created with cmDependsJava_yy_create_buffer()
+ * @param b a buffer created with yy_create_buffer()
* @param yyscanner The scanner object.
*/
- void cmDependsJava_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+ void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -2126,28 +2209,28 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner)
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
- cmDependsJava_yyfree((void *) b->yy_ch_buf ,yyscanner );
+ yyfree( (void *) b->yy_ch_buf , yyscanner );
- cmDependsJava_yyfree((void *) b ,yyscanner );
+ yyfree( (void *) b , yyscanner );
}
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
- * such as during a cmDependsJava_yyrestart() or at EOF.
+ * such as during a yyrestart() or at EOF.
*/
- static void cmDependsJava_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
+ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
{
int oerrno = errno;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- cmDependsJava_yy_flush_buffer(b ,yyscanner);
+ yy_flush_buffer( b , yyscanner);
b->yy_input_file = file;
b->yy_fill_buffer = 1;
- /* If b is the current buffer, then cmDependsJava_yy_init_buffer was _probably_
- * called from cmDependsJava_yyrestart() or through yy_get_next_buffer.
+ /* If b is the current buffer, then yy_init_buffer was _probably_
+ * called from yyrestart() or through yy_get_next_buffer.
* In that case, we don't want to reset the lineno or column.
*/
if (b != YY_CURRENT_BUFFER){
@@ -2164,7 +2247,7 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner)
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
* @param yyscanner The scanner object.
*/
- void cmDependsJava_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+ void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! b )
@@ -2185,7 +2268,7 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner)
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
- cmDependsJava_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
}
/** Pushes the new state onto the stack. The new state becomes
@@ -2194,15 +2277,15 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner)
* @param new_buffer The new state.
* @param yyscanner The scanner object.
*/
-void cmDependsJava_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (new_buffer == NULL)
return;
- cmDependsJava_yyensure_buffer_stack(yyscanner);
+ yyensure_buffer_stack(yyscanner);
- /* This block is copied from cmDependsJava_yy_switch_to_buffer. */
+ /* This block is copied from yy_switch_to_buffer. */
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
@@ -2216,8 +2299,8 @@ void cmDependsJava_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yy
yyg->yy_buffer_stack_top++;
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- /* copied from cmDependsJava_yy_switch_to_buffer. */
- cmDependsJava_yy_load_buffer_state(yyscanner );
+ /* copied from yy_switch_to_buffer. */
+ yy_load_buffer_state( yyscanner );
yyg->yy_did_buffer_switch_on_eof = 1;
}
@@ -2225,19 +2308,19 @@ void cmDependsJava_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yy
* The next element becomes the new top.
* @param yyscanner The scanner object.
*/
-void cmDependsJava_yypop_buffer_state (yyscan_t yyscanner)
+void yypop_buffer_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!YY_CURRENT_BUFFER)
return;
- cmDependsJava_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
+ yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
YY_CURRENT_BUFFER_LVALUE = NULL;
if (yyg->yy_buffer_stack_top > 0)
--yyg->yy_buffer_stack_top;
if (YY_CURRENT_BUFFER) {
- cmDependsJava_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
yyg->yy_did_buffer_switch_on_eof = 1;
}
}
@@ -2245,9 +2328,9 @@ void cmDependsJava_yypop_buffer_state (yyscan_t yyscanner)
/* Allocates the stack if it does not exist.
* Guarantees space for at least one push.
*/
-static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner)
+static void yyensure_buffer_stack (yyscan_t yyscanner)
{
- int num_to_alloc;
+ yy_size_t num_to_alloc;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!yyg->yy_buffer_stack) {
@@ -2257,11 +2340,11 @@ static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner)
* immediate realloc on the next call.
*/
num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
- yyg->yy_buffer_stack = (struct yy_buffer_state**)cmDependsJava_yyalloc
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
- YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yyensure_buffer_stack()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
@@ -2276,12 +2359,12 @@ static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner)
yy_size_t grow_size = 8 /* arbitrary grow size */;
num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
- yyg->yy_buffer_stack = (struct yy_buffer_state**)cmDependsJava_yyrealloc
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
(yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
- YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yyensure_buffer_stack()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -2295,7 +2378,7 @@ static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
@@ -2305,11 +2388,11 @@ YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char * base, yy_size_t size , yy
/* They forgot to leave room for the EOB's. */
return NULL;
- b = (YY_BUFFER_STATE) cmDependsJava_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yy_scan_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = NULL;
@@ -2319,53 +2402,53 @@ YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char * base, yy_size_t size , yy
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
- cmDependsJava_yy_switch_to_buffer(b ,yyscanner );
+ yy_switch_to_buffer( b , yyscanner );
return b;
}
-/** Setup the input buffer state to scan a string. The next call to cmDependsJava_yylex() will
+/** Setup the input buffer state to scan a string. The next call to yylex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
- * cmDependsJava_yy_scan_bytes() instead.
+ * yy_scan_bytes() instead.
*/
-YY_BUFFER_STATE cmDependsJava_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
{
- return cmDependsJava_yy_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner);
+ return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
}
-/** Setup the input buffer state to scan the given bytes. The next call to cmDependsJava_yylex() will
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE cmDependsJava_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
- yy_size_t i;
+ int i;
/* Get memory for full buffer, including space for trailing EOB's. */
- n = (yy_size_t) _yybytes_len + 2;
- buf = (char *) cmDependsJava_yyalloc(n ,yyscanner );
+ n = (yy_size_t) (_yybytes_len + 2);
+ buf = (char *) yyalloc( n , yyscanner );
if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yy_scan_bytes()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
- for ( i = 0; i < (size_t)_yybytes_len; ++i )
+ for ( i = 0; i < _yybytes_len; ++i )
buf[i] = yybytes[i];
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
- b = cmDependsJava_yy_scan_buffer(buf,n ,yyscanner);
+ b = yy_scan_buffer( buf, n , yyscanner);
if ( ! b )
- YY_FATAL_ERROR( "bad buffer in cmDependsJava_yy_scan_bytes()" );
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
/* It's okay to grow etc. this buffer, and we should throw it
* away when we're done.
@@ -2379,11 +2462,11 @@ YY_BUFFER_STATE cmDependsJava_yy_scan_bytes (yyconst char * yybytes, int _yyby
#define YY_EXIT_FAILURE 2
#endif
-static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
+static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
- (void) fprintf( stderr, "%s\n", msg );
+ fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
@@ -2409,7 +2492,7 @@ static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
/** Get the user-defined data for this scanner.
* @param yyscanner The scanner object.
*/
-YY_EXTRA_TYPE cmDependsJava_yyget_extra (yyscan_t yyscanner)
+YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyextra;
@@ -2418,7 +2501,7 @@ YY_EXTRA_TYPE cmDependsJava_yyget_extra (yyscan_t yyscanner)
/** Get the current line number.
* @param yyscanner The scanner object.
*/
-int cmDependsJava_yyget_lineno (yyscan_t yyscanner)
+int yyget_lineno (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -2431,7 +2514,7 @@ int cmDependsJava_yyget_lineno (yyscan_t yyscanner)
/** Get the current column number.
* @param yyscanner The scanner object.
*/
-int cmDependsJava_yyget_column (yyscan_t yyscanner)
+int yyget_column (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -2444,7 +2527,7 @@ int cmDependsJava_yyget_column (yyscan_t yyscanner)
/** Get the input stream.
* @param yyscanner The scanner object.
*/
-FILE *cmDependsJava_yyget_in (yyscan_t yyscanner)
+FILE *yyget_in (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyin;
@@ -2453,7 +2536,7 @@ FILE *cmDependsJava_yyget_in (yyscan_t yyscanner)
/** Get the output stream.
* @param yyscanner The scanner object.
*/
-FILE *cmDependsJava_yyget_out (yyscan_t yyscanner)
+FILE *yyget_out (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyout;
@@ -2462,7 +2545,7 @@ FILE *cmDependsJava_yyget_out (yyscan_t yyscanner)
/** Get the length of the current token.
* @param yyscanner The scanner object.
*/
-int cmDependsJava_yyget_leng (yyscan_t yyscanner)
+int yyget_leng (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyleng;
@@ -2472,7 +2555,7 @@ int cmDependsJava_yyget_leng (yyscan_t yyscanner)
* @param yyscanner The scanner object.
*/
-char *cmDependsJava_yyget_text (yyscan_t yyscanner)
+char *yyget_text (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yytext;
@@ -2482,7 +2565,7 @@ char *cmDependsJava_yyget_text (yyscan_t yyscanner)
* @param user_defined The data to be associated with this scanner.
* @param yyscanner The scanner object.
*/
-void cmDependsJava_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
+void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyextra = user_defined ;
@@ -2492,13 +2575,13 @@ void cmDependsJava_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner
* @param _line_number line number
* @param yyscanner The scanner object.
*/
-void cmDependsJava_yyset_lineno (int _line_number , yyscan_t yyscanner)
+void yyset_lineno (int _line_number , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* lineno is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "cmDependsJava_yyset_lineno called with no buffer" );
+ YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
yylineno = _line_number;
}
@@ -2507,13 +2590,13 @@ void cmDependsJava_yyset_lineno (int _line_number , yyscan_t yyscanner)
* @param _column_no column number
* @param yyscanner The scanner object.
*/
-void cmDependsJava_yyset_column (int _column_no , yyscan_t yyscanner)
+void yyset_column (int _column_no , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* column is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "cmDependsJava_yyset_column called with no buffer" );
+ YY_FATAL_ERROR( "yyset_column called with no buffer" );
yycolumn = _column_no;
}
@@ -2522,27 +2605,27 @@ void cmDependsJava_yyset_column (int _column_no , yyscan_t yyscanner)
* input buffer.
* @param _in_str A readable stream.
* @param yyscanner The scanner object.
- * @see cmDependsJava_yy_switch_to_buffer
+ * @see yy_switch_to_buffer
*/
-void cmDependsJava_yyset_in (FILE * _in_str , yyscan_t yyscanner)
+void yyset_in (FILE * _in_str , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyin = _in_str ;
}
-void cmDependsJava_yyset_out (FILE * _out_str , yyscan_t yyscanner)
+void yyset_out (FILE * _out_str , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyout = _out_str ;
}
-int cmDependsJava_yyget_debug (yyscan_t yyscanner)
+int yyget_debug (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yy_flex_debug;
}
-void cmDependsJava_yyset_debug (int _bdebug , yyscan_t yyscanner)
+void yyset_debug (int _bdebug , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yy_flex_debug = _bdebug ;
@@ -2552,20 +2635,18 @@ void cmDependsJava_yyset_debug (int _bdebug , yyscan_t yyscanner)
/* User-visible API */
-/* cmDependsJava_yylex_init is special because it creates the scanner itself, so it is
+/* yylex_init is special because it creates the scanner itself, so it is
* the ONLY reentrant function that doesn't take the scanner as the last argument.
* That's why we explicitly handle the declaration, instead of using our macros.
*/
-
-int cmDependsJava_yylex_init(yyscan_t* ptr_yy_globals)
-
+int yylex_init(yyscan_t* ptr_yy_globals)
{
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
- *ptr_yy_globals = (yyscan_t) cmDependsJava_yyalloc ( sizeof( struct yyguts_t ), NULL );
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
@@ -2578,27 +2659,25 @@ int cmDependsJava_yylex_init(yyscan_t* ptr_yy_globals)
return yy_init_globals ( *ptr_yy_globals );
}
-/* cmDependsJava_yylex_init_extra has the same functionality as cmDependsJava_yylex_init, but follows the
+/* yylex_init_extra has the same functionality as yylex_init, but follows the
* convention of taking the scanner as the last argument. Note however, that
* this is a *pointer* to a scanner, as it will be allocated by this call (and
* is the reason, too, why this function also must handle its own declaration).
- * The user defined value in the first argument will be available to cmDependsJava_yyalloc in
+ * The user defined value in the first argument will be available to yyalloc in
* the yyextra field.
*/
-
-int cmDependsJava_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
-
+int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
{
struct yyguts_t dummy_yyguts;
- cmDependsJava_yyset_extra (yy_user_defined, &dummy_yyguts);
+ yyset_extra (yy_user_defined, &dummy_yyguts);
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
- *ptr_yy_globals = (yyscan_t) cmDependsJava_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
@@ -2609,7 +2688,7 @@ int cmDependsJava_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_y
yy_init_globals. Leave at 0x00 for releases. */
memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
- cmDependsJava_yyset_extra (yy_user_defined, *ptr_yy_globals);
+ yyset_extra (yy_user_defined, *ptr_yy_globals);
return yy_init_globals ( *ptr_yy_globals );
}
@@ -2618,7 +2697,7 @@ static int yy_init_globals (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Initialization is the same as for the non-reentrant scanner.
- * This function is called from cmDependsJava_yylex_destroy(), so don't allocate here.
+ * This function is called from yylex_destroy(), so don't allocate here.
*/
yyg->yy_buffer_stack = NULL;
@@ -2642,37 +2721,37 @@ static int yy_init_globals (yyscan_t yyscanner)
#endif
/* For future reference: Set errno on error, since we are called by
- * cmDependsJava_yylex_init()
+ * yylex_init()
*/
return 0;
}
-/* cmDependsJava_yylex_destroy is for both reentrant and non-reentrant scanners. */
-int cmDependsJava_yylex_destroy (yyscan_t yyscanner)
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
+int yylex_destroy (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
- cmDependsJava_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
+ yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
YY_CURRENT_BUFFER_LVALUE = NULL;
- cmDependsJava_yypop_buffer_state(yyscanner);
+ yypop_buffer_state(yyscanner);
}
/* Destroy the stack itself. */
- cmDependsJava_yyfree(yyg->yy_buffer_stack ,yyscanner);
+ yyfree(yyg->yy_buffer_stack , yyscanner);
yyg->yy_buffer_stack = NULL;
/* Destroy the start condition stack. */
- cmDependsJava_yyfree(yyg->yy_start_stack ,yyscanner );
+ yyfree( yyg->yy_start_stack , yyscanner );
yyg->yy_start_stack = NULL;
/* Reset the globals. This is important in a non-reentrant scanner so the next time
- * cmDependsJava_yylex() is called, initialization will occur. */
+ * yylex() is called, initialization will occur. */
yy_init_globals( yyscanner);
/* Destroy the main struct (reentrant only). */
- cmDependsJava_yyfree ( yyscanner , yyscanner );
+ yyfree ( yyscanner , yyscanner );
yyscanner = NULL;
return 0;
}
@@ -2682,7 +2761,7 @@ int cmDependsJava_yylex_destroy (yyscan_t yyscanner)
*/
#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
+static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
@@ -2694,7 +2773,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
+static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
{
int n;
for ( n = 0; s[n]; ++n )
@@ -2704,14 +2783,14 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
}
#endif
-void *cmDependsJava_yyalloc (yy_size_t size , yyscan_t yyscanner)
+void *yyalloc (yy_size_t size , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
return malloc(size);
}
-void *cmDependsJava_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
+void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
@@ -2726,13 +2805,15 @@ void *cmDependsJava_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner
return realloc(ptr, size);
}
-void cmDependsJava_yyfree (void * ptr , yyscan_t yyscanner)
+void yyfree (void * ptr , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
- free( (char *) ptr ); /* see cmDependsJava_yyrealloc() for (char *) cast */
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"
-#line 174 "cmDependsJavaLexer.in.l"
+/*--------------------------------------------------------------------------*/
+
+#endif /* __clang_analyzer__ */
diff --git a/Source/LexerParser/cmDependsJavaLexer.h b/Source/LexerParser/cmDependsJavaLexer.h
index ccadd70b9..f1e87d246 100644
--- a/Source/LexerParser/cmDependsJavaLexer.h
+++ b/Source/LexerParser/cmDependsJavaLexer.h
@@ -2,10 +2,6 @@
#define cmDependsJava_yyHEADER_H 1
#define cmDependsJava_yyIN_HEADER 1
-#line 6 "cmDependsJavaLexer.h"
-
-#line 8 "cmDependsJavaLexer.h"
-
#define FLEXINT_H 1
#define YY_INT_ALIGNED short int
@@ -14,11 +10,221 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
+#define YY_FLEX_SUBMINOR_VERSION 4
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
+#ifdef yy_create_buffer
+#define cmDependsJava_yy_create_buffer_ALREADY_DEFINED
+#else
+#define yy_create_buffer cmDependsJava_yy_create_buffer
+#endif
+
+#ifdef yy_delete_buffer
+#define cmDependsJava_yy_delete_buffer_ALREADY_DEFINED
+#else
+#define yy_delete_buffer cmDependsJava_yy_delete_buffer
+#endif
+
+#ifdef yy_scan_buffer
+#define cmDependsJava_yy_scan_buffer_ALREADY_DEFINED
+#else
+#define yy_scan_buffer cmDependsJava_yy_scan_buffer
+#endif
+
+#ifdef yy_scan_string
+#define cmDependsJava_yy_scan_string_ALREADY_DEFINED
+#else
+#define yy_scan_string cmDependsJava_yy_scan_string
+#endif
+
+#ifdef yy_scan_bytes
+#define cmDependsJava_yy_scan_bytes_ALREADY_DEFINED
+#else
+#define yy_scan_bytes cmDependsJava_yy_scan_bytes
+#endif
+
+#ifdef yy_init_buffer
+#define cmDependsJava_yy_init_buffer_ALREADY_DEFINED
+#else
+#define yy_init_buffer cmDependsJava_yy_init_buffer
+#endif
+
+#ifdef yy_flush_buffer
+#define cmDependsJava_yy_flush_buffer_ALREADY_DEFINED
+#else
+#define yy_flush_buffer cmDependsJava_yy_flush_buffer
+#endif
+
+#ifdef yy_load_buffer_state
+#define cmDependsJava_yy_load_buffer_state_ALREADY_DEFINED
+#else
+#define yy_load_buffer_state cmDependsJava_yy_load_buffer_state
+#endif
+
+#ifdef yy_switch_to_buffer
+#define cmDependsJava_yy_switch_to_buffer_ALREADY_DEFINED
+#else
+#define yy_switch_to_buffer cmDependsJava_yy_switch_to_buffer
+#endif
+
+#ifdef yypush_buffer_state
+#define cmDependsJava_yypush_buffer_state_ALREADY_DEFINED
+#else
+#define yypush_buffer_state cmDependsJava_yypush_buffer_state
+#endif
+
+#ifdef yypop_buffer_state
+#define cmDependsJava_yypop_buffer_state_ALREADY_DEFINED
+#else
+#define yypop_buffer_state cmDependsJava_yypop_buffer_state
+#endif
+
+#ifdef yyensure_buffer_stack
+#define cmDependsJava_yyensure_buffer_stack_ALREADY_DEFINED
+#else
+#define yyensure_buffer_stack cmDependsJava_yyensure_buffer_stack
+#endif
+
+#ifdef yylex
+#define cmDependsJava_yylex_ALREADY_DEFINED
+#else
+#define yylex cmDependsJava_yylex
+#endif
+
+#ifdef yyrestart
+#define cmDependsJava_yyrestart_ALREADY_DEFINED
+#else
+#define yyrestart cmDependsJava_yyrestart
+#endif
+
+#ifdef yylex_init
+#define cmDependsJava_yylex_init_ALREADY_DEFINED
+#else
+#define yylex_init cmDependsJava_yylex_init
+#endif
+
+#ifdef yylex_init_extra
+#define cmDependsJava_yylex_init_extra_ALREADY_DEFINED
+#else
+#define yylex_init_extra cmDependsJava_yylex_init_extra
+#endif
+
+#ifdef yylex_destroy
+#define cmDependsJava_yylex_destroy_ALREADY_DEFINED
+#else
+#define yylex_destroy cmDependsJava_yylex_destroy
+#endif
+
+#ifdef yyget_debug
+#define cmDependsJava_yyget_debug_ALREADY_DEFINED
+#else
+#define yyget_debug cmDependsJava_yyget_debug
+#endif
+
+#ifdef yyset_debug
+#define cmDependsJava_yyset_debug_ALREADY_DEFINED
+#else
+#define yyset_debug cmDependsJava_yyset_debug
+#endif
+
+#ifdef yyget_extra
+#define cmDependsJava_yyget_extra_ALREADY_DEFINED
+#else
+#define yyget_extra cmDependsJava_yyget_extra
+#endif
+
+#ifdef yyset_extra
+#define cmDependsJava_yyset_extra_ALREADY_DEFINED
+#else
+#define yyset_extra cmDependsJava_yyset_extra
+#endif
+
+#ifdef yyget_in
+#define cmDependsJava_yyget_in_ALREADY_DEFINED
+#else
+#define yyget_in cmDependsJava_yyget_in
+#endif
+
+#ifdef yyset_in
+#define cmDependsJava_yyset_in_ALREADY_DEFINED
+#else
+#define yyset_in cmDependsJava_yyset_in
+#endif
+
+#ifdef yyget_out
+#define cmDependsJava_yyget_out_ALREADY_DEFINED
+#else
+#define yyget_out cmDependsJava_yyget_out
+#endif
+
+#ifdef yyset_out
+#define cmDependsJava_yyset_out_ALREADY_DEFINED
+#else
+#define yyset_out cmDependsJava_yyset_out
+#endif
+
+#ifdef yyget_leng
+#define cmDependsJava_yyget_leng_ALREADY_DEFINED
+#else
+#define yyget_leng cmDependsJava_yyget_leng
+#endif
+
+#ifdef yyget_text
+#define cmDependsJava_yyget_text_ALREADY_DEFINED
+#else
+#define yyget_text cmDependsJava_yyget_text
+#endif
+
+#ifdef yyget_lineno
+#define cmDependsJava_yyget_lineno_ALREADY_DEFINED
+#else
+#define yyget_lineno cmDependsJava_yyget_lineno
+#endif
+
+#ifdef yyset_lineno
+#define cmDependsJava_yyset_lineno_ALREADY_DEFINED
+#else
+#define yyset_lineno cmDependsJava_yyset_lineno
+#endif
+
+#ifdef yyget_column
+#define cmDependsJava_yyget_column_ALREADY_DEFINED
+#else
+#define yyget_column cmDependsJava_yyget_column
+#endif
+
+#ifdef yyset_column
+#define cmDependsJava_yyset_column_ALREADY_DEFINED
+#else
+#define yyset_column cmDependsJava_yyset_column
+#endif
+
+#ifdef yywrap
+#define cmDependsJava_yywrap_ALREADY_DEFINED
+#else
+#define yywrap cmDependsJava_yywrap
+#endif
+
+#ifdef yyalloc
+#define cmDependsJava_yyalloc_ALREADY_DEFINED
+#else
+#define yyalloc cmDependsJava_yyalloc
+#endif
+
+#ifdef yyrealloc
+#define cmDependsJava_yyrealloc_ALREADY_DEFINED
+#else
+#define yyrealloc cmDependsJava_yyrealloc
+#endif
+
+#ifdef yyfree
+#define cmDependsJava_yyfree_ALREADY_DEFINED
+#else
+#define yyfree cmDependsJava_yyfree
+#endif
+
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
@@ -89,10 +295,16 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
+#ifndef SIZE_MAX
+#define SIZE_MAX (~(size_t)0)
+#endif
+
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */
+
/* TODO: this is always defined, so inline it */
#define yyconst const
@@ -193,21 +405,21 @@ struct yy_buffer_state
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-void cmDependsJava_yyrestart (FILE *input_file ,yyscan_t yyscanner );
-void cmDependsJava_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmDependsJava_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
-void cmDependsJava_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmDependsJava_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmDependsJava_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-void cmDependsJava_yypop_buffer_state (yyscan_t yyscanner );
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+void yypop_buffer_state ( yyscan_t yyscanner );
-YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmDependsJava_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmDependsJava_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
-void *cmDependsJava_yyalloc (yy_size_t ,yyscan_t yyscanner );
-void *cmDependsJava_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
-void cmDependsJava_yyfree (void * ,yyscan_t yyscanner );
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
+void yyfree ( void * , yyscan_t yyscanner );
/* Begin user sect3 */
@@ -227,42 +439,42 @@ void cmDependsJava_yyfree (void * ,yyscan_t yyscanner );
#define YY_EXTRA_TYPE void *
#endif
-int cmDependsJava_yylex_init (yyscan_t* scanner);
+int yylex_init (yyscan_t* scanner);
-int cmDependsJava_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
-int cmDependsJava_yylex_destroy (yyscan_t yyscanner );
+int yylex_destroy ( yyscan_t yyscanner );
-int cmDependsJava_yyget_debug (yyscan_t yyscanner );
+int yyget_debug ( yyscan_t yyscanner );
-void cmDependsJava_yyset_debug (int debug_flag ,yyscan_t yyscanner );
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
-YY_EXTRA_TYPE cmDependsJava_yyget_extra (yyscan_t yyscanner );
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
-void cmDependsJava_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
-FILE *cmDependsJava_yyget_in (yyscan_t yyscanner );
+FILE *yyget_in ( yyscan_t yyscanner );
-void cmDependsJava_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
+void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
-FILE *cmDependsJava_yyget_out (yyscan_t yyscanner );
+FILE *yyget_out ( yyscan_t yyscanner );
-void cmDependsJava_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
+void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
- int cmDependsJava_yyget_leng (yyscan_t yyscanner );
+ int yyget_leng ( yyscan_t yyscanner );
-char *cmDependsJava_yyget_text (yyscan_t yyscanner );
+char *yyget_text ( yyscan_t yyscanner );
-int cmDependsJava_yyget_lineno (yyscan_t yyscanner );
+int yyget_lineno ( yyscan_t yyscanner );
-void cmDependsJava_yyset_lineno (int _line_number ,yyscan_t yyscanner );
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
-int cmDependsJava_yyget_column (yyscan_t yyscanner );
+int yyget_column ( yyscan_t yyscanner );
-void cmDependsJava_yyset_column (int _column_no ,yyscan_t yyscanner );
+void yyset_column ( int _column_no , yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -270,18 +482,18 @@ void cmDependsJava_yyset_column (int _column_no ,yyscan_t yyscanner );
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int cmDependsJava_yywrap (yyscan_t yyscanner );
+extern "C" int yywrap ( yyscan_t yyscanner );
#else
-extern int cmDependsJava_yywrap (yyscan_t yyscanner );
+extern int yywrap ( yyscan_t yyscanner );
#endif
#endif
#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
@@ -309,9 +521,9 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-extern int cmDependsJava_yylex (yyscan_t yyscanner);
+extern int yylex (yyscan_t yyscanner);
-#define YY_DECL int cmDependsJava_yylex (yyscan_t yyscanner)
+#define YY_DECL int yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */
/* yy_get_previous_state - get the state just before the EOB char was reached */
@@ -328,9 +540,150 @@ extern int cmDependsJava_yylex (yyscan_t yyscanner);
#undef YY_DECL
#endif
-#line 174 "cmDependsJavaLexer.in.l"
-
+#ifndef cmDependsJava_yy_create_buffer_ALREADY_DEFINED
+#undef yy_create_buffer
+#endif
+#ifndef cmDependsJava_yy_delete_buffer_ALREADY_DEFINED
+#undef yy_delete_buffer
+#endif
+#ifndef cmDependsJava_yy_scan_buffer_ALREADY_DEFINED
+#undef yy_scan_buffer
+#endif
+#ifndef cmDependsJava_yy_scan_string_ALREADY_DEFINED
+#undef yy_scan_string
+#endif
+#ifndef cmDependsJava_yy_scan_bytes_ALREADY_DEFINED
+#undef yy_scan_bytes
+#endif
+#ifndef cmDependsJava_yy_init_buffer_ALREADY_DEFINED
+#undef yy_init_buffer
+#endif
+#ifndef cmDependsJava_yy_flush_buffer_ALREADY_DEFINED
+#undef yy_flush_buffer
+#endif
+#ifndef cmDependsJava_yy_load_buffer_state_ALREADY_DEFINED
+#undef yy_load_buffer_state
+#endif
+#ifndef cmDependsJava_yy_switch_to_buffer_ALREADY_DEFINED
+#undef yy_switch_to_buffer
+#endif
+#ifndef cmDependsJava_yypush_buffer_state_ALREADY_DEFINED
+#undef yypush_buffer_state
+#endif
+#ifndef cmDependsJava_yypop_buffer_state_ALREADY_DEFINED
+#undef yypop_buffer_state
+#endif
+#ifndef cmDependsJava_yyensure_buffer_stack_ALREADY_DEFINED
+#undef yyensure_buffer_stack
+#endif
+#ifndef cmDependsJava_yylex_ALREADY_DEFINED
+#undef yylex
+#endif
+#ifndef cmDependsJava_yyrestart_ALREADY_DEFINED
+#undef yyrestart
+#endif
+#ifndef cmDependsJava_yylex_init_ALREADY_DEFINED
+#undef yylex_init
+#endif
+#ifndef cmDependsJava_yylex_init_extra_ALREADY_DEFINED
+#undef yylex_init_extra
+#endif
+#ifndef cmDependsJava_yylex_destroy_ALREADY_DEFINED
+#undef yylex_destroy
+#endif
+#ifndef cmDependsJava_yyget_debug_ALREADY_DEFINED
+#undef yyget_debug
+#endif
+#ifndef cmDependsJava_yyset_debug_ALREADY_DEFINED
+#undef yyset_debug
+#endif
+#ifndef cmDependsJava_yyget_extra_ALREADY_DEFINED
+#undef yyget_extra
+#endif
+#ifndef cmDependsJava_yyset_extra_ALREADY_DEFINED
+#undef yyset_extra
+#endif
+#ifndef cmDependsJava_yyget_in_ALREADY_DEFINED
+#undef yyget_in
+#endif
+#ifndef cmDependsJava_yyset_in_ALREADY_DEFINED
+#undef yyset_in
+#endif
+#ifndef cmDependsJava_yyget_out_ALREADY_DEFINED
+#undef yyget_out
+#endif
+#ifndef cmDependsJava_yyset_out_ALREADY_DEFINED
+#undef yyset_out
+#endif
+#ifndef cmDependsJava_yyget_leng_ALREADY_DEFINED
+#undef yyget_leng
+#endif
+#ifndef cmDependsJava_yyget_text_ALREADY_DEFINED
+#undef yyget_text
+#endif
+#ifndef cmDependsJava_yyget_lineno_ALREADY_DEFINED
+#undef yyget_lineno
+#endif
+#ifndef cmDependsJava_yyset_lineno_ALREADY_DEFINED
+#undef yyset_lineno
+#endif
+#ifndef cmDependsJava_yyget_column_ALREADY_DEFINED
+#undef yyget_column
+#endif
+#ifndef cmDependsJava_yyset_column_ALREADY_DEFINED
+#undef yyset_column
+#endif
+#ifndef cmDependsJava_yywrap_ALREADY_DEFINED
+#undef yywrap
+#endif
+#ifndef cmDependsJava_yyget_lval_ALREADY_DEFINED
+#undef yyget_lval
+#endif
+#ifndef cmDependsJava_yyset_lval_ALREADY_DEFINED
+#undef yyset_lval
+#endif
+#ifndef cmDependsJava_yyget_lloc_ALREADY_DEFINED
+#undef yyget_lloc
+#endif
+#ifndef cmDependsJava_yyset_lloc_ALREADY_DEFINED
+#undef yyset_lloc
+#endif
+#ifndef cmDependsJava_yyalloc_ALREADY_DEFINED
+#undef yyalloc
+#endif
+#ifndef cmDependsJava_yyrealloc_ALREADY_DEFINED
+#undef yyrealloc
+#endif
+#ifndef cmDependsJava_yyfree_ALREADY_DEFINED
+#undef yyfree
+#endif
+#ifndef cmDependsJava_yytext_ALREADY_DEFINED
+#undef yytext
+#endif
+#ifndef cmDependsJava_yyleng_ALREADY_DEFINED
+#undef yyleng
+#endif
+#ifndef cmDependsJava_yyin_ALREADY_DEFINED
+#undef yyin
+#endif
+#ifndef cmDependsJava_yyout_ALREADY_DEFINED
+#undef yyout
+#endif
+#ifndef cmDependsJava_yy_flex_debug_ALREADY_DEFINED
+#undef yy_flex_debug
+#endif
+#ifndef cmDependsJava_yylineno_ALREADY_DEFINED
+#undef yylineno
+#endif
+#ifndef cmDependsJava_yytables_fload_ALREADY_DEFINED
+#undef yytables_fload
+#endif
+#ifndef cmDependsJava_yytables_destroy_ALREADY_DEFINED
+#undef yytables_destroy
+#endif
+#ifndef cmDependsJava_yyTABLES_NAME_ALREADY_DEFINED
+#undef yyTABLES_NAME
+#endif
-#line 335 "cmDependsJavaLexer.h"
#undef cmDependsJava_yyIN_HEADER
#endif /* cmDependsJava_yyHEADER_H */
diff --git a/Source/LexerParser/cmDependsJavaLexer.in.l b/Source/LexerParser/cmDependsJavaLexer.in.l
index 8cb42b17a..3dd3c224a 100644
--- a/Source/LexerParser/cmDependsJavaLexer.in.l
+++ b/Source/LexerParser/cmDependsJavaLexer.in.l
@@ -7,18 +7,19 @@ This file must be translated to C++ and modified to build everywhere.
Run flex >= 2.6 like this:
- flex --nounistd -DFLEXINT_H --prefix=cmDependsJava_yy --header-file=cmDependsJavaLexer.h -ocmDependsJavaLexer.cxx cmDependsJavaLexer.in.l
+ flex --nounistd -DFLEXINT_H --noline --header-file=cmDependsJavaLexer.h -ocmDependsJavaLexer.cxx cmDependsJavaLexer.in.l
Modify cmDependsJavaLexer.cxx:
- - remove trailing whitespace: sed -i 's/\s*$//' cmDependsJavaLexer.h cmDependsJavaLexer.cxx
- - remove blank lines at end of file
- - #include "cmStandardLexer.h" at the top
- - add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t
+ - remove trailing whitespace: sed -i 's/\s*$//' cmDependsJavaLexer.h cmDependsJavaLexer.cxx
+ - remove blank lines at end of file: sed -i '${/^$/d;}' cmDependsJavaLexer.h cmDependsJavaLexer.cxx
+ - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmDependsJavaLexer.cxx
*/
/* IWYU pragma: no_forward_declare yyguts_t */
+#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+
#include <iostream>
#include "cmDependsJavaParserHelper.h"
@@ -26,7 +27,7 @@ Modify cmDependsJavaLexer.cxx:
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
- { result = yyextra->LexInput(buf, max_size); }
+ do { result = yyextra->LexInput(buf, max_size); } while (0)
/* Include the set of tokens from the parser. */
#include "cmDependsJavaParserTokens.h"
@@ -38,6 +39,8 @@ Modify cmDependsJavaLexer.cxx:
/*--------------------------------------------------------------------------*/
%}
+%option prefix="cmDependsJava_yy"
+
%option reentrant
%option noyywrap
%pointer
@@ -172,3 +175,7 @@ null { PRIMITIVE; return jp_NULLLITERAL; }
}
%%
+
+/*--------------------------------------------------------------------------*/
+
+#endif /* __clang_analyzer__ */
diff --git a/Source/LexerParser/cmDependsJavaParser.cxx b/Source/LexerParser/cmDependsJavaParser.cxx
index bc45d45e1..6c1fb2cb3 100644
--- a/Source/LexerParser/cmDependsJavaParser.cxx
+++ b/Source/LexerParser/cmDependsJavaParser.cxx
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
+/* A Bison parser, made by GNU Bison 3.3.2. */
/* Bison implementation for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
+ Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -40,11 +41,14 @@
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
+/* Undocumented macros, especially those whose name start with YY_,
+ are private implementation details. Do not rely on them. */
+
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "3.0.4"
+#define YYBISON_VERSION "3.3.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -67,8 +71,8 @@
#define yynerrs cmDependsJava_yynerrs
-/* Copy the first part of user declarations. */
-#line 1 "cmDependsJavaParser.y" /* yacc.c:339 */
+/* First part of user prologue. */
+#line 1 "cmDependsJavaParser.y" /* yacc.c:337 */
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
@@ -107,7 +111,7 @@ static void cmDependsJava_yyerror(yyscan_t yyscanner, const char* message);
#define YYMAXDEPTH 1000000
-#define jpCheckEmpty(cnt) yyGetParser->CheckEmpty(__LINE__, cnt, yyvsp);
+#define jpCheckEmpty(cnt) yyGetParser->CheckEmpty(__LINE__, cnt, yyvsp)
#define jpElementStart(cnt) yyGetParser->PrepareElement(&yyval)
#define jpStoreClass(str) yyGetParser->AddClassFound(str); yyGetParser->DeallocateParserType(&(str))
/* Disable some warnings in the generated code. */
@@ -115,14 +119,20 @@ static void cmDependsJava_yyerror(yyscan_t yyscanner, const char* message);
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but no case. */
#endif
+#if defined(__GNUC__) && __GNUC__ >= 8
+# pragma GCC diagnostic ignored "-Wconversion"
+#endif
-#line 120 "cmDependsJavaParser.cxx" /* yacc.c:339 */
-
+#line 127 "cmDependsJavaParser.cxx" /* yacc.c:337 */
# ifndef YY_NULLPTR
-# if defined __cplusplus && 201103L <= __cplusplus
-# define YY_NULLPTR nullptr
+# if defined __cplusplus
+# if 201103L <= __cplusplus
+# define YY_NULLPTR nullptr
+# else
+# define YY_NULLPTR 0
+# endif
# else
-# define YY_NULLPTR 0
+# define YY_NULLPTR ((void*)0)
# endif
# endif
@@ -369,9 +379,7 @@ int cmDependsJava_yyparse (yyscan_t yyscanner);
#endif /* !YY_CMDEPENDSJAVA_YY_CMDEPENDSJAVAPARSERTOKENS_H_INCLUDED */
-/* Copy the second part of user declarations. */
-#line 375 "cmDependsJavaParser.cxx" /* yacc.c:358 */
#ifdef short
# undef short
@@ -392,13 +400,13 @@ typedef signed char yytype_int8;
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
-typedef unsigned short int yytype_uint16;
+typedef unsigned short yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
-typedef short int yytype_int16;
+typedef short yytype_int16;
#endif
#ifndef YYSIZE_T
@@ -410,7 +418,7 @@ typedef short int yytype_int16;
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
-# define YYSIZE_T unsigned int
+# define YYSIZE_T unsigned
# endif
#endif
@@ -446,15 +454,6 @@ typedef short int yytype_int16;
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
-#if !defined _Noreturn \
- && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
-# if defined _MSC_VER && 1200 <= _MSC_VER
-# define _Noreturn __declspec (noreturn)
-# else
-# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
-# endif
-#endif
-
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
@@ -462,7 +461,7 @@ typedef short int yytype_int16;
# define YYUSE(E) /* empty */
#endif
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
@@ -624,16 +623,16 @@ union yyalloc
/* YYNSTATES -- Number of states. */
#define YYNSTATES 575
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
- by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 360
+/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
+ as returned by yylex, with out-of-bounds checking. */
#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+ ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
- as returned by yylex, without out-of-bounds checking. */
+ as returned by yylex. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -679,42 +678,42 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 179, 179, 188, 196, 204, 212, 220, 228, 237,
- 245, 254, 262, 271, 276, 281, 286, 291, 296, 301,
- 306, 312, 320, 329, 339, 348, 357, 365, 375, 381,
- 388, 395, 401, 408, 417, 427, 437, 446, 454, 463,
- 472, 478, 487, 493, 502, 508, 517, 529, 537, 546,
- 558, 571, 579, 587, 596, 604, 613, 613, 613, 614,
- 615, 615, 615, 615, 615, 615, 616, 619, 629, 638,
- 647, 656, 666, 672, 681, 690, 699, 707, 716, 725,
- 731, 740, 748, 756, 764, 773, 781, 790, 796, 804,
- 813, 821, 830, 839, 848, 856, 865, 873, 881, 890,
- 899, 909, 916, 926, 936, 943, 950, 953, 959, 969,
- 979, 989, 995, 1005, 1015, 1025, 1034, 1044, 1055, 1065,
- 1072, 1082, 1091, 1101, 1110, 1120, 1126, 1136, 1145, 1155,
- 1165, 1172, 1181, 1190, 1199, 1208, 1216, 1225, 1234, 1244,
- 1254, 1263, 1273, 1283, 1290, 1299, 1309, 1318, 1328, 1337,
- 1344, 1354, 1363, 1373, 1382, 1391, 1401, 1411, 1420, 1430,
- 1439, 1448, 1457, 1466, 1475, 1485, 1494, 1503, 1512, 1521,
- 1531, 1540, 1549, 1558, 1567, 1576, 1585, 1594, 1603, 1612,
- 1621, 1630, 1640, 1650, 1661, 1671, 1681, 1690, 1699, 1708,
- 1717, 1726, 1735, 1745, 1755, 1765, 1775, 1782, 1789, 1796,
- 1806, 1813, 1823, 1833, 1842, 1852, 1861, 1871, 1878, 1885,
- 1892, 1900, 1907, 1917, 1924, 1934, 1944, 1951, 1961, 1970,
- 1980, 1990, 1999, 2009, 2018, 2028, 2039, 2046, 2053, 2064,
- 2074, 2084, 2094, 2103, 2113, 2120, 2130, 2139, 2149, 2156,
- 2166, 2175, 2185, 2194, 2200, 2209, 2218, 2227, 2236, 2246,
- 2256, 2263, 2273, 2280, 2290, 2299, 2309, 2318, 2327, 2336,
- 2346, 2353, 2363, 2372, 2382, 2392, 2398, 2405, 2415, 2425,
- 2435, 2446, 2456, 2467, 2477, 2488, 2498, 2508, 2517, 2526,
- 2535, 2544, 2554, 2564, 2574, 2583, 2592, 2601, 2610, 2620,
- 2630, 2640, 2649, 2658, 2667, 2677, 2686, 2695, 2702, 2711,
- 2720, 2729, 2739, 2748, 2757, 2767, 2776, 2785, 2794, 2804,
- 2813, 2822, 2831, 2840, 2849, 2859, 2868, 2877, 2887, 2896,
- 2906, 2915, 2925, 2934, 2944, 2953, 2963, 2972, 2982, 2991,
- 3001, 3010, 3020, 3030, 3040, 3049, 3059, 3068, 3077, 3086,
- 3095, 3104, 3113, 3122, 3131, 3140, 3149, 3158, 3168, 3178,
- 3188, 3197
+ 0, 182, 182, 191, 199, 207, 215, 223, 231, 240,
+ 248, 257, 265, 274, 279, 284, 289, 294, 299, 304,
+ 309, 315, 323, 332, 342, 351, 360, 368, 378, 384,
+ 391, 398, 404, 411, 420, 430, 440, 449, 457, 466,
+ 475, 481, 490, 496, 505, 511, 520, 532, 540, 549,
+ 561, 574, 582, 590, 599, 607, 616, 616, 616, 617,
+ 618, 618, 618, 618, 618, 618, 619, 622, 632, 641,
+ 650, 659, 669, 675, 684, 693, 702, 710, 719, 728,
+ 734, 743, 751, 759, 767, 776, 784, 793, 799, 807,
+ 816, 824, 833, 842, 851, 859, 868, 876, 884, 893,
+ 902, 912, 919, 929, 939, 946, 953, 956, 962, 972,
+ 982, 992, 998, 1008, 1018, 1028, 1037, 1047, 1058, 1068,
+ 1075, 1085, 1094, 1104, 1113, 1123, 1129, 1139, 1148, 1158,
+ 1168, 1175, 1184, 1193, 1202, 1211, 1219, 1228, 1237, 1247,
+ 1257, 1266, 1276, 1286, 1293, 1302, 1312, 1321, 1331, 1340,
+ 1347, 1357, 1366, 1376, 1385, 1394, 1404, 1414, 1423, 1433,
+ 1442, 1451, 1460, 1469, 1478, 1488, 1497, 1506, 1515, 1524,
+ 1534, 1543, 1552, 1561, 1570, 1579, 1588, 1597, 1606, 1615,
+ 1624, 1633, 1643, 1653, 1664, 1674, 1684, 1693, 1702, 1711,
+ 1720, 1729, 1738, 1748, 1758, 1768, 1778, 1785, 1792, 1799,
+ 1809, 1816, 1826, 1836, 1845, 1855, 1864, 1874, 1881, 1888,
+ 1895, 1903, 1910, 1920, 1927, 1937, 1947, 1954, 1964, 1973,
+ 1983, 1993, 2002, 2012, 2021, 2031, 2042, 2049, 2056, 2067,
+ 2077, 2087, 2097, 2106, 2116, 2123, 2133, 2142, 2152, 2159,
+ 2169, 2178, 2188, 2197, 2203, 2212, 2221, 2230, 2239, 2249,
+ 2259, 2266, 2276, 2283, 2293, 2302, 2312, 2321, 2330, 2339,
+ 2349, 2356, 2366, 2375, 2385, 2395, 2401, 2408, 2418, 2428,
+ 2438, 2449, 2459, 2470, 2480, 2491, 2501, 2511, 2520, 2529,
+ 2538, 2547, 2557, 2567, 2577, 2586, 2595, 2604, 2613, 2623,
+ 2633, 2643, 2652, 2661, 2670, 2680, 2689, 2698, 2705, 2714,
+ 2723, 2732, 2742, 2751, 2760, 2770, 2779, 2788, 2797, 2807,
+ 2816, 2825, 2834, 2843, 2852, 2862, 2871, 2880, 2890, 2899,
+ 2909, 2918, 2928, 2937, 2947, 2956, 2966, 2975, 2985, 2994,
+ 3004, 3013, 3023, 3033, 3043, 3052, 3062, 3071, 3080, 3089,
+ 3098, 3107, 3116, 3125, 3134, 3143, 3152, 3161, 3171, 3181,
+ 3191, 3200
};
#endif
@@ -1615,22 +1614,22 @@ static const yytype_uint8 yyr2[] =
#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (yylen); \
- yystate = *yyssp; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (yyscanner, YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (0)
+#define YYBACKUP(Token, Value) \
+ do \
+ if (yychar == YYEMPTY) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (yylen); \
+ yystate = *yyssp; \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (yyscanner, YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+ while (0)
/* Error token number */
#define YYTERROR 1
@@ -1670,38 +1669,38 @@ do { \
} while (0)
-/*----------------------------------------.
-| Print this symbol's value on YYOUTPUT. |
-`----------------------------------------*/
+/*-----------------------------------.
+| Print this symbol's value on YYO. |
+`-----------------------------------*/
static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
+yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
{
- FILE *yyo = yyoutput;
- YYUSE (yyo);
+ FILE *yyoutput = yyo;
+ YYUSE (yyoutput);
YYUSE (yyscanner);
if (!yyvaluep)
return;
# ifdef YYPRINT
if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+ YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
# endif
YYUSE (yytype);
}
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
+/*---------------------------.
+| Print this symbol on YYO. |
+`---------------------------*/
static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
+yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
{
- YYFPRINTF (yyoutput, "%s %s (",
+ YYFPRINTF (yyo, "%s %s (",
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
- yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner);
- YYFPRINTF (yyoutput, ")");
+ yy_symbol_value_print (yyo, yytype, yyvaluep, yyscanner);
+ YYFPRINTF (yyo, ")");
}
/*------------------------------------------------------------------.
@@ -1735,7 +1734,7 @@ do { \
static void
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner)
{
- unsigned long int yylno = yyrline[yyrule];
+ unsigned long yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
@@ -1746,7 +1745,7 @@ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, yyscan_t yysca
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
yystos[yyssp[yyi + 1 - yynrhs]],
- &(yyvsp[(yyi + 1) - (yynrhs)])
+ &yyvsp[(yyi + 1) - (yynrhs)]
, yyscanner);
YYFPRINTF (stderr, "\n");
}
@@ -1850,7 +1849,10 @@ yytnamerr (char *yyres, const char *yystr)
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
- /* Fall through. */
+ else
+ goto append;
+
+ append:
default:
if (yyres)
yyres[yyn] = *yyp;
@@ -1868,7 +1870,7 @@ yytnamerr (char *yyres, const char *yystr)
if (! yyres)
return yystrlen (yystr);
- return yystpcpy (yyres, yystr) - yyres;
+ return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
}
# endif
@@ -1946,10 +1948,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yyarg[yycount++] = yytname[yyx];
{
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
- if (! (yysize <= yysize1
- && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+ yysize = yysize1;
+ else
return 2;
- yysize = yysize1;
}
}
}
@@ -1961,6 +1963,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
case N: \
yyformat = S; \
break
+ default: /* Avoid compiler warnings. */
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
@@ -1972,9 +1975,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
{
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
- if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+ yysize = yysize1;
+ else
return 2;
- yysize = yysize1;
}
if (*yymsg_alloc < yysize)
@@ -2105,23 +2109,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
+
/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
+| yynewstate -- push a new state, which is found in yystate. |
`------------------------------------------------------------*/
- yynewstate:
+yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
- yysetstate:
- *yyssp = yystate;
+
+/*--------------------------------------------------------------------.
+| yynewstate -- set current state (the top of the stack) to yystate. |
+`--------------------------------------------------------------------*/
+yysetstate:
+ *yyssp = (yytype_int16) yystate;
if (yyss + yystacksize - 1 <= yyssp)
+#if !defined yyoverflow && !defined YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+#else
{
/* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
+ YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
-#ifdef yyoverflow
+# if defined yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
@@ -2137,14 +2149,10 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
-
yyss = yyss1;
yyvs = yyvs1;
}
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
+# else /* defined YYSTACK_RELOCATE */
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
@@ -2160,22 +2168,22 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
-# undef YYSTACK_RELOCATE
+# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
-#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
+ (unsigned long) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
+#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
@@ -2184,11 +2192,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
goto yybackup;
+
/*-----------.
| yybackup. |
`-----------*/
yybackup:
-
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
@@ -2261,7 +2269,7 @@ yydefault:
/*-----------------------------.
-| yyreduce -- Do a reduction. |
+| yyreduce -- do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
@@ -2282,214 +2290,214 @@ yyreduce:
switch (yyn)
{
case 2:
-#line 180 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 183 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2293 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2301 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 3:
-#line 189 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 192 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2304 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2312 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 4:
-#line 197 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 200 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2315 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2323 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 5:
-#line 205 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 208 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2326 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2334 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 6:
-#line 213 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 216 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2337 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2345 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 7:
-#line 221 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 224 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2348 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2356 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 8:
-#line 229 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 232 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2359 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2367 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 9:
-#line 238 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 241 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2370 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2378 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 10:
-#line 246 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 249 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2381 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2389 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 11:
-#line 255 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 258 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2392 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2400 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 12:
-#line 263 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 266 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2403 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2411 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 13:
-#line 272 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 275 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
}
-#line 2411 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2419 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 14:
-#line 277 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 280 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
}
-#line 2419 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2427 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 15:
-#line 282 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 285 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
}
-#line 2427 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2435 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 16:
-#line 287 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 290 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
}
-#line 2435 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2443 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 17:
-#line 292 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 295 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
}
-#line 2443 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2451 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 18:
-#line 297 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 300 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
}
-#line 2451 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2459 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 19:
-#line 302 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 305 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
}
-#line 2459 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2467 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 20:
-#line 307 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 310 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
}
-#line 2467 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2475 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 21:
-#line 313 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 316 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2478 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2486 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 22:
-#line 321 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 324 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2489 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2497 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 23:
-#line 330 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 333 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpStoreClass((yyvsp[0].str));
@@ -2497,44 +2505,44 @@ yyreduce:
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2501 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2509 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 24:
-#line 340 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 343 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2512 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2520 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 25:
-#line 349 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 352 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2523 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2531 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 26:
-#line 358 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 361 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2534 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2542 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 27:
-#line 366 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 369 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpStoreClass((yyvsp[-1].str));
@@ -2542,56 +2550,56 @@ yyreduce:
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2546 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2554 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 28:
-#line 376 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 379 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
(yyval.str) = (yyvsp[0].str);
}
-#line 2555 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2563 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 29:
-#line 382 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 385 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
(yyval.str) = (yyvsp[0].str);
}
-#line 2564 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2572 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 30:
-#line 389 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 392 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
(yyval.str) = (yyvsp[0].str);
}
-#line 2573 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2581 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 31:
-#line 396 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 399 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
(yyval.str) = (yyvsp[0].str);
}
-#line 2582 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2590 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 32:
-#line 402 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 405 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
(yyval.str) = (yyvsp[0].str);
}
-#line 2591 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2599 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 33:
-#line 409 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 412 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
yyGetParser->AddClassFound((yyvsp[-2].str));
@@ -2599,11 +2607,11 @@ yyreduce:
yyGetParser->DeallocateParserType(&((yyvsp[-2].str)));
(yyval.str) = const_cast<char*>(yyGetParser->GetCurrentCombine());
}
-#line 2603 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2611 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 34:
-#line 418 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 421 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpStoreClass((yyvsp[-2].str));
@@ -2612,11 +2620,11 @@ yyreduce:
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2616 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2624 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 35:
-#line 428 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 431 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpStoreClass((yyvsp[-2].str));
@@ -2625,118 +2633,118 @@ yyreduce:
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2629 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2637 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 36:
-#line 438 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 441 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2640 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2648 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 37:
-#line 447 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 450 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2651 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2659 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 38:
-#line 455 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 458 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2662 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2670 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 39:
-#line 464 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 467 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2673 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2681 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 40:
-#line 472 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 475 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2683 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2691 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 41:
-#line 479 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 482 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2694 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2702 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 42:
-#line 487 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 490 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2704 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2712 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 43:
-#line 494 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 497 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2715 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2723 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 44:
-#line 502 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 505 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2725 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2733 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 45:
-#line 509 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 512 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2736 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2744 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 46:
-#line 518 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 521 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
yyGetParser->SetCurrentPackage((yyvsp[-1].str));
@@ -2746,33 +2754,33 @@ yyreduce:
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2750 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2758 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 47:
-#line 530 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 533 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2761 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2769 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 48:
-#line 538 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 541 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2772 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2780 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 49:
-#line 547 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 550 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
yyGetParser->AddPackagesImport((yyvsp[-1].str));
@@ -2782,11 +2790,11 @@ yyreduce:
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2786 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2794 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 50:
-#line 559 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 562 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
std::string str = (yyvsp[-3].str);
@@ -2797,77 +2805,77 @@ yyreduce:
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2801 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2809 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 51:
-#line 572 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 575 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2812 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2820 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 52:
-#line 580 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 583 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2823 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2831 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 53:
-#line 588 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 591 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2834 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2842 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 54:
-#line 597 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 600 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2845 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2853 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 55:
-#line 605 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 608 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2856 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2864 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 67:
-#line 620 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 623 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
yyGetParser->StartClass((yyvsp[0].str));
jpElementStart(3);
yyGetParser->DeallocateParserType(&((yyvsp[0].str)));
jpCheckEmpty(3);
}
-#line 2867 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2875 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 68:
-#line 630 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 633 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -2875,11 +2883,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
yyGetParser->EndClass();
}
-#line 2879 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2887 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 69:
-#line 639 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 642 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(2);
@@ -2887,11 +2895,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
yyGetParser->EndClass();
}
-#line 2891 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2899 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 70:
-#line 648 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 651 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -2899,11 +2907,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
yyGetParser->EndClass();
}
-#line 2903 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2911 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 71:
-#line 657 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 660 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
jpCheckEmpty(4);
@@ -2911,226 +2919,226 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
yyGetParser->EndClass();
}
-#line 2915 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2923 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 72:
-#line 666 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 669 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2925 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2933 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 73:
-#line 673 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 676 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2936 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2944 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 74:
-#line 682 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 685 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2947 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2955 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 75:
-#line 691 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 694 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2958 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2966 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 76:
-#line 700 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 703 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2969 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2977 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 77:
-#line 708 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 711 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2980 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2988 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 78:
-#line 717 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 720 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 2991 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 2999 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 79:
-#line 725 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 728 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3001 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3009 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 80:
-#line 732 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 735 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3012 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3020 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 81:
-#line 741 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 744 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3023 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3031 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 82:
-#line 749 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 752 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3034 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3042 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 83:
-#line 757 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 760 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3045 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3053 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 84:
-#line 765 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 768 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3056 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3064 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 85:
-#line 774 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 777 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3067 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3075 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 86:
-#line 782 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 785 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3078 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3086 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 87:
-#line 791 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 794 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
}
-#line 3086 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3094 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 88:
-#line 797 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 800 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3097 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3105 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 89:
-#line 805 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 808 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3108 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3116 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 90:
-#line 814 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 817 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3119 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3127 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 91:
-#line 822 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 825 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3130 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3138 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 92:
-#line 831 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 834 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
yyGetParser->DeallocateParserType(&((yyvsp[0].str)));
@@ -3138,77 +3146,77 @@ yyreduce:
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3142 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3150 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 93:
-#line 840 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 843 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3153 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3161 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 94:
-#line 849 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 852 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3164 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3172 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 95:
-#line 857 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 860 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3175 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3183 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 96:
-#line 866 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 869 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3186 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3194 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 97:
-#line 874 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 877 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3197 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3205 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 98:
-#line 882 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 885 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3208 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3216 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 99:
-#line 891 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 894 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
jpCheckEmpty(4);
@@ -3216,11 +3224,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3220 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3228 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 100:
-#line 900 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 903 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
jpCheckEmpty(4);
@@ -3228,22 +3236,22 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3232 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3240 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 101:
-#line 909 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 912 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3243 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3251 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 102:
-#line 917 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 920 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3251,11 +3259,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3255 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3263 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 103:
-#line 927 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 930 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
yyGetParser->DeallocateParserType(&((yyvsp[-3].str)));
@@ -3264,40 +3272,40 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3268 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3276 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 104:
-#line 937 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 940 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
}
-#line 3277 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3285 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 105:
-#line 943 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 946 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3288 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3296 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 107:
-#line 954 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 957 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
}
-#line 3297 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3305 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 108:
-#line 960 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 963 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -3305,11 +3313,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3309 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3317 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 109:
-#line 970 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 973 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -3317,11 +3325,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3321 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3329 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 110:
-#line 980 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 983 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -3329,20 +3337,20 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3333 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3341 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 111:
-#line 990 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 993 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
}
-#line 3342 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3350 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 112:
-#line 996 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 999 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -3350,11 +3358,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3354 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3362 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 113:
-#line 1006 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1009 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3362,11 +3370,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3366 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3374 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 114:
-#line 1016 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1019 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -3374,11 +3382,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3378 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3386 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 115:
-#line 1026 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1029 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
jpCheckEmpty(4);
@@ -3386,11 +3394,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3390 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3398 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 116:
-#line 1035 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1038 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
jpCheckEmpty(5);
@@ -3398,11 +3406,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3402 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3410 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 117:
-#line 1045 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1048 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
yyGetParser->DeallocateParserType(&((yyvsp[-3].str)));
@@ -3411,11 +3419,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3415 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3423 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 118:
-#line 1056 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1059 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
jpCheckEmpty(4);
@@ -3423,22 +3431,22 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3427 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3435 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 119:
-#line 1065 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1068 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3438 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3446 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 120:
-#line 1073 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1076 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -3446,11 +3454,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3450 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3458 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 121:
-#line 1083 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1086 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
jpCheckEmpty(5);
@@ -3458,11 +3466,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3462 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3470 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 122:
-#line 1092 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1095 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
jpCheckEmpty(5);
@@ -3470,22 +3478,22 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3474 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3482 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 123:
-#line 1102 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1105 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
yyGetParser->StartClass((yyvsp[0].str));
jpElementStart(3);
yyGetParser->DeallocateParserType(&((yyvsp[0].str)));
jpCheckEmpty(3);
}
-#line 3485 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3493 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 124:
-#line 1111 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1114 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -3493,21 +3501,21 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
yyGetParser->EndClass();
}
-#line 3497 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3505 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 125:
-#line 1120 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1123 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3507 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3515 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 126:
-#line 1127 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1130 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3515,11 +3523,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3519 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3527 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 127:
-#line 1137 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1140 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -3527,11 +3535,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3531 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3539 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 128:
-#line 1146 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1149 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -3539,11 +3547,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3543 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3551 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 129:
-#line 1156 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1159 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -3551,33 +3559,33 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3555 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3563 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 130:
-#line 1165 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1168 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3566 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3574 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 131:
-#line 1173 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1176 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3577 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3585 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 132:
-#line 1182 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1185 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3585,11 +3593,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3589 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3597 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 133:
-#line 1191 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1194 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3597,11 +3605,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3601 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3609 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 134:
-#line 1200 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1203 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3609,22 +3617,22 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3613 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3621 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 135:
-#line 1209 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1212 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3624 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3632 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 136:
-#line 1217 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1220 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3632,22 +3640,22 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3636 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3644 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 137:
-#line 1226 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1229 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3647 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3655 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 138:
-#line 1235 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1238 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3655,11 +3663,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3659 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3667 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 139:
-#line 1245 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1248 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -3667,11 +3675,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3671 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3679 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 140:
-#line 1255 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1258 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3679,11 +3687,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3683 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3691 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 141:
-#line 1264 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1267 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -3691,11 +3699,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3695 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3703 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 142:
-#line 1274 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1277 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -3703,22 +3711,22 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3707 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3715 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 143:
-#line 1283 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1286 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3718 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3726 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 144:
-#line 1291 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1294 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3726,11 +3734,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3730 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3738 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 145:
-#line 1300 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1303 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -3738,11 +3746,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3742 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3750 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 146:
-#line 1310 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1313 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3750,11 +3758,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3754 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3762 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 147:
-#line 1319 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1322 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -3762,33 +3770,33 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3766 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3774 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 148:
-#line 1329 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1332 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3777 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3785 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 149:
-#line 1337 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1340 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 3788 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3796 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 150:
-#line 1345 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1348 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3796,11 +3804,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3800 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3808 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 151:
-#line 1355 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1358 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3808,11 +3816,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3812 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3820 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 152:
-#line 1364 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1367 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(2);
@@ -3820,11 +3828,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3824 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3832 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 153:
-#line 1374 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1377 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3832,11 +3840,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3836 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3844 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 154:
-#line 1383 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1386 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3844,11 +3852,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3848 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3856 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 155:
-#line 1392 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1395 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3856,11 +3864,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3860 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3868 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 156:
-#line 1402 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1405 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(2);
@@ -3868,11 +3876,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3872 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3880 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 157:
-#line 1412 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1415 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(3);
@@ -3880,11 +3888,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3884 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3892 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 158:
-#line 1421 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1424 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(2);
@@ -3892,11 +3900,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3896 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3904 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 159:
-#line 1431 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1434 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3904,11 +3912,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3908 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3916 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 160:
-#line 1440 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1443 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3916,11 +3924,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3920 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3928 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 161:
-#line 1449 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1452 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3928,11 +3936,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3932 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3940 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 162:
-#line 1458 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1461 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3940,11 +3948,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3944 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3952 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 163:
-#line 1467 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1470 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3952,11 +3960,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3956 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3964 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 164:
-#line 1476 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1479 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3964,11 +3972,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3968 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3976 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 165:
-#line 1486 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1489 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3976,11 +3984,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3980 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 3988 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 166:
-#line 1495 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1498 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -3988,11 +3996,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 3992 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4000 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 167:
-#line 1504 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1507 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4000,11 +4008,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4004 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4012 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 168:
-#line 1513 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1516 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4012,11 +4020,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4016 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4024 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 169:
-#line 1522 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1525 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4024,11 +4032,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4028 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4036 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 170:
-#line 1532 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1535 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4036,11 +4044,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4040 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4048 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 171:
-#line 1541 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1544 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4048,11 +4056,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4052 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4060 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 172:
-#line 1550 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1553 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4060,11 +4068,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4064 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4072 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 173:
-#line 1559 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1562 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4072,11 +4080,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4076 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4084 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 174:
-#line 1568 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1571 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4084,11 +4092,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4088 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4096 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 175:
-#line 1577 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1580 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4096,11 +4104,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4100 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4108 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 176:
-#line 1586 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1589 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4108,11 +4116,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4112 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4120 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 177:
-#line 1595 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1598 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4120,11 +4128,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4124 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4132 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 178:
-#line 1604 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1607 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4132,11 +4140,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4136 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4144 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 179:
-#line 1613 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1616 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4144,11 +4152,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4148 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4156 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 180:
-#line 1622 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1625 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4156,11 +4164,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4160 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4168 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 181:
-#line 1631 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1634 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4168,11 +4176,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4172 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4180 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 182:
-#line 1641 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1644 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4180,11 +4188,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4184 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4192 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 183:
-#line 1651 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1654 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
yyGetParser->DeallocateParserType(&((yyvsp[-2].str)));
@@ -4193,11 +4201,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4197 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4205 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 184:
-#line 1662 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1665 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -4205,11 +4213,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4209 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4217 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 185:
-#line 1672 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1675 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -4217,11 +4225,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4221 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4229 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 186:
-#line 1682 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1685 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4229,11 +4237,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4233 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4241 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 187:
-#line 1691 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1694 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4241,11 +4249,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4245 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4253 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 188:
-#line 1700 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1703 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4253,11 +4261,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4257 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4265 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 189:
-#line 1709 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1712 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4265,11 +4273,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4269 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4277 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 190:
-#line 1718 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1721 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4277,11 +4285,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4281 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4289 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 191:
-#line 1727 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1730 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4289,11 +4297,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4293 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4301 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 192:
-#line 1736 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1739 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4301,11 +4309,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4305 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4313 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 193:
-#line 1746 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1749 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
jpCheckEmpty(5);
@@ -4313,11 +4321,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4317 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4325 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 194:
-#line 1756 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1759 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(7);
jpCheckEmpty(7);
@@ -4325,11 +4333,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4329 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4337 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 195:
-#line 1766 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1769 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(7);
jpCheckEmpty(7);
@@ -4337,40 +4345,40 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4341 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4349 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 196:
-#line 1776 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1779 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
}
-#line 4350 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4358 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 197:
-#line 1783 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1786 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
}
-#line 4359 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4367 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 198:
-#line 1789 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1792 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 4370 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4378 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 199:
-#line 1797 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1800 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4378,22 +4386,22 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4382 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4390 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 200:
-#line 1806 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1809 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 4393 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4401 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 201:
-#line 1814 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1817 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -4401,11 +4409,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4405 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4413 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 202:
-#line 1824 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1827 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -4413,11 +4421,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4417 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4425 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 203:
-#line 1834 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1837 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4425,11 +4433,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4429 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4437 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 204:
-#line 1843 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1846 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -4437,11 +4445,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4441 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4449 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 205:
-#line 1853 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1856 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -4449,11 +4457,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4453 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4461 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 206:
-#line 1862 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1865 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -4461,58 +4469,58 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4465 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4473 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 207:
-#line 1872 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1875 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
}
-#line 4474 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4482 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 208:
-#line 1879 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1882 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
}
-#line 4483 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4491 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 209:
-#line 1886 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1889 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(7);
}
-#line 4492 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4500 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 210:
-#line 1894 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1897 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(9);
}
-#line 4501 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4509 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 211:
-#line 1900 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1903 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 4512 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4520 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 212:
-#line 1908 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1911 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4520,22 +4528,22 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4524 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4532 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 213:
-#line 1917 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1920 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 4535 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4543 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 214:
-#line 1925 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1928 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4543,33 +4551,33 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4547 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4555 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 215:
-#line 1936 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1939 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(9);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 4558 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4566 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 216:
-#line 1944 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1947 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 4569 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4577 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 217:
-#line 1952 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1955 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4577,11 +4585,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4581 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4589 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 218:
-#line 1962 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1965 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4589,11 +4597,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4593 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4601 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 219:
-#line 1971 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1974 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4601,11 +4609,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4605 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4613 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 220:
-#line 1981 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1984 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4613,11 +4621,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4617 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4625 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 221:
-#line 1991 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 1994 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4625,11 +4633,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4629 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4637 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 222:
-#line 2000 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2003 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -4637,11 +4645,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4641 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4649 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 223:
-#line 2010 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2013 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -4649,11 +4657,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4653 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4661 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 224:
-#line 2019 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2022 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
jpCheckEmpty(5);
@@ -4661,11 +4669,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4665 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4673 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 225:
-#line 2029 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2032 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
yyGetParser->DeallocateParserType(&((yyvsp[-1].str)));
@@ -4674,31 +4682,31 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4678 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4686 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 226:
-#line 2039 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2042 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 4689 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4697 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 227:
-#line 2047 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2050 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
}
-#line 4698 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4706 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 228:
-#line 2054 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2057 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
yyGetParser->DeallocateParserType(&((yyvsp[-1].str)));
@@ -4707,11 +4715,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4711 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4719 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 229:
-#line 2065 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2068 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -4719,11 +4727,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4723 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4731 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 230:
-#line 2075 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2078 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -4731,11 +4739,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4735 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4743 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 231:
-#line 2085 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2088 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
jpCheckEmpty(5);
@@ -4743,11 +4751,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4747 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4755 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 232:
-#line 2095 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2098 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -4755,11 +4763,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4759 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4767 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 233:
-#line 2104 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2107 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
jpCheckEmpty(4);
@@ -4767,22 +4775,22 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4771 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4779 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 234:
-#line 2113 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2116 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 4782 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4790 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 235:
-#line 2121 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2124 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4790,11 +4798,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4794 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4802 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 236:
-#line 2131 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2134 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4802,11 +4810,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4806 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4814 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 237:
-#line 2140 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2143 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -4814,20 +4822,20 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4818 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4826 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 238:
-#line 2150 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2153 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
}
-#line 4827 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4835 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 239:
-#line 2157 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2160 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -4835,11 +4843,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4839 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4847 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 240:
-#line 2167 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2170 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4847,11 +4855,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4851 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4859 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 241:
-#line 2176 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2179 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4859,11 +4867,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4863 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4871 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 242:
-#line 2186 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2189 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4871,20 +4879,20 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4875 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4883 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 243:
-#line 2195 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2198 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
}
-#line 4884 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4892 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 244:
-#line 2201 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2204 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -4892,11 +4900,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4896 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4904 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 245:
-#line 2210 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2213 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4904,11 +4912,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4908 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4916 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 246:
-#line 2219 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2222 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4916,11 +4924,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4920 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4928 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 247:
-#line 2228 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2231 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4928,11 +4936,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4932 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4940 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 248:
-#line 2237 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2240 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4940,11 +4948,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4944 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4952 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 249:
-#line 2247 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2250 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(6);
jpCheckEmpty(6);
@@ -4952,22 +4960,22 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4956 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4964 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 250:
-#line 2256 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2259 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 4967 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4975 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 251:
-#line 2264 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2267 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4975,22 +4983,22 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 4979 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4987 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 252:
-#line 2273 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2276 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 4990 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 4998 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 253:
-#line 2281 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2284 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -4998,11 +5006,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5002 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5010 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 254:
-#line 2291 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2294 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5010,11 +5018,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5014 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5022 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 255:
-#line 2300 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2303 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5022,11 +5030,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5026 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5034 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 256:
-#line 2310 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2313 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
jpCheckEmpty(4);
@@ -5034,11 +5042,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5038 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5046 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 257:
-#line 2319 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2322 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
jpCheckEmpty(4);
@@ -5046,11 +5054,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5050 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5058 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 258:
-#line 2328 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2331 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
jpCheckEmpty(4);
@@ -5058,11 +5066,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5062 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5070 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 259:
-#line 2337 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2340 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
jpCheckEmpty(4);
@@ -5070,22 +5078,22 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5074 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5082 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 260:
-#line 2346 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2349 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(0);
(yyval.str) = 0;
yyGetParser->SetCurrentCombine("");
}
-#line 5085 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5093 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 261:
-#line 2354 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2357 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5093,11 +5101,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5097 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5105 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 262:
-#line 2364 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2367 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5105,11 +5113,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5109 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5117 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 263:
-#line 2373 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2376 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -5117,11 +5125,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5121 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5129 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 264:
-#line 2383 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2386 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5129,29 +5137,29 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5133 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5141 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 265:
-#line 2393 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2396 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
}
-#line 5142 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5150 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 266:
-#line 2399 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2402 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
}
-#line 5151 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5159 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 267:
-#line 2406 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2409 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
yyGetParser->DeallocateParserType(&((yyvsp[0].str)));
@@ -5160,11 +5168,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5164 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5172 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 268:
-#line 2416 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2419 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
yyGetParser->DeallocateParserType(&((yyvsp[0].str)));
@@ -5173,11 +5181,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5177 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5185 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 269:
-#line 2426 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2429 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
yyGetParser->DeallocateParserType(&((yyvsp[0].str)));
@@ -5186,11 +5194,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5190 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5198 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 270:
-#line 2436 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2439 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
yyGetParser->DeallocateParserType(&((yyvsp[0].str)));
@@ -5199,11 +5207,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5203 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5211 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 271:
-#line 2447 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2450 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
yyGetParser->DeallocateParserType(&((yyvsp[-3].str)));
@@ -5212,11 +5220,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5216 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5224 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 272:
-#line 2457 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2460 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(6);
yyGetParser->DeallocateParserType(&((yyvsp[-5].str)));
@@ -5226,11 +5234,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5230 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5238 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 273:
-#line 2468 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2471 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(6);
yyGetParser->DeallocateParserType(&((yyvsp[-3].str)));
@@ -5239,11 +5247,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5243 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5251 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 274:
-#line 2478 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2481 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(6);
yyGetParser->DeallocateParserType(&((yyvsp[-3].str)));
@@ -5252,11 +5260,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5256 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5264 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 275:
-#line 2489 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2492 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
yyGetParser->DeallocateParserType(&((yyvsp[-3].str)));
@@ -5265,11 +5273,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5269 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5277 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 276:
-#line 2499 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2502 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
jpCheckEmpty(4);
@@ -5277,11 +5285,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5281 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5289 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 277:
-#line 2509 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2512 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5289,11 +5297,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5293 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5301 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 278:
-#line 2518 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2521 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
yyGetParser->DeallocateParserType(&((yyvsp[0].str)));
@@ -5301,11 +5309,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5305 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5313 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 279:
-#line 2527 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2530 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5313,11 +5321,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5317 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5325 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 280:
-#line 2536 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2539 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5325,11 +5333,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5329 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5337 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 281:
-#line 2545 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2548 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5337,11 +5345,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5341 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5349 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 282:
-#line 2555 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2558 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -5349,11 +5357,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5353 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5361 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 283:
-#line 2565 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2568 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -5361,11 +5369,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5365 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5373 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 284:
-#line 2575 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2578 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5373,11 +5381,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5377 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5385 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 285:
-#line 2584 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2587 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5385,11 +5393,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5389 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5397 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 286:
-#line 2593 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2596 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -5397,11 +5405,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5401 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5409 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 287:
-#line 2602 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2605 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -5409,11 +5417,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5413 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5421 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 288:
-#line 2611 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2614 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5421,11 +5429,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5425 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5433 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 289:
-#line 2621 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2624 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -5433,11 +5441,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5437 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5445 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 290:
-#line 2631 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2634 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -5445,11 +5453,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5449 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5457 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 291:
-#line 2641 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2644 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5457,11 +5465,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5461 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5469 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 292:
-#line 2650 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2653 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -5469,11 +5477,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5473 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5481 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 293:
-#line 2659 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2662 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(2);
jpCheckEmpty(2);
@@ -5481,11 +5489,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5485 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5493 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 294:
-#line 2668 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2671 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5493,11 +5501,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5497 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5505 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 295:
-#line 2678 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2681 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
jpCheckEmpty(5);
@@ -5505,11 +5513,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5509 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5517 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 296:
-#line 2687 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2690 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(4);
jpCheckEmpty(4);
@@ -5517,20 +5525,20 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5521 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5529 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 297:
-#line 2696 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2699 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
}
-#line 5530 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5538 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 298:
-#line 2703 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2706 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5538,11 +5546,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5542 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5550 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 299:
-#line 2712 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2715 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5550,11 +5558,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5554 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5562 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 300:
-#line 2721 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2724 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5562,11 +5570,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5566 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5574 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 301:
-#line 2730 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2733 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5574,11 +5582,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5578 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5586 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 302:
-#line 2740 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2743 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5586,11 +5594,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5590 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5598 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 303:
-#line 2749 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2752 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5598,11 +5606,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5602 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5610 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 304:
-#line 2758 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2761 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5610,11 +5618,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5614 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5622 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 305:
-#line 2768 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2771 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5622,11 +5630,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5626 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5634 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 306:
-#line 2777 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2780 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5634,11 +5642,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5638 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5646 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 307:
-#line 2786 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2789 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5646,11 +5654,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5650 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5658 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 308:
-#line 2795 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2798 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5658,11 +5666,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5662 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5670 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 309:
-#line 2805 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2808 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5670,11 +5678,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5674 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5682 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 310:
-#line 2814 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2817 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5682,11 +5690,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5686 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5694 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 311:
-#line 2823 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2826 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5694,11 +5702,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5698 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5706 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 312:
-#line 2832 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2835 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5706,11 +5714,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5710 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5718 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 313:
-#line 2841 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2844 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5718,11 +5726,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5722 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5730 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 314:
-#line 2850 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2853 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5730,11 +5738,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5734 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5742 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 315:
-#line 2860 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2863 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5742,11 +5750,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5746 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5754 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 316:
-#line 2869 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2872 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5754,11 +5762,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5758 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5766 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 317:
-#line 2878 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2881 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5766,11 +5774,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5770 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5778 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 318:
-#line 2888 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2891 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5778,11 +5786,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5782 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5790 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 319:
-#line 2897 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2900 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5790,11 +5798,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5794 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5802 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 320:
-#line 2907 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2910 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5802,11 +5810,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5806 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5814 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 321:
-#line 2916 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2919 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5814,11 +5822,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5818 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5826 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 322:
-#line 2926 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2929 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5826,11 +5834,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5830 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5838 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 323:
-#line 2935 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2938 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5838,11 +5846,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5842 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5850 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 324:
-#line 2945 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2948 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5850,11 +5858,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5854 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5862 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 325:
-#line 2954 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2957 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5862,11 +5870,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5866 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5874 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 326:
-#line 2964 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2967 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5874,11 +5882,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5878 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5886 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 327:
-#line 2973 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2976 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5886,11 +5894,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5890 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5898 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 328:
-#line 2983 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2986 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5898,11 +5906,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5902 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5910 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 329:
-#line 2992 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 2995 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(5);
jpCheckEmpty(5);
@@ -5910,11 +5918,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5914 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5922 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 330:
-#line 3002 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3005 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5922,11 +5930,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5926 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5934 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 331:
-#line 3011 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3014 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5934,11 +5942,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5938 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5946 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 332:
-#line 3021 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3024 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpCheckEmpty(3);
@@ -5946,11 +5954,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5950 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5958 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 333:
-#line 3031 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3034 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
yyGetParser->DeallocateParserType(&((yyvsp[0].str)));
@@ -5959,11 +5967,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5963 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5971 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 334:
-#line 3041 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3044 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5971,11 +5979,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5975 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5983 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 335:
-#line 3050 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3053 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5983,11 +5991,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5987 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 5995 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 336:
-#line 3060 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3063 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -5995,11 +6003,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 5999 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6007 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 337:
-#line 3069 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3072 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6007,11 +6015,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6011 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6019 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 338:
-#line 3078 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3081 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6019,11 +6027,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6023 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6031 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 339:
-#line 3087 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3090 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6031,11 +6039,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6035 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6043 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 340:
-#line 3096 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3099 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6043,11 +6051,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6047 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6055 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 341:
-#line 3105 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3108 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6055,11 +6063,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6059 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6067 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 342:
-#line 3114 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3117 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6067,11 +6075,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6071 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6079 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 343:
-#line 3123 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3126 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6079,11 +6087,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6083 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6091 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 344:
-#line 3132 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3135 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6091,11 +6099,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6095 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6103 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 345:
-#line 3141 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3144 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6103,11 +6111,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6107 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6115 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 346:
-#line 3150 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3153 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6115,11 +6123,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6119 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6127 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 347:
-#line 3159 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3162 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6127,11 +6135,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6131 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6139 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 348:
-#line 3169 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3172 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6139,11 +6147,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6143 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6151 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 349:
-#line 3179 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3182 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6151,11 +6159,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6155 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6163 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 350:
-#line 3189 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3192 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(1);
jpCheckEmpty(1);
@@ -6163,11 +6171,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6167 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6175 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
case 351:
-#line 3198 "cmDependsJavaParser.y" /* yacc.c:1646 */
+#line 3201 "cmDependsJavaParser.y" /* yacc.c:1652 */
{
jpElementStart(3);
jpStoreClass((yyvsp[-2].str));
@@ -6176,11 +6184,11 @@ yyreduce:
yyGetParser->SetCurrentCombine("");
}
-#line 6180 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6188 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
break;
-#line 6184 "cmDependsJavaParser.cxx" /* yacc.c:1646 */
+#line 6192 "cmDependsJavaParser.cxx" /* yacc.c:1652 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -6205,14 +6213,13 @@ yyreduce:
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
+ {
+ const int yylhs = yyr1[yyn] - YYNTOKENS;
+ const int yyi = yypgoto[yylhs] + *yyssp;
+ yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
+ ? yytable[yyi]
+ : yydefgoto[yylhs]);
+ }
goto yynewstate;
@@ -6296,12 +6303,10 @@ yyerrlab:
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
+ /* Pacify compilers when the user code never invokes YYERROR and the
+ label yyerrorlab therefore never appears in user code. */
+ if (0)
+ YYERROR;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
@@ -6364,6 +6369,7 @@ yyacceptlab:
yyresult = 0;
goto yyreturn;
+
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
@@ -6371,6 +6377,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
+
#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
@@ -6381,6 +6388,10 @@ yyexhaustedlab:
/* Fall through. */
#endif
+
+/*-----------------------------------------------------.
+| yyreturn -- parsing is finished, return the result. |
+`-----------------------------------------------------*/
yyreturn:
if (yychar != YYEMPTY)
{
@@ -6410,7 +6421,7 @@ yyreturn:
#endif
return yyresult;
}
-#line 3207 "cmDependsJavaParser.y" /* yacc.c:1906 */
+#line 3210 "cmDependsJavaParser.y" /* yacc.c:1918 */
/* End of grammar */
diff --git a/Source/LexerParser/cmDependsJavaParser.y b/Source/LexerParser/cmDependsJavaParser.y
index f7eb22818..d15cffc56 100644
--- a/Source/LexerParser/cmDependsJavaParser.y
+++ b/Source/LexerParser/cmDependsJavaParser.y
@@ -36,7 +36,7 @@ static void cmDependsJava_yyerror(yyscan_t yyscanner, const char* message);
#define YYMAXDEPTH 1000000
-#define jpCheckEmpty(cnt) yyGetParser->CheckEmpty(__LINE__, cnt, yyvsp);
+#define jpCheckEmpty(cnt) yyGetParser->CheckEmpty(__LINE__, cnt, yyvsp)
#define jpElementStart(cnt) yyGetParser->PrepareElement(&yyval)
#define jpStoreClass(str) yyGetParser->AddClassFound(str); yyGetParser->DeallocateParserType(&(str))
/* Disable some warnings in the generated code. */
@@ -44,6 +44,9 @@ static void cmDependsJava_yyerror(yyscan_t yyscanner, const char* message);
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but no case. */
#endif
+#if defined(__GNUC__) && __GNUC__ >= 8
+# pragma GCC diagnostic ignored "-Wconversion"
+#endif
%}
/* Generate a reentrant parser object. */
diff --git a/Source/LexerParser/cmDependsJavaParserTokens.h b/Source/LexerParser/cmDependsJavaParserTokens.h
index 7f18f1dd8..6bbc0848d 100644
--- a/Source/LexerParser/cmDependsJavaParserTokens.h
+++ b/Source/LexerParser/cmDependsJavaParserTokens.h
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
+/* A Bison parser, made by GNU Bison 3.3.2. */
/* Bison interface for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
+ Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,6 +31,9 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
+/* Undocumented macros, especially those whose name start with YY_,
+ are private implementation details. Do not rely on them. */
+
#ifndef YY_CMDEPENDSJAVA_YY_CMDEPENDSJAVAPARSERTOKENS_H_INCLUDED
# define YY_CMDEPENDSJAVA_YY_CMDEPENDSJAVAPARSERTOKENS_H_INCLUDED
/* Debug traces. */
diff --git a/Source/LexerParser/cmExprLexer.cxx b/Source/LexerParser/cmExprLexer.cxx
index fb6f0db98..72e59b689 100644
--- a/Source/LexerParser/cmExprLexer.cxx
+++ b/Source/LexerParser/cmExprLexer.cxx
@@ -1,7 +1,4 @@
#include "cmStandardLexer.h"
-#line 2 "cmExprLexer.cxx"
-
-#line 4 "cmExprLexer.cxx"
#define FLEXINT_H 1
#define YY_INT_ALIGNED short int
@@ -11,11 +8,221 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
+#define YY_FLEX_SUBMINOR_VERSION 4
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
+#ifdef yy_create_buffer
+#define cmExpr_yy_create_buffer_ALREADY_DEFINED
+#else
+#define yy_create_buffer cmExpr_yy_create_buffer
+#endif
+
+#ifdef yy_delete_buffer
+#define cmExpr_yy_delete_buffer_ALREADY_DEFINED
+#else
+#define yy_delete_buffer cmExpr_yy_delete_buffer
+#endif
+
+#ifdef yy_scan_buffer
+#define cmExpr_yy_scan_buffer_ALREADY_DEFINED
+#else
+#define yy_scan_buffer cmExpr_yy_scan_buffer
+#endif
+
+#ifdef yy_scan_string
+#define cmExpr_yy_scan_string_ALREADY_DEFINED
+#else
+#define yy_scan_string cmExpr_yy_scan_string
+#endif
+
+#ifdef yy_scan_bytes
+#define cmExpr_yy_scan_bytes_ALREADY_DEFINED
+#else
+#define yy_scan_bytes cmExpr_yy_scan_bytes
+#endif
+
+#ifdef yy_init_buffer
+#define cmExpr_yy_init_buffer_ALREADY_DEFINED
+#else
+#define yy_init_buffer cmExpr_yy_init_buffer
+#endif
+
+#ifdef yy_flush_buffer
+#define cmExpr_yy_flush_buffer_ALREADY_DEFINED
+#else
+#define yy_flush_buffer cmExpr_yy_flush_buffer
+#endif
+
+#ifdef yy_load_buffer_state
+#define cmExpr_yy_load_buffer_state_ALREADY_DEFINED
+#else
+#define yy_load_buffer_state cmExpr_yy_load_buffer_state
+#endif
+
+#ifdef yy_switch_to_buffer
+#define cmExpr_yy_switch_to_buffer_ALREADY_DEFINED
+#else
+#define yy_switch_to_buffer cmExpr_yy_switch_to_buffer
+#endif
+
+#ifdef yypush_buffer_state
+#define cmExpr_yypush_buffer_state_ALREADY_DEFINED
+#else
+#define yypush_buffer_state cmExpr_yypush_buffer_state
+#endif
+
+#ifdef yypop_buffer_state
+#define cmExpr_yypop_buffer_state_ALREADY_DEFINED
+#else
+#define yypop_buffer_state cmExpr_yypop_buffer_state
+#endif
+
+#ifdef yyensure_buffer_stack
+#define cmExpr_yyensure_buffer_stack_ALREADY_DEFINED
+#else
+#define yyensure_buffer_stack cmExpr_yyensure_buffer_stack
+#endif
+
+#ifdef yylex
+#define cmExpr_yylex_ALREADY_DEFINED
+#else
+#define yylex cmExpr_yylex
+#endif
+
+#ifdef yyrestart
+#define cmExpr_yyrestart_ALREADY_DEFINED
+#else
+#define yyrestart cmExpr_yyrestart
+#endif
+
+#ifdef yylex_init
+#define cmExpr_yylex_init_ALREADY_DEFINED
+#else
+#define yylex_init cmExpr_yylex_init
+#endif
+
+#ifdef yylex_init_extra
+#define cmExpr_yylex_init_extra_ALREADY_DEFINED
+#else
+#define yylex_init_extra cmExpr_yylex_init_extra
+#endif
+
+#ifdef yylex_destroy
+#define cmExpr_yylex_destroy_ALREADY_DEFINED
+#else
+#define yylex_destroy cmExpr_yylex_destroy
+#endif
+
+#ifdef yyget_debug
+#define cmExpr_yyget_debug_ALREADY_DEFINED
+#else
+#define yyget_debug cmExpr_yyget_debug
+#endif
+
+#ifdef yyset_debug
+#define cmExpr_yyset_debug_ALREADY_DEFINED
+#else
+#define yyset_debug cmExpr_yyset_debug
+#endif
+
+#ifdef yyget_extra
+#define cmExpr_yyget_extra_ALREADY_DEFINED
+#else
+#define yyget_extra cmExpr_yyget_extra
+#endif
+
+#ifdef yyset_extra
+#define cmExpr_yyset_extra_ALREADY_DEFINED
+#else
+#define yyset_extra cmExpr_yyset_extra
+#endif
+
+#ifdef yyget_in
+#define cmExpr_yyget_in_ALREADY_DEFINED
+#else
+#define yyget_in cmExpr_yyget_in
+#endif
+
+#ifdef yyset_in
+#define cmExpr_yyset_in_ALREADY_DEFINED
+#else
+#define yyset_in cmExpr_yyset_in
+#endif
+
+#ifdef yyget_out
+#define cmExpr_yyget_out_ALREADY_DEFINED
+#else
+#define yyget_out cmExpr_yyget_out
+#endif
+
+#ifdef yyset_out
+#define cmExpr_yyset_out_ALREADY_DEFINED
+#else
+#define yyset_out cmExpr_yyset_out
+#endif
+
+#ifdef yyget_leng
+#define cmExpr_yyget_leng_ALREADY_DEFINED
+#else
+#define yyget_leng cmExpr_yyget_leng
+#endif
+
+#ifdef yyget_text
+#define cmExpr_yyget_text_ALREADY_DEFINED
+#else
+#define yyget_text cmExpr_yyget_text
+#endif
+
+#ifdef yyget_lineno
+#define cmExpr_yyget_lineno_ALREADY_DEFINED
+#else
+#define yyget_lineno cmExpr_yyget_lineno
+#endif
+
+#ifdef yyset_lineno
+#define cmExpr_yyset_lineno_ALREADY_DEFINED
+#else
+#define yyset_lineno cmExpr_yyset_lineno
+#endif
+
+#ifdef yyget_column
+#define cmExpr_yyget_column_ALREADY_DEFINED
+#else
+#define yyget_column cmExpr_yyget_column
+#endif
+
+#ifdef yyset_column
+#define cmExpr_yyset_column_ALREADY_DEFINED
+#else
+#define yyset_column cmExpr_yyset_column
+#endif
+
+#ifdef yywrap
+#define cmExpr_yywrap_ALREADY_DEFINED
+#else
+#define yywrap cmExpr_yywrap
+#endif
+
+#ifdef yyalloc
+#define cmExpr_yyalloc_ALREADY_DEFINED
+#else
+#define yyalloc cmExpr_yyalloc
+#endif
+
+#ifdef yyrealloc
+#define cmExpr_yyrealloc_ALREADY_DEFINED
+#else
+#define yyrealloc cmExpr_yyrealloc
+#endif
+
+#ifdef yyfree
+#define cmExpr_yyfree_ALREADY_DEFINED
+#else
+#define yyfree cmExpr_yyfree
+#endif
+
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
@@ -86,10 +293,16 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
+#ifndef SIZE_MAX
+#define SIZE_MAX (~(size_t)0)
+#endif
+
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */
+
/* TODO: this is always defined, so inline it */
#define yyconst const
@@ -102,12 +315,10 @@ typedef unsigned int flex_uint32_t;
/* Returned upon end-of-file. */
#define YY_NULL 0
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
+/* Promotes a possibly negative, possibly signed char to an
+ * integer in range [0..255] for use as an array index.
*/
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
@@ -131,20 +342,16 @@ typedef void* yyscan_t;
* definition of BEGIN.
*/
#define BEGIN yyg->yy_start = 1 + 2 *
-
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START ((yyg->yy_start - 1) / 2)
#define YYSTATE YY_START
-
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE cmExpr_yyrestart(yyin ,yyscanner )
-
+#define YY_NEW_FILE yyrestart( yyin , yyscanner )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
@@ -194,7 +401,6 @@ typedef size_t yy_size_t;
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
-
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
#ifndef YY_STRUCT_YY_BUFFER_STATE
@@ -254,7 +460,7 @@ struct yy_buffer_state
* possible backing-up.
*
* When we actually see the EOF, we change the status to "new"
- * (via cmExpr_yyrestart()), so that the user can continue scanning by
+ * (via yyrestart()), so that the user can continue scanning by
* just pointing yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
@@ -271,73 +477,67 @@ struct yy_buffer_state
#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
: NULL)
-
/* Same as previous macro, but useful when we know that the buffer stack is not
* NULL or when we need an lvalue. For internal use only.
*/
#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
-void cmExpr_yyrestart (FILE *input_file ,yyscan_t yyscanner );
-void cmExpr_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmExpr_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
-void cmExpr_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmExpr_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-void cmExpr_yypop_buffer_state (yyscan_t yyscanner );
-
-static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner );
-static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner );
-static void cmExpr_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
-
-#define YY_FLUSH_BUFFER cmExpr_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+void yypop_buffer_state ( yyscan_t yyscanner );
-YY_BUFFER_STATE cmExpr_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmExpr_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+static void yyensure_buffer_stack ( yyscan_t yyscanner );
+static void yy_load_buffer_state ( yyscan_t yyscanner );
+static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
+#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)
-void *cmExpr_yyalloc (yy_size_t ,yyscan_t yyscanner );
-void *cmExpr_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
-void cmExpr_yyfree (void * ,yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
-#define yy_new_buffer cmExpr_yy_create_buffer
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
+void yyfree ( void * , yyscan_t yyscanner );
+#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
{ \
if ( ! YY_CURRENT_BUFFER ){ \
- cmExpr_yyensure_buffer_stack (yyscanner); \
+ yyensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
- cmExpr_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
-
#define yy_set_bol(at_bol) \
{ \
if ( ! YY_CURRENT_BUFFER ){\
- cmExpr_yyensure_buffer_stack (yyscanner); \
+ yyensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
- cmExpr_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
-
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
/* Begin user sect3 */
#define cmExpr_yywrap(yyscanner) (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
-
-typedef unsigned char YY_CHAR;
+typedef flex_uint8_t YY_CHAR;
typedef int yy_state_type;
#define yytext_ptr yytext_r
-static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
-static int yy_get_next_buffer (yyscan_t yyscanner );
-static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner );
+static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
+static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner);
+static int yy_get_next_buffer ( yyscan_t yyscanner );
+static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
@@ -348,9 +548,8 @@ static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner );
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
-
-#define YY_NUM_RULES 15
-#define YY_END_OF_BUFFER 16
+#define YY_NUM_RULES 18
+#define YY_END_OF_BUFFER 19
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -358,29 +557,29 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[23] =
+static const flex_int16_t yy_accept[29] =
{ 0,
- 0, 0, 16, 15, 6, 8, 13, 14, 4, 2,
- 3, 5, 1, 15, 15, 9, 7, 10, 1, 11,
- 12, 0
+ 0, 0, 19, 17, 1, 18, 8, 10, 15, 16,
+ 6, 4, 5, 7, 2, 2, 17, 17, 11, 9,
+ 12, 2, 0, 13, 14, 3, 3, 0
} ;
-static yyconst YY_CHAR yy_ec[256] =
+static const YY_CHAR yy_ec[256] =
{ 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 1, 1, 1, 1, 4, 5, 1, 6,
+ 7, 8, 9, 1, 10, 1, 11, 12, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 1, 1, 14,
+ 1, 15, 1, 1, 16, 16, 16, 16, 16, 16,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 2, 3, 1, 4,
- 5, 6, 7, 1, 8, 1, 9, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 1, 1, 11,
- 1, 12, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 13, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 17, 1, 1,
+ 1, 1, 1, 18, 1, 1, 16, 16, 16, 16,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 14, 1, 15, 1, 1, 1, 1,
+ 16, 16, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 17,
+ 1, 1, 1, 19, 1, 20, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -397,40 +596,46 @@ static yyconst YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
-static yyconst YY_CHAR yy_meta[16] =
+static const YY_CHAR yy_meta[21] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
+ 1, 2, 2, 1, 1, 3, 4, 1, 1, 1
} ;
-static yyconst flex_uint16_t yy_base[23] =
+static const flex_int16_t yy_base[32] =
{ 0,
- 0, 0, 20, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 9, 7, 5, 21, 21, 21, 6, 21,
- 21, 21
+ 0, 0, 34, 35, 35, 35, 35, 35, 35, 35,
+ 35, 35, 35, 35, 16, 9, 18, 11, 35, 35,
+ 35, 11, 0, 35, 35, 0, 0, 35, 23, 26,
+ 28
} ;
-static yyconst flex_int16_t yy_def[23] =
+static const flex_int16_t yy_def[32] =
{ 0,
- 22, 1, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 0
+ 28, 1, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 29, 28, 28, 28, 28, 28,
+ 28, 28, 30, 28, 28, 31, 31, 0, 28, 28,
+ 28
} ;
-static yyconst flex_uint16_t yy_nxt[37] =
+static const flex_int16_t yy_nxt[56] =
{ 0,
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, 21, 20, 19, 22,
- 3, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22
+ 14, 15, 16, 17, 18, 4, 4, 19, 20, 21,
+ 22, 22, 22, 22, 22, 25, 22, 26, 26, 27,
+ 27, 24, 23, 28, 3, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28
} ;
-static yyconst flex_int16_t yy_chk[37] =
+static const flex_int16_t yy_chk[56] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 19, 15, 14, 13, 3,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 16, 16, 22, 22, 29, 18, 29, 30, 30, 31,
+ 31, 17, 15, 3, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28
} ;
/* The intent behind this definition is that it'll catch
@@ -440,8 +645,6 @@ static yyconst flex_int16_t yy_chk[37] =
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
-#line 1 "cmExprLexer.in.l"
-#line 2 "cmExprLexer.in.l"
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
/*
@@ -450,30 +653,32 @@ This file must be translated to C++ and modified to build everywhere.
Run flex >= 2.6 like this:
- flex --nounistd -DFLEXINT_H --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l
+ flex --nounistd -DFLEXINT_H --noline --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l
Modify cmExprLexer.cxx:
- - remove trailing whitespace: sed -i 's/\s*$//' cmExprLexer.h cmExprLexer.cxx
- - remove blank lines at end of file
- - #include "cmStandardLexer.h" at the top
- - add cast in cmExpr_yy_scan_bytes for loop condition of _yybytes_len to size_t
+ - remove trailing whitespace: sed -i 's/\s*$//' cmExprLexer.h cmExprLexer.cxx
+ - remove blank lines at end of file: sed -i '${/^$/d;}' cmExprLexer.h cmExprLexer.cxx
+ - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmExprLexer.cxx
*/
/* IWYU pragma: no_forward_declare yyguts_t */
+#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+
#include "cmExprParserHelper.h"
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
- { result = yyextra->LexInput(buf, max_size); }
+ do { result = yyextra->LexInput(buf, max_size); } while (0)
/* Include the set of tokens from the parser. */
#include "cmExprParserTokens.h"
+#include <string>
+
/*--------------------------------------------------------------------------*/
-#line 476 "cmExprLexer.cxx"
#define INITIAL 0
@@ -515,44 +720,44 @@ struct yyguts_t
}; /* end struct yyguts_t */
-static int yy_init_globals (yyscan_t yyscanner );
+static int yy_init_globals ( yyscan_t yyscanner );
-int cmExpr_yylex_init (yyscan_t* scanner);
+int yylex_init (yyscan_t* scanner);
-int cmExpr_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
-int cmExpr_yylex_destroy (yyscan_t yyscanner );
+int yylex_destroy ( yyscan_t yyscanner );
-int cmExpr_yyget_debug (yyscan_t yyscanner );
+int yyget_debug ( yyscan_t yyscanner );
-void cmExpr_yyset_debug (int debug_flag ,yyscan_t yyscanner );
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
-YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner );
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
-void cmExpr_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
-FILE *cmExpr_yyget_in (yyscan_t yyscanner );
+FILE *yyget_in ( yyscan_t yyscanner );
-void cmExpr_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
+void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
-FILE *cmExpr_yyget_out (yyscan_t yyscanner );
+FILE *yyget_out ( yyscan_t yyscanner );
-void cmExpr_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
+void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
- int cmExpr_yyget_leng (yyscan_t yyscanner );
+ int yyget_leng ( yyscan_t yyscanner );
-char *cmExpr_yyget_text (yyscan_t yyscanner );
+char *yyget_text ( yyscan_t yyscanner );
-int cmExpr_yyget_lineno (yyscan_t yyscanner );
+int yyget_lineno ( yyscan_t yyscanner );
-void cmExpr_yyset_lineno (int _line_number ,yyscan_t yyscanner );
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
-int cmExpr_yyget_column (yyscan_t yyscanner );
+int yyget_column ( yyscan_t yyscanner );
-void cmExpr_yyset_column (int _column_no ,yyscan_t yyscanner );
+void yyset_column ( int _column_no , yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -560,32 +765,31 @@ void cmExpr_yyset_column (int _column_no ,yyscan_t yyscanner );
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int cmExpr_yywrap (yyscan_t yyscanner );
+extern "C" int yywrap ( yyscan_t yyscanner );
#else
-extern int cmExpr_yywrap (yyscan_t yyscanner );
+extern int yywrap ( yyscan_t yyscanner );
#endif
#endif
#ifndef YY_NO_UNPUT
- static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner);
+ static void yyunput ( int c, char *buf_ptr , yyscan_t yyscanner);
#endif
#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
-
#ifdef __cplusplus
-static int yyinput (yyscan_t yyscanner );
+static int yyinput ( yyscan_t yyscanner );
#else
-static int input (yyscan_t yyscanner );
+static int input ( yyscan_t yyscanner );
#endif
#endif
@@ -616,7 +820,7 @@ static int input (yyscan_t yyscanner );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
- size_t n; \
+ int n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@@ -629,7 +833,7 @@ static int input (yyscan_t yyscanner );
else \
{ \
errno=0; \
- while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
@@ -670,9 +874,9 @@ static int input (yyscan_t yyscanner );
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-extern int cmExpr_yylex (yyscan_t yyscanner);
+extern int yylex (yyscan_t yyscanner);
-#define YY_DECL int cmExpr_yylex (yyscan_t yyscanner)
+#define YY_DECL int yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */
/* Code executed at the beginning of each rule, after yytext and yyleng
@@ -717,19 +921,15 @@ YY_DECL
yyout = stdout;
if ( ! YY_CURRENT_BUFFER ) {
- cmExpr_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
- cmExpr_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
}
- cmExpr_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
}
{
-#line 39 "cmExprLexer.in.l"
-
-
-#line 732 "cmExprLexer.cxx"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
@@ -756,13 +956,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 23 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ if ( yy_current_state >= 29 )
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
- while ( yy_base[yy_current_state] != 21 );
+ while ( yy_base[yy_current_state] != 35 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -788,80 +988,76 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
-#line 41 "cmExprLexer.in.l"
-{ yylvalp->Number = atoi(yytext); return exp_NUMBER; }
+{}
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 43 "cmExprLexer.in.l"
-{ return exp_PLUS; }
+{ yylvalp->Number = std::stoll(yytext, nullptr, 10); return exp_NUMBER; }
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 44 "cmExprLexer.in.l"
-{ return exp_MINUS; }
+{ yylvalp->Number = std::stoll(yytext, nullptr, 16); return exp_NUMBER; }
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 45 "cmExprLexer.in.l"
-{ return exp_TIMES; }
+{ return exp_PLUS; }
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 46 "cmExprLexer.in.l"
-{ return exp_DIVIDE; }
+{ return exp_MINUS; }
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 47 "cmExprLexer.in.l"
-{ return exp_MOD; }
+{ return exp_TIMES; }
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 48 "cmExprLexer.in.l"
-{ return exp_OR; }
+{ return exp_DIVIDE; }
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 49 "cmExprLexer.in.l"
-{ return exp_AND; }
+{ return exp_MOD; }
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 50 "cmExprLexer.in.l"
-{ return exp_XOR; }
+{ return exp_OR; }
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 51 "cmExprLexer.in.l"
-{ return exp_NOT; }
+{ return exp_AND; }
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 52 "cmExprLexer.in.l"
-{ return exp_SHIFTLEFT; }
+{ return exp_XOR; }
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 53 "cmExprLexer.in.l"
-{ return exp_SHIFTRIGHT; }
+{ return exp_NOT; }
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 54 "cmExprLexer.in.l"
-{ return exp_OPENPARENT; }
+{ return exp_SHIFTLEFT; }
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 55 "cmExprLexer.in.l"
-{ return exp_CLOSEPARENT; }
+{ return exp_SHIFTRIGHT; }
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 57 "cmExprLexer.in.l"
+{ return exp_OPENPARENT; }
+ YY_BREAK
+case 16:
+YY_RULE_SETUP
+{ return exp_CLOSEPARENT; }
+ YY_BREAK
+case 17:
+YY_RULE_SETUP
+{ yyextra->UnexpectedChar(yytext[0]); }
+ YY_BREAK
+case 18:
+YY_RULE_SETUP
ECHO;
YY_BREAK
-#line 864 "cmExprLexer.cxx"
case YY_STATE_EOF(INITIAL):
yyterminate();
@@ -879,7 +1075,7 @@ case YY_STATE_EOF(INITIAL):
/* We're scanning a new file or input source. It's
* possible that this happened because the user
* just pointed yyin at a new source and called
- * cmExpr_yylex(). If so, then we have to assure
+ * yylex(). If so, then we have to assure
* consistency between YY_CURRENT_BUFFER and our
* globals. Here is the right place to do so, because
* this is the first action (other than possibly a
@@ -939,7 +1135,7 @@ case YY_STATE_EOF(INITIAL):
{
yyg->yy_did_buffer_switch_on_eof = 0;
- if ( cmExpr_yywrap(yyscanner ) )
+ if ( yywrap( yyscanner ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
@@ -993,7 +1189,7 @@ case YY_STATE_EOF(INITIAL):
} /* end of action switch */
} /* end of scanning one token */
} /* end of user's declarations */
-} /* end of cmExpr_yylex */
+} /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer
*
@@ -1007,7 +1203,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = yyg->yytext_ptr;
- yy_size_t number_to_move, i;
+ int number_to_move, i;
int ret_val;
if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
@@ -1036,7 +1232,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
/* Try to read more data. */
/* First move last chars to start of buffer. */
- number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
+ number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@@ -1072,7 +1268,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
- cmExpr_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
+ yyrealloc( (void *) b->yy_ch_buf,
+ (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
}
else
/* Can't grow it, we don't own it. */
@@ -1104,7 +1301,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
- cmExpr_yyrestart(yyin ,yyscanner);
+ yyrestart( yyin , yyscanner);
}
else
@@ -1118,12 +1315,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
ret_val = EOB_ACT_CONTINUE_SCAN;
- if ((int) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cmExpr_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
+ (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ /* "- 2" to take care of EOB's */
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
}
yyg->yy_n_chars += number_to_move;
@@ -1156,10 +1356,10 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 23 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ if ( yy_current_state >= 29 )
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
}
return yy_current_state;
@@ -1185,11 +1385,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 23 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ if ( yy_current_state >= 29 )
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
- yy_is_jam = (yy_current_state == 22);
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
+ yy_is_jam = (yy_current_state == 28);
(void)yyg;
return yy_is_jam ? 0 : yy_current_state;
@@ -1262,7 +1462,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
{ /* need more input */
- int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+ int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
++yyg->yy_c_buf_p;
switch ( yy_get_next_buffer( yyscanner ) )
@@ -1279,13 +1479,13 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
*/
/* Reset buffer status. */
- cmExpr_yyrestart(yyin ,yyscanner);
+ yyrestart( yyin , yyscanner);
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
- if ( cmExpr_yywrap(yyscanner ) )
+ if ( yywrap( yyscanner ) )
return 0;
if ( ! yyg->yy_did_buffer_switch_on_eof )
@@ -1317,34 +1517,34 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @note This function does not reset the start condition to @c INITIAL .
*/
- void cmExpr_yyrestart (FILE * input_file , yyscan_t yyscanner)
+ void yyrestart (FILE * input_file , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! YY_CURRENT_BUFFER ){
- cmExpr_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
- cmExpr_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
}
- cmExpr_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
- cmExpr_yy_load_buffer_state(yyscanner );
+ yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
+ yy_load_buffer_state( yyscanner );
}
/** Switch to a different input buffer.
* @param new_buffer The new input buffer.
* @param yyscanner The scanner object.
*/
- void cmExpr_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* TODO. We should be able to replace this entire function body
* with
- * cmExpr_yypop_buffer_state();
- * cmExpr_yypush_buffer_state(new_buffer);
+ * yypop_buffer_state();
+ * yypush_buffer_state(new_buffer);
*/
- cmExpr_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
if ( YY_CURRENT_BUFFER == new_buffer )
return;
@@ -1357,17 +1557,17 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- cmExpr_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
/* We don't actually know whether we did this switch during
- * EOF (cmExpr_yywrap()) processing, but the only time this flag
- * is looked at is after cmExpr_yywrap() is called, so it's safe
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
* to go ahead and always set it.
*/
yyg->yy_did_buffer_switch_on_eof = 1;
}
-static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner)
+static void yy_load_buffer_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
@@ -1382,35 +1582,35 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the allocated buffer state.
*/
- YY_BUFFER_STATE cmExpr_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
+ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
- b = (YY_BUFFER_STATE) cmExpr_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_create_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
- b->yy_buf_size = (yy_size_t)size;
+ b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
- b->yy_ch_buf = (char *) cmExpr_yyalloc(b->yy_buf_size + 2 ,yyscanner );
+ b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_create_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
- cmExpr_yy_init_buffer(b,file ,yyscanner);
+ yy_init_buffer( b, file , yyscanner);
return b;
}
/** Destroy the buffer.
- * @param b a buffer created with cmExpr_yy_create_buffer()
+ * @param b a buffer created with yy_create_buffer()
* @param yyscanner The scanner object.
*/
- void cmExpr_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+ void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -1421,28 +1621,28 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner)
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
- cmExpr_yyfree((void *) b->yy_ch_buf ,yyscanner );
+ yyfree( (void *) b->yy_ch_buf , yyscanner );
- cmExpr_yyfree((void *) b ,yyscanner );
+ yyfree( (void *) b , yyscanner );
}
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
- * such as during a cmExpr_yyrestart() or at EOF.
+ * such as during a yyrestart() or at EOF.
*/
- static void cmExpr_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
+ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
{
int oerrno = errno;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- cmExpr_yy_flush_buffer(b ,yyscanner);
+ yy_flush_buffer( b , yyscanner);
b->yy_input_file = file;
b->yy_fill_buffer = 1;
- /* If b is the current buffer, then cmExpr_yy_init_buffer was _probably_
- * called from cmExpr_yyrestart() or through yy_get_next_buffer.
+ /* If b is the current buffer, then yy_init_buffer was _probably_
+ * called from yyrestart() or through yy_get_next_buffer.
* In that case, we don't want to reset the lineno or column.
*/
if (b != YY_CURRENT_BUFFER){
@@ -1459,7 +1659,7 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner)
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
* @param yyscanner The scanner object.
*/
- void cmExpr_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+ void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! b )
@@ -1480,7 +1680,7 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner)
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
- cmExpr_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
}
/** Pushes the new state onto the stack. The new state becomes
@@ -1489,15 +1689,15 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner)
* @param new_buffer The new state.
* @param yyscanner The scanner object.
*/
-void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (new_buffer == NULL)
return;
- cmExpr_yyensure_buffer_stack(yyscanner);
+ yyensure_buffer_stack(yyscanner);
- /* This block is copied from cmExpr_yy_switch_to_buffer. */
+ /* This block is copied from yy_switch_to_buffer. */
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
@@ -1511,8 +1711,8 @@ void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner
yyg->yy_buffer_stack_top++;
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- /* copied from cmExpr_yy_switch_to_buffer. */
- cmExpr_yy_load_buffer_state(yyscanner );
+ /* copied from yy_switch_to_buffer. */
+ yy_load_buffer_state( yyscanner );
yyg->yy_did_buffer_switch_on_eof = 1;
}
@@ -1520,19 +1720,19 @@ void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner
* The next element becomes the new top.
* @param yyscanner The scanner object.
*/
-void cmExpr_yypop_buffer_state (yyscan_t yyscanner)
+void yypop_buffer_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!YY_CURRENT_BUFFER)
return;
- cmExpr_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
+ yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
YY_CURRENT_BUFFER_LVALUE = NULL;
if (yyg->yy_buffer_stack_top > 0)
--yyg->yy_buffer_stack_top;
if (YY_CURRENT_BUFFER) {
- cmExpr_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
yyg->yy_did_buffer_switch_on_eof = 1;
}
}
@@ -1540,9 +1740,9 @@ void cmExpr_yypop_buffer_state (yyscan_t yyscanner)
/* Allocates the stack if it does not exist.
* Guarantees space for at least one push.
*/
-static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner)
+static void yyensure_buffer_stack (yyscan_t yyscanner)
{
- int num_to_alloc;
+ yy_size_t num_to_alloc;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!yyg->yy_buffer_stack) {
@@ -1552,11 +1752,11 @@ static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner)
* immediate realloc on the next call.
*/
num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
- yyg->yy_buffer_stack = (struct yy_buffer_state**)cmExpr_yyalloc
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
- YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yyensure_buffer_stack()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
@@ -1571,12 +1771,12 @@ static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner)
yy_size_t grow_size = 8 /* arbitrary grow size */;
num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
- yyg->yy_buffer_stack = (struct yy_buffer_state**)cmExpr_yyrealloc
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
(yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
- YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yyensure_buffer_stack()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -1590,7 +1790,7 @@ static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE cmExpr_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
@@ -1600,11 +1800,11 @@ YY_BUFFER_STATE cmExpr_yy_scan_buffer (char * base, yy_size_t size , yyscan_t
/* They forgot to leave room for the EOB's. */
return NULL;
- b = (YY_BUFFER_STATE) cmExpr_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_scan_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = NULL;
@@ -1614,53 +1814,53 @@ YY_BUFFER_STATE cmExpr_yy_scan_buffer (char * base, yy_size_t size , yyscan_t
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
- cmExpr_yy_switch_to_buffer(b ,yyscanner );
+ yy_switch_to_buffer( b , yyscanner );
return b;
}
-/** Setup the input buffer state to scan a string. The next call to cmExpr_yylex() will
+/** Setup the input buffer state to scan a string. The next call to yylex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
- * cmExpr_yy_scan_bytes() instead.
+ * yy_scan_bytes() instead.
*/
-YY_BUFFER_STATE cmExpr_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
{
- return cmExpr_yy_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner);
+ return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
}
-/** Setup the input buffer state to scan the given bytes. The next call to cmExpr_yylex() will
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
- yy_size_t i;
+ int i;
/* Get memory for full buffer, including space for trailing EOB's. */
- n = (yy_size_t) _yybytes_len + 2;
- buf = (char *) cmExpr_yyalloc(n ,yyscanner );
+ n = (yy_size_t) (_yybytes_len + 2);
+ buf = (char *) yyalloc( n , yyscanner );
if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_scan_bytes()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
- for ( i = 0; i < (size_t)_yybytes_len; ++i )
+ for ( i = 0; i < _yybytes_len; ++i )
buf[i] = yybytes[i];
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
- b = cmExpr_yy_scan_buffer(buf,n ,yyscanner);
+ b = yy_scan_buffer( buf, n , yyscanner);
if ( ! b )
- YY_FATAL_ERROR( "bad buffer in cmExpr_yy_scan_bytes()" );
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
/* It's okay to grow etc. this buffer, and we should throw it
* away when we're done.
@@ -1674,11 +1874,11 @@ YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len
#define YY_EXIT_FAILURE 2
#endif
-static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
+static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
- (void) fprintf( stderr, "%s\n", msg );
+ fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
@@ -1704,7 +1904,7 @@ static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
/** Get the user-defined data for this scanner.
* @param yyscanner The scanner object.
*/
-YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner)
+YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyextra;
@@ -1713,7 +1913,7 @@ YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner)
/** Get the current line number.
* @param yyscanner The scanner object.
*/
-int cmExpr_yyget_lineno (yyscan_t yyscanner)
+int yyget_lineno (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -1726,7 +1926,7 @@ int cmExpr_yyget_lineno (yyscan_t yyscanner)
/** Get the current column number.
* @param yyscanner The scanner object.
*/
-int cmExpr_yyget_column (yyscan_t yyscanner)
+int yyget_column (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -1739,7 +1939,7 @@ int cmExpr_yyget_column (yyscan_t yyscanner)
/** Get the input stream.
* @param yyscanner The scanner object.
*/
-FILE *cmExpr_yyget_in (yyscan_t yyscanner)
+FILE *yyget_in (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyin;
@@ -1748,7 +1948,7 @@ FILE *cmExpr_yyget_in (yyscan_t yyscanner)
/** Get the output stream.
* @param yyscanner The scanner object.
*/
-FILE *cmExpr_yyget_out (yyscan_t yyscanner)
+FILE *yyget_out (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyout;
@@ -1757,7 +1957,7 @@ FILE *cmExpr_yyget_out (yyscan_t yyscanner)
/** Get the length of the current token.
* @param yyscanner The scanner object.
*/
-int cmExpr_yyget_leng (yyscan_t yyscanner)
+int yyget_leng (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyleng;
@@ -1767,7 +1967,7 @@ int cmExpr_yyget_leng (yyscan_t yyscanner)
* @param yyscanner The scanner object.
*/
-char *cmExpr_yyget_text (yyscan_t yyscanner)
+char *yyget_text (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yytext;
@@ -1777,7 +1977,7 @@ char *cmExpr_yyget_text (yyscan_t yyscanner)
* @param user_defined The data to be associated with this scanner.
* @param yyscanner The scanner object.
*/
-void cmExpr_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
+void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyextra = user_defined ;
@@ -1787,13 +1987,13 @@ void cmExpr_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
* @param _line_number line number
* @param yyscanner The scanner object.
*/
-void cmExpr_yyset_lineno (int _line_number , yyscan_t yyscanner)
+void yyset_lineno (int _line_number , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* lineno is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "cmExpr_yyset_lineno called with no buffer" );
+ YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
yylineno = _line_number;
}
@@ -1802,13 +2002,13 @@ void cmExpr_yyset_lineno (int _line_number , yyscan_t yyscanner)
* @param _column_no column number
* @param yyscanner The scanner object.
*/
-void cmExpr_yyset_column (int _column_no , yyscan_t yyscanner)
+void yyset_column (int _column_no , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* column is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "cmExpr_yyset_column called with no buffer" );
+ YY_FATAL_ERROR( "yyset_column called with no buffer" );
yycolumn = _column_no;
}
@@ -1817,27 +2017,27 @@ void cmExpr_yyset_column (int _column_no , yyscan_t yyscanner)
* input buffer.
* @param _in_str A readable stream.
* @param yyscanner The scanner object.
- * @see cmExpr_yy_switch_to_buffer
+ * @see yy_switch_to_buffer
*/
-void cmExpr_yyset_in (FILE * _in_str , yyscan_t yyscanner)
+void yyset_in (FILE * _in_str , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyin = _in_str ;
}
-void cmExpr_yyset_out (FILE * _out_str , yyscan_t yyscanner)
+void yyset_out (FILE * _out_str , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyout = _out_str ;
}
-int cmExpr_yyget_debug (yyscan_t yyscanner)
+int yyget_debug (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yy_flex_debug;
}
-void cmExpr_yyset_debug (int _bdebug , yyscan_t yyscanner)
+void yyset_debug (int _bdebug , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yy_flex_debug = _bdebug ;
@@ -1847,20 +2047,18 @@ void cmExpr_yyset_debug (int _bdebug , yyscan_t yyscanner)
/* User-visible API */
-/* cmExpr_yylex_init is special because it creates the scanner itself, so it is
+/* yylex_init is special because it creates the scanner itself, so it is
* the ONLY reentrant function that doesn't take the scanner as the last argument.
* That's why we explicitly handle the declaration, instead of using our macros.
*/
-
-int cmExpr_yylex_init(yyscan_t* ptr_yy_globals)
-
+int yylex_init(yyscan_t* ptr_yy_globals)
{
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
- *ptr_yy_globals = (yyscan_t) cmExpr_yyalloc ( sizeof( struct yyguts_t ), NULL );
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
@@ -1873,27 +2071,25 @@ int cmExpr_yylex_init(yyscan_t* ptr_yy_globals)
return yy_init_globals ( *ptr_yy_globals );
}
-/* cmExpr_yylex_init_extra has the same functionality as cmExpr_yylex_init, but follows the
+/* yylex_init_extra has the same functionality as yylex_init, but follows the
* convention of taking the scanner as the last argument. Note however, that
* this is a *pointer* to a scanner, as it will be allocated by this call (and
* is the reason, too, why this function also must handle its own declaration).
- * The user defined value in the first argument will be available to cmExpr_yyalloc in
+ * The user defined value in the first argument will be available to yyalloc in
* the yyextra field.
*/
-
-int cmExpr_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
-
+int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
{
struct yyguts_t dummy_yyguts;
- cmExpr_yyset_extra (yy_user_defined, &dummy_yyguts);
+ yyset_extra (yy_user_defined, &dummy_yyguts);
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
- *ptr_yy_globals = (yyscan_t) cmExpr_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
@@ -1904,7 +2100,7 @@ int cmExpr_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globa
yy_init_globals. Leave at 0x00 for releases. */
memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
- cmExpr_yyset_extra (yy_user_defined, *ptr_yy_globals);
+ yyset_extra (yy_user_defined, *ptr_yy_globals);
return yy_init_globals ( *ptr_yy_globals );
}
@@ -1913,7 +2109,7 @@ static int yy_init_globals (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Initialization is the same as for the non-reentrant scanner.
- * This function is called from cmExpr_yylex_destroy(), so don't allocate here.
+ * This function is called from yylex_destroy(), so don't allocate here.
*/
yyg->yy_buffer_stack = NULL;
@@ -1937,37 +2133,37 @@ static int yy_init_globals (yyscan_t yyscanner)
#endif
/* For future reference: Set errno on error, since we are called by
- * cmExpr_yylex_init()
+ * yylex_init()
*/
return 0;
}
-/* cmExpr_yylex_destroy is for both reentrant and non-reentrant scanners. */
-int cmExpr_yylex_destroy (yyscan_t yyscanner)
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
+int yylex_destroy (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
- cmExpr_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
+ yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
YY_CURRENT_BUFFER_LVALUE = NULL;
- cmExpr_yypop_buffer_state(yyscanner);
+ yypop_buffer_state(yyscanner);
}
/* Destroy the stack itself. */
- cmExpr_yyfree(yyg->yy_buffer_stack ,yyscanner);
+ yyfree(yyg->yy_buffer_stack , yyscanner);
yyg->yy_buffer_stack = NULL;
/* Destroy the start condition stack. */
- cmExpr_yyfree(yyg->yy_start_stack ,yyscanner );
+ yyfree( yyg->yy_start_stack , yyscanner );
yyg->yy_start_stack = NULL;
/* Reset the globals. This is important in a non-reentrant scanner so the next time
- * cmExpr_yylex() is called, initialization will occur. */
+ * yylex() is called, initialization will occur. */
yy_init_globals( yyscanner);
/* Destroy the main struct (reentrant only). */
- cmExpr_yyfree ( yyscanner , yyscanner );
+ yyfree ( yyscanner , yyscanner );
yyscanner = NULL;
return 0;
}
@@ -1977,7 +2173,7 @@ int cmExpr_yylex_destroy (yyscan_t yyscanner)
*/
#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
+static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
@@ -1989,7 +2185,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
+static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
{
int n;
for ( n = 0; s[n]; ++n )
@@ -1999,14 +2195,14 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
}
#endif
-void *cmExpr_yyalloc (yy_size_t size , yyscan_t yyscanner)
+void *yyalloc (yy_size_t size , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
return malloc(size);
}
-void *cmExpr_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
+void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
@@ -2021,13 +2217,15 @@ void *cmExpr_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
return realloc(ptr, size);
}
-void cmExpr_yyfree (void * ptr , yyscan_t yyscanner)
+void yyfree (void * ptr , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
- free( (char *) ptr ); /* see cmExpr_yyrealloc() for (char *) cast */
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"
-#line 57 "cmExprLexer.in.l"
+/*--------------------------------------------------------------------------*/
+
+#endif /* __clang_analyzer__ */
diff --git a/Source/LexerParser/cmExprLexer.h b/Source/LexerParser/cmExprLexer.h
index 835a7a36a..b55ee92e5 100644
--- a/Source/LexerParser/cmExprLexer.h
+++ b/Source/LexerParser/cmExprLexer.h
@@ -2,10 +2,6 @@
#define cmExpr_yyHEADER_H 1
#define cmExpr_yyIN_HEADER 1
-#line 6 "cmExprLexer.h"
-
-#line 8 "cmExprLexer.h"
-
#define FLEXINT_H 1
#define YY_INT_ALIGNED short int
@@ -14,11 +10,221 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
+#define YY_FLEX_SUBMINOR_VERSION 4
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
+#ifdef yy_create_buffer
+#define cmExpr_yy_create_buffer_ALREADY_DEFINED
+#else
+#define yy_create_buffer cmExpr_yy_create_buffer
+#endif
+
+#ifdef yy_delete_buffer
+#define cmExpr_yy_delete_buffer_ALREADY_DEFINED
+#else
+#define yy_delete_buffer cmExpr_yy_delete_buffer
+#endif
+
+#ifdef yy_scan_buffer
+#define cmExpr_yy_scan_buffer_ALREADY_DEFINED
+#else
+#define yy_scan_buffer cmExpr_yy_scan_buffer
+#endif
+
+#ifdef yy_scan_string
+#define cmExpr_yy_scan_string_ALREADY_DEFINED
+#else
+#define yy_scan_string cmExpr_yy_scan_string
+#endif
+
+#ifdef yy_scan_bytes
+#define cmExpr_yy_scan_bytes_ALREADY_DEFINED
+#else
+#define yy_scan_bytes cmExpr_yy_scan_bytes
+#endif
+
+#ifdef yy_init_buffer
+#define cmExpr_yy_init_buffer_ALREADY_DEFINED
+#else
+#define yy_init_buffer cmExpr_yy_init_buffer
+#endif
+
+#ifdef yy_flush_buffer
+#define cmExpr_yy_flush_buffer_ALREADY_DEFINED
+#else
+#define yy_flush_buffer cmExpr_yy_flush_buffer
+#endif
+
+#ifdef yy_load_buffer_state
+#define cmExpr_yy_load_buffer_state_ALREADY_DEFINED
+#else
+#define yy_load_buffer_state cmExpr_yy_load_buffer_state
+#endif
+
+#ifdef yy_switch_to_buffer
+#define cmExpr_yy_switch_to_buffer_ALREADY_DEFINED
+#else
+#define yy_switch_to_buffer cmExpr_yy_switch_to_buffer
+#endif
+
+#ifdef yypush_buffer_state
+#define cmExpr_yypush_buffer_state_ALREADY_DEFINED
+#else
+#define yypush_buffer_state cmExpr_yypush_buffer_state
+#endif
+
+#ifdef yypop_buffer_state
+#define cmExpr_yypop_buffer_state_ALREADY_DEFINED
+#else
+#define yypop_buffer_state cmExpr_yypop_buffer_state
+#endif
+
+#ifdef yyensure_buffer_stack
+#define cmExpr_yyensure_buffer_stack_ALREADY_DEFINED
+#else
+#define yyensure_buffer_stack cmExpr_yyensure_buffer_stack
+#endif
+
+#ifdef yylex
+#define cmExpr_yylex_ALREADY_DEFINED
+#else
+#define yylex cmExpr_yylex
+#endif
+
+#ifdef yyrestart
+#define cmExpr_yyrestart_ALREADY_DEFINED
+#else
+#define yyrestart cmExpr_yyrestart
+#endif
+
+#ifdef yylex_init
+#define cmExpr_yylex_init_ALREADY_DEFINED
+#else
+#define yylex_init cmExpr_yylex_init
+#endif
+
+#ifdef yylex_init_extra
+#define cmExpr_yylex_init_extra_ALREADY_DEFINED
+#else
+#define yylex_init_extra cmExpr_yylex_init_extra
+#endif
+
+#ifdef yylex_destroy
+#define cmExpr_yylex_destroy_ALREADY_DEFINED
+#else
+#define yylex_destroy cmExpr_yylex_destroy
+#endif
+
+#ifdef yyget_debug
+#define cmExpr_yyget_debug_ALREADY_DEFINED
+#else
+#define yyget_debug cmExpr_yyget_debug
+#endif
+
+#ifdef yyset_debug
+#define cmExpr_yyset_debug_ALREADY_DEFINED
+#else
+#define yyset_debug cmExpr_yyset_debug
+#endif
+
+#ifdef yyget_extra
+#define cmExpr_yyget_extra_ALREADY_DEFINED
+#else
+#define yyget_extra cmExpr_yyget_extra
+#endif
+
+#ifdef yyset_extra
+#define cmExpr_yyset_extra_ALREADY_DEFINED
+#else
+#define yyset_extra cmExpr_yyset_extra
+#endif
+
+#ifdef yyget_in
+#define cmExpr_yyget_in_ALREADY_DEFINED
+#else
+#define yyget_in cmExpr_yyget_in
+#endif
+
+#ifdef yyset_in
+#define cmExpr_yyset_in_ALREADY_DEFINED
+#else
+#define yyset_in cmExpr_yyset_in
+#endif
+
+#ifdef yyget_out
+#define cmExpr_yyget_out_ALREADY_DEFINED
+#else
+#define yyget_out cmExpr_yyget_out
+#endif
+
+#ifdef yyset_out
+#define cmExpr_yyset_out_ALREADY_DEFINED
+#else
+#define yyset_out cmExpr_yyset_out
+#endif
+
+#ifdef yyget_leng
+#define cmExpr_yyget_leng_ALREADY_DEFINED
+#else
+#define yyget_leng cmExpr_yyget_leng
+#endif
+
+#ifdef yyget_text
+#define cmExpr_yyget_text_ALREADY_DEFINED
+#else
+#define yyget_text cmExpr_yyget_text
+#endif
+
+#ifdef yyget_lineno
+#define cmExpr_yyget_lineno_ALREADY_DEFINED
+#else
+#define yyget_lineno cmExpr_yyget_lineno
+#endif
+
+#ifdef yyset_lineno
+#define cmExpr_yyset_lineno_ALREADY_DEFINED
+#else
+#define yyset_lineno cmExpr_yyset_lineno
+#endif
+
+#ifdef yyget_column
+#define cmExpr_yyget_column_ALREADY_DEFINED
+#else
+#define yyget_column cmExpr_yyget_column
+#endif
+
+#ifdef yyset_column
+#define cmExpr_yyset_column_ALREADY_DEFINED
+#else
+#define yyset_column cmExpr_yyset_column
+#endif
+
+#ifdef yywrap
+#define cmExpr_yywrap_ALREADY_DEFINED
+#else
+#define yywrap cmExpr_yywrap
+#endif
+
+#ifdef yyalloc
+#define cmExpr_yyalloc_ALREADY_DEFINED
+#else
+#define yyalloc cmExpr_yyalloc
+#endif
+
+#ifdef yyrealloc
+#define cmExpr_yyrealloc_ALREADY_DEFINED
+#else
+#define yyrealloc cmExpr_yyrealloc
+#endif
+
+#ifdef yyfree
+#define cmExpr_yyfree_ALREADY_DEFINED
+#else
+#define yyfree cmExpr_yyfree
+#endif
+
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
@@ -89,10 +295,16 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
+#ifndef SIZE_MAX
+#define SIZE_MAX (~(size_t)0)
+#endif
+
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */
+
/* TODO: this is always defined, so inline it */
#define yyconst const
@@ -193,21 +405,21 @@ struct yy_buffer_state
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-void cmExpr_yyrestart (FILE *input_file ,yyscan_t yyscanner );
-void cmExpr_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmExpr_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
-void cmExpr_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmExpr_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmExpr_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-void cmExpr_yypop_buffer_state (yyscan_t yyscanner );
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+void yypop_buffer_state ( yyscan_t yyscanner );
-YY_BUFFER_STATE cmExpr_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmExpr_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
-void *cmExpr_yyalloc (yy_size_t ,yyscan_t yyscanner );
-void *cmExpr_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
-void cmExpr_yyfree (void * ,yyscan_t yyscanner );
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
+void yyfree ( void * , yyscan_t yyscanner );
/* Begin user sect3 */
@@ -225,42 +437,42 @@ void cmExpr_yyfree (void * ,yyscan_t yyscanner );
#define YY_EXTRA_TYPE void *
#endif
-int cmExpr_yylex_init (yyscan_t* scanner);
+int yylex_init (yyscan_t* scanner);
-int cmExpr_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
-int cmExpr_yylex_destroy (yyscan_t yyscanner );
+int yylex_destroy ( yyscan_t yyscanner );
-int cmExpr_yyget_debug (yyscan_t yyscanner );
+int yyget_debug ( yyscan_t yyscanner );
-void cmExpr_yyset_debug (int debug_flag ,yyscan_t yyscanner );
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
-YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner );
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
-void cmExpr_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
-FILE *cmExpr_yyget_in (yyscan_t yyscanner );
+FILE *yyget_in ( yyscan_t yyscanner );
-void cmExpr_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
+void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
-FILE *cmExpr_yyget_out (yyscan_t yyscanner );
+FILE *yyget_out ( yyscan_t yyscanner );
-void cmExpr_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
+void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
- int cmExpr_yyget_leng (yyscan_t yyscanner );
+ int yyget_leng ( yyscan_t yyscanner );
-char *cmExpr_yyget_text (yyscan_t yyscanner );
+char *yyget_text ( yyscan_t yyscanner );
-int cmExpr_yyget_lineno (yyscan_t yyscanner );
+int yyget_lineno ( yyscan_t yyscanner );
-void cmExpr_yyset_lineno (int _line_number ,yyscan_t yyscanner );
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
-int cmExpr_yyget_column (yyscan_t yyscanner );
+int yyget_column ( yyscan_t yyscanner );
-void cmExpr_yyset_column (int _column_no ,yyscan_t yyscanner );
+void yyset_column ( int _column_no , yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -268,18 +480,18 @@ void cmExpr_yyset_column (int _column_no ,yyscan_t yyscanner );
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int cmExpr_yywrap (yyscan_t yyscanner );
+extern "C" int yywrap ( yyscan_t yyscanner );
#else
-extern int cmExpr_yywrap (yyscan_t yyscanner );
+extern int yywrap ( yyscan_t yyscanner );
#endif
#endif
#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
@@ -307,9 +519,9 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-extern int cmExpr_yylex (yyscan_t yyscanner);
+extern int yylex (yyscan_t yyscanner);
-#define YY_DECL int cmExpr_yylex (yyscan_t yyscanner)
+#define YY_DECL int yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */
/* yy_get_previous_state - get the state just before the EOB char was reached */
@@ -326,9 +538,150 @@ extern int cmExpr_yylex (yyscan_t yyscanner);
#undef YY_DECL
#endif
-#line 57 "cmExprLexer.in.l"
-
+#ifndef cmExpr_yy_create_buffer_ALREADY_DEFINED
+#undef yy_create_buffer
+#endif
+#ifndef cmExpr_yy_delete_buffer_ALREADY_DEFINED
+#undef yy_delete_buffer
+#endif
+#ifndef cmExpr_yy_scan_buffer_ALREADY_DEFINED
+#undef yy_scan_buffer
+#endif
+#ifndef cmExpr_yy_scan_string_ALREADY_DEFINED
+#undef yy_scan_string
+#endif
+#ifndef cmExpr_yy_scan_bytes_ALREADY_DEFINED
+#undef yy_scan_bytes
+#endif
+#ifndef cmExpr_yy_init_buffer_ALREADY_DEFINED
+#undef yy_init_buffer
+#endif
+#ifndef cmExpr_yy_flush_buffer_ALREADY_DEFINED
+#undef yy_flush_buffer
+#endif
+#ifndef cmExpr_yy_load_buffer_state_ALREADY_DEFINED
+#undef yy_load_buffer_state
+#endif
+#ifndef cmExpr_yy_switch_to_buffer_ALREADY_DEFINED
+#undef yy_switch_to_buffer
+#endif
+#ifndef cmExpr_yypush_buffer_state_ALREADY_DEFINED
+#undef yypush_buffer_state
+#endif
+#ifndef cmExpr_yypop_buffer_state_ALREADY_DEFINED
+#undef yypop_buffer_state
+#endif
+#ifndef cmExpr_yyensure_buffer_stack_ALREADY_DEFINED
+#undef yyensure_buffer_stack
+#endif
+#ifndef cmExpr_yylex_ALREADY_DEFINED
+#undef yylex
+#endif
+#ifndef cmExpr_yyrestart_ALREADY_DEFINED
+#undef yyrestart
+#endif
+#ifndef cmExpr_yylex_init_ALREADY_DEFINED
+#undef yylex_init
+#endif
+#ifndef cmExpr_yylex_init_extra_ALREADY_DEFINED
+#undef yylex_init_extra
+#endif
+#ifndef cmExpr_yylex_destroy_ALREADY_DEFINED
+#undef yylex_destroy
+#endif
+#ifndef cmExpr_yyget_debug_ALREADY_DEFINED
+#undef yyget_debug
+#endif
+#ifndef cmExpr_yyset_debug_ALREADY_DEFINED
+#undef yyset_debug
+#endif
+#ifndef cmExpr_yyget_extra_ALREADY_DEFINED
+#undef yyget_extra
+#endif
+#ifndef cmExpr_yyset_extra_ALREADY_DEFINED
+#undef yyset_extra
+#endif
+#ifndef cmExpr_yyget_in_ALREADY_DEFINED
+#undef yyget_in
+#endif
+#ifndef cmExpr_yyset_in_ALREADY_DEFINED
+#undef yyset_in
+#endif
+#ifndef cmExpr_yyget_out_ALREADY_DEFINED
+#undef yyget_out
+#endif
+#ifndef cmExpr_yyset_out_ALREADY_DEFINED
+#undef yyset_out
+#endif
+#ifndef cmExpr_yyget_leng_ALREADY_DEFINED
+#undef yyget_leng
+#endif
+#ifndef cmExpr_yyget_text_ALREADY_DEFINED
+#undef yyget_text
+#endif
+#ifndef cmExpr_yyget_lineno_ALREADY_DEFINED
+#undef yyget_lineno
+#endif
+#ifndef cmExpr_yyset_lineno_ALREADY_DEFINED
+#undef yyset_lineno
+#endif
+#ifndef cmExpr_yyget_column_ALREADY_DEFINED
+#undef yyget_column
+#endif
+#ifndef cmExpr_yyset_column_ALREADY_DEFINED
+#undef yyset_column
+#endif
+#ifndef cmExpr_yywrap_ALREADY_DEFINED
+#undef yywrap
+#endif
+#ifndef cmExpr_yyget_lval_ALREADY_DEFINED
+#undef yyget_lval
+#endif
+#ifndef cmExpr_yyset_lval_ALREADY_DEFINED
+#undef yyset_lval
+#endif
+#ifndef cmExpr_yyget_lloc_ALREADY_DEFINED
+#undef yyget_lloc
+#endif
+#ifndef cmExpr_yyset_lloc_ALREADY_DEFINED
+#undef yyset_lloc
+#endif
+#ifndef cmExpr_yyalloc_ALREADY_DEFINED
+#undef yyalloc
+#endif
+#ifndef cmExpr_yyrealloc_ALREADY_DEFINED
+#undef yyrealloc
+#endif
+#ifndef cmExpr_yyfree_ALREADY_DEFINED
+#undef yyfree
+#endif
+#ifndef cmExpr_yytext_ALREADY_DEFINED
+#undef yytext
+#endif
+#ifndef cmExpr_yyleng_ALREADY_DEFINED
+#undef yyleng
+#endif
+#ifndef cmExpr_yyin_ALREADY_DEFINED
+#undef yyin
+#endif
+#ifndef cmExpr_yyout_ALREADY_DEFINED
+#undef yyout
+#endif
+#ifndef cmExpr_yy_flex_debug_ALREADY_DEFINED
+#undef yy_flex_debug
+#endif
+#ifndef cmExpr_yylineno_ALREADY_DEFINED
+#undef yylineno
+#endif
+#ifndef cmExpr_yytables_fload_ALREADY_DEFINED
+#undef yytables_fload
+#endif
+#ifndef cmExpr_yytables_destroy_ALREADY_DEFINED
+#undef yytables_destroy
+#endif
+#ifndef cmExpr_yyTABLES_NAME_ALREADY_DEFINED
+#undef yyTABLES_NAME
+#endif
-#line 333 "cmExprLexer.h"
#undef cmExpr_yyIN_HEADER
#endif /* cmExpr_yyHEADER_H */
diff --git a/Source/LexerParser/cmExprLexer.in.l b/Source/LexerParser/cmExprLexer.in.l
index 25ddba460..f8a422431 100644
--- a/Source/LexerParser/cmExprLexer.in.l
+++ b/Source/LexerParser/cmExprLexer.in.l
@@ -7,38 +7,45 @@ This file must be translated to C++ and modified to build everywhere.
Run flex >= 2.6 like this:
- flex --nounistd -DFLEXINT_H --prefix=cmExpr_yy --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l
+ flex --nounistd -DFLEXINT_H --noline --header-file=cmExprLexer.h -ocmExprLexer.cxx cmExprLexer.in.l
Modify cmExprLexer.cxx:
- - remove trailing whitespace: sed -i 's/\s*$//' cmExprLexer.h cmExprLexer.cxx
- - remove blank lines at end of file
- - #include "cmStandardLexer.h" at the top
- - add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t
+ - remove trailing whitespace: sed -i 's/\s*$//' cmExprLexer.h cmExprLexer.cxx
+ - remove blank lines at end of file: sed -i '${/^$/d;}' cmExprLexer.h cmExprLexer.cxx
+ - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmExprLexer.cxx
*/
/* IWYU pragma: no_forward_declare yyguts_t */
+#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+
#include "cmExprParserHelper.h"
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
- { result = yyextra->LexInput(buf, max_size); }
+ do { result = yyextra->LexInput(buf, max_size); } while (0)
/* Include the set of tokens from the parser. */
#include "cmExprParserTokens.h"
+#include <string>
+
/*--------------------------------------------------------------------------*/
%}
+%option prefix="cmExpr_yy"
+
%option reentrant
%option noyywrap
%pointer
%%
+[ \t] {}
-[0-9][0-9]* { yylvalp->Number = atoi(yytext); return exp_NUMBER; }
+[0-9][0-9]* { yylvalp->Number = std::stoll(yytext, nullptr, 10); return exp_NUMBER; }
+0[xX][0-9a-fA-F][0-9a-fA-F]* { yylvalp->Number = std::stoll(yytext, nullptr, 16); return exp_NUMBER; }
"+" { return exp_PLUS; }
"-" { return exp_MINUS; }
@@ -53,5 +60,10 @@ Modify cmExprLexer.cxx:
">>" { return exp_SHIFTRIGHT; }
"(" { return exp_OPENPARENT; }
")" { return exp_CLOSEPARENT; }
+. { yyextra->UnexpectedChar(yytext[0]); }
%%
+
+/*--------------------------------------------------------------------------*/
+
+#endif /* __clang_analyzer__ */
diff --git a/Source/LexerParser/cmExprParser.cxx b/Source/LexerParser/cmExprParser.cxx
index 67664a5f5..8416e7249 100644
--- a/Source/LexerParser/cmExprParser.cxx
+++ b/Source/LexerParser/cmExprParser.cxx
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
+/* A Bison parser, made by GNU Bison 3.3.2. */
/* Bison implementation for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
+ Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -40,11 +41,14 @@
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
+/* Undocumented macros, especially those whose name start with YY_,
+ are private implementation details. Do not rely on them. */
+
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "3.0.4"
+#define YYBISON_VERSION "3.3.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -67,8 +71,8 @@
#define yynerrs cmExpr_yynerrs
-/* Copy the first part of user declarations. */
-#line 1 "cmExprParser.y" /* yacc.c:339 */
+/* First part of user prologue. */
+#line 1 "cmExprParser.y" /* yacc.c:337 */
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
@@ -89,6 +93,7 @@ Modify cmExprParser.cxx:
#include <stdlib.h>
#include <string.h>
+#include <stdexcept>
/*-------------------------------------------------------------------------*/
#define YYDEBUG 1
@@ -107,14 +112,20 @@ static void cmExpr_yyerror(yyscan_t yyscanner, const char* message);
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but no case. */
#endif
+#if defined(__GNUC__) && __GNUC__ >= 8
+# pragma GCC diagnostic ignored "-Wconversion"
+#endif
-#line 112 "cmExprParser.cxx" /* yacc.c:339 */
-
+#line 120 "cmExprParser.cxx" /* yacc.c:337 */
# ifndef YY_NULLPTR
-# if defined __cplusplus && 201103L <= __cplusplus
-# define YY_NULLPTR nullptr
+# if defined __cplusplus
+# if 201103L <= __cplusplus
+# define YY_NULLPTR nullptr
+# else
+# define YY_NULLPTR 0
+# endif
# else
-# define YY_NULLPTR 0
+# define YY_NULLPTR ((void*)0)
# endif
# endif
@@ -183,9 +194,7 @@ int cmExpr_yyparse (yyscan_t yyscanner);
#endif /* !YY_CMEXPR_YY_CMEXPRPARSERTOKENS_H_INCLUDED */
-/* Copy the second part of user declarations. */
-#line 189 "cmExprParser.cxx" /* yacc.c:358 */
#ifdef short
# undef short
@@ -206,13 +215,13 @@ typedef signed char yytype_int8;
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
-typedef unsigned short int yytype_uint16;
+typedef unsigned short yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
-typedef short int yytype_int16;
+typedef short yytype_int16;
#endif
#ifndef YYSIZE_T
@@ -224,7 +233,7 @@ typedef short int yytype_int16;
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
-# define YYSIZE_T unsigned int
+# define YYSIZE_T unsigned
# endif
#endif
@@ -260,15 +269,6 @@ typedef short int yytype_int16;
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
-#if !defined _Noreturn \
- && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
-# if defined _MSC_VER && 1200 <= _MSC_VER
-# define _Noreturn __declspec (noreturn)
-# else
-# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
-# endif
-#endif
-
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
@@ -276,7 +276,7 @@ typedef short int yytype_int16;
# define YYUSE(E) /* empty */
#endif
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
@@ -425,29 +425,29 @@ union yyalloc
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 17
+#define YYFINAL 19
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 30
+#define YYLAST 34
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 17
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 10
/* YYNRULES -- Number of rules. */
-#define YYNRULES 23
+#define YYNRULES 24
/* YYNSTATES -- Number of states. */
-#define YYNSTATES 39
+#define YYNSTATES 41
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
- by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 271
+/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
+ as returned by yylex, with out-of-bounds checking. */
#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+ ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
- as returned by yylex, without out-of-bounds checking. */
+ as returned by yylex. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -484,9 +484,9 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
- 0, 73, 73, 78, 81, 86, 89, 94, 97, 102,
- 105, 108, 113, 116, 119, 124, 127, 130, 133, 138,
- 141, 144, 149, 152
+ 0, 77, 77, 82, 85, 90, 93, 98, 101, 106,
+ 109, 112, 117, 120, 123, 128, 131, 134, 140, 145,
+ 148, 151, 154, 159, 162
};
#endif
@@ -513,10 +513,10 @@ static const yytype_uint16 yytoknum[] =
};
# endif
-#define YYPACT_NINF -8
+#define YYPACT_NINF -11
#define yypact_value_is_default(Yystate) \
- (!!((Yystate) == (-8)))
+ (!!((Yystate) == (-11)))
#define YYTABLE_NINF -1
@@ -527,10 +527,11 @@ static const yytype_uint16 yytoknum[] =
STATE-NUM. */
static const yytype_int8 yypact[] =
{
- 0, 0, 0, 0, -8, 2, -7, -5, 8, 3,
- 10, 1, -8, -8, -8, -8, 6, -8, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, -8, -5,
- 8, 3, 10, 10, 1, 1, -8, -8, -8
+ 1, 1, 1, 1, 1, -11, 6, -10, -4, 9,
+ 4, 11, 2, -11, -11, -11, -11, 7, -11, -11,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ -11, -4, 9, 4, 11, 11, 2, 2, -11, -11,
+ -11
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -538,22 +539,23 @@ static const yytype_int8 yypact[] =
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
- 0, 0, 0, 0, 22, 0, 2, 3, 5, 7,
- 9, 12, 15, 19, 20, 21, 0, 1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 23, 4,
- 6, 8, 10, 11, 13, 14, 16, 17, 18
+ 0, 0, 0, 0, 0, 23, 0, 2, 3, 5,
+ 7, 9, 12, 15, 19, 20, 21, 0, 22, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 24, 4, 6, 8, 10, 11, 13, 14, 16, 17,
+ 18
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
- -8, -8, 12, 5, 11, 9, -2, 4, -1, -8
+ -11, -11, 22, 10, 8, 12, -3, -2, -1, -11
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int8 yydefgoto[] =
{
- -1, 5, 6, 7, 8, 9, 10, 11, 12, 13
+ -1, 6, 7, 8, 9, 10, 11, 12, 13, 14
};
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
@@ -561,28 +563,29 @@ static const yytype_int8 yydefgoto[] =
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_uint8 yytable[] =
{
- 14, 15, 17, 1, 2, 18, 25, 26, 27, 19,
- 3, 21, 22, 23, 24, 16, 4, 28, 18, 32,
- 33, 20, 0, 29, 36, 37, 38, 34, 35, 31,
- 30
+ 15, 16, 20, 18, 1, 2, 19, 27, 28, 29,
+ 21, 3, 23, 24, 25, 26, 4, 5, 30, 20,
+ 34, 35, 22, 36, 37, 17, 38, 39, 40, 32,
+ 31, 0, 0, 0, 33
};
static const yytype_int8 yycheck[] =
{
- 1, 2, 0, 3, 4, 12, 5, 6, 7, 14,
- 10, 8, 9, 3, 4, 3, 16, 11, 12, 21,
- 22, 13, -1, 18, 25, 26, 27, 23, 24, 20,
- 19
+ 1, 2, 12, 4, 3, 4, 0, 5, 6, 7,
+ 14, 10, 8, 9, 3, 4, 15, 16, 11, 12,
+ 23, 24, 13, 25, 26, 3, 27, 28, 29, 21,
+ 20, -1, -1, -1, 22
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
symbol of state STATE-NUM. */
static const yytype_uint8 yystos[] =
{
- 0, 3, 4, 10, 16, 18, 19, 20, 21, 22,
- 23, 24, 25, 26, 25, 25, 19, 0, 12, 14,
- 13, 8, 9, 3, 4, 5, 6, 7, 11, 20,
- 21, 22, 23, 23, 24, 24, 25, 25, 25
+ 0, 3, 4, 10, 15, 16, 18, 19, 20, 21,
+ 22, 23, 24, 25, 26, 25, 25, 19, 25, 0,
+ 12, 14, 13, 8, 9, 3, 4, 5, 6, 7,
+ 11, 20, 21, 22, 23, 23, 24, 24, 25, 25,
+ 25
};
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
@@ -590,7 +593,7 @@ static const yytype_uint8 yyr1[] =
{
0, 17, 18, 19, 19, 20, 20, 21, 21, 22,
22, 22, 23, 23, 23, 24, 24, 24, 24, 25,
- 25, 25, 26, 26
+ 25, 25, 25, 26, 26
};
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
@@ -598,7 +601,7 @@ static const yytype_uint8 yyr2[] =
{
0, 2, 1, 1, 3, 1, 3, 1, 3, 1,
3, 3, 1, 3, 3, 1, 3, 3, 3, 1,
- 2, 2, 1, 3
+ 2, 2, 2, 1, 3
};
@@ -614,22 +617,22 @@ static const yytype_uint8 yyr2[] =
#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (yylen); \
- yystate = *yyssp; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (yyscanner, YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (0)
+#define YYBACKUP(Token, Value) \
+ do \
+ if (yychar == YYEMPTY) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (yylen); \
+ yystate = *yyssp; \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (yyscanner, YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+ while (0)
/* Error token number */
#define YYTERROR 1
@@ -669,38 +672,38 @@ do { \
} while (0)
-/*----------------------------------------.
-| Print this symbol's value on YYOUTPUT. |
-`----------------------------------------*/
+/*-----------------------------------.
+| Print this symbol's value on YYO. |
+`-----------------------------------*/
static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
+yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
{
- FILE *yyo = yyoutput;
- YYUSE (yyo);
+ FILE *yyoutput = yyo;
+ YYUSE (yyoutput);
YYUSE (yyscanner);
if (!yyvaluep)
return;
# ifdef YYPRINT
if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+ YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
# endif
YYUSE (yytype);
}
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
+/*---------------------------.
+| Print this symbol on YYO. |
+`---------------------------*/
static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
+yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
{
- YYFPRINTF (yyoutput, "%s %s (",
+ YYFPRINTF (yyo, "%s %s (",
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
- yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner);
- YYFPRINTF (yyoutput, ")");
+ yy_symbol_value_print (yyo, yytype, yyvaluep, yyscanner);
+ YYFPRINTF (yyo, ")");
}
/*------------------------------------------------------------------.
@@ -734,7 +737,7 @@ do { \
static void
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner)
{
- unsigned long int yylno = yyrline[yyrule];
+ unsigned long yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
@@ -745,7 +748,7 @@ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, yyscan_t yysca
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
yystos[yyssp[yyi + 1 - yynrhs]],
- &(yyvsp[(yyi + 1) - (yynrhs)])
+ &yyvsp[(yyi + 1) - (yynrhs)]
, yyscanner);
YYFPRINTF (stderr, "\n");
}
@@ -849,7 +852,10 @@ yytnamerr (char *yyres, const char *yystr)
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
- /* Fall through. */
+ else
+ goto append;
+
+ append:
default:
if (yyres)
yyres[yyn] = *yyp;
@@ -867,7 +873,7 @@ yytnamerr (char *yyres, const char *yystr)
if (! yyres)
return yystrlen (yystr);
- return yystpcpy (yyres, yystr) - yyres;
+ return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
}
# endif
@@ -945,10 +951,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yyarg[yycount++] = yytname[yyx];
{
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
- if (! (yysize <= yysize1
- && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+ yysize = yysize1;
+ else
return 2;
- yysize = yysize1;
}
}
}
@@ -960,6 +966,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
case N: \
yyformat = S; \
break
+ default: /* Avoid compiler warnings. */
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
@@ -971,9 +978,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
{
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
- if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+ yysize = yysize1;
+ else
return 2;
- yysize = yysize1;
}
if (*yymsg_alloc < yysize)
@@ -1104,23 +1112,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
+
/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
+| yynewstate -- push a new state, which is found in yystate. |
`------------------------------------------------------------*/
- yynewstate:
+yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
- yysetstate:
- *yyssp = yystate;
+
+/*--------------------------------------------------------------------.
+| yynewstate -- set current state (the top of the stack) to yystate. |
+`--------------------------------------------------------------------*/
+yysetstate:
+ *yyssp = (yytype_int16) yystate;
if (yyss + yystacksize - 1 <= yyssp)
+#if !defined yyoverflow && !defined YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+#else
{
/* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
+ YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
-#ifdef yyoverflow
+# if defined yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
@@ -1136,14 +1152,10 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
-
yyss = yyss1;
yyvs = yyvs1;
}
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
+# else /* defined YYSTACK_RELOCATE */
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
@@ -1159,22 +1171,22 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
-# undef YYSTACK_RELOCATE
+# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
-#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
+ (unsigned long) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
+#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
@@ -1183,11 +1195,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
goto yybackup;
+
/*-----------.
| yybackup. |
`-----------*/
yybackup:
-
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
@@ -1260,7 +1272,7 @@ yydefault:
/*-----------------------------.
-| yyreduce -- Do a reduction. |
+| yyreduce -- do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
@@ -1281,183 +1293,194 @@ yyreduce:
switch (yyn)
{
case 2:
-#line 73 "cmExprParser.y" /* yacc.c:1646 */
+#line 77 "cmExprParser.y" /* yacc.c:1652 */
{
cmExpr_yyget_extra(yyscanner)->SetResult((yyvsp[0].Number));
}
-#line 1289 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1301 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 3:
-#line 78 "cmExprParser.y" /* yacc.c:1646 */
+#line 82 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[0].Number);
}
-#line 1297 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1309 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 4:
-#line 81 "cmExprParser.y" /* yacc.c:1646 */
+#line 85 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[-2].Number) | (yyvsp[0].Number);
}
-#line 1305 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1317 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 5:
-#line 86 "cmExprParser.y" /* yacc.c:1646 */
+#line 90 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[0].Number);
}
-#line 1313 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1325 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 6:
-#line 89 "cmExprParser.y" /* yacc.c:1646 */
+#line 93 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[-2].Number) ^ (yyvsp[0].Number);
}
-#line 1321 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1333 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 7:
-#line 94 "cmExprParser.y" /* yacc.c:1646 */
+#line 98 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[0].Number);
}
-#line 1329 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1341 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 8:
-#line 97 "cmExprParser.y" /* yacc.c:1646 */
+#line 101 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[-2].Number) & (yyvsp[0].Number);
}
-#line 1337 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1349 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 9:
-#line 102 "cmExprParser.y" /* yacc.c:1646 */
+#line 106 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[0].Number);
}
-#line 1345 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1357 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 10:
-#line 105 "cmExprParser.y" /* yacc.c:1646 */
+#line 109 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[-2].Number) << (yyvsp[0].Number);
}
-#line 1353 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1365 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 11:
-#line 108 "cmExprParser.y" /* yacc.c:1646 */
+#line 112 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[-2].Number) >> (yyvsp[0].Number);
}
-#line 1361 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1373 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 12:
-#line 113 "cmExprParser.y" /* yacc.c:1646 */
+#line 117 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[0].Number);
}
-#line 1369 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1381 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 13:
-#line 116 "cmExprParser.y" /* yacc.c:1646 */
+#line 120 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[-2].Number) + (yyvsp[0].Number);
}
-#line 1377 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1389 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 14:
-#line 119 "cmExprParser.y" /* yacc.c:1646 */
+#line 123 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[-2].Number) - (yyvsp[0].Number);
}
-#line 1385 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1397 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 15:
-#line 124 "cmExprParser.y" /* yacc.c:1646 */
+#line 128 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[0].Number);
}
-#line 1393 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1405 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 16:
-#line 127 "cmExprParser.y" /* yacc.c:1646 */
+#line 131 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[-2].Number) * (yyvsp[0].Number);
}
-#line 1401 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1413 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 17:
-#line 130 "cmExprParser.y" /* yacc.c:1646 */
+#line 134 "cmExprParser.y" /* yacc.c:1652 */
{
+ if (yyvsp[0].Number == 0) {
+ throw std::overflow_error("divide by zero");
+ }
(yyval.Number) = (yyvsp[-2].Number) / (yyvsp[0].Number);
}
-#line 1409 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1424 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 18:
-#line 133 "cmExprParser.y" /* yacc.c:1646 */
+#line 140 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[-2].Number) % (yyvsp[0].Number);
}
-#line 1417 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1432 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 19:
-#line 138 "cmExprParser.y" /* yacc.c:1646 */
+#line 145 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[0].Number);
}
-#line 1425 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1440 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 20:
-#line 141 "cmExprParser.y" /* yacc.c:1646 */
+#line 148 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = + (yyvsp[0].Number);
}
-#line 1433 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1448 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 21:
-#line 144 "cmExprParser.y" /* yacc.c:1646 */
+#line 151 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = - (yyvsp[0].Number);
}
-#line 1441 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1456 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 22:
-#line 149 "cmExprParser.y" /* yacc.c:1646 */
+#line 154 "cmExprParser.y" /* yacc.c:1652 */
{
- (yyval.Number) = (yyvsp[0].Number);
+ (yyval.Number) = ~ (yyvsp[0].Number);
}
-#line 1449 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1464 "cmExprParser.cxx" /* yacc.c:1652 */
break;
case 23:
-#line 152 "cmExprParser.y" /* yacc.c:1646 */
+#line 159 "cmExprParser.y" /* yacc.c:1652 */
+ {
+ (yyval.Number) = (yyvsp[0].Number);
+ }
+#line 1472 "cmExprParser.cxx" /* yacc.c:1652 */
+ break;
+
+ case 24:
+#line 162 "cmExprParser.y" /* yacc.c:1652 */
{
(yyval.Number) = (yyvsp[-1].Number);
}
-#line 1457 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1480 "cmExprParser.cxx" /* yacc.c:1652 */
break;
-#line 1461 "cmExprParser.cxx" /* yacc.c:1646 */
+#line 1484 "cmExprParser.cxx" /* yacc.c:1652 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -1482,14 +1505,13 @@ yyreduce:
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
+ {
+ const int yylhs = yyr1[yyn] - YYNTOKENS;
+ const int yyi = yypgoto[yylhs] + *yyssp;
+ yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
+ ? yytable[yyi]
+ : yydefgoto[yylhs]);
+ }
goto yynewstate;
@@ -1573,12 +1595,10 @@ yyerrlab:
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
+ /* Pacify compilers when the user code never invokes YYERROR and the
+ label yyerrorlab therefore never appears in user code. */
+ if (0)
+ YYERROR;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
@@ -1641,6 +1661,7 @@ yyacceptlab:
yyresult = 0;
goto yyreturn;
+
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
@@ -1648,6 +1669,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
+
#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
@@ -1658,6 +1680,10 @@ yyexhaustedlab:
/* Fall through. */
#endif
+
+/*-----------------------------------------------------.
+| yyreturn -- parsing is finished, return the result. |
+`-----------------------------------------------------*/
yyreturn:
if (yychar != YYEMPTY)
{
@@ -1687,7 +1713,7 @@ yyreturn:
#endif
return yyresult;
}
-#line 157 "cmExprParser.y" /* yacc.c:1906 */
+#line 167 "cmExprParser.y" /* yacc.c:1918 */
/* End of grammar */
diff --git a/Source/LexerParser/cmExprParser.y b/Source/LexerParser/cmExprParser.y
index d1c3a97a7..7ae21188e 100644
--- a/Source/LexerParser/cmExprParser.y
+++ b/Source/LexerParser/cmExprParser.y
@@ -18,6 +18,7 @@ Modify cmExprParser.cxx:
#include <stdlib.h>
#include <string.h>
+#include <stdexcept>
/*-------------------------------------------------------------------------*/
#define YYDEBUG 1
@@ -36,6 +37,9 @@ static void cmExpr_yyerror(yyscan_t yyscanner, const char* message);
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but no case. */
#endif
+#if defined(__GNUC__) && __GNUC__ >= 8
+# pragma GCC diagnostic ignored "-Wconversion"
+#endif
%}
/* Generate a reentrant parser object. */
@@ -128,6 +132,9 @@ term:
$<Number>$ = $<Number>1 * $<Number>3;
}
| term exp_DIVIDE unary {
+ if (yyvsp[0].Number == 0) {
+ throw std::overflow_error("divide by zero");
+ }
$<Number>$ = $<Number>1 / $<Number>3;
}
| term exp_MOD unary {
@@ -144,6 +151,9 @@ unary:
| exp_MINUS unary {
$<Number>$ = - $<Number>2;
}
+| exp_NOT unary {
+ $<Number>$ = ~ $<Number>2;
+ }
factor:
exp_NUMBER {
diff --git a/Source/LexerParser/cmExprParserTokens.h b/Source/LexerParser/cmExprParserTokens.h
index 84b2bbdcd..5ffd7c510 100644
--- a/Source/LexerParser/cmExprParserTokens.h
+++ b/Source/LexerParser/cmExprParserTokens.h
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
+/* A Bison parser, made by GNU Bison 3.3.2. */
/* Bison interface for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
+ Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,6 +31,9 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
+/* Undocumented macros, especially those whose name start with YY_,
+ are private implementation details. Do not rely on them. */
+
#ifndef YY_CMEXPR_YY_CMEXPRPARSERTOKENS_H_INCLUDED
# define YY_CMEXPR_YY_CMEXPRPARSERTOKENS_H_INCLUDED
/* Debug traces. */
diff --git a/Source/LexerParser/cmFortranLexer.cxx b/Source/LexerParser/cmFortranLexer.cxx
index 01c09acb7..bcda77c30 100644
--- a/Source/LexerParser/cmFortranLexer.cxx
+++ b/Source/LexerParser/cmFortranLexer.cxx
@@ -1,7 +1,4 @@
#include "cmStandardLexer.h"
-#line 2 "cmFortranLexer.cxx"
-
-#line 4 "cmFortranLexer.cxx"
#define FLEXINT_H 1
#define YY_INT_ALIGNED short int
@@ -11,11 +8,221 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
+#define YY_FLEX_SUBMINOR_VERSION 4
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
+#ifdef yy_create_buffer
+#define cmFortran_yy_create_buffer_ALREADY_DEFINED
+#else
+#define yy_create_buffer cmFortran_yy_create_buffer
+#endif
+
+#ifdef yy_delete_buffer
+#define cmFortran_yy_delete_buffer_ALREADY_DEFINED
+#else
+#define yy_delete_buffer cmFortran_yy_delete_buffer
+#endif
+
+#ifdef yy_scan_buffer
+#define cmFortran_yy_scan_buffer_ALREADY_DEFINED
+#else
+#define yy_scan_buffer cmFortran_yy_scan_buffer
+#endif
+
+#ifdef yy_scan_string
+#define cmFortran_yy_scan_string_ALREADY_DEFINED
+#else
+#define yy_scan_string cmFortran_yy_scan_string
+#endif
+
+#ifdef yy_scan_bytes
+#define cmFortran_yy_scan_bytes_ALREADY_DEFINED
+#else
+#define yy_scan_bytes cmFortran_yy_scan_bytes
+#endif
+
+#ifdef yy_init_buffer
+#define cmFortran_yy_init_buffer_ALREADY_DEFINED
+#else
+#define yy_init_buffer cmFortran_yy_init_buffer
+#endif
+
+#ifdef yy_flush_buffer
+#define cmFortran_yy_flush_buffer_ALREADY_DEFINED
+#else
+#define yy_flush_buffer cmFortran_yy_flush_buffer
+#endif
+
+#ifdef yy_load_buffer_state
+#define cmFortran_yy_load_buffer_state_ALREADY_DEFINED
+#else
+#define yy_load_buffer_state cmFortran_yy_load_buffer_state
+#endif
+
+#ifdef yy_switch_to_buffer
+#define cmFortran_yy_switch_to_buffer_ALREADY_DEFINED
+#else
+#define yy_switch_to_buffer cmFortran_yy_switch_to_buffer
+#endif
+
+#ifdef yypush_buffer_state
+#define cmFortran_yypush_buffer_state_ALREADY_DEFINED
+#else
+#define yypush_buffer_state cmFortran_yypush_buffer_state
+#endif
+
+#ifdef yypop_buffer_state
+#define cmFortran_yypop_buffer_state_ALREADY_DEFINED
+#else
+#define yypop_buffer_state cmFortran_yypop_buffer_state
+#endif
+
+#ifdef yyensure_buffer_stack
+#define cmFortran_yyensure_buffer_stack_ALREADY_DEFINED
+#else
+#define yyensure_buffer_stack cmFortran_yyensure_buffer_stack
+#endif
+
+#ifdef yylex
+#define cmFortran_yylex_ALREADY_DEFINED
+#else
+#define yylex cmFortran_yylex
+#endif
+
+#ifdef yyrestart
+#define cmFortran_yyrestart_ALREADY_DEFINED
+#else
+#define yyrestart cmFortran_yyrestart
+#endif
+
+#ifdef yylex_init
+#define cmFortran_yylex_init_ALREADY_DEFINED
+#else
+#define yylex_init cmFortran_yylex_init
+#endif
+
+#ifdef yylex_init_extra
+#define cmFortran_yylex_init_extra_ALREADY_DEFINED
+#else
+#define yylex_init_extra cmFortran_yylex_init_extra
+#endif
+
+#ifdef yylex_destroy
+#define cmFortran_yylex_destroy_ALREADY_DEFINED
+#else
+#define yylex_destroy cmFortran_yylex_destroy
+#endif
+
+#ifdef yyget_debug
+#define cmFortran_yyget_debug_ALREADY_DEFINED
+#else
+#define yyget_debug cmFortran_yyget_debug
+#endif
+
+#ifdef yyset_debug
+#define cmFortran_yyset_debug_ALREADY_DEFINED
+#else
+#define yyset_debug cmFortran_yyset_debug
+#endif
+
+#ifdef yyget_extra
+#define cmFortran_yyget_extra_ALREADY_DEFINED
+#else
+#define yyget_extra cmFortran_yyget_extra
+#endif
+
+#ifdef yyset_extra
+#define cmFortran_yyset_extra_ALREADY_DEFINED
+#else
+#define yyset_extra cmFortran_yyset_extra
+#endif
+
+#ifdef yyget_in
+#define cmFortran_yyget_in_ALREADY_DEFINED
+#else
+#define yyget_in cmFortran_yyget_in
+#endif
+
+#ifdef yyset_in
+#define cmFortran_yyset_in_ALREADY_DEFINED
+#else
+#define yyset_in cmFortran_yyset_in
+#endif
+
+#ifdef yyget_out
+#define cmFortran_yyget_out_ALREADY_DEFINED
+#else
+#define yyget_out cmFortran_yyget_out
+#endif
+
+#ifdef yyset_out
+#define cmFortran_yyset_out_ALREADY_DEFINED
+#else
+#define yyset_out cmFortran_yyset_out
+#endif
+
+#ifdef yyget_leng
+#define cmFortran_yyget_leng_ALREADY_DEFINED
+#else
+#define yyget_leng cmFortran_yyget_leng
+#endif
+
+#ifdef yyget_text
+#define cmFortran_yyget_text_ALREADY_DEFINED
+#else
+#define yyget_text cmFortran_yyget_text
+#endif
+
+#ifdef yyget_lineno
+#define cmFortran_yyget_lineno_ALREADY_DEFINED
+#else
+#define yyget_lineno cmFortran_yyget_lineno
+#endif
+
+#ifdef yyset_lineno
+#define cmFortran_yyset_lineno_ALREADY_DEFINED
+#else
+#define yyset_lineno cmFortran_yyset_lineno
+#endif
+
+#ifdef yyget_column
+#define cmFortran_yyget_column_ALREADY_DEFINED
+#else
+#define yyget_column cmFortran_yyget_column
+#endif
+
+#ifdef yyset_column
+#define cmFortran_yyset_column_ALREADY_DEFINED
+#else
+#define yyset_column cmFortran_yyset_column
+#endif
+
+#ifdef yywrap
+#define cmFortran_yywrap_ALREADY_DEFINED
+#else
+#define yywrap cmFortran_yywrap
+#endif
+
+#ifdef yyalloc
+#define cmFortran_yyalloc_ALREADY_DEFINED
+#else
+#define yyalloc cmFortran_yyalloc
+#endif
+
+#ifdef yyrealloc
+#define cmFortran_yyrealloc_ALREADY_DEFINED
+#else
+#define yyrealloc cmFortran_yyrealloc
+#endif
+
+#ifdef yyfree
+#define cmFortran_yyfree_ALREADY_DEFINED
+#else
+#define yyfree cmFortran_yyfree
+#endif
+
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
@@ -86,10 +293,16 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
+#ifndef SIZE_MAX
+#define SIZE_MAX (~(size_t)0)
+#endif
+
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */
+
/* TODO: this is always defined, so inline it */
#define yyconst const
@@ -102,12 +315,10 @@ typedef unsigned int flex_uint32_t;
/* Returned upon end-of-file. */
#define YY_NULL 0
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
+/* Promotes a possibly negative, possibly signed char to an
+ * integer in range [0..255] for use as an array index.
*/
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
@@ -131,20 +342,16 @@ typedef void* yyscan_t;
* definition of BEGIN.
*/
#define BEGIN yyg->yy_start = 1 + 2 *
-
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START ((yyg->yy_start - 1) / 2)
#define YYSTATE YY_START
-
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE cmFortran_yyrestart(yyin ,yyscanner )
-
+#define YY_NEW_FILE yyrestart( yyin , yyscanner )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
@@ -194,7 +401,6 @@ typedef size_t yy_size_t;
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
-
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
#ifndef YY_STRUCT_YY_BUFFER_STATE
@@ -254,7 +460,7 @@ struct yy_buffer_state
* possible backing-up.
*
* When we actually see the EOF, we change the status to "new"
- * (via cmFortran_yyrestart()), so that the user can continue scanning by
+ * (via yyrestart()), so that the user can continue scanning by
* just pointing yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
@@ -271,73 +477,67 @@ struct yy_buffer_state
#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
: NULL)
-
/* Same as previous macro, but useful when we know that the buffer stack is not
* NULL or when we need an lvalue. For internal use only.
*/
#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
-void cmFortran_yyrestart (FILE *input_file ,yyscan_t yyscanner );
-void cmFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmFortran_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
-void cmFortran_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmFortran_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-void cmFortran_yypop_buffer_state (yyscan_t yyscanner );
-
-static void cmFortran_yyensure_buffer_stack (yyscan_t yyscanner );
-static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner );
-static void cmFortran_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
-
-#define YY_FLUSH_BUFFER cmFortran_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+void yypop_buffer_state ( yyscan_t yyscanner );
-YY_BUFFER_STATE cmFortran_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmFortran_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmFortran_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+static void yyensure_buffer_stack ( yyscan_t yyscanner );
+static void yy_load_buffer_state ( yyscan_t yyscanner );
+static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
+#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)
-void *cmFortran_yyalloc (yy_size_t ,yyscan_t yyscanner );
-void *cmFortran_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
-void cmFortran_yyfree (void * ,yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
-#define yy_new_buffer cmFortran_yy_create_buffer
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
+void yyfree ( void * , yyscan_t yyscanner );
+#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
{ \
if ( ! YY_CURRENT_BUFFER ){ \
- cmFortran_yyensure_buffer_stack (yyscanner); \
+ yyensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
- cmFortran_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
-
#define yy_set_bol(at_bol) \
{ \
if ( ! YY_CURRENT_BUFFER ){\
- cmFortran_yyensure_buffer_stack (yyscanner); \
+ yyensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
- cmFortran_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
-
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
/* Begin user sect3 */
#define cmFortran_yywrap(yyscanner) (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
-
-typedef unsigned char YY_CHAR;
+typedef flex_uint8_t YY_CHAR;
typedef int yy_state_type;
#define yytext_ptr yytext_r
-static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
-static int yy_get_next_buffer (yyscan_t yyscanner );
-static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner );
+static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
+static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner);
+static int yy_get_next_buffer ( yyscan_t yyscanner );
+static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
@@ -348,7 +548,6 @@ static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner );
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
-
#define YY_NUM_RULES 54
#define YY_END_OF_BUFFER 55
/* This struct is not used in this scanner,
@@ -358,7 +557,7 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[210] =
+static const flex_int16_t yy_accept[210] =
{ 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
55, 49, 51, 50, 53, 1, 49, 33, 2, 47,
@@ -368,16 +567,16 @@ static yyconst flex_int16_t yy_accept[210] =
0, 0, 33, 33, 34, 36, 39, 49, 46, 46,
46, 46, 46, 46, 0, 52, 46, 0, 0, 0,
12, 0, 0, 0, 0, 0, 0, 49, 0, 11,
- 46, 0, 0, 5, 0, 0, 0, 29, 0, 0,
+ 46, 0, 0, 5, 0, 0, 0, 0, 29, 0,
33, 33, 33, 33, 0, 0, 40, 46, 46, 46,
46, 45, 12, 12, 0, 0, 0, 23, 0, 0,
0, 0, 0, 0, 6, 0, 0, 0, 0, 0,
0, 0, 0, 0, 46, 46, 46, 46, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 30, 31, 0, 0, 0, 0, 0, 0, 46, 46,
+ 0, 30, 31, 0, 0, 0, 0, 0, 46, 46,
46, 46, 0, 24, 25, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 32, 27, 0, 0, 20, 0,
+ 0, 0, 0, 0, 20, 32, 27, 0, 0, 0,
46, 46, 43, 46, 0, 26, 21, 0, 0, 0,
19, 0, 0, 18, 28, 0, 0, 41, 46, 46,
17, 22, 0, 7, 38, 7, 15, 0, 46, 46,
@@ -385,7 +584,7 @@ static yyconst flex_int16_t yy_accept[210] =
14, 16, 42, 44, 0, 0, 0, 13, 0
} ;
-static yyconst YY_CHAR yy_ec[256] =
+static const YY_CHAR yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
@@ -417,7 +616,7 @@ static yyconst YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
-static yyconst YY_CHAR yy_meta[50] =
+static const YY_CHAR yy_meta[50] =
{ 0,
1, 2, 2, 3, 4, 3, 3, 1, 1, 3,
3, 3, 3, 1, 3, 5, 3, 3, 1, 3,
@@ -426,40 +625,40 @@ static yyconst YY_CHAR yy_meta[50] =
7, 7, 7, 7, 7, 7, 7, 7, 7
} ;
-static yyconst flex_uint16_t yy_base[219] =
+static const flex_int16_t yy_base[219] =
{ 0,
- 0, 48, 0, 49, 513, 56, 52, 57, 62, 68,
- 515, 0, 583, 583, 509, 583, 97, 74, 583, 583,
- 583, 583, 491, 583, 423, 421, 0, 19, 40, 392,
- 36, 47, 86, 146, 88, 186, 413, 235, 275, 583,
- 407, 98, 583, 583, 0, 386, 583, 323, 65, 73,
- 81, 74, 127, 146, 583, 583, 583, 108, 0, 89,
- 120, 92, 362, 116, 161, 583, 0, 167, 371, 0,
- 168, 131, 146, 171, 81, 89, 352, 420, 353, 583,
- 0, 349, 178, 196, 175, 197, 188, 208, 196, 197,
- 256, 262, 324, 330, 337, 143, 0, 151, 220, 56,
-
- 305, 0, 336, 139, 225, 315, 305, 322, 318, 163,
- 320, 268, 266, 369, 583, 340, 347, 350, 350, 351,
- 357, 350, 357, 363, 140, 235, 359, 218, 362, 375,
- 379, 380, 381, 385, 384, 404, 405, 243, 235, 213,
- 583, 583, 405, 407, 410, 171, 410, 409, 419, 418,
- 423, 426, 311, 583, 583, 428, 429, 431, 173, 462,
- 435, 166, 145, 438, 583, 583, 441, 444, 583, 433,
- 448, 89, 0, 438, 450, 583, 583, 452, 457, 487,
- 583, 114, 0, 583, 583, 457, 462, 0, 465, 463,
- 583, 583, 468, 583, 583, 583, 583, 470, 471, 474,
-
- 500, 583, 0, 0, 505, 0, 65, 583, 583, 524,
- 531, 537, 540, 547, 554, 561, 568, 575
+ 0, 48, 0, 49, 464, 56, 52, 57, 62, 68,
+ 466, 0, 468, 468, 462, 468, 74, 81, 468, 468,
+ 468, 468, 447, 468, 442, 440, 0, 19, 41, 427,
+ 47, 41, 90, 119, 97, 158, 455, 207, 247, 468,
+ 454, 101, 468, 468, 0, 455, 468, 105, 430, 423,
+ 62, 67, 119, 151, 468, 468, 468, 121, 0, 90,
+ 93, 110, 431, 112, 142, 468, 0, 160, 295, 0,
+ 162, 411, 123, 102, 408, 405, 446, 344, 447, 468,
+ 0, 444, 170, 174, 420, 421, 132, 404, 95, 404,
+ 180, 186, 192, 228, 297, 397, 0, 168, 144, 52,
+
+ 411, 0, 204, 217, 397, 179, 390, 170, 389, 378,
+ 364, 390, 389, 230, 468, 363, 355, 337, 337, 334,
+ 335, 335, 330, 334, 187, 339, 267, 339, 327, 327,
+ 327, 324, 325, 325, 318, 319, 318, 354, 352, 323,
+ 327, 468, 468, 310, 307, 305, 297, 297, 275, 275,
+ 277, 279, 287, 468, 468, 286, 283, 273, 196, 307,
+ 200, 238, 234, 210, 468, 468, 468, 174, 171, 162,
+ 279, 182, 0, 269, 150, 468, 468, 137, 109, 323,
+ 468, 239, 0, 468, 468, 72, 71, 0, 283, 283,
+ 468, 468, 51, 468, 468, 468, 468, 37, 283, 288,
+
+ 330, 468, 0, 0, 331, 0, 52, 468, 468, 384,
+ 391, 397, 400, 407, 414, 421, 428, 435
} ;
-static yyconst flex_int16_t yy_def[219] =
+static const flex_int16_t yy_def[219] =
{ 0,
209, 1, 1, 1, 1, 1, 210, 210, 210, 210,
209, 211, 209, 209, 212, 209, 211, 209, 209, 209,
209, 209, 209, 209, 209, 211, 213, 213, 213, 213,
- 213, 213, 211, 213, 209, 209, 209, 214, 209, 209,
+ 213, 213, 211, 213, 209, 211, 209, 214, 209, 209,
209, 209, 209, 209, 211, 212, 209, 209, 209, 209,
209, 209, 209, 215, 209, 209, 209, 211, 213, 213,
213, 213, 213, 213, 209, 209, 34, 209, 209, 69,
@@ -482,7 +681,7 @@ static yyconst flex_int16_t yy_def[219] =
209, 209, 209, 209, 209, 209, 209, 209
} ;
-static yyconst flex_uint16_t yy_nxt[633] =
+static const flex_int16_t yy_nxt[518] =
{ 0,
12, 13, 14, 13, 13, 15, 16, 12, 17, 18,
19, 20, 21, 12, 22, 12, 23, 24, 12, 25,
@@ -491,72 +690,59 @@ static yyconst flex_uint16_t yy_nxt[633] =
27, 27, 28, 27, 29, 27, 27, 31, 32, 35,
35, 60, 35, 35, 41, 36, 36, 35, 37, 41,
35, 42, 43, 36, 41, 60, 42, 43, 44, 38,
- 41, 42, 61, 63, 44, 53, 53, 42, 53, 54,
- 39, 39, 64, 55, 63, 208, 61, 65, 66, 68,
- 65, 85, 68, 127, 64, 69, 39, 39, 48, 83,
-
- 84, 48, 83, 86, 127, 87, 90, 85, 88, 95,
- 110, 189, 95, 89, 97, 195, 195, 100, 86, 87,
- 90, 111, 49, 50, 88, 110, 51, 89, 53, 53,
- 97, 53, 54, 100, 52, 111, 55, 96, 49, 50,
- 104, 51, 102, 104, 98, 52, 45, 92, 53, 183,
- 92, 93, 96, 45, 45, 94, 99, 105, 102, 45,
- 98, 67, 65, 66, 45, 65, 45, 45, 68, 104,
- 182, 68, 104, 105, 69, 124, 106, 149, 107, 83,
- 84, 125, 83, 71, 45, 67, 45, 70, 149, 124,
- 70, 106, 107, 45, 45, 136, 125, 114, 108, 45,
-
- 114, 71, 116, 109, 45, 115, 45, 45, 168, 136,
- 179, 72, 73, 119, 108, 74, 75, 109, 116, 168,
- 122, 179, 123, 76, 45, 45, 117, 72, 73, 119,
- 74, 75, 118, 120, 76, 78, 122, 80, 123, 163,
- 121, 117, 78, 78, 118, 164, 126, 162, 78, 120,
- 78, 152, 129, 78, 121, 78, 78, 92, 53, 164,
- 92, 93, 126, 92, 53, 94, 92, 93, 129, 150,
- 139, 94, 138, 78, 78, 79, 79, 80, 79, 79,
+ 41, 42, 208, 61, 44, 48, 64, 42, 48, 202,
+ 39, 39, 53, 53, 63, 53, 54, 61, 64, 127,
+ 55, 65, 66, 201, 65, 63, 39, 39, 68, 49,
+
+ 127, 68, 83, 84, 69, 83, 48, 87, 88, 48,
+ 89, 50, 198, 90, 197, 97, 51, 98, 52, 45,
+ 53, 53, 95, 53, 54, 95, 45, 45, 55, 99,
+ 49, 97, 45, 98, 67, 100, 121, 45, 102, 45,
+ 45, 122, 50, 65, 66, 108, 65, 51, 109, 52,
+ 193, 100, 92, 53, 102, 92, 93, 45, 67, 70,
+ 94, 68, 70, 104, 68, 96, 104, 69, 106, 107,
+ 126, 83, 84, 71, 83, 114, 118, 71, 114, 119,
+ 192, 92, 53, 115, 92, 93, 126, 92, 53, 94,
+ 92, 93, 191, 92, 53, 94, 92, 93, 125, 72,
+
+ 73, 94, 74, 75, 189, 104, 76, 78, 104, 80,
+ 187, 133, 186, 125, 78, 78, 134, 185, 104, 103,
+ 78, 104, 78, 130, 149, 78, 131, 78, 78, 92,
+ 53, 114, 92, 93, 114, 149, 184, 94, 183, 115,
+ 195, 195, 182, 181, 179, 78, 78, 79, 79, 80,
79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
- 81, 79, 79, 79, 79, 79, 79, 81, 81, 81,
-
+ 79, 79, 81, 79, 79, 79, 79, 79, 79, 81,
81, 81, 81, 81, 81, 81, 81, 81, 81, 81,
- 81, 81, 81, 79, 81, 81, 81, 81, 81, 81,
- 81, 81, 81, 81, 48, 92, 53, 48, 92, 93,
- 132, 92, 53, 94, 92, 93, 128, 104, 95, 94,
- 104, 95, 135, 175, 130, 137, 132, 133, 49, 50,
- 131, 103, 51, 113, 134, 80, 112, 175, 135, 130,
- 52, 137, 131, 133, 49, 50, 96, 51, 134, 140,
- 114, 52, 70, 114, 141, 70, 142, 144, 115, 143,
- 146, 96, 145, 147, 140, 101, 103, 148, 47, 151,
- 141, 153, 142, 144, 143, 146, 72, 73, 145, 147,
-
- 74, 75, 154, 148, 151, 155, 153, 157, 76, 156,
- 158, 82, 72, 73, 159, 74, 75, 77, 154, 76,
- 78, 155, 80, 157, 156, 62, 158, 78, 78, 159,
- 160, 161, 165, 78, 166, 78, 167, 169, 78, 170,
- 78, 78, 58, 57, 171, 172, 160, 161, 165, 173,
- 166, 174, 167, 169, 170, 176, 177, 178, 78, 78,
- 171, 172, 181, 180, 184, 173, 180, 174, 185, 186,
- 187, 176, 177, 178, 188, 190, 191, 103, 181, 192,
- 184, 187, 193, 197, 185, 186, 190, 198, 180, 199,
- 188, 180, 191, 200, 201, 192, 202, 203, 193, 197,
-
- 204, 205, 103, 198, 205, 199, 205, 56, 200, 205,
- 201, 47, 202, 203, 209, 37, 204, 209, 206, 209,
- 209, 209, 209, 206, 40, 40, 40, 40, 40, 40,
- 40, 45, 209, 209, 209, 45, 45, 46, 46, 46,
- 46, 46, 46, 46, 59, 209, 59, 79, 79, 79,
+ 81, 81, 81, 81, 81, 79, 81, 81, 81, 81,
+ 81, 81, 81, 81, 81, 81, 70, 151, 95, 70,
+
+ 171, 95, 172, 173, 174, 188, 190, 199, 180, 203,
+ 103, 180, 151, 200, 204, 178, 171, 190, 172, 173,
+ 174, 188, 103, 199, 180, 203, 177, 180, 200, 176,
+ 204, 205, 205, 175, 205, 205, 72, 73, 103, 74,
+ 75, 96, 170, 76, 78, 169, 80, 168, 206, 206,
+ 167, 78, 78, 166, 165, 164, 163, 78, 162, 78,
+ 161, 160, 78, 159, 78, 78, 158, 157, 156, 155,
+ 154, 153, 152, 150, 148, 147, 146, 145, 144, 143,
+ 142, 141, 78, 78, 40, 40, 40, 40, 40, 40,
+ 40, 45, 140, 139, 138, 45, 45, 46, 46, 46,
+
+ 46, 46, 46, 46, 59, 137, 59, 79, 79, 79,
79, 79, 79, 79, 91, 91, 91, 91, 91, 91,
- 91, 194, 194, 194, 209, 194, 194, 194, 196, 209,
- 196, 209, 196, 196, 196, 207, 207, 207, 207, 207,
- 209, 207, 11, 209, 209, 209, 209, 209, 209, 209,
+ 91, 194, 194, 194, 136, 194, 194, 194, 196, 135,
+ 196, 132, 196, 196, 196, 207, 207, 207, 207, 207,
+ 129, 207, 128, 124, 123, 120, 117, 116, 113, 80,
+ 112, 111, 110, 105, 101, 86, 85, 47, 82, 77,
+ 62, 58, 57, 56, 47, 209, 37, 11, 209, 209,
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
-
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
+
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
- 209, 209
+ 209, 209, 209, 209, 209, 209, 209
} ;
-static yyconst flex_int16_t yy_chk[633] =
+static const flex_int16_t yy_chk[518] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -565,69 +751,56 @@ static yyconst flex_int16_t yy_chk[633] =
1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
4, 28, 2, 4, 7, 2, 4, 6, 6, 8,
6, 7, 7, 6, 9, 28, 8, 8, 9, 6,
- 10, 9, 29, 31, 10, 18, 18, 10, 18, 18,
- 6, 6, 32, 18, 31, 207, 29, 33, 33, 35,
- 33, 49, 35, 100, 32, 35, 6, 6, 17, 42,
-
- 42, 17, 42, 50, 100, 50, 52, 49, 51, 58,
- 75, 172, 58, 51, 60, 182, 182, 62, 50, 50,
- 52, 76, 17, 17, 51, 75, 17, 51, 53, 53,
- 60, 53, 53, 62, 17, 76, 53, 58, 17, 17,
- 104, 17, 64, 104, 61, 17, 34, 54, 54, 163,
- 54, 54, 58, 34, 34, 54, 61, 72, 64, 34,
- 61, 34, 65, 65, 34, 65, 34, 34, 68, 71,
- 162, 68, 71, 72, 68, 96, 73, 125, 73, 83,
- 83, 98, 83, 71, 34, 34, 36, 36, 125, 96,
- 36, 73, 73, 36, 36, 110, 98, 84, 74, 36,
-
- 84, 36, 85, 74, 36, 84, 36, 36, 146, 110,
- 159, 36, 36, 87, 74, 36, 36, 74, 85, 146,
- 89, 159, 90, 36, 36, 36, 86, 36, 36, 87,
- 36, 36, 86, 88, 36, 38, 89, 38, 90, 139,
- 88, 86, 38, 38, 86, 140, 99, 138, 38, 88,
- 38, 128, 105, 38, 88, 38, 38, 91, 91, 140,
- 91, 91, 99, 92, 92, 91, 92, 92, 105, 126,
- 113, 92, 112, 38, 38, 39, 39, 39, 39, 39,
+ 10, 9, 207, 29, 10, 17, 32, 10, 17, 198,
+ 6, 6, 18, 18, 31, 18, 18, 29, 32, 100,
+ 18, 33, 33, 193, 33, 31, 6, 6, 35, 17,
+
+ 100, 35, 42, 42, 35, 42, 48, 51, 51, 48,
+ 52, 17, 187, 52, 186, 60, 17, 61, 17, 34,
+ 53, 53, 58, 53, 53, 58, 34, 34, 53, 61,
+ 48, 60, 34, 61, 34, 62, 89, 34, 64, 34,
+ 34, 89, 48, 65, 65, 74, 65, 48, 74, 48,
+ 179, 62, 54, 54, 64, 54, 54, 34, 34, 36,
+ 54, 68, 36, 71, 68, 58, 71, 68, 73, 73,
+ 99, 83, 83, 36, 83, 84, 87, 71, 84, 87,
+ 178, 91, 91, 84, 91, 91, 99, 92, 92, 91,
+ 92, 92, 175, 93, 93, 92, 93, 93, 98, 36,
+
+ 36, 93, 36, 36, 172, 103, 36, 38, 103, 38,
+ 170, 108, 169, 98, 38, 38, 108, 168, 104, 103,
+ 38, 104, 38, 106, 125, 38, 106, 38, 38, 94,
+ 94, 114, 94, 94, 114, 125, 164, 94, 163, 114,
+ 182, 182, 162, 161, 159, 38, 38, 39, 39, 39,
39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
-
39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
- 39, 39, 39, 39, 48, 93, 93, 48, 93, 93,
- 107, 94, 94, 93, 94, 94, 101, 103, 95, 94,
- 103, 95, 109, 153, 106, 111, 107, 108, 48, 48,
- 106, 103, 48, 82, 108, 79, 77, 153, 109, 106,
- 48, 111, 106, 108, 48, 48, 95, 48, 108, 116,
- 114, 48, 69, 114, 117, 69, 118, 120, 114, 119,
- 122, 95, 121, 123, 116, 63, 69, 124, 46, 127,
- 117, 129, 118, 120, 119, 122, 69, 69, 121, 123,
-
- 69, 69, 130, 124, 127, 131, 129, 133, 69, 132,
- 134, 41, 69, 69, 135, 69, 69, 37, 130, 69,
- 78, 131, 78, 133, 132, 30, 134, 78, 78, 135,
- 136, 137, 143, 78, 144, 78, 145, 147, 78, 148,
- 78, 78, 26, 25, 149, 150, 136, 137, 143, 151,
- 144, 152, 145, 147, 148, 156, 157, 158, 78, 78,
- 149, 150, 161, 160, 164, 151, 160, 152, 167, 168,
- 170, 156, 157, 158, 171, 174, 175, 160, 161, 178,
- 164, 170, 179, 186, 167, 168, 174, 187, 180, 189,
- 171, 180, 175, 190, 193, 178, 198, 199, 179, 186,
-
- 200, 201, 180, 187, 201, 189, 205, 23, 190, 205,
- 193, 15, 198, 199, 11, 5, 200, 0, 201, 0,
- 0, 0, 0, 205, 210, 210, 210, 210, 210, 210,
- 210, 211, 0, 0, 0, 211, 211, 212, 212, 212,
- 212, 212, 212, 212, 213, 0, 213, 214, 214, 214,
+ 39, 39, 39, 39, 39, 39, 69, 127, 95, 69,
+
+ 149, 95, 150, 151, 152, 171, 174, 189, 160, 199,
+ 69, 160, 127, 190, 200, 158, 149, 174, 150, 151,
+ 152, 171, 160, 189, 180, 199, 157, 180, 190, 156,
+ 200, 201, 205, 153, 201, 205, 69, 69, 180, 69,
+ 69, 95, 148, 69, 78, 147, 78, 146, 201, 205,
+ 145, 78, 78, 144, 141, 140, 139, 78, 138, 78,
+ 137, 136, 78, 135, 78, 78, 134, 133, 132, 131,
+ 130, 129, 128, 126, 124, 123, 122, 121, 120, 119,
+ 118, 117, 78, 78, 210, 210, 210, 210, 210, 210,
+ 210, 211, 116, 113, 112, 211, 211, 212, 212, 212,
+
+ 212, 212, 212, 212, 213, 111, 213, 214, 214, 214,
214, 214, 214, 214, 215, 215, 215, 215, 215, 215,
- 215, 216, 216, 216, 0, 216, 216, 216, 217, 0,
- 217, 0, 217, 217, 217, 218, 218, 218, 218, 218,
- 0, 218, 209, 209, 209, 209, 209, 209, 209, 209,
+ 215, 216, 216, 216, 110, 216, 216, 216, 217, 109,
+ 217, 107, 217, 217, 217, 218, 218, 218, 218, 218,
+ 105, 218, 101, 96, 90, 88, 86, 85, 82, 79,
+ 77, 76, 75, 72, 63, 50, 49, 46, 41, 37,
+ 30, 26, 25, 23, 15, 11, 5, 209, 209, 209,
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
-
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
+
209, 209, 209, 209, 209, 209, 209, 209, 209, 209,
- 209, 209
+ 209, 209, 209, 209, 209, 209, 209
} ;
/* The intent behind this definition is that it'll catch
@@ -637,8 +810,6 @@ static yyconst flex_int16_t yy_chk[633] =
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
-#line 1 "cmFortranLexer.in.l"
-#line 2 "cmFortranLexer.in.l"
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
/*-------------------------------------------------------------------------
@@ -657,18 +828,18 @@ This file must be translated to C++ and modified to build everywhere.
Run flex >= 2.6 like this:
- flex -i --nounistd -DFLEXINT_H --prefix=cmFortran_yy --header-file=cmFortranLexer.h -ocmFortranLexer.cxx cmFortranLexer.in.l
+ flex -i --nounistd -DFLEXINT_H --noline --header-file=cmFortranLexer.h -ocmFortranLexer.cxx cmFortranLexer.in.l
Modify cmFortranLexer.cxx:
- - remove trailing whitespace: sed -i 's/\s*$//' cmFortranLexer.h cmFortranLexer.cxx
- - remove blank lines at end of file
- - #include "cmStandardLexer.h" at the top
- - add cast in cmFortran_yy_scan_bytes for loop condition of _yybytes_len to size_t
-
+ - remove trailing whitespace: sed -i 's/\s*$//' cmFortranLexer.h cmFortranLexer.cxx
+ - remove blank lines at end of file: sed -i '${/^$/d;}' cmFortranLexer.h cmFortranLexer.cxx
+ - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmFortranLexer.cxx
*/
/* IWYU pragma: no_forward_declare yyguts_t */
+#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+
#undef YY_NO_UNPUT
#define cmFortranLexer_cxx
@@ -677,16 +848,13 @@ Modify cmFortranLexer.cxx:
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
- { result = cmFortranParser_Input(yyextra, buf, max_size); }
+ do { result = cmFortranParser_Input(yyextra, buf, max_size); } while (0)
/* Include the set of tokens from the parser. */
#include "cmFortranParserTokens.h"
/*--------------------------------------------------------------------------*/
-
-#line 688 "cmFortranLexer.cxx"
-
#define INITIAL 0
#define free_fmt 1
#define fixed_fmt 2
@@ -731,44 +899,44 @@ struct yyguts_t
}; /* end struct yyguts_t */
-static int yy_init_globals (yyscan_t yyscanner );
+static int yy_init_globals ( yyscan_t yyscanner );
-int cmFortran_yylex_init (yyscan_t* scanner);
+int yylex_init (yyscan_t* scanner);
-int cmFortran_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
-int cmFortran_yylex_destroy (yyscan_t yyscanner );
+int yylex_destroy ( yyscan_t yyscanner );
-int cmFortran_yyget_debug (yyscan_t yyscanner );
+int yyget_debug ( yyscan_t yyscanner );
-void cmFortran_yyset_debug (int debug_flag ,yyscan_t yyscanner );
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
-YY_EXTRA_TYPE cmFortran_yyget_extra (yyscan_t yyscanner );
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
-void cmFortran_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
-FILE *cmFortran_yyget_in (yyscan_t yyscanner );
+FILE *yyget_in ( yyscan_t yyscanner );
-void cmFortran_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
+void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
-FILE *cmFortran_yyget_out (yyscan_t yyscanner );
+FILE *yyget_out ( yyscan_t yyscanner );
-void cmFortran_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
+void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
- int cmFortran_yyget_leng (yyscan_t yyscanner );
+ int yyget_leng ( yyscan_t yyscanner );
-char *cmFortran_yyget_text (yyscan_t yyscanner );
+char *yyget_text ( yyscan_t yyscanner );
-int cmFortran_yyget_lineno (yyscan_t yyscanner );
+int yyget_lineno ( yyscan_t yyscanner );
-void cmFortran_yyset_lineno (int _line_number ,yyscan_t yyscanner );
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
-int cmFortran_yyget_column (yyscan_t yyscanner );
+int yyget_column ( yyscan_t yyscanner );
-void cmFortran_yyset_column (int _column_no ,yyscan_t yyscanner );
+void yyset_column ( int _column_no , yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -776,32 +944,31 @@ void cmFortran_yyset_column (int _column_no ,yyscan_t yyscanner );
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int cmFortran_yywrap (yyscan_t yyscanner );
+extern "C" int yywrap ( yyscan_t yyscanner );
#else
-extern int cmFortran_yywrap (yyscan_t yyscanner );
+extern int yywrap ( yyscan_t yyscanner );
#endif
#endif
#ifndef YY_NO_UNPUT
- static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner);
+ static void yyunput ( int c, char *buf_ptr , yyscan_t yyscanner);
#endif
#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
-
#ifdef __cplusplus
-static int yyinput (yyscan_t yyscanner );
+static int yyinput ( yyscan_t yyscanner );
#else
-static int input (yyscan_t yyscanner );
+static int input ( yyscan_t yyscanner );
#endif
#endif
@@ -832,7 +999,7 @@ static int input (yyscan_t yyscanner );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
- size_t n; \
+ int n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@@ -845,7 +1012,7 @@ static int input (yyscan_t yyscanner );
else \
{ \
errno=0; \
- while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
@@ -886,9 +1053,9 @@ static int input (yyscan_t yyscanner );
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-extern int cmFortran_yylex (yyscan_t yyscanner);
+extern int yylex (yyscan_t yyscanner);
-#define YY_DECL int cmFortran_yylex (yyscan_t yyscanner)
+#define YY_DECL int yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */
/* Code executed at the beginning of each rule, after yytext and yyleng
@@ -936,19 +1103,15 @@ YY_DECL
yyout = stdout;
if ( ! YY_CURRENT_BUFFER ) {
- cmFortran_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
- cmFortran_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
}
- cmFortran_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
}
{
-#line 56 "cmFortranLexer.in.l"
-
-
-#line 951 "cmFortranLexer.cxx"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
@@ -977,12 +1140,12 @@ yy_match:
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 210 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
- while ( yy_base[yy_current_state] != 583 );
+ while ( yy_base[yy_current_state] != 468 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -1008,7 +1171,6 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
-#line 58 "cmFortranLexer.in.l"
{
cmFortranParser_StringStart(yyextra);
cmFortranParser_SetOldStartcond(yyextra, YY_START);
@@ -1017,7 +1179,6 @@ YY_RULE_SETUP
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 64 "cmFortranLexer.in.l"
{
cmFortranParser_StringStart(yyextra);
cmFortranParser_SetOldStartcond(yyextra, YY_START);
@@ -1025,10 +1186,8 @@ YY_RULE_SETUP
}
YY_BREAK
case 3:
-#line 71 "cmFortranLexer.in.l"
case 4:
YY_RULE_SETUP
-#line 71 "cmFortranLexer.in.l"
{
BEGIN(cmFortranParser_GetOldStartcond(yyextra) );
yylvalp->string = strdup(cmFortranParser_StringEnd(yyextra));
@@ -1037,17 +1196,14 @@ YY_RULE_SETUP
YY_BREAK
case 5:
/* rule 5 can match eol */
-#line 78 "cmFortranLexer.in.l"
case 6:
/* rule 6 can match eol */
YY_RULE_SETUP
-#line 78 "cmFortranLexer.in.l"
/* Ignore (continued strings, free fmt) */
YY_BREAK
case 7:
/* rule 7 can match eol */
YY_RULE_SETUP
-#line 80 "cmFortranLexer.in.l"
{
if (cmFortranParser_GetOldStartcond(yyextra) == fixed_fmt)
; /* Ignore (cont. strings, fixed fmt) */
@@ -1060,7 +1216,6 @@ YY_RULE_SETUP
case 8:
/* rule 8 can match eol */
YY_RULE_SETUP
-#line 90 "cmFortranLexer.in.l"
{
unput ('\n');
BEGIN(INITIAL);
@@ -1069,7 +1224,6 @@ YY_RULE_SETUP
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 96 "cmFortranLexer.in.l"
{
cmFortranParser_StringAppend(yyextra, yytext[0]);
}
@@ -1077,24 +1231,20 @@ YY_RULE_SETUP
case 10:
/* rule 10 can match eol */
YY_RULE_SETUP
-#line 100 "cmFortranLexer.in.l"
{ return EOSTMT; } /* Treat comments like */
YY_BREAK
case 11:
/* rule 11 can match eol */
YY_RULE_SETUP
-#line 101 "cmFortranLexer.in.l"
{ return EOSTMT; } /* empty lines */
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 103 "cmFortranLexer.in.l"
{ return CPP_LINE_DIRECTIVE; }
YY_BREAK
case 13:
/* rule 13 can match eol */
YY_RULE_SETUP
-#line 104 "cmFortranLexer.in.l"
{
yytext[yyleng-1] = 0;
yylvalp->string = strdup(strchr(yytext, '<')+1);
@@ -1103,171 +1253,138 @@ YY_RULE_SETUP
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 109 "cmFortranLexer.in.l"
{ return CPP_INCLUDE; }
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 110 "cmFortranLexer.in.l"
{ return F90PPR_INCLUDE; }
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 111 "cmFortranLexer.in.l"
{ return COCO_INCLUDE; }
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 113 "cmFortranLexer.in.l"
{ return CPP_DEFINE; }
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 114 "cmFortranLexer.in.l"
{ return F90PPR_DEFINE; }
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 116 "cmFortranLexer.in.l"
{ return CPP_UNDEF; }
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 117 "cmFortranLexer.in.l"
{ return F90PPR_UNDEF; }
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 119 "cmFortranLexer.in.l"
{ return CPP_IFDEF; }
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 120 "cmFortranLexer.in.l"
{ return CPP_IFNDEF; }
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 121 "cmFortranLexer.in.l"
{ return CPP_IF; }
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 122 "cmFortranLexer.in.l"
{ return CPP_ELIF; }
YY_BREAK
case 25:
YY_RULE_SETUP
-#line 123 "cmFortranLexer.in.l"
{ return CPP_ELSE; }
YY_BREAK
case 26:
YY_RULE_SETUP
-#line 124 "cmFortranLexer.in.l"
{ return CPP_ENDIF; }
YY_BREAK
case 27:
YY_RULE_SETUP
-#line 126 "cmFortranLexer.in.l"
{ return F90PPR_IFDEF; }
YY_BREAK
case 28:
YY_RULE_SETUP
-#line 127 "cmFortranLexer.in.l"
{ return F90PPR_IFNDEF; }
YY_BREAK
case 29:
YY_RULE_SETUP
-#line 128 "cmFortranLexer.in.l"
{ return F90PPR_IF; }
YY_BREAK
case 30:
YY_RULE_SETUP
-#line 129 "cmFortranLexer.in.l"
{ return F90PPR_ELIF; }
YY_BREAK
case 31:
YY_RULE_SETUP
-#line 130 "cmFortranLexer.in.l"
{ return F90PPR_ELSE; }
YY_BREAK
case 32:
YY_RULE_SETUP
-#line 131 "cmFortranLexer.in.l"
{ return F90PPR_ENDIF; }
YY_BREAK
/* Line continuations, possible involving comments. */
case 33:
/* rule 33 can match eol */
YY_RULE_SETUP
-#line 134 "cmFortranLexer.in.l"
YY_BREAK
case 34:
/* rule 34 can match eol */
YY_RULE_SETUP
-#line 135 "cmFortranLexer.in.l"
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 137 "cmFortranLexer.in.l"
{ return COMMA; }
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 139 "cmFortranLexer.in.l"
{ return DCOLON; }
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 140 "cmFortranLexer.in.l"
{ return COLON; }
YY_BREAK
case 38:
/* rule 38 can match eol */
YY_RULE_SETUP
-#line 142 "cmFortranLexer.in.l"
{ return GARBAGE; }
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 144 "cmFortranLexer.in.l"
{ return ASSIGNMENT_OP; }
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 146 "cmFortranLexer.in.l"
{ return END; }
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 147 "cmFortranLexer.in.l"
{ return INCLUDE; }
YY_BREAK
case 42:
YY_RULE_SETUP
-#line 148 "cmFortranLexer.in.l"
{ return INTERFACE; }
YY_BREAK
case 43:
YY_RULE_SETUP
-#line 149 "cmFortranLexer.in.l"
{ return MODULE; }
YY_BREAK
case 44:
YY_RULE_SETUP
-#line 150 "cmFortranLexer.in.l"
{ return SUBMODULE; }
YY_BREAK
case 45:
YY_RULE_SETUP
-#line 151 "cmFortranLexer.in.l"
{ return USE; }
YY_BREAK
case 46:
YY_RULE_SETUP
-#line 153 "cmFortranLexer.in.l"
{
yylvalp->string = strdup(yytext);
return WORD;
@@ -1275,39 +1392,32 @@ YY_RULE_SETUP
YY_BREAK
case 47:
YY_RULE_SETUP
-#line 158 "cmFortranLexer.in.l"
{ return LPAREN; }
YY_BREAK
case 48:
YY_RULE_SETUP
-#line 159 "cmFortranLexer.in.l"
{ return RPAREN; }
YY_BREAK
case 49:
YY_RULE_SETUP
-#line 161 "cmFortranLexer.in.l"
{ return GARBAGE; }
YY_BREAK
case 50:
/* rule 50 can match eol */
YY_RULE_SETUP
-#line 163 "cmFortranLexer.in.l"
{ return EOSTMT; }
YY_BREAK
case 51:
YY_RULE_SETUP
-#line 166 "cmFortranLexer.in.l"
/* Ignore */
YY_BREAK
case 52:
/* rule 52 can match eol */
YY_RULE_SETUP
-#line 167 "cmFortranLexer.in.l"
/* Ignore line-endings preceded by \ */
YY_BREAK
case 53:
YY_RULE_SETUP
-#line 169 "cmFortranLexer.in.l"
{ return *yytext; }
YY_BREAK
case YY_STATE_EOF(INITIAL):
@@ -1315,7 +1425,6 @@ case YY_STATE_EOF(free_fmt):
case YY_STATE_EOF(fixed_fmt):
case YY_STATE_EOF(str_sq):
case YY_STATE_EOF(str_dq):
-#line 171 "cmFortranLexer.in.l"
{
if(!cmFortranParser_FilePop(yyextra) )
{
@@ -1325,10 +1434,8 @@ case YY_STATE_EOF(str_dq):
YY_BREAK
case 54:
YY_RULE_SETUP
-#line 178 "cmFortranLexer.in.l"
ECHO;
YY_BREAK
-#line 1331 "cmFortranLexer.cxx"
case YY_END_OF_BUFFER:
{
@@ -1344,7 +1451,7 @@ ECHO;
/* We're scanning a new file or input source. It's
* possible that this happened because the user
* just pointed yyin at a new source and called
- * cmFortran_yylex(). If so, then we have to assure
+ * yylex(). If so, then we have to assure
* consistency between YY_CURRENT_BUFFER and our
* globals. Here is the right place to do so, because
* this is the first action (other than possibly a
@@ -1404,7 +1511,7 @@ ECHO;
{
yyg->yy_did_buffer_switch_on_eof = 0;
- if ( cmFortran_yywrap(yyscanner ) )
+ if ( yywrap( yyscanner ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
@@ -1458,7 +1565,7 @@ ECHO;
} /* end of action switch */
} /* end of scanning one token */
} /* end of user's declarations */
-} /* end of cmFortran_yylex */
+} /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer
*
@@ -1472,7 +1579,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = yyg->yytext_ptr;
- yy_size_t number_to_move, i;
+ int number_to_move, i;
int ret_val;
if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
@@ -1501,7 +1608,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
/* Try to read more data. */
/* First move last chars to start of buffer. */
- number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
+ number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@@ -1537,7 +1644,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
- cmFortran_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
+ yyrealloc( (void *) b->yy_ch_buf,
+ (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
}
else
/* Can't grow it, we don't own it. */
@@ -1569,7 +1677,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
- cmFortran_yyrestart(yyin ,yyscanner);
+ yyrestart( yyin , yyscanner);
}
else
@@ -1583,12 +1691,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
ret_val = EOB_ACT_CONTINUE_SCAN;
- if ((int) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cmFortran_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
+ (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ /* "- 2" to take care of EOB's */
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
}
yyg->yy_n_chars += number_to_move;
@@ -1623,9 +1734,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 210 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
}
return yy_current_state;
@@ -1652,9 +1763,9 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 210 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 209);
(void)yyg;
@@ -1728,7 +1839,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
{ /* need more input */
- int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+ int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
++yyg->yy_c_buf_p;
switch ( yy_get_next_buffer( yyscanner ) )
@@ -1745,13 +1856,13 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
*/
/* Reset buffer status. */
- cmFortran_yyrestart(yyin ,yyscanner);
+ yyrestart( yyin , yyscanner);
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
- if ( cmFortran_yywrap(yyscanner ) )
+ if ( yywrap( yyscanner ) )
return 0;
if ( ! yyg->yy_did_buffer_switch_on_eof )
@@ -1785,34 +1896,34 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @note This function does not reset the start condition to @c INITIAL .
*/
- void cmFortran_yyrestart (FILE * input_file , yyscan_t yyscanner)
+ void yyrestart (FILE * input_file , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! YY_CURRENT_BUFFER ){
- cmFortran_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
- cmFortran_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
}
- cmFortran_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
- cmFortran_yy_load_buffer_state(yyscanner );
+ yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
+ yy_load_buffer_state( yyscanner );
}
/** Switch to a different input buffer.
* @param new_buffer The new input buffer.
* @param yyscanner The scanner object.
*/
- void cmFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* TODO. We should be able to replace this entire function body
* with
- * cmFortran_yypop_buffer_state();
- * cmFortran_yypush_buffer_state(new_buffer);
+ * yypop_buffer_state();
+ * yypush_buffer_state(new_buffer);
*/
- cmFortran_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
if ( YY_CURRENT_BUFFER == new_buffer )
return;
@@ -1825,17 +1936,17 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- cmFortran_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
/* We don't actually know whether we did this switch during
- * EOF (cmFortran_yywrap()) processing, but the only time this flag
- * is looked at is after cmFortran_yywrap() is called, so it's safe
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
* to go ahead and always set it.
*/
yyg->yy_did_buffer_switch_on_eof = 1;
}
-static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner)
+static void yy_load_buffer_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
@@ -1850,35 +1961,35 @@ static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the allocated buffer state.
*/
- YY_BUFFER_STATE cmFortran_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
+ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
- b = (YY_BUFFER_STATE) cmFortran_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in cmFortran_yy_create_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
- b->yy_buf_size = (yy_size_t)size;
+ b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
- b->yy_ch_buf = (char *) cmFortran_yyalloc(b->yy_buf_size + 2 ,yyscanner );
+ b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in cmFortran_yy_create_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
- cmFortran_yy_init_buffer(b,file ,yyscanner);
+ yy_init_buffer( b, file , yyscanner);
return b;
}
/** Destroy the buffer.
- * @param b a buffer created with cmFortran_yy_create_buffer()
+ * @param b a buffer created with yy_create_buffer()
* @param yyscanner The scanner object.
*/
- void cmFortran_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+ void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -1889,28 +2000,28 @@ static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner)
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
- cmFortran_yyfree((void *) b->yy_ch_buf ,yyscanner );
+ yyfree( (void *) b->yy_ch_buf , yyscanner );
- cmFortran_yyfree((void *) b ,yyscanner );
+ yyfree( (void *) b , yyscanner );
}
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
- * such as during a cmFortran_yyrestart() or at EOF.
+ * such as during a yyrestart() or at EOF.
*/
- static void cmFortran_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
+ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
{
int oerrno = errno;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- cmFortran_yy_flush_buffer(b ,yyscanner);
+ yy_flush_buffer( b , yyscanner);
b->yy_input_file = file;
b->yy_fill_buffer = 1;
- /* If b is the current buffer, then cmFortran_yy_init_buffer was _probably_
- * called from cmFortran_yyrestart() or through yy_get_next_buffer.
+ /* If b is the current buffer, then yy_init_buffer was _probably_
+ * called from yyrestart() or through yy_get_next_buffer.
* In that case, we don't want to reset the lineno or column.
*/
if (b != YY_CURRENT_BUFFER){
@@ -1927,7 +2038,7 @@ static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner)
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
* @param yyscanner The scanner object.
*/
- void cmFortran_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+ void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! b )
@@ -1948,7 +2059,7 @@ static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner)
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
- cmFortran_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
}
/** Pushes the new state onto the stack. The new state becomes
@@ -1957,15 +2068,15 @@ static void cmFortran_yy_load_buffer_state (yyscan_t yyscanner)
* @param new_buffer The new state.
* @param yyscanner The scanner object.
*/
-void cmFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (new_buffer == NULL)
return;
- cmFortran_yyensure_buffer_stack(yyscanner);
+ yyensure_buffer_stack(yyscanner);
- /* This block is copied from cmFortran_yy_switch_to_buffer. */
+ /* This block is copied from yy_switch_to_buffer. */
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
@@ -1979,8 +2090,8 @@ void cmFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscan
yyg->yy_buffer_stack_top++;
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- /* copied from cmFortran_yy_switch_to_buffer. */
- cmFortran_yy_load_buffer_state(yyscanner );
+ /* copied from yy_switch_to_buffer. */
+ yy_load_buffer_state( yyscanner );
yyg->yy_did_buffer_switch_on_eof = 1;
}
@@ -1988,19 +2099,19 @@ void cmFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscan
* The next element becomes the new top.
* @param yyscanner The scanner object.
*/
-void cmFortran_yypop_buffer_state (yyscan_t yyscanner)
+void yypop_buffer_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!YY_CURRENT_BUFFER)
return;
- cmFortran_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
+ yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
YY_CURRENT_BUFFER_LVALUE = NULL;
if (yyg->yy_buffer_stack_top > 0)
--yyg->yy_buffer_stack_top;
if (YY_CURRENT_BUFFER) {
- cmFortran_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
yyg->yy_did_buffer_switch_on_eof = 1;
}
}
@@ -2008,9 +2119,9 @@ void cmFortran_yypop_buffer_state (yyscan_t yyscanner)
/* Allocates the stack if it does not exist.
* Guarantees space for at least one push.
*/
-static void cmFortran_yyensure_buffer_stack (yyscan_t yyscanner)
+static void yyensure_buffer_stack (yyscan_t yyscanner)
{
- int num_to_alloc;
+ yy_size_t num_to_alloc;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!yyg->yy_buffer_stack) {
@@ -2020,11 +2131,11 @@ static void cmFortran_yyensure_buffer_stack (yyscan_t yyscanner)
* immediate realloc on the next call.
*/
num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
- yyg->yy_buffer_stack = (struct yy_buffer_state**)cmFortran_yyalloc
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
- YY_FATAL_ERROR( "out of dynamic memory in cmFortran_yyensure_buffer_stack()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
@@ -2039,12 +2150,12 @@ static void cmFortran_yyensure_buffer_stack (yyscan_t yyscanner)
yy_size_t grow_size = 8 /* arbitrary grow size */;
num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
- yyg->yy_buffer_stack = (struct yy_buffer_state**)cmFortran_yyrealloc
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
(yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
- YY_FATAL_ERROR( "out of dynamic memory in cmFortran_yyensure_buffer_stack()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -2058,7 +2169,7 @@ static void cmFortran_yyensure_buffer_stack (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE cmFortran_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
@@ -2068,11 +2179,11 @@ YY_BUFFER_STATE cmFortran_yy_scan_buffer (char * base, yy_size_t size , yyscan
/* They forgot to leave room for the EOB's. */
return NULL;
- b = (YY_BUFFER_STATE) cmFortran_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in cmFortran_yy_scan_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = NULL;
@@ -2082,53 +2193,53 @@ YY_BUFFER_STATE cmFortran_yy_scan_buffer (char * base, yy_size_t size , yyscan
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
- cmFortran_yy_switch_to_buffer(b ,yyscanner );
+ yy_switch_to_buffer( b , yyscanner );
return b;
}
-/** Setup the input buffer state to scan a string. The next call to cmFortran_yylex() will
+/** Setup the input buffer state to scan a string. The next call to yylex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
- * cmFortran_yy_scan_bytes() instead.
+ * yy_scan_bytes() instead.
*/
-YY_BUFFER_STATE cmFortran_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
{
- return cmFortran_yy_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner);
+ return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
}
-/** Setup the input buffer state to scan the given bytes. The next call to cmFortran_yylex() will
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE cmFortran_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
- yy_size_t i;
+ int i;
/* Get memory for full buffer, including space for trailing EOB's. */
- n = (yy_size_t) _yybytes_len + 2;
- buf = (char *) cmFortran_yyalloc(n ,yyscanner );
+ n = (yy_size_t) (_yybytes_len + 2);
+ buf = (char *) yyalloc( n , yyscanner );
if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in cmFortran_yy_scan_bytes()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
- for ( i = 0; i < (size_t)_yybytes_len; ++i )
+ for ( i = 0; i < _yybytes_len; ++i )
buf[i] = yybytes[i];
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
- b = cmFortran_yy_scan_buffer(buf,n ,yyscanner);
+ b = yy_scan_buffer( buf, n , yyscanner);
if ( ! b )
- YY_FATAL_ERROR( "bad buffer in cmFortran_yy_scan_bytes()" );
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
/* It's okay to grow etc. this buffer, and we should throw it
* away when we're done.
@@ -2142,11 +2253,11 @@ YY_BUFFER_STATE cmFortran_yy_scan_bytes (yyconst char * yybytes, int _yybytes_
#define YY_EXIT_FAILURE 2
#endif
-static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
+static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
- (void) fprintf( stderr, "%s\n", msg );
+ fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
@@ -2172,7 +2283,7 @@ static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
/** Get the user-defined data for this scanner.
* @param yyscanner The scanner object.
*/
-YY_EXTRA_TYPE cmFortran_yyget_extra (yyscan_t yyscanner)
+YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyextra;
@@ -2181,7 +2292,7 @@ YY_EXTRA_TYPE cmFortran_yyget_extra (yyscan_t yyscanner)
/** Get the current line number.
* @param yyscanner The scanner object.
*/
-int cmFortran_yyget_lineno (yyscan_t yyscanner)
+int yyget_lineno (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -2194,7 +2305,7 @@ int cmFortran_yyget_lineno (yyscan_t yyscanner)
/** Get the current column number.
* @param yyscanner The scanner object.
*/
-int cmFortran_yyget_column (yyscan_t yyscanner)
+int yyget_column (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -2207,7 +2318,7 @@ int cmFortran_yyget_column (yyscan_t yyscanner)
/** Get the input stream.
* @param yyscanner The scanner object.
*/
-FILE *cmFortran_yyget_in (yyscan_t yyscanner)
+FILE *yyget_in (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyin;
@@ -2216,7 +2327,7 @@ FILE *cmFortran_yyget_in (yyscan_t yyscanner)
/** Get the output stream.
* @param yyscanner The scanner object.
*/
-FILE *cmFortran_yyget_out (yyscan_t yyscanner)
+FILE *yyget_out (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyout;
@@ -2225,7 +2336,7 @@ FILE *cmFortran_yyget_out (yyscan_t yyscanner)
/** Get the length of the current token.
* @param yyscanner The scanner object.
*/
-int cmFortran_yyget_leng (yyscan_t yyscanner)
+int yyget_leng (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyleng;
@@ -2235,7 +2346,7 @@ int cmFortran_yyget_leng (yyscan_t yyscanner)
* @param yyscanner The scanner object.
*/
-char *cmFortran_yyget_text (yyscan_t yyscanner)
+char *yyget_text (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yytext;
@@ -2245,7 +2356,7 @@ char *cmFortran_yyget_text (yyscan_t yyscanner)
* @param user_defined The data to be associated with this scanner.
* @param yyscanner The scanner object.
*/
-void cmFortran_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
+void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyextra = user_defined ;
@@ -2255,13 +2366,13 @@ void cmFortran_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
* @param _line_number line number
* @param yyscanner The scanner object.
*/
-void cmFortran_yyset_lineno (int _line_number , yyscan_t yyscanner)
+void yyset_lineno (int _line_number , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* lineno is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "cmFortran_yyset_lineno called with no buffer" );
+ YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
yylineno = _line_number;
}
@@ -2270,13 +2381,13 @@ void cmFortran_yyset_lineno (int _line_number , yyscan_t yyscanner)
* @param _column_no column number
* @param yyscanner The scanner object.
*/
-void cmFortran_yyset_column (int _column_no , yyscan_t yyscanner)
+void yyset_column (int _column_no , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* column is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "cmFortran_yyset_column called with no buffer" );
+ YY_FATAL_ERROR( "yyset_column called with no buffer" );
yycolumn = _column_no;
}
@@ -2285,27 +2396,27 @@ void cmFortran_yyset_column (int _column_no , yyscan_t yyscanner)
* input buffer.
* @param _in_str A readable stream.
* @param yyscanner The scanner object.
- * @see cmFortran_yy_switch_to_buffer
+ * @see yy_switch_to_buffer
*/
-void cmFortran_yyset_in (FILE * _in_str , yyscan_t yyscanner)
+void yyset_in (FILE * _in_str , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyin = _in_str ;
}
-void cmFortran_yyset_out (FILE * _out_str , yyscan_t yyscanner)
+void yyset_out (FILE * _out_str , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyout = _out_str ;
}
-int cmFortran_yyget_debug (yyscan_t yyscanner)
+int yyget_debug (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yy_flex_debug;
}
-void cmFortran_yyset_debug (int _bdebug , yyscan_t yyscanner)
+void yyset_debug (int _bdebug , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yy_flex_debug = _bdebug ;
@@ -2315,20 +2426,18 @@ void cmFortran_yyset_debug (int _bdebug , yyscan_t yyscanner)
/* User-visible API */
-/* cmFortran_yylex_init is special because it creates the scanner itself, so it is
+/* yylex_init is special because it creates the scanner itself, so it is
* the ONLY reentrant function that doesn't take the scanner as the last argument.
* That's why we explicitly handle the declaration, instead of using our macros.
*/
-
-int cmFortran_yylex_init(yyscan_t* ptr_yy_globals)
-
+int yylex_init(yyscan_t* ptr_yy_globals)
{
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
- *ptr_yy_globals = (yyscan_t) cmFortran_yyalloc ( sizeof( struct yyguts_t ), NULL );
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
@@ -2341,27 +2450,25 @@ int cmFortran_yylex_init(yyscan_t* ptr_yy_globals)
return yy_init_globals ( *ptr_yy_globals );
}
-/* cmFortran_yylex_init_extra has the same functionality as cmFortran_yylex_init, but follows the
+/* yylex_init_extra has the same functionality as yylex_init, but follows the
* convention of taking the scanner as the last argument. Note however, that
* this is a *pointer* to a scanner, as it will be allocated by this call (and
* is the reason, too, why this function also must handle its own declaration).
- * The user defined value in the first argument will be available to cmFortran_yyalloc in
+ * The user defined value in the first argument will be available to yyalloc in
* the yyextra field.
*/
-
-int cmFortran_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
-
+int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
{
struct yyguts_t dummy_yyguts;
- cmFortran_yyset_extra (yy_user_defined, &dummy_yyguts);
+ yyset_extra (yy_user_defined, &dummy_yyguts);
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
- *ptr_yy_globals = (yyscan_t) cmFortran_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
@@ -2372,7 +2479,7 @@ int cmFortran_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_gl
yy_init_globals. Leave at 0x00 for releases. */
memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
- cmFortran_yyset_extra (yy_user_defined, *ptr_yy_globals);
+ yyset_extra (yy_user_defined, *ptr_yy_globals);
return yy_init_globals ( *ptr_yy_globals );
}
@@ -2381,7 +2488,7 @@ static int yy_init_globals (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Initialization is the same as for the non-reentrant scanner.
- * This function is called from cmFortran_yylex_destroy(), so don't allocate here.
+ * This function is called from yylex_destroy(), so don't allocate here.
*/
yyg->yy_buffer_stack = NULL;
@@ -2405,37 +2512,37 @@ static int yy_init_globals (yyscan_t yyscanner)
#endif
/* For future reference: Set errno on error, since we are called by
- * cmFortran_yylex_init()
+ * yylex_init()
*/
return 0;
}
-/* cmFortran_yylex_destroy is for both reentrant and non-reentrant scanners. */
-int cmFortran_yylex_destroy (yyscan_t yyscanner)
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
+int yylex_destroy (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
- cmFortran_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
+ yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
YY_CURRENT_BUFFER_LVALUE = NULL;
- cmFortran_yypop_buffer_state(yyscanner);
+ yypop_buffer_state(yyscanner);
}
/* Destroy the stack itself. */
- cmFortran_yyfree(yyg->yy_buffer_stack ,yyscanner);
+ yyfree(yyg->yy_buffer_stack , yyscanner);
yyg->yy_buffer_stack = NULL;
/* Destroy the start condition stack. */
- cmFortran_yyfree(yyg->yy_start_stack ,yyscanner );
+ yyfree( yyg->yy_start_stack , yyscanner );
yyg->yy_start_stack = NULL;
/* Reset the globals. This is important in a non-reentrant scanner so the next time
- * cmFortran_yylex() is called, initialization will occur. */
+ * yylex() is called, initialization will occur. */
yy_init_globals( yyscanner);
/* Destroy the main struct (reentrant only). */
- cmFortran_yyfree ( yyscanner , yyscanner );
+ yyfree ( yyscanner , yyscanner );
yyscanner = NULL;
return 0;
}
@@ -2445,7 +2552,7 @@ int cmFortran_yylex_destroy (yyscan_t yyscanner)
*/
#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
+static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
@@ -2457,7 +2564,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
+static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
{
int n;
for ( n = 0; s[n]; ++n )
@@ -2467,14 +2574,14 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
}
#endif
-void *cmFortran_yyalloc (yy_size_t size , yyscan_t yyscanner)
+void *yyalloc (yy_size_t size , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
return malloc(size);
}
-void *cmFortran_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
+void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
@@ -2489,19 +2596,15 @@ void *cmFortran_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
return realloc(ptr, size);
}
-void cmFortran_yyfree (void * ptr , yyscan_t yyscanner)
+void yyfree (void * ptr , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
- free( (char *) ptr ); /* see cmFortran_yyrealloc() for (char *) cast */
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"
-#line 178 "cmFortranLexer.in.l"
-
-
-
/*--------------------------------------------------------------------------*/
YY_BUFFER_STATE cmFortranLexer_GetCurrentBuffer(yyscan_t yyscanner)
{
@@ -2509,3 +2612,5 @@ YY_BUFFER_STATE cmFortranLexer_GetCurrentBuffer(yyscan_t yyscanner)
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return YY_CURRENT_BUFFER;
}
+
+#endif /* __clang_analyzer__ */
diff --git a/Source/LexerParser/cmFortranLexer.h b/Source/LexerParser/cmFortranLexer.h
index ddda91965..7bb9b4434 100644
--- a/Source/LexerParser/cmFortranLexer.h
+++ b/Source/LexerParser/cmFortranLexer.h
@@ -2,10 +2,6 @@
#define cmFortran_yyHEADER_H 1
#define cmFortran_yyIN_HEADER 1
-#line 6 "cmFortranLexer.h"
-
-#line 8 "cmFortranLexer.h"
-
#define FLEXINT_H 1
#define YY_INT_ALIGNED short int
@@ -14,11 +10,221 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
+#define YY_FLEX_SUBMINOR_VERSION 4
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
+#ifdef yy_create_buffer
+#define cmFortran_yy_create_buffer_ALREADY_DEFINED
+#else
+#define yy_create_buffer cmFortran_yy_create_buffer
+#endif
+
+#ifdef yy_delete_buffer
+#define cmFortran_yy_delete_buffer_ALREADY_DEFINED
+#else
+#define yy_delete_buffer cmFortran_yy_delete_buffer
+#endif
+
+#ifdef yy_scan_buffer
+#define cmFortran_yy_scan_buffer_ALREADY_DEFINED
+#else
+#define yy_scan_buffer cmFortran_yy_scan_buffer
+#endif
+
+#ifdef yy_scan_string
+#define cmFortran_yy_scan_string_ALREADY_DEFINED
+#else
+#define yy_scan_string cmFortran_yy_scan_string
+#endif
+
+#ifdef yy_scan_bytes
+#define cmFortran_yy_scan_bytes_ALREADY_DEFINED
+#else
+#define yy_scan_bytes cmFortran_yy_scan_bytes
+#endif
+
+#ifdef yy_init_buffer
+#define cmFortran_yy_init_buffer_ALREADY_DEFINED
+#else
+#define yy_init_buffer cmFortran_yy_init_buffer
+#endif
+
+#ifdef yy_flush_buffer
+#define cmFortran_yy_flush_buffer_ALREADY_DEFINED
+#else
+#define yy_flush_buffer cmFortran_yy_flush_buffer
+#endif
+
+#ifdef yy_load_buffer_state
+#define cmFortran_yy_load_buffer_state_ALREADY_DEFINED
+#else
+#define yy_load_buffer_state cmFortran_yy_load_buffer_state
+#endif
+
+#ifdef yy_switch_to_buffer
+#define cmFortran_yy_switch_to_buffer_ALREADY_DEFINED
+#else
+#define yy_switch_to_buffer cmFortran_yy_switch_to_buffer
+#endif
+
+#ifdef yypush_buffer_state
+#define cmFortran_yypush_buffer_state_ALREADY_DEFINED
+#else
+#define yypush_buffer_state cmFortran_yypush_buffer_state
+#endif
+
+#ifdef yypop_buffer_state
+#define cmFortran_yypop_buffer_state_ALREADY_DEFINED
+#else
+#define yypop_buffer_state cmFortran_yypop_buffer_state
+#endif
+
+#ifdef yyensure_buffer_stack
+#define cmFortran_yyensure_buffer_stack_ALREADY_DEFINED
+#else
+#define yyensure_buffer_stack cmFortran_yyensure_buffer_stack
+#endif
+
+#ifdef yylex
+#define cmFortran_yylex_ALREADY_DEFINED
+#else
+#define yylex cmFortran_yylex
+#endif
+
+#ifdef yyrestart
+#define cmFortran_yyrestart_ALREADY_DEFINED
+#else
+#define yyrestart cmFortran_yyrestart
+#endif
+
+#ifdef yylex_init
+#define cmFortran_yylex_init_ALREADY_DEFINED
+#else
+#define yylex_init cmFortran_yylex_init
+#endif
+
+#ifdef yylex_init_extra
+#define cmFortran_yylex_init_extra_ALREADY_DEFINED
+#else
+#define yylex_init_extra cmFortran_yylex_init_extra
+#endif
+
+#ifdef yylex_destroy
+#define cmFortran_yylex_destroy_ALREADY_DEFINED
+#else
+#define yylex_destroy cmFortran_yylex_destroy
+#endif
+
+#ifdef yyget_debug
+#define cmFortran_yyget_debug_ALREADY_DEFINED
+#else
+#define yyget_debug cmFortran_yyget_debug
+#endif
+
+#ifdef yyset_debug
+#define cmFortran_yyset_debug_ALREADY_DEFINED
+#else
+#define yyset_debug cmFortran_yyset_debug
+#endif
+
+#ifdef yyget_extra
+#define cmFortran_yyget_extra_ALREADY_DEFINED
+#else
+#define yyget_extra cmFortran_yyget_extra
+#endif
+
+#ifdef yyset_extra
+#define cmFortran_yyset_extra_ALREADY_DEFINED
+#else
+#define yyset_extra cmFortran_yyset_extra
+#endif
+
+#ifdef yyget_in
+#define cmFortran_yyget_in_ALREADY_DEFINED
+#else
+#define yyget_in cmFortran_yyget_in
+#endif
+
+#ifdef yyset_in
+#define cmFortran_yyset_in_ALREADY_DEFINED
+#else
+#define yyset_in cmFortran_yyset_in
+#endif
+
+#ifdef yyget_out
+#define cmFortran_yyget_out_ALREADY_DEFINED
+#else
+#define yyget_out cmFortran_yyget_out
+#endif
+
+#ifdef yyset_out
+#define cmFortran_yyset_out_ALREADY_DEFINED
+#else
+#define yyset_out cmFortran_yyset_out
+#endif
+
+#ifdef yyget_leng
+#define cmFortran_yyget_leng_ALREADY_DEFINED
+#else
+#define yyget_leng cmFortran_yyget_leng
+#endif
+
+#ifdef yyget_text
+#define cmFortran_yyget_text_ALREADY_DEFINED
+#else
+#define yyget_text cmFortran_yyget_text
+#endif
+
+#ifdef yyget_lineno
+#define cmFortran_yyget_lineno_ALREADY_DEFINED
+#else
+#define yyget_lineno cmFortran_yyget_lineno
+#endif
+
+#ifdef yyset_lineno
+#define cmFortran_yyset_lineno_ALREADY_DEFINED
+#else
+#define yyset_lineno cmFortran_yyset_lineno
+#endif
+
+#ifdef yyget_column
+#define cmFortran_yyget_column_ALREADY_DEFINED
+#else
+#define yyget_column cmFortran_yyget_column
+#endif
+
+#ifdef yyset_column
+#define cmFortran_yyset_column_ALREADY_DEFINED
+#else
+#define yyset_column cmFortran_yyset_column
+#endif
+
+#ifdef yywrap
+#define cmFortran_yywrap_ALREADY_DEFINED
+#else
+#define yywrap cmFortran_yywrap
+#endif
+
+#ifdef yyalloc
+#define cmFortran_yyalloc_ALREADY_DEFINED
+#else
+#define yyalloc cmFortran_yyalloc
+#endif
+
+#ifdef yyrealloc
+#define cmFortran_yyrealloc_ALREADY_DEFINED
+#else
+#define yyrealloc cmFortran_yyrealloc
+#endif
+
+#ifdef yyfree
+#define cmFortran_yyfree_ALREADY_DEFINED
+#else
+#define yyfree cmFortran_yyfree
+#endif
+
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
@@ -89,10 +295,16 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
+#ifndef SIZE_MAX
+#define SIZE_MAX (~(size_t)0)
+#endif
+
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */
+
/* TODO: this is always defined, so inline it */
#define yyconst const
@@ -193,21 +405,21 @@ struct yy_buffer_state
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-void cmFortran_yyrestart (FILE *input_file ,yyscan_t yyscanner );
-void cmFortran_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmFortran_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
-void cmFortran_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmFortran_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmFortran_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-void cmFortran_yypop_buffer_state (yyscan_t yyscanner );
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+void yypop_buffer_state ( yyscan_t yyscanner );
-YY_BUFFER_STATE cmFortran_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmFortran_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmFortran_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
-void *cmFortran_yyalloc (yy_size_t ,yyscan_t yyscanner );
-void *cmFortran_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
-void cmFortran_yyfree (void * ,yyscan_t yyscanner );
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
+void yyfree ( void * , yyscan_t yyscanner );
/* Begin user sect3 */
@@ -229,42 +441,42 @@ void cmFortran_yyfree (void * ,yyscan_t yyscanner );
#define YY_EXTRA_TYPE void *
#endif
-int cmFortran_yylex_init (yyscan_t* scanner);
+int yylex_init (yyscan_t* scanner);
-int cmFortran_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
-int cmFortran_yylex_destroy (yyscan_t yyscanner );
+int yylex_destroy ( yyscan_t yyscanner );
-int cmFortran_yyget_debug (yyscan_t yyscanner );
+int yyget_debug ( yyscan_t yyscanner );
-void cmFortran_yyset_debug (int debug_flag ,yyscan_t yyscanner );
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
-YY_EXTRA_TYPE cmFortran_yyget_extra (yyscan_t yyscanner );
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
-void cmFortran_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
-FILE *cmFortran_yyget_in (yyscan_t yyscanner );
+FILE *yyget_in ( yyscan_t yyscanner );
-void cmFortran_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
+void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
-FILE *cmFortran_yyget_out (yyscan_t yyscanner );
+FILE *yyget_out ( yyscan_t yyscanner );
-void cmFortran_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
+void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
- int cmFortran_yyget_leng (yyscan_t yyscanner );
+ int yyget_leng ( yyscan_t yyscanner );
-char *cmFortran_yyget_text (yyscan_t yyscanner );
+char *yyget_text ( yyscan_t yyscanner );
-int cmFortran_yyget_lineno (yyscan_t yyscanner );
+int yyget_lineno ( yyscan_t yyscanner );
-void cmFortran_yyset_lineno (int _line_number ,yyscan_t yyscanner );
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
-int cmFortran_yyget_column (yyscan_t yyscanner );
+int yyget_column ( yyscan_t yyscanner );
-void cmFortran_yyset_column (int _column_no ,yyscan_t yyscanner );
+void yyset_column ( int _column_no , yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -272,18 +484,18 @@ void cmFortran_yyset_column (int _column_no ,yyscan_t yyscanner );
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int cmFortran_yywrap (yyscan_t yyscanner );
+extern "C" int yywrap ( yyscan_t yyscanner );
#else
-extern int cmFortran_yywrap (yyscan_t yyscanner );
+extern int yywrap ( yyscan_t yyscanner );
#endif
#endif
#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
@@ -311,9 +523,9 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-extern int cmFortran_yylex (yyscan_t yyscanner);
+extern int yylex (yyscan_t yyscanner);
-#define YY_DECL int cmFortran_yylex (yyscan_t yyscanner)
+#define YY_DECL int yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */
/* yy_get_previous_state - get the state just before the EOB char was reached */
@@ -330,9 +542,150 @@ extern int cmFortran_yylex (yyscan_t yyscanner);
#undef YY_DECL
#endif
-#line 178 "cmFortranLexer.in.l"
-
+#ifndef cmFortran_yy_create_buffer_ALREADY_DEFINED
+#undef yy_create_buffer
+#endif
+#ifndef cmFortran_yy_delete_buffer_ALREADY_DEFINED
+#undef yy_delete_buffer
+#endif
+#ifndef cmFortran_yy_scan_buffer_ALREADY_DEFINED
+#undef yy_scan_buffer
+#endif
+#ifndef cmFortran_yy_scan_string_ALREADY_DEFINED
+#undef yy_scan_string
+#endif
+#ifndef cmFortran_yy_scan_bytes_ALREADY_DEFINED
+#undef yy_scan_bytes
+#endif
+#ifndef cmFortran_yy_init_buffer_ALREADY_DEFINED
+#undef yy_init_buffer
+#endif
+#ifndef cmFortran_yy_flush_buffer_ALREADY_DEFINED
+#undef yy_flush_buffer
+#endif
+#ifndef cmFortran_yy_load_buffer_state_ALREADY_DEFINED
+#undef yy_load_buffer_state
+#endif
+#ifndef cmFortran_yy_switch_to_buffer_ALREADY_DEFINED
+#undef yy_switch_to_buffer
+#endif
+#ifndef cmFortran_yypush_buffer_state_ALREADY_DEFINED
+#undef yypush_buffer_state
+#endif
+#ifndef cmFortran_yypop_buffer_state_ALREADY_DEFINED
+#undef yypop_buffer_state
+#endif
+#ifndef cmFortran_yyensure_buffer_stack_ALREADY_DEFINED
+#undef yyensure_buffer_stack
+#endif
+#ifndef cmFortran_yylex_ALREADY_DEFINED
+#undef yylex
+#endif
+#ifndef cmFortran_yyrestart_ALREADY_DEFINED
+#undef yyrestart
+#endif
+#ifndef cmFortran_yylex_init_ALREADY_DEFINED
+#undef yylex_init
+#endif
+#ifndef cmFortran_yylex_init_extra_ALREADY_DEFINED
+#undef yylex_init_extra
+#endif
+#ifndef cmFortran_yylex_destroy_ALREADY_DEFINED
+#undef yylex_destroy
+#endif
+#ifndef cmFortran_yyget_debug_ALREADY_DEFINED
+#undef yyget_debug
+#endif
+#ifndef cmFortran_yyset_debug_ALREADY_DEFINED
+#undef yyset_debug
+#endif
+#ifndef cmFortran_yyget_extra_ALREADY_DEFINED
+#undef yyget_extra
+#endif
+#ifndef cmFortran_yyset_extra_ALREADY_DEFINED
+#undef yyset_extra
+#endif
+#ifndef cmFortran_yyget_in_ALREADY_DEFINED
+#undef yyget_in
+#endif
+#ifndef cmFortran_yyset_in_ALREADY_DEFINED
+#undef yyset_in
+#endif
+#ifndef cmFortran_yyget_out_ALREADY_DEFINED
+#undef yyget_out
+#endif
+#ifndef cmFortran_yyset_out_ALREADY_DEFINED
+#undef yyset_out
+#endif
+#ifndef cmFortran_yyget_leng_ALREADY_DEFINED
+#undef yyget_leng
+#endif
+#ifndef cmFortran_yyget_text_ALREADY_DEFINED
+#undef yyget_text
+#endif
+#ifndef cmFortran_yyget_lineno_ALREADY_DEFINED
+#undef yyget_lineno
+#endif
+#ifndef cmFortran_yyset_lineno_ALREADY_DEFINED
+#undef yyset_lineno
+#endif
+#ifndef cmFortran_yyget_column_ALREADY_DEFINED
+#undef yyget_column
+#endif
+#ifndef cmFortran_yyset_column_ALREADY_DEFINED
+#undef yyset_column
+#endif
+#ifndef cmFortran_yywrap_ALREADY_DEFINED
+#undef yywrap
+#endif
+#ifndef cmFortran_yyget_lval_ALREADY_DEFINED
+#undef yyget_lval
+#endif
+#ifndef cmFortran_yyset_lval_ALREADY_DEFINED
+#undef yyset_lval
+#endif
+#ifndef cmFortran_yyget_lloc_ALREADY_DEFINED
+#undef yyget_lloc
+#endif
+#ifndef cmFortran_yyset_lloc_ALREADY_DEFINED
+#undef yyset_lloc
+#endif
+#ifndef cmFortran_yyalloc_ALREADY_DEFINED
+#undef yyalloc
+#endif
+#ifndef cmFortran_yyrealloc_ALREADY_DEFINED
+#undef yyrealloc
+#endif
+#ifndef cmFortran_yyfree_ALREADY_DEFINED
+#undef yyfree
+#endif
+#ifndef cmFortran_yytext_ALREADY_DEFINED
+#undef yytext
+#endif
+#ifndef cmFortran_yyleng_ALREADY_DEFINED
+#undef yyleng
+#endif
+#ifndef cmFortran_yyin_ALREADY_DEFINED
+#undef yyin
+#endif
+#ifndef cmFortran_yyout_ALREADY_DEFINED
+#undef yyout
+#endif
+#ifndef cmFortran_yy_flex_debug_ALREADY_DEFINED
+#undef yy_flex_debug
+#endif
+#ifndef cmFortran_yylineno_ALREADY_DEFINED
+#undef yylineno
+#endif
+#ifndef cmFortran_yytables_fload_ALREADY_DEFINED
+#undef yytables_fload
+#endif
+#ifndef cmFortran_yytables_destroy_ALREADY_DEFINED
+#undef yytables_destroy
+#endif
+#ifndef cmFortran_yyTABLES_NAME_ALREADY_DEFINED
+#undef yyTABLES_NAME
+#endif
-#line 337 "cmFortranLexer.h"
#undef cmFortran_yyIN_HEADER
#endif /* cmFortran_yyHEADER_H */
diff --git a/Source/LexerParser/cmFortranLexer.in.l b/Source/LexerParser/cmFortranLexer.in.l
index 112121037..3d38a7dad 100644
--- a/Source/LexerParser/cmFortranLexer.in.l
+++ b/Source/LexerParser/cmFortranLexer.in.l
@@ -17,18 +17,18 @@ This file must be translated to C++ and modified to build everywhere.
Run flex >= 2.6 like this:
- flex -i --nounistd -DFLEXINT_H --prefix=cmFortran_yy --header-file=cmFortranLexer.h -ocmFortranLexer.cxx cmFortranLexer.in.l
+ flex -i --nounistd -DFLEXINT_H --noline --header-file=cmFortranLexer.h -ocmFortranLexer.cxx cmFortranLexer.in.l
Modify cmFortranLexer.cxx:
- - remove trailing whitespace: sed -i 's/\s*$//' cmFortranLexer.h cmFortranLexer.cxx
- - remove blank lines at end of file
- - #include "cmStandardLexer.h" at the top
- - add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t
-
+ - remove trailing whitespace: sed -i 's/\s*$//' cmFortranLexer.h cmFortranLexer.cxx
+ - remove blank lines at end of file: sed -i '${/^$/d;}' cmFortranLexer.h cmFortranLexer.cxx
+ - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmFortranLexer.cxx
*/
/* IWYU pragma: no_forward_declare yyguts_t */
+#ifndef __clang_analyzer__ /* Suppress clang scan-build warnings */
+
#undef YY_NO_UNPUT
#define cmFortranLexer_cxx
@@ -37,7 +37,7 @@ Modify cmFortranLexer.cxx:
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
- { result = cmFortranParser_Input(yyextra, buf, max_size); }
+ do { result = cmFortranParser_Input(yyextra, buf, max_size); } while (0)
/* Include the set of tokens from the parser. */
#include "cmFortranParserTokens.h"
@@ -45,6 +45,7 @@ Modify cmFortranLexer.cxx:
/*--------------------------------------------------------------------------*/
%}
+%option prefix="cmFortran_yy"
%option reentrant
%option noyywrap
@@ -147,7 +148,7 @@ $[ \t]*endif { return F90PPR_ENDIF; }
[Ii][Nn][Cc][Ll][Uu][Dd][Ee] { return INCLUDE; }
[Ii][Nn][Tt][Ee][Rr][Ff][Aa][Cc][Ee] { return INTERFACE; }
[Mm][Oo][Dd][Uu][Ll][Ee] { return MODULE; }
-[Ss][Uu][bb][Mm][Oo][Dd][Uu][Ll][Ee] { return SUBMODULE; }
+[Ss][Uu][Bb][Mm][Oo][Dd][Uu][Ll][Ee] { return SUBMODULE; }
[Uu][Ss][Ee] { return USE; }
[a-zA-Z_][a-zA-Z_0-9]* {
@@ -184,3 +185,5 @@ YY_BUFFER_STATE cmFortranLexer_GetCurrentBuffer(yyscan_t yyscanner)
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return YY_CURRENT_BUFFER;
}
+
+#endif /* __clang_analyzer__ */
diff --git a/Source/LexerParser/cmFortranParser.cxx b/Source/LexerParser/cmFortranParser.cxx
index 2b3452f2e..2ca79276d 100644
--- a/Source/LexerParser/cmFortranParser.cxx
+++ b/Source/LexerParser/cmFortranParser.cxx
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
+/* A Bison parser, made by GNU Bison 3.3.2. */
/* Bison implementation for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
+ Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -40,11 +41,14 @@
define necessary library symbols; they are noted "INFRINGES ON
USER NAME SPACE" below. */
+/* Undocumented macros, especially those whose name start with YY_,
+ are private implementation details. Do not rely on them. */
+
/* Identify Bison output. */
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "3.0.4"
+#define YYBISON_VERSION "3.3.2"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -67,8 +71,8 @@
#define yynerrs cmFortran_yynerrs
-/* Copy the first part of user declarations. */
-#line 1 "cmFortranParser.y" /* yacc.c:339 */
+/* First part of user prologue. */
+#line 1 "cmFortranParser.y" /* yacc.c:337 */
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
@@ -127,14 +131,20 @@ static void cmFortran_yyerror(yyscan_t yyscanner, const char* message)
# pragma warning (disable: 4127) /* Conditional expression is constant. */
# pragma warning (disable: 4244) /* Conversion to smaller type, data loss. */
#endif
+#if defined(__GNUC__) && __GNUC__ >= 8
+# pragma GCC diagnostic ignored "-Wconversion"
+#endif
-#line 132 "cmFortranParser.cxx" /* yacc.c:339 */
-
+#line 139 "cmFortranParser.cxx" /* yacc.c:337 */
# ifndef YY_NULLPTR
-# if defined __cplusplus && 201103L <= __cplusplus
-# define YY_NULLPTR nullptr
+# if defined __cplusplus
+# if 201103L <= __cplusplus
+# define YY_NULLPTR nullptr
+# else
+# define YY_NULLPTR 0
+# endif
# else
-# define YY_NULLPTR 0
+# define YY_NULLPTR ((void*)0)
# endif
# endif
@@ -248,11 +258,11 @@ extern int cmFortran_yydebug;
union YYSTYPE
{
-#line 70 "cmFortranParser.y" /* yacc.c:355 */
+#line 73 "cmFortranParser.y" /* yacc.c:352 */
char* string;
-#line 256 "cmFortranParser.cxx" /* yacc.c:355 */
+#line 266 "cmFortranParser.cxx" /* yacc.c:352 */
};
typedef union YYSTYPE YYSTYPE;
@@ -266,9 +276,7 @@ int cmFortran_yyparse (yyscan_t yyscanner);
#endif /* !YY_CMFORTRAN_YY_CMFORTRANPARSERTOKENS_H_INCLUDED */
-/* Copy the second part of user declarations. */
-#line 272 "cmFortranParser.cxx" /* yacc.c:358 */
#ifdef short
# undef short
@@ -289,13 +297,13 @@ typedef signed char yytype_int8;
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
-typedef unsigned short int yytype_uint16;
+typedef unsigned short yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
-typedef short int yytype_int16;
+typedef short yytype_int16;
#endif
#ifndef YYSIZE_T
@@ -307,7 +315,7 @@ typedef short int yytype_int16;
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
# define YYSIZE_T size_t
# else
-# define YYSIZE_T unsigned int
+# define YYSIZE_T unsigned
# endif
#endif
@@ -343,15 +351,6 @@ typedef short int yytype_int16;
# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
#endif
-#if !defined _Noreturn \
- && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
-# if defined _MSC_VER && 1200 <= _MSC_VER
-# define _Noreturn __declspec (noreturn)
-# else
-# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
-# endif
-#endif
-
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
@@ -359,7 +358,7 @@ typedef short int yytype_int16;
# define YYUSE(E) /* empty */
#endif
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
@@ -521,16 +520,16 @@ union yyalloc
/* YYNSTATES -- Number of states. */
#define YYNSTATES 126
-/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
- by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
#define YYMAXUTOK 295
+/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
+ as returned by yylex, with out-of-bounds checking. */
#define YYTRANSLATE(YYX) \
- ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+ ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
- as returned by yylex, without out-of-bounds checking. */
+ as returned by yylex. */
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -569,13 +568,13 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
- 0, 98, 98, 98, 101, 105, 110, 119, 125, 132,
- 137, 141, 146, 154, 159, 164, 169, 174, 179, 184,
- 189, 194, 198, 202, 206, 210, 211, 216, 216, 216,
- 217, 217, 218, 218, 219, 219, 220, 220, 221, 221,
- 222, 222, 223, 223, 224, 224, 225, 225, 228, 229,
- 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
- 240, 241, 242, 243
+ 0, 101, 101, 101, 104, 108, 113, 122, 128, 135,
+ 140, 144, 149, 157, 162, 167, 172, 177, 182, 187,
+ 192, 197, 201, 205, 209, 213, 214, 219, 219, 219,
+ 220, 220, 221, 221, 222, 222, 223, 223, 224, 224,
+ 225, 225, 226, 226, 227, 227, 228, 228, 231, 232,
+ 233, 234, 235, 236, 237, 238, 239, 240, 241, 242,
+ 243, 244, 245, 246
};
#endif
@@ -860,22 +859,22 @@ static const yytype_uint8 yyr2[] =
#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (yylen); \
- yystate = *yyssp; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror (yyscanner, YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (0)
+#define YYBACKUP(Token, Value) \
+ do \
+ if (yychar == YYEMPTY) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (yylen); \
+ yystate = *yyssp; \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (yyscanner, YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+ while (0)
/* Error token number */
#define YYTERROR 1
@@ -915,38 +914,38 @@ do { \
} while (0)
-/*----------------------------------------.
-| Print this symbol's value on YYOUTPUT. |
-`----------------------------------------*/
+/*-----------------------------------.
+| Print this symbol's value on YYO. |
+`-----------------------------------*/
static void
-yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
+yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
{
- FILE *yyo = yyoutput;
- YYUSE (yyo);
+ FILE *yyoutput = yyo;
+ YYUSE (yyoutput);
YYUSE (yyscanner);
if (!yyvaluep)
return;
# ifdef YYPRINT
if (yytype < YYNTOKENS)
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+ YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
# endif
YYUSE (yytype);
}
-/*--------------------------------.
-| Print this symbol on YYOUTPUT. |
-`--------------------------------*/
+/*---------------------------.
+| Print this symbol on YYO. |
+`---------------------------*/
static void
-yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
+yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, yyscan_t yyscanner)
{
- YYFPRINTF (yyoutput, "%s %s (",
+ YYFPRINTF (yyo, "%s %s (",
yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
- yy_symbol_value_print (yyoutput, yytype, yyvaluep, yyscanner);
- YYFPRINTF (yyoutput, ")");
+ yy_symbol_value_print (yyo, yytype, yyvaluep, yyscanner);
+ YYFPRINTF (yyo, ")");
}
/*------------------------------------------------------------------.
@@ -980,7 +979,7 @@ do { \
static void
yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, yyscan_t yyscanner)
{
- unsigned long int yylno = yyrline[yyrule];
+ unsigned long yylno = yyrline[yyrule];
int yynrhs = yyr2[yyrule];
int yyi;
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
@@ -991,7 +990,7 @@ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, yyscan_t yysca
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr,
yystos[yyssp[yyi + 1 - yynrhs]],
- &(yyvsp[(yyi + 1) - (yynrhs)])
+ &yyvsp[(yyi + 1) - (yynrhs)]
, yyscanner);
YYFPRINTF (stderr, "\n");
}
@@ -1095,7 +1094,10 @@ yytnamerr (char *yyres, const char *yystr)
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
- /* Fall through. */
+ else
+ goto append;
+
+ append:
default:
if (yyres)
yyres[yyn] = *yyp;
@@ -1113,7 +1115,7 @@ yytnamerr (char *yyres, const char *yystr)
if (! yyres)
return yystrlen (yystr);
- return yystpcpy (yyres, yystr) - yyres;
+ return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
}
# endif
@@ -1191,10 +1193,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yyarg[yycount++] = yytname[yyx];
{
YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
- if (! (yysize <= yysize1
- && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+ yysize = yysize1;
+ else
return 2;
- yysize = yysize1;
}
}
}
@@ -1206,6 +1208,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
case N: \
yyformat = S; \
break
+ default: /* Avoid compiler warnings. */
YYCASE_(0, YY_("syntax error"));
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
@@ -1217,9 +1220,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
{
YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
- if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
+ yysize = yysize1;
+ else
return 2;
- yysize = yysize1;
}
if (*yymsg_alloc < yysize)
@@ -1350,23 +1354,31 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
+
/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
+| yynewstate -- push a new state, which is found in yystate. |
`------------------------------------------------------------*/
- yynewstate:
+yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
- yysetstate:
- *yyssp = yystate;
+
+/*--------------------------------------------------------------------.
+| yynewstate -- set current state (the top of the stack) to yystate. |
+`--------------------------------------------------------------------*/
+yysetstate:
+ *yyssp = (yytype_int16) yystate;
if (yyss + yystacksize - 1 <= yyssp)
+#if !defined yyoverflow && !defined YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+#else
{
/* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
+ YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
-#ifdef yyoverflow
+# if defined yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
@@ -1382,14 +1394,10 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
-
yyss = yyss1;
yyvs = yyvs1;
}
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyexhaustedlab;
-# else
+# else /* defined YYSTACK_RELOCATE */
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
@@ -1405,22 +1413,22 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
-# undef YYSTACK_RELOCATE
+# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
-#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
+ (unsigned long) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
+#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
@@ -1429,11 +1437,11 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
goto yybackup;
+
/*-----------.
| yybackup. |
`-----------*/
yybackup:
-
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
@@ -1506,7 +1514,7 @@ yydefault:
/*-----------------------------.
-| yyreduce -- Do a reduction. |
+| yyreduce -- do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
@@ -1527,26 +1535,26 @@ yyreduce:
switch (yyn)
{
case 4:
-#line 101 "cmFortranParser.y" /* yacc.c:1646 */
+#line 104 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_SetInInterface(parser, true);
}
-#line 1536 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1544 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 5:
-#line 105 "cmFortranParser.y" /* yacc.c:1646 */
+#line 108 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleUse(parser, (yyvsp[-2].string));
free((yyvsp[-2].string));
}
-#line 1546 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1554 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 6:
-#line 110 "cmFortranParser.y" /* yacc.c:1646 */
+#line 113 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
if (cmsysString_strcasecmp((yyvsp[-2].string), "function") != 0 &&
@@ -1556,63 +1564,63 @@ yyreduce:
}
free((yyvsp[-2].string));
}
-#line 1560 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1568 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 7:
-#line 119 "cmFortranParser.y" /* yacc.c:1646 */
+#line 122 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
- cmFortranParser_RuleUse(parser, (yyvsp[-4].string));
+ cmFortranParser_RuleSubmodule(parser, (yyvsp[-4].string), (yyvsp[-2].string));
free((yyvsp[-4].string));
free((yyvsp[-2].string));
}
-#line 1571 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1579 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 8:
-#line 125 "cmFortranParser.y" /* yacc.c:1646 */
+#line 128 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
- cmFortranParser_RuleUse(parser, (yyvsp[-6].string));
+ cmFortranParser_RuleSubmoduleNested(parser, (yyvsp[-6].string), (yyvsp[-4].string), (yyvsp[-2].string));
free((yyvsp[-6].string));
free((yyvsp[-4].string));
free((yyvsp[-2].string));
}
-#line 1583 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1591 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 9:
-#line 132 "cmFortranParser.y" /* yacc.c:1646 */
+#line 135 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_SetInInterface(parser, true);
free((yyvsp[-2].string));
}
-#line 1593 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1601 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 10:
-#line 137 "cmFortranParser.y" /* yacc.c:1646 */
+#line 140 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_SetInInterface(parser, false);
}
-#line 1602 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1610 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 11:
-#line 141 "cmFortranParser.y" /* yacc.c:1646 */
+#line 144 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleUse(parser, (yyvsp[-2].string));
free((yyvsp[-2].string));
}
-#line 1612 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1620 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 12:
-#line 146 "cmFortranParser.y" /* yacc.c:1646 */
+#line 149 "cmFortranParser.y" /* yacc.c:1652 */
{
if (cmsysString_strcasecmp((yyvsp[-4].string), "non_intrinsic") == 0) {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
@@ -1621,139 +1629,139 @@ yyreduce:
free((yyvsp[-4].string));
free((yyvsp[-2].string));
}
-#line 1625 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1633 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 13:
-#line 154 "cmFortranParser.y" /* yacc.c:1646 */
+#line 157 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleInclude(parser, (yyvsp[-2].string));
free((yyvsp[-2].string));
}
-#line 1635 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1643 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 14:
-#line 159 "cmFortranParser.y" /* yacc.c:1646 */
+#line 162 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleLineDirective(parser, (yyvsp[-2].string));
free((yyvsp[-2].string));
}
-#line 1645 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1653 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 15:
-#line 164 "cmFortranParser.y" /* yacc.c:1646 */
+#line 167 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleInclude(parser, (yyvsp[-2].string));
free((yyvsp[-2].string));
}
-#line 1655 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1663 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 16:
-#line 169 "cmFortranParser.y" /* yacc.c:1646 */
+#line 172 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleInclude(parser, (yyvsp[-2].string));
free((yyvsp[-2].string));
}
-#line 1665 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1673 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 17:
-#line 174 "cmFortranParser.y" /* yacc.c:1646 */
+#line 177 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleDefine(parser, (yyvsp[-2].string));
free((yyvsp[-2].string));
}
-#line 1675 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1683 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 18:
-#line 179 "cmFortranParser.y" /* yacc.c:1646 */
+#line 182 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleUndef(parser, (yyvsp[-2].string));
free((yyvsp[-2].string));
}
-#line 1685 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1693 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 19:
-#line 184 "cmFortranParser.y" /* yacc.c:1646 */
+#line 187 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleIfdef(parser, (yyvsp[-2].string));
free((yyvsp[-2].string));
}
-#line 1695 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1703 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 20:
-#line 189 "cmFortranParser.y" /* yacc.c:1646 */
+#line 192 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleIfndef(parser, (yyvsp[-2].string));
free((yyvsp[-2].string));
}
-#line 1705 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1713 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 21:
-#line 194 "cmFortranParser.y" /* yacc.c:1646 */
+#line 197 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleIf(parser);
}
-#line 1714 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1722 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 22:
-#line 198 "cmFortranParser.y" /* yacc.c:1646 */
+#line 201 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleElif(parser);
}
-#line 1723 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1731 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 23:
-#line 202 "cmFortranParser.y" /* yacc.c:1646 */
+#line 205 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleElse(parser);
}
-#line 1732 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1740 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 24:
-#line 206 "cmFortranParser.y" /* yacc.c:1646 */
+#line 209 "cmFortranParser.y" /* yacc.c:1652 */
{
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
cmFortranParser_RuleEndif(parser);
}
-#line 1741 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1749 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 48:
-#line 228 "cmFortranParser.y" /* yacc.c:1646 */
+#line 231 "cmFortranParser.y" /* yacc.c:1652 */
{ free ((yyvsp[0].string)); }
-#line 1747 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1755 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
case 55:
-#line 235 "cmFortranParser.y" /* yacc.c:1646 */
+#line 238 "cmFortranParser.y" /* yacc.c:1652 */
{ free ((yyvsp[0].string)); }
-#line 1753 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1761 "cmFortranParser.cxx" /* yacc.c:1652 */
break;
-#line 1757 "cmFortranParser.cxx" /* yacc.c:1646 */
+#line 1765 "cmFortranParser.cxx" /* yacc.c:1652 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -1778,14 +1786,13 @@ yyreduce:
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
- if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTOKENS];
+ {
+ const int yylhs = yyr1[yyn] - YYNTOKENS;
+ const int yyi = yypgoto[yylhs] + *yyssp;
+ yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
+ ? yytable[yyi]
+ : yydefgoto[yylhs]);
+ }
goto yynewstate;
@@ -1869,12 +1876,10 @@ yyerrlab:
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
-
- /* Pacify compilers like GCC when the user code never invokes
- YYERROR and the label yyerrorlab therefore never appears in user
- code. */
- if (/*CONSTCOND*/ 0)
- goto yyerrorlab;
+ /* Pacify compilers when the user code never invokes YYERROR and the
+ label yyerrorlab therefore never appears in user code. */
+ if (0)
+ YYERROR;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
@@ -1937,6 +1942,7 @@ yyacceptlab:
yyresult = 0;
goto yyreturn;
+
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
@@ -1944,6 +1950,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
+
#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
@@ -1954,6 +1961,10 @@ yyexhaustedlab:
/* Fall through. */
#endif
+
+/*-----------------------------------------------------.
+| yyreturn -- parsing is finished, return the result. |
+`-----------------------------------------------------*/
yyreturn:
if (yychar != YYEMPTY)
{
@@ -1983,6 +1994,6 @@ yyreturn:
#endif
return yyresult;
}
-#line 246 "cmFortranParser.y" /* yacc.c:1906 */
+#line 249 "cmFortranParser.y" /* yacc.c:1918 */
/* End of grammar */
diff --git a/Source/LexerParser/cmFortranParser.y b/Source/LexerParser/cmFortranParser.y
index acfb40ad8..87f3e0a16 100644
--- a/Source/LexerParser/cmFortranParser.y
+++ b/Source/LexerParser/cmFortranParser.y
@@ -56,6 +56,9 @@ static void cmFortran_yyerror(yyscan_t yyscanner, const char* message)
# pragma warning (disable: 4127) /* Conditional expression is constant. */
# pragma warning (disable: 4244) /* Conversion to smaller type, data loss. */
#endif
+#if defined(__GNUC__) && __GNUC__ >= 8
+# pragma GCC diagnostic ignored "-Wconversion"
+#endif
%}
/* Generate a reentrant parser object. */
@@ -118,13 +121,13 @@ stmt:
}
| SUBMODULE LPAREN WORD RPAREN WORD other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
- cmFortranParser_RuleUse(parser, $3);
+ cmFortranParser_RuleSubmodule(parser, $3, $5);
free($3);
free($5);
}
| SUBMODULE LPAREN WORD COLON WORD RPAREN WORD other EOSTMT {
cmFortranParser* parser = cmFortran_yyget_extra(yyscanner);
- cmFortranParser_RuleUse(parser, $3);
+ cmFortranParser_RuleSubmoduleNested(parser, $3, $5, $7);
free($3);
free($5);
free($7);
diff --git a/Source/LexerParser/cmFortranParserTokens.h b/Source/LexerParser/cmFortranParserTokens.h
index 8d6a5fe5a..0da4c1c43 100644
--- a/Source/LexerParser/cmFortranParserTokens.h
+++ b/Source/LexerParser/cmFortranParserTokens.h
@@ -1,8 +1,9 @@
-/* A Bison parser, made by GNU Bison 3.0.4. */
+/* A Bison parser, made by GNU Bison 3.3.2. */
/* Bison interface for Yacc-like parsers in C
- Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
+ Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,6 +31,9 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
+/* Undocumented macros, especially those whose name start with YY_,
+ are private implementation details. Do not rely on them. */
+
#ifndef YY_CMFORTRAN_YY_CMFORTRANPARSERTOKENS_H_INCLUDED
# define YY_CMFORTRAN_YY_CMFORTRANPARSERTOKENS_H_INCLUDED
/* Debug traces. */
@@ -130,11 +134,11 @@ extern int cmFortran_yydebug;
union YYSTYPE
{
-#line 70 "cmFortranParser.y" /* yacc.c:1909 */
+#line 73 "cmFortranParser.y" /* yacc.c:1921 */
char* string;
-#line 138 "cmFortranParserTokens.h" /* yacc.c:1909 */
+#line 142 "cmFortranParserTokens.h" /* yacc.c:1921 */
};
typedef union YYSTYPE YYSTYPE;
diff --git a/Source/LexerParser/cmListFileLexer.c b/Source/LexerParser/cmListFileLexer.c
index 3dd3b85b9..15dcda04a 100644
--- a/Source/LexerParser/cmListFileLexer.c
+++ b/Source/LexerParser/cmListFileLexer.c
@@ -1,7 +1,4 @@
#include "cmStandardLexer.h"
-#line 2 "cmListFileLexer.c"
-
-#line 4 "cmListFileLexer.c"
#define FLEXINT_H 1
#define YY_INT_ALIGNED short int
@@ -11,11 +8,221 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 6
-#define YY_FLEX_SUBMINOR_VERSION 1
+#define YY_FLEX_SUBMINOR_VERSION 4
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
+#ifdef yy_create_buffer
+#define cmListFileLexer_yy_create_buffer_ALREADY_DEFINED
+#else
+#define yy_create_buffer cmListFileLexer_yy_create_buffer
+#endif
+
+#ifdef yy_delete_buffer
+#define cmListFileLexer_yy_delete_buffer_ALREADY_DEFINED
+#else
+#define yy_delete_buffer cmListFileLexer_yy_delete_buffer
+#endif
+
+#ifdef yy_scan_buffer
+#define cmListFileLexer_yy_scan_buffer_ALREADY_DEFINED
+#else
+#define yy_scan_buffer cmListFileLexer_yy_scan_buffer
+#endif
+
+#ifdef yy_scan_string
+#define cmListFileLexer_yy_scan_string_ALREADY_DEFINED
+#else
+#define yy_scan_string cmListFileLexer_yy_scan_string
+#endif
+
+#ifdef yy_scan_bytes
+#define cmListFileLexer_yy_scan_bytes_ALREADY_DEFINED
+#else
+#define yy_scan_bytes cmListFileLexer_yy_scan_bytes
+#endif
+
+#ifdef yy_init_buffer
+#define cmListFileLexer_yy_init_buffer_ALREADY_DEFINED
+#else
+#define yy_init_buffer cmListFileLexer_yy_init_buffer
+#endif
+
+#ifdef yy_flush_buffer
+#define cmListFileLexer_yy_flush_buffer_ALREADY_DEFINED
+#else
+#define yy_flush_buffer cmListFileLexer_yy_flush_buffer
+#endif
+
+#ifdef yy_load_buffer_state
+#define cmListFileLexer_yy_load_buffer_state_ALREADY_DEFINED
+#else
+#define yy_load_buffer_state cmListFileLexer_yy_load_buffer_state
+#endif
+
+#ifdef yy_switch_to_buffer
+#define cmListFileLexer_yy_switch_to_buffer_ALREADY_DEFINED
+#else
+#define yy_switch_to_buffer cmListFileLexer_yy_switch_to_buffer
+#endif
+
+#ifdef yypush_buffer_state
+#define cmListFileLexer_yypush_buffer_state_ALREADY_DEFINED
+#else
+#define yypush_buffer_state cmListFileLexer_yypush_buffer_state
+#endif
+
+#ifdef yypop_buffer_state
+#define cmListFileLexer_yypop_buffer_state_ALREADY_DEFINED
+#else
+#define yypop_buffer_state cmListFileLexer_yypop_buffer_state
+#endif
+
+#ifdef yyensure_buffer_stack
+#define cmListFileLexer_yyensure_buffer_stack_ALREADY_DEFINED
+#else
+#define yyensure_buffer_stack cmListFileLexer_yyensure_buffer_stack
+#endif
+
+#ifdef yylex
+#define cmListFileLexer_yylex_ALREADY_DEFINED
+#else
+#define yylex cmListFileLexer_yylex
+#endif
+
+#ifdef yyrestart
+#define cmListFileLexer_yyrestart_ALREADY_DEFINED
+#else
+#define yyrestart cmListFileLexer_yyrestart
+#endif
+
+#ifdef yylex_init
+#define cmListFileLexer_yylex_init_ALREADY_DEFINED
+#else
+#define yylex_init cmListFileLexer_yylex_init
+#endif
+
+#ifdef yylex_init_extra
+#define cmListFileLexer_yylex_init_extra_ALREADY_DEFINED
+#else
+#define yylex_init_extra cmListFileLexer_yylex_init_extra
+#endif
+
+#ifdef yylex_destroy
+#define cmListFileLexer_yylex_destroy_ALREADY_DEFINED
+#else
+#define yylex_destroy cmListFileLexer_yylex_destroy
+#endif
+
+#ifdef yyget_debug
+#define cmListFileLexer_yyget_debug_ALREADY_DEFINED
+#else
+#define yyget_debug cmListFileLexer_yyget_debug
+#endif
+
+#ifdef yyset_debug
+#define cmListFileLexer_yyset_debug_ALREADY_DEFINED
+#else
+#define yyset_debug cmListFileLexer_yyset_debug
+#endif
+
+#ifdef yyget_extra
+#define cmListFileLexer_yyget_extra_ALREADY_DEFINED
+#else
+#define yyget_extra cmListFileLexer_yyget_extra
+#endif
+
+#ifdef yyset_extra
+#define cmListFileLexer_yyset_extra_ALREADY_DEFINED
+#else
+#define yyset_extra cmListFileLexer_yyset_extra
+#endif
+
+#ifdef yyget_in
+#define cmListFileLexer_yyget_in_ALREADY_DEFINED
+#else
+#define yyget_in cmListFileLexer_yyget_in
+#endif
+
+#ifdef yyset_in
+#define cmListFileLexer_yyset_in_ALREADY_DEFINED
+#else
+#define yyset_in cmListFileLexer_yyset_in
+#endif
+
+#ifdef yyget_out
+#define cmListFileLexer_yyget_out_ALREADY_DEFINED
+#else
+#define yyget_out cmListFileLexer_yyget_out
+#endif
+
+#ifdef yyset_out
+#define cmListFileLexer_yyset_out_ALREADY_DEFINED
+#else
+#define yyset_out cmListFileLexer_yyset_out
+#endif
+
+#ifdef yyget_leng
+#define cmListFileLexer_yyget_leng_ALREADY_DEFINED
+#else
+#define yyget_leng cmListFileLexer_yyget_leng
+#endif
+
+#ifdef yyget_text
+#define cmListFileLexer_yyget_text_ALREADY_DEFINED
+#else
+#define yyget_text cmListFileLexer_yyget_text
+#endif
+
+#ifdef yyget_lineno
+#define cmListFileLexer_yyget_lineno_ALREADY_DEFINED
+#else
+#define yyget_lineno cmListFileLexer_yyget_lineno
+#endif
+
+#ifdef yyset_lineno
+#define cmListFileLexer_yyset_lineno_ALREADY_DEFINED
+#else
+#define yyset_lineno cmListFileLexer_yyset_lineno
+#endif
+
+#ifdef yyget_column
+#define cmListFileLexer_yyget_column_ALREADY_DEFINED
+#else
+#define yyget_column cmListFileLexer_yyget_column
+#endif
+
+#ifdef yyset_column
+#define cmListFileLexer_yyset_column_ALREADY_DEFINED
+#else
+#define yyset_column cmListFileLexer_yyset_column
+#endif
+
+#ifdef yywrap
+#define cmListFileLexer_yywrap_ALREADY_DEFINED
+#else
+#define yywrap cmListFileLexer_yywrap
+#endif
+
+#ifdef yyalloc
+#define cmListFileLexer_yyalloc_ALREADY_DEFINED
+#else
+#define yyalloc cmListFileLexer_yyalloc
+#endif
+
+#ifdef yyrealloc
+#define cmListFileLexer_yyrealloc_ALREADY_DEFINED
+#else
+#define yyrealloc cmListFileLexer_yyrealloc
+#endif
+
+#ifdef yyfree
+#define cmListFileLexer_yyfree_ALREADY_DEFINED
+#else
+#define yyfree cmListFileLexer_yyfree
+#endif
+
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
@@ -86,10 +293,16 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
+#ifndef SIZE_MAX
+#define SIZE_MAX (~(size_t)0)
+#endif
+
#endif /* ! C99 */
#endif /* ! FLEXINT_H */
+/* begin standard C++ headers. */
+
/* TODO: this is always defined, so inline it */
#define yyconst const
@@ -102,12 +315,10 @@ typedef unsigned int flex_uint32_t;
/* Returned upon end-of-file. */
#define YY_NULL 0
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
+/* Promotes a possibly negative, possibly signed char to an
+ * integer in range [0..255] for use as an array index.
*/
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+#define YY_SC_TO_UI(c) ((YY_CHAR) (c))
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
@@ -131,20 +342,16 @@ typedef void* yyscan_t;
* definition of BEGIN.
*/
#define BEGIN yyg->yy_start = 1 + 2 *
-
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
#define YY_START ((yyg->yy_start - 1) / 2)
#define YYSTATE YY_START
-
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE cmListFileLexer_yyrestart(yyin ,yyscanner )
-
+#define YY_NEW_FILE yyrestart( yyin , yyscanner )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
@@ -180,7 +387,7 @@ typedef size_t yy_size_t;
/* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
* access to the local variable yy_act. Since yyless() is a macro, it would break
- * existing scanners that call yyless() from OUTSIDE cmListFileLexer_yylex.
+ * existing scanners that call yyless() from OUTSIDE yylex.
* One obvious solution it to make yy_act a global. I tried that, and saw
* a 5% performance hit in a non-yylineno scanner, because yy_act is
* normally declared as a register variable-- so it is not worth it.
@@ -213,7 +420,6 @@ typedef size_t yy_size_t;
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
-
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
#ifndef YY_STRUCT_YY_BUFFER_STATE
@@ -273,7 +479,7 @@ struct yy_buffer_state
* possible backing-up.
*
* When we actually see the EOF, we change the status to "new"
- * (via cmListFileLexer_yyrestart()), so that the user can continue scanning by
+ * (via yyrestart()), so that the user can continue scanning by
* just pointing yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
@@ -290,73 +496,67 @@ struct yy_buffer_state
#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
: NULL)
-
/* Same as previous macro, but useful when we know that the buffer stack is not
* NULL or when we need an lvalue. For internal use only.
*/
#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
-void cmListFileLexer_yyrestart (FILE *input_file ,yyscan_t yyscanner );
-void cmListFileLexer_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmListFileLexer_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
-void cmListFileLexer_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmListFileLexer_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
-void cmListFileLexer_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
-void cmListFileLexer_yypop_buffer_state (yyscan_t yyscanner );
-
-static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner );
-static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner );
-static void cmListFileLexer_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
+void yyrestart ( FILE *input_file , yyscan_t yyscanner );
+void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
+void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
+void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
+void yypop_buffer_state ( yyscan_t yyscanner );
-#define YY_FLUSH_BUFFER cmListFileLexer_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
+static void yyensure_buffer_stack ( yyscan_t yyscanner );
+static void yy_load_buffer_state ( yyscan_t yyscanner );
+static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
+#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)
-YY_BUFFER_STATE cmListFileLexer_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmListFileLexer_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
+YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
-void *cmListFileLexer_yyalloc (yy_size_t ,yyscan_t yyscanner );
-void *cmListFileLexer_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
-void cmListFileLexer_yyfree (void * ,yyscan_t yyscanner );
-
-#define yy_new_buffer cmListFileLexer_yy_create_buffer
+void *yyalloc ( yy_size_t , yyscan_t yyscanner );
+void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
+void yyfree ( void * , yyscan_t yyscanner );
+#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
{ \
if ( ! YY_CURRENT_BUFFER ){ \
- cmListFileLexer_yyensure_buffer_stack (yyscanner); \
+ yyensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
- cmListFileLexer_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
-
#define yy_set_bol(at_bol) \
{ \
if ( ! YY_CURRENT_BUFFER ){\
- cmListFileLexer_yyensure_buffer_stack (yyscanner); \
+ yyensure_buffer_stack (yyscanner); \
YY_CURRENT_BUFFER_LVALUE = \
- cmListFileLexer_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
} \
YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
-
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
/* Begin user sect3 */
#define cmListFileLexer_yywrap(yyscanner) (/*CONSTCOND*/1)
#define YY_SKIP_YYWRAP
-
-typedef unsigned char YY_CHAR;
+typedef flex_uint8_t YY_CHAR;
typedef int yy_state_type;
#define yytext_ptr yytext_r
-static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
-static int yy_get_next_buffer (yyscan_t yyscanner );
-static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner );
+static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
+static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner);
+static int yy_get_next_buffer ( yyscan_t yyscanner );
+static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
@@ -367,7 +567,6 @@ static void yynoreturn yy_fatal_error (yyconst char* msg ,yyscan_t yyscanner );
yyg->yy_hold_char = *yy_cp; \
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
-
#define YY_NUM_RULES 24
#define YY_END_OF_BUFFER 25
/* This struct is not used in this scanner,
@@ -377,19 +576,19 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[77] =
+static const flex_int16_t yy_accept[79] =
{ 0,
0, 0, 0, 0, 0, 0, 0, 0, 4, 4,
25, 13, 22, 1, 16, 3, 13, 5, 6, 7,
- 15, 23, 17, 19, 20, 21, 10, 11, 8, 12,
- 9, 4, 13, 0, 13, 0, 22, 0, 0, 7,
- 13, 0, 13, 0, 2, 0, 13, 17, 0, 18,
- 10, 8, 4, 0, 14, 0, 0, 0, 0, 14,
- 0, 0, 14, 0, 0, 0, 2, 14, 0, 0,
- 0, 0, 0, 0, 0, 0
+ 15, 23, 23, 17, 19, 20, 21, 24, 10, 11,
+ 8, 12, 9, 4, 13, 0, 13, 0, 22, 0,
+ 0, 7, 13, 0, 13, 0, 2, 0, 13, 17,
+ 0, 18, 10, 8, 4, 0, 14, 0, 0, 0,
+ 0, 14, 0, 0, 14, 0, 0, 0, 2, 14,
+ 0, 0, 0, 0, 0, 0, 0, 0
} ;
-static yyconst YY_CHAR yy_ec[256] =
+static const YY_CHAR yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
@@ -421,108 +620,122 @@ static yyconst YY_CHAR yy_ec[256] =
1, 1, 1, 1, 1
} ;
-static yyconst YY_CHAR yy_meta[16] =
+static const YY_CHAR yy_meta[17] =
{ 0,
1, 1, 2, 3, 4, 3, 1, 3, 5, 6,
- 1, 6, 1, 1, 7
+ 1, 6, 1, 1, 7, 2
} ;
-static yyconst flex_uint16_t yy_base[95] =
+static const flex_int16_t yy_base[97] =
{ 0,
- 0, 0, 13, 25, 14, 16, 17, 18, 90, 88,
- 88, 39, 20, 237, 237, 74, 78, 237, 237, 13,
- 54, 0, 71, 237, 237, 31, 0, 237, 73, 237,
- 237, 0, 0, 65, 75, 0, 33, 30, 72, 0,
- 0, 75, 70, 0, 74, 0, 0, 62, 70, 237,
- 0, 63, 0, 85, 99, 65, 111, 62, 34, 0,
- 54, 116, 0, 54, 127, 51, 237, 50, 0, 48,
- 47, 39, 33, 29, 17, 237, 136, 143, 150, 157,
- 164, 171, 178, 184, 191, 198, 201, 207, 214, 217,
- 219, 225, 228, 230
+ 0, 0, 14, 28, 42, 56, 70, 84, 18, 19,
+ 68, 100, 16, 298, 298, 54, 58, 298, 298, 13,
+ 115, 0, 298, 51, 298, 298, 21, 298, 0, 298,
+ 53, 298, 298, 0, 0, 126, 55, 0, 25, 25,
+ 53, 0, 0, 136, 53, 0, 57, 0, 0, 42,
+ 50, 298, 0, 43, 0, 146, 160, 45, 172, 43,
+ 26, 0, 42, 177, 0, 42, 188, 40, 298, 40,
+ 0, 38, 37, 34, 32, 31, 23, 298, 197, 204,
+ 211, 218, 225, 232, 239, 245, 252, 259, 262, 268,
+ 275, 278, 280, 286, 289, 291
} ;
-static yyconst flex_int16_t yy_def[95] =
+static const flex_int16_t yy_def[97] =
{ 0,
- 76, 1, 77, 77, 78, 78, 79, 79, 80, 80,
- 76, 76, 76, 76, 76, 76, 12, 76, 76, 12,
- 76, 81, 82, 76, 76, 82, 83, 76, 76, 76,
- 76, 84, 12, 85, 12, 86, 76, 76, 87, 20,
- 12, 88, 12, 21, 76, 89, 12, 82, 82, 76,
- 83, 76, 84, 85, 76, 54, 85, 90, 76, 55,
- 87, 88, 55, 62, 88, 91, 76, 55, 92, 93,
- 90, 94, 91, 93, 94, 0, 76, 76, 76, 76,
- 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
- 76, 76, 76, 76
+ 78, 1, 79, 79, 80, 80, 81, 81, 82, 82,
+ 78, 78, 78, 78, 78, 78, 12, 78, 78, 12,
+ 78, 83, 78, 84, 78, 78, 84, 78, 85, 78,
+ 78, 78, 78, 86, 12, 87, 12, 88, 78, 78,
+ 89, 20, 12, 90, 12, 21, 78, 91, 12, 84,
+ 84, 78, 85, 78, 86, 87, 78, 56, 87, 92,
+ 78, 57, 89, 90, 57, 64, 90, 93, 78, 57,
+ 94, 95, 92, 96, 93, 95, 96, 0, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78
} ;
-static yyconst flex_uint16_t yy_nxt[253] =
+static const flex_int16_t yy_nxt[315] =
{ 0,
12, 13, 14, 13, 15, 16, 17, 18, 19, 12,
- 12, 20, 21, 22, 12, 24, 28, 25, 28, 28,
- 28, 37, 40, 37, 40, 62, 26, 24, 29, 25,
- 29, 31, 31, 50, 37, 48, 37, 54, 26, 33,
- 59, 63, 45, 34, 59, 35, 45, 62, 33, 33,
- 33, 33, 36, 33, 41, 55, 54, 58, 42, 63,
- 43, 72, 60, 41, 44, 41, 45, 46, 41, 55,
- 55, 56, 70, 52, 48, 49, 67, 66, 57, 63,
- 60, 64, 58, 52, 49, 39, 38, 76, 65, 55,
- 14, 56, 14, 76, 76, 76, 76, 76, 57, 55,
-
- 76, 76, 76, 34, 76, 68, 76, 76, 55, 55,
- 55, 55, 69, 55, 54, 76, 54, 76, 54, 54,
- 63, 76, 64, 76, 76, 76, 76, 76, 76, 65,
- 62, 76, 62, 76, 62, 62, 23, 23, 23, 23,
- 23, 23, 23, 27, 27, 27, 27, 27, 27, 27,
- 30, 30, 30, 30, 30, 30, 30, 32, 32, 32,
- 32, 32, 32, 32, 47, 76, 47, 47, 47, 47,
- 47, 48, 76, 48, 76, 48, 48, 48, 51, 76,
- 51, 51, 51, 51, 53, 76, 53, 53, 53, 53,
- 53, 54, 76, 76, 54, 76, 54, 54, 33, 76,
-
- 33, 33, 33, 33, 33, 61, 61, 62, 76, 76,
- 62, 76, 62, 62, 41, 76, 41, 41, 41, 41,
- 41, 71, 71, 73, 73, 55, 76, 55, 55, 55,
- 55, 55, 74, 74, 75, 75, 11, 76, 76, 76,
- 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
- 76, 76
+ 12, 20, 21, 22, 12, 23, 25, 39, 26, 39,
+ 14, 14, 42, 52, 42, 50, 39, 27, 39, 28,
+ 25, 64, 26, 28, 28, 61, 61, 47, 47, 56,
+ 65, 27, 64, 28, 30, 57, 56, 60, 65, 74,
+ 62, 57, 72, 54, 50, 51, 31, 28, 30, 69,
+ 68, 62, 60, 54, 51, 41, 40, 78, 78, 78,
+ 31, 28, 30, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78, 33, 28, 30, 78, 78, 78,
+ 78, 78, 78, 78, 78, 78, 78, 78, 33, 28,
+
+ 35, 78, 78, 78, 36, 78, 37, 78, 78, 35,
+ 35, 35, 35, 38, 35, 43, 78, 78, 78, 44,
+ 78, 45, 78, 78, 43, 46, 43, 47, 48, 43,
+ 57, 78, 58, 78, 78, 78, 78, 78, 78, 59,
+ 65, 78, 66, 78, 78, 78, 78, 78, 78, 67,
+ 57, 78, 58, 78, 78, 78, 78, 78, 78, 59,
+ 57, 78, 78, 78, 36, 78, 70, 78, 78, 57,
+ 57, 57, 57, 71, 57, 56, 78, 56, 78, 56,
+ 56, 65, 78, 66, 78, 78, 78, 78, 78, 78,
+ 67, 64, 78, 64, 78, 64, 64, 24, 24, 24,
+
+ 24, 24, 24, 24, 29, 29, 29, 29, 29, 29,
+ 29, 32, 32, 32, 32, 32, 32, 32, 34, 34,
+ 34, 34, 34, 34, 34, 49, 78, 49, 49, 49,
+ 49, 49, 50, 78, 50, 78, 50, 50, 50, 53,
+ 78, 53, 53, 53, 53, 55, 78, 55, 55, 55,
+ 55, 55, 56, 78, 78, 56, 78, 56, 56, 35,
+ 78, 35, 35, 35, 35, 35, 63, 63, 64, 78,
+ 78, 64, 78, 64, 64, 43, 78, 43, 43, 43,
+ 43, 43, 73, 73, 75, 75, 57, 78, 57, 57,
+ 57, 57, 57, 76, 76, 77, 77, 11, 78, 78,
+
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78
} ;
-static yyconst flex_int16_t yy_chk[253] =
+static const flex_int16_t yy_chk[315] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 3, 5, 3, 6, 7,
- 8, 13, 20, 13, 20, 75, 3, 4, 5, 4,
- 6, 7, 8, 26, 37, 26, 37, 74, 4, 12,
- 38, 73, 38, 12, 59, 12, 59, 72, 12, 12,
- 12, 12, 12, 12, 21, 71, 70, 68, 21, 66,
- 21, 64, 61, 21, 21, 21, 21, 21, 21, 34,
- 58, 34, 56, 52, 49, 48, 45, 43, 34, 42,
- 39, 42, 35, 29, 23, 17, 16, 11, 42, 54,
- 10, 54, 9, 0, 0, 0, 0, 0, 54, 55,
-
- 0, 0, 0, 55, 0, 55, 0, 0, 55, 55,
- 55, 55, 55, 55, 57, 0, 57, 0, 57, 57,
- 62, 0, 62, 0, 0, 0, 0, 0, 0, 62,
- 65, 0, 65, 0, 65, 65, 77, 77, 77, 77,
- 77, 77, 77, 78, 78, 78, 78, 78, 78, 78,
- 79, 79, 79, 79, 79, 79, 79, 80, 80, 80,
- 80, 80, 80, 80, 81, 0, 81, 81, 81, 81,
- 81, 82, 0, 82, 0, 82, 82, 82, 83, 0,
- 83, 83, 83, 83, 84, 0, 84, 84, 84, 84,
- 84, 85, 0, 0, 85, 0, 85, 85, 86, 0,
-
- 86, 86, 86, 86, 86, 87, 87, 88, 0, 0,
- 88, 0, 88, 88, 89, 0, 89, 89, 89, 89,
- 89, 90, 90, 91, 91, 92, 0, 92, 92, 92,
- 92, 92, 93, 93, 94, 94, 76, 76, 76, 76,
- 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
- 76, 76
+ 1, 1, 1, 1, 1, 1, 3, 13, 3, 13,
+ 9, 10, 20, 27, 20, 27, 39, 3, 39, 3,
+ 4, 77, 4, 9, 10, 40, 61, 40, 61, 76,
+ 75, 4, 74, 4, 5, 73, 72, 70, 68, 66,
+ 63, 60, 58, 54, 51, 50, 5, 5, 6, 47,
+ 45, 41, 37, 31, 24, 17, 16, 11, 0, 0,
+ 6, 6, 7, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 7, 7, 8, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 8, 8,
+
+ 12, 0, 0, 0, 12, 0, 12, 0, 0, 12,
+ 12, 12, 12, 12, 12, 21, 0, 0, 0, 21,
+ 0, 21, 0, 0, 21, 21, 21, 21, 21, 21,
+ 36, 0, 36, 0, 0, 0, 0, 0, 0, 36,
+ 44, 0, 44, 0, 0, 0, 0, 0, 0, 44,
+ 56, 0, 56, 0, 0, 0, 0, 0, 0, 56,
+ 57, 0, 0, 0, 57, 0, 57, 0, 0, 57,
+ 57, 57, 57, 57, 57, 59, 0, 59, 0, 59,
+ 59, 64, 0, 64, 0, 0, 0, 0, 0, 0,
+ 64, 67, 0, 67, 0, 67, 67, 79, 79, 79,
+
+ 79, 79, 79, 79, 80, 80, 80, 80, 80, 80,
+ 80, 81, 81, 81, 81, 81, 81, 81, 82, 82,
+ 82, 82, 82, 82, 82, 83, 0, 83, 83, 83,
+ 83, 83, 84, 0, 84, 0, 84, 84, 84, 85,
+ 0, 85, 85, 85, 85, 86, 0, 86, 86, 86,
+ 86, 86, 87, 0, 0, 87, 0, 87, 87, 88,
+ 0, 88, 88, 88, 88, 88, 89, 89, 90, 0,
+ 0, 90, 0, 90, 90, 91, 0, 91, 91, 91,
+ 91, 91, 92, 92, 93, 93, 94, 0, 94, 94,
+ 94, 94, 94, 95, 95, 96, 96, 78, 78, 78,
+
+ 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
+ 78, 78, 78, 78
} ;
/* Table of booleans, true if rule could match eol. */
-static yyconst flex_int32_t yy_rule_can_match_eol[25] =
+static const flex_int32_t yy_rule_can_match_eol[25] =
{ 0,
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1,
0, 0, 0, 0, 0, };
@@ -534,8 +747,6 @@ static yyconst flex_int32_t yy_rule_can_match_eol[25] =
#define yymore() yymore_used_but_not_detected
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
-#line 1 "cmListFileLexer.in.l"
-#line 2 "cmListFileLexer.in.l"
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
/*
@@ -544,20 +755,18 @@ This file must be translated to C and modified to build everywhere.
Run flex >= 2.6 like this:
- flex --nounistd -DFLEXINT_H --prefix=cmListFileLexer_yy -ocmListFileLexer.c cmListFileLexer.in.l
+ flex --nounistd -DFLEXINT_H --noline -ocmListFileLexer.c cmListFileLexer.in.l
Modify cmListFileLexer.c:
- - remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c
- - remove blank lines at end of file
- - #include "cmStandardLexer.h" at the top
- - add cast in cmListFileLexer_yy_scan_bytes for loop condition of _yybytes_len to size_t
- - change type of variable yyl under yy_find_action from yy_size_t to int
+ - remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c
+ - remove blank lines at end of file: sed -i '${/^$/d;}' cmListFileLexer.c
+ - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmListFileLexer.c
*/
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifdef WIN32
+#ifdef _WIN32
#include "cmsys/Encoding.h"
#endif
@@ -596,15 +805,10 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer);
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
- { result = cmListFileLexerInput(cmListFileLexer_yyget_extra(yyscanner), buf, max_size); }
+ do { result = cmListFileLexerInput(cmListFileLexer_yyget_extra(yyscanner), buf, max_size); } while (0)
/*--------------------------------------------------------------------------*/
-
-
-
-#line 606 "cmListFileLexer.c"
-
#define INITIAL 0
#define STRING 1
#define BRACKET 2
@@ -649,44 +853,44 @@ struct yyguts_t
}; /* end struct yyguts_t */
-static int yy_init_globals (yyscan_t yyscanner );
+static int yy_init_globals ( yyscan_t yyscanner );
-int cmListFileLexer_yylex_init (yyscan_t* scanner);
+int yylex_init (yyscan_t* scanner);
-int cmListFileLexer_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
+int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
-int cmListFileLexer_yylex_destroy (yyscan_t yyscanner );
+int yylex_destroy ( yyscan_t yyscanner );
-int cmListFileLexer_yyget_debug (yyscan_t yyscanner );
+int yyget_debug ( yyscan_t yyscanner );
-void cmListFileLexer_yyset_debug (int debug_flag ,yyscan_t yyscanner );
+void yyset_debug ( int debug_flag , yyscan_t yyscanner );
-YY_EXTRA_TYPE cmListFileLexer_yyget_extra (yyscan_t yyscanner );
+YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
-void cmListFileLexer_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
+void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
-FILE *cmListFileLexer_yyget_in (yyscan_t yyscanner );
+FILE *yyget_in ( yyscan_t yyscanner );
-void cmListFileLexer_yyset_in (FILE * _in_str ,yyscan_t yyscanner );
+void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
-FILE *cmListFileLexer_yyget_out (yyscan_t yyscanner );
+FILE *yyget_out ( yyscan_t yyscanner );
-void cmListFileLexer_yyset_out (FILE * _out_str ,yyscan_t yyscanner );
+void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
- int cmListFileLexer_yyget_leng (yyscan_t yyscanner );
+ int yyget_leng ( yyscan_t yyscanner );
-char *cmListFileLexer_yyget_text (yyscan_t yyscanner );
+char *yyget_text ( yyscan_t yyscanner );
-int cmListFileLexer_yyget_lineno (yyscan_t yyscanner );
+int yyget_lineno ( yyscan_t yyscanner );
-void cmListFileLexer_yyset_lineno (int _line_number ,yyscan_t yyscanner );
+void yyset_lineno ( int _line_number , yyscan_t yyscanner );
-int cmListFileLexer_yyget_column (yyscan_t yyscanner );
+int yyget_column ( yyscan_t yyscanner );
-void cmListFileLexer_yyset_column (int _column_no ,yyscan_t yyscanner );
+void yyset_column ( int _column_no , yyscan_t yyscanner );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -694,32 +898,31 @@ void cmListFileLexer_yyset_column (int _column_no ,yyscan_t yyscanner );
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int cmListFileLexer_yywrap (yyscan_t yyscanner );
+extern "C" int yywrap ( yyscan_t yyscanner );
#else
-extern int cmListFileLexer_yywrap (yyscan_t yyscanner );
+extern int yywrap ( yyscan_t yyscanner );
#endif
#endif
#ifndef YY_NO_UNPUT
- static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner);
+ static void yyunput ( int c, char *buf_ptr , yyscan_t yyscanner);
#endif
#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
+static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
+static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
#endif
#ifndef YY_NO_INPUT
-
#ifdef __cplusplus
-static int yyinput (yyscan_t yyscanner );
+static int yyinput ( yyscan_t yyscanner );
#else
-static int input (yyscan_t yyscanner );
+static int input ( yyscan_t yyscanner );
#endif
#endif
@@ -750,7 +953,7 @@ static int input (yyscan_t yyscanner );
if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
int c = '*'; \
- size_t n; \
+ int n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@@ -763,7 +966,7 @@ static int input (yyscan_t yyscanner );
else \
{ \
errno=0; \
- while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
{ \
if( errno != EINTR) \
{ \
@@ -804,9 +1007,9 @@ static int input (yyscan_t yyscanner );
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-extern int cmListFileLexer_yylex (yyscan_t yyscanner);
+extern int yylex (yyscan_t yyscanner);
-#define YY_DECL int cmListFileLexer_yylex (yyscan_t yyscanner)
+#define YY_DECL int yylex (yyscan_t yyscanner)
#endif /* !YY_DECL */
/* Code executed at the beginning of each rule, after yytext and yyleng
@@ -851,19 +1054,15 @@ YY_DECL
yyout = stdout;
if ( ! YY_CURRENT_BUFFER ) {
- cmListFileLexer_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
- cmListFileLexer_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
}
- cmListFileLexer_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
}
{
-#line 80 "cmListFileLexer.in.l"
-
-
-#line 866 "cmListFileLexer.c"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
@@ -890,13 +1089,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 77 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ if ( yy_current_state >= 79 )
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
++yy_cp;
}
- while ( yy_base[yy_current_state] != 237 );
+ while ( yy_base[yy_current_state] != 298 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -935,7 +1134,6 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
/* rule 1 can match eol */
YY_RULE_SETUP
-#line 82 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_Newline;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -948,7 +1146,6 @@ YY_RULE_SETUP
case 2:
/* rule 2 can match eol */
YY_RULE_SETUP
-#line 91 "cmListFileLexer.in.l"
{
const char* bracket = yytext;
lexer->comment = yytext[0] == '#';
@@ -971,7 +1168,6 @@ YY_RULE_SETUP
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 111 "cmListFileLexer.in.l"
{
lexer->column += yyleng;
BEGIN(COMMENT);
@@ -979,14 +1175,12 @@ YY_RULE_SETUP
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 116 "cmListFileLexer.in.l"
{
lexer->column += yyleng;
}
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 120 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_ParenLeft;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -996,7 +1190,6 @@ YY_RULE_SETUP
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 127 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_ParenRight;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1006,7 +1199,6 @@ YY_RULE_SETUP
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 134 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_Identifier;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1016,7 +1208,6 @@ YY_RULE_SETUP
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 141 "cmListFileLexer.in.l"
{
/* Handle ]]====]=======]*/
cmListFileLexerAppend(lexer, yytext, yyleng);
@@ -1028,7 +1219,6 @@ YY_RULE_SETUP
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 150 "cmListFileLexer.in.l"
{
lexer->column += yyleng;
/* Erase the partial bracket from the token. */
@@ -1040,7 +1230,6 @@ YY_RULE_SETUP
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 159 "cmListFileLexer.in.l"
{
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
@@ -1049,7 +1238,6 @@ YY_RULE_SETUP
case 11:
/* rule 11 can match eol */
YY_RULE_SETUP
-#line 164 "cmListFileLexer.in.l"
{
cmListFileLexerAppend(lexer, yytext, yyleng);
++lexer->line;
@@ -1059,7 +1247,6 @@ YY_RULE_SETUP
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 171 "cmListFileLexer.in.l"
{
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
@@ -1068,7 +1255,6 @@ YY_RULE_SETUP
YY_BREAK
case YY_STATE_EOF(BRACKET):
case YY_STATE_EOF(BRACKETEND):
-#line 177 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_BadBracket;
BEGIN(INITIAL);
@@ -1077,7 +1263,6 @@ case YY_STATE_EOF(BRACKETEND):
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 183 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1087,7 +1272,6 @@ YY_RULE_SETUP
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 190 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1097,7 +1281,6 @@ YY_RULE_SETUP
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 197 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_ArgumentUnquoted;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1107,7 +1290,6 @@ YY_RULE_SETUP
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 204 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_ArgumentQuoted;
cmListFileLexerSetToken(lexer, "", 0);
@@ -1117,7 +1299,6 @@ YY_RULE_SETUP
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 211 "cmListFileLexer.in.l"
{
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
@@ -1126,7 +1307,6 @@ YY_RULE_SETUP
case 18:
/* rule 18 can match eol */
YY_RULE_SETUP
-#line 216 "cmListFileLexer.in.l"
{
/* Continuation: text is not part of string */
++lexer->line;
@@ -1136,7 +1316,6 @@ YY_RULE_SETUP
case 19:
/* rule 19 can match eol */
YY_RULE_SETUP
-#line 222 "cmListFileLexer.in.l"
{
cmListFileLexerAppend(lexer, yytext, yyleng);
++lexer->line;
@@ -1145,7 +1324,6 @@ YY_RULE_SETUP
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 228 "cmListFileLexer.in.l"
{
lexer->column += yyleng;
BEGIN(INITIAL);
@@ -1154,14 +1332,12 @@ YY_RULE_SETUP
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 234 "cmListFileLexer.in.l"
{
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
}
YY_BREAK
case YY_STATE_EOF(STRING):
-#line 239 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_BadString;
BEGIN(INITIAL);
@@ -1170,7 +1346,6 @@ case YY_STATE_EOF(STRING):
YY_BREAK
case 22:
YY_RULE_SETUP
-#line 245 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_Space;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1180,7 +1355,6 @@ YY_RULE_SETUP
YY_BREAK
case 23:
YY_RULE_SETUP
-#line 252 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_BadCharacter;
cmListFileLexerSetToken(lexer, yytext, yyleng);
@@ -1190,7 +1364,6 @@ YY_RULE_SETUP
YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT):
-#line 259 "cmListFileLexer.in.l"
{
lexer->token.type = cmListFileLexer_Token_None;
cmListFileLexerSetToken(lexer, 0, 0);
@@ -1199,10 +1372,8 @@ case YY_STATE_EOF(COMMENT):
YY_BREAK
case 24:
YY_RULE_SETUP
-#line 265 "cmListFileLexer.in.l"
ECHO;
YY_BREAK
-#line 1205 "cmListFileLexer.c"
case YY_END_OF_BUFFER:
{
@@ -1218,7 +1389,7 @@ ECHO;
/* We're scanning a new file or input source. It's
* possible that this happened because the user
* just pointed yyin at a new source and called
- * cmListFileLexer_yylex(). If so, then we have to assure
+ * yylex(). If so, then we have to assure
* consistency between YY_CURRENT_BUFFER and our
* globals. Here is the right place to do so, because
* this is the first action (other than possibly a
@@ -1278,7 +1449,7 @@ ECHO;
{
yyg->yy_did_buffer_switch_on_eof = 0;
- if ( cmListFileLexer_yywrap(yyscanner ) )
+ if ( yywrap( yyscanner ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
@@ -1332,7 +1503,7 @@ ECHO;
} /* end of action switch */
} /* end of scanning one token */
} /* end of user's declarations */
-} /* end of cmListFileLexer_yylex */
+} /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer
*
@@ -1346,7 +1517,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
char *source = yyg->yytext_ptr;
- yy_size_t number_to_move, i;
+ int number_to_move, i;
int ret_val;
if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
@@ -1375,7 +1546,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
/* Try to read more data. */
/* First move last chars to start of buffer. */
- number_to_move = (yy_size_t) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
+ number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
@@ -1411,7 +1582,8 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
- cmListFileLexer_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
+ yyrealloc( (void *) b->yy_ch_buf,
+ (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
}
else
/* Can't grow it, we don't own it. */
@@ -1443,7 +1615,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
- cmListFileLexer_yyrestart(yyin ,yyscanner);
+ yyrestart( yyin , yyscanner);
}
else
@@ -1457,12 +1629,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
ret_val = EOB_ACT_CONTINUE_SCAN;
- if ((int) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
/* Extend the array by 50%, plus the number we really need. */
int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) cmListFileLexer_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
+ (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ /* "- 2" to take care of EOB's */
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
}
yyg->yy_n_chars += number_to_move;
@@ -1486,7 +1661,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
{
- YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 16);
if ( yy_accept[yy_current_state] )
{
yyg->yy_last_accepting_state = yy_current_state;
@@ -1495,10 +1670,10 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 77 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ if ( yy_current_state >= 79 )
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
}
return yy_current_state;
@@ -1515,7 +1690,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
char *yy_cp = yyg->yy_c_buf_p;
- YY_CHAR yy_c = 1;
+ YY_CHAR yy_c = 16;
if ( yy_accept[yy_current_state] )
{
yyg->yy_last_accepting_state = yy_current_state;
@@ -1524,11 +1699,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 77 )
- yy_c = yy_meta[(unsigned int) yy_c];
+ if ( yy_current_state >= 79 )
+ yy_c = yy_meta[yy_c];
}
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
- yy_is_jam = (yy_current_state == 76);
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
+ yy_is_jam = (yy_current_state == 78);
(void)yyg;
return yy_is_jam ? 0 : yy_current_state;
@@ -1605,7 +1780,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
{ /* need more input */
- int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+ int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
++yyg->yy_c_buf_p;
switch ( yy_get_next_buffer( yyscanner ) )
@@ -1622,13 +1797,13 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
*/
/* Reset buffer status. */
- cmListFileLexer_yyrestart(yyin ,yyscanner);
+ yyrestart( yyin , yyscanner);
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
- if ( cmListFileLexer_yywrap(yyscanner ) )
+ if ( yywrap( yyscanner ) )
return 0;
if ( ! yyg->yy_did_buffer_switch_on_eof )
@@ -1667,34 +1842,34 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @note This function does not reset the start condition to @c INITIAL .
*/
- void cmListFileLexer_yyrestart (FILE * input_file , yyscan_t yyscanner)
+ void yyrestart (FILE * input_file , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! YY_CURRENT_BUFFER ){
- cmListFileLexer_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
YY_CURRENT_BUFFER_LVALUE =
- cmListFileLexer_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
+ yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
}
- cmListFileLexer_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
- cmListFileLexer_yy_load_buffer_state(yyscanner );
+ yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
+ yy_load_buffer_state( yyscanner );
}
/** Switch to a different input buffer.
* @param new_buffer The new input buffer.
* @param yyscanner The scanner object.
*/
- void cmListFileLexer_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* TODO. We should be able to replace this entire function body
* with
- * cmListFileLexer_yypop_buffer_state();
- * cmListFileLexer_yypush_buffer_state(new_buffer);
+ * yypop_buffer_state();
+ * yypush_buffer_state(new_buffer);
*/
- cmListFileLexer_yyensure_buffer_stack (yyscanner);
+ yyensure_buffer_stack (yyscanner);
if ( YY_CURRENT_BUFFER == new_buffer )
return;
@@ -1707,17 +1882,17 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
}
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- cmListFileLexer_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
/* We don't actually know whether we did this switch during
- * EOF (cmListFileLexer_yywrap()) processing, but the only time this flag
- * is looked at is after cmListFileLexer_yywrap() is called, so it's safe
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
* to go ahead and always set it.
*/
yyg->yy_did_buffer_switch_on_eof = 1;
}
-static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner)
+static void yy_load_buffer_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
@@ -1732,35 +1907,35 @@ static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the allocated buffer state.
*/
- YY_BUFFER_STATE cmListFileLexer_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
+ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
- b = (YY_BUFFER_STATE) cmListFileLexer_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_create_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
- b->yy_buf_size = (yy_size_t)size;
+ b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
- b->yy_ch_buf = (char *) cmListFileLexer_yyalloc(b->yy_buf_size + 2 ,yyscanner );
+ b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_create_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
- cmListFileLexer_yy_init_buffer(b,file ,yyscanner);
+ yy_init_buffer( b, file , yyscanner);
return b;
}
/** Destroy the buffer.
- * @param b a buffer created with cmListFileLexer_yy_create_buffer()
+ * @param b a buffer created with yy_create_buffer()
* @param yyscanner The scanner object.
*/
- void cmListFileLexer_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+ void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -1771,28 +1946,28 @@ static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner)
YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
- cmListFileLexer_yyfree((void *) b->yy_ch_buf ,yyscanner );
+ yyfree( (void *) b->yy_ch_buf , yyscanner );
- cmListFileLexer_yyfree((void *) b ,yyscanner );
+ yyfree( (void *) b , yyscanner );
}
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
- * such as during a cmListFileLexer_yyrestart() or at EOF.
+ * such as during a yyrestart() or at EOF.
*/
- static void cmListFileLexer_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
+ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
{
int oerrno = errno;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
- cmListFileLexer_yy_flush_buffer(b ,yyscanner);
+ yy_flush_buffer( b , yyscanner);
b->yy_input_file = file;
b->yy_fill_buffer = 1;
- /* If b is the current buffer, then cmListFileLexer_yy_init_buffer was _probably_
- * called from cmListFileLexer_yyrestart() or through yy_get_next_buffer.
+ /* If b is the current buffer, then yy_init_buffer was _probably_
+ * called from yyrestart() or through yy_get_next_buffer.
* In that case, we don't want to reset the lineno or column.
*/
if (b != YY_CURRENT_BUFFER){
@@ -1809,7 +1984,7 @@ static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner)
* @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
* @param yyscanner The scanner object.
*/
- void cmListFileLexer_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
+ void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if ( ! b )
@@ -1830,7 +2005,7 @@ static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner)
b->yy_buffer_status = YY_BUFFER_NEW;
if ( b == YY_CURRENT_BUFFER )
- cmListFileLexer_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
}
/** Pushes the new state onto the stack. The new state becomes
@@ -1839,15 +2014,15 @@ static void cmListFileLexer_yy_load_buffer_state (yyscan_t yyscanner)
* @param new_buffer The new state.
* @param yyscanner The scanner object.
*/
-void cmListFileLexer_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (new_buffer == NULL)
return;
- cmListFileLexer_yyensure_buffer_stack(yyscanner);
+ yyensure_buffer_stack(yyscanner);
- /* This block is copied from cmListFileLexer_yy_switch_to_buffer. */
+ /* This block is copied from yy_switch_to_buffer. */
if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
@@ -1861,8 +2036,8 @@ void cmListFileLexer_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t
yyg->yy_buffer_stack_top++;
YY_CURRENT_BUFFER_LVALUE = new_buffer;
- /* copied from cmListFileLexer_yy_switch_to_buffer. */
- cmListFileLexer_yy_load_buffer_state(yyscanner );
+ /* copied from yy_switch_to_buffer. */
+ yy_load_buffer_state( yyscanner );
yyg->yy_did_buffer_switch_on_eof = 1;
}
@@ -1870,19 +2045,19 @@ void cmListFileLexer_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t
* The next element becomes the new top.
* @param yyscanner The scanner object.
*/
-void cmListFileLexer_yypop_buffer_state (yyscan_t yyscanner)
+void yypop_buffer_state (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!YY_CURRENT_BUFFER)
return;
- cmListFileLexer_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
+ yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
YY_CURRENT_BUFFER_LVALUE = NULL;
if (yyg->yy_buffer_stack_top > 0)
--yyg->yy_buffer_stack_top;
if (YY_CURRENT_BUFFER) {
- cmListFileLexer_yy_load_buffer_state(yyscanner );
+ yy_load_buffer_state( yyscanner );
yyg->yy_did_buffer_switch_on_eof = 1;
}
}
@@ -1890,9 +2065,9 @@ void cmListFileLexer_yypop_buffer_state (yyscan_t yyscanner)
/* Allocates the stack if it does not exist.
* Guarantees space for at least one push.
*/
-static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner)
+static void yyensure_buffer_stack (yyscan_t yyscanner)
{
- int num_to_alloc;
+ yy_size_t num_to_alloc;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!yyg->yy_buffer_stack) {
@@ -1902,11 +2077,11 @@ static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner)
* immediate realloc on the next call.
*/
num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
- yyg->yy_buffer_stack = (struct yy_buffer_state**)cmListFileLexer_yyalloc
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
- YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yyensure_buffer_stack()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
@@ -1921,12 +2096,12 @@ static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner)
yy_size_t grow_size = 8 /* arbitrary grow size */;
num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
- yyg->yy_buffer_stack = (struct yy_buffer_state**)cmListFileLexer_yyrealloc
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
(yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
- YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yyensure_buffer_stack()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -1940,7 +2115,7 @@ static void cmListFileLexer_yyensure_buffer_stack (yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE cmListFileLexer_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
@@ -1950,11 +2125,11 @@ YY_BUFFER_STATE cmListFileLexer_yy_scan_buffer (char * base, yy_size_t size ,
/* They forgot to leave room for the EOB's. */
return NULL;
- b = (YY_BUFFER_STATE) cmListFileLexer_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
+ b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_scan_buffer()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
b->yy_buf_pos = b->yy_ch_buf = base;
b->yy_is_our_buffer = 0;
b->yy_input_file = NULL;
@@ -1964,53 +2139,53 @@ YY_BUFFER_STATE cmListFileLexer_yy_scan_buffer (char * base, yy_size_t size ,
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
- cmListFileLexer_yy_switch_to_buffer(b ,yyscanner );
+ yy_switch_to_buffer( b , yyscanner );
return b;
}
-/** Setup the input buffer state to scan a string. The next call to cmListFileLexer_yylex() will
+/** Setup the input buffer state to scan a string. The next call to yylex() will
* scan from a @e copy of @a str.
* @param yystr a NUL-terminated string to scan
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
* @note If you want to scan bytes that may contain NUL values, then use
- * cmListFileLexer_yy_scan_bytes() instead.
+ * yy_scan_bytes() instead.
*/
-YY_BUFFER_STATE cmListFileLexer_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
{
- return cmListFileLexer_yy_scan_bytes(yystr,(int) strlen(yystr) ,yyscanner);
+ return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
}
-/** Setup the input buffer state to scan the given bytes. The next call to cmListFileLexer_yylex() will
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
* scan from a @e copy of @a bytes.
* @param yybytes the byte buffer to scan
* @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
- yy_size_t i;
+ int i;
/* Get memory for full buffer, including space for trailing EOB's. */
- n = (yy_size_t) _yybytes_len + 2;
- buf = (char *) cmListFileLexer_yyalloc(n ,yyscanner );
+ n = (yy_size_t) (_yybytes_len + 2);
+ buf = (char *) yyalloc( n , yyscanner );
if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in cmListFileLexer_yy_scan_bytes()" );
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
- for ( i = 0; i < (size_t)_yybytes_len; ++i )
+ for ( i = 0; i < _yybytes_len; ++i )
buf[i] = yybytes[i];
buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
- b = cmListFileLexer_yy_scan_buffer(buf,n ,yyscanner);
+ b = yy_scan_buffer( buf, n , yyscanner);
if ( ! b )
- YY_FATAL_ERROR( "bad buffer in cmListFileLexer_yy_scan_bytes()" );
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
/* It's okay to grow etc. this buffer, and we should throw it
* away when we're done.
@@ -2024,11 +2199,11 @@ YY_BUFFER_STATE cmListFileLexer_yy_scan_bytes (yyconst char * yybytes, int _yy
#define YY_EXIT_FAILURE 2
#endif
-static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
+static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
- (void) fprintf( stderr, "%s\n", msg );
+ fprintf( stderr, "%s\n", msg );
exit( YY_EXIT_FAILURE );
}
@@ -2054,7 +2229,7 @@ static void yynoreturn yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
/** Get the user-defined data for this scanner.
* @param yyscanner The scanner object.
*/
-YY_EXTRA_TYPE cmListFileLexer_yyget_extra (yyscan_t yyscanner)
+YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyextra;
@@ -2063,7 +2238,7 @@ YY_EXTRA_TYPE cmListFileLexer_yyget_extra (yyscan_t yyscanner)
/** Get the current line number.
* @param yyscanner The scanner object.
*/
-int cmListFileLexer_yyget_lineno (yyscan_t yyscanner)
+int yyget_lineno (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -2076,7 +2251,7 @@ int cmListFileLexer_yyget_lineno (yyscan_t yyscanner)
/** Get the current column number.
* @param yyscanner The scanner object.
*/
-int cmListFileLexer_yyget_column (yyscan_t yyscanner)
+int yyget_column (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -2089,7 +2264,7 @@ int cmListFileLexer_yyget_column (yyscan_t yyscanner)
/** Get the input stream.
* @param yyscanner The scanner object.
*/
-FILE *cmListFileLexer_yyget_in (yyscan_t yyscanner)
+FILE *yyget_in (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyin;
@@ -2098,7 +2273,7 @@ FILE *cmListFileLexer_yyget_in (yyscan_t yyscanner)
/** Get the output stream.
* @param yyscanner The scanner object.
*/
-FILE *cmListFileLexer_yyget_out (yyscan_t yyscanner)
+FILE *yyget_out (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyout;
@@ -2107,7 +2282,7 @@ FILE *cmListFileLexer_yyget_out (yyscan_t yyscanner)
/** Get the length of the current token.
* @param yyscanner The scanner object.
*/
-int cmListFileLexer_yyget_leng (yyscan_t yyscanner)
+int yyget_leng (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyleng;
@@ -2117,7 +2292,7 @@ int cmListFileLexer_yyget_leng (yyscan_t yyscanner)
* @param yyscanner The scanner object.
*/
-char *cmListFileLexer_yyget_text (yyscan_t yyscanner)
+char *yyget_text (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yytext;
@@ -2127,7 +2302,7 @@ char *cmListFileLexer_yyget_text (yyscan_t yyscanner)
* @param user_defined The data to be associated with this scanner.
* @param yyscanner The scanner object.
*/
-void cmListFileLexer_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
+void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyextra = user_defined ;
@@ -2137,13 +2312,13 @@ void cmListFileLexer_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscann
* @param _line_number line number
* @param yyscanner The scanner object.
*/
-void cmListFileLexer_yyset_lineno (int _line_number , yyscan_t yyscanner)
+void yyset_lineno (int _line_number , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* lineno is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "cmListFileLexer_yyset_lineno called with no buffer" );
+ YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
yylineno = _line_number;
}
@@ -2152,13 +2327,13 @@ void cmListFileLexer_yyset_lineno (int _line_number , yyscan_t yyscanner)
* @param _column_no column number
* @param yyscanner The scanner object.
*/
-void cmListFileLexer_yyset_column (int _column_no , yyscan_t yyscanner)
+void yyset_column (int _column_no , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* column is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- YY_FATAL_ERROR( "cmListFileLexer_yyset_column called with no buffer" );
+ YY_FATAL_ERROR( "yyset_column called with no buffer" );
yycolumn = _column_no;
}
@@ -2167,27 +2342,27 @@ void cmListFileLexer_yyset_column (int _column_no , yyscan_t yyscanner)
* input buffer.
* @param _in_str A readable stream.
* @param yyscanner The scanner object.
- * @see cmListFileLexer_yy_switch_to_buffer
+ * @see yy_switch_to_buffer
*/
-void cmListFileLexer_yyset_in (FILE * _in_str , yyscan_t yyscanner)
+void yyset_in (FILE * _in_str , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyin = _in_str ;
}
-void cmListFileLexer_yyset_out (FILE * _out_str , yyscan_t yyscanner)
+void yyset_out (FILE * _out_str , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yyout = _out_str ;
}
-int cmListFileLexer_yyget_debug (yyscan_t yyscanner)
+int yyget_debug (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yy_flex_debug;
}
-void cmListFileLexer_yyset_debug (int _bdebug , yyscan_t yyscanner)
+void yyset_debug (int _bdebug , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yy_flex_debug = _bdebug ;
@@ -2197,20 +2372,18 @@ void cmListFileLexer_yyset_debug (int _bdebug , yyscan_t yyscanner)
/* User-visible API */
-/* cmListFileLexer_yylex_init is special because it creates the scanner itself, so it is
+/* yylex_init is special because it creates the scanner itself, so it is
* the ONLY reentrant function that doesn't take the scanner as the last argument.
* That's why we explicitly handle the declaration, instead of using our macros.
*/
-
-int cmListFileLexer_yylex_init(yyscan_t* ptr_yy_globals)
-
+int yylex_init(yyscan_t* ptr_yy_globals)
{
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
- *ptr_yy_globals = (yyscan_t) cmListFileLexer_yyalloc ( sizeof( struct yyguts_t ), NULL );
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
@@ -2223,27 +2396,25 @@ int cmListFileLexer_yylex_init(yyscan_t* ptr_yy_globals)
return yy_init_globals ( *ptr_yy_globals );
}
-/* cmListFileLexer_yylex_init_extra has the same functionality as cmListFileLexer_yylex_init, but follows the
+/* yylex_init_extra has the same functionality as yylex_init, but follows the
* convention of taking the scanner as the last argument. Note however, that
* this is a *pointer* to a scanner, as it will be allocated by this call (and
* is the reason, too, why this function also must handle its own declaration).
- * The user defined value in the first argument will be available to cmListFileLexer_yyalloc in
+ * The user defined value in the first argument will be available to yyalloc in
* the yyextra field.
*/
-
-int cmListFileLexer_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
-
+int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
{
struct yyguts_t dummy_yyguts;
- cmListFileLexer_yyset_extra (yy_user_defined, &dummy_yyguts);
+ yyset_extra (yy_user_defined, &dummy_yyguts);
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
- *ptr_yy_globals = (yyscan_t) cmListFileLexer_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
@@ -2254,7 +2425,7 @@ int cmListFileLexer_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr
yy_init_globals. Leave at 0x00 for releases. */
memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
- cmListFileLexer_yyset_extra (yy_user_defined, *ptr_yy_globals);
+ yyset_extra (yy_user_defined, *ptr_yy_globals);
return yy_init_globals ( *ptr_yy_globals );
}
@@ -2263,7 +2434,7 @@ static int yy_init_globals (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Initialization is the same as for the non-reentrant scanner.
- * This function is called from cmListFileLexer_yylex_destroy(), so don't allocate here.
+ * This function is called from yylex_destroy(), so don't allocate here.
*/
yyg->yy_buffer_stack = NULL;
@@ -2287,37 +2458,37 @@ static int yy_init_globals (yyscan_t yyscanner)
#endif
/* For future reference: Set errno on error, since we are called by
- * cmListFileLexer_yylex_init()
+ * yylex_init()
*/
return 0;
}
-/* cmListFileLexer_yylex_destroy is for both reentrant and non-reentrant scanners. */
-int cmListFileLexer_yylex_destroy (yyscan_t yyscanner)
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
+int yylex_destroy (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Pop the buffer stack, destroying each element. */
while(YY_CURRENT_BUFFER){
- cmListFileLexer_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
+ yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
YY_CURRENT_BUFFER_LVALUE = NULL;
- cmListFileLexer_yypop_buffer_state(yyscanner);
+ yypop_buffer_state(yyscanner);
}
/* Destroy the stack itself. */
- cmListFileLexer_yyfree(yyg->yy_buffer_stack ,yyscanner);
+ yyfree(yyg->yy_buffer_stack , yyscanner);
yyg->yy_buffer_stack = NULL;
/* Destroy the start condition stack. */
- cmListFileLexer_yyfree(yyg->yy_start_stack ,yyscanner );
+ yyfree( yyg->yy_start_stack , yyscanner );
yyg->yy_start_stack = NULL;
/* Reset the globals. This is important in a non-reentrant scanner so the next time
- * cmListFileLexer_yylex() is called, initialization will occur. */
+ * yylex() is called, initialization will occur. */
yy_init_globals( yyscanner);
/* Destroy the main struct (reentrant only). */
- cmListFileLexer_yyfree ( yyscanner , yyscanner );
+ yyfree ( yyscanner , yyscanner );
yyscanner = NULL;
return 0;
}
@@ -2327,7 +2498,7 @@ int cmListFileLexer_yylex_destroy (yyscan_t yyscanner)
*/
#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
+static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
@@ -2339,7 +2510,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
+static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
{
int n;
for ( n = 0; s[n]; ++n )
@@ -2349,14 +2520,14 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
}
#endif
-void *cmListFileLexer_yyalloc (yy_size_t size , yyscan_t yyscanner)
+void *yyalloc (yy_size_t size , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
return malloc(size);
}
-void *cmListFileLexer_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
+void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
@@ -2371,19 +2542,15 @@ void *cmListFileLexer_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscann
return realloc(ptr, size);
}
-void cmListFileLexer_yyfree (void * ptr , yyscan_t yyscanner)
+void yyfree (void * ptr , yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
(void)yyg;
- free( (char *) ptr ); /* see cmListFileLexer_yyrealloc() for (char *) cast */
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
}
#define YYTABLES_NAME "yytables"
-#line 265 "cmListFileLexer.in.l"
-
-
-
/*--------------------------------------------------------------------------*/
static void cmListFileLexerSetToken(cmListFileLexer* lexer, const char* text,
int length)
diff --git a/Source/LexerParser/cmListFileLexer.in.l b/Source/LexerParser/cmListFileLexer.in.l
index 5152dbf08..fdf14d2d3 100644
--- a/Source/LexerParser/cmListFileLexer.in.l
+++ b/Source/LexerParser/cmListFileLexer.in.l
@@ -7,20 +7,18 @@ This file must be translated to C and modified to build everywhere.
Run flex >= 2.6 like this:
- flex --nounistd -DFLEXINT_H --prefix=cmListFileLexer_yy -ocmListFileLexer.c cmListFileLexer.in.l
+ flex --nounistd -DFLEXINT_H --noline -ocmListFileLexer.c cmListFileLexer.in.l
Modify cmListFileLexer.c:
- - remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c
- - remove blank lines at end of file
- - #include "cmStandardLexer.h" at the top
- - add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t
- - change type of variable yyl under yy_find_action from yy_size_t to int
+ - remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c
+ - remove blank lines at end of file: sed -i '${/^$/d;}' cmListFileLexer.c
+ - #include "cmStandardLexer.h" at the top: sed -i '1i#include "cmStandardLexer.h"' cmListFileLexer.c
*/
/* IWYU pragma: no_forward_declare yyguts_t */
-#ifdef WIN32
+#ifdef _WIN32
#include "cmsys/Encoding.h"
#endif
@@ -59,11 +57,13 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer);
/* Replace the lexer input function. */
#undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \
- { result = cmListFileLexerInput(cmListFileLexer_yyget_extra(yyscanner), buf, max_size); }
+ do { result = cmListFileLexerInput(cmListFileLexer_yyget_extra(yyscanner), buf, max_size); } while (0)
/*--------------------------------------------------------------------------*/
%}
+%option prefix="cmListFileLexer_yy"
+
%option reentrant
%option yylineno
%option noyywrap
@@ -74,7 +74,7 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer);
%x COMMENT
MAKEVAR \$\([A-Za-z0-9_]*\)
-UNQUOTED ([^ \t\r\n\(\)#\\\"[=]|\\.)
+UNQUOTED ([^ \0\t\r\n\(\)#\\\"[=]|\\[^\0\n])
LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t[=])*\"
%%
@@ -113,7 +113,7 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t[=])*\"
BEGIN(COMMENT);
}
-<COMMENT>.* {
+<COMMENT>[^\0\n]* {
lexer->column += yyleng;
}
@@ -156,7 +156,7 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t[=])*\"
return 1;
}
-<BRACKET>([^]\n])+ {
+<BRACKET>([^]\0\n])+ {
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
}
@@ -168,7 +168,7 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t[=])*\"
BEGIN(BRACKET);
}
-<BRACKET,BRACKETEND>. {
+<BRACKET,BRACKETEND>[^\0\n] {
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
BEGIN(BRACKET);
@@ -208,7 +208,7 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t[=])*\"
BEGIN(STRING);
}
-<STRING>([^\\\n\"]|\\.)+ {
+<STRING>([^\\\0\n\"]|\\[^\0\n])+ {
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
}
@@ -231,7 +231,7 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t[=])*\"
return 1;
}
-<STRING>. {
+<STRING>[^\0\n] {
cmListFileLexerAppend(lexer, yytext, yyleng);
lexer->column += yyleng;
}
@@ -439,11 +439,15 @@ static cmListFileLexer_BOM cmListFileLexer_ReadBOM(FILE* f)
if (fread(b, 1, 2, f) == 2 && b[0] == 0 && b[1] == 0) {
return cmListFileLexer_BOM_UTF32LE;
}
- fsetpos(f, &p);
+ if (fsetpos(f, &p) != 0) {
+ return cmListFileLexer_BOM_Broken;
+ }
return cmListFileLexer_BOM_UTF16LE;
}
}
- rewind(f);
+ if (fseek(f, 0, SEEK_SET) != 0) {
+ return cmListFileLexer_BOM_Broken;
+ }
return cmListFileLexer_BOM_None;
}
diff --git a/Source/Modules/CheckCXXLinkerFlag.cmake b/Source/Modules/CheckCXXLinkerFlag.cmake
new file mode 100644
index 000000000..6cb1ba3ac
--- /dev/null
+++ b/Source/Modules/CheckCXXLinkerFlag.cmake
@@ -0,0 +1,29 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+include_guard(GLOBAL)
+include(CheckCXXSourceCompiles)
+include(CMakeCheckCompilerFlagCommonPatterns)
+
+function(check_cxx_linker_flag _flag _var)
+ if(CMAKE_VERSION VERSION_LESS "3.14")
+ set(CMAKE_REQUIRED_LIBRARIES "${_flag}")
+ else()
+ set(CMAKE_REQUIRED_LINK_OPTIONS "${_flag}")
+ endif()
+
+ # Normalize locale during test compilation.
+ set(_locale_vars LC_ALL LC_MESSAGES LANG)
+ foreach(v IN LISTS _locale_vars)
+ set(_locale_vars_saved_${v} "$ENV{${v}}")
+ set(ENV{${v}} C)
+ endforeach()
+ check_compiler_flag_common_patterns(_common_patterns)
+ check_cxx_source_compiles("int main() { return 0; }" ${_var}
+ ${_common_patterns}
+ )
+ foreach(v IN LISTS _locale_vars)
+ set(ENV{${v}} ${_locale_vars_saved_${v}})
+ endforeach()
+ set(${_var} "${${_var}}" PARENT_SCOPE)
+endfunction()
diff --git a/Source/Modules/FindLibUUID.cmake b/Source/Modules/FindLibUUID.cmake
new file mode 100644
index 000000000..17f11c1f5
--- /dev/null
+++ b/Source/Modules/FindLibUUID.cmake
@@ -0,0 +1,85 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindLibUUID
+------------
+
+Find LibUUID include directory and library.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+An :ref:`imported target <Imported targets>` named
+``LibUUID::LibUUID`` is provided if LibUUID has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+``LibUUID_FOUND``
+ True if LibUUID was found, false otherwise.
+``LibUUID_INCLUDE_DIRS``
+ Include directories needed to include LibUUID headers.
+``LibUUID_LIBRARIES``
+ Libraries needed to link to LibUUID.
+
+Cache Variables
+^^^^^^^^^^^^^^^
+
+This module uses the following cache variables:
+
+``LibUUID_LIBRARY``
+ The location of the LibUUID library file.
+``LibUUID_INCLUDE_DIR``
+ The location of the LibUUID include directory containing ``uuid/uuid.h``.
+
+The cache variables should not be used by project code.
+They may be set by end users to point at LibUUID components.
+#]=======================================================================]
+
+#-----------------------------------------------------------------------------
+if(CYGWIN)
+ # Note: on current version of Cygwin, linking to libuuid.dll.a doesn't
+ # import the right symbols sometimes. Fix this by linking directly
+ # to the DLL that provides the symbols, instead.
+ set(old_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .dll)
+ find_library(LibUUID_LIBRARY
+ NAMES cyguuid-1.dll
+ )
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${old_suffixes})
+else()
+ find_library(LibUUID_LIBRARY
+ NAMES uuid
+ )
+endif()
+mark_as_advanced(LibUUID_LIBRARY)
+
+find_path(LibUUID_INCLUDE_DIR
+ NAMES uuid/uuid.h
+ )
+mark_as_advanced(LibUUID_INCLUDE_DIR)
+
+#-----------------------------------------------------------------------------
+include(${CMAKE_CURRENT_LIST_DIR}/../../Modules/FindPackageHandleStandardArgs.cmake)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibUUID
+ FOUND_VAR LibUUID_FOUND
+ REQUIRED_VARS LibUUID_LIBRARY LibUUID_INCLUDE_DIR
+ )
+set(LIBUUID_FOUND ${LibUUID_FOUND})
+
+#-----------------------------------------------------------------------------
+# Provide documented result variables and targets.
+if(LibUUID_FOUND)
+ set(LibUUID_INCLUDE_DIRS ${LibUUID_INCLUDE_DIR})
+ set(LibUUID_LIBRARIES ${LibUUID_LIBRARY})
+ if(NOT TARGET LibUUID::LibUUID)
+ add_library(LibUUID::LibUUID UNKNOWN IMPORTED)
+ set_target_properties(LibUUID::LibUUID PROPERTIES
+ IMPORTED_LOCATION "${LibUUID_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${LibUUID_INCLUDE_DIRS}"
+ )
+ endif()
+endif()
diff --git a/Source/Modules/FindLibUV.cmake b/Source/Modules/FindLibUV.cmake
index ba13d75f8..0554d62c2 100644
--- a/Source/Modules/FindLibUV.cmake
+++ b/Source/Modules/FindLibUV.cmake
@@ -63,6 +63,8 @@ mark_as_advanced(LibUV_INCLUDE_DIR)
set(_LibUV_H_REGEX "#[ \t]*define[ \t]+UV_VERSION_(MAJOR|MINOR|PATCH)[ \t]+[0-9]+")
if(LibUV_INCLUDE_DIR AND EXISTS "${LibUV_INCLUDE_DIR}/uv-version.h")
file(STRINGS "${LibUV_INCLUDE_DIR}/uv-version.h" _LibUV_H REGEX "${_LibUV_H_REGEX}")
+elseif(LibUV_INCLUDE_DIR AND EXISTS "${LibUV_INCLUDE_DIR}/uv/version.h")
+ file(STRINGS "${LibUV_INCLUDE_DIR}/uv/version.h" _LibUV_H REGEX "${_LibUV_H_REGEX}")
elseif(LibUV_INCLUDE_DIR AND EXISTS "${LibUV_INCLUDE_DIR}/uv.h")
file(STRINGS "${LibUV_INCLUDE_DIR}/uv.h" _LibUV_H REGEX "${_LibUV_H_REGEX}")
else()
diff --git a/Source/Modules/OverrideC.cmake b/Source/Modules/OverrideC.cmake
new file mode 100644
index 000000000..f8299adb0
--- /dev/null
+++ b/Source/Modules/OverrideC.cmake
@@ -0,0 +1,3 @@
+if("${CMAKE_SYSTEM_NAME};${CMAKE_C_COMPILER_ID}" STREQUAL "AIX;GNU")
+ string(APPEND CMAKE_C_FLAGS_INIT " -pthread")
+endif()
diff --git a/Source/Modules/OverrideCXX.cmake b/Source/Modules/OverrideCXX.cmake
new file mode 100644
index 000000000..13689e2c5
--- /dev/null
+++ b/Source/Modules/OverrideCXX.cmake
@@ -0,0 +1,3 @@
+if("${CMAKE_SYSTEM_NAME};${CMAKE_CXX_COMPILER_ID}" STREQUAL "AIX;GNU")
+ string(APPEND CMAKE_CXX_FLAGS_INIT " -pthread")
+endif()
diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx
index 6284ac946..f5e0777bf 100644
--- a/Source/QtDialog/AddCacheEntry.cxx
+++ b/Source/QtDialog/AddCacheEntry.cxx
@@ -21,8 +21,8 @@ AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& varNames,
, VarTypes(varTypes)
{
this->setupUi(this);
- for (int i = 0; i < NumTypes; i++) {
- this->Type->addItem(TypeStrings[i]);
+ for (auto const& elem : TypeStrings) {
+ this->Type->addItem(elem);
}
QWidget* cb = new QCheckBox();
QWidget* path = new QCMakePathEditor();
@@ -32,12 +32,12 @@ AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& varNames,
this->StackedWidget->addWidget(path);
this->StackedWidget->addWidget(filepath);
this->StackedWidget->addWidget(string);
- this->setTabOrder(this->Name, this->Type);
- this->setTabOrder(this->Type, cb);
- this->setTabOrder(cb, path);
- this->setTabOrder(path, filepath);
- this->setTabOrder(filepath, string);
- this->setTabOrder(string, this->Description);
+ AddCacheEntry::setTabOrder(this->Name, this->Type);
+ AddCacheEntry::setTabOrder(this->Type, cb);
+ AddCacheEntry::setTabOrder(cb, path);
+ AddCacheEntry::setTabOrder(path, filepath);
+ AddCacheEntry::setTabOrder(filepath, string);
+ AddCacheEntry::setTabOrder(string, this->Description);
QCompleter* completer = new QCompleter(this->VarNames, this);
this->Name->setCompleter(completer);
connect(completer, SIGNAL(activated(const QString&)), this,
diff --git a/Source/QtDialog/AddCacheEntry.h b/Source/QtDialog/AddCacheEntry.h
index cc710f558..e7a60ddb3 100644
--- a/Source/QtDialog/AddCacheEntry.h
+++ b/Source/QtDialog/AddCacheEntry.h
@@ -4,14 +4,15 @@
#define AddCacheEntry_h
#include "QCMake.h"
-
#include <QCheckBox>
#include <QStringList>
#include <QWidget>
#include "ui_AddCacheEntry.h"
-class AddCacheEntry : public QWidget, public Ui::AddCacheEntry
+class AddCacheEntry
+ : public QWidget
+ , public Ui::AddCacheEntry
{
Q_OBJECT
public:
diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt
index 9e9df781e..cb89d19fd 100644
--- a/Source/QtDialog/CMakeLists.txt
+++ b/Source/QtDialog/CMakeLists.txt
@@ -2,9 +2,6 @@
# file Copyright.txt or https://cmake.org/licensing for details.
project(QtDialog)
-if(POLICY CMP0020)
- cmake_policy(SET CMP0020 NEW) # Drop when CMake >= 2.8.11 required
-endif()
CMake_OPTIONAL_COMPONENT(cmake-gui)
find_package(Qt5Widgets QUIET)
if (Qt5Widgets_FOUND)
@@ -19,9 +16,20 @@ if (Qt5Widgets_FOUND)
macro(qt4_add_resources)
qt5_add_resources(${ARGN})
endmacro()
+
set(CMake_QT_LIBRARIES ${Qt5Widgets_LIBRARIES})
set(QT_QTMAIN_LIBRARY ${Qt5Core_QTMAIN_LIBRARIES})
+ # Try to find the package WinExtras for the task bar progress
+ if(WIN32)
+ find_package(Qt5WinExtras QUIET)
+ if (Qt5WinExtras_FOUND)
+ include_directories(${Qt5WinExtras_INCLUDE_DIRS})
+ add_definitions(-DQT_WINEXTRAS)
+ list(APPEND CMake_QT_LIBRARIES ${Qt5WinExtras_LIBRARIES})
+ endif()
+ endif()
+
# Remove this when the minimum version of Qt is 4.6.
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
@@ -33,8 +41,14 @@ if (Qt5Widgets_FOUND)
PROPERTY COMPILE_DEFINITIONS USE_QXcbIntegrationPlugin)
endif()
+ if(CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES)
+ list(APPEND CMake_QT_LIBRARIES ${CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES})
+ set_property(SOURCE CMakeSetup.cxx
+ PROPERTY COMPILE_DEFINITIONS USE_QWindowsIntegrationPlugin)
+ endif()
+
# We need to install platform plugin and add qt.conf for Qt5 on Mac and Windows.
- # FIXME: This should be part of Qt5 CMake scripts, but unfortunatelly
+ # FIXME: This should be part of Qt5 CMake scripts, but unfortunately
# Qt5 support is missing there.
if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32))
macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var)
@@ -65,7 +79,7 @@ if (Qt5Widgets_FOUND)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
DESTINATION "${CMAKE_INSTALL_PREFIX}/Resources"
${COMPONENT})
- elseif(WIN32)
+ elseif(WIN32 AND NOT CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES)
install_qt5_plugin("Qt5::QWindowsIntegrationPlugin" QT_PLUGINS)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf"
"[Paths]\nPlugins = ../${_qt_plugin_dir}\n")
@@ -160,6 +174,10 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS} ${MANIFEST_FILE})
target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${CMake_QT_LIBRARIES})
+if(WIN32)
+ target_sources(cmake-gui PRIVATE $<TARGET_OBJECTS:CMakeVersion>)
+endif()
+
# cmake-gui has not been updated for `include-what-you-use`.
# Block the tool until this is done.
set_target_properties(cmake-gui PROPERTIES
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index 7fa2ac661..ee81a7d62 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -1,16 +1,8 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#include "QCMake.h" // include to disable MS warnings
+#include <iostream>
-#include "CMakeSetupDialog.h"
-#include "cmAlgorithms.h"
-#include "cmDocumentation.h"
-#include "cmDocumentationEntry.h"
-#include "cmVersion.h"
-#include "cmake.h"
-#include "cmsys/CommandLineArguments.hxx"
-#include "cmsys/Encoding.hxx"
-#include "cmsys/SystemTools.hxx"
+#include "QCMake.h" // include to disable MS warnings
#include <QApplication>
#include <QDir>
#include <QLocale>
@@ -18,23 +10,34 @@
#include <QTextCodec>
#include <QTranslator>
#include <QtPlugin>
-#include <iostream>
+#include "cmsys/CommandLineArguments.hxx"
+#include "cmsys/Encoding.hxx"
+#include "cmsys/SystemTools.hxx"
+
+#include "CMakeSetupDialog.h"
+#include "cmAlgorithms.h"
+#include "cmDocumentation.h"
+#include "cmDocumentationEntry.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h" // IWYU pragma: keep
+#include "cmVersion.h"
+#include "cmake.h"
-static const char* cmDocumentationName[][2] = { { CM_NULLPTR,
+static const char* cmDocumentationName[][2] = { { nullptr,
" cmake-gui - CMake GUI." },
- { CM_NULLPTR, CM_NULLPTR } };
+ { nullptr, nullptr } };
static const char* cmDocumentationUsage[][2] = {
- { CM_NULLPTR, " cmake-gui [options]\n"
- " cmake-gui [options] <path-to-source>\n"
- " cmake-gui [options] <path-to-existing-build>" },
- { CM_NULLPTR, CM_NULLPTR }
+ { nullptr,
+ " cmake-gui [options]\n"
+ " cmake-gui [options] <path-to-source>\n"
+ " cmake-gui [options] <path-to-existing-build>\n"
+ " cmake-gui [options] -S <path-to-source> -B <path-to-build>\n" },
+ { nullptr, nullptr }
};
-static const char* cmDocumentationOptions[]
- [2] = { { CM_NULLPTR, CM_NULLPTR } };
+static const char* cmDocumentationOptions[][2] = { { nullptr, nullptr } };
#if defined(Q_OS_MAC)
static int cmOSXInstall(std::string dir);
@@ -45,13 +48,22 @@ static void cmAddPluginPath();
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
#endif
+#if defined(USE_QWindowsIntegrationPlugin)
+Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
+# if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
+Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin);
+# endif
+#endif
+
int main(int argc, char** argv)
{
+ cmSystemTools::EnsureStdPipes();
cmsys::Encoding::CommandLineArguments encoding_args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
int argc2 = encoding_args.argc();
char const* const* argv2 = encoding_args.argv();
+ cmSystemTools::InitializeLibUV();
cmSystemTools::FindCMakeResources(argv2[0]);
// check docs first so that X is not need to get docs
// do docs, if args were given
@@ -59,13 +71,12 @@ int main(int argc, char** argv)
doc.addCMakeStandardDocSections();
if (argc2 > 1 && doc.CheckOptions(argc2, argv2)) {
// Construct and print requested documentation.
- cmake hcm(cmake::RoleInternal);
+ cmake hcm(cmake::RoleInternal, cmState::Unknown);
hcm.SetHomeDirectory("");
hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
- std::vector<cmDocumentationEntry> generators;
- hcm.GetGeneratorDocumentation(generators);
+ auto generators = hcm.GetGeneratorsDocumentation();
doc.SetName("cmake");
doc.SetSection("Name", cmDocumentationName);
doc.SetSection("Usage", cmDocumentationUsage);
@@ -93,6 +104,10 @@ int main(int argc, char** argv)
cmAddPluginPath();
#endif
+#if QT_VERSION >= 0x050600
+ QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
+
QApplication app(argc, argv);
setlocale(LC_NUMERIC, "C");
@@ -121,36 +136,66 @@ int main(int argc, char** argv)
QTranslator translator;
QString transfile = QString("cmake_%1").arg(QLocale::system().name());
translator.load(transfile, translationsDir.path());
- app.installTranslator(&translator);
+ QApplication::installTranslator(&translator);
// app setup
- app.setApplicationName("CMakeSetup");
- app.setOrganizationName("Kitware");
+ QApplication::setApplicationName("CMakeSetup");
+ QApplication::setOrganizationName("Kitware");
QIcon appIcon;
appIcon.addFile(":/Icons/CMakeSetup32.png");
appIcon.addFile(":/Icons/CMakeSetup128.png");
- app.setWindowIcon(appIcon);
+ QApplication::setWindowIcon(appIcon);
CMakeSetupDialog dialog;
dialog.show();
- cmsys::CommandLineArguments arg;
- arg.Initialize(argc2, argv2);
+ QStringList args = QApplication::arguments();
std::string binaryDirectory;
std::string sourceDirectory;
- typedef cmsys::CommandLineArguments argT;
- arg.AddArgument("-B", argT::CONCAT_ARGUMENT, &binaryDirectory,
- "Binary Directory");
- arg.AddArgument("-H", argT::CONCAT_ARGUMENT, &sourceDirectory,
- "Source Directory");
- // do not complain about unknown options
- arg.StoreUnusedArguments(true);
- arg.Parse();
+ for (int i = 1; i < args.size(); ++i) {
+ const QString& arg = args[i];
+ if (arg.startsWith("-S")) {
+ QString path = arg.mid(2);
+ if (path.isEmpty()) {
+ ++i;
+ if (i >= args.size()) {
+ std::cerr << "No source directory specified for -S" << std::endl;
+ return 1;
+ }
+ path = args[i];
+ if (path[0] == '-') {
+ std::cerr << "No source directory specified for -S" << std::endl;
+ return 1;
+ }
+ }
+
+ sourceDirectory =
+ cmSystemTools::CollapseFullPath(path.toLocal8Bit().data());
+ cmSystemTools::ConvertToUnixSlashes(sourceDirectory);
+ } else if (arg.startsWith("-B")) {
+ QString path = arg.mid(2);
+ if (path.isEmpty()) {
+ ++i;
+ if (i >= args.size()) {
+ std::cerr << "No build directory specified for -B" << std::endl;
+ return 1;
+ }
+ path = args[i];
+ if (path[0] == '-') {
+ std::cerr << "No build directory specified for -B" << std::endl;
+ return 1;
+ }
+ }
+
+ binaryDirectory =
+ cmSystemTools::CollapseFullPath(path.toLocal8Bit().data());
+ cmSystemTools::ConvertToUnixSlashes(binaryDirectory);
+ }
+ }
if (!sourceDirectory.empty() && !binaryDirectory.empty()) {
dialog.setSourceDirectory(QString::fromLocal8Bit(sourceDirectory.c_str()));
dialog.setBinaryDirectory(QString::fromLocal8Bit(binaryDirectory.c_str()));
} else {
- QStringList args = app.arguments();
if (args.count() == 2) {
std::string filePath =
cmSystemTools::CollapseFullPath(args[1].toLocal8Bit().data());
@@ -180,14 +225,16 @@ int main(int argc, char** argv)
}
}
- return app.exec();
+ return QApplication::exec();
}
#if defined(Q_OS_MAC)
-#include "cm_sys_stat.h"
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
+# include <cerrno>
+# include <cstring>
+
+# include <unistd.h>
+
+# include "cm_sys_stat.h"
static bool cmOSXInstall(std::string const& dir, std::string const& tool)
{
if (tool.empty()) {
@@ -207,12 +254,11 @@ static bool cmOSXInstall(std::string const& dir, std::string const& tool)
if (symlink(tool.c_str(), link.c_str()) == 0) {
std::cerr << "Linked: '" << link << "' -> '" << tool << "'\n";
return true;
- } else {
- int err = errno;
- std::cerr << "Failed: '" << link << "' -> '" << tool
- << "': " << strerror(err) << "\n";
- return false;
}
+ int err = errno;
+ std::cerr << "Failed: '" << link << "' -> '" << tool
+ << "': " << strerror(err) << "\n";
+ return false;
}
static int cmOSXInstall(std::string dir)
{
diff --git a/Source/QtDialog/CMakeSetup.icns b/Source/QtDialog/CMakeSetup.icns
index 4a50c0416..e0bf8fdfa 100644
--- a/Source/QtDialog/CMakeSetup.icns
+++ b/Source/QtDialog/CMakeSetup.icns
Binary files differ
diff --git a/Source/QtDialog/CMakeSetup.ico b/Source/QtDialog/CMakeSetup.ico
index e13bb156f..1ac13c830 100644
--- a/Source/QtDialog/CMakeSetup.ico
+++ b/Source/QtDialog/CMakeSetup.ico
Binary files differ
diff --git a/Source/QtDialog/CMakeSetup128.png b/Source/QtDialog/CMakeSetup128.png
index 12f1d9a9a..32984e104 100644
--- a/Source/QtDialog/CMakeSetup128.png
+++ b/Source/QtDialog/CMakeSetup128.png
Binary files differ
diff --git a/Source/QtDialog/CMakeSetup32.png b/Source/QtDialog/CMakeSetup32.png
index 7bbcee413..78df82f15 100644
--- a/Source/QtDialog/CMakeSetup32.png
+++ b/Source/QtDialog/CMakeSetup32.png
Binary files differ
diff --git a/Source/QtDialog/CMakeSetup64.png b/Source/QtDialog/CMakeSetup64.png
index 43a8cc6af..5c2dbf552 100644
--- a/Source/QtDialog/CMakeSetup64.png
+++ b/Source/QtDialog/CMakeSetup64.png
Binary files differ
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 57f8e107e..436a90466 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -21,18 +21,25 @@
#include <QToolButton>
#include <QUrl>
-#include "AddCacheEntry.h"
-#include "FirstConfigure.h"
+#ifdef QT_WINEXTRAS
+# include <QWinTaskbarButton>
+# include <QWinTaskbarProgress>
+#endif
+
#include "QCMake.h"
#include "QCMakeCacheView.h"
-#include "RegexExplorer.h"
-#include "WarningMessagesDialog.h"
+
#include "cmSystemTools.h"
#include "cmVersion.h"
+#include "AddCacheEntry.h"
+#include "FirstConfigure.h"
+#include "RegexExplorer.h"
+#include "WarningMessagesDialog.h"
+
QCMakeThread::QCMakeThread(QObject* p)
: QThread(p)
- , CMakeInstance(CM_NULLPTR)
+ , CMakeInstance(nullptr)
{
}
@@ -48,7 +55,7 @@ void QCMakeThread::run()
emit this->cmakeInitialized();
this->exec();
delete this->CMakeInstance;
- this->CMakeInstance = CM_NULLPTR;
+ this->CMakeInstance = nullptr;
}
CMakeSetupDialog::CMakeSetupDialog()
@@ -108,7 +115,7 @@ CMakeSetupDialog::CMakeSetupDialog()
QMenu* ToolsMenu = this->menuBar()->addMenu(tr("&Tools"));
this->ConfigureAction = ToolsMenu->addAction(tr("&Configure"));
- // prevent merging with Preferences menu item on Mac OS X
+ // prevent merging with Preferences menu item on macOS
this->ConfigureAction->setMenuRole(QAction::NoRole);
QObject::connect(this->ConfigureAction, SIGNAL(triggered(bool)), this,
SLOT(doConfigure()));
@@ -188,6 +195,9 @@ CMakeSetupDialog::CMakeSetupDialog()
connect(this->Output, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(doOutputContextMenu(const QPoint&)));
+ // disable open project button
+ this->OpenProjectButton->setDisabled(true);
+
// start the cmake worker thread
this->CMakeThread = new QCMakeThread(this);
QObject::connect(this->CMakeThread, SIGNAL(cmakeInitialized()), this,
@@ -249,6 +259,10 @@ void CMakeSetupDialog::initialize()
SIGNAL(outputMessage(QString)), this,
SLOT(message(QString)));
+ QObject::connect(this->CMakeThread->cmakeInstance(),
+ SIGNAL(openPossible(bool)), this->OpenProjectButton,
+ SLOT(setEnabled(bool)));
+
QObject::connect(this->groupedCheck, SIGNAL(toggled(bool)), this,
SLOT(setGroupedView(bool)));
QObject::connect(this->advancedCheck, SIGNAL(toggled(bool)), this,
@@ -287,6 +301,11 @@ void CMakeSetupDialog::initialize()
} else {
this->onBinaryDirectoryChanged(this->BinaryDirectory->lineEdit()->text());
}
+
+#ifdef QT_WINEXTRAS
+ this->TaskbarButton = new QWinTaskbarButton(this);
+ this->TaskbarButton->setWindow(this->windowHandle());
+#endif
}
CMakeSetupDialog::~CMakeSetupDialog()
@@ -374,6 +393,10 @@ void CMakeSetupDialog::doConfigure()
this->CacheValues->scrollToTop();
}
this->ProgressBar->reset();
+
+#ifdef QT_WINEXTRAS
+ this->TaskbarButton->progress()->reset();
+#endif
}
bool CMakeSetupDialog::doConfigureInternal()
@@ -488,28 +511,17 @@ void CMakeSetupDialog::doGenerate()
this->enterState(ReadyConfigure);
this->ProgressBar->reset();
+#ifdef QT_WINEXTRAS
+ this->TaskbarButton->progress()->reset();
+#endif
this->ConfigureNeeded = true;
}
-QString CMakeSetupDialog::getProjectFilename()
-{
- QStringList nameFilter;
- nameFilter << "*.sln"
- << "*.xcodeproj";
- QDir directory(this->BinaryDirectory->currentText());
- QStringList nlnFile = directory.entryList(nameFilter);
-
- if (nlnFile.count() == 1) {
- return this->BinaryDirectory->currentText() + "/" + nlnFile.at(0);
- }
-
- return QString();
-}
-
void CMakeSetupDialog::doOpenProject()
{
- QDesktopServices::openUrl(QUrl::fromLocalFile(this->getProjectFilename()));
+ QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "open",
+ Qt::QueuedConnection);
}
void CMakeSetupDialog::closeEvent(QCloseEvent* e)
@@ -630,11 +642,6 @@ void CMakeSetupDialog::updateBinaryDirectory(const QString& dir)
this->BinaryDirectory->setEditText(dir);
this->BinaryDirectory->blockSignals(false);
}
- if (!this->getProjectFilename().isEmpty()) {
- this->OpenProjectButton->setEnabled(true);
- } else {
- this->OpenProjectButton->setEnabled(false);
- }
}
void CMakeSetupDialog::doBinaryBrowse()
@@ -686,6 +693,12 @@ void CMakeSetupDialog::showProgress(const QString& /*msg*/, float percent)
{
percent = (percent * ProgressFactor) + ProgressOffset;
this->ProgressBar->setValue(qRound(percent * 100));
+
+#ifdef QT_WINEXTRAS
+ QWinTaskbarProgress* progress = this->TaskbarButton->progress();
+ progress->setVisible(true);
+ progress->setValue(qRound(percent * 100));
+#endif
}
void CMakeSetupDialog::error(const QString& msg)
@@ -739,6 +752,7 @@ bool CMakeSetupDialog::setupFirstConfigure()
if (dialog.exec() == QDialog::Accepted) {
dialog.saveToSettings();
this->CMakeThread->cmakeInstance()->setGenerator(dialog.getGenerator());
+ this->CMakeThread->cmakeInstance()->setPlatform(dialog.getPlatform());
this->CMakeThread->cmakeInstance()->setToolset(dialog.getToolset());
QCMakeCacheModel* m = this->CacheValues->cacheModel();
@@ -850,11 +864,11 @@ void CMakeSetupDialog::doAbout()
"built using Qt %2 (qt-project.org).\n"
#ifdef USE_LGPL
"\n"
- "The Qt Toolkit is Copyright (C) Digia Plc and/or its subsidiary(-ies).\n"
+ "The Qt Toolkit is Copyright (C) The Qt Company Ltd.\n"
"Qt is licensed under terms of the GNU LGPLv" USE_LGPL ", available at:\n"
" \"%3\""
#endif
- );
+ );
msg = msg.arg(cmVersion::GetCMakeVersion());
msg = msg.arg(qVersion());
#ifdef USE_LGPL
@@ -1001,8 +1015,9 @@ void CMakeSetupDialog::removeSelectedCacheEntries()
void CMakeSetupDialog::selectionChanged()
{
QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows();
- if (idxs.count() && (this->CurrentState == ReadyConfigure ||
- this->CurrentState == ReadyGenerate)) {
+ if (idxs.count() &&
+ (this->CurrentState == ReadyConfigure ||
+ this->CurrentState == ReadyGenerate)) {
this->RemoveEntry->setEnabled(true);
} else {
this->RemoveEntry->setEnabled(false);
@@ -1039,9 +1054,6 @@ void CMakeSetupDialog::enterState(CMakeSetupDialog::State s)
this->GenerateButton->setEnabled(true);
this->GenerateAction->setEnabled(true);
this->ConfigureButton->setEnabled(true);
- if (!this->getProjectFilename().isEmpty()) {
- this->OpenProjectButton->setEnabled(true);
- }
this->ConfigureButton->setText(tr("&Configure"));
this->GenerateButton->setText(tr("&Generate"));
} else if (s == ReadyGenerate) {
@@ -1049,9 +1061,6 @@ void CMakeSetupDialog::enterState(CMakeSetupDialog::State s)
this->GenerateButton->setEnabled(true);
this->GenerateAction->setEnabled(true);
this->ConfigureButton->setEnabled(true);
- if (!this->getProjectFilename().isEmpty()) {
- this->OpenProjectButton->setEnabled(true);
- }
this->ConfigureButton->setText(tr("&Configure"));
this->GenerateButton->setText(tr("&Generate"));
}
@@ -1195,7 +1204,7 @@ void CMakeSetupDialog::setSearchFilter(const QString& str)
this->CacheValues->setSearchFilter(str);
}
-void CMakeSetupDialog::doOutputContextMenu(const QPoint& pt)
+void CMakeSetupDialog::doOutputContextMenu(QPoint pt)
{
QMenu* menu = this->Output->createStandardContextMenu();
diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h
index 1abdb462d..f23aee6e8 100644
--- a/Source/QtDialog/CMakeSetupDialog.h
+++ b/Source/QtDialog/CMakeSetupDialog.h
@@ -4,19 +4,25 @@
#define CMakeSetupDialog_h
#include "QCMake.h"
-
-#include "ui_CMakeSetupDialog.h"
#include <QEventLoop>
#include <QMainWindow>
#include <QThread>
+#include "ui_CMakeSetupDialog.h"
+
class QCMakeThread;
class CMakeCacheModel;
class QProgressBar;
class QToolButton;
+#ifdef QT_WINEXTRAS
+class QWinTaskbarButton;
+#endif
+
/// Qt user interface for CMake
-class CMakeSetupDialog : public QMainWindow, public Ui::CMakeSetupDialog
+class CMakeSetupDialog
+ : public QMainWindow
+ , public Ui::CMakeSetupDialog
{
Q_OBJECT
public:
@@ -31,7 +37,6 @@ protected slots:
void initialize();
void doConfigure();
void doGenerate();
- QString getProjectFilename();
void doOpenProject();
void doInstallForCommandLine();
void doHelp();
@@ -70,7 +75,7 @@ protected slots:
bool doConfigureInternal();
bool doGenerateInternal();
void exitLoop(int);
- void doOutputContextMenu(const QPoint&);
+ void doOutputContextMenu(QPoint pt);
void doOutputFindDialog();
void doOutputFindNext(bool directionForward = true);
void doOutputFindPrev();
@@ -117,6 +122,10 @@ protected:
QEventLoop LocalLoop;
+#ifdef QT_WINEXTRAS
+ QWinTaskbarButton* TaskbarButton;
+#endif
+
float ProgressOffset;
float ProgressFactor;
};
diff --git a/Source/QtDialog/CMakeSetupDialog.ui b/Source/QtDialog/CMakeSetupDialog.ui
index 8d8e0cdc2..dc22a2989 100644
--- a/Source/QtDialog/CMakeSetupDialog.ui
+++ b/Source/QtDialog/CMakeSetupDialog.ui
@@ -57,6 +57,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="styleSheet">
+ <string notr="true">padding-left: 0</string>
+ </property>
<property name="editable">
<bool>true</bool>
</property>
diff --git a/Source/QtDialog/Compilers.h b/Source/QtDialog/Compilers.h
index 6c8c8f52a..931c93566 100644
--- a/Source/QtDialog/Compilers.h
+++ b/Source/QtDialog/Compilers.h
@@ -3,17 +3,19 @@
#ifndef COMPILERS_HPP
#define COMPILERS_HPP
-#include "cmConfigure.h"
-
-#include <QWidget>
+#include "cmConfigure.h" // IWYU pragma: keep
#include <ui_Compilers.h>
-class Compilers : public QWidget, public Ui::Compilers
+#include <QWidget>
+
+class Compilers
+ : public QWidget
+ , public Ui::Compilers
{
Q_OBJECT
public:
- Compilers(QWidget* p = CM_NULLPTR)
+ Compilers(QWidget* p = nullptr)
: QWidget(p)
{
this->setupUi(this);
diff --git a/Source/QtDialog/Delete16.png b/Source/QtDialog/Delete16.png
index 16989fee1..9d2f2b7ec 100644
--- a/Source/QtDialog/Delete16.png
+++ b/Source/QtDialog/Delete16.png
Binary files differ
diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx
index b193a2782..ca28b1972 100644
--- a/Source/QtDialog/FirstConfigure.cxx
+++ b/Source/QtDialog/FirstConfigure.cxx
@@ -1,13 +1,15 @@
#include "FirstConfigure.h"
-#include "Compilers.h"
-
#include <QComboBox>
#include <QRadioButton>
#include <QSettings>
#include <QVBoxLayout>
+#include "cmStringAlgorithms.h"
+
+#include "Compilers.h"
+
StartCompilerSetup::StartCompilerSetup(QWidget* p)
: QWizardPage(p)
{
@@ -16,8 +18,12 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p)
this->GeneratorOptions = new QComboBox(this);
l->addWidget(this->GeneratorOptions);
+ // Add the generator platform
+ this->PlatformFrame = CreatePlatformWidgets();
+ l->addWidget(PlatformFrame);
+
// Add the ability to specify toolset (-T parameter)
- ToolsetFrame = CreateToolsetWidgets();
+ this->ToolsetFrame = CreateToolsetWidgets();
l->addWidget(ToolsetFrame);
l->addSpacing(6);
@@ -45,7 +51,7 @@ StartCompilerSetup::StartCompilerSetup(QWidget* p)
SLOT(onSelectionChanged(bool)));
QObject::connect(this->CompilerSetupOptions[3], SIGNAL(toggled(bool)), this,
SLOT(onSelectionChanged(bool)));
- QObject::connect(GeneratorOptions,
+ QObject::connect(this->GeneratorOptions,
SIGNAL(currentIndexChanged(QString const&)), this,
SLOT(onGeneratorChanged(QString const&)));
}
@@ -65,10 +71,25 @@ QFrame* StartCompilerSetup::CreateToolsetWidgets()
return frame;
}
-StartCompilerSetup::~StartCompilerSetup()
+QFrame* StartCompilerSetup::CreatePlatformWidgets()
{
+ QFrame* frame = new QFrame(this);
+ QVBoxLayout* l = new QVBoxLayout(frame);
+ l->setContentsMargins(0, 0, 0, 0);
+
+ this->PlatformLabel = new QLabel(tr("Optional platform for generator"));
+ l->addWidget(this->PlatformLabel);
+
+ this->PlatformOptions = new QComboBox(frame);
+ this->PlatformOptions->setEditable(true);
+
+ l->addWidget(this->PlatformOptions);
+
+ return frame;
}
+StartCompilerSetup::~StartCompilerSetup() = default;
+
void StartCompilerSetup::setGenerators(
std::vector<cmake::GeneratorInfo> const& gens)
{
@@ -76,13 +97,31 @@ void StartCompilerSetup::setGenerators(
QStringList generator_list;
- std::vector<cmake::GeneratorInfo>::const_iterator it;
- for (it = gens.begin(); it != gens.end(); ++it) {
- generator_list.append(QString::fromLocal8Bit(it->name.c_str()));
+ for (cmake::GeneratorInfo const& gen : gens) {
+ generator_list.append(QString::fromLocal8Bit(gen.name.c_str()));
+
+ if (gen.supportsPlatform) {
+ this->GeneratorsSupportingPlatform.append(
+ QString::fromLocal8Bit(gen.name.c_str()));
+
+ this
+ ->GeneratorDefaultPlatform[QString::fromLocal8Bit(gen.name.c_str())] =
+ QString::fromLocal8Bit(gen.defaultPlatform.c_str());
+
+ auto platformIt = gen.supportedPlatforms.cbegin();
+ while (platformIt != gen.supportedPlatforms.cend()) {
+
+ this->GeneratorSupportedPlatforms.insert(
+ QString::fromLocal8Bit(gen.name.c_str()),
+ QString::fromLocal8Bit((*platformIt).c_str()));
+
+ platformIt++;
+ }
+ }
- if (it->supportsToolset) {
+ if (gen.supportsToolset) {
this->GeneratorsSupportingToolset.append(
- QString::fromLocal8Bit(it->name.c_str()));
+ QString::fromLocal8Bit(gen.name.c_str()));
}
}
@@ -102,6 +141,11 @@ QString StartCompilerSetup::getGenerator() const
return this->GeneratorOptions->currentText();
};
+QString StartCompilerSetup::getPlatform() const
+{
+ return this->PlatformOptions->currentText();
+};
+
QString StartCompilerSetup::getToolset() const
{
return this->Toolset->text();
@@ -136,6 +180,30 @@ void StartCompilerSetup::onSelectionChanged(bool on)
void StartCompilerSetup::onGeneratorChanged(QString const& name)
{
+ // Display the generator platform for the generators supporting it
+ if (GeneratorsSupportingPlatform.contains(name)) {
+
+ // Change the label title to include the default platform
+ std::string label =
+ cmStrCat("Optional platform for generator(if empty, generator uses: ",
+ this->GeneratorDefaultPlatform[name].toStdString(), ')');
+ this->PlatformLabel->setText(tr(label.c_str()));
+
+ // Regenerate the list of supported platform
+ this->PlatformOptions->clear();
+ QStringList platform_list;
+ platform_list.append("");
+
+ QList<QString> platforms = this->GeneratorSupportedPlatforms.values(name);
+ platform_list.append(platforms);
+
+ this->PlatformOptions->addItems(platform_list);
+ PlatformFrame->show();
+ } else {
+ PlatformFrame->hide();
+ }
+
+ // Display the toolset box for the generators supporting it
if (GeneratorsSupportingToolset.contains(name)) {
ToolsetFrame->show();
} else {
@@ -166,9 +234,7 @@ NativeCompilerSetup::NativeCompilerSetup(QWidget* p)
this->setupUi(c);
}
-NativeCompilerSetup::~NativeCompilerSetup()
-{
-}
+NativeCompilerSetup::~NativeCompilerSetup() = default;
QString NativeCompilerSetup::getCCompiler() const
{
@@ -230,9 +296,7 @@ CrossCompilerSetup::CrossCompilerSetup(QWidget* p)
this->registerField("systemName*", this->systemName);
}
-CrossCompilerSetup::~CrossCompilerSetup()
-{
-}
+CrossCompilerSetup::~CrossCompilerSetup() = default;
QString CrossCompilerSetup::getCCompiler() const
{
@@ -301,7 +365,7 @@ QString CrossCompilerSetup::getFindRoot() const
void CrossCompilerSetup::setFindRoot(const QString& t)
{
- return this->crossFindRoot->setText(t);
+ this->crossFindRoot->setText(t);
}
int CrossCompilerSetup::getProgramMode() const
@@ -343,9 +407,7 @@ ToolchainCompilerSetup::ToolchainCompilerSetup(QWidget* p)
l->addWidget(this->ToolchainFile);
}
-ToolchainCompilerSetup::~ToolchainCompilerSetup()
-{
-}
+ToolchainCompilerSetup::~ToolchainCompilerSetup() = default;
QString ToolchainCompilerSetup::toolchainFile() const
{
@@ -375,9 +437,7 @@ FirstConfigure::FirstConfigure()
this->setPage(ToolchainSetup, this->mToolchainCompilerSetupPage);
}
-FirstConfigure::~FirstConfigure()
-{
-}
+FirstConfigure::~FirstConfigure() = default;
void FirstConfigure::setGenerators(
std::vector<cmake::GeneratorInfo> const& gens)
@@ -390,6 +450,11 @@ QString FirstConfigure::getGenerator() const
return this->mStartCompilerSetupPage->getGenerator();
}
+QString FirstConfigure::getPlatform() const
+{
+ return this->mStartCompilerSetupPage->getPlatform();
+}
+
QString FirstConfigure::getToolset() const
{
return this->mStartCompilerSetupPage->getToolset();
diff --git a/Source/QtDialog/FirstConfigure.h b/Source/QtDialog/FirstConfigure.h
index c467ddb19..d1db5bff6 100644
--- a/Source/QtDialog/FirstConfigure.h
+++ b/Source/QtDialog/FirstConfigure.h
@@ -35,6 +35,7 @@ public:
void setCurrentGenerator(const QString& gen);
QString getGenerator() const;
QString getToolset() const;
+ QString getPlatform() const;
bool defaultSetup() const;
bool compilerSetup() const;
@@ -56,14 +57,23 @@ protected:
QFrame* ToolsetFrame;
QLineEdit* Toolset;
QLabel* ToolsetLabel;
+ QFrame* PlatformFrame;
+ QComboBox* PlatformOptions;
+ QLabel* PlatformLabel;
QStringList GeneratorsSupportingToolset;
+ QStringList GeneratorsSupportingPlatform;
+ QMultiMap<QString, QString> GeneratorSupportedPlatforms;
+ QMap<QString, QString> GeneratorDefaultPlatform;
private:
QFrame* CreateToolsetWidgets();
+ QFrame* CreatePlatformWidgets();
};
//! the page that gives basic options for native compilers
-class NativeCompilerSetup : public QWizardPage, protected Ui::Compilers
+class NativeCompilerSetup
+ : public QWizardPage
+ , protected Ui::Compilers
{
Q_OBJECT
public:
@@ -83,7 +93,9 @@ public:
};
//! the page that gives options for cross compilers
-class CrossCompilerSetup : public QWizardPage, protected Ui::CrossCompiler
+class CrossCompilerSetup
+ : public QWizardPage
+ , protected Ui::CrossCompiler
{
Q_OBJECT
public:
@@ -155,6 +167,7 @@ public:
void setGenerators(std::vector<cmake::GeneratorInfo> const& gens);
QString getGenerator() const;
+ QString getPlatform() const;
QString getToolset() const;
bool defaultSetup() const;
diff --git a/Source/QtDialog/Plus16.png b/Source/QtDialog/Plus16.png
index 552f6f004..1c33bc763 100644
--- a/Source/QtDialog/Plus16.png
+++ b/Source/QtDialog/Plus16.png
Binary files differ
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index d473d9b8f..b608fcbfc 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -7,10 +7,11 @@
#include "cmExternalMakefileProjectGenerator.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#ifdef Q_OS_WIN
-#include "qt_windows.h" // For SetErrorMode
+# include "qt_windows.h" // For SetErrorMode
#endif
QCMake::QCMake(QObject* p)
@@ -23,32 +24,33 @@ QCMake::QCMake(QObject* p)
cmSystemTools::DisableRunCommandOutput();
cmSystemTools::SetRunCommandHideConsole(true);
- cmSystemTools::SetMessageCallback(QCMake::messageCallback, this);
- cmSystemTools::SetStdoutCallback(QCMake::stdoutCallback, this);
- cmSystemTools::SetStderrCallback(QCMake::stderrCallback, this);
- this->CMakeInstance = new cmake(cmake::RoleProject);
+ cmSystemTools::SetMessageCallback(
+ [this](std::string const& msg, const char* title) {
+ this->messageCallback(msg, title);
+ });
+ cmSystemTools::SetStdoutCallback(
+ [this](std::string const& msg) { this->stdoutCallback(msg); });
+ cmSystemTools::SetStderrCallback(
+ [this](std::string const& msg) { this->stderrCallback(msg); });
+
+ this->CMakeInstance = new cmake(cmake::RoleProject, cmState::Project);
this->CMakeInstance->SetCMakeEditCommand(
cmSystemTools::GetCMakeGUICommand());
- this->CMakeInstance->SetProgressCallback(QCMake::progressCallback, this);
+ this->CMakeInstance->SetProgressCallback(
+ [this](const std::string& msg, float percent) {
+ this->progressCallback(msg, percent);
+ });
- cmSystemTools::SetInterruptCallback(QCMake::interruptCallback, this);
+ cmSystemTools::SetInterruptCallback(
+ [this] { return this->interruptCallback(); });
std::vector<cmake::GeneratorInfo> generators;
- this->CMakeInstance->GetRegisteredGenerators(generators);
-
- std::vector<cmake::GeneratorInfo>::const_iterator it;
- for (it = generators.begin(); it != generators.end(); ++it) {
- // Skip the generator "KDevelop3", since there is also
- // "KDevelop3 - Unix Makefiles", which is the full and official name.
- // The short name is actually only still there since this was the name
- // in CMake 2.4, to keep "command line argument compatibility", but
- // this is not necessary in the GUI.
- if (it->name == "KDevelop3") {
- continue;
- }
+ this->CMakeInstance->GetRegisteredGenerators(
+ generators, /*includeNamesWithPlatform=*/false);
- this->AvailableGenerators.push_back(*it);
+ for (cmake::GeneratorInfo const& gen : generators) {
+ this->AvailableGenerators.push_back(gen);
}
}
@@ -83,6 +85,7 @@ void QCMake::setBinaryDirectory(const QString& _dir)
cmState* state = this->CMakeInstance->GetState();
this->setGenerator(QString());
this->setToolset(QString());
+ this->setPlatform(QString());
if (!this->CMakeInstance->LoadCache(
this->BinaryDirectory.toLocal8Bit().data())) {
QDir testDir(this->BinaryDirectory);
@@ -103,18 +106,26 @@ void QCMake::setBinaryDirectory(const QString& _dir)
}
const char* gen = state->GetCacheEntryValue("CMAKE_GENERATOR");
if (gen) {
- const char* extraGen =
+ const std::string* extraGen =
state->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
std::string curGen =
cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
- gen, extraGen ? extraGen : "");
+ gen, extraGen ? *extraGen : "");
this->setGenerator(QString::fromLocal8Bit(curGen.c_str()));
}
+ const char* platform =
+ state->GetCacheEntryValue("CMAKE_GENERATOR_PLATFORM");
+ if (platform) {
+ this->setPlatform(QString::fromLocal8Bit(platform));
+ }
+
const char* toolset = state->GetCacheEntryValue("CMAKE_GENERATOR_TOOLSET");
if (toolset) {
this->setToolset(QString::fromLocal8Bit(toolset));
}
+
+ checkOpenPossible();
}
}
@@ -126,6 +137,14 @@ void QCMake::setGenerator(const QString& gen)
}
}
+void QCMake::setPlatform(const QString& platform)
+{
+ if (this->Platform != platform) {
+ this->Platform = platform;
+ emit this->platformChanged(this->Platform);
+ }
+}
+
void QCMake::setToolset(const QString& toolset)
{
if (this->Toolset != toolset) {
@@ -147,7 +166,8 @@ void QCMake::configure()
this->CMakeInstance->SetGlobalGenerator(
this->CMakeInstance->CreateGlobalGenerator(
this->Generator.toLocal8Bit().data()));
- this->CMakeInstance->SetGeneratorPlatform("");
+ this->CMakeInstance->SetGeneratorPlatform(
+ this->Platform.toLocal8Bit().data());
this->CMakeInstance->SetGeneratorToolset(this->Toolset.toLocal8Bit().data());
this->CMakeInstance->LoadCache();
this->CMakeInstance->SetWarnUninitialized(this->WarnUninitializedMode);
@@ -183,6 +203,26 @@ void QCMake::generate()
#endif
emit this->generateDone(err);
+ checkOpenPossible();
+}
+
+void QCMake::open()
+{
+#ifdef Q_OS_WIN
+ UINT lastErrorMode = SetErrorMode(0);
+#endif
+
+ InterruptFlag = 0;
+ cmSystemTools::ResetErrorOccuredFlag();
+
+ auto successful = this->CMakeInstance->Open(
+ this->BinaryDirectory.toLocal8Bit().data(), false);
+
+#ifdef Q_OS_WIN
+ SetErrorMode(lastErrorMode);
+#endif
+
+ emit this->openDone(successful);
}
void QCMake::setProperties(const QCMakePropertyList& newProps)
@@ -194,38 +234,37 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
// set the value of properties
cmState* state = this->CMakeInstance->GetState();
std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
- for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it) {
- cmStateEnums::CacheEntryType t = state->GetCacheEntryType(*it);
+ for (std::string const& key : cacheKeys) {
+ cmStateEnums::CacheEntryType t = state->GetCacheEntryType(key);
if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC) {
continue;
}
QCMakeProperty prop;
- prop.Key = QString::fromLocal8Bit(it->c_str());
+ prop.Key = QString::fromLocal8Bit(key.c_str());
int idx = props.indexOf(prop);
if (idx == -1) {
- toremove.append(QString::fromLocal8Bit(it->c_str()));
+ toremove.append(QString::fromLocal8Bit(key.c_str()));
} else {
prop = props[idx];
if (prop.Value.type() == QVariant::Bool) {
- state->SetCacheEntryValue(*it, prop.Value.toBool() ? "ON" : "OFF");
+ state->SetCacheEntryValue(key, prop.Value.toBool() ? "ON" : "OFF");
} else {
- state->SetCacheEntryValue(*it,
+ state->SetCacheEntryValue(key,
prop.Value.toString().toLocal8Bit().data());
}
props.removeAt(idx);
}
}
- // remove some properites
+ // remove some properties
foreach (QString const& s, toremove) {
this->CMakeInstance->UnwatchUnusedCli(s.toLocal8Bit().data());
state->RemoveCacheEntry(s.toLocal8Bit().data());
}
- // add some new properites
+ // add some new properties
foreach (QCMakeProperty const& s, props) {
this->CMakeInstance->WatchUnusedCli(s.Key.toLocal8Bit().data());
@@ -257,25 +296,24 @@ QCMakePropertyList QCMake::properties() const
cmState* state = this->CMakeInstance->GetState();
std::vector<std::string> cacheKeys = state->GetCacheEntryKeys();
- for (std::vector<std::string>::const_iterator i = cacheKeys.begin();
- i != cacheKeys.end(); ++i) {
- cmStateEnums::CacheEntryType t = state->GetCacheEntryType(*i);
+ for (std::string const& key : cacheKeys) {
+ cmStateEnums::CacheEntryType t = state->GetCacheEntryType(key);
if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC ||
t == cmStateEnums::UNINITIALIZED) {
continue;
}
- const char* cachedValue = state->GetCacheEntryValue(*i);
+ const char* cachedValue = state->GetCacheEntryValue(key);
QCMakeProperty prop;
- prop.Key = QString::fromLocal8Bit(i->c_str());
+ prop.Key = QString::fromLocal8Bit(key.c_str());
prop.Help =
- QString::fromLocal8Bit(state->GetCacheEntryProperty(*i, "HELPSTRING"));
+ QString::fromLocal8Bit(state->GetCacheEntryProperty(key, "HELPSTRING"));
prop.Value = QString::fromLocal8Bit(cachedValue);
- prop.Advanced = state->GetCacheEntryPropertyAsBool(*i, "ADVANCED");
+ prop.Advanced = state->GetCacheEntryPropertyAsBool(key, "ADVANCED");
if (t == cmStateEnums::BOOL) {
prop.Type = QCMakeProperty::BOOL;
- prop.Value = cmSystemTools::IsOn(cachedValue);
+ prop.Value = cmIsOn(cachedValue);
} else if (t == cmStateEnums::PATH) {
prop.Type = QCMakeProperty::PATH;
} else if (t == cmStateEnums::FILEPATH) {
@@ -283,7 +321,7 @@ QCMakePropertyList QCMake::properties() const
} else if (t == cmStateEnums::STRING) {
prop.Type = QCMakeProperty::STRING;
const char* stringsProperty =
- state->GetCacheEntryProperty(*i, "STRINGS");
+ state->GetCacheEntryProperty(key, "STRINGS");
if (stringsProperty) {
prop.Strings = QString::fromLocal8Bit(stringsProperty).split(";");
}
@@ -300,46 +338,40 @@ void QCMake::interrupt()
this->InterruptFlag.ref();
}
-bool QCMake::interruptCallback(void* cd)
+bool QCMake::interruptCallback()
{
- QCMake* self = reinterpret_cast<QCMake*>(cd);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- return self->InterruptFlag;
+ return this->InterruptFlag;
#else
- return self->InterruptFlag.load();
+ return this->InterruptFlag.load();
#endif
}
-void QCMake::progressCallback(const char* msg, float percent, void* cd)
+void QCMake::progressCallback(const std::string& msg, float percent)
{
- QCMake* self = reinterpret_cast<QCMake*>(cd);
if (percent >= 0) {
- emit self->progressChanged(QString::fromLocal8Bit(msg), percent);
+ emit this->progressChanged(QString::fromStdString(msg), percent);
} else {
- emit self->outputMessage(QString::fromLocal8Bit(msg));
+ emit this->outputMessage(QString::fromStdString(msg));
}
QCoreApplication::processEvents();
}
-void QCMake::messageCallback(const char* msg, const char* /*title*/,
- bool& /*stop*/, void* cd)
+void QCMake::messageCallback(std::string const& msg, const char* /*title*/)
{
- QCMake* self = reinterpret_cast<QCMake*>(cd);
- emit self->errorMessage(QString::fromLocal8Bit(msg));
+ emit this->errorMessage(QString::fromStdString(msg));
QCoreApplication::processEvents();
}
-void QCMake::stdoutCallback(const char* msg, size_t len, void* cd)
+void QCMake::stdoutCallback(std::string const& msg)
{
- QCMake* self = reinterpret_cast<QCMake*>(cd);
- emit self->outputMessage(QString::fromLocal8Bit(msg, int(len)));
+ emit this->outputMessage(QString::fromStdString(msg));
QCoreApplication::processEvents();
}
-void QCMake::stderrCallback(const char* msg, size_t len, void* cd)
+void QCMake::stderrCallback(std::string const& msg)
{
- QCMake* self = reinterpret_cast<QCMake*>(cd);
- emit self->outputMessage(QString::fromLocal8Bit(msg, int(len)));
+ emit this->outputMessage(QString::fromStdString(msg));
QCoreApplication::processEvents();
}
@@ -450,3 +482,10 @@ void QCMake::setWarnUnusedMode(bool value)
{
this->WarnUnusedMode = value;
}
+
+void QCMake::checkOpenPossible()
+{
+ auto data = this->BinaryDirectory.toLocal8Bit().data();
+ auto possible = this->CMakeInstance->Open(data, true);
+ emit openPossible(possible);
+}
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index e14cdf2c9..fa4451bc2 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -3,13 +3,13 @@
#ifndef QCMake_h
#define QCMake_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include "cmake.h"
#ifdef _MSC_VER
-#pragma warning(disable : 4127)
-#pragma warning(disable : 4512)
+# pragma warning(disable : 4127)
+# pragma warning(disable : 4512)
#endif
#include <vector>
@@ -50,7 +50,7 @@ struct QCMakeProperty
};
// list of properties
-typedef QList<QCMakeProperty> QCMakePropertyList;
+using QCMakePropertyList = QList<QCMakeProperty>;
// allow QVariant to be a property or list of properties
Q_DECLARE_METATYPE(QCMakeProperty)
@@ -63,7 +63,7 @@ class QCMake : public QObject
{
Q_OBJECT
public:
- QCMake(QObject* p = CM_NULLPTR);
+ QCMake(QObject* p = nullptr);
~QCMake();
public slots:
/// load the cache file in a directory
@@ -75,11 +75,15 @@ public slots:
/// set the desired generator to use
void setGenerator(const QString& generator);
/// set the desired generator to use
+ void setPlatform(const QString& platform);
+ /// set the desired generator to use
void setToolset(const QString& toolset);
/// do the configure step
void configure();
/// generate the files
void generate();
+ /// open the project
+ void open();
/// set the property values
void setProperties(const QCMakePropertyList&);
/// interrupt the configure or generate process (if connecting, make a direct
@@ -111,6 +115,8 @@ public slots:
void setWarnUninitializedMode(bool value);
/// set whether to run cmake with warnings about unused variables
void setWarnUnusedMode(bool value);
+ /// check if project IDE open is possible and emit openPossible signal
+ void checkOpenPossible();
public:
/// get the list of cache properties
@@ -151,22 +157,29 @@ signals:
void debugOutputChanged(bool);
/// signal when the toolset changes
void toolsetChanged(const QString& toolset);
+ /// signal when the platform changes
+ void platformChanged(const QString& platform);
+ /// signal when open is done
+ void openDone(bool successful);
+ /// signal when open is done
+ void openPossible(bool possible);
protected:
cmake* CMakeInstance;
- static bool interruptCallback(void*);
- static void progressCallback(const char* msg, float percent, void* cd);
- static void messageCallback(const char* msg, const char* title, bool&,
- void* cd);
- static void stdoutCallback(const char* msg, size_t len, void* cd);
- static void stderrCallback(const char* msg, size_t len, void* cd);
+ bool interruptCallback();
+ void progressCallback(std::string const& msg, float percent);
+ void messageCallback(std::string const& msg, const char* title);
+ void stdoutCallback(std::string const& msg);
+ void stderrCallback(std::string const& msg);
+
bool WarnUninitializedMode;
bool WarnUnusedMode;
bool WarnUnusedAllMode;
QString SourceDirectory;
QString BinaryDirectory;
QString Generator;
+ QString Platform;
QString Toolset;
std::vector<cmake::GeneratorInfo> AvailableGenerators;
QString CMakeExecutable;
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx
index 08c2d58d5..3e6a49e09 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "QCMakeCacheView.h"
+#include "QCMakeWidgets.h"
#include <QApplication>
#include <QEvent>
#include <QHBoxLayout>
@@ -11,8 +12,6 @@
#include <QSortFilterProxyModel>
#include <QStyle>
-#include "QCMakeWidgets.h"
-
// filter for searches
class QCMakeSearchFilter : public QSortFilterProxyModel
{
@@ -23,7 +22,7 @@ public:
}
protected:
- bool filterAcceptsRow(int row, const QModelIndex& p) const CM_OVERRIDE
+ bool filterAcceptsRow(int row, const QModelIndex& p) const override
{
QStringList strs;
const QAbstractItemModel* m = this->sourceModel();
@@ -77,7 +76,7 @@ public:
protected:
bool ShowAdvanced;
- bool filterAcceptsRow(int row, const QModelIndex& p) const CM_OVERRIDE
+ bool filterAcceptsRow(int row, const QModelIndex& p) const override
{
const QAbstractItemModel* m = this->sourceModel();
QModelIndex idx = m->index(row, 0, p);
@@ -186,9 +185,7 @@ QCMakeCacheModel::QCMakeCacheModel(QObject* p)
this->setHorizontalHeaderLabels(labels);
}
-QCMakeCacheModel::~QCMakeCacheModel()
-{
-}
+QCMakeCacheModel::~QCMakeCacheModel() = default;
static uint qHash(const QCMakeProperty& p)
{
@@ -212,7 +209,8 @@ void QCMakeCacheModel::clear()
void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
{
- QSet<QCMakeProperty> newProps, newProps2;
+ QSet<QCMakeProperty> newProps;
+ QSet<QCMakeProperty> newProps2;
if (this->ShowNewProperties) {
newProps = props.toSet();
@@ -248,9 +246,9 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
}
} else if (this->View == GroupView) {
QMap<QString, QCMakePropertyList> newPropsTree;
- this->breakProperties(newProps, newPropsTree);
+ QCMakeCacheModel::breakProperties(newProps, newPropsTree);
QMap<QString, QCMakePropertyList> newPropsTree2;
- this->breakProperties(newProps2, newPropsTree2);
+ QCMakeCacheModel::breakProperties(newProps2, newPropsTree2);
QStandardItem* root = this->invisibleRootItem();
@@ -539,7 +537,7 @@ QWidget* QCMakeCacheModelDelegate::createEditor(
QModelIndex var = idx.sibling(idx.row(), 0);
int type = var.data(QCMakeCacheModel::TypeRole).toInt();
if (type == QCMakeProperty::BOOL) {
- return CM_NULLPTR;
+ return nullptr;
}
if (type == QCMakeProperty::PATH) {
QCMakePathEditor* editor =
@@ -614,7 +612,7 @@ bool QCMakeCacheModelDelegate::editorEvent(QEvent* e,
// Can remove this function and FileDialogFlag when minimum Qt version is 4.5
bool QCMakeCacheModelDelegate::eventFilter(QObject* object, QEvent* evt)
{
- // workaround for what looks like a bug in Qt on Mac OS X
+ // workaround for what looks like a bug in Qt on macOS
// where it doesn't create a QWidget wrapper for the native file dialog
// so the Qt library ends up assuming the focus was lost to something else
@@ -642,7 +640,7 @@ QSize QCMakeCacheModelDelegate::sizeHint(const QStyleOptionViewItem& option,
QStyleOptionButton opt;
opt.QStyleOption::operator=(option);
sz = sz.expandedTo(
- style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, CM_NULLPTR)
+ style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, nullptr)
.size());
return sz;
diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h
index c1debf590..bea196586 100644
--- a/Source/QtDialog/QCMakeCacheView.h
+++ b/Source/QtDialog/QCMakeCacheView.h
@@ -4,7 +4,6 @@
#define QCMakeCacheView_h
#include "QCMake.h"
-
#include <QItemDelegate>
#include <QSet>
#include <QStandardItemModel>
diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx
index 7f0cafa37..332a770ef 100644
--- a/Source/QtDialog/QCMakeWidgets.cxx
+++ b/Source/QtDialog/QCMakeWidgets.cxx
@@ -2,15 +2,17 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "QCMakeWidgets.h"
+#include <utility>
+
#include <QDirModel>
#include <QFileDialog>
#include <QFileInfo>
#include <QResizeEvent>
#include <QToolButton>
-QCMakeFileEditor::QCMakeFileEditor(QWidget* p, const QString& var)
+QCMakeFileEditor::QCMakeFileEditor(QWidget* p, QString var)
: QLineEdit(p)
- , Variable(var)
+ , Variable(std::move(var))
{
this->ToolButton = new QToolButton(this);
this->ToolButton->setText("...");
@@ -57,7 +59,7 @@ void QCMakeFilePathEditor::chooseFile()
emit this->fileDialogExists(true);
path =
QFileDialog::getOpenFileName(this, title, info.absolutePath(), QString(),
- CM_NULLPTR, QFileDialog::DontResolveSymlinks);
+ nullptr, QFileDialog::DontResolveSymlinks);
emit this->fileDialogExists(false);
if (!path.isEmpty()) {
@@ -89,7 +91,7 @@ void QCMakePathEditor::chooseFile()
// use same QDirModel for all completers
static QDirModel* fileDirModel()
{
- static QDirModel* m = CM_NULLPTR;
+ static QDirModel* m = nullptr;
if (!m) {
m = new QDirModel();
}
@@ -97,7 +99,7 @@ static QDirModel* fileDirModel()
}
static QDirModel* pathDirModel()
{
- static QDirModel* m = CM_NULLPTR;
+ static QDirModel* m = nullptr;
if (!m) {
m = new QDirModel();
m->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot);
diff --git a/Source/QtDialog/QCMakeWidgets.h b/Source/QtDialog/QCMakeWidgets.h
index 1ec666ff6..5d2368eab 100644
--- a/Source/QtDialog/QCMakeWidgets.h
+++ b/Source/QtDialog/QCMakeWidgets.h
@@ -3,7 +3,7 @@
#ifndef QCMakeWidgets_h
#define QCMakeWidgets_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <QComboBox>
#include <QCompleter>
@@ -18,7 +18,7 @@ class QCMakeFileEditor : public QLineEdit
{
Q_OBJECT
public:
- QCMakeFileEditor(QWidget* p, const QString& var);
+ QCMakeFileEditor(QWidget* p, QString var);
protected slots:
virtual void chooseFile() = 0;
signals:
@@ -35,7 +35,7 @@ class QCMakePathEditor : public QCMakeFileEditor
{
Q_OBJECT
public:
- QCMakePathEditor(QWidget* p = CM_NULLPTR, const QString& var = QString());
+ QCMakePathEditor(QWidget* p = nullptr, const QString& var = QString());
void chooseFile();
};
@@ -44,8 +44,7 @@ class QCMakeFilePathEditor : public QCMakeFileEditor
{
Q_OBJECT
public:
- QCMakeFilePathEditor(QWidget* p = CM_NULLPTR,
- const QString& var = QString());
+ QCMakeFilePathEditor(QWidget* p = nullptr, const QString& var = QString());
void chooseFile();
};
diff --git a/Source/QtDialog/RegexExplorer.cxx b/Source/QtDialog/RegexExplorer.cxx
index abed70e90..746fd8af2 100644
--- a/Source/QtDialog/RegexExplorer.cxx
+++ b/Source/QtDialog/RegexExplorer.cxx
@@ -8,7 +8,7 @@ RegexExplorer::RegexExplorer(QWidget* p)
{
this->setupUi(this);
- for (int i = 1; i < cmsys::RegularExpression::NSUBEXP; ++i) {
+ for (int i = 1; i < cmsys::RegularExpressionMatch::NSUBEXP; ++i) {
matchNumber->addItem(QString("Match %1").arg(QString::number(i)),
QVariant(i));
}
@@ -20,7 +20,7 @@ void RegexExplorer::setStatusColor(QWidget* widget, bool successful)
QColor color = successful ? QColor(0, 127, 0) : Qt::red;
QPalette palette = widget->palette();
- palette.setColor(QPalette::Foreground, color);
+ palette.setColor(QPalette::WindowText, color);
widget->setPalette(palette);
}
@@ -105,7 +105,7 @@ void RegexExplorer::on_matchNumber_currentIndexChanged(int index)
QVariant itemData = matchNumber->itemData(index);
int idx = itemData.toInt();
- if (idx < 1 || idx >= cmsys::RegularExpression::NSUBEXP) {
+ if (idx < 1 || idx >= cmsys::RegularExpressionMatch::NSUBEXP) {
return;
}
diff --git a/Source/QtDialog/RegexExplorer.h b/Source/QtDialog/RegexExplorer.h
index 867989279..1a1d7700f 100644
--- a/Source/QtDialog/RegexExplorer.h
+++ b/Source/QtDialog/RegexExplorer.h
@@ -3,16 +3,20 @@
#ifndef RegexExplorer_h
#define RegexExplorer_h
-#include "cmsys/RegularExpression.hxx"
-#include <QDialog>
#include <string>
+#include <QDialog>
+
+#include "cmsys/RegularExpression.hxx"
+
#include "ui_RegexExplorer.h"
class QString;
class QWidget;
-class RegexExplorer : public QDialog, public Ui::RegexExplorer
+class RegexExplorer
+ : public QDialog
+ , public Ui::RegexExplorer
{
Q_OBJECT
public:
diff --git a/Source/QtDialog/WarningMessagesDialog.h b/Source/QtDialog/WarningMessagesDialog.h
index acb830d85..f209dbdb3 100644
--- a/Source/QtDialog/WarningMessagesDialog.h
+++ b/Source/QtDialog/WarningMessagesDialog.h
@@ -3,16 +3,18 @@
#ifndef WarningMessagesDialog_h
#define WarningMessagesDialog_h
+#include "QCMake.h"
#include <QDialog>
#include <QWidget>
-#include "QCMake.h"
#include "ui_WarningMessagesDialog.h"
/**
* Dialog window for setting the warning message related options.
*/
-class WarningMessagesDialog : public QDialog, public Ui_MessagesDialog
+class WarningMessagesDialog
+ : public QDialog
+ , public Ui_MessagesDialog
{
Q_OBJECT
diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx
index e96226a4b..b85cc3359 100644
--- a/Source/bindexplib.cxx
+++ b/Source/bindexplib.cxx
@@ -8,68 +8,87 @@
-------------------------------------------------------------------------*/
/*
-*----------------------------------------------------------------------
-* Program: dumpexts.exe
-* Author: Gordon Chaffee
-*
-* History: The real functionality of this file was written by
-* Matt Pietrek in 1993 in his pedump utility. I've
-* modified it to dump the externals in a bunch of object
-* files to create a .def file.
-*
-* Notes: Visual C++ puts an underscore before each exported symbol.
-* This file removes them. I don't know if this is a problem
-* this other compilers. If _MSC_VER is defined,
-* the underscore is removed. If not, it isn't. To get a
-* full dump of an object file, use the -f option. This can
-* help determine the something that may be different with a
-* compiler other than Visual C++.
-* ======================================
-* Corrections (Axel 2006-04-04):
-* Conversion to C++. Mostly.
-*
+ *----------------------------------------------------------------------
+ * Program: dumpexts.exe
+ * Author: Gordon Chaffee
+ *
+ * History: The real functionality of this file was written by
+ * Matt Pietrek in 1993 in his pedump utility. I've
+ * modified it to dump the externals in a bunch of object
+ * files to create a .def file.
+ *
+ * Notes: Visual C++ puts an underscore before each exported symbol.
+ * This file removes them. I don't know if this is a problem
+ * this other compilers. If _MSC_VER is defined,
+ * the underscore is removed. If not, it isn't. To get a
+ * full dump of an object file, use the -f option. This can
+ * help determine the something that may be different with a
+ * compiler other than Visual C++.
+ * ======================================
+ * Corrections (Axel 2006-04-04):
+ * Conversion to C++. Mostly.
+ *
* Extension (Axel 2006-03-15)
* As soon as an object file contains an /EXPORT directive (which
* is generated by the compiler when a symbol is declared as
- * declspec(dllexport)) no to-be-exported symbols are printed,
+ * __declspec(dllexport) no to-be-exported symbols are printed,
* as the linker will see these directives, and if those directives
* are present we only export selectively (i.e. we trust the
* programmer).
*
* ======================================
-* ======================================
-* Corrections (Valery Fine 23/02/98):
-*
-* The "(vector) deleting destructor" MUST not be exported
-* To recognize it the following test are introduced:
-* "@@UAEPAXI@Z" scalar deleting dtor
-* "@@QAEPAXI@Z" vector deleting dtor
-* "AEPAXI@Z" vector deleting dtor with thunk adjustor
-* ======================================
-* Corrections (Valery Fine 12/02/97):
-*
-* It created a wrong EXPORTS for the global pointers and constants.
-* The Section Header has been involved to discover the missing information
-* Now the pointers are correctly supplied supplied with "DATA" descriptor
-* the constants with no extra descriptor.
-*
-* Corrections (Valery Fine 16/09/96):
-*
-* It didn't work for C++ code with global variables and class definitons
-* The DumpExternalObject function has been introduced to generate .DEF file
-*
-* Author: Valery Fine 16/09/96 (E-mail: fine@vxcern.cern.ch)
-*----------------------------------------------------------------------
-*/
+ * ======================================
+ * Corrections (Valery Fine 23/02/98):
+ *
+ * The "(vector) deleting destructor" MUST not be exported
+ * To recognize it the following test are introduced:
+ * "@@UAEPAXI@Z" scalar deleting dtor
+ * "@@QAEPAXI@Z" vector deleting dtor
+ * "AEPAXI@Z" vector deleting dtor with thunk adjustor
+ * ======================================
+ * Corrections (Valery Fine 12/02/97):
+ *
+ * It created a wrong EXPORTS for the global pointers and constants.
+ * The Section Header has been involved to discover the missing information
+ * Now the pointers are correctly supplied with "DATA" descriptor
+ * the constants with no extra descriptor.
+ *
+ * Corrections (Valery Fine 16/09/96):
+ *
+ * It didn't work for C++ code with global variables and class definitions
+ * The DumpExternalObject function has been introduced to generate .DEF
+ *file
+ *
+ * Author: Valery Fine 16/09/96 (E-mail: fine@vxcern.cern.ch)
+ *----------------------------------------------------------------------
+ */
#include "bindexplib.h"
-#include "cmsys/Encoding.hxx"
-#include "cmsys/FStream.hxx"
#include <iostream>
+#include <sstream>
+#include <vector>
+
#include <windows.h>
+#include "cmsys/Encoding.hxx"
+#include "cmsys/FStream.hxx"
+
+#include "cmSystemTools.h"
+
+#ifndef IMAGE_FILE_MACHINE_ARM
+# define IMAGE_FILE_MACHINE_ARM 0x01c0 // ARM Little-Endian
+#endif
+
+#ifndef IMAGE_FILE_MACHINE_THUMB
+# define IMAGE_FILE_MACHINE_THUMB 0x01c2 // ARM Thumb/Thumb-2 Little-Endian
+#endif
+
#ifndef IMAGE_FILE_MACHINE_ARMNT
-#define IMAGE_FILE_MACHINE_ARMNT 0x01c4
+# define IMAGE_FILE_MACHINE_ARMNT 0x01c4 // ARM Thumb-2 Little-Endian
+#endif
+
+#ifndef IMAGE_FILE_MACHINE_ARM64
+# define IMAGE_FILE_MACHINE_ARM64 0xaa64 // ARM64 Little-Endian
#endif
typedef struct cmANON_OBJECT_HEADER_BIGOBJ
@@ -176,7 +195,7 @@ public:
{
this->ObjectImageHeader = ih;
this->SymbolTable =
- (SymbolTableType*)((DWORD_PTR) this->ObjectImageHeader +
+ (SymbolTableType*)((DWORD_PTR)this->ObjectImageHeader +
this->ObjectImageHeader->PointerToSymbolTable);
this->SectionHeaders = GetSectionHeaderOffset(this->ObjectImageHeader);
this->SymbolCount = this->ObjectImageHeader->NumberOfSymbols;
@@ -215,10 +234,10 @@ public:
(pSymbolTable->Type == 0x20 || pSymbolTable->Type == 0x0)) {
if (pSymbolTable->StorageClass == IMAGE_SYM_CLASS_EXTERNAL) {
/*
- * The name of the Function entry points
- */
+ * The name of the Function entry points
+ */
if (pSymbolTable->N.Name.Short != 0) {
- symbol = "";
+ symbol.clear();
symbol.insert(0, (const char*)pSymbolTable->N.ShortName, 8);
} else {
symbol = stringTable + pSymbolTable->N.Name.Long;
@@ -270,8 +289,8 @@ public:
}
/*
- * Take into account any aux symbols
- */
+ * Take into account any aux symbols
+ */
i += pSymbolTable->NumberOfAuxSymbols;
pSymbolTable += pSymbolTable->NumberOfAuxSymbols;
pSymbolTable++;
@@ -288,13 +307,68 @@ private:
bool IsI386;
};
-bool DumpFile(const char* filename, std::set<std::string>& symbols,
+bool DumpFileWithLlvmNm(std::string const& nmPath, const char* filename,
+ std::set<std::string>& symbols,
+ std::set<std::string>& dataSymbols)
+{
+ std::string output;
+ // break up command line into a vector
+ std::vector<std::string> command;
+ command.push_back(nmPath);
+ command.push_back("--no-weak");
+ command.push_back("--defined-only");
+ command.push_back("--format=posix");
+ command.push_back(filename);
+
+ // run the command
+ int exit_code = 0;
+ cmSystemTools::RunSingleCommand(command, &output, &output, &exit_code, "",
+ cmSystemTools::OUTPUT_NONE);
+
+ if (exit_code != 0) {
+ fprintf(stderr, "llvm-nm returned an error: %s\n", output.c_str());
+ return false;
+ }
+
+ std::istringstream ss(output);
+ std::string line;
+ while (std::getline(ss, line)) {
+ if (line.empty()) { // last line
+ continue;
+ }
+ size_t sym_end = line.find(" ");
+ if (sym_end == std::string::npos) {
+ fprintf(stderr, "Couldn't parse llvm-nm output line: %s\n",
+ line.c_str());
+ return false;
+ }
+ if (line.size() < sym_end + 1) {
+ fprintf(stderr, "Couldn't parse llvm-nm output line: %s\n",
+ line.c_str());
+ return false;
+ }
+ const std::string sym = line.substr(0, sym_end);
+ const char sym_type = line[sym_end + 1];
+ switch (sym_type) {
+ case 'D':
+ dataSymbols.insert(sym);
+ break;
+ case 'T':
+ symbols.insert(sym);
+ break;
+ }
+ }
+
+ return true;
+}
+
+bool DumpFile(std::string const& nmPath, const char* filename,
+ std::set<std::string>& symbols,
std::set<std::string>& dataSymbols)
{
HANDLE hFile;
HANDLE hFileMapping;
LPVOID lpFileBase;
- PIMAGE_DOS_HEADER dosHeader;
hFile = CreateFileW(cmsys::Encoding::ToWide(filename).c_str(), GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING,
@@ -320,36 +394,52 @@ bool DumpFile(const char* filename, std::set<std::string>& symbols,
return false;
}
- dosHeader = (PIMAGE_DOS_HEADER)lpFileBase;
+ const PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)lpFileBase;
if (dosHeader->e_magic == IMAGE_DOS_SIGNATURE) {
fprintf(stderr, "File is an executable. I don't dump those.\n");
return false;
- }
- /* Does it look like a COFF OBJ file??? */
- else if (((dosHeader->e_magic == IMAGE_FILE_MACHINE_I386) ||
- (dosHeader->e_magic == IMAGE_FILE_MACHINE_AMD64) ||
- (dosHeader->e_magic == IMAGE_FILE_MACHINE_ARMNT)) &&
- (dosHeader->e_sp == 0)) {
- /*
- * The two tests above aren't what they look like. They're
- * really checking for IMAGE_FILE_HEADER.Machine == i386 (0x14C)
- * and IMAGE_FILE_HEADER.SizeOfOptionalHeader == 0;
- */
- DumpSymbols<IMAGE_FILE_HEADER, IMAGE_SYMBOL> symbolDumper(
- (PIMAGE_FILE_HEADER)lpFileBase, symbols, dataSymbols,
- (dosHeader->e_magic == IMAGE_FILE_MACHINE_I386));
- symbolDumper.DumpObjFile();
} else {
- // check for /bigobj format
- cmANON_OBJECT_HEADER_BIGOBJ* h = (cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase;
- if (h->Sig1 == 0x0 && h->Sig2 == 0xffff) {
- DumpSymbols<cmANON_OBJECT_HEADER_BIGOBJ, cmIMAGE_SYMBOL_EX> symbolDumper(
- (cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase, symbols, dataSymbols,
- (h->Machine == IMAGE_FILE_MACHINE_I386));
+ const PIMAGE_FILE_HEADER imageHeader = (PIMAGE_FILE_HEADER)lpFileBase;
+ /* Does it look like a COFF OBJ file??? */
+ if (((imageHeader->Machine == IMAGE_FILE_MACHINE_I386) ||
+ (imageHeader->Machine == IMAGE_FILE_MACHINE_AMD64) ||
+ (imageHeader->Machine == IMAGE_FILE_MACHINE_ARM) ||
+ (imageHeader->Machine == IMAGE_FILE_MACHINE_ARMNT) ||
+ (imageHeader->Machine == IMAGE_FILE_MACHINE_ARM64)) &&
+ (imageHeader->Characteristics == 0)) {
+ /*
+ * The tests above are checking for IMAGE_FILE_HEADER.Machine
+ * if it contains supported machine formats (currently ARM and x86)
+ * and IMAGE_FILE_HEADER.Characteristics == 0 indicating that
+ * this is not linked COFF OBJ file;
+ */
+ DumpSymbols<IMAGE_FILE_HEADER, IMAGE_SYMBOL> symbolDumper(
+ (PIMAGE_FILE_HEADER)lpFileBase, symbols, dataSymbols,
+ (imageHeader->Machine == IMAGE_FILE_MACHINE_I386));
symbolDumper.DumpObjFile();
} else {
- printf("unrecognized file format in '%s'\n", filename);
- return false;
+ // check for /bigobj and llvm LTO format
+ cmANON_OBJECT_HEADER_BIGOBJ* h =
+ (cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase;
+ if (h->Sig1 == 0x0 && h->Sig2 == 0xffff) {
+ // bigobj
+ DumpSymbols<cmANON_OBJECT_HEADER_BIGOBJ, cmIMAGE_SYMBOL_EX>
+ symbolDumper((cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase, symbols,
+ dataSymbols, (h->Machine == IMAGE_FILE_MACHINE_I386));
+ symbolDumper.DumpObjFile();
+ } else if (
+ // BCexCODE - llvm bitcode
+ (h->Sig1 == 0x4342 && h->Sig2 == 0xDEC0) ||
+ // 0x0B17C0DE - llvm bitcode BC wrapper
+ (h->Sig1 == 0x0B17 && h->Sig2 == 0xC0DE)) {
+
+ return DumpFileWithLlvmNm(nmPath, filename, symbols, dataSymbols);
+
+ } else {
+ printf("unrecognized file format in '%s, %u'\n", filename,
+ imageHeader->Machine);
+ return false;
+ }
}
}
UnmapViewOfFile(lpFileBase);
@@ -360,7 +450,7 @@ bool DumpFile(const char* filename, std::set<std::string>& symbols,
bool bindexplib::AddObjectFile(const char* filename)
{
- return DumpFile(filename, this->Symbols, this->DataSymbols);
+ return DumpFile(NmPath, filename, this->Symbols, this->DataSymbols);
}
bool bindexplib::AddDefinitionFile(const char* filename)
@@ -372,7 +462,7 @@ bool bindexplib::AddDefinitionFile(const char* filename)
}
std::string str;
while (std::getline(infile, str)) {
- // skip the LIBRAY and EXPORTS lines (if any)
+ // skip the LIBRARY and EXPORTS lines (if any)
if ((str.compare(0, 7, "LIBRARY") == 0) ||
(str.compare(0, 7, "EXPORTS") == 0)) {
continue;
@@ -394,12 +484,15 @@ bool bindexplib::AddDefinitionFile(const char* filename)
void bindexplib::WriteFile(FILE* file)
{
fprintf(file, "EXPORTS \n");
- for (std::set<std::string>::const_iterator i = this->DataSymbols.begin();
- i != this->DataSymbols.end(); ++i) {
- fprintf(file, "\t%s \t DATA\n", i->c_str());
+ for (std::string const& ds : this->DataSymbols) {
+ fprintf(file, "\t%s \t DATA\n", ds.c_str());
}
- for (std::set<std::string>::const_iterator i = this->Symbols.begin();
- i != this->Symbols.end(); ++i) {
- fprintf(file, "\t%s\n", i->c_str());
+ for (std::string const& s : this->Symbols) {
+ fprintf(file, "\t%s\n", s.c_str());
}
}
+
+void bindexplib::SetNmPath(std::string const& nm)
+{
+ NmPath = nm;
+}
diff --git a/Source/bindexplib.h b/Source/bindexplib.h
index bc904e9f8..538177dff 100644
--- a/Source/bindexplib.h
+++ b/Source/bindexplib.h
@@ -3,22 +3,26 @@
#ifndef bindexplib_h
#define bindexplib_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <set>
-#include <stdio.h>
#include <string>
+#include <stdio.h>
+
class bindexplib
{
public:
- bindexplib() {}
+ bindexplib() { NmPath = "nm"; }
bool AddDefinitionFile(const char* filename);
bool AddObjectFile(const char* filename);
void WriteFile(FILE* file);
+ void SetNmPath(std::string const& nm);
+
private:
std::set<std::string> Symbols;
std::set<std::string> DataSymbols;
+ std::string NmPath;
};
#endif
diff --git a/Source/cmAddCompileDefinitionsCommand.cxx b/Source/cmAddCompileDefinitionsCommand.cxx
new file mode 100644
index 000000000..b00a4a7f7
--- /dev/null
+++ b/Source/cmAddCompileDefinitionsCommand.cxx
@@ -0,0 +1,16 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmAddCompileDefinitionsCommand.h"
+
+#include "cmExecutionStatus.h"
+#include "cmMakefile.h"
+
+bool cmAddCompileDefinitionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ cmMakefile& mf = status.GetMakefile();
+ for (std::string const& i : args) {
+ mf.AddCompileDefinition(i);
+ }
+ return true;
+}
diff --git a/Source/cmAddCompileDefinitionsCommand.h b/Source/cmAddCompileDefinitionsCommand.h
new file mode 100644
index 000000000..4bd621c4b
--- /dev/null
+++ b/Source/cmAddCompileDefinitionsCommand.h
@@ -0,0 +1,16 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmAddCompileDefinitionsCommand_h
+#define cmAddCompileDefinitionsCommand_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+#include <vector>
+
+class cmExecutionStatus;
+
+bool cmAddCompileDefinitionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+
+#endif
diff --git a/Source/cmAddCompileOptionsCommand.cxx b/Source/cmAddCompileOptionsCommand.cxx
index 21a8012d8..8ccb5129a 100644
--- a/Source/cmAddCompileOptionsCommand.cxx
+++ b/Source/cmAddCompileOptionsCommand.cxx
@@ -2,20 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddCompileOptionsCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-class cmExecutionStatus;
-
-bool cmAddCompileOptionsCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmAddCompileOptionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- if (args.empty()) {
- return true;
- }
-
- for (std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i) {
- this->Makefile->AddCompileOption(i->c_str());
+ cmMakefile& mf = status.GetMakefile();
+ for (std::string const& i : args) {
+ mf.AddCompileOption(i);
}
return true;
}
diff --git a/Source/cmAddCompileOptionsCommand.h b/Source/cmAddCompileOptionsCommand.h
index 297f901db..b172412be 100644
--- a/Source/cmAddCompileOptionsCommand.h
+++ b/Source/cmAddCompileOptionsCommand.h
@@ -3,29 +3,14 @@
#ifndef cmAddCompileOptionsCommand_h
#define cmAddCompileOptionsCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmAddCompileOptionsCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmAddCompileOptionsCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmAddCompileOptionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index b5e7c9ea9..6e04ce582 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -3,42 +3,51 @@
#include "cmAddCustomCommandCommand.h"
#include <sstream>
+#include <unordered_set>
+#include "cmCheckCustomOutputs.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
+#include "cmCustomCommandTypes.h"
+#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
-#include "cmSourceFile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmTarget.h"
-#include "cmake.h"
-class cmExecutionStatus;
-
-// cmAddCustomCommandCommand
-bool cmAddCustomCommandCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
/* Let's complain at the end of this function about the lack of a particular
arg. For the moment, let's say that COMMAND, and either TARGET or SOURCE
are required.
*/
if (args.size() < 4) {
- this->SetError("called with wrong number of arguments.");
+ status.SetError("called with wrong number of arguments.");
return false;
}
- std::string source, target, main_dependency, working, depfile;
+ cmMakefile& mf = status.GetMakefile();
+ std::string source;
+ std::string target;
+ std::string main_dependency;
+ std::string working;
+ std::string depfile;
+ std::string job_pool;
std::string comment_buffer;
- const char* comment = CM_NULLPTR;
- std::vector<std::string> depends, outputs, output, byproducts;
+ const char* comment = nullptr;
+ std::vector<std::string> depends;
+ std::vector<std::string> outputs;
+ std::vector<std::string> output;
+ std::vector<std::string> byproducts;
bool verbatim = false;
bool append = false;
bool uses_terminal = false;
bool command_expand_lists = false;
std::string implicit_depends_lang;
- cmCustomCommand::ImplicitDependsList implicit_depends;
+ cmImplicitDependsList implicit_depends;
// Accumulate one command line at a time.
cmCustomCommandLine currentLine;
@@ -46,7 +55,7 @@ bool cmAddCustomCommandCommand::InitialPass(
// Save all command lines.
cmCustomCommandLines commandLines;
- cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD;
+ cmCustomCommandType cctype = cmCustomCommandType::POST_BUILD;
enum tdoing
{
@@ -63,64 +72,115 @@ bool cmAddCustomCommandCommand::InitialPass(
doing_comment,
doing_working_directory,
doing_depfile,
+ doing_job_pool,
doing_nothing
};
tdoing doing = doing_nothing;
- for (unsigned int j = 0; j < args.size(); ++j) {
- std::string const& copy = args[j];
+#define MAKE_STATIC_KEYWORD(KEYWORD) \
+ static const std::string key##KEYWORD = #KEYWORD
+ MAKE_STATIC_KEYWORD(APPEND);
+ MAKE_STATIC_KEYWORD(ARGS);
+ MAKE_STATIC_KEYWORD(BYPRODUCTS);
+ MAKE_STATIC_KEYWORD(COMMAND);
+ MAKE_STATIC_KEYWORD(COMMAND_EXPAND_LISTS);
+ MAKE_STATIC_KEYWORD(COMMENT);
+ MAKE_STATIC_KEYWORD(DEPENDS);
+ MAKE_STATIC_KEYWORD(DEPFILE);
+ MAKE_STATIC_KEYWORD(IMPLICIT_DEPENDS);
+ MAKE_STATIC_KEYWORD(JOB_POOL);
+ MAKE_STATIC_KEYWORD(MAIN_DEPENDENCY);
+ MAKE_STATIC_KEYWORD(OUTPUT);
+ MAKE_STATIC_KEYWORD(OUTPUTS);
+ MAKE_STATIC_KEYWORD(POST_BUILD);
+ MAKE_STATIC_KEYWORD(PRE_BUILD);
+ MAKE_STATIC_KEYWORD(PRE_LINK);
+ MAKE_STATIC_KEYWORD(SOURCE);
+ MAKE_STATIC_KEYWORD(TARGET);
+ MAKE_STATIC_KEYWORD(USES_TERMINAL);
+ MAKE_STATIC_KEYWORD(VERBATIM);
+ MAKE_STATIC_KEYWORD(WORKING_DIRECTORY);
+#undef MAKE_STATIC_KEYWORD
+ static std::unordered_set<std::string> const keywords{
+ keyAPPEND,
+ keyARGS,
+ keyBYPRODUCTS,
+ keyCOMMAND,
+ keyCOMMAND_EXPAND_LISTS,
+ keyCOMMENT,
+ keyDEPENDS,
+ keyDEPFILE,
+ keyIMPLICIT_DEPENDS,
+ keyJOB_POOL,
+ keyMAIN_DEPENDENCY,
+ keyOUTPUT,
+ keyOUTPUTS,
+ keyPOST_BUILD,
+ keyPRE_BUILD,
+ keyPRE_LINK,
+ keySOURCE,
+ keyTARGET,
+ keyUSES_TERMINAL,
+ keyVERBATIM,
+ keyWORKING_DIRECTORY
+ };
- if (copy == "SOURCE") {
- doing = doing_source;
- } else if (copy == "COMMAND") {
- doing = doing_command;
+ for (std::string const& copy : args) {
+ if (keywords.count(copy)) {
+ if (copy == keySOURCE) {
+ doing = doing_source;
+ } else if (copy == keyCOMMAND) {
+ doing = doing_command;
- // Save the current command before starting the next command.
- if (!currentLine.empty()) {
- commandLines.push_back(currentLine);
- currentLine.clear();
- }
- } else if (copy == "PRE_BUILD") {
- cctype = cmTarget::PRE_BUILD;
- } else if (copy == "PRE_LINK") {
- cctype = cmTarget::PRE_LINK;
- } else if (copy == "POST_BUILD") {
- cctype = cmTarget::POST_BUILD;
- } else if (copy == "VERBATIM") {
- verbatim = true;
- } else if (copy == "APPEND") {
- append = true;
- } else if (copy == "USES_TERMINAL") {
- uses_terminal = true;
- } else if (copy == "COMMAND_EXPAND_LISTS") {
- command_expand_lists = true;
- } else if (copy == "TARGET") {
- doing = doing_target;
- } else if (copy == "ARGS") {
- // Ignore this old keyword.
- } else if (copy == "DEPENDS") {
- doing = doing_depends;
- } else if (copy == "OUTPUTS") {
- doing = doing_outputs;
- } else if (copy == "OUTPUT") {
- doing = doing_output;
- } else if (copy == "BYPRODUCTS") {
- doing = doing_byproducts;
- } else if (copy == "WORKING_DIRECTORY") {
- doing = doing_working_directory;
- } else if (copy == "MAIN_DEPENDENCY") {
- doing = doing_main_dependency;
- } else if (copy == "IMPLICIT_DEPENDS") {
- doing = doing_implicit_depends_lang;
- } else if (copy == "COMMENT") {
- doing = doing_comment;
- } else if (copy == "DEPFILE") {
- doing = doing_depfile;
- if (this->Makefile->GetGlobalGenerator()->GetName() != "Ninja") {
- this->SetError("Option DEPFILE not supported by " +
- this->Makefile->GetGlobalGenerator()->GetName());
- return false;
+ // Save the current command before starting the next command.
+ if (!currentLine.empty()) {
+ commandLines.push_back(currentLine);
+ currentLine.clear();
+ }
+ } else if (copy == keyPRE_BUILD) {
+ cctype = cmCustomCommandType::PRE_BUILD;
+ } else if (copy == keyPRE_LINK) {
+ cctype = cmCustomCommandType::PRE_LINK;
+ } else if (copy == keyPOST_BUILD) {
+ cctype = cmCustomCommandType::POST_BUILD;
+ } else if (copy == keyVERBATIM) {
+ verbatim = true;
+ } else if (copy == keyAPPEND) {
+ append = true;
+ } else if (copy == keyUSES_TERMINAL) {
+ uses_terminal = true;
+ } else if (copy == keyCOMMAND_EXPAND_LISTS) {
+ command_expand_lists = true;
+ } else if (copy == keyTARGET) {
+ doing = doing_target;
+ } else if (copy == keyARGS) {
+ // Ignore this old keyword.
+ } else if (copy == keyDEPENDS) {
+ doing = doing_depends;
+ } else if (copy == keyOUTPUTS) {
+ doing = doing_outputs;
+ } else if (copy == keyOUTPUT) {
+ doing = doing_output;
+ } else if (copy == keyBYPRODUCTS) {
+ doing = doing_byproducts;
+ } else if (copy == keyWORKING_DIRECTORY) {
+ doing = doing_working_directory;
+ } else if (copy == keyMAIN_DEPENDENCY) {
+ doing = doing_main_dependency;
+ } else if (copy == keyIMPLICIT_DEPENDS) {
+ doing = doing_implicit_depends_lang;
+ } else if (copy == keyCOMMENT) {
+ doing = doing_comment;
+ } else if (copy == keyDEPFILE) {
+ doing = doing_depfile;
+ if (mf.GetGlobalGenerator()->GetName() != "Ninja") {
+ status.SetError("Option DEPFILE not supported by " +
+ mf.GetGlobalGenerator()->GetName());
+ return false;
+ }
+ } else if (copy == keyJOB_POOL) {
+ doing = doing_job_pool;
}
} else {
std::string filename;
@@ -128,7 +188,7 @@ bool cmAddCustomCommandCommand::InitialPass(
case doing_output:
case doing_outputs:
case doing_byproducts:
- if (!cmSystemTools::FileIsFullPath(copy.c_str())) {
+ if (!cmSystemTools::FileIsFullPath(copy)) {
// This is an output to be generated, so it should be
// under the build tree. CMake 2.4 placed this under the
// source tree. However the only case that this change
@@ -139,8 +199,7 @@ bool cmAddCustomCommandCommand::InitialPass(
// and later references "${CMAKE_CURRENT_SOURCE_DIR}/out.txt".
// This is fairly obscure so we can wait for someone to
// complain.
- filename = this->Makefile->GetCurrentBinaryDirectory();
- filename += "/";
+ filename = cmStrCat(mf.GetCurrentBinaryDirectory(), '/');
}
filename += copy;
cmSystemTools::ConvertToUnixSlashes(filename);
@@ -155,13 +214,16 @@ bool cmAddCustomCommandCommand::InitialPass(
break;
}
- if (cmSystemTools::FileIsFullPath(filename.c_str())) {
+ if (cmSystemTools::FileIsFullPath(filename)) {
filename = cmSystemTools::CollapseFullPath(filename);
}
switch (doing) {
case doing_depfile:
depfile = copy;
break;
+ case doing_job_pool:
+ job_pool = copy;
+ break;
case doing_working_directory:
working = copy;
break;
@@ -182,13 +244,13 @@ bool cmAddCustomCommandCommand::InitialPass(
// An implicit dependency starting point is also an
// explicit dependency.
std::string dep = copy;
+ // Upfront path conversion is correct because Genex
+ // are not supported.
cmSystemTools::ConvertToUnixSlashes(dep);
depends.push_back(dep);
// Add the implicit dependency language and file.
- cmCustomCommand::ImplicitDependsPair entry(implicit_depends_lang,
- dep);
- implicit_depends.push_back(entry);
+ implicit_depends.emplace_back(implicit_depends_lang, dep);
// Switch back to looking for a language.
doing = doing_implicit_depends_lang;
@@ -200,9 +262,7 @@ bool cmAddCustomCommandCommand::InitialPass(
target = copy;
break;
case doing_depends: {
- std::string dep = copy;
- cmSystemTools::ConvertToUnixSlashes(dep);
- depends.push_back(dep);
+ depends.push_back(copy);
} break;
case doing_outputs:
outputs.push_back(filename);
@@ -215,7 +275,7 @@ bool cmAddCustomCommandCommand::InitialPass(
comment = comment_buffer.c_str();
break;
default:
- this->SetError("Wrong syntax. Unknown type of argument.");
+ status.SetError("Wrong syntax. Unknown type of argument.");
return false;
}
}
@@ -230,51 +290,44 @@ bool cmAddCustomCommandCommand::InitialPass(
// At this point we could complain about the lack of arguments. For
// the moment, let's say that COMMAND, TARGET are always required.
if (output.empty() && target.empty()) {
- this->SetError("Wrong syntax. A TARGET or OUTPUT must be specified.");
+ status.SetError("Wrong syntax. A TARGET or OUTPUT must be specified.");
return false;
}
if (source.empty() && !target.empty() && !output.empty()) {
- this->SetError(
+ status.SetError(
"Wrong syntax. A TARGET and OUTPUT can not both be specified.");
return false;
}
if (append && output.empty()) {
- this->SetError("given APPEND option with no OUTPUT.");
+ status.SetError("given APPEND option with no OUTPUT.");
return false;
}
// Make sure the output names and locations are safe.
- if (!this->CheckOutputs(output) || !this->CheckOutputs(outputs) ||
- !this->CheckOutputs(byproducts)) {
+ if (!cmCheckCustomOutputs(output, "OUTPUT", status) ||
+ !cmCheckCustomOutputs(outputs, "OUTPUTS", status) ||
+ !cmCheckCustomOutputs(byproducts, "BYPRODUCTS", status)) {
return false;
}
// Check for an append request.
if (append) {
- // Lookup an existing command.
- if (cmSourceFile* sf =
- this->Makefile->GetSourceFileWithOutput(output[0])) {
- if (cmCustomCommand* cc = sf->GetCustomCommand()) {
- cc->AppendCommands(commandLines);
- cc->AppendDepends(depends);
- cc->AppendImplicitDepends(implicit_depends);
- return true;
- }
+ if (mf.AppendCustomCommandToOutput(output[0], depends, implicit_depends,
+ commandLines)) {
+ return true;
}
// No command for this output exists.
- std::ostringstream e;
- e << "given APPEND option with output\n\"" << output[0]
- << "\"\nwhich is not already a custom command output.";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("given APPEND option with output\n ", output[0],
+ "\nwhich is not already a custom command output."));
return false;
}
- // Convert working directory to a full path.
- if (!working.empty()) {
- const char* build_dir = this->Makefile->GetCurrentBinaryDirectory();
- working = cmSystemTools::CollapseFullPath(working, build_dir);
+ if (uses_terminal && !job_pool.empty()) {
+ status.SetError("JOB_POOL is shadowed by USES_TERMINAL.");
+ return false;
}
// Choose which mode of the command to use.
@@ -282,46 +335,27 @@ bool cmAddCustomCommandCommand::InitialPass(
if (source.empty() && output.empty()) {
// Source is empty, use the target.
std::vector<std::string> no_depends;
- this->Makefile->AddCustomCommandToTarget(
- target, byproducts, no_depends, commandLines, cctype, comment,
- working.c_str(), escapeOldStyle, uses_terminal, depfile,
- command_expand_lists);
+ mf.AddCustomCommandToTarget(target, byproducts, no_depends, commandLines,
+ cctype, comment, working.c_str(),
+ escapeOldStyle, uses_terminal, depfile,
+ job_pool, command_expand_lists);
} else if (target.empty()) {
// Target is empty, use the output.
- this->Makefile->AddCustomCommandToOutput(
- output, byproducts, depends, main_dependency, commandLines, comment,
- working.c_str(), false, escapeOldStyle, uses_terminal,
- command_expand_lists, depfile);
-
- // Add implicit dependency scanning requests if any were given.
- if (!implicit_depends.empty()) {
- bool okay = false;
- if (cmSourceFile* sf =
- this->Makefile->GetSourceFileWithOutput(output[0])) {
- if (cmCustomCommand* cc = sf->GetCustomCommand()) {
- okay = true;
- cc->SetImplicitDepends(implicit_depends);
- }
- }
- if (!okay) {
- std::ostringstream e;
- e << "could not locate source file with a custom command producing \""
- << output[0] << "\" even though this command tried to create it!";
- this->SetError(e.str());
- return false;
- }
- }
+ mf.AddCustomCommandToOutput(
+ output, byproducts, depends, main_dependency, implicit_depends,
+ commandLines, comment, working.c_str(), false, escapeOldStyle,
+ uses_terminal, command_expand_lists, depfile, job_pool);
} else if (!byproducts.empty()) {
- this->SetError("BYPRODUCTS may not be specified with SOURCE signatures");
+ status.SetError("BYPRODUCTS may not be specified with SOURCE signatures");
return false;
} else if (uses_terminal) {
- this->SetError("USES_TERMINAL may not be used with SOURCE signatures");
+ status.SetError("USES_TERMINAL may not be used with SOURCE signatures");
return false;
} else {
bool issueMessage = true;
std::ostringstream e;
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0050)) {
+ MessageType messageType = MessageType::AUTHOR_WARNING;
+ switch (mf.GetPolicyStatus(cmPolicies::CMP0050)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0050) << "\n";
break;
@@ -331,51 +365,23 @@ bool cmAddCustomCommandCommand::InitialPass(
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::NEW:
- messageType = cmake::FATAL_ERROR;
+ messageType = MessageType::FATAL_ERROR;
break;
}
if (issueMessage) {
e << "The SOURCE signatures of add_custom_command are no longer "
"supported.";
- this->Makefile->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR) {
+ mf.IssueMessage(messageType, e.str());
+ if (messageType == MessageType::FATAL_ERROR) {
return false;
}
}
// Use the old-style mode for backward compatibility.
- this->Makefile->AddCustomCommandOldStyle(target, outputs, depends, source,
- commandLines, comment);
+ mf.AddCustomCommandOldStyle(target, outputs, depends, source, commandLines,
+ comment);
}
return true;
}
-
-bool cmAddCustomCommandCommand::CheckOutputs(
- const std::vector<std::string>& outputs)
-{
- for (std::vector<std::string>::const_iterator o = outputs.begin();
- o != outputs.end(); ++o) {
- // Make sure the file will not be generated into the source
- // directory during an out of source build.
- if (!this->Makefile->CanIWriteThisFile(o->c_str())) {
- std::string e = "attempted to have a file \"" + *o +
- "\" in a source directory as an output of custom command.";
- this->SetError(e);
- cmSystemTools::SetFatalErrorOccured();
- return false;
- }
-
- // Make sure the output file name has no invalid characters.
- std::string::size_type pos = o->find_first_of("#<>");
- if (pos != std::string::npos) {
- std::ostringstream msg;
- msg << "called with OUTPUT containing a \"" << (*o)[pos]
- << "\". This character is not allowed.";
- this->SetError(msg.str());
- return false;
- }
- }
- return true;
-}
diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h
index c3a91b2a3..4f8c58fef 100644
--- a/Source/cmAddCustomCommandCommand.h
+++ b/Source/cmAddCustomCommandCommand.h
@@ -3,38 +3,14 @@
#ifndef cmAddCustomCommandCommand_h
#define cmAddCustomCommandCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmAddCustomCommandCommand
- * \brief cmAddCustomCommandCommand defines a new command (rule) that can
- * be executed within the build process
- *
- */
-
-class cmAddCustomCommandCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmAddCustomCommandCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-protected:
- bool CheckOutputs(const std::vector<std::string>& outputs);
-};
+bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index 87e114780..e27b126dd 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -2,37 +2,37 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddCustomTargetCommand.h"
-#include <sstream>
+#include <utility>
+#include "cmCheckCustomOutputs.h"
#include "cmCustomCommandLines.h"
+#include "cmCustomCommandTypes.h"
+#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
-#include "cmPolicies.h"
+#include "cmMessageType.h"
+#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cmake.h"
-class cmExecutionStatus;
-
-// cmAddCustomTargetCommand
-bool cmAddCustomTargetCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
std::string const& targetName = args[0];
// Check the target name.
if (targetName.find_first_of("/\\") != std::string::npos) {
- std::ostringstream e;
- e << "called with invalid target name \"" << targetName
- << "\". Target names may not contain a slash. "
- << "Use ADD_CUSTOM_COMMAND to generate files.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("called with invalid target name \"", targetName,
+ "\". Target names may not contain a slash. "
+ "Use ADD_CUSTOM_COMMAND to generate files."));
return false;
}
@@ -43,14 +43,16 @@ bool cmAddCustomTargetCommand::InitialPass(
cmCustomCommandLines commandLines;
// Accumulate dependencies.
- std::vector<std::string> depends, byproducts;
+ std::vector<std::string> depends;
+ std::vector<std::string> byproducts;
std::string working_directory;
bool verbatim = false;
bool uses_terminal = false;
bool command_expand_lists = false;
std::string comment_buffer;
- const char* comment = CM_NULLPTR;
+ const char* comment = nullptr;
std::vector<std::string> sources;
+ std::string job_pool;
// Keep track of parser state.
enum tdoing
@@ -61,6 +63,7 @@ bool cmAddCustomTargetCommand::InitialPass(
doing_working_directory,
doing_comment,
doing_source,
+ doing_job_pool,
doing_nothing
};
tdoing doing = doing_command;
@@ -96,6 +99,8 @@ bool cmAddCustomTargetCommand::InitialPass(
command_expand_lists = true;
} else if (copy == "COMMENT") {
doing = doing_comment;
+ } else if (copy == "JOB_POOL") {
+ doing = doing_job_pool;
} else if (copy == "COMMAND") {
doing = doing_command;
@@ -116,18 +121,17 @@ bool cmAddCustomTargetCommand::InitialPass(
break;
case doing_byproducts: {
std::string filename;
- if (!cmSystemTools::FileIsFullPath(copy.c_str())) {
- filename = this->Makefile->GetCurrentBinaryDirectory();
- filename += "/";
+ if (!cmSystemTools::FileIsFullPath(copy)) {
+ filename = cmStrCat(mf.GetCurrentBinaryDirectory(), '/');
}
filename += copy;
cmSystemTools::ConvertToUnixSlashes(filename);
- byproducts.push_back(filename);
+ byproducts.push_back(cmSystemTools::CollapseFullPath(filename));
} break;
case doing_depends: {
std::string dep = copy;
cmSystemTools::ConvertToUnixSlashes(dep);
- depends.push_back(dep);
+ depends.push_back(std::move(dep));
} break;
case doing_comment:
comment_buffer = copy;
@@ -136,8 +140,11 @@ bool cmAddCustomTargetCommand::InitialPass(
case doing_source:
sources.push_back(copy);
break;
+ case doing_job_pool:
+ job_pool = copy;
+ break;
default:
- this->SetError("Wrong syntax. Unknown type of argument.");
+ status.SetError("Wrong syntax. Unknown type of argument.");
return false;
}
}
@@ -145,10 +152,9 @@ bool cmAddCustomTargetCommand::InitialPass(
std::string::size_type pos = targetName.find_first_of("#<>");
if (pos != std::string::npos) {
- std::ostringstream msg;
- msg << "called with target name containing a \"" << targetName[pos]
- << "\". This character is not allowed.";
- this->SetError(msg.str());
+ status.SetError(cmStrCat("called with target name containing a \"",
+ targetName[pos],
+ "\". This character is not allowed."));
return false;
}
@@ -160,35 +166,8 @@ bool cmAddCustomTargetCommand::InitialPass(
if (nameOk) {
nameOk = targetName.find(':') == std::string::npos;
}
- if (!nameOk) {
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- std::ostringstream e;
- bool issueMessage = false;
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) {
- case cmPolicies::WARN:
- e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
- issueMessage = true;
- case cmPolicies::OLD:
- break;
- case cmPolicies::NEW:
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- issueMessage = true;
- messageType = cmake::FATAL_ERROR;
- }
- if (issueMessage) {
- /* clang-format off */
- e << "The target name \"" << targetName <<
- "\" is reserved or not valid for certain "
- "CMake features, such as generator expressions, and may result "
- "in undefined behavior.";
- /* clang-format on */
- this->Makefile->IssueMessage(messageType, e.str());
-
- if (messageType == cmake::FATAL_ERROR) {
- return false;
- }
- }
+ if (!nameOk && !mf.CheckCMP0037(targetName, cmStateEnums::UTILITY)) {
+ return false;
}
// Store the last command line finished.
@@ -200,44 +179,45 @@ bool cmAddCustomTargetCommand::InitialPass(
// Enforce name uniqueness.
{
std::string msg;
- if (!this->Makefile->EnforceUniqueName(targetName, msg, true)) {
- this->SetError(msg);
+ if (!mf.EnforceUniqueName(targetName, msg, true)) {
+ status.SetError(msg);
return false;
}
}
- // Convert working directory to a full path.
- if (!working_directory.empty()) {
- const char* build_dir = this->Makefile->GetCurrentBinaryDirectory();
- working_directory =
- cmSystemTools::CollapseFullPath(working_directory, build_dir);
- }
-
if (commandLines.empty() && !byproducts.empty()) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
- "BYPRODUCTS may not be specified without any COMMAND");
+ mf.IssueMessage(MessageType::FATAL_ERROR,
+ "BYPRODUCTS may not be specified without any COMMAND");
return true;
}
if (commandLines.empty() && uses_terminal) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
- "USES_TERMINAL may not be specified without any COMMAND");
+ mf.IssueMessage(MessageType::FATAL_ERROR,
+ "USES_TERMINAL may not be specified without any COMMAND");
return true;
}
if (commandLines.empty() && command_expand_lists) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
"COMMAND_EXPAND_LISTS may not be specified without any COMMAND");
return true;
}
+ if (uses_terminal && !job_pool.empty()) {
+ status.SetError("JOB_POOL is shadowed by USES_TERMINAL.");
+ return false;
+ }
+
+ // Make sure the byproduct names and locations are safe.
+ if (!cmCheckCustomOutputs(byproducts, "BYPRODUCTS", status)) {
+ return false;
+ }
+
// Add the utility target to the makefile.
bool escapeOldStyle = !verbatim;
- cmTarget* target = this->Makefile->AddUtilityCommand(
- targetName, excludeFromAll, working_directory.c_str(), byproducts, depends,
- commandLines, escapeOldStyle, comment, uses_terminal,
- command_expand_lists);
+ cmTarget* target = mf.AddUtilityCommand(
+ targetName, cmCommandOrigin::Project, excludeFromAll,
+ working_directory.c_str(), byproducts, depends, commandLines,
+ escapeOldStyle, comment, uses_terminal, command_expand_lists, job_pool);
// Add additional user-specified source files to the target.
target->AddSources(sources);
diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h
index 7229c2779..e23ef9fcc 100644
--- a/Source/cmAddCustomTargetCommand.h
+++ b/Source/cmAddCustomTargetCommand.h
@@ -3,36 +3,14 @@
#ifndef cmAddCustomTargetCommand_h
#define cmAddCustomTargetCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmAddCustomTargetCommand
- * \brief Command that adds a target to the build system.
- *
- * cmAddCustomTargetCommand adds an extra target to the build system.
- * This is useful when you would like to add special
- * targets like "install,", "clean," and so on.
- */
-class cmAddCustomTargetCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmAddCustomTargetCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmAddDefinitionsCommand.cxx b/Source/cmAddDefinitionsCommand.cxx
index 9e0607c60..0b10aeef6 100644
--- a/Source/cmAddDefinitionsCommand.cxx
+++ b/Source/cmAddDefinitionsCommand.cxx
@@ -2,22 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddDefinitionsCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-class cmExecutionStatus;
-
-// cmAddDefinitionsCommand
-bool cmAddDefinitionsCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmAddDefinitionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- // it is OK to have no arguments
- if (args.empty()) {
- return true;
- }
-
- for (std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i) {
- this->Makefile->AddDefineFlag(i->c_str());
+ cmMakefile& mf = status.GetMakefile();
+ for (std::string const& i : args) {
+ mf.AddDefineFlag(i);
}
return true;
}
diff --git a/Source/cmAddDefinitionsCommand.h b/Source/cmAddDefinitionsCommand.h
index abf5a5964..a67f09516 100644
--- a/Source/cmAddDefinitionsCommand.h
+++ b/Source/cmAddDefinitionsCommand.h
@@ -3,35 +3,14 @@
#ifndef cmAddDefinitionsCommand_h
#define cmAddDefinitionsCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmAddDefinitionsCommand
- * \brief Specify a list of compiler defines
- *
- * cmAddDefinitionsCommand specifies a list of compiler defines. These defines
- * will be added to the compile command.
- */
-class cmAddDefinitionsCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmAddDefinitionsCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmAddDefinitionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index a73b57e82..b1fc89341 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -2,45 +2,47 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddDependenciesCommand.h"
-#include <sstream>
-
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
-#include "cmake.h"
-
-class cmExecutionStatus;
-// cmDependenciesCommand
-bool cmAddDependenciesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmAddDependenciesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
std::string const& target_name = args[0];
- if (this->Makefile->IsAlias(target_name)) {
- std::ostringstream e;
- e << "Cannot add target-level dependencies to alias target \""
- << target_name << "\".\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ if (mf.IsAlias(target_name)) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot add target-level dependencies to alias target \"",
+ target_name, "\".\n"));
}
- if (cmTarget* target = this->Makefile->FindTargetToUse(target_name)) {
- std::vector<std::string>::const_iterator s = args.begin();
- ++s; // skip over target_name
- for (; s != args.end(); ++s) {
- target->AddUtility(*s, this->Makefile);
+ if (cmTarget* target = mf.FindTargetToUse(target_name)) {
+
+ // skip over target_name
+ for (std::string const& arg : cmMakeRange(args).advance(1)) {
+ target->AddUtility(arg, &mf);
}
} else {
- std::ostringstream e;
- e << "Cannot add target-level dependencies to non-existent target \""
- << target_name << "\".\n"
- << "The add_dependencies works for top-level logical targets created "
- << "by the add_executable, add_library, or add_custom_target commands. "
- << "If you want to add file-level dependencies see the DEPENDS option "
- << "of the add_custom_target and add_custom_command commands.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ "Cannot add target-level dependencies to non-existent "
+ "target \"",
+ target_name,
+ "\".\nThe add_dependencies works for "
+ "top-level logical targets created by the add_executable, "
+ "add_library, or add_custom_target commands. If you want to add "
+ "file-level dependencies see the DEPENDS option of the "
+ "add_custom_target and add_custom_command commands."));
}
return true;
diff --git a/Source/cmAddDependenciesCommand.h b/Source/cmAddDependenciesCommand.h
index c7328d63e..0c60e3a2d 100644
--- a/Source/cmAddDependenciesCommand.h
+++ b/Source/cmAddDependenciesCommand.h
@@ -3,34 +3,14 @@
#ifndef cmDependenciessCommand_h
#define cmDependenciessCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmAddDependenciesCommand
- * \brief Add a dependency to a target
- *
- * cmAddDependenciesCommand adds a dependency to a target
- */
-class cmAddDependenciesCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmAddDependenciesCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmAddDependenciesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index 1d0376fe0..e738bc467 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -2,27 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddExecutableCommand.h"
-#include <sstream>
-
+#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
-#include "cmPolicies.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
-#include "cmake.h"
-
-class cmExecutionStatus;
-// cmExecutableCommand
-bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmAddExecutableCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ if (args.empty()) {
+ status.SetError("called with incorrect number of arguments");
return false;
}
- std::vector<std::string>::const_iterator s = args.begin();
+
+ cmMakefile& mf = status.GetMakefile();
+ auto s = args.begin();
std::string const& exename = *s;
@@ -63,143 +60,100 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args,
if (nameOk && !importTarget && !isAlias) {
nameOk = exename.find(':') == std::string::npos;
}
- if (!nameOk) {
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- std::ostringstream e;
- bool issueMessage = false;
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) {
- case cmPolicies::WARN:
- e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
- issueMessage = true;
- case cmPolicies::OLD:
- break;
- case cmPolicies::NEW:
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- issueMessage = true;
- messageType = cmake::FATAL_ERROR;
- }
- if (issueMessage) {
- /* clang-format off */
- e << "The target name \"" << exename <<
- "\" is reserved or not valid for certain "
- "CMake features, such as generator expressions, and may result "
- "in undefined behavior.";
- /* clang-format on */
- this->Makefile->IssueMessage(messageType, e.str());
-
- if (messageType == cmake::FATAL_ERROR) {
- return false;
- }
- }
+ if (!nameOk && !mf.CheckCMP0037(exename, cmStateEnums::EXECUTABLE)) {
+ return false;
}
// Special modifiers are not allowed with IMPORTED signature.
if (importTarget && (use_win32 || use_macbundle || excludeFromAll)) {
if (use_win32) {
- this->SetError("may not be given WIN32 for an IMPORTED target.");
+ status.SetError("may not be given WIN32 for an IMPORTED target.");
} else if (use_macbundle) {
- this->SetError("may not be given MACOSX_BUNDLE for an IMPORTED target.");
+ status.SetError(
+ "may not be given MACOSX_BUNDLE for an IMPORTED target.");
} else // if(excludeFromAll)
{
- this->SetError(
+ status.SetError(
"may not be given EXCLUDE_FROM_ALL for an IMPORTED target.");
}
return false;
}
if (isAlias) {
if (!cmGeneratorExpression::IsValidTargetName(exename)) {
- this->SetError("Invalid name for ALIAS: " + exename);
+ status.SetError("Invalid name for ALIAS: " + exename);
return false;
}
if (excludeFromAll) {
- this->SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense.");
+ status.SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense.");
return false;
}
if (importTarget || importGlobal) {
- this->SetError("IMPORTED with ALIAS is not allowed.");
+ status.SetError("IMPORTED with ALIAS is not allowed.");
return false;
}
if (args.size() != 3) {
- std::ostringstream e;
- e << "ALIAS requires exactly one target argument.";
- this->SetError(e.str());
+ status.SetError("ALIAS requires exactly one target argument.");
return false;
}
- const char* aliasedName = s->c_str();
- if (this->Makefile->IsAlias(aliasedName)) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename << "\" because target \""
- << aliasedName << "\" is itself an ALIAS.";
- this->SetError(e.str());
+ std::string const& aliasedName = *s;
+ if (mf.IsAlias(aliasedName)) {
+ status.SetError(cmStrCat("cannot create ALIAS target \"", exename,
+ "\" because target \"", aliasedName,
+ "\" is itself an ALIAS."));
return false;
}
- cmTarget* aliasedTarget =
- this->Makefile->FindTargetToUse(aliasedName, true);
+ cmTarget* aliasedTarget = mf.FindTargetToUse(aliasedName, true);
if (!aliasedTarget) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename << "\" because target \""
- << aliasedName << "\" does not already "
- "exist.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", exename,
+ "\" because target \"", aliasedName,
+ "\" does not already exist."));
return false;
}
cmStateEnums::TargetType type = aliasedTarget->GetType();
if (type != cmStateEnums::EXECUTABLE) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename << "\" because target \""
- << aliasedName << "\" is not an "
- "executable.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", exename,
+ "\" because target \"", aliasedName,
+ "\" is not an executable."));
return false;
}
- if (aliasedTarget->IsImported()) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename << "\" because target \""
- << aliasedName << "\" is IMPORTED.";
- this->SetError(e.str());
+ if (aliasedTarget->IsImported() &&
+ !aliasedTarget->IsImportedGloballyVisible()) {
+ status.SetError(cmStrCat("cannot create ALIAS target \"", exename,
+ "\" because target \"", aliasedName,
+ "\" is imported but not globally visible."));
return false;
}
- this->Makefile->AddAlias(exename, aliasedName);
+ mf.AddAlias(exename, aliasedName);
return true;
}
// Handle imported target creation.
if (importTarget) {
// Make sure the target does not already exist.
- if (this->Makefile->FindTargetToUse(exename)) {
- std::ostringstream e;
- e << "cannot create imported target \"" << exename
- << "\" because another target with the same name already exists.";
- this->SetError(e.str());
+ if (mf.FindTargetToUse(exename)) {
+ status.SetError(cmStrCat(
+ "cannot create imported target \"", exename,
+ "\" because another target with the same name already exists."));
return false;
}
// Create the imported target.
- this->Makefile->AddImportedTarget(exename, cmStateEnums::EXECUTABLE,
- importGlobal);
+ mf.AddImportedTarget(exename, cmStateEnums::EXECUTABLE, importGlobal);
return true;
}
// Enforce name uniqueness.
{
std::string msg;
- if (!this->Makefile->EnforceUniqueName(exename, msg)) {
- this->SetError(msg);
+ if (!mf.EnforceUniqueName(exename, msg)) {
+ status.SetError(msg);
return false;
}
}
- if (s == args.end()) {
- this->SetError(
- "called with incorrect number of arguments, no sources provided");
- return false;
- }
-
std::vector<std::string> srclists(s, args.end());
- cmTarget* tgt =
- this->Makefile->AddExecutable(exename.c_str(), srclists, excludeFromAll);
+ cmTarget* tgt = mf.AddExecutable(exename, srclists, excludeFromAll);
if (use_win32) {
tgt->SetProperty("WIN32_EXECUTABLE", "ON");
}
diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h
index 8100da185..f7bc27336 100644
--- a/Source/cmAddExecutableCommand.h
+++ b/Source/cmAddExecutableCommand.h
@@ -3,35 +3,14 @@
#ifndef cmExecutablesCommand_h
#define cmExecutablesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmExecutablesCommand
- * \brief Defines a list of executables to build.
- *
- * cmExecutablesCommand defines a list of executable (i.e., test)
- * programs to create.
- */
-class cmAddExecutableCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmAddExecutableCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmAddExecutableCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index ebf17632a..0439c518c 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -2,40 +2,37 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddLibraryCommand.h"
-#include <sstream>
-
+#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
-#include "cmPolicies.h"
+#include "cmMessageType.h"
#include "cmState.h"
#include "cmStateTypes.h"
-#include "cmSystemTools.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
-#include "cmake.h"
-
-class cmExecutionStatus;
-// cmLibraryCommand
-bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmAddLibraryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+
+ cmMakefile& mf = status.GetMakefile();
// Library type defaults to value of BUILD_SHARED_LIBS, if it exists,
// otherwise it defaults to static library.
cmStateEnums::TargetType type = cmStateEnums::SHARED_LIBRARY;
- if (cmSystemTools::IsOff(
- this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) {
+ if (cmIsOff(mf.GetDefinition("BUILD_SHARED_LIBS"))) {
type = cmStateEnums::STATIC_LIBRARY;
}
bool excludeFromAll = false;
bool importTarget = false;
bool importGlobal = false;
- std::vector<std::string>::const_iterator s = args.begin();
+ auto s = args.begin();
std::string const& libName = *s;
@@ -50,9 +47,8 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
std::string libType = *s;
if (libType == "STATIC") {
if (type == cmStateEnums::INTERFACE_LIBRARY) {
- std::ostringstream e;
- e << "INTERFACE library specified with conflicting STATIC type.";
- this->SetError(e.str());
+ status.SetError(
+ "INTERFACE library specified with conflicting STATIC type.");
return false;
}
++s;
@@ -60,9 +56,8 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
haveSpecifiedType = true;
} else if (libType == "SHARED") {
if (type == cmStateEnums::INTERFACE_LIBRARY) {
- std::ostringstream e;
- e << "INTERFACE library specified with conflicting SHARED type.";
- this->SetError(e.str());
+ status.SetError(
+ "INTERFACE library specified with conflicting SHARED type.");
return false;
}
++s;
@@ -70,9 +65,8 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
haveSpecifiedType = true;
} else if (libType == "MODULE") {
if (type == cmStateEnums::INTERFACE_LIBRARY) {
- std::ostringstream e;
- e << "INTERFACE library specified with conflicting MODULE type.";
- this->SetError(e.str());
+ status.SetError(
+ "INTERFACE library specified with conflicting MODULE type.");
return false;
}
++s;
@@ -80,9 +74,8 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
haveSpecifiedType = true;
} else if (libType == "OBJECT") {
if (type == cmStateEnums::INTERFACE_LIBRARY) {
- std::ostringstream e;
- e << "INTERFACE library specified with conflicting OBJECT type.";
- this->SetError(e.str());
+ status.SetError(
+ "INTERFACE library specified with conflicting OBJECT type.");
return false;
}
++s;
@@ -90,9 +83,8 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
haveSpecifiedType = true;
} else if (libType == "UNKNOWN") {
if (type == cmStateEnums::INTERFACE_LIBRARY) {
- std::ostringstream e;
- e << "INTERFACE library specified with conflicting UNKNOWN type.";
- this->SetError(e.str());
+ status.SetError(
+ "INTERFACE library specified with conflicting UNKNOWN type.");
return false;
}
++s;
@@ -100,30 +92,26 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
haveSpecifiedType = true;
} else if (libType == "ALIAS") {
if (type == cmStateEnums::INTERFACE_LIBRARY) {
- std::ostringstream e;
- e << "INTERFACE library specified with conflicting ALIAS type.";
- this->SetError(e.str());
+ status.SetError(
+ "INTERFACE library specified with conflicting ALIAS type.");
return false;
}
++s;
isAlias = true;
} else if (libType == "INTERFACE") {
if (haveSpecifiedType) {
- std::ostringstream e;
- e << "INTERFACE library specified with conflicting/multiple types.";
- this->SetError(e.str());
+ status.SetError(
+ "INTERFACE library specified with conflicting/multiple types.");
return false;
}
if (isAlias) {
- std::ostringstream e;
- e << "INTERFACE library specified with conflicting ALIAS type.";
- this->SetError(e.str());
+ status.SetError(
+ "INTERFACE library specified with conflicting ALIAS type.");
return false;
}
if (excludeFromAll) {
- std::ostringstream e;
- e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
- this->SetError(e.str());
+ status.SetError(
+ "INTERFACE library may not be used with EXCLUDE_FROM_ALL.");
return false;
}
++s;
@@ -131,9 +119,8 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
haveSpecifiedType = true;
} else if (*s == "EXCLUDE_FROM_ALL") {
if (type == cmStateEnums::INTERFACE_LIBRARY) {
- std::ostringstream e;
- e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
- this->SetError(e.str());
+ status.SetError(
+ "INTERFACE library may not be used with EXCLUDE_FROM_ALL.");
return false;
}
++s;
@@ -145,9 +132,8 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
++s;
importGlobal = true;
} else if (type == cmStateEnums::INTERFACE_LIBRARY && *s == "GLOBAL") {
- std::ostringstream e;
- e << "GLOBAL option may only be used with IMPORTED libraries.";
- this->SetError(e.str());
+ status.SetError(
+ "GLOBAL option may only be used with IMPORTED libraries.");
return false;
} else {
break;
@@ -156,15 +142,12 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
if (type == cmStateEnums::INTERFACE_LIBRARY) {
if (s != args.end()) {
- std::ostringstream e;
- e << "INTERFACE library requires no source arguments.";
- this->SetError(e.str());
+ status.SetError("INTERFACE library requires no source arguments.");
return false;
}
if (importGlobal && !importTarget) {
- std::ostringstream e;
- e << "INTERFACE library specified as GLOBAL, but not as IMPORTED.";
- this->SetError(e.str());
+ status.SetError(
+ "INTERFACE library specified as GLOBAL, but not as IMPORTED.");
return false;
}
}
@@ -175,73 +158,40 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
if (nameOk && !importTarget && !isAlias) {
nameOk = libName.find(':') == std::string::npos;
}
- if (!nameOk) {
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- std::ostringstream e;
- bool issueMessage = false;
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) {
- case cmPolicies::WARN:
- if (type != cmStateEnums::INTERFACE_LIBRARY) {
- e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
- issueMessage = true;
- }
- case cmPolicies::OLD:
- break;
- case cmPolicies::NEW:
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- issueMessage = true;
- messageType = cmake::FATAL_ERROR;
- }
- if (issueMessage) {
- e << "The target name \"" << libName
- << "\" is reserved or not valid for certain "
- "CMake features, such as generator expressions, and may result "
- "in undefined behavior.";
- this->Makefile->IssueMessage(messageType, e.str());
-
- if (messageType == cmake::FATAL_ERROR) {
- return false;
- }
- }
+ if (!nameOk && !mf.CheckCMP0037(libName, type)) {
+ return false;
}
if (isAlias) {
if (!cmGeneratorExpression::IsValidTargetName(libName)) {
- this->SetError("Invalid name for ALIAS: " + libName);
+ status.SetError("Invalid name for ALIAS: " + libName);
return false;
}
if (excludeFromAll) {
- this->SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense.");
+ status.SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense.");
return false;
}
if (importTarget || importGlobal) {
- this->SetError("IMPORTED with ALIAS is not allowed.");
+ status.SetError("IMPORTED with ALIAS is not allowed.");
return false;
}
if (args.size() != 3) {
- std::ostringstream e;
- e << "ALIAS requires exactly one target argument.";
- this->SetError(e.str());
+ status.SetError("ALIAS requires exactly one target argument.");
return false;
}
- const char* aliasedName = s->c_str();
- if (this->Makefile->IsAlias(aliasedName)) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName << "\" because target \""
- << aliasedName << "\" is itself an ALIAS.";
- this->SetError(e.str());
+ std::string const& aliasedName = *s;
+ if (mf.IsAlias(aliasedName)) {
+ status.SetError(cmStrCat("cannot create ALIAS target \"", libName,
+ "\" because target \"", aliasedName,
+ "\" is itself an ALIAS."));
return false;
}
- cmTarget* aliasedTarget =
- this->Makefile->FindTargetToUse(aliasedName, true);
+ cmTarget* aliasedTarget = mf.FindTargetToUse(aliasedName, true);
if (!aliasedTarget) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName << "\" because target \""
- << aliasedName << "\" does not already "
- "exist.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", libName,
+ "\" because target \"", aliasedName,
+ "\" does not already exist."));
return false;
}
cmStateEnums::TargetType aliasedType = aliasedTarget->GetType();
@@ -249,26 +199,27 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
aliasedType != cmStateEnums::STATIC_LIBRARY &&
aliasedType != cmStateEnums::MODULE_LIBRARY &&
aliasedType != cmStateEnums::OBJECT_LIBRARY &&
- aliasedType != cmStateEnums::INTERFACE_LIBRARY) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName << "\" because target \""
- << aliasedName << "\" is not a library.";
- this->SetError(e.str());
+ aliasedType != cmStateEnums::INTERFACE_LIBRARY &&
+ !(aliasedType == cmStateEnums::UNKNOWN_LIBRARY &&
+ aliasedTarget->IsImported())) {
+ status.SetError(cmStrCat("cannot create ALIAS target \"", libName,
+ "\" because target \"", aliasedName,
+ "\" is not a library."));
return false;
}
- if (aliasedTarget->IsImported()) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName << "\" because target \""
- << aliasedName << "\" is IMPORTED.";
- this->SetError(e.str());
+ if (aliasedTarget->IsImported() &&
+ !aliasedTarget->IsImportedGloballyVisible()) {
+ status.SetError(cmStrCat("cannot create ALIAS target \"", libName,
+ "\" because target \"", aliasedName,
+ "\" is imported but not globally visible."));
return false;
}
- this->Makefile->AddAlias(libName, aliasedName);
+ mf.AddAlias(libName, aliasedName);
return true;
}
if (importTarget && excludeFromAll) {
- this->SetError("excludeFromAll with IMPORTED target makes no sense.");
+ status.SetError("excludeFromAll with IMPORTED target makes no sense.");
return false;
}
@@ -278,14 +229,14 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
yet its linker language. */
if ((type == cmStateEnums::SHARED_LIBRARY ||
type == cmStateEnums::MODULE_LIBRARY) &&
- !this->Makefile->GetState()->GetGlobalPropertyAsBool(
- "TARGET_SUPPORTS_SHARED_LIBS")) {
- std::ostringstream w;
- w << "ADD_LIBRARY called with "
- << (type == cmStateEnums::SHARED_LIBRARY ? "SHARED" : "MODULE")
- << " option but the target platform does not support dynamic linking. "
- "Building a STATIC library instead. This may lead to problems.";
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ !mf.GetState()->GetGlobalPropertyAsBool("TARGET_SUPPORTS_SHARED_LIBS")) {
+ mf.IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(
+ "ADD_LIBRARY called with ",
+ (type == cmStateEnums::SHARED_LIBRARY ? "SHARED" : "MODULE"),
+ " option but the target platform does not support dynamic linking. ",
+ "Building a STATIC library instead. This may lead to problems."));
type = cmStateEnums::STATIC_LIBRARY;
}
@@ -293,15 +244,14 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
if (importTarget) {
// The IMPORTED signature requires a type to be specified explicitly.
if (!haveSpecifiedType) {
- this->SetError("called with IMPORTED argument but no library type.");
+ status.SetError("called with IMPORTED argument but no library type.");
return false;
}
if (type == cmStateEnums::OBJECT_LIBRARY) {
std::string reason;
- if (!this->Makefile->GetGlobalGenerator()->HasKnownObjectFileLocation(
- &reason)) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ if (!mf.GetGlobalGenerator()->HasKnownObjectFileLocation(&reason)) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
"The OBJECT library type may not be used for IMPORTED libraries" +
reason + ".");
return true;
@@ -309,31 +259,29 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
}
if (type == cmStateEnums::INTERFACE_LIBRARY) {
if (!cmGeneratorExpression::IsValidTargetName(libName)) {
- std::ostringstream e;
- e << "Invalid name for IMPORTED INTERFACE library target: " << libName;
- this->SetError(e.str());
+ status.SetError(cmStrCat(
+ "Invalid name for IMPORTED INTERFACE library target: ", libName));
return false;
}
}
// Make sure the target does not already exist.
- if (this->Makefile->FindTargetToUse(libName)) {
- std::ostringstream e;
- e << "cannot create imported target \"" << libName
- << "\" because another target with the same name already exists.";
- this->SetError(e.str());
+ if (mf.FindTargetToUse(libName)) {
+ status.SetError(cmStrCat(
+ "cannot create imported target \"", libName,
+ "\" because another target with the same name already exists."));
return false;
}
// Create the imported target.
- this->Makefile->AddImportedTarget(libName, type, importGlobal);
+ mf.AddImportedTarget(libName, type, importGlobal);
return true;
}
// A non-imported target may not have UNKNOWN type.
if (type == cmStateEnums::UNKNOWN_LIBRARY) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
"The UNKNOWN library type may be used only for IMPORTED libraries.");
return true;
}
@@ -341,8 +289,8 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
// Enforce name uniqueness.
{
std::string msg;
- if (!this->Makefile->EnforceUniqueName(libName, msg)) {
- this->SetError(msg);
+ if (!mf.EnforceUniqueName(libName, msg)) {
+ status.SetError(msg);
return false;
}
}
@@ -352,27 +300,18 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
if (type == cmStateEnums::INTERFACE_LIBRARY) {
if (!cmGeneratorExpression::IsValidTargetName(libName) ||
libName.find("::") != std::string::npos) {
- std::ostringstream e;
- e << "Invalid name for INTERFACE library target: " << libName;
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("Invalid name for INTERFACE library target: ", libName));
return false;
}
- this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll);
+ mf.AddLibrary(libName, type, srclists, excludeFromAll);
return true;
}
- if (s == args.end()) {
- std::string msg = "You have called ADD_LIBRARY for library ";
- msg += args[0];
- msg += " without any source files. This typically indicates a problem ";
- msg += "with your CMakeLists.txt file";
- cmSystemTools::Message(msg.c_str(), "Warning");
- }
-
- srclists.insert(srclists.end(), s, args.end());
+ cmAppend(srclists, s, args.end());
- this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll);
+ mf.AddLibrary(libName, type, srclists, excludeFromAll);
return true;
}
diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h
index df49fae93..609449c87 100644
--- a/Source/cmAddLibraryCommand.h
+++ b/Source/cmAddLibraryCommand.h
@@ -3,35 +3,14 @@
#ifndef cmLibrarysCommand_h
#define cmLibrarysCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmLibrarysCommand
- * \brief Defines a list of executables to build.
- *
- * cmLibrarysCommand defines a list of executable (i.e., test)
- * programs to create.
- */
-class cmAddLibraryCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmAddLibraryCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmAddLibraryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmAddLinkOptionsCommand.cxx b/Source/cmAddLinkOptionsCommand.cxx
new file mode 100644
index 000000000..7ed31bdbc
--- /dev/null
+++ b/Source/cmAddLinkOptionsCommand.cxx
@@ -0,0 +1,16 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmAddLinkOptionsCommand.h"
+
+#include "cmExecutionStatus.h"
+#include "cmMakefile.h"
+
+bool cmAddLinkOptionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ cmMakefile& mf = status.GetMakefile();
+ for (std::string const& i : args) {
+ mf.AddLinkOption(i);
+ }
+ return true;
+}
diff --git a/Source/cmAddLinkOptionsCommand.h b/Source/cmAddLinkOptionsCommand.h
new file mode 100644
index 000000000..466fc3215
--- /dev/null
+++ b/Source/cmAddLinkOptionsCommand.h
@@ -0,0 +1,16 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmAddLinkOptionsCommand_h
+#define cmAddLinkOptionsCommand_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+#include <vector>
+
+class cmExecutionStatus;
+
+bool cmAddLinkOptionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+
+#endif
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx
index 1727ca56f..6a1a514f7 100644
--- a/Source/cmAddSubDirectoryCommand.cxx
+++ b/Source/cmAddSubDirectoryCommand.cxx
@@ -2,41 +2,39 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddSubDirectoryCommand.h"
-#include <sstream>
-#include <string.h>
+#include <cstring>
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
-// cmAddSubDirectoryCommand
-bool cmAddSubDirectoryCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmAddSubDirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
// store the binpath
- std::string const& srcArg = args[0];
+ std::string const& srcArg = args.front();
std::string binArg;
bool excludeFromAll = false;
// process the rest of the arguments looking for optional args
- std::vector<std::string>::const_iterator i = args.begin();
- ++i;
- for (; i != args.end(); ++i) {
- if (*i == "EXCLUDE_FROM_ALL") {
+ for (std::string const& arg : cmMakeRange(args).advance(1)) {
+ if (arg == "EXCLUDE_FROM_ALL") {
excludeFromAll = true;
continue;
}
if (binArg.empty()) {
- binArg = *i;
+ binArg = arg;
} else {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
}
@@ -44,18 +42,15 @@ bool cmAddSubDirectoryCommand::InitialPass(
// Compute the full path to the specified source directory.
// Interpret a relative path with respect to the current source directory.
std::string srcPath;
- if (cmSystemTools::FileIsFullPath(srcArg.c_str())) {
+ if (cmSystemTools::FileIsFullPath(srcArg)) {
srcPath = srcArg;
} else {
- srcPath = this->Makefile->GetCurrentSourceDirectory();
- srcPath += "/";
- srcPath += srcArg;
+ srcPath = cmStrCat(mf.GetCurrentSourceDirectory(), '/', srcArg);
}
if (!cmSystemTools::FileIsDirectory(srcPath)) {
- std::string error = "given source \"";
- error += srcArg;
- error += "\" which is not an existing directory.";
- this->SetError(error);
+ std::string error = cmStrCat("given source \"", srcArg,
+ "\" which is not an existing directory.");
+ status.SetError(error);
return false;
}
srcPath = cmSystemTools::CollapseFullPath(srcPath);
@@ -66,46 +61,44 @@ bool cmAddSubDirectoryCommand::InitialPass(
// No binary directory was specified. If the source directory is
// not a subdirectory of the current directory then it is an
// error.
- if (!cmSystemTools::IsSubDirectory(
- srcPath, this->Makefile->GetCurrentSourceDirectory())) {
- std::ostringstream e;
- e << "not given a binary directory but the given source directory "
- << "\"" << srcPath << "\" is not a subdirectory of \""
- << this->Makefile->GetCurrentSourceDirectory() << "\". "
- << "When specifying an out-of-tree source a binary directory "
- << "must be explicitly specified.";
- this->SetError(e.str());
+ if (!cmSystemTools::IsSubDirectory(srcPath,
+ mf.GetCurrentSourceDirectory())) {
+ status.SetError(
+ cmStrCat("not given a binary directory but the given source ",
+ "directory \"", srcPath, "\" is not a subdirectory of \"",
+ mf.GetCurrentSourceDirectory(),
+ "\". When specifying an "
+ "out-of-tree source a binary directory must be explicitly "
+ "specified."));
return false;
}
// Remove the CurrentDirectory from the srcPath and replace it
// with the CurrentOutputDirectory.
- const char* src = this->Makefile->GetCurrentSourceDirectory();
- const char* bin = this->Makefile->GetCurrentBinaryDirectory();
- size_t srcLen = strlen(src);
- size_t binLen = strlen(bin);
- if (srcLen > 0 && src[srcLen - 1] == '/') {
+ const std::string& src = mf.GetCurrentSourceDirectory();
+ const std::string& bin = mf.GetCurrentBinaryDirectory();
+ size_t srcLen = src.length();
+ size_t binLen = bin.length();
+ if (srcLen > 0 && src.back() == '/') {
--srcLen;
}
- if (binLen > 0 && bin[binLen - 1] == '/') {
+ if (binLen > 0 && bin.back() == '/') {
--binLen;
}
- binPath = std::string(bin, binLen) + srcPath.substr(srcLen);
+ binPath = bin.substr(0, binLen) + srcPath.substr(srcLen);
} else {
// Use the binary directory specified.
// Interpret a relative path with respect to the current binary directory.
- if (cmSystemTools::FileIsFullPath(binArg.c_str())) {
+ if (cmSystemTools::FileIsFullPath(binArg)) {
binPath = binArg;
} else {
- binPath = this->Makefile->GetCurrentBinaryDirectory();
- binPath += "/";
- binPath += binArg;
+ binPath = cmStrCat(mf.GetCurrentBinaryDirectory(), '/', binArg);
}
}
binPath = cmSystemTools::CollapseFullPath(binPath);
// Add the subdirectory using the computed full paths.
- this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, true);
+ mf.AddSubDirectory(srcPath, binPath, excludeFromAll, true);
return true;
}
diff --git a/Source/cmAddSubDirectoryCommand.h b/Source/cmAddSubDirectoryCommand.h
index 0e71ffd85..87da8402b 100644
--- a/Source/cmAddSubDirectoryCommand.h
+++ b/Source/cmAddSubDirectoryCommand.h
@@ -3,36 +3,14 @@
#ifndef cmAddSubDirectoryCommand_h
#define cmAddSubDirectoryCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmAddSubDirectoryCommand
- * \brief Specify a subdirectory to build
- *
- * cmAddSubDirectoryCommand specifies a subdirectory to process
- * by CMake. CMake will descend
- * into the specified source directory and process any CMakeLists.txt found.
- */
-class cmAddSubDirectoryCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmAddSubDirectoryCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmAddSubDirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx
index 3a3afdb05..89421131a 100644
--- a/Source/cmAddTestCommand.cxx
+++ b/Source/cmAddTestCommand.cxx
@@ -2,63 +2,63 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddTestCommand.h"
-#include <sstream>
-
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmTest.h"
#include "cmTestGenerator.h"
-class cmExecutionStatus;
+static bool cmAddTestCommandHandleNameMode(
+ std::vector<std::string> const& args, cmExecutionStatus& status);
-// cmExecutableCommand
-bool cmAddTestCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmAddTestCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (!args.empty() && args[0] == "NAME") {
- return this->HandleNameMode(args);
+ return cmAddTestCommandHandleNameMode(args, status);
}
// First argument is the name of the test Second argument is the name of
// the executable to run (a target or external program) Remaining arguments
// are the arguments to pass to the executable
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
// Collect the command with arguments.
- std::vector<std::string> command;
- command.insert(command.end(), args.begin() + 1, args.end());
+ std::vector<std::string> command(args.begin() + 1, args.end());
// Create the test but add a generator only the first time it is
// seen. This preserves behavior from before test generators.
- cmTest* test = this->Makefile->GetTest(args[0]);
+ cmTest* test = mf.GetTest(args[0]);
if (test) {
// If the test was already added by a new-style signature do not
// allow it to be duplicated.
if (!test->GetOldStyle()) {
- std::ostringstream e;
- e << " given test name \"" << args[0]
- << "\" which already exists in this directory.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(" given test name \"", args[0],
+ "\" which already exists in this directory."));
return false;
}
} else {
- test = this->Makefile->CreateTest(args[0]);
+ test = mf.CreateTest(args[0]);
test->SetOldStyle(true);
- this->Makefile->AddTestGenerator(new cmTestGenerator(test));
+ mf.AddTestGenerator(new cmTestGenerator(test));
}
test->SetCommand(command);
return true;
}
-bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
+bool cmAddTestCommandHandleNameMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
std::string name;
std::vector<std::string> configurations;
std::string working_directory;
std::vector<std::string> command;
+ bool command_expand_lists = false;
// Read the arguments.
enum Doing
@@ -73,22 +73,29 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
for (unsigned int i = 1; i < args.size(); ++i) {
if (args[i] == "COMMAND") {
if (!command.empty()) {
- this->SetError(" may be given at most one COMMAND.");
+ status.SetError(" may be given at most one COMMAND.");
return false;
}
doing = DoingCommand;
} else if (args[i] == "CONFIGURATIONS") {
if (!configurations.empty()) {
- this->SetError(" may be given at most one set of CONFIGURATIONS.");
+ status.SetError(" may be given at most one set of CONFIGURATIONS.");
return false;
}
doing = DoingConfigs;
} else if (args[i] == "WORKING_DIRECTORY") {
if (!working_directory.empty()) {
- this->SetError(" may be given at most one WORKING_DIRECTORY.");
+ status.SetError(" may be given at most one WORKING_DIRECTORY.");
return false;
}
doing = DoingWorkingDirectory;
+ } else if (args[i] == "COMMAND_EXPAND_LISTS") {
+ if (command_expand_lists) {
+ status.SetError(" may be given at most one COMMAND_EXPAND_LISTS.");
+ return false;
+ }
+ command_expand_lists = true;
+ doing = DoingNone;
} else if (doing == DoingName) {
name = args[i];
doing = DoingNone;
@@ -100,42 +107,41 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
working_directory = args[i];
doing = DoingNone;
} else {
- std::ostringstream e;
- e << " given unknown argument:\n " << args[i] << "\n";
- this->SetError(e.str());
+ status.SetError(cmStrCat(" given unknown argument:\n ", args[i], "\n"));
return false;
}
}
// Require a test name.
if (name.empty()) {
- this->SetError(" must be given non-empty NAME.");
+ status.SetError(" must be given non-empty NAME.");
return false;
}
// Require a command.
if (command.empty()) {
- this->SetError(" must be given non-empty COMMAND.");
+ status.SetError(" must be given non-empty COMMAND.");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// Require a unique test name within the directory.
- if (this->Makefile->GetTest(name)) {
- std::ostringstream e;
- e << " given test NAME \"" << name
- << "\" which already exists in this directory.";
- this->SetError(e.str());
+ if (mf.GetTest(name)) {
+ status.SetError(cmStrCat(" given test NAME \"", name,
+ "\" which already exists in this directory."));
return false;
}
// Add the test.
- cmTest* test = this->Makefile->CreateTest(name);
+ cmTest* test = mf.CreateTest(name);
test->SetOldStyle(false);
test->SetCommand(command);
if (!working_directory.empty()) {
test->SetProperty("WORKING_DIRECTORY", working_directory.c_str());
}
- this->Makefile->AddTestGenerator(new cmTestGenerator(test, configurations));
+ test->SetCommandExpandLists(command_expand_lists);
+ mf.AddTestGenerator(new cmTestGenerator(test, configurations));
return true;
}
diff --git a/Source/cmAddTestCommand.h b/Source/cmAddTestCommand.h
index a098a03f1..5877547e8 100644
--- a/Source/cmAddTestCommand.h
+++ b/Source/cmAddTestCommand.h
@@ -3,37 +3,14 @@
#ifndef cmAddTestCommand_h
#define cmAddTestCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmAddTestCommand
- * \brief Add a test to the lists of tests to run.
- *
- * cmAddTestCommand adds a test to the list of tests to run .
- */
-class cmAddTestCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmAddTestCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- bool HandleNameMode(std::vector<std::string> const& args);
-};
+bool cmAddTestCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmAffinity.cxx b/Source/cmAffinity.cxx
new file mode 100644
index 000000000..8f9fe2ad8
--- /dev/null
+++ b/Source/cmAffinity.cxx
@@ -0,0 +1,65 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmAffinity.h"
+
+#include "cm_uv.h"
+
+#ifndef CMAKE_USE_SYSTEM_LIBUV
+# ifdef _WIN32
+# define CM_HAVE_CPU_AFFINITY
+# include <windows.h>
+# elif defined(__linux__) || defined(__FreeBSD__)
+# define CM_HAVE_CPU_AFFINITY
+# include <pthread.h>
+# include <sched.h>
+// On some platforms CPU_ZERO needs memset but sched.h forgets string.h
+# include <cstring> // IWYU pragma: keep
+# if defined(__FreeBSD__)
+# include <pthread_np.h>
+
+# include <sys/cpuset.h>
+# include <sys/param.h>
+# endif
+# if defined(__linux__)
+using cm_cpuset_t = cpu_set_t;
+# else
+using cm_cpuset_t = cpuset_t;
+# endif
+# endif
+#endif
+
+namespace cmAffinity {
+
+std::set<size_t> GetProcessorsAvailable()
+{
+ std::set<size_t> processorsAvailable;
+#ifdef CM_HAVE_CPU_AFFINITY
+ int cpumask_size = uv_cpumask_size();
+ if (cpumask_size > 0) {
+# ifdef _WIN32
+ DWORD_PTR procmask;
+ DWORD_PTR sysmask;
+ if (GetProcessAffinityMask(GetCurrentProcess(), &procmask, &sysmask) !=
+ 0) {
+ for (int i = 0; i < cpumask_size; ++i) {
+ if (procmask & (((DWORD_PTR)1) << i)) {
+ processorsAvailable.insert(i);
+ }
+ }
+ }
+# else
+ cm_cpuset_t cpuset;
+ CPU_ZERO(&cpuset); // NOLINT(clang-tidy)
+ if (pthread_getaffinity_np(pthread_self(), sizeof(cpuset), &cpuset) == 0) {
+ for (int i = 0; i < cpumask_size; ++i) {
+ if (CPU_ISSET(i, &cpuset)) {
+ processorsAvailable.insert(i);
+ }
+ }
+ }
+# endif
+ }
+#endif
+ return processorsAvailable;
+}
+}
diff --git a/Source/cmAffinity.h b/Source/cmAffinity.h
new file mode 100644
index 000000000..3775bae40
--- /dev/null
+++ b/Source/cmAffinity.h
@@ -0,0 +1,12 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#pragma once
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <cstddef>
+#include <set>
+
+namespace cmAffinity {
+
+std::set<size_t> GetProcessorsAvailable();
+}
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 4adfe2328..e0d27eedf 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -5,90 +5,25 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cm_kwiml.h"
#include <algorithm>
#include <functional>
#include <iterator>
-#include <sstream>
-#include <string.h>
-#include <string>
+#include <unordered_set>
#include <utility>
#include <vector>
-inline bool cmHasLiteralPrefixImpl(const std::string& str1, const char* str2,
- size_t N)
-{
- return strncmp(str1.c_str(), str2, N) == 0;
-}
-
-inline bool cmHasLiteralPrefixImpl(const char* str1, const char* str2,
- size_t N)
-{
- return strncmp(str1, str2, N) == 0;
-}
-
-inline bool cmHasLiteralSuffixImpl(const std::string& str1, const char* str2,
- size_t N)
-{
- size_t len = str1.size();
- return len >= N && strcmp(str1.c_str() + len - N, str2) == 0;
-}
-
-inline bool cmHasLiteralSuffixImpl(const char* str1, const char* str2,
- size_t N)
-{
- size_t len = strlen(str1);
- return len >= N && strcmp(str1 + len - N, str2) == 0;
-}
-
-template <typename T, size_t N>
-const T* cmArrayBegin(const T (&a)[N])
-{
- return a;
-}
-template <typename T, size_t N>
-const T* cmArrayEnd(const T (&a)[N])
-{
- return a + N;
-}
-template <typename T, size_t N>
-size_t cmArraySize(const T (&)[N])
-{
- return N;
-}
+#include "cm_kwiml.h"
-template <typename T, size_t N>
-bool cmHasLiteralPrefix(const T& str1, const char (&str2)[N])
-{
- return cmHasLiteralPrefixImpl(str1, str2, N - 1);
-}
+#include "cmRange.h"
-template <typename T, size_t N>
-bool cmHasLiteralSuffix(const T& str1, const char (&str2)[N])
+template <std::size_t N>
+struct cmOverloadPriority : cmOverloadPriority<N - 1>
{
- return cmHasLiteralSuffixImpl(str1, str2, N - 1);
-}
+};
-struct cmStrCmp
+template <>
+struct cmOverloadPriority<0>
{
- cmStrCmp(const char* test)
- : m_test(test)
- {
- }
- cmStrCmp(const std::string& test)
- : m_test(test)
- {
- }
-
- bool operator()(const std::string& input) const { return m_test == input; }
-
- bool operator()(const char* input) const
- {
- return strcmp(input, m_test.c_str()) == 0;
- }
-
-private:
- const std::string m_test;
};
template <typename FwdIt>
@@ -107,6 +42,34 @@ void cmEraseIf(Container& cont, Predicate pred)
cont.erase(std::remove_if(cont.begin(), cont.end(), pred), cont.end());
}
+template <typename Range, typename Key>
+auto cmContainsImpl(Range const& range, Key const& key, cmOverloadPriority<2>)
+ -> decltype(range.exists(key))
+{
+ return range.exists(key);
+}
+
+template <typename Range, typename Key>
+auto cmContainsImpl(Range const& range, Key const& key, cmOverloadPriority<1>)
+ -> decltype(range.find(key) != range.end())
+{
+ return range.find(key) != range.end();
+}
+
+template <typename Range, typename Key>
+bool cmContainsImpl(Range const& range, Key const& key, cmOverloadPriority<0>)
+{
+ using std::begin;
+ using std::end;
+ return std::find(begin(range), end(range), key) != end(range);
+}
+
+template <typename Range, typename Key>
+bool cmContains(Range const& range, Key const& key)
+{
+ return cmContainsImpl(range, key, cmOverloadPriority<2>{});
+}
+
namespace ContainerAlgorithms {
template <typename T>
@@ -119,7 +82,7 @@ struct cmIsPair
};
template <typename K, typename V>
-struct cmIsPair<std::pair<K, V> >
+struct cmIsPair<std::pair<K, V>>
{
enum
{
@@ -154,7 +117,7 @@ FwdIt RemoveN(FwdIt i1, FwdIt i2, size_t n)
template <typename Range>
struct BinarySearcher
{
- typedef typename Range::value_type argument_type;
+ using argument_type = typename Range::value_type;
BinarySearcher(Range const& r)
: m_range(r)
{
@@ -170,56 +133,9 @@ private:
};
}
-template <typename const_iterator_>
-struct cmRange
-{
- typedef const_iterator_ const_iterator;
- typedef typename std::iterator_traits<const_iterator>::value_type value_type;
- typedef typename std::iterator_traits<const_iterator>::difference_type
- difference_type;
- cmRange(const_iterator begin_, const_iterator end_)
- : Begin(begin_)
- , End(end_)
- {
- }
- const_iterator begin() const { return Begin; }
- const_iterator end() const { return End; }
- bool empty() const { return std::distance(Begin, End) == 0; }
- difference_type size() const { return std::distance(Begin, End); }
- cmRange& advance(KWIML_INT_intptr_t amount)
- {
- std::advance(Begin, amount);
- return *this;
- }
-
- cmRange& retreat(KWIML_INT_intptr_t amount)
- {
- std::advance(End, -amount);
- return *this;
- }
-
-private:
- const_iterator Begin;
- const_iterator End;
-};
-
-typedef cmRange<std::vector<std::string>::const_iterator> cmStringRange;
-
class cmListFileBacktrace;
-typedef cmRange<std::vector<cmListFileBacktrace>::const_iterator>
- cmBacktraceRange;
-
-template <typename Iter1, typename Iter2>
-cmRange<Iter1> cmMakeRange(Iter1 begin, Iter2 end)
-{
- return cmRange<Iter1>(begin, end);
-}
-
-template <typename Range>
-cmRange<typename Range::const_iterator> cmMakeRange(Range const& range)
-{
- return cmRange<typename Range::const_iterator>(range.begin(), range.end());
-}
+using cmBacktraceRange =
+ cmRange<std::vector<cmListFileBacktrace>::const_iterator>;
template <typename Range>
void cmDeleteAll(Range const& r)
@@ -228,29 +144,16 @@ void cmDeleteAll(Range const& r)
ContainerAlgorithms::DefaultDeleter<Range>());
}
-template <typename Range>
-std::string cmJoin(Range const& r, const char* delimiter)
+template <typename T, typename Range>
+void cmAppend(std::vector<T>& v, Range const& r)
{
- if (r.empty()) {
- return std::string();
- }
- std::ostringstream os;
- typedef typename Range::value_type ValueType;
- typedef typename Range::const_iterator InputIt;
- const InputIt first = r.begin();
- InputIt last = r.end();
- --last;
- std::copy(first, last, std::ostream_iterator<ValueType>(os, delimiter));
-
- os << *last;
-
- return os.str();
+ v.insert(v.end(), r.begin(), r.end());
}
-template <typename Range>
-std::string cmJoin(Range const& r, std::string const& delimiter)
+template <typename T, typename InputIt>
+void cmAppend(std::vector<T>& v, InputIt first, InputIt last)
{
- return cmJoin(r, delimiter.c_str());
+ v.insert(v.end(), first, last);
}
template <typename Range>
@@ -264,14 +167,14 @@ typename Range::const_iterator cmRemoveIndices(Range& r, InputRange const& rem)
{
typename InputRange::const_iterator remIt = rem.begin();
typename InputRange::const_iterator remEnd = rem.end();
- const typename Range::iterator rangeEnd = r.end();
+ const auto rangeEnd = r.end();
if (remIt == remEnd) {
return rangeEnd;
}
- typename Range::iterator writer = r.begin();
+ auto writer = r.begin();
std::advance(writer, *remIt);
- typename Range::iterator pivot = writer;
+ auto pivot = writer;
typename InputRange::value_type prevRem = *remIt;
++remIt;
size_t count = 1;
@@ -290,116 +193,51 @@ typename Range::const_iterator cmRemoveMatching(Range& r, MatchRange const& m)
ContainerAlgorithms::BinarySearcher<MatchRange>(m));
}
-namespace ContainerAlgorithms {
-
-template <typename Range, typename T = typename Range::value_type>
-struct RemoveDuplicatesAPI
+template <typename ForwardIterator>
+ForwardIterator cmRemoveDuplicates(ForwardIterator first, ForwardIterator last)
{
- typedef typename Range::const_iterator const_iterator;
- typedef typename Range::const_iterator value_type;
-
- static bool lessThan(value_type a, value_type b) { return *a < *b; }
- static value_type uniqueValue(const_iterator a) { return a; }
- template <typename It>
- static bool valueCompare(It it, const_iterator it2)
+ using Value = typename std::iterator_traits<ForwardIterator>::value_type;
+ using Hash = struct
{
- return **it != *it2;
- }
-};
-
-template <typename Range, typename T>
-struct RemoveDuplicatesAPI<Range, T*>
-{
- typedef typename Range::const_iterator const_iterator;
- typedef T* value_type;
+ std::size_t operator()(ForwardIterator it) const
+ {
+ return std::hash<Value>{}(*it);
+ }
+ };
- static bool lessThan(value_type a, value_type b) { return a < b; }
- static value_type uniqueValue(const_iterator a) { return *a; }
- template <typename It>
- static bool valueCompare(It it, const_iterator it2)
+ using Equal = struct
{
- return *it != *it2;
- }
-};
-}
-
-template <typename Range>
-typename Range::const_iterator cmRemoveDuplicates(Range& r)
-{
- typedef typename ContainerAlgorithms::RemoveDuplicatesAPI<Range> API;
- typedef typename API::value_type T;
- std::vector<T> unique;
- unique.reserve(r.size());
- std::vector<size_t> indices;
- size_t count = 0;
- const typename Range::const_iterator end = r.end();
- for (typename Range::const_iterator it = r.begin(); it != end;
- ++it, ++count) {
- const typename std::vector<T>::iterator low = std::lower_bound(
- unique.begin(), unique.end(), API::uniqueValue(it), API::lessThan);
- if (low == unique.end() || API::valueCompare(low, it)) {
- unique.insert(low, API::uniqueValue(it));
- } else {
- indices.push_back(count);
+ bool operator()(ForwardIterator it1, ForwardIterator it2) const
+ {
+ return *it1 == *it2;
}
+ };
+ std::unordered_set<ForwardIterator, Hash, Equal> uniq;
+
+ ForwardIterator result = first;
+ while (first != last) {
+ if (!cmContains(uniq, first)) {
+ if (result != first) {
+ *result = std::move(*first);
+ }
+ uniq.insert(result);
+ ++result;
+ }
+ ++first;
}
- if (indices.empty()) {
- return end;
- }
- return cmRemoveIndices(r, indices);
-}
-
-template <typename Range>
-std::string cmWrap(std::string const& prefix, Range const& r,
- std::string const& suffix, std::string const& sep)
-{
- if (r.empty()) {
- return std::string();
- }
- return prefix + cmJoin(r, suffix + sep + prefix) + suffix;
+ return result;
}
template <typename Range>
-std::string cmWrap(char prefix, Range const& r, char suffix,
- std::string const& sep)
+typename Range::const_iterator cmRemoveDuplicates(Range& r)
{
- return cmWrap(std::string(1, prefix), r, std::string(1, suffix), sep);
+ return cmRemoveDuplicates(r.begin(), r.end());
}
template <typename Range, typename T>
typename Range::const_iterator cmFindNot(Range const& r, T const& t)
{
- return std::find_if(r.begin(), r.end(),
- std::bind1st(std::not_equal_to<T>(), t));
-}
-
-template <typename Range>
-cmRange<typename Range::const_reverse_iterator> cmReverseRange(
- Range const& range)
-{
- return cmRange<typename Range::const_reverse_iterator>(range.rbegin(),
- range.rend());
-}
-
-template <class Iter>
-std::reverse_iterator<Iter> cmMakeReverseIterator(Iter it)
-{
- return std::reverse_iterator<Iter>(it);
-}
-
-inline bool cmHasSuffix(const std::string& str, const std::string& suffix)
-{
- if (str.size() < suffix.size()) {
- return false;
- }
- return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
-}
-
-inline void cmStripSuffixIfExists(std::string& str, const std::string& suffix)
-{
- if (cmHasSuffix(str, suffix)) {
- str.resize(str.size() - suffix.size());
- }
+ return std::find_if(r.begin(), r.end(), [&t](T const& i) { return i != t; });
}
#endif
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index 0f13b114f..e5eea795d 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -2,19 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmArchiveWrite.h"
-#include "cmLocale.h"
-#include "cmSystemTools.h"
-#include "cm_get_date.h"
-#include "cm_libarchive.h"
+#include <cstring>
+#include <ctime>
+#include <iostream>
+#include <sstream>
+
#include "cmsys/Directory.hxx"
#include "cmsys/Encoding.hxx"
#include "cmsys/FStream.hxx"
-#include <iostream>
-#include <string.h>
-#include <time.h>
+
+#include "cm_get_date.h"
+#include "cm_libarchive.h"
+
+#include "cmLocale.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
#ifndef __LA_SSIZE_T
-#define __LA_SSIZE_T la_ssize_t
+# define __LA_SSIZE_T la_ssize_t
#endif
static std::string cm_archive_error_string(struct archive* a)
@@ -53,6 +58,8 @@ public:
{
}
~Entry() { archive_entry_free(this->Object); }
+ Entry(const Entry&) = delete;
+ Entry& operator=(const Entry&) = delete;
operator struct archive_entry*() { return this->Object; }
};
@@ -82,75 +89,94 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c,
switch (c) {
case CompressNone:
if (archive_write_add_filter_none(this->Archive) != ARCHIVE_OK) {
- this->Error = "archive_write_add_filter_none: ";
- this->Error += cm_archive_error_string(this->Archive);
+ this->Error = cmStrCat("archive_write_add_filter_none: ",
+ cm_archive_error_string(this->Archive));
return;
}
break;
case CompressCompress:
if (archive_write_add_filter_compress(this->Archive) != ARCHIVE_OK) {
- this->Error = "archive_write_add_filter_compress: ";
- this->Error += cm_archive_error_string(this->Archive);
+ this->Error = cmStrCat("archive_write_add_filter_compress: ",
+ cm_archive_error_string(this->Archive));
return;
}
break;
- case CompressGZip:
+ case CompressGZip: {
if (archive_write_add_filter_gzip(this->Archive) != ARCHIVE_OK) {
- this->Error = "archive_write_add_filter_gzip: ";
- this->Error += cm_archive_error_string(this->Archive);
+ this->Error = cmStrCat("archive_write_add_filter_gzip: ",
+ cm_archive_error_string(this->Archive));
return;
}
- break;
+ std::string source_date_epoch;
+ cmSystemTools::GetEnv("SOURCE_DATE_EPOCH", source_date_epoch);
+ if (!source_date_epoch.empty()) {
+ // We're not able to specify an arbitrary timestamp for gzip.
+ // The next best thing is to omit the timestamp entirely.
+ if (archive_write_set_filter_option(this->Archive, "gzip", "timestamp",
+ nullptr) != ARCHIVE_OK) {
+ this->Error = cmStrCat("archive_write_set_filter_option: ",
+ cm_archive_error_string(this->Archive));
+ return;
+ }
+ }
+ } break;
case CompressBZip2:
if (archive_write_add_filter_bzip2(this->Archive) != ARCHIVE_OK) {
- this->Error = "archive_write_add_filter_bzip2: ";
- this->Error += cm_archive_error_string(this->Archive);
+ this->Error = cmStrCat("archive_write_add_filter_bzip2: ",
+ cm_archive_error_string(this->Archive));
return;
}
break;
case CompressLZMA:
if (archive_write_add_filter_lzma(this->Archive) != ARCHIVE_OK) {
- this->Error = "archive_write_add_filter_lzma: ";
- this->Error += cm_archive_error_string(this->Archive);
+ this->Error = cmStrCat("archive_write_add_filter_lzma: ",
+ cm_archive_error_string(this->Archive));
return;
}
break;
case CompressXZ:
if (archive_write_add_filter_xz(this->Archive) != ARCHIVE_OK) {
- this->Error = "archive_write_add_filter_xz: ";
- this->Error += cm_archive_error_string(this->Archive);
+ this->Error = cmStrCat("archive_write_add_filter_xz: ",
+ cm_archive_error_string(this->Archive));
return;
}
break;
- };
+ case CompressZstd:
+ if (archive_write_add_filter_zstd(this->Archive) != ARCHIVE_OK) {
+ this->Error = cmStrCat("archive_write_add_filter_zstd: ",
+ cm_archive_error_string(this->Archive));
+ return;
+ }
+ break;
+ }
#if !defined(_WIN32) || defined(__CYGWIN__)
if (archive_read_disk_set_standard_lookup(this->Disk) != ARCHIVE_OK) {
- this->Error = "archive_read_disk_set_standard_lookup: ";
- this->Error += cm_archive_error_string(this->Archive);
+ this->Error = cmStrCat("archive_read_disk_set_standard_lookup: ",
+ cm_archive_error_string(this->Archive));
return;
}
#endif
if (archive_write_set_format_by_name(this->Archive, format.c_str()) !=
ARCHIVE_OK) {
- this->Error = "archive_write_set_format_by_name: ";
- this->Error += cm_archive_error_string(this->Archive);
+ this->Error = cmStrCat("archive_write_set_format_by_name: ",
+ cm_archive_error_string(this->Archive));
return;
}
// do not pad the last block!!
if (archive_write_set_bytes_in_last_block(this->Archive, 1)) {
- this->Error = "archive_write_set_bytes_in_last_block: ";
- this->Error += cm_archive_error_string(this->Archive);
+ this->Error = cmStrCat("archive_write_set_bytes_in_last_block: ",
+ cm_archive_error_string(this->Archive));
return;
}
if (archive_write_open(
- this->Archive, this, CM_NULLPTR,
+ this->Archive, this, nullptr,
reinterpret_cast<archive_write_callback*>(&Callback::Write),
- CM_NULLPTR) != ARCHIVE_OK) {
- this->Error = "archive_write_open: ";
- this->Error += cm_archive_error_string(this->Archive);
+ nullptr) != ARCHIVE_OK) {
+ this->Error =
+ cmStrCat("archive_write_open: ", cm_archive_error_string(this->Archive));
return;
}
}
@@ -164,12 +190,10 @@ cmArchiveWrite::~cmArchiveWrite()
bool cmArchiveWrite::Add(std::string path, size_t skip, const char* prefix,
bool recursive)
{
- if (this->Okay()) {
- if (!path.empty() && path[path.size() - 1] == '/') {
- path.erase(path.size() - 1);
- }
- this->AddPath(path.c_str(), skip, prefix, recursive);
+ if (!path.empty() && path.back() == '/') {
+ path.erase(path.size() - 1);
}
+ this->AddPath(path.c_str(), skip, prefix, recursive);
return this->Okay();
}
@@ -185,8 +209,7 @@ bool cmArchiveWrite::AddPath(const char* path, size_t skip, const char* prefix,
}
cmsys::Directory d;
if (d.Load(path)) {
- std::string next = path;
- next += "/";
+ std::string next = cmStrCat(path, '/');
std::string::size_type end = next.size();
unsigned long n = d.GetNumberOfFiles();
for (unsigned long i = 0; i < n; ++i) {
@@ -205,6 +228,7 @@ bool cmArchiveWrite::AddPath(const char* path, size_t skip, const char* prefix,
bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix)
{
+ this->Error = "";
// Skip the file if we have no name for it. This may happen on a
// top-level directory, which does not need to be included anyway.
if (skip >= strlen(file)) {
@@ -216,20 +240,17 @@ bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix)
static_cast<void>(localeRAII);
// Meta-data.
- std::string dest = prefix ? prefix : "";
- dest += out;
+ std::string dest = cmStrCat(prefix ? prefix : "", out);
if (this->Verbose) {
std::cout << dest << "\n";
}
Entry e;
cm_archive_entry_copy_sourcepath(e, file);
cm_archive_entry_copy_pathname(e, dest);
- if (archive_read_disk_entry_from_file(this->Disk, e, -1, CM_NULLPTR) !=
+ if (archive_read_disk_entry_from_file(this->Disk, e, -1, nullptr) !=
ARCHIVE_OK) {
- this->Error = "archive_read_disk_entry_from_file '";
- this->Error += file;
- this->Error += "': ";
- this->Error += cm_archive_error_string(this->Disk);
+ this->Error = cmStrCat("Unable to read from file '", file,
+ "': ", cm_archive_error_string(this->Disk));
return false;
}
if (!this->MTime.empty()) {
@@ -237,12 +258,21 @@ bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix)
time(&now);
time_t t = cm_get_date(now, this->MTime.c_str());
if (t == -1) {
- this->Error = "unable to parse mtime '";
- this->Error += this->MTime;
- this->Error += "'";
+ this->Error = cmStrCat("unable to parse mtime '", this->MTime, '\'');
return false;
}
archive_entry_set_mtime(e, t, 0);
+ } else {
+ std::string source_date_epoch;
+ cmSystemTools::GetEnv("SOURCE_DATE_EPOCH", source_date_epoch);
+ if (!source_date_epoch.empty()) {
+ std::istringstream iss(source_date_epoch);
+ time_t epochTime;
+ iss >> epochTime;
+ if (iss.eof() && !iss.fail()) {
+ archive_entry_set_mtime(e, epochTime, 0);
+ }
+ }
}
// manages the uid/guid of the entry (if any)
@@ -278,8 +308,8 @@ bool cmArchiveWrite::AddFile(const char* file, size_t skip, const char* prefix)
}
if (archive_write_header(this->Archive, e) != ARCHIVE_OK) {
- this->Error = "archive_write_header: ";
- this->Error += cm_archive_error_string(this->Archive);
+ this->Error = cmStrCat("archive_write_header: ",
+ cm_archive_error_string(this->Archive));
return false;
}
@@ -297,17 +327,15 @@ bool cmArchiveWrite::AddData(const char* file, size_t size)
{
cmsys::ifstream fin(file, std::ios::in | std::ios::binary);
if (!fin) {
- this->Error = "Error opening \"";
- this->Error += file;
- this->Error += "\": ";
- this->Error += cmSystemTools::GetLastSystemError();
+ this->Error = cmStrCat("Error opening \"", file,
+ "\": ", cmSystemTools::GetLastSystemError());
return false;
}
char buffer[16384];
size_t nleft = size;
while (nleft > 0) {
- typedef std::streamsize ssize_type;
+ using ssize_type = std::streamsize;
size_t const nnext = nleft > sizeof(buffer) ? sizeof(buffer) : nleft;
ssize_type const nnext_s = static_cast<ssize_type>(nnext);
fin.read(buffer, nnext_s);
@@ -318,17 +346,15 @@ bool cmArchiveWrite::AddData(const char* file, size_t size)
break;
}
if (archive_write_data(this->Archive, buffer, nnext) != nnext_s) {
- this->Error = "archive_write_data: ";
- this->Error += cm_archive_error_string(this->Archive);
+ this->Error = cmStrCat("archive_write_data: ",
+ cm_archive_error_string(this->Archive));
return false;
}
nleft -= nnext;
}
if (nleft > 0) {
- this->Error = "Error reading \"";
- this->Error += file;
- this->Error += "\": ";
- this->Error += cmSystemTools::GetLastSystemError();
+ this->Error = cmStrCat("Error reading \"", file,
+ "\": ", cmSystemTools::GetLastSystemError());
return false;
}
return true;
diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h
index 4c85c0d16..e791761cb 100644
--- a/Source/cmArchiveWrite.h
+++ b/Source/cmArchiveWrite.h
@@ -5,12 +5,12 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <cstddef>
#include <iosfwd>
-#include <stddef.h>
#include <string>
-#if !defined(CMAKE_BUILD_WITH_CMAKE)
-#error "cmArchiveWrite not allowed during bootstrap build!"
+#if defined(CMAKE_BOOTSTRAP)
+# error "cmArchiveWrite not allowed during bootstrap build!"
#endif
template <typename T>
@@ -28,6 +28,7 @@ public:
void Clear() { this->IsValueSet = false; }
bool IsSet() const { return this->IsValueSet; }
T Get() const { return Value; }
+
private:
T Value;
bool IsValueSet;
@@ -39,8 +40,6 @@ private:
*/
class cmArchiveWrite
{
- typedef void (cmArchiveWrite::*safe_bool)();
- void safe_bool_true() {}
public:
/** Compression type. */
enum Compress
@@ -50,7 +49,8 @@ public:
CompressGZip,
CompressBZip2,
CompressLZMA,
- CompressXZ
+ CompressXZ,
+ CompressZstd
};
/** Construct with output stream to which to write archive. */
@@ -59,6 +59,9 @@ public:
~cmArchiveWrite();
+ cmArchiveWrite(const cmArchiveWrite&) = delete;
+ cmArchiveWrite& operator=(const cmArchiveWrite&) = delete;
+
/**
* Add a path (file or directory) to the archive. Directories are
* added recursively. The "path" must be readable on disk, either
@@ -67,14 +70,11 @@ public:
* skip. The remaining part of the input path is appended to the
* "prefix" value to construct the final name in the archive.
*/
- bool Add(std::string path, size_t skip = 0, const char* prefix = CM_NULLPTR,
+ bool Add(std::string path, size_t skip = 0, const char* prefix = nullptr,
bool recursive = true);
/** Returns true if there has been no error. */
- operator safe_bool() const
- {
- return this->Okay() ? &cmArchiveWrite::safe_bool_true : CM_NULLPTR;
- }
+ explicit operator bool() const { return this->Okay(); }
/** Returns true if there has been an error. */
bool operator!() const { return !this->Okay(); }
diff --git a/Source/cmArgumentParser.cxx b/Source/cmArgumentParser.cxx
new file mode 100644
index 000000000..4c8717749
--- /dev/null
+++ b/Source/cmArgumentParser.cxx
@@ -0,0 +1,97 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmArgumentParser.h"
+
+#include <algorithm>
+#include <type_traits>
+
+namespace ArgumentParser {
+
+auto ActionMap::Emplace(cm::string_view name, Action action)
+ -> std::pair<iterator, bool>
+{
+ auto const it =
+ std::lower_bound(this->begin(), this->end(), name,
+ [](value_type const& elem, cm::string_view const& k) {
+ return elem.first < k;
+ });
+ return (it != this->end() && it->first == name)
+ ? std::make_pair(it, false)
+ : std::make_pair(this->emplace(it, name, std::move(action)), true);
+}
+
+auto ActionMap::Find(cm::string_view name) const -> const_iterator
+{
+ auto const it =
+ std::lower_bound(this->begin(), this->end(), name,
+ [](value_type const& elem, cm::string_view const& k) {
+ return elem.first < k;
+ });
+ return (it != this->end() && it->first == name) ? it : this->end();
+}
+
+void Instance::Bind(bool& val)
+{
+ val = true;
+ this->CurrentString = nullptr;
+ this->CurrentList = nullptr;
+ this->ExpectValue = false;
+}
+
+void Instance::Bind(std::string& val)
+{
+ this->CurrentString = &val;
+ this->CurrentList = nullptr;
+ this->ExpectValue = true;
+}
+
+void Instance::Bind(StringList& val)
+{
+ this->CurrentString = nullptr;
+ this->CurrentList = &val;
+ this->ExpectValue = true;
+}
+
+void Instance::Bind(MultiStringList& val)
+{
+ this->CurrentString = nullptr;
+ this->CurrentList = (static_cast<void>(val.emplace_back()), &val.back());
+ this->ExpectValue = false;
+}
+
+void Instance::Consume(cm::string_view arg, void* result,
+ std::vector<std::string>* unparsedArguments,
+ std::vector<std::string>* keywordsMissingValue,
+ std::vector<std::string>* parsedKeywords)
+{
+ auto const it = this->Bindings.Find(arg);
+ if (it != this->Bindings.end()) {
+ if (parsedKeywords != nullptr) {
+ parsedKeywords->emplace_back(arg);
+ }
+ it->second(*this, result);
+ if (this->ExpectValue && keywordsMissingValue != nullptr) {
+ keywordsMissingValue->emplace_back(arg);
+ }
+ return;
+ }
+
+ if (this->CurrentString != nullptr) {
+ this->CurrentString->assign(std::string(arg));
+ this->CurrentString = nullptr;
+ this->CurrentList = nullptr;
+ } else if (this->CurrentList != nullptr) {
+ this->CurrentList->emplace_back(arg);
+ } else if (unparsedArguments != nullptr) {
+ unparsedArguments->emplace_back(arg);
+ }
+
+ if (this->ExpectValue) {
+ if (keywordsMissingValue != nullptr) {
+ keywordsMissingValue->pop_back();
+ }
+ this->ExpectValue = false;
+ }
+}
+
+} // namespace ArgumentParser
diff --git a/Source/cmArgumentParser.h b/Source/cmArgumentParser.h
new file mode 100644
index 000000000..94265372a
--- /dev/null
+++ b/Source/cmArgumentParser.h
@@ -0,0 +1,151 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmArgumentParser_h
+#define cmArgumentParser_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <cassert>
+#include <functional>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include <cm/string_view>
+
+#include "cm_static_string_view.hxx"
+
+namespace ArgumentParser {
+
+using StringList = std::vector<std::string>;
+using MultiStringList = std::vector<StringList>;
+
+class Instance;
+using Action = std::function<void(Instance&, void*)>;
+
+// using ActionMap = cm::flat_map<cm::string_view, Action>;
+class ActionMap : public std::vector<std::pair<cm::string_view, Action>>
+{
+public:
+ std::pair<iterator, bool> Emplace(cm::string_view name, Action action);
+ const_iterator Find(cm::string_view name) const;
+};
+
+class Instance
+{
+public:
+ Instance(ActionMap const& bindings)
+ : Bindings(bindings)
+ {
+ }
+
+ void Bind(bool& val);
+ void Bind(std::string& val);
+ void Bind(StringList& val);
+ void Bind(MultiStringList& val);
+
+ void Consume(cm::string_view arg, void* result,
+ std::vector<std::string>* unparsedArguments,
+ std::vector<std::string>* keywordsMissingValue,
+ std::vector<std::string>* parsedKeywords);
+
+private:
+ ActionMap const& Bindings;
+ std::string* CurrentString = nullptr;
+ StringList* CurrentList = nullptr;
+ bool ExpectValue = false;
+};
+
+} // namespace ArgumentParser
+
+template <typename Result>
+class cmArgumentParser
+{
+public:
+ // I *think* this function could be made `constexpr` when the code is
+ // compiled as C++20. This would allow building a parser at compile time.
+ template <typename T>
+ cmArgumentParser& Bind(cm::static_string_view name, T Result::*member)
+ {
+ bool const inserted =
+ this->Bindings
+ .Emplace(name,
+ [member](ArgumentParser::Instance& instance, void* result) {
+ instance.Bind(static_cast<Result*>(result)->*member);
+ })
+ .second;
+ assert(inserted), (void)inserted;
+ return *this;
+ }
+
+ template <typename Range>
+ void Parse(Result& result, Range const& args,
+ std::vector<std::string>* unparsedArguments = nullptr,
+ std::vector<std::string>* keywordsMissingValue = nullptr,
+ std::vector<std::string>* parsedKeywords = nullptr) const
+ {
+ ArgumentParser::Instance instance(this->Bindings);
+ for (cm::string_view arg : args) {
+ instance.Consume(arg, &result, unparsedArguments, keywordsMissingValue,
+ parsedKeywords);
+ }
+ }
+
+ template <typename Range>
+ Result Parse(Range const& args,
+ std::vector<std::string>* unparsedArguments = nullptr,
+ std::vector<std::string>* keywordsMissingValue = nullptr,
+ std::vector<std::string>* parsedKeywords = nullptr) const
+ {
+ Result result;
+ this->Parse(result, args, unparsedArguments, keywordsMissingValue,
+ parsedKeywords);
+ return result;
+ }
+
+private:
+ ArgumentParser::ActionMap Bindings;
+};
+
+template <>
+class cmArgumentParser<void>
+{
+public:
+ template <typename T>
+ cmArgumentParser& Bind(cm::static_string_view name, T& ref)
+ {
+ bool const inserted = this->Bind(cm::string_view(name), ref);
+ assert(inserted), (void)inserted;
+ return *this;
+ }
+
+ template <typename Range>
+ void Parse(Range const& args,
+ std::vector<std::string>* unparsedArguments = nullptr,
+ std::vector<std::string>* keywordsMissingValue = nullptr,
+ std::vector<std::string>* parsedKeywords = nullptr) const
+ {
+ ArgumentParser::Instance instance(this->Bindings);
+ for (cm::string_view arg : args) {
+ instance.Consume(arg, nullptr, unparsedArguments, keywordsMissingValue,
+ parsedKeywords);
+ }
+ }
+
+protected:
+ template <typename T>
+ bool Bind(cm::string_view name, T& ref)
+ {
+ return this->Bindings
+ .Emplace(name,
+ [&ref](ArgumentParser::Instance& instance, void*) {
+ instance.Bind(ref);
+ })
+ .second;
+ }
+
+private:
+ ArgumentParser::ActionMap Bindings;
+};
+
+#endif
diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx
index 847a41660..289bb7217 100644
--- a/Source/cmAuxSourceDirectoryCommand.cxx
+++ b/Source/cmAuxSourceDirectoryCommand.cxx
@@ -2,40 +2,39 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAuxSourceDirectoryCommand.h"
-#include "cmsys/Directory.hxx"
#include <algorithm>
-#include <stddef.h>
+#include <cstddef>
+#include <utility>
+
+#include "cmsys/Directory.hxx"
-#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
-class cmExecutionStatus;
-
-// cmAuxSourceDirectoryCommand
-bool cmAuxSourceDirectoryCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmAuxSourceDirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
std::string sourceListValue;
std::string const& templateDirectory = args[0];
std::string tdir;
- if (!cmSystemTools::FileIsFullPath(templateDirectory.c_str())) {
- tdir = this->Makefile->GetCurrentSourceDirectory();
- tdir += "/";
- tdir += templateDirectory;
+ if (!cmSystemTools::FileIsFullPath(templateDirectory)) {
+ tdir = cmStrCat(mf.GetCurrentSourceDirectory(), '/', templateDirectory);
} else {
tdir = templateDirectory;
}
// was the list already populated
- const char* def = this->Makefile->GetDefinition(args[1]);
+ const char* def = mf.GetDefinition(args[1]);
if (def) {
sourceListValue = def;
}
@@ -54,18 +53,14 @@ bool cmAuxSourceDirectoryCommand::InitialPass(
std::string ext = file.substr(dotpos + 1);
std::string base = file.substr(0, dotpos);
// Process only source files
- std::vector<std::string> const& srcExts =
- this->Makefile->GetCMakeInstance()->GetSourceExtensions();
- if (!base.empty() &&
- std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end()) {
- std::string fullname = templateDirectory;
- fullname += "/";
- fullname += file;
+ auto cm = mf.GetCMakeInstance();
+ if (!base.empty() && cm->IsSourceExtension(ext)) {
+ std::string fullname = cmStrCat(templateDirectory, '/', file);
// add the file as a class file so
// depends can be done
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(fullname);
+ cmSourceFile* sf = mf.GetOrCreateSource(fullname);
sf->SetProperty("ABSTRACT", "0");
- files.push_back(fullname);
+ files.push_back(std::move(fullname));
}
}
}
@@ -75,6 +70,6 @@ bool cmAuxSourceDirectoryCommand::InitialPass(
sourceListValue += ";";
}
sourceListValue += cmJoin(files, ";");
- this->Makefile->AddDefinition(args[1], sourceListValue.c_str());
+ mf.AddDefinition(args[1], sourceListValue);
return true;
}
diff --git a/Source/cmAuxSourceDirectoryCommand.h b/Source/cmAuxSourceDirectoryCommand.h
index e49e86117..ae2609205 100644
--- a/Source/cmAuxSourceDirectoryCommand.h
+++ b/Source/cmAuxSourceDirectoryCommand.h
@@ -3,38 +3,14 @@
#ifndef cmAuxSourceDirectoryCommand_h
#define cmAuxSourceDirectoryCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmAuxSourceDirectoryCommand
- * \brief Specify auxiliary source code directories.
- *
- * cmAuxSourceDirectoryCommand specifies source code directories
- * that must be built as part of this build process. This directories
- * are not recursively processed like the SUBDIR command (cmSubdirCommand).
- * A side effect of this command is to create a subdirectory in the build
- * directory structure.
- */
-class cmAuxSourceDirectoryCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmAuxSourceDirectoryCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmAuxSourceDirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmBase32.cxx b/Source/cmBase32.cxx
index 1dac212c2..80ada4766 100644
--- a/Source/cmBase32.cxx
+++ b/Source/cmBase32.cxx
@@ -34,13 +34,9 @@ void Base32Encode5(const unsigned char src[5], char dst[8])
// -- Class methods
-cmBase32Encoder::cmBase32Encoder()
-{
-}
+cmBase32Encoder::cmBase32Encoder() = default;
-cmBase32Encoder::~cmBase32Encoder()
-{
-}
+cmBase32Encoder::~cmBase32Encoder() = default;
std::string cmBase32Encoder::encodeString(const unsigned char* input,
size_t len, bool padding)
diff --git a/Source/cmBase32.h b/Source/cmBase32.h
index c6758d4f3..d85198dd5 100644
--- a/Source/cmBase32.h
+++ b/Source/cmBase32.h
@@ -5,7 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <stddef.h>
+#include <cstddef>
#include <string>
/** \class cmBase32Encoder
diff --git a/Source/cmBinUtilsLinker.cxx b/Source/cmBinUtilsLinker.cxx
new file mode 100644
index 000000000..a9f4d91fc
--- /dev/null
+++ b/Source/cmBinUtilsLinker.cxx
@@ -0,0 +1,16 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmBinUtilsLinker.h"
+
+#include "cmRuntimeDependencyArchive.h"
+
+cmBinUtilsLinker::cmBinUtilsLinker(cmRuntimeDependencyArchive* archive)
+ : Archive(archive)
+{
+}
+
+void cmBinUtilsLinker::SetError(const std::string& e)
+{
+ this->Archive->SetError(e);
+}
diff --git a/Source/cmBinUtilsLinker.h b/Source/cmBinUtilsLinker.h
new file mode 100644
index 000000000..78d517b61
--- /dev/null
+++ b/Source/cmBinUtilsLinker.h
@@ -0,0 +1,30 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmBinUtilsLinker_h
+#define cmBinUtilsLinker_h
+
+#include <string>
+
+#include "cmStateTypes.h"
+
+class cmRuntimeDependencyArchive;
+
+class cmBinUtilsLinker
+{
+public:
+ cmBinUtilsLinker(cmRuntimeDependencyArchive* archive);
+ virtual ~cmBinUtilsLinker() = default;
+
+ virtual bool Prepare() { return true; }
+
+ virtual bool ScanDependencies(std::string const& file,
+ cmStateEnums::TargetType type) = 0;
+
+protected:
+ cmRuntimeDependencyArchive* Archive;
+
+ void SetError(const std::string& e);
+};
+
+#endif // cmBinUtilsLinker_h
diff --git a/Source/cmBinUtilsLinuxELFGetRuntimeDependenciesTool.cxx b/Source/cmBinUtilsLinuxELFGetRuntimeDependenciesTool.cxx
new file mode 100644
index 000000000..abd12092c
--- /dev/null
+++ b/Source/cmBinUtilsLinuxELFGetRuntimeDependenciesTool.cxx
@@ -0,0 +1,19 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmBinUtilsLinuxELFGetRuntimeDependenciesTool.h"
+
+#include "cmRuntimeDependencyArchive.h"
+
+cmBinUtilsLinuxELFGetRuntimeDependenciesTool::
+ cmBinUtilsLinuxELFGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive)
+ : Archive(archive)
+{
+}
+
+void cmBinUtilsLinuxELFGetRuntimeDependenciesTool::SetError(
+ const std::string& error)
+{
+ this->Archive->SetError(error);
+}
diff --git a/Source/cmBinUtilsLinuxELFGetRuntimeDependenciesTool.h b/Source/cmBinUtilsLinuxELFGetRuntimeDependenciesTool.h
new file mode 100644
index 000000000..d514e7f91
--- /dev/null
+++ b/Source/cmBinUtilsLinuxELFGetRuntimeDependenciesTool.h
@@ -0,0 +1,30 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmBinUtilsLinuxELFGetRuntimeDependenciesTool_h
+#define cmBinUtilsLinuxELFGetRuntimeDependenciesTool_h
+
+#include <string>
+#include <vector>
+
+class cmRuntimeDependencyArchive;
+
+class cmBinUtilsLinuxELFGetRuntimeDependenciesTool
+{
+public:
+ cmBinUtilsLinuxELFGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive);
+ virtual ~cmBinUtilsLinuxELFGetRuntimeDependenciesTool() = default;
+
+ virtual bool GetFileInfo(std::string const& file,
+ std::vector<std::string>& needed,
+ std::vector<std::string>& rpaths,
+ std::vector<std::string>& runpaths) = 0;
+
+protected:
+ cmRuntimeDependencyArchive* Archive;
+
+ void SetError(const std::string& e);
+};
+
+#endif // cmBinUtilsLinuxELFGetRuntimeDependenciesTool_h
diff --git a/Source/cmBinUtilsLinuxELFLinker.cxx b/Source/cmBinUtilsLinuxELFLinker.cxx
new file mode 100644
index 000000000..0dea8256c
--- /dev/null
+++ b/Source/cmBinUtilsLinuxELFLinker.cxx
@@ -0,0 +1,179 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmBinUtilsLinuxELFLinker.h"
+
+#include <sstream>
+
+#include <cm/memory>
+
+#include <cmsys/RegularExpression.hxx>
+
+#include "cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.h"
+#include "cmLDConfigLDConfigTool.h"
+#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmRuntimeDependencyArchive.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+static std::string ReplaceOrigin(const std::string& rpath,
+ const std::string& origin)
+{
+ static const cmsys::RegularExpression originRegex(
+ "(\\$ORIGIN)([^a-zA-Z0-9_]|$)");
+ static const cmsys::RegularExpression originCurlyRegex("\\${ORIGIN}");
+
+ cmsys::RegularExpressionMatch match;
+ if (originRegex.find(rpath.c_str(), match)) {
+ std::string begin = rpath.substr(0, match.start(1));
+ std::string end = rpath.substr(match.end(1));
+ return begin + origin + end;
+ }
+ if (originCurlyRegex.find(rpath.c_str(), match)) {
+ std::string begin = rpath.substr(0, match.start());
+ std::string end = rpath.substr(match.end());
+ return begin + origin + end;
+ }
+ return rpath;
+}
+
+cmBinUtilsLinuxELFLinker::cmBinUtilsLinuxELFLinker(
+ cmRuntimeDependencyArchive* archive)
+ : cmBinUtilsLinker(archive)
+{
+}
+
+bool cmBinUtilsLinuxELFLinker::Prepare()
+{
+ std::string tool = this->Archive->GetGetRuntimeDependenciesTool();
+ if (tool.empty()) {
+ tool = "objdump";
+ }
+ if (tool == "objdump") {
+ this->Tool =
+ cm::make_unique<cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool>(
+ this->Archive);
+ } else {
+ std::ostringstream e;
+ e << "Invalid value for CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: " << tool;
+ this->SetError(e.str());
+ return false;
+ }
+
+ std::string ldConfigTool =
+ this->Archive->GetMakefile()->GetSafeDefinition("CMAKE_LDCONFIG_TOOL");
+ if (ldConfigTool.empty()) {
+ ldConfigTool = "ldconfig";
+ }
+ if (ldConfigTool == "ldconfig") {
+ this->LDConfigTool =
+ cm::make_unique<cmLDConfigLDConfigTool>(this->Archive);
+ } else {
+ std::ostringstream e;
+ e << "Invalid value for CMAKE_LDCONFIG_TOOL: " << ldConfigTool;
+ this->SetError(e.str());
+ return false;
+ }
+
+ return true;
+}
+
+bool cmBinUtilsLinuxELFLinker::ScanDependencies(
+ std::string const& file, cmStateEnums::TargetType /* unused */)
+{
+ std::vector<std::string> parentRpaths;
+ return this->ScanDependencies(file, parentRpaths);
+}
+
+bool cmBinUtilsLinuxELFLinker::ScanDependencies(
+ std::string const& file, std::vector<std::string> const& parentRpaths)
+{
+ std::string origin = cmSystemTools::GetFilenamePath(file);
+ std::vector<std::string> needed;
+ std::vector<std::string> rpaths;
+ std::vector<std::string> runpaths;
+ if (!this->Tool->GetFileInfo(file, needed, rpaths, runpaths)) {
+ return false;
+ }
+ for (auto& runpath : runpaths) {
+ runpath = ReplaceOrigin(runpath, origin);
+ }
+ for (auto& rpath : rpaths) {
+ rpath = ReplaceOrigin(rpath, origin);
+ }
+
+ std::vector<std::string> searchPaths;
+ if (!runpaths.empty()) {
+ searchPaths = runpaths;
+ } else {
+ searchPaths = rpaths;
+ searchPaths.insert(searchPaths.end(), parentRpaths.begin(),
+ parentRpaths.end());
+ }
+
+ std::vector<std::string> ldConfigPaths;
+ if (!this->LDConfigTool->GetLDConfigPaths(ldConfigPaths)) {
+ return false;
+ }
+ searchPaths.insert(searchPaths.end(), ldConfigPaths.begin(),
+ ldConfigPaths.end());
+
+ for (auto const& dep : needed) {
+ if (!this->Archive->IsPreExcluded(dep)) {
+ std::string path;
+ bool resolved = false;
+ if (dep.find('/') != std::string::npos) {
+ this->SetError("Paths to dependencies are not supported");
+ return false;
+ }
+ if (!this->ResolveDependency(dep, searchPaths, path, resolved)) {
+ return false;
+ }
+ if (resolved) {
+ if (!this->Archive->IsPostExcluded(path)) {
+ bool unique;
+ this->Archive->AddResolvedPath(dep, path, unique);
+ if (unique && !this->ScanDependencies(path, rpaths)) {
+ return false;
+ }
+ }
+ } else {
+ this->Archive->AddUnresolvedPath(dep);
+ }
+ }
+ }
+
+ return true;
+}
+
+bool cmBinUtilsLinuxELFLinker::ResolveDependency(
+ std::string const& name, std::vector<std::string> const& searchPaths,
+ std::string& path, bool& resolved)
+{
+ for (auto const& searchPath : searchPaths) {
+ path = cmStrCat(searchPath, '/', name);
+ if (cmSystemTools::PathExists(path)) {
+ resolved = true;
+ return true;
+ }
+ }
+
+ for (auto const& searchPath : this->Archive->GetSearchDirectories()) {
+ path = cmStrCat(searchPath, '/', name);
+ if (cmSystemTools::PathExists(path)) {
+ std::ostringstream warning;
+ warning << "Dependency " << name << " found in search directory:\n "
+ << searchPath
+ << "\nSee file(GET_RUNTIME_DEPENDENCIES) documentation for "
+ << "more information.";
+ this->Archive->GetMakefile()->IssueMessage(MessageType::WARNING,
+ warning.str());
+ resolved = true;
+ return true;
+ }
+ }
+
+ resolved = false;
+ return true;
+}
diff --git a/Source/cmBinUtilsLinuxELFLinker.h b/Source/cmBinUtilsLinuxELFLinker.h
new file mode 100644
index 000000000..b17df11ee
--- /dev/null
+++ b/Source/cmBinUtilsLinuxELFLinker.h
@@ -0,0 +1,44 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmBinUtilsLinuxELFLinker_h
+#define cmBinUtilsLinuxELFLinker_h
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "cmBinUtilsLinker.h"
+#include "cmBinUtilsLinuxELFGetRuntimeDependenciesTool.h"
+#include "cmLDConfigTool.h"
+#include "cmStateTypes.h"
+
+class cmRuntimeDependencyArchive;
+
+class cmBinUtilsLinuxELFLinker : public cmBinUtilsLinker
+{
+public:
+ cmBinUtilsLinuxELFLinker(cmRuntimeDependencyArchive* archive);
+
+ bool Prepare() override;
+
+ bool ScanDependencies(std::string const& file,
+ cmStateEnums::TargetType type) override;
+
+private:
+ std::unique_ptr<cmBinUtilsLinuxELFGetRuntimeDependenciesTool> Tool;
+ std::unique_ptr<cmLDConfigTool> LDConfigTool;
+ bool HaveLDConfigPaths = false;
+ std::vector<std::string> LDConfigPaths;
+
+ bool ScanDependencies(std::string const& file,
+ std::vector<std::string> const& parentRpaths);
+
+ bool ResolveDependency(std::string const& name,
+ std::vector<std::string> const& searchPaths,
+ std::string& path, bool& resolved);
+
+ bool GetLDConfigPaths();
+};
+
+#endif // cmBinUtilsLinuxELFLinker_h
diff --git a/Source/cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.cxx b/Source/cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.cxx
new file mode 100644
index 000000000..566e4a488
--- /dev/null
+++ b/Source/cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.cxx
@@ -0,0 +1,85 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.h"
+
+#include <sstream>
+
+#include <cmsys/RegularExpression.hxx>
+
+#include "cmRuntimeDependencyArchive.h"
+#include "cmSystemTools.h"
+#include "cmUVProcessChain.h"
+
+cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool::
+ cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive)
+ : cmBinUtilsLinuxELFGetRuntimeDependenciesTool(archive)
+{
+}
+
+bool cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool::GetFileInfo(
+ std::string const& file, std::vector<std::string>& needed,
+ std::vector<std::string>& rpaths, std::vector<std::string>& runpaths)
+{
+ cmUVProcessChainBuilder builder;
+ builder.SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT);
+
+ std::vector<std::string> command;
+ if (!this->Archive->GetGetRuntimeDependenciesCommand("objdump", command)) {
+ this->SetError("Could not find objdump");
+ return false;
+ }
+ command.emplace_back("-p");
+ command.push_back(file);
+ builder.AddCommand(command);
+
+ auto process = builder.Start();
+ if (!process.Valid()) {
+ std::ostringstream e;
+ e << "Failed to start objdump process for:\n " << file;
+ this->SetError(e.str());
+ return false;
+ }
+
+ std::string line;
+ static const cmsys::RegularExpression neededRegex("^ *NEEDED *([^\n]*)$");
+ static const cmsys::RegularExpression rpathRegex("^ *RPATH *([^\n]*)$");
+ static const cmsys::RegularExpression runpathRegex("^ *RUNPATH *([^\n]*)$");
+ while (std::getline(*process.OutputStream(), line)) {
+ cmsys::RegularExpressionMatch match;
+ if (neededRegex.find(line.c_str(), match)) {
+ needed.push_back(match.match(1));
+ } else if (rpathRegex.find(line.c_str(), match)) {
+ std::vector<std::string> rpathSplit =
+ cmSystemTools::SplitString(match.match(1), ':');
+ rpaths.reserve(rpaths.size() + rpathSplit.size());
+ for (auto const& rpath : rpathSplit) {
+ rpaths.push_back(rpath);
+ }
+ } else if (runpathRegex.find(line.c_str(), match)) {
+ std::vector<std::string> runpathSplit =
+ cmSystemTools::SplitString(match.match(1), ':');
+ runpaths.reserve(runpaths.size() + runpathSplit.size());
+ for (auto const& runpath : runpathSplit) {
+ runpaths.push_back(runpath);
+ }
+ }
+ }
+
+ if (!process.Wait()) {
+ std::ostringstream e;
+ e << "Failed to wait on objdump process for:\n " << file;
+ this->SetError(e.str());
+ return false;
+ }
+ auto status = process.GetStatus();
+ if (!status[0] || status[0]->ExitStatus != 0) {
+ std::ostringstream e;
+ e << "Failed to run objdump on:\n " << file;
+ this->SetError(e.str());
+ return false;
+ }
+
+ return true;
+}
diff --git a/Source/cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.h b/Source/cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.h
new file mode 100644
index 000000000..969e4d4dc
--- /dev/null
+++ b/Source/cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool.h
@@ -0,0 +1,26 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmBinUtilsLinuxELFGetRuntimeCollectDependenciesTool_h
+#define cmBinUtilsLinuxELFGetRuntimeCollectDependenciesTool_h
+
+#include <string>
+#include <vector>
+
+#include "cmBinUtilsLinuxELFGetRuntimeDependenciesTool.h"
+
+class cmRuntimeDependencyArchive;
+
+class cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool
+ : public cmBinUtilsLinuxELFGetRuntimeDependenciesTool
+{
+public:
+ cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive);
+
+ bool GetFileInfo(std::string const& file, std::vector<std::string>& needed,
+ std::vector<std::string>& rpaths,
+ std::vector<std::string>& runpaths) override;
+};
+
+#endif // cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool_h
diff --git a/Source/cmBinUtilsMacOSMachOGetRuntimeDependenciesTool.cxx b/Source/cmBinUtilsMacOSMachOGetRuntimeDependenciesTool.cxx
new file mode 100644
index 000000000..a296a474c
--- /dev/null
+++ b/Source/cmBinUtilsMacOSMachOGetRuntimeDependenciesTool.cxx
@@ -0,0 +1,19 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmBinUtilsMacOSMachOGetRuntimeDependenciesTool.h"
+
+#include "cmRuntimeDependencyArchive.h"
+
+cmBinUtilsMacOSMachOGetRuntimeDependenciesTool::
+ cmBinUtilsMacOSMachOGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive)
+ : Archive(archive)
+{
+}
+
+void cmBinUtilsMacOSMachOGetRuntimeDependenciesTool::SetError(
+ const std::string& error)
+{
+ this->Archive->SetError(error);
+}
diff --git a/Source/cmBinUtilsMacOSMachOGetRuntimeDependenciesTool.h b/Source/cmBinUtilsMacOSMachOGetRuntimeDependenciesTool.h
new file mode 100644
index 000000000..dbb288255
--- /dev/null
+++ b/Source/cmBinUtilsMacOSMachOGetRuntimeDependenciesTool.h
@@ -0,0 +1,29 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmBinUtilsMacOSMachOGetRuntimeDependenciesTool_h
+#define cmBinUtilsMacOSMachOGetRuntimeDependenciesTool_h
+
+#include <string>
+#include <vector>
+
+class cmRuntimeDependencyArchive;
+
+class cmBinUtilsMacOSMachOGetRuntimeDependenciesTool
+{
+public:
+ cmBinUtilsMacOSMachOGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive);
+ virtual ~cmBinUtilsMacOSMachOGetRuntimeDependenciesTool() = default;
+
+ virtual bool GetFileInfo(std::string const& file,
+ std::vector<std::string>& libs,
+ std::vector<std::string>& rpaths) = 0;
+
+protected:
+ cmRuntimeDependencyArchive* Archive;
+
+ void SetError(const std::string& error);
+};
+
+#endif // cmBinUtilsMacOSMachOGetRuntimeDependenciesTool_h
diff --git a/Source/cmBinUtilsMacOSMachOLinker.cxx b/Source/cmBinUtilsMacOSMachOLinker.cxx
new file mode 100644
index 000000000..98250b1c0
--- /dev/null
+++ b/Source/cmBinUtilsMacOSMachOLinker.cxx
@@ -0,0 +1,231 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmBinUtilsMacOSMachOLinker.h"
+
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include <cm/memory>
+
+#include "cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.h"
+#include "cmRuntimeDependencyArchive.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+cmBinUtilsMacOSMachOLinker::cmBinUtilsMacOSMachOLinker(
+ cmRuntimeDependencyArchive* archive)
+ : cmBinUtilsLinker(archive)
+{
+}
+
+bool cmBinUtilsMacOSMachOLinker::Prepare()
+{
+ std::string tool = this->Archive->GetGetRuntimeDependenciesTool();
+ if (tool.empty()) {
+ tool = "otool";
+ }
+ if (tool == "otool") {
+ this->Tool =
+ cm::make_unique<cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool>(
+ this->Archive);
+ } else {
+ std::ostringstream e;
+ e << "Invalid value for CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: " << tool;
+ this->SetError(e.str());
+ return false;
+ }
+
+ return true;
+}
+
+bool cmBinUtilsMacOSMachOLinker::ScanDependencies(
+ std::string const& file, cmStateEnums::TargetType type)
+{
+ std::string executableFile;
+ if (type == cmStateEnums::EXECUTABLE) {
+ executableFile = file;
+ } else {
+ executableFile = this->Archive->GetBundleExecutable();
+ }
+ std::string executablePath;
+ if (!executableFile.empty()) {
+ executablePath = cmSystemTools::GetFilenamePath(executableFile);
+ }
+ return this->ScanDependencies(file, executablePath);
+}
+
+bool cmBinUtilsMacOSMachOLinker::ScanDependencies(
+ std::string const& file, std::string const& executablePath)
+{
+ std::vector<std::string> libs;
+ std::vector<std::string> rpaths;
+ if (!this->Tool->GetFileInfo(file, libs, rpaths)) {
+ return false;
+ }
+
+ std::string loaderPath = cmSystemTools::GetFilenamePath(file);
+ return this->GetFileDependencies(libs, executablePath, loaderPath, rpaths);
+}
+
+bool cmBinUtilsMacOSMachOLinker::GetFileDependencies(
+ std::vector<std::string> const& names, std::string const& executablePath,
+ std::string const& loaderPath, std::vector<std::string> const& rpaths)
+{
+ for (std::string const& name : names) {
+ if (!this->Archive->IsPreExcluded(name)) {
+ std::string path;
+ bool resolved;
+ if (!this->ResolveDependency(name, executablePath, loaderPath, rpaths,
+ path, resolved)) {
+ return false;
+ }
+ if (resolved) {
+ if (!this->Archive->IsPostExcluded(path)) {
+ auto filename = cmSystemTools::GetFilenameName(path);
+ bool unique;
+ this->Archive->AddResolvedPath(filename, path, unique);
+ if (unique && !this->ScanDependencies(path, executablePath)) {
+ return false;
+ }
+ }
+ } else {
+ this->Archive->AddUnresolvedPath(name);
+ }
+ }
+ }
+
+ return true;
+}
+
+bool cmBinUtilsMacOSMachOLinker::ResolveDependency(
+ std::string const& name, std::string const& executablePath,
+ std::string const& loaderPath, std::vector<std::string> const& rpaths,
+ std::string& path, bool& resolved)
+{
+ resolved = false;
+ if (cmHasLiteralPrefix(name, "@rpath/")) {
+ if (!this->ResolveRPathDependency(name, executablePath, loaderPath, rpaths,
+ path, resolved)) {
+ return false;
+ }
+ } else if (cmHasLiteralPrefix(name, "@loader_path/")) {
+ if (!this->ResolveLoaderPathDependency(name, loaderPath, path, resolved)) {
+ return false;
+ }
+ } else if (cmHasLiteralPrefix(name, "@executable_path/")) {
+ if (!this->ResolveExecutablePathDependency(name, executablePath, path,
+ resolved)) {
+ return false;
+ }
+ } else {
+ resolved = true;
+ path = name;
+ }
+
+ if (resolved && !cmSystemTools::FileIsFullPath(path)) {
+ this->SetError("Resolved path is not absolute");
+ return false;
+ }
+
+ return true;
+}
+
+bool cmBinUtilsMacOSMachOLinker::ResolveExecutablePathDependency(
+ std::string const& name, std::string const& executablePath,
+ std::string& path, bool& resolved)
+{
+ if (executablePath.empty()) {
+ resolved = false;
+ return true;
+ }
+
+ // 16 is == "@executable_path".length()
+ path = name;
+ path.replace(0, 16, executablePath);
+
+ if (!cmSystemTools::PathExists(path)) {
+ resolved = false;
+ return true;
+ }
+
+ resolved = true;
+ return true;
+}
+
+bool cmBinUtilsMacOSMachOLinker::ResolveLoaderPathDependency(
+ std::string const& name, std::string const& loaderPath, std::string& path,
+ bool& resolved)
+{
+ if (loaderPath.empty()) {
+ resolved = false;
+ return true;
+ }
+
+ // 12 is "@loader_path".length();
+ path = name;
+ path.replace(0, 12, loaderPath);
+
+ if (!cmSystemTools::PathExists(path)) {
+ resolved = false;
+ return true;
+ }
+
+ resolved = true;
+ return true;
+}
+
+bool cmBinUtilsMacOSMachOLinker::ResolveRPathDependency(
+ std::string const& name, std::string const& executablePath,
+ std::string const& loaderPath, std::vector<std::string> const& rpaths,
+ std::string& path, bool& resolved)
+{
+ for (std::string const& rpath : rpaths) {
+ std::string searchFile = name;
+ searchFile.replace(0, 6, rpath);
+ if (cmHasLiteralPrefix(searchFile, "@loader_path/")) {
+ if (!this->ResolveLoaderPathDependency(searchFile, loaderPath, path,
+ resolved)) {
+ return false;
+ }
+ if (resolved) {
+ return true;
+ }
+ } else if (cmHasLiteralPrefix(searchFile, "@executable_path/")) {
+ if (!this->ResolveExecutablePathDependency(searchFile, executablePath,
+ path, resolved)) {
+ return false;
+ }
+ if (resolved) {
+ return true;
+ }
+ } else if (cmSystemTools::PathExists(searchFile)) {
+ /*
+ * paraphrasing @ben.boeckel:
+ * if /b/libB.dylib is supposed to be used,
+ * /a/libbB.dylib will be found first if it exists. CMake tries to
+ * sort rpath directories to avoid this, but sometimes there is no
+ * right answer.
+ *
+ * I believe it is possible to resolve this using otools -l
+ * then checking the LC_LOAD_DYLIB command whose name is
+ * equal to the value of search_file, UNLESS the build
+ * specifically sets the RPath to paths that will match
+ * duplicate libs; at this point can we just point to
+ * user error, or is there a reason why the advantages
+ * to this scenario outweigh its disadvantages?
+ *
+ * Also priority seems to be the order as passed in when compiled
+ * so as long as this method's resolution guarantees priority
+ * in that manner further checking should not be necessary?
+ */
+ path = searchFile;
+ resolved = true;
+ return true;
+ }
+ }
+
+ resolved = false;
+ return true;
+}
diff --git a/Source/cmBinUtilsMacOSMachOLinker.h b/Source/cmBinUtilsMacOSMachOLinker.h
new file mode 100644
index 000000000..4a24ea35e
--- /dev/null
+++ b/Source/cmBinUtilsMacOSMachOLinker.h
@@ -0,0 +1,59 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmBinUtilsMacOSMachOLinker_h
+#define cmBinUtilsMacOSMachOLinker_h
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "cmBinUtilsLinker.h"
+#include "cmBinUtilsMacOSMachOGetRuntimeDependenciesTool.h"
+#include "cmStateTypes.h"
+
+class cmRuntimeDependencyArchive;
+
+class cmBinUtilsMacOSMachOLinker : public cmBinUtilsLinker
+{
+public:
+ cmBinUtilsMacOSMachOLinker(cmRuntimeDependencyArchive* archive);
+
+ bool Prepare() override;
+
+ bool ScanDependencies(std::string const& file,
+ cmStateEnums::TargetType type) override;
+
+private:
+ std::unique_ptr<cmBinUtilsMacOSMachOGetRuntimeDependenciesTool> Tool;
+
+ bool ScanDependencies(std::string const& file,
+ std::string const& executablePath);
+
+ bool GetFileDependencies(std::vector<std::string> const& names,
+ std::string const& executablePath,
+ std::string const& loaderPath,
+ std::vector<std::string> const& rpaths);
+
+ bool ResolveDependency(std::string const& name,
+ std::string const& executablePath,
+ std::string const& loaderPath,
+ std::vector<std::string> const& rpaths,
+ std::string& path, bool& resolved);
+
+ bool ResolveExecutablePathDependency(std::string const& name,
+ std::string const& executablePath,
+ std::string& path, bool& resolved);
+
+ bool ResolveLoaderPathDependency(std::string const& name,
+ std::string const& loaderPath,
+ std::string& path, bool& resolved);
+
+ bool ResolveRPathDependency(std::string const& name,
+ std::string const& executablePath,
+ std::string const& loaderPath,
+ std::vector<std::string> const& rpaths,
+ std::string& path, bool& resolved);
+};
+
+#endif // cmBinUtilsMacOSMachOLinker_h
diff --git a/Source/cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.cxx b/Source/cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.cxx
new file mode 100644
index 000000000..351d92aa8
--- /dev/null
+++ b/Source/cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.cxx
@@ -0,0 +1,100 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.h"
+
+#include <sstream>
+
+#include <cmsys/RegularExpression.hxx>
+
+#include "cmRuntimeDependencyArchive.h"
+#include "cmUVProcessChain.h"
+
+cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool::
+ cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive)
+ : cmBinUtilsMacOSMachOGetRuntimeDependenciesTool(archive)
+{
+}
+
+bool cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool::GetFileInfo(
+ std::string const& file, std::vector<std::string>& libs,
+ std::vector<std::string>& rpaths)
+{
+ std::vector<std::string> command;
+ if (!this->Archive->GetGetRuntimeDependenciesCommand("otool", command)) {
+ this->SetError("Could not find otool");
+ return false;
+ }
+ command.emplace_back("-l");
+ command.emplace_back(file);
+
+ cmUVProcessChainBuilder builder;
+ builder.SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT)
+ .AddCommand(command);
+
+ auto process = builder.Start();
+ if (!process.Valid()) {
+ std::ostringstream e;
+ e << "Failed to start otool process for:\n " << file;
+ this->SetError(e.str());
+ return false;
+ }
+
+ std::string line;
+ static const cmsys::RegularExpression rpathRegex("^ *cmd LC_RPATH$");
+ static const cmsys::RegularExpression loadDylibRegex(
+ "^ *cmd LC_LOAD_DYLIB$");
+ static const cmsys::RegularExpression pathRegex(
+ "^ *path (.*) \\(offset [0-9]+\\)$");
+ static const cmsys::RegularExpression nameRegex(
+ "^ *name (.*) \\(offset [0-9]+\\)$");
+ while (std::getline(*process.OutputStream(), line)) {
+ cmsys::RegularExpressionMatch cmdMatch;
+ if (rpathRegex.find(line.c_str(), cmdMatch)) {
+ if (!std::getline(*process.OutputStream(), line) ||
+ !std::getline(*process.OutputStream(), line)) {
+ this->SetError("Invalid output from otool");
+ return false;
+ }
+
+ cmsys::RegularExpressionMatch pathMatch;
+ if (pathRegex.find(line.c_str(), pathMatch)) {
+ rpaths.push_back(pathMatch.match(1));
+ } else {
+ this->SetError("Invalid output from otool");
+ return false;
+ }
+ } else if (loadDylibRegex.find(line.c_str(), cmdMatch)) {
+ if (!std::getline(*process.OutputStream(), line) ||
+ !std::getline(*process.OutputStream(), line)) {
+ this->SetError("Invalid output from otool");
+ return false;
+ }
+
+ cmsys::RegularExpressionMatch nameMatch;
+ if (nameRegex.find(line.c_str(), nameMatch)) {
+ libs.push_back(nameMatch.match(1));
+ } else {
+ this->SetError("Invalid output from otool");
+ return false;
+ }
+ }
+ }
+
+ if (!process.Wait()) {
+ std::ostringstream e;
+ e << "Failed to wait on otool process for:\n " << file;
+ this->SetError(e.str());
+ return false;
+ }
+ auto status = process.GetStatus();
+ if (!status[0] || status[0]->ExitStatus != 0) {
+ std::ostringstream e;
+ e << "Failed to run otool on:\n " << file;
+ this->SetError(e.str());
+ return false;
+ }
+
+ return true;
+}
diff --git a/Source/cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.h b/Source/cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.h
new file mode 100644
index 000000000..8ac7e188e
--- /dev/null
+++ b/Source/cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.h
@@ -0,0 +1,25 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool_h
+#define cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool_h
+
+#include <string>
+#include <vector>
+
+#include "cmBinUtilsMacOSMachOGetRuntimeDependenciesTool.h"
+
+class cmRuntimeDependencyArchive;
+
+class cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool
+ : public cmBinUtilsMacOSMachOGetRuntimeDependenciesTool
+{
+public:
+ cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive);
+
+ bool GetFileInfo(std::string const& file, std::vector<std::string>& libs,
+ std::vector<std::string>& rpaths) override;
+};
+
+#endif // cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool_h
diff --git a/Source/cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.cxx b/Source/cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.cxx
new file mode 100644
index 000000000..f342884dc
--- /dev/null
+++ b/Source/cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.cxx
@@ -0,0 +1,68 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.h"
+
+#include <sstream>
+
+#include <cmsys/RegularExpression.hxx>
+
+#include "cmRuntimeDependencyArchive.h"
+#include "cmUVProcessChain.h"
+
+cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool::
+ cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive)
+ : cmBinUtilsWindowsPEGetRuntimeDependenciesTool(archive)
+{
+}
+
+bool cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool::GetFileInfo(
+ const std::string& file, std::vector<std::string>& needed)
+{
+ cmUVProcessChainBuilder builder;
+ builder.SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT);
+
+ std::vector<std::string> command;
+ if (!this->Archive->GetGetRuntimeDependenciesCommand("dumpbin", command)) {
+ this->SetError("Could not find dumpbin");
+ return false;
+ }
+ command.emplace_back("/dependents");
+ command.push_back(file);
+ builder.AddCommand(command);
+
+ auto process = builder.Start();
+ if (!process.Valid()) {
+ std::ostringstream e;
+ e << "Failed to start dumpbin process for:\n " << file;
+ this->SetError(e.str());
+ return false;
+ }
+
+ std::string line;
+ static const cmsys::RegularExpression regex(
+ "^ ([^\n]*\\.[Dd][Ll][Ll])\r$");
+ while (std::getline(*process.OutputStream(), line)) {
+ cmsys::RegularExpressionMatch match;
+ if (regex.find(line.c_str(), match)) {
+ needed.push_back(match.match(1));
+ }
+ }
+
+ if (!process.Wait()) {
+ std::ostringstream e;
+ e << "Failed to wait on dumpbin process for:\n " << file;
+ this->SetError(e.str());
+ return false;
+ }
+ auto status = process.GetStatus();
+ if (!status[0] || status[0]->ExitStatus != 0) {
+ std::ostringstream e;
+ e << "Failed to run dumpbin on:\n " << file;
+ this->SetError(e.str());
+ return false;
+ }
+
+ return true;
+}
diff --git a/Source/cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.h b/Source/cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.h
new file mode 100644
index 000000000..eae22eae8
--- /dev/null
+++ b/Source/cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.h
@@ -0,0 +1,25 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool_h
+#define cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool_h
+
+#include <string>
+#include <vector>
+
+#include "cmBinUtilsWindowsPEGetRuntimeDependenciesTool.h"
+
+class cmRuntimeDependencyArchive;
+
+class cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool
+ : public cmBinUtilsWindowsPEGetRuntimeDependenciesTool
+{
+public:
+ cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive);
+
+ bool GetFileInfo(const std::string& file,
+ std::vector<std::string>& needed) override;
+};
+
+#endif // cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool_h
diff --git a/Source/cmBinUtilsWindowsPEGetRuntimeDependenciesTool.cxx b/Source/cmBinUtilsWindowsPEGetRuntimeDependenciesTool.cxx
new file mode 100644
index 000000000..468a40c7a
--- /dev/null
+++ b/Source/cmBinUtilsWindowsPEGetRuntimeDependenciesTool.cxx
@@ -0,0 +1,19 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmBinUtilsWindowsPEGetRuntimeDependenciesTool.h"
+
+#include "cmRuntimeDependencyArchive.h"
+
+cmBinUtilsWindowsPEGetRuntimeDependenciesTool::
+ cmBinUtilsWindowsPEGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive)
+ : Archive(archive)
+{
+}
+
+void cmBinUtilsWindowsPEGetRuntimeDependenciesTool::SetError(
+ const std::string& error)
+{
+ this->Archive->SetError(error);
+}
diff --git a/Source/cmBinUtilsWindowsPEGetRuntimeDependenciesTool.h b/Source/cmBinUtilsWindowsPEGetRuntimeDependenciesTool.h
new file mode 100644
index 000000000..e9e402b0f
--- /dev/null
+++ b/Source/cmBinUtilsWindowsPEGetRuntimeDependenciesTool.h
@@ -0,0 +1,28 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmBinUtilsWindowsPEGetRuntimeDependenciesTool_h
+#define cmBinUtilsWindowsPEGetRuntimeDependenciesTool_h
+
+#include <string>
+#include <vector>
+
+class cmRuntimeDependencyArchive;
+
+class cmBinUtilsWindowsPEGetRuntimeDependenciesTool
+{
+public:
+ cmBinUtilsWindowsPEGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive);
+ virtual ~cmBinUtilsWindowsPEGetRuntimeDependenciesTool() = default;
+
+ virtual bool GetFileInfo(const std::string& file,
+ std::vector<std::string>& needed) = 0;
+
+protected:
+ cmRuntimeDependencyArchive* Archive;
+
+ void SetError(const std::string& error);
+};
+
+#endif // cmBinUtilsWindowsPEGetRuntimeDependenciesTool_h
diff --git a/Source/cmBinUtilsWindowsPELinker.cxx b/Source/cmBinUtilsWindowsPELinker.cxx
new file mode 100644
index 000000000..79e39e9c5
--- /dev/null
+++ b/Source/cmBinUtilsWindowsPELinker.cxx
@@ -0,0 +1,123 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmBinUtilsWindowsPELinker.h"
+
+#include <sstream>
+#include <vector>
+
+#include <cm/memory>
+
+#include "cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.h"
+#include "cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h"
+#include "cmRuntimeDependencyArchive.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
+cmBinUtilsWindowsPELinker::cmBinUtilsWindowsPELinker(
+ cmRuntimeDependencyArchive* archive)
+ : cmBinUtilsLinker(archive)
+{
+}
+
+bool cmBinUtilsWindowsPELinker::Prepare()
+{
+ std::string tool = this->Archive->GetGetRuntimeDependenciesTool();
+ if (tool.empty()) {
+ std::vector<std::string> command;
+ if (this->Archive->GetGetRuntimeDependenciesCommand("dumpbin", command)) {
+ tool = "dumpbin";
+ } else {
+ tool = "objdump";
+ }
+ }
+ if (tool == "dumpbin") {
+ this->Tool =
+ cm::make_unique<cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool>(
+ this->Archive);
+ } else if (tool == "objdump") {
+ this->Tool =
+ cm::make_unique<cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool>(
+ this->Archive);
+ } else {
+ std::ostringstream e;
+ e << "Invalid value for CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: " << tool;
+ this->SetError(e.str());
+ return false;
+ }
+
+ return true;
+}
+
+bool cmBinUtilsWindowsPELinker::ScanDependencies(
+ std::string const& file, cmStateEnums::TargetType /* unused */)
+{
+ std::vector<std::string> needed;
+ if (!this->Tool->GetFileInfo(file, needed)) {
+ return false;
+ }
+ for (auto& n : needed) {
+ n = cmSystemTools::LowerCase(n);
+ }
+ std::string origin = cmSystemTools::GetFilenamePath(file);
+
+ for (auto const& lib : needed) {
+ if (!this->Archive->IsPreExcluded(lib)) {
+ std::string path;
+ bool resolved = false;
+ if (!this->ResolveDependency(lib, origin, path, resolved)) {
+ return false;
+ }
+ if (resolved) {
+ if (!this->Archive->IsPostExcluded(path)) {
+ bool unique;
+ this->Archive->AddResolvedPath(lib, path, unique);
+ if (unique &&
+ !this->ScanDependencies(path, cmStateEnums::SHARED_LIBRARY)) {
+ return false;
+ }
+ }
+ } else {
+ this->Archive->AddUnresolvedPath(lib);
+ }
+ }
+ }
+
+ return true;
+}
+
+bool cmBinUtilsWindowsPELinker::ResolveDependency(std::string const& name,
+ std::string const& origin,
+ std::string& path,
+ bool& resolved)
+{
+ auto dirs = this->Archive->GetSearchDirectories();
+
+#ifdef _WIN32
+ char buf[MAX_PATH];
+ unsigned int len;
+ if ((len = GetWindowsDirectoryA(buf, MAX_PATH)) > 0) {
+ dirs.insert(dirs.begin(), std::string(buf, len));
+ }
+ if ((len = GetSystemDirectoryA(buf, MAX_PATH)) > 0) {
+ dirs.insert(dirs.begin(), std::string(buf, len));
+ }
+#endif
+
+ dirs.insert(dirs.begin(), origin);
+
+ for (auto const& searchPath : dirs) {
+ path = cmStrCat(searchPath, '/', name);
+ if (cmSystemTools::PathExists(path)) {
+ resolved = true;
+ return true;
+ }
+ }
+
+ resolved = false;
+ return true;
+}
diff --git a/Source/cmBinUtilsWindowsPELinker.h b/Source/cmBinUtilsWindowsPELinker.h
new file mode 100644
index 000000000..a8bb59629
--- /dev/null
+++ b/Source/cmBinUtilsWindowsPELinker.h
@@ -0,0 +1,33 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmBinUtilsWindowsPELinker_h
+#define cmBinUtilsWindowsPELinker_h
+
+#include <memory>
+#include <string>
+
+#include "cmBinUtilsLinker.h"
+#include "cmBinUtilsWindowsPEGetRuntimeDependenciesTool.h"
+#include "cmStateTypes.h"
+
+class cmRuntimeDependencyArchive;
+
+class cmBinUtilsWindowsPELinker : public cmBinUtilsLinker
+{
+public:
+ cmBinUtilsWindowsPELinker(cmRuntimeDependencyArchive* archive);
+
+ bool Prepare() override;
+
+ bool ScanDependencies(std::string const& file,
+ cmStateEnums::TargetType type) override;
+
+private:
+ std::unique_ptr<cmBinUtilsWindowsPEGetRuntimeDependenciesTool> Tool;
+
+ bool ResolveDependency(std::string const& name, std::string const& origin,
+ std::string& path, bool& resolved);
+};
+
+#endif // cmBinUtilsWindowsPELinker_h
diff --git a/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx b/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx
new file mode 100644
index 000000000..1effda053
--- /dev/null
+++ b/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.cxx
@@ -0,0 +1,68 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h"
+
+#include <sstream>
+
+#include <cmsys/RegularExpression.hxx>
+
+#include "cmRuntimeDependencyArchive.h"
+#include "cmUVProcessChain.h"
+
+cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool::
+ cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive)
+ : cmBinUtilsWindowsPEGetRuntimeDependenciesTool(archive)
+{
+}
+
+bool cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool::GetFileInfo(
+ const std::string& file, std::vector<std::string>& needed)
+{
+ cmUVProcessChainBuilder builder;
+ builder.SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT);
+
+ std::vector<std::string> command;
+ if (!this->Archive->GetGetRuntimeDependenciesCommand("objdump", command)) {
+ this->SetError("Could not find objdump");
+ return false;
+ }
+ command.emplace_back("-p");
+ command.push_back(file);
+ builder.AddCommand(command);
+
+ auto process = builder.Start();
+ if (!process.Valid()) {
+ std::ostringstream e;
+ e << "Failed to start objdump process for:\n " << file;
+ this->SetError(e.str());
+ return false;
+ }
+
+ std::string line;
+ static const cmsys::RegularExpression regex(
+ "^\t*DLL Name: ([^\n]*\\.[Dd][Ll][Ll])\r$");
+ while (std::getline(*process.OutputStream(), line)) {
+ cmsys::RegularExpressionMatch match;
+ if (regex.find(line.c_str(), match)) {
+ needed.push_back(match.match(1));
+ }
+ }
+
+ if (!process.Wait()) {
+ std::ostringstream e;
+ e << "Failed to wait on objdump process for:\n " << file;
+ this->SetError(e.str());
+ return false;
+ }
+ auto status = process.GetStatus();
+ if (!status[0] || status[0]->ExitStatus != 0) {
+ std::ostringstream e;
+ e << "Failed to run objdump on:\n " << file;
+ this->SetError(e.str());
+ return false;
+ }
+
+ return true;
+}
diff --git a/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h b/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h
new file mode 100644
index 000000000..a67cb0cf1
--- /dev/null
+++ b/Source/cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h
@@ -0,0 +1,25 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool_h
+#define cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool_h
+
+#include <string>
+#include <vector>
+
+#include "cmBinUtilsWindowsPEGetRuntimeDependenciesTool.h"
+
+class cmRuntimeDependencyArchive;
+
+class cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool
+ : public cmBinUtilsWindowsPEGetRuntimeDependenciesTool
+{
+public:
+ cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool(
+ cmRuntimeDependencyArchive* archive);
+
+ bool GetFileInfo(const std::string& file,
+ std::vector<std::string>& needed) override;
+};
+
+#endif // cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool_h
diff --git a/Source/cmBreakCommand.cxx b/Source/cmBreakCommand.cxx
index 3772c6fb6..95db689cd 100644
--- a/Source/cmBreakCommand.cxx
+++ b/Source/cmBreakCommand.cxx
@@ -6,18 +6,18 @@
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
-#include "cmake.h"
// cmBreakCommand
-bool cmBreakCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status)
+bool cmBreakCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- if (!this->Makefile->IsLoopBlock()) {
+ if (!status.GetMakefile().IsLoopBlock()) {
bool issueMessage = true;
std::ostringstream e;
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0055)) {
+ MessageType messageType = MessageType::AUTHOR_WARNING;
+ switch (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0055)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0055) << "\n";
break;
@@ -27,15 +27,15 @@ bool cmBreakCommand::InitialPass(std::vector<std::string> const& args,
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::NEW:
- messageType = cmake::FATAL_ERROR;
+ messageType = MessageType::FATAL_ERROR;
break;
}
if (issueMessage) {
e << "A BREAK command was found outside of a proper "
"FOREACH or WHILE loop scope.";
- this->Makefile->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR) {
+ status.GetMakefile().IssueMessage(messageType, e.str());
+ if (messageType == MessageType::FATAL_ERROR) {
return false;
}
}
@@ -46,8 +46,8 @@ bool cmBreakCommand::InitialPass(std::vector<std::string> const& args,
if (!args.empty()) {
bool issueMessage = true;
std::ostringstream e;
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0055)) {
+ MessageType messageType = MessageType::AUTHOR_WARNING;
+ switch (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0055)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0055) << "\n";
break;
@@ -57,14 +57,14 @@ bool cmBreakCommand::InitialPass(std::vector<std::string> const& args,
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::NEW:
- messageType = cmake::FATAL_ERROR;
+ messageType = MessageType::FATAL_ERROR;
break;
}
if (issueMessage) {
e << "The BREAK command does not accept any arguments.";
- this->Makefile->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR) {
+ status.GetMakefile().IssueMessage(messageType, e.str());
+ if (messageType == MessageType::FATAL_ERROR) {
return false;
}
}
diff --git a/Source/cmBreakCommand.h b/Source/cmBreakCommand.h
index fcca45c31..e6ce6fe74 100644
--- a/Source/cmBreakCommand.h
+++ b/Source/cmBreakCommand.h
@@ -3,34 +3,19 @@
#ifndef cmBreakCommand_h
#define cmBreakCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmBreakCommand
+/**
* \brief Break from an enclosing foreach or while loop
*
* cmBreakCommand returns from an enclosing foreach or while loop
*/
-class cmBreakCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmBreakCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmBreakCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx
index fd876004b..49c943975 100644
--- a/Source/cmBuildCommand.cxx
+++ b/Source/cmBuildCommand.cxx
@@ -2,32 +2,21 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmBuildCommand.h"
-#include <sstream>
-
+#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-
-class cmExecutionStatus;
-
-bool cmBuildCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
-{
- // Support the legacy signature of the command:
- //
- if (2 == args.size()) {
- return this->TwoArgsSignature(args);
- }
- return this->MainSignature(args);
-}
+namespace {
-bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
+bool MainSignature(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("requires at least one argument naming a CMake variable");
+ status.SetError("requires at least one argument naming a CMake variable");
return false;
}
@@ -63,9 +52,7 @@ bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
doing = DoingNone;
target = args[i];
} else {
- std::ostringstream e;
- e << "unknown argument \"" << args[i] << "\"";
- this->SetError(e.str());
+ status.SetError(cmStrCat("unknown argument \"", args[i], "\""));
return false;
}
}
@@ -82,30 +69,32 @@ bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
configuration = "Release";
}
+ cmMakefile& mf = status.GetMakefile();
if (!project_name.empty()) {
- this->Makefile->IssueMessage(
- cmake::AUTHOR_WARNING,
- "Ignoring PROJECT_NAME option because it has no effect.");
+ mf.IssueMessage(MessageType::AUTHOR_WARNING,
+ "Ignoring PROJECT_NAME option because it has no effect.");
}
- std::string makecommand =
- this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand(
- target, configuration, "", this->Makefile->IgnoreErrorsCMP0061());
+ std::string makecommand = mf.GetGlobalGenerator()->GenerateCMakeBuildCommand(
+ target, configuration, "", mf.IgnoreErrorsCMP0061());
- this->Makefile->AddDefinition(variable, makecommand.c_str());
+ mf.AddDefinition(variable, makecommand);
return true;
}
-bool cmBuildCommand::TwoArgsSignature(std::vector<std::string> const& args)
+bool TwoArgsSignature(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with less than two arguments");
+ status.SetError("called with less than two arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
std::string const& define = args[0];
- const char* cacheValue = this->Makefile->GetDefinition(define);
+ const char* cacheValue = mf.GetDefinition(define);
std::string configType;
if (!cmSystemTools::GetEnv("CMAKE_CONFIG_TYPE", configType) ||
@@ -113,16 +102,28 @@ bool cmBuildCommand::TwoArgsSignature(std::vector<std::string> const& args)
configType = "Release";
}
- std::string makecommand =
- this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand(
- "", configType, "", this->Makefile->IgnoreErrorsCMP0061());
+ std::string makecommand = mf.GetGlobalGenerator()->GenerateCMakeBuildCommand(
+ "", configType, "", mf.IgnoreErrorsCMP0061());
if (cacheValue) {
return true;
}
- this->Makefile->AddCacheDefinition(define, makecommand.c_str(),
- "Command used to build entire project "
- "from the command line.",
- cmStateEnums::STRING);
+ mf.AddCacheDefinition(define, makecommand.c_str(),
+ "Command used to build entire project "
+ "from the command line.",
+ cmStateEnums::STRING);
return true;
}
+
+} // namespace
+
+bool cmBuildCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ // Support the legacy signature of the command:
+ if (args.size() == 2) {
+ return TwoArgsSignature(args, status);
+ }
+
+ return MainSignature(args, status);
+}
diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h
index 1f357a980..45aa71da2 100644
--- a/Source/cmBuildCommand.h
+++ b/Source/cmBuildCommand.h
@@ -3,47 +3,14 @@
#ifndef cmBuildCommand_h
#define cmBuildCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmBuildCommand
- * \brief build_command command
- *
- * cmBuildCommand implements the build_command CMake command
- */
-class cmBuildCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmBuildCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
- /**
- * The primary command signature with optional, KEYWORD-based args.
- */
- virtual bool MainSignature(std::vector<std::string> const& args);
-
- /**
- * Legacy "exactly 2 args required" signature.
- */
- virtual bool TwoArgsSignature(std::vector<std::string> const& args);
-
-private:
- bool IgnoreErrors() const;
-};
+bool cmBuildCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx
index 9d2c0c642..3e517dca4 100644
--- a/Source/cmBuildNameCommand.cxx
+++ b/Source/cmBuildNameCommand.cxx
@@ -2,24 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmBuildNameCommand.h"
-#include "cmsys/RegularExpression.hxx"
#include <algorithm>
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
-// cmBuildNameCommand
-bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmBuildNameCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- const char* cacheValue = this->Makefile->GetDefinition(args[0]);
+ cmMakefile& mf = status.GetMakefile();
+ const char* cacheValue = mf.GetDefinition(args[0]);
if (cacheValue) {
// do we need to correct the value?
cmsys::RegularExpression reg("[()/]");
@@ -28,33 +28,33 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args,
std::replace(cv.begin(), cv.end(), '/', '_');
std::replace(cv.begin(), cv.end(), '(', '_');
std::replace(cv.begin(), cv.end(), ')', '_');
- this->Makefile->AddCacheDefinition(args[0], cv.c_str(), "Name of build.",
- cmStateEnums::STRING);
+ mf.AddCacheDefinition(args[0], cv.c_str(), "Name of build.",
+ cmStateEnums::STRING);
}
return true;
}
std::string buildname = "WinNT";
- if (this->Makefile->GetDefinition("UNIX")) {
- buildname = "";
+ if (mf.GetDefinition("UNIX")) {
+ buildname.clear();
cmSystemTools::RunSingleCommand("uname -a", &buildname, &buildname);
if (!buildname.empty()) {
std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) ";
- cmsys::RegularExpression reg(RegExp.c_str());
- if (reg.find(buildname.c_str())) {
+ cmsys::RegularExpression reg(RegExp);
+ if (reg.find(buildname)) {
buildname = reg.match(1) + "-" + reg.match(2);
}
}
}
std::string compiler = "${CMAKE_CXX_COMPILER}";
- this->Makefile->ExpandVariablesInString(compiler);
+ mf.ExpandVariablesInString(compiler);
buildname += "-";
buildname += cmSystemTools::GetFilenameName(compiler);
std::replace(buildname.begin(), buildname.end(), '/', '_');
std::replace(buildname.begin(), buildname.end(), '(', '_');
std::replace(buildname.begin(), buildname.end(), ')', '_');
- this->Makefile->AddCacheDefinition(args[0], buildname.c_str(),
- "Name of build.", cmStateEnums::STRING);
+ mf.AddCacheDefinition(args[0], buildname.c_str(), "Name of build.",
+ cmStateEnums::STRING);
return true;
}
diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h
index ff26c559c..37a72689c 100644
--- a/Source/cmBuildNameCommand.h
+++ b/Source/cmBuildNameCommand.h
@@ -3,21 +3,14 @@
#ifndef cmBuildNameCommand_h
#define cmBuildNameCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmBuildNameCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmBuildNameCommand; }
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmBuildNameCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmCLocaleEnvironmentScope.cxx b/Source/cmCLocaleEnvironmentScope.cxx
index 28e8f2efc..c6c38f83c 100644
--- a/Source/cmCLocaleEnvironmentScope.cxx
+++ b/Source/cmCLocaleEnvironmentScope.cxx
@@ -2,11 +2,11 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCLocaleEnvironmentScope.h"
-#include "cmSystemTools.h"
-
#include <sstream>
#include <utility>
+#include "cmSystemTools.h"
+
cmCLocaleEnvironmentScope::cmCLocaleEnvironmentScope()
{
this->SetEnv("LANGUAGE", "");
@@ -45,10 +45,9 @@ void cmCLocaleEnvironmentScope::SetEnv(std::string const& key,
cmCLocaleEnvironmentScope::~cmCLocaleEnvironmentScope()
{
- for (backup_map_t::const_iterator i = this->EnvironmentBackup.begin();
- i != this->EnvironmentBackup.end(); ++i) {
+ for (auto const& envb : this->EnvironmentBackup) {
std::ostringstream tmp;
- tmp << i->first << "=" << i->second;
+ tmp << envb.first << "=" << envb.second;
cmSystemTools::PutEnv(tmp.str());
}
}
diff --git a/Source/cmCLocaleEnvironmentScope.h b/Source/cmCLocaleEnvironmentScope.h
index e956cb24d..aa2827e74 100644
--- a/Source/cmCLocaleEnvironmentScope.h
+++ b/Source/cmCLocaleEnvironmentScope.h
@@ -3,24 +3,26 @@
#ifndef cmCLocaleEnvironmentScope_h
#define cmCLocaleEnvironmentScope_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
#include <string>
class cmCLocaleEnvironmentScope
{
- CM_DISABLE_COPY(cmCLocaleEnvironmentScope)
-
public:
cmCLocaleEnvironmentScope();
~cmCLocaleEnvironmentScope();
+ cmCLocaleEnvironmentScope(cmCLocaleEnvironmentScope const&) = delete;
+ cmCLocaleEnvironmentScope& operator=(cmCLocaleEnvironmentScope const&) =
+ delete;
+
private:
std::string GetEnv(std::string const& key);
void SetEnv(std::string const& key, std::string const& value);
- typedef std::map<std::string, std::string> backup_map_t;
+ using backup_map_t = std::map<std::string, std::string>;
backup_map_t EnvironmentBackup;
};
diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx
index 4475c5a52..26e9af027 100644
--- a/Source/cmCMakeHostSystemInformationCommand.cxx
+++ b/Source/cmCMakeHostSystemInformationCommand.cxx
@@ -2,27 +2,38 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCMakeHostSystemInformationCommand.h"
-#include <sstream>
+#include <cstddef>
-#include "cmMakefile.h"
#include "cmsys/SystemInformation.hxx"
+#include "cmExecutionStatus.h"
+#include "cmMakefile.h"
+
#if defined(_WIN32)
-#include "cmSystemTools.h"
-#include "cmVSSetupHelper.h"
-#define HAVE_VS_SETUP_HELPER
+# include "cmAlgorithms.h"
+# include "cmGlobalGenerator.h"
+# include "cmGlobalVisualStudioVersionedGenerator.h"
+# include "cmSystemTools.h"
+# include "cmVSSetupHelper.h"
+# define HAVE_VS_SETUP_HELPER
#endif
-class cmExecutionStatus;
+namespace {
+bool GetValue(cmExecutionStatus& status, cmsys::SystemInformation& info,
+ std::string const& key, std::string& value);
+std::string ValueToString(size_t value);
+std::string ValueToString(const char* value);
+std::string ValueToString(std::string const& value);
+}
// cmCMakeHostSystemInformation
-bool cmCMakeHostSystemInformationCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmCMakeHostSystemInformationCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
size_t current_index = 0;
if (args.size() < (current_index + 2) || args[current_index] != "RESULT") {
- this->SetError("missing RESULT specification.");
+ status.SetError("missing RESULT specification.");
return false;
}
@@ -30,7 +41,7 @@ bool cmCMakeHostSystemInformationCommand::InitialPass(
current_index += 2;
if (args.size() < (current_index + 2) || args[current_index] != "QUERY") {
- this->SetError("missing QUERY specification");
+ status.SetError("missing QUERY specification");
return false;
}
@@ -46,69 +57,143 @@ bool cmCMakeHostSystemInformationCommand::InitialPass(
result_list += ";";
}
std::string value;
- if (!this->GetValue(info, key, value)) {
+ if (!GetValue(status, info, key, value)) {
return false;
}
result_list += value;
}
- this->Makefile->AddDefinition(variable, result_list.c_str());
+ status.GetMakefile().AddDefinition(variable, result_list);
return true;
}
-bool cmCMakeHostSystemInformationCommand::GetValue(
- cmsys::SystemInformation& info, std::string const& key, std::string& value)
+namespace {
+
+bool GetValue(cmExecutionStatus& status, cmsys::SystemInformation& info,
+ std::string const& key, std::string& value)
{
if (key == "NUMBER_OF_LOGICAL_CORES") {
- value = this->ValueToString(info.GetNumberOfLogicalCPU());
+ value = ValueToString(info.GetNumberOfLogicalCPU());
} else if (key == "NUMBER_OF_PHYSICAL_CORES") {
- value = this->ValueToString(info.GetNumberOfPhysicalCPU());
+ value = ValueToString(info.GetNumberOfPhysicalCPU());
} else if (key == "HOSTNAME") {
- value = this->ValueToString(info.GetHostname());
+ value = ValueToString(info.GetHostname());
} else if (key == "FQDN") {
- value = this->ValueToString(info.GetFullyQualifiedDomainName());
+ value = ValueToString(info.GetFullyQualifiedDomainName());
} else if (key == "TOTAL_VIRTUAL_MEMORY") {
- value = this->ValueToString(info.GetTotalVirtualMemory());
+ value = ValueToString(info.GetTotalVirtualMemory());
} else if (key == "AVAILABLE_VIRTUAL_MEMORY") {
- value = this->ValueToString(info.GetAvailableVirtualMemory());
+ value = ValueToString(info.GetAvailableVirtualMemory());
} else if (key == "TOTAL_PHYSICAL_MEMORY") {
- value = this->ValueToString(info.GetTotalPhysicalMemory());
+ value = ValueToString(info.GetTotalPhysicalMemory());
} else if (key == "AVAILABLE_PHYSICAL_MEMORY") {
- value = this->ValueToString(info.GetAvailablePhysicalMemory());
+ value = ValueToString(info.GetAvailablePhysicalMemory());
+ } else if (key == "IS_64BIT") {
+ value = ValueToString(info.Is64Bits());
+ } else if (key == "HAS_FPU") {
+ value = ValueToString(
+ info.DoesCPUSupportFeature(cmsys::SystemInformation::CPU_FEATURE_FPU));
+ } else if (key == "HAS_MMX") {
+ value = ValueToString(
+ info.DoesCPUSupportFeature(cmsys::SystemInformation::CPU_FEATURE_MMX));
+ } else if (key == "HAS_MMX_PLUS") {
+ value = ValueToString(info.DoesCPUSupportFeature(
+ cmsys::SystemInformation::CPU_FEATURE_MMX_PLUS));
+ } else if (key == "HAS_SSE") {
+ value = ValueToString(
+ info.DoesCPUSupportFeature(cmsys::SystemInformation::CPU_FEATURE_SSE));
+ } else if (key == "HAS_SSE2") {
+ value = ValueToString(
+ info.DoesCPUSupportFeature(cmsys::SystemInformation::CPU_FEATURE_SSE2));
+ } else if (key == "HAS_SSE_FP") {
+ value = ValueToString(info.DoesCPUSupportFeature(
+ cmsys::SystemInformation::CPU_FEATURE_SSE_FP));
+ } else if (key == "HAS_SSE_MMX") {
+ value = ValueToString(info.DoesCPUSupportFeature(
+ cmsys::SystemInformation::CPU_FEATURE_SSE_MMX));
+ } else if (key == "HAS_AMD_3DNOW") {
+ value = ValueToString(info.DoesCPUSupportFeature(
+ cmsys::SystemInformation::CPU_FEATURE_AMD_3DNOW));
+ } else if (key == "HAS_AMD_3DNOW_PLUS") {
+ value = ValueToString(info.DoesCPUSupportFeature(
+ cmsys::SystemInformation::CPU_FEATURE_AMD_3DNOW_PLUS));
+ } else if (key == "HAS_IA64") {
+ value = ValueToString(
+ info.DoesCPUSupportFeature(cmsys::SystemInformation::CPU_FEATURE_IA64));
+ } else if (key == "HAS_SERIAL_NUMBER") {
+ value = ValueToString(info.DoesCPUSupportFeature(
+ cmsys::SystemInformation::CPU_FEATURE_SERIALNUMBER));
+ } else if (key == "PROCESSOR_NAME") {
+ value = ValueToString(info.GetExtendedProcessorName());
+ } else if (key == "PROCESSOR_DESCRIPTION") {
+ value = info.GetCPUDescription();
+ } else if (key == "PROCESSOR_SERIAL_NUMBER") {
+ value = ValueToString(info.GetProcessorSerialNumber());
+ } else if (key == "OS_NAME") {
+ value = ValueToString(info.GetOSName());
+ } else if (key == "OS_RELEASE") {
+ value = ValueToString(info.GetOSRelease());
+ } else if (key == "OS_VERSION") {
+ value = ValueToString(info.GetOSVersion());
+ } else if (key == "OS_PLATFORM") {
+ value = ValueToString(info.GetOSPlatform());
#ifdef HAVE_VS_SETUP_HELPER
} else if (key == "VS_15_DIR") {
- cmVSSetupAPIHelper vsSetupAPIHelper;
+ // If generating for the VS 15 IDE, use the same instance.
+ cmGlobalGenerator* gg = status.GetMakefile().GetGlobalGenerator();
+ if (cmHasLiteralPrefix(gg->GetName(), "Visual Studio 15 ")) {
+ cmGlobalVisualStudioVersionedGenerator* vs15gen =
+ static_cast<cmGlobalVisualStudioVersionedGenerator*>(gg);
+ if (vs15gen->GetVSInstance(value)) {
+ return true;
+ }
+ }
+
+ // Otherwise, find a VS 15 instance ourselves.
+ cmVSSetupAPIHelper vsSetupAPIHelper(15);
+ if (vsSetupAPIHelper.GetVSInstanceInfo(value)) {
+ cmSystemTools::ConvertToUnixSlashes(value);
+ }
+ } else if (key == "VS_16_DIR") {
+ // If generating for the VS 16 IDE, use the same instance.
+ cmGlobalGenerator* gg = status.GetMakefile().GetGlobalGenerator();
+ if (cmHasLiteralPrefix(gg->GetName(), "Visual Studio 16 ")) {
+ cmGlobalVisualStudioVersionedGenerator* vs16gen =
+ static_cast<cmGlobalVisualStudioVersionedGenerator*>(gg);
+ if (vs16gen->GetVSInstance(value)) {
+ return true;
+ }
+ }
+
+ // Otherwise, find a VS 16 instance ourselves.
+ cmVSSetupAPIHelper vsSetupAPIHelper(16);
if (vsSetupAPIHelper.GetVSInstanceInfo(value)) {
cmSystemTools::ConvertToUnixSlashes(value);
}
#endif
} else {
std::string e = "does not recognize <key> " + key;
- this->SetError(e);
+ status.SetError(e);
return false;
}
return true;
}
-std::string cmCMakeHostSystemInformationCommand::ValueToString(
- size_t value) const
+std::string ValueToString(size_t value)
{
- std::ostringstream tmp;
- tmp << value;
- return tmp.str();
+ return std::to_string(value);
}
-std::string cmCMakeHostSystemInformationCommand::ValueToString(
- const char* value) const
+std::string ValueToString(const char* value)
{
std::string safe_string = value ? value : "";
return safe_string;
}
-std::string cmCMakeHostSystemInformationCommand::ValueToString(
- std::string const& value) const
+std::string ValueToString(std::string const& value)
{
return value;
}
+}
diff --git a/Source/cmCMakeHostSystemInformationCommand.h b/Source/cmCMakeHostSystemInformationCommand.h
index ef6ca3730..79e3f2702 100644
--- a/Source/cmCMakeHostSystemInformationCommand.h
+++ b/Source/cmCMakeHostSystemInformationCommand.h
@@ -3,50 +3,20 @@
#ifndef cmCMakeHostSystemInformationCommand_h
#define cmCMakeHostSystemInformationCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include <stddef.h>
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-namespace cmsys {
-class SystemInformation;
-} // namespace cmsys
-/** \class cmCMakeHostSystemInformationCommand
+/**
* \brief Query host system specific information
*
* cmCMakeHostSystemInformationCommand queries system information of
- * the sytem on which CMake runs.
+ * the system on which CMake runs.
*/
-class cmCMakeHostSystemInformationCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE
- {
- return new cmCMakeHostSystemInformationCommand;
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- bool GetValue(cmsys::SystemInformation& info, std::string const& key,
- std::string& value);
-
- std::string ValueToString(size_t value) const;
- std::string ValueToString(const char* value) const;
- std::string ValueToString(std::string const& value) const;
-};
+bool cmCMakeHostSystemInformationCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx
index 942688cee..1b03873d0 100644
--- a/Source/cmCMakeMinimumRequired.cxx
+++ b/Source/cmCMakeMinimumRequired.cxx
@@ -2,52 +2,73 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCMakeMinimumRequired.h"
+#include <cstdio>
#include <sstream>
-#include <stdio.h>
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
-#include "cmake.h"
-class cmExecutionStatus;
+namespace {
+bool EnforceUnknownArguments(std::string const& version_max,
+ std::vector<std::string> const& unknown_arguments,
+ cmExecutionStatus& status);
+}
// cmCMakeMinimumRequired
-bool cmCMakeMinimumRequired::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmCMakeMinimumRequired(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// Process arguments.
std::string version_string;
bool doing_version = false;
- for (unsigned int i = 0; i < args.size(); ++i) {
- if (args[i] == "VERSION") {
+ std::vector<std::string> unknown_arguments;
+ for (std::string const& arg : args) {
+ if (arg == "VERSION") {
doing_version = true;
- } else if (args[i] == "FATAL_ERROR") {
+ } else if (arg == "FATAL_ERROR") {
if (doing_version) {
- this->SetError("called with no value for VERSION.");
+ status.SetError("called with no value for VERSION.");
return false;
}
doing_version = false;
} else if (doing_version) {
doing_version = false;
- version_string = args[i];
+ version_string = arg;
} else {
- this->UnknownArguments.push_back(args[i]);
+ unknown_arguments.push_back(arg);
}
}
if (doing_version) {
- this->SetError("called with no value for VERSION.");
+ status.SetError("called with no value for VERSION.");
return false;
}
// Make sure there was a version to check.
if (version_string.empty()) {
- return this->EnforceUnknownArguments();
+ return EnforceUnknownArguments(std::string(), unknown_arguments, status);
+ }
+
+ // Separate the <min> version and any trailing ...<max> component.
+ std::string::size_type const dd = version_string.find("...");
+ std::string const version_min = version_string.substr(0, dd);
+ std::string const version_max = dd != std::string::npos
+ ? version_string.substr(dd + 3, std::string::npos)
+ : std::string();
+ if (dd != std::string::npos &&
+ (version_min.empty() || version_max.empty())) {
+ std::ostringstream e;
+ e << "VERSION \"" << version_string
+ << R"(" does not have a version on both sides of "...".)";
+ status.SetError(e.str());
+ return false;
}
// Save the required version string.
- this->Makefile->AddDefinition("CMAKE_MINIMUM_REQUIRED_VERSION",
- version_string.c_str());
+ status.GetMakefile().AddDefinition("CMAKE_MINIMUM_REQUIRED_VERSION",
+ version_min);
// Get the current version number.
unsigned int current_major = cmVersion::GetMajorVersion();
@@ -61,11 +82,11 @@ bool cmCMakeMinimumRequired::InitialPass(std::vector<std::string> const& args,
unsigned int required_minor = 0;
unsigned int required_patch = 0;
unsigned int required_tweak = 0;
- if (sscanf(version_string.c_str(), "%u.%u.%u.%u", &required_major,
+ if (sscanf(version_min.c_str(), "%u.%u.%u.%u", &required_major,
&required_minor, &required_patch, &required_tweak) < 2) {
std::ostringstream e;
- e << "could not parse VERSION \"" << version_string << "\".";
- this->SetError(e.str());
+ e << "could not parse VERSION \"" << version_min << "\".";
+ status.SetError(e.str());
return false;
}
@@ -78,39 +99,67 @@ bool cmCMakeMinimumRequired::InitialPass(std::vector<std::string> const& args,
current_patch == required_patch && current_tweak < required_tweak)) {
// The current version is too low.
std::ostringstream e;
- e << "CMake " << version_string
+ e << "CMake " << version_min
<< " or higher is required. You are running version "
<< cmVersion::GetCMakeVersion();
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
cmSystemTools::SetFatalErrorOccured();
return true;
}
// The version is not from the future, so enforce unknown arguments.
- if (!this->EnforceUnknownArguments()) {
+ if (!EnforceUnknownArguments(version_max, unknown_arguments, status)) {
return false;
}
if (required_major < 2 || (required_major == 2 && required_minor < 4)) {
- this->Makefile->IssueMessage(
- cmake::AUTHOR_WARNING,
+ status.GetMakefile().IssueMessage(
+ MessageType::AUTHOR_WARNING,
"Compatibility with CMake < 2.4 is not supported by CMake >= 3.0.");
- this->Makefile->SetPolicyVersion("2.4");
+ status.GetMakefile().SetPolicyVersion("2.4", version_max);
} else {
- this->Makefile->SetPolicyVersion(version_string.c_str());
+ status.GetMakefile().SetPolicyVersion(version_min, version_max);
}
return true;
}
-bool cmCMakeMinimumRequired::EnforceUnknownArguments()
+namespace {
+bool EnforceUnknownArguments(std::string const& version_max,
+ std::vector<std::string> const& unknown_arguments,
+ cmExecutionStatus& status)
{
- if (!this->UnknownArguments.empty()) {
- std::ostringstream e;
- e << "called with unknown argument \"" << this->UnknownArguments[0]
- << "\".";
- this->SetError(e.str());
- return false;
+ if (unknown_arguments.empty()) {
+ return true;
}
- return true;
+
+ // Consider the max version if at least two components were given.
+ unsigned int max_major = 0;
+ unsigned int max_minor = 0;
+ unsigned int max_patch = 0;
+ unsigned int max_tweak = 0;
+ if (sscanf(version_max.c_str(), "%u.%u.%u.%u", &max_major, &max_minor,
+ &max_patch, &max_tweak) >= 2) {
+ unsigned int current_major = cmVersion::GetMajorVersion();
+ unsigned int current_minor = cmVersion::GetMinorVersion();
+ unsigned int current_patch = cmVersion::GetPatchVersion();
+ unsigned int current_tweak = cmVersion::GetTweakVersion();
+
+ if ((current_major < max_major) ||
+ (current_major == max_major && current_minor < max_minor) ||
+ (current_major == max_major && current_minor == max_minor &&
+ current_patch < max_patch) ||
+ (current_major == max_major && current_minor == max_minor &&
+ current_patch == max_patch && current_tweak < max_tweak)) {
+ // A ...<max> version was given that is larger than the current
+ // version of CMake, so tolerate unknown arguments.
+ return true;
+ }
+ }
+
+ std::ostringstream e;
+ e << "called with unknown argument \"" << unknown_arguments[0] << "\".";
+ status.SetError(e.str());
+ return false;
+}
}
diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h
index 45b6b7885..53f78f690 100644
--- a/Source/cmCMakeMinimumRequired.h
+++ b/Source/cmCMakeMinimumRequired.h
@@ -3,38 +3,19 @@
#ifndef cmCMakeMinimumRequired_h
#define cmCMakeMinimumRequired_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmCMakeMinimumRequired
+/**
* \brief cmake_minimum_required command
*
* cmCMakeMinimumRequired implements the cmake_minimum_required CMake command
*/
-class cmCMakeMinimumRequired : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmCMakeMinimumRequired; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- std::vector<std::string> UnknownArguments;
- bool EnforceUnknownArguments();
-};
+bool cmCMakeMinimumRequired(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx
index 3ccc815e6..b7f08d2dd 100644
--- a/Source/cmCMakePolicyCommand.cxx
+++ b/Source/cmCMakePolicyCommand.cxx
@@ -2,87 +2,99 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCMakePolicyCommand.h"
-#include <sstream>
-
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmState.h"
#include "cmStateTypes.h"
-#include "cmake.h"
+#include "cmStringAlgorithms.h"
-class cmExecutionStatus;
+namespace {
+bool HandleSetMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+bool HandleGetMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+bool HandleVersionMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+bool HandleGetWarningMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+}
// cmCMakePolicyCommand
-bool cmCMakePolicyCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmCMakePolicyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("requires at least one argument.");
+ status.SetError("requires at least one argument.");
return false;
}
if (args[0] == "SET") {
- return this->HandleSetMode(args);
+ return HandleSetMode(args, status);
}
if (args[0] == "GET") {
- return this->HandleGetMode(args);
+ return HandleGetMode(args, status);
}
if (args[0] == "PUSH") {
if (args.size() > 1) {
- this->SetError("PUSH may not be given additional arguments.");
+ status.SetError("PUSH may not be given additional arguments.");
return false;
}
- this->Makefile->PushPolicy();
+ status.GetMakefile().PushPolicy();
return true;
}
if (args[0] == "POP") {
if (args.size() > 1) {
- this->SetError("POP may not be given additional arguments.");
+ status.SetError("POP may not be given additional arguments.");
return false;
}
- this->Makefile->PopPolicy();
+ status.GetMakefile().PopPolicy();
return true;
}
if (args[0] == "VERSION") {
- return this->HandleVersionMode(args);
+ return HandleVersionMode(args, status);
+ }
+ if (args[0] == "GET_WARNING") {
+ return HandleGetWarningMode(args, status);
}
- std::ostringstream e;
- e << "given unknown first argument \"" << args[0] << "\"";
- this->SetError(e.str());
+ status.SetError(cmStrCat("given unknown first argument \"", args[0], "\""));
return false;
}
-bool cmCMakePolicyCommand::HandleSetMode(std::vector<std::string> const& args)
+namespace {
+
+bool HandleSetMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
- this->SetError("SET must be given exactly 2 additional arguments.");
+ status.SetError("SET must be given exactly 2 additional arguments.");
return false;
}
- cmPolicies::PolicyStatus status;
+ cmPolicies::PolicyStatus policyStatus;
if (args[2] == "OLD") {
- status = cmPolicies::OLD;
+ policyStatus = cmPolicies::OLD;
} else if (args[2] == "NEW") {
- status = cmPolicies::NEW;
+ policyStatus = cmPolicies::NEW;
} else {
- std::ostringstream e;
- e << "SET given unrecognized policy status \"" << args[2] << "\"";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("SET given unrecognized policy status \"", args[2], "\""));
return false;
}
- if (!this->Makefile->SetPolicy(args[1].c_str(), status)) {
- this->SetError("SET failed to set policy.");
+ if (!status.GetMakefile().SetPolicy(args[1].c_str(), policyStatus)) {
+ status.SetError("SET failed to set policy.");
return false;
}
if (args[1] == "CMP0001" &&
- (status == cmPolicies::WARN || status == cmPolicies::OLD)) {
- if (!(this->Makefile->GetState()->GetInitializedCacheValue(
+ (policyStatus == cmPolicies::WARN || policyStatus == cmPolicies::OLD)) {
+ if (!(status.GetMakefile().GetState()->GetInitializedCacheValue(
"CMAKE_BACKWARDS_COMPATIBILITY"))) {
// Set it to 2.4 because that is the last version where the
// variable had meaning.
- this->Makefile->AddCacheDefinition(
+ status.GetMakefile().AddCacheDefinition(
"CMAKE_BACKWARDS_COMPATIBILITY", "2.4",
"For backwards compatibility, what version of CMake "
"commands and "
@@ -93,10 +105,15 @@ bool cmCMakePolicyCommand::HandleSetMode(std::vector<std::string> const& args)
return true;
}
-bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
+bool HandleGetMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- if (args.size() != 3) {
- this->SetError("GET must be given exactly 2 additional arguments.");
+ bool parent_scope = false;
+ if (args.size() == 4 && args[3] == "PARENT_SCOPE") {
+ // Undocumented PARENT_SCOPE option for use within CMake.
+ parent_scope = true;
+ } else if (args.size() != 3) {
+ status.SetError("GET must be given exactly 2 additional arguments.");
return false;
}
@@ -107,55 +124,102 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
// Lookup the policy number.
cmPolicies::PolicyID pid;
if (!cmPolicies::GetPolicyID(id.c_str(), pid)) {
- std::ostringstream e;
- e << "GET given policy \"" << id << "\" which is not known to this "
- << "version of CMake.";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("GET given policy \"", id,
+ "\" which is not known to this version of CMake."));
return false;
}
// Lookup the policy setting.
- cmPolicies::PolicyStatus status = this->Makefile->GetPolicyStatus(pid);
- switch (status) {
+ cmPolicies::PolicyStatus policyStatus =
+ status.GetMakefile().GetPolicyStatus(pid, parent_scope);
+ switch (policyStatus) {
case cmPolicies::OLD:
// Report that the policy is set to OLD.
- this->Makefile->AddDefinition(var, "OLD");
+ status.GetMakefile().AddDefinition(var, "OLD");
break;
case cmPolicies::WARN:
// Report that the policy is not set.
- this->Makefile->AddDefinition(var, "");
+ status.GetMakefile().AddDefinition(var, "");
break;
case cmPolicies::NEW:
// Report that the policy is set to NEW.
- this->Makefile->AddDefinition(var, "NEW");
+ status.GetMakefile().AddDefinition(var, "NEW");
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
// The policy is required to be set before anything needs it.
{
- std::ostringstream e;
- e << cmPolicies::GetRequiredPolicyError(pid) << "\n"
- << "The call to cmake_policy(GET " << id << " ...) at which this "
- << "error appears requests the policy, and this version of CMake "
- << "requires that the policy be set to NEW before it is checked.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ cmPolicies::GetRequiredPolicyError(pid), "\n",
+ "The call to cmake_policy(GET ", id,
+ " ...) at which this "
+ "error appears requests the policy, and this version of CMake ",
+ "requires that the policy be set to NEW before it is checked."));
}
}
return true;
}
-bool cmCMakePolicyCommand::HandleVersionMode(
- std::vector<std::string> const& args)
+bool HandleVersionMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() <= 1) {
- this->SetError("VERSION not given an argument");
+ status.SetError("VERSION not given an argument");
return false;
}
if (args.size() >= 3) {
- this->SetError("VERSION given too many arguments");
+ status.SetError("VERSION given too many arguments");
+ return false;
+ }
+ std::string const& version_string = args[1];
+
+ // Separate the <min> version and any trailing ...<max> component.
+ std::string::size_type const dd = version_string.find("...");
+ std::string const version_min = version_string.substr(0, dd);
+ std::string const version_max = dd != std::string::npos
+ ? version_string.substr(dd + 3, std::string::npos)
+ : std::string();
+ if (dd != std::string::npos &&
+ (version_min.empty() || version_max.empty())) {
+ status.SetError(
+ cmStrCat("VERSION \"", version_string,
+ R"(" does not have a version on both sides of "...".)"));
return false;
}
- this->Makefile->SetPolicyVersion(args[1].c_str());
+
+ status.GetMakefile().SetPolicyVersion(version_min, version_max);
return true;
}
+
+bool HandleGetWarningMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() != 3) {
+ status.SetError(
+ "GET_WARNING must be given exactly 2 additional arguments.");
+ return false;
+ }
+
+ // Get arguments.
+ std::string const& id = args[1];
+ std::string const& var = args[2];
+
+ // Lookup the policy number.
+ cmPolicies::PolicyID pid;
+ if (!cmPolicies::GetPolicyID(id.c_str(), pid)) {
+ status.SetError(
+ cmStrCat("GET_WARNING given policy \"", id,
+ "\" which is not known to this version of CMake."));
+ return false;
+ }
+
+ // Lookup the policy warning.
+ status.GetMakefile().AddDefinition(var, cmPolicies::GetPolicyWarning(pid));
+
+ return true;
+}
+}
diff --git a/Source/cmCMakePolicyCommand.h b/Source/cmCMakePolicyCommand.h
index 0e88243f5..ba9397d76 100644
--- a/Source/cmCMakePolicyCommand.h
+++ b/Source/cmCMakePolicyCommand.h
@@ -3,40 +3,20 @@
#ifndef cmCMakePolicyCommand_h
#define cmCMakePolicyCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmCMakePolicyCommand
+/**
* \brief Set how CMake should handle policies
*
* cmCMakePolicyCommand sets how CMake should deal with backwards
* compatibility policies.
*/
-class cmCMakePolicyCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmCMakePolicyCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- bool HandleSetMode(std::vector<std::string> const& args);
- bool HandleGetMode(std::vector<std::string> const& args);
- bool HandleVersionMode(std::vector<std::string> const& args);
-};
+bool cmCMakePolicyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmCPackPropertiesGenerator.cxx b/Source/cmCPackPropertiesGenerator.cxx
index 57a8b383c..cc9ad0103 100644
--- a/Source/cmCPackPropertiesGenerator.cxx
+++ b/Source/cmCPackPropertiesGenerator.cxx
@@ -1,13 +1,12 @@
#include "cmCPackPropertiesGenerator.h"
+#include <map>
+#include <ostream>
+
#include "cmGeneratorExpression.h"
#include "cmInstalledFile.h"
#include "cmOutputConverter.h"
-#include <map>
-#include <ostream>
-#include <utility>
-
cmCPackPropertiesGenerator::cmCPackPropertiesGenerator(
cmLocalGenerator* lg, cmInstalledFile const& installedFile,
std::vector<std::string> const& configurations)
@@ -27,19 +26,17 @@ void cmCPackPropertiesGenerator::GenerateScriptForConfig(
cmInstalledFile::PropertyMapType const& properties =
this->InstalledFile.GetProperties();
- for (cmInstalledFile::PropertyMapType::const_iterator i = properties.begin();
- i != properties.end(); ++i) {
- std::string const& name = i->first;
- cmInstalledFile::Property const& property = i->second;
+ for (cmInstalledFile::PropertyMapType::value_type const& i : properties) {
+ std::string const& name = i.first;
+ cmInstalledFile::Property const& property = i.second;
os << indent << "set_property(INSTALL "
<< cmOutputConverter::EscapeForCMake(expandedFileName) << " PROPERTY "
<< cmOutputConverter::EscapeForCMake(name);
- for (cmInstalledFile::ExpressionVectorType::const_iterator j =
- property.ValueExpressions.begin();
- j != property.ValueExpressions.end(); ++j) {
- std::string value = (*j)->Evaluate(this->LG, config);
+ for (cmInstalledFile::ExpressionVectorType::value_type const& j :
+ property.ValueExpressions) {
+ std::string value = j->Evaluate(this->LG, config);
os << " " << cmOutputConverter::EscapeForCMake(value);
}
diff --git a/Source/cmCPackPropertiesGenerator.h b/Source/cmCPackPropertiesGenerator.h
index 48f4c10f4..83392383a 100644
--- a/Source/cmCPackPropertiesGenerator.h
+++ b/Source/cmCPackPropertiesGenerator.h
@@ -3,14 +3,14 @@
#ifndef cmCPackPropertiesGenerator_h
#define cmCPackPropertiesGenerator_h
-#include "cmConfigure.h"
-
-#include "cmScriptGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
#include <vector>
+#include "cmScriptGenerator.h"
+
class cmInstalledFile;
class cmLocalGenerator;
@@ -20,16 +20,18 @@ class cmLocalGenerator;
*/
class cmCPackPropertiesGenerator : public cmScriptGenerator
{
- CM_DISABLE_COPY(cmCPackPropertiesGenerator)
-
public:
cmCPackPropertiesGenerator(cmLocalGenerator* lg,
cmInstalledFile const& installedFile,
std::vector<std::string> const& configurations);
+ cmCPackPropertiesGenerator(cmCPackPropertiesGenerator const&) = delete;
+ cmCPackPropertiesGenerator& operator=(cmCPackPropertiesGenerator const&) =
+ delete;
+
protected:
void GenerateScriptForConfig(std::ostream& os, const std::string& config,
- Indent indent) CM_OVERRIDE;
+ Indent indent) override;
cmLocalGenerator* LG;
cmInstalledFile const& InstalledFile;
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index e78f5fe04..177bca889 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -7,6 +7,8 @@
#include "cmCPluginAPI.h"
+#include <cstdlib>
+
#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
@@ -14,10 +16,8 @@
#include "cmState.h"
#include "cmVersion.h"
-#include <stdlib.h>
-
#ifdef __QNX__
-#include <malloc.h> /* for malloc/free on QNX */
+# include <malloc.h> /* for malloc/free on QNX */
#endif
extern "C" {
@@ -65,8 +65,10 @@ unsigned int CCONV cmGetMinorVersion(void*)
void CCONV cmAddDefinition(void* arg, const char* name, const char* value)
{
- cmMakefile* mf = static_cast<cmMakefile*>(arg);
- mf->AddDefinition(name, value);
+ if (value) {
+ cmMakefile* mf = static_cast<cmMakefile*>(arg);
+ mf->AddDefinition(name, value);
+ }
}
/* Add a definition to this makefile and the global cmake cache. */
@@ -108,32 +110,32 @@ const char* CCONV cmGetProjectName(void* arg)
const char* CCONV cmGetHomeDirectory(void* arg)
{
cmMakefile* mf = static_cast<cmMakefile*>(arg);
- return mf->GetHomeDirectory();
+ return mf->GetHomeDirectory().c_str();
}
const char* CCONV cmGetHomeOutputDirectory(void* arg)
{
cmMakefile* mf = static_cast<cmMakefile*>(arg);
- return mf->GetHomeOutputDirectory();
+ return mf->GetHomeOutputDirectory().c_str();
}
const char* CCONV cmGetStartDirectory(void* arg)
{
cmMakefile* mf = static_cast<cmMakefile*>(arg);
- return mf->GetCurrentSourceDirectory();
+ return mf->GetCurrentSourceDirectory().c_str();
}
const char* CCONV cmGetStartOutputDirectory(void* arg)
{
cmMakefile* mf = static_cast<cmMakefile*>(arg);
- return mf->GetCurrentBinaryDirectory();
+ return mf->GetCurrentBinaryDirectory().c_str();
}
const char* CCONV cmGetCurrentDirectory(void* arg)
{
cmMakefile* mf = static_cast<cmMakefile*>(arg);
- return mf->GetCurrentSourceDirectory();
+ return mf->GetCurrentSourceDirectory().c_str();
}
const char* CCONV cmGetCurrentOutputDirectory(void* arg)
{
cmMakefile* mf = static_cast<cmMakefile*>(arg);
- return mf->GetCurrentBinaryDirectory();
+ return mf->GetCurrentBinaryDirectory().c_str();
}
const char* CCONV cmGetDefinition(void* arg, const char* def)
{
@@ -167,11 +169,11 @@ void CCONV cmAddLinkDirectoryForTarget(void* arg, const char* tgt,
cmTarget* t = mf->FindLocalNonAliasTarget(tgt);
if (!t) {
cmSystemTools::Error(
- "Attempt to add link directories to non-existent target: ", tgt,
- " for directory ", d);
+ "Attempt to add link directories to non-existent target: " +
+ std::string(tgt) + " for directory " + std::string(d));
return;
}
- t->AddLinkDirectory(d);
+ t->InsertLinkDirectory(d, mf->GetBacktrace());
}
void CCONV cmAddExecutable(void* arg, const char* exename, int numSrcs,
@@ -181,7 +183,7 @@ void CCONV cmAddExecutable(void* arg, const char* exename, int numSrcs,
std::vector<std::string> srcs2;
int i;
for (i = 0; i < numSrcs; ++i) {
- srcs2.push_back(srcs[i]);
+ srcs2.emplace_back(srcs[i]);
}
cmTarget* tg = mf->AddExecutable(exename, srcs2);
if (win32) {
@@ -218,8 +220,10 @@ void CCONV cmAddUtilityCommand(void* arg, const char* utilityName,
}
// Pass the call to the makefile instance.
- mf->AddUtilityCommand(utilityName, (all ? false : true), CM_NULLPTR,
- depends2, commandLines);
+ std::vector<std::string> no_byproducts;
+ mf->AddUtilityCommand(utilityName, cmCommandOrigin::Project,
+ (all ? false : true), nullptr, no_byproducts, depends2,
+ commandLines);
}
void CCONV cmAddCustomCommand(void* arg, const char* source,
const char* command, int numArgs,
@@ -257,7 +261,7 @@ void CCONV cmAddCustomCommand(void* arg, const char* source,
}
// Pass the call to the makefile instance.
- const char* no_comment = CM_NULLPTR;
+ const char* no_comment = nullptr;
mf->AddCustomCommandOldStyle(target, outputs2, depends2, source,
commandLines, no_comment);
}
@@ -291,8 +295,8 @@ void CCONV cmAddCustomCommandToOutput(void* arg, const char* output,
}
// Pass the call to the makefile instance.
- const char* no_comment = CM_NULLPTR;
- const char* no_working_dir = CM_NULLPTR;
+ const char* no_comment = nullptr;
+ const char* no_working_dir = nullptr;
mf->AddCustomCommandToOutput(output, depends2, main_dependency, commandLines,
no_comment, no_working_dir);
}
@@ -317,24 +321,24 @@ void CCONV cmAddCustomCommandToTarget(void* arg, const char* target,
commandLines.push_back(commandLine);
// Select the command type.
- cmTarget::CustomCommandType cctype = cmTarget::POST_BUILD;
+ cmCustomCommandType cctype = cmCustomCommandType::POST_BUILD;
switch (commandType) {
case CM_PRE_BUILD:
- cctype = cmTarget::PRE_BUILD;
+ cctype = cmCustomCommandType::PRE_BUILD;
break;
case CM_PRE_LINK:
- cctype = cmTarget::PRE_LINK;
+ cctype = cmCustomCommandType::PRE_LINK;
break;
case CM_POST_BUILD:
- cctype = cmTarget::POST_BUILD;
+ cctype = cmCustomCommandType::POST_BUILD;
break;
}
// Pass the call to the makefile instance.
std::vector<std::string> no_byproducts;
std::vector<std::string> no_depends;
- const char* no_comment = CM_NULLPTR;
- const char* no_working_dir = CM_NULLPTR;
+ const char* no_comment = nullptr;
+ const char* no_working_dir = nullptr;
mf->AddCustomCommandToTarget(target, no_byproducts, no_depends, commandLines,
cctype, no_comment, no_working_dir);
}
@@ -347,7 +351,7 @@ static void addLinkLibrary(cmMakefile* mf, std::string const& target,
std::ostringstream e;
e << "Attempt to add link library \"" << lib << "\" to target \"" << target
<< "\" which is not built in this directory.";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
@@ -362,7 +366,7 @@ static void addLinkLibrary(cmMakefile* mf, std::string const& target,
<< " may not be linked into another target. "
<< "One may link only to STATIC or SHARED libraries, or "
<< "to executables with the ENABLE_EXPORTS property set.";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
}
t->AddLinkLibrary(*mf, lib, llt);
@@ -393,11 +397,12 @@ void CCONV cmAddLibrary(void* arg, const char* libname, int shared,
std::vector<std::string> srcs2;
int i;
for (i = 0; i < numSrcs; ++i) {
- srcs2.push_back(srcs[i]);
+ srcs2.emplace_back(srcs[i]);
}
- mf->AddLibrary(libname, (shared ? cmStateEnums::SHARED_LIBRARY
- : cmStateEnums::STATIC_LIBRARY),
- srcs2);
+ mf->AddLibrary(
+ libname,
+ (shared ? cmStateEnums::SHARED_LIBRARY : cmStateEnums::STATIC_LIBRARY),
+ srcs2);
}
char CCONV* cmExpandVariablesInString(void* arg, const char* source,
@@ -405,14 +410,9 @@ char CCONV* cmExpandVariablesInString(void* arg, const char* source,
{
cmMakefile* mf = static_cast<cmMakefile*>(arg);
std::string barf = source;
- std::string result = mf->ExpandVariablesInString(
- barf, (escapeQuotes ? true : false), (atOnly ? true : false));
- char* res = static_cast<char*>(malloc(result.size() + 1));
- if (!result.empty()) {
- strcpy(res, result.c_str());
- }
- res[result.size()] = '\0';
- return res;
+ std::string const& result =
+ mf->ExpandVariablesInString(barf, escapeQuotes != 0, atOnly != 0);
+ return strdup(result.c_str());
}
int CCONV cmExecuteCommand(void* arg, const char* name, int numArgs,
@@ -423,10 +423,9 @@ int CCONV cmExecuteCommand(void* arg, const char* name, int numArgs,
lff.Name = name;
for (int i = 0; i < numArgs; ++i) {
// Assume all arguments are quoted.
- lff.Arguments.push_back(
- cmListFileArgument(args[i], cmListFileArgument::Quoted, 0));
+ lff.Arguments.emplace_back(args[i], cmListFileArgument::Quoted, 0);
}
- cmExecutionStatus status;
+ cmExecutionStatus status(*mf);
return mf->ExecuteCommand(lff, status);
}
@@ -440,10 +439,10 @@ void CCONV cmExpandSourceListArguments(void* arg, int numArgs,
std::vector<std::string> result;
int i;
for (i = 0; i < numArgs; ++i) {
- result.push_back(args[i]);
+ result.emplace_back(args[i]);
}
int resargc = static_cast<int>(result.size());
- char** resargv = CM_NULLPTR;
+ char** resargv = nullptr;
if (resargc) {
resargv = (char**)malloc(resargc * sizeof(char*));
}
@@ -460,9 +459,7 @@ void CCONV cmFreeArguments(int argc, char** argv)
for (i = 0; i < argc; ++i) {
free(argv[i]);
}
- if (argv) {
- free(argv);
- }
+ free(argv);
}
int CCONV cmGetTotalArgumentSize(int argc, char** argv)
@@ -481,11 +478,7 @@ int CCONV cmGetTotalArgumentSize(int argc, char** argv)
// API for source files.
struct cmCPluginAPISourceFile
{
- cmCPluginAPISourceFile()
- : RealSourceFile(CM_NULLPTR)
- {
- }
- cmSourceFile* RealSourceFile;
+ cmSourceFile* RealSourceFile = nullptr;
std::string SourceName;
std::string SourceExtension;
std::string FullPath;
@@ -499,27 +492,30 @@ class cmCPluginAPISourceFileMap
: public std::map<cmSourceFile*, cmCPluginAPISourceFile*>
{
public:
- typedef std::map<cmSourceFile*, cmCPluginAPISourceFile*> derived;
- typedef derived::iterator iterator;
- typedef derived::value_type value_type;
+ using derived = std::map<cmSourceFile*, cmCPluginAPISourceFile*>;
+ using iterator = derived::iterator;
+ using value_type = derived::value_type;
+ cmCPluginAPISourceFileMap() = default;
~cmCPluginAPISourceFileMap()
{
- for (iterator i = this->begin(); i != this->end(); ++i) {
- delete i->second;
+ for (auto const& i : *this) {
+ delete i.second;
}
}
+ cmCPluginAPISourceFileMap(const cmCPluginAPISourceFileMap&) = delete;
+ cmCPluginAPISourceFileMap& operator=(const cmCPluginAPISourceFileMap&) =
+ delete;
};
cmCPluginAPISourceFileMap cmCPluginAPISourceFiles;
void* CCONV cmCreateSourceFile(void)
{
- return (void*)new cmCPluginAPISourceFile;
+ return new cmCPluginAPISourceFile;
}
void* CCONV cmCreateNewSourceFile(void*)
{
- cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile;
- return (void*)sf;
+ return new cmCPluginAPISourceFile;
}
void CCONV cmDestroySourceFile(void* arg)
@@ -537,12 +533,12 @@ void CCONV* cmGetSource(void* arg, const char* name)
cmMakefile* mf = static_cast<cmMakefile*>(arg);
if (cmSourceFile* rsf = mf->GetSource(name)) {
// Lookup the proxy source file object for this source.
- cmCPluginAPISourceFileMap::iterator i = cmCPluginAPISourceFiles.find(rsf);
+ auto i = cmCPluginAPISourceFiles.find(rsf);
if (i == cmCPluginAPISourceFiles.end()) {
// Create a proxy source file object for this source.
cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile;
sf->RealSourceFile = rsf;
- sf->FullPath = rsf->GetFullPath();
+ sf->FullPath = rsf->ResolveFullPath();
sf->SourceName =
cmSystemTools::GetFilenameWithoutLastExtension(sf->FullPath);
sf->SourceExtension =
@@ -552,9 +548,9 @@ void CCONV* cmGetSource(void* arg, const char* name)
cmCPluginAPISourceFileMap::value_type entry(rsf, sf);
i = cmCPluginAPISourceFiles.insert(entry).first;
}
- return (void*)i->second;
+ return i->second;
}
- return CM_NULLPTR;
+ return nullptr;
}
void* CCONV cmAddSource(void* arg, void* arg2)
@@ -562,15 +558,14 @@ void* CCONV cmAddSource(void* arg, void* arg2)
cmMakefile* mf = static_cast<cmMakefile*>(arg);
cmCPluginAPISourceFile* osf = static_cast<cmCPluginAPISourceFile*>(arg2);
if (osf->FullPath.empty()) {
- return CM_NULLPTR;
+ return nullptr;
}
// Create the real cmSourceFile instance and copy over saved information.
cmSourceFile* rsf = mf->GetOrCreateSource(osf->FullPath);
- rsf->GetProperties() = osf->Properties;
- for (std::vector<std::string>::iterator i = osf->Depends.begin();
- i != osf->Depends.end(); ++i) {
- rsf->AddDepend(*i);
+ rsf->SetProperties(osf->Properties);
+ for (std::string const& d : osf->Depends) {
+ rsf->AddDepend(d);
}
// Create the proxy for the real source file.
@@ -582,7 +577,7 @@ void* CCONV cmAddSource(void* arg, void* arg2)
// Store the proxy in the map so it can be re-used and deleted later.
cmCPluginAPISourceFiles[rsf] = sf;
- return (void*)sf;
+ return sf;
}
const char* CCONV cmSourceFileGetSourceName(void* arg)
@@ -615,7 +610,7 @@ int CCONV cmSourceFileGetPropertyAsBool(void* arg, const char* prop)
if (cmSourceFile* rsf = sf->RealSourceFile) {
return rsf->GetPropertyAsBool(prop) ? 1 : 0;
}
- return cmSystemTools::IsOn(cmSourceFileGetProperty(arg, prop)) ? 1 : 0;
+ return cmIsOn(cmSourceFileGetProperty(arg, prop)) ? 1 : 0;
}
void CCONV cmSourceFileSetProperty(void* arg, const char* prop,
@@ -638,7 +633,7 @@ void CCONV cmSourceFileAddDepend(void* arg, const char* depend)
if (cmSourceFile* rsf = sf->RealSourceFile) {
rsf->AddDepend(depend);
} else {
- sf->Depends.push_back(depend);
+ sf->Depends.emplace_back(depend);
}
}
@@ -658,10 +653,10 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
std::vector<std::string> headerExts;
int i;
for (i = 0; i < numSourceExtensions; ++i) {
- sourceExts.push_back(sourceExtensions[i]);
+ sourceExts.emplace_back(sourceExtensions[i]);
}
for (i = 0; i < numHeaderExtensions; ++i) {
- headerExts.push_back(headerExtensions[i]);
+ headerExts.emplace_back(headerExtensions[i]);
}
// Save the original name given.
@@ -674,7 +669,7 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
// First try and see whether the listed file can be found
// as is without extensions added on.
std::string hname = pathname;
- if (cmSystemTools::FileExists(hname.c_str())) {
+ if (cmSystemTools::FileExists(hname)) {
sf->SourceName = cmSystemTools::GetFilenamePath(name);
if (!sf->SourceName.empty()) {
sf->SourceName += "/";
@@ -696,26 +691,20 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
}
// Next, try the various source extensions
- for (std::vector<std::string>::const_iterator ext = sourceExts.begin();
- ext != sourceExts.end(); ++ext) {
- hname = pathname;
- hname += ".";
- hname += *ext;
- if (cmSystemTools::FileExists(hname.c_str())) {
- sf->SourceExtension = *ext;
+ for (std::string const& ext : sourceExts) {
+ hname = cmStrCat(pathname, '.', ext);
+ if (cmSystemTools::FileExists(hname)) {
+ sf->SourceExtension = ext;
sf->FullPath = hname;
return;
}
}
// Finally, try the various header extensions
- for (std::vector<std::string>::const_iterator ext = headerExts.begin();
- ext != headerExts.end(); ++ext) {
- hname = pathname;
- hname += ".";
- hname += *ext;
- if (cmSystemTools::FileExists(hname.c_str())) {
- sf->SourceExtension = *ext;
+ for (std::string const& ext : headerExts) {
+ hname = cmStrCat(pathname, '.', ext);
+ if (cmSystemTools::FileExists(hname)) {
+ sf->SourceExtension = ext;
sf->FullPath = hname;
return;
}
@@ -724,15 +713,13 @@ void CCONV cmSourceFileSetName(void* arg, const char* name, const char* dir,
std::ostringstream e;
e << "Cannot find source file \"" << pathname << "\"";
e << "\n\nTried extensions";
- for (std::vector<std::string>::const_iterator ext = sourceExts.begin();
- ext != sourceExts.end(); ++ext) {
- e << " ." << *ext;
+ for (std::string const& ext : sourceExts) {
+ e << " ." << ext;
}
- for (std::vector<std::string>::const_iterator ext = headerExts.begin();
- ext != headerExts.end(); ++ext) {
- e << " ." << *ext;
+ for (std::string const& ext : headerExts) {
+ e << " ." << ext;
}
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
}
void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir,
@@ -763,25 +750,19 @@ void CCONV cmSourceFileSetName2(void* arg, const char* name, const char* dir,
char* CCONV cmGetFilenameWithoutExtension(const char* name)
{
std::string sres = cmSystemTools::GetFilenameWithoutExtension(name);
- char* result = (char*)malloc(sres.size() + 1);
- strcpy(result, sres.c_str());
- return result;
+ return strdup(sres.c_str());
}
char* CCONV cmGetFilenamePath(const char* name)
{
std::string sres = cmSystemTools::GetFilenamePath(name);
- char* result = (char*)malloc(sres.size() + 1);
- strcpy(result, sres.c_str());
- return result;
+ return strdup(sres.c_str());
}
char* CCONV cmCapitalized(const char* name)
{
std::string sres = cmSystemTools::Capitalized(name);
- char* result = (char*)malloc(sres.size() + 1);
- strcpy(result, sres.c_str());
- return result;
+ return strdup(sres.c_str());
}
void CCONV cmCopyFileIfDifferent(const char* name1, const char* name2)
diff --git a/Source/cmCPluginAPI.h b/Source/cmCPluginAPI.h
index 88b81c6c1..6a9514869 100644
--- a/Source/cmCPluginAPI.h
+++ b/Source/cmCPluginAPI.h
@@ -19,15 +19,16 @@ extern "C" {
#endif
#ifdef __WATCOMC__
-#define CCONV __cdecl
+# define CCONV __cdecl
#else
-#define CCONV
+# define CCONV
#endif
/*=========================================================================
this is the structure of function entry points that a plugin may call. This
structure must be kept in sync with the static decaled at the bottom of
cmCPLuginAPI.cxx
=========================================================================*/
+/* NOLINTNEXTLINE(modernize-use-using) */
typedef struct
{
/*=========================================================================
@@ -161,9 +162,9 @@ typedef struct
CM_PLUGIN_EXPORT should be used by plugins
=========================================================================*/
#ifdef _WIN32
-#define CM_PLUGIN_EXPORT __declspec(dllexport)
+# define CM_PLUGIN_EXPORT __declspec(dllexport)
#else
-#define CM_PLUGIN_EXPORT
+# define CM_PLUGIN_EXPORT
#endif
/*=========================================================================
@@ -194,12 +195,21 @@ define the different types of custom commands for a target
/*=========================================================================
Finally we define the key data structures and function prototypes
=========================================================================*/
+
+/* NOLINTNEXTLINE(modernize-use-using) */
typedef const char*(CCONV* CM_DOC_FUNCTION)();
+
+/* NOLINTNEXTLINE(modernize-use-using) */
typedef int(CCONV* CM_INITIAL_PASS_FUNCTION)(void* info, void* mf, int argc,
char* []);
+
+/* NOLINTNEXTLINE(modernize-use-using) */
typedef void(CCONV* CM_FINAL_PASS_FUNCTION)(void* info, void* mf);
+
+/* NOLINTNEXTLINE(modernize-use-using) */
typedef void(CCONV* CM_DESTRUCTOR_FUNCTION)(void* info);
+/* NOLINTNEXTLINE(modernize-use-using) */
typedef struct
{
unsigned long reserved1; /* Reserved for future use. DO NOT USE. */
@@ -216,6 +226,7 @@ typedef struct
void* ClientData;
} cmLoadedCommandInfo;
+/* NOLINTNEXTLINE(modernize-use-using) */
typedef void(CCONV* CM_INIT_FUNCTION)(cmLoadedCommandInfo*);
#ifdef __cplusplus
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index e2605561a..6eae26e4c 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2,27 +2,37 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTest.h"
-#include "cm_curl.h"
-#include "cm_zlib.h"
-#include "cmsys/Base64.h"
-#include "cmsys/Directory.hxx"
-#include "cmsys/FStream.hxx"
-#include "cmsys/Glob.hxx"
-#include "cmsys/Process.h"
-#include "cmsys/String.hxx"
-#include "cmsys/SystemInformation.hxx"
-#include <ctype.h>
+#include <algorithm>
+#include <cctype>
+#include <chrono>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
#include <iostream>
#include <map>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <string>
-#include <time.h>
#include <utility>
#include <vector>
+#include "cmsys/Base64.h"
+#include "cmsys/Directory.hxx"
+#include "cmsys/FStream.hxx"
+#include "cmsys/Glob.hxx"
+#include "cmsys/Process.h"
+#include "cmsys/SystemInformation.hxx"
+
+#include "cm_curl.h"
+#include "cm_zlib.h"
+#if defined(_WIN32)
+# include <windows.h> // IWYU pragma: keep
+#else
+# include <unistd.h> // IWYU pragma: keep
+#endif
+
+#include <cm/memory>
+
#include "cmAlgorithms.h"
#include "cmCTestBuildAndTestHandler.h"
#include "cmCTestBuildHandler.h"
@@ -36,7 +46,6 @@
#include "cmCTestTestHandler.h"
#include "cmCTestUpdateHandler.h"
#include "cmCTestUploadHandler.h"
-#include "cmCurl.h"
#include "cmDynamicLoader.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
@@ -45,37 +54,175 @@
#include "cmState.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
#include "cmVersionConfig.h"
#include "cmXMLWriter.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
#if defined(__BEOS__) || defined(__HAIKU__)
-#include <be/kernel/OS.h> /* disable_debugger() API. */
+# include <be/kernel/OS.h> /* disable_debugger() API. */
#endif
-#define DEBUGOUT \
- std::cout << __LINE__ << " "; \
- std::cout
-#define DEBUGERR \
- std::cerr << __LINE__ << " "; \
- std::cerr
+struct cmCTest::Private
+{
+ /** Representation of one part. */
+ struct PartInfo
+ {
+ void SetName(const std::string& name) { this->Name = name; }
+ const std::string& GetName() const { return this->Name; }
+
+ void Enable() { this->Enabled = true; }
+ explicit operator bool() const { return this->Enabled; }
+
+ std::vector<std::string> SubmitFiles;
+
+ private:
+ bool Enabled = false;
+ std::string Name;
+ };
+
+ int RepeatTests = 1; // default to run each test once
+ bool RepeatUntilFail = false;
+ std::string ConfigType;
+ std::string ScheduleType;
+ std::chrono::system_clock::time_point StopTime;
+ bool TestProgressOutput = false;
+ bool Verbose = false;
+ bool ExtraVerbose = false;
+ bool ProduceXML = false;
+ bool LabelSummary = true;
+ bool SubprojectSummary = true;
+ bool UseHTTP10 = false;
+ bool PrintLabels = false;
+ bool Failover = false;
+
+ bool FlushTestProgressLine = false;
+
+ bool ForceNewCTestProcess = false;
+
+ bool RunConfigurationScript = false;
+
+ // these are helper classes
+ cmCTestBuildHandler BuildHandler;
+ cmCTestBuildAndTestHandler BuildAndTestHandler;
+ cmCTestCoverageHandler CoverageHandler;
+ cmCTestScriptHandler ScriptHandler;
+ cmCTestTestHandler TestHandler;
+ cmCTestUpdateHandler UpdateHandler;
+ cmCTestConfigureHandler ConfigureHandler;
+ cmCTestMemCheckHandler MemCheckHandler;
+ cmCTestSubmitHandler SubmitHandler;
+ cmCTestUploadHandler UploadHandler;
+
+ std::vector<cmCTestGenericHandler*> GetTestingHandlers()
+ {
+ return { &this->BuildHandler, &this->BuildAndTestHandler,
+ &this->CoverageHandler, &this->ScriptHandler,
+ &this->TestHandler, &this->UpdateHandler,
+ &this->ConfigureHandler, &this->MemCheckHandler,
+ &this->SubmitHandler, &this->UploadHandler };
+ }
+
+ std::map<std::string, cmCTestGenericHandler*> GetNamedTestingHandlers()
+ {
+ return { { "build", &this->BuildHandler },
+ { "buildtest", &this->BuildAndTestHandler },
+ { "coverage", &this->CoverageHandler },
+ { "script", &this->ScriptHandler },
+ { "test", &this->TestHandler },
+ { "update", &this->UpdateHandler },
+ { "configure", &this->ConfigureHandler },
+ { "memcheck", &this->MemCheckHandler },
+ { "submit", &this->SubmitHandler },
+ { "upload", &this->UploadHandler } };
+ }
+
+ bool ShowOnly = false;
+ bool OutputAsJson = false;
+ int OutputAsJsonVersion = 1;
+
+ // TODO: The ctest configuration should be a hierarchy of
+ // configuration option sources: command-line, script, ini file.
+ // Then the ini file can get re-loaded whenever it changes without
+ // affecting any higher-precedence settings.
+ std::map<std::string, std::string> CTestConfiguration;
+ std::map<std::string, std::string> CTestConfigurationOverwrites;
+
+ PartInfo Parts[PartCount];
+ std::map<std::string, Part> PartMap;
+
+ std::string CurrentTag;
+ bool TomorrowTag = false;
+
+ int TestModel = cmCTest::EXPERIMENTAL;
+ std::string SpecificGroup;
+
+ cmDuration TimeOut = cmDuration::zero();
+
+ cmDuration GlobalTimeout = cmDuration::zero();
+
+ int MaxTestNameWidth = 30;
+
+ int ParallelLevel = 1;
+ bool ParallelLevelSetInCli = false;
+
+ unsigned long TestLoad = 0;
+
+ int CompatibilityMode;
+
+ // information for the --build-and-test options
+ std::string BinaryDir;
+
+ std::string NotesFiles;
+
+ bool InteractiveDebugMode = true;
+
+ bool ShortDateFormat = true;
+
+ bool CompressXMLFiles = false;
+ bool CompressTestOutput = true;
+
+ // By default we write output to the process output streams.
+ std::ostream* StreamOut = &std::cout;
+ std::ostream* StreamErr = &std::cerr;
+
+ bool SuppressUpdatingCTestConfiguration = false;
+
+ bool Debug = false;
+ bool ShowLineNumbers = false;
+ bool Quiet = false;
+
+ std::string BuildID;
+
+ std::vector<std::string> InitialCommandLineArguments;
+
+ int SubmitIndex = 0;
+
+ cmGeneratedFileStream* OutputLogFile = nullptr;
+ int OutputLogFileLastTag = -1;
+
+ bool OutputTestOutputOnTestFailure = false;
+ bool OutputColorCode = cmCTest::ColoredOutputSupportedByConsole();
+
+ std::map<std::string, std::string> Definitions;
+};
struct tm* cmCTest::GetNightlyTime(std::string const& str, bool tomorrowtag)
{
struct tm* lctime;
- time_t tctime = time(CM_NULLPTR);
+ time_t tctime = time(nullptr);
lctime = gmtime(&tctime);
char buf[1024];
// add todays year day and month to the time in str because
// curl_getdate no longer assumes the day is today
sprintf(buf, "%d%02d%02d %s", lctime->tm_year + 1900, lctime->tm_mon + 1,
lctime->tm_mday, str.c_str());
- cmCTestLog(this, OUTPUT, "Determine Nightly Start Time"
- << std::endl
- << " Specified time: " << str << std::endl);
+ cmCTestLog(this, OUTPUT,
+ "Determine Nightly Start Time" << std::endl
+ << " Specified time: " << str
+ << std::endl);
// Convert the nightly start time to seconds. Since we are
// providing only a time and a timezone, the current date of
// the local machine is assumed. Consequently, nightlySeconds
@@ -84,7 +231,7 @@ struct tm* cmCTest::GetNightlyTime(std::string const& str, bool tomorrowtag)
// As such, this time may be in the past or in the future.
time_t ntime = curl_getdate(buf, &tctime);
cmCTestLog(this, DEBUG, " Get curl time: " << ntime << std::endl);
- tctime = time(CM_NULLPTR);
+ tctime = time(nullptr);
cmCTestLog(this, DEBUG, " Get the current time: " << tctime << std::endl);
const int dayLength = 24 * 60 * 60;
@@ -97,16 +244,17 @@ struct tm* cmCTest::GetNightlyTime(std::string const& str, bool tomorrowtag)
// time of the current open dashboard
ntime -= dayLength;
cmCTestLog(this, DEBUG, "Pick yesterday" << std::endl);
- cmCTestLog(this, DEBUG, " Future time, subtract day: " << ntime
- << std::endl);
+ cmCTestLog(this, DEBUG,
+ " Future time, subtract day: " << ntime << std::endl);
}
while (tctime > (ntime + dayLength)) {
ntime += dayLength;
cmCTestLog(this, DEBUG, " Past time, add day: " << ntime << std::endl);
}
cmCTestLog(this, DEBUG, "nightlySeconds: " << ntime << std::endl);
- cmCTestLog(this, DEBUG, " Current time: " << tctime << " Nightly time: "
- << ntime << std::endl);
+ cmCTestLog(this, DEBUG,
+ " Current time: " << tctime << " Nightly time: " << ntime
+ << std::endl);
if (tomorrowtag) {
cmCTestLog(this, OUTPUT, " Use future tag, Add a day" << std::endl);
ntime += dayLength;
@@ -115,6 +263,11 @@ struct tm* cmCTest::GetNightlyTime(std::string const& str, bool tomorrowtag)
return lctime;
}
+bool cmCTest::GetTomorrowTag() const
+{
+ return this->Impl->TomorrowTag;
+}
+
std::string cmCTest::CleanString(const std::string& str)
{
std::string::size_type spos = str.find_first_not_of(" \n\t\r\f\v");
@@ -130,11 +283,11 @@ std::string cmCTest::CleanString(const std::string& str)
std::string cmCTest::CurrentTime()
{
- time_t currenttime = time(CM_NULLPTR);
+ time_t currenttime = time(nullptr);
struct tm* t = localtime(&currenttime);
// return ::CleanString(ctime(&currenttime));
char current_time[1024];
- if (this->ShortDateFormat) {
+ if (this->Impl->ShortDateFormat) {
strftime(current_time, 1000, "%b %d %H:%M %Z", t);
} else {
strftime(current_time, 1000, "%a %b %d %H:%M:%S %Z %Y", t);
@@ -146,101 +299,19 @@ std::string cmCTest::CurrentTime()
std::string cmCTest::GetCostDataFile()
{
std::string fname = this->GetCTestConfiguration("CostDataFile");
- if (fname == "") {
+ if (fname.empty()) {
fname = this->GetBinaryDir() + "/Testing/Temporary/CTestCostData.txt";
}
return fname;
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
-static size_t HTTPResponseCallback(void* ptr, size_t size, size_t nmemb,
- void* data)
-{
- int realsize = (int)(size * nmemb);
-
- std::string* response = static_cast<std::string*>(data);
- const char* chPtr = static_cast<char*>(ptr);
- *response += chPtr;
-
- return realsize;
-}
-
-int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
- std::string& response, std::string const& fields,
- std::string const& putFile, int timeout)
-{
- CURL* curl;
- FILE* file;
- ::curl_global_init(CURL_GLOBAL_ALL);
- curl = ::curl_easy_init();
- cmCurlSetCAInfo(curl);
-
- // set request options based on method
- switch (method) {
- case cmCTest::HTTP_POST:
- ::curl_easy_setopt(curl, CURLOPT_POST, 1);
- ::curl_easy_setopt(curl, CURLOPT_POSTFIELDS, fields.c_str());
- break;
- case cmCTest::HTTP_PUT:
- if (!cmSystemTools::FileExists(putFile.c_str())) {
- response = "Error: File ";
- response += putFile + " does not exist.\n";
- return -1;
- }
- ::curl_easy_setopt(curl, CURLOPT_PUT, 1);
- file = cmsys::SystemTools::Fopen(putFile, "rb");
- ::curl_easy_setopt(curl, CURLOPT_INFILE, file);
- // fall through to append GET fields
- case cmCTest::HTTP_GET:
- if (!fields.empty()) {
- url += "?" + fields;
- }
- break;
- }
-
- ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
- ::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
- ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
-
- // set response options
- ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HTTPResponseCallback);
- ::curl_easy_setopt(curl, CURLOPT_FILE, (void*)&response);
- ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
-
- CURLcode res = ::curl_easy_perform(curl);
-
- ::curl_easy_cleanup(curl);
- ::curl_global_cleanup();
-
- return static_cast<int>(res);
-}
-#endif
-
-std::string cmCTest::MakeURLSafe(const std::string& str)
-{
- std::ostringstream ost;
- char buffer[10];
- for (std::string::size_type pos = 0; pos < str.size(); pos++) {
- unsigned char ch = str[pos];
- if ((ch > 126 || ch < 32 || ch == '&' || ch == '%' || ch == '+' ||
- ch == '=' || ch == '@') &&
- ch != 9) {
- sprintf(buffer, "%02x;", (unsigned int)ch);
- ost << buffer;
- } else {
- ost << ch;
- }
- }
- return ost.str();
-}
-
std::string cmCTest::DecodeURL(const std::string& in)
{
std::string out;
for (const char* c = in.c_str(); *c; ++c) {
if (*c == '%' && isxdigit(*(c + 1)) && isxdigit(*(c + 2))) {
char buf[3] = { *(c + 1), *(c + 2), 0 };
- out.append(1, char(strtoul(buf, CM_NULLPTR, 16)));
+ out.append(1, char(strtoul(buf, nullptr, 16)));
c += 2;
} else {
out.append(1, *c);
@@ -250,88 +321,38 @@ std::string cmCTest::DecodeURL(const std::string& in)
}
cmCTest::cmCTest()
-{
- this->LabelSummary = true;
- this->ParallelLevel = 1;
- this->ParallelLevelSetInCli = false;
- this->TestLoad = 0;
- this->SubmitIndex = 0;
- this->Failover = false;
- this->BatchJobs = false;
- this->ForceNewCTestProcess = false;
- this->TomorrowTag = false;
- this->Verbose = false;
-
- this->Debug = false;
- this->ShowLineNumbers = false;
- this->Quiet = false;
- this->ExtraVerbose = false;
- this->ProduceXML = false;
- this->ShowOnly = false;
- this->RunConfigurationScript = false;
- this->UseHTTP10 = false;
- this->PrintLabels = false;
- this->CompressTestOutput = true;
- this->TestModel = cmCTest::EXPERIMENTAL;
- this->MaxTestNameWidth = 30;
- this->InteractiveDebugMode = true;
- this->TimeOut = 0;
- this->GlobalTimeout = 0;
- this->LastStopTimeout = 24 * 60 * 60;
- this->CompressXMLFiles = false;
- this->CTestConfigFile = "";
- this->ScheduleType = "";
- this->StopTime = "";
- this->NextDayStopTime = false;
- this->OutputLogFile = CM_NULLPTR;
- this->OutputLogFileLastTag = -1;
- this->SuppressUpdatingCTestConfiguration = false;
- this->DartVersion = 1;
- this->DropSiteCDash = false;
- this->OutputTestOutputOnTestFailure = false;
- this->RepeatTests = 1; // default to run each test once
- this->RepeatUntilFail = false;
- std::string outOnFail;
- if (cmSystemTools::GetEnv("CTEST_OUTPUT_ON_FAILURE", outOnFail)) {
- this->OutputTestOutputOnTestFailure =
- !cmSystemTools::IsOff(outOnFail.c_str());
- }
- this->InitStreams();
-
- this->Parts[PartStart].SetName("Start");
- this->Parts[PartUpdate].SetName("Update");
- this->Parts[PartConfigure].SetName("Configure");
- this->Parts[PartBuild].SetName("Build");
- this->Parts[PartTest].SetName("Test");
- this->Parts[PartCoverage].SetName("Coverage");
- this->Parts[PartMemCheck].SetName("MemCheck");
- this->Parts[PartSubmit].SetName("Submit");
- this->Parts[PartNotes].SetName("Notes");
- this->Parts[PartExtraFiles].SetName("ExtraFiles");
- this->Parts[PartUpload].SetName("Upload");
+ : Impl(new Private)
+{
+ std::string envValue;
+ if (cmSystemTools::GetEnv("CTEST_OUTPUT_ON_FAILURE", envValue)) {
+ this->Impl->OutputTestOutputOnTestFailure = !cmIsOff(envValue);
+ }
+ envValue.clear();
+ if (cmSystemTools::GetEnv("CTEST_PROGRESS_OUTPUT", envValue)) {
+ this->Impl->TestProgressOutput = !cmIsOff(envValue);
+ }
+
+ this->Impl->Parts[PartStart].SetName("Start");
+ this->Impl->Parts[PartUpdate].SetName("Update");
+ this->Impl->Parts[PartConfigure].SetName("Configure");
+ this->Impl->Parts[PartBuild].SetName("Build");
+ this->Impl->Parts[PartTest].SetName("Test");
+ this->Impl->Parts[PartCoverage].SetName("Coverage");
+ this->Impl->Parts[PartMemCheck].SetName("MemCheck");
+ this->Impl->Parts[PartSubmit].SetName("Submit");
+ this->Impl->Parts[PartNotes].SetName("Notes");
+ this->Impl->Parts[PartExtraFiles].SetName("ExtraFiles");
+ this->Impl->Parts[PartUpload].SetName("Upload");
+ this->Impl->Parts[PartDone].SetName("Done");
// Fill the part name-to-id map.
for (Part p = PartStart; p != PartCount; p = Part(p + 1)) {
- this->PartMap[cmSystemTools::LowerCase(this->Parts[p].GetName())] = p;
+ this->Impl
+ ->PartMap[cmSystemTools::LowerCase(this->Impl->Parts[p].GetName())] = p;
}
- this->ShortDateFormat = true;
-
- this->TestingHandlers["build"] = new cmCTestBuildHandler;
- this->TestingHandlers["buildtest"] = new cmCTestBuildAndTestHandler;
- this->TestingHandlers["coverage"] = new cmCTestCoverageHandler;
- this->TestingHandlers["script"] = new cmCTestScriptHandler;
- this->TestingHandlers["test"] = new cmCTestTestHandler;
- this->TestingHandlers["update"] = new cmCTestUpdateHandler;
- this->TestingHandlers["configure"] = new cmCTestConfigureHandler;
- this->TestingHandlers["memcheck"] = new cmCTestMemCheckHandler;
- this->TestingHandlers["submit"] = new cmCTestSubmitHandler;
- this->TestingHandlers["upload"] = new cmCTestUploadHandler;
-
- cmCTest::t_TestingHandlers::iterator it;
- for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
- ++it) {
- it->second->SetCTestInstance(this);
+ for (auto& handler : this->Impl->GetTestingHandlers()) {
+ handler->SetCTestInstance(this);
}
// Make sure we can capture the build tool output.
@@ -340,31 +361,40 @@ cmCTest::cmCTest()
cmCTest::~cmCTest()
{
- cmDeleteAll(this->TestingHandlers);
- this->SetOutputLogFileName(CM_NULLPTR);
+ delete this->Impl->OutputLogFile;
+}
+
+int cmCTest::GetParallelLevel() const
+{
+ return this->Impl->ParallelLevel;
}
void cmCTest::SetParallelLevel(int level)
{
- this->ParallelLevel = level < 1 ? 1 : level;
+ this->Impl->ParallelLevel = level < 1 ? 1 : level;
+}
+
+unsigned long cmCTest::GetTestLoad() const
+{
+ return this->Impl->TestLoad;
}
void cmCTest::SetTestLoad(unsigned long load)
{
- this->TestLoad = load;
+ this->Impl->TestLoad = load;
}
bool cmCTest::ShouldCompressTestOutput()
{
- return this->CompressTestOutput;
+ return this->Impl->CompressTestOutput;
}
cmCTest::Part cmCTest::GetPartFromName(const char* name)
{
// Look up by lower-case to make names case-insensitive.
std::string lower_name = cmSystemTools::LowerCase(name);
- PartMapType::const_iterator i = this->PartMap.find(lower_name);
- if (i != this->PartMap.end()) {
+ auto const i = this->Impl->PartMap.find(lower_name);
+ if (i != this->Impl->PartMap.end()) {
return i->second;
}
@@ -380,29 +410,30 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
}
cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
- if (!this->InteractiveDebugMode) {
+ if (!this->Impl->InteractiveDebugMode) {
this->BlockTestErrorDiagnostics();
} else {
cmSystemTools::PutEnv("CTEST_INTERACTIVE_DEBUG_MODE=1");
}
- this->BinaryDir = binary_dir;
- cmSystemTools::ConvertToUnixSlashes(this->BinaryDir);
+ this->Impl->BinaryDir = binary_dir;
+ cmSystemTools::ConvertToUnixSlashes(this->Impl->BinaryDir);
this->UpdateCTestConfiguration();
cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
- if (this->ProduceXML) {
+ if (this->Impl->ProduceXML) {
cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
- cmCTestOptionalLog(
- this, OUTPUT, " Site: "
- << this->GetCTestConfiguration("Site") << std::endl
- << " Build name: "
- << cmCTest::SafeBuildIdField(this->GetCTestConfiguration("BuildName"))
- << std::endl,
- quiet);
+ cmCTestOptionalLog(this, OUTPUT,
+ " Site: "
+ << this->GetCTestConfiguration("Site") << std::endl
+ << " Build name: "
+ << cmCTest::SafeBuildIdField(
+ this->GetCTestConfiguration("BuildName"))
+ << std::endl,
+ quiet);
cmCTestOptionalLog(this, DEBUG, "Produce XML is on" << std::endl, quiet);
- if (this->TestModel == cmCTest::NIGHTLY &&
+ if (this->Impl->TestModel == cmCTest::NIGHTLY &&
this->GetCTestConfiguration("NightlyStartTime").empty()) {
cmCTestOptionalLog(
this, WARNING,
@@ -416,36 +447,36 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
}
}
- cmake cm(cmake::RoleScript);
+ cmake cm(cmake::RoleScript, cmState::CTest);
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm);
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
- if (!this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(),
- mf.get())) {
+ cmMakefile mf(&gg, cm.GetCurrentSnapshot());
+ if (!this->ReadCustomConfigurationFileTree(this->Impl->BinaryDir.c_str(),
+ &mf)) {
cmCTestOptionalLog(
this, DEBUG, "Cannot find custom configuration file tree" << std::endl,
quiet);
return 0;
}
- if (this->ProduceXML) {
+ if (this->Impl->ProduceXML) {
// Verify "Testing" directory exists:
//
- std::string testingDir = this->BinaryDir + "/Testing";
- if (cmSystemTools::FileExists(testingDir.c_str())) {
+ std::string testingDir = this->Impl->BinaryDir + "/Testing";
+ if (cmSystemTools::FileExists(testingDir)) {
if (!cmSystemTools::FileIsDirectory(testingDir)) {
- cmCTestLog(this, ERROR_MESSAGE, "File "
- << testingDir
- << " is in the place of the testing directory"
- << std::endl);
+ cmCTestLog(this, ERROR_MESSAGE,
+ "File " << testingDir
+ << " is in the place of the testing directory"
+ << std::endl);
return 0;
}
} else {
- if (!cmSystemTools::MakeDirectory(testingDir.c_str())) {
- cmCTestLog(this, ERROR_MESSAGE, "Cannot create directory "
- << testingDir << std::endl);
+ if (!cmSystemTools::MakeDirectory(testingDir)) {
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Cannot create directory " << testingDir << std::endl);
return 0;
}
}
@@ -462,8 +493,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
std::string tag;
if (createNewTag) {
- time_t tctime = time(CM_NULLPTR);
- if (this->TomorrowTag) {
+ time_t tctime = time(nullptr);
+ if (this->Impl->TomorrowTag) {
tctime += (24 * 60 * 60);
}
struct tm* lctime = gmtime(&tctime);
@@ -477,26 +508,32 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
&min);
if (year != lctime->tm_year + 1900 || mon != lctime->tm_mon + 1 ||
day != lctime->tm_mday) {
- tag = "";
+ tag.clear();
}
- std::string tagmode;
- if (cmSystemTools::GetLineFromStream(tfin, tagmode)) {
- if (tagmode.size() > 4 && !this->Parts[PartStart]) {
- this->TestModel = cmCTest::GetTestModelFromString(tagmode.c_str());
- }
+ std::string group;
+ if (cmSystemTools::GetLineFromStream(tfin, group) &&
+ !this->Impl->Parts[PartStart] && !command) {
+ this->Impl->SpecificGroup = group;
+ }
+ std::string model;
+ if (cmSystemTools::GetLineFromStream(tfin, model) &&
+ !this->Impl->Parts[PartStart] && !command) {
+ this->Impl->TestModel = GetTestModelFromString(model.c_str());
}
tfin.close();
}
- if (tag.empty() || (CM_NULLPTR != command) || this->Parts[PartStart]) {
+ if (tag.empty() || (nullptr != command) ||
+ this->Impl->Parts[PartStart]) {
cmCTestOptionalLog(
this, DEBUG,
"TestModel: " << this->GetTestModelString() << std::endl, quiet);
- cmCTestOptionalLog(
- this, DEBUG, "TestModel: " << this->TestModel << std::endl, quiet);
- if (this->TestModel == cmCTest::NIGHTLY) {
+ cmCTestOptionalLog(this, DEBUG,
+ "TestModel: " << this->Impl->TestModel << std::endl,
+ quiet);
+ if (this->Impl->TestModel == cmCTest::NIGHTLY) {
lctime = this->GetNightlyTime(
this->GetCTestConfiguration("NightlyStartTime"),
- this->TomorrowTag);
+ this->Impl->TomorrowTag);
}
char datestring[100];
sprintf(datestring, "%04d%02d%02d-%02d%02d", lctime->tm_year + 1900,
@@ -507,34 +544,88 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
if (ofs) {
ofs << tag << std::endl;
ofs << this->GetTestModelString() << std::endl;
+ switch (this->Impl->TestModel) {
+ case cmCTest::EXPERIMENTAL:
+ ofs << "Experimental" << std::endl;
+ break;
+ case cmCTest::NIGHTLY:
+ ofs << "Nightly" << std::endl;
+ break;
+ case cmCTest::CONTINUOUS:
+ ofs << "Continuous" << std::endl;
+ break;
+ }
}
ofs.close();
- if (CM_NULLPTR == command) {
- cmCTestOptionalLog(this, OUTPUT, "Create new tag: "
- << tag << " - " << this->GetTestModelString()
- << std::endl,
+ if (nullptr == command) {
+ cmCTestOptionalLog(this, OUTPUT,
+ "Create new tag: " << tag << " - "
+ << this->GetTestModelString()
+ << std::endl,
quiet);
}
}
} else {
+ std::string group;
+ std::string modelStr;
+ int model = cmCTest::UNKNOWN;
+
if (tfin) {
cmSystemTools::GetLineFromStream(tfin, tag);
+ cmSystemTools::GetLineFromStream(tfin, group);
+ if (cmSystemTools::GetLineFromStream(tfin, modelStr)) {
+ model = GetTestModelFromString(modelStr.c_str());
+ }
tfin.close();
}
if (tag.empty()) {
- cmCTestLog(this, ERROR_MESSAGE, "Cannot read existing TAG file in "
- << testingDir << std::endl);
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Cannot read existing TAG file in " << testingDir
+ << std::endl);
return 0;
}
- cmCTestOptionalLog(this, OUTPUT, " Use existing tag: "
- << tag << " - " << this->GetTestModelString()
- << std::endl,
+ if (this->Impl->TestModel == cmCTest::UNKNOWN) {
+ if (model == cmCTest::UNKNOWN) {
+ cmCTestLog(this, ERROR_MESSAGE,
+ "TAG file does not contain model and "
+ "no model specified in start command"
+ << std::endl);
+ return 0;
+ }
+
+ this->SetTestModel(model);
+ }
+
+ if (model != this->Impl->TestModel && model != cmCTest::UNKNOWN &&
+ this->Impl->TestModel != cmCTest::UNKNOWN) {
+ cmCTestOptionalLog(this, WARNING,
+ "Model given in TAG does not match "
+ "model given in ctest_start()"
+ << std::endl,
+ quiet);
+ }
+
+ if (!this->Impl->SpecificGroup.empty() &&
+ group != this->Impl->SpecificGroup) {
+ cmCTestOptionalLog(this, WARNING,
+ "Group given in TAG does not match "
+ "group given in ctest_start()"
+ << std::endl,
+ quiet);
+ } else {
+ this->Impl->SpecificGroup = group;
+ }
+
+ cmCTestOptionalLog(this, OUTPUT,
+ " Use existing tag: " << tag << " - "
+ << this->GetTestModelString()
+ << std::endl,
quiet);
}
- this->CurrentTag = tag;
+ this->Impl->CurrentTag = tag;
}
return 1;
@@ -544,49 +635,37 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
{
std::string src_dir = this->GetCTestConfiguration("SourceDirectory");
std::string bld_dir = this->GetCTestConfiguration("BuildDirectory");
- this->DartVersion = 1;
- this->DropSiteCDash = false;
+ this->Impl->BuildID = "";
for (Part p = PartStart; p != PartCount; p = Part(p + 1)) {
- this->Parts[p].SubmitFiles.clear();
+ this->Impl->Parts[p].SubmitFiles.clear();
}
cmMakefile* mf = command->GetMakefile();
std::string fname;
- std::string src_dir_fname = src_dir;
- src_dir_fname += "/CTestConfig.cmake";
+ std::string src_dir_fname = cmStrCat(src_dir, "/CTestConfig.cmake");
cmSystemTools::ConvertToUnixSlashes(src_dir_fname);
- std::string bld_dir_fname = bld_dir;
- bld_dir_fname += "/CTestConfig.cmake";
+ std::string bld_dir_fname = cmStrCat(bld_dir, "/CTestConfig.cmake");
cmSystemTools::ConvertToUnixSlashes(bld_dir_fname);
- if (cmSystemTools::FileExists(bld_dir_fname.c_str())) {
+ if (cmSystemTools::FileExists(bld_dir_fname)) {
fname = bld_dir_fname;
- } else if (cmSystemTools::FileExists(src_dir_fname.c_str())) {
+ } else if (cmSystemTools::FileExists(src_dir_fname)) {
fname = src_dir_fname;
}
if (!fname.empty()) {
- cmCTestOptionalLog(this, OUTPUT, " Reading ctest configuration file: "
- << fname << std::endl,
+ cmCTestOptionalLog(this, OUTPUT,
+ " Reading ctest configuration file: " << fname
+ << std::endl,
command->ShouldBeQuiet());
- bool readit = mf->ReadDependentFile(fname.c_str());
+ bool readit = mf->ReadDependentFile(fname);
if (!readit) {
- std::string m = "Could not find include file: ";
- m += fname;
+ std::string m = cmStrCat("Could not find include file: ", fname);
command->SetError(m);
return false;
}
- } else {
- cmCTestOptionalLog(this, WARNING,
- "Cannot locate CTest configuration: in BuildDirectory: "
- << bld_dir_fname << std::endl,
- command->ShouldBeQuiet());
- cmCTestOptionalLog(
- this, WARNING, "Cannot locate CTest configuration: in SourceDirectory: "
- << src_dir_fname << std::endl,
- command->ShouldBeQuiet());
}
this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime",
@@ -596,52 +675,38 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
command->ShouldBeQuiet());
this->SetCTestConfigurationFromCMakeVariable(
mf, "BuildName", "CTEST_BUILD_NAME", command->ShouldBeQuiet());
- const char* dartVersion = mf->GetDefinition("CTEST_DART_SERVER_VERSION");
- if (dartVersion) {
- this->DartVersion = atoi(dartVersion);
- if (this->DartVersion < 0) {
- cmCTestLog(this, ERROR_MESSAGE, "Invalid Dart server version: "
- << dartVersion << ". Please specify the version number."
- << std::endl);
- return false;
- }
- }
- this->DropSiteCDash = mf->IsOn("CTEST_DROP_SITE_CDASH");
if (!this->Initialize(bld_dir.c_str(), command)) {
return false;
}
- cmCTestOptionalLog(this, OUTPUT, " Use "
- << this->GetTestModelString()
- << " tag: " << this->GetCurrentTag() << std::endl,
+ cmCTestOptionalLog(this, OUTPUT,
+ " Use " << this->GetTestModelString() << " tag: "
+ << this->GetCurrentTag() << std::endl,
command->ShouldBeQuiet());
return true;
}
bool cmCTest::UpdateCTestConfiguration()
{
- if (this->SuppressUpdatingCTestConfiguration) {
+ if (this->Impl->SuppressUpdatingCTestConfiguration) {
return true;
}
- std::string fileName = this->CTestConfigFile;
- if (fileName.empty()) {
- fileName = this->BinaryDir + "/CTestConfiguration.ini";
- if (!cmSystemTools::FileExists(fileName.c_str())) {
- fileName = this->BinaryDir + "/DartConfiguration.tcl";
- }
+ std::string fileName = this->Impl->BinaryDir + "/CTestConfiguration.ini";
+ if (!cmSystemTools::FileExists(fileName)) {
+ fileName = this->Impl->BinaryDir + "/DartConfiguration.tcl";
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
"UpdateCTestConfiguration from :" << fileName << "\n");
- if (!cmSystemTools::FileExists(fileName.c_str())) {
+ if (!cmSystemTools::FileExists(fileName)) {
// No need to exit if we are not producing XML
- if (this->ProduceXML) {
- cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName
- << std::endl);
+ if (this->Impl->ProduceXML) {
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Cannot find file: " << fileName << std::endl);
return false;
}
} else {
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:" << fileName
- << "\n");
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
+ "Parse Config file:" << fileName << "\n");
// parse the dart test file
cmsys::ifstream fin(fileName.c_str());
@@ -658,7 +723,7 @@ bool cmCTest::UpdateCTestConfiguration()
if (line.empty()) {
continue;
}
- while (fin && (line[line.size() - 1] == '\\')) {
+ while (fin && (line.back() == '\\')) {
line = line.substr(0, line.size() - 1);
buffer[0] = 0;
fin.getline(buffer, 1023);
@@ -674,28 +739,29 @@ bool cmCTest::UpdateCTestConfiguration()
}
std::string key = line.substr(0, cpos);
std::string value = cmCTest::CleanString(line.substr(cpos + 1));
- this->CTestConfiguration[key] = value;
+ this->Impl->CTestConfiguration[key] = value;
}
fin.close();
}
if (!this->GetCTestConfiguration("BuildDirectory").empty()) {
- this->BinaryDir = this->GetCTestConfiguration("BuildDirectory");
- cmSystemTools::ChangeDirectory(this->BinaryDir);
+ this->Impl->BinaryDir = this->GetCTestConfiguration("BuildDirectory");
+ cmSystemTools::ChangeDirectory(this->Impl->BinaryDir);
}
- this->TimeOut = atoi(this->GetCTestConfiguration("TimeOut").c_str());
+ this->Impl->TimeOut =
+ std::chrono::seconds(atoi(this->GetCTestConfiguration("TimeOut").c_str()));
std::string const& testLoad = this->GetCTestConfiguration("TestLoad");
if (!testLoad.empty()) {
unsigned long load;
- if (cmSystemTools::StringToULong(testLoad.c_str(), &load)) {
+ if (cmStrToULong(testLoad, &load)) {
this->SetTestLoad(load);
} else {
cmCTestLog(this, WARNING,
"Invalid value for 'Test Load' : " << testLoad << std::endl);
}
}
- if (this->ProduceXML) {
- this->CompressXMLFiles = cmSystemTools::IsOn(
- this->GetCTestConfiguration("CompressSubmission").c_str());
+ if (this->Impl->ProduceXML) {
+ this->Impl->CompressXMLFiles =
+ cmIsOn(this->GetCTestConfiguration("CompressSubmission"));
}
return true;
}
@@ -713,26 +779,32 @@ void cmCTest::BlockTestErrorDiagnostics()
void cmCTest::SetTestModel(int mode)
{
- this->InteractiveDebugMode = false;
- this->TestModel = mode;
+ this->Impl->InteractiveDebugMode = false;
+ this->Impl->TestModel = mode;
+}
+
+int cmCTest::GetTestModel() const
+{
+ return this->Impl->TestModel;
}
bool cmCTest::SetTest(const char* ttype, bool report)
{
if (cmSystemTools::LowerCase(ttype) == "all") {
for (Part p = PartStart; p != PartCount; p = Part(p + 1)) {
- this->Parts[p].Enable();
+ this->Impl->Parts[p].Enable();
}
return true;
}
Part p = this->GetPartFromName(ttype);
if (p != PartCount) {
- this->Parts[p].Enable();
+ this->Impl->Parts[p].Enable();
return true;
}
if (report) {
- cmCTestLog(this, ERROR_MESSAGE, "Don't know about test \""
- << ttype << "\" yet..." << std::endl);
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Don't know about test \"" << ttype << "\" yet..."
+ << std::endl);
}
return false;
}
@@ -744,33 +816,34 @@ void cmCTest::Finalize()
bool cmCTest::OpenOutputFile(const std::string& path, const std::string& name,
cmGeneratedFileStream& stream, bool compress)
{
- std::string testingDir = this->BinaryDir + "/Testing";
+ std::string testingDir = this->Impl->BinaryDir + "/Testing";
if (!path.empty()) {
testingDir += "/" + path;
}
- if (cmSystemTools::FileExists(testingDir.c_str())) {
+ if (cmSystemTools::FileExists(testingDir)) {
if (!cmSystemTools::FileIsDirectory(testingDir)) {
- cmCTestLog(this, ERROR_MESSAGE, "File "
- << testingDir << " is in the place of the testing directory"
- << std::endl);
+ cmCTestLog(this, ERROR_MESSAGE,
+ "File " << testingDir
+ << " is in the place of the testing directory"
+ << std::endl);
return false;
}
} else {
- if (!cmSystemTools::MakeDirectory(testingDir.c_str())) {
- cmCTestLog(this, ERROR_MESSAGE, "Cannot create directory " << testingDir
- << std::endl);
+ if (!cmSystemTools::MakeDirectory(testingDir)) {
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Cannot create directory " << testingDir << std::endl);
return false;
}
}
std::string filename = testingDir + "/" + name;
- stream.Open(filename.c_str());
+ stream.Open(filename);
if (!stream) {
- cmCTestLog(this, ERROR_MESSAGE, "Problem opening file: " << filename
- << std::endl);
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Problem opening file: " << filename << std::endl);
return false;
}
if (compress) {
- if (this->CompressXMLFiles) {
+ if (this->Impl->CompressXMLFiles) {
stream.SetCompression(true);
}
}
@@ -782,8 +855,7 @@ bool cmCTest::AddIfExists(Part part, const char* file)
if (this->CTestFileExists(file)) {
this->AddSubmitFile(part, file);
} else {
- std::string name = file;
- name += ".gz";
+ std::string name = cmStrCat(file, ".gz");
if (this->CTestFileExists(name)) {
this->AddSubmitFile(part, file);
} else {
@@ -795,40 +867,59 @@ bool cmCTest::AddIfExists(Part part, const char* file)
bool cmCTest::CTestFileExists(const std::string& filename)
{
- std::string testingDir =
- this->BinaryDir + "/Testing/" + this->CurrentTag + "/" + filename;
- return cmSystemTools::FileExists(testingDir.c_str());
+ std::string testingDir = this->Impl->BinaryDir + "/Testing/" +
+ this->Impl->CurrentTag + "/" + filename;
+ return cmSystemTools::FileExists(testingDir);
}
-cmCTestGenericHandler* cmCTest::GetInitializedHandler(const char* handler)
+cmCTestBuildHandler* cmCTest::GetBuildHandler()
{
- cmCTest::t_TestingHandlers::iterator it =
- this->TestingHandlers.find(handler);
- if (it == this->TestingHandlers.end()) {
- return CM_NULLPTR;
- }
- it->second->Initialize();
- return it->second;
+ return &this->Impl->BuildHandler;
}
-cmCTestGenericHandler* cmCTest::GetHandler(const char* handler)
+cmCTestBuildAndTestHandler* cmCTest::GetBuildAndTestHandler()
{
- cmCTest::t_TestingHandlers::iterator it =
- this->TestingHandlers.find(handler);
- if (it == this->TestingHandlers.end()) {
- return CM_NULLPTR;
- }
- return it->second;
+ return &this->Impl->BuildAndTestHandler;
}
-int cmCTest::ExecuteHandler(const char* shandler)
+cmCTestCoverageHandler* cmCTest::GetCoverageHandler()
{
- cmCTestGenericHandler* handler = this->GetHandler(shandler);
- if (!handler) {
- return -1;
- }
- handler->Initialize();
- return handler->ProcessHandler();
+ return &this->Impl->CoverageHandler;
+}
+
+cmCTestScriptHandler* cmCTest::GetScriptHandler()
+{
+ return &this->Impl->ScriptHandler;
+}
+
+cmCTestTestHandler* cmCTest::GetTestHandler()
+{
+ return &this->Impl->TestHandler;
+}
+
+cmCTestUpdateHandler* cmCTest::GetUpdateHandler()
+{
+ return &this->Impl->UpdateHandler;
+}
+
+cmCTestConfigureHandler* cmCTest::GetConfigureHandler()
+{
+ return &this->Impl->ConfigureHandler;
+}
+
+cmCTestMemCheckHandler* cmCTest::GetMemCheckHandler()
+{
+ return &this->Impl->MemCheckHandler;
+}
+
+cmCTestSubmitHandler* cmCTest::GetSubmitHandler()
+{
+ return &this->Impl->SubmitHandler;
+}
+
+cmCTestUploadHandler* cmCTest::GetUploadHandler()
+{
+ return &this->Impl->UploadHandler;
}
int cmCTest::ProcessSteps()
@@ -838,10 +929,11 @@ int cmCTest::ProcessSteps()
int update_count = 0;
for (Part p = PartStart; notest && p != PartCount; p = Part(p + 1)) {
- notest = !this->Parts[p];
+ notest = !this->Impl->Parts[p];
}
- if (this->Parts[PartUpdate] && (this->GetRemainingTimeAllowed() - 120 > 0)) {
- cmCTestGenericHandler* uphandler = this->GetHandler("update");
+ if (this->Impl->Parts[PartUpdate] &&
+ (this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) {
+ cmCTestUpdateHandler* uphandler = this->GetUpdateHandler();
uphandler->SetPersistentOption(
"SourceDirectory",
this->GetCTestConfiguration("SourceDirectory").c_str());
@@ -850,44 +942,45 @@ int cmCTest::ProcessSteps()
res |= cmCTest::UPDATE_ERRORS;
}
}
- if (this->TestModel == cmCTest::CONTINUOUS && !update_count) {
+ if (this->Impl->TestModel == cmCTest::CONTINUOUS && !update_count) {
return 0;
}
- if (this->Parts[PartConfigure] &&
- (this->GetRemainingTimeAllowed() - 120 > 0)) {
- if (this->GetHandler("configure")->ProcessHandler() < 0) {
+ if (this->Impl->Parts[PartConfigure] &&
+ (this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) {
+ if (this->GetConfigureHandler()->ProcessHandler() < 0) {
res |= cmCTest::CONFIGURE_ERRORS;
}
}
- if (this->Parts[PartBuild] && (this->GetRemainingTimeAllowed() - 120 > 0)) {
+ if (this->Impl->Parts[PartBuild] &&
+ (this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) {
this->UpdateCTestConfiguration();
- if (this->GetHandler("build")->ProcessHandler() < 0) {
+ if (this->GetBuildHandler()->ProcessHandler() < 0) {
res |= cmCTest::BUILD_ERRORS;
}
}
- if ((this->Parts[PartTest] || notest) &&
- (this->GetRemainingTimeAllowed() - 120 > 0)) {
+ if ((this->Impl->Parts[PartTest] || notest) &&
+ (this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) {
this->UpdateCTestConfiguration();
- if (this->GetHandler("test")->ProcessHandler() < 0) {
+ if (this->GetTestHandler()->ProcessHandler() < 0) {
res |= cmCTest::TEST_ERRORS;
}
}
- if (this->Parts[PartCoverage] &&
- (this->GetRemainingTimeAllowed() - 120 > 0)) {
+ if (this->Impl->Parts[PartCoverage] &&
+ (this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) {
this->UpdateCTestConfiguration();
- if (this->GetHandler("coverage")->ProcessHandler() < 0) {
+ if (this->GetCoverageHandler()->ProcessHandler() < 0) {
res |= cmCTest::COVERAGE_ERRORS;
}
}
- if (this->Parts[PartMemCheck] &&
- (this->GetRemainingTimeAllowed() - 120 > 0)) {
+ if (this->Impl->Parts[PartMemCheck] &&
+ (this->GetRemainingTimeAllowed() > std::chrono::minutes(2))) {
this->UpdateCTestConfiguration();
- if (this->GetHandler("memcheck")->ProcessHandler() < 0) {
+ if (this->GetMemCheckHandler()->ProcessHandler() < 0) {
res |= cmCTest::MEMORY_ERRORS;
}
}
if (!notest) {
- std::string notes_dir = this->BinaryDir + "/Testing/Notes";
+ std::string notes_dir = this->Impl->BinaryDir + "/Testing/Notes";
if (cmSystemTools::FileIsDirectory(notes_dir)) {
cmsys::Directory d;
d.Load(notes_dir);
@@ -895,26 +988,26 @@ int cmCTest::ProcessSteps()
for (kk = 0; kk < d.GetNumberOfFiles(); kk++) {
const char* file = d.GetFile(kk);
std::string fullname = notes_dir + "/" + file;
- if (cmSystemTools::FileExists(fullname.c_str()) &&
+ if (cmSystemTools::FileExists(fullname) &&
!cmSystemTools::FileIsDirectory(fullname)) {
- if (!this->NotesFiles.empty()) {
- this->NotesFiles += ";";
+ if (!this->Impl->NotesFiles.empty()) {
+ this->Impl->NotesFiles += ";";
}
- this->NotesFiles += fullname;
- this->Parts[PartNotes].Enable();
+ this->Impl->NotesFiles += fullname;
+ this->Impl->Parts[PartNotes].Enable();
}
}
}
}
- if (this->Parts[PartNotes]) {
+ if (this->Impl->Parts[PartNotes]) {
this->UpdateCTestConfiguration();
- if (!this->NotesFiles.empty()) {
- this->GenerateNotesFile(this->NotesFiles.c_str());
+ if (!this->Impl->NotesFiles.empty()) {
+ this->GenerateNotesFile(this->Impl->NotesFiles.c_str());
}
}
- if (this->Parts[PartSubmit]) {
+ if (this->Impl->Parts[PartSubmit]) {
this->UpdateCTestConfiguration();
- if (this->GetHandler("submit")->ProcessHandler() < 0) {
+ if (this->GetSubmitHandler()->ProcessHandler() < 0) {
res |= cmCTest::SUBMIT_ERRORS;
}
}
@@ -926,10 +1019,10 @@ int cmCTest::ProcessSteps()
std::string cmCTest::GetTestModelString()
{
- if (!this->SpecificTrack.empty()) {
- return this->SpecificTrack;
+ if (!this->Impl->SpecificGroup.empty()) {
+ return this->Impl->SpecificGroup;
}
- switch (this->TestModel) {
+ switch (this->Impl->TestModel) {
case cmCTest::NIGHTLY:
return "Nightly";
case cmCTest::CONTINUOUS:
@@ -944,10 +1037,10 @@ int cmCTest::GetTestModelFromString(const char* str)
return cmCTest::EXPERIMENTAL;
}
std::string rstr = cmSystemTools::LowerCase(str);
- if (cmHasLiteralPrefix(rstr.c_str(), "cont")) {
+ if (cmHasLiteralPrefix(rstr, "cont")) {
return cmCTest::CONTINUOUS;
}
- if (cmHasLiteralPrefix(rstr.c_str(), "nigh")) {
+ if (cmHasLiteralPrefix(rstr, "nigh")) {
return cmCTest::NIGHTLY;
}
return cmCTest::EXPERIMENTAL;
@@ -958,8 +1051,8 @@ int cmCTest::GetTestModelFromString(const char* str)
//######################################################################
//######################################################################
-int cmCTest::RunMakeCommand(const char* command, std::string& output,
- int* retVal, const char* dir, int timeout,
+int cmCTest::RunMakeCommand(const std::string& command, std::string& output,
+ int* retVal, const char* dir, cmDuration timeout,
std::ostream& ofs, Encoding encoding)
{
// First generate the command and arguments
@@ -970,26 +1063,28 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
}
std::vector<const char*> argv;
- for (std::vector<std::string>::const_iterator a = args.begin();
- a != args.end(); ++a) {
- argv.push_back(a->c_str());
+ argv.reserve(args.size() + 1);
+ for (std::string const& a : args) {
+ argv.push_back(a.c_str());
}
- argv.push_back(CM_NULLPTR);
+ argv.push_back(nullptr);
- output = "";
+ output.clear();
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Run command:");
- std::vector<const char*>::iterator ait;
- for (ait = argv.begin(); ait != argv.end() && *ait; ++ait) {
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, " \"" << *ait << "\"");
+ for (char const* arg : argv) {
+ if (!arg) {
+ break;
+ }
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, " \"" << arg << "\"");
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, std::endl);
// Now create process object
cmsysProcess* cp = cmsysProcess_New();
- cmsysProcess_SetCommand(cp, &*argv.begin());
+ cmsysProcess_SetCommand(cp, argv.data());
cmsysProcess_SetWorkingDirectory(cp, dir);
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
- cmsysProcess_SetTimeout(cp, timeout);
+ cmsysProcess_SetTimeout(cp, timeout.count());
cmsysProcess_Execute(cp);
// Initialize tick's
@@ -1001,14 +1096,16 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
int length;
cmProcessOutput processOutput(encoding);
std::string strdata;
- cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Each . represents "
- << tick_len << " bytes of output" << std::endl
- << " " << std::flush);
- while (cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) {
+ cmCTestLog(this, HANDLER_PROGRESS_OUTPUT,
+ " Each . represents " << tick_len
+ << " bytes of output\n"
+ " "
+ << std::flush);
+ while (cmsysProcess_WaitForData(cp, &data, &length, nullptr)) {
processOutput.DecodeText(data, length, strdata);
- for (size_t cc = 0; cc < strdata.size(); ++cc) {
- if (strdata[cc] == 0) {
- strdata[cc] = '\n';
+ for (char& cc : strdata) {
+ if (cc == 0) {
+ cc = '\n';
}
}
output.append(strdata);
@@ -1018,8 +1115,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
if (tick % tick_line_len == 0 && tick > 0) {
cmCTestLog(this, HANDLER_PROGRESS_OUTPUT,
" Size: " << int((double(output.size()) / 1024.0) + 1)
- << "K" << std::endl
- << " " << std::flush);
+ << "K\n " << std::flush);
}
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
@@ -1037,10 +1133,11 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
ofs << cmCTestLogWrite(strdata.c_str(), strdata.size());
}
}
- cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Size of output: "
- << int(double(output.size()) / 1024.0) << "K" << std::endl);
+ cmCTestLog(this, HANDLER_PROGRESS_OUTPUT,
+ " Size of output: " << int(double(output.size()) / 1024.0) << "K"
+ << std::endl);
- cmsysProcess_WaitForExit(cp, CM_NULLPTR);
+ cmsysProcess_WaitForExit(cp, nullptr);
int result = cmsysProcess_GetState(cp);
@@ -1050,16 +1147,17 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
"Command exited with the value: " << *retVal << std::endl);
} else if (result == cmsysProcess_State_Exception) {
*retVal = cmsysProcess_GetExitException(cp);
- cmCTestLog(this, WARNING, "There was an exception: " << *retVal
- << std::endl);
+ cmCTestLog(this, WARNING,
+ "There was an exception: " << *retVal << std::endl);
} else if (result == cmsysProcess_State_Expired) {
cmCTestLog(this, WARNING, "There was a timeout" << std::endl);
} else if (result == cmsysProcess_State_Error) {
output += "\n*** ERROR executing: ";
output += cmsysProcess_GetErrorString(cp);
output += "\n***The build process failed.";
- cmCTestLog(this, ERROR_MESSAGE, "There was an error: "
- << cmsysProcess_GetErrorString(cp) << std::endl);
+ cmCTestLog(this, ERROR_MESSAGE,
+ "There was an error: " << cmsysProcess_GetErrorString(cp)
+ << std::endl);
}
cmsysProcess_Delete(cp);
@@ -1073,58 +1171,67 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output,
//######################################################################
int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
- int* retVal, std::ostream* log, double testTimeOut,
+ int* retVal, std::ostream* log, cmDuration testTimeOut,
std::vector<std::string>* environment, Encoding encoding)
{
bool modifyEnv = (environment && !environment->empty());
// determine how much time we have
- double timeout = this->GetRemainingTimeAllowed() - 120;
- if (this->TimeOut > 0 && this->TimeOut < timeout) {
- timeout = this->TimeOut;
+ cmDuration timeout = this->GetRemainingTimeAllowed();
+ if (timeout != cmCTest::MaxDuration()) {
+ timeout -= std::chrono::minutes(2);
+ }
+ if (this->Impl->TimeOut > cmDuration::zero() &&
+ this->Impl->TimeOut < timeout) {
+ timeout = this->Impl->TimeOut;
}
- if (testTimeOut > 0 && testTimeOut < this->GetRemainingTimeAllowed()) {
+ if (testTimeOut > cmDuration::zero() &&
+ testTimeOut < this->GetRemainingTimeAllowed()) {
timeout = testTimeOut;
}
// always have at least 1 second if we got to here
- if (timeout <= 0) {
- timeout = 1;
+ if (timeout <= cmDuration::zero()) {
+ timeout = std::chrono::seconds(1);
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
- "Test timeout computed to be: " << timeout << "\n");
+ "Test timeout computed to be: "
+ << (timeout == cmCTest::MaxDuration()
+ ? std::string("infinite")
+ : std::to_string(cmDurationTo<unsigned int>(timeout)))
+ << "\n");
if (cmSystemTools::SameFile(argv[0], cmSystemTools::GetCTestCommand()) &&
- !this->ForceNewCTestProcess) {
+ !this->Impl->ForceNewCTestProcess) {
cmCTest inst;
- inst.ConfigType = this->ConfigType;
- inst.TimeOut = timeout;
+ inst.Impl->ConfigType = this->Impl->ConfigType;
+ inst.Impl->TimeOut = timeout;
// Capture output of the child ctest.
std::ostringstream oss;
inst.SetStreams(&oss, &oss);
std::vector<std::string> args;
- for (unsigned int i = 0; i < argv.size(); ++i) {
- if (argv[i]) {
+ for (char const* i : argv) {
+ if (i) {
// make sure we pass the timeout in for any build and test
// invocations. Since --build-generator is required this is a
// good place to check for it, and to add the arguments in
- if (strcmp(argv[i], "--build-generator") == 0 && timeout > 0) {
- args.push_back("--test-timeout");
- std::ostringstream msg;
- msg << timeout;
- args.push_back(msg.str());
+ if (strcmp(i, "--build-generator") == 0 &&
+ timeout != cmCTest::MaxDuration() &&
+ timeout > cmDuration::zero()) {
+ args.emplace_back("--test-timeout");
+ args.push_back(std::to_string(cmDurationTo<unsigned int>(timeout)));
}
- args.push_back(argv[i]);
+ args.emplace_back(i);
}
}
if (log) {
*log << "* Run internal CTest" << std::endl;
}
- CM_AUTO_PTR<cmSystemTools::SaveRestoreEnvironment> saveEnv;
+ std::unique_ptr<cmSystemTools::SaveRestoreEnvironment> saveEnv;
if (modifyEnv) {
- saveEnv.reset(new cmSystemTools::SaveRestoreEnvironment);
+ saveEnv = cm::make_unique<cmSystemTools::SaveRestoreEnvironment>();
cmSystemTools::AppendEnv(*environment);
}
@@ -1146,33 +1253,33 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
}
std::vector<char> tempOutput;
if (output) {
- *output = "";
+ output->clear();
}
- CM_AUTO_PTR<cmSystemTools::SaveRestoreEnvironment> saveEnv;
+ std::unique_ptr<cmSystemTools::SaveRestoreEnvironment> saveEnv;
if (modifyEnv) {
- saveEnv.reset(new cmSystemTools::SaveRestoreEnvironment);
+ saveEnv = cm::make_unique<cmSystemTools::SaveRestoreEnvironment>();
cmSystemTools::AppendEnv(*environment);
}
cmsysProcess* cp = cmsysProcess_New();
- cmsysProcess_SetCommand(cp, &*argv.begin());
+ cmsysProcess_SetCommand(cp, argv.data());
cmCTestLog(this, DEBUG, "Command is: " << argv[0] << std::endl);
if (cmSystemTools::GetRunCommandHideConsole()) {
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
}
- cmsysProcess_SetTimeout(cp, timeout);
+ cmsysProcess_SetTimeout(cp, timeout.count());
cmsysProcess_Execute(cp);
char* data;
int length;
cmProcessOutput processOutput(encoding);
std::string strdata;
- while (cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) {
+ while (cmsysProcess_WaitForData(cp, &data, &length, nullptr)) {
processOutput.DecodeText(data, length, strdata);
if (output) {
- tempOutput.insert(tempOutput.end(), data, data + length);
+ cmAppend(tempOutput, data, data + length);
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
cmCTestLogWrite(strdata.c_str(), strdata.size()));
@@ -1189,41 +1296,39 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
}
}
- cmsysProcess_WaitForExit(cp, CM_NULLPTR);
+ cmsysProcess_WaitForExit(cp, nullptr);
processOutput.DecodeText(tempOutput, tempOutput);
if (output && tempOutput.begin() != tempOutput.end()) {
- output->append(&*tempOutput.begin(), tempOutput.size());
+ output->append(tempOutput.data(), tempOutput.size());
}
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "-- Process completed"
- << std::endl);
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
+ "-- Process completed" << std::endl);
int result = cmsysProcess_GetState(cp);
if (result == cmsysProcess_State_Exited) {
*retVal = cmsysProcess_GetExitValue(cp);
- if (*retVal != 0 && this->OutputTestOutputOnTestFailure) {
+ if (*retVal != 0 && this->Impl->OutputTestOutputOnTestFailure) {
OutputTestErrors(tempOutput);
}
} else if (result == cmsysProcess_State_Exception) {
- if (this->OutputTestOutputOnTestFailure) {
+ if (this->Impl->OutputTestOutputOnTestFailure) {
OutputTestErrors(tempOutput);
}
*retVal = cmsysProcess_GetExitException(cp);
- std::string outerr = "\n*** Exception executing: ";
- outerr += cmsysProcess_GetExceptionString(cp);
+ std::string outerr = cmStrCat("\n*** Exception executing: ",
+ cmsysProcess_GetExceptionString(cp));
if (output) {
*output += outerr;
}
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr << std::endl
- << std::flush);
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr << std::endl);
} else if (result == cmsysProcess_State_Error) {
- std::string outerr = "\n*** ERROR executing: ";
- outerr += cmsysProcess_GetErrorString(cp);
+ std::string outerr =
+ cmStrCat("\n*** ERROR executing: ", cmsysProcess_GetErrorString(cp));
if (output) {
*output += outerr;
}
- cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr << std::endl
- << std::flush);
+ cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, outerr << std::endl);
}
cmsysProcess_Delete(cp);
@@ -1234,7 +1339,7 @@ std::string cmCTest::SafeBuildIdField(const std::string& value)
{
std::string safevalue(value);
- if (safevalue != "") {
+ if (!safevalue.empty()) {
// Disallow non-filename and non-space whitespace characters.
// If they occur, replace them with ""
//
@@ -1253,7 +1358,7 @@ std::string cmCTest::SafeBuildIdField(const std::string& value)
}
}
- if (safevalue == "") {
+ if (safevalue.empty()) {
safevalue = "(empty)";
}
@@ -1262,9 +1367,10 @@ std::string cmCTest::SafeBuildIdField(const std::string& value)
void cmCTest::StartXML(cmXMLWriter& xml, bool append)
{
- if (this->CurrentTag.empty()) {
- cmCTestLog(this, ERROR_MESSAGE, "Current Tag empty, this may mean"
- " NightlStartTime was not set correctly."
+ if (this->Impl->CurrentTag.empty()) {
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Current Tag empty, this may mean"
+ " NightlStartTime was not set correctly."
<< std::endl);
cmSystemTools::SetFatalErrorOccured();
}
@@ -1277,7 +1383,7 @@ void cmCTest::StartXML(cmXMLWriter& xml, bool append)
std::string buildname =
cmCTest::SafeBuildIdField(this->GetCTestConfiguration("BuildName"));
- std::string stamp = cmCTest::SafeBuildIdField(this->CurrentTag + "-" +
+ std::string stamp = cmCTest::SafeBuildIdField(this->Impl->CurrentTag + "-" +
this->GetTestModelString());
std::string site =
cmCTest::SafeBuildIdField(this->GetCTestConfiguration("Site"));
@@ -1325,8 +1431,7 @@ void cmCTest::StartXML(cmXMLWriter& xml, bool append)
void cmCTest::AddSiteProperties(cmXMLWriter& xml)
{
- cmCTestScriptHandler* ch =
- static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+ cmCTestScriptHandler* ch = this->GetScriptHandler();
cmake* cm = ch->GetCMake();
// if no CMake then this is the old style script and props like
// this will not work anyway.
@@ -1343,11 +1448,9 @@ void cmCTest::AddSiteProperties(cmXMLWriter& xml)
if (labels) {
xml.StartElement("Labels");
std::string l = labels;
- std::vector<std::string> args;
- cmSystemTools::ExpandListArgument(l, args);
- for (std::vector<std::string>::iterator i = args.begin();
- i != args.end(); ++i) {
- xml.Element("Label", *i);
+ std::vector<std::string> args = cmExpandedList(l);
+ for (std::string const& i : args) {
+ xml.Element("Label", i);
}
xml.EndElement();
}
@@ -1363,6 +1466,31 @@ void cmCTest::AddSiteProperties(cmXMLWriter& xml)
}
}
+void cmCTest::GenerateSubprojectsOutput(cmXMLWriter& xml)
+{
+ for (std::string const& subproj : this->GetLabelsForSubprojects()) {
+ xml.StartElement("Subproject");
+ xml.Attribute("name", subproj);
+ xml.Element("Label", subproj);
+ xml.EndElement(); // Subproject
+ }
+}
+
+std::vector<std::string> cmCTest::GetLabelsForSubprojects()
+{
+ std::string labelsForSubprojects =
+ this->GetCTestConfiguration("LabelsForSubprojects");
+ std::vector<std::string> subprojects = cmExpandedList(labelsForSubprojects);
+
+ // sort the array
+ std::sort(subprojects.begin(), subprojects.end());
+ // remove duplicates
+ auto new_end = std::unique(subprojects.begin(), subprojects.end());
+ subprojects.erase(new_end, subprojects.end());
+
+ return subprojects;
+}
+
void cmCTest::EndXML(cmXMLWriter& xml)
{
xml.EndElement(); // Site
@@ -1370,11 +1498,10 @@ void cmCTest::EndXML(cmXMLWriter& xml)
}
int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml,
- const cmCTest::VectorOfStrings& files)
+ std::vector<std::string> const& files)
{
std::string buildname =
cmCTest::SafeBuildIdField(this->GetCTestConfiguration("BuildName"));
- cmCTest::VectorOfStrings::const_iterator it;
xml.StartDocument();
xml.ProcessingInstruction("xml-stylesheet",
"type=\"text/xsl\" "
@@ -1383,22 +1510,22 @@ int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml,
xml.StartElement("Site");
xml.Attribute("BuildName", buildname);
xml.Attribute("BuildStamp",
- this->CurrentTag + "-" + this->GetTestModelString());
+ this->Impl->CurrentTag + "-" + this->GetTestModelString());
xml.Attribute("Name", this->GetCTestConfiguration("Site"));
xml.Attribute("Generator",
- std::string("ctest") + cmVersion::GetCMakeVersion());
+ std::string("ctest-") + cmVersion::GetCMakeVersion());
this->AddSiteProperties(xml);
xml.StartElement("Notes");
- for (it = files.begin(); it != files.end(); it++) {
- cmCTestLog(this, OUTPUT, "\tAdd file: " << *it << std::endl);
+ for (std::string const& file : files) {
+ cmCTestLog(this, OUTPUT, "\tAdd file: " << file << std::endl);
std::string note_time = this->CurrentTime();
xml.StartElement("Note");
- xml.Attribute("Name", *it);
- xml.Element("Time", cmSystemTools::GetTime());
+ xml.Attribute("Name", file);
+ xml.Element("Time", std::chrono::system_clock::now());
xml.Element("DateTime", note_time);
xml.StartElement("Text");
- cmsys::ifstream ifs(it->c_str());
+ cmsys::ifstream ifs(file.c_str());
if (ifs) {
std::string line;
while (cmSystemTools::GetLineFromStream(ifs, line)) {
@@ -1407,9 +1534,10 @@ int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml,
}
ifs.close();
} else {
- xml.Content("Problem reading file: " + *it + "\n");
- cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: "
- << *it << " while creating notes" << std::endl);
+ xml.Content("Problem reading file: " + file + "\n");
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Problem reading file: " << file << " while creating notes"
+ << std::endl);
}
xml.EndElement(); // Text
xml.EndElement(); // Note
@@ -1420,10 +1548,10 @@ int cmCTest::GenerateCTestNotesOutput(cmXMLWriter& xml,
return 1;
}
-int cmCTest::GenerateNotesFile(const VectorOfStrings& files)
+int cmCTest::GenerateNotesFile(std::vector<std::string> const& files)
{
cmGeneratedFileStream ofs;
- if (!this->OpenOutputFile(this->CurrentTag, "Notes.xml", ofs)) {
+ if (!this->OpenOutputFile(this->Impl->CurrentTag, "Notes.xml", ofs)) {
cmCTestLog(this, ERROR_MESSAGE, "Cannot open notes file" << std::endl);
return 1;
}
@@ -1438,11 +1566,10 @@ int cmCTest::GenerateNotesFile(const char* cfiles)
return 1;
}
- VectorOfStrings files;
-
cmCTestLog(this, OUTPUT, "Create notes file" << std::endl);
- files = cmSystemTools::SplitString(cfiles, ';');
+ std::vector<std::string> const files =
+ cmSystemTools::SplitString(cfiles, ';');
if (files.empty()) {
return 1;
}
@@ -1450,16 +1577,35 @@ int cmCTest::GenerateNotesFile(const char* cfiles)
return this->GenerateNotesFile(files);
}
+int cmCTest::GenerateDoneFile()
+{
+ cmGeneratedFileStream ofs;
+ if (!this->OpenOutputFile(this->Impl->CurrentTag, "Done.xml", ofs)) {
+ cmCTestLog(this, ERROR_MESSAGE, "Cannot open done file" << std::endl);
+ return 1;
+ }
+ cmXMLWriter xml(ofs);
+ xml.StartDocument();
+ xml.StartElement("Done");
+ xml.Element("buildId", this->Impl->BuildID);
+ xml.Element("time", std::chrono::system_clock::now());
+ xml.EndElement(); // Done
+ xml.EndDocument();
+
+ return 0;
+}
+
std::string cmCTest::Base64GzipEncodeFile(std::string const& file)
{
std::string tarFile = file + "_temp.tar.gz";
std::vector<std::string> files;
files.push_back(file);
- if (!cmSystemTools::CreateTar(tarFile.c_str(), files,
- cmSystemTools::TarCompressGZip, false)) {
- cmCTestLog(this, ERROR_MESSAGE, "Error creating tar while "
- "encoding file: "
+ if (!cmSystemTools::CreateTar(tarFile, files, cmSystemTools::TarCompressGZip,
+ false)) {
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Error creating tar while "
+ "encoding file: "
<< file << std::endl);
return "";
}
@@ -1471,11 +1617,12 @@ std::string cmCTest::Base64GzipEncodeFile(std::string const& file)
std::string cmCTest::Base64EncodeFile(std::string const& file)
{
size_t const len = cmSystemTools::FileLength(file);
- cmsys::ifstream ifs(file.c_str(), std::ios::in
+ cmsys::ifstream ifs(file.c_str(),
+ std::ios::in
#ifdef _WIN32
| std::ios::binary
#endif
- );
+ );
std::vector<char> file_buffer(len + 1);
ifs.read(&file_buffer[0], len);
ifs.close();
@@ -1489,16 +1636,16 @@ std::string cmCTest::Base64EncodeFile(std::string const& file)
return std::string(&encoded_buffer[0], rlen);
}
-bool cmCTest::SubmitExtraFiles(const VectorOfStrings& files)
+bool cmCTest::SubmitExtraFiles(std::vector<std::string> const& files)
{
- VectorOfStrings::const_iterator it;
- for (it = files.begin(); it != files.end(); ++it) {
- if (!cmSystemTools::FileExists(it->c_str())) {
- cmCTestLog(this, ERROR_MESSAGE, "Cannot find extra file: "
- << *it << " to submit." << std::endl;);
+ for (std::string const& file : files) {
+ if (!cmSystemTools::FileExists(file)) {
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Cannot find extra file: " << file << " to submit."
+ << std::endl;);
return false;
}
- this->AddSubmitFile(PartExtraFiles, it->c_str());
+ this->AddSubmitFile(PartExtraFiles, file.c_str());
}
return true;
}
@@ -1509,11 +1656,10 @@ bool cmCTest::SubmitExtraFiles(const char* cfiles)
return true;
}
- VectorOfStrings files;
-
cmCTestLog(this, OUTPUT, "Submit extra files" << std::endl);
- files = cmSystemTools::SplitString(cfiles, ';');
+ std::vector<std::string> const files =
+ cmSystemTools::SplitString(cfiles, ';');
if (files.empty()) {
return true;
}
@@ -1652,7 +1798,8 @@ void cmCTest::ErrorMessageUnknownDashDValue(std::string& val)
"CTest -D called with incorrect option: " << val << std::endl);
cmCTestLog(
- this, ERROR_MESSAGE, "Available options are:"
+ this, ERROR_MESSAGE,
+ "Available options are:"
<< std::endl
<< " ctest -D Continuous" << std::endl
<< " ctest -D Continuous(Start|Update|Configure|Build)" << std::endl
@@ -1680,17 +1827,17 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
{
std::string arg = args[i];
if (this->CheckArgument(arg, "-F")) {
- this->Failover = true;
+ this->Impl->Failover = true;
}
if (this->CheckArgument(arg, "-j", "--parallel") && i < args.size() - 1) {
i++;
int plevel = atoi(args[i].c_str());
this->SetParallelLevel(plevel);
- this->ParallelLevelSetInCli = true;
+ this->Impl->ParallelLevelSetInCli = true;
} else if (arg.find("-j") == 0) {
int plevel = atoi(arg.substr(2).c_str());
this->SetParallelLevel(plevel);
- this->ParallelLevelSetInCli = true;
+ this->Impl->ParallelLevelSetInCli = true;
}
if (this->CheckArgument(arg, "--repeat-until-fail")) {
if (i >= args.size() - 1) {
@@ -1699,21 +1846,21 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
}
i++;
long repeat = 1;
- if (!cmSystemTools::StringToLong(args[i].c_str(), &repeat)) {
+ if (!cmStrToLong(args[i], &repeat)) {
errormsg =
"'--repeat-until-fail' given non-integer value '" + args[i] + "'";
return false;
}
- this->RepeatTests = static_cast<int>(repeat);
+ this->Impl->RepeatTests = static_cast<int>(repeat);
if (repeat > 1) {
- this->RepeatUntilFail = true;
+ this->Impl->RepeatUntilFail = true;
}
}
if (this->CheckArgument(arg, "--test-load") && i < args.size() - 1) {
i++;
unsigned long load;
- if (cmSystemTools::StringToULong(args[i].c_str(), &load)) {
+ if (cmStrToULong(args[i], &load)) {
this->SetTestLoad(load);
} else {
cmCTestLog(this, WARNING,
@@ -1722,21 +1869,21 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
}
if (this->CheckArgument(arg, "--no-compress-output")) {
- this->CompressTestOutput = false;
+ this->Impl->CompressTestOutput = false;
}
if (this->CheckArgument(arg, "--print-labels")) {
- this->PrintLabels = true;
+ this->Impl->PrintLabels = true;
}
if (this->CheckArgument(arg, "--http1.0")) {
- this->UseHTTP10 = true;
+ this->Impl->UseHTTP10 = true;
}
if (this->CheckArgument(arg, "--timeout") && i < args.size() - 1) {
i++;
- double timeout = (double)atof(args[i].c_str());
- this->GlobalTimeout = timeout;
+ auto timeout = cmDuration(atof(args[i].c_str()));
+ this->Impl->GlobalTimeout = timeout;
}
if (this->CheckArgument(arg, "--stop-time") && i < args.size() - 1) {
@@ -1751,44 +1898,50 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
}
if (this->CheckArgument(arg, "--debug")) {
- this->Debug = true;
- this->ShowLineNumbers = true;
+ this->Impl->Debug = true;
+ this->Impl->ShowLineNumbers = true;
}
+ if (this->CheckArgument(arg, "--group") && i < args.size() - 1) {
+ i++;
+ this->Impl->SpecificGroup = args[i];
+ }
+ // This is an undocumented / deprecated option.
+ // "Track" has been renamed to "Group".
if (this->CheckArgument(arg, "--track") && i < args.size() - 1) {
i++;
- this->SpecificTrack = args[i];
+ this->Impl->SpecificGroup = args[i];
}
if (this->CheckArgument(arg, "--show-line-numbers")) {
- this->ShowLineNumbers = true;
+ this->Impl->ShowLineNumbers = true;
}
if (this->CheckArgument(arg, "--no-label-summary")) {
- this->LabelSummary = false;
+ this->Impl->LabelSummary = false;
+ }
+ if (this->CheckArgument(arg, "--no-subproject-summary")) {
+ this->Impl->SubprojectSummary = false;
}
if (this->CheckArgument(arg, "-Q", "--quiet")) {
- this->Quiet = true;
+ this->Impl->Quiet = true;
}
- if (this->CheckArgument(arg, "-V", "--verbose")) {
- this->Verbose = true;
+ if (this->CheckArgument(arg, "--progress")) {
+ this->Impl->TestProgressOutput = true;
}
- if (this->CheckArgument(arg, "-B")) {
- this->BatchJobs = true;
+ if (this->CheckArgument(arg, "-V", "--verbose")) {
+ this->Impl->Verbose = true;
}
if (this->CheckArgument(arg, "-VV", "--extra-verbose")) {
- this->ExtraVerbose = true;
- this->Verbose = true;
+ this->Impl->ExtraVerbose = true;
+ this->Impl->Verbose = true;
}
if (this->CheckArgument(arg, "--output-on-failure")) {
- this->OutputTestOutputOnTestFailure = true;
+ this->Impl->OutputTestOutputOnTestFailure = true;
}
if (this->CheckArgument(arg, "--test-output-size-passed") &&
i < args.size() - 1) {
i++;
long outputSize;
- if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize)) {
- if (cmCTestTestHandler* pCTestTestHandler =
- static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"])) {
- pCTestTestHandler->SetTestOutputSizePassed(int(outputSize));
- }
+ if (cmStrToLong(args[i], &outputSize)) {
+ this->Impl->TestHandler.SetTestOutputSizePassed(int(outputSize));
} else {
cmCTestLog(this, WARNING,
"Invalid value for '--test-output-size-passed': " << args[i]
@@ -1799,11 +1952,8 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
i < args.size() - 1) {
i++;
long outputSize;
- if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize)) {
- if (cmCTestTestHandler* pCTestTestHandler =
- static_cast<cmCTestTestHandler*>(this->TestingHandlers["test"])) {
- pCTestTestHandler->SetTestOutputSizeFailed(int(outputSize));
- }
+ if (cmStrToLong(args[i], &outputSize)) {
+ this->Impl->TestHandler.SetTestOutputSizeFailed(int(outputSize));
} else {
cmCTestLog(this, WARNING,
"Invalid value for '--test-output-size-failed': " << args[i]
@@ -1811,7 +1961,24 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
}
}
if (this->CheckArgument(arg, "-N", "--show-only")) {
- this->ShowOnly = true;
+ this->Impl->ShowOnly = true;
+ }
+ if (cmHasLiteralPrefix(arg, "--show-only=")) {
+ this->Impl->ShowOnly = true;
+
+ // Check if a specific format is requested. Defaults to human readable
+ // text.
+ std::string argWithFormat = "--show-only=";
+ std::string format = arg.substr(argWithFormat.length());
+ if (format == "json-v1") {
+ // Force quiet mode so the only output is the json object model.
+ this->Impl->Quiet = true;
+ this->Impl->OutputAsJson = true;
+ this->Impl->OutputAsJsonVersion = 1;
+ } else if (format != "human") {
+ errormsg = "'--show-only=' given unknown value '" + format + "'";
+ return false;
+ }
}
if (this->CheckArgument(arg, "-O", "--output-log") && i < args.size() - 1) {
@@ -1820,25 +1987,25 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
}
if (this->CheckArgument(arg, "--tomorrow-tag")) {
- this->TomorrowTag = true;
+ this->Impl->TomorrowTag = true;
}
if (this->CheckArgument(arg, "--force-new-ctest-process")) {
- this->ForceNewCTestProcess = true;
+ this->Impl->ForceNewCTestProcess = true;
}
if (this->CheckArgument(arg, "-W", "--max-width") && i < args.size() - 1) {
i++;
- this->MaxTestNameWidth = atoi(args[i].c_str());
+ this->Impl->MaxTestNameWidth = atoi(args[i].c_str());
}
if (this->CheckArgument(arg, "--interactive-debug-mode") &&
i < args.size() - 1) {
i++;
- this->InteractiveDebugMode = cmSystemTools::IsOn(args[i].c_str());
+ this->Impl->InteractiveDebugMode = cmIsOn(args[i]);
}
if (this->CheckArgument(arg, "--submit-index") && i < args.size() - 1) {
i++;
- this->SubmitIndex = atoi(args[i].c_str());
- if (this->SubmitIndex < 0) {
- this->SubmitIndex = 0;
+ this->Impl->SubmitIndex = atoi(args[i].c_str());
+ if (this->Impl->SubmitIndex < 0) {
+ this->Impl->SubmitIndex = 0;
}
}
@@ -1847,7 +2014,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
this->AddCTestConfigurationOverwrite(args[i]);
}
if (this->CheckArgument(arg, "-A", "--add-notes") && i < args.size() - 1) {
- this->ProduceXML = true;
+ this->Impl->ProduceXML = true;
this->SetTest("Notes");
i++;
this->SetNotesFiles(args[i].c_str());
@@ -1857,82 +2024,128 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
if (this->CheckArgument(arg, "-I", "--tests-information") &&
i < args.size() - 1) {
i++;
- this->GetHandler("test")->SetPersistentOption("TestsToRunInformation",
- args[i].c_str());
- this->GetHandler("memcheck")
- ->SetPersistentOption("TestsToRunInformation", args[i].c_str());
+ this->GetTestHandler()->SetPersistentOption("TestsToRunInformation",
+ args[i].c_str());
+ this->GetMemCheckHandler()->SetPersistentOption("TestsToRunInformation",
+ args[i].c_str());
}
if (this->CheckArgument(arg, "-U", "--union")) {
- this->GetHandler("test")->SetPersistentOption("UseUnion", "true");
- this->GetHandler("memcheck")->SetPersistentOption("UseUnion", "true");
+ this->GetTestHandler()->SetPersistentOption("UseUnion", "true");
+ this->GetMemCheckHandler()->SetPersistentOption("UseUnion", "true");
}
if (this->CheckArgument(arg, "-R", "--tests-regex") && i < args.size() - 1) {
i++;
- this->GetHandler("test")->SetPersistentOption("IncludeRegularExpression",
- args[i].c_str());
- this->GetHandler("memcheck")
- ->SetPersistentOption("IncludeRegularExpression", args[i].c_str());
+ this->GetTestHandler()->SetPersistentOption("IncludeRegularExpression",
+ args[i].c_str());
+ this->GetMemCheckHandler()->SetPersistentOption("IncludeRegularExpression",
+ args[i].c_str());
}
if (this->CheckArgument(arg, "-L", "--label-regex") && i < args.size() - 1) {
i++;
- this->GetHandler("test")->SetPersistentOption("LabelRegularExpression",
- args[i].c_str());
- this->GetHandler("memcheck")
- ->SetPersistentOption("LabelRegularExpression", args[i].c_str());
+ this->GetTestHandler()->SetPersistentOption("LabelRegularExpression",
+ args[i].c_str());
+ this->GetMemCheckHandler()->SetPersistentOption("LabelRegularExpression",
+ args[i].c_str());
}
if (this->CheckArgument(arg, "-LE", "--label-exclude") &&
i < args.size() - 1) {
i++;
- this->GetHandler("test")->SetPersistentOption(
+ this->GetTestHandler()->SetPersistentOption(
+ "ExcludeLabelRegularExpression", args[i].c_str());
+ this->GetMemCheckHandler()->SetPersistentOption(
"ExcludeLabelRegularExpression", args[i].c_str());
- this->GetHandler("memcheck")
- ->SetPersistentOption("ExcludeLabelRegularExpression", args[i].c_str());
}
if (this->CheckArgument(arg, "-E", "--exclude-regex") &&
i < args.size() - 1) {
i++;
- this->GetHandler("test")->SetPersistentOption("ExcludeRegularExpression",
- args[i].c_str());
- this->GetHandler("memcheck")
- ->SetPersistentOption("ExcludeRegularExpression", args[i].c_str());
+ this->GetTestHandler()->SetPersistentOption("ExcludeRegularExpression",
+ args[i].c_str());
+ this->GetMemCheckHandler()->SetPersistentOption("ExcludeRegularExpression",
+ args[i].c_str());
}
if (this->CheckArgument(arg, "-FA", "--fixture-exclude-any") &&
i < args.size() - 1) {
i++;
- this->GetHandler("test")->SetPersistentOption(
+ this->GetTestHandler()->SetPersistentOption(
+ "ExcludeFixtureRegularExpression", args[i].c_str());
+ this->GetMemCheckHandler()->SetPersistentOption(
"ExcludeFixtureRegularExpression", args[i].c_str());
- this->GetHandler("memcheck")
- ->SetPersistentOption("ExcludeFixtureRegularExpression",
- args[i].c_str());
}
if (this->CheckArgument(arg, "-FS", "--fixture-exclude-setup") &&
i < args.size() - 1) {
i++;
- this->GetHandler("test")->SetPersistentOption(
+ this->GetTestHandler()->SetPersistentOption(
+ "ExcludeFixtureSetupRegularExpression", args[i].c_str());
+ this->GetMemCheckHandler()->SetPersistentOption(
"ExcludeFixtureSetupRegularExpression", args[i].c_str());
- this->GetHandler("memcheck")
- ->SetPersistentOption("ExcludeFixtureSetupRegularExpression",
- args[i].c_str());
}
if (this->CheckArgument(arg, "-FC", "--fixture-exclude-cleanup") &&
i < args.size() - 1) {
i++;
- this->GetHandler("test")->SetPersistentOption(
+ this->GetTestHandler()->SetPersistentOption(
"ExcludeFixtureCleanupRegularExpression", args[i].c_str());
- this->GetHandler("memcheck")
- ->SetPersistentOption("ExcludeFixtureCleanupRegularExpression",
- args[i].c_str());
+ this->GetMemCheckHandler()->SetPersistentOption(
+ "ExcludeFixtureCleanupRegularExpression", args[i].c_str());
+ }
+
+ if (this->CheckArgument(arg, "--resource-spec-file") &&
+ i < args.size() - 1) {
+ i++;
+ this->GetTestHandler()->SetPersistentOption("ResourceSpecFile",
+ args[i].c_str());
+ this->GetMemCheckHandler()->SetPersistentOption("ResourceSpecFile",
+ args[i].c_str());
}
if (this->CheckArgument(arg, "--rerun-failed")) {
- this->GetHandler("test")->SetPersistentOption("RerunFailed", "true");
- this->GetHandler("memcheck")->SetPersistentOption("RerunFailed", "true");
+ this->GetTestHandler()->SetPersistentOption("RerunFailed", "true");
+ this->GetMemCheckHandler()->SetPersistentOption("RerunFailed", "true");
}
return true;
}
+#if !defined(_WIN32)
+bool cmCTest::ConsoleIsNotDumb()
+{
+ std::string term_env_variable;
+ if (cmSystemTools::GetEnv("TERM", term_env_variable)) {
+ return isatty(1) && term_env_variable != "dumb";
+ }
+ return false;
+}
+#endif
+
+bool cmCTest::ProgressOutputSupportedByConsole()
+{
+#if defined(_WIN32)
+ // On Windows we need a console buffer.
+ void* console = GetStdHandle(STD_OUTPUT_HANDLE);
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+ return GetConsoleScreenBufferInfo(console, &csbi);
+#else
+ // On UNIX we need a non-dumb tty.
+ return ConsoleIsNotDumb();
+#endif
+}
+
+bool cmCTest::ColoredOutputSupportedByConsole()
+{
+#if defined(_WIN32)
+ // Not supported on Windows
+ return false;
+#else
+ // On UNIX we need a non-dumb tty.
+ std::string clicolor_force;
+ if (cmSystemTools::GetEnv("CLICOLOR_FORCE", clicolor_force) &&
+ !clicolor_force.empty() && clicolor_force != "0") {
+ return true;
+ }
+ return ConsoleIsNotDumb();
+#endif
+}
+
// handle the -S -SR and -SP arguments
void cmCTest::HandleScriptArguments(size_t& i, std::vector<std::string>& args,
bool& SRArgumentSpecified)
@@ -1940,10 +2153,9 @@ void cmCTest::HandleScriptArguments(size_t& i, std::vector<std::string>& args,
std::string arg = args[i];
if (this->CheckArgument(arg, "-SP", "--script-new-process") &&
i < args.size() - 1) {
- this->RunConfigurationScript = true;
+ this->Impl->RunConfigurationScript = true;
i++;
- cmCTestScriptHandler* ch =
- static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+ cmCTestScriptHandler* ch = this->GetScriptHandler();
// -SR is an internal argument, -SP should be ignored when it is passed
if (!SRArgumentSpecified) {
ch->AddConfigurationScript(args[i].c_str(), false);
@@ -1952,18 +2164,16 @@ void cmCTest::HandleScriptArguments(size_t& i, std::vector<std::string>& args,
if (this->CheckArgument(arg, "-SR", "--script-run") && i < args.size() - 1) {
SRArgumentSpecified = true;
- this->RunConfigurationScript = true;
+ this->Impl->RunConfigurationScript = true;
i++;
- cmCTestScriptHandler* ch =
- static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+ cmCTestScriptHandler* ch = this->GetScriptHandler();
ch->AddConfigurationScript(args[i].c_str(), true);
}
if (this->CheckArgument(arg, "-S", "--script") && i < args.size() - 1) {
- this->RunConfigurationScript = true;
+ this->Impl->RunConfigurationScript = true;
i++;
- cmCTestScriptHandler* ch =
- static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+ cmCTestScriptHandler* ch = this->GetScriptHandler();
// -SR is an internal argument, -S should be ignored when it is passed
if (!SRArgumentSpecified) {
ch->AddConfigurationScript(args[i].c_str(), true);
@@ -1978,7 +2188,7 @@ bool cmCTest::AddVariableDefinition(const std::string& arg)
cmStateEnums::CacheEntryType type = cmStateEnums::UNINITIALIZED;
if (cmake::ParseCacheEntry(arg, name, value, type)) {
- this->Definitions[name] = value;
+ this->Impl->Definitions[name] = value;
return true;
}
@@ -1994,15 +2204,14 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
bool SRArgumentSpecified = false;
// copy the command line
- this->InitialCommandLineArguments.insert(
- this->InitialCommandLineArguments.end(), args.begin(), args.end());
+ cmAppend(this->Impl->InitialCommandLineArguments, args);
// process the command line arguments
for (size_t i = 1; i < args.size(); ++i) {
// handle the simple commandline arguments
std::string errormsg;
if (!this->HandleCommandLineArguments(i, args, errormsg)) {
- cmSystemTools::Error(errormsg.c_str());
+ cmSystemTools::Error(errormsg);
return 1;
}
@@ -2012,7 +2221,7 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
// --dashboard: handle a request for a dashboard
std::string arg = args[i];
if (this->CheckArgument(arg, "-D", "--dashboard") && i < args.size() - 1) {
- this->ProduceXML = true;
+ this->Impl->ProduceXML = true;
i++;
std::string targ = args[i];
// AddTestsForDashboard parses the dashboard type and converts it
@@ -2030,7 +2239,7 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
// attempts are simply ignored since previous ctest versions ignore
// this too. (As well as many other unknown command line args.)
//
- if (arg != "-D" && cmSystemTools::StringStartsWith(arg.c_str(), "-D")) {
+ if (arg != "-D" && cmHasLiteralPrefix(arg, "-D")) {
std::string input = arg.substr(2);
this->AddVariableDefinition(input);
}
@@ -2048,7 +2257,7 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
// --extra-submit
if (this->CheckArgument(arg, "--extra-submit") && i < args.size() - 1) {
- this->ProduceXML = true;
+ this->Impl->ProduceXML = true;
this->SetTest("Submit");
i++;
if (!this->SubmitExtraFiles(args[i].c_str())) {
@@ -2063,16 +2272,14 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
// --schedule-random
if (this->CheckArgument(arg, "--schedule-random")) {
- this->ScheduleType = "Random";
+ this->Impl->ScheduleType = "Random";
}
// pass the argument to all the handlers as well, but i may no longer be
// set to what it was originally so I'm not sure this is working as
// intended
- cmCTest::t_TestingHandlers::iterator it;
- for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
- ++it) {
- if (!it->second->ProcessCommandLineArguments(arg, i, args)) {
+ for (auto& handler : this->Impl->GetTestingHandlers()) {
+ if (!handler->ProcessCommandLineArguments(arg, i, args)) {
cmCTestLog(this, ERROR_MESSAGE,
"Problem parsing command line arguments within a handler");
return 0;
@@ -2081,7 +2288,7 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
} // the close of the for argument loop
// handle CTEST_PARALLEL_LEVEL environment variable
- if (!this->ParallelLevelSetInCli) {
+ if (!this->Impl->ParallelLevelSetInCli) {
std::string parallel;
if (cmSystemTools::GetEnv("CTEST_PARALLEL_LEVEL", parallel)) {
int plevel = atoi(parallel.c_str());
@@ -2089,6 +2296,18 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output)
}
}
+ // TestProgressOutput only supported if console supports it and not logging
+ // to a file
+ this->Impl->TestProgressOutput = this->Impl->TestProgressOutput &&
+ !this->Impl->OutputLogFile && this->ProgressOutputSupportedByConsole();
+#ifdef _WIN32
+ if (this->Impl->TestProgressOutput) {
+ // Disable output line buffering so we can print content without
+ // a newline.
+ std::setvbuf(stdout, nullptr, _IONBF, 0);
+ }
+#endif
+
// now what should cmake do? if --build-and-test was specified then
// we run the build and test handler and return
if (cmakeAndTest) {
@@ -2109,13 +2328,15 @@ bool cmCTest::HandleTestActionArgument(const char* ctestExec, size_t& i,
std::string arg = args[i];
if (this->CheckArgument(arg, "-T", "--test-action") &&
(i < args.size() - 1)) {
- this->ProduceXML = true;
+ this->Impl->ProduceXML = true;
i++;
if (!this->SetTest(args[i].c_str(), false)) {
success = false;
- cmCTestLog(this, ERROR_MESSAGE, "CTest -T called with incorrect option: "
- << args[i] << std::endl);
- cmCTestLog(this, ERROR_MESSAGE, "Available options are:"
+ cmCTestLog(this, ERROR_MESSAGE,
+ "CTest -T called with incorrect option: " << args[i]
+ << std::endl);
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Available options are:"
<< std::endl
<< " " << ctestExec << " -T all" << std::endl
<< " " << ctestExec << " -T start" << std::endl
@@ -2149,9 +2370,11 @@ bool cmCTest::HandleTestModelArgument(const char* ctestExec, size_t& i,
this->SetTestModel(cmCTest::EXPERIMENTAL);
} else {
success = false;
- cmCTestLog(this, ERROR_MESSAGE, "CTest -M called with incorrect option: "
- << str << std::endl);
- cmCTestLog(this, ERROR_MESSAGE, "Available options are:"
+ cmCTestLog(this, ERROR_MESSAGE,
+ "CTest -M called with incorrect option: " << str
+ << std::endl);
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Available options are:"
<< std::endl
<< " " << ctestExec << " -M Continuous" << std::endl
<< " " << ctestExec << " -M Experimental" << std::endl
@@ -2165,18 +2388,16 @@ int cmCTest::ExecuteTests()
{
int res;
// call process directory
- if (this->RunConfigurationScript) {
- if (this->ExtraVerbose) {
+ if (this->Impl->RunConfigurationScript) {
+ if (this->Impl->ExtraVerbose) {
cmCTestLog(this, OUTPUT, "* Extra verbosity turned on" << std::endl);
}
- cmCTest::t_TestingHandlers::iterator it;
- for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
- ++it) {
- it->second->SetVerbose(this->ExtraVerbose);
- it->second->SetSubmitIndex(this->SubmitIndex);
+ for (auto& handler : this->Impl->GetTestingHandlers()) {
+ handler->SetVerbose(this->Impl->ExtraVerbose);
+ handler->SetSubmitIndex(this->Impl->SubmitIndex);
}
- this->GetHandler("script")->SetVerbose(this->Verbose);
- res = this->GetHandler("script")->ProcessHandler();
+ this->GetScriptHandler()->SetVerbose(this->Impl->Verbose);
+ res = this->GetScriptHandler()->ProcessHandler();
if (res != 0) {
cmCTestLog(this, DEBUG,
"running script failing returning: " << res << std::endl);
@@ -2185,19 +2406,17 @@ int cmCTest::ExecuteTests()
} else {
// What is this? -V seems to be the same as -VV,
// and Verbose is always on in this case
- this->ExtraVerbose = this->Verbose;
- this->Verbose = true;
- cmCTest::t_TestingHandlers::iterator it;
- for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
- ++it) {
- it->second->SetVerbose(this->Verbose);
- it->second->SetSubmitIndex(this->SubmitIndex);
+ this->Impl->ExtraVerbose = this->Impl->Verbose;
+ this->Impl->Verbose = true;
+ for (auto& handler : this->Impl->GetTestingHandlers()) {
+ handler->SetVerbose(this->Impl->Verbose);
+ handler->SetSubmitIndex(this->Impl->SubmitIndex);
}
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- if (!this->Initialize(cwd.c_str(), CM_NULLPTR)) {
+ if (!this->Initialize(cwd.c_str(), nullptr)) {
res = 12;
- cmCTestLog(this, ERROR_MESSAGE, "Problem initializing the dashboard."
- << std::endl);
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Problem initializing the dashboard." << std::endl);
} else {
res = this->ProcessSteps();
}
@@ -2212,17 +2431,16 @@ int cmCTest::ExecuteTests()
int cmCTest::RunCMakeAndTest(std::string* output)
{
- this->Verbose = true;
- cmCTestBuildAndTestHandler* handler =
- static_cast<cmCTestBuildAndTestHandler*>(this->GetHandler("buildtest"));
+ this->Impl->Verbose = true;
+ cmCTestBuildAndTestHandler* handler = this->GetBuildAndTestHandler();
int retv = handler->ProcessHandler();
*output = handler->GetOutput();
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmDynamicLoader::FlushCache();
#endif
if (retv != 0) {
- cmCTestLog(this, DEBUG, "build and test failing returning: " << retv
- << std::endl);
+ cmCTestLog(this, DEBUG,
+ "build and test failing returning: " << retv << std::endl);
}
return retv;
}
@@ -2232,36 +2450,81 @@ void cmCTest::SetNotesFiles(const char* notes)
if (!notes) {
return;
}
- this->NotesFiles = notes;
+ this->Impl->NotesFiles = notes;
}
-void cmCTest::SetStopTime(std::string const& time)
+std::chrono::system_clock::time_point cmCTest::GetStopTime() const
{
- this->StopTime = time;
- this->DetermineNextDayStop();
+ return this->Impl->StopTime;
+}
+
+void cmCTest::SetStopTime(std::string const& time_str)
+{
+
+ struct tm* lctime;
+ time_t current_time = time(nullptr);
+ lctime = gmtime(&current_time);
+ int gm_hour = lctime->tm_hour;
+ time_t gm_time = mktime(lctime);
+ lctime = localtime(&current_time);
+ int local_hour = lctime->tm_hour;
+
+ int tzone_offset = local_hour - gm_hour;
+ if (gm_time > current_time && gm_hour < local_hour) {
+ // this means gm_time is on the next day
+ tzone_offset -= 24;
+ } else if (gm_time < current_time && gm_hour > local_hour) {
+ // this means gm_time is on the previous day
+ tzone_offset += 24;
+ }
+
+ tzone_offset *= 100;
+ char buf[1024];
+ sprintf(buf, "%d%02d%02d %s %+05i", lctime->tm_year + 1900,
+ lctime->tm_mon + 1, lctime->tm_mday, time_str.c_str(), tzone_offset);
+
+ time_t stop_time = curl_getdate(buf, &current_time);
+ if (stop_time == -1) {
+ this->Impl->StopTime = std::chrono::system_clock::time_point();
+ return;
+ }
+ this->Impl->StopTime = std::chrono::system_clock::from_time_t(stop_time);
+
+ if (stop_time < current_time) {
+ this->Impl->StopTime += std::chrono::hours(24);
+ }
+}
+
+std::string cmCTest::GetScheduleType() const
+{
+ return this->Impl->ScheduleType;
+}
+
+void cmCTest::SetScheduleType(std::string const& type)
+{
+ this->Impl->ScheduleType = type;
}
int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
{
bool found = false;
- VectorOfStrings dirs;
- VectorOfStrings ndirs;
- cmCTestLog(this, DEBUG, "* Read custom CTest configuration directory: "
- << dir << std::endl);
+ cmCTestLog(this, DEBUG,
+ "* Read custom CTest configuration directory: " << dir
+ << std::endl);
- std::string fname = dir;
- fname += "/CTestCustom.cmake";
+ std::string fname = cmStrCat(dir, "/CTestCustom.cmake");
cmCTestLog(this, DEBUG, "* Check for file: " << fname << std::endl);
- if (cmSystemTools::FileExists(fname.c_str())) {
- cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: "
- << fname << std::endl);
+ if (cmSystemTools::FileExists(fname)) {
+ cmCTestLog(this, DEBUG,
+ "* Read custom CTest configuration file: " << fname
+ << std::endl);
bool erroroc = cmSystemTools::GetErrorOccuredFlag();
cmSystemTools::ResetErrorOccuredFlag();
- if (!mf->ReadListFile(fname.c_str()) ||
- cmSystemTools::GetErrorOccuredFlag()) {
- cmCTestLog(this, ERROR_MESSAGE, "Problem reading custom configuration: "
- << fname << std::endl);
+ if (!mf->ReadListFile(fname) || cmSystemTools::GetErrorOccuredFlag()) {
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Problem reading custom configuration: " << fname
+ << std::endl);
}
found = true;
if (erroroc) {
@@ -2269,22 +2532,20 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
}
}
- std::string rexpr = dir;
- rexpr += "/CTestCustom.ctest";
+ std::string rexpr = cmStrCat(dir, "/CTestCustom.ctest");
cmCTestLog(this, DEBUG, "* Check for file: " << rexpr << std::endl);
- if (!found && cmSystemTools::FileExists(rexpr.c_str())) {
+ if (!found && cmSystemTools::FileExists(rexpr)) {
cmsys::Glob gl;
gl.RecurseOn();
gl.FindFiles(rexpr);
std::vector<std::string>& files = gl.GetFiles();
- std::vector<std::string>::iterator fileIt;
- for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
- cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: "
- << *fileIt << std::endl);
- if (!mf->ReadListFile(fileIt->c_str()) ||
- cmSystemTools::GetErrorOccuredFlag()) {
+ for (const std::string& file : files) {
+ cmCTestLog(this, DEBUG,
+ "* Read custom CTest configuration file: " << file
+ << std::endl);
+ if (!mf->ReadListFile(file) || cmSystemTools::GetErrorOccuredFlag()) {
cmCTestLog(this, ERROR_MESSAGE,
- "Problem reading custom configuration: " << *fileIt
+ "Problem reading custom configuration: " << file
<< std::endl);
}
}
@@ -2292,13 +2553,12 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
}
if (found) {
- cmCTest::t_TestingHandlers::iterator it;
- for (it = this->TestingHandlers.begin(); it != this->TestingHandlers.end();
- ++it) {
+ for (auto& handler : this->Impl->GetNamedTestingHandlers()) {
cmCTestLog(this, DEBUG,
"* Read custom CTest configuration vectors for handler: "
- << it->first << " (" << it->second << ")" << std::endl);
- it->second->PopulateCustomVectors(mf);
+ << handler.first << " (" << handler.second << ")"
+ << std::endl);
+ handler.second->PopulateCustomVectors(mf);
}
}
@@ -2315,11 +2575,10 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def,
cmCTestLog(this, DEBUG, "PopulateCustomVector: " << def << std::endl);
vec.clear();
- cmSystemTools::ExpandListArgument(dval, vec);
+ cmExpandList(dval, vec);
- for (std::vector<std::string>::const_iterator it = vec.begin();
- it != vec.end(); ++it) {
- cmCTestLog(this, DEBUG, " -- " << *it << std::endl);
+ for (std::string const& it : vec) {
+ cmCTestLog(this, DEBUG, " -- " << it << std::endl);
}
}
@@ -2342,17 +2601,15 @@ std::string cmCTest::GetShortPathToFile(const char* cfname)
std::string fname = cmSystemTools::CollapseFullPath(cfname);
// Find relative paths to both directories
- std::string srcRelpath =
- cmSystemTools::RelativePath(sourceDir.c_str(), fname.c_str());
- std::string bldRelpath =
- cmSystemTools::RelativePath(buildDir.c_str(), fname.c_str());
+ std::string srcRelpath = cmSystemTools::RelativePath(sourceDir, fname);
+ std::string bldRelpath = cmSystemTools::RelativePath(buildDir, fname);
// If any contains "." it is not parent directory
bool inSrc = srcRelpath.find("..") == std::string::npos;
bool inBld = bldRelpath.find("..") == std::string::npos;
// TODO: Handle files with .. in their name
- std::string* res = CM_NULLPTR;
+ std::string* res = nullptr;
if (inSrc && inBld) {
// If both have relative path with no dots, pick the shorter one
@@ -2375,7 +2632,7 @@ std::string cmCTest::GetShortPathToFile(const char* cfname)
cmSystemTools::ConvertToUnixSlashes(*res);
path = "./" + *res;
- if (path[path.size() - 1] == '/') {
+ if (path.back() == '/') {
path = path.substr(0, path.size() - 1);
}
}
@@ -2387,54 +2644,23 @@ std::string cmCTest::GetShortPathToFile(const char* cfname)
std::string cmCTest::GetCTestConfiguration(const std::string& name)
{
- if (this->CTestConfigurationOverwrites.find(name) !=
- this->CTestConfigurationOverwrites.end()) {
- return this->CTestConfigurationOverwrites[name];
+ if (this->Impl->CTestConfigurationOverwrites.find(name) !=
+ this->Impl->CTestConfigurationOverwrites.end()) {
+ return this->Impl->CTestConfigurationOverwrites[name];
}
- return this->CTestConfiguration[name];
+ return this->Impl->CTestConfiguration[name];
}
void cmCTest::EmptyCTestConfiguration()
{
- this->CTestConfiguration.clear();
-}
-
-void cmCTest::DetermineNextDayStop()
-{
- struct tm* lctime;
- time_t current_time = time(CM_NULLPTR);
- lctime = gmtime(&current_time);
- int gm_hour = lctime->tm_hour;
- time_t gm_time = mktime(lctime);
- lctime = localtime(&current_time);
- int local_hour = lctime->tm_hour;
-
- int tzone_offset = local_hour - gm_hour;
- if (gm_time > current_time && gm_hour < local_hour) {
- // this means gm_time is on the next day
- tzone_offset -= 24;
- } else if (gm_time < current_time && gm_hour > local_hour) {
- // this means gm_time is on the previous day
- tzone_offset += 24;
- }
-
- tzone_offset *= 100;
- char buf[1024];
- sprintf(buf, "%d%02d%02d %s %+05i", lctime->tm_year + 1900,
- lctime->tm_mon + 1, lctime->tm_mday, this->StopTime.c_str(),
- tzone_offset);
-
- time_t stop_time = curl_getdate(buf, &current_time);
-
- if (stop_time < current_time) {
- this->NextDayStopTime = true;
- }
+ this->Impl->CTestConfiguration.clear();
}
void cmCTest::SetCTestConfiguration(const char* name, const char* value,
bool suppress)
{
- cmCTestOptionalLog(this, HANDLER_VERBOSE_OUTPUT, "SetCTestConfiguration:"
+ cmCTestOptionalLog(this, HANDLER_VERBOSE_OUTPUT,
+ "SetCTestConfiguration:"
<< name << ":" << (value ? value : "(null)") << "\n",
suppress);
@@ -2442,67 +2668,223 @@ void cmCTest::SetCTestConfiguration(const char* name, const char* value,
return;
}
if (!value) {
- this->CTestConfiguration.erase(name);
+ this->Impl->CTestConfiguration.erase(name);
return;
}
- this->CTestConfiguration[name] = value;
+ this->Impl->CTestConfiguration[name] = value;
+}
+
+std::string cmCTest::GetSubmitURL()
+{
+ std::string url = this->GetCTestConfiguration("SubmitURL");
+ if (url.empty()) {
+ std::string method = this->GetCTestConfiguration("DropMethod");
+ std::string user = this->GetCTestConfiguration("DropSiteUser");
+ std::string password = this->GetCTestConfiguration("DropSitePassword");
+ std::string site = this->GetCTestConfiguration("DropSite");
+ std::string location = this->GetCTestConfiguration("DropLocation");
+
+ url = cmStrCat(method.empty() ? "http" : method, "://");
+ if (!user.empty()) {
+ url += user;
+ if (!password.empty()) {
+ url += ':';
+ url += password;
+ }
+ url += '@';
+ }
+ url += site;
+ url += location;
+ }
+ return url;
}
std::string cmCTest::GetCurrentTag()
{
- return this->CurrentTag;
+ return this->Impl->CurrentTag;
}
std::string cmCTest::GetBinaryDir()
{
- return this->BinaryDir;
+ return this->Impl->BinaryDir;
}
std::string const& cmCTest::GetConfigType()
{
- return this->ConfigType;
+ return this->Impl->ConfigType;
+}
+
+cmDuration cmCTest::GetTimeOut() const
+{
+ return this->Impl->TimeOut;
+}
+
+void cmCTest::SetTimeOut(cmDuration t)
+{
+ this->Impl->TimeOut = t;
+}
+
+cmDuration cmCTest::GetGlobalTimeout() const
+{
+ return this->Impl->GlobalTimeout;
}
bool cmCTest::GetShowOnly()
{
- return this->ShowOnly;
+ return this->Impl->ShowOnly;
+}
+
+bool cmCTest::GetOutputAsJson()
+{
+ return this->Impl->OutputAsJson;
+}
+
+int cmCTest::GetOutputAsJsonVersion()
+{
+ return this->Impl->OutputAsJsonVersion;
+}
+
+bool cmCTest::ShouldUseHTTP10() const
+{
+ return this->Impl->UseHTTP10;
+}
+
+bool cmCTest::ShouldPrintLabels() const
+{
+ return this->Impl->PrintLabels;
}
int cmCTest::GetMaxTestNameWidth() const
{
- return this->MaxTestNameWidth;
+ return this->Impl->MaxTestNameWidth;
+}
+
+void cmCTest::SetMaxTestNameWidth(int w)
+{
+ this->Impl->MaxTestNameWidth = w;
}
void cmCTest::SetProduceXML(bool v)
{
- this->ProduceXML = v;
+ this->Impl->ProduceXML = v;
}
bool cmCTest::GetProduceXML()
{
- return this->ProduceXML;
+ return this->Impl->ProduceXML;
}
-const char* cmCTest::GetSpecificTrack()
+std::vector<std::string>& cmCTest::GetInitialCommandLineArguments()
{
- if (this->SpecificTrack.empty()) {
- return CM_NULLPTR;
+ return this->Impl->InitialCommandLineArguments;
+}
+
+const char* cmCTest::GetSpecificGroup()
+{
+ if (this->Impl->SpecificGroup.empty()) {
+ return nullptr;
}
- return this->SpecificTrack.c_str();
+ return this->Impl->SpecificGroup.c_str();
}
-void cmCTest::SetSpecificTrack(const char* track)
+void cmCTest::SetSpecificGroup(const char* group)
{
- if (!track) {
- this->SpecificTrack = "";
+ if (!group) {
+ this->Impl->SpecificGroup.clear();
return;
}
- this->SpecificTrack = track;
+ this->Impl->SpecificGroup = group;
+}
+
+void cmCTest::SetFailover(bool failover)
+{
+ this->Impl->Failover = failover;
+}
+
+bool cmCTest::GetFailover() const
+{
+ return this->Impl->Failover;
+}
+
+bool cmCTest::GetTestProgressOutput() const
+{
+ return this->Impl->TestProgressOutput;
+}
+
+bool cmCTest::GetVerbose() const
+{
+ return this->Impl->Verbose;
+}
+
+bool cmCTest::GetExtraVerbose() const
+{
+ return this->Impl->ExtraVerbose;
+}
+
+void cmCTest::SetStreams(std::ostream* out, std::ostream* err)
+{
+ this->Impl->StreamOut = out;
+ this->Impl->StreamErr = err;
+}
+
+bool cmCTest::GetLabelSummary() const
+{
+ return this->Impl->LabelSummary;
+}
+
+bool cmCTest::GetSubprojectSummary() const
+{
+ return this->Impl->SubprojectSummary;
+}
+
+bool cmCTest::GetOutputTestOutputOnTestFailure() const
+{
+ return this->Impl->OutputTestOutputOnTestFailure;
+}
+
+const std::map<std::string, std::string>& cmCTest::GetDefinitions() const
+{
+ return this->Impl->Definitions;
+}
+
+int cmCTest::GetTestRepeat() const
+{
+ return this->Impl->RepeatTests;
+}
+
+bool cmCTest::GetRepeatUntilFail() const
+{
+ return this->Impl->RepeatUntilFail;
+}
+
+void cmCTest::SetBuildID(const std::string& id)
+{
+ this->Impl->BuildID = id;
+}
+
+std::string cmCTest::GetBuildID() const
+{
+ return this->Impl->BuildID;
}
void cmCTest::AddSubmitFile(Part part, const char* name)
{
- this->Parts[part].SubmitFiles.push_back(name);
+ this->Impl->Parts[part].SubmitFiles.emplace_back(name);
+}
+
+std::vector<std::string> const& cmCTest::GetSubmitFiles(Part part) const
+{
+ return this->Impl->Parts[part].SubmitFiles;
+}
+
+void cmCTest::ClearSubmitFiles(Part part)
+{
+ this->Impl->Parts[part].SubmitFiles.clear();
+}
+
+void cmCTest::SetSuppressUpdatingCTestConfiguration(bool val)
+{
+ this->Impl->SuppressUpdatingCTestConfiguration = val;
}
void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr)
@@ -2518,14 +2900,14 @@ void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr)
}
std::string key = overStr.substr(0, epos);
std::string value = overStr.substr(epos + 1);
- this->CTestConfigurationOverwrites[key] = value;
+ this->Impl->CTestConfigurationOverwrites[key] = value;
}
void cmCTest::SetConfigType(const char* ct)
{
- this->ConfigType = ct ? ct : "";
- cmSystemTools::ReplaceString(this->ConfigType, ".\\", "");
- std::string confTypeEnv = "CMAKE_CONFIG_TYPE=" + this->ConfigType;
+ this->Impl->ConfigType = ct ? ct : "";
+ cmSystemTools::ReplaceString(this->Impl->ConfigType, ".\\", "");
+ std::string confTypeEnv = "CMAKE_CONFIG_TYPE=" + this->Impl->ConfigType;
cmSystemTools::PutEnv(confTypeEnv);
}
@@ -2546,33 +2928,28 @@ bool cmCTest::SetCTestConfigurationFromCMakeVariable(
return true;
}
-bool cmCTest::RunCommand(const char* command, std::string* stdOut,
- std::string* stdErr, int* retVal, const char* dir,
- double timeout, Encoding encoding)
+bool cmCTest::RunCommand(std::vector<std::string> const& args,
+ std::string* stdOut, std::string* stdErr, int* retVal,
+ const char* dir, cmDuration timeout,
+ Encoding encoding)
{
- std::vector<std::string> args = cmSystemTools::ParseArguments(command);
-
- if (args.empty()) {
- return false;
- }
-
std::vector<const char*> argv;
- for (std::vector<std::string>::const_iterator a = args.begin();
- a != args.end(); ++a) {
- argv.push_back(a->c_str());
+ argv.reserve(args.size() + 1);
+ for (std::string const& a : args) {
+ argv.push_back(a.c_str());
}
- argv.push_back(CM_NULLPTR);
+ argv.push_back(nullptr);
- *stdOut = "";
- *stdErr = "";
+ stdOut->clear();
+ stdErr->clear();
cmsysProcess* cp = cmsysProcess_New();
- cmsysProcess_SetCommand(cp, &*argv.begin());
+ cmsysProcess_SetCommand(cp, argv.data());
cmsysProcess_SetWorkingDirectory(cp, dir);
if (cmSystemTools::GetRunCommandHideConsole()) {
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
}
- cmsysProcess_SetTimeout(cp, timeout);
+ cmsysProcess_SetTimeout(cp, timeout.count());
cmsysProcess_Execute(cp);
std::vector<char> tempOutput;
@@ -2584,38 +2961,38 @@ bool cmCTest::RunCommand(const char* command, std::string* stdOut,
int res;
bool done = false;
while (!done) {
- res = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR);
+ res = cmsysProcess_WaitForData(cp, &data, &length, nullptr);
switch (res) {
case cmsysProcess_Pipe_STDOUT:
- tempOutput.insert(tempOutput.end(), data, data + length);
+ cmAppend(tempOutput, data, data + length);
break;
case cmsysProcess_Pipe_STDERR:
- tempError.insert(tempError.end(), data, data + length);
+ cmAppend(tempError, data, data + length);
break;
default:
done = true;
}
if ((res == cmsysProcess_Pipe_STDOUT || res == cmsysProcess_Pipe_STDERR) &&
- this->ExtraVerbose) {
+ this->Impl->ExtraVerbose) {
processOutput.DecodeText(data, length, strdata);
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
}
- if (this->ExtraVerbose) {
+ if (this->Impl->ExtraVerbose) {
processOutput.DecodeText(std::string(), strdata);
if (!strdata.empty()) {
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
}
- cmsysProcess_WaitForExit(cp, CM_NULLPTR);
+ cmsysProcess_WaitForExit(cp, nullptr);
if (!tempOutput.empty()) {
processOutput.DecodeText(tempOutput, tempOutput);
- stdOut->append(&*tempOutput.begin(), tempOutput.size());
+ stdOut->append(tempOutput.data(), tempOutput.size());
}
if (!tempError.empty()) {
processOutput.DecodeText(tempError, tempError);
- stdErr->append(&*tempError.begin(), tempError.size());
+ stdErr->append(tempError.data(), tempError.size());
}
bool result = true;
@@ -2650,12 +3027,12 @@ bool cmCTest::RunCommand(const char* command, std::string* stdOut,
void cmCTest::SetOutputLogFileName(const char* name)
{
- if (this->OutputLogFile) {
- delete this->OutputLogFile;
- this->OutputLogFile = CM_NULLPTR;
+ if (this->Impl->OutputLogFile) {
+ delete this->Impl->OutputLogFile;
+ this->Impl->OutputLogFile = nullptr;
}
if (name) {
- this->OutputLogFile = new cmGeneratedFileStream(name);
+ this->Impl->OutputLogFile = new cmGeneratedFileStream(name);
}
}
@@ -2663,22 +3040,18 @@ static const char* cmCTestStringLogType[] = { "DEBUG",
"OUTPUT",
"HANDLER_OUTPUT",
"HANDLER_PROGRESS_OUTPUT",
+ "HANDLER_TEST_PROGRESS_OUTPUT",
"HANDLER_VERBOSE_OUTPUT",
"WARNING",
"ERROR_MESSAGE",
- CM_NULLPTR };
+ nullptr };
#define cmCTestLogOutputFileLine(stream) \
- if (this->ShowLineNumbers) { \
- (stream) << std::endl << file << ":" << line << " "; \
- }
-
-void cmCTest::InitStreams()
-{
- // By default we write output to the process output streams.
- this->StreamOut = &std::cout;
- this->StreamErr = &std::cerr;
-}
+ do { \
+ if (this->Impl->ShowLineNumbers) { \
+ (stream) << std::endl << file << ":" << line << " "; \
+ } \
+ } while (false)
void cmCTest::Log(int logType, const char* file, int line, const char* msg,
bool suppress)
@@ -2690,42 +3063,70 @@ void cmCTest::Log(int logType, const char* file, int line, const char* msg,
return;
}
if (logType == cmCTest::HANDLER_PROGRESS_OUTPUT &&
- (this->Debug || this->ExtraVerbose)) {
+ (this->Impl->Debug || this->Impl->ExtraVerbose)) {
return;
}
- if (this->OutputLogFile) {
+ if (this->Impl->OutputLogFile) {
bool display = true;
- if (logType == cmCTest::DEBUG && !this->Debug) {
+ if (logType == cmCTest::DEBUG && !this->Impl->Debug) {
display = false;
}
- if (logType == cmCTest::HANDLER_VERBOSE_OUTPUT && !this->Debug &&
- !this->ExtraVerbose) {
+ if (logType == cmCTest::HANDLER_VERBOSE_OUTPUT && !this->Impl->Debug &&
+ !this->Impl->ExtraVerbose) {
display = false;
}
if (display) {
- cmCTestLogOutputFileLine(*this->OutputLogFile);
- if (logType != this->OutputLogFileLastTag) {
- *this->OutputLogFile << "[";
+ cmCTestLogOutputFileLine(*this->Impl->OutputLogFile);
+ if (logType != this->Impl->OutputLogFileLastTag) {
+ *this->Impl->OutputLogFile << "[";
if (logType >= OTHER || logType < 0) {
- *this->OutputLogFile << "OTHER";
+ *this->Impl->OutputLogFile << "OTHER";
} else {
- *this->OutputLogFile << cmCTestStringLogType[logType];
+ *this->Impl->OutputLogFile << cmCTestStringLogType[logType];
}
- *this->OutputLogFile << "] " << std::endl << std::flush;
+ *this->Impl->OutputLogFile << "] " << std::endl;
}
- *this->OutputLogFile << msg << std::flush;
- if (logType != this->OutputLogFileLastTag) {
- *this->OutputLogFile << std::endl << std::flush;
- this->OutputLogFileLastTag = logType;
+ *this->Impl->OutputLogFile << msg << std::flush;
+ if (logType != this->Impl->OutputLogFileLastTag) {
+ *this->Impl->OutputLogFile << std::endl;
+ this->Impl->OutputLogFileLastTag = logType;
}
}
}
- if (!this->Quiet) {
- std::ostream& out = *this->StreamOut;
- std::ostream& err = *this->StreamErr;
+ if (!this->Impl->Quiet) {
+ std::ostream& out = *this->Impl->StreamOut;
+ std::ostream& err = *this->Impl->StreamErr;
+
+ if (logType == HANDLER_TEST_PROGRESS_OUTPUT) {
+ if (this->Impl->TestProgressOutput) {
+ cmCTestLogOutputFileLine(out);
+ if (this->Impl->FlushTestProgressLine) {
+ printf("\r");
+ this->Impl->FlushTestProgressLine = false;
+ out.flush();
+ }
+
+ std::string msg_str{ msg };
+ auto const lineBreakIt = msg_str.find('\n');
+ if (lineBreakIt != std::string::npos) {
+ this->Impl->FlushTestProgressLine = true;
+ msg_str.erase(std::remove(msg_str.begin(), msg_str.end(), '\n'),
+ msg_str.end());
+ }
+
+ out << msg_str;
+#ifndef _WIN32
+ printf("\x1B[K"); // move caret to end
+#endif
+ out.flush();
+ return;
+ }
+ logType = HANDLER_OUTPUT;
+ }
+
switch (logType) {
case DEBUG:
- if (this->Debug) {
+ if (this->Impl->Debug) {
cmCTestLogOutputFileLine(out);
out << msg;
out.flush();
@@ -2733,14 +3134,14 @@ void cmCTest::Log(int logType, const char* file, int line, const char* msg,
break;
case OUTPUT:
case HANDLER_OUTPUT:
- if (this->Debug || this->Verbose) {
+ if (this->Impl->Debug || this->Impl->Verbose) {
cmCTestLogOutputFileLine(out);
out << msg;
out.flush();
}
break;
case HANDLER_VERBOSE_OUTPUT:
- if (this->Debug || this->ExtraVerbose) {
+ if (this->Impl->Debug || this->Impl->ExtraVerbose) {
cmCTestLogOutputFileLine(out);
out << msg;
out.flush();
@@ -2765,25 +3166,42 @@ void cmCTest::Log(int logType, const char* file, int line, const char* msg,
}
}
-double cmCTest::GetRemainingTimeAllowed()
+std::string cmCTest::GetColorCode(Color color) const
{
- if (!this->GetHandler("script")) {
- return 1.0e7;
+ if (this->Impl->OutputColorCode) {
+#if defined(_WIN32)
+ // Not supported on Windows
+ static_cast<void>(color);
+#else
+ return "\033[0;" + std::to_string(static_cast<int>(color)) + "m";
+#endif
}
- cmCTestScriptHandler* ch =
- static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+ return "";
+}
- return ch->GetRemainingTimeAllowed();
+cmDuration cmCTest::GetRemainingTimeAllowed()
+{
+ return this->GetScriptHandler()->GetRemainingTimeAllowed();
+}
+
+cmDuration cmCTest::MaxDuration()
+{
+ return cmDuration(1.0e7);
+}
+
+void cmCTest::SetRunCurrentScript(bool value)
+{
+ this->GetScriptHandler()->SetRunCurrentScript(value);
}
void cmCTest::OutputTestErrors(std::vector<char> const& process_output)
{
std::string test_outputs("\n*** Test Failed:\n");
if (!process_output.empty()) {
- test_outputs.append(&*process_output.begin(), process_output.size());
+ test_outputs.append(process_output.data(), process_output.size());
}
- cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl << std::flush);
+ cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl);
}
bool cmCTest::CompressString(std::string& str)
@@ -2813,8 +3231,8 @@ bool cmCTest::CompressString(std::string& str)
ret = deflate(&strm, Z_FINISH);
if (ret != Z_STREAM_END) {
- cmCTestLog(this, ERROR_MESSAGE, "Error during gzip compression."
- << std::endl);
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Error during gzip compression." << std::endl);
return false;
}
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 60f3295e7..82a6f4cbd 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -3,18 +3,29 @@
#ifndef cmCTest_h
#define cmCTest_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmProcessOutput.h"
-#include "cmsys/String.hxx"
+#include <chrono>
+#include <ctime>
#include <map>
-#include <set>
+#include <memory>
#include <sstream>
#include <string>
-#include <time.h>
#include <vector>
-class cmCTestGenericHandler;
+#include "cmDuration.h"
+#include "cmProcessOutput.h"
+
+class cmCTestBuildHandler;
+class cmCTestBuildAndTestHandler;
+class cmCTestCoverageHandler;
+class cmCTestScriptHandler;
+class cmCTestTestHandler;
+class cmCTestUpdateHandler;
+class cmCTestConfigureHandler;
+class cmCTestMemCheckHandler;
+class cmCTestSubmitHandler;
+class cmCTestUploadHandler;
class cmCTestStartCommand;
class cmGeneratedFileStream;
class cmMakefile;
@@ -29,11 +40,8 @@ class cmXMLWriter;
*/
class cmCTest
{
- friend class cmCTestRunTest;
- friend class cmCTestMultiProcessHandler;
-
public:
- typedef cmProcessOutput::Encoding Encoding;
+ using Encoding = cmProcessOutput::Encoding;
/** Enumerate parts of the testing and submission process. */
enum Part
{
@@ -48,54 +56,16 @@ public:
PartNotes,
PartExtraFiles,
PartUpload,
+ PartDone,
PartCount // Update names in constructor when adding a part
};
- /** Representation of one part. */
- struct PartInfo
- {
- PartInfo()
- : Enabled(false)
- {
- }
-
- void SetName(const std::string& name) { this->Name = name; }
- const std::string& GetName() const { return this->Name; }
-
- void Enable() { this->Enabled = true; }
- operator bool() const { return this->Enabled; }
-
- std::vector<std::string> SubmitFiles;
-
- private:
- bool Enabled;
- std::string Name;
- };
-#ifdef CMAKE_BUILD_WITH_CMAKE
- enum HTTPMethod
- {
- HTTP_GET,
- HTTP_POST,
- HTTP_PUT
- };
-
- /**
- * Perform an HTTP request.
- */
- static int HTTPRequest(std::string url, HTTPMethod method,
- std::string& response, std::string const& fields = "",
- std::string const& putFile = "", int timeout = 0);
-#endif
-
/** Get a testing part id from its string name. Returns PartCount
if the string does not name a valid part. */
Part GetPartFromName(const char* name);
- typedef std::vector<cmsys::String> VectorOfStrings;
- typedef std::set<std::string> SetOfStrings;
-
/** Process Command line arguments */
- int Run(std::vector<std::string>&, std::string* output = CM_NULLPTR);
+ int Run(std::vector<std::string>&, std::string* output = nullptr);
/**
* Initialize and finalize testing
@@ -130,25 +100,25 @@ public:
/**
* Is the tomorrow tag set?
*/
- bool GetTomorrowTag() { return this->TomorrowTag; }
+ bool GetTomorrowTag() const;
/**
* Try to run tests of the project
*/
int TestDirectory(bool memcheck);
- /** what is the configuraiton type, e.g. Debug, Release etc. */
+ /** what is the configuration type, e.g. Debug, Release etc. */
std::string const& GetConfigType();
- double GetTimeOut() { return this->TimeOut; }
- void SetTimeOut(double t) { this->TimeOut = t; }
+ cmDuration GetTimeOut() const;
+ void SetTimeOut(cmDuration t);
- double GetGlobalTimeout() { return this->GlobalTimeout; }
+ cmDuration GetGlobalTimeout() const;
/** how many test to run at the same time */
- int GetParallelLevel() { return this->ParallelLevel; }
+ int GetParallelLevel() const;
void SetParallelLevel(int);
- unsigned long GetTestLoad() { return this->TestLoad; }
+ unsigned long GetTestLoad() const;
void SetTestLoad(unsigned long);
/**
@@ -166,7 +136,7 @@ public:
* Set the cmake test mode (experimental, nightly, continuous).
*/
void SetTestModel(int mode);
- int GetTestModel() { return this->TestModel; }
+ int GetTestModel() const;
std::string GetTestModelString();
static int GetTestModelFromString(const char* str);
@@ -176,12 +146,17 @@ public:
bool suppress = false);
void EmptyCTestConfiguration();
+ std::string GetSubmitURL();
+
/**
* constructor and destructor
*/
cmCTest();
~cmCTest();
+ cmCTest(const cmCTest&) = delete;
+ cmCTest& operator=(const cmCTest&) = delete;
+
/** Set the notes files to be created. */
void SetNotesFiles(const char* notes);
@@ -200,9 +175,11 @@ public:
/**
* Return the time remaining that the script is allowed to run in
* seconds if the user has set the variable CTEST_TIME_LIMIT. If that has
- * not been set it returns 1e7 seconds
+ * not been set it returns a very large duration.
*/
- double GetRemainingTimeAllowed();
+ cmDuration GetRemainingTimeAllowed();
+
+ static cmDuration MaxDuration();
/**
* Open file in the output directory and set the stream
@@ -213,23 +190,27 @@ public:
/** Should we only show what we would do? */
bool GetShowOnly();
- bool ShouldUseHTTP10() { return this->UseHTTP10; }
+ bool GetOutputAsJson();
+
+ int GetOutputAsJsonVersion();
+
+ bool ShouldUseHTTP10() const;
- bool ShouldPrintLabels() { return this->PrintLabels; }
+ bool ShouldPrintLabels() const;
bool ShouldCompressTestOutput();
bool CompressString(std::string& str);
- std::string GetStopTime() { return this->StopTime; }
+ std::chrono::system_clock::time_point GetStopTime() const;
void SetStopTime(std::string const& time);
/** Used for parallel ctest job scheduling */
- std::string GetScheduleType() { return this->ScheduleType; }
- void SetScheduleType(std::string const& type) { this->ScheduleType = type; }
+ std::string GetScheduleType() const;
+ void SetScheduleType(std::string const& type);
/** The max output width */
int GetMaxTestNameWidth() const;
- void SetMaxTestNameWidth(int w) { this->MaxTestNameWidth = w; }
+ void SetMaxTestNameWidth(int w);
/**
* Run a single executable command and put the stdout and stderr
@@ -245,15 +226,11 @@ public:
* exit code will be stored. If the retVal is not specified and
* the program exits with a code other than 0, then the this
* function will return false.
- *
- * If the command has spaces in the path the caller MUST call
- * cmSystemTools::ConvertToRunCommandPath on the command before passing
- * it into this function or it will not work. The command must be correctly
- * escaped for this to with spaces.
*/
- bool RunCommand(const char* command, std::string* stdOut,
- std::string* stdErr, int* retVal = CM_NULLPTR,
- const char* dir = CM_NULLPTR, double timeout = 0.0,
+ bool RunCommand(std::vector<std::string> const& args, std::string* stdOut,
+ std::string* stdErr, int* retVal = nullptr,
+ const char* dir = nullptr,
+ cmDuration timeout = cmDuration::zero(),
Encoding encoding = cmProcessOutput::Auto);
/**
@@ -272,8 +249,9 @@ public:
* Run command specialized for make and configure. Returns process status
* and retVal is return value or exception.
*/
- int RunMakeCommand(const char* command, std::string& output, int* retVal,
- const char* dir, int timeout, std::ostream& ofs,
+ int RunMakeCommand(const std::string& command, std::string& output,
+ int* retVal, const char* dir, cmDuration timeout,
+ std::ostream& ofs,
Encoding encoding = cmProcessOutput::Auto);
/** Return the current tag */
@@ -292,9 +270,10 @@ public:
enum
{
- EXPERIMENTAL,
- NIGHTLY,
- CONTINUOUS
+ UNKNOWN = -1,
+ EXPERIMENTAL = 0,
+ NIGHTLY = 1,
+ CONTINUOUS = 2,
};
/** provide some more detailed info on the return code for ctest */
@@ -320,21 +299,23 @@ public:
* environment variables are restored to their previous values.
*/
int RunTest(std::vector<const char*> args, std::string* output, int* retVal,
- std::ostream* logfile, double testTimeOut,
+ std::ostream* logfile, cmDuration testTimeOut,
std::vector<std::string>* environment,
Encoding encoding = cmProcessOutput::Auto);
/**
- * Execute handler and return its result. If the handler fails, it returns
- * negative value.
- */
- int ExecuteHandler(const char* handler);
-
- /**
* Get the handler object
*/
- cmCTestGenericHandler* GetHandler(const char* handler);
- cmCTestGenericHandler* GetInitializedHandler(const char* handler);
+ cmCTestBuildHandler* GetBuildHandler();
+ cmCTestBuildAndTestHandler* GetBuildAndTestHandler();
+ cmCTestCoverageHandler* GetCoverageHandler();
+ cmCTestScriptHandler* GetScriptHandler();
+ cmCTestTestHandler* GetTestHandler();
+ cmCTestUpdateHandler* GetUpdateHandler();
+ cmCTestConfigureHandler* GetConfigureHandler();
+ cmCTestMemCheckHandler* GetMemCheckHandler();
+ cmCTestSubmitHandler* GetSubmitHandler();
+ cmCTestUploadHandler* GetUploadHandler();
/**
* Set the CTest variable from CMake variable
@@ -344,9 +325,6 @@ public:
const std::string& cmake_var,
bool suppress = false);
- /** Make string safe to be send as an URL */
- static std::string MakeURLSafe(const std::string&);
-
/** Decode a URL to the original string. */
static std::string DecodeURL(const std::string&);
@@ -354,10 +332,7 @@ public:
* Should ctect configuration be updated. When using new style ctest
* script, this should be true.
*/
- void SetSuppressUpdatingCTestConfiguration(bool val)
- {
- this->SuppressUpdatingCTestConfiguration = val;
- }
+ void SetSuppressUpdatingCTestConfiguration(bool val);
/**
* Add overwrite to ctest configuration.
@@ -367,11 +342,14 @@ public:
void AddCTestConfigurationOverwrite(const std::string& encstr);
/** Create XML file that contains all the notes specified */
- int GenerateNotesFile(const VectorOfStrings& files);
+ int GenerateNotesFile(std::vector<std::string> const& files);
+
+ /** Create XML file to indicate that build is complete */
+ int GenerateDoneFile();
/** Submit extra files to the server */
bool SubmitExtraFiles(const char* files);
- bool SubmitExtraFiles(const VectorOfStrings& files);
+ bool SubmitExtraFiles(std::vector<std::string> const& files);
/** Set the output log file name */
void SetOutputLogFileName(const char* name);
@@ -386,6 +364,7 @@ public:
OUTPUT,
HANDLER_OUTPUT,
HANDLER_PROGRESS_OUTPUT,
+ HANDLER_TEST_PROGRESS_OUTPUT,
HANDLER_VERBOSE_OUTPUT,
WARNING,
ERROR_MESSAGE,
@@ -396,143 +375,74 @@ public:
void Log(int logType, const char* file, int line, const char* msg,
bool suppress = false);
- /** Get the version of dart server */
- int GetDartVersion() { return this->DartVersion; }
- int GetDropSiteCDash() { return this->DropSiteCDash; }
+ /** Color values */
+ enum class Color
+ {
+ CLEAR_COLOR = 0,
+ RED = 31,
+ GREEN = 32,
+ YELLOW = 33,
+ BLUE = 34
+ };
+
+ /** Get color code characters for a specific color */
+ std::string GetColorCode(Color color) const;
+
+ /** The Build ID is assigned by CDash */
+ void SetBuildID(const std::string& id);
+ std::string GetBuildID() const;
/** Add file to be submitted */
void AddSubmitFile(Part part, const char* name);
- std::vector<std::string> const& GetSubmitFiles(Part part)
- {
- return this->Parts[part].SubmitFiles;
- }
- void ClearSubmitFiles(Part part) { this->Parts[part].SubmitFiles.clear(); }
+ std::vector<std::string> const& GetSubmitFiles(Part part) const;
+ void ClearSubmitFiles(Part part);
/**
* Read the custom configuration files and apply them to the current ctest
*/
int ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf);
- std::vector<std::string>& GetInitialCommandLineArguments()
- {
- return this->InitialCommandLineArguments;
- }
+ std::vector<std::string>& GetInitialCommandLineArguments();
- /** Set the track to submit to */
- void SetSpecificTrack(const char* track);
- const char* GetSpecificTrack();
+ /** Set the group to submit to */
+ void SetSpecificGroup(const char* group);
+ const char* GetSpecificGroup();
- void SetFailover(bool failover) { this->Failover = failover; }
- bool GetFailover() { return this->Failover; }
+ void SetFailover(bool failover);
+ bool GetFailover() const;
- void SetBatchJobs(bool batch = true) { this->BatchJobs = batch; }
- bool GetBatchJobs() { return this->BatchJobs; }
+ bool GetTestProgressOutput() const;
- bool GetVerbose() { return this->Verbose; }
- bool GetExtraVerbose() { return this->ExtraVerbose; }
+ bool GetVerbose() const;
+ bool GetExtraVerbose() const;
/** Direct process output to given streams. */
- void SetStreams(std::ostream* out, std::ostream* err)
- {
- this->StreamOut = out;
- this->StreamErr = err;
- }
+ void SetStreams(std::ostream* out, std::ostream* err);
+
void AddSiteProperties(cmXMLWriter& xml);
- bool GetLabelSummary() { return this->LabelSummary; }
+
+ bool GetLabelSummary() const;
+ bool GetSubprojectSummary() const;
std::string GetCostDataFile();
- const std::map<std::string, std::string>& GetDefinitions()
- {
- return this->Definitions;
- }
+ bool GetOutputTestOutputOnTestFailure() const;
+
+ const std::map<std::string, std::string>& GetDefinitions() const;
/** Return the number of times a test should be run */
- int GetTestRepeat() { return this->RepeatTests; }
+ int GetTestRepeat() const;
/** Return true if test should run until fail */
- bool GetRepeatUntilFail() { return this->RepeatUntilFail; }
-
-private:
- int RepeatTests;
- bool RepeatUntilFail;
- std::string ConfigType;
- std::string ScheduleType;
- std::string StopTime;
- bool NextDayStopTime;
- bool Verbose;
- bool ExtraVerbose;
- bool ProduceXML;
- bool LabelSummary;
- bool UseHTTP10;
- bool PrintLabels;
- bool Failover;
- bool BatchJobs;
-
- bool ForceNewCTestProcess;
-
- bool RunConfigurationScript;
-
- int GenerateNotesFile(const char* files);
-
- void DetermineNextDayStop();
-
- // these are helper classes
- typedef std::map<std::string, cmCTestGenericHandler*> t_TestingHandlers;
- t_TestingHandlers TestingHandlers;
-
- bool ShowOnly;
-
- /** Map of configuration properties */
- typedef std::map<std::string, std::string> CTestConfigurationMap;
-
- std::string CTestConfigFile;
- // TODO: The ctest configuration should be a hierarchy of
- // configuration option sources: command-line, script, ini file.
- // Then the ini file can get re-loaded whenever it changes without
- // affecting any higher-precedence settings.
- CTestConfigurationMap CTestConfiguration;
- CTestConfigurationMap CTestConfigurationOverwrites;
- PartInfo Parts[PartCount];
- typedef std::map<std::string, Part> PartMapType;
- PartMapType PartMap;
-
- std::string CurrentTag;
- bool TomorrowTag;
-
- int TestModel;
- std::string SpecificTrack;
-
- double TimeOut;
-
- double GlobalTimeout;
-
- int LastStopTimeout;
+ bool GetRepeatUntilFail() const;
- int MaxTestNameWidth;
+ void GenerateSubprojectsOutput(cmXMLWriter& xml);
+ std::vector<std::string> GetLabelsForSubprojects();
- int ParallelLevel;
- bool ParallelLevelSetInCli;
+ void SetRunCurrentScript(bool value);
- unsigned long TestLoad;
-
- int CompatibilityMode;
-
- // information for the --build-and-test options
- std::string BinaryDir;
-
- std::string NotesFiles;
-
- bool InteractiveDebugMode;
-
- bool ShortDateFormat;
-
- bool CompressXMLFiles;
- bool CompressTestOutput;
-
- void InitStreams();
- std::ostream* StreamOut;
- std::ostream* StreamErr;
+private:
+ int GenerateNotesFile(const char* files);
void BlockTestErrorDiagnostics();
@@ -559,7 +469,18 @@ private:
bool HandleCommandLineArguments(size_t& i, std::vector<std::string>& args,
std::string& errormsg);
- /** hande the -S -SP and -SR arguments */
+#if !defined(_WIN32)
+ /** returns true iff the console supports progress output */
+ static bool ConsoleIsNotDumb();
+#endif
+
+ /** returns true iff the console supports progress output */
+ static bool ProgressOutputSupportedByConsole();
+
+ /** returns true iff the console supports colored output */
+ static bool ColoredOutputSupportedByConsole();
+
+ /** handle the -S -SP and -SR arguments */
void HandleScriptArguments(size_t& i, std::vector<std::string>& args,
bool& SRArgumentSpecified);
@@ -567,11 +488,12 @@ private:
bool UpdateCTestConfiguration();
/** Create note from files. */
- int GenerateCTestNotesOutput(cmXMLWriter& xml, const VectorOfStrings& files);
+ int GenerateCTestNotesOutput(cmXMLWriter& xml,
+ std::vector<std::string> const& files);
/** Check if the argument is the one specified */
bool CheckArgument(const std::string& arg, const char* varg1,
- const char* varg2 = CM_NULLPTR);
+ const char* varg2 = nullptr);
/** Output errors from a test */
void OutputTestErrors(std::vector<char> const& process_output);
@@ -587,25 +509,8 @@ private:
int RunCMakeAndTest(std::string* output);
int ExecuteTests();
- bool SuppressUpdatingCTestConfiguration;
-
- bool Debug;
- bool ShowLineNumbers;
- bool Quiet;
-
- int DartVersion;
- bool DropSiteCDash;
-
- std::vector<std::string> InitialCommandLineArguments;
-
- int SubmitIndex;
-
- cmGeneratedFileStream* OutputLogFile;
- int OutputLogFileLastTag;
-
- bool OutputTestOutputOnTestFailure;
-
- std::map<std::string, std::string> Definitions;
+ struct Private;
+ std::unique_ptr<Private> Impl;
};
class cmCTestLogWrite
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index 0b025ab6f..d627465c7 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -2,18 +2,22 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCacheManager.h"
-#include "cmsys/FStream.hxx"
-#include "cmsys/Glob.hxx"
#include <algorithm>
+#include <cstdio>
+#include <cstring>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
+#include <string>
+
+#include "cmsys/FStream.hxx"
+#include "cmsys/Glob.hxx"
#include "cmGeneratedFileStream.h"
+#include "cmMessageType.h"
+#include "cmMessenger.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
-#include "cmake.h"
cmCacheManager::cmCacheManager()
{
@@ -23,9 +27,7 @@ cmCacheManager::cmCacheManager()
void cmCacheManager::CleanCMakeFiles(const std::string& path)
{
- std::string glob = path;
- glob += cmake::GetCMakeFilesDirectory();
- glob += "/*.cmake";
+ std::string glob = cmStrCat(path, "/CMakeFiles/*.cmake");
cmsys::Glob globIt;
globIt.FindFiles(glob);
std::vector<std::string> files = globIt.GetFiles();
@@ -36,13 +38,12 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
std::set<std::string>& excludes,
std::set<std::string>& includes)
{
- std::string cacheFile = path;
- cacheFile += "/CMakeCache.txt";
+ std::string cacheFile = cmStrCat(path, "/CMakeCache.txt");
// clear the old cache, if we are reading in internal values
if (internal) {
this->Cache.clear();
}
- if (!cmSystemTools::FileExists(cacheFile.c_str())) {
+ if (!cmSystemTools::FileExists(cacheFile)) {
this->CleanCMakeFiles(path);
return false;
}
@@ -102,12 +103,10 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
// not visible in the gui
if (!internal) {
e.Type = cmStateEnums::INTERNAL;
- helpString = "DO NOT EDIT, ";
- helpString += entryKey;
- helpString += " loaded from external file. "
- "To change this value edit this file: ";
- helpString += path;
- helpString += "/CMakeCache.txt";
+ helpString = cmStrCat("DO NOT EDIT, ", entryKey,
+ " loaded from external file. "
+ "To change this value edit this file: ",
+ path, "/CMakeCache.txt");
e.SetProperty("HELPSTRING", helpString.c_str());
}
if (!this->ReadPropertyEntry(entryKey, e)) {
@@ -120,20 +119,20 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
std::ostringstream error;
error << "Parse error in cache file " << cacheFile;
error << " on line " << lineno << ". Offending entry: " << realbuffer;
- cmSystemTools::Error(error.str().c_str());
+ cmSystemTools::Error(error.str());
}
}
this->CacheMajorVersion = 0;
this->CacheMinorVersion = 0;
- if (const char* cmajor =
+ if (const std::string* cmajor =
this->GetInitializedCacheValue("CMAKE_CACHE_MAJOR_VERSION")) {
unsigned int v = 0;
- if (sscanf(cmajor, "%u", &v) == 1) {
+ if (sscanf(cmajor->c_str(), "%u", &v) == 1) {
this->CacheMajorVersion = v;
}
- if (const char* cminor =
+ if (const std::string* cminor =
this->GetInitializedCacheValue("CMAKE_CACHE_MINOR_VERSION")) {
- if (sscanf(cminor, "%u", &v) == 1) {
+ if (sscanf(cminor->c_str(), "%u", &v) == 1) {
this->CacheMinorVersion = v;
}
}
@@ -151,29 +150,31 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
}
// check to make sure the cache directory has not
// been moved
- const char* oldDir = this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
+ const std::string* oldDir =
+ this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
if (internal && oldDir) {
std::string currentcwd = path;
- std::string oldcwd = oldDir;
+ std::string oldcwd = *oldDir;
cmSystemTools::ConvertToUnixSlashes(currentcwd);
currentcwd += "/CMakeCache.txt";
oldcwd += "/CMakeCache.txt";
if (!cmSystemTools::SameFile(oldcwd, currentcwd)) {
- std::string message =
- std::string("The current CMakeCache.txt directory ") + currentcwd +
- std::string(" is different than the directory ") +
- std::string(this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR")) +
- std::string(" where CMakeCache.txt was created. This may result "
- "in binaries being created in the wrong place. If you "
- "are not sure, reedit the CMakeCache.txt");
- cmSystemTools::Error(message.c_str());
+ const std::string* dir =
+ this->GetInitializedCacheValue("CMAKE_CACHEFILE_DIR");
+ std::ostringstream message;
+ message << "The current CMakeCache.txt directory " << currentcwd
+ << " is different than the directory " << (dir ? *dir : "")
+ << " where CMakeCache.txt was created. This may result "
+ "in binaries being created in the wrong place. If you "
+ "are not sure, reedit the CMakeCache.txt";
+ cmSystemTools::Error(message.str());
}
}
return true;
}
const char* cmCacheManager::PersistentProperties[] = { "ADVANCED", "MODIFIED",
- "STRINGS", CM_NULLPTR };
+ "STRINGS", nullptr };
bool cmCacheManager::ReadPropertyEntry(std::string const& entryKey,
CacheEntry& e)
@@ -184,7 +185,7 @@ bool cmCacheManager::ReadPropertyEntry(std::string const& entryKey,
}
const char* end = entryKey.c_str() + entryKey.size();
- for (const char** p = this->PersistentProperties; *p; ++p) {
+ for (const char** p = cmCacheManager::PersistentProperties; *p; ++p) {
std::string::size_type plen = strlen(*p) + 1;
if (entryKey.size() > plen && *(end - plen) == '-' &&
strcmp(end - plen + 1, *p) == 0) {
@@ -205,53 +206,50 @@ bool cmCacheManager::ReadPropertyEntry(std::string const& entryKey,
return false;
}
-void cmCacheManager::WritePropertyEntries(std::ostream& os, CacheIterator i)
+void cmCacheManager::WritePropertyEntries(std::ostream& os, CacheIterator i,
+ cmMessenger* messenger)
{
- for (const char** p = this->PersistentProperties; *p; ++p) {
+ for (const char** p = cmCacheManager::PersistentProperties; *p; ++p) {
if (const char* value = i.GetProperty(*p)) {
- std::string helpstring = *p;
- helpstring += " property for variable: ";
- helpstring += i.GetName();
+ std::string helpstring =
+ cmStrCat(*p, " property for variable: ", i.GetName());
cmCacheManager::OutputHelpString(os, helpstring);
- std::string key = i.GetName();
- key += "-";
- key += *p;
- this->OutputKey(os, key);
+ std::string key = cmStrCat(i.GetName(), '-', *p);
+ cmCacheManager::OutputKey(os, key);
os << ":INTERNAL=";
- this->OutputValue(os, value);
+ cmCacheManager::OutputValue(os, value);
os << "\n";
+ cmCacheManager::OutputNewlineTruncationWarning(os, key, value,
+ messenger);
}
}
}
-bool cmCacheManager::SaveCache(const std::string& path)
+bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
{
- std::string cacheFile = path;
- cacheFile += "/CMakeCache.txt";
- cmGeneratedFileStream fout(cacheFile.c_str());
+ std::string cacheFile = cmStrCat(path, "/CMakeCache.txt");
+ cmGeneratedFileStream fout(cacheFile);
fout.SetCopyIfDifferent(true);
if (!fout) {
- cmSystemTools::Error("Unable to open cache file for save. ",
- cacheFile.c_str());
+ cmSystemTools::Error("Unable to open cache file for save. " + cacheFile);
cmSystemTools::ReportLastSystemError("");
return false;
}
// before writing the cache, update the version numbers
// to the
- char temp[1024];
- sprintf(temp, "%d", cmVersion::GetMinorVersion());
- this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", temp,
- "Minor version of cmake used to create the "
+ this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION",
+ std::to_string(cmVersion::GetMajorVersion()).c_str(),
+ "Major version of cmake used to create the "
"current loaded cache",
cmStateEnums::INTERNAL);
- sprintf(temp, "%d", cmVersion::GetMajorVersion());
- this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", temp,
- "Major version of cmake used to create the "
+ this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION",
+ std::to_string(cmVersion::GetMinorVersion()).c_str(),
+ "Minor version of cmake used to create the "
"current loaded cache",
cmStateEnums::INTERNAL);
- sprintf(temp, "%d", cmVersion::GetPatchVersion());
- this->AddCacheEntry("CMAKE_CACHE_PATCH_VERSION", temp,
+ this->AddCacheEntry("CMAKE_CACHE_PATCH_VERSION",
+ std::to_string(cmVersion::GetPatchVersion()).c_str(),
"Patch version of cmake used to create the "
"current loaded cache",
cmStateEnums::INTERNAL);
@@ -297,16 +295,13 @@ bool cmCacheManager::SaveCache(const std::string& path)
fout << "########################\n";
fout << "\n";
- for (std::map<std::string, CacheEntry>::const_iterator i =
- this->Cache.begin();
- i != this->Cache.end(); ++i) {
- const CacheEntry& ce = (*i).second;
+ for (auto const& i : this->Cache) {
+ CacheEntry const& ce = i.second;
cmStateEnums::CacheEntryType t = ce.Type;
if (!ce.Initialized) {
/*
// This should be added in, but is not for now.
- cmSystemTools::Error("Cache entry \"", (*i).first.c_str(),
- "\" is uninitialized");
+ cmSystemTools::Error("Cache entry \"" + i.first + "\" is uninitialized");
*/
} else if (t != cmStateEnums::INTERNAL) {
// Format is key:type=value
@@ -315,10 +310,13 @@ bool cmCacheManager::SaveCache(const std::string& path)
} else {
cmCacheManager::OutputHelpString(fout, "Missing description");
}
- this->OutputKey(fout, i->first);
+ cmCacheManager::OutputKey(fout, i.first);
fout << ":" << cmState::CacheEntryTypeToString(t) << "=";
- this->OutputValue(fout, ce.Value);
- fout << "\n\n";
+ cmCacheManager::OutputValue(fout, ce.Value);
+ fout << "\n";
+ cmCacheManager::OutputNewlineTruncationWarning(fout, i.first, ce.Value,
+ messenger);
+ fout << "\n";
}
}
@@ -335,28 +333,29 @@ bool cmCacheManager::SaveCache(const std::string& path)
}
cmStateEnums::CacheEntryType t = i.GetType();
- this->WritePropertyEntries(fout, i);
+ this->WritePropertyEntries(fout, i, messenger);
if (t == cmStateEnums::INTERNAL) {
// Format is key:type=value
if (const char* help = i.GetProperty("HELPSTRING")) {
- this->OutputHelpString(fout, help);
+ cmCacheManager::OutputHelpString(fout, help);
}
- this->OutputKey(fout, i.GetName());
+ cmCacheManager::OutputKey(fout, i.GetName());
fout << ":" << cmState::CacheEntryTypeToString(t) << "=";
- this->OutputValue(fout, i.GetValue());
+ cmCacheManager::OutputValue(fout, i.GetValue());
fout << "\n";
+ cmCacheManager::OutputNewlineTruncationWarning(fout, i.GetName(),
+ i.GetValue(), messenger);
}
}
fout << "\n";
fout.Close();
- std::string checkCacheFile = path;
- checkCacheFile += cmake::GetCMakeFilesDirectory();
- cmSystemTools::MakeDirectory(checkCacheFile.c_str());
+ std::string checkCacheFile = cmStrCat(path, "/CMakeFiles");
+ cmSystemTools::MakeDirectory(checkCacheFile);
checkCacheFile += "/cmake.check_cache";
cmsys::ofstream checkCache(checkCacheFile.c_str());
if (!checkCache) {
- cmSystemTools::Error("Unable to open check cache file for write. ",
- checkCacheFile.c_str());
+ cmSystemTools::Error("Unable to open check cache file for write. " +
+ checkCacheFile);
return false;
}
checkCache << "# This file is generated by cmake for dependency checking "
@@ -370,11 +369,11 @@ bool cmCacheManager::DeleteCache(const std::string& path)
cmSystemTools::ConvertToUnixSlashes(cacheFile);
std::string cmakeFiles = cacheFile;
cacheFile += "/CMakeCache.txt";
- if (cmSystemTools::FileExists(cacheFile.c_str())) {
+ if (cmSystemTools::FileExists(cacheFile)) {
cmSystemTools::RemoveFile(cacheFile);
// now remove the files in the CMakeFiles directory
// this cleans up language cache files
- cmakeFiles += cmake::GetCMakeFilesDirectory();
+ cmakeFiles += "/CMakeFiles";
if (cmSystemTools::FileIsDirectory(cmakeFiles)) {
cmSystemTools::RemoveADirectory(cmakeFiles);
}
@@ -392,9 +391,21 @@ void cmCacheManager::OutputKey(std::ostream& fout, std::string const& key)
void cmCacheManager::OutputValue(std::ostream& fout, std::string const& value)
{
+ // look for and truncate newlines
+ std::string::size_type newline = value.find('\n');
+ if (newline != std::string::npos) {
+ std::string truncated = value.substr(0, newline);
+ OutputValueNoNewlines(fout, truncated);
+ } else {
+ OutputValueNoNewlines(fout, value);
+ }
+}
+
+void cmCacheManager::OutputValueNoNewlines(std::ostream& fout,
+ std::string const& value)
+{
// if value has trailing space or tab, enclose it in single quotes
- if (!value.empty() &&
- (value[value.size() - 1] == ' ' || value[value.size() - 1] == '\t')) {
+ if (!value.empty() && (value.back() == ' ' || value.back() == '\t')) {
fout << '\'' << value << '\'';
} else {
fout << value;
@@ -425,9 +436,52 @@ void cmCacheManager::OutputHelpString(std::ostream& fout,
}
}
+void cmCacheManager::OutputWarningComment(std::ostream& fout,
+ std::string const& message,
+ bool wrapSpaces)
+{
+ std::string::size_type end = message.size();
+ std::string oneLine;
+ std::string::size_type pos = 0;
+ for (std::string::size_type i = 0; i <= end; i++) {
+ if ((i == end) || (message[i] == '\n') ||
+ ((i - pos >= 60) && (message[i] == ' ') && wrapSpaces)) {
+ fout << "# ";
+ if (message[pos] == '\n') {
+ pos++;
+ fout << "\\n";
+ }
+ oneLine = message.substr(pos, i - pos);
+ fout << oneLine << "\n";
+ pos = i;
+ }
+ }
+}
+
+void cmCacheManager::OutputNewlineTruncationWarning(std::ostream& fout,
+ std::string const& key,
+ std::string const& value,
+ cmMessenger* messenger)
+{
+ if (value.find('\n') != std::string::npos) {
+ if (messenger) {
+ std::string message =
+ cmStrCat("Value of ", key, " contained a newline; truncating");
+ messenger->IssueMessage(MessageType::WARNING, message);
+ }
+
+ std::string comment =
+ cmStrCat("WARNING: Value of ", key,
+ " contained a newline and was truncated. Original value:");
+
+ OutputWarningComment(fout, comment, true);
+ OutputWarningComment(fout, value, false);
+ }
+}
+
void cmCacheManager::RemoveCacheEntry(const std::string& key)
{
- CacheEntryMap::iterator i = this->Cache.find(key);
+ auto i = this->Cache.find(key);
if (i != this->Cache.end()) {
this->Cache.erase(i);
}
@@ -436,37 +490,35 @@ void cmCacheManager::RemoveCacheEntry(const std::string& key)
cmCacheManager::CacheEntry* cmCacheManager::GetCacheEntry(
const std::string& key)
{
- CacheEntryMap::iterator i = this->Cache.find(key);
+ auto i = this->Cache.find(key);
if (i != this->Cache.end()) {
return &i->second;
}
- return CM_NULLPTR;
+ return nullptr;
}
cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(const char* key)
{
- return CacheIterator(*this, key);
+ return { *this, key };
}
-const char* cmCacheManager::GetInitializedCacheValue(
+const std::string* cmCacheManager::GetInitializedCacheValue(
const std::string& key) const
{
- CacheEntryMap::const_iterator i = this->Cache.find(key);
+ auto i = this->Cache.find(key);
if (i != this->Cache.end() && i->second.Initialized) {
- return i->second.Value.c_str();
+ return &i->second.Value;
}
- return CM_NULLPTR;
+ return nullptr;
}
void cmCacheManager::PrintCache(std::ostream& out) const
{
out << "=================================================" << std::endl;
out << "CMakeCache Contents:" << std::endl;
- for (std::map<std::string, CacheEntry>::const_iterator i =
- this->Cache.begin();
- i != this->Cache.end(); ++i) {
- if ((*i).second.Type != cmStateEnums::INTERNAL) {
- out << (*i).first << " = " << (*i).second.Value << std::endl;
+ for (auto const& i : this->Cache) {
+ if (i.second.Type != cmStateEnums::INTERNAL) {
+ out << i.first << " = " << i.second.Value << std::endl;
}
}
out << "\n\n";
@@ -484,28 +536,27 @@ void cmCacheManager::AddCacheEntry(const std::string& key, const char* value,
e.Value = value;
e.Initialized = true;
} else {
- e.Value = "";
+ e.Value.clear();
}
e.Type = type;
// make sure we only use unix style paths
if (type == cmStateEnums::FILEPATH || type == cmStateEnums::PATH) {
if (e.Value.find(';') != std::string::npos) {
- std::vector<std::string> paths;
- cmSystemTools::ExpandListArgument(e.Value, paths);
+ std::vector<std::string> paths = cmExpandedList(e.Value);
const char* sep = "";
e.Value = "";
- for (std::vector<std::string>::iterator i = paths.begin();
- i != paths.end(); ++i) {
- cmSystemTools::ConvertToUnixSlashes(*i);
+ for (std::string& i : paths) {
+ cmSystemTools::ConvertToUnixSlashes(i);
e.Value += sep;
- e.Value += *i;
+ e.Value += i;
sep = ";";
}
} else {
cmSystemTools::ConvertToUnixSlashes(e.Value);
}
}
- e.SetProperty("HELPSTRING", helpString
+ e.SetProperty("HELPSTRING",
+ helpString
? helpString
: "(This variable does not exist and should not be used)");
}
@@ -548,18 +599,18 @@ void cmCacheManager::CacheIterator::SetValue(const char* value)
entry->Value = value;
entry->Initialized = true;
} else {
- entry->Value = "";
+ entry->Value.clear();
}
}
bool cmCacheManager::CacheIterator::GetValueAsBool() const
{
- return cmSystemTools::IsOn(this->GetEntry().Value.c_str());
+ return cmIsOn(this->GetEntry().Value);
}
std::vector<std::string> cmCacheManager::CacheEntry::GetPropertyList() const
{
- return this->Properties.GetPropertyList();
+ return this->Properties.GetKeys();
}
const char* cmCacheManager::CacheEntry::GetProperty(
@@ -610,7 +661,7 @@ const char* cmCacheManager::CacheIterator::GetProperty(
if (!this->IsAtEnd()) {
return this->GetEntry().GetProperty(prop);
}
- return CM_NULLPTR;
+ return nullptr;
}
void cmCacheManager::CacheIterator::SetProperty(const std::string& p,
@@ -634,7 +685,7 @@ bool cmCacheManager::CacheIterator::GetPropertyAsBool(
const std::string& prop) const
{
if (const char* value = this->GetProperty(prop)) {
- return cmSystemTools::IsOn(value);
+ return cmIsOn(value);
}
return false;
}
@@ -647,5 +698,5 @@ void cmCacheManager::CacheIterator::SetProperty(const std::string& p, bool v)
bool cmCacheManager::CacheIterator::PropertyExists(
const std::string& prop) const
{
- return this->GetProperty(prop) != CM_NULLPTR;
+ return this->GetProperty(prop) != nullptr;
}
diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h
index c464311c6..faa60c528 100644
--- a/Source/cmCacheManager.h
+++ b/Source/cmCacheManager.h
@@ -15,7 +15,7 @@
#include "cmPropertyMap.h"
#include "cmStateTypes.h"
-class cmake;
+class cmMessenger;
/** \class cmCacheManager
* \brief Control class for cmake's cache
@@ -34,20 +34,14 @@ private:
struct CacheEntry
{
std::string Value;
- cmStateEnums::CacheEntryType Type;
+ cmStateEnums::CacheEntryType Type = cmStateEnums::UNINITIALIZED;
cmPropertyMap Properties;
std::vector<std::string> GetPropertyList() const;
const char* GetProperty(const std::string&) const;
void SetProperty(const std::string& property, const char* value);
void AppendProperty(const std::string& property, const char* value,
bool asString = false);
- bool Initialized;
- CacheEntry()
- : Value("")
- , Type(cmStateEnums::UNINITIALIZED)
- , Initialized(false)
- {
- }
+ bool Initialized = false;
};
public:
@@ -99,40 +93,40 @@ public:
CacheEntry& GetEntry() { return this->Position->second; }
};
- ///! return an iterator to iterate through the cache map
- cmCacheManager::CacheIterator NewIterator() { return CacheIterator(*this); }
+ //! return an iterator to iterate through the cache map
+ cmCacheManager::CacheIterator NewIterator() { return { *this }; }
- ///! Load a cache for given makefile. Loads from path/CMakeCache.txt.
+ //! Load a cache for given makefile. Loads from path/CMakeCache.txt.
bool LoadCache(const std::string& path, bool internal,
std::set<std::string>& excludes,
std::set<std::string>& includes);
- ///! Save cache for given makefile. Saves to ouput path/CMakeCache.txt
- bool SaveCache(const std::string& path);
+ //! Save cache for given makefile. Saves to output path/CMakeCache.txt
+ bool SaveCache(const std::string& path, cmMessenger* messenger);
- ///! Delete the cache given
+ //! Delete the cache given
bool DeleteCache(const std::string& path);
- ///! Print the cache to a stream
+ //! Print the cache to a stream
void PrintCache(std::ostream&) const;
- ///! Get the iterator for an entry with a given key.
- cmCacheManager::CacheIterator GetCacheIterator(const char* key = CM_NULLPTR);
+ //! Get the iterator for an entry with a given key.
+ cmCacheManager::CacheIterator GetCacheIterator(const char* key = nullptr);
- ///! Remove an entry from the cache
+ //! Remove an entry from the cache
void RemoveCacheEntry(const std::string& key);
- ///! Get the number of entries in the cache
+ //! Get the number of entries in the cache
int GetSize() { return static_cast<int>(this->Cache.size()); }
- ///! Get a value from the cache given a key
- const char* GetInitializedCacheValue(const std::string& key) const;
+ //! Get a value from the cache given a key
+ const std::string* GetInitializedCacheValue(const std::string& key) const;
const char* GetCacheEntryValue(const std::string& key)
{
cmCacheManager::CacheIterator it = this->GetCacheIterator(key.c_str());
if (it.IsAtEnd()) {
- return CM_NULLPTR;
+ return nullptr;
}
return it.GetValue();
}
@@ -175,8 +169,7 @@ public:
void RemoveCacheEntryProperty(std::string const& key,
std::string const& propName)
{
- this->GetCacheIterator(key.c_str())
- .SetProperty(propName, (void*)CM_NULLPTR);
+ this->GetCacheIterator(key.c_str()).SetProperty(propName, nullptr);
}
void AppendCacheEntryProperty(std::string const& key,
@@ -204,14 +197,14 @@ public:
unsigned int GetCacheMinorVersion() const { return this->CacheMinorVersion; }
protected:
- ///! Add an entry into the cache
+ //! Add an entry into the cache
void AddCacheEntry(const std::string& key, const char* value,
const char* helpString,
cmStateEnums::CacheEntryType type);
- ///! Get a cache entry object for a key
+ //! Get a cache entry object for a key
CacheEntry* GetCacheEntry(const std::string& key);
- ///! Clean out the CMakeFiles directory if no CMakeCache.txt
+ //! Clean out the CMakeFiles directory if no CMakeCache.txt
void CleanCMakeFiles(const std::string& path);
// Cache version info
@@ -219,16 +212,25 @@ protected:
unsigned int CacheMinorVersion;
private:
- cmake* CMakeInstance;
- typedef std::map<std::string, CacheEntry> CacheEntryMap;
+ using CacheEntryMap = std::map<std::string, CacheEntry>;
static void OutputHelpString(std::ostream& fout,
const std::string& helpString);
+ static void OutputWarningComment(std::ostream& fout,
+ std::string const& message,
+ bool wrapSpaces);
+ static void OutputNewlineTruncationWarning(std::ostream& fout,
+ std::string const& key,
+ std::string const& value,
+ cmMessenger* messenger);
static void OutputKey(std::ostream& fout, std::string const& key);
static void OutputValue(std::ostream& fout, std::string const& value);
+ static void OutputValueNoNewlines(std::ostream& fout,
+ std::string const& value);
static const char* PersistentProperties[];
bool ReadPropertyEntry(std::string const& key, CacheEntry& e);
- void WritePropertyEntries(std::ostream& os, CacheIterator i);
+ void WritePropertyEntries(std::ostream& os, CacheIterator i,
+ cmMessenger* messenger);
CacheEntryMap Cache;
// Only cmake and cmState should be able to add cache values
diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx
index 99fe5877e..9e152ff80 100644
--- a/Source/cmCallVisualStudioMacro.cxx
+++ b/Source/cmCallVisualStudioMacro.cxx
@@ -4,10 +4,11 @@
#include <sstream>
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#if defined(_MSC_VER)
-#define HAVE_COMDEF_H
+# define HAVE_COMDEF_H
#endif
// Just for this file:
@@ -16,41 +17,41 @@ static bool LogErrorsAsMessages;
#if defined(HAVE_COMDEF_H)
-#include <comdef.h>
+# include <comdef.h>
// Copied from a correct comdef.h to avoid problems with deficient versions
// of comdef.h that exist in the wild... Fixes issue #7533.
//
-#ifdef _NATIVE_WCHAR_T_DEFINED
-#ifdef _DEBUG
-#pragma comment(lib, "comsuppwd.lib")
-#else
-#pragma comment(lib, "comsuppw.lib")
-#endif
-#else
-#ifdef _DEBUG
-#pragma comment(lib, "comsuppd.lib")
-#else
-#pragma comment(lib, "comsupp.lib")
-#endif
-#endif
-
-///! Use ReportHRESULT to make a cmSystemTools::Message after calling
-///! a COM method that may have failed.
-#define ReportHRESULT(hr, context) \
- if (FAILED(hr)) { \
- if (LogErrorsAsMessages) { \
- std::ostringstream _hresult_oss; \
- _hresult_oss.flags(std::ios::hex); \
- _hresult_oss << context << " failed HRESULT, hr = 0x" << hr \
- << std::endl; \
- _hresult_oss.flags(std::ios::dec); \
- _hresult_oss << __FILE__ << "(" << __LINE__ << ")"; \
- cmSystemTools::Message(_hresult_oss.str().c_str()); \
- } \
- }
+# ifdef _NATIVE_WCHAR_T_DEFINED
+# ifdef _DEBUG
+# pragma comment(lib, "comsuppwd.lib")
+# else
+# pragma comment(lib, "comsuppw.lib")
+# endif
+# else
+# ifdef _DEBUG
+# pragma comment(lib, "comsuppd.lib")
+# else
+# pragma comment(lib, "comsupp.lib")
+# endif
+# endif
+
+//! Use ReportHRESULT to make a cmSystemTools::Message after calling
+//! a COM method that may have failed.
+# define ReportHRESULT(hr, context) \
+ if (FAILED(hr)) { \
+ if (LogErrorsAsMessages) { \
+ std::ostringstream _hresult_oss; \
+ _hresult_oss.flags(std::ios::hex); \
+ _hresult_oss << context << " failed HRESULT, hr = 0x" << hr \
+ << std::endl; \
+ _hresult_oss.flags(std::ios::dec); \
+ _hresult_oss << __FILE__ << "(" << __LINE__ << ")"; \
+ cmSystemTools::Message(_hresult_oss.str()); \
+ } \
+ }
-///! Using the given instance of Visual Studio, call the named macro
+//! Using the given instance of Visual Studio, call the named macro
HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro,
const std::string& args)
{
@@ -61,7 +62,8 @@ HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro,
if (0 != vsIDE) {
DISPID dispid = (DISPID)-1;
- OLECHAR* name = L"ExecuteCommand";
+ wchar_t execute_command[] = L"ExecuteCommand";
+ OLECHAR* name = execute_command;
hr =
vsIDE->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &dispid);
@@ -119,7 +121,8 @@ HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro,
}
oss << " dwHelpContext: " << excep.dwHelpContext << std::endl;
oss << " pvReserved: " << excep.pvReserved << std::endl;
- oss << " pfnDeferredFillIn: " << excep.pfnDeferredFillIn << std::endl;
+ oss << " pfnDeferredFillIn: "
+ << reinterpret_cast<void*>(excep.pfnDeferredFillIn) << std::endl;
oss << " scode: " << excep.scode << std::endl;
}
@@ -133,14 +136,15 @@ HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro,
return hr;
}
-///! Get the Solution object from the IDE object
+//! Get the Solution object from the IDE object
HRESULT GetSolutionObject(IDispatch* vsIDE, IDispatchPtr& vsSolution)
{
HRESULT hr = E_POINTER;
if (0 != vsIDE) {
DISPID dispid = (DISPID)-1;
- OLECHAR* name = L"Solution";
+ wchar_t solution[] = L"Solution";
+ OLECHAR* name = solution;
hr =
vsIDE->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &dispid);
@@ -176,14 +180,15 @@ HRESULT GetSolutionObject(IDispatch* vsIDE, IDispatchPtr& vsSolution)
return hr;
}
-///! Get the FullName property from the Solution object
+//! Get the FullName property from the Solution object
HRESULT GetSolutionFullName(IDispatch* vsSolution, std::string& fullName)
{
HRESULT hr = E_POINTER;
if (0 != vsSolution) {
DISPID dispid = (DISPID)-1;
- OLECHAR* name = L"FullName";
+ wchar_t full_name[] = L"FullName";
+ OLECHAR* name = full_name;
hr = vsSolution->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_USER_DEFAULT,
&dispid);
@@ -220,7 +225,7 @@ HRESULT GetSolutionFullName(IDispatch* vsSolution, std::string& fullName)
return hr;
}
-///! Get the FullName property from the Solution object, given the IDE object
+//! Get the FullName property from the Solution object, given the IDE object
HRESULT GetIDESolutionFullName(IDispatch* vsIDE, std::string& fullName)
{
IDispatchPtr vsSolution;
@@ -235,8 +240,8 @@ HRESULT GetIDESolutionFullName(IDispatch* vsIDE, std::string& fullName)
return hr;
}
-///! Get all running objects from the Windows running object table.
-///! Save them in a map by their display names.
+//! Get all running objects from the Windows running object table.
+//! Save them in a map by their display names.
HRESULT GetRunningInstances(std::map<std::string, IUnknownPtr>& mrot)
{
// mrot == Map of the Running Object Table
@@ -292,8 +297,8 @@ HRESULT GetRunningInstances(std::map<std::string, IUnknownPtr>& mrot)
return hr;
}
-///! Do the two file names refer to the same Visual Studio solution? Or are
-///! we perhaps looking for any and all solutions?
+//! Do the two file names refer to the same Visual Studio solution? Or are
+//! we perhaps looking for any and all solutions?
bool FilesSameSolution(const std::string& slnFile, const std::string& slnName)
{
if (slnFile == "ALL" || slnName == "ALL") {
@@ -310,9 +315,9 @@ bool FilesSameSolution(const std::string& slnFile, const std::string& slnName)
return s1 == s2;
}
-///! Find instances of Visual Studio with the given solution file
-///! open. Pass "ALL" for slnFile to gather all running instances
-///! of Visual Studio.
+//! Find instances of Visual Studio with the given solution file
+//! open. Pass "ALL" for slnFile to gather all running instances
+//! of Visual Studio.
HRESULT FindVisualStudioInstances(const std::string& slnFile,
std::vector<IDispatchPtr>& instances)
{
@@ -324,8 +329,7 @@ HRESULT FindVisualStudioInstances(const std::string& slnFile,
if (SUCCEEDED(hr)) {
std::map<std::string, IUnknownPtr>::iterator it;
for (it = mrot.begin(); it != mrot.end(); ++it) {
- if (cmSystemTools::StringStartsWith(it->first.c_str(),
- "!VisualStudio.DTE.")) {
+ if (cmHasLiteralPrefix(it->first, "!VisualStudio.DTE.")) {
IDispatchPtr disp(it->second);
if (disp != (IDispatch*)0) {
std::string slnName;
@@ -384,8 +388,8 @@ int cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances(
return count;
}
-///! Get all running objects from the Windows running object table.
-///! Save them in a map by their display names.
+//! Get all running objects from the Windows running object table.
+//! Save them in a map by their display names.
int cmCallVisualStudioMacro::CallMacro(const std::string& slnFile,
const std::string& macro,
const std::string& args,
@@ -446,7 +450,7 @@ int cmCallVisualStudioMacro::CallMacro(const std::string& slnFile,
if (err && LogErrorsAsMessages) {
std::ostringstream oss;
oss << "cmCallVisualStudioMacro::CallMacro failed, err = " << err;
- cmSystemTools::Message(oss.str().c_str());
+ cmSystemTools::Message(oss.str());
}
return 0;
diff --git a/Source/cmCallVisualStudioMacro.h b/Source/cmCallVisualStudioMacro.h
index ad35d306a..9b5b3a843 100644
--- a/Source/cmCallVisualStudioMacro.h
+++ b/Source/cmCallVisualStudioMacro.h
@@ -3,7 +3,7 @@
#ifndef cmCallVisualStudioMacro_h
#define cmCallVisualStudioMacro_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
@@ -16,16 +16,16 @@
class cmCallVisualStudioMacro
{
public:
- ///! Call the named macro in instances of Visual Studio with the
- ///! given solution file open. Pass "ALL" for slnFile to call the
- ///! macro in each Visual Studio instance.
+ //! Call the named macro in instances of Visual Studio with the
+ //! given solution file open. Pass "ALL" for slnFile to call the
+ //! macro in each Visual Studio instance.
static int CallMacro(const std::string& slnFile, const std::string& macro,
const std::string& args,
const bool logErrorsAsMessages);
- ///! Count the number of running instances of Visual Studio with the
- ///! given solution file open. Pass "ALL" for slnFile to count all
- ///! running Visual Studio instances.
+ //! Count the number of running instances of Visual Studio with the
+ //! given solution file open. Pass "ALL" for slnFile to count all
+ //! running Visual Studio instances.
static int GetNumberOfRunningVisualStudioInstances(
const std::string& slnFile);
diff --git a/Source/cmCheckCustomOutputs.cxx b/Source/cmCheckCustomOutputs.cxx
new file mode 100644
index 000000000..7645c8808
--- /dev/null
+++ b/Source/cmCheckCustomOutputs.cxx
@@ -0,0 +1,36 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmCheckCustomOutputs.h"
+
+#include "cmExecutionStatus.h"
+#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+bool cmCheckCustomOutputs(const std::vector<std::string>& outputs,
+ cm::string_view keyword, cmExecutionStatus& status)
+{
+ cmMakefile& mf = status.GetMakefile();
+
+ for (std::string const& o : outputs) {
+ // Make sure the file will not be generated into the source
+ // directory during an out of source build.
+ if (!mf.CanIWriteThisFile(o)) {
+ status.SetError(
+ cmStrCat("attempted to have a file\n ", o,
+ "\nin a source directory as an output of custom command."));
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+
+ // Make sure the output file name has no invalid characters.
+ std::string::size_type pos = o.find_first_of("#<>");
+ if (pos != std::string::npos) {
+ status.SetError(cmStrCat("called with ", keyword, " containing a \"",
+ o[pos], "\". This character is not allowed."));
+ return false;
+ }
+ }
+
+ return true;
+}
diff --git a/Source/cmCheckCustomOutputs.h b/Source/cmCheckCustomOutputs.h
new file mode 100644
index 000000000..9f33d1665
--- /dev/null
+++ b/Source/cmCheckCustomOutputs.h
@@ -0,0 +1,18 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmCheckCustomOutputs_h
+#define cmCheckCustomOutputs_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+#include <vector>
+
+#include <cm/string_view>
+
+class cmExecutionStatus;
+
+bool cmCheckCustomOutputs(const std::vector<std::string>& outputs,
+ cm::string_view keyword, cmExecutionStatus& status);
+
+#endif
diff --git a/Source/cmCommand.cxx b/Source/cmCommand.cxx
index d349c9167..0c2734e0f 100644
--- a/Source/cmCommand.cxx
+++ b/Source/cmCommand.cxx
@@ -2,11 +2,19 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCommand.h"
+#include <utility>
+
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-class cmExecutionStatus;
struct cmListFileArgument;
+void cmCommand::SetExecutionStatus(cmExecutionStatus* status)
+{
+ this->Status = status;
+ this->Makefile = &status->GetMakefile();
+}
+
bool cmCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args,
cmExecutionStatus& status)
{
@@ -19,15 +27,33 @@ bool cmCommand::InvokeInitialPass(const std::vector<cmListFileArgument>& args,
return this->InitialPass(expandedArguments, status);
}
-const char* cmCommand::GetError()
+void cmCommand::SetError(const std::string& e)
{
- if (this->Error.empty()) {
- return "unknown error.";
- }
- return this->Error.c_str();
+ this->Status->SetError(e);
}
-void cmCommand::SetError(const std::string& e)
+cmLegacyCommandWrapper::cmLegacyCommandWrapper(std::unique_ptr<cmCommand> cmd)
+ : Command(std::move(cmd))
+{
+}
+
+cmLegacyCommandWrapper::cmLegacyCommandWrapper(
+ cmLegacyCommandWrapper const& other)
+ : Command(other.Command->Clone())
+{
+}
+
+cmLegacyCommandWrapper& cmLegacyCommandWrapper::operator=(
+ cmLegacyCommandWrapper const& other)
+{
+ this->Command = other.Command->Clone();
+ return *this;
+}
+
+bool cmLegacyCommandWrapper::operator()(
+ std::vector<cmListFileArgument> const& args, cmExecutionStatus& status) const
{
- this->Error = e;
+ auto cmd = this->Command->Clone();
+ cmd->SetExecutionStatus(&status);
+ return cmd->InvokeInitialPass(args, status);
}
diff --git a/Source/cmCommand.h b/Source/cmCommand.h
index ad72fe208..bcb178d38 100644
--- a/Source/cmCommand.h
+++ b/Source/cmCommand.h
@@ -3,8 +3,9 @@
#ifndef cmCommand_h
#define cmCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <memory>
#include <string>
#include <vector>
@@ -24,35 +25,35 @@ struct cmListFileArgument;
*/
class cmCommand
{
- CM_DISABLE_COPY(cmCommand)
-
public:
/**
* Construct the command. By default it has no makefile.
*/
- cmCommand()
- : Makefile(CM_NULLPTR)
- {
- }
+ cmCommand() = default;
/**
* Need virtual destructor to destroy real command type.
*/
- virtual ~cmCommand() {}
+ virtual ~cmCommand() = default;
+
+ cmCommand(cmCommand const&) = delete;
+ cmCommand& operator=(cmCommand const&) = delete;
/**
* Specify the makefile.
*/
- void SetMakefile(cmMakefile* m) { this->Makefile = m; }
cmMakefile* GetMakefile() { return this->Makefile; }
+ void SetExecutionStatus(cmExecutionStatus* s);
+ cmExecutionStatus* GetExecutionStatus() { return this->Status; };
+
/**
* This is called by the cmMakefile when the command is first
* encountered in the CMakeLists.txt file. It expands the command's
* arguments and then invokes the InitialPass.
*/
- virtual bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
- cmExecutionStatus& status);
+ bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
+ cmExecutionStatus& status);
/**
* This is called when the command is first encountered in
@@ -62,27 +63,9 @@ public:
cmExecutionStatus&) = 0;
/**
- * This is called at the end after all the information
- * specified by the command is accumulated. Most commands do
- * not implement this method. At this point, reading and
- * writing to the cache can be done.
- */
- virtual void FinalPass() {}
-
- /**
- * Does this command have a final pass? Query after InitialPass.
- */
- virtual bool HasFinalPass() const { return false; }
-
- /**
* This is a virtual constructor for the command.
*/
- virtual cmCommand* Clone() = 0;
-
- /**
- * Return the last error string.
- */
- const char* GetError();
+ virtual std::unique_ptr<cmCommand> Clone() = 0;
/**
* Set the error message
@@ -90,10 +73,28 @@ public:
void SetError(const std::string& e);
protected:
- cmMakefile* Makefile;
+ cmMakefile* Makefile = nullptr;
+
+private:
+ cmExecutionStatus* Status = nullptr;
+};
+
+class cmLegacyCommandWrapper
+{
+public:
+ explicit cmLegacyCommandWrapper(std::unique_ptr<cmCommand> cmd);
+
+ cmLegacyCommandWrapper(cmLegacyCommandWrapper const& other);
+ cmLegacyCommandWrapper& operator=(cmLegacyCommandWrapper const& other);
+
+ cmLegacyCommandWrapper(cmLegacyCommandWrapper&&) = default;
+ cmLegacyCommandWrapper& operator=(cmLegacyCommandWrapper&&) = default;
+
+ bool operator()(std::vector<cmListFileArgument> const& args,
+ cmExecutionStatus& status) const;
private:
- std::string Error;
+ std::unique_ptr<cmCommand> Command;
};
#endif
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 4eb4531f6..613ae06d1 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -2,32 +2,23 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCommandArgumentParserHelper.h"
+#include <cstring>
+#include <iostream>
+#include <sstream>
+
#include "cmCommandArgumentLexer.h"
#include "cmMakefile.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-
-#include <iostream>
-#include <sstream>
-#include <string.h>
int cmCommandArgument_yyparse(yyscan_t yyscanner);
//
cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
{
- this->WarnUninitialized = false;
- this->CheckSystemVars = false;
this->FileLine = -1;
- this->FileName = CM_NULLPTR;
+ this->FileName = nullptr;
this->RemoveEmpty = true;
- this->EmptyVariable[0] = 0;
- strcpy(this->DCURLYVariable, "${");
- strcpy(this->RCURLYVariable, "}");
- strcpy(this->ATVariable, "@");
- strcpy(this->DOLLARVariable, "$");
- strcpy(this->LCURLYVariable, "{");
- strcpy(this->BSLASHVariable, "\\");
this->NoEscapeMode = false;
this->ReplaceAtSyntax = false;
@@ -44,10 +35,10 @@ void cmCommandArgumentParserHelper::SetLineFile(long line, const char* file)
this->FileName = file;
}
-char* cmCommandArgumentParserHelper::AddString(const std::string& str)
+const char* cmCommandArgumentParserHelper::AddString(const std::string& str)
{
if (str.empty()) {
- return this->EmptyVariable;
+ return "";
}
char* stVal = new char[str.size() + 1];
strcpy(stVal, str.c_str());
@@ -55,81 +46,68 @@ char* cmCommandArgumentParserHelper::AddString(const std::string& str)
return stVal;
}
-char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
- const char* var)
+const char* cmCommandArgumentParserHelper::ExpandSpecialVariable(
+ const char* key, const char* var)
{
if (!key) {
return this->ExpandVariable(var);
}
if (!var) {
- return this->EmptyVariable;
+ return "";
}
if (strcmp(key, "ENV") == 0) {
std::string str;
if (cmSystemTools::GetEnv(var, str)) {
if (this->EscapeQuotes) {
- return this->AddString(cmSystemTools::EscapeQuotes(str));
+ return this->AddString(cmEscapeQuotes(str));
}
return this->AddString(str);
}
- return this->EmptyVariable;
+ return "";
}
if (strcmp(key, "CACHE") == 0) {
- if (const char* c =
+ if (const std::string* c =
this->Makefile->GetState()->GetInitializedCacheValue(var)) {
if (this->EscapeQuotes) {
- return this->AddString(cmSystemTools::EscapeQuotes(c));
+ return this->AddString(cmEscapeQuotes(*c));
}
- return this->AddString(c);
+ return this->AddString(*c);
}
- return this->EmptyVariable;
+ return "";
}
std::ostringstream e;
e << "Syntax $" << key << "{} is not supported. "
<< "Only ${}, $ENV{}, and $CACHE{} are allowed.";
this->SetError(e.str());
- return CM_NULLPTR;
+ return nullptr;
}
-char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
+const char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
{
if (!var) {
- return CM_NULLPTR;
+ return nullptr;
}
if (this->FileLine >= 0 && strcmp(var, "CMAKE_CURRENT_LIST_LINE") == 0) {
- std::ostringstream ostr;
- ostr << this->FileLine;
- return this->AddString(ostr.str());
+ return this->AddString(std::to_string(this->FileLine));
}
const char* value = this->Makefile->GetDefinition(var);
- if (!value && !this->RemoveEmpty) {
- // check to see if we need to print a warning
- // if strict mode is on and the variable has
- // not been "cleared"/initialized with a set(foo ) call
- if (this->WarnUninitialized && !this->Makefile->VariableInitialized(var)) {
- if (this->CheckSystemVars ||
- cmSystemTools::IsSubDirectory(this->FileName,
- this->Makefile->GetHomeDirectory()) ||
- cmSystemTools::IsSubDirectory(
- this->FileName, this->Makefile->GetHomeOutputDirectory())) {
- std::ostringstream msg;
- msg << "uninitialized variable \'" << var << "\'";
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
- }
+ if (!value) {
+ this->Makefile->MaybeWarnUninitialized(var, this->FileName);
+ if (!this->RemoveEmpty) {
+ return nullptr;
}
- return CM_NULLPTR;
}
if (this->EscapeQuotes && value) {
- return this->AddString(cmSystemTools::EscapeQuotes(value));
+ return this->AddString(cmEscapeQuotes(value));
}
return this->AddString(value ? value : "");
}
-char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
+const char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
{
if (this->ReplaceAtSyntax) {
// try to expand the variable
- char* ret = this->ExpandVariable(var);
+ const char* ret = this->ExpandVariable(var);
// if the return was 0 and we want to replace empty strings
// then return an empty string
if (!ret && this->RemoveEmpty) {
@@ -144,13 +122,12 @@ char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
// - this->ReplaceAtSyntax is false
// - this->ReplaceAtSyntax is true, but this->RemoveEmpty is false,
// and the variable was not defined
- std::string ref = "@";
- ref += var;
- ref += "@";
+ std::string ref = cmStrCat('@', var, '@');
return this->AddString(ref);
}
-char* cmCommandArgumentParserHelper::CombineUnions(char* in1, char* in2)
+const char* cmCommandArgumentParserHelper::CombineUnions(const char* in1,
+ const char* in2)
{
if (!in1) {
return in2;
@@ -169,17 +146,18 @@ char* cmCommandArgumentParserHelper::CombineUnions(char* in1, char* in2)
void cmCommandArgumentParserHelper::AllocateParserType(
cmCommandArgumentParserHelper::ParserType* pt, const char* str, int len)
{
- pt->str = CM_NULLPTR;
+ pt->str = nullptr;
if (len == 0) {
len = static_cast<int>(strlen(str));
}
if (len == 0) {
return;
}
- pt->str = new char[len + 1];
- strncpy(pt->str, str, len);
- pt->str[len] = 0;
- this->Variables.push_back(pt->str);
+ char* out = new char[len + 1];
+ memcpy(out, str, len);
+ out[len] = 0;
+ pt->str = out;
+ this->Variables.push_back(out);
}
bool cmCommandArgumentParserHelper::HandleEscapeSymbol(
@@ -234,7 +212,7 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb)
this->InputBufferPos = 0;
this->CurrentLine = 0;
- this->Result = "";
+ this->Result.clear();
yyscan_t yyscanner;
cmCommandArgument_yylex_init(&yyscanner);
@@ -257,9 +235,8 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb)
void cmCommandArgumentParserHelper::CleanupParser()
{
- std::vector<char*>::iterator sit;
- for (sit = this->Variables.begin(); sit != this->Variables.end(); ++sit) {
- delete[] * sit;
+ for (char* var : this->Variables) {
+ delete[] var;
}
this->Variables.erase(this->Variables.begin(), this->Variables.end());
}
@@ -291,14 +268,12 @@ void cmCommandArgumentParserHelper::Error(const char* str)
void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf)
{
this->Makefile = mf;
- this->WarnUninitialized = mf->GetCMakeInstance()->GetWarnUninitialized();
- this->CheckSystemVars = mf->GetCMakeInstance()->GetCheckSystemVars();
}
void cmCommandArgumentParserHelper::SetResult(const char* value)
{
if (!value) {
- this->Result = "";
+ this->Result.clear();
return;
}
this->Result = value;
diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h
index 465ca9e28..25e689224 100644
--- a/Source/cmCommandArgumentParserHelper.h
+++ b/Source/cmCommandArgumentParserHelper.h
@@ -3,7 +3,7 @@
#ifndef cmCommandArgumentParserHelper_h
#define cmCommandArgumentParserHelper_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
@@ -12,17 +12,19 @@ class cmMakefile;
class cmCommandArgumentParserHelper
{
- CM_DISABLE_COPY(cmCommandArgumentParserHelper)
-
public:
struct ParserType
{
- char* str;
+ const char* str;
};
cmCommandArgumentParserHelper();
~cmCommandArgumentParserHelper();
+ cmCommandArgumentParserHelper(cmCommandArgumentParserHelper const&) = delete;
+ cmCommandArgumentParserHelper& operator=(
+ cmCommandArgumentParserHelper const&) = delete;
+
int ParseString(const char* str, int verb);
// For the lexer:
@@ -35,11 +37,11 @@ public:
void Error(const char* str);
// For yacc
- char* CombineUnions(char* in1, char* in2);
+ const char* CombineUnions(const char* in1, const char* in2);
- char* ExpandSpecialVariable(const char* key, const char* var);
- char* ExpandVariable(const char* var);
- char* ExpandVariableForAt(const char* var);
+ const char* ExpandSpecialVariable(const char* key, const char* var);
+ const char* ExpandVariable(const char* var);
+ const char* ExpandVariableForAt(const char* var);
void SetResult(const char* value);
void SetMakefile(const cmMakefile* mf);
@@ -53,13 +55,6 @@ public:
void SetRemoveEmpty(bool b) { this->RemoveEmpty = b; }
const char* GetError() { return this->ErrorString.c_str(); }
- char EmptyVariable[1];
- char DCURLYVariable[3];
- char RCURLYVariable[3];
- char ATVariable[3];
- char DOLLARVariable[3];
- char LCURLYVariable[3];
- char BSLASHVariable[3];
private:
std::string::size_type InputBufferPos;
@@ -69,7 +64,7 @@ private:
void Print(const char* place, const char* str);
void SafePrintMissing(const char* str, int line, int cnt);
- char* AddString(const std::string& str);
+ const char* AddString(const std::string& str);
void CleanupParser();
void SetError(std::string const& msg);
@@ -82,8 +77,6 @@ private:
long FileLine;
int CurrentLine;
int Verbose;
- bool WarnUninitialized;
- bool CheckSystemVars;
bool EscapeQuotes;
bool NoEscapeMode;
bool ReplaceAtSyntax;
diff --git a/Source/cmCommandArgumentsHelper.cxx b/Source/cmCommandArgumentsHelper.cxx
deleted file mode 100644
index babddbe94..000000000
--- a/Source/cmCommandArgumentsHelper.cxx
+++ /dev/null
@@ -1,245 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmCommandArgumentsHelper.h"
-
-cmCommandArgument::cmCommandArgument(cmCommandArgumentsHelper* args,
- const char* key,
- cmCommandArgumentGroup* group)
- : Key(key)
- , Group(group)
- , WasActive(false)
- , ArgumentsBeforeEmpty(true)
- , CurrentIndex(0)
-{
- if (args != CM_NULLPTR) {
- args->AddArgument(this);
- }
-
- if (this->Group != CM_NULLPTR) {
- this->Group->ContainedArguments.push_back(this);
- }
-}
-
-void cmCommandArgument::Reset()
-{
- this->WasActive = false;
- this->CurrentIndex = 0;
- this->DoReset();
-}
-
-void cmCommandArgument::Follows(const cmCommandArgument* arg)
-{
- this->ArgumentsBeforeEmpty = false;
- this->ArgumentsBefore.insert(arg);
-}
-
-void cmCommandArgument::FollowsGroup(const cmCommandArgumentGroup* group)
-{
- if (group != CM_NULLPTR) {
- this->ArgumentsBeforeEmpty = false;
- this->ArgumentsBefore.insert(group->ContainedArguments.begin(),
- group->ContainedArguments.end());
- }
-}
-
-bool cmCommandArgument::MayFollow(const cmCommandArgument* current) const
-{
- if (this->ArgumentsBeforeEmpty) {
- return true;
- }
- return this->ArgumentsBefore.find(current) != this->ArgumentsBefore.end();
-}
-
-bool cmCommandArgument::KeyMatches(const std::string& key) const
-{
- if ((this->Key == CM_NULLPTR) || (this->Key[0] == '\0')) {
- return true;
- }
- return (key == this->Key);
-}
-
-void cmCommandArgument::ApplyOwnGroup()
-{
- if (this->Group != CM_NULLPTR) {
- for (std::vector<cmCommandArgument*>::const_iterator it =
- this->Group->ContainedArguments.begin();
- it != this->Group->ContainedArguments.end(); ++it) {
- if (*it != this) {
- this->ArgumentsBefore.insert(*it);
- }
- }
- }
-}
-
-void cmCommandArgument::Activate()
-{
- this->WasActive = true;
- this->CurrentIndex = 0;
-}
-
-bool cmCommandArgument::Consume(const std::string& arg)
-{
- bool res = this->DoConsume(arg, this->CurrentIndex);
- this->CurrentIndex++;
- return res;
-}
-
-cmCAStringVector::cmCAStringVector(cmCommandArgumentsHelper* args,
- const char* key,
- cmCommandArgumentGroup* group)
- : cmCommandArgument(args, key, group)
- , Ignore(CM_NULLPTR)
-{
- if ((key == CM_NULLPTR) || (*key == 0)) {
- this->DataStart = 0;
- } else {
- this->DataStart = 1;
- }
-}
-
-bool cmCAStringVector::DoConsume(const std::string& arg, unsigned int index)
-{
- if (index >= this->DataStart) {
- if ((this->Ignore == CM_NULLPTR) || (arg != this->Ignore)) {
- this->Vector.push_back(arg);
- }
- }
-
- return false;
-}
-
-void cmCAStringVector::DoReset()
-{
- this->Vector.clear();
-}
-
-cmCAString::cmCAString(cmCommandArgumentsHelper* args, const char* key,
- cmCommandArgumentGroup* group)
- : cmCommandArgument(args, key, group)
-{
- if ((key == CM_NULLPTR) || (*key == 0)) {
- this->DataStart = 0;
- } else {
- this->DataStart = 1;
- }
-}
-
-bool cmCAString::DoConsume(const std::string& arg, unsigned int index)
-{
- if (index == this->DataStart) {
- this->String = arg;
- }
-
- return index >= this->DataStart;
-}
-
-void cmCAString::DoReset()
-{
- this->String = "";
-}
-
-cmCAEnabler::cmCAEnabler(cmCommandArgumentsHelper* args, const char* key,
- cmCommandArgumentGroup* group)
- : cmCommandArgument(args, key, group)
- , Enabled(false)
-{
-}
-
-bool cmCAEnabler::DoConsume(const std::string&, unsigned int index)
-{
- if (index == 0) {
- this->Enabled = true;
- }
- return true;
-}
-
-void cmCAEnabler::DoReset()
-{
- this->Enabled = false;
-}
-
-cmCADisabler::cmCADisabler(cmCommandArgumentsHelper* args, const char* key,
- cmCommandArgumentGroup* group)
- : cmCommandArgument(args, key, group)
- , Enabled(true)
-{
-}
-
-bool cmCADisabler::DoConsume(const std::string&, unsigned int index)
-{
- if (index == 0) {
- this->Enabled = false;
- }
- return true;
-}
-
-void cmCADisabler::DoReset()
-{
- this->Enabled = true;
-}
-
-void cmCommandArgumentGroup::Follows(const cmCommandArgument* arg)
-{
- for (std::vector<cmCommandArgument*>::iterator it =
- this->ContainedArguments.begin();
- it != this->ContainedArguments.end(); ++it) {
- (*it)->Follows(arg);
- }
-}
-
-void cmCommandArgumentGroup::FollowsGroup(const cmCommandArgumentGroup* group)
-{
- for (std::vector<cmCommandArgument*>::iterator it =
- this->ContainedArguments.begin();
- it != this->ContainedArguments.end(); ++it) {
- (*it)->FollowsGroup(group);
- }
-}
-
-void cmCommandArgumentsHelper::Parse(const std::vector<std::string>* args,
- std::vector<std::string>* unconsumedArgs)
-{
- if (args == CM_NULLPTR) {
- return;
- }
-
- for (std::vector<cmCommandArgument*>::iterator argIt =
- this->Arguments.begin();
- argIt != this->Arguments.end(); ++argIt) {
- (*argIt)->ApplyOwnGroup();
- (*argIt)->Reset();
- }
-
- cmCommandArgument* activeArgument = CM_NULLPTR;
- const cmCommandArgument* previousArgument = CM_NULLPTR;
- for (std::vector<std::string>::const_iterator it = args->begin();
- it != args->end(); ++it) {
- for (std::vector<cmCommandArgument*>::iterator argIt =
- this->Arguments.begin();
- argIt != this->Arguments.end(); ++argIt) {
- if ((*argIt)->KeyMatches(*it) &&
- ((*argIt)->MayFollow(previousArgument))) {
- activeArgument = *argIt;
- activeArgument->Activate();
- break;
- }
- }
-
- if (activeArgument) {
- bool argDone = activeArgument->Consume(*it);
- previousArgument = activeArgument;
- if (argDone) {
- activeArgument = CM_NULLPTR;
- }
- } else {
- if (unconsumedArgs != CM_NULLPTR) {
- unconsumedArgs->push_back(*it);
- }
- }
- }
-}
-
-void cmCommandArgumentsHelper::AddArgument(cmCommandArgument* arg)
-{
- this->Arguments.push_back(arg);
-}
diff --git a/Source/cmCommandArgumentsHelper.h b/Source/cmCommandArgumentsHelper.h
deleted file mode 100644
index 44db374d6..000000000
--- a/Source/cmCommandArgumentsHelper.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmCommandArgumentsHelper_h
-#define cmCommandArgumentsHelper_h
-
-#include "cmConfigure.h"
-
-#include <set>
-#include <string>
-#include <vector>
-
-class cmCommandArgumentGroup;
-class cmCommandArgumentsHelper;
-
-/* cmCommandArgumentsHelper, cmCommandArgumentGroup and cmCommandArgument (i.e.
-its derived classes cmCAXXX can be used to simplify the processing of
-arguments to cmake commands. Maybe they can also be used to generate
-documentation.
-
-For every argument supported by a command one cmCommandArgument is created
-and added to cmCommandArgumentsHelper. cmCommand has a cmCommandArgumentsHelper
-as member variable so this should be used.
-
-The order of the arguments is defined using the Follows(arg) method. It says
-that this argument follows immediateley the given argument. It can be used
-with multiple arguments if the argument can follow after different arguments.
-
-Arguments can be arranged in groups using cmCommandArgumentGroup. Every
-member of a group can follow any other member of the group. These groups
-can also be used to define the order.
-
-Once all arguments and groups are set up, cmCommandArgumentsHelper::Parse()
-is called and afterwards the values of the arguments can be evaluated.
-
-For an example see cmExportCommand.cxx.
-*/
-class cmCommandArgument
-{
-public:
- cmCommandArgument(cmCommandArgumentsHelper* args, const char* key,
- cmCommandArgumentGroup* group = CM_NULLPTR);
- virtual ~cmCommandArgument() {}
-
- /// this argument may follow after arg. 0 means it comes first.
- void Follows(const cmCommandArgument* arg);
-
- /// this argument may follow after any of the arguments in the given group
- void FollowsGroup(const cmCommandArgumentGroup* group);
-
- /// Returns true if the argument was found in the argument list
- bool WasFound() const { return this->WasActive; }
-
- // The following methods are only called from
- // cmCommandArgumentsHelper::Parse(), but making this a friend would
- // give it access to everything
-
- /// Make the current argument the currently active argument
- void Activate();
- /// Consume the current string
- bool Consume(const std::string& arg);
-
- /// Return true if this argument may follow after the given argument.
- bool MayFollow(const cmCommandArgument* current) const;
-
- /** Returns true if the given key matches the key for this argument.
- If this argument has an empty key everything matches. */
- bool KeyMatches(const std::string& key) const;
-
- /// Make this argument follow all members of the own group
- void ApplyOwnGroup();
-
- /// Reset argument, so it's back to its initial state
- void Reset();
-
-private:
- const char* Key;
- std::set<const cmCommandArgument*> ArgumentsBefore;
- cmCommandArgumentGroup* Group;
- bool WasActive;
- bool ArgumentsBeforeEmpty;
- unsigned int CurrentIndex;
-
- virtual bool DoConsume(const std::string& arg, unsigned int index) = 0;
- virtual void DoReset() = 0;
-};
-
-/** cmCAStringVector is to be used for arguments which can consist of more
-than one string, e.g. the FILES argument in INSTALL(FILES f1 f2 f3 ...). */
-class cmCAStringVector : public cmCommandArgument
-{
-public:
- cmCAStringVector(cmCommandArgumentsHelper* args, const char* key,
- cmCommandArgumentGroup* group = CM_NULLPTR);
-
- /// Return the vector of strings
- const std::vector<std::string>& GetVector() const { return this->Vector; }
-
- /** Is there a keyword which should be skipped in
- the arguments (e.g. ARGS for ADD_CUSTOM_COMMAND) ? */
- void SetIgnore(const char* ignore) { this->Ignore = ignore; }
-private:
- std::vector<std::string> Vector;
- unsigned int DataStart;
- const char* Ignore;
- cmCAStringVector();
- bool DoConsume(const std::string& arg, unsigned int index) CM_OVERRIDE;
- void DoReset() CM_OVERRIDE;
-};
-
-/** cmCAString is to be used for arguments which consist of one value,
-e.g. the executable name in ADD_EXECUTABLE(). */
-class cmCAString : public cmCommandArgument
-{
-public:
- cmCAString(cmCommandArgumentsHelper* args, const char* key,
- cmCommandArgumentGroup* group = CM_NULLPTR);
-
- /// Return the string
- const std::string& GetString() const { return this->String; }
- const char* GetCString() const { return this->String.c_str(); }
-private:
- std::string String;
- unsigned int DataStart;
- bool DoConsume(const std::string& arg, unsigned int index) CM_OVERRIDE;
- void DoReset() CM_OVERRIDE;
- cmCAString();
-};
-
-/** cmCAEnabler is to be used for options which are off by default and can be
-enabled using a special argument, e.g. EXCLUDE_FROM_ALL in ADD_EXECUTABLE(). */
-class cmCAEnabler : public cmCommandArgument
-{
-public:
- cmCAEnabler(cmCommandArgumentsHelper* args, const char* key,
- cmCommandArgumentGroup* group = CM_NULLPTR);
-
- /// Has it been enabled ?
- bool IsEnabled() const { return this->Enabled; }
-private:
- bool Enabled;
- bool DoConsume(const std::string& arg, unsigned int index) CM_OVERRIDE;
- void DoReset() CM_OVERRIDE;
- cmCAEnabler();
-};
-
-/** cmCADisable is to be used for options which are on by default and can be
-disabled using a special argument.*/
-class cmCADisabler : public cmCommandArgument
-{
-public:
- cmCADisabler(cmCommandArgumentsHelper* args, const char* key,
- cmCommandArgumentGroup* group = CM_NULLPTR);
-
- /// Is it still enabled ?
- bool IsEnabled() const { return this->Enabled; }
-private:
- bool Enabled;
- bool DoConsume(const std::string& arg, unsigned int index) CM_OVERRIDE;
- void DoReset() CM_OVERRIDE;
- cmCADisabler();
-};
-
-/** Group of arguments, needed for ordering. E.g. WIN32, EXCLUDE_FROM_ALL and
-MACSOX_BUNDLE from ADD_EXECUTABLE() are a group.
-*/
-class cmCommandArgumentGroup
-{
- friend class cmCommandArgument;
-
-public:
- cmCommandArgumentGroup() {}
-
- /// All members of this group may follow the given argument
- void Follows(const cmCommandArgument* arg);
-
- /// All members of this group may follow all members of the given group
- void FollowsGroup(const cmCommandArgumentGroup* group);
-
-private:
- std::vector<cmCommandArgument*> ContainedArguments;
-};
-
-class cmCommandArgumentsHelper
-{
-public:
- /// Parse the argument list
- void Parse(const std::vector<std::string>* args,
- std::vector<std::string>* unconsumedArgs);
- /// Add an argument.
- void AddArgument(cmCommandArgument* arg);
-
-private:
- std::vector<cmCommandArgument*> Arguments;
-};
-
-#endif
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index e1d8ef143..6f19697bc 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -1,9 +1,11 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
+
#include "cmCommands.h"
-#include "cmPolicies.h"
-#include "cmState.h"
+#include <cm/memory>
+
+#include "cmAddCompileDefinitionsCommand.h"
#include "cmAddCustomCommandCommand.h"
#include "cmAddCustomTargetCommand.h"
#include "cmAddDefinitionsCommand.h"
@@ -16,6 +18,7 @@
#include "cmBuildCommand.h"
#include "cmCMakeMinimumRequired.h"
#include "cmCMakePolicyCommand.h"
+#include "cmCommand.h"
#include "cmConfigureFileCommand.h"
#include "cmContinueCommand.h"
#include "cmCreateTestSourceList.h"
@@ -42,6 +45,7 @@
#include "cmIfCommand.h"
#include "cmIncludeCommand.h"
#include "cmIncludeDirectoryCommand.h"
+#include "cmIncludeGuardCommand.h"
#include "cmIncludeRegularExpressionCommand.h"
#include "cmInstallCommand.h"
#include "cmInstallFilesCommand.h"
@@ -55,6 +59,7 @@
#include "cmMessageCommand.h"
#include "cmOptionCommand.h"
#include "cmParseArgumentsCommand.h"
+#include "cmPolicies.h"
#include "cmProjectCommand.h"
#include "cmReturnCommand.h"
#include "cmSeparateArgumentsCommand.h"
@@ -65,134 +70,143 @@
#include "cmSetTargetPropertiesCommand.h"
#include "cmSetTestsPropertiesCommand.h"
#include "cmSiteNameCommand.h"
+#include "cmState.h"
#include "cmStringCommand.h"
#include "cmSubdirCommand.h"
+#include "cmTargetCompileDefinitionsCommand.h"
+#include "cmTargetCompileFeaturesCommand.h"
+#include "cmTargetCompileOptionsCommand.h"
+#include "cmTargetIncludeDirectoriesCommand.h"
#include "cmTargetLinkLibrariesCommand.h"
+#include "cmTargetLinkOptionsCommand.h"
+#include "cmTargetPrecompileHeadersCommand.h"
+#include "cmTargetSourcesCommand.h"
#include "cmTryCompileCommand.h"
#include "cmTryRunCommand.h"
#include "cmUnsetCommand.h"
#include "cmWhileCommand.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmAddCompileOptionsCommand.h"
-#include "cmAuxSourceDirectoryCommand.h"
-#include "cmBuildNameCommand.h"
-#include "cmCMakeHostSystemInformationCommand.h"
-#include "cmExportCommand.h"
-#include "cmExportLibraryDependenciesCommand.h"
-#include "cmFLTKWrapUICommand.h"
-#include "cmIncludeExternalMSProjectCommand.h"
-#include "cmInstallProgramsCommand.h"
-#include "cmLinkLibrariesCommand.h"
-#include "cmLoadCacheCommand.h"
-#include "cmLoadCommandCommand.h"
-#include "cmOutputRequiredFilesCommand.h"
-#include "cmQTWrapCPPCommand.h"
-#include "cmQTWrapUICommand.h"
-#include "cmRemoveCommand.h"
-#include "cmRemoveDefinitionsCommand.h"
-#include "cmSourceGroupCommand.h"
-#include "cmSubdirDependsCommand.h"
-#include "cmTargetCompileDefinitionsCommand.h"
-#include "cmTargetCompileFeaturesCommand.h"
-#include "cmTargetCompileOptionsCommand.h"
-#include "cmTargetIncludeDirectoriesCommand.h"
-#include "cmTargetSourcesCommand.h"
-#include "cmUseMangledMesaCommand.h"
-#include "cmUtilitySourceCommand.h"
-#include "cmVariableRequiresCommand.h"
-#include "cmVariableWatchCommand.h"
-#include "cmWriteFileCommand.h"
+#if !defined(CMAKE_BOOTSTRAP)
+# include "cmAddCompileOptionsCommand.h"
+# include "cmAddLinkOptionsCommand.h"
+# include "cmAuxSourceDirectoryCommand.h"
+# include "cmBuildNameCommand.h"
+# include "cmCMakeHostSystemInformationCommand.h"
+# include "cmExportCommand.h"
+# include "cmExportLibraryDependenciesCommand.h"
+# include "cmFLTKWrapUICommand.h"
+# include "cmIncludeExternalMSProjectCommand.h"
+# include "cmInstallProgramsCommand.h"
+# include "cmLinkLibrariesCommand.h"
+# include "cmLoadCacheCommand.h"
+# include "cmLoadCommandCommand.h"
+# include "cmOutputRequiredFilesCommand.h"
+# include "cmQTWrapCPPCommand.h"
+# include "cmQTWrapUICommand.h"
+# include "cmRemoveCommand.h"
+# include "cmRemoveDefinitionsCommand.h"
+# include "cmSourceGroupCommand.h"
+# include "cmSubdirDependsCommand.h"
+# include "cmTargetLinkDirectoriesCommand.h"
+# include "cmUseMangledMesaCommand.h"
+# include "cmUtilitySourceCommand.h"
+# include "cmVariableRequiresCommand.h"
+# include "cmVariableWatchCommand.h"
+# include "cmWriteFileCommand.h"
#endif
void GetScriptingCommands(cmState* state)
{
- state->AddBuiltinCommand("break", new cmBreakCommand);
- state->AddBuiltinCommand("cmake_minimum_required",
- new cmCMakeMinimumRequired);
- state->AddBuiltinCommand("cmake_policy", new cmCMakePolicyCommand);
- state->AddBuiltinCommand("configure_file", new cmConfigureFileCommand);
- state->AddBuiltinCommand("continue", new cmContinueCommand);
- state->AddBuiltinCommand("exec_program", new cmExecProgramCommand);
- state->AddBuiltinCommand("execute_process", new cmExecuteProcessCommand);
- state->AddBuiltinCommand("file", new cmFileCommand);
- state->AddBuiltinCommand("find_file", new cmFindFileCommand);
- state->AddBuiltinCommand("find_library", new cmFindLibraryCommand);
- state->AddBuiltinCommand("find_package", new cmFindPackageCommand);
- state->AddBuiltinCommand("find_path", new cmFindPathCommand);
- state->AddBuiltinCommand("find_program", new cmFindProgramCommand);
- state->AddBuiltinCommand("foreach", new cmForEachCommand);
- state->AddBuiltinCommand("function", new cmFunctionCommand);
- state->AddBuiltinCommand("get_cmake_property",
- new cmGetCMakePropertyCommand);
+ state->AddBuiltinCommand("break", cmBreakCommand);
+ state->AddBuiltinCommand("cmake_minimum_required", cmCMakeMinimumRequired);
+ state->AddBuiltinCommand("cmake_policy", cmCMakePolicyCommand);
+ state->AddBuiltinCommand("configure_file", cmConfigureFileCommand);
+ state->AddBuiltinCommand("continue", cmContinueCommand);
+ state->AddBuiltinCommand("exec_program", cmExecProgramCommand);
+ state->AddBuiltinCommand("execute_process", cmExecuteProcessCommand);
+ state->AddBuiltinCommand("file", cmFileCommand);
+ state->AddBuiltinCommand("find_file", cmFindFile);
+ state->AddBuiltinCommand("find_library", cmFindLibrary);
+ state->AddBuiltinCommand("find_package", cmFindPackage);
+ state->AddBuiltinCommand("find_path", cmFindPath);
+ state->AddBuiltinCommand("find_program", cmFindProgram);
+ state->AddBuiltinCommand("foreach", cmForEachCommand);
+ state->AddBuiltinCommand("function", cmFunctionCommand);
+ state->AddBuiltinCommand("get_cmake_property", cmGetCMakePropertyCommand);
state->AddBuiltinCommand("get_directory_property",
- new cmGetDirectoryPropertyCommand);
+ cmGetDirectoryPropertyCommand);
state->AddBuiltinCommand("get_filename_component",
- new cmGetFilenameComponentCommand);
- state->AddBuiltinCommand("get_property", new cmGetPropertyCommand);
- state->AddBuiltinCommand("if", new cmIfCommand);
- state->AddBuiltinCommand("include", new cmIncludeCommand);
- state->AddBuiltinCommand("list", new cmListCommand);
- state->AddBuiltinCommand("macro", new cmMacroCommand);
- state->AddBuiltinCommand("make_directory", new cmMakeDirectoryCommand);
- state->AddBuiltinCommand("mark_as_advanced", new cmMarkAsAdvancedCommand);
- state->AddBuiltinCommand("math", new cmMathCommand);
- state->AddBuiltinCommand("message", new cmMessageCommand);
- state->AddBuiltinCommand("option", new cmOptionCommand);
- state->AddBuiltinCommand("cmake_parse_arguments",
- new cmParseArgumentsCommand);
- state->AddBuiltinCommand("return", new cmReturnCommand);
- state->AddBuiltinCommand("separate_arguments",
- new cmSeparateArgumentsCommand);
- state->AddBuiltinCommand("set", new cmSetCommand);
+ cmGetFilenameComponentCommand);
+ state->AddBuiltinCommand("get_property", cmGetPropertyCommand);
+ state->AddBuiltinCommand("if", cmIfCommand);
+ state->AddBuiltinCommand("include", cmIncludeCommand);
+ state->AddBuiltinCommand("include_guard", cmIncludeGuardCommand);
+ state->AddBuiltinCommand("list", cmListCommand);
+ state->AddBuiltinCommand("macro", cmMacroCommand);
+ state->AddBuiltinCommand("make_directory", cmMakeDirectoryCommand);
+ state->AddBuiltinCommand("mark_as_advanced", cmMarkAsAdvancedCommand);
+ state->AddBuiltinCommand("math", cmMathCommand);
+ state->AddBuiltinCommand("message", cmMessageCommand);
+ state->AddBuiltinCommand("option", cmOptionCommand);
+ state->AddBuiltinCommand("cmake_parse_arguments", cmParseArgumentsCommand);
+ state->AddBuiltinCommand("return", cmReturnCommand);
+ state->AddBuiltinCommand("separate_arguments", cmSeparateArgumentsCommand);
+ state->AddBuiltinCommand("set", cmSetCommand);
state->AddBuiltinCommand("set_directory_properties",
- new cmSetDirectoryPropertiesCommand);
- state->AddBuiltinCommand("set_property", new cmSetPropertyCommand);
- state->AddBuiltinCommand("site_name", new cmSiteNameCommand);
- state->AddBuiltinCommand("string", new cmStringCommand);
- state->AddBuiltinCommand("unset", new cmUnsetCommand);
- state->AddBuiltinCommand("while", new cmWhileCommand);
+ cmSetDirectoryPropertiesCommand);
+ state->AddBuiltinCommand("set_property", cmSetPropertyCommand);
+ state->AddBuiltinCommand("site_name", cmSiteNameCommand);
+ state->AddBuiltinCommand("string", cmStringCommand);
+ state->AddBuiltinCommand("unset", cmUnsetCommand);
+ state->AddBuiltinCommand("while", cmWhileCommand);
state->AddUnexpectedCommand(
- "else", "An ELSE command was found outside of a proper "
- "IF ENDIF structure. Or its arguments did not match "
- "the opening IF command.");
+ "else",
+ "An ELSE command was found outside of a proper "
+ "IF ENDIF structure. Or its arguments did not match "
+ "the opening IF command.");
state->AddUnexpectedCommand(
- "elseif", "An ELSEIF command was found outside of a proper "
- "IF ENDIF structure.");
+ "elseif",
+ "An ELSEIF command was found outside of a proper "
+ "IF ENDIF structure.");
state->AddUnexpectedCommand(
- "endforeach", "An ENDFOREACH command was found outside of a proper "
- "FOREACH ENDFOREACH structure. Or its arguments did "
- "not match the opening FOREACH command.");
+ "endforeach",
+ "An ENDFOREACH command was found outside of a proper "
+ "FOREACH ENDFOREACH structure. Or its arguments did "
+ "not match the opening FOREACH command.");
state->AddUnexpectedCommand(
- "endfunction", "An ENDFUNCTION command was found outside of a proper "
- "FUNCTION ENDFUNCTION structure. Or its arguments did not "
- "match the opening FUNCTION command.");
+ "endfunction",
+ "An ENDFUNCTION command was found outside of a proper "
+ "FUNCTION ENDFUNCTION structure. Or its arguments did not "
+ "match the opening FUNCTION command.");
state->AddUnexpectedCommand(
- "endif", "An ENDIF command was found outside of a proper "
- "IF ENDIF structure. Or its arguments did not match "
- "the opening IF command.");
+ "endif",
+ "An ENDIF command was found outside of a proper "
+ "IF ENDIF structure. Or its arguments did not match "
+ "the opening IF command.");
state->AddUnexpectedCommand(
- "endmacro", "An ENDMACRO command was found outside of a proper "
- "MACRO ENDMACRO structure. Or its arguments did not "
- "match the opening MACRO command.");
+ "endmacro",
+ "An ENDMACRO command was found outside of a proper "
+ "MACRO ENDMACRO structure. Or its arguments did not "
+ "match the opening MACRO command.");
state->AddUnexpectedCommand(
- "endwhile", "An ENDWHILE command was found outside of a proper "
- "WHILE ENDWHILE structure. Or its arguments did not "
- "match the opening WHILE command.");
+ "endwhile",
+ "An ENDWHILE command was found outside of a proper "
+ "WHILE ENDWHILE structure. Or its arguments did not "
+ "match the opening WHILE command.");
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
state->AddBuiltinCommand("cmake_host_system_information",
- new cmCMakeHostSystemInformationCommand);
- state->AddBuiltinCommand("remove", new cmRemoveCommand);
- state->AddBuiltinCommand("variable_watch", new cmVariableWatchCommand);
- state->AddBuiltinCommand("write_file", new cmWriteFileCommand);
+ cmCMakeHostSystemInformationCommand);
+ state->AddBuiltinCommand("remove", cmRemoveCommand);
+ state->AddBuiltinCommand("variable_watch", cmVariableWatchCommand);
+ state->AddBuiltinCommand("write_file", cmWriteFileCommand);
state->AddDisallowedCommand(
- "build_name", new cmBuildNameCommand, cmPolicies::CMP0036,
+ "build_name", cmBuildNameCommand, cmPolicies::CMP0036,
"The build_name command should not be called; see CMP0036.");
state->AddDisallowedCommand(
- "use_mangled_mesa", new cmUseMangledMesaCommand, cmPolicies::CMP0030,
+ "use_mangled_mesa", cmUseMangledMesaCommand, cmPolicies::CMP0030,
"The use_mangled_mesa command should not be called; see CMP0030.");
#endif
@@ -200,94 +214,96 @@ void GetScriptingCommands(cmState* state)
void GetProjectCommands(cmState* state)
{
- state->AddBuiltinCommand("add_custom_command",
- new cmAddCustomCommandCommand);
- state->AddBuiltinCommand("add_custom_target", new cmAddCustomTargetCommand);
- state->AddBuiltinCommand("add_definitions", new cmAddDefinitionsCommand);
- state->AddBuiltinCommand("add_dependencies", new cmAddDependenciesCommand);
- state->AddBuiltinCommand("add_executable", new cmAddExecutableCommand);
- state->AddBuiltinCommand("add_library", new cmAddLibraryCommand);
- state->AddBuiltinCommand("add_subdirectory", new cmAddSubDirectoryCommand);
- state->AddBuiltinCommand("add_test", new cmAddTestCommand);
- state->AddBuiltinCommand("build_command", new cmBuildCommand);
- state->AddBuiltinCommand("create_test_sourcelist",
- new cmCreateTestSourceList);
- state->AddBuiltinCommand("define_property", new cmDefinePropertyCommand);
- state->AddBuiltinCommand("enable_language", new cmEnableLanguageCommand);
- state->AddBuiltinCommand("enable_testing", new cmEnableTestingCommand);
+ state->AddBuiltinCommand("add_custom_command", cmAddCustomCommandCommand);
+ state->AddBuiltinCommand("add_custom_target", cmAddCustomTargetCommand);
+ state->AddBuiltinCommand("add_definitions", cmAddDefinitionsCommand);
+ state->AddBuiltinCommand("add_dependencies", cmAddDependenciesCommand);
+ state->AddBuiltinCommand("add_executable", cmAddExecutableCommand);
+ state->AddBuiltinCommand("add_library", cmAddLibraryCommand);
+ state->AddBuiltinCommand("add_subdirectory", cmAddSubDirectoryCommand);
+ state->AddBuiltinCommand("add_test", cmAddTestCommand);
+ state->AddBuiltinCommand("build_command", cmBuildCommand);
+ state->AddBuiltinCommand("create_test_sourcelist", cmCreateTestSourceList);
+ state->AddBuiltinCommand("define_property", cmDefinePropertyCommand);
+ state->AddBuiltinCommand("enable_language", cmEnableLanguageCommand);
+ state->AddBuiltinCommand("enable_testing", cmEnableTestingCommand);
state->AddBuiltinCommand("get_source_file_property",
- new cmGetSourceFilePropertyCommand);
- state->AddBuiltinCommand("get_target_property",
- new cmGetTargetPropertyCommand);
- state->AddBuiltinCommand("get_test_property", new cmGetTestPropertyCommand);
- state->AddBuiltinCommand("include_directories",
- new cmIncludeDirectoryCommand);
+ cmGetSourceFilePropertyCommand);
+ state->AddBuiltinCommand("get_target_property", cmGetTargetPropertyCommand);
+ state->AddBuiltinCommand("get_test_property", cmGetTestPropertyCommand);
+ state->AddBuiltinCommand("include_directories", cmIncludeDirectoryCommand);
state->AddBuiltinCommand("include_regular_expression",
- new cmIncludeRegularExpressionCommand);
- state->AddBuiltinCommand("install", new cmInstallCommand);
- state->AddBuiltinCommand("install_files", new cmInstallFilesCommand);
- state->AddBuiltinCommand("install_targets", new cmInstallTargetsCommand);
- state->AddBuiltinCommand("link_directories", new cmLinkDirectoriesCommand);
- state->AddBuiltinCommand("project", new cmProjectCommand);
+ cmIncludeRegularExpressionCommand);
+ state->AddBuiltinCommand("install", cmInstallCommand);
+ state->AddBuiltinCommand("install_files", cmInstallFilesCommand);
+ state->AddBuiltinCommand("install_targets", cmInstallTargetsCommand);
+ state->AddBuiltinCommand("link_directories", cmLinkDirectoriesCommand);
+ state->AddBuiltinCommand("project", cmProjectCommand);
state->AddBuiltinCommand("set_source_files_properties",
- new cmSetSourceFilesPropertiesCommand);
+ cmSetSourceFilesPropertiesCommand);
state->AddBuiltinCommand("set_target_properties",
- new cmSetTargetPropertiesCommand);
+ cmSetTargetPropertiesCommand);
state->AddBuiltinCommand("set_tests_properties",
- new cmSetTestsPropertiesCommand);
- state->AddBuiltinCommand("subdirs", new cmSubdirCommand);
- state->AddBuiltinCommand("target_link_libraries",
- new cmTargetLinkLibrariesCommand);
- state->AddBuiltinCommand("try_compile", new cmTryCompileCommand);
- state->AddBuiltinCommand("try_run", new cmTryRunCommand);
-
-#if defined(CMAKE_BUILD_WITH_CMAKE)
- state->AddBuiltinCommand("add_compile_options",
- new cmAddCompileOptionsCommand);
- state->AddBuiltinCommand("aux_source_directory",
- new cmAuxSourceDirectoryCommand);
- state->AddBuiltinCommand("export", new cmExportCommand);
- state->AddBuiltinCommand("fltk_wrap_ui", new cmFLTKWrapUICommand);
- state->AddBuiltinCommand("include_external_msproject",
- new cmIncludeExternalMSProjectCommand);
- state->AddBuiltinCommand("install_programs", new cmInstallProgramsCommand);
- state->AddBuiltinCommand("link_libraries", new cmLinkLibrariesCommand);
- state->AddBuiltinCommand("load_cache", new cmLoadCacheCommand);
- state->AddBuiltinCommand("qt_wrap_cpp", new cmQTWrapCPPCommand);
- state->AddBuiltinCommand("qt_wrap_ui", new cmQTWrapUICommand);
- state->AddBuiltinCommand("remove_definitions",
- new cmRemoveDefinitionsCommand);
- state->AddBuiltinCommand("source_group", new cmSourceGroupCommand);
+ cmSetTestsPropertiesCommand);
+ state->AddBuiltinCommand("subdirs", cmSubdirCommand);
state->AddBuiltinCommand("target_compile_definitions",
- new cmTargetCompileDefinitionsCommand);
+ cmTargetCompileDefinitionsCommand);
state->AddBuiltinCommand("target_compile_features",
- new cmTargetCompileFeaturesCommand);
+ cmTargetCompileFeaturesCommand);
state->AddBuiltinCommand("target_compile_options",
- new cmTargetCompileOptionsCommand);
+ cmTargetCompileOptionsCommand);
state->AddBuiltinCommand("target_include_directories",
- new cmTargetIncludeDirectoriesCommand);
- state->AddBuiltinCommand("target_sources", new cmTargetSourcesCommand);
+ cmTargetIncludeDirectoriesCommand);
+ state->AddBuiltinCommand("target_link_libraries",
+ cmTargetLinkLibrariesCommand);
+ state->AddBuiltinCommand("target_link_options", cmTargetLinkOptionsCommand);
+ state->AddBuiltinCommand("target_sources", cmTargetSourcesCommand);
+ state->AddBuiltinCommand("try_compile",
+ cm::make_unique<cmTryCompileCommand>());
+ state->AddBuiltinCommand("try_run", cm::make_unique<cmTryRunCommand>());
+ state->AddBuiltinCommand("target_precompile_headers",
+ cmTargetPrecompileHeadersCommand);
+
+#if !defined(CMAKE_BOOTSTRAP)
+ state->AddBuiltinCommand("add_compile_definitions",
+ cmAddCompileDefinitionsCommand);
+ state->AddBuiltinCommand("add_compile_options", cmAddCompileOptionsCommand);
+ state->AddBuiltinCommand("aux_source_directory",
+ cmAuxSourceDirectoryCommand);
+ state->AddBuiltinCommand("export", cmExportCommand);
+ state->AddBuiltinCommand("fltk_wrap_ui", cmFLTKWrapUICommand);
+ state->AddBuiltinCommand("include_external_msproject",
+ cmIncludeExternalMSProjectCommand);
+ state->AddBuiltinCommand("install_programs", cmInstallProgramsCommand);
+ state->AddBuiltinCommand("add_link_options", cmAddLinkOptionsCommand);
+ state->AddBuiltinCommand("link_libraries", cmLinkLibrariesCommand);
+ state->AddBuiltinCommand("target_link_directories",
+ cmTargetLinkDirectoriesCommand);
+ state->AddBuiltinCommand("load_cache", cmLoadCacheCommand);
+ state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand);
+ state->AddBuiltinCommand("qt_wrap_ui", cmQTWrapUICommand);
+ state->AddBuiltinCommand("remove_definitions", cmRemoveDefinitionsCommand);
+ state->AddBuiltinCommand("source_group", cmSourceGroupCommand);
state->AddDisallowedCommand(
- "export_library_dependencies", new cmExportLibraryDependenciesCommand,
+ "export_library_dependencies", cmExportLibraryDependenciesCommand,
cmPolicies::CMP0033,
"The export_library_dependencies command should not be called; "
"see CMP0033.");
state->AddDisallowedCommand(
- "load_command", new cmLoadCommandCommand, cmPolicies::CMP0031,
+ "load_command", cmLoadCommandCommand, cmPolicies::CMP0031,
"The load_command command should not be called; see CMP0031.");
state->AddDisallowedCommand(
- "output_required_files", new cmOutputRequiredFilesCommand,
- cmPolicies::CMP0032,
+ "output_required_files", cmOutputRequiredFilesCommand, cmPolicies::CMP0032,
"The output_required_files command should not be called; see CMP0032.");
state->AddDisallowedCommand(
- "subdir_depends", new cmSubdirDependsCommand, cmPolicies::CMP0029,
+ "subdir_depends", cmSubdirDependsCommand, cmPolicies::CMP0029,
"The subdir_depends command should not be called; see CMP0029.");
state->AddDisallowedCommand(
- "utility_source", new cmUtilitySourceCommand, cmPolicies::CMP0034,
+ "utility_source", cmUtilitySourceCommand, cmPolicies::CMP0034,
"The utility_source command should not be called; see CMP0034.");
state->AddDisallowedCommand(
- "variable_requires", new cmVariableRequiresCommand, cmPolicies::CMP0035,
+ "variable_requires", cmVariableRequiresCommand, cmPolicies::CMP0035,
"The variable_requires command should not be called; see CMP0035.");
#endif
}
@@ -341,7 +357,7 @@ void GetProjectCommandsInScriptMode(cmState* state)
CM_UNEXPECTED_PROJECT_COMMAND("try_compile");
CM_UNEXPECTED_PROJECT_COMMAND("try_run");
- // deprected commands
+ // deprecated commands
CM_UNEXPECTED_PROJECT_COMMAND("export_library_dependencies");
CM_UNEXPECTED_PROJECT_COMMAND("load_command");
CM_UNEXPECTED_PROJECT_COMMAND("output_required_files");
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index 391d65c40..19a096bdf 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -2,12 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCommonTargetGenerator.h"
-#include "cmConfigure.h"
#include <set>
#include <sstream>
#include <utility>
-#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalCommonGenerator.h"
@@ -18,20 +16,20 @@
#include "cmOutputConverter.h"
#include "cmSourceFile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt)
: GeneratorTarget(gt)
, Makefile(gt->Makefile)
- , LocalGenerator(static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator))
- , GlobalGenerator(static_cast<cmGlobalCommonGenerator*>(
+ , LocalCommonGenerator(
+ static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator))
+ , GlobalCommonGenerator(static_cast<cmGlobalCommonGenerator*>(
gt->LocalGenerator->GetGlobalGenerator()))
- , ConfigName(LocalGenerator->GetConfigName())
+ , ConfigName(LocalCommonGenerator->GetConfigName())
{
}
-cmCommonTargetGenerator::~cmCommonTargetGenerator()
-{
-}
+cmCommonTargetGenerator::~cmCommonTargetGenerator() = default;
std::string const& cmCommonTargetGenerator::GetConfigName() const
{
@@ -61,11 +59,12 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(
// Append the flag and value. Use ConvertToLinkReference to help
// vs6's "cl -link" pass it to the linker.
- std::string flag = defFileFlag;
- flag += this->LocalGenerator->ConvertToOutputFormat(
- linkLineComputer->ConvertToLinkReference(mdi->DefFile),
- cmOutputConverter::SHELL);
- this->LocalGenerator->AppendFlags(flags, flag);
+ std::string flag =
+ cmStrCat(defFileFlag,
+ this->LocalCommonGenerator->ConvertToOutputFormat(
+ linkLineComputer->ConvertToLinkReference(mdi->DefFile),
+ cmOutputConverter::SHELL));
+ this->LocalCommonGenerator->AppendFlags(flags, flag);
}
void cmCommonTargetGenerator::AppendFortranFormatFlags(
@@ -78,7 +77,7 @@ void cmCommonTargetGenerator::AppendFortranFormatFlags(
const char* tgtfmt = this->GeneratorTarget->GetProperty("Fortran_FORMAT");
format = cmOutputConverter::GetFortranFormat(tgtfmt);
}
- const char* var = CM_NULLPTR;
+ const char* var = nullptr;
switch (format) {
case cmOutputConverter::FortranFormatFixed:
var = "CMAKE_Fortran_FORMAT_FIXED_FLAG";
@@ -90,19 +89,19 @@ void cmCommonTargetGenerator::AppendFortranFormatFlags(
break;
}
if (var) {
- this->LocalGenerator->AppendFlags(flags,
- this->Makefile->GetDefinition(var));
+ this->LocalCommonGenerator->AppendFlags(
+ flags, this->Makefile->GetSafeDefinition(var));
}
}
std::string cmCommonTargetGenerator::GetFlags(const std::string& l)
{
- ByLanguageMap::iterator i = this->FlagsByLanguage.find(l);
+ auto i = this->FlagsByLanguage.find(l);
if (i == this->FlagsByLanguage.end()) {
std::string flags;
- this->LocalGenerator->GetTargetCompileFlags(this->GeneratorTarget,
- this->ConfigName, l, flags);
+ this->LocalCommonGenerator->GetTargetCompileFlags(
+ this->GeneratorTarget, this->ConfigName, l, flags);
ByLanguageMap::value_type entry(l, flags);
i = this->FlagsByLanguage.insert(entry).first;
@@ -112,14 +111,14 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string& l)
std::string cmCommonTargetGenerator::GetDefines(const std::string& l)
{
- ByLanguageMap::iterator i = this->DefinesByLanguage.find(l);
+ auto i = this->DefinesByLanguage.find(l);
if (i == this->DefinesByLanguage.end()) {
std::set<std::string> defines;
- this->LocalGenerator->GetTargetDefines(this->GeneratorTarget,
- this->ConfigName, l, defines);
+ this->LocalCommonGenerator->GetTargetDefines(this->GeneratorTarget,
+ this->ConfigName, l, defines);
std::string definesString;
- this->LocalGenerator->JoinDefines(defines, definesString, l);
+ this->LocalCommonGenerator->JoinDefines(defines, definesString, l);
ByLanguageMap::value_type entry(l, definesString);
i = this->DefinesByLanguage.insert(entry).first;
@@ -129,7 +128,7 @@ std::string cmCommonTargetGenerator::GetDefines(const std::string& l)
std::string cmCommonTargetGenerator::GetIncludes(std::string const& l)
{
- ByLanguageMap::iterator i = this->IncludesByLanguage.find(l);
+ auto i = this->IncludesByLanguage.find(l);
if (i == this->IncludesByLanguage.end()) {
std::string includes;
this->AddIncludeFlags(includes, l);
@@ -147,21 +146,19 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories()
if (cmComputeLinkInformation* cli =
this->GeneratorTarget->GetLinkInformation(this->ConfigName)) {
cmComputeLinkInformation::ItemVector const& items = cli->GetItems();
- for (cmComputeLinkInformation::ItemVector::const_iterator i =
- items.begin();
- i != items.end(); ++i) {
- cmGeneratorTarget const* linkee = i->Target;
- if (linkee && !linkee->IsImported()
+ for (auto const& item : items) {
+ cmGeneratorTarget const* linkee = item.Target;
+ if (linkee &&
+ !linkee->IsImported()
// We can ignore the INTERFACE_LIBRARY items because
// Target->GetLinkInformation already processed their
// link interface and they don't have any output themselves.
&& linkee->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
emitted.insert(linkee).second) {
cmLocalGenerator* lg = linkee->GetLocalGenerator();
- std::string di = lg->GetCurrentBinaryDirectory();
- di += "/";
- di += lg->GetTargetDirectory(linkee);
- dirs.push_back(di);
+ std::string di = cmStrCat(lg->GetCurrentBinaryDirectory(), '/',
+ lg->GetTargetDirectory(linkee));
+ dirs.push_back(std::move(di));
}
}
}
@@ -174,6 +171,7 @@ std::string cmCommonTargetGenerator::ComputeTargetCompilePDB() const
if (this->GeneratorTarget->GetType() > cmStateEnums::OBJECT_LIBRARY) {
return compilePdbPath;
}
+
compilePdbPath =
this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName());
if (compilePdbPath.empty()) {
@@ -196,11 +194,12 @@ std::string cmCommonTargetGenerator::GetManifests()
this->GeneratorTarget->GetManifests(manifest_srcs, this->ConfigName);
std::vector<std::string> manifests;
- for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
- mi != manifest_srcs.end(); ++mi) {
- manifests.push_back(this->LocalGenerator->ConvertToOutputFormat(
- this->LocalGenerator->ConvertToRelativePath(
- this->LocalGenerator->GetWorkingDirectory(), (*mi)->GetFullPath()),
+ manifests.reserve(manifest_srcs.size());
+ for (cmSourceFile const* manifest_src : manifest_srcs) {
+ manifests.push_back(this->LocalCommonGenerator->ConvertToOutputFormat(
+ this->LocalCommonGenerator->MaybeConvertToRelativePath(
+ this->LocalCommonGenerator->GetWorkingDirectory(),
+ manifest_src->GetFullPath()),
cmOutputConverter::SHELL));
}
@@ -212,11 +211,7 @@ void cmCommonTargetGenerator::AppendOSXVerFlag(std::string& flags,
const char* name, bool so)
{
// Lookup the flag to specify the version.
- std::string fvar = "CMAKE_";
- fvar += lang;
- fvar += "_OSX_";
- fvar += name;
- fvar += "_VERSION_FLAG";
+ std::string fvar = cmStrCat("CMAKE_", lang, "_OSX_", name, "_VERSION_FLAG");
const char* flag = this->Makefile->GetDefinition(fvar);
// Skip if no such flag.
@@ -233,6 +228,6 @@ void cmCommonTargetGenerator::AppendOSXVerFlag(std::string& flags,
// Append the flag since a non-zero version is specified.
std::ostringstream vflag;
vflag << flag << major << "." << minor << "." << patch;
- this->LocalGenerator->AppendFlags(flags, vflag.str());
+ this->LocalCommonGenerator->AppendFlags(flags, vflag.str());
}
}
diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h
index c36145fe2..17792d6ac 100644
--- a/Source/cmCommonTargetGenerator.h
+++ b/Source/cmCommonTargetGenerator.h
@@ -37,8 +37,8 @@ protected:
cmGeneratorTarget* GeneratorTarget;
cmMakefile* Makefile;
- cmLocalCommonGenerator* LocalGenerator;
- cmGlobalCommonGenerator* GlobalGenerator;
+ cmLocalCommonGenerator* LocalCommonGenerator;
+ cmGlobalCommonGenerator* GlobalCommonGenerator;
std::string ConfigName;
void AppendFortranFormatFlags(std::string& flags,
@@ -50,7 +50,7 @@ protected:
void AppendOSXVerFlag(std::string& flags, const std::string& lang,
const char* name, bool so);
- typedef std::map<std::string, std::string> ByLanguageMap;
+ using ByLanguageMap = std::map<std::string, std::string>;
std::string GetFlags(const std::string& l);
ByLanguageMap FlagsByLanguage;
std::string GetDefines(const std::string& l);
diff --git a/Source/cmComputeComponentGraph.cxx b/Source/cmComputeComponentGraph.cxx
index a02d8854b..af257ee03 100644
--- a/Source/cmComputeComponentGraph.cxx
+++ b/Source/cmComputeComponentGraph.cxx
@@ -3,8 +3,7 @@
#include "cmComputeComponentGraph.h"
#include <algorithm>
-
-#include <assert.h>
+#include <cassert>
cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input)
: InputGraph(input)
@@ -18,9 +17,7 @@ cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input)
this->TransferEdges();
}
-cmComputeComponentGraph::~cmComputeComponentGraph()
-{
-}
+cmComputeComponentGraph::~cmComputeComponentGraph() = default;
void cmComputeComponentGraph::Tarjan()
{
@@ -57,8 +54,8 @@ void cmComputeComponentGraph::TarjanVisit(int i)
// Follow outgoing edges.
EdgeList const& nl = this->InputGraph[i];
- for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int j = *ni;
+ for (cmGraphEdge const& ni : nl) {
+ int j = ni;
// Ignore edges to nodes that have been reached by a previous DFS
// walk. Since we did not reach the current node from that walk
@@ -88,7 +85,7 @@ void cmComputeComponentGraph::TarjanVisit(int i)
if (this->TarjanEntries[i].Root == i) {
// Yes. Create it.
int c = static_cast<int>(this->Components.size());
- this->Components.push_back(NodeList());
+ this->Components.emplace_back();
NodeList& component = this->Components[c];
// Populate the component list.
@@ -119,14 +116,14 @@ void cmComputeComponentGraph::TransferEdges()
for (int i = 0; i < n; ++i) {
int i_component = this->TarjanComponents[i];
EdgeList const& nl = this->InputGraph[i];
- for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int j = *ni;
+ for (cmGraphEdge const& ni : nl) {
+ int j = ni;
int j_component = this->TarjanComponents[j];
if (i_component != j_component) {
// We do not attempt to combine duplicate edges, but instead
// store the inter-component edges with suitable multiplicity.
- this->ComponentGraph[i_component].push_back(
- cmGraphEdge(j_component, ni->IsStrong()));
+ this->ComponentGraph[i_component].emplace_back(
+ j_component, ni.IsStrong(), ni.GetBacktrace());
}
}
}
diff --git a/Source/cmComputeComponentGraph.h b/Source/cmComputeComponentGraph.h
index 8cd4fe73a..202888cf9 100644
--- a/Source/cmComputeComponentGraph.h
+++ b/Source/cmComputeComponentGraph.h
@@ -5,11 +5,11 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmGraphAdjacencyList.h"
-
#include <stack>
#include <vector>
+#include "cmGraphAdjacencyList.h"
+
/** \class cmComputeComponentGraph
* \brief Analyze a graph to determine strongly connected components.
*
@@ -24,9 +24,9 @@ class cmComputeComponentGraph
{
public:
// Represent the graph with an adjacency list.
- typedef cmGraphNodeList NodeList;
- typedef cmGraphEdgeList EdgeList;
- typedef cmGraphAdjacencyList Graph;
+ using NodeList = cmGraphNodeList;
+ using EdgeList = cmGraphEdgeList;
+ using Graph = cmGraphAdjacencyList;
cmComputeComponentGraph(Graph const& input);
~cmComputeComponentGraph();
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 9c516ee8d..7a9e2b7f6 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -2,25 +2,28 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmComputeLinkDepends.h"
-#include "cmAlgorithms.h"
+#include <algorithm>
+#include <cassert>
+#include <cstdio>
+#include <cstring>
+#include <iterator>
+#include <sstream>
+#include <utility>
+
+#include <cm/memory>
+
#include "cmComputeComponentGraph.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
+#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmRange.h"
#include "cmStateTypes.h"
-#include "cmSystemTools.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
#include "cmake.h"
-#include <algorithm>
-#include <assert.h>
-#include <iterator>
-#include <sstream>
-#include <stdio.h>
-#include <string.h>
-#include <utility>
-
/*
This file computes an ordered list of link items to use when linking a
@@ -194,14 +197,10 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target,
this->OldLinkDirMode = false;
// No computation has been done.
- this->CCG = CM_NULLPTR;
+ this->CCG = nullptr;
}
-cmComputeLinkDepends::~cmComputeLinkDepends()
-{
- cmDeleteAll(this->InferredDependSets);
- delete this->CCG;
-}
+cmComputeLinkDepends::~cmComputeLinkDepends() = default;
void cmComputeLinkDepends::SetOldLinkDirMode(bool b)
{
@@ -239,8 +238,9 @@ cmComputeLinkDepends::Compute()
// Display the constraint graph.
if (this->DebugMode) {
- fprintf(stderr, "---------------------------------------"
- "---------------------------------------\n");
+ fprintf(stderr,
+ "---------------------------------------"
+ "---------------------------------------\n");
fprintf(stderr, "Link dependency analysis for target %s, config %s\n",
this->Target->GetName().c_str(),
this->HasConfig ? this->Config.c_str() : "noconfig");
@@ -254,11 +254,7 @@ cmComputeLinkDepends::Compute()
// Iterate in reverse order so we can keep only the last occurrence
// of a shared library.
std::set<int> emmitted;
- for (std::vector<int>::const_reverse_iterator
- li = this->FinalLinkOrder.rbegin(),
- le = this->FinalLinkOrder.rend();
- li != le; ++li) {
- int i = *li;
+ for (int i : cmReverseRange(this->FinalLinkOrder)) {
LinkEntry const& e = this->EntryList[i];
cmGeneratorTarget const* t = e.Target;
// Entries that we know the linker will re-use do not need to be repeated.
@@ -278,23 +274,22 @@ cmComputeLinkDepends::Compute()
return this->FinalLinkEntries;
}
-std::map<std::string, int>::iterator cmComputeLinkDepends::AllocateLinkEntry(
- std::string const& item)
+std::map<cmLinkItem, int>::iterator cmComputeLinkDepends::AllocateLinkEntry(
+ cmLinkItem const& item)
{
- std::map<std::string, int>::value_type index_entry(
+ std::map<cmLinkItem, int>::value_type index_entry(
item, static_cast<int>(this->EntryList.size()));
- std::map<std::string, int>::iterator lei =
- this->LinkEntryIndex.insert(index_entry).first;
- this->EntryList.push_back(LinkEntry());
- this->InferredDependSets.push_back(CM_NULLPTR);
- this->EntryConstraintGraph.push_back(EdgeList());
+ auto lei = this->LinkEntryIndex.insert(index_entry).first;
+ this->EntryList.emplace_back();
+ this->InferredDependSets.emplace_back();
+ this->EntryConstraintGraph.emplace_back();
return lei;
}
int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
{
// Check if the item entry has already been added.
- std::map<std::string, int>::iterator lei = this->LinkEntryIndex.find(item);
+ auto lei = this->LinkEntryIndex.find(item);
if (lei != this->LinkEntryIndex.end()) {
// Yes. We do not need to follow the item's dependencies again.
return lei->second;
@@ -306,27 +301,27 @@ int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
// Initialize the item entry.
int index = lei->second;
LinkEntry& entry = this->EntryList[index];
- entry.Item = item;
+ entry.Item = item.AsStr();
entry.Target = item.Target;
- entry.IsFlag = (!entry.Target && item[0] == '-' && item[1] != 'l' &&
- item.substr(0, 10) != "-framework");
+ entry.IsFlag =
+ (!entry.Target && entry.Item[0] == '-' && entry.Item[1] != 'l' &&
+ entry.Item.substr(0, 10) != "-framework");
// If the item has dependencies queue it to follow them.
if (entry.Target) {
// Target dependencies are always known. Follow them.
- BFSEntry qe = { index, CM_NULLPTR };
+ BFSEntry qe = { index, nullptr };
this->BFSQueue.push(qe);
} else {
// Look for an old-style <item>_LIB_DEPENDS variable.
- std::string var = entry.Item;
- var += "_LIB_DEPENDS";
+ std::string var = cmStrCat(entry.Item, "_LIB_DEPENDS");
if (const char* val = this->Makefile->GetDefinition(var)) {
// The item dependencies are known. Follow them.
BFSEntry qe = { index, val };
this->BFSQueue.push(qe);
} else if (!entry.IsFlag) {
// The item dependencies are not known. We need to infer them.
- this->InferredDependSets[index] = new DependSetList;
+ this->InferredDependSets[index].Initialized = true;
}
}
@@ -357,10 +352,8 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry qe)
this->FollowSharedDeps(depender_index, iface);
// Support for CMP0003.
- for (std::vector<cmLinkItem>::const_iterator oi =
- iface->WrongConfigLibraries.begin();
- oi != iface->WrongConfigLibraries.end(); ++oi) {
- this->CheckWrongConfigItem(*oi);
+ for (cmLinkItem const& oi : iface->WrongConfigLibraries) {
+ this->CheckWrongConfigItem(oi);
}
}
} else {
@@ -385,10 +378,9 @@ void cmComputeLinkDepends::FollowSharedDeps(int depender_index,
void cmComputeLinkDepends::QueueSharedDependencies(
int depender_index, std::vector<cmLinkItem> const& deps)
{
- for (std::vector<cmLinkItem>::const_iterator li = deps.begin();
- li != deps.end(); ++li) {
+ for (cmLinkItem const& li : deps) {
SharedDepEntry qe;
- qe.Item = *li;
+ qe.Item = li;
qe.DependerIndex = depender_index;
this->SharedDepQueue.push(qe);
}
@@ -397,15 +389,14 @@ void cmComputeLinkDepends::QueueSharedDependencies(
void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
{
// Check if the target already has an entry.
- std::map<std::string, int>::iterator lei =
- this->LinkEntryIndex.find(dep.Item);
+ auto lei = this->LinkEntryIndex.find(dep.Item);
if (lei == this->LinkEntryIndex.end()) {
// Allocate a spot for the item entry.
lei = this->AllocateLinkEntry(dep.Item);
// Initialize the item entry.
LinkEntry& entry = this->EntryList[lei->second];
- entry.Item = dep.Item;
+ entry.Item = dep.Item.AsStr();
entry.Target = dep.Item.Target;
// This item was added specifically because it is a dependent
@@ -420,7 +411,8 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
// This shared library dependency must follow the item that listed
// it.
- this->EntryConstraintGraph[dep.DependerIndex].push_back(index);
+ this->EntryConstraintGraph[dep.DependerIndex].emplace_back(
+ index, true, cmListFileBacktrace());
// Target items may have their own dependencies.
if (entry.Target) {
@@ -438,33 +430,30 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
// This is called to add the dependencies named by
// <item>_LIB_DEPENDS. The variable contains a semicolon-separated
// list. The list contains link-type;item pairs and just items.
- std::vector<std::string> deplist;
- cmSystemTools::ExpandListArgument(value, deplist);
+ std::vector<std::string> deplist = cmExpandedList(value);
// Look for entries meant for this configuration.
std::vector<cmLinkItem> actual_libs;
cmTargetLinkLibraryType llt = GENERAL_LibraryType;
bool haveLLT = false;
- for (std::vector<std::string>::const_iterator di = deplist.begin();
- di != deplist.end(); ++di) {
- if (*di == "debug") {
+ for (std::string const& d : deplist) {
+ if (d == "debug") {
llt = DEBUG_LibraryType;
haveLLT = true;
- } else if (*di == "optimized") {
+ } else if (d == "optimized") {
llt = OPTIMIZED_LibraryType;
haveLLT = true;
- } else if (*di == "general") {
+ } else if (d == "general") {
llt = GENERAL_LibraryType;
haveLLT = true;
- } else if (!di->empty()) {
+ } else if (!d.empty()) {
// If no explicit link type was given prior to this entry then
// check if the entry has its own link type variable. This is
// needed for compatibility with dependency files generated by
// the export_library_dependencies command from CMake 2.4 and
// lower.
if (!haveLLT) {
- std::string var = *di;
- var += "_LINK_TYPE";
+ std::string var = cmStrCat(d, "_LINK_TYPE");
if (const char* val = this->Makefile->GetDefinition(var)) {
if (strcmp(val, "debug") == 0) {
llt = DEBUG_LibraryType;
@@ -476,10 +465,9 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
// If the library is meant for this link type then use it.
if (llt == GENERAL_LibraryType || llt == this->LinkType) {
- cmLinkItem item(*di, this->FindTargetToLink(depender_index, *di));
- actual_libs.push_back(item);
+ actual_libs.emplace_back(this->ResolveLinkItem(depender_index, d));
} else if (this->OldLinkDirMode) {
- cmLinkItem item(*di, this->FindTargetToLink(depender_index, *di));
+ cmLinkItem item = this->ResolveLinkItem(depender_index, d);
this->CheckWrongConfigItem(item);
}
@@ -499,10 +487,8 @@ void cmComputeLinkDepends::AddDirectLinkEntries()
cmLinkImplementation const* impl =
this->Target->GetLinkImplementation(this->Config);
this->AddLinkEntries(-1, impl->Libraries);
- for (std::vector<cmLinkItem>::const_iterator wi =
- impl->WrongConfigLibraries.begin();
- wi != impl->WrongConfigLibraries.end(); ++wi) {
- this->CheckWrongConfigItem(*wi);
+ for (cmLinkItem const& wi : impl->WrongConfigLibraries) {
+ this->CheckWrongConfigItem(wi);
}
}
@@ -514,56 +500,54 @@ void cmComputeLinkDepends::AddLinkEntries(int depender_index,
std::map<int, DependSet> dependSets;
// Loop over the libraries linked directly by the depender.
- for (typename std::vector<T>::const_iterator li = libs.begin();
- li != libs.end(); ++li) {
+ for (T const& l : libs) {
// Skip entries that will resolve to the target getting linked or
// are empty.
- cmLinkItem const& item = *li;
- if (item == this->Target->GetName() || item.empty()) {
+ cmLinkItem const& item = l;
+ if (item.AsStr() == this->Target->GetName() || item.AsStr().empty()) {
continue;
}
// Add a link entry for this item.
- int dependee_index = this->AddLinkEntry(*li);
+ int dependee_index = this->AddLinkEntry(l);
// The dependee must come after the depender.
if (depender_index >= 0) {
- this->EntryConstraintGraph[depender_index].push_back(dependee_index);
+ this->EntryConstraintGraph[depender_index].emplace_back(
+ dependee_index, false, cmListFileBacktrace());
} else {
// This is a direct dependency of the target being linked.
this->OriginalEntries.push_back(dependee_index);
}
// Update the inferred dependencies for earlier items.
- for (std::map<int, DependSet>::iterator dsi = dependSets.begin();
- dsi != dependSets.end(); ++dsi) {
+ for (auto& dependSet : dependSets) {
// Add this item to the inferred dependencies of other items.
// Target items are never inferred dependees because unknown
// items are outside libraries that should not be depending on
// targets.
if (!this->EntryList[dependee_index].Target &&
!this->EntryList[dependee_index].IsFlag &&
- dependee_index != dsi->first) {
- dsi->second.insert(dependee_index);
+ dependee_index != dependSet.first) {
+ dependSet.second.insert(dependee_index);
}
}
// If this item needs to have dependencies inferred, do so.
- if (this->InferredDependSets[dependee_index]) {
+ if (this->InferredDependSets[dependee_index].Initialized) {
// Make sure an entry exists to hold the set for the item.
dependSets[dependee_index];
}
}
// Store the inferred dependency sets discovered for this list.
- for (std::map<int, DependSet>::iterator dsi = dependSets.begin();
- dsi != dependSets.end(); ++dsi) {
- this->InferredDependSets[dsi->first]->push_back(dsi->second);
+ for (auto const& dependSet : dependSets) {
+ this->InferredDependSets[dependSet.first].push_back(dependSet.second);
}
}
-cmGeneratorTarget const* cmComputeLinkDepends::FindTargetToLink(
- int depender_index, const std::string& name)
+cmLinkItem cmComputeLinkDepends::ResolveLinkItem(int depender_index,
+ const std::string& name)
{
// Look for a target in the scope of the depender.
cmGeneratorTarget const* from = this->Target;
@@ -573,7 +557,7 @@ cmGeneratorTarget const* cmComputeLinkDepends::FindTargetToLink(
from = depender;
}
}
- return from->FindTargetToLink(name);
+ return from->ResolveLinkItem(name, cmListFileBacktrace());
}
void cmComputeLinkDepends::InferDependencies()
@@ -585,37 +569,39 @@ void cmComputeLinkDepends::InferDependencies()
depender_index < this->InferredDependSets.size(); ++depender_index) {
// Skip items for which dependencies do not need to be inferred or
// for which the inferred dependency sets are empty.
- DependSetList* sets = this->InferredDependSets[depender_index];
- if (!sets || sets->empty()) {
+ DependSetList& sets = this->InferredDependSets[depender_index];
+ if (!sets.Initialized || sets.empty()) {
continue;
}
// Intersect the sets for this item.
- DependSetList::const_iterator i = sets->begin();
- DependSet common = *i;
- for (++i; i != sets->end(); ++i) {
+ DependSet common = sets.front();
+ for (DependSet const& i : cmMakeRange(sets).advance(1)) {
DependSet intersection;
- std::set_intersection(common.begin(), common.end(), i->begin(), i->end(),
+ std::set_intersection(common.begin(), common.end(), i.begin(), i.end(),
std::inserter(intersection, intersection.begin()));
common = intersection;
}
// Add the inferred dependencies to the graph.
cmGraphEdgeList& edges = this->EntryConstraintGraph[depender_index];
- edges.insert(edges.end(), common.begin(), common.end());
+ edges.reserve(edges.size() + common.size());
+ for (auto const& c : common) {
+ edges.emplace_back(c, true, cmListFileBacktrace());
+ }
}
}
void cmComputeLinkDepends::CleanConstraintGraph()
{
- for (Graph::iterator i = this->EntryConstraintGraph.begin();
- i != this->EntryConstraintGraph.end(); ++i) {
+ for (cmGraphEdgeList& edgeList : this->EntryConstraintGraph) {
// Sort the outgoing edges for each graph node so that the
// original order will be preserved as much as possible.
- std::sort(i->begin(), i->end());
+ std::sort(edgeList.begin(), edgeList.end());
// Make the edge list unique.
- i->erase(std::unique(i->begin(), i->end()), i->end());
+ edgeList.erase(std::unique(edgeList.begin(), edgeList.end()),
+ edgeList.end());
}
}
@@ -638,7 +624,8 @@ void cmComputeLinkDepends::OrderLinkEntires()
// the same order in which the items were originally discovered in
// the BFS. This should preserve the original order when no
// constraints disallow it.
- this->CCG = new cmComputeComponentGraph(this->EntryConstraintGraph);
+ this->CCG =
+ cm::make_unique<cmComputeComponentGraph>(this->EntryConstraintGraph);
// The component graph is guaranteed to be acyclic. Start a DFS
// from every entry to compute a topological order for the
@@ -660,9 +647,8 @@ void cmComputeLinkDepends::OrderLinkEntires()
}
// Start with the original link line.
- for (std::vector<int>::const_iterator i = this->OriginalEntries.begin();
- i != this->OriginalEntries.end(); ++i) {
- this->VisitEntry(*i);
+ for (int originalEntry : this->OriginalEntries) {
+ this->VisitEntry(originalEntry);
}
// Now explore anything left pending. Since the component graph is
@@ -684,13 +670,12 @@ void cmComputeLinkDepends::DisplayComponents()
for (unsigned int c = 0; c < components.size(); ++c) {
fprintf(stderr, "Component (%u):\n", c);
NodeList const& nl = components[c];
- for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int i = *ni;
+ for (int i : nl) {
fprintf(stderr, " item %d [%s]\n", i, this->EntryList[i].Item.c_str());
}
EdgeList const& ol = this->CCG->GetComponentGraphEdges(c);
- for (EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) {
- int i = *oi;
+ for (cmGraphEdge const& oi : ol) {
+ int i = oi;
fprintf(stderr, " followed by Component (%d)\n", i);
}
fprintf(stderr, " topo order index %d\n", this->ComponentOrder[c]);
@@ -712,9 +697,8 @@ void cmComputeLinkDepends::VisitComponent(unsigned int c)
// Run in reverse order so the topological order will preserve the
// original order where there are no constraints.
EdgeList const& nl = this->CCG->GetComponentGraphEdges(c);
- for (EdgeList::const_reverse_iterator ni = nl.rbegin(); ni != nl.rend();
- ++ni) {
- this->VisitComponent(*ni);
+ for (cmGraphEdge const& edge : cmReverseRange(nl)) {
+ this->VisitComponent(edge);
}
// Assign an ordering id to this component.
@@ -729,8 +713,7 @@ void cmComputeLinkDepends::VisitEntry(int index)
// This entry has now been seen. Update its component.
bool completed = false;
int component = this->CCG->GetComponentMap()[index];
- std::map<int, PendingComponent>::iterator mi =
- this->PendingComponents.find(this->ComponentOrder[component]);
+ auto mi = this->PendingComponents.find(this->ComponentOrder[component]);
if (mi != this->PendingComponents.end()) {
// The entry is in an already pending component.
PendingComponent& pc = mi->second;
@@ -771,10 +754,10 @@ void cmComputeLinkDepends::VisitEntry(int index)
// are now pending.
if (completed) {
EdgeList const& ol = this->CCG->GetComponentGraphEdges(component);
- for (EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) {
+ for (cmGraphEdge const& oi : ol) {
// This entire component is now pending no matter whether it has
// been partially seen already.
- this->MakePendingComponent(*oi);
+ this->MakePendingComponent(oi);
}
}
}
@@ -816,8 +799,8 @@ cmComputeLinkDepends::MakePendingComponent(unsigned int component)
int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
{
unsigned int count = 2;
- for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- if (cmGeneratorTarget const* target = this->EntryList[*ni].Target) {
+ for (int ni : nl) {
+ if (cmGeneratorTarget const* target = this->EntryList[ni].Target) {
if (cmLinkInterface const* iface =
target->GetLinkInterface(this->Config, this->Target)) {
if (iface->Multiplicity > count) {
@@ -832,13 +815,11 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
void cmComputeLinkDepends::DisplayFinalEntries()
{
fprintf(stderr, "target [%s] links to:\n", this->Target->GetName().c_str());
- for (std::vector<LinkEntry>::const_iterator lei =
- this->FinalLinkEntries.begin();
- lei != this->FinalLinkEntries.end(); ++lei) {
- if (lei->Target) {
- fprintf(stderr, " target [%s]\n", lei->Target->GetName().c_str());
+ for (LinkEntry const& lei : this->FinalLinkEntries) {
+ if (lei.Target) {
+ fprintf(stderr, " target [%s]\n", lei.Target->GetName().c_str());
} else {
- fprintf(stderr, " item [%s]\n", lei->Item.c_str());
+ fprintf(stderr, " item [%s]\n", lei.Item.c_str());
}
}
fprintf(stderr, "\n");
diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h
index 84ee9161f..645189ad5 100644
--- a/Source/cmComputeLinkDepends.h
+++ b/Source/cmComputeLinkDepends.h
@@ -5,16 +5,18 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmGraphAdjacencyList.h"
-#include "cmLinkItem.h"
-#include "cmTargetLinkLibraryType.h"
-
#include <map>
-#include <queue>
+#include <memory>
#include <set>
#include <string>
#include <vector>
+#include <queue>
+
+#include "cmGraphAdjacencyList.h"
+#include "cmLinkItem.h"
+#include "cmTargetLinkLibraryType.h"
+
class cmComputeComponentGraph;
class cmGeneratorTarget;
class cmGlobalGenerator;
@@ -31,30 +33,19 @@ public:
const std::string& config);
~cmComputeLinkDepends();
+ cmComputeLinkDepends(const cmComputeLinkDepends&) = delete;
+ cmComputeLinkDepends& operator=(const cmComputeLinkDepends&) = delete;
+
// Basic information about each link item.
struct LinkEntry
{
std::string Item;
- cmGeneratorTarget const* Target;
- bool IsSharedDep;
- bool IsFlag;
- LinkEntry()
- : Item()
- , Target(CM_NULLPTR)
- , IsSharedDep(false)
- , IsFlag(false)
- {
- }
- LinkEntry(LinkEntry const& r)
- : Item(r.Item)
- , Target(r.Target)
- , IsSharedDep(r.IsSharedDep)
- , IsFlag(r.IsFlag)
- {
- }
+ cmGeneratorTarget const* Target = nullptr;
+ bool IsSharedDep = false;
+ bool IsFlag = false;
};
- typedef std::vector<LinkEntry> EntryVector;
+ using EntryVector = std::vector<LinkEntry>;
EntryVector const& Compute();
void SetOldLinkDirMode(bool b);
@@ -72,19 +63,18 @@ private:
std::string Config;
EntryVector FinalLinkEntries;
- std::map<std::string, int>::iterator AllocateLinkEntry(
- std::string const& item);
+ std::map<cmLinkItem, int>::iterator AllocateLinkEntry(
+ cmLinkItem const& item);
int AddLinkEntry(cmLinkItem const& item);
void AddVarLinkEntries(int depender_index, const char* value);
void AddDirectLinkEntries();
template <typename T>
void AddLinkEntries(int depender_index, std::vector<T> const& libs);
- cmGeneratorTarget const* FindTargetToLink(int depender_index,
- const std::string& name);
+ cmLinkItem ResolveLinkItem(int depender_index, const std::string& name);
// One entry for each unique item.
std::vector<LinkEntry> EntryList;
- std::map<std::string, int> LinkEntryIndex;
+ std::map<cmLinkItem, int> LinkEntryIndex;
// BFS of initial dependencies.
struct BFSEntry
@@ -117,14 +107,15 @@ private:
};
struct DependSetList : public std::vector<DependSet>
{
+ bool Initialized = false;
};
- std::vector<DependSetList*> InferredDependSets;
+ std::vector<DependSetList> InferredDependSets;
void InferDependencies();
// Ordering constraint graph adjacency list.
- typedef cmGraphNodeList NodeList;
- typedef cmGraphEdgeList EdgeList;
- typedef cmGraphAdjacencyList Graph;
+ using NodeList = cmGraphNodeList;
+ using EdgeList = cmGraphEdgeList;
+ using Graph = cmGraphAdjacencyList;
Graph EntryConstraintGraph;
void CleanConstraintGraph();
void DisplayConstraintGraph();
@@ -149,7 +140,7 @@ private:
std::set<int> Entries;
};
std::map<int, PendingComponent> PendingComponents;
- cmComputeComponentGraph* CCG;
+ std::unique_ptr<cmComputeComponentGraph> CCG;
std::vector<int> FinalLinkOrder;
void DisplayComponents();
void VisitComponent(unsigned int c);
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index b2deaaa85..8773d1036 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -2,27 +2,30 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmComputeLinkInformation.h"
+#include <algorithm>
+#include <cctype>
+#include <cstring>
+#include <sstream>
+#include <utility>
+
#include "cmAlgorithms.h"
#include "cmComputeLinkDepends.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
+#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmOrderDirectories.h"
#include "cmOutputConverter.h"
#include "cmPolicies.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmake.h"
-#include <algorithm>
-#include <ctype.h>
-#include <sstream>
-#include <string.h>
-#include <utility>
-
//#define CM_COMPUTE_LINK_INFO_DEBUG
/*
@@ -30,7 +33,7 @@ Notes about linking on various platforms:
------------------------------------------------------------------------------
-Linux, FreeBSD, Mac OS X, IRIX, Sun, Windows:
+Linux, FreeBSD, macOS, Sun, Windows:
Linking to libraries using the full path works fine.
@@ -240,27 +243,24 @@ because this need be done only for shared libraries without soname-s.
cmComputeLinkInformation::cmComputeLinkInformation(
const cmGeneratorTarget* target, const std::string& config)
-{
// Store context information.
- this->Target = target;
- this->Makefile = this->Target->Target->GetMakefile();
- this->GlobalGenerator =
- this->Target->GetLocalGenerator()->GetGlobalGenerator();
- this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
-
+ : Target(target)
+ , Makefile(target->Target->GetMakefile())
+ , GlobalGenerator(target->GetLocalGenerator()->GetGlobalGenerator())
+ , CMakeInstance(this->GlobalGenerator->GetCMakeInstance())
+ // The configuration being linked.
+ , Config(config)
+{
// Check whether to recognize OpenBSD-style library versioned names.
this->OpenBSD = this->Makefile->GetState()->GetGlobalPropertyAsBool(
"FIND_LIBRARY_USE_OPENBSD_VERSIONING");
- // The configuration being linked.
- this->Config = config;
-
// Allocate internals.
this->OrderLinkerSearchPath = new cmOrderDirectories(
this->GlobalGenerator, target, "linker search path");
this->OrderRuntimeSearchPath = new cmOrderDirectories(
this->GlobalGenerator, target, "runtime search path");
- this->OrderDependentRPath = CM_NULLPTR;
+ this->OrderDependentRPath = nullptr;
// Get the language used for linking this target.
this->LinkLanguage = this->Target->GetLinkerLanguage(config);
@@ -270,10 +270,6 @@ cmComputeLinkInformation::cmComputeLinkInformation(
return;
}
- // Check whether we should use an import library for linking a target.
- this->UseImportLibrary =
- this->Makefile->IsDefinitionSet("CMAKE_IMPORT_LIBRARY_SUFFIX");
-
// Check whether we should skip dependencies on shared library files.
this->LinkDependsNoShared =
this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED");
@@ -281,22 +277,36 @@ cmComputeLinkInformation::cmComputeLinkInformation(
// On platforms without import libraries there may be a special flag
// to use when creating a plugin (module) that obtains symbols from
// the program that will load it.
- this->LoaderFlag = CM_NULLPTR;
- if (!this->UseImportLibrary &&
+ this->LoaderFlag = nullptr;
+ if (!this->Target->IsDLLPlatform() &&
this->Target->GetType() == cmStateEnums::MODULE_LIBRARY) {
- std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_";
- loader_flag_var += this->LinkLanguage;
- loader_flag_var += "_FLAG";
+ std::string loader_flag_var =
+ cmStrCat("CMAKE_SHARED_MODULE_LOADER_", this->LinkLanguage, "_FLAG");
this->LoaderFlag = this->Makefile->GetDefinition(loader_flag_var);
}
// Get options needed to link libraries.
- this->LibLinkFlag =
- this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG");
- this->LibLinkFileFlag =
- this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FILE_FLAG");
- this->LibLinkSuffix =
- this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_SUFFIX");
+ if (const char* flag = this->Makefile->GetDefinition(
+ "CMAKE_" + this->LinkLanguage + "_LINK_LIBRARY_FLAG")) {
+ this->LibLinkFlag = flag;
+ } else {
+ this->LibLinkFlag =
+ this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG");
+ }
+ if (const char* flag = this->Makefile->GetDefinition(
+ "CMAKE_" + this->LinkLanguage + "_LINK_LIBRARY_FILE_FLAG")) {
+ this->LibLinkFileFlag = flag;
+ } else {
+ this->LibLinkFileFlag =
+ this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FILE_FLAG");
+ }
+ if (const char* suffix = this->Makefile->GetDefinition(
+ "CMAKE_" + this->LinkLanguage + "_LINK_LIBRARY_SUFFIX")) {
+ this->LibLinkSuffix = suffix;
+ } else {
+ this->LibLinkSuffix =
+ this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_SUFFIX");
+ }
// Get options needed to specify RPATHs.
this->RuntimeUseChrpath = false;
@@ -304,11 +314,8 @@ cmComputeLinkInformation::cmComputeLinkInformation(
const char* tType = ((this->Target->GetType() == cmStateEnums::EXECUTABLE)
? "EXECUTABLE"
: "SHARED_LIBRARY");
- std::string rtVar = "CMAKE_";
- rtVar += tType;
- rtVar += "_RUNTIME_";
- rtVar += this->LinkLanguage;
- rtVar += "_FLAG";
+ std::string rtVar =
+ cmStrCat("CMAKE_", tType, "_RUNTIME_", this->LinkLanguage, "_FLAG");
std::string rtSepVar = rtVar + "_SEP";
this->RuntimeFlag = this->Makefile->GetSafeDefinition(rtVar);
this->RuntimeSep = this->Makefile->GetSafeDefinition(rtSepVar);
@@ -318,19 +325,15 @@ cmComputeLinkInformation::cmComputeLinkInformation(
this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config);
// Get options needed to help find dependent libraries.
- std::string rlVar = "CMAKE_";
- rlVar += tType;
- rlVar += "_RPATH_LINK_";
- rlVar += this->LinkLanguage;
- rlVar += "_FLAG";
+ std::string rlVar =
+ cmStrCat("CMAKE_", tType, "_RPATH_LINK_", this->LinkLanguage, "_FLAG");
this->RPathLinkFlag = this->Makefile->GetSafeDefinition(rlVar);
}
// Check if we need to include the runtime search path at link time.
{
- std::string var = "CMAKE_SHARED_LIBRARY_LINK_";
- var += this->LinkLanguage;
- var += "_WITH_RUNTIME_PATH";
+ std::string var = cmStrCat("CMAKE_SHARED_LIBRARY_LINK_",
+ this->LinkLanguage, "_WITH_RUNTIME_PATH");
this->LinkWithRuntimePath = this->Makefile->IsOn(var);
}
@@ -360,10 +363,10 @@ cmComputeLinkInformation::cmComputeLinkInformation(
}
// Add the search path entries requested by the user to path ordering.
- this->OrderLinkerSearchPath->AddUserDirectories(
- this->Target->GetLinkDirectories());
- this->OrderRuntimeSearchPath->AddUserDirectories(
- this->Target->GetLinkDirectories());
+ std::vector<std::string> directories;
+ this->Target->GetLinkDirectories(directories, config, this->LinkLanguage);
+ this->OrderLinkerSearchPath->AddUserDirectories(directories);
+ this->OrderRuntimeSearchPath->AddUserDirectories(directories);
// Set up the implicit link directories.
this->LoadImplicitLinkInfo();
@@ -390,8 +393,7 @@ cmComputeLinkInformation::cmComputeLinkInformation(
if (this->OldLinkDirMode) {
// Construct a mask to not bother with this behavior for link
// directories already specified by the user.
- std::vector<std::string> const& dirs = this->Target->GetLinkDirectories();
- this->OldLinkDirMask.insert(dirs.begin(), dirs.end());
+ this->OldLinkDirMask.insert(directories.begin(), directories.end());
}
this->CMP0060Warn = this->Makefile->PolicyOptionalWarningEnabled(
@@ -405,18 +407,53 @@ cmComputeLinkInformation::~cmComputeLinkInformation()
delete this->OrderDependentRPath;
}
+void cmComputeLinkInformation::AppendValues(
+ std::string& result, std::vector<BT<std::string>>& values)
+{
+ for (BT<std::string>& p : values) {
+ if (result.empty()) {
+ result.append(" ");
+ }
+
+ result.append(p.Value);
+ }
+}
+
cmComputeLinkInformation::ItemVector const&
-cmComputeLinkInformation::GetItems()
+cmComputeLinkInformation::GetItems() const
{
return this->Items;
}
std::vector<std::string> const& cmComputeLinkInformation::GetDirectories()
+ const
{
return this->OrderLinkerSearchPath->GetOrderedDirectories();
}
-std::string cmComputeLinkInformation::GetRPathLinkString()
+std::vector<BT<std::string>>
+cmComputeLinkInformation::GetDirectoriesWithBacktraces()
+{
+ std::vector<BT<std::string>> directoriesWithBacktraces;
+
+ std::vector<BT<std::string>> targetLinkDirectores =
+ this->Target->GetLinkDirectories(this->Config, this->LinkLanguage);
+
+ const std::vector<std::string>& orderedDirectories = this->GetDirectories();
+ for (const std::string& dir : orderedDirectories) {
+ auto result =
+ std::find(targetLinkDirectores.begin(), targetLinkDirectores.end(), dir);
+ if (result != targetLinkDirectores.end()) {
+ directoriesWithBacktraces.emplace_back(std::move(*result));
+ } else {
+ directoriesWithBacktraces.emplace_back(dir);
+ }
+ }
+
+ return directoriesWithBacktraces;
+}
+
+std::string cmComputeLinkInformation::GetRPathLinkString() const
{
// If there is no separate linker runtime search flag (-rpath-link)
// there is no reason to compute a string.
@@ -424,22 +461,24 @@ std::string cmComputeLinkInformation::GetRPathLinkString()
return "";
}
- // Construct the linker runtime search path.
+ // Construct the linker runtime search path. These MUST NOT contain tokens
+ // such as $ORIGIN, see https://sourceware.org/bugzilla/show_bug.cgi?id=16936
return cmJoin(this->OrderDependentRPath->GetOrderedDirectories(), ":");
}
-std::vector<std::string> const& cmComputeLinkInformation::GetDepends()
+std::vector<std::string> const& cmComputeLinkInformation::GetDepends() const
{
return this->Depends;
}
std::vector<std::string> const& cmComputeLinkInformation::GetFrameworkPaths()
+ const
{
return this->FrameworkPaths;
}
const std::set<const cmGeneratorTarget*>&
-cmComputeLinkInformation::GetSharedLibrariesLinked()
+cmComputeLinkInformation::GetSharedLibrariesLinked() const
{
return this->SharedLibrariesLinked;
}
@@ -457,8 +496,8 @@ bool cmComputeLinkInformation::Compute()
// We require a link language for the target.
if (this->LinkLanguage.empty()) {
cmSystemTools::Error(
- "CMake can not determine linker language for target: ",
- this->Target->GetName().c_str());
+ "CMake can not determine linker language for target: " +
+ this->Target->GetName());
return false;
}
@@ -468,20 +507,18 @@ bool cmComputeLinkInformation::Compute()
cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
// Add the link line items.
- for (cmComputeLinkDepends::EntryVector::const_iterator lei =
- linkEntries.begin();
- lei != linkEntries.end(); ++lei) {
- if (lei->IsSharedDep) {
- this->AddSharedDepItem(lei->Item, lei->Target);
+ for (cmComputeLinkDepends::LinkEntry const& linkEntry : linkEntries) {
+ if (linkEntry.IsSharedDep) {
+ this->AddSharedDepItem(linkEntry.Item, linkEntry.Target);
} else {
- this->AddItem(lei->Item, lei->Target);
+ this->AddItem(linkEntry.Item, linkEntry.Target);
}
}
// Restore the target link type so the correct system runtime
// libraries are found.
const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC");
- if (cmSystemTools::IsOn(lss)) {
+ if (cmIsOn(lss)) {
this->SetCurrentLinkType(LinkStatic);
} else {
this->SetCurrentLinkType(this->StartLinkType);
@@ -494,17 +531,12 @@ bool cmComputeLinkInformation::Compute()
// directories.
std::set<cmGeneratorTarget const*> const& wrongItems =
cld.GetOldWrongConfigItems();
- for (std::set<cmGeneratorTarget const*>::const_iterator i =
- wrongItems.begin();
- i != wrongItems.end(); ++i) {
- cmGeneratorTarget const* tgt = *i;
- bool implib = (this->UseImportLibrary &&
- (tgt->GetType() == cmStateEnums::SHARED_LIBRARY));
- cmStateEnums::ArtifactType artifact = implib
+ for (cmGeneratorTarget const* tgt : wrongItems) {
+ cmStateEnums::ArtifactType artifact = tgt->HasImportLibrary(this->Config)
? cmStateEnums::ImportLibraryArtifact
: cmStateEnums::RuntimeBinaryArtifact;
- std::string lib = tgt->GetFullPath(this->Config, artifact, true);
- this->OldLinkDirItems.push_back(lib);
+ this->OldLinkDirItems.push_back(
+ tgt->GetFullPath(this->Config, artifact, true));
}
}
@@ -528,7 +560,7 @@ bool cmComputeLinkInformation::Compute()
"name."
;
/* clang-format on */
- this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
+ this->CMakeInstance->IssueMessage(MessageType::AUTHOR_WARNING, w.str(),
this->Target->GetBacktrace());
}
@@ -540,11 +572,10 @@ void cmComputeLinkInformation::AddImplicitLinkInfo()
// The link closure lists all languages whose implicit info is needed.
cmGeneratorTarget::LinkClosure const* lc =
this->Target->GetLinkClosure(this->Config);
- for (std::vector<std::string>::const_iterator li = lc->Languages.begin();
- li != lc->Languages.end(); ++li) {
+ for (std::string const& li : lc->Languages) {
// Skip those of the linker language. They are implicit.
- if (*li != this->LinkLanguage) {
- this->AddImplicitLinkInfo(*li);
+ if (li != this->LinkLanguage) {
+ this->AddImplicitLinkInfo(li);
}
}
}
@@ -553,28 +584,21 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
{
// Add libraries for this language that are not implied by the
// linker language.
- std::string libVar = "CMAKE_";
- libVar += lang;
- libVar += "_IMPLICIT_LINK_LIBRARIES";
+ std::string libVar = cmStrCat("CMAKE_", lang, "_IMPLICIT_LINK_LIBRARIES");
if (const char* libs = this->Makefile->GetDefinition(libVar)) {
- std::vector<std::string> libsVec;
- cmSystemTools::ExpandListArgument(libs, libsVec);
- for (std::vector<std::string>::const_iterator i = libsVec.begin();
- i != libsVec.end(); ++i) {
- if (this->ImplicitLinkLibs.find(*i) == this->ImplicitLinkLibs.end()) {
- this->AddItem(*i, CM_NULLPTR);
+ std::vector<std::string> libsVec = cmExpandedList(libs);
+ for (std::string const& i : libsVec) {
+ if (!cmContains(this->ImplicitLinkLibs, i)) {
+ this->AddItem(i, nullptr);
}
}
}
// Add linker search paths for this language that are not
// implied by the linker language.
- std::string dirVar = "CMAKE_";
- dirVar += lang;
- dirVar += "_IMPLICIT_LINK_DIRECTORIES";
+ std::string dirVar = cmStrCat("CMAKE_", lang, "_IMPLICIT_LINK_DIRECTORIES");
if (const char* dirs = this->Makefile->GetDefinition(dirVar)) {
- std::vector<std::string> dirsVec;
- cmSystemTools::ExpandListArgument(dirs, dirsVec);
+ std::vector<std::string> dirsVec = cmExpandedList(dirs);
this->OrderLinkerSearchPath->AddLanguageDirectories(dirsVec);
}
}
@@ -585,7 +609,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
// Compute the proper name to use to link this library.
const std::string& config = this->Config;
bool impexe = (tgt && tgt->IsExecutableWithExports());
- if (impexe && !this->UseImportLibrary && !this->LoaderFlag) {
+ if (impexe && !tgt->HasImportLibrary(config) && !this->LoaderFlag) {
// Skip linking to executables on platforms with no import
// libraries or loader flags.
return;
@@ -599,36 +623,45 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
// platform. Add it now.
std::string linkItem;
linkItem = this->LoaderFlag;
- cmStateEnums::ArtifactType artifact = this->UseImportLibrary
+ cmStateEnums::ArtifactType artifact = tgt->HasImportLibrary(config)
? cmStateEnums::ImportLibraryArtifact
: cmStateEnums::RuntimeBinaryArtifact;
std::string exe = tgt->GetFullPath(config, artifact, true);
linkItem += exe;
- this->Items.push_back(Item(linkItem, true, tgt));
- this->Depends.push_back(exe);
+ this->Items.emplace_back(linkItem, true, tgt);
+ this->Depends.push_back(std::move(exe));
} else if (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
// Add the interface library as an item so it can be considered as part
// of COMPATIBLE_INTERFACE_ enforcement. The generators will ignore
// this for the actual link line.
- this->Items.push_back(Item(std::string(), false, tgt));
+ this->Items.emplace_back(std::string(), false, tgt);
// Also add the item the interface specifies to be used in its place.
std::string const& libName = tgt->GetImportedLibName(config);
if (!libName.empty()) {
- this->AddItem(libName, CM_NULLPTR);
+ this->AddItem(libName, nullptr);
}
+ } else if (tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
+ // Ignore object library!
+ // Its object-files should already have been extracted for linking.
} else {
// Decide whether to use an import library.
- bool implib =
- (this->UseImportLibrary &&
- (impexe || tgt->GetType() == cmStateEnums::SHARED_LIBRARY));
- cmStateEnums::ArtifactType artifact = implib
+ cmStateEnums::ArtifactType artifact = tgt->HasImportLibrary(config)
? cmStateEnums::ImportLibraryArtifact
: cmStateEnums::RuntimeBinaryArtifact;
// Pass the full path to the target file.
std::string lib = tgt->GetFullPath(config, artifact, true);
+ if (tgt->Target->IsAIX() && cmHasLiteralSuffix(lib, "-NOTFOUND") &&
+ artifact == cmStateEnums::ImportLibraryArtifact) {
+ // This is an imported executable on AIX that has ENABLE_EXPORTS
+ // but not IMPORTED_IMPLIB. CMake used to produce and accept such
+ // imported executables on AIX before we taught it to use linker
+ // import files. For compatibility, simply skip linking to this
+ // executable as we did before. It works with runtime linking.
+ return;
+ }
if (!this->LinkDependsNoShared ||
tgt->GetType() != cmStateEnums::SHARED_LIBRARY) {
this->Depends.push_back(lib);
@@ -639,7 +672,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
}
} else {
// This is not a CMake target. Use the name given.
- if (cmSystemTools::FileIsFullPath(item.c_str())) {
+ if (cmSystemTools::FileIsFullPath(item)) {
if (cmSystemTools::FileIsDirectory(item)) {
// This is a directory.
this->AddDirectoryItem(item);
@@ -675,13 +708,13 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
} else {
// Skip items that are not full paths. We will not be able to
// reliably specify them.
- if (!cmSystemTools::FileIsFullPath(item.c_str())) {
+ if (!cmSystemTools::FileIsFullPath(item)) {
return;
}
// Get the name of the library from the file name.
std::string file = cmSystemTools::GetFilenameName(item);
- if (!this->ExtractSharedLibraryName.find(file.c_str())) {
+ if (!this->ExtractSharedLibraryName.find(file)) {
// This is not the name of a shared library.
return;
}
@@ -698,7 +731,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
// linked will be able to find it.
std::string lib;
if (tgt) {
- cmStateEnums::ArtifactType artifact = this->UseImportLibrary
+ cmStateEnums::ArtifactType artifact = tgt->HasImportLibrary(this->Config)
? cmStateEnums::ImportLibraryArtifact
: cmStateEnums::RuntimeBinaryArtifact;
lib = tgt->GetFullPath(this->Config, artifact);
@@ -710,7 +743,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
// Check if we need to include the dependent shared library in other
// path ordering.
- cmOrderDirectories* order = CM_NULLPTR;
+ cmOrderDirectories* order = nullptr;
if (this->SharedDependencyMode == SharedDepModeLibDir &&
!this->LinkWithRuntimePath /* AddLibraryRuntimeInfo adds it */) {
// Add the item to the linker search path.
@@ -722,7 +755,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
if (order) {
if (tgt) {
std::string soName = tgt->GetSOName(this->Config);
- const char* soname = soName.empty() ? CM_NULLPTR : soName.c_str();
+ const char* soname = soName.empty() ? nullptr : soName.c_str();
order->AddRuntimeLibrary(lib, soname);
} else {
order->AddRuntimeLibrary(lib);
@@ -741,9 +774,9 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
this->LinkTypeEnabled = false;
// Lookup link type selection flags.
- const char* static_link_type_flag = CM_NULLPTR;
- const char* shared_link_type_flag = CM_NULLPTR;
- const char* target_type_str = CM_NULLPTR;
+ const char* static_link_type_flag = nullptr;
+ const char* shared_link_type_flag = nullptr;
+ const char* target_type_str = nullptr;
switch (this->Target->GetType()) {
case cmStateEnums::EXECUTABLE:
target_type_str = "EXE";
@@ -758,19 +791,15 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
break;
}
if (target_type_str) {
- std::string static_link_type_flag_var = "CMAKE_";
- static_link_type_flag_var += target_type_str;
- static_link_type_flag_var += "_LINK_STATIC_";
- static_link_type_flag_var += this->LinkLanguage;
- static_link_type_flag_var += "_FLAGS";
+ std::string static_link_type_flag_var =
+ cmStrCat("CMAKE_", target_type_str, "_LINK_STATIC_", this->LinkLanguage,
+ "_FLAGS");
static_link_type_flag =
this->Makefile->GetDefinition(static_link_type_flag_var);
- std::string shared_link_type_flag_var = "CMAKE_";
- shared_link_type_flag_var += target_type_str;
- shared_link_type_flag_var += "_LINK_DYNAMIC_";
- shared_link_type_flag_var += this->LinkLanguage;
- shared_link_type_flag_var += "_FLAGS";
+ std::string shared_link_type_flag_var =
+ cmStrCat("CMAKE_", target_type_str, "_LINK_DYNAMIC_", this->LinkLanguage,
+ "_FLAGS");
shared_link_type_flag =
this->Makefile->GetDefinition(shared_link_type_flag_var);
}
@@ -786,7 +815,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
// Lookup the starting link type from the target (linked statically?).
const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC");
- this->StartLinkType = cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared;
+ this->StartLinkType = cmIsOn(lss) ? LinkStatic : LinkShared;
this->CurrentLinkType = this->StartLinkType;
}
@@ -809,20 +838,16 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
LinkUnknown);
if (const char* linkSuffixes =
mf->GetDefinition("CMAKE_EXTRA_LINK_EXTENSIONS")) {
- std::vector<std::string> linkSuffixVec;
- cmSystemTools::ExpandListArgument(linkSuffixes, linkSuffixVec);
- for (std::vector<std::string>::iterator i = linkSuffixVec.begin();
- i != linkSuffixVec.end(); ++i) {
- this->AddLinkExtension(i->c_str(), LinkUnknown);
+ std::vector<std::string> linkSuffixVec = cmExpandedList(linkSuffixes);
+ for (std::string const& i : linkSuffixVec) {
+ this->AddLinkExtension(i.c_str(), LinkUnknown);
}
}
if (const char* sharedSuffixes =
mf->GetDefinition("CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES")) {
- std::vector<std::string> sharedSuffixVec;
- cmSystemTools::ExpandListArgument(sharedSuffixes, sharedSuffixVec);
- for (std::vector<std::string>::iterator i = sharedSuffixVec.begin();
- i != sharedSuffixVec.end(); ++i) {
- this->AddLinkExtension(i->c_str(), LinkShared);
+ std::vector<std::string> sharedSuffixVec = cmExpandedList(sharedSuffixes);
+ for (std::string const& i : sharedSuffixVec) {
+ this->AddLinkExtension(i.c_str(), LinkShared);
}
}
@@ -840,17 +865,15 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
// be the library name. Match index 3 will be the library
// extension.
reg = "^(";
- for (std::set<std::string>::iterator p = this->LinkPrefixes.begin();
- p != this->LinkPrefixes.end(); ++p) {
- reg += *p;
+ for (std::string const& p : this->LinkPrefixes) {
+ reg += p;
reg += "|";
}
reg += ")";
reg += "([^/:]*)";
// Create a regex to match any library name.
- std::string reg_any = reg;
- reg_any += libext;
+ std::string reg_any = cmStrCat(reg, libext);
#ifdef CM_COMPUTE_LINK_INFO_DEBUG
fprintf(stderr, "any regex [%s]\n", reg_any.c_str());
#endif
@@ -858,9 +881,8 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
// Create a regex to match static library names.
if (!this->StaticLinkExtensions.empty()) {
- std::string reg_static = reg;
- reg_static +=
- this->CreateExtensionRegex(this->StaticLinkExtensions, LinkStatic);
+ std::string reg_static = cmStrCat(
+ reg, this->CreateExtensionRegex(this->StaticLinkExtensions, LinkStatic));
#ifdef CM_COMPUTE_LINK_INFO_DEBUG
fprintf(stderr, "static regex [%s]\n", reg_static.c_str());
#endif
@@ -891,12 +913,12 @@ void cmComputeLinkInformation::AddLinkExtension(const char* e, LinkType type)
{
if (e && *e) {
if (type == LinkStatic) {
- this->StaticLinkExtensions.push_back(e);
+ this->StaticLinkExtensions.emplace_back(e);
}
if (type == LinkShared) {
- this->SharedLinkExtensions.push_back(e);
+ this->SharedLinkExtensions.emplace_back(e);
}
- this->LinkExtensions.push_back(e);
+ this->LinkExtensions.emplace_back(e);
}
}
@@ -906,8 +928,7 @@ std::string cmComputeLinkInformation::CreateExtensionRegex(
// Build a list of extension choices.
std::string libext = "(";
const char* sep = "";
- for (std::vector<std::string>::const_iterator i = exts.begin();
- i != exts.end(); ++i) {
+ for (std::string const& i : exts) {
// Separate this choice from the previous one.
libext += sep;
sep = "|";
@@ -915,20 +936,18 @@ std::string cmComputeLinkInformation::CreateExtensionRegex(
// Store this extension choice with the "." escaped.
libext += "\\";
#if defined(_WIN32) && !defined(__CYGWIN__)
- libext += this->NoCaseExpression(i->c_str());
+ libext += this->NoCaseExpression(i.c_str());
#else
- libext += *i;
+ libext += i;
#endif
}
// Finish the list.
libext += ")";
- // Add an optional OpenBSD version component.
- if (this->OpenBSD) {
- libext += "(\\.[0-9]+\\.[0-9]+)?";
- } else if (type == LinkShared) {
- libext += "(\\.[0-9]+)?";
+ // Add an optional OpenBSD-style version or major.minor.version component.
+ if (this->OpenBSD || type == LinkShared) {
+ libext += "(\\.[0-9]+)*";
}
libext += "$";
@@ -963,10 +982,10 @@ void cmComputeLinkInformation::SetCurrentLinkType(LinkType lt)
if (this->LinkTypeEnabled) {
switch (this->CurrentLinkType) {
case LinkStatic:
- this->Items.push_back(Item(this->StaticLinkTypeFlag, false));
+ this->Items.emplace_back(this->StaticLinkTypeFlag, false);
break;
case LinkShared:
- this->Items.push_back(Item(this->SharedLinkTypeFlag, false));
+ this->Items.emplace_back(this->SharedLinkTypeFlag, false);
break;
default:
break;
@@ -1000,21 +1019,16 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item,
return;
}
- // If this platform wants a flag before the full path, add it.
- if (!this->LibLinkFileFlag.empty()) {
- this->Items.push_back(Item(this->LibLinkFileFlag, false));
- }
-
// For compatibility with CMake 2.4 include the item's directory in
// the linker search path.
if (this->OldLinkDirMode && !target->IsFrameworkOnApple() &&
- this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
- this->OldLinkDirMask.end()) {
+ !cmContains(this->OldLinkDirMask,
+ cmSystemTools::GetFilenamePath(item))) {
this->OldLinkDirItems.push_back(item);
}
// Now add the full path to the library.
- this->Items.push_back(Item(item, true, target));
+ this->Items.emplace_back(item, true, target);
}
void cmComputeLinkInformation::AddFullItem(std::string const& item)
@@ -1036,7 +1050,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item)
(generator.find("Visual Studio") != std::string::npos ||
generator.find("Xcode") != std::string::npos)) {
std::string file = cmSystemTools::GetFilenameName(item);
- if (!this->ExtractAnyLibraryName.find(file.c_str())) {
+ if (!this->ExtractAnyLibraryName.find(file)) {
this->HandleBadFullItem(item, file);
return;
}
@@ -1062,18 +1076,13 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item)
// For compatibility with CMake 2.4 include the item's directory in
// the linker search path.
if (this->OldLinkDirMode &&
- this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
- this->OldLinkDirMask.end()) {
+ !cmContains(this->OldLinkDirMask,
+ cmSystemTools::GetFilenamePath(item))) {
this->OldLinkDirItems.push_back(item);
}
- // If this platform wants a flag before the full path, add it.
- if (!this->LibLinkFileFlag.empty()) {
- this->Items.push_back(Item(this->LibLinkFileFlag, false));
- }
-
// Now add the full path to the library.
- this->Items.push_back(Item(item, true));
+ this->Items.emplace_back(item, true);
}
bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)
@@ -1087,7 +1096,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)
// Check if this item is in an implicit link directory.
std::string dir = cmSystemTools::GetFilenamePath(item);
- if (this->ImplicitLinkDirs.find(dir) == this->ImplicitLinkDirs.end()) {
+ if (!cmContains(this->ImplicitLinkDirs, dir)) {
// Only libraries in implicit link directories are converted to
// pathless items.
return false;
@@ -1160,7 +1169,7 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
this->SetCurrentLinkType(this->StartLinkType);
// Use the item verbatim.
- this->Items.push_back(Item(item, false));
+ this->Items.emplace_back(item, false);
return;
}
@@ -1229,10 +1238,8 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
}
// Create an option to ask the linker to search for the library.
- std::string out = this->LibLinkFlag;
- out += lib;
- out += this->LibLinkSuffix;
- this->Items.push_back(Item(out, false));
+ std::string out = cmStrCat(this->LibLinkFlag, lib, this->LibLinkSuffix);
+ this->Items.emplace_back(out, false);
// Here we could try to find the library the linker will find and
// add a runtime information entry for it. It would probably not be
@@ -1243,22 +1250,17 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item,
void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
{
// Try to separate the framework name and path.
- if (!this->SplitFramework.find(item.c_str())) {
+ if (!this->SplitFramework.find(item)) {
std::ostringstream e;
e << "Could not parse framework path \"" << item << "\" "
<< "linked by target " << this->Target->GetName() << ".";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return;
}
std::string fw_path = this->SplitFramework.match(1);
std::string fw = this->SplitFramework.match(2);
- std::string full_fw = fw_path;
- full_fw += "/";
- full_fw += fw;
- full_fw += ".framework";
- full_fw += "/";
- full_fw += fw;
+ std::string full_fw = cmStrCat(fw_path, '/', fw, ".framework/", fw);
// Add the directory portion to the framework search path.
this->AddFrameworkPath(fw_path);
@@ -1267,16 +1269,16 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
this->AddLibraryRuntimeInfo(full_fw);
// Add the item using the -framework option.
- this->Items.push_back(Item("-framework", false));
+ this->Items.emplace_back("-framework", false);
cmOutputConverter converter(this->Makefile->GetStateSnapshot());
fw = converter.EscapeForShell(fw);
- this->Items.push_back(Item(fw, false));
+ this->Items.emplace_back(fw, false);
}
void cmComputeLinkInformation::AddDirectoryItem(std::string const& item)
{
if (this->Makefile->IsOn("APPLE") &&
- cmSystemTools::IsPathToFramework(item.c_str())) {
+ cmSystemTools::IsPathToFramework(item)) {
this->AddFrameworkItem(item);
} else {
this->DropDirectoryItem(item);
@@ -1292,7 +1294,7 @@ void cmComputeLinkInformation::DropDirectoryItem(std::string const& item)
<< "\" requests linking to directory \"" << item << "\". "
<< "Targets may link only to libraries. "
<< "CMake is dropping the item.";
- cmSystemTools::Message(e.str().c_str());
+ cmSystemTools::Message(e.str());
}
void cmComputeLinkInformation::ComputeFrameworkInfo()
@@ -1303,16 +1305,15 @@ void cmComputeLinkInformation::ComputeFrameworkInfo()
// Get platform-wide implicit directories.
if (const char* implicitLinks = this->Makefile->GetDefinition(
"CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES")) {
- cmSystemTools::ExpandListArgument(implicitLinks, implicitDirVec);
+ cmExpandList(implicitLinks, implicitDirVec);
}
// Get language-specific implicit directories.
- std::string implicitDirVar = "CMAKE_";
- implicitDirVar += this->LinkLanguage;
- implicitDirVar += "_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES";
+ std::string implicitDirVar = cmStrCat(
+ "CMAKE_", this->LinkLanguage, "_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES");
if (const char* implicitDirs =
this->Makefile->GetDefinition(implicitDirVar)) {
- cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec);
+ cmExpandList(implicitDirs, implicitDirVec);
}
this->FrameworkPathsEmmitted.insert(implicitDirVec.begin(),
@@ -1366,8 +1367,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
std::string const& file)
{
// Do not depend on things that do not exist.
- std::vector<std::string>::iterator i =
- std::find(this->Depends.begin(), this->Depends.end(), item);
+ auto i = std::find(this->Depends.begin(), this->Depends.end(), item);
if (i != this->Depends.end()) {
this->Depends.erase(i);
}
@@ -1382,8 +1382,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
switch (this->Target->GetPolicyStatusCMP0008()) {
case cmPolicies::WARN: {
// Print the warning at most once for this item.
- std::string wid = "CMP0008-WARNING-GIVEN-";
- wid += item;
+ std::string wid = cmStrCat("CMP0008-WARNING-GIVEN-", item);
if (!this->CMakeInstance->GetState()->GetGlobalPropertyAsBool(wid)) {
this->CMakeInstance->GetState()->SetGlobalProperty(wid, "1");
std::ostringstream w;
@@ -1393,7 +1392,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
<< " " << item << "\n"
<< "which is a full-path but not a valid library file name.";
/* clang-format on */
- this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
+ this->CMakeInstance->IssueMessage(MessageType::AUTHOR_WARNING, w.str(),
this->Target->GetBacktrace());
}
}
@@ -1412,7 +1411,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
<< " " << item << "\n"
<< "which is a full-path but not a valid library file name.";
/* clang-format on */
- this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ this->CMakeInstance->IssueMessage(MessageType::FATAL_ERROR, e.str(),
this->Target->GetBacktrace());
} break;
}
@@ -1435,7 +1434,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
"CMP0003-WARNING-GIVEN", "1");
std::ostringstream w;
this->PrintLinkPolicyDiagnosis(w);
- this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
+ this->CMakeInstance->IssueMessage(MessageType::AUTHOR_WARNING, w.str(),
this->Target->GetBacktrace());
}
case cmPolicies::OLD:
@@ -1450,17 +1449,15 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
std::ostringstream e;
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n";
this->PrintLinkPolicyDiagnosis(e);
- this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ this->CMakeInstance->IssueMessage(MessageType::FATAL_ERROR, e.str(),
this->Target->GetBacktrace());
return false;
}
}
// Add the link directories for full path items.
- for (std::vector<std::string>::const_iterator i =
- this->OldLinkDirItems.begin();
- i != this->OldLinkDirItems.end(); ++i) {
- this->OrderLinkerSearchPath->AddLinkLibrary(*i);
+ for (std::string const& i : this->OldLinkDirItems) {
+ this->OrderLinkerSearchPath->AddLinkLibrary(i);
}
return true;
}
@@ -1489,19 +1486,17 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
std::string::size_type max_size = 76;
std::string line;
const char* sep = " ";
- for (std::vector<std::string>::const_iterator i =
- this->OldUserFlagItems.begin();
- i != this->OldUserFlagItems.end(); ++i) {
+ for (std::string const& i : this->OldUserFlagItems) {
// If the addition of another item will exceed the limit then
// output the current line and reset it. Note that the separator
// is either " " or ", " which is always 2 characters.
- if (!line.empty() && (line.size() + i->size() + 2) > max_size) {
+ if (!line.empty() && (line.size() + i.size() + 2) > max_size) {
os << line << "\n";
sep = " ";
- line = "";
+ line.clear();
}
line += sep;
- line += *i;
+ line += i;
// Convert to the other separator.
sep = ", ";
}
@@ -1513,11 +1508,9 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
// List the paths old behavior is adding.
os << "and other libraries with known full path:\n";
std::set<std::string> emitted;
- for (std::vector<std::string>::const_iterator i =
- this->OldLinkDirItems.begin();
- i != this->OldLinkDirItems.end(); ++i) {
- if (emitted.insert(cmSystemTools::GetFilenamePath(*i)).second) {
- os << " " << *i << "\n";
+ for (std::string const& i : this->OldLinkDirItems) {
+ if (emitted.insert(cmSystemTools::GetFilenamePath(i)).second) {
+ os << " " << i << "\n";
}
}
@@ -1537,26 +1530,24 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo()
// Get platform-wide implicit directories.
if (const char* implicitLinks = (this->Makefile->GetDefinition(
"CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES"))) {
- cmSystemTools::ExpandListArgument(implicitLinks, implicitDirVec);
+ cmExpandList(implicitLinks, implicitDirVec);
}
// Append library architecture to all implicit platform directories
// and add them to the set
if (const char* libraryArch =
this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) {
- for (std::vector<std::string>::const_iterator i = implicitDirVec.begin();
- i != implicitDirVec.end(); ++i) {
- this->ImplicitLinkDirs.insert(*i + "/" + libraryArch);
+ for (std::string const& i : implicitDirVec) {
+ this->ImplicitLinkDirs.insert(i + "/" + libraryArch);
}
}
// Get language-specific implicit directories.
- std::string implicitDirVar = "CMAKE_";
- implicitDirVar += this->LinkLanguage;
- implicitDirVar += "_IMPLICIT_LINK_DIRECTORIES";
+ std::string implicitDirVar =
+ cmStrCat("CMAKE_", this->LinkLanguage, "_IMPLICIT_LINK_DIRECTORIES");
if (const char* implicitDirs =
this->Makefile->GetDefinition(implicitDirVar)) {
- cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec);
+ cmExpandList(implicitDirs, implicitDirVec);
}
// Store implicit link directories.
@@ -1564,20 +1555,17 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo()
// Get language-specific implicit libraries.
std::vector<std::string> implicitLibVec;
- std::string implicitLibVar = "CMAKE_";
- implicitLibVar += this->LinkLanguage;
- implicitLibVar += "_IMPLICIT_LINK_LIBRARIES";
+ std::string implicitLibVar =
+ cmStrCat("CMAKE_", this->LinkLanguage, "_IMPLICIT_LINK_LIBRARIES");
if (const char* implicitLibs =
this->Makefile->GetDefinition(implicitLibVar)) {
- cmSystemTools::ExpandListArgument(implicitLibs, implicitLibVec);
+ cmExpandList(implicitLibs, implicitLibVec);
}
// Store implicit link libraries.
- for (std::vector<std::string>::const_iterator i = implicitLibVec.begin();
- i != implicitLibVec.end(); ++i) {
+ for (std::string const& item : implicitLibVec) {
// Items starting in '-' but not '-l' are flags, not libraries,
// and should not be filtered by this implicit list.
- std::string const& item = *i;
if (item[0] != '-' || item[1] == 'l') {
this->ImplicitLinkLibs.insert(item);
}
@@ -1586,12 +1574,12 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo()
// Get platform specific rpath link directories
if (const char* rpathDirs =
(this->Makefile->GetDefinition("CMAKE_PLATFORM_RUNTIME_PATH"))) {
- cmSystemTools::ExpandListArgument(rpathDirs, this->RuntimeLinkDirs);
+ cmExpandList(rpathDirs, this->RuntimeLinkDirs);
}
}
std::vector<std::string> const&
-cmComputeLinkInformation::GetRuntimeSearchPath()
+cmComputeLinkInformation::GetRuntimeSearchPath() const
{
return this->OrderRuntimeSearchPath->GetOrderedDirectories();
}
@@ -1623,7 +1611,7 @@ void cmComputeLinkInformation::AddLibraryRuntimeInfo(
// Try to get the soname of the library. Only files with this name
// could possibly conflict.
std::string soName = target->GetSOName(this->Config);
- const char* soname = soName.empty() ? CM_NULLPTR : soName.c_str();
+ const char* soname = soName.empty() ? nullptr : soName.c_str();
// Include this library in the runtime path ordering.
this->OrderRuntimeSearchPath->AddRuntimeLibrary(fullPath, soname);
@@ -1657,7 +1645,7 @@ void cmComputeLinkInformation::AddLibraryRuntimeInfo(
if (!is_shared_library) {
// On some platforms (AIX) a shared library may look static.
if (this->ArchivesMayBeShared) {
- if (this->ExtractStaticLibraryName.find(file.c_str())) {
+ if (this->ExtractStaticLibraryName.find(file)) {
// This is the name of a shared library or archive.
is_shared_library = true;
}
@@ -1692,18 +1680,16 @@ static void cmCLI_ExpandListUnique(const char* str,
std::vector<std::string>& out,
std::set<std::string>& emitted)
{
- std::vector<std::string> tmp;
- cmSystemTools::ExpandListArgument(str, tmp);
- for (std::vector<std::string>::iterator i = tmp.begin(); i != tmp.end();
- ++i) {
- if (emitted.insert(*i).second) {
- out.push_back(*i);
+ std::vector<std::string> tmp = cmExpandedList(str);
+ for (std::string const& i : tmp) {
+ if (emitted.insert(i).second) {
+ out.push_back(i);
}
}
}
void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
- bool for_install)
+ bool for_install) const
{
// Select whether to generate runtime search directories.
bool outputRuntime =
@@ -1715,7 +1701,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
(for_install ||
this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"));
bool use_install_rpath =
- (outputRuntime && this->Target->HaveInstallTreeRPATH() &&
+ (outputRuntime && this->Target->HaveInstallTreeRPATH(this->Config) &&
linking_for_install);
bool use_build_rpath =
(outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) &&
@@ -1724,16 +1710,28 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
!this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") &&
this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH");
+ // Select whether to use $ORIGIN in RPATHs for artifacts in the build tree.
+ std::string const& originToken = this->Makefile->GetSafeDefinition(
+ "CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN");
+ std::string targetOutputDir = this->Target->GetDirectory(this->Config);
+ bool use_relative_build_rpath =
+ this->Target->GetPropertyAsBool("BUILD_RPATH_USE_ORIGIN") &&
+ !originToken.empty() && !targetOutputDir.empty();
+
// Construct the RPATH.
std::set<std::string> emitted;
if (use_install_rpath) {
- const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH");
- cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted);
+ std::string install_rpath;
+ this->Target->GetInstallRPATH(this->Config, install_rpath);
+ cmCLI_ExpandListUnique(install_rpath.c_str(), runtimeDirs, emitted);
}
if (use_build_rpath) {
// Add directories explicitly specified by user
- if (const char* build_rpath = this->Target->GetProperty("BUILD_RPATH")) {
- cmCLI_ExpandListUnique(build_rpath, runtimeDirs, emitted);
+ std::string build_rpath;
+ if (this->Target->GetBuildRPATH(this->Config, build_rpath)) {
+ // This will not resolve entries to use $ORIGIN, the user is expected to
+ // do that if necessary.
+ cmCLI_ExpandListUnique(build_rpath.c_str(), runtimeDirs, emitted);
}
}
if (use_build_rpath || use_link_rpath) {
@@ -1746,49 +1744,57 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
}
const char* stagePath =
this->Makefile->GetDefinition("CMAKE_STAGING_PREFIX");
- const char* installPrefix =
+ std::string const& installPrefix =
this->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
cmSystemTools::ConvertToUnixSlashes(rootPath);
std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath();
- for (std::vector<std::string>::const_iterator ri = rdirs.begin();
- ri != rdirs.end(); ++ri) {
+ std::string const& topBinaryDir =
+ this->CMakeInstance->GetHomeOutputDirectory();
+ for (std::string const& ri : rdirs) {
// Put this directory in the rpath if using build-tree rpath
// support or if using the link path as an rpath.
if (use_build_rpath) {
- std::string d = *ri;
+ std::string d = ri;
if (!rootPath.empty() && d.find(rootPath) == 0) {
d = d.substr(rootPath.size());
} else if (stagePath && *stagePath && d.find(stagePath) == 0) {
std::string suffix = d.substr(strlen(stagePath));
- d = installPrefix;
- d += "/";
- d += suffix;
+ d = cmStrCat(installPrefix, '/', suffix);
cmSystemTools::ConvertToUnixSlashes(d);
+ } else if (use_relative_build_rpath) {
+ // If expansion of the $ORIGIN token is supported and permitted per
+ // policy, use relative paths in the RPATH.
+ if (cmSystemTools::ComparePath(d, topBinaryDir) ||
+ cmSystemTools::IsSubDirectory(d, topBinaryDir)) {
+ d = cmSystemTools::RelativePath(targetOutputDir, d);
+ if (!d.empty()) {
+ d = cmStrCat(originToken, "/", d);
+ } else {
+ d = originToken;
+ }
+ }
}
if (emitted.insert(d).second) {
- runtimeDirs.push_back(d);
+ runtimeDirs.push_back(std::move(d));
}
} else if (use_link_rpath) {
// Do not add any path inside the source or build tree.
- const char* topSourceDir = this->CMakeInstance->GetHomeDirectory();
- const char* topBinaryDir =
- this->CMakeInstance->GetHomeOutputDirectory();
- if (!cmSystemTools::ComparePath(*ri, topSourceDir) &&
- !cmSystemTools::ComparePath(*ri, topBinaryDir) &&
- !cmSystemTools::IsSubDirectory(*ri, topSourceDir) &&
- !cmSystemTools::IsSubDirectory(*ri, topBinaryDir)) {
- std::string d = *ri;
+ std::string const& topSourceDir =
+ this->CMakeInstance->GetHomeDirectory();
+ if (!cmSystemTools::ComparePath(ri, topSourceDir) &&
+ !cmSystemTools::ComparePath(ri, topBinaryDir) &&
+ !cmSystemTools::IsSubDirectory(ri, topSourceDir) &&
+ !cmSystemTools::IsSubDirectory(ri, topBinaryDir)) {
+ std::string d = ri;
if (!rootPath.empty() && d.find(rootPath) == 0) {
d = d.substr(rootPath.size());
} else if (stagePath && *stagePath && d.find(stagePath) == 0) {
std::string suffix = d.substr(strlen(stagePath));
- d = installPrefix;
- d += "/";
- d += suffix;
+ d = cmStrCat(installPrefix, '/', suffix);
cmSystemTools::ConvertToUnixSlashes(d);
}
if (emitted.insert(d).second) {
- runtimeDirs.push_back(d);
+ runtimeDirs.push_back(std::move(d));
}
}
}
@@ -1800,12 +1806,11 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
{
cmGeneratorTarget::LinkClosure const* lc =
this->Target->GetLinkClosure(this->Config);
- for (std::vector<std::string>::const_iterator li = lc->Languages.begin();
- li != lc->Languages.end(); ++li) {
+ for (std::string const& li : lc->Languages) {
std::string useVar =
- "CMAKE_" + *li + "_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH";
+ "CMAKE_" + li + "_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH";
if (this->Makefile->IsOn(useVar)) {
- std::string dirVar = "CMAKE_" + *li + "_IMPLICIT_LINK_DIRECTORIES";
+ std::string dirVar = "CMAKE_" + li + "_IMPLICIT_LINK_DIRECTORIES";
if (const char* dirs = this->Makefile->GetDefinition(dirVar)) {
cmCLI_ExpandListUnique(dirs, runtimeDirs, emitted);
}
@@ -1818,7 +1823,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
cmCLI_ExpandListUnique(this->RuntimeAlways.c_str(), runtimeDirs, emitted);
}
-std::string cmComputeLinkInformation::GetRPathString(bool for_install)
+std::string cmComputeLinkInformation::GetRPathString(bool for_install) const
{
// Get the directories to use.
std::vector<std::string> runtimeDirs;
@@ -1846,7 +1851,7 @@ std::string cmComputeLinkInformation::GetRPathString(bool for_install)
return rpath;
}
-std::string cmComputeLinkInformation::GetChrpathString()
+std::string cmComputeLinkInformation::GetChrpathString() const
{
if (!this->RuntimeUseChrpath) {
return "";
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 00e3ad265..92ab83b3b 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -5,17 +5,21 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmsys/RegularExpression.hxx"
#include <iosfwd>
#include <set>
#include <string>
+#include <utility>
#include <vector>
+#include "cmsys/RegularExpression.hxx"
+
class cmGeneratorTarget;
class cmGlobalGenerator;
class cmMakefile;
class cmOrderDirectories;
class cmake;
+template <typename T>
+class BT;
/** \class cmComputeLinkInformation
* \brief Compute link information for a target in one configuration.
@@ -30,41 +34,45 @@ public:
struct Item
{
- Item()
- : Value()
- , IsPath(true)
- , Target(CM_NULLPTR)
- {
- }
- Item(std::string const& v, bool p,
- cmGeneratorTarget const* target = CM_NULLPTR)
- : Value(v)
+ Item() = default;
+ Item(std::string v, bool p, cmGeneratorTarget const* target = nullptr)
+ : Value(std::move(v))
, IsPath(p)
, Target(target)
{
}
std::string Value;
- bool IsPath;
- cmGeneratorTarget const* Target;
+ bool IsPath = true;
+ cmGeneratorTarget const* Target = nullptr;
};
- typedef std::vector<Item> ItemVector;
- ItemVector const& GetItems();
- std::vector<std::string> const& GetDirectories();
- std::vector<std::string> const& GetDepends();
- std::vector<std::string> const& GetFrameworkPaths();
+ using ItemVector = std::vector<Item>;
+ void AppendValues(std::string& result, std::vector<BT<std::string>>& values);
+ ItemVector const& GetItems() const;
+ std::vector<std::string> const& GetDirectories() const;
+ std::vector<BT<std::string>> GetDirectoriesWithBacktraces();
+ std::vector<std::string> const& GetDepends() const;
+ std::vector<std::string> const& GetFrameworkPaths() const;
std::string GetLinkLanguage() const { return this->LinkLanguage; }
- std::vector<std::string> const& GetRuntimeSearchPath();
+ std::vector<std::string> const& GetRuntimeSearchPath() const;
std::string const& GetRuntimeFlag() const { return this->RuntimeFlag; }
std::string const& GetRuntimeSep() const { return this->RuntimeSep; }
- void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install);
- std::string GetRPathString(bool for_install);
- std::string GetChrpathString();
- std::set<cmGeneratorTarget const*> const& GetSharedLibrariesLinked();
+ void GetRPath(std::vector<std::string>& runtimeDirs, bool for_install) const;
+ std::string GetRPathString(bool for_install) const;
+ std::string GetChrpathString() const;
+ std::set<cmGeneratorTarget const*> const& GetSharedLibrariesLinked() const;
+
+ std::string const& GetLibLinkFileFlag() const
+ {
+ return this->LibLinkFileFlag;
+ }
std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
- std::string GetRPathLinkString();
+ std::string GetRPathLinkString() const;
std::string GetConfig() const { return this->Config; }
+
+ const cmGeneratorTarget* GetTarget() { return this->Target; }
+
private:
void AddItem(std::string const& item, const cmGeneratorTarget* tgt);
void AddSharedDepItem(std::string const& item, cmGeneratorTarget const* tgt);
@@ -78,13 +86,13 @@ private:
std::set<cmGeneratorTarget const*> SharedLibrariesLinked;
// Context information.
- cmGeneratorTarget const* Target;
- cmMakefile* Makefile;
- cmGlobalGenerator* GlobalGenerator;
- cmake* CMakeInstance;
+ cmGeneratorTarget const* const Target;
+ cmMakefile* const Makefile;
+ cmGlobalGenerator* const GlobalGenerator;
+ cmake* const CMakeInstance;
// Configuration information.
- std::string Config;
+ std::string const Config;
std::string LinkLanguage;
// Modes for dealing with dependent shared libraries.
@@ -183,7 +191,6 @@ private:
bool OldLinkDirMode;
bool OpenBSD;
bool LinkDependsNoShared;
- bool UseImportLibrary;
bool RuntimeUseChrpath;
bool NoSONameUsesPath;
bool LinkWithRuntimePath;
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index ff19eac63..162bab298 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -2,13 +2,21 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmComputeTargetDepends.h"
+#include <cassert>
+#include <cstdio>
+#include <sstream>
+#include <utility>
+
#include "cmComputeComponentGraph.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
#include "cmLinkItem.h"
+#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
+#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmState.h"
#include "cmStateTypes.h"
@@ -17,13 +25,6 @@
#include "cmTargetDepend.h"
#include "cmake.h"
-#include <assert.h>
-#include <sstream>
-#include <stdio.h>
-#include <utility>
-
-class cmListFileBacktrace;
-
/*
This class is meant to analyze inter-target dependencies globally
@@ -103,9 +104,7 @@ cmComputeTargetDepends::cmComputeTargetDepends(cmGlobalGenerator* gg)
cm->GetState()->GetGlobalPropertyAsBool("GLOBAL_DEPENDS_NO_CYCLES");
}
-cmComputeTargetDepends::~cmComputeTargetDepends()
-{
-}
+cmComputeTargetDepends::~cmComputeTargetDepends() = default;
bool cmComputeTargetDepends::Compute()
{
@@ -141,17 +140,17 @@ void cmComputeTargetDepends::GetTargetDirectDepends(cmGeneratorTarget const* t,
{
// Lookup the index for this target. All targets should be known by
// this point.
- std::map<cmGeneratorTarget const*, int>::const_iterator tii =
- this->TargetIndex.find(t);
+ auto tii = this->TargetIndex.find(t);
assert(tii != this->TargetIndex.end());
int i = tii->second;
// Get its final dependencies.
EdgeList const& nl = this->FinalGraph[i];
- for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- cmGeneratorTarget const* dep = this->Targets[*ni];
- cmTargetDependSet::iterator di = deps.insert(dep).first;
- di->SetType(ni->IsStrong());
+ for (cmGraphEdge const& ni : nl) {
+ cmGeneratorTarget const* dep = this->Targets[ni];
+ auto di = deps.insert(dep).first;
+ di->SetType(ni.IsStrong());
+ di->SetBacktrace(ni.GetBacktrace());
}
}
@@ -160,15 +159,13 @@ void cmComputeTargetDepends::CollectTargets()
// Collect all targets from all generators.
std::vector<cmLocalGenerator*> const& lgens =
this->GlobalGenerator->GetLocalGenerators();
- for (unsigned int i = 0; i < lgens.size(); ++i) {
- const std::vector<cmGeneratorTarget*> targets =
- lgens[i]->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- cmGeneratorTarget* gt = *ti;
+ for (cmLocalGenerator* lgen : lgens) {
+ const std::vector<cmGeneratorTarget*>& targets =
+ lgen->GetGeneratorTargets();
+ for (cmGeneratorTarget const* ti : targets) {
int index = static_cast<int>(this->Targets.size());
- this->TargetIndex[gt] = index;
- this->Targets.push_back(gt);
+ this->TargetIndex[ti] = index;
+ this->Targets.push_back(ti);
}
}
}
@@ -197,48 +194,45 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// dependencies in all targets, because the generated build-systems can't
// deal with config-specific dependencies.
{
- std::set<std::string> emitted;
+ std::set<cmLinkItem> emitted;
- std::vector<std::string> configs;
- depender->Makefile->GetConfigurations(configs);
- if (configs.empty()) {
- configs.push_back("");
- }
- for (std::vector<std::string>::const_iterator it = configs.begin();
- it != configs.end(); ++it) {
+ std::vector<std::string> const& configs =
+ depender->Makefile->GetGeneratorConfigs();
+ for (std::string const& it : configs) {
std::vector<cmSourceFile const*> objectFiles;
- depender->GetExternalObjects(objectFiles, *it);
- for (std::vector<cmSourceFile const*>::const_iterator oi =
- objectFiles.begin();
- oi != objectFiles.end(); ++oi) {
- std::string objLib = (*oi)->GetObjectLibrary();
- if (!objLib.empty() && emitted.insert(objLib).second) {
- if (depender->GetType() != cmStateEnums::EXECUTABLE &&
- depender->GetType() != cmStateEnums::STATIC_LIBRARY &&
- depender->GetType() != cmStateEnums::SHARED_LIBRARY &&
- depender->GetType() != cmStateEnums::MODULE_LIBRARY) {
- this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
- cmake::FATAL_ERROR,
- "Only executables and non-OBJECT libraries may "
- "reference target objects.",
- depender->GetBacktrace());
- return;
+ depender->GetExternalObjects(objectFiles, it);
+ for (cmSourceFile const* o : objectFiles) {
+ std::string const& objLib = o->GetObjectLibrary();
+ if (!objLib.empty()) {
+ cmLinkItem const& objItem =
+ depender->ResolveLinkItem(objLib, cmListFileBacktrace());
+ if (emitted.insert(objItem).second) {
+ if (depender->GetType() != cmStateEnums::EXECUTABLE &&
+ depender->GetType() != cmStateEnums::STATIC_LIBRARY &&
+ depender->GetType() != cmStateEnums::SHARED_LIBRARY &&
+ depender->GetType() != cmStateEnums::MODULE_LIBRARY &&
+ depender->GetType() != cmStateEnums::OBJECT_LIBRARY) {
+ this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
+ MessageType::FATAL_ERROR,
+ "Only executables and libraries may reference target objects.",
+ depender->GetBacktrace());
+ return;
+ }
+ const_cast<cmGeneratorTarget*>(depender)->Target->AddUtility(
+ objLib);
}
- const_cast<cmGeneratorTarget*>(depender)->Target->AddUtility(objLib);
}
}
- cmLinkImplementation const* impl = depender->GetLinkImplementation(*it);
+ cmLinkImplementation const* impl = depender->GetLinkImplementation(it);
// A target should not depend on itself.
- emitted.insert(depender->GetName());
- for (std::vector<cmLinkImplItem>::const_iterator lib =
- impl->Libraries.begin();
- lib != impl->Libraries.end(); ++lib) {
+ emitted.insert(cmLinkItem(depender, cmListFileBacktrace()));
+ for (cmLinkImplItem const& lib : impl->Libraries) {
// Don't emit the same library twice for this target.
- if (emitted.insert(*lib).second) {
- this->AddTargetDepend(depender_index, *lib, true);
- this->AddInterfaceDepends(depender_index, *lib, *it, emitted);
+ if (emitted.insert(lib).second) {
+ this->AddTargetDepend(depender_index, lib, true);
+ this->AddInterfaceDepends(depender_index, lib, it, emitted);
}
}
}
@@ -247,14 +241,13 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// Loop over all utility dependencies.
{
std::set<cmLinkItem> const& tutils = depender->GetUtilityItems();
- std::set<std::string> emitted;
+ std::set<cmLinkItem> emitted;
// A target should not depend on itself.
- emitted.insert(depender->GetName());
- for (std::set<cmLinkItem>::const_iterator util = tutils.begin();
- util != tutils.end(); ++util) {
+ emitted.insert(cmLinkItem(depender, cmListFileBacktrace()));
+ for (cmLinkItem const& litem : tutils) {
// Don't emit the same utility twice for this target.
- if (emitted.insert(*util).second) {
- this->AddTargetDepend(depender_index, *util, false);
+ if (emitted.insert(litem).second) {
+ this->AddTargetDepend(depender_index, litem, false);
}
}
}
@@ -262,18 +255,22 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
void cmComputeTargetDepends::AddInterfaceDepends(
int depender_index, const cmGeneratorTarget* dependee,
- const std::string& config, std::set<std::string>& emitted)
+ cmListFileBacktrace const& dependee_backtrace, const std::string& config,
+ std::set<cmLinkItem>& emitted)
{
cmGeneratorTarget const* depender = this->Targets[depender_index];
if (cmLinkInterface const* iface =
dependee->GetLinkInterface(config, depender)) {
- for (std::vector<cmLinkItem>::const_iterator lib =
- iface->Libraries.begin();
- lib != iface->Libraries.end(); ++lib) {
+ for (cmLinkItem const& lib : iface->Libraries) {
// Don't emit the same library twice for this target.
- if (emitted.insert(*lib).second) {
- this->AddTargetDepend(depender_index, *lib, true);
- this->AddInterfaceDepends(depender_index, *lib, config, emitted);
+ if (emitted.insert(lib).second) {
+ // Inject the backtrace of the original link dependency whose
+ // link interface we are adding. This indicates the line of
+ // code in the project that caused this dependency to be added.
+ cmLinkItem libBT = lib;
+ libBT.Backtrace = dependee_backtrace;
+ this->AddTargetDepend(depender_index, libBT, true);
+ this->AddInterfaceDepends(depender_index, libBT, config, emitted);
}
}
}
@@ -281,7 +278,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(
void cmComputeTargetDepends::AddInterfaceDepends(
int depender_index, cmLinkItem const& dependee_name,
- const std::string& config, std::set<std::string>& emitted)
+ const std::string& config, std::set<cmLinkItem>& emitted)
{
cmGeneratorTarget const* depender = this->Targets[depender_index];
cmGeneratorTarget const* dependee = dependee_name.Target;
@@ -290,13 +287,14 @@ void cmComputeTargetDepends::AddInterfaceDepends(
// within the project.
if (dependee && dependee->GetType() == cmStateEnums::EXECUTABLE &&
!dependee->IsExecutableWithExports()) {
- dependee = CM_NULLPTR;
+ dependee = nullptr;
}
if (dependee) {
// A target should not depend on itself.
- emitted.insert(depender->GetName());
- this->AddInterfaceDepends(depender_index, dependee, config, emitted);
+ emitted.insert(cmLinkItem(depender, cmListFileBacktrace()));
+ this->AddInterfaceDepends(depender_index, dependee,
+ dependee_name.Backtrace, config, emitted);
}
}
@@ -312,7 +310,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
if (!dependee && !linking &&
(depender->GetType() != cmStateEnums::GLOBAL_TARGET)) {
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ MessageType messageType = MessageType::AUTHOR_WARNING;
bool issueMessage = false;
std::ostringstream e;
switch (depender->GetPolicyStatusCMP0046()) {
@@ -325,7 +323,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
issueMessage = true;
- messageType = cmake::FATAL_ERROR;
+ messageType = MessageType::FATAL_ERROR;
}
if (issueMessage) {
cmake* cm = this->GlobalGenerator->GetCMakeInstance();
@@ -333,13 +331,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
e << "The dependency target \"" << dependee_name << "\" of target \""
<< depender->GetName() << "\" does not exist.";
- cmListFileBacktrace const* backtrace =
- depender->GetUtilityBacktrace(dependee_name);
- if (backtrace) {
- cm->IssueMessage(messageType, e.str(), *backtrace);
- } else {
- cm->IssueMessage(messageType, e.str());
- }
+ cm->IssueMessage(messageType, e.str(), dependee_name.Backtrace);
}
}
@@ -348,40 +340,40 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
// within the project.
if (linking && dependee && dependee->GetType() == cmStateEnums::EXECUTABLE &&
!dependee->IsExecutableWithExports()) {
- dependee = CM_NULLPTR;
+ dependee = nullptr;
}
if (dependee) {
- this->AddTargetDepend(depender_index, dependee, linking);
+ this->AddTargetDepend(depender_index, dependee, dependee_name.Backtrace,
+ linking);
}
}
-void cmComputeTargetDepends::AddTargetDepend(int depender_index,
- const cmGeneratorTarget* dependee,
- bool linking)
+void cmComputeTargetDepends::AddTargetDepend(
+ int depender_index, cmGeneratorTarget const* dependee,
+ cmListFileBacktrace const& dependee_backtrace, bool linking)
{
if (dependee->IsImported() ||
dependee->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
// Skip IMPORTED and INTERFACE targets but follow their utility
// dependencies.
std::set<cmLinkItem> const& utils = dependee->GetUtilityItems();
- for (std::set<cmLinkItem>::const_iterator i = utils.begin();
- i != utils.end(); ++i) {
- if (cmGeneratorTarget const* transitive_dependee = i->Target) {
- this->AddTargetDepend(depender_index, transitive_dependee, false);
+ for (cmLinkItem const& i : utils) {
+ if (cmGeneratorTarget const* transitive_dependee = i.Target) {
+ this->AddTargetDepend(depender_index, transitive_dependee, i.Backtrace,
+ false);
}
}
} else {
// Lookup the index for this target. All targets should be known by
// this point.
- std::map<cmGeneratorTarget const*, int>::const_iterator tii =
- this->TargetIndex.find(dependee);
+ auto tii = this->TargetIndex.find(dependee);
assert(tii != this->TargetIndex.end());
int dependee_index = tii->second;
// Add this entry to the dependency graph.
- this->InitialGraph[depender_index].push_back(
- cmGraphEdge(dependee_index, !linking));
+ this->InitialGraph[depender_index].emplace_back(dependee_index, !linking,
+ dependee_backtrace);
}
}
@@ -395,11 +387,11 @@ void cmComputeTargetDepends::DisplayGraph(Graph const& graph,
cmGeneratorTarget const* depender = this->Targets[depender_index];
fprintf(stderr, "target %d is [%s]\n", depender_index,
depender->GetName().c_str());
- for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int dependee_index = *ni;
+ for (cmGraphEdge const& ni : nl) {
+ int dependee_index = ni;
cmGeneratorTarget const* dependee = this->Targets[dependee_index];
fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index,
- dependee->GetName().c_str(), ni->IsStrong() ? "strong" : "weak");
+ dependee->GetName().c_str(), ni.IsStrong() ? "strong" : "weak");
}
}
fprintf(stderr, "\n");
@@ -414,8 +406,7 @@ void cmComputeTargetDepends::DisplayComponents(
for (int c = 0; c < n; ++c) {
NodeList const& nl = components[c];
fprintf(stderr, "Component (%d):\n", c);
- for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int i = *ni;
+ for (int i : nl) {
fprintf(stderr, " contains target %d [%s]\n", i,
this->Targets[i]->GetName().c_str());
}
@@ -446,8 +437,8 @@ bool cmComputeTargetDepends::CheckComponents(
}
// Make sure the component is all STATIC_LIBRARY targets.
- for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- if (this->Targets[*ni]->GetType() != cmStateEnums::STATIC_LIBRARY) {
+ for (int ni : nl) {
+ if (this->Targets[ni]->GetType() != cmStateEnums::STATIC_LIBRARY) {
this->ComplainAboutBadComponent(ccg, c);
return false;
}
@@ -466,9 +457,8 @@ void cmComputeTargetDepends::ComplainAboutBadComponent(
std::vector<NodeList> const& components = ccg.GetComponents();
std::vector<int> const& cmap = ccg.GetComponentMap();
NodeList const& cl = components[c];
- for (NodeList::const_iterator ci = cl.begin(); ci != cl.end(); ++ci) {
+ for (int i : cl) {
// Get the depender.
- int i = *ci;
cmGeneratorTarget const* depender = this->Targets[i];
// Describe the depender.
@@ -477,12 +467,12 @@ void cmComputeTargetDepends::ComplainAboutBadComponent(
// List its dependencies that are inside the component.
EdgeList const& nl = this->InitialGraph[i];
- for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int j = *ni;
+ for (cmGraphEdge const& ni : nl) {
+ int j = ni;
if (cmap[j] == c) {
cmGeneratorTarget const* dependee = this->Targets[j];
e << " depends on \"" << dependee->GetName() << "\""
- << " (" << (ni->IsStrong() ? "strong" : "weak") << ")\n";
+ << " (" << (ni.IsStrong() ? "strong" : "weak") << ")\n";
}
}
}
@@ -499,7 +489,7 @@ void cmComputeTargetDepends::ComplainAboutBadComponent(
e << "At least one of these targets is not a STATIC_LIBRARY. "
<< "Cyclic dependencies are allowed only among static libraries.";
}
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
}
bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap,
@@ -514,10 +504,10 @@ bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap,
if (emitted.insert(i).second) {
// Honor strong intra-component edges in the final order.
EdgeList const& el = this->InitialGraph[i];
- for (EdgeList::const_iterator ei = el.begin(); ei != el.end(); ++ei) {
- int j = *ei;
- if (cmap[j] == c && ei->IsStrong()) {
- this->FinalGraph[i].push_back(cmGraphEdge(j, true));
+ for (cmGraphEdge const& edge : el) {
+ int j = edge;
+ if (cmap[j] == c && edge.IsStrong()) {
+ this->FinalGraph[i].emplace_back(j, true, edge.GetBacktrace());
if (!this->IntraComponent(cmap, c, j, head, emitted, visited)) {
return false;
}
@@ -526,7 +516,7 @@ bool cmComputeTargetDepends::IntraComponent(std::vector<int> const& cmap,
// Prepend to a linear linked-list of intra-component edges.
if (*head >= 0) {
- this->FinalGraph[i].push_back(cmGraphEdge(*head, false));
+ this->FinalGraph[i].emplace_back(*head, false, cmListFileBacktrace());
} else {
this->ComponentTail[c] = i;
}
@@ -555,10 +545,9 @@ bool cmComputeTargetDepends::ComputeFinalDepends(
int head = -1;
std::set<int> emitted;
NodeList const& nl = components[c];
- for (NodeList::const_reverse_iterator ni = nl.rbegin(); ni != nl.rend();
- ++ni) {
+ for (int ni : cmReverseRange(nl)) {
std::set<int> visited;
- if (!this->IntraComponent(cmap, c, *ni, &head, emitted, visited)) {
+ if (!this->IntraComponent(cmap, c, ni, &head, emitted, visited)) {
// Cycle in add_dependencies within component!
this->ComplainAboutBadComponent(ccg, c, true);
return false;
@@ -573,11 +562,11 @@ bool cmComputeTargetDepends::ComputeFinalDepends(
++depender_component) {
int depender_component_tail = this->ComponentTail[depender_component];
EdgeList const& nl = cgraph[depender_component];
- for (EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) {
- int dependee_component = *ni;
+ for (cmGraphEdge const& ni : nl) {
+ int dependee_component = ni;
int dependee_component_head = this->ComponentHead[dependee_component];
- this->FinalGraph[depender_component_tail].push_back(
- cmGraphEdge(dependee_component_head, ni->IsStrong()));
+ this->FinalGraph[depender_component_tail].emplace_back(
+ dependee_component_head, ni.IsStrong(), ni.GetBacktrace());
}
}
return true;
diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h
index e93e376ce..d8060aede 100644
--- a/Source/cmComputeTargetDepends.h
+++ b/Source/cmComputeTargetDepends.h
@@ -5,13 +5,14 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmGraphAdjacencyList.h"
-
#include <map>
#include <set>
#include <string>
#include <vector>
+#include "cmGraphAdjacencyList.h"
+#include "cmListFileCache.h"
+
class cmComputeComponentGraph;
class cmGeneratorTarget;
class cmGlobalGenerator;
@@ -47,15 +48,17 @@ private:
void AddTargetDepend(int depender_index, cmLinkItem const& dependee_name,
bool linking);
void AddTargetDepend(int depender_index, cmGeneratorTarget const* dependee,
+ cmListFileBacktrace const& dependee_backtrace,
bool linking);
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
void AddInterfaceDepends(int depender_index, cmLinkItem const& dependee_name,
const std::string& config,
- std::set<std::string>& emitted);
+ std::set<cmLinkItem>& emitted);
void AddInterfaceDepends(int depender_index,
cmGeneratorTarget const* dependee,
+ cmListFileBacktrace const& dependee_backtrace,
const std::string& config,
- std::set<std::string>& emitted);
+ std::set<cmLinkItem>& emitted);
cmGlobalGenerator* GlobalGenerator;
bool DebugMode;
bool NoCycles;
@@ -67,9 +70,9 @@ private:
// Represent the target dependency graph. The entry at each
// top-level index corresponds to a depender whose dependencies are
// listed.
- typedef cmGraphNodeList NodeList;
- typedef cmGraphEdgeList EdgeList;
- typedef cmGraphAdjacencyList Graph;
+ using NodeList = cmGraphNodeList;
+ using EdgeList = cmGraphEdgeList;
+ using Graph = cmGraphAdjacencyList;
Graph InitialGraph;
Graph FinalGraph;
void DisplayGraph(Graph const& graph, const std::string& name);
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 2bacf7321..003e60d57 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -2,20 +2,23 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmConditionEvaluator.h"
-#include "cmConfigure.h"
-#include "cmsys/RegularExpression.hxx"
-#include <algorithm>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <functional>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <utility>
+
+#include "cmsys/RegularExpression.hxx"
#include "cmAlgorithms.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+#include "cmake.h"
-class cmCommand;
class cmTest;
static std::string const keyAND = "AND";
@@ -52,11 +55,11 @@ static std::string const keyVERSION_LESS = "VERSION_LESS";
static std::string const keyVERSION_LESS_EQUAL = "VERSION_LESS_EQUAL";
cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
- const cmListFileContext& context,
- const cmListFileBacktrace& bt)
+ cmListFileContext context,
+ cmListFileBacktrace bt)
: Makefile(makefile)
- , ExecutionContext(context)
- , Backtrace(bt)
+ , ExecutionContext(std::move(context))
+ , Backtrace(std::move(bt))
, Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012))
, Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054))
, Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057))
@@ -82,9 +85,9 @@ cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
bool cmConditionEvaluator::IsTrue(
const std::vector<cmExpandedCommandArgument>& args, std::string& errorString,
- cmake::MessageType& status)
+ MessageType& status)
{
- errorString = "";
+ errorString.clear();
// handle empty invocation
if (args.empty()) {
@@ -92,10 +95,7 @@ bool cmConditionEvaluator::IsTrue(
}
// store the reduced args in this vector
- cmArgumentList newArgs;
-
- // copy to the list structure
- newArgs.insert(newArgs.end(), args.begin(), args.end());
+ cmArgumentList newArgs(args.begin(), args.end());
// now loop through the arguments and see if we can reduce any of them
// we do this multiple times. Once for each level of precedence
@@ -124,12 +124,12 @@ bool cmConditionEvaluator::IsTrue(
// now at the end there should only be one argument left
if (newArgs.size() != 1) {
errorString = "Unknown arguments specified";
- status = cmake::FATAL_ERROR;
+ status = MessageType::FATAL_ERROR;
return false;
}
- return this->GetBooleanValueWithAutoDereference(*(newArgs.begin()),
- errorString, status, true);
+ return this->GetBooleanValueWithAutoDereference(newArgs.front(), errorString,
+ status, true);
}
//=========================================================================
@@ -139,7 +139,7 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted(
if ((this->Policy54Status != cmPolicies::WARN &&
this->Policy54Status != cmPolicies::OLD) &&
argument.WasQuoted()) {
- return CM_NULLPTR;
+ return nullptr;
}
const char* def = this->Makefile.GetDefinition(argument.GetValue());
@@ -156,7 +156,7 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted(
"Since the policy is not set the OLD behavior will be used.";
this->Makefile.GetCMakeInstance()->IssueMessage(
- cmake::AUTHOR_WARNING, e.str(), this->Backtrace);
+ MessageType::AUTHOR_WARNING, e.str(), this->Backtrace);
}
}
@@ -200,7 +200,7 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword,
"Since the policy is not set the OLD behavior will be used.";
this->Makefile.GetCMakeInstance()->IssueMessage(
- cmake::AUTHOR_WARNING, e.str(), this->Backtrace);
+ MessageType::AUTHOR_WARNING, e.str(), this->Backtrace);
}
}
@@ -220,10 +220,10 @@ bool cmConditionEvaluator::GetBooleanValue(
}
// Check named constants.
- if (cmSystemTools::IsOn(arg.c_str())) {
+ if (cmIsOn(arg.GetValue())) {
return true;
}
- if (cmSystemTools::IsOff(arg.c_str())) {
+ if (cmIsOff(arg.GetValue())) {
return false;
}
@@ -239,7 +239,7 @@ bool cmConditionEvaluator::GetBooleanValue(
// Check definition.
const char* def = this->GetDefinitionIfUnquoted(arg);
- return !cmSystemTools::IsOff(def);
+ return !cmIsOff(def);
}
//=========================================================================
@@ -256,21 +256,21 @@ bool cmConditionEvaluator::GetBooleanValueOld(
return true;
}
const char* def = this->GetDefinitionIfUnquoted(arg);
- return !cmSystemTools::IsOff(def);
+ return !cmIsOff(def);
}
// Old GetVariableOrNumber behavior.
const char* def = this->GetDefinitionIfUnquoted(arg);
if (!def && atoi(arg.c_str())) {
def = arg.c_str();
}
- return !cmSystemTools::IsOff(def);
+ return !cmIsOff(def);
}
//=========================================================================
// returns the resulting boolean value
bool cmConditionEvaluator::GetBooleanValueWithAutoDereference(
cmExpandedCommandArgument& newArg, std::string& errorString,
- cmake::MessageType& status, bool oneArg) const
+ MessageType& status, bool oneArg) const
{
// Use the policy if it is set.
if (this->Policy12Status == cmPolicies::NEW) {
@@ -289,7 +289,7 @@ bool cmConditionEvaluator::GetBooleanValueWithAutoDereference(
errorString = "An argument named \"" + newArg.GetValue() +
"\" appears in a conditional statement. " +
cmPolicies::GetPolicyWarning(cmPolicies::CMP0012);
- status = cmake::AUTHOR_WARNING;
+ status = MessageType::AUTHOR_WARNING;
CM_FALLTHROUGH;
case cmPolicies::OLD:
return oldResult;
@@ -298,7 +298,7 @@ bool cmConditionEvaluator::GetBooleanValueWithAutoDereference(
errorString = "An argument named \"" + newArg.GetValue() +
"\" appears in a conditional statement. " +
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0012);
- status = cmake::FATAL_ERROR;
+ status = MessageType::FATAL_ERROR;
}
case cmPolicies::NEW:
break;
@@ -363,12 +363,12 @@ void cmConditionEvaluator::HandleBinaryOp(bool value, int& reducible,
// level 0 processes parenthetical expressions
bool cmConditionEvaluator::HandleLevel0(cmArgumentList& newArgs,
std::string& errorString,
- cmake::MessageType& status)
+ MessageType& status)
{
int reducible;
do {
reducible = 0;
- cmArgumentList::iterator arg = newArgs.begin();
+ auto arg = newArgs.begin();
while (arg != newArgs.end()) {
if (IsKeyword(keyParenL, *arg)) {
// search for the closing paren for this opening one
@@ -387,16 +387,16 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList& newArgs,
}
if (depth) {
errorString = "mismatched parenthesis in condition";
- status = cmake::FATAL_ERROR;
+ status = MessageType::FATAL_ERROR;
return false;
}
// store the reduced args in this vector
std::vector<cmExpandedCommandArgument> newArgs2;
// copy to the list structure
- cmArgumentList::iterator argP1 = arg;
+ auto argP1 = arg;
argP1++;
- newArgs2.insert(newArgs2.end(), argP1, argClose);
+ cmAppend(newArgs2, argP1, argClose);
newArgs2.pop_back();
// now recursively invoke IsTrue to handle the values inside the
// parenthetical expression
@@ -420,12 +420,12 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList& newArgs,
//=========================================================================
// level one handles most predicates except for NOT
bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
- cmake::MessageType&)
+ MessageType&)
{
int reducible;
do {
reducible = 0;
- cmArgumentList::iterator arg = newArgs.begin();
+ auto arg = newArgs.begin();
cmArgumentList::iterator argP1;
cmArgumentList::iterator argP2;
while (arg != newArgs.end()) {
@@ -453,9 +453,9 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
}
// does a command exist
if (this->IsKeyword(keyCOMMAND, *arg) && argP1 != newArgs.end()) {
- cmCommand* command =
+ cmState::Command command =
this->Makefile.GetState()->GetCommand(argP1->c_str());
- this->HandlePredicate(command != CM_NULLPTR, reducible, arg, newArgs,
+ this->HandlePredicate(command != nullptr, reducible, arg, newArgs,
argP1, argP2);
}
// does a policy exist
@@ -467,7 +467,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
// does a target exist
if (this->IsKeyword(keyTARGET, *arg) && argP1 != newArgs.end()) {
this->HandlePredicate(
- this->Makefile.FindTargetToUse(argP1->GetValue()) != CM_NULLPTR,
+ this->Makefile.FindTargetToUse(argP1->GetValue()) != nullptr,
reducible, arg, newArgs, argP1, argP2);
}
// does a test exist
@@ -475,8 +475,8 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
this->Policy64Status != cmPolicies::WARN) {
if (this->IsKeyword(keyTEST, *arg) && argP1 != newArgs.end()) {
const cmTest* haveTest = this->Makefile.GetTest(argP1->c_str());
- this->HandlePredicate(haveTest != CM_NULLPTR, reducible, arg,
- newArgs, argP1, argP2);
+ this->HandlePredicate(haveTest != nullptr, reducible, arg, newArgs,
+ argP1, argP2);
}
} else if (this->Policy64Status == cmPolicies::WARN &&
this->IsKeyword(keyTEST, *arg)) {
@@ -486,7 +486,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
"when the policy is set to NEW. "
"Since the policy is not set the OLD behavior will be used.";
- this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ this->Makefile.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
}
// is a variable defined
if (this->IsKeyword(keyDEFINED, *arg) && argP1 != newArgs.end()) {
@@ -495,7 +495,13 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
if (argP1len > 4 && argP1->GetValue().substr(0, 4) == "ENV{" &&
argP1->GetValue().operator[](argP1len - 1) == '}') {
std::string env = argP1->GetValue().substr(4, argP1len - 5);
- bdef = cmSystemTools::HasEnv(env.c_str());
+ bdef = cmSystemTools::HasEnv(env);
+ } else if (argP1len > 6 &&
+ argP1->GetValue().substr(0, 6) == "CACHE{" &&
+ argP1->GetValue().operator[](argP1len - 1) == '}') {
+ std::string cache = argP1->GetValue().substr(6, argP1len - 7);
+ bdef =
+ this->Makefile.GetState()->GetCacheEntryValue(cache) != nullptr;
} else {
bdef = this->Makefile.IsDefinitionSet(argP1->GetValue());
}
@@ -511,7 +517,7 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&,
// level two handles most binary operations except for AND OR
bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
std::string& errorString,
- cmake::MessageType& status)
+ MessageType& status)
{
int reducible;
std::string def_buf;
@@ -519,7 +525,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
const char* def2;
do {
reducible = 0;
- cmArgumentList::iterator arg = newArgs.begin();
+ auto arg = newArgs.begin();
cmArgumentList::iterator argP1;
cmArgumentList::iterator argP2;
while (arg != newArgs.end()) {
@@ -542,7 +548,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
std::ostringstream error;
error << "Regular expression \"" << rex << "\" cannot compile";
errorString = error.str();
- status = cmake::FATAL_ERROR;
+ status = MessageType::FATAL_ERROR;
return false;
}
if (regEntry.find(def)) {
@@ -663,10 +669,9 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
def2 = this->Makefile.GetDefinition(argP2->GetValue());
if (def2) {
- std::vector<std::string> list;
- cmSystemTools::ExpandListArgument(def2, list, true);
+ std::vector<std::string> list = cmExpandedList(def2, true);
- result = std::find(list.begin(), list.end(), def) != list.end();
+ result = cmContains(list, def);
}
this->HandleBinaryOp(result, reducible, arg, newArgs, argP1, argP2);
@@ -677,7 +682,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
"when the policy is set to NEW. "
"Since the policy is not set the OLD behavior will be used.";
- this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ this->Makefile.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
}
}
@@ -691,12 +696,12 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
// level 3 handles NOT
bool cmConditionEvaluator::HandleLevel3(cmArgumentList& newArgs,
std::string& errorString,
- cmake::MessageType& status)
+ MessageType& status)
{
int reducible;
do {
reducible = 0;
- cmArgumentList::iterator arg = newArgs.begin();
+ auto arg = newArgs.begin();
cmArgumentList::iterator argP1;
cmArgumentList::iterator argP2;
while (arg != newArgs.end()) {
@@ -717,14 +722,14 @@ bool cmConditionEvaluator::HandleLevel3(cmArgumentList& newArgs,
// level 4 handles AND OR
bool cmConditionEvaluator::HandleLevel4(cmArgumentList& newArgs,
std::string& errorString,
- cmake::MessageType& status)
+ MessageType& status)
{
int reducible;
bool lhs;
bool rhs;
do {
reducible = 0;
- cmArgumentList::iterator arg = newArgs.begin();
+ auto arg = newArgs.begin();
cmArgumentList::iterator argP1;
cmArgumentList::iterator argP2;
while (arg != newArgs.end()) {
diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h
index 50f4edc4f..082534ce8 100644
--- a/Source/cmConditionEvaluator.h
+++ b/Source/cmConditionEvaluator.h
@@ -11,24 +11,24 @@
#include "cmExpandedCommandArgument.h"
#include "cmListFileCache.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
-#include "cmake.h"
class cmMakefile;
class cmConditionEvaluator
{
public:
- typedef std::list<cmExpandedCommandArgument> cmArgumentList;
+ using cmArgumentList = std::list<cmExpandedCommandArgument>;
- cmConditionEvaluator(cmMakefile& makefile, cmListFileContext const& context,
- cmListFileBacktrace const& bt);
+ cmConditionEvaluator(cmMakefile& makefile, cmListFileContext context,
+ cmListFileBacktrace bt);
// this is a shared function for both If and Else to determine if the
// arguments were valid, and if so, was the response true. If there is
// an error, the errorString will be set.
bool IsTrue(const std::vector<cmExpandedCommandArgument>& args,
- std::string& errorString, cmake::MessageType& status);
+ std::string& errorString, MessageType& status);
private:
// Filter the given variable definition based on policy CMP0054.
@@ -48,7 +48,7 @@ private:
bool GetBooleanValueWithAutoDereference(cmExpandedCommandArgument& newArg,
std::string& errorString,
- cmake::MessageType& status,
+ MessageType& status,
bool oneArg = false) const;
void IncrementArguments(cmArgumentList& newArgs,
@@ -66,19 +66,18 @@ private:
cmArgumentList::iterator& argP2);
bool HandleLevel0(cmArgumentList& newArgs, std::string& errorString,
- cmake::MessageType& status);
+ MessageType& status);
- bool HandleLevel1(cmArgumentList& newArgs, std::string&,
- cmake::MessageType&);
+ bool HandleLevel1(cmArgumentList& newArgs, std::string&, MessageType&);
bool HandleLevel2(cmArgumentList& newArgs, std::string& errorString,
- cmake::MessageType& status);
+ MessageType& status);
bool HandleLevel3(cmArgumentList& newArgs, std::string& errorString,
- cmake::MessageType& status);
+ MessageType& status);
bool HandleLevel4(cmArgumentList& newArgs, std::string& errorString,
- cmake::MessageType& status);
+ MessageType& status);
cmMakefile& Makefile;
cmListFileContext ExecutionContext;
diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in
index 524fdf808..4de1c5d6f 100644
--- a/Source/cmConfigure.cmake.h.in
+++ b/Source/cmConfigure.cmake.h.in
@@ -19,51 +19,15 @@
#cmakedefine HAVE_UNSETENV
#cmakedefine CMAKE_USE_ELF_PARSER
#cmakedefine CMAKE_USE_MACH_PARSER
-#cmakedefine CMAKE_USE_LIBUV
-#cmakedefine CMake_HAVE_CXX_AUTO_PTR
-#cmakedefine CMake_HAVE_CXX_EQ_DELETE
-#cmakedefine CMake_HAVE_CXX_FALLTHROUGH
-#cmakedefine CMake_HAVE_CXX_GNU_FALLTHROUGH
-#cmakedefine CMake_HAVE_CXX_ATTRIBUTE_FALLTHROUGH
#cmakedefine CMake_HAVE_CXX_MAKE_UNIQUE
-#cmakedefine CMake_HAVE_CXX_NULLPTR
-#cmakedefine CMake_HAVE_CXX_OVERRIDE
-#cmakedefine CMake_HAVE_CXX_UNIQUE_PTR
-#cmakedefine CMake_HAVE_CXX_UNORDERED_MAP
-#cmakedefine CMake_HAVE_CXX_UNORDERED_SET
+#define CMake_DEFAULT_RECURSION_LIMIT @CMake_DEFAULT_RECURSION_LIMIT@
#define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@"
#define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"
-#ifdef CMake_HAVE_CXX_EQ_DELETE
-#define CM_EQ_DELETE = delete
-#else
-#define CM_EQ_DELETE
-#endif
-
-#if defined(CMake_HAVE_CXX_FALLTHROUGH)
-#define CM_FALLTHROUGH [[fallthrough]]
-#elif defined(CMake_HAVE_CXX_GNU_FALLTHROUGH)
-#define CM_FALLTHROUGH [[gnu::fallthrough]]
-elif defined(CMake_HAVE_CXX_ATTRIBUTE_FALLTHROUGH)
-#define CM_FALLTHROUGH __attribute__((fallthrough))
-#else
-#define CM_FALLTHROUGH
-#endif
+#define CM_FALLTHROUGH cmsys_FALLTHROUGH
-#ifdef CMake_HAVE_CXX_NULLPTR
-#define CM_NULLPTR nullptr
-#else
-#define CM_NULLPTR 0
+#if defined(_WIN32) && !defined(NOMINMAX)
+# define NOMINMAX
#endif
-#ifdef CMake_HAVE_CXX_OVERRIDE
-#define CM_OVERRIDE override
-#else
-#define CM_OVERRIDE
-#endif
-
-#define CM_DISABLE_COPY(Class) \
- Class(Class const&) CM_EQ_DELETE; \
- Class& operator=(Class const&) CM_EQ_DELETE;
-
#endif
diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx
index 18005f27c..8767386cf 100644
--- a/Source/cmConfigureFileCommand.cxx
+++ b/Source/cmConfigureFileCommand.cxx
@@ -2,84 +2,74 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmConfigureFileCommand.h"
-#include <sstream>
-
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmNewLineStyle.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-
-class cmExecutionStatus;
// cmConfigureFileCommand
-bool cmConfigureFileCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmConfigureFileCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments, expected 2");
+ status.SetError("called with incorrect number of arguments, expected 2");
return false;
}
std::string const& inFile = args[0];
- if (!cmSystemTools::FileIsFullPath(inFile)) {
- this->InputFile = this->Makefile->GetCurrentSourceDirectory();
- this->InputFile += "/";
- }
- this->InputFile += inFile;
+ const std::string inputFile = cmSystemTools::CollapseFullPath(
+ inFile, status.GetMakefile().GetCurrentSourceDirectory());
// If the input location is a directory, error out.
- if (cmSystemTools::FileIsDirectory(this->InputFile)) {
- std::ostringstream e;
- /* clang-format off */
- e << "input location\n"
- << " " << this->InputFile << "\n"
- << "is a directory but a file was expected.";
- /* clang-format on */
- this->SetError(e.str());
+ if (cmSystemTools::FileIsDirectory(inputFile)) {
+ status.SetError(cmStrCat("input location\n ", inputFile,
+ "\n"
+ "is a directory but a file was expected."));
return false;
}
std::string const& outFile = args[1];
- if (!cmSystemTools::FileIsFullPath(outFile)) {
- this->OutputFile = this->Makefile->GetCurrentBinaryDirectory();
- this->OutputFile += "/";
- }
- this->OutputFile += outFile;
+ std::string outputFile = cmSystemTools::CollapseFullPath(
+ outFile, status.GetMakefile().GetCurrentBinaryDirectory());
// If the output location is already a directory put the file in it.
- if (cmSystemTools::FileIsDirectory(this->OutputFile)) {
- this->OutputFile += "/";
- this->OutputFile += cmSystemTools::GetFilenameName(inFile);
+ if (cmSystemTools::FileIsDirectory(outputFile)) {
+ outputFile += "/";
+ outputFile += cmSystemTools::GetFilenameName(inFile);
}
- if (!this->Makefile->CanIWriteThisFile(this->OutputFile.c_str())) {
- std::string e = "attempted to configure a file: " + this->OutputFile +
+ if (!status.GetMakefile().CanIWriteThisFile(outputFile)) {
+ std::string e = "attempted to configure a file: " + outputFile +
" into a source directory.";
- this->SetError(e);
+ status.SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
std::string errorMessage;
- if (!this->NewLineStyle.ReadFromArguments(args, errorMessage)) {
- this->SetError(errorMessage);
+ cmNewLineStyle newLineStyle;
+ if (!newLineStyle.ReadFromArguments(args, errorMessage)) {
+ status.SetError(errorMessage);
return false;
}
- this->CopyOnly = false;
- this->EscapeQuotes = false;
+ bool copyOnly = false;
+ bool escapeQuotes = false;
std::string unknown_args;
- this->AtOnly = false;
+ bool atOnly = false;
for (unsigned int i = 2; i < args.size(); ++i) {
if (args[i] == "COPYONLY") {
- this->CopyOnly = true;
- if (this->NewLineStyle.IsValid()) {
- this->SetError("COPYONLY could not be used in combination "
- "with NEWLINE_STYLE");
+ copyOnly = true;
+ if (newLineStyle.IsValid()) {
+ status.SetError("COPYONLY could not be used in combination "
+ "with NEWLINE_STYLE");
return false;
}
} else if (args[i] == "ESCAPE_QUOTES") {
- this->EscapeQuotes = true;
+ escapeQuotes = true;
} else if (args[i] == "@ONLY") {
- this->AtOnly = true;
+ atOnly = true;
} else if (args[i] == "IMMEDIATE") {
/* Ignore legacy option. */
} else if (args[i] == "NEWLINE_STYLE" || args[i] == "LF" ||
@@ -93,22 +83,16 @@ bool cmConfigureFileCommand::InitialPass(std::vector<std::string> const& args,
}
}
if (!unknown_args.empty()) {
- std::string msg = "configure_file called with unknown argument(s):\n";
- msg += unknown_args;
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg);
+ std::string msg = cmStrCat(
+ "configure_file called with unknown argument(s):\n", unknown_args);
+ status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, msg);
}
- if (!this->ConfigureFile()) {
- this->SetError("Problem configuring file");
+ if (!status.GetMakefile().ConfigureFile(
+ inputFile, outputFile, copyOnly, atOnly, escapeQuotes, newLineStyle)) {
+ status.SetError("Problem configuring file");
return false;
}
return true;
}
-
-int cmConfigureFileCommand::ConfigureFile()
-{
- return this->Makefile->ConfigureFile(
- this->InputFile.c_str(), this->OutputFile.c_str(), this->CopyOnly,
- this->AtOnly, this->EscapeQuotes, this->NewLineStyle);
-}
diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h
index 6cebbd258..c7f95b852 100644
--- a/Source/cmConfigureFileCommand.h
+++ b/Source/cmConfigureFileCommand.h
@@ -3,38 +3,13 @@
#ifndef cmConfigureFileCommand_h
#define cmConfigureFileCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-#include "cmNewLineStyle.h"
-
class cmExecutionStatus;
-class cmConfigureFileCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmConfigureFileCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- int ConfigureFile();
-
- cmNewLineStyle NewLineStyle;
-
- std::string InputFile;
- std::string OutputFile;
- bool CopyOnly;
- bool EscapeQuotes;
- bool AtOnly;
-};
-
+bool cmConfigureFileCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmConnection.cxx b/Source/cmConnection.cxx
new file mode 100644
index 000000000..884e31432
--- /dev/null
+++ b/Source/cmConnection.cxx
@@ -0,0 +1,164 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmConnection.h"
+
+#include <cassert>
+#include <cstring>
+
+#include "cm_uv.h"
+
+#include "cmServer.h"
+
+struct write_req_t
+{
+ uv_write_t req;
+ uv_buf_t buf;
+};
+
+void cmEventBasedConnection::on_alloc_buffer(uv_handle_t* handle,
+ size_t suggested_size,
+ uv_buf_t* buf)
+{
+ (void)(handle);
+ char* rawBuffer = new char[suggested_size];
+ *buf = uv_buf_init(rawBuffer, static_cast<unsigned int>(suggested_size));
+}
+
+void cmEventBasedConnection::on_read(uv_stream_t* stream, ssize_t nread,
+ const uv_buf_t* buf)
+{
+ auto conn = static_cast<cmEventBasedConnection*>(stream->data);
+ if (conn) {
+ if (nread >= 0) {
+ conn->ReadData(std::string(buf->base, buf->base + nread));
+ } else {
+ conn->OnDisconnect(static_cast<int>(nread));
+ }
+ }
+
+ delete[](buf->base);
+}
+
+void cmEventBasedConnection::on_close(uv_handle_t* /*handle*/)
+{
+}
+
+void cmEventBasedConnection::on_write(uv_write_t* req, int status)
+{
+ (void)(status);
+
+ // Free req and buffer
+ write_req_t* wr = reinterpret_cast<write_req_t*>(req);
+ delete[](wr->buf.base);
+ delete wr;
+}
+
+void cmEventBasedConnection::on_new_connection(uv_stream_t* stream, int status)
+{
+ (void)(status);
+ auto conn = static_cast<cmEventBasedConnection*>(stream->data);
+
+ if (conn) {
+ conn->Connect(stream);
+ }
+}
+
+bool cmEventBasedConnection::IsOpen() const
+{
+ return this->WriteStream != nullptr;
+}
+
+void cmEventBasedConnection::WriteData(const std::string& _data)
+{
+#ifndef NDEBUG
+ auto curr_thread_id = uv_thread_self();
+ assert(this->Server);
+ assert(uv_thread_equal(&curr_thread_id, &this->Server->ServeThreadId));
+#endif
+
+ auto data = _data;
+ assert(this->WriteStream.get());
+ if (BufferStrategy) {
+ data = BufferStrategy->BufferOutMessage(data);
+ }
+
+ auto ds = data.size();
+
+ write_req_t* req = new write_req_t;
+ req->req.data = this;
+ req->buf = uv_buf_init(new char[ds], static_cast<unsigned int>(ds));
+ memcpy(req->buf.base, data.c_str(), ds);
+ uv_write(reinterpret_cast<uv_write_t*>(req), this->WriteStream, &req->buf, 1,
+ on_write);
+}
+
+void cmEventBasedConnection::ReadData(const std::string& data)
+{
+ this->RawReadBuffer += data;
+ if (BufferStrategy) {
+ std::string packet = BufferStrategy->BufferMessage(this->RawReadBuffer);
+ while (!packet.empty()) {
+ ProcessRequest(packet);
+ packet = BufferStrategy->BufferMessage(this->RawReadBuffer);
+ }
+ } else {
+ ProcessRequest(this->RawReadBuffer);
+ this->RawReadBuffer.clear();
+ }
+}
+
+cmEventBasedConnection::cmEventBasedConnection(
+ cmConnectionBufferStrategy* bufferStrategy)
+ : BufferStrategy(bufferStrategy)
+{
+}
+
+void cmEventBasedConnection::Connect(uv_stream_t* server)
+{
+ (void)server;
+ Server->OnConnected(nullptr);
+}
+
+void cmEventBasedConnection::OnDisconnect(int onerror)
+{
+ (void)onerror;
+ this->OnConnectionShuttingDown();
+ if (this->Server) {
+ this->Server->OnDisconnect(this);
+ }
+}
+
+cmConnection::~cmConnection() = default;
+
+bool cmConnection::OnConnectionShuttingDown()
+{
+ this->Server = nullptr;
+ return true;
+}
+
+void cmConnection::SetServer(cmServerBase* s)
+{
+ Server = s;
+}
+
+void cmConnection::ProcessRequest(const std::string& request)
+{
+ Server->ProcessRequest(this, request);
+}
+
+bool cmConnection::OnServeStart(std::string* errString)
+{
+ (void)errString;
+ return true;
+}
+
+bool cmEventBasedConnection::OnConnectionShuttingDown()
+{
+ if (this->WriteStream.get()) {
+ this->WriteStream->data = nullptr;
+ }
+
+ WriteStream.reset();
+
+ return true;
+}
diff --git a/Source/cmConnection.h b/Source/cmConnection.h
new file mode 100644
index 000000000..7bb249404
--- /dev/null
+++ b/Source/cmConnection.h
@@ -0,0 +1,137 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#pragma once
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <cstddef>
+#include <memory>
+#include <string>
+
+#include "cm_uv.h"
+
+#include "cmUVHandlePtr.h"
+
+class cmServerBase;
+
+/***
+ * Given a sequence of bytes with any kind of buffering, instances of this
+ * class arrange logical chunks according to whatever the use case is for
+ * the connection.
+ */
+class cmConnectionBufferStrategy
+{
+public:
+ virtual ~cmConnectionBufferStrategy();
+
+ /***
+ * Called whenever with an active raw buffer. If a logical chunk
+ * becomes available, that chunk is returned and that portion is
+ * removed from the rawBuffer
+ *
+ * @param rawBuffer in/out parameter. Receive buffer; the buffer strategy is
+ * free to manipulate this buffer anyway it needs to.
+ *
+ * @return Next chunk from the stream. Returns the empty string if a chunk
+ * isn't ready yet. Users of this interface should repeatedly call this
+ * function until an empty string is returned since its entirely possible
+ * multiple chunks come in a single raw buffer.
+ */
+ virtual std::string BufferMessage(std::string& rawBuffer) = 0;
+
+ /***
+ * Called to properly buffer an outgoing message.
+ *
+ * @param rawBuffer Message to format in the correct way
+ *
+ * @return Formatted message
+ */
+ virtual std::string BufferOutMessage(const std::string& rawBuffer) const
+ {
+ return rawBuffer;
+ };
+ /***
+ * Resets the internal state of the buffering
+ */
+ virtual void clear();
+
+ // TODO: There should be a callback / flag set for errors
+};
+
+class cmConnection
+{
+public:
+ cmConnection() = default;
+
+ cmConnection(cmConnection const&) = delete;
+ cmConnection& operator=(cmConnection const&) = delete;
+
+ virtual void WriteData(const std::string& data) = 0;
+
+ virtual ~cmConnection();
+
+ virtual bool OnConnectionShuttingDown();
+
+ virtual bool IsOpen() const = 0;
+
+ virtual void SetServer(cmServerBase* s);
+
+ virtual void ProcessRequest(const std::string& request);
+
+ virtual bool OnServeStart(std::string* pString);
+
+protected:
+ cmServerBase* Server = nullptr;
+};
+
+/***
+ * Abstraction of a connection; ties in event callbacks from libuv and notifies
+ * the server when appropriate
+ */
+class cmEventBasedConnection : public cmConnection
+{
+
+public:
+ /***
+ * @param bufferStrategy If no strategy is given, it will process the raw
+ * chunks as they come in. The connection
+ * owns the pointer given.
+ */
+ cmEventBasedConnection(cmConnectionBufferStrategy* bufferStrategy = nullptr);
+
+ virtual void Connect(uv_stream_t* server);
+
+ virtual void ReadData(const std::string& data);
+
+ bool IsOpen() const override;
+
+ void WriteData(const std::string& data) override;
+ bool OnConnectionShuttingDown() override;
+
+ virtual void OnDisconnect(int errorCode);
+
+ static void on_close(uv_handle_t* handle);
+
+ template <typename T>
+ static void on_close_delete(uv_handle_t* handle)
+ {
+ delete reinterpret_cast<T*>(handle);
+ }
+
+protected:
+ cm::uv_stream_ptr WriteStream;
+
+ std::string RawReadBuffer;
+
+ std::unique_ptr<cmConnectionBufferStrategy> BufferStrategy;
+
+ static void on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf);
+
+ static void on_write(uv_write_t* req, int status);
+
+ static void on_new_connection(uv_stream_t* stream, int status);
+
+ static void on_alloc_buffer(uv_handle_t* handle, size_t suggested_size,
+ uv_buf_t* buf);
+};
diff --git a/Source/cmContinueCommand.cxx b/Source/cmContinueCommand.cxx
index 2298a05c5..bb63dffd6 100644
--- a/Source/cmContinueCommand.cxx
+++ b/Source/cmContinueCommand.cxx
@@ -4,17 +4,18 @@
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmSystemTools.h"
-#include "cmake.h"
// cmContinueCommand
-bool cmContinueCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status)
+bool cmContinueCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- if (!this->Makefile->IsLoopBlock()) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "A CONTINUE command was found outside of a "
- "proper FOREACH or WHILE loop scope.");
+ if (!status.GetMakefile().IsLoopBlock()) {
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ "A CONTINUE command was found outside of a "
+ "proper FOREACH or WHILE loop scope.");
cmSystemTools::SetFatalErrorOccured();
return true;
}
@@ -22,9 +23,10 @@ bool cmContinueCommand::InitialPass(std::vector<std::string> const& args,
status.SetContinueInvoked();
if (!args.empty()) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "The CONTINUE command does not accept any "
- "arguments.");
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ "The CONTINUE command does not accept any "
+ "arguments.");
cmSystemTools::SetFatalErrorOccured();
return true;
}
diff --git a/Source/cmContinueCommand.h b/Source/cmContinueCommand.h
index 92bc68e85..ff903aaf6 100644
--- a/Source/cmContinueCommand.h
+++ b/Source/cmContinueCommand.h
@@ -3,34 +3,19 @@
#ifndef cmContinueCommand_h
#define cmContinueCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmContinueCommand
+/**
* \brief Continue from an enclosing foreach or while loop
*
* cmContinueCommand returns from an enclosing foreach or while loop
*/
-class cmContinueCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmContinueCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmContinueCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmConvertMSBuildXMLToJSON.py b/Source/cmConvertMSBuildXMLToJSON.py
index 93ab8a82f..02074ba65 100644
--- a/Source/cmConvertMSBuildXMLToJSON.py
+++ b/Source/cmConvertMSBuildXMLToJSON.py
@@ -96,7 +96,6 @@ def read_msbuild_json(path, values=[]):
return values
-
def main():
"""Script entrypoint."""
# Parse the arguments
@@ -213,6 +212,14 @@ def __find_and_remove_value(list, compare):
return found
+def __normalize_switch(switch, separator):
+ new = switch
+ if switch.startswith("/") or switch.startswith("-"):
+ new = switch[1:]
+ if new and separator:
+ new = new + separator
+ return new
+
###########################################################################################
# private xml functions
def __convert(root, tag, values, func):
@@ -257,6 +264,8 @@ def __convert_bool(node):
reverse_switch = __get_attribute(node, 'ReverseSwitch')
if reverse_switch:
+ __with_argument(node, converted)
+
converted_reverse = copy.deepcopy(converted)
converted_reverse['switch'] = reverse_switch
@@ -303,7 +312,11 @@ def __convert_node(node, default_value='', default_flags=vsflags()):
converted = {}
converted['name'] = name
- converted['switch'] = __get_attribute(node, 'Switch')
+
+ switch = __get_attribute(node, 'Switch')
+ separator = __get_attribute(node, 'Separator')
+ converted['switch'] = __normalize_switch(switch, separator)
+
converted['comment'] = __get_attribute(node, 'DisplayName')
converted['value'] = default_value
@@ -343,7 +356,7 @@ def __with_argument(node, value):
def __preprocess_arguments(root):
- """Preprocesses occurrances of Argument within the root.
+ """Preprocesses occurrences of Argument within the root.
Argument XML values reference other values within the document by name. The
referenced value does not contain a switch. This function will add the
@@ -435,7 +448,7 @@ def __write_json_file(path, values):
with open(path, 'w') as f:
json.dump(sorted_values, f, indent=2, separators=(',', ': '))
-
+ f.write("\n")
###########################################################################################
# private list helpers
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 9a4abf3ca..5711cae49 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -2,21 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCoreTryCompile.h"
-#include "cmConfigure.h"
-#include "cmsys/Directory.hxx"
+#include <cstdio>
+#include <cstring>
#include <set>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
#include <utility>
-#include "cmAlgorithms.h"
+#include "cmsys/Directory.hxx"
+
+#include "cm_static_string_view.hxx"
+
#include "cmExportTryCompileFileGenerator.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmOutputConverter.h"
#include "cmPolicies.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmVersion.h"
@@ -25,15 +28,25 @@
static std::string const kCMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN =
"CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN";
static std::string const kCMAKE_C_COMPILER_TARGET = "CMAKE_C_COMPILER_TARGET";
+static std::string const kCMAKE_C_LINK_NO_PIE_SUPPORTED =
+ "CMAKE_C_LINK_NO_PIE_SUPPORTED";
+static std::string const kCMAKE_C_LINK_PIE_SUPPORTED =
+ "CMAKE_C_LINK_PIE_SUPPORTED";
static std::string const kCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN =
"CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN";
static std::string const kCMAKE_CXX_COMPILER_TARGET =
"CMAKE_CXX_COMPILER_TARGET";
+static std::string const kCMAKE_CXX_LINK_NO_PIE_SUPPORTED =
+ "CMAKE_CXX_LINK_NO_PIE_SUPPORTED";
+static std::string const kCMAKE_CXX_LINK_PIE_SUPPORTED =
+ "CMAKE_CXX_LINK_PIE_SUPPORTED";
static std::string const kCMAKE_ENABLE_EXPORTS = "CMAKE_ENABLE_EXPORTS";
static std::string const kCMAKE_LINK_SEARCH_END_STATIC =
"CMAKE_LINK_SEARCH_END_STATIC";
static std::string const kCMAKE_LINK_SEARCH_START_STATIC =
"CMAKE_LINK_SEARCH_START_STATIC";
+static std::string const kCMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT =
+ "CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT";
static std::string const kCMAKE_OSX_ARCHITECTURES = "CMAKE_OSX_ARCHITECTURES";
static std::string const kCMAKE_OSX_DEPLOYMENT_TARGET =
"CMAKE_OSX_DEPLOYMENT_TARGET";
@@ -43,12 +56,21 @@ static std::string const kCMAKE_POSITION_INDEPENDENT_CODE =
static std::string const kCMAKE_SYSROOT = "CMAKE_SYSROOT";
static std::string const kCMAKE_SYSROOT_COMPILE = "CMAKE_SYSROOT_COMPILE";
static std::string const kCMAKE_SYSROOT_LINK = "CMAKE_SYSROOT_LINK";
+static std::string const kCMAKE_Swift_COMPILER_TARGET =
+ "CMAKE_Swift_COMPILER_TARGET";
static std::string const kCMAKE_TRY_COMPILE_OSX_ARCHITECTURES =
"CMAKE_TRY_COMPILE_OSX_ARCHITECTURES";
static std::string const kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES =
"CMAKE_TRY_COMPILE_PLATFORM_VARIABLES";
static std::string const kCMAKE_WARN_DEPRECATED = "CMAKE_WARN_DEPRECATED";
+/* GHS Multi platform variables */
+static std::set<std::string> ghs_platform_vars{
+ "GHS_TARGET_PLATFORM", "GHS_PRIMARY_TARGET", "GHS_TOOLSET_ROOT",
+ "GHS_OS_ROOT", "GHS_OS_DIR", "GHS_BSP_NAME",
+ "GHS_OS_DIR_OPTION"
+};
+
static void writeProperty(FILE* fout, std::string const& targetName,
std::string const& prop, std::string const& value)
{
@@ -72,7 +94,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
bool isTryRun)
{
this->BinaryDirectory = argv[1];
- this->OutputFile = "";
+ this->OutputFile.clear();
// which signature were we called with ?
this->SrcFileSignature = true;
@@ -83,17 +105,20 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
if (strcmp(tt, cmState::GetTargetTypeName(cmStateEnums::EXECUTABLE)) ==
0) {
targetType = cmStateEnums::EXECUTABLE;
- } else if (strcmp(tt, cmState::GetTargetTypeName(
- cmStateEnums::STATIC_LIBRARY)) == 0) {
+ } else if (strcmp(tt,
+ cmState::GetTargetTypeName(
+ cmStateEnums::STATIC_LIBRARY)) == 0) {
targetType = cmStateEnums::STATIC_LIBRARY;
} else {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR, std::string("Invalid value '") + tt +
+ MessageType::FATAL_ERROR,
+ std::string("Invalid value '") + tt +
"' for "
"CMAKE_TRY_COMPILE_TARGET_TYPE. Only "
"'" +
- cmState::GetTargetTypeName(cmStateEnums::EXECUTABLE) + "' and "
- "'" +
+ cmState::GetTargetTypeName(cmStateEnums::EXECUTABLE) +
+ "' and "
+ "'" +
cmState::GetTargetTypeName(cmStateEnums::STATIC_LIBRARY) +
"' "
"are allowed.");
@@ -101,24 +126,32 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
}
}
- const char* sourceDirectory = argv[2].c_str();
- const char* projectName = CM_NULLPTR;
+ std::string sourceDirectory = argv[2];
+ std::string projectName;
std::string targetName;
std::vector<std::string> cmakeFlags(1, "CMAKE_FLAGS"); // fake argv[0]
std::vector<std::string> compileDefs;
+ std::string cmakeInternal;
std::string outputVariable;
std::string copyFile;
std::string copyFileError;
std::string cStandard;
+ std::string objcStandard;
std::string cxxStandard;
+ std::string objcxxStandard;
std::string cudaStandard;
std::string cStandardRequired;
std::string cxxStandardRequired;
+ std::string objcStandardRequired;
+ std::string objcxxStandardRequired;
std::string cudaStandardRequired;
std::string cExtensions;
std::string cxxExtensions;
+ std::string objcExtensions;
+ std::string objcxxExtensions;
std::string cudaExtensions;
std::vector<std::string> targets;
+ std::vector<std::string> linkOptions;
std::string libsToLink = " ";
bool useOldLinkLibs = true;
char targetNameBuf[64];
@@ -127,12 +160,18 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
bool didCopyFileError = false;
bool didCStandard = false;
bool didCxxStandard = false;
+ bool didObjCStandard = false;
+ bool didObjCxxStandard = false;
bool didCudaStandard = false;
bool didCStandardRequired = false;
bool didCxxStandardRequired = false;
+ bool didObjCStandardRequired = false;
+ bool didObjCxxStandardRequired = false;
bool didCudaStandardRequired = false;
bool didCExtensions = false;
bool didCxxExtensions = false;
+ bool didObjCExtensions = false;
+ bool didObjCxxExtensions = false;
bool didCudaExtensions = false;
bool useSources = argv[2] == "SOURCES";
std::vector<std::string> sources;
@@ -142,20 +181,28 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
DoingNone,
DoingCMakeFlags,
DoingCompileDefinitions,
+ DoingLinkOptions,
DoingLinkLibraries,
DoingOutputVariable,
DoingCopyFile,
DoingCopyFileError,
DoingCStandard,
DoingCxxStandard,
+ DoingObjCStandard,
+ DoingObjCxxStandard,
DoingCudaStandard,
DoingCStandardRequired,
DoingCxxStandardRequired,
+ DoingObjCStandardRequired,
+ DoingObjCxxStandardRequired,
DoingCudaStandardRequired,
DoingCExtensions,
DoingCxxExtensions,
+ DoingObjCExtensions,
+ DoingObjCxxExtensions,
DoingCudaExtensions,
- DoingSources
+ DoingSources,
+ DoingCMakeInternal
};
Doing doing = useSources ? DoingSources : DoingNone;
for (size_t i = 3; i < argv.size(); ++i) {
@@ -163,6 +210,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
doing = DoingCMakeFlags;
} else if (argv[i] == "COMPILE_DEFINITIONS") {
doing = DoingCompileDefinitions;
+ } else if (argv[i] == "LINK_OPTIONS") {
+ doing = DoingLinkOptions;
} else if (argv[i] == "LINK_LIBRARIES") {
doing = DoingLinkLibraries;
useOldLinkLibs = false;
@@ -181,6 +230,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
} else if (argv[i] == "CXX_STANDARD") {
doing = DoingCxxStandard;
didCxxStandard = true;
+ } else if (argv[i] == "OBJC_STANDARD") {
+ doing = DoingObjCStandard;
+ didObjCStandard = true;
+ } else if (argv[i] == "OBJCXX_STANDARD") {
+ doing = DoingObjCxxStandard;
+ didObjCxxStandard = true;
} else if (argv[i] == "CUDA_STANDARD") {
doing = DoingCudaStandard;
didCudaStandard = true;
@@ -190,6 +245,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
} else if (argv[i] == "CXX_STANDARD_REQUIRED") {
doing = DoingCxxStandardRequired;
didCxxStandardRequired = true;
+ } else if (argv[i] == "OBJC_STANDARD_REQUIRED") {
+ doing = DoingObjCStandardRequired;
+ didObjCStandardRequired = true;
+ } else if (argv[i] == "OBJCXX_STANDARD_REQUIRED") {
+ doing = DoingObjCxxStandardRequired;
+ didObjCxxStandardRequired = true;
} else if (argv[i] == "CUDA_STANDARD_REQUIRED") {
doing = DoingCudaStandardRequired;
didCudaStandardRequired = true;
@@ -199,15 +260,25 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
} else if (argv[i] == "CXX_EXTENSIONS") {
doing = DoingCxxExtensions;
didCxxExtensions = true;
+ } else if (argv[i] == "OBJC_EXTENSIONS") {
+ doing = DoingObjCExtensions;
+ didObjCExtensions = true;
+ } else if (argv[i] == "OBJCXX_EXTENSIONS") {
+ doing = DoingObjCxxExtensions;
+ didObjCxxExtensions = true;
} else if (argv[i] == "CUDA_EXTENSIONS") {
doing = DoingCudaExtensions;
didCudaExtensions = true;
+ } else if (argv[i] == "__CMAKE_INTERNAL") {
+ doing = DoingCMakeInternal;
} else if (doing == DoingCMakeFlags) {
cmakeFlags.push_back(argv[i]);
} else if (doing == DoingCompileDefinitions) {
- compileDefs.push_back(argv[i]);
+ cmExpandList(argv[i], compileDefs);
+ } else if (doing == DoingLinkOptions) {
+ linkOptions.push_back(argv[i]);
} else if (doing == DoingLinkLibraries) {
- libsToLink += "\"" + cmSystemTools::TrimWhitespace(argv[i]) + "\" ";
+ libsToLink += "\"" + cmTrimWhitespace(argv[i]) + "\" ";
if (cmTarget* tgt = this->Makefile->FindTargetToUse(argv[i])) {
switch (tgt->GetType()) {
case cmStateEnums::SHARED_LIBRARY:
@@ -222,11 +293,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
CM_FALLTHROUGH;
default:
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"Only libraries may be used as try_compile or try_run IMPORTED "
"LINK_LIBRARIES. Got " +
- std::string(tgt->GetName()) + " of "
- "type " +
+ std::string(tgt->GetName()) +
+ " of "
+ "type " +
cmState::GetTargetTypeName(tgt->GetType()) + ".");
return -1;
}
@@ -249,6 +321,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
} else if (doing == DoingCxxStandard) {
cxxStandard = argv[i];
doing = DoingNone;
+ } else if (doing == DoingObjCStandard) {
+ objcStandard = argv[i];
+ doing = DoingNone;
+ } else if (doing == DoingObjCxxStandard) {
+ objcxxStandard = argv[i];
+ doing = DoingNone;
} else if (doing == DoingCudaStandard) {
cudaStandard = argv[i];
doing = DoingNone;
@@ -258,6 +336,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
} else if (doing == DoingCxxStandardRequired) {
cxxStandardRequired = argv[i];
doing = DoingNone;
+ } else if (doing == DoingObjCStandardRequired) {
+ objcStandardRequired = argv[i];
+ doing = DoingNone;
+ } else if (doing == DoingObjCxxStandardRequired) {
+ objcxxStandardRequired = argv[i];
+ doing = DoingNone;
} else if (doing == DoingCudaStandardRequired) {
cudaStandardRequired = argv[i];
doing = DoingNone;
@@ -267,106 +351,117 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
} else if (doing == DoingCxxExtensions) {
cxxExtensions = argv[i];
doing = DoingNone;
+ } else if (doing == DoingObjCExtensions) {
+ objcExtensions = argv[i];
+ doing = DoingNone;
+ } else if (doing == DoingObjCxxExtensions) {
+ objcxxExtensions = argv[i];
+ doing = DoingNone;
} else if (doing == DoingCudaExtensions) {
cudaExtensions = argv[i];
doing = DoingNone;
} else if (doing == DoingSources) {
sources.push_back(argv[i]);
+ } else if (doing == DoingCMakeInternal) {
+ cmakeInternal = argv[i];
+ doing = DoingNone;
} else if (i == 3) {
this->SrcFileSignature = false;
- projectName = argv[i].c_str();
+ projectName = argv[i];
} else if (i == 4 && !this->SrcFileSignature) {
targetName = argv[i];
} else {
std::ostringstream m;
m << "try_compile given unknown argument \"" << argv[i] << "\".";
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
+ this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, m.str());
}
}
if (didCopyFile && copyFile.empty()) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
"COPY_FILE must be followed by a file path");
return -1;
}
if (didCopyFileError && copyFileError.empty()) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"COPY_FILE_ERROR must be followed by a variable name");
return -1;
}
if (didCopyFileError && !didCopyFile) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR, "COPY_FILE_ERROR may be used only with COPY_FILE");
+ MessageType::FATAL_ERROR,
+ "COPY_FILE_ERROR may be used only with COPY_FILE");
return -1;
}
if (didOutputVariable && outputVariable.empty()) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"OUTPUT_VARIABLE must be followed by a variable name");
return -1;
}
if (useSources && sources.empty()) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"SOURCES must be followed by at least one source file");
return -1;
}
if (didCStandard && !this->SrcFileSignature) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR, "C_STANDARD allowed only in source file signature.");
+ MessageType::FATAL_ERROR,
+ "C_STANDARD allowed only in source file signature.");
return -1;
}
if (didCxxStandard && !this->SrcFileSignature) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"CXX_STANDARD allowed only in source file signature.");
return -1;
}
if (didCudaStandard && !this->SrcFileSignature) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"CUDA_STANDARD allowed only in source file signature.");
return -1;
}
if (didCStandardRequired && !this->SrcFileSignature) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"C_STANDARD_REQUIRED allowed only in source file signature.");
return -1;
}
if (didCxxStandardRequired && !this->SrcFileSignature) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"CXX_STANDARD_REQUIRED allowed only in source file signature.");
return -1;
}
if (didCudaStandardRequired && !this->SrcFileSignature) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"CUDA_STANDARD_REQUIRED allowed only in source file signature.");
return -1;
}
if (didCExtensions && !this->SrcFileSignature) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"C_EXTENSIONS allowed only in source file signature.");
return -1;
}
if (didCxxExtensions && !this->SrcFileSignature) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"CXX_EXTENSIONS allowed only in source file signature.");
return -1;
}
if (didCudaExtensions && !this->SrcFileSignature) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"CUDA_EXTENSIONS allowed only in source file signature.");
return -1;
}
@@ -374,32 +469,31 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
// compute the binary dir when TRY_COMPILE is called with a src file
// signature
if (this->SrcFileSignature) {
- this->BinaryDirectory += cmake::GetCMakeFilesDirectory();
- this->BinaryDirectory += "/CMakeTmp";
+ this->BinaryDirectory += "/CMakeFiles/CMakeTmp";
} else {
// only valid for srcfile signatures
if (!compileDefs.empty()) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"COMPILE_DEFINITIONS specified on a srcdir type TRY_COMPILE");
return -1;
}
if (!copyFile.empty()) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"COPY_FILE specified on a srcdir type TRY_COMPILE");
return -1;
}
}
// make sure the binary directory exists
- cmSystemTools::MakeDirectory(this->BinaryDirectory.c_str());
+ cmSystemTools::MakeDirectory(this->BinaryDirectory);
// do not allow recursive try Compiles
if (this->BinaryDirectory == this->Makefile->GetHomeOutputDirectory()) {
std::ostringstream e;
e << "Attempt at a recursive or nested TRY_COMPILE in directory\n"
<< " " << this->BinaryDirectory << "\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
return -1;
}
@@ -418,23 +512,22 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
// Detect languages to enable.
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
std::set<std::string> testLangs;
- for (std::vector<std::string>::iterator si = sources.begin();
- si != sources.end(); ++si) {
- std::string ext = cmSystemTools::GetFilenameLastExtension(*si);
+ for (std::string const& si : sources) {
+ std::string ext = cmSystemTools::GetFilenameLastExtension(si);
std::string lang = gg->GetLanguageFromExtension(ext.c_str());
if (!lang.empty()) {
testLangs.insert(lang);
} else {
std::ostringstream err;
err << "Unknown extension \"" << ext << "\" for file\n"
- << " " << *si << "\n"
+ << " " << si << "\n"
<< "try_compile() works only for enabled languages. "
<< "Currently these are:\n ";
std::vector<std::string> langs;
gg->GetEnabledLanguages(langs);
err << cmJoin(langs, " ");
err << "\nSee project() command to enable other languages.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, err.str());
+ this->Makefile->IssueMessage(MessageType::FATAL_ERROR, err.str());
return -1;
}
}
@@ -444,7 +537,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
// we need to create a directory and CMakeLists file etc...
// first create the directories
- sourceDirectory = this->BinaryDirectory.c_str();
+ sourceDirectory = this->BinaryDirectory;
// now create a CMakeLists.txt file in that directory
FILE* fout = cmsys::SystemTools::Fopen(outFileName, "w");
@@ -455,7 +548,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
<< " " << outFileName << "\n"
<< cmSystemTools::GetLastSystemError();
/* clang-format on */
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
return -1;
}
@@ -467,12 +560,18 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
fprintf(fout, "set(CMAKE_MODULE_PATH \"%s\")\n", def);
}
+ /* Set MSVC runtime library policy to match our selection. */
+ if (const char* msvcRuntimeLibraryDefault =
+ this->Makefile->GetDefinition(kCMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT)) {
+ fprintf(fout, "cmake_policy(SET CMP0091 %s)\n",
+ *msvcRuntimeLibraryDefault ? "NEW" : "OLD");
+ }
+
std::string projectLangs;
- for (std::set<std::string>::iterator li = testLangs.begin();
- li != testLangs.end(); ++li) {
- projectLangs += " " + *li;
+ for (std::string const& li : testLangs) {
+ projectLangs += " " + li;
std::string rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE";
- std::string rulesOverrideLang = rulesOverrideBase + "_" + *li;
+ std::string rulesOverrideLang = cmStrCat(rulesOverrideBase, "_", li);
if (const char* rulesOverridePath =
this->Makefile->GetDefinition(rulesOverrideLang)) {
fprintf(fout, "set(%s \"%s\")\n", rulesOverrideLang.c_str(),
@@ -484,16 +583,24 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
}
}
fprintf(fout, "project(CMAKE_TRY_COMPILE%s)\n", projectLangs.c_str());
+ if (cmakeInternal == "ABI") {
+ // This is the ABI detection step, also used for implicit includes.
+ // Erase any include_directories() calls from the toolchain file so
+ // that we do not see them as implicit. Our ABI detection source
+ // does not include any system headers anyway.
+ fprintf(fout,
+ "set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES \"\")\n");
+ }
fprintf(fout, "set(CMAKE_VERBOSE_MAKEFILE 1)\n");
- for (std::set<std::string>::iterator li = testLangs.begin();
- li != testLangs.end(); ++li) {
- std::string langFlags = "CMAKE_" + *li + "_FLAGS";
+ for (std::string const& li : testLangs) {
+ std::string langFlags = "CMAKE_" + li + "_FLAGS";
const char* flags = this->Makefile->GetDefinition(langFlags);
- fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li->c_str(),
+ fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li.c_str(),
cmOutputConverter::EscapeForCMake(flags ? flags : "").c_str());
- fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}"
- " ${COMPILE_DEFINITIONS}\")\n",
- li->c_str(), li->c_str());
+ fprintf(fout,
+ "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}"
+ " ${COMPILE_DEFINITIONS}\")\n",
+ li.c_str(), li.c_str());
}
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0066)) {
case cmPolicies::WARN:
@@ -507,7 +614,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
"(e.g. CMAKE_C_FLAGS_DEBUG) in the test project."
;
/* clang-format on */
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
}
case cmPolicies::OLD:
// OLD behavior is to do nothing.
@@ -515,7 +622,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0066));
CM_FALLTHROUGH;
case cmPolicies::NEW: {
@@ -523,9 +630,9 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
static std::string const cfgDefault = "DEBUG";
std::string const cfg =
!tcConfig.empty() ? cmSystemTools::UpperCase(tcConfig) : cfgDefault;
- for (std::set<std::string>::iterator li = testLangs.begin();
- li != testLangs.end(); ++li) {
- std::string const langFlagsCfg = "CMAKE_" + *li + "_FLAGS_" + cfg;
+ for (std::string const& li : testLangs) {
+ std::string const langFlagsCfg =
+ cmStrCat("CMAKE_", li, "_FLAGS_", cfg);
const char* flagsCfg = this->Makefile->GetDefinition(langFlagsCfg);
fprintf(fout, "set(%s %s)\n", langFlagsCfg.c_str(),
cmOutputConverter::EscapeForCMake(flagsCfg ? flagsCfg : "")
@@ -545,7 +652,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
"in the test project."
;
/* clang-format on */
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
}
case cmPolicies::OLD:
// OLD behavior is to do nothing.
@@ -553,7 +660,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0056));
CM_FALLTHROUGH;
case cmPolicies::NEW:
@@ -568,14 +675,17 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
}
break;
}
- fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}"
- " ${EXE_LINKER_FLAGS}\")\n");
+ fprintf(fout,
+ "set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}"
+ " ${EXE_LINKER_FLAGS}\")\n");
fprintf(fout, "include_directories(${INCLUDE_DIRECTORIES})\n");
fprintf(fout, "set(CMAKE_SUPPRESS_REGENERATION 1)\n");
fprintf(fout, "link_directories(${LINK_DIRECTORIES})\n");
// handle any compile flags we need to pass on
if (!compileDefs.empty()) {
- fprintf(fout, "add_definitions(%s)\n", cmJoin(compileDefs, " ").c_str());
+ // Pass using bracket arguments to preserve content.
+ fprintf(fout, "add_definitions([==[%s]==])\n",
+ cmJoin(compileDefs, "]==] [==[").c_str());
}
/* Use a random file name to avoid rapid creation and deletion
@@ -585,12 +695,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
if (!targets.empty()) {
std::string fname = "/" + std::string(targetName) + "Targets.cmake";
- cmExportTryCompileFileGenerator tcfg(gg, targets, this->Makefile);
+ cmExportTryCompileFileGenerator tcfg(gg, targets, this->Makefile,
+ testLangs);
tcfg.SetExportFile((this->BinaryDirectory + fname).c_str());
tcfg.SetConfig(tcConfig);
if (!tcfg.GenerateImportFile()) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
"could not write export file.");
fclose(fout);
return -1;
@@ -616,15 +727,26 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
vars.insert(kCMAKE_SYSROOT);
vars.insert(kCMAKE_SYSROOT_COMPILE);
vars.insert(kCMAKE_SYSROOT_LINK);
+ vars.insert(kCMAKE_Swift_COMPILER_TARGET);
vars.insert(kCMAKE_WARN_DEPRECATED);
+ vars.emplace("CMAKE_MSVC_RUNTIME_LIBRARY"_s);
if (const char* varListStr = this->Makefile->GetDefinition(
kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES)) {
- std::vector<std::string> varList;
- cmSystemTools::ExpandListArgument(varListStr, varList);
+ std::vector<std::string> varList = cmExpandedList(varListStr);
vars.insert(varList.begin(), varList.end());
}
+ if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0083) ==
+ cmPolicies::NEW) {
+ // To ensure full support of PIE, propagate cache variables
+ // driving the link options
+ vars.insert(kCMAKE_C_LINK_PIE_SUPPORTED);
+ vars.insert(kCMAKE_C_LINK_NO_PIE_SUPPORTED);
+ vars.insert(kCMAKE_CXX_LINK_PIE_SUPPORTED);
+ vars.insert(kCMAKE_CXX_LINK_NO_PIE_SUPPORTED);
+ }
+
/* for the TRY_COMPILEs we want to be able to specify the architecture.
So the user can set CMAKE_OSX_ARCHITECTURES to i386;ppc and then set
CMAKE_TRY_COMPILE_OSX_ARCHITECTURES first to i386 and then to ppc to
@@ -636,15 +758,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
kCMAKE_TRY_COMPILE_OSX_ARCHITECTURES)) {
vars.erase(kCMAKE_OSX_ARCHITECTURES);
std::string flag = "-DCMAKE_OSX_ARCHITECTURES=" + std::string(tcArchs);
- cmakeFlags.push_back(flag);
+ cmakeFlags.push_back(std::move(flag));
}
- for (std::set<std::string>::iterator vi = vars.begin(); vi != vars.end();
- ++vi) {
- std::string const& var = *vi;
+ for (std::string const& var : vars) {
if (const char* val = this->Makefile->GetDefinition(var)) {
std::string flag = "-D" + var + "=" + val;
- cmakeFlags.push_back(flag);
+ cmakeFlags.push_back(std::move(flag));
}
}
}
@@ -656,6 +776,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
? "NEW"
: "OLD");
+ /* Set the appropriate policy information for PIE link flags */
+ fprintf(fout, "cmake_policy(SET CMP0083 %s)\n",
+ this->Makefile->GetPolicyStatus(cmPolicies::CMP0083) ==
+ cmPolicies::NEW
+ ? "NEW"
+ : "OLD");
+
if (targetType == cmStateEnums::EXECUTABLE) {
/* Put the executable at a known location (for COPY_FILE). */
fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
@@ -670,28 +797,31 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
/* Create the actual static library. */
fprintf(fout, "add_library(%s STATIC", targetName.c_str());
}
- for (std::vector<std::string>::iterator si = sources.begin();
- si != sources.end(); ++si) {
- fprintf(fout, " \"%s\"", si->c_str());
+ for (std::string const& si : sources) {
+ fprintf(fout, " \"%s\"", si.c_str());
// Add dependencies on any non-temporary sources.
- if (si->find("CMakeTmp") == std::string::npos) {
- this->Makefile->AddCMakeDependFile(*si);
+ if (si.find("CMakeTmp") == std::string::npos) {
+ this->Makefile->AddCMakeDependFile(si);
}
}
fprintf(fout, ")\n");
bool const testC = testLangs.find("C") != testLangs.end();
+ bool const testObjC = testLangs.find("OBJC") != testLangs.end();
bool const testCxx = testLangs.find("CXX") != testLangs.end();
+ bool const testObjCxx = testLangs.find("OBJCXX") != testLangs.end();
bool const testCuda = testLangs.find("CUDA") != testLangs.end();
bool warnCMP0067 = false;
bool honorStandard = true;
- if (!didCStandard && !didCxxStandard && !didCudaStandard &&
- !didCStandardRequired && !didCxxStandardRequired &&
- !didCudaStandardRequired && !didCExtensions && !didCxxExtensions &&
- !didCudaExtensions) {
+ if (!didCStandard && !didCxxStandard && !didObjCStandard &&
+ !didObjCxxStandard && !didCudaStandard && !didCStandardRequired &&
+ !didCxxStandardRequired && !didObjCStandardRequired &&
+ !didObjCxxStandardRequired && !didCudaStandardRequired &&
+ !didCExtensions && !didCxxExtensions && !didObjCExtensions &&
+ !didObjCxxExtensions && !didCudaExtensions) {
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0067)) {
case cmPolicies::WARN:
warnCMP0067 = this->Makefile->PolicyOptionalWarningEnabled(
@@ -704,7 +834,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0067));
case cmPolicies::NEW:
// NEW behavior is to honor the language standard variables.
@@ -714,45 +844,42 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
}
if (honorStandard || warnCMP0067) {
- if (testC) {
- if (!didCStandard) {
- cStandard = this->LookupStdVar("CMAKE_C_STANDARD", warnCMP0067);
- }
- if (!didCStandardRequired) {
- cStandardRequired =
- this->LookupStdVar("CMAKE_C_STANDARD_REQUIRED", warnCMP0067);
- }
- if (!didCExtensions) {
- cExtensions = this->LookupStdVar("CMAKE_C_EXTENSIONS", warnCMP0067);
- }
- }
- if (testCxx) {
- if (!didCxxStandard) {
- cxxStandard = this->LookupStdVar("CMAKE_CXX_STANDARD", warnCMP0067);
- }
- if (!didCxxStandardRequired) {
- cxxStandardRequired =
- this->LookupStdVar("CMAKE_CXX_STANDARD_REQUIRED", warnCMP0067);
- }
- if (!didCxxExtensions) {
- cxxExtensions =
- this->LookupStdVar("CMAKE_CXX_EXTENSIONS", warnCMP0067);
- }
- }
- if (testCuda) {
- if (!didCudaStandard) {
- cudaStandard =
- this->LookupStdVar("CMAKE_CUDA_STANDARD", warnCMP0067);
- }
- if (!didCudaStandardRequired) {
- cudaStandardRequired =
- this->LookupStdVar("CMAKE_CUDA_STANDARD_REQUIRED", warnCMP0067);
- }
- if (!didCudaExtensions) {
- cudaExtensions =
- this->LookupStdVar("CMAKE_CUDA_EXTENSIONS", warnCMP0067);
- }
- }
+
+ auto testLanguage =
+ [&](bool testLang, bool didLangStandard, bool didLangStandardRequired,
+ bool didLangExtensions, std::string& langStandard,
+ std::string& langStandardRequired, std::string& langExtensions,
+ const std::string& lang) {
+ if (testLang) {
+ if (!didLangStandard) {
+ langStandard = this->LookupStdVar(
+ cmStrCat("CMAKE_", lang, "_STANDARD"), warnCMP0067);
+ }
+ if (!didLangStandardRequired) {
+ langStandardRequired = this->LookupStdVar(
+ cmStrCat("CMAKE_", lang, "_STANDARD_REQUIRED"), warnCMP0067);
+ }
+ if (!didLangExtensions) {
+ langExtensions = this->LookupStdVar(
+ cmStrCat("CMAKE_", lang, "_EXTENSIONS"), warnCMP0067);
+ }
+ }
+ };
+
+ testLanguage(testC, didCStandard, didCStandardRequired, didCExtensions,
+ cStandard, cStandardRequired, cExtensions, "C");
+ testLanguage(testObjC, didObjCStandard, didObjCStandardRequired,
+ didObjCExtensions, objcStandard, objcStandardRequired,
+ objcExtensions, "OBJC");
+ testLanguage(testCxx, didCxxStandard, didCxxStandardRequired,
+ didCxxExtensions, cxxStandard, cxxStandardRequired,
+ cxxExtensions, "CXX");
+ testLanguage(testObjCxx, didObjCxxStandard, didObjCxxStandardRequired,
+ didObjCxxExtensions, objcxxStandard, objcxxStandardRequired,
+ objcxxExtensions, "OBJCXX");
+ testLanguage(testCuda, didCudaStandard, didCudaStandardRequired,
+ didCudaExtensions, cudaStandard, cudaStandardRequired,
+ cudaExtensions, "CUDA");
}
if (!this->WarnCMP0067.empty()) {
@@ -763,49 +890,58 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
"is not honoring language standard variables in the test project:\n"
;
/* clang-format on */
- for (std::vector<std::string>::iterator vi = this->WarnCMP0067.begin();
- vi != this->WarnCMP0067.end(); ++vi) {
- w << " " << *vi << "\n";
+ for (std::string const& vi : this->WarnCMP0067) {
+ w << " " << vi << "\n";
}
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
}
- if (testC) {
- if (!cStandard.empty()) {
- writeProperty(fout, targetName, "C_STANDARD", cStandard);
- }
- if (!cStandardRequired.empty()) {
- writeProperty(fout, targetName, "C_STANDARD_REQUIRED",
- cStandardRequired);
- }
- if (!cExtensions.empty()) {
- writeProperty(fout, targetName, "C_EXTENSIONS", cExtensions);
+ auto writeLanguageProperties = [&](bool testLang,
+ const std::string& langStandard,
+ const std::string& langStandardRequired,
+ const std::string& langExtensions,
+ const std::string& lang) {
+ if (testLang) {
+ if (!langStandard.empty()) {
+ writeProperty(fout, targetName, cmStrCat(lang, "_STANDARD"),
+ langStandard);
+ }
+ if (!langStandardRequired.empty()) {
+ writeProperty(fout, targetName, cmStrCat(lang, "_STANDARD_REQUIRED"),
+ langStandardRequired);
+ }
+ if (!langExtensions.empty()) {
+ writeProperty(fout, targetName, cmStrCat(lang, "_EXTENSIONS"),
+ langExtensions);
+ }
}
- }
+ };
- if (testCxx) {
- if (!cxxStandard.empty()) {
- writeProperty(fout, targetName, "CXX_STANDARD", cxxStandard);
- }
- if (!cxxStandardRequired.empty()) {
- writeProperty(fout, targetName, "CXX_STANDARD_REQUIRED",
- cxxStandardRequired);
- }
- if (!cxxExtensions.empty()) {
- writeProperty(fout, targetName, "CXX_EXTENSIONS", cxxExtensions);
- }
- }
+ writeLanguageProperties(testC, cStandard, cStandardRequired, cExtensions,
+ "C");
+ writeLanguageProperties(testObjC, objcStandard, objcStandardRequired,
+ objcExtensions, "OBJC");
+ writeLanguageProperties(testCxx, cxxStandard, cxxStandardRequired,
+ cxxExtensions, "CXX");
+ writeLanguageProperties(testObjCxx, objcxxStandard, objcxxStandardRequired,
+ objcxxExtensions, "OBJCXX");
+ writeLanguageProperties(testCuda, cudaStandard, cudaStandardRequired,
+ cudaExtensions, "CUDA");
- if (testCuda) {
- if (!cudaStandard.empty()) {
- writeProperty(fout, targetName, "CUDA_STANDARD", cudaStandard);
- }
- if (!cudaStandardRequired.empty()) {
- writeProperty(fout, targetName, "CUDA_STANDARD_REQUIRED",
- cudaStandardRequired);
+ if (!linkOptions.empty()) {
+ std::vector<std::string> options;
+ options.reserve(linkOptions.size());
+ for (const auto& option : linkOptions) {
+ options.emplace_back(cmOutputConverter::EscapeForCMake(option));
}
- if (!cudaExtensions.empty()) {
- writeProperty(fout, targetName, "CUDA_EXTENSIONS", cudaExtensions);
+
+ if (targetType == cmStateEnums::STATIC_LIBRARY) {
+ fprintf(fout,
+ "set_property(TARGET %s PROPERTY STATIC_LIBRARY_OPTIONS %s)\n",
+ targetName.c_str(), cmJoin(options, " ").c_str());
+ } else {
+ fprintf(fout, "target_link_options(%s PRIVATE %s)\n",
+ targetName.c_str(), cmJoin(options, " ").c_str());
}
}
@@ -820,13 +956,24 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
projectName = "CMAKE_TRY_COMPILE";
}
+ if (this->Makefile->GetState()->UseGhsMultiIDE()) {
+ // Forward the GHS variables to the inner project cache.
+ for (std::string const& var : ghs_platform_vars) {
+ if (const char* val = this->Makefile->GetDefinition(var)) {
+ std::string flag = "-D" + var + "=" + "'" + val + "'";
+ cmakeFlags.push_back(std::move(flag));
+ }
+ }
+ }
+
bool erroroc = cmSystemTools::GetErrorOccuredFlag();
cmSystemTools::ResetErrorOccuredFlag();
std::string output;
// actually do the try compile now that everything is setup
int res = this->Makefile->TryCompile(
sourceDirectory, this->BinaryDirectory, projectName, targetName,
- this->SrcFileSignature, &cmakeFlags, output);
+ this->SrcFileSignature, cmake::NO_BUILD_PARALLEL_LEVEL, &cmakeFlags,
+ output);
if (erroroc) {
cmSystemTools::SetErrorOccured();
}
@@ -837,7 +984,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
cmStateEnums::INTERNAL);
if (!outputVariable.empty()) {
- this->Makefile->AddDefinition(outputVariable, output.c_str());
+ this->Makefile->AddDefinition(outputVariable, output);
}
if (this->SrcFileSignature) {
@@ -855,10 +1002,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
<< " '" << copyFile << "'\n";
/* clang-format on */
if (!this->FindErrorMessage.empty()) {
- emsg << this->FindErrorMessage.c_str();
+ emsg << this->FindErrorMessage;
}
if (copyFileError.empty()) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, emsg.str());
+ this->Makefile->IssueMessage(MessageType::FATAL_ERROR, emsg.str());
return -1;
}
copyFileErrorMessage = emsg.str();
@@ -866,24 +1013,22 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
}
if (!copyFileError.empty()) {
- this->Makefile->AddDefinition(copyFileError,
- copyFileErrorMessage.c_str());
+ this->Makefile->AddDefinition(copyFileError, copyFileErrorMessage);
}
}
return res;
}
-void cmCoreTryCompile::CleanupFiles(const char* binDir)
+void cmCoreTryCompile::CleanupFiles(std::string const& binDir)
{
- if (!binDir) {
+ if (binDir.empty()) {
return;
}
- std::string bdir = binDir;
- if (bdir.find("CMakeTmp") == std::string::npos) {
+ if (binDir.find("CMakeTmp") == std::string::npos) {
cmSystemTools::Error(
"TRY_COMPILE attempt to remove -rf directory that does not contain "
- "CMakeTmp:",
+ "CMakeTmp:" +
binDir);
return;
}
@@ -898,7 +1043,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
std::string const fullPath =
std::string(binDir).append("/").append(fileName);
if (cmSystemTools::FileIsDirectory(fullPath)) {
- this->CleanupFiles(fullPath.c_str());
+ this->CleanupFiles(fullPath);
cmSystemTools::RemoveADirectory(fullPath);
} else {
#ifdef _WIN32
@@ -906,9 +1051,8 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
// cannot delete them immediately. Try a few times.
cmSystemTools::WindowsFileRetry retry =
cmSystemTools::GetWindowsFileRetry();
- while (!cmSystemTools::RemoveFile(fullPath.c_str()) &&
- --retry.Count &&
- cmSystemTools::FileExists(fullPath.c_str())) {
+ while (!cmSystemTools::RemoveFile(fullPath) && --retry.Count &&
+ cmSystemTools::FileExists(fullPath)) {
cmSystemTools::Delay(retry.Delay);
}
if (retry.Count == 0)
@@ -928,8 +1072,8 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
void cmCoreTryCompile::FindOutputFile(const std::string& targetName,
cmStateEnums::TargetType targetType)
{
- this->FindErrorMessage = "";
- this->OutputFile = "";
+ this->FindErrorMessage.clear();
+ this->OutputFile.clear();
std::string tmpOutputFile = "/";
if (targetType == cmStateEnums::EXECUTABLE) {
tmpOutputFile += targetName;
@@ -947,29 +1091,31 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName,
// a list of directories where to search for the compilation result
// at first directly in the binary dir
std::vector<std::string> searchDirs;
- searchDirs.push_back("");
+ searchDirs.emplace_back();
const char* config =
this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
// if a config was specified try that first
if (config && config[0]) {
- std::string tmp = "/";
- tmp += config;
- searchDirs.push_back(tmp);
+ std::string tmp = cmStrCat('/', config);
+ searchDirs.push_back(std::move(tmp));
}
- searchDirs.push_back("/Debug");
+ searchDirs.emplace_back("/Debug");
#if defined(__APPLE__)
- std::string app = "/Debug/" + targetName + ".app";
- searchDirs.push_back(app);
+ std::string app = "/" + targetName + ".app";
+ if (config && config[0]) {
+ std::string tmp = cmStrCat('/', config, app);
+ searchDirs.push_back(std::move(tmp));
+ }
+ std::string tmp = "/Debug" + app;
+ searchDirs.emplace_back(std::move(tmp));
+ searchDirs.push_back(std::move(app));
#endif
- searchDirs.push_back("/Development");
-
- for (std::vector<std::string>::const_iterator it = searchDirs.begin();
- it != searchDirs.end(); ++it) {
- std::string command = this->BinaryDirectory;
- command += *it;
- command += tmpOutputFile;
- if (cmSystemTools::FileExists(command.c_str())) {
+ searchDirs.emplace_back("/Development");
+
+ for (std::string const& sdir : searchDirs) {
+ std::string command = cmStrCat(this->BinaryDirectory, sdir, tmpOutputFile);
+ if (cmSystemTools::FileExists(command)) {
this->OutputFile = cmSystemTools::CollapseFullPath(command);
return;
}
diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h
index 365154dfb..ae714a63a 100644
--- a/Source/cmCoreTryCompile.h
+++ b/Source/cmCoreTryCompile.h
@@ -33,7 +33,7 @@ protected:
* This way we do not have to rely on the timing and
* dependencies of makefiles.
*/
- void CleanupFiles(const char* binDir);
+ void CleanupFiles(std::string const& binDir);
/**
* This tries to find the (executable) file created by
@@ -46,7 +46,7 @@ protected:
std::string BinaryDirectory;
std::string OutputFile;
std::string FindErrorMessage;
- bool SrcFileSignature;
+ bool SrcFileSignature = false;
private:
std::vector<std::string> WarnCMP0067;
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index 69532e61b..9d492ba84 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -4,22 +4,21 @@
#include <algorithm>
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
-// cmCreateTestSourceList
-bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmCreateTestSourceList(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("called with wrong number of arguments.");
+ status.SetError("called with wrong number of arguments.");
return false;
}
- std::vector<std::string>::const_iterator i = args.begin();
+ auto i = args.begin();
std::string extraInclude;
std::string function;
std::vector<std::string> tests;
@@ -28,20 +27,17 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
if (*i == "EXTRA_INCLUDE") {
++i;
if (i == args.end()) {
- this->SetError("incorrect arguments to EXTRA_INCLUDE");
+ status.SetError("incorrect arguments to EXTRA_INCLUDE");
return false;
}
- extraInclude = "#include \"";
- extraInclude += *i;
- extraInclude += "\"\n";
+ extraInclude = cmStrCat("#include \"", *i, "\"\n");
} else if (*i == "FUNCTION") {
++i;
if (i == args.end()) {
- this->SetError("incorrect arguments to FUNCTION");
+ status.SetError("incorrect arguments to FUNCTION");
return false;
}
- function = *i;
- function += "(&ac, &av);\n";
+ function = cmStrCat(*i, "(&ac, &av);\n");
} else {
tests.push_back(*i);
}
@@ -56,13 +52,12 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
// Name of the test driver
// make sure they specified an extension
if (cmSystemTools::GetFilenameExtension(*i).size() < 2) {
- this->SetError(
+ status.SetError(
"You must specify a file extension for the test driver file.");
return false;
}
- std::string driver = this->Makefile->GetCurrentBinaryDirectory();
- driver += "/";
- driver += *i;
+ cmMakefile& mf = status.GetMakefile();
+ std::string driver = cmStrCat(mf.GetCurrentBinaryDirectory(), '/', *i);
++i;
std::string configFile = cmSystemTools::GetCMakeRoot();
@@ -70,7 +65,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
configFile += "/Templates/TestDriver.cxx.in";
// Create the test driver file
- std::vector<std::string>::const_iterator testsBegin = i;
+ auto testsBegin = i;
std::vector<std::string> tests_func_name;
// The rest of the arguments consist of a list of test source files.
@@ -124,37 +119,32 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
numTests++;
}
if (!extraInclude.empty()) {
- this->Makefile->AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES",
- extraInclude.c_str());
+ mf.AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES", extraInclude);
}
if (!function.empty()) {
- this->Makefile->AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION",
- function.c_str());
+ mf.AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION", function);
}
- this->Makefile->AddDefinition("CMAKE_FORWARD_DECLARE_TESTS",
- forwardDeclareCode.c_str());
- this->Makefile->AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES",
- functionMapCode.c_str());
+ mf.AddDefinition("CMAKE_FORWARD_DECLARE_TESTS", forwardDeclareCode);
+ mf.AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES", functionMapCode);
bool res = true;
- if (!this->Makefile->ConfigureFile(configFile.c_str(), driver.c_str(), false,
- true, false)) {
+ if (!mf.ConfigureFile(configFile, driver, false, true, false)) {
res = false;
}
// Construct the source list.
std::string sourceListValue;
{
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver);
+ cmSourceFile* sf = mf.GetOrCreateSource(driver);
sf->SetProperty("ABSTRACT", "0");
sourceListValue = args[1];
}
for (i = testsBegin; i != tests.end(); ++i) {
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
+ cmSourceFile* sf = mf.GetOrCreateSource(*i);
sf->SetProperty("ABSTRACT", "0");
sourceListValue += ";";
sourceListValue += *i;
}
- this->Makefile->AddDefinition(sourceList, sourceListValue.c_str());
+ mf.AddDefinition(sourceList, sourceListValue);
return res;
}
diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h
index f1f1e4b8a..19503f43d 100644
--- a/Source/cmCreateTestSourceList.h
+++ b/Source/cmCreateTestSourceList.h
@@ -3,34 +3,14 @@
#ifndef cmCreateTestSourceList_h
#define cmCreateTestSourceList_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmCreateTestSourceList
- * \brief Test driver generation command
- *
- */
-
-class cmCreateTestSourceList : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmCreateTestSourceList; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmCreateTestSourceList(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx
index 7995b2cb3..dc7d939c9 100644
--- a/Source/cmCryptoHash.cxx
+++ b/Source/cmCryptoHash.cxx
@@ -2,10 +2,12 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCryptoHash.h"
+#include <cm/memory>
+
+#include "cmsys/FStream.hxx"
+
#include "cm_kwiml.h"
#include "cm_rhash.h"
-#include "cmsys/FStream.hxx"
-#include <string.h>
static unsigned int const cmCryptoHashAlgoToId[] = {
/* clang-format needs this comment to break after the opening brace */
@@ -43,39 +45,39 @@ cmCryptoHash::~cmCryptoHash()
rhash_free(this->CTX);
}
-CM_AUTO_PTR<cmCryptoHash> cmCryptoHash::New(const char* algo)
+std::unique_ptr<cmCryptoHash> cmCryptoHash::New(cm::string_view algo)
{
- if (strcmp(algo, "MD5") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoMD5));
+ if (algo == "MD5") {
+ return cm::make_unique<cmCryptoHash>(AlgoMD5);
}
- if (strcmp(algo, "SHA1") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA1));
+ if (algo == "SHA1") {
+ return cm::make_unique<cmCryptoHash>(AlgoSHA1);
}
- if (strcmp(algo, "SHA224") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA224));
+ if (algo == "SHA224") {
+ return cm::make_unique<cmCryptoHash>(AlgoSHA224);
}
- if (strcmp(algo, "SHA256") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA256));
+ if (algo == "SHA256") {
+ return cm::make_unique<cmCryptoHash>(AlgoSHA256);
}
- if (strcmp(algo, "SHA384") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA384));
+ if (algo == "SHA384") {
+ return cm::make_unique<cmCryptoHash>(AlgoSHA384);
}
- if (strcmp(algo, "SHA512") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA512));
+ if (algo == "SHA512") {
+ return cm::make_unique<cmCryptoHash>(AlgoSHA512);
}
- if (strcmp(algo, "SHA3_224") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_224));
+ if (algo == "SHA3_224") {
+ return cm::make_unique<cmCryptoHash>(AlgoSHA3_224);
}
- if (strcmp(algo, "SHA3_256") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_256));
+ if (algo == "SHA3_256") {
+ return cm::make_unique<cmCryptoHash>(AlgoSHA3_256);
}
- if (strcmp(algo, "SHA3_384") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_384));
+ if (algo == "SHA3_384") {
+ return cm::make_unique<cmCryptoHash>(AlgoSHA3_384);
}
- if (strcmp(algo, "SHA3_512") == 0) {
- return CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(AlgoSHA3_512));
+ if (algo == "SHA3_512") {
+ return cm::make_unique<cmCryptoHash>(AlgoSHA3_512);
}
- return CM_AUTO_PTR<cmCryptoHash>(CM_NULLPTR);
+ return std::unique_ptr<cmCryptoHash>(nullptr);
}
bool cmCryptoHash::IntFromHexDigit(char input, char& output)
@@ -103,20 +105,18 @@ std::string cmCryptoHash::ByteHashToString(
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
std::string res;
- for (std::vector<unsigned char>::const_iterator vit = hash.begin();
- vit != hash.end(); ++vit) {
- res.push_back(hex[(*vit) >> 4]);
- res.push_back(hex[(*vit) & 0xF]);
+ res.reserve(hash.size() * 2);
+ for (unsigned char v : hash) {
+ res.push_back(hex[v >> 4]);
+ res.push_back(hex[v & 0xF]);
}
return res;
}
-std::vector<unsigned char> cmCryptoHash::ByteHashString(
- const std::string& input)
+std::vector<unsigned char> cmCryptoHash::ByteHashString(cm::string_view input)
{
this->Initialize();
- this->Append(reinterpret_cast<unsigned char const*>(input.c_str()),
- static_cast<int>(input.size()));
+ this->Append(input);
return this->Finalize();
}
@@ -154,7 +154,7 @@ std::vector<unsigned char> cmCryptoHash::ByteHashFile(const std::string& file)
return std::vector<unsigned char>();
}
-std::string cmCryptoHash::HashString(const std::string& input)
+std::string cmCryptoHash::HashString(cm::string_view input)
{
return ByteHashToString(this->ByteHashString(input));
}
@@ -174,9 +174,9 @@ void cmCryptoHash::Append(void const* buf, size_t sz)
rhash_update(this->CTX, buf, sz);
}
-void cmCryptoHash::Append(std::string const& str)
+void cmCryptoHash::Append(cm::string_view input)
{
- this->Append(str.c_str(), str.size());
+ rhash_update(this->CTX, input.data(), input.size());
}
std::vector<unsigned char> cmCryptoHash::Finalize()
diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h
index c380d85ff..f27bb5db4 100644
--- a/Source/cmCryptoHash.h
+++ b/Source/cmCryptoHash.h
@@ -3,21 +3,20 @@
#ifndef cmCryptoHash_h
#define cmCryptoHash_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include <stddef.h>
+#include <cstddef>
+#include <memory>
#include <string>
#include <vector>
-#include "cm_auto_ptr.hxx"
+#include <cm/string_view>
/**
* @brief Abstract base class for cryptographic hash generators
*/
class cmCryptoHash
{
- CM_DISABLE_COPY(cmCryptoHash)
-
public:
enum Algo
{
@@ -36,13 +35,16 @@ public:
cmCryptoHash(Algo algo);
~cmCryptoHash();
+ cmCryptoHash(cmCryptoHash const&) = delete;
+ cmCryptoHash& operator=(cmCryptoHash const&) = delete;
+
/// @brief Returns a new hash generator of the requested type
/// @arg algo Hash type name. Supported hash types are
/// MD5, SHA1, SHA224, SHA256, SHA384, SHA512,
/// SHA3_224, SHA3_256, SHA3_384, SHA3_512
/// @return A valid auto pointer if algo is supported or
/// an invalid/NULL pointer otherwise
- static CM_AUTO_PTR<cmCryptoHash> New(const char* algo);
+ static std::unique_ptr<cmCryptoHash> New(cm::string_view algo);
/// @brief Converts a hex character to its binary value (4 bits)
/// @arg input Hex character [0-9a-fA-F].
@@ -55,7 +57,7 @@ public:
/// @brief Calculates a binary hash from string input data
/// @return Binary hash vector
- std::vector<unsigned char> ByteHashString(const std::string& input);
+ std::vector<unsigned char> ByteHashString(cm::string_view input);
/// @brief Calculates a binary hash from file content
/// @see ByteHashString()
@@ -65,7 +67,7 @@ public:
/// @brief Calculates a hash string from string input data
/// @return Sequence of hex characters pairs for each byte of the binary hash
- std::string HashString(const std::string& input);
+ std::string HashString(cm::string_view input);
/// @brief Calculates a hash string from file content
/// @see HashString()
@@ -75,7 +77,7 @@ public:
void Initialize();
void Append(void const*, size_t);
- void Append(std::string const& str);
+ void Append(cm::string_view input);
std::vector<unsigned char> Finalize();
std::string FinalizeHex();
diff --git a/Source/cmCurl.cxx b/Source/cmCurl.cxx
index 341b8c077..233790e54 100644
--- a/Source/cmCurl.cxx
+++ b/Source/cmCurl.cxx
@@ -2,25 +2,26 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCurl.h"
-#include "cmThirdParty.h"
-
#if !defined(CMAKE_USE_SYSTEM_CURL) && !defined(_WIN32) && \
!defined(__APPLE__) && !defined(CURL_CA_BUNDLE) && !defined(CURL_CA_PATH)
-#define CMAKE_FIND_CAFILE
-#include "cmSystemTools.h"
+# define CMAKE_FIND_CAFILE
+# include "cmSystemTools.h"
#endif
+#include "cmStringAlgorithms.h"
// curl versions before 7.21.5 did not provide this error code
#if defined(LIBCURL_VERSION_NUM) && LIBCURL_VERSION_NUM < 0x071505
-#define CURLE_NOT_BUILT_IN 4
+# define CURLE_NOT_BUILT_IN 4
#endif
#define check_curl_result(result, errstr) \
- if ((result) != CURLE_OK && (result) != CURLE_NOT_BUILT_IN) { \
- e += e.empty() ? "" : "\n"; \
- e += (errstr); \
- e += ::curl_easy_strerror(result); \
- }
+ do { \
+ if ((result) != CURLE_OK && (result) != CURLE_NOT_BUILT_IN) { \
+ e += e.empty() ? "" : "\n"; \
+ e += (errstr); \
+ e += ::curl_easy_strerror(result); \
+ } \
+ } while (false)
std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile)
{
@@ -30,29 +31,67 @@ std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile)
check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
}
#ifdef CMAKE_FIND_CAFILE
-#define CMAKE_CAFILE_FEDORA "/etc/pki/tls/certs/ca-bundle.crt"
+# define CMAKE_CAFILE_FEDORA "/etc/pki/tls/certs/ca-bundle.crt"
else if (cmSystemTools::FileExists(CMAKE_CAFILE_FEDORA, true)) {
::CURLcode res =
::curl_easy_setopt(curl, CURLOPT_CAINFO, CMAKE_CAFILE_FEDORA);
check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
}
-#undef CMAKE_CAFILE_FEDORA
+# undef CMAKE_CAFILE_FEDORA
else {
-#define CMAKE_CAFILE_COMMON "/etc/ssl/certs/ca-certificates.crt"
+# define CMAKE_CAFILE_COMMON "/etc/ssl/certs/ca-certificates.crt"
if (cmSystemTools::FileExists(CMAKE_CAFILE_COMMON, true)) {
::CURLcode res =
::curl_easy_setopt(curl, CURLOPT_CAINFO, CMAKE_CAFILE_COMMON);
check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
}
-#undef CMAKE_CAFILE_COMMON
-#define CMAKE_CAPATH_COMMON "/etc/ssl/certs"
+# undef CMAKE_CAFILE_COMMON
+# define CMAKE_CAPATH_COMMON "/etc/ssl/certs"
if (cmSystemTools::FileIsDirectory(CMAKE_CAPATH_COMMON)) {
::CURLcode res =
::curl_easy_setopt(curl, CURLOPT_CAPATH, CMAKE_CAPATH_COMMON);
check_curl_result(res, "Unable to set TLS/SSL Verify CAPATH: ");
}
-#undef CMAKE_CAPATH_COMMON
+# undef CMAKE_CAPATH_COMMON
}
#endif
return e;
}
+
+std::string cmCurlSetNETRCOption(::CURL* curl, const std::string& netrc_level,
+ const std::string& netrc_file)
+{
+ std::string e;
+ CURL_NETRC_OPTION curl_netrc_level = CURL_NETRC_LAST;
+ ::CURLcode res;
+
+ if (!netrc_level.empty()) {
+ if (netrc_level == "OPTIONAL") {
+ curl_netrc_level = CURL_NETRC_OPTIONAL;
+ } else if (netrc_level == "REQUIRED") {
+ curl_netrc_level = CURL_NETRC_REQUIRED;
+ } else if (netrc_level == "IGNORED") {
+ curl_netrc_level = CURL_NETRC_IGNORED;
+ } else {
+ e = cmStrCat("NETRC accepts OPTIONAL, IGNORED or REQUIRED but got: ",
+ netrc_level);
+ return e;
+ }
+ }
+
+ if (curl_netrc_level != CURL_NETRC_LAST &&
+ curl_netrc_level != CURL_NETRC_IGNORED) {
+ res = ::curl_easy_setopt(curl, CURLOPT_NETRC, curl_netrc_level);
+ check_curl_result(res, "Unable to set netrc level: ");
+ if (!e.empty()) {
+ return e;
+ }
+
+ // check to see if a .netrc file has been specified
+ if (!netrc_file.empty()) {
+ res = ::curl_easy_setopt(curl, CURLOPT_NETRC_FILE, netrc_file.c_str());
+ check_curl_result(res, "Unable to set .netrc file path : ");
+ }
+ }
+ return e;
+}
diff --git a/Source/cmCurl.h b/Source/cmCurl.h
index a2fa4b1c0..cb73ce631 100644
--- a/Source/cmCurl.h
+++ b/Source/cmCurl.h
@@ -3,11 +3,14 @@
#ifndef cmCurl_h
#define cmCurl_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cm_curl.h"
#include <string>
-std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile = CM_NULLPTR);
+#include "cm_curl.h"
+
+std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile = nullptr);
+std::string cmCurlSetNETRCOption(::CURL* curl, const std::string& netrc_level,
+ const std::string& netrc_file);
#endif
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx
index 5e377b574..09d269b20 100644
--- a/Source/cmCustomCommand.cxx
+++ b/Source/cmCustomCommand.cxx
@@ -2,38 +2,25 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCustomCommand.h"
-#include "cmMakefile.h"
-
-#include "cmConfigure.h"
+#include <utility>
-cmCustomCommand::cmCustomCommand()
- : Backtrace()
-{
- this->HaveComment = false;
- this->EscapeOldStyle = true;
- this->EscapeAllowMakeVars = false;
- this->UsesTerminal = false;
- this->CommandExpandLists = false;
-}
+#include "cmAlgorithms.h"
+#include "cmMakefile.h"
cmCustomCommand::cmCustomCommand(cmMakefile const* mf,
- const std::vector<std::string>& outputs,
- const std::vector<std::string>& byproducts,
- const std::vector<std::string>& depends,
- const cmCustomCommandLines& commandLines,
+ std::vector<std::string> outputs,
+ std::vector<std::string> byproducts,
+ std::vector<std::string> depends,
+ cmCustomCommandLines commandLines,
const char* comment,
const char* workingDirectory)
- : Outputs(outputs)
- , Byproducts(byproducts)
- , Depends(depends)
- , CommandLines(commandLines)
- , Backtrace()
+ : Outputs(std::move(outputs))
+ , Byproducts(std::move(byproducts))
+ , Depends(std::move(depends))
+ , CommandLines(std::move(commandLines))
, Comment(comment ? comment : "")
, WorkingDirectory(workingDirectory ? workingDirectory : "")
- , HaveComment(comment != CM_NULLPTR)
- , EscapeAllowMakeVars(false)
- , EscapeOldStyle(true)
- , CommandExpandLists(false)
+ , HaveComment(comment != nullptr)
{
if (mf) {
this->Backtrace = mf->GetBacktrace();
@@ -62,19 +49,18 @@ const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const
const char* cmCustomCommand::GetComment() const
{
- const char* no_comment = CM_NULLPTR;
+ const char* no_comment = nullptr;
return this->HaveComment ? this->Comment.c_str() : no_comment;
}
void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
{
- this->CommandLines.insert(this->CommandLines.end(), commandLines.begin(),
- commandLines.end());
+ cmAppend(this->CommandLines, commandLines);
}
void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
{
- this->Depends.insert(this->Depends.end(), depends.begin(), depends.end());
+ cmAppend(this->Depends, depends);
}
bool cmCustomCommand::GetEscapeOldStyle() const
@@ -102,21 +88,19 @@ cmListFileBacktrace const& cmCustomCommand::GetBacktrace() const
return this->Backtrace;
}
-cmCustomCommand::ImplicitDependsList const&
-cmCustomCommand::GetImplicitDepends() const
+cmImplicitDependsList const& cmCustomCommand::GetImplicitDepends() const
{
return this->ImplicitDepends;
}
-void cmCustomCommand::SetImplicitDepends(ImplicitDependsList const& l)
+void cmCustomCommand::SetImplicitDepends(cmImplicitDependsList const& l)
{
this->ImplicitDepends = l;
}
-void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l)
+void cmCustomCommand::AppendImplicitDepends(cmImplicitDependsList const& l)
{
- this->ImplicitDepends.insert(this->ImplicitDepends.end(), l.begin(),
- l.end());
+ cmAppend(this->ImplicitDepends, l);
}
bool cmCustomCommand::GetUsesTerminal() const
@@ -148,3 +132,13 @@ void cmCustomCommand::SetDepfile(const std::string& depfile)
{
this->Depfile = depfile;
}
+
+const std::string& cmCustomCommand::GetJobPool() const
+{
+ return this->JobPool;
+}
+
+void cmCustomCommand::SetJobPool(const std::string& job_pool)
+{
+ this->JobPool = job_pool;
+}
diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h
index 9e82f2505..4689aceea 100644
--- a/Source/cmCustomCommand.h
+++ b/Source/cmCustomCommand.h
@@ -5,15 +5,20 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmCustomCommandLines.h"
-#include "cmListFileCache.h"
-
#include <string>
#include <utility>
#include <vector>
+#include "cmCustomCommandLines.h"
+#include "cmListFileCache.h"
+
class cmMakefile;
+class cmImplicitDependsList
+ : public std::vector<std::pair<std::string, std::string>>
+{
+};
+
/** \class cmCustomCommand
* \brief A class to encapsulate a custom command
*
@@ -22,16 +27,12 @@ class cmMakefile;
class cmCustomCommand
{
public:
- /** Default and copy constructors for STL containers. */
- cmCustomCommand();
-
/** Main constructor specifies all information for the command. */
- cmCustomCommand(cmMakefile const* mf,
- const std::vector<std::string>& outputs,
- const std::vector<std::string>& byproducts,
- const std::vector<std::string>& depends,
- const cmCustomCommandLines& commandLines,
- const char* comment, const char* workingDirectory);
+ cmCustomCommand(cmMakefile const* mf, std::vector<std::string> outputs,
+ std::vector<std::string> byproducts,
+ std::vector<std::string> depends,
+ cmCustomCommandLines commandLines, const char* comment,
+ const char* workingDirectory);
/** Get the output file produced by the command. */
const std::vector<std::string>& GetOutputs() const;
@@ -72,13 +73,9 @@ public:
/** Backtrace of the command that created this custom command. */
cmListFileBacktrace const& GetBacktrace() const;
- typedef std::pair<std::string, std::string> ImplicitDependsPair;
- class ImplicitDependsList : public std::vector<ImplicitDependsPair>
- {
- };
- void SetImplicitDepends(ImplicitDependsList const&);
- void AppendImplicitDepends(ImplicitDependsList const&);
- ImplicitDependsList const& GetImplicitDepends() const;
+ void SetImplicitDepends(cmImplicitDependsList const&);
+ void AppendImplicitDepends(cmImplicitDependsList const&);
+ cmImplicitDependsList const& GetImplicitDepends() const;
/** Set/Get whether this custom command should be given access to the
real console (if possible). */
@@ -93,21 +90,26 @@ public:
const std::string& GetDepfile() const;
void SetDepfile(const std::string& depfile);
+ /** Set/Get the job_pool (used by the Ninja generator) */
+ const std::string& GetJobPool() const;
+ void SetJobPool(const std::string& job_pool);
+
private:
std::vector<std::string> Outputs;
std::vector<std::string> Byproducts;
std::vector<std::string> Depends;
cmCustomCommandLines CommandLines;
cmListFileBacktrace Backtrace;
- ImplicitDependsList ImplicitDepends;
+ cmImplicitDependsList ImplicitDepends;
std::string Comment;
std::string WorkingDirectory;
std::string Depfile;
- bool HaveComment;
- bool EscapeAllowMakeVars;
- bool EscapeOldStyle;
- bool UsesTerminal;
- bool CommandExpandLists;
+ std::string JobPool;
+ bool HaveComment = false;
+ bool EscapeAllowMakeVars = false;
+ bool EscapeOldStyle = true;
+ bool UsesTerminal = false;
+ bool CommandExpandLists = false;
};
#endif
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 67213ecaa..c1f412df8 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -2,53 +2,94 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCustomCommandGenerator.h"
+#include <cstddef>
+#include <memory>
+#include <utility>
+
+#include "cmAlgorithms.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
-#include "cmOutputConverter.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
-#include "cmConfigure.h"
+namespace {
+void AppendPaths(const std::vector<std::string>& inputs,
+ cmGeneratorExpression const& ge, cmLocalGenerator* lg,
+ std::string const& config, std::vector<std::string>& output)
+{
+ for (std::string const& in : inputs) {
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(in);
+ std::vector<std::string> result =
+ cmExpandedList(cge->Evaluate(lg, config));
+ for (std::string& it : result) {
+ cmSystemTools::ConvertToUnixSlashes(it);
+ if (cmSystemTools::FileIsFullPath(it)) {
+ it = cmSystemTools::CollapseFullPath(it);
+ }
+ }
+ cmAppend(output, result);
+ }
+}
+}
cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
- const std::string& config,
+ std::string config,
cmLocalGenerator* lg)
: CC(cc)
- , Config(config)
+ , Config(std::move(config))
, LG(lg)
, OldStyle(cc.GetEscapeOldStyle())
, MakeVars(cc.GetEscapeAllowMakeVars())
- , GE(new cmGeneratorExpression(cc.GetBacktrace()))
- , DependsDone(false)
+ , EmulatorsWithArguments(cc.GetCommandLines().size())
{
+ cmGeneratorExpression ge(cc.GetBacktrace());
+
const cmCustomCommandLines& cmdlines = this->CC.GetCommandLines();
- for (cmCustomCommandLines::const_iterator cmdline = cmdlines.begin();
- cmdline != cmdlines.end(); ++cmdline) {
+ for (cmCustomCommandLine const& cmdline : cmdlines) {
cmCustomCommandLine argv;
- for (cmCustomCommandLine::const_iterator clarg = cmdline->begin();
- clarg != cmdline->end(); ++clarg) {
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(*clarg);
+ for (std::string const& clarg : cmdline) {
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(clarg);
std::string parsed_arg = cge->Evaluate(this->LG, this->Config);
if (this->CC.GetCommandExpandLists()) {
- std::vector<std::string> ExpandedArg;
- cmSystemTools::ExpandListArgument(parsed_arg, ExpandedArg);
- argv.insert(argv.end(), ExpandedArg.begin(), ExpandedArg.end());
+ cmAppend(argv, cmExpandedList(parsed_arg));
} else {
- argv.push_back(parsed_arg);
+ argv.push_back(std::move(parsed_arg));
}
}
- this->CommandLines.push_back(argv);
+
+ // Later code assumes at least one entry exists, but expanding
+ // lists on an empty command may have left this empty.
+ // FIXME: Should we define behavior for removing empty commands?
+ if (argv.empty()) {
+ argv.emplace_back();
+ }
+
+ this->CommandLines.push_back(std::move(argv));
+ }
+
+ AppendPaths(cc.GetByproducts(), ge, this->LG, this->Config,
+ this->Byproducts);
+ AppendPaths(cc.GetDepends(), ge, this->LG, this->Config, this->Depends);
+
+ const std::string& workingdirectory = this->CC.GetWorkingDirectory();
+ if (!workingdirectory.empty()) {
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
+ ge.Parse(workingdirectory);
+ this->WorkingDirectory = cge->Evaluate(this->LG, this->Config);
+ // Convert working directory to a full path.
+ if (!this->WorkingDirectory.empty()) {
+ std::string const& build_dir = this->LG->GetCurrentBinaryDirectory();
+ this->WorkingDirectory =
+ cmSystemTools::CollapseFullPath(this->WorkingDirectory, build_dir);
+ }
}
-}
-cmCustomCommandGenerator::~cmCustomCommandGenerator()
-{
- delete this->GE;
+ this->FillEmulatorsWithArguments();
}
unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const
@@ -56,19 +97,36 @@ unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const
return static_cast<unsigned int>(this->CC.GetCommandLines().size());
}
-const char* cmCustomCommandGenerator::GetCrossCompilingEmulator(
- unsigned int c) const
+void cmCustomCommandGenerator::FillEmulatorsWithArguments()
{
if (!this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING")) {
- return CM_NULLPTR;
+ return;
}
- std::string const& argv0 = this->CommandLines[c][0];
- cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0);
- if (target && target->GetType() == cmStateEnums::EXECUTABLE &&
- !target->IsImported()) {
- return target->GetProperty("CROSSCOMPILING_EMULATOR");
+
+ for (unsigned int c = 0; c < this->GetNumberOfCommands(); ++c) {
+ std::string const& argv0 = this->CommandLines[c][0];
+ cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0);
+ if (target && target->GetType() == cmStateEnums::EXECUTABLE &&
+ !target->IsImported()) {
+
+ const char* emulator_property =
+ target->GetProperty("CROSSCOMPILING_EMULATOR");
+ if (!emulator_property) {
+ continue;
+ }
+
+ cmExpandList(emulator_property, this->EmulatorsWithArguments[c]);
+ }
}
- return CM_NULLPTR;
+}
+
+std::vector<std::string> cmCustomCommandGenerator::GetCrossCompilingEmulator(
+ unsigned int c) const
+{
+ if (c >= this->EmulatorsWithArguments.size()) {
+ return std::vector<std::string>();
+ }
+ return this->EmulatorsWithArguments[c];
}
const char* cmCustomCommandGenerator::GetArgv0Location(unsigned int c) const
@@ -81,13 +139,26 @@ const char* cmCustomCommandGenerator::GetArgv0Location(unsigned int c) const
!this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"))) {
return target->GetLocation(this->Config);
}
- return CM_NULLPTR;
+ return nullptr;
+}
+
+bool cmCustomCommandGenerator::HasOnlyEmptyCommandLines() const
+{
+ for (size_t i = 0; i < this->CommandLines.size(); ++i) {
+ for (size_t j = 0; j < this->CommandLines[i].size(); ++j) {
+ if (!this->CommandLines[i][j].empty()) {
+ return false;
+ }
+ }
+ }
+ return true;
}
std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const
{
- if (const char* emulator = this->GetCrossCompilingEmulator(c)) {
- return std::string(emulator);
+ std::vector<std::string> emulator = this->GetCrossCompilingEmulator(c);
+ if (!emulator.empty()) {
+ return emulator[0];
}
if (const char* location = this->GetArgv0Location(c)) {
return std::string(location);
@@ -104,9 +175,7 @@ std::string escapeForShellOldStyle(const std::string& str)
std::string temp = str;
if (temp.find(" ") != std::string::npos &&
temp.find("\"") == std::string::npos) {
- result = "\"";
- result += str;
- result += "\"";
+ result = cmStrCat('"', str, '"');
return result;
}
return str;
@@ -125,14 +194,24 @@ void cmCustomCommandGenerator::AppendArguments(unsigned int c,
std::string& cmd) const
{
unsigned int offset = 1;
- if (this->GetCrossCompilingEmulator(c) != CM_NULLPTR) {
+ std::vector<std::string> emulator = this->GetCrossCompilingEmulator(c);
+ if (!emulator.empty()) {
+ for (unsigned j = 1; j < emulator.size(); ++j) {
+ cmd += " ";
+ if (this->OldStyle) {
+ cmd += escapeForShellOldStyle(emulator[j]);
+ } else {
+ cmd += this->LG->EscapeForShell(emulator[j], this->MakeVars);
+ }
+ }
+
offset = 0;
}
+
cmCustomCommandLine const& commandLine = this->CommandLines[c];
for (unsigned int j = offset; j < commandLine.size(); ++j) {
std::string arg;
- if (const char* location =
- j == 0 ? this->GetArgv0Location(c) : CM_NULLPTR) {
+ if (const char* location = j == 0 ? this->GetArgv0Location(c) : nullptr) {
// GetCommand returned the emulator instead of the argv0 location,
// so transform the latter now.
arg = location;
@@ -143,8 +222,7 @@ void cmCustomCommandGenerator::AppendArguments(unsigned int c,
if (this->OldStyle) {
cmd += escapeForShellOldStyle(arg);
} else {
- cmOutputConverter converter(this->LG->GetStateSnapshot());
- cmd += converter.EscapeForShell(arg, this->MakeVars);
+ cmd += this->LG->EscapeForShell(arg, this->MakeVars);
}
}
}
@@ -156,7 +234,7 @@ const char* cmCustomCommandGenerator::GetComment() const
std::string cmCustomCommandGenerator::GetWorkingDirectory() const
{
- return this->CC.GetWorkingDirectory();
+ return this->WorkingDirectory;
}
std::vector<std::string> const& cmCustomCommandGenerator::GetOutputs() const
@@ -166,28 +244,10 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetOutputs() const
std::vector<std::string> const& cmCustomCommandGenerator::GetByproducts() const
{
- return this->CC.GetByproducts();
+ return this->Byproducts;
}
std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
{
- if (!this->DependsDone) {
- this->DependsDone = true;
- std::vector<std::string> depends = this->CC.GetDepends();
- for (std::vector<std::string>::const_iterator i = depends.begin();
- i != depends.end(); ++i) {
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = this->GE->Parse(*i);
- std::vector<std::string> result;
- cmSystemTools::ExpandListArgument(cge->Evaluate(this->LG, this->Config),
- result);
- for (std::vector<std::string>::iterator it = result.begin();
- it != result.end(); ++it) {
- if (cmSystemTools::FileIsFullPath(it->c_str())) {
- *it = cmSystemTools::CollapseFullPath(*it);
- }
- }
- this->Depends.insert(this->Depends.end(), result.begin(), result.end());
- }
- }
return this->Depends;
}
diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h
index 0a2adb524..67ee9e0e1 100644
--- a/Source/cmCustomCommandGenerator.h
+++ b/Source/cmCustomCommandGenerator.h
@@ -4,13 +4,13 @@
#define cmCustomCommandGenerator_h
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmCustomCommandLines.h"
#include <string>
#include <vector>
+#include "cmCustomCommandLines.h"
+
class cmCustomCommand;
-class cmGeneratorExpression;
class cmLocalGenerator;
class cmCustomCommandGenerator
@@ -20,18 +20,22 @@ class cmCustomCommandGenerator
cmLocalGenerator* LG;
bool OldStyle;
bool MakeVars;
- cmGeneratorExpression* GE;
- mutable bool DependsDone;
- mutable std::vector<std::string> Depends;
cmCustomCommandLines CommandLines;
+ std::vector<std::vector<std::string>> EmulatorsWithArguments;
+ std::vector<std::string> Byproducts;
+ std::vector<std::string> Depends;
+ std::string WorkingDirectory;
- const char* GetCrossCompilingEmulator(unsigned int c) const;
+ void FillEmulatorsWithArguments();
+ std::vector<std::string> GetCrossCompilingEmulator(unsigned int c) const;
const char* GetArgv0Location(unsigned int c) const;
public:
- cmCustomCommandGenerator(cmCustomCommand const& cc,
- const std::string& config, cmLocalGenerator* lg);
- ~cmCustomCommandGenerator();
+ cmCustomCommandGenerator(cmCustomCommand const& cc, std::string config,
+ cmLocalGenerator* lg);
+ cmCustomCommandGenerator(const cmCustomCommandGenerator&) = delete;
+ cmCustomCommandGenerator& operator=(const cmCustomCommandGenerator&) =
+ delete;
cmCustomCommand const& GetCC() const { return this->CC; }
unsigned int GetNumberOfCommands() const;
std::string GetCommand(unsigned int c) const;
@@ -41,6 +45,7 @@ public:
std::vector<std::string> const& GetOutputs() const;
std::vector<std::string> const& GetByproducts() const;
std::vector<std::string> const& GetDepends() const;
+ bool HasOnlyEmptyCommandLines() const;
};
#endif
diff --git a/Source/cmCustomCommandLines.cxx b/Source/cmCustomCommandLines.cxx
new file mode 100644
index 000000000..37ad75b7c
--- /dev/null
+++ b/Source/cmCustomCommandLines.cxx
@@ -0,0 +1,22 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmCustomCommandLines.h"
+
+cmCustomCommandLine cmMakeCommandLine(
+ std::initializer_list<cm::string_view> ilist)
+{
+ cmCustomCommandLine commandLine;
+ commandLine.reserve(ilist.size());
+ for (cm::string_view cmd : ilist) {
+ commandLine.emplace_back(cmd);
+ }
+ return commandLine;
+}
+
+cmCustomCommandLines cmMakeSingleCommandLine(
+ std::initializer_list<cm::string_view> ilist)
+{
+ cmCustomCommandLines commandLines;
+ commandLines.push_back(cmMakeCommandLine(ilist));
+ return commandLines;
+}
diff --git a/Source/cmCustomCommandLines.h b/Source/cmCustomCommandLines.h
index 36838f23f..ead579280 100644
--- a/Source/cmCustomCommandLines.h
+++ b/Source/cmCustomCommandLines.h
@@ -5,25 +5,28 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <initializer_list>
#include <string>
#include <vector>
+#include <cm/string_view> // IWYU pragma: keep
+
/** Data structure to represent a single command line. */
class cmCustomCommandLine : public std::vector<std::string>
{
-public:
- typedef std::vector<std::string> Superclass;
- typedef Superclass::iterator iterator;
- typedef Superclass::const_iterator const_iterator;
};
/** Data structure to represent a list of command lines. */
class cmCustomCommandLines : public std::vector<cmCustomCommandLine>
{
-public:
- typedef std::vector<cmCustomCommandLine> Superclass;
- typedef Superclass::iterator iterator;
- typedef Superclass::const_iterator const_iterator;
};
+/** Return a command line from a list of command line parts. */
+cmCustomCommandLine cmMakeCommandLine(
+ std::initializer_list<cm::string_view> ilist);
+
+/** Return a command line vector with a single command line. */
+cmCustomCommandLines cmMakeSingleCommandLine(
+ std::initializer_list<cm::string_view> ilist);
+
#endif
diff --git a/Source/cmCustomCommandTypes.h b/Source/cmCustomCommandTypes.h
new file mode 100644
index 000000000..d4bf1f9c3
--- /dev/null
+++ b/Source/cmCustomCommandTypes.h
@@ -0,0 +1,39 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmCustomCommandTypes_h
+#define cmCustomCommandTypes_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+
+/** Target custom command type */
+enum class cmCustomCommandType
+{
+ PRE_BUILD,
+ PRE_LINK,
+ POST_BUILD
+};
+
+/** Where the command originated from. */
+enum class cmCommandOrigin
+{
+ Project,
+ Generator
+};
+
+/** How to handle custom commands for object libraries */
+enum class cmObjectLibraryCommands
+{
+ Reject,
+ Accept
+};
+
+/** Utility target output source file name. */
+struct cmUtilityOutput
+{
+ std::string Name;
+ std::string NameCMP0049;
+};
+
+#endif
diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx
index 86a83dabe..f4e4fda4d 100644
--- a/Source/cmDefinePropertyCommand.cxx
+++ b/Source/cmDefinePropertyCommand.cxx
@@ -2,19 +2,17 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmDefinePropertyCommand.h"
-#include <sstream>
-
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmProperty.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
-class cmExecutionStatus;
-
-bool cmDefinePropertyCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmDefinePropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
@@ -37,17 +35,17 @@ bool cmDefinePropertyCommand::InitialPass(std::vector<std::string> const& args,
} else if (scope_arg == "CACHED_VARIABLE") {
scope = cmProperty::CACHED_VARIABLE;
} else {
- std::ostringstream e;
- e << "given invalid scope " << scope_arg << ". "
- << "Valid scopes are "
- << "GLOBAL, DIRECTORY, TARGET, SOURCE, "
- << "TEST, VARIABLE, CACHED_VARIABLE.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("given invalid scope ", scope_arg,
+ ". Valid scopes are GLOBAL, DIRECTORY, TARGET, "
+ "SOURCE, TEST, VARIABLE, CACHED_VARIABLE."));
return false;
}
// Parse remaining arguments.
bool inherited = false;
+ std::string PropertyName;
+ std::string BriefDocs;
+ std::string FullDocs;
enum Doing
{
DoingNone,
@@ -68,39 +66,36 @@ bool cmDefinePropertyCommand::InitialPass(std::vector<std::string> const& args,
inherited = true;
} else if (doing == DoingProperty) {
doing = DoingNone;
- this->PropertyName = args[i];
+ PropertyName = args[i];
} else if (doing == DoingBrief) {
- this->BriefDocs += args[i];
+ BriefDocs += args[i];
} else if (doing == DoingFull) {
- this->FullDocs += args[i];
+ FullDocs += args[i];
} else {
- std::ostringstream e;
- e << "given invalid argument \"" << args[i] << "\".";
- this->SetError(e.str());
+ status.SetError(cmStrCat("given invalid argument \"", args[i], "\"."));
return false;
}
}
// Make sure a property name was found.
- if (this->PropertyName.empty()) {
- this->SetError("not given a PROPERTY <name> argument.");
+ if (PropertyName.empty()) {
+ status.SetError("not given a PROPERTY <name> argument.");
return false;
}
// Make sure documentation was given.
- if (this->BriefDocs.empty()) {
- this->SetError("not given a BRIEF_DOCS <brief-doc> argument.");
+ if (BriefDocs.empty()) {
+ status.SetError("not given a BRIEF_DOCS <brief-doc> argument.");
return false;
}
- if (this->FullDocs.empty()) {
- this->SetError("not given a FULL_DOCS <full-doc> argument.");
+ if (FullDocs.empty()) {
+ status.SetError("not given a FULL_DOCS <full-doc> argument.");
return false;
}
// Actually define the property.
- this->Makefile->GetState()->DefineProperty(
- this->PropertyName, scope, this->BriefDocs.c_str(), this->FullDocs.c_str(),
- inherited);
+ status.GetMakefile().GetState()->DefineProperty(
+ PropertyName, scope, BriefDocs.c_str(), FullDocs.c_str(), inherited);
return true;
}
diff --git a/Source/cmDefinePropertyCommand.h b/Source/cmDefinePropertyCommand.h
index bc120c564..60dd76a0d 100644
--- a/Source/cmDefinePropertyCommand.h
+++ b/Source/cmDefinePropertyCommand.h
@@ -3,31 +3,14 @@
#ifndef cmDefinesPropertyCommand_h
#define cmDefinesPropertyCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmDefinePropertyCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmDefinePropertyCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- std::string PropertyName;
- std::string BriefDocs;
- std::string FullDocs;
-};
+bool cmDefinePropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 7aa7641e1..69a64276b 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -2,11 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmDefinitions.h"
-#include "cmConfigure.h"
-#include <assert.h>
-#include <set>
+#include <cassert>
+#include <functional>
+#include <unordered_set>
#include <utility>
+#include <cm/string_view>
+
cmDefinitions::Def cmDefinitions::NoDef;
cmDefinitions::Def const& cmDefinitions::GetInternal(const std::string& key,
@@ -14,10 +16,12 @@ cmDefinitions::Def const& cmDefinitions::GetInternal(const std::string& key,
StackIter end, bool raise)
{
assert(begin != end);
- MapType::iterator i = begin->Map.find(key);
- if (i != begin->Map.end()) {
- i->second.Used = true;
- return i->second;
+ {
+ auto it = begin->Map.find(cm::String::borrow(key));
+ if (it != begin->Map.end()) {
+ it->second.Used = true;
+ return it->second;
+ }
}
StackIter it = begin;
++it;
@@ -28,14 +32,14 @@ cmDefinitions::Def const& cmDefinitions::GetInternal(const std::string& key,
if (!raise) {
return def;
}
- return begin->Map.insert(MapType::value_type(key, def)).first->second;
+ return begin->Map.emplace(key, def).first->second;
}
-const char* cmDefinitions::Get(const std::string& key, StackIter begin,
- StackIter end)
+const std::string* cmDefinitions::Get(const std::string& key, StackIter begin,
+ StackIter end)
{
Def const& def = cmDefinitions::GetInternal(key, begin, end, false);
- return def.Exists ? def.c_str() : CM_NULLPTR;
+ return def.Value ? def.Value.str_if_stable() : nullptr;
}
void cmDefinitions::Raise(const std::string& key, StackIter begin,
@@ -48,49 +52,27 @@ bool cmDefinitions::HasKey(const std::string& key, StackIter begin,
StackIter end)
{
for (StackIter it = begin; it != end; ++it) {
- MapType::const_iterator i = it->Map.find(key);
- if (i != it->Map.end()) {
+ if (it->Map.find(cm::String::borrow(key)) != it->Map.end()) {
return true;
}
}
return false;
}
-void cmDefinitions::Set(const std::string& key, const char* value)
-{
- Def def(value);
- this->Map[key] = def;
-}
-
-std::vector<std::string> cmDefinitions::UnusedKeys() const
-{
- std::vector<std::string> keys;
- keys.reserve(this->Map.size());
- // Consider local definitions.
- for (MapType::const_iterator mi = this->Map.begin(); mi != this->Map.end();
- ++mi) {
- if (!mi->second.Used) {
- keys.push_back(mi->first);
- }
- }
- return keys;
-}
-
cmDefinitions cmDefinitions::MakeClosure(StackIter begin, StackIter end)
{
cmDefinitions closure;
- std::set<std::string> undefined;
+ std::unordered_set<cm::string_view> undefined;
for (StackIter it = begin; it != end; ++it) {
// Consider local definitions.
- for (MapType::const_iterator mi = it->Map.begin(); mi != it->Map.end();
- ++mi) {
+ for (auto const& mi : it->Map) {
// Use this key if it is not already set or unset.
- if (closure.Map.find(mi->first) == closure.Map.end() &&
- undefined.find(mi->first) == undefined.end()) {
- if (mi->second.Exists) {
- closure.Map.insert(*mi);
+ if (closure.Map.find(mi.first) == closure.Map.end() &&
+ undefined.find(mi.first.view()) == undefined.end()) {
+ if (mi.second.Value) {
+ closure.Map.insert(mi);
} else {
- undefined.insert(mi->first);
+ undefined.emplace(mi.first.view());
}
}
}
@@ -101,19 +83,41 @@ cmDefinitions cmDefinitions::MakeClosure(StackIter begin, StackIter end)
std::vector<std::string> cmDefinitions::ClosureKeys(StackIter begin,
StackIter end)
{
- std::set<std::string> bound;
std::vector<std::string> defined;
+ std::unordered_set<cm::string_view> bound;
for (StackIter it = begin; it != end; ++it) {
defined.reserve(defined.size() + it->Map.size());
- for (MapType::const_iterator mi = it->Map.begin(); mi != it->Map.end();
- ++mi) {
+ for (auto const& mi : it->Map) {
// Use this key if it is not already set or unset.
- if (bound.insert(mi->first).second && mi->second.Exists) {
- defined.push_back(mi->first);
+ if (bound.emplace(mi.first.view()).second && mi.second.Value) {
+ defined.push_back(*mi.first.str_if_stable());
}
}
}
return defined;
}
+
+void cmDefinitions::Set(const std::string& key, cm::string_view value)
+{
+ this->Map[key] = Def(value);
+}
+
+void cmDefinitions::Unset(const std::string& key)
+{
+ this->Map[key] = Def();
+}
+
+std::vector<std::string> cmDefinitions::UnusedKeys() const
+{
+ std::vector<std::string> keys;
+ keys.reserve(this->Map.size());
+ // Consider local definitions.
+ for (auto const& mi : this->Map) {
+ if (!mi.second.Used) {
+ keys.push_back(*mi.first.str_if_stable());
+ }
+ }
+ return keys;
+}
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index ddb89188c..0e38fb1af 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -5,11 +5,15 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <functional>
#include <string>
+#include <unordered_map>
#include <vector>
+#include <cm/string_view>
+
#include "cmLinkedTree.h"
-#include "cm_unordered_map.hxx"
+#include "cmString.hxx"
/** \class cmDefinitions
* \brief Store a scope of variable definitions for CMake language.
@@ -20,58 +24,49 @@
*/
class cmDefinitions
{
- typedef cmLinkedTree<cmDefinitions>::iterator StackIter;
+ using StackIter = cmLinkedTree<cmDefinitions>::iterator;
public:
- static const char* Get(const std::string& key, StackIter begin,
- StackIter end);
+ // -- Static member functions
+
+ static const std::string* Get(const std::string& key, StackIter begin,
+ StackIter end);
static void Raise(const std::string& key, StackIter begin, StackIter end);
static bool HasKey(const std::string& key, StackIter begin, StackIter end);
- /** Set (or unset if null) a value associated with a key. */
- void Set(const std::string& key, const char* value);
-
- std::vector<std::string> UnusedKeys() const;
-
static std::vector<std::string> ClosureKeys(StackIter begin, StackIter end);
static cmDefinitions MakeClosure(StackIter begin, StackIter end);
+ // -- Member functions
+
+ /** Set a value associated with a key. */
+ void Set(const std::string& key, cm::string_view value);
+
+ /** Unset a definition. */
+ void Unset(const std::string& key);
+
+ /** List of unused keys. */
+ std::vector<std::string> UnusedKeys() const;
+
private:
- // String with existence boolean.
- struct Def : public std::string
+ /** String with existence boolean. */
+ struct Def
{
- private:
- typedef std::string std_string;
-
public:
- Def()
- : std_string()
- , Exists(false)
- , Used(false)
- {
- }
- Def(const char* v)
- : std_string(v ? v : "")
- , Exists(v ? true : false)
- , Used(false)
- {
- }
- Def(const std_string& v)
- : std_string(v)
- , Exists(true)
- , Used(false)
+ Def() = default;
+ Def(cm::string_view value)
+ : Value(value)
{
}
- bool Exists;
- bool Used;
+ cm::String Value;
+ bool Used = false;
};
static Def NoDef;
- typedef CM_UNORDERED_MAP<std::string, Def> MapType;
- MapType Map;
+ std::unordered_map<cm::String, Def> Map;
static Def const& GetInternal(const std::string& key, StackIter begin,
StackIter end, bool raise);
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index c898d12ba..129a5f72f 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -2,63 +2,51 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmDepends.h"
-#include "cmFileTimeComparison.h"
+#include <sstream>
+#include <utility>
+
+#include "cmsys/FStream.hxx"
+
+#include "cmFileTime.h"
+#include "cmFileTimeCache.h"
#include "cmGeneratedFileStream.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmWorkingDirectory.h"
-#include "cmsys/FStream.hxx"
-#include <sstream>
-#include <string.h>
-#include <utility>
-
-cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir)
- : CompileDirectory()
- , LocalGenerator(lg)
- , Verbose(false)
- , FileComparison(CM_NULLPTR)
- , TargetDirectory(targetDir)
- , MaxPath(16384)
- , Dependee(new char[MaxPath])
- , Depender(new char[MaxPath])
+cmDepends::cmDepends(cmLocalGenerator* lg, std::string targetDir)
+ : LocalGenerator(lg)
+ , TargetDirectory(std::move(targetDir))
{
}
-cmDepends::~cmDepends()
-{
- delete[] this->Dependee;
- delete[] this->Depender;
-}
+cmDepends::~cmDepends() = default;
bool cmDepends::Write(std::ostream& makeDepends, std::ostream& internalDepends)
{
- // Lookup the set of sources to scan.
- std::string srcLang = "CMAKE_DEPENDS_CHECK_";
- srcLang += this->Language;
- cmMakefile* mf = this->LocalGenerator->GetMakefile();
- const char* srcStr = mf->GetSafeDefinition(srcLang);
- std::vector<std::string> pairs;
- cmSystemTools::ExpandListArgument(srcStr, pairs);
-
- std::map<std::string, std::set<std::string> > dependencies;
- for (std::vector<std::string>::iterator si = pairs.begin();
- si != pairs.end();) {
- // Get the source and object file.
- std::string const& src = *si++;
- if (si == pairs.end()) {
- break;
+ std::map<std::string, std::set<std::string>> dependencies;
+ {
+ // Lookup the set of sources to scan.
+ std::vector<std::string> pairs;
+ {
+ std::string const srcLang = "CMAKE_DEPENDS_CHECK_" + this->Language;
+ cmMakefile* mf = this->LocalGenerator->GetMakefile();
+ cmExpandList(mf->GetSafeDefinition(srcLang), pairs);
+ }
+ for (auto si = pairs.begin(); si != pairs.end();) {
+ // Get the source and object file.
+ std::string const& src = *si++;
+ if (si == pairs.end()) {
+ break;
+ }
+ std::string const& obj = *si++;
+ dependencies[obj].insert(src);
}
- std::string const& obj = *si++;
- dependencies[obj].insert(src);
}
- for (std::map<std::string, std::set<std::string> >::const_iterator it =
- dependencies.begin();
- it != dependencies.end(); ++it) {
-
+ for (auto const& d : dependencies) {
// Write the dependencies for this pair.
- if (!this->WriteDependencies(it->second, it->first, makeDepends,
+ if (!this->WriteDependencies(d.second, d.first, makeDepends,
internalDepends)) {
return false;
}
@@ -72,32 +60,30 @@ bool cmDepends::Finalize(std::ostream& /*unused*/, std::ostream& /*unused*/)
return true;
}
-bool cmDepends::Check(const char* makeFile, const char* internalFile,
- std::map<std::string, DependencyVector>& validDeps)
+bool cmDepends::Check(const std::string& makeFile,
+ const std::string& internalFile,
+ DependencyMap& validDeps)
{
- // Dependency checks must be done in proper working directory.
- cmWorkingDirectory workdir(this->CompileDirectory);
-
// Check whether dependencies must be regenerated.
bool okay = true;
- cmsys::ifstream fin(internalFile);
+ cmsys::ifstream fin(internalFile.c_str());
if (!(fin && this->CheckDependencies(fin, internalFile, validDeps))) {
// Clear all dependencies so they will be regenerated.
this->Clear(makeFile);
cmSystemTools::RemoveFile(internalFile);
+ this->FileTimeCache->Remove(internalFile);
okay = false;
}
-
return okay;
}
-void cmDepends::Clear(const char* file)
+void cmDepends::Clear(const std::string& file)
{
// Print verbose output.
if (this->Verbose) {
std::ostringstream msg;
msg << "Clearing dependencies in \"" << file << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
// Write an empty dependency file.
@@ -116,48 +102,62 @@ bool cmDepends::WriteDependencies(const std::set<std::string>& /*unused*/,
return false;
}
-bool cmDepends::CheckDependencies(
- std::istream& internalDepends, const char* internalDependsFileName,
- std::map<std::string, DependencyVector>& validDeps)
+bool cmDepends::CheckDependencies(std::istream& internalDepends,
+ const std::string& internalDependsFileName,
+ DependencyMap& validDeps)
{
+ // Read internal depends file time
+ cmFileTime internalDependsTime;
+ if (!this->FileTimeCache->Load(internalDependsFileName,
+ internalDependsTime)) {
+ return false;
+ }
+
// Parse dependencies from the stream. If any dependee is missing
// or newer than the depender then dependencies should be
// regenerated.
bool okay = true;
bool dependerExists = false;
- DependencyVector* currentDependencies = CM_NULLPTR;
- while (internalDepends.getline(this->Dependee, this->MaxPath)) {
- if (this->Dependee[0] == 0 || this->Dependee[0] == '#' ||
- this->Dependee[0] == '\r') {
+ std::string line;
+ line.reserve(1024);
+ std::string depender;
+ std::string dependee;
+ cmFileTime dependerTime;
+ cmFileTime dependeeTime;
+ std::vector<std::string>* currentDependencies = nullptr;
+
+ while (std::getline(internalDepends, line)) {
+ // Check if this an empty or a comment line
+ if (line.empty() || line.front() == '#') {
continue;
}
- size_t len = internalDepends.gcount() - 1;
- if (this->Dependee[len - 1] == '\r') {
- len--;
- this->Dependee[len] = 0;
+ // Drop carriage return character at the end
+ if (line.back() == '\r') {
+ line.pop_back();
+ if (line.empty()) {
+ continue;
+ }
}
- if (this->Dependee[0] != ' ') {
- memcpy(this->Depender, this->Dependee, len + 1);
- // Calling FileExists() for the depender here saves in many cases 50%
- // of the calls to FileExists() further down in the loop. E.g. for
- // kdelibs/khtml this reduces the number of calls from 184k down to 92k,
- // or the time for cmake -E cmake_depends from 0.3 s down to 0.21 s.
- dependerExists = cmSystemTools::FileExists(this->Depender);
+ // Check if this a depender line
+ if (line.front() != ' ') {
+ depender = line;
+ dependerExists = this->FileTimeCache->Load(depender, dependerTime);
// If we erase validDeps[this->Depender] by overwriting it with an empty
// vector, we lose dependencies for dependers that have multiple
// entries. No need to initialize the entry, std::map will do so on first
// access.
- currentDependencies = &validDeps[this->Depender];
+ currentDependencies = &validDeps[depender];
continue;
}
- /*
- // Parse the dependency line.
- if(!this->ParseDependency(line.c_str()))
- {
- continue;
- }
- */
+
+ // This is a dependee line
+ dependee = line.substr(1);
+
+ // Add dependee to depender's list
+ if (currentDependencies != nullptr) {
+ currentDependencies->push_back(dependee);
+ }
// Dependencies must be regenerated
// * if the dependee does not exist
@@ -165,13 +165,8 @@ bool cmDepends::CheckDependencies(
// * if the depender does not exist, but the dependee is newer than the
// depends file
bool regenerate = false;
- const char* dependee = this->Dependee + 1;
- const char* depender = this->Depender;
- if (currentDependencies != CM_NULLPTR) {
- currentDependencies->push_back(dependee);
- }
-
- if (!cmSystemTools::FileExists(dependee)) {
+ bool dependeeExists = this->FileTimeCache->Load(dependee, dependeeTime);
+ if (!dependeeExists) {
// The dependee does not exist.
regenerate = true;
@@ -180,61 +175,55 @@ bool cmDepends::CheckDependencies(
std::ostringstream msg;
msg << "Dependee \"" << dependee << "\" does not exist for depender \""
<< depender << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
- } else {
- if (dependerExists) {
- // The dependee and depender both exist. Compare file times.
- int result = 0;
- if ((!this->FileComparison->FileTimeCompare(depender, dependee,
- &result) ||
- result < 0)) {
- // The depender is older than the dependee.
- regenerate = true;
-
- // Print verbose output.
- if (this->Verbose) {
- std::ostringstream msg;
- msg << "Dependee \"" << dependee << "\" is newer than depender \""
- << depender << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
- }
+ } else if (dependerExists) {
+ // The dependee and depender both exist. Compare file times.
+ if (dependerTime.Older(dependeeTime)) {
+ // The depender is older than the dependee.
+ regenerate = true;
+
+ // Print verbose output.
+ if (this->Verbose) {
+ std::ostringstream msg;
+ msg << "Dependee \"" << dependee << "\" is newer than depender \""
+ << depender << "\"." << std::endl;
+ cmSystemTools::Stdout(msg.str());
}
- } else {
- // The dependee exists, but the depender doesn't. Regenerate if the
- // internalDepends file is older than the dependee.
- int result = 0;
- if ((!this->FileComparison->FileTimeCompare(internalDependsFileName,
- dependee, &result) ||
- result < 0)) {
- // The depends-file is older than the dependee.
- regenerate = true;
-
- // Print verbose output.
- if (this->Verbose) {
- std::ostringstream msg;
- msg << "Dependee \"" << dependee
- << "\" is newer than depends file \""
- << internalDependsFileName << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
- }
+ }
+ } else {
+ // The dependee exists, but the depender doesn't. Regenerate if the
+ // internalDepends file is older than the dependee.
+ if (internalDependsTime.Older(dependeeTime)) {
+ // The depends-file is older than the dependee.
+ regenerate = true;
+
+ // Print verbose output.
+ if (this->Verbose) {
+ std::ostringstream msg;
+ msg << "Dependee \"" << dependee
+ << "\" is newer than depends file \"" << internalDependsFileName
+ << "\"." << std::endl;
+ cmSystemTools::Stdout(msg.str());
}
}
}
+
if (regenerate) {
// Dependencies must be regenerated.
okay = false;
// Remove the information of this depender from the map, it needs
// to be rescanned
- if (currentDependencies != CM_NULLPTR) {
- validDeps.erase(this->Depender);
- currentDependencies = CM_NULLPTR;
+ if (currentDependencies != nullptr) {
+ validDeps.erase(depender);
+ currentDependencies = nullptr;
}
// Remove the depender to be sure it is rebuilt.
if (dependerExists) {
cmSystemTools::RemoveFile(depender);
+ this->FileTimeCache->Remove(depender);
dependerExists = false;
}
}
@@ -246,22 +235,19 @@ bool cmDepends::CheckDependencies(
void cmDepends::SetIncludePathFromLanguage(const std::string& lang)
{
// Look for the new per "TARGET_" variant first:
- const char* includePath = CM_NULLPTR;
- std::string includePathVar = "CMAKE_";
- includePathVar += lang;
- includePathVar += "_TARGET_INCLUDE_PATH";
+ const char* includePath = nullptr;
+ std::string includePathVar =
+ cmStrCat("CMAKE_", lang, "_TARGET_INCLUDE_PATH");
cmMakefile* mf = this->LocalGenerator->GetMakefile();
includePath = mf->GetDefinition(includePathVar);
if (includePath) {
- cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
+ cmExpandList(includePath, this->IncludePath);
} else {
// Fallback to the old directory level variable if no per-target var:
- includePathVar = "CMAKE_";
- includePathVar += lang;
- includePathVar += "_INCLUDE_PATH";
+ includePathVar = cmStrCat("CMAKE_", lang, "_INCLUDE_PATH");
includePath = mf->GetDefinition(includePathVar);
if (includePath) {
- cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
+ cmExpandList(includePath, this->IncludePath);
}
}
}
diff --git a/Source/cmDepends.h b/Source/cmDepends.h
index b33feb902..d9387758c 100644
--- a/Source/cmDepends.h
+++ b/Source/cmDepends.h
@@ -3,16 +3,15 @@
#ifndef cmDepends_h
#define cmDepends_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
#include <set>
-#include <stddef.h>
#include <string>
#include <vector>
-class cmFileTimeComparison;
+class cmFileTimeCache;
class cmLocalGenerator;
/** \class cmDepends
@@ -24,15 +23,16 @@ class cmLocalGenerator;
*/
class cmDepends
{
- CM_DISABLE_COPY(cmDepends)
+public:
+ using DependencyMap = std::map<std::string, std::vector<std::string>>;
public:
/** Instances need to know the build directory name and the relative
path from the build directory to the target file. */
- cmDepends(cmLocalGenerator* lg = CM_NULLPTR, const char* targetDir = "");
+ cmDepends(cmLocalGenerator* lg = nullptr, std::string targetDir = "");
- /** at what level will the compile be done from */
- void SetCompileDirectory(const char* dir) { this->CompileDirectory = dir; }
+ cmDepends(cmDepends const&) = delete;
+ cmDepends& operator=(cmDepends const&) = delete;
/** Set the local generator for the directory in which we are
scanning dependencies. This is not a full local generator; it
@@ -44,7 +44,10 @@ public:
void SetLanguage(const std::string& lang) { this->Language = lang; }
/** Set the target build directory. */
- void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; }
+ void SetTargetDirectory(const std::string& dir)
+ {
+ this->TargetDirectory = dir;
+ }
/** should this be verbose in its output */
void SetVerbose(bool verb) { this->Verbose = verb; }
@@ -55,26 +58,19 @@ public:
/** Write dependencies for the target file. */
bool Write(std::ostream& makeDepends, std::ostream& internalDepends);
- class DependencyVector : public std::vector<std::string>
- {
- };
-
/** Check dependencies for the target file. Returns true if
dependencies are okay and false if they must be generated. If
they must be generated Clear has already been called to wipe out
the old dependencies.
Dependencies which are still valid will be stored in validDeps. */
- bool Check(const char* makeFile, const char* internalFile,
- std::map<std::string, DependencyVector>& validDeps);
+ bool Check(const std::string& makeFile, const std::string& internalFile,
+ DependencyMap& validDeps);
/** Clear dependencies for the target file so they will be regenerated. */
- void Clear(const char* file);
+ void Clear(const std::string& file);
/** Set the file comparison object */
- void SetFileComparison(cmFileTimeComparison* fc)
- {
- this->FileComparison = fc;
- }
+ void SetFileTimeCache(cmFileTimeCache* fc) { this->FileTimeCache = fc; }
protected:
// Write dependencies for the target file to the given stream.
@@ -87,33 +83,26 @@ protected:
// Check dependencies for the target file in the given stream.
// Return false if dependencies must be regenerated and true
// otherwise.
- virtual bool CheckDependencies(
- std::istream& internalDepends, const char* internalDependsFileName,
- std::map<std::string, DependencyVector>& validDeps);
+ virtual bool CheckDependencies(std::istream& internalDepends,
+ const std::string& internalDependsFileName,
+ DependencyMap& validDeps);
// Finalize the dependency information for the target.
virtual bool Finalize(std::ostream& makeDepends,
std::ostream& internalDepends);
- // The directory in which the build rule for the target file is executed.
- std::string CompileDirectory;
-
// The local generator.
cmLocalGenerator* LocalGenerator;
// Flag for verbose output.
- bool Verbose;
- cmFileTimeComparison* FileComparison;
+ bool Verbose = false;
+ cmFileTimeCache* FileTimeCache = nullptr;
std::string Language;
// The full path to the target's build directory.
std::string TargetDirectory;
- size_t MaxPath;
- char* Dependee;
- char* Depender;
-
// The include file search path.
std::vector<std::string> IncludePath;
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 2c464cc9c..e30d9597d 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -2,13 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmDependsC.h"
-#include "cmsys/FStream.hxx"
#include <utility>
-#include "cmAlgorithms.h"
-#include "cmFileTimeComparison.h"
+#include "cmsys/FStream.hxx"
+
+#include "cmFileTime.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#define INCLUDE_REGEX_LINE \
@@ -19,14 +20,10 @@
#define INCLUDE_REGEX_COMPLAIN_MARKER "#IncludeRegexComplain: "
#define INCLUDE_REGEX_TRANSFORM_MARKER "#IncludeRegexTransform: "
-cmDependsC::cmDependsC()
- : ValidDeps(CM_NULLPTR)
-{
-}
+cmDependsC::cmDependsC() = default;
-cmDependsC::cmDependsC(
- cmLocalGenerator* lg, const char* targetDir, const std::string& lang,
- const std::map<std::string, DependencyVector>* validDeps)
+cmDependsC::cmDependsC(cmLocalGenerator* lg, const std::string& targetDir,
+ const std::string& lang, const DependencyMap* validDeps)
: cmDepends(lg, targetDir)
, ValidDeps(validDeps)
{
@@ -39,35 +36,30 @@ cmDependsC::cmDependsC(
std::string scanRegex = "^.*$";
std::string complainRegex = "^$";
{
- std::string scanRegexVar = "CMAKE_";
- scanRegexVar += lang;
- scanRegexVar += "_INCLUDE_REGEX_SCAN";
+ std::string scanRegexVar = cmStrCat("CMAKE_", lang, "_INCLUDE_REGEX_SCAN");
if (const char* sr = mf->GetDefinition(scanRegexVar)) {
scanRegex = sr;
}
- std::string complainRegexVar = "CMAKE_";
- complainRegexVar += lang;
- complainRegexVar += "_INCLUDE_REGEX_COMPLAIN";
+ std::string complainRegexVar =
+ cmStrCat("CMAKE_", lang, "_INCLUDE_REGEX_COMPLAIN");
if (const char* cr = mf->GetDefinition(complainRegexVar)) {
complainRegex = cr;
}
}
this->IncludeRegexLine.compile(INCLUDE_REGEX_LINE);
- this->IncludeRegexScan.compile(scanRegex.c_str());
- this->IncludeRegexComplain.compile(complainRegex.c_str());
+ this->IncludeRegexScan.compile(scanRegex);
+ this->IncludeRegexComplain.compile(complainRegex);
this->IncludeRegexLineString = INCLUDE_REGEX_LINE_MARKER INCLUDE_REGEX_LINE;
- this->IncludeRegexScanString = INCLUDE_REGEX_SCAN_MARKER;
- this->IncludeRegexScanString += scanRegex;
- this->IncludeRegexComplainString = INCLUDE_REGEX_COMPLAIN_MARKER;
- this->IncludeRegexComplainString += complainRegex;
+ this->IncludeRegexScanString =
+ cmStrCat(INCLUDE_REGEX_SCAN_MARKER, scanRegex);
+ this->IncludeRegexComplainString =
+ cmStrCat(INCLUDE_REGEX_COMPLAIN_MARKER, complainRegex);
this->SetupTransforms();
- this->CacheFileName = this->TargetDirectory;
- this->CacheFileName += "/";
- this->CacheFileName += lang;
- this->CacheFileName += ".includecache";
+ this->CacheFileName =
+ cmStrCat(this->TargetDirectory, '/', lang, ".includecache");
this->ReadCacheFile();
}
@@ -75,7 +67,6 @@ cmDependsC::cmDependsC(
cmDependsC::~cmDependsC()
{
this->WriteCacheFile();
- cmDeleteAll(this->FileCache);
}
bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
@@ -96,9 +87,16 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
std::set<std::string> dependencies;
bool haveDeps = false;
- if (this->ValidDeps != CM_NULLPTR) {
- std::map<std::string, DependencyVector>::const_iterator tmpIt =
- this->ValidDeps->find(obj);
+ std::string binDir = this->LocalGenerator->GetBinaryDirectory();
+
+ // Compute a path to the object file to write to the internal depend file.
+ // Any existing content of the internal depend file has already been
+ // loaded in ValidDeps with this path as a key.
+ std::string obj_i =
+ this->LocalGenerator->MaybeConvertToRelativePath(binDir, obj);
+
+ if (this->ValidDeps != nullptr) {
+ auto const tmpIt = this->ValidDeps->find(obj_i);
if (tmpIt != this->ValidDeps->end()) {
dependencies.insert(tmpIt->second.begin(), tmpIt->second.end());
haveDeps = true;
@@ -107,24 +105,17 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
if (!haveDeps) {
// Walk the dependency graph starting with the source file.
- int srcFiles = (int)sources.size();
+ int srcFiles = static_cast<int>(sources.size());
this->Encountered.clear();
- for (std::set<std::string>::const_iterator srcIt = sources.begin();
- srcIt != sources.end(); ++srcIt) {
+ for (std::string const& src : sources) {
UnscannedEntry root;
- root.FileName = *srcIt;
+ root.FileName = src;
this->Unscanned.push(root);
- this->Encountered.insert(*srcIt);
+ this->Encountered.insert(src);
}
std::set<std::string> scanned;
-
- // Use reserve to allocate enough memory for tempPathStr
- // so that during the loops no memory is allocated or freed
- std::string tempPathStr;
- tempPathStr.reserve(4 * 1024);
-
while (!this->Unscanned.empty()) {
// Get the next file to scan.
UnscannedEntry current = this->Unscanned.front();
@@ -132,37 +123,32 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// If not a full path, find the file in the include path.
std::string fullName;
- if ((srcFiles > 0) ||
- cmSystemTools::FileIsFullPath(current.FileName.c_str())) {
- if (cmSystemTools::FileExists(current.FileName.c_str(), true)) {
+ if ((srcFiles > 0) || cmSystemTools::FileIsFullPath(current.FileName)) {
+ if (cmSystemTools::FileExists(current.FileName, true)) {
fullName = current.FileName;
}
} else if (!current.QuotedLocation.empty() &&
- cmSystemTools::FileExists(current.QuotedLocation.c_str(),
- true)) {
+ cmSystemTools::FileExists(current.QuotedLocation, true)) {
// The include statement producing this entry was a double-quote
// include and the included file is present in the directory of
// the source containing the include statement.
fullName = current.QuotedLocation;
} else {
- std::map<std::string, std::string>::iterator headerLocationIt =
+ auto headerLocationIt =
this->HeaderLocationCache.find(current.FileName);
if (headerLocationIt != this->HeaderLocationCache.end()) {
fullName = headerLocationIt->second;
} else {
- for (std::vector<std::string>::const_iterator i =
- this->IncludePath.begin();
- i != this->IncludePath.end(); ++i) {
+ for (std::string const& iPath : this->IncludePath) {
// Construct the name of the file as if it were in the current
// include directory. Avoid using a leading "./".
-
- tempPathStr =
- cmSystemTools::CollapseCombinedPath(*i, current.FileName);
+ std::string tmpPath =
+ cmSystemTools::CollapseFullPath(current.FileName, iPath);
// Look for the file in this location.
- if (cmSystemTools::FileExists(tempPathStr.c_str(), true)) {
- fullName = tempPathStr;
- HeaderLocationCache[current.FileName] = fullName;
+ if (cmSystemTools::FileExists(tmpPath, true)) {
+ fullName = tmpPath;
+ this->HeaderLocationCache[current.FileName] = std::move(tmpPath);
break;
}
}
@@ -172,9 +158,8 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// Complain if the file cannot be found and matches the complain
// regex.
if (fullName.empty() &&
- this->IncludeRegexComplain.find(current.FileName.c_str())) {
- cmSystemTools::Error("Cannot find file \"", current.FileName.c_str(),
- "\".");
+ this->IncludeRegexComplain.find(current.FileName)) {
+ cmSystemTools::Error("Cannot find file \"" + current.FileName + "\".");
return false;
}
@@ -184,18 +169,15 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
scanned.insert(fullName);
// Check whether this file is already in the cache
- std::map<std::string, cmIncludeLines*>::iterator fileIt =
- this->FileCache.find(fullName);
+ auto fileIt = this->FileCache.find(fullName);
if (fileIt != this->FileCache.end()) {
- fileIt->second->Used = true;
+ fileIt->second.Used = true;
dependencies.insert(fullName);
- for (std::vector<UnscannedEntry>::const_iterator incIt =
- fileIt->second->UnscannedEntries.begin();
- incIt != fileIt->second->UnscannedEntries.end(); ++incIt) {
- if (this->Encountered.find(incIt->FileName) ==
+ for (UnscannedEntry const& inc : fileIt->second.UnscannedEntries) {
+ if (this->Encountered.find(inc.FileName) ==
this->Encountered.end()) {
- this->Encountered.insert(incIt->FileName);
- this->Unscanned.push(*incIt);
+ this->Encountered.insert(inc.FileName);
+ this->Unscanned.push(inc);
}
}
} else {
@@ -213,7 +195,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// Scan this file for new dependencies. Pass the directory
// containing the file to handle double-quote includes.
std::string dir = cmSystemTools::GetFilenamePath(fullName);
- this->Scan(fin, dir.c_str(), fullName);
+ this->Scan(fin, dir, fullName);
} else {
// Skip file with encoding we do not implement.
}
@@ -229,19 +211,16 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// written by the original local generator for this directory
// convert the dependencies to paths relative to the home output
// directory. We must do the same here.
- std::string binDir = this->LocalGenerator->GetBinaryDirectory();
- std::string obj_i = this->LocalGenerator->ConvertToRelativePath(binDir, obj);
- std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str());
+ std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i);
internalDepends << obj_i << std::endl;
- for (std::set<std::string>::const_iterator i = dependencies.begin();
- i != dependencies.end(); ++i) {
- makeDepends
- << obj_m << ": "
- << cmSystemTools::ConvertToOutputPath(
- this->LocalGenerator->ConvertToRelativePath(binDir, *i).c_str())
- << std::endl;
- internalDepends << " " << *i << std::endl;
+ for (std::string const& dep : dependencies) {
+ makeDepends << obj_m << ": "
+ << cmSystemTools::ConvertToOutputPath(
+ this->LocalGenerator->MaybeConvertToRelativePath(binDir,
+ dep))
+ << std::endl;
+ internalDepends << " " << dep << std::endl;
}
makeDepends << std::endl;
@@ -259,27 +238,28 @@ void cmDependsC::ReadCacheFile()
}
std::string line;
- cmIncludeLines* cacheEntry = CM_NULLPTR;
+ cmIncludeLines* cacheEntry = nullptr;
bool haveFileName = false;
+ cmFileTime cacheFileTime;
+ bool const cacheFileTimeGood = cacheFileTime.Load(this->CacheFileName);
while (cmSystemTools::GetLineFromStream(fin, line)) {
if (line.empty()) {
- cacheEntry = CM_NULLPTR;
+ cacheEntry = nullptr;
haveFileName = false;
continue;
}
// the first line after an empty line is the name of the parsed file
if (!haveFileName) {
haveFileName = true;
- int newer = 0;
- cmFileTimeComparison comp;
- bool res = comp.FileTimeCompare(this->CacheFileName.c_str(),
- line.c_str(), &newer);
- if (res && newer == 1) // cache is newer than the parsed file
+ cmFileTime fileTime;
+ bool const res = cacheFileTimeGood && fileTime.Load(line);
+ bool const newer = res && cacheFileTime.Newer(fileTime);
+
+ if (res && newer) // cache is newer than the parsed file
{
- cacheEntry = new cmIncludeLines;
- this->FileCache[line] = cacheEntry;
+ cacheEntry = &this->FileCache[line];
}
// file doesn't exist, check that the regular expressions
// haven't changed
@@ -302,14 +282,14 @@ void cmDependsC::ReadCacheFile()
}
}
}
- } else if (cacheEntry != CM_NULLPTR) {
+ } else if (cacheEntry != nullptr) {
UnscannedEntry entry;
entry.FileName = line;
if (cmSystemTools::GetLineFromStream(fin, line)) {
if (line != "-") {
entry.QuotedLocation = line;
}
- cacheEntry->UnscannedEntries.push_back(entry);
+ cacheEntry->UnscannedEntries.push_back(std::move(entry));
}
}
}
@@ -330,20 +310,16 @@ void cmDependsC::WriteCacheFile() const
cacheOut << this->IncludeRegexComplainString << "\n\n";
cacheOut << this->IncludeRegexTransformString << "\n\n";
- for (std::map<std::string, cmIncludeLines*>::const_iterator fileIt =
- this->FileCache.begin();
- fileIt != this->FileCache.end(); ++fileIt) {
- if (fileIt->second->Used) {
- cacheOut << fileIt->first << std::endl;
-
- for (std::vector<UnscannedEntry>::const_iterator incIt =
- fileIt->second->UnscannedEntries.begin();
- incIt != fileIt->second->UnscannedEntries.end(); ++incIt) {
- cacheOut << incIt->FileName << std::endl;
- if (incIt->QuotedLocation.empty()) {
+ for (auto const& fileIt : this->FileCache) {
+ if (fileIt.second.Used) {
+ cacheOut << fileIt.first << std::endl;
+
+ for (UnscannedEntry const& inc : fileIt.second.UnscannedEntries) {
+ cacheOut << inc.FileName << std::endl;
+ if (inc.QuotedLocation.empty()) {
cacheOut << "-" << std::endl;
} else {
- cacheOut << incIt->QuotedLocation << std::endl;
+ cacheOut << inc.QuotedLocation << std::endl;
}
}
cacheOut << std::endl;
@@ -351,12 +327,11 @@ void cmDependsC::WriteCacheFile() const
}
}
-void cmDependsC::Scan(std::istream& is, const char* directory,
+void cmDependsC::Scan(std::istream& is, const std::string& directory,
const std::string& fullName)
{
- cmIncludeLines* newCacheEntry = new cmIncludeLines;
- newCacheEntry->Used = true;
- this->FileCache[fullName] = newCacheEntry;
+ cmIncludeLines& newCacheEntry = this->FileCache[fullName];
+ newCacheEntry.Used = true;
// Read one line at a time.
std::string line;
@@ -367,18 +342,18 @@ void cmDependsC::Scan(std::istream& is, const char* directory,
}
// Match include directives.
- if (this->IncludeRegexLine.find(line.c_str())) {
+ if (this->IncludeRegexLine.find(line)) {
// Get the file being included.
UnscannedEntry entry;
entry.FileName = this->IncludeRegexLine.match(2);
cmSystemTools::ConvertToUnixSlashes(entry.FileName);
if (this->IncludeRegexLine.match(3) == "\"" &&
- !cmSystemTools::FileIsFullPath(entry.FileName.c_str())) {
+ !cmSystemTools::FileIsFullPath(entry.FileName)) {
// This was a double-quoted include with a relative path. We
// must check for the file in the directory containing the
// file we are scanning.
entry.QuotedLocation =
- cmSystemTools::CollapseCombinedPath(directory, entry.FileName);
+ cmSystemTools::CollapseFullPath(entry.FileName, directory);
}
// Queue the file if it has not yet been encountered and it
@@ -391,8 +366,8 @@ void cmDependsC::Scan(std::istream& is, const char* directory,
// file their own directory by simply using "filename.h" (#12619)
// This kind of problem will be fixed when a more
// preprocessor-like implementation of this scanner is created.
- if (this->IncludeRegexScan.find(entry.FileName.c_str())) {
- newCacheEntry->UnscannedEntries.push_back(entry);
+ if (this->IncludeRegexScan.find(entry.FileName)) {
+ newCacheEntry.UnscannedEntries.push_back(entry);
if (this->Encountered.find(entry.FileName) ==
this->Encountered.end()) {
this->Encountered.insert(entry.FileName);
@@ -409,11 +384,10 @@ void cmDependsC::SetupTransforms()
std::vector<std::string> transformRules;
cmMakefile* mf = this->LocalGenerator->GetMakefile();
if (const char* xform = mf->GetDefinition("CMAKE_INCLUDE_TRANSFORMS")) {
- cmSystemTools::ExpandListArgument(xform, transformRules, true);
+ cmExpandList(xform, transformRules, true);
}
- for (std::vector<std::string>::const_iterator tri = transformRules.begin();
- tri != transformRules.end(); ++tri) {
- this->ParseTransform(*tri);
+ for (std::string const& tr : transformRules) {
+ this->ParseTransform(tr);
}
this->IncludeRegexTransformString = INCLUDE_REGEX_TRANSFORM_MARKER;
@@ -422,24 +396,22 @@ void cmDependsC::SetupTransforms()
// transformed.
std::string xform = "^([ \t]*[#%][ \t]*(include|import)[ \t]*)(";
const char* sep = "";
- for (TransformRulesType::const_iterator tri = this->TransformRules.begin();
- tri != this->TransformRules.end(); ++tri) {
+ for (auto const& tr : this->TransformRules) {
xform += sep;
- xform += tri->first;
+ xform += tr.first;
sep = "|";
}
xform += ")[ \t]*\\(([^),]*)\\)";
- this->IncludeRegexTransform.compile(xform.c_str());
+ this->IncludeRegexTransform.compile(xform);
// Build a string that encodes all transformation rules and will
// change when rules are changed.
this->IncludeRegexTransformString += xform;
- for (TransformRulesType::const_iterator tri = this->TransformRules.begin();
- tri != this->TransformRules.end(); ++tri) {
+ for (auto const& tr : this->TransformRules) {
this->IncludeRegexTransformString += " ";
- this->IncludeRegexTransformString += tri->first;
+ this->IncludeRegexTransformString += tr.first;
this->IncludeRegexTransformString += "(%)=";
- this->IncludeRegexTransformString += tri->second;
+ this->IncludeRegexTransformString += tr.second;
}
}
}
@@ -460,11 +432,10 @@ void cmDependsC::ParseTransform(std::string const& xform)
void cmDependsC::TransformLine(std::string& line)
{
// Check for a transform rule match. Return if none.
- if (!this->IncludeRegexTransform.find(line.c_str())) {
+ if (!this->IncludeRegexTransform.find(line)) {
return;
}
- TransformRulesType::const_iterator tri =
- this->TransformRules.find(this->IncludeRegexTransform.match(3));
+ auto tri = this->TransformRules.find(this->IncludeRegexTransform.match(3));
if (tri == this->TransformRules.end()) {
return;
}
@@ -472,11 +443,11 @@ void cmDependsC::TransformLine(std::string& line)
// Construct the transformed line.
std::string newline = this->IncludeRegexTransform.match(1);
std::string arg = this->IncludeRegexTransform.match(4);
- for (const char* c = tri->second.c_str(); *c; ++c) {
- if (*c == '%') {
+ for (char c : tri->second) {
+ if (c == '%') {
newline += arg;
} else {
- newline += *c;
+ newline += c;
}
}
diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h
index 250d40f8a..3bb6e36a3 100644
--- a/Source/cmDependsC.h
+++ b/Source/cmDependsC.h
@@ -3,18 +3,20 @@
#ifndef cmDependsC_h
#define cmDependsC_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmDepends.h"
-
-#include "cmsys/RegularExpression.hxx"
#include <iosfwd>
#include <map>
-#include <queue>
#include <set>
#include <string>
#include <vector>
+#include <queue>
+
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmDepends.h"
+
class cmLocalGenerator;
/** \class cmDependsC
@@ -22,27 +24,27 @@ class cmLocalGenerator;
*/
class cmDependsC : public cmDepends
{
- CM_DISABLE_COPY(cmDependsC)
-
public:
/** Checking instances need to know the build directory name and the
relative path from the build directory to the target file. */
cmDependsC();
- cmDependsC(cmLocalGenerator* lg, const char* targetDir,
- const std::string& lang,
- const std::map<std::string, DependencyVector>* validDeps);
+ cmDependsC(cmLocalGenerator* lg, const std::string& targetDir,
+ const std::string& lang, const DependencyMap* validDeps);
/** Virtual destructor to cleanup subclasses properly. */
- ~cmDependsC() CM_OVERRIDE;
+ ~cmDependsC() override;
+
+ cmDependsC(cmDependsC const&) = delete;
+ cmDependsC& operator=(cmDependsC const&) = delete;
protected:
// Implement writing/checking methods required by superclass.
bool WriteDependencies(const std::set<std::string>& sources,
const std::string& obj, std::ostream& makeDepends,
- std::ostream& internalDepends) CM_OVERRIDE;
+ std::ostream& internalDepends) override;
// Method to scan a single file.
- void Scan(std::istream& is, const char* directory,
+ void Scan(std::istream& is, const std::string& directory,
const std::string& fullName);
// Regular expression to identify C preprocessor include directives.
@@ -59,7 +61,7 @@ protected:
// Regex to transform #include lines.
std::string IncludeRegexTransformString;
cmsys::RegularExpression IncludeRegexTransform;
- typedef std::map<std::string, std::string> TransformRulesType;
+ using TransformRulesType = std::map<std::string, std::string>;
TransformRulesType TransformRules;
void SetupTransforms();
void ParseTransform(std::string const& xform);
@@ -75,20 +77,16 @@ public:
struct cmIncludeLines
{
- cmIncludeLines()
- : Used(false)
- {
- }
std::vector<UnscannedEntry> UnscannedEntries;
- bool Used;
+ bool Used = false;
};
protected:
- const std::map<std::string, DependencyVector>* ValidDeps;
+ const DependencyMap* ValidDeps = nullptr;
std::set<std::string> Encountered;
std::queue<UnscannedEntry> Unscanned;
- std::map<std::string, cmIncludeLines*> FileCache;
+ std::map<std::string, cmIncludeLines> FileCache;
std::map<std::string, std::string> HeaderLocationCache;
std::string CacheFileName;
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index 8b05fab49..36922029a 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -2,14 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmDependsFortran.h"
-#include "cmsys/FStream.hxx"
-#include <assert.h>
+#include <cassert>
+#include <cstdlib>
#include <iostream>
#include <map>
-#include <stdlib.h>
-#include <string.h>
#include <utility>
+#include "cmsys/FStream.hxx"
+
#include "cmFortranParser.h" /* Interface to parser object. */
#include "cmGeneratedFileStream.h"
#include "cmLocalGenerator.h"
@@ -17,12 +17,31 @@
#include "cmOutputConverter.h"
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
// TODO: Test compiler for the case of the mod file. Some always
// use lower case and some always use upper case. I do not know if any
// use the case from the source code.
+static void cmFortranModuleAppendUpperLower(std::string const& mod,
+ std::string& mod_upper,
+ std::string& mod_lower)
+{
+ std::string::size_type ext_len = 0;
+ if (cmHasLiteralSuffix(mod, ".mod")) {
+ ext_len = 4;
+ } else if (cmHasLiteralSuffix(mod, ".smod")) {
+ ext_len = 5;
+ } else if (cmHasLiteralSuffix(mod, ".sub")) {
+ ext_len = 4;
+ }
+ std::string const& name = mod.substr(0, mod.size() - ext_len);
+ std::string const& ext = mod.substr(mod.size() - ext_len);
+ mod_upper += cmSystemTools::UpperCase(name) + ext;
+ mod_lower += mod;
+}
+
class cmDependsFortranInternals
{
public:
@@ -30,17 +49,17 @@ public:
std::set<std::string> TargetProvides;
// Map modules required by this target to locations.
- typedef std::map<std::string, std::string> TargetRequiresMap;
+ using TargetRequiresMap = std::map<std::string, std::string>;
TargetRequiresMap TargetRequires;
// Information about each object file.
- typedef std::map<std::string, cmFortranSourceInfo> ObjectInfoMap;
+ using ObjectInfoMap = std::map<std::string, cmFortranSourceInfo>;
ObjectInfoMap ObjectInfo;
- cmFortranSourceInfo& CreateObjectInfo(const char* obj, const char* src)
+ cmFortranSourceInfo& CreateObjectInfo(const std::string& obj,
+ const std::string& src)
{
- std::map<std::string, cmFortranSourceInfo>::iterator i =
- this->ObjectInfo.find(obj);
+ auto i = this->ObjectInfo.find(obj);
if (i == this->ObjectInfo.end()) {
std::map<std::string, cmFortranSourceInfo>::value_type entry(
obj, cmFortranSourceInfo());
@@ -51,10 +70,7 @@ public:
}
};
-cmDependsFortran::cmDependsFortran()
- : Internal(CM_NULLPTR)
-{
-}
+cmDependsFortran::cmDependsFortran() = default;
cmDependsFortran::cmDependsFortran(cmLocalGenerator* lg)
: cmDepends(lg)
@@ -68,20 +84,22 @@ cmDependsFortran::cmDependsFortran(cmLocalGenerator* lg)
cmMakefile* mf = this->LocalGenerator->GetMakefile();
if (const char* c_defines =
mf->GetDefinition("CMAKE_TARGET_DEFINITIONS_Fortran")) {
- cmSystemTools::ExpandListArgument(c_defines, definitions);
+ cmExpandList(c_defines, definitions);
}
// translate i.e. FOO=BAR to FOO and add it to the list of defined
// preprocessor symbols
- for (std::vector<std::string>::const_iterator it = definitions.begin();
- it != definitions.end(); ++it) {
- std::string def = *it;
+ for (std::string def : definitions) {
std::string::size_type assignment = def.find('=');
if (assignment != std::string::npos) {
- def = it->substr(0, assignment);
+ def = def.substr(0, assignment);
}
this->PPDefinitions.insert(def);
}
+
+ this->CompilerId = mf->GetSafeDefinition("CMAKE_Fortran_COMPILER_ID");
+ this->SModSep = mf->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_SEP");
+ this->SModExt = mf->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_EXT");
}
cmDependsFortran::~cmDependsFortran()
@@ -104,17 +122,19 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources,
return false;
}
+ cmFortranCompiler fc;
+ fc.Id = this->CompilerId;
+ fc.SModSep = this->SModSep;
+ fc.SModExt = this->SModExt;
+
bool okay = true;
- for (std::set<std::string>::const_iterator it = sources.begin();
- it != sources.end(); ++it) {
- const std::string& src = *it;
+ for (std::string const& src : sources) {
// Get the information object for this source.
- cmFortranSourceInfo& info =
- this->Internal->CreateObjectInfo(obj.c_str(), src.c_str());
+ cmFortranSourceInfo& info = this->Internal->CreateObjectInfo(obj, src);
// Create the parser object. The constructor takes info by reference,
// so we may look into the resulting objects later.
- cmFortranParser parser(this->IncludePath, this->PPDefinitions, info);
+ cmFortranParser parser(fc, this->IncludePath, this->PPDefinitions, info);
// Push on the starting file.
cmFortranParser_FilePush(&parser, src.c_str());
@@ -141,7 +161,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
this->LocateModules();
// Get the directory in which stamp files will be stored.
- const char* stamp_dir = this->TargetDirectory.c_str();
+ const std::string& stamp_dir = this->TargetDirectory;
// Get the directory in which module files will be created.
cmMakefile* mf = this->LocalGenerator->GetMakefile();
@@ -152,52 +172,39 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
}
// Actually write dependencies to the streams.
- typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
+ using ObjectInfoMap = cmDependsFortranInternals::ObjectInfoMap;
ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
- for (ObjectInfoMap::const_iterator i = objInfo.begin(); i != objInfo.end();
- ++i) {
- if (!this->WriteDependenciesReal(i->first.c_str(), i->second, mod_dir,
- stamp_dir, makeDepends,
- internalDepends)) {
+ for (auto const& i : objInfo) {
+ if (!this->WriteDependenciesReal(i.first, i.second, mod_dir, stamp_dir,
+ makeDepends, internalDepends)) {
return false;
}
}
// Store the list of modules provided by this target.
- std::string fiName = this->TargetDirectory;
- fiName += "/fortran.internal";
- cmGeneratedFileStream fiStream(fiName.c_str());
+ std::string fiName = cmStrCat(this->TargetDirectory, "/fortran.internal");
+ cmGeneratedFileStream fiStream(fiName);
fiStream << "# The fortran modules provided by this target.\n";
fiStream << "provides\n";
std::set<std::string> const& provides = this->Internal->TargetProvides;
- for (std::set<std::string>::const_iterator i = provides.begin();
- i != provides.end(); ++i) {
- fiStream << " " << *i << "\n";
+ for (std::string const& i : provides) {
+ fiStream << " " << i << "\n";
}
// Create a script to clean the modules.
if (!provides.empty()) {
- std::string fcName = this->TargetDirectory;
- fcName += "/cmake_clean_Fortran.cmake";
- cmGeneratedFileStream fcStream(fcName.c_str());
+ std::string fcName =
+ cmStrCat(this->TargetDirectory, "/cmake_clean_Fortran.cmake");
+ cmGeneratedFileStream fcStream(fcName);
fcStream << "# Remove fortran modules provided by this target.\n";
fcStream << "FILE(REMOVE";
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
- for (std::set<std::string>::const_iterator i = provides.begin();
- i != provides.end(); ++i) {
- std::string mod_upper = mod_dir;
- mod_upper += "/";
- mod_upper += cmSystemTools::UpperCase(*i);
- mod_upper += ".mod";
- std::string mod_lower = mod_dir;
- mod_lower += "/";
- mod_lower += *i;
- mod_lower += ".mod";
- std::string stamp = stamp_dir;
- stamp += "/";
- stamp += *i;
- stamp += ".mod.stamp";
+ for (std::string const& i : provides) {
+ std::string mod_upper = cmStrCat(mod_dir, '/');
+ std::string mod_lower = cmStrCat(mod_dir, '/');
+ cmFortranModuleAppendUpperLower(i, mod_upper, mod_lower);
+ std::string stamp = cmStrCat(stamp_dir, '/', i, ".stamp");
fcStream << "\n";
fcStream << " \""
<< this->MaybeConvertToRelativePath(currentBinDir, mod_lower)
@@ -217,18 +224,16 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
void cmDependsFortran::LocateModules()
{
// Collect the set of modules provided and required by all sources.
- typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
+ using ObjectInfoMap = cmDependsFortranInternals::ObjectInfoMap;
ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
- for (ObjectInfoMap::const_iterator infoI = objInfo.begin();
- infoI != objInfo.end(); ++infoI) {
- cmFortranSourceInfo const& info = infoI->second;
+ for (auto const& infoI : objInfo) {
+ cmFortranSourceInfo const& info = infoI.second;
// Include this module in the set provided by this target.
this->Internal->TargetProvides.insert(info.Provides.begin(),
info.Provides.end());
- for (std::set<std::string>::const_iterator i = info.Requires.begin();
- i != info.Requires.end(); ++i) {
- this->Internal->TargetRequires[*i] = "";
+ for (std::string const& r : info.Requires) {
+ this->Internal->TargetRequires[r].clear();
}
}
@@ -245,31 +250,29 @@ void cmDependsFortran::LocateModules()
std::vector<std::string> infoFiles;
if (const char* infoFilesValue =
mf->GetDefinition("CMAKE_TARGET_LINKED_INFO_FILES")) {
- cmSystemTools::ExpandListArgument(infoFilesValue, infoFiles);
+ cmExpandList(infoFilesValue, infoFiles);
}
- for (std::vector<std::string>::const_iterator i = infoFiles.begin();
- i != infoFiles.end(); ++i) {
- std::string targetDir = cmSystemTools::GetFilenamePath(*i);
+ for (std::string const& i : infoFiles) {
+ std::string targetDir = cmSystemTools::GetFilenamePath(i);
std::string fname = targetDir + "/fortran.internal";
cmsys::ifstream fin(fname.c_str());
if (fin) {
- this->MatchRemoteModules(fin, targetDir.c_str());
+ this->MatchRemoteModules(fin, targetDir);
}
}
}
void cmDependsFortran::MatchLocalModules()
{
- const char* stampDir = this->TargetDirectory.c_str();
+ std::string const& stampDir = this->TargetDirectory;
std::set<std::string> const& provides = this->Internal->TargetProvides;
- for (std::set<std::string>::const_iterator i = provides.begin();
- i != provides.end(); ++i) {
- this->ConsiderModule(i->c_str(), stampDir);
+ for (std::string const& i : provides) {
+ this->ConsiderModule(i, stampDir);
}
}
void cmDependsFortran::MatchRemoteModules(std::istream& fin,
- const char* stampDir)
+ const std::string& stampDir)
{
std::string line;
bool doing_provides = false;
@@ -281,7 +284,15 @@ void cmDependsFortran::MatchRemoteModules(std::istream& fin,
if (line[0] == ' ') {
if (doing_provides) {
- this->ConsiderModule(line.c_str() + 1, stampDir);
+ std::string mod = line;
+ if (!cmHasLiteralSuffix(mod, ".mod") &&
+ !cmHasLiteralSuffix(mod, ".smod") &&
+ !cmHasLiteralSuffix(mod, ".sub")) {
+ // Support fortran.internal files left by older versions of CMake.
+ // They do not include the ".mod" extension.
+ mod += ".mod";
+ }
+ this->ConsiderModule(mod.substr(1), stampDir);
}
} else if (line == "provides") {
doing_provides = true;
@@ -291,143 +302,109 @@ void cmDependsFortran::MatchRemoteModules(std::istream& fin,
}
}
-void cmDependsFortran::ConsiderModule(const char* name, const char* stampDir)
+void cmDependsFortran::ConsiderModule(const std::string& name,
+ const std::string& stampDir)
{
// Locate each required module.
- typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
- TargetRequiresMap::iterator required =
- this->Internal->TargetRequires.find(name);
+ auto required = this->Internal->TargetRequires.find(name);
if (required != this->Internal->TargetRequires.end() &&
required->second.empty()) {
// The module is provided by a CMake target. It will have a stamp file.
- std::string stampFile = stampDir;
- stampFile += "/";
- stampFile += name;
- stampFile += ".mod.stamp";
+ std::string stampFile = cmStrCat(stampDir, '/', name, ".stamp");
required->second = stampFile;
}
}
-bool cmDependsFortran::WriteDependenciesReal(const char* obj,
+bool cmDependsFortran::WriteDependenciesReal(std::string const& obj,
cmFortranSourceInfo const& info,
std::string const& mod_dir,
- const char* stamp_dir,
+ std::string const& stamp_dir,
std::ostream& makeDepends,
std::ostream& internalDepends)
{
- typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
-
// Get the source file for this object.
- const char* src = info.Source.c_str();
+ std::string const& src = info.Source;
// Write the include dependencies to the output stream.
std::string binDir = this->LocalGenerator->GetBinaryDirectory();
std::string obj_i = this->MaybeConvertToRelativePath(binDir, obj);
- std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i.c_str());
+ std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i);
internalDepends << obj_i << std::endl;
internalDepends << " " << src << std::endl;
- for (std::set<std::string>::const_iterator i = info.Includes.begin();
- i != info.Includes.end(); ++i) {
+ for (std::string const& i : info.Includes) {
makeDepends << obj_m << ": "
<< cmSystemTools::ConvertToOutputPath(
- this->MaybeConvertToRelativePath(binDir, *i).c_str())
+ this->MaybeConvertToRelativePath(binDir, i))
<< std::endl;
- internalDepends << " " << *i << std::endl;
+ internalDepends << " " << i << std::endl;
}
makeDepends << std::endl;
// Write module requirements to the output stream.
- for (std::set<std::string>::const_iterator i = info.Requires.begin();
- i != info.Requires.end(); ++i) {
+ for (std::string const& i : info.Requires) {
// Require only modules not provided in the same source.
- if (std::set<std::string>::const_iterator(info.Provides.find(*i)) !=
- info.Provides.end()) {
+ if (info.Provides.find(i) != info.Provides.cend()) {
continue;
}
- // If the module is provided in this target special handling is
- // needed.
- if (this->Internal->TargetProvides.find(*i) !=
- this->Internal->TargetProvides.end()) {
- // The module is provided by a different source in the same
- // target. Add the proxy dependency to make sure the other
- // source builds first.
- std::string proxy = stamp_dir;
- proxy += "/";
- proxy += *i;
- proxy += ".mod.proxy";
- proxy = cmSystemTools::ConvertToOutputPath(
- this->MaybeConvertToRelativePath(binDir, proxy).c_str());
-
- // since we require some things add them to our list of requirements
- makeDepends << obj_m << ".requires: " << proxy << std::endl;
- }
-
// The object file should depend on timestamped files for the
// modules it uses.
- TargetRequiresMap::const_iterator required =
- this->Internal->TargetRequires.find(*i);
+ auto required = this->Internal->TargetRequires.find(i);
if (required == this->Internal->TargetRequires.end()) {
abort();
}
if (!required->second.empty()) {
// This module is known. Depend on its timestamp file.
std::string stampFile = cmSystemTools::ConvertToOutputPath(
- this->MaybeConvertToRelativePath(binDir, required->second).c_str());
+ this->MaybeConvertToRelativePath(binDir, required->second));
makeDepends << obj_m << ": " << stampFile << "\n";
} else {
// This module is not known to CMake. Try to locate it where
// the compiler will and depend on that.
std::string module;
- if (this->FindModule(*i, module)) {
+ if (this->FindModule(i, module)) {
module = cmSystemTools::ConvertToOutputPath(
- this->MaybeConvertToRelativePath(binDir, module).c_str());
+ this->MaybeConvertToRelativePath(binDir, module));
makeDepends << obj_m << ": " << module << "\n";
}
}
}
- // Write provided modules to the output stream.
- for (std::set<std::string>::const_iterator i = info.Provides.begin();
- i != info.Provides.end(); ++i) {
- std::string proxy = stamp_dir;
- proxy += "/";
- proxy += *i;
- proxy += ".mod.proxy";
- proxy = cmSystemTools::ConvertToOutputPath(
- this->MaybeConvertToRelativePath(binDir, proxy).c_str());
- makeDepends << proxy << ": " << obj_m << ".provides" << std::endl;
- }
-
// If any modules are provided then they must be converted to stamp files.
if (!info.Provides.empty()) {
// Create a target to copy the module after the object file
// changes.
- makeDepends << obj_m << ".provides.build:\n";
- for (std::set<std::string>::const_iterator i = info.Provides.begin();
- i != info.Provides.end(); ++i) {
+ for (std::string const& i : info.Provides) {
// Include this module in the set provided by this target.
- this->Internal->TargetProvides.insert(*i);
+ this->Internal->TargetProvides.insert(i);
// Always use lower case for the mod stamp file name. The
// cmake_copy_f90_mod will call back to this class, which will
// try various cases for the real mod file name.
- std::string m = cmSystemTools::LowerCase(*i);
- std::string modFile = mod_dir;
- modFile += "/";
- modFile += *i;
+ std::string modFile = cmStrCat(mod_dir, '/', i);
modFile = this->LocalGenerator->ConvertToOutputFormat(
this->MaybeConvertToRelativePath(binDir, modFile),
cmOutputConverter::SHELL);
- std::string stampFile = stamp_dir;
- stampFile += "/";
- stampFile += m;
- stampFile += ".mod.stamp";
- stampFile = this->LocalGenerator->ConvertToOutputFormat(
- this->MaybeConvertToRelativePath(binDir, stampFile),
- cmOutputConverter::SHELL);
+ std::string stampFile = cmStrCat(stamp_dir, '/', i, ".stamp");
+ stampFile = this->MaybeConvertToRelativePath(binDir, stampFile);
+ std::string const stampFileForShell =
+ this->LocalGenerator->ConvertToOutputFormat(stampFile,
+ cmOutputConverter::SHELL);
+ std::string const stampFileForMake =
+ cmSystemTools::ConvertToOutputPath(stampFile);
+
+ makeDepends << obj_m << ".provides.build"
+ << ": " << stampFileForMake << "\n";
+ // Note that when cmake_copy_f90_mod finds that a module file
+ // and the corresponding stamp file have no differences, the stamp
+ // file is not updated. In such case the stamp file will be always
+ // older than its prerequisite and trigger cmake_copy_f90_mod
+ // on each new build. This is expected behavior for incremental
+ // builds and can not be changed without preforming recursive make
+ // calls that would considerably slow down the building process.
+ makeDepends << stampFileForMake << ": " << obj_m << "\n";
makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod " << modFile
- << " " << stampFile;
+ << " " << stampFileForShell;
cmMakefile* mf = this->LocalGenerator->GetMakefile();
const char* cid = mf->GetDefinition("CMAKE_Fortran_COMPILER_ID");
if (cid && *cid) {
@@ -435,17 +412,16 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
}
makeDepends << "\n";
}
- // After copying the modules update the timestamp file so that
- // copying will not be done again until the source rebuilds.
+ makeDepends << obj_m << ".provides.build:\n";
+ // After copying the modules update the timestamp file.
makeDepends << "\t$(CMAKE_COMMAND) -E touch " << obj_m
<< ".provides.build\n";
// Make sure the module timestamp rule is evaluated by the time
// the target finishes building.
- std::string driver = this->TargetDirectory;
- driver += "/build";
+ std::string driver = cmStrCat(this->TargetDirectory, "/build");
driver = cmSystemTools::ConvertToOutputPath(
- this->MaybeConvertToRelativePath(binDir, driver).c_str());
+ this->MaybeConvertToRelativePath(binDir, driver));
makeDepends << driver << ": " << obj_m << ".provides.build\n";
}
@@ -455,29 +431,23 @@ bool cmDependsFortran::WriteDependenciesReal(const char* obj,
bool cmDependsFortran::FindModule(std::string const& name, std::string& module)
{
// Construct possible names for the module file.
- std::string mod_upper = cmSystemTools::UpperCase(name);
- std::string mod_lower = name;
- mod_upper += ".mod";
- mod_lower += ".mod";
+ std::string mod_upper;
+ std::string mod_lower;
+ cmFortranModuleAppendUpperLower(name, mod_upper, mod_lower);
// Search the include path for the module.
std::string fullName;
- for (std::vector<std::string>::const_iterator i = this->IncludePath.begin();
- i != this->IncludePath.end(); ++i) {
+ for (std::string const& ip : this->IncludePath) {
// Try the lower-case name.
- fullName = *i;
- fullName += "/";
- fullName += mod_lower;
- if (cmSystemTools::FileExists(fullName.c_str(), true)) {
+ fullName = cmStrCat(ip, '/', mod_lower);
+ if (cmSystemTools::FileExists(fullName, true)) {
module = fullName;
return true;
}
// Try the upper-case name.
- fullName = *i;
- fullName += "/";
- fullName += mod_upper;
- if (cmSystemTools::FileExists(fullName.c_str(), true)) {
+ fullName = cmStrCat(ip, '/', mod_upper);
+ if (cmSystemTools::FileExists(fullName, true)) {
module = fullName;
return true;
}
@@ -503,20 +473,22 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
if (args.size() >= 5) {
compilerId = args[4];
}
+ if (!cmHasLiteralSuffix(mod, ".mod") && !cmHasLiteralSuffix(mod, ".smod") &&
+ !cmHasLiteralSuffix(mod, ".sub")) {
+ // Support depend.make files left by older versions of CMake.
+ // They do not include the ".mod" extension.
+ mod += ".mod";
+ }
std::string mod_dir = cmSystemTools::GetFilenamePath(mod);
if (!mod_dir.empty()) {
mod_dir += "/";
}
std::string mod_upper = mod_dir;
- mod_upper += cmSystemTools::UpperCase(cmSystemTools::GetFilenameName(mod));
std::string mod_lower = mod_dir;
- mod_lower += cmSystemTools::LowerCase(cmSystemTools::GetFilenameName(mod));
- mod += ".mod";
- mod_upper += ".mod";
- mod_lower += ".mod";
- if (cmSystemTools::FileExists(mod_upper.c_str(), true)) {
- if (cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(),
- compilerId.c_str())) {
+ cmFortranModuleAppendUpperLower(cmSystemTools::GetFilenameName(mod),
+ mod_upper, mod_lower);
+ if (cmSystemTools::FileExists(mod_upper, true)) {
+ if (cmDependsFortran::ModulesDiffer(mod_upper, stamp, compilerId)) {
if (!cmSystemTools::CopyFileAlways(mod_upper, stamp)) {
std::cerr << "Error copying Fortran module from \"" << mod_upper
<< "\" to \"" << stamp << "\".\n";
@@ -525,9 +497,8 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
}
return true;
}
- if (cmSystemTools::FileExists(mod_lower.c_str(), true)) {
- if (cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
- compilerId.c_str())) {
+ if (cmSystemTools::FileExists(mod_lower, true)) {
+ if (cmDependsFortran::ModulesDiffer(mod_lower, stamp, compilerId)) {
if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) {
std::cerr << "Error copying Fortran module from \"" << mod_lower
<< "\" to \"" << stamp << "\".\n";
@@ -594,9 +565,9 @@ static bool cmFortranStreamsDiffer(std::istream& ifs1, std::istream& ifs2)
return true;
}
-bool cmDependsFortran::ModulesDiffer(const char* modFile,
- const char* stampFile,
- const char* compilerId)
+bool cmDependsFortran::ModulesDiffer(const std::string& modFile,
+ const std::string& stampFile,
+ const std::string& compilerId)
{
/*
gnu >= 4.9:
@@ -616,7 +587,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
A mod file is a binary file.
However, looking into both generated bar.mod files with a hex editor
shows that they differ only before a sequence linefeed-zero (0x0A 0x00)
- which is located some bytes in front of the absoulte path to the source
+ which is located some bytes in front of the absolute path to the source
file.
sun:
@@ -630,16 +601,17 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
* source is compiled twice
* -SunPro
*/
- if (strcmp(compilerId, "SunPro") == 0) {
+ if (compilerId == "SunPro") {
return cmSystemTools::FilesDiffer(modFile, stampFile);
}
#if defined(_WIN32) || defined(__CYGWIN__)
- cmsys::ifstream finModFile(modFile, std::ios::in | std::ios::binary);
- cmsys::ifstream finStampFile(stampFile, std::ios::in | std::ios::binary);
+ cmsys::ifstream finModFile(modFile.c_str(), std::ios::in | std::ios::binary);
+ cmsys::ifstream finStampFile(stampFile.c_str(),
+ std::ios::in | std::ios::binary);
#else
- cmsys::ifstream finModFile(modFile);
- cmsys::ifstream finStampFile(stampFile);
+ cmsys::ifstream finModFile(modFile.c_str());
+ cmsys::ifstream finStampFile(stampFile.c_str());
#endif
if (!finModFile || !finStampFile) {
// At least one of the files does not exist. The modules differ.
@@ -654,7 +626,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
* Eat the stream content until all recompile only related changes
* are left behind.
*/
- if (strcmp(compilerId, "GNU") == 0) {
+ if (compilerId == "GNU") {
// GNU Fortran 4.9 and later compress .mod files with gzip
// but also do not include a date so we can fall through to
// compare them without skipping any prefix.
@@ -677,7 +649,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
return true;
}
}
- } else if (strcmp(compilerId, "Intel") == 0) {
+ } else if (compilerId == "Intel") {
const char seq[2] = { '\n', '\0' };
const int seqlen = 2;
@@ -709,9 +681,9 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
std::string cmDependsFortran::MaybeConvertToRelativePath(
std::string const& base, std::string const& path)
{
- if (!cmOutputConverter::ContainedInDirectory(
- base, path, this->LocalGenerator->GetStateSnapshot().GetDirectory())) {
+ if (!this->LocalGenerator->GetStateSnapshot().GetDirectory().ContainsBoth(
+ base, path)) {
return path;
}
- return cmOutputConverter::ForceToRelativePath(base, path);
+ return cmSystemTools::ForceToRelativePath(base, path);
}
diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h
index ec208af3a..04851152e 100644
--- a/Source/cmDependsFortran.h
+++ b/Source/cmDependsFortran.h
@@ -3,7 +3,7 @@
#ifndef cmFortran_h
#define cmFortran_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <set>
@@ -21,8 +21,6 @@ class cmLocalGenerator;
*/
class cmDependsFortran : public cmDepends
{
- CM_DISABLE_COPY(cmDependsFortran)
-
public:
/** Checking instances need to know the build directory name and the
relative path from the build directory to the target file. */
@@ -35,7 +33,10 @@ public:
cmDependsFortran(cmLocalGenerator* lg);
/** Virtual destructor to cleanup subclasses properly. */
- ~cmDependsFortran() CM_OVERRIDE;
+ ~cmDependsFortran() override;
+
+ cmDependsFortran(cmDependsFortran const&) = delete;
+ cmDependsFortran& operator=(cmDependsFortran const&) = delete;
/** Callback from build system after a .mod file has been generated
by a Fortran90 compiler to copy the .mod file to the
@@ -44,39 +45,46 @@ public:
/** Determine if a mod file and the corresponding mod.stamp file
are representing different module information. */
- static bool ModulesDiffer(const char* modFile, const char* stampFile,
- const char* compilerId);
+ static bool ModulesDiffer(const std::string& modFile,
+ const std::string& stampFile,
+ const std::string& compilerId);
protected:
// Finalize the dependency information for the target.
bool Finalize(std::ostream& makeDepends,
- std::ostream& internalDepends) CM_OVERRIDE;
+ std::ostream& internalDepends) override;
// Find all the modules required by the target.
void LocateModules();
void MatchLocalModules();
- void MatchRemoteModules(std::istream& fin, const char* stampDir);
- void ConsiderModule(const char* name, const char* stampDir);
+ void MatchRemoteModules(std::istream& fin, const std::string& stampDir);
+ void ConsiderModule(const std::string& name, const std::string& stampDir);
bool FindModule(std::string const& name, std::string& module);
// Implement writing/checking methods required by superclass.
bool WriteDependencies(const std::set<std::string>& sources,
const std::string& file, std::ostream& makeDepends,
- std::ostream& internalDepends) CM_OVERRIDE;
+ std::ostream& internalDepends) override;
- // Actually write the depenencies to the streams.
- bool WriteDependenciesReal(const char* obj, cmFortranSourceInfo const& info,
- std::string const& mod_dir, const char* stamp_dir,
+ // Actually write the dependencies to the streams.
+ bool WriteDependenciesReal(std::string const& obj,
+ cmFortranSourceInfo const& info,
+ std::string const& mod_dir,
+ std::string const& stamp_dir,
std::ostream& makeDepends,
std::ostream& internalDepends);
// The source file from which to start scanning.
std::string SourceFile;
+ std::string CompilerId;
+ std::string SModSep;
+ std::string SModExt;
+
std::set<std::string> PPDefinitions;
// Internal implementation details.
- cmDependsFortranInternals* Internal;
+ cmDependsFortranInternals* Internal = nullptr;
private:
std::string MaybeConvertToRelativePath(std::string const& base,
diff --git a/Source/cmDependsJava.cxx b/Source/cmDependsJava.cxx
index 29938ba36..b17b2ba74 100644
--- a/Source/cmDependsJava.cxx
+++ b/Source/cmDependsJava.cxx
@@ -4,13 +4,9 @@
#include "cmSystemTools.h"
-cmDependsJava::cmDependsJava()
-{
-}
+cmDependsJava::cmDependsJava() = default;
-cmDependsJava::~cmDependsJava()
-{
-}
+cmDependsJava::~cmDependsJava() = default;
bool cmDependsJava::WriteDependencies(const std::set<std::string>& sources,
const std::string& /*obj*/,
@@ -27,8 +23,8 @@ bool cmDependsJava::WriteDependencies(const std::set<std::string>& sources,
}
bool cmDependsJava::CheckDependencies(
- std::istream& /*internalDepends*/, const char* /*internalDependsFileName*/,
- std::map<std::string, DependencyVector>& /*validDeps*/)
+ std::istream& /*internalDepends*/,
+ const std::string& /*internalDependsFileName*/, DependencyMap& /*validDeps*/)
{
return true;
}
diff --git a/Source/cmDependsJava.h b/Source/cmDependsJava.h
index a07bf0979..2a9025101 100644
--- a/Source/cmDependsJava.h
+++ b/Source/cmDependsJava.h
@@ -3,38 +3,38 @@
#ifndef cmDependsJava_h
#define cmDependsJava_h
-#include "cmConfigure.h"
-
-#include "cmDepends.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
-#include <map>
#include <set>
#include <string>
+#include "cmDepends.h"
+
/** \class cmDependsJava
* \brief Dependency scanner for Java class files.
*/
class cmDependsJava : public cmDepends
{
- CM_DISABLE_COPY(cmDependsJava)
-
public:
/** Checking instances need to know the build directory name and the
relative path from the build directory to the target file. */
cmDependsJava();
/** Virtual destructor to cleanup subclasses properly. */
- ~cmDependsJava() CM_OVERRIDE;
+ ~cmDependsJava() override;
+
+ cmDependsJava(cmDependsJava const&) = delete;
+ cmDependsJava& operator=(cmDependsJava const&) = delete;
protected:
// Implement writing/checking methods required by superclass.
bool WriteDependencies(const std::set<std::string>& sources,
const std::string& file, std::ostream& makeDepends,
- std::ostream& internalDepends) CM_OVERRIDE;
- bool CheckDependencies(
- std::istream& internalDepends, const char* internalDependsFileName,
- std::map<std::string, DependencyVector>& validDeps) CM_OVERRIDE;
+ std::ostream& internalDepends) override;
+ bool CheckDependencies(std::istream& internalDepends,
+ const std::string& internalDependsFileName,
+ DependencyMap& validDeps) override;
};
#endif
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx
index 7bc91bfd4..516bbbfe0 100644
--- a/Source/cmDependsJavaParserHelper.cxx
+++ b/Source/cmDependsJavaParserHelper.cxx
@@ -2,16 +2,18 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmDependsJavaParserHelper.h"
-#include "cmConfigure.h"
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <iostream>
+#include <utility>
-#include "cmDependsJavaLexer.h"
-#include "cmSystemTools.h"
+#include <cm/string_view>
#include "cmsys/FStream.hxx"
-#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+
+#include "cmDependsJavaLexer.h"
+#include "cmSystemTools.h"
int cmDependsJava_yyparse(yyscan_t yyscanner);
@@ -24,7 +26,7 @@ cmDependsJavaParserHelper::cmDependsJavaParserHelper()
CurrentClass tl;
tl.Name = "*";
- this->ClassStack.push_back(tl);
+ this->ClassStack.push_back(std::move(tl));
}
cmDependsJavaParserHelper::~cmDependsJavaParserHelper()
@@ -42,10 +44,8 @@ void cmDependsJavaParserHelper::CurrentClass::AddFileNamesForPrinting(
}
rname += this->Name;
files->push_back(rname);
- std::vector<CurrentClass>::const_iterator it;
- for (it = this->NestedClasses.begin(); it != this->NestedClasses.end();
- ++it) {
- it->AddFileNamesForPrinting(files, rname.c_str(), sep);
+ for (CurrentClass const& nc : this->NestedClasses) {
+ nc.AddFileNamesForPrinting(files, rname.c_str(), sep);
}
}
@@ -57,7 +57,7 @@ void cmDependsJavaParserHelper::DeallocateParserType(char** pt)
if (!*pt) {
return;
}
- *pt = CM_NULLPTR;
+ *pt = nullptr;
this->UnionsAvailable--;
}
@@ -66,25 +66,22 @@ void cmDependsJavaParserHelper::AddClassFound(const char* sclass)
if (!sclass) {
return;
}
- std::vector<std::string>::iterator it;
- for (it = this->ClassesFound.begin(); it != this->ClassesFound.end(); it++) {
- if (*it == sclass) {
+ for (std::string const& cf : this->ClassesFound) {
+ if (cf == sclass) {
return;
}
}
- this->ClassesFound.push_back(sclass);
+ this->ClassesFound.emplace_back(sclass);
}
void cmDependsJavaParserHelper::AddPackagesImport(const char* sclass)
{
- std::vector<std::string>::iterator it;
- for (it = this->PackagesImport.begin(); it != this->PackagesImport.end();
- it++) {
- if (*it == sclass) {
+ for (std::string const& pi : this->PackagesImport) {
+ if (pi == sclass) {
return;
}
}
- this->PackagesImport.push_back(sclass);
+ this->PackagesImport.emplace_back(sclass);
}
void cmDependsJavaParserHelper::SafePrintMissing(const char* str, int line,
@@ -96,9 +93,9 @@ void cmDependsJavaParserHelper::SafePrintMissing(const char* str, int line,
for (cc = 0; cc < strlen(str); cc++) {
unsigned char ch = str[cc];
if (ch >= 32 && ch <= 126) {
- std::cout << (char)ch;
+ std::cout << static_cast<char>(ch);
} else {
- std::cout << "<" << (int)ch << ">";
+ std::cout << "<" << static_cast<int>(ch) << ">";
break;
}
}
@@ -158,15 +155,15 @@ void cmDependsJavaParserHelper::PrepareElement(
cmDependsJavaParserHelper::ParserType* me)
{
// Inititalize self
- me->str = CM_NULLPTR;
+ me->str = nullptr;
}
void cmDependsJavaParserHelper::AllocateParserType(
cmDependsJavaParserHelper::ParserType* pt, const char* str, int len)
{
- pt->str = CM_NULLPTR;
+ pt->str = nullptr;
if (len == 0) {
- len = (int)strlen(str);
+ len = static_cast<int>(strlen(str));
}
if (len == 0) {
return;
@@ -182,7 +179,7 @@ void cmDependsJavaParserHelper::StartClass(const char* cls)
{
CurrentClass cl;
cl.Name = cls;
- this->ClassStack.push_back(cl);
+ this->ClassStack.push_back(std::move(cl));
this->CurrentDepth++;
}
@@ -210,10 +207,8 @@ void cmDependsJavaParserHelper::PrintClasses()
std::cerr << "Error when parsing. No classes on class stack" << std::endl;
abort();
}
- std::vector<std::string> files = this->GetFilesProduced();
- std::vector<std::string>::iterator sit;
- for (sit = files.begin(); sit != files.end(); ++sit) {
- std::cout << " " << *sit << ".class" << std::endl;
+ for (std::string const& f : this->GetFilesProduced()) {
+ std::cout << " " << f << ".class" << std::endl;
}
}
@@ -221,10 +216,8 @@ std::vector<std::string> cmDependsJavaParserHelper::GetFilesProduced()
{
std::vector<std::string> files;
CurrentClass const& toplevel = this->ClassStack.front();
- std::vector<CurrentClass>::const_iterator it;
- for (it = toplevel.NestedClasses.begin(); it != toplevel.NestedClasses.end();
- ++it) {
- it->AddFileNamesForPrinting(&files, CM_NULLPTR, "$");
+ for (CurrentClass const& nc : toplevel.NestedClasses) {
+ nc.AddFileNamesForPrinting(&files, nullptr, "$");
}
return files;
}
@@ -264,10 +257,8 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb)
std::cout << std::endl;
std::cout << "Depends on:";
if (!this->ClassesFound.empty()) {
- std::vector<std::string>::iterator it;
- for (it = this->ClassesFound.begin(); it != this->ClassesFound.end();
- ++it) {
- std::cout << " " << *it;
+ for (std::string const& cf : this->ClassesFound) {
+ std::cout << " " << cf;
}
}
std::cout << std::endl;
@@ -284,9 +275,8 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb)
void cmDependsJavaParserHelper::CleanupParser()
{
- std::vector<char*>::iterator it;
- for (it = this->Allocates.begin(); it != this->Allocates.end(); ++it) {
- delete[] * it;
+ for (char* allocate : this->Allocates) {
+ delete[] allocate;
}
this->Allocates.erase(this->Allocates.begin(), this->Allocates.end());
}
@@ -311,20 +301,16 @@ void cmDependsJavaParserHelper::Error(const char* str)
unsigned long pos = static_cast<unsigned long>(this->InputBufferPos);
fprintf(stderr, "JPError: %s (%lu / Line: %d)\n", str, pos,
this->CurrentLine);
- int cc;
- std::cerr << "String: [";
- for (cc = 0;
- cc < 30 && *(this->InputBuffer.c_str() + this->InputBufferPos + cc);
- cc++) {
- std::cerr << *(this->InputBuffer.c_str() + this->InputBufferPos + cc);
- }
- std::cerr << "]" << std::endl;
+ std::cerr << "String: ["
+ << cm::string_view{ this->InputBuffer }.substr(
+ this->InputBufferPos, 30)
+ << "]" << std::endl;
}
void cmDependsJavaParserHelper::UpdateCombine(const char* str1,
const char* str2)
{
- if (this->CurrentCombine == "" && str1 != CM_NULLPTR) {
+ if (this->CurrentCombine.empty() && str1 != nullptr) {
this->CurrentCombine = str1;
}
this->CurrentCombine += ".";
diff --git a/Source/cmDependsJavaParserHelper.h b/Source/cmDependsJavaParserHelper.h
index 0b445d924..a673b5bbb 100644
--- a/Source/cmDependsJavaParserHelper.h
+++ b/Source/cmDependsJavaParserHelper.h
@@ -24,6 +24,10 @@ public:
cmDependsJavaParserHelper();
~cmDependsJavaParserHelper();
+ cmDependsJavaParserHelper(const cmDependsJavaParserHelper&) = delete;
+ cmDependsJavaParserHelper& operator=(const cmDependsJavaParserHelper&) =
+ delete;
+
int ParseString(const char* str, int verb);
int ParseFile(const char* file);
diff --git a/Source/cmDisallowedCommand.cxx b/Source/cmDisallowedCommand.cxx
deleted file mode 100644
index ce1965d30..000000000
--- a/Source/cmDisallowedCommand.cxx
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmDisallowedCommand.h"
-
-#include "cmMakefile.h"
-#include "cmake.h"
-
-class cmExecutionStatus;
-
-bool cmDisallowedCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status)
-{
- switch (this->Makefile->GetPolicyStatus(this->Policy)) {
- case cmPolicies::WARN:
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
- cmPolicies::GetPolicyWarning(this->Policy));
- break;
- case cmPolicies::OLD:
- break;
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::NEW:
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, this->Message);
- return true;
- }
-
- this->Command->SetMakefile(this->GetMakefile());
- bool const ret = this->Command->InitialPass(args, status);
- this->SetError(this->Command->GetError());
- return ret;
-}
diff --git a/Source/cmDisallowedCommand.h b/Source/cmDisallowedCommand.h
deleted file mode 100644
index 0030116b8..000000000
--- a/Source/cmDisallowedCommand.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmDisallowedCommand_h
-#define cmDisallowedCommand_h
-
-#include "cmConfigure.h"
-
-#include <string>
-#include <vector>
-
-#include "cmCommand.h"
-#include "cmPolicies.h"
-
-class cmExecutionStatus;
-
-class cmDisallowedCommand : public cmCommand
-{
-public:
- cmDisallowedCommand(cmCommand* command, cmPolicies::PolicyID policy,
- const char* message)
- : Command(command)
- , Policy(policy)
- , Message(message)
- {
- }
-
- ~cmDisallowedCommand() CM_OVERRIDE { delete this->Command; }
-
- cmCommand* Clone() CM_OVERRIDE
- {
- return new cmDisallowedCommand(this->Command->Clone(), this->Policy,
- this->Message);
- }
-
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
- void FinalPass() CM_OVERRIDE { this->Command->FinalPass(); }
-
- bool HasFinalPass() const CM_OVERRIDE
- {
- return this->Command->HasFinalPass();
- }
-
-private:
- cmCommand* Command;
- cmPolicies::PolicyID Policy;
- const char* Message;
-};
-
-#endif
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index c6286b35a..1bc453d37 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -2,20 +2,20 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmDocumentation.h"
-#include "cmAlgorithms.h"
+#include <algorithm>
+#include <cctype>
+#include <cstring>
+#include <utility>
+
+#include "cmsys/FStream.hxx"
+#include "cmsys/Glob.hxx"
+
#include "cmDocumentationEntry.h"
#include "cmDocumentationSection.h"
#include "cmRST.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
-#include "cmsys/FStream.hxx"
-#include "cmsys/Glob.hxx"
-#include <algorithm>
-#include <ctype.h>
-#include <string.h>
-#include <utility>
-
static const char* cmDocumentationStandardOptions[][2] = {
{ "--help,-help,-usage,-h,-H,/?", "Print usage information and exit." },
{ "--version,-version,/V [<f>]", "Print version number and exit." },
@@ -41,12 +41,19 @@ static const char* cmDocumentationStandardOptions[][2] = {
{ "--help-variable-list [<f>]",
"List variables with help available and exit." },
{ "--help-variables [<f>]", "Print cmake-variables manual and exit." },
- { CM_NULLPTR, CM_NULLPTR }
+ { nullptr, nullptr }
};
-static const char* cmDocumentationGeneratorsHeader[][2] = {
- { CM_NULLPTR, "The following generators are available on this platform:" },
- { CM_NULLPTR, CM_NULLPTR }
+static const char* cmDocumentationCPackGeneratorsHeader[][2] = {
+ { nullptr, "The following generators are available on this platform:" },
+ { nullptr, nullptr }
+};
+
+static const char* cmDocumentationCMakeGeneratorsHeader[][2] = {
+ { nullptr,
+ "The following generators are available on this platform (* marks "
+ "default):" },
+ { nullptr, nullptr }
};
cmDocumentation::cmDocumentation()
@@ -55,11 +62,6 @@ cmDocumentation::cmDocumentation()
this->ShowGenerators = true;
}
-cmDocumentation::~cmDocumentation()
-{
- cmDeleteAll(this->AllSections);
-}
-
bool cmDocumentation::PrintVersion(std::ostream& os)
{
/* clang-format off */
@@ -123,23 +125,21 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
bool result = true;
// Loop over requested documentation types.
- for (std::vector<RequestedHelpItem>::const_iterator i =
- this->RequestedHelpItems.begin();
- i != this->RequestedHelpItems.end(); ++i) {
- this->CurrentArgument = i->Argument;
+ for (RequestedHelpItem const& rhi : this->RequestedHelpItems) {
+ this->CurrentArgument = rhi.Argument;
// If a file name was given, use it. Otherwise, default to the
// given stream.
cmsys::ofstream fout;
std::ostream* s = &os;
- if (!i->Filename.empty()) {
- fout.open(i->Filename.c_str());
+ if (!rhi.Filename.empty()) {
+ fout.open(rhi.Filename.c_str());
s = &fout;
} else if (++count > 1) {
os << "\n\n";
}
// Print this documentation type to the stream.
- if (!this->PrintDocumentation(i->HelpType, *s) || s->fail()) {
+ if (!this->PrintDocumentation(rhi.HelpType, *s) || s->fail()) {
result = false;
}
}
@@ -147,10 +147,12 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
}
#define GET_OPT_ARGUMENT(target) \
- if ((i + 1 < argc) && !this->IsOption(argv[i + 1])) { \
- (target) = argv[i + 1]; \
- i = i + 1; \
- };
+ do { \
+ if ((i + 1 < argc) && !this->IsOption(argv[i + 1])) { \
+ (target) = argv[i + 1]; \
+ i = i + 1; \
+ }; \
+ } while (false)
void cmDocumentation::WarnFormFromFilename(
cmDocumentation::RequestedHelpItem& request, bool& result)
@@ -176,20 +178,16 @@ void cmDocumentation::WarnFormFromFilename(
void cmDocumentation::addCommonStandardDocSections()
{
- cmDocumentationSection* sec;
-
- sec = new cmDocumentationSection("Options", "OPTIONS");
- sec->Append(cmDocumentationStandardOptions);
- this->AllSections["Options"] = sec;
+ cmDocumentationSection sec{ "Options" };
+ sec.Append(cmDocumentationStandardOptions);
+ this->AllSections.emplace("Options", std::move(sec));
}
void cmDocumentation::addCMakeStandardDocSections()
{
- cmDocumentationSection* sec;
-
- sec = new cmDocumentationSection("Generators", "GENERATORS");
- sec->Append(cmDocumentationGeneratorsHeader);
- this->AllSections["Generators"] = sec;
+ cmDocumentationSection sec{ "Generators" };
+ sec.Append(cmDocumentationCMakeGeneratorsHeader);
+ this->AllSections.emplace("Generators", std::move(sec));
}
void cmDocumentation::addCTestStandardDocSections()
@@ -201,11 +199,9 @@ void cmDocumentation::addCTestStandardDocSections()
void cmDocumentation::addCPackStandardDocSections()
{
- cmDocumentationSection* sec;
-
- sec = new cmDocumentationSection("Generators", "GENERATORS");
- sec->Append(cmDocumentationGeneratorsHeader);
- this->AllSections["Generators"] = sec;
+ cmDocumentationSection sec{ "Generators" };
+ sec.Append(cmDocumentationCPackGeneratorsHeader);
+ this->AllSections.emplace("Generators", std::move(sec));
}
bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
@@ -215,7 +211,7 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
if (argc == 1) {
RequestedHelpItem help;
help.HelpType = cmDocumentation::Usage;
- this->RequestedHelpItems.push_back(help);
+ this->RequestedHelpItems.push_back(std::move(help));
return true;
}
@@ -354,7 +350,7 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
if (help.HelpType != None) {
// This is a help option. See if there is a file name given.
result = true;
- this->RequestedHelpItems.push_back(help);
+ this->RequestedHelpItems.push_back(std::move(help));
}
}
return result;
@@ -366,93 +362,59 @@ void cmDocumentation::SetName(const std::string& name)
}
void cmDocumentation::SetSection(const char* name,
- cmDocumentationSection* section)
+ cmDocumentationSection section)
{
- if (this->AllSections.find(name) != this->AllSections.end()) {
- delete this->AllSections[name];
- }
- this->AllSections[name] = section;
+ this->SectionAtName(name) = std::move(section);
}
void cmDocumentation::SetSection(const char* name,
std::vector<cmDocumentationEntry>& docs)
{
- cmDocumentationSection* sec =
- new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
- sec->Append(docs);
- this->SetSection(name, sec);
+ cmDocumentationSection sec{ name };
+ sec.Append(docs);
+ this->SetSection(name, std::move(sec));
}
void cmDocumentation::SetSection(const char* name, const char* docs[][2])
{
- cmDocumentationSection* sec =
- new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
- sec->Append(docs);
- this->SetSection(name, sec);
+ cmDocumentationSection sec{ name };
+ sec.Append(docs);
+ this->SetSection(name, std::move(sec));
}
void cmDocumentation::SetSections(
- std::map<std::string, cmDocumentationSection*>& sections)
+ std::map<std::string, cmDocumentationSection> sections)
{
- for (std::map<std::string, cmDocumentationSection*>::const_iterator it =
- sections.begin();
- it != sections.end(); ++it) {
- this->SetSection(it->first.c_str(), it->second);
+ for (auto& s : sections) {
+ this->SetSection(s.first.c_str(), std::move(s.second));
}
}
+cmDocumentationSection& cmDocumentation::SectionAtName(const char* name)
+{
+ return this->AllSections.emplace(name, cmDocumentationSection{ name })
+ .first->second;
+}
void cmDocumentation::PrependSection(const char* name, const char* docs[][2])
{
- cmDocumentationSection* sec = CM_NULLPTR;
- if (this->AllSections.find(name) == this->AllSections.end()) {
- sec =
- new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
- this->SetSection(name, sec);
- } else {
- sec = this->AllSections[name];
- }
- sec->Prepend(docs);
+ this->SectionAtName(name).Prepend(docs);
}
void cmDocumentation::PrependSection(const char* name,
std::vector<cmDocumentationEntry>& docs)
{
- cmDocumentationSection* sec = CM_NULLPTR;
- if (this->AllSections.find(name) == this->AllSections.end()) {
- sec =
- new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
- this->SetSection(name, sec);
- } else {
- sec = this->AllSections[name];
- }
- sec->Prepend(docs);
+ this->SectionAtName(name).Prepend(docs);
}
void cmDocumentation::AppendSection(const char* name, const char* docs[][2])
{
- cmDocumentationSection* sec = CM_NULLPTR;
- if (this->AllSections.find(name) == this->AllSections.end()) {
- sec =
- new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
- this->SetSection(name, sec);
- } else {
- sec = this->AllSections[name];
- }
- sec->Append(docs);
+ this->SectionAtName(name).Append(docs);
}
void cmDocumentation::AppendSection(const char* name,
std::vector<cmDocumentationEntry>& docs)
{
- cmDocumentationSection* sec = CM_NULLPTR;
- if (this->AllSections.find(name) == this->AllSections.end()) {
- sec =
- new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str());
- this->SetSection(name, sec);
- } else {
- sec = this->AllSections[name];
- }
- sec->Append(docs);
+ this->SectionAtName(name).Append(docs);
}
void cmDocumentation::AppendSection(const char* name,
@@ -489,10 +451,9 @@ void cmDocumentation::PrintNames(std::ostream& os, std::string const& pattern)
std::vector<std::string> files;
this->GlobHelp(files, pattern);
std::vector<std::string> names;
- for (std::vector<std::string>::const_iterator i = files.begin();
- i != files.end(); ++i) {
+ for (std::string const& f : files) {
std::string line;
- cmsys::ifstream fin(i->c_str());
+ cmsys::ifstream fin(f.c_str());
while (fin && cmSystemTools::GetLineFromStream(fin, line)) {
if (!line.empty() && (isalnum(line[0]) || line[0] == '<')) {
names.push_back(line);
@@ -501,9 +462,8 @@ void cmDocumentation::PrintNames(std::ostream& os, std::string const& pattern)
}
}
std::sort(names.begin(), names.end());
- for (std::vector<std::string>::iterator i = names.begin(); i != names.end();
- ++i) {
- os << *i << "\n";
+ for (std::string const& n : names) {
+ os << n << "\n";
}
}
@@ -514,9 +474,8 @@ bool cmDocumentation::PrintFiles(std::ostream& os, std::string const& pattern)
this->GlobHelp(files, pattern);
std::sort(files.begin(), files.end());
cmRST r(os, cmSystemTools::GetCMakeRoot() + "/Help");
- for (std::vector<std::string>::const_iterator i = files.begin();
- i != files.end(); ++i) {
- found = r.ProcessFile(*i) || found;
+ for (std::string const& f : files) {
+ found = r.ProcessFile(f) || found;
}
return found;
}
@@ -586,15 +545,13 @@ bool cmDocumentation::PrintHelpListModules(std::ostream& os)
std::vector<std::string> files;
this->GlobHelp(files, "module/*");
std::vector<std::string> modules;
- for (std::vector<std::string>::iterator fi = files.begin();
- fi != files.end(); ++fi) {
- std::string module = cmSystemTools::GetFilenameName(*fi);
+ for (std::string const& f : files) {
+ std::string module = cmSystemTools::GetFilenameName(f);
modules.push_back(module.substr(0, module.size() - 4));
}
std::sort(modules.begin(), modules.end());
- for (std::vector<std::string>::iterator i = modules.begin();
- i != modules.end(); ++i) {
- os << *i << "\n";
+ for (std::string const& m : modules) {
+ os << m << "\n";
}
return true;
}
@@ -640,11 +597,10 @@ bool cmDocumentation::PrintHelpListPolicies(std::ostream& os)
bool cmDocumentation::PrintHelpListGenerators(std::ostream& os)
{
- std::map<std::string, cmDocumentationSection*>::iterator si;
- si = this->AllSections.find("Generators");
+ const auto si = this->AllSections.find("Generators");
if (si != this->AllSections.end()) {
this->Formatter.SetIndent(" ");
- this->Formatter.PrintSection(os, *si->second);
+ this->Formatter.PrintSection(os, si->second);
}
return true;
}
@@ -670,29 +626,27 @@ bool cmDocumentation::PrintHelpListVariables(std::ostream& os)
bool cmDocumentation::PrintUsage(std::ostream& os)
{
- std::map<std::string, cmDocumentationSection*>::iterator si;
- si = this->AllSections.find("Usage");
+ const auto si = this->AllSections.find("Usage");
if (si != this->AllSections.end()) {
- this->Formatter.PrintSection(os, *si->second);
+ this->Formatter.PrintSection(os, si->second);
}
return true;
}
bool cmDocumentation::PrintHelp(std::ostream& os)
{
- std::map<std::string, cmDocumentationSection*>::iterator si;
- si = this->AllSections.find("Usage");
+ auto si = this->AllSections.find("Usage");
if (si != this->AllSections.end()) {
- this->Formatter.PrintSection(os, *si->second);
+ this->Formatter.PrintSection(os, si->second);
}
si = this->AllSections.find("Options");
if (si != this->AllSections.end()) {
- this->Formatter.PrintSection(os, *si->second);
+ this->Formatter.PrintSection(os, si->second);
}
if (this->ShowGenerators) {
si = this->AllSections.find("Generators");
if (si != this->AllSections.end()) {
- this->Formatter.PrintSection(os, *si->second);
+ this->Formatter.PrintSection(os, si->second);
}
}
return true;
diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h
index 2866fef03..3768e1abe 100644
--- a/Source/cmDocumentation.h
+++ b/Source/cmDocumentation.h
@@ -3,16 +3,16 @@
#ifndef _cmDocumentation_h
#define _cmDocumentation_h
-#include "cmConfigure.h"
-
-#include "cmDocumentationFormatter.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
#include <string>
#include <vector>
-class cmDocumentationSection;
+#include "cmDocumentationFormatter.h"
+#include "cmDocumentationSection.h"
+
struct cmDocumentationEntry;
/** Class to generate documentation. */
@@ -21,8 +21,6 @@ class cmDocumentation : public cmDocumentationEnums
public:
cmDocumentation();
- ~cmDocumentation();
-
/**
* Check command line arguments for documentation options. Returns
* true if documentation options are found, and false otherwise.
@@ -32,7 +30,7 @@ public:
* help arguments.
*/
bool CheckOptions(int argc, const char* const* argv,
- const char* exitOpt = CM_NULLPTR);
+ const char* exitOpt = nullptr);
/**
* Print help requested on the command line. Call after
@@ -52,11 +50,11 @@ public:
/** Set a section of the documentation. Typical sections include Name,
Usage, Description, Options */
- void SetSection(const char* sectionName, cmDocumentationSection* section);
+ void SetSection(const char* sectionName, cmDocumentationSection section);
void SetSection(const char* sectionName,
std::vector<cmDocumentationEntry>& docs);
void SetSection(const char* sectionName, const char* docs[][2]);
- void SetSections(std::map<std::string, cmDocumentationSection*>& sections);
+ void SetSections(std::map<std::string, cmDocumentationSection> sections);
/** Add the documentation to the beginning/end of the section */
void PrependSection(const char* sectionName, const char* docs[][2]);
@@ -110,17 +108,14 @@ private:
bool ShowGenerators;
std::string NameString;
- std::map<std::string, cmDocumentationSection*> AllSections;
+ std::map<std::string, cmDocumentationSection> AllSections;
+ cmDocumentationSection& SectionAtName(const char* name);
std::string CurrentArgument;
struct RequestedHelpItem
{
- RequestedHelpItem()
- : HelpType(None)
- {
- }
- cmDocumentationEnums::Type HelpType;
+ cmDocumentationEnums::Type HelpType = None;
std::string Filename;
std::string Argument;
};
diff --git a/Source/cmDocumentationEntry.h b/Source/cmDocumentationEntry.h
index ea43b88c3..afbca5e4b 100644
--- a/Source/cmDocumentationEntry.h
+++ b/Source/cmDocumentationEntry.h
@@ -12,7 +12,8 @@ struct cmDocumentationEntry
{
std::string Name;
std::string Brief;
- cmDocumentationEntry() {}
+ char CustomNamePrefix = ' ';
+ cmDocumentationEntry() = default;
cmDocumentationEntry(const char* doc[2])
{
if (doc[0]) {
diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx
index 001826318..732637e36 100644
--- a/Source/cmDocumentationFormatter.cxx
+++ b/Source/cmDocumentationFormatter.cxx
@@ -2,23 +2,18 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmDocumentationFormatter.h"
-#include "cmDocumentationEntry.h"
-#include "cmDocumentationSection.h"
-
+#include <cstring>
+#include <iomanip>
#include <ostream>
-#include <string.h>
#include <string>
#include <vector>
-cmDocumentationFormatter::cmDocumentationFormatter()
- : TextWidth(77)
- , TextIndent("")
-{
-}
+#include "cmDocumentationEntry.h"
+#include "cmDocumentationSection.h"
-cmDocumentationFormatter::~cmDocumentationFormatter()
-{
-}
+cmDocumentationFormatter::cmDocumentationFormatter() = default;
+
+cmDocumentationFormatter::~cmDocumentationFormatter() = default;
void cmDocumentationFormatter::PrintFormatted(std::ostream& os,
const char* text)
@@ -90,7 +85,7 @@ void cmDocumentationFormatter::SetIndent(const char* indent)
void cmDocumentationFormatter::PrintColumn(std::ostream& os, const char* text)
{
- // Print text arranged in an indented column of fixed witdh.
+ // Print text arranged in an indented column of fixed width.
const char* l = text;
long column = 0;
bool newSentence = false;
@@ -168,26 +163,25 @@ void cmDocumentationFormatter::PrintSection(
os << section.GetName() << "\n";
const std::vector<cmDocumentationEntry>& entries = section.GetEntries();
- for (std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
- op != entries.end(); ++op) {
- if (!op->Name.empty()) {
- os << " " << op->Name;
+ for (cmDocumentationEntry const& entry : entries) {
+ if (!entry.Name.empty()) {
+ os << std::setw(2) << std::left << entry.CustomNamePrefix << entry.Name;
this->TextIndent = " ";
int align = static_cast<int>(strlen(this->TextIndent)) - 4;
- for (int i = static_cast<int>(op->Name.size()); i < align; ++i) {
+ for (int i = static_cast<int>(entry.Name.size()); i < align; ++i) {
os << " ";
}
- if (op->Name.size() > strlen(this->TextIndent) - 4) {
+ if (entry.Name.size() > strlen(this->TextIndent) - 4) {
os << "\n";
os.write(this->TextIndent, strlen(this->TextIndent) - 2);
}
os << "= ";
- this->PrintColumn(os, op->Brief.c_str());
+ this->PrintColumn(os, entry.Brief.c_str());
os << "\n";
} else {
os << "\n";
this->TextIndent = "";
- this->PrintFormatted(os, op->Brief.c_str());
+ this->PrintFormatted(os, entry.Brief.c_str());
}
}
os << "\n";
diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h
index 1f04250c9..17b63dacc 100644
--- a/Source/cmDocumentationFormatter.h
+++ b/Source/cmDocumentationFormatter.h
@@ -59,8 +59,8 @@ public:
void SetIndent(const char* indent);
private:
- int TextWidth;
- const char* TextIndent;
+ int TextWidth = 77;
+ const char* TextIndent = "";
};
#endif
diff --git a/Source/cmDocumentationSection.cxx b/Source/cmDocumentationSection.cxx
index c47f33e4f..439da1bc1 100644
--- a/Source/cmDocumentationSection.cxx
+++ b/Source/cmDocumentationSection.cxx
@@ -6,7 +6,7 @@ void cmDocumentationSection::Append(const char* data[][2])
{
int i = 0;
while (data[i][1]) {
- this->Entries.push_back(cmDocumentationEntry(data[i][0], data[i][1]));
+ this->Entries.emplace_back(data[i][0], data[i][1]);
data += 1;
}
}
@@ -16,7 +16,7 @@ void cmDocumentationSection::Prepend(const char* data[][2])
std::vector<cmDocumentationEntry> tmp;
int i = 0;
while (data[i][1]) {
- tmp.push_back(cmDocumentationEntry(data[i][0], data[i][1]));
+ tmp.emplace_back(data[i][0], data[i][1]);
data += 1;
}
this->Entries.insert(this->Entries.begin(), tmp.begin(), tmp.end());
@@ -24,5 +24,5 @@ void cmDocumentationSection::Prepend(const char* data[][2])
void cmDocumentationSection::Append(const char* n, const char* b)
{
- this->Entries.push_back(cmDocumentationEntry(n, b));
+ this->Entries.emplace_back(n, b);
}
diff --git a/Source/cmDocumentationSection.h b/Source/cmDocumentationSection.h
index d9e8187f8..15cada6de 100644
--- a/Source/cmDocumentationSection.h
+++ b/Source/cmDocumentationSection.h
@@ -5,11 +5,12 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmDocumentationEntry.h"
-
#include <string>
#include <vector>
+#include "cmAlgorithms.h"
+#include "cmDocumentationEntry.h"
+
// Low-level interface for custom documents:
/** Internal class representing a section of the documentation.
* Cares e.g. for the different section titles in the different
@@ -19,7 +20,7 @@ class cmDocumentationSection
{
public:
/** Create a cmSection, with a special name for man-output mode. */
- cmDocumentationSection(const char* name, const char*)
+ explicit cmDocumentationSection(const char* name)
: Name(name)
{
}
@@ -46,7 +47,7 @@ public:
}
void Append(const std::vector<cmDocumentationEntry>& entries)
{
- this->Entries.insert(this->Entries.end(), entries.begin(), entries.end());
+ cmAppend(this->Entries, entries);
}
/** Append an entry to this section using NULL terminated chars */
diff --git a/Source/cmDuration.cxx b/Source/cmDuration.cxx
new file mode 100644
index 000000000..8ca5d8d12
--- /dev/null
+++ b/Source/cmDuration.cxx
@@ -0,0 +1,27 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#define CMDURATION_CPP
+#include "cmDuration.h"
+
+template <typename T>
+T cmDurationTo(const cmDuration& duration)
+{
+ /* This works because the comparison operators for duration rely on
+ * std::common_type.
+ * So for example duration<int>::max() gets promoted to a duration<double>,
+ * which can then be safely compared.
+ */
+ if (duration >= std::chrono::duration<T>::max()) {
+ return std::chrono::duration<T>::max().count();
+ }
+ if (duration <= std::chrono::duration<T>::min()) {
+ return std::chrono::duration<T>::min().count();
+ }
+ // Ensure number of seconds by defining ratio<1>
+ return std::chrono::duration_cast<std::chrono::duration<T, std::ratio<1>>>(
+ duration)
+ .count();
+}
+
+template int cmDurationTo<int>(const cmDuration&);
+template unsigned int cmDurationTo<unsigned int>(const cmDuration&);
diff --git a/Source/cmDuration.h b/Source/cmDuration.h
new file mode 100644
index 000000000..ccd1cc1cc
--- /dev/null
+++ b/Source/cmDuration.h
@@ -0,0 +1,24 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#pragma once
+
+#include <chrono>
+#include <ratio>
+
+using cmDuration = std::chrono::duration<double, std::ratio<1>>;
+
+/*
+ * This function will return number of seconds in the requested type T.
+ *
+ * A duration_cast from duration<double> to duration<T> will not yield what
+ * one might expect if the double representation does not fit into type T.
+ * This function aims to safely convert, by clamping the double value between
+ * the permissible valid values for T.
+ */
+template <typename T>
+T cmDurationTo(const cmDuration& duration);
+
+#ifndef CMDURATION_CPP
+extern template int cmDurationTo<int>(const cmDuration&);
+extern template unsigned int cmDurationTo<unsigned int>(const cmDuration&);
+#endif
diff --git a/Source/cmDynamicLoader.cxx b/Source/cmDynamicLoader.cxx
index 7fbe75c7b..0b72a94b2 100644
--- a/Source/cmDynamicLoader.cxx
+++ b/Source/cmDynamicLoader.cxx
@@ -22,11 +22,9 @@ private:
static cmDynamicLoaderCache* Instance;
};
-cmDynamicLoaderCache* cmDynamicLoaderCache::Instance = CM_NULLPTR;
+cmDynamicLoaderCache* cmDynamicLoaderCache::Instance = nullptr;
-cmDynamicLoaderCache::~cmDynamicLoaderCache()
-{
-}
+cmDynamicLoaderCache::~cmDynamicLoaderCache() = default;
void cmDynamicLoaderCache::CacheFile(const char* path,
cmsys::DynamicLoader::LibraryHandle p)
@@ -41,8 +39,7 @@ void cmDynamicLoaderCache::CacheFile(const char* path,
bool cmDynamicLoaderCache::GetCacheFile(const char* path,
cmsys::DynamicLoader::LibraryHandle& p)
{
- std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it =
- this->CacheMap.find(path);
+ auto it = this->CacheMap.find(path);
if (it != this->CacheMap.end()) {
p = it->second;
return true;
@@ -52,8 +49,7 @@ bool cmDynamicLoaderCache::GetCacheFile(const char* path,
bool cmDynamicLoaderCache::FlushCache(const char* path)
{
- std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it =
- this->CacheMap.find(path);
+ auto it = this->CacheMap.find(path);
bool ret = false;
if (it != this->CacheMap.end()) {
cmsys::DynamicLoader::CloseLibrary(it->second);
@@ -65,13 +61,11 @@ bool cmDynamicLoaderCache::FlushCache(const char* path)
void cmDynamicLoaderCache::FlushCache()
{
- for (std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator
- it = this->CacheMap.begin();
- it != this->CacheMap.end(); it++) {
- cmsys::DynamicLoader::CloseLibrary(it->second);
+ for (auto const& it : this->CacheMap) {
+ cmsys::DynamicLoader::CloseLibrary(it.second);
}
delete cmDynamicLoaderCache::Instance;
- cmDynamicLoaderCache::Instance = CM_NULLPTR;
+ cmDynamicLoaderCache::Instance = nullptr;
}
cmDynamicLoaderCache* cmDynamicLoaderCache::GetInstance()
diff --git a/Source/cmDynamicLoader.h b/Source/cmDynamicLoader.h
index 7c46dd5d4..4b89388e2 100644
--- a/Source/cmDynamicLoader.h
+++ b/Source/cmDynamicLoader.h
@@ -8,14 +8,12 @@
#ifndef cmDynamicLoader_h
#define cmDynamicLoader_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include "cmsys/DynamicLoader.hxx" // IWYU pragma: export
class cmDynamicLoader
{
- CM_DISABLE_COPY(cmDynamicLoader)
-
public:
// Description:
// Load a dynamic library into the current process.
@@ -28,8 +26,8 @@ public:
static void FlushCache();
protected:
- cmDynamicLoader() {}
- ~cmDynamicLoader() {}
+ cmDynamicLoader() = default;
+ ~cmDynamicLoader() = default;
};
#endif
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index fc97bf3b3..5976b2f78 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -2,50 +2,56 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmELF.h"
-#include "cm_auto_ptr.hxx"
-#include "cm_kwiml.h"
-#include "cmsys/FStream.hxx"
+#include <cstddef>
#include <map>
+#include <memory>
#include <sstream>
-#include <stddef.h>
#include <utility>
#include <vector>
+#include <cm/memory>
+
+#include "cmsys/FStream.hxx"
+
+#include "cm_kwiml.h"
+
+#include "cmAlgorithms.h"
+
// Include the ELF format information system header.
#if defined(__OpenBSD__)
-#include <elf_abi.h>
-#include <stdint.h>
+# include <elf_abi.h>
+# include <stdint.h>
#elif defined(__HAIKU__)
-#include <elf32.h>
-#include <elf64.h>
-typedef struct Elf32_Ehdr Elf32_Ehdr;
-typedef struct Elf32_Shdr Elf32_Shdr;
-typedef struct Elf32_Sym Elf32_Sym;
-typedef struct Elf32_Rel Elf32_Rel;
-typedef struct Elf32_Rela Elf32_Rela;
-#define ELFMAG0 0x7F
-#define ELFMAG1 'E'
-#define ELFMAG2 'L'
-#define ELFMAG3 'F'
-#define ET_NONE 0
-#define ET_REL 1
-#define ET_EXEC 2
-#define ET_DYN 3
-#define ET_CORE 4
-#define EM_386 3
-#define EM_SPARC 2
-#define EM_PPC 20
+# include <elf32.h>
+# include <elf64.h>
+using Elf32_Ehdr = struct Elf32_Ehdr;
+using Elf32_Shdr = struct Elf32_Shdr;
+using Elf32_Sym = struct Elf32_Sym;
+using Elf32_Rel = struct Elf32_Rel;
+using Elf32_Rela = struct Elf32_Rela;
+# define ELFMAG0 0x7F
+# define ELFMAG1 'E'
+# define ELFMAG2 'L'
+# define ELFMAG3 'F'
+# define ET_NONE 0
+# define ET_REL 1
+# define ET_EXEC 2
+# define ET_DYN 3
+# define ET_CORE 4
+# define EM_386 3
+# define EM_SPARC 2
+# define EM_PPC 20
#else
-#include <elf.h>
+# include <elf.h>
#endif
#if defined(__sun)
-#include <sys/link.h> // For dynamic section information
+# include <sys/link.h> // For dynamic section information
#endif
#ifdef _SCO_DS
-#include <link.h> // For DT_SONAME etc.
+# include <link.h> // For DT_SONAME etc.
#endif
#ifndef DT_RUNPATH
-#define DT_RUNPATH 29
+# define DT_RUNPATH 29
#endif
// Low-level byte swapping implementation.
@@ -100,7 +106,7 @@ void cmELFByteSwap(T& x)
class cmELFInternal
{
public:
- typedef cmELF::StringEntry StringEntry;
+ using StringEntry = cmELF::StringEntry;
enum ByteOrderType
{
ByteOrderMSB,
@@ -108,10 +114,10 @@ public:
};
// Construct and take ownership of the file stream object.
- cmELFInternal(cmELF* external, CM_AUTO_PTR<cmsys::ifstream>& fin,
+ cmELFInternal(cmELF* external, std::unique_ptr<std::istream> fin,
ByteOrderType order)
: External(external)
- , Stream(*fin.release())
+ , Stream(std::move(fin))
, ByteOrder(order)
, ELFType(cmELF::FileTypeInvalid)
{
@@ -131,7 +137,7 @@ public:
}
// Destruct and delete the file stream object.
- virtual ~cmELFInternal() { delete &this->Stream; }
+ virtual ~cmELFInternal() = default;
// Forward to the per-class implementation.
virtual unsigned int GetNumberOfSections() const = 0;
@@ -162,6 +168,7 @@ public:
// Return the recorded ELF type.
cmELF::FileType GetFileType() const { return this->ELFType; }
+
protected:
// Data common to all ELF class implementations.
@@ -169,7 +176,7 @@ protected:
cmELF* External;
// The stream from which to read.
- std::istream& Stream;
+ std::unique_ptr<std::istream> Stream;
// The byte order of the ELF file.
ByteOrderType ByteOrder;
@@ -197,11 +204,11 @@ protected:
// Configure the implementation template for 32-bit ELF files.
struct cmELFTypes32
{
- typedef Elf32_Ehdr ELF_Ehdr;
- typedef Elf32_Shdr ELF_Shdr;
- typedef Elf32_Dyn ELF_Dyn;
- typedef Elf32_Half ELF_Half;
- typedef KWIML_INT_uint32_t tagtype;
+ using ELF_Ehdr = Elf32_Ehdr;
+ using ELF_Shdr = Elf32_Shdr;
+ using ELF_Dyn = Elf32_Dyn;
+ using ELF_Half = Elf32_Half;
+ using tagtype = ::uint32_t;
static const char* GetName() { return "32-bit"; }
};
@@ -209,11 +216,11 @@ struct cmELFTypes32
#ifndef _SCO_DS
struct cmELFTypes64
{
- typedef Elf64_Ehdr ELF_Ehdr;
- typedef Elf64_Shdr ELF_Shdr;
- typedef Elf64_Dyn ELF_Dyn;
- typedef Elf64_Half ELF_Half;
- typedef KWIML_INT_uint64_t tagtype;
+ using ELF_Ehdr = Elf64_Ehdr;
+ using ELF_Shdr = Elf64_Shdr;
+ using ELF_Dyn = Elf64_Dyn;
+ using ELF_Half = Elf64_Half;
+ using tagtype = ::uint64_t;
static const char* GetName() { return "64-bit"; }
};
#endif
@@ -224,34 +231,34 @@ class cmELFInternalImpl : public cmELFInternal
{
public:
// Copy the ELF file format types from our configuration parameter.
- typedef typename Types::ELF_Ehdr ELF_Ehdr;
- typedef typename Types::ELF_Shdr ELF_Shdr;
- typedef typename Types::ELF_Dyn ELF_Dyn;
- typedef typename Types::ELF_Half ELF_Half;
- typedef typename Types::tagtype tagtype;
+ using ELF_Ehdr = typename Types::ELF_Ehdr;
+ using ELF_Shdr = typename Types::ELF_Shdr;
+ using ELF_Dyn = typename Types::ELF_Dyn;
+ using ELF_Half = typename Types::ELF_Half;
+ using tagtype = typename Types::tagtype;
// Construct with a stream and byte swap indicator.
- cmELFInternalImpl(cmELF* external, CM_AUTO_PTR<cmsys::ifstream>& fin,
+ cmELFInternalImpl(cmELF* external, std::unique_ptr<std::istream> fin,
ByteOrderType order);
// Return the number of sections as specified by the ELF header.
- unsigned int GetNumberOfSections() const CM_OVERRIDE
+ unsigned int GetNumberOfSections() const override
{
return static_cast<unsigned int>(this->ELFHeader.e_shnum);
}
// Get the file position of a dynamic section entry.
- unsigned long GetDynamicEntryPosition(int j) CM_OVERRIDE;
+ unsigned long GetDynamicEntryPosition(int j) override;
- cmELF::DynamicEntryList GetDynamicEntries() CM_OVERRIDE;
- std::vector<char> EncodeDynamicEntries(const cmELF::DynamicEntryList&)
- CM_OVERRIDE;
+ cmELF::DynamicEntryList GetDynamicEntries() override;
+ std::vector<char> EncodeDynamicEntries(
+ const cmELF::DynamicEntryList&) override;
// Lookup a string from the dynamic section with the given tag.
- StringEntry const* GetDynamicSectionString(unsigned int tag) CM_OVERRIDE;
+ StringEntry const* GetDynamicSectionString(unsigned int tag) override;
// Print information about the ELF file.
- void PrintInfo(std::ostream& os) const CM_OVERRIDE
+ void PrintInfo(std::ostream& os) const override
{
os << "ELF " << Types::GetName();
if (this->ByteOrder == ByteOrderMSB) {
@@ -286,9 +293,8 @@ public:
}
private:
- // ByteSwap(ELF_Dyn) assumes d_val and d_ptr are the same size
- typedef char dyn_size_assert
- [sizeof(ELF_Dyn().d_un.d_val) == sizeof(ELF_Dyn().d_un.d_ptr) ? 1 : -1];
+ static_assert(sizeof(ELF_Dyn().d_un.d_val) == sizeof(ELF_Dyn().d_un.d_ptr),
+ "ByteSwap(ELF_Dyn) assumes d_val and d_ptr are the same size");
void ByteSwap(ELF_Ehdr& elf_header)
{
@@ -350,7 +356,7 @@ private:
bool Read(ELF_Ehdr& x)
{
// Read the header from the file.
- if (!this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x))) {
+ if (!this->Stream->read(reinterpret_cast<char*>(&x), sizeof(x))) {
return false;
}
@@ -380,26 +386,26 @@ private:
}
bool Read(ELF_Shdr& x)
{
- if (this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x)) &&
+ if (this->Stream->read(reinterpret_cast<char*>(&x), sizeof(x)) &&
this->NeedSwap) {
ByteSwap(x);
}
- return !this->Stream.fail();
+ return !this->Stream->fail();
}
bool Read(ELF_Dyn& x)
{
- if (this->Stream.read(reinterpret_cast<char*>(&x), sizeof(x)) &&
+ if (this->Stream->read(reinterpret_cast<char*>(&x), sizeof(x)) &&
this->NeedSwap) {
ByteSwap(x);
}
- return !this->Stream.fail();
+ return !this->Stream->fail();
}
bool LoadSectionHeader(ELF_Half i)
{
// Read the section header from the file.
- this->Stream.seekg(this->ELFHeader.e_shoff +
- this->ELFHeader.e_shentsize * i);
+ this->Stream->seekg(this->ELFHeader.e_shoff +
+ this->ELFHeader.e_shentsize * i);
if (!this->Read(this->SectionHeaders[i])) {
return false;
}
@@ -425,9 +431,9 @@ private:
template <class Types>
cmELFInternalImpl<Types>::cmELFInternalImpl(cmELF* external,
- CM_AUTO_PTR<cmsys::ifstream>& fin,
+ std::unique_ptr<std::istream> fin,
ByteOrderType order)
- : cmELFInternal(external, fin, order)
+ : cmELFInternal(external, std::move(fin), order)
{
// Read the main header.
if (!this->Read(this->ELFHeader)) {
@@ -509,7 +515,7 @@ bool cmELFInternalImpl<Types>::LoadDynamicSection()
// Read each entry.
for (int j = 0; j < n; ++j) {
// Seek to the beginning of the section entry.
- this->Stream.seekg(sec.sh_offset + sec.sh_entsize * j);
+ this->Stream->seekg(sec.sh_offset + sec.sh_entsize * j);
ELF_Dyn& dyn = this->DynamicSectionEntries[j];
// Try reading the entry.
@@ -547,12 +553,8 @@ cmELF::DynamicEntryList cmELFInternalImpl<Types>::GetDynamicEntries()
// Copy into public array
result.reserve(this->DynamicSectionEntries.size());
- for (typename std::vector<ELF_Dyn>::iterator di =
- this->DynamicSectionEntries.begin();
- di != this->DynamicSectionEntries.end(); ++di) {
- ELF_Dyn& dyn = *di;
- result.push_back(
- std::pair<unsigned long, unsigned long>(dyn.d_tag, dyn.d_un.d_val));
+ for (ELF_Dyn& dyn : this->DynamicSectionEntries) {
+ result.emplace_back(dyn.d_tag, dyn.d_un.d_val);
}
return result;
@@ -565,19 +567,18 @@ std::vector<char> cmELFInternalImpl<Types>::EncodeDynamicEntries(
std::vector<char> result;
result.reserve(sizeof(ELF_Dyn) * entries.size());
- for (cmELF::DynamicEntryList::const_iterator it = entries.begin();
- it != entries.end(); it++) {
+ for (auto const& entry : entries) {
// Store the entry in an ELF_Dyn, byteswap it, then serialize to chars
ELF_Dyn dyn;
- dyn.d_tag = static_cast<tagtype>(it->first);
- dyn.d_un.d_val = static_cast<tagtype>(it->second);
+ dyn.d_tag = static_cast<tagtype>(entry.first);
+ dyn.d_un.d_val = static_cast<tagtype>(entry.second);
if (this->NeedSwap) {
ByteSwap(dyn);
}
char* pdyn = reinterpret_cast<char*>(&dyn);
- result.insert(result.end(), pdyn, pdyn + sizeof(ELF_Dyn));
+ cmAppend(result, pdyn, pdyn + sizeof(ELF_Dyn));
}
return result;
@@ -588,13 +589,12 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
unsigned int tag)
{
// Short-circuit if already checked.
- std::map<unsigned int, StringEntry>::iterator dssi =
- this->DynamicSectionStrings.find(tag);
+ auto dssi = this->DynamicSectionStrings.find(tag);
if (dssi != this->DynamicSectionStrings.end()) {
if (dssi->second.Position > 0) {
return &dssi->second;
}
- return CM_NULLPTR;
+ return nullptr;
}
// Create an entry for this tag. Assume it is missing until found.
@@ -605,20 +605,19 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
// Try reading the dynamic section.
if (!this->LoadDynamicSection()) {
- return CM_NULLPTR;
+ return nullptr;
}
// Get the string table referenced by the DYNAMIC section.
ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex];
if (sec.sh_link >= this->SectionHeaders.size()) {
this->SetErrorMessage("Section DYNAMIC has invalid string table index.");
- return CM_NULLPTR;
+ return nullptr;
}
ELF_Shdr const& strtab = this->SectionHeaders[sec.sh_link];
// Look for the requested entry.
- for (typename std::vector<ELF_Dyn>::iterator di =
- this->DynamicSectionEntries.begin();
+ for (auto di = this->DynamicSectionEntries.begin();
di != this->DynamicSectionEntries.end(); ++di) {
ELF_Dyn& dyn = *di;
if (static_cast<tagtype>(dyn.d_tag) == static_cast<tagtype>(tag)) {
@@ -627,14 +626,14 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
if (dyn.d_un.d_val >= strtab.sh_size) {
this->SetErrorMessage("Section DYNAMIC references string beyond "
"the end of its string section.");
- return CM_NULLPTR;
+ return nullptr;
}
// Seek to the position reported by the entry.
unsigned long first = static_cast<unsigned long>(dyn.d_un.d_val);
unsigned long last = first;
unsigned long end = static_cast<unsigned long>(strtab.sh_size);
- this->Stream.seekg(strtab.sh_offset + first);
+ this->Stream->seekg(strtab.sh_offset + first);
// Read the string. It may be followed by more than one NULL
// terminator. Count the total size of the region allocated to
@@ -643,7 +642,7 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
// assumption.
bool terminated = false;
char c;
- while (last != end && this->Stream.get(c) && !(terminated && c)) {
+ while (last != end && this->Stream->get(c) && !(terminated && c)) {
++last;
if (c) {
se.Value += c;
@@ -653,10 +652,10 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
}
// Make sure the whole value was read.
- if (!this->Stream) {
+ if (!(*this->Stream)) {
this->SetErrorMessage("Dynamic section specifies unreadable RPATH.");
se.Value = "";
- return CM_NULLPTR;
+ return nullptr;
}
// The value has been read successfully. Report it.
@@ -667,7 +666,7 @@ cmELF::StringEntry const* cmELFInternalImpl<Types>::GetDynamicSectionString(
return &se;
}
}
- return CM_NULLPTR;
+ return nullptr;
}
//============================================================================
@@ -683,13 +682,12 @@ const long cmELF::TagMipsRldMapRel = 0;
#endif
cmELF::cmELF(const char* fname)
- : Internal(CM_NULLPTR)
{
// Try to open the file.
- CM_AUTO_PTR<cmsys::ifstream> fin(new cmsys::ifstream(fname));
+ auto fin = cm::make_unique<cmsys::ifstream>(fname);
// Quit now if the file could not be opened.
- if (!fin.get() || !*fin) {
+ if (!fin || !*fin) {
this->ErrorMessage = "Error opening input file.";
return;
}
@@ -729,12 +727,14 @@ cmELF::cmELF(const char* fname)
// parser implementation.
if (ident[EI_CLASS] == ELFCLASS32) {
// 32-bit ELF
- this->Internal = new cmELFInternalImpl<cmELFTypes32>(this, fin, order);
+ this->Internal = cm::make_unique<cmELFInternalImpl<cmELFTypes32>>(
+ this, std::move(fin), order);
}
#ifndef _SCO_DS
else if (ident[EI_CLASS] == ELFCLASS64) {
// 64-bit ELF
- this->Internal = new cmELFInternalImpl<cmELFTypes64>(this, fin, order);
+ this->Internal = cm::make_unique<cmELFInternalImpl<cmELFTypes64>>(
+ this, std::move(fin), order);
}
#endif
else {
@@ -743,10 +743,7 @@ cmELF::cmELF(const char* fname)
}
}
-cmELF::~cmELF()
-{
- delete this->Internal;
-}
+cmELF::~cmELF() = default;
bool cmELF::Valid() const
{
@@ -811,7 +808,7 @@ cmELF::StringEntry const* cmELF::GetSOName()
this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary) {
return this->Internal->GetSOName();
}
- return CM_NULLPTR;
+ return nullptr;
}
cmELF::StringEntry const* cmELF::GetRPath()
@@ -821,7 +818,7 @@ cmELF::StringEntry const* cmELF::GetRPath()
this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) {
return this->Internal->GetRPath();
}
- return CM_NULLPTR;
+ return nullptr;
}
cmELF::StringEntry const* cmELF::GetRunPath()
@@ -831,7 +828,7 @@ cmELF::StringEntry const* cmELF::GetRunPath()
this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) {
return this->Internal->GetRunPath();
}
- return CM_NULLPTR;
+ return nullptr;
}
void cmELF::PrintInfo(std::ostream& os) const
diff --git a/Source/cmELF.h b/Source/cmELF.h
index a6e407fe1..123bf9b1f 100644
--- a/Source/cmELF.h
+++ b/Source/cmELF.h
@@ -3,15 +3,16 @@
#ifndef cmELF_h
#define cmELF_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
+#include <memory>
#include <string>
#include <utility>
#include <vector>
#if !defined(CMAKE_USE_ELF_PARSER)
-#error "This file may be included only if CMAKE_USE_ELF_PARSER is enabled."
+# error "This file may be included only if CMAKE_USE_ELF_PARSER is enabled."
#endif
class cmELFInternal;
@@ -28,11 +29,14 @@ public:
/** Destruct. */
~cmELF();
+ cmELF(const cmELF&) = delete;
+ cmELF& operator=(const cmELF&) = delete;
+
/** Get the error message if any. */
std::string const& GetErrorMessage() const { return this->ErrorMessage; }
/** Boolean conversion. True if the ELF file is valid. */
- operator bool() const { return this->Valid(); }
+ explicit operator bool() const { return this->Valid(); }
/** Enumeration of ELF file types. */
enum FileType
@@ -64,7 +68,7 @@ public:
};
/** Represent entire dynamic section header */
- typedef std::vector<std::pair<long, unsigned long> > DynamicEntryList;
+ using DynamicEntryList = std::vector<std::pair<long, unsigned long>>;
/** Get the type of the file opened. */
FileType GetFileType() const;
@@ -105,7 +109,7 @@ public:
private:
friend class cmELFInternal;
bool Valid() const;
- cmELFInternal* Internal;
+ std::unique_ptr<cmELFInternal> Internal;
std::string ErrorMessage;
};
diff --git a/Source/cmEnableLanguageCommand.cxx b/Source/cmEnableLanguageCommand.cxx
index c57b7b15c..59522c040 100644
--- a/Source/cmEnableLanguageCommand.cxx
+++ b/Source/cmEnableLanguageCommand.cxx
@@ -2,29 +2,27 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmEnableLanguageCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-class cmExecutionStatus;
-
-// cmEnableLanguageCommand
-bool cmEnableLanguageCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmEnableLanguageCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- bool optional = false;
- std::vector<std::string> languages;
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- for (std::vector<std::string>::const_iterator it = args.begin();
- it != args.end(); ++it) {
- if ((*it) == "OPTIONAL") {
+
+ bool optional = false;
+ std::vector<std::string> languages;
+ for (std::string const& it : args) {
+ if (it == "OPTIONAL") {
optional = true;
} else {
- languages.push_back(*it);
+ languages.push_back(it);
}
}
- this->Makefile->EnableLanguage(languages, optional);
+ status.GetMakefile().EnableLanguage(languages, optional);
return true;
}
diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h
index 33c1c22bf..1f8c4ce7e 100644
--- a/Source/cmEnableLanguageCommand.h
+++ b/Source/cmEnableLanguageCommand.h
@@ -3,37 +3,14 @@
#ifndef cmEnableLanguageCommand_h
#define cmEnableLanguageCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmEnableLanguageCommand
- * \brief Specify the name for this build project.
- *
- * cmEnableLanguageCommand is used to specify a name for this build project.
- * It is defined once per set of CMakeList.txt files (including
- * all subdirectories). Currently it just sets the name of the workspace
- * file for Microsoft Visual C++
- */
-class cmEnableLanguageCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmEnableLanguageCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmEnableLanguageCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmEnableTestingCommand.cxx b/Source/cmEnableTestingCommand.cxx
index 6a64450f5..89212c801 100644
--- a/Source/cmEnableTestingCommand.cxx
+++ b/Source/cmEnableTestingCommand.cxx
@@ -2,15 +2,12 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmEnableTestingCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-class cmExecutionStatus;
-
-// we do this in the final pass so that we now the subdirs have all
-// been defined
-bool cmEnableTestingCommand::InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&)
+bool cmEnableTestingCommand(std::vector<std::string> const&,
+ cmExecutionStatus& status)
{
- this->Makefile->AddDefinition("CMAKE_TESTING_ENABLED", "1");
+ status.GetMakefile().AddDefinition("CMAKE_TESTING_ENABLED", "1");
return true;
}
diff --git a/Source/cmEnableTestingCommand.h b/Source/cmEnableTestingCommand.h
index e24966221..e4593f2fe 100644
--- a/Source/cmEnableTestingCommand.h
+++ b/Source/cmEnableTestingCommand.h
@@ -3,16 +3,14 @@
#ifndef cmEnableTestingCommand_h
#define cmEnableTestingCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmEnableTestingCommand
+/**
* \brief Enable testing for this directory and below.
*
* Produce the output testfile. This produces a file in the build directory
@@ -25,20 +23,7 @@ class cmExecutionStatus;
* Note that CTest expects to find this file in the build directory root;
* therefore, this command should be in the source directory root too.
*/
-class cmEnableTestingCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmEnableTestingCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&) CM_OVERRIDE;
-};
+bool cmEnableTestingCommand(std::vector<std::string> const&,
+ cmExecutionStatus&);
#endif
diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx
index fcc3c45c6..51fb2191a 100644
--- a/Source/cmExecProgramCommand.cxx
+++ b/Source/cmExecProgramCommand.cxx
@@ -2,21 +2,30 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExecProgramCommand.h"
+#include <cstdio>
+
#include "cmsys/Process.h"
-#include <stdio.h>
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmProcessOutput.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
+using Encoding = cmProcessOutput::Encoding;
+
+namespace {
+bool RunCommand(std::string command, std::string& output, int& retVal,
+ const char* directory = nullptr, bool verbose = true,
+ Encoding encoding = cmProcessOutput::Auto);
+}
// cmExecProgramCommand
-bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmExecProgramCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
std::string arguments;
@@ -26,40 +35,40 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
bool haveoutput_variable = false;
std::string return_variable;
bool havereturn_variable = false;
- for (size_t i = 0; i < args.size(); ++i) {
- if (args[i] == "OUTPUT_VARIABLE") {
+ for (std::string const& arg : args) {
+ if (arg == "OUTPUT_VARIABLE") {
count++;
doingargs = false;
havereturn_variable = false;
haveoutput_variable = true;
} else if (haveoutput_variable) {
if (!output_variable.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- output_variable = args[i];
+ output_variable = arg;
haveoutput_variable = false;
count++;
- } else if (args[i] == "RETURN_VALUE") {
+ } else if (arg == "RETURN_VALUE") {
count++;
doingargs = false;
haveoutput_variable = false;
havereturn_variable = true;
} else if (havereturn_variable) {
if (!return_variable.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- return_variable = args[i];
+ return_variable = arg;
havereturn_variable = false;
count++;
- } else if (args[i] == "ARGS") {
+ } else if (arg == "ARGS") {
count++;
havereturn_variable = false;
haveoutput_variable = false;
doingargs = true;
} else if (doingargs) {
- arguments += args[i];
+ arguments += arg;
arguments += " ";
count++;
}
@@ -67,9 +76,8 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
std::string command;
if (!arguments.empty()) {
- command = cmSystemTools::ConvertToRunCommandPath(args[0].c_str());
- command += " ";
- command += arguments;
+ command = cmStrCat(cmSystemTools::ConvertToRunCommandPath(args[0]), ' ',
+ arguments);
} else {
command = args[0];
}
@@ -81,12 +89,10 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
std::string output;
bool result = true;
if (args.size() - count == 2) {
- cmSystemTools::MakeDirectory(args[1].c_str());
- result = cmExecProgramCommand::RunCommand(command.c_str(), output, retVal,
- args[1].c_str(), verbose);
+ cmSystemTools::MakeDirectory(args[1]);
+ result = RunCommand(command, output, retVal, args[1].c_str(), verbose);
} else {
- result = cmExecProgramCommand::RunCommand(command.c_str(), output, retVal,
- CM_NULLPTR, verbose);
+ result = RunCommand(command, output, retVal, nullptr, verbose);
}
if (!result) {
retVal = -1;
@@ -103,21 +109,21 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args,
}
std::string coutput = std::string(output, first, last - first + 1);
- this->Makefile->AddDefinition(output_variable, coutput.c_str());
+ status.GetMakefile().AddDefinition(output_variable, coutput);
}
if (!return_variable.empty()) {
char buffer[100];
sprintf(buffer, "%d", retVal);
- this->Makefile->AddDefinition(return_variable, buffer);
+ status.GetMakefile().AddDefinition(return_variable, buffer);
}
return true;
}
-bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
- int& retVal, const char* dir,
- bool verbose, Encoding encoding)
+namespace {
+bool RunCommand(std::string command, std::string& output, int& retVal,
+ const char* dir, bool verbose, Encoding encoding)
{
if (cmSystemTools::GetRunCommandOutput()) {
verbose = false;
@@ -128,12 +134,11 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
// try to find the program, and if the program can not be
// found use system to run the command as it must be a built in
// shell command like echo or dir
- int count = 0;
- std::string shortCmd;
- if (command[0] == '\"') {
+ if (!command.empty() && command[0] == '\"') {
// count the number of quotes
- for (const char* s = command; *s != 0; ++s) {
- if (*s == '\"') {
+ int count = 0;
+ for (char c : command) {
+ if (c == '\"') {
count++;
if (count > 2) {
break;
@@ -147,20 +152,21 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
if (count > 2) {
cmsys::RegularExpression quoted("^\"([^\"]*)\"[ \t](.*)");
if (quoted.find(command)) {
+ std::string shortCmd;
std::string cmd = quoted.match(1);
std::string args = quoted.match(2);
- if (!cmSystemTools::FileExists(cmd.c_str())) {
+ if (!cmSystemTools::FileExists(cmd)) {
shortCmd = cmd;
- } else if (!cmSystemTools::GetShortPath(cmd.c_str(), shortCmd)) {
- cmSystemTools::Error("GetShortPath failed for ", cmd.c_str());
+ } else if (!cmSystemTools::GetShortPath(cmd, shortCmd)) {
+ cmSystemTools::Error("GetShortPath failed for " + cmd);
return false;
}
shortCmd += " ";
shortCmd += args;
- command = shortCmd.c_str();
+ command = shortCmd;
} else {
- cmSystemTools::Error("Could not parse command line with quotes ",
+ cmSystemTools::Error("Could not parse command line with quotes " +
command);
}
}
@@ -182,22 +188,19 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
}
cmsysProcess_SetOption(cp, cmsysProcess_Option_Verbatim, 1);
- const char* cmd[] = { command, 0 };
+ const char* cmd[] = { command.c_str(), nullptr };
cmsysProcess_SetCommand(cp, cmd);
#else
std::string commandInDir;
if (dir) {
- commandInDir = "cd \"";
- commandInDir += dir;
- commandInDir += "\" && ";
- commandInDir += command;
+ commandInDir = cmStrCat("cd \"", dir, "\" && ", command);
} else {
commandInDir = command;
}
-#ifndef __VMS
+# ifndef __VMS
commandInDir += " 2>&1";
-#endif
- command = commandInDir.c_str();
+# endif
+ command = commandInDir;
if (verbose) {
cmSystemTools::Stdout("running ");
cmSystemTools::Stdout(command);
@@ -205,7 +208,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
}
fflush(stdout);
fflush(stderr);
- const char* cmd[] = { "/bin/sh", "-c", command, CM_NULLPTR };
+ const char* cmd[] = { "/bin/sh", "-c", command.c_str(), nullptr };
cmsysProcess_SetCommand(cp, cmd);
#endif
@@ -217,11 +220,11 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
int p;
cmProcessOutput processOutput(encoding);
std::string strdata;
- while ((p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) {
+ while ((p = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) {
if (p == cmsysProcess_Pipe_STDOUT || p == cmsysProcess_Pipe_STDERR) {
if (verbose) {
processOutput.DecodeText(data, length, strdata);
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
output.append(data, length);
}
@@ -230,12 +233,12 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
if (verbose) {
processOutput.DecodeText(std::string(), strdata);
if (!strdata.empty()) {
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
}
// All output has been read. Wait for the process to exit.
- cmsysProcess_WaitForExit(cp, CM_NULLPTR);
+ cmsysProcess_WaitForExit(cp, nullptr);
processOutput.DecodeText(output, output);
// Check the result of running the process.
@@ -270,7 +273,7 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
}
msg += "\n";
if (verbose) {
- cmSystemTools::Stdout(msg.c_str());
+ cmSystemTools::Stdout(msg);
}
output += msg;
#else
@@ -284,3 +287,4 @@ bool cmExecProgramCommand::RunCommand(const char* command, std::string& output,
return true;
}
+}
diff --git a/Source/cmExecProgramCommand.h b/Source/cmExecProgramCommand.h
index 6463c4db5..7c751e154 100644
--- a/Source/cmExecProgramCommand.h
+++ b/Source/cmExecProgramCommand.h
@@ -3,44 +3,21 @@
#ifndef cmExecProgramCommand_h
#define cmExecProgramCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-#include "cmProcessOutput.h"
-
class cmExecutionStatus;
-/** \class cmExecProgramCommand
+/**
* \brief Command that adds a target to the build system.
*
* cmExecProgramCommand adds an extra target to the build system.
* This is useful when you would like to add special
* targets like "install,", "clean," and so on.
*/
-class cmExecProgramCommand : public cmCommand
-{
-public:
- typedef cmProcessOutput::Encoding Encoding;
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmExecProgramCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- static bool RunCommand(const char* command, std::string& output, int& retVal,
- const char* directory = CM_NULLPTR,
- bool verbose = true,
- Encoding encoding = cmProcessOutput::Auto);
-};
+bool cmExecProgramCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index 8c10dbe29..80e4bcd63 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -2,193 +2,148 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExecuteProcessCommand.h"
+#include <algorithm>
+#include <cctype> /* isspace */
+#include <cstdio>
+#include <iostream>
+#include <memory>
+#include <vector>
+
#include "cmsys/Process.h"
-#include <ctype.h> /* isspace */
-#include <sstream>
-#include <stdio.h>
+#include "cm_static_string_view.hxx"
+
+#include "cmAlgorithms.h"
+#include "cmArgumentParser.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmProcessOutput.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
-static bool cmExecuteProcessCommandIsWhitespace(char c)
+namespace {
+bool cmExecuteProcessCommandIsWhitespace(char c)
{
- return (isspace((int)c) || c == '\n' || c == '\r');
+ return (isspace(static_cast<int>(c)) || c == '\n' || c == '\r');
}
void cmExecuteProcessCommandFixText(std::vector<char>& output,
bool strip_trailing_whitespace);
void cmExecuteProcessCommandAppend(std::vector<char>& output, const char* data,
int length);
+}
// cmExecuteProcessCommand
-bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmExecuteProcessCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- std::vector<std::vector<const char*> > cmds;
- std::string arguments;
- bool doing_command = false;
- size_t command_index = 0;
- bool output_quiet = false;
- bool error_quiet = false;
- bool output_strip_trailing_whitespace = false;
- bool error_strip_trailing_whitespace = false;
- std::string timeout_string;
- std::string input_file;
- std::string output_file;
- std::string error_file;
- std::string output_variable;
- std::string error_variable;
- std::string result_variable;
- std::string working_directory;
- cmProcessOutput::Encoding encoding = cmProcessOutput::None;
- for (size_t i = 0; i < args.size(); ++i) {
- if (args[i] == "COMMAND") {
- doing_command = true;
- command_index = cmds.size();
- cmds.push_back(std::vector<const char*>());
- } else if (args[i] == "OUTPUT_VARIABLE") {
- doing_command = false;
- if (++i < args.size()) {
- output_variable = args[i];
- } else {
- this->SetError(" called with no value for OUTPUT_VARIABLE.");
- return false;
- }
- } else if (args[i] == "ERROR_VARIABLE") {
- doing_command = false;
- if (++i < args.size()) {
- error_variable = args[i];
- } else {
- this->SetError(" called with no value for ERROR_VARIABLE.");
- return false;
- }
- } else if (args[i] == "RESULT_VARIABLE") {
- doing_command = false;
- if (++i < args.size()) {
- result_variable = args[i];
- } else {
- this->SetError(" called with no value for RESULT_VARIABLE.");
- return false;
- }
- } else if (args[i] == "WORKING_DIRECTORY") {
- doing_command = false;
- if (++i < args.size()) {
- working_directory = args[i];
- } else {
- this->SetError(" called with no value for WORKING_DIRECTORY.");
- return false;
- }
- } else if (args[i] == "INPUT_FILE") {
- doing_command = false;
- if (++i < args.size()) {
- input_file = args[i];
- } else {
- this->SetError(" called with no value for INPUT_FILE.");
- return false;
- }
- } else if (args[i] == "OUTPUT_FILE") {
- doing_command = false;
- if (++i < args.size()) {
- output_file = args[i];
- } else {
- this->SetError(" called with no value for OUTPUT_FILE.");
- return false;
- }
- } else if (args[i] == "ERROR_FILE") {
- doing_command = false;
- if (++i < args.size()) {
- error_file = args[i];
- } else {
- this->SetError(" called with no value for ERROR_FILE.");
- return false;
- }
- } else if (args[i] == "TIMEOUT") {
- doing_command = false;
- if (++i < args.size()) {
- timeout_string = args[i];
- } else {
- this->SetError(" called with no value for TIMEOUT.");
- return false;
- }
- } else if (args[i] == "OUTPUT_QUIET") {
- doing_command = false;
- output_quiet = true;
- } else if (args[i] == "ERROR_QUIET") {
- doing_command = false;
- error_quiet = true;
- } else if (args[i] == "OUTPUT_STRIP_TRAILING_WHITESPACE") {
- doing_command = false;
- output_strip_trailing_whitespace = true;
- } else if (args[i] == "ERROR_STRIP_TRAILING_WHITESPACE") {
- doing_command = false;
- error_strip_trailing_whitespace = true;
- } else if (args[i] == "ENCODING") {
- doing_command = false;
- if (++i < args.size()) {
- encoding = cmProcessOutput::FindEncoding(args[i]);
- } else {
- this->SetError(" called with no value for ENCODING.");
- return false;
- }
- } else if (doing_command) {
- cmds[command_index].push_back(args[i].c_str());
- } else {
- std::ostringstream e;
- e << " given unknown argument \"" << args[i] << "\".";
- this->SetError(e.str());
- return false;
- }
+
+ struct Arguments
+ {
+ std::vector<std::vector<std::string>> Commands;
+ std::string OutputVariable;
+ std::string ErrorVariable;
+ std::string ResultVariable;
+ std::string ResultsVariable;
+ std::string WorkingDirectory;
+ std::string InputFile;
+ std::string OutputFile;
+ std::string ErrorFile;
+ std::string Timeout;
+ std::string CommandEcho;
+ bool OutputQuiet = false;
+ bool ErrorQuiet = false;
+ bool OutputStripTrailingWhitespace = false;
+ bool ErrorStripTrailingWhitespace = false;
+ std::string Encoding;
+ };
+
+ static auto const parser =
+ cmArgumentParser<Arguments>{}
+ .Bind("COMMAND"_s, &Arguments::Commands)
+ .Bind("COMMAND_ECHO"_s, &Arguments::CommandEcho)
+ .Bind("OUTPUT_VARIABLE"_s, &Arguments::OutputVariable)
+ .Bind("ERROR_VARIABLE"_s, &Arguments::ErrorVariable)
+ .Bind("RESULT_VARIABLE"_s, &Arguments::ResultVariable)
+ .Bind("RESULTS_VARIABLE"_s, &Arguments::ResultsVariable)
+ .Bind("WORKING_DIRECTORY"_s, &Arguments::WorkingDirectory)
+ .Bind("INPUT_FILE"_s, &Arguments::InputFile)
+ .Bind("OUTPUT_FILE"_s, &Arguments::OutputFile)
+ .Bind("ERROR_FILE"_s, &Arguments::ErrorFile)
+ .Bind("TIMEOUT"_s, &Arguments::Timeout)
+ .Bind("OUTPUT_QUIET"_s, &Arguments::OutputQuiet)
+ .Bind("ERROR_QUIET"_s, &Arguments::ErrorQuiet)
+ .Bind("OUTPUT_STRIP_TRAILING_WHITESPACE"_s,
+ &Arguments::OutputStripTrailingWhitespace)
+ .Bind("ERROR_STRIP_TRAILING_WHITESPACE"_s,
+ &Arguments::ErrorStripTrailingWhitespace)
+ .Bind("ENCODING"_s, &Arguments::Encoding);
+
+ std::vector<std::string> unparsedArguments;
+ std::vector<std::string> keywordsMissingValue;
+ Arguments const arguments =
+ parser.Parse(args, &unparsedArguments, &keywordsMissingValue);
+
+ if (!keywordsMissingValue.empty()) {
+ status.SetError(" called with no value for " +
+ keywordsMissingValue.front() + ".");
+ return false;
+ }
+ if (!unparsedArguments.empty()) {
+ status.SetError(" given unknown argument \"" + unparsedArguments.front() +
+ "\".");
+ return false;
}
- if (!this->Makefile->CanIWriteThisFile(output_file.c_str())) {
- std::string e = "attempted to output into a file: " + output_file +
- " into a source directory.";
- this->SetError(e);
+ if (!status.GetMakefile().CanIWriteThisFile(arguments.OutputFile)) {
+ status.SetError("attempted to output into a file: " +
+ arguments.OutputFile + " into a source directory.");
cmSystemTools::SetFatalErrorOccured();
return false;
}
// Check for commands given.
- if (cmds.empty()) {
- this->SetError(" called with no COMMAND argument.");
+ if (arguments.Commands.empty()) {
+ status.SetError(" called with no COMMAND argument.");
return false;
}
- for (unsigned int i = 0; i < cmds.size(); ++i) {
- if (cmds[i].empty()) {
- this->SetError(" given COMMAND argument with no value.");
+ for (std::vector<std::string> const& cmd : arguments.Commands) {
+ if (cmd.empty()) {
+ status.SetError(" given COMMAND argument with no value.");
return false;
}
- // Add the null terminating pointer to the command argument list.
- cmds[i].push_back(CM_NULLPTR);
}
// Parse the timeout string.
double timeout = -1;
- if (!timeout_string.empty()) {
- if (sscanf(timeout_string.c_str(), "%lg", &timeout) != 1) {
- this->SetError(" called with TIMEOUT value that could not be parsed.");
+ if (!arguments.Timeout.empty()) {
+ if (sscanf(arguments.Timeout.c_str(), "%lg", &timeout) != 1) {
+ status.SetError(" called with TIMEOUT value that could not be parsed.");
return false;
}
}
-
// Create a process instance.
- cmsysProcess* cp = cmsysProcess_New();
+ std::unique_ptr<cmsysProcess, void (*)(cmsysProcess*)> cp_ptr(
+ cmsysProcess_New(), cmsysProcess_Delete);
+ cmsysProcess* cp = cp_ptr.get();
// Set the command sequence.
- for (unsigned int i = 0; i < cmds.size(); ++i) {
- cmsysProcess_AddCommand(cp, &*cmds[i].begin());
+ for (std::vector<std::string> const& cmd : arguments.Commands) {
+ std::vector<const char*> argv(cmd.size() + 1);
+ std::transform(cmd.begin(), cmd.end(), argv.begin(),
+ [](std::string const& s) { return s.c_str(); });
+ argv.back() = nullptr;
+ cmsysProcess_AddCommand(cp, argv.data());
}
// Set the process working directory.
- if (!working_directory.empty()) {
- cmsysProcess_SetWorkingDirectory(cp, working_directory.c_str());
+ if (!arguments.WorkingDirectory.empty()) {
+ cmsysProcess_SetWorkingDirectory(cp, arguments.WorkingDirectory.c_str());
}
// Always hide the process window.
@@ -196,22 +151,24 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
// Check the output variables.
bool merge_output = false;
- if (!input_file.empty()) {
- cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDIN, input_file.c_str());
+ if (!arguments.InputFile.empty()) {
+ cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDIN,
+ arguments.InputFile.c_str());
}
- if (!output_file.empty()) {
+ if (!arguments.OutputFile.empty()) {
cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDOUT,
- output_file.c_str());
+ arguments.OutputFile.c_str());
}
- if (!error_file.empty()) {
- if (error_file == output_file) {
+ if (!arguments.ErrorFile.empty()) {
+ if (arguments.ErrorFile == arguments.OutputFile) {
merge_output = true;
} else {
cmsysProcess_SetPipeFile(cp, cmsysProcess_Pipe_STDERR,
- error_file.c_str());
+ arguments.ErrorFile.c_str());
}
}
- if (!output_variable.empty() && output_variable == error_variable) {
+ if (!arguments.OutputVariable.empty() &&
+ arguments.OutputVariable == arguments.ErrorVariable) {
merge_output = true;
}
if (merge_output) {
@@ -223,6 +180,51 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
cmsysProcess_SetTimeout(cp, timeout);
}
+ bool echo_stdout = false;
+ bool echo_stderr = false;
+ bool echo_output_from_variable = true;
+ std::string echo_output = status.GetMakefile().GetSafeDefinition(
+ "CMAKE_EXECUTE_PROCESS_COMMAND_ECHO");
+ if (!arguments.CommandEcho.empty()) {
+ echo_output_from_variable = false;
+ echo_output = arguments.CommandEcho;
+ }
+
+ if (!echo_output.empty()) {
+ if (echo_output == "STDERR") {
+ echo_stderr = true;
+ } else if (echo_output == "STDOUT") {
+ echo_stdout = true;
+ } else if (echo_output != "NONE") {
+ std::string error;
+ if (echo_output_from_variable) {
+ error = "CMAKE_EXECUTE_PROCESS_COMMAND_ECHO set to '";
+ } else {
+ error = " called with '";
+ }
+ error += echo_output;
+ error += "' expected STDERR|STDOUT|NONE";
+ if (!echo_output_from_variable) {
+ error += " for COMMAND_ECHO.";
+ }
+ status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, error);
+ return true;
+ }
+ }
+ if (echo_stdout || echo_stderr) {
+ std::string command;
+ for (auto& cmd : arguments.Commands) {
+ command += "'";
+ command += cmJoin(cmd, "' '");
+ command += "'";
+ command += "\n";
+ }
+ if (echo_stdout) {
+ std::cout << command;
+ } else if (echo_stderr) {
+ std::cerr << command;
+ }
+ }
// Start the process.
cmsysProcess_Execute(cp);
@@ -232,86 +234,131 @@ bool cmExecuteProcessCommand::InitialPass(std::vector<std::string> const& args,
int length;
char* data;
int p;
- cmProcessOutput processOutput(encoding);
+ cmProcessOutput processOutput(
+ cmProcessOutput::FindEncoding(arguments.Encoding));
std::string strdata;
- while ((p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) {
+ while ((p = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) {
// Put the output in the right place.
- if (p == cmsysProcess_Pipe_STDOUT && !output_quiet) {
- if (output_variable.empty()) {
+ if (p == cmsysProcess_Pipe_STDOUT && !arguments.OutputQuiet) {
+ if (arguments.OutputVariable.empty()) {
processOutput.DecodeText(data, length, strdata, 1);
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
} else {
cmExecuteProcessCommandAppend(tempOutput, data, length);
}
- } else if (p == cmsysProcess_Pipe_STDERR && !error_quiet) {
- if (error_variable.empty()) {
+ } else if (p == cmsysProcess_Pipe_STDERR && !arguments.ErrorQuiet) {
+ if (arguments.ErrorVariable.empty()) {
processOutput.DecodeText(data, length, strdata, 2);
- cmSystemTools::Stderr(strdata.c_str(), strdata.size());
+ cmSystemTools::Stderr(strdata);
} else {
cmExecuteProcessCommandAppend(tempError, data, length);
}
}
}
- if (!output_quiet && output_variable.empty()) {
+ if (!arguments.OutputQuiet && arguments.OutputVariable.empty()) {
processOutput.DecodeText(std::string(), strdata, 1);
if (!strdata.empty()) {
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
}
- if (!error_quiet && error_variable.empty()) {
+ if (!arguments.ErrorQuiet && arguments.ErrorVariable.empty()) {
processOutput.DecodeText(std::string(), strdata, 2);
if (!strdata.empty()) {
- cmSystemTools::Stderr(strdata.c_str(), strdata.size());
+ cmSystemTools::Stderr(strdata);
}
}
// All output has been read. Wait for the process to exit.
- cmsysProcess_WaitForExit(cp, CM_NULLPTR);
+ cmsysProcess_WaitForExit(cp, nullptr);
processOutput.DecodeText(tempOutput, tempOutput);
processOutput.DecodeText(tempError, tempError);
// Fix the text in the output strings.
- cmExecuteProcessCommandFixText(tempOutput, output_strip_trailing_whitespace);
- cmExecuteProcessCommandFixText(tempError, error_strip_trailing_whitespace);
+ cmExecuteProcessCommandFixText(tempOutput,
+ arguments.OutputStripTrailingWhitespace);
+ cmExecuteProcessCommandFixText(tempError,
+ arguments.ErrorStripTrailingWhitespace);
// Store the output obtained.
- if (!output_variable.empty() && !tempOutput.empty()) {
- this->Makefile->AddDefinition(output_variable, &*tempOutput.begin());
+ if (!arguments.OutputVariable.empty() && !tempOutput.empty()) {
+ status.GetMakefile().AddDefinition(arguments.OutputVariable,
+ tempOutput.data());
}
- if (!merge_output && !error_variable.empty() && !tempError.empty()) {
- this->Makefile->AddDefinition(error_variable, &*tempError.begin());
+ if (!merge_output && !arguments.ErrorVariable.empty() &&
+ !tempError.empty()) {
+ status.GetMakefile().AddDefinition(arguments.ErrorVariable,
+ tempError.data());
}
// Store the result of running the process.
- if (!result_variable.empty()) {
+ if (!arguments.ResultVariable.empty()) {
switch (cmsysProcess_GetState(cp)) {
case cmsysProcess_State_Exited: {
int v = cmsysProcess_GetExitValue(cp);
- char buf[100];
+ char buf[16];
sprintf(buf, "%d", v);
- this->Makefile->AddDefinition(result_variable, buf);
+ status.GetMakefile().AddDefinition(arguments.ResultVariable, buf);
} break;
case cmsysProcess_State_Exception:
- this->Makefile->AddDefinition(result_variable,
- cmsysProcess_GetExceptionString(cp));
+ status.GetMakefile().AddDefinition(
+ arguments.ResultVariable, cmsysProcess_GetExceptionString(cp));
break;
case cmsysProcess_State_Error:
- this->Makefile->AddDefinition(result_variable,
- cmsysProcess_GetErrorString(cp));
+ status.GetMakefile().AddDefinition(arguments.ResultVariable,
+ cmsysProcess_GetErrorString(cp));
break;
case cmsysProcess_State_Expired:
- this->Makefile->AddDefinition(result_variable,
- "Process terminated due to timeout");
+ status.GetMakefile().AddDefinition(
+ arguments.ResultVariable, "Process terminated due to timeout");
+ break;
+ }
+ }
+ // Store the result of running the processes.
+ if (!arguments.ResultsVariable.empty()) {
+ switch (cmsysProcess_GetState(cp)) {
+ case cmsysProcess_State_Exited: {
+ std::vector<std::string> res;
+ for (size_t i = 0; i < arguments.Commands.size(); ++i) {
+ switch (cmsysProcess_GetStateByIndex(cp, static_cast<int>(i))) {
+ case kwsysProcess_StateByIndex_Exited: {
+ int exitCode =
+ cmsysProcess_GetExitValueByIndex(cp, static_cast<int>(i));
+ char buf[16];
+ sprintf(buf, "%d", exitCode);
+ res.emplace_back(buf);
+ } break;
+ case kwsysProcess_StateByIndex_Exception:
+ res.emplace_back(cmsysProcess_GetExceptionStringByIndex(
+ cp, static_cast<int>(i)));
+ break;
+ case kwsysProcess_StateByIndex_Error:
+ default:
+ res.emplace_back("Error getting the child return code");
+ break;
+ }
+ }
+ status.GetMakefile().AddDefinition(arguments.ResultsVariable,
+ cmJoin(res, ";"));
+ } break;
+ case cmsysProcess_State_Exception:
+ status.GetMakefile().AddDefinition(
+ arguments.ResultsVariable, cmsysProcess_GetExceptionString(cp));
+ break;
+ case cmsysProcess_State_Error:
+ status.GetMakefile().AddDefinition(arguments.ResultsVariable,
+ cmsysProcess_GetErrorString(cp));
+ break;
+ case cmsysProcess_State_Expired:
+ status.GetMakefile().AddDefinition(
+ arguments.ResultsVariable, "Process terminated due to timeout");
break;
}
}
-
- // Delete the process instance.
- cmsysProcess_Delete(cp);
return true;
}
+namespace {
void cmExecuteProcessCommandFixText(std::vector<char>& output,
bool strip_trailing_whitespace)
{
@@ -355,5 +402,6 @@ void cmExecuteProcessCommandAppend(std::vector<char>& output, const char* data,
--length;
}
#endif
- output.insert(output.end(), data, data + length);
+ cmAppend(output, data, data + length);
+}
}
diff --git a/Source/cmExecuteProcessCommand.h b/Source/cmExecuteProcessCommand.h
index 08fde0adc..9c4b6007f 100644
--- a/Source/cmExecuteProcessCommand.h
+++ b/Source/cmExecuteProcessCommand.h
@@ -3,35 +3,20 @@
#ifndef cmExecuteProcessCommand_h
#define cmExecuteProcessCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmExecuteProcessCommand
+/**
* \brief Command that adds a target to the build system.
*
* cmExecuteProcessCommand is a CMake language interface to the KWSys
* Process Execution implementation.
*/
-class cmExecuteProcessCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmExecuteProcessCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmExecuteProcessCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h
index ac5fe1d72..d2cc9b87a 100644
--- a/Source/cmExecutionStatus.h
+++ b/Source/cmExecutionStatus.h
@@ -3,6 +3,12 @@
#ifndef cmExecutionStatus_h
#define cmExecutionStatus_h
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include <string>
+
+class cmMakefile;
+
/** \class cmExecutionStatus
* \brief Superclass for all command status classes
*
@@ -11,21 +17,16 @@
class cmExecutionStatus
{
public:
- cmExecutionStatus()
- : ReturnInvoked(false)
- , BreakInvoked(false)
- , ContinueInvoked(false)
- , NestedError(false)
+ cmExecutionStatus(cmMakefile& makefile)
+ : Makefile(makefile)
+ , Error("unknown error.")
{
}
- void Clear()
- {
- this->ReturnInvoked = false;
- this->BreakInvoked = false;
- this->ContinueInvoked = false;
- this->NestedError = false;
- }
+ cmMakefile& GetMakefile() { return this->Makefile; }
+
+ void SetError(std::string const& e) { this->Error = e; }
+ std::string const& GetError() const { return this->Error; }
void SetReturnInvoked() { this->ReturnInvoked = true; }
bool GetReturnInvoked() const { return this->ReturnInvoked; }
@@ -40,10 +41,12 @@ public:
bool GetNestedError() const { return this->NestedError; }
private:
- bool ReturnInvoked;
- bool BreakInvoked;
- bool ContinueInvoked;
- bool NestedError;
+ cmMakefile& Makefile;
+ std::string Error;
+ bool ReturnInvoked = false;
+ bool BreakInvoked = false;
+ bool ContinueInvoked = false;
+ bool NestedError = false;
};
#endif
diff --git a/Source/cmExpandedCommandArgument.cxx b/Source/cmExpandedCommandArgument.cxx
index 0bea65fd0..43f648bc3 100644
--- a/Source/cmExpandedCommandArgument.cxx
+++ b/Source/cmExpandedCommandArgument.cxx
@@ -2,14 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExpandedCommandArgument.h"
-cmExpandedCommandArgument::cmExpandedCommandArgument()
- : Quoted(false)
-{
-}
+#include <utility>
-cmExpandedCommandArgument::cmExpandedCommandArgument(std::string const& value,
+cmExpandedCommandArgument::cmExpandedCommandArgument() = default;
+
+cmExpandedCommandArgument::cmExpandedCommandArgument(std::string value,
bool quoted)
- : Value(value)
+ : Value(std::move(value))
, Quoted(quoted)
{
}
@@ -24,6 +23,11 @@ bool cmExpandedCommandArgument::WasQuoted() const
return this->Quoted;
}
+bool cmExpandedCommandArgument::operator==(const char* value) const
+{
+ return this->Value == value;
+}
+
bool cmExpandedCommandArgument::operator==(std::string const& value) const
{
return this->Value == value;
diff --git a/Source/cmExpandedCommandArgument.h b/Source/cmExpandedCommandArgument.h
index fe86528db..69d35debe 100644
--- a/Source/cmExpandedCommandArgument.h
+++ b/Source/cmExpandedCommandArgument.h
@@ -18,12 +18,13 @@ class cmExpandedCommandArgument
{
public:
cmExpandedCommandArgument();
- cmExpandedCommandArgument(std::string const& value, bool quoted);
+ cmExpandedCommandArgument(std::string value, bool quoted);
std::string const& GetValue() const;
bool WasQuoted() const;
+ bool operator==(const char* value) const;
bool operator==(std::string const& value) const;
bool empty() const;
@@ -32,7 +33,7 @@ public:
private:
std::string Value;
- bool Quoted;
+ bool Quoted = false;
};
#endif
diff --git a/Source/cmExportBuildAndroidMKGenerator.cxx b/Source/cmExportBuildAndroidMKGenerator.cxx
index b443fb0b4..561e83066 100644
--- a/Source/cmExportBuildAndroidMKGenerator.cxx
+++ b/Source/cmExportBuildAndroidMKGenerator.cxx
@@ -2,27 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportBuildAndroidMKGenerator.h"
-#include <algorithm>
-#include <map>
#include <sstream>
#include <utility>
-#include "cmGeneratorExpression.h"
+#include "cmAlgorithms.h"
#include "cmGeneratorTarget.h"
#include "cmLinkItem.h"
-#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cm_auto_ptr.hxx"
-#include "cmake.h"
cmExportBuildAndroidMKGenerator::cmExportBuildAndroidMKGenerator()
{
- this->LG = CM_NULLPTR;
- this->ExportSet = CM_NULLPTR;
+ this->LG = nullptr;
+ this->ExportSet = nullptr;
}
void cmExportBuildAndroidMKGenerator::GenerateImportHeaderCode(
@@ -41,16 +38,15 @@ void cmExportBuildAndroidMKGenerator::GenerateExpectedTargetsCode(
}
void cmExportBuildAndroidMKGenerator::GenerateImportTargetCode(
- std::ostream& os, const cmGeneratorTarget* target)
+ std::ostream& os, cmGeneratorTarget const* target,
+ cmStateEnums::TargetType /*targetType*/)
{
- std::string targetName = this->Namespace;
- targetName += target->GetExportName();
+ std::string targetName = cmStrCat(this->Namespace, target->GetExportName());
os << "include $(CLEAR_VARS)\n";
os << "LOCAL_MODULE := ";
os << targetName << "\n";
os << "LOCAL_SRC_FILES := ";
- std::string path =
- cmSystemTools::ConvertToOutputPath(target->GetFullPath().c_str());
+ std::string path = cmSystemTools::ConvertToOutputPath(target->GetFullPath());
os << path << "\n";
}
@@ -94,57 +90,45 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties(
}
w << " set to OLD for target " << target->Target->GetName() << ". "
<< "The export will only work with CMP0022 set to NEW.";
- target->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ target->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
}
if (!properties.empty()) {
os << "LOCAL_CPP_FEATURES := rtti exceptions\n";
- for (ImportPropertyMap::const_iterator pi = properties.begin();
- pi != properties.end(); ++pi) {
- if (pi->first == "INTERFACE_COMPILE_OPTIONS") {
+ for (auto const& property : properties) {
+ if (property.first == "INTERFACE_COMPILE_OPTIONS") {
os << "LOCAL_CPP_FEATURES += ";
- os << (pi->second) << "\n";
- } else if (pi->first == "INTERFACE_LINK_LIBRARIES") {
- // need to look at list in pi->second and see if static or shared
- // FindTargetToLink
- // target->GetLocalGenerator()->FindGeneratorTargetToUse()
- // then add to LOCAL_CPPFLAGS
- std::vector<std::string> libraries;
- cmSystemTools::ExpandListArgument(pi->second, libraries);
+ os << (property.second) << "\n";
+ } else if (property.first == "INTERFACE_LINK_LIBRARIES") {
std::string staticLibs;
std::string sharedLibs;
std::string ldlibs;
- for (std::vector<std::string>::iterator i = libraries.begin();
- i != libraries.end(); ++i) {
- cmGeneratorTarget* gt =
- target->GetLocalGenerator()->FindGeneratorTargetToUse(*i);
+ cmLinkInterfaceLibraries const* linkIFace =
+ target->GetLinkInterfaceLibraries(config, target, false);
+ for (cmLinkItem const& item : linkIFace->Libraries) {
+ cmGeneratorTarget const* gt = item.Target;
+ std::string const& lib = item.AsStr();
if (gt) {
if (gt->GetType() == cmStateEnums::SHARED_LIBRARY ||
gt->GetType() == cmStateEnums::MODULE_LIBRARY) {
- sharedLibs += " " + *i;
+ sharedLibs += " " + lib;
} else {
- staticLibs += " " + *i;
+ staticLibs += " " + lib;
}
} else {
- // evaluate any generator expressions with the current
- // build type of the makefile
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*i);
- std::string evaluated =
- cge->Evaluate(target->GetLocalGenerator(), config);
bool relpath = false;
if (type == cmExportBuildAndroidMKGenerator::INSTALL) {
- relpath = i->substr(0, 3) == "../";
+ relpath = lib.substr(0, 3) == "../";
}
// check for full path or if it already has a -l, or
// in the case of an install check for relative paths
// if it is full or a link library then use string directly
- if (cmSystemTools::FileIsFullPath(evaluated) ||
- evaluated.substr(0, 2) == "-l" || relpath) {
- ldlibs += " " + evaluated;
+ if (cmSystemTools::FileIsFullPath(lib) ||
+ lib.substr(0, 2) == "-l" || relpath) {
+ ldlibs += " " + lib;
// if it is not a path and does not have a -l then add -l
- } else if (!evaluated.empty()) {
- ldlibs += " -l" + evaluated;
+ } else if (!lib.empty()) {
+ ldlibs += " -l" + lib;
}
}
}
@@ -157,20 +141,23 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties(
if (!ldlibs.empty()) {
os << "LOCAL_EXPORT_LDLIBS :=" << ldlibs << "\n";
}
- } else if (pi->first == "INTERFACE_INCLUDE_DIRECTORIES") {
- std::string includes = pi->second;
- std::vector<std::string> includeList;
- cmSystemTools::ExpandListArgument(includes, includeList);
+ } else if (property.first == "INTERFACE_INCLUDE_DIRECTORIES") {
+ std::string includes = property.second;
+ std::vector<std::string> includeList = cmExpandedList(includes);
os << "LOCAL_EXPORT_C_INCLUDES := ";
std::string end;
- for (std::vector<std::string>::iterator i = includeList.begin();
- i != includeList.end(); ++i) {
- os << end << *i;
+ for (std::string const& i : includeList) {
+ os << end << i;
end = "\\\n";
}
os << "\n";
+ } else if (property.first == "INTERFACE_LINK_OPTIONS") {
+ os << "LOCAL_EXPORT_LDFLAGS := ";
+ std::vector<std::string> linkFlagsList =
+ cmExpandedList(property.second);
+ os << cmJoin(linkFlagsList, " ") << "\n";
} else {
- os << "# " << pi->first << " " << (pi->second) << "\n";
+ os << "# " << property.first << " " << (property.second) << "\n";
}
}
}
@@ -178,8 +165,7 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties(
// Tell the NDK build system if prebuilt static libraries use C++.
if (target->GetType() == cmStateEnums::STATIC_LIBRARY) {
cmLinkImplementation const* li = target->GetLinkImplementation(config);
- if (std::find(li->Languages.begin(), li->Languages.end(), "CXX") !=
- li->Languages.end()) {
+ if (cmContains(li->Languages, "CXX")) {
os << "LOCAL_HAS_CPP := true\n";
}
}
diff --git a/Source/cmExportBuildAndroidMKGenerator.h b/Source/cmExportBuildAndroidMKGenerator.h
index d028ef48d..a9b6107f8 100644
--- a/Source/cmExportBuildAndroidMKGenerator.h
+++ b/Source/cmExportBuildAndroidMKGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmExportBuildAndroidMKGenerator_h
#define cmExportBuildAndroidMKGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
@@ -11,6 +11,7 @@
#include "cmExportBuildFileGenerator.h"
#include "cmExportFileGenerator.h"
+#include "cmStateTypes.h"
class cmGeneratorTarget;
@@ -42,25 +43,25 @@ public:
protected:
// Implement virtual methods from the superclass.
- void GeneratePolicyHeaderCode(std::ostream&) CM_OVERRIDE {}
- void GeneratePolicyFooterCode(std::ostream&) CM_OVERRIDE {}
+ void GeneratePolicyHeaderCode(std::ostream&) override {}
+ void GeneratePolicyFooterCode(std::ostream&) override {}
void GenerateImportHeaderCode(std::ostream& os,
- const std::string& config = "") CM_OVERRIDE;
- void GenerateImportFooterCode(std::ostream& os) CM_OVERRIDE;
- void GenerateImportTargetCode(std::ostream& os,
- const cmGeneratorTarget* target) CM_OVERRIDE;
+ const std::string& config = "") override;
+ void GenerateImportFooterCode(std::ostream& os) override;
+ void GenerateImportTargetCode(
+ std::ostream& os, cmGeneratorTarget const* target,
+ cmStateEnums::TargetType /*targetType*/) override;
void GenerateExpectedTargetsCode(
- std::ostream& os, const std::string& expectedTargets) CM_OVERRIDE;
- void GenerateImportPropertyCode(std::ostream& os, const std::string& config,
- cmGeneratorTarget const* target,
- ImportPropertyMap const& properties)
- CM_OVERRIDE;
+ std::ostream& os, const std::string& expectedTargets) override;
+ void GenerateImportPropertyCode(
+ std::ostream& os, const std::string& config,
+ cmGeneratorTarget const* target,
+ ImportPropertyMap const& properties) override;
void GenerateMissingTargetsCheckCode(
- std::ostream& os,
- const std::vector<std::string>& missingTargets) CM_OVERRIDE;
+ std::ostream& os, const std::vector<std::string>& missingTargets) override;
void GenerateInterfaceProperties(
cmGeneratorTarget const* target, std::ostream& os,
- const ImportPropertyMap& properties) CM_OVERRIDE;
+ const ImportPropertyMap& properties) override;
};
#endif
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index a1c424aca..7e9a98738 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -2,32 +2,32 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportBuildFileGenerator.h"
-#include "cmAlgorithms.h"
+#include <map>
+#include <memory>
+#include <set>
+#include <sstream>
+#include <utility>
+
#include "cmExportSet.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
-#include "cmSystemTools.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
#include "cmTargetExport.h"
#include "cmake.h"
-#include <algorithm>
-#include <map>
-#include <set>
-#include <sstream>
-#include <utility>
-
class cmSourceFile;
cmExportBuildFileGenerator::cmExportBuildFileGenerator()
{
- this->LG = CM_NULLPTR;
- this->ExportSet = CM_NULLPTR;
+ this->LG = nullptr;
+ this->ExportSet = nullptr;
}
void cmExportBuildFileGenerator::Compute(cmLocalGenerator* lg)
@@ -44,10 +44,10 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
std::string expectedTargets;
std::string sep;
std::vector<std::string> targets;
+ bool generatedInterfaceRequired = false;
this->GetTargets(targets);
- for (std::vector<std::string>::const_iterator tei = targets.begin();
- tei != targets.end(); ++tei) {
- cmGeneratorTarget* te = this->LG->FindGeneratorTargetToUse(*tei);
+ for (std::string const& tei : targets) {
+ cmGeneratorTarget* te = this->LG->FindGeneratorTargetToUse(tei);
expectedTargets += sep + this->Namespace + te->GetExportName();
sep = " ";
if (this->ExportedTargets.insert(te).second) {
@@ -56,26 +56,25 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
std::ostringstream e;
e << "given target \"" << te->GetName() << "\" more than once.";
this->LG->GetGlobalGenerator()->GetCMakeInstance()->IssueMessage(
- cmake::FATAL_ERROR, e.str(),
+ MessageType::FATAL_ERROR, e.str(),
this->LG->GetMakefile()->GetBacktrace());
return false;
}
- if (te->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
- this->GenerateRequiredCMakeVersion(os, "3.0.0");
- }
+ generatedInterfaceRequired |=
+ this->GetExportTargetType(te) == cmStateEnums::INTERFACE_LIBRARY;
}
+ if (generatedInterfaceRequired) {
+ this->GenerateRequiredCMakeVersion(os, "3.0.0");
+ }
this->GenerateExpectedTargetsCode(os, expectedTargets);
}
std::vector<std::string> missingTargets;
// Create all the imported targets.
- for (std::vector<cmGeneratorTarget*>::const_iterator tei =
- this->Exports.begin();
- tei != this->Exports.end(); ++tei) {
- cmGeneratorTarget* gte = *tei;
- this->GenerateImportTargetCode(os, gte);
+ for (cmGeneratorTarget* gte : this->Exports) {
+ this->GenerateImportTargetCode(os, gte, this->GetExportTargetType(gte));
gte->Target->AppendBuildInterfaceIncludes();
@@ -93,14 +92,35 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", gte,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_PRECOMPILE_HEADERS", gte,
+ cmGeneratorExpression::BuildInterface,
+ properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gte,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gte,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_LINK_OPTIONS", gte,
+ cmGeneratorExpression::BuildInterface,
+ properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_LINK_DIRECTORIES", gte,
+ cmGeneratorExpression::BuildInterface,
+ properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_LINK_DEPENDS", gte,
+ cmGeneratorExpression::BuildInterface,
+ properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", gte,
properties);
+
+ std::string errorMessage;
+ if (!this->PopulateExportProperties(gte, properties, errorMessage)) {
+ this->LG->GetGlobalGenerator()->GetCMakeInstance()->IssueMessage(
+ MessageType::FATAL_ERROR, errorMessage,
+ this->LG->GetMakefile()->GetBacktrace());
+ return false;
+ }
+
const bool newCMP0022Behavior =
gte->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
gte->GetPolicyStatusCMP0022() != cmPolicies::OLD;
@@ -115,10 +135,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
}
// Generate import file content for each configuration.
- for (std::vector<std::string>::const_iterator ci =
- this->Configurations.begin();
- ci != this->Configurations.end(); ++ci) {
- this->GenerateImportConfig(os, *ci, missingTargets);
+ for (std::string const& c : this->Configurations) {
+ this->GenerateImportConfig(os, c, missingTargets);
}
this->GenerateMissingTargetsCheckCode(os, missingTargets);
@@ -130,19 +148,17 @@ void cmExportBuildFileGenerator::GenerateImportTargetsConfig(
std::ostream& os, const std::string& config, std::string const& suffix,
std::vector<std::string>& missingTargets)
{
- for (std::vector<cmGeneratorTarget*>::const_iterator tei =
- this->Exports.begin();
- tei != this->Exports.end(); ++tei) {
+ for (cmGeneratorTarget* target : this->Exports) {
// Collect import properties for this target.
- cmGeneratorTarget* target = *tei;
ImportPropertyMap properties;
- if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ if (this->GetExportTargetType(target) != cmStateEnums::INTERFACE_LIBRARY) {
this->SetImportLocationProperty(config, suffix, target, properties);
}
if (!properties.empty()) {
// Get the rest of the target details.
- if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ if (this->GetExportTargetType(target) !=
+ cmStateEnums::INTERFACE_LIBRARY) {
this->SetImportDetailProperties(config, suffix, target, properties,
missingTargets);
this->SetImportLinkInterface(config, suffix,
@@ -150,7 +166,7 @@ void cmExportBuildFileGenerator::GenerateImportTargetsConfig(
target, properties, missingTargets);
}
- // TOOD: PUBLIC_HEADER_LOCATION
+ // TODO: PUBLIC_HEADER_LOCATION
// This should wait until the build feature propagation stuff
// is done. Then this can be a propagated include directory.
// this->GenerateImportProperty(config, te->HeaderGenerator,
@@ -162,6 +178,21 @@ void cmExportBuildFileGenerator::GenerateImportTargetsConfig(
}
}
+cmStateEnums::TargetType cmExportBuildFileGenerator::GetExportTargetType(
+ cmGeneratorTarget const* target) const
+{
+ cmStateEnums::TargetType targetType = target->GetType();
+ // An object library exports as an interface library if we cannot
+ // tell clients where to find the objects. This is sufficient
+ // to support transitive usage requirements on other targets that
+ // use the object library.
+ if (targetType == cmStateEnums::OBJECT_LIBRARY &&
+ !this->LG->GetGlobalGenerator()->HasKnownObjectFileLocation(nullptr)) {
+ targetType = cmStateEnums::INTERFACE_LIBRARY;
+ }
+ return targetType;
+}
+
void cmExportBuildFileGenerator::SetExportSet(cmExportSet* exportSet)
{
this->ExportSet = exportSet;
@@ -175,8 +206,7 @@ void cmExportBuildFileGenerator::SetImportLocationProperty(
cmMakefile* mf = target->Makefile;
if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
- std::string prop = "IMPORTED_OBJECTS";
- prop += suffix;
+ std::string prop = cmStrCat("IMPORTED_OBJECTS", suffix);
// Compute all the object files inside this target and setup
// IMPORTED_OBJECTS as a list of object files
@@ -184,10 +214,8 @@ void cmExportBuildFileGenerator::SetImportLocationProperty(
target->GetObjectSources(objectSources, config);
std::string const obj_dir = target->GetObjectDirectory(config);
std::vector<std::string> objects;
- for (std::vector<cmSourceFile const*>::const_iterator si =
- objectSources.begin();
- si != objectSources.end(); ++si) {
- const std::string& obj = target->GetObjectName(*si);
+ for (cmSourceFile const* sf : objectSources) {
+ const std::string& obj = target->GetObjectName(sf);
objects.push_back(obj_dir + obj);
}
@@ -196,8 +224,7 @@ void cmExportBuildFileGenerator::SetImportLocationProperty(
} else {
// Add the main target file.
{
- std::string prop = "IMPORTED_LOCATION";
- prop += suffix;
+ std::string prop = cmStrCat("IMPORTED_LOCATION", suffix);
std::string value;
if (target->IsAppBundleOnApple()) {
value =
@@ -210,13 +237,14 @@ void cmExportBuildFileGenerator::SetImportLocationProperty(
}
// Add the import library for windows DLLs.
- if (target->HasImportLibrary() &&
- mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) {
- std::string prop = "IMPORTED_IMPLIB";
- prop += suffix;
+ if (target->HasImportLibrary(config)) {
+ std::string prop = cmStrCat("IMPORTED_IMPLIB", suffix);
std::string value =
target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact);
- target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
+ if (mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) {
+ target->GetImplibGNUtoMS(config, value, value,
+ "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
+ }
properties[prop] = value;
}
}
@@ -231,20 +259,20 @@ void cmExportBuildFileGenerator::HandleMissingTarget(
const std::string name = dependee->GetName();
cmGlobalGenerator* gg =
dependee->GetLocalGenerator()->GetGlobalGenerator();
- std::vector<std::string> namespaces = this->FindNamespaces(gg, name);
+ auto exportInfo = this->FindBuildExportInfo(gg, name);
+ std::vector<std::string> const& exportFiles = exportInfo.first;
- int targetOccurrences = (int)namespaces.size();
- if (targetOccurrences == 1) {
- std::string missingTarget = namespaces[0];
+ if (exportFiles.size() == 1) {
+ std::string missingTarget = exportInfo.second;
missingTarget += dependee->GetExportName();
link_libs += missingTarget;
- missingTargets.push_back(missingTarget);
+ missingTargets.push_back(std::move(missingTarget));
return;
}
// We are not appending, so all exported targets should be
// known here. This is probably user-error.
- this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
+ this->ComplainAboutMissingTarget(depender, dependee, exportFiles);
}
// Assume the target will be exported by another command.
// Append it with the export namespace.
@@ -256,59 +284,59 @@ void cmExportBuildFileGenerator::GetTargets(
std::vector<std::string>& targets) const
{
if (this->ExportSet) {
- for (std::vector<cmTargetExport*>::const_iterator tei =
- this->ExportSet->GetTargetExports()->begin();
- tei != this->ExportSet->GetTargetExports()->end(); ++tei) {
- targets.push_back((*tei)->TargetName);
+ for (std::unique_ptr<cmTargetExport> const& te :
+ this->ExportSet->GetTargetExports()) {
+ targets.push_back(te->TargetName);
}
return;
}
targets = this->Targets;
}
-std::vector<std::string> cmExportBuildFileGenerator::FindNamespaces(
- cmGlobalGenerator* gg, const std::string& name)
+std::pair<std::vector<std::string>, std::string>
+cmExportBuildFileGenerator::FindBuildExportInfo(cmGlobalGenerator* gg,
+ const std::string& name)
{
- std::vector<std::string> namespaces;
+ std::vector<std::string> exportFiles;
+ std::string ns;
std::map<std::string, cmExportBuildFileGenerator*>& exportSets =
gg->GetBuildExportSets();
- for (std::map<std::string, cmExportBuildFileGenerator*>::const_iterator
- expIt = exportSets.begin();
- expIt != exportSets.end(); ++expIt) {
- const cmExportBuildFileGenerator* exportSet = expIt->second;
+ for (auto const& exp : exportSets) {
+ const cmExportBuildFileGenerator* exportSet = exp.second;
std::vector<std::string> targets;
exportSet->GetTargets(targets);
- if (std::find(targets.begin(), targets.end(), name) != targets.end()) {
- namespaces.push_back(exportSet->GetNamespace());
+ if (cmContains(targets, name)) {
+ exportFiles.push_back(exp.first);
+ ns = exportSet->GetNamespace();
}
}
- return namespaces;
+ return { exportFiles, ns };
}
void cmExportBuildFileGenerator::ComplainAboutMissingTarget(
- cmGeneratorTarget* depender, cmGeneratorTarget* dependee, int occurrences)
+ cmGeneratorTarget* depender, cmGeneratorTarget* dependee,
+ std::vector<std::string> const& exportFiles)
{
- if (cmSystemTools::GetErrorOccuredFlag()) {
- return;
- }
-
std::ostringstream e;
e << "export called with target \"" << depender->GetName()
<< "\" which requires target \"" << dependee->GetName() << "\" ";
- if (occurrences == 0) {
- e << "that is not in the export set.\n";
+ if (exportFiles.empty()) {
+ e << "that is not in any export set.";
} else {
- e << "that is not in this export set, but " << occurrences
- << " times in others.\n";
+ e << "that is not in this export set, but in multiple other export sets: "
+ << cmJoin(exportFiles, ", ") << ".\n";
+ e << "An exported target cannot depend upon another target which is "
+ "exported multiple times. Consider consolidating the exports of the "
+ "\""
+ << dependee->GetName() << "\" target to a single export.";
}
- e << "If the required target is not easy to reference in this call, "
- << "consider using the APPEND option with multiple separate calls.";
this->LG->GetGlobalGenerator()->GetCMakeInstance()->IssueMessage(
- cmake::FATAL_ERROR, e.str(), this->LG->GetMakefile()->GetBacktrace());
+ MessageType::FATAL_ERROR, e.str(),
+ this->LG->GetMakefile()->GetBacktrace());
}
std::string cmExportBuildFileGenerator::InstallNameDir(
diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h
index 0556983ac..11fbd02d6 100644
--- a/Source/cmExportBuildFileGenerator.h
+++ b/Source/cmExportBuildFileGenerator.h
@@ -3,14 +3,17 @@
#ifndef cmExportBuildFileGenerator_h
#define cmExportBuildFileGenerator_h
-#include "cmConfigure.h"
-
-#include "cmExportFileGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
+#include <utility>
#include <vector>
+#include "cmAlgorithms.h"
+#include "cmExportFileGenerator.h"
+#include "cmStateTypes.h"
+
class cmExportSet;
class cmGeneratorTarget;
class cmGlobalGenerator;
@@ -38,7 +41,7 @@ public:
void GetTargets(std::vector<std::string>& targets) const;
void AppendTargets(std::vector<std::string> const& targets)
{
- this->Targets.insert(this->Targets.end(), targets.begin(), targets.end());
+ cmAppend(this->Targets, targets);
}
void SetExportSet(cmExportSet*);
@@ -49,18 +52,20 @@ public:
protected:
// Implement virtual methods from the superclass.
- bool GenerateMainFile(std::ostream& os) CM_OVERRIDE;
+ bool GenerateMainFile(std::ostream& os) override;
void GenerateImportTargetsConfig(
std::ostream& os, const std::string& config, std::string const& suffix,
- std::vector<std::string>& missingTargets) CM_OVERRIDE;
+ std::vector<std::string>& missingTargets) override;
+ cmStateEnums::TargetType GetExportTargetType(
+ cmGeneratorTarget const* target) const;
void HandleMissingTarget(std::string& link_libs,
std::vector<std::string>& missingTargets,
cmGeneratorTarget* depender,
- cmGeneratorTarget* dependee) CM_OVERRIDE;
+ cmGeneratorTarget* dependee) override;
void ComplainAboutMissingTarget(cmGeneratorTarget* depender,
cmGeneratorTarget* dependee,
- int occurrences);
+ std::vector<std::string> const& namespaces);
/** Fill in properties indicating built file locations. */
void SetImportLocationProperty(const std::string& config,
@@ -69,10 +74,10 @@ protected:
ImportPropertyMap& properties);
std::string InstallNameDir(cmGeneratorTarget* target,
- const std::string& config) CM_OVERRIDE;
+ const std::string& config) override;
- std::vector<std::string> FindNamespaces(cmGlobalGenerator* gg,
- const std::string& name);
+ std::pair<std::vector<std::string>, std::string> FindBuildExportInfo(
+ cmGlobalGenerator* gg, const std::string& name);
std::vector<std::string> Targets;
cmExportSet* ExportSet;
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index 38cd511ea..2a6bf5df7 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -2,178 +2,174 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportCommand.h"
-#include "cmsys/RegularExpression.hxx"
#include <map>
#include <sstream>
+#include <utility>
+
+#include "cmsys/RegularExpression.hxx"
+#include "cm_static_string_view.hxx"
+
+#include "cmAlgorithms.h"
+#include "cmArgumentParser.h"
+#include "cmExecutionStatus.h"
#include "cmExportBuildAndroidMKGenerator.h"
#include "cmExportBuildFileGenerator.h"
-#include "cmExportSetMap.h"
+#include "cmExportSet.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmPolicies.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cmake.h"
-
-class cmExecutionStatus;
#if defined(__HAIKU__)
-#include <FindDirectory.h>
-#include <StorageDefs.h>
+# include <FindDirectory.h>
+# include <StorageDefs.h>
#endif
-cmExportCommand::cmExportCommand()
- : cmCommand()
- , ArgumentGroup()
- , Targets(&Helper, "TARGETS")
- , Append(&Helper, "APPEND", &ArgumentGroup)
- , ExportSetName(&Helper, "EXPORT", &ArgumentGroup)
- , Namespace(&Helper, "NAMESPACE", &ArgumentGroup)
- , Filename(&Helper, "FILE", &ArgumentGroup)
- , ExportOld(&Helper, "EXPORT_LINK_INTERFACE_LIBRARIES", &ArgumentGroup)
- , AndroidMKFile(&Helper, "ANDROID_MK")
-{
- this->ExportSet = CM_NULLPTR;
-}
+#if defined(_WIN32) && !defined(__CYGWIN__)
+# include <windows.h>
+#endif
+
+static bool HandlePackage(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
-// cmExportCommand
-bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+static void StorePackageRegistry(cmMakefile& mf, std::string const& package,
+ const char* content, const char* hash);
+
+bool cmExportCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with too few arguments");
+ status.SetError("called with too few arguments");
return false;
}
if (args[0] == "PACKAGE") {
- return this->HandlePackage(args);
+ return HandlePackage(args, status);
}
+
+ struct Arguments
+ {
+ std::string ExportSetName;
+ std::vector<std::string> Targets;
+ std::string Namespace;
+ std::string Filename;
+ std::string AndroidMKFile;
+ bool Append = false;
+ bool ExportOld = false;
+ };
+
+ auto parser = cmArgumentParser<Arguments>{}
+ .Bind("NAMESPACE"_s, &Arguments::Namespace)
+ .Bind("FILE"_s, &Arguments::Filename);
+
if (args[0] == "EXPORT") {
- this->ExportSetName.Follows(CM_NULLPTR);
- this->ArgumentGroup.Follows(&this->ExportSetName);
+ parser.Bind("EXPORT"_s, &Arguments::ExportSetName);
} else {
- this->Targets.Follows(CM_NULLPTR);
- this->ArgumentGroup.Follows(&this->Targets);
+ parser.Bind("TARGETS"_s, &Arguments::Targets);
+ parser.Bind("ANDROID_MK"_s, &Arguments::AndroidMKFile);
+ parser.Bind("APPEND"_s, &Arguments::Append);
+ parser.Bind("EXPORT_LINK_INTERFACE_LIBRARIES"_s, &Arguments::ExportOld);
}
std::vector<std::string> unknownArgs;
- this->Helper.Parse(&args, &unknownArgs);
+ std::vector<std::string> keywordsMissingValue;
+ Arguments const arguments =
+ parser.Parse(args, &unknownArgs, &keywordsMissingValue);
if (!unknownArgs.empty()) {
- this->SetError("Unknown arguments.");
+ status.SetError("Unknown argument: \"" + unknownArgs.front() + "\".");
return false;
}
std::string fname;
bool android = false;
- if (this->AndroidMKFile.WasFound()) {
- fname = this->AndroidMKFile.GetString();
+ if (!arguments.AndroidMKFile.empty()) {
+ fname = arguments.AndroidMKFile;
android = true;
}
- if (!this->Filename.WasFound() && fname.empty()) {
+ if (arguments.Filename.empty() && fname.empty()) {
if (args[0] != "EXPORT") {
- this->SetError("FILE <filename> option missing.");
+ status.SetError("FILE <filename> option missing.");
return false;
}
- fname = this->ExportSetName.GetString() + ".cmake";
+ fname = arguments.ExportSetName + ".cmake";
} else if (fname.empty()) {
// Make sure the file has a .cmake extension.
- if (cmSystemTools::GetFilenameLastExtension(this->Filename.GetCString()) !=
+ if (cmSystemTools::GetFilenameLastExtension(arguments.Filename) !=
".cmake") {
std::ostringstream e;
- e << "FILE option given filename \"" << this->Filename.GetString()
+ e << "FILE option given filename \"" << arguments.Filename
<< "\" which does not have an extension of \".cmake\".\n";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
- fname = this->Filename.GetString();
+ fname = arguments.Filename;
}
+ cmMakefile& mf = status.GetMakefile();
+
// Get the file to write.
- if (cmSystemTools::FileIsFullPath(fname.c_str())) {
- if (!this->Makefile->CanIWriteThisFile(fname.c_str())) {
+ if (cmSystemTools::FileIsFullPath(fname)) {
+ if (!mf.CanIWriteThisFile(fname)) {
std::ostringstream e;
e << "FILE option given filename \"" << fname
<< "\" which is in the source tree.\n";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
} else {
// Interpret relative paths with respect to the current build dir.
- std::string dir = this->Makefile->GetCurrentBinaryDirectory();
+ std::string const& dir = mf.GetCurrentBinaryDirectory();
fname = dir + "/" + fname;
}
std::vector<std::string> targets;
- cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
+ cmGlobalGenerator* gg = mf.GetGlobalGenerator();
+ cmExportSet* exportSet = nullptr;
if (args[0] == "EXPORT") {
- if (this->Append.IsEnabled()) {
- std::ostringstream e;
- e << "EXPORT signature does not recognise the APPEND option.";
- this->SetError(e.str());
- return false;
- }
-
- if (this->ExportOld.IsEnabled()) {
- std::ostringstream e;
- e << "EXPORT signature does not recognise the "
- "EXPORT_LINK_INTERFACE_LIBRARIES option.";
- this->SetError(e.str());
- return false;
- }
-
cmExportSetMap& setMap = gg->GetExportSets();
- std::string setName = this->ExportSetName.GetString();
- if (setMap.find(setName) == setMap.end()) {
+ auto const it = setMap.find(arguments.ExportSetName);
+ if (it == setMap.end()) {
std::ostringstream e;
- e << "Export set \"" << setName << "\" not found.";
- this->SetError(e.str());
+ e << "Export set \"" << arguments.ExportSetName << "\" not found.";
+ status.SetError(e.str());
return false;
}
- this->ExportSet = setMap[setName];
- } else if (this->Targets.WasFound()) {
- for (std::vector<std::string>::const_iterator currentTarget =
- this->Targets.GetVector().begin();
- currentTarget != this->Targets.GetVector().end(); ++currentTarget) {
- if (this->Makefile->IsAlias(*currentTarget)) {
+ exportSet = &it->second;
+ } else if (!arguments.Targets.empty() ||
+ cmContains(keywordsMissingValue, "TARGETS")) {
+ for (std::string const& currentTarget : arguments.Targets) {
+ if (mf.IsAlias(currentTarget)) {
std::ostringstream e;
- e << "given ALIAS target \"" << *currentTarget
+ e << "given ALIAS target \"" << currentTarget
<< "\" which may not be exported.";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
- if (cmTarget* target = gg->FindTarget(*currentTarget)) {
- if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
- std::string reason;
- if (!this->Makefile->GetGlobalGenerator()
- ->HasKnownObjectFileLocation(&reason)) {
- std::ostringstream e;
- e << "given OBJECT library \"" << *currentTarget
- << "\" which may not be exported" << reason << ".";
- this->SetError(e.str());
- return false;
- }
- }
+ if (cmTarget* target = gg->FindTarget(currentTarget)) {
if (target->GetType() == cmStateEnums::UTILITY) {
- this->SetError("given custom target \"" + *currentTarget +
- "\" which may not be exported.");
+ status.SetError("given custom target \"" + currentTarget +
+ "\" which may not be exported.");
return false;
}
} else {
std::ostringstream e;
- e << "given target \"" << *currentTarget
+ e << "given target \"" << currentTarget
<< "\" which is not built by this project.";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
- targets.push_back(*currentTarget);
+ targets.push_back(currentTarget);
}
- if (this->Append.IsEnabled()) {
+ if (arguments.Append) {
if (cmExportBuildFileGenerator* ebfg =
gg->GetExportedTargetsFile(fname)) {
ebfg->AppendTargets(targets);
@@ -181,40 +177,38 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
}
}
} else {
- this->SetError("EXPORT or TARGETS specifier missing.");
+ status.SetError("EXPORT or TARGETS specifier missing.");
return false;
}
// Setup export file generation.
- cmExportBuildFileGenerator* ebfg = CM_NULLPTR;
+ cmExportBuildFileGenerator* ebfg = nullptr;
if (android) {
ebfg = new cmExportBuildAndroidMKGenerator;
} else {
ebfg = new cmExportBuildFileGenerator;
}
ebfg->SetExportFile(fname.c_str());
- ebfg->SetNamespace(this->Namespace.GetCString());
- ebfg->SetAppendMode(this->Append.IsEnabled());
- if (this->ExportSet) {
- ebfg->SetExportSet(this->ExportSet);
+ ebfg->SetNamespace(arguments.Namespace);
+ ebfg->SetAppendMode(arguments.Append);
+ if (exportSet != nullptr) {
+ ebfg->SetExportSet(exportSet);
} else {
ebfg->SetTargets(targets);
}
- this->Makefile->AddExportBuildFileGenerator(ebfg);
- ebfg->SetExportOld(this->ExportOld.IsEnabled());
+ mf.AddExportBuildFileGenerator(ebfg);
+ ebfg->SetExportOld(arguments.ExportOld);
// Compute the set of configurations exported.
std::vector<std::string> configurationTypes;
- this->Makefile->GetConfigurations(configurationTypes);
+ mf.GetConfigurations(configurationTypes);
if (configurationTypes.empty()) {
- configurationTypes.push_back("");
+ configurationTypes.emplace_back();
}
- for (std::vector<std::string>::const_iterator ci =
- configurationTypes.begin();
- ci != configurationTypes.end(); ++ci) {
- ebfg->AddConfiguration(*ci);
+ for (std::string const& ct : configurationTypes) {
+ ebfg->AddConfiguration(ct);
}
- if (this->ExportSet) {
+ if (exportSet != nullptr) {
gg->AddBuildExportExportSet(ebfg);
} else {
gg->AddBuildExportSet(ebfg);
@@ -223,7 +217,8 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
return true;
}
-bool cmExportCommand::HandlePackage(std::vector<std::string> const& args)
+static bool HandlePackage(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// Parse PACKAGE mode arguments.
enum Doing
@@ -240,51 +235,61 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args)
} else {
std::ostringstream e;
e << "PACKAGE given unknown argument: " << args[i];
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
}
// Verify the package name.
if (package.empty()) {
- this->SetError("PACKAGE must be given a package name.");
+ status.SetError("PACKAGE must be given a package name.");
return false;
}
const char* packageExpr = "^[A-Za-z0-9_.-]+$";
cmsys::RegularExpression packageRegex(packageExpr);
- if (!packageRegex.find(package.c_str())) {
+ if (!packageRegex.find(package)) {
std::ostringstream e;
e << "PACKAGE given invalid package name \"" << package << "\". "
<< "Package names must match \"" << packageExpr << "\".";
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
- // If the CMAKE_EXPORT_NO_PACKAGE_REGISTRY variable is set the command
- // export(PACKAGE) does nothing.
- if (this->Makefile->IsOn("CMAKE_EXPORT_NO_PACKAGE_REGISTRY")) {
- return true;
+ cmMakefile& mf = status.GetMakefile();
+
+ // CMP0090 decides both the default and what variable changes it.
+ switch (mf.GetPolicyStatus(cmPolicies::CMP0090)) {
+ case cmPolicies::WARN:
+ case cmPolicies::OLD:
+ // Default is to export, but can be disabled.
+ if (mf.IsOn("CMAKE_EXPORT_NO_PACKAGE_REGISTRY")) {
+ return true;
+ }
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ // Default is to not export, but can be enabled.
+ if (!mf.IsOn("CMAKE_EXPORT_PACKAGE_REGISTRY")) {
+ return true;
+ }
+ break;
}
// We store the current build directory in the registry as a value
// named by a hash of its own content. This is deterministic and is
// unique with high probability.
- const char* outDir = this->Makefile->GetCurrentBinaryDirectory();
+ const std::string& outDir = mf.GetCurrentBinaryDirectory();
std::string hash = cmSystemTools::ComputeStringMD5(outDir);
-#if defined(_WIN32) && !defined(__CYGWIN__)
- this->StorePackageRegistryWin(package, outDir, hash.c_str());
-#else
- this->StorePackageRegistryDir(package, outDir, hash.c_str());
-#endif
+ StorePackageRegistry(mf, package, outDir.c_str(), hash.c_str());
return true;
}
#if defined(_WIN32) && !defined(__CYGWIN__)
-#include <windows.h>
-void cmExportCommand::ReportRegistryError(std::string const& msg,
- std::string const& key, long err)
+static void ReportRegistryError(cmMakefile& mf, std::string const& msg,
+ std::string const& key, long err)
{
std::ostringstream e;
e << msg << "\n"
@@ -296,21 +301,19 @@ void cmExportCommand::ReportRegistryError(std::string const& msg,
e << "Windows reported:\n"
<< " " << cmsys::Encoding::ToNarrow(winmsg);
}
- this->Makefile->IssueMessage(cmake::WARNING, e.str());
+ mf.IssueMessage(MessageType::WARNING, e.str());
}
-void cmExportCommand::StorePackageRegistryWin(std::string const& package,
- const char* content,
- const char* hash)
+static void StorePackageRegistry(cmMakefile& mf, std::string const& package,
+ const char* content, const char* hash)
{
- std::string key = "Software\\Kitware\\CMake\\Packages\\";
- key += package;
+ std::string key = cmStrCat("Software\\Kitware\\CMake\\Packages\\", package);
HKEY hKey;
LONG err =
RegCreateKeyExW(HKEY_CURRENT_USER, cmsys::Encoding::ToWide(key).c_str(), 0,
0, REG_OPTION_NON_VOLATILE, KEY_SET_VALUE, 0, &hKey, 0);
if (err != ERROR_SUCCESS) {
- this->ReportRegistryError("Cannot create/open registry key", key, err);
+ ReportRegistryError(mf, "Cannot create/open registry key", key, err);
return;
}
@@ -323,25 +326,22 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package,
if (err != ERROR_SUCCESS) {
std::ostringstream msg;
msg << "Cannot set registry value \"" << hash << "\" under key";
- this->ReportRegistryError(msg.str(), key, err);
+ ReportRegistryError(mf, msg.str(), key, err);
return;
}
}
#else
-void cmExportCommand::StorePackageRegistryDir(std::string const& package,
- const char* content,
- const char* hash)
+static void StorePackageRegistry(cmMakefile& mf, std::string const& package,
+ const char* content, const char* hash)
{
-#if defined(__HAIKU__)
+# if defined(__HAIKU__)
char dir[B_PATH_NAME_LENGTH];
if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, dir, sizeof(dir)) !=
B_OK) {
return;
}
- std::string fname = dir;
- fname += "/cmake/packages/";
- fname += package;
-#else
+ std::string fname = cmStrCat(dir, "/cmake/packages/", package);
+# else
std::string fname;
if (!cmSystemTools::GetEnv("HOME", fname)) {
return;
@@ -349,12 +349,12 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package,
cmSystemTools::ConvertToUnixSlashes(fname);
fname += "/.cmake/packages/";
fname += package;
-#endif
- cmSystemTools::MakeDirectory(fname.c_str());
+# endif
+ cmSystemTools::MakeDirectory(fname);
fname += "/";
fname += hash;
- if (!cmSystemTools::FileExists(fname.c_str())) {
- cmGeneratedFileStream entry(fname.c_str(), true);
+ if (!cmSystemTools::FileExists(fname)) {
+ cmGeneratedFileStream entry(fname, true);
if (entry) {
entry << content << "\n";
} else {
@@ -364,7 +364,7 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package,
<< " " << fname << "\n"
<< cmSystemTools::GetLastSystemError() << "\n";
/* clang-format on */
- this->Makefile->IssueMessage(cmake::WARNING, e.str());
+ mf.IssueMessage(MessageType::WARNING, e.str());
}
}
}
diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h
index c47bc42b9..965562820 100644
--- a/Source/cmExportCommand.h
+++ b/Source/cmExportCommand.h
@@ -3,62 +3,14 @@
#ifndef cmExportCommand_h
#define cmExportCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-#include "cmCommandArgumentsHelper.h"
-
class cmExecutionStatus;
-class cmExportSet;
-
-/** \class cmExportLibraryDependenciesCommand
- * \brief Add a test to the lists of tests to run.
- *
- * cmExportLibraryDependenciesCommand adds a test to the list of tests to run
- *
- */
-class cmExportCommand : public cmCommand
-{
-public:
- cmExportCommand();
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmExportCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- cmCommandArgumentsHelper Helper;
- cmCommandArgumentGroup ArgumentGroup;
- cmCAStringVector Targets;
- cmCAEnabler Append;
- cmCAString ExportSetName;
- cmCAString Namespace;
- cmCAString Filename;
- cmCAEnabler ExportOld;
- cmCAString AndroidMKFile;
-
- cmExportSet* ExportSet;
-
- friend class cmExportBuildFileGenerator;
- std::string ErrorMessage;
- bool HandlePackage(std::vector<std::string> const& args);
- void StorePackageRegistryWin(std::string const& package, const char* content,
- const char* hash);
- void StorePackageRegistryDir(std::string const& package, const char* content,
- const char* hash);
- void ReportRegistryError(std::string const& msg, std::string const& key,
- long err);
-};
+bool cmExportCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 972f4b9d1..aeef602bf 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -2,27 +2,30 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportFileGenerator.h"
-#include "cmAlgorithms.h"
+#include <cassert>
+#include <cstring>
+#include <sstream>
+#include <utility>
+
+#include <cm/memory>
+
+#include "cmsys/FStream.hxx"
+
#include "cmComputeLinkInformation.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmLinkItem.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmOutputConverter.h"
#include "cmPolicies.h"
+#include "cmPropertyMap.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetExport.h"
-#include "cmake.h"
-
-#include "cm_auto_ptr.hxx"
-#include "cmsys/FStream.hxx"
-#include <assert.h>
-#include <sstream>
-#include <string.h>
-#include <utility>
static std::string cmExportFileGeneratorEscape(std::string const& str)
{
@@ -65,24 +68,24 @@ const char* cmExportFileGenerator::GetMainExportFileName() const
bool cmExportFileGenerator::GenerateImportFile()
{
// Open the output file to generate it.
- CM_AUTO_PTR<cmsys::ofstream> foutPtr;
+ std::unique_ptr<cmsys::ofstream> foutPtr;
if (this->AppendMode) {
// Open for append.
- CM_AUTO_PTR<cmsys::ofstream> ap(
- new cmsys::ofstream(this->MainImportFile.c_str(), std::ios::app));
- foutPtr = ap;
+ auto openmodeApp = std::ios::app;
+ foutPtr = cm::make_unique<cmsys::ofstream>(this->MainImportFile.c_str(),
+ openmodeApp);
} else {
// Generate atomically and with copy-if-different.
- CM_AUTO_PTR<cmGeneratedFileStream> ap(
- new cmGeneratedFileStream(this->MainImportFile.c_str(), true));
+ std::unique_ptr<cmGeneratedFileStream> ap(
+ new cmGeneratedFileStream(this->MainImportFile, true));
ap->SetCopyIfDifferent(true);
- foutPtr = ap;
+ foutPtr = std::move(ap);
}
- if (!foutPtr.get() || !*foutPtr) {
+ if (!foutPtr || !*foutPtr) {
std::string se = cmSystemTools::GetLastSystemError();
std::ostringstream e;
e << "cannot write to file \"" << this->MainImportFile << "\": " << se;
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
}
std::ostream& os = *foutPtr;
@@ -137,7 +140,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(
if (input) {
if (!*input) {
// Set to empty
- properties[outputName] = "";
+ properties[outputName].clear();
return;
}
@@ -184,7 +187,7 @@ bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty(
return false;
}
-static bool isSubDirectory(const char* a, const char* b)
+static bool isSubDirectory(std::string const& a, std::string const& b)
{
return (cmSystemTools::ComparePath(a, b) ||
cmSystemTools::IsSubDirectory(a, b));
@@ -194,31 +197,35 @@ static bool checkInterfaceDirs(const std::string& prepro,
cmGeneratorTarget* target,
const std::string& prop)
{
- const char* installDir =
+ std::string const& installDir =
target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
- const char* topSourceDir = target->GetLocalGenerator()->GetSourceDirectory();
- const char* topBinaryDir = target->GetLocalGenerator()->GetBinaryDirectory();
+ std::string const& topSourceDir =
+ target->GetLocalGenerator()->GetSourceDirectory();
+ std::string const& topBinaryDir =
+ target->GetLocalGenerator()->GetBinaryDirectory();
std::vector<std::string> parts;
cmGeneratorExpression::Split(prepro, parts);
- const bool inSourceBuild = strcmp(topSourceDir, topBinaryDir) == 0;
+ const bool inSourceBuild = topSourceDir == topBinaryDir;
bool hadFatalError = false;
- for (std::vector<std::string>::iterator li = parts.begin();
- li != parts.end(); ++li) {
- size_t genexPos = cmGeneratorExpression::Find(*li);
+ for (std::string const& li : parts) {
+ size_t genexPos = cmGeneratorExpression::Find(li);
if (genexPos == 0) {
continue;
}
- cmake::MessageType messageType = cmake::FATAL_ERROR;
+ if (cmHasLiteralPrefix(li, "${_IMPORT_PREFIX}")) {
+ continue;
+ }
+ MessageType messageType = MessageType::FATAL_ERROR;
std::ostringstream e;
if (genexPos != std::string::npos) {
if (prop == "INTERFACE_INCLUDE_DIRECTORIES") {
switch (target->GetPolicyStatusCMP0041()) {
case cmPolicies::WARN:
- messageType = cmake::WARNING;
+ messageType = MessageType::WARNING;
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0041) << "\n";
break;
case cmPolicies::OLD:
@@ -233,20 +240,17 @@ static bool checkInterfaceDirs(const std::string& prepro,
hadFatalError = true;
}
}
- if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}")) {
- continue;
- }
- if (!cmSystemTools::FileIsFullPath(li->c_str())) {
+ if (!cmSystemTools::FileIsFullPath(li)) {
/* clang-format off */
e << "Target \"" << target->GetName() << "\" " << prop <<
" property contains relative path:\n"
- " \"" << *li << "\"";
+ " \"" << li << "\"";
/* clang-format on */
target->GetLocalGenerator()->IssueMessage(messageType, e.str());
}
- bool inBinary = isSubDirectory(li->c_str(), topBinaryDir);
- bool inSource = isSubDirectory(li->c_str(), topSourceDir);
- if (isSubDirectory(li->c_str(), installDir)) {
+ bool inBinary = isSubDirectory(li, topBinaryDir);
+ bool inSource = isSubDirectory(li, topSourceDir);
+ if (isSubDirectory(li, installDir)) {
// The include directory is inside the install tree. If the
// install tree is not inside the source tree or build tree then
// fall through to the checks below that the include directory is not
@@ -261,18 +265,20 @@ static bool checkInterfaceDirs(const std::string& prepro,
case cmPolicies::WARN: {
std::ostringstream s;
s << cmPolicies::GetPolicyWarning(cmPolicies::CMP0052) << "\n";
- s << "Directory:\n \"" << *li
+ s << "Directory:\n \"" << li
<< "\"\nin "
"INTERFACE_INCLUDE_DIRECTORIES of target \""
- << target->GetName() << "\" is a subdirectory of the install "
- "directory:\n \""
- << installDir << "\"\nhowever it is also "
- "a subdirectory of the "
+ << target->GetName()
+ << "\" is a subdirectory of the install "
+ "directory:\n \""
+ << installDir
+ << "\"\nhowever it is also "
+ "a subdirectory of the "
<< (inBinary ? "build" : "source") << " tree:\n \""
<< (inBinary ? topBinaryDir : topSourceDir) << "\""
<< std::endl;
- target->GetLocalGenerator()->IssueMessage(cmake::AUTHOR_WARNING,
- s.str());
+ target->GetLocalGenerator()->IssueMessage(
+ MessageType::AUTHOR_WARNING, s.str());
CM_FALLTHROUGH;
}
case cmPolicies::OLD:
@@ -293,7 +299,7 @@ static bool checkInterfaceDirs(const std::string& prepro,
/* clang-format off */
e << "Target \"" << target->GetName() << "\" " << prop <<
" property contains path:\n"
- " \"" << *li << "\"\nwhich is prefixed in the build directory.";
+ " \"" << li << "\"\nwhich is prefixed in the build directory.";
/* clang-format on */
target->GetLocalGenerator()->IssueMessage(messageType, e.str());
}
@@ -302,7 +308,7 @@ static bool checkInterfaceDirs(const std::string& prepro,
e << "Target \"" << target->GetName() << "\" " << prop
<< " property contains path:\n"
" \""
- << *li << "\"\nwhich is prefixed in the source directory.";
+ << li << "\"\nwhich is prefixed in the source directory.";
target->GetLocalGenerator()->IssueMessage(messageType, e.str());
}
}
@@ -314,17 +320,16 @@ static void prefixItems(std::string& exportDirs)
{
std::vector<std::string> entries;
cmGeneratorExpression::Split(exportDirs, entries);
- exportDirs = "";
+ exportDirs.clear();
const char* sep = "";
- for (std::vector<std::string>::const_iterator ei = entries.begin();
- ei != entries.end(); ++ei) {
+ for (std::string const& e : entries) {
exportDirs += sep;
sep = ";";
- if (!cmSystemTools::FileIsFullPath(ei->c_str()) &&
- ei->find("${_IMPORT_PREFIX}") == std::string::npos) {
+ if (!cmSystemTools::FileIsFullPath(e) &&
+ e.find("${_IMPORT_PREFIX}") == std::string::npos) {
exportDirs += "${_IMPORT_PREFIX}/";
}
- exportDirs += *ei;
+ exportDirs += e;
}
}
@@ -343,7 +348,7 @@ void cmExportFileGenerator::PopulateSourcesInterface(
}
if (!*input) {
- properties[propName] = "";
+ properties[propName].clear();
return;
}
@@ -374,9 +379,9 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
std::string dirs = cmGeneratorExpression::Preprocess(
tei->InterfaceIncludeDirectories, preprocessRule, true);
this->ReplaceInstallPrefix(dirs);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
std::string exportDirs =
- cge->Evaluate(target->GetLocalGenerator(), "", false, target);
+ cge->Evaluate(target->GetLocalGenerator(), "", target);
if (cge->GetHadContextSensitiveCondition()) {
cmLocalGenerator* lg = target->GetLocalGenerator();
@@ -387,7 +392,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
"depend on the configuration, policy values or the link interface "
"are "
"not supported. Consider using target_include_directories instead.";
- lg->IssueMessage(cmake::FATAL_ERROR, e.str());
+ lg->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
@@ -396,7 +401,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
}
if ((input && !*input) && exportDirs.empty()) {
// Set to empty
- properties[propName] = "";
+ properties[propName].clear();
return;
}
@@ -417,6 +422,68 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
}
}
+void cmExportFileGenerator::PopulateLinkDependsInterface(
+ cmTargetExport* tei, cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
+{
+ cmGeneratorTarget* gt = tei->Target;
+ assert(preprocessRule == cmGeneratorExpression::InstallInterface);
+
+ const char* propName = "INTERFACE_LINK_DEPENDS";
+ const char* input = gt->GetProperty(propName);
+
+ if (!input) {
+ return;
+ }
+
+ if (!*input) {
+ properties[propName].clear();
+ return;
+ }
+
+ std::string prepro =
+ cmGeneratorExpression::Preprocess(input, preprocessRule, true);
+ if (!prepro.empty()) {
+ this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets);
+
+ if (!checkInterfaceDirs(prepro, gt, propName)) {
+ return;
+ }
+ properties[propName] = prepro;
+ }
+}
+
+void cmExportFileGenerator::PopulateLinkDirectoriesInterface(
+ cmTargetExport* tei, cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
+{
+ cmGeneratorTarget* gt = tei->Target;
+ assert(preprocessRule == cmGeneratorExpression::InstallInterface);
+
+ const char* propName = "INTERFACE_LINK_DIRECTORIES";
+ const char* input = gt->GetProperty(propName);
+
+ if (!input) {
+ return;
+ }
+
+ if (!*input) {
+ properties[propName].clear();
+ return;
+ }
+
+ std::string prepro =
+ cmGeneratorExpression::Preprocess(input, preprocessRule, true);
+ if (!prepro.empty()) {
+ this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets);
+
+ if (!checkInterfaceDirs(prepro, gt, propName)) {
+ return;
+ }
+ properties[propName] = prepro;
+ }
+}
+
void cmExportFileGenerator::PopulateInterfaceProperty(
const std::string& propName, cmGeneratorTarget* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
@@ -433,8 +500,7 @@ void getPropertyContents(cmGeneratorTarget const* tgt, const std::string& prop,
if (!p) {
return;
}
- std::vector<std::string> content;
- cmSystemTools::ExpandListArgument(p, content);
+ std::vector<std::string> content = cmExpandedList(p);
ifaceProperties.insert(content.begin(), content.end());
}
@@ -455,24 +521,23 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget* target,
e << "Exporting the target \"" << target->GetName()
<< "\" is not "
"allowed since its linker language cannot be determined";
- lg->IssueMessage(cmake::FATAL_ERROR, e.str());
+ lg->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
const cmComputeLinkInformation::ItemVector& deps = info->GetItems();
- for (cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin();
- li != deps.end(); ++li) {
- if (!li->Target) {
+ for (auto const& dep : deps) {
+ if (!dep.Target) {
continue;
}
- getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_BOOL",
+ getPropertyContents(dep.Target, "COMPATIBLE_INTERFACE_BOOL",
ifaceProperties);
- getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_STRING",
+ getPropertyContents(dep.Target, "COMPATIBLE_INTERFACE_STRING",
ifaceProperties);
- getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_NUMBER_MIN",
+ getPropertyContents(dep.Target, "COMPATIBLE_INTERFACE_NUMBER_MIN",
ifaceProperties);
- getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_NUMBER_MAX",
+ getPropertyContents(dep.Target, "COMPATIBLE_INTERFACE_NUMBER_MAX",
ifaceProperties);
}
}
@@ -504,15 +569,13 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
std::vector<std::string> configNames;
gtarget->Target->GetMakefile()->GetConfigurations(configNames);
- for (std::vector<std::string>::const_iterator ci = configNames.begin();
- ci != configNames.end(); ++ci) {
- getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci);
+ for (std::string const& cn : configNames) {
+ getCompatibleInterfaceProperties(gtarget, ifaceProperties, cn);
}
}
- for (std::set<std::string>::const_iterator it = ifaceProperties.begin();
- it != ifaceProperties.end(); ++it) {
- this->PopulateInterfaceProperty("INTERFACE_" + *it, gtarget, properties);
+ for (std::string const& ip : ifaceProperties) {
+ this->PopulateInterfaceProperty("INTERFACE_" + ip, gtarget, properties);
}
}
@@ -521,13 +584,12 @@ void cmExportFileGenerator::GenerateInterfaceProperties(
const ImportPropertyMap& properties)
{
if (!properties.empty()) {
- std::string targetName = this->Namespace;
- targetName += target->GetExportName();
+ std::string targetName =
+ cmStrCat(this->Namespace, target->GetExportName());
os << "set_target_properties(" << targetName << " PROPERTIES\n";
- for (ImportPropertyMap::const_iterator pi = properties.begin();
- pi != properties.end(); ++pi) {
- os << " " << pi->first << " " << cmExportFileGeneratorEscape(pi->second)
- << "\n";
+ for (auto const& property : properties) {
+ os << " " << property.first << " "
+ << cmExportFileGeneratorEscape(property.second) << "\n";
}
os << ")\n\n";
}
@@ -537,14 +599,17 @@ bool cmExportFileGenerator::AddTargetNamespace(
std::string& input, cmGeneratorTarget* target,
std::vector<std::string>& missingTargets)
{
- cmLocalGenerator* lg = target->GetLocalGenerator();
+ cmGeneratorTarget::TargetOrString resolved =
+ target->ResolveTargetReference(input);
- cmGeneratorTarget* tgt = lg->FindGeneratorTargetToUse(input);
+ cmGeneratorTarget* tgt = resolved.Target;
if (!tgt) {
+ input = resolved.String;
return false;
}
if (tgt->IsImported()) {
+ input = tgt->GetName();
return true;
}
if (this->ExportedTargets.find(tgt) != this->ExportedTargets.end()) {
@@ -554,6 +619,8 @@ bool cmExportFileGenerator::AddTargetNamespace(
this->HandleMissingTarget(namespacedTarget, missingTargets, target, tgt);
if (!namespacedTarget.empty()) {
input = namespacedTarget;
+ } else {
+ input = tgt->GetName();
}
}
return true;
@@ -571,15 +638,14 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
cmGeneratorExpression::Split(input, parts);
std::string sep;
- input = "";
- for (std::vector<std::string>::iterator li = parts.begin();
- li != parts.end(); ++li) {
- if (cmGeneratorExpression::Find(*li) == std::string::npos) {
- this->AddTargetNamespace(*li, target, missingTargets);
+ input.clear();
+ for (std::string& li : parts) {
+ if (cmGeneratorExpression::Find(li) == std::string::npos) {
+ this->AddTargetNamespace(li, target, missingTargets);
} else {
- this->ResolveTargetsInGeneratorExpression(*li, target, missingTargets);
+ this->ResolveTargetsInGeneratorExpression(li, target, missingTargets);
}
- input += sep + *li;
+ input += sep + li;
sep = ";";
}
}
@@ -599,7 +665,7 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
std::string::size_type commaPos = input.find(',', nameStartPos);
std::string::size_type nextOpenPos = input.find("$<", nameStartPos);
if (commaPos == std::string::npos // Implied 'this' target
- || closePos == std::string::npos // Imcomplete expression.
+ || closePos == std::string::npos // Incomplete expression.
|| closePos < commaPos // Implied 'this' target
|| nextOpenPos < commaPos) // Non-literal
{
@@ -662,7 +728,8 @@ void cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
this->ReplaceInstallPrefix(input);
if (!errorString.empty()) {
- target->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, errorString);
+ target->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
+ errorString);
}
}
@@ -685,9 +752,9 @@ void cmExportFileGenerator::SetImportLinkInterface(
if (iface->ImplementationIsInterface) {
// Policy CMP0022 must not be NEW.
- this->SetImportLinkProperty(suffix, target,
- "IMPORTED_LINK_INTERFACE_LIBRARIES",
- iface->Libraries, properties, missingTargets);
+ this->SetImportLinkProperty(
+ suffix, target, "IMPORTED_LINK_INTERFACE_LIBRARIES", iface->Libraries,
+ properties, missingTargets, ImportLinkPropertyTargetNames::Yes);
return;
}
@@ -715,12 +782,12 @@ void cmExportFileGenerator::SetImportLinkInterface(
"but also has old-style LINK_INTERFACE_LIBRARIES properties "
"populated, but it was exported without the "
"EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties";
- lg->IssueMessage(cmake::FATAL_ERROR, e.str());
+ lg->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
if (!*propContent) {
- properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = "";
+ properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix].clear();
return;
}
@@ -765,29 +832,56 @@ void cmExportFileGenerator::SetImportDetailProperties(
// Add the transitive link dependencies for this configuration.
if (cmLinkInterface const* iface =
target->GetLinkInterface(config, target)) {
- this->SetImportLinkProperty(suffix, target,
- "IMPORTED_LINK_INTERFACE_LANGUAGES",
- iface->Languages, properties, missingTargets);
+ this->SetImportLinkProperty(
+ suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", iface->Languages,
+ properties, missingTargets, ImportLinkPropertyTargetNames::No);
std::vector<std::string> dummy;
- this->SetImportLinkProperty(suffix, target,
- "IMPORTED_LINK_DEPENDENT_LIBRARIES",
- iface->SharedDeps, properties, dummy);
+ this->SetImportLinkProperty(
+ suffix, target, "IMPORTED_LINK_DEPENDENT_LIBRARIES", iface->SharedDeps,
+ properties, dummy, ImportLinkPropertyTargetNames::Yes);
if (iface->Multiplicity > 0) {
- std::string prop = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
- prop += suffix;
- std::ostringstream m;
- m << iface->Multiplicity;
- properties[prop] = m.str();
+ std::string prop =
+ cmStrCat("IMPORTED_LINK_INTERFACE_MULTIPLICITY", suffix);
+ properties[prop] = std::to_string(iface->Multiplicity);
}
}
+
+ // Add information if this target is a managed target
+ if (target->GetManagedType(config) !=
+ cmGeneratorTarget::ManagedType::Native) {
+ std::string prop = cmStrCat("IMPORTED_COMMON_LANGUAGE_RUNTIME", suffix);
+ std::string propval;
+ if (auto* p = target->GetProperty("COMMON_LANGUAGE_RUNTIME")) {
+ propval = p;
+ } else if (target->IsCSharpOnly()) {
+ // C# projects do not have the /clr flag, so we set the property
+ // here to mark the target as (only) managed (i.e. no .lib file
+ // to link to). Otherwise the COMMON_LANGUAGE_RUNTIME target
+ // property would have to be set manually for C# targets to make
+ // exporting/importing work.
+ propval = "CSharp";
+ }
+ properties[prop] = propval;
+ }
+}
+
+static std::string const& asString(std::string const& l)
+{
+ return l;
+}
+
+static std::string const& asString(cmLinkItem const& l)
+{
+ return l.AsStr();
}
template <typename T>
void cmExportFileGenerator::SetImportLinkProperty(
std::string const& suffix, cmGeneratorTarget* target,
const std::string& propName, std::vector<T> const& entries,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets,
+ ImportLinkPropertyTargetNames targetNames)
{
// Skip the property if there are no entries.
if (entries.empty()) {
@@ -797,20 +891,22 @@ void cmExportFileGenerator::SetImportLinkProperty(
// Construct the property value.
std::string link_entries;
const char* sep = "";
- for (typename std::vector<T>::const_iterator li = entries.begin();
- li != entries.end(); ++li) {
+ for (T const& l : entries) {
// Separate this from the previous entry.
link_entries += sep;
sep = ";";
- std::string temp = *li;
- this->AddTargetNamespace(temp, target, missingTargets);
- link_entries += temp;
+ if (targetNames == ImportLinkPropertyTargetNames::Yes) {
+ std::string temp = asString(l);
+ this->AddTargetNamespace(temp, target, missingTargets);
+ link_entries += temp;
+ } else {
+ link_entries += asString(l);
+ }
}
// Store the property.
- std::string prop = propName;
- prop += suffix;
+ std::string prop = cmStrCat(propName, suffix);
properties[prop] = link_entries;
}
@@ -908,8 +1004,10 @@ void cmExportFileGenerator::GenerateExpectedTargetsCode(
"\n\n";
/* clang-format on */
}
+
void cmExportFileGenerator::GenerateImportTargetCode(
- std::ostream& os, const cmGeneratorTarget* target)
+ std::ostream& os, cmGeneratorTarget const* target,
+ cmStateEnums::TargetType targetType)
{
// Construct the imported target name.
std::string targetName = this->Namespace;
@@ -918,7 +1016,7 @@ void cmExportFileGenerator::GenerateImportTargetCode(
// Create the imported target.
os << "# Create imported target " << targetName << "\n";
- switch (target->GetType()) {
+ switch (targetType) {
case cmStateEnums::EXECUTABLE:
os << "add_executable(" << targetName << " IMPORTED)\n";
break;
@@ -988,10 +1086,9 @@ void cmExportFileGenerator::GenerateImportPropertyCode(
}
os << ")\n";
os << "set_target_properties(" << targetName << " PROPERTIES\n";
- for (ImportPropertyMap::const_iterator pi = properties.begin();
- pi != properties.end(); ++pi) {
- os << " " << pi->first << " " << cmExportFileGeneratorEscape(pi->second)
- << "\n";
+ for (auto const& property : properties) {
+ os << " " << property.first << " "
+ << cmExportFileGeneratorEscape(property.second) << "\n";
}
os << " )\n"
<< "\n";
@@ -1015,9 +1112,9 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(
"foreach(_target ";
/* clang-format on */
std::set<std::string> emitted;
- for (unsigned int i = 0; i < missingTargets.size(); ++i) {
- if (emitted.insert(missingTargets[i]).second) {
- os << "\"" << missingTargets[i] << "\" ";
+ for (std::string const& missingTarget : missingTargets) {
+ if (emitted.insert(missingTarget).second) {
+ os << "\"" << missingTarget << "\" ";
}
}
/* clang-format off */
@@ -1086,17 +1183,15 @@ void cmExportFileGenerator::GenerateImportedFileChecksCode(
const std::set<std::string>& importedLocations)
{
// Construct the imported target name.
- std::string targetName = this->Namespace;
- targetName += target->GetExportName();
+ std::string targetName = cmStrCat(this->Namespace, target->GetExportName());
os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName
<< " )\n"
"list(APPEND _IMPORT_CHECK_FILES_FOR_"
<< targetName << " ";
- for (std::set<std::string>::const_iterator li = importedLocations.begin();
- li != importedLocations.end(); ++li) {
- ImportPropertyMap::const_iterator pi = properties.find(*li);
+ for (std::string const& li : importedLocations) {
+ auto pi = properties.find(li);
if (pi != properties.end()) {
os << cmExportFileGeneratorEscape(pi->second) << " ";
}
@@ -1104,3 +1199,43 @@ void cmExportFileGenerator::GenerateImportedFileChecksCode(
os << ")\n\n";
}
+
+bool cmExportFileGenerator::PopulateExportProperties(
+ cmGeneratorTarget* gte, ImportPropertyMap& properties,
+ std::string& errorMessage)
+{
+ auto& targetProperties = gte->Target->GetProperties();
+ if (const char* exportProperties =
+ targetProperties.GetPropertyValue("EXPORT_PROPERTIES")) {
+ for (auto& prop : cmExpandedList(exportProperties)) {
+ /* Black list reserved properties */
+ if (cmHasLiteralPrefix(prop, "IMPORTED_") ||
+ cmHasLiteralPrefix(prop, "INTERFACE_")) {
+ std::ostringstream e;
+ e << "Target \"" << gte->Target->GetName() << "\" contains property \""
+ << prop << "\" in EXPORT_PROPERTIES but IMPORTED_* and INTERFACE_* "
+ << "properties are reserved.";
+ errorMessage = e.str();
+ return false;
+ }
+ auto propertyValue = targetProperties.GetPropertyValue(prop);
+ if (propertyValue == nullptr) {
+ // Asked to export a property that isn't defined on the target. Do not
+ // consider this an error, there's just nothing to export.
+ continue;
+ }
+ std::string evaluatedValue = cmGeneratorExpression::Preprocess(
+ propertyValue, cmGeneratorExpression::StripAllGeneratorExpressions);
+ if (evaluatedValue != propertyValue) {
+ std::ostringstream e;
+ e << "Target \"" << gte->Target->GetName() << "\" contains property \""
+ << prop << "\" in EXPORT_PROPERTIES but this property contains a "
+ << "generator expression. This is not allowed.";
+ errorMessage = e.str();
+ return false;
+ }
+ properties[prop] = propertyValue;
+ }
+ }
+ return true;
+}
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 985c8f6bc..0d69779f9 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -5,16 +5,17 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmGeneratorExpression.h"
-#include "cmVersion.h"
-#include "cmVersionConfig.h"
-
#include <iosfwd>
#include <map>
#include <set>
#include <string>
#include <vector>
+#include "cmGeneratorExpression.h"
+#include "cmStateTypes.h"
+#include "cmVersion.h"
+#include "cmVersionConfig.h"
+
class cmGeneratorTarget;
#define STRINGIFY_HELPER(X) #X
@@ -41,7 +42,7 @@ class cmExportFileGenerator
{
public:
cmExportFileGenerator();
- virtual ~cmExportFileGenerator() {}
+ virtual ~cmExportFileGenerator() = default;
/** Set the full path to the export file to generate. */
void SetExportFile(const char* mainFile);
@@ -61,7 +62,7 @@ public:
bool GenerateImportFile();
protected:
- typedef std::map<std::string, std::string> ImportPropertyMap;
+ using ImportPropertyMap = std::map<std::string, std::string>;
// Generate per-configuration target information to the given output
// stream.
@@ -76,7 +77,8 @@ protected:
virtual void GenerateImportFooterCode(std::ostream& os);
void GenerateImportVersionCode(std::ostream& os);
virtual void GenerateImportTargetCode(std::ostream& os,
- cmGeneratorTarget const* target);
+ cmGeneratorTarget const* target,
+ cmStateEnums::TargetType targetType);
virtual void GenerateImportPropertyCode(std::ostream& os,
const std::string& config,
cmGeneratorTarget const* target,
@@ -100,13 +102,19 @@ protected:
ImportPropertyMap& properties,
std::vector<std::string>& missingTargets);
+ enum class ImportLinkPropertyTargetNames
+ {
+ Yes,
+ No,
+ };
template <typename T>
void SetImportLinkProperty(std::string const& suffix,
cmGeneratorTarget* target,
const std::string& propName,
std::vector<T> const& entries,
ImportPropertyMap& properties,
- std::vector<std::string>& missingTargets);
+ std::vector<std::string>& missingTargets,
+ ImportLinkPropertyTargetNames targetNames);
/** Each subclass knows how to generate its kind of export file. */
virtual bool GenerateMainFile(std::ostream& os) = 0;
@@ -145,6 +153,14 @@ protected:
cmTargetExport* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
+ void PopulateLinkDirectoriesInterface(
+ cmTargetExport* target,
+ cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
+ void PopulateLinkDependsInterface(
+ cmTargetExport* target,
+ cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
void SetImportLinkInterface(
const std::string& config, std::string const& suffix,
@@ -166,6 +182,10 @@ protected:
virtual void GenerateRequiredCMakeVersion(std::ostream& os,
const char* versionString);
+ bool PopulateExportProperties(cmGeneratorTarget* gte,
+ ImportPropertyMap& properties,
+ std::string& errorMessage);
+
// The namespace in which the exports are placed in the generated file.
std::string Namespace;
diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx
index 9a1c647d3..2d732c1db 100644
--- a/Source/cmExportInstallAndroidMKGenerator.cxx
+++ b/Source/cmExportInstallAndroidMKGenerator.cxx
@@ -2,8 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportInstallAndroidMKGenerator.h"
+#include <cstddef>
+#include <memory>
#include <ostream>
-#include <stddef.h>
#include "cmExportBuildAndroidMKGenerator.h"
#include "cmExportSet.h"
@@ -11,6 +12,7 @@
#include "cmInstallExportGenerator.h"
#include "cmInstallTargetGenerator.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetExport.h"
@@ -34,11 +36,9 @@ void cmExportInstallAndroidMKGenerator::GenerateImportHeaderCode(
}
os << "_IMPORT_PREFIX := "
<< "$(LOCAL_PATH)" << path << "\n\n";
- for (std::vector<cmTargetExport*>::const_iterator tei =
- this->IEGen->GetExportSet()->GetTargetExports()->begin();
- tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) {
+ for (std::unique_ptr<cmTargetExport> const& te :
+ this->IEGen->GetExportSet()->GetTargetExports()) {
// Collect import properties for this target.
- cmTargetExport const* te = *tei;
if (te->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -58,10 +58,10 @@ void cmExportInstallAndroidMKGenerator::GenerateImportFooterCode(std::ostream&)
}
void cmExportInstallAndroidMKGenerator::GenerateImportTargetCode(
- std::ostream& os, const cmGeneratorTarget* target)
+ std::ostream& os, cmGeneratorTarget const* target,
+ cmStateEnums::TargetType /*targetType*/)
{
- std::string targetName = this->Namespace;
- targetName += target->GetExportName();
+ std::string targetName = cmStrCat(this->Namespace, target->GetExportName());
os << "include $(CLEAR_VARS)\n";
os << "LOCAL_MODULE := ";
os << targetName << "\n";
diff --git a/Source/cmExportInstallAndroidMKGenerator.h b/Source/cmExportInstallAndroidMKGenerator.h
index ebef78365..8883ffafb 100644
--- a/Source/cmExportInstallAndroidMKGenerator.h
+++ b/Source/cmExportInstallAndroidMKGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmExportInstallAndroidMKGenerator_h
#define cmExportInstallAndroidMKGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <set>
@@ -12,6 +12,7 @@
#include "cmExportFileGenerator.h"
#include "cmExportInstallFileGenerator.h"
+#include "cmStateTypes.h"
class cmGeneratorTarget;
class cmInstallExportGenerator;
@@ -22,7 +23,7 @@ class cmInstallExportGenerator;
* cmExportInstallAndroidMKGenerator generates files exporting targets from
* install an installation tree. The files are placed in a temporary
* location for installation by cmInstallExportGenerator. The file format
- * is for the ndk build system and is a makefile fragment specifing prebuilt
+ * is for the ndk build system and is a makefile fragment specifying prebuilt
* libraries to the ndk build system.
*
* This is used to implement the INSTALL(EXPORT_ANDROID_MK) command.
@@ -36,37 +37,37 @@ public:
protected:
// Implement virtual methods from the superclass.
- void GeneratePolicyHeaderCode(std::ostream&) CM_OVERRIDE {}
- void GeneratePolicyFooterCode(std::ostream&) CM_OVERRIDE {}
+ void GeneratePolicyHeaderCode(std::ostream&) override {}
+ void GeneratePolicyFooterCode(std::ostream&) override {}
void GenerateImportHeaderCode(std::ostream& os,
- const std::string& config = "") CM_OVERRIDE;
- void GenerateImportFooterCode(std::ostream& os) CM_OVERRIDE;
- void GenerateImportTargetCode(std::ostream& os,
- const cmGeneratorTarget* target) CM_OVERRIDE;
+ const std::string& config = "") override;
+ void GenerateImportFooterCode(std::ostream& os) override;
+ void GenerateImportTargetCode(
+ std::ostream& os, cmGeneratorTarget const* target,
+ cmStateEnums::TargetType /*targetType*/) override;
void GenerateExpectedTargetsCode(
- std::ostream& os, const std::string& expectedTargets) CM_OVERRIDE;
- void GenerateImportPropertyCode(std::ostream& os, const std::string& config,
- cmGeneratorTarget const* target,
- ImportPropertyMap const& properties)
- CM_OVERRIDE;
+ std::ostream& os, const std::string& expectedTargets) override;
+ void GenerateImportPropertyCode(
+ std::ostream& os, const std::string& config,
+ cmGeneratorTarget const* target,
+ ImportPropertyMap const& properties) override;
void GenerateMissingTargetsCheckCode(
- std::ostream& os,
- const std::vector<std::string>& missingTargets) CM_OVERRIDE;
+ std::ostream& os, const std::vector<std::string>& missingTargets) override;
void GenerateInterfaceProperties(
cmGeneratorTarget const* target, std::ostream& os,
- const ImportPropertyMap& properties) CM_OVERRIDE;
- void GenerateImportPrefix(std::ostream& os) CM_OVERRIDE;
- void LoadConfigFiles(std::ostream&) CM_OVERRIDE;
+ const ImportPropertyMap& properties) override;
+ void GenerateImportPrefix(std::ostream& os) override;
+ void LoadConfigFiles(std::ostream&) override;
void GenerateRequiredCMakeVersion(std::ostream& os,
- const char* versionString) CM_OVERRIDE;
- void CleanupTemporaryVariables(std::ostream&) CM_OVERRIDE;
- void GenerateImportedFileCheckLoop(std::ostream& os) CM_OVERRIDE;
+ const char* versionString) override;
+ void CleanupTemporaryVariables(std::ostream&) override;
+ void GenerateImportedFileCheckLoop(std::ostream& os) override;
void GenerateImportedFileChecksCode(
std::ostream& os, cmGeneratorTarget* target,
ImportPropertyMap const& properties,
- const std::set<std::string>& importedLocations) CM_OVERRIDE;
+ const std::set<std::string>& importedLocations) override;
bool GenerateImportFileConfig(const std::string& config,
- std::vector<std::string>&) CM_OVERRIDE;
+ std::vector<std::string>&) override;
};
#endif
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 664a34276..6d29c9994 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -2,9 +2,11 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportInstallFileGenerator.h"
-#include "cmAlgorithms.h"
+#include <memory>
+#include <sstream>
+#include <utility>
+
#include "cmExportSet.h"
-#include "cmExportSetMap.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
@@ -15,13 +17,11 @@
#include "cmMakefile.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetExport.h"
-#include <sstream>
-#include <utility>
-
cmExportInstallFileGenerator::cmExportInstallFileGenerator(
cmInstallExportGenerator* iegen)
: IEGen(iegen)
@@ -30,9 +30,7 @@ cmExportInstallFileGenerator::cmExportInstallFileGenerator(
std::string cmExportInstallFileGenerator::GetConfigImportFileGlob()
{
- std::string glob = this->FileBase;
- glob += "-*";
- glob += this->FileExt;
+ std::string glob = cmStrCat(this->FileBase, "-*", this->FileExt);
return glob;
}
@@ -42,23 +40,19 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
{
std::string expectedTargets;
std::string sep;
- for (std::vector<cmTargetExport*>::const_iterator tei =
- this->IEGen->GetExportSet()->GetTargetExports()->begin();
- tei != this->IEGen->GetExportSet()->GetTargetExports()->end();
- ++tei) {
- expectedTargets +=
- sep + this->Namespace + (*tei)->Target->GetExportName();
+ for (std::unique_ptr<cmTargetExport> const& te :
+ this->IEGen->GetExportSet()->GetTargetExports()) {
+ expectedTargets += sep + this->Namespace + te->Target->GetExportName();
sep = " ";
- cmTargetExport* te = *tei;
if (this->ExportedTargets.insert(te->Target).second) {
- allTargets.push_back(te);
+ allTargets.push_back(te.get());
} else {
std::ostringstream e;
e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName()
<< "\" ...) "
<< "includes target \"" << te->Target->GetName()
<< "\" more than once in the export set.";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
}
}
@@ -76,22 +70,20 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
bool require3_1_0 = false;
bool requiresConfigFiles = false;
// Create all the imported targets.
- for (std::vector<cmTargetExport*>::const_iterator tei = allTargets.begin();
- tei != allTargets.end(); ++tei) {
- cmGeneratorTarget* gt = (*tei)->Target;
+ for (cmTargetExport* te : allTargets) {
+ cmGeneratorTarget* gt = te->Target;
+ cmStateEnums::TargetType targetType = this->GetExportTargetType(te);
requiresConfigFiles =
- requiresConfigFiles || gt->GetType() != cmStateEnums::INTERFACE_LIBRARY;
+ requiresConfigFiles || targetType != cmStateEnums::INTERFACE_LIBRARY;
- this->GenerateImportTargetCode(os, gt);
+ this->GenerateImportTargetCode(os, gt, targetType);
ImportPropertyMap properties;
this->PopulateIncludeDirectoriesInterface(
- *tei, cmGeneratorExpression::InstallInterface, properties,
- missingTargets);
- this->PopulateSourcesInterface(*tei,
- cmGeneratorExpression::InstallInterface,
+ te, cmGeneratorExpression::InstallInterface, properties, missingTargets);
+ this->PopulateSourcesInterface(te, cmGeneratorExpression::InstallInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", gt,
cmGeneratorExpression::InstallInterface,
@@ -102,12 +94,28 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS", gt,
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_PRECOMPILE_HEADERS", gt,
+ cmGeneratorExpression::InstallInterface,
+ properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gt,
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gt,
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_LINK_OPTIONS", gt,
+ cmGeneratorExpression::InstallInterface,
+ properties, missingTargets);
+ this->PopulateLinkDirectoriesInterface(
+ te, cmGeneratorExpression::InstallInterface, properties, missingTargets);
+ this->PopulateLinkDependsInterface(
+ te, cmGeneratorExpression::InstallInterface, properties, missingTargets);
+
+ std::string errorMessage;
+ if (!this->PopulateExportProperties(gt, properties, errorMessage)) {
+ cmSystemTools::Error(errorMessage);
+ return false;
+ }
const bool newCMP0022Behavior =
gt->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
@@ -120,7 +128,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
require2_8_12 = true;
}
}
- if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (targetType == cmStateEnums::INTERFACE_LIBRARY) {
require3_0_0 = true;
}
if (gt->GetProperty("INTERFACE_SOURCES")) {
@@ -154,10 +162,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
// Generate an import file for each configuration.
// Don't do this if we only export INTERFACE_LIBRARY targets.
if (requiresConfigFiles) {
- for (std::vector<std::string>::const_iterator ci =
- this->Configurations.begin();
- ci != this->Configurations.end(); ++ci) {
- if (!this->GenerateImportFileConfig(*ci, missingTargets)) {
+ for (std::string const& c : this->Configurations) {
+ if (!this->GenerateImportFileConfig(c, missingTargets)) {
result = false;
}
}
@@ -193,12 +199,12 @@ void cmExportInstallFileGenerator::GenerateImportPrefix(std::ostream& os)
os << "# Compute the installation prefix relative to this file.\n"
<< "get_filename_component(_IMPORT_PREFIX"
<< " \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n";
- if (cmHasLiteralPrefix(absDestS.c_str(), "/lib/") ||
- cmHasLiteralPrefix(absDestS.c_str(), "/lib64/") ||
- cmHasLiteralPrefix(absDestS.c_str(), "/libx32/") ||
- cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib/") ||
- cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib64/") ||
- cmHasLiteralPrefix(absDestS.c_str(), "/usr/libx32/")) {
+ if (cmHasLiteralPrefix(absDestS, "/lib/") ||
+ cmHasLiteralPrefix(absDestS, "/lib64/") ||
+ cmHasLiteralPrefix(absDestS, "/libx32/") ||
+ cmHasLiteralPrefix(absDestS, "/usr/lib/") ||
+ cmHasLiteralPrefix(absDestS, "/usr/lib64/") ||
+ cmHasLiteralPrefix(absDestS, "/usr/libx32/")) {
// Handle "/usr move" symlinks created by some Linux distros.
/* clang-format off */
os <<
@@ -272,10 +278,7 @@ bool cmExportInstallFileGenerator::GenerateImportFileConfig(
}
// Construct the name of the file to generate.
- std::string fileName = this->FileDir;
- fileName += "/";
- fileName += this->FileBase;
- fileName += "-";
+ std::string fileName = cmStrCat(this->FileDir, '/', this->FileBase, '-');
if (!config.empty()) {
fileName += cmSystemTools::LowerCase(config);
} else {
@@ -284,12 +287,12 @@ bool cmExportInstallFileGenerator::GenerateImportFileConfig(
fileName += this->FileExt;
// Open the output file to generate it.
- cmGeneratedFileStream exportFileStream(fileName.c_str(), true);
+ cmGeneratedFileStream exportFileStream(fileName, true);
if (!exportFileStream) {
std::string se = cmSystemTools::GetLastSystemError();
std::ostringstream e;
e << "cannot write to file \"" << fileName << "\": " << se;
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
}
std::ostream& os = exportFileStream;
@@ -314,12 +317,11 @@ void cmExportInstallFileGenerator::GenerateImportTargetsConfig(
std::vector<std::string>& missingTargets)
{
// Add each target in the set to the export.
- for (std::vector<cmTargetExport*>::const_iterator tei =
- this->IEGen->GetExportSet()->GetTargetExports()->begin();
- tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) {
+ for (std::unique_ptr<cmTargetExport> const& te :
+ this->IEGen->GetExportSet()->GetTargetExports()) {
// Collect import properties for this target.
- cmTargetExport const* te = *tei;
- if (te->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (this->GetExportTargetType(te.get()) ==
+ cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -351,7 +353,7 @@ void cmExportInstallFileGenerator::GenerateImportTargetsConfig(
cmGeneratorExpression::InstallInterface,
gtgt, properties, missingTargets);
- // TOOD: PUBLIC_HEADER_LOCATION
+ // TODO: PUBLIC_HEADER_LOCATION
// This should wait until the build feature propagation stuff
// is done. Then this can be a propagated include directory.
// this->GenerateImportProperty(config, te->HeaderGenerator,
@@ -381,7 +383,7 @@ void cmExportInstallFileGenerator::SetImportLocationProperty(
// Construct the installed location of the target.
std::string dest = itgen->GetDestination(config);
std::string value;
- if (!cmSystemTools::FileIsFullPath(dest.c_str())) {
+ if (!cmSystemTools::FileIsFullPath(dest)) {
// The target is installed relative to the installation prefix.
value = "${_IMPORT_PREFIX}/";
}
@@ -390,28 +392,25 @@ void cmExportInstallFileGenerator::SetImportLocationProperty(
if (itgen->IsImportLibrary()) {
// Construct the property name.
- std::string prop = "IMPORTED_IMPLIB";
- prop += suffix;
+ std::string prop = cmStrCat("IMPORTED_IMPLIB", suffix);
// Append the installed file name.
- value += itgen->GetInstallFilename(target, config,
- cmInstallTargetGenerator::NameImplib);
+ value += cmInstallTargetGenerator::GetInstallFilename(
+ target, config, cmInstallTargetGenerator::NameImplib);
// Store the property.
properties[prop] = value;
importedLocations.insert(prop);
} else if (itgen->GetTarget()->GetType() == cmStateEnums::OBJECT_LIBRARY) {
// Construct the property name.
- std::string prop = "IMPORTED_OBJECTS";
- prop += suffix;
+ std::string prop = cmStrCat("IMPORTED_OBJECTS", suffix);
// Compute all the object files inside this target and setup
// IMPORTED_OBJECTS as a list of object files
std::vector<std::string> objects;
itgen->GetInstallObjectNames(config, objects);
- for (std::vector<std::string>::iterator i = objects.begin();
- i != objects.end(); ++i) {
- *i = value + *i;
+ for (std::string& obj : objects) {
+ obj = cmStrCat(value, obj);
}
// Store the property.
@@ -419,17 +418,16 @@ void cmExportInstallFileGenerator::SetImportLocationProperty(
importedLocations.insert(prop);
} else {
// Construct the property name.
- std::string prop = "IMPORTED_LOCATION";
- prop += suffix;
+ std::string prop = cmStrCat("IMPORTED_LOCATION", suffix);
// Append the installed file name.
if (target->IsAppBundleOnApple()) {
- value += itgen->GetInstallFilename(target, config);
+ value += cmInstallTargetGenerator::GetInstallFilename(target, config);
value += ".app/Contents/MacOS/";
- value += itgen->GetInstallFilename(target, config);
+ value += cmInstallTargetGenerator::GetInstallFilename(target, config);
} else {
- value += itgen->GetInstallFilename(target, config,
- cmInstallTargetGenerator::NameReal);
+ value += cmInstallTargetGenerator::GetInstallFilename(
+ target, config, cmInstallTargetGenerator::NameReal);
}
// Store the property.
@@ -438,42 +436,54 @@ void cmExportInstallFileGenerator::SetImportLocationProperty(
}
}
+cmStateEnums::TargetType cmExportInstallFileGenerator::GetExportTargetType(
+ cmTargetExport const* targetExport) const
+{
+ cmStateEnums::TargetType targetType = targetExport->Target->GetType();
+ // An OBJECT library installed with no OBJECTS DESTINATION
+ // is transformed to an INTERFACE library.
+ if (targetType == cmStateEnums::OBJECT_LIBRARY &&
+ targetExport->ObjectsGenerator == nullptr) {
+ targetType = cmStateEnums::INTERFACE_LIBRARY;
+ }
+ return targetType;
+}
+
void cmExportInstallFileGenerator::HandleMissingTarget(
std::string& link_libs, std::vector<std::string>& missingTargets,
cmGeneratorTarget* depender, cmGeneratorTarget* dependee)
{
const std::string name = dependee->GetName();
cmGlobalGenerator* gg = dependee->GetLocalGenerator()->GetGlobalGenerator();
- std::vector<std::string> namespaces = this->FindNamespaces(gg, name);
- int targetOccurrences = (int)namespaces.size();
- if (targetOccurrences == 1) {
- std::string missingTarget = namespaces[0];
+ auto exportInfo = this->FindNamespaces(gg, name);
+ std::vector<std::string> const& exportFiles = exportInfo.first;
+ if (exportFiles.size() == 1) {
+ std::string missingTarget = exportInfo.second;
missingTarget += dependee->GetExportName();
link_libs += missingTarget;
- missingTargets.push_back(missingTarget);
+ missingTargets.push_back(std::move(missingTarget));
} else {
// All exported targets should be known here and should be unique.
// This is probably user-error.
- this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
+ this->ComplainAboutMissingTarget(depender, dependee, exportFiles);
}
}
-std::vector<std::string> cmExportInstallFileGenerator::FindNamespaces(
- cmGlobalGenerator* gg, const std::string& name)
+std::pair<std::vector<std::string>, std::string>
+cmExportInstallFileGenerator::FindNamespaces(cmGlobalGenerator* gg,
+ const std::string& name)
{
- std::vector<std::string> namespaces;
+ std::vector<std::string> exportFiles;
+ std::string ns;
const cmExportSetMap& exportSets = gg->GetExportSets();
- for (cmExportSetMap::const_iterator expIt = exportSets.begin();
- expIt != exportSets.end(); ++expIt) {
- const cmExportSet* exportSet = expIt->second;
- std::vector<cmTargetExport*> const* targets =
- exportSet->GetTargetExports();
+ for (auto const& expIt : exportSets) {
+ const cmExportSet& exportSet = expIt.second;
bool containsTarget = false;
- for (unsigned int i = 0; i < targets->size(); i++) {
- if (name == (*targets)[i]->TargetName) {
+ for (auto const& target : exportSet.GetTargetExports()) {
+ if (name == target->TargetName) {
containsTarget = true;
break;
}
@@ -481,31 +491,37 @@ std::vector<std::string> cmExportInstallFileGenerator::FindNamespaces(
if (containsTarget) {
std::vector<cmInstallExportGenerator const*> const* installs =
- exportSet->GetInstallations();
- for (unsigned int i = 0; i < installs->size(); i++) {
- namespaces.push_back((*installs)[i]->GetNamespace());
+ exportSet.GetInstallations();
+ for (cmInstallExportGenerator const* install : *installs) {
+ exportFiles.push_back(install->GetDestinationFile());
+ ns = install->GetNamespace();
}
}
}
- return namespaces;
+ return { exportFiles, ns };
}
void cmExportInstallFileGenerator::ComplainAboutMissingTarget(
- cmGeneratorTarget* depender, cmGeneratorTarget* dependee, int occurrences)
+ cmGeneratorTarget* depender, cmGeneratorTarget* dependee,
+ std::vector<std::string> const& exportFiles)
{
std::ostringstream e;
e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName()
<< "\" ...) "
<< "includes target \"" << depender->GetName()
<< "\" which requires target \"" << dependee->GetName() << "\" ";
- if (occurrences == 0) {
- e << "that is not in the export set.";
+ if (exportFiles.empty()) {
+ e << "that is not in any export set.";
} else {
- e << "that is not in this export set, but " << occurrences
- << " times in others.";
+ e << "that is not in this export set, but in multiple other export sets: "
+ << cmJoin(exportFiles, ", ") << ".\n";
+ e << "An exported target cannot depend upon another target which is "
+ "exported multiple times. Consider consolidating the exports of the "
+ "\""
+ << dependee->GetName() << "\" target to a single export.";
}
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
}
std::string cmExportInstallFileGenerator::InstallNameDir(
diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h
index 8fa9b7f88..5fa812c58 100644
--- a/Source/cmExportInstallFileGenerator.h
+++ b/Source/cmExportInstallFileGenerator.h
@@ -3,20 +3,23 @@
#ifndef cmExportInstallFileGenerator_h
#define cmExportInstallFileGenerator_h
-#include "cmConfigure.h"
-
-#include "cmExportFileGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
#include <set>
#include <string>
+#include <utility>
#include <vector>
+#include "cmExportFileGenerator.h"
+#include "cmStateTypes.h"
+
class cmGeneratorTarget;
class cmGlobalGenerator;
class cmInstallExportGenerator;
class cmInstallTargetGenerator;
+class cmTargetExport;
/** \class cmExportInstallFileGenerator
* \brief Generate a file exporting targets from an install tree.
@@ -39,7 +42,7 @@ public:
files. */
cmExportInstallFileGenerator(cmInstallExportGenerator* iegen);
- /** Get the per-config file generated for each configuraiton. This
+ /** Get the per-config file generated for each configuration. This
maps from the configuration name to the file temporary location
for installation. */
std::map<std::string, std::string> const& GetConfigImportFiles()
@@ -53,23 +56,25 @@ public:
protected:
// Implement virtual methods from the superclass.
- bool GenerateMainFile(std::ostream& os) CM_OVERRIDE;
+ bool GenerateMainFile(std::ostream& os) override;
void GenerateImportTargetsConfig(
std::ostream& os, const std::string& config, std::string const& suffix,
- std::vector<std::string>& missingTargets) CM_OVERRIDE;
+ std::vector<std::string>& missingTargets) override;
+ cmStateEnums::TargetType GetExportTargetType(
+ cmTargetExport const* targetExport) const;
void HandleMissingTarget(std::string& link_libs,
std::vector<std::string>& missingTargets,
cmGeneratorTarget* depender,
- cmGeneratorTarget* dependee) CM_OVERRIDE;
+ cmGeneratorTarget* dependee) override;
- void ReplaceInstallPrefix(std::string& input) CM_OVERRIDE;
+ void ReplaceInstallPrefix(std::string& input) override;
void ComplainAboutMissingTarget(cmGeneratorTarget* depender,
cmGeneratorTarget* dependee,
- int occurrences);
+ std::vector<std::string> const& exportFiles);
- std::vector<std::string> FindNamespaces(cmGlobalGenerator* gg,
- const std::string& name);
+ std::pair<std::vector<std::string>, std::string> FindNamespaces(
+ cmGlobalGenerator* gg, const std::string& name);
/** Generate the relative import prefix. */
virtual void GenerateImportPrefix(std::ostream&);
@@ -91,7 +96,7 @@ protected:
std::set<std::string>& importedLocations);
std::string InstallNameDir(cmGeneratorTarget* target,
- const std::string& config) CM_OVERRIDE;
+ const std::string& config) override;
cmInstallExportGenerator* IEGen;
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx
index 69150aee4..89093e95f 100644
--- a/Source/cmExportLibraryDependenciesCommand.cxx
+++ b/Source/cmExportLibraryDependenciesCommand.cxx
@@ -2,85 +2,58 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportLibraryDependenciesCommand.h"
-#include "cmsys/FStream.hxx"
#include <map>
#include <utility>
+#include <cm/memory>
+
+#include "cmsys/FStream.hxx"
+
+#include "cmExecutionStatus.h"
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetLinkLibraryType.h"
-#include "cm_auto_ptr.hxx"
-#include "cm_unordered_map.hxx"
#include "cmake.h"
-class cmExecutionStatus;
-
-bool cmExportLibraryDependenciesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
-{
- if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
- return false;
- }
-
- // store the arguments for the final pass
- this->Filename = args[0];
- this->Append = false;
- if (args.size() > 1) {
- if (args[1] == "APPEND") {
- this->Append = true;
- }
- }
- return true;
-}
-
-void cmExportLibraryDependenciesCommand::FinalPass()
-{
- // export_library_dependencies() shouldn't modify anything
- // ensure this by calling a const method
- this->ConstFinalPass();
-}
-
-void cmExportLibraryDependenciesCommand::ConstFinalPass() const
+static void FinalAction(cmMakefile& makefile, std::string const& filename,
+ bool append)
{
// Use copy-if-different if not appending.
- CM_AUTO_PTR<cmsys::ofstream> foutPtr;
- if (this->Append) {
- CM_AUTO_PTR<cmsys::ofstream> ap(
- new cmsys::ofstream(this->Filename.c_str(), std::ios::app));
- foutPtr = ap;
+ std::unique_ptr<cmsys::ofstream> foutPtr;
+ if (append) {
+ const auto openmodeApp = std::ios::app;
+ foutPtr = cm::make_unique<cmsys::ofstream>(filename.c_str(), openmodeApp);
} else {
- CM_AUTO_PTR<cmGeneratedFileStream> ap(
- new cmGeneratedFileStream(this->Filename.c_str(), true));
+ std::unique_ptr<cmGeneratedFileStream> ap(
+ new cmGeneratedFileStream(filename, true));
ap->SetCopyIfDifferent(true);
- foutPtr = ap;
+ foutPtr = std::move(ap);
}
std::ostream& fout = *foutPtr;
if (!fout) {
- cmSystemTools::Error("Error Writing ", this->Filename.c_str());
+ cmSystemTools::Error("Error Writing " + filename);
cmSystemTools::ReportLastSystemError("");
return;
}
// Collect dependency information about all library targets built in
// the project.
- cmake* cm = this->Makefile->GetCMakeInstance();
+ cmake* cm = makefile.GetCMakeInstance();
cmGlobalGenerator* global = cm->GetGlobalGenerator();
const std::vector<cmMakefile*>& locals = global->GetMakefiles();
std::map<std::string, std::string> libDepsOld;
std::map<std::string, std::string> libDepsNew;
std::map<std::string, std::string> libTypes;
- for (std::vector<cmMakefile*>::const_iterator i = locals.begin();
- i != locals.end(); ++i) {
- const cmTargets& tgts = (*i)->GetTargets();
- for (cmTargets::const_iterator l = tgts.begin(); l != tgts.end(); ++l) {
+ for (cmMakefile* local : locals) {
+ for (auto const& tgt : local->GetTargets()) {
// Get the current target.
- cmTarget const& target = l->second;
+ cmTarget const& target = tgt.second;
// Skip non-library targets.
if (target.GetType() < cmStateEnums::STATIC_LIBRARY ||
@@ -89,8 +62,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
}
// Construct the dependency variable name.
- std::string targetEntry = target.GetName();
- targetEntry += "_LIB_DEPENDS";
+ std::string targetEntry = cmStrCat(target.GetName(), "_LIB_DEPENDS");
// Construct the dependency variable value with the direct link
// dependencies.
@@ -98,12 +70,10 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
std::string valueNew;
cmTarget::LinkLibraryVectorType const& libs =
target.GetOriginalLinkLibraries();
- for (cmTarget::LinkLibraryVectorType::const_iterator li = libs.begin();
- li != libs.end(); ++li) {
- std::string ltVar = li->first;
- ltVar += "_LINK_TYPE";
+ for (cmTarget::LibraryID const& li : libs) {
+ std::string ltVar = cmStrCat(li.first, "_LINK_TYPE");
std::string ltValue;
- switch (li->second) {
+ switch (li.second) {
case GENERAL_LibraryType:
valueNew += "general;";
ltValue = "general";
@@ -117,7 +87,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
ltValue = "optimized";
break;
}
- std::string lib = li->first;
+ std::string lib = li.first;
if (cmTarget* libtgt = global->FindTarget(lib)) {
// Handle simple output name changes. This command is
// deprecated so we do not support full target name
@@ -150,27 +120,40 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
fout << "# Generated by CMake\n\n";
fout << "if(" << vertest << ")\n";
fout << " # Information for CMake 2.6 and above.\n";
- for (std::map<std::string, std::string>::const_iterator i =
- libDepsNew.begin();
- i != libDepsNew.end(); ++i) {
- if (!i->second.empty()) {
- fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n";
+ for (auto const& i : libDepsNew) {
+ if (!i.second.empty()) {
+ fout << " set(\"" << i.first << "\" \"" << i.second << "\")\n";
}
}
fout << "else()\n";
fout << " # Information for CMake 2.4 and lower.\n";
- for (std::map<std::string, std::string>::const_iterator i =
- libDepsOld.begin();
- i != libDepsOld.end(); ++i) {
- if (!i->second.empty()) {
- fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n";
+ for (auto const& i : libDepsOld) {
+ if (!i.second.empty()) {
+ fout << " set(\"" << i.first << "\" \"" << i.second << "\")\n";
}
}
- for (std::map<std::string, std::string>::const_iterator i = libTypes.begin();
- i != libTypes.end(); ++i) {
- if (i->second != "general") {
- fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n";
+ for (auto const& i : libTypes) {
+ if (i.second != "general") {
+ fout << " set(\"" << i.first << "\" \"" << i.second << "\")\n";
}
}
fout << "endif()\n";
}
+
+bool cmExportLibraryDependenciesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.empty()) {
+ status.SetError("called with incorrect number of arguments");
+ return false;
+ }
+
+ std::string const& filename = args[0];
+ bool const append = args.size() > 1 && args[1] == "APPEND";
+ status.GetMakefile().AddFinalAction(
+ [filename, append](cmMakefile& makefile) {
+ FinalAction(makefile, filename, append);
+ });
+
+ return true;
+}
diff --git a/Source/cmExportLibraryDependenciesCommand.h b/Source/cmExportLibraryDependenciesCommand.h
index 5559af94b..230c90616 100644
--- a/Source/cmExportLibraryDependenciesCommand.h
+++ b/Source/cmExportLibraryDependenciesCommand.h
@@ -3,32 +3,14 @@
#ifndef cmExportLibraryDependenciesCommand_h
#define cmExportLibraryDependenciesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmExportLibraryDependenciesCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE
- {
- return new cmExportLibraryDependenciesCommand;
- }
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
- void FinalPass() CM_OVERRIDE;
- bool HasFinalPass() const CM_OVERRIDE { return true; }
-
-private:
- std::string Filename;
- bool Append;
- void ConstFinalPass() const;
-};
+bool cmExportLibraryDependenciesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx
index a93667994..a20aa9a8a 100644
--- a/Source/cmExportSet.cxx
+++ b/Source/cmExportSet.cxx
@@ -2,29 +2,43 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportSet.h"
-#include "cmAlgorithms.h"
+#include <tuple>
+#include <utility>
+
#include "cmLocalGenerator.h"
#include "cmTargetExport.h"
-cmExportSet::~cmExportSet()
+cmExportSet::cmExportSet(std::string name)
+ : Name(std::move(name))
{
- cmDeleteAll(this->TargetExports);
}
+cmExportSet::~cmExportSet() = default;
+
void cmExportSet::Compute(cmLocalGenerator* lg)
{
- for (std::vector<cmTargetExport*>::iterator it = this->TargetExports.begin();
- it != this->TargetExports.end(); ++it) {
- (*it)->Target = lg->FindGeneratorTargetToUse((*it)->TargetName);
+ for (std::unique_ptr<cmTargetExport>& tgtExport : this->TargetExports) {
+ tgtExport->Target = lg->FindGeneratorTargetToUse(tgtExport->TargetName);
}
}
-void cmExportSet::AddTargetExport(cmTargetExport* te)
+void cmExportSet::AddTargetExport(std::unique_ptr<cmTargetExport> te)
{
- this->TargetExports.push_back(te);
+ this->TargetExports.emplace_back(std::move(te));
}
void cmExportSet::AddInstallation(cmInstallExportGenerator const* installation)
{
this->Installations.push_back(installation);
}
+
+cmExportSet& cmExportSetMap::operator[](const std::string& name)
+{
+ auto it = this->find(name);
+ if (it == this->end()) // Export set not found
+ {
+ auto tup_name = std::make_tuple(name);
+ it = this->emplace(std::piecewise_construct, tup_name, tup_name).first;
+ }
+ return it->second;
+}
diff --git a/Source/cmExportSet.h b/Source/cmExportSet.h
index 58ad617d4..f0d921f5e 100644
--- a/Source/cmExportSet.h
+++ b/Source/cmExportSet.h
@@ -5,6 +5,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <map>
+#include <memory>
#include <string>
#include <vector>
@@ -17,24 +19,24 @@ class cmExportSet
{
public:
/// Construct an empty export set named \a name
- cmExportSet(const std::string& name)
- : Name(name)
- {
- }
+ cmExportSet(std::string name);
/// Destructor
~cmExportSet();
+ cmExportSet(const cmExportSet&) = delete;
+ cmExportSet& operator=(const cmExportSet&) = delete;
+
void Compute(cmLocalGenerator* lg);
- void AddTargetExport(cmTargetExport* tgt);
+ void AddTargetExport(std::unique_ptr<cmTargetExport> tgt);
void AddInstallation(cmInstallExportGenerator const* installation);
std::string const& GetName() const { return this->Name; }
- std::vector<cmTargetExport*> const* GetTargetExports() const
+ std::vector<std::unique_ptr<cmTargetExport>> const& GetTargetExports() const
{
- return &this->TargetExports;
+ return this->TargetExports;
}
std::vector<cmInstallExportGenerator const*> const* GetInstallations() const
@@ -43,9 +45,21 @@ public:
}
private:
- std::vector<cmTargetExport*> TargetExports;
+ std::vector<std::unique_ptr<cmTargetExport>> TargetExports;
std::string Name;
std::vector<cmInstallExportGenerator const*> Installations;
};
+/// A name -> cmExportSet map with overloaded operator[].
+class cmExportSetMap : public std::map<std::string, cmExportSet>
+{
+public:
+ /** \brief Overloaded operator[].
+ *
+ * The operator is overloaded because cmExportSet has no default constructor:
+ * we do not want unnamed export sets.
+ */
+ cmExportSet& operator[](const std::string& name);
+};
+
#endif
diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx
deleted file mode 100644
index 074082835..000000000
--- a/Source/cmExportSetMap.cxx
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmExportSetMap.h"
-
-#include "cmAlgorithms.h"
-#include "cmExportSet.h"
-
-#include <utility>
-
-cmExportSet* cmExportSetMap::operator[](const std::string& name)
-{
- std::map<std::string, cmExportSet*>::iterator it = this->find(name);
- if (it == this->end()) // Export set not found
- {
- it = this->insert(std::make_pair(name, new cmExportSet(name))).first;
- }
- return it->second;
-}
-
-void cmExportSetMap::clear()
-{
- cmDeleteAll(*this);
- this->derived::clear();
-}
-
-cmExportSetMap::~cmExportSetMap()
-{
- this->clear();
-}
diff --git a/Source/cmExportSetMap.h b/Source/cmExportSetMap.h
deleted file mode 100644
index 0f71c790c..000000000
--- a/Source/cmExportSetMap.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmExportSetMap_h
-#define cmExportSetMap_h
-
-#include "cmConfigure.h" // IWYU pragma: keep
-
-#include <map>
-#include <string>
-
-class cmExportSet;
-
-/// A name -> cmExportSet map with overloaded operator[].
-class cmExportSetMap : public std::map<std::string, cmExportSet*>
-{
- typedef std::map<std::string, cmExportSet*> derived;
-
-public:
- /** \brief Overloaded operator[].
- *
- * The operator is overloaded because cmExportSet has no default constructor:
- * we do not want unnamed export sets.
- */
- cmExportSet* operator[](const std::string& name);
-
- void clear();
-
- /// Overloaded destructor deletes all member export sets.
- ~cmExportSetMap();
-};
-
-#endif
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index cd0a7e69a..fafa51b7b 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -2,6 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportTryCompileFileGenerator.h"
+#include <map>
+#include <memory>
+#include <utility>
+
#include "cmGeneratorExpression.h"
#include "cmGeneratorExpressionDAGChecker.h"
#include "cmGeneratorTarget.h"
@@ -9,16 +13,13 @@
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
-#include "cmSystemTools.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
-#include "cm_auto_ptr.hxx"
-
-#include <map>
-#include <utility>
cmExportTryCompileFileGenerator::cmExportTryCompileFileGenerator(
cmGlobalGenerator* gg, const std::vector<std::string>& targets,
- cmMakefile* mf)
+ cmMakefile* mf, std::set<std::string> const& langs)
+ : Languages(langs.begin(), langs.end())
{
gg->CreateImportedGenerationObjects(mf, targets, this->Exports);
}
@@ -32,16 +33,18 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
this->Exports.pop_back();
if (emitted.insert(te).second) {
emittedDeps.insert(te);
- this->GenerateImportTargetCode(os, te);
+ this->GenerateImportTargetCode(os, te, te->GetType());
ImportPropertyMap properties;
+ for (std::string const& lang : this->Languages) {
#define FIND_TARGETS(PROPERTY) \
- this->FindTargets("INTERFACE_" #PROPERTY, te, emittedDeps);
+ this->FindTargets("INTERFACE_" #PROPERTY, te, lang, emittedDeps);
- CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS)
+ CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(FIND_TARGETS)
#undef FIND_TARGETS
+ }
this->PopulateProperties(te, properties, emittedDeps);
@@ -53,7 +56,7 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
std::string cmExportTryCompileFileGenerator::FindTargets(
const std::string& propName, cmGeneratorTarget const* tgt,
- std::set<cmGeneratorTarget const*>& emitted)
+ std::string const& language, std::set<cmGeneratorTarget const*>& emitted)
{
const char* prop = tgt->GetProperty(propName);
if (!prop) {
@@ -62,10 +65,9 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
cmGeneratorExpression ge;
- cmGeneratorExpressionDAGChecker dagChecker(tgt->GetName(), propName,
- CM_NULLPTR, CM_NULLPTR);
+ cmGeneratorExpressionDAGChecker dagChecker(tgt, propName, nullptr, nullptr);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
cmTarget dummyHead("try_compile_dummy_exe", cmStateEnums::EXECUTABLE,
cmTarget::VisibilityNormal, tgt->Target->GetMakefile());
@@ -73,15 +75,13 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator());
std::string result = cge->Evaluate(tgt->GetLocalGenerator(), this->Config,
- false, &gDummyHead, tgt, &dagChecker);
+ &gDummyHead, &dagChecker, tgt, language);
const std::set<cmGeneratorTarget const*>& allTargets =
cge->GetAllTargetsSeen();
- for (std::set<cmGeneratorTarget const*>::const_iterator li =
- allTargets.begin();
- li != allTargets.end(); ++li) {
- if (emitted.insert(*li).second) {
- this->Exports.push_back(*li);
+ for (cmGeneratorTarget const* target : allTargets) {
+ if (emitted.insert(target).second) {
+ this->Exports.push_back(target);
}
}
return result;
@@ -92,22 +92,20 @@ void cmExportTryCompileFileGenerator::PopulateProperties(
std::set<cmGeneratorTarget const*>& emitted)
{
std::vector<std::string> props = target->GetPropertyKeys();
- for (std::vector<std::string>::const_iterator i = props.begin();
- i != props.end(); ++i) {
+ for (std::string const& p : props) {
- properties[*i] = target->GetProperty(*i);
+ properties[p] = target->GetProperty(p);
- if (i->find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 ||
- i->find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0 ||
- i->find("INTERFACE_LINK_LIBRARIES") == 0) {
- std::string evalResult = this->FindTargets(*i, target, emitted);
+ if (p.find("IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 ||
+ p.find("IMPORTED_LINK_DEPENDENT_LIBRARIES") == 0 ||
+ p.find("INTERFACE_LINK_LIBRARIES") == 0) {
+ std::string evalResult =
+ this->FindTargets(p, target, std::string(), emitted);
- std::vector<std::string> depends;
- cmSystemTools::ExpandListArgument(evalResult, depends);
- for (std::vector<std::string>::const_iterator li = depends.begin();
- li != depends.end(); ++li) {
+ std::vector<std::string> depends = cmExpandedList(evalResult);
+ for (std::string const& li : depends) {
cmGeneratorTarget* tgt =
- target->GetLocalGenerator()->FindGeneratorTargetToUse(*li);
+ target->GetLocalGenerator()->FindGeneratorTargetToUse(li);
if (tgt && emitted.insert(tgt).second) {
this->Exports.push_back(tgt);
}
diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h
index 9671fac8f..7573427f6 100644
--- a/Source/cmExportTryCompileFileGenerator.h
+++ b/Source/cmExportTryCompileFileGenerator.h
@@ -3,15 +3,15 @@
#ifndef cmExportTryCompileFileGenerator_h
#define cmExportTryCompileFileGenerator_h
-#include "cmConfigure.h"
-
-#include "cmExportFileGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <set>
#include <string>
#include <vector>
+#include "cmExportFileGenerator.h"
+
class cmGeneratorTarget;
class cmGlobalGenerator;
class cmMakefile;
@@ -21,21 +21,23 @@ class cmExportTryCompileFileGenerator : public cmExportFileGenerator
public:
cmExportTryCompileFileGenerator(cmGlobalGenerator* gg,
std::vector<std::string> const& targets,
- cmMakefile* mf);
+ cmMakefile* mf,
+ std::set<std::string> const& langs);
/** Set the list of targets to export. */
void SetConfig(const std::string& config) { this->Config = config; }
+
protected:
// Implement virtual methods from the superclass.
- bool GenerateMainFile(std::ostream& os) CM_OVERRIDE;
+ bool GenerateMainFile(std::ostream& os) override;
void GenerateImportTargetsConfig(std::ostream&, const std::string&,
std::string const&,
- std::vector<std::string>&) CM_OVERRIDE
+ std::vector<std::string>&) override
{
}
void HandleMissingTarget(std::string&, std::vector<std::string>&,
- cmGeneratorTarget*, cmGeneratorTarget*) CM_OVERRIDE
+ cmGeneratorTarget*, cmGeneratorTarget*) override
{
}
@@ -44,15 +46,17 @@ protected:
std::set<const cmGeneratorTarget*>& emitted);
std::string InstallNameDir(cmGeneratorTarget* target,
- const std::string& config) CM_OVERRIDE;
+ const std::string& config) override;
private:
std::string FindTargets(const std::string& prop,
const cmGeneratorTarget* tgt,
+ std::string const& language,
std::set<const cmGeneratorTarget*>& emitted);
std::vector<cmGeneratorTarget const*> Exports;
std::string Config;
+ std::vector<std::string> Languages;
};
#endif
diff --git a/Source/cmExprParserHelper.cxx b/Source/cmExprParserHelper.cxx
index c3f026a4e..56dfc6c1d 100644
--- a/Source/cmExprParserHelper.cxx
+++ b/Source/cmExprParserHelper.cxx
@@ -2,25 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExprParserHelper.h"
-#include "cmConfigure.h"
-
-#include "cmExprLexer.h"
-
#include <iostream>
#include <sstream>
+#include <stdexcept>
+#include <utility>
+
+#include "cmExprLexer.h"
+#include "cmStringAlgorithms.h"
int cmExpr_yyparse(yyscan_t yyscanner);
//
cmExprParserHelper::cmExprParserHelper()
{
this->FileLine = -1;
- this->FileName = CM_NULLPTR;
+ this->FileName = nullptr;
+ this->Result = 0;
}
-cmExprParserHelper::~cmExprParserHelper()
-{
- this->CleanupParser();
-}
+cmExprParserHelper::~cmExprParserHelper() = default;
int cmExprParserHelper::ParseString(const char* str, int verb)
{
@@ -39,16 +38,31 @@ int cmExprParserHelper::ParseString(const char* str, int verb)
yyscan_t yyscanner;
cmExpr_yylex_init(&yyscanner);
cmExpr_yyset_extra(this, yyscanner);
- int res = cmExpr_yyparse(yyscanner);
+
+ try {
+ int res = cmExpr_yyparse(yyscanner);
+ if (res != 0) {
+ std::string e = cmStrCat("cannot parse the expression: \"", InputBuffer,
+ "\": ", ErrorString, '.');
+ this->SetError(std::move(e));
+ }
+ } catch (std::runtime_error const& fail) {
+ std::string e = cmStrCat("cannot evaluate the expression: \"", InputBuffer,
+ "\": ", fail.what(), '.');
+ this->SetError(std::move(e));
+ } catch (std::out_of_range const&) {
+ std::string e = "cannot evaluate the expression: \"" + InputBuffer +
+ "\": a numeric value is out of range.";
+ this->SetError(std::move(e));
+ } catch (...) {
+ std::string e = "cannot parse the expression: \"" + InputBuffer + "\".";
+ this->SetError(std::move(e));
+ }
cmExpr_yylex_destroy(yyscanner);
- if (res != 0) {
- // str << "CAL_Parser returned: " << res << std::endl;
- // std::cerr << "When parsing: [" << str << "]" << std::endl;
+ if (!this->ErrorString.empty()) {
return 0;
}
- this->CleanupParser();
-
if (Verbose) {
std::cerr << "Expanding [" << str << "] produced: [" << this->Result << "]"
<< std::endl;
@@ -56,10 +70,6 @@ int cmExprParserHelper::ParseString(const char* str, int verb)
return 1;
}
-void cmExprParserHelper::CleanupParser()
-{
-}
-
int cmExprParserHelper::LexInput(char* buf, int maxlen)
{
// std::cout << "JPLexInput ";
@@ -87,7 +97,21 @@ void cmExprParserHelper::Error(const char* str)
this->ErrorString = ostr.str();
}
-void cmExprParserHelper::SetResult(int value)
+void cmExprParserHelper::UnexpectedChar(char c)
+{
+ unsigned long pos = static_cast<unsigned long>(this->InputBufferPos);
+ std::ostringstream ostr;
+ ostr << "Unexpected character in expression at position " << pos << ": " << c
+ << "\n";
+ this->WarningString += ostr.str();
+}
+
+void cmExprParserHelper::SetResult(KWIML_INT_int64_t value)
{
this->Result = value;
}
+
+void cmExprParserHelper::SetError(std::string errorString)
+{
+ this->ErrorString = std::move(errorString);
+}
diff --git a/Source/cmExprParserHelper.h b/Source/cmExprParserHelper.h
index dcdaca967..eaf5dc78a 100644
--- a/Source/cmExprParserHelper.h
+++ b/Source/cmExprParserHelper.h
@@ -8,12 +8,14 @@
#include <string>
#include <vector>
+#include "cm_kwiml.h"
+
class cmExprParserHelper
{
public:
struct ParserType
{
- int Number;
+ KWIML_INT_int64_t Number;
};
cmExprParserHelper();
@@ -24,12 +26,16 @@ public:
int LexInput(char* buf, int maxlen);
void Error(const char* str);
- void SetResult(int value);
+ void SetResult(KWIML_INT_int64_t value);
- int GetResult() { return this->Result; }
+ KWIML_INT_int64_t GetResult() { return this->Result; }
const char* GetError() { return this->ErrorString.c_str(); }
+ void UnexpectedChar(char c);
+
+ std::string const& GetWarning() const { return this->WarningString; }
+
private:
std::string::size_type InputBufferPos;
std::string InputBuffer;
@@ -39,12 +45,13 @@ private:
void Print(const char* place, const char* str);
- void CleanupParser();
+ void SetError(std::string errorString);
- int Result;
+ KWIML_INT_int64_t Result;
const char* FileName;
long FileLine;
std::string ErrorString;
+ std::string WarningString;
};
#define YYSTYPE cmExprParserHelper::ParserType
diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx
index 825ec654e..5895d666e 100644
--- a/Source/cmExternalMakefileProjectGenerator.cxx
+++ b/Source/cmExternalMakefileProjectGenerator.cxx
@@ -2,6 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExternalMakefileProjectGenerator.h"
+#include <utility>
+
+#include "cmStringAlgorithms.h"
+
class cmMakefile;
void cmExternalMakefileProjectGenerator::EnableLanguage(
@@ -16,27 +20,30 @@ std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
std::string fullName;
if (!globalGenerator.empty()) {
if (!extraGenerator.empty()) {
- fullName = extraGenerator;
- fullName += " - ";
+ fullName = cmStrCat(extraGenerator, " - ");
}
fullName += globalGenerator;
}
return fullName;
}
-cmExternalMakefileProjectGeneratorFactory::
- cmExternalMakefileProjectGeneratorFactory(const std::string& n,
- const std::string& doc)
- : Name(n)
- , Documentation(doc)
+bool cmExternalMakefileProjectGenerator::Open(
+ const std::string& /*bindir*/, const std::string& /*projectName*/,
+ bool /*dryRun*/)
{
+ return false;
}
cmExternalMakefileProjectGeneratorFactory::
- ~cmExternalMakefileProjectGeneratorFactory()
+ cmExternalMakefileProjectGeneratorFactory(std::string n, std::string doc)
+ : Name(std::move(n))
+ , Documentation(std::move(doc))
{
}
+cmExternalMakefileProjectGeneratorFactory::
+ ~cmExternalMakefileProjectGeneratorFactory() = default;
+
std::string cmExternalMakefileProjectGeneratorFactory::GetName() const
{
return this->Name;
diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h
index 6b8903790..a472a0691 100644
--- a/Source/cmExternalMakefileProjectGenerator.h
+++ b/Source/cmExternalMakefileProjectGenerator.h
@@ -17,7 +17,7 @@ class cmMakefile;
* cmExternalMakefileProjectGenerator is a base class for generators
* for "external makefile based projects", i.e. IDE projects which work
* an already existing makefiles.
- * See cmGlobalKdevelopGenerator as an example.
+ * See cmExtraEclipseCDT4Generator as an example.
* After the makefiles have been generated by one of the Makefile
* generators, the Generate() method is called and this generator
* can iterate over the local generators and/or projects to produce the
@@ -26,18 +26,18 @@ class cmMakefile;
class cmExternalMakefileProjectGenerator
{
public:
- virtual ~cmExternalMakefileProjectGenerator() {}
+ virtual ~cmExternalMakefileProjectGenerator() = default;
virtual void EnableLanguage(std::vector<std::string> const& languages,
cmMakefile*, bool optional);
- ///! set the global generator which will generate the makefiles
+ //! set the global generator which will generate the makefiles
virtual void SetGlobalGenerator(cmGlobalGenerator* generator)
{
this->GlobalGenerator = generator;
}
- ///! Return the list of global generators supported by this extra generator
+ //! Return the list of global generators supported by this extra generator
const std::vector<std::string>& GetSupportedGlobalGenerators() const
{
return this->SupportedGlobalGenerators;
@@ -49,17 +49,20 @@ public:
static std::string CreateFullGeneratorName(
const std::string& globalGenerator, const std::string& extraGenerator);
- ///! Generate the project files, the Makefiles have already been generated
+ //! Generate the project files, the Makefiles have already been generated
virtual void Generate() = 0;
void SetName(const std::string& n) { Name = n; }
std::string GetName() const { return Name; }
+ virtual bool Open(const std::string& bindir, const std::string& projectName,
+ bool dryRun);
+
protected:
- ///! Contains the names of the global generators support by this generator.
+ //! Contains the names of the global generators support by this generator.
std::vector<std::string> SupportedGlobalGenerators;
- ///! the global generator which creates the makefiles
- const cmGlobalGenerator* GlobalGenerator;
+ //! the global generator which creates the makefiles
+ const cmGlobalGenerator* GlobalGenerator = nullptr;
std::string Name;
};
@@ -67,8 +70,7 @@ protected:
class cmExternalMakefileProjectGeneratorFactory
{
public:
- cmExternalMakefileProjectGeneratorFactory(const std::string& n,
- const std::string& doc);
+ cmExternalMakefileProjectGeneratorFactory(std::string n, std::string doc);
virtual ~cmExternalMakefileProjectGeneratorFactory();
std::string GetName() const;
@@ -99,7 +101,7 @@ public:
}
cmExternalMakefileProjectGenerator* CreateExternalMakefileProjectGenerator()
- const CM_OVERRIDE
+ const override
{
T* p = new T;
p->SetName(GetName());
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 5b7b82762..5a5d95910 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -4,7 +4,7 @@
#include <map>
#include <ostream>
-#include <string.h>
+#include <set>
#include <utility>
#include "cmAlgorithms.h"
@@ -13,8 +13,10 @@
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
#include "cmake.h"
@@ -32,10 +34,7 @@ Discussion:
http://forums.codeblocks.org/index.php/topic,6789.0.html
*/
-cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator()
- : cmExternalMakefileProjectGenerator()
-{
-}
+cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator() = default;
cmExternalMakefileProjectGeneratorFactory*
cmExtraCodeBlocksGenerator::GetFactory()
@@ -62,11 +61,9 @@ cmExtraCodeBlocksGenerator::GetFactory()
void cmExtraCodeBlocksGenerator::Generate()
{
// for each sub project in the project create a codeblocks project
- for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
+ for (auto const& it : this->GlobalGenerator->GetProjectMap()) {
// create a project file
- this->CreateProjectFile(it->second);
+ this->CreateProjectFile(it.second);
}
}
@@ -77,10 +74,9 @@ void cmExtraCodeBlocksGenerator::CreateProjectFile(
std::string outputDir = lgs[0]->GetCurrentBinaryDirectory();
std::string projectName = lgs[0]->GetProjectName();
- std::string filename = outputDir + "/";
- filename += projectName + ".cbp";
- std::string sessionFilename = outputDir + "/";
- sessionFilename += projectName + ".layout";
+ std::string filename = cmStrCat(outputDir, '/', projectName, ".cbp");
+ std::string sessionFilename =
+ cmStrCat(outputDir, '/', projectName, ".layout");
this->CreateNewProjectFile(lgs, filename);
}
@@ -95,7 +91,7 @@ struct Tree
{
std::string path; // only one component of the path
std::vector<Tree> folders;
- std::vector<std::string> files;
+ std::set<std::string> files;
void InsertPath(const std::vector<std::string>& splitted,
std::vector<std::string>::size_type start,
const std::string& fileName);
@@ -112,18 +108,17 @@ void Tree::InsertPath(const std::vector<std::string>& splitted,
const std::string& fileName)
{
if (start == splitted.size()) {
- files.push_back(fileName);
+ files.insert(fileName);
return;
}
- for (std::vector<Tree>::iterator it = folders.begin(); it != folders.end();
- ++it) {
- if ((*it).path == splitted[start]) {
+ for (Tree& folder : folders) {
+ if (folder.path == splitted[start]) {
if (start + 1 < splitted.size()) {
- it->InsertPath(splitted, start + 1, fileName);
+ folder.InsertPath(splitted, start + 1, fileName);
return;
}
// last part of splitted
- it->files.push_back(fileName);
+ folder.files.insert(fileName);
return;
}
}
@@ -136,7 +131,7 @@ void Tree::InsertPath(const std::vector<std::string>& splitted,
return;
}
// last part of splitted
- newFolder.files.push_back(fileName);
+ newFolder.files.insert(fileName);
folders.push_back(newFolder);
}
@@ -144,9 +139,8 @@ void Tree::BuildVirtualFolder(cmXMLWriter& xml) const
{
xml.StartElement("Option");
std::string virtualFolders = "CMake Files\\;";
- for (std::vector<Tree>::const_iterator it = folders.begin();
- it != folders.end(); ++it) {
- it->BuildVirtualFolderImpl(virtualFolders, "");
+ for (Tree const& folder : folders) {
+ folder.BuildVirtualFolderImpl(virtualFolders, "");
}
xml.Attribute("virtualFolders", virtualFolders);
xml.EndElement();
@@ -156,18 +150,16 @@ void Tree::BuildVirtualFolderImpl(std::string& virtualFolders,
const std::string& prefix) const
{
virtualFolders += "CMake Files\\" + prefix + path + "\\;";
- for (std::vector<Tree>::const_iterator it = folders.begin();
- it != folders.end(); ++it) {
- it->BuildVirtualFolderImpl(virtualFolders, prefix + path + "\\");
+ for (Tree const& folder : folders) {
+ folder.BuildVirtualFolderImpl(virtualFolders, prefix + path + "\\");
}
}
void Tree::BuildUnit(cmXMLWriter& xml, const std::string& fsPath) const
{
- for (std::vector<std::string>::const_iterator it = files.begin();
- it != files.end(); ++it) {
+ for (std::string const& f : files) {
xml.StartElement("Unit");
- xml.Attribute("filename", fsPath + *it);
+ xml.Attribute("filename", fsPath + f);
xml.StartElement("Option");
xml.Attribute("virtualFolder", "CMake Files\\");
@@ -175,9 +167,8 @@ void Tree::BuildUnit(cmXMLWriter& xml, const std::string& fsPath) const
xml.EndElement();
}
- for (std::vector<Tree>::const_iterator it = folders.begin();
- it != folders.end(); ++it) {
- it->BuildUnitImpl(xml, "", fsPath);
+ for (Tree const& folder : folders) {
+ folder.BuildUnitImpl(xml, "", fsPath);
}
}
@@ -185,22 +176,20 @@ void Tree::BuildUnitImpl(cmXMLWriter& xml,
const std::string& virtualFolderPath,
const std::string& fsPath) const
{
- for (std::vector<std::string>::const_iterator it = files.begin();
- it != files.end(); ++it) {
+ for (std::string const& f : files) {
xml.StartElement("Unit");
- xml.Attribute("filename", fsPath + path + "/" + *it);
+ xml.Attribute("filename", cmStrCat(fsPath, path, "/", f));
xml.StartElement("Option");
xml.Attribute("virtualFolder",
- "CMake Files\\" + virtualFolderPath + path + "\\");
+ cmStrCat("CMake Files\\", virtualFolderPath, path, "\\"));
xml.EndElement();
xml.EndElement();
}
- for (std::vector<Tree>::const_iterator it = folders.begin();
- it != folders.end(); ++it) {
- it->BuildUnitImpl(xml, virtualFolderPath + path + "\\",
- fsPath + path + "/");
+ for (Tree const& folder : folders) {
+ folder.BuildUnitImpl(xml, cmStrCat(virtualFolderPath, path, "\\"),
+ cmStrCat(fsPath, path, "/"));
}
}
@@ -208,7 +197,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
const std::vector<cmLocalGenerator*>& lgs, const std::string& filename)
{
const cmMakefile* mf = lgs[0]->GetMakefile();
- cmGeneratedFileStream fout(filename.c_str());
+ cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -216,29 +205,22 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
Tree tree;
// build tree of virtual folders
- for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
+ for (auto const& it : this->GlobalGenerator->GetProjectMap()) {
// Collect all files
std::vector<std::string> listFiles;
- for (std::vector<cmLocalGenerator*>::const_iterator jt =
- it->second.begin();
- jt != it->second.end(); ++jt) {
- const std::vector<std::string>& files =
- (*jt)->GetMakefile()->GetListFiles();
- listFiles.insert(listFiles.end(), files.begin(), files.end());
+ for (cmLocalGenerator* lg : it.second) {
+ cmAppend(listFiles, lg->GetMakefile()->GetListFiles());
}
// Convert
- for (std::vector<std::string>::const_iterator jt = listFiles.begin();
- jt != listFiles.end(); ++jt) {
+ for (std::string const& listFile : listFiles) {
// don't put cmake's own files into the project (#12110):
- if (jt->find(cmSystemTools::GetCMakeRoot()) == 0) {
+ if (listFile.find(cmSystemTools::GetCMakeRoot()) == 0) {
continue;
}
const std::string& relative = cmSystemTools::RelativePath(
- it->second[0]->GetSourceDirectory(), jt->c_str());
+ it.second[0]->GetSourceDirectory(), listFile);
std::vector<std::string> splitted;
cmSystemTools::SplitPath(relative, splitted, false);
// Split filename from path
@@ -248,7 +230,14 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
// We don't want paths with CMakeFiles in them
// or do we?
// In speedcrunch those where purely internal
+ //
+ // Also we can disable external (outside the project) files by setting ON
+ // CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES variable.
+ const bool excludeExternal =
+ cmIsOn(it.second[0]->GetMakefile()->GetSafeDefinition(
+ "CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES"));
if (!splitted.empty() &&
+ (!excludeExternal || (relative.find("..") == std::string::npos)) &&
relative.find("CMakeFiles") == std::string::npos) {
tree.InsertPath(splitted, 1, fileName);
}
@@ -257,8 +246,8 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
// figure out the compiler
std::string compiler = this->GetCBCompilerId(mf);
- std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
- const std::string makeArgs =
+ const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
+ const std::string& makeArgs =
mf->GetSafeDefinition("CMAKE_CODEBLOCKS_MAKE_ARGUMENTS");
cmXMLWriter xml(fout);
@@ -289,25 +278,21 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
xml.StartElement("Build");
- this->AppendTarget(xml, "all", CM_NULLPTR, make.c_str(), lgs[0],
- compiler.c_str(), makeArgs);
+ this->AppendTarget(xml, "all", nullptr, make, lgs[0], compiler, makeArgs);
// add all executable and library targets and some of the GLOBAL
// and UTILITY targets
- for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
- lg != lgs.end(); lg++) {
- std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
- ti != targets.end(); ti++) {
- std::string targetName = (*ti)->GetName();
- switch ((*ti)->GetType()) {
+ for (cmLocalGenerator* lg : lgs) {
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ std::string targetName = target->GetName();
+ switch (target->GetType()) {
case cmStateEnums::GLOBAL_TARGET: {
// Only add the global targets from CMAKE_BINARY_DIR,
// not from the subdirs
- if (strcmp((*lg)->GetCurrentBinaryDirectory(),
- (*lg)->GetBinaryDirectory()) == 0) {
- this->AppendTarget(xml, targetName, CM_NULLPTR, make.c_str(), *lg,
- compiler.c_str(), makeArgs);
+ if (lg->GetCurrentBinaryDirectory() == lg->GetBinaryDirectory()) {
+ this->AppendTarget(xml, targetName, nullptr, make, lg, compiler,
+ makeArgs);
}
} break;
case cmStateEnums::UTILITY:
@@ -322,21 +307,20 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
break;
}
- this->AppendTarget(xml, targetName, CM_NULLPTR, make.c_str(), *lg,
- compiler.c_str(), makeArgs);
+ this->AppendTarget(xml, targetName, nullptr, make, lg, compiler,
+ makeArgs);
break;
case cmStateEnums::EXECUTABLE:
case cmStateEnums::STATIC_LIBRARY:
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::OBJECT_LIBRARY: {
- cmGeneratorTarget* gt = *ti;
- this->AppendTarget(xml, targetName, gt, make.c_str(), *lg,
- compiler.c_str(), makeArgs);
- std::string fastTarget = targetName;
- fastTarget += "/fast";
- this->AppendTarget(xml, fastTarget, gt, make.c_str(), *lg,
- compiler.c_str(), makeArgs);
+ cmGeneratorTarget* gt = target;
+ this->AppendTarget(xml, targetName, gt, make, lg, compiler,
+ makeArgs);
+ std::string fastTarget = cmStrCat(targetName, "/fast");
+ this->AppendTarget(xml, fastTarget, gt, make, lg, compiler,
+ makeArgs);
} break;
default:
break;
@@ -347,22 +331,19 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
xml.EndElement(); // Build
// Collect all used source files in the project.
- // Keep a list of C/C++ source files which might have an acompanying header
+ // Keep a list of C/C++ source files which might have an accompanying header
// that should be looked for.
- typedef std::map<std::string, CbpUnit> all_files_map_t;
+ using all_files_map_t = std::map<std::string, CbpUnit>;
all_files_map_t allFiles;
std::vector<std::string> cFiles;
- std::vector<std::string> const& srcExts =
- this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions();
+ auto cm = this->GlobalGenerator->GetCMakeInstance();
- for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
- lg != lgs.end(); lg++) {
- cmMakefile* makefile = (*lg)->GetMakefile();
- std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
- ti != targets.end(); ti++) {
- switch ((*ti)->GetType()) {
+ for (cmLocalGenerator* lg : lgs) {
+ cmMakefile* makefile = lg->GetMakefile();
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ switch (target->GetType()) {
case cmStateEnums::EXECUTABLE:
case cmStateEnums::STATIC_LIBRARY:
case cmStateEnums::SHARED_LIBRARY:
@@ -371,41 +352,46 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
case cmStateEnums::UTILITY: // can have sources since 2.6.3
{
std::vector<cmSourceFile*> sources;
- cmGeneratorTarget* gt = *ti;
+ cmGeneratorTarget* gt = target;
gt->GetSourceFiles(sources,
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); si++) {
+ for (cmSourceFile* s : sources) {
// don't add source files from UTILITY target which have the
// GENERATED property set:
if (gt->GetType() == cmStateEnums::UTILITY &&
- (*si)->GetPropertyAsBool("GENERATED")) {
+ s->GetIsGenerated()) {
continue;
}
- // check whether it is a C/C++ implementation file
+ // check whether it is a C/C++/CUDA implementation file
bool isCFile = false;
- std::string lang = (*si)->GetLanguage();
- if (lang == "C" || lang == "CXX") {
- std::string const& srcext = (*si)->GetExtension();
- for (std::vector<std::string>::const_iterator ext =
- srcExts.begin();
- ext != srcExts.end(); ++ext) {
- if (srcext == *ext) {
- isCFile = true;
- break;
- }
- }
+ std::string lang = s->GetOrDetermineLanguage();
+ if (lang == "C" || lang == "CXX" || lang == "CUDA") {
+ std::string const& srcext = s->GetExtension();
+ isCFile = cm->IsSourceExtension(srcext);
}
- std::string const& fullPath = (*si)->GetFullPath();
+ std::string const& fullPath = s->ResolveFullPath();
+
+ // Check file position relative to project root dir.
+ const std::string relative =
+ cmSystemTools::RelativePath(lg->GetSourceDirectory(), fullPath);
+ // Do not add this file if it has ".." in relative path and
+ // if CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES variable is on.
+ const bool excludeExternal =
+ cmIsOn(lg->GetMakefile()->GetSafeDefinition(
+ "CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES"));
+ if (excludeExternal &&
+ (relative.find("..") != std::string::npos)) {
+ continue;
+ }
if (isCFile) {
cFiles.push_back(fullPath);
}
CbpUnit& cbpUnit = allFiles[fullPath];
- cbpUnit.Targets.push_back(*ti);
+ cbpUnit.Targets.push_back(target);
}
}
default: // intended fallthrough
@@ -422,27 +408,22 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
// C/C++ source files,
// replacing the file name extension with ".h" and checks whether such a
// file exists. If it does, it is inserted into the map of files.
- // A very similar version of that code exists also in the kdevelop
+ // A very similar version of that code exists also in the CodeLite
// project generator.
- for (std::vector<std::string>::const_iterator sit = cFiles.begin();
- sit != cFiles.end(); ++sit) {
- std::string const& fileName = *sit;
- std::string headerBasename = cmSystemTools::GetFilenamePath(fileName);
- headerBasename += "/";
- headerBasename += cmSystemTools::GetFilenameWithoutExtension(fileName);
+ for (std::string const& fileName : cFiles) {
+ std::string headerBasename =
+ cmStrCat(cmSystemTools::GetFilenamePath(fileName), '/',
+ cmSystemTools::GetFilenameWithoutExtension(fileName));
// check if there's a matching header around
- for (std::vector<std::string>::const_iterator ext = headerExts.begin();
- ext != headerExts.end(); ++ext) {
- std::string hname = headerBasename;
- hname += ".";
- hname += *ext;
+ for (std::string const& ext : headerExts) {
+ std::string hname = cmStrCat(headerBasename, '.', ext);
// if it's already in the set, don't check if it exists on disk
if (allFiles.find(hname) != allFiles.end()) {
break;
}
- if (cmSystemTools::FileExists(hname.c_str())) {
+ if (cmSystemTools::FileExists(hname)) {
allFiles[hname].Targets = allFiles[fileName].Targets;
break;
}
@@ -450,19 +431,16 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
}
// insert all source files in the CodeBlocks project
- for (all_files_map_t::const_iterator sit = allFiles.begin();
- sit != allFiles.end(); ++sit) {
- std::string const& unitFilename = sit->first;
- CbpUnit const& unit = sit->second;
+ for (auto const& s : allFiles) {
+ std::string const& unitFilename = s.first;
+ CbpUnit const& unit = s.second;
xml.StartElement("Unit");
xml.Attribute("filename", unitFilename);
- for (std::vector<const cmGeneratorTarget*>::const_iterator ti =
- unit.Targets.begin();
- ti != unit.Targets.end(); ++ti) {
+ for (cmGeneratorTarget const* tgt : unit.Targets) {
xml.StartElement("Option");
- xml.Attribute("target", (*ti)->GetName());
+ xml.Attribute("target", tgt->GetName());
xml.EndElement();
}
@@ -470,7 +448,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
}
// Add CMakeLists.txt
- tree.BuildUnit(xml, std::string(mf->GetHomeDirectory()) + "/");
+ tree.BuildUnit(xml, mf->GetHomeDirectory() + "/");
xml.EndElement(); // Project
xml.EndElement(); // CodeBlocks_project_file
@@ -484,13 +462,10 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
// this file doesn't seem to be used by C::B in custom makefile mode,
// but we generate a unique file for each OBJECT library so in case
// C::B uses it in some way, the targets don't interfere with each other.
- std::string filename = lg->GetCurrentBinaryDirectory();
- filename += "/";
- filename += lg->GetTargetDirectory(target);
- filename += "/";
- filename += target->GetName();
- filename += ".objlib";
- cmGeneratedFileStream fout(filename.c_str());
+ std::string filename = cmStrCat(lg->GetCurrentBinaryDirectory(), '/',
+ lg->GetTargetDirectory(target), '/',
+ target->GetName(), ".objlib");
+ cmGeneratedFileStream fout(filename);
if (fout) {
/* clang-format off */
fout << "# This is a dummy file for the OBJECT library "
@@ -505,17 +480,17 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
// Generate the xml code for one target.
void cmExtraCodeBlocksGenerator::AppendTarget(
cmXMLWriter& xml, const std::string& targetName, cmGeneratorTarget* target,
- const char* make, const cmLocalGenerator* lg, const char* compiler,
- const std::string& makeFlags)
+ const std::string& make, const cmLocalGenerator* lg,
+ const std::string& compiler, const std::string& makeFlags)
{
cmMakefile const* makefile = lg->GetMakefile();
- std::string makefileName = lg->GetCurrentBinaryDirectory();
- makefileName += "/Makefile";
+ std::string makefileName =
+ cmStrCat(lg->GetCurrentBinaryDirectory(), "/Makefile");
xml.StartElement("Target");
xml.Attribute("title", targetName);
- if (target != CM_NULLPTR) {
+ if (target != nullptr) {
int cbTargetType = this->GetCBTargetType(target);
std::string workingDir = lg->GetCurrentBinaryDirectory();
if (target->GetType() == cmStateEnums::EXECUTABLE) {
@@ -523,12 +498,12 @@ void cmExtraCodeBlocksGenerator::AppendTarget(
// set the working directory to this dir.
const char* runtimeOutputDir =
makefile->GetDefinition("CMAKE_RUNTIME_OUTPUT_DIRECTORY");
- if (runtimeOutputDir != CM_NULLPTR) {
+ if (runtimeOutputDir != nullptr) {
workingDir = runtimeOutputDir;
} else {
const char* executableOutputDir =
makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
- if (executableOutputDir != CM_NULLPTR) {
+ if (executableOutputDir != nullptr) {
workingDir = executableOutputDir;
}
}
@@ -572,45 +547,37 @@ void cmExtraCodeBlocksGenerator::AppendTarget(
target->GetCompileDefinitions(cdefs, buildType, "C");
// Expand the list.
- for (std::vector<std::string>::const_iterator di = cdefs.begin();
- di != cdefs.end(); ++di) {
+ for (std::string const& d : cdefs) {
xml.StartElement("Add");
- xml.Attribute("option", "-D" + *di);
+ xml.Attribute("option", "-D" + d);
xml.EndElement();
}
// the include directories for this target
std::vector<std::string> allIncludeDirs;
-
- std::vector<std::string> includes;
- lg->GetIncludeDirectories(includes, target, "C", buildType);
-
- allIncludeDirs.insert(allIncludeDirs.end(), includes.begin(),
- includes.end());
+ {
+ std::vector<std::string> includes;
+ lg->GetIncludeDirectories(includes, target, "C", buildType);
+ cmAppend(allIncludeDirs, includes);
+ }
std::string systemIncludeDirs = makefile->GetSafeDefinition(
"CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
if (!systemIncludeDirs.empty()) {
- std::vector<std::string> dirs;
- cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
- allIncludeDirs.insert(allIncludeDirs.end(), dirs.begin(), dirs.end());
+ cmAppend(allIncludeDirs, cmExpandedList(systemIncludeDirs));
}
systemIncludeDirs = makefile->GetSafeDefinition(
"CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
if (!systemIncludeDirs.empty()) {
- std::vector<std::string> dirs;
- cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
- allIncludeDirs.insert(allIncludeDirs.end(), dirs.begin(), dirs.end());
+ cmAppend(allIncludeDirs, cmExpandedList(systemIncludeDirs));
}
- std::vector<std::string>::const_iterator end =
- cmRemoveDuplicates(allIncludeDirs);
+ auto end = cmRemoveDuplicates(allIncludeDirs);
- for (std::vector<std::string>::const_iterator i = allIncludeDirs.begin();
- i != end; ++i) {
+ for (std::string const& str : cmMakeRange(allIncludeDirs.cbegin(), end)) {
xml.StartElement("Add");
- xml.Attribute("directory", *i);
+ xml.Attribute("directory", str);
xml.EndElement();
}
@@ -629,23 +596,25 @@ void cmExtraCodeBlocksGenerator::AppendTarget(
xml.StartElement("MakeCommands");
xml.StartElement("Build");
- xml.Attribute("command", this->BuildMakeCommand(make, makefileName.c_str(),
- targetName, makeFlags));
+ xml.Attribute(
+ "command",
+ this->BuildMakeCommand(make, makefileName, targetName, makeFlags));
xml.EndElement();
xml.StartElement("CompileFile");
- xml.Attribute("command", this->BuildMakeCommand(make, makefileName.c_str(),
- "\"$file\"", makeFlags));
+ xml.Attribute(
+ "command",
+ this->BuildMakeCommand(make, makefileName, "\"$file\"", makeFlags));
xml.EndElement();
xml.StartElement("Clean");
- xml.Attribute("command", this->BuildMakeCommand(make, makefileName.c_str(),
- "clean", makeFlags));
+ xml.Attribute(
+ "command", this->BuildMakeCommand(make, makefileName, "clean", makeFlags));
xml.EndElement();
xml.StartElement("DistClean");
- xml.Attribute("command", this->BuildMakeCommand(make, makefileName.c_str(),
- "clean", makeFlags));
+ xml.Attribute(
+ "command", this->BuildMakeCommand(make, makefileName, "clean", makeFlags));
xml.EndElement();
xml.EndElement(); // MakeCommands
@@ -655,6 +624,13 @@ void cmExtraCodeBlocksGenerator::AppendTarget(
// Translate the cmake compiler id into the CodeBlocks compiler id
std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
{
+ // allow the user to overwrite the detected compiler
+ std::string userCompiler =
+ mf->GetSafeDefinition("CMAKE_CODEBLOCKS_COMPILER_ID");
+ if (!userCompiler.empty()) {
+ return userCompiler;
+ }
+
// figure out which language to use
// for now care only for C, C++, and Fortran
@@ -670,7 +646,7 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
pureFortran = true;
}
- std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
+ std::string const& compilerId = mf->GetSafeDefinition(compilerIdVar);
std::string compiler = "gcc"; // default to gcc
if (compilerId == "MSVC") {
if (mf->IsDefinitionSet("MSVC10")) {
@@ -732,8 +708,8 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target)
// Create the command line for building the given target using the selected
// make
std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
- const std::string& make, const char* makefile, const std::string& target,
- const std::string& makeFlags)
+ const std::string& make, const std::string& makefile,
+ const std::string& target, const std::string& makeFlags)
{
std::string command = make;
if (!makeFlags.empty()) {
@@ -754,7 +730,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
} else if (generator == "MinGW Makefiles") {
// no escaping of spaces in this case, see
// https://gitlab.kitware.com/cmake/cmake/issues/10014
- std::string makefileName = makefile;
+ std::string const& makefileName = makefile;
command += " -f \"";
command += makefileName;
command += "\" ";
diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h
index 450a9d02c..d9f92bde5 100644
--- a/Source/cmExtraCodeBlocksGenerator.h
+++ b/Source/cmExtraCodeBlocksGenerator.h
@@ -3,13 +3,13 @@
#ifndef cmExtraCodeBlocksGenerator_h
#define cmExtraCodeBlocksGenerator_h
-#include "cmConfigure.h"
-
-#include "cmExternalMakefileProjectGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
+#include "cmExternalMakefileProjectGenerator.h"
+
class cmGeneratorTarget;
class cmLocalGenerator;
class cmMakefile;
@@ -25,7 +25,7 @@ public:
static cmExternalMakefileProjectGeneratorFactory* GetFactory();
- void Generate() CM_OVERRIDE;
+ void Generate() override;
private:
struct CbpUnit
@@ -42,12 +42,13 @@ private:
std::string GetCBCompilerId(const cmMakefile* mf);
int GetCBTargetType(cmGeneratorTarget* target);
- std::string BuildMakeCommand(const std::string& make, const char* makefile,
+ std::string BuildMakeCommand(const std::string& make,
+ const std::string& makefile,
const std::string& target,
const std::string& makeFlags);
void AppendTarget(cmXMLWriter& xml, const std::string& targetName,
- cmGeneratorTarget* target, const char* make,
- const cmLocalGenerator* lg, const char* compiler,
+ cmGeneratorTarget* target, const std::string& make,
+ const cmLocalGenerator* lg, const std::string& compiler,
const std::string& makeFlags);
};
diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index b478f34fa..c7b74570f 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -2,6 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExtraCodeLiteGenerator.h"
+#include <cstring>
+#include <map>
+#include <set>
+#include <sstream>
+#include <utility>
+
+#include "cmsys/SystemInformation.hxx"
+
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
@@ -9,21 +17,13 @@
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
#include "cmake.h"
-#include "cmsys/SystemInformation.hxx"
-#include <map>
-#include <set>
-#include <sstream>
-#include <string.h>
-#include <utility>
-
cmExtraCodeLiteGenerator::cmExtraCodeLiteGenerator()
- : cmExternalMakefileProjectGenerator()
- , ConfigName("NoConfig")
- , CpuCount(2)
+ : ConfigName("NoConfig")
{
}
@@ -54,32 +54,29 @@ void cmExtraCodeLiteGenerator::Generate()
std::string workspaceFileName;
std::string workspaceSourcePath;
- const std::map<std::string, std::vector<cmLocalGenerator*> >& projectMap =
+ const std::map<std::string, std::vector<cmLocalGenerator*>>& projectMap =
this->GlobalGenerator->GetProjectMap();
// loop projects and locate the root project.
// and extract the information for creating the worspace
// root makefile
- for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
- it = projectMap.begin();
- it != projectMap.end(); ++it) {
- const cmMakefile* mf = it->second[0]->GetMakefile();
+ for (auto const& it : projectMap) {
+ cmLocalGenerator* lg = it.second[0];
+ const cmMakefile* mf = lg->GetMakefile();
this->ConfigName = GetConfigurationName(mf);
- if (strcmp(it->second[0]->GetCurrentBinaryDirectory(),
- it->second[0]->GetBinaryDirectory()) == 0) {
- workspaceOutputDir = it->second[0]->GetCurrentBinaryDirectory();
- workspaceProjectName = it->second[0]->GetProjectName();
- workspaceSourcePath = it->second[0]->GetSourceDirectory();
- workspaceFileName = workspaceOutputDir + "/";
- workspaceFileName += workspaceProjectName + ".workspace";
- this->WorkspacePath = it->second[0]->GetCurrentBinaryDirectory();
- ;
+ if (lg->GetCurrentBinaryDirectory() == lg->GetBinaryDirectory()) {
+ workspaceOutputDir = lg->GetCurrentBinaryDirectory();
+ workspaceProjectName = lg->GetProjectName();
+ workspaceSourcePath = lg->GetSourceDirectory();
+ workspaceFileName =
+ cmStrCat(workspaceOutputDir, '/', workspaceProjectName, ".workspace");
+ this->WorkspacePath = lg->GetCurrentBinaryDirectory();
break;
}
}
- cmGeneratedFileStream fout(workspaceFileName.c_str());
+ cmGeneratedFileStream fout(workspaceFileName);
cmXMLWriter xml(fout);
xml.StartDocument("utf-8");
@@ -101,10 +98,9 @@ void cmExtraCodeLiteGenerator::Generate()
xml.Attribute("Name", this->ConfigName);
xml.Attribute("Selected", "yes");
- for (std::vector<std::string>::iterator it(ProjectNames.begin());
- it != ProjectNames.end(); it++) {
+ for (std::string const& it : ProjectNames) {
xml.StartElement("Project");
- xml.Attribute("Name", *it);
+ xml.Attribute("Name", it);
xml.Attribute("ConfigName", this->ConfigName);
xml.EndElement();
}
@@ -122,25 +118,22 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByTarget(
// for each target in the workspace create a codelite project
const std::vector<cmLocalGenerator*>& lgs =
this->GlobalGenerator->GetLocalGenerators();
- for (std::vector<cmLocalGenerator*>::const_iterator lg(lgs.begin());
- lg != lgs.end(); lg++) {
- for (std::vector<cmGeneratorTarget*>::const_iterator lt =
- (*lg)->GetGeneratorTargets().begin();
- lt != (*lg)->GetGeneratorTargets().end(); lt++) {
- cmStateEnums::TargetType type = (*lt)->GetType();
- std::string outputDir = (*lg)->GetCurrentBinaryDirectory();
- std::string targetName = (*lt)->GetName();
- std::string filename = outputDir + "/" + targetName + ".project";
+ for (cmLocalGenerator* lg : lgs) {
+ for (cmGeneratorTarget* lt : lg->GetGeneratorTargets()) {
+ cmStateEnums::TargetType type = lt->GetType();
+ std::string const& outputDir = lg->GetCurrentBinaryDirectory();
+ std::string targetName = lt->GetName();
+ std::string filename = cmStrCat(outputDir, "/", targetName, ".project");
retval.push_back(targetName);
// Make the project file relative to the workspace
- std::string relafilename = cmSystemTools::RelativePath(
- this->WorkspacePath.c_str(), filename.c_str());
+ std::string relafilename =
+ cmSystemTools::RelativePath(this->WorkspacePath, filename);
std::string visualname = targetName;
switch (type) {
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::STATIC_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
- visualname = "lib" + visualname;
+ visualname = cmStrCat("lib", visualname);
CM_FALLTHROUGH;
case cmStateEnums::EXECUTABLE:
xml->StartElement("Project");
@@ -149,7 +142,7 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByTarget(
xml->Attribute("Active", "No");
xml->EndElement();
- CreateNewProjectFile(*lt, filename);
+ CreateNewProjectFile(lt, filename);
break;
default:
break;
@@ -165,21 +158,18 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByProjectMaps(
{
std::vector<std::string> retval;
// for each sub project in the workspace create a codelite project
- for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it != this->GlobalGenerator->GetProjectMap().end(); it++) {
+ for (auto const& it : this->GlobalGenerator->GetProjectMap()) {
- std::string outputDir = it->second[0]->GetCurrentBinaryDirectory();
- std::string projectName = it->second[0]->GetProjectName();
+ std::string const& outputDir = it.second[0]->GetCurrentBinaryDirectory();
+ std::string projectName = it.second[0]->GetProjectName();
retval.push_back(projectName);
- std::string filename = outputDir + "/" + projectName + ".project";
+ std::string filename = cmStrCat(outputDir, "/", projectName, ".project");
// Make the project file relative to the workspace
- filename = cmSystemTools::RelativePath(this->WorkspacePath.c_str(),
- filename.c_str());
+ filename = cmSystemTools::RelativePath(this->WorkspacePath, filename);
// create a project file
- this->CreateProjectFile(it->second);
+ this->CreateProjectFile(it.second);
xml->StartElement("Project");
xml->Attribute("Name", projectName);
xml->Attribute("Path", filename);
@@ -193,7 +183,7 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByProjectMaps(
void cmExtraCodeLiteGenerator::CreateProjectFile(
const std::vector<cmLocalGenerator*>& lgs)
{
- std::string outputDir = lgs[0]->GetCurrentBinaryDirectory();
+ std::string const& outputDir = lgs[0]->GetCurrentBinaryDirectory();
std::string projectName = lgs[0]->GetProjectName();
std::string filename = outputDir + "/";
@@ -206,9 +196,6 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles(
std::map<std::string, cmSourceFile*>& cFiles,
std::set<std::string>& otherFiles)
{
- const std::vector<std::string>& srcExts =
- this->GlobalGenerator->GetCMakeInstance()->GetSourceExtensions();
-
std::string projectType;
switch (gt->GetType()) {
case cmStateEnums::EXECUTABLE: {
@@ -232,30 +219,21 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles(
case cmStateEnums::STATIC_LIBRARY:
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY: {
+ cmake const* cm = makefile->GetCMakeInstance();
std::vector<cmSourceFile*> sources;
gt->GetSourceFiles(sources,
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); si++) {
- // check whether it is a C/C++ implementation file
- bool isCFile = false;
- std::string lang = (*si)->GetLanguage();
- if (lang == "C" || lang == "CXX") {
- std::string const& srcext = (*si)->GetExtension();
- for (std::vector<std::string>::const_iterator ext = srcExts.begin();
- ext != srcExts.end(); ++ext) {
- if (srcext == *ext) {
- isCFile = true;
- break;
- }
- }
- }
-
+ for (cmSourceFile* s : sources) {
+ std::string const& fullPath = s->ResolveFullPath();
+ std::string const& extLower =
+ cmSystemTools::LowerCase(s->GetExtension());
+ // check whether it is a source or a include file
// then put it accordingly into one of the two containers
- if (isCFile) {
- cFiles[(*si)->GetFullPath()] = *si;
+ if (cm->IsSourceExtension(extLower) || cm->IsCudaExtension(extLower) ||
+ cm->IsFortranExtension(extLower)) {
+ cFiles[fullPath] = s;
} else {
- otherFiles.insert((*si)->GetFullPath());
+ otherFiles.insert(fullPath);
}
}
}
@@ -269,7 +247,7 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile(
const std::vector<cmLocalGenerator*>& lgs, const std::string& filename)
{
const cmMakefile* mf = lgs[0]->GetMakefile();
- cmGeneratedFileStream fout(filename.c_str());
+ cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -285,17 +263,15 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile(
// Collect all used source files in the project
// Sort them into two containers, one for C/C++ implementation files
- // which may have an acompanying header, one for all other files
+ // which may have an accompanying header, one for all other files
std::map<std::string, cmSourceFile*> cFiles;
std::set<std::string> otherFiles;
- for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
- lg != lgs.end(); lg++) {
- cmMakefile* makefile = (*lg)->GetMakefile();
- std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
- ti != targets.end(); ti++) {
- projectType = CollectSourceFiles(makefile, *ti, cFiles, otherFiles);
+ for (cmLocalGenerator* lg : lgs) {
+ cmMakefile* makefile = lg->GetMakefile();
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ projectType = CollectSourceFiles(makefile, target, cFiles, otherFiles);
}
}
@@ -321,28 +297,23 @@ void cmExtraCodeLiteGenerator::FindMatchingHeaderfiles(
// files to the project. It does that by iterating over all source files,
// replacing the file name extension with ".h" and checks whether such a
// file exists. If it does, it is inserted into the map of files.
- // A very similar version of that code exists also in the kdevelop
+ // A very similar version of that code exists also in the CodeBlocks
// project generator.
- for (std::map<std::string, cmSourceFile*>::const_iterator sit =
- cFiles.begin();
- sit != cFiles.end(); ++sit) {
- std::string headerBasename = cmSystemTools::GetFilenamePath(sit->first);
- headerBasename += "/";
- headerBasename += cmSystemTools::GetFilenameWithoutExtension(sit->first);
+ for (auto const& sit : cFiles) {
+ std::string headerBasename =
+ cmStrCat(cmSystemTools::GetFilenamePath(sit.first), '/',
+ cmSystemTools::GetFilenameWithoutExtension(sit.first));
// check if there's a matching header around
- for (std::vector<std::string>::const_iterator ext = headerExts.begin();
- ext != headerExts.end(); ++ext) {
- std::string hname = headerBasename;
- hname += ".";
- hname += *ext;
+ for (std::string const& ext : headerExts) {
+ std::string hname = cmStrCat(headerBasename, '.', ext);
// if it's already in the set, don't check if it exists on disk
- std::set<std::string>::const_iterator headerIt = otherFiles.find(hname);
+ auto headerIt = otherFiles.find(hname);
if (headerIt != otherFiles.end()) {
break;
}
- if (cmSystemTools::FileExists(hname.c_str())) {
+ if (cmSystemTools::FileExists(hname)) {
otherFiles.insert(hname);
break;
}
@@ -358,10 +329,8 @@ void cmExtraCodeLiteGenerator::CreateFoldersAndFiles(
std::vector<std::string> components;
size_t numOfEndEl = 0;
- for (std::set<std::string>::const_iterator it = cFiles.begin();
- it != cFiles.end(); ++it) {
- std::string frelapath =
- cmSystemTools::RelativePath(projectPath.c_str(), it->c_str());
+ for (std::string const& cFile : cFiles) {
+ std::string frelapath = cmSystemTools::RelativePath(projectPath, cFile);
cmsys::SystemTools::SplitPath(frelapath, components, false);
components.pop_back(); // erase last member -> it is file, not folder
components.erase(components.begin()); // erase "root"
@@ -423,10 +392,8 @@ void cmExtraCodeLiteGenerator::CreateFoldersAndFiles(
const std::string& projectPath)
{
std::set<std::string> s;
- for (std::map<std::string, cmSourceFile*>::const_iterator it =
- cFiles.begin();
- it != cFiles.end(); ++it) {
- s.insert(it->first);
+ for (auto const& it : cFiles) {
+ s.insert(it.first);
}
this->CreateFoldersAndFiles(s, xml, projectPath);
}
@@ -437,7 +404,6 @@ void cmExtraCodeLiteGenerator::CreateProjectSourceEntries(
const std::string& projectPath, const cmMakefile* mf,
const std::string& projectType, const std::string& targetName)
{
-
cmXMLWriter& xml(*_xml);
FindMatchingHeaderfiles(cFiles, otherFiles);
// Create 2 virtual folders: src and include
@@ -498,11 +464,14 @@ void cmExtraCodeLiteGenerator::CreateProjectSourceEntries(
xml.EndElement(); // ResourceCompiler
xml.StartElement("General");
- std::string outputPath = mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
+ std::string outputPath =
+ mf->GetSafeDefinition("CMAKE_RUNTIME_OUTPUT_DIRECTORY");
+ if (outputPath.empty()) {
+ outputPath = mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH");
+ }
std::string relapath;
if (!outputPath.empty()) {
- relapath = cmSystemTools::RelativePath(this->WorkspacePath.c_str(),
- outputPath.c_str());
+ relapath = cmSystemTools::RelativePath(projectPath, outputPath);
xml.Attribute("OutputFile", relapath + "/$(ProjectName)");
} else {
xml.Attribute("OutputFile", "$(IntermediateDirectory)/$(ProjectName)");
@@ -574,7 +543,7 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile(
const cmGeneratorTarget* gt, const std::string& filename)
{
const cmMakefile* mf = gt->Makefile;
- cmGeneratedFileStream fout(filename.c_str());
+ cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -598,7 +567,7 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile(
// Collect all used source files in the project
// Sort them into two containers, one for C/C++ implementation files
- // which may have an acompanying header, one for all other files
+ // which may have an accompanying header, one for all other files
std::string projectType;
std::map<std::string, cmSourceFile*> cFiles;
@@ -626,7 +595,7 @@ std::string cmExtraCodeLiteGenerator::GetCodeLiteCompilerName(
compilerIdVar = "CMAKE_C_COMPILER_ID";
}
- std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
+ std::string const& compilerId = mf->GetSafeDefinition(compilerIdVar);
std::string compiler = "gnu g++"; // default to g++
// Since we need the compiler for parsing purposes only
@@ -658,14 +627,14 @@ std::string cmExtraCodeLiteGenerator::GetConfigurationName(
std::string cmExtraCodeLiteGenerator::GetBuildCommand(
const cmMakefile* mf, const std::string& targetName) const
{
- std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
- std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
+ const std::string& generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
+ const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
std::string buildCommand = make; // Default
std::ostringstream ss;
if (generator == "NMake Makefiles" || generator == "Ninja") {
ss << make;
} else if (generator == "MinGW Makefiles" || generator == "Unix Makefiles") {
- ss << make << " -j " << this->CpuCount;
+ ss << make << " -f$(ProjectPath)/Makefile -j " << this->CpuCount;
}
if (!targetName.empty()) {
ss << " " << targetName;
@@ -699,11 +668,15 @@ std::string cmExtraCodeLiteGenerator::GetSingleFileBuildCommand(
const cmMakefile* mf) const
{
std::string buildCommand;
- std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
- std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
+ const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
+ const std::string& generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
if (generator == "Unix Makefiles" || generator == "MinGW Makefiles") {
std::ostringstream ss;
- ss << make << " -f$(ProjectPath)/Makefile $(CurrentFileName).cpp.o";
+#if defined(_WIN32)
+ ss << make << " -f$(ProjectPath)/Makefile -B $(CurrentFileFullName).obj";
+#else
+ ss << make << " -f$(ProjectPath)/Makefile -B $(CurrentFileFullName).o";
+#endif
buildCommand = ss.str();
}
return buildCommand;
diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h
index de330988d..0ce90b093 100644
--- a/Source/cmExtraCodeLiteGenerator.h
+++ b/Source/cmExtraCodeLiteGenerator.h
@@ -3,15 +3,15 @@
#ifndef cmGlobalCodeLiteGenerator_h
#define cmGlobalCodeLiteGenerator_h
-#include "cmConfigure.h"
-
-#include "cmExternalMakefileProjectGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
#include <set>
#include <string>
#include <vector>
+#include "cmExternalMakefileProjectGenerator.h"
+
class cmLocalGenerator;
class cmMakefile;
class cmGeneratorTarget;
@@ -23,7 +23,7 @@ class cmExtraCodeLiteGenerator : public cmExternalMakefileProjectGenerator
protected:
std::string ConfigName;
std::string WorkspacePath;
- unsigned int CpuCount;
+ unsigned int CpuCount = 2;
protected:
std::string GetCodeLiteCompilerName(const cmMakefile* mf) const;
@@ -60,7 +60,7 @@ public:
static cmExternalMakefileProjectGeneratorFactory* GetFactory();
- void Generate() CM_OVERRIDE;
+ void Generate() override;
void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index 2a6ce98a7..b286acf0c 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -2,24 +2,27 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExtraEclipseCDT4Generator.h"
-#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
#include <map>
#include <sstream>
-#include <stdio.h>
#include <utility>
+#include "cmsys/RegularExpression.hxx"
+
#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmSourceFile.h"
#include "cmSourceGroup.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmXMLWriter.h"
#include "cmake.h"
@@ -42,8 +45,9 @@ void AppendDictionary(cmXMLWriter& xml, const char* key, T const& value)
}
cmExtraEclipseCDT4Generator::cmExtraEclipseCDT4Generator()
- : cmExternalMakefileProjectGenerator()
{
+ this->IsOutOfSourceBuild = false;
+ this->GenerateSourceProject = false;
this->SupportsVirtualFolders = true;
this->GenerateLinkedResources = true;
this->SupportsGmakeErrorParser = true;
@@ -78,16 +82,15 @@ void cmExtraEclipseCDT4Generator::EnableLanguage(
std::vector<std::string> const& languages, cmMakefile* /*unused*/,
bool /*optional*/)
{
- for (std::vector<std::string>::const_iterator lit = languages.begin();
- lit != languages.end(); ++lit) {
- if (*lit == "CXX") {
+ for (std::string const& l : languages) {
+ if (l == "CXX") {
this->Natures.insert("org.eclipse.cdt.core.ccnature");
this->Natures.insert("org.eclipse.cdt.core.cnature");
this->CXXEnabled = true;
- } else if (*lit == "C") {
+ } else if (l == "C") {
this->Natures.insert("org.eclipse.cdt.core.cnature");
this->CEnabled = true;
- } else if (*lit == "Java") {
+ } else if (l == "Java") {
this->Natures.insert("org.eclipse.jdt.core.javanature");
}
}
@@ -100,7 +103,7 @@ void cmExtraEclipseCDT4Generator::Generate()
std::string eclipseVersion = mf->GetSafeDefinition("CMAKE_ECLIPSE_VERSION");
cmsys::RegularExpression regex(".*([0-9]+\\.[0-9]+).*");
- if (regex.find(eclipseVersion.c_str())) {
+ if (regex.find(eclipseVersion)) {
unsigned int majorVersion = 0;
unsigned int minorVersion = 0;
int res =
@@ -136,7 +139,7 @@ void cmExtraEclipseCDT4Generator::Generate()
if (!this->GenerateSourceProject &&
(mf->IsOn("ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT"))) {
mf->IssueMessage(
- cmake::WARNING,
+ MessageType::WARNING,
"ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT is set to TRUE, "
"but this variable is not supported anymore since CMake 2.8.7.\n"
"Enable CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT instead.");
@@ -144,7 +147,7 @@ void cmExtraEclipseCDT4Generator::Generate()
if (cmSystemTools::IsSubDirectory(this->HomeOutputDirectory,
this->HomeDirectory)) {
- mf->IssueMessage(cmake::WARNING,
+ mf->IssueMessage(MessageType::WARNING,
"The build directory is a subdirectory "
"of the source directory.\n"
"This is not supported well by Eclipse. It is strongly "
@@ -165,6 +168,29 @@ void cmExtraEclipseCDT4Generator::Generate()
// create a .cproject file
this->CreateCProjectFile();
+
+ // create resource settings
+ this->CreateSettingsResourcePrefsFile();
+}
+
+void cmExtraEclipseCDT4Generator::CreateSettingsResourcePrefsFile()
+{
+ cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
+ cmMakefile* mf = lg->GetMakefile();
+
+ const std::string filename =
+ this->HomeOutputDirectory + "/.settings/org.eclipse.core.resources.prefs";
+
+ cmGeneratedFileStream fout(filename);
+ if (!fout) {
+ return;
+ }
+
+ fout << "eclipse.preferences.version=1" << std::endl;
+ const char* encoding = mf->GetDefinition("CMAKE_ECLIPSE_RESOURCE_ENCODING");
+ if (encoding) {
+ fout << "encoding/<project>=" << encoding << std::endl;
+ }
}
void cmExtraEclipseCDT4Generator::CreateSourceProjectFile()
@@ -173,12 +199,12 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile()
// set up the project name: <project>-Source@<baseSourcePathName>
cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0];
- std::string name =
- this->GenerateProjectName(lg->GetProjectName(), "Source",
- this->GetPathBasename(this->HomeDirectory));
+ std::string name = cmExtraEclipseCDT4Generator::GenerateProjectName(
+ lg->GetProjectName(), "Source",
+ cmExtraEclipseCDT4Generator::GetPathBasename(this->HomeDirectory));
const std::string filename = this->HomeDirectory + "/.project";
- cmGeneratedFileStream fout(filename.c_str());
+ cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -215,33 +241,32 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out,
std::string envVarValue;
const bool envVarSet = cmSystemTools::GetEnv(envVar, envVarValue);
- std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_";
- cacheEntryName += envVar;
- const char* cacheValue =
+ std::string cacheEntryName = cmStrCat("CMAKE_ECLIPSE_ENVVAR_", envVar);
+ const std::string* cacheValue =
lg->GetState()->GetInitializedCacheValue(cacheEntryName);
// now we have both, decide which one to use
std::string valueToUse;
- if (!envVarSet && cacheValue == CM_NULLPTR) {
+ if (!envVarSet && cacheValue == nullptr) {
// nothing known, do nothing
- valueToUse = "";
- } else if (envVarSet && cacheValue == CM_NULLPTR) {
+ valueToUse.clear();
+ } else if (envVarSet && cacheValue == nullptr) {
// The variable is in the env, but not in the cache. Use it and put it
// in the cache
valueToUse = envVarValue;
mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
cacheEntryName.c_str(), cmStateEnums::STRING, true);
mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory());
- } else if (!envVarSet && cacheValue != CM_NULLPTR) {
+ } else if (!envVarSet && cacheValue != nullptr) {
// It is already in the cache, but not in the env, so use it from the cache
- valueToUse = cacheValue;
+ valueToUse = *cacheValue;
} else {
// It is both in the cache and in the env.
// Use the version from the env. except if the value from the env is
// completely contained in the value from the cache (for the case that we
// now have a PATH without MSVC dirs in the env. but had the full PATH with
// all MSVC dirs during the cmake run which stored the var in the cache:
- valueToUse = cacheValue;
+ valueToUse = *cacheValue;
if (valueToUse.find(envVarValue) == std::string::npos) {
valueToUse = envVarValue;
mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
@@ -263,7 +288,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
const std::string filename = this->HomeOutputDirectory + "/.project";
- cmGeneratedFileStream fout(filename.c_str());
+ cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -279,10 +304,12 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
xml.StartDocument("UTF-8");
xml.StartElement("projectDescription");
- xml.Element("name", this->GenerateProjectName(
- lg->GetProjectName(),
- mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
- this->GetPathBasename(this->HomeOutputDirectory)));
+ xml.Element("name",
+ cmExtraEclipseCDT4Generator::GenerateProjectName(
+ lg->GetProjectName(),
+ mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
+ cmExtraEclipseCDT4Generator::GetPathBasename(
+ this->HomeOutputDirectory)));
xml.Element("comment", "");
xml.Element("projects", "");
@@ -303,16 +330,17 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
// set the make command
AppendDictionary(xml, "org.eclipse.cdt.make.core.enabledIncrementalBuild",
"true");
- AppendDictionary(
- xml, "org.eclipse.cdt.make.core.build.command",
- this->GetEclipsePath(mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM")));
+ AppendDictionary(xml, "org.eclipse.cdt.make.core.build.command",
+ cmExtraEclipseCDT4Generator::GetEclipsePath(
+ mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM")));
AppendDictionary(xml, "org.eclipse.cdt.make.core.contents",
"org.eclipse.cdt.make.core.activeConfigSettings");
AppendDictionary(xml, "org.eclipse.cdt.make.core.build.target.inc", "all");
AppendDictionary(xml, "org.eclipse.cdt.make.core.build.arguments",
mf->GetSafeDefinition("CMAKE_ECLIPSE_MAKE_ARGUMENTS"));
- AppendDictionary(xml, "org.eclipse.cdt.make.core.buildLocation",
- this->GetEclipsePath(this->HomeOutputDirectory));
+ AppendDictionary(
+ xml, "org.eclipse.cdt.make.core.buildLocation",
+ cmExtraEclipseCDT4Generator::GetEclipsePath(this->HomeOutputDirectory));
AppendDictionary(xml, "org.eclipse.cdt.make.core.useDefaultBuildCmd",
"false");
@@ -342,8 +370,9 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
"clean");
AppendDictionary(xml, "org.eclipse.cdt.make.core.fullBuildTarget", "all");
AppendDictionary(xml, "org.eclipse.cdt.make.core.buildArguments", "");
- AppendDictionary(xml, "org.eclipse.cdt.make.core.build.location",
- this->GetEclipsePath(this->HomeOutputDirectory));
+ AppendDictionary(
+ xml, "org.eclipse.cdt.make.core.build.location",
+ cmExtraEclipseCDT4Generator::GetEclipsePath(this->HomeOutputDirectory));
AppendDictionary(xml, "org.eclipse.cdt.make.core.autoBuildTarget", "all");
// set error parsers
@@ -380,20 +409,16 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
xml.StartElement("natures");
xml.Element("nature", "org.eclipse.cdt.make.core.makeNature");
xml.Element("nature", "org.eclipse.cdt.make.core.ScannerConfigNature");
- ;
- for (std::set<std::string>::const_iterator nit = this->Natures.begin();
- nit != this->Natures.end(); ++nit) {
- xml.Element("nature", *nit);
+ for (std::string const& n : this->Natures) {
+ xml.Element("nature", n);
}
if (const char* extraNaturesProp =
mf->GetState()->GetGlobalProperty("ECLIPSE_EXTRA_NATURES")) {
- std::vector<std::string> extraNatures;
- cmSystemTools::ExpandListArgument(extraNaturesProp, extraNatures);
- for (std::vector<std::string>::const_iterator nit = extraNatures.begin();
- nit != extraNatures.end(); ++nit) {
- xml.Element("nature", *nit);
+ std::vector<std::string> extraNatures = cmExpandedList(extraNaturesProp);
+ for (std::string const& n : extraNatures) {
+ xml.Element("nature", n);
}
}
@@ -410,14 +435,16 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
std::string sourceLinkedResourceName = "[Source directory]";
std::string linkSourceDirectory =
- this->GetEclipsePath(lg->GetCurrentSourceDirectory());
+ cmExtraEclipseCDT4Generator::GetEclipsePath(
+ lg->GetCurrentSourceDirectory());
// .project dir can't be subdir of a linked resource dir
if (!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory,
linkSourceDirectory)) {
- this->AppendLinkedResource(xml, sourceLinkedResourceName,
- this->GetEclipsePath(linkSourceDirectory),
- LinkToFolder);
- this->SrcLinkedResources.push_back(sourceLinkedResourceName);
+ cmExtraEclipseCDT4Generator::AppendLinkedResource(
+ xml, sourceLinkedResourceName,
+ cmExtraEclipseCDT4Generator::GetEclipsePath(linkSourceDirectory),
+ LinkToFolder);
+ this->SrcLinkedResources.push_back(std::move(sourceLinkedResourceName));
}
}
@@ -435,32 +462,27 @@ void cmExtraEclipseCDT4Generator::WriteGroups(
std::vector<cmSourceGroup> const& sourceGroups, std::string& linkName,
cmXMLWriter& xml)
{
- for (std::vector<cmSourceGroup>::const_iterator sgIt = sourceGroups.begin();
- sgIt != sourceGroups.end(); ++sgIt) {
- std::string linkName3 = linkName;
- linkName3 += "/";
- linkName3 += sgIt->GetFullName();
+ for (cmSourceGroup const& sg : sourceGroups) {
+ std::string linkName3 = cmStrCat(linkName, '/', sg.GetFullName());
std::replace(linkName3.begin(), linkName3.end(), '\\', '/');
- this->AppendLinkedResource(xml, linkName3, "virtual:/virtual",
- VirtualFolder);
- std::vector<cmSourceGroup> const& children = sgIt->GetGroupChildren();
+ cmExtraEclipseCDT4Generator::AppendLinkedResource(
+ xml, linkName3, "virtual:/virtual", VirtualFolder);
+ std::vector<cmSourceGroup> const& children = sg.GetGroupChildren();
if (!children.empty()) {
this->WriteGroups(children, linkName, xml);
}
- std::vector<const cmSourceFile*> sFiles = sgIt->GetSourceFiles();
- for (std::vector<const cmSourceFile*>::const_iterator fileIt =
- sFiles.begin();
- fileIt != sFiles.end(); ++fileIt) {
- std::string const& fullPath = (*fileIt)->GetFullPath();
+ std::vector<const cmSourceFile*> sFiles = sg.GetSourceFiles();
+ for (cmSourceFile const* file : sFiles) {
+ std::string const& fullPath = file->GetFullPath();
if (!cmSystemTools::FileIsDirectory(fullPath)) {
- std::string linkName4 = linkName3;
- linkName4 += "/";
- linkName4 += cmSystemTools::GetFilenameName(fullPath);
- this->AppendLinkedResource(xml, linkName4,
- this->GetEclipsePath(fullPath), LinkToFile);
+ std::string linkName4 =
+ cmStrCat(linkName3, '/', cmSystemTools::GetFilenameName(fullPath));
+ cmExtraEclipseCDT4Generator::AppendLinkedResource(
+ xml, linkName4,
+ cmExtraEclipseCDT4Generator::GetEclipsePath(fullPath), LinkToFile);
}
}
}
@@ -469,49 +491,44 @@ void cmExtraEclipseCDT4Generator::WriteGroups(
void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml)
{
std::string linkName = "[Targets]";
- this->AppendLinkedResource(xml, linkName, "virtual:/virtual", VirtualFolder);
-
- for (std::vector<cmLocalGenerator*>::const_iterator lgIt =
- this->GlobalGenerator->GetLocalGenerators().begin();
- lgIt != this->GlobalGenerator->GetLocalGenerators().end(); ++lgIt) {
- cmMakefile* makefile = (*lgIt)->GetMakefile();
- const std::vector<cmGeneratorTarget*> targets =
- (*lgIt)->GetGeneratorTargets();
-
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- std::string linkName2 = linkName;
- linkName2 += "/";
- switch ((*ti)->GetType()) {
+ cmExtraEclipseCDT4Generator::AppendLinkedResource(
+ xml, linkName, "virtual:/virtual", VirtualFolder);
+
+ for (cmLocalGenerator* lg : this->GlobalGenerator->GetLocalGenerators()) {
+ cmMakefile* makefile = lg->GetMakefile();
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+
+ for (cmGeneratorTarget* target : targets) {
+ std::string linkName2 = cmStrCat(linkName, '/');
+ switch (target->GetType()) {
case cmStateEnums::EXECUTABLE:
case cmStateEnums::STATIC_LIBRARY:
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::OBJECT_LIBRARY: {
const char* prefix =
- ((*ti)->GetType() == cmStateEnums::EXECUTABLE ? "[exe] "
- : "[lib] ");
+ (target->GetType() == cmStateEnums::EXECUTABLE ? "[exe] "
+ : "[lib] ");
linkName2 += prefix;
- linkName2 += (*ti)->GetName();
- this->AppendLinkedResource(xml, linkName2, "virtual:/virtual",
- VirtualFolder);
+ linkName2 += target->GetName();
+ cmExtraEclipseCDT4Generator::AppendLinkedResource(
+ xml, linkName2, "virtual:/virtual", VirtualFolder);
if (!this->GenerateLinkedResources) {
break; // skip generating the linked resources to the source files
}
std::vector<cmSourceGroup> sourceGroups =
makefile->GetSourceGroups();
// get the files from the source lists then add them to the groups
- cmGeneratorTarget* gt = const_cast<cmGeneratorTarget*>(*ti);
+ cmGeneratorTarget* gt = const_cast<cmGeneratorTarget*>(target);
std::vector<cmSourceFile*> files;
gt->GetSourceFiles(files,
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- for (std::vector<cmSourceFile*>::const_iterator sfIt = files.begin();
- sfIt != files.end(); sfIt++) {
+ for (cmSourceFile* sf : files) {
// Add the file to the list of sources.
- std::string const& source = (*sfIt)->GetFullPath();
+ std::string const& source = sf->ResolveFullPath();
cmSourceGroup* sourceGroup =
- makefile->FindSourceGroup(source.c_str(), sourceGroups);
- sourceGroup->AssignSource(*sfIt);
+ makefile->FindSourceGroup(source, sourceGroups);
+ sourceGroup->AssignSource(sf);
}
this->WriteGroups(sourceGroups, linkName2, xml);
@@ -533,23 +550,22 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
// for each sub project create a linked resource to the source dir
// - only if it is an out-of-source build
- this->AppendLinkedResource(xml, "[Subprojects]", "virtual:/virtual",
- VirtualFolder);
+ cmExtraEclipseCDT4Generator::AppendLinkedResource(
+ xml, "[Subprojects]", "virtual:/virtual", VirtualFolder);
- for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
+ for (auto const& it : this->GlobalGenerator->GetProjectMap()) {
std::string linkSourceDirectory =
- this->GetEclipsePath(it->second[0]->GetCurrentSourceDirectory());
+ cmExtraEclipseCDT4Generator::GetEclipsePath(
+ it.second[0]->GetCurrentSourceDirectory());
// a linked resource must not point to a parent directory of .project or
// .project itself
if ((baseDir != linkSourceDirectory) &&
!cmSystemTools::IsSubDirectory(baseDir, linkSourceDirectory)) {
- std::string linkName = "[Subprojects]/";
- linkName += it->first;
- this->AppendLinkedResource(xml, linkName,
- this->GetEclipsePath(linkSourceDirectory),
- LinkToFolder);
+ std::string linkName = cmStrCat("[Subprojects]/", it.first);
+ cmExtraEclipseCDT4Generator::AppendLinkedResource(
+ xml, linkName,
+ cmExtraEclipseCDT4Generator::GetEclipsePath(linkSourceDirectory),
+ LinkToFolder);
// Don't add it to the srcLinkedResources, because listing multiple
// directories confuses the Eclipse indexer (#13596).
}
@@ -560,16 +576,15 @@ void cmExtraEclipseCDT4Generator::AppendIncludeDirectories(
cmXMLWriter& xml, const std::vector<std::string>& includeDirs,
std::set<std::string>& emittedDirs)
{
- for (std::vector<std::string>::const_iterator inc = includeDirs.begin();
- inc != includeDirs.end(); ++inc) {
- if (!inc->empty()) {
- std::string dir = cmSystemTools::CollapseFullPath(*inc);
+ for (std::string const& inc : includeDirs) {
+ if (!inc.empty()) {
+ std::string dir = cmSystemTools::CollapseFullPath(inc);
// handle framework include dirs on OSX, the remainder after the
// Frameworks/ part has to be stripped
// /System/Library/Frameworks/GLUT.framework/Headers
cmsys::RegularExpression frameworkRx("(.+/Frameworks)/.+\\.framework/");
- if (frameworkRx.find(dir.c_str())) {
+ if (frameworkRx.find(dir)) {
dir = frameworkRx.match(1);
}
@@ -596,7 +611,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
const std::string filename = this->HomeOutputDirectory + "/.cproject";
- cmGeneratedFileStream fout(filename.c_str());
+ cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -656,7 +671,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
xml.EndElement(); // extension
} else if (systemName == "Darwin") {
xml.StartElement("extension");
- xml.Attribute("id", this->SupportsMachO64Parser
+ xml.Attribute("id",
+ this->SupportsMachO64Parser
? "org.eclipse.cdt.core.MachO64"
: "org.eclipse.cdt.core.MachO");
xml.Attribute("point", "org.eclipse.cdt.core.BinaryParser");
@@ -712,19 +728,17 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
xml.EndElement();
}
- for (std::vector<std::string>::const_iterator it =
- this->SrcLinkedResources.begin();
- it != this->SrcLinkedResources.end(); ++it) {
+ for (std::string const& p : this->SrcLinkedResources) {
xml.StartElement("pathentry");
xml.Attribute("kind", "src");
- xml.Attribute("path", *it);
+ xml.Attribute("path", p);
xml.EndElement();
- // exlude source directory from output search path
+ // exclude source directory from output search path
// - only if not named the same as an output directory
if (!cmSystemTools::FileIsDirectory(
- std::string(this->HomeOutputDirectory + "/" + *it))) {
- excludeFromOut += *it + "/|";
+ std::string(this->HomeOutputDirectory + "/" + p))) {
+ excludeFromOut += p + "/|";
}
}
@@ -738,34 +752,31 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// add pre-processor definitions to allow eclipse to gray out sections
emmited.clear();
- for (std::vector<cmLocalGenerator*>::const_iterator it =
- this->GlobalGenerator->GetLocalGenerators().begin();
- it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
+ for (cmLocalGenerator* lgen : this->GlobalGenerator->GetLocalGenerators()) {
if (const char* cdefs =
- (*it)->GetMakefile()->GetProperty("COMPILE_DEFINITIONS")) {
+ lgen->GetMakefile()->GetProperty("COMPILE_DEFINITIONS")) {
// Expand the list.
std::vector<std::string> defs;
cmGeneratorExpression::Split(cdefs, defs);
- for (std::vector<std::string>::const_iterator di = defs.begin();
- di != defs.end(); ++di) {
- if (cmGeneratorExpression::Find(*di) != std::string::npos) {
+ for (std::string const& d : defs) {
+ if (cmGeneratorExpression::Find(d) != std::string::npos) {
continue;
}
- std::string::size_type equals = di->find('=', 0);
- std::string::size_type enddef = di->length();
+ std::string::size_type equals = d.find('=', 0);
+ std::string::size_type enddef = d.length();
std::string def;
std::string val;
if (equals != std::string::npos && equals < enddef) {
// we have -DFOO=BAR
- def = di->substr(0, equals);
- val = di->substr(equals + 1, enddef - equals + 1);
+ def = d.substr(0, equals);
+ val = d.substr(equals + 1, enddef - equals + 1);
} else {
// we have -DFOO
- def = *di;
+ def = d;
}
// insert the definition if not already added.
@@ -786,12 +797,11 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
mf->GetDefinition("CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS");
if (this->CEnabled && cDefs) {
// Expand the list.
- std::vector<std::string> defs;
- cmSystemTools::ExpandListArgument(cDefs, defs, true);
+ std::vector<std::string> defs = cmExpandedList(cDefs, true);
// the list must contain only definition-value pairs:
if ((defs.size() % 2) == 0) {
- std::vector<std::string>::const_iterator di = defs.begin();
+ auto di = defs.begin();
while (di != defs.end()) {
std::string def = *di;
++di;
@@ -819,12 +829,11 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
mf->GetDefinition("CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS");
if (this->CXXEnabled && cxxDefs) {
// Expand the list.
- std::vector<std::string> defs;
- cmSystemTools::ExpandListArgument(cxxDefs, defs, true);
+ std::vector<std::string> defs = cmExpandedList(cxxDefs, true);
// the list must contain only definition-value pairs:
if ((defs.size() % 2) == 0) {
- std::vector<std::string>::const_iterator di = defs.begin();
+ auto di = defs.begin();
while (di != defs.end()) {
std::string def = *di;
++di;
@@ -850,15 +859,16 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// include dirs
emmited.clear();
- for (std::vector<cmLocalGenerator*>::const_iterator it =
- this->GlobalGenerator->GetLocalGenerators().begin();
- it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
- std::vector<cmGeneratorTarget*> targets = (*it)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator l = targets.begin();
- l != targets.end(); ++l) {
+ for (cmLocalGenerator* lgen : this->GlobalGenerator->GetLocalGenerators()) {
+ const std::vector<cmGeneratorTarget*>& targets =
+ lgen->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ continue;
+ }
std::vector<std::string> includeDirs;
std::string config = mf->GetSafeDefinition("CMAKE_BUILD_TYPE");
- (*it)->GetIncludeDirectories(includeDirs, *l, "C", config);
+ lgen->GetIncludeDirectories(includeDirs, target, "C", config);
this->AppendIncludeDirectories(xml, includeDirs, emmited);
}
}
@@ -869,16 +879,14 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
if (this->CEnabled && !compiler.empty()) {
std::string systemIncludeDirs =
mf->GetSafeDefinition("CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
- std::vector<std::string> dirs;
- cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
+ std::vector<std::string> dirs = cmExpandedList(systemIncludeDirs);
this->AppendIncludeDirectories(xml, dirs, emmited);
}
compiler = mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
if (this->CXXEnabled && !compiler.empty()) {
std::string systemIncludeDirs =
mf->GetSafeDefinition("CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
- std::vector<std::string> dirs;
- cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
+ std::vector<std::string> dirs = cmExpandedList(systemIncludeDirs);
this->AppendIncludeDirectories(xml, dirs, emmited);
}
@@ -889,8 +897,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
xml.Attribute("moduleId", "org.eclipse.cdt.make.core.buildtargets");
xml.StartElement("buildTargets");
emmited.clear();
- const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
- const std::string makeArgs =
+ const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
+ const std::string& makeArgs =
mf->GetSafeDefinition("CMAKE_ECLIPSE_MAKE_ARGUMENTS");
cmGlobalGenerator* generator =
@@ -907,26 +915,24 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// add all executable and library targets and some of the GLOBAL
// and UTILITY targets
- for (std::vector<cmLocalGenerator*>::const_iterator it =
- this->GlobalGenerator->GetLocalGenerators().begin();
- it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
- const std::vector<cmGeneratorTarget*> targets =
- (*it)->GetGeneratorTargets();
- std::string subdir = (*it)->ConvertToRelativePath(
- this->HomeOutputDirectory, (*it)->GetCurrentBinaryDirectory());
+ for (cmLocalGenerator* lgen : this->GlobalGenerator->GetLocalGenerators()) {
+ const std::vector<cmGeneratorTarget*>& targets =
+ lgen->GetGeneratorTargets();
+ std::string subdir = lgen->MaybeConvertToRelativePath(
+ this->HomeOutputDirectory, lgen->GetCurrentBinaryDirectory());
if (subdir == ".") {
- subdir = "";
+ subdir.clear();
}
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- std::string targetName = (*ti)->GetName();
- switch ((*ti)->GetType()) {
+ for (cmGeneratorTarget* target : targets) {
+ std::string targetName = target->GetName();
+ switch (target->GetType()) {
case cmStateEnums::GLOBAL_TARGET: {
// Only add the global targets from CMAKE_BINARY_DIR,
// not from the subdirs
if (subdir.empty()) {
- this->AppendTarget(xml, targetName, make, makeArgs, subdir, ": ");
+ cmExtraEclipseCDT4Generator::AppendTarget(xml, targetName, make,
+ makeArgs, subdir, ": ");
}
} break;
case cmStateEnums::UTILITY:
@@ -941,7 +947,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
break;
}
- this->AppendTarget(xml, targetName, make, makeArgs, subdir, ": ");
+ cmExtraEclipseCDT4Generator::AppendTarget(xml, targetName, make,
+ makeArgs, subdir, ": ");
break;
case cmStateEnums::EXECUTABLE:
case cmStateEnums::STATIC_LIBRARY:
@@ -949,37 +956,35 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::OBJECT_LIBRARY: {
const char* prefix =
- ((*ti)->GetType() == cmStateEnums::EXECUTABLE ? "[exe] "
- : "[lib] ");
- this->AppendTarget(xml, targetName, make, makeArgs, subdir, prefix);
- std::string fastTarget = targetName;
- fastTarget += "/fast";
- this->AppendTarget(xml, fastTarget, make, makeArgs, subdir, prefix);
+ (target->GetType() == cmStateEnums::EXECUTABLE ? "[exe] "
+ : "[lib] ");
+ cmExtraEclipseCDT4Generator::AppendTarget(xml, targetName, make,
+ makeArgs, subdir, prefix);
+ std::string fastTarget = cmStrCat(targetName, "/fast");
+ cmExtraEclipseCDT4Generator::AppendTarget(xml, fastTarget, make,
+ makeArgs, subdir, prefix);
// Add Build and Clean targets in the virtual folder of targets:
if (this->SupportsVirtualFolders) {
- std::string virtDir = "[Targets]/";
- virtDir += prefix;
- virtDir += targetName;
- std::string buildArgs = "-C \"";
- buildArgs += (*it)->GetBinaryDirectory();
- buildArgs += "\" ";
- buildArgs += makeArgs;
- this->AppendTarget(xml, "Build", make, buildArgs, virtDir, "",
- targetName.c_str());
-
- std::string cleanArgs = "-E chdir \"";
- cleanArgs += (*it)->GetCurrentBinaryDirectory();
- cleanArgs += "\" \"";
- cleanArgs += cmSystemTools::GetCMakeCommand();
- cleanArgs += "\" -P \"";
- cmGeneratorTarget* gt = *ti;
- cleanArgs += (*it)->GetTargetDirectory(gt);
+ std::string virtDir = cmStrCat("[Targets]/", prefix, targetName);
+ std::string buildArgs =
+ cmStrCat("-C \"", lgen->GetBinaryDirectory(), "\" ", makeArgs);
+ cmExtraEclipseCDT4Generator::AppendTarget(
+ xml, "Build", make, buildArgs, virtDir, "", targetName.c_str());
+
+ std::string cleanArgs =
+ cmStrCat("-E chdir \"", lgen->GetCurrentBinaryDirectory(),
+ "\" \"", cmSystemTools::GetCMakeCommand(), "\" -P \"");
+ cmGeneratorTarget* gt = target;
+ cleanArgs += lgen->GetTargetDirectory(gt);
cleanArgs += "/cmake_clean.cmake\"";
- this->AppendTarget(xml, "Clean", cmSystemTools::GetCMakeCommand(),
- cleanArgs, virtDir, "", "");
+ cmExtraEclipseCDT4Generator::AppendTarget(
+ xml, "Clean", cmSystemTools::GetCMakeCommand(), cleanArgs,
+ virtDir, "", "");
}
} break;
+ case cmStateEnums::INTERFACE_LIBRARY:
+ break;
default:
break;
}
@@ -987,33 +992,34 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// insert the all and clean targets in every subdir
if (!allTarget.empty()) {
- this->AppendTarget(xml, allTarget, make, makeArgs, subdir, ": ");
+ cmExtraEclipseCDT4Generator::AppendTarget(xml, allTarget, make, makeArgs,
+ subdir, ": ");
}
if (!cleanTarget.empty()) {
- this->AppendTarget(xml, cleanTarget, make, makeArgs, subdir, ": ");
+ cmExtraEclipseCDT4Generator::AppendTarget(xml, cleanTarget, make,
+ makeArgs, subdir, ": ");
}
// insert rules for compiling, preprocessing and assembling individual
// files
std::vector<std::string> objectFileTargets;
- (*it)->GetIndividualFileTargets(objectFileTargets);
- for (std::vector<std::string>::const_iterator fit =
- objectFileTargets.begin();
- fit != objectFileTargets.end(); ++fit) {
+ lg->GetIndividualFileTargets(objectFileTargets);
+ for (std::string const& f : objectFileTargets) {
const char* prefix = "[obj] ";
- if ((*fit)[fit->length() - 1] == 's') {
+ if (f.back() == 's') {
prefix = "[to asm] ";
- } else if ((*fit)[fit->length() - 1] == 'i') {
+ } else if (f.back() == 'i') {
prefix = "[pre] ";
}
- this->AppendTarget(xml, *fit, make, makeArgs, subdir, prefix);
+ cmExtraEclipseCDT4Generator::AppendTarget(xml, f, make, makeArgs, subdir,
+ prefix);
}
}
xml.EndElement(); // buildTargets
xml.EndElement(); // storageModule
- this->AppendStorageScanners(xml, *mf);
+ cmExtraEclipseCDT4Generator::AppendStorageScanners(xml, *mf);
xml.EndElement(); // cconfiguration
xml.EndElement(); // storageModule
@@ -1028,6 +1034,13 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
xml.EndElement(); // project
xml.EndElement(); // storageModule
+
+ // Append additional cproject contents without applying any XML formatting
+ if (const char* extraCProjectContents =
+ mf->GetState()->GetGlobalProperty("ECLIPSE_EXTRA_CPROJECT_CONTENTS")) {
+ fout << extraCProjectContents;
+ }
+
xml.EndElement(); // cproject
}
@@ -1053,8 +1066,7 @@ std::string cmExtraEclipseCDT4Generator::GetPathBasename(
{
std::string outputBasename = path;
while (!outputBasename.empty() &&
- (outputBasename[outputBasename.size() - 1] == '/' ||
- outputBasename[outputBasename.size() - 1] == '\\')) {
+ (outputBasename.back() == '/' || outputBasename.back() == '\\')) {
outputBasename.resize(outputBasename.size() - 1);
}
std::string::size_type loc = outputBasename.find_last_of("/\\");
@@ -1076,7 +1088,8 @@ void cmExtraEclipseCDT4Generator::AppendStorageScanners(
cmXMLWriter& xml, const cmMakefile& makefile)
{
// we need the "make" and the C (or C++) compiler which are used, Alex
- std::string make = makefile.GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
+ const std::string& make =
+ makefile.GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
std::string compiler = makefile.GetSafeDefinition("CMAKE_C_COMPILER");
std::string arg1 = makefile.GetSafeDefinition("CMAKE_C_COMPILER_ARG1");
if (compiler.empty()) {
diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h
index 1380d1867..ff4c59eeb 100644
--- a/Source/cmExtraEclipseCDT4Generator.h
+++ b/Source/cmExtraEclipseCDT4Generator.h
@@ -3,15 +3,15 @@
#ifndef cmExtraEclipseCDT4Generator_h
#define cmExtraEclipseCDT4Generator_h
-#include "cmConfigure.h"
-
-#include "cmExternalMakefileProjectGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <set>
#include <string>
#include <vector>
+#include "cmExternalMakefileProjectGenerator.h"
+
class cmLocalGenerator;
class cmMakefile;
class cmSourceGroup;
@@ -35,14 +35,17 @@ public:
static cmExternalMakefileProjectGeneratorFactory* GetFactory();
void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
- bool optional) CM_OVERRIDE;
+ bool optional) override;
- void Generate() CM_OVERRIDE;
+ void Generate() override;
private:
// create .project file in the source tree
void CreateSourceProjectFile();
+ // create .settings/org.eclipse.core.resources.prefs
+ void CreateSettingsResourcePrefsFile();
+
// create .project file
void CreateProjectFile();
@@ -67,7 +70,7 @@ private:
const std::string& make,
const std::string& makeArguments,
const std::string& path, const char* prefix = "",
- const char* makeTarget = CM_NULLPTR);
+ const char* makeTarget = nullptr);
static void AppendScannerProfile(
cmXMLWriter& xml, const std::string& profileID, bool openActionEnabled,
const std::string& openActionFilePath, bool pParserEnabled,
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx
index 373043309..e8c9dd002 100644
--- a/Source/cmExtraKateGenerator.cxx
+++ b/Source/cmExtraKateGenerator.cxx
@@ -2,6 +2,11 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExtraKateGenerator.h"
+#include <cstring>
+#include <ostream>
+#include <set>
+#include <vector>
+
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
@@ -9,17 +14,10 @@
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include <ostream>
-#include <set>
-#include <string.h>
-#include <vector>
-
-cmExtraKateGenerator::cmExtraKateGenerator()
- : cmExternalMakefileProjectGenerator()
-{
-}
+cmExtraKateGenerator::cmExtraKateGenerator() = default;
cmExternalMakefileProjectGeneratorFactory* cmExtraKateGenerator::GetFactory()
{
@@ -56,9 +54,8 @@ void cmExtraKateGenerator::Generate()
void cmExtraKateGenerator::CreateKateProjectFile(
const cmLocalGenerator* lg) const
{
- std::string filename = lg->GetBinaryDirectory();
- filename += "/.kateproject";
- cmGeneratedFileStream fout(filename.c_str());
+ std::string filename = cmStrCat(lg->GetBinaryDirectory(), "/.kateproject");
+ cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -78,15 +75,15 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
cmGeneratedFileStream& fout) const
{
cmMakefile const* mf = lg->GetMakefile();
- const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
- const std::string makeArgs =
+ const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
+ const std::string& makeArgs =
mf->GetSafeDefinition("CMAKE_KATE_MAKE_ARGUMENTS");
- const char* homeOutputDir = lg->GetBinaryDirectory();
+ std::string const& homeOutputDir = lg->GetBinaryDirectory();
/* clang-format off */
fout <<
"\t\"build\": {\n"
- "\t\t\"directory\": \"" << lg->GetBinaryDirectory() << "\",\n"
+ "\t\t\"directory\": \"" << homeOutputDir << "\",\n"
"\t\t\"default_target\": \"all\",\n"
"\t\t\"clean_target\": \"clean\",\n";
/* clang-format on */
@@ -112,18 +109,16 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
// add all executable and library targets and some of the GLOBAL
// and UTILITY targets
- for (std::vector<cmLocalGenerator*>::const_iterator it =
- this->GlobalGenerator->GetLocalGenerators().begin();
- it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) {
- const std::vector<cmGeneratorTarget*> targets =
- (*it)->GetGeneratorTargets();
- std::string currentDir = (*it)->GetCurrentBinaryDirectory();
- bool topLevel = (currentDir == (*it)->GetBinaryDirectory());
-
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- std::string targetName = (*ti)->GetName();
- switch ((*ti)->GetType()) {
+ for (cmLocalGenerator* localGen :
+ this->GlobalGenerator->GetLocalGenerators()) {
+ const std::vector<cmGeneratorTarget*>& targets =
+ localGen->GetGeneratorTargets();
+ std::string currentDir = localGen->GetCurrentBinaryDirectory();
+ bool topLevel = (currentDir == localGen->GetBinaryDirectory());
+
+ for (cmGeneratorTarget* target : targets) {
+ std::string const& targetName = target->GetName();
+ switch (target->GetType()) {
case cmStateEnums::GLOBAL_TARGET: {
bool insertTarget = false;
// Only add the global targets from CMAKE_BINARY_DIR,
@@ -134,10 +129,10 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
// this will not work within the IDE
if (targetName == "edit_cache") {
const char* editCommand =
- (*it)->GetMakefile()->GetDefinition("CMAKE_EDIT_COMMAND");
- if (editCommand == CM_NULLPTR) {
+ localGen->GetMakefile()->GetDefinition("CMAKE_EDIT_COMMAND");
+ if (editCommand == nullptr) {
insertTarget = false;
- } else if (strstr(editCommand, "ccmake") != CM_NULLPTR) {
+ } else if (strstr(editCommand, "ccmake") != nullptr) {
insertTarget = false;
}
}
@@ -169,8 +164,7 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
case cmStateEnums::OBJECT_LIBRARY: {
this->AppendTarget(fout, targetName, make, makeArgs, currentDir,
homeOutputDir);
- std::string fastTarget = targetName;
- fastTarget += "/fast";
+ std::string fastTarget = cmStrCat(targetName, "/fast");
this->AppendTarget(fout, fastTarget, make, makeArgs, currentDir,
homeOutputDir);
@@ -183,12 +177,9 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg,
// insert rules for compiling, preprocessing and assembling individual
// files
std::vector<std::string> objectFileTargets;
- (*it)->GetIndividualFileTargets(objectFileTargets);
- for (std::vector<std::string>::const_iterator fit =
- objectFileTargets.begin();
- fit != objectFileTargets.end(); ++fit) {
- this->AppendTarget(fout, *fit, make, makeArgs, currentDir,
- homeOutputDir);
+ localGen->GetIndividualFileTargets(objectFileTargets);
+ for (std::string const& f : objectFileTargets) {
+ this->AppendTarget(fout, f, make, makeArgs, currentDir, homeOutputDir);
}
}
@@ -200,13 +191,14 @@ void cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout,
const std::string& make,
const std::string& makeArgs,
const std::string& path,
- const char* homeOutputDir) const
+ const std::string& homeOutputDir) const
{
static char JsonSep = ' ';
- fout << "\t\t\t" << JsonSep << "{\"name\":\"" << target << "\", "
- "\"build_cmd\":\""
- << make << " -C \\\"" << (this->UseNinja ? homeOutputDir : path.c_str())
+ fout << "\t\t\t" << JsonSep << R"({"name":")" << target
+ << "\", "
+ "\"build_cmd\":\""
+ << make << " -C \\\"" << (this->UseNinja ? homeOutputDir : path)
<< "\\\" " << makeArgs << " " << target << "\"}\n";
JsonSep = ',';
@@ -215,11 +207,9 @@ void cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout,
void cmExtraKateGenerator::CreateDummyKateProjectFile(
const cmLocalGenerator* lg) const
{
- std::string filename = lg->GetBinaryDirectory();
- filename += "/";
- filename += this->ProjectName;
- filename += ".kateproject";
- cmGeneratedFileStream fout(filename.c_str());
+ std::string filename =
+ cmStrCat(lg->GetBinaryDirectory(), '/', this->ProjectName, ".kateproject");
+ cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -231,58 +221,50 @@ void cmExtraKateGenerator::CreateDummyKateProjectFile(
std::string cmExtraKateGenerator::GenerateFilesString(
const cmLocalGenerator* lg) const
{
- std::string s = lg->GetSourceDirectory();
- s += "/.git";
- if (cmSystemTools::FileExists(s.c_str())) {
- return std::string("\"git\": 1 ");
+ std::string s = cmStrCat(lg->GetSourceDirectory(), "/.git");
+ if (cmSystemTools::FileExists(s)) {
+ return "\"git\": 1 ";
}
- s = lg->GetSourceDirectory();
- s += "/.svn";
- if (cmSystemTools::FileExists(s.c_str())) {
- return std::string("\"svn\": 1 ");
+ s = cmStrCat(lg->GetSourceDirectory(), "/.svn");
+ if (cmSystemTools::FileExists(s)) {
+ return "\"svn\": 1 ";
}
- s = lg->GetSourceDirectory();
- s += "/";
+ s = cmStrCat(lg->GetSourceDirectory(), '/');
std::set<std::string> files;
std::string tmp;
const std::vector<cmLocalGenerator*>& lgs =
this->GlobalGenerator->GetLocalGenerators();
- for (std::vector<cmLocalGenerator*>::const_iterator it = lgs.begin();
- it != lgs.end(); it++) {
- cmMakefile* makefile = (*it)->GetMakefile();
+ for (cmLocalGenerator* lgen : lgs) {
+ cmMakefile* makefile = lgen->GetMakefile();
const std::vector<std::string>& listFiles = makefile->GetListFiles();
- for (std::vector<std::string>::const_iterator lt = listFiles.begin();
- lt != listFiles.end(); lt++) {
- tmp = *lt;
+ for (std::string const& listFile : listFiles) {
+ tmp = listFile;
{
files.insert(tmp);
}
}
const std::vector<cmSourceFile*>& sources = makefile->GetSourceFiles();
- for (std::vector<cmSourceFile*>::const_iterator sfIt = sources.begin();
- sfIt != sources.end(); sfIt++) {
- cmSourceFile* sf = *sfIt;
- if (sf->GetPropertyAsBool("GENERATED")) {
+ for (cmSourceFile* sf : sources) {
+ if (sf->GetIsGenerated()) {
continue;
}
- tmp = sf->GetFullPath();
+ tmp = sf->ResolveFullPath();
files.insert(tmp);
}
}
const char* sep = "";
tmp = "\"list\": [";
- for (std::set<std::string>::const_iterator it = files.begin();
- it != files.end(); ++it) {
+ for (std::string const& f : files) {
tmp += sep;
tmp += " \"";
- tmp += *it;
+ tmp += f;
tmp += "\"";
sep = ",";
}
@@ -303,8 +285,7 @@ std::string cmExtraKateGenerator::GetPathBasename(
{
std::string outputBasename = path;
while (!outputBasename.empty() &&
- (outputBasename[outputBasename.size() - 1] == '/' ||
- outputBasename[outputBasename.size() - 1] == '\\')) {
+ (outputBasename.back() == '/' || outputBasename.back() == '\\')) {
outputBasename.resize(outputBasename.size() - 1);
}
std::string::size_type loc = outputBasename.find_last_of("/\\");
diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h
index 6b9c7af5c..be1376aa2 100644
--- a/Source/cmExtraKateGenerator.h
+++ b/Source/cmExtraKateGenerator.h
@@ -3,12 +3,12 @@
#ifndef cmExtraKateGenerator_h
#define cmExtraKateGenerator_h
-#include "cmConfigure.h"
-
-#include "cmExternalMakefileProjectGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include "cmExternalMakefileProjectGenerator.h"
+
class cmGeneratedFileStream;
class cmLocalGenerator;
@@ -22,7 +22,7 @@ public:
static cmExternalMakefileProjectGeneratorFactory* GetFactory();
- void Generate() CM_OVERRIDE;
+ void Generate() override;
private:
void CreateKateProjectFile(const cmLocalGenerator* lg) const;
@@ -31,7 +31,8 @@ private:
cmGeneratedFileStream& fout) const;
void AppendTarget(cmGeneratedFileStream& fout, const std::string& target,
const std::string& make, const std::string& makeArgs,
- const std::string& path, const char* homeOutputDir) const;
+ const std::string& path,
+ const std::string& homeOutputDir) const;
std::string GenerateFilesString(const cmLocalGenerator* lg) const;
std::string GetPathBasename(const std::string& path) const;
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 1fd1418de..495324cbf 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -2,20 +2,23 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExtraSublimeTextGenerator.h"
-#include "cmsys/RegularExpression.hxx"
+#include <cstring>
#include <set>
#include <sstream>
-#include <string.h>
#include <utility>
+#include "cmsys/RegularExpression.hxx"
+
#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmSourceFile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
@@ -55,7 +58,6 @@ cmExtraSublimeTextGenerator::GetFactory()
}
cmExtraSublimeTextGenerator::cmExtraSublimeTextGenerator()
- : cmExternalMakefileProjectGenerator()
{
this->ExcludeBuildFolder = false;
}
@@ -68,11 +70,9 @@ void cmExtraSublimeTextGenerator::Generate()
"CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS");
// for each sub project in the project create a sublime text 2 project
- for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
+ for (auto const& it : this->GlobalGenerator->GetProjectMap()) {
// create a project file
- this->CreateProjectFile(it->second);
+ this->CreateProjectFile(it.second);
}
}
@@ -93,7 +93,7 @@ void cmExtraSublimeTextGenerator::CreateNewProjectFile(
{
const cmMakefile* mf = lgs[0]->GetMakefile();
- cmGeneratedFileStream fout(filename.c_str());
+ cmGeneratedFileStream fout(filename);
if (!fout) {
return;
}
@@ -135,8 +135,7 @@ void cmExtraSublimeTextGenerator::CreateNewProjectFile(
// End of build_systems
fout << "\n\t]";
std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
- std::vector<std::string> tokens;
- cmSystemTools::ExpandListArgument(this->EnvSettings, tokens);
+ std::vector<std::string> tokens = cmExpandedList(this->EnvSettings);
if (!this->EnvSettings.empty()) {
fout << ",";
@@ -144,21 +143,20 @@ void cmExtraSublimeTextGenerator::CreateNewProjectFile(
fout << "\n\t{";
fout << "\n\t\t" << systemName << ":";
fout << "\n\t\t{";
- for (std::vector<std::string>::iterator i = tokens.begin();
- i != tokens.end(); ++i) {
- size_t const pos = i->find_first_of('=');
+ for (std::string const& t : tokens) {
+ size_t const pos = t.find_first_of('=');
if (pos != std::string::npos) {
- std::string varName = i->substr(0, pos);
- std::string varValue = i->substr(pos + 1);
+ std::string varName = t.substr(0, pos);
+ std::string varValue = t.substr(pos + 1);
fout << "\n\t\t\t\"" << varName << "\":\"" << varValue << "\"";
} else {
std::ostringstream e;
e << "Could not parse Env Vars specified in "
"\"CMAKE_SUBLIME_TEXT_2_ENV_SETTINGS\""
- << ", corrupted string " << *i;
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ << ", corrupted string " << t;
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
}
}
fout << "\n\t\t}";
@@ -171,31 +169,28 @@ void cmExtraSublimeTextGenerator::AppendAllTargets(
const std::vector<cmLocalGenerator*>& lgs, const cmMakefile* mf,
cmGeneratedFileStream& fout, MapSourceFileFlags& sourceFileFlags)
{
- std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
+ const std::string& make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
std::string compiler;
if (!lgs.empty()) {
- this->AppendTarget(fout, "all", lgs[0], CM_NULLPTR, make.c_str(), mf,
+ this->AppendTarget(fout, "all", lgs[0], nullptr, make.c_str(), mf,
compiler.c_str(), sourceFileFlags, true);
- this->AppendTarget(fout, "clean", lgs[0], CM_NULLPTR, make.c_str(), mf,
+ this->AppendTarget(fout, "clean", lgs[0], nullptr, make.c_str(), mf,
compiler.c_str(), sourceFileFlags, false);
}
// add all executable and library targets and some of the GLOBAL
// and UTILITY targets
- for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
- lg != lgs.end(); lg++) {
- cmMakefile* makefile = (*lg)->GetMakefile();
- std::vector<cmGeneratorTarget*> targets = (*lg)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
- ti != targets.end(); ti++) {
- std::string targetName = (*ti)->GetName();
- switch ((*ti)->GetType()) {
+ for (cmLocalGenerator* lg : lgs) {
+ cmMakefile* makefile = lg->GetMakefile();
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ std::string targetName = target->GetName();
+ switch (target->GetType()) {
case cmStateEnums::GLOBAL_TARGET: {
// Only add the global targets from CMAKE_BINARY_DIR,
// not from the subdirs
- if (strcmp((*lg)->GetCurrentBinaryDirectory(),
- (*lg)->GetBinaryDirectory()) == 0) {
- this->AppendTarget(fout, targetName, *lg, CM_NULLPTR, make.c_str(),
+ if (lg->GetCurrentBinaryDirectory() == lg->GetBinaryDirectory()) {
+ this->AppendTarget(fout, targetName, lg, nullptr, make.c_str(),
makefile, compiler.c_str(), sourceFileFlags,
false);
}
@@ -212,7 +207,7 @@ void cmExtraSublimeTextGenerator::AppendAllTargets(
break;
}
- this->AppendTarget(fout, targetName, *lg, CM_NULLPTR, make.c_str(),
+ this->AppendTarget(fout, targetName, lg, nullptr, make.c_str(),
makefile, compiler.c_str(), sourceFileFlags,
false);
break;
@@ -221,12 +216,11 @@ void cmExtraSublimeTextGenerator::AppendAllTargets(
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::OBJECT_LIBRARY: {
- this->AppendTarget(fout, targetName, *lg, *ti, make.c_str(),
+ this->AppendTarget(fout, targetName, lg, target, make.c_str(),
makefile, compiler.c_str(), sourceFileFlags,
false);
- std::string fastTarget = targetName;
- fastTarget += "/fast";
- this->AppendTarget(fout, fastTarget, *lg, *ti, make.c_str(),
+ std::string fastTarget = cmStrCat(targetName, "/fast");
+ this->AppendTarget(fout, fastTarget, lg, target, make.c_str(),
makefile, compiler.c_str(), sourceFileFlags,
false);
} break;
@@ -244,35 +238,35 @@ void cmExtraSublimeTextGenerator::AppendTarget(
MapSourceFileFlags& sourceFileFlags, bool firstTarget)
{
- if (target != CM_NULLPTR) {
+ if (target != nullptr) {
std::vector<cmSourceFile*> sourceFiles;
target->GetSourceFiles(sourceFiles,
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- std::vector<cmSourceFile*>::const_iterator sourceFilesEnd =
- sourceFiles.end();
- for (std::vector<cmSourceFile*>::const_iterator iter = sourceFiles.begin();
- iter != sourceFilesEnd; ++iter) {
- cmSourceFile* sourceFile = *iter;
- MapSourceFileFlags::iterator sourceFileFlagsIter =
- sourceFileFlags.find(sourceFile->GetFullPath());
+ for (cmSourceFile* sourceFile : sourceFiles) {
+ auto sourceFileFlagsIter =
+ sourceFileFlags.find(sourceFile->ResolveFullPath());
if (sourceFileFlagsIter == sourceFileFlags.end()) {
sourceFileFlagsIter =
sourceFileFlags
- .insert(MapSourceFileFlags::value_type(sourceFile->GetFullPath(),
- std::vector<std::string>()))
+ .insert(MapSourceFileFlags::value_type(
+ sourceFile->ResolveFullPath(), std::vector<std::string>()))
.first;
}
std::vector<std::string>& flags = sourceFileFlagsIter->second;
- std::string flagsString = this->ComputeFlagsForObject(*iter, lg, target);
- std::string definesString = this->ComputeDefines(*iter, lg, target);
+ std::string flagsString =
+ this->ComputeFlagsForObject(sourceFile, lg, target);
+ std::string definesString = this->ComputeDefines(sourceFile, lg, target);
+ std::string includesString =
+ this->ComputeIncludes(sourceFile, lg, target);
flags.clear();
cmsys::RegularExpression flagRegex;
// Regular expression to extract compiler flags from a string
// https://gist.github.com/3944250
const char* regexString =
- "(^|[ ])-[DIOUWfgs][^= ]+(=\\\"[^\"]+\\\"|=[^\"][^ ]+)?";
+ R"((^|[ ])-[DIOUWfgs][^= ]+(=\"[^"]+\"|=[^"][^ ]+)?)";
flagRegex.compile(regexString);
- std::string workString = flagsString + " " + definesString;
+ std::string workString =
+ cmStrCat(flagsString, " ", definesString, " ", includesString);
while (flagRegex.find(workString)) {
std::string::size_type start = flagRegex.start();
if (workString[start] == ' ') {
@@ -282,7 +276,7 @@ void cmExtraSublimeTextGenerator::AppendTarget(
if (flagRegex.end() < workString.size()) {
workString = workString.substr(flagRegex.end());
} else {
- workString = "";
+ workString.clear();
}
}
}
@@ -316,17 +310,16 @@ void cmExtraSublimeTextGenerator::AppendTarget(
std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
const std::string& make, const char* makefile, const std::string& target)
{
- std::string command = "\"";
- command += make + "\"";
+ std::string command = cmStrCat('"', make, '"');
std::string generator = this->GlobalGenerator->GetName();
if (generator == "NMake Makefiles") {
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
- command += ", \"/NOLOGO\", \"/f\", \"";
+ command += R"(, "/NOLOGO", "/f", ")";
command += makefileName + "\"";
command += ", \"" + target + "\"";
} else if (generator == "Ninja") {
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
- command += ", \"-f\", \"";
+ command += R"(, "-f", ")";
command += makefileName + "\"";
command += ", \"" + target + "\"";
} else {
@@ -338,7 +331,7 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
} else {
makefileName = cmSystemTools::ConvertToOutputPath(makefile);
}
- command += ", \"-f\", \"";
+ command += R"(, "-f", ")";
command += makefileName + "\"";
command += ", \"" + target + "\"";
}
@@ -350,7 +343,7 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject(
cmSourceFile* source, cmLocalGenerator* lg, cmGeneratorTarget* gtgt)
{
std::string flags;
- std::string language = source->GetLanguage();
+ std::string language = source->GetOrDetermineLanguage();
if (language.empty()) {
language = "C";
}
@@ -359,20 +352,19 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject(
lg->GetTargetCompileFlags(gtgt, config, language, flags);
- // Add include directory flags.
- {
- std::vector<std::string> includes;
- lg->GetIncludeDirectories(includes, gtgt, language, config);
- std::string includeFlags = lg->GetIncludeFlags(includes, gtgt, language,
- true); // full include paths
- lg->AppendFlags(flags, includeFlags);
+ // Add source file specific flags.
+ cmGeneratorExpressionInterpreter genexInterpreter(lg, config, gtgt,
+ language);
+
+ const std::string COMPILE_FLAGS("COMPILE_FLAGS");
+ if (const char* cflags = source->GetProperty(COMPILE_FLAGS)) {
+ lg->AppendFlags(flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS));
}
- // Add source file specific flags.
- if (const char* cflags = source->GetProperty("COMPILE_FLAGS")) {
- cmGeneratorExpression ge;
- const char* processed = ge.Parse(cflags)->Evaluate(lg, config);
- lg->AppendFlags(flags, processed);
+ const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
+ if (const char* coptions = source->GetProperty(COMPILE_OPTIONS)) {
+ lg->AppendCompileOptions(
+ flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS));
}
return flags;
@@ -386,21 +378,25 @@ std::string cmExtraSublimeTextGenerator::ComputeDefines(
{
std::set<std::string> defines;
cmMakefile* makefile = lg->GetMakefile();
- const std::string& language = source->GetLanguage();
+ const std::string& language = source->GetOrDetermineLanguage();
const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target,
+ language);
- // Add the export symbol definition for shared library objects.
- if (const char* exportMacro = target->GetExportMacro()) {
- lg->AppendDefines(defines, exportMacro);
+ // Add preprocessor definitions for this target and configuration.
+ lg->GetTargetDefines(target, config, language, defines);
+ const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
+ if (const char* compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) {
+ lg->AppendDefines(
+ defines, genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS));
}
- // Add preprocessor definitions for this target and configuration.
- lg->AddCompileDefinitions(defines, target, config, language);
- lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS"));
- {
- std::string defPropName = "COMPILE_DEFINITIONS_";
- defPropName += cmSystemTools::UpperCase(config);
- lg->AppendDefines(defines, source->GetProperty(defPropName));
+ std::string defPropName =
+ cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(config));
+ if (const char* config_compile_defs = source->GetProperty(defPropName)) {
+ lg->AppendDefines(
+ defines,
+ genexInterpreter.Evaluate(config_compile_defs, COMPILE_DEFINITIONS));
}
std::string definesString;
@@ -408,3 +404,54 @@ std::string cmExtraSublimeTextGenerator::ComputeDefines(
return definesString;
}
+
+std::string cmExtraSublimeTextGenerator::ComputeIncludes(
+ cmSourceFile* source, cmLocalGenerator* lg, cmGeneratorTarget* target)
+
+{
+ std::vector<std::string> includes;
+ cmMakefile* makefile = lg->GetMakefile();
+ const std::string& language = source->GetOrDetermineLanguage();
+ const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target,
+ language);
+
+ // Add include directories for this source file
+ const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
+ if (const char* cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) {
+ lg->AppendIncludeDirectories(
+ includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES),
+ *source);
+ }
+
+ // Add include directory flags.
+ lg->GetIncludeDirectories(includes, target, language, config);
+
+ std::string includesString =
+ lg->GetIncludeFlags(includes, target, language, true, false, config);
+
+ return includesString;
+}
+
+bool cmExtraSublimeTextGenerator::Open(const std::string& bindir,
+ const std::string& projectName,
+ bool dryRun)
+{
+ const char* sublExecutable =
+ this->GlobalGenerator->GetCMakeInstance()->GetCacheDefinition(
+ "CMAKE_SUBLIMETEXT_EXECUTABLE");
+ if (!sublExecutable) {
+ return false;
+ }
+ if (cmIsNOTFOUND(sublExecutable)) {
+ return false;
+ }
+
+ std::string filename = bindir + "/" + projectName + ".sublime-project";
+ if (dryRun) {
+ return cmSystemTools::FileExists(filename, true);
+ }
+
+ return cmSystemTools::RunSingleCommand(
+ { sublExecutable, "--project", filename });
+}
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index 9022d3754..7e8f2d4ec 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -3,14 +3,14 @@
#ifndef cmExtraSublimeTextGenerator_h
#define cmExtraSublimeTextGenerator_h
-#include "cmConfigure.h"
-
-#include "cmExternalMakefileProjectGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
#include <string>
#include <vector>
+#include "cmExternalMakefileProjectGenerator.h"
+
class cmGeneratedFileStream;
class cmGeneratorTarget;
class cmLocalGenerator;
@@ -24,10 +24,10 @@ class cmExtraSublimeTextGenerator : public cmExternalMakefileProjectGenerator
{
public:
static cmExternalMakefileProjectGeneratorFactory* GetFactory();
- typedef std::map<std::string, std::vector<std::string> > MapSourceFileFlags;
+ using MapSourceFileFlags = std::map<std::string, std::vector<std::string>>;
cmExtraSublimeTextGenerator();
- void Generate() CM_OVERRIDE;
+ void Generate() override;
private:
void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
@@ -65,6 +65,12 @@ private:
std::string ComputeDefines(cmSourceFile* source, cmLocalGenerator* lg,
cmGeneratorTarget* gtgt);
+ std::string ComputeIncludes(cmSourceFile* source, cmLocalGenerator* lg,
+ cmGeneratorTarget* gtgt);
+
+ bool Open(const std::string& bindir, const std::string& projectName,
+ bool dryRun) override;
+
bool ExcludeBuildFolder;
std::string EnvSettings;
};
diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx
index ff78f52e3..11844e47d 100644
--- a/Source/cmFLTKWrapUICommand.cxx
+++ b/Source/cmFLTKWrapUICommand.cxx
@@ -2,122 +2,121 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFLTKWrapUICommand.h"
-#include <stddef.h>
+#include <cstddef>
#include "cmCustomCommandLines.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmRange.h"
#include "cmSourceFile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
class cmTarget;
-// cmFLTKWrapUICommand
-bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+static void FinalAction(cmMakefile& makefile, std::string const& name)
+{
+ // people should add the srcs to the target themselves, but the old command
+ // didn't support that, so check and see if they added the files in and if
+ // they didn;t then print a warning and add then anyhow
+ cmTarget* target = makefile.FindLocalNonAliasTarget(name);
+ if (!target) {
+ std::string msg = cmStrCat(
+ "FLTK_WRAP_UI was called with a target that was never created: ", name,
+ ". The problem was found while processing the source directory: ",
+ makefile.GetCurrentSourceDirectory(),
+ ". This FLTK_WRAP_UI call will be ignored.");
+ cmSystemTools::Message(msg, "Warning");
+ }
+}
+
+bool cmFLTKWrapUICommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// what is the current source dir
- std::string cdir = this->Makefile->GetCurrentSourceDirectory();
- const char* fluid_exe =
- this->Makefile->GetRequiredDefinition("FLTK_FLUID_EXECUTABLE");
+ std::string cdir = mf.GetCurrentSourceDirectory();
+ std::string const& fluid_exe =
+ mf.GetRequiredDefinition("FLTK_FLUID_EXECUTABLE");
- // get parameter for the command
- this->Target = args[0]; // Target that will use the generated files
+ // Target that will use the generated files
+ std::string const& target = args[0];
// get the list of GUI files from which .cxx and .h will be generated
- std::string outputDirectory = this->Makefile->GetCurrentBinaryDirectory();
+ std::string outputDirectory = mf.GetCurrentBinaryDirectory();
{
// Some of the generated files are *.h so the directory "GUI"
// where they are created have to be added to the include path
std::vector<std::string> outputDirectories;
outputDirectories.push_back(outputDirectory);
- this->Makefile->AddIncludeDirectories(outputDirectories);
+ mf.AddIncludeDirectories(outputDirectories);
}
- for (std::vector<std::string>::const_iterator i = (args.begin() + 1);
- i != args.end(); i++) {
- cmSourceFile* curr = this->Makefile->GetSource(*i);
+ // List of produced files.
+ std::vector<cmSourceFile*> generatedSourcesClasses;
+
+ for (std::string const& arg : cmMakeRange(args).advance(1)) {
+ cmSourceFile* curr = mf.GetSource(arg);
// if we should use the source GUI
// to generate .cxx and .h files
if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) {
- std::string outName = outputDirectory;
- outName += "/";
- outName += cmSystemTools::GetFilenameWithoutExtension(*i);
- std::string hname = outName;
- hname += ".h";
- std::string origname = cdir + "/" + *i;
+ std::string outName = cmStrCat(
+ outputDirectory, "/", cmSystemTools::GetFilenameWithoutExtension(arg));
+ std::string hname = cmStrCat(outName, ".h");
+ std::string origname = cmStrCat(cdir, "/", arg);
// add starting depends
std::vector<std::string> depends;
depends.push_back(origname);
depends.push_back(fluid_exe);
- std::string cxxres = outName;
- cxxres += ".cxx";
-
- cmCustomCommandLine commandLine;
- commandLine.push_back(fluid_exe);
- commandLine.push_back("-c"); // instructs Fluid to run in command line
- commandLine.push_back("-h"); // optionally rename .h files
- commandLine.push_back(hname);
- commandLine.push_back("-o"); // optionally rename .cxx files
- commandLine.push_back(cxxres);
- commandLine.push_back(origname); // name of the GUI fluid file
- cmCustomCommandLines commandLines;
- commandLines.push_back(commandLine);
+ std::string cxxres = cmStrCat(outName, ".cxx");
+
+ cmCustomCommandLines commandLines = cmMakeSingleCommandLine({
+ fluid_exe,
+ "-c", // instructs Fluid to run in command line
+ "-h", // optionally rename .h files
+ hname,
+ "-o", // optionally rename .cxx files
+ cxxres,
+ origname // name of the GUI fluid file
+ });
// Add command for generating the .h and .cxx files
std::string no_main_dependency;
- const char* no_comment = CM_NULLPTR;
- const char* no_working_dir = CM_NULLPTR;
- this->Makefile->AddCustomCommandToOutput(
- cxxres, depends, no_main_dependency, commandLines, no_comment,
- no_working_dir);
- this->Makefile->AddCustomCommandToOutput(
- hname, depends, no_main_dependency, commandLines, no_comment,
- no_working_dir);
-
- cmSourceFile* sf = this->Makefile->GetSource(cxxres);
+ const char* no_comment = nullptr;
+ const char* no_working_dir = nullptr;
+ mf.AddCustomCommandToOutput(cxxres, depends, no_main_dependency,
+ commandLines, no_comment, no_working_dir);
+ mf.AddCustomCommandToOutput(hname, depends, no_main_dependency,
+ commandLines, no_comment, no_working_dir);
+
+ cmSourceFile* sf = mf.GetSource(cxxres);
sf->AddDepend(hname);
sf->AddDepend(origname);
- this->GeneratedSourcesClasses.push_back(sf);
+ generatedSourcesClasses.push_back(sf);
}
}
// create the variable with the list of sources in it
- size_t lastHeadersClass = this->GeneratedSourcesClasses.size();
+ size_t lastHeadersClass = generatedSourcesClasses.size();
std::string sourceListValue;
for (size_t classNum = 0; classNum < lastHeadersClass; classNum++) {
if (classNum) {
sourceListValue += ";";
}
- sourceListValue += this->GeneratedSourcesClasses[classNum]->GetFullPath();
+ sourceListValue += generatedSourcesClasses[classNum]->ResolveFullPath();
}
- std::string varName = this->Target;
- varName += "_FLTK_UI_SRCS";
- this->Makefile->AddDefinition(varName, sourceListValue.c_str());
- return true;
-}
+ std::string const varName = target + "_FLTK_UI_SRCS";
+ mf.AddDefinition(varName, sourceListValue);
-void cmFLTKWrapUICommand::FinalPass()
-{
- // people should add the srcs to the target themselves, but the old command
- // didn't support that, so check and see if they added the files in and if
- // they didn;t then print a warning and add then anyhow
- cmTarget* target = this->Makefile->FindLocalNonAliasTarget(this->Target);
- if (!target) {
- std::string msg =
- "FLTK_WRAP_UI was called with a target that was never created: ";
- msg += this->Target;
- msg += ". The problem was found while processing the source directory: ";
- msg += this->Makefile->GetCurrentSourceDirectory();
- msg += ". This FLTK_WRAP_UI call will be ignored.";
- cmSystemTools::Message(msg.c_str(), "Warning");
- return;
- }
+ mf.AddFinalAction(
+ [target](cmMakefile& makefile) { FinalAction(makefile, target); });
+ return true;
}
diff --git a/Source/cmFLTKWrapUICommand.h b/Source/cmFLTKWrapUICommand.h
index d8045ab6a..bb56dbd44 100644
--- a/Source/cmFLTKWrapUICommand.h
+++ b/Source/cmFLTKWrapUICommand.h
@@ -3,57 +3,14 @@
#ifndef cmFLTKWrapUICommand_h
#define cmFLTKWrapUICommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmSourceFile;
-
-/** \class cmFLTKWrapUICommand
- * \brief Create .h and .cxx files rules for FLTK user interfaces files
- *
- * cmFLTKWrapUICommand is used to create wrappers for FLTK classes into
- * normal C++
- */
-class cmFLTKWrapUICommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmFLTKWrapUICommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
- /**
- * This is called at the end after all the information
- * specified by the command is accumulated. Most commands do
- * not implement this method. At this point, reading and
- * writing to the cache can be done.
- */
- void FinalPass() CM_OVERRIDE;
- bool HasFinalPass() const CM_OVERRIDE { return true; }
-
-private:
- /**
- * List of produced files.
- */
- std::vector<cmSourceFile*> GeneratedSourcesClasses;
- /**
- * List of Fluid files that provide the source
- * generating .cxx and .h files
- */
- std::string Target;
-};
+bool cmFLTKWrapUICommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmFSPermissions.cxx b/Source/cmFSPermissions.cxx
new file mode 100644
index 000000000..4015a5164
--- /dev/null
+++ b/Source/cmFSPermissions.cxx
@@ -0,0 +1,34 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmFSPermissions.h"
+
+bool cmFSPermissions::stringToModeT(std::string const& arg,
+ mode_t& permissions)
+{
+ if (arg == "OWNER_READ") {
+ permissions |= mode_owner_read;
+ } else if (arg == "OWNER_WRITE") {
+ permissions |= mode_owner_write;
+ } else if (arg == "OWNER_EXECUTE") {
+ permissions |= mode_owner_execute;
+ } else if (arg == "GROUP_READ") {
+ permissions |= mode_group_read;
+ } else if (arg == "GROUP_WRITE") {
+ permissions |= mode_group_write;
+ } else if (arg == "GROUP_EXECUTE") {
+ permissions |= mode_group_execute;
+ } else if (arg == "WORLD_READ") {
+ permissions |= mode_world_read;
+ } else if (arg == "WORLD_WRITE") {
+ permissions |= mode_world_write;
+ } else if (arg == "WORLD_EXECUTE") {
+ permissions |= mode_world_execute;
+ } else if (arg == "SETUID") {
+ permissions |= mode_setuid;
+ } else if (arg == "SETGID") {
+ permissions |= mode_setgid;
+ } else {
+ return false;
+ }
+ return true;
+}
diff --git a/Source/cmFSPermissions.h b/Source/cmFSPermissions.h
new file mode 100644
index 000000000..fef72e616
--- /dev/null
+++ b/Source/cmFSPermissions.h
@@ -0,0 +1,45 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmFSPermissions_h
+#define cmFSPermissions_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+
+#include "cm_sys_stat.h"
+
+namespace cmFSPermissions {
+
+// Table of permissions flags.
+#if defined(_WIN32) && !defined(__CYGWIN__)
+static const mode_t mode_owner_read = S_IREAD;
+static const mode_t mode_owner_write = S_IWRITE;
+static const mode_t mode_owner_execute = S_IEXEC;
+static const mode_t mode_group_read = 040;
+static const mode_t mode_group_write = 020;
+static const mode_t mode_group_execute = 010;
+static const mode_t mode_world_read = 04;
+static const mode_t mode_world_write = 02;
+static const mode_t mode_world_execute = 01;
+static const mode_t mode_setuid = 04000;
+static const mode_t mode_setgid = 02000;
+#else
+static const mode_t mode_owner_read = S_IRUSR;
+static const mode_t mode_owner_write = S_IWUSR;
+static const mode_t mode_owner_execute = S_IXUSR;
+static const mode_t mode_group_read = S_IRGRP;
+static const mode_t mode_group_write = S_IWGRP;
+static const mode_t mode_group_execute = S_IXGRP;
+static const mode_t mode_world_read = S_IROTH;
+static const mode_t mode_world_write = S_IWOTH;
+static const mode_t mode_world_execute = S_IXOTH;
+static const mode_t mode_setuid = S_ISUID;
+static const mode_t mode_setgid = S_ISGID;
+#endif
+
+bool stringToModeT(std::string const& arg, mode_t& permissions);
+
+} // ns
+
+#endif
diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx
new file mode 100644
index 000000000..a56ad22f6
--- /dev/null
+++ b/Source/cmFileAPI.cxx
@@ -0,0 +1,832 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmFileAPI.h"
+
+#include <algorithm>
+#include <cassert>
+#include <chrono>
+#include <cstddef>
+#include <ctime>
+#include <iomanip>
+#include <sstream>
+#include <utility>
+
+#include "cmsys/Directory.hxx"
+#include "cmsys/FStream.hxx"
+
+#include "cmCryptoHash.h"
+#include "cmFileAPICMakeFiles.h"
+#include "cmFileAPICache.h"
+#include "cmFileAPICodemodel.h"
+#include "cmGlobalGenerator.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmTimestamp.h"
+#include "cmake.h"
+
+cmFileAPI::cmFileAPI(cmake* cm)
+ : CMakeInstance(cm)
+{
+ this->APIv1 =
+ this->CMakeInstance->GetHomeOutputDirectory() + "/.cmake/api/v1";
+
+ Json::CharReaderBuilder rbuilder;
+ rbuilder["collectComments"] = false;
+ rbuilder["failIfExtra"] = true;
+ rbuilder["rejectDupKeys"] = false;
+ rbuilder["strictRoot"] = true;
+ this->JsonReader =
+ std::unique_ptr<Json::CharReader>(rbuilder.newCharReader());
+
+ Json::StreamWriterBuilder wbuilder;
+ wbuilder["indentation"] = "\t";
+ this->JsonWriter =
+ std::unique_ptr<Json::StreamWriter>(wbuilder.newStreamWriter());
+}
+
+void cmFileAPI::ReadQueries()
+{
+ std::string const query_dir = this->APIv1 + "/query";
+ this->QueryExists = cmSystemTools::FileIsDirectory(query_dir);
+ if (!this->QueryExists) {
+ return;
+ }
+
+ // Load queries at the top level.
+ std::vector<std::string> queries = cmFileAPI::LoadDir(query_dir);
+
+ // Read the queries and save for later.
+ for (std::string& query : queries) {
+ if (cmHasLiteralPrefix(query, "client-")) {
+ this->ReadClient(query);
+ } else if (!cmFileAPI::ReadQuery(query, this->TopQuery.Known)) {
+ this->TopQuery.Unknown.push_back(std::move(query));
+ }
+ }
+}
+
+void cmFileAPI::WriteReplies()
+{
+ if (this->QueryExists) {
+ cmSystemTools::MakeDirectory(this->APIv1 + "/reply");
+ this->WriteJsonFile(this->BuildReplyIndex(), "index", ComputeSuffixTime);
+ }
+
+ this->RemoveOldReplyFiles();
+}
+
+std::vector<std::string> cmFileAPI::LoadDir(std::string const& dir)
+{
+ std::vector<std::string> files;
+ cmsys::Directory d;
+ d.Load(dir);
+ for (unsigned long i = 0; i < d.GetNumberOfFiles(); ++i) {
+ std::string f = d.GetFile(i);
+ if (f != "." && f != "..") {
+ files.push_back(std::move(f));
+ }
+ }
+ std::sort(files.begin(), files.end());
+ return files;
+}
+
+void cmFileAPI::RemoveOldReplyFiles()
+{
+ std::string const reply_dir = this->APIv1 + "/reply";
+ std::vector<std::string> files = this->LoadDir(reply_dir);
+ for (std::string const& f : files) {
+ if (this->ReplyFiles.find(f) == this->ReplyFiles.end()) {
+ std::string file = cmStrCat(reply_dir, "/", f);
+ cmSystemTools::RemoveFile(file);
+ }
+ }
+}
+
+bool cmFileAPI::ReadJsonFile(std::string const& file, Json::Value& value,
+ std::string& error)
+{
+ std::vector<char> content;
+
+ cmsys::ifstream fin;
+ if (!cmSystemTools::FileIsDirectory(file)) {
+ fin.open(file.c_str(), std::ios::binary);
+ }
+ auto finEnd = fin.rdbuf()->pubseekoff(0, std::ios::end);
+ if (finEnd > 0) {
+ size_t finSize = finEnd;
+ try {
+ // Allocate a buffer to read the whole file.
+ content.resize(finSize);
+
+ // Now read the file from the beginning.
+ fin.seekg(0, std::ios::beg);
+ fin.read(content.data(), finSize);
+ } catch (...) {
+ fin.setstate(std::ios::failbit);
+ }
+ }
+ fin.close();
+ if (!fin) {
+ value = Json::Value();
+ error = "failed to read from file";
+ return false;
+ }
+
+ // Parse our buffer as json.
+ if (!this->JsonReader->parse(content.data(), content.data() + content.size(),
+ &value, &error)) {
+ value = Json::Value();
+ return false;
+ }
+
+ return true;
+}
+
+std::string cmFileAPI::WriteJsonFile(
+ Json::Value const& value, std::string const& prefix,
+ std::string (*computeSuffix)(std::string const&))
+{
+ std::string fileName;
+
+ // Write the json file with a temporary name.
+ std::string const& tmpFile = this->APIv1 + "/tmp.json";
+ cmsys::ofstream ftmp(tmpFile.c_str());
+ this->JsonWriter->write(value, &ftmp);
+ ftmp << "\n";
+ ftmp.close();
+ if (!ftmp) {
+ cmSystemTools::RemoveFile(tmpFile);
+ return fileName;
+ }
+
+ // Compute the final name for the file.
+ fileName = prefix + "-" + computeSuffix(tmpFile) + ".json";
+
+ // Create the destination.
+ std::string file = this->APIv1 + "/reply";
+ cmSystemTools::MakeDirectory(file);
+ file += "/";
+ file += fileName;
+
+ // If the final name already exists then assume it has proper content.
+ // Otherwise, atomically place the reply file at its final name
+ if (cmSystemTools::FileExists(file, true) ||
+ !cmSystemTools::RenameFile(tmpFile, file)) {
+ cmSystemTools::RemoveFile(tmpFile);
+ }
+
+ // Record this among files we have just written.
+ this->ReplyFiles.insert(fileName);
+
+ return fileName;
+}
+
+Json::Value cmFileAPI::MaybeJsonFile(Json::Value in, std::string const& prefix)
+{
+ Json::Value out;
+ if (in.isObject() || in.isArray()) {
+ out = Json::objectValue;
+ out["jsonFile"] = this->WriteJsonFile(in, prefix);
+ } else {
+ out = std::move(in);
+ }
+ return out;
+}
+
+std::string cmFileAPI::ComputeSuffixHash(std::string const& file)
+{
+ cmCryptoHash hasher(cmCryptoHash::AlgoSHA3_256);
+ std::string hash = hasher.HashFile(file);
+ hash.resize(20, '0');
+ return hash;
+}
+
+std::string cmFileAPI::ComputeSuffixTime(std::string const&)
+{
+ std::chrono::milliseconds ms =
+ std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::system_clock::now().time_since_epoch());
+ std::chrono::seconds s =
+ std::chrono::duration_cast<std::chrono::seconds>(ms);
+
+ std::time_t ts = s.count();
+ std::size_t tms = ms.count() % 1000;
+
+ cmTimestamp cmts;
+ std::ostringstream ss;
+ ss << cmts.CreateTimestampFromTimeT(ts, "%Y-%m-%dT%H-%M-%S", true) << '-'
+ << std::setfill('0') << std::setw(4) << tms;
+ return ss.str();
+}
+
+bool cmFileAPI::ReadQuery(std::string const& query,
+ std::vector<Object>& objects)
+{
+ // Parse the "<kind>-" syntax.
+ std::string::size_type sep_pos = query.find('-');
+ if (sep_pos == std::string::npos) {
+ return false;
+ }
+ std::string kindName = query.substr(0, sep_pos);
+ std::string verStr = query.substr(sep_pos + 1);
+ if (kindName == ObjectKindName(ObjectKind::CodeModel)) {
+ Object o;
+ o.Kind = ObjectKind::CodeModel;
+ if (verStr == "v2") {
+ o.Version = 2;
+ } else {
+ return false;
+ }
+ objects.push_back(o);
+ return true;
+ }
+ if (kindName == ObjectKindName(ObjectKind::Cache)) {
+ Object o;
+ o.Kind = ObjectKind::Cache;
+ if (verStr == "v2") {
+ o.Version = 2;
+ } else {
+ return false;
+ }
+ objects.push_back(o);
+ return true;
+ }
+ if (kindName == ObjectKindName(ObjectKind::CMakeFiles)) {
+ Object o;
+ o.Kind = ObjectKind::CMakeFiles;
+ if (verStr == "v1") {
+ o.Version = 1;
+ } else {
+ return false;
+ }
+ objects.push_back(o);
+ return true;
+ }
+ if (kindName == ObjectKindName(ObjectKind::InternalTest)) {
+ Object o;
+ o.Kind = ObjectKind::InternalTest;
+ if (verStr == "v1") {
+ o.Version = 1;
+ } else if (verStr == "v2") {
+ o.Version = 2;
+ } else {
+ return false;
+ }
+ objects.push_back(o);
+ return true;
+ }
+ return false;
+}
+
+void cmFileAPI::ReadClient(std::string const& client)
+{
+ // Load queries for the client.
+ std::string clientDir = this->APIv1 + "/query/" + client;
+ std::vector<std::string> queries = this->LoadDir(clientDir);
+
+ // Read the queries and save for later.
+ ClientQuery& clientQuery = this->ClientQueries[client];
+ for (std::string& query : queries) {
+ if (query == "query.json") {
+ clientQuery.HaveQueryJson = true;
+ this->ReadClientQuery(client, clientQuery.QueryJson);
+ } else if (!this->ReadQuery(query, clientQuery.DirQuery.Known)) {
+ clientQuery.DirQuery.Unknown.push_back(std::move(query));
+ }
+ }
+}
+
+void cmFileAPI::ReadClientQuery(std::string const& client, ClientQueryJson& q)
+{
+ // Read the query.json file.
+ std::string queryFile = this->APIv1 + "/query/" + client + "/query.json";
+ Json::Value query;
+ if (!this->ReadJsonFile(queryFile, query, q.Error)) {
+ return;
+ }
+ if (!query.isObject()) {
+ q.Error = "query root is not an object";
+ return;
+ }
+
+ Json::Value const& clientValue = query["client"];
+ if (!clientValue.isNull()) {
+ q.ClientValue = clientValue;
+ }
+ q.RequestsValue = std::move(query["requests"]);
+ q.Requests = this->BuildClientRequests(q.RequestsValue);
+}
+
+Json::Value cmFileAPI::BuildReplyIndex()
+{
+ Json::Value index(Json::objectValue);
+
+ // Report information about this version of CMake.
+ index["cmake"] = this->BuildCMake();
+
+ // Reply to all queries that we loaded.
+ Json::Value& reply = index["reply"] = this->BuildReply(this->TopQuery);
+ for (auto const& client : this->ClientQueries) {
+ std::string const& clientName = client.first;
+ ClientQuery const& clientQuery = client.second;
+ reply[clientName] = this->BuildClientReply(clientQuery);
+ }
+
+ // Move our index of generated objects into its field.
+ Json::Value& objects = index["objects"] = Json::arrayValue;
+ for (auto& entry : this->ReplyIndexObjects) {
+ objects.append(std::move(entry.second)); // NOLINT(*)
+ }
+
+ return index;
+}
+
+Json::Value cmFileAPI::BuildCMake()
+{
+ Json::Value cmake = Json::objectValue;
+ cmake["version"] = this->CMakeInstance->ReportVersionJson();
+ Json::Value& cmake_paths = cmake["paths"] = Json::objectValue;
+ cmake_paths["cmake"] = cmSystemTools::GetCMakeCommand();
+ cmake_paths["ctest"] = cmSystemTools::GetCTestCommand();
+ cmake_paths["cpack"] = cmSystemTools::GetCPackCommand();
+ cmake_paths["root"] = cmSystemTools::GetCMakeRoot();
+ cmake["generator"] = this->CMakeInstance->GetGlobalGenerator()->GetJson();
+ return cmake;
+}
+
+Json::Value cmFileAPI::BuildReply(Query const& q)
+{
+ Json::Value reply = Json::objectValue;
+ for (Object const& o : q.Known) {
+ std::string const& name = ObjectName(o);
+ reply[name] = this->AddReplyIndexObject(o);
+ }
+
+ for (std::string const& name : q.Unknown) {
+ reply[name] = cmFileAPI::BuildReplyError("unknown query file");
+ }
+ return reply;
+}
+
+Json::Value cmFileAPI::BuildReplyError(std::string const& error)
+{
+ Json::Value e = Json::objectValue;
+ e["error"] = error;
+ return e;
+}
+
+Json::Value const& cmFileAPI::AddReplyIndexObject(Object const& o)
+{
+ Json::Value& indexEntry = this->ReplyIndexObjects[o];
+ if (!indexEntry.isNull()) {
+ // The reply object has already been generated.
+ return indexEntry;
+ }
+
+ // Generate this reply object.
+ Json::Value const& object = this->BuildObject(o);
+ assert(object.isObject());
+
+ // Populate this index entry.
+ indexEntry = Json::objectValue;
+ indexEntry["kind"] = object["kind"];
+ indexEntry["version"] = object["version"];
+ indexEntry["jsonFile"] = this->WriteJsonFile(object, ObjectName(o));
+ return indexEntry;
+}
+
+const char* cmFileAPI::ObjectKindName(ObjectKind kind)
+{
+ // Keep in sync with ObjectKind enum.
+ static const char* objectKindNames[] = {
+ "codemodel", //
+ "cache", //
+ "cmakeFiles", //
+ "__test" //
+ };
+ return objectKindNames[size_t(kind)];
+}
+
+std::string cmFileAPI::ObjectName(Object const& o)
+{
+ std::string name = cmStrCat(ObjectKindName(o.Kind), "-v", o.Version);
+ return name;
+}
+
+Json::Value cmFileAPI::BuildVersion(unsigned int major, unsigned int minor)
+{
+ Json::Value version;
+ version["major"] = major;
+ version["minor"] = minor;
+ return version;
+}
+
+Json::Value cmFileAPI::BuildObject(Object const& object)
+{
+ Json::Value value;
+
+ switch (object.Kind) {
+ case ObjectKind::CodeModel:
+ value = this->BuildCodeModel(object);
+ break;
+ case ObjectKind::Cache:
+ value = this->BuildCache(object);
+ break;
+ case ObjectKind::CMakeFiles:
+ value = this->BuildCMakeFiles(object);
+ break;
+ case ObjectKind::InternalTest:
+ value = this->BuildInternalTest(object);
+ break;
+ }
+
+ return value;
+}
+
+cmFileAPI::ClientRequests cmFileAPI::BuildClientRequests(
+ Json::Value const& requests)
+{
+ ClientRequests result;
+ if (requests.isNull()) {
+ result.Error = "'requests' member missing";
+ return result;
+ }
+ if (!requests.isArray()) {
+ result.Error = "'requests' member is not an array";
+ return result;
+ }
+
+ result.reserve(requests.size());
+ for (Json::Value const& request : requests) {
+ result.emplace_back(this->BuildClientRequest(request));
+ }
+
+ return result;
+}
+
+cmFileAPI::ClientRequest cmFileAPI::BuildClientRequest(
+ Json::Value const& request)
+{
+ ClientRequest r;
+
+ if (!request.isObject()) {
+ r.Error = "request is not an object";
+ return r;
+ }
+
+ Json::Value const& kind = request["kind"];
+ if (kind.isNull()) {
+ r.Error = "'kind' member missing";
+ return r;
+ }
+ if (!kind.isString()) {
+ r.Error = "'kind' member is not a string";
+ return r;
+ }
+ std::string const& kindName = kind.asString();
+
+ if (kindName == this->ObjectKindName(ObjectKind::CodeModel)) {
+ r.Kind = ObjectKind::CodeModel;
+ } else if (kindName == this->ObjectKindName(ObjectKind::Cache)) {
+ r.Kind = ObjectKind::Cache;
+ } else if (kindName == this->ObjectKindName(ObjectKind::CMakeFiles)) {
+ r.Kind = ObjectKind::CMakeFiles;
+ } else if (kindName == this->ObjectKindName(ObjectKind::InternalTest)) {
+ r.Kind = ObjectKind::InternalTest;
+ } else {
+ r.Error = "unknown request kind '" + kindName + "'";
+ return r;
+ }
+
+ Json::Value const& version = request["version"];
+ if (version.isNull()) {
+ r.Error = "'version' member missing";
+ return r;
+ }
+ std::vector<RequestVersion> versions;
+ if (!cmFileAPI::ReadRequestVersions(version, versions, r.Error)) {
+ return r;
+ }
+
+ switch (r.Kind) {
+ case ObjectKind::CodeModel:
+ this->BuildClientRequestCodeModel(r, versions);
+ break;
+ case ObjectKind::Cache:
+ this->BuildClientRequestCache(r, versions);
+ break;
+ case ObjectKind::CMakeFiles:
+ this->BuildClientRequestCMakeFiles(r, versions);
+ break;
+ case ObjectKind::InternalTest:
+ this->BuildClientRequestInternalTest(r, versions);
+ break;
+ }
+
+ return r;
+}
+
+Json::Value cmFileAPI::BuildClientReply(ClientQuery const& q)
+{
+ Json::Value reply = this->BuildReply(q.DirQuery);
+
+ if (!q.HaveQueryJson) {
+ return reply;
+ }
+
+ Json::Value& reply_query_json = reply["query.json"];
+ ClientQueryJson const& qj = q.QueryJson;
+
+ if (!qj.Error.empty()) {
+ reply_query_json = this->BuildReplyError(qj.Error);
+ return reply;
+ }
+
+ if (!qj.ClientValue.isNull()) {
+ reply_query_json["client"] = qj.ClientValue;
+ }
+
+ if (!qj.RequestsValue.isNull()) {
+ reply_query_json["requests"] = qj.RequestsValue;
+ }
+
+ reply_query_json["responses"] = this->BuildClientReplyResponses(qj.Requests);
+
+ return reply;
+}
+
+Json::Value cmFileAPI::BuildClientReplyResponses(
+ ClientRequests const& requests)
+{
+ Json::Value responses;
+
+ if (!requests.Error.empty()) {
+ responses = this->BuildReplyError(requests.Error);
+ return responses;
+ }
+
+ responses = Json::arrayValue;
+ for (ClientRequest const& request : requests) {
+ responses.append(this->BuildClientReplyResponse(request));
+ }
+
+ return responses;
+}
+
+Json::Value cmFileAPI::BuildClientReplyResponse(ClientRequest const& request)
+{
+ Json::Value response;
+ if (!request.Error.empty()) {
+ response = this->BuildReplyError(request.Error);
+ return response;
+ }
+ response = this->AddReplyIndexObject(request);
+ return response;
+}
+
+bool cmFileAPI::ReadRequestVersions(Json::Value const& version,
+ std::vector<RequestVersion>& versions,
+ std::string& error)
+{
+ if (version.isArray()) {
+ for (Json::Value const& v : version) {
+ if (!ReadRequestVersion(v, /*inArray=*/true, versions, error)) {
+ return false;
+ }
+ }
+ } else {
+ if (!ReadRequestVersion(version, /*inArray=*/false, versions, error)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool cmFileAPI::ReadRequestVersion(Json::Value const& version, bool inArray,
+ std::vector<RequestVersion>& result,
+ std::string& error)
+{
+ if (version.isUInt()) {
+ RequestVersion v;
+ v.Major = version.asUInt();
+ result.push_back(v);
+ return true;
+ }
+
+ if (!version.isObject()) {
+ if (inArray) {
+ error = "'version' array entry is not a non-negative integer or object";
+ } else {
+ error =
+ "'version' member is not a non-negative integer, object, or array";
+ }
+ return false;
+ }
+
+ Json::Value const& major = version["major"];
+ if (major.isNull()) {
+ error = "'version' object 'major' member missing";
+ return false;
+ }
+ if (!major.isUInt()) {
+ error = "'version' object 'major' member is not a non-negative integer";
+ return false;
+ }
+
+ RequestVersion v;
+ v.Major = major.asUInt();
+
+ Json::Value const& minor = version["minor"];
+ if (minor.isUInt()) {
+ v.Minor = minor.asUInt();
+ } else if (!minor.isNull()) {
+ error = "'version' object 'minor' member is not a non-negative integer";
+ return false;
+ }
+
+ result.push_back(v);
+
+ return true;
+}
+
+std::string cmFileAPI::NoSupportedVersion(
+ std::vector<RequestVersion> const& versions)
+{
+ std::ostringstream msg;
+ msg << "no supported version specified";
+ if (!versions.empty()) {
+ msg << " among:";
+ for (RequestVersion const& v : versions) {
+ msg << " " << v.Major << "." << v.Minor;
+ }
+ }
+ return msg.str();
+}
+
+// The "codemodel" object kind.
+
+static unsigned int const CodeModelV2Minor = 0;
+
+void cmFileAPI::BuildClientRequestCodeModel(
+ ClientRequest& r, std::vector<RequestVersion> const& versions)
+{
+ // Select a known version from those requested.
+ for (RequestVersion const& v : versions) {
+ if ((v.Major == 2 && v.Minor <= CodeModelV2Minor)) {
+ r.Version = v.Major;
+ break;
+ }
+ }
+ if (!r.Version) {
+ r.Error = NoSupportedVersion(versions);
+ }
+}
+
+Json::Value cmFileAPI::BuildCodeModel(Object const& object)
+{
+ Json::Value codemodel = cmFileAPICodemodelDump(*this, object.Version);
+ codemodel["kind"] = this->ObjectKindName(object.Kind);
+
+ Json::Value& version = codemodel["version"];
+ if (object.Version == 2) {
+ version = BuildVersion(2, CodeModelV2Minor);
+ } else {
+ return codemodel; // should be unreachable
+ }
+
+ return codemodel;
+}
+
+// The "cache" object kind.
+
+static unsigned int const CacheV2Minor = 0;
+
+void cmFileAPI::BuildClientRequestCache(
+ ClientRequest& r, std::vector<RequestVersion> const& versions)
+{
+ // Select a known version from those requested.
+ for (RequestVersion const& v : versions) {
+ if ((v.Major == 2 && v.Minor <= CacheV2Minor)) {
+ r.Version = v.Major;
+ break;
+ }
+ }
+ if (!r.Version) {
+ r.Error = NoSupportedVersion(versions);
+ }
+}
+
+Json::Value cmFileAPI::BuildCache(Object const& object)
+{
+ Json::Value cache = cmFileAPICacheDump(*this, object.Version);
+ cache["kind"] = this->ObjectKindName(object.Kind);
+
+ Json::Value& version = cache["version"];
+ if (object.Version == 2) {
+ version = BuildVersion(2, CacheV2Minor);
+ } else {
+ return cache; // should be unreachable
+ }
+
+ return cache;
+}
+
+// The "cmakeFiles" object kind.
+
+static unsigned int const CMakeFilesV1Minor = 0;
+
+void cmFileAPI::BuildClientRequestCMakeFiles(
+ ClientRequest& r, std::vector<RequestVersion> const& versions)
+{
+ // Select a known version from those requested.
+ for (RequestVersion const& v : versions) {
+ if ((v.Major == 1 && v.Minor <= CMakeFilesV1Minor)) {
+ r.Version = v.Major;
+ break;
+ }
+ }
+ if (!r.Version) {
+ r.Error = NoSupportedVersion(versions);
+ }
+}
+
+Json::Value cmFileAPI::BuildCMakeFiles(Object const& object)
+{
+ Json::Value cmakeFiles = cmFileAPICMakeFilesDump(*this, object.Version);
+ cmakeFiles["kind"] = this->ObjectKindName(object.Kind);
+
+ Json::Value& version = cmakeFiles["version"];
+ if (object.Version == 1) {
+ version = BuildVersion(1, CMakeFilesV1Minor);
+ } else {
+ return cmakeFiles; // should be unreachable
+ }
+
+ return cmakeFiles;
+}
+
+// The "__test" object kind is for internal testing of CMake.
+
+static unsigned int const InternalTestV1Minor = 3;
+static unsigned int const InternalTestV2Minor = 0;
+
+void cmFileAPI::BuildClientRequestInternalTest(
+ ClientRequest& r, std::vector<RequestVersion> const& versions)
+{
+ // Select a known version from those requested.
+ for (RequestVersion const& v : versions) {
+ if ((v.Major == 1 && v.Minor <= InternalTestV1Minor) || //
+ (v.Major == 2 && v.Minor <= InternalTestV2Minor)) {
+ r.Version = v.Major;
+ break;
+ }
+ }
+ if (!r.Version) {
+ r.Error = NoSupportedVersion(versions);
+ }
+}
+
+Json::Value cmFileAPI::BuildInternalTest(Object const& object)
+{
+ Json::Value test = Json::objectValue;
+ test["kind"] = this->ObjectKindName(object.Kind);
+ Json::Value& version = test["version"];
+ if (object.Version == 2) {
+ version = BuildVersion(2, InternalTestV2Minor);
+ } else {
+ version = BuildVersion(1, InternalTestV1Minor);
+ }
+ return test;
+}
+
+Json::Value cmFileAPI::ReportCapabilities()
+{
+ Json::Value capabilities = Json::objectValue;
+ Json::Value& requests = capabilities["requests"] = Json::arrayValue;
+
+ {
+ Json::Value request = Json::objectValue;
+ request["kind"] = ObjectKindName(ObjectKind::CodeModel);
+ Json::Value& versions = request["version"] = Json::arrayValue;
+ versions.append(BuildVersion(2, CodeModelV2Minor));
+ requests.append(std::move(request)); // NOLINT(*)
+ }
+
+ {
+ Json::Value request = Json::objectValue;
+ request["kind"] = ObjectKindName(ObjectKind::Cache);
+ Json::Value& versions = request["version"] = Json::arrayValue;
+ versions.append(BuildVersion(2, CacheV2Minor));
+ requests.append(std::move(request)); // NOLINT(*)
+ }
+
+ {
+ Json::Value request = Json::objectValue;
+ request["kind"] = ObjectKindName(ObjectKind::CMakeFiles);
+ Json::Value& versions = request["version"] = Json::arrayValue;
+ versions.append(BuildVersion(1, CMakeFilesV1Minor));
+ requests.append(std::move(request)); // NOLINT(*)
+ }
+
+ return capabilities;
+}
diff --git a/Source/cmFileAPI.h b/Source/cmFileAPI.h
new file mode 100644
index 000000000..e183e0d97
--- /dev/null
+++ b/Source/cmFileAPI.h
@@ -0,0 +1,209 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmFileAPI_h
+#define cmFileAPI_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <map>
+#include <memory>
+#include <string>
+#include <unordered_set>
+#include <vector>
+
+#include "cm_jsoncpp_reader.h"
+#include "cm_jsoncpp_value.h"
+#include "cm_jsoncpp_writer.h"
+
+class cmake;
+
+class cmFileAPI
+{
+public:
+ cmFileAPI(cmake* cm);
+
+ /** Read fileapi queries from disk. */
+ void ReadQueries();
+
+ /** Write fileapi replies to disk. */
+ void WriteReplies();
+
+ /** Get the "cmake" instance with which this was constructed. */
+ cmake* GetCMakeInstance() const { return this->CMakeInstance; }
+
+ /** Convert a JSON object or array into an object with a single
+ "jsonFile" member specifying a file named with the given prefix
+ and holding the original object. Other JSON types are unchanged. */
+ Json::Value MaybeJsonFile(Json::Value in, std::string const& prefix);
+
+ /** Report file-api capabilities for cmake -E capabilities. */
+ static Json::Value ReportCapabilities();
+
+private:
+ cmake* CMakeInstance;
+
+ /** The api/v1 directory location. */
+ std::string APIv1;
+
+ /** The set of files we have just written to the reply directory. */
+ std::unordered_set<std::string> ReplyFiles;
+
+ static std::vector<std::string> LoadDir(std::string const& dir);
+ void RemoveOldReplyFiles();
+
+ // Keep in sync with ObjectKindName.
+ enum class ObjectKind
+ {
+ CodeModel,
+ Cache,
+ CMakeFiles,
+ InternalTest
+ };
+
+ /** Identify one object kind and major version. */
+ struct Object
+ {
+ ObjectKind Kind;
+ unsigned long Version = 0;
+ friend bool operator<(Object const& l, Object const& r)
+ {
+ if (l.Kind != r.Kind) {
+ return l.Kind < r.Kind;
+ }
+ return l.Version < r.Version;
+ }
+ };
+
+ /** Represent content of a query directory. */
+ struct Query
+ {
+ /** Known object kind-version pairs. */
+ std::vector<Object> Known;
+ /** Unknown object kind names. */
+ std::vector<std::string> Unknown;
+ };
+
+ /** Represent one request in a client 'query.json'. */
+ struct ClientRequest : public Object
+ {
+ /** Empty if request is valid, else the error string. */
+ std::string Error;
+ };
+
+ /** Represent the "requests" in a client 'query.json'. */
+ struct ClientRequests : public std::vector<ClientRequest>
+ {
+ /** Empty if requests field is valid, else the error string. */
+ std::string Error;
+ };
+
+ /** Represent the content of a client query.json file. */
+ struct ClientQueryJson
+ {
+ /** The error string if parsing failed, else empty. */
+ std::string Error;
+
+ /** The 'query.json' object "client" member if it exists, else null. */
+ Json::Value ClientValue;
+
+ /** The 'query.json' object "requests" member if it exists, else null. */
+ Json::Value RequestsValue;
+
+ /** Requests extracted from 'query.json'. */
+ ClientRequests Requests;
+ };
+
+ /** Represent content of a client query directory. */
+ struct ClientQuery
+ {
+ /** The content of the client query directory except 'query.json'. */
+ Query DirQuery;
+
+ /** True if 'query.json' exists. */
+ bool HaveQueryJson = false;
+
+ /** The 'query.json' content. */
+ ClientQueryJson QueryJson;
+ };
+
+ /** Whether the top-level query directory exists at all. */
+ bool QueryExists = false;
+
+ /** The content of the top-level query directory. */
+ Query TopQuery;
+
+ /** The content of each "client-$client" query directory. */
+ std::map<std::string, ClientQuery> ClientQueries;
+
+ /** Reply index object generated for object kind/version.
+ This populates the "objects" field of the reply index. */
+ std::map<Object, Json::Value> ReplyIndexObjects;
+
+ std::unique_ptr<Json::CharReader> JsonReader;
+ std::unique_ptr<Json::StreamWriter> JsonWriter;
+
+ bool ReadJsonFile(std::string const& file, Json::Value& value,
+ std::string& error);
+
+ std::string WriteJsonFile(
+ Json::Value const& value, std::string const& prefix,
+ std::string (*computeSuffix)(std::string const&) = ComputeSuffixHash);
+ static std::string ComputeSuffixHash(std::string const&);
+ static std::string ComputeSuffixTime(std::string const&);
+
+ static bool ReadQuery(std::string const& query,
+ std::vector<Object>& objects);
+ void ReadClient(std::string const& client);
+ void ReadClientQuery(std::string const& client, ClientQueryJson& q);
+
+ Json::Value BuildReplyIndex();
+ Json::Value BuildCMake();
+ Json::Value BuildReply(Query const& q);
+ static Json::Value BuildReplyError(std::string const& error);
+ Json::Value const& AddReplyIndexObject(Object const& o);
+
+ static const char* ObjectKindName(ObjectKind kind);
+ static std::string ObjectName(Object const& o);
+
+ static Json::Value BuildVersion(unsigned int major, unsigned int minor);
+
+ Json::Value BuildObject(Object const& object);
+
+ ClientRequests BuildClientRequests(Json::Value const& requests);
+ ClientRequest BuildClientRequest(Json::Value const& request);
+ Json::Value BuildClientReply(ClientQuery const& q);
+ Json::Value BuildClientReplyResponses(ClientRequests const& requests);
+ Json::Value BuildClientReplyResponse(ClientRequest const& request);
+
+ struct RequestVersion
+ {
+ unsigned int Major = 0;
+ unsigned int Minor = 0;
+ };
+ static bool ReadRequestVersions(Json::Value const& version,
+ std::vector<RequestVersion>& versions,
+ std::string& error);
+ static bool ReadRequestVersion(Json::Value const& version, bool inArray,
+ std::vector<RequestVersion>& result,
+ std::string& error);
+ static std::string NoSupportedVersion(
+ std::vector<RequestVersion> const& versions);
+
+ void BuildClientRequestCodeModel(
+ ClientRequest& r, std::vector<RequestVersion> const& versions);
+ Json::Value BuildCodeModel(Object const& object);
+
+ void BuildClientRequestCache(ClientRequest& r,
+ std::vector<RequestVersion> const& versions);
+ Json::Value BuildCache(Object const& object);
+
+ void BuildClientRequestCMakeFiles(
+ ClientRequest& r, std::vector<RequestVersion> const& versions);
+ Json::Value BuildCMakeFiles(Object const& object);
+
+ void BuildClientRequestInternalTest(
+ ClientRequest& r, std::vector<RequestVersion> const& versions);
+ Json::Value BuildInternalTest(Object const& object);
+};
+
+#endif
diff --git a/Source/cmFileAPICMakeFiles.cxx b/Source/cmFileAPICMakeFiles.cxx
new file mode 100644
index 000000000..f41999771
--- /dev/null
+++ b/Source/cmFileAPICMakeFiles.cxx
@@ -0,0 +1,114 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmFileAPICMakeFiles.h"
+
+#include <string>
+#include <vector>
+
+#include "cm_jsoncpp_value.h"
+
+#include "cmFileAPI.h"
+#include "cmGlobalGenerator.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
+#include "cmSystemTools.h"
+#include "cmake.h"
+
+namespace {
+
+class CMakeFiles
+{
+ cmFileAPI& FileAPI;
+ unsigned long Version;
+ std::string CMakeModules;
+ std::string const& TopSource;
+ std::string const& TopBuild;
+ bool OutOfSource;
+
+ Json::Value DumpPaths();
+ Json::Value DumpInputs();
+ Json::Value DumpInput(std::string const& file);
+
+public:
+ CMakeFiles(cmFileAPI& fileAPI, unsigned long version);
+ Json::Value Dump();
+};
+
+CMakeFiles::CMakeFiles(cmFileAPI& fileAPI, unsigned long version)
+ : FileAPI(fileAPI)
+ , Version(version)
+ , CMakeModules(cmSystemTools::GetCMakeRoot() + "/Modules")
+ , TopSource(this->FileAPI.GetCMakeInstance()->GetHomeDirectory())
+ , TopBuild(this->FileAPI.GetCMakeInstance()->GetHomeOutputDirectory())
+ , OutOfSource(TopBuild != TopSource)
+{
+ static_cast<void>(this->Version);
+}
+
+Json::Value CMakeFiles::Dump()
+{
+ Json::Value cmakeFiles = Json::objectValue;
+ cmakeFiles["paths"] = this->DumpPaths();
+ cmakeFiles["inputs"] = DumpInputs();
+ return cmakeFiles;
+}
+
+Json::Value CMakeFiles::DumpPaths()
+{
+ Json::Value paths = Json::objectValue;
+ paths["source"] = this->TopSource;
+ paths["build"] = this->TopBuild;
+ return paths;
+}
+
+Json::Value CMakeFiles::DumpInputs()
+{
+ Json::Value inputs = Json::arrayValue;
+
+ cmGlobalGenerator* gg =
+ this->FileAPI.GetCMakeInstance()->GetGlobalGenerator();
+ for (cmLocalGenerator const* lg : gg->GetLocalGenerators()) {
+ cmMakefile const* mf = lg->GetMakefile();
+ for (std::string const& file : mf->GetListFiles()) {
+ inputs.append(this->DumpInput(file));
+ }
+ }
+
+ return inputs;
+}
+
+Json::Value CMakeFiles::DumpInput(std::string const& file)
+{
+ Json::Value input = Json::objectValue;
+
+ bool const isCMake = cmSystemTools::IsSubDirectory(file, this->CMakeModules);
+ if (isCMake) {
+ input["isCMake"] = true;
+ }
+
+ if (!cmSystemTools::IsSubDirectory(file, this->TopSource) &&
+ !cmSystemTools::IsSubDirectory(file, this->TopBuild)) {
+ input["isExternal"] = true;
+ }
+
+ if (this->OutOfSource &&
+ cmSystemTools::IsSubDirectory(file, this->TopBuild)) {
+ input["isGenerated"] = true;
+ }
+
+ std::string path = file;
+ if (!isCMake && cmSystemTools::IsSubDirectory(path, this->TopSource)) {
+ // Use a relative path within the source directory.
+ path = cmSystemTools::RelativePath(this->TopSource, path);
+ }
+ input["path"] = path;
+
+ return input;
+}
+}
+
+Json::Value cmFileAPICMakeFilesDump(cmFileAPI& fileAPI, unsigned long version)
+{
+ CMakeFiles cmakeFiles(fileAPI, version);
+ return cmakeFiles.Dump();
+}
diff --git a/Source/cmFileAPICMakeFiles.h b/Source/cmFileAPICMakeFiles.h
new file mode 100644
index 000000000..a851c32f4
--- /dev/null
+++ b/Source/cmFileAPICMakeFiles.h
@@ -0,0 +1,15 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmFileAPICMakeFiles_h
+#define cmFileAPICMakeFiles_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include "cm_jsoncpp_value.h"
+
+class cmFileAPI;
+
+extern Json::Value cmFileAPICMakeFilesDump(cmFileAPI& fileAPI,
+ unsigned long version);
+
+#endif
diff --git a/Source/cmFileAPICache.cxx b/Source/cmFileAPICache.cxx
new file mode 100644
index 000000000..ef7779567
--- /dev/null
+++ b/Source/cmFileAPICache.cxx
@@ -0,0 +1,106 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmFileAPICache.h"
+
+#include <algorithm>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "cm_jsoncpp_value.h"
+
+#include "cmFileAPI.h"
+#include "cmState.h"
+#include "cmake.h"
+
+namespace {
+
+class Cache
+{
+ cmFileAPI& FileAPI;
+ unsigned long Version;
+ cmState* State;
+
+ Json::Value DumpEntries();
+ Json::Value DumpEntry(std::string const& name);
+ Json::Value DumpEntryProperties(std::string const& name);
+ Json::Value DumpEntryProperty(std::string const& name,
+ std::string const& prop);
+
+public:
+ Cache(cmFileAPI& fileAPI, unsigned long version);
+ Json::Value Dump();
+};
+
+Cache::Cache(cmFileAPI& fileAPI, unsigned long version)
+ : FileAPI(fileAPI)
+ , Version(version)
+ , State(this->FileAPI.GetCMakeInstance()->GetState())
+{
+ static_cast<void>(this->Version);
+}
+
+Json::Value Cache::Dump()
+{
+ Json::Value cache = Json::objectValue;
+ cache["entries"] = DumpEntries();
+ return cache;
+}
+
+Json::Value Cache::DumpEntries()
+{
+ Json::Value entries = Json::arrayValue;
+
+ std::vector<std::string> names = this->State->GetCacheEntryKeys();
+ std::sort(names.begin(), names.end());
+
+ for (std::string const& name : names) {
+ entries.append(this->DumpEntry(name));
+ }
+
+ return entries;
+}
+
+Json::Value Cache::DumpEntry(std::string const& name)
+{
+ Json::Value entry = Json::objectValue;
+ entry["name"] = name;
+ entry["type"] =
+ cmState::CacheEntryTypeToString(this->State->GetCacheEntryType(name));
+ entry["value"] = this->State->GetCacheEntryValue(name);
+
+ Json::Value properties = this->DumpEntryProperties(name);
+ if (!properties.empty()) {
+ entry["properties"] = std::move(properties);
+ }
+
+ return entry;
+}
+
+Json::Value Cache::DumpEntryProperties(std::string const& name)
+{
+ Json::Value properties = Json::arrayValue;
+ std::vector<std::string> props =
+ this->State->GetCacheEntryPropertyList(name);
+ std::sort(props.begin(), props.end());
+ for (std::string const& prop : props) {
+ properties.append(this->DumpEntryProperty(name, prop));
+ }
+ return properties;
+}
+
+Json::Value Cache::DumpEntryProperty(std::string const& name,
+ std::string const& prop)
+{
+ Json::Value property = Json::objectValue;
+ property["name"] = prop;
+ property["value"] = this->State->GetCacheEntryProperty(name, prop);
+ return property;
+}
+}
+
+Json::Value cmFileAPICacheDump(cmFileAPI& fileAPI, unsigned long version)
+{
+ Cache cache(fileAPI, version);
+ return cache.Dump();
+}
diff --git a/Source/cmFileAPICache.h b/Source/cmFileAPICache.h
new file mode 100644
index 000000000..09d9e1ce9
--- /dev/null
+++ b/Source/cmFileAPICache.h
@@ -0,0 +1,15 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmFileAPICache_h
+#define cmFileAPICache_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include "cm_jsoncpp_value.h"
+
+class cmFileAPI;
+
+extern Json::Value cmFileAPICacheDump(cmFileAPI& fileAPI,
+ unsigned long version);
+
+#endif
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
new file mode 100644
index 000000000..d7993c7d9
--- /dev/null
+++ b/Source/cmFileAPICodemodel.cxx
@@ -0,0 +1,1424 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmFileAPICodemodel.h"
+
+#include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <functional>
+#include <limits>
+#include <map>
+#include <memory>
+#include <set>
+#include <string>
+#include <unordered_map>
+#include <utility>
+#include <vector>
+
+#include "cm_jsoncpp_value.h"
+
+#include "cmAlgorithms.h"
+#include "cmCryptoHash.h"
+#include "cmFileAPI.h"
+#include "cmGeneratorExpression.h"
+#include "cmGeneratorTarget.h"
+#include "cmGlobalGenerator.h"
+#include "cmInstallGenerator.h"
+#include "cmInstallSubdirectoryGenerator.h"
+#include "cmInstallTargetGenerator.h"
+#include "cmLinkLineComputer.h"
+#include "cmListFileCache.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
+#include "cmSourceFile.h"
+#include "cmSourceGroup.h"
+#include "cmState.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
+#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmTarget.h"
+#include "cmTargetDepend.h"
+#include "cmake.h"
+
+namespace {
+
+class Codemodel
+{
+ cmFileAPI& FileAPI;
+ unsigned long Version;
+
+ Json::Value DumpPaths();
+ Json::Value DumpConfigurations();
+ Json::Value DumpConfiguration(std::string const& config);
+
+public:
+ Codemodel(cmFileAPI& fileAPI, unsigned long version);
+ Json::Value Dump();
+};
+
+class CodemodelConfig
+{
+ cmFileAPI& FileAPI;
+ unsigned long Version;
+ std::string const& Config;
+ std::string TopSource;
+ std::string TopBuild;
+
+ struct Directory
+ {
+ cmStateSnapshot Snapshot;
+ cmLocalGenerator const* LocalGenerator = nullptr;
+ Json::Value TargetIndexes = Json::arrayValue;
+ Json::ArrayIndex ProjectIndex;
+ bool HasInstallRule = false;
+ };
+ std::map<cmStateSnapshot, Json::ArrayIndex, cmStateSnapshot::StrictWeakOrder>
+ DirectoryMap;
+ std::vector<Directory> Directories;
+
+ struct Project
+ {
+ cmStateSnapshot Snapshot;
+ static const Json::ArrayIndex NoParentIndex =
+ static_cast<Json::ArrayIndex>(-1);
+ Json::ArrayIndex ParentIndex = NoParentIndex;
+ Json::Value ChildIndexes = Json::arrayValue;
+ Json::Value DirectoryIndexes = Json::arrayValue;
+ Json::Value TargetIndexes = Json::arrayValue;
+ };
+ std::map<cmStateSnapshot, Json::ArrayIndex, cmStateSnapshot::StrictWeakOrder>
+ ProjectMap;
+ std::vector<Project> Projects;
+
+ void ProcessDirectories();
+
+ Json::ArrayIndex GetDirectoryIndex(cmLocalGenerator const* lg);
+ Json::ArrayIndex GetDirectoryIndex(cmStateSnapshot s);
+
+ Json::ArrayIndex AddProject(cmStateSnapshot s);
+
+ Json::Value DumpTargets();
+ Json::Value DumpTarget(cmGeneratorTarget* gt, Json::ArrayIndex ti);
+
+ Json::Value DumpDirectories();
+ Json::Value DumpDirectory(Directory& d);
+
+ Json::Value DumpProjects();
+ Json::Value DumpProject(Project& p);
+
+ Json::Value DumpMinimumCMakeVersion(cmStateSnapshot s);
+
+public:
+ CodemodelConfig(cmFileAPI& fileAPI, unsigned long version,
+ std::string const& config);
+ Json::Value Dump();
+};
+
+std::string RelativeIfUnder(std::string const& top, std::string const& in)
+{
+ std::string out;
+ if (in == top) {
+ out = ".";
+ } else if (cmSystemTools::IsSubDirectory(in, top)) {
+ out = in.substr(top.size() + 1);
+ } else {
+ out = in;
+ }
+ return out;
+}
+
+std::string TargetId(cmGeneratorTarget const* gt, std::string const& topBuild)
+{
+ cmCryptoHash hasher(cmCryptoHash::AlgoSHA3_256);
+ std::string path = RelativeIfUnder(
+ topBuild, gt->GetLocalGenerator()->GetCurrentBinaryDirectory());
+ std::string hash = hasher.HashString(path);
+ hash.resize(20, '0');
+ return gt->GetName() + CMAKE_DIRECTORY_ID_SEP + hash;
+}
+
+class JBTIndex
+{
+public:
+ JBTIndex() = default;
+ explicit operator bool() const { return Index != None; }
+ Json::ArrayIndex Index = None;
+ static Json::ArrayIndex const None = static_cast<Json::ArrayIndex>(-1);
+};
+
+template <typename T>
+class JBT
+{
+public:
+ JBT(T v = T(), JBTIndex bt = JBTIndex())
+ : Value(std::move(v))
+ , Backtrace(bt)
+ {
+ }
+ T Value;
+ JBTIndex Backtrace;
+ friend bool operator==(JBT<T> const& l, JBT<T> const& r)
+ {
+ return l.Value == r.Value && l.Backtrace.Index == r.Backtrace.Index;
+ }
+ static bool ValueEq(JBT<T> const& l, JBT<T> const& r)
+ {
+ return l.Value == r.Value;
+ }
+ static bool ValueLess(JBT<T> const& l, JBT<T> const& r)
+ {
+ return l.Value < r.Value;
+ }
+};
+
+class BacktraceData
+{
+ std::string TopSource;
+ std::unordered_map<std::string, Json::ArrayIndex> CommandMap;
+ std::unordered_map<std::string, Json::ArrayIndex> FileMap;
+ std::unordered_map<cmListFileContext const*, Json::ArrayIndex> NodeMap;
+ Json::Value Commands = Json::arrayValue;
+ Json::Value Files = Json::arrayValue;
+ Json::Value Nodes = Json::arrayValue;
+
+ Json::ArrayIndex AddCommand(std::string const& command)
+ {
+ auto i = this->CommandMap.find(command);
+ if (i == this->CommandMap.end()) {
+ auto cmdIndex = static_cast<Json::ArrayIndex>(this->Commands.size());
+ i = this->CommandMap.emplace(command, cmdIndex).first;
+ this->Commands.append(command);
+ }
+ return i->second;
+ }
+
+ Json::ArrayIndex AddFile(std::string const& file)
+ {
+ auto i = this->FileMap.find(file);
+ if (i == this->FileMap.end()) {
+ auto fileIndex = static_cast<Json::ArrayIndex>(this->Files.size());
+ i = this->FileMap.emplace(file, fileIndex).first;
+ this->Files.append(RelativeIfUnder(this->TopSource, file));
+ }
+ return i->second;
+ }
+
+public:
+ BacktraceData(std::string topSource);
+ JBTIndex Add(cmListFileBacktrace const& bt);
+ Json::Value Dump();
+};
+
+BacktraceData::BacktraceData(std::string topSource)
+ : TopSource(std::move(topSource))
+{
+}
+
+JBTIndex BacktraceData::Add(cmListFileBacktrace const& bt)
+{
+ JBTIndex index;
+ if (bt.Empty()) {
+ return index;
+ }
+ cmListFileContext const* top = &bt.Top();
+ auto found = this->NodeMap.find(top);
+ if (found != this->NodeMap.end()) {
+ index.Index = found->second;
+ return index;
+ }
+ Json::Value entry = Json::objectValue;
+ entry["file"] = this->AddFile(top->FilePath);
+ if (top->Line) {
+ entry["line"] = static_cast<int>(top->Line);
+ }
+ if (!top->Name.empty()) {
+ entry["command"] = this->AddCommand(top->Name);
+ }
+ if (JBTIndex parent = this->Add(bt.Pop())) {
+ entry["parent"] = parent.Index;
+ }
+ index.Index = this->NodeMap[top] = this->Nodes.size();
+ this->Nodes.append(std::move(entry)); // NOLINT(*)
+ return index;
+}
+
+Json::Value BacktraceData::Dump()
+{
+ Json::Value backtraceGraph;
+ this->CommandMap.clear();
+ this->FileMap.clear();
+ this->NodeMap.clear();
+ backtraceGraph["commands"] = std::move(this->Commands);
+ backtraceGraph["files"] = std::move(this->Files);
+ backtraceGraph["nodes"] = std::move(this->Nodes);
+ return backtraceGraph;
+}
+
+struct CompileData
+{
+ struct IncludeEntry
+ {
+ JBT<std::string> Path;
+ bool IsSystem = false;
+ IncludeEntry(JBT<std::string> path, bool isSystem)
+ : Path(std::move(path))
+ , IsSystem(isSystem)
+ {
+ }
+ friend bool operator==(IncludeEntry const& l, IncludeEntry const& r)
+ {
+ return l.Path == r.Path && l.IsSystem == r.IsSystem;
+ }
+ };
+
+ std::string Language;
+ std::string Sysroot;
+ std::vector<JBT<std::string>> Flags;
+ std::vector<JBT<std::string>> Defines;
+ std::vector<IncludeEntry> Includes;
+
+ friend bool operator==(CompileData const& l, CompileData const& r)
+ {
+ return (l.Language == r.Language && l.Sysroot == r.Sysroot &&
+ l.Flags == r.Flags && l.Defines == r.Defines &&
+ l.Includes == r.Includes);
+ }
+};
+}
+
+namespace std {
+
+template <>
+struct hash<CompileData>
+{
+ std::size_t operator()(CompileData const& in) const
+ {
+ using std::hash;
+ size_t result =
+ hash<std::string>()(in.Language) ^ hash<std::string>()(in.Sysroot);
+ for (auto const& i : in.Includes) {
+ result = result ^
+ (hash<std::string>()(i.Path.Value) ^
+ hash<Json::ArrayIndex>()(i.Path.Backtrace.Index) ^
+ (i.IsSystem ? std::numeric_limits<size_t>::max() : 0));
+ }
+ for (auto const& i : in.Flags) {
+ result = result ^ hash<std::string>()(i.Value) ^
+ hash<Json::ArrayIndex>()(i.Backtrace.Index);
+ }
+ for (auto const& i : in.Defines) {
+ result = result ^ hash<std::string>()(i.Value) ^
+ hash<Json::ArrayIndex>()(i.Backtrace.Index);
+ }
+ return result;
+ }
+};
+
+} // namespace std
+
+namespace {
+class Target
+{
+ cmGeneratorTarget* GT;
+ std::string const& Config;
+ std::string TopSource;
+ std::string TopBuild;
+ std::vector<cmSourceGroup> SourceGroupsLocal;
+ BacktraceData Backtraces;
+
+ std::map<std::string, CompileData> CompileDataMap;
+
+ std::unordered_map<cmSourceFile const*, Json::ArrayIndex> SourceMap;
+ Json::Value Sources = Json::arrayValue;
+
+ struct SourceGroup
+ {
+ std::string Name;
+ Json::Value SourceIndexes = Json::arrayValue;
+ };
+ std::unordered_map<cmSourceGroup const*, Json::ArrayIndex> SourceGroupsMap;
+ std::vector<SourceGroup> SourceGroups;
+
+ struct CompileGroup
+ {
+ std::unordered_map<CompileData, Json::ArrayIndex>::iterator Entry;
+ Json::Value SourceIndexes = Json::arrayValue;
+ };
+ std::unordered_map<CompileData, Json::ArrayIndex> CompileGroupMap;
+ std::vector<CompileGroup> CompileGroups;
+
+ template <typename T>
+ JBT<T> ToJBT(BT<T> const& bt)
+ {
+ return JBT<T>(bt.Value, this->Backtraces.Add(bt.Backtrace));
+ }
+
+ void ProcessLanguages();
+ void ProcessLanguage(std::string const& lang);
+
+ Json::ArrayIndex AddSourceGroup(cmSourceGroup* sg, Json::ArrayIndex si);
+ CompileData BuildCompileData(cmSourceFile* sf);
+ CompileData MergeCompileData(CompileData const& fd);
+ Json::ArrayIndex AddSourceCompileGroup(cmSourceFile* sf,
+ Json::ArrayIndex si);
+ void AddBacktrace(Json::Value& object, cmListFileBacktrace const& bt);
+ void AddBacktrace(Json::Value& object, JBTIndex bt);
+ Json::Value DumpPaths();
+ Json::Value DumpCompileData(CompileData const& cd);
+ Json::Value DumpInclude(CompileData::IncludeEntry const& inc);
+ Json::Value DumpDefine(JBT<std::string> const& def);
+ Json::Value DumpSources();
+ Json::Value DumpSource(cmGeneratorTarget::SourceAndKind const& sk,
+ Json::ArrayIndex si);
+ Json::Value DumpSourceGroups();
+ Json::Value DumpSourceGroup(SourceGroup& sg);
+ Json::Value DumpCompileGroups();
+ Json::Value DumpCompileGroup(CompileGroup& cg);
+ Json::Value DumpSysroot(std::string const& path);
+ Json::Value DumpInstall();
+ Json::Value DumpInstallPrefix();
+ Json::Value DumpInstallDestinations();
+ Json::Value DumpInstallDestination(cmInstallTargetGenerator* itGen);
+ Json::Value DumpArtifacts();
+ Json::Value DumpLink();
+ Json::Value DumpArchive();
+ Json::Value DumpLinkCommandFragments();
+ Json::Value DumpCommandFragments(std::vector<JBT<std::string>> const& frags);
+ Json::Value DumpCommandFragment(JBT<std::string> const& frag,
+ std::string const& role = std::string());
+ Json::Value DumpDependencies();
+ Json::Value DumpDependency(cmTargetDepend const& td);
+ Json::Value DumpFolder();
+
+public:
+ Target(cmGeneratorTarget* gt, std::string const& config);
+ Json::Value Dump();
+};
+
+Codemodel::Codemodel(cmFileAPI& fileAPI, unsigned long version)
+ : FileAPI(fileAPI)
+ , Version(version)
+{
+}
+
+Json::Value Codemodel::Dump()
+{
+ Json::Value codemodel = Json::objectValue;
+
+ codemodel["paths"] = this->DumpPaths();
+ codemodel["configurations"] = this->DumpConfigurations();
+
+ return codemodel;
+}
+
+Json::Value Codemodel::DumpPaths()
+{
+ Json::Value paths = Json::objectValue;
+ paths["source"] = this->FileAPI.GetCMakeInstance()->GetHomeDirectory();
+ paths["build"] = this->FileAPI.GetCMakeInstance()->GetHomeOutputDirectory();
+ return paths;
+}
+
+Json::Value Codemodel::DumpConfigurations()
+{
+ Json::Value configurations = Json::arrayValue;
+ cmGlobalGenerator* gg =
+ this->FileAPI.GetCMakeInstance()->GetGlobalGenerator();
+ auto makefiles = gg->GetMakefiles();
+ if (!makefiles.empty()) {
+ std::vector<std::string> const& configs =
+ makefiles[0]->GetGeneratorConfigs();
+ for (std::string const& config : configs) {
+ configurations.append(this->DumpConfiguration(config));
+ }
+ }
+ return configurations;
+}
+
+Json::Value Codemodel::DumpConfiguration(std::string const& config)
+{
+ CodemodelConfig configuration(this->FileAPI, this->Version, config);
+ return configuration.Dump();
+}
+
+CodemodelConfig::CodemodelConfig(cmFileAPI& fileAPI, unsigned long version,
+ std::string const& config)
+ : FileAPI(fileAPI)
+ , Version(version)
+ , Config(config)
+ , TopSource(this->FileAPI.GetCMakeInstance()->GetHomeDirectory())
+ , TopBuild(this->FileAPI.GetCMakeInstance()->GetHomeOutputDirectory())
+{
+ static_cast<void>(this->Version);
+}
+
+Json::Value CodemodelConfig::Dump()
+{
+ Json::Value configuration = Json::objectValue;
+ configuration["name"] = this->Config;
+ this->ProcessDirectories();
+ configuration["targets"] = this->DumpTargets();
+ configuration["directories"] = this->DumpDirectories();
+ configuration["projects"] = this->DumpProjects();
+ return configuration;
+}
+
+void CodemodelConfig::ProcessDirectories()
+{
+ cmGlobalGenerator* gg =
+ this->FileAPI.GetCMakeInstance()->GetGlobalGenerator();
+ std::vector<cmLocalGenerator*> const& localGens = gg->GetLocalGenerators();
+
+ // Add directories in forward order to process parents before children.
+ this->Directories.reserve(localGens.size());
+ for (cmLocalGenerator* lg : localGens) {
+ auto directoryIndex =
+ static_cast<Json::ArrayIndex>(this->Directories.size());
+ this->Directories.emplace_back();
+ Directory& d = this->Directories[directoryIndex];
+ d.Snapshot = lg->GetStateSnapshot().GetBuildsystemDirectory();
+ d.LocalGenerator = lg;
+ this->DirectoryMap[d.Snapshot] = directoryIndex;
+
+ d.ProjectIndex = this->AddProject(d.Snapshot);
+ this->Projects[d.ProjectIndex].DirectoryIndexes.append(directoryIndex);
+ }
+
+ // Update directories in reverse order to process children before parents.
+ for (auto di = this->Directories.rbegin(); di != this->Directories.rend();
+ ++di) {
+ Directory& d = *di;
+
+ // Accumulate the presence of install rules on the way up.
+ for (auto gen : d.LocalGenerator->GetMakefile()->GetInstallGenerators()) {
+ if (!dynamic_cast<cmInstallSubdirectoryGenerator*>(gen)) {
+ d.HasInstallRule = true;
+ break;
+ }
+ }
+ if (!d.HasInstallRule) {
+ for (cmStateSnapshot const& child : d.Snapshot.GetChildren()) {
+ cmStateSnapshot childDir = child.GetBuildsystemDirectory();
+ Json::ArrayIndex const childIndex = this->GetDirectoryIndex(childDir);
+ if (this->Directories[childIndex].HasInstallRule) {
+ d.HasInstallRule = true;
+ break;
+ }
+ }
+ }
+ }
+}
+
+Json::ArrayIndex CodemodelConfig::GetDirectoryIndex(cmLocalGenerator const* lg)
+{
+ return this->GetDirectoryIndex(
+ lg->GetStateSnapshot().GetBuildsystemDirectory());
+}
+
+Json::ArrayIndex CodemodelConfig::GetDirectoryIndex(cmStateSnapshot s)
+{
+ auto i = this->DirectoryMap.find(s);
+ assert(i != this->DirectoryMap.end());
+ return i->second;
+}
+
+Json::ArrayIndex CodemodelConfig::AddProject(cmStateSnapshot s)
+{
+ cmStateSnapshot ps = s.GetBuildsystemDirectoryParent();
+ if (ps.IsValid() && ps.GetProjectName() == s.GetProjectName()) {
+ // This directory is part of its parent directory project.
+ Json::ArrayIndex const parentDirIndex = this->GetDirectoryIndex(ps);
+ return this->Directories[parentDirIndex].ProjectIndex;
+ }
+
+ // This directory starts a new project.
+ auto projectIndex = static_cast<Json::ArrayIndex>(this->Projects.size());
+ this->Projects.emplace_back();
+ Project& p = this->Projects[projectIndex];
+ p.Snapshot = s;
+ this->ProjectMap[s] = projectIndex;
+ if (ps.IsValid()) {
+ Json::ArrayIndex const parentDirIndex = this->GetDirectoryIndex(ps);
+ p.ParentIndex = this->Directories[parentDirIndex].ProjectIndex;
+ this->Projects[p.ParentIndex].ChildIndexes.append(projectIndex);
+ }
+ return projectIndex;
+}
+
+Json::Value CodemodelConfig::DumpTargets()
+{
+ Json::Value targets = Json::arrayValue;
+
+ std::vector<cmGeneratorTarget*> targetList;
+ cmGlobalGenerator* gg =
+ this->FileAPI.GetCMakeInstance()->GetGlobalGenerator();
+ for (cmLocalGenerator const* lg : gg->GetLocalGenerators()) {
+ cmAppend(targetList, lg->GetGeneratorTargets());
+ }
+ std::sort(targetList.begin(), targetList.end(),
+ [](cmGeneratorTarget* l, cmGeneratorTarget* r) {
+ return l->GetName() < r->GetName();
+ });
+
+ for (cmGeneratorTarget* gt : targetList) {
+ if (gt->GetType() == cmStateEnums::GLOBAL_TARGET ||
+ gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ continue;
+ }
+
+ targets.append(this->DumpTarget(gt, targets.size()));
+ }
+
+ return targets;
+}
+
+Json::Value CodemodelConfig::DumpTarget(cmGeneratorTarget* gt,
+ Json::ArrayIndex ti)
+{
+ Target t(gt, this->Config);
+ std::string prefix = "target-" + gt->GetName();
+ for (char& c : prefix) {
+ // CMP0037 OLD behavior allows slashes in target names. Remove them.
+ if (c == '/' || c == '\\') {
+ c = '_';
+ }
+ }
+ if (!this->Config.empty()) {
+ prefix += "-" + this->Config;
+ }
+ Json::Value target = this->FileAPI.MaybeJsonFile(t.Dump(), prefix);
+ target["name"] = gt->GetName();
+ target["id"] = TargetId(gt, this->TopBuild);
+
+ // Cross-reference directory containing target.
+ Json::ArrayIndex di = this->GetDirectoryIndex(gt->GetLocalGenerator());
+ target["directoryIndex"] = di;
+ this->Directories[di].TargetIndexes.append(ti);
+
+ // Cross-reference project containing target.
+ Json::ArrayIndex pi = this->Directories[di].ProjectIndex;
+ target["projectIndex"] = pi;
+ this->Projects[pi].TargetIndexes.append(ti);
+
+ return target;
+}
+
+Json::Value CodemodelConfig::DumpDirectories()
+{
+ Json::Value directories = Json::arrayValue;
+ for (Directory& d : this->Directories) {
+ directories.append(this->DumpDirectory(d));
+ }
+ return directories;
+}
+
+Json::Value CodemodelConfig::DumpDirectory(Directory& d)
+{
+ Json::Value directory = Json::objectValue;
+
+ std::string sourceDir = d.Snapshot.GetDirectory().GetCurrentSource();
+ directory["source"] = RelativeIfUnder(this->TopSource, sourceDir);
+
+ std::string buildDir = d.Snapshot.GetDirectory().GetCurrentBinary();
+ directory["build"] = RelativeIfUnder(this->TopBuild, buildDir);
+
+ cmStateSnapshot parentDir = d.Snapshot.GetBuildsystemDirectoryParent();
+ if (parentDir.IsValid()) {
+ directory["parentIndex"] = this->GetDirectoryIndex(parentDir);
+ }
+
+ Json::Value childIndexes = Json::arrayValue;
+ for (cmStateSnapshot const& child : d.Snapshot.GetChildren()) {
+ childIndexes.append(
+ this->GetDirectoryIndex(child.GetBuildsystemDirectory()));
+ }
+ if (!childIndexes.empty()) {
+ directory["childIndexes"] = std::move(childIndexes);
+ }
+
+ directory["projectIndex"] = d.ProjectIndex;
+
+ if (!d.TargetIndexes.empty()) {
+ directory["targetIndexes"] = std::move(d.TargetIndexes);
+ }
+
+ Json::Value minimumCMakeVersion = this->DumpMinimumCMakeVersion(d.Snapshot);
+ if (!minimumCMakeVersion.isNull()) {
+ directory["minimumCMakeVersion"] = std::move(minimumCMakeVersion);
+ }
+
+ if (d.HasInstallRule) {
+ directory["hasInstallRule"] = true;
+ }
+
+ return directory;
+}
+
+Json::Value CodemodelConfig::DumpProjects()
+{
+ Json::Value projects = Json::arrayValue;
+ for (Project& p : this->Projects) {
+ projects.append(this->DumpProject(p));
+ }
+ return projects;
+}
+
+Json::Value CodemodelConfig::DumpProject(Project& p)
+{
+ Json::Value project = Json::objectValue;
+
+ project["name"] = p.Snapshot.GetProjectName();
+
+ if (p.ParentIndex != Project::NoParentIndex) {
+ project["parentIndex"] = p.ParentIndex;
+ }
+
+ if (!p.ChildIndexes.empty()) {
+ project["childIndexes"] = std::move(p.ChildIndexes);
+ }
+
+ project["directoryIndexes"] = std::move(p.DirectoryIndexes);
+
+ if (!p.TargetIndexes.empty()) {
+ project["targetIndexes"] = std::move(p.TargetIndexes);
+ }
+
+ return project;
+}
+
+Json::Value CodemodelConfig::DumpMinimumCMakeVersion(cmStateSnapshot s)
+{
+ Json::Value minimumCMakeVersion;
+ if (std::string const* def =
+ s.GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION")) {
+ minimumCMakeVersion = Json::objectValue;
+ minimumCMakeVersion["string"] = *def;
+ }
+ return minimumCMakeVersion;
+}
+
+Target::Target(cmGeneratorTarget* gt, std::string const& config)
+ : GT(gt)
+ , Config(config)
+ , TopSource(gt->GetGlobalGenerator()->GetCMakeInstance()->GetHomeDirectory())
+ , TopBuild(
+ gt->GetGlobalGenerator()->GetCMakeInstance()->GetHomeOutputDirectory())
+ , SourceGroupsLocal(this->GT->Makefile->GetSourceGroups())
+ , Backtraces(this->TopSource)
+{
+}
+
+Json::Value Target::Dump()
+{
+ Json::Value target = Json::objectValue;
+
+ cmStateEnums::TargetType const type = this->GT->GetType();
+
+ target["name"] = this->GT->GetName();
+ target["type"] = cmState::GetTargetTypeName(type);
+ target["id"] = TargetId(this->GT, this->TopBuild);
+ target["paths"] = this->DumpPaths();
+ if (this->GT->Target->GetIsGeneratorProvided()) {
+ target["isGeneratorProvided"] = true;
+ }
+
+ this->AddBacktrace(target, this->GT->GetBacktrace());
+
+ if (this->GT->Target->GetHaveInstallRule()) {
+ target["install"] = this->DumpInstall();
+ }
+
+ if (this->GT->HaveWellDefinedOutputFiles()) {
+ Json::Value artifacts = this->DumpArtifacts();
+ if (!artifacts.empty()) {
+ target["artifacts"] = std::move(artifacts);
+ }
+ }
+
+ if (type == cmStateEnums::EXECUTABLE ||
+ type == cmStateEnums::SHARED_LIBRARY ||
+ type == cmStateEnums::MODULE_LIBRARY) {
+ target["nameOnDisk"] = this->GT->GetFullName(this->Config);
+ target["link"] = this->DumpLink();
+ } else if (type == cmStateEnums::STATIC_LIBRARY) {
+ target["nameOnDisk"] = this->GT->GetFullName(this->Config);
+ target["archive"] = this->DumpArchive();
+ }
+
+ Json::Value dependencies = this->DumpDependencies();
+ if (!dependencies.empty()) {
+ target["dependencies"] = dependencies;
+ }
+
+ {
+ this->ProcessLanguages();
+
+ target["sources"] = this->DumpSources();
+
+ Json::Value folder = this->DumpFolder();
+ if (!folder.isNull()) {
+ target["folder"] = std::move(folder);
+ }
+
+ Json::Value sourceGroups = this->DumpSourceGroups();
+ if (!sourceGroups.empty()) {
+ target["sourceGroups"] = std::move(sourceGroups);
+ }
+
+ Json::Value compileGroups = this->DumpCompileGroups();
+ if (!compileGroups.empty()) {
+ target["compileGroups"] = std::move(compileGroups);
+ }
+ }
+
+ target["backtraceGraph"] = this->Backtraces.Dump();
+
+ return target;
+}
+
+void Target::ProcessLanguages()
+{
+ std::set<std::string> languages;
+ this->GT->GetLanguages(languages, this->Config);
+ for (std::string const& lang : languages) {
+ this->ProcessLanguage(lang);
+ }
+}
+
+void Target::ProcessLanguage(std::string const& lang)
+{
+ CompileData& cd = this->CompileDataMap[lang];
+ cd.Language = lang;
+ if (const char* sysrootCompile =
+ this->GT->Makefile->GetDefinition("CMAKE_SYSROOT_COMPILE")) {
+ cd.Sysroot = sysrootCompile;
+ } else if (const char* sysroot =
+ this->GT->Makefile->GetDefinition("CMAKE_SYSROOT")) {
+ cd.Sysroot = sysroot;
+ }
+ cmLocalGenerator* lg = this->GT->GetLocalGenerator();
+ {
+ // FIXME: Add flags from end section of ExpandRuleVariable,
+ // which may need to be factored out.
+ std::vector<BT<std::string>> flags =
+ lg->GetTargetCompileFlags(this->GT, this->Config, lang);
+
+ cd.Flags.reserve(flags.size());
+ for (const BT<std::string>& f : flags) {
+ cd.Flags.emplace_back(this->ToJBT(f));
+ }
+ }
+ std::set<BT<std::string>> defines =
+ lg->GetTargetDefines(this->GT, this->Config, lang);
+ cd.Defines.reserve(defines.size());
+ for (BT<std::string> const& d : defines) {
+ cd.Defines.emplace_back(this->ToJBT(d));
+ }
+ std::vector<BT<std::string>> includePathList =
+ lg->GetIncludeDirectories(this->GT, lang, this->Config);
+ for (BT<std::string> const& i : includePathList) {
+ cd.Includes.emplace_back(
+ this->ToJBT(i),
+ this->GT->IsSystemIncludeDirectory(i.Value, this->Config, lang));
+ }
+}
+
+Json::ArrayIndex Target::AddSourceGroup(cmSourceGroup* sg, Json::ArrayIndex si)
+{
+ auto i = this->SourceGroupsMap.find(sg);
+ if (i == this->SourceGroupsMap.end()) {
+ auto sgIndex = static_cast<Json::ArrayIndex>(this->SourceGroups.size());
+ i = this->SourceGroupsMap.emplace(sg, sgIndex).first;
+ SourceGroup g;
+ g.Name = sg->GetFullName();
+ this->SourceGroups.push_back(std::move(g));
+ }
+ this->SourceGroups[i->second].SourceIndexes.append(si);
+ return i->second;
+}
+
+CompileData Target::BuildCompileData(cmSourceFile* sf)
+{
+ CompileData fd;
+
+ fd.Language = sf->GetOrDetermineLanguage();
+ if (fd.Language.empty()) {
+ return fd;
+ }
+
+ cmLocalGenerator* lg = this->GT->GetLocalGenerator();
+ cmGeneratorExpressionInterpreter genexInterpreter(lg, this->Config, this->GT,
+ fd.Language);
+
+ const std::string COMPILE_FLAGS("COMPILE_FLAGS");
+ if (const char* cflags = sf->GetProperty(COMPILE_FLAGS)) {
+ std::string flags = genexInterpreter.Evaluate(cflags, COMPILE_FLAGS);
+ fd.Flags.emplace_back(std::move(flags), JBTIndex());
+ }
+ const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
+ for (BT<std::string> tmpOpt : sf->GetCompileOptions()) {
+ tmpOpt.Value = genexInterpreter.Evaluate(tmpOpt.Value, COMPILE_OPTIONS);
+ // After generator evaluation we need to use the AppendCompileOptions
+ // method so we handle situations where backtrace entries have lists
+ // and properly escape flags.
+ std::string tmp;
+ lg->AppendCompileOptions(tmp, tmpOpt.Value);
+ BT<std::string> opt(tmp, tmpOpt.Backtrace);
+ fd.Flags.emplace_back(this->ToJBT(opt));
+ }
+
+ // Add precompile headers compile options.
+ const std::string pchSource =
+ this->GT->GetPchSource(this->Config, fd.Language);
+
+ if (!pchSource.empty() && !sf->GetProperty("SKIP_PRECOMPILE_HEADERS")) {
+ std::string pchOptions;
+ if (sf->ResolveFullPath() == pchSource) {
+ pchOptions =
+ this->GT->GetPchCreateCompileOptions(this->Config, fd.Language);
+ } else {
+ pchOptions =
+ this->GT->GetPchUseCompileOptions(this->Config, fd.Language);
+ }
+
+ BT<std::string> tmpOpt(pchOptions);
+ tmpOpt.Value = genexInterpreter.Evaluate(tmpOpt.Value, COMPILE_OPTIONS);
+
+ // After generator evaluation we need to use the AppendCompileOptions
+ // method so we handle situations where backtrace entries have lists
+ // and properly escape flags.
+ std::string tmp;
+ lg->AppendCompileOptions(tmp, tmpOpt.Value);
+ BT<std::string> opt(tmp, tmpOpt.Backtrace);
+ fd.Flags.emplace_back(this->ToJBT(opt));
+ }
+
+ // Add include directories from source file properties.
+ {
+ const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
+ for (BT<std::string> tmpInclude : sf->GetIncludeDirectories()) {
+ tmpInclude.Value =
+ genexInterpreter.Evaluate(tmpInclude.Value, INCLUDE_DIRECTORIES);
+
+ // After generator evaluation we need to use the AppendIncludeDirectories
+ // method so we handle situations where backtrace entries have lists.
+ std::vector<std::string> tmp;
+ lg->AppendIncludeDirectories(tmp, tmpInclude.Value, *sf);
+ for (std::string& i : tmp) {
+ bool const isSystemInclude =
+ this->GT->IsSystemIncludeDirectory(i, this->Config, fd.Language);
+ BT<std::string> include(i, tmpInclude.Backtrace);
+ fd.Includes.emplace_back(this->ToJBT(include), isSystemInclude);
+ }
+ }
+ }
+
+ const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
+ std::set<BT<std::string>> fileDefines;
+ for (BT<std::string> tmpDef : sf->GetCompileDefinitions()) {
+ tmpDef.Value =
+ genexInterpreter.Evaluate(tmpDef.Value, COMPILE_DEFINITIONS);
+
+ // After generator evaluation we need to use the AppendDefines method
+ // so we handle situations where backtrace entries have lists.
+ std::set<std::string> tmp;
+ lg->AppendDefines(tmp, tmpDef.Value);
+ for (const std::string& i : tmp) {
+ BT<std::string> def(i, tmpDef.Backtrace);
+ fileDefines.insert(def);
+ }
+ }
+
+ std::set<std::string> configFileDefines;
+ const std::string defPropName =
+ "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(this->Config);
+ if (const char* config_defs = sf->GetProperty(defPropName)) {
+ lg->AppendDefines(
+ configFileDefines,
+ genexInterpreter.Evaluate(config_defs, COMPILE_DEFINITIONS));
+ }
+
+ fd.Defines.reserve(fileDefines.size() + configFileDefines.size());
+
+ for (BT<std::string> const& def : fileDefines) {
+ fd.Defines.emplace_back(this->ToJBT(def));
+ }
+
+ for (std::string const& d : configFileDefines) {
+ fd.Defines.emplace_back(d, JBTIndex());
+ }
+
+ return fd;
+}
+
+CompileData Target::MergeCompileData(CompileData const& fd)
+{
+ CompileData cd;
+ cd.Language = fd.Language;
+ if (cd.Language.empty()) {
+ return cd;
+ }
+ CompileData const& td = this->CompileDataMap.at(cd.Language);
+
+ // All compile groups share the sysroot of the target.
+ cd.Sysroot = td.Sysroot;
+
+ // Use target-wide flags followed by source-specific flags.
+ cd.Flags.reserve(td.Flags.size() + fd.Flags.size());
+ cd.Flags.insert(cd.Flags.end(), td.Flags.begin(), td.Flags.end());
+ cd.Flags.insert(cd.Flags.end(), fd.Flags.begin(), fd.Flags.end());
+
+ // Use source-specific includes followed by target-wide includes.
+ cd.Includes.reserve(fd.Includes.size() + td.Includes.size());
+ cd.Includes.insert(cd.Includes.end(), fd.Includes.begin(),
+ fd.Includes.end());
+ cd.Includes.insert(cd.Includes.end(), td.Includes.begin(),
+ td.Includes.end());
+
+ // Use target-wide defines followed by source-specific defines.
+ cd.Defines.reserve(td.Defines.size() + fd.Defines.size());
+ cd.Defines.insert(cd.Defines.end(), td.Defines.begin(), td.Defines.end());
+ cd.Defines.insert(cd.Defines.end(), fd.Defines.begin(), fd.Defines.end());
+
+ // De-duplicate defines.
+ std::stable_sort(cd.Defines.begin(), cd.Defines.end(),
+ JBT<std::string>::ValueLess);
+ auto end = std::unique(cd.Defines.begin(), cd.Defines.end(),
+ JBT<std::string>::ValueEq);
+ cd.Defines.erase(end, cd.Defines.end());
+
+ return cd;
+}
+
+Json::ArrayIndex Target::AddSourceCompileGroup(cmSourceFile* sf,
+ Json::ArrayIndex si)
+{
+ CompileData compileData = this->BuildCompileData(sf);
+ auto i = this->CompileGroupMap.find(compileData);
+ if (i == this->CompileGroupMap.end()) {
+ Json::ArrayIndex cgIndex =
+ static_cast<Json::ArrayIndex>(this->CompileGroups.size());
+ i = this->CompileGroupMap.emplace(std::move(compileData), cgIndex).first;
+ CompileGroup g;
+ g.Entry = i;
+ this->CompileGroups.push_back(std::move(g));
+ }
+ this->CompileGroups[i->second].SourceIndexes.append(si);
+ return i->second;
+}
+
+void Target::AddBacktrace(Json::Value& object, cmListFileBacktrace const& bt)
+{
+ if (JBTIndex backtrace = this->Backtraces.Add(bt)) {
+ object["backtrace"] = backtrace.Index;
+ }
+}
+
+void Target::AddBacktrace(Json::Value& object, JBTIndex bt)
+{
+ if (bt) {
+ object["backtrace"] = bt.Index;
+ }
+}
+
+Json::Value Target::DumpPaths()
+{
+ Json::Value paths = Json::objectValue;
+ cmLocalGenerator* lg = this->GT->GetLocalGenerator();
+
+ std::string const& sourceDir = lg->GetCurrentSourceDirectory();
+ paths["source"] = RelativeIfUnder(this->TopSource, sourceDir);
+
+ std::string const& buildDir = lg->GetCurrentBinaryDirectory();
+ paths["build"] = RelativeIfUnder(this->TopBuild, buildDir);
+
+ return paths;
+}
+
+Json::Value Target::DumpSources()
+{
+ Json::Value sources = Json::arrayValue;
+ cmGeneratorTarget::KindedSources const& kinded =
+ this->GT->GetKindedSources(this->Config);
+ for (cmGeneratorTarget::SourceAndKind const& sk : kinded.Sources) {
+ sources.append(this->DumpSource(sk, sources.size()));
+ }
+ return sources;
+}
+
+Json::Value Target::DumpSource(cmGeneratorTarget::SourceAndKind const& sk,
+ Json::ArrayIndex si)
+{
+ Json::Value source = Json::objectValue;
+
+ std::string const path = sk.Source.Value->ResolveFullPath();
+ source["path"] = RelativeIfUnder(this->TopSource, path);
+ if (sk.Source.Value->GetIsGenerated()) {
+ source["isGenerated"] = true;
+ }
+ this->AddBacktrace(source, sk.Source.Backtrace);
+
+ if (cmSourceGroup* sg =
+ this->GT->Makefile->FindSourceGroup(path, this->SourceGroupsLocal)) {
+ source["sourceGroupIndex"] = this->AddSourceGroup(sg, si);
+ }
+
+ switch (sk.Kind) {
+ case cmGeneratorTarget::SourceKindObjectSource: {
+ source["compileGroupIndex"] =
+ this->AddSourceCompileGroup(sk.Source.Value, si);
+ } break;
+ case cmGeneratorTarget::SourceKindAppManifest:
+ case cmGeneratorTarget::SourceKindCertificate:
+ case cmGeneratorTarget::SourceKindCustomCommand:
+ case cmGeneratorTarget::SourceKindExternalObject:
+ case cmGeneratorTarget::SourceKindExtra:
+ case cmGeneratorTarget::SourceKindHeader:
+ case cmGeneratorTarget::SourceKindIDL:
+ case cmGeneratorTarget::SourceKindManifest:
+ case cmGeneratorTarget::SourceKindModuleDefinition:
+ case cmGeneratorTarget::SourceKindResx:
+ case cmGeneratorTarget::SourceKindXaml:
+ case cmGeneratorTarget::SourceKindUnityBatched:
+ break;
+ }
+
+ return source;
+}
+
+Json::Value Target::DumpCompileData(CompileData const& cd)
+{
+ Json::Value result = Json::objectValue;
+
+ if (!cd.Language.empty()) {
+ result["language"] = cd.Language;
+ }
+ if (!cd.Sysroot.empty()) {
+ result["sysroot"] = this->DumpSysroot(cd.Sysroot);
+ }
+ if (!cd.Flags.empty()) {
+ result["compileCommandFragments"] = this->DumpCommandFragments(cd.Flags);
+ }
+ if (!cd.Includes.empty()) {
+ Json::Value includes = Json::arrayValue;
+ for (auto const& i : cd.Includes) {
+ includes.append(this->DumpInclude(i));
+ }
+ result["includes"] = includes;
+ }
+ if (!cd.Defines.empty()) {
+ Json::Value defines = Json::arrayValue;
+ for (JBT<std::string> const& d : cd.Defines) {
+ defines.append(this->DumpDefine(d));
+ }
+ result["defines"] = std::move(defines);
+ }
+
+ return result;
+}
+
+Json::Value Target::DumpInclude(CompileData::IncludeEntry const& inc)
+{
+ Json::Value include = Json::objectValue;
+ include["path"] = inc.Path.Value;
+ if (inc.IsSystem) {
+ include["isSystem"] = true;
+ }
+ this->AddBacktrace(include, inc.Path.Backtrace);
+ return include;
+}
+
+Json::Value Target::DumpDefine(JBT<std::string> const& def)
+{
+ Json::Value define = Json::objectValue;
+ define["define"] = def.Value;
+ this->AddBacktrace(define, def.Backtrace);
+ return define;
+}
+
+Json::Value Target::DumpSourceGroups()
+{
+ Json::Value sourceGroups = Json::arrayValue;
+ for (auto& sg : this->SourceGroups) {
+ sourceGroups.append(this->DumpSourceGroup(sg));
+ }
+ return sourceGroups;
+}
+
+Json::Value Target::DumpSourceGroup(SourceGroup& sg)
+{
+ Json::Value group = Json::objectValue;
+ group["name"] = sg.Name;
+ group["sourceIndexes"] = std::move(sg.SourceIndexes);
+ return group;
+}
+
+Json::Value Target::DumpCompileGroups()
+{
+ Json::Value compileGroups = Json::arrayValue;
+ for (auto& cg : this->CompileGroups) {
+ compileGroups.append(this->DumpCompileGroup(cg));
+ }
+ return compileGroups;
+}
+
+Json::Value Target::DumpCompileGroup(CompileGroup& cg)
+{
+ Json::Value group =
+ this->DumpCompileData(this->MergeCompileData(cg.Entry->first));
+ group["sourceIndexes"] = std::move(cg.SourceIndexes);
+ return group;
+}
+
+Json::Value Target::DumpSysroot(std::string const& path)
+{
+ Json::Value sysroot = Json::objectValue;
+ sysroot["path"] = path;
+ return sysroot;
+}
+
+Json::Value Target::DumpInstall()
+{
+ Json::Value install = Json::objectValue;
+ install["prefix"] = this->DumpInstallPrefix();
+ install["destinations"] = this->DumpInstallDestinations();
+ return install;
+}
+
+Json::Value Target::DumpInstallPrefix()
+{
+ Json::Value prefix = Json::objectValue;
+ std::string p =
+ this->GT->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
+ cmSystemTools::ConvertToUnixSlashes(p);
+ prefix["path"] = p;
+ return prefix;
+}
+
+Json::Value Target::DumpInstallDestinations()
+{
+ Json::Value destinations = Json::arrayValue;
+ auto installGens = this->GT->Target->GetInstallGenerators();
+ for (auto itGen : installGens) {
+ destinations.append(this->DumpInstallDestination(itGen));
+ }
+ return destinations;
+}
+
+Json::Value Target::DumpInstallDestination(cmInstallTargetGenerator* itGen)
+{
+ Json::Value destination = Json::objectValue;
+ destination["path"] = itGen->GetDestination(this->Config);
+ this->AddBacktrace(destination, itGen->GetBacktrace());
+ return destination;
+}
+
+Json::Value Target::DumpArtifacts()
+{
+ Json::Value artifacts = Json::arrayValue;
+
+ // Object libraries have only object files as artifacts.
+ if (this->GT->GetType() == cmStateEnums::OBJECT_LIBRARY) {
+ if (!this->GT->GetGlobalGenerator()->HasKnownObjectFileLocation(nullptr)) {
+ return artifacts;
+ }
+ std::vector<cmSourceFile const*> objectSources;
+ this->GT->GetObjectSources(objectSources, this->Config);
+ std::string const obj_dir = this->GT->GetObjectDirectory(this->Config);
+ for (cmSourceFile const* sf : objectSources) {
+ const std::string& obj = this->GT->GetObjectName(sf);
+ Json::Value artifact = Json::objectValue;
+ artifact["path"] = RelativeIfUnder(this->TopBuild, obj_dir + obj);
+ artifacts.append(std::move(artifact)); // NOLINT(*)
+ }
+ return artifacts;
+ }
+
+ // Other target types always have a "main" artifact.
+ {
+ Json::Value artifact = Json::objectValue;
+ artifact["path"] =
+ RelativeIfUnder(this->TopBuild,
+ this->GT->GetFullPath(
+ this->Config, cmStateEnums::RuntimeBinaryArtifact));
+ artifacts.append(std::move(artifact)); // NOLINT(*)
+ }
+
+ // Add Windows-specific artifacts produced by the linker.
+ if (this->GT->HasImportLibrary(this->Config)) {
+ Json::Value artifact = Json::objectValue;
+ artifact["path"] =
+ RelativeIfUnder(this->TopBuild,
+ this->GT->GetFullPath(
+ this->Config, cmStateEnums::ImportLibraryArtifact));
+ artifacts.append(std::move(artifact)); // NOLINT(*)
+ }
+ if (this->GT->IsDLLPlatform() &&
+ this->GT->GetType() != cmStateEnums::STATIC_LIBRARY) {
+ cmGeneratorTarget::OutputInfo const* output =
+ this->GT->GetOutputInfo(this->Config);
+ if (output && !output->PdbDir.empty()) {
+ Json::Value artifact = Json::objectValue;
+ artifact["path"] = RelativeIfUnder(this->TopBuild,
+ output->PdbDir + '/' +
+ this->GT->GetPDBName(this->Config));
+ artifacts.append(std::move(artifact)); // NOLINT(*)
+ }
+ }
+ return artifacts;
+}
+
+Json::Value Target::DumpLink()
+{
+ Json::Value link = Json::objectValue;
+ std::string lang = this->GT->GetLinkerLanguage(this->Config);
+ link["language"] = lang;
+ {
+ Json::Value commandFragments = this->DumpLinkCommandFragments();
+ if (!commandFragments.empty()) {
+ link["commandFragments"] = std::move(commandFragments);
+ }
+ }
+ if (const char* sysrootLink =
+ this->GT->Makefile->GetDefinition("CMAKE_SYSROOT_LINK")) {
+ link["sysroot"] = this->DumpSysroot(sysrootLink);
+ } else if (const char* sysroot =
+ this->GT->Makefile->GetDefinition("CMAKE_SYSROOT")) {
+ link["sysroot"] = this->DumpSysroot(sysroot);
+ }
+ if (this->GT->IsIPOEnabled(lang, this->Config)) {
+ link["lto"] = true;
+ }
+ return link;
+}
+
+Json::Value Target::DumpArchive()
+{
+ Json::Value archive = Json::objectValue;
+ {
+ // The "link" fragments not relevant to static libraries are empty.
+ Json::Value commandFragments = this->DumpLinkCommandFragments();
+ if (!commandFragments.empty()) {
+ archive["commandFragments"] = std::move(commandFragments);
+ }
+ }
+ std::string lang = this->GT->GetLinkerLanguage(this->Config);
+ if (this->GT->IsIPOEnabled(lang, this->Config)) {
+ archive["lto"] = true;
+ }
+ return archive;
+}
+
+Json::Value Target::DumpLinkCommandFragments()
+{
+ Json::Value linkFragments = Json::arrayValue;
+
+ std::string linkLanguageFlags;
+ std::vector<BT<std::string>> linkFlags;
+ std::string frameworkPath;
+ std::vector<BT<std::string>> linkPath;
+ std::vector<BT<std::string>> linkLibs;
+ cmLocalGenerator* lg = this->GT->GetLocalGenerator();
+ cmLinkLineComputer linkLineComputer(lg,
+ lg->GetStateSnapshot().GetDirectory());
+ lg->GetTargetFlags(&linkLineComputer, this->Config, linkLibs,
+ linkLanguageFlags, linkFlags, frameworkPath, linkPath,
+ this->GT);
+ linkLanguageFlags = cmTrimWhitespace(linkLanguageFlags);
+ frameworkPath = cmTrimWhitespace(frameworkPath);
+
+ if (!linkLanguageFlags.empty()) {
+ linkFragments.append(
+ this->DumpCommandFragment(std::move(linkLanguageFlags), "flags"));
+ }
+
+ if (!linkFlags.empty()) {
+ for (BT<std::string> frag : linkFlags) {
+ frag.Value = cmTrimWhitespace(frag.Value);
+ linkFragments.append(
+ this->DumpCommandFragment(this->ToJBT(frag), "flags"));
+ }
+ }
+
+ if (!frameworkPath.empty()) {
+ linkFragments.append(
+ this->DumpCommandFragment(std::move(frameworkPath), "frameworkPath"));
+ }
+
+ if (!linkPath.empty()) {
+ for (BT<std::string> frag : linkPath) {
+ frag.Value = cmTrimWhitespace(frag.Value);
+ linkFragments.append(
+ this->DumpCommandFragment(this->ToJBT(frag), "libraryPath"));
+ }
+ }
+
+ if (!linkLibs.empty()) {
+ for (BT<std::string> frag : linkLibs) {
+ frag.Value = cmTrimWhitespace(frag.Value);
+ linkFragments.append(
+ this->DumpCommandFragment(this->ToJBT(frag), "libraries"));
+ }
+ }
+
+ return linkFragments;
+}
+
+Json::Value Target::DumpCommandFragments(
+ std::vector<JBT<std::string>> const& frags)
+{
+ Json::Value commandFragments = Json::arrayValue;
+ for (JBT<std::string> const& f : frags) {
+ commandFragments.append(this->DumpCommandFragment(f));
+ }
+ return commandFragments;
+}
+
+Json::Value Target::DumpCommandFragment(JBT<std::string> const& frag,
+ std::string const& role)
+{
+ Json::Value fragment = Json::objectValue;
+ fragment["fragment"] = frag.Value;
+ if (!role.empty()) {
+ fragment["role"] = role;
+ }
+ this->AddBacktrace(fragment, frag.Backtrace);
+ return fragment;
+}
+
+Json::Value Target::DumpDependencies()
+{
+ Json::Value dependencies = Json::arrayValue;
+ cmGlobalGenerator* gg = this->GT->GetGlobalGenerator();
+ for (cmTargetDepend const& td : gg->GetTargetDirectDepends(this->GT)) {
+ dependencies.append(this->DumpDependency(td));
+ }
+ return dependencies;
+}
+
+Json::Value Target::DumpDependency(cmTargetDepend const& td)
+{
+ Json::Value dependency = Json::objectValue;
+ dependency["id"] = TargetId(td, this->TopBuild);
+ this->AddBacktrace(dependency, td.GetBacktrace());
+ return dependency;
+}
+
+Json::Value Target::DumpFolder()
+{
+ Json::Value folder;
+ if (const char* f = this->GT->GetProperty("FOLDER")) {
+ folder = Json::objectValue;
+ folder["name"] = f;
+ }
+ return folder;
+}
+}
+
+Json::Value cmFileAPICodemodelDump(cmFileAPI& fileAPI, unsigned long version)
+{
+ Codemodel codemodel(fileAPI, version);
+ return codemodel.Dump();
+}
diff --git a/Source/cmFileAPICodemodel.h b/Source/cmFileAPICodemodel.h
new file mode 100644
index 000000000..ffbd92863
--- /dev/null
+++ b/Source/cmFileAPICodemodel.h
@@ -0,0 +1,15 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmFileAPICodemodel_h
+#define cmFileAPICodemodel_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include "cm_jsoncpp_value.h"
+
+class cmFileAPI;
+
+extern Json::Value cmFileAPICodemodelDump(cmFileAPI& fileAPI,
+ unsigned long version);
+
+#endif
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 5777fb204..d45414f72 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2,85 +2,73 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFileCommand.h"
-#include "cm_kwiml.h"
-#include "cmsys/Directory.hxx"
-#include "cmsys/FStream.hxx"
-#include "cmsys/Glob.hxx"
-#include "cmsys/RegularExpression.hxx"
-#include "cmsys/String.hxx"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cctype>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <map>
+#include <set>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <utility>
#include <vector>
+#include <cm/memory>
+
+#include "cmsys/FStream.hxx"
+#include "cmsys/Glob.hxx"
+#include "cmsys/RegularExpression.hxx"
+
+#include "cm_kwiml.h"
+#include "cm_static_string_view.hxx"
+#include "cm_sys_stat.h"
+
#include "cmAlgorithms.h"
-#include "cmCommandArgumentsHelper.h"
+#include "cmArgumentParser.h"
#include "cmCryptoHash.h"
+#include "cmExecutionStatus.h"
+#include "cmFileCopier.h"
+#include "cmFileInstaller.h"
#include "cmFileLockPool.h"
-#include "cmFileTimeComparison.h"
+#include "cmFileTimes.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmHexFileConverter.h"
-#include "cmInstallType.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
+#include "cmRange.h"
+#include "cmRuntimeDependencyArchive.h"
+#include "cmState.h"
+#include "cmStringAlgorithms.h"
+#include "cmSubcommandTable.h"
#include "cmSystemTools.h"
#include "cmTimestamp.h"
-#include "cm_auto_ptr.hxx"
-#include "cm_sys_stat.h"
#include "cmake.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmCurl.h"
-#include "cmFileLockResult.h"
-#include "cm_curl.h"
+#if !defined(CMAKE_BOOTSTRAP)
+# include "cm_curl.h"
+
+# include "cmCurl.h"
+# include "cmFileLockResult.h"
#endif
#if defined(CMAKE_USE_ELF_PARSER)
-#include "cmELF.h"
+# include "cmELF.h"
#endif
#if defined(_WIN32)
-#include <windows.h>
+# include <windows.h>
#endif
-class cmSystemToolsFileTime;
-
-// Table of permissions flags.
-#if defined(_WIN32) && !defined(__CYGWIN__)
-static mode_t mode_owner_read = S_IREAD;
-static mode_t mode_owner_write = S_IWRITE;
-static mode_t mode_owner_execute = S_IEXEC;
-static mode_t mode_group_read = 0;
-static mode_t mode_group_write = 0;
-static mode_t mode_group_execute = 0;
-static mode_t mode_world_read = 0;
-static mode_t mode_world_write = 0;
-static mode_t mode_world_execute = 0;
-static mode_t mode_setuid = 0;
-static mode_t mode_setgid = 0;
-#else
-static mode_t mode_owner_read = S_IRUSR;
-static mode_t mode_owner_write = S_IWUSR;
-static mode_t mode_owner_execute = S_IXUSR;
-static mode_t mode_group_read = S_IRGRP;
-static mode_t mode_group_write = S_IWGRP;
-static mode_t mode_group_execute = S_IXGRP;
-static mode_t mode_world_read = S_IROTH;
-static mode_t mode_world_write = S_IWOTH;
-static mode_t mode_world_execute = S_IXOTH;
-static mode_t mode_setuid = S_ISUID;
-static mode_t mode_setgid = S_ISGID;
-#endif
+namespace {
#if defined(_WIN32)
// libcurl doesn't support file:// urls for unicode filenames on Windows.
// Convert string from UTF-8 to ACP if this is a file:// URL.
-static std::string fix_file_url_windows(const std::string& url)
+std::string fix_file_url_windows(const std::string& url)
{
std::string ret = url;
if (strncmp(url.c_str(), "file://", 7) == 0) {
@@ -102,228 +90,152 @@ static std::string fix_file_url_windows(const std::string& url)
}
#endif
-// cmLibraryCommand
-bool cmFileCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool HandleWriteImpl(std::vector<std::string> const& args, bool append,
+ cmExecutionStatus& status)
{
- if (args.size() < 2) {
- this->SetError("must be called with at least two arguments.");
- return false;
- }
- std::string const& subCommand = args[0];
- if (subCommand == "WRITE") {
- return this->HandleWriteCommand(args, false);
- }
- if (subCommand == "APPEND") {
- return this->HandleWriteCommand(args, true);
- }
- if (subCommand == "DOWNLOAD") {
- return this->HandleDownloadCommand(args);
- }
- if (subCommand == "UPLOAD") {
- return this->HandleUploadCommand(args);
- }
- if (subCommand == "READ") {
- return this->HandleReadCommand(args);
- }
- if (subCommand == "MD5" || subCommand == "SHA1" || subCommand == "SHA224" ||
- subCommand == "SHA256" || subCommand == "SHA384" ||
- subCommand == "SHA512" || subCommand == "SHA3_224" ||
- subCommand == "SHA3_256" || subCommand == "SHA3_384" ||
- subCommand == "SHA3_512") {
- return this->HandleHashCommand(args);
- }
- if (subCommand == "STRINGS") {
- return this->HandleStringsCommand(args);
- }
- if (subCommand == "GLOB") {
- return this->HandleGlobCommand(args, false);
- }
- if (subCommand == "GLOB_RECURSE") {
- return this->HandleGlobCommand(args, true);
- }
- if (subCommand == "MAKE_DIRECTORY") {
- return this->HandleMakeDirectoryCommand(args);
- }
- if (subCommand == "RENAME") {
- return this->HandleRename(args);
- }
- if (subCommand == "REMOVE") {
- return this->HandleRemove(args, false);
- }
- if (subCommand == "REMOVE_RECURSE") {
- return this->HandleRemove(args, true);
- }
- if (subCommand == "COPY") {
- return this->HandleCopyCommand(args);
- }
- if (subCommand == "INSTALL") {
- return this->HandleInstallCommand(args);
- }
- if (subCommand == "DIFFERENT") {
- return this->HandleDifferentCommand(args);
- }
- if (subCommand == "RPATH_CHANGE" || subCommand == "CHRPATH") {
- return this->HandleRPathChangeCommand(args);
- }
- if (subCommand == "RPATH_CHECK") {
- return this->HandleRPathCheckCommand(args);
- }
- if (subCommand == "RPATH_REMOVE") {
- return this->HandleRPathRemoveCommand(args);
- }
- if (subCommand == "READ_ELF") {
- return this->HandleReadElfCommand(args);
- }
- if (subCommand == "RELATIVE_PATH") {
- return this->HandleRelativePathCommand(args);
- }
- if (subCommand == "TO_CMAKE_PATH") {
- return this->HandleCMakePathCommand(args, false);
- }
- if (subCommand == "TO_NATIVE_PATH") {
- return this->HandleCMakePathCommand(args, true);
- }
- if (subCommand == "TIMESTAMP") {
- return this->HandleTimestampCommand(args);
- }
- if (subCommand == "GENERATE") {
- return this->HandleGenerateCommand(args);
- }
- if (subCommand == "LOCK") {
- return this->HandleLockCommand(args);
- }
-
- std::string e = "does not recognize sub-command " + subCommand;
- this->SetError(e);
- return false;
-}
-
-bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
- bool append)
-{
- std::vector<std::string>::const_iterator i = args.begin();
+ auto i = args.begin();
i++; // Get rid of subcommand
std::string fileName = *i;
- if (!cmsys::SystemTools::FileIsFullPath(i->c_str())) {
- fileName = this->Makefile->GetCurrentSourceDirectory();
- fileName += "/" + *i;
+ if (!cmsys::SystemTools::FileIsFullPath(*i)) {
+ fileName =
+ cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', *i);
}
i++;
- if (!this->Makefile->CanIWriteThisFile(fileName.c_str())) {
+ if (!status.GetMakefile().CanIWriteThisFile(fileName)) {
std::string e =
"attempted to write a file: " + fileName + " into a source directory.";
- this->SetError(e);
+ status.SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
std::string dir = cmSystemTools::GetFilenamePath(fileName);
- cmSystemTools::MakeDirectory(dir.c_str());
+ cmSystemTools::MakeDirectory(dir);
mode_t mode = 0;
+ bool writable = false;
// Set permissions to writable
- if (cmSystemTools::GetPermissions(fileName.c_str(), mode)) {
- cmSystemTools::SetPermissions(fileName.c_str(),
+ if (cmSystemTools::GetPermissions(fileName, mode)) {
#if defined(_MSC_VER) || defined(__MINGW32__)
- mode | S_IWRITE
+ writable = (mode & S_IWRITE) != 0;
+ mode_t newMode = mode | S_IWRITE;
#else
- mode | S_IWUSR | S_IWGRP
+ writable = mode & S_IWUSR;
+ mode_t newMode = mode | S_IWUSR | S_IWGRP;
#endif
- );
+ if (!writable) {
+ cmSystemTools::SetPermissions(fileName, newMode);
+ }
}
// If GetPermissions fails, pretend like it is ok. File open will fail if
// the file is not writable
cmsys::ofstream file(fileName.c_str(),
append ? std::ios::app : std::ios::out);
if (!file) {
- std::string error = "failed to open for writing (";
- error += cmSystemTools::GetLastSystemError();
- error += "):\n ";
- error += fileName;
- this->SetError(error);
+ std::string error =
+ cmStrCat("failed to open for writing (",
+ cmSystemTools::GetLastSystemError(), "):\n ", fileName);
+ status.SetError(error);
return false;
}
std::string message = cmJoin(cmMakeRange(i, args.end()), std::string());
file << message;
+ if (!file) {
+ std::string error =
+ cmStrCat("write failed (", cmSystemTools::GetLastSystemError(), "):\n ",
+ fileName);
+ status.SetError(error);
+ return false;
+ }
file.close();
- if (mode) {
- cmSystemTools::SetPermissions(fileName.c_str(), mode);
+ if (mode && !writable) {
+ cmSystemTools::SetPermissions(fileName, mode);
}
return true;
}
-bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
+bool HandleWriteCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleWriteImpl(args, false, status);
+}
+
+bool HandleAppendCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleWriteImpl(args, true, status);
+}
+
+bool HandleReadCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("READ must be called with at least two additional "
- "arguments");
+ status.SetError("READ must be called with at least two additional "
+ "arguments");
return false;
}
- cmCommandArgumentsHelper argHelper;
- cmCommandArgumentGroup group;
+ std::string const& fileNameArg = args[1];
+ std::string const& variable = args[2];
- cmCAString readArg(&argHelper, "READ");
- cmCAString fileNameArg(&argHelper, CM_NULLPTR);
- cmCAString resultArg(&argHelper, CM_NULLPTR);
+ struct Arguments
+ {
+ std::string Offset;
+ std::string Limit;
+ bool Hex = false;
+ };
- cmCAString offsetArg(&argHelper, "OFFSET", &group);
- cmCAString limitArg(&argHelper, "LIMIT", &group);
- cmCAEnabler hexOutputArg(&argHelper, "HEX", &group);
- readArg.Follows(CM_NULLPTR);
- fileNameArg.Follows(&readArg);
- resultArg.Follows(&fileNameArg);
- group.Follows(&resultArg);
- argHelper.Parse(&args, CM_NULLPTR);
+ static auto const parser = cmArgumentParser<Arguments>{}
+ .Bind("OFFSET"_s, &Arguments::Offset)
+ .Bind("LIMIT"_s, &Arguments::Limit)
+ .Bind("HEX"_s, &Arguments::Hex);
- std::string fileName = fileNameArg.GetString();
- if (!cmsys::SystemTools::FileIsFullPath(fileName.c_str())) {
- fileName = this->Makefile->GetCurrentSourceDirectory();
- fileName += "/" + fileNameArg.GetString();
- }
+ Arguments const arguments = parser.Parse(cmMakeRange(args).advance(3));
- std::string variable = resultArg.GetString();
+ std::string fileName = fileNameArg;
+ if (!cmsys::SystemTools::FileIsFullPath(fileName)) {
+ fileName = cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/',
+ fileNameArg);
+ }
// Open the specified file.
#if defined(_WIN32) || defined(__CYGWIN__)
- cmsys::ifstream file(
- fileName.c_str(), std::ios::in |
- (hexOutputArg.IsEnabled() ? std::ios::binary : std::ios::in));
+ cmsys::ifstream file(fileName.c_str(),
+ arguments.Hex ? (std::ios::binary | std::ios::in)
+ : std::ios::in);
#else
cmsys::ifstream file(fileName.c_str());
#endif
if (!file) {
- std::string error = "failed to open for reading (";
- error += cmSystemTools::GetLastSystemError();
- error += "):\n ";
- error += fileName;
- this->SetError(error);
+ std::string error =
+ cmStrCat("failed to open for reading (",
+ cmSystemTools::GetLastSystemError(), "):\n ", fileName);
+ status.SetError(error);
return false;
}
// is there a limit?
long sizeLimit = -1;
- if (!limitArg.GetString().empty()) {
- sizeLimit = atoi(limitArg.GetCString());
+ if (!arguments.Limit.empty()) {
+ sizeLimit = atoi(arguments.Limit.c_str());
}
// is there an offset?
long offset = 0;
- if (!offsetArg.GetString().empty()) {
- offset = atoi(offsetArg.GetCString());
+ if (!arguments.Offset.empty()) {
+ offset = atoi(arguments.Offset.c_str());
}
file.seekg(offset, std::ios::beg); // explicit ios::beg for IBM VisualAge 6
std::string output;
- if (hexOutputArg.IsEnabled()) {
+ if (arguments.Hex) {
// Convert part of the file into hex code
char c;
while ((sizeLimit != 0) && (file.get(c))) {
@@ -337,8 +249,9 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
} else {
std::string line;
bool has_newline = false;
- while (sizeLimit != 0 && cmSystemTools::GetLineFromStream(
- file, line, &has_newline, sizeLimit)) {
+ while (
+ sizeLimit != 0 &&
+ cmSystemTools::GetLineFromStream(file, line, &has_newline, sizeLimit)) {
if (sizeLimit > 0) {
sizeLimit = sizeLimit - static_cast<long>(line.size());
if (has_newline) {
@@ -354,53 +267,50 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
}
}
}
- this->Makefile->AddDefinition(variable, output.c_str());
+ status.GetMakefile().AddDefinition(variable, output);
return true;
}
-bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args)
+bool HandleHashCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
if (args.size() != 3) {
- std::ostringstream e;
- e << args[0] << " requires a file name and output variable";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " requires a file name and output variable"));
return false;
}
- CM_AUTO_PTR<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
- if (hash.get()) {
+ std::unique_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0]));
+ if (hash) {
std::string out = hash->HashFile(args[1]);
if (!out.empty()) {
- this->Makefile->AddDefinition(args[2], out.c_str());
+ status.GetMakefile().AddDefinition(args[2], out);
return true;
}
- std::ostringstream e;
- e << args[0] << " failed to read file \"" << args[1]
- << "\": " << cmSystemTools::GetLastSystemError();
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " failed to read file \"", args[1],
+ "\": ", cmSystemTools::GetLastSystemError()));
}
return false;
#else
- std::ostringstream e;
- e << args[0] << " not available during bootstrap";
- this->SetError(e.str().c_str());
+ status.SetError(cmStrCat(args[0], " not available during bootstrap"));
return false;
#endif
}
-bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
+bool HandleStringsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("STRINGS requires a file name and output variable");
+ status.SetError("STRINGS requires a file name and output variable");
return false;
}
// Get the file to read.
std::string fileName = args[1];
- if (!cmsys::SystemTools::FileIsFullPath(fileName.c_str())) {
- fileName = this->Makefile->GetCurrentSourceDirectory();
- fileName += "/" + args[1];
+ if (!cmsys::SystemTools::FileIsFullPath(fileName)) {
+ fileName =
+ cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', args[1]);
}
// Get the variable in which to store the results.
@@ -463,30 +373,24 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
} else if (arg_mode == arg_limit_input) {
if (sscanf(args[i].c_str(), "%d", &limit_input) != 1 ||
limit_input < 0) {
- std::ostringstream e;
- e << "STRINGS option LIMIT_INPUT value \"" << args[i]
- << "\" is not an unsigned integer.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LIMIT_INPUT value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
arg_mode = arg_none;
} else if (arg_mode == arg_limit_output) {
if (sscanf(args[i].c_str(), "%d", &limit_output) != 1 ||
limit_output < 0) {
- std::ostringstream e;
- e << "STRINGS option LIMIT_OUTPUT value \"" << args[i]
- << "\" is not an unsigned integer.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LIMIT_OUTPUT value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
arg_mode = arg_none;
} else if (arg_mode == arg_limit_count) {
int count;
if (sscanf(args[i].c_str(), "%d", &count) != 1 || count < 0) {
- std::ostringstream e;
- e << "STRINGS option LIMIT_COUNT value \"" << args[i]
- << "\" is not an unsigned integer.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LIMIT_COUNT value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
limit_count = count;
@@ -494,10 +398,8 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
} else if (arg_mode == arg_length_minimum) {
int len;
if (sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0) {
- std::ostringstream e;
- e << "STRINGS option LENGTH_MINIMUM value \"" << args[i]
- << "\" is not an unsigned integer.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LENGTH_MINIMUM value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
minlen = len;
@@ -505,20 +407,16 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
} else if (arg_mode == arg_length_maximum) {
int len;
if (sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0) {
- std::ostringstream e;
- e << "STRINGS option LENGTH_MAXIMUM value \"" << args[i]
- << "\" is not an unsigned integer.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LENGTH_MAXIMUM value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
maxlen = len;
arg_mode = arg_none;
} else if (arg_mode == arg_regex) {
- if (!regex.compile(args[i].c_str())) {
- std::ostringstream e;
- e << "STRINGS option REGEX value \"" << args[i]
- << "\" could not be compiled.";
- this->SetError(e.str());
+ if (!regex.compile(args[i])) {
+ status.SetError(cmStrCat("STRINGS option REGEX value \"", args[i],
+ "\" could not be compiled."));
return false;
}
have_regex = true;
@@ -535,27 +433,24 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
} else if (args[i] == "UTF-32BE") {
encoding = encoding_utf32be;
} else {
- std::ostringstream e;
- e << "STRINGS option ENCODING \"" << args[i] << "\" not recognized.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option ENCODING \"", args[i],
+ "\" not recognized."));
return false;
}
arg_mode = arg_none;
} else {
- std::ostringstream e;
- e << "STRINGS given unknown argument \"" << args[i] << "\"";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("STRINGS given unknown argument \"", args[i], "\""));
return false;
}
}
if (hex_conversion_enabled) {
// TODO: should work without temp file, but just on a memory buffer
- std::string binaryFileName = this->Makefile->GetCurrentBinaryDirectory();
- binaryFileName += cmake::GetCMakeFilesDirectory();
- binaryFileName += "/FileCommandStringsBinaryFile";
- if (cmHexFileConverter::TryConvert(fileName.c_str(),
- binaryFileName.c_str())) {
+ std::string binaryFileName =
+ cmStrCat(status.GetMakefile().GetCurrentBinaryDirectory(),
+ "/CMakeFiles/FileCommandStringsBinaryFile");
+ if (cmHexFileConverter::TryConvert(fileName, binaryFileName)) {
fileName = binaryFileName;
}
}
@@ -567,9 +462,8 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmsys::ifstream fin(fileName.c_str());
#endif
if (!fin) {
- std::ostringstream e;
- e << "STRINGS file \"" << fileName << "\" cannot be read.";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("STRINGS file \"", fileName, "\" cannot be read."));
return false;
}
@@ -617,8 +511,8 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
continue;
}
- if ((c >= 0x20 && c < 0x7F) || c == '\t' ||
- (c == '\n' && newline_consume)) {
+ if (c >= 0 && c <= 0xFF &&
+ (isprint(c) || c == '\t' || (c == '\n' && newline_consume))) {
// This is an ASCII character that may be part of a string.
// Cast added to avoid compiler warning. Cast is ok because
// c is guaranteed to fit in char by the above if...
@@ -626,7 +520,9 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
} else if (encoding == encoding_utf8) {
// Check for UTF-8 encoded string (up to 4 octets)
static const unsigned char utf8_check_table[3][2] = {
- { 0xE0, 0xC0 }, { 0xF0, 0xE0 }, { 0xF8, 0xF0 },
+ { 0xE0, 0xC0 },
+ { 0xF0, 0xE0 },
+ { 0xF8, 0xF0 },
};
// how many octets are there?
@@ -656,7 +552,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
c = current_str[current_str.size() - 1 - j];
fin.putback(static_cast<char>(c));
}
- current_str = "";
+ current_str.clear();
}
}
@@ -664,48 +560,48 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
// The current line has been terminated. Check if the current
// string matches the requirements. The length may now be as
// low as zero since blank lines are allowed.
- if (s.length() >= minlen && (!have_regex || regex.find(s.c_str()))) {
+ if (s.length() >= minlen && (!have_regex || regex.find(s))) {
output_size += static_cast<int>(s.size()) + 1;
if (limit_output >= 0 && output_size >= limit_output) {
- s = "";
+ s.clear();
break;
}
strings.push_back(s);
}
// Reset the string to empty.
- s = "";
+ s.clear();
} else if (current_str.empty()) {
// A non-string character has been found. Check if the current
// string matches the requirements. We require that the length
// be at least one no matter what the user specified.
if (s.length() >= minlen && !s.empty() &&
- (!have_regex || regex.find(s.c_str()))) {
+ (!have_regex || regex.find(s))) {
output_size += static_cast<int>(s.size()) + 1;
if (limit_output >= 0 && output_size >= limit_output) {
- s = "";
+ s.clear();
break;
}
strings.push_back(s);
}
// Reset the string to empty.
- s = "";
+ s.clear();
} else {
s += current_str;
}
if (maxlen > 0 && s.size() == maxlen) {
// Terminate a string if the maximum length is reached.
- if (s.length() >= minlen && (!have_regex || regex.find(s.c_str()))) {
+ if (s.length() >= minlen && (!have_regex || regex.find(s))) {
output_size += static_cast<int>(s.size()) + 1;
if (limit_output >= 0 && output_size >= limit_output) {
- s = "";
+ s.clear();
break;
}
strings.push_back(s);
}
- s = "";
+ s.clear();
}
}
@@ -713,7 +609,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
// input file or the input size limit. Check if the current string
// matches the requirements.
if ((!limit_count || strings.size() < limit_count) && !s.empty() &&
- s.length() >= minlen && (!have_regex || regex.find(s.c_str()))) {
+ s.length() >= minlen && (!have_regex || regex.find(s))) {
output_size += static_cast<int>(s.size()) + 1;
if (limit_output < 0 || output_size < limit_output) {
strings.push_back(s);
@@ -723,35 +619,33 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
// Encode the result in a CMake list.
const char* sep = "";
std::string output;
- for (std::vector<std::string>::const_iterator si = strings.begin();
- si != strings.end(); ++si) {
+ for (std::string const& sr : strings) {
// Separate the strings in the output to make it a list.
output += sep;
sep = ";";
// Store the string in the output, but escape semicolons to
// make sure it is a list.
- std::string const& sr = *si;
- for (unsigned int i = 0; i < sr.size(); ++i) {
- if (sr[i] == ';') {
+ for (char i : sr) {
+ if (i == ';') {
output += '\\';
}
- output += sr[i];
+ output += i;
}
}
// Save the output in a makefile variable.
- this->Makefile->AddDefinition(outVar, output.c_str());
+ status.GetMakefile().AddDefinition(outVar, output);
return true;
}
-bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
- bool recurse)
+bool HandleGlobImpl(std::vector<std::string> const& args, bool recurse,
+ cmExecutionStatus& status)
{
// File commands has at least one argument
assert(args.size() > 1);
- std::vector<std::string>::const_iterator i = args.begin();
+ auto i = args.begin();
i++; // Get rid of subcommand
@@ -761,10 +655,10 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
g.SetRecurse(recurse);
bool explicitFollowSymlinks = false;
- cmPolicies::PolicyStatus status =
- this->Makefile->GetPolicyStatus(cmPolicies::CMP0009);
+ cmPolicies::PolicyStatus policyStatus =
+ status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0009);
if (recurse) {
- switch (status) {
+ switch (policyStatus) {
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
@@ -777,172 +671,259 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
}
}
- std::string output;
- bool first = true;
- for (; i != args.end(); ++i) {
+ std::vector<std::string> files;
+ bool configureDepends = false;
+ bool warnConfigureLate = false;
+ bool warnFollowedSymlinks = false;
+ const cmake::WorkingMode workingMode =
+ status.GetMakefile().GetCMakeInstance()->GetWorkingMode();
+ while (i != args.end()) {
if (*i == "LIST_DIRECTORIES") {
- ++i;
+ ++i; // skip LIST_DIRECTORIES
if (i != args.end()) {
- if (cmSystemTools::IsOn(i->c_str())) {
+ if (cmIsOn(*i)) {
g.SetListDirs(true);
g.SetRecurseListDirs(true);
- } else if (cmSystemTools::IsOff(i->c_str())) {
+ } else if (cmIsOff(*i)) {
g.SetListDirs(false);
g.SetRecurseListDirs(false);
} else {
- this->SetError("LIST_DIRECTORIES missing bool value.");
+ status.SetError("LIST_DIRECTORIES missing bool value.");
return false;
}
+ ++i;
} else {
- this->SetError("LIST_DIRECTORIES missing bool value.");
+ status.SetError("LIST_DIRECTORIES missing bool value.");
return false;
}
- continue;
- }
-
- if (recurse && (*i == "FOLLOW_SYMLINKS")) {
- explicitFollowSymlinks = true;
- g.RecurseThroughSymlinksOn();
- ++i;
- if (i == args.end()) {
- this->SetError(
- "GLOB_RECURSE requires a glob expression after FOLLOW_SYMLINKS");
- return false;
+ } else if (*i == "FOLLOW_SYMLINKS") {
+ ++i; // skip FOLLOW_SYMLINKS
+ if (recurse) {
+ explicitFollowSymlinks = true;
+ g.RecurseThroughSymlinksOn();
+ if (i == args.end()) {
+ status.SetError(
+ "GLOB_RECURSE requires a glob expression after FOLLOW_SYMLINKS.");
+ return false;
+ }
}
- }
-
- if (*i == "RELATIVE") {
+ } else if (*i == "RELATIVE") {
++i; // skip RELATIVE
if (i == args.end()) {
- this->SetError("GLOB requires a directory after the RELATIVE tag");
+ status.SetError("GLOB requires a directory after the RELATIVE tag.");
return false;
}
g.SetRelative(i->c_str());
++i;
if (i == args.end()) {
- this->SetError("GLOB requires a glob expression after the directory");
+ status.SetError(
+ "GLOB requires a glob expression after the directory.");
return false;
}
- }
-
- cmsys::Glob::GlobMessages globMessages;
- if (!cmsys::SystemTools::FileIsFullPath(i->c_str())) {
- std::string expr = this->Makefile->GetCurrentSourceDirectory();
- // Handle script mode
- if (!expr.empty()) {
- expr += "/" + *i;
- g.FindFiles(expr, &globMessages);
- } else {
- g.FindFiles(*i, &globMessages);
+ } else if (*i == "CONFIGURE_DEPENDS") {
+ // Generated build system depends on glob results
+ if (!configureDepends && warnConfigureLate) {
+ status.GetMakefile().IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ "CONFIGURE_DEPENDS flag was given after a glob expression was "
+ "already evaluated.");
+ }
+ if (workingMode != cmake::NORMAL_MODE) {
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ "CONFIGURE_DEPENDS is invalid for script and find package modes.");
+ return false;
+ }
+ configureDepends = true;
+ ++i;
+ if (i == args.end()) {
+ status.SetError(
+ "GLOB requires a glob expression after CONFIGURE_DEPENDS.");
+ return false;
}
} else {
- g.FindFiles(*i, &globMessages);
- }
-
- if (!globMessages.empty()) {
- bool shouldExit = false;
- for (cmsys::Glob::GlobMessagesIterator it = globMessages.begin();
- it != globMessages.end(); ++it) {
- if (it->type == cmsys::Glob::cyclicRecursion) {
- this->Makefile->IssueMessage(
- cmake::AUTHOR_WARNING,
- "Cyclic recursion detected while globbing for '" + *i + "':\n" +
- it->content);
+ std::string expr = *i;
+ if (!cmsys::SystemTools::FileIsFullPath(*i)) {
+ expr = status.GetMakefile().GetCurrentSourceDirectory();
+ // Handle script mode
+ if (!expr.empty()) {
+ expr += "/" + *i;
} else {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR, "Error has occurred while globbing for '" +
- *i + "' - " + it->content);
- shouldExit = true;
+ expr = *i;
}
}
- if (shouldExit) {
- return false;
+
+ cmsys::Glob::GlobMessages globMessages;
+ g.FindFiles(expr, &globMessages);
+
+ if (!globMessages.empty()) {
+ bool shouldExit = false;
+ for (cmsys::Glob::Message const& globMessage : globMessages) {
+ if (globMessage.type == cmsys::Glob::cyclicRecursion) {
+ status.GetMakefile().IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ "Cyclic recursion detected while globbing for '" + *i + "':\n" +
+ globMessage.content);
+ } else {
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ "Error has occurred while globbing for '" + *i + "' - " +
+ globMessage.content);
+ shouldExit = true;
+ }
+ }
+ if (shouldExit) {
+ return false;
+ }
}
- }
- std::vector<std::string>::size_type cc;
- std::vector<std::string>& files = g.GetFiles();
- std::sort(files.begin(), files.end());
- for (cc = 0; cc < files.size(); cc++) {
- if (!first) {
- output += ";";
+ if (recurse && !explicitFollowSymlinks &&
+ g.GetFollowedSymlinkCount() != 0) {
+ warnFollowedSymlinks = true;
}
- output += files[cc];
- first = false;
+
+ std::vector<std::string>& foundFiles = g.GetFiles();
+ cmAppend(files, foundFiles);
+
+ if (configureDepends) {
+ std::sort(foundFiles.begin(), foundFiles.end());
+ foundFiles.erase(std::unique(foundFiles.begin(), foundFiles.end()),
+ foundFiles.end());
+ status.GetMakefile().GetCMakeInstance()->AddGlobCacheEntry(
+ recurse, (recurse ? g.GetRecurseListDirs() : g.GetListDirs()),
+ (recurse ? g.GetRecurseThroughSymlinks() : false),
+ (g.GetRelative() ? g.GetRelative() : ""), expr, foundFiles, variable,
+ status.GetMakefile().GetBacktrace());
+ } else {
+ warnConfigureLate = true;
+ }
+ ++i;
}
}
- if (recurse && !explicitFollowSymlinks) {
- switch (status) {
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::NEW:
- // Correct behavior, yay!
- break;
- case cmPolicies::OLD:
- // Probably not really the expected behavior, but the author explicitly
- // asked for the old behavior... no warning.
- case cmPolicies::WARN:
- // Possibly unexpected old behavior *and* we actually traversed
- // symlinks without being explicitly asked to: warn the author.
- if (g.GetFollowedSymlinkCount() != 0) {
- this->Makefile->IssueMessage(
- cmake::AUTHOR_WARNING,
- cmPolicies::GetPolicyWarning(cmPolicies::CMP0009));
- }
- break;
- }
+ switch (policyStatus) {
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ // Correct behavior, yay!
+ break;
+ case cmPolicies::OLD:
+ // Probably not really the expected behavior, but the author explicitly
+ // asked for the old behavior... no warning.
+ case cmPolicies::WARN:
+ // Possibly unexpected old behavior *and* we actually traversed
+ // symlinks without being explicitly asked to: warn the author.
+ if (warnFollowedSymlinks) {
+ status.GetMakefile().IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0009));
+ }
+ break;
}
- this->Makefile->AddDefinition(variable, output.c_str());
+ std::sort(files.begin(), files.end());
+ files.erase(std::unique(files.begin(), files.end()), files.end());
+ status.GetMakefile().AddDefinition(variable, cmJoin(files, ";"));
return true;
}
-bool cmFileCommand::HandleMakeDirectoryCommand(
- std::vector<std::string> const& args)
+bool HandleGlobCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- // File command has at least one argument
- assert(args.size() > 1);
+ return HandleGlobImpl(args, false, status);
+}
- std::vector<std::string>::const_iterator i = args.begin();
+bool HandleGlobRecurseCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleGlobImpl(args, true, status);
+}
- i++; // Get rid of subcommand
+bool HandleMakeDirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ // File command has at least one argument
+ assert(args.size() > 1);
std::string expr;
- for (; i != args.end(); ++i) {
- const std::string* cdir = &(*i);
- if (!cmsys::SystemTools::FileIsFullPath(i->c_str())) {
- expr = this->Makefile->GetCurrentSourceDirectory();
- expr += "/" + *i;
+ for (std::string const& arg :
+ cmMakeRange(args).advance(1)) // Get rid of subcommand
+ {
+ const std::string* cdir = &arg;
+ if (!cmsys::SystemTools::FileIsFullPath(arg)) {
+ expr =
+ cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', arg);
cdir = &expr;
}
- if (!this->Makefile->CanIWriteThisFile(cdir->c_str())) {
+ if (!status.GetMakefile().CanIWriteThisFile(*cdir)) {
std::string e = "attempted to create a directory: " + *cdir +
" into a source directory.";
- this->SetError(e);
+ status.SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
- if (!cmSystemTools::MakeDirectory(cdir->c_str())) {
+ if (!cmSystemTools::MakeDirectory(*cdir)) {
std::string error = "problem creating directory: " + *cdir;
- this->SetError(error);
+ status.SetError(error);
+ return false;
+ }
+ }
+ return true;
+}
+
+bool HandleTouchImpl(std::vector<std::string> const& args, bool create,
+ cmExecutionStatus& status)
+{
+ // File command has at least one argument
+ assert(args.size() > 1);
+
+ for (std::string const& arg :
+ cmMakeRange(args).advance(1)) // Get rid of subcommand
+ {
+ std::string tfile = arg;
+ if (!cmsys::SystemTools::FileIsFullPath(tfile)) {
+ tfile =
+ cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', arg);
+ }
+ if (!status.GetMakefile().CanIWriteThisFile(tfile)) {
+ std::string e =
+ "attempted to touch a file: " + tfile + " in a source directory.";
+ status.SetError(e);
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+ if (!cmSystemTools::Touch(tfile, create)) {
+ std::string error = "problem touching file: " + tfile;
+ status.SetError(error);
return false;
}
}
return true;
}
-bool cmFileCommand::HandleDifferentCommand(
- std::vector<std::string> const& args)
+bool HandleTouchCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleTouchImpl(args, true, status);
+}
+
+bool HandleTouchNocreateCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleTouchImpl(args, false, status);
+}
+
+bool HandleDifferentCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
/*
FILE(DIFFERENT <variable> FILES <lhs> <rhs>)
*/
// Evaluate arguments.
- const char* file_lhs = CM_NULLPTR;
- const char* file_rhs = CM_NULLPTR;
- const char* var = CM_NULLPTR;
+ const char* file_lhs = nullptr;
+ const char* file_rhs = nullptr;
+ const char* var = nullptr;
enum Doing
{
DoingNone,
@@ -964,1073 +945,41 @@ bool cmFileCommand::HandleDifferentCommand(
file_rhs = args[i].c_str();
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "DIFFERENT given unknown argument " << args[i];
- this->SetError(e.str());
+ status.SetError(cmStrCat("DIFFERENT given unknown argument ", args[i]));
return false;
}
}
if (!var) {
- this->SetError("DIFFERENT not given result variable name.");
+ status.SetError("DIFFERENT not given result variable name.");
return false;
}
if (!file_lhs || !file_rhs) {
- this->SetError("DIFFERENT not given FILES option with two file names.");
+ status.SetError("DIFFERENT not given FILES option with two file names.");
return false;
}
// Compare the files.
const char* result =
cmSystemTools::FilesDiffer(file_lhs, file_rhs) ? "1" : "0";
- this->Makefile->AddDefinition(var, result);
- return true;
-}
-
-// File installation helper class.
-struct cmFileCopier
-{
- cmFileCopier(cmFileCommand* command, const char* name = "COPY")
- : FileCommand(command)
- , Makefile(command->GetMakefile())
- , Name(name)
- , Always(false)
- , MatchlessFiles(true)
- , FilePermissions(0)
- , DirPermissions(0)
- , CurrentMatchRule(CM_NULLPTR)
- , UseGivenPermissionsFile(false)
- , UseGivenPermissionsDir(false)
- , UseSourcePermissions(true)
- , Doing(DoingNone)
- {
- }
- virtual ~cmFileCopier() {}
-
- bool Run(std::vector<std::string> const& args);
-
-protected:
- cmFileCommand* FileCommand;
- cmMakefile* Makefile;
- const char* Name;
- bool Always;
- cmFileTimeComparison FileTimes;
-
- // Whether to install a file not matching any expression.
- bool MatchlessFiles;
-
- // Permissions for files and directories installed by this object.
- mode_t FilePermissions;
- mode_t DirPermissions;
-
- // Properties set by pattern and regex match rules.
- struct MatchProperties
- {
- bool Exclude;
- mode_t Permissions;
- MatchProperties()
- : Exclude(false)
- , Permissions(0)
- {
- }
- };
- struct MatchRule
- {
- cmsys::RegularExpression Regex;
- MatchProperties Properties;
- std::string RegexString;
- MatchRule(std::string const& regex)
- : Regex(regex.c_str())
- , RegexString(regex)
- {
- }
- };
- std::vector<MatchRule> MatchRules;
-
- // Get the properties from rules matching this input file.
- MatchProperties CollectMatchProperties(const char* file)
- {
-// Match rules are case-insensitive on some platforms.
-#if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
- std::string lower = cmSystemTools::LowerCase(file);
- const char* file_to_match = lower.c_str();
-#else
- const char* file_to_match = file;
-#endif
-
- // Collect properties from all matching rules.
- bool matched = false;
- MatchProperties result;
- for (std::vector<MatchRule>::iterator mr = this->MatchRules.begin();
- mr != this->MatchRules.end(); ++mr) {
- if (mr->Regex.find(file_to_match)) {
- matched = true;
- result.Exclude |= mr->Properties.Exclude;
- result.Permissions |= mr->Properties.Permissions;
- }
- }
- if (!matched && !this->MatchlessFiles) {
- result.Exclude = !cmSystemTools::FileIsDirectory(file);
- }
- return result;
- }
-
- bool SetPermissions(const char* toFile, mode_t permissions)
- {
- if (permissions && !cmSystemTools::SetPermissions(toFile, permissions)) {
- std::ostringstream e;
- e << this->Name << " cannot set permissions on \"" << toFile << "\"";
- this->FileCommand->SetError(e.str());
- return false;
- }
- return true;
- }
-
- // Translate an argument to a permissions bit.
- bool CheckPermissions(std::string const& arg, mode_t& permissions)
- {
- if (arg == "OWNER_READ") {
- permissions |= mode_owner_read;
- } else if (arg == "OWNER_WRITE") {
- permissions |= mode_owner_write;
- } else if (arg == "OWNER_EXECUTE") {
- permissions |= mode_owner_execute;
- } else if (arg == "GROUP_READ") {
- permissions |= mode_group_read;
- } else if (arg == "GROUP_WRITE") {
- permissions |= mode_group_write;
- } else if (arg == "GROUP_EXECUTE") {
- permissions |= mode_group_execute;
- } else if (arg == "WORLD_READ") {
- permissions |= mode_world_read;
- } else if (arg == "WORLD_WRITE") {
- permissions |= mode_world_write;
- } else if (arg == "WORLD_EXECUTE") {
- permissions |= mode_world_execute;
- } else if (arg == "SETUID") {
- permissions |= mode_setuid;
- } else if (arg == "SETGID") {
- permissions |= mode_setgid;
- } else {
- std::ostringstream e;
- e << this->Name << " given invalid permission \"" << arg << "\".";
- this->FileCommand->SetError(e.str());
- return false;
- }
- return true;
- }
-
- bool InstallSymlink(const char* fromFile, const char* toFile);
- bool InstallFile(const char* fromFile, const char* toFile,
- MatchProperties match_properties);
- bool InstallDirectory(const char* source, const char* destination,
- MatchProperties match_properties);
- virtual bool Install(const char* fromFile, const char* toFile);
- virtual std::string const& ToName(std::string const& fromName)
- {
- return fromName;
- }
-
- enum Type
- {
- TypeFile,
- TypeDir,
- TypeLink
- };
- virtual void ReportCopy(const char*, Type, bool) {}
- virtual bool ReportMissing(const char* fromFile)
- {
- // The input file does not exist and installation is not optional.
- std::ostringstream e;
- e << this->Name << " cannot find \"" << fromFile << "\".";
- this->FileCommand->SetError(e.str());
- return false;
- }
-
- MatchRule* CurrentMatchRule;
- bool UseGivenPermissionsFile;
- bool UseGivenPermissionsDir;
- bool UseSourcePermissions;
- std::string Destination;
- std::string FilesFromDir;
- std::vector<std::string> Files;
- int Doing;
-
- virtual bool Parse(std::vector<std::string> const& args);
- enum
- {
- DoingNone,
- DoingError,
- DoingDestination,
- DoingFilesFromDir,
- DoingFiles,
- DoingPattern,
- DoingRegex,
- DoingPermissionsFile,
- DoingPermissionsDir,
- DoingPermissionsMatch,
- DoingLast1
- };
- virtual bool CheckKeyword(std::string const& arg);
- virtual bool CheckValue(std::string const& arg);
-
- void NotBeforeMatch(std::string const& arg)
- {
- std::ostringstream e;
- e << "option " << arg << " may not appear before PATTERN or REGEX.";
- this->FileCommand->SetError(e.str());
- this->Doing = DoingError;
- }
- void NotAfterMatch(std::string const& arg)
- {
- std::ostringstream e;
- e << "option " << arg << " may not appear after PATTERN or REGEX.";
- this->FileCommand->SetError(e.str());
- this->Doing = DoingError;
- }
- virtual void DefaultFilePermissions()
- {
- // Use read/write permissions.
- this->FilePermissions = 0;
- this->FilePermissions |= mode_owner_read;
- this->FilePermissions |= mode_owner_write;
- this->FilePermissions |= mode_group_read;
- this->FilePermissions |= mode_world_read;
- }
- virtual void DefaultDirectoryPermissions()
- {
- // Use read/write/executable permissions.
- this->DirPermissions = 0;
- this->DirPermissions |= mode_owner_read;
- this->DirPermissions |= mode_owner_write;
- this->DirPermissions |= mode_owner_execute;
- this->DirPermissions |= mode_group_read;
- this->DirPermissions |= mode_group_execute;
- this->DirPermissions |= mode_world_read;
- this->DirPermissions |= mode_world_execute;
- }
-};
-
-bool cmFileCopier::Parse(std::vector<std::string> const& args)
-{
- this->Doing = DoingFiles;
- for (unsigned int i = 1; i < args.size(); ++i) {
- // Check this argument.
- if (!this->CheckKeyword(args[i]) && !this->CheckValue(args[i])) {
- std::ostringstream e;
- e << "called with unknown argument \"" << args[i] << "\".";
- this->FileCommand->SetError(e.str());
- return false;
- }
-
- // Quit if an argument is invalid.
- if (this->Doing == DoingError) {
- return false;
- }
- }
-
- // Require a destination.
- if (this->Destination.empty()) {
- std::ostringstream e;
- e << this->Name << " given no DESTINATION";
- this->FileCommand->SetError(e.str());
- return false;
- }
-
- // If file permissions were not specified set default permissions.
- if (!this->UseGivenPermissionsFile && !this->UseSourcePermissions) {
- this->DefaultFilePermissions();
- }
-
- // If directory permissions were not specified set default permissions.
- if (!this->UseGivenPermissionsDir && !this->UseSourcePermissions) {
- this->DefaultDirectoryPermissions();
- }
-
- return true;
-}
-
-bool cmFileCopier::CheckKeyword(std::string const& arg)
-{
- if (arg == "DESTINATION") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingDestination;
- }
- } else if (arg == "FILES_FROM_DIR") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingFilesFromDir;
- }
- } else if (arg == "PATTERN") {
- this->Doing = DoingPattern;
- } else if (arg == "REGEX") {
- this->Doing = DoingRegex;
- } else if (arg == "EXCLUDE") {
- // Add this property to the current match rule.
- if (this->CurrentMatchRule) {
- this->CurrentMatchRule->Properties.Exclude = true;
- this->Doing = DoingNone;
- } else {
- this->NotBeforeMatch(arg);
- }
- } else if (arg == "PERMISSIONS") {
- if (this->CurrentMatchRule) {
- this->Doing = DoingPermissionsMatch;
- } else {
- this->NotBeforeMatch(arg);
- }
- } else if (arg == "FILE_PERMISSIONS") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingPermissionsFile;
- this->UseGivenPermissionsFile = true;
- }
- } else if (arg == "DIRECTORY_PERMISSIONS") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingPermissionsDir;
- this->UseGivenPermissionsDir = true;
- }
- } else if (arg == "USE_SOURCE_PERMISSIONS") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingNone;
- this->UseSourcePermissions = true;
- }
- } else if (arg == "NO_SOURCE_PERMISSIONS") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingNone;
- this->UseSourcePermissions = false;
- }
- } else if (arg == "FILES_MATCHING") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingNone;
- this->MatchlessFiles = false;
- }
- } else {
- return false;
- }
+ status.GetMakefile().AddDefinition(var, result);
return true;
}
-bool cmFileCopier::CheckValue(std::string const& arg)
+bool HandleCopyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- switch (this->Doing) {
- case DoingFiles:
- this->Files.push_back(arg);
- break;
- case DoingDestination:
- if (arg.empty() || cmSystemTools::FileIsFullPath(arg.c_str())) {
- this->Destination = arg;
- } else {
- this->Destination = this->Makefile->GetCurrentBinaryDirectory();
- this->Destination += "/" + arg;
- }
- this->Doing = DoingNone;
- break;
- case DoingFilesFromDir:
- if (cmSystemTools::FileIsFullPath(arg.c_str())) {
- this->FilesFromDir = arg;
- } else {
- this->FilesFromDir = this->Makefile->GetCurrentSourceDirectory();
- this->FilesFromDir += "/" + arg;
- }
- cmSystemTools::ConvertToUnixSlashes(this->FilesFromDir);
- this->Doing = DoingNone;
- break;
- case DoingPattern: {
- // Convert the pattern to a regular expression. Require a
- // leading slash and trailing end-of-string in the matched
- // string to make sure the pattern matches only whole file
- // names.
- std::string regex = "/";
- regex += cmsys::Glob::PatternToRegex(arg, false);
- regex += "$";
- this->MatchRules.push_back(MatchRule(regex));
- this->CurrentMatchRule = &*(this->MatchRules.end() - 1);
- if (this->CurrentMatchRule->Regex.is_valid()) {
- this->Doing = DoingNone;
- } else {
- std::ostringstream e;
- e << "could not compile PATTERN \"" << arg << "\".";
- this->FileCommand->SetError(e.str());
- this->Doing = DoingError;
- }
- } break;
- case DoingRegex:
- this->MatchRules.push_back(MatchRule(arg));
- this->CurrentMatchRule = &*(this->MatchRules.end() - 1);
- if (this->CurrentMatchRule->Regex.is_valid()) {
- this->Doing = DoingNone;
- } else {
- std::ostringstream e;
- e << "could not compile REGEX \"" << arg << "\".";
- this->FileCommand->SetError(e.str());
- this->Doing = DoingError;
- }
- break;
- case DoingPermissionsFile:
- if (!this->CheckPermissions(arg, this->FilePermissions)) {
- this->Doing = DoingError;
- }
- break;
- case DoingPermissionsDir:
- if (!this->CheckPermissions(arg, this->DirPermissions)) {
- this->Doing = DoingError;
- }
- break;
- case DoingPermissionsMatch:
- if (!this->CheckPermissions(
- arg, this->CurrentMatchRule->Properties.Permissions)) {
- this->Doing = DoingError;
- }
- break;
- default:
- return false;
- }
- return true;
-}
-
-bool cmFileCopier::Run(std::vector<std::string> const& args)
-{
- if (!this->Parse(args)) {
- return false;
- }
-
- for (std::vector<std::string>::const_iterator i = this->Files.begin();
- i != this->Files.end(); ++i) {
- std::string file;
- if (!i->empty() && !cmSystemTools::FileIsFullPath(*i)) {
- if (!this->FilesFromDir.empty()) {
- file = this->FilesFromDir;
- } else {
- file = this->Makefile->GetCurrentSourceDirectory();
- }
- file += "/";
- file += *i;
- } else if (!this->FilesFromDir.empty()) {
- this->FileCommand->SetError("option FILES_FROM_DIR requires all files "
- "to be specified as relative paths.");
- return false;
- } else {
- file = *i;
- }
-
- // Split the input file into its directory and name components.
- std::vector<std::string> fromPathComponents;
- cmSystemTools::SplitPath(file, fromPathComponents);
- std::string fromName = *(fromPathComponents.end() - 1);
- std::string fromDir = cmSystemTools::JoinPath(
- fromPathComponents.begin(), fromPathComponents.end() - 1);
-
- // Compute the full path to the destination file.
- std::string toFile = this->Destination;
- if (!this->FilesFromDir.empty()) {
- std::string dir = cmSystemTools::GetFilenamePath(*i);
- if (!dir.empty()) {
- toFile += "/";
- toFile += dir;
- }
- }
- std::string const& toName = this->ToName(fromName);
- if (!toName.empty()) {
- toFile += "/";
- toFile += toName;
- }
-
- // Construct the full path to the source file. The file name may
- // have been changed above.
- std::string fromFile = fromDir;
- if (!fromName.empty()) {
- fromFile += "/";
- fromFile += fromName;
- }
-
- if (!this->Install(fromFile.c_str(), toFile.c_str())) {
- return false;
- }
- }
- return true;
-}
-
-bool cmFileCopier::Install(const char* fromFile, const char* toFile)
-{
- if (!*fromFile) {
- std::ostringstream e;
- e << "INSTALL encountered an empty string input file name.";
- this->FileCommand->SetError(e.str());
- return false;
- }
-
- // Collect any properties matching this file name.
- MatchProperties match_properties = this->CollectMatchProperties(fromFile);
-
- // Skip the file if it is excluded.
- if (match_properties.Exclude) {
- return true;
- }
-
- if (cmSystemTools::SameFile(fromFile, toFile)) {
- return true;
- }
- if (cmSystemTools::FileIsSymlink(fromFile)) {
- return this->InstallSymlink(fromFile, toFile);
- }
- if (cmSystemTools::FileIsDirectory(fromFile)) {
- return this->InstallDirectory(fromFile, toFile, match_properties);
- }
- if (cmSystemTools::FileExists(fromFile)) {
- return this->InstallFile(fromFile, toFile, match_properties);
- }
- return this->ReportMissing(fromFile);
-}
-
-bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile)
-{
- // Read the original symlink.
- std::string symlinkTarget;
- if (!cmSystemTools::ReadSymlink(fromFile, symlinkTarget)) {
- std::ostringstream e;
- e << this->Name << " cannot read symlink \"" << fromFile
- << "\" to duplicate at \"" << toFile << "\".";
- this->FileCommand->SetError(e.str());
- return false;
- }
-
- // Compare the symlink value to that at the destination if not
- // always installing.
- bool copy = true;
- if (!this->Always) {
- std::string oldSymlinkTarget;
- if (cmSystemTools::ReadSymlink(toFile, oldSymlinkTarget)) {
- if (symlinkTarget == oldSymlinkTarget) {
- copy = false;
- }
- }
- }
-
- // Inform the user about this file installation.
- this->ReportCopy(toFile, TypeLink, copy);
-
- if (copy) {
- // Remove the destination file so we can always create the symlink.
- cmSystemTools::RemoveFile(toFile);
-
- // Create destination directory if it doesn't exist
- cmSystemTools::MakeDirectory(cmSystemTools::GetFilenamePath(toFile));
-
- // Create the symlink.
- if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) {
- std::ostringstream e;
- e << this->Name << " cannot duplicate symlink \"" << fromFile
- << "\" at \"" << toFile << "\".";
- this->FileCommand->SetError(e.str());
- return false;
- }
- }
-
- return true;
-}
-
-bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile,
- MatchProperties match_properties)
-{
- // Determine whether we will copy the file.
- bool copy = true;
- if (!this->Always) {
- // If both files exist with the same time do not copy.
- if (!this->FileTimes.FileTimesDiffer(fromFile, toFile)) {
- copy = false;
- }
- }
-
- // Inform the user about this file installation.
- this->ReportCopy(toFile, TypeFile, copy);
-
- // Copy the file.
- if (copy && !cmSystemTools::CopyAFile(fromFile, toFile, true)) {
- std::ostringstream e;
- e << this->Name << " cannot copy file \"" << fromFile << "\" to \""
- << toFile << "\".";
- this->FileCommand->SetError(e.str());
- return false;
- }
-
- // Set the file modification time of the destination file.
- if (copy && !this->Always) {
- // Add write permission so we can set the file time.
- // Permissions are set unconditionally below anyway.
- mode_t perm = 0;
- if (cmSystemTools::GetPermissions(toFile, perm)) {
- cmSystemTools::SetPermissions(toFile, perm | mode_owner_write);
- }
- if (!cmSystemTools::CopyFileTime(fromFile, toFile)) {
- std::ostringstream e;
- e << this->Name << " cannot set modification time on \"" << toFile
- << "\"";
- this->FileCommand->SetError(e.str());
- return false;
- }
- }
-
- // Set permissions of the destination file.
- mode_t permissions =
- (match_properties.Permissions ? match_properties.Permissions
- : this->FilePermissions);
- if (!permissions) {
- // No permissions were explicitly provided but the user requested
- // that the source file permissions be used.
- cmSystemTools::GetPermissions(fromFile, permissions);
- }
- return this->SetPermissions(toFile, permissions);
-}
-
-bool cmFileCopier::InstallDirectory(const char* source,
- const char* destination,
- MatchProperties match_properties)
-{
- // Inform the user about this directory installation.
- this->ReportCopy(destination, TypeDir,
- !cmSystemTools::FileIsDirectory(destination));
-
- // Make sure the destination directory exists.
- if (!cmSystemTools::MakeDirectory(destination)) {
- std::ostringstream e;
- e << this->Name << " cannot make directory \"" << destination
- << "\": " << cmSystemTools::GetLastSystemError();
- this->FileCommand->SetError(e.str());
- return false;
- }
-
- // Compute the requested permissions for the destination directory.
- mode_t permissions =
- (match_properties.Permissions ? match_properties.Permissions
- : this->DirPermissions);
- if (!permissions) {
- // No permissions were explicitly provided but the user requested
- // that the source directory permissions be used.
- cmSystemTools::GetPermissions(source, permissions);
- }
-
- // Compute the set of permissions required on this directory to
- // recursively install files and subdirectories safely.
- mode_t required_permissions =
- mode_owner_read | mode_owner_write | mode_owner_execute;
-
- // If the required permissions are specified it is safe to set the
- // final permissions now. Otherwise we must add the required
- // permissions temporarily during file installation.
- mode_t permissions_before = 0;
- mode_t permissions_after = 0;
- if ((permissions & required_permissions) == required_permissions) {
- permissions_before = permissions;
- } else {
- permissions_before = permissions | required_permissions;
- permissions_after = permissions;
- }
-
- // Set the required permissions of the destination directory.
- if (!this->SetPermissions(destination, permissions_before)) {
- return false;
- }
-
- // Load the directory contents to traverse it recursively.
- cmsys::Directory dir;
- if (source && *source) {
- dir.Load(source);
- }
- unsigned long numFiles = static_cast<unsigned long>(dir.GetNumberOfFiles());
- for (unsigned long fileNum = 0; fileNum < numFiles; ++fileNum) {
- if (!(strcmp(dir.GetFile(fileNum), ".") == 0 ||
- strcmp(dir.GetFile(fileNum), "..") == 0)) {
- std::string fromPath = source;
- fromPath += "/";
- fromPath += dir.GetFile(fileNum);
- std::string toPath = destination;
- toPath += "/";
- toPath += dir.GetFile(fileNum);
- if (!this->Install(fromPath.c_str(), toPath.c_str())) {
- return false;
- }
- }
- }
-
- // Set the requested permissions of the destination directory.
- return this->SetPermissions(destination, permissions_after);
-}
-
-bool cmFileCommand::HandleCopyCommand(std::vector<std::string> const& args)
-{
- cmFileCopier copier(this);
+ cmFileCopier copier(status);
return copier.Run(args);
}
-struct cmFileInstaller : public cmFileCopier
-{
- cmFileInstaller(cmFileCommand* command)
- : cmFileCopier(command, "INSTALL")
- , InstallType(cmInstallType_FILES)
- , Optional(false)
- , MessageAlways(false)
- , MessageLazy(false)
- , MessageNever(false)
- , DestDirLength(0)
- {
- // Installation does not use source permissions by default.
- this->UseSourcePermissions = false;
- // Check whether to copy files always or only if they have changed.
- std::string install_always;
- if (cmSystemTools::GetEnv("CMAKE_INSTALL_ALWAYS", install_always)) {
- this->Always = cmSystemTools::IsOn(install_always.c_str());
- }
- // Get the current manifest.
- this->Manifest =
- this->Makefile->GetSafeDefinition("CMAKE_INSTALL_MANIFEST_FILES");
- }
- ~cmFileInstaller() CM_OVERRIDE
- {
- // Save the updated install manifest.
- this->Makefile->AddDefinition("CMAKE_INSTALL_MANIFEST_FILES",
- this->Manifest.c_str());
- }
-
-protected:
- cmInstallType InstallType;
- bool Optional;
- bool MessageAlways;
- bool MessageLazy;
- bool MessageNever;
- int DestDirLength;
- std::string Rename;
-
- std::string Manifest;
- void ManifestAppend(std::string const& file)
- {
- if (!this->Manifest.empty()) {
- this->Manifest += ";";
- }
- this->Manifest += file.substr(this->DestDirLength);
- }
-
- std::string const& ToName(std::string const& fromName) CM_OVERRIDE
- {
- return this->Rename.empty() ? fromName : this->Rename;
- }
-
- void ReportCopy(const char* toFile, Type type, bool copy) CM_OVERRIDE
- {
- if (!this->MessageNever && (copy || !this->MessageLazy)) {
- std::string message = (copy ? "Installing: " : "Up-to-date: ");
- message += toFile;
- this->Makefile->DisplayStatus(message.c_str(), -1);
- }
- if (type != TypeDir) {
- // Add the file to the manifest.
- this->ManifestAppend(toFile);
- }
- }
- bool ReportMissing(const char* fromFile) CM_OVERRIDE
- {
- return (this->Optional || this->cmFileCopier::ReportMissing(fromFile));
- }
- bool Install(const char* fromFile, const char* toFile) CM_OVERRIDE
- {
- // Support installing from empty source to make a directory.
- if (this->InstallType == cmInstallType_DIRECTORY && !*fromFile) {
- return this->InstallDirectory(fromFile, toFile, MatchProperties());
- }
- return this->cmFileCopier::Install(fromFile, toFile);
- }
-
- bool Parse(std::vector<std::string> const& args) CM_OVERRIDE;
- enum
- {
- DoingType = DoingLast1,
- DoingRename,
- DoingLast2
- };
- bool CheckKeyword(std::string const& arg) CM_OVERRIDE;
- bool CheckValue(std::string const& arg) CM_OVERRIDE;
- void DefaultFilePermissions() CM_OVERRIDE
- {
- this->cmFileCopier::DefaultFilePermissions();
- // Add execute permissions based on the target type.
- switch (this->InstallType) {
- case cmInstallType_SHARED_LIBRARY:
- case cmInstallType_MODULE_LIBRARY:
- if (this->Makefile->IsOn("CMAKE_INSTALL_SO_NO_EXE")) {
- break;
- }
- CM_FALLTHROUGH;
- case cmInstallType_EXECUTABLE:
- case cmInstallType_PROGRAMS:
- this->FilePermissions |= mode_owner_execute;
- this->FilePermissions |= mode_group_execute;
- this->FilePermissions |= mode_world_execute;
- break;
- default:
- break;
- }
- }
- bool GetTargetTypeFromString(const std::string& stype);
- bool HandleInstallDestination();
-};
-
-bool cmFileInstaller::Parse(std::vector<std::string> const& args)
-{
- if (!this->cmFileCopier::Parse(args)) {
- return false;
- }
-
- if (!this->Rename.empty()) {
- if (!this->FilesFromDir.empty()) {
- this->FileCommand->SetError("INSTALL option RENAME may not be "
- "combined with FILES_FROM_DIR.");
- return false;
- }
- if (this->InstallType != cmInstallType_FILES &&
- this->InstallType != cmInstallType_PROGRAMS) {
- this->FileCommand->SetError("INSTALL option RENAME may be used "
- "only with FILES or PROGRAMS.");
- return false;
- }
- if (this->Files.size() > 1) {
- this->FileCommand->SetError("INSTALL option RENAME may be used "
- "only with one file.");
- return false;
- }
- }
-
- if (!this->HandleInstallDestination()) {
- return false;
- }
-
- if (((this->MessageAlways ? 1 : 0) + (this->MessageLazy ? 1 : 0) +
- (this->MessageNever ? 1 : 0)) > 1) {
- this->FileCommand->SetError("INSTALL options MESSAGE_ALWAYS, "
- "MESSAGE_LAZY, and MESSAGE_NEVER "
- "are mutually exclusive.");
- return false;
- }
-
- return true;
-}
-
-bool cmFileInstaller::CheckKeyword(std::string const& arg)
-{
- if (arg == "TYPE") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingType;
- }
- } else if (arg == "FILES") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingFiles;
- }
- } else if (arg == "RENAME") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingRename;
- }
- } else if (arg == "OPTIONAL") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingNone;
- this->Optional = true;
- }
- } else if (arg == "MESSAGE_ALWAYS") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingNone;
- this->MessageAlways = true;
- }
- } else if (arg == "MESSAGE_LAZY") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingNone;
- this->MessageLazy = true;
- }
- } else if (arg == "MESSAGE_NEVER") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- this->Doing = DoingNone;
- this->MessageNever = true;
- }
- } else if (arg == "PERMISSIONS") {
- if (this->CurrentMatchRule) {
- this->Doing = DoingPermissionsMatch;
- } else {
- // file(INSTALL) aliases PERMISSIONS to FILE_PERMISSIONS
- this->Doing = DoingPermissionsFile;
- this->UseGivenPermissionsFile = true;
- }
- } else if (arg == "DIR_PERMISSIONS") {
- if (this->CurrentMatchRule) {
- this->NotAfterMatch(arg);
- } else {
- // file(INSTALL) aliases DIR_PERMISSIONS to DIRECTORY_PERMISSIONS
- this->Doing = DoingPermissionsDir;
- this->UseGivenPermissionsDir = true;
- }
- } else if (arg == "COMPONENTS" || arg == "CONFIGURATIONS" ||
- arg == "PROPERTIES") {
- std::ostringstream e;
- e << "INSTALL called with old-style " << arg << " argument. "
- << "This script was generated with an older version of CMake. "
- << "Re-run this cmake version on your build tree.";
- this->FileCommand->SetError(e.str());
- this->Doing = DoingError;
- } else {
- return this->cmFileCopier::CheckKeyword(arg);
- }
- return true;
-}
-
-bool cmFileInstaller::CheckValue(std::string const& arg)
-{
- switch (this->Doing) {
- case DoingType:
- if (!this->GetTargetTypeFromString(arg)) {
- this->Doing = DoingError;
- }
- break;
- case DoingRename:
- this->Rename = arg;
- break;
- default:
- return this->cmFileCopier::CheckValue(arg);
- }
- return true;
-}
-
-bool cmFileInstaller::GetTargetTypeFromString(const std::string& stype)
-{
- if (stype == "EXECUTABLE") {
- this->InstallType = cmInstallType_EXECUTABLE;
- } else if (stype == "FILE") {
- this->InstallType = cmInstallType_FILES;
- } else if (stype == "PROGRAM") {
- this->InstallType = cmInstallType_PROGRAMS;
- } else if (stype == "STATIC_LIBRARY") {
- this->InstallType = cmInstallType_STATIC_LIBRARY;
- } else if (stype == "SHARED_LIBRARY") {
- this->InstallType = cmInstallType_SHARED_LIBRARY;
- } else if (stype == "MODULE") {
- this->InstallType = cmInstallType_MODULE_LIBRARY;
- } else if (stype == "DIRECTORY") {
- this->InstallType = cmInstallType_DIRECTORY;
- } else {
- std::ostringstream e;
- e << "Option TYPE given unknown value \"" << stype << "\".";
- this->FileCommand->SetError(e.str());
- return false;
- }
- return true;
-}
-
-bool cmFileInstaller::HandleInstallDestination()
-{
- std::string& destination = this->Destination;
-
- // allow for / to be a valid destination
- if (destination.size() < 2 && destination != "/") {
- this->FileCommand->SetError("called with inappropriate arguments. "
- "No DESTINATION provided or .");
- return false;
- }
-
- std::string sdestdir;
- if (cmSystemTools::GetEnv("DESTDIR", sdestdir) && !sdestdir.empty()) {
- cmSystemTools::ConvertToUnixSlashes(sdestdir);
- char ch1 = destination[0];
- char ch2 = destination[1];
- char ch3 = 0;
- if (destination.size() > 2) {
- ch3 = destination[2];
- }
- int skip = 0;
- if (ch1 != '/') {
- int relative = 0;
- if (((ch1 >= 'a' && ch1 <= 'z') || (ch1 >= 'A' && ch1 <= 'Z')) &&
- ch2 == ':') {
- // Assume windows
- // let's do some destdir magic:
- skip = 2;
- if (ch3 != '/') {
- relative = 1;
- }
- } else {
- relative = 1;
- }
- if (relative) {
- // This is relative path on unix or windows. Since we are doing
- // destdir, this case does not make sense.
- this->FileCommand->SetError(
- "called with relative DESTINATION. This "
- "does not make sense when using DESTDIR. Specify "
- "absolute path or remove DESTDIR environment variable.");
- return false;
- }
- } else {
- if (ch2 == '/') {
- // looks like a network path.
- std::string message =
- "called with network path DESTINATION. This "
- "does not make sense when using DESTDIR. Specify local "
- "absolute path or remove DESTDIR environment variable."
- "\nDESTINATION=\n";
- message += destination;
- this->FileCommand->SetError(message);
- return false;
- }
- }
- destination = sdestdir + (destination.c_str() + skip);
- this->DestDirLength = int(sdestdir.size());
- }
-
- if (this->InstallType != cmInstallType_DIRECTORY) {
- if (!cmSystemTools::FileExists(destination.c_str())) {
- if (!cmSystemTools::MakeDirectory(destination.c_str())) {
- std::string errstring = "cannot create directory: " + destination +
- ". Maybe need administrative privileges.";
- this->FileCommand->SetError(errstring);
- return false;
- }
- }
- if (!cmSystemTools::FileIsDirectory(destination)) {
- std::string errstring =
- "INSTALL destination: " + destination + " is not a directory.";
- this->FileCommand->SetError(errstring);
- return false;
- }
- }
- return true;
-}
-
-bool cmFileCommand::HandleRPathChangeCommand(
- std::vector<std::string> const& args)
+bool HandleRPathChangeCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// Evaluate arguments.
- const char* file = CM_NULLPTR;
- const char* oldRPath = CM_NULLPTR;
- const char* newRPath = CM_NULLPTR;
+ std::string file;
+ const char* oldRPath = nullptr;
+ const char* newRPath = nullptr;
+ bool removeEnvironmentRPath = false;
enum Doing
{
DoingNone,
@@ -2046,8 +995,10 @@ bool cmFileCommand::HandleRPathChangeCommand(
doing = DoingNew;
} else if (args[i] == "FILE") {
doing = DoingFile;
+ } else if (args[i] == "INSTALL_REMOVE_ENVIRONMENT_RPATH") {
+ removeEnvironmentRPath = true;
} else if (doing == DoingFile) {
- file = args[i].c_str();
+ file = args[i];
doing = DoingNone;
} else if (doing == DoingOld) {
oldRPath = args[i].c_str();
@@ -2056,69 +1007,56 @@ bool cmFileCommand::HandleRPathChangeCommand(
newRPath = args[i].c_str();
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "RPATH_CHANGE given unknown argument " << args[i];
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_CHANGE given unknown argument ", args[i]));
return false;
}
}
- if (!file) {
- this->SetError("RPATH_CHANGE not given FILE option.");
+ if (file.empty()) {
+ status.SetError("RPATH_CHANGE not given FILE option.");
return false;
}
if (!oldRPath) {
- this->SetError("RPATH_CHANGE not given OLD_RPATH option.");
+ status.SetError("RPATH_CHANGE not given OLD_RPATH option.");
return false;
}
if (!newRPath) {
- this->SetError("RPATH_CHANGE not given NEW_RPATH option.");
+ status.SetError("RPATH_CHANGE not given NEW_RPATH option.");
return false;
}
if (!cmSystemTools::FileExists(file, true)) {
- std::ostringstream e;
- e << "RPATH_CHANGE given FILE \"" << file << "\" that does not exist.";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_CHANGE given FILE \"", file, "\" that does not exist."));
return false;
}
bool success = true;
- cmSystemToolsFileTime* ft = cmSystemTools::FileTimeNew();
- bool have_ft = cmSystemTools::FileTimeGet(file, ft);
+ cmFileTimes const ft(file);
std::string emsg;
bool changed;
- if (!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, &emsg, &changed)) {
- std::ostringstream e;
- /* clang-format off */
- e << "RPATH_CHANGE could not write new RPATH:\n"
- << " " << newRPath << "\n"
- << "to the file:\n"
- << " " << file << "\n"
- << emsg;
- /* clang-format on */
- this->SetError(e.str());
+
+ if (!cmSystemTools::ChangeRPath(file, oldRPath, newRPath,
+ removeEnvironmentRPath, &emsg, &changed)) {
+ status.SetError(cmStrCat("RPATH_CHANGE could not write new RPATH:\n ",
+ newRPath, "\nto the file:\n ", file, "\n",
+ emsg));
success = false;
}
if (success) {
if (changed) {
- std::string message = "Set runtime path of \"";
- message += file;
- message += "\" to \"";
- message += newRPath;
- message += "\"";
- this->Makefile->DisplayStatus(message.c_str(), -1);
- }
- if (have_ft) {
- cmSystemTools::FileTimeSet(file, ft);
+ std::string message =
+ cmStrCat("Set runtime path of \"", file, "\" to \"", newRPath, '"');
+ status.GetMakefile().DisplayStatus(message, -1);
}
+ ft.Store(file);
}
- cmSystemTools::FileTimeDelete(ft);
return success;
}
-bool cmFileCommand::HandleRPathRemoveCommand(
- std::vector<std::string> const& args)
+bool HandleRPathRemoveCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// Evaluate arguments.
- const char* file = CM_NULLPTR;
+ std::string file;
enum Doing
{
DoingNone,
@@ -2129,61 +1067,50 @@ bool cmFileCommand::HandleRPathRemoveCommand(
if (args[i] == "FILE") {
doing = DoingFile;
} else if (doing == DoingFile) {
- file = args[i].c_str();
+ file = args[i];
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "RPATH_REMOVE given unknown argument " << args[i];
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_REMOVE given unknown argument ", args[i]));
return false;
}
}
- if (!file) {
- this->SetError("RPATH_REMOVE not given FILE option.");
+ if (file.empty()) {
+ status.SetError("RPATH_REMOVE not given FILE option.");
return false;
}
if (!cmSystemTools::FileExists(file, true)) {
- std::ostringstream e;
- e << "RPATH_REMOVE given FILE \"" << file << "\" that does not exist.";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_REMOVE given FILE \"", file, "\" that does not exist."));
return false;
}
bool success = true;
- cmSystemToolsFileTime* ft = cmSystemTools::FileTimeNew();
- bool have_ft = cmSystemTools::FileTimeGet(file, ft);
+ cmFileTimes const ft(file);
std::string emsg;
bool removed;
if (!cmSystemTools::RemoveRPath(file, &emsg, &removed)) {
- std::ostringstream e;
- /* clang-format off */
- e << "RPATH_REMOVE could not remove RPATH from file:\n"
- << " " << file << "\n"
- << emsg;
- /* clang-format on */
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_REMOVE could not remove RPATH from file: \n ", file,
+ "\n", emsg));
success = false;
}
if (success) {
if (removed) {
- std::string message = "Removed runtime path from \"";
- message += file;
- message += "\"";
- this->Makefile->DisplayStatus(message.c_str(), -1);
- }
- if (have_ft) {
- cmSystemTools::FileTimeSet(file, ft);
+ std::string message =
+ cmStrCat("Removed runtime path from \"", file, '"');
+ status.GetMakefile().DisplayStatus(message, -1);
}
+ ft.Store(file);
}
- cmSystemTools::FileTimeDelete(ft);
return success;
}
-bool cmFileCommand::HandleRPathCheckCommand(
- std::vector<std::string> const& args)
+bool HandleRPathCheckCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// Evaluate arguments.
- const char* file = CM_NULLPTR;
- const char* rpath = CM_NULLPTR;
+ std::string file;
+ const char* rpath = nullptr;
enum Doing
{
DoingNone,
@@ -2197,24 +1124,23 @@ bool cmFileCommand::HandleRPathCheckCommand(
} else if (args[i] == "FILE") {
doing = DoingFile;
} else if (doing == DoingFile) {
- file = args[i].c_str();
+ file = args[i];
doing = DoingNone;
} else if (doing == DoingRPath) {
rpath = args[i].c_str();
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "RPATH_CHECK given unknown argument " << args[i];
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_CHECK given unknown argument ", args[i]));
return false;
}
}
- if (!file) {
- this->SetError("RPATH_CHECK not given FILE option.");
+ if (file.empty()) {
+ status.SetError("RPATH_CHECK not given FILE option.");
return false;
}
if (!rpath) {
- this->SetError("RPATH_CHECK not given RPATH option.");
+ status.SetError("RPATH_CHECK not given RPATH option.");
return false;
}
@@ -2229,79 +1155,78 @@ bool cmFileCommand::HandleRPathCheckCommand(
return true;
}
-bool cmFileCommand::HandleReadElfCommand(std::vector<std::string> const& args)
+bool HandleReadElfCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 4) {
- this->SetError("READ_ELF must be called with at least three additional "
- "arguments.");
+ status.SetError("READ_ELF must be called with at least three additional "
+ "arguments.");
return false;
}
- cmCommandArgumentsHelper argHelper;
- cmCommandArgumentGroup group;
-
- cmCAString readArg(&argHelper, "READ_ELF");
- cmCAString fileNameArg(&argHelper, CM_NULLPTR);
+ std::string const& fileNameArg = args[1];
- cmCAString rpathArg(&argHelper, "RPATH", &group);
- cmCAString runpathArg(&argHelper, "RUNPATH", &group);
- cmCAString errorArg(&argHelper, "CAPTURE_ERROR", &group);
+ struct Arguments
+ {
+ std::string RPath;
+ std::string RunPath;
+ std::string Error;
+ };
- readArg.Follows(CM_NULLPTR);
- fileNameArg.Follows(&readArg);
- group.Follows(&fileNameArg);
- argHelper.Parse(&args, CM_NULLPTR);
+ static auto const parser = cmArgumentParser<Arguments>{}
+ .Bind("RPATH"_s, &Arguments::RPath)
+ .Bind("RUNPATH"_s, &Arguments::RunPath)
+ .Bind("CAPTURE_ERROR"_s, &Arguments::Error);
+ Arguments const arguments = parser.Parse(cmMakeRange(args).advance(2));
- if (!cmSystemTools::FileExists(fileNameArg.GetString(), true)) {
- std::ostringstream e;
- e << "READ_ELF given FILE \"" << fileNameArg.GetString()
- << "\" that does not exist.";
- this->SetError(e.str());
+ if (!cmSystemTools::FileExists(fileNameArg, true)) {
+ status.SetError(cmStrCat("READ_ELF given FILE \"", fileNameArg,
+ "\" that does not exist."));
return false;
}
#if defined(CMAKE_USE_ELF_PARSER)
- cmELF elf(fileNameArg.GetCString());
+ cmELF elf(fileNameArg.c_str());
- if (!rpathArg.GetString().empty()) {
+ if (!arguments.RPath.empty()) {
if (cmELF::StringEntry const* se_rpath = elf.GetRPath()) {
std::string rpath(se_rpath->Value);
std::replace(rpath.begin(), rpath.end(), ':', ';');
- this->Makefile->AddDefinition(rpathArg.GetString(), rpath.c_str());
+ status.GetMakefile().AddDefinition(arguments.RPath, rpath);
}
}
- if (!runpathArg.GetString().empty()) {
+ if (!arguments.RunPath.empty()) {
if (cmELF::StringEntry const* se_runpath = elf.GetRunPath()) {
std::string runpath(se_runpath->Value);
std::replace(runpath.begin(), runpath.end(), ':', ';');
- this->Makefile->AddDefinition(runpathArg.GetString(), runpath.c_str());
+ status.GetMakefile().AddDefinition(arguments.RunPath, runpath);
}
}
return true;
#else
std::string error = "ELF parser not available on this platform.";
- if (errorArg.GetString().empty()) {
- this->SetError(error);
+ if (arguments.Error.empty()) {
+ status.SetError(error);
return false;
- } else {
- this->Makefile->AddDefinition(errorArg.GetString(), error.c_str());
- return true;
}
+ status.GetMakefile().AddDefinition(arguments.Error, error);
+ return true;
#endif
}
-bool cmFileCommand::HandleInstallCommand(std::vector<std::string> const& args)
+bool HandleInstallCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- cmFileInstaller installer(this);
+ cmFileInstaller installer(status);
return installer.Run(args);
}
-bool cmFileCommand::HandleRelativePathCommand(
- std::vector<std::string> const& args)
+bool HandleRelativePathCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 4) {
- this->SetError("RELATIVE_PATH called with incorrect number of arguments");
+ status.SetError("RELATIVE_PATH called with incorrect number of arguments");
return false;
}
@@ -2309,79 +1234,78 @@ bool cmFileCommand::HandleRelativePathCommand(
const std::string& directoryName = args[2];
const std::string& fileName = args[3];
- if (!cmSystemTools::FileIsFullPath(directoryName.c_str())) {
+ if (!cmSystemTools::FileIsFullPath(directoryName)) {
std::string errstring =
"RELATIVE_PATH must be passed a full path to the directory: " +
directoryName;
- this->SetError(errstring);
+ status.SetError(errstring);
return false;
}
- if (!cmSystemTools::FileIsFullPath(fileName.c_str())) {
+ if (!cmSystemTools::FileIsFullPath(fileName)) {
std::string errstring =
"RELATIVE_PATH must be passed a full path to the file: " + fileName;
- this->SetError(errstring);
+ status.SetError(errstring);
return false;
}
- std::string res =
- cmSystemTools::RelativePath(directoryName.c_str(), fileName.c_str());
- this->Makefile->AddDefinition(outVar, res.c_str());
+ std::string res = cmSystemTools::RelativePath(directoryName, fileName);
+ status.GetMakefile().AddDefinition(outVar, res);
return true;
}
-bool cmFileCommand::HandleRename(std::vector<std::string> const& args)
+bool HandleRename(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
- this->SetError("RENAME given incorrect number of arguments.");
+ status.SetError("RENAME given incorrect number of arguments.");
return false;
}
// Compute full path for old and new names.
std::string oldname = args[1];
- if (!cmsys::SystemTools::FileIsFullPath(oldname.c_str())) {
- oldname = this->Makefile->GetCurrentSourceDirectory();
- oldname += "/" + args[1];
+ if (!cmsys::SystemTools::FileIsFullPath(oldname)) {
+ oldname =
+ cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', args[1]);
}
std::string newname = args[2];
- if (!cmsys::SystemTools::FileIsFullPath(newname.c_str())) {
- newname = this->Makefile->GetCurrentSourceDirectory();
- newname += "/" + args[2];
+ if (!cmsys::SystemTools::FileIsFullPath(newname)) {
+ newname =
+ cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', args[2]);
}
- if (!cmSystemTools::RenameFile(oldname.c_str(), newname.c_str())) {
+ if (!cmSystemTools::RenameFile(oldname, newname)) {
std::string err = cmSystemTools::GetLastSystemError();
- std::ostringstream e;
- /* clang-format off */
- e << "RENAME failed to rename\n"
- << " " << oldname << "\n"
- << "to\n"
- << " " << newname << "\n"
- << "because: " << err << "\n";
- /* clang-format on */
- this->SetError(e.str());
+ status.SetError(cmStrCat("RENAME failed to rename\n ", oldname,
+ "\nto\n ", newname, "\nbecause: ", err, "\n"));
return false;
}
return true;
}
-bool cmFileCommand::HandleRemove(std::vector<std::string> const& args,
- bool recurse)
+bool HandleRemoveImpl(std::vector<std::string> const& args, bool recurse,
+ cmExecutionStatus& status)
{
std::string message;
- std::vector<std::string>::const_iterator i = args.begin();
- i++; // Get rid of subcommand
- for (; i != args.end(); ++i) {
- std::string fileName = *i;
- if (!cmsys::SystemTools::FileIsFullPath(fileName.c_str())) {
- fileName = this->Makefile->GetCurrentSourceDirectory();
- fileName += "/" + *i;
+ for (std::string const& arg :
+ cmMakeRange(args).advance(1)) // Get rid of subcommand
+ {
+ std::string fileName = arg;
+ if (fileName.empty()) {
+ std::string const r = recurse ? "REMOVE_RECURSE" : "REMOVE";
+ status.GetMakefile().IssueMessage(
+ MessageType::AUTHOR_WARNING, "Ignoring empty file name in " + r + ".");
+ continue;
+ }
+ if (!cmsys::SystemTools::FileIsFullPath(fileName)) {
+ fileName =
+ cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', arg);
}
if (cmSystemTools::FileIsDirectory(fileName) &&
!cmSystemTools::FileIsSymlink(fileName) && recurse) {
- cmSystemTools::RemoveADirectory(fileName);
+ cmSystemTools::RepeatedRemoveDirectory(fileName);
} else {
cmSystemTools::RemoveFile(fileName);
}
@@ -2389,57 +1313,76 @@ bool cmFileCommand::HandleRemove(std::vector<std::string> const& args,
return true;
}
-bool cmFileCommand::HandleCMakePathCommand(
- std::vector<std::string> const& args, bool nativePath)
+bool HandleRemove(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleRemoveImpl(args, false, status);
+}
+
+bool HandleRemoveRecurse(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleRemoveImpl(args, true, status);
+}
+
+std::string ToNativePath(const std::string& path)
+{
+ const auto& outPath = cmSystemTools::ConvertToOutputPath(path);
+ if (outPath.size() > 1 && outPath.front() == '\"' &&
+ outPath.back() == '\"') {
+ return outPath.substr(1, outPath.size() - 2);
+ }
+ return outPath;
+}
+
+std::string ToCMakePath(const std::string& path)
+{
+ auto temp = path;
+ cmSystemTools::ConvertToUnixSlashes(temp);
+ return temp;
+}
+
+bool HandlePathCommand(std::vector<std::string> const& args,
+ std::string (*convert)(std::string const&),
+ cmExecutionStatus& status)
{
- std::vector<std::string>::const_iterator i = args.begin();
if (args.size() != 3) {
- this->SetError("FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be "
- "called with exactly three arguments.");
+ status.SetError("FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be "
+ "called with exactly three arguments.");
return false;
}
- i++; // Get rid of subcommand
#if defined(_WIN32) && !defined(__CYGWIN__)
char pathSep = ';';
#else
char pathSep = ':';
#endif
- std::vector<cmsys::String> path = cmSystemTools::SplitString(*i, pathSep);
- i++;
- const char* var = i->c_str();
- std::string value;
- for (std::vector<cmsys::String>::iterator j = path.begin(); j != path.end();
- ++j) {
- if (j != path.begin()) {
- value += ";";
- }
- if (!nativePath) {
- cmSystemTools::ConvertToUnixSlashes(*j);
- } else {
- *j = cmSystemTools::ConvertToOutputPath(j->c_str());
- // remove double quotes in the path
- cmsys::String& s = *j;
+ std::vector<std::string> path = cmSystemTools::SplitString(args[1], pathSep);
- if (s.size() > 1 && s[0] == '\"' && s[s.size() - 1] == '\"') {
- s = s.substr(1, s.size() - 2);
- }
- }
- value += *j;
- }
- this->Makefile->AddDefinition(var, value.c_str());
+ std::string value = cmJoin(cmMakeRange(path).transform(convert), ";");
+ status.GetMakefile().AddDefinition(args[2], value);
return true;
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+bool HandleCMakePathCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandlePathCommand(args, ToCMakePath, status);
+}
-// Stuff for curl download/upload
-typedef std::vector<char> cmFileCommandVectorOfChar;
+bool HandleNativePathCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandlePathCommand(args, ToNativePath, status);
+}
-namespace {
+#if !defined(CMAKE_BOOTSTRAP)
+
+// Stuff for curl download/upload
+using cmFileCommandVectorOfChar = std::vector<char>;
size_t cmWriteToFileCallback(void* ptr, size_t size, size_t nmemb, void* data)
{
- int realsize = (int)(size * nmemb);
+ int realsize = static_cast<int>(size * nmemb);
cmsys::ofstream* fout = static_cast<cmsys::ofstream*>(data);
const char* chPtr = static_cast<char*>(ptr);
fout->write(chPtr, realsize);
@@ -2449,24 +1392,23 @@ size_t cmWriteToFileCallback(void* ptr, size_t size, size_t nmemb, void* data)
size_t cmWriteToMemoryCallback(void* ptr, size_t size, size_t nmemb,
void* data)
{
- int realsize = (int)(size * nmemb);
- cmFileCommandVectorOfChar* vec =
- static_cast<cmFileCommandVectorOfChar*>(data);
+ int realsize = static_cast<int>(size * nmemb);
const char* chPtr = static_cast<char*>(ptr);
- vec->insert(vec->end(), chPtr, chPtr + realsize);
+ cmAppend(*static_cast<cmFileCommandVectorOfChar*>(data), chPtr,
+ chPtr + realsize);
return realsize;
}
size_t cmFileCommandCurlDebugCallback(CURL*, curl_infotype type, char* chPtr,
size_t size, void* data)
{
- cmFileCommandVectorOfChar* vec =
- static_cast<cmFileCommandVectorOfChar*>(data);
+ cmFileCommandVectorOfChar& vec =
+ *static_cast<cmFileCommandVectorOfChar*>(data);
switch (type) {
case CURLINFO_TEXT:
case CURLINFO_HEADER_IN:
case CURLINFO_HEADER_OUT:
- vec->insert(vec->end(), chPtr, chPtr + size);
+ cmAppend(vec, chPtr, chPtr + size);
break;
case CURLINFO_DATA_IN:
case CURLINFO_DATA_OUT:
@@ -2476,7 +1418,7 @@ size_t cmFileCommandCurlDebugCallback(CURL*, curl_infotype type, char* chPtr,
int n = sprintf(buf, "[%" KWIML_INT_PRIu64 " bytes data]\n",
static_cast<KWIML_INT_uint64_t>(size));
if (n > 0) {
- vec->insert(vec->end(), buf, buf + n);
+ cmAppend(vec, buf, buf + n);
}
} break;
default:
@@ -2488,19 +1430,18 @@ size_t cmFileCommandCurlDebugCallback(CURL*, curl_infotype type, char* chPtr,
class cURLProgressHelper
{
public:
- cURLProgressHelper(cmFileCommand* fc, const char* text)
+ cURLProgressHelper(cmMakefile* mf, const char* text)
+ : Makefile(mf)
+ , Text(text)
{
- this->CurrentPercentage = -1;
- this->FileCommand = fc;
- this->Text = text;
}
bool UpdatePercentage(double value, double total, std::string& status)
{
- int OldPercentage = this->CurrentPercentage;
+ long OldPercentage = this->CurrentPercentage;
if (total > 0.0) {
- this->CurrentPercentage = static_cast<int>(value / total * 100.0 + 0.5);
+ this->CurrentPercentage = std::lround(value / total * 100.0);
if (this->CurrentPercentage > 100) {
// Avoid extra progress reports for unexpected data beyond total.
this->CurrentPercentage = 100;
@@ -2510,20 +1451,18 @@ public:
bool updated = (OldPercentage != this->CurrentPercentage);
if (updated) {
- std::ostringstream oss;
- oss << "[" << this->Text << " " << this->CurrentPercentage
- << "% complete]";
- status = oss.str();
+ status =
+ cmStrCat("[", this->Text, " ", this->CurrentPercentage, "% complete]");
}
return updated;
}
- cmFileCommand* GetFileCommand() { return this->FileCommand; }
+ cmMakefile* GetMakefile() { return this->Makefile; }
private:
- int CurrentPercentage;
- cmFileCommand* FileCommand;
+ long CurrentPercentage = -1;
+ cmMakefile* Makefile;
std::string Text;
};
@@ -2537,9 +1476,8 @@ int cmFileDownloadProgressCallback(void* clientp, double dltotal, double dlnow,
std::string status;
if (helper->UpdatePercentage(dlnow, dltotal, status)) {
- cmFileCommand* fc = helper->GetFileCommand();
- cmMakefile* mf = fc->GetMakefile();
- mf->DisplayStatus(status.c_str(), -1);
+ cmMakefile* mf = helper->GetMakefile();
+ mf->DisplayStatus(status, -1);
}
return 0;
@@ -2555,16 +1493,12 @@ int cmFileUploadProgressCallback(void* clientp, double dltotal, double dlnow,
std::string status;
if (helper->UpdatePercentage(ulnow, ultotal, status)) {
- cmFileCommand* fc = helper->GetFileCommand();
- cmMakefile* mf = fc->GetMakefile();
- mf->DisplayStatus(status.c_str(), -1);
+ cmMakefile* mf = helper->GetMakefile();
+ mf->DisplayStatus(status, -1);
}
return 0;
}
-}
-
-namespace {
class cURLEasyGuard
{
@@ -2581,28 +1515,34 @@ public:
}
}
- void release() { this->Easy = CM_NULLPTR; }
+ cURLEasyGuard(const cURLEasyGuard&) = delete;
+ cURLEasyGuard& operator=(const cURLEasyGuard&) = delete;
+
+ void release() { this->Easy = nullptr; }
private:
::CURL* Easy;
};
-}
+
#endif
#define check_curl_result(result, errstr) \
- if (result != CURLE_OK) { \
- std::string e(errstr); \
- e += ::curl_easy_strerror(result); \
- this->SetError(e); \
- return false; \
- }
-
-bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
+ do { \
+ if (result != CURLE_OK) { \
+ std::string e(errstr); \
+ e += ::curl_easy_strerror(result); \
+ status.SetError(e); \
+ return false; \
+ } \
+ } while (false)
+
+bool HandleDownloadCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
- std::vector<std::string>::const_iterator i = args.begin();
+#if !defined(CMAKE_BOOTSTRAP)
+ auto i = args.begin();
if (args.size() < 3) {
- this->SetError("DOWNLOAD must be called with at least three arguments.");
+ status.SetError("DOWNLOAD must be called with at least three arguments.");
return false;
}
++i; // Get rid of subcommand
@@ -2615,11 +1555,15 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
long inactivity_timeout = 0;
std::string logVar;
std::string statusVar;
- bool tls_verify = this->Makefile->IsOn("CMAKE_TLS_VERIFY");
- const char* cainfo = this->Makefile->GetDefinition("CMAKE_TLS_CAINFO");
+ bool tls_verify = status.GetMakefile().IsOn("CMAKE_TLS_VERIFY");
+ const char* cainfo = status.GetMakefile().GetDefinition("CMAKE_TLS_CAINFO");
+ std::string netrc_level =
+ status.GetMakefile().GetSafeDefinition("CMAKE_NETRC");
+ std::string netrc_file =
+ status.GetMakefile().GetSafeDefinition("CMAKE_NETRC_FILE");
std::string expectedHash;
std::string hashMatchMSG;
- CM_AUTO_PTR<cmCryptoHash> hash;
+ std::unique_ptr<cmCryptoHash> hash;
bool showProgress = false;
std::string userpwd;
@@ -2631,7 +1575,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
timeout = atol(i->c_str());
} else {
- this->SetError("DOWNLOAD missing time for TIMEOUT.");
+ status.SetError("DOWNLOAD missing time for TIMEOUT.");
return false;
}
} else if (*i == "INACTIVITY_TIMEOUT") {
@@ -2639,29 +1583,29 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
inactivity_timeout = atol(i->c_str());
} else {
- this->SetError("DOWNLOAD missing time for INACTIVITY_TIMEOUT.");
+ status.SetError("DOWNLOAD missing time for INACTIVITY_TIMEOUT.");
return false;
}
} else if (*i == "LOG") {
++i;
if (i == args.end()) {
- this->SetError("DOWNLOAD missing VAR for LOG.");
+ status.SetError("DOWNLOAD missing VAR for LOG.");
return false;
}
logVar = *i;
} else if (*i == "STATUS") {
++i;
if (i == args.end()) {
- this->SetError("DOWNLOAD missing VAR for STATUS.");
+ status.SetError("DOWNLOAD missing VAR for STATUS.");
return false;
}
statusVar = *i;
} else if (*i == "TLS_VERIFY") {
++i;
if (i != args.end()) {
- tls_verify = cmSystemTools::IsOn(i->c_str());
+ tls_verify = cmIsOn(*i);
} else {
- this->SetError("TLS_VERIFY missing bool value.");
+ status.SetError("TLS_VERIFY missing bool value.");
return false;
}
} else if (*i == "TLS_CAINFO") {
@@ -2669,17 +1613,32 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
cainfo = i->c_str();
} else {
- this->SetError("TLS_CAFILE missing file value.");
+ status.SetError("TLS_CAFILE missing file value.");
+ return false;
+ }
+ } else if (*i == "NETRC_FILE") {
+ ++i;
+ if (i != args.end()) {
+ netrc_file = *i;
+ } else {
+ status.SetError("DOWNLOAD missing file value for NETRC_FILE.");
+ return false;
+ }
+ } else if (*i == "NETRC") {
+ ++i;
+ if (i != args.end()) {
+ netrc_level = *i;
+ } else {
+ status.SetError("DOWNLOAD missing level value for NETRC.");
return false;
}
} else if (*i == "EXPECTED_MD5") {
++i;
if (i == args.end()) {
- this->SetError("DOWNLOAD missing sum value for EXPECTED_MD5.");
+ status.SetError("DOWNLOAD missing sum value for EXPECTED_MD5.");
return false;
}
- hash =
- CM_AUTO_PTR<cmCryptoHash>(new cmCryptoHash(cmCryptoHash::AlgoMD5));
+ hash = cm::make_unique<cmCryptoHash>(cmCryptoHash::AlgoMD5);
hashMatchMSG = "MD5 sum";
expectedHash = cmSystemTools::LowerCase(*i);
} else if (*i == "SHOW_PROGRESS") {
@@ -2687,46 +1646,44 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
} else if (*i == "EXPECTED_HASH") {
++i;
if (i == args.end()) {
- this->SetError("DOWNLOAD missing ALGO=value for EXPECTED_HASH.");
+ status.SetError("DOWNLOAD missing ALGO=value for EXPECTED_HASH.");
return false;
}
std::string::size_type pos = i->find("=");
if (pos == std::string::npos) {
std::string err =
- "DOWNLOAD EXPECTED_HASH expects ALGO=value but got: ";
- err += *i;
- this->SetError(err);
+ cmStrCat("DOWNLOAD EXPECTED_HASH expects ALGO=value but got: ", *i);
+ status.SetError(err);
return false;
}
std::string algo = i->substr(0, pos);
expectedHash = cmSystemTools::LowerCase(i->substr(pos + 1));
- hash = CM_AUTO_PTR<cmCryptoHash>(cmCryptoHash::New(algo.c_str()));
- if (!hash.get()) {
- std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: ";
- err += algo;
- this->SetError(err);
+ hash = std::unique_ptr<cmCryptoHash>(cmCryptoHash::New(algo));
+ if (!hash) {
+ std::string err =
+ cmStrCat("DOWNLOAD EXPECTED_HASH given unknown ALGO: ", algo);
+ status.SetError(err);
return false;
}
hashMatchMSG = algo + " hash";
} else if (*i == "USERPWD") {
++i;
if (i == args.end()) {
- this->SetError("DOWNLOAD missing string for USERPWD.");
+ status.SetError("DOWNLOAD missing string for USERPWD.");
return false;
}
userpwd = *i;
} else if (*i == "HTTPHEADER") {
++i;
if (i == args.end()) {
- this->SetError("DOWNLOAD missing string for HTTPHEADER.");
+ status.SetError("DOWNLOAD missing string for HTTPHEADER.");
return false;
}
curl_headers.push_back(*i);
} else {
// Do not return error for compatibility reason.
- std::string err = "Unexpected argument: ";
- err += *i;
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, err);
+ std::string err = cmStrCat("Unexpected argument: ", *i);
+ status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, err);
}
++i;
}
@@ -2734,17 +1691,14 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// and the existing file already has the expected hash, then simply
// return.
//
- if (cmSystemTools::FileExists(file.c_str()) && hash.get()) {
+ if (cmSystemTools::FileExists(file) && hash.get()) {
std::string msg;
std::string actualHash = hash->HashFile(file);
if (actualHash == expectedHash) {
- msg = "returning early; file already exists with expected ";
- msg += hashMatchMSG;
- msg += "\"";
+ msg = cmStrCat("returning early; file already exists with expected ",
+ hashMatchMSG, '"');
if (!statusVar.empty()) {
- std::ostringstream result;
- result << (int)0 << ";\"" << msg;
- this->Makefile->AddDefinition(statusVar, result.str().c_str());
+ status.GetMakefile().AddDefinition(statusVar, cmStrCat(0, ";\"", msg));
}
return true;
}
@@ -2753,30 +1707,29 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// as we receive downloaded bits from curl...
//
std::string dir = cmSystemTools::GetFilenamePath(file);
- if (!cmSystemTools::FileExists(dir.c_str()) &&
- !cmSystemTools::MakeDirectory(dir.c_str())) {
+ if (!cmSystemTools::FileExists(dir) && !cmSystemTools::MakeDirectory(dir)) {
std::string errstring = "DOWNLOAD error: cannot create directory '" + dir +
"' - Specify file by full path name and verify that you "
"have directory creation and file write privileges.";
- this->SetError(errstring);
+ status.SetError(errstring);
return false;
}
cmsys::ofstream fout(file.c_str(), std::ios::binary);
if (!fout) {
- this->SetError("DOWNLOAD cannot open file for write.");
+ status.SetError("DOWNLOAD cannot open file for write.");
return false;
}
-#if defined(_WIN32)
+# if defined(_WIN32)
url = fix_file_url_windows(url);
-#endif
+# endif
::CURL* curl;
::curl_global_init(CURL_GLOBAL_DEFAULT);
curl = ::curl_easy_init();
if (!curl) {
- this->SetError("DOWNLOAD error initializing curl.");
+ status.SetError("DOWNLOAD error initializing curl.");
return false;
}
@@ -2810,16 +1763,26 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// command arg comes first
std::string const& cainfo_err = cmCurlSetCAInfo(curl, cainfo);
if (!cainfo_err.empty()) {
- this->SetError(cainfo_err);
+ status.SetError(cainfo_err);
+ return false;
+ }
+
+ // check to see if netrc parameters have been specified
+ // local command args takes precedence over CMAKE_NETRC*
+ netrc_level = cmSystemTools::UpperCase(netrc_level);
+ std::string const& netrc_option_err =
+ cmCurlSetNETRCOption(curl, netrc_level, netrc_file);
+ if (!netrc_option_err.empty()) {
+ status.SetError(netrc_option_err);
return false;
}
cmFileCommandVectorOfChar chunkDebug;
- res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&fout);
+ res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, &fout);
check_curl_result(res, "DOWNLOAD cannot set write data: ");
- res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
+ res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug);
check_curl_result(res, "DOWNLOAD cannot set debug data: ");
res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
@@ -2846,7 +1809,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// scope intentionally, rather than inside the "if(showProgress)"
// block...
//
- cURLProgressHelper helper(this, "download");
+ cURLProgressHelper helper(&status.GetMakefile(), "download");
if (showProgress) {
res = ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
@@ -2866,10 +1829,9 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
check_curl_result(res, "DOWNLOAD cannot set user password: ");
}
- struct curl_slist* headers = CM_NULLPTR;
- for (std::vector<std::string>::const_iterator h = curl_headers.begin();
- h != curl_headers.end(); ++h) {
- headers = ::curl_slist_append(headers, h->c_str());
+ struct curl_slist* headers = nullptr;
+ for (std::string const& h : curl_headers) {
+ headers = ::curl_slist_append(headers, h.c_str());
}
::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
@@ -2882,9 +1844,9 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
::curl_easy_cleanup(curl);
if (!statusVar.empty()) {
- std::ostringstream result;
- result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
- this->Makefile->AddDefinition(statusVar, result.str().c_str());
+ status.GetMakefile().AddDefinition(
+ statusVar,
+ cmStrCat(static_cast<int>(res), ";\"", ::curl_easy_strerror(res), "\""));
}
::curl_global_cleanup();
@@ -2896,54 +1858,60 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// Verify MD5 sum if requested:
//
- if (hash.get()) {
+ if (hash) {
std::string actualHash = hash->HashFile(file);
if (actualHash.empty()) {
- this->SetError("DOWNLOAD cannot compute hash on downloaded file");
+ status.SetError("DOWNLOAD cannot compute hash on downloaded file");
return false;
}
if (expectedHash != actualHash) {
- std::ostringstream oss;
- oss << "DOWNLOAD HASH mismatch" << std::endl
- << " for file: [" << file << "]" << std::endl
- << " expected hash: [" << expectedHash << "]" << std::endl
- << " actual hash: [" << actualHash << "]" << std::endl
- << " status: [" << (int)res << ";\""
- << ::curl_easy_strerror(res) << "\"]" << std::endl;
-
if (!statusVar.empty() && res == 0) {
- std::string status = "1;HASH mismatch: "
- "expected: " +
- expectedHash + " actual: " + actualHash;
- this->Makefile->AddDefinition(statusVar, status.c_str());
- }
-
- this->SetError(oss.str());
+ status.GetMakefile().AddDefinition(statusVar,
+ "1;HASH mismatch: "
+ "expected: " +
+ expectedHash +
+ " actual: " + actualHash);
+ }
+
+ status.SetError(cmStrCat("DOWNLOAD HASH mismatch\n"
+ " for file: [",
+ file,
+ "]\n"
+ " expected hash: [",
+ expectedHash,
+ "]\n"
+ " actual hash: [",
+ actualHash,
+ "]\n"
+ " status: [",
+ static_cast<int>(res), ";\"",
+ ::curl_easy_strerror(res), "\"]\n"));
return false;
}
}
if (!logVar.empty()) {
chunkDebug.push_back(0);
- this->Makefile->AddDefinition(logVar, &*chunkDebug.begin());
+ status.GetMakefile().AddDefinition(logVar, chunkDebug.data());
}
return true;
#else
- this->SetError("DOWNLOAD not supported by bootstrap cmake.");
+ status.SetError("DOWNLOAD not supported by bootstrap cmake.");
return false;
#endif
}
-bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
+bool HandleUploadCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
if (args.size() < 3) {
- this->SetError("UPLOAD must be called with at least three arguments.");
+ status.SetError("UPLOAD must be called with at least three arguments.");
return false;
}
- std::vector<std::string>::const_iterator i = args.begin();
+ auto i = args.begin();
++i;
std::string filename = *i;
++i;
@@ -2956,6 +1924,10 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
std::string statusVar;
bool showProgress = false;
std::string userpwd;
+ std::string netrc_level =
+ status.GetMakefile().GetSafeDefinition("CMAKE_NETRC");
+ std::string netrc_file =
+ status.GetMakefile().GetSafeDefinition("CMAKE_NETRC_FILE");
std::vector<std::string> curl_headers;
@@ -2965,7 +1937,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
timeout = atol(i->c_str());
} else {
- this->SetError("UPLOAD missing time for TIMEOUT.");
+ status.SetError("UPLOAD missing time for TIMEOUT.");
return false;
}
} else if (*i == "INACTIVITY_TIMEOUT") {
@@ -2973,44 +1945,59 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
if (i != args.end()) {
inactivity_timeout = atol(i->c_str());
} else {
- this->SetError("UPLOAD missing time for INACTIVITY_TIMEOUT.");
+ status.SetError("UPLOAD missing time for INACTIVITY_TIMEOUT.");
return false;
}
} else if (*i == "LOG") {
++i;
if (i == args.end()) {
- this->SetError("UPLOAD missing VAR for LOG.");
+ status.SetError("UPLOAD missing VAR for LOG.");
return false;
}
logVar = *i;
} else if (*i == "STATUS") {
++i;
if (i == args.end()) {
- this->SetError("UPLOAD missing VAR for STATUS.");
+ status.SetError("UPLOAD missing VAR for STATUS.");
return false;
}
statusVar = *i;
} else if (*i == "SHOW_PROGRESS") {
showProgress = true;
+ } else if (*i == "NETRC_FILE") {
+ ++i;
+ if (i != args.end()) {
+ netrc_file = *i;
+ } else {
+ status.SetError("UPLOAD missing file value for NETRC_FILE.");
+ return false;
+ }
+ } else if (*i == "NETRC") {
+ ++i;
+ if (i != args.end()) {
+ netrc_level = *i;
+ } else {
+ status.SetError("UPLOAD missing level value for NETRC.");
+ return false;
+ }
} else if (*i == "USERPWD") {
++i;
if (i == args.end()) {
- this->SetError("UPLOAD missing string for USERPWD.");
+ status.SetError("UPLOAD missing string for USERPWD.");
return false;
}
userpwd = *i;
} else if (*i == "HTTPHEADER") {
++i;
if (i == args.end()) {
- this->SetError("UPLOAD missing string for HTTPHEADER.");
+ status.SetError("UPLOAD missing string for HTTPHEADER.");
return false;
}
curl_headers.push_back(*i);
} else {
// Do not return error for compatibility reason.
- std::string err = "Unexpected argument: ";
- err += *i;
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, err);
+ std::string err = cmStrCat("Unexpected argument: ", *i);
+ status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, err);
}
++i;
@@ -3020,23 +2007,23 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
//
FILE* fin = cmsys::SystemTools::Fopen(filename, "rb");
if (!fin) {
- std::string errStr = "UPLOAD cannot open file '";
- errStr += filename + "' for reading.";
- this->SetError(errStr);
+ std::string errStr =
+ cmStrCat("UPLOAD cannot open file '", filename, "' for reading.");
+ status.SetError(errStr);
return false;
}
unsigned long file_size = cmsys::SystemTools::FileLength(filename);
-#if defined(_WIN32)
+# if defined(_WIN32)
url = fix_file_url_windows(url);
-#endif
+# endif
::CURL* curl;
::curl_global_init(CURL_GLOBAL_DEFAULT);
curl = ::curl_easy_init();
if (!curl) {
- this->SetError("UPLOAD error initializing curl.");
+ status.SetError("UPLOAD error initializing curl.");
fclose(fin);
return false;
}
@@ -3065,10 +2052,10 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
cmFileCommandVectorOfChar chunkResponse;
cmFileCommandVectorOfChar chunkDebug;
- res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&chunkResponse);
+ res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, &chunkResponse);
check_curl_result(res, "UPLOAD cannot set write data: ");
- res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void*)&chunkDebug);
+ res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, &chunkDebug);
check_curl_result(res, "UPLOAD cannot set debug data: ");
res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
@@ -3095,7 +2082,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
// scope intentionally, rather than inside the "if(showProgress)"
// block...
//
- cURLProgressHelper helper(this, "upload");
+ cURLProgressHelper helper(&status.GetMakefile(), "upload");
if (showProgress) {
res = ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
@@ -3124,10 +2111,19 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
check_curl_result(res, "UPLOAD cannot set user password: ");
}
- struct curl_slist* headers = CM_NULLPTR;
- for (std::vector<std::string>::const_iterator h = curl_headers.begin();
- h != curl_headers.end(); ++h) {
- headers = ::curl_slist_append(headers, h->c_str());
+ // check to see if netrc parameters have been specified
+ // local command args takes precedence over CMAKE_NETRC*
+ netrc_level = cmSystemTools::UpperCase(netrc_level);
+ std::string const& netrc_option_err =
+ cmCurlSetNETRCOption(curl, netrc_level, netrc_file);
+ if (!netrc_option_err.empty()) {
+ status.SetError(netrc_option_err);
+ return false;
+ }
+
+ struct curl_slist* headers = nullptr;
+ for (std::string const& h : curl_headers) {
+ headers = ::curl_slist_append(headers, h.c_str());
}
::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
@@ -3140,15 +2136,15 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
::curl_easy_cleanup(curl);
if (!statusVar.empty()) {
- std::ostringstream result;
- result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
- this->Makefile->AddDefinition(statusVar, result.str().c_str());
+ status.GetMakefile().AddDefinition(
+ statusVar,
+ cmStrCat(static_cast<int>(res), ";\"", ::curl_easy_strerror(res), "\""));
}
::curl_global_cleanup();
fclose(fin);
- fin = CM_NULLPTR;
+ fin = nullptr;
if (!logVar.empty()) {
std::string log;
@@ -3156,88 +2152,90 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
if (!chunkResponse.empty()) {
chunkResponse.push_back(0);
log += "Response:\n";
- log += &*chunkResponse.begin();
+ log += chunkResponse.data();
log += "\n";
}
if (!chunkDebug.empty()) {
chunkDebug.push_back(0);
log += "Debug:\n";
- log += &*chunkDebug.begin();
+ log += chunkDebug.data();
log += "\n";
}
- this->Makefile->AddDefinition(logVar, log.c_str());
+ status.GetMakefile().AddDefinition(logVar, log);
}
return true;
#else
- this->SetError("UPLOAD not supported by bootstrap cmake.");
+ status.SetError("UPLOAD not supported by bootstrap cmake.");
return false;
#endif
}
-void cmFileCommand::AddEvaluationFile(const std::string& inputName,
- const std::string& outputExpr,
- const std::string& condition,
- bool inputIsContent)
+void AddEvaluationFile(const std::string& inputName,
+ const std::string& outputExpr,
+ const std::string& condition, bool inputIsContent,
+ cmExecutionStatus& status)
{
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+ cmListFileBacktrace lfbt = status.GetMakefile().GetBacktrace();
cmGeneratorExpression outputGe(lfbt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> outputCge =
+ std::unique_ptr<cmCompiledGeneratorExpression> outputCge =
outputGe.Parse(outputExpr);
cmGeneratorExpression conditionGe(lfbt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> conditionCge =
+ std::unique_ptr<cmCompiledGeneratorExpression> conditionCge =
conditionGe.Parse(condition);
- this->Makefile->AddEvaluationFile(inputName, outputCge, conditionCge,
- inputIsContent);
+ status.GetMakefile().AddEvaluationFile(
+ inputName, std::move(outputCge), std::move(conditionCge), inputIsContent);
}
-bool cmFileCommand::HandleGenerateCommand(std::vector<std::string> const& args)
+bool HandleGenerateCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 5) {
- this->SetError("Incorrect arguments to GENERATE subcommand.");
+ status.SetError("Incorrect arguments to GENERATE subcommand.");
return false;
}
if (args[1] != "OUTPUT") {
- this->SetError("Incorrect arguments to GENERATE subcommand.");
+ status.SetError("Incorrect arguments to GENERATE subcommand.");
return false;
}
std::string condition;
if (args.size() > 5) {
if (args[5] != "CONDITION") {
- this->SetError("Incorrect arguments to GENERATE subcommand.");
+ status.SetError("Incorrect arguments to GENERATE subcommand.");
return false;
}
if (args.size() != 7) {
- this->SetError("Incorrect arguments to GENERATE subcommand.");
+ status.SetError("Incorrect arguments to GENERATE subcommand.");
return false;
}
condition = args[6];
if (condition.empty()) {
- this->SetError("CONDITION of sub-command GENERATE must not be empty if "
- "specified.");
+ status.SetError("CONDITION of sub-command GENERATE must not be empty if "
+ "specified.");
return false;
}
}
std::string output = args[2];
const bool inputIsContent = args[3] != "INPUT";
if (inputIsContent && args[3] != "CONTENT") {
- this->SetError("Incorrect arguments to GENERATE subcommand.");
+ status.SetError("Incorrect arguments to GENERATE subcommand.");
return false;
}
std::string input = args[4];
- this->AddEvaluationFile(input, output, condition, inputIsContent);
+ AddEvaluationFile(input, output, condition, inputIsContent, status);
return true;
}
-bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
+bool HandleLockCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
// Default values
bool directory = false;
bool release = false;
@@ -3253,8 +2251,9 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
// Parse arguments
if (args.size() < 2) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR, "sub-command LOCK requires at least two arguments.");
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ "sub-command LOCK requires at least two arguments.");
return false;
}
@@ -3268,7 +2267,7 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
++i;
const char* merr = "expected FUNCTION, FILE or PROCESS after GUARD";
if (i >= args.size()) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, merr);
+ status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, merr);
return false;
}
if (args[i] == "FUNCTION") {
@@ -3278,41 +2277,42 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
} else if (args[i] == "PROCESS") {
guard = GUARD_PROCESS;
} else {
- std::ostringstream e;
- e << merr << ", but got:\n \"" << args[i] << "\".";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(merr, ", but got:\n \"", args[i], "\"."));
return false;
}
} else if (args[i] == "RESULT_VARIABLE") {
++i;
if (i >= args.size()) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR, "expected variable name after RESULT_VARIABLE");
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ "expected variable name after RESULT_VARIABLE");
return false;
}
resultVariable = args[i];
} else if (args[i] == "TIMEOUT") {
++i;
if (i >= args.size()) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "expected timeout value after TIMEOUT");
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR, "expected timeout value after TIMEOUT");
return false;
}
long scanned;
- if (!cmSystemTools::StringToLong(args[i].c_str(), &scanned) ||
- scanned < 0) {
- std::ostringstream e;
- e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ if (!cmStrToLong(args[i], &scanned) || scanned < 0) {
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("TIMEOUT value \"", args[i],
+ "\" is not an unsigned integer."));
return false;
}
timeout = static_cast<unsigned long>(scanned);
} else {
- std::ostringstream e;
- e << "expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT\n";
- e << "but got: \"" << args[i] << "\".";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or ",
+ "TIMEOUT\nbut got: \"", args[i], "\"."));
return false;
}
}
@@ -3322,7 +2322,7 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
}
if (!cmsys::SystemTools::FileIsFullPath(path)) {
- path = this->Makefile->GetCurrentSourceDirectory() + ("/" + path);
+ path = status.GetMakefile().GetCurrentSourceDirectory() + "/" + path;
}
// Unify path (remove '//', '/../', ...)
@@ -3331,18 +2331,19 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
// Create file and directories if needed
std::string parentDir = cmSystemTools::GetParentDirectory(path);
if (!cmSystemTools::MakeDirectory(parentDir)) {
- std::ostringstream e;
- e << "directory\n \"" << parentDir << "\"\ncreation failed ";
- e << "(check permissions).";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("directory\n \"", parentDir,
+ "\"\ncreation failed (check permissions)."));
cmSystemTools::SetFatalErrorOccured();
return false;
}
FILE* file = cmsys::SystemTools::Fopen(path, "w");
if (!file) {
- std::ostringstream e;
- e << "file\n \"" << path << "\"\ncreation failed (check permissions).";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("file\n \"", path,
+ "\"\ncreation failed (check permissions)."));
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -3350,7 +2351,7 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
// Actual lock/unlock
cmFileLockPool& lockPool =
- this->Makefile->GetGlobalGenerator()->GetFileLockPool();
+ status.GetMakefile().GetGlobalGenerator()->GetFileLockPool();
cmFileLockResult fileLockResult(cmFileLockResult::MakeOk());
if (release) {
@@ -3375,34 +2376,34 @@ bool cmFileCommand::HandleLockCommand(std::vector<std::string> const& args)
const std::string result = fileLockResult.GetOutputMessage();
if (resultVariable.empty() && !fileLockResult.IsOk()) {
- std::ostringstream e;
- e << "error locking file\n \"" << path << "\"\n" << result << ".";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("error locking file\n \"", path, "\"\n", result, "."));
cmSystemTools::SetFatalErrorOccured();
return false;
}
if (!resultVariable.empty()) {
- this->Makefile->AddDefinition(resultVariable, result.c_str());
+ status.GetMakefile().AddDefinition(resultVariable, result);
}
return true;
#else
static_cast<void>(args);
- this->SetError("sub-command LOCK not implemented in bootstrap cmake");
+ status.SetError("sub-command LOCK not implemented in bootstrap cmake");
return false;
#endif
}
-bool cmFileCommand::HandleTimestampCommand(
- std::vector<std::string> const& args)
+bool HandleTimestampCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("sub-command TIMESTAMP requires at least two arguments.");
+ status.SetError("sub-command TIMESTAMP requires at least two arguments.");
return false;
}
if (args.size() > 5) {
- this->SetError("sub-command TIMESTAMP takes at most four arguments.");
+ status.SetError("sub-command TIMESTAMP takes at most four arguments.");
return false;
}
@@ -3424,7 +2425,7 @@ bool cmFileCommand::HandleTimestampCommand(
} else {
std::string e = " TIMESTAMP sub-command does not recognize option " +
args[argsIndex] + ".";
- this->SetError(e);
+ status.SetError(e);
return false;
}
}
@@ -3432,7 +2433,401 @@ bool cmFileCommand::HandleTimestampCommand(
cmTimestamp timestamp;
std::string result =
timestamp.FileModificationTime(filename.c_str(), formatString, utcFlag);
- this->Makefile->AddDefinition(outputVariable, result.c_str());
+ status.GetMakefile().AddDefinition(outputVariable, result);
+
+ return true;
+}
+
+bool HandleSizeCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() != 3) {
+ status.SetError(
+ cmStrCat(args[0], " requires a file name and output variable"));
+ return false;
+ }
+
+ unsigned int argsIndex = 1;
+
+ const std::string& filename = args[argsIndex++];
+
+ const std::string& outputVariable = args[argsIndex++];
+
+ if (!cmSystemTools::FileExists(filename, true)) {
+ status.SetError(
+ cmStrCat("SIZE requested of path that is not readable:\n ", filename));
+ return false;
+ }
+
+ status.GetMakefile().AddDefinition(
+ outputVariable, std::to_string(cmSystemTools::FileLength(filename)));
+
+ return true;
+}
+
+bool HandleReadSymlinkCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() != 3) {
+ status.SetError(
+ cmStrCat(args[0], " requires a file name and output variable"));
+ return false;
+ }
+
+ const std::string& filename = args[1];
+ const std::string& outputVariable = args[2];
+
+ std::string result;
+ if (!cmSystemTools::ReadSymlink(filename, result)) {
+ status.SetError(cmStrCat(
+ "READ_SYMLINK requested of path that is not a symlink:\n ", filename));
+ return false;
+ }
+
+ status.GetMakefile().AddDefinition(outputVariable, result);
+
+ return true;
+}
+
+bool HandleCreateLinkCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() < 3) {
+ status.SetError("CREATE_LINK must be called with at least two additional "
+ "arguments");
+ return false;
+ }
+
+ std::string const& fileName = args[1];
+ std::string const& newFileName = args[2];
+
+ struct Arguments
+ {
+ std::string Result;
+ bool CopyOnError = false;
+ bool Symbolic = false;
+ };
+
+ static auto const parser =
+ cmArgumentParser<Arguments>{}
+ .Bind("RESULT"_s, &Arguments::Result)
+ .Bind("COPY_ON_ERROR"_s, &Arguments::CopyOnError)
+ .Bind("SYMBOLIC"_s, &Arguments::Symbolic);
+
+ std::vector<std::string> unconsumedArgs;
+ Arguments const arguments =
+ parser.Parse(cmMakeRange(args).advance(3), &unconsumedArgs);
+ if (!unconsumedArgs.empty()) {
+ status.SetError("unknown argument: \"" + unconsumedArgs.front() + '\"');
+ return false;
+ }
+
+ // The system error message generated in the operation.
+ std::string result;
+
+ // Check if the paths are distinct.
+ if (fileName == newFileName) {
+ result = "CREATE_LINK cannot use same file and newfile";
+ if (!arguments.Result.empty()) {
+ status.GetMakefile().AddDefinition(arguments.Result, result);
+ return true;
+ }
+ status.SetError(result);
+ return false;
+ }
+
+ // Hard link requires original file to exist.
+ if (!arguments.Symbolic && !cmSystemTools::FileExists(fileName)) {
+ result = "Cannot hard link \'" + fileName + "\' as it does not exist.";
+ if (!arguments.Result.empty()) {
+ status.GetMakefile().AddDefinition(arguments.Result, result);
+ return true;
+ }
+ status.SetError(result);
+ return false;
+ }
+
+ // Check if the new file already exists and remove it.
+ if ((cmSystemTools::FileExists(newFileName) ||
+ cmSystemTools::FileIsSymlink(newFileName)) &&
+ !cmSystemTools::RemoveFile(newFileName)) {
+ std::ostringstream e;
+ e << "Failed to create link '" << newFileName
+ << "' because existing path cannot be removed: "
+ << cmSystemTools::GetLastSystemError() << "\n";
+
+ if (!arguments.Result.empty()) {
+ status.GetMakefile().AddDefinition(arguments.Result, e.str());
+ return true;
+ }
+ status.SetError(e.str());
+ return false;
+ }
+
+ // Whether the operation completed successfully.
+ bool completed = false;
+
+ // Check if the command requires a symbolic link.
+ if (arguments.Symbolic) {
+ completed = cmSystemTools::CreateSymlink(fileName, newFileName, &result);
+ } else {
+ completed = cmSystemTools::CreateLink(fileName, newFileName, &result);
+ }
+
+ // Check if copy-on-error is enabled in the arguments.
+ if (!completed && arguments.CopyOnError) {
+ completed = cmsys::SystemTools::CopyFileAlways(fileName, newFileName);
+ if (!completed) {
+ result = "Copy failed: " + cmSystemTools::GetLastSystemError();
+ }
+ }
+
+ // Check if the operation was successful.
+ if (completed) {
+ result = "0";
+ } else if (arguments.Result.empty()) {
+ // The operation failed and the result is not reported in a variable.
+ status.SetError(result);
+ return false;
+ }
+
+ if (!arguments.Result.empty()) {
+ status.GetMakefile().AddDefinition(arguments.Result, result);
+ }
+
+ return true;
+}
+
+bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ static const std::set<std::string> supportedPlatforms = { "Windows", "Linux",
+ "Darwin" };
+ std::string platform =
+ status.GetMakefile().GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME");
+ if (!supportedPlatforms.count(platform)) {
+ status.SetError(
+ cmStrCat("GET_RUNTIME_DEPENDENCIES is not supported on system \"",
+ platform, "\""));
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+
+ if (status.GetMakefile().GetState()->GetMode() == cmState::Project) {
+ status.GetMakefile().IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ "You have used file(GET_RUNTIME_DEPENDENCIES)"
+ " in project mode. This is probably not what "
+ "you intended to do. Instead, please consider"
+ " using it in an install(CODE) or "
+ "install(SCRIPT) command. For example:"
+ "\n install(CODE [["
+ "\n file(GET_RUNTIME_DEPENDENCIES"
+ "\n # ..."
+ "\n )"
+ "\n ]])");
+ }
+
+ struct Arguments
+ {
+ std::string ResolvedDependenciesVar;
+ std::string UnresolvedDependenciesVar;
+ std::string ConflictingDependenciesPrefix;
+ std::string BundleExecutable;
+ std::vector<std::string> Executables;
+ std::vector<std::string> Libraries;
+ std::vector<std::string> Directories;
+ std::vector<std::string> Modules;
+ std::vector<std::string> PreIncludeRegexes;
+ std::vector<std::string> PreExcludeRegexes;
+ std::vector<std::string> PostIncludeRegexes;
+ std::vector<std::string> PostExcludeRegexes;
+ };
+
+ static auto const parser =
+ cmArgumentParser<Arguments>{}
+ .Bind("RESOLVED_DEPENDENCIES_VAR"_s, &Arguments::ResolvedDependenciesVar)
+ .Bind("UNRESOLVED_DEPENDENCIES_VAR"_s,
+ &Arguments::UnresolvedDependenciesVar)
+ .Bind("CONFLICTING_DEPENDENCIES_PREFIX"_s,
+ &Arguments::ConflictingDependenciesPrefix)
+ .Bind("BUNDLE_EXECUTABLE"_s, &Arguments::BundleExecutable)
+ .Bind("EXECUTABLES"_s, &Arguments::Executables)
+ .Bind("LIBRARIES"_s, &Arguments::Libraries)
+ .Bind("MODULES"_s, &Arguments::Modules)
+ .Bind("DIRECTORIES"_s, &Arguments::Directories)
+ .Bind("PRE_INCLUDE_REGEXES"_s, &Arguments::PreIncludeRegexes)
+ .Bind("PRE_EXCLUDE_REGEXES"_s, &Arguments::PreExcludeRegexes)
+ .Bind("POST_INCLUDE_REGEXES"_s, &Arguments::PostIncludeRegexes)
+ .Bind("POST_EXCLUDE_REGEXES"_s, &Arguments::PostExcludeRegexes);
+
+ std::vector<std::string> unrecognizedArguments;
+ std::vector<std::string> keywordsMissingValues;
+ auto parsedArgs =
+ parser.Parse(cmMakeRange(args).advance(1), &unrecognizedArguments,
+ &keywordsMissingValues);
+ auto argIt = unrecognizedArguments.begin();
+ if (argIt != unrecognizedArguments.end()) {
+ status.SetError(cmStrCat("Unrecognized argument: \"", *argIt, "\""));
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+
+ const std::vector<std::string> LIST_ARGS = { "DIRECTORIES",
+ "EXECUTABLES",
+ "LIBRARIES",
+ "MODULES",
+ "POST_EXCLUDE_REGEXES",
+ "POST_INCLUDE_REGEXES",
+ "PRE_EXCLUDE_REGEXES",
+ "PRE_INCLUDE_REGEXES" };
+ auto kwbegin = keywordsMissingValues.cbegin();
+ auto kwend = cmRemoveMatching(keywordsMissingValues, LIST_ARGS);
+ if (kwend != kwbegin) {
+ status.SetError(cmStrCat("Keywords missing values:\n ",
+ cmJoin(cmMakeRange(kwbegin, kwend), "\n ")));
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+
+ cmRuntimeDependencyArchive archive(
+ status, parsedArgs.Directories, parsedArgs.BundleExecutable,
+ parsedArgs.PreIncludeRegexes, parsedArgs.PreExcludeRegexes,
+ parsedArgs.PostIncludeRegexes, parsedArgs.PostExcludeRegexes);
+ if (!archive.Prepare()) {
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+
+ if (!archive.GetRuntimeDependencies(
+ parsedArgs.Executables, parsedArgs.Libraries, parsedArgs.Modules)) {
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+
+ std::vector<std::string> deps;
+ std::vector<std::string> unresolvedDeps;
+ std::vector<std::string> conflictingDeps;
+ for (auto const& val : archive.GetResolvedPaths()) {
+ bool unique = true;
+ auto it = val.second.begin();
+ assert(it != val.second.end());
+ auto const& firstPath = *it;
+ while (++it != val.second.end()) {
+ if (!cmSystemTools::SameFile(firstPath, *it)) {
+ unique = false;
+ break;
+ }
+ }
+
+ if (unique) {
+ deps.push_back(firstPath);
+ } else if (!parsedArgs.ConflictingDependenciesPrefix.empty()) {
+ conflictingDeps.push_back(val.first);
+ std::vector<std::string> paths;
+ paths.insert(paths.begin(), val.second.begin(), val.second.end());
+ std::string varName =
+ parsedArgs.ConflictingDependenciesPrefix + "_" + val.first;
+ std::string pathsStr = cmJoin(paths, ";");
+ status.GetMakefile().AddDefinition(varName, pathsStr);
+ } else {
+ std::ostringstream e;
+ e << "Multiple conflicting paths found for " << val.first << ":";
+ for (auto const& path : val.second) {
+ e << "\n " << path;
+ }
+ status.SetError(e.str());
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+ }
+ if (!archive.GetUnresolvedPaths().empty()) {
+ if (!parsedArgs.UnresolvedDependenciesVar.empty()) {
+ unresolvedDeps.insert(unresolvedDeps.begin(),
+ archive.GetUnresolvedPaths().begin(),
+ archive.GetUnresolvedPaths().end());
+ } else {
+ auto it = archive.GetUnresolvedPaths().begin();
+ assert(it != archive.GetUnresolvedPaths().end());
+ status.SetError(cmStrCat("Could not resolve file ", *it));
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+ }
+
+ if (!parsedArgs.ResolvedDependenciesVar.empty()) {
+ std::string val = cmJoin(deps, ";");
+ status.GetMakefile().AddDefinition(parsedArgs.ResolvedDependenciesVar,
+ val);
+ }
+ if (!parsedArgs.UnresolvedDependenciesVar.empty()) {
+ std::string val = cmJoin(unresolvedDeps, ";");
+ status.GetMakefile().AddDefinition(parsedArgs.UnresolvedDependenciesVar,
+ val);
+ }
+ if (!parsedArgs.ConflictingDependenciesPrefix.empty()) {
+ std::string val = cmJoin(conflictingDeps, ";");
+ status.GetMakefile().AddDefinition(
+ parsedArgs.ConflictingDependenciesPrefix + "_FILENAMES", val);
+ }
return true;
}
+
+} // namespace
+
+bool cmFileCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() < 2) {
+ status.SetError("must be called with at least two arguments.");
+ return false;
+ }
+
+ static cmSubcommandTable const subcommand{
+ { "WRITE"_s, HandleWriteCommand },
+ { "APPEND"_s, HandleAppendCommand },
+ { "DOWNLOAD"_s, HandleDownloadCommand },
+ { "UPLOAD"_s, HandleUploadCommand },
+ { "READ"_s, HandleReadCommand },
+ { "MD5"_s, HandleHashCommand },
+ { "SHA1"_s, HandleHashCommand },
+ { "SHA224"_s, HandleHashCommand },
+ { "SHA256"_s, HandleHashCommand },
+ { "SHA384"_s, HandleHashCommand },
+ { "SHA512"_s, HandleHashCommand },
+ { "SHA3_224"_s, HandleHashCommand },
+ { "SHA3_256"_s, HandleHashCommand },
+ { "SHA3_384"_s, HandleHashCommand },
+ { "SHA3_512"_s, HandleHashCommand },
+ { "STRINGS"_s, HandleStringsCommand },
+ { "GLOB"_s, HandleGlobCommand },
+ { "GLOB_RECURSE"_s, HandleGlobRecurseCommand },
+ { "MAKE_DIRECTORY"_s, HandleMakeDirectoryCommand },
+ { "RENAME"_s, HandleRename },
+ { "REMOVE"_s, HandleRemove },
+ { "REMOVE_RECURSE"_s, HandleRemoveRecurse },
+ { "COPY"_s, HandleCopyCommand },
+ { "INSTALL"_s, HandleInstallCommand },
+ { "DIFFERENT"_s, HandleDifferentCommand },
+ { "RPATH_CHANGE"_s, HandleRPathChangeCommand },
+ { "CHRPATH"_s, HandleRPathChangeCommand },
+ { "RPATH_CHECK"_s, HandleRPathCheckCommand },
+ { "RPATH_REMOVE"_s, HandleRPathRemoveCommand },
+ { "READ_ELF"_s, HandleReadElfCommand },
+ { "RELATIVE_PATH"_s, HandleRelativePathCommand },
+ { "TO_CMAKE_PATH"_s, HandleCMakePathCommand },
+ { "TO_NATIVE_PATH"_s, HandleNativePathCommand },
+ { "TOUCH"_s, HandleTouchCommand },
+ { "TOUCH_NOCREATE"_s, HandleTouchNocreateCommand },
+ { "TIMESTAMP"_s, HandleTimestampCommand },
+ { "GENERATE"_s, HandleGenerateCommand },
+ { "LOCK"_s, HandleLockCommand },
+ { "SIZE"_s, HandleSizeCommand },
+ { "READ_SYMLINK"_s, HandleReadSymlinkCommand },
+ { "CREATE_LINK"_s, HandleCreateLinkCommand },
+ { "GET_RUNTIME_DEPENDENCIES"_s, HandleGetRuntimeDependenciesCommand },
+ };
+
+ return subcommand(args[0], args, status);
+}
diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h
index d09ef42f1..8c9b21990 100644
--- a/Source/cmFileCommand.h
+++ b/Source/cmFileCommand.h
@@ -3,66 +3,14 @@
#ifndef cmFileCommand_h
#define cmFileCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmFileCommand
- * \brief Command for manipulation of files
- *
- */
-class cmFileCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmFileCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-protected:
- bool HandleRename(std::vector<std::string> const& args);
- bool HandleRemove(std::vector<std::string> const& args, bool recurse);
- bool HandleWriteCommand(std::vector<std::string> const& args, bool append);
- bool HandleReadCommand(std::vector<std::string> const& args);
- bool HandleHashCommand(std::vector<std::string> const& args);
- bool HandleStringsCommand(std::vector<std::string> const& args);
- bool HandleGlobCommand(std::vector<std::string> const& args, bool recurse);
- bool HandleMakeDirectoryCommand(std::vector<std::string> const& args);
-
- bool HandleRelativePathCommand(std::vector<std::string> const& args);
- bool HandleCMakePathCommand(std::vector<std::string> const& args,
- bool nativePath);
- bool HandleReadElfCommand(std::vector<std::string> const& args);
- bool HandleRPathChangeCommand(std::vector<std::string> const& args);
- bool HandleRPathCheckCommand(std::vector<std::string> const& args);
- bool HandleRPathRemoveCommand(std::vector<std::string> const& args);
- bool HandleDifferentCommand(std::vector<std::string> const& args);
-
- bool HandleCopyCommand(std::vector<std::string> const& args);
- bool HandleInstallCommand(std::vector<std::string> const& args);
- bool HandleDownloadCommand(std::vector<std::string> const& args);
- bool HandleUploadCommand(std::vector<std::string> const& args);
-
- bool HandleTimestampCommand(std::vector<std::string> const& args);
- bool HandleGenerateCommand(std::vector<std::string> const& args);
- bool HandleLockCommand(std::vector<std::string> const& args);
-
-private:
- void AddEvaluationFile(const std::string& inputName,
- const std::string& outputExpr,
- const std::string& condition, bool inputIsContent);
-};
+bool cmFileCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx
new file mode 100644
index 000000000..627e05b58
--- /dev/null
+++ b/Source/cmFileCopier.cxx
@@ -0,0 +1,711 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmFileCopier.h"
+
+#include "cmsys/Directory.hxx"
+#include "cmsys/Glob.hxx"
+
+#include "cmExecutionStatus.h"
+#include "cmFSPermissions.h"
+#include "cmFileTimes.h"
+#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+#ifdef _WIN32
+# include "cmsys/FStream.hxx"
+#endif
+
+#include <cstring>
+#include <sstream>
+
+using namespace cmFSPermissions;
+
+cmFileCopier::cmFileCopier(cmExecutionStatus& status, const char* name)
+ : Status(status)
+ , Makefile(&status.GetMakefile())
+ , Name(name)
+ , Always(false)
+ , MatchlessFiles(true)
+ , FilePermissions(0)
+ , DirPermissions(0)
+ , CurrentMatchRule(nullptr)
+ , UseGivenPermissionsFile(false)
+ , UseGivenPermissionsDir(false)
+ , UseSourcePermissions(true)
+ , FollowSymlinkChain(false)
+ , Doing(DoingNone)
+{
+}
+
+cmFileCopier::~cmFileCopier() = default;
+
+cmFileCopier::MatchProperties cmFileCopier::CollectMatchProperties(
+ const std::string& file)
+{
+ // Match rules are case-insensitive on some platforms.
+#if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
+ const std::string file_to_match = cmSystemTools::LowerCase(file);
+#else
+ const std::string& file_to_match = file;
+#endif
+
+ // Collect properties from all matching rules.
+ bool matched = false;
+ MatchProperties result;
+ for (MatchRule& mr : this->MatchRules) {
+ if (mr.Regex.find(file_to_match)) {
+ matched = true;
+ result.Exclude |= mr.Properties.Exclude;
+ result.Permissions |= mr.Properties.Permissions;
+ }
+ }
+ if (!matched && !this->MatchlessFiles) {
+ result.Exclude = !cmSystemTools::FileIsDirectory(file);
+ }
+ return result;
+}
+
+bool cmFileCopier::SetPermissions(const std::string& toFile,
+ mode_t permissions)
+{
+ if (permissions) {
+#ifdef WIN32
+ if (Makefile->IsOn("CMAKE_CROSSCOMPILING")) {
+ // Store the mode in an NTFS alternate stream.
+ std::string mode_t_adt_filename = toFile + ":cmake_mode_t";
+
+ // Writing to an NTFS alternate stream changes the modification
+ // time, so we need to save and restore its original value.
+ cmFileTimes file_time_orig(toFile);
+ {
+ cmsys::ofstream permissionStream(mode_t_adt_filename.c_str());
+ if (permissionStream) {
+ permissionStream << std::oct << permissions << std::endl;
+ }
+ permissionStream.close();
+ }
+ file_time_orig.Store(toFile);
+ }
+#endif
+
+ if (!cmSystemTools::SetPermissions(toFile, permissions)) {
+ std::ostringstream e;
+ e << this->Name << " cannot set permissions on \"" << toFile
+ << "\": " << cmSystemTools::GetLastSystemError() << ".";
+ this->Status.SetError(e.str());
+ return false;
+ }
+ }
+ return true;
+}
+
+// Translate an argument to a permissions bit.
+bool cmFileCopier::CheckPermissions(std::string const& arg,
+ mode_t& permissions)
+{
+ if (!cmFSPermissions::stringToModeT(arg, permissions)) {
+ std::ostringstream e;
+ e << this->Name << " given invalid permission \"" << arg << "\".";
+ this->Status.SetError(e.str());
+ return false;
+ }
+ return true;
+}
+
+std::string const& cmFileCopier::ToName(std::string const& fromName)
+{
+ return fromName;
+}
+
+bool cmFileCopier::ReportMissing(const std::string& fromFile)
+{
+ // The input file does not exist and installation is not optional.
+ std::ostringstream e;
+ e << this->Name << " cannot find \"" << fromFile
+ << "\": " << cmSystemTools::GetLastSystemError() << ".";
+ this->Status.SetError(e.str());
+ return false;
+}
+
+void cmFileCopier::NotBeforeMatch(std::string const& arg)
+{
+ std::ostringstream e;
+ e << "option " << arg << " may not appear before PATTERN or REGEX.";
+ this->Status.SetError(e.str());
+ this->Doing = DoingError;
+}
+
+void cmFileCopier::NotAfterMatch(std::string const& arg)
+{
+ std::ostringstream e;
+ e << "option " << arg << " may not appear after PATTERN or REGEX.";
+ this->Status.SetError(e.str());
+ this->Doing = DoingError;
+}
+
+void cmFileCopier::DefaultFilePermissions()
+{
+ // Use read/write permissions.
+ this->FilePermissions = 0;
+ this->FilePermissions |= mode_owner_read;
+ this->FilePermissions |= mode_owner_write;
+ this->FilePermissions |= mode_group_read;
+ this->FilePermissions |= mode_world_read;
+}
+
+void cmFileCopier::DefaultDirectoryPermissions()
+{
+ // Use read/write/executable permissions.
+ this->DirPermissions = 0;
+ this->DirPermissions |= mode_owner_read;
+ this->DirPermissions |= mode_owner_write;
+ this->DirPermissions |= mode_owner_execute;
+ this->DirPermissions |= mode_group_read;
+ this->DirPermissions |= mode_group_execute;
+ this->DirPermissions |= mode_world_read;
+ this->DirPermissions |= mode_world_execute;
+}
+
+bool cmFileCopier::GetDefaultDirectoryPermissions(mode_t** mode)
+{
+ // check if default dir creation permissions were set
+ const char* default_dir_install_permissions = this->Makefile->GetDefinition(
+ "CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS");
+ if (default_dir_install_permissions && *default_dir_install_permissions) {
+ std::vector<std::string> items =
+ cmExpandedList(default_dir_install_permissions);
+ for (const auto& arg : items) {
+ if (!this->CheckPermissions(arg, **mode)) {
+ this->Status.SetError(
+ " Set with CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS variable.");
+ return false;
+ }
+ }
+ } else {
+ *mode = nullptr;
+ }
+
+ return true;
+}
+
+bool cmFileCopier::Parse(std::vector<std::string> const& args)
+{
+ this->Doing = DoingFiles;
+ for (unsigned int i = 1; i < args.size(); ++i) {
+ // Check this argument.
+ if (!this->CheckKeyword(args[i]) && !this->CheckValue(args[i])) {
+ std::ostringstream e;
+ e << "called with unknown argument \"" << args[i] << "\".";
+ this->Status.SetError(e.str());
+ return false;
+ }
+
+ // Quit if an argument is invalid.
+ if (this->Doing == DoingError) {
+ return false;
+ }
+ }
+
+ // Require a destination.
+ if (this->Destination.empty()) {
+ std::ostringstream e;
+ e << this->Name << " given no DESTINATION";
+ this->Status.SetError(e.str());
+ return false;
+ }
+
+ // If file permissions were not specified set default permissions.
+ if (!this->UseGivenPermissionsFile && !this->UseSourcePermissions) {
+ this->DefaultFilePermissions();
+ }
+
+ // If directory permissions were not specified set default permissions.
+ if (!this->UseGivenPermissionsDir && !this->UseSourcePermissions) {
+ this->DefaultDirectoryPermissions();
+ }
+
+ return true;
+}
+
+bool cmFileCopier::CheckKeyword(std::string const& arg)
+{
+ if (arg == "DESTINATION") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingDestination;
+ }
+ } else if (arg == "FILES_FROM_DIR") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingFilesFromDir;
+ }
+ } else if (arg == "PATTERN") {
+ this->Doing = DoingPattern;
+ } else if (arg == "REGEX") {
+ this->Doing = DoingRegex;
+ } else if (arg == "FOLLOW_SYMLINK_CHAIN") {
+ this->FollowSymlinkChain = true;
+ this->Doing = DoingNone;
+ } else if (arg == "EXCLUDE") {
+ // Add this property to the current match rule.
+ if (this->CurrentMatchRule) {
+ this->CurrentMatchRule->Properties.Exclude = true;
+ this->Doing = DoingNone;
+ } else {
+ this->NotBeforeMatch(arg);
+ }
+ } else if (arg == "PERMISSIONS") {
+ if (this->CurrentMatchRule) {
+ this->Doing = DoingPermissionsMatch;
+ } else {
+ this->NotBeforeMatch(arg);
+ }
+ } else if (arg == "FILE_PERMISSIONS") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingPermissionsFile;
+ this->UseGivenPermissionsFile = true;
+ }
+ } else if (arg == "DIRECTORY_PERMISSIONS") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingPermissionsDir;
+ this->UseGivenPermissionsDir = true;
+ }
+ } else if (arg == "USE_SOURCE_PERMISSIONS") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingNone;
+ this->UseSourcePermissions = true;
+ }
+ } else if (arg == "NO_SOURCE_PERMISSIONS") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingNone;
+ this->UseSourcePermissions = false;
+ }
+ } else if (arg == "FILES_MATCHING") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingNone;
+ this->MatchlessFiles = false;
+ }
+ } else {
+ return false;
+ }
+ return true;
+}
+
+bool cmFileCopier::CheckValue(std::string const& arg)
+{
+ switch (this->Doing) {
+ case DoingFiles:
+ this->Files.push_back(arg);
+ break;
+ case DoingDestination:
+ if (arg.empty() || cmSystemTools::FileIsFullPath(arg)) {
+ this->Destination = arg;
+ } else {
+ this->Destination =
+ cmStrCat(this->Makefile->GetCurrentBinaryDirectory(), '/', arg);
+ }
+ this->Doing = DoingNone;
+ break;
+ case DoingFilesFromDir:
+ if (cmSystemTools::FileIsFullPath(arg)) {
+ this->FilesFromDir = arg;
+ } else {
+ this->FilesFromDir =
+ cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', arg);
+ }
+ cmSystemTools::ConvertToUnixSlashes(this->FilesFromDir);
+ this->Doing = DoingNone;
+ break;
+ case DoingPattern: {
+ // Convert the pattern to a regular expression. Require a
+ // leading slash and trailing end-of-string in the matched
+ // string to make sure the pattern matches only whole file
+ // names.
+ std::string regex =
+ cmStrCat('/', cmsys::Glob::PatternToRegex(arg, false), '$');
+ this->MatchRules.emplace_back(regex);
+ this->CurrentMatchRule = &*(this->MatchRules.end() - 1);
+ if (this->CurrentMatchRule->Regex.is_valid()) {
+ this->Doing = DoingNone;
+ } else {
+ std::ostringstream e;
+ e << "could not compile PATTERN \"" << arg << "\".";
+ this->Status.SetError(e.str());
+ this->Doing = DoingError;
+ }
+ } break;
+ case DoingRegex:
+ this->MatchRules.emplace_back(arg);
+ this->CurrentMatchRule = &*(this->MatchRules.end() - 1);
+ if (this->CurrentMatchRule->Regex.is_valid()) {
+ this->Doing = DoingNone;
+ } else {
+ std::ostringstream e;
+ e << "could not compile REGEX \"" << arg << "\".";
+ this->Status.SetError(e.str());
+ this->Doing = DoingError;
+ }
+ break;
+ case DoingPermissionsFile:
+ if (!this->CheckPermissions(arg, this->FilePermissions)) {
+ this->Doing = DoingError;
+ }
+ break;
+ case DoingPermissionsDir:
+ if (!this->CheckPermissions(arg, this->DirPermissions)) {
+ this->Doing = DoingError;
+ }
+ break;
+ case DoingPermissionsMatch:
+ if (!this->CheckPermissions(
+ arg, this->CurrentMatchRule->Properties.Permissions)) {
+ this->Doing = DoingError;
+ }
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+bool cmFileCopier::Run(std::vector<std::string> const& args)
+{
+ if (!this->Parse(args)) {
+ return false;
+ }
+
+ for (std::string const& f : this->Files) {
+ std::string file;
+ if (!f.empty() && !cmSystemTools::FileIsFullPath(f)) {
+ if (!this->FilesFromDir.empty()) {
+ file = this->FilesFromDir;
+ } else {
+ file = this->Makefile->GetCurrentSourceDirectory();
+ }
+ file += "/";
+ file += f;
+ } else if (!this->FilesFromDir.empty()) {
+ this->Status.SetError("option FILES_FROM_DIR requires all files "
+ "to be specified as relative paths.");
+ return false;
+ } else {
+ file = f;
+ }
+
+ // Split the input file into its directory and name components.
+ std::vector<std::string> fromPathComponents;
+ cmSystemTools::SplitPath(file, fromPathComponents);
+ std::string fromName = *(fromPathComponents.end() - 1);
+ std::string fromDir = cmSystemTools::JoinPath(
+ fromPathComponents.begin(), fromPathComponents.end() - 1);
+
+ // Compute the full path to the destination file.
+ std::string toFile = this->Destination;
+ if (!this->FilesFromDir.empty()) {
+ std::string dir = cmSystemTools::GetFilenamePath(f);
+ if (!dir.empty()) {
+ toFile += "/";
+ toFile += dir;
+ }
+ }
+ std::string const& toName = this->ToName(fromName);
+ if (!toName.empty()) {
+ toFile += "/";
+ toFile += toName;
+ }
+
+ // Construct the full path to the source file. The file name may
+ // have been changed above.
+ std::string fromFile = fromDir;
+ if (!fromName.empty()) {
+ fromFile += "/";
+ fromFile += fromName;
+ }
+
+ if (!this->Install(fromFile, toFile)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool cmFileCopier::Install(const std::string& fromFile,
+ const std::string& toFile)
+{
+ if (fromFile.empty()) {
+ this->Status.SetError(
+ "INSTALL encountered an empty string input file name.");
+ return false;
+ }
+
+ // Collect any properties matching this file name.
+ MatchProperties match_properties = this->CollectMatchProperties(fromFile);
+
+ // Skip the file if it is excluded.
+ if (match_properties.Exclude) {
+ return true;
+ }
+
+ if (cmSystemTools::SameFile(fromFile, toFile)) {
+ return true;
+ }
+
+ std::string newFromFile = fromFile;
+ std::string newToFile = toFile;
+
+ if (this->FollowSymlinkChain &&
+ !this->InstallSymlinkChain(newFromFile, newToFile)) {
+ return false;
+ }
+
+ if (cmSystemTools::FileIsSymlink(newFromFile)) {
+ return this->InstallSymlink(newFromFile, newToFile);
+ }
+ if (cmSystemTools::FileIsDirectory(newFromFile)) {
+ return this->InstallDirectory(newFromFile, newToFile, match_properties);
+ }
+ if (cmSystemTools::FileExists(newFromFile)) {
+ return this->InstallFile(newFromFile, newToFile, match_properties);
+ }
+ return this->ReportMissing(newFromFile);
+}
+
+bool cmFileCopier::InstallSymlinkChain(std::string& fromFile,
+ std::string& toFile)
+{
+ std::string newFromFile;
+ std::string toFilePath = cmSystemTools::GetFilenamePath(toFile);
+ while (cmSystemTools::ReadSymlink(fromFile, newFromFile)) {
+ if (!cmSystemTools::FileIsFullPath(newFromFile)) {
+ std::string fromFilePath = cmSystemTools::GetFilenamePath(fromFile);
+ newFromFile = cmStrCat(fromFilePath, "/", newFromFile);
+ }
+
+ std::string symlinkTarget = cmSystemTools::GetFilenameName(newFromFile);
+
+ bool copy = true;
+ if (!this->Always) {
+ std::string oldSymlinkTarget;
+ if (cmSystemTools::ReadSymlink(toFile, oldSymlinkTarget)) {
+ if (symlinkTarget == oldSymlinkTarget) {
+ copy = false;
+ }
+ }
+ }
+
+ this->ReportCopy(toFile, TypeLink, copy);
+
+ if (copy) {
+ cmSystemTools::RemoveFile(toFile);
+ cmSystemTools::MakeDirectory(toFilePath);
+
+ if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) {
+ std::ostringstream e;
+ e << this->Name << " cannot create symlink \"" << toFile
+ << "\": " << cmSystemTools::GetLastSystemError() << ".";
+ this->Status.SetError(e.str());
+ return false;
+ }
+ }
+
+ fromFile = newFromFile;
+ toFile = cmStrCat(toFilePath, "/", symlinkTarget);
+ }
+
+ return true;
+}
+
+bool cmFileCopier::InstallSymlink(const std::string& fromFile,
+ const std::string& toFile)
+{
+ // Read the original symlink.
+ std::string symlinkTarget;
+ if (!cmSystemTools::ReadSymlink(fromFile, symlinkTarget)) {
+ std::ostringstream e;
+ e << this->Name << " cannot read symlink \"" << fromFile
+ << "\" to duplicate at \"" << toFile
+ << "\": " << cmSystemTools::GetLastSystemError() << ".";
+ this->Status.SetError(e.str());
+ return false;
+ }
+
+ // Compare the symlink value to that at the destination if not
+ // always installing.
+ bool copy = true;
+ if (!this->Always) {
+ std::string oldSymlinkTarget;
+ if (cmSystemTools::ReadSymlink(toFile, oldSymlinkTarget)) {
+ if (symlinkTarget == oldSymlinkTarget) {
+ copy = false;
+ }
+ }
+ }
+
+ // Inform the user about this file installation.
+ this->ReportCopy(toFile, TypeLink, copy);
+
+ if (copy) {
+ // Remove the destination file so we can always create the symlink.
+ cmSystemTools::RemoveFile(toFile);
+
+ // Create destination directory if it doesn't exist
+ cmSystemTools::MakeDirectory(cmSystemTools::GetFilenamePath(toFile));
+
+ // Create the symlink.
+ if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) {
+ std::ostringstream e;
+ e << this->Name << " cannot duplicate symlink \"" << fromFile
+ << "\" at \"" << toFile
+ << "\": " << cmSystemTools::GetLastSystemError() << ".";
+ this->Status.SetError(e.str());
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool cmFileCopier::InstallFile(const std::string& fromFile,
+ const std::string& toFile,
+ MatchProperties match_properties)
+{
+ // Determine whether we will copy the file.
+ bool copy = true;
+ if (!this->Always) {
+ // If both files exist with the same time do not copy.
+ if (!this->FileTimes.DifferS(fromFile, toFile)) {
+ copy = false;
+ }
+ }
+
+ // Inform the user about this file installation.
+ this->ReportCopy(toFile, TypeFile, copy);
+
+ // Copy the file.
+ if (copy && !cmSystemTools::CopyAFile(fromFile, toFile, true)) {
+ std::ostringstream e;
+ e << this->Name << " cannot copy file \"" << fromFile << "\" to \""
+ << toFile << "\": " << cmSystemTools::GetLastSystemError() << ".";
+ this->Status.SetError(e.str());
+ return false;
+ }
+
+ // Set the file modification time of the destination file.
+ if (copy && !this->Always) {
+ // Add write permission so we can set the file time.
+ // Permissions are set unconditionally below anyway.
+ mode_t perm = 0;
+ if (cmSystemTools::GetPermissions(toFile, perm)) {
+ cmSystemTools::SetPermissions(toFile, perm | mode_owner_write);
+ }
+ if (!cmFileTimes::Copy(fromFile, toFile)) {
+ std::ostringstream e;
+ e << this->Name << " cannot set modification time on \"" << toFile
+ << "\": " << cmSystemTools::GetLastSystemError() << ".";
+ this->Status.SetError(e.str());
+ return false;
+ }
+ }
+
+ // Set permissions of the destination file.
+ mode_t permissions =
+ (match_properties.Permissions ? match_properties.Permissions
+ : this->FilePermissions);
+ if (!permissions) {
+ // No permissions were explicitly provided but the user requested
+ // that the source file permissions be used.
+ cmSystemTools::GetPermissions(fromFile, permissions);
+ }
+ return this->SetPermissions(toFile, permissions);
+}
+
+bool cmFileCopier::InstallDirectory(const std::string& source,
+ const std::string& destination,
+ MatchProperties match_properties)
+{
+ // Inform the user about this directory installation.
+ this->ReportCopy(destination, TypeDir,
+ !cmSystemTools::FileIsDirectory(destination));
+
+ // check if default dir creation permissions were set
+ mode_t default_dir_mode_v = 0;
+ mode_t* default_dir_mode = &default_dir_mode_v;
+ if (!this->GetDefaultDirectoryPermissions(&default_dir_mode)) {
+ return false;
+ }
+
+ // Make sure the destination directory exists.
+ if (!cmSystemTools::MakeDirectory(destination, default_dir_mode)) {
+ std::ostringstream e;
+ e << this->Name << " cannot make directory \"" << destination
+ << "\": " << cmSystemTools::GetLastSystemError() << ".";
+ this->Status.SetError(e.str());
+ return false;
+ }
+
+ // Compute the requested permissions for the destination directory.
+ mode_t permissions =
+ (match_properties.Permissions ? match_properties.Permissions
+ : this->DirPermissions);
+ if (!permissions) {
+ // No permissions were explicitly provided but the user requested
+ // that the source directory permissions be used.
+ cmSystemTools::GetPermissions(source, permissions);
+ }
+
+ // Compute the set of permissions required on this directory to
+ // recursively install files and subdirectories safely.
+ mode_t required_permissions =
+ mode_owner_read | mode_owner_write | mode_owner_execute;
+
+ // If the required permissions are specified it is safe to set the
+ // final permissions now. Otherwise we must add the required
+ // permissions temporarily during file installation.
+ mode_t permissions_before = 0;
+ mode_t permissions_after = 0;
+ if ((permissions & required_permissions) == required_permissions) {
+ permissions_before = permissions;
+ } else {
+ permissions_before = permissions | required_permissions;
+ permissions_after = permissions;
+ }
+
+ // Set the required permissions of the destination directory.
+ if (!this->SetPermissions(destination, permissions_before)) {
+ return false;
+ }
+
+ // Load the directory contents to traverse it recursively.
+ cmsys::Directory dir;
+ if (!source.empty()) {
+ dir.Load(source);
+ }
+ unsigned long numFiles = static_cast<unsigned long>(dir.GetNumberOfFiles());
+ for (unsigned long fileNum = 0; fileNum < numFiles; ++fileNum) {
+ if (!(strcmp(dir.GetFile(fileNum), ".") == 0 ||
+ strcmp(dir.GetFile(fileNum), "..") == 0)) {
+ std::string fromPath = cmStrCat(source, '/', dir.GetFile(fileNum));
+ std::string toPath = cmStrCat(destination, '/', dir.GetFile(fileNum));
+ if (!this->Install(fromPath, toPath)) {
+ return false;
+ }
+ }
+ }
+
+ // Set the requested permissions of the destination directory.
+ return this->SetPermissions(destination, permissions_after);
+}
diff --git a/Source/cmFileCopier.h b/Source/cmFileCopier.h
new file mode 100644
index 000000000..612a57fef
--- /dev/null
+++ b/Source/cmFileCopier.h
@@ -0,0 +1,124 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmFileCopier_h
+#define cmFileCopier_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+#include <vector>
+
+#include "cmsys/RegularExpression.hxx"
+
+#include "cm_sys_stat.h"
+
+#include "cmFileTimeCache.h"
+
+class cmExecutionStatus;
+class cmMakefile;
+
+// File installation helper class.
+struct cmFileCopier
+{
+ cmFileCopier(cmExecutionStatus& status, const char* name = "COPY");
+ virtual ~cmFileCopier();
+
+ bool Run(std::vector<std::string> const& args);
+
+protected:
+ cmExecutionStatus& Status;
+ cmMakefile* Makefile;
+ const char* Name;
+ bool Always;
+ cmFileTimeCache FileTimes;
+
+ // Whether to install a file not matching any expression.
+ bool MatchlessFiles;
+
+ // Permissions for files and directories installed by this object.
+ mode_t FilePermissions;
+ mode_t DirPermissions;
+
+ // Properties set by pattern and regex match rules.
+ struct MatchProperties
+ {
+ bool Exclude = false;
+ mode_t Permissions = 0;
+ };
+ struct MatchRule
+ {
+ cmsys::RegularExpression Regex;
+ MatchProperties Properties;
+ std::string RegexString;
+ MatchRule(std::string const& regex)
+ : Regex(regex)
+ , RegexString(regex)
+ {
+ }
+ };
+ std::vector<MatchRule> MatchRules;
+
+ // Get the properties from rules matching this input file.
+ MatchProperties CollectMatchProperties(const std::string& file);
+
+ bool SetPermissions(const std::string& toFile, mode_t permissions);
+
+ // Translate an argument to a permissions bit.
+ bool CheckPermissions(std::string const& arg, mode_t& permissions);
+
+ bool InstallSymlinkChain(std::string& fromFile, std::string& toFile);
+ bool InstallSymlink(const std::string& fromFile, const std::string& toFile);
+ bool InstallFile(const std::string& fromFile, const std::string& toFile,
+ MatchProperties match_properties);
+ bool InstallDirectory(const std::string& source,
+ const std::string& destination,
+ MatchProperties match_properties);
+ virtual bool Install(const std::string& fromFile, const std::string& toFile);
+ virtual std::string const& ToName(std::string const& fromName);
+
+ enum Type
+ {
+ TypeFile,
+ TypeDir,
+ TypeLink
+ };
+ virtual void ReportCopy(const std::string&, Type, bool) {}
+ virtual bool ReportMissing(const std::string& fromFile);
+
+ MatchRule* CurrentMatchRule;
+ bool UseGivenPermissionsFile;
+ bool UseGivenPermissionsDir;
+ bool UseSourcePermissions;
+ bool FollowSymlinkChain;
+ std::string Destination;
+ std::string FilesFromDir;
+ std::vector<std::string> Files;
+ int Doing;
+
+ virtual bool Parse(std::vector<std::string> const& args);
+ enum
+ {
+ DoingNone,
+ DoingError,
+ DoingDestination,
+ DoingFilesFromDir,
+ DoingFiles,
+ DoingPattern,
+ DoingRegex,
+ DoingPermissionsFile,
+ DoingPermissionsDir,
+ DoingPermissionsMatch,
+ DoingLast1
+ };
+ virtual bool CheckKeyword(std::string const& arg);
+ virtual bool CheckValue(std::string const& arg);
+
+ void NotBeforeMatch(std::string const& arg);
+ void NotAfterMatch(std::string const& arg);
+ virtual void DefaultFilePermissions();
+ virtual void DefaultDirectoryPermissions();
+
+ bool GetDefaultDirectoryPermissions(mode_t** mode);
+};
+
+#endif
diff --git a/Source/cmFileInstaller.cxx b/Source/cmFileInstaller.cxx
new file mode 100644
index 000000000..c89be9628
--- /dev/null
+++ b/Source/cmFileInstaller.cxx
@@ -0,0 +1,351 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmFileInstaller.h"
+
+#include <sstream>
+
+#include "cm_sys_stat.h"
+
+#include "cmExecutionStatus.h"
+#include "cmFSPermissions.h"
+#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+using namespace cmFSPermissions;
+
+cmFileInstaller::cmFileInstaller(cmExecutionStatus& status)
+ : cmFileCopier(status, "INSTALL")
+ , InstallType(cmInstallType_FILES)
+ , Optional(false)
+ , MessageAlways(false)
+ , MessageLazy(false)
+ , MessageNever(false)
+ , DestDirLength(0)
+{
+ // Installation does not use source permissions by default.
+ this->UseSourcePermissions = false;
+ // Check whether to copy files always or only if they have changed.
+ std::string install_always;
+ if (cmSystemTools::GetEnv("CMAKE_INSTALL_ALWAYS", install_always)) {
+ this->Always = cmIsOn(install_always);
+ }
+ // Get the current manifest.
+ this->Manifest =
+ this->Makefile->GetSafeDefinition("CMAKE_INSTALL_MANIFEST_FILES");
+}
+cmFileInstaller::~cmFileInstaller()
+{
+ // Save the updated install manifest.
+ this->Makefile->AddDefinition("CMAKE_INSTALL_MANIFEST_FILES",
+ this->Manifest);
+}
+
+void cmFileInstaller::ManifestAppend(std::string const& file)
+{
+ if (!this->Manifest.empty()) {
+ this->Manifest += ";";
+ }
+ this->Manifest += file.substr(this->DestDirLength);
+}
+
+std::string const& cmFileInstaller::ToName(std::string const& fromName)
+{
+ return this->Rename.empty() ? fromName : this->Rename;
+}
+
+void cmFileInstaller::ReportCopy(const std::string& toFile, Type type,
+ bool copy)
+{
+ if (!this->MessageNever && (copy || !this->MessageLazy)) {
+ std::string message =
+ cmStrCat((copy ? "Installing: " : "Up-to-date: "), toFile);
+ this->Makefile->DisplayStatus(message, -1);
+ }
+ if (type != TypeDir) {
+ // Add the file to the manifest.
+ this->ManifestAppend(toFile);
+ }
+}
+bool cmFileInstaller::ReportMissing(const std::string& fromFile)
+{
+ return (this->Optional || this->cmFileCopier::ReportMissing(fromFile));
+}
+bool cmFileInstaller::Install(const std::string& fromFile,
+ const std::string& toFile)
+{
+ // Support installing from empty source to make a directory.
+ if (this->InstallType == cmInstallType_DIRECTORY && fromFile.empty()) {
+ return this->InstallDirectory(fromFile, toFile, MatchProperties());
+ }
+ return this->cmFileCopier::Install(fromFile, toFile);
+}
+
+void cmFileInstaller::DefaultFilePermissions()
+{
+ this->cmFileCopier::DefaultFilePermissions();
+ // Add execute permissions based on the target type.
+ switch (this->InstallType) {
+ case cmInstallType_SHARED_LIBRARY:
+ case cmInstallType_MODULE_LIBRARY:
+ if (this->Makefile->IsOn("CMAKE_INSTALL_SO_NO_EXE")) {
+ break;
+ }
+ CM_FALLTHROUGH;
+ case cmInstallType_EXECUTABLE:
+ case cmInstallType_PROGRAMS:
+ this->FilePermissions |= mode_owner_execute;
+ this->FilePermissions |= mode_group_execute;
+ this->FilePermissions |= mode_world_execute;
+ break;
+ default:
+ break;
+ }
+}
+
+bool cmFileInstaller::Parse(std::vector<std::string> const& args)
+{
+ if (!this->cmFileCopier::Parse(args)) {
+ return false;
+ }
+
+ if (!this->Rename.empty()) {
+ if (!this->FilesFromDir.empty()) {
+ this->Status.SetError("INSTALL option RENAME may not be "
+ "combined with FILES_FROM_DIR.");
+ return false;
+ }
+ if (this->InstallType != cmInstallType_FILES &&
+ this->InstallType != cmInstallType_PROGRAMS) {
+ this->Status.SetError("INSTALL option RENAME may be used "
+ "only with FILES or PROGRAMS.");
+ return false;
+ }
+ if (this->Files.size() > 1) {
+ this->Status.SetError("INSTALL option RENAME may be used "
+ "only with one file.");
+ return false;
+ }
+ }
+
+ if (!this->HandleInstallDestination()) {
+ return false;
+ }
+
+ if (((this->MessageAlways ? 1 : 0) + (this->MessageLazy ? 1 : 0) +
+ (this->MessageNever ? 1 : 0)) > 1) {
+ this->Status.SetError("INSTALL options MESSAGE_ALWAYS, "
+ "MESSAGE_LAZY, and MESSAGE_NEVER "
+ "are mutually exclusive.");
+ return false;
+ }
+
+ return true;
+}
+
+bool cmFileInstaller::CheckKeyword(std::string const& arg)
+{
+ if (arg == "TYPE") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingType;
+ }
+ } else if (arg == "FILES") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingFiles;
+ }
+ } else if (arg == "RENAME") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingRename;
+ }
+ } else if (arg == "OPTIONAL") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingNone;
+ this->Optional = true;
+ }
+ } else if (arg == "MESSAGE_ALWAYS") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingNone;
+ this->MessageAlways = true;
+ }
+ } else if (arg == "MESSAGE_LAZY") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingNone;
+ this->MessageLazy = true;
+ }
+ } else if (arg == "MESSAGE_NEVER") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ this->Doing = DoingNone;
+ this->MessageNever = true;
+ }
+ } else if (arg == "PERMISSIONS") {
+ if (this->CurrentMatchRule) {
+ this->Doing = DoingPermissionsMatch;
+ } else {
+ // file(INSTALL) aliases PERMISSIONS to FILE_PERMISSIONS
+ this->Doing = DoingPermissionsFile;
+ this->UseGivenPermissionsFile = true;
+ }
+ } else if (arg == "DIR_PERMISSIONS") {
+ if (this->CurrentMatchRule) {
+ this->NotAfterMatch(arg);
+ } else {
+ // file(INSTALL) aliases DIR_PERMISSIONS to DIRECTORY_PERMISSIONS
+ this->Doing = DoingPermissionsDir;
+ this->UseGivenPermissionsDir = true;
+ }
+ } else if (arg == "COMPONENTS" || arg == "CONFIGURATIONS" ||
+ arg == "PROPERTIES") {
+ std::ostringstream e;
+ e << "INSTALL called with old-style " << arg << " argument. "
+ << "This script was generated with an older version of CMake. "
+ << "Re-run this cmake version on your build tree.";
+ this->Status.SetError(e.str());
+ this->Doing = DoingError;
+ } else {
+ return this->cmFileCopier::CheckKeyword(arg);
+ }
+ return true;
+}
+
+bool cmFileInstaller::CheckValue(std::string const& arg)
+{
+ switch (this->Doing) {
+ case DoingType:
+ if (!this->GetTargetTypeFromString(arg)) {
+ this->Doing = DoingError;
+ }
+ break;
+ case DoingRename:
+ this->Rename = arg;
+ break;
+ default:
+ return this->cmFileCopier::CheckValue(arg);
+ }
+ return true;
+}
+
+bool cmFileInstaller::GetTargetTypeFromString(const std::string& stype)
+{
+ if (stype == "EXECUTABLE") {
+ this->InstallType = cmInstallType_EXECUTABLE;
+ } else if (stype == "FILE") {
+ this->InstallType = cmInstallType_FILES;
+ } else if (stype == "PROGRAM") {
+ this->InstallType = cmInstallType_PROGRAMS;
+ } else if (stype == "STATIC_LIBRARY") {
+ this->InstallType = cmInstallType_STATIC_LIBRARY;
+ } else if (stype == "SHARED_LIBRARY") {
+ this->InstallType = cmInstallType_SHARED_LIBRARY;
+ } else if (stype == "MODULE") {
+ this->InstallType = cmInstallType_MODULE_LIBRARY;
+ } else if (stype == "DIRECTORY") {
+ this->InstallType = cmInstallType_DIRECTORY;
+ } else {
+ std::ostringstream e;
+ e << "Option TYPE given unknown value \"" << stype << "\".";
+ this->Status.SetError(e.str());
+ return false;
+ }
+ return true;
+}
+
+bool cmFileInstaller::HandleInstallDestination()
+{
+ std::string& destination = this->Destination;
+
+ // allow for / to be a valid destination
+ if (destination.size() < 2 && destination != "/") {
+ this->Status.SetError("called with inappropriate arguments. "
+ "No DESTINATION provided or .");
+ return false;
+ }
+
+ std::string sdestdir;
+ if (cmSystemTools::GetEnv("DESTDIR", sdestdir) && !sdestdir.empty()) {
+ cmSystemTools::ConvertToUnixSlashes(sdestdir);
+ char ch1 = destination[0];
+ char ch2 = destination[1];
+ char ch3 = 0;
+ if (destination.size() > 2) {
+ ch3 = destination[2];
+ }
+ int skip = 0;
+ if (ch1 != '/') {
+ int relative = 0;
+ if (((ch1 >= 'a' && ch1 <= 'z') || (ch1 >= 'A' && ch1 <= 'Z')) &&
+ ch2 == ':') {
+ // Assume windows
+ // let's do some destdir magic:
+ skip = 2;
+ if (ch3 != '/') {
+ relative = 1;
+ }
+ } else {
+ relative = 1;
+ }
+ if (relative) {
+ // This is relative path on unix or windows. Since we are doing
+ // destdir, this case does not make sense.
+ this->Status.SetError(
+ "called with relative DESTINATION. This "
+ "does not make sense when using DESTDIR. Specify "
+ "absolute path or remove DESTDIR environment variable.");
+ return false;
+ }
+ } else {
+ if (ch2 == '/') {
+ // looks like a network path.
+ std::string message =
+ cmStrCat("called with network path DESTINATION. This "
+ "does not make sense when using DESTDIR. Specify local "
+ "absolute path or remove DESTDIR environment variable."
+ "\nDESTINATION=\n",
+ destination);
+ this->Status.SetError(message);
+ return false;
+ }
+ }
+ destination = sdestdir + destination.substr(skip);
+ this->DestDirLength = int(sdestdir.size());
+ }
+
+ // check if default dir creation permissions were set
+ mode_t default_dir_mode_v = 0;
+ mode_t* default_dir_mode = &default_dir_mode_v;
+ if (!this->GetDefaultDirectoryPermissions(&default_dir_mode)) {
+ return false;
+ }
+
+ if (this->InstallType != cmInstallType_DIRECTORY) {
+ if (!cmSystemTools::FileExists(destination)) {
+ if (!cmSystemTools::MakeDirectory(destination, default_dir_mode)) {
+ std::string errstring = "cannot create directory: " + destination +
+ ". Maybe need administrative privileges.";
+ this->Status.SetError(errstring);
+ return false;
+ }
+ }
+ if (!cmSystemTools::FileIsDirectory(destination)) {
+ std::string errstring =
+ "INSTALL destination: " + destination + " is not a directory.";
+ this->Status.SetError(errstring);
+ return false;
+ }
+ }
+ return true;
+}
diff --git a/Source/cmFileInstaller.h b/Source/cmFileInstaller.h
new file mode 100644
index 000000000..537cd53cb
--- /dev/null
+++ b/Source/cmFileInstaller.h
@@ -0,0 +1,54 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmFileInstaller_h
+#define cmFileInstaller_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+#include <vector>
+
+#include "cmFileCopier.h"
+#include "cmInstallType.h"
+
+class cmExecutionStatus;
+
+struct cmFileInstaller : public cmFileCopier
+{
+ cmFileInstaller(cmExecutionStatus& status);
+ ~cmFileInstaller() override;
+
+protected:
+ cmInstallType InstallType;
+ bool Optional;
+ bool MessageAlways;
+ bool MessageLazy;
+ bool MessageNever;
+ int DestDirLength;
+ std::string Rename;
+
+ std::string Manifest;
+ void ManifestAppend(std::string const& file);
+
+ std::string const& ToName(std::string const& fromName) override;
+
+ void ReportCopy(const std::string& toFile, Type type, bool copy) override;
+ bool ReportMissing(const std::string& fromFile) override;
+ bool Install(const std::string& fromFile,
+ const std::string& toFile) override;
+
+ bool Parse(std::vector<std::string> const& args) override;
+ enum
+ {
+ DoingType = DoingLast1,
+ DoingRename,
+ DoingLast2
+ };
+ bool CheckKeyword(std::string const& arg) override;
+ bool CheckValue(std::string const& arg) override;
+ void DefaultFilePermissions() override;
+ bool GetTargetTypeFromString(const std::string& stype);
+ bool HandleInstallDestination();
+};
+
+#endif
diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx
index 786d6c63f..e90f57140 100644
--- a/Source/cmFileLock.cxx
+++ b/Source/cmFileLock.cxx
@@ -2,8 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFileLock.h"
+#include <cassert>
+
#include "cmFileLockResult.h"
-#include <assert.h>
// Common implementation
@@ -42,7 +43,7 @@ cmFileLockResult cmFileLock::Lock(const std::string& filename,
}
if (!result.IsOk()) {
- this->Filename = "";
+ this->Filename.clear();
}
return result;
@@ -54,7 +55,7 @@ bool cmFileLock::IsLocked(const std::string& filename) const
}
#if defined(_WIN32)
-#include "cmFileLockWin32.cxx"
+# include "cmFileLockWin32.cxx"
#else
-#include "cmFileLockUnix.cxx"
+# include "cmFileLockUnix.cxx"
#endif
diff --git a/Source/cmFileLock.h b/Source/cmFileLock.h
index ccef50816..2130d65db 100644
--- a/Source/cmFileLock.h
+++ b/Source/cmFileLock.h
@@ -3,46 +3,47 @@
#ifndef cmFileLock_h
#define cmFileLock_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#if defined(_WIN32)
-#include <windows.h> // HANDLE
+# include <windows.h> // HANDLE
#endif
class cmFileLockResult;
/**
- * @brief Cross-platform file locking.
- * @details Under the hood this class use 'fcntl' for Unix-like platforms and
- * 'LockFileEx'/'UnlockFileEx' for Win32 platform. Locks are exclusive and
- * advisory.
- */
+ * @brief Cross-platform file locking.
+ * @details Under the hood this class use 'fcntl' for Unix-like platforms and
+ * 'LockFileEx'/'UnlockFileEx' for Win32 platform. Locks are exclusive and
+ * advisory.
+ */
class cmFileLock
{
- CM_DISABLE_COPY(cmFileLock)
-
public:
cmFileLock();
~cmFileLock();
+ cmFileLock(cmFileLock const&) = delete;
+ cmFileLock& operator=(cmFileLock const&) = delete;
+
/**
- * @brief Lock the file.
- * @param timeoutSec Lock timeout. If -1 try until success or fatal error.
- */
+ * @brief Lock the file.
+ * @param timeoutSec Lock timeout. If -1 try until success or fatal error.
+ */
cmFileLockResult Lock(const std::string& filename, unsigned long timeoutSec);
/**
- * @brief Unlock the file.
- */
+ * @brief Unlock the file.
+ */
cmFileLockResult Release();
/**
- * @brief Check file is locked by this class.
- * @details This function helps to find double locks (deadlocks) and to do
- * explicit unlocks.
- */
+ * @brief Check file is locked by this class.
+ * @details This function helps to find double locks (deadlocks) and to do
+ * explicit unlocks.
+ */
bool IsLocked(const std::string& filename) const;
private:
@@ -51,14 +52,13 @@ private:
cmFileLockResult LockWithTimeout(unsigned long timeoutSec);
#if defined(_WIN32)
- typedef HANDLE FileId;
+ HANDLE File = INVALID_HANDLE_VALUE;
BOOL LockFile(DWORD flags);
#else
- typedef int FileId;
+ int File = -1;
int LockFile(int cmd, int type);
#endif
- FileId File;
std::string Filename;
};
diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx
index 7b1564c34..8db2db210 100644
--- a/Source/cmFileLockPool.cxx
+++ b/Source/cmFileLockPool.cxx
@@ -2,15 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFileLockPool.h"
-#include <assert.h>
+#include <cassert>
#include "cmAlgorithms.h"
#include "cmFileLock.h"
#include "cmFileLockResult.h"
-cmFileLockPool::cmFileLockPool()
-{
-}
+cmFileLockPool::cmFileLockPool() = default;
cmFileLockPool::~cmFileLockPool()
{
@@ -75,16 +73,15 @@ cmFileLockResult cmFileLockPool::LockProcessScope(const std::string& filename,
cmFileLockResult cmFileLockPool::Release(const std::string& filename)
{
- for (It i = this->FunctionScopes.begin(); i != this->FunctionScopes.end();
- ++i) {
- const cmFileLockResult result = (*i)->Release(filename);
+ for (auto& funcScope : this->FunctionScopes) {
+ const cmFileLockResult result = funcScope->Release(filename);
if (!result.IsOk()) {
return result;
}
}
- for (It i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i) {
- const cmFileLockResult result = (*i)->Release(filename);
+ for (auto& fileScope : this->FileScopes) {
+ const cmFileLockResult result = fileScope->Release(filename);
if (!result.IsOk()) {
return result;
}
@@ -95,16 +92,15 @@ cmFileLockResult cmFileLockPool::Release(const std::string& filename)
bool cmFileLockPool::IsAlreadyLocked(const std::string& filename) const
{
- for (CIt i = this->FunctionScopes.begin(); i != this->FunctionScopes.end();
- ++i) {
- const bool result = (*i)->IsAlreadyLocked(filename);
+ for (auto const& funcScope : this->FunctionScopes) {
+ const bool result = funcScope->IsAlreadyLocked(filename);
if (result) {
return true;
}
}
- for (CIt i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i) {
- const bool result = (*i)->IsAlreadyLocked(filename);
+ for (auto const& fileScope : this->FileScopes) {
+ const bool result = fileScope->IsAlreadyLocked(filename);
if (result) {
return true;
}
@@ -113,9 +109,7 @@ bool cmFileLockPool::IsAlreadyLocked(const std::string& filename) const
return this->ProcessScope.IsAlreadyLocked(filename);
}
-cmFileLockPool::ScopePool::ScopePool()
-{
-}
+cmFileLockPool::ScopePool::ScopePool() = default;
cmFileLockPool::ScopePool::~ScopePool()
{
@@ -138,9 +132,9 @@ cmFileLockResult cmFileLockPool::ScopePool::Lock(const std::string& filename,
cmFileLockResult cmFileLockPool::ScopePool::Release(
const std::string& filename)
{
- for (It i = this->Locks.begin(); i != this->Locks.end(); ++i) {
- if ((*i)->IsLocked(filename)) {
- return (*i)->Release();
+ for (auto& lock : this->Locks) {
+ if (lock->IsLocked(filename)) {
+ return lock->Release();
}
}
return cmFileLockResult::MakeOk();
@@ -149,8 +143,8 @@ cmFileLockResult cmFileLockPool::ScopePool::Release(
bool cmFileLockPool::ScopePool::IsAlreadyLocked(
const std::string& filename) const
{
- for (CIt i = this->Locks.begin(); i != this->Locks.end(); ++i) {
- if ((*i)->IsLocked(filename)) {
+ for (auto const& lock : this->Locks) {
+ if (lock->IsLocked(filename)) {
return true;
}
}
diff --git a/Source/cmFileLockPool.h b/Source/cmFileLockPool.h
index c96a8c2f8..dae68dd01 100644
--- a/Source/cmFileLockPool.h
+++ b/Source/cmFileLockPool.h
@@ -3,7 +3,7 @@
#ifndef cmFileLockPool_h
#define cmFileLockPool_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
@@ -13,33 +13,34 @@ class cmFileLockResult;
class cmFileLockPool
{
- CM_DISABLE_COPY(cmFileLockPool)
-
public:
cmFileLockPool();
~cmFileLockPool();
+ cmFileLockPool(cmFileLockPool const&) = delete;
+ cmFileLockPool& operator=(cmFileLockPool const&) = delete;
+
//@{
/**
- * @brief Function scope control.
- */
+ * @brief Function scope control.
+ */
void PushFunctionScope();
void PopFunctionScope();
//@}
//@{
/**
- * @brief File scope control.
- */
+ * @brief File scope control.
+ */
void PushFileScope();
void PopFileScope();
//@}
//@{
/**
- * @brief Lock the file in given scope.
- * @param timeoutSec Lock timeout. If -1 try until success or fatal error.
- */
+ * @brief Lock the file in given scope.
+ * @param timeoutSec Lock timeout. If -1 try until success or fatal error.
+ */
cmFileLockResult LockFunctionScope(const std::string& filename,
unsigned long timeoutSec);
cmFileLockResult LockFileScope(const std::string& filename,
@@ -49,8 +50,8 @@ public:
//@}
/**
- * @brief Unlock the file explicitly.
- */
+ * @brief Unlock the file explicitly.
+ */
cmFileLockResult Release(const std::string& filename);
private:
@@ -58,29 +59,30 @@ private:
class ScopePool
{
- CM_DISABLE_COPY(ScopePool)
-
public:
ScopePool();
~ScopePool();
+ ScopePool(ScopePool const&) = delete;
+ ScopePool& operator=(ScopePool const&) = delete;
+
cmFileLockResult Lock(const std::string& filename,
unsigned long timeoutSec);
cmFileLockResult Release(const std::string& filename);
bool IsAlreadyLocked(const std::string& filename) const;
private:
- typedef std::vector<cmFileLock*> List;
- typedef List::iterator It;
- typedef List::const_iterator CIt;
+ using List = std::vector<cmFileLock*>;
+ using It = List::iterator;
+ using CIt = List::const_iterator;
List Locks;
};
- typedef std::vector<ScopePool*> List;
+ using List = std::vector<ScopePool*>;
- typedef List::iterator It;
- typedef List::const_iterator CIt;
+ using It = List::iterator;
+ using CIt = List::const_iterator;
List FunctionScopes;
List FileScopes;
diff --git a/Source/cmFileLockResult.cxx b/Source/cmFileLockResult.cxx
index a040705e8..9d5a6c67a 100644
--- a/Source/cmFileLockResult.cxx
+++ b/Source/cmFileLockResult.cxx
@@ -2,12 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFileLockResult.h"
-#include <errno.h>
-#include <string.h>
+#include <cerrno>
+#include <cstring>
+#define WINMSG_BUF_LEN (1024)
cmFileLockResult cmFileLockResult::MakeOk()
{
- return cmFileLockResult(OK, 0);
+ return { OK, 0 };
}
cmFileLockResult cmFileLockResult::MakeSystem()
@@ -17,27 +18,27 @@ cmFileLockResult cmFileLockResult::MakeSystem()
#else
const Error lastError = errno;
#endif
- return cmFileLockResult(SYSTEM, lastError);
+ return { SYSTEM, lastError };
}
cmFileLockResult cmFileLockResult::MakeTimeout()
{
- return cmFileLockResult(TIMEOUT, 0);
+ return { TIMEOUT, 0 };
}
cmFileLockResult cmFileLockResult::MakeAlreadyLocked()
{
- return cmFileLockResult(ALREADY_LOCKED, 0);
+ return { ALREADY_LOCKED, 0 };
}
cmFileLockResult cmFileLockResult::MakeInternal()
{
- return cmFileLockResult(INTERNAL, 0);
+ return { INTERNAL, 0 };
}
cmFileLockResult cmFileLockResult::MakeNoFunction()
{
- return cmFileLockResult(NO_FUNCTION, 0);
+ return { NO_FUNCTION, 0 };
}
bool cmFileLockResult::IsOk() const
@@ -53,18 +54,12 @@ std::string cmFileLockResult::GetOutputMessage() const
case SYSTEM:
#if defined(_WIN32)
{
- char* errorText = NULL;
-
- // http://stackoverflow.com/a/455533/2288008
- DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS;
- ::FormatMessageA(flags, NULL, this->ErrorValue,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPSTR)&errorText, 0, NULL);
-
- if (errorText != NULL) {
- const std::string message = errorText;
- ::LocalFree(errorText);
+ char winmsg[WINMSG_BUF_LEN];
+ DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS;
+ if (FormatMessageA(flags, NULL, this->ErrorValue,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPSTR)winmsg, WINMSG_BUF_LEN, NULL)) {
+ const std::string message = winmsg;
return message;
} else {
return "Internal error (FormatMessageA failed)";
diff --git a/Source/cmFileLockResult.h b/Source/cmFileLockResult.h
index 4cedc0ae6..81c19064d 100644
--- a/Source/cmFileLockResult.h
+++ b/Source/cmFileLockResult.h
@@ -8,50 +8,50 @@
#include <string>
#if defined(_WIN32)
-#include <windows.h> // DWORD
+# include <windows.h> // DWORD
#endif
/**
- * @brief Result of the locking/unlocking file.
- * @note See @c cmFileLock
- */
+ * @brief Result of the locking/unlocking file.
+ * @note See @c cmFileLock
+ */
class cmFileLockResult
{
public:
#if defined(_WIN32)
- typedef DWORD Error;
+ using Error = DWORD;
#else
- typedef int Error;
+ using Error = int;
#endif
/**
- * @brief Successful lock/unlock.
- */
+ * @brief Successful lock/unlock.
+ */
static cmFileLockResult MakeOk();
/**
- * @brief Lock/Unlock failed. Read error/GetLastError.
- */
+ * @brief Lock/Unlock failed. Read error/GetLastError.
+ */
static cmFileLockResult MakeSystem();
/**
- * @brief Lock/Unlock failed. Timeout reached.
- */
+ * @brief Lock/Unlock failed. Timeout reached.
+ */
static cmFileLockResult MakeTimeout();
/**
- * @brief File already locked.
- */
+ * @brief File already locked.
+ */
static cmFileLockResult MakeAlreadyLocked();
/**
- * @brief Internal error.
- */
+ * @brief Internal error.
+ */
static cmFileLockResult MakeInternal();
/**
- * @brief Try to lock with function guard outside of the function
- */
+ * @brief Try to lock with function guard outside of the function
+ */
static cmFileLockResult MakeNoFunction();
bool IsOk() const;
diff --git a/Source/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx
index 7353b01fc..1456ea8c1 100644
--- a/Source/cmFileLockUnix.cxx
+++ b/Source/cmFileLockUnix.cxx
@@ -1,17 +1,15 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmFileLock.h"
+#include <cerrno> // errno
+#include <cstdio> // SEEK_SET
-#include "cmSystemTools.h"
-#include <errno.h> // errno
#include <fcntl.h>
-#include <stdio.h> // SEEK_SET
#include <unistd.h>
-cmFileLock::cmFileLock()
- : File(-1)
-{
-}
+#include "cmFileLock.h"
+#include "cmSystemTools.h"
+
+cmFileLock::cmFileLock() = default;
cmFileLockResult cmFileLock::Release()
{
diff --git a/Source/cmFileLockWin32.cxx b/Source/cmFileLockWin32.cxx
index 51ac24993..b8e435aa5 100644
--- a/Source/cmFileLockWin32.cxx
+++ b/Source/cmFileLockWin32.cxx
@@ -1,12 +1,11 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmFileLock.h"
+#include <windows.h> // CreateFileW
+#include "cmFileLock.h"
#include "cmSystemTools.h"
-#include <windows.h> // CreateFileW
cmFileLock::cmFileLock()
- : File(INVALID_HANDLE_VALUE)
{
}
diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx
index 80275357c..ac8a37eee 100644
--- a/Source/cmFileMonitor.cxx
+++ b/Source/cmFileMonitor.cxx
@@ -2,14 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFileMonitor.h"
-#include "cmAlgorithms.h"
-#include "cmsys/SystemTools.hxx"
-
#include <cassert>
-#include <stddef.h>
+#include <cstddef>
#include <unordered_map>
#include <utility>
+#include "cmsys/SystemTools.hxx"
+
+#include "cmAlgorithms.h"
+
namespace {
void on_directory_change(uv_fs_event_t* handle, const char* filename,
int events, int status);
@@ -19,7 +20,6 @@ void on_fs_close(uv_handle_t* handle);
class cmIBaseWatcher
{
public:
- cmIBaseWatcher() = default;
virtual ~cmIBaseWatcher() = default;
virtual void Trigger(const std::string& pathSegment, int events,
@@ -49,8 +49,8 @@ public:
int status) const final
{
if (pathSegment.empty()) {
- for (const auto& i : this->Children) {
- i.second->Trigger(std::string(), events, status);
+ for (auto const& child : this->Children) {
+ child.second->Trigger(std::string(), events, status);
}
} else {
const auto i = this->Children.find(pathSegment);
@@ -62,24 +62,24 @@ public:
void StartWatching() override
{
- for (const auto& i : this->Children) {
- i.second->StartWatching();
+ for (auto const& child : this->Children) {
+ child.second->StartWatching();
}
}
void StopWatching() override
{
- for (const auto& i : this->Children) {
- i.second->StopWatching();
+ for (auto const& child : this->Children) {
+ child.second->StopWatching();
}
}
std::vector<std::string> WatchedFiles() const final
{
std::vector<std::string> result;
- for (const auto& i : this->Children) {
- for (const auto& j : i.second->WatchedFiles()) {
- result.push_back(j);
+ for (auto const& child : this->Children) {
+ for (std::string const& f : child.second->WatchedFiles()) {
+ result.push_back(f);
}
}
return result;
@@ -88,9 +88,9 @@ public:
std::vector<std::string> WatchedDirectories() const override
{
std::vector<std::string> result;
- for (const auto& i : this->Children) {
- for (const auto& j : i.second->WatchedDirectories()) {
- result.push_back(j);
+ for (auto const& child : this->Children) {
+ for (std::string const& dir : child.second->WatchedDirectories()) {
+ result.push_back(dir);
}
}
return result;
@@ -150,11 +150,6 @@ public:
p->AddChildWatcher(ps, this);
}
- ~cmRealDirectoryWatcher() override
- {
- // Handle is freed via uv_handle_close callback!
- }
-
void StartWatching() final
{
if (!this->Handle) {
@@ -171,7 +166,9 @@ public:
{
if (this->Handle) {
uv_fs_event_stop(this->Handle);
- uv_close(reinterpret_cast<uv_handle_t*>(this->Handle), &on_fs_close);
+ if (!uv_is_closing(reinterpret_cast<uv_handle_t*>(this->Handle))) {
+ uv_close(reinterpret_cast<uv_handle_t*>(this->Handle), &on_fs_close);
+ }
this->Handle = nullptr;
}
cmVirtualDirectoryWatcher::StopWatching();
@@ -182,8 +179,9 @@ public:
std::vector<std::string> WatchedDirectories() const override
{
std::vector<std::string> result = { Path() };
- for (const auto& j : cmVirtualDirectoryWatcher::WatchedDirectories()) {
- result.push_back(j);
+ for (std::string const& dir :
+ cmVirtualDirectoryWatcher::WatchedDirectories()) {
+ result.push_back(dir);
}
return result;
}
@@ -265,7 +263,7 @@ public:
static_cast<void>(ps);
const std::string path = this->Path();
- for (const auto& cb : this->CbList) {
+ for (cmFileMonitor::Callback const& cb : this->CbList) {
cb(path, events, status);
}
}
@@ -309,9 +307,10 @@ cmFileMonitor::~cmFileMonitor()
void cmFileMonitor::MonitorPaths(const std::vector<std::string>& paths,
Callback const& cb)
{
- for (const auto& p : paths) {
+ for (std::string const& p : paths) {
std::vector<std::string> pathSegments;
cmsys::SystemTools::SplitPath(p, pathSegments, true);
+ const bool pathIsFile = !cmsys::SystemTools::FileIsDirectory(p);
const size_t segmentCount = pathSegments.size();
if (segmentCount < 2) { // Expect at least rootdir and filename
@@ -321,7 +320,7 @@ void cmFileMonitor::MonitorPaths(const std::vector<std::string>& paths,
for (size_t i = 0; i < segmentCount; ++i) {
assert(currentWatcher);
- const bool fileSegment = (i == segmentCount - 1);
+ const bool fileSegment = (i == segmentCount - 1 && pathIsFile);
const bool rootSegment = (i == 0);
assert(
!(fileSegment &&
diff --git a/Source/cmFileMonitor.h b/Source/cmFileMonitor.h
index d7ec92a17..7ffc9294e 100644
--- a/Source/cmFileMonitor.h
+++ b/Source/cmFileMonitor.h
@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <functional>
#include <string>
@@ -14,12 +14,14 @@ class cmRootWatcher;
class cmFileMonitor
{
- CM_DISABLE_COPY(cmFileMonitor)
public:
cmFileMonitor(uv_loop_t* l);
~cmFileMonitor();
+ cmFileMonitor(cmFileMonitor const&) = delete;
+ cmFileMonitor& operator=(cmFileMonitor const&) = delete;
+
using Callback = std::function<void(const std::string&, int, int)>;
void MonitorPaths(const std::vector<std::string>& paths, Callback const& cb);
void StopMonitoring();
diff --git a/Source/cmFilePathChecksum.cxx b/Source/cmFilePathChecksum.cxx
index 62f52e590..bb3f610d1 100644
--- a/Source/cmFilePathChecksum.cxx
+++ b/Source/cmFilePathChecksum.cxx
@@ -2,21 +2,19 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFilePathChecksum.h"
+#include <vector>
+
#include "cmBase32.h"
#include "cmCryptoHash.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
-#include <vector>
-
-cmFilePathChecksum::cmFilePathChecksum()
-{
-}
+cmFilePathChecksum::cmFilePathChecksum() = default;
-cmFilePathChecksum::cmFilePathChecksum(const std::string& currentSrcDir,
- const std::string& currentBinDir,
- const std::string& projectSrcDir,
- const std::string& projectBinDir)
+cmFilePathChecksum::cmFilePathChecksum(std::string const& currentSrcDir,
+ std::string const& currentBinDir,
+ std::string const& projectSrcDir,
+ std::string const& projectBinDir)
{
setupParentDirs(currentSrcDir, currentBinDir, projectSrcDir, projectBinDir);
}
@@ -29,36 +27,35 @@ cmFilePathChecksum::cmFilePathChecksum(cmMakefile* makefile)
makefile->GetHomeOutputDirectory());
}
-void cmFilePathChecksum::setupParentDirs(const std::string& currentSrcDir,
- const std::string& currentBinDir,
- const std::string& projectSrcDir,
- const std::string& projectBinDir)
+void cmFilePathChecksum::setupParentDirs(std::string const& currentSrcDir,
+ std::string const& currentBinDir,
+ std::string const& projectSrcDir,
+ std::string const& projectBinDir)
{
- parentDirs[0].first = cmsys::SystemTools::GetRealPath(currentSrcDir);
- parentDirs[1].first = cmsys::SystemTools::GetRealPath(currentBinDir);
- parentDirs[2].first = cmsys::SystemTools::GetRealPath(projectSrcDir);
- parentDirs[3].first = cmsys::SystemTools::GetRealPath(projectBinDir);
+ this->parentDirs[0].first = cmSystemTools::GetRealPath(currentSrcDir);
+ this->parentDirs[1].first = cmSystemTools::GetRealPath(currentBinDir);
+ this->parentDirs[2].first = cmSystemTools::GetRealPath(projectSrcDir);
+ this->parentDirs[3].first = cmSystemTools::GetRealPath(projectBinDir);
- parentDirs[0].second = "CurrentSource";
- parentDirs[1].second = "CurrentBinary";
- parentDirs[2].second = "ProjectSource";
- parentDirs[3].second = "ProjectBinary";
+ this->parentDirs[0].second = "CurrentSource";
+ this->parentDirs[1].second = "CurrentBinary";
+ this->parentDirs[2].second = "ProjectSource";
+ this->parentDirs[3].second = "ProjectBinary";
}
-std::string cmFilePathChecksum::get(const std::string& filePath) const
+std::string cmFilePathChecksum::get(std::string const& filePath) const
{
std::string relPath;
std::string relSeed;
{
- const std::string fileReal = cmsys::SystemTools::GetRealPath(filePath);
+ std::string const fileReal = cmSystemTools::GetRealPath(filePath);
std::string parentDir;
// Find closest project parent directory
- for (size_t ii = 0; ii != numParentDirs; ++ii) {
- const std::string& pDir = parentDirs[ii].first;
- if (!pDir.empty() &&
- cmsys::SystemTools::IsSubDirectory(fileReal, pDir)) {
- relSeed = parentDirs[ii].second;
- parentDir = pDir;
+ for (auto const& pDir : this->parentDirs) {
+ if (!pDir.first.empty() &&
+ cmsys::SystemTools::IsSubDirectory(fileReal, pDir.first)) {
+ parentDir = pDir.first;
+ relSeed = pDir.second;
break;
}
}
@@ -77,11 +74,11 @@ std::string cmFilePathChecksum::get(const std::string& filePath) const
cmCryptoHash(cmCryptoHash::AlgoSHA256).ByteHashString(relSeed + relPath);
// Convert binary checksum to string
- return cmBase32Encoder().encodeString(&hashBytes[0], hashBytes.size(),
+ return cmBase32Encoder().encodeString(hashBytes.data(), hashBytes.size(),
false);
}
-std::string cmFilePathChecksum::getPart(const std::string& filePath,
+std::string cmFilePathChecksum::getPart(std::string const& filePath,
size_t length) const
{
return get(filePath).substr(0, length);
diff --git a/Source/cmFilePathChecksum.h b/Source/cmFilePathChecksum.h
index 9d570eb4d..b7d5cd24c 100644
--- a/Source/cmFilePathChecksum.h
+++ b/Source/cmFilePathChecksum.h
@@ -5,7 +5,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <stddef.h>
+#include <array>
+#include <cstddef>
#include <string>
#include <utility>
@@ -28,38 +29,36 @@ public:
/// @brief Parent directories are empty
cmFilePathChecksum();
- /// @brief Initilizes the parent directories manually
- cmFilePathChecksum(const std::string& currentSrcDir,
- const std::string& currentBinDir,
- const std::string& projectSrcDir,
- const std::string& projectBinDir);
+ /// @brief Initializes the parent directories manually
+ cmFilePathChecksum(std::string const& currentSrcDir,
+ std::string const& currentBinDir,
+ std::string const& projectSrcDir,
+ std::string const& projectBinDir);
- /// @brief Initilizes the parent directories from a makefile
+ /// @brief Initializes the parent directories from a makefile
cmFilePathChecksum(cmMakefile* makefile);
/// @brief Allows parent directories setup after construction
///
- void setupParentDirs(const std::string& currentSrcDir,
- const std::string& currentBinDir,
- const std::string& projectSrcDir,
- const std::string& projectBinDir);
+ void setupParentDirs(std::string const& currentSrcDir,
+ std::string const& currentBinDir,
+ std::string const& projectSrcDir,
+ std::string const& projectBinDir);
/* @brief Calculates the path checksum for the parent directory of a file
*
*/
- std::string get(const std::string& filePath) const;
+ std::string get(std::string const& filePath) const;
/* @brief Same as get() but returns only the first length characters
*
*/
- std::string getPart(const std::string& filePath,
+ std::string getPart(std::string const& filePath,
size_t length = partLengthDefault) const;
private:
- /// Size of the parent directory list
- static const size_t numParentDirs = 4;
/// List of (directory name, seed name) pairs
- std::pair<std::string, std::string> parentDirs[numParentDirs];
+ std::array<std::pair<std::string, std::string>, 4> parentDirs;
};
#endif
diff --git a/Source/cmFileTime.cxx b/Source/cmFileTime.cxx
new file mode 100644
index 000000000..96c70fef6
--- /dev/null
+++ b/Source/cmFileTime.cxx
@@ -0,0 +1,50 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmFileTime.h"
+
+#include <ctime>
+#include <string>
+
+// Use a platform-specific API to get file times efficiently.
+#if !defined(_WIN32) || defined(__CYGWIN__)
+# include "cm_sys_stat.h"
+#else
+# include <windows.h>
+
+# include "cmsys/Encoding.hxx"
+#endif
+
+bool cmFileTime::Load(std::string const& fileName)
+{
+#if !defined(_WIN32) || defined(__CYGWIN__)
+ // POSIX version. Use the stat function.
+ struct stat fst;
+ if (::stat(fileName.c_str(), &fst) != 0) {
+ return false;
+ }
+# if CMake_STAT_HAS_ST_MTIM
+ // Nanosecond resolution
+ this->NS = fst.st_mtim.tv_sec * NsPerS + fst.st_mtim.tv_nsec;
+# elif CMake_STAT_HAS_ST_MTIMESPEC
+ // Nanosecond resolution
+ this->NS = fst.st_mtimespec.tv_sec * NsPerS + fst.st_mtimespec.tv_nsec;
+# else
+ // Second resolution
+ this->NS = fst.st_mtime * NsPerS;
+# endif
+#else
+ // Windows version. Get the modification time from extended file attributes.
+ WIN32_FILE_ATTRIBUTE_DATA fdata;
+ if (!GetFileAttributesExW(cmsys::Encoding::ToWide(fileName).c_str(),
+ GetFileExInfoStandard, &fdata)) {
+ return false;
+ }
+
+ // Copy the file time to the output location.
+ this->NS = (static_cast<NSC>(fdata.ftLastWriteTime.dwHighDateTime) << 32) |
+ static_cast<NSC>(fdata.ftLastWriteTime.dwLowDateTime);
+ // The file time resolution is 100 ns.
+ this->NS *= 100;
+#endif
+ return true;
+}
diff --git a/Source/cmFileTime.h b/Source/cmFileTime.h
new file mode 100644
index 000000000..e9a85598a
--- /dev/null
+++ b/Source/cmFileTime.h
@@ -0,0 +1,130 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmFileTime_h
+#define cmFileTime_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+
+/** \class cmFileTime
+ * \brief Abstract file modification time with support for comparison with
+ * other file modification times.
+ */
+class cmFileTime
+{
+public:
+ using NSC = long long;
+ static constexpr NSC NsPerS = 1000000000;
+
+ cmFileTime() = default;
+ ~cmFileTime() = default;
+
+ /**
+ * @brief Loads the file time of fileName from the file system
+ * @return true on success
+ */
+ bool Load(std::string const& fileName);
+
+ /**
+ * @brief Return true if this is older than ftm
+ */
+ bool Older(cmFileTime const& ftm) const { return (this->NS - ftm.NS) < 0; }
+
+ /**
+ * @brief Return true if this is newer than ftm
+ */
+ bool Newer(cmFileTime const& ftm) const { return (ftm.NS - this->NS) < 0; }
+
+ /**
+ * @brief Return true if this is the same as ftm
+ */
+ bool Equal(cmFileTime const& ftm) const { return this->NS == ftm.NS; }
+
+ /**
+ * @brief Return true if this is not the same as ftm
+ */
+ bool Differ(cmFileTime const& ftm) const { return this->NS != ftm.NS; }
+
+ /**
+ * @brief Compare file modification times.
+ * @return -1, 0, +1 for this older, same, or newer than ftm.
+ */
+ int Compare(cmFileTime const& ftm) const
+ {
+ NSC const diff = this->NS - ftm.NS;
+ if (diff == 0) {
+ return 0;
+ }
+ return (diff < 0) ? -1 : 1;
+ }
+
+ // -- Comparison in second resolution
+
+ /**
+ * @brief Return true if this is at least a second older than ftm
+ */
+ bool OlderS(cmFileTime const& ftm) const
+ {
+ return (ftm.NS - this->NS) >= cmFileTime::NsPerS;
+ }
+
+ /**
+ * @brief Return true if this is at least a second newer than ftm
+ */
+ bool NewerS(cmFileTime const& ftm) const
+ {
+ return (this->NS - ftm.NS) >= cmFileTime::NsPerS;
+ }
+
+ /**
+ * @brief Return true if this is within the same second as ftm
+ */
+ bool EqualS(cmFileTime const& ftm) const
+ {
+ NSC diff = this->NS - ftm.NS;
+ if (diff < 0) {
+ diff = -diff;
+ }
+ return (diff < cmFileTime::NsPerS);
+ }
+
+ /**
+ * @brief Return true if this is older or newer than ftm by at least a second
+ */
+ bool DifferS(cmFileTime const& ftm) const
+ {
+ NSC diff = this->NS - ftm.NS;
+ if (diff < 0) {
+ diff = -diff;
+ }
+ return (diff >= cmFileTime::NsPerS);
+ }
+
+ /**
+ * @brief Compare file modification times.
+ * @return -1: this at least a second older, 0: this within the same second
+ * as ftm, +1: this at least a second newer than ftm.
+ */
+ int CompareS(cmFileTime const& ftm) const
+ {
+ NSC const diff = this->NS - ftm.NS;
+ if (diff <= -cmFileTime::NsPerS) {
+ return -1;
+ }
+ if (diff >= cmFileTime::NsPerS) {
+ return 1;
+ }
+ return 0;
+ }
+
+ /**
+ * @brief The file modification time in nanoseconds
+ */
+ NSC GetNS() const { return this->NS; }
+
+private:
+ NSC NS = 0;
+};
+
+#endif
diff --git a/Source/cmFileTimeCache.cxx b/Source/cmFileTimeCache.cxx
new file mode 100644
index 000000000..0d1dae5e8
--- /dev/null
+++ b/Source/cmFileTimeCache.cxx
@@ -0,0 +1,64 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmFileTimeCache.h"
+
+#include <string>
+#include <unordered_map>
+#include <utility>
+
+cmFileTimeCache::cmFileTimeCache() = default;
+
+cmFileTimeCache::~cmFileTimeCache() = default;
+
+bool cmFileTimeCache::Load(std::string const& fileName, cmFileTime& fileTime)
+{
+ // Use the stored time if available.
+ {
+ auto fit = this->Cache.find(fileName);
+ if (fit != this->Cache.end()) {
+ fileTime = fit->second;
+ return true;
+ }
+ }
+ // Read file time from OS
+ if (!fileTime.Load(fileName)) {
+ return false;
+ }
+ // Store file time in cache
+ this->Cache[fileName] = fileTime;
+ return true;
+}
+
+bool cmFileTimeCache::Remove(std::string const& fileName)
+{
+ return (this->Cache.erase(fileName) != 0);
+}
+
+bool cmFileTimeCache::Compare(std::string const& f1, std::string const& f2,
+ int* result)
+{
+ // Get the modification time for each file.
+ cmFileTime ft1;
+ cmFileTime ft2;
+ if (this->Load(f1, ft1) && this->Load(f2, ft2)) {
+ // Compare the two modification times.
+ *result = ft1.Compare(ft2);
+ return true;
+ }
+ // No comparison available. Default to the same time.
+ *result = 0;
+ return false;
+}
+
+bool cmFileTimeCache::DifferS(std::string const& f1, std::string const& f2)
+{
+ // Get the modification time for each file.
+ cmFileTime ft1;
+ cmFileTime ft2;
+ if (this->Load(f1, ft1) && this->Load(f2, ft2)) {
+ // Compare the two modification times.
+ return ft1.DifferS(ft2);
+ }
+ // No comparison available. Default to different times.
+ return true;
+}
diff --git a/Source/cmFileTimeCache.h b/Source/cmFileTimeCache.h
new file mode 100644
index 000000000..83b77b651
--- /dev/null
+++ b/Source/cmFileTimeCache.h
@@ -0,0 +1,57 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmFileTimeCache_h
+#define cmFileTimeCache_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+#include <unordered_map>
+
+#include "cmFileTime.h" // IWYU pragma: keep
+
+/** \class cmFileTimeCache
+ * \brief Caches file modification times in an internal map for fast lookups.
+ */
+class cmFileTimeCache
+{
+public:
+ cmFileTimeCache();
+ ~cmFileTimeCache();
+
+ cmFileTimeCache(const cmFileTimeCache&) = delete;
+ cmFileTimeCache& operator=(const cmFileTimeCache&) = delete;
+
+ /**
+ * @brief Loads the file time from the cache or the file system.
+ * @return true on success
+ */
+ bool Load(std::string const& fileName, cmFileTime& fileTime);
+
+ /**
+ * @brief Removes a file time from the cache
+ * @return true if the file was found in the cache and removed
+ */
+ bool Remove(std::string const& fileName);
+
+ /**
+ * @brief Compare file modification times.
+ * @return true for successful comparison and false for error.
+ *
+ * When true is returned, result has -1, 0, +1 for
+ * f1 older, same, or newer than f2.
+ */
+ bool Compare(std::string const& f1, std::string const& f2, int* result);
+
+ /**
+ * @brief Compare file modification times.
+ * @return true unless both files exist and have modification times less
+ * than 1 second apart.
+ */
+ bool DifferS(std::string const& f1, std::string const& f2);
+
+private:
+ std::unordered_map<std::string, cmFileTime> Cache;
+};
+
+#endif
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx
deleted file mode 100644
index f591a8dc7..000000000
--- a/Source/cmFileTimeComparison.cxx
+++ /dev/null
@@ -1,227 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmFileTimeComparison.h"
-
-#include <string>
-#include <time.h>
-#include <utility>
-
-#include "cm_unordered_map.hxx"
-
-// Use a platform-specific API to get file times efficiently.
-#if !defined(_WIN32) || defined(__CYGWIN__)
-#include "cm_sys_stat.h"
-#define cmFileTimeComparison_Type struct stat
-#else
-#include "cmsys/Encoding.hxx"
-#include <windows.h>
-#define cmFileTimeComparison_Type FILETIME
-#endif
-
-class cmFileTimeComparisonInternal
-{
-public:
- // Internal comparison method.
- inline bool FileTimeCompare(const char* f1, const char* f2, int* result);
-
- bool FileTimesDiffer(const char* f1, const char* f2);
-
-private:
- typedef CM_UNORDERED_MAP<std::string, cmFileTimeComparison_Type>
- FileStatsMap;
- FileStatsMap Files;
-
- // Internal methods to lookup and compare modification times.
- inline bool Stat(const char* fname, cmFileTimeComparison_Type* st);
- inline int Compare(cmFileTimeComparison_Type* st1,
- cmFileTimeComparison_Type* st2);
- inline bool TimesDiffer(cmFileTimeComparison_Type* st1,
- cmFileTimeComparison_Type* st2);
-};
-
-bool cmFileTimeComparisonInternal::Stat(const char* fname,
- cmFileTimeComparison_Type* st)
-{
- // Use the stored time if available.
- cmFileTimeComparisonInternal::FileStatsMap::iterator fit =
- this->Files.find(fname);
- if (fit != this->Files.end()) {
- *st = fit->second;
- return true;
- }
-
-#if !defined(_WIN32) || defined(__CYGWIN__)
- // POSIX version. Use the stat function.
- int res = ::stat(fname, st);
- if (res != 0) {
- return false;
- }
-#else
- // Windows version. Get the modification time from extended file
- // attributes.
- WIN32_FILE_ATTRIBUTE_DATA fdata;
- if (!GetFileAttributesExW(cmsys::Encoding::ToWide(fname).c_str(),
- GetFileExInfoStandard, &fdata)) {
- return false;
- }
-
- // Copy the file time to the output location.
- *st = fdata.ftLastWriteTime;
-#endif
-
- // Store the time for future use.
- this->Files[fname] = *st;
- return true;
-}
-
-cmFileTimeComparison::cmFileTimeComparison()
-{
- this->Internals = new cmFileTimeComparisonInternal;
-}
-
-cmFileTimeComparison::~cmFileTimeComparison()
-{
- delete this->Internals;
-}
-
-bool cmFileTimeComparison::FileTimeCompare(const char* f1, const char* f2,
- int* result)
-{
- return this->Internals->FileTimeCompare(f1, f2, result);
-}
-
-bool cmFileTimeComparison::FileTimesDiffer(const char* f1, const char* f2)
-{
- return this->Internals->FileTimesDiffer(f1, f2);
-}
-
-int cmFileTimeComparisonInternal::Compare(cmFileTimeComparison_Type* s1,
- cmFileTimeComparison_Type* s2)
-{
-#if !defined(_WIN32) || defined(__CYGWIN__)
-#if CMake_STAT_HAS_ST_MTIM
- // Compare using nanosecond resolution.
- if (s1->st_mtim.tv_sec < s2->st_mtim.tv_sec) {
- return -1;
- }
- if (s1->st_mtim.tv_sec > s2->st_mtim.tv_sec) {
- return 1;
- }
- if (s1->st_mtim.tv_nsec < s2->st_mtim.tv_nsec) {
- return -1;
- }
- if (s1->st_mtim.tv_nsec > s2->st_mtim.tv_nsec) {
- return 1;
- }
-#elif CMake_STAT_HAS_ST_MTIMESPEC
- // Compare using nanosecond resolution.
- if (s1->st_mtimespec.tv_sec < s2->st_mtimespec.tv_sec) {
- return -1;
- } else if (s1->st_mtimespec.tv_sec > s2->st_mtimespec.tv_sec) {
- return 1;
- } else if (s1->st_mtimespec.tv_nsec < s2->st_mtimespec.tv_nsec) {
- return -1;
- } else if (s1->st_mtimespec.tv_nsec > s2->st_mtimespec.tv_nsec) {
- return 1;
- }
-#else
- // Compare using 1 second resolution.
- if (s1->st_mtime < s2->st_mtime) {
- return -1;
- } else if (s1->st_mtime > s2->st_mtime) {
- return 1;
- }
-#endif
- // Files have the same time.
- return 0;
-#else
- // Compare using system-provided function.
- return (int)CompareFileTime(s1, s2);
-#endif
-}
-
-bool cmFileTimeComparisonInternal::TimesDiffer(cmFileTimeComparison_Type* s1,
- cmFileTimeComparison_Type* s2)
-{
-#if !defined(_WIN32) || defined(__CYGWIN__)
-#if CMake_STAT_HAS_ST_MTIM
- // Times are integers in units of 1ns.
- long long bil = 1000000000;
- long long t1 = s1->st_mtim.tv_sec * bil + s1->st_mtim.tv_nsec;
- long long t2 = s2->st_mtim.tv_sec * bil + s2->st_mtim.tv_nsec;
- if (t1 < t2) {
- return (t2 - t1) >= bil;
- }
- if (t2 < t1) {
- return (t1 - t2) >= bil;
- }
- return false;
-#elif CMake_STAT_HAS_ST_MTIMESPEC
- // Times are integers in units of 1ns.
- long long bil = 1000000000;
- long long t1 = s1->st_mtimespec.tv_sec * bil + s1->st_mtimespec.tv_nsec;
- long long t2 = s2->st_mtimespec.tv_sec * bil + s2->st_mtimespec.tv_nsec;
- if (t1 < t2) {
- return (t2 - t1) >= bil;
- } else if (t2 < t1) {
- return (t1 - t2) >= bil;
- } else {
- return false;
- }
-#else
- // Times are integers in units of 1s.
- if (s1->st_mtime < s2->st_mtime) {
- return (s2->st_mtime - s1->st_mtime) >= 1;
- } else if (s1->st_mtime > s2->st_mtime) {
- return (s1->st_mtime - s2->st_mtime) >= 1;
- } else {
- return false;
- }
-#endif
-#else
- // Times are integers in units of 100ns.
- LARGE_INTEGER t1;
- LARGE_INTEGER t2;
- t1.LowPart = s1->dwLowDateTime;
- t1.HighPart = s1->dwHighDateTime;
- t2.LowPart = s2->dwLowDateTime;
- t2.HighPart = s2->dwHighDateTime;
- if (t1.QuadPart < t2.QuadPart) {
- return (t2.QuadPart - t1.QuadPart) >= static_cast<LONGLONG>(10000000);
- } else if (t2.QuadPart < t1.QuadPart) {
- return (t1.QuadPart - t2.QuadPart) >= static_cast<LONGLONG>(10000000);
- } else {
- return false;
- }
-#endif
-}
-
-bool cmFileTimeComparisonInternal::FileTimeCompare(const char* f1,
- const char* f2, int* result)
-{
- // Get the modification time for each file.
- cmFileTimeComparison_Type s1;
- cmFileTimeComparison_Type s2;
- if (this->Stat(f1, &s1) && this->Stat(f2, &s2)) {
- // Compare the two modification times.
- *result = this->Compare(&s1, &s2);
- return true;
- }
- // No comparison available. Default to the same time.
- *result = 0;
- return false;
-}
-
-bool cmFileTimeComparisonInternal::FileTimesDiffer(const char* f1,
- const char* f2)
-{
- // Get the modification time for each file.
- cmFileTimeComparison_Type s1;
- cmFileTimeComparison_Type s2;
- if (this->Stat(f1, &s1) && this->Stat(f2, &s2)) {
- // Compare the two modification times.
- return this->TimesDiffer(&s1, &s2);
- }
- // No comparison available. Default to different times.
- return true;
-}
diff --git a/Source/cmFileTimeComparison.h b/Source/cmFileTimeComparison.h
deleted file mode 100644
index b1f8ed636..000000000
--- a/Source/cmFileTimeComparison.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmFileTimeComparison_h
-#define cmFileTimeComparison_h
-
-#include "cmConfigure.h" // IWYU pragma: keep
-
-class cmFileTimeComparisonInternal;
-
-/** \class cmFileTimeComparison
- * \brief Helper class for performing globbing searches.
- *
- * Finds all files that match a given globbing expression.
- */
-class cmFileTimeComparison
-{
-public:
- cmFileTimeComparison();
- ~cmFileTimeComparison();
-
- /**
- * Compare file modification times.
- * Return true for successful comparison and false for error.
- * When true is returned, result has -1, 0, +1 for
- * f1 older, same, or newer than f2.
- */
- bool FileTimeCompare(const char* f1, const char* f2, int* result);
-
- /**
- * Compare file modification times. Return true unless both files
- * exist and have modification times less than 1 second apart.
- */
- bool FileTimesDiffer(const char* f1, const char* f2);
-
-protected:
- cmFileTimeComparisonInternal* Internals;
-};
-
-#endif
diff --git a/Source/cmFileTimes.cxx b/Source/cmFileTimes.cxx
new file mode 100644
index 000000000..d8fe24c5b
--- /dev/null
+++ b/Source/cmFileTimes.cxx
@@ -0,0 +1,129 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmFileTimes.h"
+
+#include <utility>
+
+#include <cm/memory>
+
+#include "cm_sys_stat.h"
+
+#if defined(_WIN32)
+# include <windows.h>
+
+# include "cmSystemTools.h"
+#else
+# include <utime.h>
+#endif
+
+#if defined(_WIN32) && \
+ (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__MINGW32__))
+# include <io.h>
+#endif
+
+#ifdef _WIN32
+class cmFileTimes::WindowsHandle
+{
+public:
+ WindowsHandle(HANDLE h)
+ : handle_(h)
+ {
+ }
+ ~WindowsHandle()
+ {
+ if (this->handle_ != INVALID_HANDLE_VALUE) {
+ CloseHandle(this->handle_);
+ }
+ }
+ explicit operator bool() const
+ {
+ return this->handle_ != INVALID_HANDLE_VALUE;
+ }
+ bool operator!() const { return this->handle_ == INVALID_HANDLE_VALUE; }
+ operator HANDLE() const { return this->handle_; }
+
+private:
+ HANDLE handle_;
+};
+#endif
+
+class cmFileTimes::Times
+{
+public:
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ FILETIME timeCreation;
+ FILETIME timeLastAccess;
+ FILETIME timeLastWrite;
+#else
+ struct utimbuf timeBuf;
+#endif
+};
+
+cmFileTimes::cmFileTimes() = default;
+cmFileTimes::cmFileTimes(std::string const& fileName)
+{
+ Load(fileName);
+}
+cmFileTimes::~cmFileTimes() = default;
+
+bool cmFileTimes::Load(std::string const& fileName)
+{
+ std::unique_ptr<Times> ptr;
+ if (IsValid()) {
+ // Invalidate this and re-use times
+ ptr.swap(this->times);
+ } else {
+ ptr = cm::make_unique<Times>();
+ }
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ cmFileTimes::WindowsHandle handle =
+ CreateFileW(cmSystemTools::ConvertToWindowsExtendedPath(fileName).c_str(),
+ GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS, 0);
+ if (!handle) {
+ return false;
+ }
+ if (!GetFileTime(handle, &ptr->timeCreation, &ptr->timeLastAccess,
+ &ptr->timeLastWrite)) {
+ return false;
+ }
+#else
+ struct stat st;
+ if (stat(fileName.c_str(), &st) < 0) {
+ return false;
+ }
+ ptr->timeBuf.actime = st.st_atime;
+ ptr->timeBuf.modtime = st.st_mtime;
+#endif
+ // Accept times
+ this->times = std::move(ptr);
+ return true;
+}
+
+bool cmFileTimes::Store(std::string const& fileName) const
+{
+ if (!IsValid()) {
+ return false;
+ }
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ cmFileTimes::WindowsHandle handle = CreateFileW(
+ cmSystemTools::ConvertToWindowsExtendedPath(fileName).c_str(),
+ FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
+ if (!handle) {
+ return false;
+ }
+ return SetFileTime(handle, &this->times->timeCreation,
+ &this->times->timeLastAccess,
+ &this->times->timeLastWrite) != 0;
+#else
+ return utime(fileName.c_str(), &this->times->timeBuf) >= 0;
+#endif
+}
+
+bool cmFileTimes::Copy(std::string const& fromFile, std::string const& toFile)
+{
+ cmFileTimes fileTimes;
+ return (fileTimes.Load(fromFile) && fileTimes.Store(toFile));
+}
diff --git a/Source/cmFileTimes.h b/Source/cmFileTimes.h
new file mode 100644
index 000000000..191d89e94
--- /dev/null
+++ b/Source/cmFileTimes.h
@@ -0,0 +1,40 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmFileTimes_h
+#define cmFileTimes_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <memory>
+#include <string>
+
+/** \class cmFileTimes
+ * \brief Loads and stores file times.
+ */
+class cmFileTimes
+{
+public:
+ cmFileTimes();
+ //! Calls Load()
+ cmFileTimes(std::string const& fileName);
+ ~cmFileTimes();
+
+ //! @return true, if file times were loaded successfully
+ bool IsValid() const { return (times != nullptr); }
+ //! Try to load the file times from @a fileName and @return IsValid()
+ bool Load(std::string const& fileName);
+ //! Stores the file times at @a fileName (if IsValid())
+ bool Store(std::string const& fileName) const;
+
+ //! Copies the file times of @a fromFile to @a toFile
+ static bool Copy(std::string const& fromFile, std::string const& toFile);
+
+private:
+#ifdef _WIN32
+ class WindowsHandle;
+#endif
+ class Times;
+ std::unique_ptr<Times> times;
+};
+
+#endif
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index 10c6fe46f..7d741182d 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -2,21 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFindBase.h"
-#include "cmConfigure.h"
+#include <cstddef>
#include <deque>
#include <iostream>
-#include <iterator>
#include <map>
-#include <stddef.h>
#include "cmAlgorithms.h"
#include "cmMakefile.h"
+#include "cmRange.h"
#include "cmSearchPath.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-cmFindBase::cmFindBase()
+class cmExecutionStatus;
+
+cmFindBase::cmFindBase(cmExecutionStatus& status)
+ : cmFindCommon(status)
{
this->AlreadyInCache = false;
this->AlreadyInCacheWithoutMetaInfo = false;
@@ -68,7 +71,8 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
}
this->AlreadyInCache = false;
- this->SelectDefaultNoPackageRootPath();
+ // Find what search path locations have been enabled/disable
+ this->SelectDefaultSearchModes();
// Find the current root path mode.
this->SelectDefaultRootPathMode();
@@ -132,25 +136,24 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
this->VariableDocumentation += "the (unknown) library be found";
} else if (this->Names.size() == 1) {
this->VariableDocumentation +=
- "the " + this->Names[0] + " library be found";
+ "the " + this->Names.front() + " library be found";
} else {
this->VariableDocumentation += "one of the ";
this->VariableDocumentation +=
cmJoin(cmMakeRange(this->Names).retreat(1), ", ");
this->VariableDocumentation +=
- " or " + this->Names[this->Names.size() - 1] + " libraries be found";
+ " or " + this->Names.back() + " libraries be found";
}
}
// look for old style
// FIND_*(VAR name path1 path2 ...)
- if (!newStyle) {
+ if (!newStyle && !this->Names.empty()) {
// All the short-hand arguments have been recorded as names.
std::vector<std::string> shortArgs = this->Names;
this->Names.clear(); // clear out any values in Names
this->Names.push_back(shortArgs[0]);
- this->UserGuessArgs.insert(this->UserGuessArgs.end(),
- shortArgs.begin() + 1, shortArgs.end());
+ cmAppend(this->UserGuessArgs, shortArgs.begin() + 1, shortArgs.end());
}
this->ExpandPaths();
@@ -189,9 +192,7 @@ void cmFindBase::FillCMakeEnvironmentPath()
cmSearchPath& paths = this->LabeledPaths[PathLabel::CMakeEnvironment];
// Add CMAKE_*_PATH environment variables
- std::string var = "CMAKE_";
- var += this->CMakePathName;
- var += "_PATH";
+ std::string var = cmStrCat("CMAKE_", this->CMakePathName, "_PATH");
paths.AddEnvPrefixPath("CMAKE_PREFIX_PATH");
paths.AddEnvPath(var);
@@ -207,16 +208,10 @@ void cmFindBase::FillPackageRootPath()
{
cmSearchPath& paths = this->LabeledPaths[PathLabel::PackageRoot];
- // Add package specific search prefixes
- // NOTE: This should be using const_reverse_iterator but HP aCC and
- // Oracle sunCC both currently have standard library issues
- // with the reverse iterator APIs.
- for (std::deque<std::string>::reverse_iterator pkg =
- this->Makefile->FindPackageModuleStack.rbegin();
- pkg != this->Makefile->FindPackageModuleStack.rend(); ++pkg) {
- std::string varName = *pkg + "_ROOT";
- paths.AddCMakePrefixPath(varName);
- paths.AddEnvPrefixPath(varName);
+ // Add the PACKAGE_ROOT_PATH from each enclosing find_package call.
+ for (std::vector<std::string> const& pkgPaths :
+ cmReverseRange(this->Makefile->FindPackageRootPathStack)) {
+ paths.AddPrefixPaths(pkgPaths);
}
paths.AddSuffixes(this->SearchPathSuffixes);
@@ -226,12 +221,10 @@ void cmFindBase::FillCMakeVariablePath()
{
cmSearchPath& paths = this->LabeledPaths[PathLabel::CMake];
- // Add CMake varibles of the same name as the previous environment
- // varibles CMAKE_*_PATH to be used most of the time with -D
+ // Add CMake variables of the same name as the previous environment
+ // variables CMAKE_*_PATH to be used most of the time with -D
// command line options
- std::string var = "CMAKE_";
- var += this->CMakePathName;
- var += "_PATH";
+ std::string var = cmStrCat("CMAKE_", this->CMakePathName, "_PATH");
paths.AddCMakePrefixPath("CMAKE_PREFIX_PATH");
paths.AddCMakePath(var);
@@ -263,9 +256,7 @@ void cmFindBase::FillCMakeSystemVariablePath()
{
cmSearchPath& paths = this->LabeledPaths[PathLabel::CMakeSystem];
- std::string var = "CMAKE_SYSTEM_";
- var += this->CMakePathName;
- var += "_PATH";
+ std::string var = cmStrCat("CMAKE_SYSTEM_", this->CMakePathName, "_PATH");
paths.AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH");
paths.AddCMakePath(var);
@@ -281,10 +272,8 @@ void cmFindBase::FillUserHintsPath()
{
cmSearchPath& paths = this->LabeledPaths[PathLabel::Hints];
- for (std::vector<std::string>::const_iterator p =
- this->UserHintsArgs.begin();
- p != this->UserHintsArgs.end(); ++p) {
- paths.AddUserPath(*p);
+ for (std::string const& p : this->UserHintsArgs) {
+ paths.AddUserPath(p);
}
paths.AddSuffixes(this->SearchPathSuffixes);
}
@@ -293,10 +282,8 @@ void cmFindBase::FillUserGuessPath()
{
cmSearchPath& paths = this->LabeledPaths[PathLabel::Guess];
- for (std::vector<std::string>::const_iterator p =
- this->UserGuessArgs.begin();
- p != this->UserGuessArgs.end(); ++p) {
- paths.AddUserPath(*p);
+ for (std::string const& p : this->UserGuessArgs) {
+ paths.AddUserPath(p);
}
paths.AddSuffixes(this->SearchPathSuffixes);
}
@@ -334,8 +321,8 @@ bool cmFindBase::CheckForVariableInCache()
this->Makefile->GetDefinition(this->VariableName)) {
cmState* state = this->Makefile->GetState();
const char* cacheEntry = state->GetCacheEntryValue(this->VariableName);
- bool found = !cmSystemTools::IsNOTFOUND(cacheValue);
- bool cached = cacheEntry != CM_NULLPTR;
+ bool found = !cmIsNOTFOUND(cacheValue);
+ bool cached = cacheEntry != nullptr;
if (found) {
// If the user specifies the entry on the command line without a
// type we should add the type and docstring but keep the
diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h
index 88b5b6c18..f75db5ff3 100644
--- a/Source/cmFindBase.h
+++ b/Source/cmFindBase.h
@@ -10,6 +10,8 @@
#include "cmFindCommon.h"
+class cmExecutionStatus;
+
/** \class cmFindBase
* \brief Base class for most FIND_XXX commands.
*
@@ -19,7 +21,9 @@
class cmFindBase : public cmFindCommon
{
public:
- cmFindBase();
+ cmFindBase(cmExecutionStatus& status);
+ virtual ~cmFindBase() = default;
+
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index 4ef0f3ec1..badec55a8 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -3,10 +3,14 @@
#include "cmFindCommon.h"
#include <algorithm>
-#include <string.h>
+#include <array>
+#include <cstring>
#include <utility>
+#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
cmFindCommon::PathGroup cmFindCommon::PathGroup::All("ALL");
@@ -21,7 +25,9 @@ cmFindCommon::PathLabel cmFindCommon::PathLabel::SystemEnvironment(
cmFindCommon::PathLabel cmFindCommon::PathLabel::CMakeSystem("CMAKE_SYSTEM");
cmFindCommon::PathLabel cmFindCommon::PathLabel::Guess("GUESS");
-cmFindCommon::cmFindCommon()
+cmFindCommon::cmFindCommon(cmExecutionStatus& status)
+ : Makefile(&status.GetMakefile())
+ , Status(status)
{
this->FindRootPathMode = RootPathModeBoth;
this->NoDefaultPath = false;
@@ -48,15 +54,16 @@ cmFindCommon::cmFindCommon()
this->InitializeSearchPathGroups();
}
-cmFindCommon::~cmFindCommon()
+void cmFindCommon::SetError(std::string const& e)
{
+ this->Status.SetError(e);
}
void cmFindCommon::InitializeSearchPathGroups()
{
std::vector<PathLabel>* labels;
- // Define the varoius different groups of path types
+ // Define the various different groups of path types
// All search paths
labels = &this->PathGroupLabelMap[PathGroup::All];
@@ -71,7 +78,7 @@ void cmFindCommon::InitializeSearchPathGroups()
// Define the search group order
this->PathGroupOrder.push_back(PathGroup::All);
- // Create the idividual labeld search paths
+ // Create the individual labeled search paths
this->LabeledPaths.insert(
std::make_pair(PathLabel::PackageRoot, cmSearchPath(this)));
this->LabeledPaths.insert(
@@ -88,18 +95,11 @@ void cmFindCommon::InitializeSearchPathGroups()
std::make_pair(PathLabel::Guess, cmSearchPath(this)));
}
-void cmFindCommon::SelectDefaultNoPackageRootPath()
-{
- if (!this->Makefile->IsOn("__UNDOCUMENTED_CMAKE_FIND_PACKAGE_ROOT")) {
- this->NoPackageRootPath = true;
- }
-}
-
void cmFindCommon::SelectDefaultRootPathMode()
{
// Check the policy variable for this find command type.
- std::string findRootPathVar = "CMAKE_FIND_ROOT_PATH_MODE_";
- findRootPathVar += this->CMakePathName;
+ std::string findRootPathVar =
+ cmStrCat("CMAKE_FIND_ROOT_PATH_MODE_", this->CMakePathName);
std::string rootPathMode =
this->Makefile->GetSafeDefinition(findRootPathVar);
if (rootPathMode == "NEVER") {
@@ -152,13 +152,32 @@ void cmFindCommon::SelectDefaultMacMode()
}
}
+void cmFindCommon::SelectDefaultSearchModes()
+{
+ const std::array<std::pair<bool&, std::string>, 5> search_paths = {
+ { { this->NoPackageRootPath, "CMAKE_FIND_USE_PACKAGE_ROOT_PATH" },
+ { this->NoCMakePath, "CMAKE_FIND_USE_CMAKE_PATH" },
+ { this->NoCMakeEnvironmentPath,
+ "CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH" },
+ { this->NoSystemEnvironmentPath,
+ "CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH" },
+ { this->NoCMakeSystemPath, "CMAKE_FIND_USE_CMAKE_SYSTEM_PATH" } }
+ };
+
+ for (auto& path : search_paths) {
+ const char* def = this->Makefile->GetDefinition(path.second);
+ if (def) {
+ path.first = !cmIsOn(def);
+ }
+ }
+}
+
void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
{
#if 0
- for(std::vector<std::string>::const_iterator i = paths.begin();
- i != paths.end(); ++i)
+ for(std::string const& p : paths)
{
- fprintf(stderr, "[%s]\n", i->c_str());
+ fprintf(stderr, "[%s]\n", p.c_str());
}
#endif
// Short-circuit if there is nothing to do.
@@ -183,20 +202,19 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
// Construct the list of path roots with no trailing slashes.
std::vector<std::string> roots;
if (rootPath) {
- cmSystemTools::ExpandListArgument(rootPath, roots);
+ cmExpandList(rootPath, roots);
}
if (sysrootCompile) {
- roots.push_back(sysrootCompile);
+ roots.emplace_back(sysrootCompile);
}
if (sysrootLink) {
- roots.push_back(sysrootLink);
+ roots.emplace_back(sysrootLink);
}
if (sysroot) {
- roots.push_back(sysroot);
+ roots.emplace_back(sysroot);
}
- for (std::vector<std::string>::iterator ri = roots.begin();
- ri != roots.end(); ++ri) {
- cmSystemTools::ConvertToUnixSlashes(*ri);
+ for (std::string& r : roots) {
+ cmSystemTools::ConvertToUnixSlashes(r);
}
const char* stagePrefix =
@@ -206,24 +224,21 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
std::vector<std::string> unrootedPaths = paths;
paths.clear();
- for (std::vector<std::string>::const_iterator ri = roots.begin();
- ri != roots.end(); ++ri) {
- for (std::vector<std::string>::const_iterator ui = unrootedPaths.begin();
- ui != unrootedPaths.end(); ++ui) {
+ for (std::string const& r : roots) {
+ for (std::string 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.
std::string rootedDir;
- if (cmSystemTools::IsSubDirectory(*ui, *ri) ||
- (stagePrefix && cmSystemTools::IsSubDirectory(*ui, stagePrefix))) {
- rootedDir = *ui;
- } else if (!ui->empty() && (*ui)[0] != '~') {
+ if (cmSystemTools::IsSubDirectory(up, r) ||
+ (stagePrefix && cmSystemTools::IsSubDirectory(up, stagePrefix))) {
+ rootedDir = up;
+ } else if (!up.empty() && up[0] != '~') {
// Start with the new root.
- rootedDir = *ri;
- rootedDir += "/";
+ rootedDir = cmStrCat(r, '/');
// Append the original path with its old root removed.
- rootedDir += cmSystemTools::SplitPathRootComponent(*ui);
+ rootedDir += cmSystemTools::SplitPathRootComponent(up);
}
// Store the new path.
@@ -234,7 +249,7 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
// If searching both rooted and unrooted paths add the original
// paths again.
if (this->FindRootPathMode == RootPathModeBoth) {
- paths.insert(paths.end(), unrootedPaths.begin(), unrootedPaths.end());
+ cmAppend(paths, unrootedPaths);
}
}
@@ -242,22 +257,21 @@ void cmFindCommon::GetIgnoredPaths(std::vector<std::string>& ignore)
{
// null-terminated list of paths.
static const char* paths[] = { "CMAKE_SYSTEM_IGNORE_PATH",
- "CMAKE_IGNORE_PATH", CM_NULLPTR };
+ "CMAKE_IGNORE_PATH", nullptr };
// Construct the list of path roots with no trailing slashes.
for (const char** pathName = paths; *pathName; ++pathName) {
// Get the list of paths to ignore from the variable.
const char* ignorePath = this->Makefile->GetDefinition(*pathName);
- if ((ignorePath == CM_NULLPTR) || (strlen(ignorePath) == 0)) {
+ if ((ignorePath == nullptr) || (strlen(ignorePath) == 0)) {
continue;
}
- cmSystemTools::ExpandListArgument(ignorePath, ignore);
+ cmExpandList(ignorePath, ignore);
}
- for (std::vector<std::string>::iterator i = ignore.begin();
- i != ignore.end(); ++i) {
- cmSystemTools::ConvertToUnixSlashes(*i);
+ for (std::string& i : ignore) {
+ cmSystemTools::ConvertToUnixSlashes(i);
}
}
@@ -305,13 +319,13 @@ void cmFindCommon::AddPathSuffix(std::string const& arg)
if (suffix.empty()) {
return;
}
- if (suffix[0] == '/') {
+ if (suffix.front() == '/') {
suffix = suffix.substr(1);
}
if (suffix.empty()) {
return;
}
- if (suffix[suffix.size() - 1] == '/') {
+ if (suffix.back() == '/') {
suffix = suffix.substr(0, suffix.size() - 1);
}
if (suffix.empty()) {
@@ -319,12 +333,12 @@ void cmFindCommon::AddPathSuffix(std::string const& arg)
}
// Store the suffix.
- this->SearchPathSuffixes.push_back(suffix);
+ this->SearchPathSuffixes.push_back(std::move(suffix));
}
void AddTrailingSlash(std::string& s)
{
- if (!s.empty() && *s.rbegin() != '/') {
+ if (!s.empty() && s.back() != '/') {
s += '/';
}
}
@@ -334,12 +348,11 @@ void cmFindCommon::ComputeFinalPaths()
std::set<std::string> ignored;
this->GetIgnoredPaths(ignored);
- // Combine the seperate path types, filtering out ignores
+ // Combine the separate path types, filtering out ignores
this->SearchPaths.clear();
std::vector<PathLabel>& allLabels = this->PathGroupLabelMap[PathGroup::All];
- for (std::vector<PathLabel>::const_iterator l = allLabels.begin();
- l != allLabels.end(); ++l) {
- this->LabeledPaths[*l].ExtractWithout(ignored, this->SearchPaths);
+ for (PathLabel const& l : allLabels) {
+ this->LabeledPaths[l].ExtractWithout(ignored, this->SearchPaths);
}
// Expand list of paths inside all search roots.
diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h
index 72dcd355d..8177eacd6 100644
--- a/Source/cmFindCommon.h
+++ b/Source/cmFindCommon.h
@@ -3,17 +3,19 @@
#ifndef cmFindCommon_h
#define cmFindCommon_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
#include <set>
#include <string>
#include <vector>
-#include "cmCommand.h"
#include "cmPathLabel.h"
#include "cmSearchPath.h"
+class cmExecutionStatus;
+class cmMakefile;
+
/** \class cmFindCommon
* \brief Base class for FIND_XXX implementations.
*
@@ -21,11 +23,12 @@
* cmFindProgramCommand, cmFindPathCommand, cmFindLibraryCommand,
* cmFindFileCommand, and cmFindPackageCommand.
*/
-class cmFindCommon : public cmCommand
+class cmFindCommon
{
public:
- cmFindCommon();
- ~cmFindCommon() CM_OVERRIDE;
+ cmFindCommon(cmExecutionStatus& status);
+
+ void SetError(std::string const& e);
protected:
friend class cmSearchPath;
@@ -84,15 +87,15 @@ protected:
/** Compute final search path list (reroot + trailing slash). */
void ComputeFinalPaths();
- /** Decide whether to enable the PACKAGE_ROOT search entries. */
- void SelectDefaultNoPackageRootPath();
-
/** Compute the current default root path mode. */
void SelectDefaultRootPathMode();
/** Compute the current default bundle/framework search policy. */
void SelectDefaultMacMode();
+ /** Compute the current default search modes based on global variables. */
+ void SelectDefaultSearchModes();
+
// Path arguments prior to path manipulation routines
std::vector<std::string> UserHintsArgs;
std::vector<std::string> UserGuessArgs;
@@ -112,7 +115,7 @@ protected:
std::vector<std::string> SearchPathSuffixes;
- std::map<PathGroup, std::vector<PathLabel> > PathGroupLabelMap;
+ std::map<PathGroup, std::vector<PathLabel>> PathGroupLabelMap;
std::vector<PathGroup> PathGroupOrder;
std::map<std::string, PathLabel> PathLabelStringMap;
std::map<PathLabel, cmSearchPath> LabeledPaths;
@@ -127,6 +130,9 @@ protected:
bool SearchAppBundleFirst;
bool SearchAppBundleOnly;
bool SearchAppBundleLast;
+
+ cmMakefile* Makefile;
+ cmExecutionStatus& Status;
};
#endif
diff --git a/Source/cmFindFileCommand.cxx b/Source/cmFindFileCommand.cxx
index 9840c4f49..29a2bc49e 100644
--- a/Source/cmFindFileCommand.cxx
+++ b/Source/cmFindFileCommand.cxx
@@ -2,7 +2,16 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFindFileCommand.h"
-cmFindFileCommand::cmFindFileCommand()
+class cmExecutionStatus;
+
+cmFindFileCommand::cmFindFileCommand(cmExecutionStatus& status)
+ : cmFindPathCommand(status)
{
this->IncludeFileInPath = true;
}
+
+bool cmFindFile(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return cmFindFileCommand(status).InitialPass(args);
+}
diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h
index bf57fecd3..7dc6e5569 100644
--- a/Source/cmFindFileCommand.h
+++ b/Source/cmFindFileCommand.h
@@ -3,11 +3,14 @@
#ifndef cmFindFileCommand_h
#define cmFindFileCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+#include <vector>
#include "cmFindPathCommand.h"
-class cmCommand;
+class cmExecutionStatus;
/** \class cmFindFileCommand
* \brief Define a command to search for an executable program.
@@ -20,11 +23,10 @@ class cmCommand;
class cmFindFileCommand : public cmFindPathCommand
{
public:
- cmFindFileCommand();
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmFindFileCommand; }
+ cmFindFileCommand(cmExecutionStatus& status);
};
+bool cmFindFile(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+
#endif
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index a6b1a2155..20221b12e 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -2,29 +2,32 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFindLibraryCommand.h"
-#include "cmsys/RegularExpression.hxx"
#include <algorithm>
+#include <cstdio>
+#include <cstring>
#include <set>
-#include <stdio.h>
-#include <string.h>
+#include <utility>
+
+#include "cmsys/RegularExpression.hxx"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
class cmExecutionStatus;
-cmFindLibraryCommand::cmFindLibraryCommand()
+cmFindLibraryCommand::cmFindLibraryCommand(cmExecutionStatus& status)
+ : cmFindBase(status)
{
this->EnvironmentPath = "LIB";
this->NamesPerDirAllowed = true;
}
// cmFindLibraryCommand
-bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn,
- cmExecutionStatus&)
+bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
{
this->VariableDocumentation = "Path to a library.";
this->CMakePathName = "LIBRARY";
@@ -68,8 +71,8 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn,
this->AddArchitecturePaths("x32");
}
- std::string library = this->FindLibrary();
- if (library != "") {
+ std::string const library = this->FindLibrary();
+ if (!library.empty()) {
// Save the value in the cache
this->Makefile->AddCacheDefinition(this->VariableName, library.c_str(),
this->VariableDocumentation.c_str(),
@@ -87,9 +90,8 @@ void cmFindLibraryCommand::AddArchitecturePaths(const char* suffix)
{
std::vector<std::string> original;
original.swap(this->SearchPaths);
- for (std::vector<std::string>::const_iterator i = original.begin();
- i != original.end(); ++i) {
- this->AddArchitecturePath(*i, 0, suffix);
+ for (std::string const& o : original) {
+ this->AddArchitecturePath(o, 0, suffix);
}
}
@@ -151,7 +153,7 @@ void cmFindLibraryCommand::AddArchitecturePath(
if (use_dirX) {
dirX += "/";
- this->SearchPaths.push_back(dirX);
+ this->SearchPaths.push_back(std::move(dirX));
}
if (use_dir) {
@@ -190,7 +192,7 @@ struct cmFindLibraryHelper
std::string SuffixRegexStr;
// Keep track of the best library file found so far.
- typedef std::vector<std::string>::size_type size_type;
+ using size_type = std::vector<std::string>::size_type;
std::string BestPath;
// Support for OpenBSD shared library naming: lib<name>.so.<major>.<minor>
@@ -199,13 +201,9 @@ struct cmFindLibraryHelper
// Current names under consideration.
struct Name
{
- bool TryRaw;
+ bool TryRaw = false;
std::string Raw;
cmsys::RegularExpression Regex;
- Name()
- : TryRaw(false)
- {
- }
};
std::vector<Name> Names;
@@ -237,12 +235,12 @@ cmFindLibraryHelper::cmFindLibraryHelper(cmMakefile* mf)
this->GG = this->Makefile->GetGlobalGenerator();
// Collect the list of library name prefixes/suffixes to try.
- const char* prefixes_list =
+ std::string const& prefixes_list =
this->Makefile->GetRequiredDefinition("CMAKE_FIND_LIBRARY_PREFIXES");
- const char* suffixes_list =
+ std::string const& suffixes_list =
this->Makefile->GetRequiredDefinition("CMAKE_FIND_LIBRARY_SUFFIXES");
- cmSystemTools::ExpandListArgument(prefixes_list, this->Prefixes, true);
- cmSystemTools::ExpandListArgument(suffixes_list, this->Suffixes, true);
+ cmExpandList(prefixes_list, this->Prefixes, true);
+ cmExpandList(suffixes_list, this->Suffixes, true);
this->RegexFromList(this->PrefixRegexStr, this->Prefixes);
this->RegexFromList(this->SuffixRegexStr, this->Suffixes);
@@ -254,15 +252,14 @@ cmFindLibraryHelper::cmFindLibraryHelper(cmMakefile* mf)
void cmFindLibraryHelper::RegexFromLiteral(std::string& out,
std::string const& in)
{
- for (std::string::const_iterator ci = in.begin(); ci != in.end(); ++ci) {
- char ch = *ci;
+ for (char ch : in) {
if (ch == '[' || ch == ']' || ch == '(' || ch == ')' || ch == '\\' ||
ch == '.' || ch == '*' || ch == '+' || ch == '?' || ch == '-' ||
ch == '^' || ch == '$') {
out += "\\";
}
#if defined(_WIN32) || defined(__APPLE__)
- out += tolower(ch);
+ out += static_cast<char>(tolower(ch));
#else
out += ch;
#endif
@@ -276,23 +273,20 @@ void cmFindLibraryHelper::RegexFromList(std::string& out,
// else and the result can be checked after matching.
out += "(";
const char* sep = "";
- for (std::vector<std::string>::const_iterator si = in.begin();
- si != in.end(); ++si) {
+ for (std::string const& s : in) {
// Separate from previous item.
out += sep;
sep = "|";
// Append this item.
- this->RegexFromLiteral(out, *si);
+ this->RegexFromLiteral(out, s);
}
out += ")";
}
bool cmFindLibraryHelper::HasValidSuffix(std::string const& name)
{
- for (std::vector<std::string>::const_iterator si = this->Suffixes.begin();
- si != this->Suffixes.end(); ++si) {
- std::string suffix = *si;
+ for (std::string suffix : this->Suffixes) {
if (name.length() <= suffix.length()) {
continue;
}
@@ -319,8 +313,7 @@ void cmFindLibraryHelper::AddName(std::string const& name)
entry.Raw = name;
// Build a regular expression to match library names.
- std::string regex = "^";
- regex += this->PrefixRegexStr;
+ std::string regex = cmStrCat('^', this->PrefixRegexStr);
this->RegexFromLiteral(regex, name);
regex += this->SuffixRegexStr;
if (this->OpenBSD) {
@@ -328,7 +321,7 @@ void cmFindLibraryHelper::AddName(std::string const& name)
}
regex += "$";
entry.Regex.compile(regex.c_str());
- this->Names.push_back(entry);
+ this->Names.push_back(std::move(entry));
}
void cmFindLibraryHelper::SetName(std::string const& name)
@@ -339,9 +332,8 @@ void cmFindLibraryHelper::SetName(std::string const& name)
bool cmFindLibraryHelper::CheckDirectory(std::string const& path)
{
- for (std::vector<Name>::iterator i = this->Names.begin();
- i != this->Names.end(); ++i) {
- if (this->CheckDirectoryForName(path, *i)) {
+ for (Name& i : this->Names) {
+ if (this->CheckDirectoryForName(path, i)) {
return true;
}
}
@@ -357,9 +349,8 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path,
// one cannot tell just from the library name whether it is a static
// library or an import library).
if (name.TryRaw) {
- this->TestPath = path;
- this->TestPath += name.Raw;
- if (cmSystemTools::FileExists(this->TestPath.c_str(), true)) {
+ this->TestPath = cmStrCat(path, name.Raw);
+ if (cmSystemTools::FileExists(this->TestPath, true)) {
this->BestPath = cmSystemTools::CollapseFullPath(this->TestPath);
cmSystemTools::ConvertToUnixSlashes(this->BestPath);
return true;
@@ -376,17 +367,14 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path,
std::string dir = path;
cmSystemTools::ConvertToUnixSlashes(dir);
std::set<std::string> const& files = this->GG->GetDirectoryContent(dir);
- for (std::set<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
- std::string const& origName = *fi;
+ for (std::string const& origName : files) {
#if defined(_WIN32) || defined(__APPLE__)
std::string testName = cmSystemTools::LowerCase(origName);
#else
std::string const& testName = origName;
#endif
if (name.Regex.find(testName)) {
- this->TestPath = path;
- this->TestPath += origName;
+ this->TestPath = cmStrCat(path, origName);
if (!cmSystemTools::FileIsDirectory(this->TestPath)) {
// This is a matching file. Check if it is better than the
// best name found so far. Earlier prefixes are preferred,
@@ -430,14 +418,12 @@ std::string cmFindLibraryCommand::FindNormalLibraryNamesPerDir()
{
// Search for all names in each directory.
cmFindLibraryHelper helper(this->Makefile);
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- helper.AddName(*ni);
+ for (std::string const& n : this->Names) {
+ helper.AddName(n);
}
// Search every directory.
- for (std::vector<std::string>::const_iterator p = this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p) {
- if (helper.CheckDirectory(*p)) {
+ for (std::string const& sp : this->SearchPaths) {
+ if (helper.CheckDirectory(sp)) {
return helper.BestPath;
}
}
@@ -449,16 +435,13 @@ std::string cmFindLibraryCommand::FindNormalLibraryDirsPerName()
{
// Search the entire path for each name.
cmFindLibraryHelper helper(this->Makefile);
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
+ for (std::string const& n : this->Names) {
// Switch to searching for this name.
- helper.SetName(*ni);
+ helper.SetName(n);
// Search every directory.
- for (std::vector<std::string>::const_iterator p =
- this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p) {
- if (helper.CheckDirectory(*p)) {
+ for (std::string const& sp : this->SearchPaths) {
+ if (helper.CheckDirectory(sp)) {
return helper.BestPath;
}
}
@@ -479,13 +462,9 @@ std::string cmFindLibraryCommand::FindFrameworkLibraryNamesPerDir()
{
std::string fwPath;
// Search for all names in each search path.
- for (std::vector<std::string>::const_iterator di = this->SearchPaths.begin();
- di != this->SearchPaths.end(); ++di) {
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- fwPath = *di;
- fwPath += *ni;
- fwPath += ".framework";
+ for (std::string const& d : this->SearchPaths) {
+ for (std::string const& n : this->Names) {
+ fwPath = cmStrCat(d, n, ".framework");
if (cmSystemTools::FileIsDirectory(fwPath)) {
return cmSystemTools::CollapseFullPath(fwPath);
}
@@ -500,14 +479,9 @@ std::string cmFindLibraryCommand::FindFrameworkLibraryDirsPerName()
{
std::string fwPath;
// Search for each name in all search paths.
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- for (std::vector<std::string>::const_iterator di =
- this->SearchPaths.begin();
- di != this->SearchPaths.end(); ++di) {
- fwPath = *di;
- fwPath += *ni;
- fwPath += ".framework";
+ for (std::string const& n : this->Names) {
+ for (std::string const& d : this->SearchPaths) {
+ fwPath = cmStrCat(d, n, ".framework");
if (cmSystemTools::FileIsDirectory(fwPath)) {
return cmSystemTools::CollapseFullPath(fwPath);
}
@@ -517,3 +491,9 @@ std::string cmFindLibraryCommand::FindFrameworkLibraryDirsPerName()
// No framework found.
return "";
}
+
+bool cmFindLibrary(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return cmFindLibraryCommand(status).InitialPass(args);
+}
diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h
index 9d38eab33..b2f71b3b8 100644
--- a/Source/cmFindLibraryCommand.h
+++ b/Source/cmFindLibraryCommand.h
@@ -3,14 +3,13 @@
#ifndef cmFindLibraryCommand_h
#define cmFindLibraryCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
#include "cmFindBase.h"
-class cmCommand;
class cmExecutionStatus;
/** \class cmFindLibraryCommand
@@ -23,18 +22,9 @@ class cmExecutionStatus;
class cmFindLibraryCommand : public cmFindBase
{
public:
- cmFindLibraryCommand();
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmFindLibraryCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
+ cmFindLibraryCommand(cmExecutionStatus& status);
+
+ bool InitialPass(std::vector<std::string> const& args);
protected:
void AddArchitecturePaths(const char* suffix);
@@ -52,4 +42,7 @@ private:
std::string FindFrameworkLibraryDirsPerName();
};
+bool cmFindLibrary(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+
#endif
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 7797700d6..2b11b62a2 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -2,34 +2,39 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFindPackageCommand.h"
-#include "cmSystemTools.h"
-#include "cmsys/Directory.hxx"
-#include "cmsys/FStream.hxx"
-#include "cmsys/Glob.hxx"
-#include "cmsys/RegularExpression.hxx"
-#include "cmsys/String.h"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
+#include <cstring>
#include <deque>
#include <functional>
#include <iterator>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
#include <utility>
+#include <cm/memory>
+
+#include "cmsys/Directory.hxx"
+#include "cmsys/FStream.hxx"
+#include "cmsys/Glob.hxx"
+#include "cmsys/RegularExpression.hxx"
+#include "cmsys/String.h"
+
#include "cmAlgorithms.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmPolicies.h"
+#include "cmRange.h"
#include "cmSearchPath.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
#include "cmVersion.h"
-#include "cm_auto_ptr.hxx"
-#include "cmake.h"
#if defined(__HAIKU__)
-#include <FindDirectory.h>
-#include <StorageDefs.h>
+# include <FindDirectory.h>
+# include <StorageDefs.h>
#endif
class cmExecutionStatus;
@@ -81,7 +86,8 @@ void cmFindPackageCommand::Sort(std::vector<std::string>::iterator begin,
// else do not sort
}
-cmFindPackageCommand::cmFindPackageCommand()
+cmFindPackageCommand::cmFindPackageCommand(cmExecutionStatus& status)
+ : cmFindCommon(status)
{
this->CMakePathName = "PACKAGE";
this->Quiet = false;
@@ -94,6 +100,7 @@ cmFindPackageCommand::cmFindPackageCommand()
this->UseLib32Paths = false;
this->UseLib64Paths = false;
this->UseLibx32Paths = false;
+ this->UseRealPath = false;
this->PolicyScope = true;
this->VersionMajor = 0;
this->VersionMinor = 0;
@@ -110,6 +117,8 @@ cmFindPackageCommand::cmFindPackageCommand()
this->SortOrder = None;
this->SortDirection = Asc;
this->AppendSearchPathGroups();
+
+ this->DeprecatedFindModules["Qt"] = cmPolicies::CMP0084;
}
void cmFindPackageCommand::AppendSearchPathGroups()
@@ -136,8 +145,7 @@ void cmFindPackageCommand::AppendSearchPathGroups()
std::make_pair(PathLabel::SystemRegistry, cmSearchPath(this)));
}
-bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
{
if (args.empty()) {
this->SetError("called with incorrect number of arguments");
@@ -183,15 +191,31 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
}
// Check if User Package Registry should be disabled
- if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY")) {
+ // The `CMAKE_FIND_USE_PACKAGE_REGISTRY` has
+ // priority over the deprecated CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
+ if (const char* def =
+ this->Makefile->GetDefinition("CMAKE_FIND_USE_PACKAGE_REGISTRY")) {
+ this->NoUserRegistry = !cmIsOn(def);
+ } else if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY")) {
this->NoUserRegistry = true;
}
// Check if System Package Registry should be disabled
- if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY")) {
+ // The `CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` has
+ // priority over the deprecated CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
+ if (const char* def = this->Makefile->GetDefinition(
+ "CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY")) {
+ this->NoSystemRegistry = !cmIsOn(def);
+ } else if (this->Makefile->IsOn(
+ "CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY")) {
this->NoSystemRegistry = true;
}
+ // Check whether we should resolve symlinks when finding packages
+ if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS")) {
+ this->UseRealPath = true;
+ }
+
// Check if Sorting should be enabled
if (const char* so =
this->Makefile->GetDefinition("CMAKE_FIND_PACKAGE_SORT_ORDER")) {
@@ -209,7 +233,8 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
this->SortDirection = strcmp(sd, "ASC") == 0 ? Asc : Dec;
}
- this->SelectDefaultNoPackageRootPath();
+ // Find what search path locations have been enabled/disable
+ this->SelectDefaultSearchModes();
// Find the current root path mode.
this->SelectDefaultRootPathMode();
@@ -225,7 +250,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
std::set<std::string> optionalComponents;
// Always search directly in a generated path.
- this->SearchPathSuffixes.push_back("");
+ this->SearchPathSuffixes.emplace_back();
// Parse the arguments.
enum Doing
@@ -330,21 +355,19 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
} else if (doing == DoingConfigs) {
if (args[i].find_first_of(":/\\") != std::string::npos ||
cmSystemTools::GetFilenameLastExtension(args[i]) != ".cmake") {
- std::ostringstream e;
- e << "given CONFIGS option followed by invalid file name \"" << args[i]
- << "\". The names given must be file names without "
- << "a path and with a \".cmake\" extension.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(
+ "given CONFIGS option followed by invalid file name \"", args[i],
+ "\". The names given must be file names without "
+ "a path and with a \".cmake\" extension."));
return false;
}
this->Configs.push_back(args[i]);
- } else if (!haveVersion && version.find(args[i].c_str())) {
+ } else if (!haveVersion && version.find(args[i])) {
haveVersion = true;
this->Version = args[i];
} else {
- std::ostringstream e;
- e << "called with invalid argument \"" << args[i] << "\"";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("called with invalid argument \"", args[i], "\""));
return false;
}
}
@@ -354,10 +377,10 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
optionalComponents.begin(), optionalComponents.end(),
std::back_inserter(doubledComponents));
if (!doubledComponents.empty()) {
- std::ostringstream e;
- e << "called with components that are both required and optional:\n";
- e << cmWrap(" ", doubledComponents, "", "\n") << "\n";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("called with components that are both required and "
+ "optional:\n",
+ cmWrap(" ", doubledComponents, "", "\n"), "\n"));
return false;
}
@@ -367,14 +390,12 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
if (!this->UseFindModules && !this->UseConfigFiles) {
std::ostringstream e;
e << "given options exclusive to Module mode:\n";
- for (std::set<unsigned int>::const_iterator si = moduleArgs.begin();
- si != moduleArgs.end(); ++si) {
- e << " " << args[*si] << "\n";
+ for (unsigned int si : moduleArgs) {
+ e << " " << args[si] << "\n";
}
e << "and options exclusive to Config mode:\n";
- for (std::set<unsigned int>::const_iterator si = configArgs.begin();
- si != configArgs.end(); ++si) {
- e << " " << args[*si] << "\n";
+ for (unsigned int si : configArgs) {
+ e << " " << args[si] << "\n";
}
e << "The options are incompatible.";
this->SetError(e.str());
@@ -385,25 +406,23 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
if (this->Version.empty() && this->VersionExact) {
this->VersionExact = false;
this->Makefile->IssueMessage(
- cmake::AUTHOR_WARNING, "Ignoring EXACT since no version is requested.");
+ MessageType::AUTHOR_WARNING,
+ "Ignoring EXACT since no version is requested.");
}
if (this->Version.empty() || components.empty()) {
// Check whether we are recursing inside "Find<name>.cmake" within
// another find_package(<name>) call.
- std::string mod = this->Name;
- mod += "_FIND_MODULE";
+ std::string mod = cmStrCat(this->Name, "_FIND_MODULE");
if (this->Makefile->IsOn(mod)) {
if (this->Version.empty()) {
// Get version information from the outer call if necessary.
// Requested version string.
- std::string ver = this->Name;
- ver += "_FIND_VERSION";
+ std::string ver = cmStrCat(this->Name, "_FIND_VERSION");
this->Version = this->Makefile->GetSafeDefinition(ver);
// Whether an exact version is required.
- std::string exact = this->Name;
- exact += "_FIND_VERSION_EXACT";
+ std::string exact = cmStrCat(this->Name, "_FIND_VERSION_EXACT");
this->VersionExact = this->Makefile->IsOn(exact);
}
if (components.empty()) {
@@ -441,75 +460,137 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
}
}
- std::string disableFindPackageVar = "CMAKE_DISABLE_FIND_PACKAGE_";
- disableFindPackageVar += this->Name;
+ std::string disableFindPackageVar =
+ cmStrCat("CMAKE_DISABLE_FIND_PACKAGE_", this->Name);
if (this->Makefile->IsOn(disableFindPackageVar)) {
if (this->Required) {
- std::ostringstream e;
- e << "for module " << this->Name << " called with REQUIRED, but "
- << disableFindPackageVar
- << " is enabled. A REQUIRED package cannot be disabled.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("for module ", this->Name, " called with REQUIRED, but ",
+ disableFindPackageVar,
+ " is enabled. A REQUIRED package cannot be disabled."));
return false;
}
return true;
}
+ {
+ // Allocate a PACKAGE_ROOT_PATH for the current find_package call.
+ this->Makefile->FindPackageRootPathStack.emplace_back();
+ std::vector<std::string>& rootPaths =
+ this->Makefile->FindPackageRootPathStack.back();
+
+ // Add root paths from <PackageName>_ROOT CMake and environment variables,
+ // subject to CMP0074.
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0074)) {
+ case cmPolicies::WARN:
+ this->Makefile->MaybeWarnCMP0074(this->Name);
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ // OLD behavior is to ignore the <pkg>_ROOT variables.
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0074));
+ break;
+ case cmPolicies::NEW: {
+ // NEW behavior is to honor the <pkg>_ROOT variables.
+ std::string const rootVar = this->Name + "_ROOT";
+ if (const char* pkgRoot = this->Makefile->GetDefinition(rootVar)) {
+ cmExpandList(pkgRoot, rootPaths, false);
+ }
+ cmSystemTools::GetPath(rootPaths, rootVar.c_str());
+ } break;
+ }
+ }
+
this->SetModuleVariables(components);
- // See if there is a Find<package>.cmake module.
- if (this->UseFindModules) {
- bool foundModule = false;
- if (!this->FindModule(foundModule)) {
- this->AppendSuccessInformation();
- return false;
+ // See if there is a Find<PackageName>.cmake module.
+ bool loadedPackage = false;
+ if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_PREFER_CONFIG")) {
+ if (this->UseConfigFiles && this->FindPackageUsingConfigMode()) {
+ loadedPackage = true;
+ } else {
+ if (this->FindPackageUsingModuleMode()) {
+ loadedPackage = true;
+ } else {
+ // The package was not loaded. Report errors.
+ if (HandlePackageMode(HandlePackageModeType::Module)) {
+ loadedPackage = true;
+ }
+ }
}
- if (foundModule) {
- this->AppendSuccessInformation();
- return true;
+ } else {
+ if (this->UseFindModules && this->FindPackageUsingModuleMode()) {
+ loadedPackage = true;
+ } else {
+ // Handle CMAKE_FIND_PACKAGE_WARN_NO_MODULE (warn when CONFIG mode is
+ // implicitly assumed)
+ if (this->UseFindModules && this->UseConfigFiles &&
+ this->Makefile->IsOn("CMAKE_FIND_PACKAGE_WARN_NO_MODULE")) {
+ std::ostringstream aw;
+ if (this->RequiredCMakeVersion >= CMake_VERSION_ENCODE(2, 8, 8)) {
+ aw << "find_package called without either MODULE or CONFIG option "
+ "and "
+ "no Find"
+ << this->Name
+ << ".cmake module is in CMAKE_MODULE_PATH. "
+ "Add MODULE to exclusively request Module mode and fail if "
+ "Find"
+ << this->Name
+ << ".cmake is missing. "
+ "Add CONFIG to exclusively request Config mode and search for "
+ "a "
+ "package configuration file provided by "
+ << this->Name << " (" << this->Name << "Config.cmake or "
+ << cmSystemTools::LowerCase(this->Name) << "-config.cmake). ";
+ } else {
+ aw << "find_package called without NO_MODULE option and no "
+ "Find"
+ << this->Name
+ << ".cmake module is in CMAKE_MODULE_PATH. "
+ "Add NO_MODULE to exclusively request Config mode and search "
+ "for a "
+ "package configuration file provided by "
+ << this->Name << " (" << this->Name << "Config.cmake or "
+ << cmSystemTools::LowerCase(this->Name)
+ << "-config.cmake). "
+ "Otherwise make Find"
+ << this->Name
+ << ".cmake available in "
+ "CMAKE_MODULE_PATH.";
+ }
+ aw << "\n"
+ "(Variable CMAKE_FIND_PACKAGE_WARN_NO_MODULE enabled this "
+ "warning.)";
+ this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, aw.str());
+ }
+
+ if (this->FindPackageUsingConfigMode()) {
+ loadedPackage = true;
+ }
}
}
- if (this->UseFindModules && this->UseConfigFiles &&
- this->Makefile->IsOn("CMAKE_FIND_PACKAGE_WARN_NO_MODULE")) {
- std::ostringstream aw;
- if (this->RequiredCMakeVersion >= CMake_VERSION_ENCODE(2, 8, 8)) {
- aw << "find_package called without either MODULE or CONFIG option and "
- "no Find"
- << this->Name
- << ".cmake module is in CMAKE_MODULE_PATH. "
- "Add MODULE to exclusively request Module mode and fail if "
- "Find"
- << this->Name
- << ".cmake is missing. "
- "Add CONFIG to exclusively request Config mode and search for a "
- "package configuration file provided by "
- << this->Name << " (" << this->Name << "Config.cmake or "
- << cmSystemTools::LowerCase(this->Name) << "-config.cmake). ";
- } else {
- aw
- << "find_package called without NO_MODULE option and no "
- "Find"
- << this->Name
- << ".cmake module is in CMAKE_MODULE_PATH. "
- "Add NO_MODULE to exclusively request Config mode and search for a "
- "package configuration file provided by "
- << this->Name << " (" << this->Name << "Config.cmake or "
- << cmSystemTools::LowerCase(this->Name) << "-config.cmake). "
- "Otherwise make Find"
- << this->Name << ".cmake available in "
- "CMAKE_MODULE_PATH.";
- }
- aw << "\n"
- "(Variable CMAKE_FIND_PACKAGE_WARN_NO_MODULE enabled this warning.)";
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, aw.str());
- }
-
- // No find module. Assume the project has a CMake config file. Use
- // a <package>_DIR cache variable to locate it.
- this->Variable = this->Name;
- this->Variable += "_DIR";
+ this->AppendSuccessInformation();
+ return loadedPackage;
+}
+
+bool cmFindPackageCommand::FindPackageUsingModuleMode()
+{
+ bool foundModule = false;
+ if (!this->FindModule(foundModule)) {
+ return false;
+ }
+ return foundModule;
+}
+
+bool cmFindPackageCommand::FindPackageUsingConfigMode()
+{
+ this->Variable = cmStrCat(this->Name, "_DIR");
// Add the default name.
if (this->Names.empty()) {
@@ -518,15 +599,12 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
// Add the default configs.
if (this->Configs.empty()) {
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- std::string config = *ni;
- config += "Config.cmake";
+ for (std::string const& n : this->Names) {
+ std::string config = cmStrCat(n, "Config.cmake");
this->Configs.push_back(config);
- config = cmSystemTools::LowerCase(*ni);
- config += "-config.cmake";
- this->Configs.push_back(config);
+ config = cmStrCat(cmSystemTools::LowerCase(n), "-config.cmake");
+ this->Configs.push_back(std::move(config));
}
}
@@ -540,9 +618,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
this->IgnoredPaths.insert(ignored.begin(), ignored.end());
// Find and load the package.
- bool result = this->HandlePackageMode();
- this->AppendSuccessInformation();
- return result;
+ return this->HandlePackageMode(HandlePackageModeType::Config);
}
void cmFindPackageCommand::SetModuleVariables(const std::string& components)
@@ -556,24 +632,21 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components)
if (this->Quiet) {
// Tell the module that is about to be read that it should find
// quietly.
- std::string quietly = this->Name;
- quietly += "_FIND_QUIETLY";
+ std::string quietly = cmStrCat(this->Name, "_FIND_QUIETLY");
this->AddFindDefinition(quietly, "1");
}
if (this->Required) {
// Tell the module that is about to be read that it should report
// a fatal error if the package is not found.
- std::string req = this->Name;
- req += "_FIND_REQUIRED";
+ std::string req = cmStrCat(this->Name, "_FIND_REQUIRED");
this->AddFindDefinition(req, "1");
}
if (!this->Version.empty()) {
// Tell the module that is about to be read what version of the
// package has been requested.
- std::string ver = this->Name;
- ver += "_FIND_VERSION";
+ std::string ver = cmStrCat(this->Name, "_FIND_VERSION");
this->AddFindDefinition(ver, this->Version.c_str());
char buf[64];
sprintf(buf, "%u", this->VersionMajor);
@@ -588,13 +661,9 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components)
this->AddFindDefinition(ver + "_COUNT", buf);
// Tell the module whether an exact version has been requested.
- std::string exact = this->Name;
- exact += "_FIND_VERSION_EXACT";
+ std::string exact = cmStrCat(this->Name, "_FIND_VERSION_EXACT");
this->AddFindDefinition(exact, this->VersionExact ? "1" : "0");
}
-
- // Push on to the pacakge stack
- this->Makefile->FindPackageModuleStack.push_back(this->Name);
}
void cmFindPackageCommand::AddFindDefinition(const std::string& var,
@@ -606,66 +675,81 @@ void cmFindPackageCommand::AddFindDefinition(const std::string& var,
} else {
this->OriginalDefs[var].exists = false;
}
- this->Makefile->AddDefinition(var, val);
+ if (val) {
+ this->Makefile->AddDefinition(var, val);
+ }
}
void cmFindPackageCommand::RestoreFindDefinitions()
{
- for (std::map<std::string, OriginalDef>::iterator i =
- this->OriginalDefs.begin();
- i != this->OriginalDefs.end(); ++i) {
- OriginalDef const& od = i->second;
+ for (auto const& i : this->OriginalDefs) {
+ OriginalDef const& od = i.second;
if (od.exists) {
- this->Makefile->AddDefinition(i->first, od.value.c_str());
+ this->Makefile->AddDefinition(i.first, od.value);
} else {
- this->Makefile->RemoveDefinition(i->first);
+ this->Makefile->RemoveDefinition(i.first);
}
}
}
bool cmFindPackageCommand::FindModule(bool& found)
{
- std::string module = "Find";
- module += this->Name;
- module += ".cmake";
- std::string mfile = this->Makefile->GetModulesFile(module.c_str());
+ std::string module = cmStrCat("Find", this->Name, ".cmake");
+ bool system = false;
+ std::string mfile = this->Makefile->GetModulesFile(module, system);
if (!mfile.empty()) {
+ if (system) {
+ auto it = this->DeprecatedFindModules.find(this->Name);
+ if (it != this->DeprecatedFindModules.end()) {
+ cmPolicies::PolicyStatus status =
+ this->Makefile->GetPolicyStatus(it->second);
+ switch (status) {
+ case cmPolicies::WARN: {
+ this->Makefile->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(cmPolicies::GetPolicyWarning(it->second), "\n"));
+ CM_FALLTHROUGH;
+ }
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ return true;
+ }
+ }
+ }
+
// Load the module we found, and set "<name>_FIND_MODULE" to true
// while inside it.
found = true;
- std::string var = this->Name;
- var += "_FIND_MODULE";
+ std::string var = cmStrCat(this->Name, "_FIND_MODULE");
this->Makefile->AddDefinition(var, "1");
- bool result = this->ReadListFile(mfile.c_str(), DoPolicyScope);
+ bool result = this->ReadListFile(mfile, DoPolicyScope);
this->Makefile->RemoveDefinition(var);
return result;
}
return true;
}
-bool cmFindPackageCommand::HandlePackageMode()
+bool cmFindPackageCommand::HandlePackageMode(
+ HandlePackageModeType handlePackageModeType)
{
this->ConsideredConfigs.clear();
- // Support old capitalization behavior.
- std::string upperDir = cmSystemTools::UpperCase(this->Name);
- std::string upperFound = cmSystemTools::UpperCase(this->Name);
- upperDir += "_DIR";
- upperFound += "_FOUND";
-
// Try to find the config file.
const char* def = this->Makefile->GetDefinition(this->Variable);
// Try to load the config file if the directory is known
bool fileFound = false;
if (this->UseConfigFiles) {
- if (!cmSystemTools::IsOff(def)) {
+ if (!cmIsOff(def)) {
// Get the directory from the variable value.
std::string dir = def;
cmSystemTools::ConvertToUnixSlashes(dir);
// Treat relative paths with respect to the current source dir.
- if (!cmSystemTools::FileIsFullPath(dir.c_str())) {
+ if (!cmSystemTools::FileIsFullPath(dir)) {
dir = "/" + dir;
dir = this->Makefile->GetCurrentSourceDirectory() + dir;
}
@@ -679,22 +763,21 @@ bool cmFindPackageCommand::HandlePackageMode()
}
// Search for the config file if it is not already found.
- if (cmSystemTools::IsOff(def) || !fileFound) {
+ if (cmIsOff(def) || !fileFound) {
fileFound = this->FindConfig();
}
// Sanity check.
if (fileFound && this->FileFound.empty()) {
this->Makefile->IssueMessage(
- cmake::INTERNAL_ERROR, "fileFound is true but FileFound is empty!");
+ MessageType::INTERNAL_ERROR,
+ "fileFound is true but FileFound is empty!");
fileFound = false;
}
}
- std::string foundVar = this->Name;
- foundVar += "_FOUND";
- std::string notFoundMessageVar = this->Name;
- notFoundMessageVar += "_NOT_FOUND_MESSAGE";
+ std::string foundVar = cmStrCat(this->Name, "_FOUND");
+ std::string notFoundMessageVar = cmStrCat(this->Name, "_NOT_FOUND_MESSAGE");
std::string notFoundMessage;
// If the directory for the config file was found, try to read the file.
@@ -718,7 +801,7 @@ bool cmFindPackageCommand::HandlePackageMode()
this->StoreVersionFound();
// Parse the configuration file.
- if (this->ReadListFile(this->FileFound.c_str(), DoPolicyScope)) {
+ if (this->ReadListFile(this->FileFound, DoPolicyScope)) {
// The package has been found.
found = true;
@@ -737,12 +820,20 @@ bool cmFindPackageCommand::HandlePackageMode()
}
}
+ if (this->UseFindModules && !found &&
+ handlePackageModeType == HandlePackageModeType::Config &&
+ this->Makefile->IsOn("CMAKE_FIND_PACKAGE_PREFER_CONFIG")) {
+ // Config mode failed. Allow Module case.
+ result = false;
+ }
+
// package not found
if (result && !found) {
// warn if package required or neither quiet nor in config mode
if (this->Required ||
- !(this->Quiet || (this->UseConfigFiles && !this->UseFindModules &&
- this->ConsideredConfigs.empty()))) {
+ !(this->Quiet ||
+ (this->UseConfigFiles && !this->UseFindModules &&
+ this->ConsideredConfigs.empty()))) {
// The variable is not set.
std::ostringstream e;
std::ostringstream aw;
@@ -760,25 +851,23 @@ bool cmFindPackageCommand::HandlePackageMode()
// If there are files in ConsideredConfigs, it means that FooConfig.cmake
// have been found, but they didn't have appropriate versions.
else if (!this->ConsideredConfigs.empty()) {
- std::vector<ConfigFileInfo>::const_iterator duplicate_end =
- cmRemoveDuplicates(this->ConsideredConfigs);
+ auto duplicate_end = cmRemoveDuplicates(this->ConsideredConfigs);
e << "Could not find a configuration file for package \"" << this->Name
<< "\" that "
<< (this->VersionExact ? "exactly matches" : "is compatible with")
<< " requested version \"" << this->Version << "\".\n"
<< "The following configuration files were considered but not "
"accepted:\n";
- for (std::vector<ConfigFileInfo>::const_iterator i =
- this->ConsideredConfigs.begin();
- i != duplicate_end; ++i) {
- e << " " << i->filename << ", version: " << i->version << "\n";
+
+ for (ConfigFileInfo const& info :
+ cmMakeRange(this->ConsideredConfigs.cbegin(), duplicate_end)) {
+ e << " " << info.filename << ", version: " << info.version << "\n";
}
} else {
std::string requestedVersionString;
if (!this->Version.empty()) {
- requestedVersionString = " (requested version ";
- requestedVersionString += this->Version;
- requestedVersionString += ")";
+ requestedVersionString =
+ cmStrCat(" (requested version ", this->Version, ')');
}
if (this->UseConfigFiles) {
@@ -787,8 +876,9 @@ bool cmFindPackageCommand::HandlePackageMode()
<< ".cmake\" in "
"CMAKE_MODULE_PATH this project has asked CMake to find a "
"package configuration file provided by \""
- << this->Name << "\", "
- "but CMake did not find one.\n";
+ << this->Name
+ << "\", "
+ "but CMake did not find one.\n";
}
if (this->Configs.size() == 1) {
@@ -809,8 +899,9 @@ bool cmFindPackageCommand::HandlePackageMode()
<< "\" to a "
"directory containing one of the above files. "
"If \""
- << this->Name << "\" provides a separate development "
- "package or SDK, be sure it has been installed.";
+ << this->Name
+ << "\" provides a separate development "
+ "package or SDK, be sure it has been installed.";
} else // if(!this->UseFindModules && !this->UseConfigFiles)
{
e << "No \"Find" << this->Name << ".cmake\" found in "
@@ -834,22 +925,23 @@ bool cmFindPackageCommand::HandlePackageMode()
}
}
- this->Makefile->IssueMessage(
- this->Required ? cmake::FATAL_ERROR : cmake::WARNING, e.str());
+ this->Makefile->IssueMessage(this->Required ? MessageType::FATAL_ERROR
+ : MessageType::WARNING,
+ e.str());
if (this->Required) {
cmSystemTools::SetFatalErrorOccured();
}
if (!aw.str().empty()) {
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, aw.str());
+ this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, aw.str());
}
}
// output result if in config mode but not in quiet mode
else if (!this->Quiet) {
- std::ostringstream aw;
- aw << "Could NOT find " << this->Name << " (missing: " << this->Name
- << "_DIR)";
- this->Makefile->DisplayStatus(aw.str().c_str(), -1);
+ this->Makefile->DisplayStatus(cmStrCat("Could NOT find ", this->Name,
+ " (missing: ", this->Name,
+ "_DIR)"),
+ -1);
}
}
@@ -857,38 +949,33 @@ bool cmFindPackageCommand::HandlePackageMode()
this->Makefile->AddDefinition(foundVar, found ? "1" : "0");
// Set a variable naming the configuration file that was found.
- std::string fileVar = this->Name;
- fileVar += "_CONFIG";
+ std::string fileVar = cmStrCat(this->Name, "_CONFIG");
if (found) {
- this->Makefile->AddDefinition(fileVar, this->FileFound.c_str());
+ this->Makefile->AddDefinition(fileVar, this->FileFound);
} else {
this->Makefile->RemoveDefinition(fileVar);
}
- std::string consideredConfigsVar = this->Name;
- consideredConfigsVar += "_CONSIDERED_CONFIGS";
- std::string consideredVersionsVar = this->Name;
- consideredVersionsVar += "_CONSIDERED_VERSIONS";
+ std::string consideredConfigsVar =
+ cmStrCat(this->Name, "_CONSIDERED_CONFIGS");
+ std::string consideredVersionsVar =
+ cmStrCat(this->Name, "_CONSIDERED_VERSIONS");
std::string consideredConfigFiles;
std::string consideredVersions;
const char* sep = "";
- for (std::vector<ConfigFileInfo>::const_iterator i =
- this->ConsideredConfigs.begin();
- i != this->ConsideredConfigs.end(); ++i) {
+ for (ConfigFileInfo const& i : this->ConsideredConfigs) {
consideredConfigFiles += sep;
consideredVersions += sep;
- consideredConfigFiles += i->filename;
- consideredVersions += i->version;
+ consideredConfigFiles += i.filename;
+ consideredVersions += i.version;
sep = ";";
}
- this->Makefile->AddDefinition(consideredConfigsVar,
- consideredConfigFiles.c_str());
+ this->Makefile->AddDefinition(consideredConfigsVar, consideredConfigFiles);
- this->Makefile->AddDefinition(consideredVersionsVar,
- consideredVersions.c_str());
+ this->Makefile->AddDefinition(consideredVersionsVar, consideredVersions);
return result;
}
@@ -934,9 +1021,8 @@ bool cmFindPackageCommand::FindConfig()
init = this->Variable + "-NOTFOUND";
}
std::string help =
- "The directory containing a CMake configuration file for ";
- help += this->Name;
- help += ".";
+ cmStrCat("The directory containing a CMake configuration file for ",
+ this->Name, '.');
// We force the value since we do not get here if it was already set.
this->Makefile->AddCacheDefinition(this->Variable, init.c_str(),
help.c_str(), cmStateEnums::PATH, true);
@@ -946,9 +1032,8 @@ bool cmFindPackageCommand::FindConfig()
bool cmFindPackageCommand::FindPrefixedConfig()
{
std::vector<std::string> const& prefixes = this->SearchPaths;
- for (std::vector<std::string>::const_iterator pi = prefixes.begin();
- pi != prefixes.end(); ++pi) {
- if (this->SearchPrefix(*pi)) {
+ for (std::string const& p : prefixes) {
+ if (this->SearchPrefix(p)) {
return true;
}
}
@@ -958,9 +1043,8 @@ bool cmFindPackageCommand::FindPrefixedConfig()
bool cmFindPackageCommand::FindFrameworkConfig()
{
std::vector<std::string> const& prefixes = this->SearchPaths;
- for (std::vector<std::string>::const_iterator i = prefixes.begin();
- i != prefixes.end(); ++i) {
- if (this->SearchFrameworkPrefix(*i)) {
+ for (std::string const& p : prefixes) {
+ if (this->SearchFrameworkPrefix(p)) {
return true;
}
}
@@ -970,24 +1054,22 @@ bool cmFindPackageCommand::FindFrameworkConfig()
bool cmFindPackageCommand::FindAppBundleConfig()
{
std::vector<std::string> const& prefixes = this->SearchPaths;
- for (std::vector<std::string>::const_iterator i = prefixes.begin();
- i != prefixes.end(); ++i) {
- if (this->SearchAppBundlePrefix(*i)) {
+ for (std::string const& p : prefixes) {
+ if (this->SearchAppBundlePrefix(p)) {
return true;
}
}
return false;
}
-bool cmFindPackageCommand::ReadListFile(const char* f, PolicyScopeRule psr)
+bool cmFindPackageCommand::ReadListFile(const std::string& f,
+ PolicyScopeRule psr)
{
const bool noPolicyScope = !this->PolicyScope || psr == NoPolicyScope;
if (this->Makefile->ReadDependentFile(f, noPolicyScope)) {
return true;
}
- std::string e = "Error reading CMake code from \"";
- e += f;
- e += "\".";
+ std::string e = cmStrCat("Error reading CMake code from \"", f, "\".");
this->SetError(e);
return false;
}
@@ -1000,8 +1082,8 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found)
if (foundProp && *foundProp) {
std::string tmp = foundProp;
- cmSystemTools::ExpandListArgument(tmp, foundContents, false);
- std::vector<std::string>::iterator nameIt =
+ cmExpandList(tmp, foundContents, false);
+ auto nameIt =
std::find(foundContents.begin(), foundContents.end(), this->Name);
if (nameIt != foundContents.end()) {
foundContents.erase(nameIt);
@@ -1014,8 +1096,8 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found)
if (notFoundProp && *notFoundProp) {
std::string tmp = notFoundProp;
- cmSystemTools::ExpandListArgument(tmp, notFoundContents, false);
- std::vector<std::string>::iterator nameIt =
+ cmExpandList(tmp, notFoundContents, false);
+ auto nameIt =
std::find(notFoundContents.begin(), notFoundContents.end(), this->Name);
if (nameIt != notFoundContents.end()) {
notFoundContents.erase(nameIt);
@@ -1039,45 +1121,38 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found)
void cmFindPackageCommand::AppendSuccessInformation()
{
{
- std::string transitivePropName = "_CMAKE_";
- transitivePropName += this->Name + "_TRANSITIVE_DEPENDENCY";
+ std::string transitivePropName =
+ cmStrCat("_CMAKE_", this->Name, "_TRANSITIVE_DEPENDENCY");
this->Makefile->GetState()->SetGlobalProperty(transitivePropName, "False");
}
- std::string found = this->Name;
- found += "_FOUND";
+ std::string found = cmStrCat(this->Name, "_FOUND");
std::string upperFound = cmSystemTools::UpperCase(found);
const char* upperResult = this->Makefile->GetDefinition(upperFound);
const char* result = this->Makefile->GetDefinition(found);
- bool packageFound =
- ((cmSystemTools::IsOn(result)) || (cmSystemTools::IsOn(upperResult)));
+ bool packageFound = ((cmIsOn(result)) || (cmIsOn(upperResult)));
this->AppendToFoundProperty(packageFound);
// Record whether the find was quiet or not, so this can be used
// e.g. in FeatureSummary.cmake
- std::string quietInfoPropName = "_CMAKE_";
- quietInfoPropName += this->Name;
- quietInfoPropName += "_QUIET";
+ std::string quietInfoPropName = cmStrCat("_CMAKE_", this->Name, "_QUIET");
this->Makefile->GetState()->SetGlobalProperty(
quietInfoPropName, this->Quiet ? "TRUE" : "FALSE");
// set a global property to record the required version of this package
- std::string versionInfoPropName = "_CMAKE_";
- versionInfoPropName += this->Name;
- versionInfoPropName += "_REQUIRED_VERSION";
+ std::string versionInfoPropName =
+ cmStrCat("_CMAKE_", this->Name, "_REQUIRED_VERSION");
std::string versionInfo;
if (!this->Version.empty()) {
- versionInfo = this->VersionExact ? "==" : ">=";
- versionInfo += " ";
- versionInfo += this->Version;
+ versionInfo =
+ cmStrCat(this->VersionExact ? "==" : ">=", ' ', this->Version);
}
this->Makefile->GetState()->SetGlobalProperty(versionInfoPropName,
versionInfo.c_str());
if (this->Required) {
- std::string requiredInfoPropName = "_CMAKE_";
- requiredInfoPropName += this->Name;
- requiredInfoPropName += "_TYPE";
+ std::string requiredInfoPropName =
+ cmStrCat("_CMAKE_", this->Name, "_TYPE");
this->Makefile->GetState()->SetGlobalProperty(requiredInfoPropName,
"REQUIRED");
}
@@ -1086,7 +1161,7 @@ void cmFindPackageCommand::AppendSuccessInformation()
this->RestoreFindDefinitions();
// Pop the package stack
- this->Makefile->FindPackageModuleStack.pop_back();
+ this->Makefile->FindPackageRootPathStack.pop_back();
}
void cmFindPackageCommand::ComputePrefixes()
@@ -1126,16 +1201,13 @@ void cmFindPackageCommand::FillPrefixesPackageRoot()
{
cmSearchPath& paths = this->LabeledPaths[PathLabel::PackageRoot];
- // Add package specific search prefixes
- // NOTE: This should be using const_reverse_iterator but HP aCC and
- // Oracle sunCC both currently have standard library issues
- // with the reverse iterator APIs.
- for (std::deque<std::string>::reverse_iterator pkg =
- this->Makefile->FindPackageModuleStack.rbegin();
- pkg != this->Makefile->FindPackageModuleStack.rend(); ++pkg) {
- std::string varName = *pkg + "_ROOT";
- paths.AddCMakePath(varName);
- paths.AddEnvPath(varName);
+ // Add the PACKAGE_ROOT_PATH from each enclosing find_package call.
+ for (auto pkgPaths = this->Makefile->FindPackageRootPathStack.rbegin();
+ pkgPaths != this->Makefile->FindPackageRootPathStack.rend();
+ ++pkgPaths) {
+ for (std::string const& path : *pkgPaths) {
+ paths.AddPath(path);
+ }
}
}
@@ -1171,14 +1243,12 @@ void cmFindPackageCommand::FillPrefixesSystemEnvironment()
// working directory.
std::vector<std::string> tmp;
cmSystemTools::GetPath(tmp);
- for (std::vector<std::string>::iterator i = tmp.begin(); i != tmp.end();
- ++i) {
+ for (std::string const& i : tmp) {
// If the path is a PREFIX/bin case then add its parent instead.
- if ((cmHasLiteralSuffix(*i, "/bin")) ||
- (cmHasLiteralSuffix(*i, "/sbin"))) {
- paths.AddPath(cmSystemTools::GetFilenamePath(*i));
+ if ((cmHasLiteralSuffix(i, "/bin")) || (cmHasLiteralSuffix(i, "/sbin"))) {
+ paths.AddPath(cmSystemTools::GetFilenamePath(i));
} else {
- paths.AddPath(*i);
+ paths.AddPath(i);
}
}
}
@@ -1191,9 +1261,7 @@ void cmFindPackageCommand::FillPrefixesUserRegistry()
char dir[B_PATH_NAME_LENGTH];
if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, dir, sizeof(dir)) ==
B_OK) {
- std::string fname = dir;
- fname += "/cmake/packages/";
- fname += Name;
+ std::string fname = cmStrCat(dir, "/cmake/packages/", Name);
this->LoadPackageRegistryDir(fname,
this->LabeledPaths[PathLabel::UserRegistry]);
}
@@ -1220,14 +1288,14 @@ void cmFindPackageCommand::FillPrefixesSystemRegistry()
}
#if defined(_WIN32) && !defined(__CYGWIN__)
-#include <windows.h>
+# include <windows.h>
// http://msdn.microsoft.com/en-us/library/aa384253%28v=vs.85%29.aspx
-#if !defined(KEY_WOW64_32KEY)
-#define KEY_WOW64_32KEY 0x0200
-#endif
-#if !defined(KEY_WOW64_64KEY)
-#define KEY_WOW64_64KEY 0x0100
-#endif
+# if !defined(KEY_WOW64_32KEY)
+# define KEY_WOW64_32KEY 0x0200
+# endif
+# if !defined(KEY_WOW64_64KEY)
+# define KEY_WOW64_64KEY 0x0100
+# endif
void cmFindPackageCommand::LoadPackageRegistryWinUser()
{
// HKEY_CURRENT_USER\\Software shares 32-bit and 64-bit views.
@@ -1296,9 +1364,8 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user, unsigned int view,
if (user && !bad.empty() &&
RegOpenKeyExW(HKEY_CURRENT_USER, key.c_str(), 0, KEY_SET_VALUE | view,
&hKey) == ERROR_SUCCESS) {
- for (std::set<std::wstring>::const_iterator vi = bad.begin();
- vi != bad.end(); ++vi) {
- RegDeleteValueW(hKey, vi->c_str());
+ for (std::wstring const& v : bad) {
+ RegDeleteValueW(hKey, v.c_str());
}
RegCloseKey(hKey);
}
@@ -1319,7 +1386,10 @@ public:
cmSystemTools::RemoveFile(this->File);
}
}
- void Release() { this->File = CM_NULLPTR; }
+ cmFindPackageCommandHoldFile(const cmFindPackageCommandHoldFile&) = delete;
+ cmFindPackageCommandHoldFile& operator=(
+ const cmFindPackageCommandHoldFile&) = delete;
+ void Release() { this->File = nullptr; }
};
void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir,
@@ -1332,9 +1402,7 @@ void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir,
std::string fname;
for (unsigned long i = 0; i < files.GetNumberOfFiles(); ++i) {
- fname = dir;
- fname += "/";
- fname += files.GetFile(i);
+ fname = cmStrCat(dir, '/', files.GetFile(i));
if (!cmSystemTools::FileIsDirectory(fname)) {
// Hold this file hostage until it behaves.
@@ -1359,10 +1427,10 @@ bool cmFindPackageCommand::CheckPackageRegistryEntry(const std::string& fname,
cmSearchPath& outPaths)
{
// Parse the content of one package registry entry.
- if (cmSystemTools::FileIsFullPath(fname.c_str())) {
+ if (cmSystemTools::FileIsFullPath(fname)) {
// The first line in the stream is the full path to a file or
// directory containing the package.
- if (cmSystemTools::FileExists(fname.c_str())) {
+ if (cmSystemTools::FileExists(fname)) {
// The path exists. Look for the package here.
if (!cmSystemTools::FileIsDirectory(fname)) {
outPaths.AddPath(cmSystemTools::GetFilenamePath(fname));
@@ -1395,10 +1463,8 @@ void cmFindPackageCommand::FillPrefixesUserGuess()
{
cmSearchPath& paths = this->LabeledPaths[PathLabel::Guess];
- for (std::vector<std::string>::const_iterator p =
- this->UserGuessArgs.begin();
- p != this->UserGuessArgs.end(); ++p) {
- paths.AddUserPath(*p);
+ for (std::string const& p : this->UserGuessArgs) {
+ paths.AddUserPath(p);
}
}
@@ -1406,24 +1472,20 @@ void cmFindPackageCommand::FillPrefixesUserHints()
{
cmSearchPath& paths = this->LabeledPaths[PathLabel::Hints];
- for (std::vector<std::string>::const_iterator p =
- this->UserHintsArgs.begin();
- p != this->UserHintsArgs.end(); ++p) {
- paths.AddUserPath(*p);
+ for (std::string const& p : this->UserHintsArgs) {
+ paths.AddUserPath(p);
}
}
bool cmFindPackageCommand::SearchDirectory(std::string const& dir)
{
- assert(!dir.empty() && dir[dir.size() - 1] == '/');
+ assert(!dir.empty() && dir.back() == '/');
// Check each path suffix on this directory.
- for (std::vector<std::string>::const_iterator si =
- this->SearchPathSuffixes.begin();
- si != this->SearchPathSuffixes.end(); ++si) {
+ for (std::string const& s : this->SearchPathSuffixes) {
std::string d = dir;
- if (!si->empty()) {
- d += *si;
+ if (!s.empty()) {
+ d += s;
d += "/";
}
if (this->CheckDirectory(d)) {
@@ -1435,7 +1497,7 @@ bool cmFindPackageCommand::SearchDirectory(std::string const& dir)
bool cmFindPackageCommand::CheckDirectory(std::string const& dir)
{
- assert(!dir.empty() && dir[dir.size() - 1] == '/');
+ assert(!dir.empty() && dir.back() == '/');
// Look for the file in this directory.
std::string d = dir.substr(0, dir.size() - 1);
@@ -1454,16 +1516,16 @@ bool cmFindPackageCommand::FindConfigFile(std::string const& dir,
return false;
}
- for (std::vector<std::string>::const_iterator ci = this->Configs.begin();
- ci != this->Configs.end(); ++ci) {
- file = dir;
- file += "/";
- file += *ci;
+ for (std::string const& c : this->Configs) {
+ file = cmStrCat(dir, '/', c);
if (this->DebugMode) {
fprintf(stderr, "Checking file [%s]\n", file.c_str());
}
- if (cmSystemTools::FileExists(file.c_str(), true) &&
- this->CheckVersion(file)) {
+ if (cmSystemTools::FileExists(file, true) && this->CheckVersion(file)) {
+ // Allow resolving symlinks when the config file is found through a link
+ if (this->UseRealPath) {
+ file = cmSystemTools::GetRealPath(file);
+ }
return true;
}
}
@@ -1481,17 +1543,15 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
std::string version_file_base = config_file.substr(0, pos);
// Look for foo-config-version.cmake
- std::string version_file = version_file_base;
- version_file += "-version.cmake";
- if (!haveResult && cmSystemTools::FileExists(version_file.c_str(), true)) {
+ std::string version_file = cmStrCat(version_file_base, "-version.cmake");
+ if (!haveResult && cmSystemTools::FileExists(version_file, true)) {
result = this->CheckVersionFile(version_file, version);
haveResult = true;
}
// Look for fooConfigVersion.cmake
- version_file = version_file_base;
- version_file += "Version.cmake";
- if (!haveResult && cmSystemTools::FileExists(version_file.c_str(), true)) {
+ version_file = cmStrCat(version_file_base, "Version.cmake");
+ if (!haveResult && cmSystemTools::FileExists(version_file, true)) {
result = this->CheckVersionFile(version_file, version);
haveResult = true;
}
@@ -1504,7 +1564,7 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
ConfigFileInfo configFileInfo;
configFileInfo.filename = config_file;
configFileInfo.version = version;
- this->ConsideredConfigs.push_back(configFileInfo);
+ this->ConsideredConfigs.push_back(std::move(configFileInfo));
return result;
}
@@ -1525,8 +1585,8 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file,
this->Makefile->RemoveDefinition("PACKAGE_VERSION_EXACT");
// Set the input variables.
- this->Makefile->AddDefinition("PACKAGE_FIND_NAME", this->Name.c_str());
- this->Makefile->AddDefinition("PACKAGE_FIND_VERSION", this->Version.c_str());
+ this->Makefile->AddDefinition("PACKAGE_FIND_NAME", this->Name);
+ this->Makefile->AddDefinition("PACKAGE_FIND_VERSION", this->Version);
char buf[64];
sprintf(buf, "%u", this->VersionMajor);
this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MAJOR", buf);
@@ -1542,7 +1602,7 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file,
// Load the version check file. Pass NoPolicyScope because we do
// our own policy push/pop independent of CMP0011.
bool suitable = false;
- if (this->ReadListFile(version_file.c_str(), NoPolicyScope)) {
+ if (this->ReadListFile(version_file, NoPolicyScope)) {
// Check the output variables.
bool okay = this->Makefile->IsOn("PACKAGE_VERSION_EXACT");
bool unsuitable = this->Makefile->IsOn("PACKAGE_VERSION_UNSUITABLE");
@@ -1598,12 +1658,11 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file,
void cmFindPackageCommand::StoreVersionFound()
{
// Store the whole version string.
- std::string ver = this->Name;
- ver += "_VERSION";
+ std::string ver = cmStrCat(this->Name, "_VERSION");
if (this->VersionFound.empty()) {
this->Makefile->RemoveDefinition(ver);
} else {
- this->Makefile->AddDefinition(ver, this->VersionFound.c_str());
+ this->Makefile->AddDefinition(ver, this->VersionFound);
}
// Store the version components.
@@ -1623,7 +1682,7 @@ void cmFindPackageCommand::StoreVersionFound()
class cmFileListGeneratorBase
{
public:
- virtual ~cmFileListGeneratorBase() {}
+ virtual ~cmFileListGeneratorBase() = default;
protected:
bool Consider(std::string const& fullPath, cmFileList& listing);
@@ -1631,21 +1690,16 @@ protected:
private:
bool Search(cmFileList&);
virtual bool Search(std::string const& parent, cmFileList&) = 0;
- virtual CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const = 0;
+ virtual std::unique_ptr<cmFileListGeneratorBase> Clone() const = 0;
friend class cmFileList;
cmFileListGeneratorBase* SetNext(cmFileListGeneratorBase const& next);
- CM_AUTO_PTR<cmFileListGeneratorBase> Next;
+ std::unique_ptr<cmFileListGeneratorBase> Next;
};
class cmFileList
{
public:
- cmFileList()
- : First()
- , Last(CM_NULLPTR)
- {
- }
- virtual ~cmFileList() {}
+ virtual ~cmFileList() = default;
cmFileList& operator/(cmFileListGeneratorBase const& rhs)
{
if (this->Last) {
@@ -1658,7 +1712,7 @@ public:
}
bool Search()
{
- if (this->First.get()) {
+ if (this->First) {
return this->First->Search(*this);
}
return false;
@@ -1667,22 +1721,21 @@ public:
private:
virtual bool Visit(std::string const& fullPath) = 0;
friend class cmFileListGeneratorBase;
- CM_AUTO_PTR<cmFileListGeneratorBase> First;
- cmFileListGeneratorBase* Last;
+ std::unique_ptr<cmFileListGeneratorBase> First;
+ cmFileListGeneratorBase* Last = nullptr;
};
class cmFindPackageFileList : public cmFileList
{
public:
cmFindPackageFileList(cmFindPackageCommand* fpc, bool use_suffixes = true)
- : cmFileList()
- , FPC(fpc)
+ : FPC(fpc)
, UseSuffixes(use_suffixes)
{
}
private:
- bool Visit(std::string const& fullPath) CM_OVERRIDE
+ bool Visit(std::string const& fullPath) override
{
if (this->UseSuffixes) {
return this->FPC->SearchDirectory(fullPath);
@@ -1708,7 +1761,7 @@ cmFileListGeneratorBase* cmFileListGeneratorBase::SetNext(
bool cmFileListGeneratorBase::Consider(std::string const& fullPath,
cmFileList& listing)
{
- if (this->Next.get()) {
+ if (this->Next) {
return this->Next->Search(fullPath + "/", listing);
}
return listing.Visit(fullPath + "/");
@@ -1717,27 +1770,25 @@ bool cmFileListGeneratorBase::Consider(std::string const& fullPath,
class cmFileListGeneratorFixed : public cmFileListGeneratorBase
{
public:
- cmFileListGeneratorFixed(std::string const& str)
- : cmFileListGeneratorBase()
- , String(str)
+ cmFileListGeneratorFixed(std::string str)
+ : String(std::move(str))
{
}
cmFileListGeneratorFixed(cmFileListGeneratorFixed const& r)
- : cmFileListGeneratorBase()
- , String(r.String)
+ : String(r.String)
{
}
private:
std::string String;
- bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE
+ bool Search(std::string const& parent, cmFileList& lister) override
{
std::string fullPath = parent + this->String;
return this->Consider(fullPath, lister);
}
- CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const CM_OVERRIDE
+ std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{
- CM_AUTO_PTR<cmFileListGeneratorBase> g(
+ std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorFixed(*this));
return g;
}
@@ -1747,31 +1798,28 @@ class cmFileListGeneratorEnumerate : public cmFileListGeneratorBase
{
public:
cmFileListGeneratorEnumerate(std::vector<std::string> const& v)
- : cmFileListGeneratorBase()
- , Vector(v)
+ : Vector(v)
{
}
cmFileListGeneratorEnumerate(cmFileListGeneratorEnumerate const& r)
- : cmFileListGeneratorBase()
- , Vector(r.Vector)
+ : Vector(r.Vector)
{
}
private:
std::vector<std::string> const& Vector;
- bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE
+ bool Search(std::string const& parent, cmFileList& lister) override
{
- for (std::vector<std::string>::const_iterator i = this->Vector.begin();
- i != this->Vector.end(); ++i) {
- if (this->Consider(parent + *i, lister)) {
+ for (std::string const& i : this->Vector) {
+ if (this->Consider(parent + i, lister)) {
return true;
}
}
return false;
}
- CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const CM_OVERRIDE
+ std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{
- CM_AUTO_PTR<cmFileListGeneratorBase> g(
+ std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorEnumerate(*this));
return g;
}
@@ -1783,14 +1831,12 @@ public:
cmFileListGeneratorProject(std::vector<std::string> const& names,
cmFindPackageCommand::SortOrderType so,
cmFindPackageCommand::SortDirectionType sd)
- : cmFileListGeneratorBase()
- , Names(names)
+ : Names(names)
{
this->SetSort(so, sd);
}
cmFileListGeneratorProject(cmFileListGeneratorProject const& r)
- : cmFileListGeneratorBase()
- , Names(r.Names)
+ : Names(r.Names)
{
this->SetSort(r.SortOrder, r.SortDirection);
}
@@ -1809,7 +1855,7 @@ protected:
private:
std::vector<std::string> const& Names;
- bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE
+ bool Search(std::string const& parent, cmFileList& lister) override
{
// Construct a list of matches.
std::vector<std::string> matches;
@@ -1820,10 +1866,9 @@ private:
if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) {
continue;
}
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- if (cmsysString_strncasecmp(fname, ni->c_str(), ni->length()) == 0) {
- matches.push_back(fname);
+ for (std::string const& n : this->Names) {
+ if (cmsysString_strncasecmp(fname, n.c_str(), n.length()) == 0) {
+ matches.emplace_back(fname);
}
}
}
@@ -1835,17 +1880,16 @@ private:
SortDirection);
}
- for (std::vector<std::string>::const_iterator i = matches.begin();
- i != matches.end(); ++i) {
- if (this->Consider(parent + *i, lister)) {
+ for (std::string const& i : matches) {
+ if (this->Consider(parent + i, lister)) {
return true;
}
}
return false;
}
- CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const CM_OVERRIDE
+ std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{
- CM_AUTO_PTR<cmFileListGeneratorBase> g(
+ std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorProject(*this));
return g;
}
@@ -1856,14 +1900,12 @@ class cmFileListGeneratorMacProject : public cmFileListGeneratorBase
public:
cmFileListGeneratorMacProject(std::vector<std::string> const& names,
const char* ext)
- : cmFileListGeneratorBase()
- , Names(names)
+ : Names(names)
, Extension(ext)
{
}
cmFileListGeneratorMacProject(cmFileListGeneratorMacProject const& r)
- : cmFileListGeneratorBase()
- , Names(r.Names)
+ : Names(r.Names)
, Extension(r.Extension)
{
}
@@ -1871,7 +1913,7 @@ public:
private:
std::vector<std::string> const& Names;
std::string Extension;
- bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE
+ bool Search(std::string const& parent, cmFileList& lister) override
{
// Construct a list of matches.
std::vector<std::string> matches;
@@ -1882,27 +1924,24 @@ private:
if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) {
continue;
}
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- std::string name = *ni;
+ for (std::string name : this->Names) {
name += this->Extension;
if (cmsysString_strcasecmp(fname, name.c_str()) == 0) {
- matches.push_back(fname);
+ matches.emplace_back(fname);
}
}
}
- for (std::vector<std::string>::const_iterator i = matches.begin();
- i != matches.end(); ++i) {
- if (this->Consider(parent + *i, lister)) {
+ for (std::string const& i : matches) {
+ if (this->Consider(parent + i, lister)) {
return true;
}
}
return false;
}
- CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const CM_OVERRIDE
+ std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{
- CM_AUTO_PTR<cmFileListGeneratorBase> g(
+ std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorMacProject(*this));
return g;
}
@@ -1911,21 +1950,19 @@ private:
class cmFileListGeneratorCaseInsensitive : public cmFileListGeneratorBase
{
public:
- cmFileListGeneratorCaseInsensitive(std::string const& str)
- : cmFileListGeneratorBase()
- , String(str)
+ cmFileListGeneratorCaseInsensitive(std::string str)
+ : String(std::move(str))
{
}
cmFileListGeneratorCaseInsensitive(
cmFileListGeneratorCaseInsensitive const& r)
- : cmFileListGeneratorBase()
- , String(r.String)
+ : String(r.String)
{
}
private:
std::string String;
- bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE
+ bool Search(std::string const& parent, cmFileList& lister) override
{
// Look for matching files.
std::vector<std::string> matches;
@@ -1944,9 +1981,9 @@ private:
}
return false;
}
- CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const CM_OVERRIDE
+ std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{
- CM_AUTO_PTR<cmFileListGeneratorBase> g(
+ std::unique_ptr<cmFileListGeneratorBase> g(
new cmFileListGeneratorCaseInsensitive(*this));
return g;
}
@@ -1955,24 +1992,21 @@ private:
class cmFileListGeneratorGlob : public cmFileListGeneratorBase
{
public:
- cmFileListGeneratorGlob(std::string const& str)
- : cmFileListGeneratorBase()
- , Pattern(str)
+ cmFileListGeneratorGlob(std::string str)
+ : Pattern(std::move(str))
{
}
cmFileListGeneratorGlob(cmFileListGeneratorGlob const& r)
- : cmFileListGeneratorBase()
- , Pattern(r.Pattern)
+ : Pattern(r.Pattern)
{
}
private:
std::string Pattern;
- bool Search(std::string const& parent, cmFileList& lister) CM_OVERRIDE
+ bool Search(std::string const& parent, cmFileList& lister) override
{
// Glob the set of matching files.
- std::string expr = parent;
- expr += this->Pattern;
+ std::string expr = cmStrCat(parent, this->Pattern);
cmsys::Glob g;
if (!g.FindFiles(expr)) {
return false;
@@ -1980,26 +2014,24 @@ private:
std::vector<std::string> const& files = g.GetFiles();
// Look for directories among the matches.
- for (std::vector<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
- if (cmSystemTools::FileIsDirectory(*fi)) {
- if (this->Consider(*fi, lister)) {
+ for (std::string const& f : files) {
+ if (cmSystemTools::FileIsDirectory(f)) {
+ if (this->Consider(f, lister)) {
return true;
}
}
}
return false;
}
- CM_AUTO_PTR<cmFileListGeneratorBase> Clone() const CM_OVERRIDE
+ std::unique_ptr<cmFileListGeneratorBase> Clone() const override
{
- CM_AUTO_PTR<cmFileListGeneratorBase> g(new cmFileListGeneratorGlob(*this));
- return g;
+ return cm::make_unique<cmFileListGeneratorGlob>(*this);
}
};
bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
{
- assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/');
+ assert(!prefix_in.empty() && prefix_in.back() == '/');
if (this->DebugMode) {
fprintf(stderr, "Checking prefix [%s]\n", prefix_in.c_str());
}
@@ -2057,18 +2089,18 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
common.push_back("lib/" + this->LibraryArchitecture);
}
if (this->UseLib32Paths) {
- common.push_back("lib32");
+ common.emplace_back("lib32");
}
if (this->UseLib64Paths) {
- common.push_back("lib64");
+ common.emplace_back("lib64");
}
if (this->UseLibx32Paths) {
- common.push_back("libx32");
+ common.emplace_back("libx32");
}
- common.push_back("lib");
- common.push_back("share");
+ common.emplace_back("lib");
+ common.emplace_back("share");
- // PREFIX/(lib/ARCH|lib|share)/cmake/(Foo|foo|FOO).*/
+ // PREFIX/(lib/ARCH|lib*|share)/cmake/(Foo|foo|FOO).*/
{
cmFindPackageFileList lister(this);
lister / cmFileListGeneratorFixed(prefix) /
@@ -2081,7 +2113,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
}
}
- // PREFIX/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/
+ // PREFIX/(lib/ARCH|lib*|share)/(Foo|foo|FOO).*/
{
cmFindPackageFileList lister(this);
lister / cmFileListGeneratorFixed(prefix) /
@@ -2093,7 +2125,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
}
}
- // PREFIX/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/(cmake|CMake)/
+ // PREFIX/(lib/ARCH|lib*|share)/(Foo|foo|FOO).*/(cmake|CMake)/
{
cmFindPackageFileList lister(this);
lister / cmFileListGeneratorFixed(prefix) /
@@ -2106,7 +2138,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
}
}
- // PREFIX/(Foo|foo|FOO).*/(lib/ARCH|lib|share)/cmake/(Foo|foo|FOO).*/
+ // PREFIX/(Foo|foo|FOO).*/(lib/ARCH|lib*|share)/cmake/(Foo|foo|FOO).*/
{
cmFindPackageFileList lister(this);
lister / cmFileListGeneratorFixed(prefix) /
@@ -2121,7 +2153,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
}
}
- // PREFIX/(Foo|foo|FOO).*/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/
+ // PREFIX/(Foo|foo|FOO).*/(lib/ARCH|lib*|share)/(Foo|foo|FOO).*/
{
cmFindPackageFileList lister(this);
lister / cmFileListGeneratorFixed(prefix) /
@@ -2135,7 +2167,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
}
}
- // PREFIX/(Foo|foo|FOO).*/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/(cmake|CMake)/
+ // PREFIX/(Foo|foo|FOO).*/(lib/ARCH|lib*|share)/(Foo|foo|FOO).*/(cmake|CMake)/
{
cmFindPackageFileList lister(this);
lister / cmFileListGeneratorFixed(prefix) /
@@ -2155,7 +2187,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
bool cmFindPackageCommand::SearchFrameworkPrefix(std::string const& prefix_in)
{
- assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/');
+ assert(!prefix_in.empty() && prefix_in.back() == '/');
if (this->DebugMode) {
fprintf(stderr, "Checking framework prefix [%s]\n", prefix_in.c_str());
}
@@ -2216,7 +2248,7 @@ bool cmFindPackageCommand::SearchFrameworkPrefix(std::string const& prefix_in)
bool cmFindPackageCommand::SearchAppBundlePrefix(std::string const& prefix_in)
{
- assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/');
+ assert(!prefix_in.empty() && prefix_in.back() == '/');
if (this->DebugMode) {
fprintf(stderr, "Checking bundle prefix [%s]\n", prefix_in.c_str());
}
@@ -2252,3 +2284,9 @@ bool cmFindPackageCommand::SearchAppBundlePrefix(std::string const& prefix_in)
}
// TODO: Debug cmsys::Glob double slash problem.
+
+bool cmFindPackage(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return cmFindPackageCommand(status).InitialPass(args);
+}
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index 99b0059ba..85fe7b6e5 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -3,17 +3,31 @@
#ifndef cmFindPackageCommand_h
#define cmFindPackageCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cm_kwiml.h"
+#include <cstddef>
+#include <functional>
#include <map>
#include <set>
#include <string>
#include <vector>
+#include "cm_kwiml.h"
+
#include "cmFindCommon.h"
+#include "cmPolicies.h"
+
+// IWYU insists we should forward-declare instead of including <functional>,
+// but we cannot forward-declare reliably because some C++ standard libraries
+// put the template in an inline namespace.
+#ifdef CMAKE_IWYU_FORWARD_STD_HASH
+/* clang-format off */
+namespace std {
+ template <class T> struct hash;
+}
+/* clang-format on */
+#endif
-class cmCommand;
class cmExecutionStatus;
class cmSearchPath;
@@ -46,19 +60,9 @@ public:
std::vector<std::string>::iterator end, SortOrderType order,
SortDirectionType dir);
- cmFindPackageCommand();
-
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmFindPackageCommand; }
+ cmFindPackageCommand(cmExecutionStatus& status);
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
+ bool InitialPass(std::vector<std::string> const& args);
private:
class PathLabel : public cmFindCommon::PathLabel
@@ -76,6 +80,9 @@ private:
static PathLabel SystemRegistry;
};
+ bool FindPackageUsingModuleMode();
+ bool FindPackageUsingConfigMode();
+
// Add additional search path labels and groups not present in the
// parent class
void AppendSearchPathGroups();
@@ -86,7 +93,14 @@ private:
bool FindModule(bool& found);
void AddFindDefinition(const std::string& var, const char* val);
void RestoreFindDefinitions();
- bool HandlePackageMode();
+
+ enum /*class*/ HandlePackageModeType
+ {
+ Module,
+ Config
+ };
+ bool HandlePackageMode(HandlePackageModeType type);
+
bool FindConfig();
bool FindPrefixedConfig();
bool FindFrameworkConfig();
@@ -96,7 +110,7 @@ private:
NoPolicyScope,
DoPolicyScope
};
- bool ReadListFile(const char* f, PolicyScopeRule psr);
+ bool ReadListFile(const std::string& f, PolicyScopeRule psr);
void StoreVersionFound();
void ComputePrefixes();
@@ -135,6 +149,8 @@ private:
};
std::map<std::string, OriginalDef> OriginalDefs;
+ std::map<std::string, cmPolicies::PolicyID> DeprecatedFindModules;
+
std::string Name;
std::string Variable;
std::string Version;
@@ -162,6 +178,7 @@ private:
bool UseLib32Paths;
bool UseLib64Paths;
bool UseLibx32Paths;
+ bool UseRealPath;
bool PolicyScope;
std::string LibraryArchitecture;
std::vector<std::string> Names;
@@ -194,6 +211,27 @@ private:
}
};
std::vector<ConfigFileInfo> ConsideredConfigs;
+
+ friend struct std::hash<ConfigFileInfo>;
};
+namespace std {
+
+template <>
+struct hash<cmFindPackageCommand::ConfigFileInfo>
+{
+ using argument_type = cmFindPackageCommand::ConfigFileInfo;
+ using result_type = size_t;
+
+ result_type operator()(argument_type const& s) const noexcept
+ {
+ result_type const h(std::hash<std::string>{}(s.filename));
+ return h;
+ }
+};
+}
+
+bool cmFindPackage(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+
#endif
diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx
index d3541ca94..f5e263108 100644
--- a/Source/cmFindPathCommand.cxx
+++ b/Source/cmFindPathCommand.cxx
@@ -6,19 +6,20 @@
#include "cmMakefile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
class cmExecutionStatus;
-cmFindPathCommand::cmFindPathCommand()
+cmFindPathCommand::cmFindPathCommand(cmExecutionStatus& status)
+ : cmFindBase(status)
{
this->EnvironmentPath = "INCLUDE";
this->IncludeFileInPath = false;
}
// cmFindPathCommand
-bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn,
- cmExecutionStatus&)
+bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn)
{
this->VariableDocumentation = "Path to a file.";
this->CMakePathName = "INCLUDE";
@@ -85,16 +86,12 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file,
// if the framework has a path in it then just use the filename
if (frameWorkName.find('/') != std::string::npos) {
fileName = file;
- frameWorkName = "";
+ frameWorkName.clear();
}
if (!frameWorkName.empty()) {
- std::string fpath = dir;
- fpath += frameWorkName;
- fpath += ".framework";
- std::string intPath = fpath;
- intPath += "/Headers/";
- intPath += fileName;
- if (cmSystemTools::FileExists(intPath.c_str())) {
+ std::string fpath = cmStrCat(dir, frameWorkName, ".framework");
+ std::string intPath = cmStrCat(fpath, "/Headers/", fileName);
+ if (cmSystemTools::FileExists(intPath)) {
if (this->IncludeFileInPath) {
return intPath;
}
@@ -104,9 +101,7 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file,
}
// if it is not found yet or not a framework header, then do a glob search
// for all frameworks in the directory: dir/*.framework/Headers/<file>
- std::string glob = dir;
- glob += "*.framework/Headers/";
- glob += file;
+ std::string glob = cmStrCat(dir, "*.framework/Headers/", file);
cmsys::Glob globIt;
globIt.FindFiles(glob);
std::vector<std::string> files = globIt.GetFiles();
@@ -124,18 +119,14 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string const& file,
std::string cmFindPathCommand::FindNormalHeader()
{
std::string tryPath;
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- for (std::vector<std::string>::const_iterator p =
- this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p) {
- tryPath = *p;
- tryPath += *ni;
- if (cmSystemTools::FileExists(tryPath.c_str())) {
+ for (std::string const& n : this->Names) {
+ for (std::string const& sp : this->SearchPaths) {
+ tryPath = cmStrCat(sp, n);
+ if (cmSystemTools::FileExists(tryPath)) {
if (this->IncludeFileInPath) {
return tryPath;
}
- return *p;
+ return sp;
}
}
}
@@ -144,12 +135,9 @@ std::string cmFindPathCommand::FindNormalHeader()
std::string cmFindPathCommand::FindFrameworkHeader()
{
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- for (std::vector<std::string>::const_iterator p =
- this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p) {
- std::string fwPath = this->FindHeaderInFramework(*ni, *p);
+ for (std::string const& n : this->Names) {
+ for (std::string const& sp : this->SearchPaths) {
+ std::string fwPath = this->FindHeaderInFramework(n, sp);
if (!fwPath.empty()) {
return fwPath;
}
@@ -157,3 +145,9 @@ std::string cmFindPathCommand::FindFrameworkHeader()
}
return "";
}
+
+bool cmFindPath(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return cmFindPathCommand(status).InitialPass(args);
+}
diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h
index 3761145b2..8d1ea8b60 100644
--- a/Source/cmFindPathCommand.h
+++ b/Source/cmFindPathCommand.h
@@ -3,14 +3,13 @@
#ifndef cmFindPathCommand_h
#define cmFindPathCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
#include "cmFindBase.h"
-class cmCommand;
class cmExecutionStatus;
/** \class cmFindPathCommand
@@ -23,18 +22,9 @@ class cmExecutionStatus;
class cmFindPathCommand : public cmFindBase
{
public:
- cmFindPathCommand();
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmFindPathCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
+ cmFindPathCommand(cmExecutionStatus& status);
+
+ bool InitialPass(std::vector<std::string> const& args);
bool IncludeFileInPath;
@@ -46,4 +36,7 @@ private:
std::string FindFrameworkHeader();
};
+bool cmFindPath(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+
#endif
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index 9327c1805..e0a3fbfcf 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -4,12 +4,13 @@
#include "cmMakefile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
class cmExecutionStatus;
#if defined(__APPLE__)
-#include <CoreFoundation/CoreFoundation.h>
+# include <CoreFoundation/CoreFoundation.h>
#endif
struct cmFindProgramHelper
@@ -22,7 +23,7 @@ struct cmFindProgramHelper
this->Extensions.push_back(".exe");
#endif
// Consider original name with no extensions.
- this->Extensions.push_back("");
+ this->Extensions.emplace_back();
}
// List of valid extensions.
@@ -34,6 +35,9 @@ struct cmFindProgramHelper
// Current names under consideration.
std::vector<std::string> Names;
+ // Current name with extension under consideration.
+ std::string TestNameExt;
+
// Current full path under consideration.
std::string TestPath;
@@ -43,11 +47,23 @@ struct cmFindProgramHelper
this->Names.clear();
this->AddName(name);
}
+ bool CheckCompoundNames()
+ {
+ for (std::string const& n : this->Names) {
+ // Only perform search relative to current directory if the file name
+ // contains a directory separator.
+ if (n.find('/') != std::string::npos) {
+ if (this->CheckDirectoryForName("", n)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
bool CheckDirectory(std::string const& path)
{
- for (std::vector<std::string>::iterator i = this->Names.begin();
- i != this->Names.end(); ++i) {
- if (this->CheckDirectoryForName(path, *i)) {
+ for (std::string const& n : this->Names) {
+ if (this->CheckDirectoryForName(path, n)) {
return true;
}
}
@@ -55,16 +71,16 @@ struct cmFindProgramHelper
}
bool CheckDirectoryForName(std::string const& path, std::string const& name)
{
- for (std::vector<std::string>::iterator ext = this->Extensions.begin();
- ext != this->Extensions.end(); ++ext) {
- this->TestPath = path;
- this->TestPath += name;
- if (!ext->empty() && cmSystemTools::StringEndsWith(name, ext->c_str())) {
+ for (std::string const& ext : this->Extensions) {
+ if (!ext.empty() && cmHasSuffix(name, ext)) {
continue;
}
- this->TestPath += *ext;
+ this->TestNameExt = cmStrCat(name, ext);
+ this->TestPath =
+ cmSystemTools::CollapseFullPath(this->TestNameExt, path);
+
if (cmSystemTools::FileExists(this->TestPath, true)) {
- this->BestPath = cmSystemTools::CollapseFullPath(this->TestPath);
+ this->BestPath = this->TestPath;
return true;
}
}
@@ -72,14 +88,14 @@ struct cmFindProgramHelper
}
};
-cmFindProgramCommand::cmFindProgramCommand()
+cmFindProgramCommand::cmFindProgramCommand(cmExecutionStatus& status)
+ : cmFindBase(status)
{
this->NamesPerDirAllowed = true;
}
// cmFindProgramCommand
-bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn,
- cmExecutionStatus&)
+bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn)
{
this->VariableDocumentation = "Path to a program.";
this->CMakePathName = "PROGRAM";
@@ -99,8 +115,8 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn,
return true;
}
- std::string result = FindProgram();
- if (result != "") {
+ std::string const result = FindProgram();
+ if (!result.empty()) {
// Save the value in the cache
this->Makefile->AddCacheDefinition(this->VariableName, result.c_str(),
this->VariableDocumentation.c_str(),
@@ -143,20 +159,18 @@ std::string cmFindProgramCommand::FindNormalProgramNamesPerDir()
{
// Search for all names in each directory.
cmFindProgramHelper helper;
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- helper.AddName(*ni);
+ for (std::string const& n : this->Names) {
+ helper.AddName(n);
}
- // Check for the names themselves (e.g. absolute paths).
- if (helper.CheckDirectory(std::string())) {
+ // Check for the names themselves if they contain a directory separator.
+ if (helper.CheckCompoundNames()) {
return helper.BestPath;
}
// Search every directory.
- for (std::vector<std::string>::const_iterator p = this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p) {
- if (helper.CheckDirectory(*p)) {
+ for (std::string const& sp : this->SearchPaths) {
+ if (helper.CheckDirectory(sp)) {
return helper.BestPath;
}
}
@@ -168,21 +182,18 @@ std::string cmFindProgramCommand::FindNormalProgramDirsPerName()
{
// Search the entire path for each name.
cmFindProgramHelper helper;
- for (std::vector<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
+ for (std::string const& n : this->Names) {
// Switch to searching for this name.
- helper.SetName(*ni);
+ helper.SetName(n);
- // Check for the name by itself (e.g. an absolute path).
- if (helper.CheckDirectory(std::string())) {
+ // Check for the names themselves if they contain a directory separator.
+ if (helper.CheckCompoundNames()) {
return helper.BestPath;
}
// Search every directory.
- for (std::vector<std::string>::const_iterator p =
- this->SearchPaths.begin();
- p != this->SearchPaths.end(); ++p) {
- if (helper.CheckDirectory(*p)) {
+ for (std::string const& sp : this->SearchPaths) {
+ if (helper.CheckDirectory(sp)) {
return helper.BestPath;
}
}
@@ -193,10 +204,9 @@ std::string cmFindProgramCommand::FindNormalProgramDirsPerName()
std::string cmFindProgramCommand::FindAppBundle()
{
- for (std::vector<std::string>::const_iterator name = this->Names.begin();
- name != this->Names.end(); ++name) {
+ for (std::string const& name : this->Names) {
- std::string appName = *name + std::string(".app");
+ std::string appName = name + std::string(".app");
std::string appPath =
cmSystemTools::FindDirectory(appName, this->SearchPaths, true);
@@ -237,7 +247,7 @@ std::string cmFindProgramCommand::GetBundleExecutable(
// returned executableURL is relative to <appbundle>/Contents/MacOS/
CFURLRef executableURL = CFBundleCopyExecutableURL(appBundle);
- if (executableURL != NULL) {
+ if (executableURL != nullptr) {
const int MAX_OSX_PATH_SIZE = 1024;
char buffer[MAX_OSX_PATH_SIZE];
@@ -260,3 +270,9 @@ std::string cmFindProgramCommand::GetBundleExecutable(
return executable;
}
+
+bool cmFindProgram(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return cmFindProgramCommand(status).InitialPass(args);
+}
diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h
index b0cd42096..043b43c5e 100644
--- a/Source/cmFindProgramCommand.h
+++ b/Source/cmFindProgramCommand.h
@@ -3,14 +3,13 @@
#ifndef cmFindProgramCommand_h
#define cmFindProgramCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
#include "cmFindBase.h"
-class cmCommand;
class cmExecutionStatus;
/** \class cmFindProgramCommand
@@ -24,18 +23,9 @@ class cmExecutionStatus;
class cmFindProgramCommand : public cmFindBase
{
public:
- cmFindProgramCommand();
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmFindProgramCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
+ cmFindProgramCommand(cmExecutionStatus& status);
+
+ bool InitialPass(std::vector<std::string> const& args);
private:
std::string FindProgram();
@@ -46,4 +36,7 @@ private:
std::string GetBundleExecutable(std::string const& bundlePath);
};
+bool cmFindProgram(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+
#endif
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 8346b2309..44392baa7 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -2,19 +2,50 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmForEachCommand.h"
-#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
+#include <utility>
+
+#include <cm/memory>
+#include <cm/string_view>
+
+#include "cm_static_string_view.hxx"
#include "cmExecutionStatus.h"
+#include "cmFunctionBlocker.h"
+#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
-#include "cmake.h"
+
+namespace {
+bool HandleInMode(std::vector<std::string> const& args, cmMakefile& makefile);
+
+class cmForEachFunctionBlocker : public cmFunctionBlocker
+{
+public:
+ cmForEachFunctionBlocker(cmMakefile* mf);
+ ~cmForEachFunctionBlocker() override;
+
+ cm::string_view StartCommandName() const override { return "foreach"_s; }
+ cm::string_view EndCommandName() const override { return "endforeach"_s; }
+
+ bool ArgumentsMatch(cmListFileFunction const& lff,
+ cmMakefile& mf) const override;
+
+ bool Replay(std::vector<cmListFileFunction> functions,
+ cmExecutionStatus& inStatus) override;
+
+ std::vector<std::string> Args;
+
+private:
+ cmMakefile* Makefile;
+};
cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf)
: Makefile(mf)
- , Depth(0)
{
this->Makefile->PushLoopBlock();
}
@@ -24,103 +55,71 @@ cmForEachFunctionBlocker::~cmForEachFunctionBlocker()
this->Makefile->PopLoopBlock();
}
-bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
- cmMakefile& mf,
- cmExecutionStatus& inStatus)
+bool cmForEachFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff,
+ cmMakefile& mf) const
{
- if (!cmSystemTools::Strucmp(lff.Name.c_str(), "foreach")) {
- // record the number of nested foreach commands
- this->Depth++;
- } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endforeach")) {
- // if this is the endofreach for this statement
- if (!this->Depth) {
- // Remove the function blocker for this scope or bail.
- CM_AUTO_PTR<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(this, lff));
- if (!fb.get()) {
- return false;
- }
+ std::vector<std::string> expandedArguments;
+ mf.ExpandArguments(lff.Arguments, expandedArguments);
+ return expandedArguments.empty() || expandedArguments[0] == this->Args[0];
+}
+
+bool cmForEachFunctionBlocker::Replay(
+ std::vector<cmListFileFunction> functions, cmExecutionStatus& inStatus)
+{
+ cmMakefile& mf = inStatus.GetMakefile();
+ // at end of for each execute recorded commands
+ // store the old value
+ std::string oldDef;
+ if (mf.GetDefinition(this->Args[0])) {
+ oldDef = mf.GetDefinition(this->Args[0]);
+ }
- // at end of for each execute recorded commands
- // store the old value
- std::string oldDef;
- if (mf.GetDefinition(this->Args[0])) {
- oldDef = mf.GetDefinition(this->Args[0]);
+ for (std::string const& arg : cmMakeRange(this->Args).advance(1)) {
+ // set the variable to the loop value
+ mf.AddDefinition(this->Args[0], arg);
+ // Invoke all the functions that were collected in the block.
+ for (cmListFileFunction const& func : functions) {
+ cmExecutionStatus status(mf);
+ mf.ExecuteCommand(func, status);
+ if (status.GetReturnInvoked()) {
+ inStatus.SetReturnInvoked();
+ // restore the variable to its prior value
+ mf.AddDefinition(this->Args[0], oldDef);
+ return true;
}
- std::vector<std::string>::const_iterator j = this->Args.begin();
- ++j;
-
- for (; j != this->Args.end(); ++j) {
- // set the variable to the loop value
- mf.AddDefinition(this->Args[0], j->c_str());
- // Invoke all the functions that were collected in the block.
- cmExecutionStatus status;
- for (unsigned int c = 0; c < this->Functions.size(); ++c) {
- status.Clear();
- mf.ExecuteCommand(this->Functions[c], status);
- if (status.GetReturnInvoked()) {
- inStatus.SetReturnInvoked();
- // restore the variable to its prior value
- mf.AddDefinition(this->Args[0], oldDef.c_str());
- return true;
- }
- if (status.GetBreakInvoked()) {
- // restore the variable to its prior value
- mf.AddDefinition(this->Args[0], oldDef.c_str());
- return true;
- }
- if (status.GetContinueInvoked()) {
- break;
- }
- if (cmSystemTools::GetFatalErrorOccured()) {
- return true;
- }
- }
+ if (status.GetBreakInvoked()) {
+ // restore the variable to its prior value
+ mf.AddDefinition(this->Args[0], oldDef);
+ return true;
+ }
+ if (status.GetContinueInvoked()) {
+ break;
+ }
+ if (cmSystemTools::GetFatalErrorOccured()) {
+ return true;
}
-
- // restore the variable to its prior value
- mf.AddDefinition(this->Args[0], oldDef.c_str());
- return true;
}
- // close out a nested foreach
- this->Depth--;
}
- // record the command
- this->Functions.push_back(lff);
-
- // always return true
+ // restore the variable to its prior value
+ mf.AddDefinition(this->Args[0], oldDef);
return true;
}
-
-bool cmForEachFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
- cmMakefile& mf)
-{
- if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endforeach")) {
- std::vector<std::string> expandedArguments;
- mf.ExpandArguments(lff.Arguments, expandedArguments);
- // if the endforeach has arguments then make sure
- // they match the begin foreach arguments
- if ((expandedArguments.empty() ||
- (expandedArguments[0] == this->Args[0]))) {
- return true;
- }
- }
- return false;
}
-bool cmForEachCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmForEachCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
if (args.size() > 1 && args[1] == "IN") {
- return this->HandleInMode(args);
+ return HandleInMode(args, status.GetMakefile());
}
// create a function blocker
- cmForEachFunctionBlocker* f = new cmForEachFunctionBlocker(this->Makefile);
+ auto fb = cm::make_unique<cmForEachFunctionBlocker>(&status.GetMakefile());
if (args.size() > 1) {
if (args[1] == "RANGE") {
int start = 0;
@@ -147,10 +146,9 @@ bool cmForEachCommand::InitialPass(std::vector<std::string> const& args,
}
if ((start > stop && step > 0) || (start < stop && step < 0) ||
step == 0) {
- std::ostringstream str;
- str << "called with incorrect range specification: start ";
- str << start << ", stop " << stop << ", step " << step;
- this->SetError(str.str());
+ status.SetError(
+ cmStrCat("called with incorrect range specification: start ", start,
+ ", stop ", stop, ", step ", step));
return false;
}
std::vector<std::string> range;
@@ -162,28 +160,28 @@ bool cmForEachCommand::InitialPass(std::vector<std::string> const& args,
break;
}
sprintf(buffer, "%d", cc);
- range.push_back(buffer);
+ range.emplace_back(buffer);
if (cc == stop) {
break;
}
}
- f->Args = range;
+ fb->Args = range;
} else {
- f->Args = args;
+ fb->Args = args;
}
} else {
- f->Args = args;
+ fb->Args = args;
}
- this->Makefile->AddFunctionBlocker(f);
+ status.GetMakefile().AddFunctionBlocker(std::move(fb));
return true;
}
-bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
+namespace {
+bool HandleInMode(std::vector<std::string> const& args, cmMakefile& makefile)
{
- CM_AUTO_PTR<cmForEachFunctionBlocker> f(
- new cmForEachFunctionBlocker(this->Makefile));
- f->Args.push_back(args[0]);
+ auto fb = cm::make_unique<cmForEachFunctionBlocker>(&makefile);
+ fb->Args.push_back(args[0]);
enum Doing
{
@@ -194,26 +192,26 @@ bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
Doing doing = DoingNone;
for (unsigned int i = 2; i < args.size(); ++i) {
if (doing == DoingItems) {
- f->Args.push_back(args[i]);
+ fb->Args.push_back(args[i]);
} else if (args[i] == "LISTS") {
doing = DoingLists;
} else if (args[i] == "ITEMS") {
doing = DoingItems;
} else if (doing == DoingLists) {
- const char* value = this->Makefile->GetDefinition(args[i]);
+ const char* value = makefile.GetDefinition(args[i]);
if (value && *value) {
- cmSystemTools::ExpandListArgument(value, f->Args, true);
+ cmExpandList(value, fb->Args, true);
}
} else {
- std::ostringstream e;
- e << "Unknown argument:\n"
- << " " << args[i] << "\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ makefile.IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Unknown argument:\n", " ", args[i], "\n"));
return true;
}
}
- this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr
+ makefile.AddFunctionBlocker(std::move(fb));
return true;
}
+}
diff --git a/Source/cmForEachCommand.h b/Source/cmForEachCommand.h
index 7c8a6d836..1feb965ce 100644
--- a/Source/cmForEachCommand.h
+++ b/Source/cmForEachCommand.h
@@ -3,53 +3,14 @@
#ifndef cmForEachCommand_h
#define cmForEachCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-#include "cmFunctionBlocker.h"
-#include "cmListFileCache.h"
-
class cmExecutionStatus;
-class cmMakefile;
-
-class cmForEachFunctionBlocker : public cmFunctionBlocker
-{
-public:
- cmForEachFunctionBlocker(cmMakefile* mf);
- ~cmForEachFunctionBlocker() CM_OVERRIDE;
- bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
- cmExecutionStatus&) CM_OVERRIDE;
- bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) CM_OVERRIDE;
-
- std::vector<std::string> Args;
- std::vector<cmListFileFunction> Functions;
-
-private:
- cmMakefile* Makefile;
- int Depth;
-};
/// Starts foreach() ... endforeach() block
-class cmForEachCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmForEachCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- bool HandleInMode(std::vector<std::string> const& args);
-};
-
+bool cmForEachCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h
index d8b002309..6f97b4243 100644
--- a/Source/cmFortranParser.h
+++ b/Source/cmFortranParser.h
@@ -4,17 +4,18 @@
#define cmFortranParser_h
#if !defined(cmFortranLexer_cxx) && !defined(cmFortranParser_cxx)
-#include "cmConfigure.h"
+# include "cmConfigure.h" // IWYU pragma: keep
-#include <set>
-#include <string>
-#include <vector>
+# include <set>
+# include <string>
+# include <utility>
+# include <vector>
#endif
-#include <stddef.h> /* size_t */
+#include <cstddef> /* size_t */
/* Forward declare parser object type. */
-typedef struct cmFortranParser_s cmFortranParser;
+using cmFortranParser = struct cmFortranParser_s;
/* Functions to enter/exit #include'd files in order. */
bool cmFortranParser_FilePush(cmFortranParser* parser, const char* fname);
@@ -39,11 +40,19 @@ int cmFortranParser_GetOldStartcond(cmFortranParser* parser);
/* Callbacks for parser. */
void cmFortranParser_Error(cmFortranParser* parser, const char* message);
-void cmFortranParser_RuleUse(cmFortranParser* parser, const char* name);
+void cmFortranParser_RuleUse(cmFortranParser* parser, const char* module_name);
void cmFortranParser_RuleLineDirective(cmFortranParser* parser,
const char* filename);
void cmFortranParser_RuleInclude(cmFortranParser* parser, const char* name);
-void cmFortranParser_RuleModule(cmFortranParser* parser, const char* name);
+void cmFortranParser_RuleModule(cmFortranParser* parser,
+ const char* module_name);
+void cmFortranParser_RuleSubmodule(cmFortranParser* parser,
+ const char* module_name,
+ const char* submodule_name);
+void cmFortranParser_RuleSubmoduleNested(cmFortranParser* parser,
+ const char* module_name,
+ const char* submodule_name,
+ const char* nested_submodule_name);
void cmFortranParser_RuleDefine(cmFortranParser* parser, const char* name);
void cmFortranParser_RuleUndef(cmFortranParser* parser, const char* name);
void cmFortranParser_RuleIfdef(cmFortranParser* parser, const char* name);
@@ -65,20 +74,20 @@ struct cmFortran_yystype
#define YYSTYPE cmFortran_yystype
#define YYSTYPE_IS_DECLARED 1
#if !defined(cmFortranLexer_cxx)
-#define YY_NO_UNISTD_H
-#include "cmFortranLexer.h"
+# define YY_NO_UNISTD_H
+# include "cmFortranLexer.h"
#endif
#if !defined(cmFortranLexer_cxx)
-#if !defined(cmFortranParser_cxx)
-#undef YY_EXTRA_TYPE
-#undef YY_DECL
-#undef YYSTYPE
-#undef YYSTYPE_IS_DECLARED
-#endif
+# if !defined(cmFortranParser_cxx)
+# undef YY_EXTRA_TYPE
+# undef YY_DECL
+# undef YYSTYPE
+# undef YYSTYPE_IS_DECLARED
+# endif
#endif
#if !defined(cmFortranLexer_cxx) && !defined(cmFortranParser_cxx)
-#include <stack>
+# include <stack>
// Information about a single source file.
class cmFortranSourceInfo
@@ -106,10 +115,10 @@ int cmFortran_yyparse(yyscan_t);
// Define parser object internal structure.
struct cmFortranFile
{
- cmFortranFile(FILE* file, YY_BUFFER_STATE buffer, const std::string& dir)
+ cmFortranFile(FILE* file, YY_BUFFER_STATE buffer, std::string dir)
: File(file)
, Buffer(buffer)
- , Directory(dir)
+ , Directory(std::move(dir))
, LastCharWasNewline(false)
{
}
@@ -119,16 +128,32 @@ struct cmFortranFile
bool LastCharWasNewline;
};
+struct cmFortranCompiler
+{
+ std::string Id;
+ std::string SModSep;
+ std::string SModExt;
+};
+
struct cmFortranParser_s
{
- cmFortranParser_s(std::vector<std::string> const& includes,
- std::set<std::string> const& defines,
- cmFortranSourceInfo& info);
+ cmFortranParser_s(cmFortranCompiler fc, std::vector<std::string> includes,
+ std::set<std::string> defines, cmFortranSourceInfo& info);
~cmFortranParser_s();
+ cmFortranParser_s(const cmFortranParser_s&) = delete;
+ cmFortranParser_s& operator=(const cmFortranParser_s&) = delete;
+
bool FindIncludeFile(const char* dir, const char* includeName,
std::string& fileName);
+ std::string ModName(std::string const& mod_name) const;
+ std::string SModName(std::string const& mod_name,
+ std::string const& sub_name) const;
+
+ // What compiler.
+ cmFortranCompiler Compiler;
+
// The include file search path.
std::vector<std::string> IncludePath;
diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx
index 4e23f3691..054a2a93e 100644
--- a/Source/cmFortranParserImpl.cxx
+++ b/Source/cmFortranParserImpl.cxx
@@ -1,16 +1,17 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmFortranParser.h"
-#include "cmSystemTools.h"
-
-#include "cmConfigure.h"
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
#include <set>
#include <stack>
-#include <stdio.h>
#include <string>
+#include <utility>
#include <vector>
+#include "cmFortranParser.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
bool cmFortranParser_s::FindIncludeFile(const char* dir,
const char* includeName,
std::string& fileName)
@@ -18,25 +19,20 @@ bool cmFortranParser_s::FindIncludeFile(const char* dir,
// If the file is a full path, include it directly.
if (cmSystemTools::FileIsFullPath(includeName)) {
fileName = includeName;
- return cmSystemTools::FileExists(fileName.c_str(), true);
+ return cmSystemTools::FileExists(fileName, true);
}
// Check for the file in the directory containing the including
// file.
- std::string fullName = dir;
- fullName += "/";
- fullName += includeName;
- if (cmSystemTools::FileExists(fullName.c_str(), true)) {
+ std::string fullName = cmStrCat(dir, '/', includeName);
+ if (cmSystemTools::FileExists(fullName, true)) {
fileName = fullName;
return true;
}
// Search the include path for the file.
- for (std::vector<std::string>::const_iterator i = this->IncludePath.begin();
- i != this->IncludePath.end(); ++i) {
- fullName = *i;
- fullName += "/";
- fullName += includeName;
- if (cmSystemTools::FileExists(fullName.c_str(), true)) {
+ for (std::string const& i : this->IncludePath) {
+ fullName = cmStrCat(i, '/', includeName);
+ if (cmSystemTools::FileExists(fullName, true)) {
fileName = fullName;
return true;
}
@@ -44,11 +40,13 @@ bool cmFortranParser_s::FindIncludeFile(const char* dir,
return false;
}
-cmFortranParser_s::cmFortranParser_s(std::vector<std::string> const& includes,
- std::set<std::string> const& defines,
+cmFortranParser_s::cmFortranParser_s(cmFortranCompiler fc,
+ std::vector<std::string> includes,
+ std::set<std::string> defines,
cmFortranSourceInfo& info)
- : IncludePath(includes)
- , PPDefinitions(defines)
+ : Compiler(std::move(fc))
+ , IncludePath(std::move(includes))
+ , PPDefinitions(std::move(defines))
, Info(info)
{
this->InInterface = false;
@@ -61,7 +59,7 @@ cmFortranParser_s::cmFortranParser_s(std::vector<std::string> const& includes,
// Create a dummy buffer that is never read but is the fallback
// buffer when the last file is popped off the stack.
YY_BUFFER_STATE buffer =
- cmFortran_yy_create_buffer(CM_NULLPTR, 4, this->Scanner);
+ cmFortran_yy_create_buffer(nullptr, 4, this->Scanner);
cmFortran_yy_switch_to_buffer(buffer, this->Scanner);
}
@@ -70,6 +68,23 @@ cmFortranParser_s::~cmFortranParser_s()
cmFortran_yylex_destroy(this->Scanner);
}
+std::string cmFortranParser_s::ModName(std::string const& mod_name) const
+{
+ return mod_name + ".mod";
+}
+
+std::string cmFortranParser_s::SModName(std::string const& mod_name,
+ std::string const& sub_name) const
+{
+ std::string const& SModExt =
+ this->Compiler.SModExt.empty() ? ".mod" : this->Compiler.SModExt;
+ // An empty separator means that the compiler does not use a prefix.
+ if (this->Compiler.SModSep.empty()) {
+ return sub_name + SModExt;
+ }
+ return mod_name + this->Compiler.SModSep + sub_name + SModExt;
+}
+
bool cmFortranParser_FilePush(cmFortranParser* parser, const char* fname)
{
// Open the new file and push it onto the stack. Save the old
@@ -79,7 +94,7 @@ bool cmFortranParser_FilePush(cmFortranParser* parser, const char* fname)
std::string dir = cmSystemTools::GetParentDirectory(fname);
cmFortranFile f(file, current, dir);
YY_BUFFER_STATE buffer =
- cmFortran_yy_create_buffer(CM_NULLPTR, 16384, parser->Scanner);
+ cmFortran_yy_create_buffer(nullptr, 16384, parser->Scanner);
cmFortran_yy_switch_to_buffer(buffer, parser->Scanner);
parser->FileStack.push(f);
return true;
@@ -121,14 +136,14 @@ int cmFortranParser_Input(cmFortranParser* parser, char* buffer,
n = 1;
ff.LastCharWasNewline = true;
}
- return (int)n;
+ return static_cast<int>(n);
}
return 0;
}
void cmFortranParser_StringStart(cmFortranParser* parser)
{
- parser->TokenString = "";
+ parser->TokenString.clear();
}
const char* cmFortranParser_StringEnd(cmFortranParser* parser)
@@ -170,11 +185,16 @@ void cmFortranParser_Error(cmFortranParser* parser, const char* msg)
parser->Error = msg ? msg : "unknown error";
}
-void cmFortranParser_RuleUse(cmFortranParser* parser, const char* name)
+void cmFortranParser_RuleUse(cmFortranParser* parser, const char* module_name)
{
- if (!parser->InPPFalseBranch) {
- parser->Info.Requires.insert(cmSystemTools::LowerCase(name));
+ if (parser->InPPFalseBranch) {
+ return;
}
+
+ // syntax: "use module_name"
+ // requires: "module_name.mod"
+ std::string const& mod_name = cmSystemTools::LowerCase(module_name);
+ parser->Info.Requires.insert(parser->ModName(mod_name));
}
void cmFortranParser_RuleLineDirective(cmFortranParser* parser,
@@ -227,11 +247,63 @@ void cmFortranParser_RuleInclude(cmFortranParser* parser, const char* name)
}
}
-void cmFortranParser_RuleModule(cmFortranParser* parser, const char* name)
+void cmFortranParser_RuleModule(cmFortranParser* parser,
+ const char* module_name)
+{
+ if (parser->InPPFalseBranch) {
+ return;
+ }
+
+ if (!parser->InInterface) {
+ // syntax: "module module_name"
+ // provides: "module_name.mod"
+ std::string const& mod_name = cmSystemTools::LowerCase(module_name);
+ parser->Info.Provides.insert(parser->ModName(mod_name));
+ }
+}
+
+void cmFortranParser_RuleSubmodule(cmFortranParser* parser,
+ const char* module_name,
+ const char* submodule_name)
+{
+ if (parser->InPPFalseBranch) {
+ return;
+ }
+
+ // syntax: "submodule (module_name) submodule_name"
+ // requires: "module_name.mod"
+ // provides: "module_name@submodule_name.smod"
+ //
+ // FIXME: Some compilers split the submodule part of a module into a
+ // separate "module_name.smod" file. Whether it is generated or
+ // not depends on conditions more subtle than we currently detect.
+ // For now we depend directly on "module_name.mod".
+
+ std::string const& mod_name = cmSystemTools::LowerCase(module_name);
+ std::string const& sub_name = cmSystemTools::LowerCase(submodule_name);
+ parser->Info.Requires.insert(parser->ModName(mod_name));
+ parser->Info.Provides.insert(parser->SModName(mod_name, sub_name));
+}
+
+void cmFortranParser_RuleSubmoduleNested(cmFortranParser* parser,
+ const char* module_name,
+ const char* submodule_name,
+ const char* nested_submodule_name)
{
- if (!parser->InPPFalseBranch && !parser->InInterface) {
- parser->Info.Provides.insert(cmSystemTools::LowerCase(name));
+ if (parser->InPPFalseBranch) {
+ return;
}
+
+ // syntax: "submodule (module_name:submodule_name) nested_submodule_name"
+ // requires: "module_name@submodule_name.smod"
+ // provides: "module_name@nested_submodule_name.smod"
+
+ std::string const& mod_name = cmSystemTools::LowerCase(module_name);
+ std::string const& sub_name = cmSystemTools::LowerCase(submodule_name);
+ std::string const& nest_name =
+ cmSystemTools::LowerCase(nested_submodule_name);
+ parser->Info.Requires.insert(parser->SModName(mod_name, sub_name));
+ parser->Info.Provides.insert(parser->SModName(mod_name, nest_name));
}
void cmFortranParser_RuleDefine(cmFortranParser* parser, const char* macro)
diff --git a/Source/cmFunctionBlocker.cxx b/Source/cmFunctionBlocker.cxx
new file mode 100644
index 000000000..5778a7152
--- /dev/null
+++ b/Source/cmFunctionBlocker.cxx
@@ -0,0 +1,46 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmFunctionBlocker.h"
+
+#include <cassert>
+#include <sstream>
+#include <utility>
+
+#include "cmExecutionStatus.h"
+#include "cmMakefile.h"
+#include "cmMessageType.h"
+
+bool cmFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
+ cmExecutionStatus& status)
+{
+ if (lff.Name.Lower == this->StartCommandName()) {
+ this->ScopeDepth++;
+ } else if (lff.Name.Lower == this->EndCommandName()) {
+ this->ScopeDepth--;
+ if (this->ScopeDepth == 0U) {
+ cmMakefile& mf = status.GetMakefile();
+ auto self = mf.RemoveFunctionBlocker();
+ assert(self.get() == this);
+
+ if (!this->ArgumentsMatch(lff, mf)) {
+ cmListFileContext const& lfc = this->GetStartingContext();
+ cmListFileContext closingContext =
+ cmListFileContext::FromCommandContext(lff, lfc.FilePath);
+ std::ostringstream e;
+ /* clang-format off */
+ e << "A logical block opening on the line\n"
+ << " " << lfc << "\n"
+ << "closes on the line\n"
+ << " " << closingContext << "\n"
+ << "with mis-matching arguments.";
+ /* clang-format on */
+ mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
+ }
+
+ return this->Replay(std::move(this->Functions), status);
+ }
+ }
+
+ this->Functions.push_back(lff);
+ return true;
+}
diff --git a/Source/cmFunctionBlocker.h b/Source/cmFunctionBlocker.h
index b3450b3f2..59bb8927f 100644
--- a/Source/cmFunctionBlocker.h
+++ b/Source/cmFunctionBlocker.h
@@ -3,6 +3,12 @@
#ifndef cmFunctionBlocker_h
#define cmFunctionBlocker_h
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <vector>
+
+#include <cm/string_view>
+
#include "cmListFileCache.h"
class cmExecutionStatus;
@@ -14,19 +20,10 @@ public:
/**
* should a function be blocked
*/
- virtual bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
- cmExecutionStatus& status) = 0;
-
- /**
- * should this function blocker be removed, useful when one function adds a
- * blocker and another must remove it
- */
- virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile&)
- {
- return false;
- }
+ bool IsFunctionBlocked(cmListFileFunction const& lff,
+ cmExecutionStatus& status);
- virtual ~cmFunctionBlocker() {}
+ virtual ~cmFunctionBlocker() = default;
/** Set/Get the context in which this blocker is created. */
void SetStartingContext(cmListFileContext const& lfc)
@@ -39,7 +36,19 @@ public:
}
private:
+ virtual cm::string_view StartCommandName() const = 0;
+ virtual cm::string_view EndCommandName() const = 0;
+
+ virtual bool ArgumentsMatch(cmListFileFunction const& lff,
+ cmMakefile& mf) const = 0;
+
+ virtual bool Replay(std::vector<cmListFileFunction> functions,
+ cmExecutionStatus& status) = 0;
+
+private:
cmListFileContext StartingContext;
+ std::vector<cmListFileFunction> Functions;
+ unsigned int ScopeDepth = 1;
};
#endif
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index ee52bde37..b3ddfe01f 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -3,111 +3,96 @@
#include "cmFunctionCommand.h"
#include <sstream>
+#include <utility>
+
+#include <cm/memory>
+#include <cm/string_view>
+
+#include "cm_static_string_view.hxx"
#include "cmAlgorithms.h"
#include "cmExecutionStatus.h"
+#include "cmFunctionBlocker.h"
+#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmPolicies.h"
+#include "cmRange.h"
#include "cmState.h"
-#include "cmSystemTools.h"
+#include "cmStringAlgorithms.h"
+namespace {
// define the class for function commands
-class cmFunctionHelperCommand : public cmCommand
+class cmFunctionHelperCommand
{
public:
- cmFunctionHelperCommand() {}
-
- ///! clean up any memory allocated by the function
- ~cmFunctionHelperCommand() CM_OVERRIDE {}
-
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE
- {
- cmFunctionHelperCommand* newC = new cmFunctionHelperCommand;
- // we must copy when we clone
- newC->Args = this->Args;
- newC->Functions = this->Functions;
- newC->Policies = this->Policies;
- newC->FilePath = this->FilePath;
- return newC;
- }
-
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
- bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
- cmExecutionStatus&) CM_OVERRIDE;
-
- bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&) CM_OVERRIDE
- {
- return false;
- }
+ bool operator()(std::vector<cmListFileArgument> const& args,
+ cmExecutionStatus& inStatus) const;
std::vector<std::string> Args;
std::vector<cmListFileFunction> Functions;
cmPolicies::PolicyMap Policies;
std::string FilePath;
};
+}
-bool cmFunctionHelperCommand::InvokeInitialPass(
- const std::vector<cmListFileArgument>& args, cmExecutionStatus& inStatus)
+bool cmFunctionHelperCommand::operator()(
+ std::vector<cmListFileArgument> const& args,
+ cmExecutionStatus& inStatus) const
{
+ cmMakefile& makefile = inStatus.GetMakefile();
+
// Expand the argument list to the function.
std::vector<std::string> expandedArgs;
- this->Makefile->ExpandArguments(args, expandedArgs);
+ makefile.ExpandArguments(args, expandedArgs);
// make sure the number of arguments passed is at least the number
// required by the signature
if (expandedArgs.size() < this->Args.size() - 1) {
- std::string errorMsg =
- "Function invoked with incorrect arguments for function named: ";
- errorMsg += this->Args[0];
- this->SetError(errorMsg);
+ std::string errorMsg = cmStrCat(
+ "Function invoked with incorrect arguments for function named: ",
+ this->Args[0]);
+ inStatus.SetError(errorMsg);
return false;
}
- cmMakefile::FunctionPushPop functionScope(this->Makefile, this->FilePath,
+ cmMakefile::FunctionPushPop functionScope(&makefile, this->FilePath,
this->Policies);
// set the value of argc
- std::ostringstream strStream;
- strStream << expandedArgs.size();
- this->Makefile->AddDefinition("ARGC", strStream.str().c_str());
- this->Makefile->MarkVariableAsUsed("ARGC");
+ makefile.AddDefinition("ARGC", std::to_string(expandedArgs.size()));
+ makefile.MarkVariableAsUsed("ARGC");
// set the values for ARGV0 ARGV1 ...
for (unsigned int t = 0; t < expandedArgs.size(); ++t) {
std::ostringstream tmpStream;
tmpStream << "ARGV" << t;
- this->Makefile->AddDefinition(tmpStream.str(), expandedArgs[t].c_str());
- this->Makefile->MarkVariableAsUsed(tmpStream.str());
+ makefile.AddDefinition(tmpStream.str(), expandedArgs[t]);
+ makefile.MarkVariableAsUsed(tmpStream.str());
}
// define the formal arguments
for (unsigned int j = 1; j < this->Args.size(); ++j) {
- this->Makefile->AddDefinition(this->Args[j], expandedArgs[j - 1].c_str());
+ makefile.AddDefinition(this->Args[j], expandedArgs[j - 1]);
}
// define ARGV and ARGN
std::string argvDef = cmJoin(expandedArgs, ";");
- std::vector<std::string>::const_iterator eit =
- expandedArgs.begin() + (this->Args.size() - 1);
+ auto eit = expandedArgs.begin() + (this->Args.size() - 1);
std::string argnDef = cmJoin(cmMakeRange(eit, expandedArgs.end()), ";");
- this->Makefile->AddDefinition("ARGV", argvDef.c_str());
- this->Makefile->MarkVariableAsUsed("ARGV");
- this->Makefile->AddDefinition("ARGN", argnDef.c_str());
- this->Makefile->MarkVariableAsUsed("ARGN");
+ makefile.AddDefinition("ARGV", argvDef);
+ makefile.MarkVariableAsUsed("ARGV");
+ makefile.AddDefinition("ARGN", argnDef);
+ makefile.MarkVariableAsUsed("ARGN");
// Invoke all the functions that were collected in the block.
// for each function
- for (unsigned int c = 0; c < this->Functions.size(); ++c) {
- cmExecutionStatus status;
- if (!this->Makefile->ExecuteCommand(this->Functions[c], status) ||
- status.GetNestedError()) {
+ for (cmListFileFunction const& func : this->Functions) {
+ cmExecutionStatus status(makefile);
+ if (!makefile.ExecuteCommand(func, status) || status.GetNestedError()) {
// The error message should have already included the call stack
// so we do not need to report an error here.
functionScope.Quiet();
@@ -123,66 +108,57 @@ bool cmFunctionHelperCommand::InvokeInitialPass(
return true;
}
-bool cmFunctionFunctionBlocker::IsFunctionBlocked(
- const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus&)
+class cmFunctionFunctionBlocker : public cmFunctionBlocker
{
- // record commands until we hit the ENDFUNCTION
- // at the ENDFUNCTION call we shift gears and start looking for invocations
- if (!cmSystemTools::Strucmp(lff.Name.c_str(), "function")) {
- this->Depth++;
- } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endfunction")) {
- // if this is the endfunction for this function then execute
- if (!this->Depth) {
- // create a new command and add it to cmake
- cmFunctionHelperCommand* f = new cmFunctionHelperCommand();
- f->Args = this->Args;
- f->Functions = this->Functions;
- f->FilePath = this->GetStartingContext().FilePath;
- mf.RecordPolicies(f->Policies);
- mf.GetState()->AddScriptedCommand(this->Args[0], f);
- // remove the function blocker now that the function is defined
- mf.RemoveFunctionBlocker(this, lff);
- return true;
- }
- // decrement for each nested function that ends
- this->Depth--;
- }
+public:
+ cm::string_view StartCommandName() const override { return "function"_s; }
+ cm::string_view EndCommandName() const override { return "endfunction"_s; }
- // if it wasn't an endfunction and we are not executing then we must be
- // recording
- this->Functions.push_back(lff);
- return true;
-}
+ bool ArgumentsMatch(cmListFileFunction const&,
+ cmMakefile& mf) const override;
+
+ bool Replay(std::vector<cmListFileFunction> functions,
+ cmExecutionStatus& status) override;
+
+ std::vector<std::string> Args;
+};
-bool cmFunctionFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
- cmMakefile& mf)
+bool cmFunctionFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff,
+ cmMakefile& mf) const
{
- if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endfunction")) {
- std::vector<std::string> expandedArguments;
- mf.ExpandArguments(lff.Arguments, expandedArguments,
- this->GetStartingContext().FilePath.c_str());
- // if the endfunction has arguments then make sure
- // they match the ones in the opening function command
- if ((expandedArguments.empty() ||
- (expandedArguments[0] == this->Args[0]))) {
- return true;
- }
- }
+ std::vector<std::string> expandedArguments;
+ mf.ExpandArguments(lff.Arguments, expandedArguments,
+ this->GetStartingContext().FilePath.c_str());
+ return expandedArguments.empty() || expandedArguments[0] == this->Args[0];
+}
- return false;
+bool cmFunctionFunctionBlocker::Replay(
+ std::vector<cmListFileFunction> functions, cmExecutionStatus& status)
+{
+ cmMakefile& mf = status.GetMakefile();
+ // create a new command and add it to cmake
+ cmFunctionHelperCommand f;
+ f.Args = this->Args;
+ f.Functions = std::move(functions);
+ f.FilePath = this->GetStartingContext().FilePath;
+ mf.RecordPolicies(f.Policies);
+ mf.GetState()->AddScriptedCommand(this->Args[0], std::move(f));
+ return true;
}
-bool cmFunctionCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmFunctionCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
// create a function blocker
- cmFunctionFunctionBlocker* f = new cmFunctionFunctionBlocker();
- f->Args.insert(f->Args.end(), args.begin(), args.end());
- this->Makefile->AddFunctionBlocker(f);
+ {
+ auto fb = cm::make_unique<cmFunctionFunctionBlocker>();
+ cmAppend(fb->Args, args);
+ status.GetMakefile().AddFunctionBlocker(std::move(fb));
+ }
return true;
}
diff --git a/Source/cmFunctionCommand.h b/Source/cmFunctionCommand.h
index f26312632..d6b549c67 100644
--- a/Source/cmFunctionCommand.h
+++ b/Source/cmFunctionCommand.h
@@ -3,47 +3,15 @@
#ifndef cmFunctionCommand_h
#define cmFunctionCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-#include "cmFunctionBlocker.h"
-#include "cmListFileCache.h"
-
class cmExecutionStatus;
-class cmMakefile;
-
-class cmFunctionFunctionBlocker : public cmFunctionBlocker
-{
-public:
- cmFunctionFunctionBlocker() { this->Depth = 0; }
- ~cmFunctionFunctionBlocker() CM_OVERRIDE {}
- bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf,
- cmExecutionStatus&) CM_OVERRIDE;
- bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) CM_OVERRIDE;
-
- std::vector<std::string> Args;
- std::vector<cmListFileFunction> Functions;
- int Depth;
-};
/// Starts function() ... endfunction() block
-class cmFunctionCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmFunctionCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmFunctionCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx
index 6aa593cc0..2af04b691 100644
--- a/Source/cmGeneratedFileStream.cxx
+++ b/Source/cmGeneratedFileStream.cxx
@@ -2,20 +2,19 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGeneratedFileStream.h"
-#include <stdio.h>
+#include <cstdio>
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cm_codecvt.hxx"
-#include "cm_zlib.h"
+#if !defined(CMAKE_BOOTSTRAP)
+# include "cm_codecvt.hxx"
+# include "cm_zlib.h"
#endif
cmGeneratedFileStream::cmGeneratedFileStream(Encoding encoding)
- : cmGeneratedFileStreamBase()
- , Stream()
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
if (encoding != codecvt::None) {
imbue(std::locale(getloc(), new codecvt(encoding)));
}
@@ -24,18 +23,17 @@ cmGeneratedFileStream::cmGeneratedFileStream(Encoding encoding)
#endif
}
-cmGeneratedFileStream::cmGeneratedFileStream(const char* name, bool quiet,
- Encoding encoding)
+cmGeneratedFileStream::cmGeneratedFileStream(std::string const& name,
+ bool quiet, Encoding encoding)
: cmGeneratedFileStreamBase(name)
, Stream(TempName.c_str())
{
// Check if the file opened.
if (!*this && !quiet) {
- cmSystemTools::Error("Cannot open file for write: ",
- this->TempName.c_str());
+ cmSystemTools::Error("Cannot open file for write: " + this->TempName);
cmSystemTools::ReportLastSystemError("");
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
if (encoding != codecvt::None) {
imbue(std::locale(getloc(), new codecvt(encoding)));
}
@@ -54,7 +52,7 @@ cmGeneratedFileStream::~cmGeneratedFileStream()
this->Okay = !this->fail();
}
-cmGeneratedFileStream& cmGeneratedFileStream::Open(const char* name,
+cmGeneratedFileStream& cmGeneratedFileStream::Open(std::string const& name,
bool quiet, bool binaryFlag)
{
// Store the file name and construct the temporary file name.
@@ -70,8 +68,7 @@ cmGeneratedFileStream& cmGeneratedFileStream::Open(const char* name,
// Check if the file opened.
if (!*this && !quiet) {
- cmSystemTools::Error("Cannot open file for write: ",
- this->TempName.c_str());
+ cmSystemTools::Error("Cannot open file for write: " + this->TempName);
cmSystemTools::ReportLastSystemError("");
}
return *this;
@@ -104,23 +101,9 @@ void cmGeneratedFileStream::SetCompressionExtraExtension(bool ext)
this->CompressExtraExtension = ext;
}
-cmGeneratedFileStreamBase::cmGeneratedFileStreamBase()
- : Name()
- , TempName()
- , CopyIfDifferent(false)
- , Okay(false)
- , Compress(false)
- , CompressExtraExtension(true)
-{
-}
+cmGeneratedFileStreamBase::cmGeneratedFileStreamBase() = default;
-cmGeneratedFileStreamBase::cmGeneratedFileStreamBase(const char* name)
- : Name()
- , TempName()
- , CopyIfDifferent(false)
- , Okay(false)
- , Compress(false)
- , CompressExtraExtension(true)
+cmGeneratedFileStreamBase::cmGeneratedFileStreamBase(std::string const& name)
{
this->Open(name);
}
@@ -130,7 +113,7 @@ cmGeneratedFileStreamBase::~cmGeneratedFileStreamBase()
this->Close();
}
-void cmGeneratedFileStreamBase::Open(const char* name)
+void cmGeneratedFileStreamBase::Open(std::string const& name)
{
// Save the original name of the file.
this->Name = name;
@@ -147,7 +130,7 @@ void cmGeneratedFileStreamBase::Open(const char* name)
cmSystemTools::RemoveFile(this->TempName);
std::string dir = cmSystemTools::GetFilenamePath(this->TempName);
- cmSystemTools::MakeDirectory(dir.c_str());
+ cmSystemTools::MakeDirectory(dir);
}
bool cmGeneratedFileStreamBase::Close()
@@ -167,13 +150,13 @@ bool cmGeneratedFileStreamBase::Close()
// The destination is to be replaced. Rename the temporary to the
// destination atomically.
if (this->Compress) {
- std::string gzname = this->TempName + ".temp.gz";
- if (this->CompressFile(this->TempName.c_str(), gzname.c_str())) {
- this->RenameFile(gzname.c_str(), resname.c_str());
+ std::string gzname = cmStrCat(this->TempName, ".temp.gz");
+ if (this->CompressFile(this->TempName, gzname)) {
+ this->RenameFile(gzname, resname);
}
cmSystemTools::RemoveFile(gzname);
} else {
- this->RenameFile(this->TempName.c_str(), resname.c_str());
+ this->RenameFile(this->TempName, resname);
}
replaced = true;
@@ -187,11 +170,11 @@ bool cmGeneratedFileStreamBase::Close()
return replaced;
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
-int cmGeneratedFileStreamBase::CompressFile(const char* oldname,
- const char* newname)
+#ifndef CMAKE_BOOTSTRAP
+int cmGeneratedFileStreamBase::CompressFile(std::string const& oldname,
+ std::string const& newname)
{
- gzFile gf = gzopen(newname, "w");
+ gzFile gf = gzopen(newname.c_str(), "w");
if (!gf) {
return 0;
}
@@ -214,14 +197,15 @@ int cmGeneratedFileStreamBase::CompressFile(const char* oldname,
return 1;
}
#else
-int cmGeneratedFileStreamBase::CompressFile(const char*, const char*)
+int cmGeneratedFileStreamBase::CompressFile(std::string const&,
+ std::string const&)
{
return 0;
}
#endif
-int cmGeneratedFileStreamBase::RenameFile(const char* oldname,
- const char* newname)
+int cmGeneratedFileStreamBase::RenameFile(std::string const& oldname,
+ std::string const& newname)
{
return cmSystemTools::RenameFile(oldname, newname);
}
diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h
index 56f9988ff..a9088ac8a 100644
--- a/Source/cmGeneratedFileStream.h
+++ b/Source/cmGeneratedFileStream.h
@@ -3,12 +3,14 @@
#ifndef cmGeneratedFileStream_h
#define cmGeneratedFileStream_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cm_codecvt.hxx"
-#include "cmsys/FStream.hxx"
#include <string>
+#include "cmsys/FStream.hxx"
+
+#include "cm_codecvt.hxx"
+
// This is the first base class of cmGeneratedFileStream. It will be
// created before and destroyed after the ofstream portion and can
// therefore be used to manage the temporary file.
@@ -20,7 +22,7 @@ protected:
cmGeneratedFileStreamBase();
// This constructor prepares the temporary output file.
- cmGeneratedFileStreamBase(const char* name);
+ cmGeneratedFileStreamBase(std::string const& name);
// The destructor renames the temporary output file to the real name.
~cmGeneratedFileStreamBase();
@@ -29,14 +31,14 @@ protected:
// called before the real stream is opened. Close is always called
// after the real stream is closed and Okay is set to whether the
// real stream was still valid for writing when it was closed.
- void Open(const char* name);
+ void Open(std::string const& name);
bool Close();
// Internal file replacement implementation.
- int RenameFile(const char* oldname, const char* newname);
+ int RenameFile(std::string const& oldname, std::string const& newname);
// Internal file compression implementation.
- int CompressFile(const char* oldname, const char* newname);
+ int CompressFile(std::string const& oldname, std::string const& newname);
// The name of the final destination file for the output.
std::string Name;
@@ -45,16 +47,16 @@ protected:
std::string TempName;
// Whether to do a copy-if-different.
- bool CopyIfDifferent;
+ bool CopyIfDifferent = false;
// Whether the real file stream was valid when it was closed.
- bool Okay;
+ bool Okay = false;
// Whether the destination file is compressed
- bool Compress;
+ bool Compress = false;
// Whether the destination file is compressed
- bool CompressExtraExtension;
+ bool CompressExtraExtension = true;
};
/** \class cmGeneratedFileStream
@@ -67,12 +69,13 @@ protected:
* contents have changed to prevent the file modification time from
* being updated.
*/
-class cmGeneratedFileStream : private cmGeneratedFileStreamBase,
- public cmsys::ofstream
+class cmGeneratedFileStream
+ : private cmGeneratedFileStreamBase
+ , public cmsys::ofstream
{
public:
- typedef cmsys::ofstream Stream;
- typedef codecvt::Encoding Encoding;
+ using Stream = cmsys::ofstream;
+ using Encoding = codecvt::Encoding;
/**
* This constructor prepares a default stream. The open method must
@@ -86,7 +89,7 @@ public:
* file cannot be opened an error message is produced unless the
* second argument is set to true.
*/
- cmGeneratedFileStream(const char* name, bool quiet = false,
+ cmGeneratedFileStream(std::string const& name, bool quiet = false,
Encoding encoding = codecvt::None);
/**
@@ -94,7 +97,9 @@ public:
* file was successfully written before allowing the original to be
* replaced.
*/
- ~cmGeneratedFileStream() CM_OVERRIDE;
+ ~cmGeneratedFileStream() override;
+
+ cmGeneratedFileStream(cmGeneratedFileStream const&) = delete;
/**
* Open an output file by name. This should be used only with a
@@ -102,13 +107,13 @@ public:
* temporary file. If the file cannot be opened an error message is
* produced unless the second argument is set to true.
*/
- cmGeneratedFileStream& Open(const char* name, bool quiet = false,
+ cmGeneratedFileStream& Open(std::string const& name, bool quiet = false,
bool binaryFlag = false);
/**
* Close the output file. This should be used only with an open
* stream. The temporary file is atomically renamed to the
- * destionation file if the stream is still valid when this method
+ * destination file if the stream is still valid when this method
* is called.
*/
bool Close();
@@ -133,9 +138,6 @@ public:
* the output file to be changed during the use of cmGeneratedFileStream.
*/
void SetName(const std::string& fname);
-
-private:
- cmGeneratedFileStream(cmGeneratedFileStream const&); // not implemented
};
#endif
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 00b5ff4ef..b7f7d1d9b 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -2,86 +2,97 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGeneratorExpression.h"
-#include "cmsys/RegularExpression.hxx"
+#include <cassert>
+#include <memory>
#include <utility>
-#include "assert.h"
+#include "cmsys/RegularExpression.hxx"
+
#include "cmAlgorithms.h"
#include "cmGeneratorExpressionContext.h"
+#include "cmGeneratorExpressionDAGChecker.h"
#include "cmGeneratorExpressionEvaluator.h"
#include "cmGeneratorExpressionLexer.h"
#include "cmGeneratorExpressionParser.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
-cmGeneratorExpression::cmGeneratorExpression(
- const cmListFileBacktrace& backtrace)
- : Backtrace(backtrace)
+cmGeneratorExpression::cmGeneratorExpression(cmListFileBacktrace backtrace)
+ : Backtrace(std::move(backtrace))
{
}
-CM_AUTO_PTR<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
- std::string const& input)
+cmGeneratorExpression::~cmGeneratorExpression() = default;
+
+std::unique_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
+ std::string input) const
{
- return CM_AUTO_PTR<cmCompiledGeneratorExpression>(
- new cmCompiledGeneratorExpression(this->Backtrace, input));
+ return std::unique_ptr<cmCompiledGeneratorExpression>(
+ new cmCompiledGeneratorExpression(this->Backtrace, std::move(input)));
}
-CM_AUTO_PTR<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
- const char* input)
+std::unique_ptr<cmCompiledGeneratorExpression> cmGeneratorExpression::Parse(
+ const char* input) const
{
return this->Parse(std::string(input ? input : ""));
}
-cmGeneratorExpression::~cmGeneratorExpression()
+std::string cmGeneratorExpression::Evaluate(
+ std::string input, cmLocalGenerator* lg, const std::string& config,
+ cmGeneratorTarget const* headTarget,
+ cmGeneratorExpressionDAGChecker* dagChecker,
+ cmGeneratorTarget const* currentTarget, std::string const& language)
{
+ if (Find(input) != std::string::npos) {
+ cmCompiledGeneratorExpression cge(cmListFileBacktrace(), std::move(input));
+ return cge.Evaluate(lg, config, headTarget, dagChecker, currentTarget,
+ language);
+ }
+ return input;
}
-const char* cmCompiledGeneratorExpression::Evaluate(
- cmLocalGenerator* lg, const std::string& config, bool quiet,
- const cmGeneratorTarget* headTarget,
+std::string cmGeneratorExpression::Evaluate(
+ const char* input, cmLocalGenerator* lg, const std::string& config,
+ cmGeneratorTarget const* headTarget,
cmGeneratorExpressionDAGChecker* dagChecker,
- std::string const& language) const
+ cmGeneratorTarget const* currentTarget, std::string const& language)
{
- return this->Evaluate(lg, config, quiet, headTarget, headTarget, dagChecker,
- language);
+ return input ? Evaluate(std::string(input), lg, config, headTarget,
+ dagChecker, currentTarget, language)
+ : "";
}
-const char* cmCompiledGeneratorExpression::Evaluate(
- cmLocalGenerator* lg, const std::string& config, bool quiet,
- const cmGeneratorTarget* headTarget, const cmGeneratorTarget* currentTarget,
+const std::string& cmCompiledGeneratorExpression::Evaluate(
+ cmLocalGenerator* lg, const std::string& config,
+ const cmGeneratorTarget* headTarget,
cmGeneratorExpressionDAGChecker* dagChecker,
- std::string const& language) const
+ const cmGeneratorTarget* currentTarget, std::string const& language) const
{
cmGeneratorExpressionContext context(
- lg, config, quiet, headTarget, currentTarget ? currentTarget : headTarget,
- this->EvaluateForBuildsystem, this->Backtrace, language);
+ lg, config, this->Quiet, headTarget,
+ currentTarget ? currentTarget : headTarget, this->EvaluateForBuildsystem,
+ this->Backtrace, language);
return this->EvaluateWithContext(context, dagChecker);
}
-const char* cmCompiledGeneratorExpression::EvaluateWithContext(
+const std::string& cmCompiledGeneratorExpression::EvaluateWithContext(
cmGeneratorExpressionContext& context,
cmGeneratorExpressionDAGChecker* dagChecker) const
{
if (!this->NeedsEvaluation) {
- return this->Input.c_str();
+ return this->Input;
}
- this->Output = "";
+ this->Output.clear();
- std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
- this->Evaluators.begin();
- const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
- this->Evaluators.end();
+ for (const cmGeneratorExpressionEvaluator* it : this->Evaluators) {
+ this->Output += it->Evaluate(&context, dagChecker);
- for (; it != end; ++it) {
- this->Output += (*it)->Evaluate(&context, dagChecker);
-
- this->SeenTargetProperties.insert(context.SeenTargetProperties.begin(),
- context.SeenTargetProperties.end());
+ this->SeenTargetProperties.insert(context.SeenTargetProperties.cbegin(),
+ context.SeenTargetProperties.cend());
if (context.HadError) {
- this->Output = "";
+ this->Output.clear();
break;
}
}
@@ -96,17 +107,17 @@ const char* cmCompiledGeneratorExpression::EvaluateWithContext(
this->DependTargets = context.DependTargets;
this->AllTargetsSeen = context.AllTargets;
- // TODO: Return a std::string from here instead?
- return this->Output.c_str();
+ return this->Output;
}
cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
- cmListFileBacktrace const& backtrace, const std::string& input)
- : Backtrace(backtrace)
- , Input(input)
+ cmListFileBacktrace backtrace, std::string input)
+ : Backtrace(std::move(backtrace))
+ , Input(std::move(input))
+ , EvaluateForBuildsystem(false)
+ , Quiet(false)
, HadContextSensitiveCondition(false)
, HadHeadSensitiveCondition(false)
- , EvaluateForBuildsystem(false)
{
cmGeneratorExpressionLexer l;
std::vector<cmGeneratorExpressionToken> tokens = l.Tokenize(this->Input);
@@ -168,7 +179,7 @@ static std::string stripAllGeneratorExpressions(const std::string& input)
const char* c = input.c_str() + pos;
const char* const cStart = c;
for (; *c; ++c) {
- if (c[0] == '$' && c[1] == '<') {
+ if (cmGeneratorExpression::StartsWithGeneratorExpression(c)) {
++nestingLevel;
++c;
continue;
@@ -199,15 +210,14 @@ static void prefixItems(const std::string& content, std::string& result,
std::vector<std::string> entries;
cmGeneratorExpression::Split(content, entries);
const char* sep = "";
- for (std::vector<std::string>::const_iterator ei = entries.begin();
- ei != entries.end(); ++ei) {
+ for (std::string const& e : entries) {
result += sep;
sep = ";";
- if (!cmSystemTools::FileIsFullPath(ei->c_str()) &&
- cmGeneratorExpression::Find(*ei) != 0) {
+ if (!cmSystemTools::FileIsFullPath(e) &&
+ cmGeneratorExpression::Find(e) != 0) {
result += prefix;
}
- result += *ei;
+ result += e;
}
}
@@ -244,7 +254,7 @@ static std::string stripExportInterface(
const char* c = input.c_str() + pos;
const char* const cStart = c;
for (; *c; ++c) {
- if (c[0] == '$' && c[1] == '<') {
+ if (cmGeneratorExpression::StartsWithGeneratorExpression(c)) {
++nestingLevel;
++c;
continue;
@@ -297,13 +307,13 @@ void cmGeneratorExpression::Split(const std::string& input,
std::string::size_type startPos = input.rfind(';', pos);
if (startPos == std::string::npos) {
preGenex = part;
- part = "";
+ part.clear();
} else if (startPos != pos - 1 && startPos >= lastPos) {
part = input.substr(lastPos, startPos - lastPos);
preGenex = input.substr(startPos + 1, pos - startPos - 1);
}
if (!part.empty()) {
- cmSystemTools::ExpandListArgument(part, output);
+ cmExpandList(part, output);
}
}
pos += 2;
@@ -311,7 +321,7 @@ void cmGeneratorExpression::Split(const std::string& input,
const char* c = input.c_str() + pos;
const char* const cStart = c;
for (; *c; ++c) {
- if (c[0] == '$' && c[1] == '<') {
+ if (cmGeneratorExpression::StartsWithGeneratorExpression(c)) {
++nestingLevel;
++c;
continue;
@@ -336,7 +346,7 @@ void cmGeneratorExpression::Split(const std::string& input,
lastPos = pos;
}
if (lastPos < input.size()) {
- cmSystemTools::ExpandListArgument(input.substr(lastPos), output);
+ cmExpandList(input.substr(lastPos), output);
}
}
@@ -378,11 +388,31 @@ bool cmGeneratorExpression::IsValidTargetName(const std::string& input)
void cmCompiledGeneratorExpression::GetMaxLanguageStandard(
const cmGeneratorTarget* tgt, std::map<std::string, std::string>& mapping)
{
- typedef std::map<cmGeneratorTarget const*,
- std::map<std::string, std::string> >
- MapType;
- MapType::const_iterator it = this->MaxLanguageStandard.find(tgt);
+ auto it = this->MaxLanguageStandard.find(tgt);
if (it != this->MaxLanguageStandard.end()) {
mapping = it->second;
}
}
+
+const std::string& cmGeneratorExpressionInterpreter::Evaluate(
+ std::string expression, const std::string& property)
+{
+ this->CompiledGeneratorExpression =
+ this->GeneratorExpression.Parse(std::move(expression));
+
+ // Specify COMPILE_OPTIONS to DAGchecker, same semantic as COMPILE_FLAGS
+ cmGeneratorExpressionDAGChecker dagChecker(
+ this->HeadTarget,
+ property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property, nullptr,
+ nullptr);
+
+ return this->CompiledGeneratorExpression->Evaluate(
+ this->LocalGenerator, this->Config, this->HeadTarget, &dagChecker, nullptr,
+ this->Language);
+}
+
+const std::string& cmGeneratorExpressionInterpreter::Evaluate(
+ const char* expression, const std::string& property)
+{
+ return this->Evaluate(std::string(expression ? expression : ""), property);
+}
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index 34516f5c5..4bd1c9f88 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -3,16 +3,17 @@
#ifndef cmGeneratorExpression_h
#define cmGeneratorExpression_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmListFileCache.h"
-
-#include "cm_auto_ptr.hxx"
#include <map>
+#include <memory>
#include <set>
#include <string>
+#include <utility>
#include <vector>
+#include "cmListFileCache.h"
+
class cmCompiledGeneratorExpression;
class cmGeneratorTarget;
class cmLocalGenerator;
@@ -31,16 +32,31 @@ struct cmGeneratorExpressionEvaluator;
*/
class cmGeneratorExpression
{
- CM_DISABLE_COPY(cmGeneratorExpression)
-
public:
/** Construct. */
- cmGeneratorExpression(
- cmListFileBacktrace const& backtrace = cmListFileBacktrace());
+ cmGeneratorExpression(cmListFileBacktrace backtrace = cmListFileBacktrace());
~cmGeneratorExpression();
- CM_AUTO_PTR<cmCompiledGeneratorExpression> Parse(std::string const& input);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> Parse(const char* input);
+ cmGeneratorExpression(cmGeneratorExpression const&) = delete;
+ cmGeneratorExpression& operator=(cmGeneratorExpression const&) = delete;
+
+ std::unique_ptr<cmCompiledGeneratorExpression> Parse(
+ std::string input) const;
+ std::unique_ptr<cmCompiledGeneratorExpression> Parse(
+ const char* input) const;
+
+ static std::string Evaluate(
+ std::string input, cmLocalGenerator* lg, const std::string& config,
+ cmGeneratorTarget const* headTarget = nullptr,
+ cmGeneratorExpressionDAGChecker* dagChecker = nullptr,
+ cmGeneratorTarget const* currentTarget = nullptr,
+ std::string const& language = std::string());
+ static std::string Evaluate(
+ const char* input, cmLocalGenerator* lg, const std::string& config,
+ cmGeneratorTarget const* headTarget = nullptr,
+ cmGeneratorExpressionDAGChecker* dagChecker = nullptr,
+ cmGeneratorTarget const* currentTarget = nullptr,
+ std::string const& language = std::string());
enum PreprocessContext
{
@@ -62,25 +78,34 @@ public:
static std::string StripEmptyListElements(const std::string& input);
+ static inline bool StartsWithGeneratorExpression(const std::string& input)
+ {
+ return input.length() >= 2 && input[0] == '$' && input[1] == '<';
+ }
+ static inline bool StartsWithGeneratorExpression(const char* input)
+ {
+ return input != nullptr && input[0] == '$' && input[1] == '<';
+ }
+
private:
cmListFileBacktrace Backtrace;
};
class cmCompiledGeneratorExpression
{
- CM_DISABLE_COPY(cmCompiledGeneratorExpression)
-
public:
- const char* Evaluate(
- cmLocalGenerator* lg, const std::string& config, bool quiet = false,
- cmGeneratorTarget const* headTarget = CM_NULLPTR,
- cmGeneratorTarget const* currentTarget = CM_NULLPTR,
- cmGeneratorExpressionDAGChecker* dagChecker = CM_NULLPTR,
+ ~cmCompiledGeneratorExpression();
+
+ cmCompiledGeneratorExpression(cmCompiledGeneratorExpression const&) = delete;
+ cmCompiledGeneratorExpression& operator=(
+ cmCompiledGeneratorExpression const&) = delete;
+
+ const std::string& Evaluate(
+ cmLocalGenerator* lg, const std::string& config,
+ cmGeneratorTarget const* headTarget = nullptr,
+ cmGeneratorExpressionDAGChecker* dagChecker = nullptr,
+ cmGeneratorTarget const* currentTarget = nullptr,
std::string const& language = std::string()) const;
- const char* Evaluate(cmLocalGenerator* lg, const std::string& config,
- bool quiet, cmGeneratorTarget const* headTarget,
- cmGeneratorExpressionDAGChecker* dagChecker,
- std::string const& language = std::string()) const;
/** Get set of targets found during evaluations. */
std::set<cmGeneratorTarget*> const& GetTargets() const
@@ -98,8 +123,6 @@ public:
return this->AllTargetsSeen;
}
- ~cmCompiledGeneratorExpression();
-
std::string const& GetInput() const { return this->Input; }
cmListFileBacktrace GetBacktrace() const { return this->Backtrace; }
@@ -121,16 +144,18 @@ public:
this->EvaluateForBuildsystem = eval;
}
+ void SetQuiet(bool quiet) { this->Quiet = quiet; }
+
void GetMaxLanguageStandard(cmGeneratorTarget const* tgt,
std::map<std::string, std::string>& mapping);
private:
- const char* EvaluateWithContext(
+ const std::string& EvaluateWithContext(
cmGeneratorExpressionContext& context,
cmGeneratorExpressionDAGChecker* dagChecker) const;
- cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
- const std::string& input);
+ cmCompiledGeneratorExpression(cmListFileBacktrace backtrace,
+ std::string input);
friend class cmGeneratorExpression;
@@ -138,18 +163,52 @@ private:
std::vector<cmGeneratorExpressionEvaluator*> Evaluators;
const std::string Input;
bool NeedsEvaluation;
+ bool EvaluateForBuildsystem;
+ bool Quiet;
mutable std::set<cmGeneratorTarget*> DependTargets;
mutable std::set<cmGeneratorTarget const*> AllTargetsSeen;
mutable std::set<std::string> SeenTargetProperties;
mutable std::map<cmGeneratorTarget const*,
- std::map<std::string, std::string> >
+ std::map<std::string, std::string>>
MaxLanguageStandard;
mutable std::string Output;
mutable bool HadContextSensitiveCondition;
mutable bool HadHeadSensitiveCondition;
mutable std::set<cmGeneratorTarget const*> SourceSensitiveTargets;
- bool EvaluateForBuildsystem;
+};
+
+class cmGeneratorExpressionInterpreter
+{
+public:
+ cmGeneratorExpressionInterpreter(cmLocalGenerator* localGenerator,
+ std::string config,
+ cmGeneratorTarget const* headTarget,
+ std::string language = std::string())
+ : LocalGenerator(localGenerator)
+ , Config(std::move(config))
+ , HeadTarget(headTarget)
+ , Language(std::move(language))
+ {
+ }
+
+ cmGeneratorExpressionInterpreter(cmGeneratorExpressionInterpreter const&) =
+ delete;
+ cmGeneratorExpressionInterpreter& operator=(
+ cmGeneratorExpressionInterpreter const&) = delete;
+
+ const std::string& Evaluate(std::string expression,
+ const std::string& property);
+ const std::string& Evaluate(const char* expression,
+ const std::string& property);
+
+protected:
+ cmGeneratorExpression GeneratorExpression;
+ std::unique_ptr<cmCompiledGeneratorExpression> CompiledGeneratorExpression;
+ cmLocalGenerator* LocalGenerator = nullptr;
+ std::string Config;
+ cmGeneratorTarget const* HeadTarget = nullptr;
+ std::string Language;
};
#endif
diff --git a/Source/cmGeneratorExpressionContext.cxx b/Source/cmGeneratorExpressionContext.cxx
index a6dde5d39..6d973310c 100644
--- a/Source/cmGeneratorExpressionContext.cxx
+++ b/Source/cmGeneratorExpressionContext.cxx
@@ -2,15 +2,17 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGeneratorExpressionContext.h"
+#include <utility>
+
cmGeneratorExpressionContext::cmGeneratorExpressionContext(
- cmLocalGenerator* lg, std::string const& config, bool quiet,
+ cmLocalGenerator* lg, std::string config, bool quiet,
cmGeneratorTarget const* headTarget, const cmGeneratorTarget* currentTarget,
- bool evaluateForBuildsystem, cmListFileBacktrace const& backtrace,
- std::string const& language)
- : Backtrace(backtrace)
+ bool evaluateForBuildsystem, cmListFileBacktrace backtrace,
+ std::string language)
+ : Backtrace(std::move(backtrace))
, LG(lg)
- , Config(config)
- , Language(language)
+ , Config(std::move(config))
+ , Language(std::move(language))
, HeadTarget(headTarget)
, CurrentTarget(currentTarget)
, Quiet(quiet)
diff --git a/Source/cmGeneratorExpressionContext.h b/Source/cmGeneratorExpressionContext.h
index cf292dcef..4709fa024 100644
--- a/Source/cmGeneratorExpressionContext.h
+++ b/Source/cmGeneratorExpressionContext.h
@@ -3,30 +3,30 @@
#ifndef cmGeneratorExpressionContext_h
#define cmGeneratorExpressionContext_h
-#include "cmListFileCache.h"
-
#include <map>
#include <set>
#include <string>
+#include "cmListFileCache.h"
+
class cmGeneratorTarget;
class cmLocalGenerator;
struct cmGeneratorExpressionContext
{
- cmGeneratorExpressionContext(cmLocalGenerator* lg, std::string const& config,
+ cmGeneratorExpressionContext(cmLocalGenerator* lg, std::string config,
bool quiet, const cmGeneratorTarget* headTarget,
cmGeneratorTarget const* currentTarget,
bool evaluateForBuildsystem,
- cmListFileBacktrace const& backtrace,
- std::string const& language);
+ cmListFileBacktrace backtrace,
+ std::string language);
cmListFileBacktrace Backtrace;
std::set<cmGeneratorTarget*> DependTargets;
std::set<cmGeneratorTarget const*> AllTargets;
std::set<std::string> SeenTargetProperties;
std::set<cmGeneratorTarget const*> SourceSensitiveTargets;
- std::map<cmGeneratorTarget const*, std::map<std::string, std::string> >
+ std::map<cmGeneratorTarget const*, std::map<std::string, std::string>>
MaxLanguageStandard;
cmLocalGenerator* LG;
std::string Config;
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index c0266311b..643ba346d 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -2,38 +2,39 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGeneratorExpressionDAGChecker.h"
-#include "cmAlgorithms.h"
+#include <cstring>
+#include <sstream>
+#include <utility>
+
#include "cmGeneratorExpressionContext.h"
#include "cmGeneratorExpressionEvaluator.h"
#include "cmGeneratorTarget.h"
#include "cmLocalGenerator.h"
+#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
#include "cmake.h"
-#include <sstream>
-#include <string.h>
-#include <utility>
-
cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
- const cmListFileBacktrace& backtrace, const std::string& target,
- const std::string& property, const GeneratorExpressionContent* content,
+ cmListFileBacktrace backtrace, cmGeneratorTarget const* target,
+ std::string property, const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* parent)
: Parent(parent)
, Target(target)
- , Property(property)
+ , Property(std::move(property))
, Content(content)
- , Backtrace(backtrace)
+ , Backtrace(std::move(backtrace))
, TransitivePropertiesOnly(false)
{
Initialize();
}
cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
- const std::string& target, const std::string& property,
+ cmGeneratorTarget const* target, std::string property,
const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* parent)
: Parent(parent)
, Target(target)
- , Property(property)
+ , Property(std::move(property))
, Content(content)
, Backtrace()
, TransitivePropertiesOnly(false)
@@ -55,11 +56,10 @@ void cmGeneratorExpressionDAGChecker::Initialize()
if (CheckResult == DAG &&
(CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
- TEST_TRANSITIVE_PROPERTY_METHOD) false)) // NOLINT(clang-tidy)
+ TEST_TRANSITIVE_PROPERTY_METHOD) false)) // NOLINT(*)
#undef TEST_TRANSITIVE_PROPERTY_METHOD
{
- std::map<std::string, std::set<std::string> >::const_iterator it =
- top->Seen.find(this->Target);
+ auto it = top->Seen.find(this->Target);
if (it != top->Seen.end()) {
const std::set<std::string>& propSet = it->second;
if (propSet.find(this->Property) != propSet.end()) {
@@ -67,9 +67,7 @@ void cmGeneratorExpressionDAGChecker::Initialize()
return;
}
}
- const_cast<cmGeneratorExpressionDAGChecker*>(top)
- ->Seen[this->Target]
- .insert(this->Property);
+ top->Seen[this->Target].insert(this->Property);
}
}
@@ -99,8 +97,8 @@ void cmGeneratorExpressionDAGChecker::ReportError(
<< " " << expr << "\n"
<< "Self reference on target \"" << context->HeadTarget->GetName()
<< "\".\n";
- context->LG->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
- parent->Backtrace);
+ context->LG->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
+ e.str(), parent->Backtrace);
return;
}
@@ -111,8 +109,8 @@ void cmGeneratorExpressionDAGChecker::ReportError(
<< " " << expr << "\n"
<< "Dependency loop found.";
/* clang-format on */
- context->LG->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
- context->Backtrace);
+ context->LG->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
+ e.str(), context->Backtrace);
}
int loopStep = 1;
@@ -122,8 +120,8 @@ void cmGeneratorExpressionDAGChecker::ReportError(
<< " "
<< (parent->Content ? parent->Content->GetOriginalExpression() : expr)
<< "\n";
- context->LG->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
- parent->Backtrace);
+ context->LG->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
+ e.str(), parent->Backtrace);
parent = parent->Parent;
++loopStep;
}
@@ -154,7 +152,26 @@ bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnly()
return top->TransitivePropertiesOnly;
}
-bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char* tgt)
+bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression()
+{
+ return this->Property.find("TARGET_GENEX_EVAL:") == 0 ||
+ this->Property.find("GENEX_EVAL:", 0) == 0;
+}
+
+bool cmGeneratorExpressionDAGChecker::EvaluatingPICExpression()
+{
+ const cmGeneratorExpressionDAGChecker* top = this;
+ const cmGeneratorExpressionDAGChecker* parent = this->Parent;
+ while (parent) {
+ top = parent;
+ parent = parent->Parent;
+ }
+
+ return top->Property == "INTERFACE_POSITION_INDEPENDENT_CODE";
+}
+
+bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(
+ cmGeneratorTarget const* tgt)
{
const cmGeneratorExpressionDAGChecker* top = this;
const cmGeneratorExpressionDAGChecker* parent = this->Parent;
@@ -177,7 +194,7 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char* tgt)
strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0;
}
-std::string cmGeneratorExpressionDAGChecker::TopTarget() const
+cmGeneratorTarget const* cmGeneratorExpressionDAGChecker::TopTarget() const
{
const cmGeneratorExpressionDAGChecker* top = this;
const cmGeneratorExpressionDAGChecker* parent = this->Parent;
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index 557a19220..f2c49bbf2 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -3,16 +3,17 @@
#ifndef cmGeneratorExpressionDAGChecker_h
#define cmGeneratorExpressionDAGChecker_h
-#include "cmConfigure.h"
-
-#include "cmListFileCache.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
#include <set>
#include <string>
+#include "cmListFileCache.h"
+
struct GeneratorExpressionContent;
struct cmGeneratorExpressionContext;
+class cmGeneratorTarget;
#define CM_SELECT_BOTH(F, A1, A2) F(A1, A2)
#define CM_SELECT_FIRST(F, A1, A2) F(A1)
@@ -25,7 +26,11 @@ struct cmGeneratorExpressionContext;
SELECT(F, EvaluatingCompileOptions, COMPILE_OPTIONS) \
SELECT(F, EvaluatingAutoUicOptions, AUTOUIC_OPTIONS) \
SELECT(F, EvaluatingSources, SOURCES) \
- SELECT(F, EvaluatingCompileFeatures, COMPILE_FEATURES)
+ SELECT(F, EvaluatingCompileFeatures, COMPILE_FEATURES) \
+ SELECT(F, EvaluatingLinkOptions, LINK_OPTIONS) \
+ SELECT(F, EvaluatingLinkDirectories, LINK_DIRECTORIES) \
+ SELECT(F, EvaluatingLinkDepends, LINK_DEPENDS) \
+ SELECT(F, EvaluatingPrecompileHeaders, PRECOMPILE_HEADERS)
#define CM_FOR_EACH_TRANSITIVE_PROPERTY(F) \
CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_BOTH)
@@ -38,13 +43,13 @@ struct cmGeneratorExpressionContext;
struct cmGeneratorExpressionDAGChecker
{
- cmGeneratorExpressionDAGChecker(const cmListFileBacktrace& backtrace,
- const std::string& target,
- const std::string& property,
+ cmGeneratorExpressionDAGChecker(cmListFileBacktrace backtrace,
+ cmGeneratorTarget const* target,
+ std::string property,
const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* parent);
- cmGeneratorExpressionDAGChecker(const std::string& target,
- const std::string& property,
+ cmGeneratorExpressionDAGChecker(cmGeneratorTarget const* target,
+ std::string property,
const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* parent);
@@ -61,7 +66,9 @@ struct cmGeneratorExpressionDAGChecker
void ReportError(cmGeneratorExpressionContext* context,
const std::string& expr);
- bool EvaluatingLinkLibraries(const char* tgt = CM_NULLPTR);
+ bool EvaluatingGenexExpression();
+ bool EvaluatingPICExpression();
+ bool EvaluatingLinkLibraries(cmGeneratorTarget const* tgt = nullptr);
#define DECLARE_TRANSITIVE_PROPERTY_METHOD(METHOD) bool METHOD() const;
@@ -72,7 +79,7 @@ struct cmGeneratorExpressionDAGChecker
bool GetTransitivePropertiesOnly();
void SetTransitivePropertiesOnly() { this->TransitivePropertiesOnly = true; }
- std::string TopTarget() const;
+ cmGeneratorTarget const* TopTarget() const;
private:
Result CheckGraph() const;
@@ -80,9 +87,9 @@ private:
private:
const cmGeneratorExpressionDAGChecker* const Parent;
- const std::string Target;
+ cmGeneratorTarget const* Target;
const std::string Property;
- std::map<std::string, std::set<std::string> > Seen;
+ mutable std::map<cmGeneratorTarget const*, std::set<std::string>> Seen;
const GeneratorExpressionContent* const Content;
const cmListFileBacktrace Backtrace;
Result CheckResult;
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index 15264545b..9e8707d9d 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -2,29 +2,32 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGeneratorExpressionEvaluationFile.h"
-#include "cmConfigure.h"
-#include "cmsys/FStream.hxx"
+#include <memory>
#include <sstream>
#include <utility>
+#include "cmsys/FStream.hxx"
+
#include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h"
#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmSourceFile.h"
+#include "cmSourceFileLocationKind.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
-#include "cmake.h"
cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile(
- const std::string& input,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> outputFileExpr,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent)
- : Input(input)
- , OutputFileExpr(outputFileExpr)
- , Condition(condition)
+ std::string input,
+ std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr,
+ std::unique_ptr<cmCompiledGeneratorExpression> condition,
+ bool inputIsContent, cmPolicies::PolicyStatus policyStatusCMP0070)
+ : Input(std::move(input))
+ , OutputFileExpr(std::move(outputFileExpr))
+ , Condition(std::move(condition))
, InputIsContent(inputIsContent)
+ , PolicyStatusCMP0070(policyStatusCMP0070)
{
}
@@ -35,8 +38,8 @@ void cmGeneratorExpressionEvaluationFile::Generate(
{
std::string rawCondition = this->Condition->GetInput();
if (!rawCondition.empty()) {
- std::string condResult = this->Condition->Evaluate(
- lg, config, false, CM_NULLPTR, CM_NULLPTR, CM_NULLPTR, lang);
+ std::string condResult =
+ this->Condition->Evaluate(lg, config, nullptr, nullptr, nullptr, lang);
if (condResult == "0") {
return;
}
@@ -46,18 +49,23 @@ void cmGeneratorExpressionEvaluationFile::Generate(
<< "\" did "
"not evaluate to valid content. Got \""
<< condResult << "\".";
- lg->IssueMessage(cmake::FATAL_ERROR, e.str());
+ lg->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
}
- const std::string outputFileName = this->OutputFileExpr->Evaluate(
- lg, config, false, CM_NULLPTR, CM_NULLPTR, CM_NULLPTR, lang);
- const std::string outputContent = inputExpression->Evaluate(
- lg, config, false, CM_NULLPTR, CM_NULLPTR, CM_NULLPTR, lang);
+ std::string outputFileName = this->OutputFileExpr->Evaluate(
+ lg, config, nullptr, nullptr, nullptr, lang);
+ const std::string& outputContent =
+ inputExpression->Evaluate(lg, config, nullptr, nullptr, nullptr, lang);
+
+ if (cmSystemTools::FileIsFullPath(outputFileName)) {
+ outputFileName = cmSystemTools::CollapseFullPath(outputFileName);
+ } else {
+ outputFileName = this->FixRelativePath(outputFileName, PathForOutput, lg);
+ }
- std::map<std::string, std::string>::iterator it =
- outputFiles.find(outputFileName);
+ auto it = outputFiles.find(outputFileName);
if (it != outputFiles.end()) {
if (it->second == outputContent) {
@@ -69,7 +77,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(
"This is generally caused by the content evaluating the "
"configuration type, language, or location of object files:\n "
<< outputFileName;
- lg->IssueMessage(cmake::FATAL_ERROR, e.str());
+ lg->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
@@ -77,7 +85,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(
this->Files.push_back(outputFileName);
outputFiles[outputFileName] = outputContent;
- cmGeneratedFileStream fout(outputFileName.c_str());
+ cmGeneratedFileStream fout(outputFileName);
fout.SetCopyIfDifferent(true);
fout << outputContent;
if (fout.Close() && perm) {
@@ -92,13 +100,19 @@ void cmGeneratorExpressionEvaluationFile::CreateOutputFile(
cmGlobalGenerator* gg = lg->GetGlobalGenerator();
gg->GetEnabledLanguages(enabledLanguages);
- for (std::vector<std::string>::const_iterator le = enabledLanguages.begin();
- le != enabledLanguages.end(); ++le) {
- std::string name = this->OutputFileExpr->Evaluate(
- lg, config, false, CM_NULLPTR, CM_NULLPTR, CM_NULLPTR, *le);
- cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource(name);
+ for (std::string const& le : enabledLanguages) {
+ std::string name = this->OutputFileExpr->Evaluate(lg, config, nullptr,
+ nullptr, nullptr, le);
+ cmSourceFile* sf = lg->GetMakefile()->GetOrCreateSource(
+ name, false, cmSourceFileLocationKind::Known);
+ // Tell TraceDependencies that the file is not expected to exist
+ // on disk yet. We generate it after that runs.
sf->SetProperty("GENERATED", "1");
+ // Tell the build system generators that there is no build rule
+ // to generate the file.
+ sf->SetProperty("__CMAKE_GENERATED_BY_CMAKE", "1");
+
gg->SetFilenameTargetDepends(
sf, this->OutputFileExpr->GetSourceSensitiveTargets());
}
@@ -111,13 +125,19 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
if (this->InputIsContent) {
inputContent = this->Input;
} else {
- lg->GetMakefile()->AddCMakeDependFile(this->Input);
- cmSystemTools::GetPermissions(this->Input.c_str(), perm);
- cmsys::ifstream fin(this->Input.c_str());
+ std::string inputFileName = this->Input;
+ if (cmSystemTools::FileIsFullPath(inputFileName)) {
+ inputFileName = cmSystemTools::CollapseFullPath(inputFileName);
+ } else {
+ inputFileName = this->FixRelativePath(inputFileName, PathForInput, lg);
+ }
+ lg->GetMakefile()->AddCMakeDependFile(inputFileName);
+ cmSystemTools::GetPermissions(inputFileName.c_str(), perm);
+ cmsys::ifstream fin(inputFileName.c_str());
if (!fin) {
std::ostringstream e;
- e << "Evaluation file \"" << this->Input << "\" cannot be read.";
- lg->IssueMessage(cmake::FATAL_ERROR, e.str());
+ e << "Evaluation file \"" << inputFileName << "\" cannot be read.";
+ lg->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
@@ -132,7 +152,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
cmListFileBacktrace lfbt = this->OutputFileExpr->GetBacktrace();
cmGeneratorExpression contentGE(lfbt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> inputExpression =
+ std::unique_ptr<cmCompiledGeneratorExpression> inputExpression =
contentGE.Parse(inputContent);
std::map<std::string, std::string> outputFiles;
@@ -141,21 +161,73 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator* lg)
lg->GetMakefile()->GetConfigurations(allConfigs);
if (allConfigs.empty()) {
- allConfigs.push_back("");
+ allConfigs.emplace_back();
}
std::vector<std::string> enabledLanguages;
cmGlobalGenerator* gg = lg->GetGlobalGenerator();
gg->GetEnabledLanguages(enabledLanguages);
- for (std::vector<std::string>::const_iterator le = enabledLanguages.begin();
- le != enabledLanguages.end(); ++le) {
- for (std::vector<std::string>::const_iterator li = allConfigs.begin();
- li != allConfigs.end(); ++li) {
- this->Generate(lg, *li, *le, inputExpression.get(), outputFiles, perm);
+ for (std::string const& le : enabledLanguages) {
+ for (std::string const& li : allConfigs) {
+ this->Generate(lg, li, le, inputExpression.get(), outputFiles, perm);
if (cmSystemTools::GetFatalErrorOccured()) {
return;
}
}
}
}
+
+std::string cmGeneratorExpressionEvaluationFile::FixRelativePath(
+ std::string const& relativePath, PathRole role, cmLocalGenerator* lg)
+{
+ std::string resultPath;
+ switch (this->PolicyStatusCMP0070) {
+ case cmPolicies::WARN: {
+ std::string arg;
+ switch (role) {
+ case PathForInput:
+ arg = "INPUT";
+ break;
+ case PathForOutput:
+ arg = "OUTPUT";
+ break;
+ }
+ std::ostringstream w;
+ /* clang-format off */
+ w <<
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0070) << "\n"
+ "file(GENERATE) given relative " << arg << " path:\n"
+ " " << relativePath << "\n"
+ "This is not defined behavior unless CMP0070 is set to NEW. "
+ "For compatibility with older versions of CMake, the previous "
+ "undefined behavior will be used."
+ ;
+ /* clang-format on */
+ lg->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+ }
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ // OLD behavior is to use the relative path unchanged,
+ // which ends up being used relative to the working dir.
+ resultPath = relativePath;
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ // NEW behavior is to interpret the relative path with respect
+ // to the current source or binary directory.
+ switch (role) {
+ case PathForInput:
+ resultPath = cmSystemTools::CollapseFullPath(
+ relativePath, lg->GetCurrentSourceDirectory());
+ break;
+ case PathForOutput:
+ resultPath = cmSystemTools::CollapseFullPath(
+ relativePath, lg->GetCurrentBinaryDirectory());
+ break;
+ }
+ break;
+ }
+ return resultPath;
+}
diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h
index 98727460e..c3bc4c85b 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.h
+++ b/Source/cmGeneratorExpressionEvaluationFile.h
@@ -6,22 +6,25 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
+#include <memory>
#include <string>
#include <vector>
-#include "cmGeneratorExpression.h"
-#include "cm_auto_ptr.hxx"
#include "cm_sys_stat.h"
+#include "cmGeneratorExpression.h"
+#include "cmPolicies.h"
+
class cmLocalGenerator;
class cmGeneratorExpressionEvaluationFile
{
public:
cmGeneratorExpressionEvaluationFile(
- const std::string& input,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> outputFileExpr,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent);
+ std::string input,
+ std::unique_ptr<cmCompiledGeneratorExpression> outputFileExpr,
+ std::unique_ptr<cmCompiledGeneratorExpression> condition,
+ bool inputIsContent, cmPolicies::PolicyStatus policyStatusCMP0070);
void Generate(cmLocalGenerator* lg);
@@ -35,12 +38,21 @@ private:
cmCompiledGeneratorExpression* inputExpression,
std::map<std::string, std::string>& outputFiles, mode_t perm);
+ enum PathRole
+ {
+ PathForInput,
+ PathForOutput
+ };
+ std::string FixRelativePath(std::string const& filePath, PathRole role,
+ cmLocalGenerator* lg);
+
private:
const std::string Input;
- const CM_AUTO_PTR<cmCompiledGeneratorExpression> OutputFileExpr;
- const CM_AUTO_PTR<cmCompiledGeneratorExpression> Condition;
+ const std::unique_ptr<cmCompiledGeneratorExpression> OutputFileExpr;
+ const std::unique_ptr<cmCompiledGeneratorExpression> Condition;
std::vector<std::string> Files;
const bool InputIsContent;
+ cmPolicies::PolicyStatus PolicyStatusCMP0070;
};
#endif
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 6ce4a8e72..e0ae170c0 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -2,13 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGeneratorExpressionEvaluator.h"
+#include <algorithm>
+#include <sstream>
+
#include "cmAlgorithms.h"
#include "cmGeneratorExpressionContext.h"
#include "cmGeneratorExpressionNode.h"
-#include <algorithm>
-#include <sstream>
-
GeneratorExpressionContent::GeneratorExpressionContent(
const char* startContent, size_t length)
: StartContent(startContent)
@@ -25,28 +25,23 @@ std::string GeneratorExpressionContent::ProcessArbitraryContent(
const cmGeneratorExpressionNode* node, const std::string& identifier,
cmGeneratorExpressionContext* context,
cmGeneratorExpressionDAGChecker* dagChecker,
- std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
+ std::vector<std::vector<cmGeneratorExpressionEvaluator*>>::const_iterator
pit) const
{
std::string result;
- const std::vector<
- std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator pend =
- this->ParamChildren.end();
+ const auto pend = this->ParamChildren.end();
for (; pit != pend; ++pit) {
- std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
- pit->begin();
- const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
- pit->end();
- for (; it != end; ++it) {
+ for (cmGeneratorExpressionEvaluator* pExprEval : *pit) {
if (node->RequiresLiteralInput()) {
- if ((*it)->GetType() != cmGeneratorExpressionEvaluator::Text) {
- reportError(context, this->GetOriginalExpression(), "$<" +
- identifier + "> expression requires literal input.");
+ if (pExprEval->GetType() != cmGeneratorExpressionEvaluator::Text) {
+ reportError(context, this->GetOriginalExpression(),
+ "$<" + identifier +
+ "> expression requires literal input.");
return std::string();
}
}
- result += (*it)->Evaluate(context, dagChecker);
+ result += pExprEval->Evaluate(context, dagChecker);
if (context->HadError) {
return std::string();
}
@@ -69,12 +64,9 @@ std::string GeneratorExpressionContent::Evaluate(
{
std::string identifier;
{
- std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
- this->IdentifierChildren.begin();
- const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
- this->IdentifierChildren.end();
- for (; it != end; ++it) {
- identifier += (*it)->Evaluate(context, dagChecker);
+ for (cmGeneratorExpressionEvaluator* pExprEval :
+ this->IdentifierChildren) {
+ identifier += pExprEval->Evaluate(context, dagChecker);
if (context->HadError) {
return std::string();
}
@@ -122,43 +114,36 @@ std::string GeneratorExpressionContent::EvaluateParameters(
{
const int numExpected = node->NumExpectedParameters();
{
- std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
- pit = this->ParamChildren.begin();
- const std::vector<
- std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator pend =
- this->ParamChildren.end();
+ auto pit = this->ParamChildren.begin();
+ const auto pend = this->ParamChildren.end();
const bool acceptsArbitraryContent =
node->AcceptsArbitraryContentParameter();
int counter = 1;
for (; pit != pend; ++pit, ++counter) {
if (acceptsArbitraryContent && counter == numExpected) {
- std::string lastParam = this->ProcessArbitraryContent(
- node, identifier, context, dagChecker, pit);
- parameters.push_back(lastParam);
+ parameters.push_back(this->ProcessArbitraryContent(
+ node, identifier, context, dagChecker, pit));
return std::string();
}
std::string parameter;
- std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
- pit->begin();
- const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
- pit->end();
- for (; it != end; ++it) {
- parameter += (*it)->Evaluate(context, dagChecker);
+ for (cmGeneratorExpressionEvaluator* pExprEval : *pit) {
+ parameter += pExprEval->Evaluate(context, dagChecker);
if (context->HadError) {
return std::string();
}
}
- parameters.push_back(parameter);
+ parameters.push_back(std::move(parameter));
}
}
if ((numExpected > cmGeneratorExpressionNode::DynamicParameters &&
- (unsigned int)numExpected != parameters.size())) {
+ static_cast<unsigned int>(numExpected) != parameters.size())) {
if (numExpected == 0) {
reportError(context, this->GetOriginalExpression(),
"$<" + identifier + "> expression requires no parameters.");
} else if (numExpected == 1) {
- reportError(context, this->GetOriginalExpression(), "$<" + identifier +
+ reportError(context, this->GetOriginalExpression(),
+ "$<" + identifier +
"> expression requires "
"exactly one parameter.");
} else {
@@ -173,12 +158,18 @@ std::string GeneratorExpressionContent::EvaluateParameters(
if (numExpected == cmGeneratorExpressionNode::OneOrMoreParameters &&
parameters.empty()) {
- reportError(context, this->GetOriginalExpression(), "$<" + identifier +
+ reportError(context, this->GetOriginalExpression(),
+ "$<" + identifier +
"> expression requires at least one parameter.");
- }
- if (numExpected == cmGeneratorExpressionNode::OneOrZeroParameters &&
- parameters.size() > 1) {
- reportError(context, this->GetOriginalExpression(), "$<" + identifier +
+ } else if (numExpected == cmGeneratorExpressionNode::TwoOrMoreParameters &&
+ parameters.size() < 2) {
+ reportError(context, this->GetOriginalExpression(),
+ "$<" + identifier +
+ "> expression requires at least two parameters.");
+ } else if (numExpected == cmGeneratorExpressionNode::OneOrZeroParameters &&
+ parameters.size() > 1) {
+ reportError(context, this->GetOriginalExpression(),
+ "$<" + identifier +
"> expression requires one or zero parameters.");
}
return std::string();
@@ -188,5 +179,5 @@ GeneratorExpressionContent::~GeneratorExpressionContent()
{
cmDeleteAll(this->IdentifierChildren);
std::for_each(this->ParamChildren.begin(), this->ParamChildren.end(),
- cmDeleteAll<std::vector<cmGeneratorExpressionEvaluator*> >);
+ cmDeleteAll<std::vector<cmGeneratorExpressionEvaluator*>>);
}
diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h
index a0a826ac6..b10bb5bda 100644
--- a/Source/cmGeneratorExpressionEvaluator.h
+++ b/Source/cmGeneratorExpressionEvaluator.h
@@ -3,10 +3,11 @@
#ifndef cmGeneratorExpressionEvaluator_h
#define cmGeneratorExpressionEvaluator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include <stddef.h>
+#include <cstddef>
#include <string>
+#include <utility>
#include <vector>
struct cmGeneratorExpressionContext;
@@ -15,8 +16,13 @@ struct cmGeneratorExpressionNode;
struct cmGeneratorExpressionEvaluator
{
- cmGeneratorExpressionEvaluator() {}
- virtual ~cmGeneratorExpressionEvaluator() {}
+ cmGeneratorExpressionEvaluator() = default;
+ virtual ~cmGeneratorExpressionEvaluator() = default;
+
+ cmGeneratorExpressionEvaluator(cmGeneratorExpressionEvaluator const&) =
+ delete;
+ cmGeneratorExpressionEvaluator& operator=(
+ cmGeneratorExpressionEvaluator const&) = delete;
enum Type
{
@@ -28,9 +34,6 @@ struct cmGeneratorExpressionEvaluator
virtual std::string Evaluate(cmGeneratorExpressionContext* context,
cmGeneratorExpressionDAGChecker*) const = 0;
-
-private:
- CM_DISABLE_COPY(cmGeneratorExpressionEvaluator)
};
struct TextContent : public cmGeneratorExpressionEvaluator
@@ -42,12 +45,12 @@ struct TextContent : public cmGeneratorExpressionEvaluator
}
std::string Evaluate(cmGeneratorExpressionContext*,
- cmGeneratorExpressionDAGChecker*) const CM_OVERRIDE
+ cmGeneratorExpressionDAGChecker*) const override
{
return std::string(this->Content, this->Length);
}
- Type GetType() const CM_OVERRIDE
+ Type GetType() const override
{
return cmGeneratorExpressionEvaluator::Text;
}
@@ -64,30 +67,29 @@ private:
struct GeneratorExpressionContent : public cmGeneratorExpressionEvaluator
{
GeneratorExpressionContent(const char* startContent, size_t length);
- void SetIdentifier(
- std::vector<cmGeneratorExpressionEvaluator*> const& identifier)
+
+ void SetIdentifier(std::vector<cmGeneratorExpressionEvaluator*> identifier)
{
- this->IdentifierChildren = identifier;
+ this->IdentifierChildren = std::move(identifier);
}
void SetParameters(
- std::vector<std::vector<cmGeneratorExpressionEvaluator*> > const&
- parameters)
+ std::vector<std::vector<cmGeneratorExpressionEvaluator*>> parameters)
{
- this->ParamChildren = parameters;
+ this->ParamChildren = std::move(parameters);
}
- Type GetType() const CM_OVERRIDE
+ Type GetType() const override
{
return cmGeneratorExpressionEvaluator::Generator;
}
std::string Evaluate(cmGeneratorExpressionContext* context,
- cmGeneratorExpressionDAGChecker*) const CM_OVERRIDE;
+ cmGeneratorExpressionDAGChecker*) const override;
std::string GetOriginalExpression() const;
- ~GeneratorExpressionContent() CM_OVERRIDE;
+ ~GeneratorExpressionContent() override;
private:
std::string EvaluateParameters(const cmGeneratorExpressionNode* node,
@@ -100,12 +102,12 @@ private:
const cmGeneratorExpressionNode* node, const std::string& identifier,
cmGeneratorExpressionContext* context,
cmGeneratorExpressionDAGChecker* dagChecker,
- std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
+ std::vector<std::vector<cmGeneratorExpressionEvaluator*>>::const_iterator
pit) const;
private:
std::vector<cmGeneratorExpressionEvaluator*> IdentifierChildren;
- std::vector<std::vector<cmGeneratorExpressionEvaluator*> > ParamChildren;
+ std::vector<std::vector<cmGeneratorExpressionEvaluator*>> ParamChildren;
const char* StartContent;
size_t ContentLength;
};
diff --git a/Source/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx
index 931fd4d62..a7f090ac7 100644
--- a/Source/cmGeneratorExpressionLexer.cxx
+++ b/Source/cmGeneratorExpressionLexer.cxx
@@ -2,18 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGeneratorExpressionLexer.h"
-cmGeneratorExpressionLexer::cmGeneratorExpressionLexer()
- : SawBeginExpression(false)
- , SawGeneratorExpression(false)
-{
-}
+cmGeneratorExpressionLexer::cmGeneratorExpressionLexer() = default;
static void InsertText(const char* upto, const char* c,
std::vector<cmGeneratorExpressionToken>& result)
{
if (upto != c) {
- result.push_back(cmGeneratorExpressionToken(
- cmGeneratorExpressionToken::Text, upto, c - upto));
+ result.emplace_back(cmGeneratorExpressionToken::Text, upto, c - upto);
}
}
@@ -22,6 +17,12 @@ std::vector<cmGeneratorExpressionToken> cmGeneratorExpressionLexer::Tokenize(
{
std::vector<cmGeneratorExpressionToken> result;
+ if (input.find('$') == std::string::npos) {
+ result.emplace_back(cmGeneratorExpressionToken::Text, input.c_str(),
+ input.size());
+ return result;
+ }
+
const char* c = input.c_str();
const char* upto = c;
@@ -30,8 +31,8 @@ std::vector<cmGeneratorExpressionToken> cmGeneratorExpressionLexer::Tokenize(
case '$':
if (c[1] == '<') {
InsertText(upto, c, result);
- result.push_back(cmGeneratorExpressionToken(
- cmGeneratorExpressionToken::BeginExpression, c, 2));
+ result.emplace_back(cmGeneratorExpressionToken::BeginExpression, c,
+ 2);
upto = c + 2;
++c;
SawBeginExpression = true;
@@ -39,21 +40,18 @@ std::vector<cmGeneratorExpressionToken> cmGeneratorExpressionLexer::Tokenize(
break;
case '>':
InsertText(upto, c, result);
- result.push_back(cmGeneratorExpressionToken(
- cmGeneratorExpressionToken::EndExpression, c, 1));
+ result.emplace_back(cmGeneratorExpressionToken::EndExpression, c, 1);
upto = c + 1;
SawGeneratorExpression = SawBeginExpression;
break;
case ':':
InsertText(upto, c, result);
- result.push_back(cmGeneratorExpressionToken(
- cmGeneratorExpressionToken::ColonSeparator, c, 1));
+ result.emplace_back(cmGeneratorExpressionToken::ColonSeparator, c, 1);
upto = c + 1;
break;
case ',':
InsertText(upto, c, result);
- result.push_back(cmGeneratorExpressionToken(
- cmGeneratorExpressionToken::CommaSeparator, c, 1));
+ result.emplace_back(cmGeneratorExpressionToken::CommaSeparator, c, 1);
upto = c + 1;
break;
default:
diff --git a/Source/cmGeneratorExpressionLexer.h b/Source/cmGeneratorExpressionLexer.h
index e53f0b547..9e0194861 100644
--- a/Source/cmGeneratorExpressionLexer.h
+++ b/Source/cmGeneratorExpressionLexer.h
@@ -5,7 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <stddef.h>
+#include <cstddef>
#include <string>
#include <vector>
@@ -46,8 +46,8 @@ public:
}
private:
- bool SawBeginExpression;
- bool SawGeneratorExpression;
+ bool SawBeginExpression = false;
+ bool SawGeneratorExpression = false;
};
#endif
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index a57d2a0d8..66f1c71f4 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -2,6 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGeneratorExpressionNode.h"
+#include <algorithm>
+#include <cassert>
+#include <cerrno>
+#include <cstdlib>
+#include <cstring>
+#include <map>
+#include <memory>
+#include <set>
+#include <sstream>
+#include <utility>
+
+#include <cm/iterator>
+
+#include "cmsys/RegularExpression.hxx"
+#include "cmsys/String.h"
+
+#include "cm_static_string_view.hxx"
+
#include "cmAlgorithms.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorExpressionContext.h"
@@ -12,39 +30,32 @@
#include "cmLinkItem.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmOutputConverter.h"
#include "cmPolicies.h"
+#include "cmRange.h"
+#include "cmState.h"
+#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
+#include "cmString.hxx"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
-#include "cmConfigure.h"
-#include "cmsys/RegularExpression.hxx"
-#include "cmsys/String.h"
-#include <algorithm>
-#include <assert.h>
-#include <errno.h>
-#include <map>
-#include <set>
-#include <sstream>
-#include <stdlib.h>
-#include <string.h>
-#include <utility>
-
std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
std::string const& prop, cmLocalGenerator* lg,
cmGeneratorExpressionContext* context, cmGeneratorTarget const* headTarget,
- cmGeneratorTarget const* currentTarget,
- cmGeneratorExpressionDAGChecker* dagChecker)
+ cmGeneratorExpressionDAGChecker* dagChecker,
+ cmGeneratorTarget const* currentTarget)
{
cmGeneratorExpression ge(context->Backtrace);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem);
+ cge->SetQuiet(context->Quiet);
std::string result =
- cge->Evaluate(lg, context->Config, context->Quiet, headTarget,
- currentTarget, dagChecker, context->Language);
+ cge->Evaluate(lg, context->Config, headTarget, dagChecker, currentTarget,
+ context->Language);
if (cge->GetHadContextSensitiveCondition()) {
context->HadContextSensitiveCondition = true;
}
@@ -56,17 +67,17 @@ std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
static const struct ZeroNode : public cmGeneratorExpressionNode
{
- ZeroNode() {}
+ ZeroNode() {} // NOLINT(modernize-use-equals-default)
- bool GeneratesContent() const CM_OVERRIDE { return false; }
+ bool GeneratesContent() const override { return false; }
- bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
+ bool AcceptsArbitraryContentParameter() const override { return true; }
- std::string Evaluate(const std::vector<std::string>& /*parameters*/,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& /*parameters*/,
+ cmGeneratorExpressionContext* /*context*/,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
return std::string();
}
@@ -74,15 +85,15 @@ static const struct ZeroNode : public cmGeneratorExpressionNode
static const struct OneNode : public cmGeneratorExpressionNode
{
- OneNode() {}
+ OneNode() {} // NOLINT(modernize-use-equals-default)
- bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
+ bool AcceptsArbitraryContentParameter() const override { return true; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* /*context*/,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
return parameters.front();
}
@@ -92,85 +103,89 @@ static const struct OneNode buildInterfaceNode;
static const struct ZeroNode installInterfaceNode;
-#define BOOLEAN_OP_NODE(OPNAME, OP, SUCCESS_VALUE, FAILURE_VALUE) \
- static const struct OP##Node : public cmGeneratorExpressionNode \
- { \
- OP##Node() {} \
- virtual int NumExpectedParameters() const { return OneOrMoreParameters; } \
- \
- std::string Evaluate(const std::vector<std::string>& parameters, \
- cmGeneratorExpressionContext* context, \
- const GeneratorExpressionContent* content, \
- cmGeneratorExpressionDAGChecker*) const \
- { \
- std::vector<std::string>::const_iterator it = parameters.begin(); \
- const std::vector<std::string>::const_iterator end = parameters.end(); \
- for (; it != end; ++it) { \
- if (*it == #FAILURE_VALUE) { \
- return #FAILURE_VALUE; \
- } \
- if (*it != #SUCCESS_VALUE) { \
- reportError(context, content->GetOriginalExpression(), \
- "Parameters to $<" #OP \
- "> must resolve to either '0' or '1'."); \
- return std::string(); \
- } \
- } \
- return #SUCCESS_VALUE; \
- } \
- } OPNAME;
-
-BOOLEAN_OP_NODE(andNode, AND, 1, 0)
-BOOLEAN_OP_NODE(orNode, OR, 0, 1)
-
-#undef BOOLEAN_OP_NODE
-
-static const struct NotNode : public cmGeneratorExpressionNode
+struct BooleanOpNode : public cmGeneratorExpressionNode
{
- NotNode() {}
+ BooleanOpNode(const char* op_, const char* successVal_,
+ const char* failureVal_)
+ : op(op_)
+ , successVal(successVal_)
+ , failureVal(failureVal_)
+ {
+ }
+
+ int NumExpectedParameters() const override { return OneOrMoreParameters; }
std::string Evaluate(const std::vector<std::string>& parameters,
cmGeneratorExpressionContext* context,
const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ cmGeneratorExpressionDAGChecker*) const override
{
- if (*parameters.begin() != "0" && *parameters.begin() != "1") {
+ for (std::string const& param : parameters) {
+ if (param == this->failureVal) {
+ return this->failureVal;
+ }
+ if (param != this->successVal) {
+ std::ostringstream e;
+ e << "Parameters to $<" << this->op;
+ e << "> must resolve to either '0' or '1'.";
+ reportError(context, content->GetOriginalExpression(), e.str());
+ return std::string();
+ }
+ }
+ return this->successVal;
+ }
+
+ const char *const op, *const successVal, *const failureVal;
+};
+
+static const BooleanOpNode andNode("AND", "1", "0"), orNode("OR", "0", "1");
+
+static const struct NotNode : public cmGeneratorExpressionNode
+{
+ NotNode() {} // NOLINT(modernize-use-equals-default)
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
+ {
+ if (parameters.front() != "0" && parameters.front() != "1") {
reportError(
context, content->GetOriginalExpression(),
"$<NOT> parameter must resolve to exactly one '0' or '1' value.");
return std::string();
}
- return *parameters.begin() == "0" ? "1" : "0";
+ return parameters.front() == "0" ? "1" : "0";
}
} notNode;
static const struct BoolNode : public cmGeneratorExpressionNode
{
- BoolNode() {}
+ BoolNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const CM_OVERRIDE { return 1; }
+ int NumExpectedParameters() const override { return 1; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* /*context*/,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
- return !cmSystemTools::IsOff(parameters.begin()->c_str()) ? "1" : "0";
+ return !cmIsOff(parameters.front()) ? "1" : "0";
}
} boolNode;
static const struct IfNode : public cmGeneratorExpressionNode
{
- IfNode() {}
+ IfNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const CM_OVERRIDE { return 3; }
+ int NumExpectedParameters() const override { return 3; }
std::string Evaluate(const std::vector<std::string>& parameters,
cmGeneratorExpressionContext* context,
const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker*) const CM_OVERRIDE
+ cmGeneratorExpressionDAGChecker*) const override
{
if (parameters[0] != "1" && parameters[0] != "0") {
reportError(context, content->GetOriginalExpression(),
@@ -184,109 +199,377 @@ static const struct IfNode : public cmGeneratorExpressionNode
static const struct StrEqualNode : public cmGeneratorExpressionNode
{
- StrEqualNode() {}
+ StrEqualNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const CM_OVERRIDE { return 2; }
+ int NumExpectedParameters() const override { return 2; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* /*context*/,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
- return *parameters.begin() == parameters[1] ? "1" : "0";
+ return parameters.front() == parameters[1] ? "1" : "0";
}
} strEqualNode;
static const struct EqualNode : public cmGeneratorExpressionNode
{
- EqualNode() {}
+ EqualNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const CM_OVERRIDE { return 2; }
+ int NumExpectedParameters() const override { return 2; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
- char* pEnd;
+ long numbers[2];
+ for (int i = 0; i < 2; ++i) {
+ if (!ParameterToLong(parameters[i].c_str(), &numbers[i])) {
+ reportError(context, content->GetOriginalExpression(),
+ "$<EQUAL> parameter " + parameters[i] +
+ " is not a valid integer.");
+ return {};
+ }
+ }
+ return numbers[0] == numbers[1] ? "1" : "0";
+ }
- int base = 0;
- bool flipSign = false;
+ static bool ParameterToLong(const char* param, long* outResult)
+ {
+ const char isNegative = param[0] == '-';
- const char* lhs = parameters[0].c_str();
- if (cmHasLiteralPrefix(lhs, "0b") || cmHasLiteralPrefix(lhs, "0B")) {
+ int base = 0;
+ if (cmHasLiteralPrefix(param, "0b") || cmHasLiteralPrefix(param, "0B")) {
base = 2;
- lhs += 2;
- }
- if (cmHasLiteralPrefix(lhs, "-0b") || cmHasLiteralPrefix(lhs, "-0B")) {
+ param += 2;
+ } else if (cmHasLiteralPrefix(param, "-0b") ||
+ cmHasLiteralPrefix(param, "-0B") ||
+ cmHasLiteralPrefix(param, "+0b") ||
+ cmHasLiteralPrefix(param, "+0B")) {
base = 2;
- lhs += 3;
- flipSign = true;
+ param += 3;
}
- if (cmHasLiteralPrefix(lhs, "+0b") || cmHasLiteralPrefix(lhs, "+0B")) {
- base = 2;
- lhs += 3;
+
+ char* pEnd;
+ long result = strtol(param, &pEnd, base);
+ if (pEnd == param || *pEnd != '\0' || errno == ERANGE) {
+ return false;
+ }
+ if (isNegative && result > 0) {
+ result *= -1;
+ }
+ *outResult = result;
+ return true;
+ }
+} equalNode;
+
+static const struct InListNode : public cmGeneratorExpressionNode
+{
+ InListNode() {} // NOLINT(modernize-use-equals-default)
+
+ int NumExpectedParameters() const override { return 2; }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
+ {
+ std::vector<std::string> values;
+ std::vector<std::string> checkValues;
+ bool check = false;
+ switch (context->LG->GetPolicyStatus(cmPolicies::CMP0085)) {
+ case cmPolicies::WARN:
+ if (parameters.front().empty()) {
+ check = true;
+ cmExpandList(parameters[1], checkValues, true);
+ }
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ cmExpandList(parameters[1], values);
+ if (check && values != checkValues) {
+ std::ostringstream e;
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0085)
+ << "\nSearch Item:\n \"" << parameters.front()
+ << "\"\nList:\n \"" << parameters[1] << "\"\n";
+ context->LG->GetCMakeInstance()->IssueMessage(
+ MessageType ::AUTHOR_WARNING, e.str(), context->Backtrace);
+ return "0";
+ }
+ if (values.empty()) {
+ return "0";
+ }
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ cmExpandList(parameters[1], values, true);
+ break;
}
- long lnum = strtol(lhs, &pEnd, base);
- if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) {
+ return cmContains(values, parameters.front()) ? "1" : "0";
+ }
+} inListNode;
+
+static const struct FilterNode : public cmGeneratorExpressionNode
+{
+ FilterNode() {} // NOLINT(modernize-use-equals-default)
+
+ int NumExpectedParameters() const override { return 3; }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
+ {
+ if (parameters.size() != 3) {
reportError(context, content->GetOriginalExpression(),
- "$<EQUAL> parameter " + parameters[0] +
- " is not a valid integer.");
+ "$<FILTER:...> expression requires three parameters");
+ return {};
+ }
+
+ if (parameters[1] != "INCLUDE" && parameters[1] != "EXCLUDE") {
+ reportError(
+ context, content->GetOriginalExpression(),
+ "$<FILTER:...> second parameter must be either INCLUDE or EXCLUDE");
+ return {};
+ }
+
+ const bool exclude = parameters[1] == "EXCLUDE";
+
+ cmsys::RegularExpression re;
+ if (!re.compile(parameters[2])) {
+ reportError(context, content->GetOriginalExpression(),
+ "$<FILTER:...> failed to compile regex");
+ return {};
+ }
+
+ std::vector<std::string> values;
+ std::vector<std::string> result;
+ cmExpandList(parameters.front(), values, true);
+
+ std::copy_if(values.cbegin(), values.cend(), std::back_inserter(result),
+ [&re, exclude](std::string const& input) {
+ return exclude ^ re.find(input);
+ });
+ return cmJoin(cmMakeRange(result.cbegin(), result.cend()), ";");
+ }
+} filterNode;
+
+static const struct RemoveDuplicatesNode : public cmGeneratorExpressionNode
+{
+ RemoveDuplicatesNode() {} // NOLINT(modernize-use-equals-default)
+
+ int NumExpectedParameters() const override { return 1; }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
+ {
+ if (parameters.size() != 1) {
+ reportError(
+ context, content->GetOriginalExpression(),
+ "$<REMOVE_DUPLICATES:...> expression requires one parameter");
+ }
+
+ std::vector<std::string> values = cmExpandedList(parameters.front(), true);
+
+ auto valuesEnd = cmRemoveDuplicates(values);
+ auto valuesBegin = values.cbegin();
+ return cmJoin(cmMakeRange(valuesBegin, valuesEnd), ";");
+ }
+
+} removeDuplicatesNode;
+
+static const struct TargetExistsNode : public cmGeneratorExpressionNode
+{
+ TargetExistsNode() {} // NOLINT(modernize-use-equals-default)
+
+ int NumExpectedParameters() const override { return 1; }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
+ {
+ if (parameters.size() != 1) {
+ reportError(context, content->GetOriginalExpression(),
+ "$<TARGET_EXISTS:...> expression requires one parameter");
return std::string();
}
- if (flipSign) {
- lnum = -lnum;
+ std::string targetName = parameters.front();
+ if (targetName.empty() ||
+ !cmGeneratorExpression::IsValidTargetName(targetName)) {
+ reportError(context, content->GetOriginalExpression(),
+ "$<TARGET_EXISTS:tgt> expression requires a non-empty "
+ "valid target name.");
+ return std::string();
}
- base = 0;
- flipSign = false;
+ return context->LG->GetMakefile()->FindTargetToUse(targetName) ? "1" : "0";
+ }
+} targetExistsNode;
- const char* rhs = parameters[1].c_str();
- if (cmHasLiteralPrefix(rhs, "0b") || cmHasLiteralPrefix(rhs, "0B")) {
- base = 2;
- rhs += 2;
+static const struct TargetNameIfExistsNode : public cmGeneratorExpressionNode
+{
+ TargetNameIfExistsNode() {} // NOLINT(modernize-use-equals-default)
+
+ int NumExpectedParameters() const override { return 1; }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
+ {
+ if (parameters.size() != 1) {
+ reportError(context, content->GetOriginalExpression(),
+ "$<TARGET_NAME_IF_EXISTS:...> expression requires one "
+ "parameter");
+ return std::string();
}
- if (cmHasLiteralPrefix(rhs, "-0b") || cmHasLiteralPrefix(rhs, "-0B")) {
- base = 2;
- rhs += 3;
- flipSign = true;
+
+ std::string targetName = parameters.front();
+ if (targetName.empty() ||
+ !cmGeneratorExpression::IsValidTargetName(targetName)) {
+ reportError(context, content->GetOriginalExpression(),
+ "$<TARGET_NAME_IF_EXISTS:tgt> expression requires a "
+ "non-empty valid target name.");
+ return std::string();
}
- if (cmHasLiteralPrefix(rhs, "+0b") || cmHasLiteralPrefix(rhs, "+0B")) {
- base = 2;
- rhs += 3;
+
+ return context->LG->GetMakefile()->FindTargetToUse(targetName)
+ ? targetName
+ : std::string();
+ }
+} targetNameIfExistsNode;
+
+struct GenexEvaluator : public cmGeneratorExpressionNode
+{
+ GenexEvaluator() {} // NOLINT(modernize-use-equals-default)
+
+protected:
+ std::string EvaluateExpression(
+ const std::string& genexOperator, const std::string& expression,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagCheckerParent) const
+ {
+ if (context->HeadTarget) {
+ cmGeneratorExpressionDAGChecker dagChecker(
+ context->Backtrace, context->HeadTarget,
+ genexOperator + ":" + expression, content, dagCheckerParent);
+ switch (dagChecker.Check()) {
+ case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
+ case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: {
+ dagChecker.ReportError(context, content->GetOriginalExpression());
+ return std::string();
+ }
+ case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
+ case cmGeneratorExpressionDAGChecker::DAG:
+ break;
+ }
+
+ return this->EvaluateDependentExpression(
+ expression, context->LG, context, context->HeadTarget, &dagChecker,
+ context->CurrentTarget);
}
- long rnum = strtol(rhs, &pEnd, base);
- if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) {
+ return this->EvaluateDependentExpression(
+ expression, context->LG, context, context->HeadTarget, dagCheckerParent,
+ context->CurrentTarget);
+ }
+};
+
+static const struct TargetGenexEvalNode : public GenexEvaluator
+{
+ TargetGenexEvalNode() {} // NOLINT(modernize-use-equals-default)
+
+ int NumExpectedParameters() const override { return 2; }
+
+ bool AcceptsArbitraryContentParameter() const override { return true; }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagCheckerParent) const override
+ {
+ const std::string& targetName = parameters.front();
+ if (targetName.empty() ||
+ !cmGeneratorExpression::IsValidTargetName(targetName)) {
reportError(context, content->GetOriginalExpression(),
- "$<EQUAL> parameter " + parameters[1] +
- " is not a valid integer.");
+ "$<TARGET_GENEX_EVAL:tgt, ...> expression requires a "
+ "non-empty valid target name.");
+ return std::string();
+ }
+
+ const auto* target = context->LG->FindGeneratorTargetToUse(targetName);
+ if (!target) {
+ std::ostringstream e;
+ e << "$<TARGET_GENEX_EVAL:tgt, ...> target \"" << targetName
+ << "\" not found.";
+ reportError(context, content->GetOriginalExpression(), e.str());
return std::string();
}
- if (flipSign) {
- rnum = -rnum;
+ const std::string& expression = parameters[1];
+ if (expression.empty()) {
+ return expression;
}
- return lnum == rnum ? "1" : "0";
+ cmGeneratorExpressionContext targetContext(
+ context->LG, context->Config, context->Quiet, target, target,
+ context->EvaluateForBuildsystem, context->Backtrace, context->Language);
+
+ return this->EvaluateExpression("TARGET_GENEX_EVAL", expression,
+ &targetContext, content, dagCheckerParent);
}
-} equalNode;
+} targetGenexEvalNode;
+
+static const struct GenexEvalNode : public GenexEvaluator
+{
+ GenexEvalNode() {} // NOLINT(modernize-use-equals-default)
+
+ int NumExpectedParameters() const override { return 1; }
+
+ bool AcceptsArbitraryContentParameter() const override { return true; }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagCheckerParent) const override
+ {
+ const std::string& expression = parameters[0];
+ if (expression.empty()) {
+ return expression;
+ }
+
+ return this->EvaluateExpression("GENEX_EVAL", expression, context, content,
+ dagCheckerParent);
+ }
+} genexEvalNode;
static const struct LowerCaseNode : public cmGeneratorExpressionNode
{
- LowerCaseNode() {}
+ LowerCaseNode() {} // NOLINT(modernize-use-equals-default)
- bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
+ bool AcceptsArbitraryContentParameter() const override { return true; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* /*context*/,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
return cmSystemTools::LowerCase(parameters.front());
}
@@ -294,15 +577,15 @@ static const struct LowerCaseNode : public cmGeneratorExpressionNode
static const struct UpperCaseNode : public cmGeneratorExpressionNode
{
- UpperCaseNode() {}
+ UpperCaseNode() {} // NOLINT(modernize-use-equals-default)
- bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
+ bool AcceptsArbitraryContentParameter() const override { return true; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* /*context*/,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
return cmSystemTools::UpperCase(parameters.front());
}
@@ -310,73 +593,66 @@ static const struct UpperCaseNode : public cmGeneratorExpressionNode
static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode
{
- MakeCIdentifierNode() {}
+ MakeCIdentifierNode() {} // NOLINT(modernize-use-equals-default)
- bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
+ bool AcceptsArbitraryContentParameter() const override { return true; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* /*context*/,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
return cmSystemTools::MakeCidentifier(parameters.front());
}
} makeCIdentifierNode;
-static const struct Angle_RNode : public cmGeneratorExpressionNode
+template <char C>
+struct CharacterNode : public cmGeneratorExpressionNode
{
- Angle_RNode() {}
+ CharacterNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const CM_OVERRIDE { return 0; }
+ int NumExpectedParameters() const override { return 0; }
- std::string Evaluate(const std::vector<std::string>& /*parameters*/,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& /*parameters*/,
+ cmGeneratorExpressionContext* /*context*/,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
- return ">";
+ return { C };
}
-} angle_rNode;
+};
+static const CharacterNode<'>'> angle_rNode;
+static const CharacterNode<','> commaNode;
+static const CharacterNode<';'> semicolonNode;
-static const struct CommaNode : public cmGeneratorExpressionNode
+struct CompilerIdNode : public cmGeneratorExpressionNode
{
- CommaNode() {}
-
- int NumExpectedParameters() const CM_OVERRIDE { return 0; }
-
- std::string Evaluate(const std::vector<std::string>& /*parameters*/,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ CompilerIdNode(const char* compilerLang)
+ : CompilerLanguage(compilerLang)
{
- return ",";
}
-} commaNode;
-static const struct SemicolonNode : public cmGeneratorExpressionNode
-{
- SemicolonNode() {}
-
- int NumExpectedParameters() const CM_OVERRIDE { return 0; }
+ int NumExpectedParameters() const override { return ZeroOrMoreParameters; }
- std::string Evaluate(const std::vector<std::string>& /*parameters*/,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
{
- return ";";
+ if (!context->HeadTarget) {
+ std::ostringstream e;
+ e << "$<" << this->CompilerLanguage
+ << "_COMPILER_ID> may only be used with binary targets. It may "
+ "not be used with add_custom_command or add_custom_target.";
+ reportError(context, content->GetOriginalExpression(), e.str());
+ return {};
+ }
+ return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
+ this->CompilerLanguage);
}
-} semicolonNode;
-
-struct CompilerIdNode : public cmGeneratorExpressionNode
-{
- CompilerIdNode() {}
-
- int NumExpectedParameters() const CM_OVERRIDE { return OneOrZeroParameters; }
std::string EvaluateWithLanguage(const std::vector<std::string>& parameters,
cmGeneratorExpressionContext* context,
@@ -384,95 +660,83 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
cmGeneratorExpressionDAGChecker* /*unused*/,
const std::string& lang) const
{
- const char* compilerId = context->LG->GetMakefile()->GetSafeDefinition(
- "CMAKE_" + lang + "_COMPILER_ID");
+ std::string const& compilerId =
+ context->LG->GetMakefile()->GetSafeDefinition("CMAKE_" + lang +
+ "_COMPILER_ID");
if (parameters.empty()) {
- return compilerId ? compilerId : "";
- }
- static cmsys::RegularExpression compilerIdValidator("^[A-Za-z0-9_]*$");
- if (!compilerIdValidator.find(*parameters.begin())) {
- reportError(context, content->GetOriginalExpression(),
- "Expression syntax not recognized.");
- return std::string();
+ return compilerId;
}
- if (!compilerId) {
+ if (compilerId.empty()) {
return parameters.front().empty() ? "1" : "0";
}
+ static cmsys::RegularExpression compilerIdValidator("^[A-Za-z0-9_]*$");
- if (strcmp(parameters.begin()->c_str(), compilerId) == 0) {
- return "1";
- }
+ for (auto& param : parameters) {
- if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0) {
- switch (context->LG->GetPolicyStatus(cmPolicies::CMP0044)) {
- case cmPolicies::WARN: {
- std::ostringstream e;
- e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0044);
- context->LG->GetCMakeInstance()->IssueMessage(
- cmake::AUTHOR_WARNING, e.str(), context->Backtrace);
- CM_FALLTHROUGH;
+ if (!compilerIdValidator.find(param)) {
+ reportError(context, content->GetOriginalExpression(),
+ "Expression syntax not recognized.");
+ return std::string();
+ }
+
+ if (strcmp(param.c_str(), compilerId.c_str()) == 0) {
+ return "1";
+ }
+
+ if (cmsysString_strcasecmp(param.c_str(), compilerId.c_str()) == 0) {
+ switch (context->LG->GetPolicyStatus(cmPolicies::CMP0044)) {
+ case cmPolicies::WARN: {
+ context->LG->GetCMakeInstance()->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0044),
+ context->Backtrace);
+ CM_FALLTHROUGH;
+ }
+ case cmPolicies::OLD:
+ return "1";
+ case cmPolicies::NEW:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ break;
}
- case cmPolicies::OLD:
- return "1";
- case cmPolicies::NEW:
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::REQUIRED_IF_USED:
- break;
}
}
return "0";
}
+
+ const char* const CompilerLanguage;
};
-static const struct CCompilerIdNode : public CompilerIdNode
-{
- CCompilerIdNode() {}
+static const CompilerIdNode cCompilerIdNode("C"), cxxCompilerIdNode("CXX"),
+ cudaCompilerIdNode("CUDA"), objcCompilerIdNode("OBJC"),
+ objcxxCompilerIdNode("OBJCXX"), fortranCompilerIdNode("Fortran");
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* dagChecker) const
- CM_OVERRIDE
+struct CompilerVersionNode : public cmGeneratorExpressionNode
+{
+ CompilerVersionNode(const char* compilerLang)
+ : CompilerLanguage(compilerLang)
{
- if (!context->HeadTarget) {
- reportError(
- context, content->GetOriginalExpression(),
- "$<C_COMPILER_ID> may only be used with binary targets. It may "
- "not be used with add_custom_command or add_custom_target.");
- return std::string();
- }
- return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
- "C");
}
-} cCompilerIdNode;
-static const struct CXXCompilerIdNode : public CompilerIdNode
-{
- CXXCompilerIdNode() {}
+ int NumExpectedParameters() const override { return OneOrZeroParameters; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* dagChecker) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
{
if (!context->HeadTarget) {
- reportError(
- context, content->GetOriginalExpression(),
- "$<CXX_COMPILER_ID> may only be used with binary targets. It may "
- "not be used with add_custom_command or add_custom_target.");
- return std::string();
+ std::ostringstream e;
+ e << "$<" << this->CompilerLanguage
+ << "_COMPILER_VERSION> may only be used with binary targets. It "
+ "may not be used with add_custom_command or add_custom_target.";
+ reportError(context, content->GetOriginalExpression(), e.str());
+ return {};
}
return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
- "CXX");
+ this->CompilerLanguage);
}
-} cxxCompilerIdNode;
-
-struct CompilerVersionNode : public cmGeneratorExpressionNode
-{
- CompilerVersionNode() {}
-
- int NumExpectedParameters() const CM_OVERRIDE { return OneOrZeroParameters; }
std::string EvaluateWithLanguage(const std::vector<std::string>& parameters,
cmGeneratorExpressionContext* context,
@@ -480,213 +744,104 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
cmGeneratorExpressionDAGChecker* /*unused*/,
const std::string& lang) const
{
- const char* compilerVersion =
+ std::string const& compilerVersion =
context->LG->GetMakefile()->GetSafeDefinition("CMAKE_" + lang +
"_COMPILER_VERSION");
if (parameters.empty()) {
- return compilerVersion ? compilerVersion : "";
+ return compilerVersion;
}
static cmsys::RegularExpression compilerIdValidator("^[0-9\\.]*$");
- if (!compilerIdValidator.find(*parameters.begin())) {
+ if (!compilerIdValidator.find(parameters.front())) {
reportError(context, content->GetOriginalExpression(),
"Expression syntax not recognized.");
- return std::string();
+ return {};
}
- if (!compilerVersion) {
+ if (compilerVersion.empty()) {
return parameters.front().empty() ? "1" : "0";
}
return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
- parameters.begin()->c_str(),
- compilerVersion)
+ parameters.front().c_str(),
+ compilerVersion.c_str())
? "1"
: "0";
}
-};
-
-static const struct CCompilerVersionNode : public CompilerVersionNode
-{
- CCompilerVersionNode() {}
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* dagChecker) const
- CM_OVERRIDE
- {
- if (!context->HeadTarget) {
- reportError(
- context, content->GetOriginalExpression(),
- "$<C_COMPILER_VERSION> may only be used with binary targets. It "
- "may not be used with add_custom_command or add_custom_target.");
- return std::string();
- }
- return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
- "C");
- }
-} cCompilerVersionNode;
-
-static const struct CxxCompilerVersionNode : public CompilerVersionNode
-{
- CxxCompilerVersionNode() {}
+ const char* const CompilerLanguage;
+};
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* dagChecker) const
- CM_OVERRIDE
- {
- if (!context->HeadTarget) {
- reportError(
- context, content->GetOriginalExpression(),
- "$<CXX_COMPILER_VERSION> may only be used with binary targets. It "
- "may not be used with add_custom_command or add_custom_target.");
- return std::string();
- }
- return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
- "CXX");
- }
-} cxxCompilerVersionNode;
+static const CompilerVersionNode cCompilerVersionNode("C"),
+ cxxCompilerVersionNode("CXX"), cudaCompilerVersionNode("CUDA"),
+ objcCompilerVersionNode("OBJC"), objcxxCompilerVersionNode("OBJCXX"),
+ fortranCompilerVersionNode("Fortran");
struct PlatformIdNode : public cmGeneratorExpressionNode
{
- PlatformIdNode() {}
+ PlatformIdNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const CM_OVERRIDE { return OneOrZeroParameters; }
+ int NumExpectedParameters() const override { return ZeroOrMoreParameters; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
- const char* platformId =
+ std::string const& platformId =
context->LG->GetMakefile()->GetSafeDefinition("CMAKE_SYSTEM_NAME");
if (parameters.empty()) {
- return platformId ? platformId : "";
+ return platformId;
}
- if (!platformId) {
+ if (platformId.empty()) {
return parameters.front().empty() ? "1" : "0";
}
- if (strcmp(parameters.begin()->c_str(), platformId) == 0) {
- return "1";
+ for (auto& param : parameters) {
+ if (param == platformId) {
+ return "1";
+ }
}
return "0";
}
} platformIdNode;
-static const struct VersionGreaterNode : public cmGeneratorExpressionNode
-{
- VersionGreaterNode() {}
-
- int NumExpectedParameters() const CM_OVERRIDE { return 2; }
-
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
- {
- return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER,
- parameters.front().c_str(),
- parameters[1].c_str())
- ? "1"
- : "0";
- }
-} versionGreaterNode;
-
-static const struct VersionGreaterEqNode : public cmGeneratorExpressionNode
-{
- VersionGreaterEqNode() {}
-
- int NumExpectedParameters() const CM_OVERRIDE { return 2; }
-
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
- {
- return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL,
- parameters.front().c_str(),
- parameters[1].c_str())
- ? "1"
- : "0";
- }
-} versionGreaterEqNode;
-
-static const struct VersionLessNode : public cmGeneratorExpressionNode
-{
- VersionLessNode() {}
-
- int NumExpectedParameters() const CM_OVERRIDE { return 2; }
-
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
- {
- return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
- parameters.front().c_str(),
- parameters[1].c_str())
- ? "1"
- : "0";
- }
-} versionLessNode;
-
-static const struct VersionLessEqNode : public cmGeneratorExpressionNode
+template <cmSystemTools::CompareOp Op>
+struct VersionNode : public cmGeneratorExpressionNode
{
- VersionLessEqNode() {}
+ VersionNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const CM_OVERRIDE { return 2; }
+ int NumExpectedParameters() const override { return 2; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* /*context*/,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
- return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS_EQUAL,
- parameters.front().c_str(),
+ return cmSystemTools::VersionCompare(Op, parameters.front().c_str(),
parameters[1].c_str())
? "1"
: "0";
}
-} versionLessEqNode;
-
-static const struct VersionEqualNode : public cmGeneratorExpressionNode
-{
- VersionEqualNode() {}
-
- int NumExpectedParameters() const CM_OVERRIDE { return 2; }
+};
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
- {
- return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
- parameters.front().c_str(),
- parameters[1].c_str())
- ? "1"
- : "0";
- }
-} versionEqualNode;
+static const VersionNode<cmSystemTools::OP_GREATER> versionGreaterNode;
+static const VersionNode<cmSystemTools::OP_GREATER_EQUAL> versionGreaterEqNode;
+static const VersionNode<cmSystemTools::OP_LESS> versionLessNode;
+static const VersionNode<cmSystemTools::OP_LESS_EQUAL> versionLessEqNode;
+static const VersionNode<cmSystemTools::OP_EQUAL> versionEqualNode;
static const struct LinkOnlyNode : public cmGeneratorExpressionNode
{
- LinkOnlyNode() {}
+ LinkOnlyNode() {} // NOLINT(modernize-use-equals-default)
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* dagChecker) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
{
if (!dagChecker) {
reportError(context, content->GetOriginalExpression(),
@@ -702,15 +857,15 @@ static const struct LinkOnlyNode : public cmGeneratorExpressionNode
static const struct ConfigurationNode : public cmGeneratorExpressionNode
{
- ConfigurationNode() {}
+ ConfigurationNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const CM_OVERRIDE { return 0; }
+ int NumExpectedParameters() const override { return 0; }
- std::string Evaluate(const std::vector<std::string>& /*parameters*/,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& /*parameters*/,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
context->HadContextSensitiveCondition = true;
return context->Config;
@@ -719,22 +874,21 @@ static const struct ConfigurationNode : public cmGeneratorExpressionNode
static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
{
- ConfigurationTestNode() {}
+ ConfigurationTestNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const CM_OVERRIDE { return OneOrZeroParameters; }
+ int NumExpectedParameters() const override { return OneOrZeroParameters; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
if (parameters.empty()) {
- return configurationNode.Evaluate(parameters, context, content,
- CM_NULLPTR);
+ return configurationNode.Evaluate(parameters, context, content, nullptr);
}
static cmsys::RegularExpression configValidator("^[A-Za-z0-9_]*$");
- if (!configValidator.find(*parameters.begin())) {
+ if (!configValidator.find(parameters.front())) {
reportError(context, content->GetOriginalExpression(),
"Expression syntax not recognized.");
return std::string();
@@ -744,14 +898,14 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
return parameters.front().empty() ? "1" : "0";
}
- if (cmsysString_strcasecmp(parameters.begin()->c_str(),
+ if (cmsysString_strcasecmp(parameters.front().c_str(),
context->Config.c_str()) == 0) {
return "1";
}
if (context->CurrentTarget && context->CurrentTarget->IsImported()) {
- const char* loc = CM_NULLPTR;
- const char* imp = CM_NULLPTR;
+ const char* loc = nullptr;
+ const char* imp = nullptr;
std::string suffix;
if (context->CurrentTarget->Target->GetMappedConfig(
context->Config, &loc, &imp, suffix)) {
@@ -759,15 +913,13 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
// for this (possibly mapped) config.
// Check if there is a proper config mapping for the tested config.
std::vector<std::string> mappedConfigs;
- std::string mapProp = "MAP_IMPORTED_CONFIG_";
- mapProp += cmSystemTools::UpperCase(context->Config);
+ std::string mapProp = cmStrCat(
+ "MAP_IMPORTED_CONFIG_", cmSystemTools::UpperCase(context->Config));
if (const char* mapValue =
context->CurrentTarget->GetProperty(mapProp)) {
- cmSystemTools::ExpandListArgument(cmSystemTools::UpperCase(mapValue),
- mappedConfigs);
- return std::find(mappedConfigs.begin(), mappedConfigs.end(),
- cmSystemTools::UpperCase(parameters.front())) !=
- mappedConfigs.end()
+ cmExpandList(cmSystemTools::UpperCase(mapValue), mappedConfigs);
+ return cmContains(mappedConfigs,
+ cmSystemTools::UpperCase(parameters.front()))
? "1"
: "0";
}
@@ -779,201 +931,204 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
static const struct JoinNode : public cmGeneratorExpressionNode
{
- JoinNode() {}
+ JoinNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const CM_OVERRIDE { return 2; }
+ int NumExpectedParameters() const override { return 2; }
- bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
+ bool AcceptsArbitraryContentParameter() const override { return true; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* /*context*/,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
- std::vector<std::string> list;
- cmSystemTools::ExpandListArgument(parameters.front(), list);
+ std::vector<std::string> list = cmExpandedList(parameters.front());
return cmJoin(list, parameters[1]);
}
} joinNode;
static const struct CompileLanguageNode : public cmGeneratorExpressionNode
{
- CompileLanguageNode() {}
+ CompileLanguageNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const CM_OVERRIDE { return OneOrZeroParameters; }
+ int NumExpectedParameters() const override { return ZeroOrMoreParameters; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* dagChecker) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
if (context->Language.empty()) {
reportError(
context, content->GetOriginalExpression(),
"$<COMPILE_LANGUAGE:...> may only be used to specify include "
- "directories compile definitions, compile options and to evaluate "
+ "directories, compile definitions, compile options, and to evaluate "
"components of the file(GENERATE) command.");
return std::string();
}
- std::vector<std::string> enabledLanguages;
cmGlobalGenerator* gg = context->LG->GetGlobalGenerator();
- gg->GetEnabledLanguages(enabledLanguages);
- if (!parameters.empty() &&
- std::find(enabledLanguages.begin(), enabledLanguages.end(),
- parameters.front()) == enabledLanguages.end()) {
- reportError(context, content->GetOriginalExpression(),
- "$<COMPILE_LANGUAGE:...> Unknown language.");
- return std::string();
- }
std::string genName = gg->GetName();
- if (genName.find("Visual Studio") != std::string::npos) {
+ if (genName.find("Makefiles") == std::string::npos &&
+ genName.find("Ninja") == std::string::npos &&
+ genName.find("Visual Studio") == std::string::npos &&
+ genName.find("Xcode") == std::string::npos &&
+ genName.find("Watcom WMake") == std::string::npos) {
reportError(context, content->GetOriginalExpression(),
- "$<COMPILE_LANGUAGE:...> may not be used with Visual Studio "
- "generators.");
+ "$<COMPILE_LANGUAGE:...> not supported for this generator.");
return std::string();
}
- if (genName.find("Xcode") != std::string::npos) {
- if (dagChecker && (dagChecker->EvaluatingCompileDefinitions() ||
- dagChecker->EvaluatingIncludeDirectories())) {
- reportError(
- context, content->GetOriginalExpression(),
- "$<COMPILE_LANGUAGE:...> may only be used with COMPILE_OPTIONS "
- "with the Xcode generator.");
- return std::string();
- }
- } else {
- if (genName.find("Makefiles") == std::string::npos &&
- genName.find("Ninja") == std::string::npos &&
- genName.find("Watcom WMake") == std::string::npos) {
- reportError(
- context, content->GetOriginalExpression(),
- "$<COMPILE_LANGUAGE:...> not supported for this generator.");
- return std::string();
- }
- }
if (parameters.empty()) {
return context->Language;
}
- return context->Language == parameters.front() ? "1" : "0";
+
+ for (auto& param : parameters) {
+ if (context->Language == param) {
+ return "1";
+ }
+ }
+ return "0";
}
} languageNode;
-#define TRANSITIVE_PROPERTY_NAME(PROPERTY) , "INTERFACE_" #PROPERTY
+static const struct CompileLanguageAndIdNode : public cmGeneratorExpressionNode
+{
+ CompileLanguageAndIdNode() {} // NOLINT(modernize-use-equals-default)
-static const char* targetPropertyTransitiveWhitelist[] = {
- CM_NULLPTR CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(TRANSITIVE_PROPERTY_NAME)
-};
+ int NumExpectedParameters() const override { return TwoOrMoreParameters; }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
+ {
+ if (!context->HeadTarget || context->Language.empty()) {
+ // reportError(context, content->GetOriginalExpression(), "");
+ reportError(
+ context, content->GetOriginalExpression(),
+ "$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets "
+ "to specify include directories, compile definitions, and compile "
+ "options. It may not be used with the add_custom_command, "
+ "add_custom_target, or file(GENERATE) commands.");
+ return std::string();
+ }
+ cmGlobalGenerator* gg = context->LG->GetGlobalGenerator();
+ std::string genName = gg->GetName();
+ if (genName.find("Makefiles") == std::string::npos &&
+ genName.find("Ninja") == std::string::npos &&
+ genName.find("Visual Studio") == std::string::npos &&
+ genName.find("Xcode") == std::string::npos &&
+ genName.find("Watcom WMake") == std::string::npos) {
+ reportError(
+ context, content->GetOriginalExpression(),
+ "$<COMPILE_LANG_AND_ID:lang,id> not supported for this generator.");
+ return std::string();
+ }
-#undef TRANSITIVE_PROPERTY_NAME
+ const std::string& lang = context->Language;
+ if (lang == parameters.front()) {
+ std::vector<std::string> idParameter((parameters.cbegin() + 1),
+ parameters.cend());
+ return CompilerIdNode{ lang.c_str() }.EvaluateWithLanguage(
+ idParameter, context, content, dagChecker, lang);
+ }
+ return "0";
+ }
+} languageAndIdNode;
-template <typename T>
std::string getLinkedTargetsContent(
- std::vector<T> const& libraries, cmGeneratorTarget const* target,
- cmGeneratorTarget const* headTarget, cmGeneratorExpressionContext* context,
- cmGeneratorExpressionDAGChecker* dagChecker,
- const std::string& interfacePropertyName)
-{
- std::string linkedTargetsContent;
- std::string sep;
- std::string depString;
- for (typename std::vector<T>::const_iterator it = libraries.begin();
- it != libraries.end(); ++it) {
- // Broken code can have a target in its own link interface.
- // Don't follow such link interface entries so as not to create a
- // self-referencing loop.
- if (it->Target && it->Target != target) {
- depString += sep + "$<TARGET_PROPERTY:" + it->Target->GetName() + "," +
- interfacePropertyName + ">";
- sep = ";";
- }
- }
- if (!depString.empty()) {
- linkedTargetsContent =
- cmGeneratorExpressionNode::EvaluateDependentExpression(
- depString, target->GetLocalGenerator(), context, headTarget, target,
- dagChecker);
- }
- linkedTargetsContent =
- cmGeneratorExpression::StripEmptyListElements(linkedTargetsContent);
- return linkedTargetsContent;
+ cmGeneratorTarget const* target, std::string const& prop,
+ cmGeneratorExpressionContext* context,
+ cmGeneratorExpressionDAGChecker* dagChecker)
+{
+ std::string result;
+ if (cmLinkImplementationLibraries const* impl =
+ target->GetLinkImplementationLibraries(context->Config)) {
+ for (cmLinkImplItem const& lib : impl->Libraries) {
+ if (lib.Target) {
+ // Pretend $<TARGET_PROPERTY:lib.Target,prop> appeared in our
+ // caller's property and hand-evaluate it as if it were compiled.
+ // Create a context as cmCompiledGeneratorExpression::Evaluate does.
+ cmGeneratorExpressionContext libContext(
+ target->GetLocalGenerator(), context->Config, context->Quiet, target,
+ target, context->EvaluateForBuildsystem, lib.Backtrace,
+ context->Language);
+ std::string libResult =
+ lib.Target->EvaluateInterfaceProperty(prop, &libContext, dagChecker);
+ if (!libResult.empty()) {
+ if (result.empty()) {
+ result = std::move(libResult);
+ } else {
+ result.reserve(result.size() + 1 + libResult.size());
+ result += ";";
+ result += libResult;
+ }
+ }
+ }
+ }
+ }
+ return result;
}
static const struct TargetPropertyNode : public cmGeneratorExpressionNode
{
- TargetPropertyNode() {}
+ TargetPropertyNode() {} // NOLINT(modernize-use-equals-default)
// This node handles errors on parameter count itself.
- int NumExpectedParameters() const CM_OVERRIDE { return OneOrMoreParameters; }
+ int NumExpectedParameters() const override { return OneOrMoreParameters; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* dagCheckerParent) const
- CM_OVERRIDE
+ static const char* GetErrorText(std::string const& targetName,
+ std::string const& propertyName)
{
- if (parameters.size() != 1 && parameters.size() != 2) {
- reportError(
- context, content->GetOriginalExpression(),
- "$<TARGET_PROPERTY:...> expression requires one or two parameters");
- return std::string();
- }
static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$");
-
- cmGeneratorTarget const* target = context->HeadTarget;
- std::string propertyName = *parameters.begin();
-
- if (parameters.size() == 1) {
- context->HadHeadSensitiveCondition = true;
+ if (targetName.empty() && propertyName.empty()) {
+ return "$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
+ "target name and property name.";
}
- if (!target && parameters.size() == 1) {
- reportError(
- context, content->GetOriginalExpression(),
- "$<TARGET_PROPERTY:prop> may only be used with binary targets. "
- "It may not be used with add_custom_command or add_custom_target. "
- "Specify the target to read a property from using the "
- "$<TARGET_PROPERTY:tgt,prop> signature instead.");
- return std::string();
+ if (targetName.empty()) {
+ return "$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
+ "target name.";
}
-
- if (parameters.size() == 2) {
- if (parameters.begin()->empty() && parameters[1].empty()) {
- reportError(
- context, content->GetOriginalExpression(),
- "$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
- "target name and property name.");
- return std::string();
- }
- if (parameters.begin()->empty()) {
- reportError(
- context, content->GetOriginalExpression(),
- "$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
- "target name.");
- return std::string();
+ if (!cmGeneratorExpression::IsValidTargetName(targetName)) {
+ if (!propertyNameValidator.find(propertyName)) {
+ return "Target name and property name not supported.";
}
+ return "Target name not supported.";
+ }
+ return nullptr;
+ }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagCheckerParent) const override
+ {
+ static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$");
- std::string targetName = parameters.front();
+ cmGeneratorTarget const* target = nullptr;
+ std::string targetName;
+ std::string propertyName;
+
+ if (parameters.size() == 2) {
+ targetName = parameters[0];
propertyName = parameters[1];
- if (!cmGeneratorExpression::IsValidTargetName(targetName)) {
- if (!propertyNameValidator.find(propertyName.c_str())) {
- ::reportError(context, content->GetOriginalExpression(),
- "Target name and property name not supported.");
- return std::string();
- }
- ::reportError(context, content->GetOriginalExpression(),
- "Target name not supported.");
+
+ if (const char* e = GetErrorText(targetName, propertyName)) {
+ reportError(context, content->GetOriginalExpression(), e);
return std::string();
}
- if (propertyName == "ALIASED_TARGET") {
+ if (propertyName == "ALIASED_TARGET"_s) {
if (context->LG->GetMakefile()->IsAlias(targetName)) {
if (cmGeneratorTarget* tgt =
context->LG->FindGeneratorTargetToUse(targetName)) {
return tgt->GetName();
}
}
- return "";
+ return std::string();
}
target = context->LG->FindGeneratorTargetToUse(targetName);
@@ -984,15 +1139,34 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
return std::string();
}
context->AllTargets.insert(target);
- }
- if (target == context->HeadTarget) {
+ } else if (parameters.size() == 1) {
+ target = context->HeadTarget;
+ propertyName = parameters[0];
+
// Keep track of the properties seen while processing.
// The evaluation of the LINK_LIBRARIES generator expressions
// will check this to ensure that properties have one consistent
// value for all evaluations.
context->SeenTargetProperties.insert(propertyName);
+
+ context->HadHeadSensitiveCondition = true;
+ if (!target) {
+ reportError(
+ context, content->GetOriginalExpression(),
+ "$<TARGET_PROPERTY:prop> may only be used with binary targets. "
+ "It may not be used with add_custom_command or add_custom_target. "
+ "Specify the target to read a property from using the "
+ "$<TARGET_PROPERTY:tgt,prop> signature instead.");
+ return std::string();
+ }
+ } else {
+ reportError(
+ context, content->GetOriginalExpression(),
+ "$<TARGET_PROPERTY:...> expression requires one or two parameters");
+ return std::string();
}
+
if (propertyName == "SOURCES") {
context->SourceSensitiveTargets.insert(target);
}
@@ -1026,37 +1200,37 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
return target->GetLinkerLanguage(context->Config);
}
- cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
- target->GetName(), propertyName,
- content, dagCheckerParent);
+ std::string interfacePropertyName;
+ bool isInterfaceProperty = false;
- switch (dagChecker.Check()) {
- case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
- dagChecker.ReportError(context, content->GetOriginalExpression());
- return std::string();
- case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE:
- // No error. We just skip cyclic references.
- return std::string();
- case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
- for (size_t i = 1; i < cmArraySize(targetPropertyTransitiveWhitelist);
- ++i) {
- if (targetPropertyTransitiveWhitelist[i] == propertyName) {
- // No error. We're not going to find anything new here.
- return std::string();
- }
- }
- case cmGeneratorExpressionDAGChecker::DAG:
- break;
+#define POPULATE_INTERFACE_PROPERTY_NAME(prop) \
+ if (propertyName == #prop) { \
+ interfacePropertyName = "INTERFACE_" #prop; \
+ } else if (propertyName == "INTERFACE_" #prop) { \
+ interfacePropertyName = "INTERFACE_" #prop; \
+ isInterfaceProperty = true; \
+ } else
+
+ CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(POPULATE_INTERFACE_PROPERTY_NAME)
+ // Note that the above macro terminates with an else
+ /* else */ if (cmHasLiteralPrefix(propertyName, "COMPILE_DEFINITIONS_")) {
+ cmPolicies::PolicyStatus polSt =
+ context->LG->GetPolicyStatus(cmPolicies::CMP0043);
+ if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) {
+ interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS";
+ }
}
+#undef POPULATE_INTERFACE_PROPERTY_NAME
- const char* prop = target->GetProperty(propertyName);
+ bool evaluatingLinkLibraries = false;
if (dagCheckerParent) {
- if (dagCheckerParent->EvaluatingLinkLibraries()) {
-#define TRANSITIVE_PROPERTY_COMPARE(PROPERTY) \
- (#PROPERTY == propertyName || "INTERFACE_" #PROPERTY == propertyName) ||
- if (CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(
- TRANSITIVE_PROPERTY_COMPARE) false) { // NOLINT(clang-tidy)
+ if (dagCheckerParent->EvaluatingGenexExpression() ||
+ dagCheckerParent->EvaluatingPICExpression()) {
+ // No check required.
+ } else if (dagCheckerParent->EvaluatingLinkLibraries()) {
+ evaluatingLinkLibraries = true;
+ if (!interfacePropertyName.empty()) {
reportError(
context, content->GetOriginalExpression(),
"$<TARGET_PROPERTY:...> expression in link libraries "
@@ -1064,70 +1238,47 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
"over the link libraries, creating a recursion.");
return std::string();
}
-#undef TRANSITIVE_PROPERTY_COMPARE
-
- if (!prop) {
- return std::string();
- }
} else {
#define ASSERT_TRANSITIVE_PROPERTY_METHOD(METHOD) dagCheckerParent->METHOD() ||
-
assert(CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
ASSERT_TRANSITIVE_PROPERTY_METHOD) false); // NOLINT(clang-tidy)
#undef ASSERT_TRANSITIVE_PROPERTY_METHOD
}
}
- std::string linkedTargetsContent;
-
- std::string interfacePropertyName;
- bool isInterfaceProperty = false;
+ if (isInterfaceProperty) {
+ return target->EvaluateInterfaceProperty(propertyName, context,
+ dagCheckerParent);
+ }
-#define POPULATE_INTERFACE_PROPERTY_NAME(prop) \
- if (propertyName == #prop) { \
- interfacePropertyName = "INTERFACE_" #prop; \
- } else if (propertyName == "INTERFACE_" #prop) { \
- interfacePropertyName = "INTERFACE_" #prop; \
- isInterfaceProperty = true; \
- } else
+ cmGeneratorExpressionDAGChecker dagChecker(
+ context->Backtrace, target, propertyName, content, dagCheckerParent);
- CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(POPULATE_INTERFACE_PROPERTY_NAME)
- // Note that the above macro terminates with an else
- /* else */ if (cmHasLiteralPrefix(propertyName.c_str(),
- "COMPILE_DEFINITIONS_")) {
- cmPolicies::PolicyStatus polSt =
- context->LG->GetPolicyStatus(cmPolicies::CMP0043);
- if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) {
- interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS";
- }
+ switch (dagChecker.Check()) {
+ case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
+ dagChecker.ReportError(context, content->GetOriginalExpression());
+ return std::string();
+ case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE:
+ // No error. We just skip cyclic references.
+ return std::string();
+ case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
+ // We handle transitive properties above. For non-transitive
+ // properties we accept repeats anyway.
+ case cmGeneratorExpressionDAGChecker::DAG:
+ break;
}
-#undef POPULATE_INTERFACE_PROPERTY_NAME
- cmGeneratorTarget const* headTarget =
- context->HeadTarget && isInterfaceProperty ? context->HeadTarget
- : target;
- if (isInterfaceProperty) {
- if (cmLinkInterfaceLibraries const* iface =
- target->GetLinkInterfaceLibraries(context->Config, headTarget,
- true)) {
- linkedTargetsContent =
- getLinkedTargetsContent(iface->Libraries, target, headTarget,
- context, &dagChecker, interfacePropertyName);
- }
- } else if (!interfacePropertyName.empty()) {
- if (cmLinkImplementationLibraries const* impl =
- target->GetLinkImplementationLibraries(context->Config)) {
- linkedTargetsContent =
- getLinkedTargetsContent(impl->Libraries, target, target, context,
- &dagChecker, interfacePropertyName);
- }
+ std::string result;
+ bool haveProp = false;
+ if (const char* p = target->GetProperty(propertyName)) {
+ result = p;
+ haveProp = true;
+ } else if (evaluatingLinkLibraries) {
+ return std::string();
}
- if (!prop) {
- if (target->IsImported() ||
- target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
- return linkedTargetsContent;
- }
+ if (!haveProp && !target->IsImported() &&
+ target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
if (target->IsLinkInterfaceDependentBoolProperty(propertyName,
context->Config)) {
context->HadContextSensitiveCondition = true;
@@ -1160,8 +1311,6 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
context->Config);
return propContent ? propContent : "";
}
-
- return linkedTargetsContent;
}
if (!target->IsImported() && dagCheckerParent &&
@@ -1183,49 +1332,51 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
return propContent ? propContent : "";
}
}
+
if (!interfacePropertyName.empty()) {
- std::string result = this->EvaluateDependentExpression(
- prop, context->LG, context, headTarget, target, &dagChecker);
+ result = this->EvaluateDependentExpression(result, context->LG, context,
+ target, &dagChecker, target);
+ std::string linkedTargetsContent = getLinkedTargetsContent(
+ target, interfacePropertyName, context, &dagChecker);
if (!linkedTargetsContent.empty()) {
result += (result.empty() ? "" : ";") + linkedTargetsContent;
}
- return result;
}
- return prop;
+ return result;
}
} targetPropertyNode;
static const struct TargetNameNode : public cmGeneratorExpressionNode
{
- TargetNameNode() {}
+ TargetNameNode() {} // NOLINT(modernize-use-equals-default)
- bool GeneratesContent() const CM_OVERRIDE { return true; }
+ bool GeneratesContent() const override { return true; }
- bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
- bool RequiresLiteralInput() const CM_OVERRIDE { return true; }
+ bool AcceptsArbitraryContentParameter() const override { return true; }
+ bool RequiresLiteralInput() const override { return true; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* /*context*/,
+ const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
return parameters.front();
}
- int NumExpectedParameters() const CM_OVERRIDE { return 1; }
+ int NumExpectedParameters() const override { return 1; }
} targetNameNode;
static const struct TargetObjectsNode : public cmGeneratorExpressionNode
{
- TargetObjectsNode() {}
+ TargetObjectsNode() {} // NOLINT(modernize-use-equals-default)
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
std::string tgtName = parameters.front();
cmGeneratorTarget* gt = context->LG->FindGeneratorTargetToUse(tgtName);
@@ -1236,10 +1387,16 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
reportError(context, content->GetOriginalExpression(), e.str());
return std::string();
}
- if (gt->GetType() != cmStateEnums::OBJECT_LIBRARY) {
+ cmStateEnums::TargetType type = gt->GetType();
+ if (type != cmStateEnums::EXECUTABLE &&
+ type != cmStateEnums::STATIC_LIBRARY &&
+ type != cmStateEnums::SHARED_LIBRARY &&
+ type != cmStateEnums::MODULE_LIBRARY &&
+ type != cmStateEnums::OBJECT_LIBRARY) {
std::ostringstream e;
e << "Objects of target \"" << tgtName
- << "\" referenced but is not an OBJECT library.";
+ << "\" referenced but is not an allowed library types (EXECUTABLE, "
+ << "STATIC, SHARED, MODULE, OBJECT).";
reportError(context, content->GetOriginalExpression(), e.str());
return std::string();
}
@@ -1250,8 +1407,9 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
std::ostringstream e;
e << "The evaluation of the TARGET_OBJECTS generator expression "
"is only suitable for consumption by CMake (limited"
- << reason << "). "
- "It is not suitable for writing out elsewhere.";
+ << reason
+ << "). "
+ "It is not suitable for writing out elsewhere.";
reportError(context, content->GetOriginalExpression(), e.str());
return std::string();
}
@@ -1260,11 +1418,11 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
std::vector<std::string> objects;
if (gt->IsImported()) {
- const char* loc = CM_NULLPTR;
- const char* imp = CM_NULLPTR;
+ const char* loc = nullptr;
+ const char* imp = nullptr;
std::string suffix;
if (gt->Target->GetMappedConfig(context->Config, &loc, &imp, suffix)) {
- cmSystemTools::ExpandListArgument(loc, objects);
+ cmExpandList(loc, objects);
}
context->HadContextSensitiveCondition = true;
} else {
@@ -1283,17 +1441,15 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
context->HadContextSensitiveCondition = true;
}
- for (std::vector<std::string>::iterator oi = objects.begin();
- oi != objects.end(); ++oi) {
- *oi = obj_dir + *oi;
+ for (std::string& o : objects) {
+ o = cmStrCat(obj_dir, o);
}
}
// Create the cmSourceFile instances in the referencing directory.
cmMakefile* mf = context->LG->GetMakefile();
- for (std::vector<std::string>::iterator oi = objects.begin();
- oi != objects.end(); ++oi) {
- mf->AddTargetObject(tgtName, *oi);
+ for (std::string& o : objects) {
+ mf->AddTargetObject(tgtName, o);
}
return cmJoin(objects, ";");
@@ -1302,15 +1458,15 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
{
- CompileFeaturesNode() {}
+ CompileFeaturesNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const CM_OVERRIDE { return OneOrMoreParameters; }
+ int NumExpectedParameters() const override { return OneOrMoreParameters; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* dagChecker) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
{
cmGeneratorTarget const* target = context->HeadTarget;
if (!target) {
@@ -1322,21 +1478,20 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
}
context->HadHeadSensitiveCondition = true;
- typedef std::map<std::string, std::vector<std::string> > LangMap;
+ using LangMap = std::map<std::string, std::vector<std::string>>;
static LangMap availableFeatures;
LangMap testedFeatures;
- for (std::vector<std::string>::const_iterator it = parameters.begin();
- it != parameters.end(); ++it) {
+ for (std::string const& p : parameters) {
std::string error;
std::string lang;
if (!context->LG->GetMakefile()->CompileFeatureKnown(
- context->HeadTarget->Target, *it, lang, &error)) {
+ context->HeadTarget->Target, p, lang, &error)) {
reportError(context, content->GetOriginalExpression(), error);
return std::string();
}
- testedFeatures[lang].push_back(*it);
+ testedFeatures[lang].push_back(p);
if (availableFeatures.find(lang) == availableFeatures.end()) {
const char* featuresKnown =
@@ -1345,23 +1500,19 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
reportError(context, content->GetOriginalExpression(), error);
return std::string();
}
- cmSystemTools::ExpandListArgument(featuresKnown,
- availableFeatures[lang]);
+ cmExpandList(featuresKnown, availableFeatures[lang]);
}
}
bool evalLL = dagChecker && dagChecker->EvaluatingLinkLibraries();
- for (LangMap::const_iterator lit = testedFeatures.begin();
- lit != testedFeatures.end(); ++lit) {
+ for (auto const& lit : testedFeatures) {
std::vector<std::string> const& langAvailable =
- availableFeatures[lit->first];
+ availableFeatures[lit.first];
const char* standardDefault = context->LG->GetMakefile()->GetDefinition(
- "CMAKE_" + lit->first + "_STANDARD_DEFAULT");
- for (std::vector<std::string>::const_iterator it = lit->second.begin();
- it != lit->second.end(); ++it) {
- if (std::find(langAvailable.begin(), langAvailable.end(), *it) ==
- langAvailable.end()) {
+ "CMAKE_" + lit.first + "_STANDARD_DEFAULT");
+ for (std::string const& it : lit.second) {
+ if (!cmContains(langAvailable, it)) {
return "0";
}
if (standardDefault && !*standardDefault) {
@@ -1370,14 +1521,14 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
continue;
}
if (!context->LG->GetMakefile()->HaveStandardAvailable(
- target->Target, lit->first, *it)) {
+ target->Target, lit.first, it)) {
if (evalLL) {
- const char* l = target->GetProperty(lit->first + "_STANDARD");
+ const char* l = target->GetProperty(lit.first + "_STANDARD");
if (!l) {
l = standardDefault;
}
assert(l);
- context->MaxLanguageStandard[target][lit->first] = l;
+ context->MaxLanguageStandard[target][lit.first] = l;
} else {
return "0";
}
@@ -1389,10 +1540,10 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
} compileFeaturesNode;
static const char* targetPolicyWhitelist[] = {
- CM_NULLPTR
+ nullptr
#define TARGET_POLICY_STRING(POLICY) , #POLICY
- CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_STRING)
+ CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_STRING)
#undef TARGET_POLICY_STRING
};
@@ -1430,15 +1581,15 @@ cmPolicies::PolicyID policyForString(const char* policy_id)
static const struct TargetPolicyNode : public cmGeneratorExpressionNode
{
- TargetPolicyNode() {}
+ TargetPolicyNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const CM_OVERRIDE { return 1; }
+ int NumExpectedParameters() const override { return 1; }
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
if (!context->HeadTarget) {
reportError(
@@ -1451,14 +1602,14 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode
context->HadContextSensitiveCondition = true;
context->HadHeadSensitiveCondition = true;
- for (size_t i = 1; i < cmArraySize(targetPolicyWhitelist); ++i) {
+ for (size_t i = 1; i < cm::size(targetPolicyWhitelist); ++i) {
const char* policy = targetPolicyWhitelist[i];
if (parameters.front() == policy) {
cmLocalGenerator* lg = context->HeadTarget->GetLocalGenerator();
switch (statusForTarget(context->HeadTarget, policy)) {
case cmPolicies::WARN:
lg->IssueMessage(
- cmake::AUTHOR_WARNING,
+ MessageType::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(policyForString(policy)));
CM_FALLTHROUGH;
case cmPolicies::REQUIRED_IF_USED:
@@ -1483,7 +1634,7 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode
CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_LIST_ITEM)
#undef TARGET_POLICY_LIST_ITEM
- );
+ );
return std::string();
}
@@ -1491,16 +1642,16 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode
static const struct InstallPrefixNode : public cmGeneratorExpressionNode
{
- InstallPrefixNode() {}
+ InstallPrefixNode() {} // NOLINT(modernize-use-equals-default)
- bool GeneratesContent() const CM_OVERRIDE { return true; }
- int NumExpectedParameters() const CM_OVERRIDE { return 0; }
+ bool GeneratesContent() const override { return true; }
+ int NumExpectedParameters() const override { return 0; }
- std::string Evaluate(const std::vector<std::string>& /*parameters*/,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& /*parameters*/,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
reportError(context, content->GetOriginalExpression(),
"INSTALL_PREFIX is a marker for install(EXPORT) only. It "
@@ -1547,9 +1698,8 @@ struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag>
"SHARED libraries.");
return std::string();
}
- std::string result = target->GetDirectory(context->Config);
- result += "/";
- result += target->GetSOName(context->Config);
+ std::string result = cmStrCat(target->GetDirectory(context->Config), '/',
+ target->GetSOName(context->Config));
return result;
}
};
@@ -1588,9 +1738,8 @@ struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag>
return std::string();
}
- std::string result = target->GetPDBDirectory(context->Config);
- result += "/";
- result += target->GetPDBName(context->Config);
+ std::string result = cmStrCat(target->GetPDBDirectory(context->Config),
+ '/', target->GetPDBName(context->Config));
return result;
}
};
@@ -1609,7 +1758,8 @@ struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag>
"executables with ENABLE_EXPORTS.");
return std::string();
}
- cmStateEnums::ArtifactType artifact = target->HasImportLibrary()
+ cmStateEnums::ArtifactType artifact =
+ target->HasImportLibrary(context->Config)
? cmStateEnums::ImportLibraryArtifact
: cmStateEnums::RuntimeBinaryArtifact;
return target->GetFullPath(context->Config, artifact);
@@ -1708,45 +1858,68 @@ struct TargetFilesystemArtifactResultGetter<ArtifactPathTag>
static std::string Get(const std::string& result) { return result; }
};
-template <typename ArtifactT, typename ComponentT>
-struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
+struct TargetArtifactBase : public cmGeneratorExpressionNode
{
- TargetFilesystemArtifact() {}
-
- int NumExpectedParameters() const CM_OVERRIDE { return 1; }
-
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* dagChecker) const
- CM_OVERRIDE
+ TargetArtifactBase() {} // NOLINT(modernize-use-equals-default)
+
+protected:
+ cmGeneratorTarget* GetTarget(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagChecker) const
{
// Lookup the referenced target.
- std::string name = *parameters.begin();
+ std::string name = parameters.front();
if (!cmGeneratorExpression::IsValidTargetName(name)) {
::reportError(context, content->GetOriginalExpression(),
"Expression syntax not recognized.");
- return std::string();
+ return nullptr;
}
cmGeneratorTarget* target = context->LG->FindGeneratorTargetToUse(name);
if (!target) {
::reportError(context, content->GetOriginalExpression(),
"No target \"" + name + "\"");
- return std::string();
+ return nullptr;
}
if (target->GetType() >= cmStateEnums::OBJECT_LIBRARY &&
target->GetType() != cmStateEnums::UNKNOWN_LIBRARY) {
- ::reportError(context, content->GetOriginalExpression(), "Target \"" +
- name + "\" is not an executable or library.");
- return std::string();
- }
- if (dagChecker && (dagChecker->EvaluatingLinkLibraries(name.c_str()) ||
- (dagChecker->EvaluatingSources() &&
- name == dagChecker->TopTarget()))) {
+ ::reportError(context, content->GetOriginalExpression(),
+ "Target \"" + name +
+ "\" is not an executable or library.");
+ return nullptr;
+ }
+ if (dagChecker &&
+ (dagChecker->EvaluatingLinkLibraries(target) ||
+ (dagChecker->EvaluatingSources() &&
+ target == dagChecker->TopTarget()))) {
::reportError(context, content->GetOriginalExpression(),
"Expressions which require the linker language may not "
"be used while evaluating link libraries");
+ return nullptr;
+ }
+
+ return target;
+ }
+};
+
+template <typename ArtifactT, typename ComponentT>
+struct TargetFilesystemArtifact : public TargetArtifactBase
+{
+ TargetFilesystemArtifact() {} // NOLINT(modernize-use-equals-default)
+
+ int NumExpectedParameters() const override { return 1; }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
+ {
+ cmGeneratorTarget* target =
+ this->GetTarget(parameters, context, content, dagChecker);
+ if (!target) {
return std::string();
}
context->DependTargets.insert(target);
@@ -1765,7 +1938,9 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
template <typename ArtifactT>
struct TargetFilesystemArtifactNodeGroup
{
- TargetFilesystemArtifactNodeGroup() {}
+ TargetFilesystemArtifactNodeGroup() // NOLINT(modernize-use-equals-default)
+ {
+ }
TargetFilesystemArtifact<ArtifactT, ArtifactPathTag> File;
TargetFilesystemArtifact<ArtifactT, ArtifactNameTag> FileName;
@@ -1791,91 +1966,364 @@ static const TargetFilesystemArtifact<ArtifactBundleContentDirTag,
ArtifactPathTag>
targetBundleContentDirNode;
+//
+// To retrieve base name for various artifacts
+//
+template <typename ArtifactT>
+struct TargetOutputNameArtifactResultGetter
+{
+ static std::string Get(cmGeneratorTarget* target,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content);
+};
+
+template <>
+struct TargetOutputNameArtifactResultGetter<ArtifactNameTag>
+{
+ static std::string Get(cmGeneratorTarget* target,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* /*unused*/)
+ {
+ return target->GetOutputName(context->Config,
+ cmStateEnums::RuntimeBinaryArtifact) +
+ target->GetFilePostfix(context->Config);
+ }
+};
+
+template <>
+struct TargetOutputNameArtifactResultGetter<ArtifactLinkerTag>
+{
+ static std::string Get(cmGeneratorTarget* target,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content)
+ {
+ // The file used to link to the target (.so, .lib, .a).
+ if (!target->IsLinkable()) {
+ ::reportError(context, content->GetOriginalExpression(),
+ "TARGET_LINKER_FILE_BASE_NAME is allowed only for "
+ "libraries and executables with ENABLE_EXPORTS.");
+ return std::string();
+ }
+ cmStateEnums::ArtifactType artifact =
+ target->HasImportLibrary(context->Config)
+ ? cmStateEnums::ImportLibraryArtifact
+ : cmStateEnums::RuntimeBinaryArtifact;
+ return target->GetOutputName(context->Config, artifact) +
+ target->GetFilePostfix(context->Config);
+ }
+};
+
+template <>
+struct TargetOutputNameArtifactResultGetter<ArtifactPdbTag>
+{
+ static std::string Get(cmGeneratorTarget* target,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content)
+ {
+ if (target->IsImported()) {
+ ::reportError(
+ context, content->GetOriginalExpression(),
+ "TARGET_PDB_FILE_BASE_NAME not allowed for IMPORTED targets.");
+ return std::string();
+ }
+
+ std::string language = target->GetLinkerLanguage(context->Config);
+
+ std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB";
+
+ if (!context->LG->GetMakefile()->IsOn(pdbSupportVar)) {
+ ::reportError(
+ context, content->GetOriginalExpression(),
+ "TARGET_PDB_FILE_BASE_NAME is not supported by the target linker.");
+ return std::string();
+ }
+
+ cmStateEnums::TargetType targetType = target->GetType();
+
+ if (targetType != cmStateEnums::SHARED_LIBRARY &&
+ targetType != cmStateEnums::MODULE_LIBRARY &&
+ targetType != cmStateEnums::EXECUTABLE) {
+ ::reportError(context, content->GetOriginalExpression(),
+ "TARGET_PDB_FILE_BASE_NAME is allowed only for "
+ "targets with linker created artifacts.");
+ return std::string();
+ }
+
+ return target->GetPDBOutputName(context->Config) +
+ target->GetFilePostfix(context->Config);
+ }
+};
+
+template <typename ArtifactT>
+struct TargetFileBaseNameArtifact : public TargetArtifactBase
+{
+ TargetFileBaseNameArtifact() {} // NOLINT(modernize-use-equals-default)
+
+ int NumExpectedParameters() const override { return 1; }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
+ {
+ cmGeneratorTarget* target =
+ this->GetTarget(parameters, context, content, dagChecker);
+ if (!target) {
+ return std::string();
+ }
+
+ std::string result = TargetOutputNameArtifactResultGetter<ArtifactT>::Get(
+ target, context, content);
+ if (context->HadError) {
+ return std::string();
+ }
+ return result;
+ }
+};
+
+static const TargetFileBaseNameArtifact<ArtifactNameTag>
+ targetFileBaseNameNode;
+static const TargetFileBaseNameArtifact<ArtifactLinkerTag>
+ targetLinkerFileBaseNameNode;
+static const TargetFileBaseNameArtifact<ArtifactPdbTag>
+ targetPdbFileBaseNameNode;
+
+class ArtifactFilePrefixTag;
+class ArtifactLinkerFilePrefixTag;
+class ArtifactFileSuffixTag;
+class ArtifactLinkerFileSuffixTag;
+
+template <typename ArtifactT>
+struct TargetFileArtifactResultGetter
+{
+ static std::string Get(cmGeneratorTarget* target,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content);
+};
+
+template <>
+struct TargetFileArtifactResultGetter<ArtifactFilePrefixTag>
+{
+ static std::string Get(cmGeneratorTarget* target,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent*)
+ {
+ return target->GetFilePrefix(context->Config);
+ }
+};
+template <>
+struct TargetFileArtifactResultGetter<ArtifactLinkerFilePrefixTag>
+{
+ static std::string Get(cmGeneratorTarget* target,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content)
+ {
+ if (!target->IsLinkable()) {
+ ::reportError(context, content->GetOriginalExpression(),
+ "TARGET_LINKER_PREFIX is allowed only for libraries and "
+ "executables with ENABLE_EXPORTS.");
+ return std::string();
+ }
+
+ cmStateEnums::ArtifactType artifact =
+ target->HasImportLibrary(context->Config)
+ ? cmStateEnums::ImportLibraryArtifact
+ : cmStateEnums::RuntimeBinaryArtifact;
+
+ return target->GetFilePrefix(context->Config, artifact);
+ }
+};
+template <>
+struct TargetFileArtifactResultGetter<ArtifactFileSuffixTag>
+{
+ static std::string Get(cmGeneratorTarget* target,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent*)
+ {
+ return target->GetFileSuffix(context->Config);
+ }
+};
+template <>
+struct TargetFileArtifactResultGetter<ArtifactLinkerFileSuffixTag>
+{
+ static std::string Get(cmGeneratorTarget* target,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content)
+ {
+ if (!target->IsLinkable()) {
+ ::reportError(context, content->GetOriginalExpression(),
+ "TARGET_LINKER_SUFFIX is allowed only for libraries and "
+ "executables with ENABLE_EXPORTS.");
+ return std::string();
+ }
+
+ cmStateEnums::ArtifactType artifact =
+ target->HasImportLibrary(context->Config)
+ ? cmStateEnums::ImportLibraryArtifact
+ : cmStateEnums::RuntimeBinaryArtifact;
+
+ return target->GetFileSuffix(context->Config, artifact);
+ }
+};
+
+template <typename ArtifactT>
+struct TargetFileArtifact : public TargetArtifactBase
+{
+ TargetFileArtifact() {} // NOLINT(modernize-use-equals-default)
+
+ int NumExpectedParameters() const override { return 1; }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
+ {
+ cmGeneratorTarget* target =
+ this->GetTarget(parameters, context, content, dagChecker);
+ if (!target) {
+ return std::string();
+ }
+
+ std::string result =
+ TargetFileArtifactResultGetter<ArtifactT>::Get(target, context, content);
+ if (context->HadError) {
+ return std::string();
+ }
+ return result;
+ }
+};
+
+static const TargetFileArtifact<ArtifactFilePrefixTag> targetFilePrefixNode;
+static const TargetFileArtifact<ArtifactLinkerFilePrefixTag>
+ targetLinkerFilePrefixNode;
+static const TargetFileArtifact<ArtifactFileSuffixTag> targetFileSuffixNode;
+static const TargetFileArtifact<ArtifactLinkerFileSuffixTag>
+ targetLinkerFileSuffixNode;
+
static const struct ShellPathNode : public cmGeneratorExpressionNode
{
- ShellPathNode() {}
+ ShellPathNode() {} // NOLINT(modernize-use-equals-default)
- std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
- CM_OVERRIDE
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
- if (!cmSystemTools::FileIsFullPath(parameters.front())) {
+ std::vector<std::string> listIn = cmExpandedList(parameters.front());
+ if (listIn.empty()) {
reportError(context, content->GetOriginalExpression(),
- "\"" + parameters.front() + "\" is not an absolute path.");
+ "\"\" is not an absolute path.");
return std::string();
}
- cmOutputConverter converter(context->LG->GetStateSnapshot());
- return converter.ConvertDirectorySeparatorsForShell(parameters.front());
+ cmStateSnapshot snapshot = context->LG->GetStateSnapshot();
+ cmOutputConverter converter(snapshot);
+ const char* separator = snapshot.GetState()->UseWindowsShell() ? ";" : ":";
+ std::vector<std::string> listOut;
+ listOut.reserve(listIn.size());
+ for (auto const& in : listIn) {
+ if (!cmSystemTools::FileIsFullPath(in)) {
+ reportError(context, content->GetOriginalExpression(),
+ "\"" + in + "\" is not an absolute path.");
+ return std::string();
+ }
+ listOut.emplace_back(converter.ConvertDirectorySeparatorsForShell(in));
+ }
+ return cmJoin(listOut, separator);
}
} shellPathNode;
const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(
const std::string& identifier)
{
- typedef std::map<std::string, const cmGeneratorExpressionNode*> NodeMap;
- static NodeMap nodeMap;
- if (nodeMap.empty()) {
- nodeMap["0"] = &zeroNode;
- nodeMap["1"] = &oneNode;
- nodeMap["AND"] = &andNode;
- nodeMap["OR"] = &orNode;
- nodeMap["NOT"] = &notNode;
- nodeMap["C_COMPILER_ID"] = &cCompilerIdNode;
- nodeMap["CXX_COMPILER_ID"] = &cxxCompilerIdNode;
- nodeMap["VERSION_GREATER"] = &versionGreaterNode;
- nodeMap["VERSION_GREATER_EQUAL"] = &versionGreaterEqNode;
- nodeMap["VERSION_LESS"] = &versionLessNode;
- nodeMap["VERSION_LESS_EQUAL"] = &versionLessEqNode;
- nodeMap["VERSION_EQUAL"] = &versionEqualNode;
- nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode;
- nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode;
- nodeMap["PLATFORM_ID"] = &platformIdNode;
- nodeMap["COMPILE_FEATURES"] = &compileFeaturesNode;
- nodeMap["CONFIGURATION"] = &configurationNode;
- nodeMap["CONFIG"] = &configurationTestNode;
- nodeMap["TARGET_FILE"] = &targetNodeGroup.File;
- nodeMap["TARGET_LINKER_FILE"] = &targetLinkerNodeGroup.File;
- nodeMap["TARGET_SONAME_FILE"] = &targetSoNameNodeGroup.File;
- nodeMap["TARGET_PDB_FILE"] = &targetPdbNodeGroup.File;
- nodeMap["TARGET_FILE_NAME"] = &targetNodeGroup.FileName;
- nodeMap["TARGET_LINKER_FILE_NAME"] = &targetLinkerNodeGroup.FileName;
- nodeMap["TARGET_SONAME_FILE_NAME"] = &targetSoNameNodeGroup.FileName;
- nodeMap["TARGET_PDB_FILE_NAME"] = &targetPdbNodeGroup.FileName;
- nodeMap["TARGET_FILE_DIR"] = &targetNodeGroup.FileDir;
- nodeMap["TARGET_LINKER_FILE_DIR"] = &targetLinkerNodeGroup.FileDir;
- nodeMap["TARGET_SONAME_FILE_DIR"] = &targetSoNameNodeGroup.FileDir;
- nodeMap["TARGET_PDB_FILE_DIR"] = &targetPdbNodeGroup.FileDir;
- nodeMap["TARGET_BUNDLE_DIR"] = &targetBundleDirNode;
- nodeMap["TARGET_BUNDLE_CONTENT_DIR"] = &targetBundleContentDirNode;
- nodeMap["STREQUAL"] = &strEqualNode;
- nodeMap["EQUAL"] = &equalNode;
- nodeMap["LOWER_CASE"] = &lowerCaseNode;
- nodeMap["UPPER_CASE"] = &upperCaseNode;
- nodeMap["MAKE_C_IDENTIFIER"] = &makeCIdentifierNode;
- nodeMap["BOOL"] = &boolNode;
- nodeMap["IF"] = &ifNode;
- nodeMap["ANGLE-R"] = &angle_rNode;
- nodeMap["COMMA"] = &commaNode;
- nodeMap["SEMICOLON"] = &semicolonNode;
- nodeMap["TARGET_PROPERTY"] = &targetPropertyNode;
- nodeMap["TARGET_NAME"] = &targetNameNode;
- nodeMap["TARGET_OBJECTS"] = &targetObjectsNode;
- nodeMap["TARGET_POLICY"] = &targetPolicyNode;
- nodeMap["BUILD_INTERFACE"] = &buildInterfaceNode;
- nodeMap["INSTALL_INTERFACE"] = &installInterfaceNode;
- nodeMap["INSTALL_PREFIX"] = &installPrefixNode;
- nodeMap["JOIN"] = &joinNode;
- nodeMap["LINK_ONLY"] = &linkOnlyNode;
- nodeMap["COMPILE_LANGUAGE"] = &languageNode;
- nodeMap["SHELL_PATH"] = &shellPathNode;
- }
- NodeMap::const_iterator i = nodeMap.find(identifier);
- if (i == nodeMap.end()) {
- return CM_NULLPTR;
- }
- return i->second;
+ static std::map<std::string, cmGeneratorExpressionNode const*> const nodeMap{
+ { "0", &zeroNode },
+ { "1", &oneNode },
+ { "AND", &andNode },
+ { "OR", &orNode },
+ { "NOT", &notNode },
+ { "C_COMPILER_ID", &cCompilerIdNode },
+ { "CXX_COMPILER_ID", &cxxCompilerIdNode },
+ { "OBJC_COMPILER_ID", &objcCompilerIdNode },
+ { "OBJCXX_COMPILER_ID", &objcxxCompilerIdNode },
+ { "CUDA_COMPILER_ID", &cudaCompilerIdNode },
+ { "Fortran_COMPILER_ID", &fortranCompilerIdNode },
+ { "VERSION_GREATER", &versionGreaterNode },
+ { "VERSION_GREATER_EQUAL", &versionGreaterEqNode },
+ { "VERSION_LESS", &versionLessNode },
+ { "VERSION_LESS_EQUAL", &versionLessEqNode },
+ { "VERSION_EQUAL", &versionEqualNode },
+ { "C_COMPILER_VERSION", &cCompilerVersionNode },
+ { "CXX_COMPILER_VERSION", &cxxCompilerVersionNode },
+ { "CUDA_COMPILER_VERSION", &cudaCompilerVersionNode },
+ { "OBJC_COMPILER_VERSION", &objcCompilerVersionNode },
+ { "OBJCXX_COMPILER_VERSION", &objcxxCompilerVersionNode },
+ { "Fortran_COMPILER_VERSION", &fortranCompilerVersionNode },
+ { "PLATFORM_ID", &platformIdNode },
+ { "COMPILE_FEATURES", &compileFeaturesNode },
+ { "CONFIGURATION", &configurationNode },
+ { "CONFIG", &configurationTestNode },
+ { "TARGET_FILE", &targetNodeGroup.File },
+ { "TARGET_LINKER_FILE", &targetLinkerNodeGroup.File },
+ { "TARGET_SONAME_FILE", &targetSoNameNodeGroup.File },
+ { "TARGET_PDB_FILE", &targetPdbNodeGroup.File },
+ { "TARGET_FILE_BASE_NAME", &targetFileBaseNameNode },
+ { "TARGET_LINKER_FILE_BASE_NAME", &targetLinkerFileBaseNameNode },
+ { "TARGET_PDB_FILE_BASE_NAME", &targetPdbFileBaseNameNode },
+ { "TARGET_FILE_PREFIX", &targetFilePrefixNode },
+ { "TARGET_LINKER_FILE_PREFIX", &targetLinkerFilePrefixNode },
+ { "TARGET_FILE_SUFFIX", &targetFileSuffixNode },
+ { "TARGET_LINKER_FILE_SUFFIX", &targetLinkerFileSuffixNode },
+ { "TARGET_FILE_NAME", &targetNodeGroup.FileName },
+ { "TARGET_LINKER_FILE_NAME", &targetLinkerNodeGroup.FileName },
+ { "TARGET_SONAME_FILE_NAME", &targetSoNameNodeGroup.FileName },
+ { "TARGET_PDB_FILE_NAME", &targetPdbNodeGroup.FileName },
+ { "TARGET_FILE_DIR", &targetNodeGroup.FileDir },
+ { "TARGET_LINKER_FILE_DIR", &targetLinkerNodeGroup.FileDir },
+ { "TARGET_SONAME_FILE_DIR", &targetSoNameNodeGroup.FileDir },
+ { "TARGET_PDB_FILE_DIR", &targetPdbNodeGroup.FileDir },
+ { "TARGET_BUNDLE_DIR", &targetBundleDirNode },
+ { "TARGET_BUNDLE_CONTENT_DIR", &targetBundleContentDirNode },
+ { "STREQUAL", &strEqualNode },
+ { "EQUAL", &equalNode },
+ { "IN_LIST", &inListNode },
+ { "FILTER", &filterNode },
+ { "REMOVE_DUPLICATES", &removeDuplicatesNode },
+ { "LOWER_CASE", &lowerCaseNode },
+ { "UPPER_CASE", &upperCaseNode },
+ { "MAKE_C_IDENTIFIER", &makeCIdentifierNode },
+ { "BOOL", &boolNode },
+ { "IF", &ifNode },
+ { "ANGLE-R", &angle_rNode },
+ { "COMMA", &commaNode },
+ { "SEMICOLON", &semicolonNode },
+ { "TARGET_PROPERTY", &targetPropertyNode },
+ { "TARGET_NAME", &targetNameNode },
+ { "TARGET_OBJECTS", &targetObjectsNode },
+ { "TARGET_POLICY", &targetPolicyNode },
+ { "TARGET_EXISTS", &targetExistsNode },
+ { "TARGET_NAME_IF_EXISTS", &targetNameIfExistsNode },
+ { "TARGET_GENEX_EVAL", &targetGenexEvalNode },
+ { "GENEX_EVAL", &genexEvalNode },
+ { "BUILD_INTERFACE", &buildInterfaceNode },
+ { "INSTALL_INTERFACE", &installInterfaceNode },
+ { "INSTALL_PREFIX", &installPrefixNode },
+ { "JOIN", &joinNode },
+ { "LINK_ONLY", &linkOnlyNode },
+ { "COMPILE_LANG_AND_ID", &languageAndIdNode },
+ { "COMPILE_LANGUAGE", &languageNode },
+ { "SHELL_PATH", &shellPathNode }
+ };
+
+ {
+ auto itr = nodeMap.find(identifier);
+ if (itr != nodeMap.end()) {
+ return itr->second;
+ }
+ }
+ return nullptr;
}
void reportError(cmGeneratorExpressionContext* context,
@@ -1892,6 +2340,6 @@ void reportError(cmGeneratorExpressionContext* context,
<< " " << expr << "\n"
<< result;
/* clang-format on */
- context->LG->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
- context->Backtrace);
+ context->LG->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
+ e.str(), context->Backtrace);
}
diff --git a/Source/cmGeneratorExpressionNode.h b/Source/cmGeneratorExpressionNode.h
index ece1c113c..13e8484ef 100644
--- a/Source/cmGeneratorExpressionNode.h
+++ b/Source/cmGeneratorExpressionNode.h
@@ -20,9 +20,11 @@ struct cmGeneratorExpressionNode
{
DynamicParameters = 0,
OneOrMoreParameters = -1,
- OneOrZeroParameters = -2
+ TwoOrMoreParameters = -2,
+ ZeroOrMoreParameters = -3,
+ OneOrZeroParameters = -4
};
- virtual ~cmGeneratorExpressionNode() {}
+ virtual ~cmGeneratorExpressionNode() = default;
virtual bool GeneratesContent() const { return true; }
@@ -41,8 +43,8 @@ struct cmGeneratorExpressionNode
static std::string EvaluateDependentExpression(
std::string const& prop, cmLocalGenerator* lg,
cmGeneratorExpressionContext* context, const cmGeneratorTarget* headTarget,
- const cmGeneratorTarget* currentTarget,
- cmGeneratorExpressionDAGChecker* dagChecker);
+ cmGeneratorExpressionDAGChecker* dagChecker,
+ const cmGeneratorTarget* currentTarget);
static const cmGeneratorExpressionNode* GetNode(
const std::string& identifier);
diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx
index c33349a63..d6cc6ab1c 100644
--- a/Source/cmGeneratorExpressionParser.cxx
+++ b/Source/cmGeneratorExpressionParser.cxx
@@ -2,14 +2,16 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGeneratorExpressionParser.h"
-#include "cmGeneratorExpressionEvaluator.h"
+#include <cassert>
+#include <cstddef>
+#include <utility>
-#include <assert.h>
-#include <stddef.h>
+#include "cmAlgorithms.h"
+#include "cmGeneratorExpressionEvaluator.h"
cmGeneratorExpressionParser::cmGeneratorExpressionParser(
- const std::vector<cmGeneratorExpressionToken>& tokens)
- : Tokens(tokens)
+ std::vector<cmGeneratorExpressionToken> tokens)
+ : Tokens(std::move(tokens))
, NestingLevel(0)
{
}
@@ -46,14 +48,14 @@ static void extendResult(
if (!result.empty() &&
(*(result.end() - 1))->GetType() ==
cmGeneratorExpressionEvaluator::Text &&
- (*contents.begin())->GetType() == cmGeneratorExpressionEvaluator::Text) {
+ contents.front()->GetType() == cmGeneratorExpressionEvaluator::Text) {
TextContent* textContent = static_cast<TextContent*>(*(result.end() - 1));
textContent->Extend(
- static_cast<TextContent*>(*contents.begin())->GetLength());
- delete *contents.begin();
- result.insert(result.end(), contents.begin() + 1, contents.end());
+ static_cast<TextContent*>(contents.front())->GetLength());
+ delete contents.front();
+ cmAppend(result, contents.begin() + 1, contents.end());
} else {
- result.insert(result.end(), contents.begin(), contents.end());
+ cmAppend(result, contents);
}
}
@@ -64,8 +66,7 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
unsigned int nestedLevel = this->NestingLevel;
++this->NestingLevel;
- std::vector<cmGeneratorExpressionToken>::const_iterator startToken =
- this->it - 1;
+ auto startToken = this->it - 1;
std::vector<cmGeneratorExpressionEvaluator*> identifier;
while (this->it->TokenType != cmGeneratorExpressionToken::EndExpression &&
@@ -86,18 +87,18 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
if (this->it != this->Tokens.end() &&
this->it->TokenType == cmGeneratorExpressionToken::EndExpression) {
- GeneratorExpressionContent* content =
- new GeneratorExpressionContent(startToken->Content, this->it->Content -
- startToken->Content + this->it->Length);
+ GeneratorExpressionContent* content = new GeneratorExpressionContent(
+ startToken->Content,
+ this->it->Content - startToken->Content + this->it->Length);
assert(this->it != this->Tokens.end());
++this->it;
--this->NestingLevel;
- content->SetIdentifier(identifier);
+ content->SetIdentifier(std::move(identifier));
result.push_back(content);
return;
}
- std::vector<std::vector<cmGeneratorExpressionEvaluator*> > parameters;
+ std::vector<std::vector<cmGeneratorExpressionEvaluator*>> parameters;
std::vector<std::vector<cmGeneratorExpressionToken>::const_iterator>
commaTokens;
std::vector<cmGeneratorExpressionToken>::const_iterator colonToken;
@@ -172,13 +173,9 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
if (!parameters.empty()) {
extendText(result, colonToken);
- typedef std::vector<cmGeneratorExpressionEvaluator*> EvaluatorVector;
- typedef std::vector<cmGeneratorExpressionToken> TokenVector;
- std::vector<EvaluatorVector>::const_iterator pit = parameters.begin();
- const std::vector<EvaluatorVector>::const_iterator pend =
- parameters.end();
- std::vector<TokenVector::const_iterator>::const_iterator commaIt =
- commaTokens.begin();
+ auto pit = parameters.begin();
+ const auto pend = parameters.end();
+ auto commaIt = commaTokens.begin();
assert(parameters.size() > commaTokens.size());
for (; pit != pend; ++pit, ++commaIt) {
if (!pit->empty() && !emptyParamTermination) {
@@ -198,8 +195,8 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
((this->it - 1)->Content - startToken->Content) + (this->it - 1)->Length;
GeneratorExpressionContent* content =
new GeneratorExpressionContent(startToken->Content, contentLength);
- content->SetIdentifier(identifier);
- content->SetParameters(parameters);
+ content->SetIdentifier(std::move(identifier));
+ content->SetParameters(std::move(parameters));
result.push_back(content);
}
diff --git a/Source/cmGeneratorExpressionParser.h b/Source/cmGeneratorExpressionParser.h
index 633381c8a..e663496da 100644
--- a/Source/cmGeneratorExpressionParser.h
+++ b/Source/cmGeneratorExpressionParser.h
@@ -13,8 +13,7 @@ struct cmGeneratorExpressionEvaluator;
struct cmGeneratorExpressionParser
{
- cmGeneratorExpressionParser(
- const std::vector<cmGeneratorExpressionToken>& tokens);
+ cmGeneratorExpressionParser(std::vector<cmGeneratorExpressionToken> tokens);
void Parse(std::vector<cmGeneratorExpressionEvaluator*>& result);
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index c9924f670..171c3ed39 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -2,37 +2,50 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGeneratorTarget.h"
-#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
-#include <errno.h>
+#include <cassert>
+#include <cerrno>
+#include <cstddef>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <iterator>
-#include <queue>
+#include <memory>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <unordered_set>
+#include <utility>
+
+#include <cm/string_view>
+
+#include <queue>
+
+#include "cmsys/RegularExpression.hxx"
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
#include "cmCustomCommandLines.h"
+#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
+#include "cmGeneratorExpressionContext.h"
#include "cmGeneratorExpressionDAGChecker.h"
+#include "cmGeneratorExpressionNode.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPropertyMap.h"
+#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmSourceFileLocation.h"
+#include "cmSourceFileLocationKind.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetLinkLibraryType.h"
#include "cmTargetPropertyComputer.h"
-#include "cm_auto_ptr.hxx"
-#include "cm_unordered_set.hxx"
#include "cmake.h"
class cmMessenger;
@@ -46,8 +59,9 @@ const char* cmTargetPropertyComputer::GetSources<cmGeneratorTarget>(
}
template <>
-const char* cmTargetPropertyComputer::ComputeLocationForBuild<
- cmGeneratorTarget>(cmGeneratorTarget const* tgt)
+const char*
+cmTargetPropertyComputer::ComputeLocationForBuild<cmGeneratorTarget>(
+ cmGeneratorTarget const* tgt)
{
return tgt->GetLocation("");
}
@@ -61,35 +75,177 @@ const char* cmTargetPropertyComputer::ComputeLocation<cmGeneratorTarget>(
class cmGeneratorTarget::TargetPropertyEntry
{
+protected:
static cmLinkImplItem NoLinkImplItem;
public:
- TargetPropertyEntry(CM_AUTO_PTR<cmCompiledGeneratorExpression> cge,
- cmLinkImplItem const& item = NoLinkImplItem)
- : ge(cge)
- , LinkImplItem(item)
+ TargetPropertyEntry(cmLinkImplItem const& item)
+ : LinkImplItem(item)
{
}
- const CM_AUTO_PTR<cmCompiledGeneratorExpression> ge;
+ virtual ~TargetPropertyEntry() = default;
+
+ virtual const std::string& Evaluate(
+ cmLocalGenerator* lg, const std::string& config,
+ cmGeneratorTarget const* headTarget,
+ cmGeneratorExpressionDAGChecker* dagChecker,
+ std::string const& language) const = 0;
+
+ virtual cmListFileBacktrace GetBacktrace() const = 0;
+ virtual std::string const& GetInput() const = 0;
+ virtual bool GetHadContextSensitiveCondition() const { return false; }
+
cmLinkImplItem const& LinkImplItem;
};
cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem;
+class TargetPropertyEntryGenex : public cmGeneratorTarget::TargetPropertyEntry
+{
+public:
+ TargetPropertyEntryGenex(std::unique_ptr<cmCompiledGeneratorExpression> cge,
+ cmLinkImplItem const& item = NoLinkImplItem)
+ : cmGeneratorTarget::TargetPropertyEntry(item)
+ , ge(std::move(cge))
+ {
+ }
+
+ const std::string& Evaluate(cmLocalGenerator* lg, const std::string& config,
+ cmGeneratorTarget const* headTarget,
+ cmGeneratorExpressionDAGChecker* dagChecker,
+ std::string const& language) const override
+ {
+ return this->ge->Evaluate(lg, config, headTarget, dagChecker, nullptr,
+ language);
+ }
+
+ cmListFileBacktrace GetBacktrace() const override
+ {
+ return this->ge->GetBacktrace();
+ }
+
+ std::string const& GetInput() const override { return this->ge->GetInput(); }
+
+ bool GetHadContextSensitiveCondition() const override
+ {
+ return this->ge->GetHadContextSensitiveCondition();
+ }
+
+private:
+ const std::unique_ptr<cmCompiledGeneratorExpression> ge;
+};
+
+class TargetPropertyEntryString : public cmGeneratorTarget::TargetPropertyEntry
+{
+public:
+ TargetPropertyEntryString(std::string propertyValue,
+ cmListFileBacktrace backtrace,
+ cmLinkImplItem const& item = NoLinkImplItem)
+ : cmGeneratorTarget::TargetPropertyEntry(item)
+ , PropertyValue(std::move(propertyValue))
+ , Backtrace(std::move(backtrace))
+ {
+ }
+
+ const std::string& Evaluate(cmLocalGenerator*, const std::string&,
+ cmGeneratorTarget const*,
+ cmGeneratorExpressionDAGChecker*,
+ std::string const&) const override
+ {
+ return this->PropertyValue;
+ }
+
+ cmListFileBacktrace GetBacktrace() const override { return this->Backtrace; }
+ std::string const& GetInput() const override { return this->PropertyValue; }
+
+private:
+ std::string PropertyValue;
+ cmListFileBacktrace Backtrace;
+};
+
+cmGeneratorTarget::TargetPropertyEntry* CreateTargetPropertyEntry(
+ const std::string& propertyValue,
+ cmListFileBacktrace backtrace = cmListFileBacktrace(),
+ bool evaluateForBuildsystem = false)
+{
+ if (cmGeneratorExpression::Find(propertyValue) != std::string::npos) {
+ cmGeneratorExpression ge(std::move(backtrace));
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
+ ge.Parse(propertyValue);
+ cge->SetEvaluateForBuildsystem(evaluateForBuildsystem);
+ return new TargetPropertyEntryGenex(std::move(cge));
+ }
+
+ return new TargetPropertyEntryString(propertyValue, std::move(backtrace));
+}
+
void CreatePropertyGeneratorExpressions(
cmStringRange entries, cmBacktraceRange backtraces,
std::vector<cmGeneratorTarget::TargetPropertyEntry*>& items,
bool evaluateForBuildsystem = false)
{
- std::vector<cmListFileBacktrace>::const_iterator btIt = backtraces.begin();
- for (std::vector<std::string>::const_iterator it = entries.begin();
- it != entries.end(); ++it, ++btIt) {
- cmGeneratorExpression ge(*btIt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*it);
- cge->SetEvaluateForBuildsystem(evaluateForBuildsystem);
- items.push_back(new cmGeneratorTarget::TargetPropertyEntry(cge));
+ auto btIt = backtraces.begin();
+ for (auto it = entries.begin(); it != entries.end(); ++it, ++btIt) {
+ items.push_back(
+ CreateTargetPropertyEntry(*it, *btIt, evaluateForBuildsystem));
}
}
+namespace {
+// Represent a target property entry after evaluating generator expressions
+// and splitting up lists.
+struct EvaluatedTargetPropertyEntry
+{
+ EvaluatedTargetPropertyEntry(cmLinkImplItem const& item,
+ cmListFileBacktrace bt)
+ : LinkImplItem(item)
+ , Backtrace(std::move(bt))
+ {
+ }
+
+ // Move-only.
+ EvaluatedTargetPropertyEntry(EvaluatedTargetPropertyEntry&&) = default;
+ EvaluatedTargetPropertyEntry(EvaluatedTargetPropertyEntry const&) = delete;
+ EvaluatedTargetPropertyEntry& operator=(EvaluatedTargetPropertyEntry&&) =
+ delete;
+ EvaluatedTargetPropertyEntry& operator=(
+ EvaluatedTargetPropertyEntry const&) = delete;
+
+ cmLinkImplItem const& LinkImplItem;
+ cmListFileBacktrace Backtrace;
+ std::vector<std::string> Values;
+ bool ContextDependent = false;
+};
+
+EvaluatedTargetPropertyEntry EvaluateTargetPropertyEntry(
+ cmGeneratorTarget const* thisTarget, std::string const& config,
+ std::string const& lang, cmGeneratorExpressionDAGChecker* dagChecker,
+ cmGeneratorTarget::TargetPropertyEntry* entry)
+{
+ EvaluatedTargetPropertyEntry ee(entry->LinkImplItem, entry->GetBacktrace());
+ cmExpandList(entry->Evaluate(thisTarget->GetLocalGenerator(), config,
+ thisTarget, dagChecker, lang),
+ ee.Values);
+ if (entry->GetHadContextSensitiveCondition()) {
+ ee.ContextDependent = true;
+ }
+ return ee;
+}
+
+std::vector<EvaluatedTargetPropertyEntry> EvaluateTargetPropertyEntries(
+ cmGeneratorTarget const* thisTarget, std::string const& config,
+ std::string const& lang, cmGeneratorExpressionDAGChecker* dagChecker,
+ std::vector<cmGeneratorTarget::TargetPropertyEntry*> const& in)
+{
+ std::vector<EvaluatedTargetPropertyEntry> out;
+ out.reserve(in.size());
+ for (cmGeneratorTarget::TargetPropertyEntry* entry : in) {
+ out.emplace_back(EvaluateTargetPropertyEntry(thisTarget, config, lang,
+ dagChecker, entry));
+ }
+ return out;
+}
+}
+
cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
: Target(t)
, FortranModuleDirectoryCreated(false)
@@ -100,6 +256,9 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
, DebugCompileOptionsDone(false)
, DebugCompileFeaturesDone(false)
, DebugCompileDefinitionsDone(false)
+ , DebugLinkOptionsDone(false)
+ , DebugLinkDirectoriesDone(false)
+ , DebugPrecompileHeadersDone(false)
, DebugSourcesDone(false)
, LinkImplementationLanguageIsContextDependent(true)
, UtilityItemsDone(false)
@@ -126,15 +285,23 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
t->GetCompileDefinitionsBacktraces(),
this->CompileDefinitionsEntries);
+ CreatePropertyGeneratorExpressions(t->GetLinkOptionsEntries(),
+ t->GetLinkOptionsBacktraces(),
+ this->LinkOptionsEntries);
+
+ CreatePropertyGeneratorExpressions(t->GetLinkDirectoriesEntries(),
+ t->GetLinkDirectoriesBacktraces(),
+ this->LinkDirectoriesEntries);
+
+ CreatePropertyGeneratorExpressions(t->GetPrecompileHeadersEntries(),
+ t->GetPrecompileHeadersBacktraces(),
+ this->PrecompileHeadersEntries);
+
CreatePropertyGeneratorExpressions(t->GetSourceEntries(),
t->GetSourceBacktraces(),
this->SourceEntries, true);
- this->DLLPlatform =
- (this->Makefile->IsOn("WIN32") || this->Makefile->IsOn("CYGWIN") ||
- this->Makefile->IsOn("MINGW"));
-
- this->PolicyMap = t->PolicyMap;
+ this->PolicyMap = t->GetPolicyMap();
}
cmGeneratorTarget::~cmGeneratorTarget()
@@ -143,6 +310,9 @@ cmGeneratorTarget::~cmGeneratorTarget()
cmDeleteAll(this->CompileOptionsEntries);
cmDeleteAll(this->CompileFeaturesEntries);
cmDeleteAll(this->CompileDefinitionsEntries);
+ cmDeleteAll(this->LinkOptionsEntries);
+ cmDeleteAll(this->LinkDirectoriesEntries);
+ cmDeleteAll(this->PrecompileHeadersEntries);
cmDeleteAll(this->SourceEntries);
cmDeleteAll(this->LinkInformation);
}
@@ -150,11 +320,8 @@ cmGeneratorTarget::~cmGeneratorTarget()
const char* cmGeneratorTarget::GetSourcesProperty() const
{
std::vector<std::string> values;
- for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
- it = this->SourceEntries.begin(),
- end = this->SourceEntries.end();
- it != end; ++it) {
- values.push_back((*it)->ge->GetInput());
+ for (TargetPropertyEntry* se : this->SourceEntries) {
+ values.push_back(se->GetInput());
}
static std::string value;
value.clear();
@@ -191,7 +358,7 @@ std::string cmGeneratorTarget::GetExportName() const
std::ostringstream e;
e << "EXPORT_NAME property \"" << exportName << "\" for \""
<< this->GetName() << "\": is not valid.";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return "";
}
return exportName;
@@ -204,18 +371,27 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const
if (!cmTargetPropertyComputer::PassesWhitelist(
this->GetType(), prop, this->Makefile->GetMessenger(),
this->GetBacktrace())) {
- return CM_NULLPTR;
+ return nullptr;
}
if (const char* result = cmTargetPropertyComputer::GetProperty(
this, prop, this->Makefile->GetMessenger(), this->GetBacktrace())) {
return result;
}
if (cmSystemTools::GetFatalErrorOccured()) {
- return CM_NULLPTR;
+ return nullptr;
}
return this->Target->GetProperty(prop);
}
+const char* cmGeneratorTarget::GetSafeProperty(const std::string& prop) const
+{
+ const char* ret = this->GetProperty(prop);
+ if (!ret) {
+ return "";
+ }
+ return ret;
+}
+
const char* cmGeneratorTarget::GetOutputTargetType(
cmStateEnums::ArtifactType artifact) const
{
@@ -242,13 +418,16 @@ const char* cmGeneratorTarget::GetOutputTargetType(
case cmStateEnums::MODULE_LIBRARY:
switch (artifact) {
case cmStateEnums::RuntimeBinaryArtifact:
- // Module import libraries are treated as archive targets.
+ // Module libraries are always treated as library targets.
return "LIBRARY";
case cmStateEnums::ImportLibraryArtifact:
- // Module libraries are always treated as library targets.
+ // Module import libraries are treated as archive targets.
return "ARCHIVE";
}
break;
+ case cmStateEnums::OBJECT_LIBRARY:
+ // Object libraries are always treated as object targets.
+ return "OBJECT";
case cmStateEnums::EXECUTABLE:
switch (artifact) {
case cmStateEnums::RuntimeBinaryArtifact:
@@ -270,8 +449,7 @@ std::string cmGeneratorTarget::GetOutputName(
{
// Lookup/compute/cache the output name for this configuration.
OutputNameKey key(config, artifact);
- cmGeneratorTarget::OutputNameMapType::iterator i =
- this->OutputNameMap.find(key);
+ auto i = this->OutputNameMap.find(key);
if (i == this->OutputNameMap.end()) {
// Add empty name in map to detect potential recursion.
OutputNameMapType::value_type entry(key, "");
@@ -296,12 +474,11 @@ std::string cmGeneratorTarget::GetOutputName(
props.push_back(configUpper + "_OUTPUT_NAME");
}
// OUTPUT_NAME
- props.push_back("OUTPUT_NAME");
+ props.emplace_back("OUTPUT_NAME");
std::string outName;
- for (std::vector<std::string>::const_iterator it = props.begin();
- it != props.end(); ++it) {
- if (const char* outNameProp = this->GetProperty(*it)) {
+ for (std::string const& p : props) {
+ if (const char* outNameProp = this->GetProperty(p)) {
outName = outNameProp;
break;
}
@@ -312,35 +489,186 @@ std::string cmGeneratorTarget::GetOutputName(
}
// Now evaluate genex and update the previously-prepared map entry.
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(outName);
- i->second = cge->Evaluate(this->LocalGenerator, config);
+ i->second =
+ cmGeneratorExpression::Evaluate(outName, this->LocalGenerator, config);
} else if (i->second.empty()) {
// An empty map entry indicates we have been called recursively
// from the above block.
this->LocalGenerator->GetCMakeInstance()->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"Target '" + this->GetName() + "' OUTPUT_NAME depends on itself.",
this->GetBacktrace());
}
return i->second;
}
-void cmGeneratorTarget::AddSourceCommon(const std::string& src)
+std::string cmGeneratorTarget::GetFilePrefix(
+ const std::string& config, cmStateEnums::ArtifactType artifact) const
+{
+ if (this->IsImported()) {
+ const char* prefix = this->GetFilePrefixInternal(config, artifact);
+
+ return prefix ? prefix : std::string();
+ }
+
+ std::string prefix;
+ std::string suffix;
+ std::string base;
+ this->GetFullNameInternal(config, artifact, prefix, base, suffix);
+ return prefix;
+}
+std::string cmGeneratorTarget::GetFileSuffix(
+ const std::string& config, cmStateEnums::ArtifactType artifact) const
+{
+ if (this->IsImported()) {
+ const char* suffix = this->GetFileSuffixInternal(config, artifact);
+
+ return suffix ? suffix : std::string();
+ }
+
+ std::string prefix;
+ std::string suffix;
+ std::string base;
+ this->GetFullNameInternal(config, artifact, prefix, base, suffix);
+ return suffix;
+}
+
+std::string cmGeneratorTarget::GetFilePostfix(const std::string& config) const
+{
+ const char* postfix = nullptr;
+ if (!config.empty()) {
+ std::string configProp =
+ cmStrCat(cmSystemTools::UpperCase(config), "_POSTFIX");
+ postfix = this->GetProperty(configProp);
+ // Mac application bundles and frameworks have no postfix.
+ if (!this->IsImported() && postfix &&
+ (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) {
+ postfix = nullptr;
+ }
+ }
+ return postfix ? postfix : std::string();
+}
+
+const char* cmGeneratorTarget::GetFilePrefixInternal(
+ std::string const& config, cmStateEnums::ArtifactType artifact,
+ const std::string& language) const
+{
+ // no prefix for non-main target types.
+ if (this->GetType() != cmStateEnums::STATIC_LIBRARY &&
+ this->GetType() != cmStateEnums::SHARED_LIBRARY &&
+ this->GetType() != cmStateEnums::MODULE_LIBRARY &&
+ this->GetType() != cmStateEnums::EXECUTABLE) {
+ return nullptr;
+ }
+
+ const bool isImportedLibraryArtifact =
+ (artifact == cmStateEnums::ImportLibraryArtifact);
+
+ // Return an empty prefix for the import library if this platform
+ // does not support import libraries.
+ if (isImportedLibraryArtifact && !this->NeedImportLibraryName(config)) {
+ return nullptr;
+ }
+
+ // The implib option is only allowed for shared libraries, module
+ // libraries, and executables.
+ if (this->GetType() != cmStateEnums::SHARED_LIBRARY &&
+ this->GetType() != cmStateEnums::MODULE_LIBRARY &&
+ this->GetType() != cmStateEnums::EXECUTABLE) {
+ artifact = cmStateEnums::RuntimeBinaryArtifact;
+ }
+
+ // Compute prefix value.
+ const char* targetPrefix =
+ (isImportedLibraryArtifact ? this->GetProperty("IMPORT_PREFIX")
+ : this->GetProperty("PREFIX"));
+
+ if (!targetPrefix) {
+ const char* prefixVar = this->Target->GetPrefixVariableInternal(artifact);
+ if (!language.empty() && prefixVar && *prefixVar) {
+ std::string langPrefix = prefixVar + std::string("_") + language;
+ targetPrefix = this->Makefile->GetDefinition(langPrefix);
+ }
+
+ // if there is no prefix on the target nor specific language
+ // use the cmake definition.
+ if (!targetPrefix && prefixVar) {
+ targetPrefix = this->Makefile->GetDefinition(prefixVar);
+ }
+ }
+
+ return targetPrefix;
+}
+const char* cmGeneratorTarget::GetFileSuffixInternal(
+ std::string const& config, cmStateEnums::ArtifactType artifact,
+ const std::string& language) const
+{
+ // no suffix for non-main target types.
+ if (this->GetType() != cmStateEnums::STATIC_LIBRARY &&
+ this->GetType() != cmStateEnums::SHARED_LIBRARY &&
+ this->GetType() != cmStateEnums::MODULE_LIBRARY &&
+ this->GetType() != cmStateEnums::EXECUTABLE) {
+ return nullptr;
+ }
+
+ const bool isImportedLibraryArtifact =
+ (artifact == cmStateEnums::ImportLibraryArtifact);
+
+ // Return an empty suffix for the import library if this platform
+ // does not support import libraries.
+ if (isImportedLibraryArtifact && !this->NeedImportLibraryName(config)) {
+ return nullptr;
+ }
+
+ // The implib option is only allowed for shared libraries, module
+ // libraries, and executables.
+ if (this->GetType() != cmStateEnums::SHARED_LIBRARY &&
+ this->GetType() != cmStateEnums::MODULE_LIBRARY &&
+ this->GetType() != cmStateEnums::EXECUTABLE) {
+ artifact = cmStateEnums::RuntimeBinaryArtifact;
+ }
+
+ // Compute suffix value.
+ const char* targetSuffix =
+ (isImportedLibraryArtifact ? this->GetProperty("IMPORT_SUFFIX")
+ : this->GetProperty("SUFFIX"));
+
+ if (!targetSuffix) {
+ const char* suffixVar = this->Target->GetSuffixVariableInternal(artifact);
+ if (!language.empty() && suffixVar && *suffixVar) {
+ std::string langSuffix = suffixVar + std::string("_") + language;
+ targetSuffix = this->Makefile->GetDefinition(langSuffix);
+ }
+
+ // if there is no suffix on the target nor specific language
+ // use the cmake definition.
+ if (!targetSuffix && suffixVar) {
+ targetSuffix = this->Makefile->GetDefinition(suffixVar);
+ }
+ }
+
+ return targetSuffix;
+}
+
+void cmGeneratorTarget::ClearSourcesCache()
{
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- cmGeneratorExpression ge(lfbt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(src);
- cge->SetEvaluateForBuildsystem(true);
- this->SourceEntries.push_back(new TargetPropertyEntry(cge));
this->KindedSourcesMap.clear();
this->LinkImplementationLanguageIsContextDependent = true;
+ this->Objects.clear();
+}
+
+void cmGeneratorTarget::AddSourceCommon(const std::string& src, bool before)
+{
+ this->SourceEntries.insert(
+ before ? this->SourceEntries.begin() : this->SourceEntries.end(),
+ CreateTargetPropertyEntry(src, this->Makefile->GetBacktrace(), true));
+ this->ClearSourcesCache();
}
-void cmGeneratorTarget::AddSource(const std::string& src)
+void cmGeneratorTarget::AddSource(const std::string& src, bool before)
{
- this->Target->AddSource(src);
- this->AddSourceCommon(src);
+ this->Target->AddSource(src, before);
+ this->AddSourceCommon(src, before);
}
void cmGeneratorTarget::AddTracedSources(std::vector<std::string> const& srcs)
@@ -355,40 +683,36 @@ void cmGeneratorTarget::AddIncludeDirectory(const std::string& src,
bool before)
{
this->Target->InsertInclude(src, this->Makefile->GetBacktrace(), before);
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- cmGeneratorExpression ge(lfbt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(src);
- cge->SetEvaluateForBuildsystem(true);
- // Insert before begin/end
- std::vector<TargetPropertyEntry*>::iterator pos = before
- ? this->IncludeDirectoriesEntries.begin()
- : this->IncludeDirectoriesEntries.end();
- this->IncludeDirectoriesEntries.insert(pos, new TargetPropertyEntry(cge));
+ this->IncludeDirectoriesEntries.insert(
+ before ? this->IncludeDirectoriesEntries.begin()
+ : this->IncludeDirectoriesEntries.end(),
+ CreateTargetPropertyEntry(src, this->Makefile->GetBacktrace(), true));
}
std::vector<cmSourceFile*> const* cmGeneratorTarget::GetSourceDepends(
cmSourceFile const* sf) const
{
- SourceEntriesType::const_iterator i = this->SourceDepends.find(sf);
+ auto i = this->SourceDepends.find(sf);
if (i != this->SourceDepends.end()) {
return &i->second.Depends;
}
- return CM_NULLPTR;
+ return nullptr;
}
-static void handleSystemIncludesDep(
- cmLocalGenerator* lg, cmGeneratorTarget const* depTgt,
- const std::string& config, cmGeneratorTarget const* headTarget,
- cmGeneratorExpressionDAGChecker* dagChecker,
- std::vector<std::string>& result, bool excludeImported)
+namespace {
+void handleSystemIncludesDep(cmLocalGenerator* lg,
+ cmGeneratorTarget const* depTgt,
+ const std::string& config,
+ cmGeneratorTarget const* headTarget,
+ cmGeneratorExpressionDAGChecker* dagChecker,
+ std::vector<std::string>& result,
+ bool excludeImported, std::string const& language)
{
if (const char* dirs =
depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) {
- cmGeneratorExpression ge;
- cmSystemTools::ExpandListArgument(
- ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, depTgt,
- dagChecker),
- result);
+ cmExpandList(cmGeneratorExpression::Evaluate(dirs, lg, config, headTarget,
+ dagChecker, depTgt, language),
+ result);
}
if (!depTgt->IsImported() || excludeImported) {
return;
@@ -396,25 +720,23 @@ static void handleSystemIncludesDep(
if (const char* dirs =
depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) {
- cmGeneratorExpression ge;
- cmSystemTools::ExpandListArgument(
- ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, depTgt,
- dagChecker),
- result);
+ cmExpandList(cmGeneratorExpression::Evaluate(dirs, lg, config, headTarget,
+ dagChecker, depTgt, language),
+ result);
}
}
+}
/* clang-format off */
#define IMPLEMENT_VISIT(KIND) \
- { \
+ do { \
KindedSources const& kinded = this->GetKindedSources(config); \
- for (std::vector<SourceAndKind>::const_iterator \
- si = kinded.Sources.begin(); si != kinded.Sources.end(); ++si) { \
- if (si->Kind == KIND) { \
- data.push_back(si->Source); \
+ for (SourceAndKind const& s : kinded.Sources) { \
+ if (s.Kind == KIND) { \
+ data.push_back(s.Source.Value); \
} \
} \
- }
+ } while (false)
/* clang-format on */
void cmGeneratorTarget::GetObjectSources(
@@ -426,9 +748,8 @@ void cmGeneratorTarget::GetObjectSources(
return;
}
- for (std::vector<cmSourceFile const*>::const_iterator it = data.begin();
- it != data.end(); ++it) {
- this->Objects[*it];
+ for (cmSourceFile const* it : data) {
+ this->Objects[it];
}
this->LocalGenerator->ComputeObjectFilenames(this->Objects, this);
@@ -440,15 +761,11 @@ void cmGeneratorTarget::ComputeObjectMapping()
return;
}
- std::vector<std::string> configs;
- this->Makefile->GetConfigurations(configs);
- if (configs.empty()) {
- configs.push_back("");
- }
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
+ std::vector<std::string> const& configs =
+ this->Makefile->GetGeneratorConfigs();
+ for (std::string const& c : configs) {
std::vector<cmSourceFile const*> sourceFiles;
- this->GetObjectSources(sourceFiles, *ci);
+ this->GetObjectSources(sourceFiles, c);
}
}
@@ -456,9 +773,8 @@ const char* cmGeneratorTarget::GetFeature(const std::string& feature,
const std::string& config) const
{
if (!config.empty()) {
- std::string featureConfig = feature;
- featureConfig += "_";
- featureConfig += cmSystemTools::UpperCase(config);
+ std::string featureConfig =
+ cmStrCat(feature, '_', cmSystemTools::UpperCase(config));
if (const char* value = this->GetProperty(featureConfig)) {
return value;
}
@@ -469,11 +785,30 @@ const char* cmGeneratorTarget::GetFeature(const std::string& feature,
return this->LocalGenerator->GetFeature(feature, config);
}
+const char* cmGeneratorTarget::GetLinkPIEProperty(
+ const std::string& config) const
+{
+ static std::string PICValue;
+
+ PICValue = this->GetLinkInterfaceDependentStringAsBoolProperty(
+ "POSITION_INDEPENDENT_CODE", config);
+
+ if (PICValue == "(unset)") {
+ // POSITION_INDEPENDENT_CODE is not set
+ return nullptr;
+ }
+
+ auto status = this->GetPolicyStatusCMP0083();
+ return (status != cmPolicies::WARN && status != cmPolicies::OLD)
+ ? PICValue.c_str()
+ : nullptr;
+}
+
bool cmGeneratorTarget::IsIPOEnabled(std::string const& lang,
std::string const& config) const
{
const char* feature = "INTERPROCEDURAL_OPTIMIZATION";
- const bool result = cmSystemTools::IsOn(this->GetFeature(feature, config));
+ const bool result = cmIsOn(this->GetFeature(feature, config));
if (!result) {
// 'INTERPROCEDURAL_OPTIMIZATION' is off, no need to check policies
@@ -503,7 +838,7 @@ bool cmGeneratorTarget::IsIPOEnabled(std::string const& lang,
w << "INTERPROCEDURAL_OPTIMIZATION property will be ignored for target "
<< "'" << this->GetName() << "'.";
this->LocalGenerator->GetCMakeInstance()->IssueMessage(
- cmake::AUTHOR_WARNING, w.str(), this->GetBacktrace());
+ MessageType::AUTHOR_WARNING, w.str(), this->GetBacktrace());
this->PolicyReportedCMP0069 = true;
}
@@ -511,7 +846,7 @@ bool cmGeneratorTarget::IsIPOEnabled(std::string const& lang,
}
// Note: check consistency with messages from CheckIPOSupported
- const char* message = CM_NULLPTR;
+ const char* message = nullptr;
if (!this->Makefile->IsOn("_CMAKE_" + lang + "_IPO_SUPPORTED_BY_CMAKE")) {
message = "CMake doesn't support IPO for current compiler";
} else if (!this->Makefile->IsOn("_CMAKE_" + lang +
@@ -534,7 +869,7 @@ bool cmGeneratorTarget::IsIPOEnabled(std::string const& lang,
this->PolicyReportedCMP0069 = true;
this->LocalGenerator->GetCMakeInstance()->IssueMessage(
- cmake::FATAL_ERROR, message, this->GetBacktrace());
+ MessageType::FATAL_ERROR, message, this->GetBacktrace());
return false;
}
@@ -553,7 +888,7 @@ const char* cmGeneratorTarget::GetCustomObjectExtension() const
extension = ".ptx";
return extension.c_str();
}
- return CM_NULLPTR;
+ return nullptr;
}
void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf)
@@ -564,8 +899,7 @@ void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf)
bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const
{
const_cast<cmGeneratorTarget*>(this)->ComputeObjectMapping();
- std::set<cmSourceFile const*>::const_iterator it =
- this->ExplicitObjectName.find(file);
+ auto it = this->ExplicitObjectName.find(file);
return it != this->ExplicitObjectName.end();
}
@@ -648,12 +982,14 @@ std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const
{
if (!this->UtilityItemsDone) {
this->UtilityItemsDone = true;
- std::set<std::string> const& utilities = this->GetUtilities();
- for (std::set<std::string>::const_iterator i = utilities.begin();
- i != utilities.end(); ++i) {
- cmGeneratorTarget* gt =
- this->LocalGenerator->FindGeneratorTargetToUse(*i);
- this->UtilityItems.insert(cmLinkItem(*i, gt));
+ std::set<BT<std::string>> const& utilities = this->GetUtilities();
+ for (BT<std::string> const& i : utilities) {
+ if (cmGeneratorTarget* gt =
+ this->LocalGenerator->FindGeneratorTargetToUse(i.Value)) {
+ this->UtilityItems.insert(cmLinkItem(gt, i.Backtrace));
+ } else {
+ this->UtilityItems.insert(cmLinkItem(i.Value, i.Backtrace));
+ }
}
}
return this->UtilityItems;
@@ -735,7 +1071,8 @@ const char* cmGeneratorTarget::GetLocationForBuild() const
}
bool cmGeneratorTarget::IsSystemIncludeDirectory(
- const std::string& dir, const std::string& config) const
+ const std::string& dir, const std::string& config,
+ const std::string& language) const
{
assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY);
std::string config_upper;
@@ -743,35 +1080,28 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(
config_upper = cmSystemTools::UpperCase(config);
}
- typedef std::map<std::string, std::vector<std::string> > IncludeCacheType;
- IncludeCacheType::const_iterator iter =
- this->SystemIncludesCache.find(config_upper);
+ using IncludeCacheType = std::map<std::string, std::vector<std::string>>;
+ auto iter = this->SystemIncludesCache.find(config_upper);
if (iter == this->SystemIncludesCache.end()) {
cmGeneratorExpressionDAGChecker dagChecker(
- this->GetName(), "SYSTEM_INCLUDE_DIRECTORIES", CM_NULLPTR, CM_NULLPTR);
+ this, "SYSTEM_INCLUDE_DIRECTORIES", nullptr, nullptr);
bool excludeImported = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED");
std::vector<std::string> result;
- for (std::set<std::string>::const_iterator it =
- this->Target->GetSystemIncludeDirectories().begin();
- it != this->Target->GetSystemIncludeDirectories().end(); ++it) {
- cmGeneratorExpression ge;
- cmSystemTools::ExpandListArgument(
- ge.Parse(*it)->Evaluate(this->LocalGenerator, config, false, this,
- &dagChecker),
- result);
+ for (std::string const& it : this->Target->GetSystemIncludeDirectories()) {
+ cmExpandList(cmGeneratorExpression::Evaluate(it, this->LocalGenerator,
+ config, this, &dagChecker,
+ nullptr, language),
+ result);
}
std::vector<cmGeneratorTarget const*> const& deps =
this->GetLinkImplementationClosure(config);
- for (std::vector<cmGeneratorTarget const *>::const_iterator
- li = deps.begin(),
- le = deps.end();
- li != le; ++li) {
- handleSystemIncludesDep(this->LocalGenerator, *li, config, this,
- &dagChecker, result, excludeImported);
+ for (cmGeneratorTarget const* dep : deps) {
+ handleSystemIncludesDep(this->LocalGenerator, dep, config, this,
+ &dagChecker, result, excludeImported, language);
}
std::for_each(result.begin(), result.end(),
@@ -791,95 +1121,235 @@ bool cmGeneratorTarget::GetPropertyAsBool(const std::string& prop) const
return this->Target->GetPropertyAsBool(prop);
}
-static void AddInterfaceEntries(
- cmGeneratorTarget const* thisTarget, std::string const& config,
- std::string const& prop,
- std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries)
+bool cmGeneratorTarget::MaybeHaveInterfaceProperty(
+ std::string const& prop, cmGeneratorExpressionContext* context) const
+{
+ std::string const key = prop + '@' + context->Config;
+ auto i = this->MaybeInterfacePropertyExists.find(key);
+ if (i == this->MaybeInterfacePropertyExists.end()) {
+ // Insert an entry now in case there is a cycle.
+ i = this->MaybeInterfacePropertyExists.emplace(key, false).first;
+ bool& maybeInterfaceProp = i->second;
+
+ // If this target itself has a non-empty property value, we are done.
+ const char* p = this->GetProperty(prop);
+ maybeInterfaceProp = p && *p;
+
+ // Otherwise, recurse to interface dependencies.
+ if (!maybeInterfaceProp) {
+ cmGeneratorTarget const* headTarget =
+ context->HeadTarget ? context->HeadTarget : this;
+ if (cmLinkInterfaceLibraries const* iface =
+ this->GetLinkInterfaceLibraries(context->Config, headTarget,
+ true)) {
+ if (iface->HadHeadSensitiveCondition) {
+ // With a different head target we may get to a library with
+ // this interface property.
+ maybeInterfaceProp = true;
+ } else {
+ // The transitive interface libraries do not depend on the
+ // head target, so we can follow them.
+ for (cmLinkItem const& lib : iface->Libraries) {
+ if (lib.Target &&
+ lib.Target->MaybeHaveInterfaceProperty(prop, context)) {
+ maybeInterfaceProp = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ return i->second;
+}
+
+std::string cmGeneratorTarget::EvaluateInterfaceProperty(
+ std::string const& prop, cmGeneratorExpressionContext* context,
+ cmGeneratorExpressionDAGChecker* dagCheckerParent) const
+{
+ std::string result;
+
+ // If the property does not appear transitively at all, we are done.
+ if (!this->MaybeHaveInterfaceProperty(prop, context)) {
+ return result;
+ }
+
+ // Evaluate $<TARGET_PROPERTY:this,prop> as if it were compiled. This is
+ // a subset of TargetPropertyNode::Evaluate without stringify/parse steps
+ // but sufficient for transitive interface properties.
+ cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, this, prop,
+ nullptr, dagCheckerParent);
+ switch (dagChecker.Check()) {
+ case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
+ dagChecker.ReportError(
+ context, "$<TARGET_PROPERTY:" + this->GetName() + "," + prop + ">");
+ return result;
+ case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE:
+ // No error. We just skip cyclic references.
+ return result;
+ case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
+ // No error. We have already seen this transitive property.
+ return result;
+ case cmGeneratorExpressionDAGChecker::DAG:
+ break;
+ }
+
+ cmGeneratorTarget const* headTarget =
+ context->HeadTarget ? context->HeadTarget : this;
+
+ if (const char* p = this->GetProperty(prop)) {
+ result = cmGeneratorExpressionNode::EvaluateDependentExpression(
+ p, context->LG, context, headTarget, &dagChecker, this);
+ }
+
+ if (cmLinkInterfaceLibraries const* iface =
+ this->GetLinkInterfaceLibraries(context->Config, headTarget, true)) {
+ for (cmLinkItem const& lib : iface->Libraries) {
+ // Broken code can have a target in its own link interface.
+ // Don't follow such link interface entries so as not to create a
+ // self-referencing loop.
+ if (lib.Target && lib.Target != this) {
+ // Pretend $<TARGET_PROPERTY:lib.Target,prop> appeared in the
+ // above property and hand-evaluate it as if it were compiled.
+ // Create a context as cmCompiledGeneratorExpression::Evaluate does.
+ cmGeneratorExpressionContext libContext(
+ context->LG, context->Config, context->Quiet, headTarget, this,
+ context->EvaluateForBuildsystem, context->Backtrace,
+ context->Language);
+ std::string libResult = cmGeneratorExpression::StripEmptyListElements(
+ lib.Target->EvaluateInterfaceProperty(prop, &libContext,
+ &dagChecker));
+ if (!libResult.empty()) {
+ if (result.empty()) {
+ result = std::move(libResult);
+ } else {
+ result.reserve(result.size() + 1 + libResult.size());
+ result += ";";
+ result += libResult;
+ }
+ }
+ context->HadContextSensitiveCondition =
+ context->HadContextSensitiveCondition ||
+ libContext.HadContextSensitiveCondition;
+ context->HadHeadSensitiveCondition =
+ context->HadHeadSensitiveCondition ||
+ libContext.HadHeadSensitiveCondition;
+ }
+ }
+ }
+
+ return result;
+}
+
+namespace {
+void AddInterfaceEntries(cmGeneratorTarget const* headTarget,
+ std::string const& config, std::string const& prop,
+ std::string const& lang,
+ cmGeneratorExpressionDAGChecker* dagChecker,
+ std::vector<EvaluatedTargetPropertyEntry>& entries)
+{
+ if (cmLinkImplementationLibraries const* impl =
+ headTarget->GetLinkImplementationLibraries(config)) {
+ for (cmLinkImplItem const& lib : impl->Libraries) {
+ if (lib.Target) {
+ EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace);
+ // Pretend $<TARGET_PROPERTY:lib.Target,prop> appeared in our
+ // caller's property and hand-evaluate it as if it were compiled.
+ // Create a context as cmCompiledGeneratorExpression::Evaluate does.
+ cmGeneratorExpressionContext context(
+ headTarget->GetLocalGenerator(), config, false, headTarget,
+ headTarget, true, lib.Backtrace, lang);
+ cmExpandList(
+ lib.Target->EvaluateInterfaceProperty(prop, &context, dagChecker),
+ ee.Values);
+ ee.ContextDependent = context.HadContextSensitiveCondition;
+ entries.emplace_back(std::move(ee));
+ }
+ }
+ }
+}
+
+void AddObjectEntries(cmGeneratorTarget const* headTarget,
+ std::string const& config,
+ cmGeneratorExpressionDAGChecker* dagChecker,
+ std::vector<EvaluatedTargetPropertyEntry>& entries)
{
if (cmLinkImplementationLibraries const* impl =
- thisTarget->GetLinkImplementationLibraries(config)) {
- for (std::vector<cmLinkImplItem>::const_iterator
- it = impl->Libraries.begin(),
- end = impl->Libraries.end();
- it != end; ++it) {
- if (it->Target) {
- std::string genex = "$<TARGET_PROPERTY:" + *it + "," + prop + ">";
- cmGeneratorExpression ge(it->Backtrace);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
+ headTarget->GetLinkImplementationLibraries(config)) {
+ for (cmLinkImplItem const& lib : impl->Libraries) {
+ if (lib.Target &&
+ lib.Target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
+ std::string uniqueName =
+ headTarget->GetGlobalGenerator()->IndexGeneratorTargetUniquely(
+ lib.Target);
+ std::string genex = "$<TARGET_OBJECTS:" + std::move(uniqueName) + ">";
+ cmGeneratorExpression ge(lib.Backtrace);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
cge->SetEvaluateForBuildsystem(true);
- entries.push_back(
- new cmGeneratorTarget::TargetPropertyEntry(cge, *it));
+
+ EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace);
+ cmExpandList(cge->Evaluate(headTarget->GetLocalGenerator(), config,
+ headTarget, dagChecker),
+ ee.Values);
+ if (cge->GetHadContextSensitiveCondition()) {
+ ee.ContextDependent = true;
+ }
+ entries.emplace_back(std::move(ee));
}
}
}
}
-static bool processSources(
- cmGeneratorTarget const* tgt,
- const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& srcs, CM_UNORDERED_SET<std::string>& uniqueSrcs,
- cmGeneratorExpressionDAGChecker* dagChecker, std::string const& config,
- bool debugSources)
+bool processSources(cmGeneratorTarget const* tgt,
+ std::vector<EvaluatedTargetPropertyEntry>& entries,
+ std::vector<BT<std::string>>& srcs,
+ std::unordered_set<std::string>& uniqueSrcs,
+ bool debugSources)
{
cmMakefile* mf = tgt->Target->GetMakefile();
bool contextDependent = false;
- for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
- it = entries.begin(),
- end = entries.end();
- it != end; ++it) {
- cmLinkImplItem const& item = (*it)->LinkImplItem;
- std::string const& targetName = item;
- std::vector<std::string> entrySources;
- cmSystemTools::ExpandListArgument(
- (*it)->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt, tgt,
- dagChecker),
- entrySources);
-
- if ((*it)->ge->GetHadContextSensitiveCondition()) {
+ for (EvaluatedTargetPropertyEntry& entry : entries) {
+ if (entry.ContextDependent) {
contextDependent = true;
}
- for (std::vector<std::string>::iterator i = entrySources.begin();
- i != entrySources.end(); ++i) {
- std::string& src = *i;
+ cmLinkImplItem const& item = entry.LinkImplItem;
+ std::string const& targetName = item.AsStr();
+
+ for (std::string& src : entry.Values) {
cmSourceFile* sf = mf->GetOrCreateSource(src);
std::string e;
- std::string fullPath = sf->GetFullPath(&e);
+ std::string fullPath = sf->ResolveFullPath(&e);
if (fullPath.empty()) {
if (!e.empty()) {
cmake* cm = tgt->GetLocalGenerator()->GetCMakeInstance();
- cm->IssueMessage(cmake::FATAL_ERROR, e, tgt->GetBacktrace());
+ cm->IssueMessage(MessageType::FATAL_ERROR, e, tgt->GetBacktrace());
}
return contextDependent;
}
- if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src.c_str())) {
+ if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src)) {
std::ostringstream err;
if (!targetName.empty()) {
err << "Target \"" << targetName
- << "\" contains relative "
- "path in its INTERFACE_SOURCES:\n"
- " \""
+ << "\" contains relative path in its INTERFACE_SOURCES:\n \""
<< src << "\"";
} else {
- err << "Found relative path while evaluating sources of "
- "\""
+ err << "Found relative path while evaluating sources of \""
<< tgt->GetName() << "\":\n \"" << src << "\"\n";
}
- tgt->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, err.str());
+ tgt->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
+ err.str());
return contextDependent;
}
src = fullPath;
}
std::string usedSources;
- for (std::vector<std::string>::iterator li = entrySources.begin();
- li != entrySources.end(); ++li) {
- std::string src = *li;
-
+ for (std::string const& src : entry.Values) {
if (uniqueSrcs.insert(src).second) {
- srcs.push_back(src);
+ srcs.emplace_back(src, entry.Backtrace);
if (debugSources) {
usedSources += " * " + src + "\n";
}
@@ -887,17 +1357,20 @@ static bool processSources(
}
if (!usedSources.empty()) {
tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
- cmake::LOG, std::string("Used sources for target ") + tgt->GetName() +
- ":\n" + usedSources,
- (*it)->ge->GetBacktrace());
+ MessageType::LOG,
+ std::string("Used sources for target ") + tgt->GetName() + ":\n" +
+ usedSources,
+ entry.Backtrace);
}
}
return contextDependent;
}
+}
-void cmGeneratorTarget::GetSourceFiles(std::vector<std::string>& files,
- const std::string& config) const
+std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths(
+ std::string const& config) const
{
+ std::vector<BT<std::string>> files;
assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY);
if (!this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) {
@@ -908,69 +1381,85 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<std::string>& files,
// behavior of CMP0024 and CMP0026 only.
cmStringRange sourceEntries = this->Target->GetSourceEntries();
- for (cmStringRange::const_iterator i = sourceEntries.begin();
- i != sourceEntries.end(); ++i) {
- std::string const& entry = *i;
-
- std::vector<std::string> items;
- cmSystemTools::ExpandListArgument(entry, items);
- for (std::vector<std::string>::const_iterator li = items.begin();
- li != items.end(); ++li) {
- if (cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
- (*li)[li->size() - 1] == '>') {
+ for (std::string const& entry : sourceEntries) {
+ std::vector<std::string> items = cmExpandedList(entry);
+ for (std::string const& item : items) {
+ if (cmHasLiteralPrefix(item, "$<TARGET_OBJECTS:") &&
+ item.back() == '>') {
continue;
}
- files.push_back(*li);
+ files.emplace_back(item);
}
}
- return;
+ return files;
}
std::vector<std::string> debugProperties;
const char* debugProp =
this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
if (debugProp) {
- cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+ cmExpandList(debugProp, debugProperties);
}
- bool debugSources = !this->DebugSourcesDone &&
- std::find(debugProperties.begin(), debugProperties.end(), "SOURCES") !=
- debugProperties.end();
+ bool debugSources =
+ !this->DebugSourcesDone && cmContains(debugProperties, "SOURCES");
if (this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) {
this->DebugSourcesDone = true;
}
- cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "SOURCES",
- CM_NULLPTR, CM_NULLPTR);
-
- CM_UNORDERED_SET<std::string> uniqueSrcs;
- bool contextDependentDirectSources =
- processSources(this, this->SourceEntries, files, uniqueSrcs, &dagChecker,
- config, debugSources);
+ cmGeneratorExpressionDAGChecker dagChecker(this, "SOURCES", nullptr,
+ nullptr);
- std::vector<cmGeneratorTarget::TargetPropertyEntry*>
- linkInterfaceSourcesEntries;
+ std::vector<EvaluatedTargetPropertyEntry> entries =
+ EvaluateTargetPropertyEntries(this, config, std::string(), &dagChecker,
+ this->SourceEntries);
- AddInterfaceEntries(this, config, "INTERFACE_SOURCES",
- linkInterfaceSourcesEntries);
+ std::unordered_set<std::string> uniqueSrcs;
+ bool contextDependentDirectSources =
+ processSources(this, entries, files, uniqueSrcs, debugSources);
+ // Collect INTERFACE_SOURCES of all direct link-dependencies.
+ std::vector<EvaluatedTargetPropertyEntry> linkInterfaceSourcesEntries;
+ AddInterfaceEntries(this, config, "INTERFACE_SOURCES", std::string(),
+ &dagChecker, linkInterfaceSourcesEntries);
std::vector<std::string>::size_type numFilesBefore = files.size();
- bool contextDependentInterfaceSources =
- processSources(this, linkInterfaceSourcesEntries, files, uniqueSrcs,
- &dagChecker, config, debugSources);
+ bool contextDependentInterfaceSources = processSources(
+ this, linkInterfaceSourcesEntries, files, uniqueSrcs, debugSources);
+
+ // Collect TARGET_OBJECTS of direct object link-dependencies.
+ bool contextDependentObjects = false;
+ std::vector<std::string>::size_type numFilesBefore2 = files.size();
+ if (this->GetType() != cmStateEnums::OBJECT_LIBRARY) {
+ std::vector<EvaluatedTargetPropertyEntry> linkObjectsEntries;
+ AddObjectEntries(this, config, &dagChecker, linkObjectsEntries);
+ contextDependentObjects = processSources(this, linkObjectsEntries, files,
+ uniqueSrcs, debugSources);
+ }
if (!contextDependentDirectSources &&
- !(contextDependentInterfaceSources && numFilesBefore < files.size())) {
+ !(contextDependentInterfaceSources && numFilesBefore < files.size()) &&
+ !(contextDependentObjects && numFilesBefore2 < files.size())) {
this->LinkImplementationLanguageIsContextDependent = false;
}
- cmDeleteAll(linkInterfaceSourcesEntries);
+ return files;
}
void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*>& files,
const std::string& config) const
{
+ std::vector<BT<cmSourceFile*>> tmp = this->GetSourceFiles(config);
+ files.reserve(tmp.size());
+ for (BT<cmSourceFile*>& v : tmp) {
+ files.push_back(v.Value);
+ }
+}
+
+std::vector<BT<cmSourceFile*>> cmGeneratorTarget::GetSourceFiles(
+ std::string const& config) const
+{
+ std::vector<BT<cmSourceFile*>> files;
if (!this->GlobalGenerator->GetConfigureDoneCMP0026()) {
// Since we are still configuring not all sources may exist yet,
// so we need to avoid full source classification because that
@@ -978,38 +1467,49 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*>& files,
// Since this is only for compatibility with old policies that
// projects should not depend on anymore, just compute the files
// without memoizing them.
- std::vector<std::string> srcs;
- this->GetSourceFiles(srcs, config);
+ std::vector<BT<std::string>> srcs = this->GetSourceFilePaths(config);
std::set<cmSourceFile*> emitted;
- for (std::vector<std::string>::const_iterator i = srcs.begin();
- i != srcs.end(); ++i) {
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
+ for (BT<std::string> const& s : srcs) {
+ cmSourceFile* sf = this->Makefile->GetOrCreateSource(s.Value);
if (emitted.insert(sf).second) {
- files.push_back(sf);
+ files.emplace_back(sf, s.Backtrace);
}
}
- return;
+ return files;
}
KindedSources const& kinded = this->GetKindedSources(config);
files.reserve(kinded.Sources.size());
- for (std::vector<SourceAndKind>::const_iterator si = kinded.Sources.begin();
- si != kinded.Sources.end(); ++si) {
- files.push_back(si->Source);
+ for (SourceAndKind const& si : kinded.Sources) {
+ files.push_back(si.Source);
}
+ return files;
}
void cmGeneratorTarget::GetSourceFilesWithoutObjectLibraries(
std::vector<cmSourceFile*>& files, const std::string& config) const
{
+ std::vector<BT<cmSourceFile*>> tmp =
+ this->GetSourceFilesWithoutObjectLibraries(config);
+ files.reserve(tmp.size());
+ for (BT<cmSourceFile*>& v : tmp) {
+ files.push_back(v.Value);
+ }
+}
+
+std::vector<BT<cmSourceFile*>>
+cmGeneratorTarget::GetSourceFilesWithoutObjectLibraries(
+ std::string const& config) const
+{
+ std::vector<BT<cmSourceFile*>> files;
KindedSources const& kinded = this->GetKindedSources(config);
files.reserve(kinded.Sources.size());
- for (std::vector<SourceAndKind>::const_iterator si = kinded.Sources.begin();
- si != kinded.Sources.end(); ++si) {
- if (si->Source->GetObjectLibrary().empty()) {
- files.push_back(si->Source);
+ for (SourceAndKind const& si : kinded.Sources) {
+ if (si.Source.Value->GetObjectLibrary().empty()) {
+ files.push_back(si.Source);
}
}
+ return files;
}
cmGeneratorTarget::KindedSources const& cmGeneratorTarget::GetKindedSources(
@@ -1023,7 +1523,7 @@ cmGeneratorTarget::KindedSources const& cmGeneratorTarget::GetKindedSources(
// Lookup any existing link implementation for this configuration.
std::string const key = cmSystemTools::UpperCase(config);
- KindedSourcesMapType::iterator it = this->KindedSourcesMap.find(key);
+ auto it = this->KindedSourcesMap.find(key);
if (it != this->KindedSourcesMap.end()) {
if (!it->second.Initialized) {
std::ostringstream e;
@@ -1031,7 +1531,7 @@ cmGeneratorTarget::KindedSources const& cmGeneratorTarget::GetKindedSources(
<< "\" use a generator expression that depends on the "
"SOURCES themselves.";
this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
- cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
+ MessageType::FATAL_ERROR, e.str(), this->GetBacktrace());
static KindedSources empty;
return empty;
}
@@ -1049,17 +1549,15 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
std::string const& config) const
{
// Get the source file paths by string.
- std::vector<std::string> srcs;
- this->GetSourceFiles(srcs, config);
+ std::vector<BT<std::string>> srcs = this->GetSourceFilePaths(config);
cmsys::RegularExpression header_regex(CM_HEADER_REGEX);
std::vector<cmSourceFile*> badObjLib;
std::set<cmSourceFile*> emitted;
- for (std::vector<std::string>::const_iterator i = srcs.begin();
- i != srcs.end(); ++i) {
+ for (BT<std::string> const& s : srcs) {
// Create each source at most once.
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
+ cmSourceFile* sf = this->Makefile->GetOrCreateSource(s.Value);
if (!emitted.insert(sf).second) {
continue;
}
@@ -1071,14 +1569,13 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
kind = SourceKindCustomCommand;
} else if (this->Target->GetType() == cmStateEnums::UTILITY) {
kind = SourceKindExtra;
+ } else if (this->IsSourceFilePartOfUnityBatch(sf->ResolveFullPath())) {
+ kind = SourceKindUnityBatched;
} else if (sf->GetPropertyAsBool("HEADER_FILE_ONLY")) {
kind = SourceKindHeader;
} else if (sf->GetPropertyAsBool("EXTERNAL_OBJECT")) {
kind = SourceKindExternalObject;
- if (this->GetType() == cmStateEnums::OBJECT_LIBRARY) {
- badObjLib.push_back(sf);
- }
- } else if (!sf->GetLanguage().empty()) {
+ } else if (!sf->GetOrDetermineLanguage().empty()) {
kind = SourceKindObjectSource;
} else if (ext == "def") {
kind = SourceKindModuleDefinition;
@@ -1097,7 +1594,7 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
// Both names would have been auto generated from Visual Studio
// where the user supplied the file name and Visual Studio
// appended the suffix.
- std::string resx = sf->GetFullPath();
+ std::string resx = sf->ResolveFullPath();
std::string hFileName = resx.substr(0, resx.find_last_of('.')) + ".h";
files.ExpectedResxHeaders.insert(hFileName);
} else if (ext == "appxmanifest") {
@@ -1113,33 +1610,31 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
// Both names would have been auto generated from Visual Studio
// where the user supplied the file name and Visual Studio
// appended the suffix.
- std::string xaml = sf->GetFullPath();
+ std::string xaml = sf->ResolveFullPath();
std::string hFileName = xaml + ".h";
std::string cppFileName = xaml + ".cpp";
files.ExpectedXamlHeaders.insert(hFileName);
files.ExpectedXamlSources.insert(cppFileName);
- } else if (header_regex.find(sf->GetFullPath().c_str())) {
+ } else if (header_regex.find(sf->ResolveFullPath())) {
kind = SourceKindHeader;
} else {
kind = SourceKindExtra;
}
// Save this classified source file in the result vector.
- SourceAndKind entry = { sf, kind };
- files.Sources.push_back(entry);
+ files.Sources.push_back({ BT<cmSourceFile*>(sf, s.Backtrace), kind });
}
if (!badObjLib.empty()) {
std::ostringstream e;
e << "OBJECT library \"" << this->GetName() << "\" contains:\n";
- for (std::vector<cmSourceFile*>::const_iterator i = badObjLib.begin();
- i != badObjLib.end(); ++i) {
- e << " " << (*i)->GetLocation().GetName() << "\n";
+ for (cmSourceFile* i : badObjLib) {
+ e << " " << i->GetLocation().GetName() << "\n";
}
e << "but may contain only sources that compile, header files, and "
"other files that would not affect linking of a normal library.";
this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
- cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
+ MessageType::FATAL_ERROR, e.str(), this->GetBacktrace());
}
}
@@ -1161,18 +1656,15 @@ void cmGeneratorTarget::ComputeAllConfigSources() const
for (size_t ci = 0; ci < configs.size(); ++ci) {
KindedSources const& sources = this->GetKindedSources(configs[ci]);
- for (std::vector<cmGeneratorTarget::SourceAndKind>::const_iterator si =
- sources.Sources.begin();
- si != sources.Sources.end(); ++si) {
- std::map<cmSourceFile const*, size_t>::iterator mi =
- index.find(si->Source);
+ for (SourceAndKind const& src : sources.Sources) {
+ auto mi = index.find(src.Source.Value);
if (mi == index.end()) {
AllConfigSource acs;
- acs.Source = si->Source;
- acs.Kind = si->Kind;
- this->AllConfigSources.push_back(acs);
+ acs.Source = src.Source.Value;
+ acs.Kind = src.Kind;
+ this->AllConfigSources.push_back(std::move(acs));
std::map<cmSourceFile const*, size_t>::value_type entry(
- si->Source, this->AllConfigSources.size() - 1);
+ src.Source.Value, this->AllConfigSources.size() - 1);
mi = index.insert(entry).first;
}
this->AllConfigSources[mi->second].Configs.push_back(ci);
@@ -1191,8 +1683,7 @@ std::string cmGeneratorTarget::GetCompilePDBName(
// Check for a per-configuration output directory target property.
std::string configUpper = cmSystemTools::UpperCase(config);
- std::string configProp = "COMPILE_PDB_NAME_";
- configProp += configUpper;
+ std::string configProp = cmStrCat("COMPILE_PDB_NAME_", configUpper);
const char* config_name = this->GetProperty(configProp);
if (config_name && *config_name) {
return prefix + config_name + ".pdb";
@@ -1264,9 +1755,8 @@ bool cmGeneratorTarget::NeedRelinkBeforeInstall(
// Check for rpath support on this platform.
std::string ll = this->GetLinkerLanguage(config);
if (!ll.empty()) {
- std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
- flagVar += ll;
- flagVar += "_FLAG";
+ std::string flagVar =
+ cmStrCat("CMAKE_SHARED_LIBRARY_RUNTIME_", ll, "_FLAG");
if (!this->Makefile->IsSet(flagVar)) {
// There is no rpath support on this platform so nothing needs
// relinking.
@@ -1282,7 +1772,7 @@ bool cmGeneratorTarget::NeedRelinkBeforeInstall(
// will likely change between the build tree and install tree and
// this target must be relinked.
bool have_rpath =
- this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH();
+ this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH(config);
bool is_ninja =
this->LocalGenerator->GetGlobalGenerator()->GetName() == "Ninja";
@@ -1299,7 +1789,7 @@ bool cmGeneratorTarget::NeedRelinkBeforeInstall(
/* clang-format on */
cmake* cm = this->LocalGenerator->GetCMakeInstance();
- cm->IssueMessage(cmake::FATAL_ERROR, w.str(), this->GetBacktrace());
+ cm->IssueMessage(MessageType::FATAL_ERROR, w.str(), this->GetBacktrace());
}
return have_rpath;
@@ -1344,9 +1834,8 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const
// binaries.
std::string ll = this->GetLinkerLanguage(config);
if (!ll.empty()) {
- std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
- sepVar += ll;
- sepVar += "_FLAG_SEP";
+ std::string sepVar =
+ cmStrCat("CMAKE_SHARED_LIBRARY_RUNTIME_", ll, "_FLAG_SEP");
const char* sep = this->Makefile->GetDefinition(sepVar);
if (sep && *sep) {
// TODO: Add ELF check to ABI detection and get rid of
@@ -1430,7 +1919,7 @@ bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir(
w << " less than 10.5 or because CMake's platform configuration is";
w << " corrupt.";
cmake* cm = this->LocalGenerator->GetCMakeInstance();
- cm->IssueMessage(cmake::FATAL_ERROR, w.str(), this->GetBacktrace());
+ cm->IssueMessage(MessageType::FATAL_ERROR, w.str(), this->GetBacktrace());
}
return true;
@@ -1463,7 +1952,7 @@ bool cmGeneratorTarget::MacOSXUseInstallNameDir() const
const char* build_with_install_name =
this->GetProperty("BUILD_WITH_INSTALL_NAME_DIR");
if (build_with_install_name) {
- return cmSystemTools::IsOn(build_with_install_name);
+ return cmIsOn(build_with_install_name);
}
cmPolicies::PolicyStatus cmp0068 = this->GetPolicyStatusCMP0068();
@@ -1525,38 +2014,33 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const
return "";
}
// Compute the soname that will be built.
- std::string name;
- std::string soName;
- std::string realName;
- std::string impName;
- std::string pdbName;
- this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
- return soName;
+ return this->GetLibraryNames(config).SharedObject;
}
-static bool shouldAddFullLevel(cmGeneratorTarget::BundleDirectoryLevel level)
+namespace {
+bool shouldAddFullLevel(cmGeneratorTarget::BundleDirectoryLevel level)
{
return level == cmGeneratorTarget::FullLevel;
}
-static bool shouldAddContentLevel(
- cmGeneratorTarget::BundleDirectoryLevel level)
+bool shouldAddContentLevel(cmGeneratorTarget::BundleDirectoryLevel level)
{
return level == cmGeneratorTarget::ContentLevel || shouldAddFullLevel(level);
}
+}
std::string cmGeneratorTarget::GetAppBundleDirectory(
const std::string& config, BundleDirectoryLevel level) const
{
- std::string fpath =
- this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact);
- fpath += ".";
+ std::string fpath = cmStrCat(
+ this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact), '.');
const char* ext = this->GetProperty("BUNDLE_EXTENSION");
if (!ext) {
ext = "app";
}
fpath += ext;
- if (shouldAddContentLevel(level) && !this->Makefile->PlatformIsAppleIos()) {
+ if (shouldAddContentLevel(level) &&
+ !this->Makefile->PlatformIsAppleEmbedded()) {
fpath += "/Contents";
if (shouldAddFullLevel(level)) {
fpath += "/MacOS";
@@ -1574,9 +2058,8 @@ bool cmGeneratorTarget::IsBundleOnApple() const
std::string cmGeneratorTarget::GetCFBundleDirectory(
const std::string& config, BundleDirectoryLevel level) const
{
- std::string fpath;
- fpath += this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact);
- fpath += ".";
+ std::string fpath = cmStrCat(
+ this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact), '.');
const char* ext = this->GetProperty("BUNDLE_EXTENSION");
if (!ext) {
if (this->IsXCTestOnApple()) {
@@ -1586,7 +2069,8 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(
}
}
fpath += ext;
- if (shouldAddContentLevel(level) && !this->Makefile->PlatformIsAppleIos()) {
+ if (shouldAddContentLevel(level) &&
+ !this->Makefile->PlatformIsAppleEmbedded()) {
fpath += "/Contents";
if (shouldAddFullLevel(level)) {
fpath += "/MacOS";
@@ -1598,15 +2082,15 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(
std::string cmGeneratorTarget::GetFrameworkDirectory(
const std::string& config, BundleDirectoryLevel level) const
{
- std::string fpath;
- fpath += this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact);
- fpath += ".";
+ std::string fpath = cmStrCat(
+ this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact), '.');
const char* ext = this->GetProperty("BUNDLE_EXTENSION");
if (!ext) {
ext = "framework";
}
fpath += ext;
- if (shouldAddFullLevel(level) && !this->Makefile->PlatformIsAppleIos()) {
+ if (shouldAddFullLevel(level) &&
+ !this->Makefile->PlatformIsAppleEmbedded()) {
fpath += "/Versions/";
fpath += this->GetFrameworkVersion();
}
@@ -1656,8 +2140,7 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const
if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_INSTALL)) {
if (install_name_dir && *install_name_dir) {
- dir = install_name_dir;
- dir += "/";
+ dir = cmStrCat(install_name_dir, '/');
}
}
if (!install_name_dir) {
@@ -1675,31 +2158,21 @@ cmListFileBacktrace cmGeneratorTarget::GetBacktrace() const
return this->Target->GetBacktrace();
}
-const std::vector<std::string>& cmGeneratorTarget::GetLinkDirectories() const
-{
- return this->Target->GetLinkDirectories();
-}
-
-const std::set<std::string>& cmGeneratorTarget::GetUtilities() const
+const std::set<BT<std::string>>& cmGeneratorTarget::GetUtilities() const
{
return this->Target->GetUtilities();
}
-const cmListFileBacktrace* cmGeneratorTarget::GetUtilityBacktrace(
- const std::string& u) const
-{
- return this->Target->GetUtilityBacktrace(u);
-}
-
bool cmGeneratorTarget::HaveWellDefinedOutputFiles() const
{
return this->GetType() == cmStateEnums::STATIC_LIBRARY ||
this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->GetType() == cmStateEnums::MODULE_LIBRARY ||
+ this->GetType() == cmStateEnums::OBJECT_LIBRARY ||
this->GetType() == cmStateEnums::EXECUTABLE;
}
-const char* cmGeneratorTarget::GetExportMacro() const
+const std::string* cmGeneratorTarget::GetExportMacro() const
{
// Define the symbol for targets that export symbols.
if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
@@ -1708,23 +2181,22 @@ const char* cmGeneratorTarget::GetExportMacro() const
if (const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL")) {
this->ExportMacro = custom_export_name;
} else {
- std::string in = this->GetName();
- in += "_EXPORTS";
+ std::string in = cmStrCat(this->GetName(), "_EXPORTS");
this->ExportMacro = cmSystemTools::MakeCidentifier(in);
}
- return this->ExportMacro.c_str();
+ return &this->ExportMacro;
}
- return CM_NULLPTR;
+ return nullptr;
}
class cmTargetCollectLinkLanguages
{
public:
cmTargetCollectLinkLanguages(cmGeneratorTarget const* target,
- const std::string& config,
- CM_UNORDERED_SET<std::string>& languages,
+ std::string config,
+ std::unordered_set<std::string>& languages,
cmGeneratorTarget const* head)
- : Config(config)
+ : Config(std::move(config))
, Languages(languages)
, HeadTarget(head)
, Target(target)
@@ -1735,15 +2207,15 @@ public:
void Visit(cmLinkItem const& item)
{
if (!item.Target) {
- if (item.find("::") != std::string::npos) {
+ if (item.AsStr().find("::") != std::string::npos) {
bool noMessage = false;
- cmake::MessageType messageType = cmake::FATAL_ERROR;
+ MessageType messageType = MessageType::FATAL_ERROR;
std::ostringstream e;
switch (this->Target->GetLocalGenerator()->GetPolicyStatus(
cmPolicies::CMP0028)) {
case cmPolicies::WARN: {
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n";
- messageType = cmake::AUTHOR_WARNING;
+ messageType = MessageType::AUTHOR_WARNING;
} break;
case cmPolicies::OLD:
noMessage = true;
@@ -1756,7 +2228,7 @@ public:
if (!noMessage) {
e << "Target \"" << this->Target->GetName()
- << "\" links to target \"" << item
+ << "\" links to target \"" << item.AsStr()
<< "\" but the target was not found. Perhaps a find_package() "
"call is missing for an IMPORTED target, or an ALIAS target is "
"missing?";
@@ -1775,21 +2247,18 @@ public:
return;
}
- for (std::vector<std::string>::const_iterator li =
- iface->Languages.begin();
- li != iface->Languages.end(); ++li) {
- this->Languages.insert(*li);
+ for (std::string const& language : iface->Languages) {
+ this->Languages.insert(language);
}
- for (std::vector<cmLinkItem>::const_iterator li = iface->Libraries.begin();
- li != iface->Libraries.end(); ++li) {
- this->Visit(*li);
+ for (cmLinkItem const& lib : iface->Libraries) {
+ this->Visit(lib);
}
}
private:
std::string Config;
- CM_UNORDERED_SET<std::string>& Languages;
+ std::unordered_set<std::string>& Languages;
cmGeneratorTarget const* HeadTarget;
const cmGeneratorTarget* Target;
std::set<cmGeneratorTarget const*> Visited;
@@ -1799,7 +2268,7 @@ cmGeneratorTarget::LinkClosure const* cmGeneratorTarget::GetLinkClosure(
const std::string& config) const
{
std::string key(cmSystemTools::UpperCase(config));
- LinkClosureMapType::iterator i = this->LinkClosureMap.find(key);
+ auto i = this->LinkClosureMap.find(key);
if (i == this->LinkClosureMap.end()) {
LinkClosure lc;
this->ComputeLinkClosure(config, lc);
@@ -1844,13 +2313,12 @@ public:
e << "Target " << this->Target->GetName()
<< " contains multiple languages with the highest linker preference"
<< " (" << this->Preference << "):\n";
- for (std::set<std::string>::const_iterator li = this->Preferred.begin();
- li != this->Preferred.end(); ++li) {
- e << " " << *li << "\n";
+ for (std::string const& li : this->Preferred) {
+ e << " " << li << "\n";
}
e << "Set the LINKER_LANGUAGE property for this target.";
cmake* cm = this->Target->GetLocalGenerator()->GetCMakeInstance();
- cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ cm->IssueMessage(MessageType::FATAL_ERROR, e.str(),
this->Target->GetBacktrace());
}
return *this->Preferred.begin();
@@ -1861,26 +2329,22 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
LinkClosure& lc) const
{
// Get languages built in this target.
- CM_UNORDERED_SET<std::string> languages;
+ std::unordered_set<std::string> languages;
cmLinkImplementation const* impl = this->GetLinkImplementation(config);
assert(impl);
- for (std::vector<std::string>::const_iterator li = impl->Languages.begin();
- li != impl->Languages.end(); ++li) {
- languages.insert(*li);
+ for (std::string const& li : impl->Languages) {
+ languages.insert(li);
}
// Add interface languages from linked targets.
cmTargetCollectLinkLanguages cll(this, config, languages, this);
- for (std::vector<cmLinkImplItem>::const_iterator li =
- impl->Libraries.begin();
- li != impl->Libraries.end(); ++li) {
- cll.Visit(*li);
+ for (cmLinkImplItem const& lib : impl->Libraries) {
+ cll.Visit(lib);
}
// Store the transitive closure of languages.
- for (CM_UNORDERED_SET<std::string>::const_iterator li = languages.begin();
- li != languages.end(); ++li) {
- lc.Languages.push_back(*li);
+ for (std::string const& lang : languages) {
+ lc.Languages.push_back(lang);
}
// Choose the language whose linker should be used.
@@ -1893,18 +2357,16 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
cmTargetSelectLinker tsl(this);
// First select from the languages compiled directly in this target.
- for (std::vector<std::string>::const_iterator li = impl->Languages.begin();
- li != impl->Languages.end(); ++li) {
- tsl.Consider(li->c_str());
+ for (std::string const& l : impl->Languages) {
+ tsl.Consider(l.c_str());
}
// Now consider languages that propagate from linked targets.
- for (CM_UNORDERED_SET<std::string>::const_iterator sit = languages.begin();
- sit != languages.end(); ++sit) {
+ for (std::string const& lang : languages) {
std::string propagates =
- "CMAKE_" + *sit + "_LINKER_PREFERENCE_PROPAGATES";
+ "CMAKE_" + lang + "_LINKER_PREFERENCE_PROPAGATES";
if (this->Makefile->IsOn(propagates)) {
- tsl.Consider(sit->c_str());
+ tsl.Consider(lang.c_str());
}
}
@@ -1940,8 +2402,7 @@ std::string cmGeneratorTarget::GetMacContentDirectory(
const std::string& config, cmStateEnums::ArtifactType artifact) const
{
// Start with the output directory for the target.
- std::string fpath = this->GetDirectory(config, artifact);
- fpath += "/";
+ std::string fpath = cmStrCat(this->GetDirectory(config, artifact), '/');
BundleDirectoryLevel level = ContentLevel;
if (this->IsFrameworkOnApple()) {
// additional files with a framework go into the version specific
@@ -1973,16 +2434,15 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo(
{
// There is no compile information for imported targets.
if (this->IsImported()) {
- return CM_NULLPTR;
+ return nullptr;
}
if (this->GetType() > cmStateEnums::OBJECT_LIBRARY) {
- std::string msg = "cmTarget::GetCompileInfo called for ";
- msg += this->GetName();
- msg += " which has type ";
- msg += cmState::GetTargetTypeName(this->GetType());
- this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
- return CM_NULLPTR;
+ std::string msg = cmStrCat("cmTarget::GetCompileInfo called for ",
+ this->GetName(), " which has type ",
+ cmState::GetTargetTypeName(this->GetType()));
+ this->LocalGenerator->IssueMessage(MessageType::INTERNAL_ERROR, msg);
+ return nullptr;
}
// Lookup/compute/cache the compile information for this configuration.
@@ -1990,8 +2450,7 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo(
if (!config.empty()) {
config_upper = cmSystemTools::UpperCase(config);
}
- CompileInfoMapType::const_iterator i =
- this->CompileInfoMap.find(config_upper);
+ auto i = this->CompileInfoMap.find(config_upper);
if (i == this->CompileInfoMap.end()) {
CompileInfo info;
this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir);
@@ -2008,7 +2467,7 @@ cmGeneratorTarget::GetModuleDefinitionInfo(std::string const& config) const
if (this->GetType() != cmStateEnums::SHARED_LIBRARY &&
this->GetType() != cmStateEnums::MODULE_LIBRARY &&
!this->IsExecutableWithExports()) {
- return CM_NULLPTR;
+ return nullptr;
}
// Lookup/compute/cache the compile information for this configuration.
@@ -2016,8 +2475,7 @@ cmGeneratorTarget::GetModuleDefinitionInfo(std::string const& config) const
if (!config.empty()) {
config_upper = cmSystemTools::UpperCase(config);
}
- ModuleDefinitionInfoMapType::const_iterator i =
- this->ModuleDefinitionInfoMap.find(config_upper);
+ auto i = this->ModuleDefinitionInfoMap.find(config_upper);
if (i == this->ModuleDefinitionInfoMap.end()) {
ModuleDefinitionInfo info;
this->ComputeModuleDefinitionInfo(config, info);
@@ -2034,8 +2492,13 @@ void cmGeneratorTarget::ComputeModuleDefinitionInfo(
info.WindowsExportAllSymbols =
this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS") &&
this->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS");
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
info.DefFileGenerated =
info.WindowsExportAllSymbols || info.Sources.size() > 1;
+#else
+ // Our __create_def helper is only available on Windows.
+ info.DefFileGenerated = false;
+#endif
if (info.DefFileGenerated) {
info.DefFile = this->ObjectDirectory /* has slash */ + "exports.def";
} else if (!info.Sources.empty()) {
@@ -2045,7 +2508,7 @@ void cmGeneratorTarget::ComputeModuleDefinitionInfo(
bool cmGeneratorTarget::IsDLLPlatform() const
{
- return this->DLLPlatform;
+ return this->Target->IsDLLPlatform();
}
void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string>& result,
@@ -2056,14 +2519,12 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string>& result,
if (!prop) {
return;
}
- cmGeneratorExpression ge;
- cmGeneratorExpressionDAGChecker dagChecker(
- this->GetName(), "AUTOUIC_OPTIONS", CM_NULLPTR, CM_NULLPTR);
- cmSystemTools::ExpandListArgument(
- ge.Parse(prop)->Evaluate(this->LocalGenerator, config, false, this,
- &dagChecker),
- result);
+ cmGeneratorExpressionDAGChecker dagChecker(this, "AUTOUIC_OPTIONS", nullptr,
+ nullptr);
+ cmExpandList(cmGeneratorExpression::Evaluate(prop, this->LocalGenerator,
+ config, this, &dagChecker),
+ result);
}
void processILibs(const std::string& config,
@@ -2076,10 +2537,8 @@ void processILibs(const std::string& config,
tgts.push_back(item.Target);
if (cmLinkInterfaceLibraries const* iface =
item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) {
- for (std::vector<cmLinkItem>::const_iterator it =
- iface->Libraries.begin();
- it != iface->Libraries.end(); ++it) {
- processILibs(config, headTarget, *it, gg, tgts, emitted);
+ for (cmLinkItem const& lib : iface->Libraries) {
+ processILibs(config, headTarget, lib, gg, tgts, emitted);
}
}
}
@@ -2097,10 +2556,8 @@ cmGeneratorTarget::GetLinkImplementationClosure(
cmLinkImplementationLibraries const* impl =
this->GetLinkImplementationLibraries(config);
- for (std::vector<cmLinkImplItem>::const_iterator it =
- impl->Libraries.begin();
- it != impl->Libraries.end(); ++it) {
- processILibs(config, this, *it,
+ for (cmLinkImplItem const& lib : impl->Libraries) {
+ processILibs(config, this, lib,
this->LocalGenerator->GetGlobalGenerator(), tgts, emitted);
}
}
@@ -2118,11 +2575,11 @@ private:
cmMakefile* Makefile;
cmLocalGenerator* LocalGenerator;
cmGlobalGenerator const* GlobalGenerator;
- typedef cmGeneratorTarget::SourceEntry SourceEntry;
+ using SourceEntry = cmGeneratorTarget::SourceEntry;
SourceEntry* CurrentEntry;
std::queue<cmSourceFile*> SourceQueue;
std::set<cmSourceFile*> SourcesQueued;
- typedef std::map<std::string, cmSourceFile*> NameMapType;
+ using NameMapType = std::map<std::string, cmSourcesWithOutput>;
NameMapType NameMap;
std::vector<std::string> NewSources;
@@ -2144,32 +2601,26 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target)
this->Makefile = target->Target->GetMakefile();
this->LocalGenerator = target->GetLocalGenerator();
this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator();
- this->CurrentEntry = CM_NULLPTR;
+ this->CurrentEntry = nullptr;
// Queue all the source files already specified for the target.
if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
- std::vector<std::string> configs;
- this->Makefile->GetConfigurations(configs);
- if (configs.empty()) {
- configs.push_back("");
- }
std::set<cmSourceFile*> emitted;
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
+ std::vector<std::string> const& configs =
+ this->Makefile->GetGeneratorConfigs();
+ for (std::string const& c : configs) {
std::vector<cmSourceFile*> sources;
- this->GeneratorTarget->GetSourceFiles(sources, *ci);
- for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); ++si) {
- cmSourceFile* sf = *si;
+ this->GeneratorTarget->GetSourceFiles(sources, c);
+ for (cmSourceFile* sf : sources) {
const std::set<cmGeneratorTarget const*> tgts =
this->GlobalGenerator->GetFilenameTargetDepends(sf);
- if (tgts.find(this->GeneratorTarget) != tgts.end()) {
+ if (cmContains(tgts, this->GeneratorTarget)) {
std::ostringstream e;
- e << "Evaluation output file\n \"" << sf->GetFullPath()
+ e << "Evaluation output file\n \"" << sf->ResolveFullPath()
<< "\"\ndepends on the sources of a target it is used in. This "
"is a dependency loop and is not allowed.";
this->GeneratorTarget->LocalGenerator->IssueMessage(
- cmake::FATAL_ERROR, e.str());
+ MessageType::FATAL_ERROR, e.str());
return;
}
if (emitted.insert(sf).second &&
@@ -2197,21 +2648,19 @@ void cmTargetTraceDependencies::Trace()
// Queue dependencies added explicitly by the user.
if (const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) {
- std::vector<std::string> objDeps;
- cmSystemTools::ExpandListArgument(additionalDeps, objDeps);
- for (std::vector<std::string>::iterator odi = objDeps.begin();
- odi != objDeps.end(); ++odi) {
- if (cmSystemTools::FileIsFullPath(*odi)) {
- *odi = cmSystemTools::CollapseFullPath(*odi);
+ std::vector<std::string> objDeps = cmExpandedList(additionalDeps);
+ for (std::string& objDep : objDeps) {
+ if (cmSystemTools::FileIsFullPath(objDep)) {
+ objDep = cmSystemTools::CollapseFullPath(objDep);
}
}
this->FollowNames(objDeps);
}
// Queue the source needed to generate this file, if any.
- this->FollowName(sf->GetFullPath());
+ this->FollowName(sf->ResolveFullPath());
- // Queue dependencies added programatically by commands.
+ // Queue dependencies added programmatically by commands.
this->FollowNames(sf->GetDepends());
// Queue custom command dependencies.
@@ -2219,7 +2668,7 @@ void cmTargetTraceDependencies::Trace()
this->CheckCustomCommand(*cc);
}
}
- this->CurrentEntry = CM_NULLPTR;
+ this->CurrentEntry = nullptr;
this->GeneratorTarget->AddTracedSources(this->NewSources);
}
@@ -2230,34 +2679,44 @@ void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf)
this->SourceQueue.push(sf);
// Make sure this file is in the target at the end.
- this->NewSources.push_back(sf->GetFullPath());
+ this->NewSources.push_back(sf->ResolveFullPath());
}
}
void cmTargetTraceDependencies::FollowName(std::string const& name)
{
- NameMapType::iterator i = this->NameMap.find(name);
- if (i == this->NameMap.end()) {
+ // Use lower bound with key comparison to not repeat the search for the
+ // insert position if the name could not be found (which is the common case).
+ auto i = this->NameMap.lower_bound(name);
+ if (i == this->NameMap.end() || i->first != name) {
// Check if we know how to generate this file.
- cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name);
- NameMapType::value_type entry(name, sf);
- i = this->NameMap.insert(entry).first;
- }
- if (cmSourceFile* sf = i->second) {
- // Record the dependency we just followed.
- if (this->CurrentEntry) {
- this->CurrentEntry->Depends.push_back(sf);
+ cmSourcesWithOutput sources = this->Makefile->GetSourcesWithOutput(name);
+ i = this->NameMap.emplace_hint(i, name, sources);
+ }
+ if (cmTarget* t = i->second.Target) {
+ // The name is a byproduct of a utility target or a PRE_BUILD, PRE_LINK, or
+ // POST_BUILD command.
+ this->GeneratorTarget->Target->AddUtility(t->GetName());
+ }
+ if (cmSourceFile* sf = i->second.Source) {
+ // For now only follow the dependency if the source file is not a
+ // byproduct. Semantics of byproducts in a non-Ninja context will have to
+ // be defined first.
+ if (!i->second.SourceIsByproduct) {
+ // Record the dependency we just followed.
+ if (this->CurrentEntry) {
+ this->CurrentEntry->Depends.push_back(sf);
+ }
+ this->QueueSource(sf);
}
- this->QueueSource(sf);
}
}
void cmTargetTraceDependencies::FollowNames(
std::vector<std::string> const& names)
{
- for (std::vector<std::string>::const_iterator i = names.begin();
- i != names.end(); ++i) {
- this->FollowName(*i);
+ for (std::string const& name : names) {
+ this->FollowName(name);
}
}
@@ -2281,7 +2740,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
// If we find the target and the dep was given as a full path,
// then make sure it was not a full path to something else, and
// the fact that the name matched a target was just a coincidence.
- if (cmSystemTools::FileIsFullPath(dep.c_str())) {
+ if (cmSystemTools::FileIsFullPath(dep)) {
if (t->GetType() >= cmStateEnums::EXECUTABLE &&
t->GetType() <= cmStateEnums::MODULE_LIBRARY) {
// This is really only for compatibility so we do not need to
@@ -2317,9 +2776,8 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
// Add target-level dependencies referenced by generator expressions.
std::set<cmGeneratorTarget*> targets;
- for (cmCustomCommandLines::const_iterator cit = cc.GetCommandLines().begin();
- cit != cc.GetCommandLines().end(); ++cit) {
- std::string const& command = *cit->begin();
+ for (cmCustomCommandLine const& cCmdLine : cc.GetCommandLines()) {
+ std::string const& command = cCmdLine.front();
// Check for a target with this name.
if (cmGeneratorTarget* t =
this->LocalGenerator->FindGeneratorTargetToUse(command)) {
@@ -2333,30 +2791,25 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc)
}
// Check for target references in generator expressions.
- for (cmCustomCommandLine::const_iterator cli = cit->begin();
- cli != cit->end(); ++cli) {
- const CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*cli);
- cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "", true);
+ for (std::string const& cl : cCmdLine) {
+ const std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(cl);
+ cge->SetQuiet(true);
+ cge->Evaluate(this->GeneratorTarget->GetLocalGenerator(), "");
std::set<cmGeneratorTarget*> geTargets = cge->GetTargets();
targets.insert(geTargets.begin(), geTargets.end());
}
}
- for (std::set<cmGeneratorTarget*>::iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- this->GeneratorTarget->Target->AddUtility((*ti)->GetName());
+ for (cmGeneratorTarget* target : targets) {
+ this->GeneratorTarget->Target->AddUtility(target->GetName());
}
// Queue the custom command dependencies.
- std::vector<std::string> configs;
std::set<std::string> emitted;
- this->Makefile->GetConfigurations(configs);
- if (configs.empty()) {
- configs.push_back("");
- }
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
- this->FollowCommandDepends(cc, *ci, emitted);
+ std::vector<std::string> const& configs =
+ this->Makefile->GetGeneratorConfigs();
+ for (std::string const& conf : configs) {
+ this->FollowCommandDepends(cc, conf, emitted);
}
}
@@ -2369,9 +2822,7 @@ void cmTargetTraceDependencies::FollowCommandDepends(
const std::vector<std::string>& depends = ccg.GetDepends();
- for (std::vector<std::string>::const_iterator di = depends.begin();
- di != depends.end(); ++di) {
- std::string const& dep = *di;
+ for (std::string const& dep : depends) {
if (emitted.insert(dep).second) {
if (!this->IsUtility(dep)) {
// The dependency does not name a target and may be a file we
@@ -2385,9 +2836,8 @@ void cmTargetTraceDependencies::FollowCommandDepends(
void cmTargetTraceDependencies::CheckCustomCommands(
const std::vector<cmCustomCommand>& commands)
{
- for (std::vector<cmCustomCommand>::const_iterator cli = commands.begin();
- cli != commands.end(); ++cli) {
- this->CheckCustomCommand(*cli);
+ for (cmCustomCommand const& command : commands) {
+ this->CheckCustomCommand(command);
}
}
@@ -2418,17 +2868,17 @@ std::string cmGeneratorTarget::GetCompilePDBDirectory(
void cmGeneratorTarget::GetAppleArchs(const std::string& config,
std::vector<std::string>& archVec) const
{
- const char* archs = CM_NULLPTR;
+ const char* archs = nullptr;
if (!config.empty()) {
- std::string defVarName = "OSX_ARCHITECTURES_";
- defVarName += cmSystemTools::UpperCase(config);
+ std::string defVarName =
+ cmStrCat("OSX_ARCHITECTURES_", cmSystemTools::UpperCase(config));
archs = this->GetProperty(defVarName);
}
if (!archs) {
archs = this->GetProperty("OSX_ARCHITECTURES");
}
if (archs) {
- cmSystemTools::ExpandListArgument(std::string(archs), archVec);
+ cmExpandList(std::string(archs), archVec);
}
}
@@ -2461,47 +2911,45 @@ std::string cmGeneratorTarget::GetCreateRuleVariable(
case cmStateEnums::MODULE_LIBRARY:
return "CMAKE_" + lang + "_CREATE_SHARED_MODULE";
case cmStateEnums::EXECUTABLE:
+ if (this->IsExecutableWithExports()) {
+ std::string linkExeWithExports =
+ "CMAKE_" + lang + "_LINK_EXECUTABLE_WITH_EXPORTS";
+ if (this->Makefile->IsDefinitionSet(linkExeWithExports)) {
+ return linkExeWithExports;
+ }
+ }
return "CMAKE_" + lang + "_LINK_EXECUTABLE";
default:
break;
}
return "";
}
-static void processIncludeDirectories(
+
+namespace {
+void processIncludeDirectories(
cmGeneratorTarget const* tgt,
- const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& includes,
- CM_UNORDERED_SET<std::string>& uniqueIncludes,
- cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
- bool debugIncludes, const std::string& language)
-{
- for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
- it = entries.begin(),
- end = entries.end();
- it != end; ++it) {
- cmLinkImplItem const& item = (*it)->LinkImplItem;
- std::string const& targetName = item;
+ std::vector<EvaluatedTargetPropertyEntry>& entries,
+ std::vector<BT<std::string>>& includes,
+ std::unordered_set<std::string>& uniqueIncludes, bool debugIncludes)
+{
+ for (EvaluatedTargetPropertyEntry& entry : entries) {
+ cmLinkImplItem const& item = entry.LinkImplItem;
+ std::string const& targetName = item.AsStr();
bool const fromImported = item.Target && item.Target->IsImported();
bool const checkCMP0027 = item.FromGenex;
- std::vector<std::string> entryIncludes;
- cmSystemTools::ExpandListArgument(
- (*it)->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt,
- dagChecker, language),
- entryIncludes);
std::string usedIncludes;
- for (std::vector<std::string>::iterator li = entryIncludes.begin();
- li != entryIncludes.end(); ++li) {
- if (fromImported && !cmSystemTools::FileExists(li->c_str())) {
+ for (std::string& entryInclude : entry.Values) {
+ if (fromImported && !cmSystemTools::FileExists(entryInclude)) {
std::ostringstream e;
- cmake::MessageType messageType = cmake::FATAL_ERROR;
+ MessageType messageType = MessageType::FATAL_ERROR;
if (checkCMP0027) {
switch (tgt->GetPolicyStatusCMP0027()) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n";
CM_FALLTHROUGH;
case cmPolicies::OLD:
- messageType = cmake::AUTHOR_WARNING;
+ messageType = MessageType::AUTHOR_WARNING;
break;
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::REQUIRED_IF_USED:
@@ -2511,7 +2959,7 @@ static void processIncludeDirectories(
}
/* clang-format off */
e << "Imported target \"" << targetName << "\" includes "
- "non-existent path\n \"" << *li << "\"\nin its "
+ "non-existent path\n \"" << entryInclude << "\"\nin its "
"INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n"
"* The path was deleted, renamed, or moved to another "
"location.\n"
@@ -2524,21 +2972,21 @@ static void processIncludeDirectories(
return;
}
- if (!cmSystemTools::FileIsFullPath(li->c_str())) {
+ if (!cmSystemTools::FileIsFullPath(entryInclude)) {
std::ostringstream e;
bool noMessage = false;
- cmake::MessageType messageType = cmake::FATAL_ERROR;
+ MessageType messageType = MessageType::FATAL_ERROR;
if (!targetName.empty()) {
/* clang-format off */
e << "Target \"" << targetName << "\" contains relative "
"path in its INTERFACE_INCLUDE_DIRECTORIES:\n"
- " \"" << *li << "\"";
+ " \"" << entryInclude << "\"";
/* clang-format on */
} else {
switch (tgt->GetPolicyStatusCMP0021()) {
case cmPolicies::WARN: {
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n";
- messageType = cmake::AUTHOR_WARNING;
+ messageType = MessageType::AUTHOR_WARNING;
} break;
case cmPolicies::OLD:
noMessage = true;
@@ -2550,77 +2998,73 @@ static void processIncludeDirectories(
}
e << "Found relative path while evaluating include directories of "
"\""
- << tgt->GetName() << "\":\n \"" << *li << "\"\n";
+ << tgt->GetName() << "\":\n \"" << entryInclude << "\"\n";
}
if (!noMessage) {
tgt->GetLocalGenerator()->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR) {
+ if (messageType == MessageType::FATAL_ERROR) {
return;
}
}
}
- if (!cmSystemTools::IsOff(li->c_str())) {
- cmSystemTools::ConvertToUnixSlashes(*li);
+ if (!cmIsOff(entryInclude)) {
+ cmSystemTools::ConvertToUnixSlashes(entryInclude);
}
- std::string inc = *li;
- if (uniqueIncludes.insert(inc).second) {
- includes.push_back(inc);
+ if (uniqueIncludes.insert(entryInclude).second) {
+ includes.emplace_back(entryInclude, entry.Backtrace);
if (debugIncludes) {
- usedIncludes += " * " + inc + "\n";
+ usedIncludes += " * " + entryInclude + "\n";
}
}
}
if (!usedIncludes.empty()) {
tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
- cmake::LOG, std::string("Used includes for target ") + tgt->GetName() +
- ":\n" + usedIncludes,
- (*it)->ge->GetBacktrace());
+ MessageType::LOG,
+ std::string("Used includes for target ") + tgt->GetName() + ":\n" +
+ usedIncludes,
+ entry.Backtrace);
}
}
}
+}
-std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
+std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
const std::string& config, const std::string& lang) const
{
- std::vector<std::string> includes;
- CM_UNORDERED_SET<std::string> uniqueIncludes;
+ std::vector<BT<std::string>> includes;
+ std::unordered_set<std::string> uniqueIncludes;
- cmGeneratorExpressionDAGChecker dagChecker(
- this->GetName(), "INCLUDE_DIRECTORIES", CM_NULLPTR, CM_NULLPTR);
+ cmGeneratorExpressionDAGChecker dagChecker(this, "INCLUDE_DIRECTORIES",
+ nullptr, nullptr);
std::vector<std::string> debugProperties;
const char* debugProp =
this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
if (debugProp) {
- cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+ cmExpandList(debugProp, debugProperties);
}
bool debugIncludes = !this->DebugIncludesDone &&
- std::find(debugProperties.begin(), debugProperties.end(),
- "INCLUDE_DIRECTORIES") != debugProperties.end();
+ cmContains(debugProperties, "INCLUDE_DIRECTORIES");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
this->DebugIncludesDone = true;
}
- processIncludeDirectories(this, this->IncludeDirectoriesEntries, includes,
- uniqueIncludes, &dagChecker, config, debugIncludes,
- lang);
+ std::vector<EvaluatedTargetPropertyEntry> entries =
+ EvaluateTargetPropertyEntries(this, config, lang, &dagChecker,
+ this->IncludeDirectoriesEntries);
- std::vector<cmGeneratorTarget::TargetPropertyEntry*>
- linkInterfaceIncludeDirectoriesEntries;
- AddInterfaceEntries(this, config, "INTERFACE_INCLUDE_DIRECTORIES",
- linkInterfaceIncludeDirectoriesEntries);
+ AddInterfaceEntries(this, config, "INTERFACE_INCLUDE_DIRECTORIES", lang,
+ &dagChecker, entries);
if (this->Makefile->IsOn("APPLE")) {
cmLinkImplementationLibraries const* impl =
this->GetLinkImplementationLibraries(config);
- for (std::vector<cmLinkImplItem>::const_iterator it =
- impl->Libraries.begin();
- it != impl->Libraries.end(); ++it) {
- std::string libDir = cmSystemTools::CollapseFullPath(*it);
+ for (cmLinkImplItem const& lib : impl->Libraries) {
+ std::string libDir = cmSystemTools::CollapseFullPath(lib.AsStr());
static cmsys::RegularExpression frameworkCheck(
"(.*\\.framework)(/Versions/[^/]+)?/[^/]+$");
@@ -2630,47 +3074,45 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
libDir = frameworkCheck.match(1);
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
- ge.Parse(libDir.c_str());
- linkInterfaceIncludeDirectoriesEntries.push_back(
- new cmGeneratorTarget::TargetPropertyEntry(cge));
+ EvaluatedTargetPropertyEntry ee(lib, cmListFileBacktrace());
+ ee.Values.emplace_back(std::move(libDir));
+ entries.emplace_back(std::move(ee));
}
}
- processIncludeDirectories(this, linkInterfaceIncludeDirectoriesEntries,
- includes, uniqueIncludes, &dagChecker, config,
- debugIncludes, lang);
-
- cmDeleteAll(linkInterfaceIncludeDirectoriesEntries);
+ processIncludeDirectories(this, entries, includes, uniqueIncludes,
+ debugIncludes);
return includes;
}
-static void processCompileOptionsInternal(
- cmGeneratorTarget const* tgt,
- const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& options,
- CM_UNORDERED_SET<std::string>& uniqueOptions,
- cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
- bool debugOptions, const char* logName, std::string const& language)
-{
- for (std::vector<cmGeneratorTarget::TargetPropertyEntry *>::const_iterator
- it = entries.begin(),
- end = entries.end();
- it != end; ++it) {
- std::vector<std::string> entryOptions;
- cmSystemTools::ExpandListArgument(
- (*it)->ge->Evaluate(tgt->GetLocalGenerator(), config, false, tgt,
- dagChecker, language),
- entryOptions);
- std::string usedOptions;
- for (std::vector<std::string>::iterator li = entryOptions.begin();
- li != entryOptions.end(); ++li) {
- std::string const& opt = *li;
+enum class OptionsParse
+{
+ None,
+ Shell
+};
+namespace {
+void processOptions(cmGeneratorTarget const* tgt,
+ std::vector<EvaluatedTargetPropertyEntry> const& entries,
+ std::vector<BT<std::string>>& options,
+ std::unordered_set<std::string>& uniqueOptions,
+ bool debugOptions, const char* logName, OptionsParse parse)
+{
+ for (EvaluatedTargetPropertyEntry const& entry : entries) {
+ std::string usedOptions;
+ for (std::string const& opt : entry.Values) {
if (uniqueOptions.insert(opt).second) {
- options.push_back(opt);
+ if (parse == OptionsParse::Shell &&
+ cmHasLiteralPrefix(opt, "SHELL:")) {
+ std::vector<std::string> tmp;
+ cmSystemTools::ParseUnixCommandLine(opt.c_str() + 6, tmp);
+ for (std::string& o : tmp) {
+ options.emplace_back(std::move(o), entry.Backtrace);
+ }
+ } else {
+ options.emplace_back(opt, entry.Backtrace);
+ }
if (debugOptions) {
usedOptions += " * " + opt + "\n";
}
@@ -2678,162 +3120,150 @@ static void processCompileOptionsInternal(
}
if (!usedOptions.empty()) {
tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
- cmake::LOG, std::string("Used compile ") + logName +
- std::string(" for target ") + tgt->GetName() + ":\n" + usedOptions,
- (*it)->ge->GetBacktrace());
+ MessageType::LOG,
+ std::string("Used ") + logName + std::string(" for target ") +
+ tgt->GetName() + ":\n" + usedOptions,
+ entry.Backtrace);
}
}
}
-
-static void processCompileOptions(
- cmGeneratorTarget const* tgt,
- const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& options,
- CM_UNORDERED_SET<std::string>& uniqueOptions,
- cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
- bool debugOptions, std::string const& language)
-{
- processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
- dagChecker, config, debugOptions, "options",
- language);
}
void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result,
const std::string& config,
const std::string& language) const
{
- CM_UNORDERED_SET<std::string> uniqueOptions;
+ std::vector<BT<std::string>> tmp = this->GetCompileOptions(config, language);
+ result.reserve(tmp.size());
+ for (BT<std::string>& v : tmp) {
+ result.emplace_back(std::move(v.Value));
+ }
+}
+
+std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions(
+ std::string const& config, std::string const& language) const
+{
+ std::vector<BT<std::string>> result;
+ std::unordered_set<std::string> uniqueOptions;
- cmGeneratorExpressionDAGChecker dagChecker(
- this->GetName(), "COMPILE_OPTIONS", CM_NULLPTR, CM_NULLPTR);
+ cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_OPTIONS", nullptr,
+ nullptr);
std::vector<std::string> debugProperties;
const char* debugProp =
this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
if (debugProp) {
- cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+ cmExpandList(debugProp, debugProperties);
}
bool debugOptions = !this->DebugCompileOptionsDone &&
- std::find(debugProperties.begin(), debugProperties.end(),
- "COMPILE_OPTIONS") != debugProperties.end();
+ cmContains(debugProperties, "COMPILE_OPTIONS");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
this->DebugCompileOptionsDone = true;
}
- processCompileOptions(this, this->CompileOptionsEntries, result,
- uniqueOptions, &dagChecker, config, debugOptions,
- language);
+ std::vector<EvaluatedTargetPropertyEntry> entries =
+ EvaluateTargetPropertyEntries(this, config, language, &dagChecker,
+ this->CompileOptionsEntries);
- std::vector<cmGeneratorTarget::TargetPropertyEntry*>
- linkInterfaceCompileOptionsEntries;
+ AddInterfaceEntries(this, config, "INTERFACE_COMPILE_OPTIONS", language,
+ &dagChecker, entries);
- AddInterfaceEntries(this, config, "INTERFACE_COMPILE_OPTIONS",
- linkInterfaceCompileOptionsEntries);
+ processOptions(this, entries, result, uniqueOptions, debugOptions,
+ "compile options", OptionsParse::Shell);
- processCompileOptions(this, linkInterfaceCompileOptionsEntries, result,
- uniqueOptions, &dagChecker, config, debugOptions,
- language);
-
- cmDeleteAll(linkInterfaceCompileOptionsEntries);
+ return result;
}
-static void processCompileFeatures(
- cmGeneratorTarget const* tgt,
- const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& options,
- CM_UNORDERED_SET<std::string>& uniqueOptions,
- cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
- bool debugOptions)
+void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string>& result,
+ const std::string& config) const
{
- processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
- dagChecker, config, debugOptions, "features",
- std::string());
+ std::vector<BT<std::string>> tmp = this->GetCompileFeatures(config);
+ result.reserve(tmp.size());
+ for (BT<std::string>& v : tmp) {
+ result.emplace_back(std::move(v.Value));
+ }
}
-void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string>& result,
- const std::string& config) const
+std::vector<BT<std::string>> cmGeneratorTarget::GetCompileFeatures(
+ std::string const& config) const
{
- CM_UNORDERED_SET<std::string> uniqueFeatures;
+ std::vector<BT<std::string>> result;
+ std::unordered_set<std::string> uniqueFeatures;
- cmGeneratorExpressionDAGChecker dagChecker(
- this->GetName(), "COMPILE_FEATURES", CM_NULLPTR, CM_NULLPTR);
+ cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_FEATURES", nullptr,
+ nullptr);
std::vector<std::string> debugProperties;
const char* debugProp =
this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
if (debugProp) {
- cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+ cmExpandList(debugProp, debugProperties);
}
bool debugFeatures = !this->DebugCompileFeaturesDone &&
- std::find(debugProperties.begin(), debugProperties.end(),
- "COMPILE_FEATURES") != debugProperties.end();
+ cmContains(debugProperties, "COMPILE_FEATURES");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
this->DebugCompileFeaturesDone = true;
}
- processCompileFeatures(this, this->CompileFeaturesEntries, result,
- uniqueFeatures, &dagChecker, config, debugFeatures);
+ std::vector<EvaluatedTargetPropertyEntry> entries =
+ EvaluateTargetPropertyEntries(this, config, std::string(), &dagChecker,
+ this->CompileFeaturesEntries);
- std::vector<cmGeneratorTarget::TargetPropertyEntry*>
- linkInterfaceCompileFeaturesEntries;
AddInterfaceEntries(this, config, "INTERFACE_COMPILE_FEATURES",
- linkInterfaceCompileFeaturesEntries);
+ std::string(), &dagChecker, entries);
- processCompileFeatures(this, linkInterfaceCompileFeaturesEntries, result,
- uniqueFeatures, &dagChecker, config, debugFeatures);
+ processOptions(this, entries, result, uniqueFeatures, debugFeatures,
+ "compile features", OptionsParse::None);
- cmDeleteAll(linkInterfaceCompileFeaturesEntries);
+ return result;
}
-static void processCompileDefinitions(
- cmGeneratorTarget const* tgt,
- const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& options,
- CM_UNORDERED_SET<std::string>& uniqueOptions,
- cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
- bool debugOptions, std::string const& language)
+void cmGeneratorTarget::GetCompileDefinitions(
+ std::vector<std::string>& result, const std::string& config,
+ const std::string& language) const
{
- processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
- dagChecker, config, debugOptions,
- "definitions", language);
+ std::vector<BT<std::string>> tmp =
+ this->GetCompileDefinitions(config, language);
+ result.reserve(tmp.size());
+ for (BT<std::string>& v : tmp) {
+ result.emplace_back(std::move(v.Value));
+ }
}
-void cmGeneratorTarget::GetCompileDefinitions(
- std::vector<std::string>& list, const std::string& config,
- const std::string& language) const
+std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
+ std::string const& config, std::string const& language) const
{
- CM_UNORDERED_SET<std::string> uniqueOptions;
+ std::vector<BT<std::string>> list;
+ std::unordered_set<std::string> uniqueOptions;
- cmGeneratorExpressionDAGChecker dagChecker(
- this->GetName(), "COMPILE_DEFINITIONS", CM_NULLPTR, CM_NULLPTR);
+ cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_DEFINITIONS",
+ nullptr, nullptr);
std::vector<std::string> debugProperties;
const char* debugProp =
this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
if (debugProp) {
- cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+ cmExpandList(debugProp, debugProperties);
}
bool debugDefines = !this->DebugCompileDefinitionsDone &&
- std::find(debugProperties.begin(), debugProperties.end(),
- "COMPILE_DEFINITIONS") != debugProperties.end();
+ cmContains(debugProperties, "COMPILE_DEFINITIONS");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
this->DebugCompileDefinitionsDone = true;
}
- processCompileDefinitions(this, this->CompileDefinitionsEntries, list,
- uniqueOptions, &dagChecker, config, debugDefines,
- language);
+ std::vector<EvaluatedTargetPropertyEntry> entries =
+ EvaluateTargetPropertyEntries(this, config, language, &dagChecker,
+ this->CompileDefinitionsEntries);
+
+ AddInterfaceEntries(this, config, "INTERFACE_COMPILE_DEFINITIONS", language,
+ &dagChecker, entries);
- std::vector<cmGeneratorTarget::TargetPropertyEntry*>
- linkInterfaceCompileDefinitionsEntries;
- AddInterfaceEntries(this, config, "INTERFACE_COMPILE_DEFINITIONS",
- linkInterfaceCompileDefinitionsEntries);
if (!config.empty()) {
std::string configPropName =
"COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config);
@@ -2841,17 +3271,16 @@ void cmGeneratorTarget::GetCompileDefinitions(
if (configProp) {
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) {
case cmPolicies::WARN: {
- std::ostringstream e;
- e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043);
- this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ this->LocalGenerator->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0043));
CM_FALLTHROUGH;
}
case cmPolicies::OLD: {
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
- ge.Parse(configProp);
- linkInterfaceCompileDefinitionsEntries.push_back(
- new cmGeneratorTarget::TargetPropertyEntry(cge));
+ std::unique_ptr<TargetPropertyEntry> entry(
+ CreateTargetPropertyEntry(configProp));
+ entries.emplace_back(EvaluateTargetPropertyEntry(
+ this, config, language, &dagChecker, entry.get()));
} break;
case cmPolicies::NEW:
case cmPolicies::REQUIRED_ALWAYS:
@@ -2861,11 +3290,662 @@ void cmGeneratorTarget::GetCompileDefinitions(
}
}
- processCompileDefinitions(this, linkInterfaceCompileDefinitionsEntries, list,
- uniqueOptions, &dagChecker, config, debugDefines,
- language);
+ processOptions(this, entries, list, uniqueOptions, debugDefines,
+ "compile definitions", OptionsParse::None);
+
+ return list;
+}
+
+std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders(
+ const std::string& config, const std::string& language) const
+{
+ std::unordered_set<std::string> uniqueOptions;
+
+ cmGeneratorExpressionDAGChecker dagChecker(this, "PRECOMPILE_HEADERS",
+ nullptr, nullptr);
+
+ std::vector<std::string> debugProperties;
+ const char* debugProp =
+ this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+ if (debugProp) {
+ cmExpandList(debugProp, debugProperties);
+ }
+
+ bool debugDefines = !this->DebugPrecompileHeadersDone &&
+ std::find(debugProperties.begin(), debugProperties.end(),
+ "PRECOMPILE_HEADERS") != debugProperties.end();
+
+ if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
+ this->DebugPrecompileHeadersDone = true;
+ }
+
+ std::vector<EvaluatedTargetPropertyEntry> entries =
+ EvaluateTargetPropertyEntries(this, config, language, &dagChecker,
+ this->PrecompileHeadersEntries);
+
+ AddInterfaceEntries(this, config, "INTERFACE_PRECOMPILE_HEADERS", language,
+ &dagChecker, entries);
+
+ std::vector<BT<std::string>> list;
+ processOptions(this, entries, list, uniqueOptions, debugDefines,
+ "precompile headers", OptionsParse::None);
+
+ return list;
+}
+
+std::string cmGeneratorTarget::GetPchHeader(const std::string& config,
+ const std::string& language) const
+{
+ if (language != "C" && language != "CXX" && language != "OBJC" &&
+ language != "OBJCXX") {
+ return std::string();
+ }
+
+ if (this->GetPropertyAsBool("DISABLE_PRECOMPILE_HEADERS")) {
+ return std::string();
+ }
+ const cmGeneratorTarget* generatorTarget = this;
+ const char* pchReuseFrom =
+ generatorTarget->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
+
+ const auto inserted =
+ this->PchHeaders.insert(std::make_pair(language + config, ""));
+ if (inserted.second) {
+ const std::vector<BT<std::string>> headers =
+ this->GetPrecompileHeaders(config, language);
+ if (headers.empty() && !pchReuseFrom) {
+ return std::string();
+ }
+ std::string& filename = inserted.first->second;
+
+ if (pchReuseFrom) {
+ generatorTarget =
+ this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom);
+ }
+
+ filename = cmStrCat(
+ generatorTarget->LocalGenerator->GetCurrentBinaryDirectory(), "/");
+
+ const std::map<std::string, std::string> languageToExtension = {
+ { "C", ".h" },
+ { "CXX", ".hxx" },
+ { "OBJC", ".objc.h" },
+ { "OBJCXX", ".objcxx.hxx" }
+ };
+
+ filename = cmStrCat(filename, "CMakeFiles/", generatorTarget->GetName(),
+ ".dir/cmake_pch", languageToExtension.at(language));
+
+ const std::string filename_tmp = cmStrCat(filename, ".tmp");
+ if (!pchReuseFrom) {
+ auto pchPrologue = this->Makefile->GetDefinition("CMAKE_PCH_PROLOGUE");
+ auto pchEpilogue = this->Makefile->GetDefinition("CMAKE_PCH_EPILOGUE");
+
+ {
+ cmGeneratedFileStream file(
+ filename_tmp, false,
+ this->GetGlobalGenerator()->GetMakefileEncoding());
+ file << "/* generated by CMake */\n\n";
+ if (pchPrologue) {
+ file << pchPrologue << "\n";
+ }
+ if (this->GetGlobalGenerator()->IsXcode()) {
+ file << "#ifndef CMAKE_SKIP_PRECOMPILE_HEADERS\n";
+ }
+ if (language == "CXX") {
+ file << "#ifdef __cplusplus\n";
+ }
+ for (auto const& header_bt : headers) {
+ if (header_bt.Value.empty()) {
+ continue;
+ }
+ if (header_bt.Value[0] == '<' || header_bt.Value[0] == '\"') {
+ file << "#include " << header_bt.Value << "\n";
+ } else {
+ file << "#include \"" << header_bt.Value << "\"\n";
+ }
+ }
+ if (language == "CXX") {
+ file << "#endif // __cplusplus\n";
+ }
+ if (this->GetGlobalGenerator()->IsXcode()) {
+ file << "#endif // CMAKE_SKIP_PRECOMPILE_HEADERS\n";
+ }
+ if (pchEpilogue) {
+ file << pchEpilogue << "\n";
+ }
+ }
+ cmSystemTools::MoveFileIfDifferent(filename_tmp, filename);
+ }
+ }
+ return inserted.first->second;
+}
+
+std::string cmGeneratorTarget::GetPchSource(const std::string& config,
+ const std::string& language) const
+{
+ if (language != "C" && language != "CXX" && language != "OBJC" &&
+ language != "OBJCXX") {
+ return std::string();
+ }
+ const auto inserted =
+ this->PchSources.insert(std::make_pair(language + config, ""));
+ if (inserted.second) {
+ const std::string pchHeader = this->GetPchHeader(config, language);
+ if (pchHeader.empty()) {
+ return std::string();
+ }
+ std::string& filename = inserted.first->second;
+
+ const cmGeneratorTarget* generatorTarget = this;
+ const char* pchReuseFrom =
+ generatorTarget->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
+ if (pchReuseFrom) {
+ generatorTarget =
+ this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom);
+ }
+
+ filename =
+ cmStrCat(generatorTarget->LocalGenerator->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/", generatorTarget->GetName(), ".dir/cmake_pch");
+
+ // For GCC the source extension will be tranformed into .h[xx].gch
+ if (!this->Makefile->IsOn("CMAKE_LINK_PCH")) {
+ const std::map<std::string, std::string> languageToExtension = {
+ { "C", ".h.c" },
+ { "CXX", ".hxx.cxx" },
+ { "OBJC", ".objc.h.m" },
+ { "OBJCXX", ".objcxx.hxx.mm" }
+ };
+
+ filename += languageToExtension.at(language);
+ } else {
+ const std::map<std::string, std::string> languageToExtension = {
+ { "C", ".c" }, { "CXX", ".cxx" }, { "OBJC", ".m" }, { "OBJCXX", ".mm" }
+ };
+
+ filename += languageToExtension.at(language);
+ }
- cmDeleteAll(linkInterfaceCompileDefinitionsEntries);
+ const std::string filename_tmp = cmStrCat(filename, ".tmp");
+ if (!pchReuseFrom) {
+ {
+ cmGeneratedFileStream file(filename_tmp);
+ file << "/* generated by CMake */\n";
+ }
+ cmSystemTools::MoveFileIfDifferent(filename_tmp, filename);
+ }
+ }
+ return inserted.first->second;
+}
+
+std::string cmGeneratorTarget::GetPchFileObject(const std::string& config,
+ const std::string& language)
+{
+ if (language != "C" && language != "CXX" && language != "OBJC" &&
+ language != "OBJCXX") {
+ return std::string();
+ }
+ const auto inserted =
+ this->PchObjectFiles.insert(std::make_pair(language + config, ""));
+ if (inserted.second) {
+ const std::string pchSource = this->GetPchSource(config, language);
+ if (pchSource.empty()) {
+ return std::string();
+ }
+ std::string& filename = inserted.first->second;
+
+ this->AddSource(pchSource, true);
+
+ auto pchSf = this->Makefile->GetOrCreateSource(
+ pchSource, false, cmSourceFileLocationKind::Known);
+
+ filename = cmStrCat(this->ObjectDirectory, this->GetObjectName(pchSf));
+ }
+ return inserted.first->second;
+}
+
+std::string cmGeneratorTarget::GetPchFile(const std::string& config,
+ const std::string& language)
+{
+ const auto inserted =
+ this->PchFiles.insert(std::make_pair(language + config, ""));
+ if (inserted.second) {
+ std::string& pchFile = inserted.first->second;
+
+ const std::string pchExtension =
+ this->Makefile->GetSafeDefinition("CMAKE_PCH_EXTENSION");
+
+ if (this->Makefile->IsOn("CMAKE_LINK_PCH")) {
+ auto replaceExtension = [](const std::string& str,
+ const std::string& ext) -> std::string {
+ auto dot_pos = str.rfind('.');
+ std::string result;
+ if (dot_pos != std::string::npos) {
+ result = str.substr(0, dot_pos);
+ }
+ result += ext;
+ return result;
+ };
+
+ cmGeneratorTarget* generatorTarget = this;
+ const char* pchReuseFrom =
+ generatorTarget->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
+ if (pchReuseFrom) {
+ generatorTarget =
+ this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom);
+ }
+
+ const std::string pchFileObject =
+ generatorTarget->GetPchFileObject(config, language);
+ if (!pchExtension.empty()) {
+ pchFile = replaceExtension(pchFileObject, pchExtension);
+ }
+ } else {
+ pchFile = this->GetPchHeader(config, language);
+ pchFile += pchExtension;
+ }
+ }
+ return inserted.first->second;
+}
+
+std::string cmGeneratorTarget::GetPchCreateCompileOptions(
+ const std::string& config, const std::string& language)
+{
+ const auto inserted = this->PchCreateCompileOptions.insert(
+ std::make_pair(language + config, ""));
+ if (inserted.second) {
+ std::string& createOptionList = inserted.first->second;
+
+ const std::string createOptVar =
+ cmStrCat("CMAKE_", language, "_COMPILE_OPTIONS_CREATE_PCH");
+ createOptionList = this->Makefile->GetSafeDefinition(createOptVar);
+
+ const std::string pchHeader = this->GetPchHeader(config, language);
+ const std::string pchFile = this->GetPchFile(config, language);
+
+ cmSystemTools::ReplaceString(createOptionList, "<PCH_HEADER>", pchHeader);
+ cmSystemTools::ReplaceString(createOptionList, "<PCH_FILE>", pchFile);
+ }
+ return inserted.first->second;
+}
+
+std::string cmGeneratorTarget::GetPchUseCompileOptions(
+ const std::string& config, const std::string& language)
+{
+ const auto inserted =
+ this->PchUseCompileOptions.insert(std::make_pair(language + config, ""));
+ if (inserted.second) {
+ std::string& useOptionList = inserted.first->second;
+
+ const std::string useOptVar =
+ cmStrCat("CMAKE_", language, "_COMPILE_OPTIONS_USE_PCH");
+ useOptionList = this->Makefile->GetSafeDefinition(useOptVar);
+
+ const std::string pchHeader = this->GetPchHeader(config, language);
+ const std::string pchFile = this->GetPchFile(config, language);
+
+ cmSystemTools::ReplaceString(useOptionList, "<PCH_HEADER>", pchHeader);
+ cmSystemTools::ReplaceString(useOptionList, "<PCH_FILE>", pchFile);
+ }
+ return inserted.first->second;
+}
+
+void cmGeneratorTarget::AddSourceFileToUnityBatch(
+ const std::string& sourceFilename)
+{
+ this->UnityBatchedSourceFiles.insert(sourceFilename);
+}
+
+bool cmGeneratorTarget::IsSourceFilePartOfUnityBatch(
+ const std::string& sourceFilename) const
+{
+ if (!this->GetPropertyAsBool("UNITY_BUILD")) {
+ return false;
+ }
+
+ return this->UnityBatchedSourceFiles.find(sourceFilename) !=
+ this->UnityBatchedSourceFiles.end();
+}
+
+void cmGeneratorTarget::GetLinkOptions(std::vector<std::string>& result,
+ const std::string& config,
+ const std::string& language) const
+{
+ std::vector<BT<std::string>> tmp = this->GetLinkOptions(config, language);
+ result.reserve(tmp.size());
+ for (BT<std::string>& v : tmp) {
+ result.emplace_back(std::move(v.Value));
+ }
+}
+
+std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
+ std::string const& config, std::string const& language) const
+{
+ std::vector<BT<std::string>> result;
+ std::unordered_set<std::string> uniqueOptions;
+
+ cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_OPTIONS", nullptr,
+ nullptr);
+
+ std::vector<std::string> debugProperties;
+ const char* debugProp =
+ this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+ if (debugProp) {
+ cmExpandList(debugProp, debugProperties);
+ }
+
+ bool debugOptions =
+ !this->DebugLinkOptionsDone && cmContains(debugProperties, "LINK_OPTIONS");
+
+ if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
+ this->DebugLinkOptionsDone = true;
+ }
+
+ std::vector<EvaluatedTargetPropertyEntry> entries =
+ EvaluateTargetPropertyEntries(this, config, language, &dagChecker,
+ this->LinkOptionsEntries);
+
+ AddInterfaceEntries(this, config, "INTERFACE_LINK_OPTIONS", language,
+ &dagChecker, entries);
+
+ processOptions(this, entries, result, uniqueOptions, debugOptions,
+ "link options", OptionsParse::Shell);
+
+ // Last step: replace "LINKER:" prefixed elements by
+ // actual linker wrapper
+ const std::string wrapper(this->Makefile->GetSafeDefinition(
+ "CMAKE_" + language + "_LINKER_WRAPPER_FLAG"));
+ std::vector<std::string> wrapperFlag = cmExpandedList(wrapper);
+ const std::string wrapperSep(this->Makefile->GetSafeDefinition(
+ "CMAKE_" + language + "_LINKER_WRAPPER_FLAG_SEP"));
+ bool concatFlagAndArgs = true;
+ if (!wrapperFlag.empty() && wrapperFlag.back() == " ") {
+ concatFlagAndArgs = false;
+ wrapperFlag.pop_back();
+ }
+
+ const std::string LINKER{ "LINKER:" };
+ const std::string SHELL{ "SHELL:" };
+ const std::string LINKER_SHELL = LINKER + SHELL;
+
+ std::vector<BT<std::string>>::iterator entry;
+ while ((entry = std::find_if(result.begin(), result.end(),
+ [&LINKER](BT<std::string> const& item) -> bool {
+ return item.Value.compare(0, LINKER.length(),
+ LINKER) == 0;
+ })) != result.end()) {
+ std::string value = std::move(entry->Value);
+ cmListFileBacktrace bt = std::move(entry->Backtrace);
+ entry = result.erase(entry);
+
+ std::vector<std::string> linkerOptions;
+ if (value.compare(0, LINKER_SHELL.length(), LINKER_SHELL) == 0) {
+ cmSystemTools::ParseUnixCommandLine(
+ value.c_str() + LINKER_SHELL.length(), linkerOptions);
+ } else {
+ linkerOptions = cmTokenize(value.substr(LINKER.length()), ",");
+ }
+
+ if (linkerOptions.empty() ||
+ (linkerOptions.size() == 1 && linkerOptions.front().empty())) {
+ continue;
+ }
+
+ // for now, raise an error if prefix SHELL: is part of arguments
+ if (std::find_if(linkerOptions.begin(), linkerOptions.end(),
+ [&SHELL](const std::string& item) -> bool {
+ return item.find(SHELL) != std::string::npos;
+ }) != linkerOptions.end()) {
+ this->LocalGenerator->GetCMakeInstance()->IssueMessage(
+ MessageType::FATAL_ERROR,
+ "'SHELL:' prefix is not supported as part of 'LINKER:' arguments.",
+ this->GetBacktrace());
+ return result;
+ }
+
+ std::vector<BT<std::string>> options;
+ if (wrapperFlag.empty()) {
+ // nothing specified, insert elements as is
+ options.reserve(linkerOptions.size());
+ for (std::string& o : linkerOptions) {
+ options.emplace_back(std::move(o), bt);
+ }
+ } else {
+ if (!wrapperSep.empty()) {
+ if (concatFlagAndArgs) {
+ // insert flag elements except last one
+ for (auto i = wrapperFlag.begin(); i != wrapperFlag.end() - 1; ++i) {
+ options.emplace_back(*i, bt);
+ }
+ // concatenate last flag element and all LINKER list values
+ // in one option
+ options.emplace_back(
+ wrapperFlag.back() + cmJoin(linkerOptions, wrapperSep), bt);
+ } else {
+ for (std::string const& i : wrapperFlag) {
+ options.emplace_back(i, bt);
+ }
+ // concatenate all LINKER list values in one option
+ options.emplace_back(cmJoin(linkerOptions, wrapperSep), bt);
+ }
+ } else {
+ // prefix each element of LINKER list with wrapper
+ if (concatFlagAndArgs) {
+ std::transform(linkerOptions.begin(), linkerOptions.end(),
+ linkerOptions.begin(),
+ [&wrapperFlag](std::string const& o) -> std::string {
+ return wrapperFlag.back() + o;
+ });
+ }
+ for (std::string& o : linkerOptions) {
+ for (auto i = wrapperFlag.begin(),
+ e = concatFlagAndArgs ? wrapperFlag.end() - 1
+ : wrapperFlag.end();
+ i != e; ++i) {
+ options.emplace_back(*i, bt);
+ }
+ options.emplace_back(std::move(o), bt);
+ }
+ }
+ }
+ result.insert(entry, options.begin(), options.end());
+ }
+ return result;
+}
+
+void cmGeneratorTarget::GetStaticLibraryLinkOptions(
+ std::vector<std::string>& result, const std::string& config,
+ const std::string& language) const
+{
+ std::vector<BT<std::string>> tmp =
+ this->GetStaticLibraryLinkOptions(config, language);
+ result.reserve(tmp.size());
+ for (BT<std::string>& v : tmp) {
+ result.emplace_back(std::move(v.Value));
+ }
+}
+
+std::vector<BT<std::string>> cmGeneratorTarget::GetStaticLibraryLinkOptions(
+ std::string const& config, std::string const& language) const
+{
+ std::vector<BT<std::string>> result;
+ std::unordered_set<std::string> uniqueOptions;
+
+ cmGeneratorExpressionDAGChecker dagChecker(this, "STATIC_LIBRARY_OPTIONS",
+ nullptr, nullptr);
+
+ std::vector<EvaluatedTargetPropertyEntry> entries;
+ if (const char* linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) {
+ std::vector<std::string> options = cmExpandedList(linkOptions);
+ for (const auto& option : options) {
+ std::unique_ptr<TargetPropertyEntry> entry(
+ CreateTargetPropertyEntry(option));
+ entries.emplace_back(EvaluateTargetPropertyEntry(
+ this, config, language, &dagChecker, entry.get()));
+ }
+ }
+ processOptions(this, entries, result, uniqueOptions, false,
+ "static library link options", OptionsParse::Shell);
+
+ return result;
+}
+
+namespace {
+void processLinkDirectories(cmGeneratorTarget const* tgt,
+ std::vector<EvaluatedTargetPropertyEntry>& entries,
+ std::vector<BT<std::string>>& directories,
+ std::unordered_set<std::string>& uniqueDirectories,
+ bool debugDirectories)
+{
+ for (EvaluatedTargetPropertyEntry& entry : entries) {
+ cmLinkImplItem const& item = entry.LinkImplItem;
+ std::string const& targetName = item.AsStr();
+
+ std::string usedDirectories;
+ for (std::string& entryDirectory : entry.Values) {
+ if (!cmSystemTools::FileIsFullPath(entryDirectory)) {
+ std::ostringstream e;
+ bool noMessage = false;
+ MessageType messageType = MessageType::FATAL_ERROR;
+ if (!targetName.empty()) {
+ /* clang-format off */
+ e << "Target \"" << targetName << "\" contains relative "
+ "path in its INTERFACE_LINK_DIRECTORIES:\n"
+ " \"" << entryDirectory << "\"";
+ /* clang-format on */
+ } else {
+ switch (tgt->GetPolicyStatusCMP0081()) {
+ case cmPolicies::WARN: {
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0081) << "\n";
+ messageType = MessageType::AUTHOR_WARNING;
+ } break;
+ case cmPolicies::OLD:
+ noMessage = true;
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ // Issue the fatal message.
+ break;
+ }
+ e << "Found relative path while evaluating link directories of "
+ "\""
+ << tgt->GetName() << "\":\n \"" << entryDirectory << "\"\n";
+ }
+ if (!noMessage) {
+ tgt->GetLocalGenerator()->IssueMessage(messageType, e.str());
+ if (messageType == MessageType::FATAL_ERROR) {
+ return;
+ }
+ }
+ }
+
+ // Sanitize the path the same way the link_directories command does
+ // in case projects set the LINK_DIRECTORIES property directly.
+ cmSystemTools::ConvertToUnixSlashes(entryDirectory);
+ if (uniqueDirectories.insert(entryDirectory).second) {
+ directories.emplace_back(entryDirectory, entry.Backtrace);
+ if (debugDirectories) {
+ usedDirectories += " * " + entryDirectory + "\n";
+ }
+ }
+ }
+ if (!usedDirectories.empty()) {
+ tgt->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
+ MessageType::LOG,
+ std::string("Used link directories for target ") + tgt->GetName() +
+ ":\n" + usedDirectories,
+ entry.Backtrace);
+ }
+ }
+}
+}
+
+void cmGeneratorTarget::GetLinkDirectories(std::vector<std::string>& result,
+ const std::string& config,
+ const std::string& language) const
+{
+ std::vector<BT<std::string>> tmp =
+ this->GetLinkDirectories(config, language);
+ result.reserve(tmp.size());
+ for (BT<std::string>& v : tmp) {
+ result.emplace_back(std::move(v.Value));
+ }
+}
+
+std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories(
+ std::string const& config, std::string const& language) const
+{
+ std::vector<BT<std::string>> result;
+ std::unordered_set<std::string> uniqueDirectories;
+
+ cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_DIRECTORIES", nullptr,
+ nullptr);
+
+ std::vector<std::string> debugProperties;
+ const char* debugProp =
+ this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+ if (debugProp) {
+ cmExpandList(debugProp, debugProperties);
+ }
+
+ bool debugDirectories = !this->DebugLinkDirectoriesDone &&
+ cmContains(debugProperties, "LINK_DIRECTORIES");
+
+ if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
+ this->DebugLinkDirectoriesDone = true;
+ }
+
+ std::vector<EvaluatedTargetPropertyEntry> entries =
+ EvaluateTargetPropertyEntries(this, config, language, &dagChecker,
+ this->LinkDirectoriesEntries);
+
+ AddInterfaceEntries(this, config, "INTERFACE_LINK_DIRECTORIES", language,
+ &dagChecker, entries);
+
+ processLinkDirectories(this, entries, result, uniqueDirectories,
+ debugDirectories);
+
+ return result;
+}
+
+void cmGeneratorTarget::GetLinkDepends(std::vector<std::string>& result,
+ const std::string& config,
+ const std::string& language) const
+{
+ std::vector<BT<std::string>> tmp = this->GetLinkDepends(config, language);
+ result.reserve(tmp.size());
+ for (BT<std::string>& v : tmp) {
+ result.emplace_back(std::move(v.Value));
+ }
+}
+
+std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDepends(
+ std::string const& config, std::string const& language) const
+{
+ std::vector<BT<std::string>> result;
+ std::unordered_set<std::string> uniqueOptions;
+ cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_DEPENDS", nullptr,
+ nullptr);
+
+ std::vector<EvaluatedTargetPropertyEntry> entries;
+ if (const char* linkDepends = this->GetProperty("LINK_DEPENDS")) {
+ std::vector<std::string> depends = cmExpandedList(linkDepends);
+ for (const auto& depend : depends) {
+ std::unique_ptr<TargetPropertyEntry> entry(
+ CreateTargetPropertyEntry(depend));
+ entries.emplace_back(EvaluateTargetPropertyEntry(
+ this, config, language, &dagChecker, entry.get()));
+ }
+ }
+ AddInterfaceEntries(this, config, "INTERFACE_LINK_DEPENDS", language,
+ &dagChecker, entries);
+
+ processOptions(this, entries, result, uniqueOptions, false, "link depends",
+ OptionsParse::None);
+
+ return result;
}
void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const
@@ -2876,17 +3956,13 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const
cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator();
// Get the names.
- std::string name;
- std::string soName;
- std::string realName;
- std::string impName;
- std::string pdbName;
+ cmGeneratorTarget::Names targetNames;
if (this->GetType() == cmStateEnums::EXECUTABLE) {
- this->GetExecutableNames(name, realName, impName, pdbName, config);
+ targetNames = this->GetExecutableNames(config);
} else if (this->GetType() == cmStateEnums::STATIC_LIBRARY ||
this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->GetType() == cmStateEnums::MODULE_LIBRARY) {
- this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
+ targetNames = this->GetLibraryNames(config);
} else {
return;
}
@@ -2897,45 +3973,35 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const
// Add each name.
std::string f;
- if (!name.empty()) {
- f = dir;
- f += "/";
- f += name;
+ if (!targetNames.Output.empty()) {
+ f = cmStrCat(dir, '/', targetNames.Output);
gg->AddToManifest(f);
}
- if (!soName.empty()) {
- f = dir;
- f += "/";
- f += soName;
+ if (!targetNames.SharedObject.empty()) {
+ f = cmStrCat(dir, '/', targetNames.SharedObject);
gg->AddToManifest(f);
}
- if (!realName.empty()) {
- f = dir;
- f += "/";
- f += realName;
+ if (!targetNames.Real.empty()) {
+ f = cmStrCat(dir, '/', targetNames.Real);
gg->AddToManifest(f);
}
- if (!pdbName.empty()) {
- f = dir;
- f += "/";
- f += pdbName;
+ if (!targetNames.PDB.empty()) {
+ f = cmStrCat(dir, '/', targetNames.PDB);
gg->AddToManifest(f);
}
- if (!impName.empty()) {
- f = this->GetDirectory(config, cmStateEnums::ImportLibraryArtifact);
- f += "/";
- f += impName;
+ if (!targetNames.ImportLibrary.empty()) {
+ f =
+ cmStrCat(this->GetDirectory(config, cmStateEnums::ImportLibraryArtifact),
+ '/', targetNames.ImportLibrary);
gg->AddToManifest(f);
}
}
bool cmGeneratorTarget::ComputeCompileFeatures(std::string const& config) const
{
- std::vector<std::string> features;
- this->GetCompileFeatures(features, config);
- for (std::vector<std::string>::const_iterator it = features.begin();
- it != features.end(); ++it) {
- if (!this->Makefile->AddRequiredTargetFeature(this->Target, *it)) {
+ std::vector<BT<std::string>> features = this->GetCompileFeatures(config);
+ for (BT<std::string> const& f : features) {
+ if (!this->Makefile->AddRequiredTargetFeature(this->Target, f.Value)) {
return false;
}
}
@@ -2966,11 +4032,10 @@ std::string cmGeneratorTarget::NormalGetFullPath(
const std::string& config, cmStateEnums::ArtifactType artifact,
bool realname) const
{
- std::string fpath = this->GetDirectory(config, artifact);
- fpath += "/";
+ std::string fpath = cmStrCat(this->GetDirectory(config, artifact), '/');
if (this->IsAppBundleOnApple()) {
- fpath = this->BuildBundleDirectory(fpath, config, FullLevel);
- fpath += "/";
+ fpath =
+ cmStrCat(this->BuildBundleDirectory(fpath, config, FullLevel), '/');
}
// Add the full name of the target.
@@ -2997,44 +4062,31 @@ std::string cmGeneratorTarget::NormalGetRealName(
// TODO: Split cmTarget into a class hierarchy to get compile-time
// enforcement of the limited imported target API.
if (this->IsImported()) {
- std::string msg = "NormalGetRealName called on imported target: ";
- msg += this->GetName();
- this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
+ std::string msg = cmStrCat("NormalGetRealName called on imported target: ",
+ this->GetName());
+ this->LocalGenerator->IssueMessage(MessageType::INTERNAL_ERROR, msg);
}
if (this->GetType() == cmStateEnums::EXECUTABLE) {
// Compute the real name that will be built.
- std::string name;
- std::string realName;
- std::string impName;
- std::string pdbName;
- this->GetExecutableNames(name, realName, impName, pdbName, config);
- return realName;
+ return this->GetExecutableNames(config).Real;
}
// Compute the real name that will be built.
- std::string name;
- std::string soName;
- std::string realName;
- std::string impName;
- std::string pdbName;
- this->GetLibraryNames(name, soName, realName, impName, pdbName, config);
- return realName;
-}
-
-void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName,
- std::string& realName,
- std::string& impName,
- std::string& pdbName,
- const std::string& config) const
+ return this->GetLibraryNames(config).Real;
+}
+
+cmGeneratorTarget::Names cmGeneratorTarget::GetLibraryNames(
+ const std::string& config) const
{
+ cmGeneratorTarget::Names targetNames;
+
// This should not be called for imported targets.
// TODO: Split cmTarget into a class hierarchy to get compile-time
// enforcement of the limited imported target API.
if (this->IsImported()) {
- std::string msg = "GetLibraryNames called on imported target: ";
- msg += this->GetName();
- this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
- return;
+ std::string msg =
+ cmStrCat("GetLibraryNames called on imported target: ", this->GetName());
+ this->LocalGenerator->IssueMessage(MessageType::INTERNAL_ERROR, msg);
}
// Check for library version properties.
@@ -3045,8 +4097,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName,
this->IsFrameworkOnApple()) {
// Versioning is supported only for shared libraries and modules,
// and then only when the platform supports an soname flag.
- version = CM_NULLPTR;
- soversion = CM_NULLPTR;
+ version = nullptr;
+ soversion = nullptr;
}
if (version && !soversion) {
// The soversion must be set if the library version is set. Use
@@ -3060,57 +4112,58 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName,
// Get the components of the library name.
std::string prefix;
- std::string base;
std::string suffix;
this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact,
- prefix, base, suffix);
+ prefix, targetNames.Base, suffix);
// The library name.
- name = prefix + base + suffix;
+ targetNames.Output = prefix + targetNames.Base + suffix;
if (this->IsFrameworkOnApple()) {
- realName = prefix;
- if (!this->Makefile->PlatformIsAppleIos()) {
- realName += "Versions/";
- realName += this->GetFrameworkVersion();
- realName += "/";
- }
- realName += base;
- soName = realName;
+ targetNames.Real = prefix;
+ if (!this->Makefile->PlatformIsAppleEmbedded()) {
+ targetNames.Real += "Versions/";
+ targetNames.Real += this->GetFrameworkVersion();
+ targetNames.Real += "/";
+ }
+ targetNames.Real += targetNames.Base;
+ targetNames.SharedObject = targetNames.Real;
} else {
// The library's soname.
- this->ComputeVersionedName(soName, prefix, base, suffix, name, soversion);
+ this->ComputeVersionedName(targetNames.SharedObject, prefix,
+ targetNames.Base, suffix, targetNames.Output,
+ soversion);
// The library's real name on disk.
- this->ComputeVersionedName(realName, prefix, base, suffix, name, version);
+ this->ComputeVersionedName(targetNames.Real, prefix, targetNames.Base,
+ suffix, targetNames.Output, version);
}
// The import library name.
if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->GetType() == cmStateEnums::MODULE_LIBRARY) {
- impName =
+ targetNames.ImportLibrary =
this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact);
- } else {
- impName = "";
}
// The program database file name.
- pdbName = this->GetPDBName(config);
+ targetNames.PDB = this->GetPDBName(config);
+
+ return targetNames;
}
-void cmGeneratorTarget::GetExecutableNames(std::string& name,
- std::string& realName,
- std::string& impName,
- std::string& pdbName,
- const std::string& config) const
+cmGeneratorTarget::Names cmGeneratorTarget::GetExecutableNames(
+ const std::string& config) const
{
+ cmGeneratorTarget::Names targetNames;
+
// This should not be called for imported targets.
// TODO: Split cmTarget into a class hierarchy to get compile-time
// enforcement of the limited imported target API.
if (this->IsImported()) {
- std::string msg = "GetExecutableNames called on imported target: ";
- msg += this->GetName();
- this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
+ std::string msg = cmStrCat(
+ "GetExecutableNames called on imported target: ", this->GetName());
+ this->LocalGenerator->IssueMessage(MessageType::INTERNAL_ERROR, msg);
}
// This versioning is supported only for executables and then only
@@ -3122,40 +4175,41 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name,
const char* version = this->GetProperty("VERSION");
if (this->GetType() != cmStateEnums::EXECUTABLE ||
this->Makefile->IsOn("XCODE")) {
- version = CM_NULLPTR;
+ version = nullptr;
}
#endif
// Get the components of the executable name.
std::string prefix;
- std::string base;
std::string suffix;
this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact,
- prefix, base, suffix);
+ prefix, targetNames.Base, suffix);
// The executable name.
- name = prefix + base + suffix;
+ targetNames.Output = prefix + targetNames.Base + suffix;
// The executable's real name on disk.
#if defined(__CYGWIN__)
- realName = prefix + base;
+ targetNames.Real = prefix + targetNames.Base;
#else
- realName = name;
+ targetNames.Real = targetNames.Output;
#endif
if (version) {
- realName += "-";
- realName += version;
+ targetNames.Real += "-";
+ targetNames.Real += version;
}
#if defined(__CYGWIN__)
- realName += suffix;
+ targetNames.Real += suffix;
#endif
// The import library name.
- impName =
+ targetNames.ImportLibrary =
this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact);
// The program database file name.
- pdbName = this->GetPDBName(config);
+ targetNames.PDB = this->GetPDBName(config);
+
+ return targetNames;
}
std::string cmGeneratorTarget::GetFullNameInternal(
@@ -3168,14 +4222,12 @@ std::string cmGeneratorTarget::GetFullNameInternal(
return prefix + base + suffix;
}
-const char* cmGeneratorTarget::ImportedGetLocation(
+std::string cmGeneratorTarget::ImportedGetLocation(
const std::string& config) const
{
- static std::string location;
assert(this->IsImported());
- location = this->Target->ImportedGetFullPath(
+ return this->Target->ImportedGetFullPath(
config, cmStateEnums::RuntimeBinaryArtifact);
- return location.c_str();
}
std::string cmGeneratorTarget::GetFullNameImported(
@@ -3194,9 +4246,9 @@ void cmGeneratorTarget::GetFullNameInternal(
this->GetType() != cmStateEnums::SHARED_LIBRARY &&
this->GetType() != cmStateEnums::MODULE_LIBRARY &&
this->GetType() != cmStateEnums::EXECUTABLE) {
- outPrefix = "";
+ outPrefix.clear();
outBase = this->GetName();
- outSuffix = "";
+ outSuffix.clear();
return;
}
@@ -3205,14 +4257,18 @@ void cmGeneratorTarget::GetFullNameInternal(
// Return an empty name for the import library if this platform
// does not support import libraries.
- if (isImportedLibraryArtifact &&
- !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) {
- outPrefix = "";
- outBase = "";
- outSuffix = "";
+ if (isImportedLibraryArtifact && !this->NeedImportLibraryName(config)) {
+ outPrefix.clear();
+ outBase.clear();
+ outSuffix.clear();
return;
}
+ // retrieve prefix and suffix
+ std::string ll = this->GetLinkerLanguage(config);
+ const char* targetPrefix = this->GetFilePrefixInternal(config, artifact, ll);
+ const char* targetSuffix = this->GetFileSuffixInternal(config, artifact, ll);
+
// The implib option is only allowed for shared libraries, module
// libraries, and executables.
if (this->GetType() != cmStateEnums::SHARED_LIBRARY &&
@@ -3222,62 +4278,21 @@ void cmGeneratorTarget::GetFullNameInternal(
}
// Compute the full name for main target types.
- const char* targetPrefix =
- (isImportedLibraryArtifact ? this->GetProperty("IMPORT_PREFIX")
- : this->GetProperty("PREFIX"));
- const char* targetSuffix =
- (isImportedLibraryArtifact ? this->GetProperty("IMPORT_SUFFIX")
- : this->GetProperty("SUFFIX"));
- const char* configPostfix = CM_NULLPTR;
- if (!config.empty()) {
- std::string configProp = cmSystemTools::UpperCase(config);
- configProp += "_POSTFIX";
- configPostfix = this->GetProperty(configProp);
- // Mac application bundles and frameworks have no postfix.
- if (configPostfix &&
- (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) {
- configPostfix = CM_NULLPTR;
- }
- }
- const char* prefixVar = this->Target->GetPrefixVariableInternal(artifact);
- const char* suffixVar = this->Target->GetSuffixVariableInternal(artifact);
-
- // Check for language-specific default prefix and suffix.
- std::string ll = this->GetLinkerLanguage(config);
- if (!ll.empty()) {
- if (!targetSuffix && suffixVar && *suffixVar) {
- std::string langSuff = suffixVar + std::string("_") + ll;
- targetSuffix = this->Makefile->GetDefinition(langSuff);
- }
- if (!targetPrefix && prefixVar && *prefixVar) {
- std::string langPrefix = prefixVar + std::string("_") + ll;
- targetPrefix = this->Makefile->GetDefinition(langPrefix);
- }
- }
-
- // if there is no prefix on the target use the cmake definition
- if (!targetPrefix && prefixVar) {
- targetPrefix = this->Makefile->GetSafeDefinition(prefixVar);
- }
- // if there is no suffix on the target use the cmake definition
- if (!targetSuffix && suffixVar) {
- targetSuffix = this->Makefile->GetSafeDefinition(suffixVar);
- }
+ const std::string configPostfix = this->GetFilePostfix(config);
// frameworks have directory prefix but no suffix
std::string fw_prefix;
if (this->IsFrameworkOnApple()) {
- fw_prefix = this->GetFrameworkDirectory(config, ContentLevel);
- fw_prefix += "/";
+ fw_prefix =
+ cmStrCat(this->GetFrameworkDirectory(config, ContentLevel), '/');
targetPrefix = fw_prefix.c_str();
- targetSuffix = CM_NULLPTR;
+ targetSuffix = nullptr;
}
if (this->IsCFBundleOnApple()) {
- fw_prefix = this->GetCFBundleDirectory(config, FullLevel);
- fw_prefix += "/";
+ fw_prefix = cmStrCat(this->GetCFBundleDirectory(config, FullLevel), '/');
targetPrefix = fw_prefix.c_str();
- targetSuffix = CM_NULLPTR;
+ targetSuffix = nullptr;
}
// Begin the final name with the prefix.
@@ -3287,7 +4302,7 @@ void cmGeneratorTarget::GetFullNameInternal(
outBase += this->GetOutputName(config, artifact);
// Append the per-configuration postfix.
- outBase += configPostfix ? configPostfix : "";
+ outBase += configPostfix;
// Name shared libraries with their version number on some platforms.
if (const char* soversion = this->GetProperty("SOVERSION")) {
@@ -3309,6 +4324,31 @@ std::string cmGeneratorTarget::GetLinkerLanguage(
return this->GetLinkClosure(config)->LinkerLanguage;
}
+std::string cmGeneratorTarget::GetPDBOutputName(
+ const std::string& config) const
+{
+ std::string base =
+ this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact);
+
+ std::vector<std::string> props;
+ std::string configUpper = cmSystemTools::UpperCase(config);
+ if (!configUpper.empty()) {
+ // PDB_NAME_<CONFIG>
+ props.push_back("PDB_NAME_" + configUpper);
+ }
+
+ // PDB_NAME
+ props.emplace_back("PDB_NAME");
+
+ for (std::string const& p : props) {
+ if (const char* outName = this->GetProperty(p)) {
+ base = outName;
+ break;
+ }
+ }
+ return base;
+}
+
std::string cmGeneratorTarget::GetPDBName(const std::string& config) const
{
std::string prefix;
@@ -3325,11 +4365,10 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const
}
// PDB_NAME
- props.push_back("PDB_NAME");
+ props.emplace_back("PDB_NAME");
- for (std::vector<std::string>::const_iterator i = props.begin();
- i != props.end(); ++i) {
- if (const char* outName = this->GetProperty(*i)) {
+ for (std::string const& p : props) {
+ if (const char* outName = this->GetProperty(p)) {
base = outName;
break;
}
@@ -3346,6 +4385,13 @@ std::string cmGeneratorTarget::GetObjectDirectory(
// find and replace $(PROJECT_NAME) xcode placeholder
const std::string projectName = this->LocalGenerator->GetProjectName();
cmSystemTools::ReplaceString(obj_dir, "$(PROJECT_NAME)", projectName);
+ // Replace Xcode's placeholder for the object file directory since
+ // installation and export scripts need to know the real directory.
+ // Xcode has build-time settings (e.g. for sanitizers) that affect this,
+ // but we use the default here. Users that want to enable sanitizers
+ // will do so at the cost of object library installation and export.
+ cmSystemTools::ReplaceString(obj_dir, "$(OBJECT_FILE_DIR_normal:base)",
+ "Objects-normal");
#endif
return obj_dir;
}
@@ -3357,20 +4403,15 @@ void cmGeneratorTarget::GetTargetObjectNames(
this->GetObjectSources(objectSources, config);
std::map<cmSourceFile const*, std::string> mapping;
- for (std::vector<cmSourceFile const*>::const_iterator it =
- objectSources.begin();
- it != objectSources.end(); ++it) {
- mapping[*it];
+ for (cmSourceFile const* sf : objectSources) {
+ mapping[sf];
}
this->LocalGenerator->ComputeObjectFilenames(mapping, this);
- for (std::vector<cmSourceFile const*>::const_iterator it =
- objectSources.begin();
- it != objectSources.end(); ++it) {
+ for (cmSourceFile const* src : objectSources) {
// Find the object file name corresponding to this source file.
- std::map<cmSourceFile const*, std::string>::const_iterator map_it =
- mapping.find(*it);
+ auto map_it = mapping.find(src);
// It must exist because we populated the mapping just above.
assert(!map_it->second.empty());
objects.push_back(map_it->second);
@@ -3382,8 +4423,9 @@ bool cmGeneratorTarget::StrictTargetComparison::operator()(
{
int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str());
if (nameResult == 0) {
- return strcmp(t1->GetLocalGenerator()->GetCurrentBinaryDirectory(),
- t2->GetLocalGenerator()->GetCurrentBinaryDirectory()) < 0;
+ return strcmp(
+ t1->GetLocalGenerator()->GetCurrentBinaryDirectory().c_str(),
+ t2->GetLocalGenerator()->GetCurrentBinaryDirectory().c_str()) < 0;
}
return nameResult < 0;
}
@@ -3393,8 +4435,7 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
{
struct SourceFileFlags flags;
this->ConstructSourceFileFlags();
- std::map<cmSourceFile const*, SourceFileFlags>::iterator si =
- this->SourceFlagsMap.find(sf);
+ auto si = this->SourceFlagsMap.find(sf);
if (si != this->SourceFlagsMap.end()) {
flags = si->second;
} else {
@@ -3409,7 +4450,7 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
if (stripResources) {
flags.MacFolder = "";
}
- } else if (cmSystemTools::StringStartsWith(location, "Resources/")) {
+ } else if (cmHasLiteralPrefix(location, "Resources/")) {
flags.Type = cmGeneratorTarget::SourceFileTypeDeepResource;
if (stripResources) {
flags.MacFolder += strlen("Resources/");
@@ -3431,11 +4472,9 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
// Process public headers to mark the source files.
if (const char* files = this->GetProperty("PUBLIC_HEADER")) {
- std::vector<std::string> relFiles;
- cmSystemTools::ExpandListArgument(files, relFiles);
- for (std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it) {
- if (cmSourceFile* sf = this->Makefile->GetSource(*it)) {
+ std::vector<std::string> relFiles = cmExpandedList(files);
+ for (std::string const& relFile : relFiles) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) {
SourceFileFlags& flags = this->SourceFlagsMap[sf];
flags.MacFolder = "Headers";
flags.Type = cmGeneratorTarget::SourceFileTypePublicHeader;
@@ -3446,11 +4485,9 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
// Process private headers after public headers so that they take
// precedence if a file is listed in both.
if (const char* files = this->GetProperty("PRIVATE_HEADER")) {
- std::vector<std::string> relFiles;
- cmSystemTools::ExpandListArgument(files, relFiles);
- for (std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it) {
- if (cmSourceFile* sf = this->Makefile->GetSource(*it)) {
+ std::vector<std::string> relFiles = cmExpandedList(files);
+ for (std::string const& relFile : relFiles) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) {
SourceFileFlags& flags = this->SourceFlagsMap[sf];
flags.MacFolder = "PrivateHeaders";
flags.Type = cmGeneratorTarget::SourceFileTypePrivateHeader;
@@ -3460,11 +4497,9 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
// Mark sources listed as resources.
if (const char* files = this->GetProperty("RESOURCE")) {
- std::vector<std::string> relFiles;
- cmSystemTools::ExpandListArgument(files, relFiles);
- for (std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it) {
- if (cmSourceFile* sf = this->Makefile->GetSource(*it)) {
+ std::vector<std::string> relFiles = cmExpandedList(files);
+ for (std::string const& relFile : relFiles) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) {
SourceFileFlags& flags = this->SourceFlagsMap[sf];
flags.MacFolder = "";
if (!this->GlobalGenerator->ShouldStripResourcePath(this->Makefile)) {
@@ -3487,13 +4522,11 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const
compat.PropsString.insert("AUTOUIC_OPTIONS");
std::vector<cmGeneratorTarget const*> const& deps =
this->GetLinkImplementationClosure(config);
- for (std::vector<cmGeneratorTarget const*>::const_iterator li =
- deps.begin();
- li != deps.end(); ++li) {
+ for (cmGeneratorTarget const* li : deps) {
#define CM_READ_COMPATIBLE_INTERFACE(X, x) \
- if (const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) { \
+ if (const char* prop = li->GetProperty("COMPATIBLE_INTERFACE_" #X)) { \
std::vector<std::string> props; \
- cmSystemTools::ExpandListArgument(prop, props); \
+ cmExpandList(prop, props); \
compat.Props##x.insert(props.begin(), props.end()); \
}
CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool)
@@ -3581,7 +4614,7 @@ const char* getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
case BoolType:
assert(false &&
"String compatibility check function called for boolean");
- return CM_NULLPTR;
+ return nullptr;
case StringType:
return tgt->GetLinkInterfaceDependentStringProperty(prop, config);
case NumberMinType:
@@ -3590,7 +4623,7 @@ const char* getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt,
return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config);
}
assert(false && "Unreachable!");
- return CM_NULLPTR;
+ return nullptr;
}
template <typename PropertyType>
@@ -3606,29 +4639,28 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender,
return;
}
- std::vector<std::string> props;
- cmSystemTools::ExpandListArgument(prop, props);
- std::string pdir = cmSystemTools::GetCMakeRoot();
- pdir += "/Help/prop_tgt/";
+ std::vector<std::string> props = cmExpandedList(prop);
+ std::string pdir =
+ cmStrCat(cmSystemTools::GetCMakeRoot(), "/Help/prop_tgt/");
- for (std::vector<std::string>::iterator pi = props.begin();
- pi != props.end(); ++pi) {
- std::string pname = cmSystemTools::HelpFileName(*pi);
+ for (std::string const& p : props) {
+ std::string pname = cmSystemTools::HelpFileName(p);
std::string pfile = pdir + pname + ".rst";
- if (cmSystemTools::FileExists(pfile.c_str(), true)) {
+ if (cmSystemTools::FileExists(pfile, true)) {
std::ostringstream e;
- e << "Target \"" << dependee->GetName() << "\" has property \"" << *pi
+ e << "Target \"" << dependee->GetName() << "\" has property \"" << p
<< "\" listed in its " << propName
<< " property. "
"This is not allowed. Only user-defined properties may appear "
"listed in the "
<< propName << " property.";
- depender->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str());
+ depender->GetLocalGenerator()->IssueMessage(MessageType::FATAL_ERROR,
+ e.str());
return;
}
- if (emitted.insert(*pi).second) {
- getLinkInterfaceDependentProperty<PropertyType>(depender, *pi, config, t,
- CM_NULLPTR);
+ if (emitted.insert(p).second) {
+ getLinkInterfaceDependentProperty<PropertyType>(depender, p, config, t,
+ nullptr);
if (cmSystemTools::GetErrorOccuredFlag()) {
return;
}
@@ -3636,8 +4668,9 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender,
}
}
-static std::string intersect(const std::set<std::string>& s1,
- const std::set<std::string>& s2)
+namespace {
+std::string intersect(const std::set<std::string>& s1,
+ const std::set<std::string>& s2)
{
std::set<std::string> intersect;
std::set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(),
@@ -3648,9 +4681,9 @@ static std::string intersect(const std::set<std::string>& s1,
return "";
}
-static std::string intersect(const std::set<std::string>& s1,
- const std::set<std::string>& s2,
- const std::set<std::string>& s3)
+std::string intersect(const std::set<std::string>& s1,
+ const std::set<std::string>& s2,
+ const std::set<std::string>& s3)
{
std::string result;
result = intersect(s1, s2);
@@ -3664,10 +4697,10 @@ static std::string intersect(const std::set<std::string>& s1,
return intersect(s2, s3);
}
-static std::string intersect(const std::set<std::string>& s1,
- const std::set<std::string>& s2,
- const std::set<std::string>& s3,
- const std::set<std::string>& s4)
+std::string intersect(const std::set<std::string>& s1,
+ const std::set<std::string>& s2,
+ const std::set<std::string>& s3,
+ const std::set<std::string>& s4)
{
std::string result;
result = intersect(s1, s2);
@@ -3684,6 +4717,7 @@ static std::string intersect(const std::set<std::string>& s1,
}
return intersect(s2, s3, s4);
}
+}
void cmGeneratorTarget::CheckPropertyCompatibility(
cmComputeLinkInformation* info, const std::string& config) const
@@ -3691,40 +4725,39 @@ void cmGeneratorTarget::CheckPropertyCompatibility(
const cmComputeLinkInformation::ItemVector& deps = info->GetItems();
std::set<std::string> emittedBools;
- static std::string strBool = "COMPATIBLE_INTERFACE_BOOL";
+ static const std::string strBool = "COMPATIBLE_INTERFACE_BOOL";
std::set<std::string> emittedStrings;
- static std::string strString = "COMPATIBLE_INTERFACE_STRING";
+ static const std::string strString = "COMPATIBLE_INTERFACE_STRING";
std::set<std::string> emittedMinNumbers;
- static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN";
+ static const std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN";
std::set<std::string> emittedMaxNumbers;
- static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX";
+ static const std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX";
- for (cmComputeLinkInformation::ItemVector::const_iterator li = deps.begin();
- li != deps.end(); ++li) {
- if (!li->Target) {
+ for (auto const& dep : deps) {
+ if (!dep.Target) {
continue;
}
- checkPropertyConsistency<bool>(this, li->Target, strBool, emittedBools,
- config, BoolType, CM_NULLPTR);
+ checkPropertyConsistency<bool>(this, dep.Target, strBool, emittedBools,
+ config, BoolType, nullptr);
if (cmSystemTools::GetErrorOccuredFlag()) {
return;
}
- checkPropertyConsistency<const char*>(this, li->Target, strString,
+ checkPropertyConsistency<const char*>(this, dep.Target, strString,
emittedStrings, config, StringType,
- CM_NULLPTR);
+ nullptr);
if (cmSystemTools::GetErrorOccuredFlag()) {
return;
}
- checkPropertyConsistency<const char*>(this, li->Target, strNumMin,
+ checkPropertyConsistency<const char*>(this, dep.Target, strNumMin,
emittedMinNumbers, config,
- NumberMinType, CM_NULLPTR);
+ NumberMinType, nullptr);
if (cmSystemTools::GetErrorOccuredFlag()) {
return;
}
- checkPropertyConsistency<const char*>(this, li->Target, strNumMax,
+ checkPropertyConsistency<const char*>(this, dep.Target, strNumMax,
emittedMaxNumbers, config,
- NumberMaxType, CM_NULLPTR);
+ NumberMaxType, nullptr);
if (cmSystemTools::GetErrorOccuredFlag()) {
return;
}
@@ -3736,7 +4769,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility(
if (!prop.empty()) {
// Use a sorted std::vector to keep the error message sorted.
std::vector<std::string> props;
- std::set<std::string>::const_iterator i = emittedBools.find(prop);
+ auto i = emittedBools.find(prop);
if (i != emittedBools.end()) {
props.push_back(strBool);
}
@@ -3754,8 +4787,8 @@ void cmGeneratorTarget::CheckPropertyCompatibility(
}
std::sort(props.begin(), props.end());
- std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", ");
- propsString += " and the " + props.back();
+ std::string propsString = cmStrCat(
+ cmJoin(cmMakeRange(props).retreat(1), ", "), " and the ", props.back());
std::ostringstream e;
e << "Property \"" << prop << "\" appears in both the " << propsString
@@ -3764,10 +4797,33 @@ void cmGeneratorTarget::CheckPropertyCompatibility(
"in a boolean interpretation, a numeric minimum, a numeric maximum "
"or a "
"string interpretation, but not a mixture.";
- this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->LocalGenerator->IssueMessage(MessageType::FATAL_ERROR, e.str());
}
}
+template <typename PropertyType>
+std::string valueAsString(PropertyType);
+template <>
+std::string valueAsString<bool>(bool value)
+{
+ return value ? "TRUE" : "FALSE";
+}
+template <>
+std::string valueAsString<const char*>(const char* value)
+{
+ return value ? value : "(unset)";
+}
+template <>
+std::string valueAsString<std::string>(std::string value)
+{
+ return value;
+}
+template <>
+std::string valueAsString<std::nullptr_t>(std::nullptr_t /*unused*/)
+{
+ return "(unset)";
+}
+
std::string compatibilityType(CompatibleType t)
{
switch (t) {
@@ -3799,34 +4855,49 @@ std::string compatibilityAgree(CompatibleType t, bool dominant)
}
template <typename PropertyType>
-PropertyType getTypedProperty(cmGeneratorTarget const* tgt,
- const std::string& prop);
+PropertyType getTypedProperty(
+ cmGeneratorTarget const* tgt, const std::string& prop,
+ cmGeneratorExpressionInterpreter* genexInterpreter = nullptr);
template <>
bool getTypedProperty<bool>(cmGeneratorTarget const* tgt,
- const std::string& prop)
+ const std::string& prop,
+ cmGeneratorExpressionInterpreter* genexInterpreter)
{
- return tgt->GetPropertyAsBool(prop);
-}
+ if (genexInterpreter == nullptr) {
+ return tgt->GetPropertyAsBool(prop);
+ }
-template <>
-const char* getTypedProperty<const char*>(cmGeneratorTarget const* tgt,
- const std::string& prop)
-{
- return tgt->GetProperty(prop);
+ const char* value = tgt->GetProperty(prop);
+ return cmIsOn(genexInterpreter->Evaluate(value, prop));
}
-template <typename PropertyType>
-std::string valueAsString(PropertyType);
template <>
-std::string valueAsString<bool>(bool value)
+const char* getTypedProperty<const char*>(
+ cmGeneratorTarget const* tgt, const std::string& prop,
+ cmGeneratorExpressionInterpreter* genexInterpreter)
{
- return value ? "TRUE" : "FALSE";
+ const char* value = tgt->GetProperty(prop);
+
+ if (genexInterpreter == nullptr) {
+ return value;
+ }
+
+ return genexInterpreter->Evaluate(value, prop).c_str();
}
+
template <>
-std::string valueAsString<const char*>(const char* value)
+std::string getTypedProperty<std::string>(
+ cmGeneratorTarget const* tgt, const std::string& prop,
+ cmGeneratorExpressionInterpreter* genexInterpreter)
{
- return value ? value : "(unset)";
+ const char* value = tgt->GetProperty(prop);
+
+ if (genexInterpreter == nullptr) {
+ return valueAsString(value);
+ }
+
+ return genexInterpreter->Evaluate(value, prop);
}
template <typename PropertyType>
@@ -3841,6 +4912,11 @@ const char* impliedValue<const char*>(const char* /*unused*/)
{
return "";
}
+template <>
+std::string impliedValue<std::string>(std::string /*unused*/) // NOLINT(*)
+{
+ return std::string();
+}
template <typename PropertyType>
std::pair<bool, PropertyType> consistentProperty(PropertyType lhs,
@@ -3851,14 +4927,21 @@ template <>
std::pair<bool, bool> consistentProperty(bool lhs, bool rhs,
CompatibleType /*unused*/)
{
- return std::make_pair(lhs == rhs, lhs);
+ return { lhs == rhs, lhs };
}
std::pair<bool, const char*> consistentStringProperty(const char* lhs,
const char* rhs)
{
const bool b = strcmp(lhs, rhs) == 0;
- return std::make_pair(b, b ? lhs : CM_NULLPTR);
+ return { b, b ? lhs : nullptr };
+}
+
+std::pair<bool, std::string> consistentStringProperty(const std::string& lhs,
+ const std::string& rhs)
+{
+ const bool b = lhs == rhs;
+ return { b, b ? lhs : valueAsString(nullptr) };
}
std::pair<bool, const char*> consistentNumberProperty(const char* lhs,
@@ -3867,22 +4950,21 @@ std::pair<bool, const char*> consistentNumberProperty(const char* lhs,
{
char* pEnd;
- const char* const null_ptr = CM_NULLPTR;
-
long lnum = strtol(lhs, &pEnd, 0);
if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) {
- return std::pair<bool, const char*>(false, null_ptr);
+ return { false, nullptr };
}
long rnum = strtol(rhs, &pEnd, 0);
if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) {
- return std::pair<bool, const char*>(false, null_ptr);
+ return { false, nullptr };
}
if (t == NumberMaxType) {
- return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs);
+ return { true, std::max(lnum, rnum) == lnum ? lhs : rhs };
}
- return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs);
+
+ return { true, std::min(lnum, rnum) == lnum ? lhs : rhs };
}
template <>
@@ -3891,21 +4973,20 @@ std::pair<bool, const char*> consistentProperty(const char* lhs,
CompatibleType t)
{
if (!lhs && !rhs) {
- return std::make_pair(true, lhs);
+ return { true, lhs };
}
if (!lhs) {
- return std::make_pair(true, rhs);
+ return { true, rhs };
}
if (!rhs) {
- return std::make_pair(true, lhs);
+ return { true, lhs };
}
- const char* const null_ptr = CM_NULLPTR;
-
switch (t) {
- case BoolType:
- assert(false && "consistentProperty for strings called with BoolType");
- return std::pair<bool, const char*>(false, null_ptr);
+ case BoolType: {
+ bool same = cmIsOn(lhs) == cmIsOn(rhs);
+ return { same, same ? lhs : nullptr };
+ }
case StringType:
return consistentStringProperty(lhs, rhs);
case NumberMinType:
@@ -3913,7 +4994,41 @@ std::pair<bool, const char*> consistentProperty(const char* lhs,
return consistentNumberProperty(lhs, rhs, t);
}
assert(false && "Unreachable!");
- return std::pair<bool, const char*>(false, null_ptr);
+ return { false, nullptr };
+}
+
+std::pair<bool, std::string> consistentProperty(const std::string& lhs,
+ const std::string& rhs,
+ CompatibleType t)
+{
+ const std::string null_ptr = valueAsString(nullptr);
+
+ if (lhs == null_ptr && rhs == null_ptr) {
+ return { true, lhs };
+ }
+ if (lhs == null_ptr) {
+ return { true, rhs };
+ }
+ if (rhs == null_ptr) {
+ return { true, lhs };
+ }
+
+ switch (t) {
+ case BoolType: {
+ bool same = cmIsOn(lhs) == cmIsOn(rhs);
+ return { same, same ? lhs : null_ptr };
+ }
+ case StringType:
+ return consistentStringProperty(lhs, rhs);
+ case NumberMinType:
+ case NumberMaxType: {
+ auto value = consistentNumberProperty(lhs.c_str(), rhs.c_str(), t);
+ return { value.first,
+ value.first ? std::string(value.second) : null_ptr };
+ }
+ }
+ assert(false && "Unreachable!");
+ return { false, null_ptr };
}
template <typename PropertyType>
@@ -3925,10 +5040,9 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
PropertyType* /*unused*/)
{
PropertyType propContent = getTypedProperty<PropertyType>(tgt, p);
+
std::vector<std::string> headPropKeys = tgt->GetPropertyKeys();
- const bool explicitlySet =
- std::find(headPropKeys.begin(), headPropKeys.end(), p) !=
- headPropKeys.end();
+ const bool explicitlySet = cmContains(headPropKeys, p);
const bool impliedByUse = tgt->IsNullImpliedByLinkLibraries(p);
assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet));
@@ -3941,8 +5055,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
}
bool propInitialized = explicitlySet;
- std::string report = " * Target \"";
- report += tgt->GetName();
+ std::string report = cmStrCat(" * Target \"", tgt->GetName());
if (explicitlySet) {
report += "\" has property content \"";
report += valueAsString<PropertyType>(propContent);
@@ -3954,22 +5067,23 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
}
std::string interfaceProperty = "INTERFACE_" + p;
- for (std::vector<cmGeneratorTarget const*>::const_iterator li = deps.begin();
- li != deps.end(); ++li) {
+ std::unique_ptr<cmGeneratorExpressionInterpreter> genexInterpreter(
+ p == "POSITION_INDEPENDENT_CODE" ? new cmGeneratorExpressionInterpreter(
+ tgt->GetLocalGenerator(), config, tgt)
+ : nullptr);
+
+ for (cmGeneratorTarget const* theTarget : deps) {
// An error should be reported if one dependency
// has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other
// has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the
// target itself has a POSITION_INDEPENDENT_CODE which disagrees
// with a dependency.
- cmGeneratorTarget const* theTarget = *li;
-
std::vector<std::string> propKeys = theTarget->GetPropertyKeys();
- const bool ifaceIsSet = std::find(propKeys.begin(), propKeys.end(),
- interfaceProperty) != propKeys.end();
- PropertyType ifacePropContent =
- getTypedProperty<PropertyType>(theTarget, interfaceProperty);
+ const bool ifaceIsSet = cmContains(propKeys, interfaceProperty);
+ PropertyType ifacePropContent = getTypedProperty<PropertyType>(
+ theTarget, interfaceProperty, genexInterpreter.get());
std::string reportEntry;
if (ifaceIsSet) {
@@ -3991,10 +5105,11 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
e << "Property " << p << " on target \"" << tgt->GetName()
<< "\" does\nnot match the "
"INTERFACE_"
- << p << " property requirement\nof "
- "dependency \""
+ << p
+ << " property requirement\nof "
+ "dependency \""
<< theTarget->GetName() << "\".\n";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
break;
}
propContent = consistent.second;
@@ -4019,7 +5134,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
"already. The INTERFACE_"
<< p << " property on\ndependency \"" << theTarget->GetName()
<< "\" is in conflict.\n";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
break;
}
propContent = consistent.second;
@@ -4039,7 +5154,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
e << "The INTERFACE_" << p << " property of \""
<< theTarget->GetName() << "\" does\nnot agree with the value of "
<< p << " already determined\nfor \"" << tgt->GetName() << "\".\n";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
break;
}
propContent = consistent.second;
@@ -4063,28 +5178,35 @@ bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty(
const std::string& p, const std::string& config) const
{
return checkInterfacePropertyCompatibility<bool>(this, p, config, "FALSE",
- BoolType, CM_NULLPTR);
+ BoolType, nullptr);
+}
+
+std::string cmGeneratorTarget::GetLinkInterfaceDependentStringAsBoolProperty(
+ const std::string& p, const std::string& config) const
+{
+ return checkInterfacePropertyCompatibility<std::string>(
+ this, p, config, "FALSE", BoolType, nullptr);
}
const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty(
const std::string& p, const std::string& config) const
{
return checkInterfacePropertyCompatibility<const char*>(
- this, p, config, "empty", StringType, CM_NULLPTR);
+ this, p, config, "empty", StringType, nullptr);
}
const char* cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty(
const std::string& p, const std::string& config) const
{
return checkInterfacePropertyCompatibility<const char*>(
- this, p, config, "empty", NumberMinType, CM_NULLPTR);
+ this, p, config, "empty", NumberMinType, nullptr);
}
const char* cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty(
const std::string& p, const std::string& config) const
{
return checkInterfacePropertyCompatibility<const char*>(
- this, p, config, "empty", NumberMaxType, CM_NULLPTR);
+ this, p, config, "empty", NumberMaxType, nullptr);
}
cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(
@@ -4092,14 +5214,14 @@ cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(
{
// Lookup any existing information for this configuration.
std::string key(cmSystemTools::UpperCase(config));
- cmTargetLinkInformationMap::iterator i = this->LinkInformation.find(key);
+ auto i = this->LinkInformation.find(key);
if (i == this->LinkInformation.end()) {
// Compute information for this configuration.
cmComputeLinkInformation* info =
new cmComputeLinkInformation(this, config);
if (!info || !info->Compute()) {
delete info;
- info = CM_NULLPTR;
+ info = nullptr;
}
// Store the information for this configuration.
@@ -4189,9 +5311,8 @@ std::string cmGeneratorTarget::CreateFortranModuleDirectory(
mod_dir = target_mod_dir;
} else {
// Interpret relative to the current output directory.
- mod_dir = this->LocalGenerator->GetCurrentBinaryDirectory();
- mod_dir += "/";
- mod_dir += target_mod_dir;
+ mod_dir = cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(),
+ '/', target_mod_dir);
}
// Make sure the module output directory exists.
@@ -4230,14 +5351,7 @@ void cmGeneratorTarget::ComputeVersionedName(std::string& vName,
std::vector<std::string> cmGeneratorTarget::GetPropertyKeys() const
{
- cmPropertyMap const& propsObject = this->Target->GetProperties();
- std::vector<std::string> props;
- props.reserve(propsObject.size());
- for (cmPropertyMap::const_iterator it = propsObject.begin();
- it != propsObject.end(); ++it) {
- props.push_back(it->first);
- }
- return props;
+ return this->Target->GetProperties().GetKeys();
}
void cmGeneratorTarget::ReportPropertyOrigin(
@@ -4248,12 +5362,11 @@ void cmGeneratorTarget::ReportPropertyOrigin(
const char* debugProp = this->Target->GetMakefile()->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES");
if (debugProp) {
- cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+ cmExpandList(debugProp, debugProperties);
}
- bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] &&
- std::find(debugProperties.begin(), debugProperties.end(), p) !=
- debugProperties.end();
+ bool debugOrigin =
+ !this->DebugCompatiblePropertiesDone[p] && cmContains(debugProperties, p);
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
this->DebugCompatiblePropertiesDone[p] = true;
@@ -4262,26 +5375,24 @@ void cmGeneratorTarget::ReportPropertyOrigin(
return;
}
- std::string areport = compatibilityType;
- areport += std::string(" of property \"") + p + "\" for target \"";
- areport += std::string(this->GetName());
- areport += "\" (result: \"";
- areport += result;
- areport += "\"):\n" + report;
+ std::string areport =
+ cmStrCat(compatibilityType, " of property \"", p, "\" for target \"",
+ this->GetName(), "\" (result: \"", result, "\"):\n", report);
- this->LocalGenerator->GetCMakeInstance()->IssueMessage(cmake::LOG, areport);
+ this->LocalGenerator->GetCMakeInstance()->IssueMessage(MessageType::LOG,
+ areport);
}
void cmGeneratorTarget::LookupLinkItems(std::vector<std::string> const& names,
+ cmListFileBacktrace const& bt,
std::vector<cmLinkItem>& items) const
{
- for (std::vector<std::string>::const_iterator i = names.begin();
- i != names.end(); ++i) {
- std::string name = this->CheckCMP0004(*i);
+ for (std::string const& n : names) {
+ std::string name = this->CheckCMP0004(n);
if (name == this->GetName() || name.empty()) {
continue;
}
- items.push_back(cmLinkItem(name, this->FindTargetToLink(name)));
+ items.push_back(this->ResolveLinkItem(name, bt));
}
}
@@ -4291,20 +5402,18 @@ void cmGeneratorTarget::ExpandLinkItems(
std::vector<cmLinkItem>& items, bool& hadHeadSensitiveCondition) const
{
cmGeneratorExpression ge;
- cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, CM_NULLPTR,
- CM_NULLPTR);
+ cmGeneratorExpressionDAGChecker dagChecker(this, prop, nullptr, nullptr);
// The $<LINK_ONLY> expression may be in a link interface to specify private
// link dependencies that are otherwise excluded from usage requirements.
if (usage_requirements_only) {
dagChecker.SetTransitivePropertiesOnly();
}
std::vector<std::string> libs;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(value);
- cmSystemTools::ExpandListArgument(cge->Evaluate(this->LocalGenerator, config,
- false, headTarget, this,
- &dagChecker),
- libs);
- this->LookupLinkItems(libs, items);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+ cmExpandList(
+ cge->Evaluate(this->LocalGenerator, config, headTarget, &dagChecker, this),
+ libs);
+ this->LookupLinkItems(libs, cge->GetBacktrace(), items);
hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition();
}
@@ -4320,7 +5429,7 @@ cmLinkInterface const* cmGeneratorTarget::GetLinkInterface(
// export symbols.
if (this->GetType() == cmStateEnums::EXECUTABLE &&
!this->IsExecutableWithExports()) {
- return CM_NULLPTR;
+ return nullptr;
}
// Lookup any existing link interface for this configuration.
@@ -4344,35 +5453,31 @@ cmLinkInterface const* cmGeneratorTarget::GetLinkInterface(
}
}
- return iface.Exists ? &iface : CM_NULLPTR;
+ return iface.Exists ? &iface : nullptr;
}
void cmGeneratorTarget::ComputeLinkInterface(
const std::string& config, cmOptionalLinkInterface& iface,
cmGeneratorTarget const* headTarget) const
{
- if (iface.ExplicitLibraries) {
+ if (iface.Explicit) {
if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->GetType() == cmStateEnums::STATIC_LIBRARY ||
this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
// Shared libraries may have runtime implementation dependencies
// on other shared libraries that are not in the interface.
- CM_UNORDERED_SET<std::string> emitted;
- for (std::vector<cmLinkItem>::const_iterator li =
- iface.Libraries.begin();
- li != iface.Libraries.end(); ++li) {
- emitted.insert(*li);
+ std::set<cmLinkItem> emitted;
+ for (cmLinkItem const& lib : iface.Libraries) {
+ emitted.insert(lib);
}
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
cmLinkImplementation const* impl = this->GetLinkImplementation(config);
- for (std::vector<cmLinkImplItem>::const_iterator li =
- impl->Libraries.begin();
- li != impl->Libraries.end(); ++li) {
- if (emitted.insert(*li).second) {
- if (li->Target) {
+ for (cmLinkImplItem const& lib : impl->Libraries) {
+ if (emitted.insert(lib).second) {
+ if (lib.Target) {
// This is a runtime dependency on another shared library.
- if (li->Target->GetType() == cmStateEnums::SHARED_LIBRARY) {
- iface.SharedDeps.push_back(*li);
+ if (lib.Target->GetType() == cmStateEnums::SHARED_LIBRARY) {
+ iface.SharedDeps.push_back(lib);
}
} else {
// TODO: Recognize shared library file names. Perhaps this
@@ -4412,8 +5517,7 @@ void cmGeneratorTarget::ComputeLinkInterface(
// How many repetitions are needed if this library has cyclic
// dependencies?
- std::string propName = "LINK_INTERFACE_MULTIPLICITY";
- propName += suffix;
+ std::string propName = cmStrCat("LINK_INTERFACE_MULTIPLICITY", suffix);
if (const char* config_reps = this->GetProperty(propName)) {
sscanf(config_reps, "%u", &iface.Multiplicity);
} else if (const char* reps =
@@ -4436,7 +5540,7 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries(
// export symbols.
if (this->GetType() == cmStateEnums::EXECUTABLE &&
!this->IsExecutableWithExports()) {
- return CM_NULLPTR;
+ return nullptr;
}
// Lookup any existing link interface for this configuration.
@@ -4459,7 +5563,7 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries(
usage_requirements_only);
}
- return iface.Exists ? &iface : CM_NULLPTR;
+ return iface.Exists ? &iface : nullptr;
}
std::string cmGeneratorTarget::GetDirectory(
@@ -4494,17 +5598,16 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo(
{
// There is no output information for imported targets.
if (this->IsImported()) {
- return CM_NULLPTR;
+ return nullptr;
}
// Only libraries and executables have well-defined output files.
if (!this->HaveWellDefinedOutputFiles()) {
- std::string msg = "cmGeneratorTarget::GetOutputInfo called for ";
- msg += this->GetName();
- msg += " which has type ";
- msg += cmState::GetTargetTypeName(this->GetType());
- this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
- return CM_NULLPTR;
+ std::string msg = cmStrCat("cmGeneratorTarget::GetOutputInfo called for ",
+ this->GetName(), " which has type ",
+ cmState::GetTargetTypeName(this->GetType()));
+ this->LocalGenerator->IssueMessage(MessageType::INTERNAL_ERROR, msg);
+ return nullptr;
}
// Lookup/compute/cache the output information for this configuration.
@@ -4512,7 +5615,7 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo(
if (!config.empty()) {
config_upper = cmSystemTools::UpperCase(config);
}
- OutputInfoMapType::iterator i = this->OutputInfoMap.find(config_upper);
+ auto i = this->OutputInfoMap.find(config_upper);
if (i == this->OutputInfoMap.end()) {
// Add empty info in map to detect potential recursion.
OutputInfo info;
@@ -4534,10 +5637,10 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo(
// An empty map entry indicates we have been called recursively
// from the above block.
this->LocalGenerator->GetCMakeInstance()->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"Target '" + this->GetName() + "' OUTPUT_DIRECTORY depends on itself.",
this->GetBacktrace());
- return CM_NULLPTR;
+ return nullptr;
}
return &i->second;
}
@@ -4552,7 +5655,7 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
// Look for a target property defining the target output directory
// based on the target type.
std::string targetTypeName = this->GetOutputTargetType(artifact);
- const char* propertyName = CM_NULLPTR;
+ const char* propertyName = nullptr;
std::string propertyNameStr = targetTypeName;
if (!propertyNameStr.empty()) {
propertyNameStr += "_OUTPUT_DIRECTORY";
@@ -4561,7 +5664,7 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
// Check for a per-configuration output directory target property.
std::string configUpper = cmSystemTools::UpperCase(conf);
- const char* configProp = CM_NULLPTR;
+ const char* configProp = nullptr;
std::string configPropStr = targetTypeName;
if (!configPropStr.empty()) {
configPropStr += "_OUTPUT_DIRECTORY_";
@@ -4572,22 +5675,20 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
// Select an output directory.
if (const char* config_outdir = this->GetProperty(configProp)) {
// Use the user-specified per-configuration output directory.
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(config_outdir);
- out = cge->Evaluate(this->LocalGenerator, config);
+ out = cmGeneratorExpression::Evaluate(config_outdir, this->LocalGenerator,
+ config);
// Skip per-configuration subdirectory.
- conf = "";
+ conf.clear();
} else if (const char* outdir = this->GetProperty(propertyName)) {
// Use the user-specified output directory.
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(outdir);
- out = cge->Evaluate(this->LocalGenerator, config);
+ out =
+ cmGeneratorExpression::Evaluate(outdir, this->LocalGenerator, config);
// Skip per-configuration subdirectory if the value contained a
// generator expression.
if (out != outdir) {
- conf = "";
+ conf.clear();
}
} else if (this->GetType() == cmStateEnums::EXECUTABLE) {
// Lookup the output path for executables.
@@ -4629,7 +5730,7 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind,
{
// Look for a target property defining the target output directory
// based on the target type.
- const char* propertyName = CM_NULLPTR;
+ const char* propertyName = nullptr;
std::string propertyNameStr = kind;
if (!propertyNameStr.empty()) {
propertyNameStr += "_OUTPUT_DIRECTORY";
@@ -4639,7 +5740,7 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind,
// Check for a per-configuration output directory target property.
std::string configUpper = cmSystemTools::UpperCase(conf);
- const char* configProp = CM_NULLPTR;
+ const char* configProp = nullptr;
std::string configPropStr = kind;
if (!configPropStr.empty()) {
configPropStr += "_OUTPUT_DIRECTORY_";
@@ -4650,13 +5751,21 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind,
// Select an output directory.
if (const char* config_outdir = this->GetProperty(configProp)) {
// Use the user-specified per-configuration output directory.
- out = config_outdir;
+ out = cmGeneratorExpression::Evaluate(config_outdir, this->LocalGenerator,
+ config);
// Skip per-configuration subdirectory.
- conf = "";
+ conf.clear();
} else if (const char* outdir = this->GetProperty(propertyName)) {
// Use the user-specified output directory.
- out = outdir;
+ out =
+ cmGeneratorExpression::Evaluate(outdir, this->LocalGenerator, config);
+
+ // Skip per-configuration subdirectory if the value contained a
+ // generator expression.
+ if (out != outdir) {
+ conf.clear();
+ }
}
if (out.empty()) {
return false;
@@ -4676,13 +5785,40 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind,
return true;
}
-bool cmGeneratorTarget::HaveInstallTreeRPATH() const
+bool cmGeneratorTarget::HaveInstallTreeRPATH(const std::string& config) const
{
- const char* install_rpath = this->GetProperty("INSTALL_RPATH");
- return (install_rpath && *install_rpath) &&
+ std::string install_rpath;
+ this->GetInstallRPATH(config, install_rpath);
+ return !install_rpath.empty() &&
!this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH");
}
+bool cmGeneratorTarget::GetBuildRPATH(const std::string& config,
+ std::string& rpath) const
+{
+ return this->GetRPATH(config, "BUILD_RPATH", rpath);
+}
+
+bool cmGeneratorTarget::GetInstallRPATH(const std::string& config,
+ std::string& rpath) const
+{
+ return this->GetRPATH(config, "INSTALL_RPATH", rpath);
+}
+
+bool cmGeneratorTarget::GetRPATH(const std::string& config,
+ const std::string& prop,
+ std::string& rpath) const
+{
+ const char* value = this->GetProperty(prop);
+ if (!value) {
+ return false;
+ }
+
+ rpath = cmGeneratorExpression::Evaluate(value, this->LocalGenerator, config);
+
+ return true;
+}
+
void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
const std::string& config, cmOptionalLinkInterface& iface,
cmGeneratorTarget const* headTarget, bool usage_requirements_only) const
@@ -4697,10 +5833,11 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
// An explicit list of interface libraries may be set for shared
// libraries and executables that export symbols.
- const char* explicitLibraries = CM_NULLPTR;
+ const char* explicitLibraries = nullptr;
std::string linkIfaceProp;
- if (this->GetPolicyStatusCMP0022() != cmPolicies::OLD &&
- this->GetPolicyStatusCMP0022() != cmPolicies::WARN) {
+ bool const cmp0022NEW = (this->GetPolicyStatusCMP0022() != cmPolicies::OLD &&
+ this->GetPolicyStatusCMP0022() != cmPolicies::WARN);
+ if (cmp0022NEW) {
// CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES.
linkIfaceProp = "INTERFACE_LINK_LIBRARIES";
explicitLibraries = this->GetProperty(linkIfaceProp);
@@ -4710,8 +5847,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
// shared lib or executable.
// Lookup the per-configuration property.
- linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
- linkIfaceProp += suffix;
+ linkIfaceProp = cmStrCat("LINK_INTERFACE_LIBRARIES", suffix);
explicitLibraries = this->GetProperty(linkIfaceProp);
// If not set, try the generic property.
@@ -4740,9 +5876,9 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
"INTERFACE_LINK_LIBRARIES:\n"
" " << newExplicitLibraries << "\n" <<
linkIfaceProp << ":\n"
- " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n";
+ " " << explicitLibraries << "\n";
/* clang-format on */
- this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->LocalGenerator->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
this->PolicyWarnedCMP0022 = true;
}
}
@@ -4755,15 +5891,14 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
return;
}
iface.Exists = true;
- iface.ExplicitLibraries = explicitLibraries;
+ iface.Explicit = cmp0022NEW || explicitLibraries != nullptr;
if (explicitLibraries) {
// The interface libraries have been explicitly set.
this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, headTarget,
usage_requirements_only, iface.Libraries,
iface.HadHeadSensitiveCondition);
- } else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN ||
- this->GetPolicyStatusCMP0022() == cmPolicies::OLD)
+ } else if (!cmp0022NEW)
// If CMP0022 is NEW then the plain tll signature sets the
// INTERFACE_LINK_LIBRARIES, so if we get here then the project
// cleared the property explicitly and we should not fall back
@@ -4811,7 +5946,8 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
"Link implementation:\n"
" " << oldLibraries << "\n";
/* clang-format on */
- this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->LocalGenerator->IssueMessage(MessageType::AUTHOR_WARNING,
+ w.str());
this->PolicyWarnedCMP0022 = true;
}
}
@@ -4824,7 +5960,7 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface(
{
cmGeneratorTarget::ImportInfo const* info = this->GetImportInfo(config);
if (!info) {
- return CM_NULLPTR;
+ return nullptr;
}
std::string CONFIG = cmSystemTools::UpperCase(config);
@@ -4843,13 +5979,12 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface(
if (!iface.AllDone) {
iface.AllDone = true;
iface.Multiplicity = info->Multiplicity;
- cmSystemTools::ExpandListArgument(info->Languages, iface.Languages);
+ cmExpandList(info->Languages, iface.Languages);
this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config,
headTarget, usage_requirements_only, iface.Libraries,
iface.HadHeadSensitiveCondition);
- std::vector<std::string> deps;
- cmSystemTools::ExpandListArgument(info->SharedDeps, deps);
- this->LookupLinkItems(deps, iface.SharedDeps);
+ std::vector<std::string> deps = cmExpandedList(info->SharedDeps);
+ this->LookupLinkItems(deps, cmListFileBacktrace(), iface.SharedDeps);
}
return &iface;
@@ -4860,7 +5995,7 @@ cmGeneratorTarget::ImportInfo const* cmGeneratorTarget::GetImportInfo(
{
// There is no imported information for non-imported targets.
if (!this->IsImported()) {
- return CM_NULLPTR;
+ return nullptr;
}
// Lookup/compute/cache the import information for this
@@ -4872,7 +6007,7 @@ cmGeneratorTarget::ImportInfo const* cmGeneratorTarget::GetImportInfo(
config_upper = "NOCONFIG";
}
- ImportInfoMapType::const_iterator i = this->ImportInfoMap.find(config_upper);
+ auto i = this->ImportInfoMap.find(config_upper);
if (i == this->ImportInfoMap.end()) {
ImportInfo info;
this->ComputeImportInfo(config_upper, info);
@@ -4886,7 +6021,7 @@ cmGeneratorTarget::ImportInfo const* cmGeneratorTarget::GetImportInfo(
// If the location is empty then the target is not available for
// this configuration.
if (i->second.Location.empty() && i->second.ImportLibrary.empty()) {
- return CM_NULLPTR;
+ return nullptr;
}
// Return the import information.
@@ -4903,8 +6038,8 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
// Initialize members.
info.NoSOName = false;
- const char* loc = CM_NULLPTR;
- const char* imp = CM_NULLPTR;
+ const char* loc = nullptr;
+ const char* imp = nullptr;
std::string suffix;
if (!this->Target->GetMappedConfig(desired_config, &loc, &imp, suffix)) {
return;
@@ -4917,8 +6052,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
if (!propertyLibs) {
- linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
- linkProp += suffix;
+ linkProp = cmStrCat("IMPORTED_LINK_INTERFACE_LIBRARIES", suffix);
propertyLibs = this->GetProperty(linkProp);
}
@@ -4946,8 +6080,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
if (loc) {
info.Location = loc;
} else {
- std::string impProp = "IMPORTED_LOCATION";
- impProp += suffix;
+ std::string impProp = cmStrCat("IMPORTED_LOCATION", suffix);
if (const char* config_location = this->GetProperty(impProp)) {
info.Location = config_location;
} else if (const char* location = this->GetProperty("IMPORTED_LOCATION")) {
@@ -4957,8 +6090,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
// Get the soname.
if (this->GetType() == cmStateEnums::SHARED_LIBRARY) {
- std::string soProp = "IMPORTED_SONAME";
- soProp += suffix;
+ std::string soProp = cmStrCat("IMPORTED_SONAME", suffix);
if (const char* config_soname = this->GetProperty(soProp)) {
info.SOName = config_soname;
} else if (const char* soname = this->GetProperty("IMPORTED_SONAME")) {
@@ -4968,13 +6100,12 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
// Get the "no-soname" mark.
if (this->GetType() == cmStateEnums::SHARED_LIBRARY) {
- std::string soProp = "IMPORTED_NO_SONAME";
- soProp += suffix;
+ std::string soProp = cmStrCat("IMPORTED_NO_SONAME", suffix);
if (const char* config_no_soname = this->GetProperty(soProp)) {
- info.NoSOName = cmSystemTools::IsOn(config_no_soname);
+ info.NoSOName = cmIsOn(config_no_soname);
} else if (const char* no_soname =
this->GetProperty("IMPORTED_NO_SONAME")) {
- info.NoSOName = cmSystemTools::IsOn(no_soname);
+ info.NoSOName = cmIsOn(no_soname);
}
}
@@ -4983,8 +6114,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
info.ImportLibrary = imp;
} else if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->IsExecutableWithExports()) {
- std::string impProp = "IMPORTED_IMPLIB";
- impProp += suffix;
+ std::string impProp = cmStrCat("IMPORTED_IMPLIB", suffix);
if (const char* config_implib = this->GetProperty(impProp)) {
info.ImportLibrary = config_implib;
} else if (const char* implib = this->GetProperty("IMPORTED_IMPLIB")) {
@@ -4994,8 +6124,8 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
// Get the link dependencies.
{
- std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES";
- linkProp += suffix;
+ std::string linkProp =
+ cmStrCat("IMPORTED_LINK_DEPENDENT_LIBRARIES", suffix);
if (const char* config_libs = this->GetProperty(linkProp)) {
info.SharedDeps = config_libs;
} else if (const char* libs =
@@ -5006,8 +6136,8 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
// Get the link languages.
if (this->LinkLanguagePropagatesToDependents()) {
- std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES";
- linkProp += suffix;
+ std::string linkProp =
+ cmStrCat("IMPORTED_LINK_INTERFACE_LANGUAGES", suffix);
if (const char* config_libs = this->GetProperty(linkProp)) {
info.Languages = config_libs;
} else if (const char* libs =
@@ -5016,10 +6146,20 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
}
}
+ // Get information if target is managed assembly.
+ {
+ std::string linkProp = "IMPORTED_COMMON_LANGUAGE_RUNTIME";
+ if (auto pc = this->GetProperty(linkProp + suffix)) {
+ info.Managed = this->CheckManagedType(pc);
+ } else if (auto p = this->GetProperty(linkProp)) {
+ info.Managed = this->CheckManagedType(p);
+ }
+ }
+
// Get the cyclic repetition count.
if (this->GetType() == cmStateEnums::STATIC_LIBRARY) {
- std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
- linkProp += suffix;
+ std::string linkProp =
+ cmStrCat("IMPORTED_LINK_INTERFACE_MULTIPLICITY", suffix);
if (const char* config_reps = this->GetProperty(linkProp)) {
sscanf(config_reps, "%u", &info.Multiplicity);
} else if (const char* reps =
@@ -5049,7 +6189,7 @@ const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation(
{
// There is no link implementation for imported targets.
if (this->IsImported()) {
- return CM_NULLPTR;
+ return nullptr;
}
std::string CONFIG = cmSystemTools::UpperCase(config);
@@ -5068,13 +6208,10 @@ const cmLinkImplementation* cmGeneratorTarget::GetLinkImplementation(
bool cmGeneratorTarget::GetConfigCommonSourceFiles(
std::vector<cmSourceFile*>& files) const
{
- std::vector<std::string> configs;
- this->Makefile->GetConfigurations(configs);
- if (configs.empty()) {
- configs.push_back("");
- }
+ std::vector<std::string> const& configs =
+ this->Makefile->GetGeneratorConfigs();
- std::vector<std::string>::const_iterator it = configs.begin();
+ auto it = configs.begin();
const std::string& firstConfig = *it;
this->GetSourceFilesWithoutObjectLibraries(files, firstConfig);
@@ -5084,19 +6221,17 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles(
if (configFiles != files) {
std::string firstConfigFiles;
const char* sep = "";
- for (std::vector<cmSourceFile*>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
+ for (cmSourceFile* f : files) {
firstConfigFiles += sep;
- firstConfigFiles += (*fi)->GetFullPath();
+ firstConfigFiles += f->ResolveFullPath();
sep = "\n ";
}
std::string thisConfigFiles;
sep = "";
- for (std::vector<cmSourceFile*>::const_iterator fi = configFiles.begin();
- fi != configFiles.end(); ++fi) {
+ for (cmSourceFile* f : configFiles) {
thisConfigFiles += sep;
- thisConfigFiles += (*fi)->GetFullPath();
+ thisConfigFiles += f->ResolveFullPath();
sep = "\n ";
}
std::ostringstream e;
@@ -5111,7 +6246,7 @@ bool cmGeneratorTarget::GetConfigCommonSourceFiles(
"Config \"" << *it << "\":\n"
" " << thisConfigFiles << "\n";
/* clang-format on */
- this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->LocalGenerator->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
}
@@ -5127,17 +6262,11 @@ void cmGeneratorTarget::GetObjectLibrariesCMP0026(
// for TARGET_OBJECTS instead for backwards compatibility with OLD
// behavior of CMP0024 and CMP0026 only.
cmStringRange rng = this->Target->GetSourceEntries();
- for (std::vector<std::string>::const_iterator i = rng.begin();
- i != rng.end(); ++i) {
- std::string const& entry = *i;
-
- std::vector<std::string> files;
- cmSystemTools::ExpandListArgument(entry, files);
- for (std::vector<std::string>::const_iterator li = files.begin();
- li != files.end(); ++li) {
- if (cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
- (*li)[li->size() - 1] == '>') {
- std::string objLibName = li->substr(17, li->size() - 18);
+ for (std::string const& entry : rng) {
+ std::vector<std::string> files = cmExpandedList(entry);
+ for (std::string const& li : files) {
+ if (cmHasLiteralPrefix(li, "$<TARGET_OBJECTS:") && li.back() == '>') {
+ std::string objLibName = li.substr(17, li.size() - 18);
if (cmGeneratorExpression::Find(objLibName) != std::string::npos) {
continue;
@@ -5174,7 +6303,8 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0004) << "\n"
<< "Target \"" << this->GetName() << "\" links to item \"" << item
<< "\" which has leading or trailing whitespace.";
- cm->IssueMessage(cmake::AUTHOR_WARNING, w.str(), this->GetBacktrace());
+ cm->IssueMessage(MessageType::AUTHOR_WARNING, w.str(),
+ this->GetBacktrace());
}
case cmPolicies::OLD:
break;
@@ -5183,7 +6313,8 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
e << "Target \"" << this->GetName() << "\" links to item \"" << item
<< "\" which has leading or trailing whitespace. "
<< "This is now an error according to policy CMP0004.";
- cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
+ cm->IssueMessage(MessageType::FATAL_ERROR, e.str(),
+ this->GetBacktrace());
} break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS: {
@@ -5191,7 +6322,8 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0004) << "\n"
<< "Target \"" << this->GetName() << "\" links to item \"" << item
<< "\" which has leading or trailing whitespace.";
- cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
+ cm->IssueMessage(MessageType::FATAL_ERROR, e.str(),
+ this->GetBacktrace());
} break;
}
}
@@ -5203,9 +6335,8 @@ void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages,
{
std::vector<cmSourceFile*> sourceFiles;
this->GetSourceFiles(sourceFiles, config);
- for (std::vector<cmSourceFile*>::const_iterator i = sourceFiles.begin();
- i != sourceFiles.end(); ++i) {
- const std::string& lang = (*i)->GetLanguage();
+ for (cmSourceFile* src : sourceFiles) {
+ const std::string& lang = src->GetOrDetermineLanguage();
if (!lang.empty()) {
languages.insert(lang);
}
@@ -5217,28 +6348,46 @@ void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages,
std::vector<cmGeneratorTarget*> objectTargets;
this->GetObjectLibrariesCMP0026(objectTargets);
objectLibraries.reserve(objectTargets.size());
- for (std::vector<cmGeneratorTarget*>::const_iterator it =
- objectTargets.begin();
- it != objectTargets.end(); ++it) {
- objectLibraries.push_back(*it);
+ for (cmGeneratorTarget* gt : objectTargets) {
+ objectLibraries.push_back(gt);
}
} else {
this->GetExternalObjects(externalObjects, config);
- for (std::vector<cmSourceFile const*>::const_iterator i =
- externalObjects.begin();
- i != externalObjects.end(); ++i) {
- std::string objLib = (*i)->GetObjectLibrary();
+ for (cmSourceFile const* extObj : externalObjects) {
+ std::string objLib = extObj->GetObjectLibrary();
if (cmGeneratorTarget* tgt =
this->LocalGenerator->FindGeneratorTargetToUse(objLib)) {
- objectLibraries.push_back(tgt);
+ auto const objLibIt =
+ std::find_if(objectLibraries.cbegin(), objectLibraries.cend(),
+ [tgt](cmGeneratorTarget* t) { return t == tgt; });
+ if (objectLibraries.cend() == objLibIt) {
+ objectLibraries.push_back(tgt);
+ }
}
}
}
- for (std::vector<cmGeneratorTarget*>::const_iterator i =
- objectLibraries.begin();
- i != objectLibraries.end(); ++i) {
- (*i)->GetLanguages(languages, config);
+ for (cmGeneratorTarget* objLib : objectLibraries) {
+ objLib->GetLanguages(languages, config);
+ }
+}
+
+bool cmGeneratorTarget::IsCSharpOnly() const
+{
+ // Only certain target types may compile CSharp.
+ if (this->GetType() != cmStateEnums::SHARED_LIBRARY &&
+ this->GetType() != cmStateEnums::STATIC_LIBRARY &&
+ this->GetType() != cmStateEnums::EXECUTABLE) {
+ return false;
+ }
+ std::set<std::string> languages;
+ this->GetLanguages(languages, "");
+ // Consider an explicit linker language property, but *not* the
+ // computed linker language that may depend on linked targets.
+ const char* linkLang = this->GetProperty("LINKER_LANGUAGE");
+ if (linkLang && *linkLang) {
+ languages.insert(linkLang);
}
+ return languages.size() == 1 && languages.count("CSharp") > 0;
}
void cmGeneratorTarget::ComputeLinkImplementationLanguages(
@@ -5248,7 +6397,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLanguages(
std::set<std::string> languages;
// Get languages used in our source files.
this->GetLanguages(languages, config);
- // Copy the set of langauges to the link implementation.
+ // Copy the set of languages to the link implementation.
impl.Languages.insert(impl.Languages.begin(), languages.begin(),
languages.end());
}
@@ -5258,7 +6407,8 @@ bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const
if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) {
return false;
}
- if (this->GetProperty("BUILD_RPATH")) {
+ std::string build_rpath;
+ if (this->GetBuildRPATH(config, build_rpath)) {
return true;
}
if (cmLinkImplementationLibraries const* impl =
@@ -5281,7 +6431,7 @@ cmGeneratorTarget::GetLinkImplementationLibrariesInternal(
{
// There is no link implementation for imported targets.
if (this->IsImported()) {
- return CM_NULLPTR;
+ return nullptr;
}
// Populate the link implementation libraries for this configuration.
@@ -5305,8 +6455,7 @@ cmGeneratorTarget::GetLinkImplementationLibrariesInternal(
bool cmGeneratorTarget::IsNullImpliedByLinkLibraries(
const std::string& p) const
{
- return this->LinkImplicitNullProperties.find(p) !=
- this->LinkImplicitNullProperties.end();
+ return cmContains(this->LinkImplicitNullProperties, p);
}
void cmGeneratorTarget::ComputeLinkImplementationLibraries(
@@ -5321,30 +6470,29 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
end = entryRange.end();
le != end; ++le, ++btIt) {
std::vector<std::string> llibs;
- cmGeneratorExpressionDAGChecker dagChecker(
- this->GetName(), "LINK_LIBRARIES", CM_NULLPTR, CM_NULLPTR);
+ cmGeneratorExpressionDAGChecker dagChecker(this, "LINK_LIBRARIES", nullptr,
+ nullptr);
cmGeneratorExpression ge(*btIt);
- CM_AUTO_PTR<cmCompiledGeneratorExpression> const cge = ge.Parse(*le);
- std::string const evaluated =
- cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker);
- cmSystemTools::ExpandListArgument(evaluated, llibs);
+ std::unique_ptr<cmCompiledGeneratorExpression> const cge = ge.Parse(*le);
+ std::string const& evaluated =
+ cge->Evaluate(this->LocalGenerator, config, head, &dagChecker);
+ cmExpandList(evaluated, llibs);
if (cge->GetHadHeadSensitiveCondition()) {
impl.HadHeadSensitiveCondition = true;
}
- for (std::vector<std::string>::const_iterator li = llibs.begin();
- li != llibs.end(); ++li) {
+ for (std::string const& lib : llibs) {
// Skip entries that resolve to the target itself or are empty.
- std::string name = this->CheckCMP0004(*li);
+ std::string name = this->CheckCMP0004(lib);
if (name == this->GetName() || name.empty()) {
if (name == this->GetName()) {
bool noMessage = false;
- cmake::MessageType messageType = cmake::FATAL_ERROR;
+ MessageType messageType = MessageType::FATAL_ERROR;
std::ostringstream e;
switch (this->GetPolicyStatusCMP0038()) {
case cmPolicies::WARN: {
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0038) << "\n";
- messageType = cmake::AUTHOR_WARNING;
+ messageType = MessageType::AUTHOR_WARNING;
} break;
case cmPolicies::OLD:
noMessage = true;
@@ -5359,7 +6507,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
e << "Target \"" << this->GetName() << "\" links to itself.";
this->LocalGenerator->GetCMakeInstance()->IssueMessage(
messageType, e.str(), this->GetBacktrace());
- if (messageType == cmake::FATAL_ERROR) {
+ if (messageType == MessageType::FATAL_ERROR) {
return;
}
}
@@ -5368,15 +6516,14 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
}
// The entry is meant for this configuration.
- impl.Libraries.push_back(cmLinkImplItem(
- name, this->FindTargetToLink(name), *btIt, evaluated != *le));
+ impl.Libraries.emplace_back(this->ResolveLinkItem(name, *btIt),
+ evaluated != *le);
}
std::set<std::string> const& seenProps = cge->GetSeenTargetProperties();
- for (std::set<std::string>::const_iterator it = seenProps.begin();
- it != seenProps.end(); ++it) {
- if (!this->GetProperty(*it)) {
- this->LinkImplicitNullProperties.insert(*it);
+ for (std::string const& sp : seenProps) {
+ if (!this->GetProperty(sp)) {
+ this->LinkImplicitNullProperties.insert(sp);
}
}
cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards);
@@ -5390,49 +6537,79 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
CMP0003_ComputeLinkType(config, debugConfigs);
cmTarget::LinkLibraryVectorType const& oldllibs =
this->Target->GetOriginalLinkLibraries();
- for (cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin();
- li != oldllibs.end(); ++li) {
- if (li->second != GENERAL_LibraryType && li->second != linkType) {
- std::string name = this->CheckCMP0004(li->first);
+ for (cmTarget::LibraryID const& oldllib : oldllibs) {
+ if (oldllib.second != GENERAL_LibraryType && oldllib.second != linkType) {
+ std::string name = this->CheckCMP0004(oldllib.first);
if (name == this->GetName() || name.empty()) {
continue;
}
// Support OLD behavior for CMP0003.
impl.WrongConfigLibraries.push_back(
- cmLinkItem(name, this->FindTargetToLink(name)));
+ this->ResolveLinkItem(name, cmListFileBacktrace()));
}
}
}
-cmGeneratorTarget* cmGeneratorTarget::FindTargetToLink(
+cmGeneratorTarget::TargetOrString cmGeneratorTarget::ResolveTargetReference(
std::string const& name) const
{
- cmGeneratorTarget* tgt =
- this->LocalGenerator->FindGeneratorTargetToUse(name);
+ cmLocalGenerator const* lg = this->LocalGenerator;
+ std::string const* lookupName = &name;
+
+ // When target_link_libraries() is called with a LHS target that is
+ // not created in the calling directory it adds a directory id suffix
+ // that we can use to look up the calling directory. It is that scope
+ // in which the item name is meaningful. This case is relatively rare
+ // so we allocate a separate string only when the directory id is present.
+ std::string::size_type pos = name.find(CMAKE_DIRECTORY_ID_SEP);
+ std::string plainName;
+ if (pos != std::string::npos) {
+ // We will look up the plain name without the directory id suffix.
+ plainName = name.substr(0, pos);
+
+ // We will look up in the scope of the directory id.
+ // If we do not recognize the id then leave the original
+ // syntax in place to produce an indicative error later.
+ cmDirectoryId const dirId =
+ name.substr(pos + sizeof(CMAKE_DIRECTORY_ID_SEP) - 1);
+ if (cmLocalGenerator const* otherLG =
+ this->GlobalGenerator->FindLocalGenerator(dirId)) {
+ lg = otherLG;
+ lookupName = &plainName;
+ }
+ }
+
+ TargetOrString resolved;
+
+ if (cmGeneratorTarget* tgt = lg->FindGeneratorTargetToUse(*lookupName)) {
+ resolved.Target = tgt;
+ } else if (lookupName == &plainName) {
+ resolved.String = std::move(plainName);
+ } else {
+ resolved.String = name;
+ }
+
+ return resolved;
+}
+
+cmLinkItem cmGeneratorTarget::ResolveLinkItem(
+ std::string const& name, cmListFileBacktrace const& bt) const
+{
+ TargetOrString resolved = this->ResolveTargetReference(name);
+
+ if (!resolved.Target) {
+ return cmLinkItem(resolved.String, bt);
+ }
// Skip targets that will not really be linked. This is probably a
// name conflict between an external library and an executable
// within the project.
- if (tgt && tgt->GetType() == cmStateEnums::EXECUTABLE &&
- !tgt->IsExecutableWithExports()) {
- tgt = CM_NULLPTR;
- }
-
- if (tgt && tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
- std::ostringstream e;
- e << "Target \"" << this->GetName() << "\" links to "
- "OBJECT library \""
- << tgt->GetName()
- << "\" but this is not "
- "allowed. "
- "One may link only to STATIC or SHARED libraries, or to executables "
- "with the ENABLE_EXPORTS property set.";
- cmake* cm = this->LocalGenerator->GetCMakeInstance();
- cm->IssueMessage(cmake::FATAL_ERROR, e.str(), this->GetBacktrace());
- tgt = CM_NULLPTR;
+ if (resolved.Target->GetType() == cmStateEnums::EXECUTABLE &&
+ !resolved.Target->IsExecutableWithExports()) {
+ return cmLinkItem(resolved.Target->GetName(), bt);
}
- return tgt;
+ return cmLinkItem(resolved.Target, bt);
}
std::string cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
@@ -5444,19 +6621,20 @@ std::string cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
return "";
}
-bool cmGeneratorTarget::HasImplibGNUtoMS() const
+bool cmGeneratorTarget::HasImplibGNUtoMS(std::string const& config) const
{
- return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS");
+ return this->HasImportLibrary(config) && this->GetPropertyAsBool("GNUtoMS");
}
-bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& gnuName,
+bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& config,
+ std::string const& gnuName,
std::string& out,
const char* newExt) const
{
- if (this->HasImplibGNUtoMS() && gnuName.size() > 6 &&
+ if (this->HasImplibGNUtoMS(config) && gnuName.size() > 6 &&
gnuName.substr(gnuName.size() - 6) == ".dll.a") {
- out = gnuName.substr(0, gnuName.size() - 6);
- out += newExt ? newExt : ".lib";
+ out = cmStrCat(cm::string_view(gnuName).substr(0, gnuName.size() - 6),
+ newExt ? newExt : ".lib");
return true;
}
return false;
@@ -5468,19 +6646,31 @@ bool cmGeneratorTarget::IsExecutableWithExports() const
this->GetPropertyAsBool("ENABLE_EXPORTS"));
}
-bool cmGeneratorTarget::HasImportLibrary() const
+bool cmGeneratorTarget::HasImportLibrary(std::string const& config) const
{
return (this->IsDLLPlatform() &&
(this->GetType() == cmStateEnums::SHARED_LIBRARY ||
- this->IsExecutableWithExports()));
+ this->IsExecutableWithExports()) &&
+ // Assemblies which have only managed code do not have
+ // import libraries.
+ this->GetManagedType(config) != ManagedType::Managed) ||
+ (this->Target->IsAIX() && this->IsExecutableWithExports());
+}
+
+bool cmGeneratorTarget::NeedImportLibraryName(std::string const& config) const
+{
+ return this->HasImportLibrary(config) ||
+ // On DLL platforms we always generate the import library name
+ // just in case the sources have export markup.
+ (this->IsDLLPlatform() &&
+ (this->GetType() == cmStateEnums::EXECUTABLE ||
+ this->GetType() == cmStateEnums::MODULE_LIBRARY));
}
std::string cmGeneratorTarget::GetSupportDirectory() const
{
- std::string dir = this->LocalGenerator->GetCurrentBinaryDirectory();
- dir += cmake::GetCMakeFilesDirectory();
- dir += "/";
- dir += this->GetName();
+ std::string dir = cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/", this->GetName());
#if defined(__VMS)
dir += "_dir";
#else
@@ -5495,6 +6685,7 @@ bool cmGeneratorTarget::IsLinkable() const
this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->GetType() == cmStateEnums::MODULE_LIBRARY ||
this->GetType() == cmStateEnums::UNKNOWN_LIBRARY ||
+ this->GetType() == cmStateEnums::OBJECT_LIBRARY ||
this->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
this->IsExecutableWithExports());
}
@@ -5524,3 +6715,52 @@ bool cmGeneratorTarget::IsCFBundleOnApple() const
return (this->GetType() == cmStateEnums::MODULE_LIBRARY &&
this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("BUNDLE"));
}
+
+cmGeneratorTarget::ManagedType cmGeneratorTarget::CheckManagedType(
+ std::string const& propval) const
+{
+ // The type of the managed assembly (mixed unmanaged C++ and C++/CLI,
+ // or only C++/CLI) does only depend on whether the property is an empty
+ // string or contains any value at all. In Visual Studio generators
+ // this propval is prepended with /clr[:] which results in:
+ //
+ // 1. propval does not exist: no /clr flag, unmanaged target, has import
+ // lib
+ // 2. empty propval: add /clr as flag, mixed unmanaged/managed
+ // target, has import lib
+ // 3. any value (safe,pure): add /clr:[propval] as flag, target with
+ // managed code only, no import lib
+ return propval.empty() ? ManagedType::Mixed : ManagedType::Managed;
+}
+
+cmGeneratorTarget::ManagedType cmGeneratorTarget::GetManagedType(
+ const std::string& config) const
+{
+ // Only libraries and executables can be managed targets.
+ if (this->GetType() > cmStateEnums::SHARED_LIBRARY) {
+ return ManagedType::Undefined;
+ }
+
+ if (this->GetType() == cmStateEnums::STATIC_LIBRARY) {
+ return ManagedType::Native;
+ }
+
+ // Check imported target.
+ if (this->IsImported()) {
+ if (cmGeneratorTarget::ImportInfo const* info =
+ this->GetImportInfo(config)) {
+ return info->Managed;
+ }
+ return ManagedType::Undefined;
+ }
+
+ // Check for explicitly set clr target property.
+ if (auto* clr = this->GetProperty("COMMON_LANGUAGE_RUNTIME")) {
+ return this->CheckManagedType(clr);
+ }
+
+ // C# targets are always managed. This language specific check
+ // is added to avoid that the COMMON_LANGUAGE_RUNTIME target property
+ // has to be set manually for C# targets.
+ return this->IsCSharpOnly() ? ManagedType::Managed : ManagedType::Native;
+}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 52147e319..493eafcf0 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -3,20 +3,22 @@
#ifndef cmGeneratorTarget_h
#define cmGeneratorTarget_h
-#include "cmConfigure.h"
-
-#include "cmLinkItem.h"
-#include "cmListFileCache.h"
-#include "cmPolicies.h"
-#include "cmStateTypes.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <cstddef>
#include <map>
#include <set>
-#include <stddef.h>
#include <string>
+#include <unordered_map>
+#include <unordered_set>
#include <utility>
#include <vector>
+#include "cmLinkItem.h"
+#include "cmListFileCache.h"
+#include "cmPolicies.h"
+#include "cmStateTypes.h"
+
class cmComputeLinkInformation;
class cmCustomCommand;
class cmGlobalGenerator;
@@ -25,14 +27,18 @@ class cmMakefile;
class cmSourceFile;
class cmTarget;
+struct cmGeneratorExpressionContext;
+struct cmGeneratorExpressionDAGChecker;
+
class cmGeneratorTarget
{
- CM_DISABLE_COPY(cmGeneratorTarget)
-
public:
cmGeneratorTarget(cmTarget*, cmLocalGenerator* lg);
~cmGeneratorTarget();
+ cmGeneratorTarget(cmGeneratorTarget const&) = delete;
+ cmGeneratorTarget& operator=(cmGeneratorTarget const&) = delete;
+
cmLocalGenerator* GetLocalGenerator() const;
cmGlobalGenerator* GetGlobalGenerator() const;
@@ -68,12 +74,15 @@ public:
std::string GetExportName() const;
std::vector<std::string> GetPropertyKeys() const;
+ //! Might return a nullptr if the property is not set or invalid
const char* GetProperty(const std::string& prop) const;
+ //! Always returns a valid pointer
+ const char* GetSafeProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;
void GetSourceFiles(std::vector<cmSourceFile*>& files,
const std::string& config) const;
- void GetSourceFilesWithoutObjectLibraries(std::vector<cmSourceFile*>& files,
- const std::string& config) const;
+ std::vector<BT<cmSourceFile*>> GetSourceFiles(
+ std::string const& config) const;
/** Source file kinds (classifications).
Generators use this to decide how to treat a source file. */
@@ -90,13 +99,14 @@ public:
SourceKindModuleDefinition,
SourceKindObjectSource,
SourceKindResx,
- SourceKindXaml
+ SourceKindXaml,
+ SourceKindUnityBatched
};
/** A source file paired with a kind (classification). */
struct SourceAndKind
{
- cmSourceFile* Source;
+ BT<cmSourceFile*> Source;
SourceKind Kind;
};
@@ -107,11 +117,7 @@ public:
std::set<std::string> ExpectedResxHeaders;
std::set<std::string> ExpectedXamlHeaders;
std::set<std::string> ExpectedXamlSources;
- bool Initialized;
- KindedSources()
- : Initialized(false)
- {
- }
+ bool Initialized = false;
};
/** Get all sources needed for a configuration with kinds assigned. */
@@ -170,6 +176,8 @@ public:
const char* GetFeature(const std::string& feature,
const std::string& config) const;
+ const char* GetLinkPIEProperty(const std::string& config) const;
+
bool IsIPOEnabled(std::string const& lang, std::string const& config) const;
bool IsLinkInterfaceDependentBoolProperty(const std::string& p,
@@ -260,20 +268,17 @@ public:
BundleDirectoryLevel level) const;
/** Return the install name directory for the target in the
- * build tree. For example: "\@rpath/", "\@loader_path/",
- * or "/full/path/to/library". */
+ * build tree. For example: "\@rpath/", "\@loader_path/",
+ * or "/full/path/to/library". */
std::string GetInstallNameDirForBuildTree(const std::string& config) const;
/** Return the install name directory for the target in the
- * install tree. For example: "\@rpath/" or "\@loader_path/". */
+ * install tree. For example: "\@rpath/" or "\@loader_path/". */
std::string GetInstallNameDirForInstallTree() const;
cmListFileBacktrace GetBacktrace() const;
- const std::vector<std::string>& GetLinkDirectories() const;
-
- std::set<std::string> const& GetUtilities() const;
- cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
+ std::set<BT<std::string>> const& GetUtilities() const;
bool LinkLanguagePropagatesToDependents() const
{
@@ -282,7 +287,7 @@ public:
/** Get the macro to define when building sources in this target.
If no macro should be defined null is returned. */
- const char* GetExportMacro() const;
+ const std::string* GetExportMacro() const;
/** Get the soname of the target. Allowed only for a shared library. */
std::string GetSOName(const std::string& config) const;
@@ -354,7 +359,15 @@ public:
cmOptionalLinkImplementation& impl,
const cmGeneratorTarget* head) const;
- cmGeneratorTarget* FindTargetToLink(std::string const& name) const;
+ struct TargetOrString
+ {
+ std::string String;
+ cmGeneratorTarget* Target = nullptr;
+ };
+ TargetOrString ResolveTargetReference(std::string const& name) const;
+
+ cmLinkItem ResolveLinkItem(std::string const& name,
+ cmListFileBacktrace const& bt) const;
// Compute the set of languages compiled by the target. This is
// computed every time it is called because the languages can change
@@ -364,6 +377,8 @@ public:
void GetLanguages(std::set<std::string>& languages,
std::string const& config) const;
+ bool IsCSharpOnly() const;
+
void GetObjectLibrariesCMP0026(
std::vector<cmGeneratorTarget*>& objlibs) const;
@@ -398,22 +413,72 @@ public:
std::string const& config) const;
/** Get the include directories for this target. */
- std::vector<std::string> GetIncludeDirectories(
+ std::vector<BT<std::string>> GetIncludeDirectories(
const std::string& config, const std::string& lang) const;
void GetCompileOptions(std::vector<std::string>& result,
const std::string& config,
const std::string& language) const;
+ std::vector<BT<std::string>> GetCompileOptions(
+ std::string const& config, std::string const& language) const;
void GetCompileFeatures(std::vector<std::string>& features,
const std::string& config) const;
+ std::vector<BT<std::string>> GetCompileFeatures(
+ std::string const& config) const;
void GetCompileDefinitions(std::vector<std::string>& result,
const std::string& config,
const std::string& language) const;
+ std::vector<BT<std::string>> GetCompileDefinitions(
+ std::string const& config, std::string const& language) const;
+
+ void GetLinkOptions(std::vector<std::string>& result,
+ const std::string& config,
+ const std::string& language) const;
+ std::vector<BT<std::string>> GetLinkOptions(
+ std::string const& config, std::string const& language) const;
+
+ void GetStaticLibraryLinkOptions(std::vector<std::string>& result,
+ const std::string& config,
+ const std::string& language) const;
+ std::vector<BT<std::string>> GetStaticLibraryLinkOptions(
+ std::string const& config, std::string const& language) const;
+
+ void GetLinkDirectories(std::vector<std::string>& result,
+ const std::string& config,
+ const std::string& language) const;
+ std::vector<BT<std::string>> GetLinkDirectories(
+ std::string const& config, std::string const& language) const;
+
+ void GetLinkDepends(std::vector<std::string>& result,
+ const std::string& config,
+ const std::string& language) const;
+ std::vector<BT<std::string>> GetLinkDepends(
+ std::string const& config, std::string const& language) const;
+
+ std::vector<BT<std::string>> GetPrecompileHeaders(
+ const std::string& config, const std::string& language) const;
+
+ std::string GetPchHeader(const std::string& config,
+ const std::string& language) const;
+ std::string GetPchSource(const std::string& config,
+ const std::string& language) const;
+ std::string GetPchFileObject(const std::string& config,
+ const std::string& language);
+ std::string GetPchFile(const std::string& config,
+ const std::string& language);
+ std::string GetPchCreateCompileOptions(const std::string& config,
+ const std::string& language);
+ std::string GetPchUseCompileOptions(const std::string& config,
+ const std::string& language);
+
+ void AddSourceFileToUnityBatch(const std::string& sourceFilename);
+ bool IsSourceFilePartOfUnityBatch(const std::string& sourceFilename) const;
bool IsSystemIncludeDirectory(const std::string& dir,
- const std::string& config) const;
+ const std::string& config,
+ const std::string& language) const;
/** Add the target output files to the global generator manifest. */
void ComputeTargetManifest(const std::string& config) const;
@@ -463,6 +528,9 @@ public:
OutputInfo const* GetOutputInfo(const std::string& config) const;
+ // Get the target PDB base name.
+ std::string GetPDBOutputName(const std::string& config) const;
+
/** Get the name of the pdb file for the target. */
std::string GetPDBName(const std::string& config = "") const;
@@ -476,7 +544,7 @@ public:
CompileInfo const* GetCompileInfo(const std::string& config) const;
- typedef std::map<std::string, CompileInfo> CompileInfoMapType;
+ using CompileInfoMapType = std::map<std::string, CompileInfo>;
mutable CompileInfoMapType CompileInfoMap;
bool IsNullImpliedByLinkLibraries(const std::string& p) const;
@@ -491,7 +559,24 @@ public:
std::string GetOutputName(const std::string& config,
cmStateEnums::ArtifactType artifact) const;
- void AddSource(const std::string& src);
+ /** Get target file prefix */
+ std::string GetFilePrefix(const std::string& config,
+ cmStateEnums::ArtifactType artifact =
+ cmStateEnums::RuntimeBinaryArtifact) const;
+ /** Get target file prefix */
+ std::string GetFileSuffix(const std::string& config,
+ cmStateEnums::ArtifactType artifact =
+ cmStateEnums::RuntimeBinaryArtifact) const;
+
+ /** Get target file postfix */
+ std::string GetFilePostfix(const std::string& config) const;
+
+ /** Clears cached meta data for local and external source files.
+ * The meta data will be recomputed on demand.
+ */
+ void ClearSourcesCache();
+
+ void AddSource(const std::string& src, bool before = false);
void AddTracedSources(std::vector<std::string> const& srcs);
/**
@@ -517,30 +602,31 @@ public:
};
struct SourceFileFlags
{
- SourceFileFlags()
- : Type(SourceFileTypeNormal)
- , MacFolder(CM_NULLPTR)
- {
- }
- SourceFileType Type;
- const char* MacFolder; // location inside Mac content folders
+ SourceFileType Type = SourceFileTypeNormal;
+ const char* MacFolder = nullptr; // location inside Mac content folders
};
void GetAutoUicOptions(std::vector<std::string>& result,
const std::string& config) const;
+ struct Names
+ {
+ std::string Base;
+ std::string Output;
+ std::string Real;
+ std::string ImportLibrary;
+ std::string PDB;
+ std::string SharedObject;
+ };
+
/** Get the names of the executable needed to generate a build rule
that takes into account executable version numbers. This should
be called only on an executable target. */
- void GetExecutableNames(std::string& name, std::string& realName,
- std::string& impName, std::string& pdbName,
- const std::string& config) const;
+ Names GetExecutableNames(const std::string& config) const;
/** Get the names of the library needed to generate a build rule
that takes into account shared library version numbers. This
should be called only on a library target. */
- void GetLibraryNames(std::string& name, std::string& soName,
- std::string& realName, std::string& impName,
- std::string& pdbName, const std::string& config) const;
+ Names GetLibraryNames(const std::string& config) const;
/**
* Compute whether this target must be relinked before installing.
@@ -556,21 +642,21 @@ public:
pdb output directory is given. */
std::string GetPDBDirectory(const std::string& config) const;
- ///! Return the preferred linker language for this target
+ //! Return the preferred linker language for this target
std::string GetLinkerLanguage(const std::string& config) const;
/** Does this target have a GNU implib to convert to MS format? */
- bool HasImplibGNUtoMS() const;
+ bool HasImplibGNUtoMS(std::string const& config) const;
/** Convert the given GNU import library name (.dll.a) to a name with a new
extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */
- bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out,
- const char* newExt = CM_NULLPTR) const;
+ bool GetImplibGNUtoMS(std::string const& config, std::string const& gnuName,
+ std::string& out, const char* newExt = nullptr) const;
bool IsExecutableWithExports() const;
/** Return whether or not the target has a DLL import library. */
- bool HasImportLibrary() const;
+ bool HasImportLibrary(std::string const& config) const;
/** Get a build-tree directory in which to place target support files. */
std::string GetSupportDirectory() const;
@@ -591,6 +677,19 @@ public:
/** Return whether this target is a CFBundle (plugin) on Apple. */
bool IsCFBundleOnApple() const;
+ /** Assembly types. The order of the values of this enum is relevant
+ because of smaller/larger comparison operations! */
+ enum ManagedType
+ {
+ Undefined = 0, // target is no lib or executable
+ Native, // target compiles to unmanaged binary.
+ Mixed, // target compiles to mixed (managed and unmanaged) binary.
+ Managed // target compiles to managed binary.
+ };
+
+ /** Return the type of assembly this target compiles to. */
+ ManagedType GetManagedType(const std::string& config) const;
+
struct SourceFileFlags GetTargetSourceFileFlags(
const cmSourceFile* sf) const;
@@ -600,7 +699,14 @@ public:
class TargetPropertyEntry;
- bool HaveInstallTreeRPATH() const;
+ std::string EvaluateInterfaceProperty(
+ std::string const& prop, cmGeneratorExpressionContext* context,
+ cmGeneratorExpressionDAGChecker* dagCheckerParent) const;
+
+ bool HaveInstallTreeRPATH(const std::string& config) const;
+
+ bool GetBuildRPATH(const std::string& config, std::string& rpath) const;
+ bool GetInstallRPATH(const std::string& config, std::string& rpath) const;
/** Whether this library has \@rpath and platform supports it. */
bool HasMacOSXRpathInstallNameDir(const std::string& config) const;
@@ -622,7 +728,7 @@ public:
no soname at all. */
bool IsImportedSharedLibWithoutSOName(const std::string& config) const;
- const char* ImportedGetLocation(const std::string& config) const;
+ std::string ImportedGetLocation(const std::string& config) const;
/** Get the target major and minor version numbers interpreted from
the VERSION property. Version 0 is returned if the property is
@@ -640,7 +746,7 @@ public:
const char* GetSourcesProperty() const;
private:
- void AddSourceCommon(const std::string& src);
+ void AddSourceCommon(const std::string& src, bool before = false);
std::string CreateFortranModuleDirectory(
std::string const& working_dir) const;
@@ -652,11 +758,11 @@ private:
{
std::vector<cmSourceFile*> Depends;
};
- typedef std::map<cmSourceFile const*, SourceEntry> SourceEntriesType;
+ using SourceEntriesType = std::map<cmSourceFile const*, SourceEntry>;
SourceEntriesType SourceDepends;
mutable std::map<cmSourceFile const*, std::string> Objects;
std::set<cmSourceFile const*> ExplicitObjectName;
- mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;
+ mutable std::map<std::string, std::vector<std::string>> SystemIncludesCache;
mutable std::string ExportMacro;
@@ -666,6 +772,15 @@ private:
mutable std::map<std::string, bool> DebugCompatiblePropertiesDone;
+ bool NeedImportLibraryName(std::string const& config) const;
+
+ const char* GetFilePrefixInternal(std::string const& config,
+ cmStateEnums::ArtifactType artifact,
+ const std::string& language = "") const;
+ const char* GetFileSuffixInternal(std::string const& config,
+ cmStateEnums::ArtifactType artifact,
+ const std::string& language = "") const;
+
std::string GetFullNameInternal(const std::string& config,
cmStateEnums::ArtifactType artifact) const;
void GetFullNameInternal(const std::string& config,
@@ -673,7 +788,7 @@ private:
std::string& outPrefix, std::string& outBase,
std::string& outSuffix) const;
- typedef std::map<std::string, LinkClosure> LinkClosureMapType;
+ using LinkClosureMapType = std::map<std::string, LinkClosure>;
mutable LinkClosureMapType LinkClosureMap;
// Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
@@ -696,16 +811,12 @@ private:
struct CompatibleInterfaces : public CompatibleInterfacesBase
{
- CompatibleInterfaces()
- : Done(false)
- {
- }
- bool Done;
+ bool Done = false;
};
mutable std::map<std::string, CompatibleInterfaces> CompatibleInterfacesMap;
- typedef std::map<std::string, cmComputeLinkInformation*>
- cmTargetLinkInformationMap;
+ using cmTargetLinkInformationMap =
+ std::map<std::string, cmComputeLinkInformation*>;
mutable cmTargetLinkInformationMap LinkInformation;
void CheckPropertyCompatibility(cmComputeLinkInformation* info,
@@ -713,15 +824,11 @@ private:
struct LinkImplClosure : public std::vector<cmGeneratorTarget const*>
{
- LinkImplClosure()
- : Done(false)
- {
- }
- bool Done;
+ bool Done = false;
};
mutable std::map<std::string, LinkImplClosure> LinkImplClosureMap;
- typedef std::map<std::string, cmHeadToLinkInterfaceMap> LinkInterfaceMapType;
+ using LinkInterfaceMapType = std::map<std::string, cmHeadToLinkInterfaceMap>;
mutable LinkInterfaceMapType LinkInterfaceMap;
mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap;
@@ -730,16 +837,15 @@ private:
cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap(
std::string const& config) const;
+ std::string GetLinkInterfaceDependentStringAsBoolProperty(
+ const std::string& p, const std::string& config) const;
+
// Cache import information from properties for each configuration.
struct ImportInfo
{
- ImportInfo()
- : NoSOName(false)
- , Multiplicity(0)
- {
- }
- bool NoSOName;
- unsigned int Multiplicity;
+ bool NoSOName = false;
+ ManagedType Managed = Native;
+ unsigned int Multiplicity = 0;
std::string Location;
std::string SOName;
std::string ImportLibrary;
@@ -750,7 +856,7 @@ private:
std::string SharedDeps;
};
- typedef std::map<std::string, ImportInfo> ImportInfoMapType;
+ using ImportInfoMapType = std::map<std::string, ImportInfo>;
mutable ImportInfoMapType ImportInfoMap;
void ComputeImportInfo(std::string const& desired_config,
ImportInfo& info) const;
@@ -764,7 +870,7 @@ private:
const std::string& config, const cmGeneratorTarget* head,
bool usage_requirements_only) const;
- typedef std::map<std::string, KindedSources> KindedSourcesMapType;
+ using KindedSourcesMapType = std::map<std::string, KindedSources>;
mutable KindedSourcesMapType KindedSourcesMap;
void ComputeKindedSources(KindedSources& files,
std::string const& config) const;
@@ -772,12 +878,27 @@ private:
mutable std::vector<AllConfigSource> AllConfigSources;
void ComputeAllConfigSources() const;
+ mutable std::unordered_map<std::string, bool> MaybeInterfacePropertyExists;
+ bool MaybeHaveInterfaceProperty(std::string const& prop,
+ cmGeneratorExpressionContext* context) const;
+
std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
std::vector<TargetPropertyEntry*> CompileOptionsEntries;
std::vector<TargetPropertyEntry*> CompileFeaturesEntries;
std::vector<TargetPropertyEntry*> CompileDefinitionsEntries;
+ std::vector<TargetPropertyEntry*> LinkOptionsEntries;
+ std::vector<TargetPropertyEntry*> LinkDirectoriesEntries;
+ std::vector<TargetPropertyEntry*> PrecompileHeadersEntries;
std::vector<TargetPropertyEntry*> SourceEntries;
mutable std::set<std::string> LinkImplicitNullProperties;
+ mutable std::map<std::string, std::string> PchHeaders;
+ mutable std::map<std::string, std::string> PchSources;
+ mutable std::map<std::string, std::string> PchObjectFiles;
+ mutable std::map<std::string, std::string> PchFiles;
+ mutable std::map<std::string, std::string> PchCreateCompileOptions;
+ mutable std::map<std::string, std::string> PchUseCompileOptions;
+
+ std::unordered_set<std::string> UnityBatchedSourceFiles;
void ExpandLinkItems(std::string const& prop, std::string const& value,
std::string const& config,
@@ -786,16 +907,21 @@ private:
std::vector<cmLinkItem>& items,
bool& hadHeadSensitiveCondition) const;
void LookupLinkItems(std::vector<std::string> const& names,
+ cmListFileBacktrace const& bt,
std::vector<cmLinkItem>& items) const;
- void GetSourceFiles(std::vector<std::string>& files,
- const std::string& config) const;
+ std::vector<BT<std::string>> GetSourceFilePaths(
+ std::string const& config) const;
+ std::vector<BT<cmSourceFile*>> GetSourceFilesWithoutObjectLibraries(
+ std::string const& config) const;
+ void GetSourceFilesWithoutObjectLibraries(std::vector<cmSourceFile*>& files,
+ const std::string& config) const;
struct HeadToLinkImplementationMap
: public std::map<cmGeneratorTarget const*, cmOptionalLinkImplementation>
{
};
- typedef std::map<std::string, HeadToLinkImplementationMap> LinkImplMapType;
+ using LinkImplMapType = std::map<std::string, HeadToLinkImplementationMap>;
mutable LinkImplMapType LinkImplMap;
cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(
@@ -804,17 +930,17 @@ private:
cmStateEnums::ArtifactType artifact,
std::string& out) const;
- typedef std::map<std::string, OutputInfo> OutputInfoMapType;
+ using OutputInfoMapType = std::map<std::string, OutputInfo>;
mutable OutputInfoMapType OutputInfoMap;
- typedef std::map<std::string, ModuleDefinitionInfo>
- ModuleDefinitionInfoMapType;
+ using ModuleDefinitionInfoMapType =
+ std::map<std::string, ModuleDefinitionInfo>;
mutable ModuleDefinitionInfoMapType ModuleDefinitionInfoMap;
void ComputeModuleDefinitionInfo(std::string const& config,
ModuleDefinitionInfo& info) const;
- typedef std::pair<std::string, cmStateEnums::ArtifactType> OutputNameKey;
- typedef std::map<OutputNameKey, std::string> OutputNameMapType;
+ using OutputNameKey = std::pair<std::string, cmStateEnums::ArtifactType>;
+ using OutputNameMapType = std::map<OutputNameKey, std::string>;
mutable OutputNameMapType OutputNameMap;
mutable std::set<cmLinkItem> UtilityItems;
cmPolicies::PolicyMap PolicyMap;
@@ -824,14 +950,21 @@ private:
mutable bool DebugCompileOptionsDone;
mutable bool DebugCompileFeaturesDone;
mutable bool DebugCompileDefinitionsDone;
+ mutable bool DebugLinkOptionsDone;
+ mutable bool DebugLinkDirectoriesDone;
+ mutable bool DebugPrecompileHeadersDone;
mutable bool DebugSourcesDone;
mutable bool LinkImplementationLanguageIsContextDependent;
mutable bool UtilityItemsDone;
- bool DLLPlatform;
bool ComputePDBOutputDir(const std::string& kind, const std::string& config,
std::string& out) const;
+ ManagedType CheckManagedType(std::string const& propval) const;
+
+ bool GetRPATH(const std::string& config, const std::string& prop,
+ std::string& rpath) const;
+
public:
const std::vector<const cmGeneratorTarget*>& GetLinkImplementationClosure(
const std::string& config) const;
diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx
index 5ba3326cb..ff4e312f3 100644
--- a/Source/cmGetCMakePropertyCommand.cxx
+++ b/Source/cmGetCMakePropertyCommand.cxx
@@ -4,19 +4,18 @@
#include <set>
-#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmState.h"
-
-class cmExecutionStatus;
+#include "cmStringAlgorithms.h"
// cmGetCMakePropertyCommand
-bool cmGetCMakePropertyCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmGetCMakePropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
@@ -24,29 +23,29 @@ bool cmGetCMakePropertyCommand::InitialPass(
std::string output = "NOTFOUND";
if (args[1] == "VARIABLES") {
- if (const char* varsProp = this->Makefile->GetProperty("VARIABLES")) {
+ if (const char* varsProp = status.GetMakefile().GetProperty("VARIABLES")) {
output = varsProp;
}
} else if (args[1] == "MACROS") {
output.clear();
- if (const char* macrosProp = this->Makefile->GetProperty("MACROS")) {
+ if (const char* macrosProp = status.GetMakefile().GetProperty("MACROS")) {
output = macrosProp;
}
} else if (args[1] == "COMPONENTS") {
const std::set<std::string>* components =
- this->Makefile->GetGlobalGenerator()->GetInstallComponents();
+ status.GetMakefile().GetGlobalGenerator()->GetInstallComponents();
output = cmJoin(*components, ";");
} else {
- const char* prop = CM_NULLPTR;
+ const char* prop = nullptr;
if (!args[1].empty()) {
- prop = this->Makefile->GetState()->GetGlobalProperty(args[1]);
+ prop = status.GetMakefile().GetState()->GetGlobalProperty(args[1]);
}
if (prop) {
output = prop;
}
}
- this->Makefile->AddDefinition(variable, output.c_str());
+ status.GetMakefile().AddDefinition(variable, output);
return true;
}
diff --git a/Source/cmGetCMakePropertyCommand.h b/Source/cmGetCMakePropertyCommand.h
index 9dfc40fda..7a6728cfe 100644
--- a/Source/cmGetCMakePropertyCommand.h
+++ b/Source/cmGetCMakePropertyCommand.h
@@ -3,26 +3,14 @@
#ifndef cmGetCMakePropertyCommand_h
#define cmGetCMakePropertyCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmGetCMakePropertyCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmGetCMakePropertyCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmGetCMakePropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx
index 1005b1543..64438d50a 100644
--- a/Source/cmGetDirectoryPropertyCommand.cxx
+++ b/Source/cmGetDirectoryPropertyCommand.cxx
@@ -2,51 +2,54 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGetDirectoryPropertyCommand.h"
+#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-class cmExecutionStatus;
+namespace {
+void StoreResult(cmMakefile& makefile, std::string const& variable,
+ const char* prop);
+}
// cmGetDirectoryPropertyCommand
-bool cmGetDirectoryPropertyCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmGetDirectoryPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- std::vector<std::string>::const_iterator i = args.begin();
+ auto i = args.begin();
std::string const& variable = *i;
++i;
// get the directory argument if there is one
- cmMakefile* dir = this->Makefile;
+ cmMakefile* dir = &status.GetMakefile();
if (*i == "DIRECTORY") {
++i;
if (i == args.end()) {
- this->SetError(
+ status.SetError(
"DIRECTORY argument provided without subsequent arguments");
return false;
}
std::string sd = *i;
// make sure the start dir is a full path
- if (!cmSystemTools::FileIsFullPath(sd.c_str())) {
- sd = this->Makefile->GetCurrentSourceDirectory();
- sd += "/";
- sd += *i;
+ if (!cmSystemTools::FileIsFullPath(sd)) {
+ sd = cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', *i);
}
// The local generators are associated with collapsed paths.
sd = cmSystemTools::CollapseFullPath(sd);
// lookup the makefile from the directory name
- dir = this->Makefile->GetGlobalGenerator()->FindMakefile(sd);
+ dir = status.GetMakefile().GetGlobalGenerator()->FindMakefile(sd);
if (!dir) {
- this->SetError(
+ status.SetError(
"DIRECTORY argument provided but requested directory not found. "
"This could be because the directory argument was invalid or, "
"it is valid but has not been processed yet.");
@@ -61,26 +64,27 @@ bool cmGetDirectoryPropertyCommand::InitialPass(
if (*i == "DEFINITION") {
++i;
if (i == args.end()) {
- this->SetError("A request for a variable definition was made without "
- "providing the name of the variable to get.");
+ status.SetError("A request for a variable definition was made without "
+ "providing the name of the variable to get.");
return false;
}
- std::string output = dir->GetSafeDefinition(*i);
- this->Makefile->AddDefinition(variable, output.c_str());
+ std::string const& output = dir->GetSafeDefinition(*i);
+ status.GetMakefile().AddDefinition(variable, output);
return true;
}
- const char* prop = CM_NULLPTR;
+ const char* prop = nullptr;
if (!i->empty()) {
if (*i == "DEFINITIONS") {
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0059)) {
+ switch (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0059)) {
case cmPolicies::WARN:
- this->Makefile->IssueMessage(
- cmake::AUTHOR_WARNING,
+ status.GetMakefile().IssueMessage(
+ MessageType::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(cmPolicies::CMP0059));
CM_FALLTHROUGH;
case cmPolicies::OLD:
- this->StoreResult(variable, this->Makefile->GetDefineFlagsCMP0059());
+ StoreResult(status.GetMakefile(), variable,
+ status.GetMakefile().GetDefineFlagsCMP0059());
return true;
case cmPolicies::NEW:
case cmPolicies::REQUIRED_ALWAYS:
@@ -90,16 +94,14 @@ bool cmGetDirectoryPropertyCommand::InitialPass(
}
prop = dir->GetProperty(*i);
}
- this->StoreResult(variable, prop);
+ StoreResult(status.GetMakefile(), variable, prop);
return true;
}
-void cmGetDirectoryPropertyCommand::StoreResult(std::string const& variable,
- const char* prop)
+namespace {
+void StoreResult(cmMakefile& makefile, std::string const& variable,
+ const char* prop)
{
- if (prop) {
- this->Makefile->AddDefinition(variable, prop);
- return;
- }
- this->Makefile->AddDefinition(variable, "");
+ makefile.AddDefinition(variable, prop ? prop : "");
+}
}
diff --git a/Source/cmGetDirectoryPropertyCommand.h b/Source/cmGetDirectoryPropertyCommand.h
index 7d9795065..f356ea5b4 100644
--- a/Source/cmGetDirectoryPropertyCommand.h
+++ b/Source/cmGetDirectoryPropertyCommand.h
@@ -3,29 +3,14 @@
#ifndef cmGetDirectoryPropertyCommand_h
#define cmGetDirectoryPropertyCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmGetDirectoryPropertyCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmGetDirectoryPropertyCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- void StoreResult(const std::string& variable, const char* prop);
-};
+bool cmGetDirectoryPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx
index c23684c22..7d91a7570 100644
--- a/Source/cmGetFilenameComponentCommand.cxx
+++ b/Source/cmGetFilenameComponentCommand.cxx
@@ -2,26 +2,26 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGetFilenameComponentCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
// cmGetFilenameComponentCommand
-bool cmGetFilenameComponentCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmGetFilenameComponentCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
// Check and see if the value has been stored in the cache
// already, if so use that value
- if (args.size() >= 4 && args[args.size() - 1] == "CACHE") {
- const char* cacheValue = this->Makefile->GetDefinition(args[0]);
- if (cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) {
+ if (args.size() >= 4 && args.back() == "CACHE") {
+ const char* cacheValue = status.GetMakefile().GetDefinition(args.front());
+ if (cacheValue && !cmIsNOTFOUND(cacheValue)) {
return true;
}
}
@@ -32,7 +32,7 @@ bool cmGetFilenameComponentCommand::InitialPass(
// Check the registry as the target application would view it.
cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32;
cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64;
- if (this->Makefile->PlatformIs64Bit()) {
+ if (status.GetMakefile().PlatformIs64Bit()) {
view = cmSystemTools::KeyWOW64_64;
other_view = cmSystemTools::KeyWOW64_32;
}
@@ -60,16 +60,43 @@ bool cmGetFilenameComponentCommand::InitialPass(
}
}
}
- cmSystemTools::SplitProgramFromArgs(filename, result, programArgs);
+
+ // First assume the path to the program was specified with no
+ // arguments and with no quoting or escaping for spaces.
+ // Only bother doing this if there is non-whitespace.
+ if (!cmTrimWhitespace(filename).empty()) {
+ result = cmSystemTools::FindProgram(filename);
+ }
+
+ // If that failed then assume a command-line string was given
+ // and split the program part from the rest of the arguments.
+ if (result.empty()) {
+ std::string program;
+ if (cmSystemTools::SplitProgramFromArgs(filename, program,
+ programArgs)) {
+ if (cmSystemTools::FileExists(program)) {
+ result = program;
+ } else {
+ result = cmSystemTools::FindProgram(program);
+ }
+ }
+ if (result.empty()) {
+ programArgs.clear();
+ }
+ }
} else if (args[2] == "EXT") {
result = cmSystemTools::GetFilenameExtension(filename);
} else if (args[2] == "NAME_WE") {
result = cmSystemTools::GetFilenameWithoutExtension(filename);
+ } else if (args[2] == "LAST_EXT") {
+ result = cmSystemTools::GetFilenameLastExtension(filename);
+ } else if (args[2] == "NAME_WLE") {
+ result = cmSystemTools::GetFilenameWithoutLastExtension(filename);
} else if (args[2] == "ABSOLUTE" || args[2] == "REALPATH") {
// If the path given is relative, evaluate it relative to the
// current source directory unless the user passes a different
// base directory.
- std::string baseDir = this->Makefile->GetCurrentSourceDirectory();
+ std::string baseDir = status.GetMakefile().GetCurrentSourceDirectory();
for (unsigned int i = 3; i < args.size(); ++i) {
if (args[i] == "BASE_DIR") {
++i;
@@ -86,24 +113,24 @@ bool cmGetFilenameComponentCommand::InitialPass(
}
} else {
std::string err = "unknown component " + args[2];
- this->SetError(err);
+ status.SetError(err);
return false;
}
- if (args.size() >= 4 && args[args.size() - 1] == "CACHE") {
+ if (args.size() >= 4 && args.back() == "CACHE") {
if (!programArgs.empty() && !storeArgs.empty()) {
- this->Makefile->AddCacheDefinition(
+ status.GetMakefile().AddCacheDefinition(
storeArgs, programArgs.c_str(), "",
args[2] == "PATH" ? cmStateEnums::FILEPATH : cmStateEnums::STRING);
}
- this->Makefile->AddCacheDefinition(
- args[0], result.c_str(), "",
+ status.GetMakefile().AddCacheDefinition(
+ args.front(), result.c_str(), "",
args[2] == "PATH" ? cmStateEnums::FILEPATH : cmStateEnums::STRING);
} else {
if (!programArgs.empty() && !storeArgs.empty()) {
- this->Makefile->AddDefinition(storeArgs, programArgs.c_str());
+ status.GetMakefile().AddDefinition(storeArgs, programArgs);
}
- this->Makefile->AddDefinition(args[0], result.c_str());
+ status.GetMakefile().AddDefinition(args.front(), result);
}
return true;
diff --git a/Source/cmGetFilenameComponentCommand.h b/Source/cmGetFilenameComponentCommand.h
index c8a23c70e..db5293b2a 100644
--- a/Source/cmGetFilenameComponentCommand.h
+++ b/Source/cmGetFilenameComponentCommand.h
@@ -3,35 +3,20 @@
#ifndef cmGetFilenameComponentCommand_h
#define cmGetFilenameComponentCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmGetFilenameComponentCommand
+/**
* \brief Get a specific component of a filename.
*
* cmGetFilenameComponentCommand is a utility command used to get the path,
* name, extension or name without extension of a full filename.
*/
-class cmGetFilenameComponentCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmGetFilenameComponentCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmGetFilenameComponentCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmGetPipes.cxx b/Source/cmGetPipes.cxx
new file mode 100644
index 000000000..4eda1c54a
--- /dev/null
+++ b/Source/cmGetPipes.cxx
@@ -0,0 +1,49 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmGetPipes.h"
+
+#include <fcntl.h>
+
+#include "cm_uv.h"
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+# include <io.h>
+
+int cmGetPipes(int* fds)
+{
+ SECURITY_ATTRIBUTES attr;
+ HANDLE readh, writeh;
+ attr.nLength = sizeof(attr);
+ attr.lpSecurityDescriptor = nullptr;
+ attr.bInheritHandle = FALSE;
+ if (!CreatePipe(&readh, &writeh, &attr, 0))
+ return uv_translate_sys_error(GetLastError());
+ fds[0] = _open_osfhandle((intptr_t)readh, 0);
+ fds[1] = _open_osfhandle((intptr_t)writeh, 0);
+ if (fds[0] == -1 || fds[1] == -1) {
+ CloseHandle(readh);
+ CloseHandle(writeh);
+ return uv_translate_sys_error(GetLastError());
+ }
+ return 0;
+}
+#else
+# include <cerrno>
+
+# include <unistd.h>
+
+int cmGetPipes(int* fds)
+{
+ if (pipe(fds) == -1) {
+ return uv_translate_sys_error(errno);
+ }
+
+ if (fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
+ fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1) {
+ close(fds[0]);
+ close(fds[1]);
+ return uv_translate_sys_error(errno);
+ }
+ return 0;
+}
+#endif
diff --git a/Source/cmGetPipes.h b/Source/cmGetPipes.h
new file mode 100644
index 000000000..2a46b51b3
--- /dev/null
+++ b/Source/cmGetPipes.h
@@ -0,0 +1,8 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmGetPipes_h
+#define cmGetPipes_h
+
+int cmGetPipes(int* fds);
+
+#endif
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index ddecdf621..947d893db 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -2,41 +2,81 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGetPropertyCommand.h"
-#include <sstream>
-
+#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmInstalledFile.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmProperty.h"
#include "cmPropertyDefinition.h"
#include "cmSourceFile.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetPropertyComputer.h"
#include "cmTest.h"
#include "cmake.h"
-class cmExecutionStatus;
class cmMessenger;
-cmGetPropertyCommand::cmGetPropertyCommand()
+namespace {
+enum OutType
{
- this->InfoType = OutValue;
+ OutValue,
+ OutDefined,
+ OutBriefDoc,
+ OutFullDoc,
+ OutSet
+};
+
+// Implementation of result storage.
+bool StoreResult(OutType infoType, cmMakefile& makefile,
+ const std::string& variable, const char* value);
+
+// Implementation of each property type.
+bool HandleGlobalMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName);
+bool HandleDirectoryMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName);
+bool HandleTargetMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName);
+bool HandleSourceMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName);
+bool HandleTestMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName);
+bool HandleVariableMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName);
+bool HandleCacheMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName);
+bool HandleInstallMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName);
}
-bool cmGetPropertyCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmGetPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
+ OutType infoType = OutValue;
if (args.size() < 3) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
// The cmake variable in which to store the result.
- this->Variable = args[0];
+ const std::string variable = args[0];
+
+ std::string name;
+ std::string propertyName;
// Get the scope from which to get the property.
cmProperty::ScopeType scope;
@@ -57,11 +97,11 @@ bool cmGetPropertyCommand::InitialPass(std::vector<std::string> const& args,
} else if (args[1] == "INSTALL") {
scope = cmProperty::INSTALL;
} else {
- std::ostringstream e;
- e << "given invalid scope " << args[1] << ". "
- << "Valid scopes are "
- << "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE, INSTALL.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(
+ "given invalid scope ", args[1],
+ ". "
+ "Valid scopes are "
+ "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE, INSTALL."));
return false;
}
@@ -79,86 +119,90 @@ bool cmGetPropertyCommand::InitialPass(std::vector<std::string> const& args,
doing = DoingProperty;
} else if (args[i] == "BRIEF_DOCS") {
doing = DoingNone;
- this->InfoType = OutBriefDoc;
+ infoType = OutBriefDoc;
} else if (args[i] == "FULL_DOCS") {
doing = DoingNone;
- this->InfoType = OutFullDoc;
+ infoType = OutFullDoc;
} else if (args[i] == "SET") {
doing = DoingNone;
- this->InfoType = OutSet;
+ infoType = OutSet;
} else if (args[i] == "DEFINED") {
doing = DoingNone;
- this->InfoType = OutDefined;
+ infoType = OutDefined;
} else if (doing == DoingName) {
doing = DoingNone;
- this->Name = args[i];
+ name = args[i];
} else if (doing == DoingProperty) {
doing = DoingNone;
- this->PropertyName = args[i];
+ propertyName = args[i];
} else {
- std::ostringstream e;
- e << "given invalid argument \"" << args[i] << "\".";
- this->SetError(e.str());
+ status.SetError(cmStrCat("given invalid argument \"", args[i], "\"."));
return false;
}
}
// Make sure a property name was found.
- if (this->PropertyName.empty()) {
- this->SetError("not given a PROPERTY <name> argument.");
+ if (propertyName.empty()) {
+ status.SetError("not given a PROPERTY <name> argument.");
return false;
}
// Compute requested output.
- if (this->InfoType == OutBriefDoc) {
+ if (infoType == OutBriefDoc) {
// Lookup brief documentation.
std::string output;
if (cmPropertyDefinition const* def =
- this->Makefile->GetState()->GetPropertyDefinition(this->PropertyName,
- scope)) {
+ status.GetMakefile().GetState()->GetPropertyDefinition(propertyName,
+ scope)) {
output = def->GetShortDescription();
} else {
output = "NOTFOUND";
}
- this->Makefile->AddDefinition(this->Variable, output.c_str());
- } else if (this->InfoType == OutFullDoc) {
+ status.GetMakefile().AddDefinition(variable, output);
+ } else if (infoType == OutFullDoc) {
// Lookup full documentation.
std::string output;
if (cmPropertyDefinition const* def =
- this->Makefile->GetState()->GetPropertyDefinition(this->PropertyName,
- scope)) {
+ status.GetMakefile().GetState()->GetPropertyDefinition(propertyName,
+ scope)) {
output = def->GetFullDescription();
} else {
output = "NOTFOUND";
}
- this->Makefile->AddDefinition(this->Variable, output.c_str());
- } else if (this->InfoType == OutDefined) {
+ status.GetMakefile().AddDefinition(variable, output);
+ } else if (infoType == OutDefined) {
// Lookup if the property is defined
- if (this->Makefile->GetState()->GetPropertyDefinition(this->PropertyName,
- scope)) {
- this->Makefile->AddDefinition(this->Variable, "1");
+ if (status.GetMakefile().GetState()->GetPropertyDefinition(propertyName,
+ scope)) {
+ status.GetMakefile().AddDefinition(variable, "1");
} else {
- this->Makefile->AddDefinition(this->Variable, "0");
+ status.GetMakefile().AddDefinition(variable, "0");
}
} else {
// Dispatch property getting.
switch (scope) {
case cmProperty::GLOBAL:
- return this->HandleGlobalMode();
+ return HandleGlobalMode(status, name, infoType, variable,
+ propertyName);
case cmProperty::DIRECTORY:
- return this->HandleDirectoryMode();
+ return HandleDirectoryMode(status, name, infoType, variable,
+ propertyName);
case cmProperty::TARGET:
- return this->HandleTargetMode();
+ return HandleTargetMode(status, name, infoType, variable,
+ propertyName);
case cmProperty::SOURCE_FILE:
- return this->HandleSourceMode();
+ return HandleSourceMode(status, name, infoType, variable,
+ propertyName);
case cmProperty::TEST:
- return this->HandleTestMode();
+ return HandleTestMode(status, name, infoType, variable, propertyName);
case cmProperty::VARIABLE:
- return this->HandleVariableMode();
+ return HandleVariableMode(status, name, infoType, variable,
+ propertyName);
case cmProperty::CACHE:
- return this->HandleCacheMode();
+ return HandleCacheMode(status, name, infoType, variable, propertyName);
case cmProperty::INSTALL:
- return this->HandleInstallMode();
+ return HandleInstallMode(status, name, infoType, variable,
+ propertyName);
case cmProperty::CACHED_VARIABLE:
break; // should never happen
@@ -168,58 +212,64 @@ bool cmGetPropertyCommand::InitialPass(std::vector<std::string> const& args,
return true;
}
-bool cmGetPropertyCommand::StoreResult(const char* value)
+namespace {
+
+bool StoreResult(OutType infoType, cmMakefile& makefile,
+ const std::string& variable, const char* value)
{
- if (this->InfoType == OutSet) {
- this->Makefile->AddDefinition(this->Variable, value ? "1" : "0");
- } else // if(this->InfoType == OutValue)
+ if (infoType == OutSet) {
+ makefile.AddDefinition(variable, value ? "1" : "0");
+ } else // if(infoType == OutValue)
{
if (value) {
- this->Makefile->AddDefinition(this->Variable, value);
+ makefile.AddDefinition(variable, value);
} else {
- this->Makefile->RemoveDefinition(this->Variable);
+ makefile.RemoveDefinition(variable);
}
}
return true;
}
-bool cmGetPropertyCommand::HandleGlobalMode()
+bool HandleGlobalMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName)
{
- if (!this->Name.empty()) {
- this->SetError("given name for GLOBAL scope.");
+ if (!name.empty()) {
+ status.SetError("given name for GLOBAL scope.");
return false;
}
// Get the property.
- cmake* cm = this->Makefile->GetCMakeInstance();
- return this->StoreResult(
- cm->GetState()->GetGlobalProperty(this->PropertyName));
+ cmake* cm = status.GetMakefile().GetCMakeInstance();
+ return StoreResult(infoType, status.GetMakefile(), variable,
+ cm->GetState()->GetGlobalProperty(propertyName));
}
-bool cmGetPropertyCommand::HandleDirectoryMode()
+bool HandleDirectoryMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName)
{
// Default to the current directory.
- cmMakefile* mf = this->Makefile;
+ cmMakefile* mf = &status.GetMakefile();
// Lookup the directory if given.
- if (!this->Name.empty()) {
+ if (!name.empty()) {
// Construct the directory name. Interpret relative paths with
// respect to the current directory.
- std::string dir = this->Name;
- if (!cmSystemTools::FileIsFullPath(dir.c_str())) {
- dir = this->Makefile->GetCurrentSourceDirectory();
- dir += "/";
- dir += this->Name;
+ std::string dir = name;
+ if (!cmSystemTools::FileIsFullPath(dir)) {
+ dir =
+ cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', name);
}
// The local generators are associated with collapsed paths.
dir = cmSystemTools::CollapseFullPath(dir);
// Lookup the generator.
- mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir);
+ mf = status.GetMakefile().GetGlobalGenerator()->FindMakefile(dir);
if (!mf) {
// Could not find the directory.
- this->SetError(
+ status.SetError(
"DIRECTORY scope provided but requested directory was not found. "
"This could be because the directory argument was invalid or, "
"it is valid but has not been processed yet.");
@@ -227,14 +277,15 @@ bool cmGetPropertyCommand::HandleDirectoryMode()
}
}
- if (this->PropertyName == "DEFINITIONS") {
+ if (propertyName == "DEFINITIONS") {
switch (mf->GetPolicyStatus(cmPolicies::CMP0059)) {
case cmPolicies::WARN:
- mf->IssueMessage(cmake::AUTHOR_WARNING,
+ mf->IssueMessage(MessageType::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(cmPolicies::CMP0059));
CM_FALLTHROUGH;
case cmPolicies::OLD:
- return this->StoreResult(mf->GetDefineFlagsCMP0059());
+ return StoreResult(infoType, status.GetMakefile(), variable,
+ mf->GetDefineFlagsCMP0059());
case cmPolicies::NEW:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::REQUIRED_IF_USED:
@@ -243,124 +294,136 @@ bool cmGetPropertyCommand::HandleDirectoryMode()
}
// Get the property.
- return this->StoreResult(mf->GetProperty(this->PropertyName));
+ return StoreResult(infoType, status.GetMakefile(), variable,
+ mf->GetProperty(propertyName));
}
-bool cmGetPropertyCommand::HandleTargetMode()
+bool HandleTargetMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName)
{
- if (this->Name.empty()) {
- this->SetError("not given name for TARGET scope.");
+ if (name.empty()) {
+ status.SetError("not given name for TARGET scope.");
return false;
}
- if (cmTarget* target = this->Makefile->FindTargetToUse(this->Name)) {
- if (this->PropertyName == "ALIASED_TARGET") {
- if (this->Makefile->IsAlias(this->Name)) {
- return this->StoreResult(target->GetName().c_str());
+ if (cmTarget* target = status.GetMakefile().FindTargetToUse(name)) {
+ if (propertyName == "ALIASED_TARGET") {
+ if (status.GetMakefile().IsAlias(name)) {
+ return StoreResult(infoType, status.GetMakefile(), variable,
+ target->GetName().c_str());
}
- return this->StoreResult(CM_NULLPTR);
+ return StoreResult(infoType, status.GetMakefile(), variable, nullptr);
}
- const char* prop_cstr = CM_NULLPTR;
- cmListFileBacktrace bt = this->Makefile->GetBacktrace();
- cmMessenger* messenger = this->Makefile->GetMessenger();
+ const char* prop_cstr = nullptr;
+ cmListFileBacktrace bt = status.GetMakefile().GetBacktrace();
+ cmMessenger* messenger = status.GetMakefile().GetMessenger();
if (cmTargetPropertyComputer::PassesWhitelist(
- target->GetType(), this->PropertyName, messenger, bt)) {
- prop_cstr =
- target->GetComputedProperty(this->PropertyName, messenger, bt);
+ target->GetType(), propertyName, messenger, bt)) {
+ prop_cstr = target->GetComputedProperty(propertyName, messenger, bt);
if (!prop_cstr) {
- prop_cstr = target->GetProperty(this->PropertyName);
+ prop_cstr = target->GetProperty(propertyName);
}
}
- return this->StoreResult(prop_cstr);
+ return StoreResult(infoType, status.GetMakefile(), variable, prop_cstr);
}
- std::ostringstream e;
- e << "could not find TARGET " << this->Name
- << ". Perhaps it has not yet been created.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("could not find TARGET ", name,
+ ". Perhaps it has not yet been created."));
return false;
}
-bool cmGetPropertyCommand::HandleSourceMode()
+bool HandleSourceMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName)
{
- if (this->Name.empty()) {
- this->SetError("not given name for SOURCE scope.");
+ if (name.empty()) {
+ status.SetError("not given name for SOURCE scope.");
return false;
}
// Get the source file.
- if (cmSourceFile* sf = this->Makefile->GetOrCreateSource(this->Name)) {
- return this->StoreResult(sf->GetPropertyForUser(this->PropertyName));
+ if (cmSourceFile* sf = status.GetMakefile().GetOrCreateSource(name)) {
+ return StoreResult(infoType, status.GetMakefile(), variable,
+ sf->GetPropertyForUser(propertyName));
}
- std::ostringstream e;
- e << "given SOURCE name that could not be found or created: " << this->Name;
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("given SOURCE name that could not be found or created: ", name));
return false;
}
-bool cmGetPropertyCommand::HandleTestMode()
+bool HandleTestMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName)
{
- if (this->Name.empty()) {
- this->SetError("not given name for TEST scope.");
+ if (name.empty()) {
+ status.SetError("not given name for TEST scope.");
return false;
}
// Loop over all tests looking for matching names.
- if (cmTest* test = this->Makefile->GetTest(this->Name)) {
- return this->StoreResult(test->GetProperty(this->PropertyName));
+ if (cmTest* test = status.GetMakefile().GetTest(name)) {
+ return StoreResult(infoType, status.GetMakefile(), variable,
+ test->GetProperty(propertyName));
}
// If not found it is an error.
- std::ostringstream e;
- e << "given TEST name that does not exist: " << this->Name;
- this->SetError(e.str());
+ status.SetError(cmStrCat("given TEST name that does not exist: ", name));
return false;
}
-bool cmGetPropertyCommand::HandleVariableMode()
+bool HandleVariableMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName)
{
- if (!this->Name.empty()) {
- this->SetError("given name for VARIABLE scope.");
+ if (!name.empty()) {
+ status.SetError("given name for VARIABLE scope.");
return false;
}
- return this->StoreResult(this->Makefile->GetDefinition(this->PropertyName));
+ return StoreResult(infoType, status.GetMakefile(), variable,
+ status.GetMakefile().GetDefinition(propertyName));
}
-bool cmGetPropertyCommand::HandleCacheMode()
+bool HandleCacheMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName)
{
- if (this->Name.empty()) {
- this->SetError("not given name for CACHE scope.");
+ if (name.empty()) {
+ status.SetError("not given name for CACHE scope.");
return false;
}
- const char* value = CM_NULLPTR;
- if (this->Makefile->GetState()->GetCacheEntryValue(this->Name)) {
- value = this->Makefile->GetState()->GetCacheEntryProperty(
- this->Name, this->PropertyName);
+ const char* value = nullptr;
+ if (status.GetMakefile().GetState()->GetCacheEntryValue(name)) {
+ value = status.GetMakefile().GetState()->GetCacheEntryProperty(
+ name, propertyName);
}
- this->StoreResult(value);
+ StoreResult(infoType, status.GetMakefile(), variable, value);
return true;
}
-bool cmGetPropertyCommand::HandleInstallMode()
+bool HandleInstallMode(cmExecutionStatus& status, const std::string& name,
+ OutType infoType, const std::string& variable,
+ const std::string& propertyName)
{
- if (this->Name.empty()) {
- this->SetError("not given name for INSTALL scope.");
+ if (name.empty()) {
+ status.SetError("not given name for INSTALL scope.");
return false;
}
// Get the installed file.
- cmake* cm = this->Makefile->GetCMakeInstance();
+ cmake* cm = status.GetMakefile().GetCMakeInstance();
if (cmInstalledFile* file =
- cm->GetOrCreateInstalledFile(this->Makefile, this->Name)) {
+ cm->GetOrCreateInstalledFile(&status.GetMakefile(), name)) {
std::string value;
- bool isSet = file->GetProperty(this->PropertyName, value);
+ bool isSet = file->GetProperty(propertyName, value);
- return this->StoreResult(isSet ? value.c_str() : CM_NULLPTR);
+ return StoreResult(infoType, status.GetMakefile(), variable,
+ isSet ? value.c_str() : nullptr);
}
- std::ostringstream e;
- e << "given INSTALL name that could not be found or created: " << this->Name;
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("given INSTALL name that could not be found or created: ", name));
return false;
}
+}
diff --git a/Source/cmGetPropertyCommand.h b/Source/cmGetPropertyCommand.h
index 649780168..cc600f4ee 100644
--- a/Source/cmGetPropertyCommand.h
+++ b/Source/cmGetPropertyCommand.h
@@ -3,55 +3,14 @@
#ifndef cmGetPropertyCommand_h
#define cmGetPropertyCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmGetPropertyCommand : public cmCommand
-{
-public:
- cmGetPropertyCommand();
-
- cmCommand* Clone() CM_OVERRIDE { return new cmGetPropertyCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- enum OutType
- {
- OutValue,
- OutDefined,
- OutBriefDoc,
- OutFullDoc,
- OutSet
- };
- std::string Variable;
- std::string Name;
- std::string PropertyName;
- OutType InfoType;
-
- // Implementation of result storage.
- bool StoreResult(const char* value);
-
- // Implementation of each property type.
- bool HandleGlobalMode();
- bool HandleDirectoryMode();
- bool HandleTargetMode();
- bool HandleSourceMode();
- bool HandleTestMode();
- bool HandleVariableMode();
- bool HandleCacheMode();
- bool HandleInstallMode();
-};
+bool cmGetPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx
index 1a5f08ef8..eefdc6ccb 100644
--- a/Source/cmGetSourceFilePropertyCommand.cxx
+++ b/Source/cmGetSourceFilePropertyCommand.cxx
@@ -2,42 +2,37 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGetSourceFilePropertyCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
-class cmExecutionStatus;
-
-// cmSetSourceFilePropertyCommand
-bool cmGetSourceFilePropertyCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmGetSourceFilePropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
std::string const& var = args[0];
std::string const& file = args[1];
- cmSourceFile* sf = this->Makefile->GetSource(file);
+ cmMakefile& mf = status.GetMakefile();
+ cmSourceFile* sf = mf.GetSource(file);
// for the location we must create a source file first
if (!sf && args[2] == "LOCATION") {
- sf = this->Makefile->CreateSource(file);
+ sf = mf.CreateSource(file);
}
if (sf) {
- if (args[2] == "LANGUAGE") {
- this->Makefile->AddDefinition(var, sf->GetLanguage().c_str());
- return true;
- }
- const char* prop = CM_NULLPTR;
+ const char* prop = nullptr;
if (!args[2].empty()) {
prop = sf->GetPropertyForUser(args[2]);
}
if (prop) {
- this->Makefile->AddDefinition(var, prop);
+ mf.AddDefinition(var, prop);
return true;
}
}
- this->Makefile->AddDefinition(var, "NOTFOUND");
+ mf.AddDefinition(var, "NOTFOUND");
return true;
}
diff --git a/Source/cmGetSourceFilePropertyCommand.h b/Source/cmGetSourceFilePropertyCommand.h
index e96bb29ed..f0c319b0a 100644
--- a/Source/cmGetSourceFilePropertyCommand.h
+++ b/Source/cmGetSourceFilePropertyCommand.h
@@ -3,26 +3,14 @@
#ifndef cmGetSourceFilePropertyCommand_h
#define cmGetSourceFilePropertyCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmGetSourceFilePropertyCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmGetSourceFilePropertyCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmGetSourceFilePropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index 0910a5324..7f5df9cfb 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -4,39 +4,39 @@
#include <sstream>
+#include "cmExecutionStatus.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmTarget.h"
#include "cmTargetPropertyComputer.h"
-#include "cmake.h"
-class cmExecutionStatus;
class cmMessenger;
-// cmSetTargetPropertyCommand
-bool cmGetTargetPropertyCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmGetTargetPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
std::string const& var = args[0];
std::string const& targetName = args[1];
std::string prop;
bool prop_exists = false;
+ cmMakefile& mf = status.GetMakefile();
- if (cmTarget* tgt = this->Makefile->FindTargetToUse(targetName)) {
+ if (cmTarget* tgt = mf.FindTargetToUse(targetName)) {
if (args[2] == "ALIASED_TARGET") {
- if (this->Makefile->IsAlias(targetName)) {
+ if (mf.IsAlias(targetName)) {
prop = tgt->GetName();
prop_exists = true;
}
} else if (!args[2].empty()) {
- const char* prop_cstr = CM_NULLPTR;
- cmListFileBacktrace bt = this->Makefile->GetBacktrace();
- cmMessenger* messenger = this->Makefile->GetMessenger();
+ const char* prop_cstr = nullptr;
+ cmListFileBacktrace bt = mf.GetBacktrace();
+ cmMessenger* messenger = mf.GetMessenger();
if (cmTargetPropertyComputer::PassesWhitelist(tgt->GetType(), args[2],
messenger, bt)) {
prop_cstr = tgt->GetComputedProperty(args[2], messenger, bt);
@@ -52,8 +52,8 @@ bool cmGetTargetPropertyCommand::InitialPass(
} else {
bool issueMessage = false;
std::ostringstream e;
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0045)) {
+ MessageType messageType = MessageType::AUTHOR_WARNING;
+ switch (mf.GetPolicyStatus(cmPolicies::CMP0045)) {
case cmPolicies::WARN:
issueMessage = true;
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0045) << "\n";
@@ -63,21 +63,21 @@ bool cmGetTargetPropertyCommand::InitialPass(
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
issueMessage = true;
- messageType = cmake::FATAL_ERROR;
+ messageType = MessageType::FATAL_ERROR;
}
if (issueMessage) {
e << "get_target_property() called with non-existent target \""
<< targetName << "\".";
- this->Makefile->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR) {
+ mf.IssueMessage(messageType, e.str());
+ if (messageType == MessageType::FATAL_ERROR) {
return false;
}
}
}
if (prop_exists) {
- this->Makefile->AddDefinition(var, prop.c_str());
+ mf.AddDefinition(var, prop);
return true;
}
- this->Makefile->AddDefinition(var, (var + "-NOTFOUND").c_str());
+ mf.AddDefinition(var, var + "-NOTFOUND");
return true;
}
diff --git a/Source/cmGetTargetPropertyCommand.h b/Source/cmGetTargetPropertyCommand.h
index 5de322563..c13078f8c 100644
--- a/Source/cmGetTargetPropertyCommand.h
+++ b/Source/cmGetTargetPropertyCommand.h
@@ -3,26 +3,14 @@
#ifndef cmGetTargetPropertyCommand_h
#define cmGetTargetPropertyCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmGetTargetPropertyCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmGetTargetPropertyCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmGetTargetPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx
index 6424515ec..cf8c1d5fa 100644
--- a/Source/cmGetTestPropertyCommand.cxx
+++ b/Source/cmGetTestPropertyCommand.cxx
@@ -2,33 +2,32 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGetTestPropertyCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmTest.h"
-class cmExecutionStatus;
-
-// cmGetTestPropertyCommand
-bool cmGetTestPropertyCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmGetTestPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
std::string const& testName = args[0];
std::string const& var = args[2];
- cmTest* test = this->Makefile->GetTest(testName);
+ cmMakefile& mf = status.GetMakefile();
+ cmTest* test = mf.GetTest(testName);
if (test) {
- const char* prop = CM_NULLPTR;
+ const char* prop = nullptr;
if (!args[1].empty()) {
prop = test->GetProperty(args[1]);
}
if (prop) {
- this->Makefile->AddDefinition(var, prop);
+ mf.AddDefinition(var, prop);
return true;
}
}
- this->Makefile->AddDefinition(var, "NOTFOUND");
+ mf.AddDefinition(var, "NOTFOUND");
return true;
}
diff --git a/Source/cmGetTestPropertyCommand.h b/Source/cmGetTestPropertyCommand.h
index b17e7a1cc..30beb8f0f 100644
--- a/Source/cmGetTestPropertyCommand.h
+++ b/Source/cmGetTestPropertyCommand.h
@@ -3,26 +3,14 @@
#ifndef cmGetTestPropertyCommand_h
#define cmGetTestPropertyCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmGetTestPropertyCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmGetTestPropertyCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmGetTestPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmGhsMultiGpj.cxx b/Source/cmGhsMultiGpj.cxx
index f58cfc1e5..da27971de 100644
--- a/Source/cmGhsMultiGpj.cxx
+++ b/Source/cmGhsMultiGpj.cxx
@@ -2,33 +2,38 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGhsMultiGpj.h"
-#include "cmGeneratedFileStream.h"
+#include <ostream>
-void GhsMultiGpj::WriteGpjTag(Types const gpjType,
- cmGeneratedFileStream* const filestream)
+static const char* GHS_TAG[] = { "[INTEGRITY Application]",
+ "[Library]",
+ "[Project]",
+ "[Program]",
+ "[Reference]",
+ "[Subproject]",
+ "[Custom Target]" };
+
+const char* GhsMultiGpj::GetGpjTag(Types gpjType)
{
char const* tag;
switch (gpjType) {
case INTERGRITY_APPLICATION:
- tag = "INTEGRITY Application";
- break;
case LIBRARY:
- tag = "Library";
- break;
case PROJECT:
- tag = "Project";
- break;
case PROGRAM:
- tag = "Program";
- break;
case REFERENCE:
- tag = "Reference";
- break;
case SUBPROJECT:
- tag = "Subproject";
+ case CUSTOM_TARGET:
+ tag = GHS_TAG[gpjType];
break;
default:
tag = "";
}
- *filestream << "[" << tag << "]" << std::endl;
+ return tag;
+}
+
+void GhsMultiGpj::WriteGpjTag(Types gpjType, std::ostream& fout)
+{
+ char const* tag;
+ tag = GhsMultiGpj::GetGpjTag(gpjType);
+ fout << tag << std::endl;
}
diff --git a/Source/cmGhsMultiGpj.h b/Source/cmGhsMultiGpj.h
index 7bc7bfc46..fbbef5d8f 100644
--- a/Source/cmGhsMultiGpj.h
+++ b/Source/cmGhsMultiGpj.h
@@ -3,9 +3,9 @@
#ifndef cmGhsMultiGpj_h
#define cmGhsMultiGpj_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-class cmGeneratedFileStream;
+#include <iosfwd>
class GhsMultiGpj
{
@@ -17,11 +17,13 @@ public:
PROJECT,
PROGRAM,
REFERENCE,
- SUBPROJECT
+ SUBPROJECT,
+ CUSTOM_TARGET
};
- static void WriteGpjTag(Types const gpjType,
- cmGeneratedFileStream* filestream);
+ static void WriteGpjTag(Types gpjType, std::ostream& fout);
+
+ static const char* GetGpjTag(Types gpjType);
};
#endif // ! cmGhsMultiGpjType_h
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index 7032cd582..8e4352e29 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -2,184 +2,149 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGhsMultiTargetGenerator.h"
+#include <algorithm>
+#include <memory>
+#include <ostream>
+#include <set>
+#include <utility>
+#include <vector>
+
+#include "cmCustomCommand.h"
+#include "cmCustomCommandGenerator.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGhsMultiGenerator.h"
#include "cmLinkLineComputer.h"
+#include "cmLocalGenerator.h"
#include "cmLocalGhsMultiGenerator.h"
#include "cmMakefile.h"
+#include "cmOutputConverter.h"
#include "cmSourceFile.h"
+#include "cmSourceFileLocation.h"
+#include "cmSourceGroup.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
+#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
#include "cmTarget.h"
-#include <assert.h>
-
-std::string const cmGhsMultiTargetGenerator::DDOption("-dynamic");
cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget* target)
: GeneratorTarget(target)
, LocalGenerator(
static_cast<cmLocalGhsMultiGenerator*>(target->GetLocalGenerator()))
, Makefile(target->Target->GetMakefile())
- , TargetGroup(DetermineIfTargetGroup(target))
- , DynamicDownload(false)
-{
- this->RelBuildFilePath = this->GetRelBuildFilePath(target);
-
- this->RelOutputFileName = this->RelBuildFilePath + target->GetName() + ".a";
-
- this->RelBuildFileName = this->RelBuildFilePath;
- this->RelBuildFileName += this->GetBuildFileName(target);
-
- std::string absPathToRoot = this->GetAbsPathToRoot(target);
- absPathToRoot = this->AddSlashIfNeededToPath(absPathToRoot);
- this->AbsBuildFilePath = absPathToRoot + this->RelBuildFilePath;
- this->AbsBuildFileName = absPathToRoot + this->RelBuildFileName;
- this->AbsOutputFileName = absPathToRoot + this->RelOutputFileName;
-}
-
-cmGhsMultiTargetGenerator::~cmGhsMultiTargetGenerator()
-{
- cmDeleteAll(this->FolderBuildStreams);
-}
-
-std::string cmGhsMultiTargetGenerator::GetRelBuildFilePath(
- const cmGeneratorTarget* target)
-{
- std::string output = target->GetEffectiveFolderName();
- cmSystemTools::ConvertToUnixSlashes(output);
- if (!output.empty()) {
- output += "/";
+ , Name(target->GetName())
+#ifdef _WIN32
+ , CmdWindowsShell(true)
+#else
+ , CmdWindowsShell(false)
+#endif
+{
+ // Store the configuration name that is being used
+ if (const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) {
+ // Use the build type given by the user.
+ this->ConfigName = config;
+ } else {
+ // No configuration type given.
+ this->ConfigName.clear();
}
- output += target->GetName() + "/";
- return output;
-}
-
-std::string cmGhsMultiTargetGenerator::GetAbsPathToRoot(
- const cmGeneratorTarget* target)
-{
- return target->GetLocalGenerator()->GetBinaryDirectory();
-}
-
-std::string cmGhsMultiTargetGenerator::GetAbsBuildFilePath(
- const cmGeneratorTarget* target)
-{
- std::string output;
- output = cmGhsMultiTargetGenerator::GetAbsPathToRoot(target);
- output = cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(output);
- output += cmGhsMultiTargetGenerator::GetRelBuildFilePath(target);
- return output;
}
-std::string cmGhsMultiTargetGenerator::GetRelBuildFileName(
- const cmGeneratorTarget* target)
-{
- std::string output;
- output = cmGhsMultiTargetGenerator::GetRelBuildFilePath(target);
- output = cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(output);
- output += cmGhsMultiTargetGenerator::GetBuildFileName(target);
- return output;
-}
-
-std::string cmGhsMultiTargetGenerator::GetBuildFileName(
- const cmGeneratorTarget* target)
-{
- std::string output;
- output = target->GetName();
- output += cmGlobalGhsMultiGenerator::FILE_EXTENSION;
- return output;
-}
-
-std::string cmGhsMultiTargetGenerator::AddSlashIfNeededToPath(
- std::string const& input)
-{
- std::string output(input);
- if (!cmHasLiteralSuffix(output, "/")) {
- output += "/";
- }
- return output;
-}
+cmGhsMultiTargetGenerator::~cmGhsMultiTargetGenerator() = default;
void cmGhsMultiTargetGenerator::Generate()
{
- std::vector<cmSourceFile*> objectSources = this->GetSources();
- if (!objectSources.empty() && this->IncludeThisTarget()) {
- if (!cmSystemTools::FileExists(this->AbsBuildFilePath.c_str())) {
- cmSystemTools::MakeDirectory(this->AbsBuildFilePath.c_str());
+ // Determine type of target for this project
+ switch (this->GeneratorTarget->GetType()) {
+ case cmStateEnums::EXECUTABLE: {
+ // Get the name of the executable to generate.
+ this->TargetNameReal =
+ this->GeneratorTarget->GetExecutableNames(this->ConfigName).Real;
+ if (cmGhsMultiTargetGenerator::DetermineIfIntegrityApp()) {
+ this->TagType = GhsMultiGpj::INTERGRITY_APPLICATION;
+ } else {
+ this->TagType = GhsMultiGpj::PROGRAM;
+ }
+ break;
}
- cmGlobalGhsMultiGenerator::Open(std::string(""), this->AbsBuildFileName,
- &this->FolderBuildStreams);
- cmGlobalGhsMultiGenerator::OpenBuildFileStream(
- this->GetFolderBuildStreams());
- std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- if (0 == config.length()) {
- config = "RELEASE";
+ case cmStateEnums::STATIC_LIBRARY: {
+ this->TargetNameReal =
+ this->GeneratorTarget->GetLibraryNames(this->ConfigName).Real;
+ this->TagType = GhsMultiGpj::LIBRARY;
+ break;
}
- const std::string language(
- this->GeneratorTarget->GetLinkerLanguage(config));
- config = cmSystemTools::UpperCase(config);
- this->DynamicDownload = this->DetermineIfDynamicDownload(config, language);
- if (this->DynamicDownload) {
- *this->GetFolderBuildStreams() << "#component integrity_dynamic_download"
- << std::endl;
+ case cmStateEnums::SHARED_LIBRARY: {
+ std::string msg =
+ cmStrCat("add_library(<name> SHARED ...) not supported: ", this->Name);
+ cmSystemTools::Message(msg);
+ return;
}
- GhsMultiGpj::WriteGpjTag(this->GetGpjTag(), this->GetFolderBuildStreams());
- cmGlobalGhsMultiGenerator::WriteDisclaimer(this->GetFolderBuildStreams());
-
- bool const notKernel = this->IsNotKernel(config, language);
- this->WriteTypeSpecifics(config, notKernel);
- this->SetCompilerFlags(config, language, notKernel);
- this->WriteCompilerFlags(config, language);
- this->WriteCompilerDefinitions(config, language);
- this->WriteIncludes(config, language);
- if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) {
- this->WriteTargetLinkLibraries(config, language);
+ case cmStateEnums::OBJECT_LIBRARY: {
+ this->TargetNameReal =
+ this->GeneratorTarget->GetLibraryNames(this->ConfigName).Real;
+ this->TagType = GhsMultiGpj::SUBPROJECT;
+ break;
}
- this->WriteCustomCommands();
-
- std::map<const cmSourceFile*, std::string> objectNames =
- cmGhsMultiTargetGenerator::GetObjectNames(
- &objectSources, this->LocalGenerator, this->GeneratorTarget);
-
- this->WriteSources(objectSources, objectNames);
+ case cmStateEnums::MODULE_LIBRARY: {
+ std::string msg =
+ cmStrCat("add_library(<name> MODULE ...) not supported: ", this->Name);
+ cmSystemTools::Message(msg);
+ return;
+ }
+ case cmStateEnums::UTILITY: {
+ this->TargetNameReal = this->GeneratorTarget->GetName();
+ this->TagType = GhsMultiGpj::CUSTOM_TARGET;
+ break;
+ }
+ case cmStateEnums::GLOBAL_TARGET: {
+ this->TargetNameReal = this->GeneratorTarget->GetName();
+ if (this->TargetNameReal ==
+ this->GetGlobalGenerator()->GetInstallTargetName()) {
+ this->TagType = GhsMultiGpj::CUSTOM_TARGET;
+ } else {
+ return;
+ }
+ break;
+ }
+ default:
+ return;
}
-}
-bool cmGhsMultiTargetGenerator::IncludeThisTarget()
-{
- bool output = true;
- char const* excludeFromAll =
- this->GeneratorTarget->GetProperty("EXCLUDE_FROM_ALL");
- if (NULL != excludeFromAll && '1' == excludeFromAll[0] &&
- '\0' == excludeFromAll[1]) {
- output = false;
- }
- return output;
-}
+ // Tell the global generator the name of the project file
+ this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME",
+ this->Name.c_str());
+ this->GeneratorTarget->Target->SetProperty(
+ "GENERATOR_FILE_NAME_EXT", GhsMultiGpj::GetGpjTag(this->TagType));
-std::vector<cmSourceFile*> cmGhsMultiTargetGenerator::GetSources() const
-{
- std::vector<cmSourceFile*> output;
- std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- this->GeneratorTarget->GetSourceFiles(output, config);
- return output;
+ this->GenerateTarget();
}
-GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag() const
+void cmGhsMultiTargetGenerator::GenerateTarget()
{
- return cmGhsMultiTargetGenerator::GetGpjTag(this->GeneratorTarget);
-}
+ // Open the target file in copy-if-different mode.
+ std::string fproj =
+ cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
+ this->Name, cmGlobalGhsMultiGenerator::FILE_EXTENSION);
+ cmGeneratedFileStream fout(fproj);
+ fout.SetCopyIfDifferent(true);
-GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag(
- const cmGeneratorTarget* target)
-{
- GhsMultiGpj::Types output;
- if (cmGhsMultiTargetGenerator::DetermineIfTargetGroup(target)) {
- output = GhsMultiGpj::INTERGRITY_APPLICATION;
- } else if (target->GetType() == cmStateEnums::STATIC_LIBRARY) {
- output = GhsMultiGpj::LIBRARY;
- } else {
- output = GhsMultiGpj::PROGRAM;
+ this->GetGlobalGenerator()->WriteFileHeader(fout);
+ GhsMultiGpj::WriteGpjTag(this->TagType, fout);
+
+ if (this->TagType != GhsMultiGpj::CUSTOM_TARGET) {
+ const std::string language(
+ this->GeneratorTarget->GetLinkerLanguage(this->ConfigName));
+ this->WriteTargetSpecifics(fout, this->ConfigName);
+ this->SetCompilerFlags(this->ConfigName, language);
+ this->WriteCompilerFlags(fout, this->ConfigName, language);
+ this->WriteCompilerDefinitions(fout, this->ConfigName, language);
+ this->WriteIncludes(fout, this->ConfigName, language);
+ this->WriteTargetLinkLine(fout, this->ConfigName);
+ this->WriteBuildEvents(fout);
}
- return output;
+ this->WriteSources(fout);
+ fout.Close();
}
cmGlobalGhsMultiGenerator* cmGhsMultiTargetGenerator::GetGlobalGenerator()
@@ -189,56 +154,37 @@ cmGlobalGhsMultiGenerator* cmGhsMultiTargetGenerator::GetGlobalGenerator()
this->LocalGenerator->GetGlobalGenerator());
}
-void cmGhsMultiTargetGenerator::WriteTypeSpecifics(const std::string& config,
- bool const notKernel)
+void cmGhsMultiTargetGenerator::WriteTargetSpecifics(std::ostream& fout,
+ const std::string& config)
{
- std::string outputDir(this->GetOutputDirectory(config));
- std::string outputFilename(this->GetOutputFilename(config));
-
- if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
- std::string const static_library_suffix =
- this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX");
- *this->GetFolderBuildStreams() << " -o \"" << outputDir
- << outputFilename << static_library_suffix
- << "\"" << std::endl;
- } else if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) {
- if (notKernel && !this->IsTargetGroup()) {
- *this->GetFolderBuildStreams() << " -relprog" << std::endl;
- }
- if (this->IsTargetGroup()) {
- *this->GetFolderBuildStreams()
- << " -o \"" << outputDir << outputFilename << ".elf\"" << std::endl;
- *this->GetFolderBuildStreams() << " :extraOutputFile=\"" << outputDir
- << outputFilename << ".elf.ael\""
- << std::endl;
- } else {
- std::string const executable_suffix =
- this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX");
- *this->GetFolderBuildStreams() << " -o \"" << outputDir
- << outputFilename << executable_suffix
- << "\"" << std::endl;
- }
+ std::string outpath;
+ std::string rootpath = this->LocalGenerator->GetCurrentBinaryDirectory();
+
+ if (this->TagType != GhsMultiGpj::SUBPROJECT) {
+ // set target binary file destination
+ outpath = this->GeneratorTarget->GetDirectory(config);
+ outpath =
+ this->LocalGenerator->MaybeConvertToRelativePath(rootpath, outpath);
+ fout << " :binDirRelative=\"" << outpath << "\"" << std::endl;
+ fout << " -o \"" << this->TargetNameReal << "\"" << std::endl;
}
+
+ // set target object file destination
+ outpath = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
+ fout << " :outputDirRelative=\"" << outpath << "\"" << std::endl;
}
void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config,
- const std::string& language,
- bool const notKernel)
+ const std::string& language)
{
- std::map<std::string, std::string>::iterator i =
- this->FlagsByLanguage.find(language);
+ auto i = this->FlagsByLanguage.find(language);
if (i == this->FlagsByLanguage.end()) {
std::string flags;
const char* lang = language.c_str();
- if (notKernel) {
- this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget,
- lang, config);
- } else {
- this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget,
- lang + std::string("_GHS_KERNEL"),
- config);
- }
+ this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget, lang,
+ config);
+
this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, lang,
config);
this->LocalGenerator->AddVisibilityPresetFlags(
@@ -262,19 +208,13 @@ void cmGhsMultiTargetGenerator::SetCompilerFlags(std::string const& config,
std::string cmGhsMultiTargetGenerator::GetDefines(const std::string& language,
std::string const& config)
{
- std::map<std::string, std::string>::iterator i =
- this->DefinesByLanguage.find(language);
+ auto i = this->DefinesByLanguage.find(language);
if (i == this->DefinesByLanguage.end()) {
std::set<std::string> defines;
const char* lang = language.c_str();
- // Add the export symbol definition for shared library objects.
- if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) {
- this->LocalGenerator->AppendDefines(defines, exportMacro);
- }
-
// Add preprocessor definitions for this target and configuration.
- this->LocalGenerator->AddCompileDefinitions(defines, this->GeneratorTarget,
- config, language);
+ this->LocalGenerator->GetTargetDefines(this->GeneratorTarget, config,
+ language, defines);
std::string definesString;
this->LocalGenerator->JoinDefines(defines, definesString, lang);
@@ -286,376 +226,562 @@ std::string cmGhsMultiTargetGenerator::GetDefines(const std::string& language,
return i->second;
}
-void cmGhsMultiTargetGenerator::WriteCompilerFlags(std::string const&,
+void cmGhsMultiTargetGenerator::WriteCompilerFlags(std::ostream& fout,
+ std::string const&,
const std::string& language)
{
- std::map<std::string, std::string>::iterator flagsByLangI =
- this->FlagsByLanguage.find(language);
+ auto flagsByLangI = this->FlagsByLanguage.find(language);
if (flagsByLangI != this->FlagsByLanguage.end()) {
if (!flagsByLangI->second.empty()) {
- *this->GetFolderBuildStreams() << " " << flagsByLangI->second
- << std::endl;
+ std::vector<std::string> ghsCompFlags =
+ cmSystemTools::ParseArguments(flagsByLangI->second);
+ for (auto& f : ghsCompFlags) {
+ fout << " " << f << std::endl;
+ }
}
}
}
void cmGhsMultiTargetGenerator::WriteCompilerDefinitions(
- const std::string& config, const std::string& language)
+ std::ostream& fout, const std::string& config, const std::string& language)
{
std::vector<std::string> compileDefinitions;
this->GeneratorTarget->GetCompileDefinitions(compileDefinitions, config,
language);
- for (std::vector<std::string>::const_iterator cdI =
- compileDefinitions.begin();
- cdI != compileDefinitions.end(); ++cdI) {
- *this->GetFolderBuildStreams() << " -D" << (*cdI) << std::endl;
+ for (std::string const& compileDefinition : compileDefinitions) {
+ fout << " -D" << compileDefinition << std::endl;
}
}
-void cmGhsMultiTargetGenerator::WriteIncludes(const std::string& config,
+void cmGhsMultiTargetGenerator::WriteIncludes(std::ostream& fout,
+ const std::string& config,
const std::string& language)
{
std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
language, config);
- for (std::vector<std::string>::const_iterator includes_i = includes.begin();
- includes_i != includes.end(); ++includes_i) {
- *this->GetFolderBuildStreams() << " -I\"" << *includes_i << "\""
- << std::endl;
+ for (std::string const& include : includes) {
+ fout << " -I\"" << include << "\"" << std::endl;
}
}
-void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries(
- std::string const& config, std::string const& language)
+void cmGhsMultiTargetGenerator::WriteTargetLinkLine(std::ostream& fout,
+ std::string const& config)
{
- // library directories
- cmTargetDependSet tds =
- this->GetGlobalGenerator()->GetTargetDirectDepends(this->GeneratorTarget);
- for (cmTargetDependSet::iterator tdsI = tds.begin(); tdsI != tds.end();
- ++tdsI) {
- const cmGeneratorTarget* tg = *tdsI;
- *this->GetFolderBuildStreams() << " -L\"" << GetAbsBuildFilePath(tg)
- << "\"" << std::endl;
- }
- // library targets
- cmTarget::LinkLibraryVectorType llv =
- this->GeneratorTarget->Target->GetOriginalLinkLibraries();
- for (cmTarget::LinkLibraryVectorType::const_iterator llvI = llv.begin();
- llvI != llv.end(); ++llvI) {
- std::string libName = llvI->first;
- // if it is a user defined target get the full path to the lib
- cmTarget* tg(GetGlobalGenerator()->FindTarget(libName));
- if (NULL != tg) {
- libName = tg->GetName() + ".a";
- }
- *this->GetFolderBuildStreams() << " -l\"" << libName << "\""
- << std::endl;
+ if (this->TagType == GhsMultiGpj::INTERGRITY_APPLICATION) {
+ return;
}
- if (!this->TargetGroup) {
- std::string linkLibraries;
- std::string flags;
- std::string linkFlags;
- std::string frameworkPath;
- std::string linkPath;
- std::string createRule =
- this->GeneratorTarget->GetCreateRuleVariable(language, config);
- bool useWatcomQuote =
- this->Makefile->IsOn(createRule + "_USE_WATCOM_QUOTE");
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
- this->GetGlobalGenerator()->CreateLinkLineComputer(
- this->LocalGenerator,
- this->LocalGenerator->GetStateSnapshot().GetDirectory()));
- linkLineComputer->SetUseWatcomQuote(useWatcomQuote);
-
- this->LocalGenerator->GetTargetFlags(
- linkLineComputer.get(), config, linkLibraries, flags, linkFlags,
- frameworkPath, linkPath, this->GeneratorTarget);
- linkFlags = cmSystemTools::TrimWhitespace(linkFlags);
-
- if (!linkPath.empty()) {
- linkPath = " " + linkPath.substr(0U, linkPath.size() - 1U);
- *this->GetFolderBuildStreams() << linkPath;
- }
+ std::string linkLibraries;
+ std::string flags;
+ std::string linkFlags;
+ std::string frameworkPath;
+ std::string linkPath;
+
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
+ this->GetGlobalGenerator()->CreateLinkLineComputer(
+ this->LocalGenerator,
+ this->LocalGenerator->GetStateSnapshot().GetDirectory()));
+
+ this->LocalGenerator->GetTargetFlags(
+ linkLineComputer.get(), config, linkLibraries, flags, linkFlags,
+ frameworkPath, linkPath, this->GeneratorTarget);
+
+ // write out link options
+ std::vector<std::string> lopts = cmSystemTools::ParseArguments(linkFlags);
+ for (auto& l : lopts) {
+ fout << " " << l << std::endl;
+ }
- if (!linkFlags.empty()) {
- *this->GetFolderBuildStreams() << " " << linkFlags << std::endl;
- }
+ // write out link search paths
+ // must be quoted for paths that contain spaces
+ std::vector<std::string> lpath = cmSystemTools::ParseArguments(linkPath);
+ for (auto& l : lpath) {
+ fout << " -L\"" << l << "\"" << std::endl;
}
-}
-void cmGhsMultiTargetGenerator::WriteCustomCommands()
-{
- WriteCustomCommandsHelper(this->GeneratorTarget->GetPreBuildCommands(),
- cmTarget::PRE_BUILD);
- WriteCustomCommandsHelper(this->GeneratorTarget->GetPostBuildCommands(),
- cmTarget::POST_BUILD);
-}
+ // write out link libs
+ // must be quoted for filepaths that contains spaces
+ std::string cbd = this->LocalGenerator->GetCurrentBinaryDirectory();
-void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper(
- std::vector<cmCustomCommand> const& commandsSet,
- cmTarget::CustomCommandType const commandType)
-{
- for (std::vector<cmCustomCommand>::const_iterator commandsSetI =
- commandsSet.begin();
- commandsSetI != commandsSet.end(); ++commandsSetI) {
- cmCustomCommandLines const& commands = commandsSetI->GetCommandLines();
- for (cmCustomCommandLines::const_iterator commandI = commands.begin();
- commandI != commands.end(); ++commandI) {
- switch (commandType) {
- case cmTarget::PRE_BUILD:
- *this->GetFolderBuildStreams() << " :preexecShellSafe=";
- break;
- case cmTarget::POST_BUILD:
- *this->GetFolderBuildStreams() << " :postexecShellSafe=";
- break;
- default:
- assert("Only pre and post are supported");
- }
- cmCustomCommandLine const& command = *commandI;
- for (cmCustomCommandLine::const_iterator commandLineI = command.begin();
- commandLineI != command.end(); ++commandLineI) {
- std::string subCommandE =
- this->LocalGenerator->EscapeForShell(*commandLineI, true);
- if (!command.empty()) {
- *this->GetFolderBuildStreams()
- << (command.begin() == commandLineI ? "'" : " ");
- // Need to double escape backslashes
- cmSystemTools::ReplaceString(subCommandE, "\\", "\\\\");
- }
- *this->GetFolderBuildStreams() << subCommandE;
- }
- if (!command.empty()) {
- *this->GetFolderBuildStreams() << "'" << std::endl;
- }
+ std::vector<std::string> llibs =
+ cmSystemTools::ParseArguments(linkLibraries);
+ for (auto& l : llibs) {
+ if (l.compare(0, 2, "-l") == 0) {
+ fout << " \"" << l << "\"" << std::endl;
+ } else {
+ std::string rl = cmSystemTools::CollapseFullPath(l, cbd);
+ fout << " -l\"" << rl << "\"" << std::endl;
}
}
}
-std::map<const cmSourceFile*, std::string>
-cmGhsMultiTargetGenerator::GetObjectNames(
- std::vector<cmSourceFile*>* const objectSources,
- cmLocalGhsMultiGenerator* const localGhsMultiGenerator,
- cmGeneratorTarget* const generatorTarget)
+void cmGhsMultiTargetGenerator::WriteBuildEvents(std::ostream& fout)
{
- std::map<std::string, std::vector<cmSourceFile*> > filenameToSource;
- std::map<cmSourceFile*, std::string> sourceToFilename;
- for (std::vector<cmSourceFile*>::const_iterator sf = objectSources->begin();
- sf != objectSources->end(); ++sf) {
- const std::string filename =
- cmSystemTools::GetFilenameName((*sf)->GetFullPath());
- const std::string lower_filename = cmSystemTools::LowerCase(filename);
- filenameToSource[lower_filename].push_back(*sf);
- sourceToFilename[*sf] = lower_filename;
- }
-
- std::vector<cmSourceFile*> duplicateSources;
- for (std::map<std::string, std::vector<cmSourceFile*> >::const_iterator
- msvSourceI = filenameToSource.begin();
- msvSourceI != filenameToSource.end(); ++msvSourceI) {
- if (msvSourceI->second.size() > 1) {
- duplicateSources.insert(duplicateSources.end(),
- msvSourceI->second.begin(),
- msvSourceI->second.end());
- }
- }
-
- std::map<const cmSourceFile*, std::string> objectNamesCorrected;
+ this->WriteBuildEventsHelper(
+ fout, this->GeneratorTarget->GetPreBuildCommands(),
+ std::string("prebuild"), std::string("preexecShell"));
- for (std::vector<cmSourceFile*>::const_iterator sf =
- duplicateSources.begin();
- sf != duplicateSources.end(); ++sf) {
- std::string const longestObjectDirectory(
- cmGhsMultiTargetGenerator::ComputeLongestObjectDirectory(
- localGhsMultiGenerator, generatorTarget, *sf));
- std::string objFilenameName =
- localGhsMultiGenerator->GetObjectFileNameWithoutTarget(
- **sf, longestObjectDirectory);
- cmsys::SystemTools::ReplaceString(objFilenameName, "/", "_");
- objectNamesCorrected[*sf] = objFilenameName;
+ if (this->TagType != GhsMultiGpj::CUSTOM_TARGET) {
+ this->WriteBuildEventsHelper(
+ fout, this->GeneratorTarget->GetPreLinkCommands(),
+ std::string("prelink"), std::string("preexecShell"));
}
- return objectNamesCorrected;
+ this->WriteBuildEventsHelper(
+ fout, this->GeneratorTarget->GetPostBuildCommands(),
+ std::string("postbuild"), std::string("postexecShell"));
+}
+
+void cmGhsMultiTargetGenerator::WriteBuildEventsHelper(
+ std::ostream& fout, const std::vector<cmCustomCommand>& ccv,
+ std::string const& name, std::string const& cmd)
+{
+ int cmdcount = 0;
+
+ for (cmCustomCommand const& cc : ccv) {
+ cmCustomCommandGenerator ccg(cc, this->ConfigName, this->LocalGenerator);
+ // Open the filestream for this custom command
+ std::string fname =
+ cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
+ '/', this->Name, '_', name, cmdcount++,
+ this->CmdWindowsShell ? ".bat" : ".sh");
+ cmGeneratedFileStream f(fname);
+ f.SetCopyIfDifferent(true);
+ this->WriteCustomCommandsHelper(f, ccg);
+ f.Close();
+ if (this->TagType != GhsMultiGpj::CUSTOM_TARGET) {
+ fout << " :" << cmd << "=\"" << fname << "\"" << std::endl;
+ } else {
+ fout << fname << std::endl;
+ fout << " :outputName=\"" << fname << ".rule\"" << std::endl;
+ }
+ for (auto& byp : ccg.GetByproducts()) {
+ fout << " :extraOutputFile=\"" << byp << "\"" << std::endl;
+ }
+ }
}
-void cmGhsMultiTargetGenerator::WriteSources(
- std::vector<cmSourceFile*> const& objectSources,
- std::map<const cmSourceFile*, std::string> const& objectNames)
+void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper(
+ std::ostream& fout, cmCustomCommandGenerator const& ccg)
{
- for (std::vector<cmSourceFile*>::const_iterator si = objectSources.begin();
- si != objectSources.end(); ++si) {
- std::vector<cmSourceGroup> sourceGroups(this->Makefile->GetSourceGroups());
- char const* sourceFullPath = (*si)->GetFullPath().c_str();
- cmSourceGroup* sourceGroup =
- this->Makefile->FindSourceGroup(sourceFullPath, sourceGroups);
- std::string sgPath(sourceGroup->GetFullName());
- cmSystemTools::ConvertToUnixSlashes(sgPath);
- cmGlobalGhsMultiGenerator::AddFilesUpToPath(
- this->GetFolderBuildStreams(), &this->FolderBuildStreams,
- this->LocalGenerator->GetBinaryDirectory(), sgPath,
- GhsMultiGpj::SUBPROJECT, this->RelBuildFilePath);
-
- std::string fullSourcePath((*si)->GetFullPath());
- if ((*si)->GetExtension() == "int" || (*si)->GetExtension() == "bsp") {
- *this->FolderBuildStreams[sgPath] << fullSourcePath << std::endl;
- } else {
- // WORKAROUND: GHS MULTI needs the path to use backslashes without quotes
- // to open files in search as of version 6.1.6
- cmsys::SystemTools::ReplaceString(fullSourcePath, "/", "\\");
- *this->FolderBuildStreams[sgPath] << fullSourcePath << std::endl;
- }
+ std::vector<std::string> cmdLines;
- if ("ld" != (*si)->GetExtension() && "int" != (*si)->GetExtension() &&
- "bsp" != (*si)->GetExtension()) {
- this->WriteObjectLangOverride(this->FolderBuildStreams[sgPath], (*si));
- if (objectNames.end() != objectNames.find(*si)) {
- *this->FolderBuildStreams[sgPath]
- << " -o \"" << objectNames.find(*si)->second << "\"" << std::endl;
+ // if the command specified a working directory use it.
+ std::string dir = this->LocalGenerator->GetCurrentBinaryDirectory();
+ std::string currentBinDir = dir;
+ std::string workingDir = ccg.GetWorkingDirectory();
+ if (!workingDir.empty()) {
+ dir = workingDir;
+ }
+
+ // Line to check for error between commands.
+#ifdef _WIN32
+ std::string check_error = "if %errorlevel% neq 0 exit /b %errorlevel%";
+#else
+ std::string check_error = "if [[ $? -ne 0 ]]; then exit 1; fi";
+#endif
+
+#ifdef _WIN32
+ cmdLines.push_back("@echo off");
+#endif
+ // Echo the custom command's comment text.
+ const char* comment = ccg.GetComment();
+ if (comment && *comment) {
+ std::string echocmd = cmStrCat("echo ", comment);
+ cmdLines.push_back(std::move(echocmd));
+ }
+
+ // Switch to working directory
+ std::string cdCmd;
+#ifdef _WIN32
+ std::string cdStr = "cd /D ";
+#else
+ std::string cdStr = "cd ";
+#endif
+ cdCmd = cdStr +
+ this->LocalGenerator->ConvertToOutputFormat(dir, cmOutputConverter::SHELL);
+ cmdLines.push_back(std::move(cdCmd));
+
+ for (unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) {
+ // Build the command line in a single string.
+ std::string cmd = ccg.GetCommand(c);
+ if (!cmd.empty()) {
+ // Use "call " before any invocations of .bat or .cmd files
+ // invoked as custom commands in the WindowsShell.
+ //
+ bool useCall = false;
+
+ if (this->CmdWindowsShell) {
+ std::string suffix;
+ if (cmd.size() > 4) {
+ suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size() - 4));
+ if (suffix == ".bat" || suffix == ".cmd") {
+ useCall = true;
+ }
+ }
}
- this->WriteObjectDir(this->FolderBuildStreams[sgPath],
- this->AbsBuildFilePath + sgPath);
+ cmSystemTools::ReplaceString(cmd, "/./", "/");
+ // Convert the command to a relative path only if the current
+ // working directory will be the start-output directory.
+ bool had_slash = cmd.find('/') != std::string::npos;
+ if (workingDir.empty()) {
+ cmd =
+ this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, cmd);
+ }
+ bool has_slash = cmd.find('/') != std::string::npos;
+ if (had_slash && !has_slash) {
+ // This command was specified as a path to a file in the
+ // current directory. Add a leading "./" so it can run
+ // without the current directory being in the search path.
+ cmd = cmStrCat("./", cmd);
+ }
+ cmd = this->LocalGenerator->ConvertToOutputFormat(
+ cmd, cmOutputConverter::SHELL);
+ if (useCall) {
+ cmd = cmStrCat("call ", cmd);
+ }
+ ccg.AppendArguments(c, cmd);
+ cmdLines.push_back(std::move(cmd));
}
}
+
+ // push back the custom commands
+ for (auto const& c : cmdLines) {
+ fout << c << std::endl;
+ fout << check_error << std::endl;
+ }
}
-void cmGhsMultiTargetGenerator::WriteObjectLangOverride(
- cmGeneratedFileStream* fileStream, cmSourceFile* sourceFile)
+void cmGhsMultiTargetGenerator::WriteSourceProperty(
+ std::ostream& fout, const cmSourceFile* sf, std::string const& propName,
+ std::string const& propFlag)
{
- const char* rawLangProp = sourceFile->GetProperty("LANGUAGE");
- if (NULL != rawLangProp) {
- std::string sourceLangProp(rawLangProp);
- std::string extension(sourceFile->GetExtension());
- if ("CXX" == sourceLangProp && ("c" == extension || "C" == extension)) {
- *fileStream << " -dotciscxx" << std::endl;
+ const char* prop = sf->GetProperty(propName);
+ if (prop) {
+ std::vector<std::string> list = cmExpandedList(prop);
+ for (auto& p : list) {
+ fout << " " << propFlag << p << std::endl;
}
}
}
-void cmGhsMultiTargetGenerator::WriteObjectDir(
- cmGeneratedFileStream* fileStream, std::string const& dir)
+void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
{
- std::string workingDir(dir);
- cmSystemTools::ConvertToUnixSlashes(workingDir);
- if (!workingDir.empty()) {
- workingDir += "/";
+ /* vector of all sources for this target */
+ std::vector<cmSourceFile*> sources;
+ this->GeneratorTarget->GetSourceFiles(sources, this->ConfigName);
+
+ /* vector of all groups defined for this target
+ * -- but the vector is not expanded with sub groups or in any useful order
+ */
+ std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
+
+ /* for each source file assign it to its group */
+ std::map<std::string, std::vector<cmSourceFile*>> groupFiles;
+ std::set<std::string> groupNames;
+ for (auto& sf : sources) {
+ cmSourceGroup* sourceGroup =
+ this->Makefile->FindSourceGroup(sf->ResolveFullPath(), sourceGroups);
+ std::string gn = sourceGroup->GetFullName();
+ groupFiles[gn].push_back(sf);
+ groupNames.insert(std::move(gn));
}
- workingDir += "Objs";
- *fileStream << " -object_dir=\"" << workingDir << "\"" << std::endl;
-}
-std::string cmGhsMultiTargetGenerator::GetOutputDirectory(
- const std::string& config) const
-{
- std::string outputDir(AbsBuildFilePath);
+ /* list of known groups and the order they are displayed in a project file */
+ const std::vector<std::string> standardGroups = {
+ "CMake Rules", "Header Files", "Source Files",
+ "Object Files", "Object Libraries", "Resources"
+ };
+
+ /* list of groups in the order they are displayed in a project file*/
+ std::vector<std::string> groupFilesList(groupFiles.size());
+
+ /* put the groups in the order they should be listed
+ * - standard groups first, and then everything else
+ * in the order used by std::map.
+ */
+ int i = 0;
+ for (const std::string& gn : standardGroups) {
+ auto n = groupNames.find(gn);
+ if (n != groupNames.end()) {
+ groupFilesList[i] = *n;
+ i += 1;
+ groupNames.erase(gn);
+ } else if (this->TagType == GhsMultiGpj::CUSTOM_TARGET &&
+ gn == "CMake Rules") {
+ /* make sure that rules folder always exists in case of custom targets
+ * that have no custom commands except for pre or post build events.
+ */
+ groupFilesList.resize(groupFilesList.size() + 1);
+ groupFilesList[i] = gn;
+ i += 1;
+ }
+ }
- const char* runtimeOutputProp =
- this->GeneratorTarget->GetProperty("RUNTIME_OUTPUT_DIRECTORY");
- if (NULL != runtimeOutputProp) {
- outputDir = runtimeOutputProp;
+ { /* catch-all group - is last item */
+ std::string gn;
+ auto n = groupNames.find(gn);
+ if (n != groupNames.end()) {
+ groupFilesList.back() = *n;
+ groupNames.erase(gn);
+ }
}
- std::string configCapped(cmSystemTools::UpperCase(config));
- const char* runtimeOutputSProp = this->GeneratorTarget->GetProperty(
- "RUNTIME_OUTPUT_DIRECTORY_" + configCapped);
- if (NULL != runtimeOutputSProp) {
- outputDir = runtimeOutputSProp;
+ for (auto& n : groupNames) {
+ groupFilesList[i] = n;
+ i += 1;
}
- cmSystemTools::ConvertToUnixSlashes(outputDir);
- if (!outputDir.empty()) {
- outputDir += "/";
+ /* sort the files within each group */
+ for (auto& n : groupFilesList) {
+ std::sort(groupFiles[n].begin(), groupFiles[n].end(),
+ [](cmSourceFile* l, cmSourceFile* r) {
+ return l->ResolveFullPath() < r->ResolveFullPath();
+ });
}
- return outputDir;
-}
+ /* list of open project files */
+ std::vector<cmGeneratedFileStream*> gfiles;
+
+ /* write files into the proper project file
+ * -- groups go into main project file
+ * unless NO_SOURCE_GROUP_FILE property or variable is set.
+ */
+ for (auto& sg : groupFilesList) {
+ std::ostream* fout;
+ bool useProjectFile =
+ cmIsOn(this->GeneratorTarget->GetProperty("GHS_NO_SOURCE_GROUP_FILE")) ||
+ cmIsOn(this->Makefile->GetDefinition("CMAKE_GHS_NO_SOURCE_GROUP_FILE"));
+ if (useProjectFile || sg.empty()) {
+ fout = &fout_proj;
+ } else {
+ // Open the filestream in copy-if-different mode.
+ std::string gname = sg;
+ cmsys::SystemTools::ReplaceString(gname, "\\", "_");
+ std::string lpath = cmStrCat(
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), '/',
+ gname, cmGlobalGhsMultiGenerator::FILE_EXTENSION);
+ std::string fpath = cmStrCat(
+ this->LocalGenerator->GetCurrentBinaryDirectory(), '/', lpath);
+ cmGeneratedFileStream* f = new cmGeneratedFileStream(fpath);
+ f->SetCopyIfDifferent(true);
+ gfiles.push_back(f);
+ fout = f;
+ this->GetGlobalGenerator()->WriteFileHeader(*f);
+ GhsMultiGpj::WriteGpjTag(GhsMultiGpj::SUBPROJECT, *f);
+ fout_proj << lpath << " ";
+ GhsMultiGpj::WriteGpjTag(GhsMultiGpj::SUBPROJECT, fout_proj);
+ }
-std::string cmGhsMultiTargetGenerator::GetOutputFilename(
- const std::string& config) const
-{
- std::string outputFilename(this->GeneratorTarget->GetName());
+ if (useProjectFile) {
+ if (sg.empty()) {
+ *fout << "{comment} Others" << std::endl;
+ } else {
+ *fout << "{comment} " << sg << std::endl;
+ }
+ } else if (sg.empty()) {
+ *fout << "{comment} Others" << std::endl;
+ }
- const char* outputNameProp =
- this->GeneratorTarget->GetProperty("OUTPUT_NAME");
- if (NULL != outputNameProp) {
- outputFilename = outputNameProp;
- }
+ if (sg != "CMake Rules") {
+ /* output rule for each source file */
+ for (const cmSourceFile* si : groupFiles[sg]) {
+ bool compile = true;
+ // Convert filename to native system
+ // WORKAROUND: GHS MULTI 6.1.4 and 6.1.6 are known to need backslash on
+ // windows when opening some files from the search window.
+ std::string fname(si->GetFullPath());
+ cmSystemTools::ConvertToOutputSlashes(fname);
+
+ /* For custom targets list any associated sources,
+ * comment out source code to prevent it from being
+ * compiled when processing this target.
+ * Otherwise, comment out any custom command (main) dependencies that
+ * are listed as source files to prevent them from being considered
+ * part of the build.
+ */
+ std::string comment;
+ if ((this->TagType == GhsMultiGpj::CUSTOM_TARGET &&
+ !si->GetLanguage().empty()) ||
+ si->GetCustomCommand()) {
+ comment = "{comment} ";
+ compile = false;
+ }
- std::string configCapped(cmSystemTools::UpperCase(config));
- const char* outputNameSProp =
- this->GeneratorTarget->GetProperty(configCapped + "_OUTPUT_NAME");
- if (NULL != outputNameSProp) {
- outputFilename = outputNameSProp;
+ *fout << comment << fname << std::endl;
+ if (compile) {
+ if ("ld" != si->GetExtension() && "int" != si->GetExtension() &&
+ "bsp" != si->GetExtension()) {
+ WriteObjectLangOverride(*fout, si);
+ }
+
+ this->WriteSourceProperty(*fout, si, "INCLUDE_DIRECTORIES", "-I");
+ this->WriteSourceProperty(*fout, si, "COMPILE_DEFINITIONS", "-D");
+ this->WriteSourceProperty(*fout, si, "COMPILE_OPTIONS", "");
+
+ /* to avoid clutter in the GUI only print out the objectName if it
+ * has been renamed */
+ std::string objectName = this->GeneratorTarget->GetObjectName(si);
+ if (!objectName.empty() &&
+ this->GeneratorTarget->HasExplicitObjectName(si)) {
+ *fout << " -o " << objectName << std::endl;
+ }
+ }
+ }
+ } else {
+ std::vector<cmSourceFile const*> customCommands;
+ if (ComputeCustomCommandOrder(customCommands)) {
+ std::string message = "The custom commands for target [" +
+ this->GeneratorTarget->GetName() + "] had a cycle.\n";
+ cmSystemTools::Error(message);
+ } else {
+ /* Custom targets do not have a dependency on SOURCES files.
+ * Therefore the dependency list may include SOURCES files after the
+ * custom target. Because nothing can depend on the custom target just
+ * move it to the last item.
+ */
+ for (auto sf = customCommands.begin(); sf != customCommands.end();
+ ++sf) {
+ if (((*sf)->GetLocation()).GetName() == this->Name + ".rule") {
+ std::rotate(sf, sf + 1, customCommands.end());
+ break;
+ }
+ }
+ int cmdcount = 0;
+ for (auto& sf : customCommands) {
+ const cmCustomCommand* cc = sf->GetCustomCommand();
+ cmCustomCommandGenerator ccg(*cc, this->ConfigName,
+ this->LocalGenerator);
+
+ // Open the filestream for this custom command
+ std::string fname = cmStrCat(
+ this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
+ '/', this->Name, "_cc", cmdcount++, '_',
+ (sf->GetLocation()).GetName(),
+ this->CmdWindowsShell ? ".bat" : ".sh");
+ cmGeneratedFileStream f(fname);
+ f.SetCopyIfDifferent(true);
+ this->WriteCustomCommandsHelper(f, ccg);
+ f.Close();
+ this->WriteCustomCommandLine(*fout, fname, ccg);
+ }
+ }
+ if (this->TagType == GhsMultiGpj::CUSTOM_TARGET) {
+ this->WriteBuildEvents(*fout);
+ }
+ }
}
- return outputFilename;
+ for (cmGeneratedFileStream* f : gfiles) {
+ f->Close();
+ }
}
-std::string cmGhsMultiTargetGenerator::ComputeLongestObjectDirectory(
- cmLocalGhsMultiGenerator const* localGhsMultiGenerator,
- cmGeneratorTarget* const generatorTarget, cmSourceFile* const sourceFile)
-{
- std::string dir_max;
- dir_max +=
- localGhsMultiGenerator->GetMakefile()->GetCurrentBinaryDirectory();
- dir_max += "/";
- dir_max += generatorTarget->Target->GetName();
- dir_max += "/";
- std::vector<cmSourceGroup> sourceGroups(
- localGhsMultiGenerator->GetMakefile()->GetSourceGroups());
- char const* const sourceFullPath = sourceFile->GetFullPath().c_str();
- cmSourceGroup* sourceGroup =
- localGhsMultiGenerator->GetMakefile()->FindSourceGroup(sourceFullPath,
- sourceGroups);
- std::string const sgPath(sourceGroup->GetFullName());
- dir_max += sgPath;
- dir_max += "/Objs/libs/";
- dir_max += generatorTarget->Target->GetName();
- dir_max += "/";
- return dir_max;
+void cmGhsMultiTargetGenerator::WriteCustomCommandLine(
+ std::ostream& fout, std::string& fname, cmCustomCommandGenerator const& ccg)
+{
+ /* NOTE: Customization Files are not well documented. Testing showed
+ * that ":outputName=file" can only be used once per script. The
+ * script will only run if ":outputName=file" is missing or just run
+ * once if ":outputName=file" is not specified. If there are
+ * multiple outputs then the script needs to be listed multiple times
+ * for each output. Otherwise it won't rerun the script if one of
+ * the outputs is manually deleted.
+ */
+ bool specifyExtra = true;
+ for (auto& out : ccg.GetOutputs()) {
+ fout << fname << std::endl;
+ fout << " :outputName=\"" << out << "\"" << std::endl;
+ if (specifyExtra) {
+ for (auto& byp : ccg.GetByproducts()) {
+ fout << " :extraOutputFile=\"" << byp << "\"" << std::endl;
+ }
+ for (auto& dep : ccg.GetDepends()) {
+ fout << " :depends=\"" << dep << "\"" << std::endl;
+ }
+ specifyExtra = false;
+ }
+ }
}
-bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const& config,
- const std::string& language)
+void cmGhsMultiTargetGenerator::WriteObjectLangOverride(
+ std::ostream& fout, const cmSourceFile* sourceFile)
{
- bool output;
- std::vector<std::string> options;
- this->GeneratorTarget->GetCompileOptions(options, config, language);
- output =
- options.end() == std::find(options.begin(), options.end(), "-kernel");
- return output;
+ const char* rawLangProp = sourceFile->GetProperty("LANGUAGE");
+ if (nullptr != rawLangProp) {
+ std::string sourceLangProp(rawLangProp);
+ std::string const& extension = sourceFile->GetExtension();
+ if ("CXX" == sourceLangProp && ("c" == extension || "C" == extension)) {
+ fout << " -dotciscxx" << std::endl;
+ }
+ }
}
-bool cmGhsMultiTargetGenerator::DetermineIfTargetGroup(
- const cmGeneratorTarget* target)
+bool cmGhsMultiTargetGenerator::DetermineIfIntegrityApp()
{
- bool output = false;
+ const char* p = this->GeneratorTarget->GetProperty("ghs_integrity_app");
+ if (p) {
+ return cmIsOn(this->GeneratorTarget->GetProperty("ghs_integrity_app"));
+ }
std::vector<cmSourceFile*> sources;
- std::string config =
- target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
- target->GetSourceFiles(sources, config);
- for (std::vector<cmSourceFile*>::const_iterator sources_i = sources.begin();
- sources.end() != sources_i; ++sources_i) {
- if ("int" == (*sources_i)->GetExtension()) {
- output = true;
+ this->GeneratorTarget->GetSourceFiles(sources, this->ConfigName);
+ for (auto& sf : sources) {
+ if ("int" == sf->GetExtension()) {
+ return true;
}
}
- return output;
+ return false;
}
-bool cmGhsMultiTargetGenerator::DetermineIfDynamicDownload(
- std::string const& config, const std::string& language)
+bool cmGhsMultiTargetGenerator::ComputeCustomCommandOrder(
+ std::vector<cmSourceFile const*>& order)
{
- std::vector<std::string> options;
- bool output = false;
- this->GeneratorTarget->GetCompileOptions(options, config, language);
- for (std::vector<std::string>::const_iterator options_i = options.begin();
- options_i != options.end(); ++options_i) {
- std::string option = *options_i;
- if (this->DDOption == option) {
- output = true;
+ std::set<cmSourceFile const*> temp;
+ std::set<cmSourceFile const*> perm;
+
+ // Collect all custom commands for this target
+ std::vector<cmSourceFile const*> customCommands;
+ this->GeneratorTarget->GetCustomCommands(customCommands, this->ConfigName);
+
+ for (cmSourceFile const* si : customCommands) {
+ bool r = VisitCustomCommand(temp, perm, order, si);
+ if (r) {
+ return r;
+ }
+ }
+ return false;
+}
+
+bool cmGhsMultiTargetGenerator::VisitCustomCommand(
+ std::set<cmSourceFile const*>& temp, std::set<cmSourceFile const*>& perm,
+ std::vector<cmSourceFile const*>& order, cmSourceFile const* si)
+{
+ /* check if permanent mark is set*/
+ if (perm.find(si) == perm.end()) {
+ /* set temporary mark; check if revisit*/
+ if (temp.insert(si).second) {
+ for (auto& di : si->GetCustomCommand()->GetDepends()) {
+ cmSourceFile const* sf = this->GeneratorTarget->GetLocalGenerator()
+ ->GetMakefile()
+ ->GetSourceFileWithOutput(di);
+ /* if sf exists then visit */
+ if (sf && this->VisitCustomCommand(temp, perm, order, sf)) {
+ return true;
+ }
+ }
+ /* mark as complete; insert into beginning of list*/
+ perm.insert(si);
+ order.push_back(si);
+ return false;
}
+ /* revisiting item - not a DAG */
+ return true;
}
- return output;
+ /* already complete */
+ return false;
}
diff --git a/Source/cmGhsMultiTargetGenerator.h b/Source/cmGhsMultiTargetGenerator.h
index 2cdf68e11..f03ca44a2 100644
--- a/Source/cmGhsMultiTargetGenerator.h
+++ b/Source/cmGhsMultiTargetGenerator.h
@@ -3,12 +3,16 @@
#ifndef cmGhsMultiTargetGenerator_h
#define cmGhsMultiTargetGenerator_h
-#include "cmGhsMultiGpj.h"
+#include <iosfwd>
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
-#include "cmTarget.h"
+#include "cmGhsMultiGpj.h"
class cmCustomCommand;
-class cmGeneratedFileStream;
+class cmCustomCommandGenerator;
class cmGeneratorTarget;
class cmGlobalGhsMultiGenerator;
class cmLocalGhsMultiGenerator;
@@ -24,97 +28,59 @@ public:
virtual void Generate();
- bool IncludeThisTarget();
- std::vector<cmSourceFile*> GetSources() const;
- GhsMultiGpj::Types GetGpjTag() const;
- static GhsMultiGpj::Types GetGpjTag(const cmGeneratorTarget* target);
- const char* GetAbsBuildFilePath() const
- {
- return this->AbsBuildFilePath.c_str();
- }
- const char* GetRelBuildFileName() const
- {
- return this->RelBuildFileName.c_str();
- }
- const char* GetAbsBuildFileName() const
- {
- return this->AbsBuildFileName.c_str();
- }
- const char* GetAbsOutputFileName() const
- {
- return this->AbsOutputFileName.c_str();
- }
-
- static std::string GetRelBuildFilePath(const cmGeneratorTarget* target);
- static std::string GetAbsPathToRoot(const cmGeneratorTarget* target);
- static std::string GetAbsBuildFilePath(const cmGeneratorTarget* target);
- static std::string GetRelBuildFileName(const cmGeneratorTarget* target);
- static std::string GetBuildFileName(const cmGeneratorTarget* target);
- static std::string AddSlashIfNeededToPath(std::string const& input);
-
private:
cmGlobalGhsMultiGenerator* GetGlobalGenerator() const;
- cmGeneratedFileStream* GetFolderBuildStreams()
- {
- return this->FolderBuildStreams[""];
- };
- bool IsTargetGroup() const { return this->TargetGroup; }
-
- void WriteTypeSpecifics(const std::string& config, bool notKernel);
- void WriteCompilerFlags(const std::string& config,
+
+ void GenerateTarget();
+
+ void WriteTargetSpecifics(std::ostream& fout, const std::string& config);
+
+ void WriteCompilerFlags(std::ostream& fout, const std::string& config,
const std::string& language);
- void WriteCompilerDefinitions(const std::string& config,
+ void WriteCompilerDefinitions(std::ostream& fout, const std::string& config,
const std::string& language);
- void SetCompilerFlags(std::string const& config, const std::string& language,
- bool const notKernel);
+ void SetCompilerFlags(std::string const& config,
+ const std::string& language);
+
std::string GetDefines(const std::string& langugae,
std::string const& config);
- void WriteIncludes(const std::string& config, const std::string& language);
- void WriteTargetLinkLibraries(std::string const& config,
- std::string const& language);
- void WriteCustomCommands();
- void WriteCustomCommandsHelper(
- std::vector<cmCustomCommand> const& commandsSet,
- cmTarget::CustomCommandType commandType);
- void WriteSources(
- std::vector<cmSourceFile*> const& objectSources,
- std::map<const cmSourceFile*, std::string> const& objectNames);
- static std::map<const cmSourceFile*, std::string> GetObjectNames(
- std::vector<cmSourceFile*>* objectSources,
- cmLocalGhsMultiGenerator* localGhsMultiGenerator,
- cmGeneratorTarget* generatorTarget);
- static void WriteObjectLangOverride(cmGeneratedFileStream* fileStream,
- cmSourceFile* sourceFile);
- static void WriteObjectDir(cmGeneratedFileStream* fileStream,
- std::string const& dir);
- std::string GetOutputDirectory(const std::string& config) const;
- std::string GetOutputFilename(const std::string& config) const;
- static std::string ComputeLongestObjectDirectory(
- cmLocalGhsMultiGenerator const* localGhsMultiGenerator,
- cmGeneratorTarget* generatorTarget, cmSourceFile* const sourceFile);
-
- bool IsNotKernel(std::string const& config, const std::string& language);
- static bool DetermineIfTargetGroup(const cmGeneratorTarget* target);
- bool DetermineIfDynamicDownload(std::string const& config,
- const std::string& language);
+ void WriteIncludes(std::ostream& fout, const std::string& config,
+ const std::string& language);
+ void WriteTargetLinkLine(std::ostream& fout, std::string const& config);
+ void WriteBuildEvents(std::ostream& fout);
+ void WriteBuildEventsHelper(std::ostream& fout,
+ const std::vector<cmCustomCommand>& ccv,
+ std::string const& name, std::string const& cmd);
+ void WriteCustomCommandsHelper(std::ostream& fout,
+ cmCustomCommandGenerator const& ccg);
+ void WriteCustomCommandLine(std::ostream& fout, std::string& fname,
+ cmCustomCommandGenerator const& ccg);
+ bool ComputeCustomCommandOrder(std::vector<cmSourceFile const*>& order);
+ bool VisitCustomCommand(std::set<cmSourceFile const*>& temp,
+ std::set<cmSourceFile const*>& perm,
+ std::vector<cmSourceFile const*>& order,
+ cmSourceFile const* sf);
+ void WriteSources(std::ostream& fout_proj);
+ void WriteSourceProperty(std::ostream& fout, const cmSourceFile* sf,
+ std::string const& propName,
+ std::string const& propFlag);
+ static void WriteObjectLangOverride(std::ostream& fout,
+ const cmSourceFile* sourceFile);
+ bool DetermineIfIntegrityApp();
cmGeneratorTarget* GeneratorTarget;
cmLocalGhsMultiGenerator* LocalGenerator;
cmMakefile* Makefile;
- std::string AbsBuildFilePath;
- std::string RelBuildFilePath;
- std::string AbsBuildFileName;
- std::string RelBuildFileName;
- std::string RelOutputFileName;
- std::string AbsOutputFileName;
- std::map<std::string, cmGeneratedFileStream*> FolderBuildStreams;
- bool TargetGroup;
- bool DynamicDownload;
- static std::string const DDOption;
std::map<std::string, std::string> FlagsByLanguage;
std::map<std::string, std::string> DefinesByLanguage;
+
+ std::string TargetNameReal;
+ GhsMultiGpj::Types TagType;
+ std::string const Name;
+ std::string ConfigName; /* CMAKE_BUILD_TYPE */
+ bool const CmdWindowsShell; /* custom commands run in cmd.exe or /bin/sh */
};
#endif // ! cmGhsMultiTargetGenerator_h
diff --git a/Source/cmGlobVerificationManager.cxx b/Source/cmGlobVerificationManager.cxx
new file mode 100644
index 000000000..481777345
--- /dev/null
+++ b/Source/cmGlobVerificationManager.cxx
@@ -0,0 +1,179 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmGlobVerificationManager.h"
+
+#include <sstream>
+
+#include "cmsys/FStream.hxx"
+
+#include "cmGeneratedFileStream.h"
+#include "cmListFileCache.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmVersion.h"
+
+bool cmGlobVerificationManager::SaveVerificationScript(const std::string& path)
+{
+ if (this->Cache.empty()) {
+ return true;
+ }
+
+ std::string scriptFile = cmStrCat(path, "/CMakeFiles");
+ std::string stampFile = scriptFile;
+ cmSystemTools::MakeDirectory(scriptFile);
+ scriptFile += "/VerifyGlobs.cmake";
+ stampFile += "/cmake.verify_globs";
+ cmGeneratedFileStream verifyScriptFile(scriptFile);
+ verifyScriptFile.SetCopyIfDifferent(true);
+ if (!verifyScriptFile) {
+ cmSystemTools::Error("Unable to open verification script file for save. " +
+ scriptFile);
+ cmSystemTools::ReportLastSystemError("");
+ return false;
+ }
+
+ verifyScriptFile << std::boolalpha;
+ verifyScriptFile << "# CMAKE generated file: DO NOT EDIT!\n"
+ << "# Generated by CMake Version "
+ << cmVersion::GetMajorVersion() << "."
+ << cmVersion::GetMinorVersion() << "\n";
+
+ for (auto const& i : this->Cache) {
+ CacheEntryKey k = std::get<0>(i);
+ CacheEntryValue v = std::get<1>(i);
+
+ if (!v.Initialized) {
+ continue;
+ }
+
+ verifyScriptFile << "\n";
+
+ for (auto const& bt : v.Backtraces) {
+ verifyScriptFile << "# " << std::get<0>(bt);
+ std::get<1>(bt).PrintTitle(verifyScriptFile);
+ verifyScriptFile << "\n";
+ }
+
+ k.PrintGlobCommand(verifyScriptFile, "NEW_GLOB");
+ verifyScriptFile << "\n";
+
+ verifyScriptFile << "set(OLD_GLOB\n";
+ for (const std::string& file : v.Files) {
+ verifyScriptFile << " \"" << file << "\"\n";
+ }
+ verifyScriptFile << " )\n";
+
+ verifyScriptFile << "if(NOT \"${NEW_GLOB}\" STREQUAL \"${OLD_GLOB}\")\n"
+ << " message(\"-- GLOB mismatch!\")\n"
+ << " file(TOUCH_NOCREATE \"" << stampFile << "\")\n"
+ << "endif()\n";
+ }
+ verifyScriptFile.Close();
+
+ cmsys::ofstream verifyStampFile(stampFile.c_str());
+ if (!verifyStampFile) {
+ cmSystemTools::Error("Unable to open verification stamp file for write. " +
+ stampFile);
+ return false;
+ }
+ verifyStampFile << "# This file is generated by CMake for checking of the "
+ "VerifyGlobs.cmake file\n";
+ this->VerifyScript = scriptFile;
+ this->VerifyStamp = stampFile;
+ return true;
+}
+
+bool cmGlobVerificationManager::DoWriteVerifyTarget() const
+{
+ return !this->VerifyScript.empty() && !this->VerifyStamp.empty();
+}
+
+bool cmGlobVerificationManager::CacheEntryKey::operator<(
+ const CacheEntryKey& r) const
+{
+ if (this->Recurse < r.Recurse) {
+ return true;
+ }
+ if (this->Recurse > r.Recurse) {
+ return false;
+ }
+ if (this->ListDirectories < r.ListDirectories) {
+ return true;
+ }
+ if (this->ListDirectories > r.ListDirectories) {
+ return false;
+ }
+ if (this->FollowSymlinks < r.FollowSymlinks) {
+ return true;
+ }
+ if (this->FollowSymlinks > r.FollowSymlinks) {
+ return false;
+ }
+ if (this->Relative < r.Relative) {
+ return true;
+ }
+ if (this->Relative > r.Relative) {
+ return false;
+ }
+ if (this->Expression < r.Expression) {
+ return true;
+ }
+ if (this->Expression > r.Expression) {
+ return false;
+ }
+ return false;
+}
+
+void cmGlobVerificationManager::CacheEntryKey::PrintGlobCommand(
+ std::ostream& out, const std::string& cmdVar)
+{
+ out << "file(GLOB" << (this->Recurse ? "_RECURSE " : " ");
+ out << cmdVar << " ";
+ if (this->Recurse && this->FollowSymlinks) {
+ out << "FOLLOW_SYMLINKS ";
+ }
+ out << "LIST_DIRECTORIES " << this->ListDirectories << " ";
+ if (!this->Relative.empty()) {
+ out << "RELATIVE \"" << this->Relative << "\" ";
+ }
+ out << "\"" << this->Expression << "\")";
+}
+
+void cmGlobVerificationManager::AddCacheEntry(
+ const bool recurse, const bool listDirectories, const bool followSymlinks,
+ const std::string& relative, const std::string& expression,
+ const std::vector<std::string>& files, const std::string& variable,
+ const cmListFileBacktrace& backtrace)
+{
+ CacheEntryKey key = CacheEntryKey(recurse, listDirectories, followSymlinks,
+ relative, expression);
+ CacheEntryValue& value = this->Cache[key];
+ if (!value.Initialized) {
+ value.Files = files;
+ value.Initialized = true;
+ value.Backtraces.emplace_back(variable, backtrace);
+ } else if (value.Initialized && value.Files != files) {
+ std::ostringstream message;
+ message << std::boolalpha;
+ message << "The glob expression\n";
+ key.PrintGlobCommand(message, variable);
+ backtrace.PrintTitle(message);
+ message << "\nwas already present in the glob cache but the directory\n"
+ "contents have changed during the configuration run.\n";
+ message << "Matching glob expressions:";
+ for (auto const& bt : value.Backtraces) {
+ message << "\n " << std::get<0>(bt);
+ std::get<1>(bt).PrintTitle(message);
+ }
+ cmSystemTools::Error(message.str());
+ } else {
+ value.Backtraces.emplace_back(variable, backtrace);
+ }
+}
+
+void cmGlobVerificationManager::Reset()
+{
+ this->Cache.clear();
+ this->VerifyScript.clear();
+ this->VerifyStamp.clear();
+}
diff --git a/Source/cmGlobVerificationManager.h b/Source/cmGlobVerificationManager.h
new file mode 100644
index 000000000..2e7e1ca70
--- /dev/null
+++ b/Source/cmGlobVerificationManager.h
@@ -0,0 +1,85 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmGlobVerificationManager_h
+#define cmGlobVerificationManager_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <iosfwd>
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "cmListFileCache.h"
+
+/** \class cmGlobVerificationManager
+ * \brief Class for expressing build-time dependencies on glob expressions.
+ *
+ * Generates a CMake script which verifies glob outputs during prebuild.
+ *
+ */
+class cmGlobVerificationManager
+{
+protected:
+ //! Save verification script for given makefile.
+ //! Saves to output <path>/<CMakeFilesDirectory>/VerifyGlobs.cmake
+ bool SaveVerificationScript(const std::string& path);
+
+ //! Add an entry into the glob cache
+ void AddCacheEntry(bool recurse, bool listDirectories, bool followSymlinks,
+ const std::string& relative,
+ const std::string& expression,
+ const std::vector<std::string>& files,
+ const std::string& variable,
+ const cmListFileBacktrace& bt);
+
+ //! Clear the glob cache for state reset.
+ void Reset();
+
+ //! Check targets should be written in generated build system.
+ bool DoWriteVerifyTarget() const;
+
+ //! Get the paths to the generated script and stamp files
+ std::string const& GetVerifyScript() const { return this->VerifyScript; }
+ std::string const& GetVerifyStamp() const { return this->VerifyStamp; }
+
+private:
+ struct CacheEntryKey
+ {
+ const bool Recurse;
+ const bool ListDirectories;
+ const bool FollowSymlinks;
+ const std::string Relative;
+ const std::string Expression;
+ CacheEntryKey(const bool rec, const bool l, const bool s, std::string rel,
+ std::string e)
+ : Recurse(rec)
+ , ListDirectories(l)
+ , FollowSymlinks(s)
+ , Relative(std::move(rel))
+ , Expression(std::move(e))
+ {
+ }
+ bool operator<(const CacheEntryKey& r) const;
+ void PrintGlobCommand(std::ostream& out, const std::string& cmdVar);
+ };
+
+ struct CacheEntryValue
+ {
+ bool Initialized = false;
+ std::vector<std::string> Files;
+ std::vector<std::pair<std::string, cmListFileBacktrace>> Backtraces;
+ };
+
+ using CacheEntryMap = std::map<CacheEntryKey, CacheEntryValue>;
+ CacheEntryMap Cache;
+ std::string VerifyScript;
+ std::string VerifyStamp;
+
+ // Only cmState should be able to add cache values.
+ // cmGlobVerificationManager should never be used directly.
+ friend class cmState; // allow access to add cache values
+};
+
+#endif
diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx
index d2372a766..51d681dee 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.cxx
+++ b/Source/cmGlobalBorlandMakefileGenerator.cxx
@@ -5,6 +5,7 @@
#include "cmDocumentationEntry.h"
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmState.h"
#include "cmake.h"
@@ -33,7 +34,7 @@ void cmGlobalBorlandMakefileGenerator::EnableLanguage(
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
}
-///! Create a local generator appropriate to this Global Generator
+//! Create a local generator appropriate to this Global Generator
cmLocalGenerator* cmGlobalBorlandMakefileGenerator::CreateLocalGenerator(
cmMakefile* mf)
{
@@ -51,3 +52,33 @@ void cmGlobalBorlandMakefileGenerator::GetDocumentation(
entry.Name = cmGlobalBorlandMakefileGenerator::GetActualName();
entry.Brief = "Generates Borland makefiles.";
}
+
+std::vector<cmGlobalGenerator::GeneratedMakeCommand>
+cmGlobalBorlandMakefileGenerator::GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int /*jobs*/, bool verbose,
+ std::vector<std::string> const& makeOptions)
+{
+ return this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
+ makeProgram, projectName, projectDir, targetNames, config, fast,
+ cmake::NO_BUILD_PARALLEL_LEVEL, verbose, makeOptions);
+}
+
+void cmGlobalBorlandMakefileGenerator::PrintBuildCommandAdvice(
+ std::ostream& os, int jobs) const
+{
+ if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
+ // Borland's make does not support parallel builds
+ // see http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Make
+
+ /* clang-format off */
+ os <<
+ "Warning: Borland's make does not support parallel builds. "
+ "Ignoring parallel build command line option.\n";
+ /* clang-format on */
+ }
+
+ this->cmGlobalUnixMakefileGenerator3::PrintBuildCommandAdvice(
+ os, cmake::NO_BUILD_PARALLEL_LEVEL);
+}
diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h
index 5578d7646..da04743ac 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.h
+++ b/Source/cmGlobalBorlandMakefileGenerator.h
@@ -3,6 +3,8 @@
#ifndef cmGlobalBorlandMakefileGenerator_h
#define cmGlobalBorlandMakefileGenerator_h
+#include <iosfwd>
+
#include "cmGlobalNMakeMakefileGenerator.h"
/** \class cmGlobalBorlandMakefileGenerator
@@ -20,8 +22,8 @@ public:
cmGlobalBorlandMakefileGenerator>();
}
- ///! Get the name for the generator.
- virtual std::string GetName() const
+ //! Get the name for the generator.
+ std::string GetName() const override
{
return cmGlobalBorlandMakefileGenerator::GetActualName();
}
@@ -30,18 +32,28 @@ public:
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
- ///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
+ //! Create a local generator appropriate to this Global Generator
+ cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override;
/**
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
*/
- virtual void EnableLanguage(std::vector<std::string> const& languages,
- cmMakefile*, bool optional);
+ void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
+ bool optional) override;
+
+ bool AllowNotParallel() const override { return false; }
+ bool AllowDeleteOnError() const override { return false; }
+
+protected:
+ std::vector<GeneratedMakeCommand> GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions =
+ std::vector<std::string>()) override;
- virtual bool AllowNotParallel() const { return false; }
- virtual bool AllowDeleteOnError() const { return false; }
+ void PrintBuildCommandAdvice(std::ostream& os, int jobs) const override;
};
#endif
diff --git a/Source/cmGlobalCommonGenerator.cxx b/Source/cmGlobalCommonGenerator.cxx
index 3b7de4b9c..9fa4467b2 100644
--- a/Source/cmGlobalCommonGenerator.cxx
+++ b/Source/cmGlobalCommonGenerator.cxx
@@ -2,6 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalCommonGenerator.h"
+#include <utility>
+
+#include "cmGeneratorTarget.h"
+#include "cmLocalGenerator.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
+#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
+
class cmake;
cmGlobalCommonGenerator::cmGlobalCommonGenerator(cmake* cm)
@@ -9,6 +18,61 @@ cmGlobalCommonGenerator::cmGlobalCommonGenerator(cmake* cm)
{
}
-cmGlobalCommonGenerator::~cmGlobalCommonGenerator()
+cmGlobalCommonGenerator::~cmGlobalCommonGenerator() = default;
+
+std::map<std::string, cmGlobalCommonGenerator::DirectoryTarget>
+cmGlobalCommonGenerator::ComputeDirectoryTargets() const
{
+ std::map<std::string, DirectoryTarget> dirTargets;
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
+ std::string const& currentBinaryDir(
+ lg->GetStateSnapshot().GetDirectory().GetCurrentBinary());
+ DirectoryTarget& dirTarget = dirTargets[currentBinaryDir];
+ dirTarget.LG = lg;
+
+ // The directory-level rule should depend on the target-level rules
+ // for all targets in the directory.
+ for (auto gt : lg->GetGeneratorTargets()) {
+ cmStateEnums::TargetType const type = gt->GetType();
+ if (type != cmStateEnums::EXECUTABLE &&
+ type != cmStateEnums::STATIC_LIBRARY &&
+ type != cmStateEnums::SHARED_LIBRARY &&
+ type != cmStateEnums::MODULE_LIBRARY &&
+ type != cmStateEnums::OBJECT_LIBRARY &&
+ type != cmStateEnums::UTILITY) {
+ continue;
+ }
+ DirectoryTarget::Target t;
+ t.GT = gt;
+ if (const char* exclude = gt->GetProperty("EXCLUDE_FROM_ALL")) {
+ if (cmIsOn(exclude)) {
+ // This target has been explicitly excluded.
+ t.ExcludeFromAll = true;
+ } else {
+ // This target has been explicitly un-excluded. The directory-level
+ // rule for every directory between this and the root should depend
+ // on the target-level rule for this target.
+ for (cmStateSnapshot dir =
+ lg->GetStateSnapshot().GetBuildsystemDirectoryParent();
+ dir.IsValid(); dir = dir.GetBuildsystemDirectoryParent()) {
+ std::string const& d = dir.GetDirectory().GetCurrentBinary();
+ dirTargets[d].Targets.emplace_back(t);
+ }
+ }
+ }
+ dirTarget.Targets.emplace_back(t);
+ }
+
+ // The directory-level rule should depend on the directory-level
+ // rules of the subdirectories.
+ for (cmStateSnapshot const& state : lg->GetStateSnapshot().GetChildren()) {
+ DirectoryTarget::Dir d;
+ d.Path = state.GetDirectory().GetCurrentBinary();
+ d.ExcludeFromAll =
+ state.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL");
+ dirTarget.Children.emplace_back(std::move(d));
+ }
+ }
+
+ return dirTargets;
}
diff --git a/Source/cmGlobalCommonGenerator.h b/Source/cmGlobalCommonGenerator.h
index f2ad059de..7d16daca2 100644
--- a/Source/cmGlobalCommonGenerator.h
+++ b/Source/cmGlobalCommonGenerator.h
@@ -3,11 +3,17 @@
#ifndef cmGlobalCommonGenerator_h
#define cmGlobalCommonGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <map>
+#include <string>
+#include <vector>
#include "cmGlobalGenerator.h"
class cmake;
+class cmGeneratorTarget;
+class cmLocalGenerator;
/** \class cmGlobalCommonGenerator
* \brief Common infrastructure for Makefile and Ninja global generators.
@@ -16,7 +22,25 @@ class cmGlobalCommonGenerator : public cmGlobalGenerator
{
public:
cmGlobalCommonGenerator(cmake* cm);
- ~cmGlobalCommonGenerator() CM_OVERRIDE;
+ ~cmGlobalCommonGenerator() override;
+
+ struct DirectoryTarget
+ {
+ cmLocalGenerator* LG = nullptr;
+ struct Target
+ {
+ cmGeneratorTarget const* GT = nullptr;
+ bool ExcludeFromAll = false;
+ };
+ std::vector<Target> Targets;
+ struct Dir
+ {
+ std::string Path;
+ bool ExcludeFromAll = false;
+ };
+ std::vector<Dir> Children;
+ };
+ std::map<std::string, DirectoryTarget> ComputeDirectoryTargets() const;
};
#endif
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 099f705f4..09fb87dd7 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2,18 +2,20 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalGenerator.h"
-#include "cmsys/Directory.hxx"
-#include "cmsys/FStream.hxx"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <initializer_list>
#include <iterator>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+
+#include "cmsys/Directory.hxx"
+#include "cmsys/FStream.hxx"
#if defined(_WIN32) && !defined(__CYGWIN__)
-#include <windows.h>
+# include <windows.h>
#endif
#include "cmAlgorithms.h"
@@ -21,6 +23,7 @@
#include "cmComputeTargetDepends.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
+#include "cmDuration.h"
#include "cmExportBuildFileGenerator.h"
#include "cmExternalMakefileProjectGenerator.h"
#include "cmGeneratedFileStream.h"
@@ -31,9 +34,9 @@
#include "cmLocalGenerator.h"
#include "cmMSVC60LinkLineComputer.h"
#include "cmMakefile.h"
-#include "cmOutputConverter.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
-#include "cmQtAutoGeneratorInitializer.h"
+#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmState.h"
#include "cmStateDirectory.h"
@@ -42,14 +45,16 @@
#include "cmWorkingDirectory.h"
#include "cmake.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmCryptoHash.h"
-#include "cm_jsoncpp_value.h"
-#include "cm_jsoncpp_writer.h"
+#if !defined(CMAKE_BOOTSTRAP)
+# include "cm_jsoncpp_value.h"
+# include "cm_jsoncpp_writer.h"
+
+# include "cmCryptoHash.h"
+# include "cmQtAutoGenGlobalInitializer.h"
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1800
-#define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+# define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
#endif
const std::string kCMAKE_PLATFORM_INFO_INITIALIZED =
@@ -62,8 +67,8 @@ bool cmTarget::StrictTargetComparison::operator()(cmTarget const* t1,
{
int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str());
if (nameResult == 0) {
- return strcmp(t1->GetMakefile()->GetCurrentBinaryDirectory(),
- t2->GetMakefile()->GetCurrentBinaryDirectory()) < 0;
+ return strcmp(t1->GetMakefile()->GetCurrentBinaryDirectory().c_str(),
+ t2->GetMakefile()->GetCurrentBinaryDirectory().c_str()) < 0;
}
return nameResult < 0;
}
@@ -87,15 +92,16 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm)
this->InstallTargetEnabled = false;
// how long to let try compiles run
- this->TryCompileTimeout = 0;
+ this->TryCompileTimeout = cmDuration::zero();
- this->ExtraGenerator = CM_NULLPTR;
- this->CurrentMakefile = CM_NULLPTR;
- this->TryCompileOuterMakefile = CM_NULLPTR;
+ this->CurrentConfigureMakefile = nullptr;
+ this->TryCompileOuterMakefile = nullptr;
this->ConfigureDoneCMP0026AndCMP0024 = false;
this->FirstTimeProgress = 0.0f;
+ this->RecursionDepth = 0;
+
cm->GetState()->SetIsGeneratorMultiConfig(false);
cm->GetState()->SetMinGWMake(false);
cm->GetState()->SetMSYSShell(false);
@@ -108,7 +114,35 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm)
cmGlobalGenerator::~cmGlobalGenerator()
{
this->ClearGeneratorMembers();
- delete this->ExtraGenerator;
+}
+
+#if !defined(CMAKE_BOOTSTRAP)
+Json::Value cmGlobalGenerator::GetJson() const
+{
+ Json::Value generator = Json::objectValue;
+ generator["name"] = this->GetName();
+ return generator;
+}
+#endif
+
+bool cmGlobalGenerator::SetGeneratorInstance(std::string const& i,
+ cmMakefile* mf)
+{
+ if (i.empty()) {
+ return true;
+ }
+
+ std::ostringstream e;
+ /* clang-format off */
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "does not support instance specification, but instance\n"
+ " " << i << "\n"
+ "was specified.";
+ /* clang-format on */
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return false;
}
bool cmGlobalGenerator::SetGeneratorPlatform(std::string const& p,
@@ -127,7 +161,7 @@ bool cmGlobalGenerator::SetGeneratorPlatform(std::string const& p,
" " << p << "\n"
"was specified.";
/* clang-format on */
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
@@ -146,7 +180,7 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts,
" " << ts << "\n"
"was specified.";
/* clang-format on */
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
@@ -154,15 +188,15 @@ std::string cmGlobalGenerator::SelectMakeProgram(
const std::string& inMakeProgram, const std::string& makeDefault) const
{
std::string makeProgram = inMakeProgram;
- if (cmSystemTools::IsOff(makeProgram.c_str())) {
+ if (cmIsOff(makeProgram)) {
const char* makeProgramCSTR =
this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
- if (cmSystemTools::IsOff(makeProgramCSTR)) {
+ if (cmIsOff(makeProgramCSTR)) {
makeProgram = makeDefault;
} else {
makeProgram = makeProgramCSTR;
}
- if (cmSystemTools::IsOff(makeProgram.c_str()) && !makeProgram.empty()) {
+ if (cmIsOff(makeProgram) && !makeProgram.empty()) {
makeProgram = "CMAKE_MAKE_PROGRAM-NOTFOUND";
}
}
@@ -173,17 +207,15 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang,
cmMakefile* mf,
bool optional) const
{
- std::string langComp = "CMAKE_";
- langComp += lang;
- langComp += "_COMPILER";
+ std::string langComp = cmStrCat("CMAKE_", lang, "_COMPILER");
if (!mf->GetDefinition(langComp)) {
if (!optional) {
- cmSystemTools::Error(langComp.c_str(), " not set, after EnableLanguage");
+ cmSystemTools::Error(langComp + " not set, after EnableLanguage");
}
return;
}
- const char* name = mf->GetRequiredDefinition(langComp);
+ std::string const& name = mf->GetRequiredDefinition(langComp);
std::string path;
if (!cmSystemTools::FileIsFullPath(name)) {
path = cmSystemTools::FindProgram(name);
@@ -193,15 +225,15 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang,
if (!optional && (path.empty() || !cmSystemTools::FileExists(path))) {
return;
}
- const char* cname =
+ const std::string* cname =
this->GetCMakeInstance()->GetState()->GetInitializedCacheValue(langComp);
std::string changeVars;
if (cname && !optional) {
std::string cnameString;
- if (!cmSystemTools::FileIsFullPath(cname)) {
- cnameString = cmSystemTools::FindProgram(cname);
+ if (!cmSystemTools::FileIsFullPath(*cname)) {
+ cnameString = cmSystemTools::FindProgram(*cname);
} else {
- cnameString = cname;
+ cnameString = *cname;
}
std::string pathString = path;
// get rid of potentially multiple slashes:
@@ -217,7 +249,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang,
}
changeVars += langComp;
changeVars += ";";
- changeVars += cname;
+ changeVars += *cname;
this->GetCMakeInstance()->GetState()->SetGlobalProperty(
"__CMAKE_DELETE_CACHE_CHANGE_VARS_", changeVars.c_str());
}
@@ -238,21 +270,18 @@ void cmGlobalGenerator::AddBuildExportExportSet(
bool cmGlobalGenerator::GenerateImportFile(const std::string& file)
{
- std::map<std::string, cmExportBuildFileGenerator*>::iterator it =
- this->BuildExportSets.find(file);
+ auto const it = this->BuildExportSets.find(file);
if (it != this->BuildExportSets.end()) {
bool result = it->second->GenerateImportFile();
if (!this->ConfigureDoneCMP0026AndCMP0024) {
- for (std::vector<cmMakefile*>::const_iterator mit =
- this->Makefiles.begin();
- mit != this->Makefiles.end(); ++mit) {
- (*mit)->RemoveExportBuildFileGeneratorCMP0024(it->second);
+ for (cmMakefile* m : this->Makefiles) {
+ m->RemoveExportBuildFileGeneratorCMP0024(it->second);
}
}
delete it->second;
- it->second = CM_NULLPTR;
+ it->second = nullptr;
this->BuildExportSets.erase(it);
return result;
}
@@ -263,16 +292,115 @@ void cmGlobalGenerator::ForceLinkerLanguages()
{
}
+bool cmGlobalGenerator::CheckTargetsForMissingSources() const
+{
+ bool failed = false;
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ for (cmGeneratorTarget* target : localGen->GetGeneratorTargets()) {
+ if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET ||
+ target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY ||
+ target->GetType() == cmStateEnums::TargetType::UTILITY ||
+ cmIsOn(target->GetProperty("ghs_integrity_app"))) {
+ continue;
+ }
+
+ std::vector<std::string> configs;
+ target->Makefile->GetConfigurations(configs);
+ std::vector<cmSourceFile*> srcs;
+ if (configs.empty()) {
+ target->GetSourceFiles(srcs, "");
+ } else {
+ for (std::string const& config : configs) {
+ target->GetSourceFiles(srcs, config);
+ if (srcs.empty()) {
+ break;
+ }
+ }
+ }
+ if (srcs.empty()) {
+ std::ostringstream e;
+ e << "No SOURCES given to target: " << target->GetName();
+ this->GetCMakeInstance()->IssueMessage(
+ MessageType::FATAL_ERROR, e.str(), target->GetBacktrace());
+ failed = true;
+ }
+ }
+ }
+ return failed;
+}
+
+bool cmGlobalGenerator::CheckTargetsForType() const
+{
+ if (!this->GetLanguageEnabled("Swift")) {
+ return false;
+ }
+ bool failed = false;
+ for (cmLocalGenerator* generator : this->LocalGenerators) {
+ for (cmGeneratorTarget* target : generator->GetGeneratorTargets()) {
+ if (target->GetType() == cmStateEnums::EXECUTABLE &&
+ target->GetPropertyAsBool("WIN32_EXECUTABLE")) {
+ std::vector<std::string> const& configs =
+ target->Makefile->GetGeneratorConfigs();
+ for (std::string const& config : configs) {
+ if (target->GetLinkerLanguage(config) == "Swift") {
+ this->GetCMakeInstance()->IssueMessage(
+ MessageType::FATAL_ERROR,
+ "WIN32_EXECUTABLE property is not supported on Swift "
+ "executables",
+ target->GetBacktrace());
+ failed = true;
+ }
+ }
+ }
+ }
+ }
+ return failed;
+}
+
+bool cmGlobalGenerator::CheckTargetsForPchCompilePdb() const
+{
+ if (!this->GetLanguageEnabled("C") && !this->GetLanguageEnabled("CXX")) {
+ return false;
+ }
+ bool failed = false;
+ for (cmLocalGenerator* generator : this->LocalGenerators) {
+ for (cmGeneratorTarget* target : generator->GetGeneratorTargets()) {
+ if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET ||
+ target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY ||
+ target->GetType() == cmStateEnums::TargetType::UTILITY ||
+ cmIsOn(target->GetProperty("ghs_integrity_app"))) {
+ continue;
+ }
+
+ const std::string reuseFrom =
+ target->GetSafeProperty("PRECOMPILE_HEADERS_REUSE_FROM");
+ const std::string compilePdb =
+ target->GetSafeProperty("COMPILE_PDB_NAME");
+
+ if (!reuseFrom.empty() && reuseFrom != compilePdb) {
+ const std::string e = cmStrCat(
+ "PRECOMPILE_HEADERS_REUSE_FROM property is set on target (\"",
+ target->GetName(),
+ "\"). Reusable precompile headers requires the COMPILE_PDB_NAME"
+ " property to have the value \"",
+ reuseFrom, "\"\n");
+ this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e,
+ target->GetBacktrace());
+ failed = true;
+ }
+ }
+ }
+ return failed;
+}
+
bool cmGlobalGenerator::IsExportedTargetsFile(
const std::string& filename) const
{
- const std::map<std::string, cmExportBuildFileGenerator*>::const_iterator it =
- this->BuildExportSets.find(filename);
+ auto const it = this->BuildExportSets.find(filename);
if (it == this->BuildExportSets.end()) {
return false;
}
- return this->BuildExportExportSets.find(filename) ==
- this->BuildExportExportSets.end();
+ return !cmContains(this->BuildExportExportSets, filename);
}
// Find the make program for the generator, required for try compiles
@@ -285,20 +413,19 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
return false;
}
if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") ||
- cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
- std::string setMakeProgram =
- mf->GetModulesFile(this->FindMakeProgramFile.c_str());
+ cmIsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
+ std::string setMakeProgram = mf->GetModulesFile(this->FindMakeProgramFile);
if (!setMakeProgram.empty()) {
- mf->ReadListFile(setMakeProgram.c_str());
+ mf->ReadListFile(setMakeProgram);
}
}
if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") ||
- cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
+ cmIsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
std::ostringstream err;
err << "CMake was unable to find a build program corresponding to \""
<< this->GetName() << "\". CMAKE_MAKE_PROGRAM is not set. You "
<< "probably need to select a different build tool.";
- cmSystemTools::Error(err.str().c_str());
+ cmSystemTools::Error(err.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -313,9 +440,7 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
std::string saveFile = file;
cmSystemTools::GetShortPath(makeProgram, makeProgram);
cmSystemTools::SplitProgramPath(makeProgram, dir, file);
- makeProgram = dir;
- makeProgram += "/";
- makeProgram += saveFile;
+ makeProgram = cmStrCat(dir, '/', saveFile);
mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", makeProgram.c_str(),
"make program", cmStateEnums::FILEPATH);
}
@@ -383,13 +508,13 @@ void cmGlobalGenerator::EnableLanguage(
}
std::set<std::string> cur_languages(languages.begin(), languages.end());
- for (std::set<std::string>::iterator li = cur_languages.begin();
- li != cur_languages.end(); ++li) {
- if (!this->LanguagesInProgress.insert(*li).second) {
+ for (std::string const& li : cur_languages) {
+ if (!this->LanguagesInProgress.insert(li).second) {
std::ostringstream e;
- e << "Language '" << *li << "' is currently being enabled. "
- "Recursive call not allowed.";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ e << "Language '" << li
+ << "' is currently being enabled. "
+ "Recursive call not allowed.";
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
cmSystemTools::SetFatalErrorOccured();
return;
}
@@ -397,17 +522,15 @@ void cmGlobalGenerator::EnableLanguage(
if (this->TryCompileOuterMakefile) {
// In a try-compile we can only enable languages provided by caller.
- for (std::vector<std::string>::const_iterator li = languages.begin();
- li != languages.end(); ++li) {
- if (*li == "NONE") {
+ for (std::string const& lang : languages) {
+ if (lang == "NONE") {
this->SetLanguageEnabled("NONE", mf);
} else {
- const char* lang = li->c_str();
- if (this->LanguagesReady.find(lang) == this->LanguagesReady.end()) {
+ if (!cmContains(this->LanguagesReady, lang)) {
std::ostringstream e;
e << "The test project needs language " << lang
<< " which is not enabled.";
- this->TryCompileOuterMakefile->IssueMessage(cmake::FATAL_ERROR,
+ this->TryCompileOuterMakefile->IssueMessage(MessageType::FATAL_ERROR,
e.str());
cmSystemTools::SetFatalErrorOccured();
return;
@@ -418,9 +541,9 @@ void cmGlobalGenerator::EnableLanguage(
bool fatalError = false;
- mf->AddDefinition("RUN_CONFIGURE", true);
- std::string rootBin = this->CMakeInstance->GetHomeOutputDirectory();
- rootBin += cmake::GetCMakeFilesDirectory();
+ mf->AddDefinitionBool("RUN_CONFIGURE", true);
+ std::string rootBin =
+ cmStrCat(this->CMakeInstance->GetHomeOutputDirectory(), "/CMakeFiles");
// If the configuration files path has been set,
// then we are in a try compile and need to copy the enable language
@@ -428,11 +551,11 @@ void cmGlobalGenerator::EnableLanguage(
if (!this->ConfiguredFilesPath.empty()) {
rootBin = this->ConfiguredFilesPath;
}
- rootBin += "/";
+ rootBin += '/';
rootBin += cmVersion::GetCMakeVersion();
// set the dir for parent files so they can be used by modules
- mf->AddDefinition("CMAKE_PLATFORM_INFO_DIR", rootBin.c_str());
+ mf->AddDefinition("CMAKE_PLATFORM_INFO_DIR", rootBin);
if (!this->CMakeInstance->GetIsInTryCompile()) {
// Keep a mark in the cache to indicate that we've initialized the
@@ -451,22 +574,13 @@ void cmGlobalGenerator::EnableLanguage(
"Platform information initialized", cmStateEnums::INTERNAL);
}
- // find and make sure CMAKE_MAKE_PROGRAM is defined
- if (!this->FindMakeProgram(mf)) {
- return;
- }
-
- if (!this->CheckLanguages(languages, mf)) {
- return;
- }
-
// try and load the CMakeSystem.cmake if it is there
std::string fpath = rootBin;
bool const readCMakeSystem = !mf->GetDefinition("CMAKE_SYSTEM_LOADED");
if (readCMakeSystem) {
fpath += "/CMakeSystem.cmake";
- if (cmSystemTools::FileExists(fpath.c_str())) {
- mf->ReadListFile(fpath.c_str());
+ if (cmSystemTools::FileExists(fpath)) {
+ mf->ReadListFile(fpath);
}
}
// Load the CMakeDetermineSystem.cmake file and find out
@@ -478,33 +592,48 @@ void cmGlobalGenerator::EnableLanguage(
ZeroMemory(&osviex, sizeof(osviex));
osviex.dwOSVersionInfoSize = sizeof(osviex);
-#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-#pragma warning(push)
-#pragma warning(disable : 4996)
-#endif
+# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+# pragma warning(push)
+# ifdef __INTEL_COMPILER
+# pragma warning(disable : 1478)
+# elif defined __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wdeprecated-declarations"
+# else
+# pragma warning(disable : 4996)
+# endif
+# endif
GetVersionExW((OSVERSIONINFOW*)&osviex);
-#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-#pragma warning(pop)
-#endif
+# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+# ifdef __clang__
+# pragma clang diagnostic pop
+# else
+# pragma warning(pop)
+# endif
+# endif
std::ostringstream windowsVersionString;
windowsVersionString << osviex.dwMajorVersion << "."
<< osviex.dwMinorVersion << "."
<< osviex.dwBuildNumber;
- windowsVersionString.str();
- mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION",
- windowsVersionString.str().c_str());
+ mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION", windowsVersionString.str());
#endif
// Read the DetermineSystem file
std::string systemFile = mf->GetModulesFile("CMakeDetermineSystem.cmake");
- mf->ReadListFile(systemFile.c_str());
+ mf->ReadListFile(systemFile);
// load the CMakeSystem.cmake from the binary directory
// this file is configured by the CMakeDetermineSystem.cmake file
- fpath = rootBin;
- fpath += "/CMakeSystem.cmake";
- mf->ReadListFile(fpath.c_str());
+ fpath = cmStrCat(rootBin, "/CMakeSystem.cmake");
+ mf->ReadListFile(fpath);
}
if (readCMakeSystem) {
+ // Tell the generator about the instance, if any.
+ std::string instance = mf->GetSafeDefinition("CMAKE_GENERATOR_INSTANCE");
+ if (!this->SetGeneratorInstance(instance, mf)) {
+ cmSystemTools::SetFatalErrorOccured();
+ return;
+ }
+
// Tell the generator about the target system.
std::string system = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
if (!this->SetSystemName(system, mf)) {
@@ -525,12 +654,23 @@ void cmGlobalGenerator::EnableLanguage(
cmSystemTools::SetFatalErrorOccured();
return;
}
+
+ // Find the native build tool for this generator.
+ if (!this->FindMakeProgram(mf)) {
+ return;
+ }
+ }
+
+ // Check that the languages are supported by the generator and its
+ // native build tool found above.
+ if (!this->CheckLanguages(languages, mf)) {
+ return;
}
// **** Load the system specific initialization if not yet loaded
if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED")) {
fpath = mf->GetModulesFile("CMakeSystemSpecificInitialize.cmake");
- if (!mf->ReadListFile(fpath.c_str())) {
+ if (!mf->ReadListFile(fpath)) {
cmSystemTools::Error("Could not find cmake module file: "
"CMakeSystemSpecificInitialize.cmake");
}
@@ -542,30 +682,22 @@ void cmGlobalGenerator::EnableLanguage(
// load the CMakeDetermine(LANG)Compiler.cmake file to find
// the compiler
- for (std::vector<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
- const char* lang = l->c_str();
+ for (std::string const& lang : languages) {
needSetLanguageEnabledMaps[lang] = false;
- if (*l == "NONE") {
+ if (lang == "NONE") {
this->SetLanguageEnabled("NONE", mf);
continue;
}
- std::string loadedLang = "CMAKE_";
- loadedLang += lang;
- loadedLang += "_COMPILER_LOADED";
+ std::string loadedLang = cmStrCat("CMAKE_", lang, "_COMPILER_LOADED");
if (!mf->GetDefinition(loadedLang)) {
- fpath = rootBin;
- fpath += "/CMake";
- fpath += lang;
- fpath += "Compiler.cmake";
+ fpath = cmStrCat(rootBin, "/CMake", lang, "Compiler.cmake");
// If the existing build tree was already configured with this
// version of CMake then try to load the configured file first
// to avoid duplicate compiler tests.
- if (cmSystemTools::FileExists(fpath.c_str())) {
- if (!mf->ReadListFile(fpath.c_str())) {
- cmSystemTools::Error("Could not find cmake module file: ",
- fpath.c_str());
+ if (cmSystemTools::FileExists(fpath)) {
+ if (!mf->ReadListFile(fpath)) {
+ cmSystemTools::Error("Could not find cmake module file: " + fpath);
}
// if this file was found then the language was already determined
// to be working
@@ -585,14 +717,12 @@ void cmGlobalGenerator::EnableLanguage(
}
// if the CMake(LANG)Compiler.cmake file was not found then
// load CMakeDetermine(LANG)Compiler.cmake
- std::string determineCompiler = "CMakeDetermine";
- determineCompiler += lang;
- determineCompiler += "Compiler.cmake";
- std::string determineFile =
- mf->GetModulesFile(determineCompiler.c_str());
- if (!mf->ReadListFile(determineFile.c_str())) {
- cmSystemTools::Error("Could not find cmake module file: ",
- determineCompiler.c_str());
+ std::string determineCompiler =
+ cmStrCat("CMakeDetermine", lang, "Compiler.cmake");
+ std::string determineFile = mf->GetModulesFile(determineCompiler);
+ if (!mf->ReadListFile(determineFile)) {
+ cmSystemTools::Error("Could not find cmake module file: " +
+ determineCompiler);
}
if (cmSystemTools::GetFatalErrorOccured()) {
return;
@@ -604,29 +734,21 @@ void cmGlobalGenerator::EnableLanguage(
// put ${CMake_(LANG)_COMPILER_ENV_VAR}=${CMAKE_(LANG)_COMPILER
// into the environment, in case user scripts want to run
// configure, or sub cmakes
- std::string compilerName = "CMAKE_";
- compilerName += lang;
- compilerName += "_COMPILER";
- std::string compilerEnv = "CMAKE_";
- compilerEnv += lang;
- compilerEnv += "_COMPILER_ENV_VAR";
- std::string envVar = mf->GetRequiredDefinition(compilerEnv);
- std::string envVarValue = mf->GetRequiredDefinition(compilerName);
- std::string env = envVar;
- env += "=";
- env += envVarValue;
+ std::string compilerName = cmStrCat("CMAKE_", lang, "_COMPILER");
+ std::string compilerEnv =
+ cmStrCat("CMAKE_", lang, "_COMPILER_ENV_VAR");
+ const std::string& envVar = mf->GetRequiredDefinition(compilerEnv);
+ const std::string& envVarValue =
+ mf->GetRequiredDefinition(compilerName);
+ std::string env = cmStrCat(envVar, '=', envVarValue);
cmSystemTools::PutEnv(env);
}
// if determineLanguage was called then load the file it
// configures CMake(LANG)Compiler.cmake
- fpath = rootBin;
- fpath += "/CMake";
- fpath += lang;
- fpath += "Compiler.cmake";
- if (!mf->ReadListFile(fpath.c_str())) {
- cmSystemTools::Error("Could not find cmake module file: ",
- fpath.c_str());
+ fpath = cmStrCat(rootBin, "/CMake", lang, "Compiler.cmake");
+ if (!mf->ReadListFile(fpath)) {
+ cmSystemTools::Error("Could not find cmake module file: " + fpath);
}
this->SetLanguageEnabledFlag(lang, mf);
needSetLanguageEnabledMaps[lang] = true;
@@ -641,38 +763,31 @@ void cmGlobalGenerator::EnableLanguage(
// **** Load the system specific information if not yet loaded
if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED")) {
fpath = mf->GetModulesFile("CMakeSystemSpecificInformation.cmake");
- if (!mf->ReadListFile(fpath.c_str())) {
+ if (!mf->ReadListFile(fpath)) {
cmSystemTools::Error("Could not find cmake module file: "
"CMakeSystemSpecificInformation.cmake");
}
}
// loop over languages again loading CMake(LANG)Information.cmake
//
- for (std::vector<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
- const char* lang = l->c_str();
- if (*l == "NONE") {
+ for (std::string const& lang : languages) {
+ if (lang == "NONE") {
this->SetLanguageEnabled("NONE", mf);
continue;
}
// Check that the compiler was found.
- std::string compilerName = "CMAKE_";
- compilerName += lang;
- compilerName += "_COMPILER";
- std::string compilerEnv = "CMAKE_";
- compilerEnv += lang;
- compilerEnv += "_COMPILER_ENV_VAR";
+ std::string compilerName = cmStrCat("CMAKE_", lang, "_COMPILER");
+ std::string compilerEnv = cmStrCat("CMAKE_", lang, "_COMPILER_ENV_VAR");
std::ostringstream noCompiler;
const char* compilerFile = mf->GetDefinition(compilerName);
- if (!compilerFile || !*compilerFile ||
- cmSystemTools::IsNOTFOUND(compilerFile)) {
+ if (!compilerFile || !*compilerFile || cmIsNOTFOUND(compilerFile)) {
/* clang-format off */
noCompiler <<
"No " << compilerName << " could be found.\n"
;
/* clang-format on */
- } else if (strcmp(lang, "RC") != 0 && strcmp(lang, "ASM_MASM") != 0) {
+ } else if ((lang != "RC") && (lang != "ASM_MASM")) {
if (!cmSystemTools::FileIsFullPath(compilerFile)) {
/* clang-format off */
noCompiler <<
@@ -697,34 +812,28 @@ void cmGlobalGenerator::EnableLanguage(
if (!optional) {
// The compiler was not found and it is not optional. Remove
// CMake(LANG)Compiler.cmake so we try again next time CMake runs.
- std::string compilerLangFile = rootBin;
- compilerLangFile += "/CMake";
- compilerLangFile += lang;
- compilerLangFile += "Compiler.cmake";
+ std::string compilerLangFile =
+ cmStrCat(rootBin, "/CMake", lang, "Compiler.cmake");
cmSystemTools::RemoveFile(compilerLangFile);
if (!this->CMakeInstance->GetIsInTryCompile()) {
this->PrintCompilerAdvice(noCompiler, lang,
mf->GetDefinition(compilerEnv));
- mf->IssueMessage(cmake::FATAL_ERROR, noCompiler.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, noCompiler.str());
fatalError = true;
}
}
}
- std::string langLoadedVar = "CMAKE_";
- langLoadedVar += lang;
- langLoadedVar += "_INFORMATION_LOADED";
+ std::string langLoadedVar =
+ cmStrCat("CMAKE_", lang, "_INFORMATION_LOADED");
if (!mf->GetDefinition(langLoadedVar)) {
- fpath = "CMake";
- fpath += lang;
- fpath += "Information.cmake";
- std::string informationFile = mf->GetModulesFile(fpath.c_str());
+ fpath = cmStrCat("CMake", lang, "Information.cmake");
+ std::string informationFile = mf->GetModulesFile(fpath);
if (informationFile.empty()) {
- cmSystemTools::Error("Could not find cmake module file: ",
- fpath.c_str());
- } else if (!mf->ReadListFile(informationFile.c_str())) {
- cmSystemTools::Error("Could not process cmake module file: ",
- informationFile.c_str());
+ cmSystemTools::Error("Could not find cmake module file: " + fpath);
+ } else if (!mf->ReadListFile(informationFile)) {
+ cmSystemTools::Error("Could not process cmake module file: " +
+ informationFile);
}
}
if (needSetLanguageEnabledMaps[lang]) {
@@ -739,37 +848,29 @@ void cmGlobalGenerator::EnableLanguage(
// If the language is untested then test it now with a try compile.
if (needTestLanguage[lang]) {
if (!this->CMakeInstance->GetIsInTryCompile()) {
- std::string testLang = "CMakeTest";
- testLang += lang;
- testLang += "Compiler.cmake";
- std::string ifpath = mf->GetModulesFile(testLang.c_str());
- if (!mf->ReadListFile(ifpath.c_str())) {
- cmSystemTools::Error("Could not find cmake module file: ",
- testLang.c_str());
+ std::string testLang = cmStrCat("CMakeTest", lang, "Compiler.cmake");
+ std::string ifpath = mf->GetModulesFile(testLang);
+ if (!mf->ReadListFile(ifpath)) {
+ cmSystemTools::Error("Could not find cmake module file: " +
+ testLang);
}
- std::string compilerWorks = "CMAKE_";
- compilerWorks += lang;
- compilerWorks += "_COMPILER_WORKS";
+ std::string compilerWorks =
+ cmStrCat("CMAKE_", lang, "_COMPILER_WORKS");
// if the compiler did not work, then remove the
// CMake(LANG)Compiler.cmake file so that it will get tested the
// next time cmake is run
if (!mf->IsOn(compilerWorks)) {
- std::string compilerLangFile = rootBin;
- compilerLangFile += "/CMake";
- compilerLangFile += lang;
- compilerLangFile += "Compiler.cmake";
+ std::string compilerLangFile =
+ cmStrCat(rootBin, "/CMake", lang, "Compiler.cmake");
cmSystemTools::RemoveFile(compilerLangFile);
}
} // end if in try compile
} // end need test language
// Store the shared library flags so that we can satisfy CMP0018
- std::string sharedLibFlagsVar = "CMAKE_SHARED_LIBRARY_";
- sharedLibFlagsVar += lang;
- sharedLibFlagsVar += "_FLAGS";
- const char* sharedLibFlags = mf->GetSafeDefinition(sharedLibFlagsVar);
- if (sharedLibFlags) {
- this->LanguageToOriginalSharedLibFlags[lang] = sharedLibFlags;
- }
+ std::string sharedLibFlagsVar =
+ cmStrCat("CMAKE_SHARED_LIBRARY_", lang, "_FLAGS");
+ this->LanguageToOriginalSharedLibFlags[lang] =
+ mf->GetSafeDefinition(sharedLibFlagsVar);
// Translate compiler ids for compatibility.
this->CheckCompilerIdCompatibility(mf, lang);
@@ -778,12 +879,11 @@ void cmGlobalGenerator::EnableLanguage(
// Now load files that can override any settings on the platform or for
// the project First load the project compatibility file if it is in
// cmake
- std::string projectCompatibility = cmSystemTools::GetCMakeRoot();
- projectCompatibility += "/Modules/";
- projectCompatibility += mf->GetSafeDefinition("PROJECT_NAME");
- projectCompatibility += "Compatibility.cmake";
- if (cmSystemTools::FileExists(projectCompatibility.c_str())) {
- mf->ReadListFile(projectCompatibility.c_str());
+ std::string projectCompatibility =
+ cmStrCat(cmSystemTools::GetCMakeRoot(), "/Modules/",
+ mf->GetSafeDefinition("PROJECT_NAME"), "Compatibility.cmake");
+ if (cmSystemTools::FileExists(projectCompatibility)) {
+ mf->ReadListFile(projectCompatibility);
}
// Inform any extra generator of the new language.
if (this->ExtraGenerator) {
@@ -794,9 +894,8 @@ void cmGlobalGenerator::EnableLanguage(
cmSystemTools::SetFatalErrorOccured();
}
- for (std::set<std::string>::iterator li = cur_languages.begin();
- li != cur_languages.end(); ++li) {
- this->LanguagesInProgress.erase(*li);
+ for (std::string const& lang : cur_languages) {
+ this->LanguagesInProgress.erase(lang);
}
}
@@ -819,12 +918,9 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
cmMakefile* mf, std::string const& lang) const
{
std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID";
- const char* compilerId = mf->GetDefinition(compilerIdVar);
- if (!compilerId) {
- return;
- }
+ std::string const compilerId = mf->GetSafeDefinition(compilerIdVar);
- if (strcmp(compilerId, "AppleClang") == 0) {
+ if (compilerId == "AppleClang") {
switch (mf->GetPolicyStatus(cmPolicies::CMP0025)) {
case cmPolicies::WARN:
if (!this->CMakeInstance->GetIsInTryCompile() &&
@@ -833,10 +929,10 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
/* clang-format off */
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0025) << "\n"
"Converting " << lang <<
- " compiler id \"AppleClang\" to \"Clang\" for compatibility."
+ R"( compiler id "AppleClang" to "Clang" for compatibility.)"
;
/* clang-format on */
- mf->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ mf->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
}
CM_FALLTHROUGH;
case cmPolicies::OLD:
@@ -846,7 +942,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
mf->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0025));
case cmPolicies::NEW:
// NEW behavior is to keep AppleClang.
@@ -854,7 +950,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
}
}
- if (strcmp(compilerId, "QCC") == 0) {
+ if (compilerId == "QCC") {
switch (mf->GetPolicyStatus(cmPolicies::CMP0047)) {
case cmPolicies::WARN:
if (!this->CMakeInstance->GetIsInTryCompile() &&
@@ -863,10 +959,10 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
/* clang-format off */
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0047) << "\n"
"Converting " << lang <<
- " compiler id \"QCC\" to \"GNU\" for compatibility."
+ R"( compiler id "QCC" to "GNU" for compatibility.)"
;
/* clang-format on */
- mf->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ mf->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
}
CM_FALLTHROUGH;
case cmPolicies::OLD:
@@ -881,7 +977,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
mf->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0047));
CM_FALLTHROUGH;
case cmPolicies::NEW:
@@ -889,6 +985,36 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
break;
}
}
+
+ if (compilerId == "XLClang") {
+ switch (mf->GetPolicyStatus(cmPolicies::CMP0089)) {
+ case cmPolicies::WARN:
+ if (!this->CMakeInstance->GetIsInTryCompile() &&
+ mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0089")) {
+ std::ostringstream w;
+ /* clang-format off */
+ w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0089) << "\n"
+ "Converting " << lang <<
+ R"( compiler id "XLClang" to "XL" for compatibility.)"
+ ;
+ /* clang-format on */
+ mf->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+ }
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ // OLD behavior is to convert XLClang to XL.
+ mf->AddDefinition(compilerIdVar, "XL");
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0089));
+ case cmPolicies::NEW:
+ // NEW behavior is to keep AppleClang.
+ break;
+ }
+ }
}
std::string cmGlobalGenerator::GetLanguageOutputExtension(
@@ -896,15 +1022,13 @@ std::string cmGlobalGenerator::GetLanguageOutputExtension(
{
const std::string& lang = source.GetLanguage();
if (!lang.empty()) {
- std::map<std::string, std::string>::const_iterator it =
- this->LanguageToOutputExtension.find(lang);
-
+ auto const it = this->LanguageToOutputExtension.find(lang);
if (it != this->LanguageToOutputExtension.end()) {
return it->second;
}
} else {
// if no language is found then check to see if it is already an
- // ouput extension for some language. In that case it should be ignored
+ // output extension for some language. In that case it should be ignored
// and in this map, so it will not be compiled but will just be used.
std::string const& ext = source.GetExtension();
if (!ext.empty()) {
@@ -923,8 +1047,7 @@ std::string cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const
if (ext && *ext == '.') {
++ext;
}
- std::map<std::string, std::string>::const_iterator it =
- this->ExtensionToLanguage.find(ext);
+ auto const it = this->ExtensionToLanguage.find(ext);
if (it != this->ExtensionToLanguage.end()) {
return it->second;
}
@@ -968,8 +1091,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l,
{
// use LanguageToLinkerPreference to detect whether this functions has
// run before
- if (this->LanguageToLinkerPreference.find(l) !=
- this->LanguageToLinkerPreference.end()) {
+ if (cmContains(this->LanguageToLinkerPreference, l)) {
return;
}
@@ -992,9 +1114,9 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l,
}
if (preference < 0) {
- std::string msg = linkerPrefVar;
- msg += " is negative, adjusting it to 0";
- cmSystemTools::Message(msg.c_str(), "Warning");
+ std::string msg =
+ cmStrCat(linkerPrefVar, " is negative, adjusting it to 0");
+ cmSystemTools::Message(msg, "Warning");
preference = 0;
}
@@ -1019,11 +1141,9 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l,
std::string ignoreExtensionsVar =
std::string("CMAKE_") + std::string(l) + std::string("_IGNORE_EXTENSIONS");
std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar);
- std::vector<std::string> extensionList;
- cmSystemTools::ExpandListArgument(ignoreExts, extensionList);
- for (std::vector<std::string>::iterator i = extensionList.begin();
- i != extensionList.end(); ++i) {
- this->IgnoreExtensions[*i] = true;
+ std::vector<std::string> extensionList = cmExpandedList(ignoreExts);
+ for (std::string const& i : extensionList) {
+ this->IgnoreExtensions[i] = true;
}
}
@@ -1032,12 +1152,10 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l,
{
std::string extensionsVar = std::string("CMAKE_") + std::string(l) +
std::string("_SOURCE_FILE_EXTENSIONS");
- std::string exts = mf->GetSafeDefinition(extensionsVar);
- std::vector<std::string> extensionList;
- cmSystemTools::ExpandListArgument(exts, extensionList);
- for (std::vector<std::string>::iterator i = extensionList.begin();
- i != extensionList.end(); ++i) {
- this->ExtensionToLanguage[*i] = l;
+ const std::string& exts = mf->GetSafeDefinition(extensionsVar);
+ std::vector<std::string> extensionList = cmExpandedList(exts);
+ for (std::string const& i : extensionList) {
+ this->ExtensionToLanguage[i] = l;
}
}
@@ -1053,7 +1171,7 @@ bool cmGlobalGenerator::GlobalSettingIsOn(std::string const& name) const
return this->Makefiles[0]->IsOn(name);
}
-const char* cmGlobalGenerator::GetSafeGlobalSetting(
+std::string cmGlobalGenerator::GetSafeGlobalSetting(
std::string const& name) const
{
assert(!this->Makefiles.empty());
@@ -1075,17 +1193,19 @@ bool cmGlobalGenerator::GetLanguageEnabled(const std::string& l) const
void cmGlobalGenerator::ClearEnabledLanguages()
{
- return this->CMakeInstance->GetState()->ClearEnabledLanguages();
+ this->CMakeInstance->GetState()->ClearEnabledLanguages();
}
void cmGlobalGenerator::CreateLocalGenerators()
{
+ this->LocalGeneratorSearchIndex.clear();
cmDeleteAll(this->LocalGenerators);
this->LocalGenerators.clear();
this->LocalGenerators.reserve(this->Makefiles.size());
- for (std::vector<cmMakefile*>::const_iterator it = this->Makefiles.begin();
- it != this->Makefiles.end(); ++it) {
- this->LocalGenerators.push_back(this->CreateLocalGenerator(*it));
+ for (cmMakefile* m : this->Makefiles) {
+ cmLocalGenerator* lg = this->CreateLocalGenerator(m);
+ this->LocalGenerators.push_back(lg);
+ this->IndexLocalGenerator(lg);
}
}
@@ -1102,6 +1222,7 @@ void cmGlobalGenerator::Configure()
this->CMakeInstance->GetHomeOutputDirectory());
cmMakefile* dirMf = new cmMakefile(this, snapshot);
+ dirMf->SetRecursionDepth(this->RecursionDepth);
this->Makefiles.push_back(dirMf);
this->IndexMakefile(dirMf);
@@ -1116,16 +1237,16 @@ void cmGlobalGenerator::Configure()
this->ConfigureDoneCMP0026AndCMP0024 = true;
// Put a copy of each global target in every directory.
- std::vector<GlobalTargetInfo> globalTargets;
- this->CreateDefaultGlobalTargets(globalTargets);
-
- for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
- cmMakefile* mf = this->Makefiles[i];
- cmTargets* targets = &(mf->GetTargets());
- for (std::vector<GlobalTargetInfo>::iterator gti = globalTargets.begin();
- gti != globalTargets.end(); ++gti) {
- targets->insert(
- cmTargets::value_type(gti->Name, this->CreateGlobalTarget(*gti, mf)));
+ {
+ std::vector<GlobalTargetInfo> globalTargets;
+ this->CreateDefaultGlobalTargets(globalTargets);
+
+ for (cmMakefile* mf : this->Makefiles) {
+ auto& targets = mf->GetTargets();
+ for (GlobalTargetInfo const& globalTarget : globalTargets) {
+ targets.emplace(globalTarget.Name,
+ this->CreateGlobalTarget(globalTarget, mf));
+ }
}
}
@@ -1145,20 +1266,18 @@ void cmGlobalGenerator::Configure()
std::ostringstream msg;
if (cmSystemTools::GetErrorOccuredFlag()) {
msg << "Configuring incomplete, errors occurred!";
- const char* logs[] = { "CMakeOutput.log", "CMakeError.log", CM_NULLPTR };
+ const char* logs[] = { "CMakeOutput.log", "CMakeError.log", nullptr };
for (const char** log = logs; *log; ++log) {
- std::string f = this->CMakeInstance->GetHomeOutputDirectory();
- f += this->CMakeInstance->GetCMakeFilesDirectory();
- f += "/";
- f += *log;
- if (cmSystemTools::FileExists(f.c_str())) {
+ std::string f = cmStrCat(this->CMakeInstance->GetHomeOutputDirectory(),
+ "/CMakeFiles/", *log);
+ if (cmSystemTools::FileExists(f)) {
msg << "\nSee also \"" << f << "\".";
}
}
} else {
msg << "Configuring done";
}
- this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1);
+ this->CMakeInstance->UpdateProgress(msg.str(), -1);
}
}
@@ -1174,13 +1293,12 @@ void cmGlobalGenerator::CreateImportedGenerationObjects(
std::vector<const cmGeneratorTarget*>& exports)
{
this->CreateGenerationObjects(ImportedOnly);
- std::vector<cmMakefile*>::iterator mfit =
+ auto const mfit =
std::find(this->Makefiles.begin(), this->Makefiles.end(), mf);
cmLocalGenerator* lg =
this->LocalGenerators[std::distance(this->Makefiles.begin(), mfit)];
- for (std::vector<std::string>::const_iterator it = targets.begin();
- it != targets.end(); ++it) {
- cmGeneratorTarget* gt = lg->FindGeneratorTargetToUse(*it);
+ for (std::string const& t : targets) {
+ cmGeneratorTarget* gt = lg->FindGeneratorTargetToUse(t);
if (gt) {
exports.push_back(gt);
}
@@ -1190,9 +1308,8 @@ void cmGlobalGenerator::CreateImportedGenerationObjects(
cmExportBuildFileGenerator* cmGlobalGenerator::GetExportedTargetsFile(
const std::string& filename) const
{
- std::map<std::string, cmExportBuildFileGenerator*>::const_iterator it =
- this->BuildExportSets.find(filename);
- return it == this->BuildExportSets.end() ? CM_NULLPTR : it->second;
+ auto const it = this->BuildExportSets.find(filename);
+ return it == this->BuildExportSets.end() ? nullptr : it->second;
}
void cmGlobalGenerator::AddCMP0042WarnTarget(const std::string& target)
@@ -1221,7 +1338,7 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const
<< "duplicate custom targets. "
<< "Consider using a Makefiles generator or fix the project to not "
<< "use duplicate target names.";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
}
@@ -1230,10 +1347,8 @@ void cmGlobalGenerator::ComputeBuildFileGenerators()
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
std::vector<cmExportBuildFileGenerator*> gens =
this->Makefiles[i]->GetExportBuildFileGenerators();
- for (std::vector<cmExportBuildFileGenerator*>::const_iterator it =
- gens.begin();
- it != gens.end(); ++it) {
- (*it)->Compute(this->LocalGenerators[i]);
+ for (cmExportBuildFileGenerator* g : gens) {
+ g->Compute(this->LocalGenerators[i]);
}
}
}
@@ -1261,18 +1376,19 @@ bool cmGlobalGenerator::Compute()
// so create the map from project name to vector of local generators
this->FillProjectMap();
-#ifdef CMAKE_BUILD_WITH_CMAKE
- // Iterate through all targets and set up automoc for those which have
- // the AUTOMOC, AUTOUIC or AUTORCC property set
- std::vector<cmGeneratorTarget const*> autogenTargets =
- this->CreateQtAutoGeneratorsTargets();
-#endif
+ // Iterate through all targets and set up AUTOMOC, AUTOUIC and AUTORCC
+ if (!this->QtAutoGen()) {
+ return false;
+ }
- unsigned int i;
+ // Add automatically generated sources (e.g. unity build).
+ if (!this->AddAutomaticSources()) {
+ return false;
+ }
// Add generator specific helper commands
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- this->LocalGenerators[i]->AddHelperCommands();
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ localGen->AddHelperCommands();
}
// Finalize the set of compile features for each target.
@@ -1281,26 +1397,18 @@ bool cmGlobalGenerator::Compute()
// on the original cmTarget instance. It accumulates features
// across all configurations. Some refactoring is needed to
// compute a per-config resulta purely during generation.
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- if (!this->LocalGenerators[i]->ComputeTargetCompileFeatures()) {
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ if (!localGen->ComputeTargetCompileFeatures()) {
return false;
}
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
- for (std::vector<cmGeneratorTarget const*>::iterator it =
- autogenTargets.begin();
- it != autogenTargets.end(); ++it) {
- cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(*it);
- }
-#endif
-
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- cmMakefile* mf = this->LocalGenerators[i]->GetMakefile();
- std::vector<cmInstallGenerator*>& gens = mf->GetInstallGenerators();
- for (std::vector<cmInstallGenerator*>::const_iterator git = gens.begin();
- git != gens.end(); ++git) {
- (*git)->Compute(this->LocalGenerators[i]);
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ cmMakefile* mf = localGen->GetMakefile();
+ for (cmInstallGenerator* g : mf->GetInstallGenerators()) {
+ if (!g->Compute(localGen)) {
+ return false;
+ }
}
}
@@ -1308,15 +1416,20 @@ bool cmGlobalGenerator::Compute()
// Trace the dependencies, after that no custom commands should be added
// because their dependencies might not be handled correctly
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- this->LocalGenerators[i]->TraceDependencies();
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ localGen->TraceDependencies();
+ }
+
+ // Make sure that all (non-imported) targets have source files added!
+ if (this->CheckTargetsForMissingSources()) {
+ return false;
}
this->ForceLinkerLanguages();
// Compute the manifest of main targets generated.
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- this->LocalGenerators[i]->ComputeTargetManifest();
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ localGen->ComputeTargetManifest();
}
// Compute the inter-target dependencies.
@@ -1324,8 +1437,16 @@ bool cmGlobalGenerator::Compute()
return false;
}
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- this->LocalGenerators[i]->ComputeHomeRelativeOutputPath();
+ if (this->CheckTargetsForType()) {
+ return false;
+ }
+
+ if (this->CheckTargetsForPchCompilePdb()) {
+ return false;
+ }
+
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ localGen->ComputeHomeRelativeOutputPath();
}
return true;
@@ -1349,22 +1470,21 @@ void cmGlobalGenerator::Generate()
}
this->LocalGenerators[i]->GenerateTestFiles();
this->CMakeInstance->UpdateProgress(
- "Generating", (static_cast<float>(i) + 1.0f) /
+ "Generating",
+ (static_cast<float>(i) + 1.0f) /
static_cast<float>(this->LocalGenerators.size()));
}
- this->SetCurrentMakefile(CM_NULLPTR);
+ this->SetCurrentMakefile(nullptr);
if (!this->GenerateCPackPropertiesFile()) {
this->GetCMakeInstance()->IssueMessage(
- cmake::FATAL_ERROR, "Could not write CPack properties file.");
+ MessageType::FATAL_ERROR, "Could not write CPack properties file.");
}
- for (std::map<std::string, cmExportBuildFileGenerator*>::iterator it =
- this->BuildExportSets.begin();
- it != this->BuildExportSets.end(); ++it) {
- if (!it->second->GenerateImportFile()) {
+ for (auto& buildExpSet : this->BuildExportSets) {
+ if (!buildExpSet.second->GenerateImportFile()) {
if (!cmSystemTools::GetErrorOccuredFlag()) {
- this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR,
+ this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
"Could not write export file.");
}
return;
@@ -1375,7 +1495,7 @@ void cmGlobalGenerator::Generate()
this->WriteSummary();
- if (this->ExtraGenerator != CM_NULLPTR) {
+ if (this->ExtraGenerator) {
this->ExtraGenerator->Generate();
}
@@ -1384,12 +1504,11 @@ void cmGlobalGenerator::Generate()
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0042) << "\n";
w << "MACOSX_RPATH is not specified for"
" the following targets:\n";
- for (std::set<std::string>::iterator iter =
- this->CMP0042WarnTargets.begin();
- iter != this->CMP0042WarnTargets.end(); ++iter) {
- w << " " << *iter << "\n";
+ for (std::string const& t : this->CMP0042WarnTargets) {
+ w << " " << t << "\n";
}
- this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING,
+ w.str());
}
if (!this->CMP0068WarnTargets.empty()) {
@@ -1402,12 +1521,11 @@ void cmGlobalGenerator::Generate()
"settings:\n"
;
/* clang-format on */
- for (std::set<std::string>::iterator iter =
- this->CMP0068WarnTargets.begin();
- iter != this->CMP0068WarnTargets.end(); ++iter) {
- w << " " << *iter << "\n";
+ for (std::string const& t : this->CMP0068WarnTargets) {
+ w << " " << t << "\n";
}
- this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING,
+ w.str());
}
this->CMakeInstance->UpdateProgress("Generating done", -1);
@@ -1419,69 +1537,46 @@ bool cmGlobalGenerator::ComputeTargetDepends()
if (!ctd.Compute()) {
return false;
}
- std::vector<cmGeneratorTarget const*> const& targets = ctd.GetTargets();
- for (std::vector<cmGeneratorTarget const*>::const_iterator ti =
- targets.begin();
- ti != targets.end(); ++ti) {
- ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]);
+ for (cmGeneratorTarget const* target : ctd.GetTargets()) {
+ ctd.GetTargetDirectDepends(target, this->TargetDependencies[target]);
}
return true;
}
-std::vector<const cmGeneratorTarget*>
-cmGlobalGenerator::CreateQtAutoGeneratorsTargets()
+bool cmGlobalGenerator::QtAutoGen()
{
- std::vector<const cmGeneratorTarget*> autogenTargets;
+#ifndef CMAKE_BOOTSTRAP
+ cmQtAutoGenGlobalInitializer initializer(this->LocalGenerators);
+ return initializer.generate();
+#else
+ return true;
+#endif
+}
-#ifdef CMAKE_BUILD_WITH_CMAKE
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- std::vector<cmGeneratorTarget*> targets =
- this->LocalGenerators[i]->GetGeneratorTargets();
- std::vector<cmGeneratorTarget*> filteredTargets;
- filteredTargets.reserve(targets.size());
- for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- if ((*ti)->GetType() == cmStateEnums::GLOBAL_TARGET) {
- continue;
- }
- if ((*ti)->GetType() != cmStateEnums::EXECUTABLE &&
- (*ti)->GetType() != cmStateEnums::STATIC_LIBRARY &&
- (*ti)->GetType() != cmStateEnums::SHARED_LIBRARY &&
- (*ti)->GetType() != cmStateEnums::MODULE_LIBRARY &&
- (*ti)->GetType() != cmStateEnums::OBJECT_LIBRARY) {
- continue;
- }
- if ((!(*ti)->GetPropertyAsBool("AUTOMOC") &&
- !(*ti)->GetPropertyAsBool("AUTOUIC") &&
- !(*ti)->GetPropertyAsBool("AUTORCC")) ||
- (*ti)->IsImported()) {
- continue;
- }
- // don't do anything if there is no Qt4 or Qt5Core (which contains moc):
- cmMakefile* mf = (*ti)->Target->GetMakefile();
- std::string qtMajorVersion = mf->GetSafeDefinition("QT_VERSION_MAJOR");
- if (qtMajorVersion == "") {
- qtMajorVersion = mf->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
- }
- if (qtMajorVersion != "4" && qtMajorVersion != "5") {
+bool cmGlobalGenerator::AddAutomaticSources()
+{
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
+ lg->CreateEvaluationFileOutputs();
+ for (cmGeneratorTarget* gt : lg->GetGeneratorTargets()) {
+ if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
+ gt->GetType() == cmStateEnums::UTILITY ||
+ gt->GetType() == cmStateEnums::GLOBAL_TARGET) {
continue;
}
-
- cmGeneratorTarget* gt = *ti;
-
- cmQtAutoGeneratorInitializer::InitializeAutogenSources(gt);
- filteredTargets.push_back(gt);
+ lg->AddUnityBuild(gt);
+ lg->AddPchDependencies(gt);
}
- for (std::vector<cmGeneratorTarget*>::iterator ti =
- filteredTargets.begin();
- ti != filteredTargets.end(); ++ti) {
- cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
- this->LocalGenerators[i], *ti);
- autogenTargets.push_back(*ti);
+ }
+ // The above transformations may have changed the classification of sources.
+ // Clear the source list and classification cache (KindedSources) of all
+ // targets so that it will be recomputed correctly by the generators later
+ // now that the above transformations are done for all targets.
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
+ for (cmGeneratorTarget* gt : lg->GetGeneratorTargets()) {
+ gt->ClearSourcesCache();
}
}
-#endif
- return autogenTargets;
+ return true;
}
cmLinkLineComputer* cmGlobalGenerator::CreateLinkLineComputer(
@@ -1502,17 +1597,14 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
this->CMakeInstance->GetState()->GetEnabledLanguages();
// Construct per-target generator information.
- for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
- cmMakefile* mf = this->Makefiles[i];
-
+ for (cmMakefile* mf : this->Makefiles) {
const cmStringRange noconfig_compile_definitions =
mf->GetCompileDefinitionsEntries();
const cmBacktraceRange noconfig_compile_definitions_bts =
mf->GetCompileDefinitionsBacktraces();
- cmTargets& targets = mf->GetTargets();
- for (cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) {
- cmTarget* t = &ti->second;
+ for (auto& target : mf->GetTargets()) {
+ cmTarget* t = &target.second;
if (t->GetType() == cmStateEnums::GLOBAL_TARGET) {
continue;
}
@@ -1523,12 +1615,12 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
continue;
}
- cmBacktraceRange::const_iterator btIt =
- noconfig_compile_definitions_bts.begin();
- for (cmStringRange::const_iterator
- it = noconfig_compile_definitions.begin();
- it != noconfig_compile_definitions.end(); ++it, ++btIt) {
- t->InsertCompileDefinition(*it, *btIt);
+ {
+ auto btIt = noconfig_compile_definitions_bts.begin();
+ auto it = noconfig_compile_definitions.begin();
+ for (; it != noconfig_compile_definitions.end(); ++it, ++btIt) {
+ t->InsertCompileDefinition(*it, *btIt);
+ }
}
cmPolicies::PolicyStatus polSt =
@@ -1537,10 +1629,9 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
std::vector<std::string> configs;
mf->GetConfigurations(configs);
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
- std::string defPropName = "COMPILE_DEFINITIONS_";
- defPropName += cmSystemTools::UpperCase(*ci);
+ for (std::string const& c : configs) {
+ std::string defPropName =
+ cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(c));
t->AppendProperty(defPropName, mf->GetProperty(defPropName));
}
}
@@ -1549,15 +1640,13 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
// The standard include directories for each language
// should be treated as system include directories.
std::set<std::string> standardIncludesSet;
- for (std::vector<std::string>::const_iterator li = langs.begin();
- li != langs.end(); ++li) {
+ for (std::string const& li : langs) {
std::string const standardIncludesVar =
- "CMAKE_" + *li + "_STANDARD_INCLUDE_DIRECTORIES";
- std::string const standardIncludesStr =
+ "CMAKE_" + li + "_STANDARD_INCLUDE_DIRECTORIES";
+ std::string const& standardIncludesStr =
mf->GetSafeDefinition(standardIncludesVar);
- std::vector<std::string> standardIncludesVec;
- cmSystemTools::ExpandListArgument(standardIncludesStr,
- standardIncludesVec);
+ std::vector<std::string> standardIncludesVec =
+ cmExpandedList(standardIncludesStr);
standardIncludesSet.insert(standardIncludesVec.begin(),
standardIncludesVec.end());
}
@@ -1570,19 +1659,15 @@ void cmGlobalGenerator::CreateGeneratorTargets(
std::map<cmTarget*, cmGeneratorTarget*> const& importedMap)
{
if (targetTypes == AllTargets) {
- cmTargets& targets = mf->GetTargets();
- for (cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) {
- cmTarget* t = &ti->second;
+ for (auto& target : mf->GetTargets()) {
+ cmTarget* t = &target.second;
cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg);
lg->AddGeneratorTarget(gt);
}
}
- std::vector<cmTarget*> itgts = mf->GetImportedTargets();
-
- for (std::vector<cmTarget*>::const_iterator j = itgts.begin();
- j != itgts.end(); ++j) {
- lg->AddImportedGeneratorTarget(importedMap.find(*j)->second);
+ for (cmTarget* t : mf->GetImportedTargets()) {
+ lg->AddImportedGeneratorTarget(importedMap.find(t)->second);
}
}
@@ -1591,13 +1676,11 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes)
std::map<cmTarget*, cmGeneratorTarget*> importedMap;
for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
cmMakefile* mf = this->Makefiles[i];
- for (std::vector<cmTarget*>::const_iterator j =
- mf->GetOwnedImportedTargets().begin();
- j != mf->GetOwnedImportedTargets().end(); ++j) {
+ for (cmTarget* ownedImpTgt : mf->GetOwnedImportedTargets()) {
cmLocalGenerator* lg = this->LocalGenerators[i];
- cmGeneratorTarget* gt = new cmGeneratorTarget(*j, lg);
+ cmGeneratorTarget* gt = new cmGeneratorTarget(ownedImpTgt, lg);
lg->AddOwnedImportedGeneratorTarget(gt);
- importedMap[*j] = gt;
+ importedMap[ownedImpTgt] = gt;
}
}
@@ -1619,11 +1702,13 @@ void cmGlobalGenerator::ClearGeneratorMembers()
cmDeleteAll(this->LocalGenerators);
this->LocalGenerators.clear();
+ this->AliasTargets.clear();
this->ExportSets.clear();
this->TargetDependencies.clear();
this->TargetSearchIndex.clear();
this->GeneratorTargetSearchIndex.clear();
this->MakefileSearchIndex.clear();
+ this->LocalGeneratorSearchIndex.clear();
this->ProjectMap.clear();
this->RuleHashes.clear();
this->DirectoryContentMap.clear();
@@ -1643,31 +1728,26 @@ void cmGlobalGenerator::CheckTargetProperties()
cmState* state = this->GetCMakeInstance()->GetState();
for (unsigned int i = 0; i < this->Makefiles.size(); ++i) {
this->Makefiles[i]->ConfigureFinalPass();
- cmTargets& targets = this->Makefiles[i]->GetTargets();
- for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) {
- if (l->second.GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (auto const& target : this->Makefiles[i]->GetTargets()) {
+ if (target.second.GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- const cmTarget::LinkLibraryVectorType& libs =
- l->second.GetOriginalLinkLibraries();
- for (cmTarget::LinkLibraryVectorType::const_iterator lib = libs.begin();
- lib != libs.end(); ++lib) {
- if (lib->first.size() > 9 &&
- cmSystemTools::IsNOTFOUND(lib->first.c_str())) {
- std::string varName = lib->first.substr(0, lib->first.size() - 9);
+ for (auto const& lib : target.second.GetOriginalLinkLibraries()) {
+ if (lib.first.size() > 9 && cmIsNOTFOUND(lib.first)) {
+ std::string varName = lib.first.substr(0, lib.first.size() - 9);
if (state->GetCacheEntryPropertyAsBool(varName, "ADVANCED")) {
varName += " (ADVANCED)";
}
- std::string text = notFoundMap[varName];
- text += "\n linked by target \"";
- text += l->second.GetName();
- text += "\" in directory ";
- text += this->Makefiles[i]->GetCurrentSourceDirectory();
+ std::string text =
+ cmStrCat(notFoundMap[varName], "\n linked by target \"",
+ target.second.GetName(), "\" in directory ",
+ this->Makefiles[i]->GetCurrentSourceDirectory());
notFoundMap[varName] = text;
}
}
std::vector<std::string> incs;
- const char* incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES");
+ const char* incDirProp =
+ target.second.GetProperty("INCLUDE_DIRECTORIES");
if (!incDirProp) {
continue;
}
@@ -1675,46 +1755,45 @@ void cmGlobalGenerator::CheckTargetProperties()
std::string incDirs = cmGeneratorExpression::Preprocess(
incDirProp, cmGeneratorExpression::StripAllGeneratorExpressions);
- cmSystemTools::ExpandListArgument(incDirs, incs);
+ cmExpandList(incDirs, incs);
- for (std::vector<std::string>::const_iterator incDir = incs.begin();
- incDir != incs.end(); ++incDir) {
- if (incDir->size() > 9 && cmSystemTools::IsNOTFOUND(incDir->c_str())) {
- std::string varName = incDir->substr(0, incDir->size() - 9);
+ for (std::string const& incDir : incs) {
+ if (incDir.size() > 9 && cmIsNOTFOUND(incDir)) {
+ std::string varName = incDir.substr(0, incDir.size() - 9);
if (state->GetCacheEntryPropertyAsBool(varName, "ADVANCED")) {
varName += " (ADVANCED)";
}
- std::string text = notFoundMap[varName];
- text += "\n used as include directory in directory ";
- text += this->Makefiles[i]->GetCurrentSourceDirectory();
+ std::string text =
+ cmStrCat(notFoundMap[varName],
+ "\n used as include directory in directory ",
+ this->Makefiles[i]->GetCurrentSourceDirectory());
notFoundMap[varName] = text;
}
}
}
this->CMakeInstance->UpdateProgress(
- "Configuring", 0.9f +
+ "Configuring",
+ 0.9f +
0.1f * (static_cast<float>(i) + 1.0f) /
static_cast<float>(this->Makefiles.size()));
}
if (!notFoundMap.empty()) {
std::string notFoundVars;
- for (std::map<std::string, std::string>::const_iterator ii =
- notFoundMap.begin();
- ii != notFoundMap.end(); ++ii) {
- notFoundVars += ii->first;
- notFoundVars += ii->second;
+ for (auto const& notFound : notFoundMap) {
+ notFoundVars += notFound.first;
+ notFoundVars += notFound.second;
notFoundVars += "\n";
}
cmSystemTools::Error("The following variables are used in this project, "
"but they are set to NOTFOUND.\n"
"Please set them or make sure they are set and "
- "tested correctly in the CMake files:\n",
- notFoundVars.c_str());
+ "tested correctly in the CMake files:\n" +
+ notFoundVars);
}
}
-int cmGlobalGenerator::TryCompile(const std::string& srcdir,
+int cmGlobalGenerator::TryCompile(int jobs, const std::string& srcdir,
const std::string& bindir,
const std::string& projectName,
const std::string& target, bool fast,
@@ -1738,47 +1817,45 @@ int cmGlobalGenerator::TryCompile(const std::string& srcdir,
this->FirstTimeProgress);
}
- std::string newTarget;
+ std::vector<std::string> newTarget = {};
if (!target.empty()) {
- newTarget += target;
-#if 0
-#if defined(_WIN32) || defined(__CYGWIN__)
- std::string tmp = target;
- // if the target does not already end in . something
- // then assume .exe
- if(tmp.size() < 4 || tmp[tmp.size()-4] != '.')
- {
- newTarget += ".exe";
- }
-#endif // WIN32
-#endif
+ newTarget = { target };
}
std::string config =
mf->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
- return this->Build(srcdir, bindir, projectName, newTarget, output, "",
+ return this->Build(jobs, srcdir, bindir, projectName, newTarget, output, "",
config, false, fast, false, this->TryCompileTimeout);
}
-void cmGlobalGenerator::GenerateBuildCommand(
- std::vector<std::string>& makeCommand, const std::string& /*unused*/,
- const std::string& /*unused*/, const std::string& /*unused*/,
+std::vector<cmGlobalGenerator::GeneratedMakeCommand>
+cmGlobalGenerator::GenerateBuildCommand(
const std::string& /*unused*/, const std::string& /*unused*/,
- bool /*unused*/, bool /*unused*/, std::vector<std::string> const& /*unused*/)
+ const std::string& /*unused*/, std::vector<std::string> const& /*unused*/,
+ const std::string& /*unused*/, bool /*unused*/, int /*unused*/,
+ bool /*unused*/, std::vector<std::string> const& /*unused*/)
{
- makeCommand.push_back(
- "cmGlobalGenerator::GenerateBuildCommand not implemented");
+ GeneratedMakeCommand makeCommand;
+ makeCommand.Add("cmGlobalGenerator::GenerateBuildCommand not implemented");
+ return { std::move(makeCommand) };
}
-int cmGlobalGenerator::Build(const std::string& /*unused*/,
- const std::string& bindir,
- const std::string& projectName,
- const std::string& target, std::string& output,
- const std::string& makeCommandCSTR,
- const std::string& config, bool clean, bool fast,
- bool verbose, double timeout,
- cmSystemTools::OutputOption outputflag,
- std::vector<std::string> const& nativeOptions)
+void cmGlobalGenerator::PrintBuildCommandAdvice(std::ostream& /*os*/,
+ int /*jobs*/) const
{
+ // Subclasses override this method if they e.g want to give a warning that
+ // they do not support certain build command line options
+}
+
+int cmGlobalGenerator::Build(
+ int jobs, const std::string& /*unused*/, const std::string& bindir,
+ const std::string& projectName, const std::vector<std::string>& targets,
+ std::string& output, const std::string& makeCommandCSTR,
+ const std::string& config, bool clean, bool fast, bool verbose,
+ cmDuration timeout, cmSystemTools::OutputOption outputflag,
+ std::vector<std::string> const& nativeOptions)
+{
+ bool hideconsole = cmSystemTools::GetRunCommandHideConsole();
+
/**
* Run an executable command and put the stdout in output.
*/
@@ -1786,37 +1863,49 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/,
output += "Change Dir: ";
output += bindir;
output += "\n";
+ if (workdir.Failed()) {
+ cmSystemTools::SetRunCommandHideConsole(hideconsole);
+ std::string err = cmStrCat("Failed to change directory: ",
+ std::strerror(workdir.GetLastResult()));
+ cmSystemTools::Error(err);
+ output += err;
+ output += "\n";
+ return 1;
+ }
- int retVal;
- bool hideconsole = cmSystemTools::GetRunCommandHideConsole();
+ int retVal = 0;
cmSystemTools::SetRunCommandHideConsole(true);
std::string outputBuffer;
std::string* outputPtr = &outputBuffer;
- std::vector<std::string> makeCommand;
- this->GenerateBuildCommand(makeCommand, makeCommandCSTR, projectName, bindir,
- target, config, fast, verbose, nativeOptions);
+ std::vector<GeneratedMakeCommand> makeCommand =
+ this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir, targets,
+ config, fast, jobs, verbose, nativeOptions);
- // Workaround to convince VCExpress.exe to produce output.
+ // Workaround to convince some commands to produce output.
if (outputflag == cmSystemTools::OUTPUT_PASSTHROUGH &&
- !makeCommand.empty() &&
- cmSystemTools::LowerCase(
- cmSystemTools::GetFilenameName(makeCommand[0])) == "vcexpress.exe") {
+ makeCommand.back().RequiresOutputForward) {
outputflag = cmSystemTools::OUTPUT_FORWARD;
}
// should we do a clean first?
if (clean) {
- std::vector<std::string> cleanCommand;
- this->GenerateBuildCommand(cleanCommand, makeCommandCSTR, projectName,
- bindir, "clean", config, fast, verbose);
+ std::vector<GeneratedMakeCommand> cleanCommand =
+ this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir,
+ { "clean" }, config, fast, jobs, verbose);
output += "\nRun Clean Command:";
- output += cmSystemTools::PrintSingleCommand(cleanCommand);
+ output += cleanCommand.front().Printable();
output += "\n";
-
- if (!cmSystemTools::RunSingleCommand(cleanCommand, outputPtr, outputPtr,
- &retVal, CM_NULLPTR, outputflag,
- timeout)) {
+ if (cleanCommand.size() != 1) {
+ this->GetCMakeInstance()->IssueMessage(MessageType::INTERNAL_ERROR,
+ "The generator did not produce "
+ "exactly one command for the "
+ "'clean' target");
+ return 1;
+ }
+ if (!cmSystemTools::RunSingleCommand(cleanCommand.front().PrimaryCommand,
+ outputPtr, outputPtr, &retVal,
+ nullptr, outputflag, timeout)) {
cmSystemTools::SetRunCommandHideConsole(hideconsole);
cmSystemTools::Error("Generator: execution of make clean failed.");
output += *outputPtr;
@@ -1828,44 +1917,62 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/,
}
// now build
- std::string makeCommandStr = cmSystemTools::PrintSingleCommand(makeCommand);
- output += "\nRun Build Command:";
- output += makeCommandStr;
- output += "\n";
+ std::string makeCommandStr;
+ output += "\nRun Build Command(s):";
- if (!cmSystemTools::RunSingleCommand(makeCommand, outputPtr, outputPtr,
- &retVal, CM_NULLPTR, outputflag,
- timeout)) {
- cmSystemTools::SetRunCommandHideConsole(hideconsole);
- cmSystemTools::Error(
- "Generator: execution of make failed. Make command was: ",
- makeCommandStr.c_str());
- output += *outputPtr;
- output += "\nGenerator: execution of make failed. Make command was: " +
- makeCommandStr + "\n";
+ for (auto command = makeCommand.begin(); command != makeCommand.end();
+ ++command) {
+ makeCommandStr = command->Printable();
+ if (command != makeCommand.end()) {
+ makeCommandStr += " && ";
+ }
- return 1;
+ output += makeCommandStr;
+ if (!cmSystemTools::RunSingleCommand(command->PrimaryCommand, outputPtr,
+ outputPtr, &retVal, nullptr,
+ outputflag, timeout)) {
+ cmSystemTools::SetRunCommandHideConsole(hideconsole);
+ cmSystemTools::Error(
+ "Generator: execution of make failed. Make command was: " +
+ makeCommandStr);
+ output += *outputPtr;
+ output += "\nGenerator: execution of make failed. Make command was: " +
+ makeCommandStr + "\n";
+
+ return 1;
+ }
+ output += *outputPtr;
}
- output += *outputPtr;
+ output += "\n";
cmSystemTools::SetRunCommandHideConsole(hideconsole);
- // The SGI MipsPro 7.3 compiler does not return an error code when
- // the source has a #error in it! This is a work-around for such
- // compilers.
- if ((retVal == 0) && (output.find("#error") != std::string::npos)) {
+ // The OpenWatcom tools do not return an error code when a link
+ // library is not found!
+ if (this->CMakeInstance->GetState()->UseWatcomWMake() && retVal == 0 &&
+ output.find("W1008: cannot open") != std::string::npos) {
retVal = 1;
}
return retVal;
}
+bool cmGlobalGenerator::Open(const std::string& bindir,
+ const std::string& projectName, bool dryRun)
+{
+ if (this->ExtraGenerator) {
+ return this->ExtraGenerator->Open(bindir, projectName, dryRun);
+ }
+
+ return false;
+}
+
std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
const std::string& target, const std::string& config,
const std::string& native, bool ignoreErrors)
{
std::string makeCommand = cmSystemTools::GetCMakeCommand();
- makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
- makeCommand += " --build .";
+ makeCommand =
+ cmStrCat(cmSystemTools::ConvertToOutputPath(makeCommand), " --build .");
if (!config.empty()) {
makeCommand += " --config \"";
makeCommand += config;
@@ -1899,7 +2006,7 @@ void cmGlobalGenerator::AddMakefile(cmMakefile* mf)
// update progress
// estimate how many lg there will be
- const char* numGenC =
+ const std::string* numGenC =
this->CMakeInstance->GetState()->GetInitializedCacheValue(
"CMAKE_NUMBER_OF_MAKEFILES");
@@ -1917,7 +2024,7 @@ void cmGlobalGenerator::AddMakefile(cmMakefile* mf)
return;
}
- int numGen = atoi(numGenC);
+ int numGen = atoi(numGenC->c_str());
float prog = 0.9f * static_cast<float>(this->Makefiles.size()) /
static_cast<float>(numGen);
if (prog > 0.9f) {
@@ -1926,9 +2033,9 @@ void cmGlobalGenerator::AddMakefile(cmMakefile* mf)
this->CMakeInstance->UpdateProgress("Configuring", prog);
}
-void cmGlobalGenerator::AddInstallComponent(const char* component)
+void cmGlobalGenerator::AddInstallComponent(const std::string& component)
{
- if (component && *component) {
+ if (!component.empty()) {
this->InstallComponents.insert(component);
}
}
@@ -1968,8 +2075,8 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen)
if (!gen->ConfiguredFilesPath.empty()) {
this->ConfiguredFilesPath = gen->ConfiguredFilesPath;
} else {
- this->ConfiguredFilesPath = gen->CMakeInstance->GetHomeOutputDirectory();
- this->ConfiguredFilesPath += cmake::GetCMakeFilesDirectory();
+ this->ConfiguredFilesPath =
+ cmStrCat(gen->CMakeInstance->GetHomeOutputDirectory(), "/CMakeFiles");
}
}
@@ -2006,11 +2113,12 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
cmGeneratorTarget* target) const
{
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
- target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
- // This target is excluded from its directory.
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
return true;
}
+ if (const char* exclude = target->GetProperty("EXCLUDE_FROM_ALL")) {
+ return cmIsOn(exclude);
+ }
// This target is included in its directory. Check whether the
// directory is excluded.
return this->IsExcluded(root, target->GetLocalGenerator());
@@ -2024,8 +2132,7 @@ void cmGlobalGenerator::GetEnabledLanguages(
int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const
{
- std::map<std::string, int>::const_iterator it =
- this->LanguageToLinkerPreference.find(lang);
+ auto const it = this->LanguageToLinkerPreference.find(lang);
if (it != this->LanguageToLinkerPreference.end()) {
return it->second;
}
@@ -2035,16 +2142,15 @@ int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const
void cmGlobalGenerator::FillProjectMap()
{
this->ProjectMap.clear(); // make sure we start with a clean map
- unsigned int i;
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
// for each local generator add all projects
- cmStateSnapshot snp = this->LocalGenerators[i]->GetStateSnapshot();
+ cmStateSnapshot snp = localGen->GetStateSnapshot();
std::string name;
do {
std::string snpProjName = snp.GetProjectName();
if (name != snpProjName) {
name = snpProjName;
- this->ProjectMap[name].push_back(this->LocalGenerators[i]);
+ this->ProjectMap[name].push_back(localGen);
}
snp = snp.GetBuildsystemDirectoryParent();
} while (snp.IsValid());
@@ -2053,26 +2159,21 @@ void cmGlobalGenerator::FillProjectMap()
cmMakefile* cmGlobalGenerator::FindMakefile(const std::string& start_dir) const
{
- MakefileMap::const_iterator i = this->MakefileSearchIndex.find(start_dir);
- if (i != this->MakefileSearchIndex.end()) {
- return i->second;
+ auto const it = this->MakefileSearchIndex.find(start_dir);
+ if (it != this->MakefileSearchIndex.end()) {
+ return it->second;
}
- return CM_NULLPTR;
+ return nullptr;
}
-///! Find a local generator by its startdirectory
cmLocalGenerator* cmGlobalGenerator::FindLocalGenerator(
- const std::string& start_dir) const
+ cmDirectoryId const& id) const
{
- for (std::vector<cmLocalGenerator*>::const_iterator it =
- this->LocalGenerators.begin();
- it != this->LocalGenerators.end(); ++it) {
- std::string sd = (*it)->GetCurrentSourceDirectory();
- if (sd == start_dir) {
- return *it;
- }
+ auto const it = this->LocalGeneratorSearchIndex.find(id.String);
+ if (it != this->LocalGeneratorSearchIndex.end()) {
+ return it->second;
}
- return CM_NULLPTR;
+ return nullptr;
}
void cmGlobalGenerator::AddAlias(const std::string& name,
@@ -2083,7 +2184,7 @@ void cmGlobalGenerator::AddAlias(const std::string& name,
bool cmGlobalGenerator::IsAlias(const std::string& name) const
{
- return this->AliasTargets.find(name) != this->AliasTargets.end();
+ return cmContains(this->AliasTargets, name);
}
void cmGlobalGenerator::IndexTarget(cmTarget* t)
@@ -2100,6 +2201,31 @@ void cmGlobalGenerator::IndexGeneratorTarget(cmGeneratorTarget* gt)
}
}
+static char const hexDigits[] = "0123456789abcdef";
+
+std::string cmGlobalGenerator::IndexGeneratorTargetUniquely(
+ cmGeneratorTarget const* gt)
+{
+ // Use the pointer value to uniquely identify the target instance.
+ // Use a ":" prefix to avoid conflict with project-defined targets.
+ // We must satisfy cmGeneratorExpression::IsValidTargetName so use no
+ // other special characters.
+ char buf[1 + sizeof(gt) * 2];
+ char* b = buf;
+ *b++ = ':';
+ for (size_t i = 0; i < sizeof(gt); ++i) {
+ unsigned char const c = reinterpret_cast<unsigned char const*>(&gt)[i];
+ *b++ = hexDigits[(c & 0xf0) >> 4];
+ *b++ = hexDigits[(c & 0x0f)];
+ }
+ std::string id(buf, sizeof(buf));
+ // We internally index pointers to non-const generator targets
+ // but our callers only have pointers to const generator targets.
+ // They will give up non-const privileges when looking up anyway.
+ this->GeneratorTargetSearchIndex[id] = const_cast<cmGeneratorTarget*>(gt);
+ return id;
+}
+
void cmGlobalGenerator::IndexMakefile(cmMakefile* mf)
{
// FIXME: add_subdirectory supports multiple build directories
@@ -2111,32 +2237,36 @@ void cmGlobalGenerator::IndexMakefile(cmMakefile* mf)
MakefileMap::value_type(mf->GetCurrentSourceDirectory(), mf));
}
+void cmGlobalGenerator::IndexLocalGenerator(cmLocalGenerator* lg)
+{
+ cmDirectoryId id = lg->GetMakefile()->GetDirectoryId();
+ this->LocalGeneratorSearchIndex[id.String] = lg;
+}
+
cmTarget* cmGlobalGenerator::FindTargetImpl(std::string const& name) const
{
- TargetMap::const_iterator i = this->TargetSearchIndex.find(name);
- if (i != this->TargetSearchIndex.end()) {
- return i->second;
+ auto const it = this->TargetSearchIndex.find(name);
+ if (it != this->TargetSearchIndex.end()) {
+ return it->second;
}
- return CM_NULLPTR;
+ return nullptr;
}
cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTargetImpl(
std::string const& name) const
{
- GeneratorTargetMap::const_iterator i =
- this->GeneratorTargetSearchIndex.find(name);
- if (i != this->GeneratorTargetSearchIndex.end()) {
- return i->second;
+ auto const it = this->GeneratorTargetSearchIndex.find(name);
+ if (it != this->GeneratorTargetSearchIndex.end()) {
+ return it->second;
}
- return CM_NULLPTR;
+ return nullptr;
}
cmTarget* cmGlobalGenerator::FindTarget(const std::string& name,
bool excludeAliases) const
{
if (!excludeAliases) {
- std::map<std::string, std::string>::const_iterator ai =
- this->AliasTargets.find(name);
+ auto const ai = this->AliasTargets.find(name);
if (ai != this->AliasTargets.end()) {
return this->FindTargetImpl(ai->second);
}
@@ -2147,8 +2277,7 @@ cmTarget* cmGlobalGenerator::FindTarget(const std::string& name,
cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTarget(
const std::string& name) const
{
- std::map<std::string, std::string>::const_iterator ai =
- this->AliasTargets.find(name);
+ auto const ai = this->AliasTargets.find(name);
if (ai != this->AliasTargets.end()) {
return this->FindGeneratorTargetImpl(ai->second);
}
@@ -2158,7 +2287,7 @@ cmGeneratorTarget* cmGlobalGenerator::FindGeneratorTarget(
bool cmGlobalGenerator::NameResolvesToFramework(
const std::string& libname) const
{
- if (cmSystemTools::IsPathToFramework(libname.c_str())) {
+ if (cmSystemTools::IsPathToFramework(libname)) {
return true;
}
@@ -2171,12 +2300,43 @@ bool cmGlobalGenerator::NameResolvesToFramework(
return false;
}
-inline std::string removeQuotes(const std::string& s)
+bool cmGlobalGenerator::CheckCMP0037(std::string const& targetName,
+ std::string const& reason) const
{
- if (s[0] == '\"' && s[s.size() - 1] == '\"') {
- return s.substr(1, s.size() - 2);
+ cmTarget* tgt = this->FindTarget(targetName);
+ if (!tgt) {
+ return true;
+ }
+ MessageType messageType = MessageType::AUTHOR_WARNING;
+ std::ostringstream e;
+ bool issueMessage = false;
+ switch (tgt->GetPolicyStatusCMP0037()) {
+ case cmPolicies::WARN:
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
+ issueMessage = true;
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::NEW:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ issueMessage = true;
+ messageType = MessageType::FATAL_ERROR;
+ break;
+ }
+ if (issueMessage) {
+ e << "The target name \"" << targetName << "\" is reserved " << reason
+ << ".";
+ if (messageType == MessageType::AUTHOR_WARNING) {
+ e << " It may result in undefined behavior.";
+ }
+ this->GetCMakeInstance()->IssueMessage(messageType, e.str(),
+ tgt->GetBacktrace());
+ if (messageType == MessageType::FATAL_ERROR) {
+ return false;
+ }
}
- return s;
+ return true;
}
void cmGlobalGenerator::CreateDefaultGlobalTargets(
@@ -2194,6 +2354,19 @@ void cmGlobalGenerator::AddGlobalTarget_Package(
std::vector<GlobalTargetInfo>& targets)
{
cmMakefile* mf = this->Makefiles[0];
+ std::string configFile =
+ cmStrCat(mf->GetCurrentBinaryDirectory(), "/CPackConfig.cmake");
+ if (!cmSystemTools::FileExists(configFile)) {
+ return;
+ }
+
+ static const auto reservedTargets = { "package", "PACKAGE" };
+ for (auto const& target : reservedTargets) {
+ if (!this->CheckCMP0037(target, "when CPack packaging is enabled")) {
+ return;
+ }
+ }
+
const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir();
GlobalTargetInfo gti;
gti.Name = this->GetPackageTargetName();
@@ -2207,125 +2380,141 @@ void cmGlobalGenerator::AddGlobalTarget_Package(
singleLine.push_back(cmakeCfgIntDir);
}
singleLine.push_back("--config");
- std::string configFile = mf->GetCurrentBinaryDirectory();
- configFile += "/CPackConfig.cmake";
- std::string relConfigFile = "./CPackConfig.cmake";
- singleLine.push_back(relConfigFile);
- gti.CommandLines.push_back(singleLine);
+ singleLine.push_back("./CPackConfig.cmake");
+ gti.CommandLines.push_back(std::move(singleLine));
if (this->GetPreinstallTargetName()) {
- gti.Depends.push_back(this->GetPreinstallTargetName());
+ gti.Depends.emplace_back(this->GetPreinstallTargetName());
} else {
const char* noPackageAll =
mf->GetDefinition("CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY");
- if (!noPackageAll || cmSystemTools::IsOff(noPackageAll)) {
- gti.Depends.push_back(this->GetAllTargetName());
+ if (!noPackageAll || cmIsOff(noPackageAll)) {
+ gti.Depends.emplace_back(this->GetAllTargetName());
}
}
- if (cmSystemTools::FileExists(configFile.c_str())) {
- targets.push_back(gti);
- }
+ targets.push_back(std::move(gti));
}
void cmGlobalGenerator::AddGlobalTarget_PackageSource(
std::vector<GlobalTargetInfo>& targets)
{
- cmMakefile* mf = this->Makefiles[0];
const char* packageSourceTargetName = this->GetPackageSourceTargetName();
- if (packageSourceTargetName) {
- GlobalTargetInfo gti;
- gti.Name = packageSourceTargetName;
- gti.Message = "Run CPack packaging tool for source...";
- gti.WorkingDir = mf->GetCurrentBinaryDirectory();
- gti.UsesTerminal = true;
- cmCustomCommandLine singleLine;
- singleLine.push_back(cmSystemTools::GetCPackCommand());
- singleLine.push_back("--config");
- std::string configFile = mf->GetCurrentBinaryDirectory();
- configFile += "/CPackSourceConfig.cmake";
- std::string relConfigFile = "./CPackSourceConfig.cmake";
- singleLine.push_back(relConfigFile);
- if (cmSystemTools::FileExists(configFile.c_str())) {
- singleLine.push_back(configFile);
- gti.CommandLines.push_back(singleLine);
- targets.push_back(gti);
+ if (!packageSourceTargetName) {
+ return;
+ }
+
+ cmMakefile* mf = this->Makefiles[0];
+ std::string configFile =
+ cmStrCat(mf->GetCurrentBinaryDirectory(), "/CPackSourceConfig.cmake");
+ if (!cmSystemTools::FileExists(configFile)) {
+ return;
+ }
+
+ static const auto reservedTargets = { "package_source" };
+ for (auto const& target : reservedTargets) {
+ if (!this->CheckCMP0037(target,
+ "when CPack source packaging is enabled")) {
+ return;
}
}
+
+ GlobalTargetInfo gti;
+ gti.Name = packageSourceTargetName;
+ gti.Message = "Run CPack packaging tool for source...";
+ gti.WorkingDir = mf->GetCurrentBinaryDirectory();
+ gti.UsesTerminal = true;
+ cmCustomCommandLine singleLine;
+ singleLine.push_back(cmSystemTools::GetCPackCommand());
+ singleLine.push_back("--config");
+ singleLine.push_back("./CPackSourceConfig.cmake");
+ singleLine.push_back(std::move(configFile));
+ gti.CommandLines.push_back(std::move(singleLine));
+ targets.push_back(std::move(gti));
}
void cmGlobalGenerator::AddGlobalTarget_Test(
std::vector<GlobalTargetInfo>& targets)
{
cmMakefile* mf = this->Makefiles[0];
- const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir();
- if (mf->IsOn("CMAKE_TESTING_ENABLED")) {
- GlobalTargetInfo gti;
- gti.Name = this->GetTestTargetName();
- gti.Message = "Running tests...";
- gti.UsesTerminal = true;
- cmCustomCommandLine singleLine;
- singleLine.push_back(cmSystemTools::GetCTestCommand());
- singleLine.push_back("--force-new-ctest-process");
- if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') {
- singleLine.push_back("-C");
- singleLine.push_back(cmakeCfgIntDir);
- } else // TODO: This is a hack. Should be something to do with the
- // generator
- {
- singleLine.push_back("$(ARGS)");
+ if (!mf->IsOn("CMAKE_TESTING_ENABLED")) {
+ return;
+ }
+
+ static const auto reservedTargets = { "test", "RUN_TESTS" };
+ for (auto const& target : reservedTargets) {
+ if (!this->CheckCMP0037(target, "when CTest testing is enabled")) {
+ return;
}
- gti.CommandLines.push_back(singleLine);
- targets.push_back(gti);
}
+
+ const char* cmakeCfgIntDir = this->GetCMakeCFGIntDir();
+ GlobalTargetInfo gti;
+ gti.Name = this->GetTestTargetName();
+ gti.Message = "Running tests...";
+ gti.UsesTerminal = true;
+ cmCustomCommandLine singleLine;
+ singleLine.push_back(cmSystemTools::GetCTestCommand());
+ singleLine.push_back("--force-new-ctest-process");
+ if (cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.') {
+ singleLine.push_back("-C");
+ singleLine.push_back(cmakeCfgIntDir);
+ } else // TODO: This is a hack. Should be something to do with the
+ // generator
+ {
+ singleLine.push_back("$(ARGS)");
+ }
+ gti.CommandLines.push_back(std::move(singleLine));
+ targets.push_back(std::move(gti));
}
void cmGlobalGenerator::AddGlobalTarget_EditCache(
std::vector<GlobalTargetInfo>& targets)
{
const char* editCacheTargetName = this->GetEditCacheTargetName();
- if (editCacheTargetName) {
- GlobalTargetInfo gti;
- gti.Name = editCacheTargetName;
- cmCustomCommandLine singleLine;
-
- // Use generator preference for the edit_cache rule if it is defined.
- std::string edit_cmd = this->GetEditCacheCommand();
- if (!edit_cmd.empty()) {
- singleLine.push_back(edit_cmd);
- singleLine.push_back("-H$(CMAKE_SOURCE_DIR)");
- singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
- gti.Message = "Running CMake cache editor...";
- gti.UsesTerminal = true;
- gti.CommandLines.push_back(singleLine);
- } else {
- singleLine.push_back(cmSystemTools::GetCMakeCommand());
- singleLine.push_back("-E");
- singleLine.push_back("echo");
- singleLine.push_back("No interactive CMake dialog available.");
- gti.Message = "No interactive CMake dialog available...";
- gti.UsesTerminal = false;
- gti.CommandLines.push_back(singleLine);
- }
+ if (!editCacheTargetName) {
+ return;
+ }
+ GlobalTargetInfo gti;
+ gti.Name = editCacheTargetName;
+ cmCustomCommandLine singleLine;
- targets.push_back(gti);
+ // Use generator preference for the edit_cache rule if it is defined.
+ std::string edit_cmd = this->GetEditCacheCommand();
+ if (!edit_cmd.empty()) {
+ singleLine.push_back(std::move(edit_cmd));
+ singleLine.push_back("-S$(CMAKE_SOURCE_DIR)");
+ singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
+ gti.Message = "Running CMake cache editor...";
+ gti.UsesTerminal = true;
+ } else {
+ singleLine.push_back(cmSystemTools::GetCMakeCommand());
+ singleLine.push_back("-E");
+ singleLine.push_back("echo");
+ singleLine.push_back("No interactive CMake dialog available.");
+ gti.Message = "No interactive CMake dialog available...";
+ gti.UsesTerminal = false;
}
+ gti.CommandLines.push_back(std::move(singleLine));
+
+ targets.push_back(std::move(gti));
}
void cmGlobalGenerator::AddGlobalTarget_RebuildCache(
std::vector<GlobalTargetInfo>& targets)
{
const char* rebuildCacheTargetName = this->GetRebuildCacheTargetName();
- if (rebuildCacheTargetName) {
- GlobalTargetInfo gti;
- gti.Name = rebuildCacheTargetName;
- gti.Message = "Running CMake to regenerate build system...";
- gti.UsesTerminal = true;
- cmCustomCommandLine singleLine;
- singleLine.push_back(cmSystemTools::GetCMakeCommand());
- singleLine.push_back("-H$(CMAKE_SOURCE_DIR)");
- singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
- gti.CommandLines.push_back(singleLine);
- targets.push_back(gti);
+ if (!rebuildCacheTargetName) {
+ return;
}
+ GlobalTargetInfo gti;
+ gti.Name = rebuildCacheTargetName;
+ gti.Message = "Running CMake to regenerate build system...";
+ gti.UsesTerminal = true;
+ cmCustomCommandLine singleLine;
+ singleLine.push_back(cmSystemTools::GetCMakeCommand());
+ singleLine.push_back("-S$(CMAKE_SOURCE_DIR)");
+ singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
+ gti.CommandLines.push_back(std::move(singleLine));
+ targets.push_back(std::move(gti));
}
void cmGlobalGenerator::AddGlobalTarget_Install(
@@ -2336,8 +2525,9 @@ void cmGlobalGenerator::AddGlobalTarget_Install(
bool skipInstallRules = mf->IsOn("CMAKE_SKIP_INSTALL_RULES");
if (this->InstallTargetEnabled && skipInstallRules) {
this->CMakeInstance->IssueMessage(
- cmake::WARNING, "CMAKE_SKIP_INSTALL_RULES was enabled even though "
- "installation rules have been specified",
+ MessageType::WARNING,
+ "CMAKE_SKIP_INSTALL_RULES was enabled even though "
+ "installation rules have been specified",
mf->GetBacktrace());
} else if (this->InstallTargetEnabled && !skipInstallRules) {
if (!cmakeCfgIntDir || !*cmakeCfgIntDir || cmakeCfgIntDir[0] == '.') {
@@ -2353,7 +2543,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install(
gti.Name = "list_install_components";
gti.Message = ostr.str();
gti.UsesTerminal = false;
- targets.push_back(gti);
+ targets.push_back(std::move(gti));
}
std::string cmd = cmSystemTools::GetCMakeCommand();
GlobalTargetInfo gti;
@@ -2362,12 +2552,12 @@ void cmGlobalGenerator::AddGlobalTarget_Install(
gti.UsesTerminal = true;
cmCustomCommandLine singleLine;
if (this->GetPreinstallTargetName()) {
- gti.Depends.push_back(this->GetPreinstallTargetName());
+ gti.Depends.emplace_back(this->GetPreinstallTargetName());
} else {
const char* noall =
mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
- if (!noall || cmSystemTools::IsOff(noall)) {
- gti.Depends.push_back(this->GetAllTargetName());
+ if (!noall || cmIsOff(noall)) {
+ gti.Depends.emplace_back(this->GetAllTargetName());
}
}
if (mf->GetDefinition("CMake_BINARY_DIR") &&
@@ -2407,13 +2597,13 @@ void cmGlobalGenerator::AddGlobalTarget_Install(
localCmdLine.insert(localCmdLine.begin() + 1,
"-DCMAKE_INSTALL_LOCAL_ONLY=1");
- gti.CommandLines.push_back(localCmdLine);
+ gti.CommandLines.push_back(std::move(localCmdLine));
targets.push_back(gti);
}
// install_strip
const char* install_strip = this->GetInstallStripTargetName();
- if ((install_strip != CM_NULLPTR) && (mf->IsSet("CMAKE_STRIP"))) {
+ if ((install_strip != nullptr) && (mf->IsSet("CMAKE_STRIP"))) {
gti.Name = install_strip;
gti.Message = "Installing the project stripped...";
gti.UsesTerminal = true;
@@ -2423,7 +2613,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install(
stripCmdLine.insert(stripCmdLine.begin() + 1,
"-DCMAKE_INSTALL_DO_STRIP=1");
- gti.CommandLines.push_back(stripCmdLine);
+ gti.CommandLines.push_back(std::move(stripCmdLine));
targets.push_back(gti);
}
}
@@ -2449,7 +2639,7 @@ bool cmGlobalGenerator::UseFolderProperty() const
// If this property is defined, let the setter turn this on or off...
//
if (prop) {
- return cmSystemTools::IsOn(prop);
+ return cmIsOn(prop);
}
// By default, this feature is OFF, since it is not supported in the
@@ -2470,16 +2660,15 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti,
std::vector<std::string> no_byproducts;
std::vector<std::string> no_depends;
// Store the custom command in the target.
- cmCustomCommand cc(CM_NULLPTR, no_outputs, no_byproducts, no_depends,
- gti.CommandLines, CM_NULLPTR, gti.WorkingDir.c_str());
+ cmCustomCommand cc(nullptr, no_outputs, no_byproducts, no_depends,
+ gti.CommandLines, nullptr, gti.WorkingDir.c_str());
cc.SetUsesTerminal(gti.UsesTerminal);
- target.AddPostBuildCommand(cc);
+ target.AddPostBuildCommand(std::move(cc));
if (!gti.Message.empty()) {
target.SetProperty("EchoString", gti.Message.c_str());
}
- for (std::vector<std::string>::const_iterator dit = gti.Depends.begin();
- dit != gti.Depends.end(); ++dit) {
- target.AddUtility(*dit);
+ for (std::string const& d : gti.Depends) {
+ target.AddUtility(d);
}
// Organize in the "predefined targets" folder:
@@ -2494,26 +2683,23 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti,
std::string cmGlobalGenerator::GenerateRuleFile(
std::string const& output) const
{
- std::string ruleFile = output;
- ruleFile += ".rule";
+ std::string ruleFile = cmStrCat(output, ".rule");
const char* dir = this->GetCMakeCFGIntDir();
if (dir && dir[0] == '$') {
- cmSystemTools::ReplaceString(ruleFile, dir,
- cmake::GetCMakeFilesDirectory());
+ cmSystemTools::ReplaceString(ruleFile, dir, "/CMakeFiles");
}
return ruleFile;
}
bool cmGlobalGenerator::ShouldStripResourcePath(cmMakefile* mf) const
{
- return mf->PlatformIsAppleIos();
+ return mf->PlatformIsAppleEmbedded();
}
std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage(
std::string const& l) const
{
- std::map<std::string, std::string>::const_iterator it =
- this->LanguageToOriginalSharedLibFlags.find(l);
+ auto const it = this->LanguageToOriginalSharedLibFlags.find(l);
if (it != this->LanguageToOriginalSharedLibFlags.end()) {
return it->second;
}
@@ -2542,21 +2728,19 @@ bool cmGlobalGenerator::IsReservedTarget(std::string const& name)
// by one or more of the cmake generators.
// Adding additional targets to this list will require a policy!
- const char* reservedTargets[] = {
- "all", "ALL_BUILD", "help", "install", "INSTALL",
- "preinstall", "clean", "edit_cache", "rebuild_cache", "test",
- "RUN_TESTS", "package", "PACKAGE", "package_source", "ZERO_CHECK"
- };
+ const char* reservedTargets[] = { "all", "ALL_BUILD", "help",
+ "install", "INSTALL", "preinstall",
+ "clean", "edit_cache", "rebuild_cache",
+ "ZERO_CHECK" };
- return std::find(cmArrayBegin(reservedTargets), cmArrayEnd(reservedTargets),
- name) != cmArrayEnd(reservedTargets);
+ return cmContains(reservedTargets, name);
}
void cmGlobalGenerator::SetExternalMakefileProjectGenerator(
cmExternalMakefileProjectGenerator* extraGenerator)
{
- this->ExtraGenerator = extraGenerator;
- if (this->ExtraGenerator != CM_NULLPTR) {
+ this->ExtraGenerator.reset(extraGenerator);
+ if (this->ExtraGenerator) {
this->ExtraGenerator->SetGlobalGenerator(this);
}
}
@@ -2587,18 +2771,13 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets,
GeneratorVector const& generators)
{
// loop over all local generators
- for (std::vector<cmLocalGenerator*>::const_iterator i = generators.begin();
- i != generators.end(); ++i) {
+ for (cmLocalGenerator* generator : generators) {
// check to make sure generator is not excluded
- if (this->IsExcluded(root, *i)) {
+ if (this->IsExcluded(root, generator)) {
continue;
}
- // Get the targets in the makefile
- std::vector<cmGeneratorTarget*> tgts = (*i)->GetGeneratorTargets();
- // loop over all the targets
- for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); ++l) {
- cmGeneratorTarget* target = *l;
+ // loop over all the generator targets in the makefile
+ for (cmGeneratorTarget* target : generator->GetGeneratorTargets()) {
if (this->IsRootOnlyTarget(target) &&
target->GetLocalGenerator() != root) {
continue;
@@ -2624,9 +2803,8 @@ void cmGlobalGenerator::AddTargetDepends(cmGeneratorTarget const* target,
if (projectTargets.insert(target).second) {
// This is the first time we have encountered the target.
// Recursively follow its dependencies.
- TargetDependSet const& ts = this->GetTargetDirectDepends(target);
- for (TargetDependSet::const_iterator i = ts.begin(); i != ts.end(); ++i) {
- this->AddTargetDepends(*i, projectTargets);
+ for (auto const& t : this->GetTargetDirectDepends(target)) {
+ this->AddTargetDepends(t, projectTargets);
}
}
}
@@ -2671,7 +2849,7 @@ std::set<std::string> const& cmGlobalGenerator::GetDirectoryContent(
void cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs,
std::string const& content)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
// Ignore if there are no outputs.
if (outputs.empty()) {
return;
@@ -2686,8 +2864,9 @@ void cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs,
}
// Shorten the output name (in expected use case).
- cmOutputConverter converter(this->GetMakefiles()[0]->GetStateSnapshot());
- std::string fname = converter.ConvertToRelativePath(
+ cmStateDirectory cmDir =
+ this->GetMakefiles()[0]->GetStateSnapshot().GetDirectory();
+ std::string fname = cmDir.ConvertToRelPathIfNotContained(
this->GetMakefiles()[0]->GetState()->GetBinaryDirectory(), outputs[0]);
// Associate the hash with this output.
@@ -2700,11 +2879,9 @@ void cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs,
void cmGlobalGenerator::CheckRuleHashes()
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
std::string home = this->GetCMakeInstance()->GetHomeOutputDirectory();
- std::string pfile = home;
- pfile += this->GetCMakeInstance()->GetCMakeFilesDirectory();
- pfile += "/CMakeRuleHashes.txt";
+ std::string pfile = cmStrCat(home, "/CMakeFiles/CMakeRuleHashes.txt");
this->CheckRuleHashes(pfile, home);
this->WriteRuleHashes(pfile);
#endif
@@ -2736,14 +2913,13 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
fname = line.substr(33);
// Look for a hash for this file's rule.
- std::map<std::string, RuleHash>::const_iterator rhi =
- this->RuleHashes.find(fname);
+ auto const rhi = this->RuleHashes.find(fname);
if (rhi != this->RuleHashes.end()) {
// Compare the rule hash in the file to that we were given.
if (strncmp(line.c_str(), rhi->second.Data, 32) != 0) {
// The rule has changed. Delete the output so it will be
// built again.
- fname = cmSystemTools::CollapseFullPath(fname, home.c_str());
+ fname = cmSystemTools::CollapseFullPath(fname, home);
cmSystemTools::RemoveFile(fname);
}
} else {
@@ -2753,10 +2929,10 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
// Instead, we keep the rule hash as long as the file exists so
// that if the feature is turned back on and the rule has
// changed the file is still rebuilt.
- std::string fpath = cmSystemTools::CollapseFullPath(fname, home.c_str());
- if (cmSystemTools::FileExists(fpath.c_str())) {
+ std::string fpath = cmSystemTools::CollapseFullPath(fname, home);
+ if (cmSystemTools::FileExists(fpath)) {
RuleHash hash;
- strncpy(hash.Data, line.c_str(), 32);
+ memcpy(hash.Data, line.c_str(), 32);
this->RuleHashes[fname] = hash;
}
}
@@ -2769,13 +2945,11 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile)
if (this->RuleHashes.empty()) {
cmSystemTools::RemoveFile(pfile);
} else {
- cmGeneratedFileStream fout(pfile.c_str());
+ cmGeneratedFileStream fout(pfile);
fout << "# Hashes of file build rules.\n";
- for (std::map<std::string, RuleHash>::const_iterator rhi =
- this->RuleHashes.begin();
- rhi != this->RuleHashes.end(); ++rhi) {
- fout.write(rhi->second.Data, 32);
- fout << " " << rhi->first << "\n";
+ for (auto const& rh : this->RuleHashes) {
+ fout.write(rh.second.Data, 32);
+ fout << " " << rh.first << "\n";
}
}
}
@@ -2783,21 +2957,17 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile)
void cmGlobalGenerator::WriteSummary()
{
// Record all target directories in a central location.
- std::string fname = this->CMakeInstance->GetHomeOutputDirectory();
- fname += cmake::GetCMakeFilesDirectory();
- fname += "/TargetDirectories.txt";
- cmGeneratedFileStream fout(fname.c_str());
+ std::string fname = cmStrCat(this->CMakeInstance->GetHomeOutputDirectory(),
+ "/CMakeFiles/TargetDirectories.txt");
+ cmGeneratedFileStream fout(fname);
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- std::vector<cmGeneratorTarget*> tgts =
- this->LocalGenerators[i]->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin();
- it != tgts.end(); ++it) {
- if ((*it)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
+ for (cmGeneratorTarget* tgt : lg->GetGeneratorTargets()) {
+ if (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- this->WriteSummary(*it);
- fout << (*it)->GetSupportDirectory() << "\n";
+ this->WriteSummary(tgt);
+ fout << tgt->GetSupportDirectory() << "\n";
}
}
}
@@ -2806,68 +2976,92 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
{
// Place the labels file in a per-target support directory.
std::string dir = target->GetSupportDirectory();
- std::string file = dir;
- file += "/Labels.txt";
+ std::string file = cmStrCat(dir, "/Labels.txt");
std::string json_file = dir + "/Labels.json";
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
// Check whether labels are enabled for this target.
- if (const char* value = target->GetProperty("LABELS")) {
+ const char* targetLabels = target->GetProperty("LABELS");
+ const char* directoryLabels =
+ target->Target->GetMakefile()->GetProperty("LABELS");
+ const char* cmakeDirectoryLabels =
+ target->Target->GetMakefile()->GetDefinition("CMAKE_DIRECTORY_LABELS");
+ if (targetLabels || directoryLabels || cmakeDirectoryLabels) {
Json::Value lj_root(Json::objectValue);
Json::Value& lj_target = lj_root["target"] = Json::objectValue;
lj_target["name"] = target->GetName();
Json::Value& lj_target_labels = lj_target["labels"] = Json::arrayValue;
Json::Value& lj_sources = lj_root["sources"] = Json::arrayValue;
- cmSystemTools::MakeDirectory(dir.c_str());
- cmGeneratedFileStream fout(file.c_str());
+ cmSystemTools::MakeDirectory(dir);
+ cmGeneratedFileStream fout(file);
+
+ std::vector<std::string> labels;
// List the target-wide labels. All sources in the target get
// these labels.
- std::vector<std::string> labels;
- cmSystemTools::ExpandListArgument(value, labels);
- if (!labels.empty()) {
- fout << "# Target labels\n";
- for (std::vector<std::string>::const_iterator li = labels.begin();
- li != labels.end(); ++li) {
- fout << " " << *li << "\n";
- lj_target_labels.append(*li);
+ if (targetLabels) {
+ cmExpandList(targetLabels, labels);
+ if (!labels.empty()) {
+ fout << "# Target labels\n";
+ for (std::string const& l : labels) {
+ fout << " " << l << "\n";
+ lj_target_labels.append(l);
+ }
}
}
+ // List directory labels
+ std::vector<std::string> directoryLabelsList;
+ std::vector<std::string> cmakeDirectoryLabelsList;
+
+ if (directoryLabels) {
+ cmExpandList(directoryLabels, directoryLabelsList);
+ }
+
+ if (cmakeDirectoryLabels) {
+ cmExpandList(cmakeDirectoryLabels, cmakeDirectoryLabelsList);
+ }
+
+ if (!directoryLabelsList.empty() || !cmakeDirectoryLabelsList.empty()) {
+ fout << "# Directory labels\n";
+ }
+
+ for (std::string const& li : directoryLabelsList) {
+ fout << " " << li << "\n";
+ lj_target_labels.append(li);
+ }
+
+ for (std::string const& li : cmakeDirectoryLabelsList) {
+ fout << " " << li << "\n";
+ lj_target_labels.append(li);
+ }
+
// List the source files with any per-source labels.
fout << "# Source files and their labels\n";
std::vector<cmSourceFile*> sources;
- std::vector<std::string> configs;
- target->Target->GetMakefile()->GetConfigurations(configs);
- if (configs.empty()) {
- configs.push_back("");
- }
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
- target->GetSourceFiles(sources, *ci);
- }
- std::vector<cmSourceFile*>::const_iterator sourcesEnd =
- cmRemoveDuplicates(sources);
- for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sourcesEnd; ++si) {
+ std::vector<std::string> const& configs =
+ target->Target->GetMakefile()->GetGeneratorConfigs();
+ for (std::string const& c : configs) {
+ target->GetSourceFiles(sources, c);
+ }
+ auto const sourcesEnd = cmRemoveDuplicates(sources);
+ for (cmSourceFile* sf : cmMakeRange(sources.cbegin(), sourcesEnd)) {
Json::Value& lj_source = lj_sources.append(Json::objectValue);
- cmSourceFile* sf = *si;
- std::string const& sfp = sf->GetFullPath();
+ std::string const& sfp = sf->ResolveFullPath();
fout << sfp << "\n";
lj_source["file"] = sfp;
if (const char* svalue = sf->GetProperty("LABELS")) {
labels.clear();
Json::Value& lj_source_labels = lj_source["labels"] = Json::arrayValue;
- cmSystemTools::ExpandListArgument(svalue, labels);
- for (std::vector<std::string>::const_iterator li = labels.begin();
- li != labels.end(); ++li) {
- fout << " " << *li << "\n";
- lj_source_labels.append(*li);
+ cmExpandList(svalue, labels);
+ for (std::string const& label : labels) {
+ fout << " " << label << "\n";
+ lj_source_labels.append(label);
}
}
}
- cmGeneratedFileStream json_fout(json_file.c_str());
+ cmGeneratedFileStream json_fout(json_file);
json_fout << lj_root;
} else
#endif
@@ -2881,11 +3075,23 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
std::string cmGlobalGenerator::EscapeJSON(const std::string& s)
{
std::string result;
- for (std::string::size_type i = 0; i < s.size(); ++i) {
- if (s[i] == '"' || s[i] == '\\') {
- result += '\\';
+ result.reserve(s.size());
+ for (char i : s) {
+ switch (i) {
+ case '"':
+ case '\\':
+ result += '\\';
+ result += i;
+ break;
+ case '\n':
+ result += "\\n";
+ break;
+ case '\t':
+ result += "\\t";
+ break;
+ default:
+ result += i;
}
- result += s[i];
}
return result;
}
@@ -2902,21 +3108,11 @@ cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const
return this->FilenameTargetDepends[sf];
}
-void cmGlobalGenerator::CreateEvaluationSourceFiles(
- std::string const& config) const
-{
- unsigned int i;
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- this->LocalGenerators[i]->CreateEvaluationFileOutputs(config);
- }
-}
-
void cmGlobalGenerator::ProcessEvaluationFiles()
{
std::vector<std::string> generatedFiles;
- unsigned int i;
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- this->LocalGenerators[i]->ProcessEvaluationFiles(generatedFiles);
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ localGen->ProcessEvaluationFiles(generatedFiles);
}
}
@@ -2937,19 +3133,18 @@ bool cmGlobalGenerator::GenerateCPackPropertiesFile()
std::vector<std::string> configs;
std::string config = mf->GetConfigurations(configs, false);
- std::string path = this->CMakeInstance->GetHomeOutputDirectory();
- path += "/CPackProperties.cmake";
+ std::string path = cmStrCat(this->CMakeInstance->GetHomeOutputDirectory(),
+ "/CPackProperties.cmake");
- if (!cmSystemTools::FileExists(path.c_str()) && installedFiles.empty()) {
+ if (!cmSystemTools::FileExists(path) && installedFiles.empty()) {
return true;
}
- cmGeneratedFileStream file(path.c_str());
+ cmGeneratedFileStream file(path);
file << "# CPack properties\n";
- for (cmake::InstalledFilesMap::const_iterator i = installedFiles.begin();
- i != installedFiles.end(); ++i) {
- cmInstalledFile const& installedFile = i->second;
+ for (auto const& i : installedFiles) {
+ cmInstalledFile const& installedFile = i.second;
cmCPackPropertiesGenerator cpackPropertiesGenerator(lg, installedFile,
configs);
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 871178be1..f25ff7b77 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -3,28 +3,38 @@
#ifndef cmGlobalGenerator_h
#define cmGlobalGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
+#include <memory>
#include <set>
#include <string>
+#include <unordered_map>
#include <utility>
#include <vector>
+#include "cm_codecvt.hxx"
+
+#include "cmAlgorithms.h"
#include "cmCustomCommandLines.h"
-#include "cmExportSetMap.h"
+#include "cmDuration.h"
+#include "cmExportSet.h"
#include "cmStateSnapshot.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetDepend.h"
-#include "cm_codecvt.hxx"
-#include "cm_unordered_map.hxx"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmFileLockPool.h"
+#if !defined(CMAKE_BOOTSTRAP)
+# include "cm_jsoncpp_value.h"
+
+# include "cmFileLockPool.h"
#endif
+#define CMAKE_DIRECTORY_ID_SEP "::@"
+
+class cmDirectoryId;
class cmExportBuildFileGenerator;
class cmExternalMakefileProjectGenerator;
class cmGeneratorTarget;
@@ -36,6 +46,41 @@ class cmSourceFile;
class cmStateDirectory;
class cmake;
+namespace detail {
+inline void AppendStrs(std::vector<std::string>&)
+{
+}
+template <typename T, typename... Ts>
+inline void AppendStrs(std::vector<std::string>& command, T&& s, Ts&&... ts)
+{
+ command.emplace_back(std::forward<T>(s));
+ AppendStrs(command, std::forward<Ts>(ts)...);
+}
+
+struct GeneratedMakeCommand
+{
+ // Add each argument as a separate element to the vector
+ template <typename... T>
+ void Add(T&&... args)
+ {
+ // iterate the args and append each one
+ AppendStrs(PrimaryCommand, std::forward<T>(args)...);
+ }
+
+ // Add each value in the iterators as a separate element to the vector
+ void Add(std::vector<std::string>::const_iterator start,
+ std::vector<std::string>::const_iterator end)
+ {
+ cmAppend(PrimaryCommand, start, end);
+ }
+
+ std::string Printable() const { return cmJoin(PrimaryCommand, " "); }
+
+ std::vector<std::string> PrimaryCommand;
+ bool RequiresOutputForward = false;
+};
+}
+
/** \class cmGlobalGenerator
* \brief Responsible for overseeing the generation process for the entire tree
*
@@ -45,13 +90,13 @@ class cmake;
class cmGlobalGenerator
{
public:
- ///! Free any memory allocated with the GlobalGenerator
+ //! Free any memory allocated with the GlobalGenerator
cmGlobalGenerator(cmake* cm);
virtual ~cmGlobalGenerator();
virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
- ///! Get the name for this generator
+ //! Get the name for this generator
virtual std::string GetName() const { return "Generic"; }
/** Check whether the given name matches the current generator. */
@@ -66,9 +111,17 @@ public:
return codecvt::None;
}
+#if !defined(CMAKE_BOOTSTRAP)
+ /** Get a JSON object describing the generator. */
+ virtual Json::Value GetJson() const;
+#endif
+
/** Tell the generator about the target system. */
virtual bool SetSystemName(std::string const&, cmMakefile*) { return true; }
+ /** Set the generator-specific instance. Returns true if supported. */
+ virtual bool SetGeneratorInstance(std::string const& i, cmMakefile* mf);
+
/** Set the generator-specific platform name. Returns true if platform
is supported and false otherwise. */
virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf);
@@ -142,9 +195,10 @@ public:
* Try running cmake and building a file. This is used for dynamically
* loaded commands, not as part of the usual build process.
*/
- int TryCompile(const std::string& srcdir, const std::string& bindir,
- const std::string& projectName, const std::string& targetName,
- bool fast, std::string& output, cmMakefile* mf);
+ int TryCompile(int jobs, const std::string& srcdir,
+ const std::string& bindir, const std::string& projectName,
+ const std::string& targetName, bool fast, std::string& output,
+ cmMakefile* mf);
/**
* Build a file given the following information. This is a more direct call
@@ -152,29 +206,41 @@ public:
* empty then all is assumed. clean indicates if a "make clean" should be
* done first.
*/
- int Build(const std::string& srcdir, const std::string& bindir,
- const std::string& projectName, const std::string& targetName,
- std::string& output, const std::string& makeProgram,
- const std::string& config, bool clean, bool fast, bool verbose,
- double timeout, cmSystemTools::OutputOption outputflag =
- cmSystemTools::OUTPUT_NONE,
- std::vector<std::string> const& nativeOptions =
- std::vector<std::string>());
-
- virtual void GenerateBuildCommand(
- std::vector<std::string>& makeCommand, const std::string& makeProgram,
- const std::string& projectName, const std::string& projectDir,
- const std::string& targetName, const std::string& config, bool fast,
- bool verbose,
+ int Build(
+ int jobs, const std::string& srcdir, const std::string& bindir,
+ const std::string& projectName,
+ std::vector<std::string> const& targetNames, std::string& output,
+ const std::string& makeProgram, const std::string& config, bool clean,
+ bool fast, bool verbose, cmDuration timeout,
+ cmSystemTools::OutputOption outputflag = cmSystemTools::OUTPUT_NONE,
+ std::vector<std::string> const& nativeOptions =
+ std::vector<std::string>());
+
+ /**
+ * Open a generated IDE project given the following information.
+ */
+ virtual bool Open(const std::string& bindir, const std::string& projectName,
+ bool dryRun);
+
+ struct GeneratedMakeCommand final : public detail::GeneratedMakeCommand
+ {
+ };
+
+ virtual std::vector<GeneratedMakeCommand> GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int jobs, bool verbose,
std::vector<std::string> const& makeOptions = std::vector<std::string>());
+ virtual void PrintBuildCommandAdvice(std::ostream& os, int jobs) const;
+
/** Generate a "cmake --build" call for a given target and config. */
std::string GenerateCMakeBuildCommand(const std::string& target,
const std::string& config,
const std::string& native,
bool ignoreErrors);
- ///! Get the CMake instance
+ //! Get the CMake instance
cmake* GetCMakeInstance() const { return this->CMakeInstance; }
void SetConfiguredFilesPath(cmGlobalGenerator* gen);
@@ -187,19 +253,25 @@ public:
return this->LocalGenerators;
}
- cmMakefile* GetCurrentMakefile() const { return this->CurrentMakefile; }
+ cmMakefile* GetCurrentMakefile() const
+ {
+ return this->CurrentConfigureMakefile;
+ }
- void SetCurrentMakefile(cmMakefile* mf) { this->CurrentMakefile = mf; }
+ void SetCurrentMakefile(cmMakefile* mf)
+ {
+ this->CurrentConfigureMakefile = mf;
+ }
void AddMakefile(cmMakefile* mf);
- ///! Set an generator for an "external makefile based project"
+ //! Set an generator for an "external makefile based project"
void SetExternalMakefileProjectGenerator(
cmExternalMakefileProjectGenerator* extraGenerator);
std::string GetExtraGeneratorName() const;
- void AddInstallComponent(const char* component);
+ void AddInstallComponent(const std::string& component);
const std::set<std::string>* GetInstallComponents() const
{
@@ -210,31 +282,31 @@ public:
const char* GetGlobalSetting(std::string const& name) const;
bool GlobalSettingIsOn(std::string const& name) const;
- const char* GetSafeGlobalSetting(std::string const& name) const;
+ std::string GetSafeGlobalSetting(std::string const& name) const;
/** Add a file to the manifest of generated targets for a configuration. */
void AddToManifest(std::string const& f);
void EnableInstallTarget();
- int TryCompileTimeout;
+ cmDuration TryCompileTimeout;
bool GetForceUnixPaths() const { return this->ForceUnixPaths; }
bool GetToolSupportsColor() const { return this->ToolSupportsColor; }
- ///! return the language for the given extension
+ //! return the language for the given extension
std::string GetLanguageFromExtension(const char* ext) const;
- ///! is an extension to be ignored
+ //! is an extension to be ignored
bool IgnoreFile(const char* ext) const;
- ///! What is the preference for linkers and this language (None or Preferred)
+ //! What is the preference for linkers and this language (None or Preferred)
int GetLinkerPreference(const std::string& lang) const;
- ///! What is the object file extension for a given source file?
+ //! What is the object file extension for a given source file?
std::string GetLanguageOutputExtension(cmSourceFile const&) const;
- ///! What is the configurations directory variable called?
+ //! What is the configurations directory variable called?
virtual const char* GetCMakeCFGIntDir() const { return "."; }
- ///! expand CFGIntDir for a configuration
+ //! expand CFGIntDir for a configuration
virtual std::string ExpandCFGIntDir(const std::string& str,
const std::string& config) const;
@@ -250,7 +322,7 @@ public:
*/
virtual bool FindMakeProgram(cmMakefile*);
- ///! Find a target by name by searching the local generators.
+ //! Find a target by name by searching the local generators.
cmTarget* FindTarget(const std::string& name,
bool excludeAliases = false) const;
@@ -264,8 +336,7 @@ public:
bool NameResolvesToFramework(const std::string& libname) const;
cmMakefile* FindMakefile(const std::string& start_dir) const;
- ///! Find a local generator by its startdirectory
- cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const;
+ cmLocalGenerator* FindLocalGenerator(cmDirectoryId const& id) const;
/** Append the subdirectory for the given configuration. If anything is
appended the given prefix and suffix will be appended around it, which
@@ -285,32 +356,36 @@ public:
void IndexTarget(cmTarget* t);
void IndexGeneratorTarget(cmGeneratorTarget* gt);
+ // Index the target using a name that is unique to that target
+ // even if other targets have the same name.
+ std::string IndexGeneratorTargetUniquely(cmGeneratorTarget const* gt);
+
static bool IsReservedTarget(std::string const& name);
virtual const char* GetAllTargetName() const { return "ALL_BUILD"; }
virtual const char* GetInstallTargetName() const { return "INSTALL"; }
- virtual const char* GetInstallLocalTargetName() const { return CM_NULLPTR; }
- virtual const char* GetInstallStripTargetName() const { return CM_NULLPTR; }
- virtual const char* GetPreinstallTargetName() const { return CM_NULLPTR; }
+ virtual const char* GetInstallLocalTargetName() const { return nullptr; }
+ virtual const char* GetInstallStripTargetName() const { return nullptr; }
+ virtual const char* GetPreinstallTargetName() const { return nullptr; }
virtual const char* GetTestTargetName() const { return "RUN_TESTS"; }
virtual const char* GetPackageTargetName() const { return "PACKAGE"; }
- virtual const char* GetPackageSourceTargetName() const { return CM_NULLPTR; }
- virtual const char* GetEditCacheTargetName() const { return CM_NULLPTR; }
- virtual const char* GetRebuildCacheTargetName() const { return CM_NULLPTR; }
- virtual const char* GetCleanTargetName() const { return CM_NULLPTR; }
+ virtual const char* GetPackageSourceTargetName() const { return nullptr; }
+ virtual const char* GetEditCacheTargetName() const { return nullptr; }
+ virtual const char* GetRebuildCacheTargetName() const { return nullptr; }
+ virtual const char* GetCleanTargetName() const { return nullptr; }
// Lookup edit_cache target command preferred by this generator.
virtual std::string GetEditCacheCommand() const { return ""; }
// Class to track a set of dependencies.
- typedef cmTargetDependSet TargetDependSet;
+ using TargetDependSet = cmTargetDependSet;
// what targets does the specified target depend on directly
// via a target_link_libraries or add_dependencies
TargetDependSet const& GetTargetDirectDepends(
const cmGeneratorTarget* target);
- const std::map<std::string, std::vector<cmLocalGenerator*> >& GetProjectMap()
+ const std::map<std::string, std::vector<cmLocalGenerator*>>& GetProjectMap()
const
{
return this->ProjectMap;
@@ -333,6 +408,8 @@ public:
i.e. "Can I build Debug and Release in the same tree?" */
virtual bool IsMultiConfig() const { return false; }
+ virtual bool IsXcode() const { return false; }
+
/** Return true if we know the exact location of object files.
If false, store the reason in the given string.
This is meaningful only after EnableLanguage has been called. */
@@ -342,6 +419,10 @@ public:
virtual bool IsIPOSupported() const { return false; }
+ /** Return whether the generator can import external visual studio project
+ using INCLUDE_EXTERNAL_MSPROJECT */
+ virtual bool IsIncludeExternalMSProjectSupported() const { return false; }
+
/** Return whether the generator should use EFFECTIVE_PLATFORM_NAME. This is
relevant for mixed macOS and iOS builds. */
virtual bool UseEffectivePlatformName(cmMakefile*) const { return false; }
@@ -376,14 +457,12 @@ public:
bool GenerateCPackPropertiesFile();
- void CreateEvaluationSourceFiles(std::string const& config) const;
-
void SetFilenameTargetDepends(
cmSourceFile* sf, std::set<cmGeneratorTarget const*> const& tgts);
const std::set<const cmGeneratorTarget*>& GetFilenameTargetDepends(
cmSourceFile* sf) const;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
cmFileLockPool& GetFileLockPool() { return FileLockPool; }
#endif
@@ -394,8 +473,10 @@ public:
std::string MakeSilentFlag;
+ int RecursionDepth;
+
protected:
- typedef std::vector<cmLocalGenerator*> GeneratorVector;
+ using GeneratorVector = std::vector<cmLocalGenerator*>;
// for a project collect all its targets by following depend
// information, and also collect all the targets
void GetTargetSets(TargetDependSet& projectTargets,
@@ -416,7 +497,11 @@ protected:
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const;
- std::vector<const cmGeneratorTarget*> CreateQtAutoGeneratorsTargets();
+ /// @brief Qt AUTOMOC/UIC/RCC target generation
+ /// @return true on success
+ bool QtAutoGen();
+
+ bool AddAutomaticSources();
std::string SelectMakeProgram(const std::string& makeProgram,
const std::string& makeDefault = "") const;
@@ -438,11 +523,7 @@ protected:
cmCustomCommandLines CommandLines;
std::vector<std::string> Depends;
std::string WorkingDir;
- bool UsesTerminal;
- GlobalTargetInfo()
- : UsesTerminal(false)
- {
- }
+ bool UsesTerminal = false;
};
void CreateDefaultGlobalTargets(std::vector<GlobalTargetInfo>& targets);
@@ -460,9 +541,9 @@ protected:
cmake* CMakeInstance;
std::vector<cmMakefile*> Makefiles;
std::vector<cmLocalGenerator*> LocalGenerators;
- cmMakefile* CurrentMakefile;
+ cmMakefile* CurrentConfigureMakefile;
// map from project name to vector of local generators in that project
- std::map<std::string, std::vector<cmLocalGenerator*> > ProjectMap;
+ std::map<std::string, std::vector<cmLocalGenerator*>> ProjectMap;
// Set of named installation components requested by the project.
std::set<std::string> InstallComponents;
@@ -476,15 +557,15 @@ protected:
cmTarget* FindTargetImpl(std::string const& name) const;
cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const;
- cmGeneratorTarget* FindImportedGeneratorTargetImpl(
- std::string const& name) const;
const char* GetPredefinedTargetsFolder();
private:
- typedef CM_UNORDERED_MAP<std::string, cmTarget*> TargetMap;
- typedef CM_UNORDERED_MAP<std::string, cmGeneratorTarget*> GeneratorTargetMap;
- typedef CM_UNORDERED_MAP<std::string, cmMakefile*> MakefileMap;
+ using TargetMap = std::unordered_map<std::string, cmTarget*>;
+ using GeneratorTargetMap =
+ std::unordered_map<std::string, cmGeneratorTarget*>;
+ using MakefileMap = std::unordered_map<std::string, cmMakefile*>;
+ using LocalGeneratorMap = std::unordered_map<std::string, cmLocalGenerator*>;
// Map efficiently from target name to cmTarget instance.
// Do not use this structure for looping over all targets.
// It contains both normal and globally visible imported targets.
@@ -496,6 +577,11 @@ private:
// It may not contain all of them (see note in IndexMakefile method).
MakefileMap MakefileSearchIndex;
+ // Map efficiently from source directory path to cmLocalGenerator instance.
+ // Do not use this structure for looping over all directories.
+ // Its order is not deterministic.
+ LocalGeneratorMap LocalGeneratorSearchIndex;
+
cmMakefile* TryCompileOuterMakefile;
// If you add a new map here, make sure it is copied
// in EnableLanguagesFromGenerator
@@ -524,6 +610,10 @@ private:
virtual void ForceLinkerLanguages();
+ bool CheckTargetsForMissingSources() const;
+ bool CheckTargetsForType() const;
+ bool CheckTargetsForPchCompilePdb() const;
+
void CreateLocalGenerators();
void CheckCompilerIdCompatibility(cmMakefile* mf,
@@ -531,13 +621,13 @@ private:
void ComputeBuildFileGenerators();
- cmExternalMakefileProjectGenerator* ExtraGenerator;
+ std::unique_ptr<cmExternalMakefileProjectGenerator> ExtraGenerator;
// track files replaced during a Generate
std::vector<std::string> FilesReplacedDuringGenerate;
// Store computed inter-target dependencies.
- typedef std::map<cmGeneratorTarget const*, TargetDependSet> TargetDependMap;
+ using TargetDependMap = std::map<cmGeneratorTarget const*, TargetDependSet>;
TargetDependMap TargetDependencies;
friend class cmake;
@@ -548,20 +638,20 @@ private:
void ClearGeneratorMembers();
+ bool CheckCMP0037(std::string const& targetName,
+ std::string const& reason) const;
+
void IndexMakefile(cmMakefile* mf);
+ void IndexLocalGenerator(cmLocalGenerator* lg);
- virtual const char* GetBuildIgnoreErrorsFlag() const { return CM_NULLPTR; }
+ virtual const char* GetBuildIgnoreErrorsFlag() const { return nullptr; }
// Cache directory content and target files to be built.
struct DirectoryContent
{
- long LastDiskTime;
+ long LastDiskTime = -1;
std::set<std::string> All;
std::set<std::string> Generated;
- DirectoryContent()
- : LastDiskTime(-1)
- {
- }
};
std::map<std::string, DirectoryContent> DirectoryContentMap;
@@ -573,10 +663,10 @@ private:
// track targets to issue CMP0068 warning for.
std::set<std::string> CMP0068WarnTargets;
- mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*> >
+ mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*>>
FilenameTargetDepends;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
// Pool of file locks
cmFileLockPool FileLockPool;
#endif
diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h
index d5a6db06e..bb5f74cca 100644
--- a/Source/cmGlobalGeneratorFactory.h
+++ b/Source/cmGlobalGeneratorFactory.h
@@ -3,7 +3,7 @@
#ifndef cmGlobalGeneratorFactory_h
#define cmGlobalGeneratorFactory_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
@@ -20,7 +20,7 @@ struct cmDocumentationEntry;
class cmGlobalGeneratorFactory
{
public:
- virtual ~cmGlobalGeneratorFactory() {}
+ virtual ~cmGlobalGeneratorFactory() = default;
/** Create a GlobalGenerator */
virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& n,
@@ -30,13 +30,20 @@ public:
virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
/** Get the names of the current registered generators */
- virtual void GetGenerators(std::vector<std::string>& names) const = 0;
+ virtual std::vector<std::string> GetGeneratorNames() const = 0;
+ virtual std::vector<std::string> GetGeneratorNamesWithPlatform() const = 0;
/** Determine whether or not this generator supports toolsets */
virtual bool SupportsToolset() const = 0;
/** Determine whether or not this generator supports platforms */
virtual bool SupportsPlatform() const = 0;
+
+ /** Get the list of supported platforms name for this generator */
+ virtual std::vector<std::string> GetKnownPlatforms() const = 0;
+
+ /** If the generator suports platforms, get its default. */
+ virtual std::string GetDefaultPlatformName() const = 0;
};
template <class T>
@@ -45,31 +52,46 @@ class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
public:
/** Create a GlobalGenerator */
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
- cmake* cm) const CM_OVERRIDE
+ cmake* cm) const override
{
if (name != T::GetActualName()) {
- return CM_NULLPTR;
+ return nullptr;
}
return new T(cm);
}
/** Get the documentation entry for this factory */
- void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
+ void GetDocumentation(cmDocumentationEntry& entry) const override
{
T::GetDocumentation(entry);
}
/** Get the names of the current registered generators */
- void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(T::GetActualName());
+ return names;
+ }
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ return std::vector<std::string>();
}
/** Determine whether or not this generator supports toolsets */
- bool SupportsToolset() const CM_OVERRIDE { return T::SupportsToolset(); }
+ bool SupportsToolset() const override { return T::SupportsToolset(); }
/** Determine whether or not this generator supports platforms */
- bool SupportsPlatform() const CM_OVERRIDE { return T::SupportsPlatform(); }
+ bool SupportsPlatform() const override { return T::SupportsPlatform(); }
+
+ /** Get the list of supported platforms name for this generator */
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ // default is no platform supported
+ return std::vector<std::string>();
+ }
+
+ std::string GetDefaultPlatformName() const override { return std::string(); }
};
#endif
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index 42ab4d98a..5a708abbc 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -2,31 +2,43 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalGhsMultiGenerator.h"
-#include "cmsys/SystemTools.hxx"
+#include <algorithm>
+#include <cstring>
+#include <map>
+#include <ostream>
+#include <utility>
#include "cmAlgorithms.h"
#include "cmDocumentationEntry.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
-#include "cmGhsMultiTargetGenerator.h"
+#include "cmGhsMultiGpj.h"
+#include "cmLocalGenerator.h"
#include "cmLocalGhsMultiGenerator.h"
#include "cmMakefile.h"
+#include "cmState.h"
+#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
#include "cmVersion.h"
+#include "cmake.h"
const char* cmGlobalGhsMultiGenerator::FILE_EXTENSION = ".gpj";
-const char* cmGlobalGhsMultiGenerator::DEFAULT_MAKE_PROGRAM = "gbuild";
+#ifdef __linux__
+const char* cmGlobalGhsMultiGenerator::DEFAULT_BUILD_PROGRAM = "gbuild";
+const char* cmGlobalGhsMultiGenerator::DEFAULT_TOOLSET_ROOT = "/usr/ghs";
+#elif defined(_WIN32)
+const char* cmGlobalGhsMultiGenerator::DEFAULT_BUILD_PROGRAM = "gbuild.exe";
+const char* cmGlobalGhsMultiGenerator::DEFAULT_TOOLSET_ROOT = "C:/ghs";
+#endif
cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake* cm)
: cmGlobalGenerator(cm)
- , OSDirRelative(false)
{
- this->GhsBuildCommandInitialized = false;
+ cm->GetState()->SetGhsMultiIDE(true);
}
-cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator()
-{
- cmDeleteAll(TargetFolderBuildStreams);
-}
+cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator() = default;
cmLocalGenerator* cmGlobalGhsMultiGenerator::CreateLocalGenerator(
cmMakefile* mf)
@@ -41,450 +53,686 @@ void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry& entry)
"Generates Green Hills MULTI files (experimental, work-in-progress).";
}
-void cmGlobalGhsMultiGenerator::EnableLanguage(
- std::vector<std::string> const& l, cmMakefile* mf, bool optional)
+void cmGlobalGhsMultiGenerator::ComputeTargetObjectDirectory(
+ cmGeneratorTarget* gt) const
{
- mf->AddDefinition("CMAKE_SYSTEM_NAME", "GHS-MULTI");
- mf->AddDefinition("CMAKE_SYSTEM_PROCESSOR", "ARM");
-
- const std::string ghsCompRoot(GetCompRoot());
- mf->AddDefinition("GHS_COMP_ROOT", ghsCompRoot.c_str());
- std::string ghsCompRootStart =
- 0 == ghsCompRootStart.size() ? "" : ghsCompRoot + "/";
- mf->AddDefinition("CMAKE_C_COMPILER",
- std::string(ghsCompRootStart + "ccarm.exe").c_str());
- mf->AddDefinition("CMAKE_C_COMPILER_ID_RUN", "TRUE");
- mf->AddDefinition("CMAKE_C_COMPILER_ID", "GHS");
- mf->AddDefinition("CMAKE_C_COMPILER_FORCED", "TRUE");
-
- mf->AddDefinition("CMAKE_CXX_COMPILER",
- std::string(ghsCompRootStart + "cxarm.exe").c_str());
- mf->AddDefinition("CMAKE_CXX_COMPILER_ID_RUN", "TRUE");
- mf->AddDefinition("CMAKE_CXX_COMPILER_ID", "GHS");
- mf->AddDefinition("CMAKE_CXX_COMPILER_FORCED", "TRUE");
-
- if (!ghsCompRoot.empty()) {
- static const char* compPreFix = "comp_";
- std::string compFilename =
- cmsys::SystemTools::FindLastString(ghsCompRoot.c_str(), compPreFix);
- cmsys::SystemTools::ReplaceString(compFilename, compPreFix, "");
- mf->AddDefinition("CMAKE_SYSTEM_VERSION", compFilename.c_str());
- }
-
- mf->AddDefinition("GHSMULTI", "1"); // identifier for user CMake files
- this->cmGlobalGenerator::EnableLanguage(l, mf, optional);
+ // Compute full path to object file directory for this target.
+ std::string dir =
+ cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(), '/',
+ gt->LocalGenerator->GetTargetDirectory(gt), '/');
+ gt->ObjectDirectory = dir;
}
-bool cmGlobalGhsMultiGenerator::FindMakeProgram(cmMakefile* mf)
+bool cmGlobalGhsMultiGenerator::SetGeneratorToolset(std::string const& ts,
+ cmMakefile* mf)
{
- // The GHS generator knows how to lookup its build tool
- // directly instead of needing a helper module to do it, so we
- // do not actually need to put CMAKE_MAKE_PROGRAM into the cache.
- if (cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
- mf->AddDefinition("CMAKE_MAKE_PROGRAM",
- this->GetGhsBuildCommand().c_str());
+ std::string tsp; /* toolset path */
+
+ this->GetToolset(mf, tsp, ts);
+
+ /* no toolset was found */
+ if (tsp.empty()) {
+ return false;
+ }
+ if (ts.empty()) {
+ std::string message;
+ message = cmStrCat(
+ "Green Hills MULTI: -T <toolset> not specified; defaulting to \"", tsp,
+ '"');
+ cmSystemTools::Message(message);
+
+ /* store the full toolset for later use
+ * -- already done if -T<toolset> was specified
+ */
+ mf->AddCacheDefinition("CMAKE_GENERATOR_TOOLSET", tsp.c_str(),
+ "Location of generator toolset.",
+ cmStateEnums::INTERNAL);
+ }
+
+ /* set the build tool to use */
+ std::string gbuild(tsp + ((tsp.back() == '/') ? "" : "/") +
+ DEFAULT_BUILD_PROGRAM);
+ const char* prevTool = mf->GetDefinition("CMAKE_MAKE_PROGRAM");
+
+ /* check if the toolset changed from last generate */
+ if (prevTool != nullptr && (gbuild != prevTool)) {
+ std::string message =
+ cmStrCat("toolset build tool: ", gbuild,
+ "\nDoes not match the previously used build tool: ", prevTool,
+ "\nEither remove the CMakeCache.txt file and CMakeFiles "
+ "directory or choose a different binary directory.");
+ cmSystemTools::Error(message);
+ return false;
}
+
+ /* store the toolset that is being used for this build */
+ mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", gbuild.c_str(),
+ "build program to use", cmStateEnums::INTERNAL, true);
+
+ mf->AddDefinition("CMAKE_SYSTEM_VERSION", tsp);
+
return true;
}
-std::string const& cmGlobalGhsMultiGenerator::GetGhsBuildCommand()
+bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p,
+ cmMakefile* mf)
{
- if (!this->GhsBuildCommandInitialized) {
- this->GhsBuildCommandInitialized = true;
- this->GhsBuildCommand = this->FindGhsBuildCommand();
+ std::string arch;
+ if (p.empty()) {
+ cmSystemTools::Message(
+ "Green Hills MULTI: -A <arch> not specified; defaulting to \"arm\"");
+ arch = "arm";
+
+ /* store the platform name for later use
+ * -- already done if -A<arch> was specified
+ */
+ mf->AddCacheDefinition("CMAKE_GENERATOR_PLATFORM", arch.c_str(),
+ "Name of generator platform.",
+ cmStateEnums::INTERNAL);
+ } else {
+ arch = p;
}
- return this->GhsBuildCommand;
+
+ /* check if OS location has been updated by platform scripts */
+ std::string platform = mf->GetSafeDefinition("GHS_TARGET_PLATFORM");
+ std::string osdir = mf->GetSafeDefinition("GHS_OS_DIR");
+ if (cmIsOff(osdir) && platform.find("integrity") != std::string::npos) {
+ if (!this->CMakeInstance->GetIsInTryCompile()) {
+ /* required OS location is not found */
+ std::string m = cmStrCat(
+ "Green Hills MULTI: GHS_OS_DIR not specified; No OS found in \"",
+ mf->GetSafeDefinition("GHS_OS_ROOT"), '"');
+ cmSystemTools::Message(m);
+ }
+ osdir = "GHS_OS_DIR-NOT-SPECIFIED";
+ } else if (!this->CMakeInstance->GetIsInTryCompile() &&
+ cmIsOff(this->OsDir) && !cmIsOff(osdir)) {
+ /* OS location was updated by auto-selection */
+ std::string m = cmStrCat(
+ "Green Hills MULTI: GHS_OS_DIR not specified; found \"", osdir, '"');
+ cmSystemTools::Message(m);
+ }
+ this->OsDir = osdir;
+
+ // Determine GHS_BSP_NAME
+ std::string bspName = mf->GetSafeDefinition("GHS_BSP_NAME");
+
+ if (cmIsOff(bspName) && platform.find("integrity") != std::string::npos) {
+ bspName = "sim" + arch;
+ /* write back the calculate name for next time */
+ mf->AddCacheDefinition("GHS_BSP_NAME", bspName.c_str(),
+ "Name of GHS target platform.",
+ cmStateEnums::STRING, true);
+ std::string m = cmStrCat(
+ "Green Hills MULTI: GHS_BSP_NAME not specified; defaulting to \"",
+ bspName, '"');
+ cmSystemTools::Message(m);
+ }
+
+ return true;
}
-std::string cmGlobalGhsMultiGenerator::FindGhsBuildCommand()
+void cmGlobalGhsMultiGenerator::EnableLanguage(
+ std::vector<std::string> const& l, cmMakefile* mf, bool optional)
{
- std::vector<std::string> userPaths;
- userPaths.push_back(this->GetCompRoot());
- std::string makeProgram =
- cmSystemTools::FindProgram(DEFAULT_MAKE_PROGRAM, userPaths);
- if (makeProgram.empty()) {
- makeProgram = DEFAULT_MAKE_PROGRAM;
+ mf->AddDefinition("CMAKE_SYSTEM_NAME", "GHS-MULTI");
+
+ mf->AddDefinition("GHSMULTI", "1"); // identifier for user CMake files
+
+ const char* tgtPlatform = mf->GetDefinition("GHS_TARGET_PLATFORM");
+ if (!tgtPlatform) {
+ cmSystemTools::Message("Green Hills MULTI: GHS_TARGET_PLATFORM not "
+ "specified; defaulting to \"integrity\"");
+ tgtPlatform = "integrity";
}
- return makeProgram;
+
+ /* store the platform name for later use */
+ mf->AddCacheDefinition("GHS_TARGET_PLATFORM", tgtPlatform,
+ "Name of GHS target platform.", cmStateEnums::STRING);
+
+ /* store original OS location */
+ this->OsDir = mf->GetSafeDefinition("GHS_OS_DIR");
+
+ this->cmGlobalGenerator::EnableLanguage(l, mf, optional);
}
-std::string cmGlobalGhsMultiGenerator::GetCompRoot()
+bool cmGlobalGhsMultiGenerator::FindMakeProgram(cmMakefile* /*mf*/)
{
- std::string output;
-
- const std::vector<std::string> potentialDirsHardPaths(
- GetCompRootHardPaths());
- const std::vector<std::string> potentialDirsRegistry(GetCompRootRegistry());
-
- std::vector<std::string> potentialDirsComplete;
- potentialDirsComplete.insert(potentialDirsComplete.end(),
- potentialDirsHardPaths.begin(),
- potentialDirsHardPaths.end());
- potentialDirsComplete.insert(potentialDirsComplete.end(),
- potentialDirsRegistry.begin(),
- potentialDirsRegistry.end());
-
- // Use latest version
- std::string outputDirName;
- for (std::vector<std::string>::const_iterator potentialDirsCompleteIt =
- potentialDirsComplete.begin();
- potentialDirsCompleteIt != potentialDirsComplete.end();
- ++potentialDirsCompleteIt) {
- const std::string dirName(
- cmsys::SystemTools::GetFilenameName(*potentialDirsCompleteIt));
- if (dirName.compare(outputDirName) > 0) {
- output = *potentialDirsCompleteIt;
- outputDirName = dirName;
- }
- }
+ // The GHS generator only knows how to lookup its build tool
+ // during generation of the project files, but this
+ // can only be done after the toolset is specified.
- return output;
+ return true;
}
-std::vector<std::string> cmGlobalGhsMultiGenerator::GetCompRootHardPaths()
+void cmGlobalGhsMultiGenerator::GetToolset(cmMakefile* mf, std::string& tsd,
+ const std::string& ts)
{
- std::vector<std::string> output;
- cmSystemTools::Glob("C:/ghs", "comp_[^;]+", output);
- for (std::vector<std::string>::iterator outputIt = output.begin();
- outputIt != output.end(); ++outputIt) {
- *outputIt = "C:/ghs/" + *outputIt;
+ const char* ghsRoot = mf->GetDefinition("GHS_TOOLSET_ROOT");
+
+ if (!ghsRoot || ghsRoot[0] == '\0') {
+ ghsRoot = DEFAULT_TOOLSET_ROOT;
+ }
+ tsd = ghsRoot;
+
+ if (ts.empty()) {
+ std::vector<std::string> output;
+
+ // Use latest? version
+ if (tsd.back() != '/') {
+ tsd += "/";
+ }
+ cmSystemTools::Glob(tsd, "comp_[^;]+", output);
+
+ if (output.empty()) {
+ std::string msg =
+ "No GHS toolsets found in GHS_TOOLSET_ROOT \"" + tsd + "\".";
+ cmSystemTools::Error(msg);
+ tsd = "";
+ } else {
+ tsd += output.back();
+ }
+ } else {
+ std::string tryPath;
+ tryPath = cmSystemTools::CollapseFullPath(ts, tsd);
+ if (!cmSystemTools::FileExists(tryPath)) {
+ std::string msg = "GHS toolset \"" + tryPath + "\" not found.";
+ cmSystemTools::Error(msg);
+ tsd = "";
+ } else {
+ tsd = tryPath;
+ }
}
- return output;
}
-std::vector<std::string> cmGlobalGhsMultiGenerator::GetCompRootRegistry()
+void cmGlobalGhsMultiGenerator::WriteFileHeader(std::ostream& fout)
{
- std::vector<std::string> output(2);
- cmsys::SystemTools::ReadRegistryValue(
- "HKEY_LOCAL_"
- "MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\"
- "Windows\\CurrentVersion\\Uninstall\\"
- "GreenHillsSoftwared771f1b4;InstallLocation",
- output[0]);
- cmsys::SystemTools::ReadRegistryValue(
- "HKEY_LOCAL_"
- "MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\"
- "Windows\\CurrentVersion\\Uninstall\\"
- "GreenHillsSoftware9881cef6;InstallLocation",
- output[1]);
- return output;
+ fout << "#!gbuild" << std::endl;
+ fout << "#" << std::endl
+ << "# CMAKE generated file: DO NOT EDIT!" << std::endl
+ << "# Generated by \"" << GetActualName() << "\""
+ << " Generator, CMake Version " << cmVersion::GetMajorVersion() << "."
+ << cmVersion::GetMinorVersion() << std::endl
+ << "#" << std::endl
+ << std::endl;
}
-void cmGlobalGhsMultiGenerator::OpenBuildFileStream(
- std::string const& filepath, cmGeneratedFileStream** filestream)
+void cmGlobalGhsMultiGenerator::WriteCustomRuleBOD(std::ostream& fout)
{
- // Get a stream where to generate things.
- if (NULL == *filestream) {
- *filestream = new cmGeneratedFileStream(filepath.c_str());
- if (NULL != *filestream) {
- OpenBuildFileStream(*filestream);
- }
- }
+ fout << "Commands {\n"
+ " Custom_Rule_Command {\n"
+ " name = \"Custom Rule Command\"\n"
+ " exec = \"";
+#ifdef _WIN32
+ fout << "cmd.exe";
+#else
+ fout << "/bin/sh";
+#endif
+ fout << "\"\n"
+ " options = {\"SpecialOptions\"}\n"
+ " }\n"
+ "}\n";
+
+ fout << "\n\n";
+ fout << "FileTypes {\n"
+ " CmakeRule {\n"
+ " name = \"Custom Rule\"\n"
+ " action = \"&Run\"\n"
+ " extensions = {\"";
+#ifdef _WIN32
+ fout << "bat";
+#else
+ fout << "sh";
+#endif
+ fout << "\"}\n"
+ " grepable = false\n"
+ " command = \"Custom Rule Command\"\n"
+ " commandLine = \"$COMMAND ";
+#ifdef _WIN32
+ fout << "/c";
+#endif
+ fout << " $INPUTFILE\"\n"
+ " progress = \"Processing Custom Rule\"\n"
+ " promoteToFirstPass = true\n"
+ " outputType = \"None\"\n"
+ " color = \"#800080\"\n"
+ " }\n"
+ "}\n";
}
-void cmGlobalGhsMultiGenerator::OpenBuildFileStream(
- cmGeneratedFileStream* filestream)
+void cmGlobalGhsMultiGenerator::WriteCustomTargetBOD(std::ostream& fout)
{
- *filestream << "#!gbuild" << std::endl;
+ fout << "FileTypes {\n"
+ " CmakeTarget {\n"
+ " name = \"Custom Target\"\n"
+ " action = \"&Execute\"\n"
+ " grepable = false\n"
+ " outputType = \"None\"\n"
+ " color = \"#800080\"\n"
+ " }\n"
+ "}\n";
}
-void cmGlobalGhsMultiGenerator::OpenBuildFileStream()
+void cmGlobalGhsMultiGenerator::WriteTopLevelProject(std::ostream& fout,
+ cmLocalGenerator* root)
{
- // Compute GHS MULTI's build file path.
- std::string buildFilePath =
- this->GetCMakeInstance()->GetHomeOutputDirectory();
- buildFilePath += "/";
- buildFilePath += "default";
- buildFilePath += FILE_EXTENSION;
-
- this->Open(std::string(""), buildFilePath, &this->TargetFolderBuildStreams);
- OpenBuildFileStream(GetBuildFileStream());
-
- char const* osDir =
- this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR");
- if (NULL == osDir) {
- osDir = "";
- cmSystemTools::Error("GHS_OS_DIR cache variable must be set");
- } else {
- this->GetCMakeInstance()->MarkCliAsUsed("GHS_OS_DIR");
- }
- std::string fOSDir(this->trimQuotes(osDir));
- std::replace(fOSDir.begin(), fOSDir.end(), '\\', '/');
- if (!fOSDir.empty() && ('c' == fOSDir[0] || 'C' == fOSDir[0])) {
- this->OSDirRelative = false;
- } else {
- this->OSDirRelative = true;
- }
+ this->WriteFileHeader(fout);
+ this->WriteMacros(fout, root);
+ this->WriteHighLevelDirectives(root, fout);
+ GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, fout);
+
+ fout << "# Top Level Project File" << std::endl;
- char const* bspName =
+ // Specify BSP option if supplied by user
+ const char* bspName =
this->GetCMakeInstance()->GetCacheDefinition("GHS_BSP_NAME");
- if (NULL == bspName) {
- bspName = "";
- cmSystemTools::Error("GHS_BSP_NAME cache variable must be set");
- } else {
- this->GetCMakeInstance()->MarkCliAsUsed("GHS_BSP_NAME");
+ if (!cmIsOff(bspName)) {
+ fout << " -bsp " << bspName << std::endl;
}
- std::string fBspName(this->trimQuotes(bspName));
- std::replace(fBspName.begin(), fBspName.end(), '\\', '/');
- this->WriteMacros();
- this->WriteHighLevelDirectives();
-
- GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, this->GetBuildFileStream());
- this->WriteDisclaimer(this->GetBuildFileStream());
- *this->GetBuildFileStream() << "# Top Level Project File" << std::endl;
- if (!fBspName.empty()) {
- *this->GetBuildFileStream() << " -bsp " << fBspName << std::endl;
+
+ // Specify OS DIR if supplied by user
+ // -- not all platforms require this entry in the project file
+ if (!cmIsOff(this->OsDir)) {
+ const char* osDirOption =
+ this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR_OPTION");
+ std::replace(this->OsDir.begin(), this->OsDir.end(), '\\', '/');
+ fout << " ";
+ if (cmIsOff(osDirOption)) {
+ fout << "";
+ } else {
+ fout << osDirOption;
+ }
+ fout << "\"" << this->OsDir << "\"" << std::endl;
}
- this->WriteCompilerOptions(fOSDir);
}
-void cmGlobalGhsMultiGenerator::CloseBuildFileStream(
- cmGeneratedFileStream** filestream)
+void cmGlobalGhsMultiGenerator::WriteSubProjects(std::ostream& fout,
+ std::string& all_target)
{
- if (filestream) {
- delete *filestream;
- *filestream = NULL;
- } else {
- cmSystemTools::Error("Build file stream was not open.");
+ fout << "CMakeFiles/" << all_target << " [Project]" << std::endl;
+ // All known targets
+ for (cmGeneratorTarget const* target : this->ProjectTargets) {
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
+ target->GetType() == cmStateEnums::MODULE_LIBRARY ||
+ target->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ (target->GetType() == cmStateEnums::GLOBAL_TARGET &&
+ target->GetName() != GetInstallTargetName())) {
+ continue;
+ }
+ fout << "CMakeFiles/" << target->GetName() + ".tgt" + FILE_EXTENSION
+ << " [Project]" << std::endl;
}
}
-void cmGlobalGhsMultiGenerator::Generate()
+void cmGlobalGhsMultiGenerator::WriteProjectLine(
+ std::ostream& fout, cmGeneratorTarget const* target, cmLocalGenerator* root,
+ std::string& rootBinaryDir)
{
- this->cmGlobalGenerator::Generate();
-
- if (!this->LocalGenerators.empty()) {
- this->OpenBuildFileStream();
-
- // Build all the folder build files
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- cmLocalGhsMultiGenerator* lg =
- static_cast<cmLocalGhsMultiGenerator*>(this->LocalGenerators[i]);
- std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets();
- this->UpdateBuildFiles(tgts);
+ const char* projName = target->GetProperty("GENERATOR_FILE_NAME");
+ const char* projType = target->GetProperty("GENERATOR_FILE_NAME_EXT");
+ if (projName && projType) {
+ cmLocalGenerator* lg = target->GetLocalGenerator();
+ std::string dir = lg->GetCurrentBinaryDirectory();
+ dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir);
+ if (dir == ".") {
+ dir.clear();
+ } else {
+ if (dir.back() != '/') {
+ dir += "/";
+ }
}
- }
- cmDeleteAll(TargetFolderBuildStreams);
- this->TargetFolderBuildStreams.clear();
+ std::string projFile = dir + projName + FILE_EXTENSION;
+ fout << projFile;
+ fout << " " << projType << std::endl;
+ } else {
+ /* Should never happen */
+ std::string message =
+ "The project file for target [" + target->GetName() + "] is missing.\n";
+ cmSystemTools::Error(message);
+ fout << "{comment} " << target->GetName() << " [missing project file]\n";
+ }
}
-void cmGlobalGhsMultiGenerator::GenerateBuildCommand(
- std::vector<std::string>& makeCommand, const std::string& makeProgram,
- const std::string& /*projectName*/, const std::string& /*projectDir*/,
- const std::string& targetName, const std::string& /*config*/, bool /*fast*/,
- bool /*verbose*/, std::vector<std::string> const& makeOptions)
+void cmGlobalGhsMultiGenerator::WriteTargets(cmLocalGenerator* root)
{
- makeCommand.push_back(
- this->SelectMakeProgram(makeProgram, this->GetGhsBuildCommand()));
-
- makeCommand.insert(makeCommand.end(), makeOptions.begin(),
- makeOptions.end());
- if (!targetName.empty()) {
- if (targetName == "clean") {
- makeCommand.push_back("-clean");
+ std::string rootBinaryDir =
+ cmStrCat(root->GetCurrentBinaryDirectory(), "/CMakeFiles");
+
+ // All known targets
+ for (cmGeneratorTarget const* target : this->ProjectTargets) {
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
+ target->GetType() == cmStateEnums::MODULE_LIBRARY ||
+ target->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ (target->GetType() == cmStateEnums::GLOBAL_TARGET &&
+ target->GetName() != GetInstallTargetName())) {
+ continue;
+ }
+
+ // create target build file
+ std::string name = cmStrCat(target->GetName(), ".tgt", FILE_EXTENSION);
+ std::string fname = cmStrCat(rootBinaryDir, "/", name);
+ cmGeneratedFileStream fbld(fname);
+ fbld.SetCopyIfDifferent(true);
+ this->WriteFileHeader(fbld);
+ GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, fbld);
+ std::vector<cmGeneratorTarget const*> build;
+ if (ComputeTargetBuildOrder(target, build)) {
+ cmSystemTools::Error(
+ cmStrCat("The inter-target dependency graph for target [",
+ target->GetName(), "] had a cycle.\n"));
} else {
- makeCommand.push_back(targetName);
+ for (auto& tgt : build) {
+ WriteProjectLine(fbld, tgt, root, rootBinaryDir);
+ }
}
+ fbld.Close();
}
}
-void cmGlobalGhsMultiGenerator::WriteMacros()
+void cmGlobalGhsMultiGenerator::WriteAllTarget(
+ cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators,
+ std::string& all_target)
{
- char const* ghsGpjMacros =
- this->GetCMakeInstance()->GetCacheDefinition("GHS_GPJ_MACROS");
- if (NULL != ghsGpjMacros) {
- std::vector<std::string> expandedList;
- cmSystemTools::ExpandListArgument(std::string(ghsGpjMacros), expandedList);
- for (std::vector<std::string>::const_iterator expandedListI =
- expandedList.begin();
- expandedListI != expandedList.end(); ++expandedListI) {
- *this->GetBuildFileStream() << "macro " << *expandedListI << std::endl;
+ this->ProjectTargets.clear();
+
+ // create target build file
+ all_target = root->GetProjectName() + "." + this->GetAllTargetName() +
+ ".tgt" + FILE_EXTENSION;
+ std::string fname =
+ root->GetCurrentBinaryDirectory() + "/CMakeFiles/" + all_target;
+ cmGeneratedFileStream fbld(fname);
+ fbld.SetCopyIfDifferent(true);
+ this->WriteFileHeader(fbld);
+ GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, fbld);
+
+ // Collect all targets under this root generator and the transitive
+ // closure of their dependencies.
+ TargetDependSet projectTargets;
+ TargetDependSet originalTargets;
+ this->GetTargetSets(projectTargets, originalTargets, root, generators);
+ OrderedTargetDependSet sortedProjectTargets(projectTargets, "");
+ std::vector<cmGeneratorTarget const*> defaultTargets;
+ for (cmGeneratorTarget const* t : sortedProjectTargets) {
+ /* save list of all targets in sorted order */
+ this->ProjectTargets.push_back(t);
+ }
+ for (cmGeneratorTarget const* t : sortedProjectTargets) {
+ if (t->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ continue;
+ }
+ if (!cmIsOn(t->GetProperty("EXCLUDE_FROM_ALL"))) {
+ defaultTargets.push_back(t);
}
}
+ std::vector<cmGeneratorTarget const*> build;
+ if (ComputeTargetBuildOrder(defaultTargets, build)) {
+ std::string message = "The inter-target dependency graph for project [" +
+ root->GetProjectName() + "] had a cycle.\n";
+ cmSystemTools::Error(message);
+ } else {
+ // determine the targets for ALL target
+ std::string rootBinaryDir =
+ cmStrCat(root->GetCurrentBinaryDirectory(), "/CMakeFiles");
+ for (cmGeneratorTarget const* target : build) {
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
+ target->GetType() == cmStateEnums::MODULE_LIBRARY ||
+ target->GetType() == cmStateEnums::SHARED_LIBRARY) {
+ continue;
+ }
+ this->WriteProjectLine(fbld, target, root, rootBinaryDir);
+ }
+ }
+ fbld.Close();
}
-void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives()
+void cmGlobalGhsMultiGenerator::Generate()
{
- *this->GetBuildFileStream() << "primaryTarget=arm_integrity.tgt"
- << std::endl;
- char const* const customization =
- this->GetCMakeInstance()->GetCacheDefinition("GHS_CUSTOMIZATION");
- if (NULL != customization && strlen(customization) > 0) {
- *this->GetBuildFileStream()
- << "customization=" << trimQuotes(customization) << std::endl;
- this->GetCMakeInstance()->MarkCliAsUsed("GHS_CUSTOMIZATION");
+ std::string fname;
+
+ // first do the superclass method
+ this->cmGlobalGenerator::Generate();
+
+ // output top-level projects
+ for (auto& it : this->ProjectMap) {
+ this->OutputTopLevelProject(it.second[0], it.second);
}
-}
-void cmGlobalGhsMultiGenerator::WriteCompilerOptions(std::string const& fOSDir)
-{
- *this->GetBuildFileStream() << " -os_dir=\"" << fOSDir << "\""
- << std::endl;
+ // create custom rule BOD file
+ fname = this->GetCMakeInstance()->GetHomeOutputDirectory() +
+ "/CMakeFiles/custom_rule.bod";
+ cmGeneratedFileStream frule(fname);
+ frule.SetCopyIfDifferent(true);
+ this->WriteFileHeader(frule);
+ this->WriteCustomRuleBOD(frule);
+ frule.Close();
+
+ // create custom target BOD file
+ fname = this->GetCMakeInstance()->GetHomeOutputDirectory() +
+ "/CMakeFiles/custom_target.bod";
+ cmGeneratedFileStream ftarget(fname);
+ ftarget.SetCopyIfDifferent(true);
+ this->WriteFileHeader(ftarget);
+ this->WriteCustomTargetBOD(ftarget);
+ ftarget.Close();
}
-void cmGlobalGhsMultiGenerator::WriteDisclaimer(std::ostream* os)
+void cmGlobalGhsMultiGenerator::OutputTopLevelProject(
+ cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
{
- (*os) << "#" << std::endl
- << "# CMAKE generated file: DO NOT EDIT!" << std::endl
- << "# Generated by \"" << GetActualName() << "\""
- << " Generator, CMake Version " << cmVersion::GetMajorVersion() << "."
- << cmVersion::GetMinorVersion() << std::endl
- << "#" << std::endl;
+ std::string fname;
+ std::string all_target;
+
+ if (generators.empty()) {
+ return;
+ }
+
+ /* Name top-level projects as filename.top.gpj to avoid name clashes
+ * with target projects. This avoid the issue where the project has
+ * the same name as the executable target.
+ */
+ fname = cmStrCat(root->GetCurrentBinaryDirectory(), '/',
+ root->GetProjectName(), ".top", FILE_EXTENSION);
+
+ cmGeneratedFileStream top(fname);
+ top.SetCopyIfDifferent(true);
+ this->WriteTopLevelProject(top, root);
+
+ this->WriteAllTarget(root, generators, all_target);
+ this->WriteTargets(root);
+
+ this->WriteSubProjects(top, all_target);
+ top.Close();
}
-void cmGlobalGhsMultiGenerator::AddFilesUpToPath(
- cmGeneratedFileStream* mainBuildFile,
- std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams,
- char const* homeOutputDirectory, std::string const& path,
- GhsMultiGpj::Types projType, std::string const& relPath)
+std::vector<cmGlobalGenerator::GeneratedMakeCommand>
+cmGlobalGhsMultiGenerator::GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& /*config*/, bool /*fast*/, int jobs, bool /*verbose*/,
+ std::vector<std::string> const& makeOptions)
{
- std::string workingPath(path);
- cmSystemTools::ConvertToUnixSlashes(workingPath);
- std::vector<cmsys::String> splitPath =
- cmSystemTools::SplitString(workingPath);
- std::string workingRelPath(relPath);
- cmSystemTools::ConvertToUnixSlashes(workingRelPath);
- if (!workingRelPath.empty()) {
- workingRelPath += "/";
+ GeneratedMakeCommand makeCommand = {};
+ std::string gbuild;
+ if (const char* gbuildCached =
+ this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM")) {
+ gbuild = gbuildCached;
+ }
+ makeCommand.Add(this->SelectMakeProgram(makeProgram, gbuild));
+
+ if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
+ makeCommand.Add("-parallel");
+ if (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL) {
+ makeCommand.Add(std::to_string(jobs));
+ }
}
- std::string pathUpTo;
- for (std::vector<cmsys::String>::const_iterator splitPathI =
- splitPath.begin();
- splitPath.end() != splitPathI; ++splitPathI) {
- pathUpTo += *splitPathI;
- if (targetFolderBuildStreams->end() ==
- targetFolderBuildStreams->find(pathUpTo)) {
- AddFilesUpToPathNewBuildFile(
- mainBuildFile, targetFolderBuildStreams, homeOutputDirectory, pathUpTo,
- splitPath.begin() == splitPathI, workingRelPath, projType);
+
+ makeCommand.Add(makeOptions.begin(), makeOptions.end());
+
+ /* determine which top-project file to use */
+ std::string proj = projectName + ".top" + FILE_EXTENSION;
+ std::vector<std::string> files;
+ cmSystemTools::Glob(projectDir, ".*\\.top\\.gpj", files);
+ if (!files.empty()) {
+ /* if multiple top-projects are found in build directory
+ * then prefer projectName top-project.
+ */
+ if (!cmContains(files, proj)) {
+ proj = files.at(0);
+ }
+ }
+
+ makeCommand.Add("-top", proj);
+ if (!targetNames.empty()) {
+ if (cmContains(targetNames, "clean")) {
+ makeCommand.Add("-clean");
+ } else {
+ for (const auto& tname : targetNames) {
+ if (!tname.empty()) {
+ makeCommand.Add(tname + ".tgt.gpj");
+ }
+ }
}
- AddFilesUpToPathAppendNextFile(targetFolderBuildStreams, pathUpTo,
- splitPathI, splitPath.end(), projType);
- pathUpTo += "/";
+ } else {
+ /* transform name to default build */;
+ std::string all = proj;
+ all.replace(all.end() - 7, all.end(),
+ std::string(this->GetAllTargetName()) + ".tgt.gpj");
+ makeCommand.Add(all);
}
+ return { makeCommand };
}
-void cmGlobalGhsMultiGenerator::Open(
- std::string const& mapKeyName, std::string const& fileName,
- std::map<std::string, cmGeneratedFileStream*>* fileMap)
+void cmGlobalGhsMultiGenerator::WriteMacros(std::ostream& fout,
+ cmLocalGenerator* root)
{
- if (fileMap->end() == fileMap->find(fileName)) {
- cmGeneratedFileStream* temp(new cmGeneratedFileStream);
- temp->open(fileName.c_str());
- (*fileMap)[mapKeyName] = temp;
+ fout << "macro PROJ_NAME=" << root->GetProjectName() << std::endl;
+ char const* ghsGpjMacros =
+ this->GetCMakeInstance()->GetCacheDefinition("GHS_GPJ_MACROS");
+ if (nullptr != ghsGpjMacros) {
+ std::vector<std::string> expandedList =
+ cmExpandedList(std::string(ghsGpjMacros));
+ for (std::string const& arg : expandedList) {
+ fout << "macro " << arg << std::endl;
+ }
}
}
-void cmGlobalGhsMultiGenerator::AddFilesUpToPathNewBuildFile(
- cmGeneratedFileStream* mainBuildFile,
- std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams,
- char const* homeOutputDirectory, std::string const& pathUpTo,
- bool const isFirst, std::string const& relPath,
- GhsMultiGpj::Types const projType)
+void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives(
+ cmLocalGenerator* root, std::ostream& fout)
{
- // create folders up to file path
- std::string absPath = std::string(homeOutputDirectory) + "/" + relPath;
- std::string newPath = absPath + pathUpTo;
- if (!cmSystemTools::FileExists(newPath.c_str())) {
- cmSystemTools::MakeDirectory(newPath.c_str());
+ /* set primary target */
+ std::string tgt;
+ const char* t =
+ this->GetCMakeInstance()->GetCacheDefinition("GHS_PRIMARY_TARGET");
+ if (t && *t != '\0') {
+ tgt = t;
+ this->GetCMakeInstance()->MarkCliAsUsed("GHS_PRIMARY_TARGET");
+ } else {
+ const char* a =
+ this->GetCMakeInstance()->GetCacheDefinition("CMAKE_GENERATOR_PLATFORM");
+ const char* p =
+ this->GetCMakeInstance()->GetCacheDefinition("GHS_TARGET_PLATFORM");
+ tgt = cmStrCat((a ? a : ""), '_', (p ? p : ""), ".tgt");
}
- // Write out to filename for first time
- std::string relFilename(GetFileNameFromPath(pathUpTo));
- std::string absFilename = absPath + relFilename;
- Open(pathUpTo, absFilename, targetFolderBuildStreams);
- OpenBuildFileStream((*targetFolderBuildStreams)[pathUpTo]);
- GhsMultiGpj::WriteGpjTag(projType, (*targetFolderBuildStreams)[pathUpTo]);
- WriteDisclaimer((*targetFolderBuildStreams)[pathUpTo]);
-
- // Add to main build file
- if (isFirst) {
- *mainBuildFile << relFilename << " ";
- GhsMultiGpj::WriteGpjTag(projType, mainBuildFile);
+ fout << "primaryTarget=" << tgt << std::endl;
+ fout << "customization=" << root->GetBinaryDirectory()
+ << "/CMakeFiles/custom_rule.bod" << std::endl;
+ fout << "customization=" << root->GetBinaryDirectory()
+ << "/CMakeFiles/custom_target.bod" << std::endl;
+
+ char const* const customization =
+ this->GetCMakeInstance()->GetCacheDefinition("GHS_CUSTOMIZATION");
+ if (nullptr != customization && strlen(customization) > 0) {
+ fout << "customization=" << this->TrimQuotes(customization) << std::endl;
+ this->GetCMakeInstance()->MarkCliAsUsed("GHS_CUSTOMIZATION");
}
}
-void cmGlobalGhsMultiGenerator::AddFilesUpToPathAppendNextFile(
- std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams,
- std::string const& pathUpTo,
- std::vector<cmsys::String>::const_iterator splitPathI,
- std::vector<cmsys::String>::const_iterator end,
- GhsMultiGpj::Types const projType)
+std::string cmGlobalGhsMultiGenerator::TrimQuotes(std::string const& str)
{
- std::vector<cmsys::String>::const_iterator splitPathNextI = splitPathI + 1;
- if (end != splitPathNextI &&
- targetFolderBuildStreams->end() ==
- targetFolderBuildStreams->find(pathUpTo + "/" + *splitPathNextI)) {
- std::string nextFilename(*splitPathNextI);
- nextFilename = GetFileNameFromPath(nextFilename);
- *(*targetFolderBuildStreams)[pathUpTo] << nextFilename << " ";
- GhsMultiGpj::WriteGpjTag(projType, (*targetFolderBuildStreams)[pathUpTo]);
+ std::string result;
+ result.reserve(str.size());
+ for (const char* ch = str.c_str(); *ch != '\0'; ++ch) {
+ if (*ch != '"') {
+ result += *ch;
+ }
}
+ return result;
}
-std::string cmGlobalGhsMultiGenerator::GetFileNameFromPath(
- std::string const& path)
+bool cmGlobalGhsMultiGenerator::TargetCompare::operator()(
+ cmGeneratorTarget const* l, cmGeneratorTarget const* r) const
{
- std::string output(path);
- if (!path.empty()) {
- cmSystemTools::ConvertToUnixSlashes(output);
- std::vector<cmsys::String> splitPath = cmSystemTools::SplitString(output);
- output += "/" + splitPath.back() + FILE_EXTENSION;
+ // Make sure a given named target is ordered first,
+ // e.g. to set ALL_BUILD as the default active project.
+ // When the empty string is named this is a no-op.
+ if (r->GetName() == this->First) {
+ return false;
+ }
+ if (l->GetName() == this->First) {
+ return true;
}
- return output;
+ return l->GetName() < r->GetName();
}
-void cmGlobalGhsMultiGenerator::UpdateBuildFiles(
- std::vector<cmGeneratorTarget*> tgts)
+cmGlobalGhsMultiGenerator::OrderedTargetDependSet::OrderedTargetDependSet(
+ TargetDependSet const& targets, std::string const& first)
+ : derived(TargetCompare(first))
{
- for (std::vector<cmGeneratorTarget*>::iterator tgtsI = tgts.begin();
- tgtsI != tgts.end(); ++tgtsI) {
- const cmGeneratorTarget* tgt = *tgtsI;
- if (IsTgtForBuild(tgt)) {
- std::string folderName = tgt->GetEffectiveFolderName();
- if (this->TargetFolderBuildStreams.end() ==
- this->TargetFolderBuildStreams.find(folderName)) {
- this->AddFilesUpToPath(
- GetBuildFileStream(), &this->TargetFolderBuildStreams,
- this->GetCMakeInstance()->GetHomeOutputDirectory(), folderName,
- GhsMultiGpj::PROJECT);
- }
- std::vector<cmsys::String> splitPath = cmSystemTools::SplitString(
- cmGhsMultiTargetGenerator::GetRelBuildFileName(tgt));
- std::string foldNameRelBuildFile(*(splitPath.end() - 2) + "/" +
- splitPath.back());
- *this->TargetFolderBuildStreams[folderName] << foldNameRelBuildFile
- << " ";
- GhsMultiGpj::WriteGpjTag(cmGhsMultiTargetGenerator::GetGpjTag(tgt),
- this->TargetFolderBuildStreams[folderName]);
- }
- }
+ this->insert(targets.begin(), targets.end());
}
-bool cmGlobalGhsMultiGenerator::IsTgtForBuild(const cmGeneratorTarget* tgt)
+bool cmGlobalGhsMultiGenerator::ComputeTargetBuildOrder(
+ cmGeneratorTarget const* tgt, std::vector<cmGeneratorTarget const*>& build)
{
- const std::string config =
- tgt->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
- std::vector<cmSourceFile*> tgtSources;
- tgt->GetSourceFiles(tgtSources, config);
- bool tgtInBuild = true;
- char const* excludeFromAll = tgt->GetProperty("EXCLUDE_FROM_ALL");
- if (NULL != excludeFromAll && '1' == excludeFromAll[0] &&
- '\0' == excludeFromAll[1]) {
- tgtInBuild = false;
+ std::vector<cmGeneratorTarget const*> t{ tgt };
+ return ComputeTargetBuildOrder(t, build);
+}
+
+bool cmGlobalGhsMultiGenerator::ComputeTargetBuildOrder(
+ std::vector<cmGeneratorTarget const*>& tgt,
+ std::vector<cmGeneratorTarget const*>& build)
+{
+ std::set<cmGeneratorTarget const*> temp;
+ std::set<cmGeneratorTarget const*> perm;
+
+ for (auto ti : tgt) {
+ bool r = VisitTarget(temp, perm, build, ti);
+ if (r) {
+ return r;
+ }
}
- return !tgtSources.empty() && tgtInBuild;
+ return false;
}
-std::string cmGlobalGhsMultiGenerator::trimQuotes(std::string const& str)
+bool cmGlobalGhsMultiGenerator::VisitTarget(
+ std::set<cmGeneratorTarget const*>& temp,
+ std::set<cmGeneratorTarget const*>& perm,
+ std::vector<cmGeneratorTarget const*>& order, cmGeneratorTarget const* ti)
{
- std::string result;
- result.reserve(str.size());
- for (const char* ch = str.c_str(); *ch != '\0'; ++ch) {
- if (*ch != '"') {
- result += *ch;
+ /* check if permanent mark is set*/
+ if (perm.find(ti) == perm.end()) {
+ /* set temporary mark; check if revisit*/
+ if (temp.insert(ti).second) {
+ /* sort targets lexicographically to ensure that nodes are always visited
+ * in the same order */
+ OrderedTargetDependSet sortedTargets(this->GetTargetDirectDepends(ti),
+ "");
+ for (auto& di : sortedTargets) {
+ if (this->VisitTarget(temp, perm, order, di)) {
+ return true;
+ }
+ }
+ /* mark as complete; insert into beginning of list*/
+ perm.insert(ti);
+ order.push_back(ti);
+ return false;
}
+ /* revisiting item - not a DAG */
+ return true;
}
- return result;
+ /* already complete */
+ return false;
}
diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h
index 7b3eebbdf..ccfe07382 100644
--- a/Source/cmGlobalGhsMultiGenerator.h
+++ b/Source/cmGlobalGhsMultiGenerator.h
@@ -3,35 +3,44 @@
#ifndef cmGhsMultiGenerator_h
#define cmGhsMultiGenerator_h
-#include "cmGlobalGenerator.h"
+#include <iosfwd>
+#include <set>
+#include <string>
+#include <utility>
+#include <vector>
-#include "cmGhsMultiGpj.h"
+#include "cmGlobalGenerator.h"
#include "cmGlobalGeneratorFactory.h"
+#include "cmTargetDepend.h"
-class cmGeneratedFileStream;
+class cmGeneratorTarget;
+class cmLocalGenerator;
+class cmMakefile;
+class cmake;
+struct cmDocumentationEntry;
class cmGlobalGhsMultiGenerator : public cmGlobalGenerator
{
public:
- /// The default name of GHS MULTI's build file. Typically: monolith.gpj.
+ // The default filename extension of GHS MULTI's build files.
static const char* FILE_EXTENSION;
cmGlobalGhsMultiGenerator(cmake* cm);
- ~cmGlobalGhsMultiGenerator();
+ ~cmGlobalGhsMultiGenerator() override;
static cmGlobalGeneratorFactory* NewFactory()
{
return new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>();
}
- ///! create the correct local generator
- virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
+ //! create the correct local generator
+ cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override;
/// @return the name of this generator.
static std::string GetActualName() { return "Green Hills MULTI"; }
- ///! Get the name for this generator
- virtual std::string GetName() const { return this->GetActualName(); }
+ //! Get the name for this generator
+ std::string GetName() const override { return GetActualName(); }
/// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
static void GetDocumentation(cmDocumentationEntry& entry);
@@ -40,94 +49,110 @@ public:
* Utilized by the generator factory to determine if this generator
* supports toolsets.
*/
- static bool SupportsToolset() { return false; }
+ static bool SupportsToolset() { return true; }
/**
* Utilized by the generator factory to determine if this generator
* supports platforms.
*/
- static bool SupportsPlatform() { return false; }
+ static bool SupportsPlatform() { return true; }
+
+ // Toolset / Platform Support
+ bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf) override;
+ bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
/**
- * Try to determine system information such as shared library
- * extension, pthreads, byte order etc.
- */
- virtual void EnableLanguage(std::vector<std::string> const& languages,
- cmMakefile*, bool optional);
+ * Try to determine system information such as shared library
+ * extension, pthreads, byte order etc.
+ */
+ void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
+ bool optional) override;
/*
- * Determine what program to use for building the project.
- */
- bool FindMakeProgram(cmMakefile* mf) CM_OVERRIDE;
+ * Determine what program to use for building the project.
+ */
+ bool FindMakeProgram(cmMakefile* mf) override;
- cmGeneratedFileStream* GetBuildFileStream()
- {
- return this->TargetFolderBuildStreams[""];
- }
+ void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;
+
+ // Write the common disclaimer text at the top of each build file.
+ void WriteFileHeader(std::ostream& fout);
- static void OpenBuildFileStream(std::string const& filepath,
- cmGeneratedFileStream** filestream);
- static void OpenBuildFileStream(cmGeneratedFileStream* filestream);
- static void CloseBuildFileStream(cmGeneratedFileStream** filestream);
- /// Write the common disclaimer text at the top of each build file.
- static void WriteDisclaimer(std::ostream* os);
- std::vector<std::string> GetLibDirs() { return this->LibDirs; }
-
- static void AddFilesUpToPath(
- cmGeneratedFileStream* mainBuildFile,
- std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams,
- char const* homeOutputDirectory, std::string const& path,
- GhsMultiGpj::Types projType, std::string const& relPath = "");
- static void Open(std::string const& mapKeyName, std::string const& fileName,
- std::map<std::string, cmGeneratedFileStream*>* fileMap);
-
- static std::string trimQuotes(std::string const& str);
- inline bool IsOSDirRelative() { return this->OSDirRelative; }
+ const char* GetInstallTargetName() const override { return "install"; }
protected:
- virtual void Generate();
- virtual void GenerateBuildCommand(
- std::vector<std::string>& makeCommand, const std::string& makeProgram,
- const std::string& projectName, const std::string& projectDir,
- const std::string& targetName, const std::string& config, bool fast,
- bool verbose,
- std::vector<std::string> const& makeOptions = std::vector<std::string>());
+ void Generate() override;
+ std::vector<GeneratedMakeCommand> GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions =
+ std::vector<std::string>()) override;
private:
- std::string const& GetGhsBuildCommand();
- std::string FindGhsBuildCommand();
- std::string GetCompRoot();
- std::vector<std::string> GetCompRootHardPaths();
- std::vector<std::string> GetCompRootRegistry();
- void OpenBuildFileStream();
-
- void WriteMacros();
- void WriteHighLevelDirectives();
- void WriteCompilerOptions(std::string const& fOSDir);
-
- static void AddFilesUpToPathNewBuildFile(
- cmGeneratedFileStream* mainBuildFile,
- std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams,
- char const* homeOutputDirectory, std::string const& pathUpTo, bool isFirst,
- std::string const& relPath, GhsMultiGpj::Types projType);
- static void AddFilesUpToPathAppendNextFile(
- std::map<std::string, cmGeneratedFileStream*>* targetFolderBuildStreams,
- std::string const& pathUpTo,
- std::vector<cmsys::String>::const_iterator splitPathI,
- std::vector<cmsys::String>::const_iterator end,
- GhsMultiGpj::Types projType);
- static std::string GetFileNameFromPath(std::string const& path);
- void UpdateBuildFiles(std::vector<cmGeneratorTarget*> tgts);
- bool IsTgtForBuild(const cmGeneratorTarget* tgt);
-
- std::vector<cmGeneratedFileStream*> TargetSubProjects;
- std::map<std::string, cmGeneratedFileStream*> TargetFolderBuildStreams;
-
- std::vector<std::string> LibDirs;
-
- bool OSDirRelative;
- bool GhsBuildCommandInitialized;
- std::string GhsBuildCommand;
- static const char* DEFAULT_MAKE_PROGRAM;
+ void GetToolset(cmMakefile* mf, std::string& tsd, const std::string& ts);
+
+ /* top-level project */
+ void OutputTopLevelProject(cmLocalGenerator* root,
+ std::vector<cmLocalGenerator*>& generators);
+ void WriteTopLevelProject(std::ostream& fout, cmLocalGenerator* root);
+ void WriteMacros(std::ostream& fout, cmLocalGenerator* root);
+ void WriteHighLevelDirectives(cmLocalGenerator* root, std::ostream& fout);
+ void WriteSubProjects(std::ostream& fout, std::string& all_target);
+ void WriteTargets(cmLocalGenerator* root);
+ void WriteProjectLine(std::ostream& fout, cmGeneratorTarget const* target,
+ cmLocalGenerator* root, std::string& rootBinaryDir);
+ void WriteCustomRuleBOD(std::ostream& fout);
+ void WriteCustomTargetBOD(std::ostream& fout);
+ void WriteAllTarget(cmLocalGenerator* root,
+ std::vector<cmLocalGenerator*>& generators,
+ std::string& all_target);
+
+ std::string TrimQuotes(std::string const& str);
+
+ std::string OsDir;
+ static const char* DEFAULT_BUILD_PROGRAM;
+ static const char* DEFAULT_TOOLSET_ROOT;
+
+ bool ComputeTargetBuildOrder(cmGeneratorTarget const* tgt,
+ std::vector<cmGeneratorTarget const*>& build);
+ bool ComputeTargetBuildOrder(std::vector<cmGeneratorTarget const*>& tgt,
+ std::vector<cmGeneratorTarget const*>& build);
+ bool VisitTarget(std::set<cmGeneratorTarget const*>& temp,
+ std::set<cmGeneratorTarget const*>& perm,
+ std::vector<cmGeneratorTarget const*>& order,
+ cmGeneratorTarget const* ti);
+
+ std::vector<cmGeneratorTarget const*> ProjectTargets;
+
+ // Target sorting
+ class TargetSet : public std::set<cmGeneratorTarget const*>
+ {
+ };
+ class TargetCompare
+ {
+ std::string First;
+
+ public:
+ TargetCompare(std::string first)
+ : First(std::move(first))
+ {
+ }
+ bool operator()(cmGeneratorTarget const* l,
+ cmGeneratorTarget const* r) const;
+ };
+ class OrderedTargetDependSet;
+};
+
+class cmGlobalGhsMultiGenerator::OrderedTargetDependSet
+ : public std::multiset<cmTargetDepend,
+ cmGlobalGhsMultiGenerator::TargetCompare>
+{
+ using derived =
+ std::multiset<cmTargetDepend, cmGlobalGhsMultiGenerator::TargetCompare>;
+
+public:
+ using TargetDependSet = cmGlobalGenerator::TargetDependSet;
+ OrderedTargetDependSet(TargetDependSet const&, std::string const& first);
};
#endif
diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx
index 18c45e0d8..ff5428868 100644
--- a/Source/cmGlobalJOMMakefileGenerator.cxx
+++ b/Source/cmGlobalJOMMakefileGenerator.cxx
@@ -6,6 +6,7 @@
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
#include "cmState.h"
+#include "cmake.h"
cmGlobalJOMMakefileGenerator::cmGlobalJOMMakefileGenerator(cmake* cm)
: cmGlobalUnixMakefileGenerator3(cm)
@@ -52,3 +53,29 @@ void cmGlobalJOMMakefileGenerator::PrintCompilerAdvice(
}
this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar);
}
+
+std::vector<cmGlobalGenerator::GeneratedMakeCommand>
+cmGlobalJOMMakefileGenerator::GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions)
+{
+ std::vector<std::string> jomMakeOptions;
+
+ // Since we have full control over the invocation of JOM, let us
+ // make it quiet.
+ jomMakeOptions.push_back(this->MakeSilentFlag);
+ cmAppend(jomMakeOptions, makeOptions);
+
+ // JOM does parallel builds by default, the -j is only needed if a specific
+ // number is given
+ // see https://github.com/qt-labs/jom/blob/v1.1.2/src/jomlib/options.cpp
+ if (jobs == cmake::DEFAULT_BUILD_PARALLEL_LEVEL) {
+ jobs = cmake::NO_BUILD_PARALLEL_LEVEL;
+ }
+
+ return cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
+ makeProgram, projectName, projectDir, targetNames, config, fast, jobs,
+ verbose, jomMakeOptions);
+}
diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h
index 2e8ee2939..fc39ddf42 100644
--- a/Source/cmGlobalJOMMakefileGenerator.h
+++ b/Source/cmGlobalJOMMakefileGenerator.h
@@ -3,6 +3,8 @@
#ifndef cmGlobalJOMMakefileGenerator_h
#define cmGlobalJOMMakefileGenerator_h
+#include <iosfwd>
+
#include "cmGlobalUnixMakefileGenerator3.h"
/** \class cmGlobalJOMMakefileGenerator
@@ -18,8 +20,8 @@ public:
{
return new cmGlobalGeneratorSimpleFactory<cmGlobalJOMMakefileGenerator>();
}
- ///! Get the name for the generator.
- virtual std::string GetName() const
+ //! Get the name for the generator.
+ std::string GetName() const override
{
return cmGlobalJOMMakefileGenerator::GetActualName();
}
@@ -34,12 +36,20 @@ public:
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
*/
- virtual void EnableLanguage(std::vector<std::string> const& languages,
- cmMakefile*, bool optional);
+ void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
+ bool optional) override;
+
+protected:
+ std::vector<GeneratedMakeCommand> GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions =
+ std::vector<std::string>()) override;
private:
void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
- const char* envVar) const;
+ const char* envVar) const override;
};
#endif
diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx
deleted file mode 100644
index e72c6e384..000000000
--- a/Source/cmGlobalKdevelopGenerator.cxx
+++ /dev/null
@@ -1,606 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmGlobalKdevelopGenerator.h"
-
-#include "cmGeneratedFileStream.h"
-#include "cmGeneratorTarget.h"
-#include "cmGlobalGenerator.h"
-#include "cmLocalGenerator.h"
-#include "cmMakefile.h"
-#include "cmSourceFile.h"
-#include "cmStateTypes.h"
-#include "cmSystemTools.h"
-#include "cmTarget.h"
-#include "cmXMLWriter.h"
-#include "cmake.h"
-
-#include "cmsys/Directory.hxx"
-#include "cmsys/FStream.hxx"
-#include <map>
-#include <set>
-#include <string.h>
-#include <utility>
-
-cmGlobalKdevelopGenerator::cmGlobalKdevelopGenerator()
- : cmExternalMakefileProjectGenerator()
-{
-}
-
-cmExternalMakefileProjectGeneratorFactory*
-cmGlobalKdevelopGenerator::GetFactory()
-{
- static cmExternalMakefileProjectGeneratorSimpleFactory<
- cmGlobalKdevelopGenerator>
- factory("KDevelop3", "Generates KDevelop 3 project files.");
-
- if (factory.GetSupportedGlobalGenerators().empty()) {
- factory.AddSupportedGlobalGenerator("Unix Makefiles");
-#ifdef CMAKE_USE_NINJA
- factory.AddSupportedGlobalGenerator("Ninja");
-#endif
-
- factory.Aliases.push_back("KDevelop3");
- }
-
- return &factory;
-}
-
-void cmGlobalKdevelopGenerator::Generate()
-{
- // for each sub project in the project create
- // a kdevelop project
- for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
- it = this->GlobalGenerator->GetProjectMap().begin();
- it != this->GlobalGenerator->GetProjectMap().end(); ++it) {
- std::string outputDir = it->second[0]->GetCurrentBinaryDirectory();
- std::string projectDir = it->second[0]->GetSourceDirectory();
- std::string projectName = it->second[0]->GetProjectName();
- std::string cmakeFilePattern("CMakeLists.txt;*.cmake;");
- std::string fileToOpen;
- const std::vector<cmLocalGenerator*>& lgs = it->second;
- // create the project.kdevelop.filelist file
- if (!this->CreateFilelistFile(lgs, outputDir, projectDir, projectName,
- cmakeFilePattern, fileToOpen)) {
- cmSystemTools::Error("Can not create filelist file");
- return;
- }
- // try to find the name of an executable so we have something to
- // run from kdevelop for now just pick the first executable found
- std::string executable;
- for (std::vector<cmLocalGenerator*>::const_iterator lg = lgs.begin();
- lg != lgs.end(); lg++) {
- std::vector<cmGeneratorTarget*> const& targets =
- (*lg)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti =
- targets.begin();
- ti != targets.end(); ti++) {
- if ((*ti)->GetType() == cmStateEnums::EXECUTABLE) {
- executable = (*ti)->GetLocation("");
- break;
- }
- }
- if (!executable.empty()) {
- break;
- }
- }
-
- // now create a project file
- this->CreateProjectFile(outputDir, projectDir, projectName, executable,
- cmakeFilePattern, fileToOpen);
- }
-}
-
-bool cmGlobalKdevelopGenerator::CreateFilelistFile(
- const std::vector<cmLocalGenerator*>& lgs, const std::string& outputDir,
- const std::string& projectDirIn, const std::string& projectname,
- std::string& cmakeFilePattern, std::string& fileToOpen)
-{
- std::string projectDir = projectDirIn + "/";
- std::string filename = outputDir + "/" + projectname + ".kdevelop.filelist";
-
- std::set<std::string> files;
- std::string tmp;
-
- std::vector<std::string> const& hdrExts =
- this->GlobalGenerator->GetCMakeInstance()->GetHeaderExtensions();
-
- for (std::vector<cmLocalGenerator*>::const_iterator it = lgs.begin();
- it != lgs.end(); it++) {
- cmMakefile* makefile = (*it)->GetMakefile();
- const std::vector<std::string>& listFiles = makefile->GetListFiles();
- for (std::vector<std::string>::const_iterator lt = listFiles.begin();
- lt != listFiles.end(); lt++) {
- tmp = *lt;
- cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
- // make sure the file is part of this source tree
- if ((tmp[0] != '/') &&
- (strstr(tmp.c_str(), cmake::GetCMakeFilesDirectoryPostSlash()) ==
- CM_NULLPTR)) {
- files.insert(tmp);
- tmp = cmSystemTools::GetFilenameName(tmp);
- // add all files which dont match the default
- // */CMakeLists.txt;*cmake; to the file pattern
- if ((tmp != "CMakeLists.txt") &&
- (strstr(tmp.c_str(), ".cmake") == CM_NULLPTR)) {
- cmakeFilePattern += tmp + ";";
- }
- }
- }
-
- // get all sources
- std::vector<cmGeneratorTarget*> targets = (*it)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
- ti != targets.end(); ti++) {
- std::vector<cmSourceFile*> sources;
- cmGeneratorTarget* gt = *ti;
- gt->GetSourceFiles(sources, gt->Target->GetMakefile()->GetSafeDefinition(
- "CMAKE_BUILD_TYPE"));
- for (std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); si++) {
- tmp = (*si)->GetFullPath();
- std::string headerBasename = cmSystemTools::GetFilenamePath(tmp);
- headerBasename += "/";
- headerBasename += cmSystemTools::GetFilenameWithoutExtension(tmp);
-
- cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
-
- if ((tmp[0] != '/') &&
- (strstr(tmp.c_str(), cmake::GetCMakeFilesDirectoryPostSlash()) ==
- CM_NULLPTR) &&
- (cmSystemTools::GetFilenameExtension(tmp) != ".moc")) {
- files.insert(tmp);
-
- // check if there's a matching header around
- for (std::vector<std::string>::const_iterator ext = hdrExts.begin();
- ext != hdrExts.end(); ++ext) {
- std::string hname = headerBasename;
- hname += ".";
- hname += *ext;
- if (cmSystemTools::FileExists(hname.c_str())) {
- cmSystemTools::ReplaceString(hname, projectDir.c_str(), "");
- files.insert(hname);
- break;
- }
- }
- }
- }
- for (std::vector<std::string>::const_iterator lt = listFiles.begin();
- lt != listFiles.end(); lt++) {
- tmp = *lt;
- cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
- if ((tmp[0] != '/') &&
- (strstr(tmp.c_str(), cmake::GetCMakeFilesDirectoryPostSlash()) ==
- CM_NULLPTR)) {
- files.insert(tmp);
- }
- }
- }
- }
-
- // check if the output file already exists and read it
- // insert all files which exist into the set of files
- cmsys::ifstream oldFilelist(filename.c_str());
- if (oldFilelist) {
- while (cmSystemTools::GetLineFromStream(oldFilelist, tmp)) {
- if (tmp[0] == '/') {
- continue;
- }
- std::string completePath = projectDir + tmp;
- if (cmSystemTools::FileExists(completePath.c_str())) {
- files.insert(tmp);
- }
- }
- oldFilelist.close();
- }
-
- // now write the new filename
- cmGeneratedFileStream fout(filename.c_str());
- if (!fout) {
- return false;
- }
-
- fileToOpen = "";
- for (std::set<std::string>::const_iterator it = files.begin();
- it != files.end(); it++) {
- // get the full path to the file
- tmp = cmSystemTools::CollapseFullPath(*it, projectDir.c_str());
- // just select the first source file
- if (fileToOpen.empty()) {
- std::string ext = cmSystemTools::GetFilenameExtension(tmp);
- if ((ext == ".c") || (ext == ".cc") || (ext == ".cpp") ||
- (ext == ".cxx") || (ext == ".C") || (ext == ".h") ||
- (ext == ".hpp")) {
- fileToOpen = tmp;
- }
- }
- // make it relative to the project dir
- cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
- // only put relative paths
- if (!tmp.empty() && tmp[0] != '/') {
- fout << tmp << "\n";
- }
- }
- return true;
-}
-
-/* create the project file, if it already exists, merge it with the
-existing one, otherwise create a new one */
-void cmGlobalKdevelopGenerator::CreateProjectFile(
- const std::string& outputDir, const std::string& projectDir,
- const std::string& projectname, const std::string& executable,
- const std::string& cmakeFilePattern, const std::string& fileToOpen)
-{
- this->Blacklist.clear();
-
- std::string filename = outputDir + "/";
- filename += projectname + ".kdevelop";
- std::string sessionFilename = outputDir + "/";
- sessionFilename += projectname + ".kdevses";
-
- if (cmSystemTools::FileExists(filename.c_str())) {
- this->MergeProjectFiles(outputDir, projectDir, filename, executable,
- cmakeFilePattern, fileToOpen, sessionFilename);
- } else {
- // add all subdirectories which are cmake build directories to the
- // kdevelop blacklist so they are not monitored for added or removed files
- // since this is handled by adding files to the cmake files
- cmsys::Directory d;
- if (d.Load(projectDir)) {
- size_t numf = d.GetNumberOfFiles();
- for (unsigned int i = 0; i < numf; i++) {
- std::string nextFile = d.GetFile(i);
- if ((nextFile != ".") && (nextFile != "..")) {
- std::string tmp = projectDir;
- tmp += "/";
- tmp += nextFile;
- if (cmSystemTools::FileIsDirectory(tmp)) {
- tmp += "/CMakeCache.txt";
- if ((nextFile == "CMakeFiles") ||
- (cmSystemTools::FileExists(tmp.c_str()))) {
- this->Blacklist.push_back(nextFile);
- }
- }
- }
- }
- }
- this->CreateNewProjectFile(outputDir, projectDir, filename, executable,
- cmakeFilePattern, fileToOpen, sessionFilename);
- }
-}
-
-void cmGlobalKdevelopGenerator::MergeProjectFiles(
- const std::string& outputDir, const std::string& projectDir,
- const std::string& filename, const std::string& executable,
- const std::string& cmakeFilePattern, const std::string& fileToOpen,
- const std::string& sessionFilename)
-{
- cmsys::ifstream oldProjectFile(filename.c_str());
- if (!oldProjectFile) {
- this->CreateNewProjectFile(outputDir, projectDir, filename, executable,
- cmakeFilePattern, fileToOpen, sessionFilename);
- return;
- }
-
- /* Read the existing project file (line by line), copy all lines
- into the new project file, except the ones which can be reliably
- set from contents of the CMakeLists.txt */
- std::string tmp;
- std::vector<std::string> lines;
- while (cmSystemTools::GetLineFromStream(oldProjectFile, tmp)) {
- lines.push_back(tmp);
- }
- oldProjectFile.close();
-
- cmGeneratedFileStream fout(filename.c_str());
- if (!fout) {
- return;
- }
-
- for (std::vector<std::string>::const_iterator it = lines.begin();
- it != lines.end(); it++) {
- const char* line = (*it).c_str();
- // skip these tags as they are always replaced
- if ((strstr(line, "<projectdirectory>") != CM_NULLPTR) ||
- (strstr(line, "<projectmanagement>") != CM_NULLPTR) ||
- (strstr(line, "<absoluteprojectpath>") != CM_NULLPTR) ||
- (strstr(line, "<filelistdirectory>") != CM_NULLPTR) ||
- (strstr(line, "<buildtool>") != CM_NULLPTR) ||
- (strstr(line, "<builddir>") != CM_NULLPTR)) {
- continue;
- }
-
- // output the line from the file if it is not one of the above tags
- fout << *it << "\n";
- // if this is the <general> tag output the stuff that goes in the
- // general tag
- if (strstr(line, "<general>")) {
- fout << " <projectmanagement>KDevCustomProject</projectmanagement>\n";
- fout << " <projectdirectory>" << projectDir
- << "</projectdirectory>\n"; // this one is important
- fout << " <absoluteprojectpath>true</absoluteprojectpath>\n";
- // and this one
- }
- // inside kdevcustomproject the <filelistdirectory> must be put
- if (strstr(line, "<kdevcustomproject>")) {
- fout << " <filelistdirectory>" << outputDir
- << "</filelistdirectory>\n";
- }
- // buildtool and builddir go inside <build>
- if (strstr(line, "<build>")) {
- fout << " <buildtool>make</buildtool>\n";
- fout << " <builddir>" << outputDir << "</builddir>\n";
- }
- }
-}
-
-void cmGlobalKdevelopGenerator::CreateNewProjectFile(
- const std::string& outputDir, const std::string& projectDir,
- const std::string& filename, const std::string& executable,
- const std::string& cmakeFilePattern, const std::string& fileToOpen,
- const std::string& sessionFilename)
-{
- cmGeneratedFileStream fout(filename.c_str());
- if (!fout) {
- return;
- }
- cmXMLWriter xml(fout);
-
- // check for a version control system
- bool hasSvn = cmSystemTools::FileExists((projectDir + "/.svn").c_str());
- bool hasCvs = cmSystemTools::FileExists((projectDir + "/CVS").c_str());
-
- bool enableCxx = (this->GlobalGenerator->GetLanguageEnabled("C") ||
- this->GlobalGenerator->GetLanguageEnabled("CXX"));
- bool enableFortran = this->GlobalGenerator->GetLanguageEnabled("Fortran");
- std::string primaryLanguage = "C++";
- if (enableFortran && !enableCxx) {
- primaryLanguage = "Fortran77";
- }
-
- xml.StartDocument();
- xml.StartElement("kdevelop");
- xml.StartElement("general");
-
- xml.Element("author", "");
- xml.Element("email", "");
- xml.Element("version", "$VERSION$");
- xml.Element("projectmanagement", "KDevCustomProject");
- xml.Element("primarylanguage", primaryLanguage);
- xml.Element("ignoreparts");
- xml.Element("projectdirectory", projectDir); // this one is important
- xml.Element("absoluteprojectpath", "true"); // and this one
-
- // setup additional languages
- xml.StartElement("secondaryLanguages");
- if (enableFortran && enableCxx) {
- xml.Element("language", "Fortran");
- }
- if (enableCxx) {
- xml.Element("language", "C");
- }
- xml.EndElement();
-
- if (hasSvn) {
- xml.Element("versioncontrol", "kdevsubversion");
- } else if (hasCvs) {
- xml.Element("versioncontrol", "kdevcvsservice");
- }
-
- xml.EndElement(); // general
- xml.StartElement("kdevcustomproject");
-
- xml.Element("filelistdirectory", outputDir);
-
- xml.StartElement("run");
- xml.Element("mainprogram", executable);
- xml.Element("directoryradio", "custom");
- xml.Element("customdirectory", outputDir);
- xml.Element("programargs", "");
- xml.Element("terminal", "false");
- xml.Element("autocompile", "true");
- xml.Element("envvars");
- xml.EndElement();
-
- xml.StartElement("build");
- xml.Element("buildtool", "make"); // this one is important
- xml.Element("builddir", outputDir); // and this one
- xml.EndElement();
-
- xml.StartElement("make");
- xml.Element("abortonerror", "false");
- xml.Element("numberofjobs", 1);
- xml.Element("dontact", "false");
- xml.Element("makebin", this->GlobalGenerator->GetLocalGenerators()[0]
- ->GetMakefile()
- ->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"));
- xml.Element("selectedenvironment", "default");
-
- xml.StartElement("environments");
- xml.StartElement("default");
-
- xml.StartElement("envvar");
- xml.Attribute("value", 1);
- xml.Attribute("name", "VERBOSE");
- xml.EndElement();
-
- xml.StartElement("envvar");
- xml.Attribute("value", 1);
- xml.Attribute("name", "CMAKE_NO_VERBOSE");
- xml.EndElement();
-
- xml.EndElement(); // default
- xml.EndElement(); // environments
- xml.EndElement(); // make
-
- xml.StartElement("blacklist");
- for (std::vector<std::string>::const_iterator dirIt =
- this->Blacklist.begin();
- dirIt != this->Blacklist.end(); ++dirIt) {
- xml.Element("path", *dirIt);
- }
- xml.EndElement();
-
- xml.EndElement(); // kdevcustomproject
-
- xml.StartElement("kdevfilecreate");
- xml.Element("filetypes");
- xml.StartElement("useglobaltypes");
-
- xml.StartElement("type");
- xml.Attribute("ext", "ui");
- xml.EndElement();
-
- xml.StartElement("type");
- xml.Attribute("ext", "cpp");
- xml.EndElement();
-
- xml.StartElement("type");
- xml.Attribute("ext", "h");
- xml.EndElement();
-
- xml.EndElement(); // useglobaltypes
- xml.EndElement(); // kdevfilecreate
-
- xml.StartElement("kdevdoctreeview");
- xml.StartElement("projectdoc");
- xml.Element("userdocDir", "html/");
- xml.Element("apidocDir", "html/");
- xml.EndElement(); // projectdoc
- xml.Element("ignoreqt_xml");
- xml.Element("ignoredoxygen");
- xml.Element("ignorekdocs");
- xml.Element("ignoretocs");
- xml.Element("ignoredevhelp");
- xml.EndElement(); // kdevdoctreeview;
-
- if (enableCxx) {
- xml.StartElement("cppsupportpart");
- xml.StartElement("filetemplates");
- xml.Element("interfacesuffix", ".h");
- xml.Element("implementationsuffix", ".cpp");
- xml.EndElement(); // filetemplates
- xml.EndElement(); // cppsupportpart
-
- xml.StartElement("kdevcppsupport");
- xml.StartElement("codecompletion");
- xml.Element("includeGlobalFunctions", "true");
- xml.Element("includeTypes", "true");
- xml.Element("includeEnums", "true");
- xml.Element("includeTypedefs", "false");
- xml.Element("automaticCodeCompletion", "true");
- xml.Element("automaticArgumentsHint", "true");
- xml.Element("automaticHeaderCompletion", "true");
- xml.Element("codeCompletionDelay", 250);
- xml.Element("argumentsHintDelay", 400);
- xml.Element("headerCompletionDelay", 250);
- xml.EndElement(); // codecompletion
- xml.Element("references");
- xml.EndElement(); // kdevcppsupport;
- }
-
- if (enableFortran) {
- xml.StartElement("kdevfortransupport");
- xml.StartElement("ftnchek");
- xml.Element("division", "false");
- xml.Element("extern", "false");
- xml.Element("declare", "false");
- xml.Element("pure", "false");
- xml.Element("argumentsall", "false");
- xml.Element("commonall", "false");
- xml.Element("truncationall", "false");
- xml.Element("usageall", "false");
- xml.Element("f77all", "false");
- xml.Element("portabilityall", "false");
- xml.Element("argumentsonly");
- xml.Element("commononly");
- xml.Element("truncationonly");
- xml.Element("usageonly");
- xml.Element("f77only");
- xml.Element("portabilityonly");
- xml.EndElement(); // ftnchek
- xml.EndElement(); // kdevfortransupport;
- }
-
- // set up file groups. maybe this can be used with the CMake SOURCE_GROUP()
- // command
- xml.StartElement("kdevfileview");
- xml.StartElement("groups");
-
- xml.StartElement("group");
- xml.Attribute("pattern", cmakeFilePattern);
- xml.Attribute("name", "CMake");
- xml.EndElement();
-
- if (enableCxx) {
- xml.StartElement("group");
- xml.Attribute("pattern", "*.h;*.hxx;*.hpp");
- xml.Attribute("name", "Header");
- xml.EndElement();
-
- xml.StartElement("group");
- xml.Attribute("pattern", "*.c");
- xml.Attribute("name", "C Sources");
- xml.EndElement();
-
- xml.StartElement("group");
- xml.Attribute("pattern", "*.cpp;*.C;*.cxx;*.cc");
- xml.Attribute("name", "C++ Sources");
- xml.EndElement();
- }
-
- if (enableFortran) {
- xml.StartElement("group");
- xml.Attribute("pattern",
- "*.f;*.F;*.f77;*.F77;*.f90;*.F90;*.for;*.f95;*.F95");
- xml.Attribute("name", "Fortran Sources");
- xml.EndElement();
- }
-
- xml.StartElement("group");
- xml.Attribute("pattern", "*.ui");
- xml.Attribute("name", "Qt Designer files");
- xml.EndElement();
-
- xml.Element("hidenonprojectfiles", "true");
- xml.EndElement(); // groups
-
- xml.StartElement("tree");
- xml.Element("hidepatterns", "*.o,*.lo,CVS,*~,cmake*");
- xml.Element("hidenonprojectfiles", "true");
- xml.EndElement(); // tree
-
- xml.EndElement(); // kdevfileview
- xml.EndElement(); // kdevelop;
- xml.EndDocument();
-
- if (sessionFilename.empty()) {
- return;
- }
-
- // and a session file, so that kdevelop opens a file if it opens the
- // project the first time
- cmGeneratedFileStream devses(sessionFilename.c_str());
- if (!devses) {
- return;
- }
- cmXMLWriter sesxml(devses);
- sesxml.StartDocument("UTF-8");
- sesxml.Doctype("KDevPrjSession");
- sesxml.StartElement("KDevPrjSession");
-
- sesxml.StartElement("DocsAndViews");
- sesxml.Attribute("NumberOfDocuments", 1);
-
- sesxml.StartElement("Doc0");
- sesxml.Attribute("NumberOfViews", 1);
- sesxml.Attribute("URL", "file://" + fileToOpen);
-
- sesxml.StartElement("View0");
- sesxml.Attribute("line", 0);
- sesxml.Attribute("Type", "Source");
- sesxml.EndElement(); // View0
-
- sesxml.EndElement(); // Doc0
- sesxml.EndElement(); // DocsAndViews
- sesxml.EndElement(); // KDevPrjSession;
-}
diff --git a/Source/cmGlobalKdevelopGenerator.h b/Source/cmGlobalKdevelopGenerator.h
deleted file mode 100644
index bdcf8a190..000000000
--- a/Source/cmGlobalKdevelopGenerator.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmGlobalKdevelopGenerator_h
-#define cmGlobalKdevelopGenerator_h
-
-#include "cmConfigure.h"
-
-#include "cmExternalMakefileProjectGenerator.h"
-
-#include <string>
-#include <vector>
-
-class cmLocalGenerator;
-
-/** \class cmGlobalKdevelopGenerator
- * \brief Write Unix Makefiles accompanied by KDevelop3 project files.
- *
- * cmGlobalKdevelopGenerator produces a project file for KDevelop 3 (KDevelop
- * > 3.1.1). The project is based on the "Custom Makefile based C/C++"
- * project of KDevelop. Such a project consists of Unix Makefiles in the
- * build directory together with a \<your_project\>.kdevelop project file,
- * which contains the project settings and a \<your_project\>.kdevelop.filelist
- * file, which lists the source files relative to the kdevelop project
- * directory. The kdevelop project directory is the base source directory.
- */
-class cmGlobalKdevelopGenerator : public cmExternalMakefileProjectGenerator
-{
-public:
- cmGlobalKdevelopGenerator();
-
- static cmExternalMakefileProjectGeneratorFactory* GetFactory();
-
- void Generate() CM_OVERRIDE;
-
-private:
- /*** Create the foo.kdevelop.filelist file, return false if it doesn't
- succeed. If the file already exists the contents will be merged.
- */
- bool CreateFilelistFile(const std::vector<cmLocalGenerator*>& lgs,
- const std::string& outputDir,
- const std::string& projectDirIn,
- const std::string& projectname,
- std::string& cmakeFilePattern,
- std::string& fileToOpen);
-
- /** Create the foo.kdevelop file. This one calls MergeProjectFiles()
- if it already exists, otherwise createNewProjectFile() The project
- files will be created in \a outputDir (in the build tree), the
- kdevelop project dir will be set to \a projectDir (in the source
- tree). \a cmakeFilePattern consists of a lists of all cmake
- listfiles used by this CMakeLists.txt */
- void CreateProjectFile(const std::string& outputDir,
- const std::string& projectDir,
- const std::string& projectname,
- const std::string& executable,
- const std::string& cmakeFilePattern,
- const std::string& fileToOpen);
-
- /*** Reads the old foo.kdevelop line by line and only replaces the
- "important" lines
- */
- void MergeProjectFiles(const std::string& outputDir,
- const std::string& projectDir,
- const std::string& filename,
- const std::string& executable,
- const std::string& cmakeFilePattern,
- const std::string& fileToOpen,
- const std::string& sessionFilename);
- ///! Creates a new foo.kdevelop and a new foo.kdevses file
- void CreateNewProjectFile(const std::string& outputDir,
- const std::string& projectDir,
- const std::string& filename,
- const std::string& executable,
- const std::string& cmakeFilePattern,
- const std::string& fileToOpen,
- const std::string& sessionFilename);
-
- std::vector<std::string> Blacklist;
-};
-
-#endif
diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx
index 3f223824a..ae9d5a768 100644
--- a/Source/cmGlobalMSYSMakefileGenerator.cxx
+++ b/Source/cmGlobalMSYSMakefileGenerator.cxx
@@ -7,6 +7,7 @@
#include "cmDocumentationEntry.h"
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmState.h"
#include "cmake.h"
@@ -23,8 +24,7 @@ cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator(cmake* cm)
std::string cmGlobalMSYSMakefileGenerator::FindMinGW(
std::string const& makeloc)
{
- std::string fstab = makeloc;
- fstab += "/../etc/fstab";
+ std::string fstab = cmStrCat(makeloc, "/../etc/fstab");
cmsys::ifstream fin(fstab.c_str());
std::string path;
std::string mount;
@@ -33,8 +33,7 @@ std::string cmGlobalMSYSMakefileGenerator::FindMinGW(
fin >> path;
fin >> mount;
if (mount == "/mingw") {
- mingwBin = path;
- mingwBin += "/bin";
+ mingwBin = cmStrCat(path, "/bin");
}
}
return mingwBin;
@@ -44,9 +43,10 @@ void cmGlobalMSYSMakefileGenerator::EnableLanguage(
std::vector<std::string> const& l, cmMakefile* mf, bool optional)
{
this->FindMakeProgram(mf);
- std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
+ const std::string& makeProgram =
+ mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
std::vector<std::string> locations;
- std::string makeloc = cmSystemTools::GetProgramPath(makeProgram.c_str());
+ std::string makeloc = cmSystemTools::GetProgramPath(makeProgram);
locations.push_back(this->FindMinGW(makeloc));
locations.push_back(makeloc);
locations.push_back("/mingw/bin");
@@ -67,16 +67,16 @@ void cmGlobalMSYSMakefileGenerator::EnableLanguage(
rc = trc;
}
mf->AddDefinition("MSYS", "1");
- mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str());
- mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
- mf->AddDefinition("CMAKE_GENERATOR_RC", rc.c_str());
+ mf->AddDefinition("CMAKE_GENERATOR_CC", gcc);
+ mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx);
+ mf->AddDefinition("CMAKE_GENERATOR_RC", rc);
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
if (!mf->IsSet("CMAKE_AR") && !this->CMakeInstance->GetIsInTryCompile() &&
!(1 == l.size() && l[0] == "NONE")) {
cmSystemTools::Error(
- "CMAKE_AR was not found, please set to archive program. ",
- mf->GetDefinition("CMAKE_AR"));
+ "CMAKE_AR was not found, please set to archive program. " +
+ mf->GetSafeDefinition("CMAKE_AR"));
}
}
diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h
index 23dbc5e31..d6e4847fe 100644
--- a/Source/cmGlobalMSYSMakefileGenerator.h
+++ b/Source/cmGlobalMSYSMakefileGenerator.h
@@ -19,7 +19,7 @@ public:
return new cmGlobalGeneratorSimpleFactory<cmGlobalMSYSMakefileGenerator>();
}
- ///! Get the name for the generator.
+ //! Get the name for the generator.
virtual std::string GetName() const
{
return cmGlobalMSYSMakefileGenerator::GetActualName();
diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx
index 3c3a5d1dc..d9fc50530 100644
--- a/Source/cmGlobalMinGWMakefileGenerator.cxx
+++ b/Source/cmGlobalMinGWMakefileGenerator.cxx
@@ -6,6 +6,7 @@
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
#include "cmState.h"
+#include "cmake.h"
cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator(cmake* cm)
: cmGlobalUnixMakefileGenerator3(cm)
@@ -22,7 +23,8 @@ void cmGlobalMinGWMakefileGenerator::EnableLanguage(
std::vector<std::string> const& l, cmMakefile* mf, bool optional)
{
this->FindMakeProgram(mf);
- std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
+ const std::string& makeProgram =
+ mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
std::vector<std::string> locations;
locations.push_back(cmSystemTools::GetProgramPath(makeProgram));
locations.push_back("/mingw/bin");
@@ -42,9 +44,9 @@ void cmGlobalMinGWMakefileGenerator::EnableLanguage(
if (!trc.empty()) {
rc = trc;
}
- mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str());
- mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
- mf->AddDefinition("CMAKE_GENERATOR_RC", rc.c_str());
+ mf->AddDefinition("CMAKE_GENERATOR_CC", gcc);
+ mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx);
+ mf->AddDefinition("CMAKE_GENERATOR_RC", rc);
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
}
diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h
index a994c9295..15297e3c7 100644
--- a/Source/cmGlobalMinGWMakefileGenerator.h
+++ b/Source/cmGlobalMinGWMakefileGenerator.h
@@ -19,7 +19,7 @@ public:
return new cmGlobalGeneratorSimpleFactory<
cmGlobalMinGWMakefileGenerator>();
}
- ///! Get the name for the generator.
+ //! Get the name for the generator.
virtual std::string GetName() const
{
return cmGlobalMinGWMakefileGenerator::GetActualName();
diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx
index da683fb39..2273c00ac 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.cxx
+++ b/Source/cmGlobalNMakeMakefileGenerator.cxx
@@ -6,6 +6,7 @@
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
#include "cmState.h"
+#include "cmake.h"
cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator(cmake* cm)
: cmGlobalUnixMakefileGenerator3(cm)
@@ -52,3 +53,40 @@ void cmGlobalNMakeMakefileGenerator::PrintCompilerAdvice(
}
this->cmGlobalUnixMakefileGenerator3::PrintCompilerAdvice(os, lang, envVar);
}
+
+std::vector<cmGlobalGenerator::GeneratedMakeCommand>
+cmGlobalNMakeMakefileGenerator::GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int /*jobs*/, bool verbose,
+ std::vector<std::string> const& makeOptions)
+{
+ std::vector<std::string> nmakeMakeOptions;
+
+ // Since we have full control over the invocation of nmake, let us
+ // make it quiet.
+ nmakeMakeOptions.push_back(this->MakeSilentFlag);
+ cmAppend(nmakeMakeOptions, makeOptions);
+
+ return this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
+ makeProgram, projectName, projectDir, targetNames, config, fast,
+ cmake::NO_BUILD_PARALLEL_LEVEL, verbose, nmakeMakeOptions);
+}
+
+void cmGlobalNMakeMakefileGenerator::PrintBuildCommandAdvice(std::ostream& os,
+ int jobs) const
+{
+ if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
+ // nmake does not support parallel build level
+ // see https://msdn.microsoft.com/en-us/library/afyyse50.aspx
+
+ /* clang-format off */
+ os <<
+ "Warning: NMake does not support parallel builds. "
+ "Ignoring parallel build command line option.\n";
+ /* clang-format on */
+ }
+
+ this->cmGlobalUnixMakefileGenerator3::PrintBuildCommandAdvice(
+ os, cmake::NO_BUILD_PARALLEL_LEVEL);
+}
diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h
index 6eb21249d..4586b77b1 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.h
+++ b/Source/cmGlobalNMakeMakefileGenerator.h
@@ -3,6 +3,8 @@
#ifndef cmGlobalNMakeMakefileGenerator_h
#define cmGlobalNMakeMakefileGenerator_h
+#include <iosfwd>
+
#include "cmGlobalUnixMakefileGenerator3.h"
/** \class cmGlobalNMakeMakefileGenerator
@@ -19,15 +21,15 @@ public:
return new cmGlobalGeneratorSimpleFactory<
cmGlobalNMakeMakefileGenerator>();
}
- ///! Get the name for the generator.
- virtual std::string GetName() const
+ //! Get the name for the generator.
+ std::string GetName() const override
{
return cmGlobalNMakeMakefileGenerator::GetActualName();
}
static std::string GetActualName() { return "NMake Makefiles"; }
/** Get encoding used by generator for makefile files */
- codecvt::Encoding GetMakefileEncoding() const CM_OVERRIDE
+ codecvt::Encoding GetMakefileEncoding() const override
{
return codecvt::ANSI;
}
@@ -39,12 +41,22 @@ public:
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
*/
- virtual void EnableLanguage(std::vector<std::string> const& languages,
- cmMakefile*, bool optional);
+ void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
+ bool optional) override;
+
+protected:
+ std::vector<GeneratedMakeCommand> GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions =
+ std::vector<std::string>()) override;
+
+ void PrintBuildCommandAdvice(std::ostream& os, int jobs) const override;
private:
void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
- const char* envVar) const;
+ const char* envVar) const override;
};
#endif
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 2eef9e492..da21d6c2a 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -2,16 +2,19 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalNinjaGenerator.h"
-#include "cm_jsoncpp_reader.h"
-#include "cm_jsoncpp_value.h"
-#include "cm_jsoncpp_writer.h"
-#include "cmsys/FStream.hxx"
#include <algorithm>
-#include <ctype.h>
-#include <functional>
+#include <cctype>
+#include <cstdio>
#include <iterator>
#include <sstream>
-#include <stdio.h>
+
+#include <cm/memory>
+
+#include "cmsys/FStream.hxx"
+
+#include "cm_jsoncpp_reader.h"
+#include "cm_jsoncpp_value.h"
+#include "cm_jsoncpp_writer.h"
#include "cmAlgorithms.h"
#include "cmDocumentationEntry.h"
@@ -19,20 +22,24 @@
#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpressionEvaluationFile.h"
#include "cmGeneratorTarget.h"
+#include "cmGlobalGenerator.h"
+#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmLocalNinjaGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmNinjaLinkLineComputer.h"
#include "cmOutputConverter.h"
+#include "cmRange.h"
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetDepend.h"
#include "cmVersion.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
class cmLinkLineComputer;
@@ -90,43 +97,18 @@ std::string cmGlobalNinjaGenerator::EncodeRuleName(std::string const& name)
// Ninja rule names must match "[a-zA-Z0-9_.-]+". Use ".xx" to encode
// "." and all invalid characters as hexadecimal.
std::string encoded;
- for (std::string::const_iterator i = name.begin(); i != name.end(); ++i) {
- if (isalnum(*i) || *i == '_' || *i == '-') {
- encoded += *i;
+ for (char i : name) {
+ if (isalnum(i) || i == '_' || i == '-') {
+ encoded += i;
} else {
char buf[16];
- sprintf(buf, ".%02x", static_cast<unsigned int>(*i));
+ sprintf(buf, ".%02x", static_cast<unsigned int>(i));
encoded += buf;
}
}
return encoded;
}
-static bool IsIdentChar(char c)
-{
- return ('a' <= c && c <= 'z') ||
- ('+' <= c && c <= '9') || // +,-./ and numbers
- ('A' <= c && c <= 'Z') || (c == '_') || (c == '$') || (c == '\\') ||
- (c == ' ') || (c == ':');
-}
-
-std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string& ident,
- std::ostream& vars)
-{
- if (std::find_if(ident.begin(), ident.end(),
- std::not1(std::ptr_fun(IsIdentChar))) != ident.end()) {
- static unsigned VarNum = 0;
- std::ostringstream names;
- names << "ident" << VarNum++;
- vars << names.str() << " = " << ident << "\n";
- return "$" + names.str();
- }
- std::string result = ident;
- cmSystemTools::ReplaceString(result, " ", "$ ");
- cmSystemTools::ReplaceString(result, ":", "$:");
- return result;
-}
-
std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string& lit)
{
std::string result = lit;
@@ -137,293 +119,256 @@ std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string& lit)
std::string cmGlobalNinjaGenerator::EncodePath(const std::string& path)
{
- std::string result = path; // NOLINT(clang-tidy)
+ std::string result = path;
#ifdef _WIN32
if (this->IsGCCOnWindows())
std::replace(result.begin(), result.end(), '\\', '/');
else
std::replace(result.begin(), result.end(), '/', '\\');
#endif
- return EncodeLiteral(result);
+ result = EncodeLiteral(result);
+ cmSystemTools::ReplaceString(result, " ", "$ ");
+ cmSystemTools::ReplaceString(result, ":", "$:");
+ return result;
}
-void cmGlobalNinjaGenerator::WriteBuild(
- std::ostream& os, const std::string& comment, const std::string& rule,
- const cmNinjaDeps& outputs, const cmNinjaDeps& implicitOuts,
- const cmNinjaDeps& explicitDeps, const cmNinjaDeps& implicitDeps,
- const cmNinjaDeps& orderOnlyDeps, const cmNinjaVars& variables,
- const std::string& rspfile, int cmdLineLimit, bool* usedResponseFile)
+void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
+ cmNinjaBuild const& build,
+ int cmdLineLimit,
+ bool* usedResponseFile)
{
// Make sure there is a rule.
- if (rule.empty()) {
- cmSystemTools::Error("No rule for WriteBuildStatement! called "
- "with comment: ",
- comment.c_str());
+ if (build.Rule.empty()) {
+ cmSystemTools::Error("No rule for WriteBuild! called with comment: " +
+ build.Comment);
return;
}
// Make sure there is at least one output file.
- if (outputs.empty()) {
- cmSystemTools::Error("No output files for WriteBuildStatement! called "
- "with comment: ",
- comment.c_str());
+ if (build.Outputs.empty()) {
+ cmSystemTools::Error(
+ "No output files for WriteBuild! called with comment: " + build.Comment);
return;
}
- cmGlobalNinjaGenerator::WriteComment(os, comment);
-
- std::string arguments;
-
- // TODO: Better formatting for when there are multiple input/output files.
+ cmGlobalNinjaGenerator::WriteComment(os, build.Comment);
- // Write explicit dependencies.
- for (cmNinjaDeps::const_iterator i = explicitDeps.begin();
- i != explicitDeps.end(); ++i) {
- arguments += " " + EncodeIdent(EncodePath(*i), os);
- }
-
- // Write implicit dependencies.
- if (!implicitDeps.empty()) {
- arguments += " |";
- for (cmNinjaDeps::const_iterator i = implicitDeps.begin();
- i != implicitDeps.end(); ++i) {
- arguments += " " + EncodeIdent(EncodePath(*i), os);
+ // Write output files.
+ std::string buildStr("build");
+ {
+ // Write explicit outputs
+ for (std::string const& output : build.Outputs) {
+ buildStr += " " + EncodePath(output);
+ if (this->ComputingUnknownDependencies) {
+ this->CombinedBuildOutputs.insert(output);
+ }
}
- }
-
- // Write order-only dependencies.
- if (!orderOnlyDeps.empty()) {
- arguments += " ||";
- for (cmNinjaDeps::const_iterator i = orderOnlyDeps.begin();
- i != orderOnlyDeps.end(); ++i) {
- arguments += " " + EncodeIdent(EncodePath(*i), os);
+ // Write implicit outputs
+ if (!build.ImplicitOuts.empty()) {
+ buildStr += " |";
+ for (std::string const& implicitOut : build.ImplicitOuts) {
+ buildStr += " " + EncodePath(implicitOut);
+ }
}
+ buildStr += ":";
+
+ // Write the rule.
+ buildStr += " ";
+ buildStr += build.Rule;
}
- arguments += "\n";
+ std::string arguments;
+ {
+ // TODO: Better formatting for when there are multiple input/output files.
- std::string build;
+ // Write explicit dependencies.
+ for (std::string const& explicitDep : build.ExplicitDeps) {
+ arguments += " " + EncodePath(explicitDep);
+ }
- // Write outputs files.
- build += "build";
- for (cmNinjaDeps::const_iterator i = outputs.begin(); i != outputs.end();
- ++i) {
- build += " " + EncodeIdent(EncodePath(*i), os);
- if (this->ComputingUnknownDependencies) {
- this->CombinedBuildOutputs.insert(*i);
+ // Write implicit dependencies.
+ if (!build.ImplicitDeps.empty()) {
+ arguments += " |";
+ for (std::string const& implicitDep : build.ImplicitDeps) {
+ arguments += " " + EncodePath(implicitDep);
+ }
}
- }
- if (!implicitOuts.empty()) {
- build += " |";
- for (cmNinjaDeps::const_iterator i = implicitOuts.begin();
- i != implicitOuts.end(); ++i) {
- build += " " + EncodeIdent(EncodePath(*i), os);
+
+ // Write order-only dependencies.
+ if (!build.OrderOnlyDeps.empty()) {
+ arguments += " ||";
+ for (std::string const& orderOnlyDep : build.OrderOnlyDeps) {
+ arguments += " " + EncodePath(orderOnlyDep);
+ }
}
- }
- build += ":";
- // Write the rule.
- build += " " + rule;
+ arguments += "\n";
+ }
// Write the variables bound to this build statement.
- std::ostringstream variable_assignments;
- for (cmNinjaVars::const_iterator i = variables.begin(); i != variables.end();
- ++i) {
- cmGlobalNinjaGenerator::WriteVariable(variable_assignments, i->first,
- i->second, "", 1);
- }
+ std::string assignments;
+ {
+ std::ostringstream variable_assignments;
+ for (auto const& variable : build.Variables) {
+ cmGlobalNinjaGenerator::WriteVariable(
+ variable_assignments, variable.first, variable.second, "", 1);
+ }
- // check if a response file rule should be used
- std::string buildstr = build;
- std::string assignments = variable_assignments.str();
- const std::string& args = arguments;
- bool useResponseFile = false;
- if (cmdLineLimit < 0 ||
- (cmdLineLimit > 0 &&
- (args.size() + buildstr.size() + assignments.size() + 1000) >
- static_cast<size_t>(cmdLineLimit))) {
- variable_assignments.str(std::string());
- cmGlobalNinjaGenerator::WriteVariable(variable_assignments, "RSP_FILE",
- rspfile, "", 1);
- assignments += variable_assignments.str();
- useResponseFile = true;
- }
- if (usedResponseFile) {
- *usedResponseFile = useResponseFile;
+ // check if a response file rule should be used
+ assignments = variable_assignments.str();
+ bool useResponseFile = false;
+ if (cmdLineLimit < 0 ||
+ (cmdLineLimit > 0 &&
+ (arguments.size() + buildStr.size() + assignments.size() + 1000) >
+ static_cast<size_t>(cmdLineLimit))) {
+ variable_assignments.str(std::string());
+ cmGlobalNinjaGenerator::WriteVariable(variable_assignments, "RSP_FILE",
+ build.RspFile, "", 1);
+ assignments += variable_assignments.str();
+ useResponseFile = true;
+ }
+ if (usedResponseFile) {
+ *usedResponseFile = useResponseFile;
+ }
}
- os << buildstr << args << assignments;
-}
-
-void cmGlobalNinjaGenerator::WritePhonyBuild(
- std::ostream& os, const std::string& comment, const cmNinjaDeps& outputs,
- const cmNinjaDeps& explicitDeps, const cmNinjaDeps& implicitDeps,
- const cmNinjaDeps& orderOnlyDeps, const cmNinjaVars& variables)
-{
- this->WriteBuild(os, comment, "phony", outputs,
- /*implicitOuts=*/cmNinjaDeps(), explicitDeps, implicitDeps,
- orderOnlyDeps, variables);
+ os << buildStr << arguments << assignments << "\n";
}
void cmGlobalNinjaGenerator::AddCustomCommandRule()
{
- this->AddRule("CUSTOM_COMMAND", "$COMMAND", "$DESC",
- "Rule for running custom commands.",
- /*depfile*/ "",
- /*deptype*/ "",
- /*rspfile*/ "",
- /*rspcontent*/ "",
- /*restat*/ "", // bound on each build statement as needed
- /*generator*/ false);
+ cmNinjaRule rule("CUSTOM_COMMAND");
+ rule.Command = "$COMMAND";
+ rule.Description = "$DESC";
+ rule.Comment = "Rule for running custom commands.";
+ this->AddRule(rule);
}
void cmGlobalNinjaGenerator::WriteCustomCommandBuild(
const std::string& command, const std::string& description,
- const std::string& comment, const std::string& depfile, bool uses_terminal,
- bool restat, const cmNinjaDeps& outputs, const cmNinjaDeps& deps,
- const cmNinjaDeps& orderOnly)
+ const std::string& comment, const std::string& depfile,
+ const std::string& job_pool, bool uses_terminal, bool restat,
+ const cmNinjaDeps& outputs, const cmNinjaDeps& explicitDeps,
+ const cmNinjaDeps& orderOnlyDeps)
{
- std::string cmd = command; // NOLINT(clang-tidy)
-#ifdef _WIN32
- if (cmd.empty())
- // TODO Shouldn't an empty command be handled by ninja?
- cmd = "cmd.exe /c";
-#endif
-
this->AddCustomCommandRule();
- cmNinjaVars vars;
- vars["COMMAND"] = cmd;
- vars["DESC"] = EncodeLiteral(description);
- if (restat) {
- vars["restat"] = "1";
- }
- if (uses_terminal && SupportsConsolePool()) {
- vars["pool"] = "console";
- }
- if (!depfile.empty()) {
- vars["depfile"] = depfile;
+ {
+ cmNinjaBuild build("CUSTOM_COMMAND");
+ build.Comment = comment;
+ build.Outputs = outputs;
+ build.ExplicitDeps = explicitDeps;
+ build.OrderOnlyDeps = orderOnlyDeps;
+
+ cmNinjaVars& vars = build.Variables;
+ {
+ std::string cmd = command; // NOLINT(*)
+#ifdef _WIN32
+ if (cmd.empty())
+ // TODO Shouldn't an empty command be handled by ninja?
+ cmd = "cmd.exe /c";
+#endif
+ vars["COMMAND"] = std::move(cmd);
+ }
+ vars["DESC"] = EncodeLiteral(description);
+ if (restat) {
+ vars["restat"] = "1";
+ }
+ if (uses_terminal && SupportsConsolePool()) {
+ vars["pool"] = "console";
+ } else if (!job_pool.empty()) {
+ vars["pool"] = job_pool;
+ }
+ if (!depfile.empty()) {
+ vars["depfile"] = depfile;
+ }
+ this->WriteBuild(*this->BuildFileStream, build);
}
- this->WriteBuild(*this->BuildFileStream, comment, "CUSTOM_COMMAND", outputs,
- /*implicitOuts=*/cmNinjaDeps(), deps, cmNinjaDeps(),
- orderOnly, vars);
if (this->ComputingUnknownDependencies) {
// we need to track every dependency that comes in, since we are trying
// to find dependencies that are side effects of build commands
- for (cmNinjaDeps::const_iterator i = deps.begin(); i != deps.end(); ++i) {
- this->CombinedCustomCommandExplicitDependencies.insert(*i);
+ for (std::string const& dep : explicitDeps) {
+ this->CombinedCustomCommandExplicitDependencies.insert(dep);
}
}
}
void cmGlobalNinjaGenerator::AddMacOSXContentRule()
{
- cmLocalGenerator* lg = this->LocalGenerators[0];
-
- std::ostringstream cmd;
- cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(),
- cmOutputConverter::SHELL)
- << " -E copy $in $out";
-
- this->AddRule("COPY_OSX_CONTENT", cmd.str(), "Copying OS X Content $out",
- "Rule for copying OS X bundle content file.",
- /*depfile*/ "",
- /*deptype*/ "",
- /*rspfile*/ "",
- /*rspcontent*/ "",
- /*restat*/ "",
- /*generator*/ false);
+ cmNinjaRule rule("COPY_OSX_CONTENT");
+ rule.Command = CMakeCmd() + " -E copy $in $out";
+ rule.Description = "Copying OS X Content $out";
+ rule.Comment = "Rule for copying OS X bundle content file.";
+ this->AddRule(rule);
}
-void cmGlobalNinjaGenerator::WriteMacOSXContentBuild(const std::string& input,
- const std::string& output)
+void cmGlobalNinjaGenerator::WriteMacOSXContentBuild(std::string input,
+ std::string output)
{
this->AddMacOSXContentRule();
-
- cmNinjaDeps outputs;
- outputs.push_back(output);
- cmNinjaDeps deps;
- deps.push_back(input);
- cmNinjaVars vars;
-
- this->WriteBuild(*this->BuildFileStream, "", "COPY_OSX_CONTENT", outputs,
- /*implicitOuts=*/cmNinjaDeps(), deps, cmNinjaDeps(),
- cmNinjaDeps(), cmNinjaVars());
+ {
+ cmNinjaBuild build("COPY_OSX_CONTENT");
+ build.Outputs.push_back(std::move(output));
+ build.ExplicitDeps.push_back(std::move(input));
+ this->WriteBuild(*this->BuildFileStream, build);
+ }
}
-void cmGlobalNinjaGenerator::WriteRule(
- std::ostream& os, const std::string& name, const std::string& command,
- const std::string& description, const std::string& comment,
- const std::string& depfile, const std::string& deptype,
- const std::string& rspfile, const std::string& rspcontent,
- const std::string& restat, bool generator)
+void cmGlobalNinjaGenerator::WriteRule(std::ostream& os,
+ cmNinjaRule const& rule)
{
+ // -- Parameter checks
// Make sure the rule has a name.
- if (name.empty()) {
- cmSystemTools::Error("No name given for WriteRuleStatement! called "
- "with comment: ",
- comment.c_str());
+ if (rule.Name.empty()) {
+ cmSystemTools::Error("No name given for WriteRule! called with comment: " +
+ rule.Comment);
return;
}
// Make sure a command is given.
- if (command.empty()) {
- cmSystemTools::Error("No command given for WriteRuleStatement! called "
- "with comment: ",
- comment.c_str());
+ if (rule.Command.empty()) {
+ cmSystemTools::Error(
+ "No command given for WriteRule! called with comment: " + rule.Comment);
return;
}
- cmGlobalNinjaGenerator::WriteComment(os, comment);
-
- // Write the rule.
- os << "rule " << name << "\n";
-
- // Write the depfile if any.
- if (!depfile.empty()) {
- cmGlobalNinjaGenerator::Indent(os, 1);
- os << "depfile = " << depfile << "\n";
- }
-
- // Write the deptype if any.
- if (!deptype.empty()) {
- cmGlobalNinjaGenerator::Indent(os, 1);
- os << "deps = " << deptype << "\n";
+ // Make sure response file content is given
+ if (!rule.RspFile.empty() && rule.RspContent.empty()) {
+ cmSystemTools::Error("rspfile but no rspfile_content given for WriteRule! "
+ "called with comment: " +
+ rule.Comment);
+ return;
}
- // Write the command.
- cmGlobalNinjaGenerator::Indent(os, 1);
- os << "command = " << command << "\n";
+ // -- Write rule
+ // Write rule intro
+ cmGlobalNinjaGenerator::WriteComment(os, rule.Comment);
+ os << "rule " << rule.Name << '\n';
- // Write the description if any.
- if (!description.empty()) {
- cmGlobalNinjaGenerator::Indent(os, 1);
- os << "description = " << description << "\n";
- }
-
- if (!rspfile.empty()) {
- if (rspcontent.empty()) {
- cmSystemTools::Error("No rspfile_content given!", comment.c_str());
- return;
+ // Write rule key/value pairs
+ auto writeKV = [&os](const char* key, std::string const& value) {
+ if (!value.empty()) {
+ cmGlobalNinjaGenerator::Indent(os, 1);
+ os << key << " = " << value << '\n';
}
- cmGlobalNinjaGenerator::Indent(os, 1);
- os << "rspfile = " << rspfile << "\n";
- cmGlobalNinjaGenerator::Indent(os, 1);
- os << "rspfile_content = " << rspcontent << "\n";
- }
+ };
- if (!restat.empty()) {
- cmGlobalNinjaGenerator::Indent(os, 1);
- os << "restat = " << restat << "\n";
+ writeKV("depfile", rule.DepFile);
+ writeKV("deps", rule.DepType);
+ writeKV("command", rule.Command);
+ writeKV("description", rule.Description);
+ if (!rule.RspFile.empty()) {
+ writeKV("rspfile", rule.RspFile);
+ writeKV("rspfile_content", rule.RspContent);
}
-
- if (generator) {
- cmGlobalNinjaGenerator::Indent(os, 1);
- os << "generator = 1\n";
+ writeKV("restat", rule.Restat);
+ if (rule.Generator) {
+ writeKV("generator", "1");
}
- os << "\n";
+ // Finish rule
+ os << '\n';
}
void cmGlobalNinjaGenerator::WriteVariable(std::ostream& os,
@@ -435,13 +380,13 @@ void cmGlobalNinjaGenerator::WriteVariable(std::ostream& os,
// Make sure we have a name.
if (name.empty()) {
cmSystemTools::Error("No name given for WriteVariable! called "
- "with comment: ",
- comment.c_str());
+ "with comment: " +
+ comment);
return;
}
// Do not add a variable if the value is empty.
- std::string val = cmSystemTools::TrimWhitespace(value);
+ std::string val = cmTrimWhitespace(value);
if (val.empty()) {
return;
}
@@ -465,26 +410,14 @@ void cmGlobalNinjaGenerator::WriteDefault(std::ostream& os,
{
cmGlobalNinjaGenerator::WriteComment(os, comment);
os << "default";
- for (cmNinjaDeps::const_iterator i = targets.begin(); i != targets.end();
- ++i) {
- os << " " << *i;
+ for (std::string const& target : targets) {
+ os << " " << target;
}
os << "\n";
}
cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm)
: cmGlobalCommonGenerator(cm)
- , BuildFileStream(CM_NULLPTR)
- , RulesFileStream(CM_NULLPTR)
- , CompileCommandsStream(CM_NULLPTR)
- , Rules()
- , AllDependencies()
- , UsingGCCOnWindows(false)
- , ComputingUnknownDependencies(false)
- , PolicyCMP0058(cmPolicies::WARN)
- , NinjaSupportsConsolePool(false)
- , NinjaSupportsImplicitOuts(false)
- , NinjaSupportsDyndeps(0)
{
#ifdef _WIN32
cm->GetState()->SetWindowsShell(true);
@@ -532,12 +465,17 @@ void cmGlobalNinjaGenerator::Generate()
std::ostringstream msg;
msg << "The detected version of Ninja (" << this->NinjaVersion;
msg << ") is less than the version of Ninja required by CMake (";
- msg << this->RequiredNinjaVersion() << ").";
- this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, msg.str());
+ msg << cmGlobalNinjaGenerator::RequiredNinjaVersion() << ").";
+ this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
+ msg.str());
+ return;
+ }
+ if (!this->OpenBuildFileStream()) {
+ return;
+ }
+ if (!this->OpenRulesFileStream()) {
return;
}
- this->OpenBuildFileStream();
- this->OpenRulesFileStream();
this->TargetDependsClosures.clear();
@@ -579,20 +517,21 @@ bool cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf)
this->NinjaCommand = ninjaCommand;
std::vector<std::string> command;
command.push_back(this->NinjaCommand);
- command.push_back("--version");
+ command.emplace_back("--version");
std::string version;
std::string error;
- if (!cmSystemTools::RunSingleCommand(command, &version, &error, CM_NULLPTR,
- CM_NULLPTR,
+ if (!cmSystemTools::RunSingleCommand(command, &version, &error, nullptr,
+ nullptr,
cmSystemTools::OUTPUT_NONE)) {
- mf->IssueMessage(cmake::FATAL_ERROR, "Running\n '" +
- cmJoin(command, "' '") + "'\n"
- "failed with:\n " +
+ mf->IssueMessage(MessageType::FATAL_ERROR,
+ "Running\n '" + cmJoin(command, "' '") +
+ "'\n"
+ "failed with:\n " +
error);
cmSystemTools::SetFatalErrorOccured();
return false;
}
- this->NinjaVersion = cmSystemTools::TrimWhitespace(version);
+ this->NinjaVersion = cmTrimWhitespace(version);
this->CheckNinjaFeatures();
}
return true;
@@ -605,15 +544,29 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures()
RequiredNinjaVersionForConsolePool().c_str());
this->NinjaSupportsImplicitOuts = !cmSystemTools::VersionCompare(
cmSystemTools::OP_LESS, this->NinjaVersion.c_str(),
- this->RequiredNinjaVersionForImplicitOuts().c_str());
- {
+ cmGlobalNinjaGenerator::RequiredNinjaVersionForImplicitOuts().c_str());
+ this->NinjaSupportsManifestRestat = !cmSystemTools::VersionCompare(
+ cmSystemTools::OP_LESS, this->NinjaVersion.c_str(),
+ RequiredNinjaVersionForManifestRestat().c_str());
+ this->NinjaSupportsMultilineDepfile = !cmSystemTools::VersionCompare(
+ cmSystemTools::OP_LESS, this->NinjaVersion.c_str(),
+ RequiredNinjaVersionForMultilineDepfile().c_str());
+ this->NinjaSupportsDyndeps = !cmSystemTools::VersionCompare(
+ cmSystemTools::OP_LESS, this->NinjaVersion.c_str(),
+ RequiredNinjaVersionForDyndeps().c_str());
+ if (!this->NinjaSupportsDyndeps) {
+ // The ninja version number is not new enough to have upstream support.
// Our ninja branch adds ".dyndep-#" to its version number,
// where '#' is a feature-specific version number. Extract it.
static std::string const k_DYNDEP_ = ".dyndep-";
std::string::size_type pos = this->NinjaVersion.find(k_DYNDEP_);
if (pos != std::string::npos) {
- const char* fv = this->NinjaVersion.c_str() + pos + k_DYNDEP_.size();
- cmSystemTools::StringToULong(fv, &this->NinjaSupportsDyndeps);
+ const char* fv = &this->NinjaVersion[pos + k_DYNDEP_.size()];
+ unsigned long dyndep = 0;
+ cmStrToULong(fv, &dyndep);
+ if (dyndep == 1) {
+ this->NinjaSupportsDyndeps = true;
+ }
}
}
}
@@ -621,8 +574,7 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures()
bool cmGlobalNinjaGenerator::CheckLanguages(
std::vector<std::string> const& languages, cmMakefile* mf) const
{
- if (std::find(languages.begin(), languages.end(), "Fortran") !=
- languages.end()) {
+ if (cmContains(languages, "Fortran")) {
return this->CheckFortran(mf);
}
return true;
@@ -630,38 +582,26 @@ bool cmGlobalNinjaGenerator::CheckLanguages(
bool cmGlobalNinjaGenerator::CheckFortran(cmMakefile* mf) const
{
- if (this->NinjaSupportsDyndeps == 1) {
+ if (this->NinjaSupportsDyndeps) {
return true;
}
std::ostringstream e;
- if (this->NinjaSupportsDyndeps == 0) {
- /* clang-format off */
- e <<
- "The Ninja generator does not support Fortran using Ninja version\n"
- " " + this->NinjaVersion + "\n"
- "due to lack of required features. "
- "Kitware has implemented the required features but as of this version "
- "of CMake they have not been integrated to upstream ninja. "
- "Pending integration, Kitware maintains a branch at:\n"
- " https://github.com/Kitware/ninja/tree/features-for-fortran#readme\n"
- "with the required features. "
- "One may build ninja from that branch to get support for Fortran."
- ;
- /* clang-format on */
- } else {
- /* clang-format off */
- e <<
- "The Ninja generator in this version of CMake does not support Fortran "
- "using Ninja version\n"
- " " + this->NinjaVersion + "\n"
- "because its 'dyndep' feature version is " <<
- this->NinjaSupportsDyndeps << ". "
- "This version of CMake is aware only of 'dyndep' feature version 1."
- ;
- /* clang-format on */
- }
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ /* clang-format off */
+ e <<
+ "The Ninja generator does not support Fortran using Ninja version\n"
+ " " + this->NinjaVersion + "\n"
+ "due to lack of required features. "
+ "Kitware has implemented the required features and they have been "
+ "merged to upstream ninja for inclusion in Ninja 1.10 and higher. "
+ "As of this version of CMake, Ninja 1.10 has not been released. "
+ "Meanwhile, Kitware maintains a branch of Ninja at:\n"
+ " https://github.com/Kitware/ninja/tree/features-for-fortran#readme\n"
+ "with the required features. "
+ "One may build ninja from that branch to get support for Fortran."
+ ;
+ /* clang-format on */
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -670,21 +610,29 @@ void cmGlobalNinjaGenerator::EnableLanguage(
std::vector<std::string> const& langs, cmMakefile* mf, bool optional)
{
this->cmGlobalGenerator::EnableLanguage(langs, mf, optional);
- for (std::vector<std::string>::const_iterator l = langs.begin();
- l != langs.end(); ++l) {
- if (*l == "NONE") {
+ for (std::string const& l : langs) {
+ if (l == "NONE") {
continue;
}
- this->ResolveLanguageCompiler(*l, mf, optional);
+ this->ResolveLanguageCompiler(l, mf, optional);
}
#ifdef _WIN32
- if (strcmp(mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID"), "MSVC") != 0 &&
- strcmp(mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID"), "MSVC") != 0 &&
- (mf->IsOn("CMAKE_COMPILER_IS_MINGW") ||
- strcmp(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID"), "GNU") == 0 ||
- strcmp(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"), "GNU") == 0 ||
- strcmp(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID"), "Clang") == 0 ||
- strcmp(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"), "Clang") == 0)) {
+ const bool clangGnuMode =
+ ((mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") == "Clang") &&
+ (mf->GetSafeDefinition("CMAKE_C_COMPILER_FRONTEND_VARIANT") == "GNU")) ||
+ ((mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID") == "Clang") &&
+ (mf->GetSafeDefinition("CMAKE_CXX_COMPILER_FRONTEND_VARIANT") == "GNU"));
+
+ if (clangGnuMode ||
+ ((mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID") != "MSVC") &&
+ (mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID") != "MSVC") &&
+ (mf->IsOn("CMAKE_COMPILER_IS_MINGW") ||
+ (mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") == "GNU") ||
+ (mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID") == "GNU") ||
+ (mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") == "Clang") ||
+ (mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID") == "Clang") ||
+ (mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") == "QCC") ||
+ (mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID") == "QCC")))) {
this->UsingGCCOnWindows = true;
}
#endif
@@ -698,56 +646,52 @@ void cmGlobalNinjaGenerator::EnableLanguage(
// cmGlobalXCodeGenerator
// Called by:
// cmGlobalGenerator::Build()
-void cmGlobalNinjaGenerator::GenerateBuildCommand(
- std::vector<std::string>& makeCommand, const std::string& makeProgram,
- const std::string& /*projectName*/, const std::string& /*projectDir*/,
- const std::string& targetName, const std::string& /*config*/, bool /*fast*/,
- bool verbose, std::vector<std::string> const& makeOptions)
+std::vector<cmGlobalGenerator::GeneratedMakeCommand>
+cmGlobalNinjaGenerator::GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& /*projectName*/,
+ const std::string& /*projectDir*/,
+ std::vector<std::string> const& targetNames, const std::string& /*config*/,
+ bool /*fast*/, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions)
{
- makeCommand.push_back(this->SelectMakeProgram(makeProgram));
+ GeneratedMakeCommand makeCommand;
+ makeCommand.Add(this->SelectMakeProgram(makeProgram));
if (verbose) {
- makeCommand.push_back("-v");
+ makeCommand.Add("-v");
}
- makeCommand.insert(makeCommand.end(), makeOptions.begin(),
- makeOptions.end());
- if (!targetName.empty()) {
- if (targetName == "clean") {
- makeCommand.push_back("-t");
- makeCommand.push_back("clean");
- } else {
- makeCommand.push_back(targetName);
+ if ((jobs != cmake::NO_BUILD_PARALLEL_LEVEL) &&
+ (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL)) {
+ makeCommand.Add("-j", std::to_string(jobs));
+ }
+
+ makeCommand.Add(makeOptions.begin(), makeOptions.end());
+ for (const auto& tname : targetNames) {
+ if (!tname.empty()) {
+ makeCommand.Add(tname);
}
}
+ return { std::move(makeCommand) };
}
// Non-virtual public methods.
-void cmGlobalNinjaGenerator::AddRule(
- const std::string& name, const std::string& command,
- const std::string& description, const std::string& comment,
- const std::string& depfile, const std::string& deptype,
- const std::string& rspfile, const std::string& rspcontent,
- const std::string& restat, bool generator)
+void cmGlobalNinjaGenerator::AddRule(cmNinjaRule const& rule)
{
// Do not add the same rule twice.
- if (this->HasRule(name)) {
+ if (!this->Rules.insert(rule.Name).second) {
return;
}
-
- this->Rules.insert(name);
- cmGlobalNinjaGenerator::WriteRule(*this->RulesFileStream, name, command,
- description, comment, depfile, deptype,
- rspfile, rspcontent, restat, generator);
-
- this->RuleCmdLength[name] = (int)command.size();
+ // Store command length
+ this->RuleCmdLength[rule.Name] = static_cast<int>(rule.Command.size());
+ // Write rule
+ cmGlobalNinjaGenerator::WriteRule(*this->RulesFileStream, rule);
}
bool cmGlobalNinjaGenerator::HasRule(const std::string& name)
{
- RulesSetType::const_iterator rule = this->Rules.find(name);
- return (rule != this->Rules.end());
+ return (this->Rules.find(name) != this->Rules.end());
}
// Private virtual overrides
@@ -763,32 +707,29 @@ void cmGlobalNinjaGenerator::ComputeTargetObjectDirectory(
cmGeneratorTarget* gt) const
{
// Compute full path to object file directory for this target.
- std::string dir;
- dir += gt->LocalGenerator->GetCurrentBinaryDirectory();
- dir += "/";
- dir += gt->LocalGenerator->GetTargetDirectory(gt);
- dir += "/";
+ std::string dir =
+ cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(), '/',
+ gt->LocalGenerator->GetTargetDirectory(gt), '/');
gt->ObjectDirectory = dir;
}
// Private methods
-void cmGlobalNinjaGenerator::OpenBuildFileStream()
+bool cmGlobalNinjaGenerator::OpenBuildFileStream()
{
// Compute Ninja's build file path.
std::string buildFilePath =
- this->GetCMakeInstance()->GetHomeOutputDirectory();
- buildFilePath += "/";
- buildFilePath += cmGlobalNinjaGenerator::NINJA_BUILD_FILE;
+ cmStrCat(this->GetCMakeInstance()->GetHomeOutputDirectory(), '/',
+ cmGlobalNinjaGenerator::NINJA_BUILD_FILE);
// Get a stream where to generate things.
if (!this->BuildFileStream) {
- this->BuildFileStream = new cmGeneratedFileStream(
- buildFilePath.c_str(), false, this->GetMakefileEncoding());
- if (!this->BuildFileStream) {
+ this->BuildFileStream = cm::make_unique<cmGeneratedFileStream>(
+ buildFilePath, false, this->GetMakefileEncoding());
+ if (!(*this->BuildFileStream)) {
// An error message is generated by the constructor if it cannot
// open the file.
- return;
+ return false;
}
}
@@ -799,34 +740,34 @@ void cmGlobalNinjaGenerator::OpenBuildFileStream()
*this->BuildFileStream
<< "# This file contains all the build statements describing the\n"
<< "# compilation DAG.\n\n";
+
+ return true;
}
void cmGlobalNinjaGenerator::CloseBuildFileStream()
{
if (this->BuildFileStream) {
- delete this->BuildFileStream;
- this->BuildFileStream = CM_NULLPTR;
+ this->BuildFileStream.reset();
} else {
cmSystemTools::Error("Build file stream was not open.");
}
}
-void cmGlobalNinjaGenerator::OpenRulesFileStream()
+bool cmGlobalNinjaGenerator::OpenRulesFileStream()
{
// Compute Ninja's build file path.
std::string rulesFilePath =
- this->GetCMakeInstance()->GetHomeOutputDirectory();
- rulesFilePath += "/";
- rulesFilePath += cmGlobalNinjaGenerator::NINJA_RULES_FILE;
+ cmStrCat(this->GetCMakeInstance()->GetHomeOutputDirectory(), '/',
+ cmGlobalNinjaGenerator::NINJA_RULES_FILE);
// Get a stream where to generate things.
if (!this->RulesFileStream) {
- this->RulesFileStream = new cmGeneratedFileStream(
- rulesFilePath.c_str(), false, this->GetMakefileEncoding());
- if (!this->RulesFileStream) {
+ this->RulesFileStream = cm::make_unique<cmGeneratedFileStream>(
+ rulesFilePath, false, this->GetMakefileEncoding());
+ if (!(*this->RulesFileStream)) {
// An error message is generated by the constructor if it cannot
// open the file.
- return;
+ return false;
}
}
@@ -841,13 +782,13 @@ void cmGlobalNinjaGenerator::OpenRulesFileStream()
<< "# It is included in the main '" << NINJA_BUILD_FILE << "'.\n\n"
;
/* clang-format on */
+ return true;
}
void cmGlobalNinjaGenerator::CloseRulesFileStream()
{
if (this->RulesFileStream) {
- delete this->RulesFileStream;
- this->RulesFileStream = CM_NULLPTR;
+ this->RulesFileStream.reset();
} else {
cmSystemTools::Error("Rules file stream was not open.");
}
@@ -858,7 +799,7 @@ static void EnsureTrailingSlash(std::string& path)
if (path.empty()) {
return;
}
- std::string::value_type last = path[path.size() - 1];
+ std::string::value_type last = path.back();
#ifdef _WIN32
if (last != '\\') {
path += '\\';
@@ -870,18 +811,29 @@ static void EnsureTrailingSlash(std::string& path)
#endif
}
-std::string cmGlobalNinjaGenerator::ConvertToNinjaPath(
+std::string const& cmGlobalNinjaGenerator::ConvertToNinjaPath(
const std::string& path) const
{
+ auto const f = ConvertToNinjaPathCache.find(path);
+ if (f != ConvertToNinjaPathCache.end()) {
+ return f->second;
+ }
+
cmLocalNinjaGenerator* ng =
static_cast<cmLocalNinjaGenerator*>(this->LocalGenerators[0]);
- std::string convPath = ng->ConvertToRelativePath(
- this->LocalGenerators[0]->GetState()->GetBinaryDirectory(), path);
+ std::string const& bin_dir = ng->GetState()->GetBinaryDirectory();
+ std::string convPath = ng->MaybeConvertToRelativePath(bin_dir, path);
convPath = this->NinjaOutputPath(convPath);
#ifdef _WIN32
std::replace(convPath.begin(), convPath.end(), '/', '\\');
#endif
- return convPath;
+ return ConvertToNinjaPathCache.emplace(path, std::move(convPath))
+ .first->second;
+}
+
+void cmGlobalNinjaGenerator::AddAdditionalCleanFile(std::string fileName)
+{
+ this->AdditionalCleanFiles.emplace(std::move(fileName));
}
void cmGlobalNinjaGenerator::AddCXXCompileCommand(
@@ -899,25 +851,25 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand(
// Get a stream where to generate things.
this->CompileCommandsStream =
- new cmGeneratedFileStream(buildFilePath.c_str());
+ cm::make_unique<cmGeneratedFileStream>(buildFilePath);
*this->CompileCommandsStream << "[";
} else {
*this->CompileCommandsStream << "," << std::endl;
}
std::string sourceFileName = sourceFile;
- if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str())) {
+ if (!cmSystemTools::FileIsFullPath(sourceFileName)) {
sourceFileName = cmSystemTools::CollapseFullPath(
sourceFileName, this->GetCMakeInstance()->GetHomeOutputDirectory());
}
/* clang-format off */
*this->CompileCommandsStream << "\n{\n"
- << " \"directory\": \""
+ << R"( "directory": ")"
<< cmGlobalGenerator::EscapeJSON(buildFileDir) << "\",\n"
- << " \"command\": \""
+ << R"( "command": ")"
<< cmGlobalGenerator::EscapeJSON(commandLine) << "\",\n"
- << " \"file\": \""
+ << R"( "file": ")"
<< cmGlobalGenerator::EscapeJSON(sourceFileName) << "\"\n"
<< "}";
/* clang-format on */
@@ -927,8 +879,7 @@ void cmGlobalNinjaGenerator::CloseCompileCommandsStream()
{
if (this->CompileCommandsStream) {
*this->CompileCommandsStream << "\n]";
- delete this->CompileCommandsStream;
- this->CompileCommandsStream = CM_NULLPTR;
+ this->CompileCommandsStream.reset();
}
}
@@ -940,27 +891,18 @@ void cmGlobalNinjaGenerator::WriteDisclaimer(std::ostream& os)
<< cmVersion::GetMinorVersion() << "\n\n";
}
-void cmGlobalNinjaGenerator::AddDependencyToAll(cmGeneratorTarget* target)
-{
- this->AppendTargetOutputs(target, this->AllDependencies);
-}
-
-void cmGlobalNinjaGenerator::AddDependencyToAll(const std::string& input)
-{
- this->AllDependencies.push_back(input);
-}
-
void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies()
{
- for (std::map<std::string, std::set<std::string> >::iterator i =
- this->AssumedSourceDependencies.begin();
- i != this->AssumedSourceDependencies.end(); ++i) {
- cmNinjaDeps deps;
- std::copy(i->second.begin(), i->second.end(), std::back_inserter(deps));
+ for (auto const& asd : this->AssumedSourceDependencies) {
+ cmNinjaDeps orderOnlyDeps;
+ std::copy(asd.second.begin(), asd.second.end(),
+ std::back_inserter(orderOnlyDeps));
WriteCustomCommandBuild(/*command=*/"", /*description=*/"",
"Assume dependencies for generated source file.",
- /*depfile*/ "", /*uses_terminal*/ false,
- /*restat*/ true, cmNinjaDeps(1, i->first), deps);
+ /*depfile*/ "", /*job_pool*/ "",
+ /*uses_terminal*/ false,
+ /*restat*/ true, cmNinjaDeps(1, asd.first),
+ cmNinjaDeps(), orderOnlyDeps);
}
}
@@ -1024,63 +966,72 @@ void cmGlobalNinjaGenerator::AppendTargetDepends(
{
if (target->GetType() == cmStateEnums::GLOBAL_TARGET) {
// These depend only on other CMake-provided targets, e.g. "all".
- std::set<std::string> const& utils = target->GetUtilities();
- for (std::set<std::string>::const_iterator i = utils.begin();
- i != utils.end(); ++i) {
+ for (BT<std::string> const& util : target->GetUtilities()) {
std::string d =
- target->GetLocalGenerator()->GetCurrentBinaryDirectory() +
- std::string("/") + *i;
+ target->GetLocalGenerator()->GetCurrentBinaryDirectory() + "/" +
+ util.Value;
outputs.push_back(this->ConvertToNinjaPath(d));
}
} else {
cmNinjaDeps outs;
- cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target);
- for (cmTargetDependSet::const_iterator i = targetDeps.begin();
- i != targetDeps.end(); ++i) {
- if ((*i)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmTargetDepend const& targetDep :
+ this->GetTargetDirectDepends(target)) {
+ if (targetDep->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- this->AppendTargetOutputs(*i, outs, depends);
+ this->AppendTargetOutputs(targetDep, outs, depends);
}
std::sort(outs.begin(), outs.end());
- outputs.insert(outputs.end(), outs.begin(), outs.end());
+ cmAppend(outputs, outs);
}
}
void cmGlobalNinjaGenerator::AppendTargetDependsClosure(
cmGeneratorTarget const* target, cmNinjaDeps& outputs)
{
- TargetDependsClosureMap::iterator i =
- this->TargetDependsClosures.find(target);
- if (i == this->TargetDependsClosures.end()) {
- TargetDependsClosureMap::value_type e(
- target, std::set<cmGeneratorTarget const*>());
- i = this->TargetDependsClosures.insert(e).first;
- this->ComputeTargetDependsClosure(target, i->second);
- }
- std::set<cmGeneratorTarget const*> const& targets = i->second;
- cmNinjaDeps outs;
- for (std::set<cmGeneratorTarget const*>::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- this->AppendTargetOutputs(*ti, outs);
- }
- std::sort(outs.begin(), outs.end());
- outputs.insert(outputs.end(), outs.begin(), outs.end());
+ cmNinjaOuts outs;
+ this->AppendTargetDependsClosure(target, outs, true);
+ cmAppend(outputs, outs);
}
-void cmGlobalNinjaGenerator::ComputeTargetDependsClosure(
- cmGeneratorTarget const* target, std::set<cmGeneratorTarget const*>& depends)
+void cmGlobalNinjaGenerator::AppendTargetDependsClosure(
+ cmGeneratorTarget const* target, cmNinjaOuts& outputs, bool omit_self)
{
- cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target);
- for (cmTargetDependSet::const_iterator i = targetDeps.begin();
- i != targetDeps.end(); ++i) {
- if ((*i)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
- continue;
- }
- if (depends.insert(*i).second) {
- this->ComputeTargetDependsClosure(*i, depends);
+
+ // try to locate the target in the cache
+ auto find = this->TargetDependsClosures.lower_bound(target);
+
+ if (find == this->TargetDependsClosures.end() || find->first != target) {
+ // We now calculate the closure outputs by inspecting the dependent
+ // targets recursively.
+ // For that we have to distinguish between a local result set that is only
+ // relevant for filling the cache entries properly isolated and a global
+ // result set that is relevant for the result of the top level call to
+ // AppendTargetDependsClosure.
+ cmNinjaOuts this_outs; // this will be the new cache entry
+
+ for (auto const& dep_target : this->GetTargetDirectDepends(target)) {
+ if (dep_target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ continue;
+ }
+
+ // Collect the dependent targets for _this_ target
+ this->AppendTargetDependsClosure(dep_target, this_outs, false);
}
+ find = this->TargetDependsClosures.emplace_hint(find, target,
+ std::move(this_outs));
+ }
+
+ // now fill the outputs of the final result from the newly generated cache
+ // entry
+ outputs.insert(find->second.begin(), find->second.end());
+
+ // finally generate the outputs of the target itself, if applicable
+ cmNinjaDeps outs;
+ if (!omit_self) {
+ this->AppendTargetOutputs(target, outs);
}
+ outputs.insert(outs.begin(), outs.end());
}
void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
@@ -1091,8 +1042,8 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
this->AppendTargetOutputs(target, outputs);
// Mark the target's outputs as ambiguous to ensure that no other target uses
// the output as an alias.
- for (cmNinjaDeps::iterator i = outputs.begin(); i != outputs.end(); ++i) {
- TargetAliases[*i] = CM_NULLPTR;
+ for (std::string const& output : outputs) {
+ TargetAliases[output] = nullptr;
}
// Insert the alias into the map. If the alias was already present in the
@@ -1100,7 +1051,7 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
std::pair<TargetAliasMap::iterator, bool> newAlias =
TargetAliases.insert(std::make_pair(buildAlias, target));
if (newAlias.second && newAlias.first->second != target) {
- newAlias.first->second = CM_NULLPTR;
+ newAlias.first->second = nullptr;
}
}
@@ -1109,17 +1060,27 @@ void cmGlobalNinjaGenerator::WriteTargetAliases(std::ostream& os)
cmGlobalNinjaGenerator::WriteDivider(os);
os << "# Target aliases.\n\n";
- for (TargetAliasMap::const_iterator i = TargetAliases.begin();
- i != TargetAliases.end(); ++i) {
+ cmNinjaBuild build("phony");
+ build.Outputs.emplace_back("");
+ for (auto const& ta : TargetAliases) {
// Don't write ambiguous aliases.
- if (!i->second) {
+ if (!ta.second) {
continue;
}
- cmNinjaDeps deps;
- this->AppendTargetOutputs(i->second, deps);
+ // Don't write alias if there is a already a custom command with
+ // matching output
+ if (this->HasCustomCommandOutput(ta.first)) {
+ continue;
+ }
- this->WritePhonyBuild(os, "", cmNinjaDeps(1, i->first), deps);
+ // Outputs
+ build.Outputs[0] = ta.first;
+ // Explicit depdendencies
+ build.ExplicitDeps.clear();
+ this->AppendTargetOutputs(ta.second, build.ExplicitDeps);
+ // Write
+ this->WriteBuild(os, build);
}
}
@@ -1128,65 +1089,32 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
cmGlobalNinjaGenerator::WriteDivider(os);
os << "# Folder targets.\n\n";
- std::map<std::string, cmNinjaDeps> targetsPerFolder;
- for (std::vector<cmLocalGenerator*>::const_iterator lgi =
- this->LocalGenerators.begin();
- lgi != this->LocalGenerators.end(); ++lgi) {
- cmLocalGenerator const* lg = *lgi;
- const std::string currentBinaryFolder(
- lg->GetStateSnapshot().GetDirectory().GetCurrentBinary());
- // The directory-level rule should depend on the target-level rules
- // for all targets in the directory.
- targetsPerFolder[currentBinaryFolder] = cmNinjaDeps();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti =
- lg->GetGeneratorTargets().begin();
- ti != lg->GetGeneratorTargets().end(); ++ti) {
- cmGeneratorTarget const* gt = *ti;
- cmStateEnums::TargetType const type = gt->GetType();
- if ((type == cmStateEnums::EXECUTABLE ||
- type == cmStateEnums::STATIC_LIBRARY ||
- type == cmStateEnums::SHARED_LIBRARY ||
- type == cmStateEnums::MODULE_LIBRARY ||
- type == cmStateEnums::OBJECT_LIBRARY ||
- type == cmStateEnums::UTILITY) &&
- !gt->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
- targetsPerFolder[currentBinaryFolder].push_back(gt->GetName());
- }
- }
+ std::map<std::string, DirectoryTarget> dirTargets =
+ this->ComputeDirectoryTargets();
- // The directory-level rule should depend on the directory-level
- // rules of the subdirectories.
- std::vector<cmStateSnapshot> const& children =
- lg->GetStateSnapshot().GetChildren();
- for (std::vector<cmStateSnapshot>::const_iterator stateIt =
- children.begin();
- stateIt != children.end(); ++stateIt) {
- std::string const currentBinaryDir =
- stateIt->GetDirectory().GetCurrentBinary();
-
- targetsPerFolder[currentBinaryFolder].push_back(
- this->ConvertToNinjaPath(currentBinaryDir + "/all"));
- }
- }
-
- std::string const rootBinaryDir =
- this->LocalGenerators[0]->GetBinaryDirectory();
- for (std::map<std::string, cmNinjaDeps>::const_iterator it =
- targetsPerFolder.begin();
- it != targetsPerFolder.end(); ++it) {
+ for (auto const& it : dirTargets) {
+ cmNinjaBuild build("phony");
cmGlobalNinjaGenerator::WriteDivider(os);
- std::string const& currentBinaryDir = it->first;
-
- // Do not generate a rule for the root binary dir.
- if (rootBinaryDir.length() >= currentBinaryDir.length()) {
- continue;
+ std::string const& currentBinaryDir = it.first;
+ DirectoryTarget const& dt = it.second;
+
+ // Setup target
+ build.Comment = "Folder: " + currentBinaryDir;
+ build.Outputs.emplace_back(
+ this->ConvertToNinjaPath(currentBinaryDir + "/all"));
+ for (DirectoryTarget::Target const& t : dt.Targets) {
+ if (!t.ExcludeFromAll) {
+ this->AppendTargetOutputs(t.GT, build.ExplicitDeps);
+ }
}
-
- std::string const comment = "Folder: " + currentBinaryDir;
- cmNinjaDeps output(1);
- output.push_back(this->ConvertToNinjaPath(currentBinaryDir + "/all"));
-
- this->WritePhonyBuild(os, comment, output, it->second);
+ for (DirectoryTarget::Dir const& d : dt.Children) {
+ if (!d.ExcludeFromAll) {
+ build.ExplicitDeps.emplace_back(
+ this->ConvertToNinjaPath(d.Path + "/all"));
+ }
+ }
+ // Write target
+ this->WriteBuild(os, build);
}
}
@@ -1220,50 +1148,37 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
// get the list of files that cmake itself has generated as a
// product of configuration.
- for (std::vector<cmLocalGenerator*>::const_iterator i =
- this->LocalGenerators.begin();
- i != this->LocalGenerators.end(); ++i) {
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
// get the vector of files created by this makefile and convert them
// to ninja paths, which are all relative in respect to the build directory
- const std::vector<std::string>& files =
- (*i)->GetMakefile()->GetOutputFiles();
- typedef std::vector<std::string>::const_iterator vect_it;
- for (vect_it j = files.begin(); j != files.end(); ++j) {
- knownDependencies.insert(this->ConvertToNinjaPath(*j));
+ for (std::string const& file : lg->GetMakefile()->GetOutputFiles()) {
+ knownDependencies.insert(this->ConvertToNinjaPath(file));
}
- // get list files which are implicit dependencies as well and will be phony
- // for rebuild manifest
- std::vector<std::string> const& lf = (*i)->GetMakefile()->GetListFiles();
- typedef std::vector<std::string>::const_iterator vect_it;
- for (vect_it j = lf.begin(); j != lf.end(); ++j) {
- knownDependencies.insert(this->ConvertToNinjaPath(*j));
+ if (!this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION")) {
+ // get list files which are implicit dependencies as well and will be
+ // phony for rebuild manifest
+ for (std::string const& j : lg->GetMakefile()->GetListFiles()) {
+ knownDependencies.insert(this->ConvertToNinjaPath(j));
+ }
}
- std::vector<cmGeneratorExpressionEvaluationFile*> const& ef =
- (*i)->GetMakefile()->GetEvaluationFiles();
- for (std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator li =
- ef.begin();
- li != ef.end(); ++li) {
+ for (cmGeneratorExpressionEvaluationFile* li :
+ lg->GetMakefile()->GetEvaluationFiles()) {
// get all the files created by generator expressions and convert them
// to ninja paths
- std::vector<std::string> evaluationFiles = (*li)->GetFiles();
- for (vect_it j = evaluationFiles.begin(); j != evaluationFiles.end();
- ++j) {
- knownDependencies.insert(this->ConvertToNinjaPath(*j));
+ for (std::string const& evaluationFile : li->GetFiles()) {
+ knownDependencies.insert(this->ConvertToNinjaPath(evaluationFile));
}
}
}
knownDependencies.insert(this->CMakeCacheFile);
- for (TargetAliasMap::const_iterator i = this->TargetAliases.begin();
- i != this->TargetAliases.end(); ++i) {
- knownDependencies.insert(this->ConvertToNinjaPath(i->first));
+ for (auto const& ta : this->TargetAliases) {
+ knownDependencies.insert(this->ConvertToNinjaPath(ta.first));
}
// remove all source files we know will exist.
- typedef std::map<std::string, std::set<std::string> >::const_iterator map_it;
- for (map_it i = this->AssumedSourceDependencies.begin();
- i != this->AssumedSourceDependencies.end(); ++i) {
- knownDependencies.insert(this->ConvertToNinjaPath(i->first));
+ for (auto const& i : this->AssumedSourceDependencies) {
+ knownDependencies.insert(this->ConvertToNinjaPath(i.first));
}
// now we difference with CombinedCustomCommandExplicitDependencies to find
@@ -1280,25 +1195,26 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
knownDependencies.begin(), knownDependencies.end(),
std::back_inserter(unknownExplicitDepends));
- std::string const rootBuildDirectory =
- this->GetCMakeInstance()->GetHomeOutputDirectory();
- bool const inSourceBuild =
- (rootBuildDirectory == this->GetCMakeInstance()->GetHomeDirectory());
std::vector<std::string> warnExplicitDepends;
- for (std::vector<std::string>::const_iterator i =
- unknownExplicitDepends.begin();
- i != unknownExplicitDepends.end(); ++i) {
- // verify the file is in the build directory
- std::string const absDepPath =
- cmSystemTools::CollapseFullPath(*i, rootBuildDirectory.c_str());
- bool const inBuildDir =
- cmSystemTools::IsSubDirectory(absDepPath, rootBuildDirectory);
- if (inBuildDir) {
- cmNinjaDeps deps(1, *i);
- this->WritePhonyBuild(os, "", deps, cmNinjaDeps());
- if (this->PolicyCMP0058 == cmPolicies::WARN && !inSourceBuild &&
- warnExplicitDepends.size() < 10) {
- warnExplicitDepends.push_back(*i);
+ if (!unknownExplicitDepends.empty()) {
+ cmake* cmk = this->GetCMakeInstance();
+ std::string const& buildRoot = cmk->GetHomeOutputDirectory();
+ bool const inSource = (buildRoot == cmk->GetHomeDirectory());
+ bool const warn = (!inSource && (this->PolicyCMP0058 == cmPolicies::WARN));
+ cmNinjaBuild build("phony");
+ build.Outputs.emplace_back("");
+ for (std::string const& ued : unknownExplicitDepends) {
+ // verify the file is in the build directory
+ std::string const absDepPath =
+ cmSystemTools::CollapseFullPath(ued, buildRoot);
+ if (cmSystemTools::IsSubDirectory(absDepPath, buildRoot)) {
+ // Generate phony build statement
+ build.Outputs[0] = ued;
+ this->WriteBuild(os, build);
+ // Add to warning on demand
+ if (warn && warnExplicitDepends.size() < 10) {
+ warnExplicitDepends.push_back(ued);
+ }
}
}
}
@@ -1320,7 +1236,8 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
"options to the custom commands that produce these files."
;
/* clang-format on */
- this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING,
+ w.str());
}
}
@@ -1330,87 +1247,144 @@ void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os)
cmGlobalNinjaGenerator::WriteDivider(os);
os << "# Built-in targets\n\n";
- this->WriteTargetAll(os);
+ this->WriteTargetDefault(os);
this->WriteTargetRebuildManifest(os);
this->WriteTargetClean(os);
this->WriteTargetHelp(os);
}
-void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os)
+void cmGlobalNinjaGenerator::WriteTargetDefault(std::ostream& os)
{
- cmNinjaDeps outputs;
- outputs.push_back(this->TargetAll);
-
- this->WritePhonyBuild(os, "The main all target.", outputs,
- this->AllDependencies);
-
if (!this->HasOutputPathPrefix()) {
- cmGlobalNinjaGenerator::WriteDefault(os, outputs,
+ cmNinjaDeps all;
+ all.push_back(this->TargetAll);
+ cmGlobalNinjaGenerator::WriteDefault(os, all,
"Make the all target the default.");
}
}
void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
{
+ if (this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION")) {
+ return;
+ }
cmLocalGenerator* lg = this->LocalGenerators[0];
- std::ostringstream cmd;
- cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(),
- cmOutputConverter::SHELL)
- << " -H"
- << lg->ConvertToOutputFormat(lg->GetSourceDirectory(),
- cmOutputConverter::SHELL)
- << " -B"
- << lg->ConvertToOutputFormat(lg->GetBinaryDirectory(),
- cmOutputConverter::SHELL);
- WriteRule(*this->RulesFileStream, "RERUN_CMAKE", cmd.str(),
- "Re-running CMake...", "Rule for re-running cmake.",
- /*depfile=*/"",
- /*deptype=*/"",
- /*rspfile=*/"",
- /*rspcontent*/ "",
- /*restat=*/"",
- /*generator=*/true);
-
- cmNinjaDeps implicitDeps;
- for (std::vector<cmLocalGenerator*>::const_iterator i =
- this->LocalGenerators.begin();
- i != this->LocalGenerators.end(); ++i) {
- std::vector<std::string> const& lf = (*i)->GetMakefile()->GetListFiles();
- for (std::vector<std::string>::const_iterator fi = lf.begin();
- fi != lf.end(); ++fi) {
- implicitDeps.push_back(this->ConvertToNinjaPath(*fi));
+ {
+ cmNinjaRule rule("RERUN_CMAKE");
+ rule.Command =
+ cmStrCat(CMakeCmd(), " -S",
+ lg->ConvertToOutputFormat(lg->GetSourceDirectory(),
+ cmOutputConverter::SHELL),
+ " -B",
+ lg->ConvertToOutputFormat(lg->GetBinaryDirectory(),
+ cmOutputConverter::SHELL));
+ rule.Description = "Re-running CMake...";
+ rule.Comment = "Rule for re-running cmake.";
+ rule.Generator = true;
+ WriteRule(*this->RulesFileStream, rule);
+ }
+
+ cmNinjaBuild reBuild("RERUN_CMAKE");
+ reBuild.Comment = "Re-run CMake if any of its inputs changed.";
+ reBuild.Outputs.push_back(this->NinjaOutputPath(NINJA_BUILD_FILE));
+
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ for (std::string const& fi : localGen->GetMakefile()->GetListFiles()) {
+ reBuild.ImplicitDeps.push_back(this->ConvertToNinjaPath(fi));
}
}
- implicitDeps.push_back(this->CMakeCacheFile);
-
- std::sort(implicitDeps.begin(), implicitDeps.end());
- implicitDeps.erase(std::unique(implicitDeps.begin(), implicitDeps.end()),
- implicitDeps.end());
+ reBuild.ImplicitDeps.push_back(this->CMakeCacheFile);
- cmNinjaVars variables;
// Use 'console' pool to get non buffered output of the CMake re-run call
// Available since Ninja 1.5
if (SupportsConsolePool()) {
- variables["pool"] = "console";
+ reBuild.Variables["pool"] = "console";
}
- std::string const ninjaBuildFile = this->NinjaOutputPath(NINJA_BUILD_FILE);
- this->WriteBuild(os, "Re-run CMake if any of its inputs changed.",
- "RERUN_CMAKE",
- /*outputs=*/cmNinjaDeps(1, ninjaBuildFile),
- /*implicitOuts=*/cmNinjaDeps(),
- /*explicitDeps=*/cmNinjaDeps(), implicitDeps,
- /*orderOnlyDeps=*/cmNinjaDeps(), variables);
+ cmake* cm = this->GetCMakeInstance();
+ if (this->SupportsManifestRestat() && cm->DoWriteGlobVerifyTarget()) {
+ {
+ cmNinjaRule rule("VERIFY_GLOBS");
+ rule.Command =
+ cmStrCat(CMakeCmd(), " -P ",
+ lg->ConvertToOutputFormat(cm->GetGlobVerifyScript(),
+ cmOutputConverter::SHELL));
+ rule.Description = "Re-checking globbed directories...";
+ rule.Comment = "Rule for re-checking globbed directories.";
+ rule.Generator = true;
+ this->WriteRule(*this->RulesFileStream, rule);
+ }
+
+ cmNinjaBuild phonyBuild("phony");
+ phonyBuild.Comment = "Phony target to force glob verification run.";
+ phonyBuild.Outputs.push_back(cm->GetGlobVerifyScript() + "_force");
+ this->WriteBuild(os, phonyBuild);
+
+ reBuild.Variables["restat"] = "1";
+ std::string const verifyScriptFile =
+ this->NinjaOutputPath(cm->GetGlobVerifyScript());
+ std::string const verifyStampFile =
+ this->NinjaOutputPath(cm->GetGlobVerifyStamp());
+ {
+ cmNinjaBuild vgBuild("VERIFY_GLOBS");
+ vgBuild.Comment =
+ "Re-run CMake to check if globbed directories changed.";
+ vgBuild.Outputs.push_back(verifyStampFile);
+ vgBuild.ImplicitDeps = phonyBuild.Outputs;
+ vgBuild.Variables = reBuild.Variables;
+ this->WriteBuild(os, vgBuild);
+ }
+ reBuild.Variables.erase("restat");
+ reBuild.ImplicitDeps.push_back(verifyScriptFile);
+ reBuild.ExplicitDeps.push_back(verifyStampFile);
+ } else if (!this->SupportsManifestRestat() &&
+ cm->DoWriteGlobVerifyTarget()) {
+ std::ostringstream msg;
+ msg << "The detected version of Ninja:\n"
+ << " " << this->NinjaVersion << "\n"
+ << "is less than the version of Ninja required by CMake for adding "
+ "restat dependencies to the build.ninja manifest regeneration "
+ "target:\n"
+ << " "
+ << cmGlobalNinjaGenerator::RequiredNinjaVersionForManifestRestat()
+ << "\n";
+ msg << "Any pre-check scripts, such as those generated for file(GLOB "
+ "CONFIGURE_DEPENDS), will not be run by Ninja.";
+ this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING,
+ msg.str());
+ }
+
+ std::sort(reBuild.ImplicitDeps.begin(), reBuild.ImplicitDeps.end());
+ reBuild.ImplicitDeps.erase(
+ std::unique(reBuild.ImplicitDeps.begin(), reBuild.ImplicitDeps.end()),
+ reBuild.ImplicitDeps.end());
+
+ this->WriteBuild(os, reBuild);
- this->WritePhonyBuild(os, "A missing CMake input file is not an error.",
- implicitDeps, cmNinjaDeps());
+ {
+ cmNinjaBuild build("phony");
+ build.Comment = "A missing CMake input file is not an error.";
+ std::set_difference(std::make_move_iterator(reBuild.ImplicitDeps.begin()),
+ std::make_move_iterator(reBuild.ImplicitDeps.end()),
+ CustomCommandOutputs.begin(),
+ CustomCommandOutputs.end(),
+ std::back_inserter(build.Outputs));
+ this->WriteBuild(os, build);
+ }
+}
+
+std::string cmGlobalNinjaGenerator::CMakeCmd() const
+{
+ cmLocalGenerator* lgen = this->LocalGenerators.at(0);
+ return lgen->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(),
+ cmOutputConverter::SHELL);
}
-std::string cmGlobalNinjaGenerator::ninjaCmd() const
+std::string cmGlobalNinjaGenerator::NinjaCmd() const
{
cmLocalGenerator* lgen = this->LocalGenerators[0];
- if (lgen) {
+ if (lgen != nullptr) {
return lgen->ConvertToOutputFormat(this->NinjaCommand,
cmOutputConverter::SHELL);
}
@@ -1427,44 +1401,115 @@ bool cmGlobalNinjaGenerator::SupportsImplicitOuts() const
return this->NinjaSupportsImplicitOuts;
}
+bool cmGlobalNinjaGenerator::SupportsManifestRestat() const
+{
+ return this->NinjaSupportsManifestRestat;
+}
+
+bool cmGlobalNinjaGenerator::SupportsMultilineDepfile() const
+{
+ return this->NinjaSupportsMultilineDepfile;
+}
+
+bool cmGlobalNinjaGenerator::WriteTargetCleanAdditional(std::ostream& os)
+{
+ cmLocalGenerator* lgr = this->LocalGenerators.at(0);
+ std::string cleanScriptRel = "CMakeFiles/clean_additional.cmake";
+ std::string cleanScriptAbs =
+ cmStrCat(lgr->GetBinaryDirectory(), '/', cleanScriptRel);
+
+ // Check if there are additional files to clean
+ if (this->AdditionalCleanFiles.empty()) {
+ // Remove cmake clean script file if it exists
+ cmSystemTools::RemoveFile(cleanScriptAbs);
+ return false;
+ }
+
+ // Write cmake clean script file
+ {
+ cmGeneratedFileStream fout(cleanScriptAbs);
+ if (!fout) {
+ return false;
+ }
+ fout << "# Additional clean files\n\n";
+ fout << "file(REMOVE_RECURSE\n";
+ for (std::string const& acf : this->AdditionalCleanFiles) {
+ fout << " "
+ << cmOutputConverter::EscapeForCMake(ConvertToNinjaPath(acf))
+ << '\n';
+ }
+ fout << ")\n";
+ }
+ // Register clean script file
+ lgr->GetMakefile()->AddCMakeOutputFile(cleanScriptAbs);
+
+ // Write rule
+ {
+ cmNinjaRule rule("CLEAN_ADDITIONAL");
+ rule.Command = cmStrCat(
+ CMakeCmd(), " -P ",
+ lgr->ConvertToOutputFormat(this->NinjaOutputPath(cleanScriptRel),
+ cmOutputConverter::SHELL));
+ rule.Description = "Cleaning additional files...";
+ rule.Comment = "Rule for cleaning additional files.";
+ WriteRule(*this->RulesFileStream, rule);
+ }
+
+ // Write build
+ {
+ cmNinjaBuild build("CLEAN_ADDITIONAL");
+ build.Comment = "Clean additional files.";
+ build.Outputs.push_back(
+ this->NinjaOutputPath(this->GetAdditionalCleanTargetName()));
+ WriteBuild(os, build);
+ }
+ // Return success
+ return true;
+}
+
void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
{
- WriteRule(*this->RulesFileStream, "CLEAN", ninjaCmd() + " -t clean",
- "Cleaning all built files...",
- "Rule for cleaning all built files.",
- /*depfile=*/"",
- /*deptype=*/"",
- /*rspfile=*/"",
- /*rspcontent*/ "",
- /*restat=*/"",
- /*generator=*/false);
- WriteBuild(os, "Clean all the built files.", "CLEAN",
- /*outputs=*/cmNinjaDeps(1, this->NinjaOutputPath("clean")),
- /*implicitOuts=*/cmNinjaDeps(),
- /*explicitDeps=*/cmNinjaDeps(),
- /*implicitDeps=*/cmNinjaDeps(),
- /*orderOnlyDeps=*/cmNinjaDeps(),
- /*variables=*/cmNinjaVars());
+ // -- Additional clean target
+ bool additionalFiles = WriteTargetCleanAdditional(os);
+
+ // -- Default clean target
+ // Write rule
+ {
+ cmNinjaRule rule("CLEAN");
+ rule.Command = NinjaCmd() + " -t clean";
+ rule.Description = "Cleaning all built files...";
+ rule.Comment = "Rule for cleaning all built files.";
+ WriteRule(*this->RulesFileStream, rule);
+ }
+
+ // Write build
+ {
+ cmNinjaBuild build("CLEAN");
+ build.Comment = "Clean all the built files.";
+ build.Outputs.push_back(this->NinjaOutputPath(this->GetCleanTargetName()));
+ if (additionalFiles) {
+ build.ExplicitDeps.push_back(
+ this->NinjaOutputPath(this->GetAdditionalCleanTargetName()));
+ }
+ WriteBuild(os, build);
+ }
}
void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os)
{
- WriteRule(*this->RulesFileStream, "HELP", ninjaCmd() + " -t targets",
- "All primary targets available:",
- "Rule for printing all primary targets available.",
- /*depfile=*/"",
- /*deptype=*/"",
- /*rspfile=*/"",
- /*rspcontent*/ "",
- /*restat=*/"",
- /*generator=*/false);
- WriteBuild(os, "Print all primary targets available.", "HELP",
- /*outputs=*/cmNinjaDeps(1, this->NinjaOutputPath("help")),
- /*implicitOuts=*/cmNinjaDeps(),
- /*explicitDeps=*/cmNinjaDeps(),
- /*implicitDeps=*/cmNinjaDeps(),
- /*orderOnlyDeps=*/cmNinjaDeps(),
- /*variables=*/cmNinjaVars());
+ {
+ cmNinjaRule rule("HELP");
+ rule.Command = NinjaCmd() + " -t targets";
+ rule.Description = "All primary targets available:";
+ rule.Comment = "Rule for printing all primary targets available.";
+ WriteRule(*this->RulesFileStream, rule);
+ }
+ {
+ cmNinjaBuild build("HELP");
+ build.Comment = "Print all primary targets available.";
+ build.Outputs.push_back(this->NinjaOutputPath("help"));
+ WriteBuild(os, build);
+ }
}
void cmGlobalNinjaGenerator::InitOutputPathPrefix()
@@ -1513,12 +1558,13 @@ Compilation of source files within a target is split into the following steps:
command = gfortran -cpp $DEFINES $INCLUDES $FLAGS -E $in -o $out &&
cmake -E cmake_ninja_depends \
--tdi=FortranDependInfo.json --pp=$out --dep=$DEP_FILE \
- --obj=$OBJ_FILE --ddi=$DYNDEP_INTERMEDIATE_FILE
+ --obj=$OBJ_FILE --ddi=$DYNDEP_INTERMEDIATE_FILE \
+ --lang=Fortran
- build src.f90-pp.f90 | src.f90-pp.f90.ddi: Fortran_PREPROCESS src.f90
+ build src.f90-pp.f90 | src.f90.o.ddi: Fortran_PREPROCESS src.f90
OBJ_FILE = src.f90.o
- DEP_FILE = src.f90-pp.f90.d
- DYNDEP_INTERMEDIATE_FILE = src.f90-pp.f90.ddi
+ DEP_FILE = src.f90.o.d
+ DYNDEP_INTERMEDIATE_FILE = src.f90.o.ddi
The ``cmake -E cmake_ninja_depends`` tool reads the preprocessed output
and generates the ninja depfile for preprocessor dependencies. It also
@@ -1532,9 +1578,9 @@ Compilation of source files within a target is split into the following steps:
rule Fortran_DYNDEP
command = cmake -E cmake_ninja_dyndep \
- --tdi=FortranDependInfo.json --dd=$out $in
+ --tdi=FortranDependInfo.json --lang=Fortran --dd=$out $in
- build Fortran.dd: Fortran_DYNDEP src1.f90-pp.f90.ddi src2.f90-pp.f90.ddi
+ build Fortran.dd: Fortran_DYNDEP src1.f90.o.ddi src2.f90.o.ddi
The ``cmake -E cmake_ninja_dyndep`` tool reads the "ddi" files from all
sources in the target and the ``FortranModules.json`` files from targets
@@ -1572,6 +1618,19 @@ Compilation of source files within a target is split into the following steps:
(because the latter consumes the module).
*/
+struct cmSourceInfo
+{
+ // Set of provided and required modules.
+ std::set<std::string> Provides;
+ std::set<std::string> Requires;
+
+ // Set of files included in the translation unit.
+ std::set<std::string> Includes;
+};
+
+static std::unique_ptr<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran(
+ std::string const& arg_tdi, std::string const& arg_pp);
+
int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
std::vector<std::string>::const_iterator argEnd)
{
@@ -1580,8 +1639,8 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
std::string arg_dep;
std::string arg_obj;
std::string arg_ddi;
- for (std::vector<std::string>::const_iterator a = argBeg; a != argEnd; ++a) {
- std::string const& arg = *a;
+ std::string arg_lang;
+ for (std::string const& arg : cmMakeRange(argBeg, argEnd)) {
if (cmHasLiteralPrefix(arg, "--tdi=")) {
arg_tdi = arg.substr(6);
} else if (cmHasLiteralPrefix(arg, "--pp=")) {
@@ -1592,9 +1651,10 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
arg_obj = arg.substr(6);
} else if (cmHasLiteralPrefix(arg, "--ddi=")) {
arg_ddi = arg.substr(6);
+ } else if (cmHasLiteralPrefix(arg, "--lang=")) {
+ arg_lang = arg.substr(7);
} else {
- cmSystemTools::Error("-E cmake_ninja_depends unknown argument: ",
- arg.c_str());
+ cmSystemTools::Error("-E cmake_ninja_depends unknown argument: " + arg);
return 1;
}
}
@@ -1618,50 +1678,31 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
cmSystemTools::Error("-E cmake_ninja_depends requires value for --ddi=");
return 1;
}
-
- std::vector<std::string> includes;
- {
- Json::Value tdio;
- Json::Value const& tdi = tdio;
- {
- cmsys::ifstream tdif(arg_tdi.c_str(), std::ios::in | std::ios::binary);
- Json::Reader reader;
- if (!reader.parse(tdif, tdio, false)) {
- cmSystemTools::Error("-E cmake_ninja_depends failed to parse ",
- arg_tdi.c_str(),
- reader.getFormattedErrorMessages().c_str());
- return 1;
- }
- }
-
- Json::Value const& tdi_include_dirs = tdi["include-dirs"];
- if (tdi_include_dirs.isArray()) {
- for (Json::Value::const_iterator i = tdi_include_dirs.begin();
- i != tdi_include_dirs.end(); ++i) {
- includes.push_back(i->asString());
- }
- }
+ if (arg_lang.empty()) {
+ cmSystemTools::Error("-E cmake_ninja_depends requires value for --lang=");
+ return 1;
}
- cmFortranSourceInfo info;
- std::set<std::string> defines;
- cmFortranParser parser(includes, defines, info);
- if (!cmFortranParser_FilePush(&parser, arg_pp.c_str())) {
- cmSystemTools::Error("-E cmake_ninja_depends failed to open ",
- arg_pp.c_str());
+ std::unique_ptr<cmSourceInfo> info;
+ if (arg_lang == "Fortran") {
+ info = cmcmd_cmake_ninja_depends_fortran(arg_tdi, arg_pp);
+ } else {
+ cmSystemTools::Error(
+ cmStrCat("-E cmake_ninja_depends does not understand the ", arg_lang,
+ " language"));
return 1;
}
- if (cmFortran_yyparse(parser.Scanner) != 0) {
- // Failed to parse the file.
+
+ if (!info) {
+ // The error message is already expected to have been output.
return 1;
}
{
- cmGeneratedFileStream depfile(arg_dep.c_str());
+ cmGeneratedFileStream depfile(arg_dep);
depfile << cmSystemTools::ConvertToUnixOutputPath(arg_pp) << ":";
- for (std::set<std::string>::iterator i = info.Includes.begin();
- i != info.Includes.end(); ++i) {
- depfile << " \\\n " << cmSystemTools::ConvertToUnixOutputPath(*i);
+ for (std::string const& include : info->Includes) {
+ depfile << " \\\n " << cmSystemTools::ConvertToUnixOutputPath(include);
}
depfile << "\n";
}
@@ -1670,30 +1711,82 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
ddi["object"] = arg_obj;
Json::Value& ddi_provides = ddi["provides"] = Json::arrayValue;
- for (std::set<std::string>::iterator i = info.Provides.begin();
- i != info.Provides.end(); ++i) {
- ddi_provides.append(*i);
+ for (std::string const& provide : info->Provides) {
+ ddi_provides.append(provide);
}
Json::Value& ddi_requires = ddi["requires"] = Json::arrayValue;
- for (std::set<std::string>::iterator i = info.Requires.begin();
- i != info.Requires.end(); ++i) {
+ for (std::string const& r : info->Requires) {
// Require modules not provided in the same source.
- if (!info.Provides.count(*i)) {
- ddi_requires.append(*i);
+ if (!info->Provides.count(r)) {
+ ddi_requires.append(r);
}
}
- cmGeneratedFileStream ddif(arg_ddi.c_str());
+ cmGeneratedFileStream ddif(arg_ddi);
ddif << ddi;
if (!ddif) {
- cmSystemTools::Error("-E cmake_ninja_depends failed to write ",
- arg_ddi.c_str());
+ cmSystemTools::Error("-E cmake_ninja_depends failed to write " + arg_ddi);
return 1;
}
return 0;
}
-struct cmFortranObjectInfo
+std::unique_ptr<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran(
+ std::string const& arg_tdi, std::string const& arg_pp)
+{
+ cmFortranCompiler fc;
+ std::vector<std::string> includes;
+ {
+ Json::Value tdio;
+ Json::Value const& tdi = tdio;
+ {
+ cmsys::ifstream tdif(arg_tdi.c_str(), std::ios::in | std::ios::binary);
+ Json::Reader reader;
+ if (!reader.parse(tdif, tdio, false)) {
+ cmSystemTools::Error(
+ cmStrCat("-E cmake_ninja_depends failed to parse ", arg_tdi,
+ reader.getFormattedErrorMessages()));
+ return nullptr;
+ }
+ }
+
+ Json::Value const& tdi_include_dirs = tdi["include-dirs"];
+ if (tdi_include_dirs.isArray()) {
+ for (auto const& tdi_include_dir : tdi_include_dirs) {
+ includes.push_back(tdi_include_dir.asString());
+ }
+ }
+
+ Json::Value const& tdi_compiler_id = tdi["compiler-id"];
+ fc.Id = tdi_compiler_id.asString();
+
+ Json::Value const& tdi_submodule_sep = tdi["submodule-sep"];
+ fc.SModSep = tdi_submodule_sep.asString();
+
+ Json::Value const& tdi_submodule_ext = tdi["submodule-ext"];
+ fc.SModExt = tdi_submodule_ext.asString();
+ }
+
+ cmFortranSourceInfo finfo;
+ std::set<std::string> defines;
+ cmFortranParser parser(fc, includes, defines, finfo);
+ if (!cmFortranParser_FilePush(&parser, arg_pp.c_str())) {
+ cmSystemTools::Error("-E cmake_ninja_depends failed to open " + arg_pp);
+ return nullptr;
+ }
+ if (cmFortran_yyparse(parser.Scanner) != 0) {
+ // Failed to parse the file.
+ return nullptr;
+ }
+
+ auto info = cm::make_unique<cmSourceInfo>();
+ info->Provides = finfo.Provides;
+ info->Requires = finfo.Requires;
+ info->Includes = finfo.Includes;
+ return info;
+}
+
+struct cmDyndepObjectInfo
{
std::string Object;
std::vector<std::string> Provides;
@@ -1705,7 +1798,8 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
std::string const& dir_cur_src, std::string const& dir_cur_bld,
std::string const& arg_dd, std::vector<std::string> const& arg_ddis,
std::string const& module_dir,
- std::vector<std::string> const& linked_target_dirs)
+ std::vector<std::string> const& linked_target_dirs,
+ std::string const& arg_lang)
{
// Setup path conversions.
{
@@ -1714,62 +1808,59 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
snapshot.GetDirectory().SetCurrentBinary(dir_cur_bld);
snapshot.GetDirectory().SetRelativePathTopSource(dir_top_src.c_str());
snapshot.GetDirectory().SetRelativePathTopBinary(dir_top_bld.c_str());
- CM_AUTO_PTR<cmMakefile> mfd(new cmMakefile(this, snapshot));
- CM_AUTO_PTR<cmLocalNinjaGenerator> lgd(static_cast<cmLocalNinjaGenerator*>(
- this->CreateLocalGenerator(mfd.get())));
+ auto mfd = cm::make_unique<cmMakefile>(this, snapshot);
+ std::unique_ptr<cmLocalNinjaGenerator> lgd(
+ static_cast<cmLocalNinjaGenerator*>(
+ this->CreateLocalGenerator(mfd.get())));
this->Makefiles.push_back(mfd.release());
this->LocalGenerators.push_back(lgd.release());
}
- std::vector<cmFortranObjectInfo> objects;
- for (std::vector<std::string>::const_iterator ddii = arg_ddis.begin();
- ddii != arg_ddis.end(); ++ddii) {
+ std::vector<cmDyndepObjectInfo> objects;
+ for (std::string const& arg_ddi : arg_ddis) {
// Load the ddi file and compute the module file paths it provides.
Json::Value ddio;
Json::Value const& ddi = ddio;
- cmsys::ifstream ddif(ddii->c_str(), std::ios::in | std::ios::binary);
+ cmsys::ifstream ddif(arg_ddi.c_str(), std::ios::in | std::ios::binary);
Json::Reader reader;
if (!reader.parse(ddif, ddio, false)) {
- cmSystemTools::Error("-E cmake_ninja_dyndep failed to parse ",
- ddii->c_str(),
- reader.getFormattedErrorMessages().c_str());
+ cmSystemTools::Error(cmStrCat("-E cmake_ninja_dyndep failed to parse ",
+ arg_ddi,
+ reader.getFormattedErrorMessages()));
return false;
}
- cmFortranObjectInfo info;
+ cmDyndepObjectInfo info;
info.Object = ddi["object"].asString();
Json::Value const& ddi_provides = ddi["provides"];
if (ddi_provides.isArray()) {
- for (Json::Value::const_iterator i = ddi_provides.begin();
- i != ddi_provides.end(); ++i) {
- info.Provides.push_back(i->asString());
+ for (auto const& ddi_provide : ddi_provides) {
+ info.Provides.push_back(ddi_provide.asString());
}
}
Json::Value const& ddi_requires = ddi["requires"];
if (ddi_requires.isArray()) {
- for (Json::Value::const_iterator i = ddi_requires.begin();
- i != ddi_requires.end(); ++i) {
- info.Requires.push_back(i->asString());
+ for (auto const& ddi_require : ddi_requires) {
+ info.Requires.push_back(ddi_require.asString());
}
}
- objects.push_back(info);
+ objects.push_back(std::move(info));
}
// Map from module name to module file path, if known.
std::map<std::string, std::string> mod_files;
// Populate the module map with those provided by linked targets first.
- for (std::vector<std::string>::const_iterator di =
- linked_target_dirs.begin();
- di != linked_target_dirs.end(); ++di) {
- std::string const ltmn = *di + "/FortranModules.json";
+ for (std::string const& linked_target_dir : linked_target_dirs) {
+ std::string const ltmn =
+ cmStrCat(linked_target_dir, "/", arg_lang, "Modules.json");
Json::Value ltm;
cmsys::ifstream ltmf(ltmn.c_str(), std::ios::in | std::ios::binary);
Json::Reader reader;
if (ltmf && !reader.parse(ltmf, ltm, false)) {
- cmSystemTools::Error("-E cmake_ninja_dyndep failed to parse ",
- di->c_str(),
- reader.getFormattedErrorMessages().c_str());
+ cmSystemTools::Error(cmStrCat("-E cmake_ninja_dyndep failed to parse ",
+ linked_target_dir,
+ reader.getFormattedErrorMessages()));
return false;
}
if (ltm.isObject()) {
@@ -1783,55 +1874,47 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile(
// We do this after loading the modules provided by linked targets
// in case we have one of the same name that must be preferred.
Json::Value tm = Json::objectValue;
- for (std::vector<cmFortranObjectInfo>::iterator oi = objects.begin();
- oi != objects.end(); ++oi) {
- for (std::vector<std::string>::iterator i = oi->Provides.begin();
- i != oi->Provides.end(); ++i) {
- std::string const mod = module_dir + *i + ".mod";
- mod_files[*i] = mod;
- tm[*i] = mod;
+ for (cmDyndepObjectInfo const& object : objects) {
+ for (std::string const& p : object.Provides) {
+ std::string const mod = module_dir + p;
+ mod_files[p] = mod;
+ tm[p] = mod;
}
}
- cmGeneratedFileStream ddf(arg_dd.c_str());
+ cmGeneratedFileStream ddf(arg_dd);
ddf << "ninja_dyndep_version = 1.0\n";
- for (std::vector<cmFortranObjectInfo>::iterator oi = objects.begin();
- oi != objects.end(); ++oi) {
- std::string const ddComment;
- std::string const ddRule = "dyndep";
- cmNinjaDeps ddOutputs;
- cmNinjaDeps ddImplicitOuts;
- cmNinjaDeps ddExplicitDeps;
- cmNinjaDeps ddImplicitDeps;
- cmNinjaDeps ddOrderOnlyDeps;
- cmNinjaVars ddVars;
-
- ddOutputs.push_back(oi->Object);
- for (std::vector<std::string>::iterator i = oi->Provides.begin();
- i != oi->Provides.end(); ++i) {
- ddImplicitOuts.push_back(this->ConvertToNinjaPath(mod_files[*i]));
- }
- for (std::vector<std::string>::iterator i = oi->Requires.begin();
- i != oi->Requires.end(); ++i) {
- std::map<std::string, std::string>::iterator m = mod_files.find(*i);
- if (m != mod_files.end()) {
- ddImplicitDeps.push_back(this->ConvertToNinjaPath(m->second));
+ {
+ cmNinjaBuild build("dyndep");
+ build.Outputs.emplace_back("");
+ for (cmDyndepObjectInfo const& object : objects) {
+ build.Outputs[0] = object.Object;
+ build.ImplicitOuts.clear();
+ for (std::string const& p : object.Provides) {
+ build.ImplicitOuts.push_back(this->ConvertToNinjaPath(mod_files[p]));
+ }
+ build.ImplicitDeps.clear();
+ for (std::string const& r : object.Requires) {
+ auto mit = mod_files.find(r);
+ if (mit != mod_files.end()) {
+ build.ImplicitDeps.push_back(this->ConvertToNinjaPath(mit->second));
+ }
+ }
+ build.Variables.clear();
+ if (!object.Provides.empty()) {
+ build.Variables.emplace("restat", "1");
}
- }
- if (!oi->Provides.empty()) {
- ddVars["restat"] = "1";
- }
- this->WriteBuild(ddf, ddComment, ddRule, ddOutputs, ddImplicitOuts,
- ddExplicitDeps, ddImplicitDeps, ddOrderOnlyDeps, ddVars);
+ this->WriteBuild(ddf, build);
+ }
}
// Store the map of modules provided by this target in a file for
// use by dependents that reference this target in linked-target-dirs.
std::string const target_mods_file =
- cmSystemTools::GetFilenamePath(arg_dd) + "/FortranModules.json";
- cmGeneratedFileStream tmf(target_mods_file.c_str());
+ cmSystemTools::GetFilenamePath(arg_dd) + "/" + arg_lang + "Modules.json";
+ cmGeneratedFileStream tmf(target_mods_file);
tmf << tm;
return true;
@@ -1844,21 +1927,21 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
cmSystemTools::HandleResponseFile(argBeg, argEnd);
std::string arg_dd;
+ std::string arg_lang;
std::string arg_tdi;
std::vector<std::string> arg_ddis;
- for (std::vector<std::string>::const_iterator a = arg_full.begin();
- a != arg_full.end(); ++a) {
- std::string const& arg = *a;
+ for (std::string const& arg : arg_full) {
if (cmHasLiteralPrefix(arg, "--tdi=")) {
arg_tdi = arg.substr(6);
+ } else if (cmHasLiteralPrefix(arg, "--lang=")) {
+ arg_lang = arg.substr(7);
} else if (cmHasLiteralPrefix(arg, "--dd=")) {
arg_dd = arg.substr(5);
} else if (!cmHasLiteralPrefix(arg, "--") &&
cmHasLiteralSuffix(arg, ".ddi")) {
arg_ddis.push_back(arg);
} else {
- cmSystemTools::Error("-E cmake_ninja_dyndep unknown argument: ",
- arg.c_str());
+ cmSystemTools::Error("-E cmake_ninja_dyndep unknown argument: " + arg);
return 1;
}
}
@@ -1866,6 +1949,10 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
cmSystemTools::Error("-E cmake_ninja_dyndep requires value for --tdi=");
return 1;
}
+ if (arg_lang.empty()) {
+ cmSystemTools::Error("-E cmake_ninja_dyndep requires value for --lang=");
+ return 1;
+ }
if (arg_dd.empty()) {
cmSystemTools::Error("-E cmake_ninja_dyndep requires value for --dd=");
return 1;
@@ -1877,9 +1964,9 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
cmsys::ifstream tdif(arg_tdi.c_str(), std::ios::in | std::ios::binary);
Json::Reader reader;
if (!reader.parse(tdif, tdio, false)) {
- cmSystemTools::Error("-E cmake_ninja_dyndep failed to parse ",
- arg_tdi.c_str(),
- reader.getFormattedErrorMessages().c_str());
+ cmSystemTools::Error(cmStrCat("-E cmake_ninja_dyndep failed to parse ",
+ arg_tdi,
+ reader.getFormattedErrorMessages()));
return 1;
}
}
@@ -1889,27 +1976,26 @@ int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg,
std::string const dir_top_bld = tdi["dir-top-bld"].asString();
std::string const dir_top_src = tdi["dir-top-src"].asString();
std::string module_dir = tdi["module-dir"].asString();
- if (!module_dir.empty()) {
+ if (!module_dir.empty() && !cmHasLiteralSuffix(module_dir, "/")) {
module_dir += "/";
}
std::vector<std::string> linked_target_dirs;
Json::Value const& tdi_linked_target_dirs = tdi["linked-target-dirs"];
if (tdi_linked_target_dirs.isArray()) {
- for (Json::Value::const_iterator i = tdi_linked_target_dirs.begin();
- i != tdi_linked_target_dirs.end(); ++i) {
- linked_target_dirs.push_back(i->asString());
+ for (auto const& tdi_linked_target_dir : tdi_linked_target_dirs) {
+ linked_target_dirs.push_back(tdi_linked_target_dir.asString());
}
}
- cmake cm(cmake::RoleInternal);
+ cmake cm(cmake::RoleInternal, cmState::Unknown);
cm.SetHomeDirectory(dir_top_src);
cm.SetHomeOutputDirectory(dir_top_bld);
- CM_AUTO_PTR<cmGlobalNinjaGenerator> ggd(
+ std::unique_ptr<cmGlobalNinjaGenerator> ggd(
static_cast<cmGlobalNinjaGenerator*>(cm.CreateGlobalGenerator("Ninja")));
- if (!ggd.get() ||
+ if (!ggd ||
!ggd->WriteDyndepFile(dir_top_src, dir_top_bld, dir_cur_src, dir_cur_bld,
- arg_dd, arg_ddis, module_dir,
- linked_target_dirs)) {
+ arg_dd, arg_ddis, module_dir, linked_target_dirs,
+ arg_lang)) {
return 1;
}
return 0;
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index b0008f74a..244e9fd38 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -3,24 +3,27 @@
#ifndef cmGlobalNinjaGenerator_h
#define cmGlobalNinjaGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
+#include <memory>
#include <set>
#include <string>
+#include <unordered_map>
+#include <unordered_set>
#include <utility>
#include <vector>
+#include "cm_codecvt.hxx"
+
+#include "cmGeneratedFileStream.h"
#include "cmGlobalCommonGenerator.h"
-#include "cmGlobalGenerator.h"
#include "cmGlobalGeneratorFactory.h"
#include "cmNinjaTypes.h"
#include "cmPolicies.h"
-#include "cm_codecvt.hxx"
class cmCustomCommand;
-class cmGeneratedFileStream;
class cmGeneratorTarget;
class cmLinkLineComputer;
class cmLocalGenerator;
@@ -40,8 +43,6 @@ struct cmDocumentationEntry;
* it is handle by Ninja's -v option.
* - We don't care about computing any progress status since Ninja manages
* it itself.
- * - We don't care about generating a clean target since Ninja already have
- * a clean tool.
* - We generate one build.ninja and one rules.ninja per project.
* - We try to minimize the number of generated rules: one per target and
* language.
@@ -72,13 +73,12 @@ public:
static void WriteDivider(std::ostream& os);
static std::string EncodeRuleName(std::string const& name);
- static std::string EncodeIdent(const std::string& ident, std::ostream& vars);
static std::string EncodeLiteral(const std::string& lit);
std::string EncodePath(const std::string& path);
cmLinkLineComputer* CreateLinkLineComputer(
cmOutputConverter* outputConverter,
- cmStateDirectory const& stateDir) const CM_OVERRIDE;
+ cmStateDirectory const& stateDir) const override;
/**
* Write the given @a comment to the output stream @a os. It
@@ -98,57 +98,30 @@ public:
*/
static bool SupportsPlatform() { return false; }
- bool IsIPOSupported() const CM_OVERRIDE { return true; }
+ bool IsIPOSupported() const override { return true; }
/**
- * Write a build statement to @a os with the @a comment using
- * the @a rule the list of @a outputs files and inputs.
- * It also writes the variables bound to this build statement.
+ * Write a build statement @a build to @a os.
* @warning no escaping of any kind is done here.
*/
- void WriteBuild(std::ostream& os, const std::string& comment,
- const std::string& rule, const cmNinjaDeps& outputs,
- const cmNinjaDeps& implicitOuts,
- const cmNinjaDeps& explicitDeps,
- const cmNinjaDeps& implicitDeps,
- const cmNinjaDeps& orderOnlyDeps,
- const cmNinjaVars& variables,
- const std::string& rspfile = std::string(),
- int cmdLineLimit = 0, bool* usedResponseFile = CM_NULLPTR);
+ void WriteBuild(std::ostream& os, cmNinjaBuild const& build,
+ int cmdLineLimit = 0, bool* usedResponseFile = nullptr);
- /**
- * Helper to write a build statement with the special 'phony' rule.
- */
- void WritePhonyBuild(std::ostream& os, const std::string& comment,
- const cmNinjaDeps& outputs,
- const cmNinjaDeps& explicitDeps,
- const cmNinjaDeps& implicitDeps = cmNinjaDeps(),
- const cmNinjaDeps& orderOnlyDeps = cmNinjaDeps(),
- const cmNinjaVars& variables = cmNinjaVars());
-
- void WriteCustomCommandBuild(const std::string& command,
- const std::string& description,
- const std::string& comment,
- const std::string& depfile, bool uses_terminal,
- bool restat, const cmNinjaDeps& outputs,
- const cmNinjaDeps& deps = cmNinjaDeps(),
- const cmNinjaDeps& orderOnly = cmNinjaDeps());
- void WriteMacOSXContentBuild(const std::string& input,
- const std::string& output);
+ void WriteCustomCommandBuild(
+ const std::string& command, const std::string& description,
+ const std::string& comment, const std::string& depfile,
+ const std::string& pool, bool uses_terminal, bool restat,
+ const cmNinjaDeps& outputs,
+ const cmNinjaDeps& explicitDeps = cmNinjaDeps(),
+ const cmNinjaDeps& orderOnlyDeps = cmNinjaDeps());
+
+ void WriteMacOSXContentBuild(std::string input, std::string output);
/**
- * Write a rule statement named @a name to @a os with the @a comment,
- * the mandatory @a command, the @a depfile and the @a description.
- * It also writes the variables bound to this rule statement.
+ * Write a rule statement to @a os.
* @warning no escaping of any kind is done here.
*/
- static void WriteRule(std::ostream& os, const std::string& name,
- const std::string& command,
- const std::string& description,
- const std::string& comment, const std::string& depfile,
- const std::string& deptype, const std::string& rspfile,
- const std::string& rspcontent,
- const std::string& restat, bool generator);
+ static void WriteRule(std::ostream& os, cmNinjaRule const& rule);
/**
* Write a variable named @a name to @a os with value @a value and an
@@ -183,11 +156,9 @@ public:
return new cmGlobalGeneratorSimpleFactory<cmGlobalNinjaGenerator>();
}
- ~cmGlobalNinjaGenerator() CM_OVERRIDE {}
+ cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override;
- cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) CM_OVERRIDE;
-
- std::string GetName() const CM_OVERRIDE
+ std::string GetName() const override
{
return cmGlobalNinjaGenerator::GetActualName();
}
@@ -195,60 +166,55 @@ public:
static std::string GetActualName() { return "Ninja"; }
/** Get encoding used by generator for ninja files */
- codecvt::Encoding GetMakefileEncoding() const CM_OVERRIDE;
+ codecvt::Encoding GetMakefileEncoding() const override;
static void GetDocumentation(cmDocumentationEntry& entry);
void EnableLanguage(std::vector<std::string> const& languages,
- cmMakefile* mf, bool optional) CM_OVERRIDE;
+ cmMakefile* mf, bool optional) override;
- void GenerateBuildCommand(std::vector<std::string>& makeCommand,
- const std::string& makeProgram,
- const std::string& projectName,
- const std::string& projectDir,
- const std::string& targetName,
- const std::string& config, bool fast, bool verbose,
- std::vector<std::string> const& makeOptions =
- std::vector<std::string>()) CM_OVERRIDE;
+ std::vector<GeneratedMakeCommand> GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions =
+ std::vector<std::string>()) override;
// Setup target names
- const char* GetAllTargetName() const CM_OVERRIDE { return "all"; }
- const char* GetInstallTargetName() const CM_OVERRIDE { return "install"; }
- const char* GetInstallLocalTargetName() const CM_OVERRIDE
+ const char* GetAllTargetName() const override { return "all"; }
+ const char* GetInstallTargetName() const override { return "install"; }
+ const char* GetInstallLocalTargetName() const override
{
return "install/local";
}
- const char* GetInstallStripTargetName() const CM_OVERRIDE
+ const char* GetInstallStripTargetName() const override
{
return "install/strip";
}
- const char* GetTestTargetName() const CM_OVERRIDE { return "test"; }
- const char* GetPackageTargetName() const CM_OVERRIDE { return "package"; }
- const char* GetPackageSourceTargetName() const CM_OVERRIDE
+ const char* GetTestTargetName() const override { return "test"; }
+ const char* GetPackageTargetName() const override { return "package"; }
+ const char* GetPackageSourceTargetName() const override
{
return "package_source";
}
- const char* GetEditCacheTargetName() const CM_OVERRIDE
- {
- return "edit_cache";
- }
- const char* GetRebuildCacheTargetName() const CM_OVERRIDE
+ const char* GetEditCacheTargetName() const override { return "edit_cache"; }
+ const char* GetRebuildCacheTargetName() const override
{
return "rebuild_cache";
}
- const char* GetCleanTargetName() const CM_OVERRIDE { return "clean"; }
+ const char* GetCleanTargetName() const override { return "clean"; }
cmGeneratedFileStream* GetBuildFileStream() const
{
- return this->BuildFileStream;
+ return this->BuildFileStream.get();
}
cmGeneratedFileStream* GetRulesFileStream() const
{
- return this->RulesFileStream;
+ return this->RulesFileStream.get();
}
- std::string ConvertToNinjaPath(const std::string& path) const;
+ std::string const& ConvertToNinjaPath(const std::string& path) const;
struct MapToNinjaPathImpl
{
@@ -262,7 +228,14 @@ public:
return this->GG->ConvertToNinjaPath(path);
}
};
- MapToNinjaPathImpl MapToNinjaPath() { return MapToNinjaPathImpl(this); }
+ MapToNinjaPathImpl MapToNinjaPath() { return { this }; }
+
+ // -- Additional clean files
+ void AddAdditionalCleanFile(std::string fileName);
+ const char* GetAdditionalCleanTargetName() const
+ {
+ return "CMakeFiles/clean.additional";
+ }
void AddCXXCompileCommand(const std::string& commandLine,
const std::string& sourceFile);
@@ -272,11 +245,7 @@ public:
* Call WriteRule() behind the scene but perform some check before like:
* - Do not add twice the same rule.
*/
- void AddRule(const std::string& name, const std::string& command,
- const std::string& description, const std::string& comment,
- const std::string& depfile, const std::string& deptype,
- const std::string& rspfile, const std::string& rspcontent,
- const std::string& restat, bool generator);
+ void AddRule(cmNinjaRule const& rule);
bool HasRule(const std::string& name);
@@ -323,31 +292,34 @@ public:
cmNinjaTargetDepends depends = DependOnTargetArtifact);
void AppendTargetDependsClosure(cmGeneratorTarget const* target,
cmNinjaDeps& outputs);
- void AddDependencyToAll(cmGeneratorTarget* target);
- void AddDependencyToAll(const std::string& input);
+ void AppendTargetDependsClosure(cmGeneratorTarget const* target,
+ cmNinjaOuts& outputs, bool omit_self);
const std::vector<cmLocalGenerator*>& GetLocalGenerators() const
{
return LocalGenerators;
}
- bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target)
- {
- return cmGlobalGenerator::IsExcluded(root, target);
- }
-
int GetRuleCmdLength(const std::string& name) { return RuleCmdLength[name]; }
void AddTargetAlias(const std::string& alias, cmGeneratorTarget* target);
- void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const CM_OVERRIDE;
+ void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;
// Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3
static std::string RequiredNinjaVersion() { return "1.3"; }
static std::string RequiredNinjaVersionForConsolePool() { return "1.5"; }
static std::string RequiredNinjaVersionForImplicitOuts() { return "1.7"; }
+ static std::string RequiredNinjaVersionForManifestRestat() { return "1.8"; }
+ static std::string RequiredNinjaVersionForMultilineDepfile()
+ {
+ return "1.9";
+ }
+ static std::string RequiredNinjaVersionForDyndeps() { return "1.10"; }
bool SupportsConsolePool() const;
bool SupportsImplicitOuts() const;
+ bool SupportsManifestRestat() const;
+ bool SupportsMultilineDepfile() const;
std::string NinjaOutputPath(std::string const& path) const;
bool HasOutputPathPrefix() const { return !this->OutputPathPrefix.empty(); }
@@ -360,27 +332,28 @@ public:
std::string const& arg_dd,
std::vector<std::string> const& arg_ddis,
std::string const& module_dir,
- std::vector<std::string> const& linked_target_dirs);
+ std::vector<std::string> const& linked_target_dirs,
+ std::string const& arg_lang);
protected:
- void Generate() CM_OVERRIDE;
+ void Generate() override;
- bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const CM_OVERRIDE { return true; }
+ bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const override { return true; }
private:
- std::string GetEditCacheCommand() const CM_OVERRIDE;
- bool FindMakeProgram(cmMakefile* mf) CM_OVERRIDE;
+ std::string GetEditCacheCommand() const override;
+ bool FindMakeProgram(cmMakefile* mf) override;
void CheckNinjaFeatures();
bool CheckLanguages(std::vector<std::string> const& languages,
- cmMakefile* mf) const CM_OVERRIDE;
+ cmMakefile* mf) const override;
bool CheckFortran(cmMakefile* mf) const;
- void OpenBuildFileStream();
+ bool OpenBuildFileStream();
void CloseBuildFileStream();
void CloseCompileCommandsStream();
- void OpenRulesFileStream();
+ bool OpenRulesFileStream();
void CloseRulesFileStream();
/// Write the common disclaimer text at the top of each build file.
@@ -393,8 +366,9 @@ private:
void WriteUnknownExplicitDependencies(std::ostream& os);
void WriteBuiltinTargets(std::ostream& os);
- void WriteTargetAll(std::ostream& os);
+ void WriteTargetDefault(std::ostream& os);
void WriteTargetRebuildManifest(std::ostream& os);
+ bool WriteTargetCleanAdditional(std::ostream& os);
void WriteTargetClean(std::ostream& os);
void WriteTargetHelp(std::ostream& os);
@@ -402,30 +376,24 @@ private:
cmGeneratorTarget const* target,
std::set<cmGeneratorTarget const*>& depends);
- std::string ninjaCmd() const;
+ std::string CMakeCmd() const;
+ std::string NinjaCmd() const;
/// The file containing the build statement. (the relationship of the
/// compilation DAG).
- cmGeneratedFileStream* BuildFileStream;
+ std::unique_ptr<cmGeneratedFileStream> BuildFileStream;
/// The file containing the rule statements. (The action attached to each
/// edge of the compilation DAG).
- cmGeneratedFileStream* RulesFileStream;
- cmGeneratedFileStream* CompileCommandsStream;
-
- /// The type used to store the set of rules added to the generated build
- /// system.
- typedef std::set<std::string> RulesSetType;
+ std::unique_ptr<cmGeneratedFileStream> RulesFileStream;
+ std::unique_ptr<cmGeneratedFileStream> CompileCommandsStream;
/// The set of rules added to the generated build system.
- RulesSetType Rules;
+ std::unordered_set<std::string> Rules;
/// Length of rule command, used by rsp file evaluation
- std::map<std::string, int> RuleCmdLength;
+ std::unordered_map<std::string, int> RuleCmdLength;
- /// The set of dependencies to add to the "all" target.
- cmNinjaDeps AllDependencies;
-
- bool UsingGCCOnWindows;
+ bool UsingGCCOnWindows = false;
/// The set of custom commands we have seen.
std::set<cmCustomCommand const*> CustomCommands;
@@ -435,8 +403,8 @@ private:
/// Whether we are collecting known build outputs and needed
/// dependencies to determine unknown dependencies.
- bool ComputingUnknownDependencies;
- cmPolicies::PolicyStatus PolicyCMP0058;
+ bool ComputingUnknownDependencies = false;
+ cmPolicies::PolicyStatus PolicyCMP0058 = cmPolicies::WARN;
/// The combined explicit dependencies of custom build commands
std::set<std::string> CombinedCustomCommandExplicitDependencies;
@@ -446,21 +414,23 @@ private:
std::set<std::string> CombinedBuildOutputs;
/// The mapping from source file to assumed dependencies.
- std::map<std::string, std::set<std::string> > AssumedSourceDependencies;
+ std::map<std::string, std::set<std::string>> AssumedSourceDependencies;
- typedef std::map<std::string, cmGeneratorTarget*> TargetAliasMap;
+ using TargetAliasMap = std::map<std::string, cmGeneratorTarget*>;
TargetAliasMap TargetAliases;
- typedef std::map<cmGeneratorTarget const*,
- std::set<cmGeneratorTarget const*> >
- TargetDependsClosureMap;
- TargetDependsClosureMap TargetDependsClosures;
+ std::map<cmGeneratorTarget const*, cmNinjaOuts> TargetDependsClosures;
+
+ /// the local cache for calls to ConvertToNinjaPath
+ mutable std::unordered_map<std::string, std::string> ConvertToNinjaPathCache;
std::string NinjaCommand;
std::string NinjaVersion;
- bool NinjaSupportsConsolePool;
- bool NinjaSupportsImplicitOuts;
- unsigned long NinjaSupportsDyndeps;
+ bool NinjaSupportsConsolePool = false;
+ bool NinjaSupportsImplicitOuts = false;
+ bool NinjaSupportsManifestRestat = false;
+ bool NinjaSupportsMultilineDepfile = false;
+ bool NinjaSupportsDyndeps = false;
private:
void InitOutputPathPrefix();
@@ -468,6 +438,7 @@ private:
std::string OutputPathPrefix;
std::string TargetAll;
std::string CMakeCacheFile;
+ std::set<std::string> AdditionalCleanFiles;
};
#endif // ! cmGlobalNinjaGenerator_h
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 23b3718dc..4c2d69f09 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -7,6 +7,8 @@
#include <sstream>
#include <utility>
+#include <cm/memory>
+
#include "cmAlgorithms.h"
#include "cmDocumentationEntry.h"
#include "cmGeneratedFileStream.h"
@@ -20,8 +22,8 @@
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmTarget.h"
#include "cmTargetDepend.h"
#include "cmake.h"
@@ -38,7 +40,7 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3(cmake* cm)
#else
this->UseLinkScript = true;
#endif
- this->CommandDatabase = CM_NULLPTR;
+ this->CommandDatabase = nullptr;
this->IncludeDirective = "include";
this->DefineWindowsNULL = false;
@@ -50,16 +52,15 @@ void cmGlobalUnixMakefileGenerator3::EnableLanguage(
std::vector<std::string> const& languages, cmMakefile* mf, bool optional)
{
this->cmGlobalGenerator::EnableLanguage(languages, mf, optional);
- for (std::vector<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
- if (*l == "NONE") {
+ for (std::string const& language : languages) {
+ if (language == "NONE") {
continue;
}
- this->ResolveLanguageCompiler(*l, mf, optional);
+ this->ResolveLanguageCompiler(language, mf, optional);
}
}
-///! Create a local generator appropriate to this Global Generator
+//! Create a local generator appropriate to this Global Generator
cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(
cmMakefile* mf)
{
@@ -107,11 +108,9 @@ void cmGlobalUnixMakefileGenerator3::ComputeTargetObjectDirectory(
cmGeneratorTarget* gt) const
{
// Compute full path to object file directory for this target.
- std::string dir;
- dir += gt->LocalGenerator->GetCurrentBinaryDirectory();
- dir += "/";
- dir += gt->LocalGenerator->GetTargetDirectory(gt);
- dir += "/";
+ std::string dir =
+ cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(), '/',
+ gt->LocalGenerator->GetTargetDirectory(gt), '/');
gt->ObjectDirectory = dir;
}
@@ -130,9 +129,8 @@ void cmGlobalUnixMakefileGenerator3::Generate()
// initialize progress
unsigned long total = 0;
- for (ProgressMapType::const_iterator pmi = this->ProgressMap.begin();
- pmi != this->ProgressMap.end(); ++pmi) {
- total += pmi->second.NumberOfActions;
+ for (auto const& pmi : this->ProgressMap) {
+ total += pmi.second.NumberOfActions;
}
// write each target's progress.make this loop is done twice. Bascially the
@@ -143,17 +141,13 @@ void cmGlobalUnixMakefileGenerator3::Generate()
// well. This is because the all targets require more information that is
// computed in the first loop.
unsigned long current = 0;
- for (ProgressMapType::iterator pmi = this->ProgressMap.begin();
- pmi != this->ProgressMap.end(); ++pmi) {
- pmi->second.WriteProgressVariables(total, current);
- }
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- cmLocalGenerator* lg = this->LocalGenerators[i];
- std::string markFileName = lg->GetCurrentBinaryDirectory();
- markFileName += "/";
- markFileName += cmake::GetCMakeFilesDirectory();
- markFileName += "/progress.marks";
- cmGeneratedFileStream markFile(markFileName.c_str());
+ for (auto& pmi : this->ProgressMap) {
+ pmi.second.WriteProgressVariables(total, current);
+ }
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
+ std::string markFileName =
+ cmStrCat(lg->GetCurrentBinaryDirectory(), "/CMakeFiles/progress.marks");
+ cmGeneratedFileStream markFile(markFileName);
markFile << this->CountProgressMarksInAll(lg) << "\n";
}
@@ -161,10 +155,10 @@ void cmGlobalUnixMakefileGenerator3::Generate()
this->WriteMainMakefile2();
this->WriteMainCMakefile();
- if (this->CommandDatabase != CM_NULLPTR) {
+ if (this->CommandDatabase != nullptr) {
*this->CommandDatabase << std::endl << "]";
delete this->CommandDatabase;
- this->CommandDatabase = CM_NULLPTR;
+ this->CommandDatabase = nullptr;
}
}
@@ -172,24 +166,23 @@ void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand(
const std::string& sourceFile, const std::string& workingDirectory,
const std::string& compileCommand)
{
- if (this->CommandDatabase == CM_NULLPTR) {
+ if (this->CommandDatabase == nullptr) {
std::string commandDatabaseName =
- std::string(this->GetCMakeInstance()->GetHomeOutputDirectory()) +
+ this->GetCMakeInstance()->GetHomeOutputDirectory() +
"/compile_commands.json";
- this->CommandDatabase =
- new cmGeneratedFileStream(commandDatabaseName.c_str());
+ this->CommandDatabase = new cmGeneratedFileStream(commandDatabaseName);
*this->CommandDatabase << "[" << std::endl;
} else {
*this->CommandDatabase << "," << std::endl;
}
*this->CommandDatabase << "{" << std::endl
- << " \"directory\": \""
+ << R"( "directory": ")"
<< cmGlobalGenerator::EscapeJSON(workingDirectory)
<< "\"," << std::endl
- << " \"command\": \""
+ << R"( "command": ")"
<< cmGlobalGenerator::EscapeJSON(compileCommand)
<< "\"," << std::endl
- << " \"file\": \""
+ << R"( "file": ")"
<< cmGlobalGenerator::EscapeJSON(sourceFile) << "\""
<< std::endl
<< "}";
@@ -201,10 +194,9 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
// because the check-build-system step compares the makefile time to
// see if the build system must be regenerated.
std::string makefileName =
- this->GetCMakeInstance()->GetHomeOutputDirectory();
- makefileName += cmake::GetCMakeFilesDirectory();
- makefileName += "/Makefile2";
- cmGeneratedFileStream makefileStream(makefileName.c_str(), false,
+ cmStrCat(this->GetCMakeInstance()->GetHomeOutputDirectory(),
+ "/CMakeFiles/Makefile2");
+ cmGeneratedFileStream makefileStream(makefileName, false,
this->GetMakefileEncoding());
if (!makefileStream) {
return;
@@ -222,7 +214,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
// Just depend on the all target to drive the build.
std::vector<std::string> depends;
std::vector<std::string> no_commands;
- depends.push_back("all");
+ depends.emplace_back("all");
// Write the rule.
lg->WriteMakeRule(makefileStream,
@@ -234,49 +226,47 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
// The all and preinstall rules might never have any dependencies
// added to them.
- if (this->EmptyRuleHackDepends != "") {
+ if (!this->EmptyRuleHackDepends.empty()) {
depends.push_back(this->EmptyRuleHackDepends);
}
- // Write and empty all:
- lg->WriteMakeRule(makefileStream, "The main recursive all target", "all",
- depends, no_commands, true);
-
- // Write an empty preinstall:
- lg->WriteMakeRule(makefileStream, "The main recursive preinstall target",
- "preinstall", depends, no_commands, true);
-
// Write out the "special" stuff
lg->WriteSpecialTargetsTop(makefileStream);
- // write the target convenience rules
- unsigned int i;
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
- this->WriteConvenienceRules2(makefileStream, lg);
+ // Write the directory level rules.
+ for (auto const& it : this->ComputeDirectoryTargets()) {
+ this->WriteDirectoryRules2(makefileStream, it.second);
}
- lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[0]);
+ // Write the target convenience rules
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ this->WriteConvenienceRules2(
+ makefileStream, static_cast<cmLocalUnixMakefileGenerator3*>(localGen));
+ }
+
+ // Write special bottom targets
lg->WriteSpecialTargetsBottom(makefileStream);
}
void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
{
+ if (this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION")) {
+ return;
+ }
+
// Open the output file. This should not be copy-if-different
// because the check-build-system step compares the makefile time to
// see if the build system must be regenerated.
std::string cmakefileName =
- this->GetCMakeInstance()->GetHomeOutputDirectory();
- cmakefileName += cmake::GetCMakeFilesDirectory();
- cmakefileName += "/Makefile.cmake";
- cmGeneratedFileStream cmakefileStream(cmakefileName.c_str());
+ cmStrCat(this->GetCMakeInstance()->GetHomeOutputDirectory(),
+ "/CMakeFiles/Makefile.cmake");
+ cmGeneratedFileStream cmakefileStream(cmakefileName);
if (!cmakefileStream) {
return;
}
std::string makefileName =
- this->GetCMakeInstance()->GetHomeOutputDirectory();
- makefileName += "/Makefile";
+ cmStrCat(this->GetCMakeInstance()->GetHomeOutputDirectory(), "/Makefile");
// get a local generator for some useful methods
cmLocalUnixMakefileGenerator3* lg =
@@ -292,18 +282,21 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
// for each cmMakefile get its list of dependencies
std::vector<std::string> lfiles;
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
-
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
// Get the list of files contributing to this generation step.
- lfiles.insert(lfiles.end(), lg->GetMakefile()->GetListFiles().begin(),
- lg->GetMakefile()->GetListFiles().end());
+ cmAppend(lfiles, localGen->GetMakefile()->GetListFiles());
+ }
+
+ cmake* cm = this->GetCMakeInstance();
+ if (cm->DoWriteGlobVerifyTarget()) {
+ lfiles.push_back(cm->GetGlobVerifyScript());
+ lfiles.push_back(cm->GetGlobVerifyStamp());
}
+
// Sort the list and remove duplicates.
std::sort(lfiles.begin(), lfiles.end(), std::less<std::string>());
#if !defined(__VMS) // The Compaq STL on VMS crashes, so accept duplicates.
- std::vector<std::string>::iterator new_end =
- std::unique(lfiles.begin(), lfiles.end());
+ auto new_end = std::unique(lfiles.begin(), lfiles.end());
lfiles.erase(new_end, lfiles.end());
#endif
@@ -316,25 +309,27 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
<< "# The top level Makefile was generated from the following files:\n"
<< "set(CMAKE_MAKEFILE_DEPENDS\n"
<< " \"CMakeCache.txt\"\n";
- for (std::vector<std::string>::const_iterator i = lfiles.begin();
- i != lfiles.end(); ++i) {
- cmakefileStream << " \"" << lg->ConvertToRelativePath(currentBinDir, *i)
+ for (std::string const& f : lfiles) {
+ cmakefileStream << " \""
+ << lg->MaybeConvertToRelativePath(currentBinDir, f)
<< "\"\n";
}
cmakefileStream << " )\n\n";
// Build the path to the cache check file.
- std::string check = this->GetCMakeInstance()->GetHomeOutputDirectory();
- check += cmake::GetCMakeFilesDirectory();
- check += "/cmake.check_cache";
+ std::string check =
+ cmStrCat(this->GetCMakeInstance()->GetHomeOutputDirectory(),
+ "/CMakeFiles/cmake.check_cache");
// Set the corresponding makefile in the cmake file.
cmakefileStream << "# The corresponding makefile is:\n"
<< "set(CMAKE_MAKEFILE_OUTPUTS\n"
<< " \""
- << lg->ConvertToRelativePath(currentBinDir, makefileName)
+ << lg->MaybeConvertToRelativePath(currentBinDir,
+ makefileName)
<< "\"\n"
- << " \"" << lg->ConvertToRelativePath(currentBinDir, check)
+ << " \""
+ << lg->MaybeConvertToRelativePath(currentBinDir, check)
<< "\"\n";
cmakefileStream << " )\n\n";
@@ -344,23 +339,20 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
{
cmakefileStream << "# Byproducts of CMake generate step:\n"
<< "set(CMAKE_MAKEFILE_PRODUCTS\n";
- const std::vector<std::string>& outfiles =
- lg->GetMakefile()->GetOutputFiles();
- for (std::vector<std::string>::const_iterator k = outfiles.begin();
- k != outfiles.end(); ++k) {
- cmakefileStream << " \"" << lg->ConvertToRelativePath(binDir, *k)
+ for (std::string const& outfile : lg->GetMakefile()->GetOutputFiles()) {
+ cmakefileStream << " \""
+ << lg->MaybeConvertToRelativePath(binDir, outfile)
<< "\"\n";
}
// add in all the directory information files
std::string tmpStr;
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- lg =
- static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
- tmpStr = lg->GetCurrentBinaryDirectory();
- tmpStr += cmake::GetCMakeFilesDirectory();
- tmpStr += "/CMakeDirectoryInformation.cmake";
- cmakefileStream << " \"" << lg->ConvertToRelativePath(binDir, tmpStr)
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ lg = static_cast<cmLocalUnixMakefileGenerator3*>(localGen);
+ tmpStr = cmStrCat(lg->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/CMakeDirectoryInformation.cmake");
+ cmakefileStream << " \""
+ << lg->MaybeConvertToRelativePath(binDir, tmpStr)
<< "\"\n";
}
cmakefileStream << " )\n\n";
@@ -379,21 +371,19 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefileLanguageRules(
// now list all the target info files
cmakefileStream << "# Dependency information for all targets:\n";
cmakefileStream << "set(CMAKE_DEPEND_INFO_FILES\n";
- for (unsigned int i = 0; i < lGenerators.size(); ++i) {
- lg = static_cast<cmLocalUnixMakefileGenerator3*>(lGenerators[i]);
+ for (cmLocalGenerator* lGenerator : lGenerators) {
+ lg = static_cast<cmLocalUnixMakefileGenerator3*>(lGenerator);
// for all of out targets
- std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); l++) {
- if (((*l)->GetType() == cmStateEnums::EXECUTABLE) ||
- ((*l)->GetType() == cmStateEnums::STATIC_LIBRARY) ||
- ((*l)->GetType() == cmStateEnums::SHARED_LIBRARY) ||
- ((*l)->GetType() == cmStateEnums::MODULE_LIBRARY) ||
- ((*l)->GetType() == cmStateEnums::OBJECT_LIBRARY) ||
- ((*l)->GetType() == cmStateEnums::UTILITY)) {
- cmGeneratorTarget* gt = *l;
- std::string tname = lg->GetRelativeTargetDirectory(gt);
- tname += "/DependInfo.cmake";
+ for (cmGeneratorTarget* tgt : lg->GetGeneratorTargets()) {
+ if ((tgt->GetType() == cmStateEnums::EXECUTABLE) ||
+ (tgt->GetType() == cmStateEnums::STATIC_LIBRARY) ||
+ (tgt->GetType() == cmStateEnums::SHARED_LIBRARY) ||
+ (tgt->GetType() == cmStateEnums::MODULE_LIBRARY) ||
+ (tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) ||
+ (tgt->GetType() == cmStateEnums::UTILITY)) {
+ cmGeneratorTarget* gt = tgt;
+ std::string tname =
+ cmStrCat(lg->GetRelativeTargetDirectory(gt), "/DependInfo.cmake");
cmSystemTools::ConvertToUnixSlashes(tname);
cmakefileStream << " \"" << tname << "\"\n";
}
@@ -403,134 +393,144 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefileLanguageRules(
}
void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2(
- std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3* lg,
- const char* pass, bool check_all, bool check_relink)
+ std::ostream& ruleFileStream, DirectoryTarget const& dt, const char* pass,
+ bool check_all, bool check_relink, std::vector<std::string> const& commands)
{
- // Get the relative path to the subdirectory from the top.
- std::string makeTarget = lg->GetCurrentBinaryDirectory();
- makeTarget += "/";
- makeTarget += pass;
+ auto* lg = static_cast<cmLocalUnixMakefileGenerator3*>(dt.LG);
+ std::string makeTarget =
+ cmStrCat(lg->GetCurrentBinaryDirectory(), '/', pass);
// The directory-level rule should depend on the target-level rules
// for all targets in the directory.
std::vector<std::string> depends;
- std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator l = targets.begin();
- l != targets.end(); ++l) {
- cmGeneratorTarget* gtarget = *l;
- int type = gtarget->GetType();
- if ((type == cmStateEnums::EXECUTABLE) ||
- (type == cmStateEnums::STATIC_LIBRARY) ||
- (type == cmStateEnums::SHARED_LIBRARY) ||
- (type == cmStateEnums::MODULE_LIBRARY) ||
- (type == cmStateEnums::OBJECT_LIBRARY) ||
- (type == cmStateEnums::UTILITY)) {
- // Add this to the list of depends rules in this directory.
- if ((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) &&
- (!check_relink ||
- gtarget->NeedRelinkBeforeInstall(lg->GetConfigName()))) {
- std::string tname = lg->GetRelativeTargetDirectory(gtarget);
- tname += "/";
- tname += pass;
- depends.push_back(tname);
- }
+ for (DirectoryTarget::Target const& t : dt.Targets) {
+ // Add this to the list of depends rules in this directory.
+ if ((!check_all || !t.ExcludeFromAll) &&
+ (!check_relink ||
+ t.GT->NeedRelinkBeforeInstall(lg->GetConfigName()))) {
+ // The target may be from a different directory; use its local gen.
+ auto const* tlg = static_cast<cmLocalUnixMakefileGenerator3 const*>(
+ t.GT->GetLocalGenerator());
+ std::string tname =
+ cmStrCat(tlg->GetRelativeTargetDirectory(t.GT), '/', pass);
+ depends.push_back(std::move(tname));
}
}
// The directory-level rule should depend on the directory-level
// rules of the subdirectories.
- std::vector<cmStateSnapshot> children = lg->GetStateSnapshot().GetChildren();
- for (std::vector<cmStateSnapshot>::const_iterator ci = children.begin();
- ci != children.end(); ++ci) {
- std::string subdir = ci->GetDirectory().GetCurrentBinary();
- subdir += "/";
- subdir += pass;
- depends.push_back(subdir);
+ for (DirectoryTarget::Dir const& d : dt.Children) {
+ if (check_all && d.ExcludeFromAll) {
+ continue;
+ }
+ std::string subdir = cmStrCat(d.Path, '/', pass);
+ depends.push_back(std::move(subdir));
}
// Work-around for makes that drop rules that have no dependencies
// or commands.
- if (depends.empty() && this->EmptyRuleHackDepends != "") {
+ if (depends.empty() && !this->EmptyRuleHackDepends.empty()) {
depends.push_back(this->EmptyRuleHackDepends);
}
// Write the rule.
- std::string doc = "Convenience name for \"";
- doc += pass;
- doc += "\" pass in the directory.";
- std::vector<std::string> no_commands;
- lg->WriteMakeRule(ruleFileStream, doc.c_str(), makeTarget, depends,
- no_commands, true);
+ std::string doc;
+ if (lg->IsRootMakefile()) {
+ doc = cmStrCat("The main recursive \"", pass, "\" target.");
+ } else {
+ doc = cmStrCat("Recursive \"", pass, "\" directory target.");
+ }
+ lg->WriteMakeRule(ruleFileStream, doc.c_str(), makeTarget, depends, commands,
+ true);
}
void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2(
- std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3* lg)
+ std::ostream& ruleFileStream, DirectoryTarget const& dt)
{
- // Only subdirectories need these rules.
- if (lg->IsRootMakefile()) {
- return;
- }
-
+ auto* lg = static_cast<cmLocalUnixMakefileGenerator3*>(dt.LG);
// Begin the directory-level rules section.
- std::string dir = cmSystemTools::ConvertToOutputPath(
- lg->ConvertToRelativePath(lg->GetBinaryDirectory(),
- lg->GetCurrentBinaryDirectory())
- .c_str());
- lg->WriteDivider(ruleFileStream);
- ruleFileStream << "# Directory level rules for directory " << dir << "\n\n";
+ {
+ std::string dir =
+ cmSystemTools::ConvertToOutputPath(lg->MaybeConvertToRelativePath(
+ lg->GetBinaryDirectory(), lg->GetCurrentBinaryDirectory()));
+ lg->WriteDivider(ruleFileStream);
+ if (lg->IsRootMakefile()) {
+ ruleFileStream << "# Directory level rules for the build root directory";
+ } else {
+ ruleFileStream << "# Directory level rules for directory " << dir;
+ }
+ ruleFileStream << "\n\n";
+ }
// Write directory-level rules for "all".
- this->WriteDirectoryRule2(ruleFileStream, lg, "all", true, false);
-
- // Write directory-level rules for "clean".
- this->WriteDirectoryRule2(ruleFileStream, lg, "clean", false, false);
+ this->WriteDirectoryRule2(ruleFileStream, dt, "all", true, false);
// Write directory-level rules for "preinstall".
- this->WriteDirectoryRule2(ruleFileStream, lg, "preinstall", true, true);
+ this->WriteDirectoryRule2(ruleFileStream, dt, "preinstall", true, true);
+
+ // Write directory-level rules for "clean".
+ {
+ std::vector<std::string> cmds;
+ lg->AppendDirectoryCleanCommand(cmds);
+ this->WriteDirectoryRule2(ruleFileStream, dt, "clean", false, false, cmds);
+ }
}
-void cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
- std::vector<std::string>& makeCommand, const std::string& makeProgram,
- const std::string& /*projectName*/, const std::string& /*projectDir*/,
- const std::string& targetName, const std::string& /*config*/, bool fast,
- bool /*verbose*/, std::vector<std::string> const& makeOptions)
+std::vector<cmGlobalGenerator::GeneratedMakeCommand>
+cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& /*projectName*/,
+ const std::string& /*projectDir*/,
+ std::vector<std::string> const& targetNames, const std::string& /*config*/,
+ bool fast, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions)
{
- makeCommand.push_back(this->SelectMakeProgram(makeProgram));
-
- // Since we have full control over the invocation of nmake, let us
- // make it quiet.
- if (cmHasLiteralPrefix(this->GetName(), "NMake Makefiles")) {
- makeCommand.push_back("/NOLOGO");
- }
- makeCommand.insert(makeCommand.end(), makeOptions.begin(),
- makeOptions.end());
- if (!targetName.empty()) {
- cmMakefile* mf;
- if (!this->Makefiles.empty()) {
- mf = this->Makefiles[0];
- } else {
- cmStateSnapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
- snapshot.GetDirectory().SetCurrentSource(
- this->CMakeInstance->GetHomeDirectory());
- snapshot.GetDirectory().SetCurrentBinary(
- this->CMakeInstance->GetHomeOutputDirectory());
- snapshot.SetDefaultDefinitions();
- mf = new cmMakefile(this, snapshot);
+ std::unique_ptr<cmMakefile> mfu;
+ cmMakefile* mf;
+ if (!this->Makefiles.empty()) {
+ mf = this->Makefiles[0];
+ } else {
+ cmStateSnapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
+ snapshot.GetDirectory().SetCurrentSource(
+ this->CMakeInstance->GetHomeDirectory());
+ snapshot.GetDirectory().SetCurrentBinary(
+ this->CMakeInstance->GetHomeOutputDirectory());
+ snapshot.SetDefaultDefinitions();
+ mfu = cm::make_unique<cmMakefile>(this, snapshot);
+ mf = mfu.get();
+ }
+
+ GeneratedMakeCommand makeCommand;
+
+ // Make it possible to set verbosity also from command line
+ if (verbose) {
+ makeCommand.Add(cmSystemTools::GetCMakeCommand());
+ makeCommand.Add("-E");
+ makeCommand.Add("env");
+ makeCommand.Add("VERBOSE=1");
+ }
+ makeCommand.Add(this->SelectMakeProgram(makeProgram));
+
+ if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
+ makeCommand.Add("-j");
+ if (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL) {
+ makeCommand.Add(std::to_string(jobs));
}
+ }
- std::string tname = targetName;
- if (fast) {
- tname += "/fast";
- }
- cmOutputConverter conv(mf->GetStateSnapshot());
- tname =
- conv.ConvertToRelativePath(mf->GetState()->GetBinaryDirectory(), tname);
- cmSystemTools::ConvertToOutputSlashes(tname);
- makeCommand.push_back(tname);
- if (this->Makefiles.empty()) {
- delete mf;
+ makeCommand.Add(makeOptions.begin(), makeOptions.end());
+ for (auto tname : targetNames) {
+ if (!tname.empty()) {
+ if (fast) {
+ tname += "/fast";
+ }
+ tname =
+ mf->GetStateSnapshot().GetDirectory().ConvertToRelPathIfNotContained(
+ mf->GetState()->GetBinaryDirectory(), tname);
+ cmSystemTools::ConvertToOutputSlashes(tname);
+ makeCommand.Add(std::move(tname));
}
}
+ return { std::move(makeCommand) };
}
void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules(
@@ -539,18 +539,17 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules(
std::vector<std::string> depends;
std::vector<std::string> commands;
- depends.push_back("cmake_check_build_system");
+ bool regenerate = !this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION");
+ if (regenerate) {
+ depends.emplace_back("cmake_check_build_system");
+ }
// write the target convenience rules
- unsigned int i;
- cmLocalUnixMakefileGenerator3* lg;
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- lg = static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ cmLocalUnixMakefileGenerator3* lg =
+ static_cast<cmLocalUnixMakefileGenerator3*>(localGen);
// for each target Generate the rule files for each target.
- std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* gtarget = *t;
+ for (cmGeneratorTarget* gtarget : lg->GetGeneratorTargets()) {
// Don't emit the same rule twice (e.g. two targets with the same
// simple name)
int type = gtarget->GetType();
@@ -571,41 +570,38 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules(
// Write the rule.
commands.clear();
- std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
- tmp += "Makefile2";
- commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), name));
+ std::string tmp = "CMakeFiles/Makefile2";
+ commands.push_back(lg->GetRecursiveMakeCall(tmp, name));
depends.clear();
- depends.push_back("cmake_check_build_system");
+ if (regenerate) {
+ depends.emplace_back("cmake_check_build_system");
+ }
lg->WriteMakeRule(ruleFileStream, "Build rule for target.", name,
depends, commands, true);
// Add a fast rule to build the target
std::string localName = lg->GetRelativeTargetDirectory(gtarget);
std::string makefileName;
- makefileName = localName;
- makefileName += "/build.make";
+ makefileName = cmStrCat(localName, "/build.make");
depends.clear();
commands.clear();
- std::string makeTargetName = localName;
- makeTargetName += "/build";
- localName = name;
- localName += "/fast";
+ std::string makeTargetName = cmStrCat(localName, "/build");
+ localName = cmStrCat(name, "/fast");
commands.push_back(
- lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+ lg->GetRecursiveMakeCall(makefileName, makeTargetName));
lg->WriteMakeRule(ruleFileStream, "fast build rule for target.",
localName, depends, commands, true);
// Add a local name for the rule to relink the target before
// installation.
if (gtarget->NeedRelinkBeforeInstall(lg->GetConfigName())) {
- makeTargetName = lg->GetRelativeTargetDirectory(gtarget);
- makeTargetName += "/preinstall";
- localName = name;
- localName += "/preinstall";
+ makeTargetName =
+ cmStrCat(lg->GetRelativeTargetDirectory(gtarget), "/preinstall");
+ localName = cmStrCat(name, "/preinstall");
depends.clear();
commands.clear();
commands.push_back(
- lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+ lg->GetRecursiveMakeCall(makefileName, makeTargetName));
lg->WriteMakeRule(ruleFileStream,
"Manual pre-install relink rule for target.",
localName, depends, commands, true);
@@ -623,68 +619,50 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
std::string localName;
std::string makeTargetName;
- // write the directory level rules for this local gen
- this->WriteDirectoryRules2(ruleFileStream, lg);
-
- depends.push_back("cmake_check_build_system");
+ bool regenerate = !this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION");
+ if (regenerate) {
+ depends.emplace_back("cmake_check_build_system");
+ }
// for each target Generate the rule files for each target.
- std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* gtarget = *t;
+ for (cmGeneratorTarget* gtarget : lg->GetGeneratorTargets()) {
int type = gtarget->GetType();
std::string name = gtarget->GetName();
- if (!name.empty() && ((type == cmStateEnums::EXECUTABLE) ||
- (type == cmStateEnums::STATIC_LIBRARY) ||
- (type == cmStateEnums::SHARED_LIBRARY) ||
- (type == cmStateEnums::MODULE_LIBRARY) ||
- (type == cmStateEnums::OBJECT_LIBRARY) ||
- (type == cmStateEnums::UTILITY))) {
+ if (!name.empty() &&
+ ((type == cmStateEnums::EXECUTABLE) ||
+ (type == cmStateEnums::STATIC_LIBRARY) ||
+ (type == cmStateEnums::SHARED_LIBRARY) ||
+ (type == cmStateEnums::MODULE_LIBRARY) ||
+ (type == cmStateEnums::OBJECT_LIBRARY) ||
+ (type == cmStateEnums::UTILITY))) {
std::string makefileName;
// Add a rule to build the target by name.
localName = lg->GetRelativeTargetDirectory(gtarget);
- makefileName = localName;
- makefileName += "/build.make";
-
- bool needRequiresStep = this->NeedRequiresStep(gtarget);
+ makefileName = cmStrCat(localName, "/build.make");
lg->WriteDivider(ruleFileStream);
ruleFileStream << "# Target rules for target " << localName << "\n\n";
commands.clear();
- makeTargetName = localName;
- makeTargetName += "/depend";
+ makeTargetName = cmStrCat(localName, "/depend");
commands.push_back(
- lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+ lg->GetRecursiveMakeCall(makefileName, makeTargetName));
- // add requires if we need it for this generator
- if (needRequiresStep) {
- makeTargetName = localName;
- makeTargetName += "/requires";
- commands.push_back(
- lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
- }
- makeTargetName = localName;
- makeTargetName += "/build";
+ makeTargetName = cmStrCat(localName, "/build");
commands.push_back(
- lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+ lg->GetRecursiveMakeCall(makefileName, makeTargetName));
// Write the rule.
localName += "/all";
depends.clear();
cmLocalUnixMakefileGenerator3::EchoProgress progress;
- progress.Dir = lg->GetBinaryDirectory();
- progress.Dir += cmake::GetCMakeFilesDirectory();
+ progress.Dir = cmStrCat(lg->GetBinaryDirectory(), "/CMakeFiles");
{
std::ostringstream progressArg;
const char* sep = "";
- std::vector<unsigned long>& progFiles =
- this->ProgressMap[gtarget].Marks;
- for (std::vector<unsigned long>::iterator i = progFiles.begin();
- i != progFiles.end(); ++i) {
- progressArg << sep << *i;
+ for (unsigned long progFile : this->ProgressMap[gtarget].Marks) {
+ progressArg << sep << progFile;
sep = ",";
}
progress.Arg = progressArg.str();
@@ -694,7 +672,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
if (const char* tgtMsg =
this->GetCMakeInstance()->GetState()->GetGlobalProperty(
"TARGET_MESSAGES")) {
- targetMessages = cmSystemTools::IsOn(tgtMsg);
+ targetMessages = cmIsOn(tgtMsg);
}
if (targetMessages) {
@@ -706,15 +684,6 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
localName, depends, commands, true);
- // add the all/all dependency
- if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) {
- depends.clear();
- depends.push_back(localName);
- commands.clear();
- lg->WriteMakeRule(ruleFileStream, "Include target in all.", "all",
- depends, commands, true);
- }
-
// Write the rule.
commands.clear();
@@ -731,9 +700,8 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
progCmd << " " << this->CountProgressMarksInTarget(gtarget, emitted);
commands.push_back(progCmd.str());
}
- std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
- tmp += "Makefile2";
- commands.push_back(lg->GetRecursiveMakeCall(tmp.c_str(), localName));
+ std::string tmp = "CMakeFiles/Makefile2";
+ commands.push_back(lg->GetRecursiveMakeCall(tmp, localName));
{
std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
@@ -744,9 +712,10 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
commands.push_back(progCmd.str());
}
depends.clear();
- depends.push_back("cmake_check_build_system");
- localName = lg->GetRelativeTargetDirectory(gtarget);
- localName += "/rule";
+ if (regenerate) {
+ depends.emplace_back("cmake_check_build_system");
+ }
+ localName = cmStrCat(lg->GetRelativeTargetDirectory(gtarget), "/rule");
lg->WriteMakeRule(ruleFileStream,
"Build rule for subdir invocation for target.",
localName, depends, commands, true);
@@ -760,58 +729,38 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2(
// Add rules to prepare the target for installation.
if (gtarget->NeedRelinkBeforeInstall(lg->GetConfigName())) {
- localName = lg->GetRelativeTargetDirectory(gtarget);
- localName += "/preinstall";
+ localName =
+ cmStrCat(lg->GetRelativeTargetDirectory(gtarget), "/preinstall");
depends.clear();
commands.clear();
- commands.push_back(
- lg->GetRecursiveMakeCall(makefileName.c_str(), localName));
+ commands.push_back(lg->GetRecursiveMakeCall(makefileName, localName));
lg->WriteMakeRule(ruleFileStream,
"Pre-install relink rule for target.", localName,
depends, commands, true);
-
- if (!this->IsExcluded(this->LocalGenerators[0], gtarget)) {
- depends.clear();
- depends.push_back(localName);
- commands.clear();
- lg->WriteMakeRule(ruleFileStream, "Prepare target for install.",
- "preinstall", depends, commands, true);
- }
}
// add the clean rule
localName = lg->GetRelativeTargetDirectory(gtarget);
- makeTargetName = localName;
- makeTargetName += "/clean";
+ makeTargetName = cmStrCat(localName, "/clean");
depends.clear();
commands.clear();
commands.push_back(
- lg->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+ lg->GetRecursiveMakeCall(makefileName, makeTargetName));
lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
makeTargetName, depends, commands, true);
commands.clear();
- depends.push_back(makeTargetName);
- lg->WriteMakeRule(ruleFileStream, "clean rule for target.", "clean",
- depends, commands, true);
}
}
}
-// Build a map that contains a the set of targets used by each local
+// Build a map that contains the set of targets used by each local
// generator directory level.
void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
{
this->DirectoryTargetsMap.clear();
// Loop over all targets in all local generators.
- for (std::vector<cmLocalGenerator*>::const_iterator lgi =
- this->LocalGenerators.begin();
- lgi != this->LocalGenerators.end(); ++lgi) {
- cmLocalGenerator* lg = *lgi;
- std::vector<cmGeneratorTarget*> targets = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator t = targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* gt = *t;
-
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
+ for (cmGeneratorTarget* gt : lg->GetGeneratorTargets()) {
cmLocalGenerator* tlg = gt->GetLocalGenerator();
if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
@@ -834,10 +783,8 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
// Add dependencies of the included target. An excluded
// target may still be included if it is a dependency of a
// non-excluded target.
- TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(gt);
- for (TargetDependSet::const_iterator ti = tgtdeps.begin();
- ti != tgtdeps.end(); ++ti) {
- targetSet.insert(*ti);
+ for (cmTargetDepend const& tgtdep : this->GetTargetDirectDepends(gt)) {
+ targetSet.insert(tgtdep);
}
}
}
@@ -850,13 +797,11 @@ size_t cmGlobalUnixMakefileGenerator3::CountProgressMarksInTarget(
size_t count = 0;
if (emitted.insert(target).second) {
count = this->ProgressMap[target].Marks.size();
- TargetDependSet const& depends = this->GetTargetDirectDepends(target);
- for (TargetDependSet::const_iterator di = depends.begin();
- di != depends.end(); ++di) {
- if ((*di)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmTargetDepend const& depend : this->GetTargetDirectDepends(target)) {
+ if (depend->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- count += this->CountProgressMarksInTarget(*di, emitted);
+ count += this->CountProgressMarksInTarget(depend, emitted);
}
}
return count;
@@ -867,11 +812,9 @@ size_t cmGlobalUnixMakefileGenerator3::CountProgressMarksInAll(
{
size_t count = 0;
std::set<cmGeneratorTarget const*> emitted;
- std::set<cmGeneratorTarget const*> const& targets =
- this->DirectoryTargetsMap[lg->GetStateSnapshot()];
- for (std::set<cmGeneratorTarget const*>::const_iterator t = targets.begin();
- t != targets.end(); ++t) {
- count += this->CountProgressMarksInTarget(*t, emitted);
+ for (cmGeneratorTarget const* target :
+ this->DirectoryTargetsMap[lg->GetStateSnapshot()]) {
+ count += this->CountProgressMarksInTarget(target, emitted);
}
return count;
}
@@ -887,7 +830,7 @@ void cmGlobalUnixMakefileGenerator3::RecordTargetProgress(
void cmGlobalUnixMakefileGenerator3::TargetProgress::WriteProgressVariables(
unsigned long total, unsigned long& current)
{
- cmGeneratedFileStream fout(this->VariableFile.c_str());
+ cmGeneratedFileStream fout(this->VariableFile);
for (unsigned long i = 1; i <= this->NumberOfActions; ++i) {
fout << "CMAKE_PROGRESS_" << i << " = ";
if (total <= 100) {
@@ -909,19 +852,17 @@ void cmGlobalUnixMakefileGenerator3::TargetProgress::WriteProgressVariables(
void cmGlobalUnixMakefileGenerator3::AppendGlobalTargetDepends(
std::vector<std::string>& depends, cmGeneratorTarget* target)
{
- TargetDependSet const& depends_set = this->GetTargetDirectDepends(target);
- for (TargetDependSet::const_iterator i = depends_set.begin();
- i != depends_set.end(); ++i) {
+ for (cmTargetDepend const& i : this->GetTargetDirectDepends(target)) {
// Create the target-level dependency.
- cmGeneratorTarget const* dep = *i;
+ cmGeneratorTarget const* dep = i;
if (dep->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
cmLocalUnixMakefileGenerator3* lg3 =
static_cast<cmLocalUnixMakefileGenerator3*>(dep->GetLocalGenerator());
- std::string tgtName =
- lg3->GetRelativeTargetDirectory(const_cast<cmGeneratorTarget*>(dep));
- tgtName += "/all";
+ std::string tgtName = cmStrCat(
+ lg3->GetRelativeTargetDirectory(const_cast<cmGeneratorTarget*>(dep)),
+ "/all");
depends.push_back(tgtName);
}
}
@@ -933,29 +874,27 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule(
std::string path;
std::vector<std::string> no_depends;
std::vector<std::string> commands;
- lg->AppendEcho(commands, "The following are some of the valid targets "
- "for this Makefile:");
+ lg->AppendEcho(commands,
+ "The following are some of the valid targets "
+ "for this Makefile:");
lg->AppendEcho(commands, "... all (the default if no target is provided)");
lg->AppendEcho(commands, "... clean");
- lg->AppendEcho(commands, "... depend");
+ if (!this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION")) {
+ lg->AppendEcho(commands, "... depend");
+ }
// Keep track of targets already listed.
std::set<std::string> emittedTargets;
// for each local generator
- unsigned int i;
- cmLocalUnixMakefileGenerator3* lg2;
- for (i = 0; i < this->LocalGenerators.size(); ++i) {
- lg2 =
- static_cast<cmLocalUnixMakefileGenerator3*>(this->LocalGenerators[i]);
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
+ cmLocalUnixMakefileGenerator3* lg2 =
+ static_cast<cmLocalUnixMakefileGenerator3*>(localGen);
// for the passed in makefile or if this is the top Makefile wripte out
// the targets
if (lg2 == lg || lg->IsRootMakefile()) {
// for each target Generate the rule files for each target.
- std::vector<cmGeneratorTarget*> targets = lg2->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* target = *t;
+ for (cmGeneratorTarget* target : lg2->GetGeneratorTargets()) {
cmStateEnums::TargetType type = target->GetType();
if ((type == cmStateEnums::EXECUTABLE) ||
(type == cmStateEnums::STATIC_LIBRARY) ||
@@ -966,41 +905,18 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule(
(type == cmStateEnums::UTILITY)) {
std::string const& name = target->GetName();
if (emittedTargets.insert(name).second) {
- path = "... ";
- path += name;
+ path = cmStrCat("... ", name);
lg->AppendEcho(commands, path);
}
}
}
}
}
- std::vector<std::string> const& localHelp = lg->GetLocalHelp();
- for (std::vector<std::string>::const_iterator o = localHelp.begin();
- o != localHelp.end(); ++o) {
- path = "... ";
- path += *o;
+ for (std::string const& o : lg->GetLocalHelp()) {
+ path = cmStrCat("... ", o);
lg->AppendEcho(commands, path);
}
lg->WriteMakeRule(ruleFileStream, "Help Target", "help", no_depends,
commands, true);
ruleFileStream << "\n\n";
}
-
-bool cmGlobalUnixMakefileGenerator3::NeedRequiresStep(
- const cmGeneratorTarget* target)
-{
- std::set<std::string> languages;
- target->GetLanguages(
- languages,
- target->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- for (std::set<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
- std::string var = "CMAKE_NEEDS_REQUIRES_STEP_";
- var += *l;
- var += "_FLAG";
- if (target->Target->GetMakefile()->GetDefinition(var)) {
- return true;
- }
- }
- return false;
-}
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index a656102fb..79db30ebd 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/Source/cmGlobalUnixMakefileGenerator3.h
@@ -3,12 +3,12 @@
#ifndef cmGlobalUnixMakefileGenerator3_h
#define cmGlobalUnixMakefileGenerator3_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <cstddef>
#include <iosfwd>
#include <map>
#include <set>
-#include <stddef.h>
#include <string>
#include <vector>
@@ -67,8 +67,8 @@ public:
cmGlobalUnixMakefileGenerator3>();
}
- ///! Get the name for the generator.
- std::string GetName() const CM_OVERRIDE
+ //! Get the name for the generator.
+ std::string GetName() const override
{
return cmGlobalUnixMakefileGenerator3::GetActualName();
}
@@ -89,23 +89,23 @@ public:
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
- cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) CM_OVERRIDE;
+ cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override;
/**
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
*/
void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
- bool optional) CM_OVERRIDE;
+ bool optional) override;
- void Configure() CM_OVERRIDE;
+ void Configure() override;
/**
* Generate the all required files for building this project/tree. This
* basically creates a series of LocalGenerators for each directory and
* requests that they Generate.
*/
- void Generate() CM_OVERRIDE;
+ void Generate() override;
void WriteMainCMakefileLanguageRules(cmGeneratedFileStream& cmakefileStream,
std::vector<cmLocalGenerator*>&);
@@ -127,14 +127,12 @@ public:
std::string GetEmptyRuleHackDepends() { return this->EmptyRuleHackDepends; }
// change the build command for speed
- void GenerateBuildCommand(std::vector<std::string>& makeCommand,
- const std::string& makeProgram,
- const std::string& projectName,
- const std::string& projectDir,
- const std::string& targetName,
- const std::string& config, bool fast, bool verbose,
- std::vector<std::string> const& makeOptions =
- std::vector<std::string>()) CM_OVERRIDE;
+ std::vector<GeneratedMakeCommand> GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions =
+ std::vector<std::string>()) override;
/** Record per-target progress information. */
void RecordTargetProgress(cmMakefileTargetGenerator* tg);
@@ -149,9 +147,9 @@ public:
/** Does the make tool tolerate .DELETE_ON_ERROR? */
virtual bool AllowDeleteOnError() const { return true; }
- bool IsIPOSupported() const CM_OVERRIDE { return true; }
+ bool IsIPOSupported() const override { return true; }
- void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const CM_OVERRIDE;
+ void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;
std::string IncludeDirective;
bool DefineWindowsNULL;
@@ -166,49 +164,41 @@ protected:
cmLocalUnixMakefileGenerator3*);
void WriteDirectoryRule2(std::ostream& ruleFileStream,
- cmLocalUnixMakefileGenerator3* lg, const char* pass,
- bool check_all, bool check_relink);
+ DirectoryTarget const& dt, const char* pass,
+ bool check_all, bool check_relink,
+ std::vector<std::string> const& commands = {});
void WriteDirectoryRules2(std::ostream& ruleFileStream,
- cmLocalUnixMakefileGenerator3* lg);
+ DirectoryTarget const& dt);
void AppendGlobalTargetDepends(std::vector<std::string>& depends,
cmGeneratorTarget* target);
- // does this generator need a requires step for any of its targets
- bool NeedRequiresStep(cmGeneratorTarget const*);
-
// Target name hooks for superclass.
- const char* GetAllTargetName() const CM_OVERRIDE { return "all"; }
- const char* GetInstallTargetName() const CM_OVERRIDE { return "install"; }
- const char* GetInstallLocalTargetName() const CM_OVERRIDE
+ const char* GetAllTargetName() const override { return "all"; }
+ const char* GetInstallTargetName() const override { return "install"; }
+ const char* GetInstallLocalTargetName() const override
{
return "install/local";
}
- const char* GetInstallStripTargetName() const CM_OVERRIDE
+ const char* GetInstallStripTargetName() const override
{
return "install/strip";
}
- const char* GetPreinstallTargetName() const CM_OVERRIDE
- {
- return "preinstall";
- }
- const char* GetTestTargetName() const CM_OVERRIDE { return "test"; }
- const char* GetPackageTargetName() const CM_OVERRIDE { return "package"; }
- const char* GetPackageSourceTargetName() const CM_OVERRIDE
+ const char* GetPreinstallTargetName() const override { return "preinstall"; }
+ const char* GetTestTargetName() const override { return "test"; }
+ const char* GetPackageTargetName() const override { return "package"; }
+ const char* GetPackageSourceTargetName() const override
{
return "package_source";
}
- const char* GetEditCacheTargetName() const CM_OVERRIDE
- {
- return "edit_cache";
- }
- const char* GetRebuildCacheTargetName() const CM_OVERRIDE
+ const char* GetEditCacheTargetName() const override { return "edit_cache"; }
+ const char* GetRebuildCacheTargetName() const override
{
return "rebuild_cache";
}
- const char* GetCleanTargetName() const CM_OVERRIDE { return "clean"; }
+ const char* GetCleanTargetName() const override { return "clean"; }
- bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const CM_OVERRIDE { return true; }
+ bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const override { return true; }
// Some make programs (Borland) do not keep a rule if there are no
// dependencies or commands. This is a problem for creating rules
@@ -225,18 +215,13 @@ protected:
// Store per-target progress counters.
struct TargetProgress
{
- TargetProgress()
- : NumberOfActions(0)
- {
- }
- unsigned long NumberOfActions;
+ unsigned long NumberOfActions = 0;
std::string VariableFile;
std::vector<unsigned long> Marks;
void WriteProgressVariables(unsigned long total, unsigned long& current);
};
- typedef std::map<cmGeneratorTarget const*, TargetProgress,
- cmGeneratorTarget::StrictTargetComparison>
- ProgressMapType;
+ using ProgressMapType = std::map<cmGeneratorTarget const*, TargetProgress,
+ cmGeneratorTarget::StrictTargetComparison>;
ProgressMapType ProgressMap;
size_t CountProgressMarksInTarget(
@@ -247,13 +232,13 @@ protected:
cmGeneratedFileStream* CommandDatabase;
private:
- const char* GetBuildIgnoreErrorsFlag() const CM_OVERRIDE { return "-i"; }
- std::string GetEditCacheCommand() const CM_OVERRIDE;
+ const char* GetBuildIgnoreErrorsFlag() const override { return "-i"; }
+ std::string GetEditCacheCommand() const override;
std::map<cmStateSnapshot, std::set<cmGeneratorTarget const*>,
cmStateSnapshot::StrictWeakOrder>
DirectoryTargetsMap;
- void InitializeProgressMarks() CM_OVERRIDE;
+ void InitializeProgressMarks() override;
};
#endif
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 4fff11a9f..f6472ab06 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -2,34 +2,29 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalVisualStudio10Generator.h"
+#include <algorithm>
+
+#include "cmsys/FStream.hxx"
+#include "cmsys/Glob.hxx"
+#include "cmsys/RegularExpression.hxx"
+
+#include "cm_jsoncpp_reader.h"
+
#include "cmAlgorithms.h"
#include "cmDocumentationEntry.h"
#include "cmGeneratorTarget.h"
#include "cmLocalVisualStudio10Generator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmSourceFile.h"
-#include "cmVS10CLFlagTable.h"
-#include "cmVS10CSharpFlagTable.h"
-#include "cmVS10CudaFlagTable.h"
-#include "cmVS10CudaHostFlagTable.h"
-#include "cmVS10LibFlagTable.h"
-#include "cmVS10LinkFlagTable.h"
-#include "cmVS10MASMFlagTable.h"
-#include "cmVS10NASMFlagTable.h"
-#include "cmVS10RCFlagTable.h"
#include "cmVersion.h"
#include "cmVisualStudioSlnData.h"
#include "cmVisualStudioSlnParser.h"
#include "cmXMLWriter.h"
#include "cmake.h"
-#include "cmsys/FStream.hxx"
-#include "cmsys/Glob.hxx"
-#include "cmsys/RegularExpression.hxx"
-
-#include <algorithm>
-
static const char vs10generatorName[] = "Visual Studio 10 2010";
+static std::map<std::string, std::vector<cmIDEFlagTable>> loadedFlagJsonFiles;
// Map generator name without year to name with year.
static const char* cmVS10GenName(const std::string& name, std::string& genName)
@@ -51,7 +46,7 @@ class cmGlobalVisualStudio10Generator::Factory
{
public:
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
- cmake* cm) const CM_OVERRIDE
+ cmake* cm) const override
{
std::string genName;
const char* p = cmVS10GenName(name, genName);
@@ -73,22 +68,41 @@ public:
return 0;
}
- void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
+ void GetDocumentation(cmDocumentationEntry& entry) const override
{
entry.Name = std::string(vs10generatorName) + " [arch]";
entry.Brief = "Generates Visual Studio 2010 project files. "
"Optional [arch] can be \"Win64\" or \"IA64\".";
}
- void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(vs10generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ std::vector<std::string> names;
names.push_back(vs10generatorName + std::string(" IA64"));
names.push_back(vs10generatorName + std::string(" Win64"));
+ return names;
+ }
+
+ bool SupportsToolset() const override { return true; }
+ bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("Itanium");
+ return platforms;
}
- bool SupportsToolset() const CM_OVERRIDE { return true; }
- bool SupportsPlatform() const CM_OVERRIDE { return true; }
+ std::string GetDefaultPlatformName() const override { return "Win32"; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory()
@@ -97,8 +111,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory()
}
cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
- cmake* cm, const std::string& name, const std::string& platformName)
- : cmGlobalVisualStudio8Generator(cm, name, platformName)
+ cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName)
+ : cmGlobalVisualStudio8Generator(cm, name, platformInGeneratorName)
{
std::string vc10Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
@@ -120,15 +135,16 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
this->DefaultPlatformToolset = "v100";
}
}
- this->DefaultClFlagTable = cmVS10CLFlagTable;
- this->DefaultCSharpFlagTable = cmVS10CSharpFlagTable;
- this->DefaultLibFlagTable = cmVS10LibFlagTable;
- this->DefaultLinkFlagTable = cmVS10LinkFlagTable;
- this->DefaultCudaFlagTable = cmVS10CudaFlagTable;
- this->DefaultCudaHostFlagTable = cmVS10CudaHostFlagTable;
- this->DefaultMasmFlagTable = cmVS10MASMFlagTable;
- this->DefaultNasmFlagTable = cmVS10NASMFlagTable;
- this->DefaultRcFlagTable = cmVS10RCFlagTable;
+ this->DefaultCLFlagTableName = "v10";
+ this->DefaultCSharpFlagTableName = "v10";
+ this->DefaultLibFlagTableName = "v10";
+ this->DefaultLinkFlagTableName = "v10";
+ this->DefaultCudaFlagTableName = "v10";
+ this->DefaultCudaHostFlagTableName = "v10";
+ this->DefaultMasmFlagTableName = "v10";
+ this->DefaultNasmFlagTableName = "v10";
+ this->DefaultRCFlagTableName = "v10";
+
this->Version = VS10;
this->PlatformToolsetNeedsDebugEnum = false;
}
@@ -184,7 +200,7 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
std::ostringstream e;
e << this->GetName() << " Windows CE version '" << this->SystemVersion
<< "' requires CMAKE_GENERATOR_TOOLSET to be set.";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
@@ -214,10 +230,24 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
}
}
+ this->SupportsUnityBuilds =
+ this->Version >= cmGlobalVisualStudioGenerator::VS16 ||
+ (this->Version == cmGlobalVisualStudioGenerator::VS15 &&
+ cmSystemTools::PathExists(this->VCTargetsPath +
+ "/Microsoft.Cpp.Unity.targets"));
+
if (this->GeneratorToolsetCuda.empty()) {
// Find the highest available version of the CUDA tools.
std::vector<std::string> cudaTools;
- std::string const bcDir = this->VCTargetsPath + "/BuildCustomizations";
+ std::string bcDir;
+ if (this->GeneratorToolsetCudaCustomDir.empty()) {
+ bcDir = this->VCTargetsPath + "/BuildCustomizations";
+ } else {
+ bcDir = this->GetPlatformToolsetCudaCustomDirString() +
+ "CUDAVisualStudioIntegration\\extras\\"
+ "visual_studio_integration\\MSBuildExtensions";
+ cmSystemTools::ConvertToUnixSlashes(bcDir);
+ }
cmsys::Glob gl;
gl.SetRelative(bcDir.c_str());
if (gl.FindFiles(bcDir + "/CUDA *.props")) {
@@ -228,25 +258,110 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset(
std::sort(cudaTools.begin(), cudaTools.end(),
cmSystemTools::VersionCompareGreater);
this->GeneratorToolsetCuda = cudaTools.at(0);
+ } else if (!this->GeneratorToolsetCudaCustomDir.empty()) {
+ // Generate an error if Visual Studio integration files are not found
+ // inside of custom cuda toolset.
+ std::ostringstream e;
+ /* clang-format off */
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "given toolset\n"
+ " cuda=" << this->GeneratorToolsetCudaCustomDir << "\n"
+ "cannot detect Visual Studio integration files in path\n"
+ " " << bcDir;
+
+ /* clang-format on */
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+
+ // Clear the configured tool-set
+ this->GeneratorToolsetCuda.clear();
+ }
+ }
+
+ if (!this->GeneratorToolsetVersion.empty() &&
+ this->GeneratorToolsetVersion != "Test Toolset Version") {
+ // If a specific minor version of the toolset was requested, verify that it
+ // is compatible to the major version and that is exists on disk.
+ // If not clear the value.
+ std::string version = this->GeneratorToolsetVersion;
+ cmsys::RegularExpression regex("[0-9][0-9]\\.[0-9][0-9]");
+ if (regex.find(version)) {
+ version = "v" + version.erase(2, 1);
+ } else {
+ // Version not recognized. Clear it.
+ version.clear();
+ }
+
+ if (version.find(this->GetPlatformToolsetString()) != 0) {
+ std::ostringstream e;
+ /* clang-format off */
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "given toolset and version specification\n"
+ " " << this->GetPlatformToolsetString() << ",version=" <<
+ this->GeneratorToolsetVersion << "\n"
+ "contains an invalid version specification."
+ ;
+ /* clang-format on */
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+
+ // Clear the configured tool-set
+ this->GeneratorToolsetVersion.clear();
+ }
+
+ bool const isDefaultToolset =
+ this->IsDefaultToolset(this->GeneratorToolsetVersion);
+ if (isDefaultToolset) {
+ // If the given version is the default toolset, remove the setting
+ this->GeneratorToolsetVersion.clear();
+ } else {
+ std::string const toolsetPath = this->GetAuxiliaryToolset();
+ if (!toolsetPath.empty() && !cmSystemTools::FileExists(toolsetPath)) {
+
+ std::ostringstream e;
+ /* clang-format off */
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "given toolset and version specification\n"
+ " " << this->GetPlatformToolsetString() << ",version=" <<
+ this->GeneratorToolsetVersion << "\n"
+ "does not seem to be installed at\n" <<
+ " " << toolsetPath;
+ ;
+ /* clang-format on */
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+
+ // Clear the configured tool-set
+ this->GeneratorToolsetVersion.clear();
+ }
}
}
if (const char* toolset = this->GetPlatformToolset()) {
mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET", toolset);
}
+ if (const char* version = this->GetPlatformToolsetVersion()) {
+ mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_VERSION", version);
+ }
if (const char* hostArch = this->GetPlatformToolsetHostArchitecture()) {
mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE", hostArch);
}
if (const char* cuda = this->GetPlatformToolsetCuda()) {
mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_CUDA", cuda);
}
+ if (const char* cudaDir = this->GetPlatformToolsetCudaCustomDir()) {
+ mf->AddDefinition("CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR", cudaDir);
+ }
return true;
}
bool cmGlobalVisualStudio10Generator::ParseGeneratorToolset(
std::string const& ts, cmMakefile* mf)
{
- std::vector<std::string> const fields = cmSystemTools::tokenize(ts, ",");
+ std::vector<std::string> const fields = cmTokenize(ts, ",");
std::vector<std::string>::const_iterator fi = fields.begin();
if (fi == fields.end()) {
return true;
@@ -274,7 +389,7 @@ bool cmGlobalVisualStudio10Generator::ParseGeneratorToolset(
"that contains a field after the first ',' with no '='."
;
/* clang-format on */
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
std::string const key = fi->substr(0, pos);
@@ -290,7 +405,7 @@ bool cmGlobalVisualStudio10Generator::ParseGeneratorToolset(
"that contains duplicate field key '" << key << "'."
;
/* clang-format on */
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
if (!this->ProcessGeneratorToolsetField(key, value)) {
@@ -304,7 +419,7 @@ bool cmGlobalVisualStudio10Generator::ParseGeneratorToolset(
"that contains invalid field '" << *fi << "'."
;
/* clang-format on */
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
}
@@ -316,7 +431,21 @@ bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField(
std::string const& key, std::string const& value)
{
if (key == "cuda") {
- this->GeneratorToolsetCuda = value;
+ /* test if cuda toolset is path to custom dir or cuda version */
+ auto pos = value.find_first_not_of("0123456789.");
+ if (pos != std::string::npos) {
+ this->GeneratorToolsetCudaCustomDir = value;
+ /* ensure trailing backslash for easy path joining */
+ if (this->GeneratorToolsetCudaCustomDir.back() != '\\') {
+ this->GeneratorToolsetCudaCustomDir.push_back('\\');
+ }
+ } else {
+ this->GeneratorToolsetCuda = value;
+ }
+ return true;
+ }
+ if (key == "version") {
+ this->GeneratorToolsetVersion = value;
return true;
}
return false;
@@ -344,16 +473,16 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
return false;
}
} else if (this->SystemName == "Android") {
- if (this->DefaultPlatformName != "Win32") {
+ if (this->PlatformInGeneratorName) {
std::ostringstream e;
e << "CMAKE_SYSTEM_NAME is 'Android' but CMAKE_GENERATOR "
<< "specifies a platform too: '" << this->GetName() << "'";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
std::string v = this->GetInstalledNsightTegraVersion();
if (v.empty()) {
- mf->IssueMessage(cmake::FATAL_ERROR,
+ mf->IssueMessage(MessageType::FATAL_ERROR,
"CMAKE_SYSTEM_NAME is 'Android' but "
"'NVIDIA Nsight Tegra Visual Studio Edition' "
"is not installed.");
@@ -362,7 +491,7 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
this->DefaultPlatformName = "Tegra-Android";
this->DefaultPlatformToolset = "Default";
this->NsightTegraVersion = v;
- mf->AddDefinition("CMAKE_VS_NsightTegra_VERSION", v.c_str());
+ mf->AddDefinition("CMAKE_VS_NsightTegra_VERSION", v);
}
return true;
@@ -375,11 +504,11 @@ bool cmGlobalVisualStudio10Generator::InitializeWindows(cmMakefile*)
bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf)
{
- if (this->DefaultPlatformName != "Win32") {
+ if (this->PlatformInGeneratorName) {
std::ostringstream e;
e << "CMAKE_SYSTEM_NAME is 'WindowsCE' but CMAKE_GENERATOR "
<< "specifies a platform too: '" << this->GetName() << "'";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
@@ -392,7 +521,7 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsPhone(cmMakefile* mf)
{
std::ostringstream e;
e << this->GetName() << " does not support Windows Phone.";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
@@ -400,21 +529,21 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsStore(cmMakefile* mf)
{
std::ostringstream e;
e << this->GetName() << " does not support Windows Store.";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
bool cmGlobalVisualStudio10Generator::SelectWindowsPhoneToolset(
std::string& toolset) const
{
- toolset = "";
+ toolset.clear();
return false;
}
bool cmGlobalVisualStudio10Generator::SelectWindowsStoreToolset(
std::string& toolset) const
{
- toolset = "";
+ toolset.clear();
return false;
}
@@ -426,17 +555,7 @@ std::string cmGlobalVisualStudio10Generator::SelectWindowsCEToolset() const
return "";
}
-void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
-{
- fout << "Microsoft Visual Studio Solution File, Format Version 11.00\n";
- if (this->ExpressEdition) {
- fout << "# Visual C++ Express 2010\n";
- } else {
- fout << "# Visual Studio 2010\n";
- }
-}
-
-///! Create a local generator appropriate to this Global Generator
+//! Create a local generator appropriate to this Global Generator
cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator(
cmMakefile* mf)
{
@@ -471,19 +590,18 @@ void cmGlobalVisualStudio10Generator::Generate()
"To avoid this problem CMake must use a full path for this file "
"which then triggers the VS 10 property dialog bug.";
/* clang-format on */
- lg->IssueMessage(cmake::WARNING, e.str().c_str());
+ lg->IssueMessage(MessageType::WARNING, e.str().c_str());
}
}
void cmGlobalVisualStudio10Generator::EnableLanguage(
std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
{
- for (std::vector<std::string>::const_iterator it = lang.begin();
- it != lang.end(); ++it) {
- if (*it == "ASM_NASM") {
+ for (std::string const& it : lang) {
+ if (it == "ASM_NASM") {
this->NasmEnabled = true;
}
- if (*it == "CUDA") {
+ if (it == "CUDA") {
this->CudaEnabled = true;
}
}
@@ -495,7 +613,7 @@ const char* cmGlobalVisualStudio10Generator::GetPlatformToolset() const
{
std::string const& toolset = this->GetPlatformToolsetString();
if (toolset.empty()) {
- return CM_NULLPTR;
+ return nullptr;
}
return toolset.c_str();
}
@@ -513,13 +631,48 @@ std::string const& cmGlobalVisualStudio10Generator::GetPlatformToolsetString()
return empty;
}
+const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetVersion() const
+{
+ std::string const& version = this->GetPlatformToolsetVersionString();
+ if (version.empty()) {
+ return nullptr;
+ }
+ return version.c_str();
+}
+
+std::string const&
+cmGlobalVisualStudio10Generator::GetPlatformToolsetVersionString() const
+{
+ if (!this->GeneratorToolsetVersion.empty()) {
+ return this->GeneratorToolsetVersion;
+ }
+ static std::string const empty;
+ return empty;
+}
+
const char*
cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitecture() const
{
+ std::string const& hostArch =
+ this->GetPlatformToolsetHostArchitectureString();
+ if (hostArch.empty()) {
+ return nullptr;
+ }
+ return hostArch.c_str();
+}
+
+std::string const&
+cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitectureString()
+ const
+{
if (!this->GeneratorToolsetHostArchitecture.empty()) {
- return this->GeneratorToolsetHostArchitecture.c_str();
+ return this->GeneratorToolsetHostArchitecture;
+ }
+ if (!this->DefaultPlatformToolsetHostArchitecture.empty()) {
+ return this->DefaultPlatformToolsetHostArchitecture;
}
- return CM_NULLPTR;
+ static std::string const empty;
+ return empty;
}
const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetCuda() const
@@ -527,7 +680,7 @@ const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetCuda() const
if (!this->GeneratorToolsetCuda.empty()) {
return this->GeneratorToolsetCuda.c_str();
}
- return CM_NULLPTR;
+ return nullptr;
}
std::string const&
@@ -536,13 +689,38 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaString() const
return this->GeneratorToolsetCuda;
}
+const char* cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaCustomDir()
+ const
+{
+ if (!this->GeneratorToolsetCudaCustomDir.empty()) {
+ return this->GeneratorToolsetCudaCustomDir.c_str();
+ }
+ return nullptr;
+}
+
+std::string const&
+cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaCustomDirString() const
+{
+ return this->GeneratorToolsetCudaCustomDir;
+}
+
+bool cmGlobalVisualStudio10Generator::IsDefaultToolset(
+ const std::string&) const
+{
+ return true;
+}
+
+std::string cmGlobalVisualStudio10Generator::GetAuxiliaryToolset() const
+{
+ return {};
+}
+
bool cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf)
{
if (!this->cmGlobalVisualStudio8Generator::FindMakeProgram(mf)) {
return false;
}
- mf->AddDefinition("CMAKE_VS_MSBUILD_COMMAND",
- this->GetMSBuildCommand().c_str());
+ mf->AddDefinition("CMAKE_VS_MSBUILD_COMMAND", this->GetMSBuildCommand());
return true;
}
@@ -561,9 +739,9 @@ std::string cmGlobalVisualStudio10Generator::FindMSBuildCommand()
std::string mskey;
// Search in standard location.
- mskey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\";
- mskey += this->GetToolsVersion();
- mskey += ";MSBuildToolsPath";
+ mskey = cmStrCat(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\",
+ this->GetToolsVersion(), ";MSBuildToolsPath");
if (cmSystemTools::ReadRegistryValue(mskey.c_str(), msbuild,
cmSystemTools::KeyWOW64_32)) {
cmSystemTools::ConvertToUnixSlashes(msbuild);
@@ -603,8 +781,8 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
// In a try-compile we are given the outer CMakeFiles directory.
wd = this->ConfiguredFilesPath;
} else {
- wd = this->GetCMakeInstance()->GetHomeOutputDirectory();
- wd += cmake::GetCMakeFilesDirectory();
+ wd = cmStrCat(this->GetCMakeInstance()->GetHomeOutputDirectory(),
+ "/CMakeFiles");
}
wd += "/";
wd += cmVersion::GetCMakeVersion();
@@ -625,7 +803,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
// Prepare the work directory.
if (!cmSystemTools::MakeDirectory(wd)) {
std::string e = "Failed to make directory:\n " + wd;
- mf->IssueMessage(cmake::FATAL_ERROR, e.c_str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.c_str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -637,121 +815,88 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
cmsys::ofstream fout(vcxprojAbs.c_str());
cmXMLWriter xw(fout);
- /* clang-format off */
- xw.StartDocument();
- xw.StartElement("Project");
- xw.Attribute("DefaultTargets", "Build");
- xw.Attribute("ToolsVersion", "4.0");
- xw.Attribute("xmlns",
- "http://schemas.microsoft.com/developer/msbuild/2003");
- if (this->IsNsightTegra()) {
- xw.StartElement("PropertyGroup");
- xw.Attribute("Label", "NsightTegraProject");
- xw.StartElement("NsightTegraProjectRevisionNumber");
- xw.Content("6");
- xw.EndElement(); // NsightTegraProjectRevisionNumber
- xw.EndElement(); // PropertyGroup
- }
- xw.StartElement("ItemGroup");
- xw.Attribute("Label", "ProjectConfigurations");
- xw.StartElement("ProjectConfiguration");
- xw.Attribute("Include", "Debug|" + this->GetPlatformName());
- xw.StartElement("Configuration");
- xw.Content("Debug");
- xw.EndElement(); // Configuration
- xw.StartElement("Platform");
- xw.Content(this->GetPlatformName());
- xw.EndElement(); // Platform
- xw.EndElement(); // ProjectConfiguration
- xw.EndElement(); // ItemGroup
- xw.StartElement("PropertyGroup");
- xw.Attribute("Label", "Globals");
- xw.StartElement("ProjectGuid");
- xw.Content("{F3FC6D86-508D-3FB1-96D2-995F08B142EC}");
- xw.EndElement(); // ProjectGuid
- xw.StartElement("Keyword");
- xw.Content("Win32Proj");
- xw.EndElement(); // Keyword
- xw.StartElement("Platform");
- xw.Content(this->GetPlatformName());
- xw.EndElement(); // Platform
- if (this->GetSystemName() == "WindowsPhone") {
- xw.StartElement("ApplicationType");
- xw.Content("Windows Phone");
- xw.EndElement(); // ApplicationType
- xw.StartElement("ApplicationTypeRevision");
- xw.Content(this->GetSystemVersion());
- xw.EndElement(); // ApplicationTypeRevision
- } else if (this->GetSystemName() == "WindowsStore") {
- xw.StartElement("ApplicationType");
- xw.Content("Windows Store");
- xw.EndElement(); // ApplicationType
- xw.StartElement("ApplicationTypeRevision");
- xw.Content(this->GetSystemVersion());
- xw.EndElement(); // ApplicationTypeRevision
- }
- if (!this->WindowsTargetPlatformVersion.empty()) {
- xw.StartElement("WindowsTargetPlatformVersion");
- xw.Content(this->WindowsTargetPlatformVersion);
- xw.EndElement(); // WindowsTargetPlatformVersion
- }
- if (this->GetPlatformName() == "ARM") {
- xw.StartElement("WindowsSDKDesktopARMSupport");
- xw.Content("true");
- xw.EndElement(); // WindowsSDKDesktopARMSupport
- }
- xw.EndElement(); // PropertyGroup
- xw.StartElement("Import");
- xw.Attribute("Project",
- "$(VCTargetsPath)\\Microsoft.Cpp.Default.props");
- xw.EndElement(); // Import
- if (!this->GeneratorToolsetHostArchitecture.empty()) {
- xw.StartElement("PropertyGroup");
- xw.StartElement("PreferredToolArchitecture");
- xw.Content(this->GeneratorToolsetHostArchitecture);
- xw.EndElement(); // PreferredToolArchitecture
- xw.EndElement(); // PropertyGroup
+ cmXMLDocument doc(xw);
+ cmXMLElement eprj(doc, "Project");
+ eprj.Attribute("DefaultTargets", "Build");
+ eprj.Attribute("ToolsVersion", "4.0");
+ eprj.Attribute("xmlns",
+ "http://schemas.microsoft.com/developer/msbuild/2003");
+ if (this->IsNsightTegra()) {
+ cmXMLElement epg(eprj, "PropertyGroup");
+ epg.Attribute("Label", "NsightTegraProject");
+ cmXMLElement(epg, "NsightTegraProjectRevisionNumber").Content("6");
}
- xw.StartElement("PropertyGroup");
- xw.Attribute("Label", "Configuration");
- xw.StartElement("ConfigurationType");
+ {
+ cmXMLElement eig(eprj, "ItemGroup");
+ eig.Attribute("Label", "ProjectConfigurations");
+ cmXMLElement epc(eig, "ProjectConfiguration");
+ epc.Attribute("Include", "Debug|" + this->GetPlatformName());
+ cmXMLElement(epc, "Configuration").Content("Debug");
+ cmXMLElement(epc, "Platform").Content(this->GetPlatformName());
+ }
+ {
+ cmXMLElement epg(eprj, "PropertyGroup");
+ epg.Attribute("Label", "Globals");
+ cmXMLElement(epg, "ProjectGuid")
+ .Content("{F3FC6D86-508D-3FB1-96D2-995F08B142EC}");
+ cmXMLElement(epg, "Keyword").Content("Win32Proj");
+ cmXMLElement(epg, "Platform").Content(this->GetPlatformName());
+ if (this->GetSystemName() == "WindowsPhone") {
+ cmXMLElement(epg, "ApplicationType").Content("Windows Phone");
+ cmXMLElement(epg, "ApplicationTypeRevision")
+ .Content(this->GetApplicationTypeRevision());
+ } else if (this->GetSystemName() == "WindowsStore") {
+ cmXMLElement(epg, "ApplicationType").Content("Windows Store");
+ cmXMLElement(epg, "ApplicationTypeRevision")
+ .Content(this->GetApplicationTypeRevision());
+ }
+ if (!this->WindowsTargetPlatformVersion.empty()) {
+ cmXMLElement(epg, "WindowsTargetPlatformVersion")
+ .Content(this->WindowsTargetPlatformVersion);
+ }
+ if (this->GetPlatformName() == "ARM64") {
+ cmXMLElement(epg, "WindowsSDKDesktopARM64Support").Content("true");
+ } else if (this->GetPlatformName() == "ARM") {
+ cmXMLElement(epg, "WindowsSDKDesktopARMSupport").Content("true");
+ }
+ }
+ cmXMLElement(eprj, "Import")
+ .Attribute("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props");
+ if (const char* hostArch = this->GetPlatformToolsetHostArchitecture()) {
+ cmXMLElement epg(eprj, "PropertyGroup");
+ cmXMLElement(epg, "PreferredToolArchitecture").Content(hostArch);
+ }
+ {
+ cmXMLElement epg(eprj, "PropertyGroup");
+ epg.Attribute("Label", "Configuration");
+ {
+ cmXMLElement ect(epg, "ConfigurationType");
+ if (this->IsNsightTegra()) {
+ // Tegra-Android platform does not understand "Utility".
+ ect.Content("StaticLibrary");
+ } else {
+ ect.Content("Utility");
+ }
+ }
+ cmXMLElement(epg, "CharacterSet").Content("MultiByte");
if (this->IsNsightTegra()) {
- // Tegra-Android platform does not understand "Utility".
- xw.Content("StaticLibrary");
+ cmXMLElement(epg, "NdkToolchainVersion")
+ .Content(this->GetPlatformToolsetString());
} else {
- xw.Content("Utility");
+ cmXMLElement(epg, "PlatformToolset")
+ .Content(this->GetPlatformToolsetString());
}
- xw.EndElement(); // ConfigurationType
- xw.StartElement("CharacterSet");
- xw.Content("MultiByte");
- xw.EndElement(); // CharacterSet
- if (this->IsNsightTegra()) {
- xw.StartElement("NdkToolchainVersion");
- xw.Content(this->GetPlatformToolsetString());
- xw.EndElement(); // NdkToolchainVersion
- } else {
- xw.StartElement("PlatformToolset");
- xw.Content(this->GetPlatformToolsetString());
- xw.EndElement(); // PlatformToolset
- }
- xw.EndElement(); // PropertyGroup
- xw.StartElement("Import");
- xw.Attribute("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props");
- xw.EndElement(); // Import
- xw.StartElement("ItemDefinitionGroup");
- xw.StartElement("PostBuildEvent");
- xw.StartElement("Command");
- xw.Content("echo VCTargetsPath=$(VCTargetsPath)");
- xw.EndElement(); // Command
- xw.EndElement(); // PostBuildEvent
- xw.EndElement(); // ItemDefinitionGroup
- xw.StartElement("Import");
- xw.Attribute("Project",
- "$(VCTargetsPath)\\Microsoft.Cpp.targets");
- xw.EndElement(); // Import
- xw.EndElement(); // Project
- xw.EndDocument();
- /* clang-format on */
+ }
+ cmXMLElement(eprj, "Import")
+ .Attribute("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props");
+ {
+ cmXMLElement eidg(eprj, "ItemDefinitionGroup");
+ cmXMLElement epbe(eidg, "PostBuildEvent");
+ cmXMLElement(epbe, "Command")
+ .Content("echo VCTargetsPath=$(VCTargetsPath)");
+ }
+ cmXMLElement(eprj, "Import")
+ .Attribute("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets");
}
std::vector<std::string> cmd;
@@ -779,7 +924,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
if (ret != 0) {
e << "Exit code: " << ret << "\n";
}
- mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str().c_str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -793,12 +938,14 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
return true;
}
-void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
- std::vector<std::string>& makeCommand, const std::string& makeProgram,
- const std::string& projectName, const std::string& projectDir,
- const std::string& targetName, const std::string& config, bool fast,
- bool verbose, std::vector<std::string> const& makeOptions)
+std::vector<cmGlobalGenerator::GeneratedMakeCommand>
+cmGlobalVisualStudio10Generator::GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions)
{
+ std::vector<GeneratedMakeCommand> makeCommands;
// Select the caller- or user-preferred make program, else MSBuild.
std::string makeProgramSelected =
this->SelectMakeProgram(makeProgram, this->GetMSBuildCommand());
@@ -809,14 +956,17 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
bool useDevEnv = (makeProgramLower.find("devenv") != std::string::npos ||
makeProgramLower.find("vcexpress") != std::string::npos);
+ // Workaround to convince VCExpress.exe to produce output.
+ const bool requiresOutputForward =
+ (makeProgramLower.find("vcexpress") != std::string::npos);
+
// MSBuild is preferred (and required for VS Express), but if the .sln has
// an Intel Fortran .vfproj then we have to use devenv. Parse it to find out.
cmSlnData slnData;
{
std::string slnFile;
if (!projectDir.empty()) {
- slnFile = projectDir;
- slnFile += "/";
+ slnFile = cmStrCat(projectDir, '/');
}
slnFile += projectName;
slnFile += ".sln";
@@ -824,9 +974,11 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
if (parser.ParseFile(slnFile, slnData,
cmVisualStudioSlnParser::DataGroupProjects)) {
std::vector<cmSlnProjectEntry> slnProjects = slnData.GetProjects();
- for (std::vector<cmSlnProjectEntry>::iterator i = slnProjects.begin();
- !useDevEnv && i != slnProjects.end(); ++i) {
- std::string proj = i->GetRelativePath();
+ for (cmSlnProjectEntry const& project : slnProjects) {
+ if (useDevEnv) {
+ break;
+ }
+ std::string proj = project.GetRelativePath();
if (proj.size() > 7 && proj.substr(proj.size() - 7) == ".vfproj") {
useDevEnv = true;
}
@@ -835,46 +987,70 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
}
if (useDevEnv) {
// Use devenv to build solutions containing Intel Fortran projects.
- cmGlobalVisualStudio7Generator::GenerateBuildCommand(
- makeCommand, makeProgram, projectName, projectDir, targetName, config,
- fast, verbose, makeOptions);
- return;
+ return cmGlobalVisualStudio7Generator::GenerateBuildCommand(
+ makeProgram, projectName, projectDir, targetNames, config, fast, jobs,
+ verbose, makeOptions);
}
- makeCommand.push_back(makeProgramSelected);
-
- std::string realTarget = targetName;
- // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
- if (realTarget.empty()) {
- realTarget = "ALL_BUILD";
+ std::vector<std::string> realTargetNames = targetNames;
+ if (targetNames.empty() ||
+ ((targetNames.size() == 1) && targetNames.front().empty())) {
+ realTargetNames = { "ALL_BUILD" };
}
- if (realTarget == "clean") {
- makeCommand.push_back(std::string(projectName) + ".sln");
- makeCommand.push_back("/t:Clean");
- } else {
- std::string targetProject(realTarget);
- targetProject += ".vcxproj";
- if (targetProject.find('/') == std::string::npos) {
- // it might be in a subdir
- if (cmSlnProjectEntry const* proj =
- slnData.GetProjectByName(realTarget)) {
- targetProject = proj->GetRelativePath();
- cmSystemTools::ConvertToUnixSlashes(targetProject);
+ for (const auto& tname : realTargetNames) {
+ // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug
+ // /target:ALL_BUILD
+ // /m
+ if (tname.empty()) {
+ continue;
+ }
+
+ GeneratedMakeCommand makeCommand;
+ makeCommand.RequiresOutputForward = requiresOutputForward;
+ makeCommand.Add(makeProgramSelected);
+
+ if (tname == "clean") {
+ makeCommand.Add(std::string(projectName) + ".sln");
+ makeCommand.Add("/t:Clean");
+ } else {
+ std::string targetProject = cmStrCat(tname, ".vcxproj");
+ if (targetProject.find('/') == std::string::npos) {
+ // it might be in a subdir
+ if (cmSlnProjectEntry const* proj = slnData.GetProjectByName(tname)) {
+ targetProject = proj->GetRelativePath();
+ cmSystemTools::ConvertToUnixSlashes(targetProject);
+ }
}
+ makeCommand.Add(std::move(targetProject));
}
- makeCommand.push_back(targetProject);
- }
- std::string configArg = "/p:Configuration=";
- if (!config.empty()) {
- configArg += config;
- } else {
- configArg += "Debug";
+ std::string configArg = "/p:Configuration=";
+ if (!config.empty()) {
+ configArg += config;
+ } else {
+ configArg += "Debug";
+ }
+ makeCommand.Add(configArg);
+ makeCommand.Add(std::string("/p:Platform=") + this->GetPlatformName());
+ makeCommand.Add(std::string("/p:VisualStudioVersion=") +
+ this->GetIDEVersion());
+
+ if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
+ if (jobs == cmake::DEFAULT_BUILD_PARALLEL_LEVEL) {
+ makeCommand.Add("/m");
+ } else {
+ makeCommand.Add(std::string("/m:") + std::to_string(jobs));
+ }
+ // Having msbuild.exe and cl.exe using multiple jobs is discouraged
+ makeCommand.Add("/p:CL_MPCount=1");
+ }
+
+ // Respect the verbosity: 'n' normal will show build commands
+ // 'm' minimal only the build step's title
+ makeCommand.Add(std::string("/v:") + ((verbose) ? "n" : "m"));
+ makeCommand.Add(makeOptions.begin(), makeOptions.end());
+ makeCommands.emplace_back(std::move(makeCommand));
}
- makeCommand.push_back(configArg);
- makeCommand.push_back(std::string("/p:VisualStudioVersion=") +
- this->GetIDEVersion());
- makeCommand.insert(makeCommand.end(), makeOptions.begin(),
- makeOptions.end());
+ return makeCommands;
}
bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf)
@@ -899,7 +1075,7 @@ bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf)
winSDK_7_1)) {
std::ostringstream m;
m << "Found Windows SDK v7.1: " << winSDK_7_1;
- mf->DisplayStatus(m.str().c_str(), -1);
+ mf->DisplayStatus(m.str(), -1);
this->DefaultPlatformToolset = "Windows7.1SDK";
return true;
} else {
@@ -909,7 +1085,7 @@ bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf)
<< "Install the Microsoft Windows SDK v7.1 to get 64-bit tools:\n"
<< " http://msdn.microsoft.com/en-us/windows/bb980924.aspx";
/* clang-format on */
- mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str().c_str());
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -920,14 +1096,12 @@ std::string cmGlobalVisualStudio10Generator::GenerateRuleFile(
{
// The VS 10 generator needs to create the .rule files on disk.
// Hide them away under the CMakeFiles directory.
- std::string ruleDir = this->GetCMakeInstance()->GetHomeOutputDirectory();
- ruleDir += cmake::GetCMakeFilesDirectory();
- ruleDir += "/";
- ruleDir += cmSystemTools::ComputeStringMD5(
- cmSystemTools::GetFilenamePath(output).c_str());
- std::string ruleFile = ruleDir + "/";
- ruleFile += cmSystemTools::GetFilenameName(output);
- ruleFile += ".rule";
+ std::string ruleDir = cmStrCat(
+ this->GetCMakeInstance()->GetHomeOutputDirectory(), "/CMakeFiles/",
+ cmSystemTools::ComputeStringMD5(
+ cmSystemTools::GetFilenamePath(output).c_str()));
+ std::string ruleFile =
+ cmStrCat(ruleDir, '/', cmSystemTools::GetFilenameName(output), ".rule");
return ruleFile;
}
@@ -936,7 +1110,7 @@ void cmGlobalVisualStudio10Generator::PathTooLong(cmGeneratorTarget* target,
std::string const& sfRel)
{
size_t len =
- (strlen(target->GetLocalGenerator()->GetCurrentBinaryDirectory()) + 1 +
+ (target->GetLocalGenerator()->GetCurrentBinaryDirectory().length() + 1 +
sfRel.length());
if (len > this->LongestSource.Length) {
this->LongestSource.Length = len;
@@ -946,6 +1120,34 @@ void cmGlobalVisualStudio10Generator::PathTooLong(cmGeneratorTarget* target,
}
}
+std::string cmGlobalVisualStudio10Generator::Encoding()
+{
+ return "utf-8";
+}
+
+const char* cmGlobalVisualStudio10Generator::GetToolsVersion() const
+{
+ switch (this->Version) {
+ case cmGlobalVisualStudioGenerator::VS9:
+ case cmGlobalVisualStudioGenerator::VS10:
+ case cmGlobalVisualStudioGenerator::VS11:
+ return "4.0";
+
+ // in Visual Studio 2013 they detached the MSBuild tools version
+ // from the .Net Framework version and instead made it have it's own
+ // version number
+ case cmGlobalVisualStudioGenerator::VS12:
+ return "12.0";
+ case cmGlobalVisualStudioGenerator::VS14:
+ return "14.0";
+ case cmGlobalVisualStudioGenerator::VS15:
+ return "15.0";
+ case cmGlobalVisualStudioGenerator::VS16:
+ return "16.0";
+ }
+ return "";
+}
+
bool cmGlobalVisualStudio10Generator::IsNsightTegra() const
{
return !this->NsightTegraVersion.empty();
@@ -966,67 +1168,227 @@ std::string cmGlobalVisualStudio10Generator::GetInstalledNsightTegraVersion()
return version;
}
+std::string cmGlobalVisualStudio10Generator::GetApplicationTypeRevision() const
+{
+ // Return the first two '.'-separated components of the Windows version.
+ std::string::size_type end1 = this->SystemVersion.find('.');
+ std::string::size_type end2 =
+ end1 == std::string::npos ? end1 : this->SystemVersion.find('.', end1 + 1);
+ return this->SystemVersion.substr(0, end2);
+}
+
+static std::string cmLoadFlagTableString(Json::Value entry, const char* field)
+{
+ if (entry.isMember(field)) {
+ auto string = entry[field];
+ if (string.isConvertibleTo(Json::ValueType::stringValue)) {
+ return string.asString();
+ }
+ }
+ return "";
+}
+
+static unsigned int cmLoadFlagTableSpecial(Json::Value entry,
+ const char* field)
+{
+ unsigned int value = 0;
+ if (entry.isMember(field)) {
+ auto specials = entry[field];
+ if (specials.isArray()) {
+ for (auto const& special : specials) {
+ std::string s = special.asString();
+ if (s == "UserValue") {
+ value |= cmIDEFlagTable::UserValue;
+ } else if (s == "UserIgnored") {
+ value |= cmIDEFlagTable::UserIgnored;
+ } else if (s == "UserRequired") {
+ value |= cmIDEFlagTable::UserRequired;
+ } else if (s == "Continue") {
+ value |= cmIDEFlagTable::Continue;
+ } else if (s == "SemicolonAppendable") {
+ value |= cmIDEFlagTable::SemicolonAppendable;
+ } else if (s == "UserFollowing") {
+ value |= cmIDEFlagTable::UserFollowing;
+ } else if (s == "CaseInsensitive") {
+ value |= cmIDEFlagTable::CaseInsensitive;
+ } else if (s == "SpaceAppendable") {
+ value |= cmIDEFlagTable::SpaceAppendable;
+ } else if (s == "CommaAppendable") {
+ value |= cmIDEFlagTable::CommaAppendable;
+ }
+ }
+ }
+ }
+ return value;
+}
+
+static cmIDEFlagTable const* cmLoadFlagTableJson(
+ std::string const& flagJsonPath)
+{
+ cmIDEFlagTable* ret = nullptr;
+ auto savedFlagIterator = loadedFlagJsonFiles.find(flagJsonPath);
+ if (savedFlagIterator != loadedFlagJsonFiles.end()) {
+ ret = savedFlagIterator->second.data();
+ } else {
+ Json::Reader reader;
+ cmsys::ifstream stream;
+
+ stream.open(flagJsonPath.c_str(), std::ios_base::in);
+ if (stream) {
+ Json::Value flags;
+ if (reader.parse(stream, flags, false) && flags.isArray()) {
+ std::vector<cmIDEFlagTable> flagTable;
+ for (auto const& flag : flags) {
+ cmIDEFlagTable flagEntry;
+ flagEntry.IDEName = cmLoadFlagTableString(flag, "name");
+ flagEntry.commandFlag = cmLoadFlagTableString(flag, "switch");
+ flagEntry.comment = cmLoadFlagTableString(flag, "comment");
+ flagEntry.value = cmLoadFlagTableString(flag, "value");
+ flagEntry.special = cmLoadFlagTableSpecial(flag, "flags");
+ flagTable.push_back(flagEntry);
+ }
+ cmIDEFlagTable endFlag{ "", "", "", "", 0 };
+ flagTable.push_back(endFlag);
+
+ loadedFlagJsonFiles[flagJsonPath] = flagTable;
+ ret = loadedFlagJsonFiles[flagJsonPath].data();
+ }
+ }
+ }
+ return ret;
+}
+
+static std::string cmGetFlagTableName(std::string const& toolsetName,
+ std::string const& table)
+{
+ return cmSystemTools::GetCMakeRoot() + "/Templates/MSBuild/FlagTables/" +
+ toolsetName + "_" + table + ".json";
+}
+
+cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable(
+ std::string const& optionsName, std::string const& toolsetName,
+ std::string const& defaultName, std::string const& table) const
+{
+ cmIDEFlagTable const* ret = nullptr;
+
+ std::string filename;
+ if (!optionsName.empty()) {
+ filename = cmGetFlagTableName(optionsName, table);
+ ret = cmLoadFlagTableJson(filename);
+ } else {
+ filename = cmGetFlagTableName(toolsetName, table);
+ if (cmSystemTools::FileExists(filename)) {
+ ret = cmLoadFlagTableJson(filename);
+ } else {
+ filename = cmGetFlagTableName(defaultName, table);
+ ret = cmLoadFlagTableJson(filename);
+ }
+ }
+
+ if (!ret) {
+ cmMakefile* mf = this->GetCurrentMakefile();
+
+ std::ostringstream e;
+ /* clang-format off */
+ e << "JSON flag table \"" << filename <<
+ "\" could not be loaded.\n";
+ /* clang-format on */
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str().c_str());
+ }
+ return ret;
+}
+
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const
{
- cmIDEFlagTable const* table = this->ToolsetOptions.GetClFlagTable(
+ std::string optionsName = this->ToolsetOptions.GetClFlagTableName(
this->GetPlatformName(), this->GetPlatformToolsetString());
-
- return (table != CM_NULLPTR) ? table : this->DefaultClFlagTable;
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultCLFlagTableName);
+ return LoadFlagTable(optionsName, toolsetName, defaultName, "CL");
}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable()
const
{
- cmIDEFlagTable const* table = this->ToolsetOptions.GetCSharpFlagTable(
+ std::string optionsName = this->ToolsetOptions.GetCSharpFlagTableName(
this->GetPlatformName(), this->GetPlatformToolsetString());
-
- return (table != CM_NULLPTR) ? table : this->DefaultCSharpFlagTable;
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultCSharpFlagTableName);
+ return LoadFlagTable(optionsName, toolsetName, defaultName, "CSharp");
}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const
{
- cmIDEFlagTable const* table = this->ToolsetOptions.GetRcFlagTable(
+ std::string optionsName = this->ToolsetOptions.GetRcFlagTableName(
this->GetPlatformName(), this->GetPlatformToolsetString());
-
- return (table != CM_NULLPTR) ? table : this->DefaultRcFlagTable;
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultRCFlagTableName);
+ return LoadFlagTable(optionsName, toolsetName, defaultName, "RC");
}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const
{
- cmIDEFlagTable const* table = this->ToolsetOptions.GetLibFlagTable(
+ std::string optionsName = this->ToolsetOptions.GetLibFlagTableName(
this->GetPlatformName(), this->GetPlatformToolsetString());
-
- return (table != CM_NULLPTR) ? table : this->DefaultLibFlagTable;
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultLibFlagTableName);
+ return LoadFlagTable(optionsName, toolsetName, defaultName, "LIB");
}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const
{
- cmIDEFlagTable const* table = this->ToolsetOptions.GetLinkFlagTable(
+ std::string optionsName = this->ToolsetOptions.GetLinkFlagTableName(
this->GetPlatformName(), this->GetPlatformToolsetString());
-
- return (table != CM_NULLPTR) ? table : this->DefaultLinkFlagTable;
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultLinkFlagTableName);
+ return LoadFlagTable(optionsName, toolsetName, defaultName, "Link");
}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const
{
- return this->DefaultCudaFlagTable;
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultCudaFlagTableName);
+ return LoadFlagTable("", toolsetName, defaultName, "Cuda");
}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable()
const
{
- return this->DefaultCudaHostFlagTable;
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultCudaHostFlagTableName);
+ return LoadFlagTable("", toolsetName, defaultName, "CudaHost");
}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const
{
- cmIDEFlagTable const* table = this->ToolsetOptions.GetMasmFlagTable(
+ std::string optionsName = this->ToolsetOptions.GetMasmFlagTableName(
this->GetPlatformName(), this->GetPlatformToolsetString());
-
- return (table != CM_NULLPTR) ? table : this->DefaultMasmFlagTable;
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultMasmFlagTableName);
+ return LoadFlagTable(optionsName, toolsetName, defaultName, "MASM");
}
cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const
{
- return this->DefaultNasmFlagTable;
+ std::string toolsetName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->GetPlatformToolsetString());
+ std::string defaultName = this->ToolsetOptions.GetToolsetName(
+ this->GetPlatformName(), this->DefaultNasmFlagTableName);
+ return LoadFlagTable("", toolsetName, defaultName, "NASM");
}
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 4a5c2454b..56f119363 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -14,33 +14,30 @@
class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator
{
public:
- cmGlobalVisualStudio10Generator(cmake* cm, const std::string& name,
- const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
- virtual bool MatchesGeneratorName(const std::string& name) const;
+ bool MatchesGeneratorName(const std::string& name) const override;
- virtual bool SetSystemName(std::string const& s, cmMakefile* mf);
- virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf);
- virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
+ bool SetSystemName(std::string const& s, cmMakefile* mf) override;
+ bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
+ bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf) override;
- virtual void GenerateBuildCommand(
- std::vector<std::string>& makeCommand, const std::string& makeProgram,
- const std::string& projectName, const std::string& projectDir,
- const std::string& targetName, const std::string& config, bool fast,
- bool verbose,
- std::vector<std::string> const& makeOptions = std::vector<std::string>());
+ std::vector<GeneratedMakeCommand> GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions =
+ std::vector<std::string>()) override;
- ///! create the correct local generator
- virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
+ //! create the correct local generator
+ cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override;
/**
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
*/
- virtual void EnableLanguage(std::vector<std::string> const& languages,
- cmMakefile*, bool optional);
- virtual void WriteSLNHeader(std::ostream& fout);
+ void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
+ bool optional) override;
bool IsCudaEnabled() const { return this->CudaEnabled; }
@@ -52,13 +49,22 @@ public:
const char* GetPlatformToolset() const;
std::string const& GetPlatformToolsetString() const;
+ /** The toolset version. */
+ const char* GetPlatformToolsetVersion() const;
+ std::string const& GetPlatformToolsetVersionString() const;
+
/** The toolset host architecture name (e.g. x64 for 64-bit host tools). */
const char* GetPlatformToolsetHostArchitecture() const;
+ std::string const& GetPlatformToolsetHostArchitectureString() const;
/** The cuda toolset version. */
const char* GetPlatformToolsetCuda() const;
std::string const& GetPlatformToolsetCudaString() const;
+ /** The custom cuda install directory */
+ const char* GetPlatformToolsetCudaCustomDir() const;
+ std::string const& GetPlatformToolsetCudaCustomDirString() const;
+
/** Return whether we need to use No/Debug instead of false/true
for GenerateDebugInformation. */
bool GetPlatformToolsetNeedsDebugEnum() const
@@ -79,7 +85,7 @@ public:
}
/** Return true if building for WindowsCE */
- bool TargetsWindowsCE() const { return this->SystemIsWindowsCE; }
+ bool TargetsWindowsCE() const override { return this->SystemIsWindowsCE; }
/** Return true if building for WindowsPhone */
bool TargetsWindowsPhone() const { return this->SystemIsWindowsPhone; }
@@ -87,21 +93,32 @@ public:
/** Return true if building for WindowsStore */
bool TargetsWindowsStore() const { return this->SystemIsWindowsStore; }
- virtual const char* GetCMakeCFGIntDir() const { return "$(Configuration)"; }
+ const char* GetCMakeCFGIntDir() const override { return "$(Configuration)"; }
bool Find64BitTools(cmMakefile* mf);
/** Generate an <output>.rule file path for a given command output. */
- virtual std::string GenerateRuleFile(std::string const& output) const;
+ std::string GenerateRuleFile(std::string const& output) const override;
void PathTooLong(cmGeneratorTarget* target, cmSourceFile const* sf,
std::string const& sfRel);
- virtual const char* GetToolsVersion() { return "4.0"; }
+ std::string Encoding() override;
+ const char* GetToolsVersion() const;
+
+ virtual bool IsDefaultToolset(const std::string& version) const;
+ virtual std::string GetAuxiliaryToolset() const;
+
+ bool GetSupportsUnityBuilds() const { return this->SupportsUnityBuilds; }
+
+ bool FindMakeProgram(cmMakefile* mf) override;
- bool FindMakeProgram(cmMakefile* mf) CM_OVERRIDE;
+ bool IsIPOSupported() const override { return true; }
static std::string GetInstalledNsightTegraVersion();
+ /** Return the first two components of CMAKE_SYSTEM_VERSION. */
+ std::string GetApplicationTypeRevision() const;
+
cmIDEFlagTable const* GetClFlagTable() const;
cmIDEFlagTable const* GetCSharpFlagTable() const;
cmIDEFlagTable const* GetRcFlagTable() const;
@@ -113,7 +130,10 @@ public:
cmIDEFlagTable const* GetNasmFlagTable() const;
protected:
- virtual void Generate();
+ cmGlobalVisualStudio10Generator(cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName);
+
+ void Generate() override;
virtual bool InitializeSystem(cmMakefile* mf);
virtual bool InitializeWindows(cmMakefile* mf);
virtual bool InitializeWindowsCE(cmMakefile* mf);
@@ -127,33 +147,42 @@ protected:
virtual bool SelectWindowsPhoneToolset(std::string& toolset) const;
virtual bool SelectWindowsStoreToolset(std::string& toolset) const;
- virtual const char* GetIDEVersion() { return "10.0"; }
-
std::string const& GetMSBuildCommand();
+ cmIDEFlagTable const* LoadFlagTable(std::string const& optionsName,
+ std::string const& toolsetName,
+ std::string const& defaultName,
+ std::string const& table) const;
+
std::string GeneratorToolset;
+ std::string GeneratorToolsetVersion;
std::string GeneratorToolsetHostArchitecture;
std::string GeneratorToolsetCuda;
+ std::string GeneratorToolsetCudaCustomDir;
std::string DefaultPlatformToolset;
+ std::string DefaultPlatformToolsetHostArchitecture;
std::string WindowsTargetPlatformVersion;
std::string SystemName;
std::string SystemVersion;
std::string NsightTegraVersion;
- cmIDEFlagTable const* DefaultClFlagTable;
- cmIDEFlagTable const* DefaultCSharpFlagTable;
- cmIDEFlagTable const* DefaultLibFlagTable;
- cmIDEFlagTable const* DefaultLinkFlagTable;
- cmIDEFlagTable const* DefaultCudaFlagTable;
- cmIDEFlagTable const* DefaultCudaHostFlagTable;
- cmIDEFlagTable const* DefaultMasmFlagTable;
- cmIDEFlagTable const* DefaultNasmFlagTable;
- cmIDEFlagTable const* DefaultRcFlagTable;
+ std::string DefaultCLFlagTableName;
+ std::string DefaultCSharpFlagTableName;
+ std::string DefaultLibFlagTableName;
+ std::string DefaultLinkFlagTableName;
+ std::string DefaultCudaFlagTableName;
+ std::string DefaultCudaHostFlagTableName;
+ std::string DefaultMasmFlagTableName;
+ std::string DefaultNasmFlagTableName;
+ std::string DefaultRCFlagTableName;
+ bool SupportsUnityBuilds = false;
bool SystemIsWindowsCE;
bool SystemIsWindowsPhone;
bool SystemIsWindowsStore;
private:
class Factory;
+ friend class Factory;
+
struct LongestSourcePath
{
LongestSourcePath()
@@ -173,8 +202,8 @@ private:
bool MSBuildCommandInitialized;
cmVisualStudio10ToolsetOptions ToolsetOptions;
virtual std::string FindMSBuildCommand();
- virtual std::string FindDevEnvCommand();
- virtual std::string GetVSMakeProgram() { return this->GetMSBuildCommand(); }
+ std::string FindDevEnvCommand() override;
+ std::string GetVSMakeProgram() override { return this->GetMSBuildCommand(); }
bool PlatformToolsetNeedsDebugEnum;
@@ -186,6 +215,6 @@ private:
bool CudaEnabled;
// We do not use the reload macros for VS >= 10.
- virtual std::string GetUserMacrosDirectory() { return ""; }
+ std::string GetUserMacrosDirectory() override { return ""; }
};
#endif
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index d37d4b095..4b74ef1b2 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -6,12 +6,6 @@
#include "cmDocumentationEntry.h"
#include "cmLocalVisualStudio10Generator.h"
#include "cmMakefile.h"
-#include "cmVS11CLFlagTable.h"
-#include "cmVS11CSharpFlagTable.h"
-#include "cmVS11LibFlagTable.h"
-#include "cmVS11LinkFlagTable.h"
-#include "cmVS11MASMFlagTable.h"
-#include "cmVS11RCFlagTable.h"
static const char vs11generatorName[] = "Visual Studio 11 2012";
@@ -35,7 +29,7 @@ class cmGlobalVisualStudio11Generator::Factory
{
public:
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
- cmake* cm) const CM_OVERRIDE
+ cmake* cm) const override
{
std::string genName;
const char* p = cmVS11GenName(name, genName);
@@ -68,29 +62,55 @@ public:
return ret;
}
- void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
+ void GetDocumentation(cmDocumentationEntry& entry) const override
{
entry.Name = std::string(vs11generatorName) + " [arch]";
entry.Brief = "Generates Visual Studio 2012 project files. "
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
- void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(vs11generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ std::vector<std::string> names;
names.push_back(vs11generatorName + std::string(" ARM"));
names.push_back(vs11generatorName + std::string(" Win64"));
std::set<std::string> installedSDKs =
cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
- for (std::set<std::string>::const_iterator i = installedSDKs.begin();
- i != installedSDKs.end(); ++i) {
- names.push_back(std::string(vs11generatorName) + " " + *i);
+ for (std::string const& i : installedSDKs) {
+ names.push_back(std::string(vs11generatorName) + " " + i);
+ }
+
+ return names;
+ }
+
+ bool SupportsToolset() const override { return true; }
+ bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("ARM");
+
+ std::set<std::string> installedSDKs =
+ cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
+ for (std::string const& i : installedSDKs) {
+ platforms.emplace_back(i);
}
+
+ return platforms;
}
- bool SupportsToolset() const CM_OVERRIDE { return true; }
- bool SupportsPlatform() const CM_OVERRIDE { return true; }
+ std::string GetDefaultPlatformName() const override { return "Win32"; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory()
@@ -99,8 +119,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory()
}
cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(
- cmake* cm, const std::string& name, const std::string& platformName)
- : cmGlobalVisualStudio10Generator(cm, name, platformName)
+ cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName)
+ : cmGlobalVisualStudio10Generator(cm, name, platformInGeneratorName)
{
std::string vc11Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
@@ -108,12 +129,12 @@ cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(
"ProductDir",
vc11Express, cmSystemTools::KeyWOW64_32);
this->DefaultPlatformToolset = "v110";
- this->DefaultClFlagTable = cmVS11CLFlagTable;
- this->DefaultCSharpFlagTable = cmVS11CSharpFlagTable;
- this->DefaultLibFlagTable = cmVS11LibFlagTable;
- this->DefaultLinkFlagTable = cmVS11LinkFlagTable;
- this->DefaultMasmFlagTable = cmVS11MASMFlagTable;
- this->DefaultRcFlagTable = cmVS11RCFlagTable;
+ this->DefaultCLFlagTableName = "v11";
+ this->DefaultCSharpFlagTableName = "v11";
+ this->DefaultLibFlagTableName = "v11";
+ this->DefaultLinkFlagTableName = "v11";
+ this->DefaultMasmFlagTableName = "v11";
+ this->DefaultRCFlagTableName = "v11";
this->Version = VS11;
}
@@ -139,7 +160,7 @@ bool cmGlobalVisualStudio11Generator::InitializeWindowsPhone(cmMakefile* mf)
<< "Desktop SDK as well as the Windows Phone '" << this->SystemVersion
<< "' SDK. Please make sure that you have both installed";
}
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
return true;
@@ -157,7 +178,7 @@ bool cmGlobalVisualStudio11Generator::InitializeWindowsStore(cmMakefile* mf)
<< "Desktop SDK as well as the Windows Store '" << this->SystemVersion
<< "' SDK. Please make sure that you have both installed";
}
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
return true;
@@ -195,17 +216,7 @@ bool cmGlobalVisualStudio11Generator::SelectWindowsStoreToolset(
toolset);
}
-void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout)
-{
- fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
- if (this->ExpressEdition) {
- fout << "# Visual Studio Express 2012 for Windows Desktop\n";
- } else {
- fout << "# Visual Studio 2012\n";
- }
-}
-
-bool cmGlobalVisualStudio11Generator::UseFolderProperty()
+bool cmGlobalVisualStudio11Generator::UseFolderProperty() const
{
// Intentionally skip up to the top-level class implementation.
// Folders are not supported by the Express editions in VS10 and earlier,
@@ -224,33 +235,27 @@ cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs()
cmSystemTools::KeyWOW64_32);
std::set<std::string> ret;
- for (std::vector<std::string>::const_iterator i = subkeys.begin();
- i != subkeys.end(); ++i) {
+ for (std::string const& i : subkeys) {
std::string key = sdksKey;
key += '\\';
- key += *i;
+ key += i;
key += ';';
std::string path;
- if (cmSystemTools::ReadRegistryValue(key.c_str(), path,
+ if (cmSystemTools::ReadRegistryValue(key, path,
cmSystemTools::KeyWOW64_32) &&
!path.empty()) {
- ret.insert(*i);
+ ret.insert(i);
}
}
return ret;
}
-bool cmGlobalVisualStudio11Generator::NeedsDeploy(
- cmStateEnums::TargetType type) const
+bool cmGlobalVisualStudio11Generator::TargetSystemSupportsDeployment() const
{
- if ((type == cmStateEnums::EXECUTABLE ||
- type == cmStateEnums::SHARED_LIBRARY) &&
- (this->SystemIsWindowsPhone || this->SystemIsWindowsStore)) {
- return true;
- }
- return cmGlobalVisualStudio10Generator::NeedsDeploy(type);
+ return this->SystemIsWindowsPhone || this->SystemIsWindowsStore ||
+ cmGlobalVisualStudio10Generator::TargetSystemSupportsDeployment();
}
bool cmGlobalVisualStudio11Generator::IsWindowsDesktopToolsetInstalled() const
diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h
index b4b327d8a..f8cce1898 100644
--- a/Source/cmGlobalVisualStudio11Generator.h
+++ b/Source/cmGlobalVisualStudio11Generator.h
@@ -3,7 +3,7 @@
#ifndef cmGlobalVisualStudio11Generator_h
#define cmGlobalVisualStudio11Generator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <set>
@@ -20,19 +20,18 @@ class cmake;
class cmGlobalVisualStudio11Generator : public cmGlobalVisualStudio10Generator
{
public:
- cmGlobalVisualStudio11Generator(cmake* cm, const std::string& name,
- const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
- virtual bool MatchesGeneratorName(const std::string& name) const;
-
- virtual void WriteSLNHeader(std::ostream& fout);
+ bool MatchesGeneratorName(const std::string& name) const override;
protected:
- virtual bool InitializeWindowsPhone(cmMakefile* mf);
- virtual bool InitializeWindowsStore(cmMakefile* mf);
- virtual bool SelectWindowsPhoneToolset(std::string& toolset) const;
- virtual bool SelectWindowsStoreToolset(std::string& toolset) const;
+ cmGlobalVisualStudio11Generator(cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName);
+
+ bool InitializeWindowsPhone(cmMakefile* mf) override;
+ bool InitializeWindowsStore(cmMakefile* mf) override;
+ bool SelectWindowsPhoneToolset(std::string& toolset) const override;
+ bool SelectWindowsStoreToolset(std::string& toolset) const override;
// Used to verify that the Desktop toolset for the current generator is
// installed on the machine.
@@ -43,12 +42,11 @@ protected:
bool IsWindowsPhoneToolsetInstalled() const;
bool IsWindowsStoreToolsetInstalled() const;
- virtual const char* GetIDEVersion() { return "11.0"; }
- bool UseFolderProperty();
+ bool UseFolderProperty() const override;
static std::set<std::string> GetInstalledWindowsCESDKs();
- /** Return true if the configuration needs to be deployed */
- virtual bool NeedsDeploy(cmStateEnums::TargetType type) const;
+ /** Return true if target system supports debugging deployment. */
+ bool TargetSystemSupportsDeployment() const override;
private:
class Factory;
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index de62ff0ac..d9702c9ee 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -6,12 +6,6 @@
#include "cmDocumentationEntry.h"
#include "cmLocalVisualStudio10Generator.h"
#include "cmMakefile.h"
-#include "cmVS12CLFlagTable.h"
-#include "cmVS12CSharpFlagTable.h"
-#include "cmVS12LibFlagTable.h"
-#include "cmVS12LinkFlagTable.h"
-#include "cmVS12MASMFlagTable.h"
-#include "cmVS12RCFlagTable.h"
static const char vs12generatorName[] = "Visual Studio 12 2013";
@@ -35,7 +29,7 @@ class cmGlobalVisualStudio12Generator::Factory
{
public:
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
- cmake* cm) const CM_OVERRIDE
+ cmake* cm) const override
{
std::string genName;
const char* p = cmVS12GenName(name, genName);
@@ -57,22 +51,41 @@ public:
return 0;
}
- void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
+ void GetDocumentation(cmDocumentationEntry& entry) const override
{
entry.Name = std::string(vs12generatorName) + " [arch]";
entry.Brief = "Generates Visual Studio 2013 project files. "
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
- void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(vs12generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ std::vector<std::string> names;
names.push_back(vs12generatorName + std::string(" ARM"));
names.push_back(vs12generatorName + std::string(" Win64"));
+ return names;
}
- bool SupportsToolset() const CM_OVERRIDE { return true; }
- bool SupportsPlatform() const CM_OVERRIDE { return true; }
+ bool SupportsToolset() const override { return true; }
+ bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("ARM");
+ return platforms;
+ }
+
+ std::string GetDefaultPlatformName() const override { return "Win32"; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory()
@@ -81,8 +94,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory()
}
cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator(
- cmake* cm, const std::string& name, const std::string& platformName)
- : cmGlobalVisualStudio11Generator(cm, name, platformName)
+ cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName)
+ : cmGlobalVisualStudio11Generator(cm, name, platformInGeneratorName)
{
std::string vc12Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
@@ -90,12 +104,12 @@ cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator(
"ProductDir",
vc12Express, cmSystemTools::KeyWOW64_32);
this->DefaultPlatformToolset = "v120";
- this->DefaultClFlagTable = cmVS12CLFlagTable;
- this->DefaultCSharpFlagTable = cmVS12CSharpFlagTable;
- this->DefaultLibFlagTable = cmVS12LibFlagTable;
- this->DefaultLinkFlagTable = cmVS12LinkFlagTable;
- this->DefaultMasmFlagTable = cmVS12MASMFlagTable;
- this->DefaultRcFlagTable = cmVS12RCFlagTable;
+ this->DefaultCLFlagTableName = "v12";
+ this->DefaultCSharpFlagTableName = "v12";
+ this->DefaultLibFlagTableName = "v12";
+ this->DefaultLinkFlagTableName = "v12";
+ this->DefaultMasmFlagTableName = "v12";
+ this->DefaultRCFlagTableName = "v12";
this->Version = VS12;
}
@@ -112,8 +126,8 @@ bool cmGlobalVisualStudio12Generator::MatchesGeneratorName(
bool cmGlobalVisualStudio12Generator::ProcessGeneratorToolsetField(
std::string const& key, std::string const& value)
{
- if (key == "host" && value == "x64") {
- this->GeneratorToolsetHostArchitecture = "x64";
+ if (key == "host" && (value == "x64" || value == "x86")) {
+ this->GeneratorToolsetHostArchitecture = value;
return true;
}
return this->cmGlobalVisualStudio11Generator::ProcessGeneratorToolsetField(
@@ -125,15 +139,16 @@ bool cmGlobalVisualStudio12Generator::InitializeWindowsPhone(cmMakefile* mf)
if (!this->SelectWindowsPhoneToolset(this->DefaultPlatformToolset)) {
std::ostringstream e;
if (this->DefaultPlatformToolset.empty()) {
- e << this->GetName() << " supports Windows Phone '8.0' and '8.1', but "
- "not '"
+ e << this->GetName()
+ << " supports Windows Phone '8.0' and '8.1', but "
+ "not '"
<< this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
} else {
e << "A Windows Phone component with CMake requires both the Windows "
<< "Desktop SDK as well as the Windows Phone '" << this->SystemVersion
<< "' SDK. Please make sure that you have both installed";
}
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
return true;
@@ -144,15 +159,16 @@ bool cmGlobalVisualStudio12Generator::InitializeWindowsStore(cmMakefile* mf)
if (!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset)) {
std::ostringstream e;
if (this->DefaultPlatformToolset.empty()) {
- e << this->GetName() << " supports Windows Store '8.0' and '8.1', but "
- "not '"
+ e << this->GetName()
+ << " supports Windows Store '8.0' and '8.1', but "
+ "not '"
<< this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
} else {
e << "A Windows Store component with CMake requires both the Windows "
<< "Desktop SDK as well as the Windows Store '" << this->SystemVersion
<< "' SDK. Please make sure that you have both installed";
}
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
return true;
@@ -190,16 +206,6 @@ bool cmGlobalVisualStudio12Generator::SelectWindowsStoreToolset(
toolset);
}
-void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout)
-{
- fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
- if (this->ExpressEdition) {
- fout << "# Visual Studio Express 2013 for Windows Desktop\n";
- } else {
- fout << "# Visual Studio 2013\n";
- }
-}
-
bool cmGlobalVisualStudio12Generator::IsWindowsDesktopToolsetInstalled() const
{
const char desktop81Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h
index ebc95bb63..53b709157 100644
--- a/Source/cmGlobalVisualStudio12Generator.h
+++ b/Source/cmGlobalVisualStudio12Generator.h
@@ -3,7 +3,7 @@
#ifndef cmGlobalVisualStudio12Generator_h
#define cmGlobalVisualStudio12Generator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
@@ -18,37 +18,33 @@ class cmake;
class cmGlobalVisualStudio12Generator : public cmGlobalVisualStudio11Generator
{
public:
- cmGlobalVisualStudio12Generator(cmake* cm, const std::string& name,
- const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
- virtual bool MatchesGeneratorName(const std::string& name) const;
-
- virtual void WriteSLNHeader(std::ostream& fout);
+ bool MatchesGeneratorName(const std::string& name) const override;
- // in Visual Studio 2013 they detached the MSBuild tools version
- // from the .Net Framework version and instead made it have it's own
- // version number
- virtual const char* GetToolsVersion() { return "12.0"; }
protected:
+ cmGlobalVisualStudio12Generator(cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName);
+
bool ProcessGeneratorToolsetField(std::string const& key,
- std::string const& value) CM_OVERRIDE;
+ std::string const& value) override;
- virtual bool InitializeWindowsPhone(cmMakefile* mf);
- virtual bool InitializeWindowsStore(cmMakefile* mf);
- virtual bool SelectWindowsPhoneToolset(std::string& toolset) const;
- virtual bool SelectWindowsStoreToolset(std::string& toolset) const;
+ bool InitializeWindowsPhone(cmMakefile* mf) override;
+ bool InitializeWindowsStore(cmMakefile* mf) override;
+ bool SelectWindowsPhoneToolset(std::string& toolset) const override;
+ bool SelectWindowsStoreToolset(std::string& toolset) const override;
// Used to verify that the Desktop toolset for the current generator is
// installed on the machine.
- virtual bool IsWindowsDesktopToolsetInstalled() const;
+ bool IsWindowsDesktopToolsetInstalled() const override;
// These aren't virtual because we need to check if the selected version
// of the toolset is installed
bool IsWindowsPhoneToolsetInstalled() const;
bool IsWindowsStoreToolsetInstalled() const;
- virtual const char* GetIDEVersion() { return "12.0"; }
+
private:
class Factory;
+ friend class Factory;
};
#endif
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index c8cf02cdd..cd4847427 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -6,12 +6,6 @@
#include "cmDocumentationEntry.h"
#include "cmLocalVisualStudio10Generator.h"
#include "cmMakefile.h"
-#include "cmVS140CLFlagTable.h"
-#include "cmVS140CSharpFlagTable.h"
-#include "cmVS140LinkFlagTable.h"
-#include "cmVS14LibFlagTable.h"
-#include "cmVS14MASMFlagTable.h"
-#include "cmVS14RCFlagTable.h"
static const char vs14generatorName[] = "Visual Studio 14 2015";
@@ -35,7 +29,7 @@ class cmGlobalVisualStudio14Generator::Factory
{
public:
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
- cmake* cm) const CM_OVERRIDE
+ cmake* cm) const override
{
std::string genName;
const char* p = cmVS14GenName(name, genName);
@@ -57,22 +51,41 @@ public:
return 0;
}
- void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
+ void GetDocumentation(cmDocumentationEntry& entry) const override
{
entry.Name = std::string(vs14generatorName) + " [arch]";
entry.Brief = "Generates Visual Studio 2015 project files. "
"Optional [arch] can be \"Win64\" or \"ARM\".";
}
- void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(vs14generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ std::vector<std::string> names;
names.push_back(vs14generatorName + std::string(" ARM"));
names.push_back(vs14generatorName + std::string(" Win64"));
+ return names;
}
- bool SupportsToolset() const CM_OVERRIDE { return true; }
- bool SupportsPlatform() const CM_OVERRIDE { return true; }
+ bool SupportsToolset() const override { return true; }
+ bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("ARM");
+ return platforms;
+ }
+
+ std::string GetDefaultPlatformName() const override { return "Win32"; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory()
@@ -81,8 +94,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory()
}
cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator(
- cmake* cm, const std::string& name, const std::string& platformName)
- : cmGlobalVisualStudio12Generator(cm, name, platformName)
+ cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName)
+ : cmGlobalVisualStudio12Generator(cm, name, platformInGeneratorName)
{
std::string vc14Express;
this->ExpressEdition = cmSystemTools::ReadRegistryValue(
@@ -90,12 +104,12 @@ cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator(
"ProductDir",
vc14Express, cmSystemTools::KeyWOW64_32);
this->DefaultPlatformToolset = "v140";
- this->DefaultClFlagTable = cmVS140CLFlagTable;
- this->DefaultCSharpFlagTable = cmVS140CSharpFlagTable;
- this->DefaultLibFlagTable = cmVS14LibFlagTable;
- this->DefaultLinkFlagTable = cmVS140LinkFlagTable;
- this->DefaultMasmFlagTable = cmVS14MASMFlagTable;
- this->DefaultRcFlagTable = cmVS14RCFlagTable;
+ this->DefaultCLFlagTableName = "v140";
+ this->DefaultCSharpFlagTableName = "v140";
+ this->DefaultLibFlagTableName = "v14";
+ this->DefaultLinkFlagTableName = "v140";
+ this->DefaultMasmFlagTableName = "v14";
+ this->DefaultRCFlagTableName = "v14";
this->Version = VS14;
}
@@ -122,15 +136,16 @@ bool cmGlobalVisualStudio14Generator::InitializeWindowsStore(cmMakefile* mf)
std::ostringstream e;
if (!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset)) {
if (this->DefaultPlatformToolset.empty()) {
- e << this->GetName() << " supports Windows Store '8.0', '8.1' and "
- "'10.0', but not '"
+ e << this->GetName()
+ << " supports Windows Store '8.0', '8.1' and "
+ "'10.0', but not '"
<< this->SystemVersion << "'. Check CMAKE_SYSTEM_VERSION.";
} else {
e << "A Windows Store component with CMake requires both the Windows "
<< "Desktop SDK as well as the Windows Store '" << this->SystemVersion
<< "' SDK. Please make sure that you have both installed";
}
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) {
@@ -143,19 +158,33 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf,
bool required)
{
// Find the default version of the Windows 10 SDK.
- this->WindowsTargetPlatformVersion = this->GetWindows10SDKVersion();
- if (required && this->WindowsTargetPlatformVersion.empty()) {
+ std::string const version = this->GetWindows10SDKVersion();
+ if (required && version.empty()) {
std::ostringstream e;
e << "Could not find an appropriate version of the Windows 10 SDK"
<< " installed on this machine";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
- mf->AddDefinition("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION",
- this->WindowsTargetPlatformVersion.c_str());
+ this->SetWindowsTargetPlatformVersion(version, mf);
return true;
}
+void cmGlobalVisualStudio14Generator::SetWindowsTargetPlatformVersion(
+ std::string const& version, cmMakefile* mf)
+{
+ this->WindowsTargetPlatformVersion = version;
+ if (!cmSystemTools::VersionCompareEqual(this->WindowsTargetPlatformVersion,
+ this->SystemVersion)) {
+ std::ostringstream e;
+ e << "Selecting Windows SDK version " << this->WindowsTargetPlatformVersion
+ << " to target Windows " << this->SystemVersion << ".";
+ mf->DisplayStatus(e.str(), -1);
+ }
+ mf->AddDefinition("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION",
+ this->WindowsTargetPlatformVersion);
+}
+
bool cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset(
std::string& toolset) const
{
@@ -172,17 +201,6 @@ bool cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset(
toolset);
}
-void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout)
-{
- // Visual Studio 14 writes .sln format 12.00
- fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
- if (this->ExpressEdition) {
- fout << "# Visual Studio Express 14 for Windows Desktop\n";
- } else {
- fout << "# Visual Studio 14\n";
- }
-}
-
bool cmGlobalVisualStudio14Generator::IsWindowsDesktopToolsetInstalled() const
{
const char desktop10Key[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
@@ -204,6 +222,16 @@ bool cmGlobalVisualStudio14Generator::IsWindowsStoreToolsetInstalled() const
cmSystemTools::KeyWOW64_32);
}
+std::string cmGlobalVisualStudio14Generator::GetWindows10SDKMaxVersion() const
+{
+ // The last Windows 10 SDK version that VS 2015 can target is 10.0.14393.0.
+ //
+ // "VS 2015 Users: The Windows 10 SDK (15063, 16299, 17134, 17763) is
+ // officially only supported for VS 2017." From:
+ // https://blogs.msdn.microsoft.com/chuckw/2018/10/02/windows-10-october-2018-update/
+ return "10.0.14393.0";
+}
+
#if defined(_WIN32) && !defined(__CYGWIN__)
struct NoWindowsH
{
@@ -212,6 +240,20 @@ struct NoWindowsH
return !cmSystemTools::FileExists(p + "/um/windows.h", true);
}
};
+class WindowsSDKTooRecent
+{
+ std::string const& MaxVersion;
+
+public:
+ WindowsSDKTooRecent(std::string const& maxVersion)
+ : MaxVersion(maxVersion)
+ {
+ }
+ bool operator()(std::string const& v)
+ {
+ return cmSystemTools::VersionCompareGreater(v, MaxVersion);
+ }
+};
#endif
std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
@@ -250,9 +292,8 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
std::vector<std::string> sdks;
// Grab the paths of the different SDKs that are installed
- for (std::vector<std::string>::iterator i = win10Roots.begin();
- i != win10Roots.end(); ++i) {
- std::string path = *i + "/Include/*";
+ for (std::string const& i : win10Roots) {
+ std::string path = i + "/Include/*";
cmSystemTools::GlobDirs(path, sdks);
}
@@ -260,24 +301,28 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
// only the UCRT MSIs were installed for them.
cmEraseIf(sdks, NoWindowsH());
- if (!sdks.empty()) {
- // Only use the filename, which will be the SDK version.
- for (std::vector<std::string>::iterator i = sdks.begin(); i != sdks.end();
- ++i) {
- *i = cmSystemTools::GetFilenameName(*i);
- }
+ // Only use the filename, which will be the SDK version.
+ for (std::string& i : sdks) {
+ i = cmSystemTools::GetFilenameName(i);
+ }
- // Sort the results to make sure we select the most recent one.
- std::sort(sdks.begin(), sdks.end(), cmSystemTools::VersionCompareGreater);
+ // Skip SDKs that cannot be used with our toolset.
+ std::string maxVersion = this->GetWindows10SDKMaxVersion();
+ if (!maxVersion.empty()) {
+ cmEraseIf(sdks, WindowsSDKTooRecent(maxVersion));
+ }
+
+ // Sort the results to make sure we select the most recent one.
+ std::sort(sdks.begin(), sdks.end(), cmSystemTools::VersionCompareGreater);
- // Look for a SDK exactly matching the requested target version.
- for (std::vector<std::string>::iterator i = sdks.begin(); i != sdks.end();
- ++i) {
- if (cmSystemTools::VersionCompareEqual(*i, this->SystemVersion)) {
- return *i;
- }
+ // Look for a SDK exactly matching the requested target version.
+ for (std::string const& i : sdks) {
+ if (cmSystemTools::VersionCompareEqual(i, this->SystemVersion)) {
+ return i;
}
+ }
+ if (!sdks.empty()) {
// Use the latest Windows 10 SDK since the exact version is not available.
return sdks.at(0);
}
diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h
index 0ce9a5641..6e12d3e2c 100644
--- a/Source/cmGlobalVisualStudio14Generator.h
+++ b/Source/cmGlobalVisualStudio14Generator.h
@@ -3,7 +3,7 @@
#ifndef cmGlobalVisualStudio14Generator_h
#define cmGlobalVisualStudio14Generator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
@@ -18,34 +18,39 @@ class cmake;
class cmGlobalVisualStudio14Generator : public cmGlobalVisualStudio12Generator
{
public:
- cmGlobalVisualStudio14Generator(cmake* cm, const std::string& name,
- const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
- virtual bool MatchesGeneratorName(const std::string& name) const;
-
- virtual void WriteSLNHeader(std::ostream& fout);
+ bool MatchesGeneratorName(const std::string& name) const override;
- virtual const char* GetToolsVersion() { return "14.0"; }
protected:
- virtual bool InitializeWindows(cmMakefile* mf);
- virtual bool InitializeWindowsStore(cmMakefile* mf);
- virtual bool SelectWindowsStoreToolset(std::string& toolset) const;
+ cmGlobalVisualStudio14Generator(cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName);
+
+ bool InitializeWindows(cmMakefile* mf) override;
+ bool InitializeWindowsStore(cmMakefile* mf) override;
+ bool SelectWindowsStoreToolset(std::string& toolset) const override;
// These aren't virtual because we need to check if the selected version
// of the toolset is installed
bool IsWindowsStoreToolsetInstalled() const;
- virtual const char* GetIDEVersion() { return "14.0"; }
+ // Used to make sure that the Windows 10 SDK selected can work with the
+ // version of the toolset.
+ virtual std::string GetWindows10SDKMaxVersion() const;
+
virtual bool SelectWindows10SDK(cmMakefile* mf, bool required);
+ void SetWindowsTargetPlatformVersion(std::string const& version,
+ cmMakefile* mf);
+
// Used to verify that the Desktop toolset for the current generator is
// installed on the machine.
- virtual bool IsWindowsDesktopToolsetInstalled() const;
+ bool IsWindowsDesktopToolsetInstalled() const override;
std::string GetWindows10SDKVersion();
private:
class Factory;
+ friend class Factory;
};
#endif
diff --git a/Source/cmGlobalVisualStudio15Generator.cxx b/Source/cmGlobalVisualStudio15Generator.cxx
deleted file mode 100644
index ce1ba007f..000000000
--- a/Source/cmGlobalVisualStudio15Generator.cxx
+++ /dev/null
@@ -1,206 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmGlobalVisualStudio15Generator.h"
-
-#include "cmAlgorithms.h"
-#include "cmDocumentationEntry.h"
-#include "cmLocalVisualStudio10Generator.h"
-#include "cmMakefile.h"
-#include "cmVS141CLFlagTable.h"
-#include "cmVS141CSharpFlagTable.h"
-#include "cmVS141LinkFlagTable.h"
-#include "cmVSSetupHelper.h"
-
-static const char vs15generatorName[] = "Visual Studio 15 2017";
-
-// Map generator name without year to name with year.
-static const char* cmVS15GenName(const std::string& name, std::string& genName)
-{
- if (strncmp(name.c_str(), vs15generatorName,
- sizeof(vs15generatorName) - 6) != 0) {
- return 0;
- }
- const char* p = name.c_str() + sizeof(vs15generatorName) - 6;
- if (cmHasLiteralPrefix(p, " 2017")) {
- p += 5;
- }
- genName = std::string(vs15generatorName) + p;
- return p;
-}
-
-class cmGlobalVisualStudio15Generator::Factory
- : public cmGlobalGeneratorFactory
-{
-public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
- cmake* cm) const
- {
- std::string genName;
- const char* p = cmVS15GenName(name, genName);
- if (!p) {
- return 0;
- }
- if (!*p) {
- return new cmGlobalVisualStudio15Generator(cm, genName, "");
- }
- if (*p++ != ' ') {
- return 0;
- }
- if (strcmp(p, "Win64") == 0) {
- return new cmGlobalVisualStudio15Generator(cm, genName, "x64");
- }
- if (strcmp(p, "ARM") == 0) {
- return new cmGlobalVisualStudio15Generator(cm, genName, "ARM");
- }
- return 0;
- }
-
- virtual void GetDocumentation(cmDocumentationEntry& entry) const
- {
- entry.Name = std::string(vs15generatorName) + " [arch]";
- entry.Brief = "Generates Visual Studio 2017 project files. "
- "Optional [arch] can be \"Win64\" or \"ARM\".";
- }
-
- virtual void GetGenerators(std::vector<std::string>& names) const
- {
- names.push_back(vs15generatorName);
- names.push_back(vs15generatorName + std::string(" ARM"));
- names.push_back(vs15generatorName + std::string(" Win64"));
- }
-
- bool SupportsToolset() const CM_OVERRIDE { return true; }
- bool SupportsPlatform() const CM_OVERRIDE { return true; }
-};
-
-cmGlobalGeneratorFactory* cmGlobalVisualStudio15Generator::NewFactory()
-{
- return new Factory;
-}
-
-cmGlobalVisualStudio15Generator::cmGlobalVisualStudio15Generator(
- cmake* cm, const std::string& name, const std::string& platformName)
- : cmGlobalVisualStudio14Generator(cm, name, platformName)
-{
- this->ExpressEdition = false;
- this->DefaultPlatformToolset = "v141";
- this->DefaultClFlagTable = cmVS141CLFlagTable;
- this->DefaultCSharpFlagTable = cmVS141CSharpFlagTable;
- this->DefaultLinkFlagTable = cmVS141LinkFlagTable;
- this->Version = VS15;
-}
-
-bool cmGlobalVisualStudio15Generator::MatchesGeneratorName(
- const std::string& name) const
-{
- std::string genName;
- if (cmVS15GenName(name, genName)) {
- return genName == this->GetName();
- }
- return false;
-}
-
-void cmGlobalVisualStudio15Generator::WriteSLNHeader(std::ostream& fout)
-{
- // Visual Studio 15 writes .sln format 12.00
- fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
- if (this->ExpressEdition) {
- fout << "# Visual Studio Express 15 for Windows Desktop\n";
- } else {
- fout << "# Visual Studio 15\n";
- }
-}
-
-bool cmGlobalVisualStudio15Generator::InitializeWindows(cmMakefile* mf)
-{
- // If the Win 8.1 SDK is installed then we can select a SDK matching
- // the target Windows version.
- if (this->IsWin81SDKInstalled()) {
- return cmGlobalVisualStudio14Generator::InitializeWindows(mf);
- }
- // Otherwise we must choose a Win 10 SDK even if we are not targeting
- // Windows 10.
- return this->SelectWindows10SDK(mf, false);
-}
-
-bool cmGlobalVisualStudio15Generator::SelectWindowsStoreToolset(
- std::string& toolset) const
-{
- if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) {
- if (this->IsWindowsStoreToolsetInstalled() &&
- this->IsWindowsDesktopToolsetInstalled()) {
- toolset = "v141"; // VS 15 uses v141 toolset
- return true;
- } else {
- return false;
- }
- }
- return this->cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset(
- toolset);
-}
-
-bool cmGlobalVisualStudio15Generator::IsWindowsDesktopToolsetInstalled() const
-{
- return vsSetupAPIHelper.IsVS2017Installed();
-}
-
-bool cmGlobalVisualStudio15Generator::IsWindowsStoreToolsetInstalled() const
-{
- return vsSetupAPIHelper.IsWin10SDKInstalled();
-}
-
-bool cmGlobalVisualStudio15Generator::IsWin81SDKInstalled() const
-{
- // Does the VS installer tool know about one?
- if (vsSetupAPIHelper.IsWin81SDKInstalled()) {
- return true;
- }
-
- // Does the registry know about one (e.g. from VS 2015)?
- std::string win81Root;
- if (cmSystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
- "Windows Kits\\Installed Roots;KitsRoot81",
- win81Root, cmSystemTools::KeyWOW64_32) ||
- cmSystemTools::ReadRegistryValue(
- "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\"
- "Windows Kits\\Installed Roots;KitsRoot81",
- win81Root, cmSystemTools::KeyWOW64_32)) {
- return cmSystemTools::FileExists(win81Root + "/um/windows.h", true);
- }
- return false;
-}
-
-std::string cmGlobalVisualStudio15Generator::FindMSBuildCommand()
-{
- std::string msbuild;
-
- // Ask Visual Studio Installer tool.
- std::string vs;
- if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) {
- msbuild = vs + "/MSBuild/15.0/Bin/MSBuild.exe";
- if (cmSystemTools::FileExists(msbuild)) {
- return msbuild;
- }
- }
-
- msbuild = "MSBuild.exe";
- return msbuild;
-}
-
-std::string cmGlobalVisualStudio15Generator::FindDevEnvCommand()
-{
- std::string devenv;
-
- // Ask Visual Studio Installer tool.
- std::string vs;
- if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) {
- devenv = vs + "/Common7/IDE/devenv.com";
- if (cmSystemTools::FileExists(devenv)) {
- return devenv;
- }
- }
-
- devenv = "devenv.com";
- return devenv;
-}
diff --git a/Source/cmGlobalVisualStudio15Generator.h b/Source/cmGlobalVisualStudio15Generator.h
deleted file mode 100644
index 4be88f44f..000000000
--- a/Source/cmGlobalVisualStudio15Generator.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmGlobalVisualStudio15Generator_h
-#define cmGlobalVisualStudio15Generator_h
-
-#include "cmConfigure.h"
-
-#include <iosfwd>
-#include <string>
-
-#include "cmGlobalVisualStudio14Generator.h"
-#include "cmVSSetupHelper.h"
-
-class cmGlobalGeneratorFactory;
-class cmake;
-
-/** \class cmGlobalVisualStudio15Generator */
-class cmGlobalVisualStudio15Generator : public cmGlobalVisualStudio14Generator
-{
-public:
- cmGlobalVisualStudio15Generator(cmake* cm, const std::string& name,
- const std::string& platformName);
- static cmGlobalGeneratorFactory* NewFactory();
-
- virtual bool MatchesGeneratorName(const std::string& name) const;
-
- virtual void WriteSLNHeader(std::ostream& fout);
-
- virtual const char* GetToolsVersion() { return "15.0"; }
-protected:
- bool InitializeWindows(cmMakefile* mf) CM_OVERRIDE;
- virtual bool SelectWindowsStoreToolset(std::string& toolset) const;
-
- virtual const char* GetIDEVersion() { return "15.0"; }
-
- // Used to verify that the Desktop toolset for the current generator is
- // installed on the machine.
- virtual bool IsWindowsDesktopToolsetInstalled() const;
-
- // These aren't virtual because we need to check if the selected version
- // of the toolset is installed
- bool IsWindowsStoreToolsetInstalled() const;
-
- // Check for a Win 8 SDK known to the registry or VS installer tool.
- bool IsWin81SDKInstalled() const;
-
- std::string FindMSBuildCommand() CM_OVERRIDE;
- std::string FindDevEnvCommand() CM_OVERRIDE;
-
-private:
- class Factory;
- mutable cmVSSetupAPIHelper vsSetupAPIHelper;
-};
-#endif
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 3b45c902c..e8e9eced9 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -6,7 +6,7 @@
#include "cmGeneratorTarget.h"
#include "cmLocalVisualStudio7Generator.h"
#include "cmMakefile.h"
-#include "cmake.h"
+#include "cmMessageType.h"
cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator(
cmake* cm, const std::string& platformName)
@@ -76,9 +76,8 @@ void cmGlobalVisualStudio71Generator::WriteSolutionConfigurations(
std::ostream& fout, std::vector<std::string> const& configs)
{
fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
- fout << "\t\t" << *i << " = " << *i << "\n";
+ for (std::string const& i : configs) {
+ fout << "\t\t" << i << " = " << i << "\n";
}
fout << "\tEndGlobalSection\n";
}
@@ -99,7 +98,7 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
ext = ".vfproj";
project = "Project(\"{6989167D-11E4-40FE-8C1A-2192A86A7E90}\") = \"";
}
- if (this->TargetIsCSharpOnly(t)) {
+ if (t->IsCSharpOnly()) {
ext = ".csproj";
project = "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"";
}
@@ -143,16 +142,12 @@ void cmGlobalVisualStudio71Generator::WriteProjectDepends(
cmGeneratorTarget const* target)
{
VSDependSet const& depends = this->VSTargetDepends[target];
- for (VSDependSet::const_iterator di = depends.begin(); di != depends.end();
- ++di) {
- const char* name = di->c_str();
+ for (std::string const& name : depends) {
std::string guid = this->GetGUID(name);
if (guid.empty()) {
- std::string m = "Target: ";
- m += target->GetName();
- m += " depends on unknown target: ";
- m += name;
- cmSystemTools::Error(m.c_str());
+ std::string m = cmStrCat("Target: ", target->GetName(),
+ " depends on unknown target: ", name);
+ cmSystemTools::Error(m);
}
fout << "\t\t{" << guid << "} = {" << guid << "}\n";
}
@@ -162,7 +157,7 @@ void cmGlobalVisualStudio71Generator::WriteProjectDepends(
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio71Generator::WriteExternalProject(
std::ostream& fout, const std::string& name, const char* location,
- const char* typeGuid, const std::set<std::string>& depends)
+ const char* typeGuid, const std::set<BT<std::string>>& depends)
{
fout << "Project(\"{"
<< (typeGuid ? typeGuid : this->ExternalProjectType(location))
@@ -174,11 +169,11 @@ void cmGlobalVisualStudio71Generator::WriteExternalProject(
// project instead of in the global section
if (!depends.empty()) {
fout << "\tProjectSection(ProjectDependencies) = postProject\n";
- std::set<std::string>::const_iterator it;
- for (it = depends.begin(); it != depends.end(); ++it) {
- if (!it->empty()) {
- fout << "\t\t{" << this->GetGUID(it->c_str()) << "} = {"
- << this->GetGUID(it->c_str()) << "}\n";
+ for (BT<std::string> const& it : depends) {
+ std::string const& dep = it.Value;
+ if (!dep.empty()) {
+ fout << "\t\t{" << this->GetGUID(dep) << "} = {" << this->GetGUID(dep)
+ << "}\n";
}
}
fout << "\tEndProjectSection\n";
@@ -198,32 +193,25 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations(
const std::string& platformName =
!platformMapping.empty() ? platformMapping : this->GetPlatformName();
std::string guid = this->GetGUID(name);
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
+ for (std::string const& i : configs) {
std::vector<std::string> mapConfig;
- const char* dstConfig = i->c_str();
+ const char* dstConfig = i.c_str();
if (target.GetProperty("EXTERNAL_MSPROJECT")) {
if (const char* m = target.GetProperty("MAP_IMPORTED_CONFIG_" +
- cmSystemTools::UpperCase(*i))) {
- cmSystemTools::ExpandListArgument(m, mapConfig);
+ cmSystemTools::UpperCase(i))) {
+ cmExpandList(m, mapConfig);
if (!mapConfig.empty()) {
dstConfig = mapConfig[0].c_str();
}
}
}
- fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << dstConfig
- << "|" << platformName << std::endl;
+ fout << "\t\t{" << guid << "}." << i << ".ActiveCfg = " << dstConfig << "|"
+ << platformName << std::endl;
std::set<std::string>::const_iterator ci =
- configsPartOfDefaultBuild.find(*i);
+ configsPartOfDefaultBuild.find(i);
if (!(ci == configsPartOfDefaultBuild.end())) {
- fout << "\t\t{" << guid << "}." << *i << ".Build.0 = " << dstConfig
- << "|" << platformName << std::endl;
+ fout << "\t\t{" << guid << "}." << i << ".Build.0 = " << dstConfig << "|"
+ << platformName << std::endl;
}
}
}
-
-// ouput standard header for dsw file
-void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout)
-{
- fout << "Microsoft Visual Studio Solution File, Format Version 8.00\n";
-}
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index 0ce02aa46..85755af60 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -17,28 +17,26 @@ public:
const std::string& platformName = "");
protected:
- virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
- std::vector<cmLocalGenerator*>& generators);
+ void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
+ std::vector<cmLocalGenerator*>& generators) override;
virtual void WriteSolutionConfigurations(
std::ostream& fout, std::vector<std::string> const& configs);
- virtual void WriteProject(std::ostream& fout, const std::string& name,
- const char* path, const cmGeneratorTarget* t);
- virtual void WriteProjectDepends(std::ostream& fout, const std::string& name,
- const char* path,
- cmGeneratorTarget const* t);
- virtual void WriteProjectConfigurations(
+ void WriteProject(std::ostream& fout, const std::string& name,
+ const char* path, const cmGeneratorTarget* t) override;
+ void WriteProjectDepends(std::ostream& fout, const std::string& name,
+ const char* path,
+ cmGeneratorTarget const* t) override;
+ void WriteProjectConfigurations(
std::ostream& fout, const std::string& name,
cmGeneratorTarget const& target, std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild,
- const std::string& platformMapping = "");
- virtual void WriteExternalProject(std::ostream& fout,
- const std::string& name, const char* path,
- const char* typeGuid,
- const std::set<std::string>& depends);
- virtual void WriteSLNHeader(std::ostream& fout);
+ const std::string& platformMapping = "") override;
+ void WriteExternalProject(std::ostream& fout, const std::string& name,
+ const char* path, const char* typeGuid,
+ const std::set<BT<std::string>>& depends) override;
// Folders are not supported by VS 7.1.
- virtual bool UseFolderProperty() { return false; }
+ bool UseFolderProperty() const override { return false; }
std::string ProjectConfigurationSectionName;
};
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index b155f5b55..40b214c03 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -2,18 +2,26 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalVisualStudio7Generator.h"
+#include <vector>
+
+#include <cm/string_view>
+
+#include <windows.h>
+
+#include <assert.h>
+
+#include "cmsys/Encoding.hxx"
+
#include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmLocalVisualStudio7Generator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmUuid.h"
#include "cmake.h"
-#include "cmsys/Encoding.hxx"
-
-#include <assert.h>
-#include <vector>
-#include <windows.h>
static cmVS7FlagTable cmVS7ExtraFlagTable[] = {
// Precompiled header and related options. Note that the
@@ -37,43 +45,44 @@ static cmVS7FlagTable cmVS7ExtraFlagTable[] = {
// and have EHa passed on the command line by leaving out the table
// entry.
- { 0, 0, 0, 0, 0 }
+ { "", "", "", "", 0 }
};
+namespace {
+std::string GetSLNFile(cmLocalGenerator* root)
+{
+ return cmStrCat(root->GetCurrentBinaryDirectory(), '/',
+ root->GetProjectName(), ".sln");
+}
+}
+
cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
- cmake* cm, const std::string& platformName)
- : cmGlobalVisualStudioGenerator(cm)
+ cmake* cm, std::string const& platformInGeneratorName)
+ : cmGlobalVisualStudioGenerator(cm, platformInGeneratorName)
{
- this->IntelProjectVersion = 0;
this->DevEnvCommandInitialized = false;
this->MasmEnabled = false;
this->NasmEnabled = false;
-
- if (platformName.empty()) {
- this->DefaultPlatformName = "Win32";
- } else {
- this->DefaultPlatformName = platformName;
- }
this->ExtraFlagTable = cmVS7ExtraFlagTable;
}
cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator()
{
- free(this->IntelProjectVersion);
}
// Package GUID of Intel Visual Fortran plugin to VS IDE
#define CM_INTEL_PLUGIN_GUID "{B68A201D-CB9B-47AF-A52F-7EEC72E217E4}"
-const char* cmGlobalVisualStudio7Generator::GetIntelProjectVersion()
+const std::string& cmGlobalVisualStudio7Generator::GetIntelProjectVersion()
{
- if (!this->IntelProjectVersion) {
+ if (this->IntelProjectVersion.empty()) {
// Compute the version of the Intel plugin to the VS IDE.
// If the key does not exist then use a default guess.
std::string intelVersion;
- std::string vskey = this->GetRegistryBase();
- vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion";
- cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion,
+ std::string vskey =
+ cmStrCat(this->GetRegistryBase(),
+ "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion");
+ cmSystemTools::ReadRegistryValue(vskey, intelVersion,
cmSystemTools::KeyWOW64_32);
unsigned int intelVersionNumber = ~0u;
sscanf(intelVersion.c_str(), "%u", &intelVersionNumber);
@@ -86,7 +95,7 @@ const char* cmGlobalVisualStudio7Generator::GetIntelProjectVersion()
} else {
// Version <= 9: use ProductVersion from registry.
}
- this->IntelProjectVersion = strdup(intelVersion.c_str());
+ this->IntelProjectVersion = intelVersion;
}
return this->IntelProjectVersion;
}
@@ -106,7 +115,7 @@ void cmGlobalVisualStudio7Generator::EnableLanguage(
}
// Create list of configurations requested by user's cache, if any.
- this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
+ this->cmGlobalVisualStudioGenerator::EnableLanguage(lang, mf, optional);
// if this environment variable is set, then copy it to
// a static cache entry. It will be used by
@@ -128,8 +137,7 @@ bool cmGlobalVisualStudio7Generator::FindMakeProgram(cmMakefile* mf)
if (!this->cmGlobalVisualStudioGenerator::FindMakeProgram(mf)) {
return false;
}
- mf->AddDefinition("CMAKE_VS_DEVENV_COMMAND",
- this->GetDevEnvCommand().c_str());
+ mf->AddDefinition("CMAKE_VS_DEVENV_COMMAND", this->GetDevEnvCommand());
return true;
}
@@ -159,8 +167,9 @@ std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand()
}
// Search where VS15Preview places it.
- vskey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;";
- vskey += this->GetIDEVersion();
+ vskey = cmStrCat(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;",
+ this->GetIDEVersion());
if (cmSystemTools::ReadRegistryValue(vskey.c_str(), vscmd,
cmSystemTools::KeyWOW64_32)) {
cmSystemTools::ConvertToUnixSlashes(vscmd);
@@ -195,11 +204,14 @@ const char* cmGlobalVisualStudio7Generator::ExternalProjectType(
}
return "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942";
}
-void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
- std::vector<std::string>& makeCommand, const std::string& makeProgram,
- const std::string& projectName, const std::string& /*projectDir*/,
- const std::string& targetName, const std::string& config, bool /*fast*/,
- bool /*verbose*/, std::vector<std::string> const& makeOptions)
+
+std::vector<cmGlobalGenerator::GeneratedMakeCommand>
+cmGlobalVisualStudio7Generator::GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& /*projectDir*/,
+ std::vector<std::string> const& targetNames, const std::string& config,
+ bool /*fast*/, int /*jobs*/, bool /*verbose*/,
+ std::vector<std::string> const& makeOptions)
{
// Select the caller- or user-preferred make program, else devenv.
std::string makeProgramSelected =
@@ -214,38 +226,43 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
makeProgramSelected = this->GetDevEnvCommand();
}
- makeCommand.push_back(makeProgramSelected);
+ // Workaround to convince VCExpress.exe to produce output.
+ const bool requiresOutputForward =
+ (makeProgramLower.find("vcexpress") != std::string::npos);
+ std::vector<GeneratedMakeCommand> makeCommands;
- makeCommand.push_back(std::string(projectName) + ".sln");
- std::string realTarget = targetName;
- bool clean = false;
- if (realTarget == "clean") {
- clean = true;
- realTarget = "ALL_BUILD";
- }
- if (clean) {
- makeCommand.push_back("/clean");
- } else {
- makeCommand.push_back("/build");
+ std::vector<std::string> realTargetNames = targetNames;
+ if (targetNames.empty() ||
+ ((targetNames.size() == 1) && targetNames.front().empty())) {
+ realTargetNames = { "ALL_BUILD" };
}
-
- if (!config.empty()) {
- makeCommand.push_back(config);
- } else {
- makeCommand.push_back("Debug");
- }
- makeCommand.push_back("/project");
-
- if (!realTarget.empty()) {
- makeCommand.push_back(realTarget);
- } else {
- makeCommand.push_back("ALL_BUILD");
- }
- makeCommand.insert(makeCommand.end(), makeOptions.begin(),
- makeOptions.end());
+ for (const auto& tname : realTargetNames) {
+ std::string realTarget;
+ if (!tname.empty()) {
+ realTarget = tname;
+ } else {
+ continue;
+ }
+ bool clean = false;
+ if (realTarget == "clean") {
+ clean = true;
+ realTarget = "ALL_BUILD";
+ }
+ GeneratedMakeCommand makeCommand;
+ makeCommand.RequiresOutputForward = requiresOutputForward;
+ makeCommand.Add(makeProgramSelected);
+ makeCommand.Add(projectName + ".sln");
+ makeCommand.Add((clean ? "/clean" : "/build"));
+ makeCommand.Add((config.empty() ? "Debug" : config));
+ makeCommand.Add("/project");
+ makeCommand.Add(realTarget);
+ makeCommand.Add(makeOptions.begin(), makeOptions.end());
+ makeCommands.emplace_back(std::move(makeCommand));
+ }
+ return makeCommands;
}
-///! Create a local generator appropriate to this Global Generator
+//! Create a local generator appropriate to this Global Generator
cmLocalGenerator* cmGlobalVisualStudio7Generator::CreateLocalGenerator(
cmMakefile* mf)
{
@@ -254,13 +271,14 @@ cmLocalGenerator* cmGlobalVisualStudio7Generator::CreateLocalGenerator(
return lg;
}
-std::string const& cmGlobalVisualStudio7Generator::GetPlatformName() const
+#if !defined(CMAKE_BOOTSTRAP)
+Json::Value cmGlobalVisualStudio7Generator::GetJson() const
{
- if (!this->GeneratorPlatform.empty()) {
- return this->GeneratorPlatform;
- }
- return this->DefaultPlatformName;
+ Json::Value generator = this->cmGlobalVisualStudioGenerator::GetJson();
+ generator["platform"] = this->GetPlatformName();
+ return generator;
}
+#endif
bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s,
cmMakefile* mf)
@@ -270,18 +288,6 @@ bool cmGlobalVisualStudio7Generator::SetSystemName(std::string const& s,
return this->cmGlobalVisualStudioGenerator::SetSystemName(s, mf);
}
-bool cmGlobalVisualStudio7Generator::SetGeneratorPlatform(std::string const& p,
- cmMakefile* mf)
-{
- if (this->GetPlatformName() == "x64") {
- mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE");
- } else if (this->GetPlatformName() == "Itanium") {
- mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE");
- }
- mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName().c_str());
- return this->cmGlobalVisualStudioGenerator::SetGeneratorPlatform(p, mf);
-}
-
void cmGlobalVisualStudio7Generator::Generate()
{
// first do the superclass method
@@ -291,21 +297,10 @@ void cmGlobalVisualStudio7Generator::Generate()
this->OutputSLNFile();
// If any solution or project files changed during the generation,
// tell Visual Studio to reload them...
- if (!cmSystemTools::GetErrorOccuredFlag()) {
- this->CallVisualStudioMacro(MacroReload);
- }
-
- if (this->Version == VS8 && !this->CMakeInstance->GetIsInTryCompile()) {
- const char* cmakeWarnVS8 =
- this->CMakeInstance->GetState()->GetCacheEntryValue("CMAKE_WARN_VS8");
- if (!cmakeWarnVS8 || !cmSystemTools::IsOff(cmakeWarnVS8)) {
- this->CMakeInstance->IssueMessage(
- cmake::WARNING,
- "The \"Visual Studio 8 2005\" generator is deprecated "
- "and will be removed in a future version of CMake."
- "\n"
- "Add CMAKE_WARN_VS8=OFF to the cache to disable this warning.");
- }
+ if (!cmSystemTools::GetErrorOccuredFlag() &&
+ !this->LocalGenerators.empty()) {
+ this->CallVisualStudioMacro(MacroReload,
+ GetSLNFile(this->LocalGenerators[0]));
}
}
@@ -316,10 +311,7 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile(
return;
}
this->CurrentProject = root->GetProjectName();
- std::string fname = root->GetCurrentBinaryDirectory();
- fname += "/";
- fname += root->GetProjectName();
- fname += ".sln";
+ std::string fname = GetSLNFile(root);
cmGeneratedFileStream fout(fname.c_str());
fout.SetCopyIfDifferent(true);
if (!fout) {
@@ -334,9 +326,8 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile(
// output the SLN file
void cmGlobalVisualStudio7Generator::OutputSLNFile()
{
- std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
- for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
- this->OutputSLNFile(it->second[0], it->second);
+ for (auto& it : this->ProjectMap) {
+ this->OutputSLNFile(it.second[0], it.second);
}
}
@@ -346,9 +337,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
{
// loop over again and write out configurations for each target
// in the solution
- for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin();
- tt != projectTargets.end(); ++tt) {
- cmGeneratorTarget const* target = *tt;
+ for (cmGeneratorTarget const* target : projectTargets) {
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -378,9 +367,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
VisualStudioFolders.clear();
std::string rootBinaryDir = root->GetCurrentBinaryDirectory();
- for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin();
- tt != projectTargets.end(); ++tt) {
- cmGeneratorTarget const* target = *tt;
+ for (cmGeneratorTarget const* target : projectTargets) {
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -401,9 +388,9 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
if (vcprojName) {
cmLocalGenerator* lg = target->GetLocalGenerator();
std::string dir = lg->GetCurrentBinaryDirectory();
- dir = root->ConvertToRelativePath(rootBinaryDir, dir.c_str());
+ dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir.c_str());
if (dir == ".") {
- dir = ""; // msbuild cannot handle ".\" prefix
+ dir.clear(); // msbuild cannot handle ".\" prefix
}
this->WriteProject(fout, vcprojName, dir.c_str(), target);
written = true;
@@ -415,24 +402,23 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
if (written && this->UseFolderProperty()) {
const std::string targetFolder = target->GetEffectiveFolderName();
if (!targetFolder.empty()) {
- std::vector<cmsys::String> tokens =
+ std::vector<std::string> tokens =
cmSystemTools::SplitString(targetFolder, '/', false);
- std::string cumulativePath = "";
+ std::string cumulativePath;
- for (std::vector<cmsys::String>::iterator iter = tokens.begin();
- iter != tokens.end(); ++iter) {
- if (!iter->size()) {
+ for (std::string const& iter : tokens) {
+ if (!iter.size()) {
continue;
}
if (cumulativePath.empty()) {
- cumulativePath = "CMAKE_FOLDER_GUID_" + *iter;
+ cumulativePath = "CMAKE_FOLDER_GUID_" + iter;
} else {
VisualStudioFolders[cumulativePath].insert(cumulativePath + "/" +
- *iter);
+ iter);
- cumulativePath = cumulativePath + "/" + *iter;
+ cumulativePath = cumulativePath + "/" + iter;
}
}
@@ -447,9 +433,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
void cmGlobalVisualStudio7Generator::WriteTargetDepends(
std::ostream& fout, OrderedTargetDependSet const& projectTargets)
{
- for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin();
- tt != projectTargets.end(); ++tt) {
- cmGeneratorTarget const* target = *tt;
+ for (cmGeneratorTarget const* target : projectTargets) {
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -464,18 +448,15 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends(
void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout)
{
- const char* prefix = "CMAKE_FOLDER_GUID_";
- const std::string::size_type skip_prefix = strlen(prefix);
+ cm::string_view const prefix = "CMAKE_FOLDER_GUID_";
std::string guidProjectTypeFolder = "2150E333-8FDC-42A3-9474-1A3956D46DE8";
- for (std::map<std::string, std::set<std::string> >::iterator iter =
- VisualStudioFolders.begin();
- iter != VisualStudioFolders.end(); ++iter) {
- std::string fullName = iter->first;
- std::string guid = this->GetGUID(fullName.c_str());
+ for (auto const& iter : VisualStudioFolders) {
+ std::string fullName = iter.first;
+ std::string guid = this->GetGUID(fullName);
std::replace(fullName.begin(), fullName.end(), '/', '\\');
- if (cmSystemTools::StringStartsWith(fullName.c_str(), prefix)) {
- fullName = fullName.substr(skip_prefix);
+ if (cmHasPrefix(fullName, prefix)) {
+ fullName = fullName.substr(prefix.size());
}
std::string nameOnly = cmSystemTools::GetFilenameName(fullName);
@@ -487,16 +468,13 @@ void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout)
void cmGlobalVisualStudio7Generator::WriteFoldersContent(std::ostream& fout)
{
- for (std::map<std::string, std::set<std::string> >::iterator iter =
- VisualStudioFolders.begin();
- iter != VisualStudioFolders.end(); ++iter) {
- std::string key(iter->first);
- std::string guidParent(this->GetGUID(key.c_str()));
+ for (auto const& iter : VisualStudioFolders) {
+ std::string key(iter.first);
+ std::string guidParent(this->GetGUID(key));
- for (std::set<std::string>::iterator it = iter->second.begin();
- it != iter->second.end(); ++it) {
- std::string value(*it);
- std::string guid(this->GetGUID(value.c_str()));
+ for (std::string const& it : iter.second) {
+ std::string value(it);
+ std::string guid(this->GetGUID(value));
fout << "\t\t{" << guid << "} = {" << guidParent << "}\n";
}
@@ -525,11 +503,10 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
bool extensibilityAddInsOverridden = false;
const std::vector<std::string> propKeys =
root->GetMakefile()->GetPropertyKeys();
- for (std::vector<std::string>::const_iterator it = propKeys.begin();
- it != propKeys.end(); ++it) {
- if (it->find("VS_GLOBAL_SECTION_") == 0) {
+ for (std::string const& it : propKeys) {
+ if (it.find("VS_GLOBAL_SECTION_") == 0) {
std::string sectionType;
- std::string name = it->substr(18);
+ std::string name = it.substr(18);
if (name.find("PRE_") == 0) {
name = name.substr(4);
sectionType = "preSolution";
@@ -548,18 +525,15 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
extensibilityAddInsOverridden = true;
}
fout << "\tGlobalSection(" << name << ") = " << sectionType << "\n";
- std::vector<std::string> keyValuePairs;
- cmSystemTools::ExpandListArgument(
- root->GetMakefile()->GetProperty(it->c_str()), keyValuePairs);
- for (std::vector<std::string>::const_iterator itPair =
- keyValuePairs.begin();
- itPair != keyValuePairs.end(); ++itPair) {
- const std::string::size_type posEqual = itPair->find('=');
+ std::vector<std::string> keyValuePairs =
+ cmExpandedList(root->GetMakefile()->GetProperty(it));
+ for (std::string const& itPair : keyValuePairs) {
+ const std::string::size_type posEqual = itPair.find('=');
if (posEqual != std::string::npos) {
const std::string key =
- cmSystemTools::TrimWhitespace(itPair->substr(0, posEqual));
+ cmTrimWhitespace(itPair.substr(0, posEqual));
const std::string value =
- cmSystemTools::TrimWhitespace(itPair->substr(posEqual + 1));
+ cmTrimWhitespace(itPair.substr(posEqual + 1));
fout << "\t\t" << key << " = " << value << "\n";
if (key == "SolutionGuid") {
addGuid = false;
@@ -594,12 +568,10 @@ std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend(
{
std::vector<std::string> configs;
target->Target->GetMakefile()->GetConfigurations(configs);
- std::string pname = target->GetName();
- pname += "_UTILITY";
- std::string fname = target->GetLocalGenerator()->GetCurrentBinaryDirectory();
- fname += "/";
- fname += pname;
- fname += ".vcproj";
+ std::string pname = cmStrCat(target->GetName(), "_UTILITY");
+ std::string fname =
+ cmStrCat(target->GetLocalGenerator()->GetCurrentBinaryDirectory(), '/',
+ pname, ".vcproj");
cmGeneratedFileStream fout(fname.c_str());
fout.SetCopyIfDifferent(true);
std::string guid = this->GetGUID(pname.c_str());
@@ -618,14 +590,13 @@ std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend(
"\t<Configurations>\n"
;
/* clang-format on */
- for (std::vector<std::string>::iterator i = configs.begin();
- i != configs.end(); ++i) {
+ for (std::string const& i : configs) {
/* clang-format off */
fout <<
"\t\t<Configuration\n"
- "\t\t\tName=\"" << *i << "|Win32\"\n"
- "\t\t\tOutputDirectory=\"" << *i << "\"\n"
- "\t\t\tIntermediateDirectory=\"" << pname << ".dir\\" << *i << "\"\n"
+ "\t\t\tName=\"" << i << "|Win32\"\n"
+ "\t\t\tOutputDirectory=\"" << i << "\"\n"
+ "\t\t\tIntermediateDirectory=\"" << pname << ".dir\\" << i << "\"\n"
"\t\t\tConfigurationType=\"10\"\n"
"\t\t\tUseOfMFC=\"0\"\n"
"\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n"
@@ -653,13 +624,12 @@ std::string cmGlobalVisualStudio7Generator::GetGUID(std::string const& name)
{
std::string const& guidStoreName = name + "_GUID_CMAKE";
if (const char* storedGUID =
- this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str())) {
+ this->CMakeInstance->GetCacheDefinition(guidStoreName)) {
return std::string(storedGUID);
}
// Compute a GUID that is deterministic but unique to the build tree.
- std::string input = this->CMakeInstance->GetState()->GetBinaryDirectory();
- input += "|";
- input += name;
+ std::string input =
+ cmStrCat(this->CMakeInstance->GetState()->GetBinaryDirectory(), '|', name);
cmUuid uuidGenerator;
@@ -696,23 +666,18 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
std::vector<std::string> targetNames;
targetNames.push_back("INSTALL");
targetNames.push_back("PACKAGE");
- for (std::vector<std::string>::const_iterator t = targetNames.begin();
- t != targetNames.end(); ++t) {
- // check if target <*t> is part of default build
- if (target->GetName() == *t) {
+ for (std::string const& t : targetNames) {
+ // check if target <t> is part of default build
+ if (target->GetName() == t) {
const std::string propertyName =
- "CMAKE_VS_INCLUDE_" + *t + "_TO_DEFAULT_BUILD";
- // inspect CMAKE_VS_INCLUDE_<*t>_TO_DEFAULT_BUILD properties
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
+ "CMAKE_VS_INCLUDE_" + t + "_TO_DEFAULT_BUILD";
+ // inspect CMAKE_VS_INCLUDE_<t>_TO_DEFAULT_BUILD properties
+ for (std::string const& i : configs) {
const char* propertyValue =
target->Target->GetMakefile()->GetDefinition(propertyName);
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
- ge.Parse(propertyValue);
- if (cmSystemTools::IsOn(
- cge->Evaluate(target->GetLocalGenerator(), *i))) {
- activeConfigs.insert(*i);
+ if (cmIsOn(cmGeneratorExpression::Evaluate(
+ propertyValue, target->GetLocalGenerator(), i))) {
+ activeConfigs.insert(i);
}
}
}
@@ -724,12 +689,11 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
return activeConfigs;
}
// inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
+ for (std::string const& i : configs) {
const char* propertyValue =
- target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str());
- if (cmSystemTools::IsOff(propertyValue)) {
- activeConfigs.insert(*i);
+ target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i);
+ if (cmIsOff(propertyValue)) {
+ activeConfigs.insert(i);
}
}
return activeConfigs;
@@ -738,9 +702,8 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
bool cmGlobalVisualStudio7Generator::IsDependedOn(
OrderedTargetDependSet const& projectTargets, cmGeneratorTarget const* gtIn)
{
- for (OrderedTargetDependSet::const_iterator l = projectTargets.begin();
- l != projectTargets.end(); ++l) {
- TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(*l);
+ for (cmTargetDepend const& l : projectTargets) {
+ TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(l);
if (tgtdeps.count(gtIn)) {
return true;
}
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index 32a8d6056..7a9fcefa2 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -3,9 +3,8 @@
#ifndef cmGlobalVisualStudio7Generator_h
#define cmGlobalVisualStudio7Generator_h
-#include "cmGlobalVisualStudioGenerator.h"
-
#include "cmGlobalGeneratorFactory.h"
+#include "cmGlobalVisualStudioGenerator.h"
class cmTarget;
struct cmIDEFlagTable;
@@ -18,19 +17,16 @@ struct cmIDEFlagTable;
class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator
{
public:
- cmGlobalVisualStudio7Generator(cmake* cm,
- const std::string& platformName = "");
~cmGlobalVisualStudio7Generator();
- ///! Get the name for the platform.
- std::string const& GetPlatformName() const;
+ //! Create a local generator appropriate to this Global Generator
+ cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override;
- ///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
-
- virtual bool SetSystemName(std::string const& s, cmMakefile* mf);
+#if !defined(CMAKE_BOOTSTRAP)
+ Json::Value GetJson() const override;
+#endif
- virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf);
+ bool SetSystemName(std::string const& s, cmMakefile* mf) override;
/**
* Utilized by the generator factory to determine if this generator
@@ -48,36 +44,36 @@ public:
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
*/
- virtual void EnableLanguage(std::vector<std::string> const& languages,
- cmMakefile*, bool optional);
+ void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
+ bool optional) override;
/**
* Try running cmake and building a file. This is used for dynamically
* loaded commands, not as part of the usual build process.
*/
- virtual void GenerateBuildCommand(
- std::vector<std::string>& makeCommand, const std::string& makeProgram,
- const std::string& projectName, const std::string& projectDir,
- const std::string& targetName, const std::string& config, bool fast,
- bool verbose,
- std::vector<std::string> const& makeOptions = std::vector<std::string>());
+ std::vector<GeneratedMakeCommand> GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions =
+ std::vector<std::string>()) override;
/**
* Generate the DSW workspace file.
*/
virtual void OutputSLNFile();
- ///! Lookup a stored GUID or compute one deterministically.
+ //! Lookup a stored GUID or compute one deterministically.
std::string GetGUID(std::string const& name);
/** Append the subdirectory for the given configuration. */
- virtual void AppendDirectoryForConfig(const std::string& prefix,
- const std::string& config,
- const std::string& suffix,
- std::string& dir);
+ void AppendDirectoryForConfig(const std::string& prefix,
+ const std::string& config,
+ const std::string& suffix,
+ std::string& dir) override;
- ///! What is the configurations directory variable called?
- virtual const char* GetCMakeCFGIntDir() const
+ //! What is the configurations directory variable called?
+ const char* GetCMakeCFGIntDir() const override
{
return "$(ConfigurationName)";
}
@@ -89,9 +85,9 @@ public:
return false;
}
- const char* GetIntelProjectVersion();
+ const std::string& GetIntelProjectVersion();
- bool FindMakeProgram(cmMakefile* mf) CM_OVERRIDE;
+ bool FindMakeProgram(cmMakefile* mf) override;
/** Is the Microsoft Assembler enabled? */
bool IsMasmEnabled() const { return this->MasmEnabled; }
@@ -103,8 +99,10 @@ public:
cmIDEFlagTable const* ExtraFlagTable;
protected:
- virtual void Generate();
- virtual const char* GetIDEVersion() = 0;
+ cmGlobalVisualStudio7Generator(cmake* cm,
+ std::string const& platformInGeneratorName);
+
+ void Generate() override;
std::string const& GetDevEnvCommand();
virtual std::string FindDevEnvCommand();
@@ -128,8 +126,7 @@ protected:
virtual void WriteSLNGlobalSections(std::ostream& fout,
cmLocalGenerator* root);
virtual void WriteSLNFooter(std::ostream& fout);
- virtual void WriteSLNHeader(std::ostream& fout) = 0;
- virtual std::string WriteUtilityDepend(const cmGeneratorTarget* target);
+ std::string WriteUtilityDepend(const cmGeneratorTarget* target) override;
virtual void WriteTargetsToSolution(
std::ostream& fout, cmLocalGenerator* root,
@@ -142,7 +139,7 @@ protected:
virtual void WriteExternalProject(
std::ostream& fout, const std::string& name, const char* path,
- const char* typeGuid, const std::set<std::string>& dependencies) = 0;
+ const char* typeGuid, const std::set<BT<std::string>>& dependencies) = 0;
std::string ConvertToSolutionPath(const char* path);
@@ -156,21 +153,19 @@ protected:
virtual void WriteFolders(std::ostream& fout);
virtual void WriteFoldersContent(std::ostream& fout);
- std::map<std::string, std::set<std::string> > VisualStudioFolders;
+ std::map<std::string, std::set<std::string>> VisualStudioFolders;
// Set during OutputSLNFile with the name of the current project.
// There is one SLN file per project.
std::string CurrentProject;
- std::string GeneratorPlatform;
- std::string DefaultPlatformName;
bool MasmEnabled;
bool NasmEnabled;
private:
- char* IntelProjectVersion;
+ std::string IntelProjectVersion;
std::string DevEnvCommand;
bool DevEnvCommandInitialized;
- virtual std::string GetVSMakeProgram() { return this->GetDevEnvCommand(); }
+ std::string GetVSMakeProgram() override { return this->GetDevEnvCommand(); }
};
#define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK"
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index f06a8a1c6..8e6125b8a 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -2,108 +2,36 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalVisualStudio8Generator.h"
+#include "cmCustomCommand.h"
+#include "cmCustomCommandLines.h"
#include "cmDocumentationEntry.h"
#include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmLocalVisualStudio7Generator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmSourceFile.h"
#include "cmVisualStudioWCEPlatformParser.h"
#include "cmake.h"
-static const char vs8generatorName[] = "Visual Studio 8 2005";
-
-class cmGlobalVisualStudio8Generator::Factory : public cmGlobalGeneratorFactory
-{
-public:
- cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
- cmake* cm) const CM_OVERRIDE
- {
- if (strncmp(name.c_str(), vs8generatorName,
- sizeof(vs8generatorName) - 1) != 0) {
- return 0;
- }
-
- const char* p = name.c_str() + sizeof(vs8generatorName) - 1;
- if (p[0] == '\0') {
- return new cmGlobalVisualStudio8Generator(cm, name, "");
- }
-
- if (p[0] != ' ') {
- return 0;
- }
-
- ++p;
-
- if (!strcmp(p, "Win64")) {
- return new cmGlobalVisualStudio8Generator(cm, name, "x64");
- }
-
- cmVisualStudioWCEPlatformParser parser(p);
- parser.ParseVersion("8.0");
- if (!parser.Found()) {
- return 0;
- }
-
- cmGlobalVisualStudio8Generator* ret =
- new cmGlobalVisualStudio8Generator(cm, name, p);
- ret->WindowsCEVersion = parser.GetOSVersion();
- return ret;
- }
-
- void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
- {
- entry.Name = std::string(vs8generatorName) + " [arch]";
- entry.Brief = "Deprecated. Generates Visual Studio 2005 project files. "
- "Optional [arch] can be \"Win64\".";
- }
-
- void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
- {
- names.push_back(vs8generatorName);
- names.push_back(vs8generatorName + std::string(" Win64"));
- cmVisualStudioWCEPlatformParser parser;
- parser.ParseVersion("8.0");
- const std::vector<std::string>& availablePlatforms =
- parser.GetAvailablePlatforms();
- for (std::vector<std::string>::const_iterator i =
- availablePlatforms.begin();
- i != availablePlatforms.end(); ++i) {
- names.push_back("Visual Studio 8 2005 " + *i);
- }
- }
-
- bool SupportsToolset() const CM_OVERRIDE { return false; }
- bool SupportsPlatform() const CM_OVERRIDE { return true; }
-};
-
-cmGlobalGeneratorFactory* cmGlobalVisualStudio8Generator::NewFactory()
-{
- return new Factory;
-}
-
cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator(
- cmake* cm, const std::string& name, const std::string& platformName)
- : cmGlobalVisualStudio71Generator(cm, platformName)
+ cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName)
+ : cmGlobalVisualStudio71Generator(cm, platformInGeneratorName)
{
this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms";
this->Name = name;
this->ExtraFlagTable = this->GetExtraFlagTableVS8();
- this->Version = VS8;
- std::string vc8Express;
- this->ExpressEdition = cmSystemTools::ReadRegistryValue(
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\8.0\\Setup\\VC;"
- "ProductDir",
- vc8Express, cmSystemTools::KeyWOW64_32);
}
std::string cmGlobalVisualStudio8Generator::FindDevEnvCommand()
{
// First look for VCExpress.
std::string vsxcmd;
- std::string vsxkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\";
- vsxkey += this->GetIDEVersion();
- vsxkey += ";InstallDir";
+ std::string vsxkey =
+ cmStrCat("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\",
+ this->GetIDEVersion(), ";InstallDir");
if (cmSystemTools::ReadRegistryValue(vsxkey.c_str(), vsxcmd,
cmSystemTools::KeyWOW64_32)) {
cmSystemTools::ConvertToUnixSlashes(vsxcmd);
@@ -117,9 +45,8 @@ std::string cmGlobalVisualStudio8Generator::FindDevEnvCommand()
void cmGlobalVisualStudio8Generator::EnableLanguage(
std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
{
- for (std::vector<std::string>::const_iterator it = lang.begin();
- it != lang.end(); ++it) {
- if (*it == "ASM_MASM") {
+ for (std::string const& it : lang) {
+ if (it == "ASM_MASM") {
this->MasmEnabled = true;
}
}
@@ -130,15 +57,14 @@ void cmGlobalVisualStudio8Generator::EnableLanguage(
void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf)
{
if (this->TargetsWindowsCE()) {
- mf->AddDefinition("CMAKE_VS_WINCE_VERSION",
- this->WindowsCEVersion.c_str());
+ mf->AddDefinition("CMAKE_VS_WINCE_VERSION", this->WindowsCEVersion);
}
}
bool cmGlobalVisualStudio8Generator::SetGeneratorPlatform(std::string const& p,
cmMakefile* mf)
{
- if (this->DefaultPlatformName == "Win32") {
+ if (!this->PlatformInGeneratorName) {
this->GeneratorPlatform = p;
return this->cmGlobalVisualStudio7Generator::SetGeneratorPlatform("", mf);
} else {
@@ -146,13 +72,6 @@ bool cmGlobalVisualStudio8Generator::SetGeneratorPlatform(std::string const& p,
}
}
-// ouput standard header for dsw file
-void cmGlobalVisualStudio8Generator::WriteSLNHeader(std::ostream& fout)
-{
- fout << "Microsoft Visual Studio Solution File, Format Version 9.00\n";
- fout << "# Visual Studio 2005\n";
-}
-
std::string cmGlobalVisualStudio8Generator::GetGenerateStampList()
{
return "generate.stamp.list";
@@ -163,71 +82,32 @@ void cmGlobalVisualStudio8Generator::Configure()
this->cmGlobalVisualStudio7Generator::Configure();
}
-bool cmGlobalVisualStudio8Generator::UseFolderProperty()
+bool cmGlobalVisualStudio8Generator::UseFolderProperty() const
{
return IsExpressEdition() ? false : cmGlobalGenerator::UseFolderProperty();
}
-std::string cmGlobalVisualStudio8Generator::GetUserMacrosDirectory()
-{
- // Some VS8 sp0 versions cannot run macros.
- // See http://support.microsoft.com/kb/928209
- const char* vc8sp1Registry =
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\"
- "InstalledProducts\\KB926601;";
- const char* vc8exSP1Registry =
- "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\"
- "InstalledProducts\\KB926748;";
- std::string vc8sp1;
- if (!cmSystemTools::ReadRegistryValue(vc8sp1Registry, vc8sp1) &&
- !cmSystemTools::ReadRegistryValue(vc8exSP1Registry, vc8sp1)) {
- return "";
- }
-
- std::string base;
- std::string path;
-
- // base begins with the VisualStudioProjectsLocation reg value...
- if (cmSystemTools::ReadRegistryValue(
- "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\8.0;"
- "VisualStudioProjectsLocation",
- base)) {
- cmSystemTools::ConvertToUnixSlashes(base);
-
- // 8.0 macros folder:
- path = base + "/VSMacros80";
- }
-
- // path is (correctly) still empty if we did not read the base value from
- // the Registry value
- return path;
-}
-
-std::string cmGlobalVisualStudio8Generator::GetUserMacrosRegKeyBase()
-{
- return "Software\\Microsoft\\VisualStudio\\8.0\\vsmacros";
-}
-
bool cmGlobalVisualStudio8Generator::AddCheckTarget()
{
// Add a special target on which all other targets depend that
// checks the build system and optionally re-runs CMake.
- const char* no_working_directory = 0;
- std::vector<std::string> no_depends;
+ // Skip the target if no regeneration is to be done.
+ if (this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION")) {
+ return false;
+ }
+
std::vector<cmLocalGenerator*> const& generators = this->LocalGenerators;
cmLocalVisualStudio7Generator* lg =
static_cast<cmLocalVisualStudio7Generator*>(generators[0]);
cmMakefile* mf = lg->GetMakefile();
- // Skip the target if no regeneration is to be done.
- if (mf->IsOn("CMAKE_SUPPRESS_REGENERATION")) {
- return false;
- }
-
- cmCustomCommandLines noCommandLines;
- cmTarget* tgt =
- mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false,
- no_working_directory, no_depends, noCommandLines);
+ const char* no_working_directory = nullptr;
+ std::vector<std::string> no_byproducts;
+ std::vector<std::string> no_depends;
+ cmCustomCommandLines no_commands;
+ cmTarget* tgt = mf->AddUtilityCommand(
+ CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmCommandOrigin::Generator, false,
+ no_working_directory, no_byproducts, no_depends, no_commands);
cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg);
lg->AddGeneratorTarget(gt);
@@ -240,22 +120,17 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
// Create a list of all stamp files for this project.
std::vector<std::string> stamps;
- std::string stampList = cmake::GetCMakeFilesDirectoryPostSlash();
- stampList += cmGlobalVisualStudio8Generator::GetGenerateStampList();
+ std::string stampList = cmStrCat(
+ "CMakeFiles/", cmGlobalVisualStudio8Generator::GetGenerateStampList());
{
std::string stampListFile =
- generators[0]->GetMakefile()->GetCurrentBinaryDirectory();
- stampListFile += "/";
- stampListFile += stampList;
+ cmStrCat(generators[0]->GetMakefile()->GetCurrentBinaryDirectory(), '/',
+ stampList);
std::string stampFile;
cmGeneratedFileStream fout(stampListFile.c_str());
- for (std::vector<cmLocalGenerator*>::const_iterator gi =
- generators.begin();
- gi != generators.end(); ++gi) {
- stampFile = (*gi)->GetMakefile()->GetCurrentBinaryDirectory();
- stampFile += "/";
- stampFile += cmake::GetCMakeFilesDirectoryPostSlash();
- stampFile += "generate.stamp";
+ for (cmLocalGenerator const* gi : generators) {
+ stampFile = cmStrCat(gi->GetMakefile()->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/generate.stamp");
fout << stampFile << "\n";
stamps.push_back(stampFile);
}
@@ -266,11 +141,29 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
// Collect the input files used to generate all targets in this
// project.
std::vector<std::string> listFiles;
- for (unsigned int j = 0; j < generators.size(); ++j) {
- cmMakefile* lmf = generators[j]->GetMakefile();
- listFiles.insert(listFiles.end(), lmf->GetListFiles().begin(),
- lmf->GetListFiles().end());
+ for (cmLocalGenerator* gen : generators) {
+ cmAppend(listFiles, gen->GetMakefile()->GetListFiles());
+ }
+
+ // Add a custom prebuild target to run the VerifyGlobs script.
+ cmake* cm = this->GetCMakeInstance();
+ if (cm->DoWriteGlobVerifyTarget()) {
+ cmCustomCommandLines verifyCommandLines = cmMakeSingleCommandLine(
+ { cmSystemTools::GetCMakeCommand(), "-P", cm->GetGlobVerifyScript() });
+ std::vector<std::string> byproducts;
+ byproducts.push_back(cm->GetGlobVerifyStamp());
+
+ mf->AddCustomCommandToTarget(
+ CMAKE_CHECK_BUILD_SYSTEM_TARGET, byproducts, no_depends,
+ verifyCommandLines, cmCustomCommandType::PRE_BUILD,
+ "Checking File Globs", no_working_directory, false);
+
+ // Ensure ZERO_CHECK always runs in Visual Studio using MSBuild,
+ // otherwise the prebuild command will not be run.
+ tgt->SetProperty("VS_GLOBAL_DisableFastUpToDateCheck", "true");
+ listFiles.push_back(cm->GetGlobVerifyStamp());
}
+
// Sort the list of input files and remove duplicates.
std::sort(listFiles.begin(), listFiles.end(), std::less<std::string>());
std::vector<std::string>::iterator new_end =
@@ -278,37 +171,27 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
listFiles.erase(new_end, listFiles.end());
// Create a rule to re-run CMake.
- std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash();
- stampName += "generate.stamp";
- cmCustomCommandLine commandLine;
- commandLine.push_back(cmSystemTools::GetCMakeCommand());
- std::string argH = "-H";
- argH += lg->GetSourceDirectory();
- commandLine.push_back(argH);
- std::string argB = "-B";
- argB += lg->GetBinaryDirectory();
- commandLine.push_back(argB);
- commandLine.push_back("--check-stamp-list");
- commandLine.push_back(stampList.c_str());
- commandLine.push_back("--vs-solution-file");
- std::string const sln = std::string(lg->GetBinaryDirectory()) + "/" +
- lg->GetProjectName() + ".sln";
- commandLine.push_back(sln);
- cmCustomCommandLines commandLines;
- commandLines.push_back(commandLine);
+ std::string argS = cmStrCat("-S", lg->GetSourceDirectory());
+ std::string argB = cmStrCat("-B", lg->GetBinaryDirectory());
+ std::string const sln =
+ lg->GetBinaryDirectory() + "/" + lg->GetProjectName() + ".sln";
+ cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
+ { cmSystemTools::GetCMakeCommand(), argS, argB, "--check-stamp-list",
+ stampList, "--vs-solution-file", sln });
// Add the rule. Note that we cannot use the CMakeLists.txt
// file as the main dependency because it would get
// overwritten by the CreateVCProjBuildRule.
// (this could be avoided with per-target source files)
- std::string no_main_dependency = "";
- std::vector<std::string> no_byproducts;
+ std::string no_main_dependency;
+ cmImplicitDependsList no_implicit_depends;
if (cmSourceFile* file = mf->AddCustomCommandToOutput(
- stamps, no_byproducts, listFiles, no_main_dependency, commandLines,
- "Checking Build System", no_working_directory, true, false)) {
- gt->AddSource(file->GetFullPath());
+ stamps, no_byproducts, listFiles, no_main_dependency,
+ no_implicit_depends, commandLines, "Checking Build System",
+ no_working_directory, true, false)) {
+ gt->AddSource(file->ResolveFullPath());
} else {
- cmSystemTools::Error("Error adding rule for ", stamps[0].c_str());
+ cmSystemTools::Error("Error adding rule for " + stamps[0]);
}
}
@@ -320,13 +203,12 @@ void cmGlobalVisualStudio8Generator::AddExtraIDETargets()
cmGlobalVisualStudio7Generator::AddExtraIDETargets();
if (this->AddCheckTarget()) {
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- std::vector<cmGeneratorTarget*> tgts =
+ const std::vector<cmGeneratorTarget*>& tgts =
this->LocalGenerators[i]->GetGeneratorTargets();
// All targets depend on the build-system check target.
- for (std::vector<cmGeneratorTarget*>::iterator ti = tgts.begin();
- ti != tgts.end(); ++ti) {
- if ((*ti)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
- (*ti)->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
+ for (cmGeneratorTarget const* ti : tgts) {
+ if (ti->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
+ ti->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
}
}
}
@@ -337,10 +219,9 @@ void cmGlobalVisualStudio8Generator::WriteSolutionConfigurations(
std::ostream& fout, std::vector<std::string> const& configs)
{
fout << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n";
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
- fout << "\t\t" << *i << "|" << this->GetPlatformName() << " = " << *i
- << "|" << this->GetPlatformName() << "\n";
+ for (std::string const& i : configs) {
+ fout << "\t\t" << i << "|" << this->GetPlatformName() << " = " << i << "|"
+ << this->GetPlatformName() << "\n";
}
fout << "\tEndGlobalSection\n";
}
@@ -352,35 +233,34 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations(
std::string const& platformMapping)
{
std::string guid = this->GetGUID(name);
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
+ for (std::string const& i : configs) {
std::vector<std::string> mapConfig;
- const char* dstConfig = i->c_str();
+ const char* dstConfig = i.c_str();
if (target.GetProperty("EXTERNAL_MSPROJECT")) {
if (const char* m = target.GetProperty("MAP_IMPORTED_CONFIG_" +
- cmSystemTools::UpperCase(*i))) {
- cmSystemTools::ExpandListArgument(m, mapConfig);
+ cmSystemTools::UpperCase(i))) {
+ cmExpandList(m, mapConfig);
if (!mapConfig.empty()) {
dstConfig = mapConfig[0].c_str();
}
}
}
- fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName()
+ fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName()
<< ".ActiveCfg = " << dstConfig << "|"
<< (!platformMapping.empty() ? platformMapping
: this->GetPlatformName())
<< "\n";
std::set<std::string>::const_iterator ci =
- configsPartOfDefaultBuild.find(*i);
+ configsPartOfDefaultBuild.find(i);
if (!(ci == configsPartOfDefaultBuild.end())) {
- fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName()
+ fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName()
<< ".Build.0 = " << dstConfig << "|"
<< (!platformMapping.empty() ? platformMapping
: this->GetPlatformName())
<< "\n";
}
- if (this->NeedsDeploy(target.GetType())) {
- fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName()
+ if (this->NeedsDeploy(target, dstConfig)) {
+ fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName()
<< ".Deploy.0 = " << dstConfig << "|"
<< (!platformMapping.empty() ? platformMapping
: this->GetPlatformName())
@@ -390,11 +270,30 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations(
}
bool cmGlobalVisualStudio8Generator::NeedsDeploy(
- cmStateEnums::TargetType type) const
+ cmGeneratorTarget const& target, const char* config) const
+{
+ cmStateEnums::TargetType type = target.GetType();
+ bool noDeploy = DeployInhibited(target, config);
+ return !noDeploy &&
+ (type == cmStateEnums::EXECUTABLE ||
+ type == cmStateEnums::SHARED_LIBRARY) &&
+ this->TargetSystemSupportsDeployment();
+}
+
+bool cmGlobalVisualStudio8Generator::DeployInhibited(
+ cmGeneratorTarget const& target, const char* config) const
+{
+ bool rVal = false;
+ if (const char* prop = target.GetProperty("VS_NO_SOLUTION_DEPLOY")) {
+ rVal = cmIsOn(
+ cmGeneratorExpression::Evaluate(prop, target.LocalGenerator, config));
+ }
+ return rVal;
+}
+
+bool cmGlobalVisualStudio8Generator::TargetSystemSupportsDeployment() const
{
- bool needsDeploy =
- (type == cmStateEnums::EXECUTABLE || type == cmStateEnums::SHARED_LIBRARY);
- return this->TargetsWindowsCE() && needsDeploy;
+ return this->TargetsWindowsCE();
}
bool cmGlobalVisualStudio8Generator::ComputeTargetDepends()
@@ -410,12 +309,11 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends(
{
TargetDependSet const& unordered = this->GetTargetDirectDepends(gt);
OrderedTargetDependSet depends(unordered, std::string());
- for (OrderedTargetDependSet::const_iterator i = depends.begin();
- i != depends.end(); ++i) {
- if ((*i)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmTargetDepend const& i : depends) {
+ if (i->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- std::string guid = this->GetGUID((*i)->GetName().c_str());
+ std::string guid = this->GetGUID(i->GetName());
fout << "\t\t{" << guid << "} = {" << guid << "}\n";
}
}
@@ -424,11 +322,9 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies(
cmGeneratorTarget* target)
{
// Look for utility dependencies that magically link.
- for (std::set<std::string>::const_iterator ui =
- target->GetUtilities().begin();
- ui != target->GetUtilities().end(); ++ui) {
+ for (BT<std::string> const& ui : target->GetUtilities()) {
if (cmGeneratorTarget* depTarget =
- target->GetLocalGenerator()->FindGeneratorTargetToUse(ui->c_str())) {
+ target->GetLocalGenerator()->FindGeneratorTargetToUse(ui.Value)) {
if (depTarget->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
depTarget->GetProperty("EXTERNAL_MSPROJECT")) {
// This utility dependency names an external .vcproj target.
@@ -473,7 +369,7 @@ static cmVS7FlagTable cmVS8ExtraFlagTable[] = {
{ "TreatWChar_tAsBuiltInType", "Zc:wchar_t-",
"wchar_t is not a built-in type", "false", 0 },
- { 0, 0, 0, 0, 0 }
+ { "", "", "", "", 0 }
};
cmIDEFlagTable const* cmGlobalVisualStudio8Generator::GetExtraFlagTableVS8()
{
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index 4723b83ba..352bc3c2b 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -13,89 +13,73 @@
class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator
{
public:
- cmGlobalVisualStudio8Generator(cmake* cm, const std::string& name,
- const std::string& platformName);
- static cmGlobalGeneratorFactory* NewFactory();
-
- ///! Get the name for the generator.
- virtual std::string GetName() const { return this->Name; }
+ //! Get the name for the generator.
+ std::string GetName() const override { return this->Name; }
/** Get the name of the main stamp list file. */
static std::string GetGenerateStampList();
- virtual void EnableLanguage(std::vector<std::string> const& languages,
- cmMakefile*, bool optional);
+ void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
+ bool optional) override;
virtual void AddPlatformDefinitions(cmMakefile* mf);
- virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf);
+ bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
/**
* Override Configure and Generate to add the build-system check
* target.
*/
- virtual void Configure();
-
- /**
- * Where does this version of Visual Studio look for macros for the
- * current user? Returns the empty string if this version of Visual
- * Studio does not implement support for VB macros.
- */
- virtual std::string GetUserMacrosDirectory();
-
- /**
- * What is the reg key path to "vsmacros" for this version of Visual
- * Studio?
- */
- virtual std::string GetUserMacrosRegKeyBase();
+ void Configure() override;
/** Return true if the target project file should have the option
LinkLibraryDependencies and link to .sln dependencies. */
- virtual bool NeedLinkLibraryDependencies(cmGeneratorTarget* target);
+ bool NeedLinkLibraryDependencies(cmGeneratorTarget* target) override;
/** Return true if building for Windows CE */
- virtual bool TargetsWindowsCE() const
+ bool TargetsWindowsCE() const override
{
return !this->WindowsCEVersion.empty();
}
- /** Is the installed VS an Express edition? */
- bool IsExpressEdition() const { return this->ExpressEdition; }
-
protected:
- virtual void AddExtraIDETargets();
- virtual const char* GetIDEVersion() { return "8.0"; }
+ cmGlobalVisualStudio8Generator(cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName);
+
+ void AddExtraIDETargets() override;
- virtual std::string FindDevEnvCommand();
+ std::string FindDevEnvCommand() override;
- virtual bool VSLinksDependencies() const { return false; }
+ bool VSLinksDependencies() const override { return false; }
bool AddCheckTarget();
/** Return true if the configuration needs to be deployed */
- virtual bool NeedsDeploy(cmStateEnums::TargetType type) const;
+ virtual bool NeedsDeploy(cmGeneratorTarget const& target,
+ const char* config) const;
+
+ /** Returns true if deployment has been disabled in cmake file. */
+ bool DeployInhibited(cmGeneratorTarget const& target,
+ const char* config) const;
+
+ /** Returns true if the target system support debugging deployment. */
+ virtual bool TargetSystemSupportsDeployment() const;
static cmIDEFlagTable const* GetExtraFlagTableVS8();
- virtual void WriteSLNHeader(std::ostream& fout);
- virtual void WriteSolutionConfigurations(
- std::ostream& fout, std::vector<std::string> const& configs);
- virtual void WriteProjectConfigurations(
+ void WriteSolutionConfigurations(
+ std::ostream& fout, std::vector<std::string> const& configs) override;
+ void WriteProjectConfigurations(
std::ostream& fout, const std::string& name,
cmGeneratorTarget const& target, std::vector<std::string> const& configs,
const std::set<std::string>& configsPartOfDefaultBuild,
- const std::string& platformMapping = "");
- virtual bool ComputeTargetDepends();
- virtual void WriteProjectDepends(std::ostream& fout, const std::string& name,
- const char* path,
- const cmGeneratorTarget* t);
+ const std::string& platformMapping = "") override;
+ bool ComputeTargetDepends() override;
+ void WriteProjectDepends(std::ostream& fout, const std::string& name,
+ const char* path,
+ const cmGeneratorTarget* t) override;
- bool UseFolderProperty();
+ bool UseFolderProperty() const override;
std::string Name;
std::string WindowsCEVersion;
- bool ExpressEdition;
-
-private:
- class Factory;
- friend class Factory;
};
#endif
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx
index b1634e2ca..6e61d2681 100644
--- a/Source/cmGlobalVisualStudio9Generator.cxx
+++ b/Source/cmGlobalVisualStudio9Generator.cxx
@@ -5,8 +5,8 @@
#include "cmDocumentationEntry.h"
#include "cmLocalVisualStudio7Generator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmVisualStudioWCEPlatformParser.h"
-#include "cmake.h"
static const char vs9generatorName[] = "Visual Studio 9 2008";
@@ -14,7 +14,7 @@ class cmGlobalVisualStudio9Generator::Factory : public cmGlobalGeneratorFactory
{
public:
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
- cmake* cm) const CM_OVERRIDE
+ cmake* cm) const override
{
if (strncmp(name.c_str(), vs9generatorName,
sizeof(vs9generatorName) - 1) != 0) {
@@ -52,31 +52,55 @@ public:
return ret;
}
- void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
+ void GetDocumentation(cmDocumentationEntry& entry) const override
{
entry.Name = std::string(vs9generatorName) + " [arch]";
entry.Brief = "Generates Visual Studio 2008 project files. "
"Optional [arch] can be \"Win64\" or \"IA64\".";
}
- void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(vs9generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ std::vector<std::string> names;
names.push_back(vs9generatorName + std::string(" Win64"));
names.push_back(vs9generatorName + std::string(" IA64"));
cmVisualStudioWCEPlatformParser parser;
parser.ParseVersion("9.0");
const std::vector<std::string>& availablePlatforms =
parser.GetAvailablePlatforms();
- for (std::vector<std::string>::const_iterator i =
- availablePlatforms.begin();
- i != availablePlatforms.end(); ++i) {
- names.push_back("Visual Studio 9 2008 " + *i);
+ for (std::string const& i : availablePlatforms) {
+ names.push_back("Visual Studio 9 2008 " + i);
}
+ return names;
}
- bool SupportsToolset() const CM_OVERRIDE { return false; }
- bool SupportsPlatform() const CM_OVERRIDE { return true; }
+ bool SupportsToolset() const override { return false; }
+ bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("Itanium");
+ cmVisualStudioWCEPlatformParser parser;
+ parser.ParseVersion("9.0");
+ const std::vector<std::string>& availablePlatforms =
+ parser.GetAvailablePlatforms();
+ for (std::string const& i : availablePlatforms) {
+ platforms.emplace_back(i);
+ }
+ return platforms;
+ }
+
+ std::string GetDefaultPlatformName() const override { return "Win32"; }
};
cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
@@ -85,8 +109,9 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
}
cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
- cmake* cm, const std::string& name, const std::string& platformName)
- : cmGlobalVisualStudio8Generator(cm, name, platformName)
+ cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName)
+ : cmGlobalVisualStudio8Generator(cm, name, platformInGeneratorName)
{
this->Version = VS9;
std::string vc9Express;
@@ -96,12 +121,6 @@ cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
vc9Express, cmSystemTools::KeyWOW64_32);
}
-void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
-{
- fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n";
- fout << "# Visual Studio 2008\n";
-}
-
std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
{
std::string base;
diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h
index fbc1f5d07..7bebfd65f 100644
--- a/Source/cmGlobalVisualStudio9Generator.h
+++ b/Source/cmGlobalVisualStudio9Generator.h
@@ -13,31 +13,25 @@
class cmGlobalVisualStudio9Generator : public cmGlobalVisualStudio8Generator
{
public:
- cmGlobalVisualStudio9Generator(cmake* cm, const std::string& name,
- const std::string& platformName);
static cmGlobalGeneratorFactory* NewFactory();
/**
- * Try to determine system information such as shared library
- * extension, pthreads, byte order etc.
- */
- virtual void WriteSLNHeader(std::ostream& fout);
-
- /**
* Where does this version of Visual Studio look for macros for the
* current user? Returns the empty string if this version of Visual
* Studio does not implement support for VB macros.
*/
- virtual std::string GetUserMacrosDirectory();
+ std::string GetUserMacrosDirectory() override;
/**
* What is the reg key path to "vsmacros" for this version of Visual
* Studio?
*/
- virtual std::string GetUserMacrosRegKeyBase();
+ std::string GetUserMacrosRegKeyBase() override;
protected:
- virtual const char* GetIDEVersion() { return "9.0"; }
+ cmGlobalVisualStudio9Generator(cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName);
+
private:
class Factory;
friend class Factory;
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index bbff48eb6..ed0cba7dd 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -3,12 +3,21 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalVisualStudioGenerator.h"
-#include "cmsys/Encoding.hxx"
+#include <future>
#include <iostream>
+
+#include <cm/iterator>
+
#include <windows.h>
-#include "cmAlgorithms.h"
+#include <objbase.h>
+#include <shellapi.h>
+
+#include "cmsys/Encoding.hxx"
+
#include "cmCallVisualStudioMacro.h"
+#include "cmCustomCommand.h"
+#include "cmCustomCommandLines.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmLocalVisualStudioGenerator.h"
@@ -16,13 +25,22 @@
#include "cmSourceFile.h"
#include "cmState.h"
#include "cmTarget.h"
+#include "cmake.h"
-cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator(cmake* cm)
+cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator(
+ cmake* cm, std::string const& platformInGeneratorName)
: cmGlobalGenerator(cm)
{
cm->GetState()->SetIsGeneratorMultiConfig(true);
cm->GetState()->SetWindowsShell(true);
cm->GetState()->SetWindowsVSIDE(true);
+
+ if (platformInGeneratorName.empty()) {
+ this->DefaultPlatformName = "Win32";
+ } else {
+ this->DefaultPlatformName = platformInGeneratorName;
+ this->PlatformInGeneratorName = true;
+ }
}
cmGlobalVisualStudioGenerator::~cmGlobalVisualStudioGenerator()
@@ -40,6 +58,119 @@ void cmGlobalVisualStudioGenerator::SetVersion(VSVersion v)
this->Version = v;
}
+void cmGlobalVisualStudioGenerator::EnableLanguage(
+ std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
+{
+ mf->AddDefinition("CMAKE_VS_PLATFORM_NAME_DEFAULT",
+ this->DefaultPlatformName);
+ this->cmGlobalGenerator::EnableLanguage(lang, mf, optional);
+}
+
+bool cmGlobalVisualStudioGenerator::SetGeneratorPlatform(std::string const& p,
+ cmMakefile* mf)
+{
+ if (this->GetPlatformName() == "x64") {
+ mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE");
+ } else if (this->GetPlatformName() == "Itanium") {
+ mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE");
+ }
+ mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName());
+ return this->cmGlobalGenerator::SetGeneratorPlatform(p, mf);
+}
+
+std::string const& cmGlobalVisualStudioGenerator::GetPlatformName() const
+{
+ if (!this->GeneratorPlatform.empty()) {
+ return this->GeneratorPlatform;
+ }
+ return this->DefaultPlatformName;
+}
+
+const char* cmGlobalVisualStudioGenerator::GetIDEVersion() const
+{
+ switch (this->Version) {
+ case cmGlobalVisualStudioGenerator::VS9:
+ return "9.0";
+ case cmGlobalVisualStudioGenerator::VS10:
+ return "10.0";
+ case cmGlobalVisualStudioGenerator::VS11:
+ return "11.0";
+ case cmGlobalVisualStudioGenerator::VS12:
+ return "12.0";
+ case cmGlobalVisualStudioGenerator::VS14:
+ return "14.0";
+ case cmGlobalVisualStudioGenerator::VS15:
+ return "15.0";
+ case cmGlobalVisualStudioGenerator::VS16:
+ return "16.0";
+ }
+ return "";
+}
+
+void cmGlobalVisualStudioGenerator::WriteSLNHeader(std::ostream& fout)
+{
+ char utf8bom[] = { char(0xEF), char(0xBB), char(0xBF) };
+ fout.write(utf8bom, 3);
+
+ switch (this->Version) {
+ case cmGlobalVisualStudioGenerator::VS9:
+ fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n";
+ fout << "# Visual Studio 2008\n";
+ break;
+ case cmGlobalVisualStudioGenerator::VS10:
+ fout << "Microsoft Visual Studio Solution File, Format Version 11.00\n";
+ if (this->ExpressEdition) {
+ fout << "# Visual C++ Express 2010\n";
+ } else {
+ fout << "# Visual Studio 2010\n";
+ }
+ break;
+ case cmGlobalVisualStudioGenerator::VS11:
+ fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
+ if (this->ExpressEdition) {
+ fout << "# Visual Studio Express 2012 for Windows Desktop\n";
+ } else {
+ fout << "# Visual Studio 2012\n";
+ }
+ break;
+ case cmGlobalVisualStudioGenerator::VS12:
+ fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
+ if (this->ExpressEdition) {
+ fout << "# Visual Studio Express 2013 for Windows Desktop\n";
+ } else {
+ fout << "# Visual Studio 2013\n";
+ }
+ break;
+ case cmGlobalVisualStudioGenerator::VS14:
+ // Visual Studio 14 writes .sln format 12.00
+ fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
+ if (this->ExpressEdition) {
+ fout << "# Visual Studio Express 14 for Windows Desktop\n";
+ } else {
+ fout << "# Visual Studio 14\n";
+ }
+ break;
+ case cmGlobalVisualStudioGenerator::VS15:
+ // Visual Studio 15 writes .sln format 12.00
+ fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
+ if (this->ExpressEdition) {
+ fout << "# Visual Studio Express 15 for Windows Desktop\n";
+ } else {
+ fout << "# Visual Studio 15\n";
+ }
+ break;
+ case cmGlobalVisualStudioGenerator::VS16:
+ // Visual Studio 16 writes .sln format 12.00
+ fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
+ if (this->ExpressEdition) {
+ fout << "# Visual Studio Express 16 for Windows Desktop\n";
+ } else {
+ fout << "# Visual Studio 16\n";
+ }
+ break;
+ }
+}
+
std::string cmGlobalVisualStudioGenerator::GetRegistryBase()
{
return cmGlobalVisualStudioGenerator::GetRegistryBase(this->GetIDEVersion());
@@ -55,19 +186,19 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
{
// Add a special target that depends on ALL projects for easy build
// of one configuration only.
- const char* no_working_dir = 0;
+ const char* no_working_dir = nullptr;
+ std::vector<std::string> no_byproducts;
std::vector<std::string> no_depends;
cmCustomCommandLines no_commands;
- std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
- for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
- std::vector<cmLocalGenerator*>& gen = it->second;
+ for (auto const& it : this->ProjectMap) {
+ std::vector<cmLocalGenerator*> const& gen = it.second;
// add the ALL_BUILD to the first local generator of each project
if (!gen.empty()) {
// Use no actual command lines so that the target itself is not
// considered always out of date.
cmTarget* allBuild = gen[0]->GetMakefile()->AddUtilityCommand(
- "ALL_BUILD", true, no_working_dir, no_depends, no_commands, false,
- "Build all projects");
+ "ALL_BUILD", cmCommandOrigin::Generator, true, no_working_dir,
+ no_byproducts, no_depends, no_commands, false, "Build all projects");
cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]);
gen[0]->AddGeneratorTarget(gt);
@@ -80,12 +211,8 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
}
// Now make all targets depend on the ALL_BUILD target
- for (std::vector<cmLocalGenerator*>::iterator i = gen.begin();
- i != gen.end(); ++i) {
- std::vector<cmGeneratorTarget*> targets = (*i)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* tgt = *t;
+ for (cmLocalGenerator const* i : gen) {
+ for (cmGeneratorTarget* tgt : i->GetGeneratorTargets()) {
if (tgt->GetType() == cmStateEnums::GLOBAL_TARGET ||
tgt->IsImported()) {
continue;
@@ -101,22 +228,13 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
// Configure CMake Visual Studio macros, for this user on this version
// of Visual Studio.
this->ConfigureCMakeVisualStudioMacros();
-
- // Add CMakeLists.txt with custom command to rerun CMake.
- for (std::vector<cmLocalGenerator*>::const_iterator lgi =
- this->LocalGenerators.begin();
- lgi != this->LocalGenerators.end(); ++lgi) {
- cmLocalVisualStudioGenerator* lg =
- static_cast<cmLocalVisualStudioGenerator*>(*lgi);
- lg->AddCMakeListsRules();
- }
}
void cmGlobalVisualStudioGenerator::ComputeTargetObjectDirectory(
cmGeneratorTarget* gt) const
{
- std::string dir = gt->LocalGenerator->GetCurrentBinaryDirectory();
- dir += "/";
+ std::string dir =
+ cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(), '/');
std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(gt);
if (!tgtDir.empty()) {
dir += tgtDir;
@@ -148,9 +266,9 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
{
std::string dir = this->GetUserMacrosDirectory();
- if (dir != "") {
- std::string src = cmSystemTools::GetCMakeRoot();
- src += "/Templates/" CMAKE_VSMACROS_FILENAME;
+ if (!dir.empty()) {
+ std::string src = cmStrCat(cmSystemTools::GetCMakeRoot(),
+ "/Templates/" CMAKE_VSMACROS_FILENAME);
std::string dst = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME;
@@ -160,13 +278,12 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
// purposes but newer versions distributed with CMake will replace
// older versions in user directories.
int res;
- if (!cmSystemTools::FileTimeCompare(src.c_str(), dst.c_str(), &res) ||
- res > 0) {
- if (!cmSystemTools::CopyFileAlways(src.c_str(), dst.c_str())) {
+ if (!cmSystemTools::FileTimeCompare(src, dst, &res) || res > 0) {
+ if (!cmSystemTools::CopyFileAlways(src, dst)) {
std::ostringstream oss;
oss << "Could not copy from: " << src << std::endl;
oss << " to: " << dst << std::endl;
- cmSystemTools::Message(oss.str().c_str(), "Warning");
+ cmSystemTools::Message(oss.str(), "Warning");
}
}
@@ -175,11 +292,10 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros()
}
void cmGlobalVisualStudioGenerator::CallVisualStudioMacro(
- MacroName m, const char* vsSolutionFile)
+ MacroName m, const std::string& vsSolutionFile)
{
// If any solution or project files changed during the generation,
// tell Visual Studio to reload them...
- cmMakefile* mf = this->LocalGenerators[0]->GetMakefile();
std::string dir = this->GetUserMacrosDirectory();
// Only really try to call the macro if:
@@ -188,44 +304,24 @@ void cmGlobalVisualStudioGenerator::CallVisualStudioMacro(
// - the CMake vsmacros file is registered
// - there were .sln/.vcproj files changed during generation
//
- if (dir != "") {
+ if (!dir.empty()) {
std::string macrosFile = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME;
std::string nextSubkeyName;
if (cmSystemTools::FileExists(macrosFile.c_str()) &&
IsVisualStudioMacrosFileRegistered(
macrosFile, this->GetUserMacrosRegKeyBase(), nextSubkeyName)) {
- std::string topLevelSlnName;
- if (vsSolutionFile) {
- topLevelSlnName = vsSolutionFile;
- } else {
- topLevelSlnName = mf->GetCurrentBinaryDirectory();
- topLevelSlnName += "/";
- topLevelSlnName += this->LocalGenerators[0]->GetProjectName();
- topLevelSlnName += ".sln";
- }
-
if (m == MacroReload) {
std::vector<std::string> filenames;
this->GetFilesReplacedDuringGenerate(filenames);
if (!filenames.empty()) {
- // Convert vector to semi-colon delimited string of filenames:
- std::string projects;
- std::vector<std::string>::iterator it = filenames.begin();
- if (it != filenames.end()) {
- projects = *it;
- ++it;
- }
- for (; it != filenames.end(); ++it) {
- projects += ";";
- projects += *it;
- }
+ std::string projects = cmJoin(filenames, ";");
cmCallVisualStudioMacro::CallMacro(
- topLevelSlnName, CMAKE_VSMACROS_RELOAD_MACRONAME, projects,
+ vsSolutionFile, CMAKE_VSMACROS_RELOAD_MACRONAME, projects,
this->GetCMakeInstance()->GetDebugOutput());
}
} else if (m == MacroStop) {
cmCallVisualStudioMacro::CallMacro(
- topLevelSlnName, CMAKE_VSMACROS_STOP_MACRONAME, "",
+ vsSolutionFile, CMAKE_VSMACROS_STOP_MACRONAME, "",
this->GetCMakeInstance()->GetDebugOutput());
}
}
@@ -247,10 +343,9 @@ void cmGlobalVisualStudioGenerator::FillLinkClosure(
{
if (linked.insert(target).second) {
TargetDependSet const& depends = this->GetTargetDirectDepends(target);
- for (TargetDependSet::const_iterator di = depends.begin();
- di != depends.end(); ++di) {
- if (di->IsLink()) {
- this->FillLinkClosure(*di, linked);
+ for (cmTargetDepend const& di : depends) {
+ if (di.IsLink()) {
+ this->FillLinkClosure(di, linked);
}
}
}
@@ -259,7 +354,7 @@ void cmGlobalVisualStudioGenerator::FillLinkClosure(
cmGlobalVisualStudioGenerator::TargetSet const&
cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmGeneratorTarget* target)
{
- TargetSetMap::iterator i = this->TargetLinkClosure.find(target);
+ auto i = this->TargetLinkClosure.find(target);
if (i == this->TargetLinkClosure.end()) {
TargetSetMap::value_type entry(target, TargetSet());
i = this->TargetLinkClosure.insert(entry).first;
@@ -279,10 +374,9 @@ void cmGlobalVisualStudioGenerator::FollowLinkDepends(
// Static library targets do not list their link dependencies so
// we must follow them transitively now.
TargetDependSet const& depends = this->GetTargetDirectDepends(target);
- for (TargetDependSet::const_iterator di = depends.begin();
- di != depends.end(); ++di) {
- if (di->IsLink()) {
- this->FollowLinkDepends(*di, linked);
+ for (cmTargetDepend const& di : depends) {
+ if (di.IsLink()) {
+ this->FollowLinkDepends(di, linked);
}
}
}
@@ -293,15 +387,10 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends()
if (!this->cmGlobalGenerator::ComputeTargetDepends()) {
return false;
}
- std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
- for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
- std::vector<cmLocalGenerator*>& gen = it->second;
- for (std::vector<cmLocalGenerator*>::iterator i = gen.begin();
- i != gen.end(); ++i) {
- std::vector<cmGeneratorTarget*> targets = (*i)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- this->ComputeVSTargetDepends(*ti);
+ for (auto const& it : this->ProjectMap) {
+ for (const cmLocalGenerator* i : it.second) {
+ for (cmGeneratorTarget* ti : i->GetGeneratorTargets()) {
+ this->ComputeVSTargetDepends(ti);
}
}
}
@@ -351,22 +440,18 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(
// due to behavior (2), but they do not really need to.
std::set<cmGeneratorTarget const*> linkDepends;
if (target->GetType() != cmStateEnums::STATIC_LIBRARY) {
- for (TargetDependSet::const_iterator di = depends.begin();
- di != depends.end(); ++di) {
- cmTargetDepend dep = *di;
- if (dep.IsLink()) {
- this->FollowLinkDepends(*di, linkDepends);
+ for (cmTargetDepend const& di : depends) {
+ if (di.IsLink()) {
+ this->FollowLinkDepends(di, linkDepends);
}
}
}
// Collect explicit util dependencies (add_dependencies).
std::set<cmGeneratorTarget const*> utilDepends;
- for (TargetDependSet::const_iterator di = depends.begin();
- di != depends.end(); ++di) {
- cmTargetDepend dep = *di;
- if (dep.IsUtil()) {
- this->FollowLinkDepends(*di, utilDepends);
+ for (cmTargetDepend const& di : depends) {
+ if (di.IsUtil()) {
+ this->FollowLinkDepends(di, utilDepends);
}
}
@@ -378,16 +463,12 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(
}
// Emit link dependencies.
- for (std::set<cmGeneratorTarget const*>::iterator di = linkDepends.begin();
- di != linkDepends.end(); ++di) {
- cmGeneratorTarget const* dep = *di;
+ for (cmGeneratorTarget const* dep : linkDepends) {
vsTargetDepend.insert(dep->GetName());
}
// Emit util dependencies. Possibly use intermediate targets.
- for (std::set<cmGeneratorTarget const*>::iterator di = utilDepends.begin();
- di != utilDepends.end(); ++di) {
- cmGeneratorTarget const* dgt = *di;
+ for (cmGeneratorTarget const* dgt : utilDepends) {
if (allowLinkable || !VSLinkable(dgt) || linked.count(dgt)) {
// Direct dependency allowed.
vsTargetDepend.insert(dgt->GetName());
@@ -404,8 +485,8 @@ bool cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf)
// Visual Studio generators know how to lookup their build tool
// directly instead of needing a helper module to do it, so we
// do not actually need to put CMAKE_MAKE_PROGRAM into the cache.
- if (cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
- mf->AddDefinition("CMAKE_MAKE_PROGRAM", this->GetVSMakeProgram().c_str());
+ if (cmIsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
+ mf->AddDefinition("CMAKE_MAKE_PROGRAM", this->GetVSMakeProgram());
}
return true;
}
@@ -413,7 +494,7 @@ bool cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf)
std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(
cmGeneratorTarget const* target)
{
- UtilityDependsMap::iterator i = this->UtilityDepends.find(target);
+ auto i = this->UtilityDepends.find(target);
if (i == this->UtilityDepends.end()) {
std::string name = this->WriteUtilityDepend(target);
UtilityDependsMap::value_type entry(target, name);
@@ -432,7 +513,7 @@ std::string cmGlobalVisualStudioGenerator::GetStartupProjectName(
return startup;
} else {
root->GetMakefile()->IssueMessage(
- cmake::AUTHOR_WARNING,
+ MessageType::AUTHOR_WARNING,
"Directory property VS_STARTUP_PROJECT specifies target "
"'" +
startup + "' that does not exist. Ignoring.");
@@ -470,24 +551,24 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
if (ERROR_SUCCESS == result) {
// Iterate the subkeys and look for the values of interest in each subkey:
wchar_t subkeyname[256];
- DWORD cch_subkeyname = sizeof(subkeyname) * sizeof(subkeyname[0]);
+ DWORD cch_subkeyname = cm::size(subkeyname);
wchar_t keyclass[256];
- DWORD cch_keyclass = sizeof(keyclass) * sizeof(keyclass[0]);
+ DWORD cch_keyclass = cm::size(keyclass);
FILETIME lastWriteTime;
lastWriteTime.dwHighDateTime = 0;
lastWriteTime.dwLowDateTime = 0;
- while (ERROR_SUCCESS == RegEnumKeyExW(hkey, index, subkeyname,
- &cch_subkeyname, 0, keyclass,
- &cch_keyclass, &lastWriteTime)) {
+ while (ERROR_SUCCESS ==
+ RegEnumKeyExW(hkey, index, subkeyname, &cch_subkeyname, 0, keyclass,
+ &cch_keyclass, &lastWriteTime)) {
// Open the subkey and query the values of interest:
HKEY hsubkey = NULL;
result = RegOpenKeyExW(hkey, subkeyname, 0, KEY_READ, &hsubkey);
if (ERROR_SUCCESS == result) {
DWORD valueType = REG_SZ;
wchar_t data1[256];
- DWORD cch_data1 = sizeof(data1) * sizeof(data1[0]);
- RegQueryValueExW(hsubkey, L"Path", 0, &valueType, (LPBYTE)&data1[0],
+ DWORD cch_data1 = sizeof(data1);
+ RegQueryValueExW(hsubkey, L"Path", 0, &valueType, (LPBYTE)data1,
&cch_data1);
DWORD data2 = 0;
@@ -535,8 +616,8 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
}
++index;
- cch_subkeyname = sizeof(subkeyname) * sizeof(subkeyname[0]);
- cch_keyclass = sizeof(keyclass) * sizeof(keyclass[0]);
+ cch_subkeyname = cm::size(subkeyname);
+ cch_keyclass = cm::size(keyclass);
lastWriteTime.dwHighDateTime = 0;
lastWriteTime.dwLowDateTime = 0;
}
@@ -551,9 +632,7 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
// follow the expected naming scheme. Expected naming scheme is that
// the subkeys of OtherProjects7 is 0 to n-1, so it's ok to use "n"
// as the name of the next subkey.
- std::ostringstream ossNext;
- ossNext << index;
- nextAvailableSubKeyName = ossNext.str();
+ nextAvailableSubKeyName = std::to_string(index);
keyname = regKeyBase + "\\RecordingProject7";
hkey = NULL;
@@ -563,9 +642,8 @@ bool IsVisualStudioMacrosFileRegistered(const std::string& macrosFile,
if (ERROR_SUCCESS == result) {
DWORD valueType = REG_SZ;
wchar_t data1[256];
- DWORD cch_data1 = sizeof(data1) * sizeof(data1[0]);
- RegQueryValueExW(hkey, L"Path", 0, &valueType, (LPBYTE)&data1[0],
- &cch_data1);
+ DWORD cch_data1 = sizeof(data1);
+ RegQueryValueExW(hkey, L"Path", 0, &valueType, (LPBYTE)data1, &cch_data1);
DWORD data2 = 0;
DWORD cch_data2 = sizeof(data2);
@@ -691,7 +769,7 @@ void RegisterVisualStudioMacros(const std::string& macrosFile,
<< "CMake needs to register Visual Studio macros when its macros"
<< " file is updated or when it detects that its current macros file"
<< " is no longer registered with Visual Studio." << std::endl;
- cmSystemTools::Message(oss.str().c_str(), "Warning");
+ cmSystemTools::Message(oss.str(), "Warning");
// Count them again now that the warning is over. In the case of a GUI
// warning, the user may have gone to close Visual Studio and then come
@@ -722,7 +800,6 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(
cmGeneratorTarget const* gt)
{
// check to see if this is a fortran build
- std::set<std::string> languages;
{
// Issue diagnostic if the source files depend on the config.
std::vector<cmSourceFile*> sources;
@@ -730,65 +807,25 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(
return false;
}
}
+
// If there's only one source language, Fortran has to be used
// in order for the sources to compile.
- // Note: Via linker propagation, LINKER_LANGUAGE could become CXX in
- // this situation and mismatch from the actual language of the linker.
- gt->GetLanguages(languages, "");
- if (languages.size() == 1) {
- if (*languages.begin() == "Fortran") {
- return true;
- }
- }
-
- // In the case of mixed object files or sources mixed with objects,
- // decide the language based on the value of LINKER_LANGUAGE.
- // This will not make it possible to mix source files of different
- // languages, but object libraries will be linked together in the
- // same fashion as other generators do.
- if (gt->GetLinkerLanguage("") == "Fortran") {
- return true;
- }
-
- return false;
-}
-
-bool cmGlobalVisualStudioGenerator::TargetIsCSharpOnly(
- cmGeneratorTarget const* gt)
-{
- // check to see if this is a C# build
std::set<std::string> languages;
- {
- // Issue diagnostic if the source files depend on the config.
- std::vector<cmSourceFile*> sources;
- if (!gt->GetConfigCommonSourceFiles(sources)) {
- return false;
- }
- // Only "real" targets are allowed to be C# targets.
- if (gt->Target->GetType() > cmStateEnums::OBJECT_LIBRARY) {
- return false;
- }
- }
gt->GetLanguages(languages, "");
- if (languages.size() == 1) {
- if (*languages.begin() == "CSharp") {
- return true;
- }
+ // Consider an explicit linker language property, but *not* the
+ // computed linker language that may depend on linked targets.
+ // This allows the project to control the language choice in
+ // a target with none of its own sources, e.g. when also using
+ // object libraries.
+ const char* linkLang = gt->GetProperty("LINKER_LANGUAGE");
+ if (linkLang && *linkLang) {
+ languages.insert(linkLang);
}
- return false;
-}
-bool cmGlobalVisualStudioGenerator::TargetCanBeReferenced(
- cmGeneratorTarget const* gt)
-{
- if (this->TargetIsCSharpOnly(gt)) {
- return true;
- }
- if (gt->GetType() != cmStateEnums::SHARED_LIBRARY &&
- gt->GetType() != cmStateEnums::EXECUTABLE) {
- return false;
- }
- return true;
+ // Intel Fortran .vfproj files do support the resource compiler.
+ languages.erase("RC");
+
+ return languages.size() == 1 && *languages.begin() == "Fortran";
}
bool cmGlobalVisualStudioGenerator::TargetCompare::operator()(
@@ -817,9 +854,8 @@ cmGlobalVisualStudioGenerator::OrderedTargetDependSet::OrderedTargetDependSet(
TargetSet const& targets, std::string const& first)
: derived(TargetCompare(first))
{
- for (TargetSet::const_iterator it = targets.begin(); it != targets.end();
- ++it) {
- this->insert(*it);
+ for (cmGeneratorTarget const* it : targets) {
+ this->insert(it);
}
}
@@ -853,56 +889,41 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
std::vector<cmSourceFile const*> objectSources;
gt->GetObjectSources(objectSources, configName);
std::map<cmSourceFile const*, std::string> mapping;
- for (std::vector<cmSourceFile const*>::const_iterator it =
- objectSources.begin();
- it != objectSources.end(); ++it) {
- mapping[*it];
+ for (cmSourceFile const* it : objectSources) {
+ mapping[it];
}
gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
std::string obj_dir = gt->ObjectDirectory;
std::string cmakeCommand = cmSystemTools::GetCMakeCommand();
- cmSystemTools::ConvertToWindowsExtendedPath(cmakeCommand);
- cmCustomCommandLine cmdl;
- cmdl.push_back(cmakeCommand);
- cmdl.push_back("-E");
- cmdl.push_back("__create_def");
- cmdl.push_back(mdi->DefFile);
std::string obj_dir_expanded = obj_dir;
cmSystemTools::ReplaceString(obj_dir_expanded, this->GetCMakeCFGIntDir(),
configName.c_str());
cmSystemTools::MakeDirectory(obj_dir_expanded);
std::string const objs_file = obj_dir_expanded + "/objects.txt";
- cmdl.push_back(objs_file);
cmGeneratedFileStream fout(objs_file.c_str());
if (!fout) {
- cmSystemTools::Error("could not open ", objs_file.c_str());
+ cmSystemTools::Error("could not open " + objs_file);
return;
}
if (mdi->WindowsExportAllSymbols) {
std::vector<std::string> objs;
- for (std::vector<cmSourceFile const*>::const_iterator it =
- objectSources.begin();
- it != objectSources.end(); ++it) {
+ for (cmSourceFile const* it : objectSources) {
// Find the object file name corresponding to this source file.
- std::map<cmSourceFile const*, std::string>::const_iterator map_it =
- mapping.find(*it);
// It must exist because we populated the mapping just above.
- assert(!map_it->second.empty());
- std::string objFile = obj_dir + map_it->second;
+ const auto& v = mapping[it];
+ assert(!v.empty());
+ std::string objFile = obj_dir + v;
objs.push_back(objFile);
}
std::vector<cmSourceFile const*> externalObjectSources;
gt->GetExternalObjects(externalObjectSources, configName);
- for (std::vector<cmSourceFile const*>::const_iterator it =
- externalObjectSources.begin();
- it != externalObjectSources.end(); ++it) {
- objs.push_back((*it)->GetFullPath());
+ for (cmSourceFile const* it : externalObjectSources) {
+ objs.push_back(it->GetFullPath());
}
- for (std::vector<std::string>::iterator it = objs.begin();
- it != objs.end(); ++it) {
- std::string objFile = *it;
+ for (std::string const& it : objs) {
+ std::string objFile = it;
// replace $(ConfigurationName) in the object names
cmSystemTools::ReplaceString(objFile, this->GetCMakeCFGIntDir(),
configName.c_str());
@@ -912,15 +933,44 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
}
}
- for (std::vector<cmSourceFile const*>::const_iterator i =
- mdi->Sources.begin();
- i != mdi->Sources.end(); ++i) {
- fout << (*i)->GetFullPath() << "\n";
+ for (cmSourceFile const* i : mdi->Sources) {
+ fout << i->GetFullPath() << "\n";
}
- cmCustomCommandLines commandLines;
- commandLines.push_back(cmdl);
+ cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
+ { cmakeCommand, "-E", "__create_def", mdi->DefFile, objs_file });
cmCustomCommand command(gt->Target->GetMakefile(), outputs, empty, empty,
commandLines, "Auto build dll exports", ".");
commands.push_back(command);
}
+
+static bool OpenSolution(std::string sln)
+{
+ HRESULT comInitialized =
+ CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
+ if (FAILED(comInitialized)) {
+ return false;
+ }
+
+ HINSTANCE hi =
+ ShellExecuteA(NULL, "open", sln.c_str(), NULL, NULL, SW_SHOWNORMAL);
+
+ CoUninitialize();
+
+ return reinterpret_cast<intptr_t>(hi) > 32;
+}
+
+bool cmGlobalVisualStudioGenerator::Open(const std::string& bindir,
+ const std::string& projectName,
+ bool dryRun)
+{
+ std::string sln = bindir + "/" + projectName + ".sln";
+
+ if (dryRun) {
+ return cmSystemTools::FileExists(sln, true);
+ }
+
+ sln = cmSystemTools::ConvertToOutputPath(sln);
+
+ return std::async(std::launch::async, OpenSolution, sln).get();
+}
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 3c43ccdd2..4f2007f75 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmGlobalVisualStudioGenerator_h
#define cmGlobalVisualStudioGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
@@ -32,22 +32,35 @@ public:
/** Known versions of Visual Studio. */
enum VSVersion
{
- VS8 = 80,
VS9 = 90,
VS10 = 100,
VS11 = 110,
VS12 = 120,
/* VS13 = 130 was skipped */
VS14 = 140,
- VS15 = 150
+ VS15 = 150,
+ VS16 = 160
};
- cmGlobalVisualStudioGenerator(cmake* cm);
virtual ~cmGlobalVisualStudioGenerator();
VSVersion GetVersion() const;
void SetVersion(VSVersion v);
+ /** Is the installed VS an Express edition? */
+ bool IsExpressEdition() const { return this->ExpressEdition; }
+
+ void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
+ bool optional) override;
+
+ bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
+
+ /**
+ * Get the name of the target platform (architecture) for which we generate.
+ * The names are as defined by VS, e.g. "Win32", "x64", "Itanium", "ARM".
+ */
+ std::string const& GetPlatformName() const;
+
/**
* Configure CMake's Visual Studio macros file into the user's Visual
* Studio macros directory.
@@ -77,17 +90,11 @@ public:
* Call the ReloadProjects macro if necessary based on
* GetFilesReplacedDuringGenerate results.
*/
- void CallVisualStudioMacro(MacroName m, const char* vsSolutionFile = 0);
+ void CallVisualStudioMacro(MacroName m, const std::string& vsSolutionFile);
// return true if target is fortran only
bool TargetIsFortranOnly(const cmGeneratorTarget* gt);
- // return true if target is C# only
- static bool TargetIsCSharpOnly(cmGeneratorTarget const* gt);
-
- // return true if target can be referenced by C# targets
- bool TargetCanBeReferenced(cmGeneratorTarget const* gt);
-
/** Get the top-level registry key for this VS version. */
std::string GetRegistryBase();
@@ -96,11 +103,20 @@ public:
/** Return true if the generated build tree may contain multiple builds.
i.e. "Can I build Debug and Release in the same tree?" */
- virtual bool IsMultiConfig() const { return true; }
+ bool IsMultiConfig() const override { return true; }
/** Return true if building for Windows CE */
virtual bool TargetsWindowsCE() const { return false; }
+ bool IsIncludeExternalMSProjectSupported() const override { return true; }
+
+ /** Get encoding used by generator for generated source files
+ */
+ codecvt::Encoding GetMakefileEncoding() const override
+ {
+ return codecvt::ANSI;
+ }
+
class TargetSet : public std::set<cmGeneratorTarget const*>
{
};
@@ -118,12 +134,12 @@ public:
};
class OrderedTargetDependSet;
- bool FindMakeProgram(cmMakefile*) CM_OVERRIDE;
+ bool FindMakeProgram(cmMakefile*) override;
- virtual std::string ExpandCFGIntDir(const std::string& str,
- const std::string& config) const;
+ std::string ExpandCFGIntDir(const std::string& str,
+ const std::string& config) const override;
- void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
+ void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;
std::string GetStartupProjectName(cmLocalGenerator const* root) const;
@@ -131,17 +147,25 @@ public:
std::vector<cmCustomCommand>& commands,
std::string const& configName);
+ bool Open(const std::string& bindir, const std::string& projectName,
+ bool dryRun) override;
+
protected:
- virtual void AddExtraIDETargets();
+ cmGlobalVisualStudioGenerator(cmake* cm,
+ std::string const& platformInGeneratorName);
+
+ void AddExtraIDETargets() override;
// Does this VS version link targets to each other if there are
// dependencies in the SLN file? This was done for VS versions
// below 8.
virtual bool VSLinksDependencies() const { return true; }
- virtual const char* GetIDEVersion() = 0;
+ const char* GetIDEVersion() const;
- virtual bool ComputeTargetDepends();
+ void WriteSLNHeader(std::ostream& fout);
+
+ bool ComputeTargetDepends() override;
class VSDependSet : public std::set<std::string>
{
};
@@ -156,16 +180,21 @@ protected:
const std::string&);
virtual std::string WriteUtilityDepend(cmGeneratorTarget const*) = 0;
std::string GetUtilityDepend(const cmGeneratorTarget* target);
- typedef std::map<cmGeneratorTarget const*, std::string> UtilityDependsMap;
+ using UtilityDependsMap = std::map<cmGeneratorTarget const*, std::string>;
UtilityDependsMap UtilityDepends;
protected:
VSVersion Version;
+ bool ExpressEdition;
+
+ std::string GeneratorPlatform;
+ std::string DefaultPlatformName;
+ bool PlatformInGeneratorName = false;
private:
virtual std::string GetVSMakeProgram() = 0;
void PrintCompilerAdvice(std::ostream&, std::string const&,
- const char*) const
+ const char*) const override
{
}
@@ -184,13 +213,12 @@ class cmGlobalVisualStudioGenerator::OrderedTargetDependSet
: public std::multiset<cmTargetDepend,
cmGlobalVisualStudioGenerator::TargetCompare>
{
- typedef std::multiset<cmTargetDepend,
- cmGlobalVisualStudioGenerator::TargetCompare>
- derived;
+ using derived = std::multiset<cmTargetDepend,
+ cmGlobalVisualStudioGenerator::TargetCompare>;
public:
- typedef cmGlobalGenerator::TargetDependSet TargetDependSet;
- typedef cmGlobalVisualStudioGenerator::TargetSet TargetSet;
+ using TargetDependSet = cmGlobalGenerator::TargetDependSet;
+ using TargetSet = cmGlobalVisualStudioGenerator::TargetSet;
OrderedTargetDependSet(TargetDependSet const&, std::string const& first);
OrderedTargetDependSet(TargetSet const&, std::string const& first);
};
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
new file mode 100644
index 000000000..a371633ed
--- /dev/null
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -0,0 +1,522 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmGlobalVisualStudioVersionedGenerator.h"
+
+#include "cmAlgorithms.h"
+#include "cmDocumentationEntry.h"
+#include "cmLocalVisualStudio10Generator.h"
+#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
+#include "cmVSSetupHelper.h"
+#include "cmake.h"
+
+#if defined(_M_ARM64)
+# define HOST_PLATFORM_NAME "ARM64"
+# define HOST_TOOLS_ARCH ""
+#elif defined(_M_ARM)
+# define HOST_PLATFORM_NAME "ARM"
+# define HOST_TOOLS_ARCH ""
+#elif defined(_M_IA64)
+# define HOST_PLATFORM_NAME "Itanium"
+# define HOST_TOOLS_ARCH ""
+#elif defined(_WIN64)
+# define HOST_PLATFORM_NAME "x64"
+# define HOST_TOOLS_ARCH "x64"
+#else
+static bool VSIsWow64()
+{
+ BOOL isWow64 = false;
+ return IsWow64Process(GetCurrentProcess(), &isWow64) && isWow64;
+}
+#endif
+
+static std::string VSHostPlatformName()
+{
+#ifdef HOST_PLATFORM_NAME
+ return HOST_PLATFORM_NAME;
+#else
+ if (VSIsWow64()) {
+ return "x64";
+ } else {
+ return "Win32";
+ }
+#endif
+}
+
+static std::string VSHostArchitecture()
+{
+#ifdef HOST_TOOLS_ARCH
+ return HOST_TOOLS_ARCH;
+#else
+ if (VSIsWow64()) {
+ return "x64";
+ } else {
+ return "x86";
+ }
+#endif
+}
+
+static unsigned int VSVersionToMajor(
+ cmGlobalVisualStudioGenerator::VSVersion v)
+{
+ switch (v) {
+ case cmGlobalVisualStudioGenerator::VS9:
+ return 9;
+ case cmGlobalVisualStudioGenerator::VS10:
+ return 10;
+ case cmGlobalVisualStudioGenerator::VS11:
+ return 11;
+ case cmGlobalVisualStudioGenerator::VS12:
+ return 12;
+ case cmGlobalVisualStudioGenerator::VS14:
+ return 14;
+ case cmGlobalVisualStudioGenerator::VS15:
+ return 15;
+ case cmGlobalVisualStudioGenerator::VS16:
+ return 16;
+ }
+ return 0;
+}
+
+static const char* VSVersionToToolset(
+ cmGlobalVisualStudioGenerator::VSVersion v)
+{
+ switch (v) {
+ case cmGlobalVisualStudioGenerator::VS9:
+ return "v90";
+ case cmGlobalVisualStudioGenerator::VS10:
+ return "v100";
+ case cmGlobalVisualStudioGenerator::VS11:
+ return "v110";
+ case cmGlobalVisualStudioGenerator::VS12:
+ return "v120";
+ case cmGlobalVisualStudioGenerator::VS14:
+ return "v140";
+ case cmGlobalVisualStudioGenerator::VS15:
+ return "v141";
+ case cmGlobalVisualStudioGenerator::VS16:
+ return "v142";
+ }
+ return "";
+}
+
+static const char vs15generatorName[] = "Visual Studio 15 2017";
+
+// Map generator name without year to name with year.
+static const char* cmVS15GenName(const std::string& name, std::string& genName)
+{
+ if (strncmp(name.c_str(), vs15generatorName,
+ sizeof(vs15generatorName) - 6) != 0) {
+ return 0;
+ }
+ const char* p = name.c_str() + sizeof(vs15generatorName) - 6;
+ if (cmHasLiteralPrefix(p, " 2017")) {
+ p += 5;
+ }
+ genName = std::string(vs15generatorName) + p;
+ return p;
+}
+
+class cmGlobalVisualStudioVersionedGenerator::Factory15
+ : public cmGlobalGeneratorFactory
+{
+public:
+ cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
+ cmake* cm) const override
+ {
+ std::string genName;
+ const char* p = cmVS15GenName(name, genName);
+ if (!p) {
+ return 0;
+ }
+ if (!*p) {
+ return new cmGlobalVisualStudioVersionedGenerator(
+ cmGlobalVisualStudioGenerator::VS15, cm, genName, "");
+ }
+ if (*p++ != ' ') {
+ return 0;
+ }
+ if (strcmp(p, "Win64") == 0) {
+ return new cmGlobalVisualStudioVersionedGenerator(
+ cmGlobalVisualStudioGenerator::VS15, cm, genName, "x64");
+ }
+ if (strcmp(p, "ARM") == 0) {
+ return new cmGlobalVisualStudioVersionedGenerator(
+ cmGlobalVisualStudioGenerator::VS15, cm, genName, "ARM");
+ }
+ return 0;
+ }
+
+ void GetDocumentation(cmDocumentationEntry& entry) const override
+ {
+ entry.Name = std::string(vs15generatorName) + " [arch]";
+ entry.Brief = "Generates Visual Studio 2017 project files. "
+ "Optional [arch] can be \"Win64\" or \"ARM\".";
+ }
+
+ std::vector<std::string> GetGeneratorNames() const override
+ {
+ std::vector<std::string> names;
+ names.push_back(vs15generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ std::vector<std::string> names;
+ names.push_back(vs15generatorName + std::string(" ARM"));
+ names.push_back(vs15generatorName + std::string(" Win64"));
+ return names;
+ }
+
+ bool SupportsToolset() const override { return true; }
+ bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("ARM");
+ platforms.emplace_back("ARM64");
+ return platforms;
+ }
+
+ std::string GetDefaultPlatformName() const override { return "Win32"; }
+};
+
+cmGlobalGeneratorFactory*
+cmGlobalVisualStudioVersionedGenerator::NewFactory15()
+{
+ return new Factory15;
+}
+
+static const char vs16generatorName[] = "Visual Studio 16 2019";
+
+// Map generator name without year to name with year.
+static const char* cmVS16GenName(const std::string& name, std::string& genName)
+{
+ if (strncmp(name.c_str(), vs16generatorName,
+ sizeof(vs16generatorName) - 6) != 0) {
+ return 0;
+ }
+ const char* p = name.c_str() + sizeof(vs16generatorName) - 6;
+ if (cmHasLiteralPrefix(p, " 2019")) {
+ p += 5;
+ }
+ genName = std::string(vs16generatorName) + p;
+ return p;
+}
+
+class cmGlobalVisualStudioVersionedGenerator::Factory16
+ : public cmGlobalGeneratorFactory
+{
+public:
+ cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
+ cmake* cm) const override
+ {
+ std::string genName;
+ const char* p = cmVS16GenName(name, genName);
+ if (!p) {
+ return 0;
+ }
+ if (!*p) {
+ return new cmGlobalVisualStudioVersionedGenerator(
+ cmGlobalVisualStudioGenerator::VS16, cm, genName, "");
+ }
+ return 0;
+ }
+
+ void GetDocumentation(cmDocumentationEntry& entry) const override
+ {
+ entry.Name = std::string(vs16generatorName);
+ entry.Brief = "Generates Visual Studio 2019 project files. "
+ "Use -A option to specify architecture.";
+ }
+
+ std::vector<std::string> GetGeneratorNames() const override
+ {
+ std::vector<std::string> names;
+ names.push_back(vs16generatorName);
+ return names;
+ }
+
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ return std::vector<std::string>();
+ }
+
+ bool SupportsToolset() const override { return true; }
+ bool SupportsPlatform() const override { return true; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ std::vector<std::string> platforms;
+ platforms.emplace_back("x64");
+ platforms.emplace_back("Win32");
+ platforms.emplace_back("ARM");
+ platforms.emplace_back("ARM64");
+ return platforms;
+ }
+
+ std::string GetDefaultPlatformName() const override
+ {
+ return VSHostPlatformName();
+ }
+};
+
+cmGlobalGeneratorFactory*
+cmGlobalVisualStudioVersionedGenerator::NewFactory16()
+{
+ return new Factory16;
+}
+
+cmGlobalVisualStudioVersionedGenerator::cmGlobalVisualStudioVersionedGenerator(
+ VSVersion version, cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName)
+ : cmGlobalVisualStudio14Generator(cm, name, platformInGeneratorName)
+ , vsSetupAPIHelper(VSVersionToMajor(version))
+{
+ this->Version = version;
+ this->ExpressEdition = false;
+ this->DefaultPlatformToolset = VSVersionToToolset(this->Version);
+ this->DefaultCLFlagTableName = VSVersionToToolset(this->Version);
+ this->DefaultCSharpFlagTableName = VSVersionToToolset(this->Version);
+ this->DefaultLinkFlagTableName = VSVersionToToolset(this->Version);
+ if (this->Version >= cmGlobalVisualStudioGenerator::VS16) {
+ this->DefaultPlatformName = VSHostPlatformName();
+ this->DefaultPlatformToolsetHostArchitecture = VSHostArchitecture();
+ }
+}
+
+bool cmGlobalVisualStudioVersionedGenerator::MatchesGeneratorName(
+ const std::string& name) const
+{
+ std::string genName;
+ switch (this->Version) {
+ case cmGlobalVisualStudioGenerator::VS9:
+ case cmGlobalVisualStudioGenerator::VS10:
+ case cmGlobalVisualStudioGenerator::VS11:
+ case cmGlobalVisualStudioGenerator::VS12:
+ case cmGlobalVisualStudioGenerator::VS14:
+ break;
+ case cmGlobalVisualStudioGenerator::VS15:
+ if (cmVS15GenName(name, genName)) {
+ return genName == this->GetName();
+ }
+ break;
+ case cmGlobalVisualStudioGenerator::VS16:
+ if (cmVS16GenName(name, genName)) {
+ return genName == this->GetName();
+ }
+ break;
+ }
+ return false;
+}
+
+bool cmGlobalVisualStudioVersionedGenerator::SetGeneratorInstance(
+ std::string const& i, cmMakefile* mf)
+{
+ if (!i.empty()) {
+ if (!this->vsSetupAPIHelper.SetVSInstance(i)) {
+ std::ostringstream e;
+ /* clang-format off */
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "could not find specified instance of Visual Studio:\n"
+ " " << i;
+ /* clang-format on */
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return false;
+ }
+ }
+
+ std::string vsInstance;
+ if (!this->vsSetupAPIHelper.GetVSInstanceInfo(vsInstance)) {
+ std::ostringstream e;
+ /* clang-format off */
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "could not find any instance of Visual Studio.\n";
+ /* clang-format on */
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return false;
+ }
+
+ // Save the selected instance persistently.
+ std::string genInstance = mf->GetSafeDefinition("CMAKE_GENERATOR_INSTANCE");
+ if (vsInstance != genInstance) {
+ this->CMakeInstance->AddCacheEntry(
+ "CMAKE_GENERATOR_INSTANCE", vsInstance.c_str(),
+ "Generator instance identifier.", cmStateEnums::INTERNAL);
+ }
+
+ return true;
+}
+
+bool cmGlobalVisualStudioVersionedGenerator::GetVSInstance(
+ std::string& dir) const
+{
+ return vsSetupAPIHelper.GetVSInstanceInfo(dir);
+}
+
+bool cmGlobalVisualStudioVersionedGenerator::IsDefaultToolset(
+ const std::string& version) const
+{
+ if (version.empty()) {
+ return true;
+ }
+
+ std::string vcToolsetVersion;
+ if (this->vsSetupAPIHelper.GetVCToolsetVersion(vcToolsetVersion)) {
+
+ cmsys::RegularExpression regex("[0-9][0-9]\\.[0-9]+");
+ if (regex.find(version) && regex.find(vcToolsetVersion)) {
+ const auto majorMinorEnd = vcToolsetVersion.find('.', 3);
+ const auto majorMinor = vcToolsetVersion.substr(0, majorMinorEnd);
+ return version == majorMinor;
+ }
+ }
+
+ return false;
+}
+
+std::string cmGlobalVisualStudioVersionedGenerator::GetAuxiliaryToolset() const
+{
+ const char* version = this->GetPlatformToolsetVersion();
+ if (version) {
+ std::string instancePath;
+ GetVSInstance(instancePath);
+ std::string toolsetDir = instancePath + "/VC/Auxiliary/Build";
+ char sep = '/';
+ if (cmSystemTools::VersionCompareGreaterEq(version, "14.20")) {
+ std::string toolsetDot =
+ cmStrCat(toolsetDir, '.', version, "/Microsoft.VCToolsVersion.",
+ version, ".props");
+ if (cmSystemTools::PathExists(toolsetDot)) {
+ sep = '.';
+ }
+ }
+ std::string toolsetPath =
+ cmStrCat(toolsetDir, sep, version, "/Microsoft.VCToolsVersion.", version,
+ ".props");
+ cmSystemTools::ConvertToUnixSlashes(toolsetPath);
+ return toolsetPath;
+ }
+ return {};
+}
+
+bool cmGlobalVisualStudioVersionedGenerator::InitializeWindows(cmMakefile* mf)
+{
+ // If the Win 8.1 SDK is installed then we can select a SDK matching
+ // the target Windows version.
+ if (this->IsWin81SDKInstalled()) {
+ // VS 2019 does not default to 8.1 so specify it explicitly when needed.
+ if (this->Version >= cmGlobalVisualStudioGenerator::VS16 &&
+ !cmSystemTools::VersionCompareGreater(this->SystemVersion, "8.1")) {
+ this->SetWindowsTargetPlatformVersion("8.1", mf);
+ return true;
+ }
+ return cmGlobalVisualStudio14Generator::InitializeWindows(mf);
+ }
+ // Otherwise we must choose a Win 10 SDK even if we are not targeting
+ // Windows 10.
+ return this->SelectWindows10SDK(mf, false);
+}
+
+bool cmGlobalVisualStudioVersionedGenerator::SelectWindowsStoreToolset(
+ std::string& toolset) const
+{
+ if (cmHasLiteralPrefix(this->SystemVersion, "10.0")) {
+ if (this->IsWindowsStoreToolsetInstalled() &&
+ this->IsWindowsDesktopToolsetInstalled()) {
+ toolset = VSVersionToToolset(this->Version);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ return this->cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset(
+ toolset);
+}
+
+bool cmGlobalVisualStudioVersionedGenerator::IsWindowsDesktopToolsetInstalled()
+ const
+{
+ return vsSetupAPIHelper.IsVSInstalled();
+}
+
+bool cmGlobalVisualStudioVersionedGenerator::IsWindowsStoreToolsetInstalled()
+ const
+{
+ return vsSetupAPIHelper.IsWin10SDKInstalled();
+}
+
+bool cmGlobalVisualStudioVersionedGenerator::IsWin81SDKInstalled() const
+{
+ // Does the VS installer tool know about one?
+ if (vsSetupAPIHelper.IsWin81SDKInstalled()) {
+ return true;
+ }
+
+ // Does the registry know about one (e.g. from VS 2015)?
+ std::string win81Root;
+ if (cmSystemTools::ReadRegistryValue(
+ "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
+ "Windows Kits\\Installed Roots;KitsRoot81",
+ win81Root, cmSystemTools::KeyWOW64_32) ||
+ cmSystemTools::ReadRegistryValue(
+ "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\"
+ "Windows Kits\\Installed Roots;KitsRoot81",
+ win81Root, cmSystemTools::KeyWOW64_32)) {
+ return cmSystemTools::FileExists(win81Root + "/include/um/windows.h",
+ true);
+ }
+ return false;
+}
+
+std::string cmGlobalVisualStudioVersionedGenerator::GetWindows10SDKMaxVersion()
+ const
+{
+ return std::string();
+}
+
+std::string cmGlobalVisualStudioVersionedGenerator::FindMSBuildCommand()
+{
+ std::string msbuild;
+
+ // Ask Visual Studio Installer tool.
+ std::string vs;
+ if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) {
+ msbuild = vs + "/MSBuild/Current/Bin/MSBuild.exe";
+ if (cmSystemTools::FileExists(msbuild)) {
+ return msbuild;
+ }
+ msbuild = vs + "/MSBuild/15.0/Bin/MSBuild.exe";
+ if (cmSystemTools::FileExists(msbuild)) {
+ return msbuild;
+ }
+ }
+
+ msbuild = "MSBuild.exe";
+ return msbuild;
+}
+
+std::string cmGlobalVisualStudioVersionedGenerator::FindDevEnvCommand()
+{
+ std::string devenv;
+
+ // Ask Visual Studio Installer tool.
+ std::string vs;
+ if (vsSetupAPIHelper.GetVSInstanceInfo(vs)) {
+ devenv = vs + "/Common7/IDE/devenv.com";
+ if (cmSystemTools::FileExists(devenv)) {
+ return devenv;
+ }
+ }
+
+ devenv = "devenv.com";
+ return devenv;
+}
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h
new file mode 100644
index 000000000..466816ba8
--- /dev/null
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.h
@@ -0,0 +1,65 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmGlobalVisualStudioVersionedGenerator_h
+#define cmGlobalVisualStudioVersionedGenerator_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <iosfwd>
+#include <string>
+
+#include "cmGlobalVisualStudio14Generator.h"
+#include "cmVSSetupHelper.h"
+
+class cmGlobalGeneratorFactory;
+class cmake;
+
+/** \class cmGlobalVisualStudioVersionedGenerator */
+class cmGlobalVisualStudioVersionedGenerator
+ : public cmGlobalVisualStudio14Generator
+{
+public:
+ static cmGlobalGeneratorFactory* NewFactory15();
+ static cmGlobalGeneratorFactory* NewFactory16();
+
+ bool MatchesGeneratorName(const std::string& name) const override;
+
+ bool SetGeneratorInstance(std::string const& i, cmMakefile* mf) override;
+
+ bool GetVSInstance(std::string& dir) const;
+
+ bool IsDefaultToolset(const std::string& version) const override;
+ std::string GetAuxiliaryToolset() const override;
+
+protected:
+ cmGlobalVisualStudioVersionedGenerator(
+ VSVersion version, cmake* cm, const std::string& name,
+ std::string const& platformInGeneratorName);
+
+ bool InitializeWindows(cmMakefile* mf) override;
+ bool SelectWindowsStoreToolset(std::string& toolset) const override;
+
+ // Used to verify that the Desktop toolset for the current generator is
+ // installed on the machine.
+ bool IsWindowsDesktopToolsetInstalled() const override;
+
+ // These aren't virtual because we need to check if the selected version
+ // of the toolset is installed
+ bool IsWindowsStoreToolsetInstalled() const;
+
+ // Check for a Win 8 SDK known to the registry or VS installer tool.
+ bool IsWin81SDKInstalled() const;
+
+ std::string GetWindows10SDKMaxVersion() const override;
+
+ std::string FindMSBuildCommand() override;
+ std::string FindDevEnvCommand() override;
+
+private:
+ class Factory15;
+ friend class Factory15;
+ class Factory16;
+ friend class Factory16;
+ mutable cmVSSetupAPIHelper vsSetupAPIHelper;
+};
+#endif
diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx
index 94cdb3848..308ddda73 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.cxx
+++ b/Source/cmGlobalWatcomWMakeGenerator.cxx
@@ -2,7 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalWatcomWMakeGenerator.h"
+#include <ostream>
+
#include "cmDocumentationEntry.h"
+#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmState.h"
#include "cmake.h"
@@ -47,3 +50,32 @@ void cmGlobalWatcomWMakeGenerator::GetDocumentation(
entry.Name = cmGlobalWatcomWMakeGenerator::GetActualName();
entry.Brief = "Generates Watcom WMake makefiles.";
}
+
+std::vector<cmGlobalGenerator::GeneratedMakeCommand>
+cmGlobalWatcomWMakeGenerator::GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int /*jobs*/, bool verbose,
+ std::vector<std::string> const& makeOptions)
+{
+ return this->cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
+ makeProgram, projectName, projectDir, targetNames, config, fast,
+ cmake::NO_BUILD_PARALLEL_LEVEL, verbose, makeOptions);
+}
+
+void cmGlobalWatcomWMakeGenerator::PrintBuildCommandAdvice(std::ostream& os,
+ int jobs) const
+{
+ if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
+ // wmake does not support parallel build level
+
+ /* clang-format off */
+ os <<
+ "Warning: Watcom's WMake does not support parallel builds. "
+ "Ignoring parallel build command line option.\n";
+ /* clang-format on */
+ }
+
+ this->cmGlobalUnixMakefileGenerator3::PrintBuildCommandAdvice(
+ os, cmake::NO_BUILD_PARALLEL_LEVEL);
+}
diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h
index b2d6d5d71..64ace1359 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.h
+++ b/Source/cmGlobalWatcomWMakeGenerator.h
@@ -3,14 +3,15 @@
#ifndef cmGlobalWatcomWMakeGenerator_h
#define cmGlobalWatcomWMakeGenerator_h
-#include "cmConfigure.h"
-
-#include "cmGlobalGeneratorFactory.h"
-#include "cmGlobalUnixMakefileGenerator3.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <iosfwd>
#include <string>
#include <vector>
+#include "cmGlobalGeneratorFactory.h"
+#include "cmGlobalUnixMakefileGenerator3.h"
+
class cmMakefile;
class cmake;
struct cmDocumentationEntry;
@@ -28,8 +29,8 @@ public:
{
return new cmGlobalGeneratorSimpleFactory<cmGlobalWatcomWMakeGenerator>();
}
- ///! Get the name for the generator.
- std::string GetName() const CM_OVERRIDE
+ //! Get the name for the generator.
+ std::string GetName() const override
{
return cmGlobalWatcomWMakeGenerator::GetActualName();
}
@@ -43,10 +44,20 @@ public:
* extension, pthreads, byte order etc.
*/
void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
- bool optional) CM_OVERRIDE;
+ bool optional) override;
+
+ bool AllowNotParallel() const override { return false; }
+ bool AllowDeleteOnError() const override { return false; }
+
+protected:
+ std::vector<GeneratedMakeCommand> GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions =
+ std::vector<std::string>()) override;
- bool AllowNotParallel() const CM_OVERRIDE { return false; }
- bool AllowDeleteOnError() const CM_OVERRIDE { return false; }
+ void PrintBuildCommandAdvice(std::ostream& os, int jobs) const override;
};
#endif
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 903796123..3002b2a68 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2,15 +2,21 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalXCodeGenerator.h"
-#include "cmsys/RegularExpression.hxx"
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
+#include <cstring>
#include <iomanip>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
+#include <cm/memory>
+
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
+#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
+#include "cmCustomCommandLines.h"
#include "cmDocumentationEntry.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
@@ -19,6 +25,7 @@
#include "cmLocalGenerator.h"
#include "cmLocalXCodeGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmOutputConverter.h"
#include "cmSourceFile.h"
#include "cmSourceGroup.h"
@@ -29,13 +36,17 @@
#include "cmXCode21Object.h"
#include "cmXCodeObject.h"
#include "cmXCodeScheme.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
struct cmLinkImplementation;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmXMLParser.h"
+#if !defined(CMAKE_BOOTSTRAP) && defined(__APPLE__)
+# define HAVE_APPLICATION_SERVICES
+# include <ApplicationServices/ApplicationServices.h>
+#endif
+
+#if !defined(CMAKE_BOOTSTRAP)
+# include "cmXMLParser.h"
// parse the xml file storing the installed version of Xcode on
// the machine
@@ -46,8 +57,11 @@ public:
: Version("1.5")
{
}
- void StartElement(const std::string&, const char**) { this->Data = ""; }
- void EndElement(const std::string& name)
+ void StartElement(const std::string&, const char**) override
+ {
+ this->Data = "";
+ }
+ void EndElement(const std::string& name) override
{
if (name == "key") {
this->Key = this->Data;
@@ -57,7 +71,7 @@ public:
}
}
}
- void CharacterDataHandler(const char* data, int length)
+ void CharacterDataHandler(const char* data, int length) override
{
this->Data.append(data, length);
}
@@ -79,7 +93,7 @@ class cmGlobalXCodeGenerator::BuildObjectListOrString
public:
BuildObjectListOrString(cmGlobalXCodeGenerator* gen, bool buildObjectList)
: Generator(gen)
- , Group(0)
+ , Group(nullptr)
, Empty(true)
{
if (buildObjectList) {
@@ -107,9 +121,8 @@ public:
{
if (this->Group) {
return this->Group;
- } else {
- return this->Generator->CreateString(this->String);
}
+ return this->Generator->CreateString(this->String);
}
};
@@ -117,20 +130,34 @@ class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory
{
public:
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
- cmake* cm) const CM_OVERRIDE;
+ cmake* cm) const override;
- void GetDocumentation(cmDocumentationEntry& entry) const CM_OVERRIDE
+ void GetDocumentation(cmDocumentationEntry& entry) const override
{
cmGlobalXCodeGenerator::GetDocumentation(entry);
}
- void GetGenerators(std::vector<std::string>& names) const CM_OVERRIDE
+ std::vector<std::string> GetGeneratorNames() const override
{
+ std::vector<std::string> names;
names.push_back(cmGlobalXCodeGenerator::GetActualName());
+ return names;
}
- bool SupportsToolset() const CM_OVERRIDE { return true; }
- bool SupportsPlatform() const CM_OVERRIDE { return false; }
+ std::vector<std::string> GetGeneratorNamesWithPlatform() const override
+ {
+ return std::vector<std::string>();
+ }
+
+ bool SupportsToolset() const override { return true; }
+ bool SupportsPlatform() const override { return false; }
+
+ std::vector<std::string> GetKnownPlatforms() const override
+ {
+ return std::vector<std::string>();
+ }
+
+ std::string GetDefaultPlatformName() const override { return std::string(); }
};
cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(
@@ -140,10 +167,10 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(
this->VersionString = version_string;
this->XcodeVersion = version_number;
- this->RootObject = 0;
- this->MainGroupChildren = 0;
- this->CurrentMakefile = 0;
- this->CurrentLocalGenerator = 0;
+ this->RootObject = nullptr;
+ this->MainGroupChildren = nullptr;
+ this->CurrentMakefile = nullptr;
+ this->CurrentLocalGenerator = nullptr;
this->XcodeBuildCommandInitialized = false;
this->ObjectDirArchDefault = "$(CURRENT_ARCH)";
@@ -160,21 +187,25 @@ cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory()
cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(
const std::string& name, cmake* cm) const
{
- if (name != GetActualName())
- return 0;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+ if (name != GetActualName()) {
+ return nullptr;
+ }
+#if !defined(CMAKE_BOOTSTRAP)
cmXcodeVersionParser parser;
std::string versionFile;
{
std::string out;
- std::string::size_type pos;
- if (cmSystemTools::RunSingleCommand("xcode-select --print-path", &out, 0,
- 0, 0, cmSystemTools::OUTPUT_NONE) &&
- (pos = out.find(".app/"), pos != std::string::npos)) {
- versionFile = out.substr(0, pos + 5) + "Contents/version.plist";
+ bool commandResult = cmSystemTools::RunSingleCommand(
+ "xcode-select --print-path", &out, nullptr, nullptr, nullptr,
+ cmSystemTools::OUTPUT_NONE);
+ if (commandResult) {
+ std::string::size_type pos = out.find(".app/");
+ if (pos != std::string::npos) {
+ versionFile = out.substr(0, pos + 5) + "Contents/version.plist";
+ }
}
}
- if (!versionFile.empty() && cmSystemTools::FileExists(versionFile.c_str())) {
+ if (!versionFile.empty() && cmSystemTools::FileExists(versionFile)) {
parser.ParseFile(versionFile.c_str());
} else if (cmSystemTools::FileExists(
"/Applications/Xcode.app/Contents/version.plist")) {
@@ -190,14 +221,14 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(
sscanf(version_string.c_str(), "%u.%u", &v[0], &v[1]);
unsigned int version_number = 10 * v[0] + v[1];
- if (version_number < 30) {
- cm->IssueMessage(cmake::FATAL_ERROR,
+ if (version_number < 50) {
+ cm->IssueMessage(MessageType::FATAL_ERROR,
"Xcode " + version_string + " not supported.");
- return CM_NULLPTR;
+ return nullptr;
}
- CM_AUTO_PTR<cmGlobalXCodeGenerator> gg(
- new cmGlobalXCodeGenerator(cm, version_string, version_number));
+ auto gg = cm::make_unique<cmGlobalXCodeGenerator>(cm, version_string,
+ version_number);
return gg.release();
#else
std::cerr << "CMake should be built with cmake to use Xcode, "
@@ -211,9 +242,8 @@ bool cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf)
// The Xcode generator knows how to lookup its build tool
// directly instead of needing a helper module to do it, so we
// do not actually need to put CMAKE_MAKE_PROGRAM into the cache.
- if (cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
- mf->AddDefinition("CMAKE_MAKE_PROGRAM",
- this->GetXcodeBuildCommand().c_str());
+ if (cmIsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
+ mf->AddDefinition("CMAKE_MAKE_PROGRAM", this->GetXcodeBuildCommand());
}
return true;
}
@@ -229,16 +259,11 @@ std::string const& cmGlobalXCodeGenerator::GetXcodeBuildCommand()
std::string cmGlobalXCodeGenerator::FindXcodeBuildCommand()
{
- if (this->XcodeVersion >= 40) {
- std::string makeProgram = cmSystemTools::FindProgram("xcodebuild");
- if (makeProgram.empty()) {
- makeProgram = "xcodebuild";
- }
- return makeProgram;
- } else {
- // Use cmakexbuild wrapper to suppress environment dump from output.
- return cmSystemTools::GetCMakeCommand() + "xbuild";
+ std::string makeProgram = cmSystemTools::FindProgram("xcodebuild");
+ if (makeProgram.empty()) {
+ makeProgram = "xcodebuild";
}
+ return makeProgram;
}
bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts,
@@ -254,13 +279,12 @@ bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts,
" " << ts << "\n"
"that was specified.";
/* clang-format on */
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
this->GeneratorToolset = ts;
if (!this->GeneratorToolset.empty()) {
- mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET",
- this->GeneratorToolset.c_str());
+ mf->AddDefinition("CMAKE_XCODE_PLATFORM_TOOLSET", this->GeneratorToolset);
}
return true;
}
@@ -269,7 +293,7 @@ void cmGlobalXCodeGenerator::EnableLanguage(
std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
{
mf->AddDefinition("XCODE", "1");
- mf->AddDefinition("XCODE_VERSION", this->VersionString.c_str());
+ mf->AddDefinition("XCODE_VERSION", this->VersionString);
if (!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) {
mf->AddCacheDefinition(
"CMAKE_CONFIGURATION_TYPES", "Debug;Release;MinSizeRel;RelWithDebInfo",
@@ -283,46 +307,87 @@ void cmGlobalXCodeGenerator::EnableLanguage(
this->ComputeArchitectures(mf);
}
-void cmGlobalXCodeGenerator::GenerateBuildCommand(
- std::vector<std::string>& makeCommand, const std::string& makeProgram,
- const std::string& projectName, const std::string& /*projectDir*/,
- const std::string& targetName, const std::string& config, bool /*fast*/,
- bool /*verbose*/, std::vector<std::string> const& makeOptions)
+bool cmGlobalXCodeGenerator::Open(const std::string& bindir,
+ const std::string& projectName, bool dryRun)
+{
+ bool ret = false;
+
+#ifdef HAVE_APPLICATION_SERVICES
+ std::string url = bindir + "/" + projectName + ".xcodeproj";
+
+ if (dryRun) {
+ return cmSystemTools::FileExists(url, false);
+ }
+
+ CFStringRef cfStr = CFStringCreateWithCString(
+ kCFAllocatorDefault, url.c_str(), kCFStringEncodingUTF8);
+ if (cfStr) {
+ CFURLRef cfUrl = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, cfStr,
+ kCFURLPOSIXPathStyle, true);
+ if (cfUrl) {
+ OSStatus err = LSOpenCFURLRef(cfUrl, nullptr);
+ ret = err == noErr;
+ CFRelease(cfUrl);
+ }
+ CFRelease(cfStr);
+ }
+#endif
+
+ return ret;
+}
+
+std::vector<cmGlobalGenerator::GeneratedMakeCommand>
+cmGlobalXCodeGenerator::GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& /*projectDir*/,
+ std::vector<std::string> const& targetNames, const std::string& config,
+ bool /*fast*/, int jobs, bool /*verbose*/,
+ std::vector<std::string> const& makeOptions)
{
+ GeneratedMakeCommand makeCommand;
// now build the test
- makeCommand.push_back(
+ makeCommand.Add(
this->SelectMakeProgram(makeProgram, this->GetXcodeBuildCommand()));
- makeCommand.push_back("-project");
- std::string projectArg = projectName;
- projectArg += ".xcode";
- projectArg += "proj";
- makeCommand.push_back(projectArg);
-
- bool clean = false;
- std::string realTarget = targetName;
- if (realTarget == "clean") {
- clean = true;
- realTarget = "ALL_BUILD";
+ if (!projectName.empty()) {
+ makeCommand.Add("-project");
+ std::string projectArg = cmStrCat(projectName, ".xcodeproj");
+ makeCommand.Add(projectArg);
}
- if (clean) {
- makeCommand.push_back("clean");
+ if (cmContains(targetNames, "clean")) {
+ makeCommand.Add("clean");
+ makeCommand.Add("-target", "ALL_BUILD");
} else {
- makeCommand.push_back("build");
+ makeCommand.Add("build");
+ if (targetNames.empty() ||
+ ((targetNames.size() == 1) && targetNames.front().empty())) {
+ makeCommand.Add("-target", "ALL_BUILD");
+ } else {
+ for (const auto& tname : targetNames) {
+ if (!tname.empty()) {
+ makeCommand.Add("-target", tname);
+ }
+ }
+ }
}
- makeCommand.push_back("-target");
- if (!realTarget.empty()) {
- makeCommand.push_back(realTarget);
- } else {
- makeCommand.push_back("ALL_BUILD");
+
+ makeCommand.Add("-configuration", (config.empty() ? "Debug" : config));
+
+ if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
+ makeCommand.Add("-jobs");
+ if (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL) {
+ makeCommand.Add(std::to_string(jobs));
+ }
}
- makeCommand.push_back("-configuration");
- makeCommand.push_back(!config.empty() ? config : "Debug");
- makeCommand.insert(makeCommand.end(), makeOptions.begin(),
- makeOptions.end());
+
+ if (this->XcodeVersion >= 70) {
+ makeCommand.Add("-hideShellScriptEnvironment");
+ }
+ makeCommand.Add(makeOptions.begin(), makeOptions.end());
+ return { std::move(makeCommand) };
}
-///! Create a local generator appropriate to this Global Generator
+//! Create a local generator appropriate to this Global Generator
cmLocalGenerator* cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf)
{
return new cmLocalXCodeGenerator(this, mf);
@@ -330,15 +395,45 @@ cmLocalGenerator* cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf)
void cmGlobalXCodeGenerator::AddExtraIDETargets()
{
- std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
// make sure extra targets are added before calling
// the parent generate which will call trace depends
- for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
- cmLocalGenerator* root = it->second[0];
+ for (auto keyVal : this->ProjectMap) {
+ cmLocalGenerator* root = keyVal.second[0];
this->SetGenerationRoot(root);
// add ALL_BUILD, INSTALL, etc
- this->AddExtraTargets(root, it->second);
+ this->AddExtraTargets(root, keyVal.second);
+ }
+}
+
+void cmGlobalXCodeGenerator::ComputeTargetOrder()
+{
+ size_t index = 0;
+ auto const& lgens = this->GetLocalGenerators();
+ for (cmLocalGenerator* lgen : lgens) {
+ auto const& targets = lgen->GetGeneratorTargets();
+ for (cmGeneratorTarget const* gt : targets) {
+ this->ComputeTargetOrder(gt, index);
+ }
+ }
+ assert(index == this->TargetOrderIndex.size());
+}
+
+void cmGlobalXCodeGenerator::ComputeTargetOrder(cmGeneratorTarget const* gt,
+ size_t& index)
+{
+ std::map<cmGeneratorTarget const*, size_t>::value_type value(gt, 0);
+ auto insertion = this->TargetOrderIndex.insert(value);
+ if (!insertion.second) {
+ return;
+ }
+ auto entry = insertion.first;
+
+ auto& deps = this->GetTargetDirectDepends(gt);
+ for (auto& d : deps) {
+ this->ComputeTargetOrder(d, index);
}
+
+ entry->second = index++;
}
void cmGlobalXCodeGenerator::Generate()
@@ -347,12 +442,25 @@ void cmGlobalXCodeGenerator::Generate()
if (cmSystemTools::GetErrorOccuredFlag()) {
return;
}
- std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
- for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
- cmLocalGenerator* root = it->second[0];
+
+ this->ComputeTargetOrder();
+
+ for (auto keyVal : this->ProjectMap) {
+ cmLocalGenerator* root = keyVal.second[0];
+
+ bool generateTopLevelProjectOnly =
+ root->GetMakefile()->IsOn("CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY");
+
+ if (generateTopLevelProjectOnly) {
+ cmStateSnapshot snp = root->GetStateSnapshot();
+ if (snp.GetBuildsystemDirectoryParent().IsValid()) {
+ continue;
+ }
+ }
+
this->SetGenerationRoot(root);
// now create the project
- this->OutputXCodeProject(root, it->second);
+ this->OutputXCodeProject(root, keyVal.second);
}
}
@@ -367,9 +475,9 @@ void cmGlobalXCodeGenerator::SetGenerationRoot(cmLocalGenerator* root)
this->CurrentLocalGenerator->GetCurrentBinaryDirectory(),
this->ProjectOutputDirectoryComponents);
- this->CurrentXCodeHackMakefile = root->GetCurrentBinaryDirectory();
- this->CurrentXCodeHackMakefile += "/CMakeScripts";
- cmSystemTools::MakeDirectory(this->CurrentXCodeHackMakefile.c_str());
+ this->CurrentXCodeHackMakefile =
+ cmStrCat(root->GetCurrentBinaryDirectory(), "/CMakeScripts");
+ cmSystemTools::MakeDirectory(this->CurrentXCodeHackMakefile);
this->CurrentXCodeHackMakefile += "/XCODE_DEPEND_HELPER.make";
}
@@ -378,54 +486,52 @@ std::string cmGlobalXCodeGenerator::PostBuildMakeTarget(
{
std::string target = tName;
std::replace(target.begin(), target.end(), ' ', '_');
- std::string out = "PostBuild." + target;
- out += "." + configName;
+ std::string out = cmStrCat("PostBuild.", target, '.', configName);
return out;
}
#define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK"
+#define OBJECT_LIBRARY_ARTIFACT_DIR std::string()
void cmGlobalXCodeGenerator::AddExtraTargets(
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& gens)
{
cmMakefile* mf = root->GetMakefile();
- // Add ALL_BUILD
- const char* no_working_directory = 0;
+ const char* no_working_directory = nullptr;
+ std::vector<std::string> no_byproducts;
std::vector<std::string> no_depends;
- cmTarget* allbuild =
- mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory,
- "echo", "Build all projects");
+
+ // Add ALL_BUILD
+ cmTarget* allbuild = mf->AddUtilityCommand(
+ "ALL_BUILD", cmCommandOrigin::Generator, true, no_working_directory,
+ no_byproducts, no_depends,
+ cmMakeSingleCommandLine({ "echo", "Build all projects" }));
cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root);
root->AddGeneratorTarget(allBuildGt);
- // Refer to the main build configuration file for easy editing.
- std::string listfile = root->GetCurrentSourceDirectory();
- listfile += "/";
- listfile += "CMakeLists.txt";
- allBuildGt->AddSource(listfile);
-
// Add XCODE depend helper
std::string dir = root->GetCurrentBinaryDirectory();
- cmCustomCommandLine makeHelper;
- makeHelper.push_back("make");
- makeHelper.push_back("-C");
- makeHelper.push_back(dir);
- makeHelper.push_back("-f");
- makeHelper.push_back(this->CurrentXCodeHackMakefile);
- makeHelper.push_back(""); // placeholder, see below
+ cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
+ { "make", "-C", dir, "-f", this->CurrentXCodeHackMakefile,
+ "OBJDIR=$(OBJDIR)", /* placeholder, see below */ "" });
// Add ZERO_CHECK
- bool regenerate = !mf->IsOn("CMAKE_SUPPRESS_REGENERATION");
- if (regenerate) {
+ bool regenerate = !this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION");
+ bool generateTopLevelProjectOnly =
+ mf->IsOn("CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY");
+ bool isTopLevel =
+ !root->GetStateSnapshot().GetBuildsystemDirectoryParent().IsValid();
+ if (regenerate && (isTopLevel || !generateTopLevelProjectOnly)) {
this->CreateReRunCMakeFile(root, gens);
std::string file =
- this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile.c_str());
+ this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile);
cmSystemTools::ReplaceString(file, "\\ ", " ");
- cmTarget* check =
- mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, true, no_depends,
- no_working_directory, "make", "-f", file.c_str());
+ cmTarget* check = mf->AddUtilityCommand(
+ CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmCommandOrigin::Generator, true,
+ no_working_directory, no_byproducts, no_depends,
+ cmMakeSingleCommandLine({ "make", "-f", file }));
cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root);
root->AddGeneratorTarget(checkGt);
@@ -433,25 +539,14 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
// now make the allbuild depend on all the non-utility targets
// in the project
- for (std::vector<cmLocalGenerator*>::iterator i = gens.begin();
- i != gens.end(); ++i) {
- cmLocalGenerator* lg = *i;
- if (this->IsExcluded(root, *i)) {
- continue;
- }
-
- std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); l++) {
- cmGeneratorTarget* target = *l;
-
+ for (auto& gen : gens) {
+ for (auto target : gen->GetGeneratorTargets()) {
if (target->GetType() == cmStateEnums::GLOBAL_TARGET) {
continue;
}
- std::string targetName = target->GetName();
-
- if (regenerate && (targetName != CMAKE_CHECK_BUILD_SYSTEM_TARGET)) {
+ if (regenerate &&
+ (target->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET)) {
target->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
}
@@ -459,33 +554,19 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
// run the depend check makefile as a post build rule
// this will make sure that when the next target is built
// things are up-to-date
- if (target->GetType() == cmStateEnums::OBJECT_LIBRARY ||
- (this->XcodeVersion < 50 &&
- (target->GetType() == cmStateEnums::EXECUTABLE ||
- target->GetType() == cmStateEnums::STATIC_LIBRARY ||
- target->GetType() == cmStateEnums::SHARED_LIBRARY ||
- target->GetType() == cmStateEnums::MODULE_LIBRARY))) {
- makeHelper[makeHelper.size() - 1] = // fill placeholder
+ if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
+ commandLines.front().back() = // fill placeholder
this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)");
- cmCustomCommandLines commandLines;
- commandLines.push_back(makeHelper);
- std::vector<std::string> no_byproducts;
- lg->GetMakefile()->AddCustomCommandToTarget(
+ gen->GetMakefile()->AddCustomCommandToTarget(
target->GetName(), no_byproducts, no_depends, commandLines,
- cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str(), true,
- false, "", false, cmMakefile::AcceptObjectLibraryCommands);
+ cmCustomCommandType::POST_BUILD, "Depend check for xcode",
+ dir.c_str(), true, false, "", "", false,
+ cmObjectLibraryCommands::Accept);
}
- if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
- !target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
+ if (!this->IsExcluded(gens[0], target)) {
allbuild->AddUtility(target->GetName());
}
-
- // Refer to the build configuration file for easy editing.
- listfile = lg->GetCurrentSourceDirectory();
- listfile += "/";
- listfile += "CMakeLists.txt";
- target->AddSource(listfile);
}
}
}
@@ -494,47 +575,60 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
cmLocalGenerator* root, std::vector<cmLocalGenerator*> const& gens)
{
std::vector<std::string> lfiles;
- for (std::vector<cmLocalGenerator*>::const_iterator gi = gens.begin();
- gi != gens.end(); ++gi) {
- std::vector<std::string> const& lf = (*gi)->GetMakefile()->GetListFiles();
- lfiles.insert(lfiles.end(), lf.begin(), lf.end());
+ for (auto gen : gens) {
+ cmAppend(lfiles, gen->GetMakefile()->GetListFiles());
}
// sort the array
- std::sort(lfiles.begin(), lfiles.end(), std::less<std::string>());
- std::vector<std::string>::iterator new_end =
- std::unique(lfiles.begin(), lfiles.end());
- lfiles.erase(new_end, lfiles.end());
- this->CurrentReRunCMakeMakefile = root->GetCurrentBinaryDirectory();
- this->CurrentReRunCMakeMakefile += "/CMakeScripts";
- cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile.c_str());
+ std::sort(lfiles.begin(), lfiles.end());
+ lfiles.erase(std::unique(lfiles.begin(), lfiles.end()), lfiles.end());
+
+ cmake* cm = this->GetCMakeInstance();
+ if (cm->DoWriteGlobVerifyTarget()) {
+ lfiles.emplace_back(cm->GetGlobVerifyStamp());
+ }
+
+ this->CurrentReRunCMakeMakefile =
+ cmStrCat(root->GetCurrentBinaryDirectory(), "/CMakeScripts");
+ cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile);
this->CurrentReRunCMakeMakefile += "/ReRunCMake.make";
- cmGeneratedFileStream makefileStream(
- this->CurrentReRunCMakeMakefile.c_str());
+ cmGeneratedFileStream makefileStream(this->CurrentReRunCMakeMakefile);
makefileStream.SetCopyIfDifferent(true);
makefileStream << "# Generated by CMake, DO NOT EDIT\n\n";
+ makefileStream << "TARGETS:= \n";
makefileStream << "empty:= \n";
makefileStream << "space:= $(empty) $(empty)\n";
makefileStream << "spaceplus:= $(empty)\\ $(empty)\n\n";
- for (std::vector<std::string>::const_iterator i = lfiles.begin();
- i != lfiles.end(); ++i) {
+ for (const auto& lfile : lfiles) {
makefileStream << "TARGETS += $(subst $(space),$(spaceplus),$(wildcard "
- << this->ConvertToRelativeForMake(i->c_str()) << "))\n";
+ << this->ConvertToRelativeForMake(lfile) << "))\n";
}
+ makefileStream << "\n";
- std::string checkCache = root->GetBinaryDirectory();
- checkCache += "/";
- checkCache += cmake::GetCMakeFilesDirectoryPostSlash();
- checkCache += "cmake.check_cache";
+ std::string checkCache =
+ cmStrCat(root->GetBinaryDirectory(), "/CMakeFiles/cmake.check_cache");
- makefileStream << "\n"
- << this->ConvertToRelativeForMake(checkCache.c_str())
+ if (cm->DoWriteGlobVerifyTarget()) {
+ makefileStream << ".NOTPARALLEL:\n\n";
+ makefileStream << ".PHONY: all VERIFY_GLOBS\n\n";
+ makefileStream << "all: VERIFY_GLOBS "
+ << this->ConvertToRelativeForMake(checkCache) << "\n\n";
+ makefileStream << "VERIFY_GLOBS:\n";
+ makefileStream << "\t"
+ << this->ConvertToRelativeForMake(
+ cmSystemTools::GetCMakeCommand())
+ << " -P "
+ << this->ConvertToRelativeForMake(cm->GetGlobVerifyScript())
+ << "\n\n";
+ }
+
+ makefileStream << this->ConvertToRelativeForMake(checkCache)
<< ": $(TARGETS)\n";
makefileStream << "\t"
<< this->ConvertToRelativeForMake(
- cmSystemTools::GetCMakeCommand().c_str())
+ cmSystemTools::GetCMakeCommand())
<< " -H"
<< this->ConvertToRelativeForMake(root->GetSourceDirectory())
<< " -B"
@@ -556,8 +650,8 @@ void cmGlobalXCodeGenerator::SortXCodeObjects()
void cmGlobalXCodeGenerator::ClearXCodeObjects()
{
this->TargetDoneSet.clear();
- for (unsigned int i = 0; i < this->XCodeObjects.size(); ++i) {
- delete this->XCodeObjects[i];
+ for (auto& obj : this->XCodeObjects) {
+ delete obj;
}
this->XCodeObjects.clear();
this->XCodeObjectIDs.clear();
@@ -571,7 +665,7 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects()
void cmGlobalXCodeGenerator::addObject(cmXCodeObject* obj)
{
if (obj->GetType() == cmXCodeObject::OBJECT) {
- std::string id = obj->GetId();
+ const std::string& id = obj->GetId();
// If this is a duplicate id, it's an error:
//
@@ -649,9 +743,58 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFileFromPath(
return buildFile;
}
+class XCodeGeneratorExpressionInterpreter
+ : public cmGeneratorExpressionInterpreter
+{
+public:
+ XCodeGeneratorExpressionInterpreter(cmSourceFile* sourceFile,
+ cmLocalGenerator* localGenerator,
+ cmGeneratorTarget* headTarget,
+ const std::string& lang)
+ : cmGeneratorExpressionInterpreter(
+ localGenerator, "NO-PER-CONFIG-SUPPORT-IN-XCODE", headTarget, lang)
+ , SourceFile(sourceFile)
+ {
+ }
+
+ XCodeGeneratorExpressionInterpreter(
+ XCodeGeneratorExpressionInterpreter const&) = delete;
+ XCodeGeneratorExpressionInterpreter& operator=(
+ XCodeGeneratorExpressionInterpreter const&) = delete;
+
+ using cmGeneratorExpressionInterpreter::Evaluate;
+
+ const std::string& Evaluate(const char* expression,
+ const std::string& property)
+ {
+ const std::string& processed =
+ this->cmGeneratorExpressionInterpreter::Evaluate(expression, property);
+ if (this->CompiledGeneratorExpression->GetHadContextSensitiveCondition()) {
+ std::ostringstream e;
+ /* clang-format off */
+ e <<
+ "Xcode does not support per-config per-source " << property << ":\n"
+ " " << expression << "\n"
+ "specified for source:\n"
+ " " << this->SourceFile->ResolveFullPath() << "\n";
+ /* clang-format on */
+ this->LocalGenerator->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ }
+
+ return processed;
+ }
+
+private:
+ cmSourceFile* SourceFile = nullptr;
+};
+
cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
cmLocalGenerator* lg, cmSourceFile* sf, cmGeneratorTarget* gtgt)
{
+ std::string lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
+
+ XCodeGeneratorExpressionInterpreter genexInterpreter(sf, lg, gtgt, lang);
+
// Add flags from target and source file properties.
std::string flags;
const char* srcfmt = sf->GetProperty("Fortran_FORMAT");
@@ -665,29 +808,30 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
default:
break;
}
- if (const char* cflags = sf->GetProperty("COMPILE_FLAGS")) {
- cmGeneratorExpression ge;
- std::string configName = "NO-PER-CONFIG-SUPPORT-IN-XCODE";
- CM_AUTO_PTR<cmCompiledGeneratorExpression> compiledExpr = ge.Parse(cflags);
- const char* processed = compiledExpr->Evaluate(lg, configName);
- if (compiledExpr->GetHadContextSensitiveCondition()) {
- std::ostringstream e;
- /* clang-format off */
- e <<
- "Xcode does not support per-config per-source COMPILE_FLAGS:\n"
- " " << cflags << "\n"
- "specified for source:\n"
- " " << sf->GetFullPath() << "\n";
- /* clang-format on */
- lg->IssueMessage(cmake::FATAL_ERROR, e.str());
- }
- lg->AppendFlags(flags, processed);
+ const std::string COMPILE_FLAGS("COMPILE_FLAGS");
+ if (const char* cflags = sf->GetProperty(COMPILE_FLAGS)) {
+ lg->AppendFlags(flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS));
+ }
+ const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
+ if (const char* coptions = sf->GetProperty(COMPILE_OPTIONS)) {
+ lg->AppendCompileOptions(
+ flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS));
}
// Add per-source definitions.
BuildObjectListOrString flagsBuild(this, false);
- this->AppendDefines(flagsBuild, sf->GetProperty("COMPILE_DEFINITIONS"),
- true);
+ const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
+ if (const char* compile_defs = sf->GetProperty(COMPILE_DEFINITIONS)) {
+ this->AppendDefines(
+ flagsBuild,
+ genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS).c_str(),
+ true);
+ }
+
+ if (sf->GetPropertyAsBool("SKIP_PRECOMPILE_HEADERS")) {
+ this->AppendDefines(flagsBuild, "CMAKE_SKIP_PRECOMPILE_HEADERS", true);
+ }
+
if (!flagsBuild.IsEmpty()) {
if (!flags.empty()) {
flags += ' ';
@@ -695,10 +839,18 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
flags += flagsBuild.GetString();
}
- std::string lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
+ // Add per-source include directories.
+ std::vector<std::string> includes;
+ const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
+ if (const char* cincludes = sf->GetProperty(INCLUDE_DIRECTORIES)) {
+ lg->AppendIncludeDirectories(
+ includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES),
+ *sf);
+ }
+ lg->AppendFlags(flags, lg->GetIncludeFlags(includes, gtgt, lang, true));
cmXCodeObject* buildFile =
- this->CreateXCodeSourceFileFromPath(sf->GetFullPath(), gtgt, lang, sf);
+ this->CreateXCodeSourceFileFromPath(sf->ResolveFullPath(), gtgt, lang, sf);
cmXCodeObject* settings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
settings->AddAttributeIfNotEmpty("COMPILER_FLAGS",
@@ -724,13 +876,11 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
const char* extraFileAttributes = sf->GetProperty("XCODE_FILE_ATTRIBUTES");
if (extraFileAttributes) {
// Expand the list of attributes.
- std::vector<std::string> attributes;
- cmSystemTools::ExpandListArgument(extraFileAttributes, attributes);
+ std::vector<std::string> attributes = cmExpandedList(extraFileAttributes);
// Store the attributes.
- for (std::vector<std::string>::const_iterator ai = attributes.begin();
- ai != attributes.end(); ++ai) {
- attrs->AddObject(this->CreateString(*ai));
+ for (const auto& attribute : attributes) {
+ attrs->AddObject(this->CreateString(attribute));
}
}
@@ -740,6 +890,19 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
return buildFile;
}
+void cmGlobalXCodeGenerator::AddXCodeProjBuildRule(
+ cmGeneratorTarget* target, std::vector<cmSourceFile*>& sources) const
+{
+ std::string listfile =
+ cmStrCat(target->GetLocalGenerator()->GetCurrentSourceDirectory(),
+ "/CMakeLists.txt");
+ cmSourceFile* srcCMakeLists = target->Makefile->GetOrCreateSource(
+ listfile, false, cmSourceFileLocationKind::Known);
+ if (!cmContains(sources, srcCMakeLists)) {
+ sources.push_back(srcCMakeLists);
+ }
+}
+
std::string GetSourcecodeValueFromFileExtension(const std::string& _ext,
const std::string& lang,
bool& keepLastKnownFileType)
@@ -779,6 +942,10 @@ std::string GetSourcecodeValueFromFileExtension(const std::string& _ext,
sourcecode += ".cpp.cpp";
} else if (lang == "C") {
sourcecode += ".c.c";
+ } else if (lang == "OBJCXX") {
+ sourcecode += ".cpp.objcpp";
+ } else if (lang == "OBJC") {
+ sourcecode += ".c.objc";
} else if (lang == "Fortran") {
sourcecode += ".fortran.f90";
} else if (lang == "ASM") {
@@ -852,11 +1019,10 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
this->CreateString(fileType));
// Store the file path relative to the top of the source tree.
- std::string path = this->RelativeToSource(fullpath.c_str());
+ std::string path = this->RelativeToSource(fullpath);
std::string name = cmSystemTools::GetFilenameName(path);
const char* sourceTree =
- (cmSystemTools::FileIsFullPath(path.c_str()) ? "<absolute>"
- : "SOURCE_ROOT");
+ cmSystemTools::FileIsFullPath(path) ? "<absolute>" : "SOURCE_ROOT";
fileRef->AddAttribute("name", this->CreateString(name));
fileRef->AddAttribute("path", this->CreateString(path));
fileRef->AddAttribute("sourceTree", this->CreateString(sourceTree));
@@ -868,7 +1034,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReference(
{
std::string lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
- return this->CreateXCodeFileReferenceFromPath(sf->GetFullPath(), target,
+ return this->CreateXCodeFileReferenceFromPath(sf->ResolveFullPath(), target,
lang, sf);
}
@@ -895,7 +1061,7 @@ void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen)
this->CurrentConfigurationTypes.clear();
this->CurrentMakefile->GetConfigurations(this->CurrentConfigurationTypes);
if (this->CurrentConfigurationTypes.empty()) {
- this->CurrentConfigurationTypes.push_back("");
+ this->CurrentConfigurationTypes.emplace_back();
}
}
@@ -903,21 +1069,23 @@ struct cmSourceFilePathCompare
{
bool operator()(cmSourceFile* l, cmSourceFile* r)
{
- return l->GetFullPath() < r->GetFullPath();
+ return l->ResolveFullPath() < r->ResolveFullPath();
}
};
struct cmCompareTargets
{
- bool operator()(std::string const& a, std::string const& b) const
+ bool operator()(cmXCodeObject* l, cmXCodeObject* r) const
{
+ std::string const& a = l->GetTarget()->GetName();
+ std::string const& b = r->GetTarget()->GetName();
if (a == "ALL_BUILD") {
return true;
}
if (b == "ALL_BUILD") {
return false;
}
- return strcmp(a.c_str(), b.c_str()) < 0;
+ return a < b;
}
};
@@ -925,298 +1093,282 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
cmLocalGenerator* gen, std::vector<cmXCodeObject*>& targets)
{
this->SetCurrentLocalGenerator(gen);
- std::vector<cmGeneratorTarget*> tgts =
+ std::vector<cmGeneratorTarget*> gts =
this->CurrentLocalGenerator->GetGeneratorTargets();
- typedef std::map<std::string, cmGeneratorTarget*, cmCompareTargets>
- cmSortedTargets;
- cmSortedTargets sortedTargets;
- for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); l++) {
- sortedTargets[(*l)->GetName()] = *l;
+ std::sort(gts.begin(), gts.end(),
+ [this](cmGeneratorTarget const* l, cmGeneratorTarget const* r) {
+ return this->TargetOrderIndex[l] < this->TargetOrderIndex[r];
+ });
+ for (auto gtgt : gts) {
+ if (!this->CreateXCodeTarget(gtgt, targets)) {
+ return false;
+ }
}
- for (cmSortedTargets::iterator l = sortedTargets.begin();
- l != sortedTargets.end(); l++) {
- cmGeneratorTarget* gtgt = l->second;
-
- std::string targetName = gtgt->GetName();
+ std::sort(targets.begin(), targets.end(), cmCompareTargets());
+ return true;
+}
- // make sure ALL_BUILD, INSTALL, etc are only done once
- if (this->SpecialTargetEmitted(targetName)) {
- continue;
- }
+bool cmGlobalXCodeGenerator::CreateXCodeTarget(
+ cmGeneratorTarget* gtgt, std::vector<cmXCodeObject*>& targets)
+{
+ std::string targetName = gtgt->GetName();
- if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
- continue;
- }
+ // make sure ALL_BUILD, INSTALL, etc are only done once
+ if (this->SpecialTargetEmitted(targetName)) {
+ return true;
+ }
- if (gtgt->GetType() == cmStateEnums::UTILITY ||
- gtgt->GetType() == cmStateEnums::GLOBAL_TARGET) {
- cmXCodeObject* t = this->CreateUtilityTarget(gtgt);
- if (!t) {
- return false;
- }
- targets.push_back(t);
- continue;
- }
+ if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ return true;
+ }
- // organize the sources
- std::vector<cmSourceFile*> classes;
- if (!gtgt->GetConfigCommonSourceFiles(classes)) {
+ if (gtgt->GetType() == cmStateEnums::UTILITY ||
+ gtgt->GetType() == cmStateEnums::GLOBAL_TARGET) {
+ cmXCodeObject* t = this->CreateUtilityTarget(gtgt);
+ if (!t) {
return false;
}
- std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare());
+ targets.push_back(t);
+ return true;
+ }
- gtgt->ComputeObjectMapping();
+ // organize the sources
+ std::vector<cmSourceFile*> classes;
+ if (!gtgt->GetConfigCommonSourceFiles(classes)) {
+ return false;
+ }
- std::vector<cmXCodeObject*> externalObjFiles;
- std::vector<cmXCodeObject*> headerFiles;
- std::vector<cmXCodeObject*> resourceFiles;
- std::vector<cmXCodeObject*> sourceFiles;
- for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
- i != classes.end(); ++i) {
- cmXCodeObject* xsf =
- this->CreateXCodeSourceFile(this->CurrentLocalGenerator, *i, gtgt);
- cmXCodeObject* fr = xsf->GetObject("fileRef");
- cmXCodeObject* filetype = fr->GetObject()->GetObject("explicitFileType");
+ // Add CMakeLists.txt file for user convenience.
+ this->AddXCodeProjBuildRule(gtgt, classes);
- cmGeneratorTarget::SourceFileFlags tsFlags =
- gtgt->GetTargetSourceFileFlags(*i);
+ // Add the Info.plist we are about to generate for an App Bundle.
+ if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) {
+ std::string plist = this->ComputeInfoPListLocation(gtgt);
+ cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(
+ plist, true, cmSourceFileLocationKind::Known);
+ classes.push_back(sf);
+ }
- if (filetype && filetype->GetString() == "compiled.mach-o.objfile") {
- if ((*i)->GetObjectLibrary().empty()) {
- externalObjFiles.push_back(xsf);
- }
- } else if (this->IsHeaderFile(*i) ||
- (tsFlags.Type ==
- cmGeneratorTarget::SourceFileTypePrivateHeader) ||
- (tsFlags.Type ==
- cmGeneratorTarget::SourceFileTypePublicHeader)) {
- headerFiles.push_back(xsf);
- } else if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource) {
- resourceFiles.push_back(xsf);
- } else if (!(*i)->GetPropertyAsBool("HEADER_FILE_ONLY")) {
- // Include this file in the build if it has a known language
- // and has not been listed as an ignored extension for this
- // generator.
- if (!this->CurrentLocalGenerator->GetSourceFileLanguage(**i).empty() &&
- !this->IgnoreFile((*i)->GetExtension().c_str())) {
- sourceFiles.push_back(xsf);
- }
- }
- }
+ std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare());
- if (this->XcodeVersion < 50) {
- // Add object library contents as external objects. (Equivalent to
- // the externalObjFiles above, except each one is not a cmSourceFile
- // within the target.)
- std::vector<cmSourceFile const*> objs;
- gtgt->GetExternalObjects(objs, "");
- for (std::vector<cmSourceFile const*>::const_iterator oi = objs.begin();
- oi != objs.end(); ++oi) {
- if ((*oi)->GetObjectLibrary().empty()) {
- continue;
- }
- std::string const& obj = (*oi)->GetFullPath();
- cmXCodeObject* xsf =
- this->CreateXCodeSourceFileFromPath(obj, gtgt, "", 0);
- externalObjFiles.push_back(xsf);
- }
- }
+ gtgt->ComputeObjectMapping();
- // some build phases only apply to bundles and/or frameworks
- bool isFrameworkTarget = gtgt->IsFrameworkOnApple();
- bool isBundleTarget = gtgt->GetPropertyAsBool("MACOSX_BUNDLE");
- bool isCFBundleTarget = gtgt->IsCFBundleOnApple();
+ std::vector<cmXCodeObject*> externalObjFiles;
+ std::vector<cmXCodeObject*> headerFiles;
+ std::vector<cmXCodeObject*> resourceFiles;
+ std::vector<cmXCodeObject*> sourceFiles;
+ for (auto sourceFile : classes) {
+ cmXCodeObject* xsf = this->CreateXCodeSourceFile(
+ this->CurrentLocalGenerator, sourceFile, gtgt);
+ cmXCodeObject* fr = xsf->GetObject("fileRef");
+ cmXCodeObject* filetype = fr->GetObject()->GetObject("explicitFileType");
- cmXCodeObject* buildFiles = 0;
+ cmGeneratorTarget::SourceFileFlags tsFlags =
+ gtgt->GetTargetSourceFileFlags(sourceFile);
- // create source build phase
- cmXCodeObject* sourceBuildPhase = 0;
- if (!sourceFiles.empty()) {
- sourceBuildPhase =
- this->CreateObject(cmXCodeObject::PBXSourcesBuildPhase);
- sourceBuildPhase->SetComment("Sources");
- sourceBuildPhase->AddAttribute("buildActionMask",
- this->CreateString("2147483647"));
- buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
- for (std::vector<cmXCodeObject*>::iterator i = sourceFiles.begin();
- i != sourceFiles.end(); ++i) {
- buildFiles->AddObject(*i);
+ if (filetype && filetype->GetString() == "compiled.mach-o.objfile") {
+ if (sourceFile->GetObjectLibrary().empty()) {
+ externalObjFiles.push_back(xsf);
+ }
+ } else if (this->IsHeaderFile(sourceFile) ||
+ (tsFlags.Type ==
+ cmGeneratorTarget::SourceFileTypePrivateHeader) ||
+ (tsFlags.Type ==
+ cmGeneratorTarget::SourceFileTypePublicHeader)) {
+ headerFiles.push_back(xsf);
+ } else if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource) {
+ resourceFiles.push_back(xsf);
+ } else if (!sourceFile->GetPropertyAsBool("HEADER_FILE_ONLY") &&
+ !gtgt->IsSourceFilePartOfUnityBatch(
+ sourceFile->ResolveFullPath())) {
+ // Include this file in the build if it has a known language
+ // and has not been listed as an ignored extension for this
+ // generator.
+ if (!this->CurrentLocalGenerator->GetSourceFileLanguage(*sourceFile)
+ .empty() &&
+ !this->IgnoreFile(sourceFile->GetExtension().c_str())) {
+ sourceFiles.push_back(xsf);
}
- sourceBuildPhase->AddAttribute("files", buildFiles);
- sourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
- this->CreateString("0"));
}
+ }
- // create header build phase - only for framework targets
- cmXCodeObject* headerBuildPhase = 0;
- if (!headerFiles.empty() && isFrameworkTarget) {
- headerBuildPhase =
- this->CreateObject(cmXCodeObject::PBXHeadersBuildPhase);
- headerBuildPhase->SetComment("Headers");
- headerBuildPhase->AddAttribute("buildActionMask",
+ // some build phases only apply to bundles and/or frameworks
+ bool isFrameworkTarget = gtgt->IsFrameworkOnApple();
+ bool isBundleTarget = gtgt->GetPropertyAsBool("MACOSX_BUNDLE");
+ bool isCFBundleTarget = gtgt->IsCFBundleOnApple();
+
+ cmXCodeObject* buildFiles = nullptr;
+
+ // create source build phase
+ cmXCodeObject* sourceBuildPhase = nullptr;
+ if (!sourceFiles.empty()) {
+ sourceBuildPhase = this->CreateObject(cmXCodeObject::PBXSourcesBuildPhase);
+ sourceBuildPhase->SetComment("Sources");
+ sourceBuildPhase->AddAttribute("buildActionMask",
+ this->CreateString("2147483647"));
+ buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
+ for (auto& sourceFile : sourceFiles) {
+ buildFiles->AddObject(sourceFile);
+ }
+ sourceBuildPhase->AddAttribute("files", buildFiles);
+ sourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
+ this->CreateString("0"));
+ }
+
+ // create header build phase - only for framework targets
+ cmXCodeObject* headerBuildPhase = nullptr;
+ if (!headerFiles.empty() && isFrameworkTarget) {
+ headerBuildPhase = this->CreateObject(cmXCodeObject::PBXHeadersBuildPhase);
+ headerBuildPhase->SetComment("Headers");
+ headerBuildPhase->AddAttribute("buildActionMask",
+ this->CreateString("2147483647"));
+ buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
+ for (auto& headerFile : headerFiles) {
+ buildFiles->AddObject(headerFile);
+ }
+ headerBuildPhase->AddAttribute("files", buildFiles);
+ headerBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
+ this->CreateString("0"));
+ }
+
+ // create resource build phase - only for framework or bundle targets
+ cmXCodeObject* resourceBuildPhase = nullptr;
+ if (!resourceFiles.empty() &&
+ (isFrameworkTarget || isBundleTarget || isCFBundleTarget)) {
+ resourceBuildPhase =
+ this->CreateObject(cmXCodeObject::PBXResourcesBuildPhase);
+ resourceBuildPhase->SetComment("Resources");
+ resourceBuildPhase->AddAttribute("buildActionMask",
this->CreateString("2147483647"));
- buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
- for (std::vector<cmXCodeObject*>::iterator i = headerFiles.begin();
- i != headerFiles.end(); ++i) {
- buildFiles->AddObject(*i);
- }
- headerBuildPhase->AddAttribute("files", buildFiles);
- headerBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
- this->CreateString("0"));
+ buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
+ for (auto& resourceFile : resourceFiles) {
+ buildFiles->AddObject(resourceFile);
}
+ resourceBuildPhase->AddAttribute("files", buildFiles);
+ resourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
+ this->CreateString("0"));
+ }
- // create resource build phase - only for framework or bundle targets
- cmXCodeObject* resourceBuildPhase = 0;
- if (!resourceFiles.empty() &&
- (isFrameworkTarget || isBundleTarget || isCFBundleTarget)) {
- resourceBuildPhase =
- this->CreateObject(cmXCodeObject::PBXResourcesBuildPhase);
- resourceBuildPhase->SetComment("Resources");
- resourceBuildPhase->AddAttribute("buildActionMask",
- this->CreateString("2147483647"));
- buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
- for (std::vector<cmXCodeObject*>::iterator i = resourceFiles.begin();
- i != resourceFiles.end(); ++i) {
- buildFiles->AddObject(*i);
+ // create vector of "non-resource content file" build phases - only for
+ // framework or bundle targets
+ std::vector<cmXCodeObject*> contentBuildPhases;
+ if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) {
+ using mapOfVectorOfSourceFiles =
+ std::map<std::string, std::vector<cmSourceFile*>>;
+ mapOfVectorOfSourceFiles bundleFiles;
+ for (auto sourceFile : classes) {
+ cmGeneratorTarget::SourceFileFlags tsFlags =
+ gtgt->GetTargetSourceFileFlags(sourceFile);
+ if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeMacContent) {
+ bundleFiles[tsFlags.MacFolder].push_back(sourceFile);
}
- resourceBuildPhase->AddAttribute("files", buildFiles);
- resourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
- this->CreateString("0"));
- }
-
- // create vector of "non-resource content file" build phases - only for
- // framework or bundle targets
- std::vector<cmXCodeObject*> contentBuildPhases;
- if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) {
- typedef std::map<std::string, std::vector<cmSourceFile*> >
- mapOfVectorOfSourceFiles;
- mapOfVectorOfSourceFiles bundleFiles;
- for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
- i != classes.end(); ++i) {
- cmGeneratorTarget::SourceFileFlags tsFlags =
- gtgt->GetTargetSourceFileFlags(*i);
- if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeMacContent) {
- bundleFiles[tsFlags.MacFolder].push_back(*i);
+ }
+ for (auto const& keySources : bundleFiles) {
+ cmXCodeObject* copyFilesBuildPhase =
+ this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
+ copyFilesBuildPhase->SetComment("Copy files");
+ copyFilesBuildPhase->AddAttribute("buildActionMask",
+ this->CreateString("2147483647"));
+ copyFilesBuildPhase->AddAttribute("dstSubfolderSpec",
+ this->CreateString("6"));
+ std::ostringstream ostr;
+ if (gtgt->IsFrameworkOnApple()) {
+ // dstPath in frameworks is relative to Versions/<version>
+ ostr << keySources.first;
+ } else if (keySources.first != "MacOS") {
+ if (gtgt->Target->GetMakefile()->PlatformIsAppleEmbedded()) {
+ ostr << keySources.first;
+ } else {
+ // dstPath in bundles is relative to Contents/MacOS
+ ostr << "../" << keySources.first;
}
}
- mapOfVectorOfSourceFiles::iterator mit;
- for (mit = bundleFiles.begin(); mit != bundleFiles.end(); ++mit) {
- cmXCodeObject* copyFilesBuildPhase =
- this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
- copyFilesBuildPhase->SetComment("Copy files");
- copyFilesBuildPhase->AddAttribute("buildActionMask",
- this->CreateString("2147483647"));
- copyFilesBuildPhase->AddAttribute("dstSubfolderSpec",
- this->CreateString("6"));
- std::ostringstream ostr;
- if (gtgt->IsFrameworkOnApple()) {
- // dstPath in frameworks is relative to Versions/<version>
- ostr << mit->first;
- } else if (mit->first != "MacOS") {
- if (gtgt->Target->GetMakefile()->PlatformIsAppleIos()) {
- ostr << mit->first;
- } else {
- // dstPath in bundles is relative to Contents/MacOS
- ostr << "../" << mit->first;
- }
- }
- copyFilesBuildPhase->AddAttribute("dstPath",
- this->CreateString(ostr.str()));
- copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
- this->CreateString("0"));
- buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
- copyFilesBuildPhase->AddAttribute("files", buildFiles);
- std::vector<cmSourceFile*>::iterator sfIt;
- for (sfIt = mit->second.begin(); sfIt != mit->second.end(); ++sfIt) {
- cmXCodeObject* xsf = this->CreateXCodeSourceFile(
- this->CurrentLocalGenerator, *sfIt, gtgt);
- buildFiles->AddObject(xsf);
- }
- contentBuildPhases.push_back(copyFilesBuildPhase);
+ copyFilesBuildPhase->AddAttribute("dstPath",
+ this->CreateString(ostr.str()));
+ copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
+ this->CreateString("0"));
+ buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
+ copyFilesBuildPhase->AddAttribute("files", buildFiles);
+ for (auto sourceFile : keySources.second) {
+ cmXCodeObject* xsf = this->CreateXCodeSourceFile(
+ this->CurrentLocalGenerator, sourceFile, gtgt);
+ buildFiles->AddObject(xsf);
}
+ contentBuildPhases.push_back(copyFilesBuildPhase);
}
+ }
- // create vector of "resource content file" build phases - only for
- // framework or bundle targets
- if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) {
- typedef std::map<std::string, std::vector<cmSourceFile*> >
- mapOfVectorOfSourceFiles;
- mapOfVectorOfSourceFiles bundleFiles;
- for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
- i != classes.end(); ++i) {
- cmGeneratorTarget::SourceFileFlags tsFlags =
- gtgt->GetTargetSourceFileFlags(*i);
- if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeDeepResource) {
- bundleFiles[tsFlags.MacFolder].push_back(*i);
- }
- }
- mapOfVectorOfSourceFiles::iterator mit;
- for (mit = bundleFiles.begin(); mit != bundleFiles.end(); ++mit) {
- cmXCodeObject* copyFilesBuildPhase =
- this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
- copyFilesBuildPhase->SetComment("Copy files");
- copyFilesBuildPhase->AddAttribute("buildActionMask",
- this->CreateString("2147483647"));
- copyFilesBuildPhase->AddAttribute("dstSubfolderSpec",
- this->CreateString("7"));
- copyFilesBuildPhase->AddAttribute("dstPath",
- this->CreateString(mit->first));
- copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
- this->CreateString("0"));
- buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
- copyFilesBuildPhase->AddAttribute("files", buildFiles);
- std::vector<cmSourceFile*>::iterator sfIt;
- for (sfIt = mit->second.begin(); sfIt != mit->second.end(); ++sfIt) {
- cmXCodeObject* xsf = this->CreateXCodeSourceFile(
- this->CurrentLocalGenerator, *sfIt, gtgt);
- buildFiles->AddObject(xsf);
- }
- contentBuildPhases.push_back(copyFilesBuildPhase);
+ // create vector of "resource content file" build phases - only for
+ // framework or bundle targets
+ if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) {
+ using mapOfVectorOfSourceFiles =
+ std::map<std::string, std::vector<cmSourceFile*>>;
+ mapOfVectorOfSourceFiles bundleFiles;
+ for (auto sourceFile : classes) {
+ cmGeneratorTarget::SourceFileFlags tsFlags =
+ gtgt->GetTargetSourceFileFlags(sourceFile);
+ if (tsFlags.Type == cmGeneratorTarget::SourceFileTypeDeepResource) {
+ bundleFiles[tsFlags.MacFolder].push_back(sourceFile);
}
}
-
- // create framework build phase
- cmXCodeObject* frameworkBuildPhase = 0;
- if (!externalObjFiles.empty()) {
- frameworkBuildPhase =
- this->CreateObject(cmXCodeObject::PBXFrameworksBuildPhase);
- frameworkBuildPhase->SetComment("Frameworks");
- frameworkBuildPhase->AddAttribute("buildActionMask",
+ for (auto const& keySources : bundleFiles) {
+ cmXCodeObject* copyFilesBuildPhase =
+ this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase);
+ copyFilesBuildPhase->SetComment("Copy files");
+ copyFilesBuildPhase->AddAttribute("buildActionMask",
this->CreateString("2147483647"));
+ copyFilesBuildPhase->AddAttribute("dstSubfolderSpec",
+ this->CreateString("7"));
+ copyFilesBuildPhase->AddAttribute("dstPath",
+ this->CreateString(keySources.first));
+ copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
+ this->CreateString("0"));
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
- frameworkBuildPhase->AddAttribute("files", buildFiles);
- for (std::vector<cmXCodeObject*>::iterator i = externalObjFiles.begin();
- i != externalObjFiles.end(); ++i) {
- buildFiles->AddObject(*i);
+ copyFilesBuildPhase->AddAttribute("files", buildFiles);
+ for (auto sourceFile : keySources.second) {
+ cmXCodeObject* xsf = this->CreateXCodeSourceFile(
+ this->CurrentLocalGenerator, sourceFile, gtgt);
+ buildFiles->AddObject(xsf);
}
- frameworkBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
- this->CreateString("0"));
+ contentBuildPhases.push_back(copyFilesBuildPhase);
}
+ }
- // create list of build phases and create the Xcode target
- cmXCodeObject* buildPhases =
- this->CreateObject(cmXCodeObject::OBJECT_LIST);
+ // create framework build phase
+ cmXCodeObject* frameworkBuildPhase = nullptr;
+ if (!externalObjFiles.empty()) {
+ frameworkBuildPhase =
+ this->CreateObject(cmXCodeObject::PBXFrameworksBuildPhase);
+ frameworkBuildPhase->SetComment("Frameworks");
+ frameworkBuildPhase->AddAttribute("buildActionMask",
+ this->CreateString("2147483647"));
+ buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
+ frameworkBuildPhase->AddAttribute("files", buildFiles);
+ for (auto& externalObjFile : externalObjFiles) {
+ buildFiles->AddObject(externalObjFile);
+ }
+ frameworkBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing",
+ this->CreateString("0"));
+ }
- this->CreateCustomCommands(buildPhases, sourceBuildPhase, headerBuildPhase,
- resourceBuildPhase, contentBuildPhases,
- frameworkBuildPhase, gtgt);
+ // create list of build phases and create the Xcode target
+ cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST);
- targets.push_back(this->CreateXCodeTarget(gtgt, buildPhases));
- }
+ this->CreateCustomCommands(buildPhases, sourceBuildPhase, headerBuildPhase,
+ resourceBuildPhase, contentBuildPhases,
+ frameworkBuildPhase, gtgt);
+
+ targets.push_back(this->CreateXCodeTarget(gtgt, buildPhases));
return true;
}
void cmGlobalXCodeGenerator::ForceLinkerLanguages()
{
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- std::vector<cmGeneratorTarget*> tgts =
- this->LocalGenerators[i]->GetGeneratorTargets();
+ for (auto localGenerator : this->LocalGenerators) {
// All targets depend on the build-system check target.
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = tgts.begin();
- ti != tgts.end(); ++ti) {
+ for (auto tgt : localGenerator->GetGeneratorTargets()) {
// This makes sure all targets link using the proper language.
- this->ForceLinkerLanguage(*ti);
+ this->ForceLinkerLanguage(tgt);
}
}
}
@@ -1236,10 +1388,9 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
}
// If the language is compiled as a source trust Xcode to link with it.
- cmLinkImplementation const* impl = gtgt->GetLinkImplementation("NOCONFIG");
- for (std::vector<std::string>::const_iterator li = impl->Languages.begin();
- li != impl->Languages.end(); ++li) {
- if (*li == llang) {
+ for (auto const& Language :
+ gtgt->GetLinkImplementation("NOCONFIG")->Languages) {
+ if (Language == llang) {
return;
}
}
@@ -1248,15 +1399,11 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
// linker language. This should convince Xcode to choose the proper
// language.
cmMakefile* mf = gtgt->Target->GetMakefile();
- std::string fname = gtgt->GetLocalGenerator()->GetCurrentBinaryDirectory();
- fname += cmake::GetCMakeFilesDirectory();
- fname += "/";
- fname += gtgt->GetName();
- fname += "-CMakeForceLinker";
- fname += ".";
- fname += cmSystemTools::LowerCase(llang);
+ std::string fname = cmStrCat(
+ gtgt->GetLocalGenerator()->GetCurrentBinaryDirectory(), "/CMakeFiles/",
+ gtgt->GetName(), "-CMakeForceLinker.", cmSystemTools::LowerCase(llang));
{
- cmGeneratedFileStream fout(fname.c_str());
+ cmGeneratedFileStream fout(fname);
fout << "\n";
}
if (cmSourceFile* sf = mf->GetOrCreateSource(fname)) {
@@ -1267,18 +1414,16 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
bool cmGlobalXCodeGenerator::IsHeaderFile(cmSourceFile* sf)
{
- const std::vector<std::string>& hdrExts =
- this->CMakeInstance->GetHeaderExtensions();
- return (std::find(hdrExts.begin(), hdrExts.end(), sf->GetExtension()) !=
- hdrExts.end());
+ return cmContains(this->CMakeInstance->GetHeaderExtensions(),
+ sf->GetExtension());
}
cmXCodeObject* cmGlobalXCodeGenerator::CreateBuildPhase(
const char* name, const char* name2, cmGeneratorTarget* target,
const std::vector<cmCustomCommand>& commands)
{
- if (commands.size() == 0 && strcmp(name, "CMake ReRun") != 0) {
- return 0;
+ if (commands.empty() && strcmp(name, "CMake ReRun") != 0) {
+ return nullptr;
}
cmXCodeObject* buildPhase =
this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase);
@@ -1297,7 +1442,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateBuildPhase(
void cmGlobalXCodeGenerator::CreateCustomCommands(
cmXCodeObject* buildPhases, cmXCodeObject* sourceBuildPhase,
cmXCodeObject* headerBuildPhase, cmXCodeObject* resourceBuildPhase,
- std::vector<cmXCodeObject*> contentBuildPhases,
+ std::vector<cmXCodeObject*> const& contentBuildPhases,
cmXCodeObject* frameworkBuildPhase, cmGeneratorTarget* gtgt)
{
std::vector<cmCustomCommand> const& prebuild = gtgt->GetPreBuildCommands();
@@ -1306,23 +1451,14 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(
if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY &&
!gtgt->IsFrameworkOnApple()) {
- cmCustomCommandLines cmd;
- cmd.resize(1);
- cmd[0].push_back(cmSystemTools::GetCMakeCommand());
- cmd[0].push_back("-E");
- cmd[0].push_back("cmake_symlink_library");
- std::string str_file = "$<TARGET_FILE:";
- str_file += gtgt->GetName();
- str_file += ">";
- std::string str_so_file = "$<TARGET_SONAME_FILE:";
- str_so_file += gtgt->GetName();
- str_so_file += ">";
- std::string str_link_file = "$<TARGET_LINKER_FILE:";
- str_link_file += gtgt->GetName();
- str_link_file += ">";
- cmd[0].push_back(str_file);
- cmd[0].push_back(str_so_file);
- cmd[0].push_back(str_link_file);
+ std::string str_file = cmStrCat("$<TARGET_FILE:", gtgt->GetName(), '>');
+ std::string str_so_file =
+ cmStrCat("$<TARGET_SONAME_FILE:", gtgt->GetName(), '>');
+ std::string str_link_file =
+ cmStrCat("$<TARGET_LINKER_FILE:", gtgt->GetName(), '>');
+ cmCustomCommandLines cmd = cmMakeSingleCommandLine(
+ { cmSystemTools::GetCMakeCommand(), "-E", "cmake_symlink_library",
+ str_file, str_so_file, str_link_file });
cmCustomCommand command(this->CurrentMakefile, std::vector<std::string>(),
std::vector<std::string>(),
@@ -1338,10 +1474,9 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(
}
// add all the sources
std::vector<cmCustomCommand> commands;
- for (std::vector<cmSourceFile*>::const_iterator i = classes.begin();
- i != classes.end(); ++i) {
- if ((*i)->GetCustomCommand()) {
- commands.push_back(*(*i)->GetCustomCommand());
+ for (auto sourceFile : classes) {
+ if (sourceFile->GetCustomCommand()) {
+ commands.push_back(*sourceFile->GetCustomCommand());
}
}
// create prebuild phase
@@ -1373,10 +1508,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(
if (resourceBuildPhase) {
buildPhases->AddObject(resourceBuildPhase);
}
- std::vector<cmXCodeObject*>::iterator cit;
- for (cit = contentBuildPhases.begin(); cit != contentBuildPhases.end();
- ++cit) {
- buildPhases->AddObject(*cit);
+ for (auto obj : contentBuildPhases) {
+ buildPhases->AddObject(obj);
}
if (sourceBuildPhase) {
buildPhases->AddObject(sourceBuildPhase);
@@ -1438,7 +1571,7 @@ std::string cmGlobalXCodeGenerator::ExtractFlagRegex(const char* exp,
std::string::size_type offset = 0;
- while (regex.find(flags.c_str() + offset)) {
+ while (regex.find(&flags[offset])) {
const std::string::size_type startPos = offset + regex.start(matchIndex);
const std::string::size_type endPos = offset + regex.end(matchIndex);
const std::string::size_type size = endPos - startPos;
@@ -1465,7 +1598,7 @@ void cmGlobalXCodeGenerator::FilterConfigurationAttribute(
return;
}
- std::string::size_type endVariant = attribute.find("]", beginVariant + 9);
+ std::string::size_type endVariant = attribute.find(']', beginVariant + 9);
if (endVariant == std::string::npos) {
// There is no terminating bracket.
return;
@@ -1489,32 +1622,23 @@ void cmGlobalXCodeGenerator::AddCommandsToBuildPhase(
cmXCodeObject* buildphase, cmGeneratorTarget* target,
std::vector<cmCustomCommand> const& commands, const char* name)
{
- std::string dir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
- dir += "/CMakeScripts";
- cmSystemTools::MakeDirectory(dir.c_str());
- std::string makefile = dir;
- makefile += "/";
- makefile += target->GetName();
- makefile += "_";
- makefile += name;
- makefile += ".make";
-
- for (std::vector<std::string>::const_iterator currentConfig =
- this->CurrentConfigurationTypes.begin();
- currentConfig != this->CurrentConfigurationTypes.end();
- currentConfig++) {
+ std::string dir = cmStrCat(
+ this->CurrentLocalGenerator->GetCurrentBinaryDirectory(), "/CMakeScripts");
+ cmSystemTools::MakeDirectory(dir);
+ std::string makefile =
+ cmStrCat(dir, '/', target->GetName(), '_', name, ".make");
+
+ for (const auto& currentConfig : this->CurrentConfigurationTypes) {
this->CreateCustomRulesMakefile(makefile.c_str(), target, commands,
- *currentConfig);
+ currentConfig);
}
std::string cdir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
- cdir = this->ConvertToRelativeForMake(cdir.c_str());
- std::string makecmd = "make -C ";
- makecmd += cdir;
- makecmd += " -f ";
- makecmd +=
- this->ConvertToRelativeForMake((makefile + "$CONFIGURATION").c_str());
- makecmd += " all";
+ cdir = this->ConvertToRelativeForMake(cdir);
+ std::string makecmd =
+ cmStrCat("make -C ", cdir, " -f ",
+ this->ConvertToRelativeForMake((makefile + "$CONFIGURATION")),
+ " OBJDIR=$(basename \"$OBJECT_FILE_DIR_normal\") all");
buildphase->AddAttribute("shellScript", this->CreateString(makecmd));
buildphase->AddAttribute("showEnvVarsInLog", this->CreateString("0"));
}
@@ -1523,9 +1647,8 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
const char* makefileBasename, cmGeneratorTarget* target,
std::vector<cmCustomCommand> const& commands, const std::string& configName)
{
- std::string makefileName = makefileBasename;
- makefileName += configName;
- cmGeneratedFileStream makefileStream(makefileName.c_str());
+ std::string makefileName = cmStrCat(makefileBasename, configName);
+ cmGeneratedFileStream makefileStream(makefileName);
if (!makefileStream) {
return;
}
@@ -1541,38 +1664,35 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
makefileStream << "all: ";
std::map<const cmCustomCommand*, std::string> tname;
int count = 0;
- for (std::vector<cmCustomCommand>::const_iterator i = commands.begin();
- i != commands.end(); ++i) {
- cmCustomCommandGenerator ccg(*i, configName, this->CurrentLocalGenerator);
+ for (auto const& command : commands) {
+ cmCustomCommandGenerator ccg(command, configName,
+ this->CurrentLocalGenerator);
if (ccg.GetNumberOfCommands() > 0) {
const std::vector<std::string>& outputs = ccg.GetOutputs();
if (!outputs.empty()) {
- for (std::vector<std::string>::const_iterator o = outputs.begin();
- o != outputs.end(); ++o) {
- makefileStream << "\\\n\t"
- << this->ConvertToRelativeForMake(o->c_str());
+ for (auto const& output : outputs) {
+ makefileStream << "\\\n\t" << this->ConvertToRelativeForMake(output);
}
} else {
std::ostringstream str;
str << "_buildpart_" << count++;
- tname[&ccg.GetCC()] = std::string(target->GetName()) + str.str();
+ tname[&ccg.GetCC()] = target->GetName() + str.str();
makefileStream << "\\\n\t" << tname[&ccg.GetCC()];
}
}
}
makefileStream << "\n\n";
- for (std::vector<cmCustomCommand>::const_iterator i = commands.begin();
- i != commands.end(); ++i) {
- cmCustomCommandGenerator ccg(*i, configName, this->CurrentLocalGenerator);
+ for (auto const& command : commands) {
+ cmCustomCommandGenerator ccg(command, configName,
+ this->CurrentLocalGenerator);
if (ccg.GetNumberOfCommands() > 0) {
makefileStream << "\n";
const std::vector<std::string>& outputs = ccg.GetOutputs();
if (!outputs.empty()) {
// There is at least one output, start the rule for it
const char* sep = "";
- for (std::vector<std::string>::const_iterator oi = outputs.begin();
- oi != outputs.end(); ++oi) {
- makefileStream << sep << this->ConvertToRelativeForMake(oi->c_str());
+ for (auto const& output : outputs) {
+ makefileStream << sep << this->ConvertToRelativeForMake(output);
sep = " ";
}
makefileStream << ": ";
@@ -1580,22 +1700,20 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
// There are no outputs. Use the generated force rule name.
makefileStream << tname[&ccg.GetCC()] << ": ";
}
- for (std::vector<std::string>::const_iterator d =
- ccg.GetDepends().begin();
- d != ccg.GetDepends().end(); ++d) {
+ for (auto const& d : ccg.GetDepends()) {
std::string dep;
- if (this->CurrentLocalGenerator->GetRealDependency(*d, configName,
+ if (this->CurrentLocalGenerator->GetRealDependency(d, configName,
dep)) {
- makefileStream << "\\\n"
- << this->ConvertToRelativeForMake(dep.c_str());
+ makefileStream << "\\\n" << this->ConvertToRelativeForMake(dep);
}
}
makefileStream << "\n";
if (const char* comment = ccg.GetComment()) {
- std::string echo_cmd = "echo ";
- echo_cmd += (this->CurrentLocalGenerator->EscapeForShell(
- comment, ccg.GetCC().GetEscapeAllowMakeVars()));
+ std::string echo_cmd =
+ cmStrCat("echo ",
+ (this->CurrentLocalGenerator->EscapeForShell(
+ comment, ccg.GetCC().GetEscapeAllowMakeVars())));
makefileStream << "\t" << echo_cmd << "\n";
}
@@ -1604,12 +1722,12 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
// Build the command line in a single string.
std::string cmd2 = ccg.GetCommand(c);
cmSystemTools::ReplaceString(cmd2, "/./", "/");
- cmd2 = this->ConvertToRelativeForMake(cmd2.c_str());
+ cmd2 = this->ConvertToRelativeForMake(cmd2);
std::string cmd;
std::string wd = ccg.GetWorkingDirectory();
if (!wd.empty()) {
cmd += "cd ";
- cmd += this->ConvertToRelativeForMake(wd.c_str());
+ cmd += this->ConvertToRelativeForMake(wd);
cmd += " && ";
}
cmd += cmd2;
@@ -1620,6 +1738,25 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
}
}
+void cmGlobalXCodeGenerator::AddPositionIndependentLinkAttribute(
+ cmGeneratorTarget* target, cmXCodeObject* buildSettings,
+ const std::string& configName)
+{
+ // For now, only EXECUTABLE is concerned
+ if (target->GetType() != cmStateEnums::EXECUTABLE) {
+ return;
+ }
+
+ const char* PICValue = target->GetLinkPIEProperty(configName);
+ if (PICValue == nullptr) {
+ // POSITION_INDEPENDENT_CODE is not set
+ return;
+ }
+
+ buildSettings->AddAttribute(
+ "LD_NO_PIE", this->CreateString(cmIsOn(PICValue) ? "NO" : "YES"));
+}
+
void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
cmXCodeObject* buildSettings,
const std::string& configName)
@@ -1639,15 +1776,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::set<std::string> languages;
gtgt->GetLanguages(languages, configName);
std::map<std::string, std::string> cflags;
- for (std::set<std::string>::iterator li = languages.begin();
- li != languages.end(); ++li) {
- std::string const& lang = *li;
+ for (auto const& lang : languages) {
std::string& flags = cflags[lang];
// Add language-specific flags.
this->CurrentLocalGenerator->AddLanguageFlags(flags, gtgt, lang,
configName);
+ if (gtgt->IsIPOEnabled(lang, configName)) {
+ this->CurrentLocalGenerator->AppendFeatureOptions(flags, lang, "IPO");
+ }
+
// Add shared-library flags if needed.
this->CurrentLocalGenerator->AddCMP0018Flags(flags, gtgt, lang,
configName);
@@ -1661,10 +1800,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::string llang = gtgt->GetLinkerLanguage(configName);
if (binary && llang.empty()) {
cmSystemTools::Error(
- "CMake can not determine linker language for target: ",
- gtgt->GetName().c_str());
+ "CMake can not determine linker language for target: " +
+ gtgt->GetName());
return;
}
+ std::string const& langForPreprocessor = llang;
if (gtgt->IsIPOEnabled(llang, configName)) {
const char* ltoValue =
@@ -1672,6 +1812,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
buildSettings->AddAttribute("LLVM_LTO", this->CreateString(ltoValue));
}
+ // Handle PIE linker configuration
+ this->AddPositionIndependentLinkAttribute(gtgt, buildSettings, configName);
+
// Add define flags
this->CurrentLocalGenerator->AppendFlags(
defFlags, this->CurrentMakefile->GetDefineFlags());
@@ -1680,12 +1823,15 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
BuildObjectListOrString ppDefs(this, true);
this->AppendDefines(
ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"");
- if (const char* exportMacro = gtgt->GetExportMacro()) {
+ if (const std::string* exportMacro = gtgt->GetExportMacro()) {
// Add the export symbol definition for shared library objects.
- this->AppendDefines(ppDefs, exportMacro);
+ this->AppendDefines(ppDefs, exportMacro->c_str());
}
std::vector<std::string> targetDefines;
- gtgt->GetCompileDefinitions(targetDefines, configName, "C");
+ if (!langForPreprocessor.empty()) {
+ gtgt->GetCompileDefinitions(targetDefines, configName,
+ langForPreprocessor);
+ }
this->AppendDefines(ppDefs, targetDefines);
buildSettings->AddAttribute("GCC_PREPROCESSOR_DEFINITIONS",
ppDefs.CreateList());
@@ -1707,7 +1853,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY ||
gtgt->GetType() == cmStateEnums::STATIC_LIBRARY) {
this->CurrentLocalGenerator->GetStaticLibraryFlags(
- extraLinkOptions, cmSystemTools::UpperCase(configName), gtgt);
+ extraLinkOptions, cmSystemTools::UpperCase(configName), llang, gtgt);
} else {
const char* targetLinkFlags = gtgt->GetProperty("LINK_FLAGS");
if (targetLinkFlags) {
@@ -1715,12 +1861,16 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
targetLinkFlags);
}
if (!configName.empty()) {
- std::string linkFlagsVar = "LINK_FLAGS_";
- linkFlagsVar += cmSystemTools::UpperCase(configName);
+ std::string linkFlagsVar =
+ cmStrCat("LINK_FLAGS_", cmSystemTools::UpperCase(configName));
if (const char* linkFlags = gtgt->GetProperty(linkFlagsVar)) {
this->CurrentLocalGenerator->AppendFlags(extraLinkOptions, linkFlags);
}
}
+ std::vector<std::string> opts;
+ gtgt->GetLinkOptions(opts, configName, llang);
+ // LINK_OPTIONS are escaped.
+ this->CurrentLocalGenerator->AppendCompileOptions(extraLinkOptions, opts);
}
// Set target-specific architectures.
@@ -1737,9 +1887,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
} else {
cmXCodeObject* archObjects =
this->CreateObject(cmXCodeObject::OBJECT_LIST);
- for (std::vector<std::string>::iterator i = archs.begin();
- i != archs.end(); i++) {
- archObjects->AddObject(this->CreateString(*i));
+ for (auto& arch : archs) {
+ archObjects->AddObject(this->CreateString(arch));
}
buildSettings->AddAttribute("ARCHS", archObjects);
}
@@ -1754,8 +1903,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
const char* version = gtgt->GetProperty("VERSION");
const char* soversion = gtgt->GetProperty("SOVERSION");
if (!gtgt->HasSOName(configName) || gtgt->IsFrameworkOnApple()) {
- version = 0;
- soversion = 0;
+ version = nullptr;
+ soversion = nullptr;
}
if (version && !soversion) {
soversion = version;
@@ -1799,8 +1948,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
pnbase = gtgt->GetName();
pnsuffix = ".a";
- std::string pncdir =
- this->GetObjectsNormalDirectory(this->CurrentProject, configName, gtgt);
+ std::string pncdir = this->GetObjectsDirectory(
+ this->CurrentProject, configName, gtgt, OBJECT_LIBRARY_ARTIFACT_DIR);
buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
this->CreateString(pncdir));
}
@@ -1827,7 +1976,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// so let it replace the framework name. This avoids creating
// a per-configuration Info.plist file.
this->CurrentLocalGenerator->GenerateFrameworkInfoPList(
- gtgt, "$(EXECUTABLE_NAME)", plist.c_str());
+ gtgt, "$(EXECUTABLE_NAME)", plist);
buildSettings->AddAttribute("INFOPLIST_FILE",
this->CreateString(plist));
buildSettings->AddAttribute("MACH_O_TYPE",
@@ -1868,7 +2017,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// a per-configuration Info.plist file. The cfbundle plist
// is very similar to the application bundle plist
this->CurrentLocalGenerator->GenerateAppleInfoPList(
- gtgt, "$(EXECUTABLE_NAME)", plist.c_str());
+ gtgt, "$(EXECUTABLE_NAME)", plist);
buildSettings->AddAttribute("INFOPLIST_FILE",
this->CreateString(plist));
} else {
@@ -1902,7 +2051,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// so let it replace the framework name. This avoids creating
// a per-configuration Info.plist file.
this->CurrentLocalGenerator->GenerateFrameworkInfoPList(
- gtgt, "$(EXECUTABLE_NAME)", plist.c_str());
+ gtgt, "$(EXECUTABLE_NAME)", plist);
buildSettings->AddAttribute("INFOPLIST_FILE",
this->CreateString(plist));
} else {
@@ -1940,7 +2089,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// so let it replace the executable name. This avoids creating
// a per-configuration Info.plist file.
this->CurrentLocalGenerator->GenerateAppleInfoPList(
- gtgt, "$(EXECUTABLE_NAME)", plist.c_str());
+ gtgt, "$(EXECUTABLE_NAME)", plist);
buildSettings->AddAttribute("INFOPLIST_FILE",
this->CreateString(plist));
}
@@ -1948,9 +2097,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
default:
break;
}
- if (this->XcodeVersion < 40) {
- buildSettings->AddAttribute("PREBINDING", this->CreateString("NO"));
- }
BuildObjectListOrString dirs(this, true);
BuildObjectListOrString fdirs(this, true);
@@ -1959,30 +2105,32 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
const bool emitSystemIncludes = this->XcodeVersion >= 83;
std::vector<std::string> includes;
- this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt, "C",
- configName);
+ if (!langForPreprocessor.empty()) {
+ this->CurrentLocalGenerator->GetIncludeDirectories(
+ includes, gtgt, langForPreprocessor, configName);
+ }
std::set<std::string> emitted;
emitted.insert("/System/Library/Frameworks");
- for (std::vector<std::string>::iterator i = includes.begin();
- i != includes.end(); ++i) {
- if (this->NameResolvesToFramework(*i)) {
- std::string frameworkDir = *i;
- frameworkDir += "/../";
+ for (auto& include : includes) {
+ if (this->NameResolvesToFramework(include)) {
+ std::string frameworkDir = cmStrCat(include, "/../");
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
if (emitted.insert(frameworkDir).second) {
std::string incpath = this->XCodeEscapePath(frameworkDir);
if (emitSystemIncludes &&
- gtgt->IsSystemIncludeDirectory(frameworkDir, configName)) {
+ gtgt->IsSystemIncludeDirectory(frameworkDir, configName,
+ langForPreprocessor)) {
sysfdirs.Add(incpath);
} else {
fdirs.Add(incpath);
}
}
} else {
- std::string incpath = this->XCodeEscapePath(*i);
+ std::string incpath = this->XCodeEscapePath(include);
if (emitSystemIncludes &&
- gtgt->IsSystemIncludeDirectory(*i, configName)) {
+ gtgt->IsSystemIncludeDirectory(include, configName,
+ langForPreprocessor)) {
sysdirs.Add(incpath);
} else {
dirs.Add(incpath);
@@ -1991,13 +2139,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
}
// Add framework search paths needed for linking.
if (cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) {
- std::vector<std::string> const& fwDirs = cli->GetFrameworkPaths();
- for (std::vector<std::string>::const_iterator fdi = fwDirs.begin();
- fdi != fwDirs.end(); ++fdi) {
- if (emitted.insert(*fdi).second) {
- std::string incpath = this->XCodeEscapePath(*fdi);
+ for (auto const& fwDir : cli->GetFrameworkPaths()) {
+ if (emitted.insert(fwDir).second) {
+ std::string incpath = this->XCodeEscapePath(fwDir);
if (emitSystemIncludes &&
- gtgt->IsSystemIncludeDirectory(*fdi, configName)) {
+ gtgt->IsSystemIncludeDirectory(fwDir, configName,
+ langForPreprocessor)) {
sysfdirs.Add(incpath);
} else {
fdirs.Add(incpath);
@@ -2025,27 +2172,25 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// system include directory awareness. We need to also keep on setting
// HEADER_SEARCH_PATHS to work around a missing compile options flag for
// GNU assembly files (#16449)
- for (std::set<std::string>::iterator li = languages.begin();
- li != languages.end(); ++li) {
+ for (auto const& language : languages) {
std::string includeFlags = this->CurrentLocalGenerator->GetIncludeFlags(
- includes, gtgt, *li, true, false, configName);
+ includes, gtgt, language, true, false, configName);
if (!includeFlags.empty()) {
- cflags[*li] += " " + includeFlags;
+ cflags[language] += " " + includeFlags;
}
}
}
bool same_gflags = true;
std::map<std::string, std::string> gflags;
- std::string const* last_gflag = 0;
+ std::string const* last_gflag = nullptr;
std::string optLevel = "0";
// Minimal map of flags to build settings.
- for (std::set<std::string>::iterator li = languages.begin();
- li != languages.end(); ++li) {
- std::string& flags = cflags[*li];
- std::string& gflag = gflags[*li];
+ for (auto const& language : languages) {
+ std::string& flags = cflags[language];
+ std::string& gflag = gflags[language];
std::string oflag =
this->ExtractFlagRegex("(^| )(-Ofast|-Os|-O[0-9]*)( |$)", 2, flags);
if (oflag.size() == 2) {
@@ -2070,16 +2215,34 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
if (!same_gflags) {
// We can't set the Xcode flag differently depending on the language,
// so put them back in this case.
- for (std::set<std::string>::iterator li = languages.begin();
- li != languages.end(); ++li) {
- cflags[*li] += " ";
- cflags[*li] += gflags[*li];
+ for (auto const& language : languages) {
+ cflags[language] += " ";
+ cflags[language] += gflags[language];
}
debugStr = "NO";
} else if (last_gflag && (last_gflag->empty() || *last_gflag == "-g0")) {
debugStr = "NO";
}
+ // extract C++ stdlib
+ for (auto const& language : languages) {
+ if (language != "CXX" && language != "OBJCXX") {
+ continue;
+ }
+ std::string& flags = cflags[language];
+
+ auto stdlib =
+ this->ExtractFlagRegex("(^| )(-stdlib=[^ ]+)( |$)", 2, flags);
+ if (stdlib.size() > 8) {
+ const auto cxxLibrary = stdlib.substr(8);
+ if (language == "CXX" ||
+ !buildSettings->GetObject("CLANG_CXX_LIBRARY")) {
+ buildSettings->AddAttribute("CLANG_CXX_LIBRARY",
+ this->CreateString(cxxLibrary));
+ }
+ }
+ }
+
buildSettings->AddAttribute("COMBINE_HIDPI_IMAGES",
this->CreateString("YES"));
buildSettings->AddAttribute("GCC_GENERATE_DEBUGGING_SYMBOLS",
@@ -2090,25 +2253,30 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
this->CreateString("NO"));
buildSettings->AddAttribute("GCC_INLINES_ARE_PRIVATE_EXTERN",
this->CreateString("NO"));
- for (std::set<std::string>::iterator li = languages.begin();
- li != languages.end(); ++li) {
- std::string flags = cflags[*li] + " " + defFlags;
- if (*li == "CXX") {
- buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS",
- this->CreateString(flags));
- } else if (*li == "Fortran") {
+
+ for (auto const& language : languages) {
+ std::string flags = cflags[language] + " " + defFlags;
+ if (language == "CXX" || language == "OBJCXX") {
+ if (language == "CXX" ||
+ !buildSettings->GetObject("OTHER_CPLUSPLUSFLAGS")) {
+ buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS",
+ this->CreateString(flags));
+ }
+ } else if (language == "Fortran") {
buildSettings->AddAttribute("IFORT_OTHER_FLAGS",
this->CreateString(flags));
- } else if (*li == "C") {
- buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags));
- } else if (*li == "Swift") {
+ } else if (language == "C" || language == "OBJC") {
+ if (language == "C" || !buildSettings->GetObject("OTHER_CFLAGS")) {
+ buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags));
+ }
+ } else if (language == "Swift") {
buildSettings->AddAttribute("OTHER_SWIFT_FLAGS",
this->CreateString(flags));
}
}
// Add Fortran source format attribute if property is set.
- const char* format = 0;
+ const char* format = nullptr;
const char* tgtfmt = gtgt->GetProperty("Fortran_FORMAT");
switch (cmOutputConverter::GetFortranFormat(tgtfmt)) {
case cmOutputConverter::FortranFormatFixed:
@@ -2162,9 +2330,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// runpath dirs needs to be unique to prevent corruption
std::set<std::string> unique_dirs;
- for (std::vector<std::string>::const_iterator i = runtimeDirs.begin();
- i != runtimeDirs.end(); ++i) {
- std::string runpath = *i;
+ for (auto runpath : runtimeDirs) {
runpath = this->ExpandCFGIntDir(runpath, configName);
if (unique_dirs.find(runpath) == unique_dirs.end()) {
@@ -2221,20 +2387,26 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
this->CreateString(vso.str()));
}
+
+ // Precompile Headers
+ std::string pchHeader = gtgt->GetPchHeader(configName, llang);
+ if (!pchHeader.empty()) {
+ buildSettings->AddAttribute("GCC_PREFIX_HEADER",
+ this->CreateString(pchHeader));
+ buildSettings->AddAttribute("GCC_PRECOMPILE_PREFIX_HEADER",
+ this->CreateString("YES"));
+ }
+
// put this last so it can override existing settings
// Convert "XCODE_ATTRIBUTE_*" properties directly.
{
- std::vector<std::string> const& props = gtgt->GetPropertyKeys();
- for (std::vector<std::string>::const_iterator i = props.begin();
- i != props.end(); ++i) {
- if (i->find("XCODE_ATTRIBUTE_") == 0) {
- std::string attribute = i->substr(16);
+ for (auto const& prop : gtgt->GetPropertyKeys()) {
+ if (prop.find("XCODE_ATTRIBUTE_") == 0) {
+ std::string attribute = prop.substr(16);
this->FilterConfigurationAttribute(configName, attribute);
if (!attribute.empty()) {
- cmGeneratorExpression ge;
- std::string processed =
- ge.Parse(gtgt->GetProperty(*i))
- ->Evaluate(this->CurrentLocalGenerator, configName);
+ std::string processed = cmGeneratorExpression::Evaluate(
+ gtgt->GetProperty(prop), this->CurrentLocalGenerator, configName);
buildSettings->AddAttribute(attribute,
this->CreateString(processed));
}
@@ -2268,8 +2440,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget(
target->SetComment(gtgt->GetName());
cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST);
std::vector<cmXCodeObject*> emptyContentVector;
- this->CreateCustomCommands(buildPhases, 0, 0, 0, emptyContentVector, 0,
- gtgt);
+ this->CreateCustomCommands(buildPhases, nullptr, nullptr, nullptr,
+ emptyContentVector, nullptr, gtgt);
target->AddAttribute("buildPhases", buildPhases);
this->AddConfigurations(target, gtgt);
cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST);
@@ -2280,16 +2452,19 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget(
this->XCodeObjectMap[gtgt] = target;
// Add source files without build rules for editing convenience.
- if (gtgt->GetType() == cmStateEnums::UTILITY) {
+ if (gtgt->GetType() == cmStateEnums::UTILITY &&
+ gtgt->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
std::vector<cmSourceFile*> sources;
if (!gtgt->GetConfigCommonSourceFiles(sources)) {
- return 0;
+ return nullptr;
}
- for (std::vector<cmSourceFile*>::const_iterator i = sources.begin();
- i != sources.end(); ++i) {
- if (!(*i)->GetPropertyAsBool("GENERATED")) {
- this->CreateXCodeFileReference(*i, gtgt);
+ // Add CMakeLists.txt file for user convenience.
+ this->AddXCodeProjBuildRule(gtgt, sources);
+
+ for (auto sourceFile : sources) {
+ if (!sourceFile->GetIsGenerated()) {
+ this->CreateXCodeFileReference(sourceFile, gtgt);
}
}
}
@@ -2302,34 +2477,28 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget(
std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target,
cmGeneratorTarget* gtgt)
{
- std::string configTypes =
- this->CurrentMakefile->GetRequiredDefinition("CMAKE_CONFIGURATION_TYPES");
- std::vector<std::string> configVectorIn;
- std::vector<std::string> configVector;
- configVectorIn.push_back(configTypes);
- cmSystemTools::ExpandList(configVectorIn, configVector);
+ std::vector<std::string> const configVector = cmExpandedList(
+ this->CurrentMakefile->GetRequiredDefinition("CMAKE_CONFIGURATION_TYPES"));
cmXCodeObject* configlist =
this->CreateObject(cmXCodeObject::XCConfigurationList);
cmXCodeObject* buildConfigurations =
this->CreateObject(cmXCodeObject::OBJECT_LIST);
configlist->AddAttribute("buildConfigurations", buildConfigurations);
- std::string comment = "Build configuration list for ";
- comment += cmXCodeObject::PBXTypeNames[target->GetIsA()];
- comment += " \"";
- comment += gtgt->GetName();
- comment += "\"";
+ std::string comment = cmStrCat("Build configuration list for ",
+ cmXCodeObject::PBXTypeNames[target->GetIsA()],
+ " \"", gtgt->GetName(), '"');
configlist->SetComment(comment);
target->AddAttribute("buildConfigurationList",
this->CreateObjectReference(configlist));
- for (unsigned int i = 0; i < configVector.size(); ++i) {
+ for (auto const& i : configVector) {
cmXCodeObject* config =
this->CreateObject(cmXCodeObject::XCBuildConfiguration);
buildConfigurations->AddObject(config);
cmXCodeObject* buildSettings =
this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
- this->CreateBuildSettings(gtgt, buildSettings, configVector[i]);
- config->AddAttribute("name", this->CreateString(configVector[i]));
- config->SetComment(configVector[i]);
+ this->CreateBuildSettings(gtgt, buildSettings, i);
+ config->AddAttribute("name", this->CreateString(i));
+ config->SetComment(i);
config->AddAttribute("buildSettings", buildSettings);
}
if (!configVector.empty()) {
@@ -2349,9 +2518,8 @@ const char* cmGlobalXCodeGenerator::GetTargetLinkFlagsVar(
(target->GetType() == cmStateEnums::STATIC_LIBRARY ||
target->GetType() == cmStateEnums::OBJECT_LIBRARY)) {
return "OTHER_LIBTOOLFLAGS";
- } else {
- return "OTHER_LDFLAGS";
}
+ return "OTHER_LDFLAGS";
}
const char* cmGlobalXCodeGenerator::GetTargetFileType(
@@ -2368,12 +2536,13 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(
return (target->GetPropertyAsBool("FRAMEWORK") ? "wrapper.framework"
: "archive.ar");
case cmStateEnums::MODULE_LIBRARY:
- if (target->IsXCTestOnApple())
+ if (target->IsXCTestOnApple()) {
return "wrapper.cfbundle";
- else if (target->IsCFBundleOnApple())
+ }
+ if (target->IsCFBundleOnApple()) {
return "wrapper.plug-in";
- else
- return "compiled.mach-o.executable";
+ }
+ return "compiled.mach-o.executable";
case cmStateEnums::SHARED_LIBRARY:
return (target->GetPropertyAsBool("FRAMEWORK")
? "wrapper.framework"
@@ -2383,7 +2552,7 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(
default:
break;
}
- return 0;
+ return nullptr;
}
const char* cmGlobalXCodeGenerator::GetTargetProductType(
@@ -2401,12 +2570,13 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType(
? "com.apple.product-type.framework"
: "com.apple.product-type.library.static");
case cmStateEnums::MODULE_LIBRARY:
- if (target->IsXCTestOnApple())
+ if (target->IsXCTestOnApple()) {
return "com.apple.product-type.bundle.unit-test";
- else if (target->IsCFBundleOnApple())
+ } else if (target->IsCFBundleOnApple()) {
return "com.apple.product-type.bundle";
- else
+ } else {
return "com.apple.product-type.tool";
+ }
case cmStateEnums::SHARED_LIBRARY:
return (target->GetPropertyAsBool("FRAMEWORK")
? "com.apple.product-type.framework"
@@ -2418,14 +2588,14 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType(
default:
break;
}
- return 0;
+ return nullptr;
}
cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(
cmGeneratorTarget* gtgt, cmXCodeObject* buildPhases)
{
if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
- return 0;
+ return nullptr;
}
cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget);
target->AddAttribute("buildPhases", buildPhases);
@@ -2444,9 +2614,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(
}
std::string fullName;
if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
- fullName = "lib";
- fullName += gtgt->GetName();
- fullName += ".a";
+ fullName = cmStrCat("lib", gtgt->GetName(), ".a");
} else {
fullName = gtgt->GetFullName(defConfig);
}
@@ -2469,13 +2637,12 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(
cmGeneratorTarget const* t)
{
if (!t) {
- return 0;
+ return nullptr;
}
- std::map<cmGeneratorTarget const*, cmXCodeObject*>::const_iterator const i =
- this->XCodeObjectMap.find(t);
+ auto const i = this->XCodeObjectMap.find(t);
if (i == this->XCodeObjectMap.end()) {
- return 0;
+ return nullptr;
}
return i->second;
}
@@ -2483,8 +2650,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(
std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
const std::string& id)
{
- std::string guidStoreName = name;
- guidStoreName += "_GUID_CMAKE";
+ std::string guidStoreName = cmStrCat(name, "_GUID_CMAKE");
const char* storedGUID =
this->CMakeInstance->GetCacheDefinition(guidStoreName);
@@ -2539,9 +2705,7 @@ void cmGlobalXCodeGenerator::AppendOrAddBuildSetting(cmXCodeObject* settings,
if (!attr) {
settings->AddAttribute(attribute, this->CreateString(value));
} else {
- std::string oldValue = attr->GetString();
- oldValue += " ";
- oldValue += value;
+ std::string oldValue = cmStrCat(attr->GetString(), ' ', value);
attr->SetString(oldValue);
}
}
@@ -2557,18 +2721,10 @@ void cmGlobalXCodeGenerator::AppendBuildSettingAttribute(
target->GetObject("buildConfigurationList")->GetObject();
cmXCodeObject* buildConfigs =
configurationList->GetObject("buildConfigurations");
- std::vector<cmXCodeObject*> list = buildConfigs->GetObjectList();
- // each configuration and the target itself has a buildSettings in it
- // list.push_back(target);
- for (std::vector<cmXCodeObject*>::iterator i = list.begin(); i != list.end();
- ++i) {
- if (!configName.empty()) {
- if ((*i)->GetObject("name")->GetString() == configName) {
- cmXCodeObject* settings = (*i)->GetObject("buildSettings");
- this->AppendOrAddBuildSetting(settings, attribute, value);
- }
- } else {
- cmXCodeObject* settings = (*i)->GetObject("buildSettings");
+ for (auto obj : buildConfigs->GetObjectList()) {
+ if (configName.empty() ||
+ obj->GetObject("name")->GetString() == configName) {
+ cmXCodeObject* settings = obj->GetObject("buildSettings");
this->AppendOrAddBuildSetting(settings, attribute, value);
}
}
@@ -2586,35 +2742,27 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
}
// Add dependencies on other CMake targets.
- TargetDependSet const& deps = this->GetTargetDirectDepends(gt);
- for (TargetDependSet::const_iterator i = deps.begin(); i != deps.end();
- ++i) {
- if (cmXCodeObject* dptarget = this->FindXCodeTarget(*i)) {
+ for (const auto& dep : this->GetTargetDirectDepends(gt)) {
+ if (cmXCodeObject* dptarget = this->FindXCodeTarget(dep)) {
this->AddDependTarget(target, dptarget);
}
}
// Loop over configuration types and set per-configuration info.
- for (std::vector<std::string>::iterator i =
- this->CurrentConfigurationTypes.begin();
- i != this->CurrentConfigurationTypes.end(); ++i) {
- // Get the current configuration name.
- std::string configName = *i;
-
- if (this->XcodeVersion >= 50) {
+ for (auto const& configName : this->CurrentConfigurationTypes) {
+ {
// Add object library contents as link flags.
std::string linkObjs;
const char* sep = "";
std::vector<cmSourceFile const*> objs;
gt->GetExternalObjects(objs, configName);
- for (std::vector<cmSourceFile const*>::const_iterator oi = objs.begin();
- oi != objs.end(); ++oi) {
- if ((*oi)->GetObjectLibrary().empty()) {
+ for (auto sourceFile : objs) {
+ if (sourceFile->GetObjectLibrary().empty()) {
continue;
}
linkObjs += sep;
sep = " ";
- linkObjs += this->XCodeEscapePath((*oi)->GetFullPath());
+ linkObjs += this->XCodeEscapePath(sourceFile->GetFullPath());
}
this->AppendBuildSettingAttribute(
target, this->GetTargetLinkFlagsVar(gt), linkObjs.c_str(), configName);
@@ -2634,28 +2782,22 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
cmComputeLinkInformation& cli = *pcli;
// Add dependencies directly on library files.
- {
- std::vector<std::string> const& libDeps = cli.GetDepends();
- for (std::vector<std::string>::const_iterator j = libDeps.begin();
- j != libDeps.end(); ++j) {
- target->AddDependLibrary(configName, *j);
- }
+ for (auto const& libDep : cli.GetDepends()) {
+ target->AddDependLibrary(configName, libDep);
}
// add the library search paths
{
- std::vector<std::string> const& libDirs = cli.GetDirectories();
std::string linkDirs;
- for (std::vector<std::string>::const_iterator libDir = libDirs.begin();
- libDir != libDirs.end(); ++libDir) {
- if (libDir->size() && *libDir != "/usr/lib") {
+ for (auto const& libDir : cli.GetDirectories()) {
+ if (!libDir.empty() && libDir != "/usr/lib") {
// Now add the same one but append
// $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it:
linkDirs += " ";
linkDirs += this->XCodeEscapePath(
- *libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)");
+ libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)");
linkDirs += " ";
- linkDirs += this->XCodeEscapePath(*libDir);
+ linkDirs += this->XCodeEscapePath(libDir);
}
}
this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS",
@@ -2666,20 +2808,18 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
{
std::string linkLibs;
const char* sep = "";
- typedef cmComputeLinkInformation::ItemVector ItemVector;
- ItemVector const& libNames = cli.GetItems();
- for (ItemVector::const_iterator li = libNames.begin();
- li != libNames.end(); ++li) {
+ for (auto const& libName : cli.GetItems()) {
linkLibs += sep;
sep = " ";
- if (li->IsPath) {
- linkLibs += this->XCodeEscapePath(li->Value);
- } else if (!li->Target ||
- li->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
- linkLibs += li->Value;
+ if (libName.IsPath) {
+ linkLibs += this->XCodeEscapePath(libName.Value);
+ } else if (!libName.Target ||
+ libName.Target->GetType() !=
+ cmStateEnums::INTERFACE_LIBRARY) {
+ linkLibs += libName.Value;
}
- if (li->Target && !li->Target->IsImported()) {
- target->AddDependTarget(configName, li->Target->GetName());
+ if (libName.Target && !libName.Target->IsImported()) {
+ target->AddDependTarget(configName, libName.Target->GetName());
}
}
this->AppendBuildSettingAttribute(
@@ -2691,17 +2831,12 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
bool cmGlobalXCodeGenerator::CreateGroups(
std::vector<cmLocalGenerator*>& generators)
{
- for (std::vector<cmLocalGenerator*>::iterator i = generators.begin();
- i != generators.end(); ++i) {
- cmMakefile* mf = (*i)->GetMakefile();
+ for (auto& generator : generators) {
+ cmMakefile* mf = generator->GetMakefile();
std::vector<cmSourceGroup> sourceGroups = mf->GetSourceGroups();
- std::vector<cmGeneratorTarget*> tgts = (*i)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); l++) {
- cmGeneratorTarget* gtgt = *l;
-
+ for (auto gtgt : generator->GetGeneratorTargets()) {
// Same skipping logic here as in CreateXCodeTargets so that we do not
- // end up with (empty anyhow) ALL_BUILD and XCODE_DEPEND_HELPER source
+ // end up with (empty anyhow) ZERO_CHECK, install, or test source
// groups:
//
if (gtgt->GetType() == cmStateEnums::GLOBAL_TARGET) {
@@ -2710,34 +2845,44 @@ bool cmGlobalXCodeGenerator::CreateGroups(
if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
-
- // add the soon to be generated Info.plist file as a source for a
- // MACOSX_BUNDLE file
- if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) {
- std::string plist = this->ComputeInfoPListLocation(gtgt);
- mf->GetOrCreateSource(plist, true);
- gtgt->AddSource(plist);
+ if (gtgt->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
+ continue;
}
- std::vector<cmGeneratorTarget::AllConfigSource> const& sources =
- gtgt->GetAllConfigSources();
+ auto addSourceToGroup = [this, mf, gtgt,
+ &sourceGroups](std::string const& source) {
+ cmSourceGroup* sourceGroup = mf->FindSourceGroup(source, sourceGroups);
+ cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(gtgt, sourceGroup);
+ std::string key = GetGroupMapKeyFromPath(gtgt, source);
+ this->GroupMap[key] = pbxgroup;
+ };
// Put cmSourceFile instances in proper groups:
- for (std::vector<cmGeneratorTarget::AllConfigSource>::const_iterator si =
- sources.begin();
- si != sources.end(); ++si) {
- cmSourceFile const* sf = si->Source;
- if (this->XcodeVersion >= 50 && !sf->GetObjectLibrary().empty()) {
+ for (auto const& si : gtgt->GetAllConfigSources()) {
+ cmSourceFile const* sf = si.Source;
+ if (!sf->GetObjectLibrary().empty()) {
// Object library files go on the link line instead.
continue;
}
- // Add the file to the list of sources.
- std::string const& source = sf->GetFullPath();
- cmSourceGroup* sourceGroup =
- mf->FindSourceGroup(source.c_str(), sourceGroups);
- cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(gtgt, sourceGroup);
- std::string key = GetGroupMapKeyFromPath(gtgt, source);
- this->GroupMap[key] = pbxgroup;
+ addSourceToGroup(sf->GetFullPath());
+ }
+
+ // Add CMakeLists.txt file for user convenience.
+ {
+ std::string listfile =
+ cmStrCat(gtgt->GetLocalGenerator()->GetCurrentSourceDirectory(),
+ "/CMakeLists.txt");
+ cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(
+ listfile, false, cmSourceFileLocationKind::Known);
+ addSourceToGroup(sf->ResolveFullPath());
+ }
+
+ // Add the Info.plist we are about to generate for an App Bundle.
+ if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) {
+ std::string plist = this->ComputeInfoPListLocation(gtgt);
+ cmSourceFile* sf = gtgt->Makefile->GetOrCreateSource(
+ plist, true, cmSourceFileLocationKind::Known);
+ addSourceToGroup(sf->ResolveFullPath());
}
}
}
@@ -2745,19 +2890,21 @@ bool cmGlobalXCodeGenerator::CreateGroups(
}
cmXCodeObject* cmGlobalXCodeGenerator::CreatePBXGroup(cmXCodeObject* parent,
- std::string name)
+ const std::string& name)
{
- cmXCodeObject* parentChildren = NULL;
- if (parent)
+ cmXCodeObject* parentChildren = nullptr;
+ if (parent) {
parentChildren = parent->GetObject("children");
+ }
cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
cmXCodeObject* groupChildren =
this->CreateObject(cmXCodeObject::OBJECT_LIST);
group->AddAttribute("name", this->CreateString(name));
group->AddAttribute("children", groupChildren);
group->AddAttribute("sourceTree", this->CreateString("<group>"));
- if (parentChildren)
+ if (parentChildren) {
parentChildren->AddObject(group);
+ }
return group;
}
@@ -2768,25 +2915,21 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup(
std::string target;
const std::string targetFolder = gtgt->GetEffectiveFolderName();
if (!targetFolder.empty()) {
- target = targetFolder;
- target += "/";
+ target = cmStrCat(targetFolder, '/');
}
target += gtgt->GetName();
- s = target + "/";
- s += sg->GetFullName();
- std::map<std::string, cmXCodeObject*>::iterator it =
- this->GroupNameMap.find(s);
+ s = cmStrCat(target, '/', sg->GetFullName());
+ auto it = this->GroupNameMap.find(s);
if (it != this->GroupNameMap.end()) {
return it->second;
}
it = this->TargetGroup.find(target);
- cmXCodeObject* tgroup = 0;
+ cmXCodeObject* tgroup = nullptr;
if (it != this->TargetGroup.end()) {
tgroup = it->second;
} else {
- std::vector<std::string> tgt_folders =
- cmSystemTools::tokenize(target, "/");
+ std::vector<std::string> tgt_folders = cmTokenize(target, "/");
std::string curr_tgt_folder;
for (std::vector<std::string>::size_type i = 0; i < tgt_folders.size();
i++) {
@@ -2811,30 +2954,26 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup(
// If it's the default source group (empty name) then put the source file
// directly in the tgroup...
//
- if (std::string(sg->GetFullName()) == "") {
+ if (sg->GetFullName().empty()) {
this->GroupNameMap[s] = tgroup;
return tgroup;
}
// It's a recursive folder structure, let's find the real parent group
- if (std::string(sg->GetFullName()) != std::string(sg->GetName())) {
- std::vector<std::string> folders =
- cmSystemTools::tokenize(sg->GetFullName(), "\\");
- std::string curr_folder = target;
- curr_folder += "/";
- for (std::vector<std::string>::size_type i = 0; i < folders.size(); i++) {
- curr_folder += folders[i];
- std::map<std::string, cmXCodeObject*>::iterator i_folder =
- this->GroupNameMap.find(curr_folder);
+ if (sg->GetFullName() != sg->GetName()) {
+ std::string curr_folder = cmStrCat(target, '/');
+ for (auto const& folder : cmTokenize(sg->GetFullName(), "\\")) {
+ curr_folder += folder;
+ auto const i_folder = this->GroupNameMap.find(curr_folder);
// Create new folder
if (i_folder == this->GroupNameMap.end()) {
- cmXCodeObject* group = this->CreatePBXGroup(tgroup, folders[i]);
+ cmXCodeObject* group = this->CreatePBXGroup(tgroup, folder);
this->GroupNameMap[curr_folder] = group;
tgroup = group;
} else {
tgroup = i_folder->second;
}
- curr_folder = curr_folder + "\\";
+ curr_folder += "\\";
}
return tgroup;
}
@@ -2847,15 +2986,16 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
{
this->ClearXCodeObjects();
- this->RootObject = 0;
- this->MainGroupChildren = 0;
+ this->RootObject = nullptr;
+ this->MainGroupChildren = nullptr;
cmXCodeObject* group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO"));
cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
- for (unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) {
+ for (const std::string& CurrentConfigurationType :
+ this->CurrentConfigurationTypes) {
cmXCodeObject* buildStyle =
this->CreateObject(cmXCodeObject::PBXBuildStyle);
- const char* name = this->CurrentConfigurationTypes[i].c_str();
+ const std::string& name = CurrentConfigurationType;
buildStyle->AddAttribute("name", this->CreateString(name));
buildStyle->SetComment(name);
cmXCodeObject* sgroup = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
@@ -2885,10 +3025,9 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
this->RootObject = this->CreateObject(cmXCodeObject::PBXProject);
this->RootObject->SetComment("Project object");
- std::string project_id = "PROJECT_";
- project_id += root->GetProjectName();
+ std::string project_id = cmStrCat("PROJECT_", root->GetProjectName());
this->RootObject->SetId(
- this->GetOrCreateId(project_id.c_str(), this->RootObject->GetId()));
+ this->GetOrCreateId(project_id, this->RootObject->GetId()));
group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
this->RootObject->AddAttribute("mainGroup",
@@ -2904,15 +3043,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
v << std::setfill('0') << std::setw(4) << XcodeVersion * 10;
group->AddAttribute("LastUpgradeCheck", this->CreateString(v.str()));
this->RootObject->AddAttribute("attributes", group);
- if (this->XcodeVersion >= 32)
- this->RootObject->AddAttribute("compatibilityVersion",
- this->CreateString("Xcode 3.2"));
- else if (this->XcodeVersion >= 31)
- this->RootObject->AddAttribute("compatibilityVersion",
- this->CreateString("Xcode 3.1"));
- else
- this->RootObject->AddAttribute("compatibilityVersion",
- this->CreateString("Xcode 3.0"));
+ this->RootObject->AddAttribute("compatibilityVersion",
+ this->CreateString("Xcode 3.2"));
// Point Xcode at the top of the source tree.
{
std::string pdir =
@@ -2924,12 +3056,11 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
this->CreateObject(cmXCodeObject::XCConfigurationList);
cmXCodeObject* buildConfigurations =
this->CreateObject(cmXCodeObject::OBJECT_LIST);
- typedef std::vector<std::pair<std::string, cmXCodeObject*> > Configs;
+ using Configs = std::vector<std::pair<std::string, cmXCodeObject*>>;
Configs configs;
- const char* defaultConfigName = "Debug";
- for (unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) {
- const char* name = this->CurrentConfigurationTypes[i].c_str();
- if (0 == i) {
+ std::string defaultConfigName;
+ for (const auto& name : this->CurrentConfigurationTypes) {
+ if (defaultConfigName.empty()) {
defaultConfigName = name;
}
cmXCodeObject* config =
@@ -2937,15 +3068,16 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
config->AddAttribute("name", this->CreateString(name));
configs.push_back(std::make_pair(name, config));
}
- for (Configs::iterator c = configs.begin(); c != configs.end(); ++c) {
- buildConfigurations->AddObject(c->second);
+ if (defaultConfigName.empty()) {
+ defaultConfigName = "Debug";
+ }
+ for (auto& config : configs) {
+ buildConfigurations->AddObject(config.second);
}
configlist->AddAttribute("buildConfigurations", buildConfigurations);
- std::string comment = "Build configuration list for PBXProject";
- comment += " \"";
- comment += this->CurrentProject;
- comment += "\"";
+ std::string comment = cmStrCat("Build configuration list for PBXProject \"",
+ this->CurrentProject, '"');
configlist->SetComment(comment);
configlist->AddAttribute("defaultConfigurationIsVisible",
this->CreateString("0"));
@@ -2971,7 +3103,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
buildSettings->AddAttribute("ARCHS", this->CreateString(archs));
}
if (deploymentTarget && *deploymentTarget) {
- buildSettings->AddAttribute("MACOSX_DEPLOYMENT_TARGET",
+ buildSettings->AddAttribute(GetDeploymentPlatform(root->GetMakefile()),
this->CreateString(deploymentTarget));
}
if (!this->GeneratorToolset.empty()) {
@@ -2983,6 +3115,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
if (const char* vers = this->CurrentMakefile->GetDefinition(
"CMAKE_Swift_LANGUAGE_VERSION")) {
swiftVersion = vers;
+ } else if (this->XcodeVersion >= 102) {
+ swiftVersion = "4.0";
} else if (this->XcodeVersion >= 83) {
swiftVersion = "3.0";
} else {
@@ -2992,57 +3126,48 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
this->CreateString(swiftVersion));
}
- std::string symroot = root->GetCurrentBinaryDirectory();
- symroot += "/build";
+ std::string symroot = cmStrCat(root->GetCurrentBinaryDirectory(), "/build");
buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot));
- for (Configs::iterator i = configs.begin(); i != configs.end(); ++i) {
+ for (auto& config : configs) {
cmXCodeObject* buildSettingsForCfg = this->CreateFlatClone(buildSettings);
// Put this last so it can override existing settings
// Convert "CMAKE_XCODE_ATTRIBUTE_*" variables directly.
- std::vector<std::string> vars = this->CurrentMakefile->GetDefinitions();
- for (std::vector<std::string>::const_iterator d = vars.begin();
- d != vars.end(); ++d) {
- if (d->find("CMAKE_XCODE_ATTRIBUTE_") == 0) {
- std::string attribute = d->substr(22);
- this->FilterConfigurationAttribute(i->first, attribute);
+ for (const auto& var : this->CurrentMakefile->GetDefinitions()) {
+ if (var.find("CMAKE_XCODE_ATTRIBUTE_") == 0) {
+ std::string attribute = var.substr(22);
+ this->FilterConfigurationAttribute(config.first, attribute);
if (!attribute.empty()) {
- cmGeneratorExpression ge;
- std::string processed =
- ge.Parse(this->CurrentMakefile->GetDefinition(*d))
- ->Evaluate(this->CurrentLocalGenerator, i->first);
+ std::string processed = cmGeneratorExpression::Evaluate(
+ this->CurrentMakefile->GetDefinition(var),
+ this->CurrentLocalGenerator, config.first);
buildSettingsForCfg->AddAttribute(attribute,
this->CreateString(processed));
}
}
}
// store per-config buildSettings into configuration object
- i->second->AddAttribute("buildSettings", buildSettingsForCfg);
+ config.second->AddAttribute("buildSettings", buildSettingsForCfg);
}
this->RootObject->AddAttribute("buildConfigurationList",
this->CreateObjectReference(configlist));
std::vector<cmXCodeObject*> targets;
- for (std::vector<cmLocalGenerator*>::iterator i = generators.begin();
- i != generators.end(); ++i) {
- if (!this->CreateXCodeTargets(*i, targets)) {
+ for (auto& generator : generators) {
+ if (!this->CreateXCodeTargets(generator, targets)) {
return false;
}
}
// loop over all targets and add link and depend info
- for (std::vector<cmXCodeObject*>::iterator i = targets.begin();
- i != targets.end(); ++i) {
- cmXCodeObject* t = *i;
+ for (auto t : targets) {
this->AddDependAndLinkInformation(t);
}
this->CreateXCodeDependHackTarget(targets);
// now add all targets to the root object
cmXCodeObject* allTargets = this->CreateObject(cmXCodeObject::OBJECT_LIST);
- for (std::vector<cmXCodeObject*>::iterator i = targets.begin();
- i != targets.end(); ++i) {
- cmXCodeObject* t = *i;
+ for (auto t : targets) {
allTargets->AddObject(t);
cmXCodeObject* productRef = t->GetObject("productReference");
if (productRef) {
@@ -3053,19 +3178,13 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
return true;
}
-std::string cmGlobalXCodeGenerator::GetObjectsNormalDirectory(
+std::string cmGlobalXCodeGenerator::GetObjectsDirectory(
const std::string& projName, const std::string& configName,
- const cmGeneratorTarget* t) const
+ const cmGeneratorTarget* t, const std::string& variant) const
{
- std::string dir = t->GetLocalGenerator()->GetCurrentBinaryDirectory();
- dir += "/";
- dir += projName;
- dir += ".build/";
- dir += configName;
- dir += "/";
- dir += t->GetName();
- dir += ".build/Objects-normal/";
-
+ std::string dir = cmStrCat(
+ t->GetLocalGenerator()->GetCurrentBinaryDirectory(), '/', projName,
+ ".build/", configName, '/', t->GetName(), ".build/", variant);
return dir;
}
@@ -3075,15 +3194,19 @@ void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf)
const char* osxArch = mf->GetDefinition("CMAKE_OSX_ARCHITECTURES");
const char* sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT");
if (osxArch && sysroot) {
- cmSystemTools::ExpandListArgument(std::string(osxArch),
- this->Architectures);
+ cmExpandList(std::string(osxArch), this->Architectures);
}
if (this->Architectures.empty()) {
// With no ARCHS we use ONLY_ACTIVE_ARCH.
// Look up the arch that Xcode chooses in this case.
- if (const char* arch = mf->GetDefinition("CMAKE_XCODE_CURRENT_ARCH")) {
+ if (const char* arch = mf->GetDefinition("CMAKE_XCODE_ARCHS")) {
this->ObjectDirArchDefault = arch;
+ // We expect only one arch but choose the first just in case.
+ std::string::size_type pos = this->ObjectDirArchDefault.find(';');
+ if (pos != std::string::npos) {
+ this->ObjectDirArchDefault = this->ObjectDirArchDefault.substr(0, pos);
+ }
}
}
@@ -3104,10 +3227,9 @@ void cmGlobalXCodeGenerator::ComputeObjectDirArch(cmMakefile* mf)
void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
std::vector<cmXCodeObject*>& targets)
{
- cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile.c_str());
+ cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile);
if (!makefileStream) {
- cmSystemTools::Error("Could not create",
- this->CurrentXCodeHackMakefile.c_str());
+ cmSystemTools::Error("Could not create " + this->CurrentXCodeHackMakefile);
return;
}
makefileStream.SetCopyIfDifferent(true);
@@ -3131,13 +3253,8 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
"# link. This forces Xcode to relink the targets from scratch. It\n"
"# does not seem to check these dependencies itself.\n";
/* clang-format on */
- for (std::vector<std::string>::const_iterator ct =
- this->CurrentConfigurationTypes.begin();
- ct != this->CurrentConfigurationTypes.end(); ++ct) {
- std::string configName = *ct;
- for (std::vector<cmXCodeObject*>::iterator i = targets.begin();
- i != targets.end(); ++i) {
- cmXCodeObject* target = *i;
+ for (const auto& configName : this->CurrentConfigurationTypes) {
+ for (auto target : targets) {
cmGeneratorTarget* gt = target->GetTarget();
if (gt->GetType() == cmStateEnums::EXECUTABLE ||
@@ -3146,7 +3263,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
gt->GetType() == cmStateEnums::SHARED_LIBRARY ||
gt->GetType() == cmStateEnums::MODULE_LIBRARY) {
// Declare an entry point for the target post-build phase.
- makefileStream << this->PostBuildMakeTarget(gt->GetName(), *ct)
+ makefileStream << this->PostBuildMakeTarget(gt->GetName(), configName)
<< ":\n";
}
@@ -3155,26 +3272,22 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
gt->GetType() == cmStateEnums::SHARED_LIBRARY ||
gt->GetType() == cmStateEnums::MODULE_LIBRARY) {
std::string tfull = gt->GetFullPath(configName);
- std::string trel = this->ConvertToRelativeForMake(tfull.c_str());
+ std::string trel = this->ConvertToRelativeForMake(tfull);
// Add this target to the post-build phases of its dependencies.
- std::map<std::string, cmXCodeObject::StringVec>::const_iterator y =
- target->GetDependTargets().find(*ct);
+ auto const y = target->GetDependTargets().find(configName);
if (y != target->GetDependTargets().end()) {
- std::vector<std::string> const& deptgts = y->second;
- for (std::vector<std::string>::const_iterator d = deptgts.begin();
- d != deptgts.end(); ++d) {
- makefileStream << this->PostBuildMakeTarget(*d, *ct) << ": "
- << trel << "\n";
+ for (auto const& deptgt : y->second) {
+ makefileStream << this->PostBuildMakeTarget(deptgt, configName)
+ << ": " << trel << "\n";
}
}
std::vector<cmGeneratorTarget*> objlibs;
gt->GetObjectLibrariesCMP0026(objlibs);
- for (std::vector<cmGeneratorTarget*>::const_iterator it =
- objlibs.begin();
- it != objlibs.end(); ++it) {
- makefileStream << this->PostBuildMakeTarget((*it)->GetName(), *ct)
+ for (auto objLib : objlibs) {
+ makefileStream << this->PostBuildMakeTarget(objLib->GetName(),
+ configName)
<< ": " << trel << "\n";
}
@@ -3182,30 +3295,24 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
makefileStream << trel << ":";
// List dependencies if any exist.
- std::map<std::string, cmXCodeObject::StringVec>::const_iterator x =
- target->GetDependLibraries().find(*ct);
+ auto const x = target->GetDependLibraries().find(configName);
if (x != target->GetDependLibraries().end()) {
- std::vector<std::string> const& deplibs = x->second;
- for (std::vector<std::string>::const_iterator d = deplibs.begin();
- d != deplibs.end(); ++d) {
- std::string file = this->ConvertToRelativeForMake(d->c_str());
+ for (auto const& deplib : x->second) {
+ std::string file = this->ConvertToRelativeForMake(deplib);
makefileStream << "\\\n\t" << file;
dummyRules.insert(file);
}
}
- for (std::vector<cmGeneratorTarget*>::const_iterator it =
- objlibs.begin();
- it != objlibs.end(); ++it) {
+ for (auto objLib : objlibs) {
- const std::string objLibName = (*it)->GetName();
- std::string d = this->GetObjectsNormalDirectory(this->CurrentProject,
- configName, *it);
- d += "lib";
- d += objLibName;
- d += ".a";
+ const std::string objLibName = objLib->GetName();
+ std::string d = cmStrCat(
+ this->GetObjectsDirectory(this->CurrentProject, configName, objLib,
+ OBJECT_LIBRARY_ARTIFACT_DIR),
+ "lib", objLibName, ".a");
- std::string dependency = this->ConvertToRelativeForMake(d.c_str());
+ std::string dependency = this->ConvertToRelativeForMake(d);
makefileStream << "\\\n\t" << dependency;
dummyRules.insert(dependency);
}
@@ -3213,23 +3320,17 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
// Write the action to remove the target if it is out of date.
makefileStream << "\n";
makefileStream << "\t/bin/rm -f "
- << this->ConvertToRelativeForMake(tfull.c_str())
- << "\n";
+ << this->ConvertToRelativeForMake(tfull) << "\n";
// if building for more than one architecture
- // then remove those exectuables as well
+ // then remove those executables as well
if (this->Architectures.size() > 1) {
- std::string universal = this->GetObjectsNormalDirectory(
- this->CurrentProject, configName, gt);
- for (std::vector<std::string>::iterator arch =
- this->Architectures.begin();
- arch != this->Architectures.end(); ++arch) {
- std::string universalFile = universal;
- universalFile += *arch;
- universalFile += "/";
- universalFile += gt->GetFullName(configName);
+ std::string universal = this->GetObjectsDirectory(
+ this->CurrentProject, configName, gt, "$(OBJDIR)/");
+ for (const auto& architecture : this->Architectures) {
+ std::string universalFile = cmStrCat(universal, architecture, '/',
+ gt->GetFullName(configName));
makefileStream << "\t/bin/rm -f "
- << this->ConvertToRelativeForMake(
- universalFile.c_str())
+ << this->ConvertToRelativeForMake(universalFile)
<< "\n";
}
}
@@ -3241,51 +3342,33 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
makefileStream << "\n\n"
<< "# For each target create a dummy rule"
<< "so the target does not have to exist\n";
- for (std::set<std::string>::const_iterator it = dummyRules.begin();
- it != dummyRules.end(); ++it) {
- makefileStream << *it << ":\n";
+ for (auto const& dummyRule : dummyRules) {
+ makefileStream << dummyRule << ":\n";
}
}
void cmGlobalXCodeGenerator::OutputXCodeProject(
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
{
- if (generators.size() == 0) {
+ if (generators.empty()) {
return;
}
- // Skip local generators that are excluded from this project.
- for (std::vector<cmLocalGenerator*>::iterator g = generators.begin();
- g != generators.end(); ++g) {
- if (this->IsExcluded(root, *g)) {
- continue;
- }
- }
-
if (!this->CreateXCodeObjects(root, generators)) {
return;
}
- std::string xcodeDir = root->GetCurrentBinaryDirectory();
- xcodeDir += "/";
- xcodeDir += root->GetProjectName();
- xcodeDir += ".xcodeproj";
- cmSystemTools::MakeDirectory(xcodeDir.c_str());
+ std::string xcodeDir = cmStrCat(root->GetCurrentBinaryDirectory(), '/',
+ root->GetProjectName(), ".xcodeproj");
+ cmSystemTools::MakeDirectory(xcodeDir);
std::string xcodeProjFile = xcodeDir + "/project.pbxproj";
- cmGeneratedFileStream fout(xcodeProjFile.c_str());
+ cmGeneratedFileStream fout(xcodeProjFile);
fout.SetCopyIfDifferent(true);
if (!fout) {
return;
}
this->WriteXCodePBXProj(fout, root, generators);
- // Since the lowest available Xcode version for testing was 7.0,
- // I'm setting this as a limit then
- if (this->XcodeVersion >= 70) {
- if (root->GetMakefile()->GetCMakeInstance()->GetIsInTryCompile() ||
- root->GetMakefile()->IsOn("CMAKE_XCODE_GENERATE_SCHEME")) {
- this->OutputXCodeSharedSchemes(xcodeDir);
- this->OutputXCodeWorkspaceSettings(xcodeDir);
- }
- }
+ bool hasGeneratedSchemes = this->OutputXCodeSharedSchemes(xcodeDir, root);
+ this->OutputXCodeWorkspaceSettings(xcodeDir, hasGeneratedSchemes);
this->ClearXCodeObjects();
@@ -3295,35 +3378,67 @@ void cmGlobalXCodeGenerator::OutputXCodeProject(
root->GetBinaryDirectory());
}
-void cmGlobalXCodeGenerator::OutputXCodeSharedSchemes(
- const std::string& xcProjDir)
+bool cmGlobalXCodeGenerator::OutputXCodeSharedSchemes(
+ const std::string& xcProjDir, cmLocalGenerator* root)
{
- for (std::vector<cmXCodeObject*>::const_iterator i =
- this->XCodeObjects.begin();
- i != this->XCodeObjects.end(); ++i) {
- cmXCodeObject* obj = *i;
- if (obj->GetType() == cmXCodeObject::OBJECT &&
- (obj->GetIsA() == cmXCodeObject::PBXNativeTarget ||
- obj->GetIsA() == cmXCodeObject::PBXAggregateTarget)) {
- cmXCodeScheme schm(obj, this->CurrentConfigurationTypes,
- this->XcodeVersion);
- schm.WriteXCodeSharedScheme(xcProjDir,
- this->RelativeToSource(xcProjDir.c_str()));
+ // collect all tests for the targets
+ std::map<std::string, cmXCodeScheme::TestObjects> testables;
+
+ for (auto obj : this->XCodeObjects) {
+ if (obj->GetType() != cmXCodeObject::OBJECT ||
+ obj->GetIsA() != cmXCodeObject::PBXNativeTarget) {
+ continue;
+ }
+
+ if (!obj->GetTarget()->IsXCTestOnApple()) {
+ continue;
+ }
+
+ const char* testee = obj->GetTarget()->GetProperty("XCTEST_TESTEE");
+ if (!testee) {
+ continue;
+ }
+
+ testables[testee].push_back(obj);
+ }
+
+ // generate scheme
+ bool ret = false;
+
+ // Since the lowest available Xcode version for testing was 6.4,
+ // I'm setting this as a limit then
+ if (this->XcodeVersion >= 64) {
+ for (auto obj : this->XCodeObjects) {
+ if (obj->GetType() == cmXCodeObject::OBJECT &&
+ (obj->GetIsA() == cmXCodeObject::PBXNativeTarget ||
+ obj->GetIsA() == cmXCodeObject::PBXAggregateTarget) &&
+ (root->GetMakefile()->GetCMakeInstance()->GetIsInTryCompile() ||
+ obj->GetTarget()->GetPropertyAsBool("XCODE_GENERATE_SCHEME"))) {
+ const std::string& targetName = obj->GetTarget()->GetName();
+ cmXCodeScheme schm(obj, testables[targetName],
+ this->CurrentConfigurationTypes,
+ this->XcodeVersion);
+ schm.WriteXCodeSharedScheme(xcProjDir,
+ this->RelativeToSource(xcProjDir));
+ ret = true;
+ }
}
}
+
+ return ret;
}
void cmGlobalXCodeGenerator::OutputXCodeWorkspaceSettings(
- const std::string& xcProjDir)
+ const std::string& xcProjDir, bool hasGeneratedSchemes)
{
- std::string xcodeSharedDataDir = xcProjDir;
- xcodeSharedDataDir += "/project.xcworkspace/xcshareddata";
+ std::string xcodeSharedDataDir =
+ cmStrCat(xcProjDir, "/project.xcworkspace/xcshareddata");
cmSystemTools::MakeDirectory(xcodeSharedDataDir);
- std::string workspaceSettingsFile = xcodeSharedDataDir;
- workspaceSettingsFile += "/WorkspaceSettings.xcsettings";
+ std::string workspaceSettingsFile =
+ cmStrCat(xcodeSharedDataDir, "/WorkspaceSettings.xcsettings");
- cmGeneratedFileStream fout(workspaceSettingsFile.c_str());
+ cmGeneratedFileStream fout(workspaceSettingsFile);
fout.SetCopyIfDifferent(true);
if (!fout) {
return;
@@ -3336,8 +3451,15 @@ void cmGlobalXCodeGenerator::OutputXCodeWorkspaceSettings(
xout.StartElement("plist");
xout.Attribute("version", "1.0");
xout.StartElement("dict");
- xout.Element("key", "IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded");
- xout.Element("false");
+ if (this->XcodeVersion >= 100) {
+ xout.Element("key", "BuildSystemType");
+ xout.Element("string", "Original");
+ }
+ if (hasGeneratedSchemes) {
+ xout.Element("key",
+ "IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded");
+ xout.Element("false");
+ }
xout.EndElement(); // dict
xout.EndElement(); // plist
xout.EndDocument();
@@ -3358,12 +3480,7 @@ void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout,
cmXCodeObject::Indent(1, fout);
fout << "};\n";
cmXCodeObject::Indent(1, fout);
- if (this->XcodeVersion >= 32)
- fout << "objectVersion = 46;\n";
- else if (this->XcodeVersion >= 31)
- fout << "objectVersion = 45;\n";
- else
- fout << "objectVersion = 44;\n";
+ fout << "objectVersion = 46;\n";
cmXCode21Object::PrintList(this->XCodeObjects, fout);
cmXCodeObject::Indent(1, fout);
fout << "rootObject = " << this->RootObject->GetId()
@@ -3402,31 +3519,30 @@ void cmGlobalXCodeGenerator::GetDocumentation(cmDocumentationEntry& entry)
entry.Brief = "Generate Xcode project files.";
}
-std::string cmGlobalXCodeGenerator::ConvertToRelativeForMake(const char* p)
+std::string cmGlobalXCodeGenerator::ConvertToRelativeForMake(
+ std::string const& p)
{
return cmSystemTools::ConvertToOutputPath(p);
}
-std::string cmGlobalXCodeGenerator::RelativeToSource(const char* p)
+std::string cmGlobalXCodeGenerator::RelativeToSource(const std::string& p)
{
// We force conversion because Xcode breakpoints do not work unless
// they are in a file named relative to the source tree.
- return cmOutputConverter::ForceToRelativePath(
+ return cmSystemTools::ForceToRelativePath(
cmSystemTools::JoinPath(this->ProjectSourceDirectoryComponents), p);
}
-std::string cmGlobalXCodeGenerator::RelativeToBinary(const char* p)
+std::string cmGlobalXCodeGenerator::RelativeToBinary(const std::string& p)
{
- return this->CurrentLocalGenerator->ConvertToRelativePath(
+ return this->CurrentLocalGenerator->MaybeConvertToRelativePath(
cmSystemTools::JoinPath(this->ProjectOutputDirectoryComponents), p);
}
std::string cmGlobalXCodeGenerator::XCodeEscapePath(const std::string& p)
{
if (p.find(' ') != std::string::npos) {
- std::string t = "\"";
- t += p;
- t += "\"";
+ std::string t = cmStrCat('"', p, '"');
return t;
}
return p;
@@ -3448,9 +3564,7 @@ std::string cmGlobalXCodeGenerator::LookupFlags(
const std::string& varNameSuffix, const std::string& default_flags)
{
if (!varNameLang.empty()) {
- std::string varName = varNamePrefix;
- varName += varNameLang;
- varName += varNameSuffix;
+ std::string varName = cmStrCat(varNamePrefix, varNameLang, varNameSuffix);
if (const char* varValue = this->CurrentMakefile->GetDefinition(varName)) {
if (*varValue) {
return varValue;
@@ -3470,8 +3584,7 @@ void cmGlobalXCodeGenerator::AppendDefines(BuildObjectListOrString& defs,
}
// Expand the list of definitions.
- std::vector<std::string> defines;
- cmSystemTools::ExpandListArgument(defines_list, defines);
+ std::vector<std::string> defines = cmExpandedList(defines_list);
// Store the definitions in the string.
this->AppendDefines(defs, defines, dflag);
@@ -3483,11 +3596,9 @@ void cmGlobalXCodeGenerator::AppendDefines(
{
// GCC_PREPROCESSOR_DEFINITIONS is a space-separated list of definitions.
std::string def;
- for (std::vector<std::string>::const_iterator di = defines.begin();
- di != defines.end(); ++di) {
+ for (auto const& define : defines) {
// Start with -D if requested.
- def = dflag ? "-D" : "";
- def += *di;
+ def = cmStrCat(dflag ? "-D" : "", define);
// Append the flag with needed escapes.
std::string tmp;
@@ -3497,7 +3608,7 @@ void cmGlobalXCodeGenerator::AppendDefines(
}
void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
- std::string const& flag)
+ std::string const& flag) const
{
// Short-circuit for an empty flag.
if (flag.empty()) {
@@ -3529,17 +3640,13 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
}
// Flag value with escaped quotes and backslashes.
- for (const char* c = flag.c_str(); *c; ++c) {
- if (*c == '\'') {
- if (this->XcodeVersion >= 40) {
- flags += "'\\''";
- } else {
- flags += "\\'";
- }
- } else if (*c == '\\') {
+ for (auto c : flag) {
+ if (c == '\'') {
+ flags += "'\\''";
+ } else if (c == '\\') {
flags += "\\\\";
} else {
- flags += *c;
+ flags += c;
}
}
@@ -3552,11 +3659,9 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags,
std::string cmGlobalXCodeGenerator::ComputeInfoPListLocation(
cmGeneratorTarget* target)
{
- std::string plist = target->GetLocalGenerator()->GetCurrentBinaryDirectory();
- plist += cmake::GetCMakeFilesDirectory();
- plist += "/";
- plist += target->GetName();
- plist += ".dir/Info.plist";
+ std::string plist =
+ cmStrCat(target->GetLocalGenerator()->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/", target->GetName(), ".dir/Info.plist");
return plist;
}
@@ -3572,7 +3677,7 @@ bool cmGlobalXCodeGenerator::HasKnownObjectFileLocation(
std::string* reason) const
{
if (this->ObjectDirArch.find('$') != std::string::npos) {
- if (reason != CM_NULLPTR) {
+ if (reason != nullptr) {
*reason = " under Xcode with multiple architectures";
}
return false;
@@ -3587,10 +3692,10 @@ bool cmGlobalXCodeGenerator::UseEffectivePlatformName(cmMakefile* mf) const
"XCODE_EMIT_EFFECTIVE_PLATFORM_NAME");
if (!epnValue) {
- return mf->PlatformIsAppleIos();
+ return mf->PlatformIsAppleEmbedded();
}
- return cmSystemTools::IsOn(epnValue);
+ return cmIsOn(epnValue);
}
bool cmGlobalXCodeGenerator::ShouldStripResourcePath(cmMakefile*) const
@@ -3604,8 +3709,29 @@ void cmGlobalXCodeGenerator::ComputeTargetObjectDirectory(
{
std::string configName = this->GetCMakeCFGIntDir();
std::string dir =
- this->GetObjectsNormalDirectory("$(PROJECT_NAME)", configName, gt);
- dir += this->ObjectDirArch;
- dir += "/";
+ cmStrCat(this->GetObjectsDirectory("$(PROJECT_NAME)", configName, gt,
+ "$(OBJECT_FILE_DIR_normal:base)/"),
+ this->ObjectDirArch, '/');
gt->ObjectDirectory = dir;
}
+
+std::string cmGlobalXCodeGenerator::GetDeploymentPlatform(const cmMakefile* mf)
+{
+ switch (mf->GetAppleSDKType()) {
+ case cmMakefile::AppleSDK::AppleTVOS:
+ case cmMakefile::AppleSDK::AppleTVSimulator:
+ return "TVOS_DEPLOYMENT_TARGET";
+
+ case cmMakefile::AppleSDK::IPhoneOS:
+ case cmMakefile::AppleSDK::IPhoneSimulator:
+ return "IPHONEOS_DEPLOYMENT_TARGET";
+
+ case cmMakefile::AppleSDK::WatchOS:
+ case cmMakefile::AppleSDK::WatchSimulator:
+ return "WATCHOS_DEPLOYMENT_TARGET";
+
+ case cmMakefile::AppleSDK::MacOS:
+ default:
+ return "MACOSX_DEPLOYMENT_TARGET";
+ }
+}
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index e69793bcc..af905d00c 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmGlobalXCodeGenerator_h
#define cmGlobalXCodeGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
@@ -36,8 +36,8 @@ public:
unsigned int version_number);
static cmGlobalGeneratorFactory* NewFactory();
- ///! Get the name for the generator.
- std::string GetName() const CM_OVERRIDE
+ //! Get the name for the generator.
+ std::string GetName() const override
{
return cmGlobalXCodeGenerator::GetActualName();
}
@@ -46,79 +46,87 @@ public:
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
- ///! Create a local generator appropriate to this Global Generator
- cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) CM_OVERRIDE;
+ //! Create a local generator appropriate to this Global Generator
+ cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override;
/**
* Try to determine system information such as shared library
* extension, pthreads, byte order etc.
*/
void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
- bool optional) CM_OVERRIDE;
+ bool optional) override;
+
+ /**
+ * Open a generated IDE project given the following information.
+ */
+ bool Open(const std::string& bindir, const std::string& projectName,
+ bool dryRun) override;
+
/**
* Try running cmake and building a file. This is used for dynalically
* loaded commands, not as part of the usual build process.
*/
- void GenerateBuildCommand(std::vector<std::string>& makeCommand,
- const std::string& makeProgram,
- const std::string& projectName,
- const std::string& projectDir,
- const std::string& targetName,
- const std::string& config, bool fast, bool verbose,
- std::vector<std::string> const& makeOptions =
- std::vector<std::string>()) CM_OVERRIDE;
+ std::vector<GeneratedMakeCommand> GenerateBuildCommand(
+ const std::string& makeProgram, const std::string& projectName,
+ const std::string& projectDir, std::vector<std::string> const& targetNames,
+ const std::string& config, bool fast, int jobs, bool verbose,
+ std::vector<std::string> const& makeOptions =
+ std::vector<std::string>()) override;
/** Append the subdirectory for the given configuration. */
void AppendDirectoryForConfig(const std::string& prefix,
const std::string& config,
const std::string& suffix,
- std::string& dir) CM_OVERRIDE;
+ std::string& dir) override;
- bool FindMakeProgram(cmMakefile*) CM_OVERRIDE;
+ bool FindMakeProgram(cmMakefile*) override;
- ///! What is the configurations directory variable called?
- const char* GetCMakeCFGIntDir() const CM_OVERRIDE;
- ///! expand CFGIntDir
+ //! What is the configurations directory variable called?
+ const char* GetCMakeCFGIntDir() const override;
+ //! expand CFGIntDir
std::string ExpandCFGIntDir(const std::string& str,
- const std::string& config) const CM_OVERRIDE;
+ const std::string& config) const override;
void SetCurrentLocalGenerator(cmLocalGenerator*);
/** Return true if the generated build tree may contain multiple builds.
i.e. "Can I build Debug and Release in the same tree?" */
- bool IsMultiConfig() const CM_OVERRIDE;
+ bool IsMultiConfig() const override;
+
+ bool IsXcode() const override { return true; }
- bool HasKnownObjectFileLocation(std::string* reason) const CM_OVERRIDE;
+ bool HasKnownObjectFileLocation(std::string* reason) const override;
- bool IsIPOSupported() const CM_OVERRIDE { return true; }
+ bool IsIPOSupported() const override { return true; }
- bool UseEffectivePlatformName(cmMakefile* mf) const CM_OVERRIDE;
+ bool UseEffectivePlatformName(cmMakefile* mf) const override;
- bool ShouldStripResourcePath(cmMakefile*) const CM_OVERRIDE;
+ bool ShouldStripResourcePath(cmMakefile*) const override;
- bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf) CM_OVERRIDE;
- void AppendFlag(std::string& flags, std::string const& flag);
+ bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf) override;
+ void AppendFlag(std::string& flags, std::string const& flag) const;
protected:
- void AddExtraIDETargets() CM_OVERRIDE;
- void Generate() CM_OVERRIDE;
+ void AddExtraIDETargets() override;
+ void ComputeTargetOrder();
+ void ComputeTargetOrder(cmGeneratorTarget const* gt, size_t& index);
+ void Generate() override;
private:
cmXCodeObject* CreateOrGetPBXGroup(cmGeneratorTarget* gtgt,
cmSourceGroup* sg);
- cmXCodeObject* CreatePBXGroup(cmXCodeObject* parent, std::string name);
+ cmXCodeObject* CreatePBXGroup(cmXCodeObject* parent,
+ const std::string& name);
bool CreateGroups(std::vector<cmLocalGenerator*>& generators);
std::string XCodeEscapePath(const std::string& p);
- std::string RelativeToSource(const char* p);
- std::string RelativeToBinary(const char* p);
- std::string ConvertToRelativeForMake(const char* p);
- void CreateCustomCommands(cmXCodeObject* buildPhases,
- cmXCodeObject* sourceBuildPhase,
- cmXCodeObject* headerBuildPhase,
- cmXCodeObject* resourceBuildPhase,
- std::vector<cmXCodeObject*> contentBuildPhases,
- cmXCodeObject* frameworkBuildPhase,
- cmGeneratorTarget* gtgt);
+ std::string RelativeToSource(const std::string& p);
+ std::string RelativeToBinary(const std::string& p);
+ std::string ConvertToRelativeForMake(std::string const& p);
+ void CreateCustomCommands(
+ cmXCodeObject* buildPhases, cmXCodeObject* sourceBuildPhase,
+ cmXCodeObject* headerBuildPhase, cmXCodeObject* resourceBuildPhase,
+ std::vector<cmXCodeObject*> const& contentBuildPhases,
+ cmXCodeObject* frameworkBuildPhase, cmGeneratorTarget* gtgt);
std::string ComputeInfoPListLocation(cmGeneratorTarget* target);
@@ -144,7 +152,7 @@ private:
cmXCodeObject* CreateFlatClone(cmXCodeObject*);
cmXCodeObject* CreateXCodeTarget(cmGeneratorTarget* gtgt,
cmXCodeObject* buildPhases);
- void ForceLinkerLanguages() CM_OVERRIDE;
+ void ForceLinkerLanguages() override;
void ForceLinkerLanguage(cmGeneratorTarget* gtgt);
const char* GetTargetLinkFlagsVar(const cmGeneratorTarget* target) const;
const char* GetTargetFileType(cmGeneratorTarget* target);
@@ -158,6 +166,9 @@ private:
const std::string& configName);
cmXCodeObject* CreateUtilityTarget(cmGeneratorTarget* gtgt);
void AddDependAndLinkInformation(cmXCodeObject* target);
+ void AddPositionIndependentLinkAttribute(cmGeneratorTarget* target,
+ cmXCodeObject* buildSettings,
+ const std::string& configName);
void CreateBuildSettings(cmGeneratorTarget* gtgt,
cmXCodeObject* buildSettings,
const std::string& buildType);
@@ -174,8 +185,11 @@ private:
void OutputXCodeProject(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
// Write shared scheme files for all the native targets
- void OutputXCodeSharedSchemes(const std::string& xcProjDir);
- void OutputXCodeWorkspaceSettings(const std::string& xcProjDir);
+ // return true if any were written
+ bool OutputXCodeSharedSchemes(const std::string& xcProjDir,
+ cmLocalGenerator* root);
+ void OutputXCodeWorkspaceSettings(const std::string& xcProjDir,
+ bool hasGeneratedSchemes);
void WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
cmXCodeObject* CreateXCodeFileReferenceFromPath(const std::string& fullpath,
@@ -190,7 +204,11 @@ private:
cmGeneratorTarget* target);
cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen, cmSourceFile* sf,
cmGeneratorTarget* gtgt);
+ void AddXCodeProjBuildRule(cmGeneratorTarget* target,
+ std::vector<cmSourceFile*>& sources) const;
bool CreateXCodeTargets(cmLocalGenerator* gen, std::vector<cmXCodeObject*>&);
+ bool CreateXCodeTarget(cmGeneratorTarget* gtgt,
+ std::vector<cmXCodeObject*>&);
bool IsHeaderFile(cmSourceFile*);
void AddDependTarget(cmXCodeObject* target, cmXCodeObject* dependTarget);
void CreateXCodeDependHackTarget(std::vector<cmXCodeObject*>& targets);
@@ -219,11 +237,11 @@ private:
std::vector<std::string> const& defines,
bool dflag = false);
- void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const CM_OVERRIDE;
+ void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;
protected:
- const char* GetInstallTargetName() const CM_OVERRIDE { return "install"; }
- const char* GetPackageTargetName() const CM_OVERRIDE { return "package"; }
+ const char* GetInstallTargetName() const override { return "install"; }
+ const char* GetPackageTargetName() const override { return "package"; }
unsigned int XcodeVersion;
std::string VersionString;
@@ -238,13 +256,16 @@ private:
bool XcodeBuildCommandInitialized;
void PrintCompilerAdvice(std::ostream&, std::string const&,
- const char*) const CM_OVERRIDE
+ const char*) const override
{
}
- std::string GetObjectsNormalDirectory(const std::string& projName,
- const std::string& configName,
- const cmGeneratorTarget* t) const;
+ std::string GetObjectsDirectory(const std::string& projName,
+ const std::string& configName,
+ const cmGeneratorTarget* t,
+ const std::string& variant) const;
+
+ static std::string GetDeploymentPlatform(const cmMakefile* mf);
void ComputeArchitectures(cmMakefile* mf);
void ComputeObjectDirArch(cmMakefile* mf);
@@ -271,6 +292,7 @@ private:
std::string ObjectDirArchDefault;
std::string ObjectDirArch;
std::string GeneratorToolset;
+ std::map<cmGeneratorTarget const*, size_t> TargetOrderIndex;
};
#endif
diff --git a/Source/cmGraphAdjacencyList.h b/Source/cmGraphAdjacencyList.h
index 46cf87871..5ed6af461 100644
--- a/Source/cmGraphAdjacencyList.h
+++ b/Source/cmGraphAdjacencyList.h
@@ -5,8 +5,11 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <utility>
#include <vector>
+#include "cmListFileCache.h"
+
/**
* Graph edge representation. Most use cases just need the
* destination vertex, so we support conversion to/from an int. We
@@ -15,17 +18,22 @@
class cmGraphEdge
{
public:
- cmGraphEdge(int n = 0, bool s = true)
+ cmGraphEdge(int n, bool s, cmListFileBacktrace bt)
: Dest(n)
, Strong(s)
+ , Backtrace(std::move(bt))
{
}
operator int() const { return this->Dest; }
bool IsStrong() const { return this->Strong; }
+
+ cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
+
private:
int Dest;
bool Strong;
+ cmListFileBacktrace Backtrace;
};
struct cmGraphEdgeList : public std::vector<cmGraphEdge>
{
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index 7e953cef1..e0d545d86 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -2,8 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGraphVizWriter.h"
-#include "cmConfigure.h"
+#include <cstddef>
#include <iostream>
+#include <memory>
#include <sstream>
#include <utility>
@@ -12,13 +13,41 @@
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmState.h"
#include "cmStateSnapshot.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
-static const char* getShapeForTarget(const cmGeneratorTarget* target)
+namespace {
+enum LinkLibraryScopeType
+{
+ LLT_SCOPE_PUBLIC,
+ LLT_SCOPE_PRIVATE,
+ LLT_SCOPE_INTERFACE
+};
+
+const char* const GRAPHVIZ_PRIVATE_EDEGE_STYLE = "dashed";
+const char* const GRAPHVIZ_INTERFACE_EDEGE_STYLE = "dotted";
+
+std::string getLinkLibraryStyle(const LinkLibraryScopeType& type)
+{
+ std::string style;
+ switch (type) {
+ case LLT_SCOPE_PRIVATE:
+ style = "[style = " + std::string(GRAPHVIZ_PRIVATE_EDEGE_STYLE) + "]";
+ break;
+ case LLT_SCOPE_INTERFACE:
+ style = "[style = " + std::string(GRAPHVIZ_INTERFACE_EDEGE_STYLE) + "]";
+ break;
+ default:
+ break;
+ }
+ return style;
+}
+
+const char* getShapeForTarget(const cmGeneratorTarget* target)
{
if (!target) {
return "ellipse";
@@ -40,17 +69,102 @@ static const char* getShapeForTarget(const cmGeneratorTarget* target)
return "box";
}
-cmGraphVizWriter::cmGraphVizWriter(
- const std::vector<cmLocalGenerator*>& localGenerators)
+std::map<std::string, LinkLibraryScopeType> getScopedLinkLibrariesFromTarget(
+ cmTarget* Target, const cmGlobalGenerator* globalGenerator)
+{
+ char sep = ';';
+ std::map<std::string, LinkLibraryScopeType> tokens;
+ size_t start = 0;
+ size_t end = 0;
+
+ const char* pInterfaceLinkLibraries =
+ Target->GetProperty("INTERFACE_LINK_LIBRARIES");
+ const char* pLinkLibraries = Target->GetProperty("LINK_LIBRARIES");
+
+ if (!pInterfaceLinkLibraries && !pLinkLibraries) {
+ return tokens; // target is not linked against any other libraries
+ }
+
+ // make sure we don't touch a null-ptr
+ auto interfaceLinkLibraries =
+ std::string(pInterfaceLinkLibraries ? pInterfaceLinkLibraries : "");
+ auto linkLibraries = std::string(pLinkLibraries ? pLinkLibraries : "");
+
+ // first extract interfaceLinkLibraries
+ while (start < interfaceLinkLibraries.length()) {
+
+ if ((end = interfaceLinkLibraries.find(sep, start)) == std::string::npos) {
+ end = interfaceLinkLibraries.length();
+ }
+
+ std::string element = interfaceLinkLibraries.substr(start, end - start);
+ if (globalGenerator->IsAlias(element)) {
+ const auto tgt = globalGenerator->FindTarget(element);
+ if (tgt) {
+ element = tgt->GetName();
+ }
+ }
+
+ if (std::string::npos == element.find("$<LINK_ONLY:", 0)) {
+ // we assume first, that this library is an interface library.
+ // if we find it again in the linklibraries property, we promote it to an
+ // public library.
+ tokens[element] = LLT_SCOPE_INTERFACE;
+ } else {
+ // this is an private linked static library.
+ // we take care of this case in the second iterator.
+ }
+ start = end + 1;
+ }
+
+ // second extract linkLibraries
+ start = 0;
+ while (start < linkLibraries.length()) {
+
+ if ((end = linkLibraries.find(sep, start)) == std::string::npos) {
+ end = linkLibraries.length();
+ }
+
+ std::string element = linkLibraries.substr(start, end - start);
+ if (globalGenerator->IsAlias(element)) {
+ const auto tgt = globalGenerator->FindTarget(element);
+ if (tgt) {
+ element = tgt->GetName();
+ }
+ }
+
+ if (tokens.find(element) == tokens.end()) {
+ // this library is not found in interfaceLinkLibraries but in
+ // linkLibraries.
+ // this results in a private linked library.
+ tokens[element] = LLT_SCOPE_PRIVATE;
+ } else if (LLT_SCOPE_INTERFACE == tokens[element]) {
+ // this library is found in interfaceLinkLibraries and linkLibraries.
+ // this results in a public linked library.
+ tokens[element] = LLT_SCOPE_PUBLIC;
+ } else {
+ // private and public linked libraries should not be changed anymore.
+ }
+
+ start = end + 1;
+ }
+
+ return tokens;
+}
+}
+
+cmGraphVizWriter::cmGraphVizWriter(const cmGlobalGenerator* globalGenerator)
: GraphType("digraph")
, GraphName("GG")
, GraphHeader("node [\n fontsize = \"12\"\n];")
, GraphNodePrefix("node")
- , LocalGenerators(localGenerators)
+ , GlobalGenerator(globalGenerator)
+ , LocalGenerators(globalGenerator->GetLocalGenerators())
, GenerateForExecutables(true)
, GenerateForStaticLibs(true)
, GenerateForSharedLibs(true)
, GenerateForModuleLibs(true)
+ , GenerateForInterface(true)
, GenerateForExternals(true)
, GeneratePerTarget(true)
, GenerateDependers(true)
@@ -58,19 +172,19 @@ cmGraphVizWriter::cmGraphVizWriter(
{
}
-void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
- const char* fallbackSettingsFileName)
+void cmGraphVizWriter::ReadSettings(
+ const std::string& settingsFileName,
+ const std::string& fallbackSettingsFileName)
{
- cmake cm(cmake::RoleScript);
+ cmake cm(cmake::RoleScript, cmState::Unknown);
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator ggi(&cm);
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&ggi, cm.GetCurrentSnapshot()));
- CM_AUTO_PTR<cmLocalGenerator> lg(ggi.CreateLocalGenerator(mf.get()));
-
- const char* inFileName = settingsFileName;
+ cmMakefile mf(&ggi, cm.GetCurrentSnapshot());
+ std::unique_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator(&mf));
+ std::string inFileName = settingsFileName;
if (!cmSystemTools::FileExists(inFileName)) {
inFileName = fallbackSettingsFileName;
if (!cmSystemTools::FileExists(inFileName)) {
@@ -78,8 +192,8 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
}
}
- if (!mf->ReadListFile(inFileName)) {
- cmSystemTools::Error("Problem opening GraphViz options file: ",
+ if (!mf.ReadListFile(inFileName)) {
+ cmSystemTools::Error("Problem opening GraphViz options file: " +
inFileName);
return;
}
@@ -87,12 +201,12 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
std::cout << "Reading GraphViz options file: " << inFileName << std::endl;
#define __set_if_set(var, cmakeDefinition) \
- { \
- const char* value = mf->GetDefinition(cmakeDefinition); \
+ do { \
+ const char* value = mf.GetDefinition(cmakeDefinition); \
if (value) { \
(var) = value; \
} \
- }
+ } while (false)
__set_if_set(this->GraphType, "GRAPHVIZ_GRAPH_TYPE");
__set_if_set(this->GraphName, "GRAPHVIZ_GRAPH_NAME");
@@ -100,17 +214,18 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
__set_if_set(this->GraphNodePrefix, "GRAPHVIZ_NODE_PREFIX");
#define __set_bool_if_set(var, cmakeDefinition) \
- { \
- const char* value = mf->GetDefinition(cmakeDefinition); \
+ do { \
+ const char* value = mf.GetDefinition(cmakeDefinition); \
if (value) { \
- (var) = mf->IsOn(cmakeDefinition); \
+ (var) = mf.IsOn(cmakeDefinition); \
} \
- }
+ } while (false)
__set_bool_if_set(this->GenerateForExecutables, "GRAPHVIZ_EXECUTABLES");
__set_bool_if_set(this->GenerateForStaticLibs, "GRAPHVIZ_STATIC_LIBS");
__set_bool_if_set(this->GenerateForSharedLibs, "GRAPHVIZ_SHARED_LIBS");
__set_bool_if_set(this->GenerateForModuleLibs, "GRAPHVIZ_MODULE_LIBS");
+ __set_bool_if_set(this->GenerateForInterface, "GRAPHVIZ_INTERFACE");
__set_bool_if_set(this->GenerateForExternals, "GRAPHVIZ_EXTERNAL_LIBS");
__set_bool_if_set(this->GeneratePerTarget, "GRAPHVIZ_GENERATE_PER_TARGET");
__set_bool_if_set(this->GenerateDependers, "GRAPHVIZ_GENERATE_DEPENDERS");
@@ -120,26 +235,22 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
this->TargetsToIgnoreRegex.clear();
if (!ignoreTargetsRegexes.empty()) {
- std::vector<std::string> ignoreTargetsRegExVector;
- cmSystemTools::ExpandListArgument(ignoreTargetsRegexes,
- ignoreTargetsRegExVector);
- for (std::vector<std::string>::const_iterator itvIt =
- ignoreTargetsRegExVector.begin();
- itvIt != ignoreTargetsRegExVector.end(); ++itvIt) {
- std::string currentRegexString(*itvIt);
+ std::vector<std::string> ignoreTargetsRegExVector =
+ cmExpandedList(ignoreTargetsRegexes);
+ for (std::string const& currentRegexString : ignoreTargetsRegExVector) {
cmsys::RegularExpression currentRegex;
- if (!currentRegex.compile(currentRegexString.c_str())) {
+ if (!currentRegex.compile(currentRegexString)) {
std::cerr << "Could not compile bad regex \"" << currentRegexString
<< "\"" << std::endl;
}
- this->TargetsToIgnoreRegex.push_back(currentRegex);
+ this->TargetsToIgnoreRegex.push_back(std::move(currentRegex));
}
}
}
// Iterate over all targets and write for each one a graph which shows
// which other targets depend on it.
-void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
+void cmGraphVizWriter::WriteTargetDependersFiles(const std::string& fileName)
{
if (!this->GenerateDependers) {
return;
@@ -147,23 +258,19 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
this->CollectTargetsAndLibs();
- for (std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
- this->TargetPtrs.begin();
- ptrIt != this->TargetPtrs.end(); ++ptrIt) {
- if (ptrIt->second == CM_NULLPTR) {
+ for (auto const& ptr : this->TargetPtrs) {
+ if (ptr.second == nullptr) {
continue;
}
- if (!this->GenerateForTargetType(ptrIt->second->GetType())) {
+ if (!this->GenerateForTargetType(ptr.second->GetType())) {
continue;
}
- std::string currentFilename = fileName;
- currentFilename += ".";
- currentFilename += ptrIt->first;
- currentFilename += ".dependers";
+ std::string currentFilename =
+ cmStrCat(fileName, '.', ptr.first, ".dependers");
- cmGeneratedFileStream str(currentFilename.c_str());
+ cmGeneratedFileStream str(currentFilename);
if (!str) {
return;
}
@@ -174,7 +281,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
std::cout << "Writing " << currentFilename << "..." << std::endl;
this->WriteHeader(str);
- this->WriteDependerConnections(ptrIt->first, insertedNodes,
+ this->WriteDependerConnections(ptr.first, insertedNodes,
insertedConnections, str);
this->WriteFooter(str);
@@ -183,7 +290,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
// Iterate over all targets and write for each one a graph which shows
// on which targets it depends.
-void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
+void cmGraphVizWriter::WritePerTargetFiles(const std::string& fileName)
{
if (!this->GeneratePerTarget) {
return;
@@ -191,24 +298,20 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
this->CollectTargetsAndLibs();
- for (std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
- this->TargetPtrs.begin();
- ptrIt != this->TargetPtrs.end(); ++ptrIt) {
- if (ptrIt->second == CM_NULLPTR) {
+ for (auto const& ptr : this->TargetPtrs) {
+ if (ptr.second == nullptr) {
continue;
}
- if (!this->GenerateForTargetType(ptrIt->second->GetType())) {
+ if (!this->GenerateForTargetType(ptr.second->GetType())) {
continue;
}
std::set<std::string> insertedConnections;
std::set<std::string> insertedNodes;
- std::string currentFilename = fileName;
- currentFilename += ".";
- currentFilename += ptrIt->first;
- cmGeneratedFileStream str(currentFilename.c_str());
+ std::string currentFilename = cmStrCat(fileName, '.', ptr.first);
+ cmGeneratedFileStream str(currentFilename);
if (!str) {
return;
}
@@ -216,13 +319,12 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
std::cout << "Writing " << currentFilename << "..." << std::endl;
this->WriteHeader(str);
- this->WriteConnections(ptrIt->first, insertedNodes, insertedConnections,
- str);
+ this->WriteConnections(ptr.first, insertedNodes, insertedConnections, str);
this->WriteFooter(str);
}
}
-void cmGraphVizWriter::WriteGlobalFile(const char* fileName)
+void cmGraphVizWriter::WriteGlobalFile(const std::string& fileName)
{
this->CollectTargetsAndLibs();
@@ -237,19 +339,16 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName)
std::set<std::string> insertedConnections;
std::set<std::string> insertedNodes;
- for (std::map<std::string, const cmGeneratorTarget*>::const_iterator ptrIt =
- this->TargetPtrs.begin();
- ptrIt != this->TargetPtrs.end(); ++ptrIt) {
- if (ptrIt->second == CM_NULLPTR) {
+ for (auto const& ptr : this->TargetPtrs) {
+ if (ptr.second == nullptr) {
continue;
}
- if (!this->GenerateForTargetType(ptrIt->second->GetType())) {
+ if (!this->GenerateForTargetType(ptr.second->GetType())) {
continue;
}
- this->WriteConnections(ptrIt->first, insertedNodes, insertedConnections,
- str);
+ this->WriteConnections(ptr.first, insertedNodes, insertedConnections, str);
}
this->WriteFooter(str);
}
@@ -269,8 +368,7 @@ void cmGraphVizWriter::WriteConnections(
const std::string& targetName, std::set<std::string>& insertedNodes,
std::set<std::string>& insertedConnections, cmGeneratedFileStream& str) const
{
- std::map<std::string, const cmGeneratorTarget*>::const_iterator targetPtrIt =
- this->TargetPtrs.find(targetName);
+ auto targetPtrIt = this->TargetPtrs.find(targetName);
if (targetPtrIt == this->TargetPtrs.end()) // not found at all
{
@@ -279,30 +377,26 @@ void cmGraphVizWriter::WriteConnections(
this->WriteNode(targetName, targetPtrIt->second, insertedNodes, str);
- if (targetPtrIt->second == CM_NULLPTR) // it's an external library
+ if (targetPtrIt->second == nullptr) // it's an external library
{
return;
}
std::string myNodeName = this->TargetNamesNodes.find(targetName)->second;
+ std::map<std::string, LinkLibraryScopeType> ll =
+ getScopedLinkLibrariesFromTarget(targetPtrIt->second->Target,
+ GlobalGenerator);
- const cmTarget::LinkLibraryVectorType* ll =
- &(targetPtrIt->second->Target->GetOriginalLinkLibraries());
-
- for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
- llit != ll->end(); ++llit) {
- const char* libName = llit->first.c_str();
- std::map<std::string, std::string>::const_iterator libNameIt =
- this->TargetNamesNodes.find(libName);
+ for (auto const& llit : ll) {
+ const std::string& libName = llit.first;
+ auto libNameIt = this->TargetNamesNodes.find(libName);
// can happen e.g. if GRAPHVIZ_TARGET_IGNORE_REGEX is used
if (libNameIt == this->TargetNamesNodes.end()) {
continue;
}
- std::string connectionName = myNodeName;
- connectionName += "-";
- connectionName += libNameIt->second;
+ std::string connectionName = cmStrCat(myNodeName, '-', libNameIt->second);
if (insertedConnections.find(connectionName) ==
insertedConnections.end()) {
insertedConnections.insert(connectionName);
@@ -310,6 +404,9 @@ void cmGraphVizWriter::WriteConnections(
insertedNodes, str);
str << " \"" << myNodeName << "\" -> \"" << libNameIt->second << "\"";
+
+ str << getLinkLibraryStyle(llit.second);
+
str << " // " << targetName << " -> " << libName << std::endl;
this->WriteConnections(libName, insertedNodes, insertedConnections, str);
}
@@ -320,8 +417,7 @@ void cmGraphVizWriter::WriteDependerConnections(
const std::string& targetName, std::set<std::string>& insertedNodes,
std::set<std::string>& insertedConnections, cmGeneratedFileStream& str) const
{
- std::map<std::string, const cmGeneratorTarget*>::const_iterator targetPtrIt =
- this->TargetPtrs.find(targetName);
+ auto targetPtrIt = this->TargetPtrs.find(targetName);
if (targetPtrIt == this->TargetPtrs.end()) // not found at all
{
@@ -330,7 +426,7 @@ void cmGraphVizWriter::WriteDependerConnections(
this->WriteNode(targetName, targetPtrIt->second, insertedNodes, str);
- if (targetPtrIt->second == CM_NULLPTR) // it's an external library
+ if (targetPtrIt->second == nullptr) // it's an external library
{
return;
}
@@ -338,46 +434,39 @@ void cmGraphVizWriter::WriteDependerConnections(
std::string myNodeName = this->TargetNamesNodes.find(targetName)->second;
// now search who links against me
- for (std::map<std::string, const cmGeneratorTarget*>::const_iterator
- dependerIt = this->TargetPtrs.begin();
- dependerIt != this->TargetPtrs.end(); ++dependerIt) {
- if (dependerIt->second == CM_NULLPTR) {
+ for (auto const& tptr : this->TargetPtrs) {
+ if (tptr.second == nullptr) {
continue;
}
- if (!this->GenerateForTargetType(dependerIt->second->GetType())) {
+ if (!this->GenerateForTargetType(tptr.second->GetType())) {
continue;
}
// Now we have a target, check whether it links against targetName.
// If so, draw a connection, and then continue with dependers on that one.
- const cmTarget::LinkLibraryVectorType* ll =
- &(dependerIt->second->Target->GetOriginalLinkLibraries());
+ std::map<std::string, LinkLibraryScopeType> ll =
+ getScopedLinkLibrariesFromTarget(tptr.second->Target, GlobalGenerator);
- for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
- llit != ll->end(); ++llit) {
- std::string libName = llit->first;
- if (libName == targetName) {
+ for (auto const& llit : ll) {
+ if (llit.first == targetName) {
// So this target links against targetName.
- std::map<std::string, std::string>::const_iterator dependerNodeNameIt =
- this->TargetNamesNodes.find(dependerIt->first);
+ auto dependerNodeNameIt = this->TargetNamesNodes.find(tptr.first);
if (dependerNodeNameIt != this->TargetNamesNodes.end()) {
- std::string connectionName = dependerNodeNameIt->second;
- connectionName += "-";
- connectionName += myNodeName;
+ std::string connectionName =
+ cmStrCat(dependerNodeNameIt->second, '-', myNodeName);
if (insertedConnections.find(connectionName) ==
insertedConnections.end()) {
insertedConnections.insert(connectionName);
- this->WriteNode(dependerIt->first, dependerIt->second,
- insertedNodes, str);
+ this->WriteNode(tptr.first, tptr.second, insertedNodes, str);
str << " \"" << dependerNodeNameIt->second << "\" -> \""
<< myNodeName << "\"";
- str << " // " << targetName << " -> " << dependerIt->first
- << std::endl;
- this->WriteDependerConnections(dependerIt->first, insertedNodes,
+ str << " // " << targetName << " -> " << tptr.first << std::endl;
+ str << getLinkLibraryStyle(llit.second);
+ this->WriteDependerConnections(tptr.first, insertedNodes,
insertedConnections, str);
}
}
@@ -394,8 +483,7 @@ void cmGraphVizWriter::WriteNode(const std::string& targetName,
{
if (insertedNodes.find(targetName) == insertedNodes.end()) {
insertedNodes.insert(targetName);
- std::map<std::string, std::string>::const_iterator nameIt =
- this->TargetNamesNodes.find(targetName);
+ auto nameIt = this->TargetNamesNodes.find(targetName);
str << " \"" << nameIt->second << "\" [ label=\"" << targetName
<< "\" shape=\"" << getShapeForTarget(target) << "\"];" << std::endl;
@@ -417,13 +505,10 @@ int cmGraphVizWriter::CollectAllTargets()
{
int cnt = 0;
// First pass get the list of all cmake targets
- for (std::vector<cmLocalGenerator*>::const_iterator lit =
- this->LocalGenerators.begin();
- lit != this->LocalGenerators.end(); ++lit) {
- std::vector<cmGeneratorTarget*> targets = (*lit)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator it = targets.begin();
- it != targets.end(); ++it) {
- const char* realTargetName = (*it)->GetName().c_str();
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ const std::string& realTargetName = target->GetName();
if (this->IgnoreThisTarget(realTargetName)) {
// Skip ignored targets
continue;
@@ -432,7 +517,7 @@ int cmGraphVizWriter::CollectAllTargets()
std::ostringstream ostr;
ostr << this->GraphNodePrefix << cnt++;
this->TargetNamesNodes[realTargetName] = ostr.str();
- this->TargetPtrs[realTargetName] = *it;
+ this->TargetPtrs[realTargetName] = target;
}
}
@@ -442,34 +527,36 @@ int cmGraphVizWriter::CollectAllTargets()
int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
{
// Ok, now find all the stuff we link to that is not in cmake
- for (std::vector<cmLocalGenerator*>::const_iterator lit =
- this->LocalGenerators.begin();
- lit != this->LocalGenerators.end(); ++lit) {
- std::vector<cmGeneratorTarget*> targets = (*lit)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator it = targets.begin();
- it != targets.end(); ++it) {
- const char* realTargetName = (*it)->GetName().c_str();
+ for (cmLocalGenerator* lg : this->LocalGenerators) {
+ const std::vector<cmGeneratorTarget*>& targets = lg->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ const std::string& realTargetName = target->GetName();
if (this->IgnoreThisTarget(realTargetName)) {
// Skip ignored targets
continue;
}
const cmTarget::LinkLibraryVectorType* ll =
- &((*it)->Target->GetOriginalLinkLibraries());
- for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin();
- llit != ll->end(); ++llit) {
- const char* libName = llit->first.c_str();
+ &(target->Target->GetOriginalLinkLibraries());
+ for (auto const& llit : *ll) {
+ std::string libName = llit.first;
if (this->IgnoreThisTarget(libName)) {
// Skip ignored targets
continue;
}
- std::map<std::string, const cmGeneratorTarget*>::const_iterator tarIt =
- this->TargetPtrs.find(libName);
+ if (GlobalGenerator->IsAlias(libName)) {
+ const auto tgt = GlobalGenerator->FindTarget(libName);
+ if (tgt) {
+ libName = tgt->GetName();
+ }
+ }
+
+ auto tarIt = this->TargetPtrs.find(libName);
if (tarIt == this->TargetPtrs.end()) {
std::ostringstream ostr;
ostr << this->GraphNodePrefix << cnt++;
this->TargetNamesNodes[libName] = ostr.str();
- this->TargetPtrs[libName] = CM_NULLPTR;
+ this->TargetPtrs[libName] = nullptr;
// str << " \"" << ostr << "\" [ label=\"" << libName
// << "\" shape=\"ellipse\"];" << std::endl;
}
@@ -481,10 +568,7 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
bool cmGraphVizWriter::IgnoreThisTarget(const std::string& name)
{
- for (std::vector<cmsys::RegularExpression>::iterator itvIt =
- this->TargetsToIgnoreRegex.begin();
- itvIt != this->TargetsToIgnoreRegex.end(); ++itvIt) {
- cmsys::RegularExpression& regEx = *itvIt;
+ for (cmsys::RegularExpression& regEx : this->TargetsToIgnoreRegex) {
if (regEx.is_valid()) {
if (regEx.find(name)) {
return true;
@@ -507,6 +591,8 @@ bool cmGraphVizWriter::GenerateForTargetType(
return this->GenerateForSharedLibs;
case cmStateEnums::MODULE_LIBRARY:
return this->GenerateForModuleLibs;
+ case cmStateEnums::INTERFACE_LIBRARY:
+ return this->GenerateForInterface;
default:
break;
}
diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h
index 824999b96..9c3051f2c 100644
--- a/Source/cmGraphVizWriter.h
+++ b/Source/cmGraphVizWriter.h
@@ -5,32 +5,34 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmStateTypes.h"
-
-#include "cmsys/RegularExpression.hxx"
#include <map>
#include <set>
#include <string>
#include <vector>
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmStateTypes.h"
+
class cmGeneratedFileStream;
class cmGeneratorTarget;
class cmLocalGenerator;
+class cmGlobalGenerator;
/** This class implements writing files for graphviz (dot) for graphs
* representing the dependencies between the targets in the project. */
class cmGraphVizWriter
{
public:
- cmGraphVizWriter(const std::vector<cmLocalGenerator*>& localGenerators);
+ cmGraphVizWriter(const cmGlobalGenerator* globalGenerator);
- void ReadSettings(const char* settingsFileName,
- const char* fallbackSettingsFileName);
+ void ReadSettings(const std::string& settingsFileName,
+ const std::string& fallbackSettingsFileName);
- void WritePerTargetFiles(const char* fileName);
- void WriteTargetDependersFiles(const char* fileName);
+ void WritePerTargetFiles(const std::string& fileName);
+ void WriteTargetDependersFiles(const std::string& fileName);
- void WriteGlobalFile(const char* fileName);
+ void WriteGlobalFile(const std::string& fileName);
protected:
void CollectTargetsAndLibs();
@@ -69,6 +71,7 @@ protected:
std::vector<cmsys::RegularExpression> TargetsToIgnoreRegex;
+ const cmGlobalGenerator* GlobalGenerator;
const std::vector<cmLocalGenerator*>& LocalGenerators;
std::map<std::string, const cmGeneratorTarget*> TargetPtrs;
@@ -79,6 +82,7 @@ protected:
bool GenerateForStaticLibs;
bool GenerateForSharedLibs;
bool GenerateForModuleLibs;
+ bool GenerateForInterface;
bool GenerateForExternals;
bool GeneratePerTarget;
bool GenerateDependers;
diff --git a/Source/cmHexFileConverter.cxx b/Source/cmHexFileConverter.cxx
index 78dceb794..2fa4b5505 100644
--- a/Source/cmHexFileConverter.cxx
+++ b/Source/cmHexFileConverter.cxx
@@ -2,9 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmHexFileConverter.h"
-#include "cmConfigure.h"
-#include <stdio.h>
-#include <string.h>
+#include <cctype>
+#include <cstdio>
+#include <cstring>
#include "cmSystemTools.h"
@@ -13,16 +13,9 @@
#define MOTOROLA_SREC_MIN_LINE_LENGTH (2 + 2 + 4 + 2)
#define MOTOROLA_SREC_MAX_LINE_LENGTH (2 + 2 + 8 + (256 * 2) + 2)
-// might go to SystemTools ?
-static bool cm_IsHexChar(char c)
-{
- return (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f')) ||
- ((c >= 'A') && (c <= 'F')));
-}
-
static unsigned int ChompStrlen(const char* line)
{
- if (line == CM_NULLPTR) {
+ if (line == nullptr) {
return 0;
}
unsigned int length = static_cast<unsigned int>(strlen(line));
@@ -135,11 +128,11 @@ static bool ConvertIntelHexLine(const char* buf, FILE* outFile)
}
cmHexFileConverter::FileType cmHexFileConverter::DetermineFileType(
- const char* inFileName)
+ const std::string& inFileName)
{
char buf[1024];
FILE* inFile = cmsys::SystemTools::Fopen(inFileName, "rb");
- if (inFile == CM_NULLPTR) {
+ if (inFile == nullptr) {
return Binary;
}
@@ -170,15 +163,15 @@ cmHexFileConverter::FileType cmHexFileConverter::DetermineFileType(
}
for (unsigned int i = 1; i < slen; i++) {
- if (!cm_IsHexChar(buf[i])) {
+ if (!isxdigit(buf[i])) {
return Binary;
}
}
return type;
}
-bool cmHexFileConverter::TryConvert(const char* inFileName,
- const char* outFileName)
+bool cmHexFileConverter::TryConvert(const std::string& inFileName,
+ const std::string& outFileName)
{
FileType type = DetermineFileType(inFileName);
if (type == Binary) {
@@ -188,11 +181,11 @@ bool cmHexFileConverter::TryConvert(const char* inFileName,
// try to open the file
FILE* inFile = cmsys::SystemTools::Fopen(inFileName, "rb");
FILE* outFile = cmsys::SystemTools::Fopen(outFileName, "wb");
- if ((inFile == CM_NULLPTR) || (outFile == CM_NULLPTR)) {
- if (inFile != CM_NULLPTR) {
+ if ((inFile == nullptr) || (outFile == nullptr)) {
+ if (inFile != nullptr) {
fclose(inFile);
}
- if (outFile != CM_NULLPTR) {
+ if (outFile != nullptr) {
fclose(outFile);
}
return false;
@@ -201,7 +194,7 @@ bool cmHexFileConverter::TryConvert(const char* inFileName,
// convert them line by line
bool success = false;
char buf[1024];
- while (fgets(buf, 1024, inFile) != CM_NULLPTR) {
+ while (fgets(buf, 1024, inFile) != nullptr) {
if (type == MotorolaSrec) {
success = ConvertMotorolaSrecLine(buf, outFile);
} else if (type == IntelHex) {
diff --git a/Source/cmHexFileConverter.h b/Source/cmHexFileConverter.h
index 1050bc1b4..26f9ea8ba 100644
--- a/Source/cmHexFileConverter.h
+++ b/Source/cmHexFileConverter.h
@@ -3,6 +3,10 @@
#ifndef cmHexFileConverter_h
#define cmHexFileConverter_h
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+
/** \class cmHexFileConverter
* \brief Can detects Intel Hex and Motorola S-record files and convert them
* to binary files.
@@ -17,8 +21,9 @@ public:
IntelHex,
MotorolaSrec
};
- static FileType DetermineFileType(const char* inFileName);
- static bool TryConvert(const char* inFileName, const char* outFileName);
+ static FileType DetermineFileType(const std::string& inFileName);
+ static bool TryConvert(const std::string& inFileName,
+ const std::string& outFileName);
};
#endif
diff --git a/Source/cmIDEFlagTable.h b/Source/cmIDEFlagTable.h
index 152e293eb..ff93432cb 100644
--- a/Source/cmIDEFlagTable.h
+++ b/Source/cmIDEFlagTable.h
@@ -3,13 +3,15 @@
#ifndef cmIDEFlagTable_h
#define cmIDEFlagTable_h
+#include <string>
+
// This is a table mapping XML tag IDE names to command line options
struct cmIDEFlagTable
{
- const char* IDEName; // name used in the IDE xml file
- const char* commandFlag; // command line flag
- const char* comment; // comment
- const char* value; // string value
+ std::string IDEName; // name used in the IDE xml file
+ std::string commandFlag; // command line flag
+ std::string comment; // comment
+ std::string value; // string value
unsigned int special; // flags for special handling requests
enum
{
@@ -27,6 +29,9 @@ struct cmIDEFlagTable
SpaceAppendable = (1 << 7), // a flag that if specified multiple times
// should have its value appended to the
// old value with spaces
+ CommaAppendable = (1 << 8), // a flag that if specified multiple times
+ // should have its value appended to the
+ // old value with commas (e.g. C# /nowarn
UserValueIgnored = UserValue | UserIgnored,
UserValueRequired = UserValue | UserRequired
diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx
index 5e872d2ff..71326d23a 100644
--- a/Source/cmIDEOptions.cxx
+++ b/Source/cmIDEOptions.cxx
@@ -2,17 +2,21 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmIDEOptions.h"
-#include "cmsys/String.h"
#include <iterator>
+
#include <string.h>
+#include "cmsys/String.h"
+
+#include "cmAlgorithms.h"
#include "cmIDEFlagTable.h"
-#include "cmSystemTools.h"
+#include "cmStringAlgorithms.h"
cmIDEOptions::cmIDEOptions()
{
this->DoingDefine = false;
this->AllowDefine = true;
+ this->DoingInclude = false;
this->AllowSlash = false;
this->DoingFollowing = 0;
for (int i = 0; i < FlagTableCount; ++i) {
@@ -24,7 +28,7 @@ cmIDEOptions::~cmIDEOptions()
{
}
-void cmIDEOptions::HandleFlag(const char* flag)
+void cmIDEOptions::HandleFlag(std::string const& flag)
{
// If the last option was -D then this option is the definition.
if (this->DoingDefine) {
@@ -33,6 +37,13 @@ void cmIDEOptions::HandleFlag(const char* flag)
return;
}
+ // If the last option was -I then this option is the include directory.
+ if (this->DoingInclude) {
+ this->DoingInclude = false;
+ this->Includes.push_back(flag);
+ return;
+ }
+
// If the last option expected a following value, this is it.
if (this->DoingFollowing) {
this->FlagMapUpdate(this->DoingFollowing, flag);
@@ -41,15 +52,27 @@ void cmIDEOptions::HandleFlag(const char* flag)
}
// Look for known arguments.
- if (flag[0] == '-' || (this->AllowSlash && flag[0] == '/')) {
+ size_t len = flag.length();
+ if (len > 0 && (flag[0] == '-' || (this->AllowSlash && flag[0] == '/'))) {
// Look for preprocessor definitions.
- if (this->AllowDefine && flag[1] == 'D') {
- if (flag[2] == '\0') {
+ if (this->AllowDefine && len > 1 && flag[1] == 'D') {
+ if (len <= 2) {
// The next argument will have the definition.
this->DoingDefine = true;
} else {
// Store this definition.
- this->Defines.push_back(flag + 2);
+ this->Defines.push_back(flag.substr(2));
+ }
+ return;
+ }
+ // Look for include directory.
+ if (this->AllowInclude && len > 1 && flag[1] == 'I') {
+ if (len <= 2) {
+ // The next argument will have the include directory.
+ this->DoingInclude = true;
+ } else {
+ // Store this include directory.
+ this->Includes.push_back(flag.substr(2));
}
return;
}
@@ -73,27 +96,28 @@ void cmIDEOptions::HandleFlag(const char* flag)
}
bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table,
- const char* flag, bool& flag_handled)
+ std::string const& flag, bool& flag_handled)
{
+ const char* pf = flag.c_str() + 1;
// Look for an entry in the flag table matching this flag.
- for (cmIDEFlagTable const* entry = table; entry->IDEName; ++entry) {
+ for (cmIDEFlagTable const* entry = table; !entry->IDEName.empty(); ++entry) {
bool entry_found = false;
if (entry->special & cmIDEFlagTable::UserValue) {
// This flag table entry accepts a user-specified value. If
// the entry specifies UserRequired we must match only if a
// non-empty value is given.
- int n = static_cast<int>(strlen(entry->commandFlag));
- if ((strncmp(flag + 1, entry->commandFlag, n) == 0 ||
+ int n = static_cast<int>(entry->commandFlag.length());
+ if ((strncmp(pf, entry->commandFlag.c_str(), n) == 0 ||
(entry->special & cmIDEFlagTable::CaseInsensitive &&
- cmsysString_strncasecmp(flag + 1, entry->commandFlag, n))) &&
+ cmsysString_strncasecmp(pf, entry->commandFlag.c_str(), n))) &&
(!(entry->special & cmIDEFlagTable::UserRequired) ||
- static_cast<int>(strlen(flag + 1)) > n)) {
- this->FlagMapUpdate(entry, flag + n + 1);
+ static_cast<int>(strlen(pf)) > n)) {
+ this->FlagMapUpdate(entry, std::string(pf + n));
entry_found = true;
}
- } else if (strcmp(flag + 1, entry->commandFlag) == 0 ||
+ } else if (strcmp(pf, entry->commandFlag.c_str()) == 0 ||
(entry->special & cmIDEFlagTable::CaseInsensitive &&
- cmsysString_strcasecmp(flag + 1, entry->commandFlag) == 0)) {
+ cmsysString_strcasecmp(pf, entry->commandFlag.c_str()) == 0)) {
if (entry->special & cmIDEFlagTable::UserFollowing) {
// This flag expects a value in the following argument.
this->DoingFollowing = entry;
@@ -118,7 +142,7 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table,
}
void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry,
- const char* new_value)
+ std::string const& new_value)
{
if (entry->special & cmIDEFlagTable::UserIgnored) {
// Ignore the user-specified value.
@@ -127,6 +151,8 @@ void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry,
this->FlagMap[entry->IDEName].push_back(new_value);
} else if (entry->special & cmIDEFlagTable::SpaceAppendable) {
this->FlagMap[entry->IDEName].append_with_space(new_value);
+ } else if (entry->special & cmIDEFlagTable::CommaAppendable) {
+ this->FlagMap[entry->IDEName].append_with_comma(new_value);
} else {
// Use the user-specified value.
this->FlagMap[entry->IDEName] = new_value;
@@ -138,16 +164,16 @@ void cmIDEOptions::AddDefine(const std::string& def)
this->Defines.push_back(def);
}
-void cmIDEOptions::AddDefines(const char* defines)
+void cmIDEOptions::AddDefines(std::string const& defines)
{
- if (defines) {
+ if (!defines.empty()) {
// Expand the list of definitions.
- cmSystemTools::ExpandListArgument(defines, this->Defines);
+ cmExpandList(defines, this->Defines);
}
}
void cmIDEOptions::AddDefines(const std::vector<std::string>& defines)
{
- this->Defines.insert(this->Defines.end(), defines.begin(), defines.end());
+ cmAppend(this->Defines, defines);
}
std::vector<std::string> const& cmIDEOptions::GetDefines() const
@@ -155,12 +181,34 @@ std::vector<std::string> const& cmIDEOptions::GetDefines() const
return this->Defines;
}
-void cmIDEOptions::AddFlag(const char* flag, const char* value)
+void cmIDEOptions::AddInclude(const std::string& include)
+{
+ this->Includes.push_back(include);
+}
+
+void cmIDEOptions::AddIncludes(std::string const& includes)
+{
+ if (!includes.empty()) {
+ // Expand the list of includes.
+ cmExpandList(includes, this->Includes);
+ }
+}
+void cmIDEOptions::AddIncludes(const std::vector<std::string>& includes)
+{
+ cmAppend(this->Includes, includes);
+}
+
+std::vector<std::string> const& cmIDEOptions::GetIncludes() const
+{
+ return this->Includes;
+}
+
+void cmIDEOptions::AddFlag(std::string const& flag, std::string const& value)
{
this->FlagMap[flag] = value;
}
-void cmIDEOptions::AddFlag(const char* flag,
+void cmIDEOptions::AddFlag(std::string const& flag,
std::vector<std::string> const& value)
{
this->FlagMap[flag] = value;
@@ -185,7 +233,7 @@ void cmIDEOptions::AppendFlagString(std::string const& flag,
this->FlagMap[flag].append_with_space(value);
}
-void cmIDEOptions::RemoveFlag(const char* flag)
+void cmIDEOptions::RemoveFlag(std::string const& flag)
{
this->FlagMap.erase(flag);
}
@@ -195,12 +243,13 @@ bool cmIDEOptions::HasFlag(std::string const& flag) const
return this->FlagMap.find(flag) != this->FlagMap.end();
}
-const char* cmIDEOptions::GetFlag(const char* flag)
+const char* cmIDEOptions::GetFlag(std::string const& flag) const
{
// This method works only for single-valued flags!
- std::map<std::string, FlagValue>::iterator i = this->FlagMap.find(flag);
- if (i != this->FlagMap.end() && i->second.size() == 1) {
+ std::map<std::string, FlagValue>::const_iterator i =
+ this->FlagMap.find(flag);
+ if (i != this->FlagMap.cend() && i->second.size() == 1) {
return i->second[0].c_str();
}
- return 0;
+ return nullptr;
}
diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h
index 19e96bd44..f949ae3dd 100644
--- a/Source/cmIDEOptions.h
+++ b/Source/cmIDEOptions.h
@@ -3,7 +3,7 @@
#ifndef cmIDEOptions_h
#define cmIDEOptions_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
#include <string>
@@ -20,21 +20,26 @@ public:
cmIDEOptions();
virtual ~cmIDEOptions();
- // Store definitions and flags.
+ // Store definitions, includes and flags.
void AddDefine(const std::string& define);
- void AddDefines(const char* defines);
+ void AddDefines(std::string const& defines);
void AddDefines(const std::vector<std::string>& defines);
std::vector<std::string> const& GetDefines() const;
- void AddFlag(const char* flag, const char* value);
- void AddFlag(const char* flag, std::vector<std::string> const& value);
+ void AddInclude(const std::string& includes);
+ void AddIncludes(std::string const& includes);
+ void AddIncludes(const std::vector<std::string>& includes);
+ std::vector<std::string> const& GetIncludes() const;
+
+ void AddFlag(std::string const& flag, std::string const& value);
+ void AddFlag(std::string const& flag, std::vector<std::string> const& value);
void AppendFlag(std::string const& flag, std::string const& value);
void AppendFlag(std::string const& flag,
std::vector<std::string> const& value);
void AppendFlagString(std::string const& flag, std::string const& value);
- void RemoveFlag(const char* flag);
+ void RemoveFlag(std::string const& flag);
bool HasFlag(std::string const& flag) const;
- const char* GetFlag(const char* flag);
+ const char* GetFlag(std::string const& flag) const;
protected:
// create a map of xml tags to the values they should have in the output
@@ -46,7 +51,7 @@ protected:
// and overwrite or add new values to this map
class FlagValue : public std::vector<std::string>
{
- typedef std::vector<std::string> derived;
+ using derived = std::vector<std::string>;
public:
FlagValue& operator=(std::string const& r)
@@ -60,12 +65,22 @@ protected:
this->derived::operator=(r);
return *this;
}
+ FlagValue& append_with_comma(std::string const& r)
+ {
+ return append_with_separator(r, ',');
+ }
FlagValue& append_with_space(std::string const& r)
{
+ return append_with_separator(r, ' ');
+ }
+
+ private:
+ FlagValue& append_with_separator(std::string const& r, char separator)
+ {
this->resize(1);
std::string& l = this->operator[](0);
if (!l.empty()) {
- l += " ";
+ l += separator;
}
l += r;
return *this;
@@ -76,8 +91,13 @@ protected:
// Preprocessor definitions.
std::vector<std::string> Defines;
+ // Include directories.
+ std::vector<std::string> Includes;
+
bool DoingDefine;
bool AllowDefine;
+ bool DoingInclude;
+ bool AllowInclude;
bool AllowSlash;
cmIDEFlagTable const* DoingFollowing;
enum
@@ -85,11 +105,12 @@ protected:
FlagTableCount = 16
};
cmIDEFlagTable const* FlagTable[FlagTableCount];
- void HandleFlag(const char* flag);
- bool CheckFlagTable(cmIDEFlagTable const* table, const char* flag,
+ void HandleFlag(std::string const& flag);
+ bool CheckFlagTable(cmIDEFlagTable const* table, std::string const& flag,
bool& flag_handled);
- void FlagMapUpdate(cmIDEFlagTable const* entry, const char* new_value);
- virtual void StoreUnknownFlag(const char* flag) = 0;
+ void FlagMapUpdate(cmIDEFlagTable const* entry,
+ std::string const& new_value);
+ virtual void StoreUnknownFlag(std::string const& flag) = 0;
};
#endif
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index 0972664a2..290e064b4 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -2,218 +2,210 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmIfCommand.h"
+#include <string>
+#include <utility>
+
+#include <cm/memory>
+#include <cm/string_view>
+
+#include "cm_static_string_view.hxx"
+
#include "cmConditionEvaluator.h"
#include "cmExecutionStatus.h"
#include "cmExpandedCommandArgument.h"
+#include "cmFunctionBlocker.h"
+#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmOutputConverter.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
static std::string cmIfCommandError(
std::vector<cmExpandedCommandArgument> const& args)
{
std::string err = "given arguments:\n ";
- for (std::vector<cmExpandedCommandArgument>::const_iterator i = args.begin();
- i != args.end(); ++i) {
+ for (cmExpandedCommandArgument const& i : args) {
err += " ";
- err += cmOutputConverter::EscapeForCMake(i->GetValue());
+ err += cmOutputConverter::EscapeForCMake(i.GetValue());
}
err += "\n";
return err;
}
-//=========================================================================
-bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
- cmMakefile& mf,
- cmExecutionStatus& inStatus)
+class cmIfFunctionBlocker : public cmFunctionBlocker
+{
+public:
+ cm::string_view StartCommandName() const override { return "if"_s; }
+ cm::string_view EndCommandName() const override { return "endif"_s; }
+
+ bool ArgumentsMatch(cmListFileFunction const& lff,
+ cmMakefile&) const override;
+
+ bool Replay(std::vector<cmListFileFunction> functions,
+ cmExecutionStatus& inStatus) override;
+
+ std::vector<cmListFileArgument> Args;
+ bool IsBlocking;
+ bool HasRun = false;
+ bool ElseSeen = false;
+};
+
+bool cmIfFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff,
+ cmMakefile&) const
{
- // we start by recording all the functions
- if (!cmSystemTools::Strucmp(lff.Name.c_str(), "if")) {
- this->ScopeDepth++;
- } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endif")) {
- this->ScopeDepth--;
- // if this is the endif for this if statement, then start executing
- if (!this->ScopeDepth) {
- // Remove the function blocker for this scope or bail.
- CM_AUTO_PTR<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(this, lff));
- if (!fb.get()) {
- return false;
+ return lff.Arguments.empty() || lff.Arguments == this->Args;
+}
+
+bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
+ cmExecutionStatus& inStatus)
+{
+ cmMakefile& mf = inStatus.GetMakefile();
+ // execute the functions for the true parts of the if statement
+ int scopeDepth = 0;
+ for (cmListFileFunction const& func : functions) {
+ // keep track of scope depth
+ if (func.Name.Lower == "if") {
+ scopeDepth++;
+ }
+ if (func.Name.Lower == "endif") {
+ scopeDepth--;
+ }
+ // watch for our state change
+ if (scopeDepth == 0 && func.Name.Lower == "else") {
+
+ if (this->ElseSeen) {
+ cmListFileBacktrace bt = mf.GetBacktrace(func);
+ mf.GetCMakeInstance()->IssueMessage(
+ MessageType::FATAL_ERROR,
+ "A duplicate ELSE command was found inside an IF block.", bt);
+ cmSystemTools::SetFatalErrorOccured();
+ return true;
}
- // execute the functions for the true parts of the if statement
- cmExecutionStatus status;
- int scopeDepth = 0;
- for (unsigned int c = 0; c < this->Functions.size(); ++c) {
- // keep track of scope depth
- if (!cmSystemTools::Strucmp(this->Functions[c].Name.c_str(), "if")) {
- scopeDepth++;
- }
- if (!cmSystemTools::Strucmp(this->Functions[c].Name.c_str(),
- "endif")) {
- scopeDepth--;
+ this->IsBlocking = this->HasRun;
+ this->HasRun = true;
+ this->ElseSeen = true;
+
+ // if trace is enabled, print a (trivially) evaluated "else"
+ // statement
+ if (!this->IsBlocking && mf.GetCMakeInstance()->GetTrace()) {
+ mf.PrintCommandTrace(func);
+ }
+ } else if (scopeDepth == 0 && func.Name.Lower == "elseif") {
+ if (this->ElseSeen) {
+ cmListFileBacktrace bt = mf.GetBacktrace(func);
+ mf.GetCMakeInstance()->IssueMessage(
+ MessageType::FATAL_ERROR,
+ "An ELSEIF command was found after an ELSE command.", bt);
+ cmSystemTools::SetFatalErrorOccured();
+ return true;
+ }
+
+ if (this->HasRun) {
+ this->IsBlocking = true;
+ } else {
+ // if trace is enabled, print the evaluated "elseif" statement
+ if (mf.GetCMakeInstance()->GetTrace()) {
+ mf.PrintCommandTrace(func);
}
- // watch for our state change
- if (scopeDepth == 0 &&
- !cmSystemTools::Strucmp(this->Functions[c].Name.c_str(), "else")) {
-
- if (this->ElseSeen) {
- cmListFileBacktrace bt = mf.GetBacktrace(this->Functions[c]);
- mf.GetCMakeInstance()->IssueMessage(
- cmake::FATAL_ERROR,
- "A duplicate ELSE command was found inside an IF block.", bt);
- cmSystemTools::SetFatalErrorOccured();
- return true;
- }
- this->IsBlocking = this->HasRun;
- this->HasRun = true;
- this->ElseSeen = true;
+ std::string errorString;
- // if trace is enabled, print a (trivially) evaluated "else"
- // statement
- if (!this->IsBlocking && mf.GetCMakeInstance()->GetTrace()) {
- mf.PrintCommandTrace(this->Functions[c]);
- }
- } else if (scopeDepth == 0 &&
- !cmSystemTools::Strucmp(this->Functions[c].Name.c_str(),
- "elseif")) {
- if (this->ElseSeen) {
- cmListFileBacktrace bt = mf.GetBacktrace(this->Functions[c]);
- mf.GetCMakeInstance()->IssueMessage(
- cmake::FATAL_ERROR,
- "An ELSEIF command was found after an ELSE command.", bt);
+ std::vector<cmExpandedCommandArgument> expandedArguments;
+ mf.ExpandArguments(func.Arguments, expandedArguments);
+
+ MessageType messType;
+
+ cmListFileContext conditionContext =
+ cmListFileContext::FromCommandContext(
+ func, this->GetStartingContext().FilePath);
+
+ cmConditionEvaluator conditionEvaluator(mf, conditionContext,
+ mf.GetBacktrace(func));
+
+ bool isTrue =
+ conditionEvaluator.IsTrue(expandedArguments, errorString, messType);
+
+ if (!errorString.empty()) {
+ std::string err =
+ cmStrCat(cmIfCommandError(expandedArguments), errorString);
+ cmListFileBacktrace bt = mf.GetBacktrace(func);
+ mf.GetCMakeInstance()->IssueMessage(messType, err, bt);
+ if (messType == MessageType::FATAL_ERROR) {
cmSystemTools::SetFatalErrorOccured();
return true;
}
-
- if (this->HasRun) {
- this->IsBlocking = true;
- } else {
- // if trace is enabled, print the evaluated "elseif" statement
- if (mf.GetCMakeInstance()->GetTrace()) {
- mf.PrintCommandTrace(this->Functions[c]);
- }
-
- std::string errorString;
-
- std::vector<cmExpandedCommandArgument> expandedArguments;
- mf.ExpandArguments(this->Functions[c].Arguments,
- expandedArguments);
-
- cmake::MessageType messType;
-
- cmListFileContext conditionContext =
- cmListFileContext::FromCommandContext(
- this->Functions[c], this->GetStartingContext().FilePath);
-
- cmConditionEvaluator conditionEvaluator(
- mf, conditionContext, mf.GetBacktrace(this->Functions[c]));
-
- bool isTrue = conditionEvaluator.IsTrue(expandedArguments,
- errorString, messType);
-
- if (!errorString.empty()) {
- std::string err = cmIfCommandError(expandedArguments);
- err += errorString;
- cmListFileBacktrace bt = mf.GetBacktrace(this->Functions[c]);
- mf.GetCMakeInstance()->IssueMessage(messType, err, bt);
- if (messType == cmake::FATAL_ERROR) {
- cmSystemTools::SetFatalErrorOccured();
- return true;
- }
- }
-
- if (isTrue) {
- this->IsBlocking = false;
- this->HasRun = true;
- }
- }
}
- // should we execute?
- else if (!this->IsBlocking) {
- status.Clear();
- mf.ExecuteCommand(this->Functions[c], status);
- if (status.GetReturnInvoked()) {
- inStatus.SetReturnInvoked();
- return true;
- }
- if (status.GetBreakInvoked()) {
- inStatus.SetBreakInvoked();
- return true;
- }
- if (status.GetContinueInvoked()) {
- inStatus.SetContinueInvoked();
- return true;
- }
+ if (isTrue) {
+ this->IsBlocking = false;
+ this->HasRun = true;
}
}
- return true;
}
- }
- // record the command
- this->Functions.push_back(lff);
-
- // always return true
- return true;
-}
-
-//=========================================================================
-bool cmIfFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
- cmMakefile&)
-{
- if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endif")) {
- // if the endif has arguments, then make sure
- // they match the arguments of the matching if
- if (lff.Arguments.empty() || lff.Arguments == this->Args) {
- return true;
+ // should we execute?
+ else if (!this->IsBlocking) {
+ cmExecutionStatus status(mf);
+ mf.ExecuteCommand(func, status);
+ if (status.GetReturnInvoked()) {
+ inStatus.SetReturnInvoked();
+ return true;
+ }
+ if (status.GetBreakInvoked()) {
+ inStatus.SetBreakInvoked();
+ return true;
+ }
+ if (status.GetContinueInvoked()) {
+ inStatus.SetContinueInvoked();
+ return true;
+ }
}
}
-
- return false;
+ return true;
}
//=========================================================================
-bool cmIfCommand::InvokeInitialPass(
- const std::vector<cmListFileArgument>& args, cmExecutionStatus&)
+bool cmIfCommand(std::vector<cmListFileArgument> const& args,
+ cmExecutionStatus& inStatus)
{
+ cmMakefile& makefile = inStatus.GetMakefile();
std::string errorString;
std::vector<cmExpandedCommandArgument> expandedArguments;
- this->Makefile->ExpandArguments(args, expandedArguments);
+ makefile.ExpandArguments(args, expandedArguments);
- cmake::MessageType status;
+ MessageType status;
cmConditionEvaluator conditionEvaluator(
- *(this->Makefile), this->Makefile->GetExecutionContext(),
- this->Makefile->GetBacktrace());
+ makefile, makefile.GetExecutionContext(), makefile.GetBacktrace());
bool isTrue =
conditionEvaluator.IsTrue(expandedArguments, errorString, status);
if (!errorString.empty()) {
- std::string err = "if " + cmIfCommandError(expandedArguments);
- err += errorString;
- if (status == cmake::FATAL_ERROR) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, err);
+ std::string err =
+ cmStrCat("if ", cmIfCommandError(expandedArguments), errorString);
+ if (status == MessageType::FATAL_ERROR) {
+ makefile.IssueMessage(MessageType::FATAL_ERROR, err);
cmSystemTools::SetFatalErrorOccured();
return true;
}
- this->Makefile->IssueMessage(status, err);
+ makefile.IssueMessage(status, err);
}
- cmIfFunctionBlocker* f = new cmIfFunctionBlocker();
- // if is isn't true block the commands
- f->ScopeDepth = 1;
- f->IsBlocking = !isTrue;
- if (isTrue) {
- f->HasRun = true;
+ {
+ auto fb = cm::make_unique<cmIfFunctionBlocker>();
+ // if is isn't true block the commands
+ fb->IsBlocking = !isTrue;
+ if (isTrue) {
+ fb->HasRun = true;
+ }
+ fb->Args = args;
+ makefile.AddFunctionBlocker(std::move(fb));
}
- f->Args = args;
- this->Makefile->AddFunctionBlocker(f);
return true;
}
diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h
index 5877a7d12..820ffa4c6 100644
--- a/Source/cmIfCommand.h
+++ b/Source/cmIfCommand.h
@@ -3,70 +3,15 @@
#ifndef cmIfCommand_h
#define cmIfCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include <string>
#include <vector>
-#include "cmCommand.h"
-#include "cmFunctionBlocker.h"
-#include "cmListFileCache.h"
-
class cmExecutionStatus;
-class cmExpandedCommandArgument;
-class cmMakefile;
-
-class cmIfFunctionBlocker : public cmFunctionBlocker
-{
-public:
- cmIfFunctionBlocker()
- {
- this->HasRun = false;
- this->ElseSeen = false;
- this->ScopeDepth = 0;
- }
- ~cmIfFunctionBlocker() CM_OVERRIDE {}
- bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
- cmExecutionStatus&) CM_OVERRIDE;
- bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) CM_OVERRIDE;
-
- std::vector<cmListFileArgument> Args;
- std::vector<cmListFileFunction> Functions;
- bool IsBlocking;
- bool HasRun;
- bool ElseSeen;
- unsigned int ScopeDepth;
-};
+struct cmListFileArgument;
/// Starts an if block
-class cmIfCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmIfCommand; }
-
- /**
- * This overrides the default InvokeInitialPass implementation.
- * It records the arguments before expansion.
- */
- bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
- cmExecutionStatus&) CM_OVERRIDE;
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&) CM_OVERRIDE
- {
- return false;
- }
-
- // Filter the given variable definition based on policy CMP0054.
- static const char* GetDefinitionIfUnquoted(
- const cmMakefile* mf, cmExpandedCommandArgument const& argument);
-};
+bool cmIfCommand(std::vector<cmListFileArgument> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index 12e0c9ab3..14264f487 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -4,21 +4,21 @@
#include <sstream>
+#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-
-class cmExecutionStatus;
// cmIncludeCommand
-bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmIncludeCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty() || args.size() > 4) {
- this->SetError("called with wrong number of arguments. "
- "include() only takes one file.");
+ status.SetError("called with wrong number of arguments. "
+ "include() only takes one file.");
return false;
}
bool optional = false;
@@ -29,20 +29,20 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
for (unsigned int i = 1; i < args.size(); i++) {
if (args[i] == "OPTIONAL") {
if (optional) {
- this->SetError("called with invalid arguments: OPTIONAL used twice");
+ status.SetError("called with invalid arguments: OPTIONAL used twice");
return false;
}
optional = true;
} else if (args[i] == "RESULT_VARIABLE") {
if (!resultVarName.empty()) {
- this->SetError("called with invalid arguments: "
- "only one result variable allowed");
+ status.SetError("called with invalid arguments: "
+ "only one result variable allowed");
return false;
}
if (++i < args.size()) {
resultVarName = args[i];
} else {
- this->SetError("called with no value for RESULT_VARIABLE.");
+ status.SetError("called with no value for RESULT_VARIABLE.");
return false;
}
} else if (args[i] == "NO_POLICY_SCOPE") {
@@ -50,39 +50,39 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
} else if (i > 1) // compat.: in previous cmake versions the second
// parameter was ignored if it wasn't "OPTIONAL"
{
- std::string errorText = "called with invalid argument: ";
- errorText += args[i];
- this->SetError(errorText);
+ std::string errorText =
+ cmStrCat("called with invalid argument: ", args[i]);
+ status.SetError(errorText);
return false;
}
}
if (fname.empty()) {
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
- "include() given empty file name (ignored).");
+ status.GetMakefile().IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ "include() given empty file name (ignored).");
return true;
}
- if (!cmSystemTools::FileIsFullPath(fname.c_str())) {
+ if (!cmSystemTools::FileIsFullPath(fname)) {
// Not a path. Maybe module.
- std::string module = fname;
- module += ".cmake";
- std::string mfile = this->Makefile->GetModulesFile(module.c_str());
+ std::string module = cmStrCat(fname, ".cmake");
+ std::string mfile = status.GetMakefile().GetModulesFile(module);
if (!mfile.empty()) {
fname = mfile;
}
}
std::string fname_abs = cmSystemTools::CollapseFullPath(
- fname, this->Makefile->GetCurrentSourceDirectory());
+ fname, status.GetMakefile().GetCurrentSourceDirectory());
- cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
+ cmGlobalGenerator* gg = status.GetMakefile().GetGlobalGenerator();
if (gg->IsExportedTargetsFile(fname_abs)) {
- const char* modal = CM_NULLPTR;
+ const char* modal = nullptr;
std::ostringstream e;
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ MessageType messageType = MessageType::AUTHOR_WARNING;
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0024)) {
+ switch (status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0024)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0024) << "\n";
modal = "should";
@@ -92,17 +92,18 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
modal = "may";
- messageType = cmake::FATAL_ERROR;
+ messageType = MessageType::FATAL_ERROR;
}
if (modal) {
- e << "The file\n " << fname_abs << "\nwas generated by the export() "
- "command. It "
+ e << "The file\n " << fname_abs
+ << "\nwas generated by the export() "
+ "command. It "
<< modal
<< " not be used as the argument to the "
"include() command. Use ALIAS targets instead to refer to targets "
"by alternative names.\n";
- this->Makefile->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR) {
+ status.GetMakefile().IssueMessage(messageType, e.str());
+ if (messageType == MessageType::FATAL_ERROR) {
return false;
}
}
@@ -111,28 +112,28 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
}
std::string listFile = cmSystemTools::CollapseFullPath(
- fname, this->Makefile->GetCurrentSourceDirectory());
- if (optional && !cmSystemTools::FileExists(listFile.c_str())) {
+ fname, status.GetMakefile().GetCurrentSourceDirectory());
+ if (optional && !cmSystemTools::FileExists(listFile)) {
if (!resultVarName.empty()) {
- this->Makefile->AddDefinition(resultVarName, "NOTFOUND");
+ status.GetMakefile().AddDefinition(resultVarName, "NOTFOUND");
}
return true;
}
bool readit =
- this->Makefile->ReadDependentFile(listFile.c_str(), noPolicyScope);
+ status.GetMakefile().ReadDependentFile(listFile, noPolicyScope);
// add the location of the included file if a result variable was given
if (!resultVarName.empty()) {
- this->Makefile->AddDefinition(resultVarName,
- readit ? fname_abs.c_str() : "NOTFOUND");
+ status.GetMakefile().AddDefinition(
+ resultVarName, readit ? fname_abs.c_str() : "NOTFOUND");
}
if (!optional && !readit && !cmSystemTools::GetFatalErrorOccured()) {
- std::string m = "could not find load file:\n"
- " ";
- m += fname;
- this->SetError(m);
+ std::string m = cmStrCat("could not find load file:\n"
+ " ",
+ fname);
+ status.SetError(m);
return false;
}
return true;
diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h
index 16dda0ef5..b0dd77956 100644
--- a/Source/cmIncludeCommand.h
+++ b/Source/cmIncludeCommand.h
@@ -3,35 +3,20 @@
#ifndef cmIncludeCommand_h
#define cmIncludeCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmIncludeCommand
+/**
* \brief cmIncludeCommand defines a list of distant
* files that can be "included" in the current list file.
* In almost every sense, this is identical to a C/C++
* #include command. Arguments are first expended as usual.
*/
-class cmIncludeCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmIncludeCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmIncludeCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx
index b81f7cb2d..170aea125 100644
--- a/Source/cmIncludeDirectoryCommand.cxx
+++ b/Source/cmIncludeDirectoryCommand.cxx
@@ -4,23 +4,31 @@
#include <algorithm>
#include <set>
+#include <utility>
+#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
+#include "cmGeneratorExpression.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
+static void GetIncludes(cmMakefile& mf, const std::string& arg,
+ std::vector<std::string>& incs);
+static void NormalizeInclude(cmMakefile& mf, std::string& inc);
-// cmIncludeDirectoryCommand
-bool cmIncludeDirectoryCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmIncludeDirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
return true;
}
- std::vector<std::string>::const_iterator i = args.begin();
+ cmMakefile& mf = status.GetMakefile();
- bool before = this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_BEFORE");
+ auto i = args.begin();
+
+ bool before = mf.IsOn("CMAKE_INCLUDE_DIRECTORIES_BEFORE");
bool system = false;
if ((*i) == "BEFORE") {
@@ -41,20 +49,18 @@ bool cmIncludeDirectoryCommand::InitialPass(
continue;
}
if (i->empty()) {
- this->SetError("given empty-string as include directory.");
+ status.SetError("given empty-string as include directory.");
return false;
}
std::vector<std::string> includes;
- this->GetIncludes(*i, includes);
+ GetIncludes(mf, *i, includes);
if (before) {
- beforeIncludes.insert(beforeIncludes.end(), includes.begin(),
- includes.end());
+ cmAppend(beforeIncludes, includes);
} else {
- afterIncludes.insert(afterIncludes.end(), includes.begin(),
- includes.end());
+ cmAppend(afterIncludes, includes);
}
if (system) {
systemIncludes.insert(includes.begin(), includes.end());
@@ -62,22 +68,17 @@ bool cmIncludeDirectoryCommand::InitialPass(
}
std::reverse(beforeIncludes.begin(), beforeIncludes.end());
- this->Makefile->AddIncludeDirectories(afterIncludes);
- this->Makefile->AddIncludeDirectories(beforeIncludes, before);
- this->Makefile->AddSystemIncludeDirectories(systemIncludes);
+ mf.AddIncludeDirectories(afterIncludes);
+ mf.AddIncludeDirectories(beforeIncludes, before);
+ mf.AddSystemIncludeDirectories(systemIncludes);
return true;
}
-static bool StartsWithGeneratorExpression(const std::string& input)
-{
- return input[0] == '$' && input[1] == '<';
-}
-
// do a lot of cleanup on the arguments because this is one place where folks
// sometimes take the output of a program and pass it directly into this
// command not thinking that a single argument could be filled with spaces
-// and newlines etc liek below:
+// and newlines etc like below:
//
// " /foo/bar
// /boo/hoo /dingle/berry "
@@ -86,8 +87,8 @@ static bool StartsWithGeneratorExpression(const std::string& input)
// output from a program and passing it into a command the cleanup doesn't
// always happen
//
-void cmIncludeDirectoryCommand::GetIncludes(const std::string& arg,
- std::vector<std::string>& incs)
+static void GetIncludes(cmMakefile& mf, const std::string& arg,
+ std::vector<std::string>& incs)
{
// break apart any line feed arguments
std::string::size_type pos = 0;
@@ -95,41 +96,36 @@ void cmIncludeDirectoryCommand::GetIncludes(const std::string& arg,
while ((pos = arg.find('\n', lastPos)) != std::string::npos) {
if (pos) {
std::string inc = arg.substr(lastPos, pos);
- this->NormalizeInclude(inc);
+ NormalizeInclude(mf, inc);
if (!inc.empty()) {
- incs.push_back(inc);
+ incs.push_back(std::move(inc));
}
}
lastPos = pos + 1;
}
std::string inc = arg.substr(lastPos);
- this->NormalizeInclude(inc);
+ NormalizeInclude(mf, inc);
if (!inc.empty()) {
- incs.push_back(inc);
+ incs.push_back(std::move(inc));
}
}
-void cmIncludeDirectoryCommand::NormalizeInclude(std::string& inc)
+static void NormalizeInclude(cmMakefile& mf, std::string& inc)
{
std::string::size_type b = inc.find_first_not_of(" \r");
std::string::size_type e = inc.find_last_not_of(" \r");
if ((b != std::string::npos) && (e != std::string::npos)) {
inc.assign(inc, b, 1 + e - b); // copy the remaining substring
} else {
- inc = "";
+ inc.clear();
return;
}
- if (!cmSystemTools::IsOff(inc.c_str())) {
+ if (!cmIsOff(inc)) {
cmSystemTools::ConvertToUnixSlashes(inc);
-
- if (!cmSystemTools::FileIsFullPath(inc.c_str())) {
- if (!StartsWithGeneratorExpression(inc)) {
- std::string tmp = this->Makefile->GetCurrentSourceDirectory();
- tmp += "/";
- tmp += inc;
- inc = tmp;
- }
+ if (!cmSystemTools::FileIsFullPath(inc) &&
+ !cmGeneratorExpression::StartsWithGeneratorExpression(inc)) {
+ inc = cmStrCat(mf.GetCurrentSourceDirectory(), '/', inc);
}
}
}
diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h
index 12de698cb..66caff721 100644
--- a/Source/cmIncludeDirectoryCommand.h
+++ b/Source/cmIncludeDirectoryCommand.h
@@ -3,40 +3,14 @@
#ifndef cmIncludeDirectoryCommand_h
#define cmIncludeDirectoryCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmIncludeDirectoryCommand
- * \brief Add include directories to the build.
- *
- * cmIncludeDirectoryCommand is used to specify directory locations
- * to search for included files.
- */
-class cmIncludeDirectoryCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmIncludeDirectoryCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-protected:
- // used internally
- void GetIncludes(const std::string& arg, std::vector<std::string>& incs);
- void NormalizeInclude(std::string& inc);
-};
+bool cmIncludeDirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx
index 03388c7e9..fa1e8bcf9 100644
--- a/Source/cmIncludeExternalMSProjectCommand.cxx
+++ b/Source/cmIncludeExternalMSProjectCommand.cxx
@@ -2,27 +2,31 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmIncludeExternalMSProjectCommand.h"
+#include "cmExecutionStatus.h"
+
#ifdef _WIN32
-#include "cmMakefile.h"
-#include "cmStateTypes.h"
-#include "cmSystemTools.h"
-#include "cmTarget.h"
+# include "cmGlobalGenerator.h"
+# include "cmMakefile.h"
+# include "cmStateTypes.h"
+# include "cmSystemTools.h"
+# include "cmTarget.h"
+# include "cmake.h"
#endif
-class cmExecutionStatus;
-
-// cmIncludeExternalMSProjectCommand
-bool cmIncludeExternalMSProjectCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmIncludeExternalMSProjectCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("INCLUDE_EXTERNAL_MSPROJECT called with incorrect "
- "number of arguments");
+ status.SetError("INCLUDE_EXTERNAL_MSPROJECT called with incorrect "
+ "number of arguments");
return false;
}
+
// only compile this for win32 to avoid coverage errors
#ifdef _WIN32
- if (this->Makefile->GetDefinition("WIN32")) {
+ cmMakefile& mf = status.GetMakefile();
+ if (mf.GetDefinition("WIN32") ||
+ mf.GetGlobalGenerator()->IsIncludeExternalMSProjectSupported()) {
enum Doing
{
DoingNone,
@@ -73,27 +77,28 @@ bool cmIncludeExternalMSProjectCommand::InitialPass(
if (!customGuid.empty()) {
std::string guidVariable = utility_name + "_GUID_CMAKE";
- this->Makefile->GetCMakeInstance()->AddCacheEntry(
- guidVariable.c_str(), customGuid.c_str(), "Stored GUID",
- cmStateEnums::INTERNAL);
+ mf.GetCMakeInstance()->AddCacheEntry(guidVariable.c_str(),
+ customGuid.c_str(), "Stored GUID",
+ cmStateEnums::INTERNAL);
}
// Create a target instance for this utility.
- cmTarget* target = this->Makefile->AddNewTarget(cmStateEnums::UTILITY,
- utility_name.c_str());
+ cmTarget* target =
+ mf.AddNewTarget(cmStateEnums::UTILITY, utility_name.c_str());
+ if (mf.GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
+ target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
+ }
target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str());
target->SetProperty("EXTERNAL_MSPROJECT", path.c_str());
- target->SetProperty("EXCLUDE_FROM_ALL", "FALSE");
if (!customType.empty())
target->SetProperty("VS_PROJECT_TYPE", customType.c_str());
if (!platformMapping.empty())
target->SetProperty("VS_PLATFORM_MAPPING", platformMapping.c_str());
- for (std::vector<std::string>::const_iterator it = depends.begin();
- it != depends.end(); ++it) {
- target->AddUtility(it->c_str());
+ for (std::string const& d : depends) {
+ target->AddUtility(d.c_str());
}
}
#endif
diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h
index 375646fa6..1013c4435 100644
--- a/Source/cmIncludeExternalMSProjectCommand.h
+++ b/Source/cmIncludeExternalMSProjectCommand.h
@@ -3,39 +3,14 @@
#ifndef cmIncludeExternalMSProjectCommand_h
#define cmIncludeExternalMSProjectCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmIncludeExternalMSProjectCommand
- * \brief Specify an external MS project file for inclusion in the workspace.
- *
- * cmIncludeExternalMSProjectCommand is used to specify an externally
- * generated Microsoft project file for inclusion in the default workspace
- * generated by CMake.
- */
-class cmIncludeExternalMSProjectCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE
- {
- return new cmIncludeExternalMSProjectCommand;
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmIncludeExternalMSProjectCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmIncludeGuardCommand.cxx b/Source/cmIncludeGuardCommand.cxx
new file mode 100644
index 000000000..ccb4496e6
--- /dev/null
+++ b/Source/cmIncludeGuardCommand.cxx
@@ -0,0 +1,108 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmIncludeGuardCommand.h"
+
+#include "cmExecutionStatus.h"
+#include "cmMakefile.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
+#include "cmSystemTools.h"
+#include "cmake.h"
+
+namespace {
+
+enum IncludeGuardScope
+{
+ VARIABLE,
+ DIRECTORY,
+ GLOBAL
+};
+
+std::string GetIncludeGuardVariableName(std::string const& filePath)
+{
+ std::string result = "__INCGUARD_";
+#ifndef CMAKE_BOOTSTRAP
+ result += cmSystemTools::ComputeStringMD5(filePath);
+#else
+ result += cmSystemTools::MakeCidentifier(filePath);
+#endif
+ result += "__";
+ return result;
+}
+
+bool CheckIncludeGuardIsSet(cmMakefile* mf, std::string const& includeGuardVar)
+{
+ if (mf->GetProperty(includeGuardVar)) {
+ return true;
+ }
+ cmStateSnapshot dirSnapshot =
+ mf->GetStateSnapshot().GetBuildsystemDirectoryParent();
+ while (dirSnapshot.GetState()) {
+ cmStateDirectory stateDir = dirSnapshot.GetDirectory();
+ if (stateDir.GetProperty(includeGuardVar)) {
+ return true;
+ }
+ dirSnapshot = dirSnapshot.GetBuildsystemDirectoryParent();
+ }
+ return false;
+}
+
+} // anonymous namespace
+
+// cmIncludeGuardCommand
+bool cmIncludeGuardCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() > 1) {
+ status.SetError(
+ "given an invalid number of arguments. The command takes at "
+ "most 1 argument.");
+ return false;
+ }
+
+ IncludeGuardScope scope = VARIABLE;
+
+ if (!args.empty()) {
+ std::string const& arg = args[0];
+ if (arg == "DIRECTORY") {
+ scope = DIRECTORY;
+ } else if (arg == "GLOBAL") {
+ scope = GLOBAL;
+ } else {
+ status.SetError("given an invalid scope: " + arg);
+ return false;
+ }
+ }
+
+ std::string includeGuardVar = GetIncludeGuardVariableName(
+ status.GetMakefile().GetDefinition("CMAKE_CURRENT_LIST_FILE"));
+
+ cmMakefile* const mf = &status.GetMakefile();
+
+ switch (scope) {
+ case VARIABLE:
+ if (mf->IsDefinitionSet(includeGuardVar)) {
+ status.SetReturnInvoked();
+ return true;
+ }
+ mf->AddDefinitionBool(includeGuardVar, true);
+ break;
+ case DIRECTORY:
+ if (CheckIncludeGuardIsSet(mf, includeGuardVar)) {
+ status.SetReturnInvoked();
+ return true;
+ }
+ mf->SetProperty(includeGuardVar, "TRUE");
+ break;
+ case GLOBAL:
+ cmake* const cm = mf->GetCMakeInstance();
+ if (cm->GetProperty(includeGuardVar)) {
+ status.SetReturnInvoked();
+ return true;
+ }
+ cm->SetProperty(includeGuardVar, "TRUE");
+ break;
+ }
+
+ return true;
+}
diff --git a/Source/cmIncludeGuardCommand.h b/Source/cmIncludeGuardCommand.h
new file mode 100644
index 000000000..b86b76015
--- /dev/null
+++ b/Source/cmIncludeGuardCommand.h
@@ -0,0 +1,22 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmIncludeGuardCommand_h
+#define cmIncludeGuardCommand_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+#include <vector>
+
+class cmExecutionStatus;
+
+/**
+ * \brief cmIncludeGuardCommand identical to C++ #pragma_once command
+ * Can work in 3 modes: GLOBAL (works on global properties),
+ * DIRECTORY(use directory property), VARIABLE(unnamed overload without
+ * arguments) define an ordinary variable to be used as include guard checker
+ */
+bool cmIncludeGuardCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+
+#endif
diff --git a/Source/cmIncludeRegularExpressionCommand.cxx b/Source/cmIncludeRegularExpressionCommand.cxx
index 073c95f7d..655ebd6e4 100644
--- a/Source/cmIncludeRegularExpressionCommand.cxx
+++ b/Source/cmIncludeRegularExpressionCommand.cxx
@@ -2,22 +2,22 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmIncludeRegularExpressionCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-class cmExecutionStatus;
-
-// cmIncludeRegularExpressionCommand
-bool cmIncludeRegularExpressionCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmIncludeRegularExpressionCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- if ((args.empty()) || (args.size() > 2)) {
- this->SetError("called with incorrect number of arguments");
+ if (args.empty() || args.size() > 2) {
+ status.SetError("called with incorrect number of arguments");
return false;
}
- this->Makefile->SetIncludeRegularExpression(args[0].c_str());
+
+ cmMakefile& mf = status.GetMakefile();
+ mf.SetIncludeRegularExpression(args[0].c_str());
if (args.size() > 1) {
- this->Makefile->SetComplainRegularExpression(args[1]);
+ mf.SetComplainRegularExpression(args[1]);
}
return true;
diff --git a/Source/cmIncludeRegularExpressionCommand.h b/Source/cmIncludeRegularExpressionCommand.h
index bac4b8fc3..ca152b046 100644
--- a/Source/cmIncludeRegularExpressionCommand.h
+++ b/Source/cmIncludeRegularExpressionCommand.h
@@ -3,38 +3,14 @@
#ifndef cmIncludeRegularExpressionCommand_h
#define cmIncludeRegularExpressionCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmIncludeRegularExpressionCommand
- * \brief Set the regular expression for following #includes.
- *
- * cmIncludeRegularExpressionCommand is used to specify the regular expression
- * that determines whether to follow a #include file in dependency checking.
- */
-class cmIncludeRegularExpressionCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE
- {
- return new cmIncludeRegularExpressionCommand;
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmIncludeRegularExpressionCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 294fb178d..0c52cc5b7 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -2,14 +2,20 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallCommand.h"
-#include "cmsys/Glob.hxx"
+#include <cstddef>
+#include <set>
#include <sstream>
-#include <stddef.h>
+#include <utility>
+
+#include <cm/memory>
+
+#include "cmsys/Glob.hxx"
+
+#include "cm_static_string_view.hxx"
-#include "cmAlgorithms.h"
-#include "cmCommandArgumentsHelper.h"
+#include "cmArgumentParser.h"
+#include "cmExecutionStatus.h"
#include "cmExportSet.h"
-#include "cmExportSetMap.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmInstallCommandArguments.h"
@@ -19,100 +25,128 @@
#include "cmInstallGenerator.h"
#include "cmInstallScriptGenerator.h"
#include "cmInstallTargetGenerator.h"
+#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
+#include "cmSubcommandTable.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetExport.h"
-#include "cmake.h"
-class cmExecutionStatus;
+namespace {
+
+class Helper
+{
+public:
+ Helper(cmExecutionStatus& status)
+ : Status(status)
+ , Makefile(&status.GetMakefile())
+ {
+ this->DefaultComponentName = this->Makefile->GetSafeDefinition(
+ "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
+ if (this->DefaultComponentName.empty()) {
+ this->DefaultComponentName = "Unspecified";
+ }
+ }
-static cmInstallTargetGenerator* CreateInstallTargetGenerator(
+ void SetError(std::string const& err) { this->Status.SetError(err); }
+
+ bool MakeFilesFullPath(const char* modeName,
+ const std::vector<std::string>& relFiles,
+ std::vector<std::string>& absFiles);
+ bool CheckCMP0006(bool& failure);
+
+ std::string GetDestination(const cmInstallCommandArguments* args,
+ const std::string& varName,
+ const std::string& guess);
+ std::string GetRuntimeDestination(const cmInstallCommandArguments* args);
+ std::string GetSbinDestination(const cmInstallCommandArguments* args);
+ std::string GetArchiveDestination(const cmInstallCommandArguments* args);
+ std::string GetLibraryDestination(const cmInstallCommandArguments* args);
+ std::string GetIncludeDestination(const cmInstallCommandArguments* args);
+ std::string GetSysconfDestination(const cmInstallCommandArguments* args);
+ std::string GetSharedStateDestination(const cmInstallCommandArguments* args);
+ std::string GetLocalStateDestination(const cmInstallCommandArguments* args);
+ std::string GetRunStateDestination(const cmInstallCommandArguments* args);
+ std::string GetDataRootDestination(const cmInstallCommandArguments* args);
+ std::string GetDataDestination(const cmInstallCommandArguments* args);
+ std::string GetInfoDestination(const cmInstallCommandArguments* args);
+ std::string GetLocaleDestination(const cmInstallCommandArguments* args);
+ std::string GetManDestination(const cmInstallCommandArguments* args);
+ std::string GetDocDestination(const cmInstallCommandArguments* args);
+ std::string GetDestinationForType(const cmInstallCommandArguments* args,
+ const std::string& type);
+
+ cmExecutionStatus& Status;
+ cmMakefile* Makefile;
+ std::string DefaultComponentName;
+};
+
+cmInstallTargetGenerator* CreateInstallTargetGenerator(
cmTarget& target, const cmInstallCommandArguments& args, bool impLib,
- bool forceOpt = false)
+ cmListFileBacktrace const& backtrace, const std::string& destination,
+ bool forceOpt = false, bool namelink = false)
{
cmInstallGenerator::MessageLevel message =
cmInstallGenerator::SelectMessageLevel(target.GetMakefile());
target.SetHaveInstallRule(true);
- return new cmInstallTargetGenerator(
- target.GetName(), args.GetDestination().c_str(), impLib,
- args.GetPermissions().c_str(), args.GetConfigurations(),
- args.GetComponent().c_str(), message, args.GetExcludeFromAll(),
- args.GetOptional() || forceOpt);
+ const char* component = namelink ? args.GetNamelinkComponent().c_str()
+ : args.GetComponent().c_str();
+ auto g = new cmInstallTargetGenerator(
+ target.GetName(), destination.c_str(), impLib,
+ args.GetPermissions().c_str(), args.GetConfigurations(), component,
+ message, args.GetExcludeFromAll(), args.GetOptional() || forceOpt,
+ backtrace);
+ target.AddInstallGenerator(g);
+ return g;
+}
+
+cmInstallTargetGenerator* CreateInstallTargetGenerator(
+ cmTarget& target, const cmInstallCommandArguments& args, bool impLib,
+ cmListFileBacktrace const& backtrace, bool forceOpt = false,
+ bool namelink = false)
+{
+ return CreateInstallTargetGenerator(target, args, impLib, backtrace,
+ args.GetDestination(), forceOpt,
+ namelink);
}
-static cmInstallFilesGenerator* CreateInstallFilesGenerator(
+cmInstallFilesGenerator* CreateInstallFilesGenerator(
cmMakefile* mf, const std::vector<std::string>& absFiles,
- const cmInstallCommandArguments& args, bool programs)
+ const cmInstallCommandArguments& args, bool programs,
+ const std::string& destination)
{
cmInstallGenerator::MessageLevel message =
cmInstallGenerator::SelectMessageLevel(mf);
return new cmInstallFilesGenerator(
- absFiles, args.GetDestination().c_str(), programs,
- args.GetPermissions().c_str(), args.GetConfigurations(),
- args.GetComponent().c_str(), message, args.GetExcludeFromAll(),
- args.GetRename().c_str(), args.GetOptional());
+ absFiles, destination.c_str(), programs, args.GetPermissions().c_str(),
+ args.GetConfigurations(), args.GetComponent().c_str(), message,
+ args.GetExcludeFromAll(), args.GetRename().c_str(), args.GetOptional());
}
-// cmInstallCommand
-bool cmInstallCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+cmInstallFilesGenerator* CreateInstallFilesGenerator(
+ cmMakefile* mf, const std::vector<std::string>& absFiles,
+ const cmInstallCommandArguments& args, bool programs)
{
- // Allow calling with no arguments so that arguments may be built up
- // using a variable that may be left empty.
- if (args.empty()) {
- return true;
- }
-
- // Enable the install target.
- this->Makefile->GetGlobalGenerator()->EnableInstallTarget();
-
- this->DefaultComponentName =
- this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
- if (this->DefaultComponentName.empty()) {
- this->DefaultComponentName = "Unspecified";
- }
-
- std::string const& mode = args[0];
-
- // Switch among the command modes.
- if (mode == "SCRIPT") {
- return this->HandleScriptMode(args);
- }
- if (mode == "CODE") {
- return this->HandleScriptMode(args);
- }
- if (mode == "TARGETS") {
- return this->HandleTargetsMode(args);
- }
- if (mode == "FILES") {
- return this->HandleFilesMode(args);
- }
- if (mode == "PROGRAMS") {
- return this->HandleFilesMode(args);
- }
- if (mode == "DIRECTORY") {
- return this->HandleDirectoryMode(args);
- }
- if (mode == "EXPORT") {
- return this->HandleExportMode(args);
- }
- if (mode == "EXPORT_ANDROID_MK") {
- return this->HandleExportAndroidMKMode(args);
- }
-
- // Unknown mode.
- std::string e = "called with unknown mode ";
- e += args[0];
- this->SetError(e);
- return false;
+ return CreateInstallFilesGenerator(mf, absFiles, args, programs,
+ args.GetDestination());
}
-bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
+std::set<std::string> const allowedTypes{
+ "BIN", "SBIN", "LIB", "INCLUDE", "SYSCONF",
+ "SHAREDSTATE", "LOCALSTATE", "RUNSTATE", "DATA", "INFO",
+ "LOCALE", "MAN", "DOC",
+};
+
+bool HandleScriptMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- std::string component = this->DefaultComponentName;
+ Helper helper(status);
+
+ std::string component = helper.DefaultComponentName;
int componentCount = 0;
bool doing_script = false;
bool doing_code = false;
@@ -132,137 +166,140 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
}
if (componentCount > 1) {
- this->SetError("given more than one COMPONENT for the SCRIPT or CODE "
- "signature of the INSTALL command. "
- "Use multiple INSTALL commands with one COMPONENT each.");
+ status.SetError("given more than one COMPONENT for the SCRIPT or CODE "
+ "signature of the INSTALL command. "
+ "Use multiple INSTALL commands with one COMPONENT each.");
return false;
}
// Scan the args again, this time adding install generators each time we
// encounter a SCRIPT or CODE arg:
//
- for (size_t i = 0; i < args.size(); ++i) {
- if (args[i] == "SCRIPT") {
+ for (std::string const& arg : args) {
+ if (arg == "SCRIPT") {
doing_script = true;
doing_code = false;
- } else if (args[i] == "CODE") {
+ } else if (arg == "CODE") {
doing_script = false;
doing_code = true;
- } else if (args[i] == "COMPONENT") {
+ } else if (arg == "COMPONENT") {
doing_script = false;
doing_code = false;
} else if (doing_script) {
doing_script = false;
- std::string script = args[i];
- if (!cmSystemTools::FileIsFullPath(script.c_str())) {
- script = this->Makefile->GetCurrentSourceDirectory();
- script += "/";
- script += args[i];
+ std::string script = arg;
+ if (!cmSystemTools::FileIsFullPath(script)) {
+ script =
+ cmStrCat(helper.Makefile->GetCurrentSourceDirectory(), '/', arg);
}
if (cmSystemTools::FileIsDirectory(script)) {
- this->SetError("given a directory as value of SCRIPT argument.");
+ status.SetError("given a directory as value of SCRIPT argument.");
return false;
}
- this->Makefile->AddInstallGenerator(new cmInstallScriptGenerator(
+ helper.Makefile->AddInstallGenerator(new cmInstallScriptGenerator(
script.c_str(), false, component.c_str(), exclude_from_all));
} else if (doing_code) {
doing_code = false;
- std::string const& code = args[i];
- this->Makefile->AddInstallGenerator(new cmInstallScriptGenerator(
+ std::string const& code = arg;
+ helper.Makefile->AddInstallGenerator(new cmInstallScriptGenerator(
code.c_str(), true, component.c_str(), exclude_from_all));
}
}
if (doing_script) {
- this->SetError("given no value for SCRIPT argument.");
+ status.SetError("given no value for SCRIPT argument.");
return false;
}
if (doing_code) {
- this->SetError("given no value for CODE argument.");
+ status.SetError("given no value for CODE argument.");
return false;
}
// Tell the global generator about any installation component names
// specified.
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(component.c_str());
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(component);
return true;
}
-/*struct InstallPart
+bool HandleTargetsMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- InstallPart(cmCommandArgumentsHelper* helper, const char* key,
- cmCommandArgumentGroup* group);
- cmCAStringVector argVector;
- cmInstallCommandArguments args;
-};*/
+ Helper helper(status);
-bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
-{
// This is the TARGETS mode.
std::vector<cmTarget*> targets;
- cmCommandArgumentsHelper argHelper;
- cmCommandArgumentGroup group;
- cmCAStringVector genericArgVector(&argHelper, CM_NULLPTR);
- cmCAStringVector archiveArgVector(&argHelper, "ARCHIVE", &group);
- cmCAStringVector libraryArgVector(&argHelper, "LIBRARY", &group);
- cmCAStringVector runtimeArgVector(&argHelper, "RUNTIME", &group);
- cmCAStringVector objectArgVector(&argHelper, "OBJECTS", &group);
- cmCAStringVector frameworkArgVector(&argHelper, "FRAMEWORK", &group);
- cmCAStringVector bundleArgVector(&argHelper, "BUNDLE", &group);
- cmCAStringVector includesArgVector(&argHelper, "INCLUDES", &group);
- cmCAStringVector privateHeaderArgVector(&argHelper, "PRIVATE_HEADER",
- &group);
- cmCAStringVector publicHeaderArgVector(&argHelper, "PUBLIC_HEADER", &group);
- cmCAStringVector resourceArgVector(&argHelper, "RESOURCE", &group);
- genericArgVector.Follows(CM_NULLPTR);
- group.Follows(&genericArgVector);
-
- argHelper.Parse(&args, CM_NULLPTR);
+ struct ArgVectors
+ {
+ std::vector<std::string> Archive;
+ std::vector<std::string> Library;
+ std::vector<std::string> Runtime;
+ std::vector<std::string> Object;
+ std::vector<std::string> Framework;
+ std::vector<std::string> Bundle;
+ std::vector<std::string> Includes;
+ std::vector<std::string> PrivateHeader;
+ std::vector<std::string> PublicHeader;
+ std::vector<std::string> Resource;
+ };
+
+ static auto const argHelper =
+ cmArgumentParser<ArgVectors>{}
+ .Bind("ARCHIVE"_s, &ArgVectors::Archive)
+ .Bind("LIBRARY"_s, &ArgVectors::Library)
+ .Bind("RUNTIME"_s, &ArgVectors::Runtime)
+ .Bind("OBJECTS"_s, &ArgVectors::Object)
+ .Bind("FRAMEWORK"_s, &ArgVectors::Framework)
+ .Bind("BUNDLE"_s, &ArgVectors::Bundle)
+ .Bind("INCLUDES"_s, &ArgVectors::Includes)
+ .Bind("PRIVATE_HEADER"_s, &ArgVectors::PrivateHeader)
+ .Bind("PUBLIC_HEADER"_s, &ArgVectors::PublicHeader)
+ .Bind("RESOURCE"_s, &ArgVectors::Resource);
+
+ std::vector<std::string> genericArgVector;
+ ArgVectors const argVectors = argHelper.Parse(args, &genericArgVector);
// now parse the generic args (i.e. the ones not specialized on LIBRARY/
// ARCHIVE, RUNTIME etc. (see above)
// These generic args also contain the targets and the export stuff
+ std::vector<std::string> targetList;
+ std::string exports;
std::vector<std::string> unknownArgs;
- cmInstallCommandArguments genericArgs(this->DefaultComponentName);
- cmCAStringVector targetList(&genericArgs.Parser, "TARGETS");
- cmCAString exports(&genericArgs.Parser, "EXPORT",
- &genericArgs.ArgumentGroup);
- targetList.Follows(CM_NULLPTR);
- genericArgs.ArgumentGroup.Follows(&targetList);
- genericArgs.Parse(&genericArgVector.GetVector(), &unknownArgs);
+ cmInstallCommandArguments genericArgs(helper.DefaultComponentName);
+ genericArgs.Bind("TARGETS"_s, targetList);
+ genericArgs.Bind("EXPORT"_s, exports);
+ genericArgs.Parse(genericArgVector, &unknownArgs);
bool success = genericArgs.Finalize();
- cmInstallCommandArguments archiveArgs(this->DefaultComponentName);
- cmInstallCommandArguments libraryArgs(this->DefaultComponentName);
- cmInstallCommandArguments runtimeArgs(this->DefaultComponentName);
- cmInstallCommandArguments objectArgs(this->DefaultComponentName);
- cmInstallCommandArguments frameworkArgs(this->DefaultComponentName);
- cmInstallCommandArguments bundleArgs(this->DefaultComponentName);
- cmInstallCommandArguments privateHeaderArgs(this->DefaultComponentName);
- cmInstallCommandArguments publicHeaderArgs(this->DefaultComponentName);
- cmInstallCommandArguments resourceArgs(this->DefaultComponentName);
+ cmInstallCommandArguments archiveArgs(helper.DefaultComponentName);
+ cmInstallCommandArguments libraryArgs(helper.DefaultComponentName);
+ cmInstallCommandArguments runtimeArgs(helper.DefaultComponentName);
+ cmInstallCommandArguments objectArgs(helper.DefaultComponentName);
+ cmInstallCommandArguments frameworkArgs(helper.DefaultComponentName);
+ cmInstallCommandArguments bundleArgs(helper.DefaultComponentName);
+ cmInstallCommandArguments privateHeaderArgs(helper.DefaultComponentName);
+ cmInstallCommandArguments publicHeaderArgs(helper.DefaultComponentName);
+ cmInstallCommandArguments resourceArgs(helper.DefaultComponentName);
cmInstallCommandIncludesArgument includesArgs;
// now parse the args for specific parts of the target (e.g. LIBRARY,
// RUNTIME, ARCHIVE etc.
- archiveArgs.Parse(&archiveArgVector.GetVector(), &unknownArgs);
- libraryArgs.Parse(&libraryArgVector.GetVector(), &unknownArgs);
- runtimeArgs.Parse(&runtimeArgVector.GetVector(), &unknownArgs);
- objectArgs.Parse(&objectArgVector.GetVector(), &unknownArgs);
- frameworkArgs.Parse(&frameworkArgVector.GetVector(), &unknownArgs);
- bundleArgs.Parse(&bundleArgVector.GetVector(), &unknownArgs);
- privateHeaderArgs.Parse(&privateHeaderArgVector.GetVector(), &unknownArgs);
- publicHeaderArgs.Parse(&publicHeaderArgVector.GetVector(), &unknownArgs);
- resourceArgs.Parse(&resourceArgVector.GetVector(), &unknownArgs);
- includesArgs.Parse(&includesArgVector.GetVector(), &unknownArgs);
+ archiveArgs.Parse(argVectors.Archive, &unknownArgs);
+ libraryArgs.Parse(argVectors.Library, &unknownArgs);
+ runtimeArgs.Parse(argVectors.Runtime, &unknownArgs);
+ objectArgs.Parse(argVectors.Object, &unknownArgs);
+ frameworkArgs.Parse(argVectors.Framework, &unknownArgs);
+ bundleArgs.Parse(argVectors.Bundle, &unknownArgs);
+ privateHeaderArgs.Parse(argVectors.PrivateHeader, &unknownArgs);
+ publicHeaderArgs.Parse(argVectors.PublicHeader, &unknownArgs);
+ resourceArgs.Parse(argVectors.Resource, &unknownArgs);
+ includesArgs.Parse(&argVectors.Includes, &unknownArgs);
if (!unknownArgs.empty()) {
// Unknown argument.
- std::ostringstream e;
- e << "TARGETS given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("TARGETS given unknown argument \"", unknownArgs[0], "\"."));
return false;
}
@@ -297,7 +334,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
objectArgs.GetNamelinkOnly() || frameworkArgs.GetNamelinkOnly() ||
bundleArgs.GetNamelinkOnly() || privateHeaderArgs.GetNamelinkOnly() ||
publicHeaderArgs.GetNamelinkOnly() || resourceArgs.GetNamelinkOnly()) {
- this->SetError(
+ status.SetError(
"TARGETS given NAMELINK_ONLY option not in LIBRARY group. "
"The NAMELINK_ONLY option may be specified only following LIBRARY.");
return false;
@@ -306,14 +343,38 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
objectArgs.GetNamelinkSkip() || frameworkArgs.GetNamelinkSkip() ||
bundleArgs.GetNamelinkSkip() || privateHeaderArgs.GetNamelinkSkip() ||
publicHeaderArgs.GetNamelinkSkip() || resourceArgs.GetNamelinkSkip()) {
- this->SetError(
+ status.SetError(
"TARGETS given NAMELINK_SKIP option not in LIBRARY group. "
"The NAMELINK_SKIP option may be specified only following LIBRARY.");
return false;
}
+ if (archiveArgs.HasNamelinkComponent() ||
+ runtimeArgs.HasNamelinkComponent() ||
+ objectArgs.HasNamelinkComponent() ||
+ frameworkArgs.HasNamelinkComponent() ||
+ bundleArgs.HasNamelinkComponent() ||
+ privateHeaderArgs.HasNamelinkComponent() ||
+ publicHeaderArgs.HasNamelinkComponent() ||
+ resourceArgs.HasNamelinkComponent()) {
+ status.SetError(
+ "TARGETS given NAMELINK_COMPONENT option not in LIBRARY group. "
+ "The NAMELINK_COMPONENT option may be specified only following "
+ "LIBRARY.");
+ return false;
+ }
if (libraryArgs.GetNamelinkOnly() && libraryArgs.GetNamelinkSkip()) {
- this->SetError("TARGETS given NAMELINK_ONLY and NAMELINK_SKIP. "
- "At most one of these two options may be specified.");
+ status.SetError("TARGETS given NAMELINK_ONLY and NAMELINK_SKIP. "
+ "At most one of these two options may be specified.");
+ return false;
+ }
+ if (!genericArgs.GetType().empty() || !archiveArgs.GetType().empty() ||
+ !libraryArgs.GetType().empty() || !runtimeArgs.GetType().empty() ||
+ !objectArgs.GetType().empty() || !frameworkArgs.GetType().empty() ||
+ !bundleArgs.GetType().empty() || !privateHeaderArgs.GetType().empty() ||
+ !publicHeaderArgs.GetType().empty() || !resourceArgs.GetType().empty()) {
+ status.SetError(
+ "TARGETS given TYPE option. The TYPE option may only be specified in "
+ " install(FILES) and install(DIRECTORIES).");
return false;
}
@@ -327,28 +388,28 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
}
// Check if there is something to do.
- if (targetList.GetVector().empty()) {
+ if (targetList.empty()) {
return true;
}
- // Check whether this is a DLL platform.
- bool dll_platform =
- (this->Makefile->IsOn("WIN32") || this->Makefile->IsOn("CYGWIN") ||
- this->Makefile->IsOn("MINGW"));
-
- for (std::vector<std::string>::const_iterator targetIt =
- targetList.GetVector().begin();
- targetIt != targetList.GetVector().end(); ++targetIt) {
+ for (std::string const& tgt : targetList) {
- if (this->Makefile->IsAlias(*targetIt)) {
- std::ostringstream e;
- e << "TARGETS given target \"" << (*targetIt) << "\" which is an alias.";
- this->SetError(e.str());
+ if (helper.Makefile->IsAlias(tgt)) {
+ status.SetError(
+ cmStrCat("TARGETS given target \"", tgt, "\" which is an alias."));
return false;
}
// Lookup this target in the current directory.
- if (cmTarget* target =
- this->Makefile->FindLocalNonAliasTarget(*targetIt)) {
+ cmTarget* target = helper.Makefile->FindLocalNonAliasTarget(tgt);
+ if (!target) {
+ // If no local target has been found, find it in the global scope.
+ cmTarget* const global_target =
+ helper.Makefile->GetGlobalGenerator()->FindTarget(tgt, true);
+ if (global_target && !global_target->IsImported()) {
+ target = global_target;
+ }
+ }
+ if (target) {
// Found the target. Check its type.
if (target->GetType() != cmStateEnums::EXECUTABLE &&
target->GetType() != cmStateEnums::STATIC_LIBRARY &&
@@ -356,31 +417,17 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
target->GetType() != cmStateEnums::MODULE_LIBRARY &&
target->GetType() != cmStateEnums::OBJECT_LIBRARY &&
target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
- std::ostringstream e;
- e << "TARGETS given target \"" << (*targetIt)
- << "\" which is not an executable, library, or module.";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("TARGETS given target \"", tgt,
+ "\" which is not an executable, library, or module."));
return false;
}
- if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
- std::string reason;
- if (!this->Makefile->GetGlobalGenerator()->HasKnownObjectFileLocation(
- &reason)) {
- std::ostringstream e;
- e << "TARGETS given OBJECT library \"" << (*targetIt)
- << "\" which may not be installed" << reason << ".";
- this->SetError(e.str());
- return false;
- }
- }
// Store the target in the list to be installed.
targets.push_back(target);
} else {
// Did not find the target.
- std::ostringstream e;
- e << "TARGETS given target \"" << (*targetIt)
- << "\" which does not exist in this directory.";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("TARGETS given target \"", tgt, "\" which does not exist."));
return false;
}
}
@@ -389,6 +436,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// any files of the given type.
bool installsArchive = false;
bool installsLibrary = false;
+ bool installsNamelink = false;
bool installsRuntime = false;
bool installsObject = false;
bool installsFramework = false;
@@ -398,19 +446,19 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
bool installsResource = false;
// Generate install script code to install the given targets.
- for (std::vector<cmTarget*>::iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
+ for (cmTarget* ti : targets) {
// Handle each target type.
- cmTarget& target = *(*ti);
- cmInstallTargetGenerator* archiveGenerator = CM_NULLPTR;
- cmInstallTargetGenerator* libraryGenerator = CM_NULLPTR;
- cmInstallTargetGenerator* runtimeGenerator = CM_NULLPTR;
- cmInstallTargetGenerator* objectGenerator = CM_NULLPTR;
- cmInstallTargetGenerator* frameworkGenerator = CM_NULLPTR;
- cmInstallTargetGenerator* bundleGenerator = CM_NULLPTR;
- cmInstallFilesGenerator* privateHeaderGenerator = CM_NULLPTR;
- cmInstallFilesGenerator* publicHeaderGenerator = CM_NULLPTR;
- cmInstallFilesGenerator* resourceGenerator = CM_NULLPTR;
+ cmTarget& target = *ti;
+ cmInstallTargetGenerator* archiveGenerator = nullptr;
+ cmInstallTargetGenerator* libraryGenerator = nullptr;
+ cmInstallTargetGenerator* namelinkGenerator = nullptr;
+ cmInstallTargetGenerator* runtimeGenerator = nullptr;
+ cmInstallTargetGenerator* objectGenerator = nullptr;
+ cmInstallTargetGenerator* frameworkGenerator = nullptr;
+ cmInstallTargetGenerator* bundleGenerator = nullptr;
+ cmInstallFilesGenerator* privateHeaderGenerator = nullptr;
+ cmInstallFilesGenerator* publicHeaderGenerator = nullptr;
+ cmInstallFilesGenerator* resourceGenerator = nullptr;
// Track whether this is a namelink-only rule.
bool namelinkOnly = false;
@@ -420,7 +468,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// Shared libraries are handled differently on DLL and non-DLL
// platforms. All windows platforms are DLL platforms including
// cygwin. Currently no other platform is a DLL platform.
- if (dll_platform) {
+ if (target.IsDLLPlatform()) {
// When in namelink only mode skip all libraries on Windows.
if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) {
continue;
@@ -429,18 +477,21 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// This is a DLL platform.
if (!archiveArgs.GetDestination().empty()) {
// The import library uses the ARCHIVE properties.
- archiveGenerator =
- CreateInstallTargetGenerator(target, archiveArgs, true);
+ archiveGenerator = CreateInstallTargetGenerator(
+ target, archiveArgs, true, helper.Makefile->GetBacktrace());
}
if (!runtimeArgs.GetDestination().empty()) {
// The DLL uses the RUNTIME properties.
- runtimeGenerator =
- CreateInstallTargetGenerator(target, runtimeArgs, false);
+ runtimeGenerator = CreateInstallTargetGenerator(
+ target, runtimeArgs, false, helper.Makefile->GetBacktrace());
}
- if ((archiveGenerator == CM_NULLPTR) &&
- (runtimeGenerator == CM_NULLPTR)) {
- this->SetError("Library TARGETS given no DESTINATION!");
- return false;
+ if ((archiveGenerator == nullptr) && (runtimeGenerator == nullptr)) {
+ archiveGenerator = CreateInstallTargetGenerator(
+ target, archiveArgs, true, helper.Makefile->GetBacktrace(),
+ helper.GetArchiveDestination(nullptr));
+ runtimeGenerator = CreateInstallTargetGenerator(
+ target, runtimeArgs, false, helper.Makefile->GetBacktrace(),
+ helper.GetRuntimeDestination(nullptr));
}
} else {
// This is a non-DLL platform.
@@ -454,32 +505,33 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// Use the FRAMEWORK properties.
if (!frameworkArgs.GetDestination().empty()) {
- frameworkGenerator =
- CreateInstallTargetGenerator(target, frameworkArgs, false);
+ frameworkGenerator = CreateInstallTargetGenerator(
+ target, frameworkArgs, false, helper.Makefile->GetBacktrace());
} else {
- std::ostringstream e;
- e << "TARGETS given no FRAMEWORK DESTINATION for shared library "
- "FRAMEWORK target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("TARGETS given no FRAMEWORK DESTINATION for shared "
+ "library FRAMEWORK target \"",
+ target.GetName(), "\"."));
return false;
}
} else {
// The shared library uses the LIBRARY properties.
- if (!libraryArgs.GetDestination().empty()) {
- libraryGenerator =
- CreateInstallTargetGenerator(target, libraryArgs, false);
- libraryGenerator->SetNamelinkMode(namelinkMode);
- namelinkOnly =
- (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
- } else {
- std::ostringstream e;
- e << "TARGETS given no LIBRARY DESTINATION for shared library "
- "target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
- return false;
+ if (namelinkMode != cmInstallTargetGenerator::NamelinkModeOnly) {
+ libraryGenerator = CreateInstallTargetGenerator(
+ target, libraryArgs, false, helper.Makefile->GetBacktrace(),
+ helper.GetLibraryDestination(&libraryArgs));
+ libraryGenerator->SetNamelinkMode(
+ cmInstallTargetGenerator::NamelinkModeSkip);
+ }
+ if (namelinkMode != cmInstallTargetGenerator::NamelinkModeSkip) {
+ namelinkGenerator = CreateInstallTargetGenerator(
+ target, libraryArgs, false, helper.Makefile->GetBacktrace(),
+ helper.GetLibraryDestination(&libraryArgs), false, true);
+ namelinkGenerator->SetNamelinkMode(
+ cmInstallTargetGenerator::NamelinkModeOnly);
}
+ namelinkOnly =
+ (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
}
}
} break;
@@ -494,109 +546,98 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// Use the FRAMEWORK properties.
if (!frameworkArgs.GetDestination().empty()) {
- frameworkGenerator =
- CreateInstallTargetGenerator(target, frameworkArgs, false);
+ frameworkGenerator = CreateInstallTargetGenerator(
+ target, frameworkArgs, false, helper.Makefile->GetBacktrace());
} else {
- std::ostringstream e;
- e << "TARGETS given no FRAMEWORK DESTINATION for static library "
- "FRAMEWORK target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("TARGETS given no FRAMEWORK DESTINATION for static "
+ "library FRAMEWORK target \"",
+ target.GetName(), "\"."));
return false;
}
} else {
// Static libraries use ARCHIVE properties.
- if (!archiveArgs.GetDestination().empty()) {
- archiveGenerator =
- CreateInstallTargetGenerator(target, archiveArgs, false);
- } else {
- std::ostringstream e;
- e << "TARGETS given no ARCHIVE DESTINATION for static library "
- "target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
- return false;
- }
+ archiveGenerator = CreateInstallTargetGenerator(
+ target, archiveArgs, false, helper.Makefile->GetBacktrace(),
+ helper.GetArchiveDestination(&archiveArgs));
}
} break;
case cmStateEnums::MODULE_LIBRARY: {
// Modules use LIBRARY properties.
if (!libraryArgs.GetDestination().empty()) {
- libraryGenerator =
- CreateInstallTargetGenerator(target, libraryArgs, false);
+ libraryGenerator = CreateInstallTargetGenerator(
+ target, libraryArgs, false, helper.Makefile->GetBacktrace());
libraryGenerator->SetNamelinkMode(namelinkMode);
namelinkOnly =
(namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
} else {
- std::ostringstream e;
- e << "TARGETS given no LIBRARY DESTINATION for module target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat("TARGETS given no LIBRARY DESTINATION for module "
+ "target \"",
+ target.GetName(), "\"."));
return false;
}
} break;
case cmStateEnums::OBJECT_LIBRARY: {
// Objects use OBJECT properties.
if (!objectArgs.GetDestination().empty()) {
- objectGenerator =
- CreateInstallTargetGenerator(target, objectArgs, false);
+ // Verify that we know where the objects are to install them.
+ std::string reason;
+ if (!helper.Makefile->GetGlobalGenerator()
+ ->HasKnownObjectFileLocation(&reason)) {
+ status.SetError(
+ cmStrCat("TARGETS given OBJECT library \"", target.GetName(),
+ "\" whose objects may not be installed", reason, "."));
+ return false;
+ }
+
+ objectGenerator = CreateInstallTargetGenerator(
+ target, objectArgs, false, helper.Makefile->GetBacktrace());
} else {
- std::ostringstream e;
- e << "TARGETS given no OBJECTS DESTINATION for object library "
- "target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
- return false;
+ // Installing an OBJECT library without a destination transforms
+ // it to an INTERFACE library. It installs no files but can be
+ // exported.
}
} break;
case cmStateEnums::EXECUTABLE: {
if (target.IsAppBundleOnApple()) {
// Application bundles use the BUNDLE properties.
if (!bundleArgs.GetDestination().empty()) {
- bundleGenerator =
- CreateInstallTargetGenerator(target, bundleArgs, false);
+ bundleGenerator = CreateInstallTargetGenerator(
+ target, bundleArgs, false, helper.Makefile->GetBacktrace());
} else if (!runtimeArgs.GetDestination().empty()) {
bool failure = false;
- if (this->CheckCMP0006(failure)) {
+ if (helper.CheckCMP0006(failure)) {
// For CMake 2.4 compatibility fallback to the RUNTIME
// properties.
- bundleGenerator =
- CreateInstallTargetGenerator(target, runtimeArgs, false);
+ bundleGenerator = CreateInstallTargetGenerator(
+ target, runtimeArgs, false, helper.Makefile->GetBacktrace());
} else if (failure) {
return false;
}
}
if (!bundleGenerator) {
- std::ostringstream e;
- e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE "
- "executable target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
+ status.SetError(cmStrCat("TARGETS given no BUNDLE DESTINATION for "
+ "MACOSX_BUNDLE executable target \"",
+ target.GetName(), "\"."));
return false;
}
} else {
// Executables use the RUNTIME properties.
- if (!runtimeArgs.GetDestination().empty()) {
- runtimeGenerator =
- CreateInstallTargetGenerator(target, runtimeArgs, false);
- } else {
- std::ostringstream e;
- e << "TARGETS given no RUNTIME DESTINATION for executable "
- "target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
- return false;
- }
+ runtimeGenerator = CreateInstallTargetGenerator(
+ target, runtimeArgs, false, helper.Makefile->GetBacktrace(),
+ helper.GetRuntimeDestination(&runtimeArgs));
}
// On DLL platforms an executable may also have an import
// library. Install it to the archive destination if it
// exists.
- if (dll_platform && !archiveArgs.GetDestination().empty() &&
+ if ((target.IsDLLPlatform() || target.IsAIX()) &&
+ !archiveArgs.GetDestination().empty() &&
target.IsExecutableWithExports()) {
// The import library uses the ARCHIVE properties.
- archiveGenerator =
- CreateInstallTargetGenerator(target, archiveArgs, true, true);
+ archiveGenerator = CreateInstallTargetGenerator(
+ target, archiveArgs, true, helper.Makefile->GetBacktrace(), true);
}
} break;
case cmStateEnums::INTERFACE_LIBRARY:
@@ -617,103 +658,89 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// generators for them.
bool createInstallGeneratorsForTargetFileSets = true;
- if (target.IsFrameworkOnApple() ||
- target.GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (target.IsFrameworkOnApple()) {
createInstallGeneratorsForTargetFileSets = false;
}
if (createInstallGeneratorsForTargetFileSets && !namelinkOnly) {
const char* files = target.GetProperty("PRIVATE_HEADER");
if ((files) && (*files)) {
- std::vector<std::string> relFiles;
- cmSystemTools::ExpandListArgument(files, relFiles);
+ std::vector<std::string> relFiles = cmExpandedList(files);
std::vector<std::string> absFiles;
- if (!this->MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles)) {
+ if (!helper.MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles)) {
return false;
}
// Create the files install generator.
- if (!privateHeaderArgs.GetDestination().empty()) {
- privateHeaderGenerator = CreateInstallFilesGenerator(
- this->Makefile, absFiles, privateHeaderArgs, false);
- } else {
- std::ostringstream e;
- e << "INSTALL TARGETS - target " << target.GetName() << " has "
- << "PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION.";
- cmSystemTools::Message(e.str().c_str(), "Warning");
- }
+ privateHeaderGenerator = CreateInstallFilesGenerator(
+ helper.Makefile, absFiles, privateHeaderArgs, false,
+ helper.GetIncludeDestination(&privateHeaderArgs));
}
files = target.GetProperty("PUBLIC_HEADER");
if ((files) && (*files)) {
- std::vector<std::string> relFiles;
- cmSystemTools::ExpandListArgument(files, relFiles);
+ std::vector<std::string> relFiles = cmExpandedList(files);
std::vector<std::string> absFiles;
- if (!this->MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles)) {
+ if (!helper.MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles)) {
return false;
}
// Create the files install generator.
- if (!publicHeaderArgs.GetDestination().empty()) {
- publicHeaderGenerator = CreateInstallFilesGenerator(
- this->Makefile, absFiles, publicHeaderArgs, false);
- } else {
- std::ostringstream e;
- e << "INSTALL TARGETS - target " << target.GetName() << " has "
- << "PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.";
- cmSystemTools::Message(e.str().c_str(), "Warning");
- }
+ publicHeaderGenerator = CreateInstallFilesGenerator(
+ helper.Makefile, absFiles, publicHeaderArgs, false,
+ helper.GetIncludeDestination(&publicHeaderArgs));
}
files = target.GetProperty("RESOURCE");
if ((files) && (*files)) {
- std::vector<std::string> relFiles;
- cmSystemTools::ExpandListArgument(files, relFiles);
+ std::vector<std::string> relFiles = cmExpandedList(files);
std::vector<std::string> absFiles;
- if (!this->MakeFilesFullPath("RESOURCE", relFiles, absFiles)) {
+ if (!helper.MakeFilesFullPath("RESOURCE", relFiles, absFiles)) {
return false;
}
// Create the files install generator.
if (!resourceArgs.GetDestination().empty()) {
resourceGenerator = CreateInstallFilesGenerator(
- this->Makefile, absFiles, resourceArgs, false);
+ helper.Makefile, absFiles, resourceArgs, false);
} else {
- std::ostringstream e;
- e << "INSTALL TARGETS - target " << target.GetName() << " has "
- << "RESOURCE files but no RESOURCE DESTINATION.";
- cmSystemTools::Message(e.str().c_str(), "Warning");
+ cmSystemTools::Message(
+ cmStrCat("INSTALL TARGETS - target ", target.GetName(),
+ " has RESOURCE files but no RESOURCE DESTINATION."),
+ "Warning");
}
}
}
// Keep track of whether we're installing anything in each category
- installsArchive = installsArchive || archiveGenerator != CM_NULLPTR;
- installsLibrary = installsLibrary || libraryGenerator != CM_NULLPTR;
- installsRuntime = installsRuntime || runtimeGenerator != CM_NULLPTR;
- installsObject = installsObject || objectGenerator != CM_NULLPTR;
- installsFramework = installsFramework || frameworkGenerator != CM_NULLPTR;
- installsBundle = installsBundle || bundleGenerator != CM_NULLPTR;
+ installsArchive = installsArchive || archiveGenerator != nullptr;
+ installsLibrary = installsLibrary || libraryGenerator != nullptr;
+ installsNamelink = installsNamelink || namelinkGenerator != nullptr;
+ installsRuntime = installsRuntime || runtimeGenerator != nullptr;
+ installsObject = installsObject || objectGenerator != nullptr;
+ installsFramework = installsFramework || frameworkGenerator != nullptr;
+ installsBundle = installsBundle || bundleGenerator != nullptr;
installsPrivateHeader =
- installsPrivateHeader || privateHeaderGenerator != CM_NULLPTR;
+ installsPrivateHeader || privateHeaderGenerator != nullptr;
installsPublicHeader =
- installsPublicHeader || publicHeaderGenerator != CM_NULLPTR;
+ installsPublicHeader || publicHeaderGenerator != nullptr;
installsResource = installsResource || resourceGenerator;
- this->Makefile->AddInstallGenerator(archiveGenerator);
- this->Makefile->AddInstallGenerator(libraryGenerator);
- this->Makefile->AddInstallGenerator(runtimeGenerator);
- this->Makefile->AddInstallGenerator(objectGenerator);
- this->Makefile->AddInstallGenerator(frameworkGenerator);
- this->Makefile->AddInstallGenerator(bundleGenerator);
- this->Makefile->AddInstallGenerator(privateHeaderGenerator);
- this->Makefile->AddInstallGenerator(publicHeaderGenerator);
- this->Makefile->AddInstallGenerator(resourceGenerator);
+ helper.Makefile->AddInstallGenerator(archiveGenerator);
+ helper.Makefile->AddInstallGenerator(libraryGenerator);
+ helper.Makefile->AddInstallGenerator(namelinkGenerator);
+ helper.Makefile->AddInstallGenerator(runtimeGenerator);
+ helper.Makefile->AddInstallGenerator(objectGenerator);
+ helper.Makefile->AddInstallGenerator(frameworkGenerator);
+ helper.Makefile->AddInstallGenerator(bundleGenerator);
+ helper.Makefile->AddInstallGenerator(privateHeaderGenerator);
+ helper.Makefile->AddInstallGenerator(publicHeaderGenerator);
+ helper.Makefile->AddInstallGenerator(resourceGenerator);
// Add this install rule to an export if one was specified and
// this is not a namelink-only rule.
- if (!exports.GetString().empty() && !namelinkOnly) {
- cmTargetExport* te = new cmTargetExport;
+ if (!exports.empty() && !namelinkOnly) {
+ auto te = cm::make_unique<cmTargetExport>();
te->TargetName = target.GetName();
te->ArchiveGenerator = archiveGenerator;
te->BundleGenerator = bundleGenerator;
@@ -722,77 +749,89 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
te->LibraryGenerator = libraryGenerator;
te->RuntimeGenerator = runtimeGenerator;
te->ObjectsGenerator = objectGenerator;
- this->Makefile->GetGlobalGenerator()
- ->GetExportSets()[exports.GetString()]
- ->AddTargetExport(te);
-
te->InterfaceIncludeDirectories =
cmJoin(includesArgs.GetIncludeDirs(), ";");
+
+ helper.Makefile->GetGlobalGenerator()
+ ->GetExportSets()[exports]
+ .AddTargetExport(std::move(te));
}
}
// Tell the global generator about any installation component names
// specified
if (installsArchive) {
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- archiveArgs.GetComponent().c_str());
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
+ archiveArgs.GetComponent());
}
if (installsLibrary) {
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- libraryArgs.GetComponent().c_str());
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
+ libraryArgs.GetComponent());
+ }
+ if (installsNamelink) {
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
+ libraryArgs.GetNamelinkComponent());
}
if (installsRuntime) {
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- runtimeArgs.GetComponent().c_str());
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
+ runtimeArgs.GetComponent());
}
if (installsObject) {
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- objectArgs.GetComponent().c_str());
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
+ objectArgs.GetComponent());
}
if (installsFramework) {
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- frameworkArgs.GetComponent().c_str());
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
+ frameworkArgs.GetComponent());
}
if (installsBundle) {
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- bundleArgs.GetComponent().c_str());
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
+ bundleArgs.GetComponent());
}
if (installsPrivateHeader) {
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- privateHeaderArgs.GetComponent().c_str());
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
+ privateHeaderArgs.GetComponent());
}
if (installsPublicHeader) {
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- publicHeaderArgs.GetComponent().c_str());
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
+ publicHeaderArgs.GetComponent());
}
if (installsResource) {
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- resourceArgs.GetComponent().c_str());
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
+ resourceArgs.GetComponent());
}
return true;
}
-bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
+bool HandleFilesMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
+ Helper helper(status);
+
// This is the FILES mode.
bool programs = (args[0] == "PROGRAMS");
- cmInstallCommandArguments ica(this->DefaultComponentName);
- cmCAStringVector files(&ica.Parser, programs ? "PROGRAMS" : "FILES");
- files.Follows(CM_NULLPTR);
- ica.ArgumentGroup.Follows(&files);
+ cmInstallCommandArguments ica(helper.DefaultComponentName);
+ std::vector<std::string> files;
+ ica.Bind(programs ? "PROGRAMS"_s : "FILES"_s, files);
std::vector<std::string> unknownArgs;
- ica.Parse(&args, &unknownArgs);
+ ica.Parse(args, &unknownArgs);
if (!unknownArgs.empty()) {
// Unknown argument.
- std::ostringstream e;
- e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\"."));
+ return false;
+ }
+
+ std::string type = ica.GetType();
+ if (!type.empty() && allowedTypes.count(type) == 0) {
+ status.SetError(
+ cmStrCat(args[0], " given non-type \"", type, "\" with TYPE argument."));
return false;
}
- const std::vector<std::string>& filesVector = files.GetVector();
+ const std::vector<std::string>& filesVector = files;
// Check if there is something to do.
if (filesVector.empty()) {
@@ -801,29 +840,27 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
if (!ica.GetRename().empty() && filesVector.size() > 1) {
// The rename option works only with one file.
- std::ostringstream e;
- e << args[0] << " given RENAME option with more than one file.";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " given RENAME option with more than one file."));
return false;
}
std::vector<std::string> absFiles;
- if (!this->MakeFilesFullPath(args[0].c_str(), filesVector, absFiles)) {
+ if (!helper.MakeFilesFullPath(args[0].c_str(), filesVector, absFiles)) {
return false;
}
- cmPolicies::PolicyStatus status =
- this->Makefile->GetPolicyStatus(cmPolicies::CMP0062);
+ cmPolicies::PolicyStatus policyStatus =
+ helper.Makefile->GetPolicyStatus(cmPolicies::CMP0062);
- cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
- for (std::vector<std::string>::const_iterator fileIt = filesVector.begin();
- fileIt != filesVector.end(); ++fileIt) {
- if (gg->IsExportedTargetsFile(*fileIt)) {
- const char* modal = CM_NULLPTR;
+ cmGlobalGenerator* gg = helper.Makefile->GetGlobalGenerator();
+ for (std::string const& file : filesVector) {
+ if (gg->IsExportedTargetsFile(file)) {
+ const char* modal = nullptr;
std::ostringstream e;
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ MessageType messageType = MessageType::AUTHOR_WARNING;
- switch (status) {
+ switch (policyStatus) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0062) << "\n";
modal = "should";
@@ -833,16 +870,18 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
modal = "may";
- messageType = cmake::FATAL_ERROR;
+ messageType = MessageType::FATAL_ERROR;
}
if (modal) {
- e << "The file\n " << *fileIt << "\nwas generated by the export() "
- "command. It "
- << modal << " not be installed with the "
- "install() command. Use the install(EXPORT) mechanism "
- "instead. See the cmake-packages(7) manual for more.\n";
- this->Makefile->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR) {
+ e << "The file\n " << file
+ << "\nwas generated by the export() "
+ "command. It "
+ << modal
+ << " not be installed with the "
+ "install() command. Use the install(EXPORT) mechanism "
+ "instead. See the cmake-packages(7) manual for more.\n";
+ helper.Makefile->IssueMessage(messageType, e.str());
+ if (messageType == MessageType::FATAL_ERROR) {
return false;
}
}
@@ -853,29 +892,37 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
return false;
}
- if (ica.GetDestination().empty()) {
+ if (!type.empty() && !ica.GetDestination().empty()) {
+ status.SetError(cmStrCat(args[0],
+ " given both TYPE and DESTINATION arguments. "
+ "You may only specify one."));
+ return false;
+ }
+
+ std::string destination = helper.GetDestinationForType(&ica, type);
+ if (destination.empty()) {
// A destination is required.
- std::ostringstream e;
- e << args[0] << " given no DESTINATION!";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " given no DESTINATION!"));
return false;
}
// Create the files install generator.
- this->Makefile->AddInstallGenerator(
- CreateInstallFilesGenerator(this->Makefile, absFiles, ica, programs));
+ helper.Makefile->AddInstallGenerator(CreateInstallFilesGenerator(
+ helper.Makefile, absFiles, ica, programs, destination));
// Tell the global generator about any installation component names
// specified.
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- ica.GetComponent().c_str());
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(
+ ica.GetComponent());
return true;
}
-bool cmInstallCommand::HandleDirectoryMode(
- std::vector<std::string> const& args)
+bool HandleDirectoryMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
+ Helper helper(status);
+
enum Doing
{
DoingNone,
@@ -887,7 +934,8 @@ bool cmInstallCommand::HandleDirectoryMode(
DoingPermsDir,
DoingPermsMatch,
DoingConfigurations,
- DoingComponent
+ DoingComponent,
+ DoingType
};
Doing doing = DoingDirs;
bool in_match_mode = false;
@@ -895,30 +943,36 @@ bool cmInstallCommand::HandleDirectoryMode(
bool exclude_from_all = false;
bool message_never = false;
std::vector<std::string> dirs;
- const char* destination = CM_NULLPTR;
+ const char* destination = nullptr;
std::string permissions_file;
std::string permissions_dir;
std::vector<std::string> configurations;
- std::string component = this->DefaultComponentName;
+ std::string component = helper.DefaultComponentName;
std::string literal_args;
+ std::string type;
for (unsigned int i = 1; i < args.size(); ++i) {
if (args[i] == "DESTINATION") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
// Switch to setting the destination property.
doing = DoingDestination;
+ } else if (args[i] == "TYPE") {
+ if (in_match_mode) {
+ status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
+ return false;
+ }
+
+ // Switch to setting the type.
+ doing = DoingType;
} else if (args[i] == "OPTIONAL") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -927,10 +981,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingNone;
} else if (args[i] == "MESSAGE_NEVER") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -948,20 +1000,16 @@ bool cmInstallCommand::HandleDirectoryMode(
} else if (args[i] == "EXCLUDE") {
// Add this property to the current match rule.
if (!in_match_mode || doing == DoingPattern || doing == DoingRegex) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" before a PATTERN or REGEX is given.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" before a PATTERN or REGEX is given."));
return false;
}
literal_args += " EXCLUDE";
doing = DoingNone;
} else if (args[i] == "PERMISSIONS") {
if (!in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" before a PATTERN or REGEX is given.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" before a PATTERN or REGEX is given."));
return false;
}
@@ -970,10 +1018,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingPermsMatch;
} else if (args[i] == "FILE_PERMISSIONS") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -981,10 +1027,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingPermsFile;
} else if (args[i] == "DIRECTORY_PERMISSIONS") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -992,10 +1036,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingPermsDir;
} else if (args[i] == "USE_SOURCE_PERMISSIONS") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1004,10 +1046,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingNone;
} else if (args[i] == "FILES_MATCHING") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1016,10 +1056,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingNone;
} else if (args[i] == "CONFIGURATIONS") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1027,10 +1065,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingConfigurations;
} else if (args[i] == "COMPONENT") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1038,10 +1074,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingComponent;
} else if (args[i] == "EXCLUDE_FROM_ALL") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
exclude_from_all = true;
@@ -1050,29 +1084,35 @@ bool cmInstallCommand::HandleDirectoryMode(
// Convert this directory to a full path.
std::string dir = args[i];
std::string::size_type gpos = cmGeneratorExpression::Find(dir);
- if (gpos != 0 && !cmSystemTools::FileIsFullPath(dir.c_str())) {
- dir = this->Makefile->GetCurrentSourceDirectory();
- dir += "/";
- dir += args[i];
+ if (gpos != 0 && !cmSystemTools::FileIsFullPath(dir)) {
+ dir =
+ cmStrCat(helper.Makefile->GetCurrentSourceDirectory(), '/', args[i]);
}
// Make sure the name is a directory.
- if (cmSystemTools::FileExists(dir.c_str()) &&
+ if (cmSystemTools::FileExists(dir) &&
!cmSystemTools::FileIsDirectory(dir)) {
- std::ostringstream e;
- e << args[0] << " given non-directory \"" << args[i]
- << "\" to install.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " given non-directory \"", args[i],
+ "\" to install."));
return false;
}
// Store the directory for installation.
- dirs.push_back(dir);
+ dirs.push_back(std::move(dir));
} else if (doing == DoingConfigurations) {
configurations.push_back(args[i]);
} else if (doing == DoingDestination) {
destination = args[i].c_str();
doing = DoingNone;
+ } else if (doing == DoingType) {
+ if (allowedTypes.count(args[i]) == 0) {
+ status.SetError(cmStrCat(args[0], " given non-type \"", args[i],
+ "\" with TYPE argument."));
+ return false;
+ }
+
+ type = args[i];
+ doing = DoingNone;
} else if (doing == DoingPattern) {
// Convert the pattern to a regular expression. Require a
// leading slash and trailing end-of-string in the matched
@@ -1103,95 +1143,101 @@ bool cmInstallCommand::HandleDirectoryMode(
// Check the requested permission.
if (!cmInstallCommandArguments::CheckPermissions(args[i],
permissions_file)) {
- std::ostringstream e;
- e << args[0] << " given invalid file permission \"" << args[i]
- << "\".";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " given invalid file permission \"",
+ args[i], "\"."));
return false;
}
} else if (doing == DoingPermsDir) {
// Check the requested permission.
if (!cmInstallCommandArguments::CheckPermissions(args[i],
permissions_dir)) {
- std::ostringstream e;
- e << args[0] << " given invalid directory permission \"" << args[i]
- << "\".";
- this->SetError(e.str());
+ status.SetError(cmStrCat(
+ args[0], " given invalid directory permission \"", args[i], "\"."));
return false;
}
} else if (doing == DoingPermsMatch) {
// Check the requested permission.
if (!cmInstallCommandArguments::CheckPermissions(args[i],
literal_args)) {
- std::ostringstream e;
- e << args[0] << " given invalid permission \"" << args[i] << "\".";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " given invalid permission \"", args[i], "\"."));
return false;
}
} else {
// Unknown argument.
- std::ostringstream e;
- e << args[0] << " given unknown argument \"" << args[i] << "\".";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " given unknown argument \"", args[i], "\"."));
return false;
}
}
// Support installing an empty directory.
if (dirs.empty() && destination) {
- dirs.push_back("");
+ dirs.emplace_back();
}
// Check if there is something to do.
if (dirs.empty()) {
return true;
}
+ std::string destinationStr;
if (!destination) {
- // A destination is required.
- std::ostringstream e;
- e << args[0] << " given no DESTINATION!";
- this->SetError(e.str());
+ if (type.empty()) {
+ // A destination is required.
+ status.SetError(cmStrCat(args[0], " given no DESTINATION!"));
+ return false;
+ }
+ destinationStr = helper.GetDestinationForType(nullptr, type);
+ destination = destinationStr.c_str();
+ } else if (!type.empty()) {
+ status.SetError(cmStrCat(args[0],
+ " given both TYPE and DESTINATION "
+ "arguments. You may only specify one."));
return false;
}
cmInstallGenerator::MessageLevel message =
- cmInstallGenerator::SelectMessageLevel(this->Makefile, message_never);
+ cmInstallGenerator::SelectMessageLevel(helper.Makefile, message_never);
// Create the directory install generator.
- this->Makefile->AddInstallGenerator(new cmInstallDirectoryGenerator(
+ helper.Makefile->AddInstallGenerator(new cmInstallDirectoryGenerator(
dirs, destination, permissions_file.c_str(), permissions_dir.c_str(),
configurations, component.c_str(), message, exclude_from_all,
literal_args.c_str(), optional));
// Tell the global generator about any installation component names
// specified.
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(component.c_str());
+ helper.Makefile->GetGlobalGenerator()->AddInstallComponent(component);
return true;
}
-bool cmInstallCommand::HandleExportAndroidMKMode(
- std::vector<std::string> const& args)
+bool HandleExportAndroidMKMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
+ Helper helper(status);
+
// This is the EXPORT mode.
- cmInstallCommandArguments ica(this->DefaultComponentName);
- cmCAString exp(&ica.Parser, "EXPORT_ANDROID_MK");
- cmCAString name_space(&ica.Parser, "NAMESPACE", &ica.ArgumentGroup);
- cmCAEnabler exportOld(&ica.Parser, "EXPORT_LINK_INTERFACE_LIBRARIES",
- &ica.ArgumentGroup);
- cmCAString filename(&ica.Parser, "FILE", &ica.ArgumentGroup);
- exp.Follows(CM_NULLPTR);
-
- ica.ArgumentGroup.Follows(&exp);
+ cmInstallCommandArguments ica(helper.DefaultComponentName);
+
+ std::string exp;
+ std::string name_space;
+ bool exportOld = false;
+ std::string filename;
+
+ ica.Bind("EXPORT_ANDROID_MK"_s, exp);
+ ica.Bind("NAMESPACE"_s, name_space);
+ ica.Bind("EXPORT_LINK_INTERFACE_LIBRARIES"_s, exportOld);
+ ica.Bind("FILE"_s, filename);
+
std::vector<std::string> unknownArgs;
- ica.Parse(&args, &unknownArgs);
+ ica.Parse(args, &unknownArgs);
if (!unknownArgs.empty()) {
// Unknown argument.
- std::ostringstream e;
- e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\"."));
return false;
}
@@ -1202,39 +1248,35 @@ bool cmInstallCommand::HandleExportAndroidMKMode(
// Make sure there is a destination.
if (ica.GetDestination().empty()) {
// A destination is required.
- std::ostringstream e;
- e << args[0] << " given no DESTINATION!";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " given no DESTINATION!"));
return false;
}
// Check the file name.
- std::string fname = filename.GetString();
+ std::string fname = filename;
if (fname.find_first_of(":/\\") != std::string::npos) {
- std::ostringstream e;
- e << args[0] << " given invalid export file name \"" << fname << "\". "
- << "The FILE argument may not contain a path. "
- << "Specify the path in the DESTINATION argument.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " given invalid export file name \"",
+ fname,
+ "\". The FILE argument may not contain a path. "
+ "Specify the path in the DESTINATION argument."));
return false;
}
// Check the file extension.
if (!fname.empty() &&
cmSystemTools::GetFilenameLastExtension(fname) != ".mk") {
- std::ostringstream e;
- e << args[0] << " given invalid export file name \"" << fname << "\". "
- << "The FILE argument must specify a name ending in \".mk\".";
- this->SetError(e.str());
+ status.SetError(cmStrCat(
+ args[0], " given invalid export file name \"", fname,
+ R"(". The FILE argument must specify a name ending in ".mk".)"));
return false;
}
if (fname.find_first_of(":/\\") != std::string::npos) {
- std::ostringstream e;
- e << args[0] << " given export name \"" << exp.GetString() << "\". "
- << "This name cannot be safely converted to a file name. "
- << "Specify a different export name or use the FILE option to set "
- << "a file name explicitly.";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " given export name \"", exp,
+ "\". "
+ "This name cannot be safely converted to a file name. "
+ "Specify a different export name or use the FILE option to set "
+ "a file name explicitly."));
return false;
}
// Use the default name
@@ -1242,48 +1284,53 @@ bool cmInstallCommand::HandleExportAndroidMKMode(
fname = "Android.mk";
}
- cmExportSet* exportSet =
- this->Makefile->GetGlobalGenerator()->GetExportSets()[exp.GetString()];
+ cmExportSet& exportSet =
+ helper.Makefile->GetGlobalGenerator()->GetExportSets()[exp];
cmInstallGenerator::MessageLevel message =
- cmInstallGenerator::SelectMessageLevel(this->Makefile);
+ cmInstallGenerator::SelectMessageLevel(helper.Makefile);
// Create the export install generator.
cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator(
- exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
+ &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
ica.GetConfigurations(), ica.GetComponent().c_str(), message,
- ica.GetExcludeFromAll(), fname.c_str(), name_space.GetCString(),
- exportOld.IsEnabled(), true);
- this->Makefile->AddInstallGenerator(exportGenerator);
+ ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
+ true);
+ helper.Makefile->AddInstallGenerator(exportGenerator);
return true;
#else
static_cast<void>(args);
- this->SetError("EXPORT_ANDROID_MK not supported in bootstrap cmake");
+ status.SetError("EXPORT_ANDROID_MK not supported in bootstrap cmake");
return false;
#endif
}
-bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
+bool HandleExportMode(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
+ Helper helper(status);
+
// This is the EXPORT mode.
- cmInstallCommandArguments ica(this->DefaultComponentName);
- cmCAString exp(&ica.Parser, "EXPORT");
- cmCAString name_space(&ica.Parser, "NAMESPACE", &ica.ArgumentGroup);
- cmCAEnabler exportOld(&ica.Parser, "EXPORT_LINK_INTERFACE_LIBRARIES",
- &ica.ArgumentGroup);
- cmCAString filename(&ica.Parser, "FILE", &ica.ArgumentGroup);
- exp.Follows(CM_NULLPTR);
-
- ica.ArgumentGroup.Follows(&exp);
+ cmInstallCommandArguments ica(helper.DefaultComponentName);
+
+ std::string exp;
+ std::string name_space;
+ bool exportOld = false;
+ std::string filename;
+
+ ica.Bind("EXPORT"_s, exp);
+ ica.Bind("NAMESPACE"_s, name_space);
+ ica.Bind("EXPORT_LINK_INTERFACE_LIBRARIES"_s, exportOld);
+ ica.Bind("FILE"_s, filename);
+
std::vector<std::string> unknownArgs;
- ica.Parse(&args, &unknownArgs);
+ ica.Parse(args, &unknownArgs);
if (!unknownArgs.empty()) {
// Unknown argument.
- std::ostringstream e;
- e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\"."));
return false;
}
@@ -1294,121 +1341,110 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
// Make sure there is a destination.
if (ica.GetDestination().empty()) {
// A destination is required.
- std::ostringstream e;
- e << args[0] << " given no DESTINATION!";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " given no DESTINATION!"));
return false;
}
// Check the file name.
- std::string fname = filename.GetString();
+ std::string fname = filename;
if (fname.find_first_of(":/\\") != std::string::npos) {
- std::ostringstream e;
- e << args[0] << " given invalid export file name \"" << fname << "\". "
- << "The FILE argument may not contain a path. "
- << "Specify the path in the DESTINATION argument.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(args[0], " given invalid export file name \"",
+ fname,
+ "\". "
+ "The FILE argument may not contain a path. "
+ "Specify the path in the DESTINATION argument."));
return false;
}
// Check the file extension.
if (!fname.empty() &&
cmSystemTools::GetFilenameLastExtension(fname) != ".cmake") {
- std::ostringstream e;
- e << args[0] << " given invalid export file name \"" << fname << "\". "
- << "The FILE argument must specify a name ending in \".cmake\".";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " given invalid export file name \"", fname,
+ "\". "
+ "The FILE argument must specify a name ending in \".cmake\"."));
return false;
}
// Construct the file name.
if (fname.empty()) {
- fname = exp.GetString();
- fname += ".cmake";
+ fname = cmStrCat(exp, ".cmake");
if (fname.find_first_of(":/\\") != std::string::npos) {
- std::ostringstream e;
- e << args[0] << " given export name \"" << exp.GetString() << "\". "
- << "This name cannot be safely converted to a file name. "
- << "Specify a different export name or use the FILE option to set "
- << "a file name explicitly.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(
+ args[0], " given export name \"", exp,
+ "\". "
+ "This name cannot be safely converted to a file name. "
+ "Specify a different export name or use the FILE option to set "
+ "a file name explicitly."));
return false;
}
}
- cmExportSet* exportSet =
- this->Makefile->GetGlobalGenerator()->GetExportSets()[exp.GetString()];
- if (exportOld.IsEnabled()) {
- for (std::vector<cmTargetExport*>::const_iterator tei =
- exportSet->GetTargetExports()->begin();
- tei != exportSet->GetTargetExports()->end(); ++tei) {
- cmTargetExport const* te = *tei;
+ cmExportSet& exportSet =
+ helper.Makefile->GetGlobalGenerator()->GetExportSets()[exp];
+ if (exportOld) {
+ for (auto const& te : exportSet.GetTargetExports()) {
cmTarget* tgt =
- this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName);
+ helper.Makefile->GetGlobalGenerator()->FindTarget(te->TargetName);
const bool newCMP0022Behavior =
(tgt && tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD);
if (!newCMP0022Behavior) {
- std::ostringstream e;
- e << "INSTALL(EXPORT) given keyword \""
- << "EXPORT_LINK_INTERFACE_LIBRARIES"
- << "\", but target \"" << te->TargetName
- << "\" does not have policy CMP0022 set to NEW.";
- this->SetError(e.str());
+ status.SetError(cmStrCat(
+ "INSTALL(EXPORT) given keyword \""
+ "EXPORT_LINK_INTERFACE_LIBRARIES\", but target \"",
+ te->TargetName, "\" does not have policy CMP0022 set to NEW."));
return false;
}
}
}
cmInstallGenerator::MessageLevel message =
- cmInstallGenerator::SelectMessageLevel(this->Makefile);
+ cmInstallGenerator::SelectMessageLevel(helper.Makefile);
// Create the export install generator.
cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator(
- exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
+ &exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
ica.GetConfigurations(), ica.GetComponent().c_str(), message,
- ica.GetExcludeFromAll(), fname.c_str(), name_space.GetCString(),
- exportOld.IsEnabled(), false);
- this->Makefile->AddInstallGenerator(exportGenerator);
+ ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
+ false);
+ helper.Makefile->AddInstallGenerator(exportGenerator);
return true;
}
-bool cmInstallCommand::MakeFilesFullPath(
- const char* modeName, const std::vector<std::string>& relFiles,
- std::vector<std::string>& absFiles)
+bool Helper::MakeFilesFullPath(const char* modeName,
+ const std::vector<std::string>& relFiles,
+ std::vector<std::string>& absFiles)
{
- for (std::vector<std::string>::const_iterator fileIt = relFiles.begin();
- fileIt != relFiles.end(); ++fileIt) {
- std::string file = (*fileIt);
+ for (std::string const& relFile : relFiles) {
+ std::string file = relFile;
std::string::size_type gpos = cmGeneratorExpression::Find(file);
- if (gpos != 0 && !cmSystemTools::FileIsFullPath(file.c_str())) {
- file = this->Makefile->GetCurrentSourceDirectory();
- file += "/";
- file += *fileIt;
+ if (gpos != 0 && !cmSystemTools::FileIsFullPath(file)) {
+ file =
+ cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', relFile);
}
// Make sure the file is not a directory.
if (gpos == std::string::npos && cmSystemTools::FileIsDirectory(file)) {
- std::ostringstream e;
- e << modeName << " given directory \"" << (*fileIt) << "\" to install.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(modeName, " given directory \"", relFile, "\" to install."));
return false;
}
// Store the file for installation.
- absFiles.push_back(file);
+ absFiles.push_back(std::move(file));
}
return true;
}
-bool cmInstallCommand::CheckCMP0006(bool& failure)
+bool Helper::CheckCMP0006(bool& failure)
{
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0006)) {
case cmPolicies::WARN:
this->Makefile->IssueMessage(
- cmake::AUTHOR_WARNING,
+ MessageType::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(cmPolicies::CMP0006));
CM_FALLTHROUGH;
case cmPolicies::OLD:
@@ -1421,9 +1457,191 @@ bool cmInstallCommand::CheckCMP0006(bool& failure)
case cmPolicies::REQUIRED_ALWAYS:
failure = true;
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0006));
break;
}
return false;
}
+
+std::string Helper::GetDestination(const cmInstallCommandArguments* args,
+ const std::string& varName,
+ const std::string& guess)
+{
+ if (args && !args->GetDestination().empty()) {
+ return args->GetDestination();
+ }
+ std::string val = this->Makefile->GetSafeDefinition(varName);
+ if (!val.empty()) {
+ return val;
+ }
+ return guess;
+}
+
+std::string Helper::GetRuntimeDestination(
+ const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_BINDIR", "bin");
+}
+
+std::string Helper::GetSbinDestination(const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_SBINDIR", "sbin");
+}
+
+std::string Helper::GetArchiveDestination(
+ const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_LIBDIR", "lib");
+}
+
+std::string Helper::GetLibraryDestination(
+ const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_LIBDIR", "lib");
+}
+
+std::string Helper::GetIncludeDestination(
+ const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_INCLUDEDIR", "include");
+}
+
+std::string Helper::GetSysconfDestination(
+ const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_SYSCONFDIR", "etc");
+}
+
+std::string Helper::GetSharedStateDestination(
+ const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_SHAREDSTATEDIR", "com");
+}
+
+std::string Helper::GetLocalStateDestination(
+ const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_LOCALSTATEDIR", "var");
+}
+
+std::string Helper::GetRunStateDestination(
+ const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_RUNSTATEDIR",
+ this->GetLocalStateDestination(nullptr) +
+ "/run");
+}
+
+std::string Helper::GetDataRootDestination(
+ const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_DATAROOTDIR", "share");
+}
+
+std::string Helper::GetDataDestination(const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_DATADIR",
+ this->GetDataRootDestination(nullptr));
+}
+
+std::string Helper::GetInfoDestination(const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_INFODIR",
+ this->GetDataRootDestination(nullptr) + "/info");
+}
+
+std::string Helper::GetLocaleDestination(const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_LOCALEDIR",
+ this->GetDataRootDestination(nullptr) +
+ "/locale");
+}
+
+std::string Helper::GetManDestination(const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_MANDIR",
+ this->GetDataRootDestination(nullptr) + "/man");
+}
+
+std::string Helper::GetDocDestination(const cmInstallCommandArguments* args)
+{
+ return this->GetDestination(args, "CMAKE_INSTALL_DOCDIR",
+ this->GetDataRootDestination(nullptr) + "/doc");
+}
+
+std::string Helper::GetDestinationForType(
+ const cmInstallCommandArguments* args, const std::string& type)
+{
+ if (args && !args->GetDestination().empty()) {
+ return args->GetDestination();
+ }
+ if (type == "BIN") {
+ return this->GetRuntimeDestination(nullptr);
+ }
+ if (type == "SBIN") {
+ return this->GetSbinDestination(nullptr);
+ }
+ if (type == "SYSCONF") {
+ return this->GetSysconfDestination(nullptr);
+ }
+ if (type == "SHAREDSTATE") {
+ return this->GetSharedStateDestination(nullptr);
+ }
+ if (type == "LOCALSTATE") {
+ return this->GetLocalStateDestination(nullptr);
+ }
+ if (type == "RUNSTATE") {
+ return this->GetRunStateDestination(nullptr);
+ }
+ if (type == "LIB") {
+ return this->GetLibraryDestination(nullptr);
+ }
+ if (type == "INCLUDE") {
+ return this->GetIncludeDestination(nullptr);
+ }
+ if (type == "DATA") {
+ return this->GetDataDestination(nullptr);
+ }
+ if (type == "INFO") {
+ return this->GetInfoDestination(nullptr);
+ }
+ if (type == "LOCALE") {
+ return this->GetLocaleDestination(nullptr);
+ }
+ if (type == "MAN") {
+ return this->GetManDestination(nullptr);
+ }
+ if (type == "DOC") {
+ return this->GetDocDestination(nullptr);
+ }
+ return "";
+}
+
+} // namespace
+
+bool cmInstallCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ // Allow calling with no arguments so that arguments may be built up
+ // using a variable that may be left empty.
+ if (args.empty()) {
+ return true;
+ }
+
+ // Enable the install target.
+ status.GetMakefile().GetGlobalGenerator()->EnableInstallTarget();
+
+ static cmSubcommandTable const subcommand{
+ { "SCRIPT"_s, HandleScriptMode },
+ { "CODE"_s, HandleScriptMode },
+ { "TARGETS"_s, HandleTargetsMode },
+ { "FILES"_s, HandleFilesMode },
+ { "PROGRAMS"_s, HandleFilesMode },
+ { "DIRECTORY"_s, HandleDirectoryMode },
+ { "EXPORT"_s, HandleExportMode },
+ { "EXPORT_ANDROID_MK"_s, HandleExportAndroidMKMode },
+ };
+
+ return subcommand(args[0], args, status);
+}
diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h
index f5d1f9265..32f00ce49 100644
--- a/Source/cmInstallCommand.h
+++ b/Source/cmInstallCommand.h
@@ -3,49 +3,14 @@
#ifndef cmInstallCommand_h
#define cmInstallCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmInstallCommand
- * \brief Specifies where to install some files
- *
- * cmInstallCommand is a general-purpose interface command for
- * specifying install rules.
- */
-class cmInstallCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmInstallCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- bool HandleScriptMode(std::vector<std::string> const& args);
- bool HandleTargetsMode(std::vector<std::string> const& args);
- bool HandleFilesMode(std::vector<std::string> const& args);
- bool HandleDirectoryMode(std::vector<std::string> const& args);
- bool HandleExportMode(std::vector<std::string> const& args);
- bool HandleExportAndroidMKMode(std::vector<std::string> const& args);
- bool MakeFilesFullPath(const char* modeName,
- const std::vector<std::string>& relFiles,
- std::vector<std::string>& absFiles);
- bool CheckCMP0006(bool& failure);
-
- std::string DefaultComponentName;
-};
+bool cmInstallCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx
index b73414dd0..31ba63f2c 100644
--- a/Source/cmInstallCommandArguments.cxx
+++ b/Source/cmInstallCommandArguments.cxx
@@ -2,35 +2,37 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallCommandArguments.h"
-#include "cmConfigure.h"
+#include <utility>
+#include "cm_static_string_view.hxx"
+
+#include "cmRange.h"
#include "cmSystemTools.h"
// Table of valid permissions.
const char* cmInstallCommandArguments::PermissionsTable[] = {
"OWNER_READ", "OWNER_WRITE", "OWNER_EXECUTE", "GROUP_READ",
"GROUP_WRITE", "GROUP_EXECUTE", "WORLD_READ", "WORLD_WRITE",
- "WORLD_EXECUTE", "SETUID", "SETGID", CM_NULLPTR
+ "WORLD_EXECUTE", "SETUID", "SETGID", nullptr
};
const std::string cmInstallCommandArguments::EmptyString;
cmInstallCommandArguments::cmInstallCommandArguments(
- const std::string& defaultComponent)
- : Parser()
- , ArgumentGroup()
- , Destination(&Parser, "DESTINATION", &ArgumentGroup)
- , Component(&Parser, "COMPONENT", &ArgumentGroup)
- , ExcludeFromAll(&Parser, "EXCLUDE_FROM_ALL", &ArgumentGroup)
- , Rename(&Parser, "RENAME", &ArgumentGroup)
- , Permissions(&Parser, "PERMISSIONS", &ArgumentGroup)
- , Configurations(&Parser, "CONFIGURATIONS", &ArgumentGroup)
- , Optional(&Parser, "OPTIONAL", &ArgumentGroup)
- , NamelinkOnly(&Parser, "NAMELINK_ONLY", &ArgumentGroup)
- , NamelinkSkip(&Parser, "NAMELINK_SKIP", &ArgumentGroup)
- , GenericArguments(CM_NULLPTR)
- , DefaultComponentName(defaultComponent)
-{
+ std::string defaultComponent)
+ : DefaultComponentName(std::move(defaultComponent))
+{
+ this->Bind("DESTINATION"_s, this->Destination);
+ this->Bind("COMPONENT"_s, this->Component);
+ this->Bind("NAMELINK_COMPONENT"_s, this->NamelinkComponent);
+ this->Bind("EXCLUDE_FROM_ALL"_s, this->ExcludeFromAll);
+ this->Bind("RENAME"_s, this->Rename);
+ this->Bind("PERMISSIONS"_s, this->Permissions);
+ this->Bind("CONFIGURATIONS"_s, this->Configurations);
+ this->Bind("OPTIONAL"_s, this->Optional);
+ this->Bind("NAMELINK_ONLY"_s, this->NamelinkOnly);
+ this->Bind("NAMELINK_SKIP"_s, this->NamelinkSkip);
+ this->Bind("TYPE"_s, this->Type);
}
const std::string& cmInstallCommandArguments::GetDestination() const
@@ -38,18 +40,18 @@ const std::string& cmInstallCommandArguments::GetDestination() const
if (!this->DestinationString.empty()) {
return this->DestinationString;
}
- if (this->GenericArguments != CM_NULLPTR) {
+ if (this->GenericArguments != nullptr) {
return this->GenericArguments->GetDestination();
}
- return this->EmptyString;
+ return EmptyString;
}
const std::string& cmInstallCommandArguments::GetComponent() const
{
- if (!this->Component.GetString().empty()) {
- return this->Component.GetString();
+ if (!this->Component.empty()) {
+ return this->Component;
}
- if (this->GenericArguments != CM_NULLPTR) {
+ if (this->GenericArguments != nullptr) {
return this->GenericArguments->GetComponent();
}
if (!this->DefaultComponentName.empty()) {
@@ -59,15 +61,23 @@ const std::string& cmInstallCommandArguments::GetComponent() const
return unspecifiedComponent;
}
+const std::string& cmInstallCommandArguments::GetNamelinkComponent() const
+{
+ if (!this->NamelinkComponent.empty()) {
+ return this->NamelinkComponent;
+ }
+ return this->GetComponent();
+}
+
const std::string& cmInstallCommandArguments::GetRename() const
{
- if (!this->Rename.GetString().empty()) {
- return this->Rename.GetString();
+ if (!this->Rename.empty()) {
+ return this->Rename;
}
- if (this->GenericArguments != CM_NULLPTR) {
+ if (this->GenericArguments != nullptr) {
return this->GenericArguments->GetRename();
}
- return this->EmptyString;
+ return EmptyString;
}
const std::string& cmInstallCommandArguments::GetPermissions() const
@@ -75,18 +85,18 @@ const std::string& cmInstallCommandArguments::GetPermissions() const
if (!this->PermissionsString.empty()) {
return this->PermissionsString;
}
- if (this->GenericArguments != CM_NULLPTR) {
+ if (this->GenericArguments != nullptr) {
return this->GenericArguments->GetPermissions();
}
- return this->EmptyString;
+ return EmptyString;
}
bool cmInstallCommandArguments::GetOptional() const
{
- if (this->Optional.IsEnabled()) {
+ if (this->Optional) {
return true;
}
- if (this->GenericArguments != CM_NULLPTR) {
+ if (this->GenericArguments != nullptr) {
return this->GenericArguments->GetOptional();
}
return false;
@@ -94,10 +104,10 @@ bool cmInstallCommandArguments::GetOptional() const
bool cmInstallCommandArguments::GetExcludeFromAll() const
{
- if (this->ExcludeFromAll.IsEnabled()) {
+ if (this->ExcludeFromAll) {
return true;
}
- if (this->GenericArguments != CM_NULLPTR) {
+ if (this->GenericArguments != nullptr) {
return this->GenericArguments->GetExcludeFromAll();
}
return false;
@@ -105,10 +115,10 @@ bool cmInstallCommandArguments::GetExcludeFromAll() const
bool cmInstallCommandArguments::GetNamelinkOnly() const
{
- if (this->NamelinkOnly.IsEnabled()) {
+ if (this->NamelinkOnly) {
return true;
}
- if (this->GenericArguments != CM_NULLPTR) {
+ if (this->GenericArguments != nullptr) {
return this->GenericArguments->GetNamelinkOnly();
}
return false;
@@ -116,25 +126,41 @@ bool cmInstallCommandArguments::GetNamelinkOnly() const
bool cmInstallCommandArguments::GetNamelinkSkip() const
{
- if (this->NamelinkSkip.IsEnabled()) {
+ if (this->NamelinkSkip) {
return true;
}
- if (this->GenericArguments != CM_NULLPTR) {
+ if (this->GenericArguments != nullptr) {
return this->GenericArguments->GetNamelinkSkip();
}
return false;
}
+bool cmInstallCommandArguments::HasNamelinkComponent() const
+{
+ if (!this->NamelinkComponent.empty()) {
+ return true;
+ }
+ if (this->GenericArguments != nullptr) {
+ return this->GenericArguments->HasNamelinkComponent();
+ }
+ return false;
+}
+
+const std::string& cmInstallCommandArguments::GetType() const
+{
+ return this->Type;
+}
+
const std::vector<std::string>& cmInstallCommandArguments::GetConfigurations()
const
{
- if (!this->Configurations.GetVector().empty()) {
- return this->Configurations.GetVector();
+ if (!this->Configurations.empty()) {
+ return this->Configurations;
}
- if (this->GenericArguments != CM_NULLPTR) {
+ if (this->GenericArguments != nullptr) {
return this->GenericArguments->GetConfigurations();
}
- return this->Configurations.GetVector();
+ return this->Configurations;
}
bool cmInstallCommandArguments::Finalize()
@@ -142,24 +168,17 @@ bool cmInstallCommandArguments::Finalize()
if (!this->CheckPermissions()) {
return false;
}
- this->DestinationString = this->Destination.GetString();
+ this->DestinationString = this->Destination;
cmSystemTools::ConvertToUnixSlashes(this->DestinationString);
return true;
}
-void cmInstallCommandArguments::Parse(const std::vector<std::string>* args,
- std::vector<std::string>* unconsumedArgs)
-{
- this->Parser.Parse(args, unconsumedArgs);
-}
-
bool cmInstallCommandArguments::CheckPermissions()
{
- this->PermissionsString = "";
- for (std::vector<std::string>::const_iterator permIt =
- this->Permissions.GetVector().begin();
- permIt != this->Permissions.GetVector().end(); ++permIt) {
- if (!this->CheckPermissions(*permIt, this->PermissionsString)) {
+ this->PermissionsString.clear();
+ for (std::string const& perm : this->Permissions) {
+ if (!cmInstallCommandArguments::CheckPermissions(
+ perm, this->PermissionsString)) {
return false;
}
}
@@ -183,9 +202,7 @@ bool cmInstallCommandArguments::CheckPermissions(
return false;
}
-cmInstallCommandIncludesArgument::cmInstallCommandIncludesArgument()
-{
-}
+cmInstallCommandIncludesArgument::cmInstallCommandIncludesArgument() = default;
const std::vector<std::string>&
cmInstallCommandIncludesArgument::GetIncludeDirs() const
@@ -199,11 +216,8 @@ void cmInstallCommandIncludesArgument::Parse(
if (args->empty()) {
return;
}
- std::vector<std::string>::const_iterator it = args->begin();
- ++it;
- for (; it != args->end(); ++it) {
- std::string dir = *it;
+ for (std::string dir : cmMakeRange(*args).advance(1)) {
cmSystemTools::ConvertToUnixSlashes(dir);
- this->IncludeDirs.push_back(dir);
+ this->IncludeDirs.push_back(std::move(dir));
}
}
diff --git a/Source/cmInstallCommandArguments.h b/Source/cmInstallCommandArguments.h
index a576e7202..5d2ee0ab4 100644
--- a/Source/cmInstallCommandArguments.h
+++ b/Source/cmInstallCommandArguments.h
@@ -8,24 +8,23 @@
#include <string>
#include <vector>
-#include "cmCommandArgumentsHelper.h"
+#include "cmArgumentParser.h"
-class cmInstallCommandArguments
+class cmInstallCommandArguments : public cmArgumentParser<void>
{
public:
- cmInstallCommandArguments(const std::string& defaultComponent);
+ cmInstallCommandArguments(std::string defaultComponent);
void SetGenericArguments(cmInstallCommandArguments* args)
{
this->GenericArguments = args;
}
- void Parse(const std::vector<std::string>* args,
- std::vector<std::string>* unconsumedArgs);
// Compute destination path.and check permissions
bool Finalize();
const std::string& GetDestination() const;
const std::string& GetComponent() const;
+ const std::string& GetNamelinkComponent() const;
bool GetExcludeFromAll() const;
const std::string& GetRename() const;
const std::string& GetPermissions() const;
@@ -33,30 +32,28 @@ public:
bool GetOptional() const;
bool GetNamelinkOnly() const;
bool GetNamelinkSkip() const;
+ bool HasNamelinkComponent() const;
+ const std::string& GetType() const;
- // once HandleDirectoryMode() is also switched to using
- // cmInstallCommandArguments then these two functions can become non-static
- // private member functions without arguments
static bool CheckPermissions(const std::string& onePerm, std::string& perm);
- cmCommandArgumentsHelper Parser;
- cmCommandArgumentGroup ArgumentGroup;
private:
- cmInstallCommandArguments(); // disabled
- cmCAString Destination;
- cmCAString Component;
- cmCAEnabler ExcludeFromAll;
- cmCAString Rename;
- cmCAStringVector Permissions;
- cmCAStringVector Configurations;
- cmCAEnabler Optional;
- cmCAEnabler NamelinkOnly;
- cmCAEnabler NamelinkSkip;
+ std::string Destination;
+ std::string Component;
+ std::string NamelinkComponent;
+ bool ExcludeFromAll = false;
+ std::string Rename;
+ std::vector<std::string> Permissions;
+ std::vector<std::string> Configurations;
+ bool Optional = false;
+ bool NamelinkOnly = false;
+ bool NamelinkSkip = false;
+ std::string Type;
std::string DestinationString;
std::string PermissionsString;
- cmInstallCommandArguments* GenericArguments;
+ cmInstallCommandArguments* GenericArguments = nullptr;
static const char* PermissionsTable[];
static const std::string EmptyString;
std::string DefaultComponentName;
diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx
index 54ad85c3b..259c7f76d 100644
--- a/Source/cmInstallDirectoryGenerator.cxx
+++ b/Source/cmInstallDirectoryGenerator.cxx
@@ -6,8 +6,8 @@
#include "cmInstallType.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
cmInstallDirectoryGenerator::cmInstallDirectoryGenerator(
std::vector<std::string> const& dirs, const char* dest,
@@ -17,7 +17,7 @@ cmInstallDirectoryGenerator::cmInstallDirectoryGenerator(
bool optional)
: cmInstallGenerator(dest, configurations, component, message,
exclude_from_all)
- , LocalGenerator(CM_NULLPTR)
+ , LocalGenerator(nullptr)
, Directories(dirs)
, FilePermissions(file_permissions)
, DirPermissions(dir_permissions)
@@ -30,21 +30,22 @@ cmInstallDirectoryGenerator::cmInstallDirectoryGenerator(
}
// We need per-config actions if any directories have generator expressions.
- for (std::vector<std::string>::const_iterator i = dirs.begin();
- !this->ActionsPerConfig && i != dirs.end(); ++i) {
- if (cmGeneratorExpression::Find(*i) != std::string::npos) {
- this->ActionsPerConfig = true;
+ if (!this->ActionsPerConfig) {
+ for (std::string const& dir : dirs) {
+ if (cmGeneratorExpression::Find(dir) != std::string::npos) {
+ this->ActionsPerConfig = true;
+ break;
+ }
}
}
}
-cmInstallDirectoryGenerator::~cmInstallDirectoryGenerator()
-{
-}
+cmInstallDirectoryGenerator::~cmInstallDirectoryGenerator() = default;
-void cmInstallDirectoryGenerator::Compute(cmLocalGenerator* lg)
+bool cmInstallDirectoryGenerator::Compute(cmLocalGenerator* lg)
{
- LocalGenerator = lg;
+ this->LocalGenerator = lg;
+ return true;
}
void cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os,
@@ -61,20 +62,16 @@ void cmInstallDirectoryGenerator::GenerateScriptForConfig(
std::ostream& os, const std::string& config, Indent indent)
{
std::vector<std::string> dirs;
- cmGeneratorExpression ge;
- for (std::vector<std::string>::const_iterator i = this->Directories.begin();
- i != this->Directories.end(); ++i) {
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*i);
- cmSystemTools::ExpandListArgument(
- cge->Evaluate(this->LocalGenerator, config), dirs);
+ for (std::string const& d : this->Directories) {
+ cmExpandList(
+ cmGeneratorExpression::Evaluate(d, this->LocalGenerator, config), dirs);
}
// Make sure all dirs have absolute paths.
cmMakefile const& mf = *this->LocalGenerator->GetMakefile();
- for (std::vector<std::string>::iterator i = dirs.begin(); i != dirs.end();
- ++i) {
- if (!cmSystemTools::FileIsFullPath(i->c_str())) {
- *i = std::string(mf.GetCurrentSourceDirectory()) + "/" + *i;
+ for (std::string& d : dirs) {
+ if (!cmSystemTools::FileIsFullPath(d)) {
+ d = cmStrCat(mf.GetCurrentSourceDirectory(), "/", d);
}
}
@@ -86,7 +83,7 @@ void cmInstallDirectoryGenerator::AddDirectoryInstallRule(
std::vector<std::string> const& dirs)
{
// Write code to install the directories.
- const char* no_rename = CM_NULLPTR;
+ const char* no_rename = nullptr;
this->AddInstallRule(os, this->GetDestination(config),
cmInstallType_DIRECTORY, dirs, this->Optional,
this->FilePermissions.c_str(),
@@ -97,6 +94,6 @@ void cmInstallDirectoryGenerator::AddDirectoryInstallRule(
std::string cmInstallDirectoryGenerator::GetDestination(
std::string const& config) const
{
- cmGeneratorExpression ge;
- return ge.Parse(this->Destination)->Evaluate(this->LocalGenerator, config);
+ return cmGeneratorExpression::Evaluate(this->Destination,
+ this->LocalGenerator, config);
}
diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h
index aa2cbc690..84c06948e 100644
--- a/Source/cmInstallDirectoryGenerator.h
+++ b/Source/cmInstallDirectoryGenerator.h
@@ -3,15 +3,15 @@
#ifndef cmInstallDirectoryGenerator_h
#define cmInstallDirectoryGenerator_h
-#include "cmInstallGenerator.h"
-#include "cmScriptGenerator.h"
-
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
#include <vector>
+#include "cmInstallGenerator.h"
+#include "cmScriptGenerator.h"
+
class cmLocalGenerator;
/** \class cmInstallDirectoryGenerator
@@ -27,16 +27,16 @@ public:
const char* component, MessageLevel message,
bool exclude_from_all, const char* literal_args,
bool optional = false);
- ~cmInstallDirectoryGenerator() CM_OVERRIDE;
+ ~cmInstallDirectoryGenerator() override;
- void Compute(cmLocalGenerator* lg) CM_OVERRIDE;
+ bool Compute(cmLocalGenerator* lg) override;
std::string GetDestination(std::string const& config) const;
protected:
- void GenerateScriptActions(std::ostream& os, Indent indent) CM_OVERRIDE;
+ void GenerateScriptActions(std::ostream& os, Indent indent) override;
void GenerateScriptForConfig(std::ostream& os, const std::string& config,
- Indent indent) CM_OVERRIDE;
+ Indent indent) override;
void AddDirectoryInstallRule(std::ostream& os, const std::string& config,
Indent indent,
std::vector<std::string> const& dirs);
diff --git a/Source/cmInstallExportAndroidMKGenerator.cxx b/Source/cmInstallExportAndroidMKGenerator.cxx
deleted file mode 100644
index 8eeaa9c7c..000000000
--- a/Source/cmInstallExportAndroidMKGenerator.cxx
+++ /dev/null
@@ -1,140 +0,0 @@
-
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmInstallExportAndroidMKGenerator.h"
-
-#include <stdio.h>
-
-#include "cmExportInstallFileGenerator.h"
-#include "cmExportSet.h"
-#include "cmGeneratedFileStream.h"
-#include "cmGlobalGenerator.h"
-#include "cmInstallFilesGenerator.h"
-#include "cmInstallTargetGenerator.h"
-#include "cmLocalGenerator.h"
-#include "cmMakefile.h"
-#include "cmake.h"
-
-cmInstallExportAndroidMKGenerator::cmInstallExportAndroidMKGenerator(
- cmExportSet* exportSet, const char* destination,
- const char* file_permissions, std::vector<std::string> const& configurations,
- const char* component, MessageLevel message, bool exclude_from_all,
- const char* filename, const char* name_space, bool exportOld)
- : cmInstallExportGenerator(exportSet, destination, file_permissions,
- configurations, component, message,
- exclude_from_all, filename, name_space, exportOld)
-{
-}
-
-cmInstallExportAndroidMKGenerator::~cmInstallExportAndroidMKGenerator()
-{
-}
-
-void cmInstallExportAndroidMKGenerator::Compute(cmLocalGenerator* lg)
-{
- this->LocalGenerator = lg;
- this->ExportSet->Compute(lg);
-}
-
-void cmInstallExportAndroidMKGenerator::GenerateScript(std::ostream& os)
-{
- // Skip empty sets.
- if (ExportSet->GetTargetExports()->empty()) {
- std::ostringstream e;
- e << "INSTALL(EXPORT) given unknown export \"" << ExportSet->GetName()
- << "\"";
- cmSystemTools::Error(e.str().c_str());
- return;
- }
-
- // Create the temporary directory in which to store the files.
- this->ComputeTempDir();
- cmSystemTools::MakeDirectory(this->TempDir.c_str());
-
- // Construct a temporary location for the file.
- this->MainImportFile = this->TempDir;
- this->MainImportFile += "/";
- this->MainImportFile += this->FileName;
-
- // Generate the import file for this export set.
- this->EFGen->SetExportFile(this->MainImportFile.c_str());
- this->EFGen->SetNamespace(this->Namespace);
- this->EFGen->SetExportOld(this->ExportOld);
- if (this->ConfigurationTypes->empty()) {
- if (!this->ConfigurationName.empty()) {
- this->EFGen->AddConfiguration(this->ConfigurationName);
- } else {
- this->EFGen->AddConfiguration("");
- }
- } else {
- for (std::vector<std::string>::const_iterator ci =
- this->ConfigurationTypes->begin();
- ci != this->ConfigurationTypes->end(); ++ci) {
- this->EFGen->AddConfiguration(*ci);
- }
- }
- this->EFGen->GenerateImportFile();
-
- // Perform the main install script generation.
- this->cmInstallGenerator::GenerateScript(os);
-}
-
-void cmInstallExportAndroidMKGenerator::GenerateScriptConfigs(
- std::ostream& os, Indent const& indent)
-{
- // Create the main install rules first.
- this->cmInstallGenerator::GenerateScriptConfigs(os, indent);
-
- // Now create a configuration-specific install rule for the import
- // file of each configuration.
- std::vector<std::string> files;
- for (std::map<std::string, std::string>::const_iterator i =
- this->EFGen->GetConfigImportFiles().begin();
- i != this->EFGen->GetConfigImportFiles().end(); ++i) {
- files.push_back(i->second);
- std::string config_test = this->CreateConfigTest(i->first);
- os << indent << "if(" << config_test << ")\n";
- this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files,
- false, this->FilePermissions.c_str(), CM_NULLPTR,
- CM_NULLPTR, CM_NULLPTR, indent.Next());
- os << indent << "endif()\n";
- files.clear();
- }
-}
-
-void cmInstallExportAndroidMKGenerator::GenerateScriptActions(
- std::ostream& os, Indent const& indent)
-{
- // Remove old per-configuration export files if the main changes.
- std::string installedDir = "$ENV{DESTDIR}";
- installedDir += this->ConvertToAbsoluteDestination(this->Destination);
- installedDir += "/";
- std::string installedFile = installedDir;
- installedFile += this->FileName;
- os << indent << "if(EXISTS \"" << installedFile << "\")\n";
- Indent indentN = indent.Next();
- Indent indentNN = indentN.Next();
- Indent indentNNN = indentNN.Next();
- /* clang-format off */
- os << indentN << "file(DIFFERENT EXPORT_FILE_CHANGED FILES\n"
- << indentN << " \"" << installedFile << "\"\n"
- << indentN << " \"" << this->MainImportFile << "\")\n";
- os << indentN << "if(EXPORT_FILE_CHANGED)\n";
- os << indentNN << "file(GLOB OLD_CONFIG_FILES \"" << installedDir
- << this->EFGen->GetConfigImportFileGlob() << "\")\n";
- os << indentNN << "if(OLD_CONFIG_FILES)\n";
- os << indentNNN << "message(STATUS \"Old export file \\\"" << installedFile
- << "\\\" will be replaced. Removing files [${OLD_CONFIG_FILES}].\")\n";
- os << indentNNN << "file(REMOVE ${OLD_CONFIG_FILES})\n";
- os << indentNN << "endif()\n";
- os << indentN << "endif()\n";
- os << indent << "endif()\n";
- /* clang-format on */
-
- // Install the main export file.
- std::vector<std::string> files;
- files.push_back(this->MainImportFile);
- this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files,
- false, this->FilePermissions.c_str(), CM_NULLPTR,
- CM_NULLPTR, CM_NULLPTR, indent);
-}
diff --git a/Source/cmInstallExportAndroidMKGenerator.h b/Source/cmInstallExportAndroidMKGenerator.h
deleted file mode 100644
index 189084a1a..000000000
--- a/Source/cmInstallExportAndroidMKGenerator.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmInstallExportAndroidMKGenerator_h
-#define cmInstallExportAndroidMKGenerator_h
-
-#include "cmInstallExportGenerator.h"
-
-class cmExportInstallFileGenerator;
-class cmInstallFilesGenerator;
-class cmInstallTargetGenerator;
-class cmExportSet;
-class cmMakefile;
-
-/** \class cmInstallExportAndroidMKGenerator
- * \brief Generate rules for creating an export files.
- */
-class cmInstallExportAndroidMKGenerator : public cmInstallExportGenerator
-{
-public:
- cmInstallExportAndroidMKGenerator(
- cmExportSet* exportSet, const char* dest, const char* file_permissions,
- const std::vector<std::string>& configurations, const char* component,
- MessageLevel message, bool exclude_from_all, const char* filename,
- const char* name_space, bool exportOld);
- ~cmInstallExportAndroidMKGenerator();
-
- void Compute(cmLocalGenerator* lg);
-
-protected:
- virtual void GenerateScript(std::ostream& os);
- virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent);
- virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
- void GenerateImportFile(cmExportSet const* exportSet);
- void GenerateImportFile(const char* config, cmExportSet const* exportSet);
-};
-
-#endif
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index b176e85c5..cba68bed4 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -7,15 +7,15 @@
#include <sstream>
#include <utility>
-#ifdef CMAKE_BUILD_WITH_CMAKE
-#include "cmExportInstallAndroidMKGenerator.h"
+#ifndef CMAKE_BOOTSTRAP
+# include "cmExportInstallAndroidMKGenerator.h"
#endif
#include "cmExportInstallFileGenerator.h"
#include "cmExportSet.h"
#include "cmInstallType.h"
#include "cmLocalGenerator.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmake.h"
cmInstallExportGenerator::cmInstallExportGenerator(
cmExportSet* exportSet, const char* destination,
@@ -29,10 +29,10 @@ cmInstallExportGenerator::cmInstallExportGenerator(
, FileName(filename)
, Namespace(name_space)
, ExportOld(exportOld)
- , LocalGenerator(CM_NULLPTR)
+ , LocalGenerator(nullptr)
{
if (android) {
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
this->EFGen = new cmExportInstallAndroidMKGenerator(this);
#endif
} else {
@@ -46,19 +46,19 @@ cmInstallExportGenerator::~cmInstallExportGenerator()
delete this->EFGen;
}
-void cmInstallExportGenerator::Compute(cmLocalGenerator* lg)
+bool cmInstallExportGenerator::Compute(cmLocalGenerator* lg)
{
this->LocalGenerator = lg;
this->ExportSet->Compute(lg);
+ return true;
}
void cmInstallExportGenerator::ComputeTempDir()
{
// Choose a temporary directory in which to generate the import
// files to be installed.
- this->TempDir = this->LocalGenerator->GetCurrentBinaryDirectory();
- this->TempDir += cmake::GetCMakeFilesDirectory();
- this->TempDir += "/Export";
+ this->TempDir = cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/Export");
if (this->Destination.empty()) {
return;
}
@@ -111,11 +111,9 @@ size_t cmInstallExportGenerator::GetMaxConfigLength() const
len = this->ConfigurationName.size();
}
} else {
- for (std::vector<std::string>::const_iterator ci =
- this->ConfigurationTypes->begin();
- ci != this->ConfigurationTypes->end(); ++ci) {
- if (ci->size() > len) {
- len = ci->size();
+ for (std::string const& c : *this->ConfigurationTypes) {
+ if (c.size() > len) {
+ len = c.size();
}
}
}
@@ -125,22 +123,20 @@ size_t cmInstallExportGenerator::GetMaxConfigLength() const
void cmInstallExportGenerator::GenerateScript(std::ostream& os)
{
// Skip empty sets.
- if (ExportSet->GetTargetExports()->empty()) {
+ if (ExportSet->GetTargetExports().empty()) {
std::ostringstream e;
e << "INSTALL(EXPORT) given unknown export \"" << ExportSet->GetName()
<< "\"";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return;
}
// Create the temporary directory in which to store the files.
this->ComputeTempDir();
- cmSystemTools::MakeDirectory(this->TempDir.c_str());
+ cmSystemTools::MakeDirectory(this->TempDir);
// Construct a temporary location for the file.
- this->MainImportFile = this->TempDir;
- this->MainImportFile += "/";
- this->MainImportFile += this->FileName;
+ this->MainImportFile = cmStrCat(this->TempDir, '/', this->FileName);
// Generate the import file for this export set.
this->EFGen->SetExportFile(this->MainImportFile.c_str());
@@ -153,10 +149,8 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
this->EFGen->AddConfiguration("");
}
} else {
- for (std::vector<std::string>::const_iterator ci =
- this->ConfigurationTypes->begin();
- ci != this->ConfigurationTypes->end(); ++ci) {
- this->EFGen->AddConfiguration(*ci);
+ for (std::string const& c : *this->ConfigurationTypes) {
+ this->EFGen->AddConfiguration(c);
}
}
this->EFGen->GenerateImportFile();
@@ -174,15 +168,13 @@ void cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os,
// Now create a configuration-specific install rule for the import
// file of each configuration.
std::vector<std::string> files;
- for (std::map<std::string, std::string>::const_iterator i =
- this->EFGen->GetConfigImportFiles().begin();
- i != this->EFGen->GetConfigImportFiles().end(); ++i) {
- files.push_back(i->second);
- std::string config_test = this->CreateConfigTest(i->first);
+ for (auto const& i : this->EFGen->GetConfigImportFiles()) {
+ files.push_back(i.second);
+ std::string config_test = this->CreateConfigTest(i.first);
os << indent << "if(" << config_test << ")\n";
this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files,
- false, this->FilePermissions.c_str(), CM_NULLPTR,
- CM_NULLPTR, CM_NULLPTR, indent.Next());
+ false, this->FilePermissions.c_str(), nullptr,
+ nullptr, nullptr, indent.Next());
os << indent << "endif()\n";
files.clear();
}
@@ -192,11 +184,10 @@ void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os,
Indent indent)
{
// Remove old per-configuration export files if the main changes.
- std::string installedDir = "$ENV{DESTDIR}";
- installedDir += this->ConvertToAbsoluteDestination(this->Destination);
- installedDir += "/";
- std::string installedFile = installedDir;
- installedFile += this->FileName;
+ std::string installedDir =
+ cmStrCat("$ENV{DESTDIR}",
+ this->ConvertToAbsoluteDestination(this->Destination), '/');
+ std::string installedFile = cmStrCat(installedDir, this->FileName);
os << indent << "if(EXISTS \"" << installedFile << "\")\n";
Indent indentN = indent.Next();
Indent indentNN = indentN.Next();
@@ -209,7 +200,7 @@ void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os,
os << indentNN << "file(GLOB OLD_CONFIG_FILES \"" << installedDir
<< this->EFGen->GetConfigImportFileGlob() << "\")\n";
os << indentNN << "if(OLD_CONFIG_FILES)\n";
- os << indentNNN << "message(STATUS \"Old export file \\\"" << installedFile
+ os << indentNNN << R"(message(STATUS "Old export file \")" << installedFile
<< "\\\" will be replaced. Removing files [${OLD_CONFIG_FILES}].\")\n";
os << indentNNN << "file(REMOVE ${OLD_CONFIG_FILES})\n";
os << indentNN << "endif()\n";
@@ -221,6 +212,11 @@ void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os,
std::vector<std::string> files;
files.push_back(this->MainImportFile);
this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files,
- false, this->FilePermissions.c_str(), CM_NULLPTR,
- CM_NULLPTR, CM_NULLPTR, indent);
+ false, this->FilePermissions.c_str(), nullptr, nullptr,
+ nullptr, indent);
+}
+
+std::string cmInstallExportGenerator::GetDestinationFile() const
+{
+ return this->Destination + '/' + this->FileName;
}
diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h
index 047e6b3cd..f44127e3d 100644
--- a/Source/cmInstallExportGenerator.h
+++ b/Source/cmInstallExportGenerator.h
@@ -3,16 +3,16 @@
#ifndef cmInstallExportGenerator_h
#define cmInstallExportGenerator_h
-#include "cmConfigure.h"
-
-#include "cmInstallGenerator.h"
-#include "cmScriptGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <cstddef>
#include <iosfwd>
-#include <stddef.h>
#include <string>
#include <vector>
+#include "cmInstallGenerator.h"
+#include "cmScriptGenerator.h"
+
class cmExportInstallFileGenerator;
class cmExportSet;
class cmLocalGenerator;
@@ -30,22 +30,23 @@ public:
bool exclude_from_all, const char* filename,
const char* name_space, bool exportOld,
bool android);
- ~cmInstallExportGenerator() CM_OVERRIDE;
+ ~cmInstallExportGenerator() override;
cmExportSet* GetExportSet() { return this->ExportSet; }
- void Compute(cmLocalGenerator* lg) CM_OVERRIDE;
+ bool Compute(cmLocalGenerator* lg) override;
cmLocalGenerator* GetLocalGenerator() const { return this->LocalGenerator; }
const std::string& GetNamespace() const { return this->Namespace; }
std::string const& GetDestination() const { return this->Destination; }
+ std::string GetDestinationFile() const;
protected:
- void GenerateScript(std::ostream& os) CM_OVERRIDE;
- void GenerateScriptConfigs(std::ostream& os, Indent indent) CM_OVERRIDE;
- void GenerateScriptActions(std::ostream& os, Indent indent) CM_OVERRIDE;
+ void GenerateScript(std::ostream& os) override;
+ void GenerateScriptConfigs(std::ostream& os, Indent indent) override;
+ void GenerateScriptActions(std::ostream& os, Indent indent) override;
void GenerateImportFile(cmExportSet const* exportSet);
void GenerateImportFile(const char* config, cmExportSet const* exportSet);
void ComputeTempDir();
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
index 4a3b620af..d62394311 100644
--- a/Source/cmInstallFilesCommand.cxx
+++ b/Source/cmInstallFilesCommand.cxx
@@ -2,67 +2,72 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallFilesCommand.h"
+#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmInstallFilesGenerator.h"
#include "cmInstallGenerator.h"
#include "cmMakefile.h"
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
+static std::string FindInstallSource(cmMakefile& makefile, const char* name);
+static void CreateInstallGenerator(cmMakefile& makefile,
+ std::string const& dest,
+ std::vector<std::string> const& files);
+static void FinalAction(cmMakefile& makefile, std::string const& dest,
+ std::vector<std::string> const& args);
-// cmExecutableCommand
-bool cmInstallFilesCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmInstallFilesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// Enable the install target.
- this->Makefile->GetGlobalGenerator()->EnableInstallTarget();
+ mf.GetGlobalGenerator()->EnableInstallTarget();
- this->Destination = args[0];
+ std::string const& dest = args[0];
if ((args.size() > 1) && (args[1] == "FILES")) {
- this->IsFilesForm = true;
- for (std::vector<std::string>::const_iterator s = args.begin() + 2;
- s != args.end(); ++s) {
+ std::vector<std::string> files;
+ for (std::string const& arg : cmMakeRange(args).advance(2)) {
// Find the source location for each file listed.
- std::string f = this->FindInstallSource(s->c_str());
- this->Files.push_back(f);
+ files.push_back(FindInstallSource(mf, arg.c_str()));
}
- this->CreateInstallGenerator();
+ CreateInstallGenerator(mf, dest, files);
} else {
- this->IsFilesForm = false;
- this->FinalArgs.insert(this->FinalArgs.end(), args.begin() + 1,
- args.end());
+ std::vector<std::string> finalArgs(args.begin() + 1, args.end());
+ mf.AddFinalAction([dest, finalArgs](cmMakefile& makefile) {
+ FinalAction(makefile, dest, finalArgs);
+ });
}
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
+ mf.GetGlobalGenerator()->AddInstallComponent(
+ mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
return true;
}
-void cmInstallFilesCommand::FinalPass()
+static void FinalAction(cmMakefile& makefile, std::string const& dest,
+ std::vector<std::string> const& args)
{
- // No final pass for "FILES" form of arguments.
- if (this->IsFilesForm) {
- return;
- }
-
std::string testf;
- std::string const& ext = this->FinalArgs[0];
+ std::string const& ext = args[0];
+ std::vector<std::string> installFiles;
// two different options
- if (this->FinalArgs.size() > 1) {
+ if (args.size() > 1) {
// now put the files into the list
- std::vector<std::string>::iterator s = this->FinalArgs.begin();
+ auto s = args.begin();
++s;
// for each argument, get the files
- for (; s != this->FinalArgs.end(); ++s) {
+ for (; s != args.end(); ++s) {
// replace any variables
std::string const& temps = *s;
if (!cmSystemTools::GetFilenamePath(temps).empty()) {
@@ -73,30 +78,31 @@ void cmInstallFilesCommand::FinalPass()
}
// add to the result
- this->Files.push_back(this->FindInstallSource(testf.c_str()));
+ installFiles.push_back(FindInstallSource(makefile, testf.c_str()));
}
} else // reg exp list
{
std::vector<std::string> files;
- std::string const& regex = this->FinalArgs[0];
- cmSystemTools::Glob(this->Makefile->GetCurrentSourceDirectory(), regex,
- files);
+ std::string const& regex = args[0];
+ cmSystemTools::Glob(makefile.GetCurrentSourceDirectory(), regex, files);
- std::vector<std::string>::iterator s = files.begin();
+ auto s = files.begin();
// for each argument, get the files
for (; s != files.end(); ++s) {
- this->Files.push_back(this->FindInstallSource(s->c_str()));
+ installFiles.push_back(FindInstallSource(makefile, s->c_str()));
}
}
- this->CreateInstallGenerator();
+ CreateInstallGenerator(makefile, dest, installFiles);
}
-void cmInstallFilesCommand::CreateInstallGenerator() const
+static void CreateInstallGenerator(cmMakefile& makefile,
+ std::string const& dest,
+ std::vector<std::string> const& files)
{
// Construct the destination. This command always installs under
// the prefix. We skip the leading slash given by the user.
- std::string destination = this->Destination.substr(1);
+ std::string destination = dest.substr(1);
cmSystemTools::ConvertToUnixSlashes(destination);
if (destination.empty()) {
destination = ".";
@@ -107,12 +113,12 @@ void cmInstallFilesCommand::CreateInstallGenerator() const
const char* no_rename = "";
bool no_exclude_from_all = false;
std::string no_component =
- this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
+ makefile.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
std::vector<std::string> no_configurations;
cmInstallGenerator::MessageLevel message =
- cmInstallGenerator::SelectMessageLevel(this->Makefile);
- this->Makefile->AddInstallGenerator(new cmInstallFilesGenerator(
- this->Files, destination.c_str(), false, no_permissions, no_configurations,
+ cmInstallGenerator::SelectMessageLevel(&makefile);
+ makefile.AddInstallGenerator(new cmInstallFilesGenerator(
+ files, destination.c_str(), false, no_permissions, no_configurations,
no_component.c_str(), message, no_exclude_from_all, no_rename));
}
@@ -122,7 +128,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const
* present in the build tree. If a full path is given, it is just
* returned.
*/
-std::string cmInstallFilesCommand::FindInstallSource(const char* name) const
+static std::string FindInstallSource(cmMakefile& makefile, const char* name)
{
if (cmSystemTools::FileIsFullPath(name) ||
cmGeneratorExpression::Find(name) == 0) {
@@ -131,18 +137,14 @@ std::string cmInstallFilesCommand::FindInstallSource(const char* name) const
}
// This is a relative path.
- std::string tb = this->Makefile->GetCurrentBinaryDirectory();
- tb += "/";
- tb += name;
- std::string ts = this->Makefile->GetCurrentSourceDirectory();
- ts += "/";
- ts += name;
-
- if (cmSystemTools::FileExists(tb.c_str())) {
+ std::string tb = cmStrCat(makefile.GetCurrentBinaryDirectory(), '/', name);
+ std::string ts = cmStrCat(makefile.GetCurrentSourceDirectory(), '/', name);
+
+ if (cmSystemTools::FileExists(tb)) {
// The file exists in the binary tree. Use it.
return tb;
}
- if (cmSystemTools::FileExists(ts.c_str())) {
+ if (cmSystemTools::FileExists(ts)) {
// The file exists in the source tree. Use it.
return ts;
}
diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h
index b3c27b827..f4ebbdec9 100644
--- a/Source/cmInstallFilesCommand.h
+++ b/Source/cmInstallFilesCommand.h
@@ -3,54 +3,14 @@
#ifndef cmInstallFilesCommand_h
#define cmInstallFilesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmInstallFilesCommand
- * \brief Specifies where to install some files
- *
- * cmInstallFilesCommand specifies the relative path where a list of
- * files should be installed.
- */
-class cmInstallFilesCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmInstallFilesCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
- /**
- * This is called at the end after all the information
- * specified by the command is accumulated. Most commands do
- * not implement this method. At this point, reading and
- * writing to the cache can be done.
- */
- void FinalPass() CM_OVERRIDE;
- bool HasFinalPass() const CM_OVERRIDE { return !this->IsFilesForm; }
-
-protected:
- void CreateInstallGenerator() const;
- std::string FindInstallSource(const char* name) const;
-
-private:
- std::vector<std::string> FinalArgs;
- bool IsFilesForm;
- std::string Destination;
- std::vector<std::string> Files;
-};
+bool cmInstallFilesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index 6323a9189..f5b69a5d4 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -4,8 +4,7 @@
#include "cmGeneratorExpression.h"
#include "cmInstallType.h"
-#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
+#include "cmStringAlgorithms.h"
class cmLocalGenerator;
@@ -16,7 +15,7 @@ cmInstallFilesGenerator::cmInstallFilesGenerator(
const char* rename, bool optional)
: cmInstallGenerator(dest, configurations, component, message,
exclude_from_all)
- , LocalGenerator(CM_NULLPTR)
+ , LocalGenerator(nullptr)
, Files(files)
, FilePermissions(file_permissions)
, Rename(rename)
@@ -28,29 +27,30 @@ cmInstallFilesGenerator::cmInstallFilesGenerator(
this->ActionsPerConfig = true;
}
- // We need per-config actions if any files have generator expressions.
- for (std::vector<std::string>::const_iterator i = files.begin();
- !this->ActionsPerConfig && i != files.end(); ++i) {
- if (cmGeneratorExpression::Find(*i) != std::string::npos) {
- this->ActionsPerConfig = true;
+ // We need per-config actions if any directories have generator expressions.
+ if (!this->ActionsPerConfig) {
+ for (std::string const& file : files) {
+ if (cmGeneratorExpression::Find(file) != std::string::npos) {
+ this->ActionsPerConfig = true;
+ break;
+ }
}
}
}
-cmInstallFilesGenerator::~cmInstallFilesGenerator()
-{
-}
+cmInstallFilesGenerator::~cmInstallFilesGenerator() = default;
-void cmInstallFilesGenerator::Compute(cmLocalGenerator* lg)
+bool cmInstallFilesGenerator::Compute(cmLocalGenerator* lg)
{
this->LocalGenerator = lg;
+ return true;
}
std::string cmInstallFilesGenerator::GetDestination(
std::string const& config) const
{
- cmGeneratorExpression ge;
- return ge.Parse(this->Destination)->Evaluate(this->LocalGenerator, config);
+ return cmGeneratorExpression::Evaluate(this->Destination,
+ this->LocalGenerator, config);
}
void cmInstallFilesGenerator::AddFilesInstallRule(
@@ -58,12 +58,12 @@ void cmInstallFilesGenerator::AddFilesInstallRule(
std::vector<std::string> const& files)
{
// Write code to install the files.
- const char* no_dir_permissions = CM_NULLPTR;
+ const char* no_dir_permissions = nullptr;
this->AddInstallRule(
os, this->GetDestination(config),
(this->Programs ? cmInstallType_PROGRAMS : cmInstallType_FILES), files,
this->Optional, this->FilePermissions.c_str(), no_dir_permissions,
- this->Rename.c_str(), CM_NULLPTR, indent);
+ this->Rename.c_str(), nullptr, indent);
}
void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
@@ -80,12 +80,9 @@ void cmInstallFilesGenerator::GenerateScriptForConfig(
std::ostream& os, const std::string& config, Indent indent)
{
std::vector<std::string> files;
- cmGeneratorExpression ge;
- for (std::vector<std::string>::const_iterator i = this->Files.begin();
- i != this->Files.end(); ++i) {
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(*i);
- cmSystemTools::ExpandListArgument(
- cge->Evaluate(this->LocalGenerator, config), files);
+ for (std::string const& f : this->Files) {
+ cmExpandList(
+ cmGeneratorExpression::Evaluate(f, this->LocalGenerator, config), files);
}
this->AddFilesInstallRule(os, config, indent, files);
}
diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h
index 62b57f9c7..a6800375b 100644
--- a/Source/cmInstallFilesGenerator.h
+++ b/Source/cmInstallFilesGenerator.h
@@ -3,15 +3,15 @@
#ifndef cmInstallFilesGenerator_h
#define cmInstallFilesGenerator_h
-#include "cmConfigure.h"
-
-#include "cmInstallGenerator.h"
-#include "cmScriptGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
#include <vector>
+#include "cmInstallGenerator.h"
+#include "cmScriptGenerator.h"
+
class cmLocalGenerator;
/** \class cmInstallFilesGenerator
@@ -27,16 +27,16 @@ public:
const char* component, MessageLevel message,
bool exclude_from_all, const char* rename,
bool optional = false);
- ~cmInstallFilesGenerator() CM_OVERRIDE;
+ ~cmInstallFilesGenerator() override;
- void Compute(cmLocalGenerator* lg) CM_OVERRIDE;
+ bool Compute(cmLocalGenerator* lg) override;
std::string GetDestination(std::string const& config) const;
protected:
- void GenerateScriptActions(std::ostream& os, Indent indent) CM_OVERRIDE;
+ void GenerateScriptActions(std::ostream& os, Indent indent) override;
void GenerateScriptForConfig(std::ostream& os, const std::string& config,
- Indent indent) CM_OVERRIDE;
+ Indent indent) override;
void AddFilesInstallRule(std::ostream& os, std::string const& config,
Indent indent,
std::vector<std::string> const& files);
diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx
index 13b588efb..ec173619f 100644
--- a/Source/cmInstallGenerator.cxx
+++ b/Source/cmInstallGenerator.cxx
@@ -2,11 +2,11 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallGenerator.h"
+#include <ostream>
+
#include "cmMakefile.h"
#include "cmSystemTools.h"
-#include <ostream>
-
cmInstallGenerator::cmInstallGenerator(
const char* destination, std::vector<std::string> const& configurations,
const char* component, MessageLevel message, bool exclude_from_all)
@@ -18,8 +18,19 @@ cmInstallGenerator::cmInstallGenerator(
{
}
-cmInstallGenerator::~cmInstallGenerator()
+cmInstallGenerator::~cmInstallGenerator() = default;
+
+bool cmInstallGenerator::HaveInstall()
{
+ return true;
+}
+
+void cmInstallGenerator::CheckCMP0082(bool& haveSubdirectoryInstall,
+ bool& haveInstallAfterSubdirectory)
+{
+ if (haveSubdirectoryInstall) {
+ haveInstallAfterSubdirectory = true;
+ }
}
void cmInstallGenerator::AddInstallRule(
@@ -55,20 +66,21 @@ void cmInstallGenerator::AddInstallRule(
break;
}
os << indent;
- if (cmSystemTools::FileIsFullPath(dest.c_str())) {
+ if (cmSystemTools::FileIsFullPath(dest)) {
os << "list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES\n";
os << indent << " \"";
- for (std::vector<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
- if (fi != files.begin()) {
+ bool firstIteration = true;
+ for (std::string const& file : files) {
+ if (!firstIteration) {
os << ";";
}
os << dest << "/";
if (rename && *rename) {
os << rename;
} else {
- os << cmSystemTools::GetFilenameName(*fi);
+ os << cmSystemTools::GetFilenameName(file);
}
+ firstIteration = false;
}
os << "\")\n";
os << indent << "if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)\n";
@@ -113,9 +125,8 @@ void cmInstallGenerator::AddInstallRule(
if (files.size() == 1) {
os << " \"" << files[0] << "\"";
} else {
- for (std::vector<std::string>::const_iterator fi = files.begin();
- fi != files.end(); ++fi) {
- os << "\n" << indent << " \"" << *fi << "\"";
+ for (std::string const& f : files) {
+ os << "\n" << indent << " \"" << f << "\"";
}
os << "\n" << indent << " ";
if (!(literal_args && *literal_args)) {
@@ -131,9 +142,9 @@ void cmInstallGenerator::AddInstallRule(
std::string cmInstallGenerator::CreateComponentTest(const char* component,
bool exclude_from_all)
{
- std::string result = "\"${CMAKE_INSTALL_COMPONENT}\" STREQUAL \"";
+ std::string result = R"("x${CMAKE_INSTALL_COMPONENT}x" STREQUAL "x)";
result += component;
- result += "\"";
+ result += "x\"";
if (!exclude_from_all) {
result += " OR NOT CMAKE_INSTALL_COMPONENT";
}
@@ -166,7 +177,7 @@ std::string cmInstallGenerator::ConvertToAbsoluteDestination(
std::string const& dest) const
{
std::string result;
- if (!dest.empty() && !cmSystemTools::FileIsFullPath(dest.c_str())) {
+ if (!dest.empty() && !cmSystemTools::FileIsFullPath(dest)) {
result = "${CMAKE_INSTALL_PREFIX}/";
}
result += dest;
diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h
index 8f8701f1a..024027d4d 100644
--- a/Source/cmInstallGenerator.h
+++ b/Source/cmInstallGenerator.h
@@ -3,15 +3,15 @@
#ifndef cmInstallGenerator_h
#define cmInstallGenerator_h
-#include "cmConfigure.h"
-
-#include "cmInstallType.h"
-#include "cmScriptGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
#include <vector>
+#include "cmInstallType.h"
+#include "cmScriptGenerator.h"
+
class cmLocalGenerator;
class cmMakefile;
@@ -21,8 +21,6 @@ class cmMakefile;
*/
class cmInstallGenerator : public cmScriptGenerator
{
- CM_DISABLE_COPY(cmInstallGenerator)
-
public:
enum MessageLevel
{
@@ -36,14 +34,21 @@ public:
std::vector<std::string> const& configurations,
const char* component, MessageLevel message,
bool exclude_from_all);
- ~cmInstallGenerator() CM_OVERRIDE;
+ ~cmInstallGenerator() override;
+
+ cmInstallGenerator(cmInstallGenerator const&) = delete;
+ cmInstallGenerator& operator=(cmInstallGenerator const&) = delete;
+
+ virtual bool HaveInstall();
+ virtual void CheckCMP0082(bool& haveSubdirectoryInstall,
+ bool& haveInstallAfterSubdirectory);
void AddInstallRule(
std::ostream& os, std::string const& dest, cmInstallType type,
std::vector<std::string> const& files, bool optional = false,
- const char* permissions_file = CM_NULLPTR,
- const char* permissions_dir = CM_NULLPTR, const char* rename = CM_NULLPTR,
- const char* literal_args = CM_NULLPTR, Indent indent = Indent());
+ const char* permissions_file = nullptr,
+ const char* permissions_dir = nullptr, const char* rename = nullptr,
+ const char* literal_args = nullptr, Indent indent = Indent());
/** Get the install destination as it should appear in the
installation script. */
@@ -55,10 +60,10 @@ public:
/** Select message level from CMAKE_INSTALL_MESSAGE or 'never'. */
static MessageLevel SelectMessageLevel(cmMakefile* mf, bool never = false);
- virtual void Compute(cmLocalGenerator*) {}
+ virtual bool Compute(cmLocalGenerator*) { return true; }
protected:
- void GenerateScript(std::ostream& os) CM_OVERRIDE;
+ void GenerateScript(std::ostream& os) override;
std::string CreateComponentTest(const char* component,
bool exclude_from_all);
diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx
index 5ee81fbf6..6bb4409d5 100644
--- a/Source/cmInstallProgramsCommand.cxx
+++ b/Source/cmInstallProgramsCommand.cxx
@@ -2,72 +2,81 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallProgramsCommand.h"
+#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmInstallFilesGenerator.h"
#include "cmInstallGenerator.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
+static void FinalAction(cmMakefile& makefile, std::string const& dest,
+ std::vector<std::string> const& args);
+static std::string FindInstallSource(cmMakefile& makefile, const char* name);
-// cmExecutableCommand
-bool cmInstallProgramsCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmInstallProgramsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- // Enable the install target.
- this->Makefile->GetGlobalGenerator()->EnableInstallTarget();
-
- this->Destination = args[0];
+ cmMakefile& mf = status.GetMakefile();
- this->FinalArgs.insert(this->FinalArgs.end(), args.begin() + 1, args.end());
+ // Enable the install target.
+ mf.GetGlobalGenerator()->EnableInstallTarget();
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
+ mf.GetGlobalGenerator()->AddInstallComponent(
+ mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
+ std::string const& dest = args[0];
+ std::vector<std::string> const finalArgs(args.begin() + 1, args.end());
+ mf.AddFinalAction([dest, finalArgs](cmMakefile& makefile) {
+ FinalAction(makefile, dest, finalArgs);
+ });
return true;
}
-void cmInstallProgramsCommand::FinalPass()
+static void FinalAction(cmMakefile& makefile, std::string const& dest,
+ std::vector<std::string> const& args)
{
bool files_mode = false;
- if (!this->FinalArgs.empty() && this->FinalArgs[0] == "FILES") {
+ if (!args.empty() && args[0] == "FILES") {
files_mode = true;
}
+ std::vector<std::string> files;
+
// two different options
- if (this->FinalArgs.size() > 1 || files_mode) {
+ if (args.size() > 1 || files_mode) {
// for each argument, get the programs
- std::vector<std::string>::iterator s = this->FinalArgs.begin();
+ auto s = args.begin();
if (files_mode) {
// Skip the FILES argument in files mode.
++s;
}
- for (; s != this->FinalArgs.end(); ++s) {
+ for (; s != args.end(); ++s) {
// add to the result
- this->Files.push_back(this->FindInstallSource(s->c_str()));
+ files.push_back(FindInstallSource(makefile, s->c_str()));
}
} else // reg exp list
{
std::vector<std::string> programs;
- cmSystemTools::Glob(this->Makefile->GetCurrentSourceDirectory(),
- this->FinalArgs[0], programs);
+ cmSystemTools::Glob(makefile.GetCurrentSourceDirectory(), args[0],
+ programs);
- std::vector<std::string>::iterator s = programs.begin();
+ auto s = programs.begin();
// for each argument, get the programs
for (; s != programs.end(); ++s) {
- this->Files.push_back(this->FindInstallSource(s->c_str()));
+ files.push_back(FindInstallSource(makefile, s->c_str()));
}
}
// Construct the destination. This command always installs under
// the prefix. We skip the leading slash given by the user.
- std::string destination = this->Destination.substr(1);
+ std::string destination = dest.substr(1);
cmSystemTools::ConvertToUnixSlashes(destination);
if (destination.empty()) {
destination = ".";
@@ -78,12 +87,12 @@ void cmInstallProgramsCommand::FinalPass()
const char* no_rename = "";
bool no_exclude_from_all = false;
std::string no_component =
- this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
+ makefile.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
std::vector<std::string> no_configurations;
cmInstallGenerator::MessageLevel message =
- cmInstallGenerator::SelectMessageLevel(this->Makefile);
- this->Makefile->AddInstallGenerator(new cmInstallFilesGenerator(
- this->Files, destination.c_str(), true, no_permissions, no_configurations,
+ cmInstallGenerator::SelectMessageLevel(&makefile);
+ makefile.AddInstallGenerator(new cmInstallFilesGenerator(
+ files, destination.c_str(), true, no_permissions, no_configurations,
no_component.c_str(), message, no_exclude_from_all, no_rename));
}
@@ -93,7 +102,7 @@ void cmInstallProgramsCommand::FinalPass()
* present in the build tree. If a full path is given, it is just
* returned.
*/
-std::string cmInstallProgramsCommand::FindInstallSource(const char* name) const
+static std::string FindInstallSource(cmMakefile& makefile, const char* name)
{
if (cmSystemTools::FileIsFullPath(name) ||
cmGeneratorExpression::Find(name) == 0) {
@@ -102,18 +111,14 @@ std::string cmInstallProgramsCommand::FindInstallSource(const char* name) const
}
// This is a relative path.
- std::string tb = this->Makefile->GetCurrentBinaryDirectory();
- tb += "/";
- tb += name;
- std::string ts = this->Makefile->GetCurrentSourceDirectory();
- ts += "/";
- ts += name;
-
- if (cmSystemTools::FileExists(tb.c_str())) {
+ std::string tb = cmStrCat(makefile.GetCurrentBinaryDirectory(), '/', name);
+ std::string ts = cmStrCat(makefile.GetCurrentSourceDirectory(), '/', name);
+
+ if (cmSystemTools::FileExists(tb)) {
// The file exists in the binary tree. Use it.
return tb;
}
- if (cmSystemTools::FileExists(ts.c_str())) {
+ if (cmSystemTools::FileExists(ts)) {
// The file exists in the source tree. Use it.
return ts;
}
diff --git a/Source/cmInstallProgramsCommand.h b/Source/cmInstallProgramsCommand.h
index 242fb953d..c567f3bac 100644
--- a/Source/cmInstallProgramsCommand.h
+++ b/Source/cmInstallProgramsCommand.h
@@ -3,53 +3,14 @@
#ifndef cmInstallProgramsCommand_h
#define cmInstallProgramsCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmInstallProgramsCommand
- * \brief Specifies where to install some programs
- *
- * cmInstallProgramsCommand specifies the relative path where a list of
- * programs should be installed.
- */
-class cmInstallProgramsCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmInstallProgramsCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
- /**
- * This is called at the end after all the information
- * specified by the command is accumulated. Most commands do
- * not implement this method. At this point, reading and
- * writing to the cache can be done.
- */
- void FinalPass() CM_OVERRIDE;
-
- bool HasFinalPass() const CM_OVERRIDE { return true; }
-
-protected:
- std::string FindInstallSource(const char* name) const;
-
-private:
- std::vector<std::string> FinalArgs;
- std::string Destination;
- std::vector<std::string> Files;
-};
+bool cmInstallProgramsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx
index b39a622f5..ea294556b 100644
--- a/Source/cmInstallScriptGenerator.cxx
+++ b/Source/cmInstallScriptGenerator.cxx
@@ -2,38 +2,86 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallScriptGenerator.h"
-#include "cmScriptGenerator.h"
-
#include <ostream>
#include <vector>
+#include "cmGeneratorExpression.h"
+#include "cmLocalGenerator.h"
+#include "cmMessageType.h"
+#include "cmPolicies.h"
+#include "cmScriptGenerator.h"
+
cmInstallScriptGenerator::cmInstallScriptGenerator(const char* script,
bool code,
const char* component,
bool exclude_from_all)
- : cmInstallGenerator(CM_NULLPTR, std::vector<std::string>(), component,
+ : cmInstallGenerator(nullptr, std::vector<std::string>(), component,
MessageDefault, exclude_from_all)
, Script(script)
, Code(code)
+ , AllowGenex(false)
{
+ // We need per-config actions if the script has generator expressions.
+ if (cmGeneratorExpression::Find(Script) != std::string::npos) {
+ this->ActionsPerConfig = true;
+ }
}
-cmInstallScriptGenerator::~cmInstallScriptGenerator()
+cmInstallScriptGenerator::~cmInstallScriptGenerator() = default;
+
+bool cmInstallScriptGenerator::Compute(cmLocalGenerator* lg)
{
+ this->LocalGenerator = lg;
+
+ if (this->ActionsPerConfig) {
+ switch (this->LocalGenerator->GetPolicyStatus(cmPolicies::CMP0087)) {
+ case cmPolicies::WARN:
+ this->LocalGenerator->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0087));
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::NEW:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ this->AllowGenex = true;
+ break;
+ }
+ }
+
+ return true;
}
-void cmInstallScriptGenerator::GenerateScript(std::ostream& os)
+void cmInstallScriptGenerator::AddScriptInstallRule(std::ostream& os,
+ Indent indent,
+ std::string const& script)
{
- Indent indent;
- std::string component_test =
- this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll);
- os << indent << "if(" << component_test << ")\n";
-
if (this->Code) {
- os << indent.Next() << this->Script << "\n";
+ os << indent << script << "\n";
} else {
- os << indent.Next() << "include(\"" << this->Script << "\")\n";
+ os << indent << "include(\"" << script << "\")\n";
}
+}
- os << indent << "endif()\n\n";
+void cmInstallScriptGenerator::GenerateScriptActions(std::ostream& os,
+ Indent indent)
+{
+ if (this->AllowGenex && this->ActionsPerConfig) {
+ this->cmInstallGenerator::GenerateScriptActions(os, indent);
+ } else {
+ this->AddScriptInstallRule(os, indent, this->Script);
+ }
+}
+
+void cmInstallScriptGenerator::GenerateScriptForConfig(
+ std::ostream& os, const std::string& config, Indent indent)
+{
+ if (this->AllowGenex) {
+ this->AddScriptInstallRule(os, indent,
+ cmGeneratorExpression::Evaluate(
+ this->Script, this->LocalGenerator, config));
+ } else {
+ this->AddScriptInstallRule(os, indent, this->Script);
+ }
}
diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h
index e183999d0..7efa32169 100644
--- a/Source/cmInstallScriptGenerator.h
+++ b/Source/cmInstallScriptGenerator.h
@@ -3,13 +3,16 @@
#ifndef cmInstallScriptGenerator_h
#define cmInstallScriptGenerator_h
-#include "cmConfigure.h"
-
-#include "cmInstallGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
+#include "cmInstallGenerator.h"
+#include "cmScriptGenerator.h"
+
+class cmLocalGenerator;
+
/** \class cmInstallScriptGenerator
* \brief Generate target installation rules.
*/
@@ -18,12 +21,21 @@ class cmInstallScriptGenerator : public cmInstallGenerator
public:
cmInstallScriptGenerator(const char* script, bool code,
const char* component, bool exclude_from_all);
- ~cmInstallScriptGenerator() CM_OVERRIDE;
+ ~cmInstallScriptGenerator() override;
+
+ bool Compute(cmLocalGenerator* lg) override;
protected:
- void GenerateScript(std::ostream& os) CM_OVERRIDE;
+ void GenerateScriptActions(std::ostream& os, Indent indent) override;
+ void GenerateScriptForConfig(std::ostream& os, const std::string& config,
+ Indent indent) override;
+ void AddScriptInstallRule(std::ostream& os, Indent indent,
+ std::string const& script);
+
std::string Script;
bool Code;
+ cmLocalGenerator* LocalGenerator;
+ bool AllowGenex;
};
#endif
diff --git a/Source/cmInstallSubdirectoryGenerator.cxx b/Source/cmInstallSubdirectoryGenerator.cxx
new file mode 100644
index 000000000..8a0fefac2
--- /dev/null
+++ b/Source/cmInstallSubdirectoryGenerator.cxx
@@ -0,0 +1,76 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmInstallSubdirectoryGenerator.h"
+
+#include <sstream>
+#include <vector>
+
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
+#include "cmPolicies.h"
+#include "cmScriptGenerator.h"
+#include "cmSystemTools.h"
+
+cmInstallSubdirectoryGenerator::cmInstallSubdirectoryGenerator(
+ cmMakefile* makefile, const char* binaryDirectory, bool excludeFromAll)
+ : cmInstallGenerator(nullptr, std::vector<std::string>(), nullptr,
+ MessageDefault, excludeFromAll)
+ , Makefile(makefile)
+ , BinaryDirectory(binaryDirectory)
+{
+}
+
+cmInstallSubdirectoryGenerator::~cmInstallSubdirectoryGenerator() = default;
+
+bool cmInstallSubdirectoryGenerator::HaveInstall()
+{
+ for (auto generator : this->Makefile->GetInstallGenerators()) {
+ if (generator->HaveInstall()) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void cmInstallSubdirectoryGenerator::CheckCMP0082(
+ bool& haveSubdirectoryInstall, bool& /*unused*/)
+{
+ if (this->HaveInstall()) {
+ haveSubdirectoryInstall = true;
+ }
+}
+
+bool cmInstallSubdirectoryGenerator::Compute(cmLocalGenerator* lg)
+{
+ this->LocalGenerator = lg;
+ return true;
+}
+
+void cmInstallSubdirectoryGenerator::GenerateScript(std::ostream& os)
+{
+ if (!this->ExcludeFromAll) {
+ cmPolicies::PolicyStatus status =
+ this->LocalGenerator->GetPolicyStatus(cmPolicies::CMP0082);
+ switch (status) {
+ case cmPolicies::WARN:
+ case cmPolicies::OLD:
+ // OLD behavior is handled in cmLocalGenerator::GenerateInstallRules()
+ break;
+
+ case cmPolicies::NEW:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS: {
+ Indent indent;
+ std::string odir = this->BinaryDirectory;
+ cmSystemTools::ConvertToUnixSlashes(odir);
+ os << indent << "if(NOT CMAKE_INSTALL_LOCAL_ONLY)\n"
+ << indent.Next()
+ << "# Include the install script for the subdirectory.\n"
+ << indent.Next() << "include(\"" << odir
+ << "/cmake_install.cmake\")\n"
+ << indent << "endif()\n\n";
+ } break;
+ }
+ }
+}
diff --git a/Source/cmInstallSubdirectoryGenerator.h b/Source/cmInstallSubdirectoryGenerator.h
new file mode 100644
index 000000000..b99bdd5ff
--- /dev/null
+++ b/Source/cmInstallSubdirectoryGenerator.h
@@ -0,0 +1,41 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmInstallSubdirectoryGenerator_h
+#define cmInstallSubdirectoryGenerator_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <iosfwd>
+#include <string>
+
+#include "cmInstallGenerator.h"
+
+class cmLocalGenerator;
+class cmMakefile;
+
+/** \class cmInstallSubdirectoryGenerator
+ * \brief Generate target installation rules.
+ */
+class cmInstallSubdirectoryGenerator : public cmInstallGenerator
+{
+public:
+ cmInstallSubdirectoryGenerator(cmMakefile* makefile,
+ const char* binaryDirectory,
+ bool excludeFromAll);
+ ~cmInstallSubdirectoryGenerator() override;
+
+ bool HaveInstall() override;
+ void CheckCMP0082(bool& haveSubdirectoryInstall,
+ bool& haveInstallAfterSubdirectory) override;
+
+ bool Compute(cmLocalGenerator* lg) override;
+
+protected:
+ void GenerateScript(std::ostream& os) override;
+
+ cmMakefile* Makefile;
+ std::string BinaryDirectory;
+ cmLocalGenerator* LocalGenerator;
+};
+
+#endif
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 84d6f7ac9..aa92fa71a 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallTargetGenerator.h"
-#include <assert.h>
+#include <cassert>
#include <map>
#include <set>
#include <sstream>
@@ -15,47 +15,34 @@
#include "cmInstallType.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmOutputConverter.h"
+#include "cmPolicies.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmake.h"
cmInstallTargetGenerator::cmInstallTargetGenerator(
- const std::string& targetName, const char* dest, bool implib,
+ std::string targetName, const char* dest, bool implib,
const char* file_permissions, std::vector<std::string> const& configurations,
const char* component, MessageLevel message, bool exclude_from_all,
- bool optional)
+ bool optional, cmListFileBacktrace backtrace)
: cmInstallGenerator(dest, configurations, component, message,
exclude_from_all)
- , TargetName(targetName)
- , Target(CM_NULLPTR)
+ , TargetName(std::move(targetName))
+ , Target(nullptr)
, FilePermissions(file_permissions)
, ImportLibrary(implib)
, Optional(optional)
+ , Backtrace(std::move(backtrace))
{
this->ActionsPerConfig = true;
this->NamelinkMode = NamelinkModeNone;
}
-cmInstallTargetGenerator::~cmInstallTargetGenerator()
-{
-}
-
-void cmInstallTargetGenerator::GenerateScript(std::ostream& os)
-{
- // Warn if installing an exclude-from-all target.
- if (this->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
- std::ostringstream msg;
- msg << "WARNING: Target \"" << this->Target->GetName()
- << "\" has EXCLUDE_FROM_ALL set and will not be built by default "
- << "but an install rule has been provided for it. CMake does "
- << "not define behavior for this case.";
- cmSystemTools::Message(msg.str().c_str(), "Warning");
- }
-
- // Perform the main install script generation.
- this->cmInstallGenerator::GenerateScript(os);
-}
+cmInstallTargetGenerator::~cmInstallTargetGenerator() = default;
void cmInstallTargetGenerator::GenerateScriptForConfig(
std::ostream& os, const std::string& config, Indent indent)
@@ -90,7 +77,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(
case cmStateEnums::GLOBAL_TARGET:
case cmStateEnums::UNKNOWN_LIBRARY:
this->Target->GetLocalGenerator()->IssueMessage(
- cmake::INTERNAL_ERROR,
+ MessageType::INTERNAL_ERROR,
"cmInstallTargetGenerator created with non-installable target.");
return;
}
@@ -99,20 +86,18 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(
std::string fromDirConfig;
if (this->Target->NeedRelinkBeforeInstall(config)) {
fromDirConfig =
- this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory();
- fromDirConfig += cmake::GetCMakeFilesDirectory();
- fromDirConfig += "/CMakeRelink.dir/";
+ cmStrCat(this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/CMakeRelink.dir/");
} else {
cmStateEnums::ArtifactType artifact = this->ImportLibrary
? cmStateEnums::ImportLibraryArtifact
: cmStateEnums::RuntimeBinaryArtifact;
- fromDirConfig = this->Target->GetDirectory(config, artifact);
- fromDirConfig += "/";
+ fromDirConfig =
+ cmStrCat(this->Target->GetDirectory(config, artifact), '/');
}
- std::string toDir =
- this->ConvertToAbsoluteDestination(this->GetDestination(config));
- toDir += "/";
+ std::string toDir = cmStrCat(
+ this->ConvertToAbsoluteDestination(this->GetDestination(config)), '/');
// Compute the list of files to install for this target.
std::vector<std::string> filesFrom;
@@ -123,19 +108,15 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(
// There is a bug in cmInstallCommand if this fails.
assert(this->NamelinkMode == NamelinkModeNone);
- std::string targetName;
- std::string targetNameReal;
- std::string targetNameImport;
- std::string targetNamePDB;
- this->Target->GetExecutableNames(targetName, targetNameReal,
- targetNameImport, targetNamePDB, config);
+ cmGeneratorTarget::Names targetNames =
+ this->Target->GetExecutableNames(config);
if (this->ImportLibrary) {
- std::string from1 = fromDirConfig + targetNameImport;
- std::string to1 = toDir + targetNameImport;
- filesFrom.push_back(from1);
- filesTo.push_back(to1);
+ std::string from1 = fromDirConfig + targetNames.ImportLibrary;
+ std::string to1 = toDir + targetNames.ImportLibrary;
+ filesFrom.push_back(std::move(from1));
+ filesTo.push_back(std::move(to1));
std::string targetNameImportLib;
- if (this->Target->GetImplibGNUtoMS(targetNameImport,
+ if (this->Target->GetImplibGNUtoMS(config, targetNames.ImportLibrary,
targetNameImportLib)) {
filesFrom.push_back(fromDirConfig + targetNameImportLib);
filesTo.push_back(toDir + targetNameImportLib);
@@ -144,8 +125,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(
// An import library looks like a static library.
type = cmInstallType_STATIC_LIBRARY;
} else {
- std::string from1 = fromDirConfig + targetName;
- std::string to1 = toDir + targetName;
+ std::string from1 = fromDirConfig + targetNames.Output;
+ std::string to1 = toDir + targetNames.Output;
// Handle OSX Bundles.
if (this->Target->IsAppBundleOnApple()) {
@@ -167,41 +148,36 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(
to1 += ".";
to1 += ext;
to1 += "/";
- if (!mf->PlatformIsAppleIos()) {
+ if (!mf->PlatformIsAppleEmbedded()) {
to1 += "Contents/MacOS/";
}
- to1 += targetName;
+ to1 += targetNames.Output;
} else {
// Tweaks apply to the real file, so list it first.
- if (targetNameReal != targetName) {
- std::string from2 = fromDirConfig + targetNameReal;
- std::string to2 = toDir += targetNameReal;
- filesFrom.push_back(from2);
- filesTo.push_back(to2);
+ if (targetNames.Real != targetNames.Output) {
+ std::string from2 = fromDirConfig + targetNames.Real;
+ std::string to2 = toDir += targetNames.Real;
+ filesFrom.push_back(std::move(from2));
+ filesTo.push_back(std::move(to2));
}
}
- filesFrom.push_back(from1);
- filesTo.push_back(to1);
+ filesFrom.push_back(std::move(from1));
+ filesTo.push_back(std::move(to1));
}
} else {
- std::string targetName;
- std::string targetNameSO;
- std::string targetNameReal;
- std::string targetNameImport;
- std::string targetNamePDB;
- this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal,
- targetNameImport, targetNamePDB, config);
+ cmGeneratorTarget::Names targetNames =
+ this->Target->GetLibraryNames(config);
if (this->ImportLibrary) {
// There is a bug in cmInstallCommand if this fails.
assert(this->NamelinkMode == NamelinkModeNone);
- std::string from1 = fromDirConfig + targetNameImport;
- std::string to1 = toDir + targetNameImport;
- filesFrom.push_back(from1);
- filesTo.push_back(to1);
+ std::string from1 = fromDirConfig + targetNames.ImportLibrary;
+ std::string to1 = toDir + targetNames.ImportLibrary;
+ filesFrom.push_back(std::move(from1));
+ filesTo.push_back(std::move(to1));
std::string targetNameImportLib;
- if (this->Target->GetImplibGNUtoMS(targetNameImport,
+ if (this->Target->GetImplibGNUtoMS(config, targetNames.ImportLibrary,
targetNameImportLib)) {
filesFrom.push_back(fromDirConfig + targetNameImportLib);
filesTo.push_back(toDir + targetNameImportLib);
@@ -210,56 +186,84 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(
// An import library looks like a static library.
type = cmInstallType_STATIC_LIBRARY;
} else if (this->Target->IsFrameworkOnApple()) {
- // There is a bug in cmInstallCommand if this fails.
- assert(this->NamelinkMode == NamelinkModeNone);
+ // FIXME: In principle we should be able to
+ // assert(this->NamelinkMode == NamelinkModeNone);
+ // but since the current install() command implementation checks
+ // the FRAMEWORK property immediately instead of delaying until
+ // generate time, it is possible for project code to set the
+ // property after calling install(). In such a case, the install()
+ // command will use the LIBRARY code path and create two install
+ // generators, one for the namelink component (NamelinkModeOnly)
+ // and one for the primary artifact component (NamelinkModeSkip).
+ // Historically this was not diagnosed and resulted in silent
+ // installation of a framework to the LIBRARY destination.
+ // Retain that behavior and warn about the case.
+ switch (this->NamelinkMode) {
+ case NamelinkModeNone:
+ // Normal case.
+ break;
+ case NamelinkModeOnly:
+ // Assume the NamelinkModeSkip instance will warn and install.
+ return;
+ case NamelinkModeSkip: {
+ std::string e = "Target '" + this->Target->GetName() +
+ "' was changed to a FRAMEWORK sometime after install(). "
+ "This may result in the wrong install DESTINATION. "
+ "Set the FRAMEWORK property earlier.";
+ this->Target->GetGlobalGenerator()->GetCMakeInstance()->IssueMessage(
+ MessageType::AUTHOR_WARNING, e, this->GetBacktrace());
+ } break;
+ }
// Install the whole framework directory.
type = cmInstallType_DIRECTORY;
literal_args += " USE_SOURCE_PERMISSIONS";
- std::string from1 = fromDirConfig + targetName;
+ std::string from1 = fromDirConfig + targetNames.Output;
from1 = cmSystemTools::GetFilenamePath(from1);
// Tweaks apply to the binary inside the bundle.
- std::string to1 = toDir + targetNameReal;
+ std::string to1 = toDir + targetNames.Real;
- filesFrom.push_back(from1);
- filesTo.push_back(to1);
+ filesFrom.push_back(std::move(from1));
+ filesTo.push_back(std::move(to1));
} else if (this->Target->IsCFBundleOnApple()) {
// Install the whole app bundle directory.
type = cmInstallType_DIRECTORY;
literal_args += " USE_SOURCE_PERMISSIONS";
- std::string targetNameBase = targetName.substr(0, targetName.find('/'));
+ std::string targetNameBase =
+ targetNames.Output.substr(0, targetNames.Output.find('/'));
std::string from1 = fromDirConfig + targetNameBase;
- std::string to1 = toDir + targetName;
+ std::string to1 = toDir + targetNames.Output;
- filesFrom.push_back(from1);
- filesTo.push_back(to1);
+ filesFrom.push_back(std::move(from1));
+ filesTo.push_back(std::move(to1));
} else {
bool haveNamelink = false;
// Library link name.
- std::string fromName = fromDirConfig + targetName;
- std::string toName = toDir + targetName;
+ std::string fromName = fromDirConfig + targetNames.Output;
+ std::string toName = toDir + targetNames.Output;
// Library interface name.
std::string fromSOName;
std::string toSOName;
- if (targetNameSO != targetName) {
+ if (targetNames.SharedObject != targetNames.Output) {
haveNamelink = true;
- fromSOName = fromDirConfig + targetNameSO;
- toSOName = toDir + targetNameSO;
+ fromSOName = fromDirConfig + targetNames.SharedObject;
+ toSOName = toDir + targetNames.SharedObject;
}
// Library implementation name.
std::string fromRealName;
std::string toRealName;
- if (targetNameReal != targetName && targetNameReal != targetNameSO) {
+ if (targetNames.Real != targetNames.Output &&
+ targetNames.Real != targetNames.SharedObject) {
haveNamelink = true;
- fromRealName = fromDirConfig + targetNameReal;
- toRealName = toDir + targetNameReal;
+ fromRealName = fromDirConfig + targetNames.Real;
+ toRealName = toDir + targetNames.Real;
}
// Add the names based on the current namelink mode.
@@ -312,8 +316,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(
&cmInstallTargetGenerator::PreReplacementTweaks);
// Write code to install the target file.
- const char* no_dir_permissions = CM_NULLPTR;
- const char* no_rename = CM_NULLPTR;
+ const char* no_dir_permissions = nullptr;
+ const char* no_rename = nullptr;
bool optional = this->Optional || this->ImportLibrary;
this->AddInstallRule(os, this->GetDestination(config), type, filesFrom,
optional, this->FilePermissions.c_str(),
@@ -351,8 +355,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfigObjectLibrary(
std::string const obj_dir = this->Target->GetObjectDirectory(config);
std::string const literal_args = " FILES_FROM_DIR \"" + obj_dir + "\"";
- const char* no_dir_permissions = CM_NULLPTR;
- const char* no_rename = CM_NULLPTR;
+ const char* no_dir_permissions = nullptr;
+ const char* no_rename = nullptr;
this->AddInstallRule(os, dest, cmInstallType_FILES, objects, this->Optional,
this->FilePermissions.c_str(), no_dir_permissions,
no_rename, literal_args.c_str(), indent);
@@ -362,18 +366,16 @@ void cmInstallTargetGenerator::GetInstallObjectNames(
std::string const& config, std::vector<std::string>& objects) const
{
this->Target->GetTargetObjectNames(config, objects);
- for (std::vector<std::string>::iterator i = objects.begin();
- i != objects.end(); ++i) {
- *i = computeInstallObjectDir(this->Target, config) + "/" + *i;
+ for (std::string& o : objects) {
+ o = cmStrCat(computeInstallObjectDir(this->Target, config), "/", o);
}
}
std::string cmInstallTargetGenerator::GetDestination(
std::string const& config) const
{
- cmGeneratorExpression ge;
- return ge.Parse(this->Destination)
- ->Evaluate(this->Target->GetLocalGenerator(), config);
+ return cmGeneratorExpression::Evaluate(
+ this->Destination, this->Target->GetLocalGenerator(), config);
}
std::string cmInstallTargetGenerator::GetInstallFilename(
@@ -391,57 +393,54 @@ std::string cmInstallTargetGenerator::GetInstallFilename(
std::string fname;
// Compute the name of the library.
if (target->GetType() == cmStateEnums::EXECUTABLE) {
- std::string targetName;
- std::string targetNameReal;
- std::string targetNameImport;
- std::string targetNamePDB;
- target->GetExecutableNames(targetName, targetNameReal, targetNameImport,
- targetNamePDB, config);
+ cmGeneratorTarget::Names targetNames = target->GetExecutableNames(config);
if (nameType == NameImplib) {
// Use the import library name.
- if (!target->GetImplibGNUtoMS(targetNameImport, fname,
+ if (!target->GetImplibGNUtoMS(config, targetNames.ImportLibrary, fname,
"${CMAKE_IMPORT_LIBRARY_SUFFIX}")) {
- fname = targetNameImport;
+ fname = targetNames.ImportLibrary;
}
} else if (nameType == NameReal) {
// Use the canonical name.
- fname = targetNameReal;
+ fname = targetNames.Real;
} else {
// Use the canonical name.
- fname = targetName;
+ fname = targetNames.Output;
}
} else {
- std::string targetName;
- std::string targetNameSO;
- std::string targetNameReal;
- std::string targetNameImport;
- std::string targetNamePDB;
- target->GetLibraryNames(targetName, targetNameSO, targetNameReal,
- targetNameImport, targetNamePDB, config);
+ cmGeneratorTarget::Names targetNames = target->GetLibraryNames(config);
if (nameType == NameImplib) {
// Use the import library name.
- if (!target->GetImplibGNUtoMS(targetNameImport, fname,
+ if (!target->GetImplibGNUtoMS(config, targetNames.ImportLibrary, fname,
"${CMAKE_IMPORT_LIBRARY_SUFFIX}")) {
- fname = targetNameImport;
+ fname = targetNames.ImportLibrary;
}
} else if (nameType == NameSO) {
// Use the soname.
- fname = targetNameSO;
+ fname = targetNames.SharedObject;
} else if (nameType == NameReal) {
// Use the real name.
- fname = targetNameReal;
+ fname = targetNames.Real;
} else {
// Use the canonical name.
- fname = targetName;
+ fname = targetNames.Output;
}
}
return fname;
}
-void cmInstallTargetGenerator::Compute(cmLocalGenerator* lg)
+bool cmInstallTargetGenerator::Compute(cmLocalGenerator* lg)
{
+ // Lookup this target in the current directory.
this->Target = lg->FindLocalNonAliasGeneratorTarget(this->TargetName);
+ if (!this->Target) {
+ // If no local target has been found, find it in the global scope.
+ this->Target =
+ lg->GetGlobalGenerator()->FindGeneratorTarget(this->TargetName);
+ }
+
+ return true;
}
void cmInstallTargetGenerator::AddTweak(std::ostream& os, Indent indent,
@@ -476,9 +475,8 @@ void cmInstallTargetGenerator::AddTweak(std::ostream& os, Indent indent,
if (!tws.empty()) {
Indent indent2 = indent.Next().Next();
os << indent << "foreach(file\n";
- for (std::vector<std::string>::const_iterator i = files.begin();
- i != files.end(); ++i) {
- os << indent2 << "\"" << this->GetDestDirPath(*i) << "\"\n";
+ for (std::string const& f : files) {
+ os << indent2 << "\"" << this->GetDestDirPath(f) << "\"\n";
}
os << indent2 << ")\n";
os << tws;
@@ -546,11 +544,7 @@ void cmInstallTargetGenerator::AddInstallNamePatchRule(
this->Target->GetLinkInformation(config)) {
std::set<cmGeneratorTarget const*> const& sharedLibs =
cli->GetSharedLibrariesLinked();
- for (std::set<cmGeneratorTarget const*>::const_iterator j =
- sharedLibs.begin();
- j != sharedLibs.end(); ++j) {
- cmGeneratorTarget const* tgt = *j;
-
+ for (cmGeneratorTarget const* tgt : sharedLibs) {
// The install_name of an imported target does not change.
if (tgt->IsImported()) {
continue;
@@ -596,8 +590,8 @@ void cmInstallTargetGenerator::AddInstallNamePatchRule(
// on the installed file.
if (for_build != for_install) {
// Prepare to refer to the install-tree install_name.
- new_id = for_install;
- new_id += this->GetInstallFilename(this->Target, config, NameSO);
+ new_id = cmStrCat(
+ for_install, this->GetInstallFilename(this->Target, config, NameSO));
}
}
@@ -609,12 +603,9 @@ void cmInstallTargetGenerator::AddInstallNamePatchRule(
if (!new_id.empty()) {
os << "\n" << indent << " -id \"" << new_id << "\"";
}
- for (std::map<std::string, std::string>::const_iterator i =
- install_name_remap.begin();
- i != install_name_remap.end(); ++i) {
+ for (auto const& i : install_name_remap) {
os << "\n"
- << indent << " -change \"" << i->first << "\" \"" << i->second
- << "\"";
+ << indent << " -change \"" << i.first << "\" \"" << i.second << "\"";
}
os << "\n" << indent << " \"" << toDestDirPath << "\")\n";
}
@@ -641,17 +632,34 @@ void cmInstallTargetGenerator::AddRPathCheckRule(
return;
}
- // Get the install RPATH from the link information.
- std::string newRpath = cli->GetChrpathString();
-
// Write a rule to remove the installed file if its rpath is not the
// new rpath. This is needed for existing build/install trees when
// the installed rpath changes but the file is not rebuilt.
- /* clang-format off */
os << indent << "file(RPATH_CHECK\n"
- << indent << " FILE \"" << toDestDirPath << "\"\n"
- << indent << " RPATH \"" << newRpath << "\")\n";
- /* clang-format on */
+ << indent << " FILE \"" << toDestDirPath << "\"\n";
+
+ // CMP0095: ``RPATH`` entries are properly escaped in the intermediary
+ // CMake install script.
+ switch (this->Target->GetPolicyStatusCMP0095()) {
+ case cmPolicies::WARN:
+ // No author warning needed here, we warn later in
+ // cmInstallTargetGenerator::AddChrpathPatchRule().
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD: {
+ // Get the install RPATH from the link information.
+ std::string newRpath = cli->GetChrpathString();
+ os << indent << " RPATH \"" << newRpath << "\")\n";
+ break;
+ }
+ default: {
+ // Get the install RPATH from the link information and
+ // escape any CMake syntax in the install RPATH.
+ std::string escapedNewRpath =
+ cmOutputConverter::EscapeForCMake(cli->GetChrpathString());
+ os << indent << " RPATH " << escapedNewRpath << ")\n";
+ break;
+ }
+ }
}
void cmInstallTargetGenerator::AddChrpathPatchRule(
@@ -677,7 +685,8 @@ void cmInstallTargetGenerator::AddChrpathPatchRule(
std::string installNameTool =
mf->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL");
- std::vector<std::string> oldRuntimeDirs, newRuntimeDirs;
+ std::vector<std::string> oldRuntimeDirs;
+ std::vector<std::string> newRuntimeDirs;
cli->GetRPath(oldRuntimeDirs, false);
cli->GetRPath(newRuntimeDirs, true);
@@ -697,15 +706,14 @@ void cmInstallTargetGenerator::AddChrpathPatchRule(
<< "Therefore, runtime paths will not be changed when installing. "
<< "CMAKE_BUILD_WITH_INSTALL_RPATH may be used to work around"
" this limitation.";
- mf->IssueMessage(cmake::WARNING, msg.str());
+ mf->IssueMessage(MessageType::WARNING, msg.str());
} else {
// Note: These paths are kept unique to avoid
// install_name_tool corruption.
std::set<std::string> runpaths;
- for (std::vector<std::string>::const_iterator i = oldRuntimeDirs.begin();
- i != oldRuntimeDirs.end(); ++i) {
+ for (std::string const& i : oldRuntimeDirs) {
std::string runpath =
- mf->GetGlobalGenerator()->ExpandCFGIntDir(*i, config);
+ mf->GetGlobalGenerator()->ExpandCFGIntDir(i, config);
if (runpaths.find(runpath) == runpaths.end()) {
runpaths.insert(runpath);
@@ -717,10 +725,9 @@ void cmInstallTargetGenerator::AddChrpathPatchRule(
}
runpaths.clear();
- for (std::vector<std::string>::const_iterator i = newRuntimeDirs.begin();
- i != newRuntimeDirs.end(); ++i) {
+ for (std::string const& i : newRuntimeDirs) {
std::string runpath =
- mf->GetGlobalGenerator()->ExpandCFGIntDir(*i, config);
+ mf->GetGlobalGenerator()->ExpandCFGIntDir(i, config);
if (runpaths.find(runpath) == runpaths.end()) {
os << indent << "execute_process(COMMAND " << installNameTool
@@ -742,11 +749,34 @@ void cmInstallTargetGenerator::AddChrpathPatchRule(
return;
}
+ // Escape any CMake syntax in the RPATHs.
+ std::string escapedOldRpath = cmOutputConverter::EscapeForCMake(oldRpath);
+ std::string escapedNewRpath = cmOutputConverter::EscapeForCMake(newRpath);
+
// Write a rule to run chrpath to set the install-tree RPATH
os << indent << "file(RPATH_CHANGE\n"
<< indent << " FILE \"" << toDestDirPath << "\"\n"
- << indent << " OLD_RPATH \"" << oldRpath << "\"\n"
- << indent << " NEW_RPATH \"" << newRpath << "\")\n";
+ << indent << " OLD_RPATH " << escapedOldRpath << "\n";
+
+ // CMP0095: ``RPATH`` entries are properly escaped in the intermediary
+ // CMake install script.
+ switch (this->Target->GetPolicyStatusCMP0095()) {
+ case cmPolicies::WARN:
+ this->IssueCMP0095Warning(newRpath);
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ os << indent << " NEW_RPATH \"" << newRpath << "\"";
+ break;
+ default:
+ os << indent << " NEW_RPATH " << escapedNewRpath;
+ break;
+ }
+
+ if (this->Target->GetPropertyAsBool("INSTALL_REMOVE_ENVIRONMENT_RPATH")) {
+ os << "\n" << indent << " INSTALL_REMOVE_ENVIRONMENT_RPATH)\n";
+ } else {
+ os << ")\n";
+ }
}
}
@@ -771,10 +801,22 @@ void cmInstallTargetGenerator::AddStripRule(std::ostream& os, Indent indent,
return;
}
+ std::string stripArgs;
+
+ // macOS 'strip' is picky, executables need '-u -r' and dylibs need '-x'.
+ if (this->Target->Target->GetMakefile()->IsOn("APPLE")) {
+ if (this->Target->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->Target->GetType() == cmStateEnums::MODULE_LIBRARY) {
+ stripArgs = "-x ";
+ } else if (this->Target->GetType() == cmStateEnums::EXECUTABLE) {
+ stripArgs = "-u -r ";
+ }
+ }
+
os << indent << "if(CMAKE_INSTALL_DO_STRIP)\n";
os << indent << " execute_process(COMMAND \""
<< this->Target->Target->GetMakefile()->GetDefinition("CMAKE_STRIP")
- << "\" \"" << toDestDirPath << "\")\n";
+ << "\" " << stripArgs << "\"" << toDestDirPath << "\")\n";
os << indent << "endif()\n";
}
@@ -792,7 +834,7 @@ void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, Indent indent,
return;
}
- std::string ranlib =
+ const std::string& ranlib =
this->Target->Target->GetMakefile()->GetRequiredDefinition("CMAKE_RANLIB");
if (ranlib.empty()) {
return;
@@ -807,7 +849,7 @@ void cmInstallTargetGenerator::AddUniversalInstallRule(
{
cmMakefile const* mf = this->Target->Target->GetMakefile();
- if (!mf->PlatformIsAppleIos() || !mf->IsOn("XCODE")) {
+ if (!mf->PlatformIsAppleEmbedded() || !mf->IsOn("XCODE")) {
return;
}
@@ -837,3 +879,26 @@ void cmInstallTargetGenerator::AddUniversalInstallRule(
<< "\"" << this->Target->Target->GetName() << "\" "
<< "\"" << toDestDirPath << "\")\n";
}
+
+void cmInstallTargetGenerator::IssueCMP0095Warning(
+ const std::string& unescapedRpath)
+{
+ // Reduce warning noise to cases where used RPATHs may actually be affected
+ // by CMP0095. This filter is meant to skip warnings in cases when
+ // non-curly-braces syntax (e.g. $ORIGIN) or no keyword is used which has
+ // worked already before CMP0095. We intend to issue a warning in all cases
+ // with curly-braces syntax, even if the workaround of double-escaping is in
+ // place, since we deprecate the need for it with CMP0095.
+ const bool potentially_affected(unescapedRpath.find("${") !=
+ std::string::npos);
+
+ if (potentially_affected) {
+ std::ostringstream w;
+ w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0095) << "\n";
+ w << "RPATH entries for target '" << this->Target->GetName() << "' "
+ << "will not be escaped in the intermediary "
+ << "cmake_install.cmake script.";
+ this->Target->GetGlobalGenerator()->GetCMakeInstance()->IssueMessage(
+ MessageType::AUTHOR_WARNING, w.str(), this->GetBacktrace());
+ }
+}
diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h
index cf2de58f9..8730454b1 100644
--- a/Source/cmInstallTargetGenerator.h
+++ b/Source/cmInstallTargetGenerator.h
@@ -3,15 +3,16 @@
#ifndef cmInstallTargetGenerator_h
#define cmInstallTargetGenerator_h
-#include "cmConfigure.h"
-
-#include "cmInstallGenerator.h"
-#include "cmScriptGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
#include <vector>
+#include "cmInstallGenerator.h"
+#include "cmListFileCache.h"
+#include "cmScriptGenerator.h"
+
class cmGeneratorTarget;
class cmLocalGenerator;
@@ -21,12 +22,13 @@ class cmLocalGenerator;
class cmInstallTargetGenerator : public cmInstallGenerator
{
public:
- cmInstallTargetGenerator(std::string const& targetName, const char* dest,
- bool implib, const char* file_permissions,
- std::vector<std::string> const& configurations,
- const char* component, MessageLevel message,
- bool exclude_from_all, bool optional);
- ~cmInstallTargetGenerator() CM_OVERRIDE;
+ cmInstallTargetGenerator(
+ std::string targetName, const char* dest, bool implib,
+ const char* file_permissions,
+ std::vector<std::string> const& configurations, const char* component,
+ MessageLevel message, bool exclude_from_all, bool optional,
+ cmListFileBacktrace backtrace = cmListFileBacktrace());
+ ~cmInstallTargetGenerator() override;
/** Select the policy for installing shared library linkable name
symlinks. */
@@ -56,7 +58,7 @@ public:
const std::string& config,
NameType nameType = NameNormal);
- void Compute(cmLocalGenerator* lg) CM_OVERRIDE;
+ bool Compute(cmLocalGenerator* lg) override;
cmGeneratorTarget* GetTarget() const { return this->Target; }
@@ -64,16 +66,17 @@ public:
std::string GetDestination(std::string const& config) const;
+ cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
+
protected:
- void GenerateScript(std::ostream& os) CM_OVERRIDE;
void GenerateScriptForConfig(std::ostream& os, const std::string& config,
- Indent indent) CM_OVERRIDE;
+ Indent indent) override;
void GenerateScriptForConfigObjectLibrary(std::ostream& os,
const std::string& config,
Indent indent);
- typedef void (cmInstallTargetGenerator::*TweakMethod)(std::ostream&, Indent,
- const std::string&,
- std::string const&);
+ using TweakMethod = void (cmInstallTargetGenerator::*)(std::ostream&, Indent,
+ const std::string&,
+ const std::string&);
void AddTweak(std::ostream& os, Indent indent, const std::string& config,
std::string const& file, TweakMethod tweak);
void AddTweak(std::ostream& os, Indent indent, const std::string& config,
@@ -101,6 +104,7 @@ protected:
const std::string& toDestDirPath);
void AddUniversalInstallRule(std::ostream& os, Indent indent,
const std::string& toDestDirPath);
+ void IssueCMP0095Warning(const std::string& unescapedRpath);
std::string TargetName;
cmGeneratorTarget* Target;
@@ -108,6 +112,7 @@ protected:
NamelinkModeType NamelinkMode;
bool ImportLibrary;
bool Optional;
+ cmListFileBacktrace Backtrace;
};
#endif
diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx
index e00eba012..44f23a581 100644
--- a/Source/cmInstallTargetsCommand.cxx
+++ b/Source/cmInstallTargetsCommand.cxx
@@ -2,57 +2,57 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallTargetsCommand.h"
+#include <unordered_map>
#include <utility>
+#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmTarget.h"
-#include "cm_unordered_map.hxx"
-class cmExecutionStatus;
-
-// cmExecutableCommand
-bool cmInstallTargetsCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmInstallTargetsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// Enable the install target.
- this->Makefile->GetGlobalGenerator()->EnableInstallTarget();
+ mf.GetGlobalGenerator()->EnableInstallTarget();
- cmTargets& tgts = this->Makefile->GetTargets();
- std::vector<std::string>::const_iterator s = args.begin();
+ cmMakefile::cmTargetMap& tgts = mf.GetTargets();
+ auto s = args.begin();
++s;
std::string runtime_dir = "/bin";
for (; s != args.end(); ++s) {
if (*s == "RUNTIME_DIRECTORY") {
++s;
if (s == args.end()) {
- this->SetError("called with RUNTIME_DIRECTORY but no actual "
- "directory");
+ status.SetError("called with RUNTIME_DIRECTORY but no actual "
+ "directory");
return false;
}
runtime_dir = *s;
} else {
- cmTargets::iterator ti = tgts.find(*s);
+ auto ti = tgts.find(*s);
if (ti != tgts.end()) {
- ti->second.SetInstallPath(args[0].c_str());
- ti->second.SetRuntimeInstallPath(runtime_dir.c_str());
+ ti->second.SetInstallPath(args[0]);
+ ti->second.SetRuntimeInstallPath(runtime_dir);
ti->second.SetHaveInstallRule(true);
} else {
std::string str = "Cannot find target: \"" + *s + "\" to install.";
- this->SetError(str);
+ status.SetError(str);
return false;
}
}
}
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
+ mf.GetGlobalGenerator()->AddInstallComponent(
+ mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
return true;
}
diff --git a/Source/cmInstallTargetsCommand.h b/Source/cmInstallTargetsCommand.h
index cc8484365..0c5850c91 100644
--- a/Source/cmInstallTargetsCommand.h
+++ b/Source/cmInstallTargetsCommand.h
@@ -3,36 +3,14 @@
#ifndef cmInstallTargetsCommand_h
#define cmInstallTargetsCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmInstallTargetsCommand
- * \brief Specifies where to install some targets
- *
- * cmInstallTargetsCommand specifies the relative path where a list of
- * targets should be installed. The targets can be executables or
- * libraries.
- */
-class cmInstallTargetsCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmInstallTargetsCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmInstallTargetsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx
index d51fd8d74..eabe5903b 100644
--- a/Source/cmInstalledFile.cxx
+++ b/Source/cmInstalledFile.cxx
@@ -2,29 +2,22 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstalledFile.h"
+#include <utility>
+
#include "cmAlgorithms.h"
+#include "cmGeneratorExpression.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
-#include "cmSystemTools.h"
+#include "cmStringAlgorithms.h"
-#include "cmConfigure.h"
-#include <utility>
-
-cmInstalledFile::cmInstalledFile()
- : NameExpression(CM_NULLPTR)
-{
-}
+cmInstalledFile::cmInstalledFile() = default;
cmInstalledFile::~cmInstalledFile()
{
- if (NameExpression) {
- delete NameExpression;
- }
+ delete NameExpression;
}
-cmInstalledFile::Property::Property()
-{
-}
+cmInstalledFile::Property::Property() = default;
cmInstalledFile::Property::~Property()
{
@@ -81,7 +74,7 @@ bool cmInstalledFile::HasProperty(const std::string& prop) const
bool cmInstalledFile::GetProperty(const std::string& prop,
std::string& value) const
{
- PropertyMapType::const_iterator i = this->Properties.find(prop);
+ auto i = this->Properties.find(prop);
if (i == this->Properties.end()) {
return false;
}
@@ -91,11 +84,9 @@ bool cmInstalledFile::GetProperty(const std::string& prop,
std::string output;
std::string separator;
- for (ExpressionVectorType::const_iterator j =
- property.ValueExpressions.begin();
- j != property.ValueExpressions.end(); ++j) {
+ for (auto ve : property.ValueExpressions) {
output += separator;
- output += (*j)->GetInput();
+ output += ve->GetInput();
separator = ";";
}
@@ -107,7 +98,7 @@ bool cmInstalledFile::GetPropertyAsBool(const std::string& prop) const
{
std::string value;
bool isSet = this->GetProperty(prop, value);
- return isSet && cmSystemTools::IsOn(value.c_str());
+ return isSet && cmIsOn(value);
}
void cmInstalledFile::GetPropertyAsList(const std::string& prop,
@@ -117,5 +108,5 @@ void cmInstalledFile::GetPropertyAsList(const std::string& prop,
this->GetProperty(prop, value);
list.clear();
- cmSystemTools::ExpandListArgument(value, list);
+ cmExpandList(value, list);
}
diff --git a/Source/cmInstalledFile.h b/Source/cmInstalledFile.h
index fbf754ffd..ee809ee79 100644
--- a/Source/cmInstalledFile.h
+++ b/Source/cmInstalledFile.h
@@ -5,13 +5,12 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmGeneratorExpression.h"
-#include "cm_auto_ptr.hxx"
-
#include <map>
+#include <memory>
#include <string>
#include <vector>
+class cmCompiledGeneratorExpression;
class cmMakefile;
/** \class cmInstalledFile
@@ -22,25 +21,31 @@ class cmMakefile;
class cmInstalledFile
{
public:
- typedef CM_AUTO_PTR<cmCompiledGeneratorExpression>
- CompiledGeneratorExpressionPtrType;
+ using CompiledGeneratorExpressionPtrType =
+ std::unique_ptr<cmCompiledGeneratorExpression>;
- typedef std::vector<cmCompiledGeneratorExpression*> ExpressionVectorType;
+ using ExpressionVectorType = std::vector<cmCompiledGeneratorExpression*>;
struct Property
{
Property();
~Property();
+ Property(const Property&) = delete;
+ Property& operator=(const Property&) = delete;
+
ExpressionVectorType ValueExpressions;
};
- typedef std::map<std::string, Property> PropertyMapType;
+ using PropertyMapType = std::map<std::string, Property>;
cmInstalledFile();
~cmInstalledFile();
+ cmInstalledFile(const cmInstalledFile&) = delete;
+ cmInstalledFile& operator=(const cmInstalledFile&) = delete;
+
void RemoveProperty(const std::string& prop);
void SetProperty(cmMakefile const* mf, const std::string& prop,
@@ -68,7 +73,7 @@ public:
private:
std::string Name;
- cmCompiledGeneratorExpression* NameExpression;
+ cmCompiledGeneratorExpression* NameExpression = nullptr;
PropertyMapType Properties;
};
diff --git a/Source/cmJsonObjectDictionary.h b/Source/cmJsonObjectDictionary.h
new file mode 100644
index 000000000..8a2b52995
--- /dev/null
+++ b/Source/cmJsonObjectDictionary.h
@@ -0,0 +1,45 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#pragma once
+
+#include <string>
+
+// Vocabulary:
+
+static const std::string kARTIFACTS_KEY = "artifacts";
+static const std::string kBUILD_DIRECTORY_KEY = "buildDirectory";
+static const std::string kCOMPILE_FLAGS_KEY = "compileFlags";
+static const std::string kCONFIGURATIONS_KEY = "configurations";
+static const std::string kDEFINES_KEY = "defines";
+static const std::string kFILE_GROUPS_KEY = "fileGroups";
+static const std::string kFRAMEWORK_PATH_KEY = "frameworkPath";
+static const std::string kFULL_NAME_KEY = "fullName";
+static const std::string kINCLUDE_PATH_KEY = "includePath";
+static const std::string kIS_CMAKE_KEY = "isCMake";
+static const std::string kIS_GENERATED_KEY = "isGenerated";
+static const std::string kIS_SYSTEM_KEY = "isSystem";
+static const std::string kIS_TEMPORARY_KEY = "isTemporary";
+static const std::string kKEY_KEY = "key";
+static const std::string kLANGUAGE_KEY = "language";
+static const std::string kLINKER_LANGUAGE_KEY = "linkerLanguage";
+static const std::string kLINK_FLAGS_KEY = "linkFlags";
+static const std::string kLINK_LANGUAGE_FLAGS_KEY = "linkLanguageFlags";
+static const std::string kLINK_LIBRARIES_KEY = "linkLibraries";
+static const std::string kLINK_PATH_KEY = "linkPath";
+static const std::string kNAME_KEY = "name";
+static const std::string kPATH_KEY = "path";
+static const std::string kPROJECTS_KEY = "projects";
+static const std::string kPROPERTIES_KEY = "properties";
+static const std::string kSOURCE_DIRECTORY_KEY = "sourceDirectory";
+static const std::string kSOURCES_KEY = "sources";
+static const std::string kSYSROOT_KEY = "sysroot";
+static const std::string kTARGETS_KEY = "targets";
+static const std::string kTYPE_KEY = "type";
+static const std::string kVALUE_KEY = "value";
+static const std::string kHAS_INSTALL_RULE = "hasInstallRule";
+static const std::string kINSTALL_PATHS = "installPaths";
+static const std::string kCTEST_NAME = "ctestName";
+static const std::string kCTEST_COMMAND = "ctestCommand";
+static const std::string kCTEST_INFO = "ctestInfo";
+static const std::string kMINIMUM_CMAKE_VERSION = "minimumCMakeVersion";
+static const std::string kIS_GENERATOR_PROVIDED_KEY = "isGeneratorProvided";
diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx
new file mode 100644
index 000000000..b23ab43d8
--- /dev/null
+++ b/Source/cmJsonObjects.cxx
@@ -0,0 +1,692 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmJsonObjects.h" // IWYU pragma: keep
+
+#include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <functional>
+#include <limits>
+#include <map>
+#include <set>
+#include <string>
+#include <unordered_map>
+#include <utility>
+#include <vector>
+
+#include "cmAlgorithms.h"
+#include "cmGeneratorExpression.h"
+#include "cmGeneratorTarget.h"
+#include "cmGlobalGenerator.h"
+#include "cmInstallGenerator.h"
+#include "cmInstallSubdirectoryGenerator.h"
+#include "cmInstallTargetGenerator.h"
+#include "cmJsonObjectDictionary.h"
+#include "cmJsonObjects.h"
+#include "cmLinkLineComputer.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
+#include "cmPropertyMap.h"
+#include "cmSourceFile.h"
+#include "cmState.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
+#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmTarget.h"
+#include "cmTest.h"
+#include "cmake.h"
+
+namespace {
+
+std::vector<std::string> getConfigurations(const cmake* cm)
+{
+ std::vector<std::string> configurations;
+ auto makefiles = cm->GetGlobalGenerator()->GetMakefiles();
+ if (makefiles.empty()) {
+ return configurations;
+ }
+
+ makefiles[0]->GetConfigurations(configurations);
+ if (configurations.empty()) {
+ configurations.emplace_back();
+ }
+ return configurations;
+}
+
+bool hasString(const Json::Value& v, const std::string& s)
+{
+ return !v.isNull() &&
+ std::any_of(v.begin(), v.end(),
+ [s](const Json::Value& i) { return i.asString() == s; });
+}
+
+template <class T>
+Json::Value fromStringList(const T& in)
+{
+ Json::Value result = Json::arrayValue;
+ for (std::string const& i : in) {
+ result.append(i);
+ }
+ return result;
+}
+
+} // namespace
+
+void cmGetCMakeInputs(const cmGlobalGenerator* gg,
+ const std::string& sourceDir,
+ const std::string& buildDir,
+ std::vector<std::string>* internalFiles,
+ std::vector<std::string>* explicitFiles,
+ std::vector<std::string>* tmpFiles)
+{
+ const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot() + '/';
+ std::vector<cmMakefile*> const& makefiles = gg->GetMakefiles();
+ for (cmMakefile const* mf : makefiles) {
+ for (std::string const& lf : mf->GetListFiles()) {
+
+ const std::string startOfFile = lf.substr(0, cmakeRootDir.size());
+ const bool isInternal = (startOfFile == cmakeRootDir);
+ const bool isTemporary = !isInternal && (lf.find(buildDir + '/') == 0);
+
+ std::string toAdd = lf;
+ if (!sourceDir.empty()) {
+ const std::string& relative =
+ cmSystemTools::RelativePath(sourceDir, lf);
+ if (toAdd.size() > relative.size()) {
+ toAdd = relative;
+ }
+ }
+
+ if (isInternal) {
+ if (internalFiles) {
+ internalFiles->push_back(std::move(toAdd));
+ }
+ } else {
+ if (isTemporary) {
+ if (tmpFiles) {
+ tmpFiles->push_back(std::move(toAdd));
+ }
+ } else {
+ if (explicitFiles) {
+ explicitFiles->push_back(std::move(toAdd));
+ }
+ }
+ }
+ }
+ }
+}
+
+Json::Value cmDumpCMakeInputs(const cmake* cm)
+{
+ const cmGlobalGenerator* gg = cm->GetGlobalGenerator();
+ const std::string& buildDir = cm->GetHomeOutputDirectory();
+ const std::string& sourceDir = cm->GetHomeDirectory();
+
+ std::vector<std::string> internalFiles;
+ std::vector<std::string> explicitFiles;
+ std::vector<std::string> tmpFiles;
+ cmGetCMakeInputs(gg, sourceDir, buildDir, &internalFiles, &explicitFiles,
+ &tmpFiles);
+
+ Json::Value array = Json::arrayValue;
+
+ Json::Value tmp = Json::objectValue;
+ tmp[kIS_CMAKE_KEY] = true;
+ tmp[kIS_TEMPORARY_KEY] = false;
+ tmp[kSOURCES_KEY] = fromStringList(internalFiles);
+ array.append(tmp);
+
+ tmp = Json::objectValue;
+ tmp[kIS_CMAKE_KEY] = false;
+ tmp[kIS_TEMPORARY_KEY] = false;
+ tmp[kSOURCES_KEY] = fromStringList(explicitFiles);
+ array.append(tmp);
+
+ tmp = Json::objectValue;
+ tmp[kIS_CMAKE_KEY] = false;
+ tmp[kIS_TEMPORARY_KEY] = true;
+ tmp[kSOURCES_KEY] = fromStringList(tmpFiles);
+ array.append(tmp);
+
+ return array;
+}
+
+class LanguageData
+{
+public:
+ bool operator==(const LanguageData& other) const;
+
+ void SetDefines(const std::set<std::string>& defines);
+
+ bool IsGenerated = false;
+ std::string Language;
+ std::string Flags;
+ std::vector<std::string> Defines;
+ std::vector<std::pair<std::string, bool>> IncludePathList;
+};
+
+bool LanguageData::operator==(const LanguageData& other) const
+{
+ return Language == other.Language && Defines == other.Defines &&
+ Flags == other.Flags && IncludePathList == other.IncludePathList &&
+ IsGenerated == other.IsGenerated;
+}
+
+void LanguageData::SetDefines(const std::set<std::string>& defines)
+{
+ std::vector<std::string> result;
+ result.reserve(defines.size());
+ for (std::string const& i : defines) {
+ result.push_back(i);
+ }
+ std::sort(result.begin(), result.end());
+ Defines = std::move(result);
+}
+
+namespace std {
+
+template <>
+struct hash<LanguageData>
+{
+ std::size_t operator()(const LanguageData& in) const
+ {
+ using std::hash;
+ size_t result =
+ hash<std::string>()(in.Language) ^ hash<std::string>()(in.Flags);
+ for (auto const& i : in.IncludePathList) {
+ result = result ^
+ (hash<std::string>()(i.first) ^
+ (i.second ? std::numeric_limits<size_t>::max() : 0));
+ }
+ for (auto const& i : in.Defines) {
+ result = result ^ hash<std::string>()(i);
+ }
+ result =
+ result ^ (in.IsGenerated ? std::numeric_limits<size_t>::max() : 0);
+ return result;
+ }
+};
+
+} // namespace std
+
+static Json::Value DumpSourceFileGroup(const LanguageData& data,
+ const std::vector<std::string>& files,
+ const std::string& baseDir)
+{
+ Json::Value result = Json::objectValue;
+
+ if (!data.Language.empty()) {
+ result[kLANGUAGE_KEY] = data.Language;
+ if (!data.Flags.empty()) {
+ result[kCOMPILE_FLAGS_KEY] = data.Flags;
+ }
+ if (!data.IncludePathList.empty()) {
+ Json::Value includes = Json::arrayValue;
+ for (auto const& i : data.IncludePathList) {
+ Json::Value tmp = Json::objectValue;
+ tmp[kPATH_KEY] = i.first;
+ if (i.second) {
+ tmp[kIS_SYSTEM_KEY] = i.second;
+ }
+ includes.append(tmp);
+ }
+ result[kINCLUDE_PATH_KEY] = includes;
+ }
+ if (!data.Defines.empty()) {
+ result[kDEFINES_KEY] = fromStringList(data.Defines);
+ }
+ }
+
+ result[kIS_GENERATED_KEY] = data.IsGenerated;
+
+ Json::Value sourcesValue = Json::arrayValue;
+ for (auto const& i : files) {
+ const std::string relPath = cmSystemTools::RelativePath(baseDir, i);
+ sourcesValue.append(relPath.size() < i.size() ? relPath : i);
+ }
+
+ result[kSOURCES_KEY] = sourcesValue;
+ return result;
+}
+
+static Json::Value DumpSourceFilesList(
+ cmGeneratorTarget* target, const std::string& config,
+ const std::map<std::string, LanguageData>& languageDataMap)
+{
+ // Collect sourcefile groups:
+
+ std::vector<cmSourceFile*> files;
+ target->GetSourceFiles(files, config);
+
+ std::unordered_map<LanguageData, std::vector<std::string>> fileGroups;
+ for (cmSourceFile* file : files) {
+ LanguageData fileData;
+ fileData.Language = file->GetOrDetermineLanguage();
+ if (!fileData.Language.empty()) {
+ const LanguageData& ld = languageDataMap.at(fileData.Language);
+ cmLocalGenerator* lg = target->GetLocalGenerator();
+ cmGeneratorExpressionInterpreter genexInterpreter(lg, config, target,
+ fileData.Language);
+
+ std::string compileFlags = ld.Flags;
+ const std::string COMPILE_FLAGS("COMPILE_FLAGS");
+ if (const char* cflags = file->GetProperty(COMPILE_FLAGS)) {
+ lg->AppendFlags(compileFlags,
+ genexInterpreter.Evaluate(cflags, COMPILE_FLAGS));
+ }
+ const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
+ if (const char* coptions = file->GetProperty(COMPILE_OPTIONS)) {
+ lg->AppendCompileOptions(
+ compileFlags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS));
+ }
+ fileData.Flags = compileFlags;
+
+ // Add include directories from source file properties.
+ std::vector<std::string> includes;
+
+ const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
+ if (const char* cincludes = file->GetProperty(INCLUDE_DIRECTORIES)) {
+ const std::string& evaluatedIncludes =
+ genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES);
+ lg->AppendIncludeDirectories(includes, evaluatedIncludes, *file);
+
+ for (const auto& include : includes) {
+ fileData.IncludePathList.emplace_back(
+ include,
+ target->IsSystemIncludeDirectory(include, config,
+ fileData.Language));
+ }
+ }
+
+ fileData.IncludePathList.insert(fileData.IncludePathList.end(),
+ ld.IncludePathList.begin(),
+ ld.IncludePathList.end());
+
+ const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
+ std::set<std::string> defines;
+ if (const char* defs = file->GetProperty(COMPILE_DEFINITIONS)) {
+ lg->AppendDefines(
+ defines, genexInterpreter.Evaluate(defs, COMPILE_DEFINITIONS));
+ }
+
+ const std::string defPropName =
+ "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config);
+ if (const char* config_defs = file->GetProperty(defPropName)) {
+ lg->AppendDefines(
+ defines,
+ genexInterpreter.Evaluate(config_defs, COMPILE_DEFINITIONS));
+ }
+
+ defines.insert(ld.Defines.begin(), ld.Defines.end());
+
+ fileData.SetDefines(defines);
+ }
+
+ fileData.IsGenerated = file->GetIsGenerated();
+ std::vector<std::string>& groupFileList = fileGroups[fileData];
+ groupFileList.push_back(file->ResolveFullPath());
+ }
+
+ const std::string& baseDir = target->Makefile->GetCurrentSourceDirectory();
+ Json::Value result = Json::arrayValue;
+ for (auto const& it : fileGroups) {
+ Json::Value group = DumpSourceFileGroup(it.first, it.second, baseDir);
+ if (!group.isNull()) {
+ result.append(group);
+ }
+ }
+
+ return result;
+}
+
+static Json::Value DumpCTestInfo(cmLocalGenerator* lg, cmTest* testInfo,
+ const std::string& config)
+{
+ Json::Value result = Json::objectValue;
+ result[kCTEST_NAME] = testInfo->GetName();
+
+ // Concat command entries together. After the first should be the arguments
+ // for the command
+ std::string command;
+ for (auto const& cmd : testInfo->GetCommand()) {
+ command.append(cmd);
+ command.append(" ");
+ }
+
+ // Remove any config specific variables from the output.
+ result[kCTEST_COMMAND] =
+ cmGeneratorExpression::Evaluate(command, lg, config);
+
+ // Build up the list of properties that may have been specified
+ Json::Value properties = Json::arrayValue;
+ for (auto& prop : testInfo->GetProperties().GetList()) {
+ Json::Value entry = Json::objectValue;
+ entry[kKEY_KEY] = prop.first;
+
+ // Remove config variables from the value too.
+ entry[kVALUE_KEY] =
+ cmGeneratorExpression::Evaluate(prop.second, lg, config);
+ properties.append(entry);
+ }
+ result[kPROPERTIES_KEY] = properties;
+
+ return result;
+}
+
+static void DumpMakefileTests(cmLocalGenerator* lg, const std::string& config,
+ Json::Value* result)
+{
+ auto mf = lg->GetMakefile();
+ std::vector<cmTest*> tests;
+ mf->GetTests(config, tests);
+ for (auto test : tests) {
+ Json::Value tmp = DumpCTestInfo(lg, test, config);
+ if (!tmp.isNull()) {
+ result->append(tmp);
+ }
+ }
+}
+
+static Json::Value DumpCTestProjectList(const cmake* cm,
+ std::string const& config)
+{
+ Json::Value result = Json::arrayValue;
+
+ auto globalGen = cm->GetGlobalGenerator();
+
+ for (const auto& projectIt : globalGen->GetProjectMap()) {
+ Json::Value pObj = Json::objectValue;
+ pObj[kNAME_KEY] = projectIt.first;
+
+ Json::Value tests = Json::arrayValue;
+
+ // Gather tests for every generator
+ for (const auto& lg : projectIt.second) {
+ // Make sure they're generated.
+ lg->GenerateTestFiles();
+ DumpMakefileTests(lg, config, &tests);
+ }
+
+ pObj[kCTEST_INFO] = tests;
+
+ result.append(pObj);
+ }
+
+ return result;
+}
+
+static Json::Value DumpCTestConfiguration(const cmake* cm,
+ const std::string& config)
+{
+ Json::Value result = Json::objectValue;
+ result[kNAME_KEY] = config;
+
+ result[kPROJECTS_KEY] = DumpCTestProjectList(cm, config);
+
+ return result;
+}
+
+static Json::Value DumpCTestConfigurationsList(const cmake* cm)
+{
+ Json::Value result = Json::arrayValue;
+
+ for (const std::string& c : getConfigurations(cm)) {
+ result.append(DumpCTestConfiguration(cm, c));
+ }
+
+ return result;
+}
+
+Json::Value cmDumpCTestInfo(const cmake* cm)
+{
+ Json::Value result = Json::objectValue;
+ result[kCONFIGURATIONS_KEY] = DumpCTestConfigurationsList(cm);
+ return result;
+}
+
+static Json::Value DumpTarget(cmGeneratorTarget* target,
+ const std::string& config)
+{
+ cmLocalGenerator* lg = target->GetLocalGenerator();
+
+ const cmStateEnums::TargetType type = target->GetType();
+ const std::string typeName = cmState::GetTargetTypeName(type);
+
+ Json::Value ttl = Json::arrayValue;
+ ttl.append("EXECUTABLE");
+ ttl.append("STATIC_LIBRARY");
+ ttl.append("SHARED_LIBRARY");
+ ttl.append("MODULE_LIBRARY");
+ ttl.append("OBJECT_LIBRARY");
+ ttl.append("UTILITY");
+ ttl.append("INTERFACE_LIBRARY");
+
+ if (!hasString(ttl, typeName) || target->IsImported()) {
+ return Json::Value();
+ }
+
+ Json::Value result = Json::objectValue;
+ result[kNAME_KEY] = target->GetName();
+ result[kIS_GENERATOR_PROVIDED_KEY] =
+ target->Target->GetIsGeneratorProvided();
+ result[kTYPE_KEY] = typeName;
+ result[kSOURCE_DIRECTORY_KEY] = lg->GetCurrentSourceDirectory();
+ result[kBUILD_DIRECTORY_KEY] = lg->GetCurrentBinaryDirectory();
+
+ if (type == cmStateEnums::INTERFACE_LIBRARY) {
+ return result;
+ }
+
+ result[kFULL_NAME_KEY] = target->GetFullName(config);
+
+ if (target->Target->GetHaveInstallRule()) {
+ result[kHAS_INSTALL_RULE] = true;
+
+ Json::Value installPaths = Json::arrayValue;
+ auto targetGenerators = target->Makefile->GetInstallGenerators();
+ for (auto installGenerator : targetGenerators) {
+ auto installTargetGenerator =
+ dynamic_cast<cmInstallTargetGenerator*>(installGenerator);
+ if (installTargetGenerator != nullptr &&
+ installTargetGenerator->GetTarget()->Target == target->Target) {
+ auto dest = installTargetGenerator->GetDestination(config);
+
+ std::string installPath;
+ if (!dest.empty() && cmSystemTools::FileIsFullPath(dest)) {
+ installPath = dest;
+ } else {
+ installPath = cmStrCat(
+ target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX"), '/',
+ dest);
+ }
+
+ installPaths.append(installPath);
+ }
+ }
+
+ result[kINSTALL_PATHS] = installPaths;
+ }
+
+ if (target->HaveWellDefinedOutputFiles()) {
+ Json::Value artifacts = Json::arrayValue;
+ artifacts.append(
+ target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact));
+ if (target->HasImportLibrary(config)) {
+ artifacts.append(
+ target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact));
+ }
+ if (target->IsDLLPlatform()) {
+ const cmGeneratorTarget::OutputInfo* output =
+ target->GetOutputInfo(config);
+ if (output && !output->PdbDir.empty()) {
+ artifacts.append(output->PdbDir + '/' + target->GetPDBName(config));
+ }
+ }
+ result[kARTIFACTS_KEY] = artifacts;
+
+ result[kLINKER_LANGUAGE_KEY] = target->GetLinkerLanguage(config);
+
+ std::string linkLibs;
+ std::string linkFlags;
+ std::string linkLanguageFlags;
+ std::string frameworkPath;
+ std::string linkPath;
+ cmLinkLineComputer linkLineComputer(lg,
+ lg->GetStateSnapshot().GetDirectory());
+ lg->GetTargetFlags(&linkLineComputer, config, linkLibs, linkLanguageFlags,
+ linkFlags, frameworkPath, linkPath, target);
+
+ linkLibs = cmTrimWhitespace(linkLibs);
+ linkFlags = cmTrimWhitespace(linkFlags);
+ linkLanguageFlags = cmTrimWhitespace(linkLanguageFlags);
+ frameworkPath = cmTrimWhitespace(frameworkPath);
+ linkPath = cmTrimWhitespace(linkPath);
+
+ if (!cmTrimWhitespace(linkLibs).empty()) {
+ result[kLINK_LIBRARIES_KEY] = linkLibs;
+ }
+ if (!cmTrimWhitespace(linkFlags).empty()) {
+ result[kLINK_FLAGS_KEY] = linkFlags;
+ }
+ if (!cmTrimWhitespace(linkLanguageFlags).empty()) {
+ result[kLINK_LANGUAGE_FLAGS_KEY] = linkLanguageFlags;
+ }
+ if (!frameworkPath.empty()) {
+ result[kFRAMEWORK_PATH_KEY] = frameworkPath;
+ }
+ if (!linkPath.empty()) {
+ result[kLINK_PATH_KEY] = linkPath;
+ }
+ const std::string sysroot =
+ lg->GetMakefile()->GetSafeDefinition("CMAKE_SYSROOT");
+ if (!sysroot.empty()) {
+ result[kSYSROOT_KEY] = sysroot;
+ }
+ }
+
+ std::set<std::string> languages;
+ target->GetLanguages(languages, config);
+ std::map<std::string, LanguageData> languageDataMap;
+
+ for (std::string const& lang : languages) {
+ LanguageData& ld = languageDataMap[lang];
+ ld.Language = lang;
+ lg->GetTargetCompileFlags(target, config, lang, ld.Flags);
+ std::set<std::string> defines;
+ lg->GetTargetDefines(target, config, lang, defines);
+ ld.SetDefines(defines);
+ std::vector<std::string> includePathList;
+ lg->GetIncludeDirectories(includePathList, target, lang, config);
+ for (std::string const& i : includePathList) {
+ ld.IncludePathList.emplace_back(
+ i, target->IsSystemIncludeDirectory(i, config, lang));
+ }
+ }
+
+ Json::Value sourceGroupsValue =
+ DumpSourceFilesList(target, config, languageDataMap);
+ if (!sourceGroupsValue.empty()) {
+ result[kFILE_GROUPS_KEY] = sourceGroupsValue;
+ }
+
+ return result;
+}
+
+static Json::Value DumpTargetsList(
+ const std::vector<cmLocalGenerator*>& generators, const std::string& config)
+{
+ Json::Value result = Json::arrayValue;
+
+ std::vector<cmGeneratorTarget*> targetList;
+ for (auto const& lgIt : generators) {
+ cmAppend(targetList, lgIt->GetGeneratorTargets());
+ }
+ std::sort(targetList.begin(), targetList.end());
+
+ for (cmGeneratorTarget* target : targetList) {
+ Json::Value tmp = DumpTarget(target, config);
+ if (!tmp.isNull()) {
+ result.append(tmp);
+ }
+ }
+
+ return result;
+}
+
+static Json::Value DumpProjectList(const cmake* cm, std::string const& config)
+{
+ Json::Value result = Json::arrayValue;
+
+ auto globalGen = cm->GetGlobalGenerator();
+
+ for (auto const& projectIt : globalGen->GetProjectMap()) {
+ Json::Value pObj = Json::objectValue;
+ pObj[kNAME_KEY] = projectIt.first;
+
+ // All Projects must have at least one local generator
+ assert(!projectIt.second.empty());
+ const cmLocalGenerator* lg = projectIt.second.at(0);
+
+ // Project structure information:
+ const cmMakefile* mf = lg->GetMakefile();
+ auto minVersion = mf->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
+ pObj[kMINIMUM_CMAKE_VERSION] = minVersion ? minVersion : "";
+ pObj[kSOURCE_DIRECTORY_KEY] = mf->GetCurrentSourceDirectory();
+ pObj[kBUILD_DIRECTORY_KEY] = mf->GetCurrentBinaryDirectory();
+ pObj[kTARGETS_KEY] = DumpTargetsList(projectIt.second, config);
+
+ // For a project-level install rule it might be defined in any of its
+ // associated generators.
+ bool hasInstallRule = false;
+ for (const auto generator : projectIt.second) {
+ for (const auto installGen :
+ generator->GetMakefile()->GetInstallGenerators()) {
+ if (!dynamic_cast<cmInstallSubdirectoryGenerator*>(installGen)) {
+ hasInstallRule = true;
+ break;
+ }
+ }
+
+ if (hasInstallRule) {
+ break;
+ }
+ }
+
+ pObj[kHAS_INSTALL_RULE] = hasInstallRule;
+
+ result.append(pObj);
+ }
+
+ return result;
+}
+
+static Json::Value DumpConfiguration(const cmake* cm,
+ const std::string& config)
+{
+ Json::Value result = Json::objectValue;
+ result[kNAME_KEY] = config;
+
+ result[kPROJECTS_KEY] = DumpProjectList(cm, config);
+
+ return result;
+}
+
+static Json::Value DumpConfigurationsList(const cmake* cm)
+{
+ Json::Value result = Json::arrayValue;
+
+ for (std::string const& c : getConfigurations(cm)) {
+ result.append(DumpConfiguration(cm, c));
+ }
+
+ return result;
+}
+
+Json::Value cmDumpCodeModel(const cmake* cm)
+{
+ Json::Value result = Json::objectValue;
+ result[kCONFIGURATIONS_KEY] = DumpConfigurationsList(cm);
+ return result;
+}
diff --git a/Source/cmJsonObjects.h b/Source/cmJsonObjects.h
new file mode 100644
index 000000000..64291cc06
--- /dev/null
+++ b/Source/cmJsonObjects.h
@@ -0,0 +1,27 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmJsonObjects_h
+#define cmJsonObjects_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+#include <vector>
+
+#include "cm_jsoncpp_value.h"
+
+class cmake;
+class cmGlobalGenerator;
+
+extern void cmGetCMakeInputs(const cmGlobalGenerator* gg,
+ const std::string& sourceDir,
+ const std::string& buildDir,
+ std::vector<std::string>* internalFiles,
+ std::vector<std::string>* explicitFiles,
+ std::vector<std::string>* tmpFiles);
+
+extern Json::Value cmDumpCodeModel(const cmake* cm);
+extern Json::Value cmDumpCTestInfo(const cmake* cm);
+extern Json::Value cmDumpCMakeInputs(const cmake* cm);
+
+#endif
diff --git a/Source/cmLDConfigLDConfigTool.cxx b/Source/cmLDConfigLDConfigTool.cxx
new file mode 100644
index 000000000..cce6178da
--- /dev/null
+++ b/Source/cmLDConfigLDConfigTool.cxx
@@ -0,0 +1,71 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmLDConfigLDConfigTool.h"
+
+#include <istream>
+#include <string>
+#include <vector>
+
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmMakefile.h"
+#include "cmRuntimeDependencyArchive.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmUVProcessChain.h"
+
+cmLDConfigLDConfigTool::cmLDConfigLDConfigTool(
+ cmRuntimeDependencyArchive* archive)
+ : cmLDConfigTool(archive)
+{
+}
+
+bool cmLDConfigLDConfigTool::GetLDConfigPaths(std::vector<std::string>& paths)
+{
+ std::string ldConfigPath =
+ this->Archive->GetMakefile()->GetSafeDefinition("CMAKE_LDCONFIG_COMMAND");
+ if (ldConfigPath.empty()) {
+ ldConfigPath = cmSystemTools::FindProgram(
+ "ldconfig", { "/sbin", "/usr/sbin", "/usr/local/sbin" });
+ if (ldConfigPath.empty()) {
+ this->Archive->SetError("Could not find ldconfig");
+ return false;
+ }
+ }
+
+ std::vector<std::string> ldConfigCommand = cmExpandedList(ldConfigPath);
+ ldConfigCommand.emplace_back("-v");
+ ldConfigCommand.emplace_back("-N"); // Don't rebuild the cache.
+ ldConfigCommand.emplace_back("-X"); // Don't update links.
+
+ cmUVProcessChainBuilder builder;
+ builder.SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT)
+ .AddCommand(ldConfigCommand);
+ auto process = builder.Start();
+ if (!process.Valid()) {
+ this->Archive->SetError("Failed to start ldconfig process");
+ return false;
+ }
+
+ std::string line;
+ static const cmsys::RegularExpression regex("^([^\t:]*):");
+ while (std::getline(*process.OutputStream(), line)) {
+ cmsys::RegularExpressionMatch match;
+ if (regex.find(line.c_str(), match)) {
+ paths.push_back(match.match(1));
+ }
+ }
+
+ if (!process.Wait()) {
+ this->Archive->SetError("Failed to wait on ldconfig process");
+ return false;
+ }
+ auto status = process.GetStatus();
+ if (!status[0] || status[0]->ExitStatus != 0) {
+ this->Archive->SetError("Failed to run ldconfig");
+ return false;
+ }
+
+ return true;
+}
diff --git a/Source/cmLDConfigLDConfigTool.h b/Source/cmLDConfigLDConfigTool.h
new file mode 100644
index 000000000..34bf6c61f
--- /dev/null
+++ b/Source/cmLDConfigLDConfigTool.h
@@ -0,0 +1,22 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmLDConfigLDConfigTool_h
+#define cmLDConfigLDConfigTool_h
+
+#include <string>
+#include <vector>
+
+#include "cmLDConfigTool.h"
+
+class cmRuntimeDependencyArchive;
+
+class cmLDConfigLDConfigTool : public cmLDConfigTool
+{
+public:
+ cmLDConfigLDConfigTool(cmRuntimeDependencyArchive* archive);
+
+ bool GetLDConfigPaths(std::vector<std::string>& paths) override;
+};
+
+#endif
diff --git a/Source/cmLDConfigTool.cxx b/Source/cmLDConfigTool.cxx
new file mode 100644
index 000000000..8d5d5630b
--- /dev/null
+++ b/Source/cmLDConfigTool.cxx
@@ -0,0 +1,9 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmLDConfigTool.h"
+
+cmLDConfigTool::cmLDConfigTool(cmRuntimeDependencyArchive* archive)
+ : Archive(archive)
+{
+}
diff --git a/Source/cmLDConfigTool.h b/Source/cmLDConfigTool.h
new file mode 100644
index 000000000..c816562d4
--- /dev/null
+++ b/Source/cmLDConfigTool.h
@@ -0,0 +1,24 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmLDConfigTool_h
+#define cmLDConfigTool_h
+
+#include <string>
+#include <vector>
+
+class cmRuntimeDependencyArchive;
+
+class cmLDConfigTool
+{
+public:
+ cmLDConfigTool(cmRuntimeDependencyArchive* archive);
+ virtual ~cmLDConfigTool() = default;
+
+ virtual bool GetLDConfigPaths(std::vector<std::string>& paths) = 0;
+
+protected:
+ cmRuntimeDependencyArchive* Archive;
+};
+
+#endif
diff --git a/Source/cmLinkDirectoriesCommand.cxx b/Source/cmLinkDirectoriesCommand.cxx
index 9b0c28817..29140462a 100644
--- a/Source/cmLinkDirectoriesCommand.cxx
+++ b/Source/cmLinkDirectoriesCommand.cxx
@@ -4,33 +4,53 @@
#include <sstream>
+#include "cmExecutionStatus.h"
+#include "cmGeneratorExpression.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-class cmExecutionStatus;
+static void AddLinkDir(cmMakefile& mf, std::string const& dir,
+ std::vector<std::string>& directories);
-// cmLinkDirectoriesCommand
-bool cmLinkDirectoriesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmLinkDirectoriesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
return true;
}
- for (std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i) {
- this->AddLinkDir(*i);
+ cmMakefile& mf = status.GetMakefile();
+ bool before = mf.IsOn("CMAKE_LINK_DIRECTORIES_BEFORE");
+
+ auto i = args.cbegin();
+ if ((*i) == "BEFORE") {
+ before = true;
+ ++i;
+ } else if ((*i) == "AFTER") {
+ before = false;
+ ++i;
+ }
+
+ std::vector<std::string> directories;
+ for (; i != args.cend(); ++i) {
+ AddLinkDir(mf, *i, directories);
}
+
+ mf.AddLinkDirectory(cmJoin(directories, ";"), before);
+
return true;
}
-void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
+static void AddLinkDir(cmMakefile& mf, std::string const& dir,
+ std::vector<std::string>& directories)
{
std::string unixPath = dir;
cmSystemTools::ConvertToUnixSlashes(unixPath);
- if (!cmSystemTools::FileIsFullPath(unixPath.c_str())) {
+ if (!cmSystemTools::FileIsFullPath(unixPath) &&
+ !cmGeneratorExpression::StartsWithGeneratorExpression(unixPath)) {
bool convertToAbsolute = false;
std::ostringstream e;
/* clang-format off */
@@ -38,17 +58,18 @@ void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
<< " " << unixPath << "\n"
<< "as a link directory.\n";
/* clang-format on */
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0015)) {
+ switch (mf.GetPolicyStatus(cmPolicies::CMP0015)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0015);
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
+ break;
case cmPolicies::OLD:
// OLD behavior does not convert
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0015);
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
CM_FALLTHROUGH;
case cmPolicies::NEW:
// NEW behavior converts
@@ -56,11 +77,8 @@ void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
break;
}
if (convertToAbsolute) {
- std::string tmp = this->Makefile->GetCurrentSourceDirectory();
- tmp += "/";
- tmp += unixPath;
- unixPath = tmp;
+ unixPath = cmStrCat(mf.GetCurrentSourceDirectory(), '/', unixPath);
}
}
- this->Makefile->AppendProperty("LINK_DIRECTORIES", unixPath.c_str());
+ directories.push_back(unixPath);
}
diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h
index b64e48d70..a7caa5c63 100644
--- a/Source/cmLinkDirectoriesCommand.h
+++ b/Source/cmLinkDirectoriesCommand.h
@@ -3,40 +3,14 @@
#ifndef cmLinkDirectoriesCommand_h
#define cmLinkDirectoriesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmLinkDirectoriesCommand
- * \brief Define a list of directories containing files to link.
- *
- * cmLinkDirectoriesCommand is used to specify a list
- * of directories containing files to link into executable(s).
- * Note that the command supports the use of CMake built-in variables
- * such as CMAKE_BINARY_DIR and CMAKE_SOURCE_DIR.
- */
-class cmLinkDirectoriesCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmLinkDirectoriesCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- void AddLinkDir(std::string const& dir);
-};
+bool cmLinkDirectoriesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmLinkItem.cxx b/Source/cmLinkItem.cxx
new file mode 100644
index 000000000..91eb18337
--- /dev/null
+++ b/Source/cmLinkItem.cxx
@@ -0,0 +1,64 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmLinkItem.h"
+
+#include <utility> // IWYU pragma: keep
+
+#include "cmGeneratorTarget.h"
+
+cmLinkItem::cmLinkItem() = default;
+
+cmLinkItem::cmLinkItem(std::string n, cmListFileBacktrace bt)
+ : String(std::move(n))
+ , Backtrace(std::move(bt))
+{
+}
+
+cmLinkItem::cmLinkItem(cmGeneratorTarget const* t, cmListFileBacktrace bt)
+ : Target(t)
+ , Backtrace(std::move(bt))
+{
+}
+
+std::string const& cmLinkItem::AsStr() const
+{
+ return this->Target ? this->Target->GetName() : this->String;
+}
+
+bool operator<(cmLinkItem const& l, cmLinkItem const& r)
+{
+ // Order among targets.
+ if (l.Target && r.Target) {
+ return l.Target < r.Target;
+ }
+ // Order targets before strings.
+ if (l.Target) {
+ return true;
+ }
+ if (r.Target) {
+ return false;
+ }
+ // Order among strings.
+ return l.String < r.String;
+}
+
+bool operator==(cmLinkItem const& l, cmLinkItem const& r)
+{
+ return l.Target == r.Target && l.String == r.String;
+}
+
+std::ostream& operator<<(std::ostream& os, cmLinkItem const& item)
+{
+ return os << item.AsStr();
+}
+
+cmLinkImplItem::cmLinkImplItem()
+ : cmLinkItem()
+{
+}
+
+cmLinkImplItem::cmLinkImplItem(cmLinkItem item, bool fromGenex)
+ : cmLinkItem(std::move(item))
+ , FromGenex(fromGenex)
+{
+}
diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h
index f0fded21f..2d9378bd5 100644
--- a/Source/cmLinkItem.h
+++ b/Source/cmLinkItem.h
@@ -3,13 +3,14 @@
#ifndef cmLinkItem_h
#define cmLinkItem_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include <algorithm>
#include <map>
+#include <ostream>
#include <string>
#include <vector>
+#include "cmAlgorithms.h"
#include "cmListFileCache.h"
#include "cmSystemTools.h"
#include "cmTargetLinkLibraryType.h"
@@ -17,42 +18,28 @@
class cmGeneratorTarget;
// Basic information about each link item.
-class cmLinkItem : public std::string
+class cmLinkItem
{
- typedef std::string std_string;
+ std::string String;
public:
- cmLinkItem()
- : std_string()
- , Target(CM_NULLPTR)
- {
- }
- cmLinkItem(const std_string& n, cmGeneratorTarget const* t)
- : std_string(n)
- , Target(t)
- {
- }
- cmGeneratorTarget const* Target;
+ cmLinkItem();
+ cmLinkItem(std::string s, cmListFileBacktrace bt);
+ cmLinkItem(cmGeneratorTarget const* t, cmListFileBacktrace bt);
+ std::string const& AsStr() const;
+ cmGeneratorTarget const* Target = nullptr;
+ cmListFileBacktrace Backtrace;
+ friend bool operator<(cmLinkItem const& l, cmLinkItem const& r);
+ friend bool operator==(cmLinkItem const& l, cmLinkItem const& r);
+ friend std::ostream& operator<<(std::ostream& os, cmLinkItem const& item);
};
class cmLinkImplItem : public cmLinkItem
{
public:
- cmLinkImplItem()
- : cmLinkItem()
- , Backtrace()
- , FromGenex(false)
- {
- }
- cmLinkImplItem(std::string const& n, cmGeneratorTarget const* t,
- cmListFileBacktrace const& bt, bool fromGenex)
- : cmLinkItem(n, t)
- , Backtrace(bt)
- , FromGenex(fromGenex)
- {
- }
- cmListFileBacktrace Backtrace;
- bool FromGenex;
+ cmLinkImplItem();
+ cmLinkImplItem(cmLinkItem item, bool fromGenex);
+ bool FromGenex = false;
};
/** The link implementation specifies the direct library
@@ -71,6 +58,9 @@ struct cmLinkInterfaceLibraries
{
// Libraries listed in the interface.
std::vector<cmLinkItem> Libraries;
+
+ // Whether the list depends on a genex referencing the head target.
+ bool HadHeadSensitiveCondition = false;
};
struct cmLinkInterface : public cmLinkInterfaceLibraries
@@ -83,36 +73,21 @@ struct cmLinkInterface : public cmLinkInterfaceLibraries
// Number of repetitions of a strongly connected component of two
// or more static libraries.
- unsigned int Multiplicity;
+ unsigned int Multiplicity = 0;
// Libraries listed for other configurations.
// Needed only for OLD behavior of CMP0003.
std::vector<cmLinkItem> WrongConfigLibraries;
- bool ImplementationIsInterface;
-
- cmLinkInterface()
- : Multiplicity(0)
- , ImplementationIsInterface(false)
- {
- }
+ bool ImplementationIsInterface = false;
};
struct cmOptionalLinkInterface : public cmLinkInterface
{
- cmOptionalLinkInterface()
- : LibrariesDone(false)
- , AllDone(false)
- , Exists(false)
- , HadHeadSensitiveCondition(false)
- , ExplicitLibraries(CM_NULLPTR)
- {
- }
- bool LibrariesDone;
- bool AllDone;
- bool Exists;
- bool HadHeadSensitiveCondition;
- const char* ExplicitLibraries;
+ bool LibrariesDone = false;
+ bool AllDone = false;
+ bool Exists = false;
+ bool Explicit = false;
};
struct cmHeadToLinkInterfaceMap
@@ -129,15 +104,9 @@ struct cmLinkImplementation : public cmLinkImplementationLibraries
// Cache link implementation computation from each configuration.
struct cmOptionalLinkImplementation : public cmLinkImplementation
{
- cmOptionalLinkImplementation()
- : LibrariesDone(false)
- , LanguagesDone(false)
- , HadHeadSensitiveCondition(false)
- {
- }
- bool LibrariesDone;
- bool LanguagesDone;
- bool HadHeadSensitiveCondition;
+ bool LibrariesDone = false;
+ bool LanguagesDone = false;
+ bool HadHeadSensitiveCondition = false;
};
/** Compute the link type to use for the given configuration. */
@@ -151,8 +120,7 @@ inline cmTargetLinkLibraryType CMP0003_ComputeLinkType(
// Check if any entry in the list matches this configuration.
std::string configUpper = cmSystemTools::UpperCase(config);
- if (std::find(debugConfigs.begin(), debugConfigs.end(), configUpper) !=
- debugConfigs.end()) {
+ if (cmContains(debugConfigs, configUpper)) {
return DEBUG_LibraryType;
}
// The current configuration is not a debug configuration.
diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx
index 708ec8c00..cb63ceb03 100644
--- a/Source/cmLinkLibrariesCommand.cxx
+++ b/Source/cmLinkLibrariesCommand.cxx
@@ -2,39 +2,37 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLinkLibrariesCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-class cmExecutionStatus;
-
-// cmLinkLibrariesCommand
-bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmLinkLibrariesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
return true;
}
- // add libraries, nothe that there is an optional prefix
+ cmMakefile& mf = status.GetMakefile();
+ // add libraries, note that there is an optional prefix
// of debug and optimized than can be used
- for (std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i) {
+ for (auto i = args.begin(); i != args.end(); ++i) {
if (*i == "debug") {
++i;
if (i == args.end()) {
- this->SetError("The \"debug\" argument must be followed by "
- "a library");
+ status.SetError("The \"debug\" argument must be followed by "
+ "a library");
return false;
}
- this->Makefile->AppendProperty("LINK_LIBRARIES", "debug");
+ mf.AppendProperty("LINK_LIBRARIES", "debug");
} else if (*i == "optimized") {
++i;
if (i == args.end()) {
- this->SetError("The \"optimized\" argument must be followed by "
- "a library");
+ status.SetError("The \"optimized\" argument must be followed by "
+ "a library");
return false;
}
- this->Makefile->AppendProperty("LINK_LIBRARIES", "optimized");
+ mf.AppendProperty("LINK_LIBRARIES", "optimized");
}
- this->Makefile->AppendProperty("LINK_LIBRARIES", i->c_str());
+ mf.AppendProperty("LINK_LIBRARIES", i->c_str());
}
return true;
diff --git a/Source/cmLinkLibrariesCommand.h b/Source/cmLinkLibrariesCommand.h
index f1b3a6816..34122513c 100644
--- a/Source/cmLinkLibrariesCommand.h
+++ b/Source/cmLinkLibrariesCommand.h
@@ -3,36 +3,14 @@
#ifndef cmLinkLibrariesCommand_h
#define cmLinkLibrariesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmLinkLibrariesCommand
- * \brief Specify a list of libraries to link into executables.
- *
- * cmLinkLibrariesCommand is used to specify a list of libraries to link
- * into executable(s) or shared objects. The names of the libraries
- * should be those defined by the LIBRARY(library) command(s).
- */
-class cmLinkLibrariesCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmLinkLibrariesCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmLinkLibrariesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx
index c0f702e25..0dc6236a0 100644
--- a/Source/cmLinkLineComputer.cxx
+++ b/Source/cmLinkLineComputer.cxx
@@ -4,13 +4,18 @@
#include "cmLinkLineComputer.h"
#include <sstream>
+#include <utility>
#include <vector>
#include "cmComputeLinkInformation.h"
#include "cmGeneratorTarget.h"
+#include "cmLinkItem.h"
+#include "cmListFileCache.h"
#include "cmOutputConverter.h"
#include "cmStateDirectory.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
cmLinkLineComputer::cmLinkLineComputer(cmOutputConverter* outputConverter,
cmStateDirectory const& stateDir)
@@ -22,9 +27,7 @@ cmLinkLineComputer::cmLinkLineComputer(cmOutputConverter* outputConverter,
{
}
-cmLinkLineComputer::~cmLinkLineComputer()
-{
-}
+cmLinkLineComputer::~cmLinkLineComputer() = default;
void cmLinkLineComputer::SetUseWatcomQuote(bool useWatcomQuote)
{
@@ -46,9 +49,8 @@ std::string cmLinkLineComputer::ConvertToLinkReference(
{
std::string relLib = lib;
- if (cmOutputConverter::ContainedInDirectory(
- this->StateDir.GetCurrentBinary(), lib, this->StateDir)) {
- relLib = cmOutputConverter::ForceToRelativePath(
+ if (this->StateDir.ContainsBoth(this->StateDir.GetCurrentBinary(), lib)) {
+ relLib = cmSystemTools::ForceToRelativePath(
this->StateDir.GetCurrentBinary(), lib);
}
return relLib;
@@ -57,23 +59,49 @@ std::string cmLinkLineComputer::ConvertToLinkReference(
std::string cmLinkLineComputer::ComputeLinkLibs(cmComputeLinkInformation& cli)
{
std::string linkLibs;
- typedef cmComputeLinkInformation::ItemVector ItemVector;
+ std::vector<BT<std::string>> linkLibsList;
+ this->ComputeLinkLibs(cli, linkLibsList);
+ cli.AppendValues(linkLibs, linkLibsList);
+ return linkLibs;
+}
+
+void cmLinkLineComputer::ComputeLinkLibs(
+ cmComputeLinkInformation& cli, std::vector<BT<std::string>>& linkLibraries)
+{
+ using ItemVector = cmComputeLinkInformation::ItemVector;
ItemVector const& items = cli.GetItems();
- for (ItemVector::const_iterator li = items.begin(); li != items.end();
- ++li) {
- if (li->Target &&
- li->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (auto const& item : items) {
+ if (item.Target &&
+ item.Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- if (li->IsPath) {
- linkLibs +=
- this->ConvertToOutputFormat(this->ConvertToLinkReference(li->Value));
+
+ BT<std::string> linkLib;
+ if (item.IsPath) {
+ linkLib.Value += cli.GetLibLinkFileFlag();
+ linkLib.Value +=
+ this->ConvertToOutputFormat(this->ConvertToLinkReference(item.Value));
} else {
- linkLibs += li->Value;
+ linkLib.Value += item.Value;
}
- linkLibs += " ";
+ linkLib.Value += " ";
+
+ const cmLinkImplementation* linkImpl =
+ cli.GetTarget()->GetLinkImplementation(cli.GetConfig());
+
+ for (const cmLinkImplItem& iter : linkImpl->Libraries) {
+ if (iter.Target != nullptr &&
+ iter.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ std::string libPath = iter.Target->GetLocation(cli.GetConfig());
+ if (item.Value == libPath) {
+ linkLib.Backtrace = iter.Backtrace;
+ break;
+ }
+ }
+ }
+
+ linkLibraries.emplace_back(linkLib);
}
- return linkLibs;
}
std::string cmLinkLineComputer::ConvertToOutputFormat(std::string const& input)
@@ -102,18 +130,51 @@ std::string cmLinkLineComputer::ComputeLinkPath(
std::string const& libPathTerminator)
{
std::string linkPath;
- std::vector<std::string> const& libDirs = cli.GetDirectories();
- for (std::vector<std::string>::const_iterator libDir = libDirs.begin();
- libDir != libDirs.end(); ++libDir) {
- std::string libpath = this->ConvertToOutputForExisting(*libDir);
- linkPath += " " + libPathFlag;
- linkPath += libpath;
- linkPath += libPathTerminator;
- linkPath += " ";
- }
+ std::vector<BT<std::string>> linkPathList;
+ this->ComputeLinkPath(cli, libPathFlag, libPathTerminator, linkPathList);
+ cli.AppendValues(linkPath, linkPathList);
return linkPath;
}
+void cmLinkLineComputer::ComputeLinkPath(
+ cmComputeLinkInformation& cli, std::string const& libPathFlag,
+ std::string const& libPathTerminator, std::vector<BT<std::string>>& linkPath)
+{
+ if (cli.GetLinkLanguage() == "Swift") {
+ std::string linkPathNoBT;
+
+ for (const cmComputeLinkInformation::Item& item : cli.GetItems()) {
+ const cmGeneratorTarget* target = item.Target;
+ if (!target) {
+ continue;
+ }
+
+ if (target->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ target->GetType() == cmStateEnums::SHARED_LIBRARY) {
+ cmStateEnums::ArtifactType type = cmStateEnums::RuntimeBinaryArtifact;
+ if (target->HasImportLibrary(cli.GetConfig())) {
+ type = cmStateEnums::ImportLibraryArtifact;
+ }
+
+ linkPathNoBT += cmStrCat(
+ " ", libPathFlag, item.Target->GetDirectory(cli.GetConfig(), type),
+ libPathTerminator, " ");
+ }
+ }
+
+ if (!linkPathNoBT.empty()) {
+ linkPath.emplace_back(std::move(linkPathNoBT));
+ }
+ }
+
+ for (BT<std::string> libDir : cli.GetDirectoriesWithBacktraces()) {
+ libDir.Value = cmStrCat(" ", libPathFlag,
+ this->ConvertToOutputForExisting(libDir.Value),
+ libPathTerminator, " ");
+ linkPath.emplace_back(libDir);
+ }
+}
+
std::string cmLinkLineComputer::ComputeRPath(cmComputeLinkInformation& cli)
{
std::string rpath;
@@ -123,10 +184,9 @@ std::string cmLinkLineComputer::ComputeRPath(cmComputeLinkInformation& cli)
std::vector<std::string> runtimeDirs;
cli.GetRPath(runtimeDirs, this->Relink);
- for (std::vector<std::string>::iterator ri = runtimeDirs.begin();
- ri != runtimeDirs.end(); ++ri) {
+ for (std::string const& rd : runtimeDirs) {
rpath += cli.GetRuntimeFlag();
- rpath += this->ConvertToOutputFormat(*ri);
+ rpath += this->ConvertToOutputFormat(rd);
rpath += " ";
}
} else {
@@ -150,10 +210,9 @@ std::string cmLinkLineComputer::ComputeFrameworkPath(
std::string frameworkPath;
if (!fwSearchFlag.empty()) {
std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths();
- for (std::vector<std::string>::const_iterator fdi = fwDirs.begin();
- fdi != fwDirs.end(); ++fdi) {
+ for (std::string const& fd : fwDirs) {
frameworkPath += fwSearchFlag;
- frameworkPath += this->ConvertToOutputFormat(*fdi);
+ frameworkPath += this->ConvertToOutputFormat(fd);
frameworkPath += " ";
}
}
@@ -163,13 +222,30 @@ std::string cmLinkLineComputer::ComputeFrameworkPath(
std::string cmLinkLineComputer::ComputeLinkLibraries(
cmComputeLinkInformation& cli, std::string const& stdLibString)
{
- std::ostringstream fout;
- fout << this->ComputeRPath(cli);
+ std::string linkLibraries;
+ std::vector<BT<std::string>> linkLibrariesList;
+ this->ComputeLinkLibraries(cli, stdLibString, linkLibrariesList);
+ cli.AppendValues(linkLibraries, linkLibrariesList);
+ return linkLibraries;
+}
+
+void cmLinkLineComputer::ComputeLinkLibraries(
+ cmComputeLinkInformation& cli, std::string const& stdLibString,
+ std::vector<BT<std::string>>& linkLibraries)
+{
+ std::ostringstream rpathOut;
+ rpathOut << this->ComputeRPath(cli);
+
+ std::string rpath = rpathOut.str();
+ if (!rpath.empty()) {
+ linkLibraries.emplace_back(std::move(rpath));
+ }
// Write the library flags to the build rule.
- fout << this->ComputeLinkLibs(cli);
+ this->ComputeLinkLibs(cli, linkLibraries);
// Add the linker runtime search path if any.
+ std::ostringstream fout;
std::string rpath_link = cli.GetRPathLinkString();
if (!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) {
fout << cli.GetRPathLinkFlag();
@@ -182,7 +258,10 @@ std::string cmLinkLineComputer::ComputeLinkLibraries(
fout << stdLibString << " ";
}
- return fout.str();
+ std::string remainingLibs = fout.str();
+ if (!remainingLibs.empty()) {
+ linkLibraries.emplace_back(remainingLibs);
+ }
}
std::string cmLinkLineComputer::GetLinkerLanguage(cmGeneratorTarget* target,
diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h
index d33e8d1ff..f426976a2 100644
--- a/Source/cmLinkLineComputer.h
+++ b/Source/cmLinkLineComputer.h
@@ -4,25 +4,29 @@
#ifndef cmLinkLineComputer_h
#define cmLinkLineComputer_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <vector>
#include "cmStateDirectory.h"
class cmComputeLinkInformation;
class cmGeneratorTarget;
class cmOutputConverter;
+template <typename T>
+class BT;
class cmLinkLineComputer
{
- CM_DISABLE_COPY(cmLinkLineComputer)
-
public:
cmLinkLineComputer(cmOutputConverter* outputConverter,
cmStateDirectory const& stateDir);
virtual ~cmLinkLineComputer();
+ cmLinkLineComputer(cmLinkLineComputer const&) = delete;
+ cmLinkLineComputer& operator=(cmLinkLineComputer const&) = delete;
+
void SetUseWatcomQuote(bool useWatcomQuote);
void SetForResponse(bool forResponse);
void SetRelink(bool relink);
@@ -33,17 +37,28 @@ public:
std::string const& libPathFlag,
std::string const& libPathTerminator);
+ void ComputeLinkPath(cmComputeLinkInformation& cli,
+ std::string const& libPathFlag,
+ std::string const& libPathTerminator,
+ std::vector<BT<std::string>>& linkPath);
+
std::string ComputeFrameworkPath(cmComputeLinkInformation& cli,
std::string const& fwSearchFlag);
- virtual std::string ComputeLinkLibraries(cmComputeLinkInformation& cli,
- std::string const& stdLibString);
+ std::string ComputeLinkLibraries(cmComputeLinkInformation& cli,
+ std::string const& stdLibString);
+
+ virtual void ComputeLinkLibraries(
+ cmComputeLinkInformation& cli, std::string const& stdLibString,
+ std::vector<BT<std::string>>& linkLibraries);
virtual std::string GetLinkerLanguage(cmGeneratorTarget* target,
std::string const& config);
protected:
std::string ComputeLinkLibs(cmComputeLinkInformation& cli);
+ void ComputeLinkLibs(cmComputeLinkInformation& cli,
+ std::vector<BT<std::string>>& linkLibraries);
std::string ComputeRPath(cmComputeLinkInformation& cli);
std::string ConvertToOutputFormat(std::string const& input);
diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx
index 942e9b92c..847334b20 100644
--- a/Source/cmLinkLineDeviceComputer.cxx
+++ b/Source/cmLinkLineDeviceComputer.cxx
@@ -4,13 +4,20 @@
#include "cmLinkLineDeviceComputer.h"
#include <set>
-#include <sstream>
-#include <vector>
+#include <utility>
+#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
#include "cmGeneratorTarget.h"
-#include "cmGlobalNinjaGenerator.h"
+#include "cmGlobalGenerator.h"
+#include "cmLinkItem.h"
+#include "cmListFileCache.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
+#include "cmStateDirectory.h"
+#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
class cmOutputConverter;
@@ -20,65 +27,132 @@ cmLinkLineDeviceComputer::cmLinkLineDeviceComputer(
{
}
-cmLinkLineDeviceComputer::~cmLinkLineDeviceComputer()
+cmLinkLineDeviceComputer::~cmLinkLineDeviceComputer() = default;
+
+static bool cmLinkItemValidForDevice(std::string const& item)
{
+ // Valid items are:
+ // * Non-flags (does not start in '-')
+ // * Specific flags --library, --library-path, -l, -L
+ // For example:
+ // * 'cublas_device' => pass-along
+ // * '--library pthread' => pass-along
+ // * '-lpthread' => pass-along
+ // * '-pthread' => drop
+ // * '-a' => drop
+ // * '-framework Name' (as one string) => drop
+ return (!cmHasLiteralPrefix(item, "-") || //
+ cmHasLiteralPrefix(item, "-l") || //
+ cmHasLiteralPrefix(item, "-L") || //
+ cmHasLiteralPrefix(item, "--library"));
}
-std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
- cmComputeLinkInformation& cli, std::string const& stdLibString)
+bool cmLinkLineDeviceComputer::ComputeRequiresDeviceLinking(
+ cmComputeLinkInformation& cli)
{
- // Write the library flags to the build rule.
- std::ostringstream fout;
- typedef cmComputeLinkInformation::ItemVector ItemVector;
+ // Determine if this item might requires device linking.
+ // For this we only consider targets
+ using ItemVector = cmComputeLinkInformation::ItemVector;
ItemVector const& items = cli.GetItems();
std::string config = cli.GetConfig();
- for (ItemVector::const_iterator li = items.begin(); li != items.end();
- ++li) {
- if (!li->Target) {
- continue;
+ for (auto const& item : items) {
+ if (item.Target &&
+ item.Target->GetType() == cmStateEnums::STATIC_LIBRARY) {
+ if ((!item.Target->GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS")) &&
+ item.Target->GetPropertyAsBool("CUDA_SEPARABLE_COMPILATION")) {
+ // this dependency requires us to device link it
+ return true;
+ }
}
+ }
+ return false;
+}
- bool skippable = false;
- switch (li->Target->GetType()) {
- case cmStateEnums::SHARED_LIBRARY:
- case cmStateEnums::MODULE_LIBRARY:
- case cmStateEnums::INTERFACE_LIBRARY:
- skippable = true;
- break;
- case cmStateEnums::STATIC_LIBRARY:
- // If a static library is resolving its device linking, it should
- // be removed for other device linking
- skippable =
- li->Target->GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS");
- break;
- default:
- break;
+void cmLinkLineDeviceComputer::ComputeLinkLibraries(
+ cmComputeLinkInformation& cli, std::string const& stdLibString,
+ std::vector<BT<std::string>>& linkLibraries)
+{
+ // Generate the unique set of link items when device linking.
+ // The nvcc device linker is designed so that each static library
+ // with device symbols only needs to be listed once as it doesn't
+ // care about link order.
+ std::set<std::string> emitted;
+ using ItemVector = cmComputeLinkInformation::ItemVector;
+ ItemVector const& items = cli.GetItems();
+ std::string config = cli.GetConfig();
+ bool skipItemAfterFramework = false;
+ // Note:
+ // Any modification of this algorithm should be reflected also in
+ // cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions
+ for (auto const& item : items) {
+ if (skipItemAfterFramework) {
+ skipItemAfterFramework = false;
+ continue;
}
- if (skippable) {
- continue;
+ if (item.Target) {
+ bool skip = false;
+ switch (item.Target->GetType()) {
+ case cmStateEnums::SHARED_LIBRARY:
+ case cmStateEnums::MODULE_LIBRARY:
+ case cmStateEnums::INTERFACE_LIBRARY:
+ skip = true;
+ break;
+ case cmStateEnums::STATIC_LIBRARY:
+ skip = item.Target->GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS");
+ break;
+ default:
+ break;
+ }
+ if (skip) {
+ continue;
+ }
}
- std::set<std::string> langs;
- li->Target->GetLanguages(langs, config);
- if (langs.count("CUDA") == 0) {
+ BT<std::string> linkLib;
+ if (item.IsPath) {
+ // nvcc understands absolute paths to libraries ending in '.a' or '.lib'.
+ // These should be passed to nvlink. Other extensions need to be left
+ // out because nvlink may not understand or need them. Even though it
+ // can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'.
+ if (cmHasLiteralSuffix(item.Value, ".a") ||
+ cmHasLiteralSuffix(item.Value, ".lib")) {
+ linkLib.Value += this->ConvertToOutputFormat(
+ this->ConvertToLinkReference(item.Value));
+ }
+ } else if (item.Value == "-framework") {
+ // This is the first part of '-framework Name' where the framework
+ // name is specified as a following item. Ignore both.
+ skipItemAfterFramework = true;
continue;
+ } else if (cmLinkItemValidForDevice(item.Value)) {
+ linkLib.Value += item.Value;
}
- if (li->IsPath) {
- fout << this->ConvertToOutputFormat(
- this->ConvertToLinkReference(li->Value));
- } else {
- fout << li->Value;
+ if (emitted.insert(linkLib.Value).second) {
+ linkLib.Value += " ";
+
+ const cmLinkImplementation* linkImpl =
+ cli.GetTarget()->GetLinkImplementation(cli.GetConfig());
+
+ for (const cmLinkImplItem& iter : linkImpl->Libraries) {
+ if (iter.Target != nullptr &&
+ iter.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ std::string libPath = iter.Target->GetLocation(cli.GetConfig());
+ if (item.Value == libPath) {
+ linkLib.Backtrace = iter.Backtrace;
+ break;
+ }
+ }
+ }
+
+ linkLibraries.emplace_back(linkLib);
}
- fout << " ";
}
if (!stdLibString.empty()) {
- fout << stdLibString << " ";
+ linkLibraries.emplace_back(cmStrCat(stdLibString, ' '));
}
-
- return fout.str();
}
std::string cmLinkLineDeviceComputer::GetLinkerLanguage(cmGeneratorTarget*,
@@ -87,16 +161,58 @@ std::string cmLinkLineDeviceComputer::GetLinkerLanguage(cmGeneratorTarget*,
return "CUDA";
}
-cmNinjaLinkLineDeviceComputer::cmNinjaLinkLineDeviceComputer(
- cmOutputConverter* outputConverter, cmStateDirectory const& stateDir,
- cmGlobalNinjaGenerator const* gg)
- : cmLinkLineDeviceComputer(outputConverter, stateDir)
- , GG(gg)
+bool requireDeviceLinking(cmGeneratorTarget& target, cmLocalGenerator& lg,
+ const std::string& config)
{
-}
+ if (!target.GetGlobalGenerator()->GetLanguageEnabled("CUDA")) {
+ return false;
+ }
-std::string cmNinjaLinkLineDeviceComputer::ConvertToLinkReference(
- std::string const& lib) const
-{
- return GG->ConvertToNinjaPath(lib);
+ if (target.GetType() == cmStateEnums::OBJECT_LIBRARY) {
+ return false;
+ }
+
+ if (!lg.GetMakefile()->IsOn("CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE")) {
+ return false;
+ }
+
+ if (const char* resolveDeviceSymbols =
+ target.GetProperty("CUDA_RESOLVE_DEVICE_SYMBOLS")) {
+ // If CUDA_RESOLVE_DEVICE_SYMBOLS has been explicitly set we need
+ // to honor the value no matter what it is.
+ return cmIsOn(resolveDeviceSymbols);
+ }
+
+ // Determine if we have any dependencies that require
+ // us to do a device link step
+ cmGeneratorTarget::LinkClosure const* closure =
+ target.GetLinkClosure(config);
+
+ if (cmContains(closure->Languages, "CUDA")) {
+ if (const char* separableCompilation =
+ target.GetProperty("CUDA_SEPARABLE_COMPILATION")) {
+ if (cmIsOn(separableCompilation)) {
+ bool doDeviceLinking = false;
+ switch (target.GetType()) {
+ case cmStateEnums::SHARED_LIBRARY:
+ case cmStateEnums::MODULE_LIBRARY:
+ case cmStateEnums::EXECUTABLE:
+ doDeviceLinking = true;
+ break;
+ default:
+ break;
+ }
+ return doDeviceLinking;
+ }
+ }
+
+ cmComputeLinkInformation* pcli = target.GetLinkInformation(config);
+ if (pcli) {
+ cmLinkLineDeviceComputer deviceLinkComputer(
+ &lg, lg.GetStateSnapshot().GetDirectory());
+ return deviceLinkComputer.ComputeRequiresDeviceLinking(*pcli);
+ }
+ return true;
+ }
+ return false;
}
diff --git a/Source/cmLinkLineDeviceComputer.h b/Source/cmLinkLineDeviceComputer.h
index c3fac6182..a9b01cd9c 100644
--- a/Source/cmLinkLineDeviceComputer.h
+++ b/Source/cmLinkLineDeviceComputer.h
@@ -4,49 +4,43 @@
#ifndef cmLinkLineDeviceComputer_h
#define cmLinkLineDeviceComputer_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <vector>
#include "cmLinkLineComputer.h"
class cmComputeLinkInformation;
class cmGeneratorTarget;
-class cmGlobalNinjaGenerator;
+class cmLocalGenerator;
class cmOutputConverter;
class cmStateDirectory;
+template <typename T>
+class BT;
class cmLinkLineDeviceComputer : public cmLinkLineComputer
{
- CM_DISABLE_COPY(cmLinkLineDeviceComputer)
-
public:
cmLinkLineDeviceComputer(cmOutputConverter* outputConverter,
cmStateDirectory const& stateDir);
- ~cmLinkLineDeviceComputer() CM_OVERRIDE;
+ ~cmLinkLineDeviceComputer() override;
- std::string ComputeLinkLibraries(cmComputeLinkInformation& cli,
- std::string const& stdLibString)
- CM_OVERRIDE;
+ cmLinkLineDeviceComputer(cmLinkLineDeviceComputer const&) = delete;
+ cmLinkLineDeviceComputer& operator=(cmLinkLineDeviceComputer const&) =
+ delete;
- std::string GetLinkerLanguage(cmGeneratorTarget* target,
- std::string const& config) CM_OVERRIDE;
-};
+ bool ComputeRequiresDeviceLinking(cmComputeLinkInformation& cli);
-class cmNinjaLinkLineDeviceComputer : public cmLinkLineDeviceComputer
-{
- CM_DISABLE_COPY(cmNinjaLinkLineDeviceComputer)
+ void ComputeLinkLibraries(
+ cmComputeLinkInformation& cli, std::string const& stdLibString,
+ std::vector<BT<std::string>>& linkLibraries) override;
-public:
- cmNinjaLinkLineDeviceComputer(cmOutputConverter* outputConverter,
- cmStateDirectory const& stateDir,
- cmGlobalNinjaGenerator const* gg);
-
- std::string ConvertToLinkReference(std::string const& input) const
- CM_OVERRIDE;
-
-private:
- cmGlobalNinjaGenerator const* GG;
+ std::string GetLinkerLanguage(cmGeneratorTarget* target,
+ std::string const& config) override;
};
+bool requireDeviceLinking(cmGeneratorTarget& target, cmLocalGenerator& lg,
+ const std::string& config);
+
#endif
diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h
index 55592cb35..c7453eac9 100644
--- a/Source/cmLinkedTree.h
+++ b/Source/cmLinkedTree.h
@@ -3,10 +3,9 @@
#ifndef cmLinkedTree_h
#define cmLinkedTree_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include <assert.h>
-#include <iterator>
+#include <cassert>
#include <vector>
/**
@@ -28,12 +27,12 @@
template <typename T>
class cmLinkedTree
{
- typedef typename std::vector<T>::size_type PositionType;
- typedef T* PointerType;
- typedef T& ReferenceType;
+ using PositionType = typename std::vector<T>::size_type;
+ using PointerType = T*;
+ using ReferenceType = T&;
public:
- class iterator : public std::iterator<std::forward_iterator_tag, T>
+ class iterator
{
friend class cmLinkedTree;
cmLinkedTree* Tree;
@@ -49,7 +48,7 @@ public:
public:
iterator()
- : Tree(CM_NULLPTR)
+ : Tree(nullptr)
, Position(0)
{
}
@@ -137,7 +136,7 @@ public:
iterator Push(iterator it) { return Push_impl(it, T()); }
- iterator Push(iterator it, T t) { return Push_impl(it, t); }
+ iterator Push(iterator it, T t) { return Push_impl(it, std::move(t)); }
bool IsLast(iterator it) { return it.Position == this->Data.size(); }
@@ -177,12 +176,12 @@ private:
T* GetPointer(PositionType pos) { return &this->Data[pos]; }
- iterator Push_impl(iterator it, T t)
+ iterator Push_impl(iterator it, T&& t)
{
assert(this->UpPositions.size() == this->Data.size());
assert(it.Position <= this->UpPositions.size());
this->UpPositions.push_back(it.Position);
- this->Data.push_back(t);
+ this->Data.push_back(std::move(t));
return iterator(this, this->UpPositions.size());
}
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index 0542c4fce..5200a160f 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -2,75 +2,49 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmListCommand.h"
-#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cstddef>
+#include <cstdio>
+#include <cstdlib> // required for atoi
+#include <functional>
#include <iterator>
+#include <set>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h> // required for atoi
+#include <stdexcept>
+#include <utility>
+#include <vector>
+
+#include <cm/memory>
+
+#include "cmsys/RegularExpression.hxx"
+
+#include "cm_static_string_view.hxx"
#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
+#include "cmGeneratorExpression.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
+#include "cmStringReplaceHelper.h"
+#include "cmSubcommandTable.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-class cmExecutionStatus;
+namespace {
-bool cmListCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
-{
- if (args.size() < 2) {
- this->SetError("must be called with at least two arguments.");
- return false;
- }
-
- const std::string& subCommand = args[0];
- if (subCommand == "LENGTH") {
- return this->HandleLengthCommand(args);
- }
- if (subCommand == "GET") {
- return this->HandleGetCommand(args);
- }
- if (subCommand == "APPEND") {
- return this->HandleAppendCommand(args);
- }
- if (subCommand == "FIND") {
- return this->HandleFindCommand(args);
- }
- if (subCommand == "INSERT") {
- return this->HandleInsertCommand(args);
- }
- if (subCommand == "REMOVE_AT") {
- return this->HandleRemoveAtCommand(args);
- }
- if (subCommand == "REMOVE_ITEM") {
- return this->HandleRemoveItemCommand(args);
- }
- if (subCommand == "REMOVE_DUPLICATES") {
- return this->HandleRemoveDuplicatesCommand(args);
- }
- if (subCommand == "SORT") {
- return this->HandleSortCommand(args);
- }
- if (subCommand == "REVERSE") {
- return this->HandleReverseCommand(args);
- }
- if (subCommand == "FILTER") {
- return this->HandleFilterCommand(args);
- }
+bool FilterRegex(std::vector<std::string> const& args, bool includeMatches,
+ std::string const& listName,
+ std::vector<std::string>& varArgsExpanded,
+ cmExecutionStatus& status);
- std::string e = "does not recognize sub-command " + subCommand;
- this->SetError(e);
- return false;
-}
-
-bool cmListCommand::GetListString(std::string& listString,
- const std::string& var)
+bool GetListString(std::string& listString, const std::string& var,
+ const cmMakefile& makefile)
{
// get the old value
- const char* cacheValue = this->Makefile->GetDefinition(var);
+ const char* cacheValue = makefile.GetDefinition(var);
if (!cacheValue) {
return false;
}
@@ -78,11 +52,11 @@ bool cmListCommand::GetListString(std::string& listString,
return true;
}
-bool cmListCommand::GetList(std::vector<std::string>& list,
- const std::string& var)
+bool GetList(std::vector<std::string>& list, const std::string& var,
+ const cmMakefile& makefile)
{
std::string listString;
- if (!this->GetListString(listString, var)) {
+ if (!GetListString(listString, var, makefile)) {
return false;
}
// if the size of the list
@@ -90,25 +64,24 @@ bool cmListCommand::GetList(std::vector<std::string>& list,
return true;
}
// expand the variable into a list
- cmSystemTools::ExpandListArgument(listString, list, true);
+ cmExpandList(listString, list, true);
// if no empty elements then just return
- if (std::find(list.begin(), list.end(), std::string()) == list.end()) {
+ if (!cmContains(list, std::string())) {
return true;
}
// if we have empty elements we need to check policy CMP0007
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0007)) {
+ switch (makefile.GetPolicyStatus(cmPolicies::CMP0007)) {
case cmPolicies::WARN: {
// Default is to warn and use old behavior
// OLD behavior is to allow compatibility, so recall
// ExpandListArgument without the true which will remove
// empty values
list.clear();
- cmSystemTools::ExpandListArgument(listString, list);
- std::string warn = cmPolicies::GetPolicyWarning(cmPolicies::CMP0007);
- warn += " List has value = [";
- warn += listString;
- warn += "].";
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, warn);
+ cmExpandList(listString, list);
+ std::string warn =
+ cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0007),
+ " List has value = [", listString, "].");
+ makefile.IssueMessage(MessageType::AUTHOR_WARNING, warn);
return true;
}
case cmPolicies::OLD:
@@ -116,60 +89,62 @@ bool cmListCommand::GetList(std::vector<std::string>& list,
// ExpandListArgument without the true which will remove
// empty values
list.clear();
- cmSystemTools::ExpandListArgument(listString, list);
+ cmExpandList(listString, list);
return true;
case cmPolicies::NEW:
return true;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ makefile.IssueMessage(
+ MessageType::FATAL_ERROR,
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0007));
return false;
}
return true;
}
-bool cmListCommand::HandleLengthCommand(std::vector<std::string> const& args)
+bool HandleLengthCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
- this->SetError("sub-command LENGTH requires two arguments.");
+ status.SetError("sub-command LENGTH requires two arguments.");
return false;
}
const std::string& listName = args[1];
- const std::string& variableName = args[args.size() - 1];
+ const std::string& variableName = args.back();
std::vector<std::string> varArgsExpanded;
// do not check the return value here
// if the list var is not found varArgsExpanded will have size 0
// and we will return 0
- this->GetList(varArgsExpanded, listName);
+ GetList(varArgsExpanded, listName, status.GetMakefile());
size_t length = varArgsExpanded.size();
char buffer[1024];
sprintf(buffer, "%d", static_cast<int>(length));
- this->Makefile->AddDefinition(variableName, buffer);
+ status.GetMakefile().AddDefinition(variableName, buffer);
return true;
}
-bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args)
+bool HandleGetCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 4) {
- this->SetError("sub-command GET requires at least three arguments.");
+ status.SetError("sub-command GET requires at least three arguments.");
return false;
}
const std::string& listName = args[1];
- const std::string& variableName = args[args.size() - 1];
+ const std::string& variableName = args.back();
// expand the variable
std::vector<std::string> varArgsExpanded;
- if (!this->GetList(varArgsExpanded, listName)) {
- this->Makefile->AddDefinition(variableName, "NOTFOUND");
+ if (!GetList(varArgsExpanded, listName, status.GetMakefile())) {
+ status.GetMakefile().AddDefinition(variableName, "NOTFOUND");
return true;
}
// FIXME: Add policy to make non-existing lists an error like empty lists.
if (varArgsExpanded.empty()) {
- this->SetError("GET given empty list");
+ status.SetError("GET given empty list");
return false;
}
@@ -182,23 +157,22 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args)
value += sep;
sep = ";";
if (item < 0) {
- item = (int)nitem + item;
+ item = static_cast<int>(nitem) + item;
}
- if (item < 0 || nitem <= (size_t)item) {
- std::ostringstream str;
- str << "index: " << item << " out of range (-" << nitem << ", "
- << nitem - 1 << ")";
- this->SetError(str.str());
+ if (item < 0 || nitem <= static_cast<size_t>(item)) {
+ status.SetError(cmStrCat("index: ", item, " out of range (-", nitem,
+ ", ", nitem - 1, ")"));
return false;
}
value += varArgsExpanded[item];
}
- this->Makefile->AddDefinition(variableName, value.c_str());
+ status.GetMakefile().AddDefinition(variableName, value);
return true;
}
-bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
+bool HandleAppendCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
assert(args.size() >= 2);
@@ -207,53 +181,180 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
return true;
}
- const std::string& listName = args[1];
+ cmMakefile& makefile = status.GetMakefile();
+ std::string const& listName = args[1];
// expand the variable
std::string listString;
- this->GetListString(listString, listName);
+ GetListString(listString, listName, makefile);
- if (!listString.empty() && !args.empty()) {
- listString += ";";
+ // If `listString` or `args` is empty, no need to append `;`,
+ // then index is going to be `1` and points to the end-of-string ";"
+ auto const offset =
+ std::string::size_type(listString.empty() || args.empty());
+ listString += &";"[offset] + cmJoin(cmMakeRange(args).advance(2), ";");
+
+ makefile.AddDefinition(listName, listString);
+ return true;
+}
+
+bool HandlePrependCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ assert(args.size() >= 2);
+
+ // Skip if nothing to prepend.
+ if (args.size() < 3) {
+ return true;
}
- listString += cmJoin(cmMakeRange(args).advance(2), ";");
- this->Makefile->AddDefinition(listName, listString.c_str());
+ cmMakefile& makefile = status.GetMakefile();
+ std::string const& listName = args[1];
+ // expand the variable
+ std::string listString;
+ GetListString(listString, listName, makefile);
+
+ // If `listString` or `args` is empty, no need to append `;`,
+ // then `offset` is going to be `1` and points to the end-of-string ";"
+ auto const offset =
+ std::string::size_type(listString.empty() || args.empty());
+ listString.insert(0,
+ cmJoin(cmMakeRange(args).advance(2), ";") + &";"[offset]);
+
+ makefile.AddDefinition(listName, listString);
return true;
}
-bool cmListCommand::HandleFindCommand(std::vector<std::string> const& args)
+bool HandlePopBackCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ assert(args.size() >= 2);
+
+ cmMakefile& makefile = status.GetMakefile();
+ auto ai = args.cbegin();
+ ++ai; // Skip subcommand name
+ std::string const& listName = *ai++;
+ std::vector<std::string> varArgsExpanded;
+ if (!GetList(varArgsExpanded, listName, makefile)) {
+ // Can't get the list definition... undefine any vars given after.
+ for (; ai != args.cend(); ++ai) {
+ makefile.RemoveDefinition(*ai);
+ }
+ return true;
+ }
+
+ if (!varArgsExpanded.empty()) {
+ if (ai == args.cend()) {
+ // No variables are given... Just remove one element.
+ varArgsExpanded.pop_back();
+ } else {
+ // Ok, assign elements to be removed to the given variables
+ for (; !varArgsExpanded.empty() && ai != args.cend(); ++ai) {
+ assert(!ai->empty());
+ makefile.AddDefinition(*ai, varArgsExpanded.back());
+ varArgsExpanded.pop_back();
+ }
+ // Undefine the rest variables if the list gets empty earlier...
+ for (; ai != args.cend(); ++ai) {
+ makefile.RemoveDefinition(*ai);
+ }
+ }
+
+ makefile.AddDefinition(listName, cmJoin(varArgsExpanded, ";"));
+
+ } else if (ai !=
+ args.cend()) { // The list is empty, but some args were given
+ // Need to *undefine* 'em all, cuz there are no items to assign...
+ for (; ai != args.cend(); ++ai) {
+ makefile.RemoveDefinition(*ai);
+ }
+ }
+
+ return true;
+}
+
+bool HandlePopFrontCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ assert(args.size() >= 2);
+
+ cmMakefile& makefile = status.GetMakefile();
+ auto ai = args.cbegin();
+ ++ai; // Skip subcommand name
+ std::string const& listName = *ai++;
+ std::vector<std::string> varArgsExpanded;
+ if (!GetList(varArgsExpanded, listName, makefile)) {
+ // Can't get the list definition... undefine any vars given after.
+ for (; ai != args.cend(); ++ai) {
+ makefile.RemoveDefinition(*ai);
+ }
+ return true;
+ }
+
+ if (!varArgsExpanded.empty()) {
+ if (ai == args.cend()) {
+ // No variables are given... Just remove one element.
+ varArgsExpanded.erase(varArgsExpanded.begin());
+ } else {
+ // Ok, assign elements to be removed to the given variables
+ auto vi = varArgsExpanded.begin();
+ for (; vi != varArgsExpanded.end() && ai != args.cend(); ++ai, ++vi) {
+ assert(!ai->empty());
+ makefile.AddDefinition(*ai, *vi);
+ }
+ varArgsExpanded.erase(varArgsExpanded.begin(), vi);
+ // Undefine the rest variables if the list gets empty earlier...
+ for (; ai != args.cend(); ++ai) {
+ makefile.RemoveDefinition(*ai);
+ }
+ }
+
+ makefile.AddDefinition(listName, cmJoin(varArgsExpanded, ";"));
+
+ } else if (ai !=
+ args.cend()) { // The list is empty, but some args were given
+ // Need to *undefine* 'em all, cuz there are no items to assign...
+ for (; ai != args.cend(); ++ai) {
+ makefile.RemoveDefinition(*ai);
+ }
+ }
+
+ return true;
+}
+
+bool HandleFindCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 4) {
- this->SetError("sub-command FIND requires three arguments.");
+ status.SetError("sub-command FIND requires three arguments.");
return false;
}
const std::string& listName = args[1];
- const std::string& variableName = args[args.size() - 1];
+ const std::string& variableName = args.back();
// expand the variable
std::vector<std::string> varArgsExpanded;
- if (!this->GetList(varArgsExpanded, listName)) {
- this->Makefile->AddDefinition(variableName, "-1");
+ if (!GetList(varArgsExpanded, listName, status.GetMakefile())) {
+ status.GetMakefile().AddDefinition(variableName, "-1");
return true;
}
- std::vector<std::string>::iterator it =
- std::find(varArgsExpanded.begin(), varArgsExpanded.end(), args[2]);
+ auto it = std::find(varArgsExpanded.begin(), varArgsExpanded.end(), args[2]);
if (it != varArgsExpanded.end()) {
- std::ostringstream indexStream;
- indexStream << std::distance(varArgsExpanded.begin(), it);
- this->Makefile->AddDefinition(variableName, indexStream.str().c_str());
+ status.GetMakefile().AddDefinition(
+ variableName,
+ std::to_string(std::distance(varArgsExpanded.begin(), it)));
return true;
}
- this->Makefile->AddDefinition(variableName, "-1");
+ status.GetMakefile().AddDefinition(variableName, "-1");
return true;
}
-bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
+bool HandleInsertCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 4) {
- this->SetError("sub-command INSERT requires at least three arguments.");
+ status.SetError("sub-command INSERT requires at least three arguments.");
return false;
}
@@ -262,26 +363,22 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
// expand the variable
int item = atoi(args[2].c_str());
std::vector<std::string> varArgsExpanded;
- if ((!this->GetList(varArgsExpanded, listName) || varArgsExpanded.empty()) &&
+ if ((!GetList(varArgsExpanded, listName, status.GetMakefile()) ||
+ varArgsExpanded.empty()) &&
item != 0) {
- std::ostringstream str;
- str << "index: " << item << " out of range (0, 0)";
- this->SetError(str.str());
+ status.SetError(cmStrCat("index: ", item, " out of range (0, 0)"));
return false;
}
if (!varArgsExpanded.empty()) {
size_t nitem = varArgsExpanded.size();
if (item < 0) {
- item = (int)nitem + item;
- }
- if (item < 0 || nitem <= (size_t)item) {
- std::ostringstream str;
- str << "index: " << item << " out of range (-" << varArgsExpanded.size()
- << ", "
- << (varArgsExpanded.empty() ? 0 : (varArgsExpanded.size() - 1))
- << ")";
- this->SetError(str.str());
+ item = static_cast<int>(nitem) + item;
+ }
+ if (item < 0 || nitem < static_cast<size_t>(item)) {
+ status.SetError(cmStrCat("index: ", item, " out of range (-",
+ varArgsExpanded.size(), ", ",
+ varArgsExpanded.size(), ")"));
return false;
}
}
@@ -290,130 +387,928 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
args.end());
std::string value = cmJoin(varArgsExpanded, ";");
- this->Makefile->AddDefinition(listName, value.c_str());
+ status.GetMakefile().AddDefinition(listName, value);
return true;
}
-bool cmListCommand::HandleRemoveItemCommand(
- std::vector<std::string> const& args)
+bool HandleJoinCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- if (args.size() < 3) {
- this->SetError("sub-command REMOVE_ITEM requires two or more arguments.");
+ if (args.size() != 4) {
+ status.SetError(cmStrCat("sub-command JOIN requires three arguments (",
+ args.size() - 1, " found)."));
return false;
}
const std::string& listName = args[1];
+ const std::string& glue = args[2];
+ const std::string& variableName = args[3];
+
// expand the variable
std::vector<std::string> varArgsExpanded;
- if (!this->GetList(varArgsExpanded, listName)) {
- this->SetError("sub-command REMOVE_ITEM requires list to be present.");
+ if (!GetList(varArgsExpanded, listName, status.GetMakefile())) {
+ status.GetMakefile().AddDefinition(variableName, "");
+ return true;
+ }
+
+ std::string value =
+ cmJoin(cmMakeRange(varArgsExpanded.begin(), varArgsExpanded.end()), glue);
+
+ status.GetMakefile().AddDefinition(variableName, value);
+ return true;
+}
+
+bool HandleRemoveItemCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() < 3) {
+ status.SetError("sub-command REMOVE_ITEM requires two or more arguments.");
return false;
}
+ const std::string& listName = args[1];
+ // expand the variable
+ std::vector<std::string> varArgsExpanded;
+ if (!GetList(varArgsExpanded, listName, status.GetMakefile())) {
+ return true;
+ }
+
std::vector<std::string> remove(args.begin() + 2, args.end());
std::sort(remove.begin(), remove.end());
- std::vector<std::string>::const_iterator remEnd =
- std::unique(remove.begin(), remove.end());
- std::vector<std::string>::const_iterator remBegin = remove.begin();
+ auto remEnd = std::unique(remove.begin(), remove.end());
+ auto remBegin = remove.begin();
- std::vector<std::string>::const_iterator argsEnd =
+ auto argsEnd =
cmRemoveMatching(varArgsExpanded, cmMakeRange(remBegin, remEnd));
- std::vector<std::string>::const_iterator argsBegin = varArgsExpanded.begin();
+ auto argsBegin = varArgsExpanded.cbegin();
std::string value = cmJoin(cmMakeRange(argsBegin, argsEnd), ";");
- this->Makefile->AddDefinition(listName, value.c_str());
+ status.GetMakefile().AddDefinition(listName, value);
return true;
}
-bool cmListCommand::HandleReverseCommand(std::vector<std::string> const& args)
+bool HandleReverseCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
assert(args.size() >= 2);
if (args.size() > 2) {
- this->SetError("sub-command REVERSE only takes one argument.");
+ status.SetError("sub-command REVERSE only takes one argument.");
return false;
}
const std::string& listName = args[1];
// expand the variable
std::vector<std::string> varArgsExpanded;
- if (!this->GetList(varArgsExpanded, listName)) {
- this->SetError("sub-command REVERSE requires list to be present.");
- return false;
+ if (!GetList(varArgsExpanded, listName, status.GetMakefile())) {
+ return true;
}
std::string value = cmJoin(cmReverseRange(varArgsExpanded), ";");
- this->Makefile->AddDefinition(listName, value.c_str());
+ status.GetMakefile().AddDefinition(listName, value);
return true;
}
-bool cmListCommand::HandleRemoveDuplicatesCommand(
- std::vector<std::string> const& args)
+bool HandleRemoveDuplicatesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
assert(args.size() >= 2);
if (args.size() > 2) {
- this->SetError("sub-command REMOVE_DUPLICATES only takes one argument.");
+ status.SetError("sub-command REMOVE_DUPLICATES only takes one argument.");
return false;
}
const std::string& listName = args[1];
// expand the variable
std::vector<std::string> varArgsExpanded;
- if (!this->GetList(varArgsExpanded, listName)) {
- this->SetError(
- "sub-command REMOVE_DUPLICATES requires list to be present.");
- return false;
+ if (!GetList(varArgsExpanded, listName, status.GetMakefile())) {
+ return true;
}
- std::vector<std::string>::const_iterator argsEnd =
- cmRemoveDuplicates(varArgsExpanded);
- std::vector<std::string>::const_iterator argsBegin = varArgsExpanded.begin();
+ auto argsEnd = cmRemoveDuplicates(varArgsExpanded);
+ auto argsBegin = varArgsExpanded.cbegin();
std::string value = cmJoin(cmMakeRange(argsBegin, argsEnd), ";");
- this->Makefile->AddDefinition(listName, value.c_str());
+ status.GetMakefile().AddDefinition(listName, value);
return true;
}
-bool cmListCommand::HandleSortCommand(std::vector<std::string> const& args)
+// Helpers for list(TRANSFORM <list> ...)
+using transform_type = std::function<std::string(const std::string&)>;
+
+class transform_error : public std::runtime_error
+{
+public:
+ transform_error(const std::string& error)
+ : std::runtime_error(error)
+ {
+ }
+};
+
+class TransformSelector
+{
+public:
+ virtual ~TransformSelector() = default;
+
+ std::string Tag;
+
+ virtual bool Validate(std::size_t count = 0) = 0;
+
+ virtual bool InSelection(const std::string&) = 0;
+
+ virtual void Transform(std::vector<std::string>& list,
+ const transform_type& transform)
+ {
+ std::transform(list.begin(), list.end(), list.begin(), transform);
+ }
+
+protected:
+ TransformSelector(std::string&& tag)
+ : Tag(std::move(tag))
+ {
+ }
+};
+class TransformNoSelector : public TransformSelector
+{
+public:
+ TransformNoSelector()
+ : TransformSelector("NO SELECTOR")
+ {
+ }
+
+ bool Validate(std::size_t) override { return true; }
+
+ bool InSelection(const std::string&) override { return true; }
+};
+class TransformSelectorRegex : public TransformSelector
+{
+public:
+ TransformSelectorRegex(const std::string& regex)
+ : TransformSelector("REGEX")
+ , Regex(regex)
+ {
+ }
+
+ bool Validate(std::size_t) override { return this->Regex.is_valid(); }
+
+ bool InSelection(const std::string& value) override
+ {
+ return this->Regex.find(value);
+ }
+
+ cmsys::RegularExpression Regex;
+};
+class TransformSelectorIndexes : public TransformSelector
+{
+public:
+ std::vector<int> Indexes;
+
+ bool InSelection(const std::string&) override { return true; }
+
+ void Transform(std::vector<std::string>& list,
+ const transform_type& transform) override
+ {
+ this->Validate(list.size());
+
+ for (auto index : this->Indexes) {
+ list[index] = transform(list[index]);
+ }
+ }
+
+protected:
+ TransformSelectorIndexes(std::string&& tag)
+ : TransformSelector(std::move(tag))
+ {
+ }
+ TransformSelectorIndexes(std::string&& tag, std::vector<int>&& indexes)
+ : TransformSelector(std::move(tag))
+ , Indexes(indexes)
+ {
+ }
+
+ int NormalizeIndex(int index, std::size_t count)
+ {
+ if (index < 0) {
+ index = static_cast<int>(count) + index;
+ }
+ if (index < 0 || count <= static_cast<std::size_t>(index)) {
+ throw transform_error(cmStrCat(
+ "sub-command TRANSFORM, selector ", this->Tag, ", index: ", index,
+ " out of range (-", count, ", ", count - 1, ")."));
+ }
+ return index;
+ }
+};
+class TransformSelectorAt : public TransformSelectorIndexes
+{
+public:
+ TransformSelectorAt(std::vector<int>&& indexes)
+ : TransformSelectorIndexes("AT", std::move(indexes))
+ {
+ }
+
+ bool Validate(std::size_t count) override
+ {
+ decltype(Indexes) indexes;
+
+ for (auto index : Indexes) {
+ indexes.push_back(this->NormalizeIndex(index, count));
+ }
+ this->Indexes = std::move(indexes);
+
+ return true;
+ }
+};
+class TransformSelectorFor : public TransformSelectorIndexes
+{
+public:
+ TransformSelectorFor(int start, int stop, int step)
+ : TransformSelectorIndexes("FOR")
+ , Start(start)
+ , Stop(stop)
+ , Step(step)
+ {
+ }
+
+ bool Validate(std::size_t count) override
+ {
+ this->Start = this->NormalizeIndex(this->Start, count);
+ this->Stop = this->NormalizeIndex(this->Stop, count);
+
+ // compute indexes
+ auto size = (this->Stop - this->Start + 1) / this->Step;
+ if ((this->Stop - this->Start + 1) % this->Step != 0) {
+ size += 1;
+ }
+
+ this->Indexes.resize(size);
+ auto start = this->Start;
+ auto step = this->Step;
+ std::generate(this->Indexes.begin(), this->Indexes.end(),
+ [&start, step]() -> int {
+ auto r = start;
+ start += step;
+ return r;
+ });
+
+ return true;
+ }
+
+private:
+ int Start, Stop, Step;
+};
+
+class TransformAction
+{
+public:
+ virtual ~TransformAction() = default;
+
+ virtual std::string Transform(const std::string& input) = 0;
+};
+class TransformReplace : public TransformAction
+{
+public:
+ TransformReplace(const std::vector<std::string>& arguments,
+ cmMakefile* makefile)
+ : ReplaceHelper(arguments[0], arguments[1], makefile)
+ {
+ makefile->ClearMatches();
+
+ if (!this->ReplaceHelper.IsRegularExpressionValid()) {
+ throw transform_error(
+ cmStrCat("sub-command TRANSFORM, action REPLACE: Failed to compile "
+ "regex \"",
+ arguments[0], "\"."));
+ }
+ if (!this->ReplaceHelper.IsReplaceExpressionValid()) {
+ throw transform_error(cmStrCat("sub-command TRANSFORM, action REPLACE: ",
+ this->ReplaceHelper.GetError(), "."));
+ }
+ }
+
+ std::string Transform(const std::string& input) override
+ {
+ // Scan through the input for all matches.
+ std::string output;
+
+ if (!this->ReplaceHelper.Replace(input, output)) {
+ throw transform_error(cmStrCat("sub-command TRANSFORM, action REPLACE: ",
+ this->ReplaceHelper.GetError(), "."));
+ }
+
+ return output;
+ }
+
+private:
+ cmStringReplaceHelper ReplaceHelper;
+};
+
+bool HandleTransformCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() < 3) {
+ status.SetError(
+ "sub-command TRANSFORM requires an action to be specified.");
+ return false;
+ }
+
+ // Structure collecting all elements of the command
+ struct Command
+ {
+ Command(const std::string& listName)
+ : ListName(listName)
+ , OutputName(listName)
+ {
+ }
+
+ std::string Name;
+ std::string ListName;
+ std::vector<std::string> Arguments;
+ std::unique_ptr<TransformAction> Action;
+ std::unique_ptr<TransformSelector> Selector;
+ std::string OutputName;
+ } command(args[1]);
+
+ // Descriptor of action
+ // Arity: number of arguments required for the action
+ // Transform: lambda function implementing the action
+ struct ActionDescriptor
+ {
+ ActionDescriptor(std::string name)
+ : Name(std::move(name))
+ {
+ }
+ ActionDescriptor(std::string name, int arity, transform_type transform)
+ : Name(std::move(name))
+ , Arity(arity)
+#if defined(__GNUC__) && __GNUC__ == 6 && defined(__aarch64__)
+ // std::function move constructor miscompiles on this architecture
+ , Transform(transform)
+#else
+ , Transform(std::move(transform))
+#endif
+ {
+ }
+
+ operator const std::string&() const { return Name; }
+
+ std::string Name;
+ int Arity = 0;
+ transform_type Transform;
+ };
+
+ // Build a set of supported actions.
+ std::set<ActionDescriptor,
+ std::function<bool(const std::string&, const std::string&)>>
+ descriptors(
+ [](const std::string& x, const std::string& y) { return x < y; });
+ descriptors = { { "APPEND", 1,
+ [&command](const std::string& s) -> std::string {
+ if (command.Selector->InSelection(s)) {
+ return s + command.Arguments[0];
+ }
+
+ return s;
+ } },
+ { "PREPEND", 1,
+ [&command](const std::string& s) -> std::string {
+ if (command.Selector->InSelection(s)) {
+ return command.Arguments[0] + s;
+ }
+
+ return s;
+ } },
+ { "TOUPPER", 0,
+ [&command](const std::string& s) -> std::string {
+ if (command.Selector->InSelection(s)) {
+ return cmSystemTools::UpperCase(s);
+ }
+
+ return s;
+ } },
+ { "TOLOWER", 0,
+ [&command](const std::string& s) -> std::string {
+ if (command.Selector->InSelection(s)) {
+ return cmSystemTools::LowerCase(s);
+ }
+
+ return s;
+ } },
+ { "STRIP", 0,
+ [&command](const std::string& s) -> std::string {
+ if (command.Selector->InSelection(s)) {
+ return cmTrimWhitespace(s);
+ }
+
+ return s;
+ } },
+ { "GENEX_STRIP", 0,
+ [&command](const std::string& s) -> std::string {
+ if (command.Selector->InSelection(s)) {
+ return cmGeneratorExpression::Preprocess(
+ s,
+ cmGeneratorExpression::StripAllGeneratorExpressions);
+ }
+
+ return s;
+ } },
+ { "REPLACE", 2,
+ [&command](const std::string& s) -> std::string {
+ if (command.Selector->InSelection(s)) {
+ return command.Action->Transform(s);
+ }
+
+ return s;
+ } } };
+
+ using size_type = std::vector<std::string>::size_type;
+ size_type index = 2;
+
+ // Parse all possible function parameters
+ auto descriptor = descriptors.find(args[index]);
+
+ if (descriptor == descriptors.end()) {
+ status.SetError(
+ cmStrCat(" sub-command TRANSFORM, ", args[index], " invalid action."));
+ return false;
+ }
+
+ // Action arguments
+ index += 1;
+ if (args.size() < index + descriptor->Arity) {
+ status.SetError(cmStrCat("sub-command TRANSFORM, action ",
+ descriptor->Name, " expects ", descriptor->Arity,
+ " argument(s)."));
+ return false;
+ }
+
+ command.Name = descriptor->Name;
+ index += descriptor->Arity;
+ if (descriptor->Arity > 0) {
+ command.Arguments =
+ std::vector<std::string>(args.begin() + 3, args.begin() + index);
+ }
+
+ if (command.Name == "REPLACE") {
+ try {
+ command.Action = cm::make_unique<TransformReplace>(
+ command.Arguments, &status.GetMakefile());
+ } catch (const transform_error& e) {
+ status.SetError(e.what());
+ return false;
+ }
+ }
+
+ const std::string REGEX{ "REGEX" };
+ const std::string AT{ "AT" };
+ const std::string FOR{ "FOR" };
+ const std::string OUTPUT_VARIABLE{ "OUTPUT_VARIABLE" };
+
+ // handle optional arguments
+ while (args.size() > index) {
+ if ((args[index] == REGEX || args[index] == AT || args[index] == FOR) &&
+ command.Selector) {
+ status.SetError(
+ cmStrCat("sub-command TRANSFORM, selector already specified (",
+ command.Selector->Tag, ")."));
+
+ return false;
+ }
+
+ // REGEX selector
+ if (args[index] == REGEX) {
+ if (args.size() == ++index) {
+ status.SetError("sub-command TRANSFORM, selector REGEX expects "
+ "'regular expression' argument.");
+ return false;
+ }
+
+ command.Selector = cm::make_unique<TransformSelectorRegex>(args[index]);
+ if (!command.Selector->Validate()) {
+ status.SetError(
+ cmStrCat("sub-command TRANSFORM, selector REGEX failed to compile "
+ "regex \"",
+ args[index], "\"."));
+ return false;
+ }
+
+ index += 1;
+ continue;
+ }
+
+ // AT selector
+ if (args[index] == AT) {
+ // get all specified indexes
+ std::vector<int> indexes;
+ while (args.size() > ++index) {
+ std::size_t pos;
+ int value;
+
+ try {
+ value = std::stoi(args[index], &pos);
+ if (pos != args[index].length()) {
+ // this is not a number, stop processing
+ break;
+ }
+ indexes.push_back(value);
+ } catch (const std::invalid_argument&) {
+ // this is not a number, stop processing
+ break;
+ }
+ }
+
+ if (indexes.empty()) {
+ status.SetError(
+ "sub-command TRANSFORM, selector AT expects at least one "
+ "numeric value.");
+ return false;
+ }
+
+ command.Selector =
+ cm::make_unique<TransformSelectorAt>(std::move(indexes));
+
+ continue;
+ }
+
+ // FOR selector
+ if (args[index] == FOR) {
+ if (args.size() <= ++index + 1) {
+ status.SetError(
+ "sub-command TRANSFORM, selector FOR expects, at least,"
+ " two arguments.");
+ return false;
+ }
+
+ int start = 0;
+ int stop = 0;
+ int step = 1;
+ bool valid = true;
+ try {
+ std::size_t pos;
+
+ start = std::stoi(args[index], &pos);
+ if (pos != args[index].length()) {
+ // this is not a number
+ valid = false;
+ } else {
+ stop = std::stoi(args[++index], &pos);
+ if (pos != args[index].length()) {
+ // this is not a number
+ valid = false;
+ }
+ }
+ } catch (const std::invalid_argument&) {
+ // this is not numbers
+ valid = false;
+ }
+ if (!valid) {
+ status.SetError("sub-command TRANSFORM, selector FOR expects, "
+ "at least, two numeric values.");
+ return false;
+ }
+ // try to read a third numeric value for step
+ if (args.size() > ++index) {
+ try {
+ std::size_t pos;
+
+ step = std::stoi(args[index], &pos);
+ if (pos != args[index].length()) {
+ // this is not a number
+ step = 1;
+ } else {
+ index += 1;
+ }
+ } catch (const std::invalid_argument&) {
+ // this is not number, ignore exception
+ }
+ }
+
+ if (step < 0) {
+ status.SetError("sub-command TRANSFORM, selector FOR expects "
+ "non negative numeric value for <step>.");
+ }
+
+ command.Selector =
+ cm::make_unique<TransformSelectorFor>(start, stop, step);
+
+ continue;
+ }
+
+ // output variable
+ if (args[index] == OUTPUT_VARIABLE) {
+ if (args.size() == ++index) {
+ status.SetError("sub-command TRANSFORM, OUTPUT_VARIABLE "
+ "expects variable name argument.");
+ return false;
+ }
+
+ command.OutputName = args[index++];
+ continue;
+ }
+
+ status.SetError(cmStrCat("sub-command TRANSFORM, '",
+ cmJoin(cmMakeRange(args).advance(index), " "),
+ "': unexpected argument(s)."));
+ return false;
+ }
+
+ // expand the list variable
+ std::vector<std::string> varArgsExpanded;
+ if (!GetList(varArgsExpanded, command.ListName, status.GetMakefile())) {
+ status.GetMakefile().AddDefinition(command.OutputName, "");
+ return true;
+ }
+
+ if (!command.Selector) {
+ // no selector specified, apply transformation to all elements
+ command.Selector = cm::make_unique<TransformNoSelector>();
+ }
+
+ try {
+ command.Selector->Transform(varArgsExpanded, descriptor->Transform);
+ } catch (const transform_error& e) {
+ status.SetError(e.what());
+ return false;
+ }
+
+ status.GetMakefile().AddDefinition(command.OutputName,
+ cmJoin(varArgsExpanded, ";"));
+
+ return true;
+}
+
+class cmStringSorter
+{
+public:
+ enum class Order
+ {
+ UNINITIALIZED,
+ ASCENDING,
+ DESCENDING,
+ };
+
+ enum class Compare
+ {
+ UNINITIALIZED,
+ STRING,
+ FILE_BASENAME,
+ };
+ enum class CaseSensitivity
+ {
+ UNINITIALIZED,
+ SENSITIVE,
+ INSENSITIVE,
+ };
+
+protected:
+ using StringFilter = std::string (*)(const std::string&);
+ StringFilter GetCompareFilter(Compare compare)
+ {
+ return (compare == Compare::FILE_BASENAME) ? cmSystemTools::GetFilenameName
+ : nullptr;
+ }
+
+ StringFilter GetCaseFilter(CaseSensitivity sensitivity)
+ {
+ return (sensitivity == CaseSensitivity::INSENSITIVE)
+ ? cmSystemTools::LowerCase
+ : nullptr;
+ }
+
+public:
+ cmStringSorter(Compare compare, CaseSensitivity caseSensitivity,
+ Order desc = Order::ASCENDING)
+ : filters{ GetCompareFilter(compare), GetCaseFilter(caseSensitivity) }
+ , descending(desc == Order::DESCENDING)
+ {
+ }
+
+ std::string ApplyFilter(const std::string& argument)
+ {
+ std::string result = argument;
+ for (auto filter : filters) {
+ if (filter != nullptr) {
+ result = filter(result);
+ }
+ }
+ return result;
+ }
+
+ bool operator()(const std::string& a, const std::string& b)
+ {
+ std::string af = ApplyFilter(a);
+ std::string bf = ApplyFilter(b);
+ bool result;
+ if (descending) {
+ result = bf < af;
+ } else {
+ result = af < bf;
+ }
+ return result;
+ }
+
+protected:
+ StringFilter filters[2] = { nullptr, nullptr };
+ bool descending;
+};
+
+bool HandleSortCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
assert(args.size() >= 2);
- if (args.size() > 2) {
- this->SetError("sub-command SORT only takes one argument.");
+ if (args.size() > 8) {
+ status.SetError("sub-command SORT only takes up to six arguments.");
return false;
}
+ auto sortCompare = cmStringSorter::Compare::UNINITIALIZED;
+ auto sortCaseSensitivity = cmStringSorter::CaseSensitivity::UNINITIALIZED;
+ auto sortOrder = cmStringSorter::Order::UNINITIALIZED;
+
+ size_t argumentIndex = 2;
+ const std::string messageHint = "sub-command SORT ";
+
+ while (argumentIndex < args.size()) {
+ const std::string option = args[argumentIndex++];
+ if (option == "COMPARE") {
+ if (sortCompare != cmStringSorter::Compare::UNINITIALIZED) {
+ std::string error = cmStrCat(messageHint, "option \"", option,
+ "\" has been specified multiple times.");
+ status.SetError(error);
+ return false;
+ }
+ if (argumentIndex < args.size()) {
+ const std::string argument = args[argumentIndex++];
+ if (argument == "STRING") {
+ sortCompare = cmStringSorter::Compare::STRING;
+ } else if (argument == "FILE_BASENAME") {
+ sortCompare = cmStringSorter::Compare::FILE_BASENAME;
+ } else {
+ std::string error =
+ cmStrCat(messageHint, "value \"", argument, "\" for option \"",
+ option, "\" is invalid.");
+ status.SetError(error);
+ return false;
+ }
+ } else {
+ status.SetError(cmStrCat(messageHint, "missing argument for option \"",
+ option, "\"."));
+ return false;
+ }
+ } else if (option == "CASE") {
+ if (sortCaseSensitivity !=
+ cmStringSorter::CaseSensitivity::UNINITIALIZED) {
+ status.SetError(cmStrCat(messageHint, "option \"", option,
+ "\" has been specified multiple times."));
+ return false;
+ }
+ if (argumentIndex < args.size()) {
+ const std::string argument = args[argumentIndex++];
+ if (argument == "SENSITIVE") {
+ sortCaseSensitivity = cmStringSorter::CaseSensitivity::SENSITIVE;
+ } else if (argument == "INSENSITIVE") {
+ sortCaseSensitivity = cmStringSorter::CaseSensitivity::INSENSITIVE;
+ } else {
+ status.SetError(cmStrCat(messageHint, "value \"", argument,
+ "\" for option \"", option,
+ "\" is invalid."));
+ return false;
+ }
+ } else {
+ status.SetError(cmStrCat(messageHint, "missing argument for option \"",
+ option, "\"."));
+ return false;
+ }
+ } else if (option == "ORDER") {
+
+ if (sortOrder != cmStringSorter::Order::UNINITIALIZED) {
+ status.SetError(cmStrCat(messageHint, "option \"", option,
+ "\" has been specified multiple times."));
+ return false;
+ }
+ if (argumentIndex < args.size()) {
+ const std::string argument = args[argumentIndex++];
+ if (argument == "ASCENDING") {
+ sortOrder = cmStringSorter::Order::ASCENDING;
+ } else if (argument == "DESCENDING") {
+ sortOrder = cmStringSorter::Order::DESCENDING;
+ } else {
+ status.SetError(cmStrCat(messageHint, "value \"", argument,
+ "\" for option \"", option,
+ "\" is invalid."));
+ return false;
+ }
+ } else {
+ status.SetError(cmStrCat(messageHint, "missing argument for option \"",
+ option, "\"."));
+ return false;
+ }
+ } else {
+ status.SetError(
+ cmStrCat(messageHint, "option \"", option, "\" is unknown."));
+ return false;
+ }
+ }
+ // set Default Values if Option is not given
+ if (sortCompare == cmStringSorter::Compare::UNINITIALIZED) {
+ sortCompare = cmStringSorter::Compare::STRING;
+ }
+ if (sortCaseSensitivity == cmStringSorter::CaseSensitivity::UNINITIALIZED) {
+ sortCaseSensitivity = cmStringSorter::CaseSensitivity::SENSITIVE;
+ }
+ if (sortOrder == cmStringSorter::Order::UNINITIALIZED) {
+ sortOrder = cmStringSorter::Order::ASCENDING;
+ }
+
const std::string& listName = args[1];
// expand the variable
std::vector<std::string> varArgsExpanded;
- if (!this->GetList(varArgsExpanded, listName)) {
- this->SetError("sub-command SORT requires list to be present.");
- return false;
+ if (!GetList(varArgsExpanded, listName, status.GetMakefile())) {
+ return true;
}
- std::sort(varArgsExpanded.begin(), varArgsExpanded.end());
+ if ((sortCompare == cmStringSorter::Compare::STRING) &&
+ (sortCaseSensitivity == cmStringSorter::CaseSensitivity::SENSITIVE) &&
+ (sortOrder == cmStringSorter::Order::ASCENDING)) {
+ std::sort(varArgsExpanded.begin(), varArgsExpanded.end());
+ } else {
+ cmStringSorter sorter(sortCompare, sortCaseSensitivity, sortOrder);
+ std::sort(varArgsExpanded.begin(), varArgsExpanded.end(), sorter);
+ }
std::string value = cmJoin(varArgsExpanded, ";");
- this->Makefile->AddDefinition(listName, value.c_str());
+ status.GetMakefile().AddDefinition(listName, value);
return true;
}
-bool cmListCommand::HandleRemoveAtCommand(std::vector<std::string> const& args)
+bool HandleSublistCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- if (args.size() < 3) {
- this->SetError("sub-command REMOVE_AT requires at least "
- "two arguments.");
+ if (args.size() != 5) {
+ status.SetError(cmStrCat("sub-command SUBLIST requires four arguments (",
+ args.size() - 1, " found)."));
return false;
}
const std::string& listName = args[1];
+ const std::string& variableName = args.back();
+
// expand the variable
std::vector<std::string> varArgsExpanded;
- if (!this->GetList(varArgsExpanded, listName)) {
- this->SetError("sub-command REMOVE_AT requires list to be present.");
+ if (!GetList(varArgsExpanded, listName, status.GetMakefile()) ||
+ varArgsExpanded.empty()) {
+ status.GetMakefile().AddDefinition(variableName, "");
+ return true;
+ }
+
+ const int start = atoi(args[2].c_str());
+ const int length = atoi(args[3].c_str());
+
+ using size_type = decltype(varArgsExpanded)::size_type;
+
+ if (start < 0 || size_type(start) >= varArgsExpanded.size()) {
+ status.SetError(cmStrCat("begin index: ", start, " is out of range 0 - ",
+ varArgsExpanded.size() - 1));
return false;
}
- // FIXME: Add policy to make non-existing lists an error like empty lists.
- if (varArgsExpanded.empty()) {
- this->SetError("REMOVE_AT given empty list");
+ if (length < -1) {
+ status.SetError(cmStrCat("length: ", length, " should be -1 or greater"));
+ return false;
+ }
+
+ const size_type end =
+ (length == -1 || size_type(start + length) > varArgsExpanded.size())
+ ? varArgsExpanded.size()
+ : size_type(start + length);
+ std::vector<std::string> sublist(varArgsExpanded.begin() + start,
+ varArgsExpanded.begin() + end);
+ status.GetMakefile().AddDefinition(variableName, cmJoin(sublist, ";"));
+ return true;
+}
+
+bool HandleRemoveAtCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() < 3) {
+ status.SetError("sub-command REMOVE_AT requires at least "
+ "two arguments.");
+ return false;
+ }
+
+ const std::string& listName = args[1];
+ // expand the variable
+ std::vector<std::string> varArgsExpanded;
+ if (!GetList(varArgsExpanded, listName, status.GetMakefile()) ||
+ varArgsExpanded.empty()) {
+ std::ostringstream str;
+ str << "index: ";
+ for (size_t i = 1; i < args.size(); ++i) {
+ str << args[i];
+ if (i != args.size() - 1) {
+ str << ", ";
+ }
+ }
+ str << " out of range (0, 0)";
+ status.SetError(str.str());
return false;
}
@@ -423,54 +1318,45 @@ bool cmListCommand::HandleRemoveAtCommand(std::vector<std::string> const& args)
for (cc = 2; cc < args.size(); ++cc) {
int item = atoi(args[cc].c_str());
if (item < 0) {
- item = (int)nitem + item;
+ item = static_cast<int>(nitem) + item;
}
- if (item < 0 || nitem <= (size_t)item) {
- std::ostringstream str;
- str << "index: " << item << " out of range (-" << nitem << ", "
- << nitem - 1 << ")";
- this->SetError(str.str());
+ if (item < 0 || nitem <= static_cast<size_t>(item)) {
+ status.SetError(cmStrCat("index: ", item, " out of range (-", nitem,
+ ", ", nitem - 1, ")"));
return false;
}
removed.push_back(static_cast<size_t>(item));
}
std::sort(removed.begin(), removed.end());
- std::vector<size_t>::const_iterator remEnd =
- std::unique(removed.begin(), removed.end());
- std::vector<size_t>::const_iterator remBegin = removed.begin();
+ auto remEnd = std::unique(removed.begin(), removed.end());
+ auto remBegin = removed.begin();
- std::vector<std::string>::const_iterator argsEnd =
+ auto argsEnd =
cmRemoveIndices(varArgsExpanded, cmMakeRange(remBegin, remEnd));
- std::vector<std::string>::const_iterator argsBegin = varArgsExpanded.begin();
+ auto argsBegin = varArgsExpanded.cbegin();
std::string value = cmJoin(cmMakeRange(argsBegin, argsEnd), ";");
- this->Makefile->AddDefinition(listName, value.c_str());
+ status.GetMakefile().AddDefinition(listName, value);
return true;
}
-bool cmListCommand::HandleFilterCommand(std::vector<std::string> const& args)
+bool HandleFilterCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("sub-command FILTER requires a list to be specified.");
+ status.SetError("sub-command FILTER requires a list to be specified.");
return false;
}
if (args.size() < 3) {
- this->SetError("sub-command FILTER requires an operator to be specified.");
+ status.SetError(
+ "sub-command FILTER requires an operator to be specified.");
return false;
}
if (args.size() < 4) {
- this->SetError("sub-command FILTER requires a mode to be specified.");
- return false;
- }
-
- const std::string& listName = args[1];
- // expand the variable
- std::vector<std::string> varArgsExpanded;
- if (!this->GetList(varArgsExpanded, listName)) {
- this->SetError("sub-command FILTER requires list to be present.");
+ status.SetError("sub-command FILTER requires a mode to be specified.");
return false;
}
@@ -481,21 +1367,29 @@ bool cmListCommand::HandleFilterCommand(std::vector<std::string> const& args)
} else if (op == "EXCLUDE") {
includeMatches = false;
} else {
- this->SetError("sub-command FILTER does not recognize operator " + op);
+ status.SetError("sub-command FILTER does not recognize operator " + op);
return false;
}
+ const std::string& listName = args[1];
+ // expand the variable
+ std::vector<std::string> varArgsExpanded;
+ if (!GetList(varArgsExpanded, listName, status.GetMakefile())) {
+ return true;
+ }
+
const std::string& mode = args[3];
if (mode == "REGEX") {
if (args.size() != 5) {
- this->SetError("sub-command FILTER, mode REGEX "
- "requires five arguments.");
+ status.SetError("sub-command FILTER, mode REGEX "
+ "requires five arguments.");
return false;
}
- return this->FilterRegex(args, includeMatches, listName, varArgsExpanded);
+ return FilterRegex(args, includeMatches, listName, varArgsExpanded,
+ status);
}
- this->SetError("sub-command FILTER does not recognize mode " + mode);
+ status.SetError("sub-command FILTER does not recognize mode " + mode);
return false;
}
@@ -518,28 +1412,60 @@ private:
const bool includeMatches;
};
-bool cmListCommand::FilterRegex(std::vector<std::string> const& args,
- bool includeMatches,
- std::string const& listName,
- std::vector<std::string>& varArgsExpanded)
+bool FilterRegex(std::vector<std::string> const& args, bool includeMatches,
+ std::string const& listName,
+ std::vector<std::string>& varArgsExpanded,
+ cmExecutionStatus& status)
{
const std::string& pattern = args[4];
cmsys::RegularExpression regex(pattern);
if (!regex.is_valid()) {
- std::string error = "sub-command FILTER, mode REGEX ";
- error += "failed to compile regex \"";
- error += pattern;
- error += "\".";
- this->SetError(error);
+ std::string error =
+ cmStrCat("sub-command FILTER, mode REGEX failed to compile regex \"",
+ pattern, "\".");
+ status.SetError(error);
return false;
}
- std::vector<std::string>::iterator argsBegin = varArgsExpanded.begin();
- std::vector<std::string>::iterator argsEnd = varArgsExpanded.end();
- std::vector<std::string>::iterator newArgsEnd =
+ auto argsBegin = varArgsExpanded.begin();
+ auto argsEnd = varArgsExpanded.end();
+ auto newArgsEnd =
std::remove_if(argsBegin, argsEnd, MatchesRegex(regex, includeMatches));
std::string value = cmJoin(cmMakeRange(argsBegin, newArgsEnd), ";");
- this->Makefile->AddDefinition(listName, value.c_str());
+ status.GetMakefile().AddDefinition(listName, value);
return true;
}
+
+} // namespace
+
+bool cmListCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() < 2) {
+ status.SetError("must be called with at least two arguments.");
+ return false;
+ }
+
+ static cmSubcommandTable const subcommand{
+ { "LENGTH"_s, HandleLengthCommand },
+ { "GET"_s, HandleGetCommand },
+ { "APPEND"_s, HandleAppendCommand },
+ { "PREPEND"_s, HandlePrependCommand },
+ { "POP_BACK"_s, HandlePopBackCommand },
+ { "POP_FRONT"_s, HandlePopFrontCommand },
+ { "FIND"_s, HandleFindCommand },
+ { "INSERT"_s, HandleInsertCommand },
+ { "JOIN"_s, HandleJoinCommand },
+ { "REMOVE_AT"_s, HandleRemoveAtCommand },
+ { "REMOVE_ITEM"_s, HandleRemoveItemCommand },
+ { "REMOVE_DUPLICATES"_s, HandleRemoveDuplicatesCommand },
+ { "TRANSFORM"_s, HandleTransformCommand },
+ { "SORT"_s, HandleSortCommand },
+ { "SUBLIST"_s, HandleSublistCommand },
+ { "REVERSE"_s, HandleReverseCommand },
+ { "FILTER"_s, HandleFilterCommand },
+ };
+
+ return subcommand(args[0], args, status);
+}
diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h
index 7789f7df1..274d9fdbd 100644
--- a/Source/cmListCommand.h
+++ b/Source/cmListCommand.h
@@ -3,52 +3,18 @@
#ifndef cmListCommand_h
#define cmListCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmListCommand
+/**
* \brief Common list operations
*
*/
-class cmListCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmListCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-protected:
- bool HandleLengthCommand(std::vector<std::string> const& args);
- bool HandleGetCommand(std::vector<std::string> const& args);
- bool HandleAppendCommand(std::vector<std::string> const& args);
- bool HandleFindCommand(std::vector<std::string> const& args);
- bool HandleInsertCommand(std::vector<std::string> const& args);
- bool HandleRemoveAtCommand(std::vector<std::string> const& args);
- bool HandleRemoveItemCommand(std::vector<std::string> const& args);
- bool HandleRemoveDuplicatesCommand(std::vector<std::string> const& args);
- bool HandleSortCommand(std::vector<std::string> const& args);
- bool HandleReverseCommand(std::vector<std::string> const& args);
- bool HandleFilterCommand(std::vector<std::string> const& args);
- bool FilterRegex(std::vector<std::string> const& args, bool includeMatches,
- std::string const& listName,
- std::vector<std::string>& varArgsExpanded);
-
- bool GetList(std::vector<std::string>& list, const std::string& var);
- bool GetListString(std::string& listString, const std::string& var);
-};
+bool cmListCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 0c73cd725..47679c932 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -2,23 +2,34 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmListFileCache.h"
+#include <cassert>
+#include <memory>
+#include <sstream>
+#include <utility>
+
#include "cmListFileLexer.h"
+#include "cmMessageType.h"
#include "cmMessenger.h"
-#include "cmOutputConverter.h"
#include "cmState.h"
+#include "cmStateDirectory.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-#include "cmConfigure.h"
-#include <algorithm>
-#include <assert.h>
-#include <sstream>
+cmCommandContext::cmCommandName& cmCommandContext::cmCommandName::operator=(
+ std::string const& name)
+{
+ this->Original = name;
+ this->Lower = cmSystemTools::LowerCase(name);
+ return *this;
+}
struct cmListFileParser
{
- cmListFileParser(cmListFile* lf, cmListFileBacktrace const& lfbt,
+ cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt,
cmMessenger* messenger, const char* filename);
~cmListFileParser();
+ cmListFileParser(const cmListFileParser&) = delete;
+ cmListFileParser& operator=(const cmListFileParser&) = delete;
void IssueFileOpenError(std::string const& text) const;
void IssueError(std::string const& text) const;
bool ParseFile();
@@ -39,12 +50,11 @@ struct cmListFileParser
} Separation;
};
-cmListFileParser::cmListFileParser(cmListFile* lf,
- cmListFileBacktrace const& lfbt,
+cmListFileParser::cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt,
cmMessenger* messenger,
const char* filename)
: ListFile(lf)
- , Backtrace(lfbt)
+ , Backtrace(std::move(lfbt))
, Messenger(messenger)
, FileName(filename)
, Lexer(cmListFileLexer_New())
@@ -58,7 +68,8 @@ cmListFileParser::~cmListFileParser()
void cmListFileParser::IssueFileOpenError(const std::string& text) const
{
- this->Messenger->IssueMessage(cmake::FATAL_ERROR, text, this->Backtrace);
+ this->Messenger->IssueMessage(MessageType::FATAL_ERROR, text,
+ this->Backtrace);
}
void cmListFileParser::IssueError(const std::string& text) const
@@ -68,7 +79,7 @@ void cmListFileParser::IssueError(const std::string& text) const
lfc.Line = cmListFileLexer_GetCurrentLine(this->Lexer);
cmListFileBacktrace lfbt = this->Backtrace;
lfbt = lfbt.Push(lfc);
- this->Messenger->IssueMessage(cmake::FATAL_ERROR, text, lfbt);
+ this->Messenger->IssueMessage(MessageType::FATAL_ERROR, text, lfbt);
cmSystemTools::SetFatalErrorOccured();
}
@@ -82,7 +93,7 @@ bool cmListFileParser::ParseFile()
}
if (bom == cmListFileLexer_BOM_Broken) {
- cmListFileLexer_SetFileName(this->Lexer, CM_NULLPTR, CM_NULLPTR);
+ cmListFileLexer_SetFileName(this->Lexer, nullptr, nullptr);
this->IssueFileOpenError("Error while reading Byte-Order-Mark. "
"File not seekable?");
return false;
@@ -90,7 +101,7 @@ bool cmListFileParser::ParseFile()
// Verify the Byte-Order-Mark, if any.
if (bom != cmListFileLexer_BOM_None && bom != cmListFileLexer_BOM_UTF8) {
- cmListFileLexer_SetFileName(this->Lexer, CM_NULLPTR, CM_NULLPTR);
+ cmListFileLexer_SetFileName(this->Lexer, nullptr, nullptr);
this->IssueFileOpenError(
"File starts with a Byte-Order-Mark that is not UTF-8.");
return false;
@@ -182,11 +193,9 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
}
// Arguments.
- unsigned long lastLine;
unsigned long parenDepth = 0;
this->Separation = SeparationOkay;
- while ((lastLine = cmListFileLexer_GetCurrentLine(this->Lexer),
- token = cmListFileLexer_Scan(this->Lexer))) {
+ while ((token = cmListFileLexer_Scan(this->Lexer))) {
if (token->type == cmListFileLexer_Token_Space ||
token->type == cmListFileLexer_Token_Newline) {
this->Separation = SeparationOkay;
@@ -241,20 +250,19 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
std::ostringstream error;
cmListFileContext lfc;
lfc.FilePath = this->FileName;
- lfc.Line = lastLine;
+ lfc.Line = line;
cmListFileBacktrace lfbt = this->Backtrace;
lfbt = lfbt.Push(lfc);
error << "Parse error. Function missing ending \")\". "
<< "End of file reached.";
- this->Messenger->IssueMessage(cmake::FATAL_ERROR, error.str(), lfbt);
+ this->Messenger->IssueMessage(MessageType::FATAL_ERROR, error.str(), lfbt);
return false;
}
bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
cmListFileArgument::Delimiter delim)
{
- cmListFileArgument a(token->text, delim, token->line);
- this->Function.Arguments.push_back(a);
+ this->Function.Arguments.emplace_back(token->text, delim, token->line);
if (this->Separation == SeparationOkay) {
return true;
}
@@ -272,98 +280,74 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
<< "Argument not separated from preceding token by whitespace.";
/* clang-format on */
if (isError) {
- this->Messenger->IssueMessage(cmake::FATAL_ERROR, m.str(), lfbt);
+ this->Messenger->IssueMessage(MessageType::FATAL_ERROR, m.str(), lfbt);
return false;
}
- this->Messenger->IssueMessage(cmake::AUTHOR_WARNING, m.str(), lfbt);
+ this->Messenger->IssueMessage(MessageType::AUTHOR_WARNING, m.str(), lfbt);
return true;
}
-struct cmListFileBacktrace::Entry : public cmListFileContext
+// We hold either the bottom scope of a directory or a call/file context.
+// Discriminate these cases via the parent pointer.
+struct cmListFileBacktrace::Entry
{
- Entry(cmListFileContext const& lfc, Entry* up)
- : cmListFileContext(lfc)
- , Up(up)
- , RefCount(0)
+ Entry(cmStateSnapshot bottom)
+ : Bottom(bottom)
{
- if (this->Up) {
- this->Up->Ref();
- }
}
- ~Entry()
+
+ Entry(std::shared_ptr<Entry const> parent, cmListFileContext lfc)
+ : Context(std::move(lfc))
+ , Parent(std::move(parent))
{
- if (this->Up) {
- this->Up->Unref();
- }
}
- void Ref() { ++this->RefCount; }
- void Unref()
+
+ ~Entry()
{
- if (--this->RefCount == 0) {
- delete this;
+ if (this->Parent) {
+ this->Context.~cmListFileContext();
+ } else {
+ this->Bottom.~cmStateSnapshot();
}
}
- Entry* Up;
- unsigned int RefCount;
-};
-cmListFileBacktrace::cmListFileBacktrace(cmStateSnapshot const& bottom,
- Entry* up,
- cmListFileContext const& lfc)
- : Bottom(bottom)
- , Cur(new Entry(lfc, up))
-{
- assert(this->Bottom.IsValid());
- this->Cur->Ref();
-}
+ bool IsBottom() const { return !this->Parent; }
-cmListFileBacktrace::cmListFileBacktrace(cmStateSnapshot const& bottom,
- Entry* cur)
- : Bottom(bottom)
- , Cur(cur)
-{
- if (this->Cur) {
- assert(this->Bottom.IsValid());
- this->Cur->Ref();
- }
-}
-
-cmListFileBacktrace::cmListFileBacktrace()
- : Bottom()
- , Cur(CM_NULLPTR)
-{
-}
+ union
+ {
+ cmStateSnapshot Bottom;
+ cmListFileContext Context;
+ };
+ std::shared_ptr<Entry const> Parent;
+};
cmListFileBacktrace::cmListFileBacktrace(cmStateSnapshot const& snapshot)
- : Bottom(snapshot.GetCallStackBottom())
- , Cur(CM_NULLPTR)
+ : TopEntry(std::make_shared<Entry const>(snapshot.GetCallStackBottom()))
{
}
-cmListFileBacktrace::cmListFileBacktrace(cmListFileBacktrace const& r)
- : Bottom(r.Bottom)
- , Cur(r.Cur)
+/* NOLINTNEXTLINE(performance-unnecessary-value-param) */
+cmListFileBacktrace::cmListFileBacktrace(std::shared_ptr<Entry const> parent,
+ cmListFileContext const& lfc)
+ : TopEntry(std::make_shared<Entry const>(std::move(parent), lfc))
{
- if (this->Cur) {
- assert(this->Bottom.IsValid());
- this->Cur->Ref();
- }
}
-cmListFileBacktrace& cmListFileBacktrace::operator=(
- cmListFileBacktrace const& r)
+cmListFileBacktrace::cmListFileBacktrace(std::shared_ptr<Entry const> top)
+ : TopEntry(std::move(top))
{
- cmListFileBacktrace tmp(r);
- std::swap(this->Cur, tmp.Cur);
- std::swap(this->Bottom, tmp.Bottom);
- return *this;
}
-cmListFileBacktrace::~cmListFileBacktrace()
+cmStateSnapshot cmListFileBacktrace::GetBottom() const
{
- if (this->Cur) {
- this->Cur->Unref();
+ cmStateSnapshot bottom;
+ if (Entry const* cur = this->TopEntry.get()) {
+ while (Entry const* parent = cur->Parent.get()) {
+ cur = parent;
+ }
+ bottom = cur->Bottom;
}
+ return bottom;
}
cmListFileBacktrace cmListFileBacktrace::Push(std::string const& file) const
@@ -374,54 +358,60 @@ cmListFileBacktrace cmListFileBacktrace::Push(std::string const& file) const
// skipped during call stack printing.
cmListFileContext lfc;
lfc.FilePath = file;
- return cmListFileBacktrace(this->Bottom, this->Cur, lfc);
+ return this->Push(lfc);
}
cmListFileBacktrace cmListFileBacktrace::Push(
cmListFileContext const& lfc) const
{
- return cmListFileBacktrace(this->Bottom, this->Cur, lfc);
+ assert(this->TopEntry);
+ assert(!this->TopEntry->IsBottom() || this->TopEntry->Bottom.IsValid());
+ return cmListFileBacktrace(this->TopEntry, lfc);
}
cmListFileBacktrace cmListFileBacktrace::Pop() const
{
- assert(this->Cur);
- return cmListFileBacktrace(this->Bottom, this->Cur->Up);
+ assert(this->TopEntry);
+ assert(!this->TopEntry->IsBottom());
+ return cmListFileBacktrace(this->TopEntry->Parent);
}
cmListFileContext const& cmListFileBacktrace::Top() const
{
- if (this->Cur) {
- return *this->Cur;
- }
- static cmListFileContext const empty;
- return empty;
+ assert(this->TopEntry);
+ assert(!this->TopEntry->IsBottom());
+ return this->TopEntry->Context;
}
void cmListFileBacktrace::PrintTitle(std::ostream& out) const
{
- if (!this->Cur) {
+ // The title exists only if we have a call on top of the bottom.
+ if (!this->TopEntry || this->TopEntry->IsBottom()) {
return;
}
- cmOutputConverter converter(this->Bottom);
- cmListFileContext lfc = *this->Cur;
- if (!this->Bottom.GetState()->GetIsInTryCompile()) {
- lfc.FilePath = converter.ConvertToRelativePath(
- this->Bottom.GetState()->GetSourceDirectory(), lfc.FilePath);
+ cmListFileContext lfc = this->TopEntry->Context;
+ cmStateSnapshot bottom = this->GetBottom();
+ if (!bottom.GetState()->GetIsInTryCompile()) {
+ lfc.FilePath = bottom.GetDirectory().ConvertToRelPathIfNotContained(
+ bottom.GetState()->GetSourceDirectory(), lfc.FilePath);
}
out << (lfc.Line ? " at " : " in ") << lfc;
}
void cmListFileBacktrace::PrintCallStack(std::ostream& out) const
{
- if (!this->Cur || !this->Cur->Up) {
+ // The call stack exists only if we have at least two calls on top
+ // of the bottom.
+ if (!this->TopEntry || this->TopEntry->IsBottom() ||
+ this->TopEntry->Parent->IsBottom()) {
return;
}
bool first = true;
- cmOutputConverter converter(this->Bottom);
- for (Entry* i = this->Cur->Up; i; i = i->Up) {
- if (i->Name.empty()) {
+ cmStateSnapshot bottom = this->GetBottom();
+ for (Entry const* cur = this->TopEntry->Parent.get(); !cur->IsBottom();
+ cur = cur->Parent.get()) {
+ if (cur->Context.Name.empty()) {
// Skip this whole-file scope. When we get here we already will
// have printed a more-specific context within the file.
continue;
@@ -430,15 +420,31 @@ void cmListFileBacktrace::PrintCallStack(std::ostream& out) const
first = false;
out << "Call Stack (most recent call first):\n";
}
- cmListFileContext lfc = *i;
- if (!this->Bottom.GetState()->GetIsInTryCompile()) {
- lfc.FilePath = converter.ConvertToRelativePath(
- this->Bottom.GetState()->GetSourceDirectory(), lfc.FilePath);
+ cmListFileContext lfc = cur->Context;
+ if (!bottom.GetState()->GetIsInTryCompile()) {
+ lfc.FilePath = bottom.GetDirectory().ConvertToRelPathIfNotContained(
+ bottom.GetState()->GetSourceDirectory(), lfc.FilePath);
}
out << " " << lfc << "\n";
}
}
+size_t cmListFileBacktrace::Depth() const
+{
+ size_t depth = 0;
+ if (Entry const* cur = this->TopEntry.get()) {
+ for (; !cur->IsBottom(); cur = cur->Parent.get()) {
+ ++depth;
+ }
+ }
+ return depth;
+}
+
+bool cmListFileBacktrace::Empty() const
+{
+ return !this->TopEntry || this->TopEntry->IsBottom();
+}
+
std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
{
os << lfc.FilePath;
@@ -468,3 +474,20 @@ bool operator!=(const cmListFileContext& lhs, const cmListFileContext& rhs)
{
return !(lhs == rhs);
}
+
+std::ostream& operator<<(std::ostream& os, BT<std::string> const& s)
+{
+ return os << s.Value;
+}
+
+std::vector<BT<std::string>> ExpandListWithBacktrace(
+ std::string const& list, cmListFileBacktrace const& bt)
+{
+ std::vector<BT<std::string>> result;
+ std::vector<std::string> tmp = cmExpandedList(list);
+ result.reserve(tmp.size());
+ for (std::string& i : tmp) {
+ result.emplace_back(std::move(i), bt);
+ }
+ return result;
+}
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 349ddef91..9cae8277b 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -5,8 +5,11 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <cstddef>
#include <iosfwd>
+#include <memory>
#include <string>
+#include <utility>
#include <vector>
#include "cmStateSnapshot.h"
@@ -22,11 +25,19 @@ class cmMessenger;
struct cmCommandContext
{
- std::string Name;
- long Line;
- cmCommandContext()
- : Name()
- , Line(0)
+ struct cmCommandName
+ {
+ std::string Lower;
+ std::string Original;
+ cmCommandName() = default;
+ cmCommandName(std::string const& name) { *this = name; }
+ cmCommandName& operator=(std::string const& name);
+ } Name;
+ long Line = 0;
+ cmCommandContext() = default;
+ cmCommandContext(const char* name, int line)
+ : Name(name)
+ , Line(line)
{
}
};
@@ -39,14 +50,9 @@ struct cmListFileArgument
Quoted,
Bracket
};
- cmListFileArgument()
- : Value()
- , Delim(Unquoted)
- , Line(0)
- {
- }
- cmListFileArgument(const std::string& v, Delimiter d, long line)
- : Value(v)
+ cmListFileArgument() = default;
+ cmListFileArgument(std::string v, Delimiter d, long line)
+ : Value(std::move(v))
, Delim(d)
, Line(line)
{
@@ -57,8 +63,8 @@ struct cmListFileArgument
}
bool operator!=(const cmListFileArgument& r) const { return !(*this == r); }
std::string Value;
- Delimiter Delim;
- long Line;
+ Delimiter Delim = Unquoted;
+ long Line = 0;
};
class cmListFileContext
@@ -66,13 +72,7 @@ class cmListFileContext
public:
std::string Name;
std::string FilePath;
- long Line;
- cmListFileContext()
- : Name()
- , FilePath()
- , Line(0)
- {
- }
+ long Line = 0;
static cmListFileContext FromCommandContext(cmCommandContext const& lfcc,
std::string const& fileName)
@@ -80,7 +80,7 @@ public:
cmListFileContext lfc;
lfc.FilePath = fileName;
lfc.Line = lfcc.Line;
- lfc.Name = lfcc.Name;
+ lfc.Name = lfcc.Name.Original;
return lfc;
}
};
@@ -103,18 +103,13 @@ public:
// Default-constructed backtrace may not be used until after
// set via assignment from a backtrace constructed with a
// valid snapshot.
- cmListFileBacktrace();
+ cmListFileBacktrace() = default;
// Construct an empty backtrace whose bottom sits in the directory
// indicated by the given valid snapshot.
cmListFileBacktrace(cmStateSnapshot const& snapshot);
- // Backtraces may be copied and assigned as values.
- cmListFileBacktrace(cmListFileBacktrace const& r);
- cmListFileBacktrace& operator=(cmListFileBacktrace const& r);
- ~cmListFileBacktrace();
-
- cmStateSnapshot GetBottom() const { return this->Bottom; }
+ cmStateSnapshot GetBottom() const;
// Get a backtrace with the given file scope added to the top.
// May not be called until after construction with a valid snapshot.
@@ -129,7 +124,7 @@ public:
cmListFileBacktrace Pop() const;
// Get the context at the top of the backtrace.
- // Returns an empty context if the backtrace is empty.
+ // This may be called only if Empty() would return false.
cmListFileContext const& Top() const;
// Print the top of the backtrace.
@@ -138,16 +133,52 @@ public:
// Print the call stack below the top of the backtrace.
void PrintCallStack(std::ostream& out) const;
+ // Get the number of 'frames' in this backtrace
+ size_t Depth() const;
+
+ // Return true if this backtrace is empty.
+ bool Empty() const;
+
private:
struct Entry;
-
- cmStateSnapshot Bottom;
- Entry* Cur;
- cmListFileBacktrace(cmStateSnapshot const& bottom, Entry* up,
+ std::shared_ptr<Entry const> TopEntry;
+ cmListFileBacktrace(std::shared_ptr<Entry const> parent,
cmListFileContext const& lfc);
- cmListFileBacktrace(cmStateSnapshot const& bottom, Entry* cur);
+ cmListFileBacktrace(std::shared_ptr<Entry const> top);
};
+// Wrap type T as a value with a backtrace. For purposes of
+// ordering and equality comparison, only the original value is
+// used. The backtrace is considered incidental.
+template <typename T>
+class BT
+{
+public:
+ BT(T v = T(), cmListFileBacktrace bt = cmListFileBacktrace())
+ : Value(std::move(v))
+ , Backtrace(std::move(bt))
+ {
+ }
+ T Value;
+ cmListFileBacktrace Backtrace;
+ friend bool operator==(BT<T> const& l, BT<T> const& r)
+ {
+ return l.Value == r.Value;
+ }
+ friend bool operator<(BT<T> const& l, BT<T> const& r)
+ {
+ return l.Value < r.Value;
+ }
+ friend bool operator==(BT<T> const& l, T const& r) { return l.Value == r; }
+ friend bool operator==(T const& l, BT<T> const& r) { return l == r.Value; }
+};
+
+std::ostream& operator<<(std::ostream& os, BT<std::string> const& s);
+
+std::vector<BT<std::string>> ExpandListWithBacktrace(
+ std::string const& list,
+ cmListFileBacktrace const& bt = cmListFileBacktrace());
+
struct cmListFile
{
bool ParseFile(const char* path, cmMessenger* messenger,
diff --git a/Source/cmListFileLexer.h b/Source/cmListFileLexer.h
index f243010ad..ec6b3cd77 100644
--- a/Source/cmListFileLexer.h
+++ b/Source/cmListFileLexer.h
@@ -3,7 +3,13 @@
#ifndef cmListFileLexer_h
#define cmListFileLexer_h
-typedef enum cmListFileLexer_Type_e {
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* NOLINTNEXTLINE(modernize-use-using) */
+typedef enum cmListFileLexer_Type_e
+{
cmListFileLexer_Token_None,
cmListFileLexer_Token_Space,
cmListFileLexer_Token_Newline,
@@ -19,6 +25,7 @@ typedef enum cmListFileLexer_Type_e {
cmListFileLexer_Token_BadString
} cmListFileLexer_Type;
+/* NOLINTNEXTLINE(modernize-use-using) */
typedef struct cmListFileLexer_Token_s cmListFileLexer_Token;
struct cmListFileLexer_Token_s
{
@@ -39,14 +46,13 @@ enum cmListFileLexer_BOM_e
cmListFileLexer_BOM_UTF32BE,
cmListFileLexer_BOM_UTF32LE
};
+
+/* NOLINTNEXTLINE(modernize-use-using) */
typedef enum cmListFileLexer_BOM_e cmListFileLexer_BOM;
+/* NOLINTNEXTLINE(modernize-use-using) */
typedef struct cmListFileLexer_s cmListFileLexer;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
cmListFileLexer* cmListFileLexer_New(void);
int cmListFileLexer_SetFileName(cmListFileLexer*, const char*,
cmListFileLexer_BOM* bom);
diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx
index 00a30bf0e..1184bcb58 100644
--- a/Source/cmLoadCacheCommand.cxx
+++ b/Source/cmLoadCacheCommand.cxx
@@ -2,42 +2,48 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLoadCacheCommand.h"
+#include <set>
+
#include "cmsys/FStream.hxx"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmake.h"
-class cmExecutionStatus;
+static bool ReadWithPrefix(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+
+static void CheckLine(cmMakefile& mf, std::string const& prefix,
+ std::set<std::string> const& variablesToRead,
+ const char* line);
-// cmLoadCacheCommand
-bool cmLoadCacheCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmLoadCacheCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with wrong number of arguments.");
+ status.SetError("called with wrong number of arguments.");
}
if (args.size() >= 2 && args[1] == "READ_WITH_PREFIX") {
- return this->ReadWithPrefix(args);
+ return ReadWithPrefix(args, status);
}
// Cache entries to be excluded from the import list.
// If this set is empty, all cache entries are brought in
// and they can not be overridden.
bool excludeFiles = false;
- unsigned int i;
std::set<std::string> excludes;
- for (i = 0; i < args.size(); i++) {
+ for (std::string const& arg : args) {
if (excludeFiles) {
- excludes.insert(args[i]);
+ excludes.insert(arg);
}
- if (args[i] == "EXCLUDE") {
+ if (arg == "EXCLUDE") {
excludeFiles = true;
}
- if (excludeFiles && (args[i] == "INCLUDE_INTERNALS")) {
+ if (excludeFiles && (arg == "INCLUDE_INTERNALS")) {
break;
}
}
@@ -48,54 +54,58 @@ bool cmLoadCacheCommand::InitialPass(std::vector<std::string> const& args,
bool includeFiles = false;
std::set<std::string> includes;
- for (i = 0; i < args.size(); i++) {
+ for (std::string const& arg : args) {
if (includeFiles) {
- includes.insert(args[i]);
+ includes.insert(arg);
}
- if (args[i] == "INCLUDE_INTERNALS") {
+ if (arg == "INCLUDE_INTERNALS") {
includeFiles = true;
}
- if (includeFiles && (args[i] == "EXCLUDE")) {
+ if (includeFiles && (arg == "EXCLUDE")) {
break;
}
}
+ cmMakefile& mf = status.GetMakefile();
+
// Loop over each build directory listed in the arguments. Each
// directory has a cache file.
- for (i = 0; i < args.size(); i++) {
- if ((args[i] == "EXCLUDE") || (args[i] == "INCLUDE_INTERNALS")) {
+ for (std::string const& arg : args) {
+ if ((arg == "EXCLUDE") || (arg == "INCLUDE_INTERNALS")) {
break;
}
- this->Makefile->GetCMakeInstance()->LoadCache(args[i], false, excludes,
- includes);
+ mf.GetCMakeInstance()->LoadCache(arg, false, excludes, includes);
}
return true;
}
-bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
+static bool ReadWithPrefix(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// Make sure we have a prefix.
if (args.size() < 3) {
- this->SetError("READ_WITH_PREFIX form must specify a prefix.");
+ status.SetError("READ_WITH_PREFIX form must specify a prefix.");
return false;
}
// Make sure the cache file exists.
std::string cacheFile = args[0] + "/CMakeCache.txt";
- if (!cmSystemTools::FileExists(cacheFile.c_str())) {
+ if (!cmSystemTools::FileExists(cacheFile)) {
std::string e = "Cannot load cache file from " + cacheFile;
- this->SetError(e);
+ status.SetError(e);
return false;
}
// Prepare the table of variables to read.
- this->Prefix = args[2];
- this->VariablesToRead.insert(args.begin() + 3, args.end());
+ std::string const prefix = args[2];
+ std::set<std::string> const variablesToRead(args.begin() + 3, args.end());
// Read the cache file.
cmsys::ifstream fin(cacheFile.c_str());
+ cmMakefile& mf = status.GetMakefile();
+
// This is a big hack read loop to overcome a buggy ifstream
// implementation on HP-UX. This should work on all platforms even
// for small buffer sizes.
@@ -124,8 +134,8 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
}
if (i != end) {
// Completed a line.
- this->CheckLine(line.c_str());
- line = "";
+ CheckLine(mf, prefix, variablesToRead, line.c_str());
+ line.clear();
// Skip the newline character.
++i;
@@ -135,13 +145,15 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
}
if (!line.empty()) {
// Partial last line.
- this->CheckLine(line.c_str());
+ CheckLine(mf, prefix, variablesToRead, line.c_str());
}
return true;
}
-void cmLoadCacheCommand::CheckLine(const char* line)
+static void CheckLine(cmMakefile& mf, std::string const& prefix,
+ std::set<std::string> const& variablesToRead,
+ const char* line)
{
// Check one line of the cache file.
std::string var;
@@ -149,14 +161,14 @@ void cmLoadCacheCommand::CheckLine(const char* line)
cmStateEnums::CacheEntryType type = cmStateEnums::UNINITIALIZED;
if (cmake::ParseCacheEntry(line, var, value, type)) {
// Found a real entry. See if this one was requested.
- if (this->VariablesToRead.find(var) != this->VariablesToRead.end()) {
+ if (variablesToRead.find(var) != variablesToRead.end()) {
// This was requested. Set this variable locally with the given
// prefix.
- var = this->Prefix + var;
+ var = prefix + var;
if (!value.empty()) {
- this->Makefile->AddDefinition(var, value.c_str());
+ mf.AddDefinition(var, value);
} else {
- this->Makefile->RemoveDefinition(var);
+ mf.RemoveDefinition(var);
}
}
}
diff --git a/Source/cmLoadCacheCommand.h b/Source/cmLoadCacheCommand.h
index 1a8a0fc4c..7cee6637c 100644
--- a/Source/cmLoadCacheCommand.h
+++ b/Source/cmLoadCacheCommand.h
@@ -3,42 +3,14 @@
#ifndef cmLoadCacheCommand_h
#define cmLoadCacheCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include <set>
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmLoadCacheCommand
- * \brief load a cache file
- *
- * cmLoadCacheCommand loads the non internal values of a cache file
- */
-class cmLoadCacheCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmLoadCacheCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-protected:
- std::set<std::string> VariablesToRead;
- std::string Prefix;
-
- bool ReadWithPrefix(std::vector<std::string> const& args);
- void CheckLine(const char* line);
-};
+bool cmLoadCacheCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index 92a32a147..23ace649a 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -2,49 +2,121 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLoadCommandCommand.h"
-#include <signal.h>
-#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <csignal>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <utility>
+
+#include <cm/memory>
-#include "cmCPluginAPI.cxx"
#include "cmCPluginAPI.h"
+#include "cmCommand.h"
#include "cmDynamicLoader.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
+#include "cmCPluginAPI.cxx"
#ifdef __QNX__
-#include <malloc.h> /* for malloc/free on QNX */
+# include <malloc.h> /* for malloc/free on QNX */
#endif
-extern "C" void TrapsForSignalsCFunction(int sig);
+namespace {
+
+const char* LastName = nullptr;
+
+extern "C" void TrapsForSignals(int sig)
+{
+ fprintf(stderr, "CMake loaded command %s crashed with signal: %d.\n",
+ LastName, sig);
+}
+
+struct SignalHandlerGuard
+{
+ explicit SignalHandlerGuard(const char* name)
+ {
+ LastName = name != nullptr ? name : "????";
+
+ signal(SIGSEGV, TrapsForSignals);
+#ifdef SIGBUS
+ signal(SIGBUS, TrapsForSignals);
+#endif
+ signal(SIGILL, TrapsForSignals);
+ }
+
+ ~SignalHandlerGuard()
+ {
+ signal(SIGSEGV, nullptr);
+#ifdef SIGBUS
+ signal(SIGBUS, nullptr);
+#endif
+ signal(SIGILL, nullptr);
+ }
+
+ SignalHandlerGuard(SignalHandlerGuard const&) = delete;
+ SignalHandlerGuard& operator=(SignalHandlerGuard const&) = delete;
+};
+
+struct LoadedCommandImpl : cmLoadedCommandInfo
+{
+ explicit LoadedCommandImpl(CM_INIT_FUNCTION init)
+ : cmLoadedCommandInfo{ 0, 0, &cmStaticCAPI, 0,
+ nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr }
+ {
+ init(this);
+ }
+
+ ~LoadedCommandImpl()
+ {
+ if (this->Destructor) {
+ SignalHandlerGuard guard(this->Name);
+ this->Destructor(this);
+ }
+ if (this->Error != nullptr) {
+ free(this->Error);
+ }
+ }
+
+ LoadedCommandImpl(LoadedCommandImpl const&) = delete;
+ LoadedCommandImpl& operator=(LoadedCommandImpl const&) = delete;
+
+ int DoInitialPass(cmMakefile* mf, int argc, char* argv[])
+ {
+ SignalHandlerGuard guard(this->Name);
+ return this->InitialPass(this, mf, argc, argv);
+ }
+
+ void DoFinalPass(cmMakefile* mf)
+ {
+ SignalHandlerGuard guard(this->Name);
+ this->FinalPass(this, mf);
+ }
+};
// a class for loadabple commands
class cmLoadedCommand : public cmCommand
{
public:
- cmLoadedCommand()
+ cmLoadedCommand() = default;
+ explicit cmLoadedCommand(CM_INIT_FUNCTION init)
+ : Impl(std::make_shared<LoadedCommandImpl>(init))
{
- memset(&this->info, 0, sizeof(this->info));
- this->info.CAPI = &cmStaticCAPI;
}
- ///! clean up any memory allocated by the plugin
- ~cmLoadedCommand() CM_OVERRIDE;
-
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE
+ std::unique_ptr<cmCommand> Clone() override
{
- cmLoadedCommand* newC = new cmLoadedCommand;
+ auto newC = cm::make_unique<cmLoadedCommand>();
// we must copy when we clone
- memcpy(&newC->info, &this->info, sizeof(info));
- return newC;
+ newC->Impl = this->Impl;
+ return std::unique_ptr<cmCommand>(std::move(newC));
}
/**
@@ -52,121 +124,58 @@ public:
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&) CM_OVERRIDE;
-
- /**
- * This is called at the end after all the information
- * specified by the command is accumulated. Most commands do
- * not implement this method. At this point, reading and
- * writing to the cache can be done.
- */
- void FinalPass() CM_OVERRIDE;
- bool HasFinalPass() const CM_OVERRIDE
- {
- return this->info.FinalPass != CM_NULLPTR;
- }
-
- static const char* LastName;
- static void TrapsForSignals(int sig)
- {
- fprintf(stderr, "CMake loaded command %s crashed with signal: %d.\n",
- cmLoadedCommand::LastName, sig);
- }
- static void InstallSignalHandlers(const char* name, int remove = 0)
- {
- cmLoadedCommand::LastName = name;
- if (!name) {
- cmLoadedCommand::LastName = "????";
- }
-
- if (!remove) {
- signal(SIGSEGV, TrapsForSignalsCFunction);
-#ifdef SIGBUS
- signal(SIGBUS, TrapsForSignalsCFunction);
-#endif
- signal(SIGILL, TrapsForSignalsCFunction);
- } else {
- signal(SIGSEGV, CM_NULLPTR);
-#ifdef SIGBUS
- signal(SIGBUS, CM_NULLPTR);
-#endif
- signal(SIGILL, CM_NULLPTR);
- }
- }
+ cmExecutionStatus&) override;
- cmLoadedCommandInfo info;
+private:
+ std::shared_ptr<LoadedCommandImpl> Impl;
};
-extern "C" void TrapsForSignalsCFunction(int sig)
-{
- cmLoadedCommand::TrapsForSignals(sig);
-}
-
-const char* cmLoadedCommand::LastName = CM_NULLPTR;
-
bool cmLoadedCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
{
- if (!info.InitialPass) {
+ if (!this->Impl->InitialPass) {
return true;
}
// clear the error string
- if (this->info.Error) {
- free(this->info.Error);
+ if (this->Impl->Error) {
+ free(this->Impl->Error);
}
// create argc and argv and then invoke the command
int argc = static_cast<int>(args.size());
- char** argv = CM_NULLPTR;
+ char** argv = nullptr;
if (argc) {
- argv = (char**)malloc(argc * sizeof(char*));
+ argv = static_cast<char**>(malloc(argc * sizeof(char*)));
}
int i;
for (i = 0; i < argc; ++i) {
argv[i] = strdup(args[i].c_str());
}
- cmLoadedCommand::InstallSignalHandlers(info.Name);
- int result =
- info.InitialPass((void*)&info, (void*)this->Makefile, argc, argv);
- cmLoadedCommand::InstallSignalHandlers(info.Name, 1);
+ int result = this->Impl->DoInitialPass(this->Makefile, argc, argv);
cmFreeArguments(argc, argv);
if (result) {
+ if (this->Impl->FinalPass) {
+ auto impl = this->Impl;
+ this->Makefile->AddFinalAction(
+ [impl](cmMakefile& makefile) { impl->DoFinalPass(&makefile); });
+ }
return true;
}
/* Initial Pass must have failed so set the error string */
- if (this->info.Error) {
- this->SetError(this->info.Error);
+ if (this->Impl->Error) {
+ this->SetError(this->Impl->Error);
}
return false;
}
-void cmLoadedCommand::FinalPass()
-{
- if (this->info.FinalPass) {
- cmLoadedCommand::InstallSignalHandlers(info.Name);
- this->info.FinalPass((void*)&this->info, (void*)this->Makefile);
- cmLoadedCommand::InstallSignalHandlers(info.Name, 1);
- }
-}
-
-cmLoadedCommand::~cmLoadedCommand()
-{
- if (this->info.Destructor) {
- cmLoadedCommand::InstallSignalHandlers(info.Name);
- this->info.Destructor((void*)&this->info);
- cmLoadedCommand::InstallSignalHandlers(info.Name, 1);
- }
- if (this->info.Error) {
- free(this->info.Error);
- }
-}
+} // namespace
// cmLoadCommandCommand
-bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmLoadCommandCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
return true;
@@ -174,16 +183,14 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
// Construct a variable to report what file was loaded, if any.
// Start by removing the definition in case of failure.
- std::string reportVar = "CMAKE_LOADED_COMMAND_";
- reportVar += args[0];
- this->Makefile->RemoveDefinition(reportVar);
+ std::string reportVar = cmStrCat("CMAKE_LOADED_COMMAND_", args[0]);
+ status.GetMakefile().RemoveDefinition(reportVar);
// the file must exist
- std::string moduleName =
- this->Makefile->GetRequiredDefinition("CMAKE_SHARED_MODULE_PREFIX");
- moduleName += "cm" + args[0];
- moduleName +=
- this->Makefile->GetRequiredDefinition("CMAKE_SHARED_MODULE_SUFFIX");
+ std::string moduleName = cmStrCat(
+ status.GetMakefile().GetRequiredDefinition("CMAKE_SHARED_MODULE_PREFIX"),
+ "cm", args[0],
+ status.GetMakefile().GetRequiredDefinition("CMAKE_SHARED_MODULE_SUFFIX"));
// search for the file
std::vector<std::string> path;
@@ -198,10 +205,9 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
// Try to find the program.
std::string fullPath = cmSystemTools::FindFile(moduleName, path);
- if (fullPath == "") {
- std::ostringstream e;
- e << "Attempt to load command failed from file \"" << moduleName << "\"";
- this->SetError(e.str());
+ if (fullPath.empty()) {
+ status.SetError(cmStrCat("Attempt to load command failed from file \"",
+ moduleName, "\""));
return false;
}
@@ -209,42 +215,38 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
cmsys::DynamicLoader::LibraryHandle lib =
cmDynamicLoader::OpenLibrary(fullPath.c_str());
if (!lib) {
- std::string err = "Attempt to load the library ";
- err += fullPath + " failed.";
+ std::string err =
+ cmStrCat("Attempt to load the library ", fullPath, " failed.");
const char* error = cmsys::DynamicLoader::LastError();
if (error) {
err += " Additional error info is:\n";
err += error;
}
- this->SetError(err);
+ status.SetError(err);
return false;
}
// Report what file was loaded for this command.
- this->Makefile->AddDefinition(reportVar, fullPath.c_str());
+ status.GetMakefile().AddDefinition(reportVar, fullPath);
// find the init function
std::string initFuncName = args[0] + "Init";
- CM_INIT_FUNCTION initFunction =
- (CM_INIT_FUNCTION)cmsys::DynamicLoader::GetSymbolAddress(lib,
- initFuncName);
+ CM_INIT_FUNCTION initFunction = reinterpret_cast<CM_INIT_FUNCTION>(
+ cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName));
if (!initFunction) {
- initFuncName = "_";
- initFuncName += args[0];
- initFuncName += "Init";
- initFunction = (CM_INIT_FUNCTION)(
+ initFuncName = cmStrCat('_', args[0], "Init");
+ initFunction = reinterpret_cast<CM_INIT_FUNCTION>(
cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName));
}
// if the symbol is found call it to set the name on the
// function blocker
if (initFunction) {
- // create a function blocker and set it up
- cmLoadedCommand* f = new cmLoadedCommand();
- (*initFunction)(&f->info);
- this->Makefile->GetState()->AddScriptedCommand(args[0], f);
+ status.GetMakefile().GetState()->AddScriptedCommand(
+ args[0],
+ cmLegacyCommandWrapper(cm::make_unique<cmLoadedCommand>(initFunction)));
return true;
}
- this->SetError("Attempt to load command failed. "
- "No init function found.");
+ status.SetError("Attempt to load command failed. "
+ "No init function found.");
return false;
}
diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h
index 030786e3d..f5fd754b1 100644
--- a/Source/cmLoadCommandCommand.h
+++ b/Source/cmLoadCommandCommand.h
@@ -3,21 +3,14 @@
#ifndef cmLoadCommandCommand_h
#define cmLoadCommandCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmLoadCommandCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmLoadCommandCommand; }
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmLoadCommandCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx
index 6524db401..f86955dd0 100644
--- a/Source/cmLocalCommonGenerator.cxx
+++ b/Source/cmLocalCommonGenerator.cxx
@@ -2,19 +2,20 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLocalCommonGenerator.h"
+#include <utility>
#include <vector>
#include "cmGeneratorTarget.h"
#include "cmMakefile.h"
#include "cmOutputConverter.h"
+#include "cmStringAlgorithms.h"
class cmGlobalGenerator;
cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
- cmMakefile* mf,
- std::string const& wd)
+ cmMakefile* mf, std::string wd)
: cmLocalGenerator(gg, mf)
- , WorkingDirectory(wd)
+ , WorkingDirectory(std::move(wd))
{
// Store the configuration name that will be generated.
if (const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) {
@@ -22,13 +23,11 @@ cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
this->ConfigName = config;
} else {
// No configuration type given.
- this->ConfigName = "";
+ this->ConfigName.clear();
}
}
-cmLocalCommonGenerator::~cmLocalCommonGenerator()
-{
-}
+cmLocalCommonGenerator::~cmLocalCommonGenerator() = default;
std::string cmLocalCommonGenerator::GetTargetFortranFlags(
cmGeneratorTarget const* target, std::string const& config)
@@ -36,27 +35,24 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags(
std::string flags;
// Enable module output if necessary.
- if (const char* modout_flag =
- this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG")) {
- this->AppendFlags(flags, modout_flag);
- }
+ this->AppendFlags(
+ flags, this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODOUT_FLAG"));
// Add a module output directory flag if necessary.
std::string mod_dir =
target->GetFortranModuleDirectory(this->WorkingDirectory);
if (!mod_dir.empty()) {
mod_dir = this->ConvertToOutputFormat(
- this->ConvertToRelativePath(this->WorkingDirectory, mod_dir),
+ this->MaybeConvertToRelativePath(this->WorkingDirectory, mod_dir),
cmOutputConverter::SHELL);
} else {
mod_dir =
this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
}
if (!mod_dir.empty()) {
- const char* moddir_flag =
- this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG");
- std::string modflag = moddir_flag;
- modflag += mod_dir;
+ std::string modflag = cmStrCat(
+ this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG"),
+ mod_dir);
this->AppendFlags(flags, modflag);
}
@@ -67,13 +63,27 @@ std::string cmLocalCommonGenerator::GetTargetFortranFlags(
this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) {
std::vector<std::string> includes;
this->GetIncludeDirectories(includes, target, "C", config);
- for (std::vector<std::string>::const_iterator idi = includes.begin();
- idi != includes.end(); ++idi) {
- std::string flg = modpath_flag;
- flg += this->ConvertToOutputFormat(*idi, cmOutputConverter::SHELL);
+ for (std::string const& id : includes) {
+ std::string flg =
+ cmStrCat(modpath_flag,
+ this->ConvertToOutputFormat(id, cmOutputConverter::SHELL));
this->AppendFlags(flags, flg);
}
}
return flags;
}
+
+void cmLocalCommonGenerator::ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt)
+{
+ // Determine if these object files should use a custom extension
+ char const* custom_ext = gt->GetCustomObjectExtension();
+ for (auto& si : mapping) {
+ cmSourceFile const* sf = si.first;
+ bool keptSourceExtension;
+ si.second = this->GetObjectFileNameWithoutTarget(
+ *sf, gt->ObjectDirectory, &keptSourceExtension, custom_ext);
+ }
+}
diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h
index a5afcd87d..eaef6ab53 100644
--- a/Source/cmLocalCommonGenerator.h
+++ b/Source/cmLocalCommonGenerator.h
@@ -3,8 +3,9 @@
#ifndef cmLocalCommonGenerator_h
#define cmLocalCommonGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <map>
#include <string>
#include "cmLocalGenerator.h"
@@ -12,6 +13,7 @@
class cmGeneratorTarget;
class cmGlobalGenerator;
class cmMakefile;
+class cmSourceFile;
/** \class cmLocalCommonGenerator
* \brief Common infrastructure for Makefile and Ninja local generators.
@@ -20,15 +22,19 @@ class cmLocalCommonGenerator : public cmLocalGenerator
{
public:
cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf,
- std::string const& wd);
- ~cmLocalCommonGenerator() CM_OVERRIDE;
+ std::string wd);
+ ~cmLocalCommonGenerator() override;
- std::string const& GetConfigName() { return this->ConfigName; }
+ std::string const& GetConfigName() const { return this->ConfigName; }
std::string GetWorkingDirectory() const { return this->WorkingDirectory; }
std::string GetTargetFortranFlags(cmGeneratorTarget const* target,
- std::string const& config) CM_OVERRIDE;
+ std::string const& config) override;
+
+ void ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt = nullptr) override;
protected:
std::string WorkingDirectory;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 6ce31c5ea..ffd46d454 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -2,10 +2,16 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLocalGenerator.h"
+#include "cmsys/RegularExpression.hxx"
+
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
+#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
+#include "cmCustomCommandLines.h"
+#include "cmCustomCommandTypes.h"
#include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpression.h"
#include "cmGeneratorExpressionEvaluationFile.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
@@ -13,35 +19,44 @@
#include "cmInstallScriptGenerator.h"
#include "cmInstallTargetGenerator.h"
#include "cmLinkLineComputer.h"
+#include "cmLinkLineDeviceComputer.h"
#include "cmMakefile.h"
#include "cmRulePlaceholderExpander.h"
#include "cmSourceFile.h"
+#include "cmSourceFileLocation.h"
+#include "cmSourceFileLocationKind.h"
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTestGenerator.h"
#include "cmVersion.h"
#include "cmake.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#define CM_LG_ENCODE_OBJECT_NAMES
-#include "cmCryptoHash.h"
+#if !defined(CMAKE_BOOTSTRAP)
+# define CM_LG_ENCODE_OBJECT_NAMES
+# include "cmCryptoHash.h"
#endif
-#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <initializer_list>
#include <iterator>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
+#include <unordered_set>
#include <utility>
+#include <vector>
+
+#include <cm/string_view>
#if defined(__HAIKU__)
-#include <FindDirectory.h>
-#include <StorageDefs.h>
+# include <FindDirectory.h>
+# include <StorageDefs.h>
#endif
// List of variables that are replaced when
@@ -49,24 +64,23 @@
// replaced in the form <var> with GetSafeDefinition(var).
// ${LANG} is replaced in the variable first with all enabled
// languages.
-static const char* ruleReplaceVars[] = {
- "CMAKE_${LANG}_COMPILER",
- "CMAKE_SHARED_LIBRARY_CREATE_${LANG}_FLAGS",
- "CMAKE_SHARED_MODULE_CREATE_${LANG}_FLAGS",
- "CMAKE_SHARED_MODULE_${LANG}_FLAGS",
- "CMAKE_SHARED_LIBRARY_${LANG}_FLAGS",
- "CMAKE_${LANG}_LINK_FLAGS",
- "CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG",
- "CMAKE_${LANG}_ARCHIVE",
- "CMAKE_AR",
- "CMAKE_CURRENT_SOURCE_DIR",
- "CMAKE_CURRENT_BINARY_DIR",
- "CMAKE_RANLIB",
- "CMAKE_LINKER",
- "CMAKE_CUDA_HOST_COMPILER",
- "CMAKE_CUDA_HOST_LINK_LAUNCHER",
- "CMAKE_CL_SHOWINCLUDES_PREFIX"
-};
+static auto ruleReplaceVars = { "CMAKE_${LANG}_COMPILER",
+ "CMAKE_SHARED_LIBRARY_CREATE_${LANG}_FLAGS",
+ "CMAKE_SHARED_MODULE_CREATE_${LANG}_FLAGS",
+ "CMAKE_SHARED_MODULE_${LANG}_FLAGS",
+ "CMAKE_SHARED_LIBRARY_${LANG}_FLAGS",
+ "CMAKE_${LANG}_LINK_FLAGS",
+ "CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG",
+ "CMAKE_${LANG}_ARCHIVE",
+ "CMAKE_AR",
+ "CMAKE_CURRENT_SOURCE_DIR",
+ "CMAKE_CURRENT_BINARY_DIR",
+ "CMAKE_RANLIB",
+ "CMAKE_LINKER",
+ "CMAKE_MT",
+ "CMAKE_CUDA_HOST_COMPILER",
+ "CMAKE_CUDA_HOST_LINK_LAUNCHER",
+ "CMAKE_CL_SHOWINCLUDES_PREFIX" };
cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
: cmOutputConverter(makefile->GetStateSnapshot())
@@ -85,6 +99,19 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
this->ComputeObjectMaxPath();
+ // Canonicalize entries of the CPATH environment variable the same
+ // way detection of CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES does.
+ {
+ std::vector<std::string> cpath;
+ cmSystemTools::GetPath(cpath, "CPATH");
+ for (std::string& cp : cpath) {
+ if (cmSystemTools::FileIsFullPath(cp)) {
+ cp = cmSystemTools::CollapseFullPath(cp);
+ this->EnvCPATH.emplace(std::move(cp));
+ }
+ }
+ }
+
std::vector<std::string> enabledLanguages =
this->GetState()->GetEnabledLanguages();
@@ -102,9 +129,7 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
this->LinkerSysroot = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
}
- for (std::vector<std::string>::iterator i = enabledLanguages.begin();
- i != enabledLanguages.end(); ++i) {
- std::string const& lang = *i;
+ for (std::string const& lang : enabledLanguages) {
if (lang == "NONE") {
continue;
}
@@ -137,15 +162,13 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
this->VariableMappings[compilerOptionSysroot] =
this->Makefile->GetSafeDefinition(compilerOptionSysroot);
- for (const char* const* replaceIter = cmArrayBegin(ruleReplaceVars);
- replaceIter != cmArrayEnd(ruleReplaceVars); ++replaceIter) {
- std::string actualReplace = *replaceIter;
- if (actualReplace.find("${LANG}") != std::string::npos) {
- cmSystemTools::ReplaceString(actualReplace, "${LANG}", lang);
+ for (std::string replaceVar : ruleReplaceVars) {
+ if (replaceVar.find("${LANG}") != std::string::npos) {
+ cmSystemTools::ReplaceString(replaceVar, "${LANG}", lang);
}
- this->VariableMappings[actualReplace] =
- this->Makefile->GetSafeDefinition(actualReplace);
+ this->VariableMappings[replaceVar] =
+ this->Makefile->GetSafeDefinition(replaceVar);
}
}
}
@@ -164,7 +187,7 @@ cmLocalGenerator::~cmLocalGenerator()
cmDeleteAll(this->OwnedImportedGeneratorTargets);
}
-void cmLocalGenerator::IssueMessage(cmake::MessageType t,
+void cmLocalGenerator::IssueMessage(MessageType t,
std::string const& text) const
{
this->GetCMakeInstance()->IssueMessage(t, text, this->DirectoryBacktrace);
@@ -189,38 +212,63 @@ void cmLocalGenerator::ComputeObjectMaxPath()
w << "CMAKE_OBJECT_PATH_MAX is set to " << pmax
<< ", which is less than the minimum of 128. "
<< "The value will be ignored.";
- this->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
}
} else {
std::ostringstream w;
w << "CMAKE_OBJECT_PATH_MAX is set to \"" << plen
<< "\", which fails to parse as a positive integer. "
<< "The value will be ignored.";
- this->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
}
}
this->ObjectMaxPathViolations.clear();
}
-void cmLocalGenerator::TraceDependencies()
+static void MoveSystemIncludesToEnd(std::vector<std::string>& includeDirs,
+ const std::string& config,
+ const std::string& lang,
+ const cmGeneratorTarget* target)
{
- std::vector<std::string> configs;
- this->Makefile->GetConfigurations(configs);
- if (configs.empty()) {
- configs.push_back("");
+ if (!target) {
+ return;
}
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
- this->GlobalGenerator->CreateEvaluationSourceFiles(*ci);
+
+ std::stable_sort(
+ includeDirs.begin(), includeDirs.end(),
+ [&target, &config, &lang](std::string const& a, std::string const& b) {
+ return !target->IsSystemIncludeDirectory(a, config, lang) &&
+ target->IsSystemIncludeDirectory(b, config, lang);
+ });
+}
+
+static void MoveSystemIncludesToEnd(std::vector<BT<std::string>>& includeDirs,
+ const std::string& config,
+ const std::string& lang,
+ const cmGeneratorTarget* target)
+{
+ if (!target) {
+ return;
}
+
+ std::stable_sort(includeDirs.begin(), includeDirs.end(),
+ [target, &config, &lang](BT<std::string> const& a,
+ BT<std::string> const& b) {
+ return !target->IsSystemIncludeDirectory(a.Value, config,
+ lang) &&
+ target->IsSystemIncludeDirectory(b.Value, config, lang);
+ });
+}
+
+void cmLocalGenerator::TraceDependencies()
+{
// Generate the rule files for each target.
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
- t != targets.end(); ++t) {
- if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- (*t)->TraceDependencies();
+ target->TraceDependencies();
}
}
@@ -235,11 +283,11 @@ void cmLocalGenerator::GenerateTestFiles()
const std::string& config =
this->Makefile->GetConfigurations(configurationTypes, false);
- std::string file = this->StateSnapshot.GetDirectory().GetCurrentBinary();
- file += "/";
- file += "CTestTestfile.cmake";
+ std::string file =
+ cmStrCat(this->StateSnapshot.GetDirectory().GetCurrentBinary(),
+ "/CTestTestfile.cmake");
- cmGeneratedFileStream fout(file.c_str());
+ cmGeneratedFileStream fout(file);
fout.SetCopyIfDifferent(true);
fout << "# CMake generated Testfile for " << std::endl
@@ -259,50 +307,81 @@ void cmLocalGenerator::GenerateTestFiles()
fout << "include(\"" << testIncludeFile << "\")" << std::endl;
}
+ const char* testIncludeFiles =
+ this->Makefile->GetProperty("TEST_INCLUDE_FILES");
+ if (testIncludeFiles) {
+ std::vector<std::string> includesList = cmExpandedList(testIncludeFiles);
+ for (std::string const& i : includesList) {
+ fout << "include(\"" << i << "\")" << std::endl;
+ }
+ }
+
// Ask each test generator to write its code.
std::vector<cmTestGenerator*> const& testers =
this->Makefile->GetTestGenerators();
- for (std::vector<cmTestGenerator*>::const_iterator gi = testers.begin();
- gi != testers.end(); ++gi) {
- (*gi)->Compute(this);
- (*gi)->Generate(fout, config, configurationTypes);
+ for (cmTestGenerator* tester : testers) {
+ tester->Compute(this);
+ tester->Generate(fout, config, configurationTypes);
}
- typedef std::vector<cmStateSnapshot> vec_t;
+ using vec_t = std::vector<cmStateSnapshot>;
vec_t const& children = this->Makefile->GetStateSnapshot().GetChildren();
std::string parentBinDir = this->GetCurrentBinaryDirectory();
- for (vec_t::const_iterator i = children.begin(); i != children.end(); ++i) {
+ for (cmStateSnapshot const& i : children) {
// TODO: Use add_subdirectory instead?
- std::string outP = i->GetDirectory().GetCurrentBinary();
- outP = this->ConvertToRelativePath(parentBinDir, outP);
+ std::string outP = i.GetDirectory().GetCurrentBinary();
+ outP = this->MaybeConvertToRelativePath(parentBinDir, outP);
outP = cmOutputConverter::EscapeForCMake(outP);
fout << "subdirs(" << outP << ")" << std::endl;
}
+
+ // Add directory labels property
+ const char* directoryLabels =
+ this->Makefile->GetDefinition("CMAKE_DIRECTORY_LABELS");
+ const char* labels = this->Makefile->GetProperty("LABELS");
+
+ if (labels || directoryLabels) {
+ fout << "set_directory_properties(PROPERTIES LABELS ";
+ if (labels) {
+ fout << cmOutputConverter::EscapeForCMake(labels);
+ }
+ if (labels && directoryLabels) {
+ fout << ";";
+ }
+ if (directoryLabels) {
+ fout << cmOutputConverter::EscapeForCMake(directoryLabels);
+ }
+ fout << ")" << std::endl;
+ }
+}
+
+void cmLocalGenerator::CreateEvaluationFileOutputs()
+{
+ std::vector<std::string> const& configs =
+ this->Makefile->GetGeneratorConfigs();
+ for (std::string const& c : configs) {
+ this->CreateEvaluationFileOutputs(c);
+ }
}
void cmLocalGenerator::CreateEvaluationFileOutputs(std::string const& config)
{
std::vector<cmGeneratorExpressionEvaluationFile*> ef =
this->Makefile->GetEvaluationFiles();
- for (std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator li =
- ef.begin();
- li != ef.end(); ++li) {
- (*li)->CreateOutputFile(this, config);
+ for (cmGeneratorExpressionEvaluationFile* geef : ef) {
+ geef->CreateOutputFile(this, config);
}
}
void cmLocalGenerator::ProcessEvaluationFiles(
std::vector<std::string>& generatedFiles)
{
- std::vector<cmGeneratorExpressionEvaluationFile*> ef =
- this->Makefile->GetEvaluationFiles();
- for (std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator li =
- ef.begin();
- li != ef.end(); ++li) {
- (*li)->Generate(this);
+ for (cmGeneratorExpressionEvaluationFile* geef :
+ this->Makefile->GetEvaluationFiles()) {
+ geef->Generate(this);
if (cmSystemTools::GetFatalErrorOccured()) {
return;
}
- std::vector<std::string> files = (*li)->GetFiles();
+ std::vector<std::string> files = geef->GetFiles();
std::sort(files.begin(), files.end());
std::vector<std::string> intersection;
@@ -311,15 +390,15 @@ void cmLocalGenerator::ProcessEvaluationFiles(
std::back_inserter(intersection));
if (!intersection.empty()) {
cmSystemTools::Error("Files to be generated by multiple different "
- "commands: ",
- cmWrap('"', intersection, '"', " ").c_str());
+ "commands: " +
+ cmWrap('"', intersection, '"', " "));
return;
}
- generatedFiles.insert(generatedFiles.end(), files.begin(), files.end());
- std::vector<std::string>::iterator newIt =
- generatedFiles.end() - files.size();
- std::inplace_merge(generatedFiles.begin(), newIt, generatedFiles.end());
+ cmAppend(generatedFiles, files);
+ std::inplace_merge(generatedFiles.begin(),
+ generatedFiles.end() - files.size(),
+ generatedFiles.end());
}
}
@@ -327,6 +406,7 @@ void cmLocalGenerator::GenerateInstallRules()
{
// Compute the install prefix.
const char* prefix = this->Makefile->GetDefinition("CMAKE_INSTALL_PREFIX");
+
#if defined(_WIN32) && !defined(__CYGWIN__)
std::string prefix_win32;
if (!prefix) {
@@ -370,12 +450,11 @@ void cmLocalGenerator::GenerateInstallRules()
// Choose a default install configuration.
std::string default_config = config;
const char* default_order[] = { "RELEASE", "MINSIZEREL", "RELWITHDEBINFO",
- "DEBUG", CM_NULLPTR };
+ "DEBUG", nullptr };
for (const char** c = default_order; *c && default_config.empty(); ++c) {
- for (std::vector<std::string>::iterator i = configurationTypes.begin();
- i != configurationTypes.end(); ++i) {
- if (cmSystemTools::UpperCase(*i) == *c) {
- default_config = *i;
+ for (std::string const& configurationType : configurationTypes) {
+ if (cmSystemTools::UpperCase(configurationType) == *c) {
+ default_config = configurationType;
}
}
}
@@ -391,7 +470,7 @@ void cmLocalGenerator::GenerateInstallRules()
toplevel_install = 1;
}
file += "/cmake_install.cmake";
- cmGeneratedFileStream fout(file.c_str());
+ cmGeneratedFileStream fout(file);
fout.SetCopyIfDifferent(true);
// Write the header.
@@ -402,7 +481,7 @@ void cmLocalGenerator::GenerateInstallRules()
<< "if(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl
<< " set(CMAKE_INSTALL_PREFIX \"" << prefix << "\")" << std::endl
<< "endif()" << std::endl
- << "string(REGEX REPLACE \"/$\" \"\" CMAKE_INSTALL_PREFIX "
+ << R"(string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX )"
<< "\"${CMAKE_INSTALL_PREFIX}\")" << std::endl
<< std::endl;
@@ -451,35 +530,90 @@ void cmLocalGenerator::GenerateInstallRules()
/* clang-format on */
}
+ // Copy cmake cross compile state to install code.
+ if (const char* crosscompiling =
+ this->Makefile->GetDefinition("CMAKE_CROSSCOMPILING")) {
+ /* clang-format off */
+ fout <<
+ "# Is this installation the result of a crosscompile?\n"
+ "if(NOT DEFINED CMAKE_CROSSCOMPILING)\n"
+ " set(CMAKE_CROSSCOMPILING \"" << crosscompiling << "\")\n"
+ "endif()\n"
+ "\n";
+ /* clang-format on */
+ }
+
+ // Write default directory permissions.
+ if (const char* defaultDirPermissions = this->Makefile->GetDefinition(
+ "CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS")) {
+ /* clang-format off */
+ fout <<
+ "# Set default install directory permissions.\n"
+ "if(NOT DEFINED CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS)\n"
+ " set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS \""
+ << defaultDirPermissions << "\")\n"
+ "endif()\n"
+ "\n";
+ /* clang-format on */
+ }
+
// Ask each install generator to write its code.
+ cmPolicies::PolicyStatus status = this->GetPolicyStatus(cmPolicies::CMP0082);
std::vector<cmInstallGenerator*> const& installers =
this->Makefile->GetInstallGenerators();
- for (std::vector<cmInstallGenerator*>::const_iterator gi =
- installers.begin();
- gi != installers.end(); ++gi) {
- (*gi)->Generate(fout, config, configurationTypes);
+ bool haveSubdirectoryInstall = false;
+ bool haveInstallAfterSubdirectory = false;
+ if (status == cmPolicies::WARN) {
+ for (cmInstallGenerator* installer : installers) {
+ installer->CheckCMP0082(haveSubdirectoryInstall,
+ haveInstallAfterSubdirectory);
+ installer->Generate(fout, config, configurationTypes);
+ }
+ } else {
+ for (cmInstallGenerator* installer : installers) {
+ installer->Generate(fout, config, configurationTypes);
+ }
}
// Write rules from old-style specification stored in targets.
this->GenerateTargetInstallRules(fout, config, configurationTypes);
// Include install scripts from subdirectories.
- std::vector<cmStateSnapshot> children =
- this->Makefile->GetStateSnapshot().GetChildren();
- if (!children.empty()) {
- fout << "if(NOT CMAKE_INSTALL_LOCAL_ONLY)\n";
- fout << " # Include the install script for each subdirectory.\n";
- for (std::vector<cmStateSnapshot>::const_iterator ci = children.begin();
- ci != children.end(); ++ci) {
- if (!ci->GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
- std::string odir = ci->GetDirectory().GetCurrentBinary();
- cmSystemTools::ConvertToUnixSlashes(odir);
- fout << " include(\"" << odir << "/cmake_install.cmake\")"
- << std::endl;
+ switch (status) {
+ case cmPolicies::WARN:
+ if (haveInstallAfterSubdirectory &&
+ this->Makefile->PolicyOptionalWarningEnabled(
+ "CMAKE_POLICY_WARNING_CMP0082")) {
+ std::ostringstream e;
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0082) << "\n";
+ this->IssueMessage(MessageType::AUTHOR_WARNING, e.str());
}
- }
- fout << "\n";
- fout << "endif()\n\n";
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD: {
+ std::vector<cmStateSnapshot> children =
+ this->Makefile->GetStateSnapshot().GetChildren();
+ if (!children.empty()) {
+ fout << "if(NOT CMAKE_INSTALL_LOCAL_ONLY)\n";
+ fout << " # Include the install script for each subdirectory.\n";
+ for (cmStateSnapshot const& c : children) {
+ if (!c.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
+ std::string odir = c.GetDirectory().GetCurrentBinary();
+ cmSystemTools::ConvertToUnixSlashes(odir);
+ fout << " include(\"" << odir << "/cmake_install.cmake\")"
+ << std::endl;
+ }
+ }
+ fout << "\n";
+ fout << "endif()\n\n";
+ }
+ } break;
+
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ // NEW behavior is handled in
+ // cmInstallSubdirectoryGenerator::GenerateScript()
+ break;
}
// Record the install manifest.
@@ -504,12 +638,13 @@ void cmLocalGenerator::GenerateInstallRules()
void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt)
{
this->GeneratorTargets.push_back(gt);
+ this->GeneratorTargetSearchIndex.emplace(gt->GetName(), gt);
this->GlobalGenerator->IndexGeneratorTarget(gt);
}
void cmLocalGenerator::AddImportedGeneratorTarget(cmGeneratorTarget* gt)
{
- this->ImportedGeneratorTargets.push_back(gt);
+ this->ImportedGeneratorTargets.emplace(gt->GetName(), gt);
this->GlobalGenerator->IndexGeneratorTarget(gt);
}
@@ -518,32 +653,14 @@ void cmLocalGenerator::AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt)
this->OwnedImportedGeneratorTargets.push_back(gt);
}
-struct NamedGeneratorTargetFinder
-{
- NamedGeneratorTargetFinder(std::string const& name)
- : Name(name)
- {
- }
-
- bool operator()(cmGeneratorTarget* tgt)
- {
- return tgt->GetName() == this->Name;
- }
-
-private:
- std::string Name;
-};
-
cmGeneratorTarget* cmLocalGenerator::FindLocalNonAliasGeneratorTarget(
const std::string& name) const
{
- std::vector<cmGeneratorTarget*>::const_iterator ti =
- std::find_if(this->GeneratorTargets.begin(), this->GeneratorTargets.end(),
- NamedGeneratorTargetFinder(name));
- if (ti != this->GeneratorTargets.end()) {
- return *ti;
+ auto ti = this->GeneratorTargetSearchIndex.find(name);
+ if (ti != this->GeneratorTargetSearchIndex.end()) {
+ return ti->second;
}
- return CM_NULLPTR;
+ return nullptr;
}
void cmLocalGenerator::ComputeTargetManifest()
@@ -552,21 +669,17 @@ void cmLocalGenerator::ComputeTargetManifest()
std::vector<std::string> configNames;
this->Makefile->GetConfigurations(configNames);
if (configNames.empty()) {
- configNames.push_back("");
+ configNames.emplace_back();
}
// Add our targets to the manifest for each configuration.
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* target = *t;
+ const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- for (std::vector<std::string>::iterator ci = configNames.begin();
- ci != configNames.end(); ++ci) {
- const char* config = ci->c_str();
- target->ComputeTargetManifest(config);
+ for (std::string const& c : configNames) {
+ target->ComputeTargetManifest(c);
}
}
}
@@ -577,20 +690,61 @@ bool cmLocalGenerator::ComputeTargetCompileFeatures()
std::vector<std::string> configNames;
this->Makefile->GetConfigurations(configNames);
if (configNames.empty()) {
- configNames.push_back("");
+ configNames.emplace_back();
+ }
+
+ using LanguagePair = std::pair<std::string, std::string>;
+ std::vector<LanguagePair> pairedLanguages{ { "OBJC", "C" },
+ { "OBJCXX", "CXX" } };
+ std::set<LanguagePair> objcEnabledLanguages;
+ for (auto const& lang : pairedLanguages) {
+ if (this->Makefile->GetState()->GetLanguageEnabled(lang.first)) {
+ objcEnabledLanguages.insert(lang);
+ }
}
// Process compile features of all targets.
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* target = *t;
- for (std::vector<std::string>::iterator ci = configNames.begin();
- ci != configNames.end(); ++ci) {
- if (!target->ComputeCompileFeatures(*ci)) {
+ const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
+ for (cmGeneratorTarget* target : targets) {
+ for (std::string const& c : configNames) {
+ if (!target->ComputeCompileFeatures(c)) {
return false;
}
}
+
+ // Now that C/C++ _STANDARD values have been computed
+ // set the values to ObjC/ObjCXX _STANDARD variables
+ if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ auto copyStandardToObjLang = [&](LanguagePair const& lang) -> bool {
+ if (!target->GetProperty(cmStrCat(lang.first, "_STANDARD"))) {
+ auto* standard =
+ target->GetProperty(cmStrCat(lang.second, "_STANDARD"));
+ if (!standard) {
+ standard = this->Makefile->GetDefinition(
+ cmStrCat("CMAKE_", lang.second, "_STANDARD_DEFAULT"));
+ }
+ target->Target->SetProperty(cmStrCat(lang.first, "_STANDARD"),
+ standard);
+ return true;
+ }
+ return false;
+ };
+ auto copyPropertyToObjLang = [&](LanguagePair const& lang,
+ const char* property) {
+ if (!target->GetProperty(cmStrCat(lang.first, property)) &&
+ target->GetProperty(cmStrCat(lang.second, property))) {
+ target->Target->SetProperty(
+ cmStrCat(lang.first, property),
+ target->GetProperty(cmStrCat(lang.second, property)));
+ }
+ };
+ for (auto const& lang : objcEnabledLanguages) {
+ if (copyStandardToObjLang(lang)) {
+ copyPropertyToObjLang(lang, "_STANDARD_REQUIRED");
+ copyPropertyToObjLang(lang, "_EXTENSIONS");
+ }
+ }
+ }
}
return true;
@@ -628,7 +782,7 @@ std::string cmLocalGenerator::ConvertToIncludeReference(
}
std::string cmLocalGenerator::GetIncludeFlags(
- const std::vector<std::string>& includes, cmGeneratorTarget* target,
+ const std::vector<std::string>& includeDirs, cmGeneratorTarget* target,
const std::string& lang, bool forceFullPaths, bool forResponseFile,
const std::string& config)
{
@@ -636,15 +790,16 @@ std::string cmLocalGenerator::GetIncludeFlags(
return "";
}
+ std::vector<std::string> includes = includeDirs;
+ MoveSystemIncludesToEnd(includes, config, lang, target);
+
OutputFormat shellFormat = forResponseFile ? RESPONSE : SHELL;
std::ostringstream includeFlags;
- std::string flagVar = "CMAKE_INCLUDE_FLAG_";
- flagVar += lang;
- const char* includeFlag = this->Makefile->GetSafeDefinition(flagVar);
- flagVar = "CMAKE_INCLUDE_FLAG_SEP_";
- flagVar += lang;
- const char* sep = this->Makefile->GetDefinition(flagVar);
+ std::string const& includeFlag =
+ this->Makefile->GetSafeDefinition(cmStrCat("CMAKE_INCLUDE_FLAG_", lang));
+ const char* sep =
+ this->Makefile->GetDefinition(cmStrCat("CMAKE_INCLUDE_FLAG_SEP_", lang));
bool quotePaths = false;
if (this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS")) {
quotePaths = true;
@@ -661,39 +816,30 @@ std::string cmLocalGenerator::GetIncludeFlags(
// Support special system include flag if it is available and the
// normal flag is repeated for each directory.
- std::string sysFlagVar = "CMAKE_INCLUDE_SYSTEM_FLAG_";
- sysFlagVar += lang;
- const char* sysIncludeFlag = CM_NULLPTR;
+ const char* sysIncludeFlag = nullptr;
if (repeatFlag) {
- sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar);
+ sysIncludeFlag = this->Makefile->GetDefinition(
+ cmStrCat("CMAKE_INCLUDE_SYSTEM_FLAG_", lang));
}
- std::string fwSearchFlagVar = "CMAKE_";
- fwSearchFlagVar += lang;
- fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG";
- const char* fwSearchFlag = this->Makefile->GetDefinition(fwSearchFlagVar);
-
- std::string sysFwSearchFlagVar = "CMAKE_";
- sysFwSearchFlagVar += lang;
- sysFwSearchFlagVar += "_SYSTEM_FRAMEWORK_SEARCH_FLAG";
- const char* sysFwSearchFlag =
- this->Makefile->GetDefinition(sysFwSearchFlagVar);
+ const char* fwSearchFlag = this->Makefile->GetDefinition(
+ cmStrCat("CMAKE_", lang, "_FRAMEWORK_SEARCH_FLAG"));
+ const char* sysFwSearchFlag = this->Makefile->GetDefinition(
+ cmStrCat("CMAKE_", lang, "_SYSTEM_FRAMEWORK_SEARCH_FLAG"));
bool flagUsed = false;
std::set<std::string> emitted;
#ifdef __APPLE__
emitted.insert("/System/Library/Frameworks");
#endif
- std::vector<std::string>::const_iterator i;
- for (i = includes.begin(); i != includes.end(); ++i) {
+ for (std::string const& i : includes) {
if (fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE") &&
- cmSystemTools::IsPathToFramework(i->c_str())) {
- std::string frameworkDir = *i;
- frameworkDir += "/../";
- frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
+ cmSystemTools::IsPathToFramework(i)) {
+ std::string const frameworkDir =
+ cmSystemTools::CollapseFullPath(cmStrCat(i, "/../"));
if (emitted.insert(frameworkDir).second) {
if (sysFwSearchFlag && target &&
- target->IsSystemIncludeDirectory(*i, config)) {
+ target->IsSystemIncludeDirectory(i, config, lang)) {
includeFlags << sysFwSearchFlag;
} else {
includeFlags << fwSearchFlag;
@@ -706,7 +852,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
if (!flagUsed || repeatFlag) {
if (sysIncludeFlag && target &&
- target->IsSystemIncludeDirectory(*i, config)) {
+ target->IsSystemIncludeDirectory(i, config, lang)) {
includeFlags << sysIncludeFlag;
} else {
includeFlags << includeFlag;
@@ -714,35 +860,35 @@ std::string cmLocalGenerator::GetIncludeFlags(
flagUsed = true;
}
std::string includePath =
- this->ConvertToIncludeReference(*i, shellFormat, forceFullPaths);
- if (quotePaths && !includePath.empty() && includePath[0] != '\"') {
+ this->ConvertToIncludeReference(i, shellFormat, forceFullPaths);
+ if (quotePaths && !includePath.empty() && includePath.front() != '\"') {
includeFlags << "\"";
}
includeFlags << includePath;
- if (quotePaths && !includePath.empty() && includePath[0] != '\"') {
+ if (quotePaths && !includePath.empty() && includePath.front() != '\"') {
includeFlags << "\"";
}
includeFlags << sep;
}
std::string flags = includeFlags.str();
// remove trailing separators
- if ((sep[0] != ' ') && !flags.empty() && flags[flags.size() - 1] == sep[0]) {
- flags[flags.size() - 1] = ' ';
+ if ((sep[0] != ' ') && !flags.empty() && flags.back() == sep[0]) {
+ flags.back() = ' ';
}
return flags;
}
-void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines,
- cmGeneratorTarget const* target,
- const std::string& config,
- const std::string& lang) const
+void cmLocalGenerator::AddCompileOptions(std::string& flags,
+ cmGeneratorTarget* target,
+ const std::string& lang,
+ const std::string& config)
{
- std::vector<std::string> targetDefines;
- target->GetCompileDefinitions(targetDefines, config, lang);
- this->AppendDefines(defines, targetDefines);
+ std::vector<BT<std::string>> tmpFlags;
+ this->AddCompileOptions(tmpFlags, target, lang, config);
+ this->AppendFlags(flags, tmpFlags);
}
-void cmLocalGenerator::AddCompileOptions(std::string& flags,
+void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags,
cmGeneratorTarget* target,
const std::string& lang,
const std::string& config)
@@ -752,74 +898,116 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags,
if (const char* langFlagRegexStr =
this->Makefile->GetDefinition(langFlagRegexVar)) {
// Filter flags acceptable to this language.
- cmsys::RegularExpression r(langFlagRegexStr);
- std::vector<std::string> opts;
if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) {
+ std::vector<std::string> opts;
cmSystemTools::ParseWindowsCommandLine(targetFlags, opts);
- }
- target->GetCompileOptions(opts, config, lang);
- for (std::vector<std::string>::const_iterator i = opts.begin();
- i != opts.end(); ++i) {
- if (r.find(i->c_str())) {
- // (Re-)Escape this flag. COMPILE_FLAGS were already parsed
- // as a command line above, and COMPILE_OPTIONS are escaped.
- this->AppendFlagEscape(flags, *i);
+ // Re-escape these flags since COMPILE_FLAGS were already parsed
+ // as a command line above.
+ std::string compileOpts;
+ this->AppendCompileOptions(compileOpts, opts, langFlagRegexStr);
+ if (!compileOpts.empty()) {
+ flags.emplace_back(std::move(compileOpts));
}
}
+ std::vector<BT<std::string>> targetCompileOpts =
+ target->GetCompileOptions(config, lang);
+ // COMPILE_OPTIONS are escaped.
+ this->AppendCompileOptions(flags, targetCompileOpts, langFlagRegexStr);
} else {
// Use all flags.
if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) {
// COMPILE_FLAGS are not escaped for historical reasons.
- this->AppendFlags(flags, targetFlags);
- }
- std::vector<std::string> opts;
- target->GetCompileOptions(opts, config, lang);
- for (std::vector<std::string>::const_iterator i = opts.begin();
- i != opts.end(); ++i) {
- // COMPILE_OPTIONS are escaped.
- this->AppendFlagEscape(flags, *i);
+ std::string compileFlags;
+ this->AppendFlags(compileFlags, targetFlags);
+ if (!compileFlags.empty()) {
+ flags.emplace_back(std::move(compileFlags));
+ }
}
+ std::vector<BT<std::string>> targetCompileOpts =
+ target->GetCompileOptions(config, lang);
+ // COMPILE_OPTIONS are escaped.
+ this->AppendCompileOptions(flags, targetCompileOpts);
}
- for (std::map<std::string, std::string>::const_iterator it =
- target->GetMaxLanguageStandards().begin();
- it != target->GetMaxLanguageStandards().end(); ++it) {
- const char* standard = target->GetProperty(it->first + "_STANDARD");
+ for (auto const& it : target->GetMaxLanguageStandards()) {
+ const char* standard = target->GetProperty(it.first + "_STANDARD");
if (!standard) {
continue;
}
- if (this->Makefile->IsLaterStandard(it->first, standard, it->second)) {
+ if (this->Makefile->IsLaterStandard(it.first, standard, it.second)) {
std::ostringstream e;
e << "The COMPILE_FEATURES property of target \"" << target->GetName()
<< "\" was evaluated when computing the link "
"implementation, and the \""
- << it->first << "_STANDARD\" was \"" << it->second
+ << it.first << "_STANDARD\" was \"" << it.second
<< "\" for that computation. Computing the "
"COMPILE_FEATURES based on the link implementation resulted in a "
"higher \""
- << it->first << "_STANDARD\" \"" << standard
+ << it.first << "_STANDARD\" \"" << standard
<< "\". "
"This is not permitted. The COMPILE_FEATURES may not both depend "
"on "
"and be depended on by the link implementation."
<< std::endl;
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
}
- this->AddCompilerRequirementFlag(flags, target, lang);
+
+ std::string compReqFlag;
+ this->AddCompilerRequirementFlag(compReqFlag, target, lang);
+ if (!compReqFlag.empty()) {
+ flags.emplace_back(std::move(compReqFlag));
+ }
+
+ // Add compile flag for the MSVC compiler only.
+ cmMakefile* mf = this->GetMakefile();
+ if (const char* jmc =
+ mf->GetDefinition("CMAKE_" + lang + "_COMPILE_OPTIONS_JMC")) {
+
+ // Handle Just My Code debugging flags, /JMC.
+ // If the target is a Managed C++ one, /JMC is not compatible.
+ if (target->GetManagedType(config) !=
+ cmGeneratorTarget::ManagedType::Managed) {
+ // add /JMC flags if target property VS_JUST_MY_CODE_DEBUGGING is set
+ // to ON
+ if (char const* jmcExprGen =
+ target->GetProperty("VS_JUST_MY_CODE_DEBUGGING")) {
+ std::string isJMCEnabled =
+ cmGeneratorExpression::Evaluate(jmcExprGen, this, config);
+ if (cmIsOn(isJMCEnabled)) {
+ std::vector<std::string> optVec = cmExpandedList(jmc);
+ std::string jmcFlags;
+ this->AppendCompileOptions(jmcFlags, optVec);
+ if (!jmcFlags.empty()) {
+ flags.emplace_back(std::move(jmcFlags));
+ }
+ }
+ }
+ }
+ }
}
-void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
- cmGeneratorTarget const* target,
- const std::string& lang,
- const std::string& config,
- bool stripImplicitInclDirs) const
+std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
+ cmGeneratorTarget const* target, std::string const& lang,
+ std::string const& config, bool stripImplicitDirs,
+ bool appendAllImplicitDirs) const
{
- // Need to decide whether to automatically include the source and
- // binary directories at the beginning of the include path.
- bool includeSourceDir = false;
- bool includeBinaryDir = false;
+ std::vector<BT<std::string>> result;
+ // Do not repeat an include path.
+ std::set<std::string> emitted;
+
+ auto emitDir = [&result, &emitted](std::string const& dir) {
+ if (emitted.insert(dir).second) {
+ result.emplace_back(dir);
+ }
+ };
+
+ auto emitBT = [&result, &emitted](BT<std::string> const& dir) {
+ if (emitted.insert(dir.Value).second) {
+ result.emplace_back(dir);
+ }
+ };
// When automatic include directories are requested for a build then
// include the source and binary directories at the beginning of the
@@ -829,130 +1017,228 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
// cannot fix this because not all native build tools support
// per-source-file include paths.
if (this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR")) {
- includeSourceDir = true;
- includeBinaryDir = true;
- }
-
- // Do not repeat an include path.
- std::set<std::string> emitted;
-
- // Store the automatic include paths.
- if (includeBinaryDir) {
- std::string binDir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
- if (emitted.find(binDir) == emitted.end()) {
- dirs.push_back(binDir);
- emitted.insert(binDir);
- }
- }
- if (includeSourceDir) {
- std::string srcDir = this->StateSnapshot.GetDirectory().GetCurrentSource();
- if (emitted.find(srcDir) == emitted.end()) {
- dirs.push_back(srcDir);
- emitted.insert(srcDir);
- }
+ // Current binary directory
+ emitDir(this->StateSnapshot.GetDirectory().GetCurrentBinary());
+ // Current source directory
+ emitDir(this->StateSnapshot.GetDirectory().GetCurrentSource());
}
if (!target) {
- return;
+ return result;
}
- std::string rootPath;
- if (const char* sysrootCompile =
- this->Makefile->GetDefinition("CMAKE_SYSROOT_COMPILE")) {
- rootPath = sysrootCompile;
- } else {
- rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
+ // Standard include directories to be added unconditionally at the end.
+ // These are intended to simulate additional implicit include directories.
+ std::vector<std::string> userStandardDirs;
+ {
+ std::string const value = this->Makefile->GetSafeDefinition(
+ cmStrCat("CMAKE_", lang, "_STANDARD_INCLUDE_DIRECTORIES"));
+ cmExpandList(value, userStandardDirs);
+ for (std::string& usd : userStandardDirs) {
+ cmSystemTools::ConvertToUnixSlashes(usd);
+ }
}
+ // Implicit include directories
std::vector<std::string> implicitDirs;
- // Load implicit include directories for this language.
- std::string impDirVar = "CMAKE_";
- impDirVar += lang;
- impDirVar += "_IMPLICIT_INCLUDE_DIRECTORIES";
- if (const char* value = this->Makefile->GetDefinition(impDirVar)) {
- std::vector<std::string> impDirVec;
- cmSystemTools::ExpandListArgument(value, impDirVec);
- for (std::vector<std::string>::const_iterator i = impDirVec.begin();
- i != impDirVec.end(); ++i) {
- std::string d = rootPath + *i;
- cmSystemTools::ConvertToUnixSlashes(d);
- emitted.insert(d);
- if (!stripImplicitInclDirs) {
- implicitDirs.push_back(*i);
+ std::set<std::string> implicitSet;
+ // Include directories to be excluded as if they were implicit.
+ std::set<std::string> implicitExclude;
+ {
+ // Raw list of implicit include directories
+ // Start with "standard" directories that we unconditionally add below.
+ std::vector<std::string> impDirVec = userStandardDirs;
+
+ // Load implicit include directories for this language.
+ // We ignore this for Fortran because:
+ // * There are no standard library headers to avoid overriding.
+ // * Compilers like gfortran do not search their own implicit include
+ // directories for modules ('.mod' files).
+ if (lang != "Fortran") {
+ const char* value = this->Makefile->GetDefinition(
+ cmStrCat("CMAKE_", lang, "_IMPLICIT_INCLUDE_DIRECTORIES"));
+ if (value != nullptr) {
+ size_t const impDirVecOldSize = impDirVec.size();
+ cmExpandList(value, impDirVec);
+ // FIXME: Use cmRange with 'advance()' when it supports non-const.
+ for (size_t i = impDirVecOldSize; i < impDirVec.size(); ++i) {
+ cmSystemTools::ConvertToUnixSlashes(impDirVec[i]);
+ }
+ }
+ }
+
+ // The Platform/UnixPaths module used to hard-code /usr/include for C, CXX,
+ // and CUDA in CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES, but those
+ // variables are now computed. On macOS the /usr/include directory is
+ // inside the platform SDK so the computed value does not contain it
+ // directly. In this case adding -I/usr/include can hide SDK headers so we
+ // must still exclude it.
+ if ((lang == "C" || lang == "CXX" || lang == "CUDA") &&
+ !cmContains(impDirVec, "/usr/include") &&
+ std::find_if(impDirVec.begin(), impDirVec.end(),
+ [](std::string const& d) {
+ return cmHasLiteralSuffix(d, "/usr/include");
+ }) != impDirVec.end()) {
+ // Only exclude this hard coded path for backwards compatibility.
+ implicitExclude.emplace("/usr/include");
+ }
+
+ for (std::string const& i : impDirVec) {
+ if (implicitSet.insert(cmSystemTools::GetRealPath(i)).second) {
+ implicitDirs.emplace_back(i);
}
}
}
- // Get the target-specific include directories.
- std::vector<std::string> includes;
+ // Checks if this is not an excluded (implicit) include directory.
+ auto notExcluded = [this, &implicitSet, &implicitExclude,
+ &lang](std::string const& dir) {
+ return (
+ // Do not exclude directories that are not in an excluded set.
+ ((!cmContains(implicitSet, cmSystemTools::GetRealPath(dir))) &&
+ (!cmContains(implicitExclude, dir)))
+ // Do not exclude entries of the CPATH environment variable even though
+ // they are implicitly searched by the compiler. They are meant to be
+ // user-specified directories that can be re-ordered or converted to
+ // -isystem without breaking real compiler builtin headers.
+ || ((lang == "C" || lang == "CXX") && cmContains(this->EnvCPATH, dir)));
+ };
- includes = target->GetIncludeDirectories(config, lang);
+ // Get the target-specific include directories.
+ std::vector<BT<std::string>> userDirs =
+ target->GetIncludeDirectories(config, lang);
// Support putting all the in-project include directories first if
// it is requested by the project.
if (this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE")) {
- const char* topSourceDir = this->GetState()->GetSourceDirectory();
- const char* topBinaryDir = this->GetState()->GetBinaryDirectory();
- for (std::vector<std::string>::const_iterator i = includes.begin();
- i != includes.end(); ++i) {
+ std::string const& topSourceDir = this->GetState()->GetSourceDirectory();
+ std::string const& topBinaryDir = this->GetState()->GetBinaryDirectory();
+ for (BT<std::string> const& udr : userDirs) {
// Emit this directory only if it is a subdirectory of the
// top-level source or binary tree.
- if (cmSystemTools::ComparePath(*i, topSourceDir) ||
- cmSystemTools::ComparePath(*i, topBinaryDir) ||
- cmSystemTools::IsSubDirectory(*i, topSourceDir) ||
- cmSystemTools::IsSubDirectory(*i, topBinaryDir)) {
- if (emitted.insert(*i).second) {
- dirs.push_back(*i);
+ if (cmSystemTools::ComparePath(udr.Value, topSourceDir) ||
+ cmSystemTools::ComparePath(udr.Value, topBinaryDir) ||
+ cmSystemTools::IsSubDirectory(udr.Value, topSourceDir) ||
+ cmSystemTools::IsSubDirectory(udr.Value, topBinaryDir)) {
+ if (notExcluded(udr.Value)) {
+ emitBT(udr);
}
}
}
}
- // Construct the final ordered include directory list.
- for (std::vector<std::string>::const_iterator i = includes.begin();
- i != includes.end(); ++i) {
- if (emitted.insert(*i).second) {
- dirs.push_back(*i);
+ // Emit remaining non implicit user direcories.
+ for (BT<std::string> const& udr : userDirs) {
+ if (notExcluded(udr.Value)) {
+ emitBT(udr);
}
}
- // Add standard include directories for this language.
- // We do not filter out implicit directories here.
- std::string const standardIncludesVar =
- "CMAKE_" + lang + "_STANDARD_INCLUDE_DIRECTORIES";
- std::string const standardIncludes =
- this->Makefile->GetSafeDefinition(standardIncludesVar);
- std::vector<std::string>::size_type const before = includes.size();
- cmSystemTools::ExpandListArgument(standardIncludes, includes);
- for (std::vector<std::string>::iterator i = includes.begin() + before;
- i != includes.end(); ++i) {
- cmSystemTools::ConvertToUnixSlashes(*i);
- dirs.push_back(*i);
+ // Sort result
+ MoveSystemIncludesToEnd(result, config, lang, target);
+
+ // Append standard include directories for this language.
+ userDirs.reserve(userDirs.size() + userStandardDirs.size());
+ for (std::string& usd : userStandardDirs) {
+ emitDir(usd);
+ userDirs.emplace_back(std::move(usd));
}
- for (std::vector<std::string>::const_iterator i = implicitDirs.begin();
- i != implicitDirs.end(); ++i) {
- if (std::find(includes.begin(), includes.end(), *i) != includes.end()) {
- dirs.push_back(*i);
+ // Append compiler implicit include directories
+ if (!stripImplicitDirs) {
+ // Append implicit directories that were requested by the user only
+ for (BT<std::string> const& udr : userDirs) {
+ if (cmContains(implicitSet, cmSystemTools::GetRealPath(udr.Value))) {
+ emitBT(udr);
+ }
+ }
+ // Append remaining implicit directories (on demand)
+ if (appendAllImplicitDirs) {
+ for (std::string& imd : implicitDirs) {
+ emitDir(imd);
+ }
}
}
+
+ return result;
+}
+
+void cmLocalGenerator::GetIncludeDirectoriesImplicit(
+ std::vector<std::string>& dirs, cmGeneratorTarget const* target,
+ const std::string& lang, const std::string& config, bool stripImplicitDirs,
+ bool appendAllImplicitDirs) const
+{
+ std::vector<BT<std::string>> tmp = this->GetIncludeDirectoriesImplicit(
+ target, lang, config, stripImplicitDirs, appendAllImplicitDirs);
+ dirs.reserve(dirs.size() + tmp.size());
+ for (BT<std::string>& v : tmp) {
+ dirs.emplace_back(std::move(v.Value));
+ }
+}
+
+std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories(
+ cmGeneratorTarget const* target, std::string const& lang,
+ std::string const& config) const
+{
+ return this->GetIncludeDirectoriesImplicit(target, lang, config);
+}
+
+void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
+ cmGeneratorTarget const* target,
+ const std::string& lang,
+ const std::string& config) const
+{
+ this->GetIncludeDirectoriesImplicit(dirs, target, lang, config);
}
void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags,
std::string const& config,
+ std::string const& linkLanguage,
cmGeneratorTarget* target)
{
- this->AppendFlags(
- flags, this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS"));
- if (!config.empty()) {
- std::string name = "CMAKE_STATIC_LINKER_FLAGS_" + config;
- this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name));
+ std::vector<BT<std::string>> tmpFlags =
+ this->GetStaticLibraryFlags(config, linkLanguage, target);
+ this->AppendFlags(flags, tmpFlags);
+}
+
+std::vector<BT<std::string>> cmLocalGenerator::GetStaticLibraryFlags(
+ std::string const& config, std::string const& linkLanguage,
+ cmGeneratorTarget* target)
+{
+ std::vector<BT<std::string>> flags;
+ if (linkLanguage != "Swift") {
+ std::string staticLibFlags;
+ this->AppendFlags(
+ staticLibFlags,
+ this->Makefile->GetSafeDefinition("CMAKE_STATIC_LINKER_FLAGS"));
+ if (!config.empty()) {
+ std::string name = "CMAKE_STATIC_LINKER_FLAGS_" + config;
+ this->AppendFlags(staticLibFlags,
+ this->Makefile->GetSafeDefinition(name));
+ }
+ if (!staticLibFlags.empty()) {
+ flags.emplace_back(std::move(staticLibFlags));
+ }
}
- this->AppendFlags(flags, target->GetProperty("STATIC_LIBRARY_FLAGS"));
+
+ std::string staticLibFlags;
+ this->AppendFlags(staticLibFlags,
+ target->GetSafeProperty("STATIC_LIBRARY_FLAGS"));
if (!config.empty()) {
std::string name = "STATIC_LIBRARY_FLAGS_" + config;
- this->AppendFlags(flags, target->GetProperty(name));
+ this->AppendFlags(staticLibFlags, target->GetSafeProperty(name));
+ }
+
+ if (!staticLibFlags.empty()) {
+ flags.emplace_back(std::move(staticLibFlags));
}
+
+ std::vector<BT<std::string>> staticLibOpts =
+ target->GetStaticLibraryLinkOptions(config, linkLanguage);
+ // STATIC_LIBRARY_OPTIONS are escaped.
+ this->AppendCompileOptions(flags, staticLibOpts);
+
+ return flags;
}
void cmLocalGenerator::GetTargetFlags(
@@ -960,6 +1246,22 @@ void cmLocalGenerator::GetTargetFlags(
std::string& linkLibs, std::string& flags, std::string& linkFlags,
std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target)
{
+ std::vector<BT<std::string>> linkFlagsList;
+ std::vector<BT<std::string>> linkPathList;
+ std::vector<BT<std::string>> linkLibsList;
+ this->GetTargetFlags(linkLineComputer, config, linkLibsList, flags,
+ linkFlagsList, frameworkPath, linkPathList, target);
+ this->AppendFlags(linkFlags, linkFlagsList);
+ this->AppendFlags(linkPath, linkPathList);
+ this->AppendFlags(linkLibs, linkLibsList);
+}
+
+void cmLocalGenerator::GetTargetFlags(
+ cmLinkLineComputer* linkLineComputer, const std::string& config,
+ std::vector<BT<std::string>>& linkLibs, std::string& flags,
+ std::vector<BT<std::string>>& linkFlags, std::string& frameworkPath,
+ std::vector<BT<std::string>>& linkPath, cmGeneratorTarget* target)
+{
const std::string buildType = cmSystemTools::UpperCase(config);
cmComputeLinkInformation* pcli = target->GetLinkInformation(config);
const char* libraryLinkVariable =
@@ -970,129 +1272,161 @@ void cmLocalGenerator::GetTargetFlags(
switch (target->GetType()) {
case cmStateEnums::STATIC_LIBRARY:
- this->GetStaticLibraryFlags(linkFlags, buildType, target);
+ linkFlags = this->GetStaticLibraryFlags(buildType, linkLanguage, target);
+ if (pcli && dynamic_cast<cmLinkLineDeviceComputer*>(linkLineComputer)) {
+ // Compute the required cuda device link libraries when
+ // resolving cuda device symbols
+ this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
+ frameworkPath, linkPath);
+ }
break;
case cmStateEnums::MODULE_LIBRARY:
libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS";
CM_FALLTHROUGH;
case cmStateEnums::SHARED_LIBRARY: {
- linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable);
- linkFlags += " ";
- if (!buildType.empty()) {
- std::string build = libraryLinkVariable;
- build += "_";
- build += buildType;
- linkFlags += this->Makefile->GetSafeDefinition(build);
- linkFlags += " ";
- }
- if (this->Makefile->IsOn("WIN32") &&
- !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) {
- std::vector<cmSourceFile*> sources;
- target->GetSourceFiles(sources, buildType);
- std::string defFlag =
- this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
- for (std::vector<cmSourceFile*>::const_iterator i = sources.begin();
- i != sources.end(); ++i) {
- cmSourceFile* sf = *i;
- if (sf->GetExtension() == "def") {
- linkFlags += defFlag;
- linkFlags += this->ConvertToOutputFormat(
- cmSystemTools::CollapseFullPath(sf->GetFullPath()), SHELL);
- linkFlags += " ";
+ std::string sharedLibFlags;
+ if (linkLanguage != "Swift") {
+ sharedLibFlags = cmStrCat(
+ this->Makefile->GetSafeDefinition(libraryLinkVariable), ' ');
+ if (!buildType.empty()) {
+ std::string build = cmStrCat(libraryLinkVariable, '_', buildType);
+ sharedLibFlags += this->Makefile->GetSafeDefinition(build);
+ sharedLibFlags += " ";
+ }
+ if (this->Makefile->IsOn("WIN32") &&
+ !(this->Makefile->IsOn("CYGWIN") ||
+ this->Makefile->IsOn("MINGW"))) {
+ std::vector<cmSourceFile*> sources;
+ target->GetSourceFiles(sources, buildType);
+ std::string defFlag =
+ this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
+ for (cmSourceFile* sf : sources) {
+ if (sf->GetExtension() == "def") {
+ sharedLibFlags += defFlag;
+ sharedLibFlags += this->ConvertToOutputFormat(
+ cmSystemTools::CollapseFullPath(sf->ResolveFullPath()), SHELL);
+ sharedLibFlags += " ";
+ }
}
}
}
+
const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
if (targetLinkFlags) {
- linkFlags += targetLinkFlags;
- linkFlags += " ";
+ sharedLibFlags += targetLinkFlags;
+ sharedLibFlags += " ";
}
if (!buildType.empty()) {
- std::string configLinkFlags = "LINK_FLAGS_";
- configLinkFlags += buildType;
- targetLinkFlags = target->GetProperty(configLinkFlags);
+ targetLinkFlags =
+ target->GetProperty(cmStrCat("LINK_FLAGS_", buildType));
if (targetLinkFlags) {
- linkFlags += targetLinkFlags;
- linkFlags += " ";
+ sharedLibFlags += targetLinkFlags;
+ sharedLibFlags += " ";
}
}
+
+ if (!sharedLibFlags.empty()) {
+ linkFlags.emplace_back(std::move(sharedLibFlags));
+ }
+
+ std::vector<BT<std::string>> linkOpts =
+ target->GetLinkOptions(config, linkLanguage);
+ // LINK_OPTIONS are escaped.
+ this->AppendCompileOptions(linkFlags, linkOpts);
if (pcli) {
this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
frameworkPath, linkPath);
}
} break;
case cmStateEnums::EXECUTABLE: {
- linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
- linkFlags += " ";
- if (!buildType.empty()) {
- std::string build = "CMAKE_EXE_LINKER_FLAGS_";
- build += buildType;
- linkFlags += this->Makefile->GetSafeDefinition(build);
- linkFlags += " ";
- }
- if (linkLanguage.empty()) {
- cmSystemTools::Error(
- "CMake can not determine linker language for target: ",
- target->GetName().c_str());
- return;
+ std::string exeFlags;
+ if (linkLanguage != "Swift") {
+ exeFlags = this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
+ exeFlags += " ";
+ if (!buildType.empty()) {
+ exeFlags += this->Makefile->GetSafeDefinition(
+ cmStrCat("CMAKE_EXE_LINKER_FLAGS_", buildType));
+ exeFlags += " ";
+ }
+ if (linkLanguage.empty()) {
+ cmSystemTools::Error(
+ "CMake can not determine linker language for target: " +
+ target->GetName());
+ return;
+ }
+
+ if (target->GetPropertyAsBool("WIN32_EXECUTABLE")) {
+ exeFlags +=
+ this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE");
+ exeFlags += " ";
+ } else {
+ exeFlags +=
+ this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE");
+ exeFlags += " ";
+ }
+
+ if (target->IsExecutableWithExports()) {
+ exeFlags += this->Makefile->GetSafeDefinition(
+ cmStrCat("CMAKE_EXE_EXPORTS_", linkLanguage, "_FLAG"));
+ exeFlags += " ";
+ }
}
+
this->AddLanguageFlagsForLinking(flags, target, linkLanguage, buildType);
if (pcli) {
this->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
frameworkPath, linkPath);
}
- if (cmSystemTools::IsOn(
- this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) {
+
+ if (cmIsOn(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) {
std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") +
linkLanguage + std::string("_FLAGS");
- linkFlags += this->Makefile->GetSafeDefinition(sFlagVar);
- linkFlags += " ";
- }
- if (target->GetPropertyAsBool("WIN32_EXECUTABLE")) {
- linkFlags +=
- this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE");
- linkFlags += " ";
- } else {
- linkFlags +=
- this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE");
- linkFlags += " ";
- }
- if (target->IsExecutableWithExports()) {
- std::string exportFlagVar = "CMAKE_EXE_EXPORTS_";
- exportFlagVar += linkLanguage;
- exportFlagVar += "_FLAG";
-
- linkFlags += this->Makefile->GetSafeDefinition(exportFlagVar);
- linkFlags += " ";
+ exeFlags += this->Makefile->GetSafeDefinition(sFlagVar);
+ exeFlags += " ";
}
std::string cmp0065Flags =
this->GetLinkLibsCMP0065(linkLanguage, *target);
if (!cmp0065Flags.empty()) {
- linkFlags += cmp0065Flags;
- linkFlags += " ";
+ exeFlags += cmp0065Flags;
+ exeFlags += " ";
}
const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
if (targetLinkFlags) {
- linkFlags += targetLinkFlags;
- linkFlags += " ";
+ exeFlags += targetLinkFlags;
+ exeFlags += " ";
}
if (!buildType.empty()) {
- std::string configLinkFlags = "LINK_FLAGS_";
- configLinkFlags += buildType;
- targetLinkFlags = target->GetProperty(configLinkFlags);
+ targetLinkFlags =
+ target->GetProperty(cmStrCat("LINK_FLAGS_", buildType));
if (targetLinkFlags) {
- linkFlags += targetLinkFlags;
- linkFlags += " ";
+ exeFlags += targetLinkFlags;
+ exeFlags += " ";
}
}
+
+ if (!exeFlags.empty()) {
+ linkFlags.emplace_back(std::move(exeFlags));
+ }
+
+ std::vector<BT<std::string>> linkOpts =
+ target->GetLinkOptions(config, linkLanguage);
+ // LINK_OPTIONS are escaped.
+ this->AppendCompileOptions(linkFlags, linkOpts);
} break;
default:
break;
}
- this->AppendIPOLinkerFlags(linkFlags, target, config, linkLanguage);
+ std::string extraLinkFlags;
+ this->AppendPositionIndependentLinkerFlags(extraLinkFlags, target, config,
+ linkLanguage);
+ this->AppendIPOLinkerFlags(extraLinkFlags, target, config, linkLanguage);
+
+ if (!extraLinkFlags.empty()) {
+ linkFlags.emplace_back(std::move(extraLinkFlags));
+ }
}
void cmLocalGenerator::GetTargetCompileFlags(cmGeneratorTarget* target,
@@ -1100,22 +1434,45 @@ void cmLocalGenerator::GetTargetCompileFlags(cmGeneratorTarget* target,
std::string const& lang,
std::string& flags)
{
+ std::vector<BT<std::string>> tmpFlags =
+ this->GetTargetCompileFlags(target, config, lang);
+ this->AppendFlags(flags, tmpFlags);
+}
+
+std::vector<BT<std::string>> cmLocalGenerator::GetTargetCompileFlags(
+ cmGeneratorTarget* target, std::string const& config,
+ std::string const& lang)
+{
+ std::vector<BT<std::string>> flags;
+ std::string compileFlags;
+
cmMakefile* mf = this->GetMakefile();
// Add language-specific flags.
- this->AddLanguageFlags(flags, target, lang, config);
+ this->AddLanguageFlags(compileFlags, target, lang, config);
+
+ if (target->IsIPOEnabled(lang, config)) {
+ this->AppendFeatureOptions(compileFlags, lang, "IPO");
+ }
- this->AddArchitectureFlags(flags, target, lang, config);
+ this->AddArchitectureFlags(compileFlags, target, lang, config);
if (lang == "Fortran") {
- this->AppendFlags(flags, this->GetTargetFortranFlags(target, config));
+ this->AppendFlags(compileFlags,
+ this->GetTargetFortranFlags(target, config));
}
- this->AddCMP0018Flags(flags, target, lang, config);
- this->AddVisibilityPresetFlags(flags, target, lang);
- this->AppendFlags(flags, mf->GetDefineFlags());
- this->AppendFlags(flags, this->GetFrameworkFlags(lang, config, target));
+ this->AddCMP0018Flags(compileFlags, target, lang, config);
+ this->AddVisibilityPresetFlags(compileFlags, target, lang);
+ this->AppendFlags(compileFlags, mf->GetDefineFlags());
+ this->AppendFlags(compileFlags,
+ this->GetFrameworkFlags(lang, config, target));
+
+ if (!compileFlags.empty()) {
+ flags.emplace_back(std::move(compileFlags));
+ }
this->AddCompileOptions(flags, target, lang, config);
+ return flags;
}
static std::string GetFrameworkFlags(const std::string& lang,
@@ -1144,11 +1501,9 @@ static std::string GetFrameworkFlags(const std::string& lang,
lg->GetIncludeDirectories(includes, target, "C", config);
// check all include directories for frameworks as this
// will already have added a -F for the framework
- for (std::vector<std::string>::iterator i = includes.begin();
- i != includes.end(); ++i) {
- if (lg->GetGlobalGenerator()->NameResolvesToFramework(*i)) {
- std::string frameworkDir = *i;
- frameworkDir += "/../";
+ for (std::string const& include : includes) {
+ if (lg->GetGlobalGenerator()->NameResolvesToFramework(include)) {
+ std::string frameworkDir = cmStrCat(include, "/../");
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
emitted.insert(frameworkDir);
}
@@ -1157,11 +1512,11 @@ static std::string GetFrameworkFlags(const std::string& lang,
std::string flags;
if (cmComputeLinkInformation* cli = target->GetLinkInformation(config)) {
std::vector<std::string> const& frameworks = cli->GetFrameworkPaths();
- for (std::vector<std::string>::const_iterator i = frameworks.begin();
- i != frameworks.end(); ++i) {
- if (emitted.insert(*i).second) {
+ for (std::string const& framework : frameworks) {
+ if (emitted.insert(framework).second) {
flags += fwSearchFlag;
- flags += lg->ConvertToOutputFormat(*i, cmOutputConverter::SHELL);
+ flags +=
+ lg->ConvertToOutputFormat(framework, cmOutputConverter::SHELL);
flags += " ";
}
}
@@ -1181,13 +1536,29 @@ void cmLocalGenerator::GetTargetDefines(cmGeneratorTarget const* target,
std::string const& lang,
std::set<std::string>& defines) const
{
+ std::set<BT<std::string>> tmp = this->GetTargetDefines(target, config, lang);
+ for (BT<std::string> const& v : tmp) {
+ defines.emplace(v.Value);
+ }
+}
+
+std::set<BT<std::string>> cmLocalGenerator::GetTargetDefines(
+ cmGeneratorTarget const* target, std::string const& config,
+ std::string const& lang) const
+{
+ std::set<BT<std::string>> defines;
+
// Add the export symbol definition for shared library objects.
- if (const char* exportMacro = target->GetExportMacro()) {
- this->AppendDefines(defines, exportMacro);
+ if (const std::string* exportMacro = target->GetExportMacro()) {
+ this->AppendDefines(defines, *exportMacro);
}
// Add preprocessor definitions for this target and configuration.
- this->AddCompileDefinitions(defines, target, config, lang);
+ std::vector<BT<std::string>> targetDefines =
+ target->GetCompileDefinitions(config, lang);
+ this->AppendDefines(defines, targetDefines);
+
+ return defines;
}
std::string cmLocalGenerator::GetTargetFortranFlags(
@@ -1207,36 +1578,53 @@ void cmLocalGenerator::OutputLinkLibraries(
std::string& linkLibraries, std::string& frameworkPath,
std::string& linkPath)
{
+ std::vector<BT<std::string>> linkLibrariesList;
+ std::vector<BT<std::string>> linkPathList;
+ this->OutputLinkLibraries(pcli, linkLineComputer, linkLibrariesList,
+ frameworkPath, linkPathList);
+ pcli->AppendValues(linkLibraries, linkLibrariesList);
+ pcli->AppendValues(linkPath, linkPathList);
+}
+
+void cmLocalGenerator::OutputLinkLibraries(
+ cmComputeLinkInformation* pcli, cmLinkLineComputer* linkLineComputer,
+ std::vector<BT<std::string>>& linkLibraries, std::string& frameworkPath,
+ std::vector<BT<std::string>>& linkPath)
+{
cmComputeLinkInformation& cli = *pcli;
std::string linkLanguage = cli.GetLinkLanguage();
- std::string libPathFlag =
- this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG");
- std::string libPathTerminator =
- this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR");
+ std::string libPathFlag;
+ if (const char* value = this->Makefile->GetDefinition(
+ "CMAKE_" + cli.GetLinkLanguage() + "_LIBRARY_PATH_FLAG")) {
+ libPathFlag = value;
+ } else {
+ libPathFlag =
+ this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG");
+ }
- // Add standard libraries for this language.
- std::string standardLibsVar = "CMAKE_";
- standardLibsVar += cli.GetLinkLanguage();
- standardLibsVar += "_STANDARD_LIBRARIES";
- std::string stdLibString;
- if (const char* stdLibs = this->Makefile->GetDefinition(standardLibsVar)) {
- stdLibString = stdLibs;
+ std::string libPathTerminator;
+ if (const char* value = this->Makefile->GetDefinition(
+ "CMAKE_" + cli.GetLinkLanguage() + "_LIBRARY_PATH_TERMINATOR")) {
+ libPathTerminator = value;
+ } else {
+ libPathTerminator =
+ this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_TERMINATOR");
}
+ // Add standard libraries for this language.
+ std::string stdLibString = this->Makefile->GetSafeDefinition(
+ cmStrCat("CMAKE_", cli.GetLinkLanguage(), "_STANDARD_LIBRARIES"));
+
// Append the framework search path flags.
- std::string fwSearchFlagVar = "CMAKE_";
- fwSearchFlagVar += linkLanguage;
- fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG";
- std::string fwSearchFlag =
- this->Makefile->GetSafeDefinition(fwSearchFlagVar);
+ std::string fwSearchFlag = this->Makefile->GetSafeDefinition(
+ cmStrCat("CMAKE_", linkLanguage, "_FRAMEWORK_SEARCH_FLAG"));
frameworkPath = linkLineComputer->ComputeFrameworkPath(cli, fwSearchFlag);
- linkPath =
- linkLineComputer->ComputeLinkPath(cli, libPathFlag, libPathTerminator);
-
- linkLibraries = linkLineComputer->ComputeLinkLibraries(cli, stdLibString);
+ linkLineComputer->ComputeLinkPath(cli, libPathFlag, libPathTerminator,
+ linkPath);
+ linkLineComputer->ComputeLinkLibraries(cli, stdLibString, linkLibraries);
}
std::string cmLocalGenerator::GetLinkLibsCMP0065(
@@ -1261,30 +1649,32 @@ std::string cmLocalGenerator::GetLinkLibsCMP0065(
"additional flags may be added to export symbols on all "
"executables regardless of their ENABLE_EXPORTS property.";
/* clang-format on */
- this->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
}
CM_FALLTHROUGH;
case cmPolicies::OLD:
- // OLD behavior is to always add the flags
- add_shlib_flags = true;
+ // OLD behavior is to always add the flags, except on AIX where
+ // we compute symbol exports if ENABLE_EXPORTS is on.
+ add_shlib_flags =
+ !(tgt.Target->IsAIX() && tgt.GetPropertyAsBool("ENABLE_EXPORTS"));
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
this->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065));
CM_FALLTHROUGH;
case cmPolicies::NEW:
- // NEW behavior is to only add the flags if ENABLE_EXPORTS is on
- add_shlib_flags = tgt.GetPropertyAsBool("ENABLE_EXPORTS");
+ // NEW behavior is to only add the flags if ENABLE_EXPORTS is on,
+ // except on AIX where we compute symbol exports.
+ add_shlib_flags =
+ !tgt.Target->IsAIX() && tgt.GetPropertyAsBool("ENABLE_EXPORTS");
break;
}
if (add_shlib_flags) {
- std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_";
- linkFlagsVar += linkLanguage;
- linkFlagsVar += "_FLAGS";
- linkFlags = this->Makefile->GetSafeDefinition(linkFlagsVar);
+ linkFlags = this->Makefile->GetSafeDefinition(
+ cmStrCat("CMAKE_SHARED_LIBRARY_LINK_", linkLanguage, "_FLAGS"));
}
}
return linkFlags;
@@ -1295,13 +1685,13 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
const std::string& lang,
const std::string& config)
{
- // Only add Mac OS X specific flags on Darwin platforms (OSX and iphone):
+ // Only add macOS specific flags on Darwin platforms (macOS and iOS):
if (this->Makefile->IsOn("APPLE") && this->EmitUniversalBinaryFlags) {
std::vector<std::string> archs;
target->GetAppleArchs(config, archs);
const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
if (sysroot && sysroot[0] == '/' && !sysroot[1]) {
- sysroot = CM_NULLPTR;
+ sysroot = nullptr;
}
std::string sysrootFlagVar =
std::string("CMAKE_") + lang + "_SYSROOT_FLAG";
@@ -1313,11 +1703,10 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
const char* deploymentTargetFlag =
this->Makefile->GetDefinition(deploymentTargetFlagVar);
if (!archs.empty() && !lang.empty() &&
- (lang[0] == 'C' || lang[0] == 'F')) {
- for (std::vector<std::string>::iterator i = archs.begin();
- i != archs.end(); ++i) {
+ (lang[0] == 'C' || lang[0] == 'F' || lang[0] == 'O')) {
+ for (std::string const& arch : archs) {
flags += " -arch ";
- flags += *i;
+ flags += arch;
}
}
@@ -1343,13 +1732,50 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
const std::string& config)
{
// Add language-specific flags.
- std::string flagsVar = "CMAKE_";
- flagsVar += lang;
- flagsVar += "_FLAGS";
- this->AddConfigVariableFlags(flags, flagsVar, config);
+ this->AddConfigVariableFlags(flags, cmStrCat("CMAKE_", lang, "_FLAGS"),
+ config);
+
+ if (lang == "Swift") {
+ if (const char* v = target->GetProperty("Swift_LANGUAGE_VERSION")) {
+ if (cmSystemTools::VersionCompare(
+ cmSystemTools::OP_GREATER_EQUAL,
+ this->Makefile->GetDefinition("CMAKE_Swift_COMPILER_VERSION"),
+ "4.2")) {
+ this->AppendFlags(flags, "-swift-version " + std::string(v));
+ }
+ }
+ }
- if (target->IsIPOEnabled(lang, config)) {
- this->AppendFeatureOptions(flags, lang, "IPO");
+ // Add MSVC runtime library flags. This is activated by the presence
+ // of a default selection whether or not it is overridden by a property.
+ const char* msvcRuntimeLibraryDefault =
+ this->Makefile->GetDefinition("CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT");
+ if (msvcRuntimeLibraryDefault && *msvcRuntimeLibraryDefault) {
+ const char* msvcRuntimeLibraryValue =
+ target->GetProperty("MSVC_RUNTIME_LIBRARY");
+ if (!msvcRuntimeLibraryValue) {
+ msvcRuntimeLibraryValue = msvcRuntimeLibraryDefault;
+ }
+ std::string const msvcRuntimeLibrary = cmGeneratorExpression::Evaluate(
+ msvcRuntimeLibraryValue, this, config, target);
+ if (!msvcRuntimeLibrary.empty()) {
+ if (const char* msvcRuntimeLibraryOptions =
+ this->Makefile->GetDefinition(
+ "CMAKE_" + lang + "_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_" +
+ msvcRuntimeLibrary)) {
+ this->AppendCompileOptions(flags, msvcRuntimeLibraryOptions);
+ } else if ((this->Makefile->GetSafeDefinition(
+ "CMAKE_" + lang + "_COMPILER_ID") == "MSVC" ||
+ this->Makefile->GetSafeDefinition(
+ "CMAKE_" + lang + "_SIMULATE_ID") == "MSVC") &&
+ !cmSystemTools::GetErrorOccuredFlag()) {
+ // The compiler uses the MSVC ABI so it needs a known runtime library.
+ this->IssueMessage(MessageType::FATAL_ERROR,
+ "MSVC_RUNTIME_LIBRARY value '" +
+ msvcRuntimeLibrary + "' not known for this " +
+ lang + " compiler.");
+ }
+ }
}
}
@@ -1367,16 +1793,18 @@ void cmLocalGenerator::AddLanguageFlagsForLinking(
}
this->AddLanguageFlags(flags, target, lang, config);
+
+ if (target->IsIPOEnabled(lang, config)) {
+ this->AppendFeatureOptions(flags, lang, "IPO");
+ }
}
cmGeneratorTarget* cmLocalGenerator::FindGeneratorTargetToUse(
const std::string& name) const
{
- std::vector<cmGeneratorTarget*>::const_iterator imported = std::find_if(
- this->ImportedGeneratorTargets.begin(),
- this->ImportedGeneratorTargets.end(), NamedGeneratorTargetFinder(name));
+ auto imported = this->ImportedGeneratorTargets.find(name);
if (imported != this->ImportedGeneratorTargets.end()) {
- return *imported;
+ return imported->second;
}
if (cmGeneratorTarget* t = this->FindLocalNonAliasGeneratorTarget(name)) {
@@ -1399,7 +1827,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
// If the input name is the empty string, there is no real
// dependency. Short-circuit the other checks:
- if (name == "") {
+ if (name.empty()) {
return false;
}
@@ -1411,7 +1839,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
if (cmGeneratorTarget* target = this->FindGeneratorTargetToUse(name)) {
// make sure it is not just a coincidence that the target name
// found is part of the inName
- if (cmSystemTools::FileIsFullPath(inName.c_str())) {
+ if (cmSystemTools::FileIsFullPath(inName)) {
std::string tLocation;
if (target->GetType() >= cmStateEnums::EXECUTABLE &&
target->GetType() <= cmStateEnums::MODULE_LIBRARY) {
@@ -1455,7 +1883,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
}
// The name was not that of a CMake target. It must name a file.
- if (cmSystemTools::FileIsFullPath(inName.c_str())) {
+ if (cmSystemTools::FileIsFullPath(inName)) {
// This is a full path. Return it as given.
dep = inName;
return true;
@@ -1464,15 +1892,14 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
// Check for a source file in this directory that matches the
// dependency.
if (cmSourceFile* sf = this->Makefile->GetSource(inName)) {
- dep = sf->GetFullPath();
+ dep = sf->ResolveFullPath();
return true;
}
// Treat the name as relative to the source directory in which it
// was given.
- dep = this->StateSnapshot.GetDirectory().GetCurrentSource();
- dep += "/";
- dep += inName;
+ dep = cmStrCat(this->StateSnapshot.GetDirectory().GetCurrentSource(), '/',
+ inName);
return true;
}
@@ -1483,10 +1910,9 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags,
// Add flags for dealing with shared libraries for this language.
if (shared) {
- flagsVar = "CMAKE_SHARED_LIBRARY_";
- flagsVar += lang;
- flagsVar += "_FLAGS";
- this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
+ this->AppendFlags(flags,
+ this->Makefile->GetSafeDefinition(
+ cmStrCat("CMAKE_SHARED_LIBRARY_", lang, "_FLAGS")));
}
}
@@ -1502,20 +1928,33 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
// This compiler has no notion of language standard levels.
return;
}
- std::string stdProp = lang + "_STANDARD";
- const char* standardProp = target->GetProperty(stdProp);
- if (!standardProp) {
- return;
- }
std::string extProp = lang + "_EXTENSIONS";
- std::string type = "EXTENSION";
bool ext = true;
if (const char* extPropValue = target->GetProperty(extProp)) {
- if (cmSystemTools::IsOff(extPropValue)) {
+ if (cmIsOff(extPropValue)) {
ext = false;
- type = "STANDARD";
}
}
+ std::string stdProp = lang + "_STANDARD";
+ const char* standardProp = target->GetProperty(stdProp);
+ if (!standardProp) {
+ if (ext) {
+ // No language standard is specified and extensions are not disabled.
+ // Check if this compiler needs a flag to enable extensions.
+ std::string const option_flag =
+ "CMAKE_" + lang + "_EXTENSION_COMPILE_OPTION";
+ if (const char* opt =
+ target->Target->GetMakefile()->GetDefinition(option_flag)) {
+ std::vector<std::string> optVec = cmExpandedList(opt);
+ for (std::string const& i : optVec) {
+ this->AppendFlagEscape(flags, i);
+ }
+ }
+ }
+ return;
+ }
+
+ std::string const type = ext ? "EXTENSION" : "STANDARD";
if (target->GetPropertyAsBool(lang + "_STANDARD_REQUIRED")) {
std::string option_flag =
@@ -1525,90 +1964,102 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
target->Target->GetMakefile()->GetDefinition(option_flag);
if (!opt) {
std::ostringstream e;
- e << "Target \"" << target->GetName() << "\" requires the language "
- "dialect \""
+ e << "Target \"" << target->GetName()
+ << "\" requires the language "
+ "dialect \""
<< lang << standardProp << "\" "
<< (ext ? "(with compiler extensions)" : "")
<< ", but CMake "
"does not know the compile flags to use to enable it.";
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->IssueMessage(MessageType::FATAL_ERROR, e.str());
} else {
- std::vector<std::string> optVec;
- cmSystemTools::ExpandListArgument(opt, optVec);
- for (size_t i = 0; i < optVec.size(); ++i) {
- this->AppendFlagEscape(flags, optVec[i]);
+ std::vector<std::string> optVec = cmExpandedList(opt);
+ for (std::string const& i : optVec) {
+ this->AppendFlagEscape(flags, i);
}
}
return;
}
- static std::map<std::string, std::vector<std::string> > langStdMap;
+ static std::map<std::string, std::vector<std::string>> langStdMap;
if (langStdMap.empty()) {
// Maintain sorted order, most recent first.
- langStdMap["CXX"].push_back("17");
- langStdMap["CXX"].push_back("14");
- langStdMap["CXX"].push_back("11");
- langStdMap["CXX"].push_back("98");
+ langStdMap["CXX"].emplace_back("20");
+ langStdMap["CXX"].emplace_back("17");
+ langStdMap["CXX"].emplace_back("14");
+ langStdMap["CXX"].emplace_back("11");
+ langStdMap["CXX"].emplace_back("98");
+
+ langStdMap["OBJCXX"].emplace_back("20");
+ langStdMap["OBJCXX"].emplace_back("17");
+ langStdMap["OBJCXX"].emplace_back("14");
+ langStdMap["OBJCXX"].emplace_back("11");
+ langStdMap["OBJCXX"].emplace_back("98");
+
+ langStdMap["C"].emplace_back("11");
+ langStdMap["C"].emplace_back("99");
+ langStdMap["C"].emplace_back("90");
- langStdMap["C"].push_back("11");
- langStdMap["C"].push_back("99");
- langStdMap["C"].push_back("90");
+ langStdMap["OBJC"].emplace_back("11");
+ langStdMap["OBJC"].emplace_back("99");
+ langStdMap["OBJC"].emplace_back("90");
- langStdMap["CUDA"].push_back("14");
- langStdMap["CUDA"].push_back("11");
- langStdMap["CUDA"].push_back("98");
+ langStdMap["CUDA"].emplace_back("14");
+ langStdMap["CUDA"].emplace_back("11");
+ langStdMap["CUDA"].emplace_back("98");
}
std::string standard(standardProp);
std::vector<std::string>& stds = langStdMap[lang];
- std::vector<std::string>::const_iterator stdIt =
- std::find(stds.begin(), stds.end(), standard);
+ auto stdIt = std::find(stds.begin(), stds.end(), standard);
if (stdIt == stds.end()) {
std::string e =
lang + "_STANDARD is set to invalid value '" + standard + "'";
this->GetGlobalGenerator()->GetCMakeInstance()->IssueMessage(
- cmake::FATAL_ERROR, e, target->GetBacktrace());
+ MessageType::FATAL_ERROR, e, target->GetBacktrace());
return;
}
- std::vector<std::string>::const_iterator defaultStdIt =
- std::find(stds.begin(), stds.end(), defaultStd);
+ auto defaultStdIt = std::find(stds.begin(), stds.end(), defaultStd);
if (defaultStdIt == stds.end()) {
std::string e = "CMAKE_" + lang +
"_STANDARD_DEFAULT is set to invalid value '" + std::string(defaultStd) +
"'";
- this->IssueMessage(cmake::INTERNAL_ERROR, e);
+ this->IssueMessage(MessageType::INTERNAL_ERROR, e);
return;
}
- // Greater or equal because the standards are stored in
- // backward chronological order.
+ // If the standard requested is older than the compiler's default
+ // then we need to use a flag to change it. The comparison is
+ // greater-or-equal because the standards are stored in backward
+ // chronological order.
if (stdIt >= defaultStdIt) {
std::string option_flag =
"CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION";
- const char* opt =
+ std::string const& opt =
target->Target->GetMakefile()->GetRequiredDefinition(option_flag);
- std::vector<std::string> optVec;
- cmSystemTools::ExpandListArgument(opt, optVec);
- for (size_t i = 0; i < optVec.size(); ++i) {
- this->AppendFlagEscape(flags, optVec[i]);
+ std::vector<std::string> optVec = cmExpandedList(opt);
+ for (std::string const& i : optVec) {
+ this->AppendFlagEscape(flags, i);
}
return;
}
+ // The standard requested is at least as new as the compiler's default,
+ // and the standard request is not required. Decay to the newest standard
+ // for which a flag is defined.
for (; stdIt < defaultStdIt; ++stdIt) {
std::string option_flag =
- "CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION";
+ cmStrCat("CMAKE_", lang, *stdIt, "_", type, "_COMPILE_OPTION");
if (const char* opt =
target->Target->GetMakefile()->GetDefinition(option_flag)) {
- std::vector<std::string> optVec;
- cmSystemTools::ExpandListArgument(opt, optVec);
- for (size_t i = 0; i < optVec.size(); ++i) {
- this->AppendFlagEscape(flags, optVec[i]);
+ std::vector<std::string> optVec = cmExpandedList(opt);
+ for (std::string const& i : optVec) {
+ this->AppendFlagEscape(flags, i);
}
return;
}
@@ -1640,8 +2091,10 @@ static void AddVisibilityCompileOption(std::string& flags,
strcmp(prop, "protected") != 0 && strcmp(prop, "internal") != 0) {
std::ostringstream e;
e << "Target " << target->GetName() << " uses unsupported value \"" << prop
- << "\" for " << flagDefine << ".";
- cmSystemTools::Error(e.str().c_str());
+ << "\" for " << flagDefine << "."
+ << " The supported values are: default, hidden, protected, and "
+ "internal.";
+ cmSystemTools::Error(e.str());
return;
}
std::string option = std::string(opt) + prop;
@@ -1651,10 +2104,11 @@ static void AddVisibilityCompileOption(std::string& flags,
static void AddInlineVisibilityCompileOption(std::string& flags,
cmGeneratorTarget const* target,
cmLocalGenerator* lg,
- std::string* warnCMP0063)
+ std::string* warnCMP0063,
+ const std::string& lang)
{
std::string compileOption =
- "CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN";
+ cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN");
const char* opt = lg->GetMakefile()->GetDefinition(compileOption);
if (!opt) {
return;
@@ -1679,7 +2133,7 @@ void cmLocalGenerator::AddVisibilityPresetFlags(
}
std::string warnCMP0063;
- std::string* pWarnCMP0063 = CM_NULLPTR;
+ std::string* pWarnCMP0063 = nullptr;
if (target->GetType() != cmStateEnums::SHARED_LIBRARY &&
target->GetType() != cmStateEnums::MODULE_LIBRARY &&
!target->IsExecutableWithExports()) {
@@ -1696,8 +2150,8 @@ void cmLocalGenerator::AddVisibilityPresetFlags(
AddVisibilityCompileOption(flags, target, this, lang, pWarnCMP0063);
- if (lang == "CXX") {
- AddInlineVisibilityCompileOption(flags, target, this, pWarnCMP0063);
+ if (lang == "CXX" || lang == "OBJCXX") {
+ AddInlineVisibilityCompileOption(flags, target, this, pWarnCMP0063, lang);
}
if (!warnCMP0063.empty() && this->WarnCMP0063.insert(target).second) {
@@ -1712,7 +2166,7 @@ void cmLocalGenerator::AddVisibilityPresetFlags(
"For compatibility CMake is not honoring them for this target.";
/* clang-format on */
target->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
- cmake::AUTHOR_WARNING, w.str(), target->GetBacktrace());
+ MessageType::AUTHOR_WARNING, w.str(), target->GetBacktrace());
}
}
@@ -1752,12 +2206,10 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
std::string originalFlags =
this->GlobalGenerator->GetSharedLibFlagsForLanguage(lang);
if (shared) {
- std::string flagsVar = "CMAKE_SHARED_LIBRARY_";
- flagsVar += lang;
- flagsVar += "_FLAGS";
- const char* flags = this->Makefile->GetSafeDefinition(flagsVar);
+ std::string flagsVar = cmStrCat("CMAKE_SHARED_LIBRARY_", lang, "_FLAGS");
+ std::string const& flags = this->Makefile->GetSafeDefinition(flagsVar);
- if (flags && flags != originalFlags) {
+ if (flags != originalFlags) {
switch (this->GetPolicyStatus(cmPolicies::CMP0018)) {
case cmPolicies::WARN: {
std::ostringstream e;
@@ -1771,7 +2223,7 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
<< flagsVar << " was removed.\n"
<< cmPolicies::GetPolicyWarning(cmPolicies::CMP0018);
- this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ this->IssueMessage(MessageType::AUTHOR_WARNING, e.str());
CM_FALLTHROUGH;
}
case cmPolicies::OLD:
@@ -1790,26 +2242,20 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
std::string const& lang,
int targetType)
{
- const char* picFlags = CM_NULLPTR;
+ std::string picFlags;
if (targetType == cmStateEnums::EXECUTABLE) {
- std::string flagsVar = "CMAKE_";
- flagsVar += lang;
- flagsVar += "_COMPILE_OPTIONS_PIE";
- picFlags = this->Makefile->GetSafeDefinition(flagsVar);
+ picFlags = this->Makefile->GetSafeDefinition(
+ cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_PIE"));
}
- if (!picFlags) {
- std::string flagsVar = "CMAKE_";
- flagsVar += lang;
- flagsVar += "_COMPILE_OPTIONS_PIC";
- picFlags = this->Makefile->GetSafeDefinition(flagsVar);
+ if (picFlags.empty()) {
+ picFlags = this->Makefile->GetSafeDefinition(
+ cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_PIC"));
}
- if (picFlags) {
- std::vector<std::string> options;
- cmSystemTools::ExpandListArgument(picFlags, options);
- for (std::vector<std::string>::const_iterator oi = options.begin();
- oi != options.end(); ++oi) {
- this->AppendFlagEscape(flags, *oi);
+ if (!picFlags.empty()) {
+ std::vector<std::string> options = cmExpandedList(picFlags);
+ for (std::string const& o : options) {
+ this->AppendFlagEscape(flags, o);
}
}
}
@@ -1819,18 +2265,17 @@ void cmLocalGenerator::AddConfigVariableFlags(std::string& flags,
const std::string& config)
{
// Add the flags from the variable itself.
- std::string flagsVar = var;
- this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
+ this->AppendFlags(flags, this->Makefile->GetSafeDefinition(var));
// Add the flags from the build-type specific variable.
if (!config.empty()) {
- flagsVar += "_";
- flagsVar += cmSystemTools::UpperCase(config);
- this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
+ const std::string flagsVar =
+ cmStrCat(var, '_', cmSystemTools::UpperCase(config));
+ this->AppendFlags(flags, this->Makefile->GetSafeDefinition(flagsVar));
}
}
void cmLocalGenerator::AppendFlags(std::string& flags,
- const std::string& newFlags)
+ const std::string& newFlags) const
{
if (!newFlags.empty()) {
if (!flags.empty()) {
@@ -1840,19 +2285,284 @@ void cmLocalGenerator::AppendFlags(std::string& flags,
}
}
-void cmLocalGenerator::AppendFlags(std::string& flags, const char* newFlags)
+void cmLocalGenerator::AppendFlags(
+ std::string& flags, const std::vector<BT<std::string>>& newFlags) const
{
- if (newFlags && *newFlags) {
- this->AppendFlags(flags, std::string(newFlags));
+ for (BT<std::string> const& flag : newFlags) {
+ this->AppendFlags(flags, flag.Value);
}
}
void cmLocalGenerator::AppendFlagEscape(std::string& flags,
- const std::string& rawFlag)
+ const std::string& rawFlag) const
{
this->AppendFlags(flags, this->EscapeForShell(rawFlag));
}
+void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
+{
+ // FIXME: Handle all configurations in multi-config generators.
+ std::string config;
+ if (!this->GetGlobalGenerator()->IsMultiConfig()) {
+ config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ }
+ const std::string buildType = cmSystemTools::UpperCase(config);
+
+ // FIXME: Refactor collection of sources to not evaluate object libraries.
+ std::vector<cmSourceFile*> sources;
+ target->GetSourceFiles(sources, buildType);
+
+ for (const std::string& lang : { "C", "CXX", "OBJC", "OBJCXX" }) {
+ auto langSources =
+ std::count_if(sources.begin(), sources.end(), [lang](cmSourceFile* sf) {
+ return lang == sf->GetLanguage() &&
+ !sf->GetProperty("SKIP_PRECOMPILE_HEADERS");
+ });
+ if (langSources == 0) {
+ continue;
+ }
+
+ const std::string pchSource = target->GetPchSource(config, lang);
+ const std::string pchHeader = target->GetPchHeader(config, lang);
+
+ if (pchSource.empty() || pchHeader.empty()) {
+ continue;
+ }
+
+ const std::string pchExtension =
+ this->Makefile->GetSafeDefinition("CMAKE_PCH_EXTENSION");
+
+ if (pchExtension.empty()) {
+ continue;
+ }
+
+ const char* pchReuseFrom =
+ target->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
+
+ auto pch_sf = this->Makefile->GetOrCreateSource(
+ pchSource, false, cmSourceFileLocationKind::Known);
+
+ if (!this->GetGlobalGenerator()->IsXcode()) {
+ if (!pchReuseFrom) {
+ target->AddSource(pchSource, true);
+ }
+
+ const std::string pchFile = target->GetPchFile(config, lang);
+
+ // Exclude the pch files from linking
+ if (this->Makefile->IsOn("CMAKE_LINK_PCH")) {
+ if (!pchReuseFrom) {
+ pch_sf->SetProperty("OBJECT_OUTPUTS", pchFile.c_str());
+ } else {
+ auto reuseTarget =
+ this->GlobalGenerator->FindGeneratorTarget(pchReuseFrom);
+
+ if (this->Makefile->IsOn("CMAKE_PCH_COPY_COMPILE_PDB")) {
+
+ const std::string pdb_prefix =
+ this->GetGlobalGenerator()->IsMultiConfig()
+ ? cmStrCat(this->GlobalGenerator->GetCMakeCFGIntDir(), "/")
+ : "";
+
+ const std::string target_compile_pdb_dir = cmStrCat(
+ target->GetLocalGenerator()->GetCurrentBinaryDirectory(), "/",
+ target->GetName(), ".dir/");
+
+ const std::string copy_script =
+ cmStrCat(target_compile_pdb_dir, "copy_idb_pdb.cmake");
+ cmGeneratedFileStream file(copy_script);
+
+ file << "# CMake generated file\n";
+ for (auto extension : { ".pdb", ".idb" }) {
+ const std::string from_file = cmStrCat(
+ reuseTarget->GetLocalGenerator()->GetCurrentBinaryDirectory(),
+ "/", pchReuseFrom, ".dir/${PDB_PREFIX}", pchReuseFrom,
+ extension);
+
+ const std::string to_dir = cmStrCat(
+ target->GetLocalGenerator()->GetCurrentBinaryDirectory(), "/",
+ target->GetName(), ".dir/${PDB_PREFIX}");
+
+ const std::string to_file =
+ cmStrCat(to_dir, pchReuseFrom, extension);
+
+ std::string dest_file = to_file;
+
+ const std::string prefix = target->GetSafeProperty("PREFIX");
+ if (!prefix.empty()) {
+ dest_file = cmStrCat(to_dir, prefix, pchReuseFrom, extension);
+ }
+
+ file << "if (EXISTS \"" << from_file << "\" AND \"" << from_file
+ << "\" IS_NEWER_THAN \"" << dest_file << "\")\n";
+ file << " file(COPY \"" << from_file << "\""
+ << " DESTINATION \"" << to_dir << "\")\n";
+ if (!prefix.empty()) {
+ file << " file(REMOVE \"" << dest_file << "\")\n";
+ file << " file(RENAME \"" << to_file << "\" \"" << dest_file
+ << "\")\n";
+ }
+ file << "endif()\n";
+ }
+
+ cmCustomCommandLines commandLines;
+ cmCustomCommandLine currentLine;
+ currentLine.push_back(cmSystemTools::GetCMakeCommand());
+ currentLine.push_back(cmStrCat("-DPDB_PREFIX=", pdb_prefix));
+ currentLine.push_back("-P");
+ currentLine.push_back(copy_script);
+ commandLines.push_back(std::move(currentLine));
+
+ const std::string no_main_dependency;
+ const std::vector<std::string> no_deps;
+ const char* no_message = "";
+ const char* no_current_dir = nullptr;
+ std::vector<std::string> no_byproducts;
+
+ std::vector<std::string> outputs;
+ outputs.push_back(cmStrCat(target_compile_pdb_dir, pdb_prefix,
+ pchReuseFrom, ".pdb"));
+
+ if (this->GetGlobalGenerator()->IsMultiConfig()) {
+ this->Makefile->AddCustomCommandToTarget(
+ target->GetName(), outputs, no_deps, commandLines,
+ cmCustomCommandType::PRE_BUILD, no_message, no_current_dir);
+ } else {
+ cmImplicitDependsList no_implicit_depends;
+ cmSourceFile* copy_rule =
+ this->Makefile->AddCustomCommandToOutput(
+ outputs, no_byproducts, no_deps, no_main_dependency,
+ no_implicit_depends, commandLines, no_message,
+ no_current_dir);
+
+ if (copy_rule) {
+ target->AddSource(copy_rule->ResolveFullPath());
+ }
+ }
+
+ target->Target->SetProperty("COMPILE_PDB_OUTPUT_DIRECTORY",
+ target_compile_pdb_dir.c_str());
+ }
+
+ std::string pchSourceObj =
+ reuseTarget->GetPchFileObject(config, lang);
+
+ // Link to the pch object file
+ target->Target->AppendProperty(
+ "LINK_FLAGS",
+ cmStrCat(" ", this->ConvertToOutputFormat(pchSourceObj, SHELL))
+ .c_str(),
+ true);
+ }
+ } else {
+ pch_sf->SetProperty("PCH_EXTENSION", pchExtension.c_str());
+ }
+
+ // Add pchHeader to source files, which will
+ // be grouped as "Precompile Header File"
+ auto pchHeader_sf = this->Makefile->GetOrCreateSource(
+ pchHeader, false, cmSourceFileLocationKind::Known);
+ std::string err;
+ pchHeader_sf->ResolveFullPath(&err);
+ target->AddSource(pchHeader);
+ }
+ }
+}
+
+void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target)
+{
+ if (!target->GetPropertyAsBool("UNITY_BUILD")) {
+ return;
+ }
+
+ // FIXME: Handle all configurations in multi-config generators.
+ std::string config;
+ if (!this->GetGlobalGenerator()->IsMultiConfig()) {
+ config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ }
+
+ const std::string buildType = cmSystemTools::UpperCase(config);
+
+ std::string filename_base =
+ cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/",
+ target->GetName(), ".dir/Unity/");
+
+ // FIXME: Refactor collection of sources to not evaluate object libraries.
+ std::vector<cmSourceFile*> sources;
+ target->GetSourceFiles(sources, buildType);
+
+ auto batchSizeString = target->GetProperty("UNITY_BUILD_BATCH_SIZE");
+ const size_t unityBatchSize =
+ static_cast<size_t>(std::atoi(batchSizeString));
+
+ auto beforeInclude = target->GetProperty("UNITY_BUILD_CODE_BEFORE_INCLUDE");
+ auto afterInclude = target->GetProperty("UNITY_BUILD_CODE_AFTER_INCLUDE");
+
+ for (std::string lang : { "C", "CXX" }) {
+ std::vector<cmSourceFile*> filtered_sources;
+ std::copy_if(sources.begin(), sources.end(),
+ std::back_inserter(filtered_sources), [&](cmSourceFile* sf) {
+ return sf->GetLanguage() == lang &&
+ !sf->GetPropertyAsBool("SKIP_UNITY_BUILD_INCLUSION") &&
+ !sf->GetPropertyAsBool("HEADER_FILE_ONLY") &&
+ !sf->GetProperty("COMPILE_OPTIONS") &&
+ !sf->GetProperty("COMPILE_DEFINITIONS") &&
+ !sf->GetProperty("COMPILE_FLAGS") &&
+ !sf->GetProperty("INCLUDE_DIRECTORIES");
+ });
+
+ size_t batchSize = unityBatchSize;
+ if (unityBatchSize == 0) {
+ batchSize = filtered_sources.size();
+ }
+
+ for (size_t itemsLeft = filtered_sources.size(), chunk = batchSize,
+ batch = 0;
+ itemsLeft > 0; itemsLeft -= chunk, ++batch) {
+
+ chunk = std::min(itemsLeft, batchSize);
+
+ std::string filename = cmStrCat(filename_base, "unity_", batch,
+ (lang == "C") ? "_c.c" : "_cxx.cxx");
+
+ const std::string filename_tmp = cmStrCat(filename, ".tmp");
+ {
+ size_t begin = batch * batchSize;
+ size_t end = begin + chunk;
+
+ cmGeneratedFileStream file(
+ filename_tmp, false,
+ this->GetGlobalGenerator()->GetMakefileEncoding());
+ file << "/* generated by CMake */\n\n";
+
+ for (; begin != end; ++begin) {
+ cmSourceFile* sf = filtered_sources[begin];
+
+ target->AddSourceFileToUnityBatch(sf->ResolveFullPath());
+ sf->SetProperty("UNITY_SOURCE_FILE", filename.c_str());
+
+ if (beforeInclude) {
+ file << beforeInclude << "\n";
+ }
+
+ file << "#include \"" << sf->ResolveFullPath() << "\"\n";
+
+ if (afterInclude) {
+ file << afterInclude << "\n";
+ }
+ }
+ }
+ cmSystemTools::MoveFileIfDifferent(filename_tmp, filename);
+
+ target->AddSource(filename, true);
+
+ auto unity = this->Makefile->GetOrCreateSource(filename);
+ unity->SetProperty("SKIP_UNITY_BUILD_INCLUSION", "ON");
+ unity->SetProperty("UNITY_SOURCE_FILE", filename.c_str());
+ }
+ }
+}
+
void cmLocalGenerator::AppendIPOLinkerFlags(std::string& flags,
cmGeneratorTarget* target,
const std::string& config,
@@ -1873,43 +2583,186 @@ void cmLocalGenerator::AppendIPOLinkerFlags(std::string& flags,
const std::string name = "CMAKE_" + lang + "_LINK_OPTIONS_IPO";
const char* rawFlagsList = this->Makefile->GetDefinition(name);
- if (rawFlagsList == CM_NULLPTR) {
+ if (rawFlagsList == nullptr) {
+ return;
+ }
+
+ std::vector<std::string> flagsList = cmExpandedList(rawFlagsList);
+ for (std::string const& o : flagsList) {
+ this->AppendFlagEscape(flags, o);
+ }
+}
+
+void cmLocalGenerator::AppendPositionIndependentLinkerFlags(
+ std::string& flags, cmGeneratorTarget* target, const std::string& config,
+ const std::string& lang)
+{
+ // For now, only EXECUTABLE is concerned
+ if (target->GetType() != cmStateEnums::EXECUTABLE) {
+ return;
+ }
+
+ const char* PICValue = target->GetLinkPIEProperty(config);
+ if (PICValue == nullptr) {
+ // POSITION_INDEPENDENT_CODE is not set
+ return;
+ }
+
+ const std::string mode = cmIsOn(PICValue) ? "PIE" : "NO_PIE";
+
+ std::string supported = "CMAKE_" + lang + "_LINK_" + mode + "_SUPPORTED";
+ if (cmIsOff(this->Makefile->GetDefinition(supported))) {
+ return;
+ }
+
+ std::string name = "CMAKE_" + lang + "_LINK_OPTIONS_" + mode;
+
+ auto pieFlags = this->Makefile->GetSafeDefinition(name);
+ if (pieFlags.empty()) {
+ return;
+ }
+
+ std::vector<std::string> flagsList = cmExpandedList(pieFlags);
+ for (const auto& flag : flagsList) {
+ this->AppendFlagEscape(flags, flag);
+ }
+}
+
+void cmLocalGenerator::AppendCompileOptions(std::string& options,
+ const char* options_list,
+ const char* regex) const
+{
+ // Short-circuit if there are no options.
+ if (!options_list) {
return;
}
- std::vector<std::string> flagsList;
- cmSystemTools::ExpandListArgument(rawFlagsList, flagsList);
- for (std::vector<std::string>::const_iterator oi = flagsList.begin();
- oi != flagsList.end(); ++oi) {
- this->AppendFlagEscape(flags, *oi);
+ // Expand the list of options.
+ std::vector<std::string> options_vec = cmExpandedList(options_list);
+ this->AppendCompileOptions(options, options_vec, regex);
+}
+
+void cmLocalGenerator::AppendCompileOptions(
+ std::string& options, const std::vector<std::string>& options_vec,
+ const char* regex) const
+{
+ if (regex != nullptr) {
+ // Filter flags upon specified reges.
+ cmsys::RegularExpression r(regex);
+
+ for (std::string const& opt : options_vec) {
+ if (r.find(opt)) {
+ this->AppendFlagEscape(options, opt);
+ }
+ }
+ } else {
+ for (std::string const& opt : options_vec) {
+ this->AppendFlagEscape(options, opt);
+ }
+ }
+}
+
+void cmLocalGenerator::AppendCompileOptions(
+ std::vector<BT<std::string>>& options,
+ const std::vector<BT<std::string>>& options_vec, const char* regex) const
+{
+ if (regex != nullptr) {
+ // Filter flags upon specified regular expressions.
+ cmsys::RegularExpression r(regex);
+
+ for (BT<std::string> const& opt : options_vec) {
+ if (r.find(opt.Value)) {
+ std::string flag;
+ this->AppendFlagEscape(flag, opt.Value);
+ options.emplace_back(std::move(flag), opt.Backtrace);
+ }
+ }
+ } else {
+ for (BT<std::string> const& opt : options_vec) {
+ std::string flag;
+ this->AppendFlagEscape(flag, opt.Value);
+ options.emplace_back(std::move(flag), opt.Backtrace);
+ }
+ }
+}
+
+void cmLocalGenerator::AppendIncludeDirectories(
+ std::vector<std::string>& includes, const char* includes_list,
+ const cmSourceFile& sourceFile) const
+{
+ // Short-circuit if there are no includes.
+ if (!includes_list) {
+ return;
+ }
+
+ // Expand the list of includes.
+ std::vector<std::string> includes_vec = cmExpandedList(includes_list);
+ this->AppendIncludeDirectories(includes, includes_vec, sourceFile);
+}
+
+void cmLocalGenerator::AppendIncludeDirectories(
+ std::vector<std::string>& includes,
+ const std::vector<std::string>& includes_vec,
+ const cmSourceFile& sourceFile) const
+{
+ std::unordered_set<std::string> uniqueIncludes;
+
+ for (const std::string& include : includes_vec) {
+ if (!cmSystemTools::FileIsFullPath(include)) {
+ std::ostringstream e;
+ e << "Found relative path while evaluating include directories of "
+ "\""
+ << sourceFile.GetLocation().GetName() << "\":\n \"" << include
+ << "\"\n";
+
+ this->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return;
+ }
+
+ std::string inc = include;
+
+ if (!cmIsOff(inc)) {
+ cmSystemTools::ConvertToUnixSlashes(inc);
+ }
+
+ if (uniqueIncludes.insert(inc).second) {
+ includes.push_back(std::move(inc));
+ }
}
}
void cmLocalGenerator::AppendDefines(std::set<std::string>& defines,
- const char* defines_list) const
+ std::string const& defines_list) const
+{
+ std::set<BT<std::string>> tmp;
+ this->AppendDefines(tmp, ExpandListWithBacktrace(defines_list));
+ for (BT<std::string> const& i : tmp) {
+ defines.emplace(i.Value);
+ }
+}
+
+void cmLocalGenerator::AppendDefines(std::set<BT<std::string>>& defines,
+ std::string const& defines_list) const
{
// Short-circuit if there are no definitions.
- if (!defines_list) {
+ if (defines_list.empty()) {
return;
}
// Expand the list of definitions.
- std::vector<std::string> defines_vec;
- cmSystemTools::ExpandListArgument(defines_list, defines_vec);
- this->AppendDefines(defines, defines_vec);
+ this->AppendDefines(defines, ExpandListWithBacktrace(defines_list));
}
void cmLocalGenerator::AppendDefines(
- std::set<std::string>& defines,
- const std::vector<std::string>& defines_vec) const
+ std::set<BT<std::string>>& defines,
+ const std::vector<BT<std::string>>& defines_vec) const
{
- for (std::vector<std::string>::const_iterator di = defines_vec.begin();
- di != defines_vec.end(); ++di) {
+ for (BT<std::string> const& d : defines_vec) {
// Skip unsupported definitions.
- if (!this->CheckDefinition(*di)) {
+ if (!this->CheckDefinition(d.Value)) {
continue;
}
- defines.insert(*di);
+ defines.insert(d);
}
}
@@ -1920,19 +2773,14 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
// Lookup the define flag for the current language.
std::string dflag = "-D";
if (!lang.empty()) {
- std::string defineFlagVar = "CMAKE_";
- defineFlagVar += lang;
- defineFlagVar += "_DEFINE_FLAG";
- const char* df = this->Makefile->GetDefinition(defineFlagVar);
+ const char* df =
+ this->Makefile->GetDefinition(cmStrCat("CMAKE_", lang, "_DEFINE_FLAG"));
if (df && *df) {
dflag = df;
}
}
-
- std::set<std::string>::const_iterator defineIt = defines.begin();
- const std::set<std::string>::const_iterator defineEnd = defines.end();
const char* itemSeparator = definesString.empty() ? "" : " ";
- for (; defineIt != defineEnd; ++defineIt) {
+ for (std::string const& define : defines) {
// Append the definition with proper escaping.
std::string def = dflag;
if (this->GetState()->UseWatcomWMake()) {
@@ -1946,7 +2794,7 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
// command line without any escapes. However we still have to
// get the '$' and '#' characters through WMake as '$$' and
// '$#'.
- for (const char* c = defineIt->c_str(); *c; ++c) {
+ for (const char* c = define.c_str(); *c; ++c) {
if (*c == '$' || *c == '#') {
def += '$';
}
@@ -1955,11 +2803,11 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
} else {
// Make the definition appear properly on the command line. Use
// -DNAME="value" instead of -D"NAME=value" for historical reasons.
- std::string::size_type eq = defineIt->find("=");
- def += defineIt->substr(0, eq);
+ std::string::size_type eq = define.find('=');
+ def += define.substr(0, eq);
if (eq != std::string::npos) {
def += "=";
- def += this->EscapeForShell(defineIt->c_str() + eq + 1, true);
+ def += this->EscapeForShell(define.substr(eq + 1), true);
}
}
definesString += itemSeparator;
@@ -1972,16 +2820,12 @@ void cmLocalGenerator::AppendFeatureOptions(std::string& flags,
const std::string& lang,
const char* feature)
{
- std::string optVar = "CMAKE_";
- optVar += lang;
- optVar += "_COMPILE_OPTIONS_";
- optVar += feature;
- if (const char* optionList = this->Makefile->GetDefinition(optVar)) {
- std::vector<std::string> options;
- cmSystemTools::ExpandListArgument(optionList, options);
- for (std::vector<std::string>::const_iterator oi = options.begin();
- oi != options.end(); ++oi) {
- this->AppendFlagEscape(flags, *oi);
+ const char* optionList = this->Makefile->GetDefinition(
+ cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_", feature));
+ if (optionList != nullptr) {
+ std::vector<std::string> options = cmExpandedList(optionList);
+ for (std::string const& o : options) {
+ this->AppendFlagEscape(flags, o);
}
}
}
@@ -2003,7 +2847,7 @@ const char* cmLocalGenerator::GetFeature(const std::string& feature,
}
snp = snp.GetBuildsystemDirectoryParent();
}
- return CM_NULLPTR;
+ return nullptr;
}
std::string cmLocalGenerator::GetProjectName() const
@@ -2025,10 +2869,9 @@ std::string cmLocalGenerator::ConstructComment(
comment = "Generating ";
const char* sep = "";
std::string currentBinaryDir = this->GetCurrentBinaryDirectory();
- for (std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin();
- o != ccg.GetOutputs().end(); ++o) {
+ for (std::string const& o : ccg.GetOutputs()) {
comment += sep;
- comment += this->ConvertToRelativePath(currentBinaryDir, *o);
+ comment += this->MaybeConvertToRelativePath(currentBinaryDir, o);
sep = ", ";
}
return comment;
@@ -2058,37 +2901,36 @@ void cmLocalGenerator::GenerateTargetInstallRules(
{
// Convert the old-style install specification from each target to
// an install generator and run it.
- std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); ++l) {
- if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets();
+ for (cmGeneratorTarget* l : tgts) {
+ if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
// Include the user-specified pre-install script for this target.
- if (const char* preinstall = (*l)->GetProperty("PRE_INSTALL_SCRIPT")) {
- cmInstallScriptGenerator g(preinstall, false, CM_NULLPTR, false);
+ if (const char* preinstall = l->GetProperty("PRE_INSTALL_SCRIPT")) {
+ cmInstallScriptGenerator g(preinstall, false, nullptr, false);
g.Generate(os, config, configurationTypes);
}
// Install this target if a destination is given.
- if ((*l)->Target->GetInstallPath() != "") {
+ if (!l->Target->GetInstallPath().empty()) {
// Compute the full install destination. Note that converting
// to unix slashes also removes any trailing slash.
// We also skip over the leading slash given by the user.
- std::string destination = (*l)->Target->GetInstallPath().substr(1);
+ std::string destination = l->Target->GetInstallPath().substr(1);
cmSystemTools::ConvertToUnixSlashes(destination);
if (destination.empty()) {
destination = ".";
}
// Generate the proper install generator for this target type.
- switch ((*l)->GetType()) {
+ switch (l->GetType()) {
case cmStateEnums::EXECUTABLE:
case cmStateEnums::STATIC_LIBRARY:
case cmStateEnums::MODULE_LIBRARY: {
// Use a target install generator.
- cmInstallTargetGeneratorLocal g(this, (*l)->GetName(),
+ cmInstallTargetGeneratorLocal g(this, l->GetName(),
destination.c_str(), false);
g.Generate(os, config, configurationTypes);
} break;
@@ -2097,18 +2939,18 @@ void cmLocalGenerator::GenerateTargetInstallRules(
// Special code to handle DLL. Install the import library
// to the normal destination and the DLL to the runtime
// destination.
- cmInstallTargetGeneratorLocal g1(this, (*l)->GetName(),
+ cmInstallTargetGeneratorLocal g1(this, l->GetName(),
destination.c_str(), true);
g1.Generate(os, config, configurationTypes);
// We also skip over the leading slash given by the user.
- destination = (*l)->Target->GetRuntimeInstallPath().substr(1);
+ destination = l->Target->GetRuntimeInstallPath().substr(1);
cmSystemTools::ConvertToUnixSlashes(destination);
- cmInstallTargetGeneratorLocal g2(this, (*l)->GetName(),
+ cmInstallTargetGeneratorLocal g2(this, l->GetName(),
destination.c_str(), false);
g2.Generate(os, config, configurationTypes);
#else
// Use a target install generator.
- cmInstallTargetGeneratorLocal g(this, (*l)->GetName(),
+ cmInstallTargetGeneratorLocal g(this, l->GetName(),
destination.c_str(), false);
g.Generate(os, config, configurationTypes);
#endif
@@ -2119,8 +2961,8 @@ void cmLocalGenerator::GenerateTargetInstallRules(
}
// Include the user-specified post-install script for this target.
- if (const char* postinstall = (*l)->GetProperty("POST_INSTALL_SCRIPT")) {
- cmInstallScriptGenerator g(postinstall, false, CM_NULLPTR, false);
+ if (const char* postinstall = l->GetProperty("POST_INSTALL_SCRIPT")) {
+ cmInstallScriptGenerator g(postinstall, false, nullptr, false);
g.Generate(os, config, configurationTypes);
}
}
@@ -2136,8 +2978,8 @@ static bool cmLocalGeneratorShortenObjectName(std::string& objName,
objName.find('/', objName.size() - max_len + 32);
if (pos != std::string::npos) {
cmCryptoHash md5(cmCryptoHash::AlgoMD5);
- std::string md5name = md5.HashString(objName.substr(0, pos));
- md5name += objName.substr(pos);
+ std::string md5name = cmStrCat(md5.HashString(objName.substr(0, pos)),
+ cm::string_view(objName).substr(pos));
objName = md5name;
// The object name is now short enough.
@@ -2172,8 +3014,7 @@ std::string& cmLocalGenerator::CreateSafeUniqueObjectFileName(
const std::string& sin, std::string const& dir_max)
{
// Look for an existing mapped name for this object file.
- std::map<std::string, std::string>::iterator it =
- this->UniqueObjectNamesMap.find(sin);
+ auto it = this->UniqueObjectNamesMap.find(sin);
// If no entry exists create one.
if (it == this->UniqueObjectNamesMap.end()) {
@@ -2235,7 +3076,7 @@ std::string& cmLocalGenerator::CreateSafeUniqueObjectFileName(
<< "cannot be safely placed under this directory. "
<< "The build may not work correctly.";
/* clang-format on */
- this->IssueMessage(cmake::WARNING, m.str());
+ this->IssueMessage(MessageType::WARNING, m.str());
}
}
#else
@@ -2286,17 +3127,17 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
std::string const& fullPath = source.GetFullPath();
// Try referencing the source relative to the source tree.
- std::string relFromSource =
- this->ConvertToRelativePath(this->GetCurrentSourceDirectory(), fullPath);
+ std::string relFromSource = this->MaybeConvertToRelativePath(
+ this->GetCurrentSourceDirectory(), fullPath);
assert(!relFromSource.empty());
- bool relSource = !cmSystemTools::FileIsFullPath(relFromSource.c_str());
+ bool relSource = !cmSystemTools::FileIsFullPath(relFromSource);
bool subSource = relSource && relFromSource[0] != '.';
// Try referencing the source relative to the binary tree.
- std::string relFromBinary =
- this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), fullPath);
+ std::string relFromBinary = this->MaybeConvertToRelativePath(
+ this->GetCurrentBinaryDirectory(), fullPath);
assert(!relFromBinary.empty());
- bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary.c_str());
+ bool relBinary = !cmSystemTools::FileIsFullPath(relFromBinary);
bool subBinary = relBinary && relFromBinary[0] != '.';
// Select a nice-looking reference to the source file to construct
@@ -2315,12 +3156,29 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
// if it is still a full path check for the try compile case
// try compile never have in source sources, and should not
// have conflicting source file names in the same target
- if (cmSystemTools::FileIsFullPath(objectName.c_str())) {
+ if (cmSystemTools::FileIsFullPath(objectName)) {
if (this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile()) {
objectName = cmSystemTools::GetFilenameName(source.GetFullPath());
}
}
+ // Ensure that for the CMakeFiles/<target>.dir/generated_source_file
+ // we don't end up having:
+ // CMakeFiles/<target>.dir/CMakeFiles/<target>.dir/generated_source_file.obj
+ const char* unitySourceFile = source.GetProperty("UNITY_SOURCE_FILE");
+ const char* pchExtension = source.GetProperty("PCH_EXTENSION");
+ const bool isPchObject = objectName.find("cmake_pch") != std::string::npos;
+ if (unitySourceFile || pchExtension || isPchObject) {
+ if (pchExtension) {
+ customOutputExtension = pchExtension;
+ }
+
+ cmsys::RegularExpression var("(CMakeFiles/[^/]+.dir/)");
+ if (var.find(objectName)) {
+ objectName.erase(var.start(), var.end() - var.start());
+ }
+ }
+
// Replace the original source file extension with the object file
// extension.
bool keptSourceExtension = true;
@@ -2332,10 +3190,8 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
if (!replaceExt) {
std::string lang = source.GetLanguage();
if (!lang.empty()) {
- std::string repVar = "CMAKE_";
- repVar += lang;
- repVar += "_OUTPUT_EXTENSION_REPLACE";
- replaceExt = this->Makefile->IsOn(repVar);
+ replaceExt = this->Makefile->IsOn(
+ cmStrCat("CMAKE_", lang, "_OUTPUT_EXTENSION_REPLACE"));
}
}
@@ -2373,26 +3229,33 @@ cmake* cmLocalGenerator::GetCMakeInstance() const
return this->GlobalGenerator->GetCMakeInstance();
}
-const char* cmLocalGenerator::GetSourceDirectory() const
+std::string const& cmLocalGenerator::GetSourceDirectory() const
{
return this->GetCMakeInstance()->GetHomeDirectory();
}
-const char* cmLocalGenerator::GetBinaryDirectory() const
+std::string const& cmLocalGenerator::GetBinaryDirectory() const
{
return this->GetCMakeInstance()->GetHomeOutputDirectory();
}
-const char* cmLocalGenerator::GetCurrentBinaryDirectory() const
+std::string const& cmLocalGenerator::GetCurrentBinaryDirectory() const
{
return this->StateSnapshot.GetDirectory().GetCurrentBinary();
}
-const char* cmLocalGenerator::GetCurrentSourceDirectory() const
+std::string const& cmLocalGenerator::GetCurrentSourceDirectory() const
{
return this->StateSnapshot.GetDirectory().GetCurrentSource();
}
+std::string cmLocalGenerator::MaybeConvertToRelativePath(
+ std::string const& local_path, std::string const& remote_path) const
+{
+ return this->StateSnapshot.GetDirectory().ConvertToRelPathIfNotContained(
+ local_path, remote_path);
+}
+
std::string cmLocalGenerator::GetTargetDirectory(
const cmGeneratorTarget* /*unused*/) const
{
@@ -2479,7 +3342,7 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const
<< "CMake is dropping a preprocessor definition: " << define << "\n"
<< "Consider defining the macro in a (configured) header file.\n";
/* clang-format on */
- cmSystemTools::Message(e.str().c_str());
+ cmSystemTools::Message(e.str());
return false;
}
}
@@ -2494,7 +3357,7 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const
<< "CMake is dropping a preprocessor definition: " << define << "\n"
<< "Consider defining the macro in a (configured) header file.\n";
/* clang-format on */
- cmSystemTools::Message(e.str().c_str());
+ cmSystemTools::Message(e.str());
return false;
}
@@ -2512,22 +3375,22 @@ static void cmLGInfoProp(cmMakefile* mf, cmGeneratorTarget* target,
void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
const std::string& targetName,
- const char* fname)
+ const std::string& fname)
{
// Find the Info.plist template.
const char* in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST");
std::string inFile = (in && *in) ? in : "MacOSXBundleInfo.plist.in";
- if (!cmSystemTools::FileIsFullPath(inFile.c_str())) {
- std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
+ if (!cmSystemTools::FileIsFullPath(inFile)) {
+ std::string inMod = this->Makefile->GetModulesFile(inFile);
if (!inMod.empty()) {
inFile = inMod;
}
}
- if (!cmSystemTools::FileExists(inFile.c_str(), true)) {
+ if (!cmSystemTools::FileExists(inFile, true)) {
std::ostringstream e;
e << "Target " << target->GetName() << " Info.plist template \"" << inFile
<< "\" could not be found.";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return;
}
@@ -2537,7 +3400,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
// back to the directory-level values set by the user.
cmMakefile* mf = this->Makefile;
cmMakefile::ScopePushPop varScope(mf);
- mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName.c_str());
+ mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName);
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_INFO_STRING");
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_ICON_FILE");
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_GUI_IDENTIFIER");
@@ -2546,26 +3409,27 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_SHORT_VERSION_STRING");
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_BUNDLE_VERSION");
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_COPYRIGHT");
- mf->ConfigureFile(inFile.c_str(), fname, false, false, false);
+ mf->ConfigureFile(inFile, fname, false, false, false);
}
void cmLocalGenerator::GenerateFrameworkInfoPList(
- cmGeneratorTarget* target, const std::string& targetName, const char* fname)
+ cmGeneratorTarget* target, const std::string& targetName,
+ const std::string& fname)
{
// Find the Info.plist template.
const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
std::string inFile = (in && *in) ? in : "MacOSXFrameworkInfo.plist.in";
- if (!cmSystemTools::FileIsFullPath(inFile.c_str())) {
- std::string inMod = this->Makefile->GetModulesFile(inFile.c_str());
+ if (!cmSystemTools::FileIsFullPath(inFile)) {
+ std::string inMod = this->Makefile->GetModulesFile(inFile);
if (!inMod.empty()) {
inFile = inMod;
}
}
- if (!cmSystemTools::FileExists(inFile.c_str(), true)) {
+ if (!cmSystemTools::FileExists(inFile, true)) {
std::ostringstream e;
e << "Target " << target->GetName() << " Info.plist template \"" << inFile
<< "\" could not be found.";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return;
}
@@ -2575,10 +3439,10 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(
// back to the directory-level values set by the user.
cmMakefile* mf = this->Makefile;
cmMakefile::ScopePushPop varScope(mf);
- mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName.c_str());
+ mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName);
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_ICON_FILE");
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER");
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING");
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_BUNDLE_VERSION");
- mf->ConfigureFile(inFile.c_str(), fname, false, false, false);
+ mf->ConfigureFile(inFile, fname, false, false, false);
}
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 9f78be465..12359dbdd 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -3,20 +3,22 @@
#ifndef cmLocalGenerator_h
#define cmLocalGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cm_kwiml.h"
#include <iosfwd>
#include <map>
#include <set>
#include <string>
+#include <unordered_map>
#include <vector>
+#include "cm_kwiml.h"
+
#include "cmListFileCache.h"
+#include "cmMessageType.h"
#include "cmOutputConverter.h"
#include "cmPolicies.h"
#include "cmStateSnapshot.h"
-#include "cmake.h"
class cmComputeLinkInformation;
class cmCustomCommandGenerator;
@@ -27,6 +29,7 @@ class cmMakefile;
class cmRulePlaceholderExpander;
class cmSourceFile;
class cmState;
+class cmake;
/** \class cmLocalGenerator
* \brief Create required build files for a directory.
@@ -74,13 +77,13 @@ public:
bool IsRootMakefile() const;
- ///! Get the makefile for this generator
+ //! Get the makefile for this generator
cmMakefile* GetMakefile() { return this->Makefile; }
- ///! Get the makefile for this generator, const version
+ //! Get the makefile for this generator, const version
const cmMakefile* GetMakefile() const { return this->Makefile; }
- ///! Get the GlobalGenerator this is associated with
+ //! Get the GlobalGenerator this is associated with
cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; }
const cmGlobalGenerator* GetGlobalGenerator() const
{
@@ -116,15 +119,23 @@ public:
void AddCompilerRequirementFlag(std::string& flags,
cmGeneratorTarget const* target,
const std::string& lang);
- ///! Append flags to a string.
- virtual void AppendFlags(std::string& flags, const std::string& newFlags);
- virtual void AppendFlags(std::string& flags, const char* newFlags);
+ //! Append flags to a string.
+ virtual void AppendFlags(std::string& flags,
+ const std::string& newFlags) const;
+ virtual void AppendFlags(std::string& flags,
+ const std::vector<BT<std::string>>& newFlags) const;
virtual void AppendFlagEscape(std::string& flags,
- const std::string& rawFlag);
+ const std::string& rawFlag) const;
+ void AddPchDependencies(cmGeneratorTarget* target);
+ void AddUnityBuild(cmGeneratorTarget* target);
void AppendIPOLinkerFlags(std::string& flags, cmGeneratorTarget* target,
const std::string& config,
const std::string& lang);
- ///! Get the include flags for the current makefile and language
+ void AppendPositionIndependentLinkerFlags(std::string& flags,
+ cmGeneratorTarget* target,
+ const std::string& config,
+ const std::string& lang);
+ //! Get the include flags for the current makefile and language
std::string GetIncludeFlags(const std::vector<std::string>& includes,
cmGeneratorTarget* target,
const std::string& lang,
@@ -137,11 +148,6 @@ public:
return this->GeneratorTargets;
}
- const std::vector<cmGeneratorTarget*>& GetImportedGeneratorTargets() const
- {
- return this->ImportedGeneratorTargets;
- }
-
void AddGeneratorTarget(cmGeneratorTarget* gt);
void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
void AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt);
@@ -151,18 +157,51 @@ public:
cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
/**
+ * Process a list of include directories
+ */
+ void AppendIncludeDirectories(std::vector<std::string>& includes,
+ const char* includes_list,
+ const cmSourceFile& sourceFile) const;
+ void AppendIncludeDirectories(std::vector<std::string>& includes,
+ std::string const& includes_list,
+ const cmSourceFile& sourceFile) const
+ {
+ this->AppendIncludeDirectories(includes, includes_list.c_str(),
+ sourceFile);
+ }
+ void AppendIncludeDirectories(std::vector<std::string>& includes,
+ const std::vector<std::string>& includes_vec,
+ const cmSourceFile& sourceFile) const;
+
+ /**
* Encode a list of preprocessor definitions for the compiler
* command line.
*/
void AppendDefines(std::set<std::string>& defines,
- const char* defines_list) const;
- void AppendDefines(std::set<std::string>& defines,
- std::string const& defines_list) const
+ std::string const& defines_list) const;
+ void AppendDefines(std::set<BT<std::string>>& defines,
+ std::string const& defines_list) const;
+ void AppendDefines(std::set<BT<std::string>>& defines,
+ const std::vector<BT<std::string>>& defines_vec) const;
+
+ /**
+ * Encode a list of compile options for the compiler
+ * command line.
+ */
+ void AppendCompileOptions(std::string& options, const char* options_list,
+ const char* regex = nullptr) const;
+ void AppendCompileOptions(std::string& options,
+ std::string const& options_list,
+ const char* regex = nullptr) const
{
- this->AppendDefines(defines, defines_list.c_str());
+ this->AppendCompileOptions(options, options_list.c_str(), regex);
}
- void AppendDefines(std::set<std::string>& defines,
- const std::vector<std::string>& defines_vec) const;
+ void AppendCompileOptions(std::string& options,
+ const std::vector<std::string>& options_vec,
+ const char* regex = nullptr) const;
+ void AppendCompileOptions(std::vector<BT<std::string>>& options,
+ const std::vector<BT<std::string>>& options_vec,
+ const char* regex = nullptr) const;
/**
* Join a set of defines into a definesString with a space separator.
@@ -201,24 +240,57 @@ public:
virtual void ClearDependencies(cmMakefile* /* mf */, bool /* verbose */) {}
/** Called from command-line hook to update dependencies. */
- virtual bool UpdateDependencies(const char* /* tgtInfo */, bool /*verbose*/,
- bool /*color*/)
+ virtual bool UpdateDependencies(const std::string& /* tgtInfo */,
+ bool /*verbose*/, bool /*color*/)
{
return true;
}
- /** Get the include flags for the current makefile and language. */
+ /** @brief Get the include directories for the current makefile and language
+ * and optional the compiler implicit include directories.
+ *
+ * @arg stripImplicitDirs Strip all directories found in
+ * CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES from the result.
+ * @arg appendAllImplicitDirs Append all directories found in
+ * CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES to the result.
+ */
+ std::vector<BT<std::string>> GetIncludeDirectoriesImplicit(
+ cmGeneratorTarget const* target, std::string const& lang = "C",
+ std::string const& config = "", bool stripImplicitDirs = true,
+ bool appendAllImplicitDirs = false) const;
+
+ /** @brief Get the include directories for the current makefile and language
+ * and optional the compiler implicit include directories.
+ *
+ * @arg dirs Directories are appended to this list
+ */
+ void GetIncludeDirectoriesImplicit(std::vector<std::string>& dirs,
+ cmGeneratorTarget const* target,
+ const std::string& lang = "C",
+ const std::string& config = "",
+ bool stripImplicitDirs = true,
+ bool appendAllImplicitDirs = false) const;
+
+ /** @brief Get the include directories for the current makefile and language.
+ * @arg dirs Include directories are appended to this list
+ */
void GetIncludeDirectories(std::vector<std::string>& dirs,
cmGeneratorTarget const* target,
const std::string& lang = "C",
- const std::string& config = "",
- bool stripImplicitInclDirs = true) const;
+ const std::string& config = "") const;
+
+ /** @brief Get the include directories for the current makefile and language.
+ * @return The include directory list
+ */
+ std::vector<BT<std::string>> GetIncludeDirectories(
+ cmGeneratorTarget const* target, std::string const& lang = "C",
+ std::string const& config = "") const;
+
void AddCompileOptions(std::string& flags, cmGeneratorTarget* target,
const std::string& lang, const std::string& config);
- void AddCompileDefinitions(std::set<std::string>& defines,
- cmGeneratorTarget const* target,
- const std::string& config,
- const std::string& lang) const;
+ void AddCompileOptions(std::vector<BT<std::string>>& flags,
+ cmGeneratorTarget* target, const std::string& lang,
+ const std::string& config);
std::string GetProjectName() const;
@@ -257,37 +329,51 @@ public:
cmake* GetCMakeInstance() const;
- const char* GetSourceDirectory() const;
- const char* GetBinaryDirectory() const;
+ std::string const& GetSourceDirectory() const;
+ std::string const& GetBinaryDirectory() const;
- const char* GetCurrentBinaryDirectory() const;
- const char* GetCurrentSourceDirectory() const;
+ std::string const& GetCurrentBinaryDirectory() const;
+ std::string const& GetCurrentSourceDirectory() const;
/**
- * Generate a Mac OS X application bundle Info.plist file.
+ * Convert the given remote path to a relative path with respect to
+ * the given local path. Both paths must use forward slashes and not
+ * already be escaped or quoted.
+ * The conversion is skipped if the paths are not both in the source
+ * or both in the binary tree.
+ */
+ std::string MaybeConvertToRelativePath(std::string const& local_path,
+ std::string const& remote_path) const;
+
+ /**
+ * Generate a macOS application bundle Info.plist file.
*/
void GenerateAppleInfoPList(cmGeneratorTarget* target,
const std::string& targetName,
- const char* fname);
+ const std::string& fname);
/**
- * Generate a Mac OS X framework Info.plist file.
+ * Generate a macOS framework Info.plist file.
*/
void GenerateFrameworkInfoPList(cmGeneratorTarget* target,
const std::string& targetName,
- const char* fname);
+ const std::string& fname);
/** Construct a comment for a custom command. */
std::string ConstructComment(cmCustomCommandGenerator const& ccg,
const char* default_comment = "");
// Compute object file names.
std::string GetObjectFileNameWithoutTarget(
const cmSourceFile& source, std::string const& dir_max,
- bool* hasSourceExtension = CM_NULLPTR,
- char const* customOutputExtension = CM_NULLPTR);
+ bool* hasSourceExtension = nullptr,
+ char const* customOutputExtension = nullptr);
/** Fill out the static linker flags for the given target. */
void GetStaticLibraryFlags(std::string& flags, std::string const& config,
+ std::string const& linkLanguage,
cmGeneratorTarget* target);
+ std::vector<BT<std::string>> GetStaticLibraryFlags(
+ std::string const& config, std::string const& linkLanguage,
+ cmGeneratorTarget* target);
/** Fill out these strings for the given target. Libraries to link,
* flags, and linkflags. */
@@ -296,12 +382,23 @@ public:
std::string& flags, std::string& linkFlags,
std::string& frameworkPath, std::string& linkPath,
cmGeneratorTarget* target);
+ void GetTargetFlags(
+ cmLinkLineComputer* linkLineComputer, const std::string& config,
+ std::vector<BT<std::string>>& linkLibs, std::string& flags,
+ std::vector<BT<std::string>>& linkFlags, std::string& frameworkPath,
+ std::vector<BT<std::string>>& linkPath, cmGeneratorTarget* target);
void GetTargetDefines(cmGeneratorTarget const* target,
std::string const& config, std::string const& lang,
std::set<std::string>& defines) const;
+ std::set<BT<std::string>> GetTargetDefines(cmGeneratorTarget const* target,
+ std::string const& config,
+ std::string const& lang) const;
void GetTargetCompileFlags(cmGeneratorTarget* target,
std::string const& config,
std::string const& lang, std::string& flags);
+ std::vector<BT<std::string>> GetTargetCompileFlags(cmGeneratorTarget* target,
+ std::string const& config,
+ std::string const& lang);
std::string GetFrameworkFlags(std::string const& l,
std::string const& config,
@@ -311,15 +408,16 @@ public:
virtual void ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping,
- cmGeneratorTarget const* gt = CM_NULLPTR);
+ cmGeneratorTarget const* gt = nullptr);
bool IsWindowsShell() const;
bool IsWatcomWMake() const;
bool IsMinGWMake() const;
bool IsNMake() const;
- void IssueMessage(cmake::MessageType t, std::string const& text) const;
+ void IssueMessage(MessageType t, std::string const& text) const;
+ void CreateEvaluationFileOutputs();
void CreateEvaluationFileOutputs(const std::string& config);
void ProcessEvaluationFiles(std::vector<std::string>& generatedFiles);
@@ -327,11 +425,16 @@ public:
const std::string& prop);
protected:
- ///! put all the libraries for a target on into the given stream
+ //! put all the libraries for a target on into the given stream
void OutputLinkLibraries(cmComputeLinkInformation* pcli,
cmLinkLineComputer* linkLineComputer,
std::string& linkLibraries,
std::string& frameworkPath, std::string& linkPath);
+ void OutputLinkLibraries(cmComputeLinkInformation* pcli,
+ cmLinkLineComputer* linkLineComputer,
+ std::vector<BT<std::string>>& linkLibraries,
+ std::string& frameworkPath,
+ std::vector<BT<std::string>>& linkPath);
// Handle old-style install rules stored in the targets.
void GenerateTargetInstallRules(
@@ -353,9 +456,15 @@ protected:
std::string::size_type ObjectPathMax;
std::set<std::string> ObjectMaxPathViolations;
- std::set<cmGeneratorTarget const*> WarnCMP0063;
+ std::set<std::string> EnvCPATH;
+
+ using GeneratorTargetMap =
+ std::unordered_map<std::string, cmGeneratorTarget*>;
+ GeneratorTargetMap GeneratorTargetSearchIndex;
std::vector<cmGeneratorTarget*> GeneratorTargets;
- std::vector<cmGeneratorTarget*> ImportedGeneratorTargets;
+
+ std::set<cmGeneratorTarget const*> WarnCMP0063;
+ GeneratorTargetMap ImportedGeneratorTargets;
std::vector<cmGeneratorTarget*> OwnedImportedGeneratorTargets;
std::map<std::string, std::string> AliasTargets;
@@ -379,7 +488,7 @@ private:
void ComputeObjectMaxPath();
};
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
bool cmLocalGeneratorCheckObjectName(std::string& objName,
std::string::size_type dir_len,
std::string::size_type max_total_len);
diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx
index 5f37af528..4b10798e1 100644
--- a/Source/cmLocalGhsMultiGenerator.cxx
+++ b/Source/cmLocalGhsMultiGenerator.cxx
@@ -2,11 +2,16 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLocalGhsMultiGenerator.h"
-#include "cmGeneratedFileStream.h"
+#include <algorithm>
+#include <utility>
+
#include "cmGeneratorTarget.h"
#include "cmGhsMultiTargetGenerator.h"
-#include "cmGlobalGhsMultiGenerator.h"
-#include "cmMakefile.h"
+#include "cmGlobalGenerator.h"
+#include "cmSourceFile.h"
+#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg,
cmMakefile* mf)
@@ -14,20 +19,80 @@ cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg,
{
}
-cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator()
+cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator() = default;
+
+std::string cmLocalGhsMultiGenerator::GetTargetDirectory(
+ cmGeneratorTarget const* target) const
{
+ std::string dir = cmStrCat(target->GetName(), ".dir");
+ return dir;
+}
+
+void cmLocalGhsMultiGenerator::GenerateTargetsDepthFirst(
+ cmGeneratorTarget* target, std::vector<cmGeneratorTarget*>& remaining)
+{
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ return;
+ }
+ // Find this target in the list of remaining targets.
+ auto it = std::find(remaining.begin(), remaining.end(), target);
+ if (it == remaining.end()) {
+ // This target was already handled.
+ return;
+ }
+ // Remove this target from the list of remaining targets because
+ // we are handling it now.
+ *it = nullptr;
+
+ cmGhsMultiTargetGenerator tg(target);
+ tg.Generate();
}
void cmLocalGhsMultiGenerator::Generate()
{
- std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
+ std::vector<cmGeneratorTarget*> remaining = this->GetGeneratorTargets();
+ for (auto& t : remaining) {
+ if (t) {
+ GenerateTargetsDepthFirst(t, remaining);
+ }
+ }
+}
+
+void cmLocalGhsMultiGenerator::ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt)
+{
+ std::string dir_max = cmStrCat(this->GetCurrentBinaryDirectory(), '/',
+ this->GetTargetDirectory(gt), '/');
+
+ // Count the number of object files with each name. Note that
+ // filesystem may not be case sensitive.
+ std::map<std::string, int> counts;
+
+ for (auto const& si : mapping) {
+ cmSourceFile const* sf = si.first;
+ std::string objectNameLower = cmStrCat(
+ cmSystemTools::LowerCase(
+ cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())),
+ this->GlobalGenerator->GetLanguageOutputExtension(*sf));
+ counts[objectNameLower] += 1;
+ }
+
+ // For all source files producing duplicate names we need unique
+ // object name computation.
+ for (auto& si : mapping) {
+ cmSourceFile const* sf = si.first;
+ std::string objectName = cmStrCat(
+ cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()),
+ this->GlobalGenerator->GetLanguageOutputExtension(*sf));
- for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); ++l) {
- if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
- continue;
+ if (counts[cmSystemTools::LowerCase(objectName)] > 1) {
+ const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf);
+ bool keptSourceExtension;
+ objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max,
+ &keptSourceExtension);
+ cmsys::SystemTools::ReplaceString(objectName, "/", "_");
}
- cmGhsMultiTargetGenerator tg(*l);
- tg.Generate();
+ si.second = objectName;
}
}
diff --git a/Source/cmLocalGhsMultiGenerator.h b/Source/cmLocalGhsMultiGenerator.h
index aa842d74b..2250e5745 100644
--- a/Source/cmLocalGhsMultiGenerator.h
+++ b/Source/cmLocalGhsMultiGenerator.h
@@ -3,9 +3,16 @@
#ifndef cmLocalGhsMultiGenerator_h
#define cmLocalGhsMultiGenerator_h
+#include <map>
+#include <string>
+#include <vector>
+
#include "cmLocalGenerator.h"
-class cmGeneratedFileStream;
+class cmGeneratorTarget;
+class cmGlobalGenerator;
+class cmMakefile;
+class cmSourceFile;
/** \class cmLocalGhsMultiGenerator
* \brief Write Green Hills MULTI project files.
@@ -18,12 +25,23 @@ class cmLocalGhsMultiGenerator : public cmLocalGenerator
public:
cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
- virtual ~cmLocalGhsMultiGenerator();
+ ~cmLocalGhsMultiGenerator() override;
/**
* Generate the makefile for this directory.
*/
- virtual void Generate();
+ void Generate() override;
+
+ std::string GetTargetDirectory(
+ cmGeneratorTarget const* target) const override;
+
+ void ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt = nullptr) override;
+
+private:
+ void GenerateTargetsDepthFirst(cmGeneratorTarget* target,
+ std::vector<cmGeneratorTarget*>& remaining);
};
#endif
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 266710cb1..134bbe18a 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -3,26 +3,32 @@
#include "cmLocalNinjaGenerator.h"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
#include <iterator>
+#include <memory>
#include <sstream>
-#include <stdio.h>
#include <utility>
+#include "cmsys/FStream.hxx"
+
+#include "cmCryptoHash.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
#include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
#include "cmGlobalNinjaGenerator.h"
+#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmNinjaTargetGenerator.h"
#include "cmRulePlaceholderExpander.h"
#include "cmSourceFile.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
@@ -38,24 +44,21 @@ cmRulePlaceholderExpander*
cmLocalNinjaGenerator::CreateRulePlaceholderExpander() const
{
cmRulePlaceholderExpander* ret =
- new cmRulePlaceholderExpander(this->Compilers, this->VariableMappings,
- this->CompilerSysroot, this->LinkerSysroot);
+ this->cmLocalGenerator::CreateRulePlaceholderExpander();
ret->SetTargetImpLib("$TARGET_IMPLIB");
return ret;
}
-cmLocalNinjaGenerator::~cmLocalNinjaGenerator()
-{
-}
+cmLocalNinjaGenerator::~cmLocalNinjaGenerator() = default;
void cmLocalNinjaGenerator::Generate()
{
// Compute the path to use when referencing the current output
// directory from the top output directory.
- this->HomeRelativeOutputPath = this->ConvertToRelativePath(
+ this->HomeRelativeOutputPath = this->MaybeConvertToRelativePath(
this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory());
if (this->HomeRelativeOutputPath == ".") {
- this->HomeRelativeOutputPath = "";
+ this->HomeRelativeOutputPath.clear();
}
this->WriteProcessedMakefile(this->GetBuildFileStream());
@@ -69,43 +72,35 @@ void cmLocalNinjaGenerator::Generate()
this->WritePools(this->GetRulesFileStream());
- const std::string showIncludesPrefix =
+ const std::string& showIncludesPrefix =
this->GetMakefile()->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
if (!showIncludesPrefix.empty()) {
cmGlobalNinjaGenerator::WriteComment(this->GetRulesFileStream(),
"localized /showIncludes string");
- this->GetRulesFileStream() << "msvc_deps_prefix = " << showIncludesPrefix
- << "\n\n";
+ this->GetRulesFileStream()
+ << "msvc_deps_prefix = " << showIncludesPrefix << "\n\n";
}
}
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
- t != targets.end(); ++t) {
- if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmGeneratorTarget* target : this->GetGeneratorTargets()) {
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(*t);
+ auto tg = cmNinjaTargetGenerator::New(target);
if (tg) {
tg->Generate();
- // Add the target to "all" if required.
- if (!this->GetGlobalNinjaGenerator()->IsExcluded(
- this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], *t)) {
- this->GetGlobalNinjaGenerator()->AddDependencyToAll(*t);
- }
- delete tg;
}
}
this->WriteCustomCommandBuildStatements();
+ this->AdditionalCleanFiles();
}
// TODO: Picked up from cmLocalUnixMakefileGenerator3. Refactor it.
std::string cmLocalNinjaGenerator::GetTargetDirectory(
cmGeneratorTarget const* target) const
{
- std::string dir = cmake::GetCMakeFilesDirectoryPostSlash();
- dir += target->GetName();
+ std::string dir = cmStrCat("CMakeFiles/", target->GetName());
#if defined(__VMS)
dir += "_dir";
#else
@@ -139,7 +134,8 @@ std::string cmLocalNinjaGenerator::ConvertToIncludeReference(
format);
}
return this->ConvertToOutputFormat(
- this->ConvertToRelativePath(this->GetBinaryDirectory(), path), format);
+ this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), path),
+ format);
}
// Private methods.
@@ -186,13 +182,22 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os)
void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream& os)
{
// Default required version
- std::string requiredVersion =
- this->GetGlobalNinjaGenerator()->RequiredNinjaVersion();
+ std::string requiredVersion = cmGlobalNinjaGenerator::RequiredNinjaVersion();
// Ninja generator uses the 'console' pool if available (>= 1.5)
if (this->GetGlobalNinjaGenerator()->SupportsConsolePool()) {
requiredVersion =
- this->GetGlobalNinjaGenerator()->RequiredNinjaVersionForConsolePool();
+ cmGlobalNinjaGenerator::RequiredNinjaVersionForConsolePool();
+ }
+
+ // The Ninja generator writes rules which require support for restat
+ // when rebuilding build.ninja manifest (>= 1.8)
+ if (this->GetGlobalNinjaGenerator()->SupportsManifestRestat() &&
+ this->GetCMakeInstance()->DoWriteGlobVerifyTarget() &&
+ !this->GetGlobalNinjaGenerator()->GlobalSettingIsOn(
+ "CMAKE_SUPPRESS_REGENERATION")) {
+ requiredVersion =
+ cmGlobalNinjaGenerator::RequiredNinjaVersionForManifestRestat();
}
cmGlobalNinjaGenerator::WriteComment(
@@ -207,13 +212,14 @@ void cmLocalNinjaGenerator::WritePools(std::ostream& os)
const char* jobpools =
this->GetCMakeInstance()->GetState()->GetGlobalProperty("JOB_POOLS");
+ if (!jobpools) {
+ jobpools = this->GetMakefile()->GetDefinition("CMAKE_JOB_POOLS");
+ }
if (jobpools) {
cmGlobalNinjaGenerator::WriteComment(
os, "Pools defined by global property JOB_POOLS");
- std::vector<std::string> pools;
- cmSystemTools::ExpandListArgument(jobpools, pools);
- for (size_t i = 0; i < pools.size(); ++i) {
- std::string const& pool = pools[i];
+ std::vector<std::string> pools = cmExpandedList(jobpools);
+ for (std::string const& pool : pools) {
const std::string::size_type eq = pool.find('=');
unsigned int jobs;
if (eq != std::string::npos &&
@@ -222,8 +228,8 @@ void cmLocalNinjaGenerator::WritePools(std::ostream& os)
os << " depth = " << jobs << std::endl;
os << std::endl;
} else {
- cmSystemTools::Error("Invalid pool defined by property 'JOB_POOLS': ",
- pool.c_str());
+ cmSystemTools::Error("Invalid pool defined by property 'JOB_POOLS': " +
+ pool);
}
}
}
@@ -237,29 +243,12 @@ void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os)
cmGlobalNinjaGenerator* ng = this->GetGlobalNinjaGenerator();
std::string const ninjaRulesFile =
ng->NinjaOutputPath(cmGlobalNinjaGenerator::NINJA_RULES_FILE);
- std::string const rulesFilePath =
- ng->EncodeIdent(ng->EncodePath(ninjaRulesFile), os);
+ std::string const rulesFilePath = ng->EncodePath(ninjaRulesFile);
cmGlobalNinjaGenerator::WriteInclude(os, rulesFilePath,
"Include rules file.");
os << "\n";
}
-void cmLocalNinjaGenerator::ComputeObjectFilenames(
- std::map<cmSourceFile const*, std::string>& mapping,
- cmGeneratorTarget const* gt)
-{
- // Determine if these object files should use a custom extension
- char const* custom_ext = gt->GetCustomObjectExtension();
- for (std::map<cmSourceFile const*, std::string>::iterator si =
- mapping.begin();
- si != mapping.end(); ++si) {
- cmSourceFile const* sf = si->first;
- bool keptSourceExtension;
- si->second = this->GetObjectFileNameWithoutTarget(
- *sf, gt->ObjectDirectory, &keptSourceExtension, custom_ext);
- }
-}
-
void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
{
cmGlobalNinjaGenerator::WriteDivider(os);
@@ -290,19 +279,72 @@ void cmLocalNinjaGenerator::AppendTargetDepends(cmGeneratorTarget* target,
void cmLocalNinjaGenerator::AppendCustomCommandDeps(
cmCustomCommandGenerator const& ccg, cmNinjaDeps& ninjaDeps)
{
- const std::vector<std::string>& deps = ccg.GetDepends();
- for (std::vector<std::string>::const_iterator i = deps.begin();
- i != deps.end(); ++i) {
+ for (std::string const& i : ccg.GetDepends()) {
std::string dep;
- if (this->GetRealDependency(*i, this->GetConfigName(), dep)) {
+ if (this->GetRealDependency(i, this->GetConfigName(), dep)) {
ninjaDeps.push_back(
this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(dep));
}
}
}
+std::string cmLocalNinjaGenerator::WriteCommandScript(
+ std::vector<std::string> const& cmdLines, std::string const& customStep,
+ cmGeneratorTarget const* target) const
+{
+ std::string scriptPath;
+ if (target) {
+ scriptPath = target->GetSupportDirectory();
+ } else {
+ scriptPath = cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles");
+ }
+ cmSystemTools::MakeDirectory(scriptPath);
+ scriptPath += '/';
+ scriptPath += customStep;
+#ifdef _WIN32
+ scriptPath += ".bat";
+#else
+ scriptPath += ".sh";
+#endif
+
+ cmsys::ofstream script(scriptPath.c_str());
+
+#ifdef _WIN32
+ script << "@echo off\n";
+ int line = 1;
+#else
+ script << "set -e\n\n";
+#endif
+
+ for (auto const& i : cmdLines) {
+ std::string cmd = i;
+ // The command line was built assuming it would be written to
+ // the build.ninja file, so it uses '$$' for '$'. Remove this
+ // for the raw shell script.
+ cmSystemTools::ReplaceString(cmd, "$$", "$");
+#ifdef _WIN32
+ script << cmd << " || (set FAIL_LINE=" << ++line << "& goto :ABORT)"
+ << '\n';
+#else
+ script << cmd << '\n';
+#endif
+ }
+
+#ifdef _WIN32
+ script << "goto :EOF\n\n"
+ ":ABORT\n"
+ "set ERROR_CODE=%ERRORLEVEL%\n"
+ "echo Batch file failed at line %FAIL_LINE% "
+ "with errorcode %ERRORLEVEL%\n"
+ "exit /b %ERROR_CODE%";
+#endif
+
+ return scriptPath;
+}
+
std::string cmLocalNinjaGenerator::BuildCommandLine(
- const std::vector<std::string>& cmdLines)
+ std::vector<std::string> const& cmdLines, std::string const& customStep,
+ cmGeneratorTarget const* target) const
{
// If we have no commands but we need to build a command anyway, use noop.
// This happens when building a POST_BUILD value for link targets that
@@ -311,9 +353,37 @@ std::string cmLocalNinjaGenerator::BuildCommandLine(
return cmGlobalNinjaGenerator::SHELL_NOOP;
}
+ // If this is a custom step then we will have no '$VAR' ninja placeholders.
+ // This means we can deal with long command sequences by writing to a script.
+ // Do this if the command lines are on the scale of the OS limit.
+ if (!customStep.empty()) {
+ size_t cmdLinesTotal = 0;
+ for (std::string const& cmd : cmdLines) {
+ cmdLinesTotal += cmd.length() + 6;
+ }
+ if (cmdLinesTotal > cmSystemTools::CalculateCommandLineLengthLimit() / 2) {
+ std::string const scriptPath =
+ this->WriteCommandScript(cmdLines, customStep, target);
+ std::string cmd
+#ifndef _WIN32
+ = "/bin/sh "
+#endif
+ ;
+ cmd += this->ConvertToOutputFormat(
+ this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(scriptPath),
+ cmOutputConverter::SHELL);
+
+ // Add an unused argument based on script content so that Ninja
+ // knows when the command lines change.
+ cmd += " ";
+ cmCryptoHash hash(cmCryptoHash::AlgoSHA256);
+ cmd += hash.HashFile(scriptPath).substr(0, 16);
+ return cmd;
+ }
+ }
+
std::ostringstream cmd;
- for (std::vector<std::string>::const_iterator li = cmdLines.begin();
- li != cmdLines.end(); ++li)
+ for (auto li = cmdLines.begin(); li != cmdLines.end(); ++li)
#ifdef _WIN32
{
if (li != cmdLines.begin()) {
@@ -378,7 +448,8 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(
void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
cmCustomCommand const* cc, const cmNinjaDeps& orderOnlyDeps)
{
- if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc)) {
+ cmGlobalNinjaGenerator* gg = this->GetGlobalNinjaGenerator();
+ if (gg->SeenCustomCommand(cc)) {
return;
}
@@ -386,46 +457,56 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
const std::vector<std::string>& outputs = ccg.GetOutputs();
const std::vector<std::string>& byproducts = ccg.GetByproducts();
- cmNinjaDeps ninjaOutputs(outputs.size() + byproducts.size()), ninjaDeps;
bool symbolic = false;
- for (std::vector<std::string>::const_iterator o = outputs.begin();
- !symbolic && o != outputs.end(); ++o) {
- if (cmSourceFile* sf = this->Makefile->GetSource(*o)) {
- symbolic = sf->GetPropertyAsBool("SYMBOLIC");
+ for (std::string const& output : outputs) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(output)) {
+ if (sf->GetPropertyAsBool("SYMBOLIC")) {
+ symbolic = true;
+ break;
+ }
}
}
#if 0
-#error TODO: Once CC in an ExternalProject target must provide the \
+# error TODO: Once CC in an ExternalProject target must provide the \
file of each imported target that has an add_dependencies pointing \
at us. How to know which ExternalProject step actually provides it?
#endif
+ cmNinjaDeps ninjaOutputs(outputs.size() + byproducts.size());
std::transform(outputs.begin(), outputs.end(), ninjaOutputs.begin(),
- this->GetGlobalNinjaGenerator()->MapToNinjaPath());
+ gg->MapToNinjaPath());
std::transform(byproducts.begin(), byproducts.end(),
- ninjaOutputs.begin() + outputs.size(),
- this->GetGlobalNinjaGenerator()->MapToNinjaPath());
- this->AppendCustomCommandDeps(ccg, ninjaDeps);
+ ninjaOutputs.begin() + outputs.size(), gg->MapToNinjaPath());
- for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end();
- ++i) {
- this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(*i);
+ for (std::string const& ninjaOutput : ninjaOutputs) {
+ gg->SeenCustomCommandOutput(ninjaOutput);
}
+ cmNinjaDeps ninjaDeps;
+ this->AppendCustomCommandDeps(ccg, ninjaDeps);
+
std::vector<std::string> cmdLines;
this->AppendCustomCommandLines(ccg, cmdLines);
if (cmdLines.empty()) {
- this->GetGlobalNinjaGenerator()->WritePhonyBuild(
- this->GetBuildFileStream(),
- "Phony custom command for " + ninjaOutputs[0], ninjaOutputs, ninjaDeps,
- cmNinjaDeps(), orderOnlyDeps, cmNinjaVars());
+ cmNinjaBuild build("phony");
+ build.Comment = "Phony custom command for " + ninjaOutputs[0];
+ build.Outputs = std::move(ninjaOutputs);
+ build.ExplicitDeps = std::move(ninjaDeps);
+ build.OrderOnlyDeps = orderOnlyDeps;
+ gg->WriteBuild(this->GetBuildFileStream(), build);
} else {
- this->GetGlobalNinjaGenerator()->WriteCustomCommandBuild(
- this->BuildCommandLine(cmdLines), this->ConstructComment(ccg),
- "Custom command for " + ninjaOutputs[0], cc->GetDepfile(),
- cc->GetUsesTerminal(),
+ std::string customStep = cmSystemTools::GetFilenameName(ninjaOutputs[0]);
+ // Hash full path to make unique.
+ customStep += '-';
+ cmCryptoHash hash(cmCryptoHash::AlgoSHA256);
+ customStep += hash.HashString(ninjaOutputs[0]).substr(0, 7);
+
+ gg->WriteCustomCommandBuild(
+ this->BuildCommandLine(cmdLines, customStep),
+ this->ConstructComment(ccg), "Custom command for " + ninjaOutputs[0],
+ cc->GetDepfile(), cc->GetJobPool(), cc->GetUsesTerminal(),
/*restat*/ !symbolic || !byproducts.empty(), ninjaOutputs, ninjaDeps,
orderOnlyDeps);
}
@@ -445,10 +526,8 @@ void cmLocalNinjaGenerator::AddCustomCommandTarget(cmCustomCommand const* cc,
void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements()
{
- for (std::vector<cmCustomCommand const*>::iterator vi =
- this->CustomCommands.begin();
- vi != this->CustomCommands.end(); ++vi) {
- CustomCommandTargetMap::iterator i = this->CustomCommandTargets.find(*vi);
+ for (cmCustomCommand const* customCommand : this->CustomCommands) {
+ auto i = this->CustomCommandTargets.find(customCommand);
assert(i != this->CustomCommandTargets.end());
// A custom command may appear on multiple targets. However, some build
@@ -460,7 +539,7 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements()
//
// FIXME: This won't work in certain obscure scenarios involving indirect
// dependencies.
- std::set<cmGeneratorTarget*>::iterator j = i->second.begin();
+ auto j = i->second.begin();
assert(j != i->second.end());
std::vector<std::string> ccTargetDeps;
this->GetGlobalNinjaGenerator()->AppendTargetDependsClosure(*j,
@@ -469,7 +548,8 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements()
++j;
for (; j != i->second.end(); ++j) {
- std::vector<std::string> jDeps, depsIntersection;
+ std::vector<std::string> jDeps;
+ std::vector<std::string> depsIntersection;
this->GetGlobalNinjaGenerator()->AppendTargetDependsClosure(*j, jDeps);
std::sort(jDeps.begin(), jDeps.end());
std::set_intersection(ccTargetDeps.begin(), ccTargetDeps.end(),
@@ -492,8 +572,7 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
return std::string();
}
- // Expand rules in the empty string. It may insert the launcher and
- // perform replacements.
+ // Expand rule variables referenced in the given launcher command.
cmRulePlaceholderExpander::RuleVariables vars;
std::string output;
@@ -501,19 +580,17 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
if (!outputs.empty()) {
output = outputs[0];
if (ccg.GetWorkingDirectory().empty()) {
- output =
- this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), output);
+ output = this->MaybeConvertToRelativePath(
+ this->GetCurrentBinaryDirectory(), output);
}
output = this->ConvertToOutputFormat(output, cmOutputConverter::SHELL);
}
vars.Output = output.c_str();
- std::string launcher = property_value;
- launcher += " ";
-
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->CreateRulePlaceholderExpander());
+ std::string launcher = property_value;
rulePlaceholderExpander->ExpandRuleVariables(this, launcher, vars);
if (!launcher.empty()) {
launcher += " ";
@@ -521,3 +598,24 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
return launcher;
}
+
+void cmLocalNinjaGenerator::AdditionalCleanFiles()
+{
+ if (const char* prop_value =
+ this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) {
+ std::vector<std::string> cleanFiles;
+ {
+ cmExpandList(cmGeneratorExpression::Evaluate(
+ prop_value, this,
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")),
+ cleanFiles);
+ }
+ std::string const& binaryDir = this->GetCurrentBinaryDirectory();
+ cmGlobalNinjaGenerator* gg = this->GetGlobalNinjaGenerator();
+ for (std::string const& cleanFile : cleanFiles) {
+ // Support relative paths
+ gg->AddAdditionalCleanFile(
+ cmSystemTools::CollapseFullPath(cleanFile, binaryDir));
+ }
+ }
+}
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index a45e01851..f64534ce1 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmLocalNinjaGenerator_h
#define cmLocalNinjaGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
@@ -23,7 +23,6 @@ class cmGlobalGenerator;
class cmGlobalNinjaGenerator;
class cmMakefile;
class cmRulePlaceholderExpander;
-class cmSourceFile;
class cmake;
/**
@@ -38,14 +37,14 @@ class cmLocalNinjaGenerator : public cmLocalCommonGenerator
public:
cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
- ~cmLocalNinjaGenerator() CM_OVERRIDE;
+ ~cmLocalNinjaGenerator() override;
- void Generate() CM_OVERRIDE;
+ void Generate() override;
- cmRulePlaceholderExpander* CreateRulePlaceholderExpander() const CM_OVERRIDE;
+ cmRulePlaceholderExpander* CreateRulePlaceholderExpander() const override;
- std::string GetTargetDirectory(cmGeneratorTarget const* target) const
- CM_OVERRIDE;
+ std::string GetTargetDirectory(
+ cmGeneratorTarget const* target) const override;
const cmGlobalNinjaGenerator* GetGlobalNinjaGenerator() const;
cmGlobalNinjaGenerator* GetGlobalNinjaGenerator();
@@ -60,7 +59,10 @@ public:
return this->HomeRelativeOutputPath;
}
- std::string BuildCommandLine(const std::vector<std::string>& cmdLines);
+ std::string BuildCommandLine(
+ std::vector<std::string> const& cmdLines,
+ std::string const& customStep = std::string(),
+ cmGeneratorTarget const* target = nullptr) const;
void AppendTargetOutputs(cmGeneratorTarget* target, cmNinjaDeps& outputs);
void AppendTargetDepends(
@@ -74,15 +76,11 @@ public:
void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
cmNinjaDeps& ninjaDeps);
- void ComputeObjectFilenames(
- std::map<cmSourceFile const*, std::string>& mapping,
- cmGeneratorTarget const* gt = CM_NULLPTR) CM_OVERRIDE;
-
protected:
std::string ConvertToIncludeReference(
std::string const& path,
cmOutputConverter::OutputFormat format = cmOutputConverter::SHELL,
- bool forceFullPaths = false) CM_OVERRIDE;
+ bool forceFullPaths = false) override;
private:
cmGeneratedFileStream& GetBuildFileStream() const;
@@ -95,7 +93,6 @@ private:
void WriteProcessedMakefile(std::ostream& os);
void WritePools(std::ostream& os);
- void WriteCustomCommandRule();
void WriteCustomCommandBuildStatement(cmCustomCommand const* cc,
const cmNinjaDeps& orderOnlyDeps);
@@ -103,10 +100,16 @@ private:
std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg);
+ std::string WriteCommandScript(std::vector<std::string> const& cmdLines,
+ std::string const& customStep,
+ cmGeneratorTarget const* target) const;
+
+ void AdditionalCleanFiles();
+
std::string HomeRelativeOutputPath;
- typedef std::map<cmCustomCommand const*, std::set<cmGeneratorTarget*> >
- CustomCommandTargetMap;
+ using CustomCommandTargetMap =
+ std::map<cmCustomCommand const*, std::set<cmGeneratorTarget*>>;
CustomCommandTargetMap CustomCommandTargets;
std::vector<cmCustomCommand const*> CustomCommands;
};
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 9b9d22cf5..4a70248d6 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -2,43 +2,48 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLocalUnixMakefileGenerator3.h"
-#include "cmsys/FStream.hxx"
-#include "cmsys/Terminal.h"
#include <algorithm>
-#include <functional>
+#include <cstdio>
#include <sstream>
-#include <stdio.h>
#include <utility>
+#include <cm/memory>
+
+#include "cmsys/FStream.hxx"
+#include "cmsys/Terminal.h"
+
#include "cmAlgorithms.h"
-#include "cmCustomCommand.h"
+#include "cmCustomCommand.h" // IWYU pragma: keep
#include "cmCustomCommandGenerator.h"
-#include "cmFileTimeComparison.h"
+#include "cmFileTimeCache.h"
#include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
#include "cmGlobalUnixMakefileGenerator3.h"
+#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmMakefileTargetGenerator.h"
#include "cmOutputConverter.h"
+#include "cmRange.h"
#include "cmRulePlaceholderExpander.h"
#include "cmSourceFile.h"
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
// Include dependency scanners for supported languages. Only the
// C/C++ scanner is needed for bootstrapping CMake.
#include "cmDependsC.h"
-#ifdef CMAKE_BUILD_WITH_CMAKE
-#include "cmDependsFortran.h"
-#include "cmDependsJava.h"
+#ifndef CMAKE_BOOTSTRAP
+# include "cmDependsFortran.h"
+# include "cmDependsJava.h"
#endif
// Escape special characters in Makefile dependency lines
@@ -99,9 +104,7 @@ cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3(
this->BorlandMakeCurlyHack = false;
}
-cmLocalUnixMakefileGenerator3::~cmLocalUnixMakefileGenerator3()
-{
-}
+cmLocalUnixMakefileGenerator3::~cmLocalUnixMakefileGenerator3() = default;
void cmLocalUnixMakefileGenerator3::Generate()
{
@@ -116,17 +119,15 @@ void cmLocalUnixMakefileGenerator3::Generate()
this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES");
// Generate the rule files for each target.
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
cmGlobalUnixMakefileGenerator3* gg =
static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
- t != targets.end(); ++t) {
- if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmGeneratorTarget* target : this->GetGeneratorTargets()) {
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- CM_AUTO_PTR<cmMakefileTargetGenerator> tg(
- cmMakefileTargetGenerator::New(*t));
- if (tg.get()) {
+ std::unique_ptr<cmMakefileTargetGenerator> tg(
+ cmMakefileTargetGenerator::New(target));
+ if (tg) {
tg->WriteRuleFiles();
gg->RecordTargetProgress(tg.get());
}
@@ -146,61 +147,36 @@ void cmLocalUnixMakefileGenerator3::ComputeHomeRelativeOutputPath()
this->HomeRelativeOutputPath = this->MaybeConvertToRelativePath(
this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory());
if (this->HomeRelativeOutputPath == ".") {
- this->HomeRelativeOutputPath = "";
+ this->HomeRelativeOutputPath.clear();
}
if (!this->HomeRelativeOutputPath.empty()) {
this->HomeRelativeOutputPath += "/";
}
}
-void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames(
- std::map<cmSourceFile const*, std::string>& mapping,
- cmGeneratorTarget const* gt)
-{
- // Determine if these object files should use a custom extension
- char const* custom_ext = gt->GetCustomObjectExtension();
- for (std::map<cmSourceFile const*, std::string>::iterator si =
- mapping.begin();
- si != mapping.end(); ++si) {
- cmSourceFile const* sf = si->first;
- bool keptSourceExtension;
- si->second = this->GetObjectFileNameWithoutTarget(
- *sf, gt->ObjectDirectory, &keptSourceExtension, custom_ext);
- }
-}
-
void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles(
std::map<std::string, LocalObjectInfo>& localObjectFiles)
{
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- cmGeneratorTarget* gt = *ti;
+ for (cmGeneratorTarget* gt : this->GetGeneratorTargets()) {
if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
std::vector<cmSourceFile const*> objectSources;
- gt->GetObjectSources(
- objectSources, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+ gt->GetObjectSources(objectSources, this->ConfigName);
// Compute full path to object file directory for this target.
- std::string dir;
- dir += gt->LocalGenerator->GetCurrentBinaryDirectory();
- dir += "/";
- dir += this->GetTargetDirectory(gt);
- dir += "/";
+ std::string dir = cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(),
+ '/', this->GetTargetDirectory(gt), '/');
// Compute the name of each object file.
- for (std::vector<cmSourceFile const*>::iterator si = objectSources.begin();
- si != objectSources.end(); ++si) {
- cmSourceFile const* sf = *si;
+ for (cmSourceFile const* sf : objectSources) {
bool hasSourceExtension = true;
std::string objectName =
this->GetObjectFileNameWithoutTarget(*sf, dir, &hasSourceExtension);
- if (cmSystemTools::FileIsFullPath(objectName.c_str())) {
+ if (cmSystemTools::FileIsFullPath(objectName)) {
objectName = cmSystemTools::GetFilenameName(objectName);
}
LocalObjectInfo& info = localObjectFiles[objectName];
info.HasSourceExtension = hasSourceExtension;
- info.push_back(LocalObjectEntry(gt, sf->GetLanguage()));
+ info.emplace_back(gt, sf->GetLanguage());
}
}
}
@@ -210,18 +186,16 @@ void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets(
{
std::map<std::string, LocalObjectInfo> localObjectFiles;
this->GetLocalObjectFiles(localObjectFiles);
- for (std::map<std::string, LocalObjectInfo>::iterator lo =
- localObjectFiles.begin();
- lo != localObjectFiles.end(); ++lo) {
- targets.push_back(lo->first);
-
- std::string::size_type dot_pos = lo->first.rfind(".");
- std::string base = lo->first.substr(0, dot_pos);
- if (lo->second.HasPreprocessRule) {
+ for (auto const& localObjectFile : localObjectFiles) {
+ targets.push_back(localObjectFile.first);
+
+ std::string::size_type dot_pos = localObjectFile.first.rfind(".");
+ std::string base = localObjectFile.first.substr(0, dot_pos);
+ if (localObjectFile.second.HasPreprocessRule) {
targets.push_back(base + ".i");
}
- if (lo->second.HasAssembleRule) {
+ if (localObjectFile.second.HasAssembleRule) {
targets.push_back(base + ".s");
}
}
@@ -236,8 +210,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
// rules may depend on this file itself.
std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
cmGeneratedFileStream ruleFileStream(
- ruleFileNameFull.c_str(), false,
- this->GlobalGenerator->GetMakefileEncoding());
+ ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
if (!ruleFileStream) {
return;
}
@@ -270,23 +243,20 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
// now write out the object rules
// for each object file name
- for (std::map<std::string, LocalObjectInfo>::iterator lo =
- localObjectFiles.begin();
- lo != localObjectFiles.end(); ++lo) {
+ for (auto& localObjectFile : localObjectFiles) {
// Add a convenience rule for building the object file.
- this->WriteObjectConvenienceRule(ruleFileStream,
- "target to build an object file",
- lo->first.c_str(), lo->second);
+ this->WriteObjectConvenienceRule(
+ ruleFileStream, "target to build an object file", localObjectFile.first,
+ localObjectFile.second);
// Check whether preprocessing and assembly rules make sense.
// They make sense only for C and C++ sources.
bool lang_has_preprocessor = false;
bool lang_has_assembly = false;
- for (std::vector<LocalObjectEntry>::const_iterator ei = lo->second.begin();
- ei != lo->second.end(); ++ei) {
- if (ei->Language == "C" || ei->Language == "CXX" ||
- ei->Language == "CUDA" || ei->Language == "Fortran") {
+ for (LocalObjectEntry const& entry : localObjectFile.second) {
+ if (entry.Language == "C" || entry.Language == "CXX" ||
+ entry.Language == "CUDA" || entry.Language == "Fortran") {
// Right now, C, C++, Fortran and CUDA have both a preprocessor and the
// ability to generate assembly code
lang_has_preprocessor = true;
@@ -297,21 +267,21 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
// Add convenience rules for preprocessed and assembly files.
if (lang_has_preprocessor && do_preprocess_rules) {
- std::string::size_type dot_pos = lo->first.rfind(".");
- std::string base = lo->first.substr(0, dot_pos);
+ std::string::size_type dot_pos = localObjectFile.first.rfind(".");
+ std::string base = localObjectFile.first.substr(0, dot_pos);
this->WriteObjectConvenienceRule(ruleFileStream,
"target to preprocess a source file",
- (base + ".i").c_str(), lo->second);
- lo->second.HasPreprocessRule = true;
+ (base + ".i"), localObjectFile.second);
+ localObjectFile.second.HasPreprocessRule = true;
}
if (lang_has_assembly && do_assembly_rules) {
- std::string::size_type dot_pos = lo->first.rfind(".");
- std::string base = lo->first.substr(0, dot_pos);
+ std::string::size_type dot_pos = localObjectFile.first.rfind(".");
+ std::string base = localObjectFile.first.substr(0, dot_pos);
this->WriteObjectConvenienceRule(
ruleFileStream, "target to generate assembly for a file",
- (base + ".s").c_str(), lo->second);
- lo->second.HasAssembleRule = true;
+ (base + ".s"), localObjectFile.second);
+ localObjectFile.second.HasAssembleRule = true;
}
}
@@ -326,7 +296,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
}
void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule(
- std::ostream& ruleFileStream, const char* comment, const char* output,
+ std::ostream& ruleFileStream, const char* comment, const std::string& output,
LocalObjectInfo const& info)
{
// If the rule includes the source file extension then create a
@@ -346,24 +316,23 @@ void cmLocalUnixMakefileGenerator3::WriteObjectConvenienceRule(
// Add a rule to drive the rule below.
std::vector<std::string> depends;
- depends.push_back(output);
+ depends.emplace_back(output);
std::vector<std::string> no_commands;
- this->WriteMakeRule(ruleFileStream, CM_NULLPTR, outNoExt, depends,
+ this->WriteMakeRule(ruleFileStream, nullptr, outNoExt, depends,
no_commands, true, true);
inHelp = false;
}
// Recursively make the rule for each target using the object file.
std::vector<std::string> commands;
- for (std::vector<LocalObjectEntry>::const_iterator t = info.begin();
- t != info.end(); ++t) {
- std::string tgtMakefileName = this->GetRelativeTargetDirectory(t->Target);
+ for (LocalObjectEntry const& t : info) {
+ std::string tgtMakefileName = this->GetRelativeTargetDirectory(t.Target);
std::string targetName = tgtMakefileName;
tgtMakefileName += "/build.make";
targetName += "/";
targetName += output;
commands.push_back(
- this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName));
+ this->GetRecursiveMakeCall(tgtMakefileName, targetName));
}
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
@@ -382,54 +351,48 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
// for each target we just provide a rule to cd up to the top and do a make
// on the target
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
std::string localName;
- for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin();
- t != targets.end(); ++t) {
- if (((*t)->GetType() == cmStateEnums::EXECUTABLE) ||
- ((*t)->GetType() == cmStateEnums::STATIC_LIBRARY) ||
- ((*t)->GetType() == cmStateEnums::SHARED_LIBRARY) ||
- ((*t)->GetType() == cmStateEnums::MODULE_LIBRARY) ||
- ((*t)->GetType() == cmStateEnums::OBJECT_LIBRARY) ||
- ((*t)->GetType() == cmStateEnums::UTILITY)) {
- emitted.insert((*t)->GetName());
+ for (cmGeneratorTarget* target : this->GetGeneratorTargets()) {
+ if ((target->GetType() == cmStateEnums::EXECUTABLE) ||
+ (target->GetType() == cmStateEnums::STATIC_LIBRARY) ||
+ (target->GetType() == cmStateEnums::SHARED_LIBRARY) ||
+ (target->GetType() == cmStateEnums::MODULE_LIBRARY) ||
+ (target->GetType() == cmStateEnums::OBJECT_LIBRARY) ||
+ (target->GetType() == cmStateEnums::UTILITY)) {
+ emitted.insert(target->GetName());
// for subdirs add a rule to build this specific target by name.
- localName = this->GetRelativeTargetDirectory(*t);
- localName += "/rule";
+ localName = cmStrCat(this->GetRelativeTargetDirectory(target), "/rule");
commands.clear();
depends.clear();
// Build the target for this pass.
- std::string makefile2 = cmake::GetCMakeFilesDirectoryPostSlash();
- makefile2 += "Makefile2";
- commands.push_back(
- this->GetRecursiveMakeCall(makefile2.c_str(), localName));
+ std::string makefile2 = "CMakeFiles/Makefile2";
+ commands.push_back(this->GetRecursiveMakeCall(makefile2, localName));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
localName, depends, commands, true);
// Add a target with the canonical name (no prefix, suffix or path).
- if (localName != (*t)->GetName()) {
+ if (localName != target->GetName()) {
commands.clear();
depends.push_back(localName);
this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
- (*t)->GetName(), depends, commands, true);
+ target->GetName(), depends, commands, true);
}
// Add a fast rule to build the target
- std::string makefileName = this->GetRelativeTargetDirectory(*t);
- makefileName += "/build.make";
+ std::string makefileName =
+ cmStrCat(this->GetRelativeTargetDirectory(target), "/build.make");
// make sure the makefile name is suitable for a makefile
- std::string makeTargetName = this->GetRelativeTargetDirectory(*t);
- makeTargetName += "/build";
- localName = (*t)->GetName();
- localName += "/fast";
+ std::string makeTargetName =
+ cmStrCat(this->GetRelativeTargetDirectory(target), "/build");
+ localName = cmStrCat(target->GetName(), "/fast");
depends.clear();
commands.clear();
commands.push_back(
- this->GetRecursiveMakeCall(makefileName.c_str(), makeTargetName));
+ this->GetRecursiveMakeCall(makefileName, makeTargetName));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "fast build rule for target.",
@@ -437,15 +400,14 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
// Add a local name for the rule to relink the target before
// installation.
- if ((*t)->NeedRelinkBeforeInstall(this->ConfigName)) {
- makeTargetName = this->GetRelativeTargetDirectory(*t);
- makeTargetName += "/preinstall";
- localName = (*t)->GetName();
- localName += "/preinstall";
+ if (target->NeedRelinkBeforeInstall(this->ConfigName)) {
+ makeTargetName =
+ cmStrCat(this->GetRelativeTargetDirectory(target), "/preinstall");
+ localName = cmStrCat(target->GetName(), "/preinstall");
depends.clear();
commands.clear();
commands.push_back(
- this->GetRecursiveMakeCall(makefile2.c_str(), makeTargetName));
+ this->GetRecursiveMakeCall(makefile2, makeTargetName));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream,
@@ -458,12 +420,12 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets(
void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
{
- std::string infoFileName = this->GetCurrentBinaryDirectory();
- infoFileName += cmake::GetCMakeFilesDirectory();
- infoFileName += "/CMakeDirectoryInformation.cmake";
+ std::string infoFileName =
+ cmStrCat(this->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/CMakeDirectoryInformation.cmake");
// Open the output file.
- cmGeneratedFileStream infoFileStream(infoFileName.c_str());
+ cmGeneratedFileStream infoFileStream(infoFileName);
if (!infoFileStream) {
return;
}
@@ -500,12 +462,12 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
<< "# The C and CXX include file regular expressions for "
<< "this directory.\n";
infoFileStream << "set(CMAKE_C_INCLUDE_REGEX_SCAN ";
- this->WriteCMakeArgument(infoFileStream,
- this->Makefile->GetIncludeRegularExpression());
+ cmLocalUnixMakefileGenerator3::WriteCMakeArgument(
+ infoFileStream, this->Makefile->GetIncludeRegularExpression());
infoFileStream << ")\n";
infoFileStream << "set(CMAKE_C_INCLUDE_REGEX_COMPLAIN ";
- this->WriteCMakeArgument(infoFileStream,
- this->Makefile->GetComplainRegularExpression());
+ cmLocalUnixMakefileGenerator3::WriteCMakeArgument(
+ infoFileStream, this->Makefile->GetComplainRegularExpression());
infoFileStream << ")\n";
infoFileStream
<< "set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})\n";
@@ -516,9 +478,8 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
std::string cmLocalUnixMakefileGenerator3::ConvertToFullPath(
const std::string& localPath)
{
- std::string dir = this->GetCurrentBinaryDirectory();
- dir += "/";
- dir += localPath;
+ std::string dir =
+ cmStrCat(this->GetCurrentBinaryDirectory(), '/', localPath);
return dir;
}
@@ -534,8 +495,11 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
{
// Make sure there is a target.
if (target.empty()) {
- cmSystemTools::Error("No target for WriteMakeRule! called with comment: ",
- comment);
+ std::string err("No target for WriteMakeRule! called with comment: ");
+ if (comment) {
+ err += comment;
+ }
+ cmSystemTools::Error(err);
return;
}
@@ -555,8 +519,7 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
// Construct the left hand side of the rule.
std::string tgt = cmSystemTools::ConvertToOutputPath(
- this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), target)
- .c_str());
+ this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), target));
const char* space = "";
if (tgt.size() == 1) {
@@ -581,11 +544,10 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
// Split dependencies into multiple rule lines. This allows for
// very long dependency lists even on older make implementations.
std::string binDir = this->GetBinaryDirectory();
- for (std::vector<std::string>::const_iterator dep = depends.begin();
- dep != depends.end(); ++dep) {
- replace = *dep;
+ for (std::string const& depend : depends) {
+ replace = depend;
replace = cmSystemTools::ConvertToOutputPath(
- this->MaybeConvertToRelativePath(binDir, replace).c_str());
+ this->MaybeConvertToRelativePath(binDir, replace));
os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n";
}
}
@@ -605,7 +567,7 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
std::string cmLocalUnixMakefileGenerator3::MaybeConvertWatcomShellCommand(
std::string const& cmd)
{
- if (this->IsWatcomWMake() && cmSystemTools::FileIsFullPath(cmd.c_str()) &&
+ if (this->IsWatcomWMake() && cmSystemTools::FileIsFullPath(cmd) &&
cmd.find_first_of("( )") != std::string::npos) {
// On Watcom WMake use the windows short path for the command
// name. This is needed to avoid funny quoting problems on
@@ -717,8 +679,8 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsTop(
}
// Add a fake suffix to keep HP happy. Must be max 32 chars for SGI make.
std::vector<std::string> depends;
- depends.push_back(".hpux_make_needs_suffix_list");
- this->WriteMakeRule(makefileStream, CM_NULLPTR, ".SUFFIXES", depends,
+ depends.emplace_back(".hpux_make_needs_suffix_list");
+ this->WriteMakeRule(makefileStream, nullptr, ".SUFFIXES", depends,
no_commands, false);
if (this->IsWatcomWMake()) {
// Switch on WMake feature, if an error or interrupt occurs during
@@ -767,11 +729,11 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsTop(
static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
std::string hack = gg->GetEmptyRuleHackDepends();
if (!hack.empty()) {
- no_depends.push_back(hack);
+ no_depends.push_back(std::move(hack));
}
std::string hack_cmd = gg->GetEmptyRuleHackCommand();
if (!hack_cmd.empty()) {
- no_commands.push_back(hack_cmd);
+ no_commands.push_back(std::move(hack_cmd));
}
// Special symbolic target that never exists to force dependers to
@@ -792,31 +754,39 @@ void cmLocalUnixMakefileGenerator3::WriteSpecialTargetsBottom(
// Write special "cmake_check_build_system" target to run cmake with
// the --check-build-system flag.
- {
+ if (!this->GlobalGenerator->GlobalSettingIsOn(
+ "CMAKE_SUPPRESS_REGENERATION")) {
// Build command to run CMake to check if anything needs regenerating.
- std::string cmakefileName = cmake::GetCMakeFilesDirectoryPostSlash();
- cmakefileName += "Makefile.cmake";
- std::string runRule =
- "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
- runRule += " --check-build-system ";
- runRule +=
- this->ConvertToOutputFormat(cmakefileName, cmOutputConverter::SHELL);
- runRule += " 0";
+ std::vector<std::string> commands;
+ cmake* cm = this->GlobalGenerator->GetCMakeInstance();
+ if (cm->DoWriteGlobVerifyTarget()) {
+ std::string rescanRule =
+ cmStrCat("$(CMAKE_COMMAND) -P ",
+ this->ConvertToOutputFormat(cm->GetGlobVerifyScript(),
+ cmOutputConverter::SHELL));
+ commands.push_back(rescanRule);
+ }
+ std::string cmakefileName = "CMakeFiles/Makefile.cmake";
+ std::string runRule = cmStrCat(
+ "$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) "
+ "--check-build-system ",
+ this->ConvertToOutputFormat(cmakefileName, cmOutputConverter::SHELL),
+ " 0");
std::vector<std::string> no_depends;
- std::vector<std::string> commands;
- commands.push_back(runRule);
+ commands.push_back(std::move(runRule));
if (!this->IsRootMakefile()) {
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
}
- this->WriteMakeRule(
- makefileStream, "Special rule to run CMake to check the build system "
- "integrity.\n"
- "No rule that depends on this can have "
- "commands that come from listfiles\n"
- "because they might be regenerated.",
- "cmake_check_build_system", no_depends, commands, true);
+ this->WriteMakeRule(makefileStream,
+ "Special rule to run CMake to check the build system "
+ "integrity.\n"
+ "No rule that depends on this can have "
+ "commands that come from listfiles\n"
+ "because they might be regenerated.",
+ "cmake_check_build_system", no_depends, commands,
+ true);
}
}
@@ -840,15 +810,15 @@ void cmLocalUnixMakefileGenerator3::WriteConvenienceRule(
}
std::string cmLocalUnixMakefileGenerator3::GetRelativeTargetDirectory(
- cmGeneratorTarget* target)
+ cmGeneratorTarget const* target) const
{
- std::string dir = this->HomeRelativeOutputPath;
- dir += this->GetTargetDirectory(target);
+ std::string dir =
+ cmStrCat(this->HomeRelativeOutputPath, this->GetTargetDirectory(target));
return dir;
}
-void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags,
- const std::string& newFlags)
+void cmLocalUnixMakefileGenerator3::AppendFlags(
+ std::string& flags, const std::string& newFlags) const
{
if (this->IsWatcomWMake() && !newFlags.empty()) {
std::string newf = newFlags;
@@ -861,12 +831,6 @@ void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags,
this->cmLocalGenerator::AppendFlags(flags, newFlags);
}
-void cmLocalUnixMakefileGenerator3::AppendFlags(std::string& flags,
- const char* newFlags)
-{
- this->cmLocalGenerator::AppendFlags(flags, newFlags);
-}
-
void cmLocalUnixMakefileGenerator3::AppendRuleDepend(
std::vector<std::string>& depends, const char* ruleFileName)
{
@@ -874,8 +838,8 @@ void cmLocalUnixMakefileGenerator3::AppendRuleDepend(
// it is specifically enabled by the user or project.
const char* nodep =
this->Makefile->GetDefinition("CMAKE_SKIP_RULE_DEPENDENCY");
- if (!nodep || cmSystemTools::IsOff(nodep)) {
- depends.push_back(ruleFileName);
+ if (!nodep || cmIsOff(nodep)) {
+ depends.emplace_back(ruleFileName);
}
}
@@ -885,16 +849,15 @@ void cmLocalUnixMakefileGenerator3::AppendRuleDepends(
// Add a dependency on the rule file itself unless an option to skip
// it is specifically enabled by the user or project.
if (!this->Makefile->IsOn("CMAKE_SKIP_RULE_DEPENDENCY")) {
- depends.insert(depends.end(), ruleFiles.begin(), ruleFiles.end());
+ cmAppend(depends, ruleFiles);
}
}
void cmLocalUnixMakefileGenerator3::AppendCustomDepends(
std::vector<std::string>& depends, const std::vector<cmCustomCommand>& ccs)
{
- for (std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
- i != ccs.end(); ++i) {
- cmCustomCommandGenerator ccg(*i, this->ConfigName, this);
+ for (cmCustomCommand const& cc : ccs) {
+ cmCustomCommandGenerator ccg(cc, this->ConfigName, this);
this->AppendCustomDepend(depends, ccg);
}
}
@@ -902,12 +865,11 @@ void cmLocalUnixMakefileGenerator3::AppendCustomDepends(
void cmLocalUnixMakefileGenerator3::AppendCustomDepend(
std::vector<std::string>& depends, cmCustomCommandGenerator const& ccg)
{
- for (std::vector<std::string>::const_iterator d = ccg.GetDepends().begin();
- d != ccg.GetDepends().end(); ++d) {
+ for (std::string const& d : ccg.GetDepends()) {
// Lookup the real name of the dependency in case it is a CMake target.
std::string dep;
- if (this->GetRealDependency(*d, this->ConfigName, dep)) {
- depends.push_back(dep);
+ if (this->GetRealDependency(d, this->ConfigName, dep)) {
+ depends.push_back(std::move(dep));
}
}
}
@@ -916,9 +878,8 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommands(
std::vector<std::string>& commands, const std::vector<cmCustomCommand>& ccs,
cmGeneratorTarget* target, std::string const& relative)
{
- for (std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
- i != ccs.end(); ++i) {
- cmCustomCommandGenerator ccg(*i, this->ConfigName, this);
+ for (cmCustomCommand const& cc : ccs) {
+ cmCustomCommandGenerator ccg(cc, this->ConfigName, this);
this->AppendCustomCommand(commands, ccg, target, relative, true);
}
}
@@ -950,7 +911,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
*content << dir;
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->CreateRulePlaceholderExpander());
// Add each command line to the set of commands.
@@ -987,15 +948,14 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
// This command was specified as a path to a file in the
// current directory. Add a leading "./" so it can run
// without the current directory being in the search path.
- cmd = "./" + cmd;
+ cmd = cmStrCat("./", cmd);
}
std::string launcher;
// Short-circuit if there is no launcher.
const char* val = this->GetRuleLauncher(target, "RULE_LAUNCH_CUSTOM");
if (val && *val) {
- // Expand rules in the empty string. It may insert the launcher and
- // perform replacements.
+ // Expand rule variables referenced in the given launcher command.
cmRulePlaceholderExpander::RuleVariables vars;
vars.CMTargetName = target->GetName().c_str();
vars.CMTargetType = cmState::GetTargetTypeName(target->GetType());
@@ -1013,7 +973,6 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
vars.Output = output.c_str();
launcher = val;
- launcher += " ";
rulePlaceholderExpander->ExpandRuleVariables(this, launcher, vars);
if (!launcher.empty()) {
launcher += " ";
@@ -1043,40 +1002,36 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand(
std::string::size_type rcurly = cmd.find('}');
if (rcurly == std::string::npos || rcurly > lcurly) {
// The first curly is a left curly. Use the hack.
- std::string hack_cmd = cmd.substr(0, lcurly);
- hack_cmd += "{{}";
- hack_cmd += cmd.substr(lcurly + 1);
- cmd = hack_cmd;
+ cmd =
+ cmStrCat(cmd.substr(0, lcurly), "{{}", cmd.substr(lcurly + 1));
}
}
}
if (launcher.empty()) {
if (useCall) {
- cmd = "call " + cmd;
+ cmd = cmStrCat("call ", cmd);
} else if (this->IsNMake() && cmd[0] == '"') {
- cmd = "echo >nul && " + cmd;
+ cmd = cmStrCat("echo >nul && ", cmd);
}
}
- commands1.push_back(cmd);
+ commands1.push_back(std::move(cmd));
}
}
// Setup the proper working directory for the commands.
- this->CreateCDCommand(commands1, dir.c_str(), relative);
+ this->CreateCDCommand(commands1, dir, relative);
// push back the custom commands
- commands.insert(commands.end(), commands1.begin(), commands1.end());
+ cmAppend(commands, commands1);
}
void cmLocalUnixMakefileGenerator3::AppendCleanCommand(
- std::vector<std::string>& commands, const std::vector<std::string>& files,
+ std::vector<std::string>& commands, const std::set<std::string>& files,
cmGeneratorTarget* target, const char* filename)
{
std::string currentBinDir = this->GetCurrentBinaryDirectory();
- std::string cleanfile = currentBinDir;
- cleanfile += "/";
- cleanfile += this->GetTargetDirectory(target);
- cleanfile += "/cmake_clean";
+ std::string cleanfile = cmStrCat(
+ currentBinDir, '/', this->GetTargetDirectory(target), "/cmake_clean");
if (filename) {
cleanfile += "_";
cleanfile += filename;
@@ -1085,23 +1040,25 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand(
std::string cleanfilePath = cmSystemTools::CollapseFullPath(cleanfile);
cmsys::ofstream fout(cleanfilePath.c_str());
if (!fout) {
- cmSystemTools::Error("Could not create ", cleanfilePath.c_str());
+ cmSystemTools::Error("Could not create " + cleanfilePath);
}
if (!files.empty()) {
fout << "file(REMOVE_RECURSE\n";
- for (std::vector<std::string>::const_iterator f = files.begin();
- f != files.end(); ++f) {
- std::string fc = this->MaybeConvertToRelativePath(currentBinDir, *f);
+ for (std::string const& file : files) {
+ std::string fc = this->MaybeConvertToRelativePath(currentBinDir, file);
fout << " " << cmOutputConverter::EscapeForCMake(fc) << "\n";
}
fout << ")\n";
}
- std::string remove = "$(CMAKE_COMMAND) -P ";
- remove += this->ConvertToOutputFormat(
- this->MaybeConvertToRelativePath(this->GetCurrentBinaryDirectory(),
- cleanfile),
- cmOutputConverter::SHELL);
- commands.push_back(remove);
+ {
+ std::string remove =
+ cmStrCat("$(CMAKE_COMMAND) -P ",
+ this->ConvertToOutputFormat(
+ this->MaybeConvertToRelativePath(
+ this->GetCurrentBinaryDirectory(), cleanfile),
+ cmOutputConverter::SHELL));
+ commands.push_back(std::move(remove));
+ }
// For the main clean rule add per-language cleaning.
if (!filename) {
@@ -1120,6 +1077,55 @@ void cmLocalUnixMakefileGenerator3::AppendCleanCommand(
}
}
+void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand(
+ std::vector<std::string>& commands)
+{
+ std::vector<std::string> cleanFiles;
+ // Look for additional files registered for cleaning in this directory.
+ if (const char* prop_value =
+ this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) {
+ cmExpandList(cmGeneratorExpression::Evaluate(
+ prop_value, this,
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")),
+ cleanFiles);
+ }
+ if (cleanFiles.empty()) {
+ return;
+ }
+
+ cmLocalGenerator* rootLG =
+ this->GetGlobalGenerator()->GetLocalGenerators().at(0);
+ std::string const& binaryDir = rootLG->GetCurrentBinaryDirectory();
+ std::string const& currentBinaryDir = this->GetCurrentBinaryDirectory();
+ std::string cleanfile =
+ cmStrCat(currentBinaryDir, "/CMakeFiles/cmake_directory_clean.cmake");
+ // Write clean script
+ {
+ std::string cleanfilePath = cmSystemTools::CollapseFullPath(cleanfile);
+ cmsys::ofstream fout(cleanfilePath.c_str());
+ if (!fout) {
+ cmSystemTools::Error("Could not create " + cleanfilePath);
+ return;
+ }
+ fout << "file(REMOVE_RECURSE\n";
+ for (std::string const& cfl : cleanFiles) {
+ std::string fc = rootLG->MaybeConvertToRelativePath(
+ binaryDir, cmSystemTools::CollapseFullPath(cfl, currentBinaryDir));
+ fout << " " << cmOutputConverter::EscapeForCMake(fc) << "\n";
+ }
+ fout << ")\n";
+ }
+ // Create command
+ {
+ std::string remove =
+ cmStrCat("$(CMAKE_COMMAND) -P ",
+ this->ConvertToOutputFormat(
+ rootLG->MaybeConvertToRelativePath(binaryDir, cleanfile),
+ cmOutputConverter::SHELL));
+ commands.push_back(std::move(remove));
+ }
+}
+
void cmLocalUnixMakefileGenerator3::AppendEcho(
std::vector<std::string>& commands, std::string const& text, EchoColor color,
EchoProgress const* progress)
@@ -1161,12 +1167,12 @@ void cmLocalUnixMakefileGenerator3::AppendEcho(
std::string cmd;
if (color_name.empty() && !progress) {
// Use the native echo command.
- cmd = "@echo ";
- cmd += this->EscapeForShell(line, false, true);
+ cmd = cmStrCat("@echo ", this->EscapeForShell(line, false, true));
} else {
// Use cmake to echo the text in color.
- cmd = "@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) ";
- cmd += color_name;
+ cmd = cmStrCat(
+ "@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) ",
+ color_name);
if (progress) {
cmd += "--progress-dir=";
cmd += this->ConvertToOutputFormat(
@@ -1179,14 +1185,14 @@ void cmLocalUnixMakefileGenerator3::AppendEcho(
}
cmd += this->EscapeForShell(line);
}
- commands.push_back(cmd);
+ commands.push_back(std::move(cmd));
}
- // Reset the line to emtpy.
- line = "";
+ // Reset the line to empty.
+ line.clear();
// Progress appears only on first line.
- progress = CM_NULLPTR;
+ progress = nullptr;
// Terminate on end-of-string.
if (*c == '\0') {
@@ -1202,8 +1208,7 @@ void cmLocalUnixMakefileGenerator3::AppendEcho(
std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable(
std::string const& s, std::string const& s2)
{
- std::string unmodified = s;
- unmodified += s2;
+ std::string unmodified = cmStrCat(s, s2);
// if there is no restriction on the length of make variables
// and there are no "." characters in the string, then return the
// unmodified combination.
@@ -1218,8 +1223,7 @@ std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable(
// see if the variable has been defined before and return
// the modified version of the variable
- std::map<std::string, std::string>::iterator i =
- this->MakeVariableMap.find(unmodified);
+ auto i = this->MakeVariableMap.find(unmodified);
if (i != this->MakeVariableMap.end()) {
return i->second;
}
@@ -1281,9 +1285,8 @@ std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable(
return ret;
}
-bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
- bool verbose,
- bool color)
+bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
+ const std::string& tgtInfo, bool verbose, bool color)
{
// read in the target info file
if (!this->Makefile->ReadListFile(tgtInfo) ||
@@ -1294,26 +1297,25 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
// Check if any multiple output pairs have a missing file.
this->CheckMultipleOutputs(verbose);
- std::string dir = cmSystemTools::GetFilenamePath(tgtInfo);
- std::string internalDependFile = dir + "/depend.internal";
- std::string dependFile = dir + "/depend.make";
+ std::string const targetDir = cmSystemTools::GetFilenamePath(tgtInfo);
+ std::string const internalDependFile = targetDir + "/depend.internal";
+ std::string const dependFile = targetDir + "/depend.make";
// If the target DependInfo.cmake file has changed since the last
// time dependencies were scanned then force rescanning. This may
// happen when a new source file is added and CMake regenerates the
// project but no other sources were touched.
bool needRescanDependInfo = false;
- cmFileTimeComparison* ftc =
- this->GlobalGenerator->GetCMakeInstance()->GetFileComparison();
+ cmFileTimeCache* ftc =
+ this->GlobalGenerator->GetCMakeInstance()->GetFileTimeCache();
{
int result;
- if (!ftc->FileTimeCompare(internalDependFile.c_str(), tgtInfo, &result) ||
- result < 0) {
+ if (!ftc->Compare(internalDependFile, tgtInfo, &result) || result < 0) {
if (verbose) {
std::ostringstream msg;
msg << "Dependee \"" << tgtInfo << "\" is newer than depender \""
<< internalDependFile << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
needRescanDependInfo = true;
}
@@ -1322,19 +1324,18 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
// If the directory information is newer than depend.internal, include dirs
// may have changed. In this case discard all old dependencies.
bool needRescanDirInfo = false;
- std::string dirInfoFile = this->GetCurrentBinaryDirectory();
- dirInfoFile += cmake::GetCMakeFilesDirectory();
- dirInfoFile += "/CMakeDirectoryInformation.cmake";
{
+ std::string dirInfoFile =
+ cmStrCat(this->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/CMakeDirectoryInformation.cmake");
int result;
- if (!ftc->FileTimeCompare(internalDependFile.c_str(), dirInfoFile.c_str(),
- &result) ||
+ if (!ftc->Compare(internalDependFile, dirInfoFile, &result) ||
result < 0) {
if (verbose) {
std::ostringstream msg;
msg << "Dependee \"" << dirInfoFile << "\" is newer than depender \""
<< internalDependFile << "\"." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
needRescanDirInfo = true;
}
@@ -1344,12 +1345,12 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
// The build.make file may have explicit dependencies for the object
// files but these will not affect the scanning process so they need
// not be considered.
- std::map<std::string, cmDepends::DependencyVector> validDependencies;
+ cmDepends::DependencyMap validDependencies;
bool needRescanDependencies = false;
if (!needRescanDirInfo) {
cmDependsC checker;
checker.SetVerbose(verbose);
- checker.SetFileComparison(ftc);
+ checker.SetFileTimeCache(ftc);
// cmDependsC::Check() fills the vector validDependencies() with the
// dependencies for those files where they are still valid, i.e. neither
// the files themselves nor any files they depend on have changed.
@@ -1360,21 +1361,22 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
// dependency vector. This means that in the normal case, when only
// few or one file have been edited, then also only this one file is
// actually scanned again, instead of all files for this target.
- needRescanDependencies = !checker.Check(
- dependFile.c_str(), internalDependFile.c_str(), validDependencies);
+ needRescanDependencies =
+ !checker.Check(dependFile, internalDependFile, validDependencies);
}
if (needRescanDependInfo || needRescanDirInfo || needRescanDependencies) {
// The dependencies must be regenerated.
- std::string targetName = cmSystemTools::GetFilenameName(dir);
+ std::string targetName = cmSystemTools::GetFilenameName(targetDir);
targetName = targetName.substr(0, targetName.length() - 4);
- std::string message = "Scanning dependencies of target ";
- message += targetName;
+ std::string message =
+ cmStrCat("Scanning dependencies of target ", targetName);
cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundMagenta |
cmsysTerminal_Color_ForegroundBold,
message.c_str(), true, color);
- return this->ScanDependencies(dir.c_str(), validDependencies);
+ return this->ScanDependencies(targetDir, dependFile, internalDependFile,
+ validDependencies);
}
// The dependencies are already up-to-date.
@@ -1382,25 +1384,27 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
}
bool cmLocalUnixMakefileGenerator3::ScanDependencies(
- const char* targetDir,
- std::map<std::string, cmDepends::DependencyVector>& validDeps)
+ std::string const& targetDir, std::string const& dependFile,
+ std::string const& internalDependFile, cmDepends::DependencyMap& validDeps)
{
// Read the directory information file.
cmMakefile* mf = this->Makefile;
bool haveDirectoryInfo = false;
- std::string dirInfoFile = this->GetCurrentBinaryDirectory();
- dirInfoFile += cmake::GetCMakeFilesDirectory();
- dirInfoFile += "/CMakeDirectoryInformation.cmake";
- if (mf->ReadListFile(dirInfoFile.c_str()) &&
- !cmSystemTools::GetErrorOccuredFlag()) {
- haveDirectoryInfo = true;
+ {
+ std::string dirInfoFile =
+ cmStrCat(this->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/CMakeDirectoryInformation.cmake");
+ if (mf->ReadListFile(dirInfoFile) &&
+ !cmSystemTools::GetErrorOccuredFlag()) {
+ haveDirectoryInfo = true;
+ }
}
// Lookup useful directory information.
if (haveDirectoryInfo) {
// Test whether we need to force Unix paths.
if (const char* force = mf->GetDefinition("CMAKE_FORCE_UNIX_PATHS")) {
- if (!cmSystemTools::IsOff(force)) {
+ if (!cmIsOff(force)) {
cmSystemTools::SetForceUnixPaths(true);
}
}
@@ -1420,16 +1424,10 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
cmSystemTools::Error("Directory Information file not found");
}
- // create the file stream for the depends file
- std::string dir = targetDir;
-
// Open the make depends file. This should be copy-if-different
// because the make tool may try to reload it needlessly otherwise.
- std::string ruleFileNameFull = dir;
- ruleFileNameFull += "/depend.make";
cmGeneratedFileStream ruleFileStream(
- ruleFileNameFull.c_str(), false,
- this->GlobalGenerator->GetMakefileEncoding());
+ dependFile, false, this->GlobalGenerator->GetMakefileEncoding());
ruleFileStream.SetCopyIfDifferent(true);
if (!ruleFileStream) {
return false;
@@ -1438,11 +1436,8 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
// Open the cmake dependency tracking file. This should not be
// copy-if-different because dependencies are re-scanned when it is
// older than the DependInfo.cmake.
- std::string internalRuleFileNameFull = dir;
- internalRuleFileNameFull += "/depend.internal";
cmGeneratedFileStream internalRuleFileStream(
- internalRuleFileNameFull.c_str(), false,
- this->GlobalGenerator->GetMakefileEncoding());
+ internalDependFile, false, this->GlobalGenerator->GetMakefileEncoding());
if (!internalRuleFileStream) {
return false;
}
@@ -1451,39 +1446,34 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
this->WriteDisclaimer(internalRuleFileStream);
// for each language we need to scan, scan it
- const char* langStr = mf->GetSafeDefinition("CMAKE_DEPENDS_LANGUAGES");
- std::vector<std::string> langs;
- cmSystemTools::ExpandListArgument(langStr, langs);
- for (std::vector<std::string>::iterator li = langs.begin();
- li != langs.end(); ++li) {
+ std::vector<std::string> langs =
+ cmExpandedList(mf->GetSafeDefinition("CMAKE_DEPENDS_LANGUAGES"));
+ for (std::string const& lang : langs) {
// construct the checker
- std::string lang = *li;
-
// Create the scanner for this language
- cmDepends* scanner = CM_NULLPTR;
+ std::unique_ptr<cmDepends> scanner;
if (lang == "C" || lang == "CXX" || lang == "RC" || lang == "ASM" ||
lang == "CUDA") {
// TODO: Handle RC (resource files) dependencies correctly.
- scanner = new cmDependsC(this, targetDir, lang, &validDeps);
+ scanner = cm::make_unique<cmDependsC>(this, targetDir, lang, &validDeps);
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
else if (lang == "Fortran") {
- scanner = new cmDependsFortran(this);
+ ruleFileStream << "# Note that incremental build could trigger "
+ << "a call to cmake_copy_f90_mod on each re-build\n";
+ scanner = cm::make_unique<cmDependsFortran>(this);
} else if (lang == "Java") {
- scanner = new cmDependsJava();
+ scanner = cm::make_unique<cmDependsJava>();
}
#endif
if (scanner) {
scanner->SetLocalGenerator(this);
- scanner->SetFileComparison(
- this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
+ scanner->SetFileTimeCache(
+ this->GlobalGenerator->GetCMakeInstance()->GetFileTimeCache());
scanner->SetLanguage(lang);
- scanner->SetTargetDirectory(dir.c_str());
+ scanner->SetTargetDirectory(targetDir);
scanner->Write(ruleFileStream, internalRuleFileStream);
-
- // free the scanner for this language
- delete scanner;
}
}
@@ -1501,23 +1491,21 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose)
}
// Convert the string to a list and preserve empty entries.
- std::vector<std::string> pairs;
- cmSystemTools::ExpandListArgument(pairs_string, pairs, true);
- for (std::vector<std::string>::const_iterator i = pairs.begin();
- i != pairs.end() && (i + 1) != pairs.end();) {
+ std::vector<std::string> pairs = cmExpandedList(pairs_string, true);
+ for (auto i = pairs.begin(); i != pairs.end() && (i + 1) != pairs.end();) {
const std::string& depender = *i++;
const std::string& dependee = *i++;
// If the depender is missing then delete the dependee to make
// sure both will be regenerated.
- if (cmSystemTools::FileExists(dependee.c_str()) &&
- !cmSystemTools::FileExists(depender.c_str())) {
+ if (cmSystemTools::FileExists(dependee) &&
+ !cmSystemTools::FileExists(depender)) {
if (verbose) {
std::ostringstream msg;
msg << "Deleting primary custom command output \"" << dependee
<< "\" because another output \"" << depender
<< "\" does not exist." << std::endl;
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
cmSystemTools::RemoveFile(dependee);
}
@@ -1535,7 +1523,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
// Just depend on the all target to drive the build.
std::vector<std::string> depends;
std::vector<std::string> no_commands;
- depends.push_back("all");
+ depends.emplace_back("all");
// Write the rule.
this->WriteMakeRule(ruleFileStream,
@@ -1548,9 +1536,10 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
if (gg->AllowNotParallel()) {
std::vector<std::string> no_depends;
- this->WriteMakeRule(ruleFileStream, "Allow only one \"make -f "
- "Makefile2\" at a time, but pass "
- "parallelism.",
+ this->WriteMakeRule(ruleFileStream,
+ "Allow only one \"make -f "
+ "Makefile2\" at a time, but pass "
+ "parallelism.",
".NOTPARALLEL", no_depends, no_commands, false);
}
}
@@ -1562,26 +1551,25 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
this->WriteDivider(ruleFileStream);
ruleFileStream << "# Targets provided globally by CMake.\n"
<< "\n";
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
- std::vector<cmGeneratorTarget*>::iterator glIt;
- for (glIt = targets.begin(); glIt != targets.end(); ++glIt) {
- if ((*glIt)->GetType() == cmStateEnums::GLOBAL_TARGET) {
+ const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
+ for (cmGeneratorTarget* gt : targets) {
+ if (gt->GetType() == cmStateEnums::GLOBAL_TARGET) {
std::string targetString =
- "Special rule for the target " + (*glIt)->GetName();
+ "Special rule for the target " + gt->GetName();
std::vector<std::string> commands;
std::vector<std::string> depends;
- const char* text = (*glIt)->GetProperty("EchoString");
+ const char* text = gt->GetProperty("EchoString");
if (!text) {
text = "Running external command ...";
}
- depends.insert(depends.end(), (*glIt)->GetUtilities().begin(),
- (*glIt)->GetUtilities().end());
+ depends.reserve(gt->GetUtilities().size());
+ for (BT<std::string> const& u : gt->GetUtilities()) {
+ depends.push_back(u.Value);
+ }
this->AppendEcho(commands, text,
cmLocalUnixMakefileGenerator3::EchoGlobal);
- cmGeneratorTarget* gt = *glIt;
-
// Global targets store their rules in pre- and post-build commands.
this->AppendCustomDepends(depends, gt->GetPreBuildCommands());
this->AppendCustomDepends(depends, gt->GetPostBuildCommands());
@@ -1599,7 +1587,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
(targetName == "install/strip")) {
// Provide a fast install target that does not depend on all
// but has the same command.
- depends.push_back("preinstall/fast");
+ depends.emplace_back("preinstall/fast");
} else {
// Just forward to the real target so at least it will work.
depends.push_back(targetName);
@@ -1615,21 +1603,24 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
std::vector<std::string> commands;
// Write the all rule.
- std::string recursiveTarget = this->GetCurrentBinaryDirectory();
- recursiveTarget += "/all";
+ std::string recursiveTarget =
+ cmStrCat(this->GetCurrentBinaryDirectory(), "/all");
- depends.push_back("cmake_check_build_system");
+ bool regenerate =
+ !this->GlobalGenerator->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION");
+ if (regenerate) {
+ depends.emplace_back("cmake_check_build_system");
+ }
- std::string progressDir = this->GetBinaryDirectory();
- progressDir += cmake::GetCMakeFilesDirectory();
+ std::string progressDir =
+ cmStrCat(this->GetBinaryDirectory(), "/CMakeFiles");
{
std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
progCmd << this->ConvertToOutputFormat(
cmSystemTools::CollapseFullPath(progressDir), cmOutputConverter::SHELL);
- std::string progressFile = cmake::GetCMakeFilesDirectory();
- progressFile += "/progress.marks";
+ std::string progressFile = "/CMakeFiles/progress.marks";
std::string progressFileNameFull = this->ConvertToFullPath(progressFile);
progCmd << " "
<< this->ConvertToOutputFormat(
@@ -1637,10 +1628,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
cmOutputConverter::SHELL);
commands.push_back(progCmd.str());
}
- std::string mf2Dir = cmake::GetCMakeFilesDirectoryPostSlash();
- mf2Dir += "Makefile2";
- commands.push_back(
- this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
+ std::string mf2Dir = "CMakeFiles/Makefile2";
+ commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
{
@@ -1655,38 +1644,34 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
commands, true);
// Write the clean rule.
- recursiveTarget = this->GetCurrentBinaryDirectory();
- recursiveTarget += "/clean";
+ recursiveTarget = cmStrCat(this->GetCurrentBinaryDirectory(), "/clean");
commands.clear();
depends.clear();
- commands.push_back(
- this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
+ commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "The main clean target", "clean",
depends, commands, true);
commands.clear();
depends.clear();
- depends.push_back("clean");
+ depends.emplace_back("clean");
this->WriteMakeRule(ruleFileStream, "The main clean target", "clean/fast",
depends, commands, true);
// Write the preinstall rule.
- recursiveTarget = this->GetCurrentBinaryDirectory();
- recursiveTarget += "/preinstall";
+ recursiveTarget = cmStrCat(this->GetCurrentBinaryDirectory(), "/preinstall");
commands.clear();
depends.clear();
const char* noall =
this->Makefile->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
- if (!noall || cmSystemTools::IsOff(noall)) {
+ if (!noall || cmIsOff(noall)) {
// Drive the build before installing.
- depends.push_back("all");
- } else {
+ depends.emplace_back("all");
+ } else if (regenerate) {
// At least make sure the build system is up to date.
- depends.push_back("cmake_check_build_system");
+ depends.emplace_back("cmake_check_build_system");
}
- commands.push_back(
- this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
+ commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget));
this->CreateCDCommand(commands, this->GetBinaryDirectory(),
this->GetCurrentBinaryDirectory());
this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.",
@@ -1695,22 +1680,32 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.",
"preinstall/fast", depends, commands, true);
- // write the depend rule, really a recompute depends rule
- depends.clear();
- commands.clear();
- std::string cmakefileName = cmake::GetCMakeFilesDirectoryPostSlash();
- cmakefileName += "Makefile.cmake";
- std::string runRule =
- "$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
- runRule += " --check-build-system ";
- runRule +=
- this->ConvertToOutputFormat(cmakefileName, cmOutputConverter::SHELL);
- runRule += " 1";
- commands.push_back(runRule);
- this->CreateCDCommand(commands, this->GetBinaryDirectory(),
- this->GetCurrentBinaryDirectory());
- this->WriteMakeRule(ruleFileStream, "clear depends", "depend", depends,
- commands, true);
+ if (regenerate) {
+ // write the depend rule, really a recompute depends rule
+ depends.clear();
+ commands.clear();
+ cmake* cm = this->GlobalGenerator->GetCMakeInstance();
+ if (cm->DoWriteGlobVerifyTarget()) {
+ std::string rescanRule =
+ cmStrCat("$(CMAKE_COMMAND) -P ",
+ this->ConvertToOutputFormat(cm->GetGlobVerifyScript(),
+ cmOutputConverter::SHELL));
+ commands.push_back(rescanRule);
+ }
+ std::string cmakefileName = "CMakeFiles/Makefile.cmake";
+ {
+ std::string runRule = cmStrCat(
+ "$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) "
+ "--check-build-system ",
+ this->ConvertToOutputFormat(cmakefileName, cmOutputConverter::SHELL),
+ " 1");
+ commands.push_back(std::move(runRule));
+ }
+ this->CreateCDCommand(commands, this->GetBinaryDirectory(),
+ this->GetCurrentBinaryDirectory());
+ this->WriteMakeRule(ruleFileStream, "clear depends", "depend", depends,
+ commands, true);
+ }
}
void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
@@ -1721,20 +1716,18 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
if (!infoDef) {
return;
}
- std::vector<std::string> files;
- cmSystemTools::ExpandListArgument(infoDef, files);
+ std::vector<std::string> files = cmExpandedList(infoDef);
// Each depend information file corresponds to a target. Clear the
// dependencies for that target.
cmDepends clearer;
clearer.SetVerbose(verbose);
- for (std::vector<std::string>::iterator l = files.begin(); l != files.end();
- ++l) {
- std::string dir = cmSystemTools::GetFilenamePath(*l);
+ for (std::string const& file : files) {
+ std::string dir = cmSystemTools::GetFilenamePath(file);
// Clear the implicit dependency makefile.
std::string dependFile = dir + "/depend.make";
- clearer.Clear(dependFile.c_str());
+ clearer.Clear(dependFile);
// Remove the internal dependency check file to force
// regeneration.
@@ -1751,9 +1744,9 @@ class NotInProjectDir
{
public:
// Constructor with the source and binary directory's path
- NotInProjectDir(const std::string& sourceDir, const std::string& binaryDir)
- : SourceDir(sourceDir)
- , BinaryDir(binaryDir)
+ NotInProjectDir(std::string sourceDir, std::string binaryDir)
+ : SourceDir(std::move(sourceDir))
+ , BinaryDir(std::move(binaryDir))
{
}
@@ -1802,54 +1795,61 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
cmakefileStream
<< "# The set of languages for which implicit dependencies are needed:\n";
cmakefileStream << "set(CMAKE_DEPENDS_LANGUAGES\n";
- for (ImplicitDependLanguageMap::const_iterator l = implicitLangs.begin();
- l != implicitLangs.end(); ++l) {
- cmakefileStream << " \"" << l->first << "\"\n";
+ for (auto const& implicitLang : implicitLangs) {
+ cmakefileStream << " \"" << implicitLang.first << "\"\n";
}
cmakefileStream << " )\n";
// now list the files for each language
cmakefileStream
<< "# The set of files for implicit dependencies of each language:\n";
- for (ImplicitDependLanguageMap::const_iterator l = implicitLangs.begin();
- l != implicitLangs.end(); ++l) {
- cmakefileStream << "set(CMAKE_DEPENDS_CHECK_" << l->first << "\n";
- ImplicitDependFileMap const& implicitPairs = l->second;
+ for (auto const& implicitLang : implicitLangs) {
+ cmakefileStream << "set(CMAKE_DEPENDS_CHECK_" << implicitLang.first
+ << "\n";
+ ImplicitDependFileMap const& implicitPairs = implicitLang.second;
// for each file pair
- for (ImplicitDependFileMap::const_iterator pi = implicitPairs.begin();
- pi != implicitPairs.end(); ++pi) {
- for (cmDepends::DependencyVector::const_iterator di = pi->second.begin();
- di != pi->second.end(); ++di) {
- cmakefileStream << " \"" << *di << "\" ";
- cmakefileStream << "\"" << pi->first << "\"\n";
+ for (auto const& implicitPair : implicitPairs) {
+ for (auto const& di : implicitPair.second) {
+ cmakefileStream << " \"" << di << "\" ";
+ cmakefileStream << "\"" << implicitPair.first << "\"\n";
}
}
cmakefileStream << " )\n";
// Tell the dependency scanner what compiler is used.
- std::string cidVar = "CMAKE_";
- cidVar += l->first;
- cidVar += "_COMPILER_ID";
+ std::string cidVar =
+ cmStrCat("CMAKE_", implicitLang.first, "_COMPILER_ID");
const char* cid = this->Makefile->GetDefinition(cidVar);
if (cid && *cid) {
- cmakefileStream << "set(CMAKE_" << l->first << "_COMPILER_ID \"" << cid
+ cmakefileStream << "set(CMAKE_" << implicitLang.first
+ << "_COMPILER_ID \"" << cid << "\")\n";
+ }
+
+ if (implicitLang.first == "Fortran") {
+ std::string smodSep =
+ this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_SEP");
+ std::string smodExt =
+ this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_EXT");
+ cmakefileStream << "set(CMAKE_Fortran_SUBMODULE_SEP \"" << smodSep
+ << "\")\n";
+ cmakefileStream << "set(CMAKE_Fortran_SUBMODULE_EXT \"" << smodExt
<< "\")\n";
}
// Build a list of preprocessor definitions for the target.
std::set<std::string> defines;
- this->AddCompileDefinitions(defines, target, this->ConfigName, l->first);
+ this->GetTargetDefines(target, this->ConfigName, implicitLang.first,
+ defines);
if (!defines.empty()) {
/* clang-format off */
cmakefileStream
<< "\n"
<< "# Preprocessor definitions for this target.\n"
- << "set(CMAKE_TARGET_DEFINITIONS_" << l->first << "\n";
+ << "set(CMAKE_TARGET_DEFINITIONS_" << implicitLang.first << "\n";
/* clang-format on */
- for (std::set<std::string>::const_iterator di = defines.begin();
- di != defines.end(); ++di) {
- cmakefileStream << " " << cmOutputConverter::EscapeForCMake(*di)
+ for (std::string const& define : defines) {
+ cmakefileStream << " " << cmOutputConverter::EscapeForCMake(define)
<< "\n";
}
cmakefileStream << " )\n";
@@ -1858,21 +1858,20 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
// Target-specific include directories:
cmakefileStream << "\n"
<< "# The include file search paths:\n";
- cmakefileStream << "set(CMAKE_" << l->first << "_TARGET_INCLUDE_PATH\n";
+ cmakefileStream << "set(CMAKE_" << implicitLang.first
+ << "_TARGET_INCLUDE_PATH\n";
std::vector<std::string> includes;
- const std::string& config =
- this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- this->GetIncludeDirectories(includes, target, l->first, config);
+ this->GetIncludeDirectories(includes, target, implicitLang.first,
+ this->ConfigName);
std::string binaryDir = this->GetState()->GetBinaryDirectory();
if (this->Makefile->IsOn("CMAKE_DEPENDS_IN_PROJECT_ONLY")) {
- const char* sourceDir = this->GetState()->GetSourceDirectory();
+ std::string const& sourceDir = this->GetState()->GetSourceDirectory();
cmEraseIf(includes, ::NotInProjectDir(sourceDir, binaryDir));
}
- for (std::vector<std::string>::iterator i = includes.begin();
- i != includes.end(); ++i) {
+ for (std::string const& include : includes) {
cmakefileStream << " \""
- << this->MaybeConvertToRelativePath(binaryDir, *i)
+ << this->MaybeConvertToRelativePath(binaryDir, include)
<< "\"\n";
}
cmakefileStream << " )\n";
@@ -1883,18 +1882,16 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
std::vector<std::string> transformRules;
if (const char* xform =
this->Makefile->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) {
- cmSystemTools::ExpandListArgument(xform, transformRules);
+ cmExpandList(xform, transformRules);
}
if (const char* xform =
target->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) {
- cmSystemTools::ExpandListArgument(xform, transformRules);
+ cmExpandList(xform, transformRules);
}
if (!transformRules.empty()) {
cmakefileStream << "set(CMAKE_INCLUDE_TRANSFORMS\n";
- for (std::vector<std::string>::const_iterator tri = transformRules.begin();
- tri != transformRules.end(); ++tri) {
- cmakefileStream << " " << cmOutputConverter::EscapeForCMake(*tri)
- << "\n";
+ for (std::string const& tr : transformRules) {
+ cmakefileStream << " " << cmOutputConverter::EscapeForCMake(tr) << "\n";
}
cmakefileStream << " )\n";
}
@@ -1909,13 +1906,12 @@ void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os)
}
std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall(
- const char* makefile, const std::string& tgt)
+ const std::string& makefile, const std::string& tgt)
{
// Call make on the given file.
- std::string cmd;
- cmd += "$(MAKE) -f ";
- cmd += this->ConvertToOutputFormat(makefile, cmOutputConverter::SHELL);
- cmd += " ";
+ std::string cmd = cmStrCat(
+ "$(MAKE) -f ",
+ this->ConvertToOutputFormat(makefile, cmOutputConverter::SHELL), ' ');
cmGlobalUnixMakefileGenerator3* gg =
static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
@@ -1979,7 +1975,7 @@ void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os,
}
std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
- const char* p, bool useWatcomQuote)
+ const std::string& p, bool useWatcomQuote)
{
// Split the path into its components.
std::vector<std::string> components;
@@ -2004,10 +2000,9 @@ std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
#if defined(_WIN32) && !defined(__CYGWIN__)
if (!cmSystemTools::GetForceUnixPaths()) {
slash = "\\";
- for (std::string::iterator i = components[0].begin();
- i != components[0].end(); ++i) {
- if (*i == '/') {
- *i = '\\';
+ for (char& i : components[0]) {
+ if (i == '/') {
+ i = '\\';
}
}
}
@@ -2019,10 +2014,9 @@ std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
if (components.size() > 1) {
// Now add the rest of the components separated by the proper slash
// direction for this platform.
- std::vector<std::string>::const_iterator compEnd = std::remove(
- components.begin() + 1, components.end() - 1, std::string());
- std::vector<std::string>::const_iterator compStart =
- components.begin() + 1;
+ auto compEnd = std::remove(components.begin() + 1, components.end() - 1,
+ std::string());
+ auto compStart = components.begin() + 1;
result += cmJoin(cmMakeRange(compStart, compEnd), slash);
// Only the last component can be empty to avoid double slashes.
result += slash;
@@ -2047,8 +2041,7 @@ std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
std::string cmLocalUnixMakefileGenerator3::GetTargetDirectory(
cmGeneratorTarget const* target) const
{
- std::string dir = cmake::GetCMakeFilesDirectoryPostSlash();
- dir += target->GetName();
+ std::string dir = cmStrCat("CMakeFiles/", target->GetName());
#if defined(__VMS)
dir += "_dir";
#else
@@ -2064,14 +2057,14 @@ cmLocalUnixMakefileGenerator3::GetImplicitDepends(const cmGeneratorTarget* tgt)
}
void cmLocalUnixMakefileGenerator3::AddImplicitDepends(
- const cmGeneratorTarget* tgt, const std::string& lang, const char* obj,
- const char* src)
+ const cmGeneratorTarget* tgt, const std::string& lang,
+ const std::string& obj, const std::string& src)
{
this->ImplicitDepends[tgt->GetName()][lang][obj].push_back(src);
}
void cmLocalUnixMakefileGenerator3::CreateCDCommand(
- std::vector<std::string>& commands, const char* tgtDir,
+ std::vector<std::string>& commands, std::string const& tgtDir,
std::string const& relDir)
{
// do we need to cd?
@@ -2091,14 +2084,13 @@ void cmLocalUnixMakefileGenerator3::CreateCDCommand(
// On Windows we must perform each step separately and then change
// back because the shell keeps the working directory between
// commands.
- std::string cmd = cd_cmd;
- cmd += this->ConvertToOutputForExisting(tgtDir);
+ std::string cmd =
+ cmStrCat(cd_cmd, this->ConvertToOutputForExisting(tgtDir));
commands.insert(commands.begin(), cmd);
// Change back to the starting directory.
- cmd = cd_cmd;
- cmd += this->ConvertToOutputForExisting(relDir);
- commands.push_back(cmd);
+ cmd = cmStrCat(cd_cmd, this->ConvertToOutputForExisting(relDir));
+ commands.push_back(std::move(cmd));
} else {
// On UNIX we must construct a single shell command to change
// directory and build because make resets the directory between
@@ -2106,16 +2098,6 @@ void cmLocalUnixMakefileGenerator3::CreateCDCommand(
std::string outputForExisting = this->ConvertToOutputForExisting(tgtDir);
std::string prefix = cd_cmd + outputForExisting + " && ";
std::transform(commands.begin(), commands.end(), commands.begin(),
- std::bind1st(std::plus<std::string>(), prefix));
- }
-}
-
-std::string cmLocalUnixMakefileGenerator3::MaybeConvertToRelativePath(
- std::string const& base, std::string const& path)
-{
- if (!cmOutputConverter::ContainedInDirectory(
- base, path, this->GetStateSnapshot().GetDirectory())) {
- return path;
+ [&prefix](std::string const& s) { return prefix + s; });
}
- return cmOutputConverter::ForceToRelativePath(base, path);
}
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index f64409cba..f12ae8b16 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -3,23 +3,23 @@
#ifndef cmLocalUnixMakefileGenerator3_h
#define cmLocalUnixMakefileGenerator3_h
-#include "cmConfigure.h"
-
-#include "cmDepends.h"
-#include "cmLocalCommonGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
#include <set>
#include <string>
+#include <utility>
#include <vector>
+#include "cmDepends.h"
+#include "cmLocalCommonGenerator.h"
+
class cmCustomCommand;
class cmCustomCommandGenerator;
class cmGeneratorTarget;
class cmGlobalGenerator;
class cmMakefile;
-class cmSourceFile;
/** \class cmLocalUnixMakefileGenerator3
* \brief Write a LocalUnix makefiles.
@@ -31,14 +31,14 @@ class cmLocalUnixMakefileGenerator3 : public cmLocalCommonGenerator
{
public:
cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf);
- ~cmLocalUnixMakefileGenerator3() CM_OVERRIDE;
+ ~cmLocalUnixMakefileGenerator3() override;
- void ComputeHomeRelativeOutputPath() CM_OVERRIDE;
+ void ComputeHomeRelativeOutputPath() override;
/**
* Generate the makefile for this directory.
*/
- void Generate() CM_OVERRIDE;
+ void Generate() override;
// this returns the relative path between the HomeOutputDirectory and this
// local generators StartOutputDirectory
@@ -84,13 +84,13 @@ public:
void WriteDivider(std::ostream& os);
/** used to create a recursive make call */
- std::string GetRecursiveMakeCall(const char* makefile,
+ std::string GetRecursiveMakeCall(const std::string& makefile,
const std::string& tgt);
// append flags to a string
void AppendFlags(std::string& flags,
- const std::string& newFlags) CM_OVERRIDE;
- void AppendFlags(std::string& flags, const char* newFlags) CM_OVERRIDE;
+ const std::string& newFlags) const override;
+ using cmLocalCommonGenerator::AppendFlags;
// append an echo command
enum EchoColor
@@ -108,20 +108,20 @@ public:
std::string Arg;
};
void AppendEcho(std::vector<std::string>& commands, std::string const& text,
- EchoColor color = EchoNormal,
- EchoProgress const* = CM_NULLPTR);
+ EchoColor color = EchoNormal, EchoProgress const* = nullptr);
/** Get whether the makefile is to have color. */
bool GetColorMakefile() const { return this->ColorMakefile; }
- std::string GetTargetDirectory(cmGeneratorTarget const* target) const
- CM_OVERRIDE;
+ std::string GetTargetDirectory(
+ cmGeneratorTarget const* target) const override;
// create a command that cds to the start dir then runs the commands
void CreateCDCommand(std::vector<std::string>& commands,
- const char* targetDir, std::string const& relDir);
+ std::string const& targetDir,
+ std::string const& relDir);
- static std::string ConvertToQuotedOutputPath(const char* p,
+ static std::string ConvertToQuotedOutputPath(const std::string& p,
bool useWatcomQuote);
std::string CreateMakeVariable(const std::string& sin,
@@ -129,22 +129,22 @@ public:
/** Called from command-line hook to bring dependencies up to date
for a target. */
- bool UpdateDependencies(const char* tgtInfo, bool verbose,
- bool color) CM_OVERRIDE;
+ bool UpdateDependencies(const std::string& tgtInfo, bool verbose,
+ bool color) override;
/** Called from command-line hook to clear dependencies. */
- void ClearDependencies(cmMakefile* mf, bool verbose) CM_OVERRIDE;
+ void ClearDependencies(cmMakefile* mf, bool verbose) override;
/** write some extra rules such as make test etc */
void WriteSpecialTargetsTop(std::ostream& makefileStream);
void WriteSpecialTargetsBottom(std::ostream& makefileStream);
- std::string GetRelativeTargetDirectory(cmGeneratorTarget* target);
+ std::string GetRelativeTargetDirectory(
+ cmGeneratorTarget const* target) const;
// File pairs for implicit dependency scanning. The key of the map
// is the depender and the value is the explicit dependee.
- struct ImplicitDependFileMap
- : public std::map<std::string, cmDepends::DependencyVector>
+ struct ImplicitDependFileMap : public cmDepends::DependencyMap
{
};
struct ImplicitDependLanguageMap
@@ -159,8 +159,8 @@ public:
cmGeneratorTarget const* tgt);
void AddImplicitDepends(cmGeneratorTarget const* tgt,
- const std::string& lang, const char* obj,
- const char* src);
+ const std::string& lang, const std::string& obj,
+ const std::string& src);
// write the target rules for the local Makefile into the stream
void WriteLocalAllRules(std::ostream& ruleFileStream);
@@ -184,9 +184,6 @@ public:
// Eclipse generator.
void GetIndividualFileTargets(std::vector<std::string>& targets);
- std::string MaybeConvertToRelativePath(std::string const& base,
- std::string const& path);
-
protected:
void WriteLocalMakefile();
@@ -201,9 +198,6 @@ protected:
void WriteDependLanguageInfo(std::ostream& cmakefileStream,
cmGeneratorTarget* tgt);
- // write the local help rule
- void WriteHelpRule(std::ostream& ruleFileStream);
-
// this converts a file name that is relative to the StartOuputDirectory
// into a full path
std::string ConvertToFullPath(const std::string& localPath);
@@ -212,15 +206,6 @@ protected:
const std::string& realTarget,
const std::string& helpTarget);
- void WriteTargetDependRule(std::ostream& ruleFileStream,
- cmGeneratorTarget* target);
- void WriteTargetCleanRule(std::ostream& ruleFileStream,
- cmGeneratorTarget* target,
- const std::vector<std::string>& files);
- void WriteTargetRequiresRule(std::ostream& ruleFileStream,
- cmGeneratorTarget* target,
- const std::vector<std::string>& objects);
-
void AppendRuleDepend(std::vector<std::string>& depends,
const char* ruleFileName);
void AppendRuleDepends(std::vector<std::string>& depends,
@@ -238,25 +223,23 @@ protected:
cmGeneratorTarget* target,
std::string const& relative,
bool echo_comment = false,
- std::ostream* content = CM_NULLPTR);
+ std::ostream* content = nullptr);
void AppendCleanCommand(std::vector<std::string>& commands,
- const std::vector<std::string>& files,
+ const std::set<std::string>& files,
cmGeneratorTarget* target,
- const char* filename = CM_NULLPTR);
-
- // Helper methods for dependeny updates.
- bool ScanDependencies(
- const char* targetDir,
- std::map<std::string, cmDepends::DependencyVector>& validDeps);
+ const char* filename = nullptr);
+ void AppendDirectoryCleanCommand(std::vector<std::string>& commands);
+
+ // Helper methods for dependency updates.
+ bool ScanDependencies(std::string const& targetDir,
+ std::string const& dependFile,
+ std::string const& internalDependFile,
+ cmDepends::DependencyMap& validDeps);
void CheckMultipleOutputs(bool verbose);
private:
std::string MaybeConvertWatcomShellCommand(std::string const& cmd);
- void ComputeObjectFilenames(
- std::map<cmSourceFile const*, std::string>& mapping,
- cmGeneratorTarget const* gt = CM_NULLPTR) CM_OVERRIDE;
-
friend class cmMakefileTargetGenerator;
friend class cmMakefileExecutableTargetGenerator;
friend class cmMakefileLibraryTargetGenerator;
@@ -269,36 +252,27 @@ private:
struct LocalObjectEntry
{
- cmGeneratorTarget* Target;
+ cmGeneratorTarget* Target = nullptr;
std::string Language;
- LocalObjectEntry()
- : Target(CM_NULLPTR)
- , Language()
- {
- }
- LocalObjectEntry(cmGeneratorTarget* t, const std::string& lang)
+ LocalObjectEntry() = default;
+ LocalObjectEntry(cmGeneratorTarget* t, std::string lang)
: Target(t)
- , Language(lang)
+ , Language(std::move(lang))
{
}
};
struct LocalObjectInfo : public std::vector<LocalObjectEntry>
{
- bool HasSourceExtension;
- bool HasPreprocessRule;
- bool HasAssembleRule;
- LocalObjectInfo()
- : HasSourceExtension(false)
- , HasPreprocessRule(false)
- , HasAssembleRule(false)
- {
- }
+ bool HasSourceExtension = false;
+ bool HasPreprocessRule = false;
+ bool HasAssembleRule = false;
};
void GetLocalObjectFiles(
std::map<std::string, LocalObjectInfo>& localObjectFiles);
void WriteObjectConvenienceRule(std::ostream& ruleFileStream,
- const char* comment, const char* output,
+ const char* comment,
+ const std::string& output,
LocalObjectInfo const& info);
std::vector<std::string> LocalHelp;
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index 85d4a73b7..f3d828b28 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -2,13 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLocalVisualStudio10Generator.h"
+#include "cm_expat.h"
+
#include "cmGeneratorTarget.h"
#include "cmGlobalVisualStudio10Generator.h"
#include "cmMakefile.h"
#include "cmVisualStudio10TargetGenerator.h"
#include "cmXMLParser.h"
-
-#include "cm_expat.h"
+#include "cmake.h"
class cmVS10XMLParser : public cmXMLParser
{
@@ -17,7 +18,12 @@ public:
virtual void CharacterDataHandler(const char* data, int length)
{
if (this->DoGUID) {
- this->GUID.assign(data + 1, length - 2);
+ if (data[0] == '{') {
+ // remove surrounding curly brackets
+ this->GUID.assign(data + 1, length - 2);
+ } else {
+ this->GUID.assign(data, length);
+ }
this->DoGUID = false;
}
}
@@ -57,23 +63,48 @@ cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator()
{
}
-void cmLocalVisualStudio10Generator::Generate()
+void cmLocalVisualStudio10Generator::GenerateTargetsDepthFirst(
+ cmGeneratorTarget* target, std::vector<cmGeneratorTarget*>& remaining)
{
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ return;
+ }
+ // Find this target in the list of remaining targets.
+ auto it = std::find(remaining.begin(), remaining.end(), target);
+ if (it == remaining.end()) {
+ // This target was already handled.
+ return;
+ }
+ // Remove this target from the list of remaining targets because
+ // we are handling it now.
+ *it = nullptr;
+ auto& deps = this->GlobalGenerator->GetTargetDirectDepends(target);
+ for (auto& d : deps) {
+ // FIXME: Revise CreateSingleVCProj so we do not have to drop `const` here.
+ auto dependee = const_cast<cmGeneratorTarget*>(&*d);
+ GenerateTargetsDepthFirst(dependee, remaining);
+ // Take the union of visited source files of custom commands
+ auto visited = GetSourcesVisited(dependee);
+ GetSourcesVisited(target).insert(visited.begin(), visited.end());
+ }
+ if (static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
+ ->TargetIsFortranOnly(target)) {
+ this->CreateSingleVCProj(target->GetName(), target);
+ } else {
+ cmVisualStudio10TargetGenerator tg(
+ target,
+ static_cast<cmGlobalVisualStudio10Generator*>(
+ this->GetGlobalGenerator()));
+ tg.Generate();
+ }
+}
- std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); ++l) {
- if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
- continue;
- }
- if (static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
- ->TargetIsFortranOnly(*l)) {
- this->CreateSingleVCProj((*l)->GetName().c_str(), *l);
- } else {
- cmVisualStudio10TargetGenerator tg(
- *l, static_cast<cmGlobalVisualStudio10Generator*>(
- this->GetGlobalGenerator()));
- tg.Generate();
+void cmLocalVisualStudio10Generator::Generate()
+{
+ std::vector<cmGeneratorTarget*> remaining = this->GetGeneratorTargets();
+ for (auto& t : remaining) {
+ if (t) {
+ GenerateTargetsDepthFirst(t, remaining);
}
}
this->WriteStampFiles();
@@ -90,8 +121,7 @@ void cmLocalVisualStudio10Generator::ReadAndStoreExternalGUID(
return;
}
- std::string guidStoreName = name;
- guidStoreName += "_GUID_CMAKE";
+ std::string guidStoreName = cmStrCat(name, "_GUID_CMAKE");
// save the GUID in the cache
this->GlobalGenerator->GetCMakeInstance()->AddCacheEntry(
guidStoreName.c_str(), parser.GUID.c_str(), "Stored GUID",
diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h
index e57dd8f20..5c6400e9f 100644
--- a/Source/cmLocalVisualStudio10Generator.h
+++ b/Source/cmLocalVisualStudio10Generator.h
@@ -3,7 +3,7 @@
#ifndef cmLocalVisualStudio10Generator_h
#define cmLocalVisualStudio10Generator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
@@ -21,7 +21,7 @@ class cmMakefile;
class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator
{
public:
- ///! Set cache only and recurse to false by default.
+ //! Set cache only and recurse to false by default.
cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf);
virtual ~cmLocalVisualStudio10Generator();
@@ -29,14 +29,23 @@ public:
/**
* Generate the makefile for this directory.
*/
- virtual void Generate();
- virtual void ReadAndStoreExternalGUID(const std::string& name,
- const char* path);
+ void Generate() override;
+ void ReadAndStoreExternalGUID(const std::string& name,
+ const char* path) override;
+
+ std::set<cmSourceFile const*>& GetSourcesVisited(cmGeneratorTarget* target)
+ {
+ return SourcesVisited[target];
+ };
protected:
- virtual const char* ReportErrorLabel() const;
- virtual bool CustomCommandUseLocal() const { return true; }
+ const char* ReportErrorLabel() const override;
+ bool CustomCommandUseLocal() const override { return true; }
private:
+ void GenerateTargetsDepthFirst(cmGeneratorTarget* target,
+ std::vector<cmGeneratorTarget*>& remaining);
+
+ std::map<cmGeneratorTarget*, std::set<cmSourceFile const*>> SourcesVisited;
};
#endif
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index dd08e5bdb..f19549d7b 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -2,22 +2,26 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLocalVisualStudio7Generator.h"
+#include <windows.h>
+
+#include <ctype.h> // for isspace
+
+#include "cm_expat.h"
+
+#include "cmComputeLinkInformation.h"
+#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
+#include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalVisualStudio7Generator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmSourceFile.h"
#include "cmSystemTools.h"
#include "cmXMLParser.h"
-#include "cm_expat.h"
#include "cmake.h"
-#include "cmComputeLinkInformation.h"
-#include "cmGeneratedFileStream.h"
-
-#include <ctype.h> // for isspace
-#include <windows.h>
-
static bool cmLVS7G_IsFAT(const char* dir);
class cmLocalVisualStudio7GeneratorInternals
@@ -27,7 +31,7 @@ public:
: LocalGenerator(e)
{
}
- typedef cmComputeLinkInformation::ItemVector ItemVector;
+ using ItemVector = cmComputeLinkInformation::ItemVector;
void OutputLibraries(std::ostream& fout, ItemVector const& libs);
void OutputObjects(std::ostream& fout, cmGeneratorTarget* t,
std::string const& config, const char* isep = 0);
@@ -36,16 +40,14 @@ private:
cmLocalVisualStudio7Generator* LocalGenerator;
};
-extern cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[];
-
-static void cmConvertToWindowsSlash(std::string& s)
+class cmLocalVisualStudio7Generator::AllConfigSources
{
- std::string::size_type pos = 0;
- while ((pos = s.find('/', pos)) != std::string::npos) {
- s[pos] = '\\';
- pos++;
- }
-}
+public:
+ std::vector<cmGeneratorTarget::AllConfigSource> Sources;
+ std::map<cmSourceFile const*, size_t> Index;
+};
+
+extern cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[];
cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator(
cmGlobalGenerator* gg, cmMakefile* mf)
@@ -62,15 +64,14 @@ cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator()
void cmLocalVisualStudio7Generator::AddHelperCommands()
{
// Now create GUIDs for targets
- std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); ++l) {
- if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets();
+ for (cmGeneratorTarget const* l : tgts) {
+ if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- const char* path = (*l)->GetProperty("EXTERNAL_MSPROJECT");
+ const char* path = l->GetProperty("EXTERNAL_MSPROJECT");
if (path) {
- this->ReadAndStoreExternalGUID((*l)->GetName().c_str(), path);
+ this->ReadAndStoreExternalGUID(l->GetName(), path);
}
}
@@ -83,53 +84,28 @@ void cmLocalVisualStudio7Generator::Generate()
this->WriteStampFiles();
}
-void cmLocalVisualStudio7Generator::AddCMakeListsRules()
-{
- // Create the regeneration custom rule.
- if (!this->Makefile->IsOn("CMAKE_SUPPRESS_REGENERATION")) {
- // Create a rule to regenerate the build system when the target
- // specification source changes.
- if (cmSourceFile* sf = this->CreateVCProjBuildRule()) {
- // Add the rule to targets that need it.
- std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); ++l) {
- if ((*l)->GetType() == cmStateEnums::GLOBAL_TARGET) {
- continue;
- }
- if ((*l)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
- (*l)->AddSource(sf->GetFullPath());
- }
- }
- }
- }
-}
-
void cmLocalVisualStudio7Generator::FixGlobalTargets()
{
// Visual Studio .NET 2003 Service Pack 1 will not run post-build
// commands for targets in which no sources are built. Add dummy
// rules to force these targets to build.
- std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); l++) {
- if ((*l)->GetType() == cmStateEnums::GLOBAL_TARGET) {
+ const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets();
+ for (cmGeneratorTarget* l : tgts) {
+ if (l->GetType() == cmStateEnums::GLOBAL_TARGET) {
std::vector<std::string> no_depends;
- cmCustomCommandLine force_command;
- force_command.push_back("cd");
- force_command.push_back(".");
- cmCustomCommandLines force_commands;
- force_commands.push_back(force_command);
- std::string no_main_dependency = "";
- std::string force = this->GetCurrentBinaryDirectory();
- force += cmake::GetCMakeFilesDirectory();
- force += "/";
- force += (*l)->GetName();
- force += "_force";
+ cmCustomCommandLines force_commands =
+ cmMakeSingleCommandLine({ "cd", "." });
+ std::string no_main_dependency;
+ std::string force = cmStrCat(this->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/", l->GetName(), "_force");
+ if (cmSourceFile* sf =
+ this->Makefile->GetOrCreateGeneratedSource(force)) {
+ sf->SetProperty("SYMBOLIC", "1");
+ }
if (cmSourceFile* file = this->Makefile->AddCustomCommandToOutput(
force.c_str(), no_depends, no_main_dependency, force_commands, " ",
0, true)) {
- (*l)->AddSource(file->GetFullPath());
+ l->AddSource(file->ResolveFullPath());
}
}
}
@@ -141,27 +117,25 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
void cmLocalVisualStudio7Generator::WriteProjectFiles()
{
// If not an in source build, then create the output directory
- if (strcmp(this->GetCurrentBinaryDirectory(), this->GetSourceDirectory()) !=
- 0) {
+ if (this->GetCurrentBinaryDirectory() != this->GetSourceDirectory()) {
if (!cmSystemTools::MakeDirectory(this->GetCurrentBinaryDirectory())) {
- cmSystemTools::Error("Error creating directory ",
+ cmSystemTools::Error("Error creating directory " +
this->GetCurrentBinaryDirectory());
}
}
// Get the set of targets in this directory.
- std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets();
+ const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets();
// Create the project file for each target.
- for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin();
- l != tgts.end(); l++) {
- if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmGeneratorTarget* l : tgts) {
+ if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
// INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
// so don't build a projectfile for it
- if (!(*l)->GetProperty("EXTERNAL_MSPROJECT")) {
- this->CreateSingleVCProj((*l)->GetName().c_str(), *l);
+ if (!l->GetProperty("EXTERNAL_MSPROJECT")) {
+ this->CreateSingleVCProj(l->GetName(), l);
}
}
}
@@ -170,11 +144,10 @@ void cmLocalVisualStudio7Generator::WriteStampFiles()
{
// Touch a timestamp file used to determine when the project file is
// out of date.
- std::string stampName = this->GetCurrentBinaryDirectory();
- stampName += cmake::GetCMakeFilesDirectory();
+ std::string stampName =
+ cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles");
cmSystemTools::MakeDirectory(stampName.c_str());
- stampName += "/";
- stampName += "generate.stamp";
+ stampName += "/generate.stamp";
cmsys::ofstream stamp(stampName.c_str());
stamp << "# CMake generation timestamp file for this directory.\n";
@@ -184,14 +157,24 @@ void cmLocalVisualStudio7Generator::WriteStampFiles()
// dependencies. If any file listed in it is newer than itself then
// CMake must rerun. Otherwise the project files are up to date and
// the stamp file can just be touched.
- std::string depName = stampName;
- depName += ".depend";
+ std::string depName = cmStrCat(stampName, ".depend");
cmsys::ofstream depFile(depName.c_str());
depFile << "# CMake generation dependency list for this directory.\n";
- std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();
- for (std::vector<std::string>::const_iterator lf = listFiles.begin();
- lf != listFiles.end(); ++lf) {
- depFile << *lf << std::endl;
+
+ std::vector<std::string> listFiles(this->Makefile->GetListFiles());
+ cmake* cm = this->GlobalGenerator->GetCMakeInstance();
+ if (cm->DoWriteGlobVerifyTarget()) {
+ listFiles.push_back(cm->GetGlobVerifyStamp());
+ }
+
+ // Sort the list of input files and remove duplicates.
+ std::sort(listFiles.begin(), listFiles.end(), std::less<std::string>());
+ std::vector<std::string>::iterator new_end =
+ std::unique(listFiles.begin(), listFiles.end());
+ listFiles.erase(new_end, listFiles.end());
+
+ for (const std::string& lf : listFiles) {
+ depFile << lf << "\n";
}
}
@@ -214,9 +197,7 @@ void cmLocalVisualStudio7Generator::CreateSingleVCProj(
target->Target->SetProperty("GENERATOR_FILE_NAME", lname.c_str());
// create the dsp.cmake file
std::string fname;
- fname = this->GetCurrentBinaryDirectory();
- fname += "/";
- fname += lname;
+ fname = cmStrCat(this->GetCurrentBinaryDirectory(), '/', lname);
if (this->FortranProject) {
fname += ".vfproj";
} else {
@@ -238,46 +219,57 @@ void cmLocalVisualStudio7Generator::CreateSingleVCProj(
cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
{
- std::string stampName = this->GetCurrentBinaryDirectory();
- stampName += "/";
- stampName += cmake::GetCMakeFilesDirectoryPostSlash();
- stampName += "generate.stamp";
- cmCustomCommandLine commandLine;
- commandLine.push_back(cmSystemTools::GetCMakeCommand());
- std::string makefileIn = this->GetCurrentSourceDirectory();
- makefileIn += "/";
- makefileIn += "CMakeLists.txt";
- makefileIn = cmSystemTools::CollapseFullPath(makefileIn.c_str());
- if (!cmSystemTools::FileExists(makefileIn.c_str())) {
- return 0;
- }
- std::string comment = "Building Custom Rule ";
- comment += makefileIn;
- std::string args;
- args = "-H";
- args += this->GetSourceDirectory();
- commandLine.push_back(args);
- args = "-B";
- args += this->GetBinaryDirectory();
- commandLine.push_back(args);
- commandLine.push_back("--check-stamp-file");
- commandLine.push_back(stampName);
-
- std::vector<std::string> const& listFiles = this->Makefile->GetListFiles();
-
- cmCustomCommandLines commandLines;
- commandLines.push_back(commandLine);
- const char* no_working_directory = 0;
+ if (this->GlobalGenerator->GlobalSettingIsOn(
+ "CMAKE_SUPPRESS_REGENERATION")) {
+ return nullptr;
+ }
+
+ std::string makefileIn =
+ cmStrCat(this->GetCurrentSourceDirectory(), "/CMakeLists.txt");
+ makefileIn = cmSystemTools::CollapseFullPath(makefileIn);
+ if (cmSourceFile* file = this->Makefile->GetSource(makefileIn)) {
+ if (file->GetCustomCommand()) {
+ return file;
+ }
+ }
+ if (!cmSystemTools::FileExists(makefileIn)) {
+ return nullptr;
+ }
+
+ std::vector<std::string> listFiles = this->Makefile->GetListFiles();
+ cmake* cm = this->GlobalGenerator->GetCMakeInstance();
+ if (cm->DoWriteGlobVerifyTarget()) {
+ listFiles.push_back(cm->GetGlobVerifyStamp());
+ }
+
+ // Sort the list of input files and remove duplicates.
+ std::sort(listFiles.begin(), listFiles.end(), std::less<std::string>());
+ std::vector<std::string>::iterator new_end =
+ std::unique(listFiles.begin(), listFiles.end());
+ listFiles.erase(new_end, listFiles.end());
+
+ std::string argS = cmStrCat("-S", this->GetSourceDirectory());
+ std::string argB = cmStrCat("-B", this->GetBinaryDirectory());
+ std::string stampName =
+ cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/generate.stamp");
+ cmCustomCommandLines commandLines =
+ cmMakeSingleCommandLine({ cmSystemTools::GetCMakeCommand(), argS, argB,
+ "--check-stamp-file", stampName });
+ std::string comment = cmStrCat("Building Custom Rule ", makefileIn);
+ const char* no_working_directory = nullptr;
std::string fullpathStampName =
cmSystemTools::CollapseFullPath(stampName.c_str());
this->Makefile->AddCustomCommandToOutput(
- fullpathStampName.c_str(), listFiles, makefileIn.c_str(), commandLines,
- comment.c_str(), no_working_directory, true, false);
+ fullpathStampName, listFiles, makefileIn, commandLines, comment.c_str(),
+ no_working_directory, true, false);
if (cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str())) {
+ // Finalize the source file path now since we're adding this after
+ // the generator validated all project-named sources.
+ file->ResolveFullPath();
return file;
} else {
- cmSystemTools::Error("Error adding rule for ", makefileIn.c_str());
- return 0;
+ cmSystemTools::Error("Error adding rule for " + makefileIn);
+ return nullptr;
}
}
@@ -286,9 +278,8 @@ void cmLocalVisualStudio7Generator::WriteConfigurations(
const std::string& libName, cmGeneratorTarget* target)
{
fout << "\t<Configurations>\n";
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
- this->WriteConfiguration(fout, i->c_str(), libName, target);
+ for (std::string const& config : configs) {
+ this->WriteConfiguration(fout, config.c_str(), libName, target);
}
fout << "\t</Configurations>\n";
}
@@ -356,7 +347,7 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFortranFlagTable[] = {
{ "EnableRecursion", "recursive", "", "true", 0 },
{ "ReentrantCode", "reentrancy", "", "true", 0 },
// done up to Language
- { 0, 0, 0, 0, 0 }
+ { "", "", "", "", 0 }
};
// fill the table here currently the comment field is not used for
// anything other than documentation NOTE: Make sure the longer
@@ -466,7 +457,7 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = {
{ "WarnAsError", "WX", "Treat warnings as errors", "true", 0 },
{ "BrowseInformation", "FR", "Generate browse information", "1", 0 },
{ "StringPooling", "GF", "Enable StringPooling", "true", 0 },
- { 0, 0, 0, 0, 0 }
+ { "", "", "", "", 0 }
};
cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = {
@@ -525,12 +516,13 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = {
{ "TargetMachine", "MACHINE:SH5", "Machine SH5", "15", 0 },
{ "TargetMachine", "MACHINE:THUMB", "Machine THUMB", "16", 0 },
{ "TargetMachine", "MACHINE:X64", "Machine x64", "17", 0 },
+ { "TargetMachine", "MACHINE:ARM64", "Machine ARM64", "18", 0 },
{ "TurnOffAssemblyGeneration", "NOASSEMBLY",
"No assembly even if CLR information is present in objects.", "true", 0 },
{ "ModuleDefinitionFile", "DEF:", "add an export def file", "",
cmVS7FlagTable::UserValue },
{ "GenerateMapFile", "MAP", "enable generation of map file", "true", 0 },
- { 0, 0, 0, 0, 0 }
+ { "", "", "", "", 0 }
};
cmVS7FlagTable cmLocalVisualStudio7GeneratorFortranLinkFlagTable[] = {
@@ -538,7 +530,15 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFortranLinkFlagTable[] = {
"linkIncrementalNo", 0 },
{ "LinkIncremental", "INCREMENTAL:YES", "link incremental",
"linkIncrementalYes", 0 },
- { 0, 0, 0, 0, 0 }
+ { "EnableCOMDATFolding", "OPT:NOICF", "Do not remove redundant COMDATs",
+ "optNoFolding", 0 },
+ { "EnableCOMDATFolding", "OPT:ICF", "Remove redundant COMDATs", "optFolding",
+ 0 },
+ { "OptimizeReferences", "OPT:NOREF", "Keep unreferenced data",
+ "optNoReferences", 0 },
+ { "OptimizeReferences", "OPT:REF", "Eliminate unreferenced data",
+ "optReferences", 0 },
+ { "", "", "", "", 0 }
};
// Helper class to write build event <Tool .../> elements.
@@ -561,9 +561,8 @@ public:
void Finish() { this->Stream << (this->First ? "" : "\"") << "/>\n"; }
void Write(std::vector<cmCustomCommand> const& ccs)
{
- for (std::vector<cmCustomCommand>::const_iterator ci = ccs.begin();
- ci != ccs.end(); ++ci) {
- this->Write(*ci);
+ for (cmCustomCommand const& command : ccs) {
+ this->Write(command);
}
}
void Write(cmCustomCommand const& cc)
@@ -616,6 +615,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
switch (target->GetType()) {
case cmStateEnums::OBJECT_LIBRARY:
targetBuilds = false; // no manifest tool for object library
+ CM_FALLTHROUGH;
case cmStateEnums::STATIC_LIBRARY:
projectType = "typeStaticLibrary";
configType = "4";
@@ -631,6 +631,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
case cmStateEnums::UTILITY:
case cmStateEnums::GLOBAL_TARGET:
configType = "10";
+ CM_FALLTHROUGH;
default:
targetBuilds = false;
break;
@@ -639,26 +640,21 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
configType = projectType;
}
std::string flags;
- if (strcmp(configType, "10") != 0) {
+ std::string langForClCompile;
+ if (target->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
const std::string& linkLanguage =
(this->FortranProject ? std::string("Fortran")
: target->GetLinkerLanguage(configName));
if (linkLanguage.empty()) {
cmSystemTools::Error(
- "CMake can not determine linker language for target: ",
- target->GetName().c_str());
+ "CMake can not determine linker language for target: " +
+ target->GetName());
return;
}
- if (linkLanguage == "C" || linkLanguage == "CXX" ||
- linkLanguage == "Fortran") {
- std::string baseFlagVar = "CMAKE_";
- baseFlagVar += linkLanguage;
- baseFlagVar += "_FLAGS";
- flags = this->Makefile->GetRequiredDefinition(baseFlagVar.c_str());
- std::string flagVar =
- baseFlagVar + std::string("_") + cmSystemTools::UpperCase(configName);
- flags += " ";
- flags += this->Makefile->GetRequiredDefinition(flagVar.c_str());
+ langForClCompile = linkLanguage;
+ if (langForClCompile == "C" || langForClCompile == "CXX" ||
+ langForClCompile == "Fortran") {
+ this->AddLanguageFlags(flags, target, langForClCompile, configName);
}
// set the correct language
if (linkLanguage == "C") {
@@ -669,7 +665,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
}
// Add the target-specific flags.
- this->AddCompileOptions(flags, target, linkLanguage, configName);
+ this->AddCompileOptions(flags, target, langForClCompile, configName);
// Check IPO related warning/error.
target->IsIPOEnabled(linkLanguage, configName);
@@ -699,33 +695,36 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
}
Options targetOptions(this, t, table, gg->ExtraFlagTable);
targetOptions.FixExceptionHandlingDefault();
- std::string asmLocation = configName + "/";
- targetOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
- targetOptions.Parse(flags.c_str());
- targetOptions.Parse(defineFlags.c_str());
+ targetOptions.AddFlag("AssemblerListingLocation", "$(IntDir)\\");
+ targetOptions.Parse(flags);
+ targetOptions.Parse(defineFlags);
targetOptions.ParseFinish();
- std::vector<std::string> targetDefines;
- target->GetCompileDefinitions(targetDefines, configName, "CXX");
- targetOptions.AddDefines(targetDefines);
+ if (!langForClCompile.empty()) {
+ std::vector<std::string> targetDefines;
+ target->GetCompileDefinitions(targetDefines, configName, langForClCompile);
+ targetOptions.AddDefines(targetDefines);
+
+ std::vector<std::string> targetIncludes;
+ this->GetIncludeDirectories(targetIncludes, target, langForClCompile,
+ configName);
+ targetOptions.AddIncludes(targetIncludes);
+ }
targetOptions.SetVerboseMakefile(
this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
// Add a definition for the configuration name.
- std::string configDefine = "CMAKE_INTDIR=\"";
- configDefine += configName;
- configDefine += "\"";
+ std::string configDefine = cmStrCat("CMAKE_INTDIR=\"", configName, '"');
targetOptions.AddDefine(configDefine);
// Add the export symbol definition for shared library objects.
- if (const char* exportMacro = target->GetExportMacro()) {
- targetOptions.AddDefine(exportMacro);
+ if (const std::string* exportMacro = target->GetExportMacro()) {
+ targetOptions.AddDefine(*exportMacro);
}
// The intermediate directory name consists of a directory for the
// target and a subdirectory for the configuration name.
- std::string intermediateDir = this->GetTargetDirectory(target);
- intermediateDir += "/";
- intermediateDir += configName;
+ std::string intermediateDir =
+ cmStrCat(this->GetTargetDirectory(target), '/', configName);
if (target->GetType() < cmStateEnums::UTILITY) {
std::string const& outDir =
@@ -784,8 +783,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
target->GetProperty("Fortran_MODULE_DIRECTORY");
std::string modDir;
if (target_mod_dir) {
- modDir = this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(),
- target_mod_dir);
+ modDir = this->MaybeConvertToRelativePath(
+ this->GetCurrentBinaryDirectory(), target_mod_dir);
} else {
modDir = ".";
}
@@ -793,26 +792,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
<< this->ConvertToXMLOutputPath(modDir.c_str())
<< "\\$(ConfigurationName)\"\n";
}
- fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
- std::vector<std::string> includes;
- this->GetIncludeDirectories(includes, target, "C", configName);
- std::vector<std::string>::iterator i = includes.begin();
- for (; i != includes.end(); ++i) {
- // output the include path
- std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
- fout << ipath << ";";
- // if this is fortran then output the include with
- // a ConfigurationName on the end of it.
- if (this->FortranProject) {
- ipath = i->c_str();
- ipath += "/$(ConfigurationName)";
- ipath = this->ConvertToXMLOutputPath(ipath.c_str());
- fout << ipath << ";";
- }
- }
- fout << "\"\n";
- targetOptions.OutputFlagMap(fout, "\t\t\t\t");
- targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX");
+ targetOptions.OutputAdditionalIncludeDirectories(
+ fout, 4, this->FortranProject ? "Fortran" : langForClCompile);
+ targetOptions.OutputFlagMap(fout, 4);
+ targetOptions.OutputPreprocessorDefinitions(fout, 4, langForClCompile);
fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
if (target->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
// Specify the compiler program database file if configured.
@@ -829,21 +812,12 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
fout <<
"\t\t\t<Tool\n"
"\t\t\t\tName=\"MASM\"\n"
- "\t\t\t\tIncludePaths=\""
;
/* clang-format on */
- const char* sep = "";
- for (i = includes.begin(); i != includes.end(); ++i) {
- std::string inc = *i;
- cmConvertToWindowsSlash(inc);
- fout << sep << this->EscapeForXML(inc);
- sep = ";";
- }
- fout << "\"\n";
+ targetOptions.OutputAdditionalIncludeDirectories(fout, 4, "ASM_MASM");
// Use same preprocessor definitions as VCCLCompilerTool.
- targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n",
- "ASM_MASM");
- masmOptions.OutputFlagMap(fout, "\t\t\t\t");
+ targetOptions.OutputPreprocessorDefinitions(fout, 4, "ASM_MASM");
+ masmOptions.OutputFlagMap(fout, 4);
/* clang-format off */
fout <<
"\t\t\t\tObjectFile=\"$(IntDir)\\\"\n"
@@ -859,27 +833,17 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
if (this->FortranProject) {
tool = "VFResourceCompilerTool";
}
- fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n"
- << "\t\t\t\tAdditionalIncludeDirectories=\"";
- for (i = includes.begin(); i != includes.end(); ++i) {
- std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
- fout << ipath << ";";
- }
+ fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n";
+ targetOptions.OutputAdditionalIncludeDirectories(fout, 4, "RC");
// add the -D flags to the RC tool
- fout << "\"";
- targetOptions.OutputPreprocessorDefinitions(fout, "\n\t\t\t\t", "", "RC");
- fout << "/>\n";
+ targetOptions.OutputPreprocessorDefinitions(fout, 4, "RC");
+ fout << "\t\t\t/>\n";
tool = "VCMIDLTool";
if (this->FortranProject) {
tool = "VFMIDLTool";
}
fout << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"\n";
- fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
- for (i = includes.begin(); i != includes.end(); ++i) {
- std::string ipath = this->ConvertToXMLOutputPath(i->c_str());
- fout << ipath << ";";
- }
- fout << "\"\n";
+ targetOptions.OutputAdditionalIncludeDirectories(fout, 4, "MIDL");
fout << "\t\t\t\tMkTypLibCompatible=\"false\"\n";
if (gg->GetPlatformName() == "x64") {
fout << "\t\t\t\tTargetEnvironment=\"3\"\n";
@@ -913,10 +877,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
target->GetManifests(manifest_srcs, configName);
if (!manifest_srcs.empty()) {
fout << "\n\t\t\t\tAdditionalManifestFiles=\"";
- for (std::vector<cmSourceFile const*>::const_iterator mi =
- manifest_srcs.begin();
- mi != manifest_srcs.end(); ++mi) {
- std::string m = (*mi)->GetFullPath();
+ for (cmSourceFile const* manifest : manifest_srcs) {
+ std::string m = manifest->GetFullPath();
fout << this->ConvertToXMLOutputPath(m.c_str()) << ";";
}
fout << "\"";
@@ -947,9 +909,8 @@ std::string cmLocalVisualStudio7Generator::GetBuildTypeLinkerFlags(
std::string extraLinkOptionsBuildTypeDef =
rootLinkerFlags + "_" + configTypeUpper;
- std::string extraLinkOptionsBuildType =
- this->Makefile->GetRequiredDefinition(
- extraLinkOptionsBuildTypeDef.c_str());
+ const std::string& extraLinkOptionsBuildType =
+ this->Makefile->GetRequiredDefinition(extraLinkOptionsBuildTypeDef);
return extraLinkOptionsBuildType;
}
@@ -964,21 +925,18 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
std::string extraLinkOptions;
if (target->GetType() == cmStateEnums::EXECUTABLE) {
extraLinkOptions =
- this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS") +
- std::string(" ") +
+ this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS") + " " +
GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName);
}
if (target->GetType() == cmStateEnums::SHARED_LIBRARY) {
extraLinkOptions =
this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS") +
- std::string(" ") +
- GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName);
+ " " + GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName);
}
if (target->GetType() == cmStateEnums::MODULE_LIBRARY) {
extraLinkOptions =
this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS") +
- std::string(" ") +
- GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName);
+ " " + GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName);
}
const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
@@ -987,38 +945,41 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
extraLinkOptions += targetLinkFlags;
}
std::string configTypeUpper = cmSystemTools::UpperCase(configName);
- std::string linkFlagsConfig = "LINK_FLAGS_";
- linkFlagsConfig += configTypeUpper;
+ std::string linkFlagsConfig = cmStrCat("LINK_FLAGS_", configTypeUpper);
targetLinkFlags = target->GetProperty(linkFlagsConfig.c_str());
if (targetLinkFlags) {
extraLinkOptions += " ";
extraLinkOptions += targetLinkFlags;
}
+
+ std::vector<std::string> opts;
+ target->GetLinkOptions(opts, configName,
+ target->GetLinkerLanguage(configName));
+ // LINK_OPTIONS are escaped.
+ this->AppendCompileOptions(extraLinkOptions, opts);
+
Options linkOptions(this, Options::Linker);
if (this->FortranProject) {
linkOptions.AddTable(cmLocalVisualStudio7GeneratorFortranLinkFlagTable);
}
linkOptions.AddTable(cmLocalVisualStudio7GeneratorLinkFlagTable);
- linkOptions.Parse(extraLinkOptions.c_str());
+ linkOptions.Parse(extraLinkOptions);
cmGeneratorTarget::ModuleDefinitionInfo const* mdi =
target->GetModuleDefinitionInfo(configName);
if (mdi && !mdi->DefFile.empty()) {
std::string defFile =
this->ConvertToOutputFormat(mdi->DefFile, cmOutputConverter::SHELL);
- linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str());
+ linkOptions.AddFlag("ModuleDefinitionFile", defFile);
}
switch (target->GetType()) {
case cmStateEnums::UNKNOWN_LIBRARY:
break;
case cmStateEnums::OBJECT_LIBRARY: {
- std::string libpath = this->GetTargetDirectory(target);
- libpath += "/";
- libpath += configName;
- libpath += "/";
- libpath += target->GetName();
- libpath += ".lib";
+ std::string libpath =
+ cmStrCat(this->GetTargetDirectory(target), '/', configName, '/',
+ target->GetName(), ".lib");
const char* tool =
this->FortranProject ? "VFLibrarianTool" : "VCLibrarianTool";
fout << "\t\t\t<Tool\n"
@@ -1029,9 +990,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
}
case cmStateEnums::STATIC_LIBRARY: {
std::string targetNameFull = target->GetFullName(configName);
- std::string libpath = target->GetDirectory(configName);
- libpath += "/";
- libpath += targetNameFull;
+ std::string libpath =
+ cmStrCat(target->GetDirectory(configName), '/', targetNameFull);
const char* tool = "VCLibrarianTool";
if (this->FortranProject) {
tool = "VFLibrarianTool";
@@ -1048,7 +1008,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
}
}
std::string libflags;
- this->GetStaticLibraryFlags(libflags, configTypeUpper, target);
+ this->GetStaticLibraryFlags(libflags, configTypeUpper,
+ target->GetLinkerLanguage(configName),
+ target);
if (!libflags.empty()) {
fout << "\t\t\t\tAdditionalOptions=\"" << libflags << "\"\n";
}
@@ -1058,13 +1020,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
}
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY: {
- std::string targetName;
- std::string targetNameSO;
- std::string targetNameFull;
- std::string targetNameImport;
- std::string targetNamePDB;
- target->GetLibraryNames(targetName, targetNameSO, targetNameFull,
- targetNameImport, targetNamePDB, configName);
+ cmGeneratorTarget::Names targetNames =
+ target->GetLibraryNames(configName);
// Compute the link library and directory information.
cmComputeLinkInformation* pcli = target->GetLinkInformation(configName);
@@ -1076,9 +1033,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
// Compute the variable name to lookup standard libraries for this
// language.
- std::string standardLibsVar = "CMAKE_";
- standardLibsVar += linkLanguage;
- standardLibsVar += "_STANDARD_LIBRARIES";
+ std::string standardLibsVar =
+ cmStrCat("CMAKE_", linkLanguage, "_STANDARD_LIBRARIES");
const char* tool = "VCLinkerTool";
if (this->FortranProject) {
tool = "VFLinkerTool";
@@ -1091,26 +1047,24 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
// Use the NOINHERIT macro to avoid getting VS project default
// libraries which may be set by the user to something bad.
fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
- << this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
+ << this->Makefile->GetSafeDefinition(standardLibsVar);
if (this->FortranProject) {
this->Internal->OutputObjects(fout, target, configName, " ");
}
fout << " ";
this->Internal->OutputLibraries(fout, cli.GetItems());
fout << "\"\n";
- temp = target->GetDirectory(configName);
- temp += "/";
- temp += targetNameFull;
+ temp =
+ cmStrCat(target->GetDirectory(configName), '/', targetNames.Output);
fout << "\t\t\t\tOutputFile=\""
<< this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
this->WriteTargetVersionAttribute(fout, target);
- linkOptions.OutputFlagMap(fout, "\t\t\t\t");
+ linkOptions.OutputFlagMap(fout, 4);
fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
this->OutputLibraryDirectories(fout, cli.GetDirectories());
fout << "\"\n";
- temp = target->GetPDBDirectory(configName);
- temp += "/";
- temp += targetNamePDB;
+ temp =
+ cmStrCat(target->GetPDBDirectory(configName), '/', targetNames.PDB);
fout << "\t\t\t\tProgramDatabaseFile=\""
<< this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
if (targetOptions.IsDebug()) {
@@ -1123,17 +1077,14 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
fout << "\t\t\t\tSubSystem=\"8\"\n";
}
}
- std::string stackVar = "CMAKE_";
- stackVar += linkLanguage;
- stackVar += "_STACK_SIZE";
+ std::string stackVar = cmStrCat("CMAKE_", linkLanguage, "_STACK_SIZE");
const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
if (stackVal) {
fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"\n";
}
- temp =
- target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact);
- temp += "/";
- temp += targetNameImport;
+ temp = cmStrCat(
+ target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact),
+ '/', targetNames.ImportLibrary);
fout << "\t\t\t\tImportLibrary=\""
<< this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"";
if (this->FortranProject) {
@@ -1142,12 +1093,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
fout << "/>\n";
} break;
case cmStateEnums::EXECUTABLE: {
- std::string targetName;
- std::string targetNameFull;
- std::string targetNameImport;
- std::string targetNamePDB;
- target->GetExecutableNames(targetName, targetNameFull, targetNameImport,
- targetNamePDB, configName);
+ cmGeneratorTarget::Names targetNames =
+ target->GetExecutableNames(configName);
// Compute the link library and directory information.
cmComputeLinkInformation* pcli = target->GetLinkInformation(configName);
@@ -1161,9 +1108,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
// Compute the variable name to lookup standard libraries for this
// language.
- std::string standardLibsVar = "CMAKE_";
- standardLibsVar += linkLanguage;
- standardLibsVar += "_STANDARD_LIBRARIES";
+ std::string standardLibsVar =
+ cmStrCat("CMAKE_", linkLanguage, "_STANDARD_LIBRARIES");
const char* tool = "VCLinkerTool";
if (this->FortranProject) {
tool = "VFLinkerTool";
@@ -1176,27 +1122,26 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
// Use the NOINHERIT macro to avoid getting VS project default
// libraries which may be set by the user to something bad.
fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
- << this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
+ << this->Makefile->GetSafeDefinition(standardLibsVar);
if (this->FortranProject) {
this->Internal->OutputObjects(fout, target, configName, " ");
}
fout << " ";
this->Internal->OutputLibraries(fout, cli.GetItems());
fout << "\"\n";
- temp = target->GetDirectory(configName);
- temp += "/";
- temp += targetNameFull;
+ temp =
+ cmStrCat(target->GetDirectory(configName), '/', targetNames.Output);
fout << "\t\t\t\tOutputFile=\""
<< this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
this->WriteTargetVersionAttribute(fout, target);
- linkOptions.OutputFlagMap(fout, "\t\t\t\t");
+ linkOptions.OutputFlagMap(fout, 4);
fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
this->OutputLibraryDirectories(fout, cli.GetDirectories());
fout << "\"\n";
std::string path = this->ConvertToXMLOutputPathSingle(
target->GetPDBDirectory(configName).c_str());
- fout << "\t\t\t\tProgramDatabaseFile=\"" << path << "/" << targetNamePDB
- << "\"\n";
+ fout << "\t\t\t\tProgramDatabaseFile=\"" << path << "/"
+ << targetNames.PDB << "\"\n";
if (targetOptions.IsDebug()) {
fout << "\t\t\t\tGenerateDebugInformation=\"true\"\n";
}
@@ -1221,17 +1166,14 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
fout << "\t\t\t\tSubSystem=\"" << (isWin32Executable ? "2" : "1")
<< "\"\n";
}
- std::string stackVar = "CMAKE_";
- stackVar += linkLanguage;
- stackVar += "_STACK_SIZE";
+ std::string stackVar = cmStrCat("CMAKE_", linkLanguage, "_STACK_SIZE");
const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
if (stackVal) {
fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"";
}
- temp =
- target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact);
- temp += "/";
- temp += targetNameImport;
+ temp = cmStrCat(
+ target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact),
+ '/', targetNames.ImportLibrary);
fout << "\t\t\t\tImportLibrary=\""
<< this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n";
break;
@@ -1243,30 +1185,56 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
}
}
+static std::string cmLocalVisualStudio7GeneratorEscapeForXML(
+ const std::string& s)
+{
+ std::string ret = s;
+ cmSystemTools::ReplaceString(ret, "&", "&amp;");
+ cmSystemTools::ReplaceString(ret, "\"", "&quot;");
+ cmSystemTools::ReplaceString(ret, "<", "&lt;");
+ cmSystemTools::ReplaceString(ret, ">", "&gt;");
+ cmSystemTools::ReplaceString(ret, "\n", "&#x0D;&#x0A;");
+ return ret;
+}
+
+static std::string GetEscapedPropertyIfValueNotNULL(const char* propertyValue)
+{
+ return propertyValue == nullptr
+ ? std::string()
+ : cmLocalVisualStudio7GeneratorEscapeForXML(propertyValue);
+}
+
void cmLocalVisualStudio7Generator::OutputDeploymentDebuggerTool(
std::ostream& fout, std::string const& config, cmGeneratorTarget* target)
{
if (this->WindowsCEProject) {
- if (const char* dir = target->GetProperty("DEPLOYMENT_REMOTE_DIRECTORY")) {
- /* clang-format off */
- fout <<
- "\t\t\t<DeploymentTool\n"
- "\t\t\t\tForceDirty=\"-1\"\n"
- "\t\t\t\tRemoteDirectory=\"" << this->EscapeForXML(dir) << "\"\n"
- "\t\t\t\tRegisterOutput=\"0\"\n"
- "\t\t\t\tAdditionalFiles=\"\"/>\n"
- ;
- /* clang-format on */
+ const char* dir = target->GetProperty("DEPLOYMENT_REMOTE_DIRECTORY");
+ const char* additionalFiles =
+ target->GetProperty("DEPLOYMENT_ADDITIONAL_FILES");
+
+ if (dir == nullptr && additionalFiles == nullptr) {
+ return;
+ }
+
+ fout << "\t\t\t<DeploymentTool\n"
+ "\t\t\t\tForceDirty=\"-1\"\n"
+ "\t\t\t\tRemoteDirectory=\""
+ << GetEscapedPropertyIfValueNotNULL(dir)
+ << "\"\n"
+ "\t\t\t\tRegisterOutput=\"0\"\n"
+ "\t\t\t\tAdditionalFiles=\""
+ << GetEscapedPropertyIfValueNotNULL(additionalFiles) << "\"/>\n";
+
+ if (dir != nullptr) {
std::string const exe =
dir + std::string("\\") + target->GetFullName(config);
- /* clang-format off */
- fout <<
- "\t\t\t<DebuggerTool\n"
- "\t\t\t\tRemoteExecutable=\"" << this->EscapeForXML(exe) << "\"\n"
- "\t\t\t\tArguments=\"\"\n"
- "\t\t\t/>\n"
- ;
- /* clang-format on */
+
+ fout << "\t\t\t<DebuggerTool\n"
+ "\t\t\t\tRemoteExecutable=\""
+ << this->EscapeForXML(exe)
+ << "\"\n"
+ "\t\t\t\tArguments=\"\"\n"
+ "\t\t\t/>\n";
}
}
}
@@ -1285,14 +1253,14 @@ void cmLocalVisualStudio7GeneratorInternals::OutputLibraries(
{
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
std::string currentBinDir = lg->GetCurrentBinaryDirectory();
- for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
- if (l->IsPath) {
+ for (auto const& lib : libs) {
+ if (lib.IsPath) {
std::string rel =
- lg->ConvertToRelativePath(currentBinDir, l->Value.c_str());
+ lg->MaybeConvertToRelativePath(currentBinDir, lib.Value.c_str());
fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " ";
- } else if (!l->Target ||
- l->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
- fout << l->Value << " ";
+ } else if (!lib.Target ||
+ lib.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ fout << lib.Value << " ";
}
}
}
@@ -1310,11 +1278,10 @@ void cmLocalVisualStudio7GeneratorInternals::OutputObjects(
gt->GetExternalObjects(objs, configName);
const char* sep = isep ? isep : "";
- for (std::vector<cmSourceFile const*>::const_iterator i = objs.begin();
- i != objs.end(); ++i) {
- if (!(*i)->GetObjectLibrary().empty()) {
- std::string const& objFile = (*i)->GetFullPath();
- std::string rel = lg->ConvertToRelativePath(currentBinDir, objFile);
+ for (cmSourceFile const* obj : objs) {
+ if (!obj->GetObjectLibrary().empty()) {
+ std::string const& objFile = obj->GetFullPath();
+ std::string rel = lg->MaybeConvertToRelativePath(currentBinDir, objFile);
fout << sep << lg->ConvertToXMLOutputPath(rel.c_str());
sep = " ";
}
@@ -1326,11 +1293,9 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(
{
const char* comma = "";
std::string currentBinDir = this->GetCurrentBinaryDirectory();
- for (std::vector<std::string>::const_iterator d = dirs.begin();
- d != dirs.end(); ++d) {
+ for (std::string dir : dirs) {
// Remove any trailing slash and skip empty paths.
- std::string dir = *d;
- if (dir[dir.size() - 1] == '/') {
+ if (dir.back() == '/') {
dir = dir.substr(0, dir.size() - 1);
}
if (dir.empty()) {
@@ -1340,7 +1305,7 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(
// Switch to a relative path specification if it is shorter.
if (cmSystemTools::FileIsFullPath(dir.c_str())) {
std::string rel =
- this->ConvertToRelativePath(currentBinDir, dir.c_str());
+ this->MaybeConvertToRelativePath(currentBinDir, dir.c_str());
if (rel.size() < dir.size()) {
dir = rel;
}
@@ -1366,13 +1331,37 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
// We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
- std::vector<cmGeneratorTarget::AllConfigSource> const& sources =
- target->GetAllConfigSources();
- std::map<cmSourceFile const*, size_t> sourcesIndex;
+ AllConfigSources sources;
+ sources.Sources = target->GetAllConfigSources();
+
+ // Add CMakeLists.txt file with rule to re-run CMake for user convenience.
+ if (target->GetType() != cmStateEnums::GLOBAL_TARGET &&
+ target->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
+ if (cmSourceFile const* sf = this->CreateVCProjBuildRule()) {
+ cmGeneratorTarget::AllConfigSource acs;
+ acs.Source = sf;
+ acs.Kind = cmGeneratorTarget::SourceKindCustomCommand;
+ for (size_t ci = 0; ci < configs.size(); ++ci) {
+ acs.Configs.push_back(ci);
+ }
+ bool haveCMakeLists = false;
+ for (cmGeneratorTarget::AllConfigSource& si : sources.Sources) {
+ if (si.Source == sf) {
+ haveCMakeLists = true;
+ // Replace the explicit source reference with our generated one.
+ si = acs;
+ break;
+ }
+ }
+ if (!haveCMakeLists) {
+ sources.Sources.emplace_back(std::move(acs));
+ }
+ }
+ }
- for (size_t si = 0; si < sources.size(); ++si) {
- cmSourceFile const* sf = sources[si].Source;
- sourcesIndex[sf] = si;
+ for (size_t si = 0; si < sources.Sources.size(); ++si) {
+ cmSourceFile const* sf = sources.Sources[si].Source;
+ sources.Index[sf] = si;
if (!sf->GetObjectLibrary().empty()) {
if (this->FortranProject) {
// Intel Fortran does not support per-config source locations
@@ -1384,7 +1373,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
// Add the file to the list of sources.
std::string const source = sf->GetFullPath();
cmSourceGroup* sourceGroup =
- this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
+ this->Makefile->FindSourceGroup(source, sourceGroups);
sourceGroup->AssignSource(sf);
}
@@ -1398,7 +1387,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
// Loop through every source group.
for (unsigned int i = 0; i < sourceGroups.size(); ++i) {
cmSourceGroup sg = sourceGroups[i];
- this->WriteGroup(&sg, target, fout, libName, configs, sourcesIndex);
+ this->WriteGroup(&sg, target, fout, libName, configs, sources);
}
fout << "\t</Files>\n";
@@ -1414,6 +1403,7 @@ struct cmLVS7GFileConfig
std::string CompileDefs;
std::string CompileDefsConfig;
std::string AdditionalDeps;
+ std::string IncludeDirs;
bool ExcludedFromBuild;
};
@@ -1440,21 +1430,54 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
// Compute per-source, per-config information.
size_t ci = 0;
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i, ++ci) {
- std::string configUpper = cmSystemTools::UpperCase(*i);
+ for (std::string const& config : configs) {
+ std::string configUpper = cmSystemTools::UpperCase(config);
cmLVS7GFileConfig fc;
+
+ std::string lang =
+ lg->GlobalGenerator->GetLanguageFromExtension(sf.GetExtension().c_str());
+ const std::string& sourceLang = lg->GetSourceFileLanguage(sf);
+ bool needForceLang = false;
+ // source file does not match its extension language
+ if (lang != sourceLang) {
+ needForceLang = true;
+ lang = sourceLang;
+ }
+
+ cmGeneratorExpressionInterpreter genexInterpreter(lg, config, gt, lang);
+
bool needfc = false;
if (!objectName.empty()) {
fc.ObjectName = objectName;
needfc = true;
}
- if (const char* cflags = sf.GetProperty("COMPILE_FLAGS")) {
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(cflags);
- fc.CompileFlags = cge->Evaluate(lg, *i);
+ const std::string COMPILE_FLAGS("COMPILE_FLAGS");
+ if (const char* cflags = sf.GetProperty(COMPILE_FLAGS)) {
+ fc.CompileFlags = genexInterpreter.Evaluate(cflags, COMPILE_FLAGS);
+ needfc = true;
+ }
+ const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
+ if (const char* coptions = sf.GetProperty(COMPILE_OPTIONS)) {
+ lg->AppendCompileOptions(
+ fc.CompileFlags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS));
needfc = true;
}
+ // Add precompile headers compile options.
+ const std::string pchSource = gt->GetPchSource(config, lang);
+ if (!pchSource.empty() && !sf.GetProperty("SKIP_PRECOMPILE_HEADERS")) {
+ std::string pchOptions;
+ if (sf.GetFullPath() == pchSource) {
+ pchOptions = gt->GetPchCreateCompileOptions(config, lang);
+ } else {
+ pchOptions = gt->GetPchUseCompileOptions(config, lang);
+ }
+
+ lg->AppendCompileOptions(
+ fc.CompileFlags,
+ genexInterpreter.Evaluate(pchOptions, COMPILE_OPTIONS));
+ needfc = true;
+ }
+
if (lg->FortranProject) {
switch (cmOutputConverter::GetFortranFormat(
sf.GetProperty("Fortran_FORMAT"))) {
@@ -1470,21 +1493,27 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
break;
}
}
- if (const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) {
- fc.CompileDefs = cdefs;
+ const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
+ if (const char* cdefs = sf.GetProperty(COMPILE_DEFINITIONS)) {
+ fc.CompileDefs = genexInterpreter.Evaluate(cdefs, COMPILE_DEFINITIONS);
+ needfc = true;
+ }
+ std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper);
+ if (const char* ccdefs = sf.GetProperty(defPropName)) {
+ fc.CompileDefsConfig =
+ genexInterpreter.Evaluate(ccdefs, COMPILE_DEFINITIONS);
needfc = true;
}
- std::string defPropName = "COMPILE_DEFINITIONS_";
- defPropName += configUpper;
- if (const char* ccdefs = sf.GetProperty(defPropName.c_str())) {
- fc.CompileDefsConfig = ccdefs;
+
+ const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
+ if (const char* cincs = sf.GetProperty(INCLUDE_DIRECTORIES)) {
+ fc.IncludeDirs = genexInterpreter.Evaluate(cincs, INCLUDE_DIRECTORIES);
needfc = true;
}
// Check for extra object-file dependencies.
if (const char* deps = sf.GetProperty("OBJECT_DEPENDS")) {
- std::vector<std::string> depends;
- cmSystemTools::ExpandListArgument(deps, depends);
+ std::vector<std::string> depends = cmExpandedList(deps);
const char* sep = "";
for (std::vector<std::string>::iterator j = depends.begin();
j != depends.end(); ++j) {
@@ -1495,21 +1524,14 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
}
}
- std::string lang =
- lg->GlobalGenerator->GetLanguageFromExtension(sf.GetExtension().c_str());
- const std::string& sourceLang = lg->GetSourceFileLanguage(sf);
- const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str());
- bool needForceLang = false;
- // source file does not match its extension language
- if (lang != sourceLang) {
- needForceLang = true;
- lang = sourceLang;
- }
+ const std::string& linkLanguage = gt->GetLinkerLanguage(config.c_str());
// If HEADER_FILE_ONLY is set, we must suppress this generation in
// the project file
fc.ExcludedFromBuild = sf.GetPropertyAsBool("HEADER_FILE_ONLY") ||
- std::find(acs.Configs.begin(), acs.Configs.end(), ci) ==
- acs.Configs.end();
+ !cmContains(acs.Configs, ci) ||
+ (gt->GetPropertyAsBool("UNITY_BUILD") &&
+ sf.GetProperty("UNITY_SOURCE_FILE") &&
+ !sf.GetPropertyAsBool("SKIP_UNITY_BUILD_INCLUSION"));
if (fc.ExcludedFromBuild) {
needfc = true;
}
@@ -1529,8 +1551,9 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
}
if (needfc) {
- this->FileConfigMap[*i] = fc;
+ this->FileConfigMap[config] = fc;
}
+ ++ci;
}
}
@@ -1552,20 +1575,16 @@ std::string cmLocalVisualStudio7Generator::ComputeLongestObjectDirectory(
// Compute the maximum length full path to the intermediate
// files directory for any configuration. This is used to construct
// object file names that do not produce paths that are too long.
- std::string dir_max;
- dir_max += this->GetCurrentBinaryDirectory();
- dir_max += "/";
- dir_max += this->GetTargetDirectory(target);
- dir_max += "/";
- dir_max += config_max;
- dir_max += "/";
+ std::string dir_max =
+ cmStrCat(this->GetCurrentBinaryDirectory(), '/',
+ this->GetTargetDirectory(target), '/', config_max, '/');
return dir_max;
}
bool cmLocalVisualStudio7Generator::WriteGroup(
const cmSourceGroup* sg, cmGeneratorTarget* target, std::ostream& fout,
const std::string& libName, std::vector<std::string> const& configs,
- std::map<cmSourceFile const*, size_t> const& sourcesIndex)
+ AllConfigSources const& sources)
{
cmGlobalVisualStudio7Generator* gg =
static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
@@ -1577,7 +1596,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
std::ostringstream tmpOut;
for (unsigned int i = 0; i < children.size(); ++i) {
if (this->WriteGroup(&children[i], target, tmpOut, libName, configs,
- sourcesIndex)) {
+ sources)) {
hasChildrenWithSources = true;
}
}
@@ -1588,28 +1607,24 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
}
// If the group has a name, write the header.
- std::string name = sg->GetName();
- if (name != "") {
+ std::string const& name = sg->GetName();
+ if (!name.empty()) {
this->WriteVCProjBeginGroup(fout, name.c_str(), "");
}
- std::vector<cmGeneratorTarget::AllConfigSource> const& sources =
- target->GetAllConfigSources();
-
// Loop through each source in the source group.
- for (std::vector<const cmSourceFile*>::const_iterator sf =
- sourceFiles.begin();
- sf != sourceFiles.end(); ++sf) {
- std::string source = (*sf)->GetFullPath();
+ for (const cmSourceFile* sf : sourceFiles) {
+ std::string source = sf->GetFullPath();
if (source != libName || target->GetType() == cmStateEnums::UTILITY ||
target->GetType() == cmStateEnums::GLOBAL_TARGET) {
// Look up the source kind and configs.
std::map<cmSourceFile const*, size_t>::const_iterator map_it =
- sourcesIndex.find(*sf);
+ sources.Index.find(sf);
// The map entry must exist because we populated it earlier.
- assert(map_it != sourcesIndex.end());
- cmGeneratorTarget::AllConfigSource const& acs = sources[map_it->second];
+ assert(map_it != sources.Index.end());
+ cmGeneratorTarget::AllConfigSource const& acs =
+ sources.Sources[map_it->second];
FCInfo fcinfo(this, target, acs, configs);
@@ -1618,16 +1633,16 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
// Tell MS-Dev what the source is. If the compiler knows how to
// build it, then it will.
fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
- if (cmCustomCommand const* command = (*sf)->GetCustomCommand()) {
+ if (cmCustomCommand const* command = sf->GetCustomCommand()) {
this->WriteCustomRule(fout, configs, source.c_str(), *command, fcinfo);
} else if (!fcinfo.FileConfigMap.empty()) {
const char* aCompilerTool = "VCCLCompilerTool";
- const char* ppLang = "CXX";
+ std::string ppLang = "CXX";
if (this->FortranProject) {
aCompilerTool = "VFFortranCompilerTool";
}
- std::string const& lang = (*sf)->GetLanguage();
- std::string ext = (*sf)->GetExtension();
+ std::string const& lang = sf->GetLanguage();
+ std::string ext = sf->GetExtension();
ext = cmSystemTools::LowerCase(ext);
if (ext == "idl") {
aCompilerTool = "VCMIDLTool";
@@ -1655,12 +1670,10 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
if (acs.Kind == cmGeneratorTarget::SourceKindExternalObject) {
aCompilerTool = "VCCustomBuildTool";
}
- for (std::map<std::string, cmLVS7GFileConfig>::const_iterator fci =
- fcinfo.FileConfigMap.begin();
- fci != fcinfo.FileConfigMap.end(); ++fci) {
- cmLVS7GFileConfig const& fc = fci->second;
+ for (auto const& fci : fcinfo.FileConfigMap) {
+ cmLVS7GFileConfig const& fc = fci.second;
fout << "\t\t\t\t<FileConfiguration\n"
- << "\t\t\t\t\tName=\"" << fci->first << "|"
+ << "\t\t\t\t\tName=\"" << fci.first << "|"
<< gg->GetPlatformName() << "\"";
if (fc.ExcludedFromBuild) {
fout << " ExcludedFromBuild=\"true\"";
@@ -1669,7 +1682,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
fout << "\t\t\t\t\t<Tool\n"
<< "\t\t\t\t\tName=\"" << aCompilerTool << "\"\n";
if (!fc.CompileFlags.empty() || !fc.CompileDefs.empty() ||
- !fc.CompileDefsConfig.empty()) {
+ !fc.CompileDefsConfig.empty() || !fc.IncludeDirs.empty()) {
Options::Tool tool = Options::Compiler;
cmVS7FlagTable const* table =
cmLocalVisualStudio7GeneratorFlagTable;
@@ -1678,12 +1691,18 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
table = cmLocalVisualStudio7GeneratorFortranFlagTable;
}
Options fileOptions(this, tool, table, gg->ExtraFlagTable);
- fileOptions.Parse(fc.CompileFlags.c_str());
- fileOptions.AddDefines(fc.CompileDefs.c_str());
- fileOptions.AddDefines(fc.CompileDefsConfig.c_str());
- fileOptions.OutputFlagMap(fout, "\t\t\t\t\t");
- fileOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t\t", "\n",
- ppLang);
+ fileOptions.Parse(fc.CompileFlags);
+ fileOptions.AddDefines(fc.CompileDefs);
+ fileOptions.AddDefines(fc.CompileDefsConfig);
+ // validate source level include directories
+ std::vector<std::string> includes;
+ this->AppendIncludeDirectories(includes, fc.IncludeDirs, *sf);
+ fileOptions.AddIncludes(includes);
+ fileOptions.OutputFlagMap(fout, 5);
+ fileOptions.OutputAdditionalIncludeDirectories(
+ fout, 5,
+ ppLang == "CXX" && this->FortranProject ? "Fortran" : ppLang);
+ fileOptions.OutputPreprocessorDefinitions(fout, 5, ppLang);
}
if (!fc.AdditionalDeps.empty()) {
fout << "\t\t\t\t\tAdditionalDependencies=\"" << fc.AdditionalDeps
@@ -1707,7 +1726,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
}
// If the group has a name, write the footer.
- if (name != "") {
+ if (!name.empty()) {
this->WriteVCProjEndGroup(fout);
}
@@ -1730,12 +1749,11 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
if (this->FortranProject) {
customTool = "VFCustomBuildTool";
}
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
- cmCustomCommandGenerator ccg(command, *i, this);
- cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i];
+ for (std::string const& config : configs) {
+ cmCustomCommandGenerator ccg(command, config, this);
+ cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[config];
fout << "\t\t\t\t<FileConfiguration\n";
- fout << "\t\t\t\t\tName=\"" << *i << "|" << gg->GetPlatformName()
+ fout << "\t\t\t\t\tName=\"" << config << "|" << gg->GetPlatformName()
<< "\">\n";
if (!fc.CompileFlags.empty()) {
fout << "\t\t\t\t\t<Tool\n"
@@ -1747,7 +1765,7 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
std::string comment = this->ConstructComment(ccg);
std::string script = this->ConstructScript(ccg);
if (this->FortranProject) {
- cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str());
+ cmSystemTools::ReplaceString(script, "$(Configuration)", config.c_str());
}
/* clang-format off */
fout << "\t\t\t\t\t<Tool\n"
@@ -1768,12 +1786,10 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
fout << this->ConvertToXMLOutputPath(source);
} else {
// Write out the dependencies for the rule.
- for (std::vector<std::string>::const_iterator d =
- ccg.GetDepends().begin();
- d != ccg.GetDepends().end(); ++d) {
+ for (std::string const& d : ccg.GetDepends()) {
// Get the real name of the dependency in case it is a CMake target.
std::string dep;
- if (this->GetRealDependency(d->c_str(), i->c_str(), dep)) {
+ if (this->GetRealDependency(d.c_str(), config.c_str(), dep)) {
fout << this->ConvertToXMLOutputPath(dep.c_str()) << ";";
}
}
@@ -1785,10 +1801,8 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
} else {
// Write a rule for the output generated by this command.
const char* sep = "";
- for (std::vector<std::string>::const_iterator o =
- ccg.GetOutputs().begin();
- o != ccg.GetOutputs().end(); ++o) {
- fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str());
+ for (std::string const& output : ccg.GetOutputs()) {
+ fout << sep << this->ConvertToXMLOutputPathSingle(output.c_str());
sep = ";";
}
}
@@ -1847,7 +1861,7 @@ void cmLocalVisualStudio7Generator::OutputTargetRules(
if (!addedPrelink) {
event.Write(target->GetPreLinkCommands());
}
- CM_AUTO_PTR<cmCustomCommand> pcc(
+ std::unique_ptr<cmCustomCommand> pcc(
this->MaybeCreateImplibDir(target, configName, this->FortranProject));
if (pcc.get()) {
event.Write(*pcc);
@@ -1999,16 +2013,14 @@ void cmLocalVisualStudio7Generator::WriteVCProjFooter(
{
fout << "\t<Globals>\n";
- std::vector<std::string> const& props = target->GetPropertyKeys();
- for (std::vector<std::string>::const_iterator i = props.begin();
- i != props.end(); ++i) {
- if (i->find("VS_GLOBAL_") == 0) {
- std::string name = i->substr(10);
- if (name != "") {
+ for (std::string const& key : target->GetPropertyKeys()) {
+ if (key.find("VS_GLOBAL_") == 0) {
+ std::string name = key.substr(10);
+ if (!name.empty()) {
/* clang-format off */
fout << "\t\t<Global\n"
<< "\t\t\tName=\"" << name << "\"\n"
- << "\t\t\tValue=\"" << target->GetProperty(*i) << "\"\n"
+ << "\t\t\tValue=\"" << target->GetProperty(key) << "\"\n"
<< "\t\t/>\n";
/* clang-format on */
}
@@ -2019,17 +2031,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFooter(
<< "</VisualStudioProject>\n";
}
-std::string cmLocalVisualStudio7GeneratorEscapeForXML(const std::string& s)
-{
- std::string ret = s;
- cmSystemTools::ReplaceString(ret, "&", "&amp;");
- cmSystemTools::ReplaceString(ret, "\"", "&quot;");
- cmSystemTools::ReplaceString(ret, "<", "&lt;");
- cmSystemTools::ReplaceString(ret, ">", "&gt;");
- cmSystemTools::ReplaceString(ret, "\n", "&#x0D;&#x0A;");
- return ret;
-}
-
std::string cmLocalVisualStudio7Generator::EscapeForXML(const std::string& s)
{
return cmLocalVisualStudio7GeneratorEscapeForXML(s);
@@ -2059,6 +2060,19 @@ std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPathSingle(
return ret;
}
+void cmVS7GeneratorOptions::OutputFlag(std::ostream& fout, int indent,
+ const char* flag,
+ const std::string& content)
+{
+ fout.fill('\t');
+ fout.width(indent);
+ // write an empty string to get the fill level indent to print
+ fout << "";
+ fout << flag << "=\"";
+ fout << cmLocalVisualStudio7GeneratorEscapeForXML(content);
+ fout << "\"\n";
+}
+
// This class is used to parse an existing vs 7 project
// and extract the GUID
class cmVS7XMLParser : public cmXMLParser
@@ -2077,9 +2091,12 @@ public:
if (strcmp(atts[i], "ProjectGUID") == 0) {
if (atts[i + 1]) {
this->GUID = atts[i + 1];
- this->GUID = this->GUID.substr(1, this->GUID.size() - 2);
+ if (this->GUID[0] == '{') {
+ // remove surrounding curly brackets
+ this->GUID = this->GUID.substr(1, this->GUID.size() - 2);
+ }
} else {
- this->GUID = "";
+ this->GUID.clear();
}
return;
}
@@ -2110,8 +2127,7 @@ void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID(
if (parser.GUID.empty()) {
return;
}
- std::string guidStoreName = name;
- guidStoreName += "_GUID_CMAKE";
+ std::string guidStoreName = cmStrCat(name, "_GUID_CMAKE");
// save the GUID in the cache
this->GlobalGenerator->GetCMakeInstance()->AddCacheEntry(
guidStoreName.c_str(), parser.GUID.c_str(), "Stored GUID",
@@ -2121,9 +2137,7 @@ void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID(
std::string cmLocalVisualStudio7Generator::GetTargetDirectory(
cmGeneratorTarget const* target) const
{
- std::string dir;
- dir += target->GetName();
- dir += ".dir";
+ std::string dir = cmStrCat(target->GetName(), ".dir");
return dir;
}
diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h
index 89a3ee353..671783fa5 100644
--- a/Source/cmLocalVisualStudio7Generator.h
+++ b/Source/cmLocalVisualStudio7Generator.h
@@ -3,7 +3,7 @@
#ifndef cmLocalVisualStudio7Generator_h
#define cmLocalVisualStudio7Generator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
@@ -21,6 +21,19 @@ class cmMakefile;
class cmSourceFile;
class cmSourceGroup;
+class cmVS7GeneratorOptions : public cmVisualStudioGeneratorOptions
+{
+public:
+ cmVS7GeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
+ cmVS7FlagTable const* table = nullptr,
+ cmVS7FlagTable const* extraTable = nullptr)
+ : cmVisualStudioGeneratorOptions(lg, tool, table, extraTable)
+ {
+ }
+ void OutputFlag(std::ostream& fout, int indent, const char* tag,
+ const std::string& content) override;
+};
+
/** \class cmLocalVisualStudio7Generator
* \brief Write Visual Studio .NET project files.
*
@@ -30,17 +43,17 @@ class cmSourceGroup;
class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
{
public:
- ///! Set cache only and recurse to false by default.
+ //! Set cache only and recurse to false by default.
cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf);
virtual ~cmLocalVisualStudio7Generator();
- virtual void AddHelperCommands();
+ void AddHelperCommands() override;
/**
* Generate the makefile for this directory.
*/
- virtual void Generate();
+ void Generate() override;
enum BuildType
{
@@ -56,23 +69,22 @@ public:
*/
void SetBuildType(BuildType, const std::string& name);
- virtual std::string GetTargetDirectory(
- cmGeneratorTarget const* target) const;
+ std::string GetTargetDirectory(
+ cmGeneratorTarget const* target) const override;
cmSourceFile* CreateVCProjBuildRule();
void WriteStampFiles();
- virtual std::string ComputeLongestObjectDirectory(
- cmGeneratorTarget const*) const;
+ std::string ComputeLongestObjectDirectory(
+ cmGeneratorTarget const*) const override;
virtual void ReadAndStoreExternalGUID(const std::string& name,
const char* path);
- virtual void AddCMakeListsRules();
protected:
void CreateSingleVCProj(const std::string& lname, cmGeneratorTarget* tgt);
private:
- typedef cmVisualStudioGeneratorOptions Options;
- typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo;
+ using Options = cmVS7GeneratorOptions;
+ using FCInfo = cmLocalVisualStudio7GeneratorFCInfo;
std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
const std::string& configName);
void FixGlobalTargets();
@@ -117,10 +129,11 @@ private:
FCInfo& fcinfo);
void WriteTargetVersionAttribute(std::ostream& fout, cmGeneratorTarget* gt);
+ class AllConfigSources;
bool WriteGroup(const cmSourceGroup* sg, cmGeneratorTarget* target,
std::ostream& fout, const std::string& libName,
std::vector<std::string> const& configs,
- std::map<cmSourceFile const*, size_t> const& sourcesIndex);
+ AllConfigSources const& sources);
friend class cmLocalVisualStudio7GeneratorFCInfo;
friend class cmLocalVisualStudio7GeneratorInternals;
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index 41025af6c..336e3a5a1 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -2,13 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLocalVisualStudioGenerator.h"
+#include "windows.h"
+
+#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmSystemTools.h"
-#include "windows.h"
cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator(
cmGlobalGenerator* gg, cmMakefile* mf)
@@ -39,10 +41,8 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
// windows file names are not case sensitive.
std::map<std::string, int> counts;
- for (std::map<cmSourceFile const*, std::string>::iterator si =
- mapping.begin();
- si != mapping.end(); ++si) {
- cmSourceFile const* sf = si->first;
+ for (auto const& si : mapping) {
+ cmSourceFile const* sf = si.first;
std::string objectNameLower = cmSystemTools::LowerCase(
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
if (custom_ext) {
@@ -57,10 +57,8 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
// For all source files producing duplicate names we need unique
// object name computation.
- for (std::map<cmSourceFile const*, std::string>::iterator si =
- mapping.begin();
- si != mapping.end(); ++si) {
- cmSourceFile const* sf = si->first;
+ for (auto& si : mapping) {
+ cmSourceFile const* sf = si.first;
std::string objectName =
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
if (custom_ext) {
@@ -74,16 +72,16 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
objectName = this->GetObjectFileNameWithoutTarget(
*sf, dir_max, &keptSourceExtension, custom_ext);
}
- si->second = objectName;
+ si.second = objectName;
}
}
-CM_AUTO_PTR<cmCustomCommand>
+std::unique_ptr<cmCustomCommand>
cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
const std::string& config,
bool isFortran)
{
- CM_AUTO_PTR<cmCustomCommand> pcc;
+ std::unique_ptr<cmCustomCommand> pcc;
// If an executable exports symbols then VS wants to create an
// import library but forgets to create the output directory.
@@ -101,16 +99,11 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
}
// Add a pre-build event to create the directory.
- cmCustomCommandLine command;
- command.push_back(cmSystemTools::GetCMakeCommand());
- command.push_back("-E");
- command.push_back("make_directory");
- command.push_back(impDir);
std::vector<std::string> no_output;
std::vector<std::string> no_byproducts;
std::vector<std::string> no_depends;
- cmCustomCommandLines commands;
- commands.push_back(command);
+ cmCustomCommandLines commands = cmMakeSingleCommandLine(
+ { cmSystemTools::GetCMakeCommand(), "-E", "make_directory", impDir });
pcc.reset(new cmCustomCommand(0, no_output, no_byproducts, no_depends,
commands, 0, 0));
pcc->SetEscapeOldStyle(false);
@@ -135,7 +128,7 @@ std::string cmLocalVisualStudioGenerator::ConstructScript(
std::string workingDirectory = ccg.GetWorkingDirectory();
// Avoid leading or trailing newlines.
- std::string newline = "";
+ std::string newline;
// Line to check for error between commands.
std::string check_error = newline_text;
@@ -191,13 +184,17 @@ std::string cmLocalVisualStudioGenerator::ConstructScript(
// Write each command on a single line.
for (unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) {
+ // Add this command line.
+ std::string cmd = ccg.GetCommand(c);
+
+ if (cmd.empty()) {
+ continue;
+ }
+
// Start a new line.
script += newline;
newline = newline_text;
- // Add this command line.
- std::string cmd = ccg.GetCommand(c);
-
// Use "call " before any invocations of .bat or .cmd files
// invoked as custom commands.
//
@@ -210,9 +207,10 @@ std::string cmLocalVisualStudioGenerator::ConstructScript(
}
if (workingDirectory.empty()) {
- script += this->ConvertToOutputFormat(
- this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), cmd),
- cmOutputConverter::SHELL);
+ script +=
+ this->ConvertToOutputFormat(this->MaybeConvertToRelativePath(
+ this->GetCurrentBinaryDirectory(), cmd),
+ cmOutputConverter::SHELL);
} else {
script += this->ConvertToOutputFormat(cmd.c_str(), SHELL);
}
diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h
index 85fb8a511..585eb3c33 100644
--- a/Source/cmLocalVisualStudioGenerator.h
+++ b/Source/cmLocalVisualStudioGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmLocalVisualStudioGenerator_h
#define cmLocalVisualStudioGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
#include <memory>
@@ -11,7 +11,6 @@
#include "cmGlobalVisualStudioGenerator.h"
#include "cmLocalGenerator.h"
-#include "cm_auto_ptr.hxx"
class cmCustomCommand;
class cmCustomCommandGenerator;
@@ -45,20 +44,17 @@ public:
virtual std::string ComputeLongestObjectDirectory(
cmGeneratorTarget const*) const = 0;
- virtual void AddCMakeListsRules() = 0;
-
- virtual void ComputeObjectFilenames(
+ void ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping,
- cmGeneratorTarget const* = 0);
+ cmGeneratorTarget const* = 0) override;
protected:
virtual const char* ReportErrorLabel() const;
virtual bool CustomCommandUseLocal() const { return false; }
/** Construct a custom command to make exe import lib dir. */
- CM_AUTO_PTR<cmCustomCommand> MaybeCreateImplibDir(cmGeneratorTarget* target,
- const std::string& config,
- bool isFortran);
+ std::unique_ptr<cmCustomCommand> MaybeCreateImplibDir(
+ cmGeneratorTarget* target, const std::string& config, bool isFortran);
};
#endif
diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx
index 739ef4367..5a06d4a53 100644
--- a/Source/cmLocalXCodeGenerator.cxx
+++ b/Source/cmLocalXCodeGenerator.cxx
@@ -19,9 +19,7 @@ cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg,
this->EmitUniversalBinaryFlags = false;
}
-cmLocalXCodeGenerator::~cmLocalXCodeGenerator()
-{
-}
+cmLocalXCodeGenerator::~cmLocalXCodeGenerator() = default;
std::string cmLocalXCodeGenerator::GetTargetDirectory(
cmGeneratorTarget const*) const
@@ -31,10 +29,10 @@ std::string cmLocalXCodeGenerator::GetTargetDirectory(
}
void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags,
- const std::string& rawFlag)
+ const std::string& rawFlag) const
{
- cmGlobalXCodeGenerator* gg =
- static_cast<cmGlobalXCodeGenerator*>(this->GlobalGenerator);
+ const cmGlobalXCodeGenerator* gg =
+ static_cast<const cmGlobalXCodeGenerator*>(this->GlobalGenerator);
gg->AppendFlag(flags, rawFlag);
}
@@ -42,10 +40,8 @@ void cmLocalXCodeGenerator::Generate()
{
cmLocalGenerator::Generate();
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator iter = targets.begin();
- iter != targets.end(); ++iter) {
- (*iter)->HasMacOSXRpathInstallNameDir("");
+ for (auto target : this->GetGeneratorTargets()) {
+ target->HasMacOSXRpathInstallNameDir("");
}
}
@@ -53,10 +49,8 @@ void cmLocalXCodeGenerator::GenerateInstallRules()
{
cmLocalGenerator::GenerateInstallRules();
- std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::iterator iter = targets.begin();
- iter != targets.end(); ++iter) {
- (*iter)->HasMacOSXRpathInstallNameDir("");
+ for (auto target : this->GetGeneratorTargets()) {
+ target->HasMacOSXRpathInstallNameDir("");
}
}
@@ -69,19 +63,16 @@ void cmLocalXCodeGenerator::ComputeObjectFilenames(
// to avoid exact duplicate file names. Note that Mac file names are not
// typically case sensitive, hence the LowerCase.
std::map<std::string, int> counts;
- for (std::map<cmSourceFile const*, std::string>::iterator si =
- mapping.begin();
- si != mapping.end(); ++si) {
- cmSourceFile const* sf = si->first;
- std::string objectName =
- cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
- objectName += ".o";
+ for (auto& si : mapping) {
+ cmSourceFile const* sf = si.first;
+ std::string objectName = cmStrCat(
+ cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()), ".o");
std::string objectNameLower = cmSystemTools::LowerCase(objectName);
counts[objectNameLower] += 1;
if (2 == counts[objectNameLower]) {
// TODO: emit warning about duplicate name?
}
- si->second = objectName;
+ si.second = objectName;
}
}
diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h
index 4ca02a9d0..42de20b47 100644
--- a/Source/cmLocalXCodeGenerator.h
+++ b/Source/cmLocalXCodeGenerator.h
@@ -24,19 +24,19 @@ class cmSourceFile;
class cmLocalXCodeGenerator : public cmLocalGenerator
{
public:
- ///! Set cache only and recurse to false by default.
+ //! Set cache only and recurse to false by default.
cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
- virtual ~cmLocalXCodeGenerator();
- virtual std::string GetTargetDirectory(
- cmGeneratorTarget const* target) const;
- virtual void AppendFlagEscape(std::string& flags,
- const std::string& rawFlag);
- virtual void Generate();
+ ~cmLocalXCodeGenerator() override;
+ std::string GetTargetDirectory(
+ cmGeneratorTarget const* target) const override;
+ void AppendFlagEscape(std::string& flags,
+ const std::string& rawFlag) const override;
+ void Generate() override;
virtual void GenerateInstallRules();
- virtual void ComputeObjectFilenames(
+ void ComputeObjectFilenames(
std::map<cmSourceFile const*, std::string>& mapping,
- cmGeneratorTarget const* gt = 0);
+ cmGeneratorTarget const* gt = nullptr) override;
private:
};
diff --git a/Source/cmLocale.h b/Source/cmLocale.h
index 9f90a3a99..c44a42db7 100644
--- a/Source/cmLocale.h
+++ b/Source/cmLocale.h
@@ -3,23 +3,25 @@
#ifndef cmLocale_h
#define cmLocale_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include <locale.h>
+#include <clocale>
#include <string>
class cmLocaleRAII
{
- CM_DISABLE_COPY(cmLocaleRAII)
-
public:
cmLocaleRAII()
- : OldLocale(setlocale(LC_CTYPE, CM_NULLPTR))
+ : OldLocale(setlocale(LC_CTYPE, nullptr))
{
setlocale(LC_CTYPE, "");
}
+
~cmLocaleRAII() { setlocale(LC_CTYPE, this->OldLocale.c_str()); }
+ cmLocaleRAII(cmLocaleRAII const&) = delete;
+ cmLocaleRAII& operator=(cmLocaleRAII const&) = delete;
+
private:
std::string OldLocale;
};
diff --git a/Source/cmMSVC60LinkLineComputer.cxx b/Source/cmMSVC60LinkLineComputer.cxx
index 5298d1a79..74c94351c 100644
--- a/Source/cmMSVC60LinkLineComputer.cxx
+++ b/Source/cmMSVC60LinkLineComputer.cxx
@@ -4,7 +4,7 @@
#include "cmMSVC60LinkLineComputer.h"
#if defined(_WIN32) && !defined(__CYGWIN__)
-#include "cmSystemTools.h"
+# include "cmSystemTools.h"
#endif
class cmOutputConverter;
diff --git a/Source/cmMSVC60LinkLineComputer.h b/Source/cmMSVC60LinkLineComputer.h
index f2892d53f..d767914b9 100644
--- a/Source/cmMSVC60LinkLineComputer.h
+++ b/Source/cmMSVC60LinkLineComputer.h
@@ -4,7 +4,7 @@
#ifndef cmMSVC60LinkLineComputer_h
#define cmMSVC60LinkLineComputer_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
@@ -15,14 +15,15 @@ class cmStateDirectory;
class cmMSVC60LinkLineComputer : public cmLinkLineComputer
{
- CM_DISABLE_COPY(cmMSVC60LinkLineComputer)
-
public:
cmMSVC60LinkLineComputer(cmOutputConverter* outputConverter,
cmStateDirectory const& stateDir);
- std::string ConvertToLinkReference(std::string const& input) const
- CM_OVERRIDE;
+ cmMSVC60LinkLineComputer(cmMSVC60LinkLineComputer const&) = delete;
+ cmMSVC60LinkLineComputer& operator=(cmMSVC60LinkLineComputer const&) =
+ delete;
+
+ std::string ConvertToLinkReference(std::string const& input) const override;
};
#endif
diff --git a/Source/cmMachO.cxx b/Source/cmMachO.cxx
index a4350f7ce..6cbed36d9 100644
--- a/Source/cmMachO.cxx
+++ b/Source/cmMachO.cxx
@@ -2,12 +2,16 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMachO.h"
-#include "cmsys/FStream.hxx"
-#include <algorithm>
-#include <stddef.h>
+#include <cstddef>
#include <string>
#include <vector>
+#include <cm/memory>
+
+#include "cmsys/FStream.hxx"
+
+#include "cmAlgorithms.h"
+
// Include the Mach-O format information system header.
#include <mach-o/fat.h>
#include <mach-o/loader.h>
@@ -52,10 +56,7 @@ bool peek(cmsys::ifstream& fin, T& v)
template <typename T>
bool read(cmsys::ifstream& fin, T& v)
{
- if (!fin.read(reinterpret_cast<char*>(&v), sizeof(T))) {
- return false;
- }
- return true;
+ return !!fin.read(reinterpret_cast<char*>(&v), sizeof(T));
}
// read from the file and fill multiple data structures where
@@ -67,10 +68,7 @@ bool read(cmsys::ifstream& fin, std::vector<T>& v)
if (v.empty()) {
return true;
}
- if (!fin.read(reinterpret_cast<char*>(&v[0]), sizeof(T) * v.size())) {
- return false;
- }
- return true;
+ return !!fin.read(reinterpret_cast<char*>(&v[0]), sizeof(T) * v.size());
}
}
@@ -97,7 +95,7 @@ public:
: Swap(_swap)
{
}
- virtual ~cmMachOHeaderAndLoadCommands() {}
+ virtual ~cmMachOHeaderAndLoadCommands() = default;
virtual bool read_mach_o(cmsys::ifstream& fin) = 0;
@@ -126,7 +124,7 @@ protected:
// Implementation for reading Mach-O header and load commands.
// This is 32 or 64 bit arch specific.
-template <class T>
+template <typename T>
class cmMachOHeaderAndLoadCommandsImpl : public cmMachOHeaderAndLoadCommands
{
public:
@@ -134,7 +132,7 @@ public:
: cmMachOHeaderAndLoadCommands(_swap)
{
}
- bool read_mach_o(cmsys::ifstream& fin)
+ bool read_mach_o(cmsys::ifstream& fin) override
{
if (!read(fin, this->Header)) {
return false;
@@ -251,8 +249,7 @@ cmMachOInternal::cmMachOInternal(const char* fname)
}
// parse each Mach-O file
- for (size_t i = 0; i < this->FatArchs.size(); i++) {
- const fat_arch& arch = this->FatArchs[i];
+ for (const auto& arch : this->FatArchs) {
if (!this->read_mach_o(OSSwapBigToHostInt32(arch.offset))) {
return;
}
@@ -265,8 +262,8 @@ cmMachOInternal::cmMachOInternal(const char* fname)
cmMachOInternal::~cmMachOInternal()
{
- for (size_t i = 0; i < this->MachOList.size(); i++) {
- delete this->MachOList[i];
+ for (auto& i : this->MachOList) {
+ delete i;
}
}
@@ -283,7 +280,7 @@ bool cmMachOInternal::read_mach_o(uint32_t file_offset)
return false;
}
- cmMachOHeaderAndLoadCommands* f = NULL;
+ cmMachOHeaderAndLoadCommands* f = nullptr;
if (magic == MH_CIGAM || magic == MH_MAGIC) {
bool swap = false;
if (magic == MH_CIGAM) {
@@ -313,15 +310,11 @@ bool cmMachOInternal::read_mach_o(uint32_t file_offset)
// External class implementation.
cmMachO::cmMachO(const char* fname)
- : Internal(0)
+ : Internal(cm::make_unique<cmMachOInternal>(fname))
{
- this->Internal = new cmMachOInternal(fname);
}
-cmMachO::~cmMachO()
-{
- delete this->Internal;
-}
+cmMachO::~cmMachO() = default;
std::string const& cmMachO::GetErrorMessage() const
{
diff --git a/Source/cmMachO.h b/Source/cmMachO.h
index 42745cf60..0c44b5564 100644
--- a/Source/cmMachO.h
+++ b/Source/cmMachO.h
@@ -3,13 +3,13 @@
#ifndef cmMachO_h
#define cmMachO_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
#if !defined(CMAKE_USE_MACH_PARSER)
-#error "This file may be included only if CMAKE_USE_MACH_PARSER is enabled."
+# error "This file may be included only if CMAKE_USE_MACH_PARSER is enabled."
#endif
class cmMachOInternal;
@@ -30,7 +30,7 @@ public:
std::string const& GetErrorMessage() const;
/** Boolean conversion. True if the Mach-O file is valid. */
- operator bool() const { return this->Valid(); }
+ explicit operator bool() const { return this->Valid(); }
/** Get Install name from binary **/
bool GetInstallName(std::string& install_name);
@@ -41,7 +41,7 @@ public:
private:
friend class cmMachOInternal;
bool Valid() const;
- cmMachOInternal* Internal;
+ std::unique_ptr<cmMachOInternal> Internal;
};
#endif
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index a6a9ea316..ba9947a33 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -2,51 +2,37 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMacroCommand.h"
-#include <sstream>
-#include <stdio.h>
+#include <cstdio>
+#include <utility>
+
+#include <cm/memory>
+#include <cm/string_view>
+
+#include "cm_static_string_view.hxx"
#include "cmAlgorithms.h"
#include "cmExecutionStatus.h"
+#include "cmFunctionBlocker.h"
+#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmPolicies.h"
+#include "cmRange.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+namespace {
+
// define the class for macro commands
-class cmMacroHelperCommand : public cmCommand
+class cmMacroHelperCommand
{
public:
- cmMacroHelperCommand() {}
-
- ///! clean up any memory allocated by the macro
- ~cmMacroHelperCommand() CM_OVERRIDE {}
-
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE
- {
- cmMacroHelperCommand* newC = new cmMacroHelperCommand;
- // we must copy when we clone
- newC->Args = this->Args;
- newC->Functions = this->Functions;
- newC->FilePath = this->FilePath;
- newC->Policies = this->Policies;
- return newC;
- }
-
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
- bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
- cmExecutionStatus&) CM_OVERRIDE;
-
- bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&) CM_OVERRIDE
- {
- return false;
- }
+ bool operator()(std::vector<cmListFileArgument> const& args,
+ cmExecutionStatus& inStatus) const;
std::vector<std::string> Args;
std::vector<cmListFileFunction> Functions;
@@ -54,33 +40,33 @@ public:
std::string FilePath;
};
-bool cmMacroHelperCommand::InvokeInitialPass(
- const std::vector<cmListFileArgument>& args, cmExecutionStatus& inStatus)
+bool cmMacroHelperCommand::operator()(
+ std::vector<cmListFileArgument> const& args,
+ cmExecutionStatus& inStatus) const
{
+ cmMakefile& makefile = inStatus.GetMakefile();
+
// Expand the argument list to the macro.
std::vector<std::string> expandedArgs;
- this->Makefile->ExpandArguments(args, expandedArgs);
+ makefile.ExpandArguments(args, expandedArgs);
// make sure the number of arguments passed is at least the number
// required by the signature
if (expandedArgs.size() < this->Args.size() - 1) {
std::string errorMsg =
- "Macro invoked with incorrect arguments for macro named: ";
- errorMsg += this->Args[0];
- this->SetError(errorMsg);
+ cmStrCat("Macro invoked with incorrect arguments for macro named: ",
+ this->Args[0]);
+ inStatus.SetError(errorMsg);
return false;
}
- cmMakefile::MacroPushPop macroScope(this->Makefile, this->FilePath,
+ cmMakefile::MacroPushPop macroScope(&makefile, this->FilePath,
this->Policies);
// set the value of argc
- std::ostringstream argcDefStream;
- argcDefStream << expandedArgs.size();
- std::string argcDef = argcDefStream.str();
+ std::string argcDef = std::to_string(expandedArgs.size());
- std::vector<std::string>::const_iterator eit =
- expandedArgs.begin() + (this->Args.size() - 1);
+ auto eit = expandedArgs.begin() + (this->Args.size() - 1);
std::string expandedArgn = cmJoin(cmMakeRange(eit, expandedArgs.end()), ";");
std::string expandedArgv = cmJoin(expandedArgs, ";");
std::vector<std::string> variables;
@@ -92,26 +78,24 @@ bool cmMacroHelperCommand::InvokeInitialPass(
argVs.reserve(expandedArgs.size());
char argvName[60];
for (unsigned int j = 0; j < expandedArgs.size(); ++j) {
- sprintf(argvName, "${ARGV%i}", j);
- argVs.push_back(argvName);
+ sprintf(argvName, "${ARGV%u}", j);
+ argVs.emplace_back(argvName);
}
// Invoke all the functions that were collected in the block.
cmListFileFunction newLFF;
// for each function
- for (unsigned int c = 0; c < this->Functions.size(); ++c) {
+ for (cmListFileFunction const& func : this->Functions) {
// Replace the formal arguments and then invoke the command.
newLFF.Arguments.clear();
- newLFF.Arguments.reserve(this->Functions[c].Arguments.size());
- newLFF.Name = this->Functions[c].Name;
- newLFF.Line = this->Functions[c].Line;
+ newLFF.Arguments.reserve(func.Arguments.size());
+ newLFF.Name = func.Name;
+ newLFF.Line = func.Line;
// for each argument of the current function
- for (std::vector<cmListFileArgument>::iterator k =
- this->Functions[c].Arguments.begin();
- k != this->Functions[c].Arguments.end(); ++k) {
+ for (cmListFileArgument const& k : func.Arguments) {
cmListFileArgument arg;
- arg.Value = k->Value;
- if (k->Delim != cmListFileArgument::Bracket) {
+ arg.Value = k.Value;
+ if (k.Delim != cmListFileArgument::Bracket) {
// replace formal arguments
for (unsigned int j = 0; j < variables.size(); ++j) {
cmSystemTools::ReplaceString(arg.Value, variables[j],
@@ -131,13 +115,12 @@ bool cmMacroHelperCommand::InvokeInitialPass(
}
}
}
- arg.Delim = k->Delim;
- arg.Line = k->Line;
- newLFF.Arguments.push_back(arg);
+ arg.Delim = k.Delim;
+ arg.Line = k.Line;
+ newLFF.Arguments.push_back(std::move(arg));
}
- cmExecutionStatus status;
- if (!this->Makefile->ExecuteCommand(newLFF, status) ||
- status.GetNestedError()) {
+ cmExecutionStatus status(makefile);
+ if (!makefile.ExecuteCommand(newLFF, status) || status.GetNestedError()) {
// The error message should have already included the call stack
// so we do not need to report an error here.
macroScope.Quiet();
@@ -156,68 +139,59 @@ bool cmMacroHelperCommand::InvokeInitialPass(
return true;
}
-bool cmMacroFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
- cmMakefile& mf,
- cmExecutionStatus&)
+class cmMacroFunctionBlocker : public cmFunctionBlocker
{
- // record commands until we hit the ENDMACRO
- // at the ENDMACRO call we shift gears and start looking for invocations
- if (!cmSystemTools::Strucmp(lff.Name.c_str(), "macro")) {
- this->Depth++;
- } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endmacro")) {
- // if this is the endmacro for this macro then execute
- if (!this->Depth) {
- mf.AppendProperty("MACROS", this->Args[0].c_str());
- // create a new command and add it to cmake
- cmMacroHelperCommand* f = new cmMacroHelperCommand();
- f->Args = this->Args;
- f->Functions = this->Functions;
- f->FilePath = this->GetStartingContext().FilePath;
- mf.RecordPolicies(f->Policies);
- mf.GetState()->AddScriptedCommand(this->Args[0], f);
- // remove the function blocker now that the macro is defined
- mf.RemoveFunctionBlocker(this, lff);
- return true;
- }
- // decrement for each nested macro that ends
- this->Depth--;
- }
+public:
+ cm::string_view StartCommandName() const override { return "macro"_s; }
+ cm::string_view EndCommandName() const override { return "endmacro"_s; }
- // if it wasn't an endmacro and we are not executing then we must be
- // recording
- this->Functions.push_back(lff);
- return true;
-}
+ bool ArgumentsMatch(cmListFileFunction const&,
+ cmMakefile& mf) const override;
+
+ bool Replay(std::vector<cmListFileFunction> functions,
+ cmExecutionStatus& status) override;
-bool cmMacroFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
- cmMakefile& mf)
+ std::vector<std::string> Args;
+};
+
+bool cmMacroFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff,
+ cmMakefile& mf) const
{
- if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endmacro")) {
- std::vector<std::string> expandedArguments;
- mf.ExpandArguments(lff.Arguments, expandedArguments,
- this->GetStartingContext().FilePath.c_str());
- // if the endmacro has arguments make sure they
- // match the arguments of the macro
- if ((expandedArguments.empty() ||
- (expandedArguments[0] == this->Args[0]))) {
- return true;
- }
- }
+ std::vector<std::string> expandedArguments;
+ mf.ExpandArguments(lff.Arguments, expandedArguments,
+ this->GetStartingContext().FilePath.c_str());
+ return expandedArguments.empty() || expandedArguments[0] == this->Args[0];
+}
- return false;
+bool cmMacroFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
+ cmExecutionStatus& status)
+{
+ cmMakefile& mf = status.GetMakefile();
+ mf.AppendProperty("MACROS", this->Args[0].c_str());
+ // create a new command and add it to cmake
+ cmMacroHelperCommand f;
+ f.Args = this->Args;
+ f.Functions = std::move(functions);
+ f.FilePath = this->GetStartingContext().FilePath;
+ mf.RecordPolicies(f.Policies);
+ mf.GetState()->AddScriptedCommand(this->Args[0], std::move(f));
+ return true;
+}
}
-bool cmMacroCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmMacroCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
// create a function blocker
- cmMacroFunctionBlocker* f = new cmMacroFunctionBlocker();
- f->Args.insert(f->Args.end(), args.begin(), args.end());
- this->Makefile->AddFunctionBlocker(f);
+ {
+ auto fb = cm::make_unique<cmMacroFunctionBlocker>();
+ cmAppend(fb->Args, args);
+ status.GetMakefile().AddFunctionBlocker(std::move(fb));
+ }
return true;
}
diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h
index 0d35fe06e..25091eacf 100644
--- a/Source/cmMacroCommand.h
+++ b/Source/cmMacroCommand.h
@@ -3,47 +3,15 @@
#ifndef cmMacroCommand_h
#define cmMacroCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-#include "cmFunctionBlocker.h"
-#include "cmListFileCache.h"
-
class cmExecutionStatus;
-class cmMakefile;
-
-class cmMacroFunctionBlocker : public cmFunctionBlocker
-{
-public:
- cmMacroFunctionBlocker() { this->Depth = 0; }
- ~cmMacroFunctionBlocker() CM_OVERRIDE {}
- bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf,
- cmExecutionStatus&) CM_OVERRIDE;
- bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) CM_OVERRIDE;
-
- std::vector<std::string> Args;
- std::vector<cmListFileFunction> Functions;
- int Depth;
-};
/// Starts macro() ... endmacro() block
-class cmMacroCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmMacroCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmMacroCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmMakeDirectoryCommand.cxx b/Source/cmMakeDirectoryCommand.cxx
index 06e295bc0..cdde6f990 100644
--- a/Source/cmMakeDirectoryCommand.cxx
+++ b/Source/cmMakeDirectoryCommand.cxx
@@ -2,26 +2,25 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakeDirectoryCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
// cmMakeDirectoryCommand
-bool cmMakeDirectoryCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmMakeDirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 1) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- if (!this->Makefile->CanIWriteThisFile(args[0].c_str())) {
+ if (!status.GetMakefile().CanIWriteThisFile(args[0])) {
std::string e = "attempted to create a directory: " + args[0] +
" into a source directory.";
- this->SetError(e);
+ status.SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
- cmSystemTools::MakeDirectory(args[0].c_str());
+ cmSystemTools::MakeDirectory(args[0]);
return true;
}
diff --git a/Source/cmMakeDirectoryCommand.h b/Source/cmMakeDirectoryCommand.h
index af72eab96..2474383bb 100644
--- a/Source/cmMakeDirectoryCommand.h
+++ b/Source/cmMakeDirectoryCommand.h
@@ -3,16 +3,14 @@
#ifndef cmMakeDirectoryCommand_h
#define cmMakeDirectoryCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmMakeDirectoryCommand
+/**
* \brief Specify auxiliary source code directories.
*
* cmMakeDirectoryCommand specifies source code directories
@@ -21,20 +19,7 @@ class cmExecutionStatus;
* A side effect of this command is to create a subdirectory in the build
* directory structure.
*/
-class cmMakeDirectoryCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmMakeDirectoryCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmMakeDirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 608b18a46..f143ef704 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1,52 +1,69 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmConfigure.h" // IWYU pragma: keep
+
#include "cmMakefile.h"
-#include "cmsys/FStream.hxx"
-#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
-#include <ctype.h>
+#include <cassert>
+#include <cctype>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <sstream>
-#include <stdlib.h>
-#include <string.h>
#include <utility>
+#include <cm/iterator>
+#include <cm/memory>
+
+#include "cmsys/FStream.hxx"
+#include "cmsys/RegularExpression.hxx"
+
+#include "cm_sys_stat.h"
+
#include "cmAlgorithms.h"
-#include "cmCommand.h"
#include "cmCommandArgumentParserHelper.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
#include "cmExecutionStatus.h"
-#include "cmExpandedCommandArgument.h"
+#include "cmExpandedCommandArgument.h" // IWYU pragma: keep
#include "cmFileLockPool.h"
#include "cmFunctionBlocker.h"
+#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorExpressionEvaluationFile.h"
#include "cmGlobalGenerator.h"
#include "cmInstallGenerator.h" // IWYU pragma: keep
+#include "cmInstallSubdirectoryGenerator.h"
#include "cmListFileCache.h"
+#include "cmMessageType.h"
+#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmSourceFileLocation.h"
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+#include "cmTarget.h"
#include "cmTargetLinkLibraryType.h"
#include "cmTest.h"
#include "cmTestGenerator.h" // IWYU pragma: keep
#include "cmVersion.h"
#include "cmWorkingDirectory.h"
-#include "cm_auto_ptr.hxx"
-#include "cm_sys_stat.h"
#include "cmake.h"
-#ifdef CMAKE_BUILD_WITH_CMAKE
-#include "cmVariableWatch.h"
+#ifndef CMAKE_BOOTSTRAP
+# include "cmVariableWatch.h"
#endif
class cmMessenger;
+cmDirectoryId::cmDirectoryId(std::string s)
+ : String(std::move(s))
+{
+}
+
// default is not to be building executables
cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
cmStateSnapshot const& snapshot)
@@ -59,21 +76,22 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused();
this->CheckSystemVars = this->GetCMakeInstance()->GetCheckSystemVars();
- this->SuppressWatches = false;
+ this->SuppressSideEffects = false;
// Setup the default include complaint regular expression (match nothing).
this->ComplainFileRegularExpression = "^$";
this->DefineFlags = " ";
- this->cmDefineRegex.compile("#cmakedefine[ \t]+([A-Za-z_0-9]*)");
- this->cmDefine01Regex.compile("#cmakedefine01[ \t]+([A-Za-z_0-9]*)");
+ this->cmDefineRegex.compile("#([ \t]*)cmakedefine[ \t]+([A-Za-z_0-9]*)");
+ this->cmDefine01Regex.compile("#([ \t]*)cmakedefine01[ \t]+([A-Za-z_0-9]*)");
this->cmAtVarRegex.compile("(@[A-Za-z_0-9/.+-]+@)");
this->cmNamedCurly.compile("^[A-Za-z0-9/_.+-]+{");
this->StateSnapshot =
this->StateSnapshot.GetState()->CreatePolicyScopeSnapshot(
this->StateSnapshot);
+ this->RecursionDepth = 0;
// Enter a policy level for this directory.
this->PushPolicy();
@@ -85,19 +103,17 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
// cmListFileCache in the top level if necessary.
this->CheckCMP0000 = false;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->AddSourceGroup("", "^.*$");
- this->AddSourceGroup("Source Files",
- "\\.(C|M|c|c\\+\\+|cc|cpp|cxx|f|f90|for|fpp"
- "|ftn|m|mm|rc|def|r|odl|idl|hpj|bat)$");
+ this->AddSourceGroup("Source Files", CM_SOURCE_REGEX);
this->AddSourceGroup("Header Files", CM_HEADER_REGEX);
+ this->AddSourceGroup("Precompile Header File", CM_PCH_REGEX);
this->AddSourceGroup("CMake Rules", "\\.rule$");
- this->AddSourceGroup("Resources", "\\.plist$");
+ this->AddSourceGroup("Resources", CM_RESOURCE_REGEX);
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
this->ObjectLibrariesSourceGroupIndex = this->SourceGroups.size();
- this->SourceGroups.push_back(
- cmSourceGroup("Object Libraries", "^MATCH_NO_SOURCES$"));
+ this->SourceGroups.emplace_back("Object Libraries", "^MATCH_NO_SOURCES$");
#endif
}
@@ -108,22 +124,93 @@ cmMakefile::~cmMakefile()
cmDeleteAll(this->SourceFiles);
cmDeleteAll(this->Tests);
cmDeleteAll(this->ImportedTargetsOwned);
- cmDeleteAll(this->FinalPassCommands);
- cmDeleteAll(this->FunctionBlockers);
cmDeleteAll(this->EvaluationFiles);
}
-void cmMakefile::IssueMessage(cmake::MessageType t,
- std::string const& text) const
+cmDirectoryId cmMakefile::GetDirectoryId() const
+{
+ // Use the instance pointer value to uniquely identify this directory.
+ // If we ever need to expose this to CMake language code we should
+ // add a read-only property in cmMakefile::GetProperty.
+ char buf[32];
+ sprintf(buf, "<%p>",
+ static_cast<void const*>(this)); // cast avoids format warning
+ return std::string(buf);
+}
+
+void cmMakefile::IssueMessage(MessageType t, std::string const& text) const
{
if (!this->ExecutionStatusStack.empty()) {
- if ((t == cmake::FATAL_ERROR) || (t == cmake::INTERNAL_ERROR)) {
+ if ((t == MessageType::FATAL_ERROR) ||
+ (t == MessageType::INTERNAL_ERROR)) {
this->ExecutionStatusStack.back()->SetNestedError();
}
}
this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace());
}
+bool cmMakefile::CheckCMP0037(std::string const& targetName,
+ cmStateEnums::TargetType targetType) const
+{
+ MessageType messageType = MessageType::AUTHOR_WARNING;
+ std::ostringstream e;
+ bool issueMessage = false;
+ switch (this->GetPolicyStatus(cmPolicies::CMP0037)) {
+ case cmPolicies::WARN:
+ if (targetType != cmStateEnums::INTERFACE_LIBRARY) {
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n";
+ issueMessage = true;
+ }
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::NEW:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ issueMessage = true;
+ messageType = MessageType::FATAL_ERROR;
+ break;
+ }
+ if (issueMessage) {
+ e << "The target name \"" << targetName
+ << "\" is reserved or not valid for certain "
+ "CMake features, such as generator expressions, and may result "
+ "in undefined behavior.";
+ this->IssueMessage(messageType, e.str());
+
+ if (messageType == MessageType::FATAL_ERROR) {
+ return false;
+ }
+ }
+ return true;
+}
+
+void cmMakefile::MaybeWarnCMP0074(std::string const& pkg)
+{
+ // Warn if a <pkg>_ROOT variable we may use is set.
+ std::string const varName = pkg + "_ROOT";
+ const char* var = this->GetDefinition(varName);
+ std::string env;
+ cmSystemTools::GetEnv(varName, env);
+
+ bool const haveVar = var && *var;
+ bool const haveEnv = !env.empty();
+ if ((haveVar || haveEnv) && this->WarnedCMP0074.insert(varName).second) {
+ std::ostringstream w;
+ w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0074) << "\n";
+ if (haveVar) {
+ w << "CMake variable " << varName << " is set to:\n"
+ << " " << var << "\n";
+ }
+ if (haveEnv) {
+ w << "Environment variable " << varName << " is set to:\n"
+ << " " << env << "\n";
+ }
+ w << "For compatibility, CMake is ignoring the variable.";
+ this->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+ }
+}
+
cmStringRange cmMakefile::GetIncludeDirectoriesEntries() const
{
return this->StateSnapshot.GetDirectory().GetIncludeDirectoriesEntries();
@@ -156,6 +243,27 @@ cmBacktraceRange cmMakefile::GetCompileDefinitionsBacktraces() const
.GetCompileDefinitionsEntryBacktraces();
}
+cmStringRange cmMakefile::GetLinkOptionsEntries() const
+{
+ return this->StateSnapshot.GetDirectory().GetLinkOptionsEntries();
+}
+
+cmBacktraceRange cmMakefile::GetLinkOptionsBacktraces() const
+{
+ return this->StateSnapshot.GetDirectory().GetLinkOptionsEntryBacktraces();
+}
+
+cmStringRange cmMakefile::GetLinkDirectoriesEntries() const
+{
+ return this->StateSnapshot.GetDirectory().GetLinkDirectoriesEntries();
+}
+
+cmBacktraceRange cmMakefile::GetLinkDirectoriesBacktraces() const
+{
+ return this->StateSnapshot.GetDirectory()
+ .GetLinkDirectoriesEntryBacktraces();
+}
+
cmListFileBacktrace cmMakefile::GetBacktrace() const
{
return this->Backtrace;
@@ -164,7 +272,7 @@ cmListFileBacktrace cmMakefile::GetBacktrace() const
cmListFileBacktrace cmMakefile::GetBacktrace(cmCommandContext const& cc) const
{
cmListFileContext lfc;
- lfc.Name = cc.Name;
+ lfc.Name = cc.Name.Original;
lfc.Line = cc.Line;
lfc.FilePath = this->StateSnapshot.GetExecutionListFile();
return this->Backtrace.Push(lfc);
@@ -189,13 +297,14 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
std::string const& only_filename = cmSystemTools::GetFilenameName(full_path);
bool trace = trace_only_this_files.empty();
if (!trace) {
- for (std::vector<std::string>::const_iterator i =
- trace_only_this_files.begin();
- !trace && i != trace_only_this_files.end(); ++i) {
- std::string::size_type const pos = full_path.rfind(*i);
+ for (std::string const& file : trace_only_this_files) {
+ std::string::size_type const pos = full_path.rfind(file);
trace = (pos != std::string::npos) &&
- ((pos + i->size()) == full_path.size()) &&
- (only_filename == cmSystemTools::GetFilenameName(*i));
+ ((pos + file.size()) == full_path.size()) &&
+ (only_filename == cmSystemTools::GetFilenameName(file));
+ if (trace) {
+ break;
+ }
}
// Do nothing if current file wasn't requested for trace...
if (!trace) {
@@ -205,23 +314,27 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
std::ostringstream msg;
msg << full_path << "(" << lff.Line << "): ";
- msg << lff.Name << "(";
+ msg << lff.Name.Original << "(";
bool expand = this->GetCMakeInstance()->GetTraceExpand();
std::string temp;
- for (std::vector<cmListFileArgument>::const_iterator i =
- lff.Arguments.begin();
- i != lff.Arguments.end(); ++i) {
+ for (cmListFileArgument const& arg : lff.Arguments) {
if (expand) {
- temp = i->Value;
+ temp = arg.Value;
this->ExpandVariablesInString(temp);
msg << temp;
} else {
- msg << i->Value;
+ msg << arg.Value;
}
msg << " ";
}
msg << ")";
- cmSystemTools::Message(msg.str().c_str());
+
+ auto& f = this->GetCMakeInstance()->GetTraceFile();
+ if (f) {
+ f << msg.str() << '\n';
+ } else {
+ cmSystemTools::Message(msg.str());
+ }
}
// Helper class to make sure the call stack is valid.
@@ -235,19 +348,29 @@ public:
cmListFileContext const& lfc = cmListFileContext::FromCommandContext(
cc, this->Makefile->StateSnapshot.GetExecutionListFile());
this->Makefile->Backtrace = this->Makefile->Backtrace.Push(lfc);
+ ++this->Makefile->RecursionDepth;
this->Makefile->ExecutionStatusStack.push_back(&status);
}
~cmMakefileCall()
{
this->Makefile->ExecutionStatusStack.pop_back();
+ --this->Makefile->RecursionDepth;
this->Makefile->Backtrace = this->Makefile->Backtrace.Pop();
}
+ cmMakefileCall(const cmMakefileCall&) = delete;
+ cmMakefileCall& operator=(const cmMakefileCall&) = delete;
+
private:
cmMakefile* Makefile;
};
+void cmMakefile::OnExecuteCommand(std::function<void()> callback)
+{
+ this->ExecuteCommandCallback = std::move(callback);
+}
+
bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
cmExecutionStatus& status)
{
@@ -259,18 +382,35 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
return result;
}
- std::string name = lff.Name;
+ if (this->ExecuteCommandCallback) {
+ this->ExecuteCommandCallback();
+ }
// Place this call on the call stack.
cmMakefileCall stack_manager(this, lff, status);
static_cast<void>(stack_manager);
- // Lookup the command prototype.
- if (cmCommand* proto = this->GetState()->GetCommand(name)) {
- // Clone the prototype.
- CM_AUTO_PTR<cmCommand> pcmd(proto->Clone());
- pcmd->SetMakefile(this);
+ // Check for maximum recursion depth.
+ int depth = CMake_DEFAULT_RECURSION_LIMIT;
+ const char* depthStr = this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH");
+ if (depthStr) {
+ std::istringstream s(depthStr);
+ int d;
+ if (s >> d) {
+ depth = d;
+ }
+ }
+ if (this->RecursionDepth > depth) {
+ std::ostringstream e;
+ e << "Maximum recursion depth of " << depth << " exceeded";
+ this->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+ // Lookup the command prototype.
+ if (cmState::Command command =
+ this->GetState()->GetCommandByExactName(lff.Name.Lower)) {
// Decide whether to invoke the command.
if (!cmSystemTools::GetFatalErrorOccured()) {
// if trace is enabled, print out invoke information
@@ -278,29 +418,26 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
this->PrintCommandTrace(lff);
}
// Try invoking the command.
- bool invokeSucceeded = pcmd->InvokeInitialPass(lff.Arguments, status);
+ bool invokeSucceeded = command(lff.Arguments, status);
bool hadNestedError = status.GetNestedError();
if (!invokeSucceeded || hadNestedError) {
if (!hadNestedError) {
// The command invocation requested that we report an error.
- std::string const error = name + " " + pcmd->GetError();
- this->IssueMessage(cmake::FATAL_ERROR, error);
+ std::string const error =
+ std::string(lff.Name.Original) + " " + status.GetError();
+ this->IssueMessage(MessageType::FATAL_ERROR, error);
}
result = false;
if (this->GetCMakeInstance()->GetWorkingMode() != cmake::NORMAL_MODE) {
cmSystemTools::SetFatalErrorOccured();
}
- } else if (pcmd->HasFinalPass()) {
- // use the command
- this->FinalPassCommands.push_back(pcmd.release());
}
}
} else {
if (!cmSystemTools::GetFatalErrorOccured()) {
- std::string error = "Unknown CMake command \"";
- error += lff.Name;
- error += "\".";
- this->IssueMessage(cmake::FATAL_ERROR, error);
+ std::string error =
+ cmStrCat("Unknown CMake command \"", lff.Name.Original, "\".");
+ this->IssueMessage(MessageType::FATAL_ERROR, error);
result = false;
cmSystemTools::SetFatalErrorOccured();
}
@@ -317,6 +454,9 @@ public:
~IncludeScope();
void Quiet() { this->ReportError = false; }
+ IncludeScope(const IncludeScope&) = delete;
+ IncludeScope& operator=(const IncludeScope&) = delete;
+
private:
cmMakefile* Makefile;
bool NoPolicyScope;
@@ -412,7 +552,7 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
<< "affects policy settings. "
<< "CMake is implying the NO_POLICY_SCOPE option for compatibility, "
<< "so the effects are applied to the including context.";
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
}
break;
case cmPolicies::REQUIRED_IF_USED:
@@ -424,7 +564,7 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
<< this->Makefile->GetExecutionFilePath() << "\n"
<< "affects policy settings, so it requires this policy to be set.";
/* clang-format on */
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
} break;
case cmPolicies::OLD:
case cmPolicies::NEW:
@@ -435,10 +575,12 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
}
}
-bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope)
+bool cmMakefile::ReadDependentFile(const std::string& filename,
+ bool noPolicyScope)
{
- this->AddDefinition("CMAKE_PARENT_LIST_FILE",
- this->GetDefinition("CMAKE_CURRENT_LIST_FILE"));
+ if (const char* def = this->GetDefinition("CMAKE_CURRENT_LIST_FILE")) {
+ this->AddDefinition("CMAKE_PARENT_LIST_FILE", def);
+ }
std::string filenametoread = cmSystemTools::CollapseFullPath(
filename, this->GetCurrentSourceDirectory());
@@ -483,12 +625,15 @@ public:
void Quiet() { this->ReportError = false; }
+ ListFileScope(const ListFileScope&) = delete;
+ ListFileScope& operator=(const ListFileScope&) = delete;
+
private:
cmMakefile* Makefile;
bool ReportError;
};
-bool cmMakefile::ReadListFile(const char* filename)
+bool cmMakefile::ReadListFile(const std::string& filename)
{
std::string filenametoread = cmSystemTools::CollapseFullPath(
filename, this->GetCurrentSourceDirectory());
@@ -518,9 +663,9 @@ void cmMakefile::ReadListFile(cmListFile const& listFile,
this->GetSafeDefinition("CMAKE_PARENT_LIST_FILE");
std::string currentFile = this->GetSafeDefinition("CMAKE_CURRENT_LIST_FILE");
- this->AddDefinition("CMAKE_CURRENT_LIST_FILE", filenametoread.c_str());
+ this->AddDefinition("CMAKE_CURRENT_LIST_FILE", filenametoread);
this->AddDefinition("CMAKE_CURRENT_LIST_DIR",
- cmSystemTools::GetFilenamePath(filenametoread).c_str());
+ cmSystemTools::GetFilenamePath(filenametoread));
this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
@@ -529,7 +674,7 @@ void cmMakefile::ReadListFile(cmListFile const& listFile,
// Run the parsed commands.
const size_t numberFunctions = listFile.Functions.size();
for (size_t i = 0; i < numberFunctions; ++i) {
- cmExecutionStatus status;
+ cmExecutionStatus status(*this);
this->ExecuteCommand(listFile.Functions[i], status);
if (cmSystemTools::GetFatalErrorOccured()) {
break;
@@ -541,10 +686,10 @@ void cmMakefile::ReadListFile(cmListFile const& listFile,
}
this->CheckForUnusedVariables();
- this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str());
- this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str());
+ this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile);
+ this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile);
this->AddDefinition("CMAKE_CURRENT_LIST_DIR",
- cmSystemTools::GetFilenamePath(currentFile).c_str());
+ cmSystemTools::GetFilenamePath(currentFile));
this->MarkVariableAsUsed("CMAKE_PARENT_LIST_FILE");
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_FILE");
this->MarkVariableAsUsed("CMAKE_CURRENT_LIST_DIR");
@@ -566,9 +711,9 @@ void cmMakefile::EnforceDirectoryLevelRules() const
<< "\"cmake --help-policy CMP0000\".";
switch (this->GetPolicyStatus(cmPolicies::CMP0000)) {
case cmPolicies::WARN:
- // Warn because the user did not provide a mimimum required
+ // Warn because the user did not provide a minimum required
// version.
- this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
+ this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING,
msg.str(), this->Backtrace);
case cmPolicies::OLD:
// OLD behavior is to use policy version 2.4 set in
@@ -578,8 +723,8 @@ void cmMakefile::EnforceDirectoryLevelRules() const
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
// NEW behavior is to issue an error.
- this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, msg.str(),
- this->Backtrace);
+ this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
+ msg.str(), this->Backtrace);
cmSystemTools::SetFatalErrorOccured();
return;
}
@@ -588,11 +733,13 @@ void cmMakefile::EnforceDirectoryLevelRules() const
void cmMakefile::AddEvaluationFile(
const std::string& inputFile,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> outputName,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> condition, bool inputIsContent)
+ std::unique_ptr<cmCompiledGeneratorExpression> outputName,
+ std::unique_ptr<cmCompiledGeneratorExpression> condition,
+ bool inputIsContent)
{
this->EvaluationFiles.push_back(new cmGeneratorExpressionEvaluationFile(
- inputFile, outputName, condition, inputIsContent));
+ inputFile, std::move(outputName), std::move(condition), inputIsContent,
+ this->GetPolicyStatus(cmPolicies::CMP0070)));
}
std::vector<cmGeneratorExpressionEvaluationFile*>
@@ -610,9 +757,8 @@ cmMakefile::GetExportBuildFileGenerators() const
void cmMakefile::RemoveExportBuildFileGeneratorCMP0024(
cmExportBuildFileGenerator* gen)
{
- std::vector<cmExportBuildFileGenerator*>::iterator it =
- std::find(this->ExportBuildFileGenerators.begin(),
- this->ExportBuildFileGenerators.end(), gen);
+ auto it = std::find(this->ExportBuildFileGenerators.begin(),
+ this->ExportBuildFileGenerators.end(), gen);
if (it != this->ExportBuildFileGenerators.end()) {
this->ExportBuildFileGenerators.erase(it);
}
@@ -629,11 +775,16 @@ struct file_not_persistent
bool operator()(const std::string& path) const
{
return !(path.find("CMakeTmp") == std::string::npos &&
- cmSystemTools::FileExists(path.c_str()));
+ cmSystemTools::FileExists(path));
}
};
}
+void cmMakefile::AddFinalAction(FinalAction action)
+{
+ this->FinalActions.push_back(std::move(action));
+}
+
void cmMakefile::FinalPass()
{
// do all the variable expansions here
@@ -641,9 +792,8 @@ void cmMakefile::FinalPass()
// give all the commands a chance to do something
// after the file has been parsed before generation
- for (std::vector<cmCommand*>::iterator i = this->FinalPassCommands.begin();
- i != this->FinalPassCommands.end(); ++i) {
- (*i)->FinalPass();
+ for (FinalAction& action : this->FinalActions) {
+ action(*this);
}
// go through all configured files and see which ones still exist.
@@ -666,7 +816,7 @@ void cmMakefile::ConfigureFinalPass()
if (oldValue &&
cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, oldValue, "2.4")) {
this->GetCMakeInstance()->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"You have set CMAKE_BACKWARDS_COMPATIBILITY to a CMake version less "
"than 2.4. This version of CMake only supports backwards compatibility "
"with CMake 2.4 or later. For compatibility with older versions please "
@@ -675,19 +825,30 @@ void cmMakefile::ConfigureFinalPass()
}
}
-void cmMakefile::AddCustomCommandToTarget(
- const std::string& target, const std::vector<std::string>& byproducts,
- const std::vector<std::string>& depends,
- const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type,
- const char* comment, const char* workingDir, bool escapeOldStyle,
- bool uses_terminal, const std::string& depfile, bool command_expand_lists,
- ObjectLibraryCommands objLibraryCommands)
+bool cmMakefile::ValidateCustomCommand(
+ const cmCustomCommandLines& commandLines) const
+{
+ // TODO: More strict?
+ for (cmCustomCommandLine const& cl : commandLines) {
+ if (!cl.empty() && !cl[0].empty() && cl[0][0] == '"') {
+ std::ostringstream e;
+ e << "COMMAND may not contain literal quotes:\n " << cl[0] << "\n";
+ this->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return false;
+ }
+ }
+
+ return true;
+}
+
+cmTarget* cmMakefile::GetCustomCommandTarget(
+ const std::string& target, cmObjectLibraryCommands objLibCommands) const
{
// Find the target to which to add the custom command.
- cmTargets::iterator ti = this->Targets.find(target);
+ auto ti = this->Targets.find(target);
if (ti == this->Targets.end()) {
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ MessageType messageType = MessageType::AUTHOR_WARNING;
bool issueMessage = false;
std::ostringstream e;
switch (this->GetPolicyStatus(cmPolicies::CMP0040)) {
@@ -700,7 +861,7 @@ void cmMakefile::AddCustomCommandToTarget(
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
issueMessage = true;
- messageType = cmake::FATAL_ERROR;
+ messageType = MessageType::FATAL_ERROR;
}
if (issueMessage) {
@@ -715,38 +876,67 @@ void cmMakefile::AddCustomCommandToTarget(
e << "No TARGET '" << target
<< "' has been created in this directory.";
}
- IssueMessage(messageType, e.str());
+ this->IssueMessage(messageType, e.str());
}
- return;
+ return nullptr;
}
- if (objLibraryCommands == RejectObjectLibraryCommands &&
- ti->second.GetType() == cmStateEnums::OBJECT_LIBRARY) {
+ cmTarget* t = &ti->second;
+ if (objLibCommands == cmObjectLibraryCommands::Reject &&
+ t->GetType() == cmStateEnums::OBJECT_LIBRARY) {
std::ostringstream e;
e << "Target \"" << target
<< "\" is an OBJECT library "
"that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands.";
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
- return;
+ this->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return nullptr;
}
- if (ti->second.GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ if (t->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
std::ostringstream e;
e << "Target \"" << target
<< "\" is an INTERFACE library "
"that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands.";
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
- return;
+ this->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return nullptr;
}
- // Always create the byproduct sources and mark them generated.
- for (std::vector<std::string>::const_iterator o = byproducts.begin();
- o != byproducts.end(); ++o) {
- if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
- out->SetProperty("GENERATED", "1");
- }
+ return t;
+}
+
+cmTarget* cmMakefile::AddCustomCommandToTarget(
+ const std::string& target, const std::vector<std::string>& byproducts,
+ const std::vector<std::string>& depends,
+ const cmCustomCommandLines& commandLines, cmCustomCommandType type,
+ const char* comment, const char* workingDir, bool escapeOldStyle,
+ bool uses_terminal, const std::string& depfile, const std::string& job_pool,
+ bool command_expand_lists, cmObjectLibraryCommands objLibCommands)
+{
+ cmTarget* t = this->GetCustomCommandTarget(target, objLibCommands);
+
+ // Validate custom commands.
+ if (!t || !this->ValidateCustomCommand(commandLines)) {
+ return t;
}
+ // Always create the byproduct sources and mark them generated.
+ this->CreateGeneratedSources(byproducts);
+
+ this->CommitCustomCommandToTarget(
+ t, byproducts, depends, commandLines, type, comment, workingDir,
+ escapeOldStyle, uses_terminal, depfile, job_pool, command_expand_lists);
+
+ return t;
+}
+
+void cmMakefile::CommitCustomCommandToTarget(
+ cmTarget* target, const std::vector<std::string>& byproducts,
+ const std::vector<std::string>& depends,
+ const cmCustomCommandLines& commandLines, cmCustomCommandType type,
+ const char* comment, const char* workingDir, bool escapeOldStyle,
+ bool uses_terminal, const std::string& depfile, const std::string& job_pool,
+ bool command_expand_lists)
+{
// Add the command to the appropriate build step for the target.
std::vector<std::string> no_output;
cmCustomCommand cc(this, no_output, byproducts, depends, commandLines,
@@ -756,47 +946,82 @@ void cmMakefile::AddCustomCommandToTarget(
cc.SetUsesTerminal(uses_terminal);
cc.SetCommandExpandLists(command_expand_lists);
cc.SetDepfile(depfile);
+ cc.SetJobPool(job_pool);
switch (type) {
- case cmTarget::PRE_BUILD:
- ti->second.AddPreBuildCommand(cc);
+ case cmCustomCommandType::PRE_BUILD:
+ target->AddPreBuildCommand(std::move(cc));
break;
- case cmTarget::PRE_LINK:
- ti->second.AddPreLinkCommand(cc);
+ case cmCustomCommandType::PRE_LINK:
+ target->AddPreLinkCommand(std::move(cc));
break;
- case cmTarget::POST_BUILD:
- ti->second.AddPostBuildCommand(cc);
+ case cmCustomCommandType::POST_BUILD:
+ target->AddPostBuildCommand(std::move(cc));
break;
}
+
+ this->AddTargetByproducts(target, byproducts);
+}
+
+cmSourceFile* cmMakefile::AddCustomCommandToOutput(
+ const std::string& output, const std::vector<std::string>& depends,
+ const std::string& main_dependency, const cmCustomCommandLines& commandLines,
+ const char* comment, const char* workingDir, bool replace,
+ bool escapeOldStyle, bool uses_terminal, bool command_expand_lists,
+ const std::string& depfile, const std::string& job_pool)
+{
+ std::vector<std::string> outputs;
+ outputs.push_back(output);
+ std::vector<std::string> no_byproducts;
+ cmImplicitDependsList no_implicit_depends;
+ return this->AddCustomCommandToOutput(
+ outputs, no_byproducts, depends, main_dependency, no_implicit_depends,
+ commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal,
+ command_expand_lists, depfile, job_pool);
}
cmSourceFile* cmMakefile::AddCustomCommandToOutput(
const std::vector<std::string>& outputs,
const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends, const std::string& main_dependency,
+ const cmImplicitDependsList& implicit_depends,
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace, bool escapeOldStyle,
- bool uses_terminal, bool command_expand_lists, const std::string& depfile)
+ bool uses_terminal, bool command_expand_lists, const std::string& depfile,
+ const std::string& job_pool)
{
// Make sure there is at least one output.
if (outputs.empty()) {
cmSystemTools::Error("Attempt to add a custom rule with no output!");
- return CM_NULLPTR;
+ return nullptr;
}
- // Validate custom commands. TODO: More strict?
- for (cmCustomCommandLines::const_iterator i = commandLines.begin();
- i != commandLines.end(); ++i) {
- cmCustomCommandLine const& cl = *i;
- if (!cl.empty() && !cl[0].empty() && cl[0][0] == '"') {
- std::ostringstream e;
- e << "COMMAND may not contain literal quotes:\n " << cl[0] << "\n";
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
- return CM_NULLPTR;
- }
+ // Validate custom commands.
+ if (!this->ValidateCustomCommand(commandLines)) {
+ return nullptr;
}
+ // Always create the output sources and mark them generated.
+ this->CreateGeneratedSources(outputs);
+ this->CreateGeneratedSources(byproducts);
+
+ return this->CommitCustomCommandToOutput(
+ outputs, byproducts, depends, main_dependency, implicit_depends,
+ commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal,
+ command_expand_lists, depfile, job_pool);
+}
+
+cmSourceFile* cmMakefile::CommitCustomCommandToOutput(
+ const std::vector<std::string>& outputs,
+ const std::vector<std::string>& byproducts,
+ const std::vector<std::string>& depends, const std::string& main_dependency,
+ const cmImplicitDependsList& implicit_depends,
+ const cmCustomCommandLines& commandLines, const char* comment,
+ const char* workingDir, bool replace, bool escapeOldStyle,
+ bool uses_terminal, bool command_expand_lists, const std::string& depfile,
+ const std::string& job_pool)
+{
// Choose a source file on which to store the custom command.
- cmSourceFile* file = CM_NULLPTR;
+ cmSourceFile* file = nullptr;
if (!commandLines.empty() && !main_dependency.empty()) {
// The main dependency was specified. Use it unless a different
// custom command already used it.
@@ -810,7 +1035,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
}
// The existing custom command is different. We need to
// generate a rule file for this new command.
- file = CM_NULLPTR;
+ file = nullptr;
} else if (!file) {
file = this->CreateSource(main_dependency);
}
@@ -824,38 +1049,24 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
std::string outName = gg->GenerateRuleFile(outputs[0]);
// Check if the rule file already exists.
- file = this->GetSource(outName);
+ file = this->GetSource(outName, cmSourceFileLocationKind::Known);
if (file && file->GetCustomCommand() && !replace) {
// The rule file already exists.
if (commandLines != file->GetCustomCommand()->GetCommandLines()) {
- cmSystemTools::Error("Attempt to add a custom rule to output \"",
- outName.c_str(),
- "\" which already has a custom rule.");
+ cmSystemTools::Error("Attempt to add a custom rule to output \"" +
+ outName + "\" which already has a custom rule.");
}
return file;
}
// Create a cmSourceFile for the rule file.
if (!file) {
- file = this->CreateSource(outName, true);
+ file =
+ this->CreateSource(outName, true, cmSourceFileLocationKind::Known);
}
file->SetProperty("__CMAKE_RULE", "1");
}
- // Always create the output sources and mark them generated.
- for (std::vector<std::string>::const_iterator o = outputs.begin();
- o != outputs.end(); ++o) {
- if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
- out->SetProperty("GENERATED", "1");
- }
- }
- for (std::vector<std::string>::const_iterator o = byproducts.begin();
- o != byproducts.end(); ++o) {
- if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
- out->SetProperty("GENERATED", "1");
- }
- }
-
// Attach the custom command to the file.
if (file) {
// Construct a complete list of dependencies.
@@ -864,60 +1075,20 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
depends2.push_back(main_dependency);
}
- cmCustomCommand* cc = new cmCustomCommand(
+ std::unique_ptr<cmCustomCommand> cc = cm::make_unique<cmCustomCommand>(
this, outputs, byproducts, depends2, commandLines, comment, workingDir);
cc->SetEscapeOldStyle(escapeOldStyle);
cc->SetEscapeAllowMakeVars(true);
+ cc->SetImplicitDepends(implicit_depends);
cc->SetUsesTerminal(uses_terminal);
cc->SetCommandExpandLists(command_expand_lists);
cc->SetDepfile(depfile);
- file->SetCustomCommand(cc);
- this->UpdateOutputToSourceMap(outputs, file);
- }
- return file;
-}
+ cc->SetJobPool(job_pool);
+ file->SetCustomCommand(std::move(cc));
-void cmMakefile::UpdateOutputToSourceMap(
- std::vector<std::string> const& outputs, cmSourceFile* source)
-{
- for (std::vector<std::string>::const_iterator o = outputs.begin();
- o != outputs.end(); ++o) {
- this->UpdateOutputToSourceMap(*o, source);
+ this->AddSourceOutputs(file, outputs, byproducts);
}
-}
-
-void cmMakefile::UpdateOutputToSourceMap(std::string const& output,
- cmSourceFile* source)
-{
- OutputToSourceMap::iterator i = this->OutputToSource.find(output);
- if (i != this->OutputToSource.end()) {
- // Multiple custom commands produce the same output but may
- // be attached to a different source file (MAIN_DEPENDENCY).
- // LinearGetSourceFileWithOutput would return the first one,
- // so keep the mapping for the first one.
- //
- // TODO: Warn the user about this case. However, the VS 8 generator
- // triggers it for separate generate.stamp rules in ZERO_CHECK and
- // individual targets.
- return;
- }
- this->OutputToSource[output] = source;
-}
-
-cmSourceFile* cmMakefile::AddCustomCommandToOutput(
- const std::string& output, const std::vector<std::string>& depends,
- const std::string& main_dependency, const cmCustomCommandLines& commandLines,
- const char* comment, const char* workingDir, bool replace,
- bool escapeOldStyle, bool uses_terminal, bool command_expand_lists,
- const std::string& depfile)
-{
- std::vector<std::string> outputs;
- outputs.push_back(output);
- std::vector<std::string> no_byproducts;
- return this->AddCustomCommandToOutput(
- outputs, no_byproducts, depends, main_dependency, commandLines, comment,
- workingDir, replace, escapeOldStyle, uses_terminal, command_expand_lists,
- depfile);
+ return file;
}
void cmMakefile::AddCustomCommandOldStyle(
@@ -932,198 +1103,210 @@ void cmMakefile::AddCustomCommandOldStyle(
// same then it added a post-build rule to the target. Preserve
// this behavior.
std::vector<std::string> no_byproducts;
- this->AddCustomCommandToTarget(target, no_byproducts, depends,
- commandLines, cmTarget::POST_BUILD, comment,
- CM_NULLPTR);
+ this->AddCustomCommandToTarget(
+ target, no_byproducts, depends, commandLines,
+ cmCustomCommandType::POST_BUILD, comment, nullptr);
return;
}
- // Each output must get its own copy of this rule.
- cmsys::RegularExpression sourceFiles("\\.(C|M|c|c\\+\\+|cc|cpp|cxx|m|mm|"
- "rc|def|r|odl|idl|hpj|bat|h|h\\+\\+|"
- "hm|hpp|hxx|in|txx|inl)$");
- for (std::vector<std::string>::const_iterator oi = outputs.begin();
- oi != outputs.end(); ++oi) {
- // Get the name of this output.
- const char* output = oi->c_str();
- cmSourceFile* sf;
-
- // Choose whether to use a main dependency.
- if (sourceFiles.find(source)) {
- // The source looks like a real file. Use it as the main dependency.
- sf = this->AddCustomCommandToOutput(output, depends, source,
- commandLines, comment, CM_NULLPTR);
- } else {
- // The source may not be a real file. Do not use a main dependency.
- std::string no_main_dependency;
- std::vector<std::string> depends2 = depends;
- depends2.push_back(source);
- sf = this->AddCustomCommandToOutput(output, depends2, no_main_dependency,
- commandLines, comment, CM_NULLPTR);
- }
+ auto ti = this->Targets.find(target);
+ cmTarget* t = ti != this->Targets.end() ? &ti->second : nullptr;
+ auto addRuleFileToTarget = [=](cmSourceFile* sf) {
// If the rule was added to the source (and not a .rule file),
// then add the source to the target to make sure the rule is
// included.
- if (sf && !sf->GetPropertyAsBool("__CMAKE_RULE")) {
- cmTargets::iterator ti = this->Targets.find(target);
- if (ti != this->Targets.end()) {
- ti->second.AddSource(sf->GetFullPath());
+ if (!sf->GetPropertyAsBool("__CMAKE_RULE")) {
+ if (t) {
+ t->AddSource(sf->ResolveFullPath());
} else {
cmSystemTools::Error("Attempt to add a custom rule to a target "
- "that does not exist yet for target ",
- target.c_str());
- return;
+ "that does not exist yet for target " +
+ target);
+ }
+ }
+ };
+
+ // Each output must get its own copy of this rule.
+ cmsys::RegularExpression sourceFiles("\\.(C|M|c|c\\+\\+|cc|cpp|cxx|cu|m|mm|"
+ "rc|def|r|odl|idl|hpj|bat|h|h\\+\\+|"
+ "hm|hpp|hxx|in|txx|inl)$");
+
+ // Choose whether to use a main dependency.
+ if (sourceFiles.find(source)) {
+ // The source looks like a real file. Use it as the main dependency.
+ for (std::string const& output : outputs) {
+ cmSourceFile* sf = this->AddCustomCommandToOutput(
+ output, depends, source, commandLines, comment, nullptr);
+ if (sf) {
+ addRuleFileToTarget(sf);
+ }
+ }
+ } else {
+ std::string no_main_dependency;
+ std::vector<std::string> depends2 = depends;
+ depends2.push_back(source);
+
+ // The source may not be a real file. Do not use a main dependency.
+ for (std::string const& output : outputs) {
+ cmSourceFile* sf = this->AddCustomCommandToOutput(
+ output, depends2, no_main_dependency, commandLines, comment, nullptr);
+ if (sf) {
+ addRuleFileToTarget(sf);
}
}
}
}
-cmTarget* cmMakefile::AddUtilityCommand(
- const std::string& utilityName, bool excludeFromAll,
- const std::vector<std::string>& depends, const char* workingDirectory,
- const char* command, const char* arg1, const char* arg2, const char* arg3,
- const char* arg4)
+bool cmMakefile::AppendCustomCommandToOutput(
+ const std::string& output, const std::vector<std::string>& depends,
+ const cmImplicitDependsList& implicit_depends,
+ const cmCustomCommandLines& commandLines)
{
- // Construct the command line for the custom command.
- cmCustomCommandLine commandLine;
- commandLine.push_back(command);
- if (arg1) {
- commandLine.push_back(arg1);
- }
- if (arg2) {
- commandLine.push_back(arg2);
- }
- if (arg3) {
- commandLine.push_back(arg3);
+ // Check as good as we can if there will be a command for this output.
+ if (!this->MightHaveCustomCommand(output)) {
+ return false;
}
- if (arg4) {
- commandLine.push_back(arg4);
+
+ // Validate custom commands.
+ if (this->ValidateCustomCommand(commandLines)) {
+ // Add command factory to allow generator expressions in output.
+ this->CommitAppendCustomCommandToOutput(output, depends, implicit_depends,
+ commandLines);
}
- cmCustomCommandLines commandLines;
- commandLines.push_back(commandLine);
- // Call the real signature of this method.
- return this->AddUtilityCommand(utilityName, excludeFromAll, workingDirectory,
- depends, commandLines);
+ return true;
+}
+
+void cmMakefile::CommitAppendCustomCommandToOutput(
+ const std::string& output, const std::vector<std::string>& depends,
+ const cmImplicitDependsList& implicit_depends,
+ const cmCustomCommandLines& commandLines)
+{
+ // Lookup an existing command.
+ if (cmSourceFile* sf = this->GetSourceFileWithOutput(output)) {
+ if (cmCustomCommand* cc = sf->GetCustomCommand()) {
+ cc->AppendCommands(commandLines);
+ cc->AppendDepends(depends);
+ cc->AppendImplicitDepends(implicit_depends);
+ }
+ }
}
-cmTarget* cmMakefile::AddUtilityCommand(
- const std::string& utilityName, bool excludeFromAll,
- const char* workingDirectory, const std::vector<std::string>& depends,
- const cmCustomCommandLines& commandLines, bool escapeOldStyle,
- const char* comment, bool uses_terminal, bool command_expand_lists)
+cmUtilityOutput cmMakefile::GetUtilityOutput(cmTarget* target)
{
- std::vector<std::string> no_byproducts;
- return this->AddUtilityCommand(utilityName, excludeFromAll, workingDirectory,
- no_byproducts, depends, commandLines,
- escapeOldStyle, comment, uses_terminal,
- command_expand_lists);
+ std::string force = cmStrCat(this->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/", target->GetName());
+ std::string forceCMP0049 = target->GetSourceCMP0049(force);
+ {
+ cmSourceFile* sf = nullptr;
+ if (!forceCMP0049.empty()) {
+ sf = this->GetOrCreateSource(forceCMP0049, false,
+ cmSourceFileLocationKind::Known);
+ }
+ // The output is not actually created so mark it symbolic.
+ if (sf) {
+ sf->SetProperty("SYMBOLIC", "1");
+ } else {
+ cmSystemTools::Error("Could not get source file entry for " + force);
+ }
+ }
+ return { std::move(force), std::move(forceCMP0049) };
}
cmTarget* cmMakefile::AddUtilityCommand(
- const std::string& utilityName, bool excludeFromAll,
+ const std::string& utilityName, cmCommandOrigin origin, bool excludeFromAll,
const char* workingDirectory, const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle,
- const char* comment, bool uses_terminal, bool command_expand_lists)
+ const char* comment, bool uses_terminal, bool command_expand_lists,
+ const std::string& job_pool)
{
- // Create a target instance for this utility.
- cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName);
- if (excludeFromAll) {
- target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
+ cmTarget* target =
+ this->AddNewUtilityTarget(utilityName, origin, excludeFromAll);
+
+ // Validate custom commands.
+ if ((commandLines.empty() && depends.empty()) ||
+ !this->ValidateCustomCommand(commandLines)) {
+ return target;
}
+
+ // Get the output name of the utility target and mark it generated.
+ cmUtilityOutput force = this->GetUtilityOutput(target);
+ this->GetOrCreateGeneratedSource(force.Name);
+
+ // Always create the byproduct sources and mark them generated.
+ this->CreateGeneratedSources(byproducts);
+
if (!comment) {
// Use an empty comment to avoid generation of default comment.
comment = "";
}
- // Store the custom command in the target.
- if (!commandLines.empty() || !depends.empty()) {
- std::string force = this->GetCurrentBinaryDirectory();
- force += cmake::GetCMakeFilesDirectory();
- force += "/";
- force += utilityName;
- std::vector<std::string> forced;
- forced.push_back(force);
- std::string no_main_dependency;
- bool no_replace = false;
- this->AddCustomCommandToOutput(
- forced, byproducts, depends, no_main_dependency, commandLines, comment,
- workingDirectory, no_replace, escapeOldStyle, uses_terminal,
- command_expand_lists);
- cmSourceFile* sf = target->AddSourceCMP0049(force);
-
- // The output is not actually created so mark it symbolic.
- if (sf) {
- sf->SetProperty("SYMBOLIC", "1");
- } else {
- cmSystemTools::Error("Could not get source file entry for ",
- force.c_str());
- }
+ this->CommitUtilityCommand(target, force, workingDirectory, byproducts,
+ depends, commandLines, escapeOldStyle, comment,
+ uses_terminal, command_expand_lists, job_pool);
- // Always create the byproduct sources and mark them generated.
- for (std::vector<std::string>::const_iterator o = byproducts.begin();
- o != byproducts.end(); ++o) {
- if (cmSourceFile* out = this->GetOrCreateSource(*o, true)) {
- out->SetProperty("GENERATED", "1");
- }
- }
- }
return target;
}
-void cmMakefile::AddDefineFlag(const char* flag)
+void cmMakefile::CommitUtilityCommand(
+ cmTarget* target, const cmUtilityOutput& force, const char* workingDirectory,
+ const std::vector<std::string>& byproducts,
+ const std::vector<std::string>& depends,
+ const cmCustomCommandLines& commandLines, bool escapeOldStyle,
+ const char* comment, bool uses_terminal, bool command_expand_lists,
+ const std::string& job_pool)
{
- if (!flag) {
- return;
+ std::vector<std::string> forced;
+ forced.push_back(force.Name);
+ std::string no_main_dependency;
+ cmImplicitDependsList no_implicit_depends;
+ bool no_replace = false;
+ cmSourceFile* sf = this->AddCustomCommandToOutput(
+ forced, byproducts, depends, no_main_dependency, no_implicit_depends,
+ commandLines, comment, workingDirectory, no_replace, escapeOldStyle,
+ uses_terminal, command_expand_lists, /*depfile=*/"", job_pool);
+ if (!force.NameCMP0049.empty()) {
+ target->AddSource(force.NameCMP0049);
}
-
- // Update the string used for the old DEFINITIONS property.
- this->AddDefineFlag(flag, this->DefineFlagsOrig);
-
- // If this is really a definition, update COMPILE_DEFINITIONS.
- if (this->ParseDefineFlag(flag, false)) {
- return;
+ if (sf) {
+ this->AddTargetByproducts(target, byproducts);
}
-
- // Add this flag that does not look like a definition.
- this->AddDefineFlag(flag, this->DefineFlags);
}
-void cmMakefile::AddDefineFlag(const char* flag, std::string& dflags)
+static void s_AddDefineFlag(std::string const& flag, std::string& dflags)
{
// remove any \n\r
std::string::size_type initSize = dflags.size();
- dflags += std::string(" ") + flag;
+ dflags += ' ';
+ dflags += flag;
std::string::iterator flagStart = dflags.begin() + initSize + 1;
std::replace(flagStart, dflags.end(), '\n', ' ');
std::replace(flagStart, dflags.end(), '\r', ' ');
}
-void cmMakefile::RemoveDefineFlag(const char* flag)
+void cmMakefile::AddDefineFlag(std::string const& flag)
{
- // Check the length of the flag to remove.
- std::string::size_type len = strlen(flag);
- if (len < 1) {
+ if (flag.empty()) {
return;
}
// Update the string used for the old DEFINITIONS property.
- this->RemoveDefineFlag(flag, len, this->DefineFlagsOrig);
+ s_AddDefineFlag(flag, this->DefineFlagsOrig);
// If this is really a definition, update COMPILE_DEFINITIONS.
- if (this->ParseDefineFlag(flag, true)) {
+ if (this->ParseDefineFlag(flag, false)) {
return;
}
- // Remove this flag that does not look like a definition.
- this->RemoveDefineFlag(flag, len, this->DefineFlags);
+ // Add this flag that does not look like a definition.
+ s_AddDefineFlag(flag, this->DefineFlags);
}
-void cmMakefile::RemoveDefineFlag(const char* flag, std::string::size_type len,
- std::string& dflags)
+static void s_RemoveDefineFlag(std::string const& flag, std::string& dflags)
{
+ std::string::size_type const len = flag.length();
// Remove all instances of the flag that are surrounded by
// whitespace or the beginning/end of the string.
for (std::string::size_type lpos = dflags.find(flag, 0);
@@ -1138,9 +1321,50 @@ void cmMakefile::RemoveDefineFlag(const char* flag, std::string::size_type len,
}
}
-void cmMakefile::AddCompileOption(const char* option)
+void cmMakefile::RemoveDefineFlag(std::string const& flag)
+{
+ // Check the length of the flag to remove.
+ if (flag.empty()) {
+ return;
+ }
+
+ // Update the string used for the old DEFINITIONS property.
+ s_RemoveDefineFlag(flag, this->DefineFlagsOrig);
+
+ // If this is really a definition, update COMPILE_DEFINITIONS.
+ if (this->ParseDefineFlag(flag, true)) {
+ return;
+ }
+
+ // Remove this flag that does not look like a definition.
+ s_RemoveDefineFlag(flag, this->DefineFlags);
+}
+
+void cmMakefile::AddCompileDefinition(std::string const& option)
+{
+ this->AppendProperty("COMPILE_DEFINITIONS", option.c_str());
+}
+
+void cmMakefile::AddCompileOption(std::string const& option)
+{
+ this->AppendProperty("COMPILE_OPTIONS", option.c_str());
+}
+
+void cmMakefile::AddLinkOption(std::string const& option)
{
- this->AppendProperty("COMPILE_OPTIONS", option);
+ this->AppendProperty("LINK_OPTIONS", option.c_str());
+}
+
+void cmMakefile::AddLinkDirectory(std::string const& directory, bool before)
+{
+ cmListFileBacktrace lfbt = this->GetBacktrace();
+ if (before) {
+ this->StateSnapshot.GetDirectory().PrependLinkDirectoriesEntry(directory,
+ lfbt);
+ } else {
+ this->StateSnapshot.GetDirectory().AppendLinkDirectoriesEntry(directory,
+ lfbt);
+ }
}
bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
@@ -1149,18 +1373,18 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
static cmsys::RegularExpression valid("^[-/]D[A-Za-z_][A-Za-z0-9_]*(=.*)?$");
// Make sure the definition matches.
- if (!valid.find(def.c_str())) {
+ if (!valid.find(def)) {
return false;
}
// Definitions with non-trivial values require a policy check.
static cmsys::RegularExpression trivial(
"^[-/]D[A-Za-z_][A-Za-z0-9_]*(=[A-Za-z0-9_.]+)?$");
- if (!trivial.find(def.c_str())) {
+ if (!trivial.find(def)) {
// This definition has a non-trivial value.
switch (this->GetPolicyStatus(cmPolicies::CMP0005)) {
case cmPolicies::WARN:
- this->IssueMessage(cmake::AUTHOR_WARNING,
+ this->IssueMessage(MessageType::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(cmPolicies::CMP0005));
CM_FALLTHROUGH;
case cmPolicies::OLD:
@@ -1170,7 +1394,7 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
this->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0005));
return false;
case cmPolicies::NEW:
@@ -1186,13 +1410,11 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
if (remove) {
if (const char* cdefs = this->GetProperty("COMPILE_DEFINITIONS")) {
// Expand the list.
- std::vector<std::string> defs;
- cmSystemTools::ExpandListArgument(cdefs, defs);
+ std::vector<std::string> defs = cmExpandedList(cdefs);
// Recompose the list without the definition.
- std::vector<std::string>::const_iterator defEnd =
- std::remove(defs.begin(), defs.end(), define);
- std::vector<std::string>::const_iterator defBegin = defs.begin();
+ auto defEnd = std::remove(defs.begin(), defs.end(), define);
+ auto defBegin = defs.begin();
std::string ndefs = cmJoin(cmMakeRange(defBegin, defEnd), ";");
// Store the new list.
@@ -1227,22 +1449,20 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
parent->GetProperty("COMPILE_DEFINITIONS"));
std::vector<std::string> configs;
this->GetConfigurations(configs);
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
- std::string defPropName = "COMPILE_DEFINITIONS_";
- defPropName += cmSystemTools::UpperCase(*ci);
+ for (std::string const& config : configs) {
+ std::string defPropName =
+ cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(config));
const char* prop = parent->GetProperty(defPropName);
this->SetProperty(defPropName, prop);
}
}
+ // labels
+ this->SetProperty("LABELS", parent->GetProperty("LABELS"));
+
// link libraries
this->SetProperty("LINK_LIBRARIES", parent->GetProperty("LINK_LIBRARIES"));
- // link directories
- this->SetProperty("LINK_DIRECTORIES",
- parent->GetProperty("LINK_DIRECTORIES"));
-
// the initial project name
this->StateSnapshot.SetProjectName(parent->StateSnapshot.GetProjectName());
@@ -1251,6 +1471,9 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
// Imported targets.
this->ImportedTargets = parent->ImportedTargets;
+
+ // Recursion depth.
+ this->RecursionDepth = parent->RecursionDepth;
}
void cmMakefile::PushFunctionScope(std::string const& fileName,
@@ -1262,7 +1485,7 @@ void cmMakefile::PushFunctionScope(std::string const& fileName,
this->PushLoopBlockBarrier();
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->GetGlobalGenerator()->GetFileLockPool().PushFunctionScope();
#endif
@@ -1279,7 +1502,7 @@ void cmMakefile::PopFunctionScope(bool reportError)
this->PopFunctionBlockerBarrier(reportError);
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->GetGlobalGenerator()->GetFileLockPool().PopFunctionScope();
#endif
@@ -1321,8 +1544,8 @@ public:
, ReportError(true)
{
std::string currentStart =
- this->Makefile->StateSnapshot.GetDirectory().GetCurrentSource();
- currentStart += "/CMakeLists.txt";
+ cmStrCat(this->Makefile->StateSnapshot.GetDirectory().GetCurrentSource(),
+ "/CMakeLists.txt");
this->Makefile->StateSnapshot.SetListFile(currentStart);
this->Makefile->StateSnapshot =
this->Makefile->StateSnapshot.GetState()->CreatePolicyScopeSnapshot(
@@ -1334,7 +1557,7 @@ public:
this->Snapshot = this->GG->GetCMakeInstance()->GetCurrentSnapshot();
this->GG->GetCMakeInstance()->SetCurrentSnapshot(this->Snapshot);
this->GG->SetCurrentMakefile(mf);
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->GG->GetFileLockPool().PushFileScope();
#endif
}
@@ -1343,7 +1566,7 @@ public:
{
this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
this->Makefile->PopSnapshot(this->ReportError);
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->GG->GetFileLockPool().PopFileScope();
#endif
this->GG->SetCurrentMakefile(this->CurrentMakefile);
@@ -1352,6 +1575,9 @@ public:
void Quiet() { this->ReportError = false; }
+ BuildsystemFileScope(const BuildsystemFileScope&) = delete;
+ BuildsystemFileScope& operator=(const BuildsystemFileScope&) = delete;
+
private:
cmMakefile* Makefile;
cmGlobalGenerator* GG;
@@ -1362,9 +1588,8 @@ private:
void cmMakefile::Configure()
{
- std::string currentStart =
- this->StateSnapshot.GetDirectory().GetCurrentSource();
- currentStart += "/CMakeLists.txt";
+ std::string currentStart = cmStrCat(
+ this->StateSnapshot.GetDirectory().GetCurrentSource(), "/CMakeLists.txt");
// Add the bottom of all backtraces within this directory.
// We will never pop this scope because it should be available
@@ -1374,12 +1599,12 @@ void cmMakefile::Configure()
BuildsystemFileScope scope(this);
// make sure the CMakeFiles dir is there
- std::string filesDir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
- filesDir += cmake::GetCMakeFilesDirectory();
- cmSystemTools::MakeDirectory(filesDir.c_str());
+ std::string filesDir = cmStrCat(
+ this->StateSnapshot.GetDirectory().GetCurrentBinary(), "/CMakeFiles");
+ cmSystemTools::MakeDirectory(filesDir);
- assert(cmSystemTools::FileExists(currentStart.c_str(), true));
- this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str());
+ assert(cmSystemTools::FileExists(currentStart, true));
+ this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart);
cmListFile listFile;
if (!listFile.ParseFile(currentStart.c_str(), this->GetMessenger(),
@@ -1389,10 +1614,8 @@ void cmMakefile::Configure()
if (this->IsRootMakefile()) {
bool hasVersion = false;
// search for the right policy command
- for (std::vector<cmListFileFunction>::iterator i =
- listFile.Functions.begin();
- i != listFile.Functions.end(); ++i) {
- if (cmSystemTools::LowerCase(i->Name) == "cmake_minimum_required") {
+ for (cmListFileFunction const& func : listFile.Functions) {
+ if (func.Name.Lower == "cmake_minimum_required") {
hasVersion = true;
break;
}
@@ -1418,11 +1641,8 @@ void cmMakefile::Configure()
allowedCommands.insert("option");
allowedCommands.insert("message");
isProblem = false;
- for (std::vector<cmListFileFunction>::iterator i =
- listFile.Functions.begin();
- i != listFile.Functions.end(); ++i) {
- std::string name = cmSystemTools::LowerCase(i->Name);
- if (allowedCommands.find(name) == allowedCommands.end()) {
+ for (cmListFileFunction const& func : listFile.Functions) {
+ if (!cmContains(allowedCommands, func.Name.Lower)) {
isProblem = true;
break;
}
@@ -1435,25 +1655,35 @@ void cmMakefile::Configure()
this->SetCheckCMP0000(true);
// Implicitly set the version for the user.
- this->SetPolicyVersion("2.4");
+ this->SetPolicyVersion("2.4", std::string());
}
}
bool hasProject = false;
// search for a project command
- for (std::vector<cmListFileFunction>::iterator i =
- listFile.Functions.begin();
- i != listFile.Functions.end(); ++i) {
- if (cmSystemTools::LowerCase(i->Name) == "project") {
+ for (cmListFileFunction const& func : listFile.Functions) {
+ if (func.Name.Lower == "project") {
hasProject = true;
break;
}
}
// if no project command is found, add one
if (!hasProject) {
+ this->GetCMakeInstance()->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ "No project() command is present. The top-level CMakeLists.txt "
+ "file must contain a literal, direct call to the project() command. "
+ "Add a line of code such as\n"
+ " project(ProjectName)\n"
+ "near the top of the file, but after cmake_minimum_required().\n"
+ "CMake is pretending there is a \"project(Project)\" command on "
+ "the first line.",
+ this->Backtrace);
cmListFileFunction project;
- project.Name = "PROJECT";
- cmListFileArgument prj("Project", cmListFileArgument::Unquoted, 0);
- project.Arguments.push_back(prj);
+ project.Name.Lower = "project";
+ project.Arguments.emplace_back("Project", cmListFileArgument::Unquoted,
+ 0);
+ project.Arguments.emplace_back("__CMAKE_INJECTED_PROJECT_COMMAND__",
+ cmListFileArgument::Unquoted, 0);
listFile.Functions.insert(listFile.Functions.begin(), project);
}
}
@@ -1467,7 +1697,7 @@ void cmMakefile::Configure()
std::vector<cmMakefile*> subdirs = this->UnConfiguredDirectories;
// for each subdir recurse
- std::vector<cmMakefile*>::iterator sdi = subdirs.begin();
+ auto sdi = subdirs.begin();
for (; sdi != subdirs.end(); ++sdi) {
(*sdi)->StateSnapshot.InitializeFromParent_ForSubdirsCommand();
this->ConfigureSubDirectory(*sdi);
@@ -1481,9 +1711,8 @@ void cmMakefile::ConfigureSubDirectory(cmMakefile* mf)
mf->InitializeFromParent(this);
std::string currentStart = mf->GetCurrentSourceDirectory();
if (this->GetCMakeInstance()->GetDebugOutput()) {
- std::string msg = " Entering ";
- msg += currentStart;
- cmSystemTools::Message(msg.c_str());
+ std::string msg = cmStrCat(" Entering ", currentStart);
+ cmSystemTools::Message(msg);
}
std::string const currentStartFile = currentStart + "/CMakeLists.txt";
@@ -1506,7 +1735,7 @@ void cmMakefile::ConfigureSubDirectory(cmMakefile* mf)
<< "\n"
<< cmPolicies::GetPolicyWarning(cmPolicies::CMP0014);
/* clang-format on */
- this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ this->IssueMessage(MessageType::AUTHOR_WARNING, e.str());
case cmPolicies::OLD:
// OLD behavior does not warn.
break;
@@ -1516,7 +1745,7 @@ void cmMakefile::ConfigureSubDirectory(cmMakefile* mf)
CM_FALLTHROUGH;
case cmPolicies::NEW:
// NEW behavior prints the error.
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->IssueMessage(MessageType::FATAL_ERROR, e.str());
}
return;
}
@@ -1524,9 +1753,9 @@ void cmMakefile::ConfigureSubDirectory(cmMakefile* mf)
mf->Configure();
if (this->GetCMakeInstance()->GetDebugOutput()) {
- std::string msg = " Returning to ";
- msg += this->GetCurrentSourceDirectory();
- cmSystemTools::Message(msg.c_str());
+ std::string msg =
+ cmStrCat(" Returning to ", this->GetCurrentSourceDirectory());
+ cmSystemTools::Message(msg);
}
}
@@ -1545,7 +1774,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
newSnapshot.GetDirectory().SetCurrentSource(srcPath);
newSnapshot.GetDirectory().SetCurrentBinary(binPath);
- cmSystemTools::MakeDirectory(binPath.c_str());
+ cmSystemTools::MakeDirectory(binPath);
cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
this->GetGlobalGenerator()->AddMakefile(subMf);
@@ -1559,14 +1788,17 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
} else {
this->UnConfiguredDirectories.push_back(subMf);
}
+
+ this->AddInstallGenerator(new cmInstallSubdirectoryGenerator(
+ subMf, binPath.c_str(), excludeFromAll));
}
-const char* cmMakefile::GetCurrentSourceDirectory() const
+const std::string& cmMakefile::GetCurrentSourceDirectory() const
{
return this->StateSnapshot.GetDirectory().GetCurrentSource();
}
-const char* cmMakefile::GetCurrentBinaryDirectory() const
+const std::string& cmMakefile::GetCurrentBinaryDirectory() const
{
return this->StateSnapshot.GetDirectory().GetCurrentBinary();
}
@@ -1575,9 +1807,8 @@ std::vector<cmTarget*> cmMakefile::GetImportedTargets() const
{
std::vector<cmTarget*> tgts;
tgts.reserve(this->ImportedTargets.size());
- for (TargetMap::const_iterator it = this->ImportedTargets.begin();
- it != this->ImportedTargets.end(); ++it) {
- tgts.push_back(it->second);
+ for (auto const& impTarget : this->ImportedTargets) {
+ tgts.push_back(impTarget.second);
}
return tgts;
}
@@ -1600,9 +1831,8 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string>& incs,
}
// Property on each target:
- for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end();
- ++l) {
- cmTarget& t = l->second;
+ for (auto& target : this->Targets) {
+ cmTarget& t = target.second;
t.InsertInclude(entryString, lfbt, before);
}
}
@@ -1615,58 +1845,60 @@ void cmMakefile::AddSystemIncludeDirectories(const std::set<std::string>& incs)
this->SystemIncludeDirectories.insert(incs.begin(), incs.end());
- for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end();
- ++l) {
- cmTarget& t = l->second;
+ for (auto& target : this->Targets) {
+ cmTarget& t = target.second;
t.AddSystemIncludeDirectories(incs);
}
}
-void cmMakefile::AddDefinition(const std::string& name, const char* value)
+void cmMakefile::AddDefinition(const std::string& name, cm::string_view value)
{
- if (!value) {
- return;
- }
-
if (this->VariableInitialized(name)) {
this->LogUnused("changing definition", name);
}
this->StateSnapshot.SetDefinition(name, value);
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmVariableWatch* vv = this->GetVariableWatch();
if (vv) {
vv->VariableAccessed(name, cmVariableWatch::VARIABLE_MODIFIED_ACCESS,
- value, this);
+ value.data(), this);
}
#endif
}
+void cmMakefile::AddDefinitionBool(const std::string& name, bool value)
+{
+ this->AddDefinition(name, value ? "ON" : "OFF");
+}
+
void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
const char* doc,
cmStateEnums::CacheEntryType type,
bool force)
{
- const char* existingValue = this->GetState()->GetInitializedCacheValue(name);
+ const std::string* existingValue =
+ this->GetState()->GetInitializedCacheValue(name);
// must be outside the following if() to keep it alive long enough
std::string nvalue;
- if (existingValue && (this->GetState()->GetCacheEntryType(name) ==
- cmStateEnums::UNINITIALIZED)) {
+ if (existingValue &&
+ (this->GetState()->GetCacheEntryType(name) ==
+ cmStateEnums::UNINITIALIZED)) {
// if this is not a force, then use the value from the cache
// if it is a force, then use the value being passed in
if (!force) {
- value = existingValue;
+ 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 : "";
- cmSystemTools::ExpandListArgument(nvalue, files);
- nvalue = "";
+ cmExpandList(nvalue, files);
+ nvalue.clear();
for (cc = 0; cc < files.size(); cc++) {
- if (!cmSystemTools::IsOff(files[cc].c_str())) {
+ if (!cmIsOff(files[cc])) {
files[cc] = cmSystemTools::CollapseFullPath(files[cc]);
}
if (cc > 0) {
@@ -1676,7 +1908,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
}
this->GetCMakeInstance()->AddCacheEntry(name, nvalue.c_str(), doc, type);
- nvalue = this->GetState()->GetInitializedCacheValue(name);
+ nvalue = *this->GetState()->GetInitializedCacheValue(name);
value = nvalue.c_str();
}
}
@@ -1685,32 +1917,13 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
this->StateSnapshot.RemoveDefinition(name);
}
-void cmMakefile::AddDefinition(const std::string& name, bool value)
-{
- if (this->VariableInitialized(name)) {
- this->LogUnused("changing definition", name);
- }
-
- this->StateSnapshot.SetDefinition(name, value ? "ON" : "OFF");
-
-#ifdef CMAKE_BUILD_WITH_CMAKE
- cmVariableWatch* vv = this->GetVariableWatch();
- if (vv) {
- vv->VariableAccessed(name, cmVariableWatch::VARIABLE_MODIFIED_ACCESS,
- value ? "ON" : "OFF", this);
- }
-#endif
-}
-
void cmMakefile::CheckForUnusedVariables() const
{
if (!this->WarnUnused) {
return;
}
- const std::vector<std::string>& unused = this->StateSnapshot.UnusedKeys();
- std::vector<std::string>::const_iterator it = unused.begin();
- for (; it != unused.end(); ++it) {
- this->LogUnused("out of scope", *it);
+ for (const std::string& key : this->StateSnapshot.UnusedKeys()) {
+ this->LogUnused("out of scope", key);
}
}
@@ -1724,6 +1937,23 @@ bool cmMakefile::VariableInitialized(const std::string& var) const
return this->StateSnapshot.IsInitialized(var);
}
+void cmMakefile::MaybeWarnUninitialized(std::string const& variable,
+ const char* sourceFilename) const
+{
+ // check to see if we need to print a warning
+ // if strict mode is on and the variable has
+ // not been "cleared"/initialized with a set(foo ) call
+ if (this->GetCMakeInstance()->GetWarnUninitialized() &&
+ !this->VariableInitialized(variable)) {
+ if (this->CheckSystemVars ||
+ (sourceFilename && this->IsProjectFile(sourceFilename))) {
+ std::ostringstream msg;
+ msg << "uninitialized variable \'" << variable << "\'";
+ this->IssueMessage(MessageType::AUTHOR_WARNING, msg.str());
+ }
+ }
+}
+
void cmMakefile::LogUnused(const char* reason, const std::string& name) const
{
if (this->WarnUnused) {
@@ -1731,18 +1961,13 @@ void cmMakefile::LogUnused(const char* reason, const std::string& name) const
if (!this->ExecutionStatusStack.empty()) {
path = this->GetExecutionContext().FilePath;
} else {
- path = this->GetCurrentSourceDirectory();
- path += "/CMakeLists.txt";
+ path = cmStrCat(this->GetCurrentSourceDirectory(), "/CMakeLists.txt");
}
- if (this->CheckSystemVars ||
- cmSystemTools::IsSubDirectory(path, this->GetHomeDirectory()) ||
- (cmSystemTools::IsSubDirectory(path, this->GetHomeOutputDirectory()) &&
- !cmSystemTools::IsSubDirectory(path,
- cmake::GetCMakeFilesDirectory()))) {
+ if (this->CheckSystemVars || this->IsProjectFile(path.c_str())) {
std::ostringstream msg;
msg << "unused variable (" << reason << ") \'" << name << "\'";
- this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
+ this->IssueMessage(MessageType::AUTHOR_WARNING, msg.str());
}
}
}
@@ -1753,11 +1978,11 @@ void cmMakefile::RemoveDefinition(const std::string& name)
this->LogUnused("unsetting", name);
}
this->StateSnapshot.RemoveDefinition(name);
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmVariableWatch* vv = this->GetVariableWatch();
if (vv) {
vv->VariableAccessed(name, cmVariableWatch::VARIABLE_REMOVED_ACCESS,
- CM_NULLPTR, this);
+ nullptr, this);
}
#endif
}
@@ -1782,27 +2007,11 @@ void cmMakefile::AddGlobalLinkInformation(cmTarget& target)
return;
default:;
}
- if (const char* linkDirsProp = this->GetProperty("LINK_DIRECTORIES")) {
- std::vector<std::string> linkDirs;
- cmSystemTools::ExpandListArgument(linkDirsProp, linkDirs);
-
- for (std::vector<std::string>::iterator j = linkDirs.begin();
- j != linkDirs.end(); ++j) {
- std::string newdir = *j;
- // remove trailing slashes
- if (*j->rbegin() == '/') {
- newdir = j->substr(0, j->size() - 1);
- }
- target.AddLinkDirectory(*j);
- }
- }
if (const char* linkLibsProp = this->GetProperty("LINK_LIBRARIES")) {
- std::vector<std::string> linkLibs;
- cmSystemTools::ExpandListArgument(linkLibsProp, linkLibs);
+ std::vector<std::string> linkLibs = cmExpandedList(linkLibsProp);
- for (std::vector<std::string>::iterator j = linkLibs.begin();
- j != linkLibs.end(); ++j) {
+ for (auto j = linkLibs.begin(); j != linkLibs.end(); ++j) {
std::string libraryName = *j;
cmTargetLinkLibraryType libType = GENERAL_LibraryType;
if (libraryName == "optimized") {
@@ -1844,7 +2053,7 @@ cmTarget* cmMakefile::AddLibrary(const std::string& lname,
// Clear its dependencies. Otherwise, dependencies might persist
// over changes in CMakeLists.txt, making the information stale and
// hence useless.
- target->ClearDependencyInformation(*this, lname);
+ target->ClearDependencyInformation(*this);
if (excludeFromAll) {
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
@@ -1853,7 +2062,7 @@ cmTarget* cmMakefile::AddLibrary(const std::string& lname,
return target;
}
-cmTarget* cmMakefile::AddExecutable(const char* exeName,
+cmTarget* cmMakefile::AddExecutable(const std::string& exeName,
const std::vector<std::string>& srcs,
bool excludeFromAll)
{
@@ -1869,86 +2078,248 @@ cmTarget* cmMakefile::AddExecutable(const char* exeName,
cmTarget* cmMakefile::AddNewTarget(cmStateEnums::TargetType type,
const std::string& name)
{
- cmTargets::iterator it =
+ auto it =
this->Targets
- .insert(cmTargets::value_type(
- name, cmTarget(name, type, cmTarget::VisibilityNormal, this)))
+ .emplace(name, cmTarget(name, type, cmTarget::VisibilityNormal, this))
.first;
+ this->OrderedTargets.push_back(&it->second);
this->GetGlobalGenerator()->IndexTarget(&it->second);
this->GetStateSnapshot().GetDirectory().AddNormalTargetName(name);
return &it->second;
}
+cmTarget* cmMakefile::AddNewUtilityTarget(const std::string& utilityName,
+ cmCommandOrigin origin,
+ bool excludeFromAll)
+{
+ cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName);
+ target->SetIsGeneratorProvided(origin == cmCommandOrigin::Generator);
+ if (excludeFromAll) {
+ target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
+ }
+ return target;
+}
+
+namespace {
+bool AnyOutputMatches(const std::string& name,
+ const std::vector<std::string>& outputs)
+{
+ for (std::string const& output : outputs) {
+ std::string::size_type pos = output.rfind(name);
+ // If the output matches exactly
+ if (pos != std::string::npos && pos == output.size() - name.size() &&
+ (pos == 0 || output[pos - 1] == '/')) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool AnyTargetCommandOutputMatches(
+ const std::string& name, const std::vector<cmCustomCommand>& commands)
+{
+ for (cmCustomCommand const& command : commands) {
+ if (AnyOutputMatches(name, command.GetByproducts())) {
+ return true;
+ }
+ }
+ return false;
+}
+}
+
+cmTarget* cmMakefile::LinearGetTargetWithOutput(const std::string& name) const
+{
+ // We go through the ordered vector of targets to get reproducible results
+ // should multiple names match.
+ for (cmTarget* t : this->OrderedTargets) {
+ // Does the output of any command match the source file name?
+ if (AnyTargetCommandOutputMatches(name, t->GetPreBuildCommands())) {
+ return t;
+ }
+ if (AnyTargetCommandOutputMatches(name, t->GetPreLinkCommands())) {
+ return t;
+ }
+ if (AnyTargetCommandOutputMatches(name, t->GetPostBuildCommands())) {
+ return t;
+ }
+ }
+ return nullptr;
+}
+
cmSourceFile* cmMakefile::LinearGetSourceFileWithOutput(
- const std::string& name) const
+ const std::string& name, cmSourceOutputKind kind, bool& byproduct) const
{
- std::string out;
+ // Outputs take precedence over byproducts.
+ byproduct = false;
+ cmSourceFile* fallback = nullptr;
- // look through all the source files that have custom commands
- // and see if the custom command has the passed source file as an output
- for (std::vector<cmSourceFile*>::const_iterator i =
- this->SourceFiles.begin();
- i != this->SourceFiles.end(); ++i) {
- // does this source file have a custom command?
- if ((*i)->GetCustomCommand()) {
+ // Look through all the source files that have custom commands and see if the
+ // custom command has the passed source file as an output.
+ for (cmSourceFile* src : this->SourceFiles) {
+ // Does this source file have a custom command?
+ if (src->GetCustomCommand()) {
// Does the output of the custom command match the source file name?
- const std::vector<std::string>& outputs =
- (*i)->GetCustomCommand()->GetOutputs();
- for (std::vector<std::string>::const_iterator o = outputs.begin();
- o != outputs.end(); ++o) {
- out = *o;
- std::string::size_type pos = out.rfind(name);
- // If the output matches exactly
- if (pos != std::string::npos && pos == out.size() - name.size() &&
- (pos == 0 || out[pos - 1] == '/')) {
- return *i;
+ if (AnyOutputMatches(name, src->GetCustomCommand()->GetOutputs())) {
+ // Return the first matching output.
+ return src;
+ }
+ if (kind == cmSourceOutputKind::OutputOrByproduct) {
+ if (AnyOutputMatches(name, src->GetCustomCommand()->GetByproducts())) {
+ // Do not return the source yet as there might be a matching output.
+ fallback = src;
}
}
}
}
- // otherwise return NULL
- return CM_NULLPTR;
+ // Did we find a byproduct?
+ byproduct = fallback != nullptr;
+ return fallback;
}
-cmSourceFile* cmMakefile::GetSourceFileWithOutput(
+cmSourcesWithOutput cmMakefile::GetSourcesWithOutput(
const std::string& name) const
{
+ // Linear search? Also see GetSourceFileWithOutput for detail.
+ if (!cmSystemTools::FileIsFullPath(name)) {
+ cmSourcesWithOutput sources;
+ sources.Target = this->LinearGetTargetWithOutput(name);
+ sources.Source = this->LinearGetSourceFileWithOutput(
+ name, cmSourceOutputKind::OutputOrByproduct, sources.SourceIsByproduct);
+ return sources;
+ }
+ // Otherwise we use an efficient lookup map.
+ auto o = this->OutputToSource.find(name);
+ if (o != this->OutputToSource.end()) {
+ return o->second.Sources;
+ }
+ return {};
+}
+
+cmSourceFile* cmMakefile::GetSourceFileWithOutput(
+ const std::string& name, cmSourceOutputKind kind) const
+{
// If the queried path is not absolute we use the backward compatible
// linear-time search for an output with a matching suffix.
- if (!cmSystemTools::FileIsFullPath(name.c_str())) {
- return this->LinearGetSourceFileWithOutput(name);
+ if (!cmSystemTools::FileIsFullPath(name)) {
+ bool byproduct = false;
+ return this->LinearGetSourceFileWithOutput(name, kind, byproduct);
}
// Otherwise we use an efficient lookup map.
- OutputToSourceMap::const_iterator o = this->OutputToSource.find(name);
- if (o != this->OutputToSource.end()) {
- return (*o).second;
+ auto o = this->OutputToSource.find(name);
+ if (o != this->OutputToSource.end() &&
+ (!o->second.Sources.SourceIsByproduct ||
+ kind == cmSourceOutputKind::OutputOrByproduct)) {
+ // Source file could also be null pointer for example if we found the
+ // byproduct of a utility target or a PRE_BUILD, PRE_LINK, or POST_BUILD
+ // command of a target.
+ return o->second.Sources.Source;
+ }
+ return nullptr;
+}
+
+bool cmMakefile::MightHaveCustomCommand(const std::string& name) const
+{
+ // This will have to be changed for delaying custom command creation, because
+ // GetSourceFileWithOutput requires the command to be already created.
+ if (cmSourceFile* sf = this->GetSourceFileWithOutput(name)) {
+ if (sf->GetCustomCommand()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void cmMakefile::AddTargetByproducts(
+ cmTarget* target, const std::vector<std::string>& byproducts)
+{
+ for (std::string const& o : byproducts) {
+ this->UpdateOutputToSourceMap(o, target);
+ }
+}
+
+void cmMakefile::AddSourceOutputs(cmSourceFile* source,
+ const std::vector<std::string>& outputs,
+ const std::vector<std::string>& byproducts)
+{
+ for (std::string const& o : outputs) {
+ this->UpdateOutputToSourceMap(o, source, false);
+ }
+ for (std::string const& o : byproducts) {
+ this->UpdateOutputToSourceMap(o, source, true);
+ }
+}
+
+void cmMakefile::UpdateOutputToSourceMap(std::string const& byproduct,
+ cmTarget* target)
+{
+ SourceEntry entry;
+ entry.Sources.Target = target;
+
+ auto pr = this->OutputToSource.emplace(byproduct, entry);
+ if (!pr.second) {
+ SourceEntry& current = pr.first->second;
+ // Has the target already been set?
+ if (!current.Sources.Target) {
+ current.Sources.Target = target;
+ } else {
+ // Multiple custom commands/targets produce the same output (source file
+ // or target). See also comment in other UpdateOutputToSourceMap
+ // overload.
+ //
+ // TODO: Warn the user about this case.
+ }
}
- return CM_NULLPTR;
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+void cmMakefile::UpdateOutputToSourceMap(std::string const& output,
+ cmSourceFile* source, bool byproduct)
+{
+ SourceEntry entry;
+ entry.Sources.Source = source;
+ entry.Sources.SourceIsByproduct = byproduct;
+
+ auto pr = this->OutputToSource.emplace(output, entry);
+ if (!pr.second) {
+ SourceEntry& current = pr.first->second;
+ // Outputs take precedence over byproducts
+ if (!current.Sources.Source ||
+ (current.Sources.SourceIsByproduct && !byproduct)) {
+ current.Sources.Source = source;
+ current.Sources.SourceIsByproduct = false;
+ } else {
+ // Multiple custom commands produce the same output but may
+ // be attached to a different source file (MAIN_DEPENDENCY).
+ // LinearGetSourceFileWithOutput would return the first one,
+ // so keep the mapping for the first one.
+ //
+ // TODO: Warn the user about this case. However, the VS 8 generator
+ // triggers it for separate generate.stamp rules in ZERO_CHECK and
+ // individual targets.
+ }
+ }
+}
+
+#if !defined(CMAKE_BOOTSTRAP)
cmSourceGroup* cmMakefile::GetSourceGroup(
const std::vector<std::string>& name) const
{
- cmSourceGroup* sg = CM_NULLPTR;
+ cmSourceGroup* sg = nullptr;
// first look for source group starting with the same as the one we want
- for (std::vector<cmSourceGroup>::const_iterator sgIt =
- this->SourceGroups.begin();
- sgIt != this->SourceGroups.end(); ++sgIt) {
- std::string sgName = sgIt->GetName();
+ for (cmSourceGroup const& srcGroup : this->SourceGroups) {
+ std::string const& sgName = srcGroup.GetName();
if (sgName == name[0]) {
- sg = const_cast<cmSourceGroup*>(&(*sgIt));
+ sg = const_cast<cmSourceGroup*>(&srcGroup);
break;
}
}
- if (sg != CM_NULLPTR) {
+ if (sg != nullptr) {
// iterate through its children to find match source group
for (unsigned int i = 1; i < name.size(); ++i) {
- sg = sg->LookupChild(name[i].c_str());
- if (sg == CM_NULLPTR) {
+ sg = sg->LookupChild(name[i]);
+ if (sg == nullptr) {
break;
}
}
@@ -1966,14 +2337,14 @@ void cmMakefile::AddSourceGroup(const std::string& name, const char* regex)
void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
const char* regex)
{
- cmSourceGroup* sg = CM_NULLPTR;
+ cmSourceGroup* sg = nullptr;
std::vector<std::string> currentName;
int i = 0;
const int lastElement = static_cast<int>(name.size() - 1);
for (i = lastElement; i >= 0; --i) {
currentName.assign(name.begin(), name.begin() + i + 1);
sg = this->GetSourceGroup(currentName);
- if (sg != CM_NULLPTR) {
+ if (sg != nullptr) {
break;
}
}
@@ -1991,7 +2362,7 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
if (i == -1) {
// group does not exist nor belong to any existing group
// add its first component
- this->SourceGroups.push_back(cmSourceGroup(name[0].c_str(), regex));
+ this->SourceGroups.emplace_back(name[0], regex);
sg = this->GetSourceGroup(currentName);
i = 0; // last component found
}
@@ -2001,14 +2372,62 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
}
// build the whole source group path
for (++i; i <= lastElement; ++i) {
- sg->AddChild(
- cmSourceGroup(name[i].c_str(), CM_NULLPTR, sg->GetFullName()));
- sg = sg->LookupChild(name[i].c_str());
+ sg->AddChild(cmSourceGroup(name[i], nullptr, sg->GetFullName().c_str()));
+ sg = sg->LookupChild(name[i]);
}
sg->SetGroupRegex(regex);
}
+cmSourceGroup* cmMakefile::GetOrCreateSourceGroup(
+ const std::vector<std::string>& folders)
+{
+ cmSourceGroup* sg = this->GetSourceGroup(folders);
+ if (sg == nullptr) {
+ this->AddSourceGroup(folders);
+ sg = this->GetSourceGroup(folders);
+ }
+ return sg;
+}
+
+cmSourceGroup* cmMakefile::GetOrCreateSourceGroup(const std::string& name)
+{
+ const char* delimiter = this->GetDefinition("SOURCE_GROUP_DELIMITER");
+ if (delimiter == nullptr) {
+ delimiter = "\\";
+ }
+ return this->GetOrCreateSourceGroup(cmTokenize(name, delimiter));
+}
+
+/**
+ * Find a source group whose regular expression matches the filename
+ * part of the given source name. Search backward through the list of
+ * source groups, and take the first matching group found. This way
+ * non-inherited SOURCE_GROUP commands will have precedence over
+ * inherited ones.
+ */
+cmSourceGroup* cmMakefile::FindSourceGroup(
+ const std::string& source, std::vector<cmSourceGroup>& groups) const
+{
+ // First search for a group that lists the file explicitly.
+ for (auto sg = groups.rbegin(); sg != groups.rend(); ++sg) {
+ cmSourceGroup* result = sg->MatchChildrenFiles(source);
+ if (result) {
+ return result;
+ }
+ }
+
+ // Now search for a group whose regex matches the file.
+ for (auto sg = groups.rbegin(); sg != groups.rend(); ++sg) {
+ cmSourceGroup* result = sg->MatchChildrenRegex(source);
+ if (result) {
+ return result;
+ }
+ }
+
+ // Shouldn't get here, but just in case, return the default group.
+ return groups.data();
+}
#endif
static bool mightExpandVariablesCMP0019(const char* s)
@@ -2041,9 +2460,8 @@ void cmMakefile::ExpandVariablesCMP0019()
}
// Also for each target's INCLUDE_DIRECTORIES property:
- for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end();
- ++l) {
- cmTarget& t = l->second;
+ for (auto& target : this->Targets) {
+ cmTarget& t = target.second;
if (t.GetType() == cmStateEnums::INTERFACE_LIBRARY ||
t.GetType() == cmStateEnums::GLOBAL_TARGET) {
continue;
@@ -2081,11 +2499,9 @@ void cmMakefile::ExpandVariablesCMP0019()
}
if (const char* linkLibsProp = this->GetProperty("LINK_LIBRARIES")) {
- std::vector<std::string> linkLibs;
- cmSystemTools::ExpandListArgument(linkLibsProp, linkLibs);
+ std::vector<std::string> linkLibs = cmExpandedList(linkLibsProp);
- for (std::vector<std::string>::iterator l = linkLibs.begin();
- l != linkLibs.end(); ++l) {
+ for (auto l = linkLibs.begin(); l != linkLibs.end(); ++l) {
std::string libName = *l;
if (libName == "optimized") {
++l;
@@ -2117,15 +2533,15 @@ void cmMakefile::ExpandVariablesCMP0019()
<< "The following variable evaluations were encountered:\n"
<< w.str();
/* clang-format on */
- this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, m.str(),
- this->Backtrace);
+ this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING,
+ m.str(), this->Backtrace);
}
}
bool cmMakefile::IsOn(const std::string& name) const
{
const char* value = this->GetDefinition(name);
- return cmSystemTools::IsOn(value);
+ return cmIsOn(value);
}
bool cmMakefile::IsSet(const std::string& name) const
@@ -2139,7 +2555,7 @@ bool cmMakefile::IsSet(const std::string& name) const
return false;
}
- if (cmSystemTools::IsNOTFOUND(value)) {
+ if (cmIsNOTFOUND(value)) {
return false;
}
@@ -2179,25 +2595,38 @@ bool cmMakefile::PlatformIsx32() const
return false;
}
-bool cmMakefile::PlatformIsAppleIos() const
+cmMakefile::AppleSDK cmMakefile::GetAppleSDKType() const
{
std::string sdkRoot;
sdkRoot = this->GetSafeDefinition("CMAKE_OSX_SYSROOT");
sdkRoot = cmSystemTools::LowerCase(sdkRoot);
- const std::string embedded[] = {
- "appletvos", "appletvsimulator", "iphoneos",
- "iphonesimulator", "watchos", "watchsimulator",
+ struct
+ {
+ std::string name;
+ AppleSDK sdk;
+ } const sdkDatabase[]{
+ { "appletvos", AppleSDK::AppleTVOS },
+ { "appletvsimulator", AppleSDK::AppleTVSimulator },
+ { "iphoneos", AppleSDK::IPhoneOS },
+ { "iphonesimulator", AppleSDK::IPhoneSimulator },
+ { "watchos", AppleSDK::WatchOS },
+ { "watchsimulator", AppleSDK::WatchSimulator },
};
- for (size_t i = 0; i < sizeof(embedded) / sizeof(embedded[0]); ++i) {
- if (sdkRoot.find(embedded[i]) == 0 ||
- sdkRoot.find(std::string("/") + embedded[i]) != std::string::npos) {
- return true;
+ for (auto const& entry : sdkDatabase) {
+ if (sdkRoot.find(entry.name) == 0 ||
+ sdkRoot.find(std::string("/") + entry.name) != std::string::npos) {
+ return entry.sdk;
}
}
- return false;
+ return AppleSDK::MacOS;
+}
+
+bool cmMakefile::PlatformIsAppleEmbedded() const
+{
+ return GetAppleSDKType() != AppleSDK::MacOS;
}
const char* cmMakefile::GetSONameFlag(const std::string& language) const
@@ -2211,7 +2640,7 @@ const char* cmMakefile::GetSONameFlag(const std::string& language) const
return GetDefinition(name);
}
-bool cmMakefile::CanIWriteThisFile(const char* fileName) const
+bool cmMakefile::CanIWriteThisFile(std::string const& fileName) const
{
if (!this->IsOn("CMAKE_DISABLE_SOURCE_CHANGES")) {
return true;
@@ -2223,51 +2652,56 @@ bool cmMakefile::CanIWriteThisFile(const char* fileName) const
}
return !cmSystemTools::IsSubDirectory(fileName, this->GetHomeDirectory()) ||
- cmSystemTools::IsSubDirectory(fileName, this->GetHomeOutputDirectory());
+ cmSystemTools::IsSubDirectory(fileName, this->GetHomeOutputDirectory()) ||
+ cmSystemTools::SameFile(fileName, this->GetHomeOutputDirectory());
}
-const char* cmMakefile::GetRequiredDefinition(const std::string& name) const
+const std::string& cmMakefile::GetRequiredDefinition(
+ const std::string& name) const
{
- const char* ret = this->GetDefinition(name);
- if (!ret) {
+ static std::string const empty;
+ const std::string* def = GetDef(name);
+ if (!def) {
cmSystemTools::Error("Error required internal CMake variable not "
- "set, cmake may not be built correctly.\n",
- "Missing variable is:\n", name.c_str());
- return "";
+ "set, cmake may not be built correctly.\n"
+ "Missing variable is:\n" +
+ name);
+ return empty;
}
- return ret;
+ return *def;
}
bool cmMakefile::IsDefinitionSet(const std::string& name) const
{
- const char* def = this->StateSnapshot.GetDefinition(name);
+ const std::string* def = this->StateSnapshot.GetDefinition(name);
if (!def) {
def = this->GetState()->GetInitializedCacheValue(name);
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
if (cmVariableWatch* vv = this->GetVariableWatch()) {
if (!def) {
vv->VariableAccessed(
- name, cmVariableWatch::UNKNOWN_VARIABLE_DEFINED_ACCESS, def, this);
+ name, cmVariableWatch::UNKNOWN_VARIABLE_DEFINED_ACCESS, nullptr, this);
}
}
#endif
- return def != CM_NULLPTR;
+ return def != nullptr;
}
-const char* cmMakefile::GetDefinition(const std::string& name) const
+const std::string* cmMakefile::GetDef(const std::string& name) const
{
- const char* def = this->StateSnapshot.GetDefinition(name);
+ const std::string* def = this->StateSnapshot.GetDefinition(name);
if (!def) {
def = this->GetState()->GetInitializedCacheValue(name);
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmVariableWatch* vv = this->GetVariableWatch();
- if (vv && !this->SuppressWatches) {
- bool const watch_function_executed = vv->VariableAccessed(
- name, def ? cmVariableWatch::VARIABLE_READ_ACCESS
- : cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS,
- def, this);
+ if (vv && !this->SuppressSideEffects) {
+ bool const watch_function_executed =
+ vv->VariableAccessed(name,
+ def ? cmVariableWatch::VARIABLE_READ_ACCESS
+ : cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS,
+ (def ? def->c_str() : nullptr), this);
if (watch_function_executed) {
// A callback was executed and may have caused re-allocation of the
@@ -2283,35 +2717,45 @@ const char* cmMakefile::GetDefinition(const std::string& name) const
return def;
}
-const char* cmMakefile::GetSafeDefinition(const std::string& def) const
+const char* cmMakefile::GetDefinition(const std::string& name) const
+{
+ const std::string* def = GetDef(name);
+ if (!def) {
+ return nullptr;
+ }
+ return def->c_str();
+}
+
+const std::string& cmMakefile::GetSafeDefinition(const std::string& name) const
{
- const char* ret = this->GetDefinition(def);
- if (!ret) {
- return "";
+ static std::string const empty;
+ const std::string* def = GetDef(name);
+ if (!def) {
+ return empty;
}
- return ret;
+ return *def;
}
std::vector<std::string> cmMakefile::GetDefinitions() const
{
std::vector<std::string> res = this->StateSnapshot.ClosureKeys();
- std::vector<std::string> cacheKeys = this->GetState()->GetCacheEntryKeys();
- res.insert(res.end(), cacheKeys.begin(), cacheKeys.end());
+ cmAppend(res, this->GetState()->GetCacheEntryKeys());
std::sort(res.begin(), res.end());
return res;
}
-const char* cmMakefile::ExpandVariablesInString(std::string& source) const
+const std::string& cmMakefile::ExpandVariablesInString(
+ std::string& source) const
{
return this->ExpandVariablesInString(source, false, false);
}
-const char* cmMakefile::ExpandVariablesInString(
+const std::string& cmMakefile::ExpandVariablesInString(
std::string& source, bool escapeQuotes, bool noEscapes, bool atOnly,
const char* filename, long line, bool removeEmpty, bool replaceAt) const
{
bool compareResults = false;
- cmake::MessageType mtype = cmake::LOG;
+ MessageType mtype = MessageType::LOG;
std::string errorstr;
std::string original;
@@ -2319,16 +2763,16 @@ const char* cmMakefile::ExpandVariablesInString(
if (atOnly && (!noEscapes || !removeEmpty)) {
// This case should never be called. At-only is for
// configure-file/string which always does no escapes.
- this->IssueMessage(cmake::INTERNAL_ERROR,
+ this->IssueMessage(MessageType::INTERNAL_ERROR,
"ExpandVariablesInString @ONLY called "
"on something with escapes.");
- return source.c_str();
+ return source;
}
// Variables used in the WARN case.
std::string newResult;
std::string newErrorstr;
- cmake::MessageType newError = cmake::LOG;
+ MessageType newError = MessageType::LOG;
switch (this->GetPolicyStatus(cmPolicies::CMP0053)) {
case cmPolicies::WARN: {
@@ -2338,11 +2782,11 @@ const char* cmMakefile::ExpandVariablesInString(
compareResults = true;
// Suppress variable watches to avoid calling hooks twice. Suppress new
// dereferences since the OLD behavior is still what is actually used.
- this->SuppressWatches = true;
- newError = ExpandVariablesInStringNew(
- newErrorstr, newResult, escapeQuotes, noEscapes, atOnly, filename,
- line, removeEmpty, replaceAt);
- this->SuppressWatches = false;
+ this->SuppressSideEffects = true;
+ newError = ExpandVariablesInStringNew(newErrorstr, newResult,
+ escapeQuotes, noEscapes, atOnly,
+ filename, line, replaceAt);
+ this->SuppressSideEffects = false;
CM_FALLTHROUGH;
}
case cmPolicies::OLD:
@@ -2354,23 +2798,23 @@ const char* cmMakefile::ExpandVariablesInString(
case cmPolicies::REQUIRED_ALWAYS:
// Messaging here would be *very* verbose.
case cmPolicies::NEW:
- mtype = ExpandVariablesInStringNew(errorstr, source, escapeQuotes,
- noEscapes, atOnly, filename, line,
- removeEmpty, replaceAt);
+ mtype =
+ ExpandVariablesInStringNew(errorstr, source, escapeQuotes, noEscapes,
+ atOnly, filename, line, replaceAt);
break;
}
// If it's an error in either case, just report the error...
- if (mtype != cmake::LOG) {
- if (mtype == cmake::FATAL_ERROR) {
+ if (mtype != MessageType::LOG) {
+ if (mtype == MessageType::FATAL_ERROR) {
cmSystemTools::SetFatalErrorOccured();
}
this->IssueMessage(mtype, errorstr);
}
// ...otherwise, see if there's a difference that needs to be warned about.
else if (compareResults && (newResult != source || newError != mtype)) {
- std::string msg = cmPolicies::GetPolicyWarning(cmPolicies::CMP0053);
- msg += "\n";
+ std::string msg =
+ cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0053), '\n');
std::string msg_input = original;
cmSystemTools::ReplaceString(msg_input, "\n", "\n ");
@@ -2401,20 +2845,20 @@ const char* cmMakefile::ExpandVariablesInString(
msg +=
"Using the old result for compatibility since the policy is not set.";
- this->IssueMessage(cmake::AUTHOR_WARNING, msg);
+ this->IssueMessage(MessageType::AUTHOR_WARNING, msg);
}
- return source.c_str();
+ return source;
}
-cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
+MessageType cmMakefile::ExpandVariablesInStringOld(
std::string& errorstr, std::string& source, bool escapeQuotes,
bool noEscapes, bool atOnly, const char* filename, long line,
bool removeEmpty, bool replaceAt) const
{
// Fast path strings without any special characters.
if (source.find_first_of("$@\\") == std::string::npos) {
- return cmake::LOG;
+ return MessageType::LOG;
}
// Special-case the @ONLY mode.
@@ -2423,7 +2867,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
std::string input = source;
// Start with empty output.
- source = "";
+ source.clear();
// Look for one @VAR@ at a time.
const char* in = input.c_str();
@@ -2440,7 +2884,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
if (const char* val = this->GetDefinition(var)) {
// Store the value in the output escaping as requested.
if (escapeQuotes) {
- source.append(cmSystemTools::EscapeQuotes(val));
+ source.append(cmEscapeQuotes(val));
} else {
source.append(val);
}
@@ -2453,7 +2897,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
// Append the rest of the unchanged part of the string.
source.append(in);
- return cmake::LOG;
+ return MessageType::LOG;
}
// This method replaces ${VAR} and @VAR@ where VAR is looked up
@@ -2470,7 +2914,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
parser.SetRemoveEmpty(removeEmpty);
int res = parser.ParseString(source.c_str(), 0);
const char* emsg = parser.GetError();
- cmake::MessageType mtype = cmake::LOG;
+ MessageType mtype = MessageType::LOG;
if (res && !emsg[0]) {
source = parser.GetResult();
} else {
@@ -2493,7 +2937,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
// parser reported an error message without failing because the
// helper implementation is unhappy, which has always reported an
// error.
- mtype = cmake::FATAL_ERROR;
+ mtype = MessageType::FATAL_ERROR;
if (!res) {
// This is a real argument parsing error. Use policy CMP0010 to
// decide whether it is an error.
@@ -2503,7 +2947,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
CM_FALLTHROUGH;
case cmPolicies::OLD:
// OLD behavior is to just warn and continue.
- mtype = cmake::AUTHOR_WARNING;
+ mtype = MessageType::AUTHOR_WARNING;
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
@@ -2519,22 +2963,40 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
return mtype;
}
-typedef enum { NORMAL, ENVIRONMENT, CACHE } t_domain;
+enum t_domain
+{
+ NORMAL,
+ ENVIRONMENT,
+ CACHE
+};
+
struct t_lookup
{
- t_lookup()
- : domain(NORMAL)
- , loc(0)
- {
- }
- t_domain domain;
- size_t loc;
+ t_domain domain = NORMAL;
+ size_t loc = 0;
};
-cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
+bool cmMakefile::IsProjectFile(const char* filename) const
+{
+ return cmSystemTools::IsSubDirectory(filename, this->GetHomeDirectory()) ||
+ (cmSystemTools::IsSubDirectory(filename, this->GetHomeOutputDirectory()) &&
+ !cmSystemTools::IsSubDirectory(filename, "/CMakeFiles"));
+}
+
+int cmMakefile::GetRecursionDepth() const
+{
+ return this->RecursionDepth;
+}
+
+void cmMakefile::SetRecursionDepth(int recursionDepth)
+{
+ this->RecursionDepth = recursionDepth;
+}
+
+MessageType cmMakefile::ExpandVariablesInStringNew(
std::string& errorstr, std::string& source, bool escapeQuotes,
bool noEscapes, bool atOnly, const char* filename, long line,
- bool removeEmpty, bool replaceAt) const
+ bool replaceAt) const
{
// This method replaces ${VAR} and @VAR@ where VAR is looked up
// with GetDefinition(), if not found in the map, nothing is expanded.
@@ -2548,10 +3010,11 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
std::vector<t_lookup> openstack;
bool error = false;
bool done = false;
- cmake::MessageType mtype = cmake::LOG;
+ MessageType mtype = MessageType::LOG;
cmState* state = this->GetCMakeInstance()->GetState();
+ static const std::string lineVar = "CMAKE_CURRENT_LIST_LINE";
do {
char inc = *in;
switch (inc) {
@@ -2561,16 +3024,13 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
openstack.pop_back();
result.append(last, in - last);
std::string const& lookup = result.substr(var.loc);
- const char* value = CM_NULLPTR;
+ const char* value = nullptr;
std::string varresult;
std::string svalue;
- static const std::string lineVar = "CMAKE_CURRENT_LIST_LINE";
switch (var.domain) {
case NORMAL:
if (filename && lookup == lineVar) {
- std::ostringstream ostr;
- ostr << line;
- varresult = ostr.str();
+ varresult = std::to_string(line);
} else {
value = this->GetDefinition(lookup);
}
@@ -2587,26 +3047,12 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
// Get the string we're meant to append to.
if (value) {
if (escapeQuotes) {
- varresult = cmSystemTools::EscapeQuotes(value);
+ varresult = cmEscapeQuotes(value);
} else {
varresult = value;
}
- } else if (!removeEmpty) {
- // check to see if we need to print a warning
- // if strict mode is on and the variable has
- // not been "cleared"/initialized with a set(foo ) call
- if (this->GetCMakeInstance()->GetWarnUninitialized() &&
- !this->VariableInitialized(lookup)) {
- if (this->CheckSystemVars ||
- cmSystemTools::IsSubDirectory(filename,
- this->GetHomeDirectory()) ||
- cmSystemTools::IsSubDirectory(
- filename, this->GetHomeOutputDirectory())) {
- std::ostringstream msg;
- msg << "uninitialized variable \'" << lookup << "\'";
- this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
- }
- }
+ } else if (!this->SuppressSideEffects) {
+ this->MaybeWarnUninitialized(lookup, filename);
}
result.replace(var.loc, result.size() - var.loc, varresult);
// Start looking from here on out.
@@ -2617,7 +3063,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
if (!atOnly) {
t_lookup lookup;
const char* next = in + 1;
- const char* start = CM_NULLPTR;
+ const char* start = nullptr;
char nextc = *next;
if (nextc == '{') {
// Looking for a variable.
@@ -2641,7 +3087,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
std::string(next, this->cmNamedCurly.end()) +
"{} is not supported. Only ${}, $ENV{}, "
"and $CACHE{} are allowed.";
- mtype = cmake::FATAL_ERROR;
+ mtype = MessageType::FATAL_ERROR;
error = true;
}
}
@@ -2707,13 +3153,27 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
const char* nextAt = strchr(in + 1, '@');
if (nextAt && nextAt != in + 1 &&
nextAt ==
- in + 1 + strspn(in + 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789/_.+-")) {
+ in + 1 +
+ strspn(in + 1,
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "0123456789/_.+-")) {
std::string variable(in + 1, nextAt - in - 1);
- std::string varresult = this->GetSafeDefinition(variable);
+
+ std::string varresult;
+ if (filename && variable == lineVar) {
+ varresult = std::to_string(line);
+ } else {
+ const std::string* def = this->GetDef(variable);
+ if (def) {
+ varresult = *def;
+ } else if (!this->SuppressSideEffects) {
+ this->MaybeWarnUninitialized(variable, filename);
+ }
+ }
+
if (escapeQuotes) {
- varresult = cmSystemTools::EscapeQuotes(varresult);
+ varresult = cmEscapeQuotes(varresult);
}
// Skip over the variable.
result.append(last, in - last);
@@ -2735,7 +3195,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
errorstr += "\') in a variable name: "
"'" +
result.substr(openstack.back().loc) + "'";
- mtype = cmake::FATAL_ERROR;
+ mtype = MessageType::FATAL_ERROR;
error = true;
}
break;
@@ -2766,7 +3226,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
emsg << "when parsing string\n"
<< " " << source << "\n";
emsg << errorstr;
- mtype = cmake::FATAL_ERROR;
+ mtype = MessageType::FATAL_ERROR;
errorstr = emsg.str();
} else {
// Append the rest of the unchanged part of the string.
@@ -2806,7 +3266,7 @@ std::string cmMakefile::GetConfigurations(std::vector<std::string>& configs,
if (this->GetGlobalGenerator()->IsMultiConfig()) {
if (const char* configTypes =
this->GetDefinition("CMAKE_CONFIGURATION_TYPES")) {
- cmSystemTools::ExpandListArgument(configTypes, configs);
+ cmExpandList(configTypes, configs);
}
return "";
}
@@ -2817,59 +3277,25 @@ std::string cmMakefile::GetConfigurations(std::vector<std::string>& configs,
return buildType;
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-/**
- * Find a source group whose regular expression matches the filename
- * part of the given source name. Search backward through the list of
- * source groups, and take the first matching group found. This way
- * non-inherited SOURCE_GROUP commands will have precedence over
- * inherited ones.
- */
-cmSourceGroup* cmMakefile::FindSourceGroup(
- const char* source, std::vector<cmSourceGroup>& groups) const
+std::vector<std::string> cmMakefile::GetGeneratorConfigs() const
{
- // First search for a group that lists the file explicitly.
- for (std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin();
- sg != groups.rend(); ++sg) {
- cmSourceGroup* result = sg->MatchChildrenFiles(source);
- if (result) {
- return result;
- }
- }
-
- // Now search for a group whose regex matches the file.
- for (std::vector<cmSourceGroup>::reverse_iterator sg = groups.rbegin();
- sg != groups.rend(); ++sg) {
- cmSourceGroup* result = sg->MatchChildrenRegex(source);
- if (result) {
- return result;
- }
+ std::vector<std::string> configs;
+ GetConfigurations(configs);
+ if (configs.empty()) {
+ configs.emplace_back();
}
-
- // Shouldn't get here, but just in case, return the default group.
- return &groups.front();
+ return configs;
}
-#endif
bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff,
cmExecutionStatus& status)
{
// if there are no blockers get out of here
- if (this->FunctionBlockers.begin() == this->FunctionBlockers.end()) {
+ if (this->FunctionBlockers.empty()) {
return false;
}
- // loop over all function blockers to see if any block this command
- // evaluate in reverse, this is critical for balanced IF statements etc
- std::vector<cmFunctionBlocker*>::reverse_iterator pos;
- for (pos = this->FunctionBlockers.rbegin();
- pos != this->FunctionBlockers.rend(); ++pos) {
- if ((*pos)->IsFunctionBlocked(lff, *this, status)) {
- return true;
- }
- }
-
- return false;
+ return this->FunctionBlockers.top()->IsFunctionBlocked(lff, status);
}
void cmMakefile::PushFunctionBlockerBarrier()
@@ -2883,8 +3309,9 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
FunctionBlockersType::size_type barrier =
this->FunctionBlockerBarriers.back();
while (this->FunctionBlockers.size() > barrier) {
- CM_AUTO_PTR<cmFunctionBlocker> fb(this->FunctionBlockers.back());
- this->FunctionBlockers.pop_back();
+ std::unique_ptr<cmFunctionBlocker> fb(
+ std::move(this->FunctionBlockers.top()));
+ this->FunctionBlockers.pop();
if (reportError) {
// Report the context in which the unclosed block was opened.
cmListFileContext const& lfc = fb->GetStartingContext();
@@ -2894,7 +3321,7 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
<< " " << lfc << "\n"
<< "is not closed.";
/* clang-format on */
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->IssueMessage(MessageType::FATAL_ERROR, e.str());
reportError = false;
}
}
@@ -2948,26 +3375,25 @@ bool cmMakefile::ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
if (!filename) {
filename = efp.c_str();
}
- std::vector<cmListFileArgument>::const_iterator i;
std::string value;
outArgs.reserve(inArgs.size());
- for (i = inArgs.begin(); i != inArgs.end(); ++i) {
+ for (cmListFileArgument const& i : inArgs) {
// No expansion in a bracket argument.
- if (i->Delim == cmListFileArgument::Bracket) {
- outArgs.push_back(i->Value);
+ if (i.Delim == cmListFileArgument::Bracket) {
+ outArgs.push_back(i.Value);
continue;
}
// Expand the variables in the argument.
- value = i->Value;
- this->ExpandVariablesInString(value, false, false, false, filename,
- i->Line, false, false);
+ value = i.Value;
+ this->ExpandVariablesInString(value, false, false, false, filename, i.Line,
+ false, false);
// If the argument is quoted, it should be one argument.
// Otherwise, it may be a list of arguments.
- if (i->Delim == cmListFileArgument::Quoted) {
+ if (i.Delim == cmListFileArgument::Quoted) {
outArgs.push_back(value);
} else {
- cmSystemTools::ExpandListArgument(value, outArgs);
+ cmExpandList(value, outArgs);
}
}
return !cmSystemTools::GetFatalErrorOccured();
@@ -2981,147 +3407,158 @@ bool cmMakefile::ExpandArguments(
if (!filename) {
filename = efp.c_str();
}
- std::vector<cmListFileArgument>::const_iterator i;
std::string value;
outArgs.reserve(inArgs.size());
- for (i = inArgs.begin(); i != inArgs.end(); ++i) {
+ for (cmListFileArgument const& i : inArgs) {
// No expansion in a bracket argument.
- if (i->Delim == cmListFileArgument::Bracket) {
- outArgs.push_back(cmExpandedCommandArgument(i->Value, true));
+ if (i.Delim == cmListFileArgument::Bracket) {
+ outArgs.emplace_back(i.Value, true);
continue;
}
// Expand the variables in the argument.
- value = i->Value;
- this->ExpandVariablesInString(value, false, false, false, filename,
- i->Line, false, false);
+ value = i.Value;
+ this->ExpandVariablesInString(value, false, false, false, filename, i.Line,
+ false, false);
// If the argument is quoted, it should be one argument.
// Otherwise, it may be a list of arguments.
- if (i->Delim == cmListFileArgument::Quoted) {
- outArgs.push_back(cmExpandedCommandArgument(value, true));
+ if (i.Delim == cmListFileArgument::Quoted) {
+ outArgs.emplace_back(value, true);
} else {
- std::vector<std::string> stringArgs;
- cmSystemTools::ExpandListArgument(value, stringArgs);
- for (size_t j = 0; j < stringArgs.size(); ++j) {
- outArgs.push_back(cmExpandedCommandArgument(stringArgs[j], false));
+ std::vector<std::string> stringArgs = cmExpandedList(value);
+ for (std::string const& stringArg : stringArgs) {
+ outArgs.emplace_back(stringArg, false);
}
}
}
return !cmSystemTools::GetFatalErrorOccured();
}
-void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb)
+void cmMakefile::AddFunctionBlocker(std::unique_ptr<cmFunctionBlocker> fb)
{
if (!this->ExecutionStatusStack.empty()) {
// Record the context in which the blocker is created.
fb->SetStartingContext(this->GetExecutionContext());
}
- this->FunctionBlockers.push_back(fb);
+ this->FunctionBlockers.push(std::move(fb));
}
-CM_AUTO_PTR<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker(
- cmFunctionBlocker* fb, const cmListFileFunction& lff)
+std::unique_ptr<cmFunctionBlocker> cmMakefile::RemoveFunctionBlocker()
{
- // Find the function blocker stack barrier for the current scope.
- // We only remove a blocker whose index is not less than the barrier.
- FunctionBlockersType::size_type barrier = 0;
- if (!this->FunctionBlockerBarriers.empty()) {
- barrier = this->FunctionBlockerBarriers.back();
- }
-
- // Search for the function blocker whose scope this command ends.
- for (FunctionBlockersType::size_type i = this->FunctionBlockers.size();
- i > barrier; --i) {
- std::vector<cmFunctionBlocker*>::iterator pos =
- this->FunctionBlockers.begin() + (i - 1);
- if (*pos == fb) {
- // Warn if the arguments do not match, but always remove.
- if (!(*pos)->ShouldRemove(lff, *this)) {
- cmListFileContext const& lfc = fb->GetStartingContext();
- cmListFileContext closingContext =
- cmListFileContext::FromCommandContext(lff, lfc.FilePath);
- std::ostringstream e;
- /* clang-format off */
- e << "A logical block opening on the line\n"
- << " " << lfc << "\n"
- << "closes on the line\n"
- << " " << closingContext << "\n"
- << "with mis-matching arguments.";
- /* clang-format on */
- this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
- }
- cmFunctionBlocker* b = *pos;
- this->FunctionBlockers.erase(pos);
- return CM_AUTO_PTR<cmFunctionBlocker>(b);
- }
- }
+ assert(!this->FunctionBlockers.empty());
+ assert(this->FunctionBlockerBarriers.empty() ||
+ this->FunctionBlockers.size() > this->FunctionBlockerBarriers.back());
- return CM_AUTO_PTR<cmFunctionBlocker>();
+ auto b = std::move(this->FunctionBlockers.top());
+ this->FunctionBlockers.pop();
+ return b;
}
-const char* cmMakefile::GetHomeDirectory() const
+std::string const& cmMakefile::GetHomeDirectory() const
{
return this->GetCMakeInstance()->GetHomeDirectory();
}
-const char* cmMakefile::GetHomeOutputDirectory() const
+std::string const& cmMakefile::GetHomeOutputDirectory() const
{
return this->GetCMakeInstance()->GetHomeOutputDirectory();
}
-void cmMakefile::SetScriptModeFile(const char* scriptfile)
+void cmMakefile::SetScriptModeFile(std::string const& scriptfile)
{
this->AddDefinition("CMAKE_SCRIPT_MODE_FILE", scriptfile);
}
void cmMakefile::SetArgcArgv(const std::vector<std::string>& args)
{
- std::ostringstream strStream;
- strStream << args.size();
- this->AddDefinition("CMAKE_ARGC", strStream.str().c_str());
+ this->AddDefinition("CMAKE_ARGC", std::to_string(args.size()));
// this->MarkVariableAsUsed("CMAKE_ARGC");
for (unsigned int t = 0; t < args.size(); ++t) {
std::ostringstream tmpStream;
tmpStream << "CMAKE_ARGV" << t;
- this->AddDefinition(tmpStream.str(), args[t].c_str());
+ this->AddDefinition(tmpStream.str(), args[t]);
// this->MarkVariableAsUsed(tmpStream.str().c_str());
}
}
-cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
+cmSourceFile* cmMakefile::GetSource(const std::string& sourceName,
+ cmSourceFileLocationKind kind) const
{
- cmSourceFileLocation sfl(this, sourceName);
- for (std::vector<cmSourceFile*>::const_iterator sfi =
- this->SourceFiles.begin();
- sfi != this->SourceFiles.end(); ++sfi) {
- cmSourceFile* sf = *sfi;
- if (sf->Matches(sfl)) {
- return sf;
+ // First check "Known" paths (avoids the creation of cmSourceFileLocation)
+ if (kind == cmSourceFileLocationKind::Known) {
+ auto sfsi = this->KnownFileSearchIndex.find(sourceName);
+ if (sfsi != this->KnownFileSearchIndex.end()) {
+ return sfsi->second;
}
}
- return CM_NULLPTR;
+
+ cmSourceFileLocation sfl(this, sourceName, kind);
+ auto name = this->GetCMakeInstance()->StripExtension(sfl.GetName());
+#if defined(_WIN32) || defined(__APPLE__)
+ name = cmSystemTools::LowerCase(name);
+#endif
+ auto sfsi = this->SourceFileSearchIndex.find(name);
+ if (sfsi != this->SourceFileSearchIndex.end()) {
+ for (auto sf : sfsi->second) {
+ if (sf->Matches(sfl)) {
+ return sf;
+ }
+ }
+ }
+ return nullptr;
}
cmSourceFile* cmMakefile::CreateSource(const std::string& sourceName,
- bool generated)
+ bool generated,
+ cmSourceFileLocationKind kind)
{
- cmSourceFile* sf = new cmSourceFile(this, sourceName);
+ cmSourceFile* sf = new cmSourceFile(this, sourceName, kind);
if (generated) {
sf->SetProperty("GENERATED", "1");
}
this->SourceFiles.push_back(sf);
+
+ auto name =
+ this->GetCMakeInstance()->StripExtension(sf->GetLocation().GetName());
+#if defined(_WIN32) || defined(__APPLE__)
+ name = cmSystemTools::LowerCase(name);
+#endif
+ this->SourceFileSearchIndex[name].push_back(sf);
+ // for "Known" paths add direct lookup (used for faster lookup in GetSource)
+ if (kind == cmSourceFileLocationKind::Known) {
+ this->KnownFileSearchIndex[sourceName] = sf;
+ }
+
return sf;
}
cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
- bool generated)
+ bool generated,
+ cmSourceFileLocationKind kind)
{
- if (cmSourceFile* esf = this->GetSource(sourceName)) {
+ if (cmSourceFile* esf = this->GetSource(sourceName, kind)) {
return esf;
}
- return this->CreateSource(sourceName, generated);
+ return this->CreateSource(sourceName, generated, kind);
+}
+
+cmSourceFile* cmMakefile::GetOrCreateGeneratedSource(
+ const std::string& sourceName)
+{
+ cmSourceFile* sf =
+ this->GetOrCreateSource(sourceName, true, cmSourceFileLocationKind::Known);
+ sf->SetProperty("GENERATED", "1");
+ return sf;
+}
+
+void cmMakefile::CreateGeneratedSources(
+ const std::vector<std::string>& outputs)
+{
+ for (std::string const& output : outputs) {
+ this->GetOrCreateGeneratedSource(output);
+ }
}
void cmMakefile::AddTargetObject(std::string const& tgtName,
@@ -3130,29 +3567,29 @@ void cmMakefile::AddTargetObject(std::string const& tgtName,
cmSourceFile* sf = this->GetOrCreateSource(objFile, true);
sf->SetObjectLibrary(tgtName);
sf->SetProperty("EXTERNAL_OBJECT", "1");
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->SourceGroups[this->ObjectLibrariesSourceGroupIndex].AddGroupFile(
- sf->GetFullPath());
+ sf->ResolveFullPath());
#endif
}
void cmMakefile::EnableLanguage(std::vector<std::string> const& lang,
bool optional)
{
- this->AddDefinition("CMAKE_CFG_INTDIR",
- this->GetGlobalGenerator()->GetCMakeCFGIntDir());
+ if (const char* def = this->GetGlobalGenerator()->GetCMakeCFGIntDir()) {
+ this->AddDefinition("CMAKE_CFG_INTDIR", def);
+ }
// If RC is explicitly listed we need to do it after other languages.
// On some platforms we enable RC implicitly while enabling others.
// Do not let that look like recursive enable_language(RC).
std::vector<std::string> langs;
std::vector<std::string> langsRC;
langs.reserve(lang.size());
- for (std::vector<std::string>::const_iterator i = lang.begin();
- i != lang.end(); ++i) {
- if (*i == "RC") {
- langsRC.push_back(*i);
+ for (std::string const& i : lang) {
+ if (i == "RC") {
+ langsRC.push_back(i);
} else {
- langs.push_back(*i);
+ langs.push_back(i);
}
}
if (!langs.empty()) {
@@ -3166,42 +3603,53 @@ void cmMakefile::EnableLanguage(std::vector<std::string> const& lang,
int cmMakefile::TryCompile(const std::string& srcdir,
const std::string& bindir,
const std::string& projectName,
- const std::string& targetName, bool fast,
+ const std::string& targetName, bool fast, int jobs,
const std::vector<std::string>* cmakeArgs,
std::string& output)
{
this->IsSourceFileTryCompile = fast;
// does the binary directory exist ? If not create it...
if (!cmSystemTools::FileIsDirectory(bindir)) {
- cmSystemTools::MakeDirectory(bindir.c_str());
+ cmSystemTools::MakeDirectory(bindir);
}
// change to the tests directory and run cmake
// use the cmake object instead of calling cmake
cmWorkingDirectory workdir(bindir);
+ if (workdir.Failed()) {
+ this->IssueMessage(MessageType::FATAL_ERROR,
+ "Failed to set working directory to " + bindir + " : " +
+ std::strerror(workdir.GetLastResult()));
+ cmSystemTools::SetFatalErrorOccured();
+ this->IsSourceFileTryCompile = false;
+ return 1;
+ }
// make sure the same generator is used
// use this program as the cmake to be run, it should not
// be run that way but the cmake object requires a vailid path
- cmake cm(cmake::RoleProject);
+ cmake cm(cmake::RoleProject, cmState::Project);
cm.SetIsInTryCompile(true);
cmGlobalGenerator* gg =
cm.CreateGlobalGenerator(this->GetGlobalGenerator()->GetName());
if (!gg) {
- this->IssueMessage(cmake::INTERNAL_ERROR, "Global generator '" +
+ this->IssueMessage(MessageType::INTERNAL_ERROR,
+ "Global generator '" +
this->GetGlobalGenerator()->GetName() +
"' could not be created.");
cmSystemTools::SetFatalErrorOccured();
this->IsSourceFileTryCompile = false;
return 1;
}
+ gg->RecursionDepth = this->RecursionDepth;
cm.SetGlobalGenerator(gg);
// do a configure
cm.SetHomeDirectory(srcdir);
cm.SetHomeOutputDirectory(bindir);
- cm.SetGeneratorPlatform(this->GetCMakeInstance()->GetGeneratorPlatform());
- cm.SetGeneratorToolset(this->GetCMakeInstance()->GetGeneratorToolset());
+ cm.SetGeneratorInstance(this->GetSafeDefinition("CMAKE_GENERATOR_INSTANCE"));
+ cm.SetGeneratorPlatform(this->GetSafeDefinition("CMAKE_GENERATOR_PLATFORM"));
+ cm.SetGeneratorToolset(this->GetSafeDefinition("CMAKE_GENERATOR_TOOLSET"));
cm.LoadCache();
if (!gg->IsMultiConfig()) {
if (const char* config =
@@ -3213,6 +3661,12 @@ int cmMakefile::TryCompile(const std::string& srcdir,
cmStateEnums::STRING);
}
}
+ const char* recursionDepth =
+ this->GetDefinition("CMAKE_MAXIMUM_RECURSION_DEPTH");
+ if (recursionDepth) {
+ cm.AddCacheEntry("CMAKE_MAXIMUM_RECURSION_DEPTH", recursionDepth,
+ "Maximum recursion depth", cmStateEnums::STRING);
+ }
// if cmake args were provided then pass them in
if (cmakeArgs) {
// FIXME: Workaround to ignore unused CLI variables in try-compile.
@@ -3252,7 +3706,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
cmStateEnums::INTERNAL);
}
if (cm.Configure() != 0) {
- this->IssueMessage(cmake::FATAL_ERROR,
+ this->IssueMessage(MessageType::FATAL_ERROR,
"Failed to configure test project build system.");
cmSystemTools::SetFatalErrorOccured();
this->IsSourceFileTryCompile = false;
@@ -3260,7 +3714,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
}
if (cm.Generate() != 0) {
- this->IssueMessage(cmake::FATAL_ERROR,
+ this->IssueMessage(MessageType::FATAL_ERROR,
"Failed to generate test project build system.");
cmSystemTools::SetFatalErrorOccured();
this->IsSourceFileTryCompile = false;
@@ -3269,7 +3723,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
// finally call the generator to actually build the resulting project
int ret = this->GetGlobalGenerator()->TryCompile(
- srcdir, bindir, projectName, targetName, fast, output, this);
+ jobs, srcdir, bindir, projectName, targetName, fast, output, this);
this->IsSourceFileTryCompile = false;
return ret;
@@ -3295,14 +3749,14 @@ cmGlobalGenerator* cmMakefile::GetGlobalGenerator() const
return this->GlobalGenerator;
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmVariableWatch* cmMakefile::GetVariableWatch() const
{
if (this->GetCMakeInstance() &&
this->GetCMakeInstance()->GetVariableWatch()) {
return this->GetCMakeInstance()->GetVariableWatch();
}
- return CM_NULLPTR;
+ return nullptr;
}
#endif
@@ -3311,7 +3765,7 @@ cmState* cmMakefile::GetState() const
return this->GetCMakeInstance()->GetState();
}
-void cmMakefile::DisplayStatus(const char* message, float s) const
+void cmMakefile::DisplayStatus(const std::string& message, float s) const
{
cmake* cm = this->GetCMakeInstance();
if (cm->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) {
@@ -3322,7 +3776,8 @@ void cmMakefile::DisplayStatus(const char* message, float s) const
cm->UpdateProgress(message, s);
}
-std::string cmMakefile::GetModulesFile(const char* filename) const
+std::string cmMakefile::GetModulesFile(const std::string& filename,
+ bool& system) const
{
std::string result;
@@ -3342,17 +3797,14 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
// Always search in CMAKE_MODULE_PATH:
const char* cmakeModulePath = this->GetDefinition("CMAKE_MODULE_PATH");
if (cmakeModulePath) {
- std::vector<std::string> modulePath;
- cmSystemTools::ExpandListArgument(cmakeModulePath, modulePath);
+ std::vector<std::string> modulePath = cmExpandedList(cmakeModulePath);
// Look through the possible module directories.
- for (std::vector<std::string>::iterator i = modulePath.begin();
- i != modulePath.end(); ++i) {
- std::string itempl = *i;
+ for (std::string itempl : modulePath) {
cmSystemTools::ConvertToUnixSlashes(itempl);
itempl += "/";
itempl += filename;
- if (cmSystemTools::FileExists(itempl.c_str())) {
+ if (cmSystemTools::FileExists(itempl)) {
moduleInCMakeModulePath = itempl;
break;
}
@@ -3360,19 +3812,20 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
}
// Always search in the standard modules location.
- moduleInCMakeRoot = cmSystemTools::GetCMakeRoot();
- moduleInCMakeRoot += "/Modules/";
- moduleInCMakeRoot += filename;
+ moduleInCMakeRoot =
+ cmStrCat(cmSystemTools::GetCMakeRoot(), "/Modules/", filename);
cmSystemTools::ConvertToUnixSlashes(moduleInCMakeRoot);
- if (!cmSystemTools::FileExists(moduleInCMakeRoot.c_str())) {
- moduleInCMakeRoot = "";
+ if (!cmSystemTools::FileExists(moduleInCMakeRoot)) {
+ moduleInCMakeRoot.clear();
}
// Normally, prefer the files found in CMAKE_MODULE_PATH. Only when the file
// from which we are being called is located itself in CMAKE_ROOT, then
// prefer results from CMAKE_ROOT depending on the policy setting.
+ system = false;
result = moduleInCMakeModulePath;
if (result.empty()) {
+ system = true;
result = moduleInCMakeRoot;
}
@@ -3391,15 +3844,17 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
<< cmPolicies::GetPolicyWarning(cmPolicies::CMP0017);
/* clang-format on */
- this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ this->IssueMessage(MessageType::AUTHOR_WARNING, e.str());
CM_FALLTHROUGH;
}
case cmPolicies::OLD:
+ system = false;
result = moduleInCMakeModulePath;
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
+ system = true;
result = moduleInCMakeRoot;
break;
}
@@ -3432,20 +3887,24 @@ void cmMakefile::ConfigureString(const std::string& input, std::string& output,
// Replace #cmakedefine instances.
if (this->cmDefineRegex.find(line)) {
- const char* def = this->GetDefinition(this->cmDefineRegex.match(1));
- if (!cmSystemTools::IsOff(def)) {
- cmSystemTools::ReplaceString(line, "#cmakedefine", "#define");
+ const char* def = this->GetDefinition(this->cmDefineRegex.match(2));
+ if (!cmIsOff(def)) {
+ const std::string indentation = this->cmDefineRegex.match(1);
+ cmSystemTools::ReplaceString(line, "#" + indentation + "cmakedefine",
+ "#" + indentation + "define");
output += line;
} else {
output += "/* #undef ";
- output += this->cmDefineRegex.match(1);
+ output += this->cmDefineRegex.match(2);
output += " */";
}
} else if (this->cmDefine01Regex.find(line)) {
- const char* def = this->GetDefinition(this->cmDefine01Regex.match(1));
- cmSystemTools::ReplaceString(line, "#cmakedefine01", "#define");
+ const std::string indentation = this->cmDefine01Regex.match(1);
+ const char* def = this->GetDefinition(this->cmDefine01Regex.match(2));
+ cmSystemTools::ReplaceString(line, "#" + indentation + "cmakedefine01",
+ "#" + indentation + "define");
output += line;
- if (!cmSystemTools::IsOff(def)) {
+ if (!cmIsOff(def)) {
output += " 1";
} else {
output += " 0";
@@ -3463,26 +3922,34 @@ void cmMakefile::ConfigureString(const std::string& input, std::string& output,
}
// Perform variable replacements.
- this->ExpandVariablesInString(output, escapeQuotes, true, atOnly, CM_NULLPTR,
- -1, true, true);
+ const char* filename = nullptr;
+ long lineNumber = -1;
+ if (!this->Backtrace.Empty()) {
+ const auto& currentTrace = this->Backtrace.Top();
+ filename = currentTrace.FilePath.c_str();
+ lineNumber = currentTrace.Line;
+ }
+ this->ExpandVariablesInString(output, escapeQuotes, true, atOnly, filename,
+ lineNumber, true, true);
}
-int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
- bool copyonly, bool atOnly, bool escapeQuotes,
+int cmMakefile::ConfigureFile(const std::string& infile,
+ const std::string& outfile, bool copyonly,
+ bool atOnly, bool escapeQuotes,
cmNewLineStyle newLine)
{
int res = 1;
if (!this->CanIWriteThisFile(outfile)) {
- cmSystemTools::Error("Attempt to write file: ", outfile,
+ cmSystemTools::Error("Attempt to write file: " + outfile +
" into a source directory.");
return 0;
}
if (!cmSystemTools::FileExists(infile)) {
- cmSystemTools::Error("File ", infile, " does not exist.");
+ cmSystemTools::Error("File " + infile + " does not exist.");
return 0;
}
std::string soutfile = outfile;
- std::string sinfile = infile;
+ const std::string& sinfile = infile;
this->AddCMakeDependFile(sinfile);
cmSystemTools::ConvertToUnixSlashes(soutfile);
@@ -3492,16 +3959,15 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
this->AddCMakeOutputFile(soutfile);
mode_t perm = 0;
- cmSystemTools::GetPermissions(sinfile.c_str(), perm);
+ cmSystemTools::GetPermissions(sinfile, perm);
std::string::size_type pos = soutfile.rfind('/');
if (pos != std::string::npos) {
std::string path = soutfile.substr(0, pos);
- cmSystemTools::MakeDirectory(path.c_str());
+ cmSystemTools::MakeDirectory(path);
}
if (copyonly) {
- if (!cmSystemTools::CopyFileIfDifferent(sinfile.c_str(),
- soutfile.c_str())) {
+ if (!cmSystemTools::CopyFileIfDifferent(sinfile, soutfile)) {
return 0;
}
} else {
@@ -3513,19 +3979,18 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
} else {
newLineCharacters = "\n";
}
- std::string tempOutputFile = soutfile;
- tempOutputFile += ".tmp";
+ std::string tempOutputFile = cmStrCat(soutfile, ".tmp");
cmsys::ofstream fout(tempOutputFile.c_str(), omode);
if (!fout) {
- cmSystemTools::Error("Could not open file for write in copy operation ",
- tempOutputFile.c_str());
+ cmSystemTools::Error("Could not open file for write in copy operation " +
+ tempOutputFile);
cmSystemTools::ReportLastSystemError("");
return 0;
}
cmsys::ifstream fin(sinfile.c_str());
if (!fin) {
- cmSystemTools::Error("Could not open file for read in copy operation ",
- sinfile.c_str());
+ cmSystemTools::Error("Could not open file for read in copy operation " +
+ sinfile);
return 0;
}
@@ -3534,7 +3999,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
std::ostringstream e;
e << "File starts with a Byte-Order-Mark that is not UTF-8:\n "
<< sinfile;
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->IssueMessage(MessageType::FATAL_ERROR, e.str());
return 0;
}
// rewind to copy BOM to output file
@@ -3545,18 +4010,17 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
std::string inLine;
std::string outLine;
while (cmSystemTools::GetLineFromStream(fin, inLine)) {
- outLine = "";
+ outLine.clear();
this->ConfigureString(inLine, outLine, atOnly, escapeQuotes);
fout << outLine << newLineCharacters;
}
// close the files before attempting to copy
fin.close();
fout.close();
- if (!cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(),
- soutfile.c_str())) {
+ if (!cmSystemTools::CopyFileIfDifferent(tempOutputFile, soutfile)) {
res = 0;
} else {
- cmSystemTools::SetPermissions(soutfile.c_str(), perm);
+ cmSystemTools::SetPermissions(soutfile, perm);
}
cmSystemTools::RemoveFile(tempOutputFile);
}
@@ -3579,6 +4043,20 @@ void cmMakefile::AppendProperty(const std::string& prop, const char* value,
const char* cmMakefile::GetProperty(const std::string& prop) const
{
+ // Check for computed properties.
+ static std::string output;
+ if (prop == "TESTS") {
+ std::vector<std::string> keys;
+ // get list of keys
+ std::transform(this->Tests.begin(), this->Tests.end(),
+ std::back_inserter(keys),
+ [](decltype(this->Tests)::value_type const& pair) {
+ return pair.first;
+ });
+ output = cmJoin(keys, ";");
+ return output.c_str();
+ }
+
return this->StateSnapshot.GetDirectory().GetProperty(prop);
}
@@ -3589,7 +4067,7 @@ const char* cmMakefile::GetProperty(const std::string& prop, bool chain) const
bool cmMakefile::GetPropertyAsBool(const std::string& prop) const
{
- return cmSystemTools::IsOn(this->GetProperty(prop));
+ return cmIsOn(this->GetProperty(prop));
}
std::vector<std::string> cmMakefile::GetPropertyKeys() const
@@ -3599,11 +4077,11 @@ std::vector<std::string> cmMakefile::GetPropertyKeys() const
cmTarget* cmMakefile::FindLocalNonAliasTarget(const std::string& name) const
{
- cmTargets::iterator i = this->Targets.find(name);
+ auto i = this->Targets.find(name);
if (i != this->Targets.end()) {
return &i->second;
}
- return CM_NULLPTR;
+ return nullptr;
}
cmTest* cmMakefile::CreateTest(const std::string& testName)
@@ -3620,28 +4098,34 @@ cmTest* cmMakefile::CreateTest(const std::string& testName)
cmTest* cmMakefile::GetTest(const std::string& testName) const
{
- std::map<std::string, cmTest*>::const_iterator mi =
- this->Tests.find(testName);
+ auto mi = this->Tests.find(testName);
if (mi != this->Tests.end()) {
return mi->second;
}
- return CM_NULLPTR;
+ return nullptr;
+}
+
+void cmMakefile::GetTests(const std::string& config,
+ std::vector<cmTest*>& tests)
+{
+ for (auto generator : this->GetTestGenerators()) {
+ if (generator->TestsForConfig(config)) {
+ tests.push_back(generator->GetTest());
+ }
+ }
}
void cmMakefile::AddCMakeDependFilesFromUser()
{
std::vector<std::string> deps;
if (const char* deps_str = this->GetProperty("CMAKE_CONFIGURE_DEPENDS")) {
- cmSystemTools::ExpandListArgument(deps_str, deps);
+ cmExpandList(deps_str, deps);
}
- for (std::vector<std::string>::iterator i = deps.begin(); i != deps.end();
- ++i) {
- if (cmSystemTools::FileIsFullPath(i->c_str())) {
- this->AddCMakeDependFile(*i);
+ for (std::string const& dep : deps) {
+ if (cmSystemTools::FileIsFullPath(dep)) {
+ this->AddCMakeDependFile(dep);
} else {
- std::string f = this->GetCurrentSourceDirectory();
- f += "/";
- f += *i;
+ std::string f = cmStrCat(this->GetCurrentSourceDirectory(), '/', dep);
this->AddCMakeDependFile(f);
}
}
@@ -3659,7 +4143,7 @@ std::string cmMakefile::FormatListFileStack() const
std::ostringstream tmp;
size_t depth = listFiles.size();
if (depth > 0) {
- std::vector<std::string>::const_iterator it = listFiles.end();
+ auto it = listFiles.end();
do {
if (depth != listFiles.size()) {
tmp << "\n ";
@@ -3681,14 +4165,14 @@ void cmMakefile::PushScope()
this->GetState()->CreateVariableScopeSnapshot(this->StateSnapshot);
this->PushLoopBlockBarrier();
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->GetGlobalGenerator()->GetFileLockPool().PushFunctionScope();
#endif
}
void cmMakefile::PopScope()
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->GetGlobalGenerator()->GetFileLockPool().PopFunctionScope();
#endif
@@ -3708,8 +4192,17 @@ void cmMakefile::RaiseScope(const std::string& var, const char* varDef)
if (!this->StateSnapshot.RaiseScope(var, varDef)) {
std::ostringstream m;
m << "Cannot set \"" << var << "\": current scope has no parent.";
- this->IssueMessage(cmake::AUTHOR_WARNING, m.str());
+ this->IssueMessage(MessageType::AUTHOR_WARNING, m.str());
+ return;
+ }
+
+#ifndef CMAKE_BOOTSTRAP
+ cmVariableWatch* vv = this->GetVariableWatch();
+ if (vv) {
+ vv->VariableAccessed(var, cmVariableWatch::VARIABLE_MODIFIED_ACCESS,
+ varDef, this);
}
+#endif
}
cmTarget* cmMakefile::AddImportedTarget(const std::string& name,
@@ -3717,9 +4210,10 @@ cmTarget* cmMakefile::AddImportedTarget(const std::string& name,
bool global)
{
// Create the target.
- CM_AUTO_PTR<cmTarget> target(
- new cmTarget(name, type, global ? cmTarget::VisibilityImportedGlobally
- : cmTarget::VisibilityImported,
+ std::unique_ptr<cmTarget> target(
+ new cmTarget(name, type,
+ global ? cmTarget::VisibilityImportedGlobally
+ : cmTarget::VisibilityImported,
this));
// Add to the set of available imported targets.
@@ -3736,7 +4230,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
{
// Look for an imported target. These take priority because they
// are more local in scope and do not have to be globally unique.
- TargetMap::const_iterator imported = this->ImportedTargets.find(name);
+ auto imported = this->ImportedTargets.find(name);
if (imported != this->ImportedTargets.end()) {
return imported->second;
}
@@ -3752,7 +4246,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
bool cmMakefile::IsAlias(const std::string& name) const
{
- if (this->AliasTargets.find(name) != this->AliasTargets.end()) {
+ if (cmContains(this->AliasTargets, name)) {
return true;
}
return this->GetGlobalGenerator()->IsAlias(name);
@@ -3783,7 +4277,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
// target names must be globally unique
switch (this->GetPolicyStatus(cmPolicies::CMP0002)) {
case cmPolicies::WARN:
- this->IssueMessage(cmake::AUTHOR_WARNING,
+ this->IssueMessage(MessageType::AUTHOR_WARNING,
cmPolicies::GetPolicyWarning(cmPolicies::CMP0002));
CM_FALLTHROUGH;
case cmPolicies::OLD:
@@ -3791,7 +4285,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
this->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0002));
return true;
case cmPolicies::NEW:
@@ -3870,7 +4364,7 @@ bool cmMakefile::EnforceUniqueDir(const std::string& srcPath,
<< "to work accidentally and is being allowed for "
<< "compatibility.";
/* clang-format on */
- this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ this->IssueMessage(MessageType::AUTHOR_WARNING, e.str());
CM_FALLTHROUGH;
case cmPolicies::OLD:
// OLD behavior does not warn.
@@ -3889,23 +4383,13 @@ bool cmMakefile::EnforceUniqueDir(const std::string& srcPath,
<< " " << srcPath << "\n"
<< "Specify a unique binary directory name.";
/* clang-format on */
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->IssueMessage(MessageType::FATAL_ERROR, e.str());
break;
}
return false;
}
-void cmMakefile::AddQtUiFileWithOptions(cmSourceFile* sf)
-{
- this->QtUiFilesWithOptions.push_back(sf);
-}
-
-std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const
-{
- return this->QtUiFilesWithOptions;
-}
-
static std::string const matchVariables[] = {
"CMAKE_MATCH_0", "CMAKE_MATCH_1", "CMAKE_MATCH_2", "CMAKE_MATCH_3",
"CMAKE_MATCH_4", "CMAKE_MATCH_5", "CMAKE_MATCH_6", "CMAKE_MATCH_7",
@@ -3940,7 +4424,7 @@ void cmMakefile::StoreMatches(cmsys::RegularExpression& re)
std::string const& m = re.match(i);
if (!m.empty()) {
std::string const& var = matchVariables[i];
- this->AddDefinition(var, m.c_str());
+ this->AddDefinition(var, m);
this->MarkVariableAsUsed(var);
highest = static_cast<char>('0' + i);
}
@@ -3960,17 +4444,17 @@ const char* cmMakefile::GetDefineFlagsCMP0059() const
return this->DefineFlagsOrig.c_str();
}
-cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(
- cmPolicies::PolicyID id) const
+cmPolicies::PolicyStatus cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id,
+ bool parent_scope) const
{
- return this->StateSnapshot.GetPolicy(id);
+ return this->StateSnapshot.GetPolicy(id, parent_scope);
}
bool cmMakefile::PolicyOptionalWarningEnabled(std::string const& var)
{
// Check for an explicit CMAKE_POLICY_WARNING_CMP<NNNN> setting.
if (const char* val = this->GetDefinition(var)) {
- return cmSystemTools::IsOn(val);
+ return cmIsOn(val);
}
// Enable optional policy warnings with --debug-output, --trace,
// or --trace-expand.
@@ -3984,7 +4468,7 @@ bool cmMakefile::SetPolicy(const char* id, cmPolicies::PolicyStatus status)
if (!cmPolicies::GetPolicyID(id, /* out */ pid)) {
std::ostringstream e;
e << "Policy \"" << id << "\" is not known to this version of CMake.";
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ this->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
return this->SetPolicy(pid, status);
@@ -3997,14 +4481,18 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
if (status != cmPolicies::NEW &&
cmPolicies::GetPolicyStatus(id) == cmPolicies::REQUIRED_ALWAYS) {
std::string msg = cmPolicies::GetRequiredAlwaysPolicyError(id);
- this->IssueMessage(cmake::FATAL_ERROR, msg);
+ this->IssueMessage(MessageType::FATAL_ERROR, msg);
return false;
}
// Deprecate old policies, especially those that require a lot
// of code to maintain the old behavior.
- if (status == cmPolicies::OLD && id <= cmPolicies::CMP0036) {
- this->IssueMessage(cmake::DEPRECATION_WARNING,
+ if (status == cmPolicies::OLD && id <= cmPolicies::CMP0067 &&
+ !(this->GetCMakeInstance()->GetIsInTryCompile() &&
+ (
+ // Policies set by cmCoreTryCompile::TryCompileCode.
+ id == cmPolicies::CMP0065))) {
+ this->IssueMessage(MessageType::DEPRECATION_WARNING,
cmPolicies::GetPolicyDeprecatedWarning(id));
}
@@ -4031,7 +4519,7 @@ void cmMakefile::PushPolicy(bool weak, cmPolicies::PolicyMap const& pm)
void cmMakefile::PopPolicy()
{
if (!this->StateSnapshot.PopPolicy()) {
- this->IssueMessage(cmake::FATAL_ERROR,
+ this->IssueMessage(MessageType::FATAL_ERROR,
"cmake_policy POP without matching PUSH");
}
}
@@ -4043,7 +4531,7 @@ void cmMakefile::PopSnapshot(bool reportError)
// reject any still-open nested policy scopes with an error.
while (!this->StateSnapshot.CanPopPolicyScope()) {
if (reportError) {
- this->IssueMessage(cmake::FATAL_ERROR,
+ this->IssueMessage(MessageType::FATAL_ERROR,
"cmake_policy PUSH without matching POP");
reportError = false;
}
@@ -4054,9 +4542,10 @@ void cmMakefile::PopSnapshot(bool reportError)
assert(this->StateSnapshot.IsValid());
}
-bool cmMakefile::SetPolicyVersion(const char* version)
+bool cmMakefile::SetPolicyVersion(std::string const& version_min,
+ std::string const& version_max)
{
- return cmPolicies::ApplyPolicyVersion(this, version);
+ return cmPolicies::ApplyPolicyVersion(this, version_min, version_max);
}
bool cmMakefile::HasCMP0054AlreadyBeenReported(
@@ -4068,7 +4557,7 @@ bool cmMakefile::HasCMP0054AlreadyBeenReported(
void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm)
{
/* Record the setting of every policy. */
- typedef cmPolicies::PolicyID PolicyID;
+ using PolicyID = cmPolicies::PolicyID;
for (PolicyID pid = cmPolicies::CMP0000; pid != cmPolicies::CMPCOUNT;
pid = PolicyID(pid + 1)) {
pm.Set(pid, this->GetPolicyStatus(pid));
@@ -4093,15 +4582,15 @@ bool cmMakefile::IgnoreErrorsCMP0061() const
}
#define FEATURE_STRING(F) , #F
-static const char* const C_FEATURES[] = { CM_NULLPTR FOR_EACH_C_FEATURE(
+static const char* const C_FEATURES[] = { nullptr FOR_EACH_C_FEATURE(
FEATURE_STRING) };
-static const char* const CXX_FEATURES[] = { CM_NULLPTR FOR_EACH_CXX_FEATURE(
+static const char* const CXX_FEATURES[] = { nullptr FOR_EACH_CXX_FEATURE(
FEATURE_STRING) };
#undef FEATURE_STRING
static const char* const C_STANDARDS[] = { "90", "99", "11" };
-static const char* const CXX_STANDARDS[] = { "98", "11", "14", "17" };
+static const char* const CXX_STANDARDS[] = { "98", "11", "14", "17", "20" };
bool cmMakefile::AddRequiredTargetFeature(cmTarget* target,
const std::string& feature,
@@ -4122,10 +4611,8 @@ bool cmMakefile::AddRequiredTargetFeature(cmTarget* target,
return false;
}
- std::vector<std::string> availableFeatures;
- cmSystemTools::ExpandListArgument(features, availableFeatures);
- if (std::find(availableFeatures.begin(), availableFeatures.end(), feature) ==
- availableFeatures.end()) {
+ std::vector<std::string> availableFeatures = cmExpandedList(features);
+ if (!cmContains(availableFeatures, feature)) {
std::ostringstream e;
e << "The compiler feature \"" << feature << "\" is not known to " << lang
<< " compiler\n\""
@@ -4135,7 +4622,7 @@ bool cmMakefile::AddRequiredTargetFeature(cmTarget* target,
if (error) {
*error = e.str();
} else {
- this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e.str(),
this->Backtrace);
}
return false;
@@ -4143,9 +4630,9 @@ bool cmMakefile::AddRequiredTargetFeature(cmTarget* target,
target->AppendProperty("COMPILE_FEATURES", feature.c_str());
- return lang == "C"
- ? this->AddRequiredTargetCFeature(target, feature, error)
- : this->AddRequiredTargetCxxFeature(target, feature, error);
+ return lang == "C" || lang == "OBJC"
+ ? this->AddRequiredTargetCFeature(target, feature, lang, error)
+ : this->AddRequiredTargetCxxFeature(target, feature, lang, error);
}
bool cmMakefile::CompileFeatureKnown(cmTarget const* target,
@@ -4156,15 +4643,15 @@ bool cmMakefile::CompileFeatureKnown(cmTarget const* target,
assert(cmGeneratorExpression::Find(feature) == std::string::npos);
bool isCFeature =
- std::find_if(cmArrayBegin(C_FEATURES) + 1, cmArrayEnd(C_FEATURES),
- cmStrCmp(feature)) != cmArrayEnd(C_FEATURES);
+ std::find_if(cm::cbegin(C_FEATURES) + 1, cm::cend(C_FEATURES),
+ cmStrCmp(feature)) != cm::cend(C_FEATURES);
if (isCFeature) {
lang = "C";
return true;
}
bool isCxxFeature =
- std::find_if(cmArrayBegin(CXX_FEATURES) + 1, cmArrayEnd(CXX_FEATURES),
- cmStrCmp(feature)) != cmArrayEnd(CXX_FEATURES);
+ std::find_if(cm::cbegin(CXX_FEATURES) + 1, cm::cend(CXX_FEATURES),
+ cmStrCmp(feature)) != cm::cend(CXX_FEATURES);
if (isCxxFeature) {
lang = "CXX";
return true;
@@ -4175,13 +4662,14 @@ bool cmMakefile::CompileFeatureKnown(cmTarget const* target,
} else {
e << "Specified";
}
- e << " unknown feature \"" << feature << "\" for "
- "target \""
+ e << " unknown feature \"" << feature
+ << "\" for "
+ "target \""
<< target->GetName() << "\".";
if (error) {
*error = e.str();
} else {
- this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e.str(),
this->Backtrace);
}
return false;
@@ -4201,10 +4689,10 @@ const char* cmMakefile::CompileFeaturesAvailable(const std::string& lang,
if (error) {
*error = e.str();
} else {
- this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e.str(),
this->Backtrace);
}
- return CM_NULLPTR;
+ return nullptr;
}
const char* featuresKnown =
@@ -4224,10 +4712,10 @@ const char* cmMakefile::CompileFeaturesAvailable(const std::string& lang,
if (error) {
*error = e.str();
} else {
- this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e.str(),
this->Backtrace);
}
- return CM_NULLPTR;
+ return nullptr;
}
return featuresKnown;
}
@@ -4236,30 +4724,33 @@ bool cmMakefile::HaveStandardAvailable(cmTarget const* target,
std::string const& lang,
const std::string& feature) const
{
- return lang == "C" ? this->HaveCStandardAvailable(target, feature)
- : this->HaveCxxStandardAvailable(target, feature);
+ return lang == "C" || lang == "OBJC"
+ ? this->HaveCStandardAvailable(target, feature, lang)
+ : this->HaveCxxStandardAvailable(target, feature, lang);
}
bool cmMakefile::HaveCStandardAvailable(cmTarget const* target,
- const std::string& feature) const
+ const std::string& feature,
+ std::string const& lang) const
{
const char* defaultCStandard =
- this->GetDefinition("CMAKE_C_STANDARD_DEFAULT");
+ this->GetDefinition(cmStrCat("CMAKE_", lang, "_STANDARD_DEFAULT"));
if (!defaultCStandard) {
- std::ostringstream e;
- e << "CMAKE_C_STANDARD_DEFAULT is not set. COMPILE_FEATURES support "
- "not fully configured for this compiler.";
- this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
+ this->IssueMessage(
+ MessageType::INTERNAL_ERROR,
+ cmStrCat("CMAKE_", lang,
+ "_STANDARD_DEFAULT is not set. COMPILE_FEATURES support "
+ "not fully configured for this compiler."));
// Return true so the caller does not try to lookup the default standard.
return true;
}
- if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
- cmStrCmp(defaultCStandard)) == cmArrayEnd(C_STANDARDS)) {
- std::ostringstream e;
- e << "The CMAKE_C_STANDARD_DEFAULT variable contains an "
- "invalid value: \""
- << defaultCStandard << "\".";
- this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
+ if (std::find_if(cm::cbegin(C_STANDARDS), cm::cend(C_STANDARDS),
+ cmStrCmp(defaultCStandard)) == cm::cend(C_STANDARDS)) {
+ const std::string e = cmStrCat("The CMAKE_", lang,
+ "_STANDARD_DEFAULT variable contains an "
+ "invalid value: \"",
+ defaultCStandard, "\".");
+ this->IssueMessage(MessageType::INTERNAL_ERROR, e);
return false;
}
@@ -4267,40 +4758,41 @@ bool cmMakefile::HaveCStandardAvailable(cmTarget const* target,
bool needC99 = false;
bool needC11 = false;
- this->CheckNeededCLanguage(feature, needC90, needC99, needC11);
+ this->CheckNeededCLanguage(feature, lang, needC90, needC99, needC11);
- const char* existingCStandard = target->GetProperty("C_STANDARD");
+ const char* existingCStandard =
+ target->GetProperty(cmStrCat(lang, "_STANDARD"));
if (!existingCStandard) {
existingCStandard = defaultCStandard;
}
- if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
- cmStrCmp(existingCStandard)) == cmArrayEnd(C_STANDARDS)) {
- std::ostringstream e;
- e << "The C_STANDARD property on target \"" << target->GetName()
- << "\" contained an invalid value: \"" << existingCStandard << "\".";
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ if (std::find_if(cm::cbegin(C_STANDARDS), cm::cend(C_STANDARDS),
+ cmStrCmp(existingCStandard)) == cm::cend(C_STANDARDS)) {
+ const std::string e = cmStrCat(
+ "The ", lang, "_STANDARD property on target \"", target->GetName(),
+ "\" contained an invalid value: \"", existingCStandard, "\".");
+ this->IssueMessage(MessageType::FATAL_ERROR, e);
return false;
}
const char* const* existingCIt = existingCStandard
- ? std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
+ ? std::find_if(cm::cbegin(C_STANDARDS), cm::cend(C_STANDARDS),
cmStrCmp(existingCStandard))
- : cmArrayEnd(C_STANDARDS);
+ : cm::cend(C_STANDARDS);
if (needC11 && existingCStandard &&
- existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
- cmArrayEnd(C_STANDARDS), cmStrCmp("11"))) {
+ existingCIt < std::find_if(cm::cbegin(C_STANDARDS),
+ cm::cend(C_STANDARDS), cmStrCmp("11"))) {
return false;
}
if (needC99 && existingCStandard &&
- existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
- cmArrayEnd(C_STANDARDS), cmStrCmp("99"))) {
+ existingCIt < std::find_if(cm::cbegin(C_STANDARDS),
+ cm::cend(C_STANDARDS), cmStrCmp("99"))) {
return false;
}
if (needC90 && existingCStandard &&
- existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
- cmArrayEnd(C_STANDARDS), cmStrCmp("90"))) {
+ existingCIt < std::find_if(cm::cbegin(C_STANDARDS),
+ cm::cend(C_STANDARDS), cmStrCmp("90"))) {
return false;
}
return true;
@@ -4310,41 +4802,41 @@ bool cmMakefile::IsLaterStandard(std::string const& lang,
std::string const& lhs,
std::string const& rhs)
{
- if (lang == "C") {
+ if (lang == "C" || lang == "OBJC") {
const char* const* rhsIt = std::find_if(
- cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS), cmStrCmp(rhs));
+ cm::cbegin(C_STANDARDS), cm::cend(C_STANDARDS), cmStrCmp(rhs));
- return std::find_if(rhsIt, cmArrayEnd(C_STANDARDS), cmStrCmp(lhs)) !=
- cmArrayEnd(C_STANDARDS);
+ return std::find_if(rhsIt, cm::cend(C_STANDARDS), cmStrCmp(lhs)) !=
+ cm::cend(C_STANDARDS);
}
const char* const* rhsIt = std::find_if(
- cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS), cmStrCmp(rhs));
+ cm::cbegin(CXX_STANDARDS), cm::cend(CXX_STANDARDS), cmStrCmp(rhs));
- return std::find_if(rhsIt, cmArrayEnd(CXX_STANDARDS), cmStrCmp(lhs)) !=
- cmArrayEnd(CXX_STANDARDS);
+ return std::find_if(rhsIt, cm::cend(CXX_STANDARDS), cmStrCmp(lhs)) !=
+ cm::cend(CXX_STANDARDS);
}
bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
- const std::string& feature) const
+ const std::string& feature,
+ std::string const& lang) const
{
const char* defaultCxxStandard =
- this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT");
+ this->GetDefinition(cmStrCat("CMAKE_", lang, "_STANDARD_DEFAULT"));
if (!defaultCxxStandard) {
- std::ostringstream e;
- e << "CMAKE_CXX_STANDARD_DEFAULT is not set. COMPILE_FEATURES support "
- "not fully configured for this compiler.";
- this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
+ this->IssueMessage(
+ MessageType::INTERNAL_ERROR,
+ cmStrCat("CMAKE_", lang,
+ "_STANDARD_DEFAULT is not set. COMPILE_FEATURES support "
+ "not fully configured for this compiler."));
// Return true so the caller does not try to lookup the default standard.
return true;
}
- if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
- cmStrCmp(defaultCxxStandard)) ==
- cmArrayEnd(CXX_STANDARDS)) {
- std::ostringstream e;
- e << "The CMAKE_CXX_STANDARD_DEFAULT variable contains an "
- "invalid value: \""
- << defaultCxxStandard << "\".";
- this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
+ if (std::find_if(cm::cbegin(CXX_STANDARDS), cm::cend(CXX_STANDARDS),
+ cmStrCmp(defaultCxxStandard)) == cm::cend(CXX_STANDARDS)) {
+ const std::string e =
+ cmStrCat("The CMAKE_", lang, "_STANDARD_DEFAULT variable contains an ",
+ "invalid value: \"", defaultCxxStandard, "\".");
+ this->IssueMessage(MessageType::INTERNAL_ERROR, e);
return false;
}
@@ -4352,232 +4844,250 @@ bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
bool needCxx11 = false;
bool needCxx14 = false;
bool needCxx17 = false;
- this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14,
- needCxx17);
+ bool needCxx20 = false;
+ this->CheckNeededCxxLanguage(feature, lang, needCxx98, needCxx11, needCxx14,
+ needCxx17, needCxx20);
- const char* existingCxxStandard = target->GetProperty("CXX_STANDARD");
+ const char* existingCxxStandard =
+ target->GetProperty(cmStrCat(lang, "_STANDARD"));
if (!existingCxxStandard) {
existingCxxStandard = defaultCxxStandard;
}
- if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
- cmStrCmp(existingCxxStandard)) ==
- cmArrayEnd(CXX_STANDARDS)) {
- std::ostringstream e;
- e << "The CXX_STANDARD property on target \"" << target->GetName()
- << "\" contained an invalid value: \"" << existingCxxStandard << "\".";
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ const char* const* existingCxxLevel =
+ std::find_if(cm::cbegin(CXX_STANDARDS), cm::cend(CXX_STANDARDS),
+ cmStrCmp(existingCxxStandard));
+ if (existingCxxLevel == cm::cend(CXX_STANDARDS)) {
+ const std::string e = cmStrCat(
+ "The ", lang, "_STANDARD property on target \"", target->GetName(),
+ "\" contained an invalid value: \"", existingCxxStandard, "\".");
+ this->IssueMessage(MessageType::FATAL_ERROR, e);
return false;
}
- const char* const* existingCxxIt = existingCxxStandard
- ? std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
- cmStrCmp(existingCxxStandard))
- : cmArrayEnd(CXX_STANDARDS);
+ /* clang-format off */
+ const char* const* needCxxLevel =
+ needCxx20 ? &CXX_STANDARDS[4]
+ : needCxx17 ? &CXX_STANDARDS[3]
+ : needCxx14 ? &CXX_STANDARDS[2]
+ : needCxx11 ? &CXX_STANDARDS[1]
+ : needCxx98 ? &CXX_STANDARDS[0]
+ : nullptr;
+ /* clang-format on */
- if (needCxx11 &&
- existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
- cmArrayEnd(CXX_STANDARDS),
- cmStrCmp("11"))) {
- return false;
- }
- if (needCxx98 &&
- existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
- cmArrayEnd(CXX_STANDARDS),
- cmStrCmp("98"))) {
- return false;
- }
- return true;
+ return !needCxxLevel || needCxxLevel <= existingCxxLevel;
}
void cmMakefile::CheckNeededCxxLanguage(const std::string& feature,
+ std::string const& lang,
bool& needCxx98, bool& needCxx11,
- bool& needCxx14, bool& needCxx17) const
+ bool& needCxx14, bool& needCxx17,
+ bool& needCxx20) const
{
if (const char* propCxx98 =
- this->GetDefinition("CMAKE_CXX98_COMPILE_FEATURES")) {
- std::vector<std::string> props;
- cmSystemTools::ExpandListArgument(propCxx98, props);
- needCxx98 = std::find(props.begin(), props.end(), feature) != props.end();
+ this->GetDefinition(cmStrCat("CMAKE_", lang, "98_COMPILE_FEATURES"))) {
+ std::vector<std::string> props = cmExpandedList(propCxx98);
+ needCxx98 = cmContains(props, feature);
}
if (const char* propCxx11 =
- this->GetDefinition("CMAKE_CXX11_COMPILE_FEATURES")) {
- std::vector<std::string> props;
- cmSystemTools::ExpandListArgument(propCxx11, props);
- needCxx11 = std::find(props.begin(), props.end(), feature) != props.end();
+ this->GetDefinition(cmStrCat("CMAKE_", lang, "11_COMPILE_FEATURES"))) {
+ std::vector<std::string> props = cmExpandedList(propCxx11);
+ needCxx11 = cmContains(props, feature);
}
if (const char* propCxx14 =
- this->GetDefinition("CMAKE_CXX14_COMPILE_FEATURES")) {
- std::vector<std::string> props;
- cmSystemTools::ExpandListArgument(propCxx14, props);
- needCxx14 = std::find(props.begin(), props.end(), feature) != props.end();
+ this->GetDefinition(cmStrCat("CMAKE_", lang, "14_COMPILE_FEATURES"))) {
+ std::vector<std::string> props = cmExpandedList(propCxx14);
+ needCxx14 = cmContains(props, feature);
}
if (const char* propCxx17 =
- this->GetDefinition("CMAKE_CXX17_COMPILE_FEATURES")) {
- std::vector<std::string> props;
- cmSystemTools::ExpandListArgument(propCxx17, props);
- needCxx17 = std::find(props.begin(), props.end(), feature) != props.end();
+ this->GetDefinition(cmStrCat("CMAKE_", lang, "17_COMPILE_FEATURES"))) {
+ std::vector<std::string> props = cmExpandedList(propCxx17);
+ needCxx17 = cmContains(props, feature);
+ }
+ if (const char* propCxx20 =
+ this->GetDefinition(cmStrCat("CMAKE_", lang, "20_COMPILE_FEATURES"))) {
+ std::vector<std::string> props = cmExpandedList(propCxx20);
+ needCxx20 = cmContains(props, feature);
}
}
bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target,
const std::string& feature,
+ std::string const& lang,
std::string* error) const
{
bool needCxx98 = false;
bool needCxx11 = false;
bool needCxx14 = false;
bool needCxx17 = false;
-
- this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14,
- needCxx17);
-
- const char* existingCxxStandard = target->GetProperty("CXX_STANDARD");
+ bool needCxx20 = false;
+
+ this->CheckNeededCxxLanguage(feature, lang, needCxx98, needCxx11, needCxx14,
+ needCxx17, needCxx20);
+
+ const char* existingCxxStandard =
+ target->GetProperty(cmStrCat(lang, "_STANDARD"));
+ if (existingCxxStandard == nullptr) {
+ const char* defaultCxxStandard =
+ this->GetDefinition(cmStrCat("CMAKE_", lang, "_STANDARD_DEFAULT"));
+ if (defaultCxxStandard && *defaultCxxStandard) {
+ existingCxxStandard = defaultCxxStandard;
+ }
+ }
+ const char* const* existingCxxLevel = nullptr;
if (existingCxxStandard) {
- if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
- cmStrCmp(existingCxxStandard)) ==
- cmArrayEnd(CXX_STANDARDS)) {
+ existingCxxLevel =
+ std::find_if(cm::cbegin(CXX_STANDARDS), cm::cend(CXX_STANDARDS),
+ cmStrCmp(existingCxxStandard));
+ if (existingCxxLevel == cm::cend(CXX_STANDARDS)) {
+ const std::string e = cmStrCat(
+ "The ", lang, "_STANDARD property on target \"", target->GetName(),
+ "\" contained an invalid value: \"", existingCxxStandard, "\".");
+ if (error) {
+ *error = e;
+ } else {
+ this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e,
+ this->Backtrace);
+ }
+ return false;
+ }
+ }
+
+ const char* existingCudaStandard = target->GetProperty("CUDA_STANDARD");
+ const char* const* existingCudaLevel = nullptr;
+ if (existingCudaStandard) {
+ existingCudaLevel =
+ std::find_if(cm::cbegin(CXX_STANDARDS), cm::cend(CXX_STANDARDS),
+ cmStrCmp(existingCudaStandard));
+ if (existingCudaLevel == cm::cend(CXX_STANDARDS)) {
std::ostringstream e;
- e << "The CXX_STANDARD property on target \"" << target->GetName()
- << "\" contained an invalid value: \"" << existingCxxStandard << "\".";
+ e << "The CUDA_STANDARD property on target \"" << target->GetName()
+ << "\" contained an invalid value: \"" << existingCudaStandard
+ << "\".";
if (error) {
*error = e.str();
} else {
- this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
- this->Backtrace);
+ this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
+ e.str(), this->Backtrace);
}
return false;
}
}
- const char* const* existingCxxIt = existingCxxStandard
- ? std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
- cmStrCmp(existingCxxStandard))
- : cmArrayEnd(CXX_STANDARDS);
-
- bool setCxx98 = needCxx98 && !existingCxxStandard;
- bool setCxx11 = needCxx11 && !existingCxxStandard;
- bool setCxx14 = needCxx14 && !existingCxxStandard;
- bool setCxx17 = needCxx17 && !existingCxxStandard;
-
- if (needCxx17 && existingCxxStandard &&
- existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
- cmArrayEnd(CXX_STANDARDS),
- cmStrCmp("17"))) {
- setCxx17 = true;
- } else if (needCxx14 && existingCxxStandard &&
- existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
- cmArrayEnd(CXX_STANDARDS),
- cmStrCmp("14"))) {
- setCxx14 = true;
- } else if (needCxx11 && existingCxxStandard &&
- existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
- cmArrayEnd(CXX_STANDARDS),
- cmStrCmp("11"))) {
- setCxx11 = true;
- } else if (needCxx98 && existingCxxStandard &&
- existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS),
- cmArrayEnd(CXX_STANDARDS),
- cmStrCmp("98"))) {
- setCxx98 = true;
- }
-
- if (setCxx17) {
- target->SetProperty("CXX_STANDARD", "17");
- target->SetProperty("CUDA_STANDARD", "17");
- } else if (setCxx14) {
- target->SetProperty("CXX_STANDARD", "14");
- target->SetProperty("CUDA_STANDARD", "14");
- } else if (setCxx11) {
- target->SetProperty("CXX_STANDARD", "11");
- target->SetProperty("CUDA_STANDARD", "11");
- } else if (setCxx98) {
- target->SetProperty("CXX_STANDARD", "98");
- target->SetProperty("CUDA_STANDARD", "98");
+
+ /* clang-format off */
+ const char* const* needCxxLevel =
+ needCxx20 ? &CXX_STANDARDS[4]
+ : needCxx17 ? &CXX_STANDARDS[3]
+ : needCxx14 ? &CXX_STANDARDS[2]
+ : needCxx11 ? &CXX_STANDARDS[1]
+ : needCxx98 ? &CXX_STANDARDS[0]
+ : nullptr;
+ /* clang-format on */
+
+ if (needCxxLevel) {
+ // Ensure the C++ language level is high enough to support
+ // the needed C++ features.
+ if (!existingCxxLevel || existingCxxLevel < needCxxLevel) {
+ target->SetProperty(cmStrCat(lang, "_STANDARD"), *needCxxLevel);
+ }
+
+ // Ensure the CUDA language level is high enough to support
+ // the needed C++ features.
+ if (!existingCudaLevel || existingCudaLevel < needCxxLevel) {
+ target->SetProperty("CUDA_STANDARD", *needCxxLevel);
+ }
}
+
return true;
}
void cmMakefile::CheckNeededCLanguage(const std::string& feature,
- bool& needC90, bool& needC99,
- bool& needC11) const
+ std::string const& lang, bool& needC90,
+ bool& needC99, bool& needC11) const
{
if (const char* propC90 =
- this->GetDefinition("CMAKE_C90_COMPILE_FEATURES")) {
- std::vector<std::string> props;
- cmSystemTools::ExpandListArgument(propC90, props);
- needC90 = std::find(props.begin(), props.end(), feature) != props.end();
+ this->GetDefinition(cmStrCat("CMAKE_", lang, "90_COMPILE_FEATURES"))) {
+ std::vector<std::string> props = cmExpandedList(propC90);
+ needC90 = cmContains(props, feature);
}
if (const char* propC99 =
- this->GetDefinition("CMAKE_C99_COMPILE_FEATURES")) {
- std::vector<std::string> props;
- cmSystemTools::ExpandListArgument(propC99, props);
- needC99 = std::find(props.begin(), props.end(), feature) != props.end();
+ this->GetDefinition(cmStrCat("CMAKE_", lang, "99_COMPILE_FEATURES"))) {
+ std::vector<std::string> props = cmExpandedList(propC99);
+ needC99 = cmContains(props, feature);
}
if (const char* propC11 =
- this->GetDefinition("CMAKE_C11_COMPILE_FEATURES")) {
- std::vector<std::string> props;
- cmSystemTools::ExpandListArgument(propC11, props);
- needC11 = std::find(props.begin(), props.end(), feature) != props.end();
+ this->GetDefinition(cmStrCat("CMAKE_", lang, "11_COMPILE_FEATURES"))) {
+ std::vector<std::string> props = cmExpandedList(propC11);
+ needC11 = cmContains(props, feature);
}
}
bool cmMakefile::AddRequiredTargetCFeature(cmTarget* target,
const std::string& feature,
+ std::string const& lang,
std::string* error) const
{
bool needC90 = false;
bool needC99 = false;
bool needC11 = false;
- this->CheckNeededCLanguage(feature, needC90, needC99, needC11);
+ this->CheckNeededCLanguage(feature, lang, needC90, needC99, needC11);
- const char* existingCStandard = target->GetProperty("C_STANDARD");
+ const char* existingCStandard =
+ target->GetProperty(cmStrCat(lang, "_STANDARD"));
+ if (existingCStandard == nullptr) {
+ const char* defaultCStandard =
+ this->GetDefinition(cmStrCat("CMAKE_", lang, "_STANDARD_DEFAULT"));
+ if (defaultCStandard && *defaultCStandard) {
+ existingCStandard = defaultCStandard;
+ }
+ }
if (existingCStandard) {
- if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
- cmStrCmp(existingCStandard)) == cmArrayEnd(C_STANDARDS)) {
- std::ostringstream e;
- e << "The C_STANDARD property on target \"" << target->GetName()
- << "\" contained an invalid value: \"" << existingCStandard << "\".";
+ if (std::find_if(cm::cbegin(C_STANDARDS), cm::cend(C_STANDARDS),
+ cmStrCmp(existingCStandard)) == cm::cend(C_STANDARDS)) {
+ const std::string e = cmStrCat(
+ "The ", lang, "_STANDARD property on target \"", target->GetName(),
+ "\" contained an invalid value: \"", existingCStandard, "\".");
if (error) {
- *error = e.str();
+ *error = e;
} else {
- this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e,
this->Backtrace);
}
return false;
}
}
const char* const* existingCIt = existingCStandard
- ? std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
+ ? std::find_if(cm::cbegin(C_STANDARDS), cm::cend(C_STANDARDS),
cmStrCmp(existingCStandard))
- : cmArrayEnd(C_STANDARDS);
+ : cm::cend(C_STANDARDS);
bool setC90 = needC90 && !existingCStandard;
bool setC99 = needC99 && !existingCStandard;
bool setC11 = needC11 && !existingCStandard;
if (needC11 && existingCStandard &&
- existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
- cmArrayEnd(C_STANDARDS), cmStrCmp("11"))) {
+ existingCIt < std::find_if(cm::cbegin(C_STANDARDS),
+ cm::cend(C_STANDARDS), cmStrCmp("11"))) {
setC11 = true;
} else if (needC99 && existingCStandard &&
- existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
- cmArrayEnd(C_STANDARDS),
+ existingCIt < std::find_if(cm::cbegin(C_STANDARDS),
+ cm::cend(C_STANDARDS),
cmStrCmp("99"))) {
setC99 = true;
} else if (needC90 && existingCStandard &&
- existingCIt < std::find_if(cmArrayBegin(C_STANDARDS),
- cmArrayEnd(C_STANDARDS),
+ existingCIt < std::find_if(cm::cbegin(C_STANDARDS),
+ cm::cend(C_STANDARDS),
cmStrCmp("90"))) {
setC90 = true;
}
if (setC11) {
- target->SetProperty("C_STANDARD", "11");
+ target->SetProperty(cmStrCat(lang, "_STANDARD"), "11");
} else if (setC99) {
- target->SetProperty("C_STANDARD", "99");
+ target->SetProperty(cmStrCat(lang, "_STANDARD"), "99");
} else if (setC90) {
- target->SetProperty("C_STANDARD", "90");
+ target->SetProperty(cmStrCat(lang, "_STANDARD"), "90");
}
return true;
}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index e65ba468f..6e5949404 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -3,33 +3,42 @@
#ifndef cmMakefile_h
#define cmMakefile_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmsys/RegularExpression.hxx"
+#include <cstddef>
#include <deque>
+#include <functional>
#include <map>
+#include <memory>
#include <set>
#include <stack>
-#include <stddef.h>
#include <string>
+#include <unordered_map>
#include <vector>
+#include <cm/string_view>
+
+#include "cmsys/RegularExpression.hxx"
+
#include "cmAlgorithms.h"
+#include "cmCustomCommandTypes.h"
#include "cmListFileCache.h"
+#include "cmMessageType.h"
#include "cmNewLineStyle.h"
#include "cmPolicies.h"
+#include "cmSourceFileLocationKind.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
-#include "cmTarget.h"
-#include "cm_auto_ptr.hxx"
-#include "cm_unordered_map.hxx"
-#include "cmake.h"
+#include "cmStringAlgorithms.h"
+
+// IWYU does not see that 'std::unordered_map<std::string, cmTarget>'
+// will not compile without the complete type.
+#include "cmTarget.h" // IWYU pragma: keep
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmSourceGroup.h"
+#if !defined(CMAKE_BOOTSTRAP)
+# include "cmSourceGroup.h"
#endif
-class cmCommand;
class cmCompiledGeneratorExpression;
class cmCustomCommandLines;
class cmExecutionStatus;
@@ -38,6 +47,7 @@ class cmExportBuildFileGenerator;
class cmFunctionBlocker;
class cmGeneratorExpressionEvaluationFile;
class cmGlobalGenerator;
+class cmImplicitDependsList;
class cmInstallGenerator;
class cmMessenger;
class cmSourceFile;
@@ -45,6 +55,33 @@ class cmState;
class cmTest;
class cmTestGenerator;
class cmVariableWatch;
+class cmake;
+
+/** Flag if byproducts shall also be considered. */
+enum class cmSourceOutputKind
+{
+ OutputOnly,
+ OutputOrByproduct
+};
+
+/** Target and source file which have a specific output. */
+struct cmSourcesWithOutput
+{
+ /** Target with byproduct. */
+ cmTarget* Target = nullptr;
+
+ /** Source file with output or byproduct. */
+ cmSourceFile* Source = nullptr;
+ bool SourceIsByproduct = false;
+};
+
+/** A type-safe wrapper for a string representing a directory id. */
+class cmDirectoryId
+{
+public:
+ cmDirectoryId(std::string s);
+ std::string String;
+};
/** \class cmMakefile
* \brief Process the input CMakeLists.txt file.
@@ -55,8 +92,6 @@ class cmVariableWatch;
*/
class cmMakefile
{
- CM_DISABLE_COPY(cmMakefile)
-
public:
/* Mark a variable as used */
void MarkVariableAsUsed(const std::string& var);
@@ -74,16 +109,20 @@ public:
*/
~cmMakefile();
- bool ReadListFile(const char* filename);
+ cmMakefile(cmMakefile const&) = delete;
+ cmMakefile& operator=(cmMakefile const&) = delete;
+
+ cmDirectoryId GetDirectoryId() const;
- bool ReadDependentFile(const char* filename, bool noPolicyScope = true);
+ bool ReadListFile(const std::string& filename);
- bool ProcessBuildsystemFile(const char* filename);
+ bool ReadDependentFile(const std::string& filename,
+ bool noPolicyScope = true);
/**
* Add a function blocker to this makefile
*/
- void AddFunctionBlocker(cmFunctionBlocker* fb);
+ void AddFunctionBlocker(std::unique_ptr<cmFunctionBlocker> fb);
/// @return whether we are processing the top CMakeLists.txt file.
bool IsRootMakefile() const;
@@ -92,8 +131,7 @@ public:
* Remove the function blocker whose scope ends with the given command.
* This returns ownership of the function blocker object.
*/
- CM_AUTO_PTR<cmFunctionBlocker> RemoveFunctionBlocker(
- cmFunctionBlocker* fb, const cmListFileFunction& lff);
+ std::unique_ptr<cmFunctionBlocker> RemoveFunctionBlocker();
/**
* Try running cmake and building a file. This is used for dynalically
@@ -101,7 +139,8 @@ public:
*/
int TryCompile(const std::string& srcdir, const std::string& bindir,
const std::string& projectName, const std::string& targetName,
- bool fast, const std::vector<std::string>* cmakeArgs,
+ bool fast, int jobs,
+ const std::vector<std::string>* cmakeArgs,
std::string& output);
bool GetIsSourceFileTryCompile() const;
@@ -112,6 +151,13 @@ public:
bool EnforceUniqueName(std::string const& name, std::string& msg,
bool isCustom = false) const;
+ using FinalAction = std::function<void(cmMakefile&)>;
+
+ /**
+ * Register an action that is executed during FinalPass
+ */
+ void AddFinalAction(FinalAction action);
+
/**
* Perform FinalPass, Library dependency analysis etc before output of the
* makefile.
@@ -119,55 +165,75 @@ public:
void ConfigureFinalPass();
/**
- * run the final pass on all commands.
+ * run all FinalActions.
*/
void FinalPass();
- /** How to handle custom commands for object libraries */
- enum ObjectLibraryCommands
- {
- RejectObjectLibraryCommands,
- AcceptObjectLibraryCommands
- };
+ /**
+ * Get the target for PRE_BUILD, PRE_LINK, or POST_BUILD commands.
+ */
+ cmTarget* GetCustomCommandTarget(
+ const std::string& target, cmObjectLibraryCommands objLibCommands) const;
/** Add a custom command to the build. */
- void AddCustomCommandToTarget(
+ cmTarget* AddCustomCommandToTarget(
const std::string& target, const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
- const cmCustomCommandLines& commandLines, cmTarget::CustomCommandType type,
+ const cmCustomCommandLines& commandLines, cmCustomCommandType type,
const char* comment, const char* workingDir, bool escapeOldStyle = true,
bool uses_terminal = false, const std::string& depfile = "",
- bool command_expand_lists = false,
- ObjectLibraryCommands objLibraryCommands = RejectObjectLibraryCommands);
+ const std::string& job_pool = "", bool command_expand_lists = false,
+ cmObjectLibraryCommands objLibCommands = cmObjectLibraryCommands::Reject);
cmSourceFile* AddCustomCommandToOutput(
- const std::vector<std::string>& outputs,
- const std::vector<std::string>& byproducts,
- const std::vector<std::string>& depends,
+ const std::string& output, const std::vector<std::string>& depends,
const std::string& main_dependency,
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace = false, bool escapeOldStyle = true,
bool uses_terminal = false, bool command_expand_lists = false,
- const std::string& depfile = "");
+ const std::string& depfile = "", const std::string& job_pool = "");
cmSourceFile* AddCustomCommandToOutput(
- const std::string& output, const std::vector<std::string>& depends,
+ const std::vector<std::string>& outputs,
+ const std::vector<std::string>& byproducts,
+ const std::vector<std::string>& depends,
const std::string& main_dependency,
+ const cmImplicitDependsList& implicit_depends,
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace = false, bool escapeOldStyle = true,
bool uses_terminal = false, bool command_expand_lists = false,
- const std::string& depfile = "");
+ const std::string& depfile = "", const std::string& job_pool = "");
void AddCustomCommandOldStyle(const std::string& target,
const std::vector<std::string>& outputs,
const std::vector<std::string>& depends,
const std::string& source,
const cmCustomCommandLines& commandLines,
const char* comment);
+ bool AppendCustomCommandToOutput(
+ const std::string& output, const std::vector<std::string>& depends,
+ const cmImplicitDependsList& implicit_depends,
+ const cmCustomCommandLines& commandLines);
+
+ /**
+ * Add target byproducts.
+ */
+ void AddTargetByproducts(cmTarget* target,
+ const std::vector<std::string>& byproducts);
+
+ /**
+ * Add source file outputs.
+ */
+ void AddSourceOutputs(cmSourceFile* source,
+ const std::vector<std::string>& outputs,
+ const std::vector<std::string>& byproducts);
/**
* Add a define flag to the build.
*/
- void AddDefineFlag(const char* definition);
- void RemoveDefineFlag(const char* definition);
- void AddCompileOption(const char* option);
+ void AddDefineFlag(std::string const& definition);
+ void RemoveDefineFlag(std::string const& definition);
+ void AddCompileDefinition(std::string const& definition);
+ void AddCompileOption(std::string const& option);
+ void AddLinkOption(std::string const& option);
+ void AddLinkDirectory(std::string const& directory, bool before = false);
/** Create a new imported target with the name and type given. */
cmTarget* AddImportedTarget(const std::string& name,
@@ -176,36 +242,34 @@ public:
cmTarget* AddNewTarget(cmStateEnums::TargetType type,
const std::string& name);
+ /** Create a target instance for the utility. */
+ cmTarget* AddNewUtilityTarget(const std::string& utilityName,
+ cmCommandOrigin origin, bool excludeFromAll);
+
/**
* Add an executable to the build.
*/
- cmTarget* AddExecutable(const char* exename,
+ cmTarget* AddExecutable(const std::string& exename,
const std::vector<std::string>& srcs,
bool excludeFromAll = false);
/**
- * Add a utility to the build. A utiltity target is a command that
+ * Return the utility target output source file name and the CMP0049 name.
+ */
+ cmUtilityOutput GetUtilityOutput(cmTarget* target);
+
+ /**
+ * Add a utility to the build. A utility target is a command that
* is run every time the target is built.
*/
cmTarget* AddUtilityCommand(
- const std::string& utilityName, bool excludeFromAll,
- const std::vector<std::string>& depends, const char* workingDirectory,
- const char* command, const char* arg1 = CM_NULLPTR,
- const char* arg2 = CM_NULLPTR, const char* arg3 = CM_NULLPTR,
- const char* arg4 = CM_NULLPTR);
- cmTarget* AddUtilityCommand(
- const std::string& utilityName, bool excludeFromAll,
- const char* workingDirectory, const std::vector<std::string>& depends,
- const cmCustomCommandLines& commandLines, bool escapeOldStyle = true,
- const char* comment = CM_NULLPTR, bool uses_terminal = false,
- bool command_expand_lists = false);
- cmTarget* AddUtilityCommand(
- const std::string& utilityName, bool excludeFromAll,
- const char* workingDirectory, const std::vector<std::string>& byproducts,
+ const std::string& utilityName, cmCommandOrigin origin,
+ bool excludeFromAll, const char* workingDirectory,
+ const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle = true,
- const char* comment = CM_NULLPTR, bool uses_terminal = false,
- bool command_expand_lists = false);
+ const char* comment = nullptr, bool uses_terminal = false,
+ bool command_expand_lists = false, const std::string& job_pool = "");
/**
* Add a subdirectory to the build.
@@ -231,23 +295,22 @@ public:
* Add a variable definition to the build. This variable
* can be used in CMake to refer to lists, directories, etc.
*/
- void AddDefinition(const std::string& name, const char* value);
- ///! Add a definition to this makefile and the global cmake cache.
- void AddCacheDefinition(const std::string& name, const char* value,
- const char* doc, cmStateEnums::CacheEntryType type,
- bool force = false);
-
+ void AddDefinition(const std::string& name, cm::string_view value);
/**
* Add bool variable definition to the build.
*/
- void AddDefinition(const std::string& name, bool);
+ void AddDefinitionBool(const std::string& name, bool);
+ //! Add a definition to this makefile and the global cmake cache.
+ void AddCacheDefinition(const std::string& name, const char* value,
+ const char* doc, cmStateEnums::CacheEntryType type,
+ bool force = false);
/**
* Remove a variable definition from the build. This is not valid
* for cache entries, and will only affect the current makefile.
*/
void RemoveDefinition(const std::string& name);
- ///! Remove a definition from the cache.
+ //! Remove a definition from the cache.
void RemoveCacheDefinition(const std::string& name);
/**
@@ -259,6 +322,9 @@ public:
std::string GetConfigurations(std::vector<std::string>& configs,
bool single = true) const;
+ /** Get the configurations for dependency checking. */
+ std::vector<std::string> GetGeneratorConfigs() const;
+
/**
* Set the name of the library.
*/
@@ -268,29 +334,16 @@ public:
bool excludeFromAll = false);
void AddAlias(const std::string& libname, const std::string& tgt);
-#if defined(CMAKE_BUILD_WITH_CMAKE)
- /**
- * Add a root source group for consideration when adding a new source.
- */
- void AddSourceGroup(const std::string& name, const char* regex = CM_NULLPTR);
-
- /**
- * Add a source group for consideration when adding a new source.
- * name is tokenized.
- */
- void AddSourceGroup(const std::vector<std::string>& name,
- const char* regex = CM_NULLPTR);
-
-#endif
-
//@{
/**
- * Set, Push, Pop policy values for CMake.
- */
+ * Set, Push, Pop policy values for CMake.
+ */
bool SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
bool SetPolicy(const char* id, cmPolicies::PolicyStatus status);
- cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id) const;
- bool SetPolicyVersion(const char* version);
+ cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id,
+ bool parent_scope = false) const;
+ bool SetPolicyVersion(std::string const& version_min,
+ std::string const& version_max);
void RecordPolicies(cmPolicies::PolicyMap& pm);
//@}
@@ -301,6 +354,9 @@ public:
PolicyPushPop(cmMakefile* m);
~PolicyPushPop();
+ PolicyPushPop(const PolicyPushPop&) = delete;
+ PolicyPushPop& operator=(const PolicyPushPop&) = delete;
+
private:
cmMakefile* Makefile;
};
@@ -314,21 +370,21 @@ public:
bool IgnoreErrorsCMP0061() const;
- const char* GetHomeDirectory() const;
- const char* GetHomeOutputDirectory() const;
+ std::string const& GetHomeDirectory() const;
+ std::string const& GetHomeOutputDirectory() const;
/**
* Set CMAKE_SCRIPT_MODE_FILE variable when running a -P script.
*/
- void SetScriptModeFile(const char* scriptfile);
+ void SetScriptModeFile(std::string const& scriptfile);
/**
* Set CMAKE_ARGC, CMAKE_ARGV0 ... variables.
*/
void SetArgcArgv(const std::vector<std::string>& args);
- const char* GetCurrentSourceDirectory() const;
- const char* GetCurrentBinaryDirectory() const;
+ std::string const& GetCurrentSourceDirectory() const;
+ std::string const& GetCurrentBinaryDirectory() const;
//@}
@@ -358,14 +414,13 @@ public:
return this->ComplainFileRegularExpression.c_str();
}
- /**
- * Get the list of targets
- */
- cmTargets& GetTargets() { return this->Targets; }
- /**
- * Get the list of targets, const version
- */
- const cmTargets& GetTargets() const { return this->Targets; }
+ // -- List of targets
+ using cmTargetMap = std::unordered_map<std::string, cmTarget>;
+ /** Get the target map */
+ cmTargetMap& GetTargets() { return this->Targets; }
+ /** Get the target map - const version */
+ cmTargetMap const& GetTargets() const { return this->Targets; }
+
const std::vector<cmTarget*>& GetOwnedImportedTargets() const
{
return this->ImportedTargetsOwned;
@@ -393,22 +448,32 @@ public:
/** Get a cmSourceFile pointer for a given source name, if the name is
* not found, then a null pointer is returned.
*/
- cmSourceFile* GetSource(const std::string& sourceName) const;
+ cmSourceFile* GetSource(
+ const std::string& sourceName,
+ cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous) const;
/** Create the source file and return it. generated
* indicates if it is a generated file, this is used in determining
* how to create the source file instance e.g. name
*/
- cmSourceFile* CreateSource(const std::string& sourceName,
- bool generated = false);
+ cmSourceFile* CreateSource(
+ const std::string& sourceName, bool generated = false,
+ cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous);
/** Get a cmSourceFile pointer for a given source name, if the name is
* not found, then create the source file and return it. generated
* indicates if it is a generated file, this is used in determining
* how to create the source file instance e.g. name
*/
- cmSourceFile* GetOrCreateSource(const std::string& sourceName,
- bool generated = false);
+ cmSourceFile* GetOrCreateSource(
+ const std::string& sourceName, bool generated = false,
+ cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous);
+
+ /** Get a cmSourceFile pointer for a given source name and always mark the
+ * file as generated, if the name is not found, then create the source file
+ * and return it.
+ */
+ cmSourceFile* GetOrCreateGeneratedSource(const std::string& sourceName);
void AddTargetObject(std::string const& tgtName, std::string const& objFile);
@@ -418,8 +483,9 @@ public:
* cache is then queried.
*/
const char* GetDefinition(const std::string&) const;
- const char* GetSafeDefinition(const std::string&) const;
- const char* GetRequiredDefinition(const std::string& name) const;
+ const std::string* GetDef(const std::string&) const;
+ const std::string& GetSafeDefinition(const std::string&) const;
+ const std::string& GetRequiredDefinition(const std::string& name) const;
bool IsDefinitionSet(const std::string&) const;
/**
* Get the list of all variables in the current space. If argument
@@ -445,8 +511,23 @@ public:
/** Return whether the target platform is x32. */
bool PlatformIsx32() const;
+ /** Apple SDK Type */
+ enum class AppleSDK
+ {
+ MacOS,
+ IPhoneOS,
+ IPhoneSimulator,
+ AppleTVOS,
+ AppleTVSimulator,
+ WatchOS,
+ WatchSimulator,
+ };
+
+ /** What SDK type points CMAKE_OSX_SYSROOT to? */
+ AppleSDK GetAppleSDKType() const;
+
/** Return whether the target platform is Apple iOS. */
- bool PlatformIsAppleIos() const;
+ bool PlatformIsAppleEmbedded() const;
/** Retrieve soname flag for the specified language if supported */
const char* GetSONameFlag(const std::string& language) const;
@@ -459,9 +540,9 @@ public:
/**
* Make sure CMake can write this file
*/
- bool CanIWriteThisFile(const char* fileName) const;
+ bool CanIWriteThisFile(std::string const& fileName) const;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
/**
* Get the vector source groups.
*/
@@ -474,6 +555,36 @@ public:
* Get the source group
*/
cmSourceGroup* GetSourceGroup(const std::vector<std::string>& name) const;
+
+ /**
+ * Add a root source group for consideration when adding a new source.
+ */
+ void AddSourceGroup(const std::string& name, const char* regex = nullptr);
+
+ /**
+ * Add a source group for consideration when adding a new source.
+ * name is tokenized.
+ */
+ void AddSourceGroup(const std::vector<std::string>& name,
+ const char* regex = nullptr);
+
+ /**
+ * Get and existing or create a new source group.
+ */
+ cmSourceGroup* GetOrCreateSourceGroup(
+ const std::vector<std::string>& folders);
+
+ /**
+ * Get and existing or create a new source group.
+ * The name will be tokenized.
+ */
+ cmSourceGroup* GetOrCreateSourceGroup(const std::string& name);
+
+ /**
+ * find what source group this source is in
+ */
+ cmSourceGroup* FindSourceGroup(const std::string& source,
+ std::vector<cmSourceGroup>& groups) const;
#endif
/**
@@ -483,7 +594,7 @@ public:
{
return this->ListFiles;
}
- ///! When the file changes cmake will be re-run from the build system.
+ //! When the file changes cmake will be re-run from the build system.
void AddCMakeDependFile(const std::string& file)
{
this->ListFiles.push_back(file);
@@ -518,12 +629,11 @@ public:
* entry in the this->Definitions map. Also \@var\@ is
* expanded to match autoconf style expansions.
*/
- const char* ExpandVariablesInString(std::string& source) const;
- const char* ExpandVariablesInString(std::string& source, bool escapeQuotes,
- bool noEscapes, bool atOnly = false,
- const char* filename = CM_NULLPTR,
- long line = -1, bool removeEmpty = false,
- bool replaceAt = false) const;
+ const std::string& ExpandVariablesInString(std::string& source) const;
+ const std::string& ExpandVariablesInString(
+ std::string& source, bool escapeQuotes, bool noEscapes,
+ bool atOnly = false, const char* filename = nullptr, long line = -1,
+ bool removeEmpty = false, bool replaceAt = false) const;
/**
* Remove any remaining variables in the string. Anything with ${var} or
@@ -544,24 +654,21 @@ public:
bool atOnly, bool escapeQuotes) const;
/**
- * Copy file but change lines acording to ConfigureString
+ * Copy file but change lines according to ConfigureString
*/
- int ConfigureFile(const char* infile, const char* outfile, bool copyonly,
- bool atOnly, bool escapeQuotes,
+ int ConfigureFile(const std::string& infile, const std::string& outfile,
+ bool copyonly, bool atOnly, bool escapeQuotes,
cmNewLineStyle = cmNewLineStyle());
-#if defined(CMAKE_BUILD_WITH_CMAKE)
/**
- * find what source group this source is in
+ * Print a command's invocation
*/
- cmSourceGroup* FindSourceGroup(const char* source,
- std::vector<cmSourceGroup>& groups) const;
-#endif
+ void PrintCommandTrace(const cmListFileFunction& lff) const;
/**
- * Print a command's invocation
+ * Set a callback that is invoked whenever ExecuteCommand is called.
*/
- void PrintCommandTrace(const cmListFileFunction& lff) const;
+ void OnExecuteCommand(std::function<void()> callback);
/**
* Execute a single CMake command. Returns true if the command
@@ -570,7 +677,7 @@ public:
bool ExecuteCommand(const cmListFileFunction& lff,
cmExecutionStatus& status);
- ///! Enable support for named language, if nil then all languages are
+ //! Enable support for named language, if nil then all languages are
/// enabled.
void EnableLanguage(std::vector<std::string> const& languages,
bool optional);
@@ -581,12 +688,12 @@ public:
* Get the variable watch. This is used to determine when certain variables
* are accessed.
*/
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmVariableWatch* GetVariableWatch() const;
#endif
- ///! Display progress or status message.
- void DisplayStatus(const char*, float) const;
+ //! Display progress or status message.
+ void DisplayStatus(const std::string&, float) const;
/**
* Expand the given list file arguments into the full set after
@@ -594,11 +701,11 @@ public:
*/
bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
std::vector<std::string>& outArgs,
- const char* filename = CM_NULLPTR) const;
+ const char* filename = nullptr) const;
bool ExpandArguments(std::vector<cmListFileArgument> const& inArgs,
std::vector<cmExpandedCommandArgument>& outArgs,
- const char* filename = CM_NULLPTR) const;
+ const char* filename = nullptr) const;
/**
* Get the instance
@@ -614,15 +721,23 @@ public:
{
return this->SourceFiles;
}
- std::vector<cmSourceFile*>& GetSourceFiles() { return this->SourceFiles; }
/**
- * Is there a source file that has the provided source file as an output?
- * if so then return it
+ * Return the target if the provided source name is a byproduct of a utility
+ * target or a PRE_BUILD, PRE_LINK, or POST_BUILD command.
+ * Return the source file which has the provided source name as output.
+ */
+ cmSourcesWithOutput GetSourcesWithOutput(const std::string& name) const;
+
+ /**
+ * Is there a source file that has the provided source name as an output?
+ * If so then return it.
*/
- cmSourceFile* GetSourceFileWithOutput(const std::string& outName) const;
+ cmSourceFile* GetSourceFileWithOutput(
+ const std::string& name,
+ cmSourceOutputKind kind = cmSourceOutputKind::OutputOnly) const;
- ///! Add a new cmTest to the list of tests for this makefile.
+ //! Add a new cmTest to the list of tests for this makefile.
cmTest* CreateTest(const std::string& testName);
/** Get a cmTest pointer for a given test name, if the name is
@@ -631,11 +746,22 @@ public:
cmTest* GetTest(const std::string& testName) const;
/**
+ * Get all tests that run under the given configuration.
+ */
+ void GetTests(const std::string& config, std::vector<cmTest*>& tests);
+
+ /**
* Return a location of a file in cmake or custom modules directory
*/
- std::string GetModulesFile(const char* name) const;
+ std::string GetModulesFile(const std::string& name) const
+ {
+ bool system;
+ return this->GetModulesFile(name, system);
+ }
+
+ std::string GetModulesFile(const std::string& name, bool& system) const;
- ///! Set/Get a property of this directory
+ //! Set/Get a property of this directory
void SetProperty(const std::string& prop, const char* value);
void AppendProperty(const std::string& prop, const char* value,
bool asString = false);
@@ -644,7 +770,7 @@ public:
bool GetPropertyAsBool(const std::string& prop) const;
std::vector<std::string> GetPropertyKeys() const;
- ///! Initialize a makefile from its parent
+ //! Initialize a makefile from its parent
void InitializeFromParent(cmMakefile* parent);
void AddInstallGenerator(cmInstallGenerator* g)
@@ -657,6 +783,10 @@ public:
{
return this->InstallGenerators;
}
+ const std::vector<cmInstallGenerator*>& GetInstallGenerators() const
+ {
+ return this->InstallGenerators;
+ }
void AddTestGenerator(cmTestGenerator* g)
{
@@ -676,7 +806,11 @@ public:
cmPolicies::PolicyMap const& pm);
~FunctionPushPop();
+ FunctionPushPop(const FunctionPushPop&) = delete;
+ FunctionPushPop& operator=(const FunctionPushPop&) = delete;
+
void Quiet() { this->ReportError = false; }
+
private:
cmMakefile* Makefile;
bool ReportError;
@@ -689,7 +823,11 @@ public:
cmPolicies::PolicyMap const& pm);
~MacroPushPop();
+ MacroPushPop(const MacroPushPop&) = delete;
+ MacroPushPop& operator=(const MacroPushPop&) = delete;
+
void Quiet() { this->ReportError = false; }
+
private:
cmMakefile* Makefile;
bool ReportError;
@@ -712,32 +850,40 @@ public:
/** Helper class to push and pop scopes automatically. */
class ScopePushPop
{
- CM_DISABLE_COPY(ScopePushPop)
public:
ScopePushPop(cmMakefile* m)
: Makefile(m)
{
this->Makefile->PushScope();
}
+
~ScopePushPop() { this->Makefile->PopScope(); }
+
+ ScopePushPop(ScopePushPop const&) = delete;
+ ScopePushPop& operator=(ScopePushPop const&) = delete;
+
private:
cmMakefile* Makefile;
};
- void IssueMessage(cmake::MessageType t, std::string const& text) const;
+ void IssueMessage(MessageType t, std::string const& text) const;
/** Set whether or not to report a CMP0000 violation. */
void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; }
+ bool CheckCMP0037(std::string const& targetName,
+ cmStateEnums::TargetType targetType) const;
+
cmStringRange GetIncludeDirectoriesEntries() const;
cmBacktraceRange GetIncludeDirectoriesBacktraces() const;
cmStringRange GetCompileOptionsEntries() const;
cmBacktraceRange GetCompileOptionsBacktraces() const;
cmStringRange GetCompileDefinitionsEntries() const;
cmBacktraceRange GetCompileDefinitionsBacktraces() const;
-
- void AddQtUiFileWithOptions(cmSourceFile* sf);
- std::vector<cmSourceFile*> GetQtUiFilesWithOptions() const;
+ cmStringRange GetLinkOptionsEntries() const;
+ cmBacktraceRange GetLinkOptionsBacktraces() const;
+ cmStringRange GetLinkDirectoriesEntries() const;
+ cmBacktraceRange GetLinkDirectoriesBacktraces() const;
std::set<std::string> const& GetSystemIncludeDirectories() const
{
@@ -747,7 +893,7 @@ public:
bool PolicyOptionalWarningEnabled(std::string const& var);
bool AddRequiredTargetFeature(cmTarget* target, const std::string& feature,
- std::string* error = CM_NULLPTR) const;
+ std::string* error = nullptr) const;
bool CompileFeatureKnown(cmTarget const* target, const std::string& feature,
std::string& lang, std::string* error) const;
@@ -776,10 +922,11 @@ public:
void EnforceDirectoryLevelRules() const;
- void AddEvaluationFile(const std::string& inputFile,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> outputName,
- CM_AUTO_PTR<cmCompiledGeneratorExpression> condition,
- bool inputIsContent);
+ void AddEvaluationFile(
+ const std::string& inputFile,
+ std::unique_ptr<cmCompiledGeneratorExpression> outputName,
+ std::unique_ptr<cmCompiledGeneratorExpression> condition,
+ bool inputIsContent);
std::vector<cmGeneratorExpressionEvaluationFile*> GetEvaluationFiles() const;
std::vector<cmExportBuildFileGenerator*> GetExportBuildFileGenerators()
@@ -787,9 +934,17 @@ public:
void RemoveExportBuildFileGeneratorCMP0024(cmExportBuildFileGenerator* gen);
void AddExportBuildFileGenerator(cmExportBuildFileGenerator* gen);
- // Maintain a stack of pacakge names to determine the depth of find modules
- // we are currently being called with
- std::deque<std::string> FindPackageModuleStack;
+ // Maintain a stack of package roots to allow nested PACKAGE_ROOT_PATH
+ // searches
+ std::deque<std::vector<std::string>> FindPackageRootPathStack;
+
+ void MaybeWarnCMP0074(std::string const& pkg);
+ void MaybeWarnUninitialized(std::string const& variable,
+ const char* sourceFilename) const;
+ bool IsProjectFile(const char* filename) const;
+
+ int GetRecursionDepth() const;
+ void SetRecursionDepth(int recursionDepth);
protected:
// add link libraries and directories to the target
@@ -801,9 +956,26 @@ protected:
mutable std::set<cmListFileContext> CMP0054ReportedIds;
// libraries, classes, and executables
- mutable cmTargets Targets;
+ mutable cmTargetMap Targets;
std::map<std::string, std::string> AliasTargets;
- std::vector<cmSourceFile*> SourceFiles;
+
+ using TargetsVec = std::vector<cmTarget*>;
+ TargetsVec OrderedTargets;
+
+ using SourceFileVec = std::vector<cmSourceFile*>;
+ SourceFileVec SourceFiles;
+
+ // Because cmSourceFile names are compared in a fuzzy way (see
+ // cmSourceFileLocation::Match()) we can't have a straight mapping from
+ // filename to cmSourceFile. To make lookups more efficient we store the
+ // Name portion of the cmSourceFileLocation and then compare on the list of
+ // cmSourceFiles that might match that name. Note that on platforms which
+ // have a case-insensitive filesystem we store the key in all lowercase.
+ using SourceFileMap = std::unordered_map<std::string, SourceFileVec>;
+ SourceFileMap SourceFileSearchIndex;
+
+ // For "Known" paths we can store a direct filename to cmSourceFile map
+ std::unordered_map<std::string, cmSourceFile*> KnownFileSearchIndex;
// Tests
std::map<std::string, cmTest*> Tests;
@@ -822,16 +994,14 @@ protected:
std::string DefineFlags;
// Track the value of the computed DEFINITIONS property.
- void AddDefineFlag(const char*, std::string&);
- void RemoveDefineFlag(const char*, std::string::size_type, std::string&);
std::string DefineFlagsOrig;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
std::vector<cmSourceGroup> SourceGroups;
size_t ObjectLibrariesSourceGroupIndex;
#endif
- std::vector<cmCommand*> FinalPassCommands;
+ std::vector<FinalAction> FinalActions;
cmGlobalGenerator* GlobalGenerator;
bool IsFunctionBlocked(const cmListFileFunction& lff,
cmExecutionStatus& status);
@@ -839,6 +1009,7 @@ protected:
private:
cmStateSnapshot StateSnapshot;
cmListFileBacktrace Backtrace;
+ int RecursionDepth;
void ReadListFile(cmListFile const& listFile,
const std::string& filenametoread);
@@ -848,7 +1019,10 @@ private:
bool EnforceUniqueDir(const std::string& srcPath,
const std::string& binPath) const;
- typedef std::vector<cmFunctionBlocker*> FunctionBlockersType;
+ std::function<void()> ExecuteCommandCallback;
+ using FunctionBlockerPtr = std::unique_ptr<cmFunctionBlocker>;
+ using FunctionBlockersType =
+ std::stack<FunctionBlockerPtr, std::vector<FunctionBlockerPtr>>;
FunctionBlockersType FunctionBlockers;
std::vector<FunctionBlockersType::size_type> FunctionBlockerBarriers;
void PushFunctionBlockerBarrier();
@@ -871,7 +1045,7 @@ private:
friend class cmParseFileScope;
std::vector<cmTarget*> ImportedTargetsOwned;
- typedef CM_UNORDERED_MAP<std::string, cmTarget*> TargetMap;
+ using TargetMap = std::unordered_map<std::string, cmTarget*>;
TargetMap ImportedTargets;
// Internal policy stack management.
@@ -879,63 +1053,122 @@ private:
cmPolicies::PolicyMap const& pm = cmPolicies::PolicyMap());
void PopPolicy();
void PopSnapshot(bool reportError = true);
- friend class cmCMakePolicyCommand;
+ friend bool cmCMakePolicyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
class IncludeScope;
-
friend class IncludeScope;
- class ListFileScope;
+ class ListFileScope;
friend class ListFileScope;
- class BuildsystemFileScope;
+ class BuildsystemFileScope;
friend class BuildsystemFileScope;
// CMP0053 == old
- cmake::MessageType ExpandVariablesInStringOld(
- std::string& errorstr, std::string& source, bool escapeQuotes,
- bool noEscapes, bool atOnly, const char* filename, long line,
- bool removeEmpty, bool replaceAt) const;
+ MessageType ExpandVariablesInStringOld(std::string& errorstr,
+ std::string& source,
+ bool escapeQuotes, bool noEscapes,
+ bool atOnly, const char* filename,
+ long line, bool removeEmpty,
+ bool replaceAt) const;
// CMP0053 == new
- cmake::MessageType ExpandVariablesInStringNew(
- std::string& errorstr, std::string& source, bool escapeQuotes,
- bool noEscapes, bool atOnly, const char* filename, long line,
- bool removeEmpty, bool replaceAt) const;
+ MessageType ExpandVariablesInStringNew(std::string& errorstr,
+ std::string& source,
+ bool escapeQuotes, bool noEscapes,
+ bool atOnly, const char* filename,
+ long line, bool replaceAt) const;
+
+ bool ValidateCustomCommand(const cmCustomCommandLines& commandLines) const;
+
+ void CreateGeneratedSources(const std::vector<std::string>& outputs);
+
+ void CommitCustomCommandToTarget(
+ cmTarget* target, const std::vector<std::string>& byproducts,
+ const std::vector<std::string>& depends,
+ const cmCustomCommandLines& commandLines, cmCustomCommandType type,
+ const char* comment, const char* workingDir, bool escapeOldStyle,
+ bool uses_terminal, const std::string& depfile,
+ const std::string& job_pool, bool command_expand_lists);
+ cmSourceFile* CommitCustomCommandToOutput(
+ const std::vector<std::string>& outputs,
+ const std::vector<std::string>& byproducts,
+ const std::vector<std::string>& depends,
+ const std::string& main_dependency,
+ const cmImplicitDependsList& implicit_depends,
+ const cmCustomCommandLines& commandLines, const char* comment,
+ const char* workingDir, bool replace, bool escapeOldStyle,
+ bool uses_terminal, bool command_expand_lists, const std::string& depfile,
+ const std::string& job_pool);
+ void CommitAppendCustomCommandToOutput(
+ const std::string& output, const std::vector<std::string>& depends,
+ const cmImplicitDependsList& implicit_depends,
+ const cmCustomCommandLines& commandLines);
+
+ void CommitUtilityCommand(cmTarget* target, const cmUtilityOutput& force,
+ const char* workingDirectory,
+ const std::vector<std::string>& byproducts,
+ const std::vector<std::string>& depends,
+ const cmCustomCommandLines& commandLines,
+ bool escapeOldStyle, const char* comment,
+ bool uses_terminal, bool command_expand_lists,
+ const std::string& job_pool);
+
+ /**
+ * See LinearGetSourceFileWithOutput for background information
+ */
+ cmTarget* LinearGetTargetWithOutput(const std::string& name) const;
+
/**
- * Old version of GetSourceFileWithOutput(const std::string&) kept for
- * backward-compatibility. It implements a linear search and support
- * relative file paths. It is used as a fall back by
- * GetSourceFileWithOutput(const std::string&).
+ * Generalized old version of GetSourceFileWithOutput kept for
+ * backward-compatibility. It implements a linear search and supports
+ * relative file paths. It is used as a fall back by GetSourceFileWithOutput
+ * and GetSourcesWithOutput.
*/
- cmSourceFile* LinearGetSourceFileWithOutput(const std::string& cname) const;
+ cmSourceFile* LinearGetSourceFileWithOutput(const std::string& name,
+ cmSourceOutputKind kind,
+ bool& byproduct) const;
+
+ struct SourceEntry
+ {
+ cmSourcesWithOutput Sources;
+ };
// A map for fast output to input look up.
- typedef CM_UNORDERED_MAP<std::string, cmSourceFile*> OutputToSourceMap;
+ using OutputToSourceMap = std::unordered_map<std::string, SourceEntry>;
OutputToSourceMap OutputToSource;
- void UpdateOutputToSourceMap(std::vector<std::string> const& outputs,
- cmSourceFile* source);
- void UpdateOutputToSourceMap(std::string const& output,
- cmSourceFile* source);
+ void UpdateOutputToSourceMap(std::string const& byproduct, cmTarget* target);
+ void UpdateOutputToSourceMap(std::string const& output, cmSourceFile* source,
+ bool byproduct);
- std::vector<cmSourceFile*> QtUiFilesWithOptions;
+ /**
+ * Return if the provided source file might have a custom command.
+ */
+ bool MightHaveCustomCommand(const std::string& name) const;
bool AddRequiredTargetCFeature(cmTarget* target, const std::string& feature,
- std::string* error = CM_NULLPTR) const;
+ std::string const& lang,
+ std::string* error = nullptr) const;
bool AddRequiredTargetCxxFeature(cmTarget* target,
const std::string& feature,
- std::string* error = CM_NULLPTR) const;
+ std::string const& lang,
+ std::string* error = nullptr) const;
- void CheckNeededCLanguage(const std::string& feature, bool& needC90,
+ void CheckNeededCLanguage(const std::string& feature,
+ std::string const& lang, bool& needC90,
bool& needC99, bool& needC11) const;
- void CheckNeededCxxLanguage(const std::string& feature, bool& needCxx98,
+ void CheckNeededCxxLanguage(const std::string& feature,
+ std::string const& lang, bool& needCxx98,
bool& needCxx11, bool& needCxx14,
- bool& needCxx17) const;
+ bool& needCxx17, bool& needCxx20) const;
bool HaveCStandardAvailable(cmTarget const* target,
- const std::string& feature) const;
+ const std::string& feature,
+ std::string const& lang) const;
bool HaveCxxStandardAvailable(cmTarget const* target,
- const std::string& feature) const;
+ const std::string& feature,
+ std::string const& lang) const;
void CheckForUnusedVariables() const;
@@ -943,8 +1176,9 @@ private:
bool WarnUnused;
bool CheckSystemVars;
bool CheckCMP0000;
+ std::set<std::string> WarnedCMP0074;
bool IsSourceFileTryCompile;
- mutable bool SuppressWatches;
+ mutable bool SuppressSideEffects;
};
#endif
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 359b9fdbb..40265ff65 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -2,11 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileExecutableTargetGenerator.h"
-#include <algorithm>
+#include <set>
#include <sstream>
#include <string>
+#include <utility>
#include <vector>
+#include <cm/memory>
+
+#include "cmAlgorithms.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalUnixMakefileGenerator3.h"
@@ -22,28 +26,24 @@
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
-#include "cmake.h"
cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator(
cmGeneratorTarget* target)
: cmMakefileTargetGenerator(target)
{
this->CustomCommandDriver = OnDepends;
- this->GeneratorTarget->GetExecutableNames(
- this->TargetNameOut, this->TargetNameReal, this->TargetNameImport,
- this->TargetNamePDB, this->ConfigName);
+ this->TargetNames =
+ this->GeneratorTarget->GetExecutableNames(this->ConfigName);
this->OSXBundleGenerator =
- new cmOSXBundleGenerator(target, this->ConfigName);
+ cm::make_unique<cmOSXBundleGenerator>(target, this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
}
-cmMakefileExecutableTargetGenerator::~cmMakefileExecutableTargetGenerator()
-{
- delete this->OSXBundleGenerator;
-}
+cmMakefileExecutableTargetGenerator::~cmMakefileExecutableTargetGenerator() =
+ default;
void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
{
@@ -69,9 +69,6 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
this->WriteExecutableRule(true);
}
- // Write the requires target.
- this->WriteTargetRequiresRules();
-
// Write clean target
this->WriteTargetCleanRules();
@@ -86,29 +83,24 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
bool relink)
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
- const std::string cuda_lang("CUDA");
- cmGeneratorTarget::LinkClosure const* closure =
- this->GeneratorTarget->GetLinkClosure(this->ConfigName);
-
- const bool hasCUDA =
- (std::find(closure->Languages.begin(), closure->Languages.end(),
- cuda_lang) != closure->Languages.end());
- if (!hasCUDA) {
+#ifndef CMAKE_BOOTSTRAP
+ const bool requiresDeviceLinking = requireDeviceLinking(
+ *this->GeneratorTarget, *this->LocalGenerator, this->ConfigName);
+ if (!requiresDeviceLinking) {
return;
}
std::vector<std::string> commands;
- // Build list of dependencies.
- std::vector<std::string> depends;
- this->AppendLinkDepends(depends);
-
// Get the language to use for linking this library.
std::string linkLanguage = "CUDA";
- std::string const objExt =
+ std::string const& objExt =
this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
+ // Build list of dependencies.
+ std::vector<std::string> depends;
+ this->AppendLinkDepends(depends, linkLanguage);
+
// Get the name of the device object to generate.
std::string const targetOutputReal =
this->GeneratorTarget->ObjectDirectory + "cmake_device_link" + objExt;
@@ -119,14 +111,13 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
cmLocalUnixMakefileGenerator3::EchoProgress progress;
this->MakeEchoProgress(progress);
// Add the link message.
- std::string buildEcho = "Linking ";
- buildEcho += linkLanguage;
- buildEcho += " device code ";
- buildEcho += this->LocalGenerator->ConvertToOutputFormat(
- this->LocalGenerator->MaybeConvertToRelativePath(
- this->LocalGenerator->GetCurrentBinaryDirectory(),
- this->DeviceLinkObject),
- cmOutputConverter::SHELL);
+ std::string buildEcho =
+ cmStrCat("Linking ", linkLanguage, " device code ",
+ this->LocalGenerator->ConvertToOutputFormat(
+ this->LocalGenerator->MaybeConvertToRelativePath(
+ this->LocalGenerator->GetCurrentBinaryDirectory(),
+ this->DeviceLinkObject),
+ cmOutputConverter::SHELL));
this->LocalGenerator->AppendEcho(
commands, buildEcho, cmLocalUnixMakefileGenerator3::EchoLink, &progress);
}
@@ -138,11 +129,10 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
// Add flags to create an executable.
// Add symbol export flags if necessary.
if (this->GeneratorTarget->IsExecutableWithExports()) {
- std::string export_flag_var = "CMAKE_EXE_EXPORTS_";
- export_flag_var += linkLanguage;
- export_flag_var += "_FLAG";
+ std::string export_flag_var =
+ cmStrCat("CMAKE_EXE_EXPORTS_", linkLanguage, "_FLAG");
this->LocalGenerator->AppendFlags(
- linkFlags, this->Makefile->GetDefinition(export_flag_var));
+ linkFlags, this->Makefile->GetSafeDefinition(export_flag_var));
}
this->LocalGenerator->AppendFlags(linkFlags,
@@ -157,12 +147,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
linkLanguage, this->ConfigName);
// Add target-specific linker flags.
- this->LocalGenerator->AppendFlags(
- linkFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
- std::string linkFlagsConfig = "LINK_FLAGS_";
- linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
- this->LocalGenerator->AppendFlags(
- linkFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
+ this->GetTargetLinkFlags(linkFlags, linkLanguage);
// Construct a list of files associated with this executable that
// may need to be cleaned.
@@ -178,7 +163,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
const std::string linkRuleVar = "CMAKE_CUDA_DEVICE_LINK_EXECUTABLE";
const std::string linkRule = this->GetLinkRule(linkRuleVar);
std::vector<std::string> commands1;
- cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
+ cmExpandList(linkRule, real_link_commands);
bool useResponseFileForObjects =
this->CheckUseResponseFileForObjects(linkLanguage);
@@ -193,7 +178,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
// Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
new cmLinkLineDeviceComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@@ -247,20 +232,18 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
const char* val = this->LocalGenerator->GetRuleLauncher(
this->GeneratorTarget, "RULE_LAUNCH_LINK");
if (val && *val) {
- launcher = val;
- launcher += " ";
+ launcher = cmStrCat(val, ' ');
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander());
// Expand placeholders in the commands.
rulePlaceholderExpander->SetTargetImpLib(targetOutputReal);
- for (std::vector<std::string>::iterator i = real_link_commands.begin();
- i != real_link_commands.end(); ++i) {
- *i = launcher + *i;
- rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, *i,
- vars);
+ for (std::string& real_link_command : real_link_commands) {
+ real_link_command = cmStrCat(launcher, real_link_command);
+ rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
+ real_link_command, vars);
}
// Restore path conversion to normal shells.
@@ -280,11 +263,11 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
this->LocalGenerator->CreateCDCommand(
commands1, this->Makefile->GetCurrentBinaryDirectory(),
this->LocalGenerator->GetBinaryDirectory());
- commands.insert(commands.end(), commands1.begin(), commands1.end());
+ cmAppend(commands, commands1);
commands1.clear();
// Write the build rule.
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
targetOutputReal, depends, commands,
false);
@@ -292,8 +275,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
this->WriteTargetDriverRule(targetOutputReal, relink);
// Clean all the possible executable names and symlinks.
- this->CleanFiles.insert(this->CleanFiles.end(), exeCleanFiles.begin(),
- exeCleanFiles.end());
+ this->CleanFiles.insert(exeCleanFiles.begin(), exeCleanFiles.end());
#else
static_cast<void>(relink);
#endif
@@ -303,61 +285,48 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
{
std::vector<std::string> commands;
- // Build list of dependencies.
- std::vector<std::string> depends;
- this->AppendLinkDepends(depends);
- if (!this->DeviceLinkObject.empty()) {
- depends.push_back(this->DeviceLinkObject);
- }
-
// Get the name of the executable to generate.
- std::string targetName;
- std::string targetNameReal;
- std::string targetNameImport;
- std::string targetNamePDB;
- this->GeneratorTarget->GetExecutableNames(targetName, targetNameReal,
- targetNameImport, targetNamePDB,
- this->ConfigName);
+ cmGeneratorTarget::Names targetNames =
+ this->GeneratorTarget->GetExecutableNames(this->ConfigName);
// Construct the full path version of the names.
std::string outpath = this->GeneratorTarget->GetDirectory(this->ConfigName);
if (this->GeneratorTarget->IsAppBundleOnApple()) {
- this->OSXBundleGenerator->CreateAppBundle(targetName, outpath);
+ this->OSXBundleGenerator->CreateAppBundle(targetNames.Output, outpath);
}
- outpath += "/";
+ outpath += '/';
std::string outpathImp;
if (relink) {
- outpath = this->Makefile->GetCurrentBinaryDirectory();
- outpath += cmake::GetCMakeFilesDirectory();
- outpath += "/CMakeRelink.dir";
- cmSystemTools::MakeDirectory(outpath.c_str());
- outpath += "/";
- if (!targetNameImport.empty()) {
+ outpath = cmStrCat(this->Makefile->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/CMakeRelink.dir");
+ cmSystemTools::MakeDirectory(outpath);
+ outpath += '/';
+ if (!targetNames.ImportLibrary.empty()) {
outpathImp = outpath;
}
} else {
- cmSystemTools::MakeDirectory(outpath.c_str());
- if (!targetNameImport.empty()) {
+ cmSystemTools::MakeDirectory(outpath);
+ if (!targetNames.ImportLibrary.empty()) {
outpathImp = this->GeneratorTarget->GetDirectory(
this->ConfigName, cmStateEnums::ImportLibraryArtifact);
- cmSystemTools::MakeDirectory(outpathImp.c_str());
- outpathImp += "/";
+ cmSystemTools::MakeDirectory(outpathImp);
+ outpathImp += '/';
}
}
std::string compilePdbOutputPath =
this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName);
- cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str());
+ cmSystemTools::MakeDirectory(compilePdbOutputPath);
std::string pdbOutputPath =
this->GeneratorTarget->GetPDBDirectory(this->ConfigName);
- cmSystemTools::MakeDirectory(pdbOutputPath.c_str());
- pdbOutputPath += "/";
+ cmSystemTools::MakeDirectory(pdbOutputPath);
+ pdbOutputPath += '/';
- std::string targetFullPath = outpath + targetName;
- std::string targetFullPathReal = outpath + targetNameReal;
- std::string targetFullPathPDB = pdbOutputPath + targetNamePDB;
- std::string targetFullPathImport = outpathImp + targetNameImport;
+ std::string targetFullPath = outpath + targetNames.Output;
+ std::string targetFullPathReal = outpath + targetNames.Real;
+ std::string targetFullPathPDB = pdbOutputPath + targetNames.PDB;
+ std::string targetFullPathImport = outpathImp + targetNames.ImportLibrary;
std::string targetOutPathPDB = this->LocalGenerator->ConvertToOutputFormat(
targetFullPathPDB, cmOutputConverter::SHELL);
// Convert to the output path to use in constructing commands.
@@ -382,20 +351,25 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Make sure we have a link language.
if (linkLanguage.empty()) {
- cmSystemTools::Error("Cannot determine link language for target \"",
- this->GeneratorTarget->GetName().c_str(), "\".");
+ cmSystemTools::Error("Cannot determine link language for target \"" +
+ this->GeneratorTarget->GetName() + "\".");
return;
}
+ // Build list of dependencies.
+ std::vector<std::string> depends;
+ this->AppendLinkDepends(depends, linkLanguage);
+ if (!this->DeviceLinkObject.empty()) {
+ depends.push_back(this->DeviceLinkObject);
+ }
+
this->NumberOfProgressActions++;
if (!this->NoRuleMessages) {
cmLocalUnixMakefileGenerator3::EchoProgress progress;
this->MakeEchoProgress(progress);
// Add the link message.
- std::string buildEcho = "Linking ";
- buildEcho += linkLanguage;
- buildEcho += " executable ";
- buildEcho += targetOutPath;
+ std::string buildEcho =
+ cmStrCat("Linking ", linkLanguage, " executable ", targetOutPath);
this->LocalGenerator->AppendEcho(
commands, buildEcho, cmLocalUnixMakefileGenerator3::EchoLink, &progress);
}
@@ -410,19 +384,19 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
if (this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) {
this->LocalGenerator->AppendFlags(
- linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_WIN32_EXE"));
+ linkFlags, this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE"));
} else {
this->LocalGenerator->AppendFlags(
- linkFlags, this->Makefile->GetDefinition("CMAKE_CREATE_CONSOLE_EXE"));
+ linkFlags,
+ this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"));
}
// Add symbol export flags if necessary.
if (this->GeneratorTarget->IsExecutableWithExports()) {
- std::string export_flag_var = "CMAKE_EXE_EXPORTS_";
- export_flag_var += linkLanguage;
- export_flag_var += "_FLAG";
+ std::string export_flag_var =
+ cmStrCat("CMAKE_EXE_EXPORTS_", linkLanguage, "_FLAG");
this->LocalGenerator->AppendFlags(
- linkFlags, this->Makefile->GetDefinition(export_flag_var));
+ linkFlags, this->Makefile->GetSafeDefinition(export_flag_var));
}
this->LocalGenerator->AppendFlags(linkFlags,
@@ -441,15 +415,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
linkLanguage, this->ConfigName);
// Add target-specific linker flags.
- this->LocalGenerator->AppendFlags(
- linkFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
- std::string linkFlagsConfig = "LINK_FLAGS_";
- linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
- this->LocalGenerator->AppendFlags(
- linkFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
+ this->GetTargetLinkFlags(linkFlags, linkLanguage);
{
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@@ -470,19 +439,19 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// clean set just in case.
exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(),
- (targetFullPath + ".manifest").c_str()));
+ targetFullPath + ".manifest"));
#endif
- if (targetNameReal != targetName) {
+ if (this->TargetNames.Real != this->TargetNames.Output) {
exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal));
}
- if (!targetNameImport.empty()) {
+ if (!this->TargetNames.ImportLibrary.empty()) {
exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(),
targetFullPathImport));
std::string implib;
- if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport,
- implib)) {
+ if (this->GeneratorTarget->GetImplibGNUtoMS(
+ this->ConfigName, targetFullPathImport, implib)) {
exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), implib));
}
@@ -491,7 +460,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// List the PDB for cleaning only when the whole target is
// cleaned. We do not want to delete the .pdb file just before
// linking the target.
- this->CleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
+ this->CleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathPDB));
// Add the pre-build and pre-link rules building but not when relinking.
@@ -509,20 +478,18 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Construct the main link rule.
std::vector<std::string> real_link_commands;
- std::string linkRuleVar = "CMAKE_";
- linkRuleVar += linkLanguage;
- linkRuleVar += "_LINK_EXECUTABLE";
+ std::string linkRuleVar = this->GeneratorTarget->GetCreateRuleVariable(
+ linkLanguage, this->ConfigName);
std::string linkRule = this->GetLinkRule(linkRuleVar);
std::vector<std::string> commands1;
- cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
+ cmExpandList(linkRule, real_link_commands);
if (this->GeneratorTarget->IsExecutableWithExports()) {
// If a separate rule for creating an import library is specified
// add it now.
- std::string implibRuleVar = "CMAKE_";
- implibRuleVar += linkLanguage;
- implibRuleVar += "_CREATE_IMPORT_LIBRARY";
+ std::string implibRuleVar =
+ cmStrCat("CMAKE_", linkLanguage, "_CREATE_IMPORT_LIBRARY");
if (const char* rule = this->Makefile->GetDefinition(implibRuleVar)) {
- cmSystemTools::ExpandListArgument(rule, real_link_commands);
+ cmExpandList(rule, real_link_commands);
}
}
@@ -539,7 +506,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@@ -617,11 +584,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
vars.Manifests = manifests.c_str();
if (this->GeneratorTarget->GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
- std::string cmakeCommand = this->LocalGenerator->ConvertToOutputFormat(
- cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
- cmakeCommand += " -E __run_iwyu --lwyu=";
- cmakeCommand += targetOutPathReal;
- real_link_commands.push_back(cmakeCommand);
+ std::string cmakeCommand =
+ cmStrCat(this->LocalGenerator->ConvertToOutputFormat(
+ cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL),
+ " -E __run_co_compile --lwyu=", targetOutPathReal);
+ real_link_commands.push_back(std::move(cmakeCommand));
}
std::string launcher;
@@ -629,20 +596,18 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
const char* val = this->LocalGenerator->GetRuleLauncher(
this->GeneratorTarget, "RULE_LAUNCH_LINK");
if (val && *val) {
- launcher = val;
- launcher += " ";
+ launcher = cmStrCat(val, ' ');
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander());
// Expand placeholders in the commands.
rulePlaceholderExpander->SetTargetImpLib(targetOutPathImport);
- for (std::vector<std::string>::iterator i = real_link_commands.begin();
- i != real_link_commands.end(); ++i) {
- *i = launcher + *i;
- rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, *i,
- vars);
+ for (std::string& real_link_command : real_link_commands) {
+ real_link_command = cmStrCat(launcher, real_link_command);
+ rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
+ real_link_command, vars);
}
// Restore path conversion to normal shells.
@@ -662,20 +627,19 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
this->LocalGenerator->CreateCDCommand(
commands1, this->Makefile->GetCurrentBinaryDirectory(),
this->LocalGenerator->GetBinaryDirectory());
- commands.insert(commands.end(), commands1.begin(), commands1.end());
+ cmAppend(commands, commands1);
commands1.clear();
// Add a rule to create necessary symlinks for the library.
if (targetOutPath != targetOutPathReal) {
- std::string symlink = "$(CMAKE_COMMAND) -E cmake_symlink_executable ";
- symlink += targetOutPathReal;
- symlink += " ";
- symlink += targetOutPath;
- commands1.push_back(symlink);
+ std::string symlink =
+ cmStrCat("$(CMAKE_COMMAND) -E cmake_symlink_executable ",
+ targetOutPathReal, ' ', targetOutPath);
+ commands1.push_back(std::move(symlink));
this->LocalGenerator->CreateCDCommand(
commands1, this->Makefile->GetCurrentBinaryDirectory(),
this->LocalGenerator->GetBinaryDirectory());
- commands.insert(commands.end(), commands1.begin(), commands1.end());
+ cmAppend(commands, commands1);
commands1.clear();
}
@@ -687,7 +651,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
}
// Write the build rule.
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
targetFullPathReal, depends, commands,
false);
@@ -698,7 +662,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
depends.clear();
commands.clear();
depends.push_back(targetFullPathReal);
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
targetFullPath, depends, commands,
false);
}
@@ -707,6 +671,5 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
this->WriteTargetDriverRule(targetFullPath, relink);
// Clean all the possible executable names and symlinks.
- this->CleanFiles.insert(this->CleanFiles.end(), exeCleanFiles.begin(),
- exeCleanFiles.end());
+ this->CleanFiles.insert(exeCleanFiles.begin(), exeCleanFiles.end());
}
diff --git a/Source/cmMakefileExecutableTargetGenerator.h b/Source/cmMakefileExecutableTargetGenerator.h
index 01aa6270c..b9bbe8667 100644
--- a/Source/cmMakefileExecutableTargetGenerator.h
+++ b/Source/cmMakefileExecutableTargetGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmMakefileExecutableTargetGenerator_h
#define cmMakefileExecutableTargetGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
@@ -15,11 +15,11 @@ class cmMakefileExecutableTargetGenerator : public cmMakefileTargetGenerator
{
public:
cmMakefileExecutableTargetGenerator(cmGeneratorTarget* target);
- ~cmMakefileExecutableTargetGenerator() CM_OVERRIDE;
+ ~cmMakefileExecutableTargetGenerator() override;
/* the main entry point for this class. Writes the Makefiles associated
with this target */
- void WriteRuleFiles() CM_OVERRIDE;
+ void WriteRuleFiles() override;
protected:
virtual void WriteExecutableRule(bool relink);
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 3d1594bdb..54a66065c 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -2,10 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileLibraryTargetGenerator.h"
-#include <algorithm>
+#include <cstddef>
+#include <set>
#include <sstream>
+#include <utility>
#include <vector>
+#include <cm/memory>
+
+#include "cmAlgorithms.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalUnixMakefileGenerator3.h"
@@ -21,9 +26,8 @@
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
-#include "cmake.h"
cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator(
cmGeneratorTarget* target)
@@ -31,20 +35,17 @@ cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator(
{
this->CustomCommandDriver = OnDepends;
if (this->GeneratorTarget->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
- this->GeneratorTarget->GetLibraryNames(
- this->TargetNameOut, this->TargetNameSO, this->TargetNameReal,
- this->TargetNameImport, this->TargetNamePDB, this->ConfigName);
+ this->TargetNames =
+ this->GeneratorTarget->GetLibraryNames(this->ConfigName);
}
this->OSXBundleGenerator =
- new cmOSXBundleGenerator(target, this->ConfigName);
+ cm::make_unique<cmOSXBundleGenerator>(target, this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
}
-cmMakefileLibraryTargetGenerator::~cmMakefileLibraryTargetGenerator()
-{
- delete this->OSXBundleGenerator;
-}
+cmMakefileLibraryTargetGenerator::~cmMakefileLibraryTargetGenerator() =
+ default;
void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
{
@@ -89,9 +90,6 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
break;
}
- // Write the requires target.
- this->WriteTargetRequiresRules();
-
// Write clean target
this->WriteTargetCleanRules();
@@ -117,7 +115,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
this->AppendObjectDepends(depends);
// Write the rule.
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
this->GeneratorTarget->GetName(),
depends, commands, true);
@@ -127,22 +125,11 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
{
- const std::string cuda_lang("CUDA");
- cmGeneratorTarget::LinkClosure const* closure =
- this->GeneratorTarget->GetLinkClosure(this->ConfigName);
-
- const bool hasCUDA =
- (std::find(closure->Languages.begin(), closure->Languages.end(),
- cuda_lang) != closure->Languages.end());
-
- const bool resolveDeviceSymbols =
- this->GeneratorTarget->GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS");
- if (hasCUDA && resolveDeviceSymbols) {
+ const bool requiresDeviceLinking = requireDeviceLinking(
+ *this->GeneratorTarget, *this->LocalGenerator, this->ConfigName);
+ if (requiresDeviceLinking) {
std::string linkRuleVar = "CMAKE_CUDA_DEVICE_LINK_LIBRARY";
- std::string extraFlags;
- this->LocalGenerator->AppendFlags(
- extraFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
- this->WriteDeviceLibraryRules(linkRuleVar, extraFlags, false);
+ this->WriteDeviceLibraryRules(linkRuleVar, false);
}
std::string linkLanguage =
@@ -153,7 +140,7 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
std::string extraFlags;
this->LocalGenerator->GetStaticLibraryFlags(
- extraFlags, cmSystemTools::UpperCase(this->ConfigName),
+ extraFlags, cmSystemTools::UpperCase(this->ConfigName), linkLanguage,
this->GeneratorTarget);
this->WriteLibraryRules(linkRuleVar, extraFlags, false);
}
@@ -166,40 +153,25 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
}
if (!relink) {
- const std::string cuda_lang("CUDA");
- cmGeneratorTarget::LinkClosure const* closure =
- this->GeneratorTarget->GetLinkClosure(this->ConfigName);
-
- const bool hasCUDA =
- (std::find(closure->Languages.begin(), closure->Languages.end(),
- cuda_lang) != closure->Languages.end());
- if (hasCUDA) {
+ const bool requiresDeviceLinking = requireDeviceLinking(
+ *this->GeneratorTarget, *this->LocalGenerator, this->ConfigName);
+ if (requiresDeviceLinking) {
std::string linkRuleVar = "CMAKE_CUDA_DEVICE_LINK_LIBRARY";
- std::string extraFlags;
- this->LocalGenerator->AppendFlags(
- extraFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
- this->WriteDeviceLibraryRules(linkRuleVar, extraFlags, relink);
+ this->WriteDeviceLibraryRules(linkRuleVar, relink);
}
}
std::string linkLanguage =
this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
- std::string linkRuleVar = "CMAKE_";
- linkRuleVar += linkLanguage;
- linkRuleVar += "_CREATE_SHARED_LIBRARY";
+ std::string linkRuleVar =
+ cmStrCat("CMAKE_", linkLanguage, "_CREATE_SHARED_LIBRARY");
std::string extraFlags;
- this->LocalGenerator->AppendFlags(
- extraFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
- std::string linkFlagsConfig = "LINK_FLAGS_";
- linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
- this->LocalGenerator->AppendFlags(
- extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
-
+ this->GetTargetLinkFlags(extraFlags, linkLanguage);
this->LocalGenerator->AddConfigVariableFlags(
extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName);
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@@ -214,41 +186,26 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
{
-
if (!relink) {
- const std::string cuda_lang("CUDA");
- cmGeneratorTarget::LinkClosure const* closure =
- this->GeneratorTarget->GetLinkClosure(this->ConfigName);
-
- const bool hasCUDA =
- (std::find(closure->Languages.begin(), closure->Languages.end(),
- cuda_lang) != closure->Languages.end());
- if (hasCUDA) {
+ const bool requiresDeviceLinking = requireDeviceLinking(
+ *this->GeneratorTarget, *this->LocalGenerator, this->ConfigName);
+ if (requiresDeviceLinking) {
std::string linkRuleVar = "CMAKE_CUDA_DEVICE_LINK_LIBRARY";
- std::string extraFlags;
- this->LocalGenerator->AppendFlags(
- extraFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
- this->WriteDeviceLibraryRules(linkRuleVar, extraFlags, relink);
+ this->WriteDeviceLibraryRules(linkRuleVar, relink);
}
}
std::string linkLanguage =
this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
- std::string linkRuleVar = "CMAKE_";
- linkRuleVar += linkLanguage;
- linkRuleVar += "_CREATE_SHARED_MODULE";
+ std::string linkRuleVar =
+ cmStrCat("CMAKE_", linkLanguage, "_CREATE_SHARED_MODULE");
std::string extraFlags;
- this->LocalGenerator->AppendFlags(
- extraFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
- std::string linkFlagsConfig = "LINK_FLAGS_";
- linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
- this->LocalGenerator->AppendFlags(
- extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
+ this->GetTargetLinkFlags(extraFlags, linkLanguage);
this->LocalGenerator->AddConfigVariableFlags(
extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName);
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@@ -262,17 +219,11 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
{
std::string linkLanguage =
this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
- std::string linkRuleVar = "CMAKE_";
- linkRuleVar += linkLanguage;
- linkRuleVar += "_CREATE_MACOSX_FRAMEWORK";
+ std::string linkRuleVar =
+ cmStrCat("CMAKE_", linkLanguage, "_CREATE_MACOSX_FRAMEWORK");
std::string extraFlags;
- this->LocalGenerator->AppendFlags(
- extraFlags, this->GeneratorTarget->GetProperty("LINK_FLAGS"));
- std::string linkFlagsConfig = "LINK_FLAGS_";
- linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
- this->LocalGenerator->AppendFlags(
- extraFlags, this->GeneratorTarget->GetProperty(linkFlagsConfig));
+ this->GetTargetLinkFlags(extraFlags, linkLanguage);
this->LocalGenerator->AddConfigVariableFlags(
extraFlags, "CMAKE_MACOSX_FRAMEWORK_LINKER_FLAGS", this->ConfigName);
@@ -280,25 +231,25 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
}
void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
- const std::string& linkRuleVar, const std::string& extraFlags, bool relink)
+ const std::string& linkRuleVar, bool relink)
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
// TODO: Merge the methods that call this method to avoid
// code duplication.
std::vector<std::string> commands;
- // Build list of dependencies.
- std::vector<std::string> depends;
- this->AppendLinkDepends(depends);
-
// Get the language to use for linking this library.
std::string linkLanguage = "CUDA";
std::string const objExt =
this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
+ // Build list of dependencies.
+ std::vector<std::string> depends;
+ this->AppendLinkDepends(depends, linkLanguage);
+
// Create set of linking flags.
std::string linkFlags;
- this->LocalGenerator->AppendFlags(linkFlags, extraFlags);
+ this->GetTargetLinkFlags(linkFlags, linkLanguage);
// Get the name of the device object to generate.
std::string const targetOutputReal =
@@ -310,18 +261,19 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
cmLocalUnixMakefileGenerator3::EchoProgress progress;
this->MakeEchoProgress(progress);
// Add the link message.
- std::string buildEcho = "Linking " + linkLanguage + " device code ";
- buildEcho += this->LocalGenerator->ConvertToOutputFormat(
- this->LocalGenerator->MaybeConvertToRelativePath(
- this->LocalGenerator->GetCurrentBinaryDirectory(),
- this->DeviceLinkObject),
- cmOutputConverter::SHELL);
+ std::string buildEcho =
+ cmStrCat("Linking ", linkLanguage, " device code ",
+ this->LocalGenerator->ConvertToOutputFormat(
+ this->LocalGenerator->MaybeConvertToRelativePath(
+ this->LocalGenerator->GetCurrentBinaryDirectory(),
+ this->DeviceLinkObject),
+ cmOutputConverter::SHELL));
this->LocalGenerator->AppendEcho(
commands, buildEcho, cmLocalUnixMakefileGenerator3::EchoLink, &progress);
}
// Clean files associated with this library.
- std::vector<std::string> libCleanFiles;
- libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
+ std::set<std::string> libCleanFiles;
+ libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetOutputReal));
// Determine whether a link script will be used.
@@ -346,19 +298,16 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
// Collect up flags to link in needed libraries.
std::string linkLibs;
- if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) {
-
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
- new cmLinkLineDeviceComputer(
- this->LocalGenerator,
- this->LocalGenerator->GetStateSnapshot().GetDirectory()));
- linkLineComputer->SetForResponse(useResponseFileForLibs);
- linkLineComputer->SetUseWatcomQuote(useWatcomQuote);
- linkLineComputer->SetRelink(relink);
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
+ new cmLinkLineDeviceComputer(
+ this->LocalGenerator,
+ this->LocalGenerator->GetStateSnapshot().GetDirectory()));
+ linkLineComputer->SetForResponse(useResponseFileForLibs);
+ linkLineComputer->SetUseWatcomQuote(useWatcomQuote);
+ linkLineComputer->SetRelink(relink);
- this->CreateLinkLibs(linkLineComputer.get(), linkLibs,
- useResponseFileForLibs, depends);
- }
+ this->CreateLinkLibs(linkLineComputer.get(), linkLibs,
+ useResponseFileForLibs, depends);
// Construct object file lists that may be needed to expand the
// rule.
@@ -406,31 +355,28 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
const char* val = this->LocalGenerator->GetRuleLauncher(
this->GeneratorTarget, "RULE_LAUNCH_LINK");
if (val && *val) {
- launcher = val;
- launcher += " ";
+ launcher = cmStrCat(val, ' ');
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander());
// Construct the main link rule and expand placeholders.
rulePlaceholderExpander->SetTargetImpLib(targetOutputReal);
std::string linkRule = this->GetLinkRule(linkRuleVar);
- cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
+ cmExpandList(linkRule, real_link_commands);
// Expand placeholders.
- for (std::vector<std::string>::iterator i = real_link_commands.begin();
- i != real_link_commands.end(); ++i) {
- *i = launcher + *i;
- rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, *i,
- vars);
+ for (std::string& real_link_command : real_link_commands) {
+ real_link_command = cmStrCat(launcher, real_link_command);
+ rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
+ real_link_command, vars);
}
// Restore path conversion to normal shells.
this->LocalGenerator->SetLinkScriptShell(false);
// Clean all the possible library names and symlinks.
- this->CleanFiles.insert(this->CleanFiles.end(), libCleanFiles.begin(),
- libCleanFiles.end());
+ this->CleanFiles.insert(libCleanFiles.begin(), libCleanFiles.end());
}
std::vector<std::string> commands1;
@@ -447,21 +393,20 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
this->LocalGenerator->CreateCDCommand(
commands1, this->Makefile->GetCurrentBinaryDirectory(),
this->LocalGenerator->GetBinaryDirectory());
- commands.insert(commands.end(), commands1.begin(), commands1.end());
+ cmAppend(commands, commands1);
commands1.clear();
// Compute the list of outputs.
std::vector<std::string> outputs(1, targetOutputReal);
// Write the build rule.
- this->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, outputs, depends,
+ this->WriteMakeRule(*this->BuildFileStream, nullptr, outputs, depends,
commands, false);
// Write the main driver rule to build everything in this target.
this->WriteTargetDriverRule(targetOutputReal, relink);
#else
static_cast<void>(linkRuleVar);
- static_cast<void>(extraFlags);
static_cast<void>(relink);
#endif
}
@@ -473,24 +418,24 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// code duplication.
std::vector<std::string> commands;
- // Build list of dependencies.
- std::vector<std::string> depends;
- this->AppendLinkDepends(depends);
- if (!this->DeviceLinkObject.empty()) {
- depends.push_back(this->DeviceLinkObject);
- }
-
// Get the language to use for linking this library.
std::string linkLanguage =
this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
// Make sure we have a link language.
if (linkLanguage.empty()) {
- cmSystemTools::Error("Cannot determine link language for target \"",
- this->GeneratorTarget->GetName().c_str(), "\".");
+ cmSystemTools::Error("Cannot determine link language for target \"" +
+ this->GeneratorTarget->GetName() + "\".");
return;
}
+ // Build list of dependencies.
+ std::vector<std::string> depends;
+ this->AppendLinkDepends(depends, linkLanguage);
+ if (!this->DeviceLinkObject.empty()) {
+ depends.push_back(this->DeviceLinkObject);
+ }
+
// Create set of linking flags.
std::string linkFlags;
this->LocalGenerator->AppendFlags(linkFlags, extraFlags);
@@ -505,61 +450,56 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
}
// Construct the name of the library.
- std::string targetName;
- std::string targetNameSO;
- std::string targetNameReal;
- std::string targetNameImport;
- std::string targetNamePDB;
- this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO,
- targetNameReal, targetNameImport,
- targetNamePDB, this->ConfigName);
+ this->GeneratorTarget->GetLibraryNames(this->ConfigName);
// Construct the full path version of the names.
std::string outpath;
std::string outpathImp;
if (this->GeneratorTarget->IsFrameworkOnApple()) {
outpath = this->GeneratorTarget->GetDirectory(this->ConfigName);
- this->OSXBundleGenerator->CreateFramework(targetName, outpath);
- outpath += "/";
+ this->OSXBundleGenerator->CreateFramework(this->TargetNames.Output,
+ outpath);
+ outpath += '/';
} else if (this->GeneratorTarget->IsCFBundleOnApple()) {
outpath = this->GeneratorTarget->GetDirectory(this->ConfigName);
- this->OSXBundleGenerator->CreateCFBundle(targetName, outpath);
- outpath += "/";
+ this->OSXBundleGenerator->CreateCFBundle(this->TargetNames.Output,
+ outpath);
+ outpath += '/';
} else if (relink) {
- outpath = this->Makefile->GetCurrentBinaryDirectory();
- outpath += cmake::GetCMakeFilesDirectory();
- outpath += "/CMakeRelink.dir";
- cmSystemTools::MakeDirectory(outpath.c_str());
- outpath += "/";
- if (!targetNameImport.empty()) {
+ outpath = cmStrCat(this->Makefile->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/CMakeRelink.dir");
+ cmSystemTools::MakeDirectory(outpath);
+ outpath += '/';
+ if (!this->TargetNames.ImportLibrary.empty()) {
outpathImp = outpath;
}
} else {
outpath = this->GeneratorTarget->GetDirectory(this->ConfigName);
- cmSystemTools::MakeDirectory(outpath.c_str());
- outpath += "/";
- if (!targetNameImport.empty()) {
+ cmSystemTools::MakeDirectory(outpath);
+ outpath += '/';
+ if (!this->TargetNames.ImportLibrary.empty()) {
outpathImp = this->GeneratorTarget->GetDirectory(
this->ConfigName, cmStateEnums::ImportLibraryArtifact);
- cmSystemTools::MakeDirectory(outpathImp.c_str());
- outpathImp += "/";
+ cmSystemTools::MakeDirectory(outpathImp);
+ outpathImp += '/';
}
}
std::string compilePdbOutputPath =
this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName);
- cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str());
+ cmSystemTools::MakeDirectory(compilePdbOutputPath);
std::string pdbOutputPath =
this->GeneratorTarget->GetPDBDirectory(this->ConfigName);
- cmSystemTools::MakeDirectory(pdbOutputPath.c_str());
+ cmSystemTools::MakeDirectory(pdbOutputPath);
pdbOutputPath += "/";
- std::string targetFullPath = outpath + targetName;
- std::string targetFullPathPDB = pdbOutputPath + targetNamePDB;
- std::string targetFullPathSO = outpath + targetNameSO;
- std::string targetFullPathReal = outpath + targetNameReal;
- std::string targetFullPathImport = outpathImp + targetNameImport;
+ std::string targetFullPath = outpath + this->TargetNames.Output;
+ std::string targetFullPathPDB = pdbOutputPath + this->TargetNames.PDB;
+ std::string targetFullPathSO = outpath + this->TargetNames.SharedObject;
+ std::string targetFullPathReal = outpath + this->TargetNames.Real;
+ std::string targetFullPathImport =
+ outpathImp + this->TargetNames.ImportLibrary;
// Construct the output path version of the names for use in command
// arguments.
@@ -590,8 +530,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
cmLocalUnixMakefileGenerator3::EchoProgress progress;
this->MakeEchoProgress(progress);
// Add the link message.
- std::string buildEcho = "Linking ";
- buildEcho += linkLanguage;
+ std::string buildEcho = cmStrCat("Linking ", linkLanguage);
switch (this->GeneratorTarget->GetType()) {
case cmStateEnums::STATIC_LIBRARY:
buildEcho += " static library ";
@@ -615,8 +554,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
}
// Clean files associated with this library.
- std::vector<std::string> libCleanFiles;
- libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
+ std::set<std::string> libCleanFiles;
+ libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal));
std::vector<std::string> commands1;
@@ -628,26 +567,27 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
this->LocalGenerator->CreateCDCommand(
commands1, this->Makefile->GetCurrentBinaryDirectory(),
this->LocalGenerator->GetBinaryDirectory());
- commands.insert(commands.end(), commands1.begin(), commands1.end());
+ cmAppend(commands, commands1);
commands1.clear();
}
- if (targetName != targetNameReal) {
- libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
+ if (this->TargetNames.Output != this->TargetNames.Real) {
+ libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath));
}
- if (targetNameSO != targetNameReal && targetNameSO != targetName) {
- libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
+ if (this->TargetNames.SharedObject != this->TargetNames.Real &&
+ this->TargetNames.SharedObject != this->TargetNames.Output) {
+ libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathSO));
}
- if (!targetNameImport.empty()) {
- libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
+ if (!this->TargetNames.ImportLibrary.empty()) {
+ libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(),
targetFullPathImport));
std::string implib;
- if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport,
- implib)) {
- libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
+ if (this->GeneratorTarget->GetImplibGNUtoMS(
+ this->ConfigName, targetFullPathImport, implib)) {
+ libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), implib));
}
}
@@ -655,16 +595,16 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// List the PDB for cleaning only when the whole target is
// cleaned. We do not want to delete the .pdb file just before
// linking the target.
- this->CleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
+ this->CleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathPDB));
#ifdef _WIN32
// There may be a manifest file for this target. Add it to the
// clean set just in case.
if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) {
- libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
+ libCleanFiles.insert(this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(),
- (targetFullPath + ".manifest").c_str()));
+ targetFullPath + ".manifest"));
}
#endif
@@ -694,35 +634,32 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
std::string::size_type archiveCommandLimit = std::string::npos;
if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
haveStaticLibraryRule = this->Makefile->IsDefinitionSet(linkRuleVar);
- std::string arCreateVar = "CMAKE_";
- arCreateVar += linkLanguage;
- arCreateVar += "_ARCHIVE_CREATE";
+ std::string arCreateVar =
+ cmStrCat("CMAKE_", linkLanguage, "_ARCHIVE_CREATE");
arCreateVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable(
arCreateVar, linkLanguage, this->ConfigName);
if (const char* rule = this->Makefile->GetDefinition(arCreateVar)) {
- cmSystemTools::ExpandListArgument(rule, archiveCreateCommands);
+ cmExpandList(rule, archiveCreateCommands);
}
- std::string arAppendVar = "CMAKE_";
- arAppendVar += linkLanguage;
- arAppendVar += "_ARCHIVE_APPEND";
+ std::string arAppendVar =
+ cmStrCat("CMAKE_", linkLanguage, "_ARCHIVE_APPEND");
arAppendVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable(
arAppendVar, linkLanguage, this->ConfigName);
if (const char* rule = this->Makefile->GetDefinition(arAppendVar)) {
- cmSystemTools::ExpandListArgument(rule, archiveAppendCommands);
+ cmExpandList(rule, archiveAppendCommands);
}
- std::string arFinishVar = "CMAKE_";
- arFinishVar += linkLanguage;
- arFinishVar += "_ARCHIVE_FINISH";
+ std::string arFinishVar =
+ cmStrCat("CMAKE_", linkLanguage, "_ARCHIVE_FINISH");
arFinishVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable(
arFinishVar, linkLanguage, this->ConfigName);
if (const char* rule = this->Makefile->GetDefinition(arFinishVar)) {
- cmSystemTools::ExpandListArgument(rule, archiveFinishCommands);
+ cmExpandList(rule, archiveFinishCommands);
}
}
@@ -736,10 +673,14 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// Archiving rules never use a response file.
useResponseFileForObjects = false;
- // Limit the length of individual object lists to less than the
- // 32K command line length limit on Windows. We could make this a
- // platform file variable but this should work everywhere.
- archiveCommandLimit = 30000;
+ // Limit the length of individual object lists to less than half of
+ // the command line length limit (leaving half for other flags).
+ // This may result in several calls to the archiver.
+ if (size_t limit = cmSystemTools::CalculateCommandLineLengthLimit()) {
+ archiveCommandLimit = limit / 2;
+ } else {
+ archiveCommandLimit = 8000;
+ }
}
// Expand the rule variables.
@@ -755,7 +696,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
std::string linkLibs;
if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) {
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
this->CreateLinkLineComputer(
this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory()));
@@ -832,7 +773,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
vars.ObjectsQuoted = buildObjs.c_str();
if (this->GeneratorTarget->HasSOName(this->ConfigName)) {
vars.SONameFlag = this->Makefile->GetSONameFlag(linkLanguage);
- vars.TargetSOName = targetNameSO.c_str();
+ vars.TargetSOName = this->TargetNames.SharedObject.c_str();
}
vars.LinkFlags = linkFlags.c_str();
@@ -870,11 +811,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
const char* val = this->LocalGenerator->GetRuleLauncher(
this->GeneratorTarget, "RULE_LAUNCH_LINK");
if (val && *val) {
- launcher = val;
- launcher += " ";
+ launcher = cmStrCat(val, ' ');
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander());
// Construct the main link rule and expand placeholders.
rulePlaceholderExpander->SetTargetImpLib(targetOutPathImport);
@@ -894,62 +834,55 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
}
// Create the archive with the first set of objects.
- std::vector<std::string>::iterator osi = object_strings.begin();
+ auto osi = object_strings.begin();
{
vars.Objects = osi->c_str();
- for (std::vector<std::string>::const_iterator i =
- archiveCreateCommands.begin();
- i != archiveCreateCommands.end(); ++i) {
- std::string cmd = launcher + *i;
+ for (std::string const& acc : archiveCreateCommands) {
+ std::string cmd = launcher + acc;
rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
cmd, vars);
- real_link_commands.push_back(cmd);
+ real_link_commands.push_back(std::move(cmd));
}
}
// Append to the archive with the other object sets.
for (++osi; osi != object_strings.end(); ++osi) {
vars.Objects = osi->c_str();
- for (std::vector<std::string>::const_iterator i =
- archiveAppendCommands.begin();
- i != archiveAppendCommands.end(); ++i) {
- std::string cmd = launcher + *i;
+ for (std::string const& aac : archiveAppendCommands) {
+ std::string cmd = launcher + aac;
rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
cmd, vars);
- real_link_commands.push_back(cmd);
+ real_link_commands.push_back(std::move(cmd));
}
}
// Finish the archive.
vars.Objects = "";
- for (std::vector<std::string>::const_iterator i =
- archiveFinishCommands.begin();
- i != archiveFinishCommands.end(); ++i) {
- std::string cmd = launcher + *i;
+ for (std::string const& afc : archiveFinishCommands) {
+ std::string cmd = launcher + afc;
rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, cmd,
vars);
// If there is no ranlib the command will be ":". Skip it.
if (!cmd.empty() && cmd[0] != ':') {
- real_link_commands.push_back(cmd);
+ real_link_commands.push_back(std::move(cmd));
}
}
} else {
// Get the set of commands.
std::string linkRule = this->GetLinkRule(linkRuleVar);
- cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
+ cmExpandList(linkRule, real_link_commands);
if (this->GeneratorTarget->GetPropertyAsBool("LINK_WHAT_YOU_USE") &&
(this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY)) {
- std::string cmakeCommand = this->LocalGenerator->ConvertToOutputFormat(
- cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
- cmakeCommand += " -E __run_iwyu --lwyu=";
- cmakeCommand += targetOutPathReal;
- real_link_commands.push_back(cmakeCommand);
+ std::string cmakeCommand = cmStrCat(
+ this->LocalGenerator->ConvertToOutputFormat(
+ cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL),
+ " -E __run_co_compile --lwyu=", targetOutPathReal);
+ real_link_commands.push_back(std::move(cmakeCommand));
}
// Expand placeholders.
- for (std::vector<std::string>::iterator i = real_link_commands.begin();
- i != real_link_commands.end(); ++i) {
- *i = launcher + *i;
- rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, *i,
- vars);
+ for (std::string& real_link_command : real_link_commands) {
+ real_link_command = cmStrCat(launcher, real_link_command);
+ rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
+ real_link_command, vars);
}
}
@@ -970,24 +903,21 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
this->LocalGenerator->CreateCDCommand(
commands1, this->Makefile->GetCurrentBinaryDirectory(),
this->LocalGenerator->GetBinaryDirectory());
- commands.insert(commands.end(), commands1.begin(), commands1.end());
+ cmAppend(commands, commands1);
commands1.clear();
// Add a rule to create necessary symlinks for the library.
// Frameworks are handled by cmOSXBundleGenerator.
if (targetOutPath != targetOutPathReal &&
!this->GeneratorTarget->IsFrameworkOnApple()) {
- std::string symlink = "$(CMAKE_COMMAND) -E cmake_symlink_library ";
- symlink += targetOutPathReal;
- symlink += " ";
- symlink += targetOutPathSO;
- symlink += " ";
- symlink += targetOutPath;
- commands1.push_back(symlink);
+ std::string symlink =
+ cmStrCat("$(CMAKE_COMMAND) -E cmake_symlink_library ", targetOutPathReal,
+ ' ', targetOutPathSO, ' ', targetOutPath);
+ commands1.push_back(std::move(symlink));
this->LocalGenerator->CreateCDCommand(
commands1, this->Makefile->GetCurrentBinaryDirectory(),
this->LocalGenerator->GetBinaryDirectory());
- commands.insert(commands.end(), commands1.begin(), commands1.end());
+ cmAppend(commands, commands1);
commands1.clear();
}
@@ -1000,21 +930,21 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// Compute the list of outputs.
std::vector<std::string> outputs(1, targetFullPathReal);
- if (targetNameSO != targetNameReal) {
+ if (this->TargetNames.SharedObject != this->TargetNames.Real) {
outputs.push_back(targetFullPathSO);
}
- if (targetName != targetNameSO && targetName != targetNameReal) {
+ if (this->TargetNames.Output != this->TargetNames.SharedObject &&
+ this->TargetNames.Output != this->TargetNames.Real) {
outputs.push_back(targetFullPath);
}
// Write the build rule.
- this->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, outputs, depends,
+ this->WriteMakeRule(*this->BuildFileStream, nullptr, outputs, depends,
commands, false);
// Write the main driver rule to build everything in this target.
this->WriteTargetDriverRule(targetFullPath, relink);
// Clean all the possible library names and symlinks.
- this->CleanFiles.insert(this->CleanFiles.end(), libCleanFiles.begin(),
- libCleanFiles.end());
+ this->CleanFiles.insert(libCleanFiles.begin(), libCleanFiles.end());
}
diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h
index da1d8b65c..ca22b099d 100644
--- a/Source/cmMakefileLibraryTargetGenerator.h
+++ b/Source/cmMakefileLibraryTargetGenerator.h
@@ -3,23 +3,23 @@
#ifndef cmMakefileLibraryTargetGenerator_h
#define cmMakefileLibraryTargetGenerator_h
-#include "cmConfigure.h"
-
-#include "cmMakefileTargetGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include "cmMakefileTargetGenerator.h"
+
class cmGeneratorTarget;
class cmMakefileLibraryTargetGenerator : public cmMakefileTargetGenerator
{
public:
cmMakefileLibraryTargetGenerator(cmGeneratorTarget* target);
- ~cmMakefileLibraryTargetGenerator() CM_OVERRIDE;
+ ~cmMakefileLibraryTargetGenerator() override;
/* the main entry point for this class. Writes the Makefiles associated
with this target */
- void WriteRuleFiles() CM_OVERRIDE;
+ void WriteRuleFiles() override;
protected:
void WriteObjectLibraryRules();
@@ -27,8 +27,7 @@ protected:
void WriteSharedLibraryRules(bool relink);
void WriteModuleLibraryRules(bool relink);
- void WriteDeviceLibraryRules(const std::string& linkRule,
- const std::string& extraFlags, bool relink);
+ void WriteDeviceLibraryRules(const std::string& linkRule, bool relink);
void WriteLibraryRules(const std::string& linkRule,
const std::string& extraFlags, bool relink);
// MacOSX Framework support methods
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index a4511b63b..dd8a389cb 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -2,8 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileTargetGenerator.h"
+#include <cstdio>
+#include <memory>
#include <sstream>
-#include <stdio.h>
#include <utility>
#include "cmAlgorithms.h"
@@ -14,30 +15,32 @@
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalUnixMakefileGenerator3.h"
+#include "cmLocalCommonGenerator.h"
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
#include "cmMakefileExecutableTargetGenerator.h"
#include "cmMakefileLibraryTargetGenerator.h"
#include "cmMakefileUtilityTargetGenerator.h"
#include "cmOutputConverter.h"
+#include "cmRange.h"
#include "cmRulePlaceholderExpander.h"
#include "cmSourceFile.h"
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target)
: cmCommonTargetGenerator(target)
- , OSXBundleGenerator(CM_NULLPTR)
- , MacOSXContentGenerator(CM_NULLPTR)
+ , OSXBundleGenerator(nullptr)
+ , MacOSXContentGenerator(nullptr)
{
- this->BuildFileStream = CM_NULLPTR;
- this->InfoFileStream = CM_NULLPTR;
- this->FlagFileStream = CM_NULLPTR;
+ this->BuildFileStream = nullptr;
+ this->InfoFileStream = nullptr;
+ this->FlagFileStream = nullptr;
this->CustomCommandDriver = OnBuild;
this->LocalGenerator =
static_cast<cmLocalUnixMakefileGenerator3*>(target->GetLocalGenerator());
@@ -47,7 +50,7 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target)
this->NoRuleMessages = false;
if (const char* ruleStatus =
cm->GetState()->GetGlobalProperty("RULE_MESSAGES")) {
- this->NoRuleMessages = cmSystemTools::IsOff(ruleStatus);
+ this->NoRuleMessages = cmIsOff(ruleStatus);
}
MacOSXContentGenerator = new MacOSXContentGeneratorType(this);
}
@@ -60,7 +63,7 @@ cmMakefileTargetGenerator::~cmMakefileTargetGenerator()
cmMakefileTargetGenerator* cmMakefileTargetGenerator::New(
cmGeneratorTarget* tgt)
{
- cmMakefileTargetGenerator* result = CM_NULLPTR;
+ cmMakefileTargetGenerator* result = nullptr;
switch (tgt->GetType()) {
case cmStateEnums::EXECUTABLE:
@@ -82,6 +85,26 @@ cmMakefileTargetGenerator* cmMakefileTargetGenerator::New(
return result;
}
+void cmMakefileTargetGenerator::GetTargetLinkFlags(
+ std::string& flags, const std::string& linkLanguage)
+{
+ this->LocalGenerator->AppendFlags(
+ flags, this->GeneratorTarget->GetSafeProperty("LINK_FLAGS"));
+
+ std::string linkFlagsConfig =
+ cmStrCat("LINK_FLAGS_", cmSystemTools::UpperCase(this->ConfigName));
+ this->LocalGenerator->AppendFlags(
+ flags, this->GeneratorTarget->GetSafeProperty(linkFlagsConfig));
+
+ std::vector<std::string> opts;
+ this->GeneratorTarget->GetLinkOptions(opts, this->ConfigName, linkLanguage);
+ // LINK_OPTIONS are escaped.
+ this->LocalGenerator->AppendCompileOptions(flags, opts);
+
+ this->LocalGenerator->AppendPositionIndependentLinkerFlags(
+ flags, this->GeneratorTarget, this->ConfigName, linkLanguage);
+}
+
void cmMakefileTargetGenerator::CreateRuleFile()
{
// Create a directory for this target.
@@ -89,17 +112,16 @@ void cmMakefileTargetGenerator::CreateRuleFile()
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
this->TargetBuildDirectoryFull =
this->LocalGenerator->ConvertToFullPath(this->TargetBuildDirectory);
- cmSystemTools::MakeDirectory(this->TargetBuildDirectoryFull.c_str());
+ cmSystemTools::MakeDirectory(this->TargetBuildDirectoryFull);
// Construct the rule file name.
- this->BuildFileName = this->TargetBuildDirectory;
- this->BuildFileName += "/build.make";
- this->BuildFileNameFull = this->TargetBuildDirectoryFull;
- this->BuildFileNameFull += "/build.make";
+ this->BuildFileName = cmStrCat(this->TargetBuildDirectory, "/build.make");
+ this->BuildFileNameFull =
+ cmStrCat(this->TargetBuildDirectoryFull, "/build.make");
// Construct the rule file name.
- this->ProgressFileNameFull = this->TargetBuildDirectoryFull;
- this->ProgressFileNameFull += "/progress.make";
+ this->ProgressFileNameFull =
+ cmStrCat(this->TargetBuildDirectoryFull, "/progress.make");
// reset the progress count
this->NumberOfProgressActions = 0;
@@ -107,12 +129,12 @@ void cmMakefileTargetGenerator::CreateRuleFile()
// Open the rule file. This should be copy-if-different because the
// rules may depend on this file itself.
this->BuildFileStream =
- new cmGeneratedFileStream(this->BuildFileNameFull.c_str(), false,
+ new cmGeneratedFileStream(this->BuildFileNameFull, false,
this->GlobalGenerator->GetMakefileEncoding());
- this->BuildFileStream->SetCopyIfDifferent(true);
if (!this->BuildFileStream) {
return;
}
+ this->BuildFileStream->SetCopyIfDifferent(true);
this->LocalGenerator->WriteDisclaimer(*this->BuildFileStream);
if (this->GlobalGenerator->AllowDeleteOnError()) {
std::vector<std::string> no_depends;
@@ -126,70 +148,110 @@ void cmMakefileTargetGenerator::CreateRuleFile()
void cmMakefileTargetGenerator::WriteTargetBuildRules()
{
- const std::string& config =
- this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
-
- // write the custom commands for this target
- // Look for files registered for cleaning in this directory.
- if (const char* additional_clean_files =
+ // -- Write the custom commands for this target
+
+ // Evaluates generator expressions and expands prop_value
+ auto evaluatedFiles =
+ [this](const char* prop_value) -> std::vector<std::string> {
+ std::vector<std::string> files;
+ cmExpandList(
+ cmGeneratorExpression::Evaluate(prop_value, this->LocalGenerator,
+ this->ConfigName, this->GeneratorTarget),
+ files);
+ return files;
+ };
+
+ // Look for additional files registered for cleaning in this directory.
+ if (const char* prop_value =
this->Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES")) {
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
- ge.Parse(additional_clean_files);
-
- cmSystemTools::ExpandListArgument(
- cge->Evaluate(this->LocalGenerator, config, false, this->GeneratorTarget,
- CM_NULLPTR, CM_NULLPTR),
- this->CleanFiles);
+ std::vector<std::string> const files = evaluatedFiles(prop_value);
+ this->CleanFiles.insert(files.begin(), files.end());
+ }
+
+ // Look for additional files registered for cleaning in this target.
+ if (const char* prop_value =
+ this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) {
+ std::vector<std::string> const files = evaluatedFiles(prop_value);
+ // For relative path support
+ std::string const& binaryDir =
+ this->LocalGenerator->GetCurrentBinaryDirectory();
+ for (std::string const& cfl : files) {
+ this->CleanFiles.insert(cmSystemTools::CollapseFullPath(cfl, binaryDir));
+ }
}
// add custom commands to the clean rules?
const char* clean_no_custom = this->Makefile->GetProperty("CLEAN_NO_CUSTOM");
- bool clean = cmSystemTools::IsOff(clean_no_custom);
+ bool clean = cmIsOff(clean_no_custom);
// First generate the object rule files. Save a list of all object
// files for this target.
std::vector<cmSourceFile const*> customCommands;
- this->GeneratorTarget->GetCustomCommands(customCommands, config);
+ this->GeneratorTarget->GetCustomCommands(customCommands, this->ConfigName);
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
- for (std::vector<cmSourceFile const*>::const_iterator si =
- customCommands.begin();
- si != customCommands.end(); ++si) {
- cmCustomCommandGenerator ccg(*(*si)->GetCustomCommand(), this->ConfigName,
+ for (cmSourceFile const* sf : customCommands) {
+ cmCustomCommandGenerator ccg(*sf->GetCustomCommand(), this->ConfigName,
this->LocalGenerator);
this->GenerateCustomRuleFile(ccg);
if (clean) {
const std::vector<std::string>& outputs = ccg.GetOutputs();
- for (std::vector<std::string>::const_iterator o = outputs.begin();
- o != outputs.end(); ++o) {
- this->CleanFiles.push_back(
- this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, *o));
+ for (std::string const& output : outputs) {
+ this->CleanFiles.insert(
+ this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir,
+ output));
+ }
+ const std::vector<std::string>& byproducts = ccg.GetByproducts();
+ for (std::string const& byproduct : byproducts) {
+ this->CleanFiles.insert(
+ this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir,
+ byproduct));
+ }
+ }
+ }
+
+ // Add byproducts from build events to the clean rules
+ if (clean) {
+ std::vector<cmCustomCommand> buildEventCommands =
+ this->GeneratorTarget->GetPreBuildCommands();
+
+ cmAppend(buildEventCommands, this->GeneratorTarget->GetPreLinkCommands());
+ cmAppend(buildEventCommands,
+ this->GeneratorTarget->GetPostBuildCommands());
+
+ for (const auto& be : buildEventCommands) {
+ cmCustomCommandGenerator beg(be, this->ConfigName, this->LocalGenerator);
+ const std::vector<std::string>& byproducts = beg.GetByproducts();
+ for (std::string const& byproduct : byproducts) {
+ this->CleanFiles.insert(
+ this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir,
+ byproduct));
}
}
}
std::vector<cmSourceFile const*> headerSources;
- this->GeneratorTarget->GetHeaderSources(headerSources, config);
+ this->GeneratorTarget->GetHeaderSources(headerSources, this->ConfigName);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
headerSources, this->MacOSXContentGenerator);
std::vector<cmSourceFile const*> extraSources;
- this->GeneratorTarget->GetExtraSources(extraSources, config);
+ this->GeneratorTarget->GetExtraSources(extraSources, this->ConfigName);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
extraSources, this->MacOSXContentGenerator);
+ const char* pchExtension =
+ this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION");
std::vector<cmSourceFile const*> externalObjects;
- this->GeneratorTarget->GetExternalObjects(externalObjects, config);
- for (std::vector<cmSourceFile const*>::const_iterator si =
- externalObjects.begin();
- si != externalObjects.end(); ++si) {
- this->ExternalObjects.push_back((*si)->GetFullPath());
+ this->GeneratorTarget->GetExternalObjects(externalObjects, this->ConfigName);
+ for (cmSourceFile const* sf : externalObjects) {
+ auto const& objectFileName = sf->GetFullPath();
+ if (!cmSystemTools::StringEndsWith(objectFileName, pchExtension)) {
+ this->ExternalObjects.push_back(objectFileName);
+ }
}
std::vector<cmSourceFile const*> objectSources;
- this->GeneratorTarget->GetObjectSources(objectSources, config);
- for (std::vector<cmSourceFile const*>::const_iterator si =
- objectSources.begin();
- si != objectSources.end(); ++si) {
+ this->GeneratorTarget->GetObjectSources(objectSources, this->ConfigName);
+ for (cmSourceFile const* sf : objectSources) {
// Generate this object file's rule file.
- this->WriteObjectRuleFiles(**si);
+ this->WriteObjectRuleFiles(*sf);
}
}
@@ -200,16 +262,14 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
: "");
// Include the dependencies for the target.
- std::string dependFileNameFull = this->TargetBuildDirectoryFull;
- dependFileNameFull += "/depend.make";
+ std::string dependFileNameFull =
+ cmStrCat(this->TargetBuildDirectoryFull, "/depend.make");
*this->BuildFileStream
<< "# Include any dependencies generated for this target.\n"
<< this->GlobalGenerator->IncludeDirective << " " << root
<< cmSystemTools::ConvertToOutputPath(
- this->LocalGenerator
- ->MaybeConvertToRelativePath(
- this->LocalGenerator->GetBinaryDirectory(), dependFileNameFull)
- .c_str())
+ this->LocalGenerator->MaybeConvertToRelativePath(
+ this->LocalGenerator->GetBinaryDirectory(), dependFileNameFull))
<< "\n\n";
if (!this->NoRuleMessages) {
@@ -218,20 +278,17 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
<< "# Include the progress variables for this target.\n"
<< this->GlobalGenerator->IncludeDirective << " " << root
<< cmSystemTools::ConvertToOutputPath(
- this->LocalGenerator
- ->MaybeConvertToRelativePath(
- this->LocalGenerator->GetBinaryDirectory(),
- this->ProgressFileNameFull)
- .c_str())
+ this->LocalGenerator->MaybeConvertToRelativePath(
+ this->LocalGenerator->GetBinaryDirectory(),
+ this->ProgressFileNameFull))
<< "\n\n";
}
// make sure the depend file exists
- if (!cmSystemTools::FileExists(dependFileNameFull.c_str())) {
+ if (!cmSystemTools::FileExists(dependFileNameFull)) {
// Write an empty dependency file.
cmGeneratedFileStream depFileStream(
- dependFileNameFull.c_str(), false,
- this->GlobalGenerator->GetMakefileEncoding());
+ dependFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
depFileStream << "# Empty dependencies file for "
<< this->GeneratorTarget->GetName() << ".\n"
<< "# This may be replaced when dependencies are built."
@@ -240,15 +297,15 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
// Open the flags file. This should be copy-if-different because the
// rules may depend on this file itself.
- this->FlagFileNameFull = this->TargetBuildDirectoryFull;
- this->FlagFileNameFull += "/flags.make";
+ this->FlagFileNameFull =
+ cmStrCat(this->TargetBuildDirectoryFull, "/flags.make");
this->FlagFileStream =
- new cmGeneratedFileStream(this->FlagFileNameFull.c_str(), false,
+ new cmGeneratedFileStream(this->FlagFileNameFull, false,
this->GlobalGenerator->GetMakefileEncoding());
- this->FlagFileStream->SetCopyIfDifferent(true);
if (!this->FlagFileStream) {
return;
}
+ this->FlagFileStream->SetCopyIfDifferent(true);
this->LocalGenerator->WriteDisclaimer(*this->FlagFileStream);
// Include the flags for the target.
@@ -256,11 +313,8 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
<< "# Include the compile flags for this target's objects.\n"
<< this->GlobalGenerator->IncludeDirective << " " << root
<< cmSystemTools::ConvertToOutputPath(
- this->LocalGenerator
- ->MaybeConvertToRelativePath(
- this->LocalGenerator->GetBinaryDirectory(),
- this->FlagFileNameFull)
- .c_str())
+ this->LocalGenerator->MaybeConvertToRelativePath(
+ this->LocalGenerator->GetBinaryDirectory(), this->FlagFileNameFull))
<< "\n\n";
}
@@ -272,28 +326,24 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
// put the compiler in the rules.make file so that if it changes
// things rebuild
- for (std::set<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
- std::string compiler = "CMAKE_";
- compiler += *l;
- compiler += "_COMPILER";
- *this->FlagFileStream << "# compile " << *l << " with "
+ for (std::string const& language : languages) {
+ std::string compiler = cmStrCat("CMAKE_", language, "_COMPILER");
+ *this->FlagFileStream << "# compile " << language << " with "
<< this->Makefile->GetSafeDefinition(compiler)
<< "\n";
}
- for (std::set<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
- std::string flags = this->GetFlags(*l);
- std::string defines = this->GetDefines(*l);
- std::string includes = this->GetIncludes(*l);
+ for (std::string const& language : languages) {
+ std::string flags = this->GetFlags(language);
+ std::string defines = this->GetDefines(language);
+ std::string includes = this->GetIncludes(language);
// Escape comment characters so they do not terminate assignment.
cmSystemTools::ReplaceString(flags, "#", "\\#");
cmSystemTools::ReplaceString(defines, "#", "\\#");
cmSystemTools::ReplaceString(includes, "#", "\\#");
- *this->FlagFileStream << *l << "_FLAGS = " << flags << "\n\n";
- *this->FlagFileStream << *l << "_DEFINES = " << defines << "\n\n";
- *this->FlagFileStream << *l << "_INCLUDES = " << includes << "\n\n";
+ *this->FlagFileStream << language << "_FLAGS = " << flags << "\n\n";
+ *this->FlagFileStream << language << "_DEFINES = " << defines << "\n\n";
+ *this->FlagFileStream << language << "_INCLUDES = " << includes << "\n\n";
}
}
@@ -312,10 +362,9 @@ void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()(
std::string const& input = source.GetFullPath();
// Get the output file location.
- std::string output = macdir;
- output += "/";
- output += cmSystemTools::GetFilenameName(input);
- this->Generator->CleanFiles.push_back(
+ std::string output =
+ cmStrCat(macdir, '/', cmSystemTools::GetFilenameName(input));
+ this->Generator->CleanFiles.insert(
this->Generator->LocalGenerator->MaybeConvertToRelativePath(
this->Generator->LocalGenerator->GetCurrentBinaryDirectory(), output));
output = this->Generator->LocalGenerator->MaybeConvertToRelativePath(
@@ -325,19 +374,19 @@ void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()(
std::vector<std::string> depends;
std::vector<std::string> commands;
depends.push_back(input);
- std::string copyEcho = "Copying OS X content ";
- copyEcho += output;
+ std::string copyEcho = cmStrCat("Copying OS X content ", output);
this->Generator->LocalGenerator->AppendEcho(
commands, copyEcho, cmLocalUnixMakefileGenerator3::EchoBuild);
- std::string copyCommand = "$(CMAKE_COMMAND) -E copy ";
- copyCommand += this->Generator->LocalGenerator->ConvertToOutputFormat(
- input, cmOutputConverter::SHELL);
- copyCommand += " ";
- copyCommand += this->Generator->LocalGenerator->ConvertToOutputFormat(
- output, cmOutputConverter::SHELL);
- commands.push_back(copyCommand);
+ std::string copyCommand =
+ cmStrCat("$(CMAKE_COMMAND) -E copy ",
+ this->Generator->LocalGenerator->ConvertToOutputFormat(
+ input, cmOutputConverter::SHELL),
+ ' ',
+ this->Generator->LocalGenerator->ConvertToOutputFormat(
+ output, cmOutputConverter::SHELL));
+ commands.push_back(std::move(copyCommand));
this->Generator->LocalGenerator->WriteMakeRule(
- *this->Generator->BuildFileStream, CM_NULLPTR, output, depends, commands,
+ *this->Generator->BuildFileStream, nullptr, output, depends, commands,
false);
this->Generator->ExtraFiles.insert(output);
}
@@ -357,9 +406,8 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
std::string const& objectName =
this->GeneratorTarget->GetObjectName(&source);
std::string obj =
- this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- obj += "/";
- obj += objectName;
+ cmStrCat(this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
+ '/', objectName);
// Avoid generating duplicate rules.
if (this->ObjectFiles.find(obj) == this->ObjectFiles.end()) {
@@ -369,47 +417,32 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
err << "Warning: Source file \"" << source.GetFullPath()
<< "\" is listed multiple times for target \""
<< this->GeneratorTarget->GetName() << "\".";
- cmSystemTools::Message(err.str().c_str(), "Warning");
+ cmSystemTools::Message(err.str(), "Warning");
return;
}
// Create the directory containing the object file. This may be a
// subdirectory under the target's directory.
- std::string dir = cmSystemTools::GetFilenamePath(obj);
- cmSystemTools::MakeDirectory(
- this->LocalGenerator->ConvertToFullPath(dir).c_str());
+ {
+ std::string dir = cmSystemTools::GetFilenamePath(obj);
+ cmSystemTools::MakeDirectory(this->LocalGenerator->ConvertToFullPath(dir));
+ }
// Save this in the target's list of object files.
this->Objects.push_back(obj);
- this->CleanFiles.push_back(obj);
-
- // TODO: Remove
- // std::string relativeObj
- //= this->LocalGenerator->GetHomeRelativeOutputPath();
- // relativeObj += obj;
+ this->CleanFiles.insert(obj);
- // we compute some depends when writing the depend.make that we will also
- // use in the build.make, same with depMakeFile
std::vector<std::string> depends;
- // generate the build rule file
- this->WriteObjectBuildFile(obj, lang, source, depends);
-
// The object file should be checked for dependency integrity.
- std::string objFullPath = this->LocalGenerator->GetCurrentBinaryDirectory();
- objFullPath += "/";
- objFullPath += obj;
+ std::string objFullPath =
+ cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/', obj);
objFullPath = cmSystemTools::CollapseFullPath(objFullPath);
std::string srcFullPath =
cmSystemTools::CollapseFullPath(source.GetFullPath());
- this->LocalGenerator->AddImplicitDepends(
- this->GeneratorTarget, lang, objFullPath.c_str(), srcFullPath.c_str());
-}
+ this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, lang,
+ objFullPath, srcFullPath);
-void cmMakefileTargetGenerator::WriteObjectBuildFile(
- std::string& obj, const std::string& lang, cmSourceFile const& source,
- std::vector<std::string>& depends)
-{
this->LocalGenerator->AppendRuleDepend(depends,
this->FlagFileNameFull.c_str());
this->LocalGenerator->AppendRuleDepends(depends,
@@ -418,21 +451,36 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
// generate the depend scanning rule
this->WriteObjectDependRules(source, depends);
- std::string relativeObj = this->LocalGenerator->GetHomeRelativeOutputPath();
- relativeObj += obj;
+ std::string config = this->LocalGenerator->GetConfigName();
+ std::string configUpper = cmSystemTools::UpperCase(config);
+
+ // Add precompile headers dependencies
+ const std::string pchSource =
+ this->GeneratorTarget->GetPchSource(config, lang);
+ if (!pchSource.empty() && !source.GetProperty("SKIP_PRECOMPILE_HEADERS")) {
+ std::string const& pchHeader =
+ this->GeneratorTarget->GetPchHeader(config, lang);
+ depends.push_back(pchHeader);
+ if (source.GetFullPath() != pchSource) {
+ depends.push_back(this->GeneratorTarget->GetPchFile(config, lang));
+ }
+ this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, lang,
+ objFullPath, pchHeader);
+ }
+
+ std::string relativeObj =
+ cmStrCat(this->LocalGenerator->GetHomeRelativeOutputPath(), obj);
// Write the build rule.
// Build the set of compiler flags.
std::string flags;
// Add language-specific flags.
- std::string langFlags = "$(";
- langFlags += lang;
- langFlags += "_FLAGS)";
+ std::string langFlags = cmStrCat("$(", lang, "_FLAGS)");
this->LocalGenerator->AppendFlags(flags, langFlags);
- std::string config = this->LocalGenerator->GetConfigName();
- std::string configUpper = cmSystemTools::UpperCase(config);
+ cmGeneratorExpressionInterpreter genexInterpreter(
+ this->LocalGenerator, config, this->GeneratorTarget, lang);
// Add Fortran format flags.
if (lang == "Fortran") {
@@ -440,34 +488,81 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
}
// Add flags from source file properties.
- if (const char* cflags = source.GetProperty("COMPILE_FLAGS")) {
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(cflags);
- const char* evaluatedFlags = cge->Evaluate(this->LocalGenerator, config,
- false, this->GeneratorTarget);
+ const std::string COMPILE_FLAGS("COMPILE_FLAGS");
+ if (const char* cflags = source.GetProperty(COMPILE_FLAGS)) {
+ const std::string& evaluatedFlags =
+ genexInterpreter.Evaluate(cflags, COMPILE_FLAGS);
this->LocalGenerator->AppendFlags(flags, evaluatedFlags);
*this->FlagFileStream << "# Custom flags: " << relativeObj
<< "_FLAGS = " << evaluatedFlags << "\n"
<< "\n";
}
+ const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
+ if (const char* coptions = source.GetProperty(COMPILE_OPTIONS)) {
+ const std::string& evaluatedOptions =
+ genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS);
+ this->LocalGenerator->AppendCompileOptions(flags, evaluatedOptions);
+ *this->FlagFileStream << "# Custom options: " << relativeObj
+ << "_OPTIONS = " << evaluatedOptions << "\n"
+ << "\n";
+ }
+
+ // Add precompile headers compile options.
+ if (!pchSource.empty() && !source.GetProperty("SKIP_PRECOMPILE_HEADERS")) {
+ std::string pchOptions;
+ if (source.GetFullPath() == pchSource) {
+ pchOptions =
+ this->GeneratorTarget->GetPchCreateCompileOptions(config, lang);
+ } else {
+ pchOptions =
+ this->GeneratorTarget->GetPchUseCompileOptions(config, lang);
+ }
+
+ const std::string& evaluatedFlags =
+ genexInterpreter.Evaluate(pchOptions, COMPILE_OPTIONS);
+
+ this->LocalGenerator->AppendCompileOptions(flags, evaluatedFlags);
+ *this->FlagFileStream << "# PCH options: " << relativeObj
+ << "_OPTIONS = " << evaluatedFlags << "\n"
+ << "\n";
+ }
+
+ // Add include directories from source file properties.
+ std::vector<std::string> includes;
+
+ const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
+ if (const char* cincludes = source.GetProperty(INCLUDE_DIRECTORIES)) {
+ const std::string& evaluatedIncludes =
+ genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES);
+ this->LocalGenerator->AppendIncludeDirectories(includes, evaluatedIncludes,
+ source);
+ *this->FlagFileStream << "# Custom include directories: " << relativeObj
+ << "_INCLUDE_DIRECTORIES = " << evaluatedIncludes
+ << "\n"
+ << "\n";
+ }
+
// Add language-specific defines.
std::set<std::string> defines;
- // Add source-sepcific preprocessor definitions.
- if (const char* compile_defs = source.GetProperty("COMPILE_DEFINITIONS")) {
- this->LocalGenerator->AppendDefines(defines, compile_defs);
+ // Add source-specific preprocessor definitions.
+ const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
+ if (const char* compile_defs = source.GetProperty(COMPILE_DEFINITIONS)) {
+ const std::string& evaluatedDefs =
+ genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS);
+ this->LocalGenerator->AppendDefines(defines, evaluatedDefs);
*this->FlagFileStream << "# Custom defines: " << relativeObj
- << "_DEFINES = " << compile_defs << "\n"
+ << "_DEFINES = " << evaluatedDefs << "\n"
<< "\n";
}
- std::string defPropName = "COMPILE_DEFINITIONS_";
- defPropName += configUpper;
+ std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper);
if (const char* config_compile_defs = source.GetProperty(defPropName)) {
- this->LocalGenerator->AppendDefines(defines, config_compile_defs);
+ const std::string& evaluatedDefs =
+ genexInterpreter.Evaluate(config_compile_defs, COMPILE_DEFINITIONS);
+ this->LocalGenerator->AppendDefines(defines, evaluatedDefs);
*this->FlagFileStream << "# Custom defines: " << relativeObj << "_DEFINES_"
- << configUpper << " = " << config_compile_defs
- << "\n"
+ << configUpper << " = " << evaluatedDefs << "\n"
<< "\n";
}
@@ -485,10 +580,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
if (!this->NoRuleMessages) {
cmLocalUnixMakefileGenerator3::EchoProgress progress;
this->MakeEchoProgress(progress);
- std::string buildEcho = "Building ";
- buildEcho += lang;
- buildEcho += " object ";
- buildEcho += relativeObj;
+ std::string buildEcho =
+ cmStrCat("Building ", lang, " object ", relativeObj);
this->LocalGenerator->AppendEcho(commands, buildEcho,
cmLocalUnixMakefileGenerator3::EchoBuild,
&progress);
@@ -508,9 +601,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
targetFullPathReal = this->GeneratorTarget->GetFullPath(
this->ConfigName, cmStateEnums::RuntimeBinaryArtifact, true);
targetFullPathPDB =
- this->GeneratorTarget->GetPDBDirectory(this->ConfigName);
- targetFullPathPDB += "/";
- targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName);
+ cmStrCat(this->GeneratorTarget->GetPDBDirectory(this->ConfigName), '/',
+ this->GeneratorTarget->GetPDBName(this->ConfigName));
}
targetOutPathReal = this->LocalGenerator->ConvertToOutputFormat(
@@ -530,7 +622,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
// mingw32-make incorrectly interprets 'a\ b c' as 'a b' and 'c'
// (but 'a\ b "c"' as 'a\', 'b', and 'c'!). Workaround this by
// avoiding a trailing backslash in the argument.
- targetOutPathCompilePDB[targetOutPathCompilePDB.size() - 1] = '/';
+ targetOutPathCompilePDB.back() = '/';
}
}
cmRulePlaceholderExpander::RuleVariables vars;
@@ -559,15 +651,16 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
vars.ObjectFileDir = objectFileDir.c_str();
vars.Flags = flags.c_str();
- std::string definesString = "$(";
- definesString += lang;
- definesString += "_DEFINES)";
+ std::string definesString = cmStrCat("$(", lang, "_DEFINES)");
this->LocalGenerator->JoinDefines(defines, definesString, lang);
vars.Defines = definesString.c_str();
- std::string const includesString = "$(" + lang + "_INCLUDES)";
+ std::string includesString = this->LocalGenerator->GetIncludeFlags(
+ includes, this->GeneratorTarget, lang, true, false, config);
+ this->LocalGenerator->AppendFlags(includesString,
+ "$(" + lang + "_INCLUDES)");
vars.Includes = includesString.c_str();
// At the moment, it is assumed that C, C++, Fortran, and CUDA have both
@@ -578,7 +671,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
bool const lang_has_assembly = lang_has_preprocessor;
bool const lang_can_export_cmds = lang_has_preprocessor;
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->LocalGenerator->CreateRulePlaceholderExpander());
// Construct the compile rules.
@@ -588,20 +681,21 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
std::string cmdVar;
if (this->GeneratorTarget->GetPropertyAsBool(
"CUDA_SEPARABLE_COMPILATION")) {
- cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION");
+ cmdVar = "CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION";
} else if (this->GeneratorTarget->GetPropertyAsBool(
"CUDA_PTX_COMPILATION")) {
- cmdVar = std::string("CMAKE_CUDA_COMPILE_PTX_COMPILATION");
+ cmdVar = "CMAKE_CUDA_COMPILE_PTX_COMPILATION";
} else {
- cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION");
+ cmdVar = "CMAKE_CUDA_COMPILE_WHOLE_COMPILATION";
}
- std::string compileRule = this->Makefile->GetRequiredDefinition(cmdVar);
- cmSystemTools::ExpandListArgument(compileRule, compileCommands);
+ const std::string& compileRule =
+ this->Makefile->GetRequiredDefinition(cmdVar);
+ cmExpandList(compileRule, compileCommands);
} else {
- const std::string cmdVar =
- std::string("CMAKE_") + lang + "_COMPILE_OBJECT";
- std::string compileRule = this->Makefile->GetRequiredDefinition(cmdVar);
- cmSystemTools::ExpandListArgument(compileRule, compileCommands);
+ const std::string cmdVar = "CMAKE_" + lang + "_COMPILE_OBJECT";
+ const std::string& compileRule =
+ this->Makefile->GetRequiredDefinition(cmdVar);
+ cmExpandList(compileRule, compileCommands);
}
if (this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS") &&
@@ -621,10 +715,34 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
std::string langIncludes = std::string("$(") + lang + "_INCLUDES)";
compileCommand.replace(compileCommand.find(langIncludes),
langIncludes.size(), this->GetIncludes(lang));
+
+ const char* eliminate[] = {
+ this->Makefile->GetDefinition("CMAKE_START_TEMP_FILE"),
+ this->Makefile->GetDefinition("CMAKE_END_TEMP_FILE")
+ };
+ for (const char* el : eliminate) {
+ if (el) {
+ cmSystemTools::ReplaceString(compileCommand, el, "");
+ }
+ }
+
this->GlobalGenerator->AddCXXCompileCommand(
source.GetFullPath(), workingDirectory, compileCommand);
}
+ // See if we need to use a compiler launcher like ccache or distcc
+ std::string compilerLauncher;
+ if (!compileCommands.empty() &&
+ (lang == "C" || lang == "CXX" || lang == "Fortran" || lang == "CUDA" ||
+ lang == "OBJC" || lang == "OBJCXX")) {
+ std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
+ const char* clauncher =
+ this->GeneratorTarget->GetProperty(clauncher_prop);
+ if (clauncher && *clauncher) {
+ compilerLauncher = clauncher;
+ }
+ }
+
// Maybe insert an include-what-you-use runner.
if (!compileCommands.empty() && (lang == "C" || lang == "CXX")) {
std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE";
@@ -633,8 +751,18 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
const char* tidy = this->GeneratorTarget->GetProperty(tidy_prop);
std::string const cpplint_prop = lang + "_CPPLINT";
const char* cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
- if ((iwyu && *iwyu) || (tidy && *tidy) || (cpplint && *cpplint)) {
- std::string run_iwyu = "$(CMAKE_COMMAND) -E __run_iwyu";
+ std::string const cppcheck_prop = lang + "_CPPCHECK";
+ const char* cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
+ if ((iwyu && *iwyu) || (tidy && *tidy) || (cpplint && *cpplint) ||
+ (cppcheck && *cppcheck)) {
+ std::string run_iwyu = "$(CMAKE_COMMAND) -E __run_co_compile";
+ if (!compilerLauncher.empty()) {
+ // In __run_co_compile case the launcher command is supplied
+ // via --launcher=<maybe-list> and consumed
+ run_iwyu += " --launcher=";
+ run_iwyu += this->LocalGenerator->EscapeForShell(compilerLauncher);
+ compilerLauncher.clear();
+ }
if (iwyu && *iwyu) {
run_iwyu += " --iwyu=";
run_iwyu += this->LocalGenerator->EscapeForShell(iwyu);
@@ -647,7 +775,12 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
run_iwyu += " --cpplint=";
run_iwyu += this->LocalGenerator->EscapeForShell(cpplint);
}
- if ((tidy && *tidy) || (cpplint && *cpplint)) {
+ if (cppcheck && *cppcheck) {
+ run_iwyu += " --cppcheck=";
+ run_iwyu += this->LocalGenerator->EscapeForShell(cppcheck);
+ }
+ if ((tidy && *tidy) || (cpplint && *cpplint) ||
+ (cppcheck && *cppcheck)) {
run_iwyu += " --source=";
run_iwyu += sourceFile;
}
@@ -656,22 +789,18 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
}
}
- // Maybe insert a compiler launcher like ccache or distcc
- if (!compileCommands.empty() && (lang == "C" || lang == "CXX")) {
- std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
- const char* clauncher =
- this->GeneratorTarget->GetProperty(clauncher_prop);
- if (clauncher && *clauncher) {
- std::vector<std::string> launcher_cmd;
- cmSystemTools::ExpandListArgument(clauncher, launcher_cmd, true);
- for (std::vector<std::string>::iterator i = launcher_cmd.begin(),
- e = launcher_cmd.end();
- i != e; ++i) {
- *i = this->LocalGenerator->EscapeForShell(*i);
+ // If compiler launcher was specified and not consumed above, it
+ // goes to the beginning of the command line.
+ if (!compileCommands.empty() && !compilerLauncher.empty()) {
+ std::vector<std::string> args = cmExpandedList(compilerLauncher, true);
+ if (!args.empty()) {
+ args[0] = this->LocalGenerator->ConvertToOutputFormat(
+ args[0], cmOutputConverter::SHELL);
+ for (std::string& i : cmMakeRange(args.begin() + 1, args.end())) {
+ i = this->LocalGenerator->EscapeForShell(i);
}
- std::string const& run_launcher = cmJoin(launcher_cmd, " ") + " ";
- compileCommands.front().insert(0, run_launcher);
}
+ compileCommands.front().insert(0, cmJoin(args, " ") + " ");
}
std::string launcher;
@@ -679,38 +808,34 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
const char* val = this->LocalGenerator->GetRuleLauncher(
this->GeneratorTarget, "RULE_LAUNCH_COMPILE");
if (val && *val) {
- launcher = val;
- launcher += " ";
+ launcher = cmStrCat(val, ' ');
}
}
// Expand placeholders in the commands.
- for (std::vector<std::string>::iterator i = compileCommands.begin();
- i != compileCommands.end(); ++i) {
- *i = launcher + *i;
- rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, *i,
- vars);
+ for (std::string& compileCommand : compileCommands) {
+ compileCommand = cmStrCat(launcher, compileCommand);
+ rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
+ compileCommand, vars);
}
// Change the command working directory to the local build tree.
this->LocalGenerator->CreateCDCommand(
compileCommands, this->LocalGenerator->GetCurrentBinaryDirectory(),
this->LocalGenerator->GetBinaryDirectory());
- commands.insert(commands.end(), compileCommands.begin(),
- compileCommands.end());
+ cmAppend(commands, compileCommands);
}
// Check for extra outputs created by the compilation.
std::vector<std::string> outputs(1, relativeObj);
if (const char* extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) {
// Register these as extra files to clean.
- cmSystemTools::ExpandListArgument(extra_outputs_str, outputs);
- this->CleanFiles.insert(this->CleanFiles.end(), outputs.begin() + 1,
- outputs.end());
+ cmExpandList(extra_outputs_str, outputs);
+ this->CleanFiles.insert(outputs.begin() + 1, outputs.end());
}
// Write the rule.
- this->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, outputs, depends,
+ this->WriteMakeRule(*this->BuildFileStream, nullptr, outputs, depends,
commands);
bool do_preprocess_rules = lang_has_preprocessor &&
@@ -719,7 +844,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
lang_has_assembly && this->LocalGenerator->GetCreateAssemblySourceRules();
if (do_preprocess_rules || do_assembly_rules) {
std::vector<std::string> force_depends;
- force_depends.push_back("cmake_force");
+ force_depends.emplace_back("cmake_force");
std::string::size_type dot_pos = relativeObj.rfind('.');
std::string relativeObjBase = relativeObj.substr(0, dot_pos);
dot_pos = obj.rfind('.');
@@ -730,46 +855,42 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
std::string relativeObjI = relativeObjBase + ".i";
std::string objI = objBase + ".i";
- std::string preprocessEcho = "Preprocessing ";
- preprocessEcho += lang;
- preprocessEcho += " source to ";
- preprocessEcho += objI;
+ std::string preprocessEcho =
+ cmStrCat("Preprocessing ", lang, " source to ", objI);
this->LocalGenerator->AppendEcho(
commands, preprocessEcho, cmLocalUnixMakefileGenerator3::EchoBuild);
- std::string preprocessRuleVar = "CMAKE_";
- preprocessRuleVar += lang;
- preprocessRuleVar += "_CREATE_PREPROCESSED_SOURCE";
+ std::string preprocessRuleVar =
+ cmStrCat("CMAKE_", lang, "_CREATE_PREPROCESSED_SOURCE");
if (const char* preprocessRule =
this->Makefile->GetDefinition(preprocessRuleVar)) {
- std::vector<std::string> preprocessCommands;
- cmSystemTools::ExpandListArgument(preprocessRule, preprocessCommands);
+ std::vector<std::string> preprocessCommands =
+ cmExpandedList(preprocessRule);
std::string shellObjI = this->LocalGenerator->ConvertToOutputFormat(
objI, cmOutputConverter::SHELL);
vars.PreprocessedSource = shellObjI.c_str();
// Expand placeholders in the commands.
- for (std::vector<std::string>::iterator i = preprocessCommands.begin();
- i != preprocessCommands.end(); ++i) {
+ for (std::string& preprocessCommand : preprocessCommands) {
// no launcher for preprocessor commands
- rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
- *i, vars);
+ rulePlaceholderExpander->ExpandRuleVariables(
+ this->LocalGenerator, preprocessCommand, vars);
}
this->LocalGenerator->CreateCDCommand(
preprocessCommands,
this->LocalGenerator->GetCurrentBinaryDirectory(),
this->LocalGenerator->GetBinaryDirectory());
- commands.insert(commands.end(), preprocessCommands.begin(),
- preprocessCommands.end());
+ cmAppend(commands, preprocessCommands);
} else {
- std::string cmd = "$(CMAKE_COMMAND) -E cmake_unimplemented_variable ";
- cmd += preprocessRuleVar;
- commands.push_back(cmd);
+ std::string cmd =
+ cmStrCat("$(CMAKE_COMMAND) -E cmake_unimplemented_variable ",
+ preprocessRuleVar);
+ commands.push_back(std::move(cmd));
}
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
relativeObjI, force_depends,
commands, false);
}
@@ -779,109 +900,45 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
std::string relativeObjS = relativeObjBase + ".s";
std::string objS = objBase + ".s";
- std::string assemblyEcho = "Compiling ";
- assemblyEcho += lang;
- assemblyEcho += " source to assembly ";
- assemblyEcho += objS;
+ std::string assemblyEcho =
+ cmStrCat("Compiling ", lang, " source to assembly ", objS);
this->LocalGenerator->AppendEcho(
commands, assemblyEcho, cmLocalUnixMakefileGenerator3::EchoBuild);
- std::string assemblyRuleVar = "CMAKE_";
- assemblyRuleVar += lang;
- assemblyRuleVar += "_CREATE_ASSEMBLY_SOURCE";
+ std::string assemblyRuleVar =
+ cmStrCat("CMAKE_", lang, "_CREATE_ASSEMBLY_SOURCE");
if (const char* assemblyRule =
this->Makefile->GetDefinition(assemblyRuleVar)) {
- std::vector<std::string> assemblyCommands;
- cmSystemTools::ExpandListArgument(assemblyRule, assemblyCommands);
+ std::vector<std::string> assemblyCommands =
+ cmExpandedList(assemblyRule);
std::string shellObjS = this->LocalGenerator->ConvertToOutputFormat(
objS, cmOutputConverter::SHELL);
vars.AssemblySource = shellObjS.c_str();
// Expand placeholders in the commands.
- for (std::vector<std::string>::iterator i = assemblyCommands.begin();
- i != assemblyCommands.end(); ++i) {
+ for (std::string& assemblyCommand : assemblyCommands) {
// no launcher for assembly commands
rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator,
- *i, vars);
+ assemblyCommand, vars);
}
this->LocalGenerator->CreateCDCommand(
assemblyCommands, this->LocalGenerator->GetCurrentBinaryDirectory(),
this->LocalGenerator->GetBinaryDirectory());
- commands.insert(commands.end(), assemblyCommands.begin(),
- assemblyCommands.end());
+ cmAppend(commands, assemblyCommands);
} else {
- std::string cmd = "$(CMAKE_COMMAND) -E cmake_unimplemented_variable ";
- cmd += assemblyRuleVar;
- commands.push_back(cmd);
+ std::string cmd =
+ cmStrCat("$(CMAKE_COMMAND) -E cmake_unimplemented_variable ",
+ assemblyRuleVar);
+ commands.push_back(std::move(cmd));
}
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
relativeObjS, force_depends,
commands, false);
}
}
-
- // If the language needs provides-requires mode, create the
- // corresponding targets.
- std::string objectRequires = relativeObj;
- objectRequires += ".requires";
- std::vector<std::string> p_depends;
- // always provide an empty requires target
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
- objectRequires, p_depends, no_commands,
- true);
-
- // write a build rule to recursively build what this obj provides
- std::string objectProvides = relativeObj;
- objectProvides += ".provides";
- std::string temp = relativeObj;
- temp += ".provides.build";
- std::vector<std::string> r_commands;
- std::string tgtMakefileName =
- this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget);
- tgtMakefileName += "/build.make";
- r_commands.push_back(
- this->LocalGenerator->GetRecursiveMakeCall(tgtMakefileName.c_str(), temp));
-
- p_depends.clear();
- p_depends.push_back(objectRequires);
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
- objectProvides, p_depends, r_commands,
- true);
-
- // write the provides.build rule dependency on the obj file
- p_depends.clear();
- p_depends.push_back(relativeObj);
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR, temp,
- p_depends, no_commands, false);
-}
-
-void cmMakefileTargetGenerator::WriteTargetRequiresRules()
-{
- std::vector<std::string> depends;
- std::vector<std::string> no_commands;
-
- // Construct the name of the dependency generation target.
- std::string depTarget =
- this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget);
- depTarget += "/requires";
-
- // This target drives dependency generation for all object files.
- std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath();
- std::string objTarget;
- for (std::vector<std::string>::const_iterator obj = this->Objects.begin();
- obj != this->Objects.end(); ++obj) {
- objTarget = relPath;
- objTarget += *obj;
- objTarget += ".requires";
- depends.push_back(objTarget);
- }
-
- // Write the rule.
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
- depTarget, depends, no_commands, true);
}
void cmMakefileTargetGenerator::WriteTargetCleanRules()
@@ -890,9 +947,9 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules()
std::vector<std::string> commands;
// Construct the clean target name.
- std::string cleanTarget =
- this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget);
- cleanTarget += "/clean";
+ std::string cleanTarget = cmStrCat(
+ this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget),
+ "/clean");
// Construct the clean command.
this->LocalGenerator->AppendCleanCommand(commands, this->CleanFiles,
@@ -902,7 +959,7 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules()
this->LocalGenerator->GetBinaryDirectory());
// Write the rule.
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
cleanTarget, depends, commands, true);
}
@@ -939,18 +996,17 @@ bool cmMakefileTargetGenerator::WriteMakeRule(
// For multiple outputs, make the extra ones depend on the first one.
std::vector<std::string> const output_depends(1, outputs[0]);
std::string binDir = this->LocalGenerator->GetBinaryDirectory();
- for (std::vector<std::string>::const_iterator o = outputs.begin() + 1;
- o != outputs.end(); ++o) {
+ for (std::string const& output : cmMakeRange(outputs).advance(1)) {
// Touch the extra output so "make" knows that it was updated,
- // but only if the output was acually created.
+ // but only if the output was actually created.
std::string const out = this->LocalGenerator->ConvertToOutputFormat(
- this->LocalGenerator->MaybeConvertToRelativePath(binDir, *o),
+ this->LocalGenerator->MaybeConvertToRelativePath(binDir, output),
cmOutputConverter::SHELL);
std::vector<std::string> output_commands;
bool o_symbolic = false;
if (need_symbolic) {
- if (cmSourceFile* sf = this->Makefile->GetSource(*o)) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(output)) {
o_symbolic = sf->GetPropertyAsBool("SYMBOLIC");
}
}
@@ -959,13 +1015,13 @@ bool cmMakefileTargetGenerator::WriteMakeRule(
if (!o_symbolic) {
output_commands.push_back("@$(CMAKE_COMMAND) -E touch_nocreate " + out);
}
- this->LocalGenerator->WriteMakeRule(os, CM_NULLPTR, *o, output_depends,
+ this->LocalGenerator->WriteMakeRule(os, nullptr, output, output_depends,
output_commands, o_symbolic, in_help);
if (!o_symbolic) {
// At build time, remove the first output if this one does not exist
// so that "make" will rerun the real commands that create this one.
- MultipleOutputPairsType::value_type p(*o, outputs[0]);
+ MultipleOutputPairsType::value_type p(output, outputs[0]);
this->MultipleOutputPairs.insert(p);
}
}
@@ -977,16 +1033,14 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
// must write the targets depend info file
std::string dir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- this->InfoFileNameFull = dir;
- this->InfoFileNameFull += "/DependInfo.cmake";
+ this->InfoFileNameFull = cmStrCat(dir, "/DependInfo.cmake");
this->InfoFileNameFull =
this->LocalGenerator->ConvertToFullPath(this->InfoFileNameFull);
- this->InfoFileStream =
- new cmGeneratedFileStream(this->InfoFileNameFull.c_str());
- this->InfoFileStream->SetCopyIfDifferent(true);
- if (!*this->InfoFileStream) {
+ this->InfoFileStream = new cmGeneratedFileStream(this->InfoFileNameFull);
+ if (!this->InfoFileStream) {
return;
}
+ this->InfoFileStream->SetCopyIfDifferent(true);
this->LocalGenerator->WriteDependLanguageInfo(*this->InfoFileStream,
this->GeneratorTarget);
@@ -998,12 +1052,10 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
<< "# Pairs of files generated by the same build rule.\n"
<< "set(CMAKE_MULTIPLE_OUTPUT_PAIRS\n";
/* clang-format on */
- for (MultipleOutputPairsType::const_iterator pi =
- this->MultipleOutputPairs.begin();
- pi != this->MultipleOutputPairs.end(); ++pi) {
+ for (auto const& pi : this->MultipleOutputPairs) {
*this->InfoFileStream
- << " " << cmOutputConverter::EscapeForCMake(pi->first) << " "
- << cmOutputConverter::EscapeForCMake(pi->second) << "\n";
+ << " " << cmOutputConverter::EscapeForCMake(pi.first) << " "
+ << cmOutputConverter::EscapeForCMake(pi.second) << "\n";
}
*this->InfoFileStream << " )\n\n";
}
@@ -1017,9 +1069,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
<< "set(CMAKE_TARGET_LINKED_INFO_FILES\n";
/* clang-format on */
std::vector<std::string> dirs = this->GetLinkedTargetDirectories();
- for (std::vector<std::string>::iterator i = dirs.begin(); i != dirs.end();
- ++i) {
- *this->InfoFileStream << " \"" << *i << "/DependInfo.cmake\"\n";
+ for (std::string const& d : dirs) {
+ *this->InfoFileStream << " \"" << d << "/DependInfo.cmake\"\n";
}
*this->InfoFileStream << " )\n";
}
@@ -1041,9 +1092,9 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
std::vector<std::string> commands;
// Construct the name of the dependency generation target.
- std::string depTarget =
- this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget);
- depTarget += "/depend";
+ std::string depTarget = cmStrCat(
+ this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget),
+ "/depend");
// Add a command to call CMake to scan dependencies. CMake will
// touch the corresponding depends file after scanning dependencies.
@@ -1055,10 +1106,11 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
// paths. Make sure PWD is set to the original name of the home
// output directory to help cmSystemTools to create the same
// translation table for the dependency scanning process.
- depCmd << "cd " << (this->LocalGenerator->ConvertToOutputFormat(
- cmSystemTools::CollapseFullPath(
- this->LocalGenerator->GetBinaryDirectory()),
- cmOutputConverter::SHELL))
+ depCmd << "cd "
+ << (this->LocalGenerator->ConvertToOutputFormat(
+ cmSystemTools::CollapseFullPath(
+ this->LocalGenerator->GetBinaryDirectory()),
+ cmOutputConverter::SHELL))
<< " && ";
#endif
// Generate a call this signature:
@@ -1106,7 +1158,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
}
// Write the rule.
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
depTarget, depends, commands, true);
}
@@ -1117,13 +1169,11 @@ void cmMakefileTargetGenerator::DriveCustomCommands(
std::vector<cmSourceFile*> sources;
this->GeneratorTarget->GetSourceFiles(
sources, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- for (std::vector<cmSourceFile*>::const_iterator source = sources.begin();
- source != sources.end(); ++source) {
- if (cmCustomCommand* cc = (*source)->GetCustomCommand()) {
+ for (cmSourceFile* source : sources) {
+ if (cmCustomCommand* cc = source->GetCustomCommand()) {
cmCustomCommandGenerator ccg(*cc, this->ConfigName,
this->LocalGenerator);
- const std::vector<std::string>& outputs = ccg.GetOutputs();
- depends.insert(depends.end(), outputs.begin(), outputs.end());
+ cmAppend(depends, ccg.GetOutputs());
}
}
}
@@ -1135,7 +1185,7 @@ void cmMakefileTargetGenerator::WriteObjectDependRules(
// shared between the object file and dependency scanning rule.
depends.push_back(source.GetFullPath());
if (const char* objectDeps = source.GetProperty("OBJECT_DEPENDS")) {
- cmSystemTools::ExpandListArgument(objectDeps, depends);
+ cmExpandList(objectDeps, depends);
}
}
@@ -1169,8 +1219,8 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile(
// Write the rule.
const std::vector<std::string>& outputs = ccg.GetOutputs();
- bool symbolic = this->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
- outputs, depends, commands);
+ bool symbolic = this->WriteMakeRule(*this->BuildFileStream, nullptr, outputs,
+ depends, commands);
// If the rule has changed make sure the output is rebuilt.
if (!symbolic) {
@@ -1178,22 +1228,19 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile(
}
// Setup implicit dependency scanning.
- for (cmCustomCommand::ImplicitDependsList::const_iterator idi =
- ccg.GetCC().GetImplicitDepends().begin();
- idi != ccg.GetCC().GetImplicitDepends().end(); ++idi) {
+ for (auto const& idi : ccg.GetCC().GetImplicitDepends()) {
std::string objFullPath = cmSystemTools::CollapseFullPath(outputs[0]);
- std::string srcFullPath = cmSystemTools::CollapseFullPath(idi->second);
- this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, idi->first,
- objFullPath.c_str(),
- srcFullPath.c_str());
+ std::string srcFullPath = cmSystemTools::CollapseFullPath(idi.second);
+ this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, idi.first,
+ objFullPath, srcFullPath);
}
}
void cmMakefileTargetGenerator::MakeEchoProgress(
cmLocalUnixMakefileGenerator3::EchoProgress& progress) const
{
- progress.Dir = this->LocalGenerator->GetBinaryDirectory();
- progress.Dir += cmake::GetCMakeFilesDirectory();
+ progress.Dir =
+ cmStrCat(this->LocalGenerator->GetBinaryDirectory(), "/CMakeFiles");
std::ostringstream progressArg;
progressArg << "$(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")";
progress.Arg = progressArg.str();
@@ -1216,11 +1263,18 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
if (!lineContinue) {
lineContinue = "\\";
}
- for (std::vector<std::string>::const_iterator i = this->Objects.begin();
- i != this->Objects.end(); ++i) {
+
+ const char* pchExtension =
+ this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION");
+
+ for (std::string const& obj : this->Objects) {
+ if (cmSystemTools::StringEndsWith(obj, pchExtension)) {
+ continue;
+ }
*this->BuildFileStream << " " << lineContinue << "\n";
- *this->BuildFileStream << this->LocalGenerator->ConvertToQuotedOutputPath(
- i->c_str(), useWatcomQuote);
+ *this->BuildFileStream
+ << cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
+ obj, useWatcomQuote);
}
*this->BuildFileStream << "\n";
@@ -1237,14 +1291,13 @@ void cmMakefileTargetGenerator::WriteObjectsVariable(
/* clang-format on */
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
- for (std::vector<std::string>::const_iterator i =
- this->ExternalObjects.begin();
- i != this->ExternalObjects.end(); ++i) {
+ for (std::string const& obj : this->ExternalObjects) {
object =
- this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, *i);
+ this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir, obj);
*this->BuildFileStream << " " << lineContinue << "\n";
- *this->BuildFileStream << this->LocalGenerator->ConvertToQuotedOutputPath(
- i->c_str(), useWatcomQuote);
+ *this->BuildFileStream
+ << cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
+ obj, useWatcomQuote);
}
*this->BuildFileStream << "\n"
<< "\n";
@@ -1275,7 +1328,7 @@ public:
(this->CurrentString.length() + 1 + this->NextObject.length() >
this->LengthLimit)) {
this->Strings.push_back(this->CurrentString);
- this->CurrentString = "";
+ this->CurrentString.clear();
this->Space = "";
}
@@ -1291,11 +1344,10 @@ public:
private:
std::string MaybeConvertToRelativePath(std::string const& obj)
{
- if (!cmOutputConverter::ContainedInDirectory(
- this->StateDir.GetCurrentBinary(), obj, this->StateDir)) {
+ if (!this->StateDir.ContainsBoth(this->StateDir.GetCurrentBinary(), obj)) {
return obj;
}
- return cmOutputConverter::ForceToRelativePath(
+ return cmSystemTools::ForceToRelativePath(
this->StateDir.GetCurrentBinary(), obj);
}
@@ -1311,17 +1363,20 @@ private:
void cmMakefileTargetGenerator::WriteObjectsStrings(
std::vector<std::string>& objStrings, std::string::size_type limit)
{
+ const char* pchExtension =
+ this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION");
+
cmMakefileTargetGeneratorObjectStrings helper(
objStrings, this->LocalGenerator,
this->LocalGenerator->GetStateSnapshot().GetDirectory(), limit);
- for (std::vector<std::string>::const_iterator i = this->Objects.begin();
- i != this->Objects.end(); ++i) {
- helper.Feed(*i);
+ for (std::string const& obj : this->Objects) {
+ if (cmSystemTools::StringEndsWith(obj, pchExtension)) {
+ continue;
+ }
+ helper.Feed(obj);
}
- for (std::vector<std::string>::const_iterator i =
- this->ExternalObjects.begin();
- i != this->ExternalObjects.end(); ++i) {
- helper.Feed(*i);
+ for (std::string const& obj : this->ExternalObjects) {
+ helper.Feed(obj);
}
helper.Done();
}
@@ -1332,8 +1387,8 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(
// Compute the name of the driver target.
std::string dir =
this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget);
- std::string buildTargetRuleName = dir;
- buildTargetRuleName += relink ? "/preinstall" : "/build";
+ std::string buildTargetRuleName =
+ cmStrCat(dir, relink ? "/preinstall" : "/build");
buildTargetRuleName = this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetBinaryDirectory(), buildTargetRuleName);
@@ -1341,7 +1396,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(
std::vector<std::string> depends;
depends.push_back(main_output);
- const char* comment = CM_NULLPTR;
+ const char* comment = nullptr;
if (relink) {
// Setup the comment for the preinstall driver.
comment = "Rule to relink during preinstall.";
@@ -1355,8 +1410,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(
}
// Make sure the extra files are built.
- depends.insert(depends.end(), this->ExtraFiles.begin(),
- this->ExtraFiles.end());
+ cmAppend(depends, this->ExtraFiles);
}
// Write the driver rule.
@@ -1375,11 +1429,10 @@ void cmMakefileTargetGenerator::AppendTargetDepends(
}
// Loop over all library dependencies.
- const char* cfg = this->LocalGenerator->GetConfigName().c_str();
+ const std::string& cfg = this->LocalGenerator->GetConfigName();
if (cmComputeLinkInformation* cli =
this->GeneratorTarget->GetLinkInformation(cfg)) {
- std::vector<std::string> const& libDeps = cli->GetDepends();
- depends.insert(depends.end(), libDeps.begin(), libDeps.end());
+ cmAppend(depends, cli->GetDepends());
}
}
@@ -1387,18 +1440,15 @@ void cmMakefileTargetGenerator::AppendObjectDepends(
std::vector<std::string>& depends)
{
// Add dependencies on the compiled object files.
- std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath();
- std::string objTarget;
- for (std::vector<std::string>::const_iterator obj = this->Objects.begin();
- obj != this->Objects.end(); ++obj) {
- objTarget = relPath;
- objTarget += *obj;
- depends.push_back(objTarget);
+ std::string const& relPath =
+ this->LocalGenerator->GetHomeRelativeOutputPath();
+ for (std::string const& obj : this->Objects) {
+ std::string objTarget = cmStrCat(relPath, obj);
+ depends.push_back(std::move(objTarget));
}
// Add dependencies on the external object files.
- depends.insert(depends.end(), this->ExternalObjects.begin(),
- this->ExternalObjects.end());
+ cmAppend(depends, this->ExternalObjects);
// Add a dependency on the rule file itself.
this->LocalGenerator->AppendRuleDepend(depends,
@@ -1406,7 +1456,7 @@ void cmMakefileTargetGenerator::AppendObjectDepends(
}
void cmMakefileTargetGenerator::AppendLinkDepends(
- std::vector<std::string>& depends)
+ std::vector<std::string>& depends, const std::string& linkLanguage)
{
this->AppendObjectDepends(depends);
@@ -1417,36 +1467,31 @@ void cmMakefileTargetGenerator::AppendLinkDepends(
if (cmGeneratorTarget::ModuleDefinitionInfo const* mdi =
this->GeneratorTarget->GetModuleDefinitionInfo(
this->GetConfigName())) {
- for (std::vector<cmSourceFile const*>::const_iterator i =
- mdi->Sources.begin();
- i != mdi->Sources.end(); ++i) {
- depends.push_back((*i)->GetFullPath());
+ for (cmSourceFile const* src : mdi->Sources) {
+ depends.push_back(src->GetFullPath());
}
}
// Add a dependency on user-specified manifest files, if any.
std::vector<cmSourceFile const*> manifest_srcs;
this->GeneratorTarget->GetManifests(manifest_srcs, this->ConfigName);
- for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
- mi != manifest_srcs.end(); ++mi) {
- depends.push_back((*mi)->GetFullPath());
+ for (cmSourceFile const* manifest_src : manifest_srcs) {
+ depends.push_back(manifest_src->GetFullPath());
}
// Add user-specified dependencies.
- if (const char* linkDepends =
- this->GeneratorTarget->GetProperty("LINK_DEPENDS")) {
- cmSystemTools::ExpandListArgument(linkDepends, depends);
- }
+ this->GeneratorTarget->GetLinkDepends(depends, this->ConfigName,
+ linkLanguage);
}
std::string cmMakefileTargetGenerator::GetLinkRule(
const std::string& linkRuleVar)
{
std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
- if (this->GeneratorTarget->HasImplibGNUtoMS()) {
- std::string ruleVar = "CMAKE_";
- ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
- ruleVar += "_GNUtoMS_RULE";
+ if (this->GeneratorTarget->HasImplibGNUtoMS(this->ConfigName)) {
+ std::string ruleVar = cmStrCat(
+ "CMAKE_", this->GeneratorTarget->GetLinkerLanguage(this->ConfigName),
+ "_GNUtoMS_RULE");
if (const char* rule = this->Makefile->GetDefinition(ruleVar)) {
linkRule += rule;
}
@@ -1467,29 +1512,28 @@ void cmMakefileTargetGenerator::CreateLinkScript(
std::vector<std::string>& makefile_depends)
{
// Create the link script file.
- std::string linkScriptName = this->TargetBuildDirectoryFull;
- linkScriptName += "/";
- linkScriptName += name;
- cmGeneratedFileStream linkScriptStream(linkScriptName.c_str());
+ std::string linkScriptName =
+ cmStrCat(this->TargetBuildDirectoryFull, '/', name);
+ cmGeneratedFileStream linkScriptStream(linkScriptName);
linkScriptStream.SetCopyIfDifferent(true);
- for (std::vector<std::string>::const_iterator cmd = link_commands.begin();
- cmd != link_commands.end(); ++cmd) {
+ for (std::string const& link_command : link_commands) {
// Do not write out empty commands or commands beginning in the
// shell no-op ":".
- if (!cmd->empty() && (*cmd)[0] != ':') {
- linkScriptStream << *cmd << "\n";
+ if (!link_command.empty() && link_command[0] != ':') {
+ linkScriptStream << link_command << "\n";
}
}
// Create the makefile command to invoke the link script.
- std::string link_command = "$(CMAKE_COMMAND) -E cmake_link_script ";
- link_command += this->LocalGenerator->ConvertToOutputFormat(
- this->LocalGenerator->MaybeConvertToRelativePath(
- this->LocalGenerator->GetCurrentBinaryDirectory(), linkScriptName),
- cmOutputConverter::SHELL);
- link_command += " --verbose=$(VERBOSE)";
- makefile_commands.push_back(link_command);
- makefile_depends.push_back(linkScriptName);
+ std::string link_command = cmStrCat(
+ "$(CMAKE_COMMAND) -E cmake_link_script ",
+ this->LocalGenerator->ConvertToOutputFormat(
+ this->LocalGenerator->MaybeConvertToRelativePath(
+ this->LocalGenerator->GetCurrentBinaryDirectory(), linkScriptName),
+ cmOutputConverter::SHELL),
+ " --verbose=$(VERBOSE)");
+ makefile_commands.push_back(std::move(link_command));
+ makefile_depends.push_back(std::move(linkScriptName));
}
bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects(
@@ -1500,7 +1544,7 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects(
"CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_OBJECTS";
if (const char* val = this->Makefile->GetDefinition(responseVar)) {
if (*val) {
- return cmSystemTools::IsOn(val);
+ return cmIsOn(val);
}
}
@@ -1512,14 +1556,11 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects(
// actual list will likely be much shorter than this. However, in the
// worst case all objects will remain as absolute paths.
size_t length = 0;
- for (std::vector<std::string>::const_iterator i = this->Objects.begin();
- i != this->Objects.end(); ++i) {
- length += i->size() + 3;
+ for (std::string const& obj : this->Objects) {
+ length += obj.size() + 3;
}
- for (std::vector<std::string>::const_iterator i =
- this->ExternalObjects.begin();
- i != this->ExternalObjects.end(); ++i) {
- length += i->size() + 3;
+ for (std::string const& ext_obj : this->ExternalObjects) {
+ length += ext_obj.size() + 3;
}
// We need to guarantee room for both objects and libraries, so
@@ -1542,7 +1583,7 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForLibraries(
"CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_LIBRARIES";
if (const char* val = this->Makefile->GetDefinition(responseVar)) {
if (*val) {
- return cmSystemTools::IsOn(val);
+ return cmIsOn(val);
}
}
@@ -1555,21 +1596,19 @@ std::string cmMakefileTargetGenerator::CreateResponseFile(
std::vector<std::string>& makefile_depends)
{
// Create the response file.
- std::string responseFileNameFull = this->TargetBuildDirectoryFull;
- responseFileNameFull += "/";
- responseFileNameFull += name;
- cmGeneratedFileStream responseStream(responseFileNameFull.c_str());
+ std::string responseFileNameFull =
+ cmStrCat(this->TargetBuildDirectoryFull, '/', name);
+ cmGeneratedFileStream responseStream(responseFileNameFull);
responseStream.SetCopyIfDifferent(true);
responseStream << options << "\n";
// Add a dependency so the target will rebuild when the set of
// objects changes.
- makefile_depends.push_back(responseFileNameFull);
+ makefile_depends.push_back(std::move(responseFileNameFull));
// Construct the name to be used on the command line.
- std::string responseFileName = this->TargetBuildDirectory;
- responseFileName += "/";
- responseFileName += name;
+ std::string responseFileName =
+ cmStrCat(this->TargetBuildDirectory, '/', name);
return responseFileName;
}
@@ -1590,9 +1629,8 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
{
std::string frameworkPath;
std::string linkPath;
- std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
cmComputeLinkInformation* pcli =
- this->GeneratorTarget->GetLinkInformation(config);
+ this->GeneratorTarget->GetLinkInformation(this->ConfigName);
this->LocalGenerator->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
frameworkPath, linkPath);
linkLibs = frameworkPath + linkPath + linkLibs;
@@ -1600,10 +1638,9 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
if (useResponseFile &&
linkLibs.find_first_not_of(' ') != std::string::npos) {
// Lookup the response file reference flag.
- std::string responseFlagVar = "CMAKE_";
- responseFlagVar +=
- this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
- responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
+ std::string responseFlagVar = cmStrCat(
+ "CMAKE_", this->GeneratorTarget->GetLinkerLanguage(this->ConfigName),
+ "_RESPONSE_FILE_LINK_FLAG");
const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar);
if (!responseFlag) {
responseFlag = "@";
@@ -1614,9 +1651,9 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
this->CreateResponseFile("linklibs.rsp", linkLibs, makefile_depends);
// Reference the response file.
- linkLibs = responseFlag;
- linkLibs += this->LocalGenerator->ConvertToOutputFormat(
- link_rsp, cmOutputConverter::SHELL);
+ linkLibs = cmStrCat(responseFlag,
+ this->LocalGenerator->ConvertToOutputFormat(
+ link_rsp, cmOutputConverter::SHELL));
}
}
@@ -1638,10 +1675,9 @@ void cmMakefileTargetGenerator::CreateObjectLists(
this->WriteObjectsStrings(object_strings, responseFileLimit);
// Lookup the response file reference flag.
- std::string responseFlagVar = "CMAKE_";
- responseFlagVar +=
- this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
- responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
+ std::string responseFlagVar = cmStrCat(
+ "CMAKE_", this->GeneratorTarget->GetLinkerLanguage(this->ConfigName),
+ "_RESPONSE_FILE_LINK_FLAG");
const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar);
if (!responseFlag) {
responseFlag = "@";
@@ -1674,39 +1710,39 @@ void cmMakefileTargetGenerator::CreateObjectLists(
buildObjs = objStrings[0];
}
} else {
- buildObjs = "$(";
- buildObjs += variableName;
- buildObjs += ") $(";
- buildObjs += variableNameExternal;
- buildObjs += ")";
+ buildObjs =
+ cmStrCat("$(", variableName, ") $(", variableNameExternal, ')');
}
}
void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
const std::string& lang)
{
- std::string responseVar = "CMAKE_";
- responseVar += lang;
- responseVar += "_USE_RESPONSE_FILE_FOR_INCLUDES";
+ std::string responseVar =
+ cmStrCat("CMAKE_", lang, "_USE_RESPONSE_FILE_FOR_INCLUDES");
bool useResponseFile = this->Makefile->IsOn(responseVar);
std::vector<std::string> includes;
- const std::string& config =
- this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
- lang, config);
+ lang, this->ConfigName);
std::string includeFlags = this->LocalGenerator->GetIncludeFlags(
- includes, this->GeneratorTarget, lang, false, useResponseFile, config);
+ includes, this->GeneratorTarget, lang, false, useResponseFile,
+ this->ConfigName);
if (includeFlags.empty()) {
return;
}
if (useResponseFile) {
- std::string name = "includes_";
- name += lang;
- name += ".rsp";
- std::string arg = "@" +
+ std::string const responseFlagVar =
+ "CMAKE_" + lang + "_RESPONSE_FILE_FLAG";
+ std::string responseFlag =
+ this->Makefile->GetSafeDefinition(responseFlagVar);
+ if (responseFlag.empty()) {
+ responseFlag = "@";
+ }
+ std::string name = cmStrCat("includes_", lang, ".rsp");
+ std::string arg = std::move(responseFlag) +
this->CreateResponseFile(name.c_str(), includeFlags,
this->FlagFileDepends[lang]);
this->LocalGenerator->AppendFlags(flags, arg);
@@ -1724,40 +1760,41 @@ void cmMakefileTargetGenerator::GenDefFile(
return;
}
std::string cmd = cmSystemTools::GetCMakeCommand();
- cmd =
- this->LocalGenerator->ConvertToOutputFormat(cmd, cmOutputConverter::SHELL);
- cmd += " -E __create_def ";
- cmd += this->LocalGenerator->ConvertToOutputFormat(
- this->LocalGenerator->MaybeConvertToRelativePath(
- this->LocalGenerator->GetCurrentBinaryDirectory(), mdi->DefFile),
- cmOutputConverter::SHELL);
- cmd += " ";
+ cmd = cmStrCat(
+ this->LocalGenerator->ConvertToOutputFormat(cmd, cmOutputConverter::SHELL),
+ " -E __create_def ",
+ this->LocalGenerator->ConvertToOutputFormat(
+ this->LocalGenerator->MaybeConvertToRelativePath(
+ this->LocalGenerator->GetCurrentBinaryDirectory(), mdi->DefFile),
+ cmOutputConverter::SHELL),
+ ' ');
std::string objlist_file = mdi->DefFile + ".objs";
cmd += this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->MaybeConvertToRelativePath(
this->LocalGenerator->GetCurrentBinaryDirectory(), objlist_file),
cmOutputConverter::SHELL);
+ const char* nm_executable = this->Makefile->GetDefinition("CMAKE_NM");
+ if (nm_executable && *nm_executable) {
+ cmd += " --nm=";
+ cmd += this->LocalCommonGenerator->ConvertToOutputFormat(
+ nm_executable, cmOutputConverter::SHELL);
+ }
real_link_commands.insert(real_link_commands.begin(), cmd);
// create a list of obj files for the -E __create_def to read
- cmGeneratedFileStream fout(objlist_file.c_str());
+ cmGeneratedFileStream fout(objlist_file);
if (mdi->WindowsExportAllSymbols) {
- for (std::vector<std::string>::const_iterator i = this->Objects.begin();
- i != this->Objects.end(); ++i) {
- if (cmHasLiteralSuffix(*i, ".obj")) {
- fout << *i << "\n";
+ for (std::string const& obj : this->Objects) {
+ if (cmHasLiteralSuffix(obj, ".obj")) {
+ fout << obj << "\n";
}
}
- for (std::vector<std::string>::const_iterator i =
- this->ExternalObjects.begin();
- i != this->ExternalObjects.end(); ++i) {
- fout << *i << "\n";
+ for (std::string const& obj : this->ExternalObjects) {
+ fout << obj << "\n";
}
}
- for (std::vector<cmSourceFile const*>::const_iterator i =
- mdi->Sources.begin();
- i != mdi->Sources.end(); ++i) {
- fout << (*i)->GetFullPath() << "\n";
+ for (cmSourceFile const* src : mdi->Sources) {
+ fout << src->GetFullPath() << "\n";
}
}
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 92c9f60b0..7b9c7a5ff 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -3,21 +3,22 @@
#ifndef cmMakefileTargetGenerator_h
#define cmMakefileTargetGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <vector>
#include "cmCommonTargetGenerator.h"
+#include "cmGeneratorTarget.h"
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmOSXBundleGenerator.h"
class cmCustomCommandGenerator;
class cmGeneratedFileStream;
-class cmGeneratorTarget;
class cmGlobalUnixMakefileGenerator3;
class cmLinkLineComputer;
class cmOutputConverter;
@@ -33,7 +34,7 @@ class cmMakefileTargetGenerator : public cmCommonTargetGenerator
public:
// constructor to set the ivars
cmMakefileTargetGenerator(cmGeneratorTarget* target);
- ~cmMakefileTargetGenerator() CM_OVERRIDE;
+ ~cmMakefileTargetGenerator() override;
// construct using this factory call
static cmMakefileTargetGenerator* New(cmGeneratorTarget* tgt);
@@ -52,6 +53,8 @@ public:
cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget; }
protected:
+ void GetTargetLinkFlags(std::string& flags, const std::string& linkLanguage);
+
// create the file and directory etc
void CreateRuleFile();
@@ -63,16 +66,13 @@ protected:
void WriteCommonCodeRules();
void WriteTargetLanguageFlags();
- // write the provide require rules for this target
- void WriteTargetRequiresRules();
-
// write the clean rules for this target
void WriteTargetCleanRules();
// write the depend rules for this target
void WriteTargetDependRules();
- // write rules for Mac OS X Application Bundle content.
+ // write rules for macOS Application Bundle content.
struct MacOSXContentGeneratorType
: cmOSXBundleGenerator::MacOSXContentGeneratorType
{
@@ -81,8 +81,7 @@ protected:
{
}
- void operator()(cmSourceFile const& source,
- const char* pkgloc) CM_OVERRIDE;
+ void operator()(cmSourceFile const& source, const char* pkgloc) override;
private:
cmMakefileTargetGenerator* Generator;
@@ -92,11 +91,6 @@ protected:
// write the rules for an object
void WriteObjectRuleFiles(cmSourceFile const& source);
- // write the build rule for an object
- void WriteObjectBuildFile(std::string& obj, const std::string& lang,
- cmSourceFile const& source,
- std::vector<std::string>& depends);
-
// write the depend.make file for an object
void WriteObjectDependRules(cmSourceFile const& source,
std::vector<std::string>& depends);
@@ -130,7 +124,8 @@ protected:
void AppendObjectDepends(std::vector<std::string>& depends);
// Append link rule dependencies (objects, etc.).
- void AppendLinkDepends(std::vector<std::string>& depends);
+ void AppendLinkDepends(std::vector<std::string>& depends,
+ const std::string& linkLanguage);
// Lookup the link rule for this target.
std::string GetLinkRule(const std::string& linkRuleVar);
@@ -168,8 +163,7 @@ protected:
/** Add commands for generate def files */
void GenDefFile(std::vector<std::string>& real_link_commands);
- void AddIncludeFlags(std::string& flags,
- const std::string& lang) CM_OVERRIDE;
+ void AddIncludeFlags(std::string& flags, const std::string& lang) override;
virtual void CloseFileStreams();
cmLocalUnixMakefileGenerator3* LocalGenerator;
@@ -212,7 +206,7 @@ protected:
cmGeneratedFileStream* InfoFileStream;
// files to clean
- std::vector<std::string> CleanFiles;
+ std::set<std::string> CleanFiles;
// objects used by this target
std::vector<std::string> Objects;
@@ -224,7 +218,7 @@ protected:
// Set of extra output files to be driven by the build.
std::set<std::string> ExtraFiles;
- typedef std::map<std::string, std::string> MultipleOutputPairsType;
+ using MultipleOutputPairsType = std::map<std::string, std::string>;
MultipleOutputPairsType MultipleOutputPairs;
bool WriteMakeRule(std::ostream& os, const char* comment,
const std::vector<std::string>& outputs,
@@ -233,15 +227,11 @@ protected:
bool in_help = false);
// Target name info.
- std::string TargetNameOut;
- std::string TargetNameSO;
- std::string TargetNameReal;
- std::string TargetNameImport;
- std::string TargetNamePDB;
+ cmGeneratorTarget::Names TargetNames;
- // Mac OS X content info.
+ // macOS content info.
std::set<std::string> MacContentFolders;
- cmOSXBundleGenerator* OSXBundleGenerator;
+ std::unique_ptr<cmOSXBundleGenerator> OSXBundleGenerator;
MacOSXContentGeneratorType* MacOSXContentGenerator;
};
diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx
index a7c5d27f2..1625e4fdb 100644
--- a/Source/cmMakefileUtilityTargetGenerator.cxx
+++ b/Source/cmMakefileUtilityTargetGenerator.cxx
@@ -4,8 +4,11 @@
#include <ostream>
#include <string>
+#include <utility>
#include <vector>
+#include <cm/memory>
+
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalUnixMakefileGenerator3.h"
@@ -20,14 +23,12 @@ cmMakefileUtilityTargetGenerator::cmMakefileUtilityTargetGenerator(
{
this->CustomCommandDriver = OnUtility;
this->OSXBundleGenerator =
- new cmOSXBundleGenerator(target, this->ConfigName);
+ cm::make_unique<cmOSXBundleGenerator>(target, this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
}
-cmMakefileUtilityTargetGenerator::~cmMakefileUtilityTargetGenerator()
-{
- delete this->OSXBundleGenerator;
-}
+cmMakefileUtilityTargetGenerator::~cmMakefileUtilityTargetGenerator() =
+ default;
void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
{
@@ -45,11 +46,9 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
<< "# Include the progress variables for this target.\n"
<< this->GlobalGenerator->IncludeDirective << " " << root
<< cmSystemTools::ConvertToOutputPath(
- this->LocalGenerator
- ->MaybeConvertToRelativePath(
- this->LocalGenerator->GetBinaryDirectory(),
- this->ProgressFileNameFull)
- .c_str())
+ this->LocalGenerator->MaybeConvertToRelativePath(
+ this->LocalGenerator->GetBinaryDirectory(),
+ this->ProgressFileNameFull))
<< "\n\n";
}
@@ -90,12 +89,12 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
if (depends.empty() && commands.empty()) {
std::string hack = this->GlobalGenerator->GetEmptyRuleHackDepends();
if (!hack.empty()) {
- depends.push_back(hack);
+ depends.push_back(std::move(hack));
}
}
// Write the rule.
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, CM_NULLPTR,
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr,
this->GeneratorTarget->GetName(),
depends, commands, true);
diff --git a/Source/cmMakefileUtilityTargetGenerator.h b/Source/cmMakefileUtilityTargetGenerator.h
index 8df5dd46f..be243a7f5 100644
--- a/Source/cmMakefileUtilityTargetGenerator.h
+++ b/Source/cmMakefileUtilityTargetGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmMakefileUtilityTargetGenerator_h
#define cmMakefileUtilityTargetGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include "cmMakefileTargetGenerator.h"
@@ -13,11 +13,11 @@ class cmMakefileUtilityTargetGenerator : public cmMakefileTargetGenerator
{
public:
cmMakefileUtilityTargetGenerator(cmGeneratorTarget* target);
- ~cmMakefileUtilityTargetGenerator() CM_OVERRIDE;
+ ~cmMakefileUtilityTargetGenerator() override;
/* the main entry point for this class. Writes the Makefiles associated
with this target */
- void WriteRuleFiles() CM_OVERRIDE;
+ void WriteRuleFiles() override;
protected:
};
diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx
index 14fd96f08..ca46e14c2 100644
--- a/Source/cmMarkAsAdvancedCommand.cxx
+++ b/Source/cmMarkAsAdvancedCommand.cxx
@@ -2,20 +2,19 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMarkAsAdvancedCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmState.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmake.h"
-class cmExecutionStatus;
-
// cmMarkAsAdvancedCommand
-bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmMarkAsAdvancedCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
@@ -31,10 +30,10 @@ bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& args,
}
for (; i < args.size(); ++i) {
std::string const& variable = args[i];
- cmState* state = this->Makefile->GetState();
+ cmState* state = status.GetMakefile().GetState();
if (!state->GetCacheEntryValue(variable)) {
- this->Makefile->GetCMakeInstance()->AddCacheEntry(
- variable, CM_NULLPTR, CM_NULLPTR, cmStateEnums::UNINITIALIZED);
+ status.GetMakefile().GetCMakeInstance()->AddCacheEntry(
+ variable, nullptr, nullptr, cmStateEnums::UNINITIALIZED);
overwrite = true;
}
if (!state->GetCacheEntryValue(variable)) {
diff --git a/Source/cmMarkAsAdvancedCommand.h b/Source/cmMarkAsAdvancedCommand.h
index a7791a932..de7bf08b4 100644
--- a/Source/cmMarkAsAdvancedCommand.h
+++ b/Source/cmMarkAsAdvancedCommand.h
@@ -3,34 +3,19 @@
#ifndef cmMarkAsAdvancedCommand_h
#define cmMarkAsAdvancedCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmMarkAsAdvancedCommand
+/**
* \brief mark_as_advanced command
*
* cmMarkAsAdvancedCommand implements the mark_as_advanced CMake command
*/
-class cmMarkAsAdvancedCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmMarkAsAdvancedCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmMarkAsAdvancedCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmMathCommand.cxx b/Source/cmMathCommand.cxx
index c1cd1b6c2..f11b906d4 100644
--- a/Source/cmMathCommand.cxx
+++ b/Source/cmMathCommand.cxx
@@ -2,50 +2,119 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMathCommand.h"
-#include <stdio.h>
+#include <cstdio>
+#include "cm_kwiml.h"
+
+#include "cmExecutionStatus.h"
#include "cmExprParserHelper.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
-class cmExecutionStatus;
+namespace {
+bool HandleExprCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+}
-bool cmMathCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmMathCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("must be called with at least one argument.");
+ status.SetError("must be called with at least one argument.");
return false;
}
const std::string& subCommand = args[0];
if (subCommand == "EXPR") {
- return this->HandleExprCommand(args);
+ return HandleExprCommand(args, status);
}
std::string e = "does not recognize sub-command " + subCommand;
- this->SetError(e);
+ status.SetError(e);
return false;
}
-bool cmMathCommand::HandleExprCommand(std::vector<std::string> const& args)
+namespace {
+bool HandleExprCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- if (args.size() != 3) {
- this->SetError("EXPR called with incorrect arguments.");
+ if ((args.size() != 3) && (args.size() != 5)) {
+ status.SetError("EXPR called with incorrect arguments.");
return false;
}
+ enum class NumericFormat
+ {
+ UNINITIALIZED,
+ DECIMAL,
+ HEXADECIMAL,
+ };
+
const std::string& outputVariable = args[1];
const std::string& expression = args[2];
+ size_t argumentIndex = 3;
+ NumericFormat outputFormat = NumericFormat::UNINITIALIZED;
+
+ status.GetMakefile().AddDefinition(outputVariable, "ERROR");
+
+ if (argumentIndex < args.size()) {
+ const std::string messageHint = "sub-command EXPR ";
+ const std::string option = args[argumentIndex++];
+ if (option == "OUTPUT_FORMAT") {
+ if (argumentIndex < args.size()) {
+ const std::string argument = args[argumentIndex++];
+ if (argument == "DECIMAL") {
+ outputFormat = NumericFormat::DECIMAL;
+ } else if (argument == "HEXADECIMAL") {
+ outputFormat = NumericFormat::HEXADECIMAL;
+ } else {
+ std::string error = messageHint + "value \"" + argument +
+ "\" for option \"" + option + "\" is invalid.";
+ status.SetError(error);
+ return false;
+ }
+ } else {
+ std::string error =
+ messageHint + "missing argument for option \"" + option + "\".";
+ status.SetError(error);
+ return false;
+ }
+ } else {
+ std::string error =
+ messageHint + "option \"" + option + "\" is unknown.";
+ status.SetError(error);
+ return false;
+ }
+ }
+
+ if (outputFormat == NumericFormat::UNINITIALIZED) {
+ outputFormat = NumericFormat::DECIMAL;
+ }
cmExprParserHelper helper;
if (!helper.ParseString(expression.c_str(), 0)) {
- std::string e = "cannot parse the expression: \"" + expression + "\": ";
- e += helper.GetError();
- this->SetError(e);
+ status.SetError(helper.GetError());
return false;
}
char buffer[1024];
- sprintf(buffer, "%d", helper.GetResult());
+ const char* fmt;
+ switch (outputFormat) {
+ case NumericFormat::HEXADECIMAL:
+ fmt = "0x%" KWIML_INT_PRIx64;
+ break;
+ case NumericFormat::DECIMAL:
+ CM_FALLTHROUGH;
+ default:
+ fmt = "%" KWIML_INT_PRId64;
+ break;
+ }
+ sprintf(buffer, fmt, helper.GetResult());
- this->Makefile->AddDefinition(outputVariable, buffer);
+ std::string const& w = helper.GetWarning();
+ if (!w.empty()) {
+ status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, w);
+ }
+
+ status.GetMakefile().AddDefinition(outputVariable, buffer);
return true;
}
+}
diff --git a/Source/cmMathCommand.h b/Source/cmMathCommand.h
index 67dbdda37..ac1957c24 100644
--- a/Source/cmMathCommand.h
+++ b/Source/cmMathCommand.h
@@ -3,33 +3,15 @@
#ifndef cmMathCommand_h
#define cmMathCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
/// Mathematical expressions: math(EXPR ...) command.
-class cmMathCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmMathCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-protected:
- bool HandleExprCommand(std::vector<std::string> const& args);
-};
+bool cmMathCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index 43fb5f54c..96a6386bf 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -2,77 +2,143 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMessageCommand.h"
-#include "cmAlgorithms.h"
+#include <cassert>
+
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmMessenger.h"
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
-class cmExecutionStatus;
-
// cmLibraryCommand
-bool cmMessageCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmMessageCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- std::vector<std::string>::const_iterator i = args.begin();
+ auto i = args.cbegin();
- cmake::MessageType type = cmake::MESSAGE;
- bool status = false;
- bool fatal = false;
+ auto type = MessageType::MESSAGE;
+ auto fatal = false;
+ auto level = cmake::LogLevel::LOG_UNDEFINED;
if (*i == "SEND_ERROR") {
- type = cmake::FATAL_ERROR;
+ type = MessageType::FATAL_ERROR;
+ level = cmake::LogLevel::LOG_ERROR;
++i;
} else if (*i == "FATAL_ERROR") {
fatal = true;
- type = cmake::FATAL_ERROR;
+ type = MessageType::FATAL_ERROR;
+ level = cmake::LogLevel::LOG_ERROR;
++i;
} else if (*i == "WARNING") {
- type = cmake::WARNING;
+ type = MessageType::WARNING;
+ level = cmake::LogLevel::LOG_WARNING;
++i;
} else if (*i == "AUTHOR_WARNING") {
- if (this->Makefile->IsSet("CMAKE_SUPPRESS_DEVELOPER_ERRORS") &&
- !this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_ERRORS")) {
+ if (status.GetMakefile().IsSet("CMAKE_SUPPRESS_DEVELOPER_ERRORS") &&
+ !status.GetMakefile().IsOn("CMAKE_SUPPRESS_DEVELOPER_ERRORS")) {
fatal = true;
- type = cmake::AUTHOR_ERROR;
- } else if (!this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) {
- type = cmake::AUTHOR_WARNING;
+ type = MessageType::AUTHOR_ERROR;
+ level = cmake::LogLevel::LOG_ERROR;
+ } else if (!status.GetMakefile().IsOn(
+ "CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) {
+ type = MessageType::AUTHOR_WARNING;
+ level = cmake::LogLevel::LOG_WARNING;
} else {
return true;
}
++i;
} else if (*i == "STATUS") {
- status = true;
+ level = cmake::LogLevel::LOG_STATUS;
+ ++i;
+ } else if (*i == "VERBOSE") {
+ level = cmake::LogLevel::LOG_VERBOSE;
+ ++i;
+ } else if (*i == "DEBUG") {
+ level = cmake::LogLevel::LOG_DEBUG;
+ ++i;
+ } else if (*i == "TRACE") {
+ level = cmake::LogLevel::LOG_TRACE;
++i;
} else if (*i == "DEPRECATION") {
- if (this->Makefile->IsOn("CMAKE_ERROR_DEPRECATED")) {
+ if (status.GetMakefile().IsOn("CMAKE_ERROR_DEPRECATED")) {
fatal = true;
- type = cmake::DEPRECATION_ERROR;
- } else if ((!this->Makefile->IsSet("CMAKE_WARN_DEPRECATED") ||
- this->Makefile->IsOn("CMAKE_WARN_DEPRECATED"))) {
- type = cmake::DEPRECATION_WARNING;
+ type = MessageType::DEPRECATION_ERROR;
+ level = cmake::LogLevel::LOG_ERROR;
+ } else if (!status.GetMakefile().IsSet("CMAKE_WARN_DEPRECATED") ||
+ status.GetMakefile().IsOn("CMAKE_WARN_DEPRECATED")) {
+ type = MessageType::DEPRECATION_WARNING;
+ level = cmake::LogLevel::LOG_WARNING;
} else {
return true;
}
++i;
+ } else if (*i == "NOTICE") {
+ // `NOTICE` message type is going to be output to stderr
+ level = cmake::LogLevel::LOG_NOTICE;
+ ++i;
+ } else {
+ // Messages w/o any type are `NOTICE`s
+ level = cmake::LogLevel::LOG_NOTICE;
}
+ assert("Message log level expected to be set" &&
+ level != cmake::LogLevel::LOG_UNDEFINED);
- std::string message = cmJoin(cmMakeRange(i, args.end()), std::string());
+ auto desiredLevel = status.GetMakefile().GetCMakeInstance()->GetLogLevel();
+ assert("Expected a valid log level here" &&
+ desiredLevel != cmake::LogLevel::LOG_UNDEFINED);
- if (type != cmake::MESSAGE) {
- // we've overriden the message type, above, so display it directly
- cmMessenger* m = this->Makefile->GetMessenger();
- m->DisplayMessage(type, message, this->Makefile->GetBacktrace());
- } else {
- if (status) {
- this->Makefile->DisplayStatus(message.c_str(), -1);
- } else {
- cmSystemTools::Message(message.c_str());
- }
+ if (desiredLevel < level) {
+ // Suppress the message
+ return true;
}
+
+ auto message = cmJoin(cmMakeRange(i, args.cend()), "");
+
+ if (cmake::LogLevel::LOG_NOTICE <= level) {
+ // Check if any indentation has requested:
+ // `CMAKE_MESSAGE_INDENT` is a list of "padding" pieces
+ // to be joined and prepended to the message lines.
+ auto indent = cmJoin(cmExpandedList(status.GetMakefile().GetSafeDefinition(
+ "CMAKE_MESSAGE_INDENT")),
+ "");
+ // Make every line of the `message` indented
+ // NOTE Can't reuse `cmDocumentationFormatter::PrintPreformatted`
+ // here cuz it appends `\n` to the EOM ;-(
+ cmSystemTools::ReplaceString(message, "\n", "\n" + indent);
+ message = indent + message;
+ }
+
+ switch (level) {
+ case cmake::LogLevel::LOG_ERROR:
+ case cmake::LogLevel::LOG_WARNING:
+ // we've overridden the message type, above, so display it directly
+ status.GetMakefile().GetMessenger()->DisplayMessage(
+ type, message, status.GetMakefile().GetBacktrace());
+ break;
+
+ case cmake::LogLevel::LOG_NOTICE:
+ cmSystemTools::Message(message);
+ break;
+
+ case cmake::LogLevel::LOG_STATUS:
+ case cmake::LogLevel::LOG_VERBOSE:
+ case cmake::LogLevel::LOG_DEBUG:
+ case cmake::LogLevel::LOG_TRACE:
+ status.GetMakefile().DisplayStatus(message, -1);
+ break;
+
+ default:
+ assert("Unexpected log level! Review the `cmMessageCommand.cxx`." &&
+ false);
+ break;
+ }
+
if (fatal) {
cmSystemTools::SetFatalErrorOccured();
}
diff --git a/Source/cmMessageCommand.h b/Source/cmMessageCommand.h
index 96939e514..7d544c408 100644
--- a/Source/cmMessageCommand.h
+++ b/Source/cmMessageCommand.h
@@ -3,33 +3,18 @@
#ifndef cmMessageCommand_h
#define cmMessageCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmMessageCommand
+/**
* \brief Displays a message to the user
*
*/
-class cmMessageCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmMessageCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmMessageCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmMessageType.h b/Source/cmMessageType.h
new file mode 100644
index 000000000..b57b86bee
--- /dev/null
+++ b/Source/cmMessageType.h
@@ -0,0 +1,21 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmMessageType_h
+#define cmMessageType_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+enum class MessageType
+{
+ AUTHOR_WARNING,
+ AUTHOR_ERROR,
+ FATAL_ERROR,
+ INTERNAL_ERROR,
+ MESSAGE,
+ WARNING,
+ LOG,
+ DEPRECATION_ERROR,
+ DEPRECATION_WARNING
+};
+
+#endif
diff --git a/Source/cmMessenger.cxx b/Source/cmMessenger.cxx
index 3ae5bc5c2..af83478a6 100644
--- a/Source/cmMessenger.cxx
+++ b/Source/cmMessenger.cxx
@@ -2,58 +2,57 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMessenger.h"
-#include "cmAlgorithms.h"
#include "cmDocumentationFormatter.h"
-#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmsys/SystemInformation.hxx"
+#if !defined(CMAKE_BOOTSTRAP)
+# include "cmsys/SystemInformation.hxx"
#endif
#include <sstream>
-cmake::MessageType cmMessenger::ConvertMessageType(cmake::MessageType t) const
+MessageType cmMessenger::ConvertMessageType(MessageType t) const
{
bool warningsAsErrors;
- if (t == cmake::AUTHOR_WARNING || t == cmake::AUTHOR_ERROR) {
+ if (t == MessageType::AUTHOR_WARNING || t == MessageType::AUTHOR_ERROR) {
warningsAsErrors = this->GetDevWarningsAsErrors();
- if (warningsAsErrors && t == cmake::AUTHOR_WARNING) {
- t = cmake::AUTHOR_ERROR;
- } else if (!warningsAsErrors && t == cmake::AUTHOR_ERROR) {
- t = cmake::AUTHOR_WARNING;
+ if (warningsAsErrors && t == MessageType::AUTHOR_WARNING) {
+ t = MessageType::AUTHOR_ERROR;
+ } else if (!warningsAsErrors && t == MessageType::AUTHOR_ERROR) {
+ t = MessageType::AUTHOR_WARNING;
}
- } else if (t == cmake::DEPRECATION_WARNING ||
- t == cmake::DEPRECATION_ERROR) {
+ } else if (t == MessageType::DEPRECATION_WARNING ||
+ t == MessageType::DEPRECATION_ERROR) {
warningsAsErrors = this->GetDeprecatedWarningsAsErrors();
- if (warningsAsErrors && t == cmake::DEPRECATION_WARNING) {
- t = cmake::DEPRECATION_ERROR;
- } else if (!warningsAsErrors && t == cmake::DEPRECATION_ERROR) {
- t = cmake::DEPRECATION_WARNING;
+ if (warningsAsErrors && t == MessageType::DEPRECATION_WARNING) {
+ t = MessageType::DEPRECATION_ERROR;
+ } else if (!warningsAsErrors && t == MessageType::DEPRECATION_ERROR) {
+ t = MessageType::DEPRECATION_WARNING;
}
}
return t;
}
-bool cmMessenger::IsMessageTypeVisible(cmake::MessageType t) const
+bool cmMessenger::IsMessageTypeVisible(MessageType t) const
{
bool isVisible = true;
- if (t == cmake::DEPRECATION_ERROR) {
+ if (t == MessageType::DEPRECATION_ERROR) {
if (!this->GetDeprecatedWarningsAsErrors()) {
isVisible = false;
}
- } else if (t == cmake::DEPRECATION_WARNING) {
+ } else if (t == MessageType::DEPRECATION_WARNING) {
if (this->GetSuppressDeprecatedWarnings()) {
isVisible = false;
}
- } else if (t == cmake::AUTHOR_ERROR) {
+ } else if (t == MessageType::AUTHOR_ERROR) {
if (!this->GetDevWarningsAsErrors()) {
isVisible = false;
}
- } else if (t == cmake::AUTHOR_WARNING) {
+ } else if (t == MessageType::AUTHOR_WARNING) {
if (this->GetSuppressDevWarnings()) {
isVisible = false;
}
@@ -62,22 +61,22 @@ bool cmMessenger::IsMessageTypeVisible(cmake::MessageType t) const
return isVisible;
}
-static bool printMessagePreamble(cmake::MessageType t, std::ostream& msg)
+static bool printMessagePreamble(MessageType t, std::ostream& msg)
{
// Construct the message header.
- if (t == cmake::FATAL_ERROR) {
+ if (t == MessageType::FATAL_ERROR) {
msg << "CMake Error";
- } else if (t == cmake::INTERNAL_ERROR) {
+ } else if (t == MessageType::INTERNAL_ERROR) {
msg << "CMake Internal Error (please report a bug)";
- } else if (t == cmake::LOG) {
+ } else if (t == MessageType::LOG) {
msg << "CMake Debug Log";
- } else if (t == cmake::DEPRECATION_ERROR) {
+ } else if (t == MessageType::DEPRECATION_ERROR) {
msg << "CMake Deprecation Error";
- } else if (t == cmake::DEPRECATION_WARNING) {
+ } else if (t == MessageType::DEPRECATION_WARNING) {
msg << "CMake Deprecation Warning";
- } else if (t == cmake::AUTHOR_WARNING) {
+ } else if (t == MessageType::AUTHOR_WARNING) {
msg << "CMake Warning (dev)";
- } else if (t == cmake::AUTHOR_ERROR) {
+ } else if (t == MessageType::AUTHOR_ERROR) {
msg << "CMake Error (dev)";
} else {
msg << "CMake Warning";
@@ -93,24 +92,23 @@ void printMessageText(std::ostream& msg, std::string const& text)
formatter.PrintFormatted(msg, text.c_str());
}
-void displayMessage(cmake::MessageType t, std::ostringstream& msg)
+void displayMessage(MessageType t, std::ostringstream& msg)
{
// Add a note about warning suppression.
- if (t == cmake::AUTHOR_WARNING) {
+ if (t == MessageType::AUTHOR_WARNING) {
msg << "This warning is for project developers. Use -Wno-dev to suppress "
"it.";
- } else if (t == cmake::AUTHOR_ERROR) {
+ } else if (t == MessageType::AUTHOR_ERROR) {
msg << "This error is for project developers. Use -Wno-error=dev to "
- "suppress "
- "it.";
+ "suppress it.";
}
// Add a terminating blank line.
msg << "\n";
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
// Add a C++ stack trace to internal errors.
- if (t == cmake::INTERNAL_ERROR) {
+ if (t == MessageType::INTERNAL_ERROR) {
std::string stack = cmsys::SystemInformation::GetProgramStack(0, 0);
if (!stack.empty()) {
if (cmHasLiteralPrefix(stack, "WARNING:")) {
@@ -122,27 +120,22 @@ void displayMessage(cmake::MessageType t, std::ostringstream& msg)
#endif
// Output the message.
- if (t == cmake::FATAL_ERROR || t == cmake::INTERNAL_ERROR ||
- t == cmake::DEPRECATION_ERROR || t == cmake::AUTHOR_ERROR) {
+ if (t == MessageType::FATAL_ERROR || t == MessageType::INTERNAL_ERROR ||
+ t == MessageType::DEPRECATION_ERROR || t == MessageType::AUTHOR_ERROR) {
cmSystemTools::SetErrorOccured();
- cmSystemTools::Message(msg.str().c_str(), "Error");
+ cmSystemTools::Message(msg.str(), "Error");
} else {
- cmSystemTools::Message(msg.str().c_str(), "Warning");
+ cmSystemTools::Message(msg.str(), "Warning");
}
}
-cmMessenger::cmMessenger(cmState* state)
- : State(state)
-{
-}
-
-void cmMessenger::IssueMessage(cmake::MessageType t, const std::string& text,
+void cmMessenger::IssueMessage(MessageType t, const std::string& text,
const cmListFileBacktrace& backtrace) const
{
bool force = false;
if (!force) {
// override the message type, if needed, for warnings and errors
- cmake::MessageType override = this->ConvertMessageType(t);
+ MessageType override = this->ConvertMessageType(t);
if (override != t) {
t = override;
force = true;
@@ -155,7 +148,7 @@ void cmMessenger::IssueMessage(cmake::MessageType t, const std::string& text,
this->DisplayMessage(t, text, backtrace);
}
-void cmMessenger::DisplayMessage(cmake::MessageType t, const std::string& text,
+void cmMessenger::DisplayMessage(MessageType t, const std::string& text,
const cmListFileBacktrace& backtrace) const
{
std::ostringstream msg;
@@ -173,31 +166,3 @@ void cmMessenger::DisplayMessage(cmake::MessageType t, const std::string& text,
displayMessage(t, msg);
}
-
-bool cmMessenger::GetSuppressDevWarnings() const
-{
- const char* cacheEntryValue =
- this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
- return cmSystemTools::IsOn(cacheEntryValue);
-}
-
-bool cmMessenger::GetSuppressDeprecatedWarnings() const
-{
- const char* cacheEntryValue =
- this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED");
- return cacheEntryValue && cmSystemTools::IsOff(cacheEntryValue);
-}
-
-bool cmMessenger::GetDevWarningsAsErrors() const
-{
- const char* cacheEntryValue =
- this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_ERRORS");
- return cacheEntryValue && cmSystemTools::IsOff(cacheEntryValue);
-}
-
-bool cmMessenger::GetDeprecatedWarningsAsErrors() const
-{
- const char* cacheEntryValue =
- this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED");
- return cmSystemTools::IsOn(cacheEntryValue);
-}
diff --git a/Source/cmMessenger.h b/Source/cmMessenger.h
index 4aafbd40b..8c097827e 100644
--- a/Source/cmMessenger.h
+++ b/Source/cmMessenger.h
@@ -5,35 +5,57 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmListFileCache.h"
-#include "cmake.h"
-
#include <string>
-class cmState;
+#include "cmListFileCache.h"
+#include "cmMessageType.h"
class cmMessenger
{
public:
- cmMessenger(cmState* state);
-
void IssueMessage(
- cmake::MessageType t, std::string const& text,
+ MessageType t, std::string const& text,
cmListFileBacktrace const& backtrace = cmListFileBacktrace()) const;
- void DisplayMessage(cmake::MessageType t, std::string const& text,
+ void DisplayMessage(MessageType t, std::string const& text,
cmListFileBacktrace const& backtrace) const;
- bool GetSuppressDevWarnings() const;
- bool GetSuppressDeprecatedWarnings() const;
- bool GetDevWarningsAsErrors() const;
- bool GetDeprecatedWarningsAsErrors() const;
+ void SetSuppressDevWarnings(bool suppress)
+ {
+ this->SuppressDevWarnings = suppress;
+ }
+ void SetSuppressDeprecatedWarnings(bool suppress)
+ {
+ this->SuppressDeprecatedWarnings = suppress;
+ }
+ void SetDevWarningsAsErrors(bool error)
+ {
+ this->DevWarningsAsErrors = error;
+ }
+ void SetDeprecatedWarningsAsErrors(bool error)
+ {
+ this->DeprecatedWarningsAsErrors = error;
+ }
+
+ bool GetSuppressDevWarnings() const { return this->SuppressDevWarnings; }
+ bool GetSuppressDeprecatedWarnings() const
+ {
+ return this->SuppressDeprecatedWarnings;
+ }
+ bool GetDevWarningsAsErrors() const { return this->DevWarningsAsErrors; }
+ bool GetDeprecatedWarningsAsErrors() const
+ {
+ return this->DeprecatedWarningsAsErrors;
+ }
private:
- bool IsMessageTypeVisible(cmake::MessageType t) const;
- cmake::MessageType ConvertMessageType(cmake::MessageType t) const;
+ bool IsMessageTypeVisible(MessageType t) const;
+ MessageType ConvertMessageType(MessageType t) const;
- cmState* State;
+ bool SuppressDevWarnings = false;
+ bool SuppressDeprecatedWarnings = false;
+ bool DevWarningsAsErrors = false;
+ bool DeprecatedWarningsAsErrors = false;
};
#endif
diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx
index 5500eba65..a121332b2 100644
--- a/Source/cmNewLineStyle.cxx
+++ b/Source/cmNewLineStyle.cxx
@@ -2,12 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmNewLineStyle.h"
-#include <stddef.h>
+#include <cstddef>
-cmNewLineStyle::cmNewLineStyle()
- : NewLineStyle(Invalid)
-{
-}
+cmNewLineStyle::cmNewLineStyle() = default;
bool cmNewLineStyle::IsValid() const
{
@@ -44,7 +41,7 @@ bool cmNewLineStyle::ReadFromArguments(const std::vector<std::string>& args,
return true;
}
-const std::string cmNewLineStyle::GetCharacters() const
+std::string cmNewLineStyle::GetCharacters() const
{
switch (NewLineStyle) {
case Invalid:
diff --git a/Source/cmNewLineStyle.h b/Source/cmNewLineStyle.h
index 397cd2c50..ab9002e4d 100644
--- a/Source/cmNewLineStyle.h
+++ b/Source/cmNewLineStyle.h
@@ -30,10 +30,10 @@ public:
bool ReadFromArguments(const std::vector<std::string>& args,
std::string& errorString);
- const std::string GetCharacters() const;
+ std::string GetCharacters() const;
private:
- Style NewLineStyle;
+ Style NewLineStyle = Invalid;
};
#endif
diff --git a/Source/cmNinjaLinkLineComputer.h b/Source/cmNinjaLinkLineComputer.h
index 13f05a838..b2b2e84e1 100644
--- a/Source/cmNinjaLinkLineComputer.h
+++ b/Source/cmNinjaLinkLineComputer.h
@@ -4,7 +4,7 @@
#ifndef cmNinjaLinkLineComputer_h
#define cmNinjaLinkLineComputer_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
@@ -16,15 +16,15 @@ class cmStateDirectory;
class cmNinjaLinkLineComputer : public cmLinkLineComputer
{
- CM_DISABLE_COPY(cmNinjaLinkLineComputer)
-
public:
cmNinjaLinkLineComputer(cmOutputConverter* outputConverter,
cmStateDirectory const& stateDir,
cmGlobalNinjaGenerator const* gg);
- std::string ConvertToLinkReference(std::string const& input) const
- CM_OVERRIDE;
+ cmNinjaLinkLineComputer(cmNinjaLinkLineComputer const&) = delete;
+ cmNinjaLinkLineComputer& operator=(cmNinjaLinkLineComputer const&) = delete;
+
+ std::string ConvertToLinkReference(std::string const& input) const override;
private:
cmGlobalNinjaGenerator const* GG;
diff --git a/Source/cmNinjaLinkLineDeviceComputer.cxx b/Source/cmNinjaLinkLineDeviceComputer.cxx
new file mode 100644
index 000000000..84c1b37d3
--- /dev/null
+++ b/Source/cmNinjaLinkLineDeviceComputer.cxx
@@ -0,0 +1,20 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmNinjaLinkLineDeviceComputer.h"
+
+#include "cmGlobalNinjaGenerator.h"
+
+cmNinjaLinkLineDeviceComputer::cmNinjaLinkLineDeviceComputer(
+ cmOutputConverter* outputConverter, cmStateDirectory const& stateDir,
+ cmGlobalNinjaGenerator const* gg)
+ : cmLinkLineDeviceComputer(outputConverter, stateDir)
+ , GG(gg)
+{
+}
+
+std::string cmNinjaLinkLineDeviceComputer::ConvertToLinkReference(
+ std::string const& lib) const
+{
+ return GG->ConvertToNinjaPath(lib);
+}
diff --git a/Source/cmNinjaLinkLineDeviceComputer.h b/Source/cmNinjaLinkLineDeviceComputer.h
new file mode 100644
index 000000000..84ced5b35
--- /dev/null
+++ b/Source/cmNinjaLinkLineDeviceComputer.h
@@ -0,0 +1,34 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmNinjaLinkLineDeviceComputer_h
+#define cmNinjaLinkLineDeviceComputer_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+
+#include "cmLinkLineDeviceComputer.h"
+
+class cmGlobalNinjaGenerator;
+class cmOutputConverter;
+class cmStateDirectory;
+
+class cmNinjaLinkLineDeviceComputer : public cmLinkLineDeviceComputer
+{
+public:
+ cmNinjaLinkLineDeviceComputer(cmOutputConverter* outputConverter,
+ cmStateDirectory const& stateDir,
+ cmGlobalNinjaGenerator const* gg);
+
+ cmNinjaLinkLineDeviceComputer(cmNinjaLinkLineDeviceComputer const&) = delete;
+ cmNinjaLinkLineDeviceComputer& operator=(
+ cmNinjaLinkLineDeviceComputer const&) = delete;
+
+ std::string ConvertToLinkReference(std::string const& input) const override;
+
+private:
+ cmGlobalNinjaGenerator const* GG;
+};
+
+#endif
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 14a4ef824..beedef4c2 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -3,23 +3,29 @@
#include "cmNinjaNormalTargetGenerator.h"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
#include <iterator>
#include <map>
#include <set>
#include <sstream>
+#include <utility>
+
+#include <cm/memory>
#include "cmAlgorithms.h"
-#include "cmCustomCommand.h"
+#include "cmComputeLinkInformation.h"
+#include "cmCustomCommand.h" // IWYU pragma: keep
#include "cmCustomCommandGenerator.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalNinjaGenerator.h"
#include "cmLinkLineComputer.h"
#include "cmLinkLineDeviceComputer.h"
+#include "cmLocalCommonGenerator.h"
#include "cmLocalGenerator.h"
#include "cmLocalNinjaGenerator.h"
#include "cmMakefile.h"
+#include "cmNinjaLinkLineDeviceComputer.h"
#include "cmNinjaTypes.h"
#include "cmOSXBundleGenerator.h"
#include "cmOutputConverter.h"
@@ -29,30 +35,20 @@
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
-#include "cmake.h"
cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator(
cmGeneratorTarget* target)
: cmNinjaTargetGenerator(target)
- , TargetNameOut()
- , TargetNameSO()
- , TargetNameReal()
- , TargetNameImport()
- , TargetNamePDB()
, TargetLinkLanguage("")
- , DeviceLinkObject()
{
this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
if (target->GetType() == cmStateEnums::EXECUTABLE) {
- this->GetGeneratorTarget()->GetExecutableNames(
- this->TargetNameOut, this->TargetNameReal, this->TargetNameImport,
- this->TargetNamePDB, GetLocalGenerator()->GetConfigName());
+ this->TargetNames = this->GetGeneratorTarget()->GetExecutableNames(
+ GetLocalGenerator()->GetConfigName());
} else {
- this->GetGeneratorTarget()->GetLibraryNames(
- this->TargetNameOut, this->TargetNameSO, this->TargetNameReal,
- this->TargetNameImport, this->TargetNamePDB,
+ this->TargetNames = this->GetGeneratorTarget()->GetLibraryNames(
GetLocalGenerator()->GetConfigName());
}
@@ -63,21 +59,18 @@ cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator(
}
this->OSXBundleGenerator =
- new cmOSXBundleGenerator(target, this->GetConfigName());
+ cm::make_unique<cmOSXBundleGenerator>(target, this->GetConfigName());
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
}
-cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
-{
- delete this->OSXBundleGenerator;
-}
+cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() = default;
void cmNinjaNormalTargetGenerator::Generate()
{
if (this->TargetLinkLanguage.empty()) {
cmSystemTools::Error("CMake can not determine linker language for "
- "target: ",
- this->GetGeneratorTarget()->GetName().c_str());
+ "target: " +
+ this->GetGeneratorTarget()->GetName());
return;
}
@@ -95,6 +88,9 @@ void cmNinjaNormalTargetGenerator::Generate()
this->WriteDeviceLinkStatement();
this->WriteLinkStatement();
}
+
+ // Find ADDITIONAL_CLEAN_FILES
+ this->AdditionalCleanFiles();
}
void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
@@ -112,17 +108,14 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
std::vector<cmSourceFile const*> sourceFiles;
this->GetGeneratorTarget()->GetObjectSources(
sourceFiles, this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
- for (std::vector<cmSourceFile const*>::const_iterator i =
- sourceFiles.begin();
- i != sourceFiles.end(); ++i) {
- const std::string& lang = (*i)->GetLanguage();
+ for (cmSourceFile const* sf : sourceFiles) {
+ std::string const lang = sf->GetLanguage();
if (!lang.empty()) {
languages.insert(lang);
}
}
- for (std::set<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l) {
- this->WriteLanguageRules(*l);
+ for (std::string const& language : languages) {
+ this->WriteLanguageRules(language);
}
}
@@ -142,7 +135,7 @@ const char* cmNinjaNormalTargetGenerator::GetVisibleTypeName() const
case cmStateEnums::EXECUTABLE:
return "executable";
default:
- return CM_NULLPTR;
+ return nullptr;
}
}
@@ -150,16 +143,18 @@ std::string cmNinjaNormalTargetGenerator::LanguageLinkerRule() const
{
return this->TargetLinkLanguage + "_" +
cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) +
- "_LINKER__" + cmGlobalNinjaGenerator::EncodeRuleName(
- this->GetGeneratorTarget()->GetName());
+ "_LINKER__" +
+ cmGlobalNinjaGenerator::EncodeRuleName(
+ this->GetGeneratorTarget()->GetName());
}
std::string cmNinjaNormalTargetGenerator::LanguageLinkerDeviceRule() const
{
return this->TargetLinkLanguage + "_" +
cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()) +
- "_DEVICE_LINKER__" + cmGlobalNinjaGenerator::EncodeRuleName(
- this->GetGeneratorTarget()->GetName());
+ "_DEVICE_LINKER__" +
+ cmGlobalNinjaGenerator::EncodeRuleName(
+ this->GetGeneratorTarget()->GetName());
}
struct cmNinjaRemoveNoOpCommands
@@ -172,13 +167,8 @@ struct cmNinjaRemoveNoOpCommands
void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile)
{
- cmStateEnums::TargetType targetType = this->GetGeneratorTarget()->GetType();
- std::string ruleName = this->LanguageLinkerDeviceRule();
- // Select whether to use a response file for objects.
- std::string rspfile;
- std::string rspcontent;
-
- if (!this->GetGlobalGenerator()->HasRule(ruleName)) {
+ cmNinjaRule rule(this->LanguageLinkerDeviceRule());
+ if (!this->GetGlobalGenerator()->HasRule(rule.Name)) {
cmRulePlaceholderExpander::RuleVariables vars;
vars.CMTargetName = this->GetGeneratorTarget()->GetName().c_str();
vars.CMTargetType =
@@ -186,32 +176,24 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile)
vars.Language = "CUDA";
- std::string responseFlag;
- if (!useResponseFile) {
+ // build response file name
+ std::string responseFlag = this->GetMakefile()->GetSafeDefinition(
+ "CMAKE_CUDA_RESPONSE_FILE_LINK_FLAG");
+
+ if (!useResponseFile || responseFlag.empty()) {
vars.Objects = "$in";
- vars.LinkLibraries = "$LINK_LIBRARIES";
+ vars.LinkLibraries = "$LINK_PATH $LINK_LIBRARIES";
} else {
- std::string cmakeVarLang = "CMAKE_";
- cmakeVarLang += this->TargetLinkLanguage;
-
- // build response file name
- std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_LINK_FLAG";
- const char* flag = GetMakefile()->GetDefinition(cmakeLinkVar);
- if (flag) {
- responseFlag = flag;
- } else {
- responseFlag = "@";
- }
- rspfile = "$RSP_FILE";
- responseFlag += rspfile;
+ rule.RspFile = "$RSP_FILE";
+ responseFlag += rule.RspFile;
// build response file content
if (this->GetGlobalGenerator()->IsGCCOnWindows()) {
- rspcontent = "$in";
+ rule.RspContent = "$in";
} else {
- rspcontent = "$in_newline";
+ rule.RspContent = "$in_newline";
}
- rspcontent += " $LINK_LIBRARIES";
+ rule.RspContent += " $LINK_LIBRARIES";
vars.Objects = responseFlag.c_str();
vars.LinkLibraries = "";
}
@@ -230,7 +212,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile)
vars.Manifests = "$MANIFESTS";
std::string langFlags;
- if (targetType != cmStateEnums::EXECUTABLE) {
+ if (this->GetGeneratorTarget()->GetType() != cmStateEnums::EXECUTABLE) {
langFlags += "$LANGUAGE_COMPILE_FLAGS $ARCH_FLAGS";
vars.LanguageCompileFlags = langFlags.c_str();
}
@@ -239,88 +221,94 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile)
const char* val = this->GetLocalGenerator()->GetRuleLauncher(
this->GetGeneratorTarget(), "RULE_LAUNCH_LINK");
if (val && *val) {
- launcher = val;
- launcher += " ";
+ launcher = cmStrCat(val, ' ');
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->GetLocalGenerator()->CreateRulePlaceholderExpander());
// Rule for linking library/executable.
std::vector<std::string> linkCmds = this->ComputeDeviceLinkCmd();
- for (std::vector<std::string>::iterator i = linkCmds.begin();
- i != linkCmds.end(); ++i) {
- *i = launcher + *i;
+ for (std::string& linkCmd : linkCmds) {
+ linkCmd = cmStrCat(launcher, linkCmd);
rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(),
- *i, vars);
+ linkCmd, vars);
}
// If there is no ranlib the command will be ":". Skip it.
cmEraseIf(linkCmds, cmNinjaRemoveNoOpCommands());
- std::string linkCmd =
- this->GetLocalGenerator()->BuildCommandLine(linkCmds);
+ rule.Command = this->GetLocalGenerator()->BuildCommandLine(linkCmds);
// Write the linker rule with response file if needed.
- std::ostringstream comment;
- comment << "Rule for linking " << this->TargetLinkLanguage << " "
- << this->GetVisibleTypeName() << ".";
- std::ostringstream description;
- description << "Linking " << this->TargetLinkLanguage << " "
- << this->GetVisibleTypeName() << " $TARGET_FILE";
- this->GetGlobalGenerator()->AddRule(ruleName, linkCmd, description.str(),
- comment.str(),
- /*depfile*/ "",
- /*deptype*/ "", rspfile, rspcontent,
- /*restat*/ "$RESTAT",
- /*generator*/ false);
+ rule.Comment = cmStrCat("Rule for linking ", this->TargetLinkLanguage, ' ',
+ this->GetVisibleTypeName(), '.');
+ rule.Description = cmStrCat("Linking ", this->TargetLinkLanguage, ' ',
+ this->GetVisibleTypeName(), " $TARGET_FILE");
+ rule.Restat = "$RESTAT";
+
+ this->GetGlobalGenerator()->AddRule(rule);
}
}
void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
{
cmStateEnums::TargetType targetType = this->GetGeneratorTarget()->GetType();
- std::string ruleName = this->LanguageLinkerRule();
-
- // Select whether to use a response file for objects.
- std::string rspfile;
- std::string rspcontent;
- if (!this->GetGlobalGenerator()->HasRule(ruleName)) {
+ std::string linkRuleName = this->LanguageLinkerRule();
+ if (!this->GetGlobalGenerator()->HasRule(linkRuleName)) {
+ cmNinjaRule rule(std::move(linkRuleName));
cmRulePlaceholderExpander::RuleVariables vars;
vars.CMTargetName = this->GetGeneratorTarget()->GetName().c_str();
- vars.CMTargetType =
- cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType());
+ vars.CMTargetType = cmState::GetTargetTypeName(targetType);
vars.Language = this->TargetLinkLanguage.c_str();
+ if (this->TargetLinkLanguage == "Swift") {
+ vars.SwiftLibraryName = "$SWIFT_LIBRARY_NAME";
+ vars.SwiftModule = "$SWIFT_MODULE";
+ vars.SwiftModuleName = "$SWIFT_MODULE_NAME";
+ vars.SwiftOutputFileMap = "$SWIFT_OUTPUT_FILE_MAP";
+ vars.SwiftSources = "$SWIFT_SOURCES";
+
+ vars.Defines = "$DEFINES";
+ vars.Flags = "$FLAGS";
+ vars.Includes = "$INCLUDES";
+ }
+
std::string responseFlag;
- if (!useResponseFile) {
+
+ std::string cmakeVarLang = cmStrCat("CMAKE_", this->TargetLinkLanguage);
+
+ // build response file name
+ std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_LINK_FLAG";
+ const char* flag = GetMakefile()->GetDefinition(cmakeLinkVar);
+
+ if (flag) {
+ responseFlag = flag;
+ } else if (this->TargetLinkLanguage != "CUDA") {
+ responseFlag = "@";
+ }
+
+ if (!useResponseFile || responseFlag.empty()) {
vars.Objects = "$in";
vars.LinkLibraries = "$LINK_PATH $LINK_LIBRARIES";
} else {
- std::string cmakeVarLang = "CMAKE_";
- cmakeVarLang += this->TargetLinkLanguage;
-
- // build response file name
- std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_LINK_FLAG";
- const char* flag = GetMakefile()->GetDefinition(cmakeLinkVar);
- if (flag) {
- responseFlag = flag;
- } else {
- responseFlag = "@";
- }
- rspfile = "$RSP_FILE";
- responseFlag += rspfile;
+ rule.RspFile = "$RSP_FILE";
+ responseFlag += rule.RspFile;
// build response file content
if (this->GetGlobalGenerator()->IsGCCOnWindows()) {
- rspcontent = "$in";
+ rule.RspContent = "$in";
} else {
- rspcontent = "$in_newline";
+ rule.RspContent = "$in_newline";
+ }
+ rule.RspContent += " $LINK_PATH $LINK_LIBRARIES";
+ if (this->TargetLinkLanguage == "Swift") {
+ vars.SwiftSources = responseFlag.c_str();
+ } else {
+ vars.Objects = responseFlag.c_str();
}
- rspcontent += " $LINK_PATH $LINK_LIBRARIES";
- vars.Objects = responseFlag.c_str();
vars.LinkLibraries = "";
}
@@ -364,76 +352,64 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile)
const char* val = this->GetLocalGenerator()->GetRuleLauncher(
this->GetGeneratorTarget(), "RULE_LAUNCH_LINK");
if (val && *val) {
- launcher = val;
- launcher += " ";
+ launcher = cmStrCat(val, ' ');
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->GetLocalGenerator()->CreateRulePlaceholderExpander());
// Rule for linking library/executable.
std::vector<std::string> linkCmds = this->ComputeLinkCmd();
- for (std::vector<std::string>::iterator i = linkCmds.begin();
- i != linkCmds.end(); ++i) {
- *i = launcher + *i;
+ for (std::string& linkCmd : linkCmds) {
+ linkCmd = cmStrCat(launcher, linkCmd);
rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(),
- *i, vars);
+ linkCmd, vars);
}
// If there is no ranlib the command will be ":". Skip it.
cmEraseIf(linkCmds, cmNinjaRemoveNoOpCommands());
linkCmds.insert(linkCmds.begin(), "$PRE_LINK");
- linkCmds.push_back("$POST_BUILD");
- std::string linkCmd =
- this->GetLocalGenerator()->BuildCommandLine(linkCmds);
+ linkCmds.emplace_back("$POST_BUILD");
+ rule.Command = this->GetLocalGenerator()->BuildCommandLine(linkCmds);
// Write the linker rule with response file if needed.
- std::ostringstream comment;
- comment << "Rule for linking " << this->TargetLinkLanguage << " "
- << this->GetVisibleTypeName() << ".";
- std::ostringstream description;
- description << "Linking " << this->TargetLinkLanguage << " "
- << this->GetVisibleTypeName() << " $TARGET_FILE";
- this->GetGlobalGenerator()->AddRule(ruleName, linkCmd, description.str(),
- comment.str(),
- /*depfile*/ "",
- /*deptype*/ "", rspfile, rspcontent,
- /*restat*/ "$RESTAT",
- /*generator*/ false);
+ rule.Comment = cmStrCat("Rule for linking ", this->TargetLinkLanguage, ' ',
+ this->GetVisibleTypeName(), '.');
+ rule.Description = cmStrCat("Linking ", this->TargetLinkLanguage, ' ',
+ this->GetVisibleTypeName(), " $TARGET_FILE");
+ rule.Restat = "$RESTAT";
+ this->GetGlobalGenerator()->AddRule(rule);
}
- if (this->TargetNameOut != this->TargetNameReal &&
+ if (this->TargetNames.Output != this->TargetNames.Real &&
!this->GetGeneratorTarget()->IsFrameworkOnApple()) {
std::string cmakeCommand =
this->GetLocalGenerator()->ConvertToOutputFormat(
cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
if (targetType == cmStateEnums::EXECUTABLE) {
- this->GetGlobalGenerator()->AddRule(
- "CMAKE_SYMLINK_EXECUTABLE",
- cmakeCommand + " -E cmake_symlink_executable"
- " $in $out && $POST_BUILD",
- "Creating executable symlink $out", "Rule for creating "
- "executable symlink.",
- /*depfile*/ "",
- /*deptype*/ "",
- /*rspfile*/ "",
- /*rspcontent*/ "",
- /*restat*/ "",
- /*generator*/ false);
+ cmNinjaRule rule("CMAKE_SYMLINK_EXECUTABLE");
+ {
+ std::vector<std::string> cmd;
+ cmd.push_back(cmakeCommand + " -E cmake_symlink_executable $in $out");
+ cmd.emplace_back("$POST_BUILD");
+ rule.Command = this->GetLocalGenerator()->BuildCommandLine(cmd);
+ }
+ rule.Description = "Creating executable symlink $out";
+ rule.Comment = "Rule for creating executable symlink.";
+ this->GetGlobalGenerator()->AddRule(rule);
} else {
- this->GetGlobalGenerator()->AddRule(
- "CMAKE_SYMLINK_LIBRARY",
- cmakeCommand + " -E cmake_symlink_library"
- " $in $SONAME $out && $POST_BUILD",
- "Creating library symlink $out", "Rule for creating "
- "library symlink.",
- /*depfile*/ "",
- /*deptype*/ "",
- /*rspfile*/ "",
- /*rspcontent*/ "",
- /*restat*/ "",
- /*generator*/ false);
+ cmNinjaRule rule("CMAKE_SYMLINK_LIBRARY");
+ {
+ std::vector<std::string> cmd;
+ cmd.push_back(cmakeCommand +
+ " -E cmake_symlink_library $in $SONAME $out");
+ cmd.emplace_back("$POST_BUILD");
+ rule.Command = this->GetLocalGenerator()->BuildCommandLine(cmd);
+ }
+ rule.Description = "Creating library symlink $out";
+ rule.Comment = "Rule for creating library symlink.";
+ this->GetGlobalGenerator()->AddRule(rule);
}
}
}
@@ -452,12 +428,12 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeDeviceLinkCmd()
case cmStateEnums::MODULE_LIBRARY: {
const std::string cudaLinkCmd(
this->GetMakefile()->GetDefinition("CMAKE_CUDA_DEVICE_LINK_LIBRARY"));
- cmSystemTools::ExpandListArgument(cudaLinkCmd, linkCmds);
+ cmExpandList(cudaLinkCmd, linkCmds);
} break;
case cmStateEnums::EXECUTABLE: {
const std::string cudaLinkCmd(this->GetMakefile()->GetDefinition(
"CMAKE_CUDA_DEVICE_LINK_EXECUTABLE"));
- cmSystemTools::ExpandListArgument(cudaLinkCmd, linkCmds);
+ cmExpandList(cudaLinkCmd, linkCmds);
} break;
default:
break;
@@ -477,21 +453,28 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd()
this->TargetLinkLanguage, this->GetConfigName());
const char* linkCmd = mf->GetDefinition(linkCmdVar);
if (linkCmd) {
- cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
+ std::string linkCmdStr = linkCmd;
+ if (this->GetGeneratorTarget()->HasImplibGNUtoMS(this->ConfigName)) {
+ std::string ruleVar = cmStrCat(
+ "CMAKE_", this->GeneratorTarget->GetLinkerLanguage(this->ConfigName),
+ "_GNUtoMS_RULE");
+ if (const char* rule = this->Makefile->GetDefinition(ruleVar)) {
+ linkCmdStr += rule;
+ }
+ }
+ cmExpandList(linkCmdStr, linkCmds);
if (this->GetGeneratorTarget()->GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
- std::string cmakeCommand =
+ std::string cmakeCommand = cmStrCat(
this->GetLocalGenerator()->ConvertToOutputFormat(
- cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
- cmakeCommand += " -E __run_iwyu --lwyu=";
+ cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL),
+ " -E __run_co_compile --lwyu=");
cmGeneratorTarget& gt = *this->GetGeneratorTarget();
const std::string cfgName = this->GetConfigName();
- std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName));
std::string targetOutputReal = this->ConvertToNinjaPath(
gt.GetFullPath(cfgName, cmStateEnums::RuntimeBinaryArtifact,
/*realname=*/true));
cmakeCommand += targetOutputReal;
- cmakeCommand += " || true";
- linkCmds.push_back(cmakeCommand);
+ linkCmds.push_back(std::move(cmakeCommand));
}
return linkCmds;
}
@@ -507,27 +490,39 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd()
}
// TODO: Use ARCHIVE_APPEND for archives over a certain size.
{
- std::string linkCmdVar = "CMAKE_";
- linkCmdVar += this->TargetLinkLanguage;
- linkCmdVar += "_ARCHIVE_CREATE";
+ std::string linkCmdVar =
+ cmStrCat("CMAKE_", this->TargetLinkLanguage, "_ARCHIVE_CREATE");
linkCmdVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable(
linkCmdVar, this->TargetLinkLanguage, this->GetConfigName());
- const char* linkCmd = mf->GetRequiredDefinition(linkCmdVar);
- cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
+ std::string const& linkCmd = mf->GetRequiredDefinition(linkCmdVar);
+ cmExpandList(linkCmd, linkCmds);
}
{
- std::string linkCmdVar = "CMAKE_";
- linkCmdVar += this->TargetLinkLanguage;
- linkCmdVar += "_ARCHIVE_FINISH";
+ std::string linkCmdVar =
+ cmStrCat("CMAKE_", this->TargetLinkLanguage, "_ARCHIVE_FINISH");
linkCmdVar = this->GeneratorTarget->GetFeatureSpecificLinkRuleVariable(
linkCmdVar, this->TargetLinkLanguage, this->GetConfigName());
- const char* linkCmd = mf->GetRequiredDefinition(linkCmdVar);
- cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
+ std::string const& linkCmd = mf->GetRequiredDefinition(linkCmdVar);
+ cmExpandList(linkCmd, linkCmds);
}
+#ifdef __APPLE__
+ // On macOS ranlib truncates the fractional part of the static archive
+ // file modification time. If the archive and at least one contained
+ // object file were created within the same second this will make look
+ // the archive older than the object file. On subsequent ninja runs this
+ // leads to re-achiving and updating dependent targets.
+ // As a work-around we touch the archive after ranlib (see #19222).
+ {
+ std::string cmakeCommand =
+ this->GetLocalGenerator()->ConvertToOutputFormat(
+ cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
+ linkCmds.push_back(cmakeCommand + " -E touch $TARGET_FILE");
+ }
+#endif
return linkCmds;
}
case cmStateEnums::SHARED_LIBRARY:
@@ -542,33 +537,16 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd()
void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
{
- cmGeneratorTarget& genTarget = *this->GetGeneratorTarget();
-
- // determine if we need to do any device linking for this target
- const std::string cuda_lang("CUDA");
- cmGeneratorTarget::LinkClosure const* closure =
- genTarget.GetLinkClosure(this->GetConfigName());
-
- const bool hasCUDA =
- (std::find(closure->Languages.begin(), closure->Languages.end(),
- cuda_lang) != closure->Languages.end());
-
- bool shouldHaveDeviceLinking = false;
- switch (genTarget.GetType()) {
- case cmStateEnums::SHARED_LIBRARY:
- case cmStateEnums::MODULE_LIBRARY:
- case cmStateEnums::EXECUTABLE:
- shouldHaveDeviceLinking = true;
- break;
- case cmStateEnums::STATIC_LIBRARY:
- shouldHaveDeviceLinking =
- genTarget.GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS");
- break;
- default:
- break;
+ cmGlobalNinjaGenerator* globalGen = this->GetGlobalGenerator();
+ if (!globalGen->GetLanguageEnabled("CUDA")) {
+ return;
}
- if (!(shouldHaveDeviceLinking && hasCUDA)) {
+ cmGeneratorTarget* genTarget = this->GetGeneratorTarget();
+
+ bool requiresDeviceLinking = requireDeviceLinking(
+ *this->GeneratorTarget, *this->GetLocalGenerator(), this->ConfigName);
+ if (!requiresDeviceLinking) {
return;
}
@@ -577,44 +555,42 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
// First and very important step is to make sure while inside this
// step our link language is set to CUDA
std::string cudaLinkLanguage = "CUDA";
- std::string const objExt =
+ std::string const& objExt =
this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
std::string const cfgName = this->GetConfigName();
std::string const targetOutputReal = ConvertToNinjaPath(
- genTarget.ObjectDirectory + "cmake_device_link" + objExt);
+ genTarget->ObjectDirectory + "cmake_device_link" + objExt);
std::string const targetOutputImplib = ConvertToNinjaPath(
- genTarget.GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact));
+ genTarget->GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact));
this->DeviceLinkObject = targetOutputReal;
// Write comments.
cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
- const cmStateEnums::TargetType targetType = genTarget.GetType();
+ const cmStateEnums::TargetType targetType = genTarget->GetType();
this->GetBuildFileStream() << "# Device Link build statements for "
<< cmState::GetTargetTypeName(targetType)
<< " target " << this->GetTargetName() << "\n\n";
// Compute the comment.
- std::ostringstream comment;
- comment << "Link the " << this->GetVisibleTypeName() << " "
- << targetOutputReal;
+ cmNinjaBuild build(this->LanguageLinkerDeviceRule());
+ build.Comment =
+ cmStrCat("Link the ", this->GetVisibleTypeName(), ' ', targetOutputReal);
- cmNinjaDeps emptyDeps;
- cmNinjaVars vars;
+ cmNinjaVars& vars = build.Variables;
// Compute outputs.
- cmNinjaDeps outputs;
- outputs.push_back(targetOutputReal);
+ build.Outputs.push_back(targetOutputReal);
// Compute specific libraries to link with.
- cmNinjaDeps explicitDeps = this->GetObjects();
- cmNinjaDeps implicitDeps = this->ComputeLinkDeps();
+ build.ExplicitDeps = this->GetObjects();
+ build.ImplicitDeps = this->ComputeLinkDeps(this->TargetLinkLanguage);
std::string frameworkPath;
std::string linkPath;
- std::string createRule = genTarget.GetCreateRuleVariable(
+ std::string createRule = genTarget->GetCreateRuleVariable(
this->TargetLinkLanguage, this->GetConfigName());
const bool useWatcomQuote =
this->GetMakefile()->IsOn(createRule + "_USE_WATCOM_QUOTE");
@@ -623,18 +599,18 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
vars["TARGET_FILE"] =
localGen.ConvertToOutputFormat(targetOutputReal, cmOutputConverter::SHELL);
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
new cmNinjaLinkLineDeviceComputer(
this->GetLocalGenerator(),
this->GetLocalGenerator()->GetStateSnapshot().GetDirectory(),
- this->GetGlobalGenerator()));
+ globalGen));
linkLineComputer->SetUseWatcomQuote(useWatcomQuote);
localGen.GetTargetFlags(
linkLineComputer.get(), this->GetConfigName(), vars["LINK_LIBRARIES"],
- vars["FLAGS"], vars["LINK_FLAGS"], frameworkPath, linkPath, &genTarget);
+ vars["FLAGS"], vars["LINK_FLAGS"], frameworkPath, linkPath, genTarget);
- this->addPoolNinjaVariable("JOB_POOL_LINK", &genTarget, vars);
+ this->addPoolNinjaVariable("JOB_POOL_LINK", genTarget, vars);
vars["LINK_FLAGS"] =
cmGlobalNinjaGenerator::EncodeLiteral(vars["LINK_FLAGS"]);
@@ -648,21 +624,21 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
// code between the Makefile executable and library generators.
if (targetType == cmStateEnums::EXECUTABLE) {
std::string t = vars["FLAGS"];
- localGen.AddArchitectureFlags(t, &genTarget, cudaLinkLanguage, cfgName);
+ localGen.AddArchitectureFlags(t, genTarget, cudaLinkLanguage, cfgName);
vars["FLAGS"] = t;
} else {
std::string t = vars["ARCH_FLAGS"];
- localGen.AddArchitectureFlags(t, &genTarget, cudaLinkLanguage, cfgName);
+ localGen.AddArchitectureFlags(t, genTarget, cudaLinkLanguage, cfgName);
vars["ARCH_FLAGS"] = t;
- t = "";
- localGen.AddLanguageFlagsForLinking(t, &genTarget, cudaLinkLanguage,
+ t.clear();
+ localGen.AddLanguageFlagsForLinking(t, genTarget, cudaLinkLanguage,
cfgName);
vars["LANGUAGE_COMPILE_FLAGS"] = t;
}
- if (this->GetGeneratorTarget()->HasSOName(cfgName)) {
+ if (genTarget->HasSOName(cfgName)) {
vars["SONAME_FLAG"] =
this->GetMakefile()->GetSONameFlag(this->TargetLinkLanguage);
- vars["SONAME"] = this->TargetNameSO;
+ vars["SONAME"] = this->TargetNames.SharedObject;
if (targetType == cmStateEnums::SHARED_LIBRARY) {
std::string install_dir =
this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName);
@@ -673,16 +649,11 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
}
}
- cmNinjaDeps byproducts;
-
- if (!this->TargetNameImport.empty()) {
+ if (!this->TargetNames.ImportLibrary.empty()) {
const std::string impLibPath = localGen.ConvertToOutputFormat(
targetOutputImplib, cmOutputConverter::SHELL);
vars["TARGET_IMPLIB"] = impLibPath;
EnsureParentDirectoryExists(impLibPath);
- if (genTarget.HasImportLibrary()) {
- byproducts.push_back(targetOutputImplib);
- }
}
const std::string objPath = GetGeneratorTarget()->GetSupportDirectory();
@@ -692,7 +663,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
this->SetMsvcTargetPdbVariable(vars);
- if (this->GetGlobalGenerator()->IsGCCOnWindows()) {
+ if (globalGen->IsGCCOnWindows()) {
// ar.exe can't handle backslashes in rsp files (implicitly used by gcc)
std::string& linkLibraries = vars["LINK_LIBRARIES"];
std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/');
@@ -700,143 +671,182 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
std::replace(link_path.begin(), link_path.end(), '\\', '/');
}
- const std::vector<cmCustomCommand>* cmdLists[3] = {
- &genTarget.GetPreBuildCommands(), &genTarget.GetPreLinkCommands(),
- &genTarget.GetPostBuildCommands()
- };
-
- std::vector<std::string> preLinkCmdLines, postBuildCmdLines;
- vars["PRE_LINK"] = localGen.BuildCommandLine(preLinkCmdLines);
- vars["POST_BUILD"] = localGen.BuildCommandLine(postBuildCmdLines);
-
- std::vector<std::string>* cmdLineLists[3] = { &preLinkCmdLines,
- &preLinkCmdLines,
- &postBuildCmdLines };
-
- for (unsigned i = 0; i != 3; ++i) {
- for (std::vector<cmCustomCommand>::const_iterator ci =
- cmdLists[i]->begin();
- ci != cmdLists[i]->end(); ++ci) {
- cmCustomCommandGenerator ccg(*ci, cfgName, this->GetLocalGenerator());
- localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]);
- std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
- std::transform(ccByproducts.begin(), ccByproducts.end(),
- std::back_inserter(byproducts), MapToNinjaPath());
- }
- }
-
- cmGlobalNinjaGenerator& globalGen = *this->GetGlobalGenerator();
-
// Device linking currently doesn't support response files so
// do not check if the user has explicitly forced a response file.
int const commandLineLengthLimit =
static_cast<int>(cmSystemTools::CalculateCommandLineLengthLimit()) -
- globalGen.GetRuleCmdLength(this->LanguageLinkerDeviceRule());
+ globalGen->GetRuleCmdLength(this->LanguageLinkerDeviceRule());
- const std::string rspfile =
- std::string(cmake::GetCMakeFilesDirectoryPostSlash()) +
- genTarget.GetName() + ".rsp";
+ build.RspFile = this->ConvertToNinjaPath(std::string("CMakeFiles/") +
+ genTarget->GetName() + ".rsp");
// Gather order-only dependencies.
- cmNinjaDeps orderOnlyDeps;
this->GetLocalGenerator()->AppendTargetDepends(this->GetGeneratorTarget(),
- orderOnlyDeps);
+ build.OrderOnlyDeps);
// Write the build statement for this target.
bool usedResponseFile = false;
- globalGen.WriteBuild(this->GetBuildFileStream(), comment.str(),
- this->LanguageLinkerDeviceRule(), outputs,
- /*implicitOuts=*/cmNinjaDeps(), explicitDeps,
- implicitDeps, orderOnlyDeps, vars, rspfile,
- commandLineLengthLimit, &usedResponseFile);
+ globalGen->WriteBuild(this->GetBuildFileStream(), build,
+ commandLineLengthLimit, &usedResponseFile);
this->WriteDeviceLinkRule(usedResponseFile);
}
void cmNinjaNormalTargetGenerator::WriteLinkStatement()
{
- cmGeneratorTarget& gt = *this->GetGeneratorTarget();
+ cmMakefile* mf = this->GetMakefile();
+ cmGlobalNinjaGenerator* globalGen = this->GetGlobalGenerator();
+ cmGeneratorTarget* gt = this->GetGeneratorTarget();
+
const std::string cfgName = this->GetConfigName();
- std::string targetOutput = ConvertToNinjaPath(gt.GetFullPath(cfgName));
+ std::string targetOutput = ConvertToNinjaPath(gt->GetFullPath(cfgName));
std::string targetOutputReal = ConvertToNinjaPath(
- gt.GetFullPath(cfgName, cmStateEnums::RuntimeBinaryArtifact,
- /*realname=*/true));
+ gt->GetFullPath(cfgName, cmStateEnums::RuntimeBinaryArtifact,
+ /*realname=*/true));
std::string targetOutputImplib = ConvertToNinjaPath(
- gt.GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact));
+ gt->GetFullPath(cfgName, cmStateEnums::ImportLibraryArtifact));
- if (gt.IsAppBundleOnApple()) {
+ if (gt->IsAppBundleOnApple()) {
// Create the app bundle
- std::string outpath = gt.GetDirectory(cfgName);
- this->OSXBundleGenerator->CreateAppBundle(this->TargetNameOut, outpath);
+ std::string outpath = gt->GetDirectory(cfgName);
+ this->OSXBundleGenerator->CreateAppBundle(this->TargetNames.Output,
+ outpath);
// Calculate the output path
- targetOutput = outpath;
- targetOutput += "/";
- targetOutput += this->TargetNameOut;
+ targetOutput = cmStrCat(outpath, '/', this->TargetNames.Output);
targetOutput = this->ConvertToNinjaPath(targetOutput);
- targetOutputReal = outpath;
- targetOutputReal += "/";
- targetOutputReal += this->TargetNameReal;
+ targetOutputReal = cmStrCat(outpath, '/', this->TargetNames.Real);
targetOutputReal = this->ConvertToNinjaPath(targetOutputReal);
- } else if (gt.IsFrameworkOnApple()) {
+ } else if (gt->IsFrameworkOnApple()) {
// Create the library framework.
- this->OSXBundleGenerator->CreateFramework(this->TargetNameOut,
- gt.GetDirectory(cfgName));
- } else if (gt.IsCFBundleOnApple()) {
+ this->OSXBundleGenerator->CreateFramework(this->TargetNames.Output,
+ gt->GetDirectory(cfgName));
+ } else if (gt->IsCFBundleOnApple()) {
// Create the core foundation bundle.
- this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut,
- gt.GetDirectory(cfgName));
+ this->OSXBundleGenerator->CreateCFBundle(this->TargetNames.Output,
+ gt->GetDirectory(cfgName));
}
// Write comments.
cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
- const cmStateEnums::TargetType targetType = gt.GetType();
- this->GetBuildFileStream() << "# Link build statements for "
- << cmState::GetTargetTypeName(targetType)
- << " target " << this->GetTargetName() << "\n\n";
+ const cmStateEnums::TargetType targetType = gt->GetType();
+ this->GetBuildFileStream()
+ << "# Link build statements for " << cmState::GetTargetTypeName(targetType)
+ << " target " << this->GetTargetName() << "\n\n";
- cmNinjaDeps emptyDeps;
- cmNinjaVars vars;
+ cmNinjaBuild linkBuild(this->LanguageLinkerRule());
+ cmNinjaVars& vars = linkBuild.Variables;
// Compute the comment.
- std::ostringstream comment;
- comment << "Link the " << this->GetVisibleTypeName() << " "
- << targetOutputReal;
+ linkBuild.Comment =
+ cmStrCat("Link the ", this->GetVisibleTypeName(), ' ', targetOutputReal);
// Compute outputs.
- cmNinjaDeps outputs;
- outputs.push_back(targetOutputReal);
+ linkBuild.Outputs.push_back(targetOutputReal);
+
+ if (this->TargetLinkLanguage == "Swift") {
+ vars["SWIFT_LIBRARY_NAME"] = [this]() -> std::string {
+ cmGeneratorTarget::Names targetNames =
+ this->GetGeneratorTarget()->GetLibraryNames(this->GetConfigName());
+ return targetNames.Base;
+ }();
+
+ vars["SWIFT_MODULE_NAME"] = [gt]() -> std::string {
+ if (const char* name = gt->GetProperty("Swift_MODULE_NAME")) {
+ return name;
+ }
+ return gt->GetName();
+ }();
+
+ vars["SWIFT_MODULE"] = [this](const std::string& module) -> std::string {
+ std::string directory =
+ this->GetLocalGenerator()->GetCurrentBinaryDirectory();
+ if (const char* prop = this->GetGeneratorTarget()->GetProperty(
+ "Swift_MODULE_DIRECTORY")) {
+ directory = prop;
+ }
+
+ std::string name = module + ".swiftmodule";
+ if (const char* prop =
+ this->GetGeneratorTarget()->GetProperty("Swift_MODULE")) {
+ name = prop;
+ }
+
+ return this->GetLocalGenerator()->ConvertToOutputFormat(
+ this->ConvertToNinjaPath(directory + "/" + name),
+ cmOutputConverter::SHELL);
+ }(vars["SWIFT_MODULE_NAME"]);
+
+ vars["SWIFT_OUTPUT_FILE_MAP"] =
+ this->GetLocalGenerator()->ConvertToOutputFormat(
+ this->ConvertToNinjaPath(gt->GetSupportDirectory() +
+ "/output-file-map.json"),
+ cmOutputConverter::SHELL);
+
+ vars["SWIFT_SOURCES"] = [this]() -> std::string {
+ std::vector<cmSourceFile const*> sources;
+ std::stringstream oss;
+
+ this->GetGeneratorTarget()->GetObjectSources(sources,
+ this->GetConfigName());
+ cmLocalGenerator const* LocalGen = this->GetLocalGenerator();
+ for (const auto& source : sources) {
+ oss << " "
+ << LocalGen->ConvertToOutputFormat(
+ this->ConvertToNinjaPath(this->GetSourceFilePath(source)),
+ cmOutputConverter::SHELL);
+ }
+ return oss.str();
+ }();
+
+ // Since we do not perform object builds, compute the
+ // defines/flags/includes here so that they can be passed along
+ // appropriately.
+ vars["DEFINES"] = this->GetDefines("Swift");
+ vars["FLAGS"] = this->GetFlags("Swift");
+ vars["INCLUDES"] = this->GetIncludes("Swift");
+ }
// Compute specific libraries to link with.
- cmNinjaDeps explicitDeps = this->GetObjects();
- cmNinjaDeps implicitDeps = this->ComputeLinkDeps();
+ if (this->TargetLinkLanguage == "Swift") {
+ std::vector<cmSourceFile const*> sources;
+ gt->GetObjectSources(sources, this->GetConfigName());
+ for (const auto& source : sources) {
+ linkBuild.Outputs.push_back(
+ this->ConvertToNinjaPath(this->GetObjectFilePath(source)));
+ linkBuild.ExplicitDeps.push_back(
+ this->ConvertToNinjaPath(this->GetSourceFilePath(source)));
+ }
- if (!this->DeviceLinkObject.empty()) {
- explicitDeps.push_back(this->DeviceLinkObject);
+ linkBuild.Outputs.push_back(vars["SWIFT_MODULE"]);
+ } else {
+ linkBuild.ExplicitDeps = this->GetObjects();
}
+ linkBuild.ImplicitDeps = this->ComputeLinkDeps(this->TargetLinkLanguage);
- cmMakefile* mf = this->GetMakefile();
+ if (!this->DeviceLinkObject.empty()) {
+ linkBuild.ExplicitDeps.push_back(this->DeviceLinkObject);
+ }
std::string frameworkPath;
std::string linkPath;
- cmGeneratorTarget& genTarget = *this->GetGeneratorTarget();
- std::string createRule = genTarget.GetCreateRuleVariable(
- this->TargetLinkLanguage, this->GetConfigName());
+ std::string createRule =
+ gt->GetCreateRuleVariable(this->TargetLinkLanguage, this->GetConfigName());
bool useWatcomQuote = mf->IsOn(createRule + "_USE_WATCOM_QUOTE");
cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator();
vars["TARGET_FILE"] =
localGen.ConvertToOutputFormat(targetOutputReal, cmOutputConverter::SHELL);
- CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer(
- this->GetGlobalGenerator()->CreateLinkLineComputer(
+ std::unique_ptr<cmLinkLineComputer> linkLineComputer(
+ globalGen->CreateLinkLineComputer(
this->GetLocalGenerator(),
this->GetLocalGenerator()->GetStateSnapshot().GetDirectory()));
linkLineComputer->SetUseWatcomQuote(useWatcomQuote);
- localGen.GetTargetFlags(
- linkLineComputer.get(), this->GetConfigName(), vars["LINK_LIBRARIES"],
- vars["FLAGS"], vars["LINK_FLAGS"], frameworkPath, linkPath, &genTarget);
+ localGen.GetTargetFlags(linkLineComputer.get(), this->GetConfigName(),
+ vars["LINK_LIBRARIES"], vars["FLAGS"],
+ vars["LINK_FLAGS"], frameworkPath, linkPath, gt);
// Add OS X version flags, if any.
if (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
@@ -847,7 +857,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
"CURRENT", false);
}
- this->addPoolNinjaVariable("JOB_POOL_LINK", &gt, vars);
+ this->addPoolNinjaVariable("JOB_POOL_LINK", gt, vars);
this->AddModuleDefinitionFlag(linkLineComputer.get(), vars["LINK_FLAGS"]);
vars["LINK_FLAGS"] =
@@ -857,7 +867,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
vars["LINK_PATH"] = frameworkPath + linkPath;
std::string lwyuFlags;
- if (genTarget.GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
+ if (gt->GetPropertyAsBool("LINK_WHAT_YOU_USE")) {
lwyuFlags = " -Wl,--no-as-needed";
}
@@ -866,25 +876,23 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// code between the Makefile executable and library generators.
if (targetType == cmStateEnums::EXECUTABLE) {
std::string t = vars["FLAGS"];
- localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
+ localGen.AddArchitectureFlags(t, gt, TargetLinkLanguage, cfgName);
t += lwyuFlags;
vars["FLAGS"] = t;
} else {
std::string t = vars["ARCH_FLAGS"];
- localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
+ localGen.AddArchitectureFlags(t, gt, TargetLinkLanguage, cfgName);
vars["ARCH_FLAGS"] = t;
- t = "";
+ t.clear();
t += lwyuFlags;
- localGen.AddLanguageFlagsForLinking(t, &genTarget, TargetLinkLanguage,
- cfgName);
+ localGen.AddLanguageFlagsForLinking(t, gt, TargetLinkLanguage, cfgName);
vars["LANGUAGE_COMPILE_FLAGS"] = t;
}
- if (this->GetGeneratorTarget()->HasSOName(cfgName)) {
+ if (gt->HasSOName(cfgName)) {
vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage);
- vars["SONAME"] = this->TargetNameSO;
+ vars["SONAME"] = this->TargetNames.SharedObject;
if (targetType == cmStateEnums::SHARED_LIBRARY) {
- std::string install_dir =
- this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName);
+ std::string install_dir = gt->GetInstallNameDirForBuildTree(cfgName);
if (!install_dir.empty()) {
vars["INSTALLNAME_DIR"] = localGen.ConvertToOutputFormat(
install_dir, cmOutputConverter::SHELL);
@@ -894,12 +902,12 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
cmNinjaDeps byproducts;
- if (!this->TargetNameImport.empty()) {
+ if (!this->TargetNames.ImportLibrary.empty()) {
const std::string impLibPath = localGen.ConvertToOutputFormat(
targetOutputImplib, cmOutputConverter::SHELL);
vars["TARGET_IMPLIB"] = impLibPath;
EnsureParentDirectoryExists(impLibPath);
- if (genTarget.HasImportLibrary()) {
+ if (gt->HasImportLibrary(cfgName)) {
byproducts.push_back(targetOutputImplib);
}
}
@@ -910,7 +918,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
std::string prefix;
std::string base;
std::string suffix;
- this->GetGeneratorTarget()->GetFullNameComponents(prefix, base, suffix);
+ gt->GetFullNameComponents(prefix, base, suffix);
std::string dbg_suffix = ".dbg";
// TODO: Where to document?
if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) {
@@ -919,12 +927,12 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
vars["TARGET_PDB"] = base + suffix + dbg_suffix;
}
- const std::string objPath = GetGeneratorTarget()->GetSupportDirectory();
+ const std::string objPath = gt->GetSupportDirectory();
vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
this->ConvertToNinjaPath(objPath), cmOutputConverter::SHELL);
EnsureDirectoryExists(objPath);
- if (this->GetGlobalGenerator()->IsGCCOnWindows()) {
+ if (globalGen->IsGCCOnWindows()) {
// ar.exe can't handle backslashes in rsp files (implicitly used by gcc)
std::string& linkLibraries = vars["LINK_LIBRARIES"];
std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/');
@@ -933,20 +941,19 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
const std::vector<cmCustomCommand>* cmdLists[3] = {
- &gt.GetPreBuildCommands(), &gt.GetPreLinkCommands(),
- &gt.GetPostBuildCommands()
+ &gt->GetPreBuildCommands(), &gt->GetPreLinkCommands(),
+ &gt->GetPostBuildCommands()
};
- std::vector<std::string> preLinkCmdLines, postBuildCmdLines;
+ std::vector<std::string> preLinkCmdLines;
+ std::vector<std::string> postBuildCmdLines;
std::vector<std::string>* cmdLineLists[3] = { &preLinkCmdLines,
&preLinkCmdLines,
&postBuildCmdLines };
for (unsigned i = 0; i != 3; ++i) {
- for (std::vector<cmCustomCommand>::const_iterator ci =
- cmdLists[i]->begin();
- ci != cmdLists[i]->end(); ++ci) {
- cmCustomCommandGenerator ccg(*ci, cfgName, this->GetLocalGenerator());
+ for (cmCustomCommand const& cc : *cmdLists[i]) {
+ cmCustomCommandGenerator ccg(cc, cfgName, this->GetLocalGenerator());
localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]);
std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
std::transform(ccByproducts.begin(), ccByproducts.end(),
@@ -956,142 +963,171 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// maybe create .def file from list of objects
cmGeneratorTarget::ModuleDefinitionInfo const* mdi =
- gt.GetModuleDefinitionInfo(this->GetConfigName());
+ gt->GetModuleDefinitionInfo(this->GetConfigName());
if (mdi && mdi->DefFileGenerated) {
std::string cmakeCommand =
this->GetLocalGenerator()->ConvertToOutputFormat(
cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
- std::string cmd = cmakeCommand;
- cmd += " -E __create_def ";
- cmd += this->GetLocalGenerator()->ConvertToOutputFormat(
- mdi->DefFile, cmOutputConverter::SHELL);
- cmd += " ";
+ std::string cmd =
+ cmStrCat(cmakeCommand, " -E __create_def ",
+ this->GetLocalGenerator()->ConvertToOutputFormat(
+ mdi->DefFile, cmOutputConverter::SHELL),
+ ' ');
std::string obj_list_file = mdi->DefFile + ".objs";
cmd += this->GetLocalGenerator()->ConvertToOutputFormat(
obj_list_file, cmOutputConverter::SHELL);
- preLinkCmdLines.push_back(cmd);
+
+ const char* nm_executable = GetMakefile()->GetDefinition("CMAKE_NM");
+ if (nm_executable && *nm_executable) {
+ cmd += " --nm=";
+ cmd += this->LocalCommonGenerator->ConvertToOutputFormat(
+ nm_executable, cmOutputConverter::SHELL);
+ }
+ preLinkCmdLines.push_back(std::move(cmd));
// create a list of obj files for the -E __create_def to read
- cmGeneratedFileStream fout(obj_list_file.c_str());
+ cmGeneratedFileStream fout(obj_list_file);
if (mdi->WindowsExportAllSymbols) {
cmNinjaDeps objs = this->GetObjects();
- for (cmNinjaDeps::iterator i = objs.begin(); i != objs.end(); ++i) {
- if (cmHasLiteralSuffix(*i, ".obj")) {
- fout << *i << "\n";
+ for (std::string const& obj : objs) {
+ if (cmHasLiteralSuffix(obj, ".obj")) {
+ fout << obj << "\n";
}
}
}
- for (std::vector<cmSourceFile const*>::const_iterator i =
- mdi->Sources.begin();
- i != mdi->Sources.end(); ++i) {
- fout << (*i)->GetFullPath() << "\n";
+ for (cmSourceFile const* src : mdi->Sources) {
+ fout << src->GetFullPath() << "\n";
}
}
// If we have any PRE_LINK commands, we need to go back to CMAKE_BINARY_DIR
- // for
- // the link commands.
+ // for the link commands.
if (!preLinkCmdLines.empty()) {
const std::string homeOutDir = localGen.ConvertToOutputFormat(
localGen.GetBinaryDirectory(), cmOutputConverter::SHELL);
preLinkCmdLines.push_back("cd " + homeOutDir);
}
- vars["PRE_LINK"] = localGen.BuildCommandLine(preLinkCmdLines);
- std::string postBuildCmdLine = localGen.BuildCommandLine(postBuildCmdLines);
+ vars["PRE_LINK"] = localGen.BuildCommandLine(preLinkCmdLines, "pre-link",
+ this->GeneratorTarget);
+ std::string postBuildCmdLine = localGen.BuildCommandLine(
+ postBuildCmdLines, "post-build", this->GeneratorTarget);
cmNinjaVars symlinkVars;
bool const symlinkNeeded =
- (targetOutput != targetOutputReal && !gt.IsFrameworkOnApple());
+ (targetOutput != targetOutputReal && !gt->IsFrameworkOnApple());
if (!symlinkNeeded) {
vars["POST_BUILD"] = postBuildCmdLine;
} else {
vars["POST_BUILD"] = cmGlobalNinjaGenerator::SHELL_NOOP;
symlinkVars["POST_BUILD"] = postBuildCmdLine;
}
- cmGlobalNinjaGenerator& globalGen = *this->GetGlobalGenerator();
+
+ std::string cmakeVarLang = cmStrCat("CMAKE_", this->TargetLinkLanguage);
+
+ // build response file name
+ std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_LINK_FLAG";
+
+ const char* flag = GetMakefile()->GetDefinition(cmakeLinkVar);
bool const lang_supports_response =
- !(this->TargetLinkLanguage == "RC" || this->TargetLinkLanguage == "CUDA");
+ !(this->TargetLinkLanguage == "RC" ||
+ (this->TargetLinkLanguage == "CUDA" && !flag));
int commandLineLengthLimit = -1;
if (!lang_supports_response || !this->ForceResponseFile()) {
commandLineLengthLimit =
static_cast<int>(cmSystemTools::CalculateCommandLineLengthLimit()) -
- globalGen.GetRuleCmdLength(this->LanguageLinkerRule());
+ globalGen->GetRuleCmdLength(linkBuild.Rule);
}
- const std::string rspfile =
- std::string(cmake::GetCMakeFilesDirectoryPostSlash()) + gt.GetName() +
- ".rsp";
+ linkBuild.RspFile = this->ConvertToNinjaPath(std::string("CMakeFiles/") +
+ gt->GetName() + ".rsp");
// Gather order-only dependencies.
- cmNinjaDeps orderOnlyDeps;
- this->GetLocalGenerator()->AppendTargetDepends(this->GetGeneratorTarget(),
- orderOnlyDeps);
+ this->GetLocalGenerator()->AppendTargetDepends(gt, linkBuild.OrderOnlyDeps);
+
+ // Add order-only dependencies on versioning symlinks of shared libs we link.
+ if (!this->GeneratorTarget->IsDLLPlatform()) {
+ if (cmComputeLinkInformation* cli =
+ this->GeneratorTarget->GetLinkInformation(this->GetConfigName())) {
+ for (auto const& item : cli->GetItems()) {
+ if (item.Target &&
+ item.Target->GetType() == cmStateEnums::SHARED_LIBRARY &&
+ !item.Target->IsFrameworkOnApple()) {
+ std::string const& lib = this->ConvertToNinjaPath(
+ item.Target->GetFullPath(this->GetConfigName()));
+ if (std::find(linkBuild.ImplicitDeps.begin(),
+ linkBuild.ImplicitDeps.end(),
+ lib) == linkBuild.ImplicitDeps.end()) {
+ linkBuild.OrderOnlyDeps.emplace_back(lib);
+ }
+ }
+ }
+ }
+ }
// Ninja should restat after linking if and only if there are byproducts.
vars["RESTAT"] = byproducts.empty() ? "" : "1";
- for (cmNinjaDeps::const_iterator oi = byproducts.begin(),
- oe = byproducts.end();
- oi != oe; ++oi) {
- this->GetGlobalGenerator()->SeenCustomCommandOutput(*oi);
- outputs.push_back(*oi);
+ for (std::string const& o : byproducts) {
+ globalGen->SeenCustomCommandOutput(o);
+ linkBuild.Outputs.push_back(o);
}
// Write the build statement for this target.
bool usedResponseFile = false;
- globalGen.WriteBuild(this->GetBuildFileStream(), comment.str(),
- this->LanguageLinkerRule(), outputs,
- /*implicitOuts=*/cmNinjaDeps(), explicitDeps,
- implicitDeps, orderOnlyDeps, vars, rspfile,
- commandLineLengthLimit, &usedResponseFile);
+ globalGen->WriteBuild(this->GetBuildFileStream(), linkBuild,
+ commandLineLengthLimit, &usedResponseFile);
this->WriteLinkRule(usedResponseFile);
if (symlinkNeeded) {
if (targetType == cmStateEnums::EXECUTABLE) {
- globalGen.WriteBuild(
- this->GetBuildFileStream(),
- "Create executable symlink " + targetOutput,
- "CMAKE_SYMLINK_EXECUTABLE", cmNinjaDeps(1, targetOutput),
- /*implicitOuts=*/cmNinjaDeps(), cmNinjaDeps(1, targetOutputReal),
- emptyDeps, emptyDeps, symlinkVars);
+ cmNinjaBuild build("CMAKE_SYMLINK_EXECUTABLE");
+ build.Comment = "Create executable symlink " + targetOutput;
+ build.Outputs.push_back(targetOutput);
+ build.ExplicitDeps.push_back(targetOutputReal);
+ build.Variables = std::move(symlinkVars);
+ globalGen->WriteBuild(this->GetBuildFileStream(), build);
} else {
- cmNinjaDeps symlinks;
- std::string const soName =
- this->ConvertToNinjaPath(this->GetTargetFilePath(this->TargetNameSO));
+ cmNinjaBuild build("CMAKE_SYMLINK_LIBRARY");
+ build.Comment = "Create library symlink " + targetOutput;
+
+ std::string const soName = this->ConvertToNinjaPath(
+ this->GetTargetFilePath(this->TargetNames.SharedObject));
// If one link has to be created.
if (targetOutputReal == soName || targetOutput == soName) {
- symlinkVars["SONAME"] = soName;
+ symlinkVars["SONAME"] =
+ this->GetLocalGenerator()->ConvertToOutputFormat(
+ soName, cmOutputConverter::SHELL);
} else {
- symlinkVars["SONAME"] = "";
- symlinks.push_back(soName);
+ symlinkVars["SONAME"].clear();
+ build.Outputs.push_back(soName);
}
- symlinks.push_back(targetOutput);
- globalGen.WriteBuild(
- this->GetBuildFileStream(), "Create library symlink " + targetOutput,
- "CMAKE_SYMLINK_LIBRARY", symlinks,
- /*implicitOuts=*/cmNinjaDeps(), cmNinjaDeps(1, targetOutputReal),
- emptyDeps, emptyDeps, symlinkVars);
+ build.Outputs.push_back(targetOutput);
+ build.ExplicitDeps.push_back(targetOutputReal);
+ build.Variables = std::move(symlinkVars);
+
+ globalGen->WriteBuild(this->GetBuildFileStream(), build);
}
}
// Add aliases for the file name and the target name.
- globalGen.AddTargetAlias(this->TargetNameOut, &gt);
- globalGen.AddTargetAlias(this->GetTargetName(), &gt);
+ globalGen->AddTargetAlias(this->TargetNames.Output, gt);
+ globalGen->AddTargetAlias(this->GetTargetName(), gt);
}
void cmNinjaNormalTargetGenerator::WriteObjectLibStatement()
{
// Write a phony output that depends on all object files.
- cmNinjaDeps outputs;
- this->GetLocalGenerator()->AppendTargetOutputs(this->GetGeneratorTarget(),
- outputs);
- cmNinjaDeps depends = this->GetObjects();
- this->GetGlobalGenerator()->WritePhonyBuild(
- this->GetBuildFileStream(), "Object library " + this->GetTargetName(),
- outputs, depends);
+ {
+ cmNinjaBuild build("phony");
+ build.Comment = "Object library " + this->GetTargetName();
+ this->GetLocalGenerator()->AppendTargetOutputs(this->GetGeneratorTarget(),
+ build.Outputs);
+ build.ExplicitDeps = this->GetObjects();
+ this->GetGlobalGenerator()->WriteBuild(this->GetBuildFileStream(), build);
+ }
// Add aliases for the target name.
this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index 677b1c666..ebc126823 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -3,22 +3,21 @@
#ifndef cmNinjaNormalTargetGenerator_h
#define cmNinjaNormalTargetGenerator_h
-#include "cmConfigure.h"
-
-#include "cmNinjaTargetGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-class cmGeneratorTarget;
+#include "cmGeneratorTarget.h"
+#include "cmNinjaTargetGenerator.h"
class cmNinjaNormalTargetGenerator : public cmNinjaTargetGenerator
{
public:
cmNinjaNormalTargetGenerator(cmGeneratorTarget* target);
- ~cmNinjaNormalTargetGenerator() CM_OVERRIDE;
+ ~cmNinjaNormalTargetGenerator() override;
- void Generate() CM_OVERRIDE;
+ void Generate() override;
private:
std::string LanguageLinkerRule() const;
@@ -40,11 +39,7 @@ private:
private:
// Target name info.
- std::string TargetNameOut;
- std::string TargetNameSO;
- std::string TargetNameReal;
- std::string TargetNameImport;
- std::string TargetNamePDB;
+ cmGeneratorTarget::Names TargetNames;
std::string TargetLinkLanguage;
std::string DeviceLinkObject;
};
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index d38dbcb09..0aab9127b 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -2,14 +2,17 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmNinjaTargetGenerator.h"
-#include "cm_jsoncpp_value.h"
-#include "cm_jsoncpp_writer.h"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
#include <iterator>
#include <map>
-#include <sstream>
-#include <string.h>
+#include <ostream>
+#include <utility>
+
+#include <cm/memory>
+
+#include "cm_jsoncpp_value.h"
+#include "cm_jsoncpp_writer.h"
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
@@ -24,15 +27,17 @@
#include "cmNinjaNormalTargetGenerator.h"
#include "cmNinjaUtilityTargetGenerator.h"
#include "cmOutputConverter.h"
+#include "cmRange.h"
#include "cmRulePlaceholderExpander.h"
#include "cmSourceFile.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
-cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
+std::unique_ptr<cmNinjaTargetGenerator> cmNinjaTargetGenerator::New(
+ cmGeneratorTarget* target)
{
switch (target->GetType()) {
case cmStateEnums::EXECUTABLE:
@@ -40,33 +45,28 @@ cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
case cmStateEnums::STATIC_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
case cmStateEnums::OBJECT_LIBRARY:
- return new cmNinjaNormalTargetGenerator(target);
+ return cm::make_unique<cmNinjaNormalTargetGenerator>(target);
case cmStateEnums::UTILITY:
case cmStateEnums::GLOBAL_TARGET:
- return new cmNinjaUtilityTargetGenerator(target);
+ return cm::make_unique<cmNinjaUtilityTargetGenerator>(target);
default:
- return CM_NULLPTR;
+ return std::unique_ptr<cmNinjaTargetGenerator>();
}
}
cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target)
: cmCommonTargetGenerator(target)
- , MacOSXContentGenerator(CM_NULLPTR)
- , OSXBundleGenerator(CM_NULLPTR)
- , MacContentFolders()
+ , MacOSXContentGenerator(nullptr)
+ , OSXBundleGenerator(nullptr)
, LocalGenerator(
static_cast<cmLocalNinjaGenerator*>(target->GetLocalGenerator()))
- , Objects()
{
- MacOSXContentGenerator = new MacOSXContentGeneratorType(this);
+ MacOSXContentGenerator = cm::make_unique<MacOSXContentGeneratorType>(this);
}
-cmNinjaTargetGenerator::~cmNinjaTargetGenerator()
-{
- delete this->MacOSXContentGenerator;
-}
+cmNinjaTargetGenerator::~cmNinjaTargetGenerator() = default;
cmGeneratedFileStream& cmNinjaTargetGenerator::GetBuildFileStream() const
{
@@ -103,6 +103,19 @@ bool cmNinjaTargetGenerator::NeedExplicitPreprocessing(
return lang == "Fortran";
}
+bool cmNinjaTargetGenerator::UsePreprocessedSource(
+ std::string const& lang) const
+{
+ return lang == "Fortran";
+}
+
+bool cmNinjaTargetGenerator::CompilePreprocessedSourceWithDefines(
+ std::string const& lang) const
+{
+ return this->Makefile->IsOn(
+ cmStrCat("CMAKE_", lang, "_COMPILE_WITH_DEFINES"));
+}
+
std::string cmNinjaTargetGenerator::LanguageDyndepRule(
const std::string& lang) const
{
@@ -128,6 +141,7 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(
cmSourceFile const* source, const std::string& language)
{
std::string flags = this->GetFlags(language);
+ const std::string configName = this->LocalGenerator->GetConfigName();
// Add Fortran format flags.
if (language == "Fortran") {
@@ -135,13 +149,37 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(
}
// Add source file specific flags.
- if (const char* cflags = source->GetProperty("COMPILE_FLAGS")) {
- std::string config = this->LocalGenerator->GetConfigName();
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(cflags);
- const char* evaluatedFlags = cge->Evaluate(this->LocalGenerator, config,
- false, this->GeneratorTarget);
- this->LocalGenerator->AppendFlags(flags, evaluatedFlags);
+ cmGeneratorExpressionInterpreter genexInterpreter(
+ this->LocalGenerator, configName, this->GeneratorTarget, language);
+
+ const std::string COMPILE_FLAGS("COMPILE_FLAGS");
+ if (const char* cflags = source->GetProperty(COMPILE_FLAGS)) {
+ this->LocalGenerator->AppendFlags(
+ flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS));
+ }
+
+ const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
+ if (const char* coptions = source->GetProperty(COMPILE_OPTIONS)) {
+ this->LocalGenerator->AppendCompileOptions(
+ flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS));
+ }
+
+ // Add precompile headers compile options.
+ const std::string pchSource =
+ this->GeneratorTarget->GetPchSource(configName, language);
+
+ if (!pchSource.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) {
+ std::string pchOptions;
+ if (source->GetFullPath() == pchSource) {
+ pchOptions = this->GeneratorTarget->GetPchCreateCompileOptions(
+ configName, language);
+ } else {
+ pchOptions =
+ this->GeneratorTarget->GetPchUseCompileOptions(configName, language);
+ }
+
+ this->LocalGenerator->AppendCompileOptions(
+ flags, genexInterpreter.Evaluate(pchOptions, COMPILE_OPTIONS));
}
return flags;
@@ -167,9 +205,28 @@ void cmNinjaTargetGenerator::AddIncludeFlags(std::string& languageFlags,
bool cmNinjaTargetGenerator::NeedDepTypeMSVC(const std::string& lang) const
{
- return strcmp(this->GetMakefile()->GetSafeDefinition("CMAKE_NINJA_DEPTYPE_" +
- lang),
- "msvc") == 0;
+ std::string const& deptype =
+ this->GetMakefile()->GetSafeDefinition("CMAKE_NINJA_DEPTYPE_" + lang);
+ if (deptype == "msvc") {
+ return true;
+ }
+ if (deptype == "intel") {
+ // Ninja does not really define "intel", but we use it to switch based
+ // on whether this environment supports "gcc" or "msvc" deptype.
+ if (!this->GetGlobalGenerator()->SupportsMultilineDepfile()) {
+ // This ninja version is too old to support the Intel depfile format.
+ // Fall back to msvc deptype.
+ return true;
+ }
+ if ((this->Makefile->GetHomeDirectory().find(' ') != std::string::npos) ||
+ (this->Makefile->GetHomeOutputDirectory().find(' ') !=
+ std::string::npos)) {
+ // The Intel compiler does not properly escape spaces in a depfile.
+ // Fall back to msvc deptype.
+ return true;
+ }
+ }
+ return false;
}
// TODO: Refactor with
@@ -178,13 +235,22 @@ std::string cmNinjaTargetGenerator::ComputeDefines(cmSourceFile const* source,
const std::string& language)
{
std::set<std::string> defines;
- this->LocalGenerator->AppendDefines(
- defines, source->GetProperty("COMPILE_DEFINITIONS"));
- {
- std::string defPropName = "COMPILE_DEFINITIONS_";
- defPropName += cmSystemTools::UpperCase(this->GetConfigName());
- this->LocalGenerator->AppendDefines(defines,
- source->GetProperty(defPropName));
+ const std::string config = this->LocalGenerator->GetConfigName();
+ cmGeneratorExpressionInterpreter genexInterpreter(
+ this->LocalGenerator, config, this->GeneratorTarget, language);
+
+ const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
+ if (const char* compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) {
+ this->LocalGenerator->AppendDefines(
+ defines, genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS));
+ }
+
+ std::string defPropName =
+ cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(config));
+ if (const char* config_compile_defs = source->GetProperty(defPropName)) {
+ this->LocalGenerator->AppendDefines(
+ defines,
+ genexInterpreter.Evaluate(config_compile_defs, COMPILE_DEFINITIONS));
}
std::string definesString = this->GetDefines(language);
@@ -193,7 +259,31 @@ std::string cmNinjaTargetGenerator::ComputeDefines(cmSourceFile const* source,
return definesString;
}
-cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
+std::string cmNinjaTargetGenerator::ComputeIncludes(
+ cmSourceFile const* source, const std::string& language)
+{
+ std::vector<std::string> includes;
+ const std::string config = this->LocalGenerator->GetConfigName();
+ cmGeneratorExpressionInterpreter genexInterpreter(
+ this->LocalGenerator, config, this->GeneratorTarget, language);
+
+ const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
+ if (const char* cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) {
+ this->LocalGenerator->AppendIncludeDirectories(
+ includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES),
+ *source);
+ }
+
+ std::string includesString = this->LocalGenerator->GetIncludeFlags(
+ includes, this->GeneratorTarget, language, true, false, config);
+ this->LocalGenerator->AppendFlags(includesString,
+ this->GetIncludes(language));
+
+ return includesString;
+}
+
+cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps(
+ const std::string& linkLanguage) const
{
// Static libraries never depend on other targets for linking.
if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY ||
@@ -215,29 +305,24 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
if (cmGeneratorTarget::ModuleDefinitionInfo const* mdi =
this->GeneratorTarget->GetModuleDefinitionInfo(
this->GetConfigName())) {
- for (std::vector<cmSourceFile const*>::const_iterator i =
- mdi->Sources.begin();
- i != mdi->Sources.end(); ++i) {
- result.push_back(this->ConvertToNinjaPath((*i)->GetFullPath()));
+ for (cmSourceFile const* src : mdi->Sources) {
+ result.push_back(this->ConvertToNinjaPath(src->GetFullPath()));
}
}
// Add a dependency on user-specified manifest files, if any.
std::vector<cmSourceFile const*> manifest_srcs;
this->GeneratorTarget->GetManifests(manifest_srcs, this->ConfigName);
- for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
- mi != manifest_srcs.end(); ++mi) {
- result.push_back(this->ConvertToNinjaPath((*mi)->GetFullPath()));
+ for (cmSourceFile const* manifest_src : manifest_srcs) {
+ result.push_back(this->ConvertToNinjaPath(manifest_src->GetFullPath()));
}
// Add user-specified dependencies.
- if (const char* linkDepends =
- this->GeneratorTarget->GetProperty("LINK_DEPENDS")) {
- std::vector<std::string> linkDeps;
- cmSystemTools::ExpandListArgument(linkDepends, linkDeps);
- std::transform(linkDeps.begin(), linkDeps.end(),
- std::back_inserter(result), MapToNinjaPath());
- }
+ std::vector<std::string> linkDeps;
+ this->GeneratorTarget->GetLinkDepends(linkDeps, this->ConfigName,
+ linkLanguage);
+ std::transform(linkDeps.begin(), linkDeps.end(), std::back_inserter(result),
+ MapToNinjaPath());
return result;
}
@@ -315,10 +400,10 @@ std::string cmNinjaTargetGenerator::GetDyndepFilePath(
std::string cmNinjaTargetGenerator::GetTargetDependInfoPath(
std::string const& lang) const
{
- std::string path = this->Makefile->GetCurrentBinaryDirectory();
- path += "/";
- path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- path += "/" + lang + "DependInfo.json";
+ std::string path =
+ cmStrCat(this->Makefile->GetCurrentBinaryDirectory(), '/',
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
+ '/', lang, "DependInfo.json");
return path;
}
@@ -357,9 +442,9 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY ||
this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) {
- pdbPath = this->GeneratorTarget->GetPDBDirectory(this->GetConfigName());
- pdbPath += "/";
- pdbPath += this->GeneratorTarget->GetPDBName(this->GetConfigName());
+ pdbPath = cmStrCat(
+ this->GeneratorTarget->GetPDBDirectory(this->GetConfigName()), '/',
+ this->GeneratorTarget->GetPDBName(this->GetConfigName()));
}
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
@@ -399,74 +484,28 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
vars.ObjectDir = "$OBJECT_DIR";
vars.ObjectFileDir = "$OBJECT_FILE_DIR";
+ cmMakefile* mf = this->GetMakefile();
+
// For some cases we do an explicit preprocessor invocation.
bool const explicitPP = this->NeedExplicitPreprocessing(lang);
+ bool const compilePPWithDefines = this->UsePreprocessedSource(lang) &&
+ this->CompilePreprocessedSourceWithDefines(lang);
bool const needDyndep = this->NeedDyndep(lang);
- cmMakefile* mf = this->GetMakefile();
-
std::string flags = "$FLAGS";
- std::string rspfile;
- std::string rspcontent;
- std::string responseFlag;
- bool const lang_supports_response = !(lang == "RC" || lang == "CUDA");
+ std::string responseFlag;
+ bool const lang_supports_response = lang != "RC";
if (lang_supports_response && this->ForceResponseFile()) {
- rspfile = "$RSP_FILE";
- responseFlag = "@" + rspfile;
- rspcontent = " $DEFINES $INCLUDES $FLAGS";
- flags = responseFlag;
- vars.Defines = "";
- vars.Includes = "";
- }
-
- // Tell ninja dependency format so all deps can be loaded into a database
- std::string deptype;
- std::string depfile;
- std::string cldeps;
- if (explicitPP) {
- // The explicit preprocessing step will handle dependency scanning.
- } else if (this->NeedDepTypeMSVC(lang)) {
- deptype = "msvc";
- depfile = "";
- flags += " /showIncludes";
- } else if (mf->IsOn("CMAKE_NINJA_CMCLDEPS_" + lang)) {
- // For the MS resource compiler we need cmcldeps, but skip dependencies
- // for source-file try_compile cases because they are always fresh.
- if (!mf->GetIsSourceFileTryCompile()) {
- deptype = "gcc";
- depfile = "$DEP_FILE";
- const std::string cl = mf->GetDefinition("CMAKE_C_COMPILER")
- ? mf->GetSafeDefinition("CMAKE_C_COMPILER")
- : mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
- cldeps = "\"";
- cldeps += cmSystemTools::GetCMClDepsCommand();
- cldeps += "\" " + lang + " " + vars.Source + " \"$DEP_FILE\" $out \"";
- cldeps += mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
- cldeps += "\" \"" + cl + "\" ";
- }
- } else {
- deptype = "gcc";
- const char* langdeptype = mf->GetDefinition("CMAKE_NINJA_DEPTYPE_" + lang);
- if (langdeptype) {
- deptype = langdeptype;
- }
- depfile = "$DEP_FILE";
- const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang;
- std::string depfileFlags = mf->GetSafeDefinition(flagsName);
- if (!depfileFlags.empty()) {
- cmSystemTools::ReplaceString(depfileFlags, "<DEPFILE>", "$DEP_FILE");
- cmSystemTools::ReplaceString(depfileFlags, "<OBJECT>", "$out");
- cmSystemTools::ReplaceString(depfileFlags, "<CMAKE_C_COMPILER>",
- mf->GetDefinition("CMAKE_C_COMPILER"));
- flags += " " + depfileFlags;
+ std::string const responseFlagVar =
+ "CMAKE_" + lang + "_RESPONSE_FILE_FLAG";
+ responseFlag = this->Makefile->GetSafeDefinition(responseFlagVar);
+ if (responseFlag.empty() && lang != "CUDA") {
+ responseFlag = "@";
}
}
- vars.Flags = flags.c_str();
- vars.DependencyFile = depfile.c_str();
-
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->GetLocalGenerator()->CreateRulePlaceholderExpander());
std::string const tdi = this->GetLocalGenerator()->ConvertToOutputFormat(
@@ -477,19 +516,18 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
const char* val = this->GetLocalGenerator()->GetRuleLauncher(
this->GetGeneratorTarget(), "RULE_LAUNCH_COMPILE");
if (val && *val) {
- launcher = val;
- launcher += " ";
+ launcher = cmStrCat(val, ' ');
}
- if (explicitPP) {
- // Lookup the explicit preprocessing rule.
- std::string const ppVar = "CMAKE_" + lang + "_PREPROCESS_SOURCE";
- std::string const ppCmd =
- this->GetMakefile()->GetRequiredDefinition(ppVar);
+ std::string const cmakeCmd =
+ this->GetLocalGenerator()->ConvertToOutputFormat(
+ cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
+ if (explicitPP) {
+ cmNinjaRule rule(this->LanguagePreprocessRule(lang));
// Explicit preprocessing always uses a depfile.
- std::string const ppDeptype; // no deps= for multiple outputs
- std::string const ppDepfile = "$DEP_FILE";
+ rule.DepType = ""; // no deps= for multiple outputs
+ rule.DepFile = "$DEP_FILE";
cmRulePlaceholderExpander::RuleVariables ppVars;
ppVars.CMTargetName = vars.CMTargetName;
@@ -497,7 +535,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
ppVars.Language = vars.Language;
ppVars.Object = "$out"; // for RULE_LAUNCH_COMPILE
ppVars.PreprocessedSource = "$out";
- ppVars.DependencyFile = ppDepfile.c_str();
+ ppVars.DependencyFile = rule.DepFile.c_str();
// Preprocessing uses the original source,
// compilation uses preprocessed output.
@@ -505,114 +543,172 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
vars.Source = "$in";
// Preprocessing and compilation use the same flags.
- ppVars.Flags = vars.Flags;
+ std::string ppFlags = flags;
- // Move preprocessor definitions to the preprocessor rule.
- ppVars.Defines = vars.Defines;
- vars.Defines = "";
+ if (!compilePPWithDefines) {
+ // Move preprocessor definitions to the preprocessor rule.
+ ppVars.Defines = vars.Defines;
+ vars.Defines = "";
+ } else {
+ // Copy preprocessor definitions to the preprocessor rule.
+ ppVars.Defines = vars.Defines;
+ }
// Copy include directories to the preprocessor rule. The Fortran
// compilation rule still needs them for the INCLUDE directive.
ppVars.Includes = vars.Includes;
+ // If using a response file, move defines, includes, and flags into it.
+ if (!responseFlag.empty()) {
+ rule.RspFile = "$RSP_FILE";
+ rule.RspContent =
+ cmStrCat(' ', ppVars.Defines, ' ', ppVars.Includes, ' ', ppFlags);
+ ppFlags = responseFlag + rule.RspFile;
+ ppVars.Defines = "";
+ ppVars.Includes = "";
+ }
+
+ ppVars.Flags = ppFlags.c_str();
+
// Rule for preprocessing source file.
std::vector<std::string> ppCmds;
- cmSystemTools::ExpandListArgument(ppCmd, ppCmds);
+ {
+ // Lookup the explicit preprocessing rule.
+ std::string ppVar = cmStrCat("CMAKE_", lang, "_PREPROCESS_SOURCE");
+ cmExpandList(this->GetMakefile()->GetRequiredDefinition(ppVar), ppCmds);
+ }
- for (std::vector<std::string>::iterator i = ppCmds.begin();
- i != ppCmds.end(); ++i) {
- *i = launcher + *i;
+ for (std::string& i : ppCmds) {
+ i = cmStrCat(launcher, i);
rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(),
- *i, ppVars);
+ i, ppVars);
}
// Run CMake dependency scanner on preprocessed output.
- std::string const cmake = this->GetLocalGenerator()->ConvertToOutputFormat(
- cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
- ppCmds.push_back(
- cmake + " -E cmake_ninja_depends"
- " --tdi=" +
- tdi + " --pp=$out"
- " --dep=$DEP_FILE" +
- (needDyndep ? " --obj=$OBJ_FILE --ddi=$DYNDEP_INTERMEDIATE_FILE" : ""));
-
- std::string const ppCmdLine =
- this->GetLocalGenerator()->BuildCommandLine(ppCmds);
+ {
+ std::string ccmd =
+ cmStrCat(cmakeCmd, " -E cmake_ninja_depends --tdi=", tdi,
+ " --lang=", lang, " --pp=$out --dep=$DEP_FILE");
+ if (needDyndep) {
+ ccmd += " --obj=$OBJ_FILE --ddi=$DYNDEP_INTERMEDIATE_FILE";
+ }
+ ppCmds.emplace_back(std::move(ccmd));
+ }
+ rule.Command = this->GetLocalGenerator()->BuildCommandLine(ppCmds);
// Write the rule for preprocessing file of the given language.
- std::ostringstream ppComment;
- ppComment << "Rule for preprocessing " << lang << " files.";
- std::ostringstream ppDesc;
- ppDesc << "Building " << lang << " preprocessed $out";
- this->GetGlobalGenerator()->AddRule(this->LanguagePreprocessRule(lang),
- ppCmdLine, ppDesc.str(),
- ppComment.str(), ppDepfile, ppDeptype,
- /*rspfile*/ "",
- /*rspcontent*/ "",
- /*restat*/ "",
- /*generator*/ false);
+ rule.Comment = cmStrCat("Rule for preprocessing ", lang, " files.");
+ rule.Description = cmStrCat("Building ", lang, " preprocessed $out");
+ this->GetGlobalGenerator()->AddRule(rule);
}
if (needDyndep) {
// Write the rule for ninja dyndep file generation.
- std::vector<std::string> ddCmds;
-
-#ifdef _WIN32
- // Windows command line length is limited -> use response file for dyndep
- // rules
- std::string ddRspFile = "$out.rsp";
- std::string ddRspContent = "$in";
- std::string ddInput = "@" + ddRspFile;
-#else
- std::string ddRspFile;
- std::string ddRspContent;
- std::string ddInput = "$in";
-#endif
+ cmNinjaRule rule(this->LanguageDyndepRule(lang));
+ // Command line length is almost always limited -> use response file for
+ // dyndep rules
+ rule.RspFile = "$out.rsp";
+ rule.RspContent = "$in";
+
+ // Run CMake dependency scanner on the source file (using the preprocessed
+ // source if that was performed).
+ {
+ std::vector<std::string> ddCmds;
+ {
+ std::string ccmd =
+ cmStrCat(cmakeCmd, " -E cmake_ninja_dyndep --tdi=", tdi,
+ " --lang=", lang, " --dd=$out @", rule.RspFile);
+ ddCmds.emplace_back(std::move(ccmd));
+ }
+ rule.Command = this->GetLocalGenerator()->BuildCommandLine(ddCmds);
+ }
+ rule.Comment =
+ cmStrCat("Rule to generate ninja dyndep files for ", lang, '.');
+ rule.Description = cmStrCat("Generating ", lang, " dyndep file $out");
+ this->GetGlobalGenerator()->AddRule(rule);
+ }
- // Run CMake dependency scanner on preprocessed output.
- std::string const cmake = this->GetLocalGenerator()->ConvertToOutputFormat(
- cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL);
- ddCmds.push_back(cmake + " -E cmake_ninja_dyndep"
- " --tdi=" +
- tdi + " --dd=$out"
- " " +
- ddInput);
-
- std::string const ddCmdLine =
- this->GetLocalGenerator()->BuildCommandLine(ddCmds);
-
- std::ostringstream ddComment;
- ddComment << "Rule to generate ninja dyndep files for " << lang << ".";
- std::ostringstream ddDesc;
- ddDesc << "Generating " << lang << " dyndep file $out";
- this->GetGlobalGenerator()->AddRule(
- this->LanguageDyndepRule(lang), ddCmdLine, ddDesc.str(), ddComment.str(),
- /*depfile*/ "",
- /*deps*/ "", ddRspFile, ddRspContent,
- /*restat*/ "",
- /*generator*/ false);
+ cmNinjaRule rule(this->LanguageCompilerRule(lang));
+ // If using a response file, move defines, includes, and flags into it.
+ if (!responseFlag.empty()) {
+ rule.RspFile = "$RSP_FILE";
+ rule.RspContent =
+ cmStrCat(' ', vars.Defines, ' ', vars.Includes, ' ', flags);
+ flags = responseFlag + rule.RspFile;
+ vars.Defines = "";
+ vars.Includes = "";
}
+ // Tell ninja dependency format so all deps can be loaded into a database
+ std::string cldeps;
+ if (explicitPP) {
+ // The explicit preprocessing step will handle dependency scanning.
+ } else if (this->NeedDepTypeMSVC(lang)) {
+ rule.DepType = "msvc";
+ rule.DepFile.clear();
+ flags += " /showIncludes";
+ } else if (mf->IsOn("CMAKE_NINJA_CMCLDEPS_" + lang)) {
+ // For the MS resource compiler we need cmcldeps, but skip dependencies
+ // for source-file try_compile cases because they are always fresh.
+ if (!mf->GetIsSourceFileTryCompile()) {
+ rule.DepType = "gcc";
+ rule.DepFile = "$DEP_FILE";
+ const std::string cl = mf->GetDefinition("CMAKE_C_COMPILER")
+ ? mf->GetSafeDefinition("CMAKE_C_COMPILER")
+ : mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
+ cldeps = cmStrCat('"', cmSystemTools::GetCMClDepsCommand(), "\" ", lang,
+ ' ', vars.Source, " $DEP_FILE $out \"",
+ mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX"),
+ "\" \"", cl, "\" ");
+ }
+ } else {
+ rule.DepType = "gcc";
+ rule.DepFile = "$DEP_FILE";
+ const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang;
+ std::string depfileFlags = mf->GetSafeDefinition(flagsName);
+ if (!depfileFlags.empty()) {
+ cmSystemTools::ReplaceString(depfileFlags, "<DEPFILE>", "$DEP_FILE");
+ cmSystemTools::ReplaceString(depfileFlags, "<OBJECT>", "$out");
+ cmSystemTools::ReplaceString(depfileFlags, "<CMAKE_C_COMPILER>",
+ mf->GetDefinition("CMAKE_C_COMPILER"));
+ flags += " " + depfileFlags;
+ }
+ }
+
+ vars.Flags = flags.c_str();
+ vars.DependencyFile = rule.DepFile.c_str();
+
// Rule for compiling object file.
std::vector<std::string> compileCmds;
if (lang == "CUDA") {
std::string cmdVar;
if (this->GeneratorTarget->GetPropertyAsBool(
"CUDA_SEPARABLE_COMPILATION")) {
- cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION");
+ cmdVar = "CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION";
} else if (this->GeneratorTarget->GetPropertyAsBool(
"CUDA_PTX_COMPILATION")) {
- cmdVar = std::string("CMAKE_CUDA_COMPILE_PTX_COMPILATION");
+ cmdVar = "CMAKE_CUDA_COMPILE_PTX_COMPILATION";
} else {
- cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION");
+ cmdVar = "CMAKE_CUDA_COMPILE_WHOLE_COMPILATION";
}
- std::string compileCmd = mf->GetRequiredDefinition(cmdVar);
- cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
+ const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar);
+ cmExpandList(compileCmd, compileCmds);
} else {
- const std::string cmdVar =
- std::string("CMAKE_") + lang + "_COMPILE_OBJECT";
- std::string compileCmd = mf->GetRequiredDefinition(cmdVar);
- cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
+ const std::string cmdVar = "CMAKE_" + lang + "_COMPILE_OBJECT";
+ const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar);
+ cmExpandList(compileCmd, compileCmds);
+ }
+
+ // See if we need to use a compiler launcher like ccache or distcc
+ std::string compilerLauncher;
+ if (!compileCmds.empty() &&
+ (lang == "C" || lang == "CXX" || lang == "Fortran" || lang == "CUDA" ||
+ lang == "OBJC" || lang == "OBJCXX")) {
+ std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
+ const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
+ if (clauncher && *clauncher) {
+ compilerLauncher = clauncher;
+ }
}
// Maybe insert an include-what-you-use runner.
@@ -623,10 +719,18 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
const char* tidy = this->GeneratorTarget->GetProperty(tidy_prop);
std::string const cpplint_prop = lang + "_CPPLINT";
const char* cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
- if ((iwyu && *iwyu) || (tidy && *tidy) || (cpplint && *cpplint)) {
- std::string run_iwyu = this->GetLocalGenerator()->ConvertToOutputFormat(
- cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
- run_iwyu += " -E __run_iwyu";
+ std::string const cppcheck_prop = lang + "_CPPCHECK";
+ const char* cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
+ if ((iwyu && *iwyu) || (tidy && *tidy) || (cpplint && *cpplint) ||
+ (cppcheck && *cppcheck)) {
+ std::string run_iwyu = cmStrCat(cmakeCmd, " -E __run_co_compile");
+ if (!compilerLauncher.empty()) {
+ // In __run_co_compile case the launcher command is supplied
+ // via --launcher=<maybe-list> and consumed
+ run_iwyu += " --launcher=";
+ run_iwyu += this->LocalGenerator->EscapeForShell(compilerLauncher);
+ compilerLauncher.clear();
+ }
if (iwyu && *iwyu) {
run_iwyu += " --iwyu=";
run_iwyu += this->GetLocalGenerator()->EscapeForShell(iwyu);
@@ -639,7 +743,12 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
run_iwyu += " --cpplint=";
run_iwyu += this->GetLocalGenerator()->EscapeForShell(cpplint);
}
- if ((tidy && *tidy) || (cpplint && *cpplint)) {
+ if (cppcheck && *cppcheck) {
+ run_iwyu += " --cppcheck=";
+ run_iwyu += this->GetLocalGenerator()->EscapeForShell(cppcheck);
+ }
+ if ((tidy && *tidy) || (cpplint && *cpplint) ||
+ (cppcheck && *cppcheck)) {
run_iwyu += " --source=$in";
}
run_iwyu += " -- ";
@@ -647,47 +756,36 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
}
}
- // Maybe insert a compiler launcher like ccache or distcc
- if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) {
- std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
- const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
- if (clauncher && *clauncher) {
- std::vector<std::string> launcher_cmd;
- cmSystemTools::ExpandListArgument(clauncher, launcher_cmd, true);
- for (std::vector<std::string>::iterator i = launcher_cmd.begin(),
- e = launcher_cmd.end();
- i != e; ++i) {
- *i = this->LocalGenerator->EscapeForShell(*i);
+ // If compiler launcher was specified and not consumed above, it
+ // goes to the beginning of the command line.
+ if (!compileCmds.empty() && !compilerLauncher.empty()) {
+ std::vector<std::string> args = cmExpandedList(compilerLauncher, true);
+ if (!args.empty()) {
+ args[0] = this->LocalGenerator->ConvertToOutputFormat(
+ args[0], cmOutputConverter::SHELL);
+ for (std::string& i : cmMakeRange(args.begin() + 1, args.end())) {
+ i = this->LocalGenerator->EscapeForShell(i);
}
- std::string const& run_launcher = cmJoin(launcher_cmd, " ") + " ";
- compileCmds.front().insert(0, run_launcher);
}
+ compileCmds.front().insert(0, cmJoin(args, " ") + " ");
}
if (!compileCmds.empty()) {
compileCmds.front().insert(0, cldeps);
}
- for (std::vector<std::string>::iterator i = compileCmds.begin();
- i != compileCmds.end(); ++i) {
- *i = launcher + *i;
- rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), *i,
+ for (std::string& i : compileCmds) {
+ i = cmStrCat(launcher, i);
+ rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), i,
vars);
}
- std::string cmdLine =
- this->GetLocalGenerator()->BuildCommandLine(compileCmds);
+ rule.Command = this->GetLocalGenerator()->BuildCommandLine(compileCmds);
// Write the rule for compiling file of the given language.
- std::ostringstream comment;
- comment << "Rule for compiling " << lang << " files.";
- std::ostringstream description;
- description << "Building " << lang << " object $out";
- this->GetGlobalGenerator()->AddRule(
- this->LanguageCompilerRule(lang), cmdLine, description.str(),
- comment.str(), depfile, deptype, rspfile, rspcontent,
- /*restat*/ "",
- /*generator*/ false);
+ rule.Comment = cmStrCat("Rule for compiling ", lang, " files.");
+ rule.Description = cmStrCat("Building ", lang, " object $out");
+ this->GetGlobalGenerator()->AddRule(rule);
}
void cmNinjaTargetGenerator::WriteObjectBuildStatements()
@@ -699,109 +797,144 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
<< cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType())
<< " target " << this->GetTargetName() << "\n\n";
- std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- std::vector<cmSourceFile const*> customCommands;
- this->GeneratorTarget->GetCustomCommands(customCommands, config);
- for (std::vector<cmSourceFile const*>::const_iterator si =
- customCommands.begin();
- si != customCommands.end(); ++si) {
- cmCustomCommand const* cc = (*si)->GetCustomCommand();
- this->GetLocalGenerator()->AddCustomCommandTarget(
- cc, this->GetGeneratorTarget());
- // Record the custom commands for this target. The container is used
- // in WriteObjectBuildStatement when called in a loop below.
- this->CustomCommands.push_back(cc);
+ {
+ std::vector<cmSourceFile const*> customCommands;
+ this->GeneratorTarget->GetCustomCommands(customCommands, this->ConfigName);
+ for (cmSourceFile const* sf : customCommands) {
+ cmCustomCommand const* cc = sf->GetCustomCommand();
+ this->GetLocalGenerator()->AddCustomCommandTarget(
+ cc, this->GetGeneratorTarget());
+ // Record the custom commands for this target. The container is used
+ // in WriteObjectBuildStatement when called in a loop below.
+ this->CustomCommands.push_back(cc);
+ }
}
- std::vector<cmSourceFile const*> headerSources;
- this->GeneratorTarget->GetHeaderSources(headerSources, config);
- this->OSXBundleGenerator->GenerateMacOSXContentStatements(
- headerSources, this->MacOSXContentGenerator);
- std::vector<cmSourceFile const*> extraSources;
- this->GeneratorTarget->GetExtraSources(extraSources, config);
- this->OSXBundleGenerator->GenerateMacOSXContentStatements(
- extraSources, this->MacOSXContentGenerator);
- std::vector<cmSourceFile const*> externalObjects;
- this->GeneratorTarget->GetExternalObjects(externalObjects, config);
- for (std::vector<cmSourceFile const*>::const_iterator si =
- externalObjects.begin();
- si != externalObjects.end(); ++si) {
- this->Objects.push_back(this->GetSourceFilePath(*si));
+ {
+ std::vector<cmSourceFile const*> headerSources;
+ this->GeneratorTarget->GetHeaderSources(headerSources, this->ConfigName);
+ this->OSXBundleGenerator->GenerateMacOSXContentStatements(
+ headerSources, this->MacOSXContentGenerator.get());
}
-
- cmNinjaDeps orderOnlyDeps;
- this->GetLocalGenerator()->AppendTargetDepends(
- this->GeneratorTarget, orderOnlyDeps, DependOnTargetOrdering);
-
- // Add order-only dependencies on other files associated with the target.
- orderOnlyDeps.insert(orderOnlyDeps.end(), this->ExtraFiles.begin(),
- this->ExtraFiles.end());
-
- // Add order-only dependencies on custom command outputs.
- for (std::vector<cmCustomCommand const*>::const_iterator cci =
- this->CustomCommands.begin();
- cci != this->CustomCommands.end(); ++cci) {
- cmCustomCommand const* cc = *cci;
- cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
- this->GetLocalGenerator());
- const std::vector<std::string>& ccoutputs = ccg.GetOutputs();
- const std::vector<std::string>& ccbyproducts = ccg.GetByproducts();
- std::transform(ccoutputs.begin(), ccoutputs.end(),
- std::back_inserter(orderOnlyDeps), MapToNinjaPath());
- std::transform(ccbyproducts.begin(), ccbyproducts.end(),
- std::back_inserter(orderOnlyDeps), MapToNinjaPath());
+ {
+ std::vector<cmSourceFile const*> extraSources;
+ this->GeneratorTarget->GetExtraSources(extraSources, this->ConfigName);
+ this->OSXBundleGenerator->GenerateMacOSXContentStatements(
+ extraSources, this->MacOSXContentGenerator.get());
+ }
+ {
+ const char* pchExtension =
+ GetMakefile()->GetDefinition("CMAKE_PCH_EXTENSION");
+
+ std::vector<cmSourceFile const*> externalObjects;
+ this->GeneratorTarget->GetExternalObjects(externalObjects,
+ this->ConfigName);
+ for (cmSourceFile const* sf : externalObjects) {
+ const auto objectFileName = this->GetSourceFilePath(sf);
+ if (!cmSystemTools::StringEndsWith(objectFileName, pchExtension)) {
+ this->Objects.push_back(objectFileName);
+ }
+ }
}
-
- std::sort(orderOnlyDeps.begin(), orderOnlyDeps.end());
- orderOnlyDeps.erase(std::unique(orderOnlyDeps.begin(), orderOnlyDeps.end()),
- orderOnlyDeps.end());
{
- cmNinjaDeps orderOnlyTarget;
- orderOnlyTarget.push_back(this->OrderDependsTargetForTarget());
- this->GetGlobalGenerator()->WritePhonyBuild(
- this->GetBuildFileStream(),
- "Order-only phony target for " + this->GetTargetName(), orderOnlyTarget,
- cmNinjaDeps(), cmNinjaDeps(), orderOnlyDeps);
+ cmNinjaBuild build("phony");
+ build.Comment = "Order-only phony target for " + this->GetTargetName();
+ build.Outputs.push_back(this->OrderDependsTargetForTarget());
+
+ cmNinjaDeps& orderOnlyDeps = build.OrderOnlyDeps;
+ this->GetLocalGenerator()->AppendTargetDepends(
+ this->GeneratorTarget, orderOnlyDeps, DependOnTargetOrdering);
+
+ // Add order-only dependencies on other files associated with the target.
+ cmAppend(orderOnlyDeps, this->ExtraFiles);
+
+ // Add order-only dependencies on custom command outputs.
+ for (cmCustomCommand const* cc : this->CustomCommands) {
+ cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
+ this->GetLocalGenerator());
+ const std::vector<std::string>& ccoutputs = ccg.GetOutputs();
+ const std::vector<std::string>& ccbyproducts = ccg.GetByproducts();
+ std::transform(ccoutputs.begin(), ccoutputs.end(),
+ std::back_inserter(orderOnlyDeps), MapToNinjaPath());
+ std::transform(ccbyproducts.begin(), ccbyproducts.end(),
+ std::back_inserter(orderOnlyDeps), MapToNinjaPath());
+ }
+
+ std::sort(orderOnlyDeps.begin(), orderOnlyDeps.end());
+ orderOnlyDeps.erase(
+ std::unique(orderOnlyDeps.begin(), orderOnlyDeps.end()),
+ orderOnlyDeps.end());
+
+ // The phony target must depend on at least one input or ninja will explain
+ // that "output ... of phony edge with no inputs doesn't exist" and
+ // consider the phony output "dirty".
+ if (orderOnlyDeps.empty()) {
+ // Any path that always exists will work here. It would be nice to
+ // use just "." but that is not supported by Ninja < 1.7.
+ std::string tgtDir = cmStrCat(
+ this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget));
+ orderOnlyDeps.push_back(this->ConvertToNinjaPath(tgtDir));
+ }
+
+ this->GetGlobalGenerator()->WriteBuild(this->GetBuildFileStream(), build);
}
- std::vector<cmSourceFile const*> objectSources;
- this->GeneratorTarget->GetObjectSources(objectSources, config);
- for (std::vector<cmSourceFile const*>::const_iterator si =
- objectSources.begin();
- si != objectSources.end(); ++si) {
- this->WriteObjectBuildStatement(*si);
+
+ {
+ std::vector<cmSourceFile const*> objectSources;
+ this->GeneratorTarget->GetObjectSources(objectSources, this->ConfigName);
+ for (cmSourceFile const* sf : objectSources) {
+ this->WriteObjectBuildStatement(sf);
+ }
}
- if (!this->DDIFiles.empty()) {
- std::string const ddComment;
- std::string const ddRule = this->LanguageDyndepRule("Fortran");
- cmNinjaDeps ddOutputs;
- cmNinjaDeps ddImplicitOuts;
- cmNinjaDeps const& ddExplicitDeps = this->DDIFiles;
- cmNinjaDeps ddImplicitDeps;
- cmNinjaDeps ddOrderOnlyDeps;
- cmNinjaVars ddVars;
+ for (auto const& langDDIFiles : this->DDIFiles) {
+ std::string const& language = langDDIFiles.first;
+ cmNinjaDeps const& ddiFiles = langDDIFiles.second;
- this->WriteTargetDependInfo("Fortran");
+ cmNinjaBuild build(this->LanguageDyndepRule(language));
+ build.Outputs.push_back(this->GetDyndepFilePath(language));
+ build.ExplicitDeps = ddiFiles;
- ddOutputs.push_back(this->GetDyndepFilePath("Fortran"));
+ this->WriteTargetDependInfo(language);
// Make sure dyndep files for all our dependencies have already
- // been generated so that the 'FortranModules.json' files they
+ // been generated so that the '<LANG>Modules.json' files they
// produced as side-effects are available for us to read.
- // Ideally we should depend on the 'FortranModules.json' files
+ // Ideally we should depend on the '<LANG>Modules.json' files
// from our dependencies directly, but we don't know which of
// our dependencies produces them. Fixing this will require
// refactoring the Ninja generator to generate targets in
// dependency order so that we can collect the needed information.
this->GetLocalGenerator()->AppendTargetDepends(
- this->GeneratorTarget, ddOrderOnlyDeps, DependOnTargetArtifact);
+ this->GeneratorTarget, build.OrderOnlyDeps, DependOnTargetArtifact);
- this->GetGlobalGenerator()->WriteBuild(
- this->GetBuildFileStream(), ddComment, ddRule, ddOutputs, ddImplicitOuts,
- ddExplicitDeps, ddImplicitDeps, ddOrderOnlyDeps, ddVars);
+ this->GetGlobalGenerator()->WriteBuild(this->GetBuildFileStream(), build);
}
this->GetBuildFileStream() << "\n";
+
+ if (!this->SwiftOutputMap.empty()) {
+ std::string const mapFilePath =
+ this->GeneratorTarget->GetSupportDirectory() + "/output-file-map.json";
+ std::string const targetSwiftDepsPath = [this]() -> std::string {
+ cmGeneratorTarget const* target = this->GeneratorTarget;
+ if (const char* name = target->GetProperty("Swift_DEPENDENCIES_FILE")) {
+ return name;
+ }
+ return this->ConvertToNinjaPath(target->GetSupportDirectory() + "/" +
+ target->GetName() + ".swiftdeps");
+ }();
+
+ // build the global target dependencies
+ // https://github.com/apple/swift/blob/master/docs/Driver.md#output-file-maps
+ Json::Value deps(Json::objectValue);
+ deps["swift-dependencies"] = targetSwiftDepsPath;
+ this->SwiftOutputMap[""] = deps;
+
+ cmGeneratedFileStream output(mapFilePath);
+ output << this->SwiftOutputMap;
+ }
}
void cmNinjaTargetGenerator::WriteObjectBuildStatement(
@@ -817,55 +950,102 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
std::string const objectFileDir =
cmSystemTools::GetFilenamePath(objectFileName);
- cmNinjaVars vars;
+ std::string cmakeVarLang = cmStrCat("CMAKE_", language);
+
+ // build response file name
+ std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_FLAG";
+
+ const char* flag = GetMakefile()->GetDefinition(cmakeLinkVar);
+
+ bool const lang_supports_response =
+ !(language == "RC" || (language == "CUDA" && !flag));
+ int const commandLineLengthLimit =
+ ((lang_supports_response && this->ForceResponseFile())) ? -1 : 0;
+
+ cmNinjaBuild objBuild(this->LanguageCompilerRule(language));
+ cmNinjaVars& vars = objBuild.Variables;
vars["FLAGS"] = this->ComputeFlagsForObject(source, language);
vars["DEFINES"] = this->ComputeDefines(source, language);
- vars["INCLUDES"] = this->GetIncludes(language);
+ vars["INCLUDES"] = this->ComputeIncludes(source, language);
+
if (!this->NeedDepTypeMSVC(language)) {
- vars["DEP_FILE"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- objectFileName + ".d", cmOutputConverter::SHELL);
+ bool replaceExt(false);
+ if (!language.empty()) {
+ std::string repVar =
+ cmStrCat("CMAKE_", language, "_DEPFILE_EXTENSION_REPLACE");
+ replaceExt = this->Makefile->IsOn(repVar);
+ }
+ if (!replaceExt) {
+ // use original code
+ vars["DEP_FILE"] = this->GetLocalGenerator()->ConvertToOutputFormat(
+ objectFileName + ".d", cmOutputConverter::SHELL);
+ } else {
+ // Replace the original source file extension with the
+ // depend file extension.
+ std::string dependFileName =
+ cmSystemTools::GetFilenameWithoutLastExtension(objectFileName) + ".d";
+ vars["DEP_FILE"] = this->GetLocalGenerator()->ConvertToOutputFormat(
+ objectFileDir + "/" + dependFileName, cmOutputConverter::SHELL);
+ }
}
this->ExportObjectCompileCommand(
language, sourceFileName, objectDir, objectFileName, objectFileDir,
vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"]);
- std::string comment;
- std::string rule = this->LanguageCompilerRule(language);
+ objBuild.Outputs.push_back(objectFileName);
+ const char* pchExtension =
+ this->GetMakefile()->GetDefinition("CMAKE_PCH_EXTENSION");
+ if (!cmSystemTools::StringEndsWith(objectFileName, pchExtension)) {
+ // Add this object to the list of object files.
+ this->Objects.push_back(objectFileName);
+ }
- cmNinjaDeps outputs;
- outputs.push_back(objectFileName);
- // Add this object to the list of object files.
- this->Objects.push_back(objectFileName);
+ objBuild.ExplicitDeps.push_back(sourceFileName);
- cmNinjaDeps explicitDeps;
- explicitDeps.push_back(sourceFileName);
+ // Add precompile headers dependencies
+ std::vector<std::string> depList;
+
+ const std::string pchSource =
+ this->GeneratorTarget->GetPchSource(this->GetConfigName(), language);
+ if (!pchSource.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) {
+ depList.push_back(
+ this->GeneratorTarget->GetPchHeader(this->GetConfigName(), language));
+ if (source->GetFullPath() != pchSource) {
+ depList.push_back(
+ this->GeneratorTarget->GetPchFile(this->GetConfigName(), language));
+ }
+ }
- cmNinjaDeps implicitDeps;
if (const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) {
- std::vector<std::string> depList;
- cmSystemTools::ExpandListArgument(objectDeps, depList);
- for (std::vector<std::string>::iterator odi = depList.begin();
- odi != depList.end(); ++odi) {
- if (cmSystemTools::FileIsFullPath(*odi)) {
- *odi = cmSystemTools::CollapseFullPath(*odi);
+ std::vector<std::string> objDepList = cmExpandedList(objectDeps);
+ std::copy(objDepList.begin(), objDepList.end(),
+ std::back_inserter(depList));
+ }
+
+ if (!depList.empty()) {
+ for (std::string& odi : depList) {
+ if (cmSystemTools::FileIsFullPath(odi)) {
+ odi = cmSystemTools::CollapseFullPath(odi);
}
}
std::transform(depList.begin(), depList.end(),
- std::back_inserter(implicitDeps), MapToNinjaPath());
+ std::back_inserter(objBuild.ImplicitDeps),
+ MapToNinjaPath());
}
- cmNinjaDeps orderOnlyDeps;
- orderOnlyDeps.push_back(this->OrderDependsTargetForTarget());
+ objBuild.OrderOnlyDeps.push_back(this->OrderDependsTargetForTarget());
// If the source file is GENERATED and does not have a custom command
// (either attached to this source file or another one), assume that one of
// the target dependencies, OBJECT_DEPENDS or header file custom commands
// will rebuild the file.
- if (source->GetPropertyAsBool("GENERATED") && !source->GetCustomCommand() &&
+ if (source->GetIsGenerated() &&
+ !source->GetPropertyAsBool("__CMAKE_GENERATED_BY_CMAKE") &&
+ !source->GetCustomCommand() &&
!this->GetGlobalGenerator()->HasCustomCommandOutput(sourceFileName)) {
- this->GetGlobalGenerator()->AddAssumedSourceDependencies(sourceFileName,
- orderOnlyDeps);
+ this->GetGlobalGenerator()->AddAssumedSourceDependencies(
+ sourceFileName, objBuild.OrderOnlyDeps);
}
// For some cases we need to generate a ninja dyndep file.
@@ -874,80 +1054,103 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
// For some cases we do an explicit preprocessor invocation.
bool const explicitPP = this->NeedExplicitPreprocessing(language);
if (explicitPP) {
- std::string const ppComment;
- std::string const ppRule = this->LanguagePreprocessRule(language);
- cmNinjaDeps ppOutputs;
- cmNinjaDeps ppImplicitOuts;
- cmNinjaDeps ppExplicitDeps;
- cmNinjaDeps ppImplicitDeps;
- cmNinjaDeps ppOrderOnlyDeps;
- cmNinjaVars ppVars;
+ cmNinjaBuild ppBuild(this->LanguagePreprocessRule(language));
std::string const ppFileName =
this->ConvertToNinjaPath(this->GetPreprocessedFilePath(source));
- ppOutputs.push_back(ppFileName);
-
- // Move compilation dependencies to the preprocessing build statement.
- std::swap(ppExplicitDeps, explicitDeps);
- std::swap(ppImplicitDeps, implicitDeps);
- std::swap(ppOrderOnlyDeps, orderOnlyDeps);
- std::swap(ppVars["IN_ABS"], vars["IN_ABS"]);
+ ppBuild.Outputs.push_back(ppFileName);
+
+ ppBuild.RspFile = ppFileName + ".rsp";
+
+ bool const compilePP = this->UsePreprocessedSource(language);
+ bool const compilePPWithDefines =
+ compilePP && this->CompilePreprocessedSourceWithDefines(language);
+ if (compilePP) {
+ // Move compilation dependencies to the preprocessing build statement.
+ std::swap(ppBuild.ExplicitDeps, objBuild.ExplicitDeps);
+ std::swap(ppBuild.ImplicitDeps, objBuild.ImplicitDeps);
+ std::swap(ppBuild.OrderOnlyDeps, objBuild.OrderOnlyDeps);
+ std::swap(ppBuild.Variables["IN_ABS"], vars["IN_ABS"]);
+
+ // The actual compilation will now use the preprocessed source.
+ objBuild.ExplicitDeps.push_back(ppFileName);
+ } else {
+ // Copy compilation dependencies to the preprocessing build statement.
+ ppBuild.ExplicitDeps = objBuild.ExplicitDeps;
+ ppBuild.ImplicitDeps = objBuild.ImplicitDeps;
+ ppBuild.OrderOnlyDeps = objBuild.OrderOnlyDeps;
+ ppBuild.Variables["IN_ABS"] = vars["IN_ABS"];
+ }
- // The actual compilation will now use the preprocessed source.
- explicitDeps.push_back(ppFileName);
+ // Preprocessing and compilation generally use the same flags.
+ ppBuild.Variables["FLAGS"] = vars["FLAGS"];
- // Preprocessing and compilation use the same flags.
- ppVars["FLAGS"] = vars["FLAGS"];
+ if (compilePP) {
+ // In case compilation requires flags that are incompatible with
+ // preprocessing, include them here.
+ std::string const& postFlag = this->Makefile->GetSafeDefinition(
+ "CMAKE_" + language + "_POSTPROCESS_FLAG");
+ this->LocalGenerator->AppendFlags(vars["FLAGS"], postFlag);
+ }
- // Move preprocessor definitions to the preprocessor build statement.
- std::swap(ppVars["DEFINES"], vars["DEFINES"]);
+ if (compilePP && !compilePPWithDefines) {
+ // Move preprocessor definitions to the preprocessor build statement.
+ std::swap(ppBuild.Variables["DEFINES"], vars["DEFINES"]);
+ } else {
+ // Copy preprocessor definitions to the preprocessor build statement.
+ ppBuild.Variables["DEFINES"] = vars["DEFINES"];
+ }
// Copy include directories to the preprocessor build statement. The
// Fortran compilation build statement still needs them for the INCLUDE
// directive.
- ppVars["INCLUDES"] = vars["INCLUDES"];
+ ppBuild.Variables["INCLUDES"] = vars["INCLUDES"];
- // Prepend source file's original directory as an include directory
- // so e.g. Fortran INCLUDE statements can look for files in it.
- std::vector<std::string> sourceDirectory;
- sourceDirectory.push_back(
- cmSystemTools::GetParentDirectory(source->GetFullPath()));
+ if (compilePP) {
+ // Prepend source file's original directory as an include directory
+ // so e.g. Fortran INCLUDE statements can look for files in it.
+ std::vector<std::string> sourceDirectory;
+ sourceDirectory.push_back(
+ cmSystemTools::GetParentDirectory(source->GetFullPath()));
- std::string sourceDirectoryFlag = this->LocalGenerator->GetIncludeFlags(
- sourceDirectory, this->GeneratorTarget, language, false, false,
- this->GetConfigName());
+ std::string sourceDirectoryFlag = this->LocalGenerator->GetIncludeFlags(
+ sourceDirectory, this->GeneratorTarget, language, false, false,
+ this->GetConfigName());
- vars["INCLUDES"] = sourceDirectoryFlag + " " + vars["INCLUDES"];
+ vars["INCLUDES"] = sourceDirectoryFlag + " " + vars["INCLUDES"];
+ }
// Explicit preprocessing always uses a depfile.
- ppVars["DEP_FILE"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- ppFileName + ".d", cmOutputConverter::SHELL);
- // The actual compilation does not need a depfile because it
- // depends on the already-preprocessed source.
- vars.erase("DEP_FILE");
+ ppBuild.Variables["DEP_FILE"] =
+ this->GetLocalGenerator()->ConvertToOutputFormat(
+ objectFileName + ".pp.d", cmOutputConverter::SHELL);
+ if (compilePP) {
+ // The actual compilation does not need a depfile because it
+ // depends on the already-preprocessed source.
+ vars.erase("DEP_FILE");
+ }
if (needDyndep) {
// Tell dependency scanner the object file that will result from
- // compiling the preprocessed source.
- ppVars["OBJ_FILE"] = objectFileName;
+ // compiling the source.
+ ppBuild.Variables["OBJ_FILE"] = objectFileName;
// Tell dependency scanner where to store dyndep intermediate results.
- std::string const ddiFile = ppFileName + ".ddi";
- ppVars["DYNDEP_INTERMEDIATE_FILE"] = ddiFile;
- ppImplicitOuts.push_back(ddiFile);
- this->DDIFiles.push_back(ddiFile);
+ std::string const ddiFile = objectFileName + ".ddi";
+ ppBuild.Variables["DYNDEP_INTERMEDIATE_FILE"] = ddiFile;
+ ppBuild.ImplicitOuts.push_back(ddiFile);
+ this->DDIFiles[language].push_back(ddiFile);
}
this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetGeneratorTarget(),
- ppVars);
+ ppBuild.Variables);
- this->GetGlobalGenerator()->WriteBuild(
- this->GetBuildFileStream(), ppComment, ppRule, ppOutputs, ppImplicitOuts,
- ppExplicitDeps, ppImplicitDeps, ppOrderOnlyDeps, ppVars);
+ this->GetGlobalGenerator()->WriteBuild(this->GetBuildFileStream(), ppBuild,
+ commandLineLengthLimit);
}
if (needDyndep) {
std::string const dyndep = this->GetDyndepFilePath(language);
- orderOnlyDeps.push_back(dyndep);
+ objBuild.OrderOnlyDeps.push_back(dyndep);
vars["dyndep"] = dyndep;
}
@@ -963,25 +1166,23 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
this->SetMsvcTargetPdbVariable(vars);
- bool const lang_supports_response =
- !(language == "RC" || language == "CUDA");
- int const commandLineLengthLimit =
- ((lang_supports_response && this->ForceResponseFile())) ? -1 : 0;
- std::string const rspfile = objectFileName + ".rsp";
+ objBuild.RspFile = objectFileName + ".rsp";
- this->GetGlobalGenerator()->WriteBuild(
- this->GetBuildFileStream(), comment, rule, outputs,
- /*implicitOuts=*/cmNinjaDeps(), explicitDeps, implicitDeps, orderOnlyDeps,
- vars, rspfile, commandLineLengthLimit);
+ if (language == "Swift") {
+ this->EmitSwiftDependencyInfo(source);
+ } else {
+ this->GetGlobalGenerator()->WriteBuild(this->GetBuildFileStream(),
+ objBuild, commandLineLengthLimit);
+ }
if (const char* objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) {
- std::vector<std::string> outputList;
- cmSystemTools::ExpandListArgument(objectOutputs, outputList);
- std::transform(outputList.begin(), outputList.end(), outputList.begin(),
- MapToNinjaPath());
- this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
- "Additional output files.",
- outputList, outputs);
+ cmNinjaBuild build("phony");
+ build.Comment = "Additional output files.";
+ build.Outputs = cmExpandedList(objectOutputs);
+ std::transform(build.Outputs.begin(), build.Outputs.end(),
+ build.Outputs.begin(), MapToNinjaPath());
+ build.ExplicitDeps = objBuild.Outputs;
+ this->GetGlobalGenerator()->WriteBuild(this->GetBuildFileStream(), build);
}
}
@@ -999,6 +1200,10 @@ void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang)
mod_dir = this->Makefile->GetCurrentBinaryDirectory();
}
tdi["module-dir"] = mod_dir;
+ tdi["submodule-sep"] =
+ this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_SEP");
+ tdi["submodule-ext"] =
+ this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_EXT");
}
tdi["dir-cur-bld"] = this->Makefile->GetCurrentBinaryDirectory();
@@ -1010,26 +1215,69 @@ void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang)
std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
lang, this->GetConfigName());
- for (std::vector<std::string>::iterator i = includes.begin();
- i != includes.end(); ++i) {
+ for (std::string const& i : includes) {
// Convert the include directories the same way we do for -I flags.
// See upstream ninja issue 1251.
- tdi_include_dirs.append(this->ConvertToNinjaPath(*i));
+ tdi_include_dirs.append(this->ConvertToNinjaPath(i));
}
Json::Value& tdi_linked_target_dirs = tdi["linked-target-dirs"] =
Json::arrayValue;
- std::vector<std::string> linked = this->GetLinkedTargetDirectories();
- for (std::vector<std::string>::iterator i = linked.begin();
- i != linked.end(); ++i) {
- tdi_linked_target_dirs.append(*i);
+ for (std::string const& l : this->GetLinkedTargetDirectories()) {
+ tdi_linked_target_dirs.append(l);
}
std::string const tdin = this->GetTargetDependInfoPath(lang);
- cmGeneratedFileStream tdif(tdin.c_str());
+ cmGeneratedFileStream tdif(tdin);
tdif << tdi;
}
+void cmNinjaTargetGenerator::EmitSwiftDependencyInfo(
+ cmSourceFile const* source)
+{
+ std::string const sourceFilePath =
+ this->ConvertToNinjaPath(this->GetSourceFilePath(source));
+ std::string const objectFilePath =
+ this->ConvertToNinjaPath(this->GetObjectFilePath(source));
+ std::string const swiftDepsPath = [source, objectFilePath]() -> std::string {
+ if (const char* name = source->GetProperty("Swift_DEPENDENCIES_FILE")) {
+ return name;
+ }
+ return objectFilePath + ".swiftdeps";
+ }();
+ std::string const swiftDiaPath = [source, objectFilePath]() -> std::string {
+ if (const char* name = source->GetProperty("Swift_DIAGNOSTICS_FILE")) {
+ return name;
+ }
+ return objectFilePath + ".dia";
+ }();
+ std::string const makeDepsPath = [this, source]() -> std::string {
+ cmLocalNinjaGenerator const* local = this->GetLocalGenerator();
+ std::string const objectFileName =
+ this->ConvertToNinjaPath(this->GetObjectFilePath(source));
+ std::string const objectFileDir =
+ cmSystemTools::GetFilenamePath(objectFileName);
+
+ if (this->Makefile->IsOn("CMAKE_Swift_DEPFLE_EXTNSION_REPLACE")) {
+ std::string dependFileName =
+ cmSystemTools::GetFilenameWithoutLastExtension(objectFileName) + ".d";
+ return local->ConvertToOutputFormat(objectFileDir + "/" + dependFileName,
+ cmOutputConverter::SHELL);
+ }
+ return local->ConvertToOutputFormat(objectFileName + ".d",
+ cmOutputConverter::SHELL);
+ }();
+
+ // build the source file mapping
+ // https://github.com/apple/swift/blob/master/docs/Driver.md#output-file-maps
+ Json::Value entry = Json::Value(Json::objectValue);
+ entry["object"] = objectFilePath;
+ entry["dependencies"] = makeDepsPath;
+ entry["swift-dependencies"] = swiftDepsPath;
+ entry["diagnostics"] = swiftDiaPath;
+ SwiftOutputMap[sourceFilePath] = entry;
+}
+
void cmNinjaTargetGenerator::ExportObjectCompileCommand(
std::string const& language, std::string const& sourceFileName,
std::string const& objectDir, std::string const& objectFileName,
@@ -1045,11 +1293,12 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
std::string escapedSourceFileName = sourceFileName;
- if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str())) {
- escapedSourceFileName = cmSystemTools::CollapseFullPath(
- escapedSourceFileName, this->GetGlobalGenerator()
- ->GetCMakeInstance()
- ->GetHomeOutputDirectory());
+ if (!cmSystemTools::FileIsFullPath(sourceFileName)) {
+ escapedSourceFileName =
+ cmSystemTools::CollapseFullPath(escapedSourceFileName,
+ this->GetGlobalGenerator()
+ ->GetCMakeInstance()
+ ->GetHomeOutputDirectory());
}
escapedSourceFileName = this->LocalGenerator->ConvertToOutputFormat(
@@ -1069,31 +1318,29 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
std::string cmdVar;
if (this->GeneratorTarget->GetPropertyAsBool(
"CUDA_SEPARABLE_COMPILATION")) {
- cmdVar = std::string("CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION");
+ cmdVar = "CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION";
} else if (this->GeneratorTarget->GetPropertyAsBool(
"CUDA_PTX_COMPILATION")) {
- cmdVar = std::string("CMAKE_CUDA_COMPILE_PTX_COMPILATION");
+ cmdVar = "CMAKE_CUDA_COMPILE_PTX_COMPILATION";
} else {
- cmdVar = std::string("CMAKE_CUDA_COMPILE_WHOLE_COMPILATION");
+ cmdVar = "CMAKE_CUDA_COMPILE_WHOLE_COMPILATION";
}
- std::string compileCmd =
+ const std::string& compileCmd =
this->GetMakefile()->GetRequiredDefinition(cmdVar);
- cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
+ cmExpandList(compileCmd, compileCmds);
} else {
- const std::string cmdVar =
- std::string("CMAKE_") + language + "_COMPILE_OBJECT";
- std::string compileCmd =
+ const std::string cmdVar = "CMAKE_" + language + "_COMPILE_OBJECT";
+ const std::string& compileCmd =
this->GetMakefile()->GetRequiredDefinition(cmdVar);
- cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
+ cmExpandList(compileCmd, compileCmds);
}
- CM_AUTO_PTR<cmRulePlaceholderExpander> rulePlaceholderExpander(
+ std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
this->GetLocalGenerator()->CreateRulePlaceholderExpander());
- for (std::vector<std::string>::iterator i = compileCmds.begin();
- i != compileCmds.end(); ++i) {
+ for (std::string& i : compileCmds) {
// no launcher for CMAKE_EXPORT_COMPILE_COMMANDS
- rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), *i,
+ rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), i,
compileObjectVars);
}
@@ -1103,19 +1350,39 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
this->GetGlobalGenerator()->AddCXXCompileCommand(cmdLine, sourceFileName);
}
+void cmNinjaTargetGenerator::AdditionalCleanFiles()
+{
+ if (const char* prop_value =
+ this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) {
+ cmLocalNinjaGenerator* lg = this->LocalGenerator;
+ std::vector<std::string> cleanFiles;
+ cmExpandList(cmGeneratorExpression::Evaluate(
+ prop_value, lg,
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"),
+ this->GeneratorTarget),
+ cleanFiles);
+ std::string const& binaryDir = lg->GetCurrentBinaryDirectory();
+ cmGlobalNinjaGenerator* gg = lg->GetGlobalNinjaGenerator();
+ for (std::string const& cleanFile : cleanFiles) {
+ // Support relative paths
+ gg->AddAdditionalCleanFile(
+ cmSystemTools::CollapseFullPath(cleanFile, binaryDir));
+ }
+ }
+}
+
void cmNinjaTargetGenerator::EnsureDirectoryExists(
const std::string& path) const
{
- if (cmSystemTools::FileIsFullPath(path.c_str())) {
- cmSystemTools::MakeDirectory(path.c_str());
+ if (cmSystemTools::FileIsFullPath(path)) {
+ cmSystemTools::MakeDirectory(path);
} else {
cmGlobalNinjaGenerator* gg = this->GetGlobalGenerator();
- std::string fullPath =
- std::string(gg->GetCMakeInstance()->GetHomeOutputDirectory());
+ std::string fullPath = gg->GetCMakeInstance()->GetHomeOutputDirectory();
// Also ensures their is a trailing slash.
gg->StripNinjaOutputPathPrefixAsSuffix(fullPath);
fullPath += path;
- cmSystemTools::MakeDirectory(fullPath.c_str());
+ cmSystemTools::MakeDirectory(fullPath);
}
}
@@ -1141,9 +1408,8 @@ void cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
input = this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(input);
// Get the output file location.
- std::string output = macdir;
- output += "/";
- output += cmSystemTools::GetFilenameName(input);
+ std::string output =
+ cmStrCat(macdir, '/', cmSystemTools::GetFilenameName(input));
output = this->Generator->GetGlobalGenerator()->ConvertToNinjaPath(output);
// Write a build statement to copy the content into the bundle.
@@ -1151,7 +1417,7 @@ void cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
output);
// Add as a dependency to the target so that it gets called.
- this->Generator->ExtraFiles.push_back(output);
+ this->Generator->ExtraFiles.push_back(std::move(output));
}
void cmNinjaTargetGenerator::addPoolNinjaVariable(
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 5eb7a9a49..4627bcdc6 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -3,17 +3,21 @@
#ifndef cmNinjaTargetGenerator_h
#define cmNinjaTargetGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <map>
+#include <memory>
+#include <set>
+#include <string>
+#include <vector>
+
+#include "cm_jsoncpp_value.h"
#include "cmCommonTargetGenerator.h"
#include "cmGlobalNinjaGenerator.h"
#include "cmNinjaTypes.h"
#include "cmOSXBundleGenerator.h"
-#include <set>
-#include <string>
-#include <vector>
-
class cmCustomCommand;
class cmGeneratedFileStream;
class cmGeneratorTarget;
@@ -25,13 +29,14 @@ class cmNinjaTargetGenerator : public cmCommonTargetGenerator
{
public:
/// Create a cmNinjaTargetGenerator according to the @a target's type.
- static cmNinjaTargetGenerator* New(cmGeneratorTarget* target);
+ static std::unique_ptr<cmNinjaTargetGenerator> New(
+ cmGeneratorTarget* target);
/// Build a NinjaTargetGenerator.
cmNinjaTargetGenerator(cmGeneratorTarget* target);
/// Destructor.
- ~cmNinjaTargetGenerator() CM_OVERRIDE;
+ ~cmNinjaTargetGenerator() override;
virtual void Generate() = 0;
@@ -64,6 +69,8 @@ protected:
bool NeedExplicitPreprocessing(std::string const& lang) const;
std::string LanguageDyndepRule(std::string const& lang) const;
bool NeedDyndep(std::string const& lang) const;
+ bool UsePreprocessedSource(std::string const& lang) const;
+ bool CompilePreprocessedSourceWithDefines(std::string const& lang) const;
std::string OrderDependsTargetForTarget();
@@ -77,12 +84,14 @@ protected:
std::string ComputeFlagsForObject(cmSourceFile const* source,
const std::string& language);
- void AddIncludeFlags(std::string& flags,
- std::string const& lang) CM_OVERRIDE;
+ void AddIncludeFlags(std::string& flags, std::string const& lang) override;
std::string ComputeDefines(cmSourceFile const* source,
const std::string& language);
+ std::string ComputeIncludes(cmSourceFile const* source,
+ const std::string& language);
+
std::string ConvertToNinjaPath(const std::string& path) const
{
return this->GetGlobalGenerator()->ConvertToNinjaPath(path);
@@ -93,7 +102,7 @@ protected:
}
/// @return the list of link dependency for the given target @a target.
- cmNinjaDeps ComputeLinkDeps() const;
+ cmNinjaDeps ComputeLinkDeps(const std::string& linkLanguage) const;
/// @return the source file path for the given @a source.
std::string GetSourceFilePath(cmSourceFile const* source) const;
@@ -122,18 +131,22 @@ protected:
void WriteObjectBuildStatement(cmSourceFile const* source);
void WriteTargetDependInfo(std::string const& lang);
+ void EmitSwiftDependencyInfo(cmSourceFile const* source);
+
void ExportObjectCompileCommand(
std::string const& language, std::string const& sourceFileName,
std::string const& objectDir, std::string const& objectFileName,
std::string const& objectFileDir, std::string const& flags,
std::string const& defines, std::string const& includes);
+ void AdditionalCleanFiles();
+
cmNinjaDeps GetObjects() const { return this->Objects; }
void EnsureDirectoryExists(const std::string& dir) const;
void EnsureParentDirectoryExists(const std::string& path) const;
- // write rules for Mac OS X Application Bundle content.
+ // write rules for macOS Application Bundle content.
struct MacOSXContentGeneratorType
: cmOSXBundleGenerator::MacOSXContentGeneratorType
{
@@ -142,17 +155,16 @@ protected:
{
}
- void operator()(cmSourceFile const& source,
- const char* pkgloc) CM_OVERRIDE;
+ void operator()(cmSourceFile const& source, const char* pkgloc) override;
private:
cmNinjaTargetGenerator* Generator;
};
friend struct MacOSXContentGeneratorType;
- MacOSXContentGeneratorType* MacOSXContentGenerator;
+ std::unique_ptr<MacOSXContentGeneratorType> MacOSXContentGenerator;
// Properly initialized by sub-classes.
- cmOSXBundleGenerator* OSXBundleGenerator;
+ std::unique_ptr<cmOSXBundleGenerator> OSXBundleGenerator;
std::set<std::string> MacContentFolders;
void addPoolNinjaVariable(const std::string& pool_property,
@@ -164,7 +176,10 @@ private:
cmLocalNinjaGenerator* LocalGenerator;
/// List of object files for this target.
cmNinjaDeps Objects;
- cmNinjaDeps DDIFiles; // TODO: Make per-language.
+ // Fortran Support
+ std::map<std::string, cmNinjaDeps> DDIFiles;
+ // Swift Support
+ Json::Value SwiftOutputMap;
std::vector<cmCustomCommand const*> CustomCommands;
cmNinjaDeps ExtraFiles;
};
diff --git a/Source/cmNinjaTypes.h b/Source/cmNinjaTypes.h
index ec435d9dd..bd0e83fa1 100644
--- a/Source/cmNinjaTypes.h
+++ b/Source/cmNinjaTypes.h
@@ -6,7 +6,9 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
+#include <set>
#include <string>
+#include <utility>
#include <vector>
enum cmNinjaTargetDepends
@@ -15,7 +17,48 @@ enum cmNinjaTargetDepends
DependOnTargetOrdering
};
-typedef std::vector<std::string> cmNinjaDeps;
-typedef std::map<std::string, std::string> cmNinjaVars;
+using cmNinjaDeps = std::vector<std::string>;
+using cmNinjaOuts = std::set<std::string>;
+using cmNinjaVars = std::map<std::string, std::string>;
+
+class cmNinjaRule
+{
+public:
+ cmNinjaRule(std::string name)
+ : Name(std::move(name))
+ {
+ }
+
+ std::string Name;
+ std::string Command;
+ std::string Description;
+ std::string Comment;
+ std::string DepFile;
+ std::string DepType;
+ std::string RspFile;
+ std::string RspContent;
+ std::string Restat;
+ bool Generator = false;
+};
+
+class cmNinjaBuild
+{
+public:
+ cmNinjaBuild() = default;
+ cmNinjaBuild(std::string rule)
+ : Rule(std::move(rule))
+ {
+ }
+
+ std::string Comment;
+ std::string Rule;
+ cmNinjaDeps Outputs;
+ cmNinjaDeps ImplicitOuts;
+ cmNinjaDeps ExplicitDeps;
+ cmNinjaDeps ImplicitDeps;
+ cmNinjaDeps OrderOnlyDeps;
+ cmNinjaVars Variables;
+ std::string RspFile;
+};
#endif // ! cmNinjaTypes_h
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx
index 500ff4a45..5259037bf 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -2,6 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmNinjaUtilityTargetGenerator.h"
+#include <algorithm>
+#include <array>
+#include <iterator>
+#include <string>
+#include <utility>
+#include <vector>
+
#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
#include "cmGeneratedFileStream.h"
@@ -13,13 +20,8 @@
#include "cmOutputConverter.h"
#include "cmSourceFile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-
-#include <algorithm>
-#include <iterator>
-#include <string>
-#include <vector>
cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(
cmGeneratorTarget* target)
@@ -27,83 +29,78 @@ cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(
{
}
-cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator()
-{
-}
+cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() = default;
void cmNinjaUtilityTargetGenerator::Generate()
{
+ cmGlobalNinjaGenerator* gg = this->GetGlobalGenerator();
+ cmLocalNinjaGenerator* lg = this->GetLocalGenerator();
+ cmGeneratorTarget* genTarget = this->GetGeneratorTarget();
+
std::string utilCommandName =
- this->GetLocalGenerator()->GetCurrentBinaryDirectory();
- utilCommandName += cmake::GetCMakeFilesDirectory();
- utilCommandName += "/";
- utilCommandName += this->GetTargetName() + ".util";
+ cmStrCat(lg->GetCurrentBinaryDirectory(), "/CMakeFiles/",
+ this->GetTargetName(), ".util");
utilCommandName = this->ConvertToNinjaPath(utilCommandName);
+ cmNinjaBuild phonyBuild("phony");
std::vector<std::string> commands;
- cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName);
-
- const std::vector<cmCustomCommand>* cmdLists[2] = {
- &this->GetGeneratorTarget()->GetPreBuildCommands(),
- &this->GetGeneratorTarget()->GetPostBuildCommands()
- };
+ cmNinjaDeps deps;
+ cmNinjaDeps util_outputs(1, utilCommandName);
bool uses_terminal = false;
-
- for (unsigned i = 0; i != 2; ++i) {
- for (std::vector<cmCustomCommand>::const_iterator ci =
- cmdLists[i]->begin();
- ci != cmdLists[i]->end(); ++ci) {
- cmCustomCommandGenerator ccg(*ci, this->GetConfigName(),
- this->GetLocalGenerator());
- this->GetLocalGenerator()->AppendCustomCommandDeps(ccg, deps);
- this->GetLocalGenerator()->AppendCustomCommandLines(ccg, commands);
- std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
- std::transform(ccByproducts.begin(), ccByproducts.end(),
- std::back_inserter(util_outputs), MapToNinjaPath());
- if (ci->GetUsesTerminal()) {
- uses_terminal = true;
+ {
+ std::array<std::vector<cmCustomCommand> const*, 2> const cmdLists = {
+ { &genTarget->GetPreBuildCommands(), &genTarget->GetPostBuildCommands() }
+ };
+
+ for (std::vector<cmCustomCommand> const* cmdList : cmdLists) {
+ for (cmCustomCommand const& ci : *cmdList) {
+ cmCustomCommandGenerator ccg(ci, this->GetConfigName(), lg);
+ lg->AppendCustomCommandDeps(ccg, deps);
+ lg->AppendCustomCommandLines(ccg, commands);
+ std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
+ std::transform(ccByproducts.begin(), ccByproducts.end(),
+ std::back_inserter(util_outputs), MapToNinjaPath());
+ if (ci.GetUsesTerminal()) {
+ uses_terminal = true;
+ }
}
}
}
- std::vector<cmSourceFile*> sources;
- std::string config =
- this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
- this->GetGeneratorTarget()->GetSourceFiles(sources, config);
- for (std::vector<cmSourceFile*>::const_iterator source = sources.begin();
- source != sources.end(); ++source) {
- if (cmCustomCommand* cc = (*source)->GetCustomCommand()) {
- cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
- this->GetLocalGenerator());
- this->GetLocalGenerator()->AddCustomCommandTarget(
- cc, this->GetGeneratorTarget());
-
- // Depend on all custom command outputs.
- const std::vector<std::string>& ccOutputs = ccg.GetOutputs();
- const std::vector<std::string>& ccByproducts = ccg.GetByproducts();
- std::transform(ccOutputs.begin(), ccOutputs.end(),
- std::back_inserter(deps), MapToNinjaPath());
- std::transform(ccByproducts.begin(), ccByproducts.end(),
- std::back_inserter(deps), MapToNinjaPath());
+ {
+ std::string const& config =
+ this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ std::vector<cmSourceFile*> sources;
+ genTarget->GetSourceFiles(sources, config);
+ for (cmSourceFile const* source : sources) {
+ if (cmCustomCommand const* cc = source->GetCustomCommand()) {
+ cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), lg);
+ lg->AddCustomCommandTarget(cc, genTarget);
+
+ // Depend on all custom command outputs.
+ const std::vector<std::string>& ccOutputs = ccg.GetOutputs();
+ const std::vector<std::string>& ccByproducts = ccg.GetByproducts();
+ std::transform(ccOutputs.begin(), ccOutputs.end(),
+ std::back_inserter(deps), MapToNinjaPath());
+ std::transform(ccByproducts.begin(), ccByproducts.end(),
+ std::back_inserter(deps), MapToNinjaPath());
+ }
}
}
- this->GetLocalGenerator()->AppendTargetOutputs(this->GetGeneratorTarget(),
- outputs);
- this->GetLocalGenerator()->AppendTargetDepends(this->GetGeneratorTarget(),
- deps);
+ lg->AppendTargetOutputs(genTarget, phonyBuild.Outputs);
+ lg->AppendTargetDepends(genTarget, deps);
if (commands.empty()) {
- this->GetGlobalGenerator()->WritePhonyBuild(
- this->GetBuildFileStream(),
- "Utility command for " + this->GetTargetName(), outputs, deps);
+ phonyBuild.Comment = "Utility command for " + this->GetTargetName();
+ phonyBuild.ExplicitDeps = std::move(deps);
+ gg->WriteBuild(this->GetBuildFileStream(), phonyBuild);
} else {
std::string command =
- this->GetLocalGenerator()->BuildCommandLine(commands);
- const char* echoStr =
- this->GetGeneratorTarget()->GetProperty("EchoString");
+ lg->BuildCommandLine(commands, "utility", this->GeneratorTarget);
std::string desc;
+ const char* echoStr = genTarget->GetProperty("EchoString");
if (echoStr) {
desc = echoStr;
} else {
@@ -114,45 +111,38 @@ void cmNinjaUtilityTargetGenerator::Generate()
// makefile vars.
cmSystemTools::ReplaceString(
command, "$(CMAKE_SOURCE_DIR)",
- this->GetLocalGenerator()
- ->ConvertToOutputFormat(
- this->GetLocalGenerator()->GetSourceDirectory(),
- cmOutputConverter::SHELL)
- .c_str());
+ lg->ConvertToOutputFormat(lg->GetSourceDirectory(),
+ cmOutputConverter::SHELL));
cmSystemTools::ReplaceString(
command, "$(CMAKE_BINARY_DIR)",
- this->GetLocalGenerator()
- ->ConvertToOutputFormat(
- this->GetLocalGenerator()->GetBinaryDirectory(),
- cmOutputConverter::SHELL)
- .c_str());
+ lg->ConvertToOutputFormat(lg->GetBinaryDirectory(),
+ cmOutputConverter::SHELL));
cmSystemTools::ReplaceString(command, "$(ARGS)", "");
if (command.find('$') != std::string::npos) {
return;
}
- for (cmNinjaDeps::const_iterator oi = util_outputs.begin(),
- oe = util_outputs.end();
- oi != oe; ++oi) {
- this->GetGlobalGenerator()->SeenCustomCommandOutput(*oi);
+ for (std::string const& util_output : util_outputs) {
+ gg->SeenCustomCommandOutput(util_output);
}
- this->GetGlobalGenerator()->WriteCustomCommandBuild(
- command, desc, "Utility command for " + this->GetTargetName(),
- /*depfile*/ "", uses_terminal,
- /*restat*/ true, util_outputs, deps);
+ gg->WriteCustomCommandBuild(command, desc,
+ "Utility command for " + this->GetTargetName(),
+ /*depfile*/ "", /*job_pool*/ "", uses_terminal,
+ /*restat*/ true, util_outputs, deps);
- this->GetGlobalGenerator()->WritePhonyBuild(
- this->GetBuildFileStream(), "", outputs,
- cmNinjaDeps(1, utilCommandName));
+ phonyBuild.ExplicitDeps.push_back(utilCommandName);
+ gg->WriteBuild(this->GetBuildFileStream(), phonyBuild);
}
+ // Find ADDITIONAL_CLEAN_FILES
+ this->AdditionalCleanFiles();
+
// Add an alias for the logical target name regardless of what directory
// contains it. Skip this for GLOBAL_TARGET because they are meant to
// be per-directory and have one at the top-level anyway.
- if (this->GetGeneratorTarget()->GetType() != cmStateEnums::GLOBAL_TARGET) {
- this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(),
- this->GetGeneratorTarget());
+ if (genTarget->GetType() != cmStateEnums::GLOBAL_TARGET) {
+ gg->AddTargetAlias(this->GetTargetName(), genTarget);
}
}
diff --git a/Source/cmNinjaUtilityTargetGenerator.h b/Source/cmNinjaUtilityTargetGenerator.h
index 9256e369c..01cc4595f 100644
--- a/Source/cmNinjaUtilityTargetGenerator.h
+++ b/Source/cmNinjaUtilityTargetGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmNinjaUtilityTargetGenerator_h
#define cmNinjaUtilityTargetGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include "cmNinjaTargetGenerator.h"
@@ -13,9 +13,9 @@ class cmNinjaUtilityTargetGenerator : public cmNinjaTargetGenerator
{
public:
cmNinjaUtilityTargetGenerator(cmGeneratorTarget* target);
- ~cmNinjaUtilityTargetGenerator() CM_OVERRIDE;
+ ~cmNinjaUtilityTargetGenerator() override;
- void Generate() CM_OVERRIDE;
+ void Generate() override;
};
#endif // ! cmNinjaUtilityTargetGenerator_h
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index beddc6e6d..a6f4e512e 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -2,26 +2,26 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmOSXBundleGenerator.h"
-#include "cmConfigure.h"
+#include <cassert>
+#include <utility>
#include "cmGeneratorTarget.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include <cassert>
-
class cmSourceFile;
cmOSXBundleGenerator::cmOSXBundleGenerator(cmGeneratorTarget* target,
- const std::string& configName)
+ std::string configName)
: GT(target)
, Makefile(target->Target->GetMakefile())
, LocalGenerator(target->GetLocalGenerator())
- , ConfigName(configName)
- , MacContentFolders(CM_NULLPTR)
+ , ConfigName(std::move(configName))
+ , MacContentFolders(nullptr)
{
if (this->MustSkip()) {
return;
@@ -41,22 +41,21 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
}
// Compute bundle directory names.
- std::string out = outpath;
- out += "/";
- out += this->GT->GetAppBundleDirectory(this->ConfigName,
- cmGeneratorTarget::FullLevel);
- cmSystemTools::MakeDirectory(out.c_str());
+ std::string out =
+ cmStrCat(outpath, '/',
+ this->GT->GetAppBundleDirectory(this->ConfigName,
+ cmGeneratorTarget::FullLevel));
+ cmSystemTools::MakeDirectory(out);
this->Makefile->AddCMakeOutputFile(out);
// Configure the Info.plist file. Note that it needs the executable name
// to be set.
- std::string plist = outpath;
- plist += "/";
- plist += this->GT->GetAppBundleDirectory(this->ConfigName,
- cmGeneratorTarget::ContentLevel);
- plist += "/Info.plist";
- this->LocalGenerator->GenerateAppleInfoPList(this->GT, targetName,
- plist.c_str());
+ std::string plist =
+ cmStrCat(outpath, '/',
+ this->GT->GetAppBundleDirectory(this->ConfigName,
+ cmGeneratorTarget::ContentLevel),
+ "/Info.plist");
+ this->LocalGenerator->GenerateAppleInfoPList(this->GT, targetName, plist);
this->Makefile->AddCMakeOutputFile(plist);
outpath = out;
}
@@ -71,10 +70,11 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
assert(this->MacContentFolders);
// Compute the location of the top-level foo.framework directory.
- std::string contentdir = outpath + "/" +
- this->GT->GetFrameworkDirectory(this->ConfigName,
- cmGeneratorTarget::ContentLevel);
- contentdir += "/";
+ std::string contentdir =
+ cmStrCat(outpath, '/',
+ this->GT->GetFrameworkDirectory(this->ConfigName,
+ cmGeneratorTarget::ContentLevel),
+ '/');
std::string newoutpath = outpath + "/" +
this->GT->GetFrameworkDirectory(this->ConfigName,
@@ -84,18 +84,17 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
// Configure the Info.plist file
std::string plist = newoutpath;
- if (!this->Makefile->PlatformIsAppleIos()) {
+ if (!this->Makefile->PlatformIsAppleEmbedded()) {
// Put the Info.plist file into the Resources directory.
this->MacContentFolders->insert("Resources");
plist += "/Resources";
}
plist += "/Info.plist";
std::string name = cmSystemTools::GetFilenameName(targetName);
- this->LocalGenerator->GenerateFrameworkInfoPList(this->GT, name,
- plist.c_str());
+ this->LocalGenerator->GenerateFrameworkInfoPList(this->GT, name, plist);
// Generate Versions directory only for MacOSX frameworks
- if (this->Makefile->PlatformIsAppleIos()) {
+ if (this->Makefile->PlatformIsAppleEmbedded()) {
return;
}
@@ -105,26 +104,22 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
std::string newName;
// Make foo.framework/Versions
- std::string versions = contentdir;
- versions += "Versions";
- cmSystemTools::MakeDirectory(versions.c_str());
+ std::string versions = cmStrCat(contentdir, "Versions");
+ cmSystemTools::MakeDirectory(versions);
// Make foo.framework/Versions/version
- cmSystemTools::MakeDirectory(newoutpath.c_str());
+ cmSystemTools::MakeDirectory(newoutpath);
// Current -> version
oldName = frameworkVersion;
- newName = versions;
- newName += "/Current";
+ newName = cmStrCat(versions, "/Current");
cmSystemTools::RemoveFile(newName);
cmSystemTools::CreateSymlink(oldName, newName);
this->Makefile->AddCMakeOutputFile(newName);
// foo -> Versions/Current/foo
- oldName = "Versions/Current/";
- oldName += name;
- newName = contentdir;
- newName += name;
+ oldName = cmStrCat("Versions/Current/", name);
+ newName = cmStrCat(contentdir, name);
cmSystemTools::RemoveFile(newName);
cmSystemTools::CreateSymlink(oldName, newName);
this->Makefile->AddCMakeOutputFile(newName);
@@ -133,8 +128,7 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
if (this->MacContentFolders->find("Resources") !=
this->MacContentFolders->end()) {
oldName = "Versions/Current/Resources";
- newName = contentdir;
- newName += "Resources";
+ newName = cmStrCat(contentdir, "Resources");
cmSystemTools::RemoveFile(newName);
cmSystemTools::CreateSymlink(oldName, newName);
this->Makefile->AddCMakeOutputFile(newName);
@@ -144,8 +138,7 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
if (this->MacContentFolders->find("Headers") !=
this->MacContentFolders->end()) {
oldName = "Versions/Current/Headers";
- newName = contentdir;
- newName += "Headers";
+ newName = cmStrCat(contentdir, "Headers");
cmSystemTools::RemoveFile(newName);
cmSystemTools::CreateSymlink(oldName, newName);
this->Makefile->AddCMakeOutputFile(newName);
@@ -155,8 +148,7 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
if (this->MacContentFolders->find("PrivateHeaders") !=
this->MacContentFolders->end()) {
oldName = "Versions/Current/PrivateHeaders";
- newName = contentdir;
- newName += "PrivateHeaders";
+ newName = cmStrCat(contentdir, "PrivateHeaders");
cmSystemTools::RemoveFile(newName);
cmSystemTools::CreateSymlink(oldName, newName);
this->Makefile->AddCMakeOutputFile(newName);
@@ -171,21 +163,22 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
}
// Compute bundle directory names.
- std::string out = root;
- out += "/";
- out += this->GT->GetCFBundleDirectory(this->ConfigName,
- cmGeneratorTarget::FullLevel);
- cmSystemTools::MakeDirectory(out.c_str());
+ std::string out =
+ cmStrCat(root, '/',
+ this->GT->GetCFBundleDirectory(this->ConfigName,
+ cmGeneratorTarget::FullLevel));
+ cmSystemTools::MakeDirectory(out);
this->Makefile->AddCMakeOutputFile(out);
// Configure the Info.plist file. Note that it needs the executable name
// to be set.
- std::string plist = root + "/" +
- this->GT->GetCFBundleDirectory(this->ConfigName,
- cmGeneratorTarget::ContentLevel);
- plist += "/Info.plist";
+ std::string plist =
+ cmStrCat(root, '/',
+ this->GT->GetCFBundleDirectory(this->ConfigName,
+ cmGeneratorTarget::ContentLevel),
+ "/Info.plist");
std::string name = cmSystemTools::GetFilenameName(targetName);
- this->LocalGenerator->GenerateAppleInfoPList(this->GT, name, plist.c_str());
+ this->LocalGenerator->GenerateAppleInfoPList(this->GT, name, plist);
this->Makefile->AddCMakeOutputFile(plist);
}
@@ -197,12 +190,11 @@ void cmOSXBundleGenerator::GenerateMacOSXContentStatements(
return;
}
- for (std::vector<cmSourceFile const*>::const_iterator si = sources.begin();
- si != sources.end(); ++si) {
+ for (cmSourceFile const* source : sources) {
cmGeneratorTarget::SourceFileFlags tsFlags =
- this->GT->GetTargetSourceFileFlags(*si);
+ this->GT->GetTargetSourceFileFlags(source);
if (tsFlags.Type != cmGeneratorTarget::SourceFileTypeNormal) {
- (*generator)(**si, tsFlags.MacFolder);
+ (*generator)(*source, tsFlags.MacFolder);
}
}
}
@@ -212,11 +204,11 @@ std::string cmOSXBundleGenerator::InitMacOSXContentDirectory(
{
// Construct the full path to the content subdirectory.
- std::string macdir = this->GT->GetMacContentDirectory(
- this->ConfigName, cmStateEnums::RuntimeBinaryArtifact);
- macdir += "/";
- macdir += pkgloc;
- cmSystemTools::MakeDirectory(macdir.c_str());
+ std::string macdir =
+ cmStrCat(this->GT->GetMacContentDirectory(
+ this->ConfigName, cmStateEnums::RuntimeBinaryArtifact),
+ '/', pkgloc);
+ cmSystemTools::MakeDirectory(macdir);
// Record use of this content location. Only the first level
// directory is needed.
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
index be7e932f9..3dea6cc8a 100644
--- a/Source/cmOSXBundleGenerator.h
+++ b/Source/cmOSXBundleGenerator.h
@@ -17,8 +17,7 @@ class cmSourceFile;
class cmOSXBundleGenerator
{
public:
- cmOSXBundleGenerator(cmGeneratorTarget* target,
- const std::string& configName);
+ cmOSXBundleGenerator(cmGeneratorTarget* target, std::string configName);
// create an app bundle at a given root, and return
// the directory within the bundle that contains the executable
@@ -32,7 +31,7 @@ public:
struct MacOSXContentGeneratorType
{
- virtual ~MacOSXContentGeneratorType() {}
+ virtual ~MacOSXContentGeneratorType() = default;
virtual void operator()(cmSourceFile const& source,
const char* pkgloc) = 0;
};
diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx
index 00a2d2bce..22e59ac43 100644
--- a/Source/cmOptionCommand.cxx
+++ b/Source/cmOptionCommand.cxx
@@ -2,55 +2,84 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmOptionCommand.h"
-#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmPolicies.h"
#include "cmState.h"
+#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
-#include "cmSystemTools.h"
-
-class cmExecutionStatus;
+#include "cmStringAlgorithms.h"
// cmOptionCommand
-bool cmOptionCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmOptionCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- bool argError = false;
- if (args.size() < 2) {
- argError = true;
- }
- // for VTK 4.0 we have to support the option command with more than 3
- // arguments if CMAKE_MINIMUM_REQUIRED_VERSION is not defined, if
- // CMAKE_MINIMUM_REQUIRED_VERSION is defined, then we can have stricter
- // checking.
- if (this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION")) {
- if (args.size() > 3) {
- argError = true;
- }
- }
+ const bool argError = (args.size() < 2) || (args.size() > 3);
if (argError) {
- std::string m = "called with incorrect number of arguments: ";
- m += cmJoin(args, " ");
- this->SetError(m);
+ std::string m = cmStrCat("called with incorrect number of arguments: ",
+ cmJoin(args, " "));
+ status.SetError(m);
return false;
}
- std::string initialValue = "Off";
- // Now check and see if the value has been stored in the cache
- // already, if so use that value and don't look for the program
- cmState* state = this->Makefile->GetState();
- const char* existingValue = state->GetCacheEntryValue(args[0]);
- if (existingValue) {
- if (state->GetCacheEntryType(args[0]) != cmStateEnums::UNINITIALIZED) {
- state->SetCacheEntryProperty(args[0], "HELPSTRING", args[1]);
- return true;
+ // Determine the state of the option policy
+ bool checkAndWarn = false;
+ {
+ auto policyStatus =
+ status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0077);
+ const auto* existsBeforeSet =
+ status.GetMakefile().GetStateSnapshot().GetDefinition(args[0]);
+ switch (policyStatus) {
+ case cmPolicies::WARN:
+ checkAndWarn = (existsBeforeSet != nullptr);
+ break;
+ case cmPolicies::OLD:
+ // OLD behavior does not warn.
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW: {
+ // See if a local variable with this name already exists.
+ // If so we ignore the option command.
+ if (existsBeforeSet) {
+ return true;
+ }
+ } break;
}
- initialValue = existingValue;
}
+
+ // See if a cache variable with this name already exists
+ // If so just make sure the doc state is correct
+ cmState* state = status.GetMakefile().GetState();
+ const char* existingValue = state->GetCacheEntryValue(args[0]);
+ if (existingValue &&
+ (state->GetCacheEntryType(args[0]) != cmStateEnums::UNINITIALIZED)) {
+ state->SetCacheEntryProperty(args[0], "HELPSTRING", args[1]);
+ return true;
+ }
+
+ // Nothing in the cache so add it
+ std::string initialValue = existingValue ? existingValue : "Off";
if (args.size() == 3) {
initialValue = args[2];
}
- bool init = cmSystemTools::IsOn(initialValue.c_str());
- this->Makefile->AddCacheDefinition(args[0], init ? "ON" : "OFF",
- args[1].c_str(), cmStateEnums::BOOL);
+ bool init = cmIsOn(initialValue);
+ status.GetMakefile().AddCacheDefinition(args[0], init ? "ON" : "OFF",
+ args[1].c_str(), cmStateEnums::BOOL);
+
+ if (checkAndWarn) {
+ const auto* existsAfterSet =
+ status.GetMakefile().GetStateSnapshot().GetDefinition(args[0]);
+ if (!existsAfterSet) {
+ status.GetMakefile().IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0077),
+ "\n"
+ "For compatibility with older versions of CMake, option "
+ "is clearing the normal variable '",
+ args[0], "'."));
+ }
+ }
return true;
}
diff --git a/Source/cmOptionCommand.h b/Source/cmOptionCommand.h
index 634e3a824..cbd1cb864 100644
--- a/Source/cmOptionCommand.h
+++ b/Source/cmOptionCommand.h
@@ -3,34 +3,18 @@
#ifndef cmOptionCommand_h
#define cmOptionCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmOptionCommand
+/**
* \brief Provide an option to the user
*
* cmOptionCommand provides an option for the user to select
*/
-class cmOptionCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmOptionCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
-
+bool cmOptionCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index 333e3134c..073222cd8 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -2,17 +2,20 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmOrderDirectories.h"
+#include <algorithm>
+#include <cassert>
+#include <functional>
+#include <sstream>
+#include <vector>
+
#include "cmAlgorithms.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
+#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
-#include <algorithm>
-#include <assert.h>
-#include <functional>
-#include <sstream>
-
/*
Directory ordering computation.
- Useful to compute a safe runtime library path order
@@ -47,7 +50,7 @@ public:
this->FileName = cmSystemTools::GetFilenameName(file);
}
}
- virtual ~cmOrderDirectoriesConstraint() {}
+ virtual ~cmOrderDirectoriesConstraint() = default;
void AddDirectory()
{
@@ -75,9 +78,8 @@ public:
void FindImplicitConflicts(std::ostringstream& w)
{
bool first = true;
- for (unsigned int i = 0; i < this->OD->OriginalDirectories.size(); ++i) {
+ for (std::string const& dir : this->OD->OriginalDirectories) {
// Check if this directory conflicts with the entry.
- std::string const& dir = this->OD->OriginalDirectories[i];
if (dir != this->Directory &&
cmSystemTools::GetRealPath(dir) !=
cmSystemTools::GetRealPath(this->Directory) &&
@@ -116,10 +118,8 @@ bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir,
std::string const& name)
{
// Check if the file exists on disk.
- std::string file = dir;
- file += "/";
- file += name;
- if (cmSystemTools::FileExists(file.c_str(), true)) {
+ std::string file = cmStrCat(dir, '/', name);
+ if (cmSystemTools::FileExists(file, true)) {
// The file conflicts only if it is not the same as the original
// file due to a symlink or hardlink.
return !cmSystemTools::SameFile(this->FullPath, file);
@@ -128,7 +128,7 @@ bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir,
// Check if the file will be built by cmake.
std::set<std::string> const& files =
(this->GlobalGenerator->GetDirectoryContent(dir, false));
- std::set<std::string>::const_iterator fi = files.find(name);
+ auto fi = files.find(name);
return fi != files.end();
}
@@ -150,7 +150,7 @@ public:
}
}
- void Report(std::ostream& e) CM_OVERRIDE
+ void Report(std::ostream& e) override
{
e << "runtime library [";
if (this->SOName.empty()) {
@@ -161,7 +161,7 @@ public:
e << "]";
}
- bool FindConflict(std::string const& dir) CM_OVERRIDE;
+ bool FindConflict(std::string const& dir) override;
private:
// The soname of the shared library if it is known.
@@ -186,9 +186,9 @@ bool cmOrderDirectoriesConstraintSOName::FindConflict(std::string const& dir)
// know the soname just look at all files that start with the
// file name. Usually the soname starts with the library name.
std::string base = this->FileName;
- std::set<std::string>::const_iterator first = files.lower_bound(base);
- ++base[base.size() - 1];
- std::set<std::string>::const_iterator last = files.upper_bound(base);
+ auto first = files.lower_bound(base);
+ ++base.back();
+ auto last = files.upper_bound(base);
if (first != last) {
return true;
}
@@ -205,12 +205,12 @@ public:
{
}
- void Report(std::ostream& e) CM_OVERRIDE
+ void Report(std::ostream& e) override
{
e << "link library [" << this->FileName << "]";
}
- bool FindConflict(std::string const& dir) CM_OVERRIDE;
+ bool FindConflict(std::string const& dir) override;
};
bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir)
@@ -226,12 +226,9 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir)
this->OD->RemoveLibraryExtension.find(this->FileName)) {
std::string lib = this->OD->RemoveLibraryExtension.match(1);
std::string ext = this->OD->RemoveLibraryExtension.match(2);
- for (std::vector<std::string>::iterator i =
- this->OD->LinkExtensions.begin();
- i != this->OD->LinkExtensions.end(); ++i) {
- if (*i != ext) {
- std::string fname = lib;
- fname += *i;
+ for (std::string const& LinkExtension : this->OD->LinkExtensions) {
+ if (LinkExtension != ext) {
+ std::string fname = cmStrCat(lib, LinkExtension);
if (this->FileMayConflict(dir, fname)) {
return true;
}
@@ -331,24 +328,21 @@ void cmOrderDirectories::AddLinkLibrary(std::string const& fullPath)
void cmOrderDirectories::AddUserDirectories(
std::vector<std::string> const& extra)
{
- this->UserDirectories.insert(this->UserDirectories.end(), extra.begin(),
- extra.end());
+ cmAppend(this->UserDirectories, extra);
}
void cmOrderDirectories::AddLanguageDirectories(
std::vector<std::string> const& dirs)
{
- this->LanguageDirectories.insert(this->LanguageDirectories.end(),
- dirs.begin(), dirs.end());
+ cmAppend(this->LanguageDirectories, dirs);
}
void cmOrderDirectories::SetImplicitDirectories(
std::set<std::string> const& implicitDirs)
{
this->ImplicitDirectories.clear();
- for (std::set<std::string>::const_iterator i = implicitDirs.begin();
- i != implicitDirs.end(); ++i) {
- this->ImplicitDirectories.insert(this->GetRealPath(*i));
+ for (std::string const& implicitDir : implicitDirs) {
+ this->ImplicitDirectories.insert(this->GetRealPath(implicitDir));
}
}
@@ -375,8 +369,8 @@ void cmOrderDirectories::CollectOriginalDirectories()
this->AddOriginalDirectories(this->UserDirectories);
// Add directories containing constraints.
- for (unsigned int i = 0; i < this->ConstraintEntries.size(); ++i) {
- this->ConstraintEntries[i]->AddDirectory();
+ for (cmOrderDirectoriesConstraint* entry : this->ConstraintEntries) {
+ entry->AddDirectory();
}
// Add language runtime directories last.
@@ -386,7 +380,7 @@ void cmOrderDirectories::CollectOriginalDirectories()
int cmOrderDirectories::AddOriginalDirectory(std::string const& dir)
{
// Add the runtime directory with a unique index.
- std::map<std::string, int>::iterator i = this->DirectoryIndex.find(dir);
+ auto i = this->DirectoryIndex.find(dir);
if (i == this->DirectoryIndex.end()) {
std::map<std::string, int>::value_type entry(
dir, static_cast<int>(this->OriginalDirectories.size()));
@@ -400,26 +394,25 @@ int cmOrderDirectories::AddOriginalDirectory(std::string const& dir)
void cmOrderDirectories::AddOriginalDirectories(
std::vector<std::string> const& dirs)
{
- for (std::vector<std::string>::const_iterator di = dirs.begin();
- di != dirs.end(); ++di) {
+ for (std::string const& dir : dirs) {
// We never explicitly specify implicit link directories.
- if (this->IsImplicitDirectory(*di)) {
+ if (this->IsImplicitDirectory(dir)) {
continue;
}
// Skip the empty string.
- if (di->empty()) {
+ if (dir.empty()) {
continue;
}
// Add this directory.
- this->AddOriginalDirectory(*di);
+ this->AddOriginalDirectory(dir);
}
}
struct cmOrderDirectoriesCompare
{
- typedef std::pair<int, int> ConflictPair;
+ using ConflictPair = std::pair<int, int>;
// The conflict pair is unique based on just the directory
// (first). The second element is only used for displaying
@@ -442,16 +435,14 @@ void cmOrderDirectories::FindConflicts()
}
// Clean up the conflict graph representation.
- for (std::vector<ConflictList>::iterator i = this->ConflictGraph.begin();
- i != this->ConflictGraph.end(); ++i) {
+ for (ConflictList& cl : this->ConflictGraph) {
// Sort the outgoing edges for each graph node so that the
// original order will be preserved as much as possible.
- std::sort(i->begin(), i->end());
+ std::sort(cl.begin(), cl.end());
// Make the edge list unique so cycle detection will be reliable.
- ConflictList::iterator last =
- std::unique(i->begin(), i->end(), cmOrderDirectoriesCompare());
- i->erase(last, i->end());
+ auto last = std::unique(cl.begin(), cl.end(), cmOrderDirectoriesCompare());
+ cl.erase(last, cl.end());
}
// Check items in implicit link directories.
@@ -463,25 +454,25 @@ void cmOrderDirectories::FindImplicitConflicts()
// Check for items in implicit link directories that have conflicts
// in the explicit directories.
std::ostringstream conflicts;
- for (unsigned int i = 0; i < this->ImplicitDirEntries.size(); ++i) {
- this->ImplicitDirEntries[i]->FindImplicitConflicts(conflicts);
+ for (cmOrderDirectoriesConstraint* entry : this->ImplicitDirEntries) {
+ entry->FindImplicitConflicts(conflicts);
}
// Skip warning if there were no conflicts.
- std::string text = conflicts.str();
+ std::string const text = conflicts.str();
if (text.empty()) {
return;
}
// Warn about the conflicts.
- std::ostringstream w;
- w << "Cannot generate a safe " << this->Purpose << " for target "
- << this->Target->GetName()
- << " because files in some directories may conflict with "
- << " libraries in implicit directories:\n"
- << text << "Some of these libraries may not be found correctly.";
this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
- cmake::WARNING, w.str(), this->Target->GetBacktrace());
+ MessageType::WARNING,
+ cmStrCat("Cannot generate a safe ", this->Purpose, " for target ",
+ this->Target->GetName(),
+ " because files in some directories may "
+ "conflict with libraries in implicit directories:\n",
+ text, "Some of these libraries may not be found correctly."),
+ this->Target->GetBacktrace());
}
void cmOrderDirectories::OrderDirectories()
@@ -515,8 +506,8 @@ void cmOrderDirectories::VisitDirectory(unsigned int i)
// Visit the neighbors of the node first.
ConflictList const& clist = this->ConflictGraph[i];
- for (ConflictList::const_iterator j = clist.begin(); j != clist.end(); ++j) {
- this->VisitDirectory(j->first);
+ for (ConflictPair const& j : clist) {
+ this->VisitDirectory(j.first);
}
// Now that all directories required to come before this one have
@@ -542,16 +533,15 @@ void cmOrderDirectories::DiagnoseCycle()
for (unsigned int i = 0; i < this->ConflictGraph.size(); ++i) {
ConflictList const& clist = this->ConflictGraph[i];
e << " dir " << i << " is [" << this->OriginalDirectories[i] << "]\n";
- for (ConflictList::const_iterator j = clist.begin(); j != clist.end();
- ++j) {
- e << " dir " << j->first << " must precede it due to ";
- this->ConstraintEntries[j->second]->Report(e);
+ for (ConflictPair const& j : clist) {
+ e << " dir " << j.first << " must precede it due to ";
+ this->ConstraintEntries[j.second]->Report(e);
e << "\n";
}
}
e << "Some of these libraries may not be found correctly.";
this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
- cmake::WARNING, e.str(), this->Target->GetBacktrace());
+ MessageType::WARNING, e.str(), this->Target->GetBacktrace());
}
bool cmOrderDirectories::IsSameDirectory(std::string const& l,
@@ -562,11 +552,10 @@ bool cmOrderDirectories::IsSameDirectory(std::string const& l,
std::string const& cmOrderDirectories::GetRealPath(std::string const& dir)
{
- std::map<std::string, std::string>::iterator i =
- this->RealPaths.lower_bound(dir);
+ auto i = this->RealPaths.lower_bound(dir);
if (i == this->RealPaths.end() ||
this->RealPaths.key_comp()(dir, i->first)) {
- typedef std::map<std::string, std::string>::value_type value_type;
+ using value_type = std::map<std::string, std::string>::value_type;
i = this->RealPaths.insert(
i, value_type(dir, cmSystemTools::GetRealPath(dir)));
}
diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h
index 3a0637afb..23c514500 100644
--- a/Source/cmOrderDirectories.h
+++ b/Source/cmOrderDirectories.h
@@ -3,15 +3,16 @@
#ifndef cmOrderDirectories_h
#define cmOrderDirectories_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmsys/RegularExpression.hxx"
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
+#include "cmsys/RegularExpression.hxx"
+
class cmGeneratorTarget;
class cmGlobalGenerator;
class cmOrderDirectoriesConstraint;
@@ -25,8 +26,10 @@ public:
cmOrderDirectories(cmGlobalGenerator* gg, cmGeneratorTarget const* target,
const char* purpose);
~cmOrderDirectories();
+ cmOrderDirectories(const cmOrderDirectories&) = delete;
+ cmOrderDirectories& operator=(const cmOrderDirectories&) = delete;
void AddRuntimeLibrary(std::string const& fullPath,
- const char* soname = CM_NULLPTR);
+ const char* soname = nullptr);
void AddLinkLibrary(std::string const& fullPath);
void AddUserDirectories(std::vector<std::string> const& extra);
void AddLanguageDirectories(std::vector<std::string> const& dirs);
@@ -73,7 +76,7 @@ private:
// the index of the directory that must come first. The second
// element is the index of the runtime library that added the
// constraint.
- typedef std::pair<int, int> ConflictPair;
+ using ConflictPair = std::pair<int, int>;
struct ConflictList : public std::vector<ConflictPair>
{
};
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index 14c986dd8..e602a6d0a 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -3,15 +3,13 @@
#include "cmOutputConverter.h"
#include <algorithm>
-#include <assert.h>
-#include <ctype.h>
+#include <cassert>
+#include <cctype>
#include <set>
-#include <sstream>
#include <vector>
-#include "cmAlgorithms.h"
#include "cmState.h"
-#include "cmStateDirectory.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
cmOutputConverter::cmOutputConverter(cmStateSnapshot const& snapshot)
@@ -29,7 +27,7 @@ std::string cmOutputConverter::ConvertToOutputForExisting(
// space.
if (this->GetState()->UseWindowsShell() &&
remote.find(' ') != std::string::npos &&
- cmSystemTools::FileExists(remote.c_str())) {
+ cmSystemTools::FileExists(remote)) {
std::string tmp;
if (cmSystemTools::GetShortPath(remote, tmp)) {
return this->ConvertToOutputFormat(tmp, format);
@@ -40,10 +38,10 @@ std::string cmOutputConverter::ConvertToOutputForExisting(
return this->ConvertToOutputFormat(remote, format);
}
-std::string cmOutputConverter::ConvertToOutputFormat(const std::string& source,
+std::string cmOutputConverter::ConvertToOutputFormat(cm::string_view source,
OutputFormat output) const
{
- std::string result = source;
+ std::string result(source);
// Convert it to an output path.
if (output == SHELL || output == WATCOMQUOTE) {
result = this->ConvertDirectorySeparatorsForShell(source);
@@ -55,9 +53,9 @@ std::string cmOutputConverter::ConvertToOutputFormat(const std::string& source,
}
std::string cmOutputConverter::ConvertDirectorySeparatorsForShell(
- const std::string& source) const
+ cm::string_view source) const
{
- std::string result = source;
+ std::string result(source);
// For the MSYS shell convert drive letters to posix paths, so
// that c:/some/path becomes /c/some/path. This is needed to
// avoid problems with the shell path translation.
@@ -73,148 +71,21 @@ std::string cmOutputConverter::ConvertDirectorySeparatorsForShell(
return result;
}
-static bool cmOutputConverterNotAbove(const char* a, const char* b)
+static bool cmOutputConverterIsShellOperator(cm::string_view str)
{
- return (cmSystemTools::ComparePath(a, b) ||
- cmSystemTools::IsSubDirectory(a, b));
+ static std::set<cm::string_view> const shellOperators{
+ "<", ">", "<<", ">>", "|", "||", "&&", "&>", "1>", "2>", "2>&1", "1>&2"
+ };
+ return (shellOperators.count(str) != 0);
}
-bool cmOutputConverter::ContainedInDirectory(std::string const& local_path,
- std::string const& remote_path,
- cmStateDirectory const& directory)
-{
- const std::string relativePathTopBinary =
- directory.GetRelativePathTopBinary();
- const std::string relativePathTopSource =
- directory.GetRelativePathTopSource();
-
- const bool bothInBinary =
- cmOutputConverterNotAbove(local_path.c_str(),
- relativePathTopBinary.c_str()) &&
- cmOutputConverterNotAbove(remote_path.c_str(),
- relativePathTopBinary.c_str());
-
- const bool bothInSource =
- cmOutputConverterNotAbove(local_path.c_str(),
- relativePathTopSource.c_str()) &&
- cmOutputConverterNotAbove(remote_path.c_str(),
- relativePathTopSource.c_str());
-
- return bothInSource || bothInBinary;
-}
-
-std::string cmOutputConverter::ConvertToRelativePath(
- std::string const& local_path, std::string const& remote_path) const
-{
- if (!ContainedInDirectory(local_path, remote_path,
- this->StateSnapshot.GetDirectory())) {
- return remote_path;
- }
-
- return this->ForceToRelativePath(local_path, remote_path);
-}
-
-std::string cmOutputConverter::ForceToRelativePath(
- std::string const& local_path, std::string const& remote_path)
-{
- // The paths should never be quoted.
- assert(local_path[0] != '\"');
- assert(remote_path[0] != '\"');
-
- // The local path should never have a trailing slash.
- assert(local_path.empty() || local_path[local_path.size() - 1] != '/');
-
- // If the path is already relative then just return the path.
- if (!cmSystemTools::FileIsFullPath(remote_path.c_str())) {
- return remote_path;
- }
-
- // Identify the longest shared path component between the remote
- // path and the local path.
- std::vector<std::string> local;
- cmSystemTools::SplitPath(local_path, local);
- std::vector<std::string> remote;
- cmSystemTools::SplitPath(remote_path, remote);
- unsigned int common = 0;
- while (common < remote.size() && common < local.size() &&
- cmSystemTools::ComparePath(remote[common], local[common])) {
- ++common;
- }
-
- // If no part of the path is in common then return the full path.
- if (common == 0) {
- return remote_path;
- }
-
- // If the entire path is in common then just return a ".".
- if (common == remote.size() && common == local.size()) {
- return ".";
- }
-
- // If the entire path is in common except for a trailing slash then
- // just return a "./".
- if (common + 1 == remote.size() && remote[common].empty() &&
- common == local.size()) {
- return "./";
- }
-
- // Construct the relative path.
- std::string relative;
-
- // First add enough ../ to get up to the level of the shared portion
- // of the path. Leave off the trailing slash. Note that the last
- // component of local will never be empty because local should never
- // have a trailing slash.
- for (unsigned int i = common; i < local.size(); ++i) {
- relative += "..";
- if (i < local.size() - 1) {
- relative += "/";
- }
- }
-
- // Now add the portion of the destination path that is not included
- // in the shared portion of the path. Add a slash the first time
- // only if there was already something in the path. If there was a
- // trailing slash in the input then the last iteration of the loop
- // will add a slash followed by an empty string which will preserve
- // the trailing slash in the output.
-
- if (!relative.empty() && !remote.empty()) {
- relative += "/";
- }
- relative += cmJoin(cmMakeRange(remote).advance(common), "/");
-
- // Finally return the path.
- return relative;
-}
-
-static bool cmOutputConverterIsShellOperator(const std::string& str)
-{
- static std::set<std::string> shellOperators;
- if (shellOperators.empty()) {
- shellOperators.insert("<");
- shellOperators.insert(">");
- shellOperators.insert("<<");
- shellOperators.insert(">>");
- shellOperators.insert("|");
- shellOperators.insert("||");
- shellOperators.insert("&&");
- shellOperators.insert("&>");
- shellOperators.insert("1>");
- shellOperators.insert("2>");
- shellOperators.insert("2>&1");
- shellOperators.insert("1>&2");
- }
- return shellOperators.count(str) > 0;
-}
-
-std::string cmOutputConverter::EscapeForShell(const std::string& str,
+std::string cmOutputConverter::EscapeForShell(cm::string_view str,
bool makeVars, bool forEcho,
bool useWatcomQuote) const
{
// Do not escape shell operators.
if (cmOutputConverterIsShellOperator(str)) {
- return str;
+ return std::string(str);
}
// Compute the flags for the target shell environment.
@@ -246,51 +117,48 @@ std::string cmOutputConverter::EscapeForShell(const std::string& str,
flags |= Shell_Flag_IsUnix;
}
- return Shell__GetArgument(str.c_str(), flags);
+ return Shell__GetArgument(str, flags);
}
-std::string cmOutputConverter::EscapeForCMake(const std::string& str)
+std::string cmOutputConverter::EscapeForCMake(cm::string_view str)
{
// Always double-quote the argument to take care of most escapes.
std::string result = "\"";
- for (const char* c = str.c_str(); *c; ++c) {
- if (*c == '"') {
+ for (const char c : str) {
+ if (c == '"') {
// Escape the double quote to avoid ending the argument.
result += "\\\"";
- } else if (*c == '$') {
+ } else if (c == '$') {
// Escape the dollar to avoid expanding variables.
result += "\\$";
- } else if (*c == '\\') {
+ } else if (c == '\\') {
// Escape the backslash to avoid other escapes.
result += "\\\\";
} else {
// Other characters will be parsed correctly.
- result += *c;
+ result += c;
}
}
result += "\"";
return result;
}
-std::string cmOutputConverter::EscapeWindowsShellArgument(const char* arg,
+std::string cmOutputConverter::EscapeWindowsShellArgument(cm::string_view arg,
int shell_flags)
{
return Shell__GetArgument(arg, shell_flags);
}
cmOutputConverter::FortranFormat cmOutputConverter::GetFortranFormat(
- const char* value)
+ cm::string_view value)
{
FortranFormat format = FortranFormatNone;
- if (value && *value) {
- std::vector<std::string> fmt;
- cmSystemTools::ExpandListArgument(value, fmt);
- for (std::vector<std::string>::iterator fi = fmt.begin(); fi != fmt.end();
- ++fi) {
- if (*fi == "FIXED") {
+ if (!value.empty()) {
+ for (std::string const& fi : cmExpandedList(value)) {
+ if (fi == "FIXED") {
format = FortranFormatFixed;
}
- if (*fi == "FREE") {
+ if (fi == "FREE") {
format = FortranFormatFree;
}
}
@@ -298,6 +166,15 @@ cmOutputConverter::FortranFormat cmOutputConverter::GetFortranFormat(
return format;
}
+cmOutputConverter::FortranFormat cmOutputConverter::GetFortranFormat(
+ const char* value)
+{
+ if (!value) {
+ return FortranFormatNone;
+ }
+ return GetFortranFormat(cm::string_view(value));
+}
+
void cmOutputConverter::SetLinkScriptShell(bool linkScriptShell)
{
this->LinkScriptShell = linkScriptShell;
@@ -342,12 +219,13 @@ redirection character (for example, ^>, ^<, or ^| ). If you need to
use the caret character itself (^), use two in a row (^^).
*/
-int cmOutputConverter::Shell__CharIsWhitespace(char c)
+/* Some helpers to identify character classes */
+static bool Shell__CharIsWhitespace(char c)
{
return ((c == ' ') || (c == '\t'));
}
-int cmOutputConverter::Shell__CharNeedsQuotesOnUnix(char c)
+static bool Shell__CharNeedsQuotesOnUnix(char c)
{
return ((c == '\'') || (c == '`') || (c == ';') || (c == '#') ||
(c == '&') || (c == '$') || (c == '(') || (c == ')') || (c == '~') ||
@@ -355,51 +233,52 @@ int cmOutputConverter::Shell__CharNeedsQuotesOnUnix(char c)
(c == '\\'));
}
-int cmOutputConverter::Shell__CharNeedsQuotesOnWindows(char c)
+static bool Shell__CharNeedsQuotesOnWindows(char c)
{
return ((c == '\'') || (c == '#') || (c == '&') || (c == '<') ||
(c == '>') || (c == '|') || (c == '^'));
}
-int cmOutputConverter::Shell__CharNeedsQuotes(char c, int flags)
+static bool Shell__CharIsMakeVariableName(char c)
+{
+ return c && (c == '_' || isalpha((static_cast<int>(c))));
+}
+
+bool cmOutputConverter::Shell__CharNeedsQuotes(char c, int flags)
{
/* On Windows the built-in command shell echo never needs quotes. */
if (!(flags & Shell_Flag_IsUnix) && (flags & Shell_Flag_EchoWindows)) {
- return 0;
+ return false;
}
/* On all platforms quotes are needed to preserve whitespace. */
if (Shell__CharIsWhitespace(c)) {
- return 1;
+ return true;
}
if (flags & Shell_Flag_IsUnix) {
/* On UNIX several special characters need quotes to preserve them. */
if (Shell__CharNeedsQuotesOnUnix(c)) {
- return 1;
+ return true;
}
} else {
/* On Windows several special characters need quotes to preserve them. */
if (Shell__CharNeedsQuotesOnWindows(c)) {
- return 1;
+ return true;
}
}
- return 0;
+ return false;
}
-int cmOutputConverter::Shell__CharIsMakeVariableName(char c)
+cm::string_view::iterator cmOutputConverter::Shell__SkipMakeVariables(
+ cm::string_view::iterator c, cm::string_view::iterator end)
{
- return c && (c == '_' || isalpha(((int)c)));
-}
-
-const char* cmOutputConverter::Shell__SkipMakeVariables(const char* c)
-{
- while (*c == '$' && *(c + 1) == '(') {
- const char* skip = c + 2;
- while (Shell__CharIsMakeVariableName(*skip)) {
+ while ((c != end && (c + 1) != end) && (*c == '$' && *(c + 1) == '(')) {
+ cm::string_view::iterator skip = c + 2;
+ while ((skip != end) && Shell__CharIsMakeVariableName(*skip)) {
++skip;
}
- if (*skip == ')') {
+ if ((skip != end) && *skip == ')') {
c = skip + 1;
} else {
break;
@@ -431,61 +310,60 @@ flag later when we understand applications of this better.
*/
#define KWSYS_SYSTEM_SHELL_QUOTE_MAKE_VARIABLES 0
-int cmOutputConverter::Shell__ArgumentNeedsQuotes(const char* in, int flags)
+bool cmOutputConverter::Shell__ArgumentNeedsQuotes(cm::string_view in,
+ int flags)
{
/* The empty string needs quotes. */
- if (!*in) {
- return 1;
+ if (in.empty()) {
+ return true;
}
/* Scan the string for characters that require quoting. */
- {
- const char* c;
- for (c = in; *c; ++c) {
- /* Look for $(MAKEVAR) syntax if requested. */
- if (flags & Shell_Flag_AllowMakeVariables) {
+ for (cm::string_view::iterator cit = in.begin(), cend = in.end();
+ cit != cend; ++cit) {
+ /* Look for $(MAKEVAR) syntax if requested. */
+ if (flags & Shell_Flag_AllowMakeVariables) {
#if KWSYS_SYSTEM_SHELL_QUOTE_MAKE_VARIABLES
- const char* skip = Shell__SkipMakeVariables(c);
- if (skip != c) {
- /* We need to quote make variable references to preserve the
- string with contents substituted in its place. */
- return 1;
- }
+ cm::string_view::iterator skip = Shell__SkipMakeVariables(cit, cend);
+ if (skip != cit) {
+ /* We need to quote make variable references to preserve the
+ string with contents substituted in its place. */
+ return true;
+ }
#else
- /* Skip over the make variable references if any are present. */
- c = Shell__SkipMakeVariables(c);
+ /* Skip over the make variable references if any are present. */
+ cit = Shell__SkipMakeVariables(cit, cend);
- /* Stop if we have reached the end of the string. */
- if (!*c) {
- break;
- }
-#endif
+ /* Stop if we have reached the end of the string. */
+ if (cit == cend) {
+ break;
}
+#endif
+ }
- /* Check whether this character needs quotes. */
- if (Shell__CharNeedsQuotes(*c, flags)) {
- return 1;
- }
+ /* Check whether this character needs quotes. */
+ if (Shell__CharNeedsQuotes(*cit, flags)) {
+ return true;
}
}
/* On Windows some single character arguments need quotes. */
- if (flags & Shell_Flag_IsUnix && *in && !*(in + 1)) {
- char c = *in;
+ if (flags & Shell_Flag_IsUnix && in.size() == 1) {
+ char c = in[0];
if ((c == '?') || (c == '&') || (c == '^') || (c == '|') || (c == '#')) {
- return 1;
+ return true;
}
}
- return 0;
+ return false;
}
-std::string cmOutputConverter::Shell__GetArgument(const char* in, int flags)
+std::string cmOutputConverter::Shell__GetArgument(cm::string_view in,
+ int flags)
{
- std::ostringstream out;
-
- /* String iterator. */
- const char* c;
+ /* Output will be at least as long as input string. */
+ std::string out;
+ out.reserve(in.size());
/* Keep track of how many backslashes have been encountered in a row. */
int windows_backslashes = 0;
@@ -496,23 +374,24 @@ std::string cmOutputConverter::Shell__GetArgument(const char* in, int flags)
/* Add the opening quote for this argument. */
if (flags & Shell_Flag_WatcomQuote) {
if (flags & Shell_Flag_IsUnix) {
- out << '"';
+ out += '"';
}
- out << '\'';
+ out += '\'';
} else {
- out << '"';
+ out += '"';
}
}
/* Scan the string for characters that require escaping or quoting. */
- for (c = in; *c; ++c) {
+ for (cm::string_view::iterator cit = in.begin(), cend = in.end();
+ cit != cend; ++cit) {
/* Look for $(MAKEVAR) syntax if requested. */
if (flags & Shell_Flag_AllowMakeVariables) {
- const char* skip = Shell__SkipMakeVariables(c);
- if (skip != c) {
+ cm::string_view::iterator skip = Shell__SkipMakeVariables(cit, cend);
+ if (skip != cit) {
/* Copy to the end of the make variable references. */
- while (c != skip) {
- out << *c++;
+ while (cit != skip) {
+ out += *cit++;
}
/* The make variable reference eliminates any escaping needed
@@ -520,7 +399,7 @@ std::string cmOutputConverter::Shell__GetArgument(const char* in, int flags)
windows_backslashes = 0;
/* Stop if we have reached the end of the string. */
- if (!*c) {
+ if (cit == cend) {
break;
}
}
@@ -530,27 +409,27 @@ std::string cmOutputConverter::Shell__GetArgument(const char* in, int flags)
if (flags & Shell_Flag_IsUnix) {
/* On Unix a few special characters need escaping even inside a
quoted argument. */
- if (*c == '\\' || *c == '"' || *c == '`' || *c == '$') {
+ if (*cit == '\\' || *cit == '"' || *cit == '`' || *cit == '$') {
/* This character needs a backslash to escape it. */
- out << '\\';
+ out += '\\';
}
} else if (flags & Shell_Flag_EchoWindows) {
/* On Windows the built-in command shell echo never needs escaping. */
} else {
/* On Windows only backslashes and double-quotes need escaping. */
- if (*c == '\\') {
+ if (*cit == '\\') {
/* Found a backslash. It may need to be escaped later. */
++windows_backslashes;
- } else if (*c == '"') {
+ } else if (*cit == '"') {
/* Found a double-quote. Escape all immediately preceding
backslashes. */
while (windows_backslashes > 0) {
--windows_backslashes;
- out << '\\';
+ out += '\\';
}
/* Add the backslash to escape the double-quote. */
- out << '\\';
+ out += '\\';
} else {
/* We encountered a normal character. This eliminates any
escaping needed for preceding backslashes. */
@@ -559,11 +438,11 @@ std::string cmOutputConverter::Shell__GetArgument(const char* in, int flags)
}
/* Check whether this character needs escaping for a make tool. */
- if (*c == '$') {
+ if (*cit == '$') {
if (flags & Shell_Flag_Make) {
/* In Makefiles a dollar is written $$. The make tool will
replace it with just $ before passing it to the shell. */
- out << "$$";
+ out += "$$";
} else if (flags & Shell_Flag_VSIDE) {
/* In a VS IDE a dollar is written "$". If this is written in
an un-quoted argument it starts a quoted segment, inserts
@@ -571,46 +450,46 @@ std::string cmOutputConverter::Shell__GetArgument(const char* in, int flags)
argument it ends quoting, inserts the $ and restarts
quoting. Either way the $ is isolated from surrounding
text to avoid looking like a variable reference. */
- out << "\"$\"";
+ out += "\"$\"";
} else {
/* Otherwise a dollar is written just $. */
- out << '$';
+ out += '$';
}
- } else if (*c == '#') {
+ } else if (*cit == '#') {
if ((flags & Shell_Flag_Make) && (flags & Shell_Flag_WatcomWMake)) {
/* In Watcom WMake makefiles a pound is written $#. The make
tool will replace it with just # before passing it to the
shell. */
- out << "$#";
+ out += "$#";
} else {
/* Otherwise a pound is written just #. */
- out << '#';
+ out += '#';
}
- } else if (*c == '%') {
+ } else if (*cit == '%') {
if ((flags & Shell_Flag_VSIDE) ||
((flags & Shell_Flag_Make) &&
((flags & Shell_Flag_MinGWMake) || (flags & Shell_Flag_NMake)))) {
/* In the VS IDE, NMake, or MinGW make a percent is written %%. */
- out << "%%";
+ out += "%%";
} else {
/* Otherwise a percent is written just %. */
- out << '%';
+ out += '%';
}
- } else if (*c == ';') {
+ } else if (*cit == ';') {
if (flags & Shell_Flag_VSIDE) {
/* In a VS IDE a semicolon is written ";". If this is written
in an un-quoted argument it starts a quoted segment,
inserts the ; and ends the segment. If it is written in a
quoted argument it ends quoting, inserts the ; and restarts
quoting. Either way the ; is isolated. */
- out << "\";\"";
+ out += "\";\"";
} else {
/* Otherwise a semicolon is written just ;. */
- out << ';';
+ out += ';';
}
} else {
/* Store this character. */
- out << *c;
+ out += *cit;
}
}
@@ -618,19 +497,19 @@ std::string cmOutputConverter::Shell__GetArgument(const char* in, int flags)
/* Add enough backslashes to escape any trailing ones. */
while (windows_backslashes > 0) {
--windows_backslashes;
- out << '\\';
+ out += '\\';
}
/* Add the closing quote for this argument. */
if (flags & Shell_Flag_WatcomQuote) {
- out << '\'';
+ out += '\'';
if (flags & Shell_Flag_IsUnix) {
- out << '"';
+ out += '"';
}
} else {
- out << '"';
+ out += '"';
}
}
- return out.str();
+ return out;
}
diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h
index ae15055ed..349a069d6 100644
--- a/Source/cmOutputConverter.h
+++ b/Source/cmOutputConverter.h
@@ -7,10 +7,11 @@
#include <string>
+#include <cm/string_view>
+
#include "cmStateSnapshot.h"
class cmState;
-class cmStateDirectory;
class cmOutputConverter
{
@@ -23,12 +24,11 @@ public:
WATCOMQUOTE,
RESPONSE
};
- std::string ConvertToOutputFormat(const std::string& source,
+ std::string ConvertToOutputFormat(cm::string_view source,
OutputFormat output) const;
- std::string ConvertDirectorySeparatorsForShell(
- const std::string& source) const;
+ std::string ConvertDirectorySeparatorsForShell(cm::string_view source) const;
- ///! for existing files convert to output path and short path if spaces
+ //! for existing files convert to output path and short path if spaces
std::string ConvertToOutputForExisting(const std::string& remote,
OutputFormat format = SHELL) const;
@@ -73,15 +73,15 @@ public:
Shell_Flag_IsUnix = (1 << 8)
};
- std::string EscapeForShell(const std::string& str, bool makeVars = false,
+ std::string EscapeForShell(cm::string_view str, bool makeVars = false,
bool forEcho = false,
bool useWatcomQuote = false) const;
- static std::string EscapeForCMake(const std::string& str);
+ static std::string EscapeForCMake(cm::string_view str);
/** Compute an escaped version of the given argument for use in a
windows shell. */
- static std::string EscapeWindowsShellArgument(const char* arg,
+ static std::string EscapeWindowsShellArgument(cm::string_view arg,
int shell_flags);
enum FortranFormat
@@ -90,41 +90,17 @@ public:
FortranFormatFixed,
FortranFormatFree
};
+ static FortranFormat GetFortranFormat(cm::string_view value);
static FortranFormat GetFortranFormat(const char* value);
- static bool ContainedInDirectory(std::string const& local_path,
- std::string const& remote_path,
- cmStateDirectory const& directory);
-
- /**
- * Convert the given remote path to a relative path with respect to
- * the given local path. Both paths must use forward slashes and not
- * already be escaped or quoted.
- * The conversion is skipped if the paths are not both in the source
- * or both in the binary tree.
- */
- std::string ConvertToRelativePath(std::string const& local_path,
- std::string const& remote_path) const;
-
- /**
- * Convert the given remote path to a relative path with respect to
- * the given local path. Both paths must use forward slashes and not
- * already be escaped or quoted.
- */
- static std::string ForceToRelativePath(std::string const& local_path,
- std::string const& remote_path);
-
private:
cmState* GetState() const;
- static int Shell__CharIsWhitespace(char c);
- static int Shell__CharNeedsQuotesOnUnix(char c);
- static int Shell__CharNeedsQuotesOnWindows(char c);
- static int Shell__CharNeedsQuotes(char c, int flags);
- static int Shell__CharIsMakeVariableName(char c);
- static const char* Shell__SkipMakeVariables(const char* c);
- static int Shell__ArgumentNeedsQuotes(const char* in, int flags);
- static std::string Shell__GetArgument(const char* in, int flags);
+ static bool Shell__CharNeedsQuotes(char c, int flags);
+ static cm::string_view::iterator Shell__SkipMakeVariables(
+ cm::string_view::iterator begin, cm::string_view::iterator end);
+ static bool Shell__ArgumentNeedsQuotes(cm::string_view in, int flags);
+ static std::string Shell__GetArgument(cm::string_view in, int flags);
private:
cmStateSnapshot StateSnapshot;
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index 2339d6876..e093be019 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -2,21 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmOutputRequiredFilesCommand.h"
-#include "cmsys/FStream.hxx"
-#include "cmsys/RegularExpression.hxx"
+#include <cstdio>
#include <map>
+#include <set>
#include <utility>
+#include "cmsys/FStream.hxx"
+#include "cmsys/RegularExpression.hxx"
+
#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cm_unordered_map.hxx"
-
-class cmExecutionStatus;
+namespace {
/** \class cmDependInformation
* \brief Store dependency information for a single source file.
*
@@ -29,29 +32,25 @@ public:
* Construct with dependency generation marked not done; instance
* not placed in cmMakefile's list.
*/
- cmDependInformation()
- : DependDone(false)
- , SourceFile(CM_NULLPTR)
- {
- }
+ cmDependInformation() = default;
/**
* The set of files on which this one depends.
*/
- typedef std::set<cmDependInformation*> DependencySetType;
+ using DependencySetType = std::set<cmDependInformation*>;
DependencySetType DependencySet;
/**
* This flag indicates whether dependency checking has been
* performed for this file.
*/
- bool DependDone;
+ bool DependDone = false;
/**
* If this object corresponds to a cmSourceFile instance, this points
* to it.
*/
- const cmSourceFile* SourceFile;
+ const cmSourceFile* SourceFile = nullptr;
/**
* Full path to this file.
@@ -97,6 +96,9 @@ public:
*/
~cmLBDepend() { cmDeleteAll(this->DependInformationMap); }
+ cmLBDepend(const cmLBDepend&) = delete;
+ cmLBDepend& operator=(const cmLBDepend&) = delete;
+
/**
* Set the makefile that is used as a source of classes.
*/
@@ -113,9 +115,9 @@ public:
// Now extract any include paths from the targets
std::set<std::string> uniqueIncludes;
std::vector<std::string> orderedAndUniqueIncludes;
- cmTargets& targets = this->Makefile->GetTargets();
- for (cmTargets::iterator l = targets.begin(); l != targets.end(); ++l) {
- const char* incDirProp = l->second.GetProperty("INCLUDE_DIRECTORIES");
+ for (auto const& target : this->Makefile->GetTargets()) {
+ const char* incDirProp =
+ target.second.GetProperty("INCLUDE_DIRECTORIES");
if (!incDirProp) {
continue;
}
@@ -123,12 +125,9 @@ public:
std::string incDirs = cmGeneratorExpression::Preprocess(
incDirProp, cmGeneratorExpression::StripAllGeneratorExpressions);
- std::vector<std::string> includes;
- cmSystemTools::ExpandListArgument(incDirs, includes);
+ std::vector<std::string> includes = cmExpandedList(incDirs);
- for (std::vector<std::string>::const_iterator j = includes.begin();
- j != includes.end(); ++j) {
- std::string path = *j;
+ for (std::string& path : includes) {
this->Makefile->ExpandVariablesInString(path);
if (uniqueIncludes.insert(path).second) {
orderedAndUniqueIncludes.push_back(path);
@@ -136,10 +135,8 @@ public:
}
}
- for (std::vector<std::string>::const_iterator it =
- orderedAndUniqueIncludes.begin();
- it != orderedAndUniqueIncludes.end(); ++it) {
- this->AddSearchPath(*it);
+ for (std::string const& inc : orderedAndUniqueIncludes) {
+ this->AddSearchPath(inc);
}
}
@@ -157,7 +154,7 @@ public:
*/
const cmDependInformation* FindDependencies(const char* file)
{
- cmDependInformation* info = this->GetDependInformation(file, CM_NULLPTR);
+ cmDependInformation* info = this->GetDependInformation(file, nullptr);
this->GenerateDependInformation(info);
return info;
}
@@ -171,13 +168,13 @@ protected:
{
cmsys::ifstream fin(info->FullPath.c_str());
if (!fin) {
- cmSystemTools::Error("error can not open ", info->FullPath.c_str());
+ cmSystemTools::Error("error can not open " + info->FullPath);
return;
}
std::string line;
while (cmSystemTools::GetLineFromStream(fin, line)) {
- if (cmHasLiteralPrefix(line.c_str(), "#include")) {
+ if (cmHasLiteralPrefix(line, "#include")) {
// if it is an include line then create a string class
size_t qstart = line.find('\"', 8);
size_t qend;
@@ -186,7 +183,7 @@ protected:
qstart = line.find('<', 8);
// if a < is not found then move on
if (qstart == std::string::npos) {
- cmSystemTools::Error("unknown include directive ", line.c_str());
+ cmSystemTools::Error("unknown include directive " + line);
continue;
}
qend = line.find('>', qstart + 1);
@@ -198,11 +195,9 @@ protected:
// see if the include matches the regular expression
if (!this->IncludeFileRegularExpression.find(includeFile)) {
if (this->Verbose) {
- std::string message = "Skipping ";
- message += includeFile;
- message += " for file ";
- message += info->FullPath;
- cmSystemTools::Error(message.c_str(), CM_NULLPTR);
+ std::string message =
+ cmStrCat("Skipping ", includeFile, " for file ", info->FullPath);
+ cmSystemTools::Error(message);
}
continue;
}
@@ -217,63 +212,43 @@ protected:
cxxFile = root + ".cxx";
bool found = false;
// try jumping to .cxx .cpp and .c in order
- if (cmSystemTools::FileExists(cxxFile.c_str())) {
+ if (cmSystemTools::FileExists(cxxFile)) {
found = true;
}
- for (std::vector<std::string>::iterator i =
- this->IncludeDirectories.begin();
- i != this->IncludeDirectories.end(); ++i) {
- std::string path = *i;
- path = path + "/";
- path = path + cxxFile;
- if (cmSystemTools::FileExists(path.c_str())) {
+ for (std::string const& path : this->IncludeDirectories) {
+ if (cmSystemTools::FileExists(cmStrCat(path, "/", cxxFile))) {
found = true;
}
}
if (!found) {
cxxFile = root + ".cpp";
- if (cmSystemTools::FileExists(cxxFile.c_str())) {
+ if (cmSystemTools::FileExists(cxxFile)) {
found = true;
}
- for (std::vector<std::string>::iterator i =
- this->IncludeDirectories.begin();
- i != this->IncludeDirectories.end(); ++i) {
- std::string path = *i;
- path = path + "/";
- path = path + cxxFile;
- if (cmSystemTools::FileExists(path.c_str())) {
+ for (std::string const& path : this->IncludeDirectories) {
+ if (cmSystemTools::FileExists(cmStrCat(path, "/", cxxFile))) {
found = true;
}
}
}
if (!found) {
cxxFile = root + ".c";
- if (cmSystemTools::FileExists(cxxFile.c_str())) {
+ if (cmSystemTools::FileExists(cxxFile)) {
found = true;
}
- for (std::vector<std::string>::iterator i =
- this->IncludeDirectories.begin();
- i != this->IncludeDirectories.end(); ++i) {
- std::string path = *i;
- path = path + "/";
- path = path + cxxFile;
- if (cmSystemTools::FileExists(path.c_str())) {
+ for (std::string const& path : this->IncludeDirectories) {
+ if (cmSystemTools::FileExists(cmStrCat(path, "/", cxxFile))) {
found = true;
}
}
}
if (!found) {
cxxFile = root + ".txx";
- if (cmSystemTools::FileExists(cxxFile.c_str())) {
+ if (cmSystemTools::FileExists(cxxFile)) {
found = true;
}
- for (std::vector<std::string>::iterator i =
- this->IncludeDirectories.begin();
- i != this->IncludeDirectories.end(); ++i) {
- std::string path = *i;
- path = path + "/";
- path = path + cxxFile;
- if (cmSystemTools::FileExists(path.c_str())) {
+ for (std::string const& path : this->IncludeDirectories) {
+ if (cmSystemTools::FileExists(cmStrCat(path, "/", cxxFile))) {
found = true;
}
}
@@ -310,8 +285,8 @@ protected:
// Make sure we don't visit the same file more than once.
info->DependDone = true;
- const char* path = info->FullPath.c_str();
- if (!path) {
+ const std::string& path = info->FullPath;
+ if (path.empty()) {
cmSystemTools::Error(
"Attempt to find dependencies for file without path!");
return;
@@ -328,7 +303,7 @@ protected:
// See if the cmSourceFile for it has any files specified as
// dependency hints.
- if (info->SourceFile != CM_NULLPTR) {
+ if (info->SourceFile != nullptr) {
// Get the cmSourceFile corresponding to this.
const cmSourceFile& cFile = *(info->SourceFile);
@@ -337,10 +312,8 @@ protected:
if (!cFile.GetDepends().empty()) {
// Dependency hints have been given. Use them to begin the
// recursion.
- for (std::vector<std::string>::const_iterator file =
- cFile.GetDepends().begin();
- file != cFile.GetDepends().end(); ++file) {
- this->AddDependency(info, file->c_str());
+ for (std::string const& file : cFile.GetDepends()) {
+ this->AddDependency(info, file.c_str());
}
// Found dependency information. We are done.
@@ -353,19 +326,16 @@ protected:
cmSourceFile* srcFile = this->Makefile->GetSource(
cmSystemTools::GetFilenameWithoutExtension(path));
if (srcFile) {
- if (srcFile->GetFullPath() == path) {
+ if (srcFile->ResolveFullPath() == path) {
found = true;
} else {
// try to guess which include path to use
- for (std::vector<std::string>::iterator t =
- this->IncludeDirectories.begin();
- t != this->IncludeDirectories.end(); ++t) {
- std::string incpath = *t;
- if (!incpath.empty() && incpath[incpath.size() - 1] != '/') {
- incpath = incpath + "/";
+ for (std::string incpath : this->IncludeDirectories) {
+ if (!incpath.empty() && incpath.back() != '/') {
+ incpath += "/";
}
- incpath = incpath + path;
- if (srcFile->GetFullPath() == incpath) {
+ incpath += path;
+ if (srcFile->ResolveFullPath() == incpath) {
// set the path to the guessed path
info->FullPath = incpath;
found = true;
@@ -377,13 +347,12 @@ protected:
if (!found) {
// Couldn't find any dependency information.
- if (this->ComplainFileRegularExpression.find(
- info->IncludeName.c_str())) {
- cmSystemTools::Error("error cannot find dependencies for ", path);
+ if (this->ComplainFileRegularExpression.find(info->IncludeName)) {
+ cmSystemTools::Error("error cannot find dependencies for " + path);
} else {
// Destroy the name of the file so that it won't be output as a
// dependency.
- info->FullPath = "";
+ info->FullPath.clear();
}
}
}
@@ -399,8 +368,7 @@ protected:
std::string fullPath = this->FullPath(file, extraPath);
// Try to find the file's instance of cmDependInformation.
- DependInformationMapType::const_iterator result =
- this->DependInformationMap.find(fullPath);
+ auto result = this->DependInformationMap.find(fullPath);
if (result != this->DependInformationMap.end()) {
// Found an instance, return it.
return result->second;
@@ -430,7 +398,7 @@ protected:
if (m != this->DirectoryToFileToPathMap.end()) {
FileToPathMapType& map = m->second;
- FileToPathMapType::iterator p = map.find(fname);
+ auto p = map.find(fname);
if (p != map.end()) {
return p->second;
}
@@ -442,15 +410,12 @@ protected:
return fp;
}
- for (std::vector<std::string>::iterator i =
- this->IncludeDirectories.begin();
- i != this->IncludeDirectories.end(); ++i) {
- std::string path = *i;
- if (!path.empty() && path[path.size() - 1] != '/') {
- path = path + "/";
+ for (std::string path : this->IncludeDirectories) {
+ if (!path.empty() && path.back() != '/') {
+ path += "/";
}
- path = path + fname;
- if (cmSystemTools::FileExists(path.c_str(), true) &&
+ path += fname;
+ if (cmSystemTools::FileExists(path, true) &&
!cmSystemTools::FileIsDirectory(path)) {
std::string fp = cmSystemTools::CollapseFullPath(path);
this->DirectoryToFileToPathMap[extraPath ? extraPath : ""][fname] = fp;
@@ -460,11 +425,11 @@ protected:
if (extraPath) {
std::string path = extraPath;
- if (!path.empty() && path[path.size() - 1] != '/') {
+ if (!path.empty() && path.back() != '/') {
path = path + "/";
}
path = path + fname;
- if (cmSystemTools::FileExists(path.c_str(), true) &&
+ if (cmSystemTools::FileExists(path, true) &&
!cmSystemTools::FileIsDirectory(path)) {
std::string fp = cmSystemTools::CollapseFullPath(path);
this->DirectoryToFileToPathMap[extraPath][fname] = fp;
@@ -481,70 +446,71 @@ protected:
cmsys::RegularExpression IncludeFileRegularExpression;
cmsys::RegularExpression ComplainFileRegularExpression;
std::vector<std::string> IncludeDirectories;
- typedef std::map<std::string, std::string> FileToPathMapType;
- typedef std::map<std::string, FileToPathMapType>
- DirectoryToFileToPathMapType;
- typedef std::map<std::string, cmDependInformation*> DependInformationMapType;
+ using FileToPathMapType = std::map<std::string, std::string>;
+ using DirectoryToFileToPathMapType =
+ std::map<std::string, FileToPathMapType>;
+ using DependInformationMapType = std::map<std::string, cmDependInformation*>;
DependInformationMapType DependInformationMap;
DirectoryToFileToPathMapType DirectoryToFileToPathMap;
};
+void ListDependencies(cmDependInformation const* info, FILE* fout,
+ std::set<cmDependInformation const*>* visited);
+}
+
// cmOutputRequiredFilesCommand
-bool cmOutputRequiredFilesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmOutputRequiredFilesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
// store the arg for final pass
- this->File = args[0];
- this->OutputFile = args[1];
+ const std::string& file = args[0];
+ const std::string& outputFile = args[1];
// compute the list of files
cmLBDepend md;
- md.SetMakefile(this->Makefile);
- md.AddSearchPath(this->Makefile->GetCurrentSourceDirectory());
+ md.SetMakefile(&status.GetMakefile());
+ md.AddSearchPath(status.GetMakefile().GetCurrentSourceDirectory());
// find the depends for a file
- const cmDependInformation* info = md.FindDependencies(this->File.c_str());
+ const cmDependInformation* info = md.FindDependencies(file.c_str());
if (info) {
// write them out
- FILE* fout = cmsys::SystemTools::Fopen(this->OutputFile, "w");
+ FILE* fout = cmsys::SystemTools::Fopen(outputFile, "w");
if (!fout) {
- std::string err = "Can not open output file: ";
- err += this->OutputFile;
- this->SetError(err);
+ status.SetError(cmStrCat("Can not open output file: ", outputFile));
return false;
}
std::set<cmDependInformation const*> visited;
- this->ListDependencies(info, fout, &visited);
+ ListDependencies(info, fout, &visited);
fclose(fout);
}
return true;
}
-void cmOutputRequiredFilesCommand::ListDependencies(
- cmDependInformation const* info, FILE* fout,
- std::set<cmDependInformation const*>* visited)
+namespace {
+void ListDependencies(cmDependInformation const* info, FILE* fout,
+ std::set<cmDependInformation const*>* visited)
{
// add info to the visited set
visited->insert(info);
// now recurse with info's dependencies
- for (cmDependInformation::DependencySetType::const_iterator d =
- info->DependencySet.begin();
- d != info->DependencySet.end(); ++d) {
- if (visited->find(*d) == visited->end()) {
- if (info->FullPath != "") {
- std::string tmp = (*d)->FullPath;
+ for (cmDependInformation* d : info->DependencySet) {
+ if (visited->find(d) == visited->end()) {
+ if (!info->FullPath.empty()) {
+ std::string tmp = d->FullPath;
std::string::size_type pos = tmp.rfind('.');
if (pos != std::string::npos && (tmp.substr(pos) != ".h")) {
tmp = tmp.substr(0, pos);
- fprintf(fout, "%s\n", (*d)->FullPath.c_str());
+ fprintf(fout, "%s\n", d->FullPath.c_str());
}
}
- this->ListDependencies(*d, fout, visited);
+ ListDependencies(d, fout, visited);
}
}
}
+}
diff --git a/Source/cmOutputRequiredFilesCommand.h b/Source/cmOutputRequiredFilesCommand.h
index d20bfbdc1..4c1189457 100644
--- a/Source/cmOutputRequiredFilesCommand.h
+++ b/Source/cmOutputRequiredFilesCommand.h
@@ -3,31 +3,14 @@
#ifndef cmOutputRequiredFilesCommand_h
#define cmOutputRequiredFilesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include <set>
-#include <stdio.h>
#include <string>
#include <vector>
-#include "cmCommand.h"
-
-class cmDependInformation;
class cmExecutionStatus;
-class cmOutputRequiredFilesCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmOutputRequiredFilesCommand; }
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
- void ListDependencies(cmDependInformation const* info, FILE* fout,
- std::set<cmDependInformation const*>* visited);
-
-private:
- std::string File;
- std::string OutputFile;
-};
+bool cmOutputRequiredFilesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx
index d75ee8e86..d712edb81 100644
--- a/Source/cmParseArgumentsCommand.cxx
+++ b/Source/cmParseArgumentsCommand.cxx
@@ -5,59 +5,136 @@
#include <map>
#include <set>
#include <sstream>
-#include <stddef.h>
#include <utility>
-#include "cmAlgorithms.h"
+#include <cm/string_view>
+
+#include "cmArgumentParser.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-
-class cmExecutionStatus;
-static std::string escape_arg(const std::string& arg)
+static std::string EscapeArg(const std::string& arg)
{
// replace ";" with "\;" so output argument lists will split correctly
std::string escapedArg;
- for (size_t i = 0; i < arg.size(); ++i) {
- if (arg[i] == ';') {
+ for (char i : arg) {
+ if (i == ';') {
escapedArg += '\\';
}
- escapedArg += arg[i];
+ escapedArg += i;
}
return escapedArg;
}
-bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+static std::string JoinList(std::vector<std::string> const& arg, bool escape)
+{
+ return escape ? cmJoin(cmMakeRange(arg).transform(EscapeArg), ";")
+ : cmJoin(cmMakeRange(arg), ";");
+}
+
+namespace {
+
+using options_map = std::map<std::string, bool>;
+using single_map = std::map<std::string, std::string>;
+using multi_map = std::map<std::string, std::vector<std::string>>;
+using options_set = std::set<std::string>;
+
+struct UserArgumentParser : public cmArgumentParser<void>
+{
+ template <typename T, typename H>
+ void Bind(std::vector<std::string> const& names,
+ std::map<std::string, T>& ref, H duplicateKey)
+ {
+ for (std::string const& key : names) {
+ auto const it = ref.emplace(key, T{}).first;
+ bool const inserted = this->cmArgumentParser<void>::Bind(
+ cm::string_view(it->first), it->second);
+ if (!inserted) {
+ duplicateKey(key);
+ }
+ }
+ }
+};
+
+} // namespace
+
+static void PassParsedArguments(
+ const std::string& prefix, cmMakefile& makefile, const options_map& options,
+ const single_map& singleValArgs, const multi_map& multiValArgs,
+ const std::vector<std::string>& unparsed,
+ const options_set& keywordsMissingValues, bool parseFromArgV)
+{
+ for (auto const& iter : options) {
+ makefile.AddDefinition(prefix + iter.first,
+ iter.second ? "TRUE" : "FALSE");
+ }
+
+ for (auto const& iter : singleValArgs) {
+ if (!iter.second.empty()) {
+ makefile.AddDefinition(prefix + iter.first, iter.second);
+ } else {
+ makefile.RemoveDefinition(prefix + iter.first);
+ }
+ }
+
+ for (auto const& iter : multiValArgs) {
+ if (!iter.second.empty()) {
+ makefile.AddDefinition(prefix + iter.first,
+ JoinList(iter.second, parseFromArgV));
+ } else {
+ makefile.RemoveDefinition(prefix + iter.first);
+ }
+ }
+
+ if (!unparsed.empty()) {
+ makefile.AddDefinition(prefix + "UNPARSED_ARGUMENTS",
+ JoinList(unparsed, parseFromArgV));
+ } else {
+ makefile.RemoveDefinition(prefix + "UNPARSED_ARGUMENTS");
+ }
+
+ if (!keywordsMissingValues.empty()) {
+ makefile.AddDefinition(prefix + "KEYWORDS_MISSING_VALUES",
+ cmJoin(cmMakeRange(keywordsMissingValues), ";"));
+ } else {
+ makefile.RemoveDefinition(prefix + "KEYWORDS_MISSING_VALUES");
+ }
+}
+
+bool cmParseArgumentsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// cmake_parse_arguments(prefix options single multi <ARGN>)
// 1 2 3 4
// or
// cmake_parse_arguments(PARSE_ARGV N prefix options single multi)
if (args.size() < 4) {
- this->SetError("must be called with at least 4 arguments.");
+ status.SetError("must be called with at least 4 arguments.");
return false;
}
- std::vector<std::string>::const_iterator argIter = args.begin(),
- argEnd = args.end();
+ auto argIter = args.begin();
+ auto argEnd = args.end();
bool parseFromArgV = false;
unsigned long argvStart = 0;
if (*argIter == "PARSE_ARGV") {
if (args.size() != 6) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
"PARSE_ARGV must be called with exactly 6 arguments.");
cmSystemTools::SetFatalErrorOccured();
return true;
}
parseFromArgV = true;
argIter++; // move past PARSE_ARGV
- if (!cmSystemTools::StringToULong(argIter->c_str(), &argvStart)) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, "PARSE_ARGV index '" +
- *argIter +
- "' is not an unsigned integer");
+ if (!cmStrToULong(*argIter, &argvStart)) {
+ status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR,
+ "PARSE_ARGV index '" + *argIter +
+ "' is not an unsigned integer");
cmSystemTools::SetFatalErrorOccured();
return true;
}
@@ -66,179 +143,79 @@ bool cmParseArgumentsCommand::InitialPass(std::vector<std::string> const& args,
// the first argument is the prefix
const std::string prefix = (*argIter++) + "_";
+ UserArgumentParser parser;
+
// define the result maps holding key/value pairs for
// options, single values and multi values
- typedef std::map<std::string, bool> options_map;
- typedef std::map<std::string, std::string> single_map;
- typedef std::map<std::string, std::vector<std::string> > multi_map;
options_map options;
- single_map single;
- multi_map multi;
+ single_map singleValArgs;
+ multi_map multiValArgs;
// anything else is put into a vector of unparsed strings
std::vector<std::string> unparsed;
- // remember already defined keywords
- std::set<std::string> used_keywords;
- const std::string dup_warning = "keyword defined more than once: ";
+ auto const duplicateKey = [&status](std::string const& key) {
+ status.GetMakefile().IssueMessage(
+ MessageType::WARNING, "keyword defined more than once: " + key);
+ };
// the second argument is a (cmake) list of options without argument
- std::vector<std::string> list;
- cmSystemTools::ExpandListArgument(*argIter++, list);
- for (std::vector<std::string>::const_iterator iter = list.begin(),
- end = list.end();
- iter != end; ++iter) {
- if (!used_keywords.insert(*iter).second) {
- this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + *iter);
- }
- options[*iter]; // default initialize
- }
+ std::vector<std::string> list = cmExpandedList(*argIter++);
+ parser.Bind(list, options, duplicateKey);
// the third argument is a (cmake) list of single argument options
list.clear();
- cmSystemTools::ExpandListArgument(*argIter++, list);
- for (std::vector<std::string>::const_iterator iter = list.begin(),
- end = list.end();
- iter != end; ++iter) {
- if (!used_keywords.insert(*iter).second) {
- this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + *iter);
- }
- single[*iter]; // default initialize
- }
+ cmExpandList(*argIter++, list);
+ parser.Bind(list, singleValArgs, duplicateKey);
// the fourth argument is a (cmake) list of multi argument options
list.clear();
- cmSystemTools::ExpandListArgument(*argIter++, list);
- for (std::vector<std::string>::const_iterator iter = list.begin(),
- end = list.end();
- iter != end; ++iter) {
- if (!used_keywords.insert(*iter).second) {
- this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + *iter);
- }
- multi[*iter]; // default initialize
- }
-
- enum insideValues
- {
- NONE,
- SINGLE,
- MULTI
- } insideValues = NONE;
- std::string currentArgName;
+ cmExpandList(*argIter++, list);
+ parser.Bind(list, multiValArgs, duplicateKey);
list.clear();
if (!parseFromArgV) {
// Flatten ;-lists in the arguments into a single list as was done
// by the original function(CMAKE_PARSE_ARGUMENTS).
for (; argIter != argEnd; ++argIter) {
- cmSystemTools::ExpandListArgument(*argIter, list);
+ cmExpandList(*argIter, list);
}
} else {
// in the PARSE_ARGV move read the arguments from ARGC and ARGV#
- std::string argc = this->Makefile->GetSafeDefinition("ARGC");
+ std::string argc = status.GetMakefile().GetSafeDefinition("ARGC");
unsigned long count;
- if (!cmSystemTools::StringToULong(argc.c_str(), &count)) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "PARSE_ARGV called with ARGC='" + argc +
- "' that is not an unsigned integer");
+ if (!cmStrToULong(argc, &count)) {
+ status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR,
+ "PARSE_ARGV called with ARGC='" +
+ argc +
+ "' that is not an unsigned integer");
cmSystemTools::SetFatalErrorOccured();
return true;
}
for (unsigned long i = argvStart; i < count; ++i) {
std::ostringstream argName;
argName << "ARGV" << i;
- const char* arg = this->Makefile->GetDefinition(argName.str());
+ const char* arg = status.GetMakefile().GetDefinition(argName.str());
if (!arg) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "PARSE_ARGV called with " +
- argName.str() + " not set");
+ status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR,
+ "PARSE_ARGV called with " +
+ argName.str() + " not set");
cmSystemTools::SetFatalErrorOccured();
return true;
}
- list.push_back(arg);
+ list.emplace_back(arg);
}
}
- // iterate over the arguments list and fill in the values where applicable
- for (argIter = list.begin(), argEnd = list.end(); argIter != argEnd;
- ++argIter) {
- const options_map::iterator optIter = options.find(*argIter);
- if (optIter != options.end()) {
- insideValues = NONE;
- optIter->second = true;
- continue;
- }
-
- const single_map::iterator singleIter = single.find(*argIter);
- if (singleIter != single.end()) {
- insideValues = SINGLE;
- currentArgName = *argIter;
- continue;
- }
+ std::vector<std::string> keywordsMissingValues;
- const multi_map::iterator multiIter = multi.find(*argIter);
- if (multiIter != multi.end()) {
- insideValues = MULTI;
- currentArgName = *argIter;
- continue;
- }
+ parser.Parse(list, &unparsed, &keywordsMissingValues);
- switch (insideValues) {
- case SINGLE:
- single[currentArgName] = *argIter;
- insideValues = NONE;
- break;
- case MULTI:
- if (parseFromArgV) {
- multi[currentArgName].push_back(escape_arg(*argIter));
- } else {
- multi[currentArgName].push_back(*argIter);
- }
- break;
- default:
- if (parseFromArgV) {
- unparsed.push_back(escape_arg(*argIter));
- } else {
- unparsed.push_back(*argIter);
- }
- break;
- }
- }
-
- // now iterate over the collected values and update their definition
- // within the current scope. undefine if necessary.
-
- for (options_map::const_iterator iter = options.begin(), end = options.end();
- iter != end; ++iter) {
- this->Makefile->AddDefinition(prefix + iter->first,
- iter->second ? "TRUE" : "FALSE");
- }
- for (single_map::const_iterator iter = single.begin(), end = single.end();
- iter != end; ++iter) {
- if (!iter->second.empty()) {
- this->Makefile->AddDefinition(prefix + iter->first,
- iter->second.c_str());
- } else {
- this->Makefile->RemoveDefinition(prefix + iter->first);
- }
- }
-
- for (multi_map::const_iterator iter = multi.begin(), end = multi.end();
- iter != end; ++iter) {
- if (!iter->second.empty()) {
- this->Makefile->AddDefinition(
- prefix + iter->first, cmJoin(cmMakeRange(iter->second), ";").c_str());
- } else {
- this->Makefile->RemoveDefinition(prefix + iter->first);
- }
- }
-
- if (!unparsed.empty()) {
- this->Makefile->AddDefinition(prefix + "UNPARSED_ARGUMENTS",
- cmJoin(cmMakeRange(unparsed), ";").c_str());
- } else {
- this->Makefile->RemoveDefinition(prefix + "UNPARSED_ARGUMENTS");
- }
+ PassParsedArguments(
+ prefix, status.GetMakefile(), options, singleValArgs, multiValArgs,
+ unparsed,
+ options_set(keywordsMissingValues.begin(), keywordsMissingValues.end()),
+ parseFromArgV);
return true;
}
diff --git a/Source/cmParseArgumentsCommand.h b/Source/cmParseArgumentsCommand.h
index 359fb85b9..b2e436d89 100644
--- a/Source/cmParseArgumentsCommand.h
+++ b/Source/cmParseArgumentsCommand.h
@@ -3,32 +3,14 @@
#ifndef cmParseArgumentsCommand_h
#define cmParseArgumentsCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmParseArgumentsCommand
- *
- */
-class cmParseArgumentsCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmParseArgumentsCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmParseArgumentsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmPathLabel.cxx b/Source/cmPathLabel.cxx
index 30ba08151..fb8135101 100644
--- a/Source/cmPathLabel.cxx
+++ b/Source/cmPathLabel.cxx
@@ -2,15 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmPathLabel.h"
-#include <stddef.h>
+#include <utility>
-cmPathLabel::cmPathLabel(const std::string& label)
- : Label(label)
+cmPathLabel::cmPathLabel(std::string label)
+ : Label(std::move(label))
, Hash(0)
{
// Use a Jenkins one-at-a-time hash with under/over-flow protection
- for (size_t i = 0; i < this->Label.size(); ++i) {
- this->Hash += this->Label[i];
+ for (char i : this->Label) {
+ this->Hash += i;
this->Hash += ((this->Hash & 0x003FFFFF) << 10);
this->Hash ^= ((this->Hash & 0xFFFFFFC0) >> 6);
}
diff --git a/Source/cmPathLabel.h b/Source/cmPathLabel.h
index 97551fb46..55dffabe0 100644
--- a/Source/cmPathLabel.h
+++ b/Source/cmPathLabel.h
@@ -17,7 +17,7 @@
class cmPathLabel
{
public:
- cmPathLabel(const std::string& label);
+ cmPathLabel(std::string label);
// The comparison operators are only for quick sorting and searching and
// in no way imply any lexicographical order of the label
diff --git a/Source/cmPipeConnection.cxx b/Source/cmPipeConnection.cxx
new file mode 100644
index 000000000..1eede13e0
--- /dev/null
+++ b/Source/cmPipeConnection.cxx
@@ -0,0 +1,71 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmPipeConnection.h"
+
+#include <utility>
+
+#include "cmServer.h"
+
+cmPipeConnection::cmPipeConnection(std::string name,
+ cmConnectionBufferStrategy* bufferStrategy)
+ : cmEventBasedConnection(bufferStrategy)
+ , PipeName(std::move(name))
+{
+}
+
+void cmPipeConnection::Connect(uv_stream_t* server)
+{
+ if (this->WriteStream.get()) {
+ // Accept and close all pipes but the first:
+ cm::uv_pipe_ptr rejectPipe;
+
+ rejectPipe.init(*this->Server->GetLoop(), 0);
+ uv_accept(server, rejectPipe);
+
+ return;
+ }
+
+ cm::uv_pipe_ptr ClientPipe;
+ ClientPipe.init(*this->Server->GetLoop(), 0,
+ static_cast<cmEventBasedConnection*>(this));
+
+ if (uv_accept(server, ClientPipe) != 0) {
+ return;
+ }
+
+ uv_read_start(ClientPipe, on_alloc_buffer, on_read);
+ WriteStream = std::move(ClientPipe);
+ Server->OnConnected(this);
+}
+
+bool cmPipeConnection::OnServeStart(std::string* errorMessage)
+{
+ this->ServerPipe.init(*this->Server->GetLoop(), 0,
+ static_cast<cmEventBasedConnection*>(this));
+
+ int r;
+ if ((r = uv_pipe_bind(this->ServerPipe, this->PipeName.c_str())) != 0) {
+ *errorMessage = std::string("Internal Error with ") + this->PipeName +
+ ": " + uv_err_name(r);
+ return false;
+ }
+
+ if ((r = uv_listen(this->ServerPipe, 1, on_new_connection)) != 0) {
+ *errorMessage = std::string("Internal Error listening on ") +
+ this->PipeName + ": " + uv_err_name(r);
+ return false;
+ }
+
+ return cmConnection::OnServeStart(errorMessage);
+}
+
+bool cmPipeConnection::OnConnectionShuttingDown()
+{
+ if (this->WriteStream.get()) {
+ this->WriteStream->data = nullptr;
+ }
+
+ this->ServerPipe.reset();
+
+ return cmEventBasedConnection::OnConnectionShuttingDown();
+}
diff --git a/Source/cmPipeConnection.h b/Source/cmPipeConnection.h
new file mode 100644
index 000000000..81f8a49f6
--- /dev/null
+++ b/Source/cmPipeConnection.h
@@ -0,0 +1,29 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#pragma once
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+
+#include "cm_uv.h"
+
+#include "cmConnection.h"
+#include "cmUVHandlePtr.h"
+
+class cmPipeConnection : public cmEventBasedConnection
+{
+public:
+ cmPipeConnection(std::string name,
+ cmConnectionBufferStrategy* bufferStrategy = nullptr);
+
+ bool OnServeStart(std::string* pString) override;
+
+ bool OnConnectionShuttingDown() override;
+
+ void Connect(uv_stream_t* server) override;
+
+private:
+ const std::string PipeName;
+ cm::uv_pipe_ptr ServerPipe;
+};
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index da3edd427..5c8bc98b2 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -1,20 +1,19 @@
#include "cmPolicies.h"
-#include "cmAlgorithms.h"
+#include <cassert>
+#include <cctype>
+#include <cstdio>
+#include <cstring>
+#include <sstream>
+#include <vector>
+
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
-#include "cmake.h"
-
-#include "cmConfigure.h"
-#include <assert.h>
-#include <ctype.h>
-#include <sstream>
-#include <stdio.h>
-#include <string.h>
-#include <vector>
static bool stringToId(const char* input, cmPolicies::PolicyID& pid)
{
@@ -35,7 +34,7 @@ static bool stringToId(const char* input, cmPolicies::PolicyID& pid)
}
}
long id;
- if (!cmSystemTools::StringToLong(input + 3, &id)) {
+ if (!cmStrToLong(input + 3, &id)) {
return false;
}
if (id >= cmPolicies::CMPCOUNT) {
@@ -62,9 +61,9 @@ static const char* idToString(cmPolicies::PolicyID id)
CM_FOR_EACH_POLICY_ID(POLICY_CASE)
#undef POLICY_CASE
case cmPolicies::CMPCOUNT:
- return CM_NULLPTR;
+ return nullptr;
}
- return CM_NULLPTR;
+ return nullptr;
}
static const char* idToVersion(cmPolicies::PolicyID id)
@@ -76,9 +75,9 @@ static const char* idToVersion(cmPolicies::PolicyID id)
CM_FOR_EACH_POLICY_ID_VERSION(POLICY_CASE)
#undef POLICY_CASE
case cmPolicies::CMPCOUNT:
- return CM_NULLPTR;
+ return nullptr;
}
- return CM_NULLPTR;
+ return nullptr;
}
static bool isPolicyNewerThan(cmPolicies::PolicyID id, unsigned int majorV,
@@ -108,9 +107,9 @@ const char* idToShortDescription(cmPolicies::PolicyID id)
CM_FOR_EACH_POLICY_ID_DOC(POLICY_CASE)
#undef POLICY_CASE
case cmPolicies::CMPCOUNT:
- return CM_NULLPTR;
+ return nullptr;
}
- return CM_NULLPTR;
+ return nullptr;
}
static void DiagnoseAncientPolicies(
@@ -121,67 +120,61 @@ static void DiagnoseAncientPolicies(
e << "The project requests behavior compatible with CMake version \""
<< majorVer << "." << minorVer << "." << patchVer
<< "\", which requires the OLD behavior for some policies:\n";
- for (std::vector<cmPolicies::PolicyID>::const_iterator i = ancient.begin();
- i != ancient.end(); ++i) {
- e << " " << idToString(*i) << ": " << idToShortDescription(*i) << "\n";
+ for (cmPolicies::PolicyID i : ancient) {
+ e << " " << idToString(i) << ": " << idToShortDescription(i) << "\n";
}
e << "However, this version of CMake no longer supports the OLD "
<< "behavior for these policies. "
<< "Please either update your CMakeLists.txt files to conform to "
<< "the new behavior or use an older version of CMake that still "
<< "supports the old behavior.";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
}
static bool GetPolicyDefault(cmMakefile* mf, std::string const& policy,
cmPolicies::PolicyStatus* defaultSetting)
{
std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
- std::string defaultValue = mf->GetSafeDefinition(defaultVar);
+ std::string const& defaultValue = mf->GetSafeDefinition(defaultVar);
if (defaultValue == "NEW") {
*defaultSetting = cmPolicies::NEW;
} else if (defaultValue == "OLD") {
*defaultSetting = cmPolicies::OLD;
- } else if (defaultValue == "") {
+ } else if (defaultValue.empty()) {
*defaultSetting = cmPolicies::WARN;
} else {
std::ostringstream e;
e << defaultVar << " has value \"" << defaultValue
- << "\" but must be \"OLD\", \"NEW\", or \"\" (empty).";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ << R"(" but must be "OLD", "NEW", or "" (empty).)";
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
return true;
}
-bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, const char* version)
+bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf,
+ std::string const& version_min,
+ std::string const& version_max)
{
- std::string ver = "2.4.0";
-
- if (version && strlen(version) > 0) {
- ver = version;
- }
-
- unsigned int majorVer = 2;
- unsigned int minorVer = 0;
- unsigned int patchVer = 0;
- unsigned int tweakVer = 0;
-
- // parse the string
- if (sscanf(ver.c_str(), "%u.%u.%u.%u", &majorVer, &minorVer, &patchVer,
- &tweakVer) < 2) {
+ // Parse components of the minimum version.
+ unsigned int minMajor = 2;
+ unsigned int minMinor = 0;
+ unsigned int minPatch = 0;
+ unsigned int minTweak = 0;
+ if (sscanf(version_min.c_str(), "%u.%u.%u.%u", &minMajor, &minMinor,
+ &minPatch, &minTweak) < 2) {
std::ostringstream e;
- e << "Invalid policy version value \"" << ver << "\". "
+ e << "Invalid policy version value \"" << version_min << "\". "
<< "A numeric major.minor[.patch[.tweak]] must be given.";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
// it is an error if the policy version is less than 2.4
- if (majorVer < 2 || (majorVer == 2 && minorVer < 4)) {
+ if (minMajor < 2 || (minMajor == 2 && minMinor < 4)) {
mf->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"Compatibility with CMake < 2.4 is not supported by CMake >= 3.0. "
"For compatibility with older versions please use any CMake 2.8.x "
"release or lower.");
@@ -190,26 +183,72 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, const char* version)
// It is an error if the policy version is greater than the running
// CMake.
- if (majorVer > cmVersion::GetMajorVersion() ||
- (majorVer == cmVersion::GetMajorVersion() &&
- minorVer > cmVersion::GetMinorVersion()) ||
- (majorVer == cmVersion::GetMajorVersion() &&
- minorVer == cmVersion::GetMinorVersion() &&
- patchVer > cmVersion::GetPatchVersion()) ||
- (majorVer == cmVersion::GetMajorVersion() &&
- minorVer == cmVersion::GetMinorVersion() &&
- patchVer == cmVersion::GetPatchVersion() &&
- tweakVer > cmVersion::GetTweakVersion())) {
+ if (minMajor > cmVersion::GetMajorVersion() ||
+ (minMajor == cmVersion::GetMajorVersion() &&
+ minMinor > cmVersion::GetMinorVersion()) ||
+ (minMajor == cmVersion::GetMajorVersion() &&
+ minMinor == cmVersion::GetMinorVersion() &&
+ minPatch > cmVersion::GetPatchVersion()) ||
+ (minMajor == cmVersion::GetMajorVersion() &&
+ minMinor == cmVersion::GetMinorVersion() &&
+ minPatch == cmVersion::GetPatchVersion() &&
+ minTweak > cmVersion::GetTweakVersion())) {
std::ostringstream e;
e << "An attempt was made to set the policy version of CMake to \""
- << version << "\" which is greater than this version of CMake. "
+ << version_min << "\" which is greater than this version of CMake. "
<< "This is not allowed because the greater version may have new "
<< "policies not known to this CMake. "
<< "You may need a newer CMake version to build this project.";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
return false;
}
+ unsigned int polMajor = minMajor;
+ unsigned int polMinor = minMinor;
+ unsigned int polPatch = minPatch;
+
+ if (!version_max.empty()) {
+ // Parse components of the maximum version.
+ unsigned int maxMajor = 0;
+ unsigned int maxMinor = 0;
+ unsigned int maxPatch = 0;
+ unsigned int maxTweak = 0;
+ if (sscanf(version_max.c_str(), "%u.%u.%u.%u", &maxMajor, &maxMinor,
+ &maxPatch, &maxTweak) < 2) {
+ std::ostringstream e;
+ e << "Invalid policy max version value \"" << version_max << "\". "
+ << "A numeric major.minor[.patch[.tweak]] must be given.";
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return false;
+ }
+
+ // It is an error if the min version is greater than the max version.
+ if (minMajor > maxMajor || (minMajor == maxMajor && minMinor > maxMinor) ||
+ (minMajor == maxMajor && minMinor == maxMinor &&
+ minPatch > maxPatch) ||
+ (minMajor == maxMajor && minMinor == maxMinor &&
+ minPatch == maxPatch && minTweak > maxTweak)) {
+ std::ostringstream e;
+ e << "Policy VERSION range \"" << version_min << "..." << version_max
+ << "\""
+ << " specifies a larger minimum than maximum.";
+ mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return false;
+ }
+
+ // Use the max version as the policy version.
+ polMajor = maxMajor;
+ polMinor = maxMinor;
+ polPatch = maxPatch;
+ }
+
+ return cmPolicies::ApplyPolicyVersion(mf, polMajor, polMinor, polPatch);
+}
+
+bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer,
+ unsigned int minorVer,
+ unsigned int patchVer)
+{
// now loop over all the policies and set them as appropriate
std::vector<cmPolicies::PolicyID> ancientPolicies;
for (PolicyID pid = cmPolicies::CMP0000; pid != cmPolicies::CMPCOUNT;
@@ -260,18 +299,21 @@ bool cmPolicies::GetPolicyID(const char* id, cmPolicies::PolicyID& pid)
return stringToId(id, pid);
}
-///! return a warning string for a given policy
+//! return a warning string for a given policy
std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id)
{
std::ostringstream msg;
- msg << "Policy " << idToString(id) << " is not set: "
- ""
- << idToShortDescription(id) << " "
- "Run \"cmake --help-policy "
- << idToString(id) << "\" for "
- "policy details. "
- "Use the cmake_policy command to set the policy "
- "and suppress this warning.";
+ msg << "Policy " << idToString(id)
+ << " is not set: "
+ ""
+ << idToShortDescription(id)
+ << " "
+ "Run \"cmake --help-policy "
+ << idToString(id)
+ << "\" for "
+ "policy details. "
+ "Use the cmake_policy command to set the policy "
+ "and suppress this warning.";
return msg.str();
}
@@ -291,30 +333,33 @@ std::string cmPolicies::GetPolicyDeprecatedWarning(cmPolicies::PolicyID id)
return msg.str();
}
-///! return an error string for when a required policy is unspecified
+//! return an error string for when a required policy is unspecified
std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id)
{
std::ostringstream error;
- error << "Policy " << idToString(id) << " is not set to NEW: "
- ""
- << idToShortDescription(id) << " "
- "Run \"cmake --help-policy "
+ error << "Policy " << idToString(id)
+ << " is not set to NEW: "
+ ""
+ << idToShortDescription(id)
+ << " "
+ "Run \"cmake --help-policy "
<< idToString(id)
<< "\" for "
"policy details. "
"CMake now requires this policy to be set to NEW by the project. "
"The policy may be set explicitly using the code\n"
" cmake_policy(SET "
- << idToString(id) << " NEW)\n"
- "or by upgrading all policies with the code\n"
- " cmake_policy(VERSION "
+ << idToString(id)
+ << " NEW)\n"
+ "or by upgrading all policies with the code\n"
+ " cmake_policy(VERSION "
<< idToVersion(id)
<< ") # or later\n"
"Run \"cmake --help-command cmake_policy\" for more information.";
return error.str();
}
-///! Get the default status for a policy
+//! Get the default status for a policy
cmPolicies::PolicyStatus cmPolicies::GetPolicyStatus(
cmPolicies::PolicyID /*unused*/)
{
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 69cbc1844..92c80bb4c 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -126,7 +126,7 @@ class cmMakefile;
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0040, \
"The target in the TARGET signature of add_custom_command() must " \
- "exist.", \
+ "exist and must be defined in the current directory.", \
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0041, \
"Error on relative include with generator expression.", 3, 0, 0, \
@@ -155,8 +155,9 @@ class cmMakefile;
3, 0, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0051, "List TARGET_OBJECTS in SOURCES target property.", \
3, 1, 0, cmPolicies::WARN) \
- SELECT(POLICY, CMP0052, "Reject source and build dirs in installed " \
- "INTERFACE_INCLUDE_DIRECTORIES.", \
+ SELECT(POLICY, CMP0052, \
+ "Reject source and build dirs in installed " \
+ "INTERFACE_INCLUDE_DIRECTORIES.", \
3, 1, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0053, \
"Simplify variable reference and escape sequence evaluation.", 3, 1, \
@@ -206,7 +207,90 @@ class cmMakefile;
cmPolicies::WARN) \
SELECT(POLICY, CMP0069, \
"INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.", 3, 9, 0, \
- cmPolicies::WARN)
+ cmPolicies::WARN) \
+ SELECT(POLICY, CMP0070, \
+ "Define file(GENERATE) behavior for relative paths.", 3, 10, 0, \
+ cmPolicies::WARN) \
+ SELECT(POLICY, CMP0071, "Let AUTOMOC and AUTOUIC process GENERATED files.", \
+ 3, 10, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0072, \
+ "FindOpenGL prefers GLVND by default when available.", 3, 11, 0, \
+ cmPolicies::WARN) \
+ SELECT(POLICY, CMP0073, \
+ "Do not produce legacy _LIB_DEPENDS cache entries.", 3, 12, 0, \
+ cmPolicies::WARN) \
+ SELECT(POLICY, CMP0074, "find_package uses <PackageName>_ROOT variables.", \
+ 3, 12, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0075, \
+ "Include file check macros honor CMAKE_REQUIRED_LIBRARIES.", 3, 12, \
+ 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0076, \
+ "target_sources() command converts relative paths to absolute.", 3, \
+ 13, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0077, "option() honors normal variables.", 3, 13, 0, \
+ cmPolicies::WARN) \
+ SELECT(POLICY, CMP0078, "UseSWIG generates standard target names.", 3, 13, \
+ 0, cmPolicies::WARN) \
+ SELECT( \
+ POLICY, CMP0079, \
+ "target_link_libraries allows use with targets in other directories.", 3, \
+ 13, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0080, \
+ "BundleUtilities cannot be included at configure time.", 3, 13, 0, \
+ cmPolicies::WARN) \
+ SELECT(POLICY, CMP0081, \
+ "Relative paths not allowed in LINK_DIRECTORIES target property.", \
+ 3, 13, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0082, \
+ "Install rules from add_subdirectory() are interleaved with those " \
+ "in caller.", \
+ 3, 14, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0083, "Add PIE options when linking executable.", 3, 14, \
+ 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0084, \
+ "The FindQt module does not exist for find_package().", 3, 14, 0, \
+ cmPolicies::WARN) \
+ SELECT(POLICY, CMP0085, "$<IN_LIST:...> handles empty list items.", 3, 14, \
+ 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0086, \
+ "UseSWIG honors SWIG_MODULE_NAME via -module flag.", 3, 14, 0, \
+ cmPolicies::WARN) \
+ SELECT(POLICY, CMP0087, \
+ "Install CODE|SCRIPT allow the use of generator " \
+ "expressions.", \
+ 3, 14, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0088, \
+ "FindBISON runs bison in CMAKE_CURRENT_BINARY_DIR when executing.", \
+ 3, 14, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0089, \
+ "Compiler id for IBM Clang-based XL compilers is now XLClang.", 3, \
+ 15, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0090, \
+ "export(PACKAGE) does not populate package registry by default.", 3, \
+ 15, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0091, \
+ "MSVC runtime library flags are selected by an abstraction.", 3, 15, \
+ 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0092, \
+ "MSVC warning flags are not in CMAKE_<LANG>_FLAGS by default.", 3, \
+ 15, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0093, "FindBoost reports Boost_VERSION in x.y.z format.", \
+ 3, 15, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0094, \
+ "FindPython3, FindPython2 and FindPyton use " \
+ "LOCATION for lookup strategy.", \
+ 3, 15, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0095, \
+ "RPATH entries are properly escaped in the intermediary CMake " \
+ "install script.", \
+ 3, 16, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0096, \
+ "project() preserves leading zeros in version components.", 3, 16, \
+ 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0097, \
+ "ExternalProject_Add with GIT_SUBMODULES \"\" initializes no " \
+ "submodules.", \
+ 3, 16, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
@@ -220,6 +304,7 @@ class cmMakefile;
F(CMP0021) \
F(CMP0022) \
F(CMP0027) \
+ F(CMP0037) \
F(CMP0038) \
F(CMP0041) \
F(CMP0042) \
@@ -229,14 +314,17 @@ class cmMakefile;
F(CMP0063) \
F(CMP0065) \
F(CMP0068) \
- F(CMP0069)
+ F(CMP0069) \
+ F(CMP0073) \
+ F(CMP0076) \
+ F(CMP0081) \
+ F(CMP0083) \
+ F(CMP0095)
/** \class cmPolicies
* \brief Handles changes in CMake behavior and policies
*
- * See the cmake wiki section on
- * <a href="https://cmake.org/Wiki/CMake/Policies">policies</a>
- * for an overview of this class's purpose
+ * See the cmake-policies(7) manual for an overview of this class's purpose.
*/
class cmPolicies
{
@@ -268,23 +356,27 @@ public:
CMPCOUNT
};
- ///! convert a string policy ID into a number
+ //! convert a string policy ID into a number
static bool GetPolicyID(const char* id, /* out */ cmPolicies::PolicyID& pid);
- ///! Get the default status for a policy
+ //! Get the default status for a policy
static cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id);
- ///! Set a policy level for this listfile
- static bool ApplyPolicyVersion(cmMakefile* mf, const char* version);
+ //! Set a policy level for this listfile
+ static bool ApplyPolicyVersion(cmMakefile* mf,
+ std::string const& version_min,
+ std::string const& version_max);
+ static bool ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer,
+ unsigned int minorVer, unsigned int patchVer);
- ///! return a warning string for a given policy
+ //! return a warning string for a given policy
static std::string GetPolicyWarning(cmPolicies::PolicyID id);
static std::string GetPolicyDeprecatedWarning(cmPolicies::PolicyID id);
- ///! return an error string for when a required policy is unspecified
+ //! return an error string for when a required policy is unspecified
static std::string GetRequiredPolicyError(cmPolicies::PolicyID id);
- ///! return an error string for when a required policy is unspecified
+ //! return an error string for when a required policy is unspecified
static std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id);
/** Represent a set of policy values. */
diff --git a/Source/cmProcessOutput.cxx b/Source/cmProcessOutput.cxx
index 617e1ca7d..e80ea5c8d 100644
--- a/Source/cmProcessOutput.cxx
+++ b/Source/cmProcessOutput.cxx
@@ -4,7 +4,7 @@
#include "cmProcessOutput.h"
#if defined(_WIN32)
-#include <windows.h>
+# include <windows.h>
unsigned int cmProcessOutput::defaultCodepage =
KWSYS_ENCODING_DEFAULT_CODEPAGE;
#endif
@@ -13,7 +13,7 @@ cmProcessOutput::Encoding cmProcessOutput::FindEncoding(
std::string const& name)
{
Encoding encoding = Auto;
- if (name == "UTF8") {
+ if ((name == "UTF8") || (name == "UTF-8")) {
encoding = UTF8;
} else if (name == "NONE") {
encoding = None;
@@ -48,9 +48,7 @@ cmProcessOutput::cmProcessOutput(Encoding encoding, unsigned int maxSize)
#endif
}
-cmProcessOutput::~cmProcessOutput()
-{
-}
+cmProcessOutput::~cmProcessOutput() = default;
bool cmProcessOutput::DecodeText(std::string raw, std::string& decoded,
size_t id)
diff --git a/Source/cmProcessOutput.h b/Source/cmProcessOutput.h
index b5ec4a8be..3db47a4b4 100644
--- a/Source/cmProcessOutput.h
+++ b/Source/cmProcessOutput.h
@@ -5,7 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <stddef.h>
+#include <cstddef>
#include <string>
#include <vector>
@@ -28,10 +28,10 @@ public:
};
/**
- * Find encoding enum value for given encoding \a name.
- * \param name a encoding name.
- * \return encoding enum value or Auto if \a name was not found.
- */
+ * Find encoding enum value for given encoding \a name.
+ * \param name a encoding name.
+ * \return encoding enum value or Auto if \a name was not found.
+ */
static Encoding FindEncoding(std::string const& name);
/// The code page that is used as internal encoding to which we will encode.
diff --git a/Source/cmProcessTools.cxx b/Source/cmProcessTools.cxx
index de7b06126..9ebf5b771 100644
--- a/Source/cmProcessTools.cxx
+++ b/Source/cmProcessTools.cxx
@@ -1,31 +1,33 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmProcessTools.h"
-#include "cmProcessOutput.h"
-#include "cmsys/Process.h"
#include <ostream>
+#include "cmsys/Process.h"
+
+#include "cmProcessOutput.h"
+
void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out,
OutputParser* err, Encoding encoding)
{
cmsysProcess_Execute(cp);
- char* data = CM_NULLPTR;
+ char* data = nullptr;
int length = 0;
int p;
cmProcessOutput processOutput(encoding);
std::string strdata;
while ((out || err) &&
- (p = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR), p)) {
+ (p = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) {
if (out && p == cmsysProcess_Pipe_STDOUT) {
processOutput.DecodeText(data, length, strdata, 1);
if (!out->Process(strdata.c_str(), int(strdata.size()))) {
- out = CM_NULLPTR;
+ out = nullptr;
}
} else if (err && p == cmsysProcess_Pipe_STDERR) {
processOutput.DecodeText(data, length, strdata, 2);
if (!err->Process(strdata.c_str(), int(strdata.size()))) {
- err = CM_NULLPTR;
+ err = nullptr;
}
}
}
@@ -38,17 +40,14 @@ void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out,
if (err) {
processOutput.DecodeText(std::string(), strdata, 2);
if (!strdata.empty()) {
- out->Process(strdata.c_str(), int(strdata.size()));
+ err->Process(strdata.c_str(), int(strdata.size()));
}
}
- cmsysProcess_WaitForExit(cp, CM_NULLPTR);
+ cmsysProcess_WaitForExit(cp, nullptr);
}
cmProcessTools::LineParser::LineParser(char sep, bool ignoreCR)
- : Log(CM_NULLPTR)
- , Prefix(CM_NULLPTR)
- , Separator(sep)
- , LineEnd('\0')
+ : Separator(sep)
, IgnoreCR(ignoreCR)
{
}
@@ -73,11 +72,11 @@ bool cmProcessTools::LineParser::ProcessChunk(const char* first, int length)
// Hand this line to the subclass implementation.
if (!this->ProcessLine()) {
- this->Line = "";
+ this->Line.clear();
return false;
}
- this->Line = "";
+ this->Line.clear();
} else if (*c != '\r' || !this->IgnoreCR) {
// Append this character to the line under construction.
this->Line.append(1, *c);
diff --git a/Source/cmProcessTools.h b/Source/cmProcessTools.h
index e7d9a10eb..21d59c463 100644
--- a/Source/cmProcessTools.h
+++ b/Source/cmProcessTools.h
@@ -3,13 +3,14 @@
#ifndef cmProcessTools_h
#define cmProcessTools_h
-#include "cmConfigure.h"
-#include "cmProcessOutput.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <cstring>
#include <iosfwd>
-#include <string.h>
#include <string>
+#include "cmProcessOutput.h"
+
/** \class cmProcessTools
* \brief Helper classes for process output parsing
*
@@ -17,7 +18,7 @@
class cmProcessTools
{
public:
- typedef cmProcessOutput::Encoding Encoding;
+ using Encoding = cmProcessOutput::Encoding;
/** Abstract interface for process output parsers. */
class OutputParser
{
@@ -34,7 +35,8 @@ public:
return this->Process(data, static_cast<int>(strlen(data)));
}
- virtual ~OutputParser() {}
+ virtual ~OutputParser() = default;
+
protected:
/** Implement in a subclass to process a chunk of data. It should
return true only if it is interested in more data. */
@@ -53,13 +55,13 @@ public:
void SetLog(std::ostream* log, const char* prefix);
protected:
- std::ostream* Log;
- const char* Prefix;
+ std::ostream* Log = nullptr;
+ const char* Prefix = nullptr;
std::string Line;
char Separator;
- char LineEnd;
+ char LineEnd = '\0';
bool IgnoreCR;
- bool ProcessChunk(const char* data, int length) CM_OVERRIDE;
+ bool ProcessChunk(const char* data, int length) override;
/** Implement in a subclass to process one line of input. It
should return true only if it is interested in more data. */
@@ -70,18 +72,18 @@ public:
class OutputLogger : public LineParser
{
public:
- OutputLogger(std::ostream& log, const char* prefix = CM_NULLPTR)
+ OutputLogger(std::ostream& log, const char* prefix = nullptr)
{
this->SetLog(&log, prefix);
}
private:
- bool ProcessLine() CM_OVERRIDE { return true; }
+ bool ProcessLine() override { return true; }
};
/** Run a process and send output to given parsers. */
static void RunProcess(struct cmsysProcess_s* cp, OutputParser* out,
- OutputParser* err = CM_NULLPTR,
+ OutputParser* err = nullptr,
Encoding encoding = cmProcessOutput::Auto);
};
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index d72c7909c..7bb5209da 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -2,52 +2,56 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmProjectCommand.h"
+#include <array>
+#include <cstddef>
+#include <cstdio>
+#include <functional>
+#include <limits>
+#include <utility>
+
#include "cmsys/RegularExpression.hxx"
-#include <sstream>
-#include <stdio.h>
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmake.h"
-class cmExecutionStatus;
+static bool IncludeByVariable(cmExecutionStatus& status,
+ const std::string& variable);
+static void TopLevelCMakeVarCondSet(cmMakefile& mf, std::string const& name,
+ std::string const& value);
-// cmProjectCommand
-bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmProjectCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("PROJECT called with incorrect number of arguments");
+ status.SetError("PROJECT called with incorrect number of arguments");
return false;
}
- std::string const& projectName = args[0];
-
- this->Makefile->SetProjectName(projectName);
+ cmMakefile& mf = status.GetMakefile();
+ if (!IncludeByVariable(status, "CMAKE_PROJECT_INCLUDE_BEFORE")) {
+ return false;
+ }
- std::string bindir = projectName;
- bindir += "_BINARY_DIR";
- std::string srcdir = projectName;
- srcdir += "_SOURCE_DIR";
+ std::string const& projectName = args[0];
- this->Makefile->AddCacheDefinition(
- bindir, this->Makefile->GetCurrentBinaryDirectory(),
- "Value Computed by CMake", cmStateEnums::STATIC);
- this->Makefile->AddCacheDefinition(
- srcdir, this->Makefile->GetCurrentSourceDirectory(),
- "Value Computed by CMake", cmStateEnums::STATIC);
+ mf.SetProjectName(projectName);
- bindir = "PROJECT_BINARY_DIR";
- srcdir = "PROJECT_SOURCE_DIR";
+ mf.AddCacheDefinition(projectName + "_BINARY_DIR",
+ mf.GetCurrentBinaryDirectory().c_str(),
+ "Value Computed by CMake", cmStateEnums::STATIC);
+ mf.AddCacheDefinition(projectName + "_SOURCE_DIR",
+ mf.GetCurrentSourceDirectory().c_str(),
+ "Value Computed by CMake", cmStateEnums::STATIC);
- this->Makefile->AddDefinition(bindir,
- this->Makefile->GetCurrentBinaryDirectory());
- this->Makefile->AddDefinition(srcdir,
- this->Makefile->GetCurrentSourceDirectory());
+ mf.AddDefinition("PROJECT_BINARY_DIR", mf.GetCurrentBinaryDirectory());
+ mf.AddDefinition("PROJECT_SOURCE_DIR", mf.GetCurrentSourceDirectory());
- this->Makefile->AddDefinition("PROJECT_NAME", projectName.c_str());
+ mf.AddDefinition("PROJECT_NAME", projectName);
// Set the CMAKE_PROJECT_NAME variable to be the highest-level
// project name in the tree. If there are two project commands
@@ -55,23 +59,29 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
// CMakeLists.txt file, then go with the last one, so that
// CMAKE_PROJECT_NAME will match PROJECT_NAME, and cmake --build
// will work.
- if (!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME") ||
- (this->Makefile->IsRootMakefile())) {
- this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", projectName.c_str());
- this->Makefile->AddCacheDefinition(
- "CMAKE_PROJECT_NAME", projectName.c_str(), "Value Computed by CMake",
- cmStateEnums::STATIC);
+ if (!mf.GetDefinition("CMAKE_PROJECT_NAME") || mf.IsRootMakefile()) {
+ mf.AddDefinition("CMAKE_PROJECT_NAME", projectName);
+ mf.AddCacheDefinition("CMAKE_PROJECT_NAME", projectName.c_str(),
+ "Value Computed by CMake", cmStateEnums::STATIC);
}
bool haveVersion = false;
bool haveLanguages = false;
bool haveDescription = false;
+ bool haveHomepage = false;
+ bool injectedProjectCommand = false;
std::string version;
std::string description;
+ std::string homepage;
std::vector<std::string> languages;
+ std::function<void()> missedValueReporter;
+ auto resetReporter = [&missedValueReporter]() {
+ missedValueReporter = std::function<void()>();
+ };
enum Doing
{
DoingDescription,
+ DoingHomepage,
DoingLanguages,
DoingVersion
};
@@ -79,175 +89,292 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
for (size_t i = 1; i < args.size(); ++i) {
if (args[i] == "LANGUAGES") {
if (haveLanguages) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR, "LANGUAGES may be specified at most once.");
+ mf.IssueMessage(MessageType::FATAL_ERROR,
+ "LANGUAGES may be specified at most once.");
cmSystemTools::SetFatalErrorOccured();
return true;
}
haveLanguages = true;
+ if (missedValueReporter) {
+ missedValueReporter();
+ }
doing = DoingLanguages;
+ if (!languages.empty()) {
+ std::string msg = cmStrCat(
+ "the following parameters must be specified after LANGUAGES "
+ "keyword: ",
+ cmJoin(languages, ", "), '.');
+ mf.IssueMessage(MessageType::WARNING, msg);
+ }
} else if (args[i] == "VERSION") {
if (haveVersion) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "VERSION may be specified at most once.");
+ mf.IssueMessage(MessageType::FATAL_ERROR,
+ "VERSION may be specified at most once.");
cmSystemTools::SetFatalErrorOccured();
return true;
}
haveVersion = true;
+ if (missedValueReporter) {
+ missedValueReporter();
+ }
doing = DoingVersion;
+ missedValueReporter = [&mf, &resetReporter]() {
+ mf.IssueMessage(
+ MessageType::WARNING,
+ "VERSION keyword not followed by a value or was followed by a "
+ "value that expanded to nothing.");
+ resetReporter();
+ };
} else if (args[i] == "DESCRIPTION") {
if (haveDescription) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR, "DESCRITPION may be specified at most once.");
+ mf.IssueMessage(MessageType::FATAL_ERROR,
+ "DESCRIPTION may be specified at most once.");
cmSystemTools::SetFatalErrorOccured();
return true;
}
haveDescription = true;
+ if (missedValueReporter) {
+ missedValueReporter();
+ }
doing = DoingDescription;
+ missedValueReporter = [&mf, &resetReporter]() {
+ mf.IssueMessage(
+ MessageType::WARNING,
+ "DESCRIPTION keyword not followed by a value or was followed "
+ "by a value that expanded to nothing.");
+ resetReporter();
+ };
+ } else if (args[i] == "HOMEPAGE_URL") {
+ if (haveHomepage) {
+ mf.IssueMessage(MessageType::FATAL_ERROR,
+ "HOMEPAGE_URL may be specified at most once.");
+ cmSystemTools::SetFatalErrorOccured();
+ return true;
+ }
+ haveHomepage = true;
+ doing = DoingHomepage;
+ missedValueReporter = [&mf, &resetReporter]() {
+ mf.IssueMessage(
+ MessageType::WARNING,
+ "HOMEPAGE_URL keyword not followed by a value or was followed "
+ "by a value that expanded to nothing.");
+ resetReporter();
+ };
+ } else if (i == 1 && args[i] == "__CMAKE_INJECTED_PROJECT_COMMAND__") {
+ injectedProjectCommand = true;
} else if (doing == DoingVersion) {
doing = DoingLanguages;
version = args[i];
+ resetReporter();
} else if (doing == DoingDescription) {
doing = DoingLanguages;
description = args[i];
+ resetReporter();
+ } else if (doing == DoingHomepage) {
+ doing = DoingLanguages;
+ homepage = args[i];
+ resetReporter();
} else // doing == DoingLanguages
{
languages.push_back(args[i]);
}
}
- if (haveVersion && !haveLanguages && !languages.empty()) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
- "project with VERSION must use LANGUAGES before language names.");
+ if (missedValueReporter) {
+ missedValueReporter();
+ }
+
+ if ((haveVersion || haveDescription || haveHomepage) && !haveLanguages &&
+ !languages.empty()) {
+ mf.IssueMessage(MessageType::FATAL_ERROR,
+ "project with VERSION, DESCRIPTION or HOMEPAGE_URL must "
+ "use LANGUAGES before language names.");
cmSystemTools::SetFatalErrorOccured();
return true;
}
if (haveLanguages && languages.empty()) {
- languages.push_back("NONE");
+ languages.emplace_back("NONE");
}
- cmPolicies::PolicyStatus cmp0048 =
- this->Makefile->GetPolicyStatus(cmPolicies::CMP0048);
+ cmPolicies::PolicyStatus const cmp0048 =
+ mf.GetPolicyStatus(cmPolicies::CMP0048);
if (haveVersion) {
// Set project VERSION variables to given values
if (cmp0048 == cmPolicies::OLD || cmp0048 == cmPolicies::WARN) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
- "VERSION not allowed unless CMP0048 is set to NEW");
+ mf.IssueMessage(MessageType::FATAL_ERROR,
+ "VERSION not allowed unless CMP0048 is set to NEW");
cmSystemTools::SetFatalErrorOccured();
return true;
}
cmsys::RegularExpression vx(
- "^([0-9]+(\\.[0-9]+(\\.[0-9]+(\\.[0-9]+)?)?)?)?$");
+ R"(^([0-9]+(\.[0-9]+(\.[0-9]+(\.[0-9]+)?)?)?)?$)");
if (!vx.find(version)) {
- std::string e = "VERSION \"" + version + "\" format invalid.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e);
+ std::string e = R"(VERSION ")" + version + R"(" format invalid.)";
+ mf.IssueMessage(MessageType::FATAL_ERROR, e);
cmSystemTools::SetFatalErrorOccured();
return true;
}
- std::string vs;
- const char* sep = "";
- char vb[4][64];
- unsigned int v[4] = { 0, 0, 0, 0 };
- int vc =
- sscanf(version.c_str(), "%u.%u.%u.%u", &v[0], &v[1], &v[2], &v[3]);
- for (int i = 0; i < 4; ++i) {
- if (i < vc) {
- sprintf(vb[i], "%u", v[i]);
- vs += sep;
- vs += vb[i];
- sep = ".";
- } else {
- vb[i][0] = 0;
+ cmPolicies::PolicyStatus const cmp0096 =
+ mf.GetPolicyStatus(cmPolicies::CMP0096);
+
+ constexpr std::size_t MAX_VERSION_COMPONENTS = 4u;
+ std::string version_string;
+ std::array<std::string, MAX_VERSION_COMPONENTS> version_components;
+
+ if (cmp0096 == cmPolicies::OLD || cmp0096 == cmPolicies::WARN) {
+ char vb[MAX_VERSION_COMPONENTS]
+ [std::numeric_limits<unsigned>::digits10 + 2];
+ unsigned v[MAX_VERSION_COMPONENTS] = { 0, 0, 0, 0 };
+ const int vc = std::sscanf(version.c_str(), "%u.%u.%u.%u", &v[0], &v[1],
+ &v[2], &v[3]);
+ for (auto i = 0u; i < MAX_VERSION_COMPONENTS; ++i) {
+ if (int(i) < vc) {
+ std::sprintf(vb[i], "%u", v[i]);
+ version_string += &"."[std::size_t(i == 0)];
+ version_string += vb[i];
+ version_components[i] = vb[i];
+ } else {
+ vb[i][0] = '\x00';
+ }
+ }
+ } else {
+ // The regex above verified that we have a .-separated string of
+ // non-negative integer components. Keep the original string.
+ version_string = std::move(version);
+ // Split the integer components.
+ auto components = cmSystemTools::SplitString(version_string, '.');
+ for (auto i = 0u; i < components.size(); ++i) {
+ version_components[i] = std::move(components[i]);
}
}
std::string vv;
vv = projectName + "_VERSION";
- this->Makefile->AddDefinition("PROJECT_VERSION", vs.c_str());
- this->Makefile->AddDefinition(vv, vs.c_str());
+ mf.AddDefinition("PROJECT_VERSION", version_string);
+ mf.AddDefinition(vv, version_string);
vv = projectName + "_VERSION_MAJOR";
- this->Makefile->AddDefinition("PROJECT_VERSION_MAJOR", vb[0]);
- this->Makefile->AddDefinition(vv, vb[0]);
+ mf.AddDefinition("PROJECT_VERSION_MAJOR", version_components[0]);
+ mf.AddDefinition(vv, version_components[0]);
vv = projectName + "_VERSION_MINOR";
- this->Makefile->AddDefinition("PROJECT_VERSION_MINOR", vb[1]);
- this->Makefile->AddDefinition(vv, vb[1]);
+ mf.AddDefinition("PROJECT_VERSION_MINOR", version_components[1]);
+ mf.AddDefinition(vv, version_components[1]);
vv = projectName + "_VERSION_PATCH";
- this->Makefile->AddDefinition("PROJECT_VERSION_PATCH", vb[2]);
- this->Makefile->AddDefinition(vv, vb[2]);
+ mf.AddDefinition("PROJECT_VERSION_PATCH", version_components[2]);
+ mf.AddDefinition(vv, version_components[2]);
vv = projectName + "_VERSION_TWEAK";
- this->Makefile->AddDefinition("PROJECT_VERSION_TWEAK", vb[3]);
- this->Makefile->AddDefinition(vv, vb[3]);
+ mf.AddDefinition("PROJECT_VERSION_TWEAK", version_components[3]);
+ mf.AddDefinition(vv, version_components[3]);
+ // Also, try set top level variables
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION", version_string);
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION_MAJOR",
+ version_components[0]);
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION_MINOR",
+ version_components[1]);
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION_PATCH",
+ version_components[2]);
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_VERSION_TWEAK",
+ version_components[3]);
} else if (cmp0048 != cmPolicies::OLD) {
// Set project VERSION variables to empty
- std::vector<std::string> vv;
- vv.push_back("PROJECT_VERSION");
- vv.push_back("PROJECT_VERSION_MAJOR");
- vv.push_back("PROJECT_VERSION_MINOR");
- vv.push_back("PROJECT_VERSION_PATCH");
- vv.push_back("PROJECT_VERSION_TWEAK");
- vv.push_back(projectName + "_VERSION");
- vv.push_back(projectName + "_VERSION_MAJOR");
- vv.push_back(projectName + "_VERSION_MINOR");
- vv.push_back(projectName + "_VERSION_PATCH");
- vv.push_back(projectName + "_VERSION_TWEAK");
+ std::vector<std::string> vv = { "PROJECT_VERSION",
+ "PROJECT_VERSION_MAJOR",
+ "PROJECT_VERSION_MINOR",
+ "PROJECT_VERSION_PATCH",
+ "PROJECT_VERSION_TWEAK",
+ projectName + "_VERSION",
+ projectName + "_VERSION_MAJOR",
+ projectName + "_VERSION_MINOR",
+ projectName + "_VERSION_PATCH",
+ projectName + "_VERSION_TWEAK" };
+ if (mf.IsRootMakefile()) {
+ vv.emplace_back("CMAKE_PROJECT_VERSION");
+ vv.emplace_back("CMAKE_PROJECT_VERSION_MAJOR");
+ vv.emplace_back("CMAKE_PROJECT_VERSION_MINOR");
+ vv.emplace_back("CMAKE_PROJECT_VERSION_PATCH");
+ vv.emplace_back("CMAKE_PROJECT_VERSION_TWEAK");
+ }
std::string vw;
- for (std::vector<std::string>::iterator i = vv.begin(); i != vv.end();
- ++i) {
- const char* v = this->Makefile->GetDefinition(*i);
+ for (std::string const& i : vv) {
+ const char* const v = mf.GetDefinition(i);
if (v && *v) {
if (cmp0048 == cmPolicies::WARN) {
- vw += "\n ";
- vw += *i;
+ if (!injectedProjectCommand) {
+ vw += "\n ";
+ vw += i;
+ }
} else {
- this->Makefile->AddDefinition(*i, "");
+ mf.AddDefinition(i, "");
}
}
}
if (!vw.empty()) {
- std::ostringstream w;
- w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0048)
- << "\nThe following variable(s) would be set to empty:" << vw;
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ mf.IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0048),
+ "\nThe following variable(s) would be set to empty:", vw));
}
}
- if (haveDescription) {
- this->Makefile->AddDefinition("PROJECT_DESCRIPTION", description.c_str());
- // Set the CMAKE_PROJECT_DESCRIPTION variable to be the highest-level
- // project name in the tree. If there are two project commands
- // in the same CMakeLists.txt file, and it is the top level
- // CMakeLists.txt file, then go with the last one.
- if (!this->Makefile->GetDefinition("CMAKE_PROJECT_DESCRIPTION") ||
- (this->Makefile->IsRootMakefile())) {
- this->Makefile->AddDefinition("CMAKE_PROJECT_DESCRIPTION",
- description.c_str());
- this->Makefile->AddCacheDefinition(
- "CMAKE_PROJECT_DESCRIPTION", description.c_str(),
- "Value Computed by CMake", cmStateEnums::STATIC);
- }
- }
+ mf.AddDefinition("PROJECT_DESCRIPTION", description);
+ mf.AddDefinition(projectName + "_DESCRIPTION", description);
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_DESCRIPTION", description);
+
+ mf.AddDefinition("PROJECT_HOMEPAGE_URL", homepage);
+ mf.AddDefinition(projectName + "_HOMEPAGE_URL", homepage);
+ TopLevelCMakeVarCondSet(mf, "CMAKE_PROJECT_HOMEPAGE_URL", homepage);
if (languages.empty()) {
// if no language is specified do c and c++
- languages.push_back("C");
- languages.push_back("CXX");
+ languages = { "C", "CXX" };
}
- this->Makefile->EnableLanguage(languages, false);
- std::string extraInclude = "CMAKE_PROJECT_" + projectName + "_INCLUDE";
- const char* include = this->Makefile->GetDefinition(extraInclude);
- if (include) {
- bool readit = this->Makefile->ReadDependentFile(include);
- if (!readit && !cmSystemTools::GetFatalErrorOccured()) {
- std::string m = "could not find file:\n"
- " ";
- m += include;
- this->SetError(m);
- return false;
- }
+ mf.EnableLanguage(languages, false);
+
+ if (!IncludeByVariable(status, "CMAKE_PROJECT_INCLUDE")) {
+ return false;
}
+
+ if (!IncludeByVariable(status,
+ "CMAKE_PROJECT_" + projectName + "_INCLUDE")) {
+ return false;
+ }
+
return true;
}
+
+static bool IncludeByVariable(cmExecutionStatus& status,
+ const std::string& variable)
+{
+ cmMakefile& mf = status.GetMakefile();
+ const char* const include = mf.GetDefinition(variable);
+ if (!include) {
+ return true;
+ }
+
+ const bool readit = mf.ReadDependentFile(include);
+ if (readit) {
+ return true;
+ }
+
+ if (cmSystemTools::GetFatalErrorOccured()) {
+ return true;
+ }
+
+ status.SetError(cmStrCat("could not find file:\n ", include));
+ return false;
+}
+
+static void TopLevelCMakeVarCondSet(cmMakefile& mf, std::string const& name,
+ std::string const& value)
+{
+ // Set the CMAKE_PROJECT_XXX variable to be the highest-level
+ // project name in the tree. If there are two project commands
+ // in the same CMakeLists.txt file, and it is the top level
+ // CMakeLists.txt file, then go with the last one.
+ if (!mf.GetDefinition(name) || mf.IsRootMakefile()) {
+ mf.AddDefinition(name, value);
+ mf.AddCacheDefinition(name, value.c_str(), "Value Computed by CMake",
+ cmStateEnums::STATIC);
+ }
+}
diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h
index 3c579ac9d..c06b4594c 100644
--- a/Source/cmProjectCommand.h
+++ b/Source/cmProjectCommand.h
@@ -3,37 +3,14 @@
#ifndef cmProjectCommand_h
#define cmProjectCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmProjectCommand
- * \brief Specify the name for this build project.
- *
- * cmProjectCommand is used to specify a name for this build project.
- * It is defined once per set of CMakeList.txt files (including
- * all subdirectories). Currently it just sets the name of the workspace
- * file for Microsoft Visual C++
- */
-class cmProjectCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmProjectCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmProjectCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx
deleted file mode 100644
index 222afb497..000000000
--- a/Source/cmProperty.cxx
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmProperty.h"
-
-#include "cmConfigure.h"
-
-void cmProperty::Set(const char* value)
-{
- this->Value = value;
- this->ValueHasBeenSet = true;
-}
-
-void cmProperty::Append(const char* value, bool asString)
-{
- if (!this->Value.empty() && *value && !asString) {
- this->Value += ";";
- }
- this->Value += value;
- this->ValueHasBeenSet = true;
-}
-
-const char* cmProperty::GetValue() const
-{
- if (this->ValueHasBeenSet) {
- return this->Value.c_str();
- }
- return CM_NULLPTR;
-}
diff --git a/Source/cmProperty.h b/Source/cmProperty.h
index d11c5efbb..80f131a76 100644
--- a/Source/cmProperty.h
+++ b/Source/cmProperty.h
@@ -5,8 +5,6 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <string>
-
class cmProperty
{
public:
@@ -22,22 +20,6 @@ public:
CACHED_VARIABLE,
INSTALL
};
-
- // set this property
- void Set(const char* value);
-
- // append to this property
- void Append(const char* value, bool asString = false);
-
- // get the value
- const char* GetValue() const;
-
- // construct with the value not set
- cmProperty() { this->ValueHasBeenSet = false; }
-
-protected:
- std::string Value;
- bool ValueHasBeenSet;
};
#endif
diff --git a/Source/cmPropertyDefinition.h b/Source/cmPropertyDefinition.h
index 9adff4902..0d68c328b 100644
--- a/Source/cmPropertyDefinition.h
+++ b/Source/cmPropertyDefinition.h
@@ -5,10 +5,10 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmProperty.h"
-
#include <string>
+#include "cmProperty.h"
+
/** \class cmPropertyDefinition
* \brief Property meta-information
*
diff --git a/Source/cmPropertyDefinitionMap.cxx b/Source/cmPropertyDefinitionMap.cxx
index 5daaf9ba3..f752ed7c6 100644
--- a/Source/cmPropertyDefinitionMap.cxx
+++ b/Source/cmPropertyDefinitionMap.cxx
@@ -10,7 +10,7 @@ void cmPropertyDefinitionMap::DefineProperty(const std::string& name,
const char* FullDescription,
bool chain)
{
- cmPropertyDefinitionMap::iterator it = this->find(name);
+ auto it = this->find(name);
cmPropertyDefinition* prop;
if (it == this->end()) {
prop = &(*this)[name];
@@ -26,7 +26,7 @@ bool cmPropertyDefinitionMap::IsPropertyDefined(const std::string& name) const
bool cmPropertyDefinitionMap::IsPropertyChained(const std::string& name) const
{
- cmPropertyDefinitionMap::const_iterator it = this->find(name);
+ auto it = this->find(name);
if (it == this->end()) {
return false;
}
diff --git a/Source/cmPropertyDefinitionMap.h b/Source/cmPropertyDefinitionMap.h
index 97ba55391..8ec791033 100644
--- a/Source/cmPropertyDefinitionMap.h
+++ b/Source/cmPropertyDefinitionMap.h
@@ -5,12 +5,12 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmProperty.h"
-#include "cmPropertyDefinition.h"
-
#include <map>
#include <string>
+#include "cmProperty.h"
+#include "cmPropertyDefinition.h"
+
class cmPropertyDefinitionMap
: public std::map<std::string, cmPropertyDefinition>
{
diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx
index 1e089d1c8..a3d49460b 100644
--- a/Source/cmPropertyMap.cxx
+++ b/Source/cmPropertyMap.cxx
@@ -2,43 +2,22 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmPropertyMap.h"
-#include "cmConfigure.h"
#include <algorithm>
-#include <assert.h>
#include <utility>
-cmProperty* cmPropertyMap::GetOrCreateProperty(const std::string& name)
+void cmPropertyMap::Clear()
{
- cmPropertyMap::iterator it = this->find(name);
- cmProperty* prop;
- if (it == this->end()) {
- prop = &(*this)[name];
- } else {
- prop = &(it->second);
- }
- return prop;
-}
-
-std::vector<std::string> cmPropertyMap::GetPropertyList() const
-{
- std::vector<std::string> keyList;
- for (cmPropertyMap::const_iterator i = this->begin(), e = this->end();
- i != e; ++i) {
- keyList.push_back(i->first);
- }
- std::sort(keyList.begin(), keyList.end());
- return keyList;
+ Map_.clear();
}
void cmPropertyMap::SetProperty(const std::string& name, const char* value)
{
if (!value) {
- this->erase(name);
+ Map_.erase(name);
return;
}
- cmProperty* prop = this->GetOrCreateProperty(name);
- prop->Set(value);
+ Map_[name] = value;
}
void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
@@ -49,17 +28,53 @@ void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
return;
}
- cmProperty* prop = this->GetOrCreateProperty(name);
- prop->Append(value, asString);
+ {
+ std::string& pVal = Map_[name];
+ if (!pVal.empty() && !asString) {
+ pVal += ';';
+ }
+ pVal += value;
+ }
+}
+
+void cmPropertyMap::RemoveProperty(const std::string& name)
+{
+ Map_.erase(name);
}
const char* cmPropertyMap::GetPropertyValue(const std::string& name) const
{
- assert(!name.empty());
+ {
+ auto it = Map_.find(name);
+ if (it != Map_.end()) {
+ return it->second.c_str();
+ }
+ }
+ return nullptr;
+}
- cmPropertyMap::const_iterator it = this->find(name);
- if (it == this->end()) {
- return CM_NULLPTR;
+std::vector<std::string> cmPropertyMap::GetKeys() const
+{
+ std::vector<std::string> keyList;
+ keyList.reserve(Map_.size());
+ for (auto const& item : Map_) {
+ keyList.push_back(item.first);
+ }
+ std::sort(keyList.begin(), keyList.end());
+ return keyList;
+}
+
+std::vector<std::pair<std::string, std::string>> cmPropertyMap::GetList() const
+{
+ using StringPair = std::pair<std::string, std::string>;
+ std::vector<StringPair> kvList;
+ kvList.reserve(Map_.size());
+ for (auto const& item : Map_) {
+ kvList.emplace_back(item.first, item.second);
}
- return it->second.GetValue();
+ std::sort(kvList.begin(), kvList.end(),
+ [](StringPair const& a, StringPair const& b) {
+ return a.first < b.first;
+ });
+ return kvList;
}
diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h
index 5a0515076..9aed34960 100644
--- a/Source/cmPropertyMap.h
+++ b/Source/cmPropertyMap.h
@@ -5,25 +5,47 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmProperty.h"
-
-#include <map>
#include <string>
+#include <unordered_map>
+#include <utility>
#include <vector>
-class cmPropertyMap : public std::map<std::string, cmProperty>
+/** \class cmPropertyMap
+ * \brief String property map.
+ */
+class cmPropertyMap
{
public:
- cmProperty* GetOrCreateProperty(const std::string& name);
+ // -- General
+
+ //! Clear property list
+ void Clear();
- std::vector<std::string> GetPropertyList() const;
+ // -- Properties
+ //! Set the property value
void SetProperty(const std::string& name, const char* value);
+ //! Append to the property value
void AppendProperty(const std::string& name, const char* value,
bool asString = false);
+ //! Get the property value
const char* GetPropertyValue(const std::string& name) const;
+
+ //! Remove the property @a name from the map
+ void RemoveProperty(const std::string& name);
+
+ // -- Lists
+
+ //! Get a sorted list of property keys
+ std::vector<std::string> GetKeys() const;
+
+ //! Get a sorted by key list of property key,value pairs
+ std::vector<std::pair<std::string, std::string>> GetList() const;
+
+private:
+ std::unordered_map<std::string, std::string> Map_;
};
#endif
diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx
index de9e54505..cc4df8f89 100644
--- a/Source/cmQTWrapCPPCommand.cxx
+++ b/Source/cmQTWrapCPPCommand.cxx
@@ -3,58 +3,57 @@
#include "cmQTWrapCPPCommand.h"
#include "cmCustomCommandLines.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmRange.h"
#include "cmSourceFile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
-// cmQTWrapCPPCommand
-bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmQTWrapCPPCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// Get the moc executable to run in the custom command.
- const char* moc_exe =
- this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE");
+ std::string const& moc_exe = mf.GetRequiredDefinition("QT_MOC_EXECUTABLE");
// Get the variable holding the list of sources.
std::string const& sourceList = args[1];
- std::string sourceListValue = this->Makefile->GetSafeDefinition(sourceList);
+ std::string sourceListValue = mf.GetSafeDefinition(sourceList);
// Create a rule for all sources listed.
- for (std::vector<std::string>::const_iterator j = (args.begin() + 2);
- j != args.end(); ++j) {
- cmSourceFile* curr = this->Makefile->GetSource(*j);
+ for (std::string const& arg : cmMakeRange(args).advance(2)) {
+ cmSourceFile* curr = mf.GetSource(arg);
// if we should wrap the class
if (!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) {
// Compute the name of the file to generate.
- std::string srcName = cmSystemTools::GetFilenameWithoutLastExtension(*j);
- std::string newName = this->Makefile->GetCurrentBinaryDirectory();
- newName += "/moc_";
- newName += srcName;
- newName += ".cxx";
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(newName, true);
+ std::string srcName =
+ cmSystemTools::GetFilenameWithoutLastExtension(arg);
+ std::string newName =
+ cmStrCat(mf.GetCurrentBinaryDirectory(), "/moc_", srcName, ".cxx");
+ cmSourceFile* sf = mf.GetOrCreateSource(newName, true);
if (curr) {
sf->SetProperty("ABSTRACT", curr->GetProperty("ABSTRACT"));
}
// Compute the name of the header from which to generate the file.
std::string hname;
- if (cmSystemTools::FileIsFullPath(j->c_str())) {
- hname = *j;
+ if (cmSystemTools::FileIsFullPath(arg)) {
+ hname = arg;
} else {
- if (curr && curr->GetPropertyAsBool("GENERATED")) {
- hname = this->Makefile->GetCurrentBinaryDirectory();
+ if (curr && curr->GetIsGenerated()) {
+ hname = mf.GetCurrentBinaryDirectory();
} else {
- hname = this->Makefile->GetCurrentSourceDirectory();
+ hname = mf.GetCurrentSourceDirectory();
}
hname += "/";
- hname += *j;
+ hname += arg;
}
// Append the generated source file to the list.
@@ -64,28 +63,22 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
sourceListValue += newName;
// Create the custom command to generate the file.
- cmCustomCommandLine commandLine;
- commandLine.push_back(moc_exe);
- commandLine.push_back("-o");
- commandLine.push_back(newName);
- commandLine.push_back(hname);
-
- cmCustomCommandLines commandLines;
- commandLines.push_back(commandLine);
+ cmCustomCommandLines commandLines =
+ cmMakeSingleCommandLine({ moc_exe, "-o", newName, hname });
std::vector<std::string> depends;
depends.push_back(moc_exe);
depends.push_back(hname);
std::string no_main_dependency;
- const char* no_working_dir = CM_NULLPTR;
- this->Makefile->AddCustomCommandToOutput(
- newName, depends, no_main_dependency, commandLines, "Qt Wrapped File",
- no_working_dir);
+ const char* no_working_dir = nullptr;
+ mf.AddCustomCommandToOutput(newName, depends, no_main_dependency,
+ commandLines, "Qt Wrapped File",
+ no_working_dir);
}
}
// Store the final list of source files.
- this->Makefile->AddDefinition(sourceList, sourceListValue.c_str());
+ mf.AddDefinition(sourceList, sourceListValue);
return true;
}
diff --git a/Source/cmQTWrapCPPCommand.h b/Source/cmQTWrapCPPCommand.h
index ad1ccf38d..75fa18028 100644
--- a/Source/cmQTWrapCPPCommand.h
+++ b/Source/cmQTWrapCPPCommand.h
@@ -3,35 +3,14 @@
#ifndef cmQTWrapCPPCommand_h
#define cmQTWrapCPPCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmQTWrapCPPCommand
- * \brief Create moc file rules for Qt classes
- *
- * cmQTWrapCPPCommand is used to create wrappers for Qt classes into
- * normal C++
- */
-class cmQTWrapCPPCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmQTWrapCPPCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmQTWrapCPPCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx
index d3c663176..66c0228fc 100644
--- a/Source/cmQTWrapUICommand.cxx
+++ b/Source/cmQTWrapUICommand.cxx
@@ -3,66 +3,60 @@
#include "cmQTWrapUICommand.h"
#include "cmCustomCommandLines.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmRange.h"
#include "cmSourceFile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
-// cmQTWrapUICommand
-bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmQTWrapUICommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 4) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// Get the uic and moc executables to run in the custom commands.
- const char* uic_exe =
- this->Makefile->GetRequiredDefinition("QT_UIC_EXECUTABLE");
- const char* moc_exe =
- this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE");
+ std::string const& uic_exe = mf.GetRequiredDefinition("QT_UIC_EXECUTABLE");
+ std::string const& moc_exe = mf.GetRequiredDefinition("QT_MOC_EXECUTABLE");
// Get the variable holding the list of sources.
std::string const& headerList = args[1];
std::string const& sourceList = args[2];
- std::string headerListValue = this->Makefile->GetSafeDefinition(headerList);
- std::string sourceListValue = this->Makefile->GetSafeDefinition(sourceList);
+ std::string headerListValue = mf.GetSafeDefinition(headerList);
+ std::string sourceListValue = mf.GetSafeDefinition(sourceList);
// Create rules for all sources listed.
- for (std::vector<std::string>::const_iterator j = (args.begin() + 3);
- j != args.end(); ++j) {
- cmSourceFile* curr = this->Makefile->GetSource(*j);
+ for (std::string const& arg : cmMakeRange(args).advance(3)) {
+ cmSourceFile* curr = mf.GetSource(arg);
// if we should wrap the class
if (!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) {
// Compute the name of the files to generate.
- std::string srcName = cmSystemTools::GetFilenameWithoutLastExtension(*j);
- std::string hName = this->Makefile->GetCurrentBinaryDirectory();
- hName += "/";
- hName += srcName;
- hName += ".h";
- std::string cxxName = this->Makefile->GetCurrentBinaryDirectory();
- cxxName += "/";
- cxxName += srcName;
- cxxName += ".cxx";
- std::string mocName = this->Makefile->GetCurrentBinaryDirectory();
- mocName += "/moc_";
- mocName += srcName;
- mocName += ".cxx";
+ std::string srcName =
+ cmSystemTools::GetFilenameWithoutLastExtension(arg);
+ std::string hName =
+ cmStrCat(mf.GetCurrentBinaryDirectory(), '/', srcName, ".h");
+ std::string cxxName =
+ cmStrCat(mf.GetCurrentBinaryDirectory(), '/', srcName, ".cxx");
+ std::string mocName =
+ cmStrCat(mf.GetCurrentBinaryDirectory(), "/moc_", srcName, ".cxx");
// Compute the name of the ui file from which to generate others.
std::string uiName;
- if (cmSystemTools::FileIsFullPath(j->c_str())) {
- uiName = *j;
+ if (cmSystemTools::FileIsFullPath(arg)) {
+ uiName = arg;
} else {
- if (curr && curr->GetPropertyAsBool("GENERATED")) {
- uiName = this->Makefile->GetCurrentBinaryDirectory();
+ if (curr && curr->GetIsGenerated()) {
+ uiName = mf.GetCurrentBinaryDirectory();
} else {
- uiName = this->Makefile->GetCurrentSourceDirectory();
+ uiName = mf.GetCurrentSourceDirectory();
}
uiName += "/";
- uiName += *j;
+ uiName += arg;
}
// create the list of headers
@@ -80,56 +74,34 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
sourceListValue += mocName;
// set up .ui to .h and .cxx command
- cmCustomCommandLine hCommand;
- hCommand.push_back(uic_exe);
- hCommand.push_back("-o");
- hCommand.push_back(hName);
- hCommand.push_back(uiName);
- cmCustomCommandLines hCommandLines;
- hCommandLines.push_back(hCommand);
-
- cmCustomCommandLine cxxCommand;
- cxxCommand.push_back(uic_exe);
- cxxCommand.push_back("-impl");
- cxxCommand.push_back(hName);
- cxxCommand.push_back("-o");
- cxxCommand.push_back(cxxName);
- cxxCommand.push_back(uiName);
- cmCustomCommandLines cxxCommandLines;
- cxxCommandLines.push_back(cxxCommand);
-
- cmCustomCommandLine mocCommand;
- mocCommand.push_back(moc_exe);
- mocCommand.push_back("-o");
- mocCommand.push_back(mocName);
- mocCommand.push_back(hName);
- cmCustomCommandLines mocCommandLines;
- mocCommandLines.push_back(mocCommand);
+ cmCustomCommandLines hCommandLines =
+ cmMakeSingleCommandLine({ uic_exe, "-o", hName, uiName });
+ cmCustomCommandLines cxxCommandLines = cmMakeSingleCommandLine(
+ { uic_exe, "-impl", hName, "-o", cxxName, uiName });
+ cmCustomCommandLines mocCommandLines =
+ cmMakeSingleCommandLine({ moc_exe, "-o", mocName, hName });
std::vector<std::string> depends;
depends.push_back(uiName);
std::string no_main_dependency;
- const char* no_comment = CM_NULLPTR;
- const char* no_working_dir = CM_NULLPTR;
- this->Makefile->AddCustomCommandToOutput(
- hName, depends, no_main_dependency, hCommandLines, no_comment,
- no_working_dir);
+ const char* no_comment = nullptr;
+ const char* no_working_dir = nullptr;
+ mf.AddCustomCommandToOutput(hName, depends, no_main_dependency,
+ hCommandLines, no_comment, no_working_dir);
depends.push_back(hName);
- this->Makefile->AddCustomCommandToOutput(
- cxxName, depends, no_main_dependency, cxxCommandLines, no_comment,
- no_working_dir);
+ mf.AddCustomCommandToOutput(cxxName, depends, no_main_dependency,
+ cxxCommandLines, no_comment, no_working_dir);
depends.clear();
depends.push_back(hName);
- this->Makefile->AddCustomCommandToOutput(
- mocName, depends, no_main_dependency, mocCommandLines, no_comment,
- no_working_dir);
+ mf.AddCustomCommandToOutput(mocName, depends, no_main_dependency,
+ mocCommandLines, no_comment, no_working_dir);
}
}
// Store the final list of source files and headers.
- this->Makefile->AddDefinition(sourceList, sourceListValue.c_str());
- this->Makefile->AddDefinition(headerList, headerListValue.c_str());
+ mf.AddDefinition(sourceList, sourceListValue);
+ mf.AddDefinition(headerList, headerListValue);
return true;
}
diff --git a/Source/cmQTWrapUICommand.h b/Source/cmQTWrapUICommand.h
index ac7ab01c7..a17ef547d 100644
--- a/Source/cmQTWrapUICommand.h
+++ b/Source/cmQTWrapUICommand.h
@@ -3,34 +3,14 @@
#ifndef cmQTWrapUICommand_h
#define cmQTWrapUICommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmQTWrapUICommand
- * \brief Create .h and .cxx files rules for Qt user interfaces files
- *
- * cmQTWrapUICommand is used to create wrappers for Qt classes into normal C++
- */
-class cmQTWrapUICommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmQTWrapUICommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmQTWrapUICommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx
new file mode 100644
index 000000000..eb7c900c3
--- /dev/null
+++ b/Source/cmQtAutoGen.cxx
@@ -0,0 +1,385 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmQtAutoGen.h"
+
+#include <algorithm>
+#include <array>
+#include <initializer_list>
+#include <sstream>
+#include <utility>
+
+#include "cmsys/FStream.hxx"
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmAlgorithms.h"
+#include "cmDuration.h"
+#include "cmProcessOutput.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+// - Static functions
+
+/// @brief Merges newOpts into baseOpts
+/// @arg valueOpts list of options that accept a value
+void MergeOptions(std::vector<std::string>& baseOpts,
+ std::vector<std::string> const& newOpts,
+ std::initializer_list<cm::string_view> valueOpts, bool isQt5)
+{
+ if (newOpts.empty()) {
+ return;
+ }
+ if (baseOpts.empty()) {
+ baseOpts = newOpts;
+ return;
+ }
+
+ std::vector<std::string> extraOpts;
+ for (auto fit = newOpts.begin(), fitEnd = newOpts.end(); fit != fitEnd;
+ ++fit) {
+ std::string const& newOpt = *fit;
+ auto existIt = std::find(baseOpts.begin(), baseOpts.end(), newOpt);
+ if (existIt != baseOpts.end()) {
+ if (newOpt.size() >= 2) {
+ // Acquire the option name
+ std::string optName;
+ {
+ auto oit = newOpt.begin();
+ if (*oit == '-') {
+ ++oit;
+ if (isQt5 && (*oit == '-')) {
+ ++oit;
+ }
+ optName.assign(oit, newOpt.end());
+ }
+ }
+ // Test if this is a value option and change the existing value
+ if (!optName.empty() && cmContains(valueOpts, optName)) {
+ const auto existItNext(existIt + 1);
+ const auto fitNext(fit + 1);
+ if ((existItNext != baseOpts.end()) && (fitNext != fitEnd)) {
+ *existItNext = *fitNext;
+ ++fit;
+ }
+ }
+ }
+ } else {
+ extraOpts.push_back(newOpt);
+ }
+ }
+ // Append options
+ cmAppend(baseOpts, extraOpts);
+}
+
+// - Class definitions
+
+unsigned int const cmQtAutoGen::ParallelMax = 64;
+
+cm::string_view cmQtAutoGen::GeneratorName(GenT genType)
+{
+ switch (genType) {
+ case GenT::GEN:
+ return "AutoGen";
+ case GenT::MOC:
+ return "AutoMoc";
+ case GenT::UIC:
+ return "AutoUic";
+ case GenT::RCC:
+ return "AutoRcc";
+ }
+ return "AutoGen";
+}
+
+cm::string_view cmQtAutoGen::GeneratorNameUpper(GenT genType)
+{
+ switch (genType) {
+ case GenT::GEN:
+ return "AUTOGEN";
+ case GenT::MOC:
+ return "AUTOMOC";
+ case GenT::UIC:
+ return "AUTOUIC";
+ case GenT::RCC:
+ return "AUTORCC";
+ }
+ return "AUTOGEN";
+}
+
+std::string cmQtAutoGen::Tools(bool moc, bool uic, bool rcc)
+{
+ std::array<cm::string_view, 3> lst;
+ decltype(lst)::size_type num = 0;
+ if (moc) {
+ lst.at(num++) = "AUTOMOC";
+ }
+ if (uic) {
+ lst.at(num++) = "AUTOUIC";
+ }
+ if (rcc) {
+ lst.at(num++) = "AUTORCC";
+ }
+ switch (num) {
+ case 1:
+ return std::string(lst[0]);
+ case 2:
+ return cmStrCat(lst[0], " and ", lst[1]);
+ case 3:
+ return cmStrCat(lst[0], ", ", lst[1], " and ", lst[2]);
+ default:
+ break;
+ }
+ return std::string();
+}
+
+std::string cmQtAutoGen::Quoted(cm::string_view text)
+{
+ static std::initializer_list<std::pair<const char*, const char*>> const
+ replacements = { { "\\", "\\\\" }, { "\"", "\\\"" }, { "\a", "\\a" },
+ { "\b", "\\b" }, { "\f", "\\f" }, { "\n", "\\n" },
+ { "\r", "\\r" }, { "\t", "\\t" }, { "\v", "\\v" } };
+
+ std::string res(text);
+ for (auto const& pair : replacements) {
+ cmSystemTools::ReplaceString(res, pair.first, pair.second);
+ }
+ return cmStrCat('"', res, '"');
+}
+
+std::string cmQtAutoGen::QuotedCommand(std::vector<std::string> const& command)
+{
+ std::string res;
+ for (std::string const& item : command) {
+ if (!res.empty()) {
+ res.push_back(' ');
+ }
+ std::string const cesc = cmQtAutoGen::Quoted(item);
+ if (item.empty() || (cesc.size() > (item.size() + 2)) ||
+ (cesc.find(' ') != std::string::npos)) {
+ res += cesc;
+ } else {
+ res += item;
+ }
+ }
+ return res;
+}
+
+std::string cmQtAutoGen::FileNameWithoutLastExtension(cm::string_view filename)
+{
+ auto slashPos = filename.rfind('/');
+ if (slashPos != cm::string_view::npos) {
+ filename.remove_prefix(slashPos + 1);
+ }
+ auto dotPos = filename.rfind('.');
+ return std::string(filename.substr(0, dotPos));
+}
+
+std::string cmQtAutoGen::ParentDir(cm::string_view filename)
+{
+ auto slashPos = filename.rfind('/');
+ if (slashPos == cm::string_view::npos) {
+ return std::string();
+ }
+ return std::string(filename.substr(0, slashPos));
+}
+
+std::string cmQtAutoGen::SubDirPrefix(cm::string_view filename)
+{
+ auto slashPos = filename.rfind('/');
+ if (slashPos == cm::string_view::npos) {
+ return std::string();
+ }
+ return std::string(filename.substr(0, slashPos + 1));
+}
+
+std::string cmQtAutoGen::AppendFilenameSuffix(cm::string_view filename,
+ cm::string_view suffix)
+{
+ auto dotPos = filename.rfind('.');
+ if (dotPos == cm::string_view::npos) {
+ return cmStrCat(filename, suffix);
+ }
+ return cmStrCat(filename.substr(0, dotPos), suffix,
+ filename.substr(dotPos, filename.size() - dotPos));
+}
+
+void cmQtAutoGen::UicMergeOptions(std::vector<std::string>& baseOpts,
+ std::vector<std::string> const& newOpts,
+ bool isQt5)
+{
+ static std::initializer_list<cm::string_view> const valueOpts = {
+ "tr", "translate", "postfix", "generator",
+ "include", // Since Qt 5.3
+ "g"
+ };
+ MergeOptions(baseOpts, newOpts, valueOpts, isQt5);
+}
+
+void cmQtAutoGen::RccMergeOptions(std::vector<std::string>& baseOpts,
+ std::vector<std::string> const& newOpts,
+ bool isQt5)
+{
+ static std::initializer_list<cm::string_view> const valueOpts = {
+ "name", "root", "compress", "threshold"
+ };
+ MergeOptions(baseOpts, newOpts, valueOpts, isQt5);
+}
+
+static void RccListParseContent(std::string const& content,
+ std::vector<std::string>& files)
+{
+ cmsys::RegularExpression fileMatchRegex("(<file[^<]+)");
+ cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)");
+
+ const char* contentChars = content.c_str();
+ while (fileMatchRegex.find(contentChars)) {
+ std::string const qrcEntry = fileMatchRegex.match(1);
+ contentChars += qrcEntry.size();
+ {
+ fileReplaceRegex.find(qrcEntry);
+ std::string const tag = fileReplaceRegex.match(1);
+ files.push_back(qrcEntry.substr(tag.size()));
+ }
+ }
+}
+
+static bool RccListParseOutput(std::string const& rccStdOut,
+ std::string const& rccStdErr,
+ std::vector<std::string>& files,
+ std::string& error)
+{
+ // Lambda to strip CR characters
+ auto StripCR = [](std::string& line) {
+ std::string::size_type cr = line.find('\r');
+ if (cr != std::string::npos) {
+ line = line.substr(0, cr);
+ }
+ };
+
+ // Parse rcc std output
+ {
+ std::istringstream ostr(rccStdOut);
+ std::string oline;
+ while (std::getline(ostr, oline)) {
+ StripCR(oline);
+ if (!oline.empty()) {
+ files.push_back(oline);
+ }
+ }
+ }
+ // Parse rcc error output
+ {
+ std::istringstream estr(rccStdErr);
+ std::string eline;
+ while (std::getline(estr, eline)) {
+ StripCR(eline);
+ if (cmHasLiteralPrefix(eline, "RCC: Error in")) {
+ static std::string const searchString = "Cannot find file '";
+
+ std::string::size_type pos = eline.find(searchString);
+ if (pos == std::string::npos) {
+ error = cmStrCat("rcc lists unparsable output:\n",
+ cmQtAutoGen::Quoted(eline), '\n');
+ return false;
+ }
+ pos += searchString.length();
+ std::string::size_type sz = eline.size() - pos - 1;
+ files.push_back(eline.substr(pos, sz));
+ }
+ }
+ }
+
+ return true;
+}
+
+cmQtAutoGen::RccLister::RccLister() = default;
+
+cmQtAutoGen::RccLister::RccLister(std::string rccExecutable,
+ std::vector<std::string> listOptions)
+ : RccExcutable_(std::move(rccExecutable))
+ , ListOptions_(std::move(listOptions))
+{
+}
+
+bool cmQtAutoGen::RccLister::list(std::string const& qrcFile,
+ std::vector<std::string>& files,
+ std::string& error, bool verbose) const
+{
+ error.clear();
+
+ if (!cmSystemTools::FileExists(qrcFile, true)) {
+ error =
+ cmStrCat("The resource file ", Quoted(qrcFile), " does not exist.");
+ return false;
+ }
+
+ // Run rcc list command in the directory of the qrc file with the pathless
+ // qrc file name argument. This way rcc prints relative paths.
+ // This avoids issues on Windows when the qrc file is in a path that
+ // contains non-ASCII characters.
+ std::string const fileDir = cmSystemTools::GetFilenamePath(qrcFile);
+
+ if (!this->RccExcutable_.empty() &&
+ cmSystemTools::FileExists(this->RccExcutable_, true) &&
+ !this->ListOptions_.empty()) {
+
+ bool result = false;
+ int retVal = 0;
+ std::string rccStdOut;
+ std::string rccStdErr;
+ {
+ std::vector<std::string> cmd;
+ cmd.emplace_back(this->RccExcutable_);
+ cmAppend(cmd, this->ListOptions_);
+ cmd.emplace_back(cmSystemTools::GetFilenameName(qrcFile));
+
+ // Log command
+ if (verbose) {
+ cmSystemTools::Stdout(
+ cmStrCat("Running command:\n", QuotedCommand(cmd), '\n'));
+ }
+
+ result = cmSystemTools::RunSingleCommand(
+ cmd, &rccStdOut, &rccStdErr, &retVal, fileDir.c_str(),
+ cmSystemTools::OUTPUT_NONE, cmDuration::zero(), cmProcessOutput::Auto);
+ }
+ if (!result || retVal) {
+ error =
+ cmStrCat("The rcc list process failed for ", Quoted(qrcFile), '\n');
+ if (!rccStdOut.empty()) {
+ error += cmStrCat(rccStdOut, '\n');
+ }
+ if (!rccStdErr.empty()) {
+ error += cmStrCat(rccStdErr, '\n');
+ }
+ return false;
+ }
+ if (!RccListParseOutput(rccStdOut, rccStdErr, files, error)) {
+ return false;
+ }
+ } else {
+ // We can't use rcc for the file listing.
+ // Read the qrc file content into string and parse it.
+ {
+ std::string qrcContents;
+ {
+ cmsys::ifstream ifs(qrcFile.c_str());
+ if (ifs) {
+ std::ostringstream osst;
+ osst << ifs.rdbuf();
+ qrcContents = osst.str();
+ } else {
+ error = cmStrCat("The resource file ", Quoted(qrcFile),
+ " is not readable\n");
+ return false;
+ }
+ }
+ // Parse string content
+ RccListParseContent(qrcContents, files);
+ }
+ }
+
+ // Convert relative paths to absolute paths
+ for (std::string& entry : files) {
+ entry = cmSystemTools::CollapseFullPath(entry, fileDir);
+ }
+ return true;
+}
diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h
new file mode 100644
index 000000000..a740ba30a
--- /dev/null
+++ b/Source/cmQtAutoGen.h
@@ -0,0 +1,145 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmQtAutoGen_h
+#define cmQtAutoGen_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include <cm/string_view>
+
+/** \class cmQtAutoGen
+ * \brief Common base class for QtAutoGen classes
+ */
+class cmQtAutoGen
+{
+public:
+ /** Integer version. */
+ struct IntegerVersion
+ {
+ unsigned int Major = 0;
+ unsigned int Minor = 0;
+
+ IntegerVersion() = default;
+ IntegerVersion(unsigned int major, unsigned int minor)
+ : Major(major)
+ , Minor(minor)
+ {
+ }
+
+ bool operator>(IntegerVersion const version)
+ {
+ return (this->Major > version.Major) ||
+ ((this->Major == version.Major) && (this->Minor > version.Minor));
+ }
+
+ bool operator>=(IntegerVersion const version)
+ {
+ return (this->Major > version.Major) ||
+ ((this->Major == version.Major) && (this->Minor >= version.Minor));
+ }
+ };
+
+ /** Compiler features. */
+ class CompilerFeatures
+ {
+ public:
+ bool Evaluated = false;
+ std::string HelpOutput;
+ std::vector<std::string> ListOptions;
+ };
+ using CompilerFeaturesHandle = std::shared_ptr<CompilerFeatures>;
+
+ /** AutoGen generator type. */
+ enum class GenT
+ {
+ GEN, // AUTOGEN
+ MOC, // AUTOMOC
+ UIC, // AUTOUIC
+ RCC // AUTORCC
+ };
+
+ /// @brief Maximum number of parallel threads/processes in a generator
+ static unsigned int const ParallelMax;
+
+public:
+ /// @brief Returns the generator name
+ static cm::string_view GeneratorName(GenT genType);
+ /// @brief Returns the generator name in upper case
+ static cm::string_view GeneratorNameUpper(GenT genType);
+
+ /// @brief Returns a string with the requested tool names
+ static std::string Tools(bool moc, bool uic, bool rcc);
+
+ /// @brief Returns the string escaped and enclosed in quotes
+ static std::string Quoted(cm::string_view text);
+
+ static std::string QuotedCommand(std::vector<std::string> const& command);
+
+ /// @brief Returns the file name without path and extension (thread safe)
+ static std::string FileNameWithoutLastExtension(cm::string_view filename);
+
+ /// @brief Returns the parent directory of the file (thread safe)
+ static std::string ParentDir(cm::string_view filename);
+
+ /// @brief Returns the parent directory of the file with a "/" suffix
+ static std::string SubDirPrefix(cm::string_view filename);
+
+ /// @brief Appends the suffix to the filename before the last dot
+ static std::string AppendFilenameSuffix(cm::string_view filename,
+ cm::string_view suffix);
+
+ /// @brief Merges newOpts into baseOpts
+ static void UicMergeOptions(std::vector<std::string>& baseOpts,
+ std::vector<std::string> const& newOpts,
+ bool isQt5);
+
+ /// @brief Merges newOpts into baseOpts
+ static void RccMergeOptions(std::vector<std::string>& baseOpts,
+ std::vector<std::string> const& newOpts,
+ bool isQt5);
+
+ /** @class RccLister
+ * @brief Lists files in qrc resource files
+ */
+ class RccLister
+ {
+ public:
+ RccLister();
+ RccLister(std::string rccExecutable, std::vector<std::string> listOptions);
+
+ //! The rcc executable
+ std::string const& RccExcutable() const { return RccExcutable_; }
+ void SetRccExecutable(std::string const& rccExecutable)
+ {
+ RccExcutable_ = rccExecutable;
+ }
+
+ //! The rcc executable list options
+ std::vector<std::string> const& ListOptions() const
+ {
+ return ListOptions_;
+ }
+ void SetListOptions(std::vector<std::string> const& listOptions)
+ {
+ ListOptions_ = listOptions;
+ }
+
+ /**
+ * @brief Lists a files in the qrcFile
+ * @arg files The file names are appended to this list
+ * @arg error contains the error message when the function fails
+ */
+ bool list(std::string const& qrcFile, std::vector<std::string>& files,
+ std::string& error, bool verbose = false) const;
+
+ private:
+ std::string RccExcutable_;
+ std::vector<std::string> ListOptions_;
+ };
+};
+
+#endif
diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx
new file mode 100644
index 000000000..ef6b88636
--- /dev/null
+++ b/Source/cmQtAutoGenGlobalInitializer.cxx
@@ -0,0 +1,289 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmQtAutoGenGlobalInitializer.h"
+
+#include <utility>
+
+#include <cm/memory>
+
+#include "cmCustomCommandLines.h"
+#include "cmCustomCommandTypes.h"
+#include "cmDuration.h"
+#include "cmGeneratorTarget.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmProcessOutput.h"
+#include "cmQtAutoGen.h"
+#include "cmQtAutoGenInitializer.h"
+#include "cmState.h"
+#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmTarget.h"
+
+cmQtAutoGenGlobalInitializer::Keywords::Keywords()
+ : AUTOMOC("AUTOMOC")
+ , AUTOUIC("AUTOUIC")
+ , AUTORCC("AUTORCC")
+ , AUTOMOC_EXECUTABLE("AUTOMOC_EXECUTABLE")
+ , AUTOUIC_EXECUTABLE("AUTOUIC_EXECUTABLE")
+ , AUTORCC_EXECUTABLE("AUTORCC_EXECUTABLE")
+ , SKIP_AUTOGEN("SKIP_AUTOGEN")
+ , SKIP_AUTOMOC("SKIP_AUTOMOC")
+ , SKIP_AUTOUIC("SKIP_AUTOUIC")
+ , SKIP_AUTORCC("SKIP_AUTORCC")
+ , AUTOUIC_OPTIONS("AUTOUIC_OPTIONS")
+ , AUTORCC_OPTIONS("AUTORCC_OPTIONS")
+ , qrc("qrc")
+ , ui("ui")
+{
+}
+
+cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer(
+ std::vector<cmLocalGenerator*> const& localGenerators)
+{
+ for (cmLocalGenerator* localGen : localGenerators) {
+ // Detect global autogen and autorcc target names
+ bool globalAutoGenTarget = false;
+ bool globalAutoRccTarget = false;
+ {
+ cmMakefile* makefile = localGen->GetMakefile();
+ // Detect global autogen target name
+ if (cmIsOn(makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTOGEN_TARGET"))) {
+ std::string targetName =
+ makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTOGEN_TARGET_NAME");
+ if (targetName.empty()) {
+ targetName = "autogen";
+ }
+ GlobalAutoGenTargets_.emplace(localGen, std::move(targetName));
+ globalAutoGenTarget = true;
+ }
+
+ // Detect global autorcc target name
+ if (cmIsOn(makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTORCC_TARGET"))) {
+ std::string targetName =
+ makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTORCC_TARGET_NAME");
+ if (targetName.empty()) {
+ targetName = "autorcc";
+ }
+ GlobalAutoRccTargets_.emplace(localGen, std::move(targetName));
+ globalAutoRccTarget = true;
+ }
+ }
+
+ // Find targets that require AUTOMOC/UIC/RCC processing
+ for (cmGeneratorTarget* target : localGen->GetGeneratorTargets()) {
+ // Process only certain target types
+ switch (target->GetType()) {
+ case cmStateEnums::EXECUTABLE:
+ case cmStateEnums::STATIC_LIBRARY:
+ case cmStateEnums::SHARED_LIBRARY:
+ case cmStateEnums::MODULE_LIBRARY:
+ case cmStateEnums::OBJECT_LIBRARY:
+ // Process target
+ break;
+ default:
+ // Don't process target
+ continue;
+ }
+ if (target->IsImported()) {
+ // Don't process target
+ continue;
+ }
+
+ bool const moc = target->GetPropertyAsBool(kw().AUTOMOC);
+ bool const uic = target->GetPropertyAsBool(kw().AUTOUIC);
+ bool const rcc = target->GetPropertyAsBool(kw().AUTORCC);
+ if (moc || uic || rcc) {
+ std::string const mocExec =
+ target->GetSafeProperty(kw().AUTOMOC_EXECUTABLE);
+ std::string const uicExec =
+ target->GetSafeProperty(kw().AUTOUIC_EXECUTABLE);
+ std::string const rccExec =
+ target->GetSafeProperty(kw().AUTORCC_EXECUTABLE);
+
+ // We support Qt4, Qt5 and Qt6
+ auto qtVersion = cmQtAutoGenInitializer::GetQtVersion(target);
+ bool const validQt = (qtVersion.first.Major == 4) ||
+ (qtVersion.first.Major == 5) || (qtVersion.first.Major == 6);
+
+ bool const mocAvailable = (validQt || !mocExec.empty());
+ bool const uicAvailable = (validQt || !uicExec.empty());
+ bool const rccAvailable = (validQt || !rccExec.empty());
+ bool const mocIsValid = (moc && mocAvailable);
+ bool const uicIsValid = (uic && uicAvailable);
+ bool const rccIsValid = (rcc && rccAvailable);
+ // Disabled AUTOMOC/UIC/RCC warning
+ bool const mocDisabled = (moc && !mocAvailable);
+ bool const uicDisabled = (uic && !uicAvailable);
+ bool const rccDisabled = (rcc && !rccAvailable);
+ if (mocDisabled || uicDisabled || rccDisabled) {
+ cmAlphaNum version = (qtVersion.second == 0)
+ ? cmAlphaNum("<QTVERSION>")
+ : cmAlphaNum(qtVersion.second);
+ cmAlphaNum component = uicDisabled ? "Widgets" : "Core";
+
+ std::string const msg = cmStrCat(
+ "AUTOGEN: No valid Qt version found for target ",
+ target->GetName(), ". ",
+ cmQtAutoGen::Tools(mocDisabled, uicDisabled, rccDisabled),
+ " disabled. Consider adding:\n", " find_package(Qt", version,
+ " COMPONENTS ", component, ")\n", "to your CMakeLists.txt file.");
+ target->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, msg);
+ }
+ if (mocIsValid || uicIsValid || rccIsValid) {
+ // Create autogen target initializer
+ Initializers_.emplace_back(cm::make_unique<cmQtAutoGenInitializer>(
+ this, target, qtVersion.first, mocIsValid, uicIsValid, rccIsValid,
+ globalAutoGenTarget, globalAutoRccTarget));
+ }
+ }
+ }
+ }
+}
+
+cmQtAutoGenGlobalInitializer::~cmQtAutoGenGlobalInitializer() = default;
+
+void cmQtAutoGenGlobalInitializer::GetOrCreateGlobalTarget(
+ cmLocalGenerator* localGen, std::string const& name,
+ std::string const& comment)
+{
+ // Test if the target already exists
+ if (localGen->FindGeneratorTargetToUse(name) == nullptr) {
+ cmMakefile* makefile = localGen->GetMakefile();
+
+ // Create utility target
+ cmTarget* target = makefile->AddUtilityCommand(
+ name, cmCommandOrigin::Generator, true,
+ makefile->GetHomeOutputDirectory().c_str() /*work dir*/,
+ std::vector<std::string>() /*output*/,
+ std::vector<std::string>() /*depends*/, cmCustomCommandLines(), false,
+ comment.c_str());
+ localGen->AddGeneratorTarget(new cmGeneratorTarget(target, localGen));
+
+ // Set FOLDER property in the target
+ {
+ char const* folder =
+ makefile->GetState()->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER");
+ if (folder != nullptr) {
+ target->SetProperty("FOLDER", folder);
+ }
+ }
+ }
+}
+
+void cmQtAutoGenGlobalInitializer::AddToGlobalAutoGen(
+ cmLocalGenerator* localGen, std::string const& targetName)
+{
+ auto it = GlobalAutoGenTargets_.find(localGen);
+ if (it != GlobalAutoGenTargets_.end()) {
+ cmGeneratorTarget* target = localGen->FindGeneratorTargetToUse(it->second);
+ if (target != nullptr) {
+ target->Target->AddUtility(targetName, localGen->GetMakefile());
+ }
+ }
+}
+
+void cmQtAutoGenGlobalInitializer::AddToGlobalAutoRcc(
+ cmLocalGenerator* localGen, std::string const& targetName)
+{
+ auto it = GlobalAutoRccTargets_.find(localGen);
+ if (it != GlobalAutoRccTargets_.end()) {
+ cmGeneratorTarget* target = localGen->FindGeneratorTargetToUse(it->second);
+ if (target != nullptr) {
+ target->Target->AddUtility(targetName, localGen->GetMakefile());
+ }
+ }
+}
+
+cmQtAutoGen::CompilerFeaturesHandle
+cmQtAutoGenGlobalInitializer::GetCompilerFeatures(
+ std::string const& generator, std::string const& executable,
+ std::string& error)
+{
+ // Check if we have cached features
+ {
+ auto it = this->CompilerFeatures_.find(executable);
+ if (it != this->CompilerFeatures_.end()) {
+ return it->second;
+ }
+ }
+
+ // Check if the executable exists
+ if (!cmSystemTools::FileExists(executable, true)) {
+ error = cmStrCat("The \"", generator, "\" executable ",
+ cmQtAutoGen::Quoted(executable), " does not exist.");
+ return cmQtAutoGen::CompilerFeaturesHandle();
+ }
+
+ // Test the executable
+ std::string stdOut;
+ {
+ std::string stdErr;
+ std::vector<std::string> command;
+ command.emplace_back(executable);
+ command.emplace_back("-h");
+ int retVal = 0;
+ const bool runResult = cmSystemTools::RunSingleCommand(
+ command, &stdOut, &stdErr, &retVal, nullptr, cmSystemTools::OUTPUT_NONE,
+ cmDuration::zero(), cmProcessOutput::Auto);
+ if (!runResult) {
+ error = cmStrCat("Test run of \"", generator, "\" executable ",
+ cmQtAutoGen::Quoted(executable), " failed.\n",
+ cmQtAutoGen::QuotedCommand(command), '\n', stdOut, '\n',
+ stdErr);
+ return cmQtAutoGen::CompilerFeaturesHandle();
+ }
+ }
+
+ // Create valid handle
+ cmQtAutoGen::CompilerFeaturesHandle res =
+ std::make_shared<cmQtAutoGen::CompilerFeatures>();
+ res->HelpOutput = std::move(stdOut);
+
+ // Register compiler features
+ this->CompilerFeatures_.emplace(executable, res);
+
+ return res;
+}
+
+bool cmQtAutoGenGlobalInitializer::generate()
+{
+ return (InitializeCustomTargets() && SetupCustomTargets());
+}
+
+bool cmQtAutoGenGlobalInitializer::InitializeCustomTargets()
+{
+ // Initialize global autogen targets
+ {
+ std::string const comment = "Global AUTOGEN target";
+ for (auto const& pair : GlobalAutoGenTargets_) {
+ GetOrCreateGlobalTarget(pair.first, pair.second, comment);
+ }
+ }
+ // Initialize global autorcc targets
+ {
+ std::string const comment = "Global AUTORCC target";
+ for (auto const& pair : GlobalAutoRccTargets_) {
+ GetOrCreateGlobalTarget(pair.first, pair.second, comment);
+ }
+ }
+ // Initialize per target autogen targets
+ for (auto& initializer : Initializers_) {
+ if (!initializer->InitCustomTargets()) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool cmQtAutoGenGlobalInitializer::SetupCustomTargets()
+{
+ for (auto& initializer : Initializers_) {
+ if (!initializer->SetupCustomTargets()) {
+ return false;
+ }
+ }
+ return true;
+}
diff --git a/Source/cmQtAutoGenGlobalInitializer.h b/Source/cmQtAutoGenGlobalInitializer.h
new file mode 100644
index 000000000..806725a01
--- /dev/null
+++ b/Source/cmQtAutoGenGlobalInitializer.h
@@ -0,0 +1,86 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmQtAutoGenGlobalInitializer_h
+#define cmQtAutoGenGlobalInitializer_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <map>
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "cmQtAutoGen.h"
+
+class cmLocalGenerator;
+class cmQtAutoGenInitializer;
+
+/// @brief Initializes the QtAutoGen generators
+class cmQtAutoGenGlobalInitializer
+{
+public:
+ /// @brief Collection of QtAutogen related keywords
+ class Keywords
+ {
+ public:
+ Keywords();
+
+ std::string AUTOMOC;
+ std::string AUTOUIC;
+ std::string AUTORCC;
+
+ std::string AUTOMOC_EXECUTABLE;
+ std::string AUTOUIC_EXECUTABLE;
+ std::string AUTORCC_EXECUTABLE;
+
+ std::string SKIP_AUTOGEN;
+ std::string SKIP_AUTOMOC;
+ std::string SKIP_AUTOUIC;
+ std::string SKIP_AUTORCC;
+
+ std::string AUTOUIC_OPTIONS;
+ std::string AUTORCC_OPTIONS;
+
+ std::string qrc;
+ std::string ui;
+ };
+
+public:
+ cmQtAutoGenGlobalInitializer(
+ std::vector<cmLocalGenerator*> const& localGenerators);
+ ~cmQtAutoGenGlobalInitializer();
+
+ Keywords const& kw() const { return Keywords_; };
+
+ bool generate();
+
+private:
+ friend class cmQtAutoGenInitializer;
+
+ bool InitializeCustomTargets();
+ bool SetupCustomTargets();
+
+ void GetOrCreateGlobalTarget(cmLocalGenerator* localGen,
+ std::string const& name,
+ std::string const& comment);
+
+ void AddToGlobalAutoGen(cmLocalGenerator* localGen,
+ std::string const& targetName);
+ void AddToGlobalAutoRcc(cmLocalGenerator* localGen,
+ std::string const& targetName);
+
+ cmQtAutoGen::CompilerFeaturesHandle GetCompilerFeatures(
+ std::string const& generator, std::string const& executable,
+ std::string& error);
+
+private:
+ std::vector<std::unique_ptr<cmQtAutoGenInitializer>> Initializers_;
+ std::map<cmLocalGenerator*, std::string> GlobalAutoGenTargets_;
+ std::map<cmLocalGenerator*, std::string> GlobalAutoRccTargets_;
+ std::unordered_map<std::string, cmQtAutoGen::CompilerFeaturesHandle>
+ CompilerFeatures_;
+ Keywords const Keywords_;
+};
+
+#endif
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
new file mode 100644
index 000000000..5eb04f704
--- /dev/null
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -0,0 +1,1735 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmQtAutoGenInitializer.h"
+
+#include <cstddef>
+#include <deque>
+#include <initializer_list>
+#include <map>
+#include <ostream>
+#include <set>
+#include <string>
+#include <unordered_set>
+#include <utility>
+#include <vector>
+
+#include <cm/algorithm>
+#include <cm/iterator>
+#include <cm/memory>
+
+#include "cmsys/SystemInformation.hxx"
+
+#include "cm_jsoncpp_value.h"
+#include "cm_jsoncpp_writer.h"
+
+#include "cmAlgorithms.h"
+#include "cmCustomCommand.h"
+#include "cmCustomCommandLines.h"
+#include "cmCustomCommandTypes.h"
+#include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpression.h"
+#include "cmGeneratorTarget.h"
+#include "cmGlobalGenerator.h"
+#include "cmLinkItem.h"
+#include "cmListFileCache.h"
+#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmPolicies.h"
+#include "cmQtAutoGen.h"
+#include "cmQtAutoGenGlobalInitializer.h"
+#include "cmSourceFile.h"
+#include "cmSourceFileLocationKind.h"
+#include "cmSourceGroup.h"
+#include "cmState.h"
+#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmTarget.h"
+#include "cmake.h"
+
+namespace {
+
+unsigned int GetParallelCPUCount()
+{
+ static unsigned int count = 0;
+ // Detect only on the first call
+ if (count == 0) {
+ cmsys::SystemInformation info;
+ info.RunCPUCheck();
+ count =
+ cm::clamp(info.GetNumberOfPhysicalCPU(), 1u, cmQtAutoGen::ParallelMax);
+ }
+ return count;
+}
+
+std::string FileProjectRelativePath(cmMakefile* makefile,
+ std::string const& fileName)
+{
+ std::string res;
+ {
+ std::string pSource = cmSystemTools::RelativePath(
+ makefile->GetCurrentSourceDirectory(), fileName);
+ std::string pBinary = cmSystemTools::RelativePath(
+ makefile->GetCurrentBinaryDirectory(), fileName);
+ if (pSource.size() < pBinary.size()) {
+ res = std::move(pSource);
+ } else if (pBinary.size() < fileName.size()) {
+ res = std::move(pBinary);
+ } else {
+ res = fileName;
+ }
+ }
+ return res;
+}
+
+/**
+ * Tests if targetDepend is a STATIC_LIBRARY and if any of its
+ * recursive STATIC_LIBRARY dependencies depends on targetOrigin
+ * (STATIC_LIBRARY cycle).
+ */
+bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin,
+ cmGeneratorTarget const* targetDepend,
+ std::string const& config)
+{
+ bool cycle = false;
+ if ((targetOrigin->GetType() == cmStateEnums::STATIC_LIBRARY) &&
+ (targetDepend->GetType() == cmStateEnums::STATIC_LIBRARY)) {
+ std::set<cmGeneratorTarget const*> knownLibs;
+ std::deque<cmGeneratorTarget const*> testLibs;
+
+ // Insert initial static_library dependency
+ knownLibs.insert(targetDepend);
+ testLibs.push_back(targetDepend);
+
+ while (!testLibs.empty()) {
+ cmGeneratorTarget const* testTarget = testLibs.front();
+ testLibs.pop_front();
+ // Check if the test target is the origin target (cycle)
+ if (testTarget == targetOrigin) {
+ cycle = true;
+ break;
+ }
+ // Collect all static_library dependencies from the test target
+ cmLinkImplementationLibraries const* libs =
+ testTarget->GetLinkImplementationLibraries(config);
+ if (libs != nullptr) {
+ for (cmLinkItem const& item : libs->Libraries) {
+ cmGeneratorTarget const* depTarget = item.Target;
+ if ((depTarget != nullptr) &&
+ (depTarget->GetType() == cmStateEnums::STATIC_LIBRARY) &&
+ knownLibs.insert(depTarget).second) {
+ testLibs.push_back(depTarget);
+ }
+ }
+ }
+ }
+ }
+ return cycle;
+}
+
+/** Sanitizes file search paths. */
+class SearchPathSanitizer
+{
+public:
+ SearchPathSanitizer(cmMakefile* makefile)
+ : SourcePath_(makefile->GetCurrentSourceDirectory())
+ {
+ }
+ std::vector<std::string> operator()(
+ std::vector<std::string> const& paths) const;
+
+private:
+ std::string SourcePath_;
+};
+
+std::vector<std::string> SearchPathSanitizer::operator()(
+ std::vector<std::string> const& paths) const
+{
+ std::vector<std::string> res;
+ res.reserve(paths.size());
+ for (std::string const& srcPath : paths) {
+ // Collapse relative paths
+ std::string path = cmSystemTools::CollapseFullPath(srcPath, SourcePath_);
+ // Remove suffix slashes
+ while (cmHasSuffix(path, '/')) {
+ path.pop_back();
+ }
+ // Accept only non empty paths
+ if (!path.empty()) {
+ res.emplace_back(std::move(path));
+ }
+ }
+ return res;
+}
+
+/** @brief Writes a CMake info file. */
+class InfoWriter
+{
+public:
+ // -- Single value
+ void Set(std::string const& key, std::string const& value)
+ {
+ Value_[key] = value;
+ }
+ void SetConfig(std::string const& key,
+ cmQtAutoGenInitializer::ConfigString const& cfgStr);
+ void SetBool(std::string const& key, bool value) { Value_[key] = value; }
+ void SetUInt(std::string const& key, unsigned int value)
+ {
+ Value_[key] = value;
+ }
+
+ // -- Array utility
+ template <typename CONT>
+ static bool MakeArray(Json::Value& jval, CONT const& container);
+
+ template <typename CONT>
+ static void MakeStringArray(Json::Value& jval, CONT const& container);
+
+ // -- Array value
+ template <typename CONT>
+ void SetArray(std::string const& key, CONT const& container);
+ template <typename CONT>
+ void SetConfigArray(
+ std::string const& key,
+ cmQtAutoGenInitializer::ConfigStrings<CONT> const& cfgStr);
+
+ // -- Array of arrays
+ template <typename CONT, typename FUNC>
+ void SetArrayArray(std::string const& key, CONT const& container, FUNC func);
+
+ // -- Save to json file
+ bool Save(std::string const& filename);
+
+private:
+ Json::Value Value_;
+};
+
+void InfoWriter::SetConfig(std::string const& key,
+ cmQtAutoGenInitializer::ConfigString const& cfgStr)
+{
+ Set(key, cfgStr.Default);
+ for (auto const& item : cfgStr.Config) {
+ Set(cmStrCat(key, '_', item.first), item.second);
+ }
+}
+
+template <typename CONT>
+bool InfoWriter::MakeArray(Json::Value& jval, CONT const& container)
+{
+ jval = Json::arrayValue;
+ std::size_t const listSize = cm::size(container);
+ if (listSize == 0) {
+ return false;
+ }
+ jval.resize(static_cast<unsigned int>(listSize));
+ return true;
+}
+
+template <typename CONT>
+void InfoWriter::MakeStringArray(Json::Value& jval, CONT const& container)
+{
+ if (MakeArray(jval, container)) {
+ Json::ArrayIndex ii = 0;
+ for (std::string const& item : container) {
+ jval[ii++] = item;
+ }
+ }
+}
+
+template <typename CONT>
+void InfoWriter::SetArray(std::string const& key, CONT const& container)
+{
+ MakeStringArray(Value_[key], container);
+}
+
+template <typename CONT, typename FUNC>
+void InfoWriter::SetArrayArray(std::string const& key, CONT const& container,
+ FUNC func)
+{
+ Json::Value& jval = Value_[key];
+ if (MakeArray(jval, container)) {
+ Json::ArrayIndex ii = 0;
+ for (auto const& citem : container) {
+ Json::Value& aval = jval[ii++];
+ aval = Json::arrayValue;
+ func(aval, citem);
+ }
+ }
+}
+
+template <typename CONT>
+void InfoWriter::SetConfigArray(
+ std::string const& key,
+ cmQtAutoGenInitializer::ConfigStrings<CONT> const& cfgStr)
+{
+ SetArray(key, cfgStr.Default);
+ for (auto const& item : cfgStr.Config) {
+ SetArray(cmStrCat(key, '_', item.first), item.second);
+ }
+}
+
+bool InfoWriter::Save(std::string const& filename)
+{
+ cmGeneratedFileStream fileStream;
+ fileStream.SetCopyIfDifferent(true);
+ fileStream.Open(filename, false, true);
+ if (!fileStream) {
+ return false;
+ }
+
+ Json::StyledStreamWriter jsonWriter;
+ try {
+ jsonWriter.write(fileStream, Value_);
+ } catch (...) {
+ return false;
+ }
+
+ return fileStream.Close();
+}
+
+} // End of unnamed namespace
+
+cmQtAutoGenInitializer::cmQtAutoGenInitializer(
+ cmQtAutoGenGlobalInitializer* globalInitializer,
+ cmGeneratorTarget* genTarget, IntegerVersion const& qtVersion,
+ bool mocEnabled, bool uicEnabled, bool rccEnabled, bool globalAutogenTarget,
+ bool globalAutoRccTarget)
+ : GlobalInitializer(globalInitializer)
+ , GenTarget(genTarget)
+ , GlobalGen(genTarget->GetGlobalGenerator())
+ , LocalGen(genTarget->GetLocalGenerator())
+ , Makefile(genTarget->Makefile)
+ , PathCheckSum(genTarget->Makefile)
+ , QtVersion(qtVersion)
+{
+ AutogenTarget.GlobalTarget = globalAutogenTarget;
+ Moc.Enabled = mocEnabled;
+ Uic.Enabled = uicEnabled;
+ Rcc.Enabled = rccEnabled;
+ Rcc.GlobalTarget = globalAutoRccTarget;
+}
+
+bool cmQtAutoGenInitializer::InitCustomTargets()
+{
+ // Configurations
+ this->MultiConfig = this->GlobalGen->IsMultiConfig();
+ this->ConfigDefault = this->Makefile->GetConfigurations(this->ConfigsList);
+ if (this->ConfigsList.empty()) {
+ this->ConfigsList.push_back(this->ConfigDefault);
+ }
+
+ // Verbosity
+ {
+ std::string def =
+ this->Makefile->GetSafeDefinition("CMAKE_AUTOGEN_VERBOSE");
+ if (!def.empty()) {
+ unsigned long iVerb = 0;
+ if (cmStrToULong(def, &iVerb)) {
+ // Numeric verbosity
+ this->Verbosity = static_cast<unsigned int>(iVerb);
+ } else {
+ // Non numeric verbosity
+ if (cmIsOn(def)) {
+ this->Verbosity = 1;
+ }
+ }
+ }
+ }
+
+ // Targets FOLDER
+ {
+ const char* folder =
+ this->Makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");
+ if (folder == nullptr) {
+ folder = this->Makefile->GetState()->GetGlobalProperty(
+ "AUTOGEN_TARGETS_FOLDER");
+ }
+ // Inherit FOLDER property from target (#13688)
+ if (folder == nullptr) {
+ folder = this->GenTarget->GetProperty("FOLDER");
+ }
+ if (folder != nullptr) {
+ this->TargetsFolder = folder;
+ }
+ }
+
+ // Check status of policy CMP0071
+ {
+ cmPolicies::PolicyStatus const CMP0071_status =
+ this->Makefile->GetPolicyStatus(cmPolicies::CMP0071);
+ switch (CMP0071_status) {
+ case cmPolicies::WARN:
+ this->CMP0071Warn = true;
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ // Ignore GENERATED file
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ // Process GENERATED file
+ this->CMP0071Accept = true;
+ break;
+ }
+ }
+
+ // Common directories
+ {
+ // Collapsed current binary directory
+ std::string const cbd = cmSystemTools::CollapseFullPath(
+ std::string(), this->Makefile->GetCurrentBinaryDirectory());
+
+ // Info directory
+ this->Dir.Info = cmStrCat(cbd, "/CMakeFiles/", this->GenTarget->GetName(),
+ "_autogen.dir");
+ cmSystemTools::ConvertToUnixSlashes(this->Dir.Info);
+
+ // Build directory
+ this->Dir.Build = this->GenTarget->GetSafeProperty("AUTOGEN_BUILD_DIR");
+ if (this->Dir.Build.empty()) {
+ this->Dir.Build =
+ cmStrCat(cbd, '/', this->GenTarget->GetName(), "_autogen");
+ }
+ cmSystemTools::ConvertToUnixSlashes(this->Dir.Build);
+ // Cleanup build directory
+ this->AddCleanFile(this->Dir.Build);
+
+ // Working directory
+ this->Dir.Work = cbd;
+ cmSystemTools::ConvertToUnixSlashes(this->Dir.Work);
+
+ // Include directory
+ ConfigFileNames(this->Dir.Include, cmStrCat(this->Dir.Build, "/include"),
+ "");
+ this->Dir.IncludeGenExp = this->Dir.Include.Default;
+ if (this->MultiConfig) {
+ this->Dir.IncludeGenExp += "_$<CONFIG>";
+ }
+ }
+
+ // Moc, Uic and _autogen target settings
+ if (this->MocOrUicEnabled()) {
+ // Init moc specific settings
+ if (this->Moc.Enabled && !InitMoc()) {
+ return false;
+ }
+
+ // Init uic specific settings
+ if (this->Uic.Enabled && !InitUic()) {
+ return false;
+ }
+
+ // Autogen target name
+ this->AutogenTarget.Name =
+ cmStrCat(this->GenTarget->GetName(), "_autogen");
+
+ // Autogen target parallel processing
+ {
+ std::string prop = this->GenTarget->GetSafeProperty("AUTOGEN_PARALLEL");
+ if (prop.empty() || (prop == "AUTO")) {
+ // Autodetect number of CPUs
+ this->AutogenTarget.Parallel = GetParallelCPUCount();
+ } else {
+ this->AutogenTarget.Parallel = 1;
+ }
+ }
+
+ // Autogen target info and settings files
+ {
+ // Info file
+ this->AutogenTarget.InfoFile =
+ cmStrCat(this->Dir.Info, "/AutogenInfo.json");
+
+ // Used settings file
+ ConfigFileNames(this->AutogenTarget.SettingsFile,
+ cmStrCat(this->Dir.Info, "/AutogenUsed"), ".txt");
+ ConfigFileClean(this->AutogenTarget.SettingsFile);
+
+ // Parse cache file
+ ConfigFileNames(this->AutogenTarget.ParseCacheFile,
+ cmStrCat(this->Dir.Info, "/ParseCache"), ".txt");
+ ConfigFileClean(this->AutogenTarget.ParseCacheFile);
+ }
+
+ // Autogen target: Compute user defined dependencies
+ {
+ this->AutogenTarget.DependOrigin =
+ this->GenTarget->GetPropertyAsBool("AUTOGEN_ORIGIN_DEPENDS");
+
+ std::string const deps =
+ this->GenTarget->GetSafeProperty("AUTOGEN_TARGET_DEPENDS");
+ if (!deps.empty()) {
+ for (std::string const& depName : cmExpandedList(deps)) {
+ // Allow target and file dependencies
+ auto* depTarget = this->Makefile->FindTargetToUse(depName);
+ if (depTarget != nullptr) {
+ this->AutogenTarget.DependTargets.insert(depTarget);
+ } else {
+ this->AutogenTarget.DependFiles.insert(depName);
+ }
+ }
+ }
+ }
+
+ if (this->Moc.Enabled) {
+ // Path prefix
+ if (cmIsOn(this->GenTarget->GetSafeProperty("AUTOMOC_PATH_PREFIX"))) {
+ this->Moc.PathPrefix = true;
+ }
+
+ // CMAKE_AUTOMOC_RELAXED_MODE
+ if (this->Makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE")) {
+ this->Moc.RelaxedMode = true;
+ this->Makefile->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat("AUTOMOC: CMAKE_AUTOMOC_RELAXED_MODE is "
+ "deprecated an will be removed in the future. Consider "
+ "disabling it and converting the target ",
+ this->GenTarget->GetName(), " to regular mode."));
+ }
+
+ // Options
+ cmExpandList(this->GenTarget->GetSafeProperty("AUTOMOC_MOC_OPTIONS"),
+ this->Moc.Options);
+ // Filters
+ cmExpandList(this->GenTarget->GetSafeProperty("AUTOMOC_MACRO_NAMES"),
+ this->Moc.MacroNames);
+ {
+ auto filterList = cmExpandedList(
+ this->GenTarget->GetSafeProperty("AUTOMOC_DEPEND_FILTERS"));
+ if ((filterList.size() % 2) != 0) {
+ cmSystemTools::Error(
+ cmStrCat("AutoMoc: AUTOMOC_DEPEND_FILTERS predefs size ",
+ filterList.size(), " is not a multiple of 2."));
+ return false;
+ }
+ this->Moc.DependFilters.reserve(1 + (filterList.size() / 2));
+ this->Moc.DependFilters.emplace_back(
+ "Q_PLUGIN_METADATA",
+ "[\n][ \t]*Q_PLUGIN_METADATA[ \t]*\\("
+ "[^\\)]*FILE[ \t]*\"([^\"]+)\"");
+ for (std::size_t ii = 0; ii != filterList.size(); ii += 2) {
+ this->Moc.DependFilters.emplace_back(filterList[ii],
+ filterList[ii + 1]);
+ }
+ }
+ }
+ }
+
+ // Init rcc specific settings
+ if (this->Rcc.Enabled && !InitRcc()) {
+ return false;
+ }
+
+ // Add autogen include directory to the origin target INCLUDE_DIRECTORIES
+ if (this->MocOrUicEnabled() || (this->Rcc.Enabled && this->MultiConfig)) {
+ this->GenTarget->AddIncludeDirectory(this->Dir.IncludeGenExp, true);
+ }
+
+ // Scan files
+ if (!this->InitScanFiles()) {
+ return false;
+ }
+
+ // Create autogen target
+ if (this->MocOrUicEnabled() && !this->InitAutogenTarget()) {
+ return false;
+ }
+
+ // Create rcc targets
+ if (this->Rcc.Enabled && !this->InitRccTargets()) {
+ return false;
+ }
+
+ return true;
+}
+
+bool cmQtAutoGenInitializer::InitMoc()
+{
+ // Mocs compilation file
+ this->Moc.CompilationFile =
+ cmStrCat(this->Dir.Build, "/mocs_compilation.cpp");
+
+ // Moc predefs
+ if (this->GenTarget->GetPropertyAsBool("AUTOMOC_COMPILER_PREDEFINES") &&
+ (this->QtVersion >= IntegerVersion(5, 8))) {
+ // Command
+ cmExpandList(this->Makefile->GetSafeDefinition(
+ "CMAKE_CXX_COMPILER_PREDEFINES_COMMAND"),
+ this->Moc.PredefsCmd);
+ // Header
+ if (!this->Moc.PredefsCmd.empty()) {
+ ConfigFileNames(this->Moc.PredefsFile,
+ cmStrCat(this->Dir.Build, "/moc_predefs"), ".h");
+ }
+ }
+
+ // Moc includes
+ {
+ SearchPathSanitizer sanitizer(this->Makefile);
+ auto getDirs =
+ [this, &sanitizer](std::string const& cfg) -> std::vector<std::string> {
+ // Get the include dirs for this target, without stripping the implicit
+ // include dirs off, see issue #13667.
+ std::vector<std::string> dirs;
+ bool const appendImplicit = (this->QtVersion.Major >= 5);
+ this->LocalGen->GetIncludeDirectoriesImplicit(
+ dirs, this->GenTarget, "CXX", cfg, false, appendImplicit);
+ return sanitizer(dirs);
+ };
+
+ // Default configuration include directories
+ this->Moc.Includes.Default = getDirs(this->ConfigDefault);
+ // Other configuration settings
+ if (this->MultiConfig) {
+ for (std::string const& cfg : this->ConfigsList) {
+ std::vector<std::string> dirs = getDirs(cfg);
+ if (dirs == this->Moc.Includes.Default) {
+ continue;
+ }
+ this->Moc.Includes.Config[cfg] = std::move(dirs);
+ }
+ }
+ }
+
+ // Moc compile definitions
+ {
+ auto getDefs = [this](std::string const& cfg) -> std::set<std::string> {
+ std::set<std::string> defines;
+ this->LocalGen->GetTargetDefines(this->GenTarget, cfg, "CXX", defines);
+#ifdef _WIN32
+ if (this->Moc.PredefsCmd.empty()) {
+ // Add WIN32 definition if we don't have a moc_predefs.h
+ defines.insert("WIN32");
+ }
+#endif
+ return defines;
+ };
+
+ // Default configuration defines
+ this->Moc.Defines.Default = getDefs(this->ConfigDefault);
+ // Other configuration defines
+ if (this->MultiConfig) {
+ for (std::string const& cfg : this->ConfigsList) {
+ std::set<std::string> defines = getDefs(cfg);
+ if (defines == this->Moc.Defines.Default) {
+ continue;
+ }
+ this->Moc.Defines.Config[cfg] = std::move(defines);
+ }
+ }
+ }
+
+ // Moc executable
+ {
+ if (!this->GetQtExecutable(this->Moc, "moc", false)) {
+ return false;
+ }
+ // Let the _autogen target depend on the moc executable
+ if (this->Moc.ExecutableTarget != nullptr) {
+ this->AutogenTarget.DependTargets.insert(
+ this->Moc.ExecutableTarget->Target);
+ }
+ }
+
+ return true;
+}
+
+bool cmQtAutoGenInitializer::InitUic()
+{
+ // Uic search paths
+ {
+ std::string const usp =
+ this->GenTarget->GetSafeProperty("AUTOUIC_SEARCH_PATHS");
+ if (!usp.empty()) {
+ this->Uic.SearchPaths =
+ SearchPathSanitizer(this->Makefile)(cmExpandedList(usp));
+ }
+ }
+ // Uic target options
+ {
+ auto getOpts = [this](std::string const& cfg) -> std::vector<std::string> {
+ std::vector<std::string> opts;
+ this->GenTarget->GetAutoUicOptions(opts, cfg);
+ return opts;
+ };
+
+ // Default options
+ this->Uic.Options.Default = getOpts(this->ConfigDefault);
+ // Configuration specific options
+ if (this->MultiConfig) {
+ for (std::string const& cfg : this->ConfigsList) {
+ std::vector<std::string> options = getOpts(cfg);
+ if (options == this->Uic.Options.Default) {
+ continue;
+ }
+ this->Uic.Options.Config[cfg] = std::move(options);
+ }
+ }
+ }
+
+ // Uic executable
+ {
+ if (!this->GetQtExecutable(this->Uic, "uic", true)) {
+ return false;
+ }
+ // Let the _autogen target depend on the uic executable
+ if (this->Uic.ExecutableTarget != nullptr) {
+ this->AutogenTarget.DependTargets.insert(
+ this->Uic.ExecutableTarget->Target);
+ }
+ }
+
+ return true;
+}
+
+bool cmQtAutoGenInitializer::InitRcc()
+{
+ // Rcc executable
+ {
+ if (!this->GetQtExecutable(this->Rcc, "rcc", false)) {
+ return false;
+ }
+ // Evaluate test output on demand
+ CompilerFeatures& features = *this->Rcc.ExecutableFeatures;
+ if (!features.Evaluated) {
+ // Look for list options
+ if (this->QtVersion.Major == 5 || this->QtVersion.Major == 6) {
+ if (features.HelpOutput.find("--list") != std::string::npos) {
+ features.ListOptions.emplace_back("--list");
+ } else if (features.HelpOutput.find("-list") != std::string::npos) {
+ features.ListOptions.emplace_back("-list");
+ }
+ }
+ // Evaluation finished
+ features.Evaluated = true;
+ }
+ }
+
+ return true;
+}
+
+bool cmQtAutoGenInitializer::InitScanFiles()
+{
+ cmake const* cm = this->Makefile->GetCMakeInstance();
+ auto const& kw = this->GlobalInitializer->kw();
+
+ auto makeMUFile = [this, &kw](cmSourceFile* sf, std::string const& fullPath,
+ bool muIt) -> MUFileHandle {
+ MUFileHandle muf = cm::make_unique<MUFile>();
+ muf->FullPath = fullPath;
+ muf->SF = sf;
+ muf->Generated = sf->GetIsGenerated();
+ bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN);
+ muf->SkipMoc = this->Moc.Enabled &&
+ (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOMOC));
+ muf->SkipUic = this->Uic.Enabled &&
+ (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC));
+ if (muIt) {
+ muf->MocIt = this->Moc.Enabled && !muf->SkipMoc;
+ muf->UicIt = this->Uic.Enabled && !muf->SkipUic;
+ }
+ return muf;
+ };
+
+ auto addMUFile = [&](MUFileHandle&& muf, bool isHeader) {
+ if ((muf->MocIt || muf->UicIt) && muf->Generated) {
+ this->AutogenTarget.FilesGenerated.emplace_back(muf.get());
+ }
+ if (isHeader) {
+ this->AutogenTarget.Headers.emplace(muf->SF, std::move(muf));
+ } else {
+ this->AutogenTarget.Sources.emplace(muf->SF, std::move(muf));
+ }
+ };
+
+ // Scan through target files
+ {
+ // Scan through target files
+ std::vector<cmSourceFile*> srcFiles;
+ this->GenTarget->GetConfigCommonSourceFiles(srcFiles);
+ for (cmSourceFile* sf : srcFiles) {
+ // sf->GetExtension() is only valid after sf->ResolveFullPath() ...
+ // Since we're iterating over source files that might be not in the
+ // target we need to check for path errors (not existing files).
+ std::string pathError;
+ std::string const& fullPath = sf->ResolveFullPath(&pathError);
+ if (!pathError.empty() || fullPath.empty()) {
+ continue;
+ }
+ std::string const& extLower =
+ cmSystemTools::LowerCase(sf->GetExtension());
+
+ // Register files that will be scanned by moc or uic
+ if (this->MocOrUicEnabled()) {
+ // FIXME: Add a policy to include .hh files.
+ if (cm->IsHeaderExtension(extLower) && extLower != "hh") {
+ addMUFile(makeMUFile(sf, fullPath, true), true);
+ } else if (cm->IsSourceExtension(extLower)) {
+ addMUFile(makeMUFile(sf, fullPath, true), false);
+ }
+ }
+
+ // Register rcc enabled files
+ if (this->Rcc.Enabled) {
+ if ((extLower == kw.qrc) && !sf->GetPropertyAsBool(kw.SKIP_AUTOGEN) &&
+ !sf->GetPropertyAsBool(kw.SKIP_AUTORCC)) {
+ // Register qrc file
+ Qrc qrc;
+ qrc.QrcFile = fullPath;
+ qrc.QrcName =
+ cmSystemTools::GetFilenameWithoutLastExtension(qrc.QrcFile);
+ qrc.Generated = sf->GetIsGenerated();
+ // RCC options
+ {
+ std::string const opts = sf->GetSafeProperty(kw.AUTORCC_OPTIONS);
+ if (!opts.empty()) {
+ cmExpandList(opts, qrc.Options);
+ }
+ }
+ this->Rcc.Qrcs.push_back(std::move(qrc));
+ }
+ }
+ }
+ }
+ // cmGeneratorTarget::GetConfigCommonSourceFiles computes the target's
+ // sources meta data cache. Clear it so that OBJECT library targets that
+ // are AUTOGEN initialized after this target get their added
+ // mocs_compilation.cpp source acknowledged by this target.
+ this->GenTarget->ClearSourcesCache();
+
+ // For source files find additional headers and private headers
+ if (this->MocOrUicEnabled()) {
+ std::vector<MUFileHandle> extraHeaders;
+ extraHeaders.reserve(this->AutogenTarget.Sources.size() * 2);
+ // Header search suffixes and extensions
+ static std::initializer_list<cm::string_view> const suffixes{ "", "_p" };
+ auto const& exts = cm->GetHeaderExtensions();
+ // Scan through sources
+ for (auto const& pair : this->AutogenTarget.Sources) {
+ MUFile const& muf = *pair.second;
+ if (muf.MocIt || muf.UicIt) {
+ // Search for the default header file and a private header
+ std::string const& srcFullPath = muf.SF->ResolveFullPath();
+ std::string basePath = cmStrCat(
+ cmQtAutoGen::SubDirPrefix(srcFullPath),
+ cmSystemTools::GetFilenameWithoutLastExtension(srcFullPath));
+ for (auto const& suffix : suffixes) {
+ std::string const suffixedPath = cmStrCat(basePath, suffix);
+ for (auto const& ext : exts) {
+ std::string fullPath = cmStrCat(suffixedPath, '.', ext);
+
+ auto constexpr locationKind = cmSourceFileLocationKind::Known;
+ cmSourceFile* sf =
+ this->Makefile->GetSource(fullPath, locationKind);
+ if (sf != nullptr) {
+ // Check if we know about this header already
+ if (cmContains(this->AutogenTarget.Headers, sf)) {
+ continue;
+ }
+ // We only accept not-GENERATED files that do exist.
+ if (!sf->GetIsGenerated() &&
+ !cmSystemTools::FileExists(fullPath)) {
+ continue;
+ }
+ } else if (cmSystemTools::FileExists(fullPath)) {
+ // Create a new source file for the existing file
+ sf = this->Makefile->CreateSource(fullPath, false, locationKind);
+ }
+
+ if (sf != nullptr) {
+ auto eMuf = makeMUFile(sf, fullPath, true);
+ // Ony process moc/uic when the parent is processed as well
+ if (!muf.MocIt) {
+ eMuf->MocIt = false;
+ }
+ if (!muf.UicIt) {
+ eMuf->UicIt = false;
+ }
+ extraHeaders.emplace_back(std::move(eMuf));
+ }
+ }
+ }
+ }
+ }
+ // Move generated files to main headers list
+ for (auto& eMuf : extraHeaders) {
+ addMUFile(std::move(eMuf), true);
+ }
+ }
+
+ // Scan through all source files in the makefile to extract moc and uic
+ // parameters. Historically we support non target source file parameters.
+ // The reason is that their file names might be discovered from source files
+ // at generation time.
+ if (this->MocOrUicEnabled()) {
+ for (cmSourceFile* sf : this->Makefile->GetSourceFiles()) {
+ // sf->GetExtension() is only valid after sf->ResolveFullPath() ...
+ // Since we're iterating over source files that might be not in the
+ // target we need to check for path errors (not existing files).
+ std::string pathError;
+ std::string const& fullPath = sf->ResolveFullPath(&pathError);
+ if (!pathError.empty() || fullPath.empty()) {
+ continue;
+ }
+ std::string const& extLower =
+ cmSystemTools::LowerCase(sf->GetExtension());
+
+ // FIXME: Add a policy to include .hh files.
+ if (cm->IsHeaderExtension(extLower) && extLower != "hh") {
+ if (!cmContains(this->AutogenTarget.Headers, sf)) {
+ auto muf = makeMUFile(sf, fullPath, false);
+ if (muf->SkipMoc || muf->SkipUic) {
+ this->AutogenTarget.Headers.emplace(sf, std::move(muf));
+ }
+ }
+ } else if (cm->IsSourceExtension(extLower)) {
+ if (!cmContains(this->AutogenTarget.Headers, sf)) {
+ auto muf = makeMUFile(sf, fullPath, false);
+ if (muf->SkipMoc || muf->SkipUic) {
+ this->AutogenTarget.Sources.emplace(sf, std::move(muf));
+ }
+ }
+ } else if (this->Uic.Enabled && (extLower == kw.ui)) {
+ // .ui file
+ bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN);
+ bool const skipUic =
+ (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC));
+ if (!skipUic) {
+ // Check if the .ui file has uic options
+ std::string const uicOpts = sf->GetSafeProperty(kw.AUTOUIC_OPTIONS);
+ if (!uicOpts.empty()) {
+ this->Uic.UiFiles.emplace_back(fullPath, cmExpandedList(uicOpts));
+ }
+ } else {
+ // Register skipped .ui file
+ this->Uic.SkipUi.insert(fullPath);
+ }
+ }
+ }
+ }
+
+ // Process GENERATED sources and headers
+ if (this->MocOrUicEnabled() && !this->AutogenTarget.FilesGenerated.empty()) {
+ if (this->CMP0071Accept) {
+ // Let the autogen target depend on the GENERATED files
+ for (MUFile* muf : this->AutogenTarget.FilesGenerated) {
+ this->AutogenTarget.DependFiles.insert(muf->FullPath);
+ }
+ } else if (this->CMP0071Warn) {
+ cm::string_view property;
+ if (this->Moc.Enabled && this->Uic.Enabled) {
+ property = "SKIP_AUTOGEN";
+ } else if (this->Moc.Enabled) {
+ property = "SKIP_AUTOMOC";
+ } else if (this->Uic.Enabled) {
+ property = "SKIP_AUTOUIC";
+ }
+ std::string files;
+ for (MUFile* muf : this->AutogenTarget.FilesGenerated) {
+ files += cmStrCat(" ", Quoted(muf->FullPath), '\n');
+ }
+ this->Makefile->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0071), '\n',
+ "For compatibility, CMake is excluding the GENERATED source "
+ "file(s):\n",
+ files, "from processing by ",
+ cmQtAutoGen::Tools(this->Moc.Enabled, this->Uic.Enabled, false),
+ ". If any of the files should be processed, set CMP0071 to NEW. "
+ "If any of the files should not be processed, "
+ "explicitly exclude them by setting the source file property ",
+ property, ":\n set_property(SOURCE file.h PROPERTY ", property,
+ " ON)\n"));
+ }
+ }
+
+ // Process qrc files
+ if (!this->Rcc.Qrcs.empty()) {
+ const bool modernQt = (this->QtVersion.Major >= 5);
+ // Target rcc options
+ std::vector<std::string> optionsTarget =
+ cmExpandedList(this->GenTarget->GetSafeProperty(kw.AUTORCC_OPTIONS));
+
+ // Check if file name is unique
+ for (Qrc& qrc : this->Rcc.Qrcs) {
+ qrc.Unique = true;
+ for (Qrc const& qrc2 : this->Rcc.Qrcs) {
+ if ((&qrc != &qrc2) && (qrc.QrcName == qrc2.QrcName)) {
+ qrc.Unique = false;
+ break;
+ }
+ }
+ }
+ // Path checksum and file names
+ for (Qrc& qrc : this->Rcc.Qrcs) {
+ // Path checksum
+ qrc.QrcPathChecksum = this->PathCheckSum.getPart(qrc.QrcFile);
+ // Output file name
+ qrc.OutputFile = cmStrCat(this->Dir.Build, '/', qrc.QrcPathChecksum,
+ "/qrc_", qrc.QrcName, ".cpp");
+ std::string const base = cmStrCat(this->Dir.Info, "/AutoRcc_",
+ qrc.QrcName, '_', qrc.QrcPathChecksum);
+ qrc.LockFile = cmStrCat(base, "_Lock.lock");
+ qrc.InfoFile = cmStrCat(base, "_Info.json");
+ ConfigFileNames(qrc.SettingsFile, cmStrCat(base, "_Used"), ".txt");
+ }
+ // rcc options
+ for (Qrc& qrc : this->Rcc.Qrcs) {
+ // Target options
+ std::vector<std::string> opts = optionsTarget;
+ // Merge computed "-name XYZ" option
+ {
+ std::string name = qrc.QrcName;
+ // Replace '-' with '_'. The former is not valid for symbol names.
+ std::replace(name.begin(), name.end(), '-', '_');
+ if (!qrc.Unique) {
+ name += cmStrCat('_', qrc.QrcPathChecksum);
+ }
+ std::vector<std::string> nameOpts;
+ nameOpts.emplace_back("-name");
+ nameOpts.emplace_back(std::move(name));
+ RccMergeOptions(opts, nameOpts, modernQt);
+ }
+ // Merge file option
+ RccMergeOptions(opts, qrc.Options, modernQt);
+ qrc.Options = std::move(opts);
+ }
+ // rcc resources
+ for (Qrc& qrc : this->Rcc.Qrcs) {
+ if (!qrc.Generated) {
+ std::string error;
+ RccLister const lister(this->Rcc.Executable,
+ this->Rcc.ExecutableFeatures->ListOptions);
+ if (!lister.list(qrc.QrcFile, qrc.Resources, error)) {
+ cmSystemTools::Error(error);
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+bool cmQtAutoGenInitializer::InitAutogenTarget()
+{
+ // Register info file as generated by CMake
+ this->Makefile->AddCMakeOutputFile(this->AutogenTarget.InfoFile);
+
+ // Files provided by the autogen target
+ std::vector<std::string> autogenProvides;
+ if (this->Moc.Enabled) {
+ this->AddGeneratedSource(this->Moc.CompilationFile, this->Moc, true);
+ autogenProvides.push_back(this->Moc.CompilationFile);
+ }
+
+ // Compose target comment
+ std::string autogenComment;
+ {
+ std::string tools;
+ if (this->Moc.Enabled) {
+ tools += "MOC";
+ }
+ if (this->Uic.Enabled) {
+ if (!tools.empty()) {
+ tools += " and ";
+ }
+ tools += "UIC";
+ }
+ autogenComment = cmStrCat("Automatic ", tools, " for target ",
+ this->GenTarget->GetName());
+ }
+
+ // Compose command lines
+ cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
+ { cmSystemTools::GetCMakeCommand(), "-E", "cmake_autogen",
+ this->AutogenTarget.InfoFile, "$<CONFIGURATION>" });
+
+ // Use PRE_BUILD on demand
+ bool usePRE_BUILD = false;
+ if (this->GlobalGen->GetName().find("Visual Studio") != std::string::npos) {
+ // Under VS use a PRE_BUILD event instead of a separate target to
+ // reduce the number of targets loaded into the IDE.
+ // This also works around a VS 11 bug that may skip updating the target:
+ // https://connect.microsoft.com/VisualStudio/feedback/details/769495
+ usePRE_BUILD = true;
+ }
+ // Disable PRE_BUILD in some cases
+ if (usePRE_BUILD) {
+ // Cannot use PRE_BUILD with file depends
+ if (!this->AutogenTarget.DependFiles.empty()) {
+ usePRE_BUILD = false;
+ }
+ // Cannot use PRE_BUILD when a global autogen target is in place
+ if (AutogenTarget.GlobalTarget) {
+ usePRE_BUILD = false;
+ }
+ }
+ // Create the autogen target/command
+ if (usePRE_BUILD) {
+ // Add additional autogen target dependencies to origin target
+ for (cmTarget* depTarget : this->AutogenTarget.DependTargets) {
+ this->GenTarget->Target->AddUtility(depTarget->GetName(),
+ this->Makefile);
+ }
+
+ // Add the pre-build command directly to bypass the OBJECT_LIBRARY
+ // rejection in cmMakefile::AddCustomCommandToTarget because we know
+ // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case.
+ //
+ // PRE_BUILD does not support file dependencies!
+ const std::vector<std::string> no_output;
+ const std::vector<std::string> no_deps;
+ cmCustomCommand cc(this->Makefile, no_output, autogenProvides, no_deps,
+ commandLines, autogenComment.c_str(),
+ this->Dir.Work.c_str());
+ cc.SetEscapeOldStyle(false);
+ cc.SetEscapeAllowMakeVars(true);
+ this->GenTarget->Target->AddPreBuildCommand(std::move(cc));
+ } else {
+
+ // Add link library target dependencies to the autogen target
+ // dependencies
+ if (this->AutogenTarget.DependOrigin) {
+ // add_dependencies/addUtility do not support generator expressions.
+ // We depend only on the libraries found in all configs therefore.
+ std::map<cmGeneratorTarget const*, std::size_t> commonTargets;
+ for (std::string const& config : this->ConfigsList) {
+ cmLinkImplementationLibraries const* libs =
+ this->GenTarget->GetLinkImplementationLibraries(config);
+ if (libs != nullptr) {
+ for (cmLinkItem const& item : libs->Libraries) {
+ cmGeneratorTarget const* libTarget = item.Target;
+ if ((libTarget != nullptr) &&
+ !StaticLibraryCycle(this->GenTarget, libTarget, config)) {
+ // Increment target config count
+ commonTargets[libTarget]++;
+ }
+ }
+ }
+ }
+ for (auto const& item : commonTargets) {
+ if (item.second == this->ConfigsList.size()) {
+ this->AutogenTarget.DependTargets.insert(item.first->Target);
+ }
+ }
+ }
+
+ // Create autogen target
+ cmTarget* autogenTarget = this->Makefile->AddUtilityCommand(
+ this->AutogenTarget.Name, cmCommandOrigin::Generator, true,
+ this->Dir.Work.c_str(), /*byproducts=*/autogenProvides,
+ std::vector<std::string>(this->AutogenTarget.DependFiles.begin(),
+ this->AutogenTarget.DependFiles.end()),
+ commandLines, false, autogenComment.c_str());
+ // Create autogen generator target
+ this->LocalGen->AddGeneratorTarget(
+ new cmGeneratorTarget(autogenTarget, this->LocalGen));
+
+ // Forward origin utilities to autogen target
+ if (this->AutogenTarget.DependOrigin) {
+ for (BT<std::string> const& depName : this->GenTarget->GetUtilities()) {
+ autogenTarget->AddUtility(depName.Value, this->Makefile);
+ }
+ }
+ // Add additional autogen target dependencies to autogen target
+ for (cmTarget* depTarget : this->AutogenTarget.DependTargets) {
+ autogenTarget->AddUtility(depTarget->GetName(), this->Makefile);
+ }
+
+ // Set FOLDER property in autogen target
+ if (!this->TargetsFolder.empty()) {
+ autogenTarget->SetProperty("FOLDER", this->TargetsFolder.c_str());
+ }
+
+ // Add autogen target to the origin target dependencies
+ this->GenTarget->Target->AddUtility(this->AutogenTarget.Name,
+ this->Makefile);
+
+ // Add autogen target to the global autogen target dependencies
+ if (this->AutogenTarget.GlobalTarget) {
+ this->GlobalInitializer->AddToGlobalAutoGen(this->LocalGen,
+ this->AutogenTarget.Name);
+ }
+ }
+
+ return true;
+}
+
+bool cmQtAutoGenInitializer::InitRccTargets()
+{
+ for (Qrc const& qrc : this->Rcc.Qrcs) {
+ // Register info file as generated by CMake
+ this->Makefile->AddCMakeOutputFile(qrc.InfoFile);
+ // Register file at target
+ {
+ cmSourceFile* sf = this->AddGeneratedSource(qrc.OutputFile, this->Rcc);
+ sf->SetProperty("SKIP_UNITY_BUILD_INCLUSION", "On");
+ }
+
+ std::vector<std::string> ccOutput;
+ ccOutput.push_back(qrc.OutputFile);
+
+ std::vector<std::string> ccDepends;
+ // Add the .qrc and info file to the custom command dependencies
+ ccDepends.push_back(qrc.QrcFile);
+ ccDepends.push_back(qrc.InfoFile);
+
+ cmCustomCommandLines commandLines;
+ if (this->MultiConfig) {
+ // Build for all configurations
+ for (std::string const& config : this->ConfigsList) {
+ commandLines.push_back(
+ cmMakeCommandLine({ cmSystemTools::GetCMakeCommand(), "-E",
+ "cmake_autorcc", qrc.InfoFile, config }));
+ }
+ } else {
+ commandLines.push_back(
+ cmMakeCommandLine({ cmSystemTools::GetCMakeCommand(), "-E",
+ "cmake_autorcc", qrc.InfoFile, "$<CONFIG>" }));
+ }
+ std::string ccComment =
+ cmStrCat("Automatic RCC for ",
+ FileProjectRelativePath(this->Makefile, qrc.QrcFile));
+
+ if (qrc.Generated || this->Rcc.GlobalTarget) {
+ // Create custom rcc target
+ std::string ccName;
+ {
+ ccName = cmStrCat(this->GenTarget->GetName(), "_arcc_", qrc.QrcName);
+ if (!qrc.Unique) {
+ ccName += cmStrCat('_', qrc.QrcPathChecksum);
+ }
+
+ cmTarget* autoRccTarget = this->Makefile->AddUtilityCommand(
+ ccName, cmCommandOrigin::Generator, true, this->Dir.Work.c_str(),
+ ccOutput, ccDepends, commandLines, false, ccComment.c_str());
+
+ // Create autogen generator target
+ this->LocalGen->AddGeneratorTarget(
+ new cmGeneratorTarget(autoRccTarget, this->LocalGen));
+
+ // Set FOLDER property in autogen target
+ if (!this->TargetsFolder.empty()) {
+ autoRccTarget->SetProperty("FOLDER", this->TargetsFolder.c_str());
+ }
+ if (!this->Rcc.ExecutableTargetName.empty()) {
+ autoRccTarget->AddUtility(this->Rcc.ExecutableTargetName,
+ this->Makefile);
+ }
+ }
+ // Add autogen target to the origin target dependencies
+ this->GenTarget->Target->AddUtility(ccName, this->Makefile);
+
+ // Add autogen target to the global autogen target dependencies
+ if (this->Rcc.GlobalTarget) {
+ this->GlobalInitializer->AddToGlobalAutoRcc(this->LocalGen, ccName);
+ }
+ } else {
+ // Create custom rcc command
+ {
+ std::vector<std::string> ccByproducts;
+
+ // Add the resource files to the dependencies
+ for (std::string const& fileName : qrc.Resources) {
+ // Add resource file to the custom command dependencies
+ ccDepends.push_back(fileName);
+ }
+ if (!this->Rcc.ExecutableTargetName.empty()) {
+ ccDepends.push_back(this->Rcc.ExecutableTargetName);
+ }
+ std::string no_main_dependency;
+ cmImplicitDependsList no_implicit_depends;
+ this->Makefile->AddCustomCommandToOutput(
+ ccOutput, ccByproducts, ccDepends, no_main_dependency,
+ no_implicit_depends, commandLines, ccComment.c_str(),
+ this->Dir.Work.c_str());
+ }
+ // Reconfigure when .qrc file changes
+ this->Makefile->AddCMakeDependFile(qrc.QrcFile);
+ }
+ }
+
+ return true;
+}
+
+bool cmQtAutoGenInitializer::SetupCustomTargets()
+{
+ // Create info directory on demand
+ if (!cmSystemTools::MakeDirectory(this->Dir.Info)) {
+ cmSystemTools::Error(cmStrCat("AutoGen: Could not create directory: ",
+ Quoted(this->Dir.Info)));
+ return false;
+ }
+
+ // Generate autogen target info file
+ if (this->MocOrUicEnabled()) {
+ // Write autogen target info files
+ if (!this->SetupWriteAutogenInfo()) {
+ return false;
+ }
+ }
+
+ // Write AUTORCC info files
+ return !this->Rcc.Enabled || this->SetupWriteRccInfo();
+}
+
+bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
+{
+ // Utility lambdas
+ auto MfDef = [this](std::string const& key) {
+ return this->Makefile->GetSafeDefinition(key);
+ };
+
+ // Filtered headers and sources
+ std::set<std::string> moc_skip;
+ std::set<std::string> uic_skip;
+ std::vector<MUFile const*> headers;
+ std::vector<MUFile const*> sources;
+
+ // Filter headers
+ {
+ headers.reserve(this->AutogenTarget.Headers.size());
+ for (auto const& pair : this->AutogenTarget.Headers) {
+ MUFile const* const muf = pair.second.get();
+ if (muf->Generated && !this->CMP0071Accept) {
+ continue;
+ }
+ if (muf->SkipMoc) {
+ moc_skip.insert(muf->FullPath);
+ }
+ if (muf->SkipUic) {
+ uic_skip.insert(muf->FullPath);
+ }
+ if (muf->MocIt || muf->UicIt) {
+ headers.emplace_back(muf);
+ }
+ }
+ std::sort(headers.begin(), headers.end(),
+ [](MUFile const* a, MUFile const* b) {
+ return (a->FullPath < b->FullPath);
+ });
+ }
+
+ // Filter sources
+ {
+ sources.reserve(this->AutogenTarget.Sources.size());
+ for (auto const& pair : this->AutogenTarget.Sources) {
+ MUFile const* const muf = pair.second.get();
+ if (muf->Generated && !this->CMP0071Accept) {
+ continue;
+ }
+ if (muf->SkipMoc) {
+ moc_skip.insert(muf->FullPath);
+ }
+ if (muf->SkipUic) {
+ uic_skip.insert(muf->FullPath);
+ }
+ if (muf->MocIt || muf->UicIt) {
+ sources.emplace_back(muf);
+ }
+ }
+ std::sort(sources.begin(), sources.end(),
+ [](MUFile const* a, MUFile const* b) {
+ return (a->FullPath < b->FullPath);
+ });
+ }
+
+ // Info writer
+ InfoWriter info;
+
+ // General
+ info.SetBool("MULTI_CONFIG", this->MultiConfig);
+ info.SetUInt("PARALLEL", this->AutogenTarget.Parallel);
+ info.SetUInt("VERBOSITY", this->Verbosity);
+
+ // Directories
+ info.Set("CMAKE_SOURCE_DIR", MfDef("CMAKE_SOURCE_DIR"));
+ info.Set("CMAKE_BINARY_DIR", MfDef("CMAKE_BINARY_DIR"));
+ info.Set("CMAKE_CURRENT_SOURCE_DIR", MfDef("CMAKE_CURRENT_SOURCE_DIR"));
+ info.Set("CMAKE_CURRENT_BINARY_DIR", MfDef("CMAKE_CURRENT_BINARY_DIR"));
+ info.Set("BUILD_DIR", this->Dir.Build);
+ info.SetConfig("INCLUDE_DIR", this->Dir.Include);
+
+ info.SetUInt("QT_VERSION_MAJOR", this->QtVersion.Major);
+ info.Set("QT_MOC_EXECUTABLE", this->Moc.Executable);
+ info.Set("QT_UIC_EXECUTABLE", this->Uic.Executable);
+
+ info.Set("CMAKE_EXECUTABLE", cmSystemTools::GetCMakeCommand());
+ info.SetConfig("SETTINGS_FILE", this->AutogenTarget.SettingsFile);
+ info.SetConfig("PARSE_CACHE_FILE", this->AutogenTarget.ParseCacheFile);
+ info.SetArray("HEADER_EXTENSIONS",
+ this->Makefile->GetCMakeInstance()->GetHeaderExtensions());
+ info.SetArrayArray(
+ "HEADERS", headers, [this](Json::Value& jval, MUFile const* muf) {
+ jval.resize(3u);
+ jval[0u] = muf->FullPath;
+ jval[1u] = cmStrCat(muf->MocIt ? 'M' : 'm', muf->UicIt ? 'U' : 'u');
+ jval[2u] = this->GetMocBuildPath(*muf);
+ });
+ info.SetArrayArray(
+ "SOURCES", sources, [](Json::Value& jval, MUFile const* muf) {
+ jval.resize(2u);
+ jval[0u] = muf->FullPath;
+ jval[1u] = cmStrCat(muf->MocIt ? 'M' : 'm', muf->UicIt ? 'U' : 'u');
+ });
+
+ // Write moc settings
+ if (this->Moc.Enabled) {
+ info.SetArray("MOC_SKIP", moc_skip);
+ info.SetConfigArray("MOC_DEFINITIONS", this->Moc.Defines);
+ info.SetConfigArray("MOC_INCLUDES", this->Moc.Includes);
+ info.SetArray("MOC_OPTIONS", this->Moc.Options);
+ info.SetBool("MOC_RELAXED_MODE", this->Moc.RelaxedMode);
+ info.SetBool("MOC_PATH_PREFIX", this->Moc.PathPrefix);
+ info.SetArray("MOC_MACRO_NAMES", this->Moc.MacroNames);
+ info.SetArrayArray(
+ "MOC_DEPEND_FILTERS", this->Moc.DependFilters,
+ [](Json::Value& jval, std::pair<std::string, std::string> const& pair) {
+ jval.resize(2u);
+ jval[0u] = pair.first;
+ jval[1u] = pair.second;
+ });
+ info.Set("MOC_COMPILATION_FILE", this->Moc.CompilationFile);
+ info.SetArray("MOC_PREDEFS_CMD", this->Moc.PredefsCmd);
+ info.SetConfig("MOC_PREDEFS_FILE", this->Moc.PredefsFile);
+ }
+
+ // Write uic settings
+ if (this->Uic.Enabled) {
+ // Add skipped .ui files
+ uic_skip.insert(this->Uic.SkipUi.begin(), this->Uic.SkipUi.end());
+
+ info.SetArray("UIC_SKIP", uic_skip);
+ info.SetArrayArray("UIC_UI_FILES", this->Uic.UiFiles,
+ [](Json::Value& jval, UicT::UiFileT const& uiFile) {
+ jval.resize(2u);
+ jval[0u] = uiFile.first;
+ InfoWriter::MakeStringArray(jval[1u], uiFile.second);
+ });
+ info.SetConfigArray("UIC_OPTIONS", this->Uic.Options);
+ info.SetArray("UIC_SEARCH_PATHS", this->Uic.SearchPaths);
+ }
+
+ info.Save(this->AutogenTarget.InfoFile);
+
+ return true;
+}
+
+bool cmQtAutoGenInitializer::SetupWriteRccInfo()
+{
+ for (Qrc const& qrc : this->Rcc.Qrcs) {
+ // Utility lambdas
+ auto MfDef = [this](std::string const& key) {
+ return this->Makefile->GetSafeDefinition(key);
+ };
+
+ InfoWriter info;
+
+ // General
+ info.SetBool("MULTI_CONFIG", this->MultiConfig);
+ info.SetUInt("VERBOSITY", this->Verbosity);
+
+ // Files
+ info.Set("LOCK_FILE", qrc.LockFile);
+ info.SetConfig("SETTINGS_FILE", qrc.SettingsFile);
+
+ // Directories
+ info.Set("CMAKE_SOURCE_DIR", MfDef("CMAKE_SOURCE_DIR"));
+ info.Set("CMAKE_BINARY_DIR", MfDef("CMAKE_BINARY_DIR"));
+ info.Set("CMAKE_CURRENT_SOURCE_DIR", MfDef("CMAKE_CURRENT_SOURCE_DIR"));
+ info.Set("CMAKE_CURRENT_BINARY_DIR", MfDef("CMAKE_CURRENT_BINARY_DIR"));
+ info.Set("BUILD_DIR", this->Dir.Build);
+ info.SetConfig("INCLUDE_DIR", this->Dir.Include);
+
+ // rcc executable
+ info.Set("RCC_EXECUTABLE", this->Rcc.Executable);
+ info.SetArray("RCC_LIST_OPTIONS",
+ this->Rcc.ExecutableFeatures->ListOptions);
+
+ // qrc file
+ info.Set("SOURCE", qrc.QrcFile);
+ info.Set("OUTPUT_CHECKSUM", qrc.QrcPathChecksum);
+ info.Set("OUTPUT_NAME", cmSystemTools::GetFilenameName(qrc.OutputFile));
+ info.SetArray("OPTIONS", qrc.Options);
+ info.SetArray("INPUTS", qrc.Resources);
+
+ info.Save(qrc.InfoFile);
+ }
+
+ return true;
+}
+
+cmSourceFile* cmQtAutoGenInitializer::RegisterGeneratedSource(
+ std::string const& filename)
+{
+ cmSourceFile* gFile = this->Makefile->GetOrCreateSource(filename, true);
+ gFile->SetProperty("GENERATED", "1");
+ gFile->SetProperty("SKIP_AUTOGEN", "1");
+ return gFile;
+}
+
+cmSourceFile* cmQtAutoGenInitializer::AddGeneratedSource(
+ std::string const& filename, GenVarsT const& genVars, bool prepend)
+{
+ // Register source at makefile
+ cmSourceFile* gFile = this->RegisterGeneratedSource(filename);
+ // Add source file to target
+ this->GenTarget->AddSource(filename, prepend);
+
+ // Add source file to source group
+ this->AddToSourceGroup(filename, genVars.GenNameUpper);
+
+ return gFile;
+}
+
+void cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
+ cm::string_view genNameUpper)
+{
+ cmSourceGroup* sourceGroup = nullptr;
+ // Acquire source group
+ {
+ std::string property;
+ std::string groupName;
+ {
+ // Prefer generator specific source group name
+ std::initializer_list<std::string> const props{
+ cmStrCat(genNameUpper, "_SOURCE_GROUP"), "AUTOGEN_SOURCE_GROUP"
+ };
+ for (std::string const& prop : props) {
+ const char* propName =
+ this->Makefile->GetState()->GetGlobalProperty(prop);
+ if ((propName != nullptr) && (*propName != '\0')) {
+ groupName = propName;
+ property = prop;
+ break;
+ }
+ }
+ }
+ // Generate a source group on demand
+ if (!groupName.empty()) {
+ sourceGroup = this->Makefile->GetOrCreateSourceGroup(groupName);
+ if (sourceGroup == nullptr) {
+ cmSystemTools::Error(
+ cmStrCat(genNameUpper, " error in ", property,
+ ": Could not find or create the source group ",
+ cmQtAutoGen::Quoted(groupName)));
+ }
+ }
+ }
+ if (sourceGroup != nullptr) {
+ sourceGroup->AddGroupFile(fileName);
+ }
+}
+
+void cmQtAutoGenInitializer::AddCleanFile(std::string const& fileName)
+{
+ this->GenTarget->Target->AppendProperty("ADDITIONAL_CLEAN_FILES",
+ fileName.c_str(), false);
+}
+
+void cmQtAutoGenInitializer::ConfigFileNames(ConfigString& configString,
+ cm::string_view prefix,
+ cm::string_view suffix)
+{
+ configString.Default = cmStrCat(prefix, suffix);
+ if (this->MultiConfig) {
+ for (auto const& cfg : this->ConfigsList) {
+ configString.Config[cfg] = cmStrCat(prefix, '_', cfg, suffix);
+ }
+ }
+}
+
+void cmQtAutoGenInitializer::ConfigFileClean(ConfigString& configString)
+{
+ this->AddCleanFile(configString.Default);
+ if (this->MultiConfig) {
+ for (auto const& pair : configString.Config) {
+ this->AddCleanFile(pair.second);
+ }
+ }
+}
+
+std::pair<cmQtAutoGen::IntegerVersion, unsigned int>
+cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target)
+{
+ // Converts a char ptr to an unsigned int value
+ auto toUInt = [](const char* const input) -> unsigned int {
+ unsigned long tmp = 0;
+ if (input != nullptr && cmStrToULong(input, &tmp)) {
+ return static_cast<unsigned int>(tmp);
+ }
+ return 0u;
+ };
+
+ // Initialize return value to a default
+ std::pair<IntegerVersion, unsigned int> res(
+ IntegerVersion(),
+ toUInt(target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION",
+ "")));
+
+ // Acquire known Qt versions
+ std::vector<cmQtAutoGen::IntegerVersion> knownQtVersions;
+ {
+ // Qt version variable prefixes
+ static std::initializer_list<
+ std::pair<cm::string_view, cm::string_view>> const keys{
+ { "Qt6Core_VERSION_MAJOR", "Qt6Core_VERSION_MINOR" },
+ { "Qt5Core_VERSION_MAJOR", "Qt5Core_VERSION_MINOR" },
+ { "QT_VERSION_MAJOR", "QT_VERSION_MINOR" },
+ };
+
+ knownQtVersions.reserve(keys.size() * 2);
+
+ // Adds a version to the result (nullptr safe)
+ auto addVersion = [&knownQtVersions, &toUInt](const char* major,
+ const char* minor) {
+ cmQtAutoGen::IntegerVersion ver(toUInt(major), toUInt(minor));
+ if (ver.Major != 0) {
+ knownQtVersions.emplace_back(ver);
+ }
+ };
+
+ // Read versions from variables
+ for (auto const& keyPair : keys) {
+ addVersion(target->Makefile->GetDefinition(std::string(keyPair.first)),
+ target->Makefile->GetDefinition(std::string(keyPair.second)));
+ }
+
+ // Read versions from directory properties
+ for (auto const& keyPair : keys) {
+ addVersion(target->Makefile->GetProperty(std::string(keyPair.first)),
+ target->Makefile->GetProperty(std::string(keyPair.second)));
+ }
+ }
+
+ // Evaluate known Qt versions
+ if (!knownQtVersions.empty()) {
+ if (res.second == 0) {
+ // No specific version was requested by the target:
+ // Use highest known Qt version.
+ res.first = knownQtVersions.at(0);
+ } else {
+ // Pick a version from the known versions:
+ for (auto it : knownQtVersions) {
+ if (it.Major == res.second) {
+ res.first = it;
+ break;
+ }
+ }
+ }
+ }
+ return res;
+}
+
+std::string cmQtAutoGenInitializer::GetMocBuildPath(MUFile const& muf)
+{
+ std::string res;
+ if (!muf.MocIt) {
+ return res;
+ }
+ {
+ std::string const basePath =
+ cmStrCat(this->PathCheckSum.getPart(muf.FullPath), "/moc_",
+ FileNameWithoutLastExtension(muf.FullPath));
+ std::string suffix;
+ constexpr std::size_t num_tries_max = 256;
+ for (std::size_t ii = 0; ii != num_tries_max; ++ii) {
+ res = cmStrCat(basePath, suffix, ".cpp");
+ if (this->Moc.EmittedBuildPaths.emplace(res).second) {
+ break;
+ }
+ // Compute new suffix
+ suffix = cmStrCat('_', ii + 1);
+ }
+ }
+ return res;
+}
+
+bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
+ const std::string& executable,
+ bool ignoreMissingTarget) const
+{
+ auto print_err = [this, &genVars](std::string const& err) {
+ cmSystemTools::Error(cmStrCat(genVars.GenNameUpper, " for target ",
+ this->GenTarget->GetName(), ": ", err));
+ };
+
+ // Custom executable
+ {
+ std::string const prop = cmStrCat(genVars.GenNameUpper, "_EXECUTABLE");
+ std::string const val = this->GenTarget->Target->GetSafeProperty(prop);
+ if (!val.empty()) {
+ // Evaluate generator expression
+ {
+ cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+ cmGeneratorExpression ge(lfbt);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(val);
+ genVars.Executable = cge->Evaluate(this->LocalGen, "");
+ }
+ if (genVars.Executable.empty() && !ignoreMissingTarget) {
+ print_err(prop + " evaluates to an empty value");
+ return false;
+ }
+
+ // Create empty compiler features.
+ genVars.ExecutableFeatures =
+ std::make_shared<cmQtAutoGen::CompilerFeatures>();
+ return true;
+ }
+ }
+
+ // Find executable target
+ {
+ // Find executable target name
+ cm::string_view prefix;
+ if (this->QtVersion.Major == 4) {
+ prefix = "Qt4::";
+ } else if (this->QtVersion.Major == 5) {
+ prefix = "Qt5::";
+ } else if (this->QtVersion.Major == 6) {
+ prefix = "Qt6::";
+ }
+ std::string const targetName = cmStrCat(prefix, executable);
+
+ // Find target
+ cmGeneratorTarget* genTarget =
+ this->LocalGen->FindGeneratorTargetToUse(targetName);
+ if (genTarget != nullptr) {
+ genVars.ExecutableTargetName = targetName;
+ genVars.ExecutableTarget = genTarget;
+ if (genTarget->IsImported()) {
+ genVars.Executable = genTarget->ImportedGetLocation("");
+ } else {
+ genVars.Executable = genTarget->GetLocation("");
+ }
+ } else {
+ if (ignoreMissingTarget) {
+ // Create empty compiler features.
+ genVars.ExecutableFeatures =
+ std::make_shared<cmQtAutoGen::CompilerFeatures>();
+ return true;
+ }
+ print_err(cmStrCat("Could not find ", executable, " executable target ",
+ targetName));
+ return false;
+ }
+ }
+
+ // Get executable features
+ {
+ std::string err;
+ genVars.ExecutableFeatures = this->GlobalInitializer->GetCompilerFeatures(
+ executable, genVars.Executable, err);
+ if (!genVars.ExecutableFeatures) {
+ print_err(err);
+ return false;
+ }
+ }
+
+ return true;
+}
diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h
new file mode 100644
index 000000000..d55259c5e
--- /dev/null
+++ b/Source/cmQtAutoGenInitializer.h
@@ -0,0 +1,248 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmQtAutoGenInitializer_h
+#define cmQtAutoGenInitializer_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <memory>
+#include <set>
+#include <string>
+#include <unordered_map>
+#include <unordered_set>
+#include <utility>
+#include <vector>
+
+#include <cm/string_view>
+
+#include "cmFilePathChecksum.h"
+#include "cmQtAutoGen.h"
+
+class cmGeneratorTarget;
+class cmGlobalGenerator;
+class cmLocalGenerator;
+class cmMakefile;
+class cmQtAutoGenGlobalInitializer;
+class cmSourceFile;
+class cmTarget;
+
+/** \class cmQtAutoGenerator
+ * \brief Initializes the QtAutoGen generators
+ */
+class cmQtAutoGenInitializer : public cmQtAutoGen
+{
+public:
+ /** String value with per configuration variants. */
+ class ConfigString
+ {
+ public:
+ std::string Default;
+ std::unordered_map<std::string, std::string> Config;
+ };
+
+ /** String values with per configuration variants. */
+ template <typename C>
+ class ConfigStrings
+ {
+ public:
+ C Default;
+ std::unordered_map<std::string, C> Config;
+ };
+
+ /** rcc job. */
+ class Qrc
+ {
+ public:
+ std::string LockFile;
+ std::string QrcFile;
+ std::string QrcName;
+ std::string QrcPathChecksum;
+ std::string InfoFile;
+ ConfigString SettingsFile;
+ std::string OutputFile;
+ bool Generated = false;
+ bool Unique = false;
+ std::vector<std::string> Options;
+ std::vector<std::string> Resources;
+ };
+
+ /** moc and/or uic file. */
+ struct MUFile
+ {
+ std::string FullPath;
+ cmSourceFile* SF = nullptr;
+ bool Generated = false;
+ bool SkipMoc = false;
+ bool SkipUic = false;
+ bool MocIt = false;
+ bool UicIt = false;
+ };
+ using MUFileHandle = std::unique_ptr<MUFile>;
+
+ /** Abstract moc/uic/rcc generator variables base class. */
+ struct GenVarsT
+ {
+ bool Enabled = false;
+ // Generator type/name
+ GenT Gen;
+ cm::string_view GenNameUpper;
+ // Executable
+ std::string ExecutableTargetName;
+ cmGeneratorTarget* ExecutableTarget = nullptr;
+ std::string Executable;
+ CompilerFeaturesHandle ExecutableFeatures;
+
+ GenVarsT(GenT gen)
+ : Gen(gen)
+ , GenNameUpper(cmQtAutoGen::GeneratorNameUpper(gen)){};
+ };
+
+public:
+ /** @return The detected Qt version and the required Qt major version. */
+ static std::pair<IntegerVersion, unsigned int> GetQtVersion(
+ cmGeneratorTarget const* genTarget);
+
+ cmQtAutoGenInitializer(cmQtAutoGenGlobalInitializer* globalInitializer,
+ cmGeneratorTarget* genTarget,
+ IntegerVersion const& qtVersion, bool mocEnabled,
+ bool uicEnabled, bool rccEnabled,
+ bool globalAutogenTarget, bool globalAutoRccTarget);
+
+ bool InitCustomTargets();
+ bool SetupCustomTargets();
+
+private:
+ /** If moc or uic is enabled, the autogen target will be generated. */
+ bool MocOrUicEnabled() const
+ {
+ return (this->Moc.Enabled || this->Uic.Enabled);
+ }
+
+ bool InitMoc();
+ bool InitUic();
+ bool InitRcc();
+
+ bool InitScanFiles();
+ bool InitAutogenTarget();
+ bool InitRccTargets();
+
+ bool SetupWriteAutogenInfo();
+ bool SetupWriteRccInfo();
+
+ cmSourceFile* RegisterGeneratedSource(std::string const& filename);
+ cmSourceFile* AddGeneratedSource(std::string const& filename,
+ GenVarsT const& genVars,
+ bool prepend = false);
+ void AddToSourceGroup(std::string const& fileName,
+ cm::string_view genNameUpper);
+ void AddCleanFile(std::string const& fileName);
+
+ void ConfigFileNames(ConfigString& configString, cm::string_view prefix,
+ cm::string_view suffix);
+ void ConfigFileClean(ConfigString& configString);
+
+ std::string GetMocBuildPath(MUFile const& muf);
+
+ bool GetQtExecutable(GenVarsT& genVars, const std::string& executable,
+ bool ignoreMissingTarget) const;
+
+private:
+ cmQtAutoGenGlobalInitializer* GlobalInitializer = nullptr;
+ cmGeneratorTarget* GenTarget = nullptr;
+ cmGlobalGenerator* GlobalGen = nullptr;
+ cmLocalGenerator* LocalGen = nullptr;
+ cmMakefile* Makefile = nullptr;
+ cmFilePathChecksum const PathCheckSum;
+
+ // -- Configuration
+ IntegerVersion QtVersion;
+ unsigned int Verbosity = 0;
+ bool MultiConfig = false;
+ bool CMP0071Accept = false;
+ bool CMP0071Warn = false;
+ std::string ConfigDefault;
+ std::vector<std::string> ConfigsList;
+ std::string TargetsFolder;
+
+ /** Common directories. */
+ struct
+ {
+ std::string Info;
+ std::string Build;
+ std::string Work;
+ ConfigString Include;
+ std::string IncludeGenExp;
+ } Dir;
+
+ /** Autogen target variables. */
+ struct
+ {
+ std::string Name;
+ bool GlobalTarget = false;
+ // Settings
+ unsigned int Parallel = 1;
+ // Configuration files
+ std::string InfoFile;
+ ConfigString SettingsFile;
+ ConfigString ParseCacheFile;
+ // Dependencies
+ bool DependOrigin = false;
+ std::set<std::string> DependFiles;
+ std::set<cmTarget*> DependTargets;
+ // Sources to process
+ std::unordered_map<cmSourceFile*, MUFileHandle> Headers;
+ std::unordered_map<cmSourceFile*, MUFileHandle> Sources;
+ std::vector<MUFile*> FilesGenerated;
+ } AutogenTarget;
+
+ /** moc variables. */
+ struct MocT : public GenVarsT
+ {
+ MocT()
+ : GenVarsT(GenT::MOC){};
+
+ bool RelaxedMode = false;
+ bool PathPrefix = false;
+ std::string CompilationFile;
+ // Compiler implicit pre defines
+ std::vector<std::string> PredefsCmd;
+ ConfigString PredefsFile;
+ // Defines
+ ConfigStrings<std::set<std::string>> Defines;
+ // Includes
+ ConfigStrings<std::vector<std::string>> Includes;
+ // Options
+ std::vector<std::string> Options;
+ // Filters
+ std::vector<std::string> MacroNames;
+ std::vector<std::pair<std::string, std::string>> DependFilters;
+ // Utility
+ std::unordered_set<std::string> EmittedBuildPaths;
+ } Moc;
+
+ /** uic variables. */
+ struct UicT : public GenVarsT
+ {
+ using UiFileT = std::pair<std::string, std::vector<std::string>>;
+
+ UicT()
+ : GenVarsT(GenT::UIC){};
+
+ std::set<std::string> SkipUi;
+ std::vector<UiFileT> UiFiles;
+ ConfigStrings<std::vector<std::string>> Options;
+ std::vector<std::string> SearchPaths;
+ } Uic;
+
+ /** rcc variables. */
+ struct RccT : public GenVarsT
+ {
+ RccT()
+ : GenVarsT(GenT::RCC){};
+
+ bool GlobalTarget = false;
+ std::vector<Qrc> Qrcs;
+ } Rcc;
+};
+
+#endif
diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx
new file mode 100644
index 000000000..da963052f
--- /dev/null
+++ b/Source/cmQtAutoGenerator.cxx
@@ -0,0 +1,492 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmQtAutoGenerator.h"
+
+#include "cmsys/FStream.hxx"
+
+#include "cm_jsoncpp_reader.h"
+
+#include "cmQtAutoGen.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+cmQtAutoGenerator::Logger::Logger()
+{
+ // Initialize logger
+ {
+ std::string verbose;
+ if (cmSystemTools::GetEnv("VERBOSE", verbose) && !verbose.empty()) {
+ unsigned long iVerbose = 0;
+ if (cmStrToULong(verbose, &iVerbose)) {
+ SetVerbosity(static_cast<unsigned int>(iVerbose));
+ } else {
+ // Non numeric verbosity
+ SetVerbose(cmIsOn(verbose));
+ }
+ }
+ }
+ {
+ std::string colorEnv;
+ cmSystemTools::GetEnv("COLOR", colorEnv);
+ if (!colorEnv.empty()) {
+ SetColorOutput(cmIsOn(colorEnv));
+ } else {
+ SetColorOutput(true);
+ }
+ }
+}
+
+cmQtAutoGenerator::Logger::~Logger() = default;
+
+void cmQtAutoGenerator::Logger::RaiseVerbosity(unsigned int value)
+{
+ if (this->Verbosity_ < value) {
+ this->Verbosity_ = value;
+ }
+}
+
+void cmQtAutoGenerator::Logger::SetColorOutput(bool value)
+{
+ ColorOutput_ = value;
+}
+
+std::string cmQtAutoGenerator::Logger::HeadLine(cm::string_view title)
+{
+ return cmStrCat(title, '\n', std::string(title.size(), '-'), '\n');
+}
+
+void cmQtAutoGenerator::Logger::Info(GenT genType,
+ cm::string_view message) const
+{
+ std::string msg = cmStrCat(GeneratorName(genType), ": ", message,
+ cmHasSuffix(message, '\n') ? "" : "\n");
+ {
+ std::lock_guard<std::mutex> lock(Mutex_);
+ cmSystemTools::Stdout(msg);
+ }
+}
+
+void cmQtAutoGenerator::Logger::Warning(GenT genType,
+ cm::string_view message) const
+{
+ std::string msg;
+ if (message.find('\n') == std::string::npos) {
+ // Single line message
+ msg = cmStrCat(GeneratorName(genType), " warning: ", message,
+ cmHasSuffix(message, '\n') ? "\n" : "\n\n");
+ } else {
+ // Multi line message
+ msg = cmStrCat(HeadLine(cmStrCat(GeneratorName(genType), " warning")),
+ message, cmHasSuffix(message, '\n') ? "\n" : "\n\n");
+ }
+ {
+ std::lock_guard<std::mutex> lock(Mutex_);
+ cmSystemTools::Stdout(msg);
+ }
+}
+
+void cmQtAutoGenerator::Logger::Error(GenT genType,
+ cm::string_view message) const
+{
+ std::string msg =
+ cmStrCat('\n', HeadLine(cmStrCat(GeneratorName(genType), " error")),
+ message, cmHasSuffix(message, '\n') ? "\n" : "\n\n");
+ {
+ std::lock_guard<std::mutex> lock(Mutex_);
+ cmSystemTools::Stderr(msg);
+ }
+}
+
+void cmQtAutoGenerator::Logger::ErrorCommand(
+ GenT genType, cm::string_view message,
+ std::vector<std::string> const& command, std::string const& output) const
+{
+ std::string msg = cmStrCat(
+ '\n', HeadLine(cmStrCat(GeneratorName(genType), " subprocess error")),
+ message, cmHasSuffix(message, '\n') ? "\n" : "\n\n");
+ msg += cmStrCat(HeadLine("Command"), QuotedCommand(command), "\n\n");
+ msg += cmStrCat(HeadLine("Output"), output,
+ cmHasSuffix(output, '\n') ? "\n" : "\n\n");
+ {
+ std::lock_guard<std::mutex> lock(Mutex_);
+ cmSystemTools::Stderr(msg);
+ }
+}
+
+bool cmQtAutoGenerator::MakeParentDirectory(std::string const& filename)
+{
+ bool success = true;
+ std::string const dirName = cmSystemTools::GetFilenamePath(filename);
+ if (!dirName.empty()) {
+ success = cmSystemTools::MakeDirectory(dirName);
+ }
+ return success;
+}
+
+bool cmQtAutoGenerator::FileRead(std::string& content,
+ std::string const& filename,
+ std::string* error)
+{
+ content.clear();
+ if (!cmSystemTools::FileExists(filename, true)) {
+ if (error != nullptr) {
+ *error = "Not a file.";
+ }
+ return false;
+ }
+
+ unsigned long const length = cmSystemTools::FileLength(filename);
+ cmsys::ifstream ifs(filename.c_str(), (std::ios::in | std::ios::binary));
+
+ // Use lambda to save destructor calls of ifs
+ return [&ifs, length, &content, error]() -> bool {
+ if (!ifs) {
+ if (error != nullptr) {
+ *error = "Opening the file for reading failed.";
+ }
+ return false;
+ }
+ content.reserve(length);
+ using IsIt = std::istreambuf_iterator<char>;
+ content.assign(IsIt{ ifs }, IsIt{});
+ if (!ifs) {
+ content.clear();
+ if (error != nullptr) {
+ *error = "Reading from the file failed.";
+ }
+ return false;
+ }
+ return true;
+ }();
+}
+
+bool cmQtAutoGenerator::FileWrite(std::string const& filename,
+ std::string const& content,
+ std::string* error)
+{
+ // Make sure the parent directory exists
+ if (!cmQtAutoGenerator::MakeParentDirectory(filename)) {
+ if (error != nullptr) {
+ *error = "Could not create parent directory.";
+ }
+ return false;
+ }
+ cmsys::ofstream ofs;
+ ofs.open(filename.c_str(),
+ (std::ios::out | std::ios::binary | std::ios::trunc));
+
+ // Use lambda to save destructor calls of ofs
+ return [&ofs, &content, error]() -> bool {
+ if (!ofs) {
+ if (error != nullptr) {
+ *error = "Opening file for writing failed.";
+ }
+ return false;
+ }
+ ofs << content;
+ if (!ofs.good()) {
+ if (error != nullptr) {
+ *error = "File writing failed.";
+ }
+ return false;
+ }
+ return true;
+ }();
+}
+
+bool cmQtAutoGenerator::FileDiffers(std::string const& filename,
+ std::string const& content)
+{
+ bool differs = true;
+ std::string oldContents;
+ if (FileRead(oldContents, filename) && (oldContents == content)) {
+ differs = false;
+ }
+ return differs;
+}
+
+cmQtAutoGenerator::cmQtAutoGenerator(GenT genType)
+ : GenType_(genType)
+{
+}
+
+cmQtAutoGenerator::~cmQtAutoGenerator() = default;
+
+bool cmQtAutoGenerator::InfoT::Read(std::istream& istr)
+{
+ try {
+ istr >> Json_;
+ } catch (...) {
+ return false;
+ }
+ return true;
+}
+
+bool cmQtAutoGenerator::InfoT::GetJsonArray(std::vector<std::string>& list,
+ Json::Value const& jval)
+{
+ Json::ArrayIndex const arraySize = jval.size();
+ if (arraySize == 0) {
+ return false;
+ }
+
+ bool picked = false;
+ list.reserve(list.size() + arraySize);
+ for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) {
+ Json::Value const& ival = jval[ii];
+ if (ival.isString()) {
+ list.emplace_back(ival.asString());
+ picked = true;
+ }
+ }
+ return picked;
+}
+
+bool cmQtAutoGenerator::InfoT::GetJsonArray(
+ std::unordered_set<std::string>& list, Json::Value const& jval)
+{
+ Json::ArrayIndex const arraySize = jval.size();
+ if (arraySize == 0) {
+ return false;
+ }
+
+ bool picked = false;
+ list.reserve(list.size() + arraySize);
+ for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) {
+ Json::Value const& ival = jval[ii];
+ if (ival.isString()) {
+ list.emplace(ival.asString());
+ picked = true;
+ }
+ }
+ return picked;
+}
+
+std::string cmQtAutoGenerator::InfoT::ConfigKey(cm::string_view key) const
+{
+ return cmStrCat(key, '_', Gen_.InfoConfig());
+}
+
+bool cmQtAutoGenerator::InfoT::GetString(std::string const& key,
+ std::string& value,
+ bool required) const
+{
+ Json::Value const& jval = Json_[key];
+ if (!jval.isString()) {
+ if (!jval.isNull() || required) {
+ return LogError(cmStrCat(key, " is not a string."));
+ }
+ } else {
+ value = jval.asString();
+ if (value.empty() && required) {
+ return LogError(cmStrCat(key, " is empty."));
+ }
+ }
+ return true;
+}
+
+bool cmQtAutoGenerator::InfoT::GetStringConfig(std::string const& key,
+ std::string& value,
+ bool required) const
+{
+ { // Try config
+ std::string const configKey = ConfigKey(key);
+ Json::Value const& jval = Json_[configKey];
+ if (!jval.isNull()) {
+ if (!jval.isString()) {
+ return LogError(cmStrCat(configKey, " is not a string."));
+ }
+ value = jval.asString();
+ if (required && value.empty()) {
+ return LogError(cmStrCat(configKey, " is empty."));
+ }
+ return true;
+ }
+ }
+ // Try plain
+ return GetString(key, value, required);
+}
+
+bool cmQtAutoGenerator::InfoT::GetBool(std::string const& key, bool& value,
+ bool required) const
+{
+ Json::Value const& jval = Json_[key];
+ if (jval.isBool()) {
+ value = jval.asBool();
+ } else {
+ if (!jval.isNull() || required) {
+ return LogError(cmStrCat(key, " is not a boolean."));
+ }
+ }
+ return true;
+}
+
+bool cmQtAutoGenerator::InfoT::GetUInt(std::string const& key,
+ unsigned int& value,
+ bool required) const
+{
+ Json::Value const& jval = Json_[key];
+ if (jval.isUInt()) {
+ value = jval.asUInt();
+ } else {
+ if (!jval.isNull() || required) {
+ return LogError(cmStrCat(key, " is not an unsigned integer."));
+ }
+ }
+ return true;
+}
+
+bool cmQtAutoGenerator::InfoT::GetArray(std::string const& key,
+ std::vector<std::string>& list,
+ bool required) const
+{
+ Json::Value const& jval = Json_[key];
+ if (!jval.isArray()) {
+ if (!jval.isNull() || required) {
+ return LogError(cmStrCat(key, " is not an array."));
+ }
+ }
+ return GetJsonArray(list, jval) || !required;
+}
+
+bool cmQtAutoGenerator::InfoT::GetArray(std::string const& key,
+ std::unordered_set<std::string>& list,
+ bool required) const
+{
+ Json::Value const& jval = Json_[key];
+ if (!jval.isArray()) {
+ if (!jval.isNull() || required) {
+ return LogError(cmStrCat(key, " is not an array."));
+ }
+ }
+ return GetJsonArray(list, jval) || !required;
+}
+
+bool cmQtAutoGenerator::InfoT::GetArrayConfig(std::string const& key,
+ std::vector<std::string>& list,
+ bool required) const
+{
+ { // Try config
+ std::string const configKey = ConfigKey(key);
+ Json::Value const& jval = Json_[configKey];
+ if (!jval.isNull()) {
+ if (!jval.isArray()) {
+ return LogError(cmStrCat(configKey, " is not an array string."));
+ }
+ if (!GetJsonArray(list, jval) && required) {
+ return LogError(cmStrCat(configKey, " is empty."));
+ }
+ return true;
+ }
+ }
+ // Try plain
+ return GetArray(key, list, required);
+}
+
+bool cmQtAutoGenerator::InfoT::LogError(GenT genType,
+ cm::string_view message) const
+{
+ Gen_.Log().Error(genType,
+ cmStrCat("Info error in info file\n",
+ Quoted(Gen_.InfoFile()), ":\n", message));
+ return false;
+}
+
+bool cmQtAutoGenerator::InfoT::LogError(cm::string_view message) const
+{
+ return LogError(Gen_.GenType_, message);
+}
+
+std::string cmQtAutoGenerator::SettingsFind(cm::string_view content,
+ cm::string_view key)
+{
+ cm::string_view res;
+ std::string const prefix = cmStrCat(key, ':');
+ cm::string_view::size_type pos = content.find(prefix);
+ if (pos != cm::string_view::npos) {
+ pos += prefix.size();
+ if (pos < content.size()) {
+ cm::string_view::size_type posE = content.find('\n', pos);
+ if ((posE != cm::string_view::npos) && (posE != pos)) {
+ res = content.substr(pos, posE - pos);
+ }
+ }
+ }
+ return std::string(res);
+}
+
+std::string cmQtAutoGenerator::MessagePath(cm::string_view path) const
+{
+ std::string res;
+ if (cmHasPrefix(path, ProjectDirs().Source)) {
+ res = cmStrCat("SRC:", path.substr(ProjectDirs().Source.size()));
+ } else if (cmHasPrefix(path, ProjectDirs().Binary)) {
+ res = cmStrCat("BIN:", path.substr(ProjectDirs().Binary.size()));
+ } else {
+ res = std::string(path);
+ }
+ return cmQtAutoGen::Quoted(res);
+}
+
+bool cmQtAutoGenerator::Run(cm::string_view infoFile, cm::string_view config)
+{
+ // Info config
+ InfoConfig_ = std::string(config);
+
+ // Info file
+ InfoFile_ = std::string(infoFile);
+ cmSystemTools::CollapseFullPath(InfoFile_);
+ InfoDir_ = cmSystemTools::GetFilenamePath(InfoFile_);
+
+ // Load info file time
+ if (!InfoFileTime_.Load(InfoFile_)) {
+ cmSystemTools::Stderr(cmStrCat("AutoGen: The info file ",
+ Quoted(InfoFile_), " is not readable\n"));
+ return false;
+ }
+
+ {
+ InfoT info(*this);
+
+ // Read info file
+ {
+ cmsys::ifstream ifs(InfoFile_.c_str(),
+ (std::ios::in | std::ios::binary));
+ if (!ifs) {
+ Log().Error(
+ GenType_,
+ cmStrCat("Could not to open info file ", Quoted(InfoFile_)));
+ return false;
+ }
+ if (!info.Read(ifs)) {
+ Log().Error(GenType_,
+ cmStrCat("Could not read info file ", Quoted(InfoFile_)));
+ return false;
+ }
+ }
+
+ // -- Read common info settings
+ {
+ unsigned int verbosity = 0;
+ // Info: setup project directories
+ if (!info.GetUInt("VERBOSITY", verbosity, false) ||
+ !info.GetString("CMAKE_SOURCE_DIR", ProjectDirs_.Source, true) ||
+ !info.GetString("CMAKE_BINARY_DIR", ProjectDirs_.Binary, true) ||
+ !info.GetString("CMAKE_CURRENT_SOURCE_DIR",
+ ProjectDirs_.CurrentSource, true) ||
+ !info.GetString("CMAKE_CURRENT_BINARY_DIR",
+ ProjectDirs_.CurrentBinary, true)) {
+ return false;
+ }
+ Logger_.RaiseVerbosity(verbosity);
+ }
+
+ // -- Call virtual init from info method.
+ if (!this->InitFromInfo(info)) {
+ return false;
+ }
+ }
+
+ // Call virtual process method.
+ return this->Process();
+}
diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h
new file mode 100644
index 000000000..bbe6dd015
--- /dev/null
+++ b/Source/cmQtAutoGenerator.h
@@ -0,0 +1,181 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmQtAutoGenerator_h
+#define cmQtAutoGenerator_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <istream>
+#include <mutex>
+#include <string>
+#include <unordered_set>
+#include <vector>
+
+#include <cm/string_view>
+
+#include "cm_jsoncpp_value.h"
+
+#include "cmFileTime.h"
+#include "cmQtAutoGen.h"
+
+/** \class cmQtAutoGenerator
+ * \brief Base class for QtAutoGen generators
+ */
+class cmQtAutoGenerator : public cmQtAutoGen
+{
+public:
+ // -- Types
+
+ /** Thread safe logger. */
+ class Logger
+ {
+ public:
+ // -- Construction
+ Logger();
+ ~Logger();
+ // -- Verbosity
+ unsigned int Verbosity() const { return this->Verbosity_; }
+ void SetVerbosity(unsigned int value) { this->Verbosity_ = value; }
+ void RaiseVerbosity(unsigned int value);
+ bool Verbose() const { return (this->Verbosity_ != 0); }
+ void SetVerbose(bool value) { this->Verbosity_ = value ? 1 : 0; }
+ // -- Color output
+ bool ColorOutput() const { return this->ColorOutput_; }
+ void SetColorOutput(bool value);
+ // -- Log info
+ void Info(GenT genType, cm::string_view message) const;
+ // -- Log warning
+ void Warning(GenT genType, cm::string_view message) const;
+ // -- Log error
+ void Error(GenT genType, cm::string_view message) const;
+ void ErrorCommand(GenT genType, cm::string_view message,
+ std::vector<std::string> const& command,
+ std::string const& output) const;
+
+ private:
+ static std::string HeadLine(cm::string_view title);
+
+ private:
+ mutable std::mutex Mutex_;
+ unsigned int Verbosity_ = 0;
+ bool ColorOutput_ = false;
+ };
+
+ /** Project directories. */
+ struct ProjectDirsT
+ {
+ std::string Source;
+ std::string Binary;
+ std::string CurrentSource;
+ std::string CurrentBinary;
+ };
+
+ // -- File system methods
+ static bool MakeParentDirectory(std::string const& filename);
+ static bool FileRead(std::string& content, std::string const& filename,
+ std::string* error = nullptr);
+ static bool FileWrite(std::string const& filename,
+ std::string const& content,
+ std::string* error = nullptr);
+ static bool FileDiffers(std::string const& filename,
+ std::string const& content);
+
+public:
+ // -- Constructors
+ cmQtAutoGenerator(GenT genType);
+ virtual ~cmQtAutoGenerator();
+
+ cmQtAutoGenerator(cmQtAutoGenerator const&) = delete;
+ cmQtAutoGenerator& operator=(cmQtAutoGenerator const&) = delete;
+
+ // -- Info options
+ std::string const& InfoFile() const { return InfoFile_; }
+ std::string const& InfoDir() const { return InfoDir_; }
+ cmFileTime const& InfoFileTime() const { return InfoFileTime_; }
+ std::string const& InfoConfig() const { return InfoConfig_; }
+
+ // -- Info file parsing
+ /** Info file reader class. */
+ class InfoT
+ {
+ public:
+ InfoT(cmQtAutoGenerator& gen)
+ : Gen_(gen)
+ {
+ }
+
+ /** Read json data from a stream. */
+ bool Read(std::istream& istr);
+
+ /** Returns false if the JSON value isn't a string. */
+ bool GetString(std::string const& key, std::string& value,
+ bool required) const;
+ bool GetStringConfig(std::string const& key, std::string& value,
+ bool required) const;
+ bool GetBool(std::string const& key, bool& value, bool required) const;
+ bool GetUInt(std::string const& key, unsigned int& value,
+ bool required) const;
+ /** Returns false if the JSON value isn't an array. */
+ bool GetArray(std::string const& key, std::vector<std::string>& list,
+ bool required) const;
+ bool GetArray(std::string const& key,
+ std::unordered_set<std::string>& list, bool required) const;
+ bool GetArrayConfig(std::string const& key, std::vector<std::string>& list,
+ bool required) const;
+
+ Json::Value const& GetValue(std::string const& key) const
+ {
+ return Json_[key];
+ }
+
+ /** Returns true if strings were appended to the list. */
+ static bool GetJsonArray(std::vector<std::string>& list,
+ Json::Value const& jval);
+ /** Returns true if strings were found in the JSON array. */
+ static bool GetJsonArray(std::unordered_set<std::string>& list,
+ Json::Value const& jval);
+
+ bool LogError(GenT genType, cm::string_view message) const;
+ bool LogError(cm::string_view message) const;
+
+ private:
+ std::string ConfigKey(cm::string_view key) const;
+
+ private:
+ Json::Value Json_;
+ cmQtAutoGenerator& Gen_;
+ };
+
+ // -- Settings file
+ static std::string SettingsFind(cm::string_view content,
+ cm::string_view key);
+
+ // -- Directories
+ ProjectDirsT const& ProjectDirs() const { return ProjectDirs_; }
+ std::string MessagePath(cm::string_view path) const;
+
+ // -- Run
+ bool Run(cm::string_view infoFile, cm::string_view config);
+
+protected:
+ // -- Abstract processing interface
+ virtual bool InitFromInfo(InfoT const& info) = 0;
+ virtual bool Process() = 0;
+ // - Utility classes
+ Logger const& Log() const { return Logger_; }
+
+private:
+ // -- Generator type
+ GenT GenType_;
+ // -- Logging
+ Logger Logger_;
+ // -- Info file
+ std::string InfoFile_;
+ std::string InfoDir_;
+ cmFileTime InfoFileTime_;
+ std::string InfoConfig_;
+ // -- Directories
+ ProjectDirsT ProjectDirs_;
+};
+
+#endif
diff --git a/Source/cmQtAutoGeneratorCommon.cxx b/Source/cmQtAutoGeneratorCommon.cxx
deleted file mode 100644
index 3e1b58caa..000000000
--- a/Source/cmQtAutoGeneratorCommon.cxx
+++ /dev/null
@@ -1,216 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmQtAutoGeneratorCommon.h"
-#include "cmAlgorithms.h"
-#include "cmSystemTools.h"
-
-#include "cmsys/FStream.hxx"
-#include "cmsys/RegularExpression.hxx"
-
-#include <sstream>
-#include <stddef.h>
-
-// - Static functions
-
-static std::string utilStripCR(std::string const& line)
-{
- // Strip CR characters rcc may have printed (possibly more than one!).
- std::string::size_type cr = line.find('\r');
- if (cr != std::string::npos) {
- return line.substr(0, cr);
- }
- return line;
-}
-
-/// @brief Reads the resource files list from from a .qrc file - Qt4 version
-/// @return True if the .qrc file was successfully parsed
-static bool RccListInputsQt4(const std::string& fileName,
- std::vector<std::string>& files,
- std::string* errorMessage)
-{
- bool allGood = true;
- // Read qrc file content into string
- std::string qrcContents;
- {
- cmsys::ifstream ifs(fileName.c_str());
- if (ifs) {
- std::ostringstream osst;
- osst << ifs.rdbuf();
- qrcContents = osst.str();
- } else {
- if (errorMessage != CM_NULLPTR) {
- std::ostringstream ost;
- ost << "AutoRcc: Error: Rcc file not readable:\n"
- << cmQtAutoGeneratorCommon::Quoted(fileName) << "\n";
- *errorMessage = ost.str();
- }
- allGood = false;
- }
- }
- if (allGood) {
- // qrc file directory
- std::string qrcDir(cmsys::SystemTools::GetFilenamePath(fileName));
- if (!qrcDir.empty()) {
- qrcDir += '/';
- }
-
- cmsys::RegularExpression fileMatchRegex("(<file[^<]+)");
- cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)");
-
- size_t offset = 0;
- while (fileMatchRegex.find(qrcContents.c_str() + offset)) {
- std::string qrcEntry = fileMatchRegex.match(1);
- offset += qrcEntry.size();
- {
- fileReplaceRegex.find(qrcEntry);
- std::string tag = fileReplaceRegex.match(1);
- qrcEntry = qrcEntry.substr(tag.size());
- }
- if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str())) {
- qrcEntry = qrcDir + qrcEntry;
- }
- files.push_back(qrcEntry);
- }
- }
- return allGood;
-}
-
-/// @brief Reads the resource files list from from a .qrc file - Qt5 version
-/// @return True if the .qrc file was successfully parsed
-static bool RccListInputsQt5(const std::string& rccCommand,
- const std::string& fileName,
- std::vector<std::string>& files,
- std::string* errorMessage)
-{
- if (rccCommand.empty()) {
- cmSystemTools::Error("AutoRcc: Error: rcc executable not available\n");
- return false;
- }
-
- // Read rcc features
- bool hasDashDashList = false;
- {
- std::vector<std::string> command;
- command.push_back(rccCommand);
- command.push_back("--help");
- std::string rccStdOut;
- std::string rccStdErr;
- int retVal = 0;
- bool result =
- cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal,
- CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
- if (result && retVal == 0 &&
- rccStdOut.find("--list") != std::string::npos) {
- hasDashDashList = true;
- }
- }
-
- // Run rcc list command
- bool result = false;
- int retVal = 0;
- std::string rccStdOut;
- std::string rccStdErr;
- {
- std::vector<std::string> command;
- command.push_back(rccCommand);
- command.push_back(hasDashDashList ? "--list" : "-list");
- command.push_back(fileName);
- result =
- cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal,
- CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
- }
- if (!result || retVal) {
- if (errorMessage != CM_NULLPTR) {
- std::ostringstream ost;
- ost << "AutoRcc: Error: Rcc list process for " << fileName
- << " failed:\n"
- << rccStdOut << "\n"
- << rccStdErr << "\n";
- *errorMessage = ost.str();
- }
- return false;
- }
-
- // Parse rcc std output
- {
- std::istringstream ostr(rccStdOut);
- std::string oline;
- while (std::getline(ostr, oline)) {
- oline = utilStripCR(oline);
- if (!oline.empty()) {
- files.push_back(oline);
- }
- }
- }
- // Parse rcc error output
- {
- std::istringstream estr(rccStdErr);
- std::string eline;
- while (std::getline(estr, eline)) {
- eline = utilStripCR(eline);
- if (cmHasLiteralPrefix(eline, "RCC: Error in")) {
- static std::string searchString = "Cannot find file '";
-
- std::string::size_type pos = eline.find(searchString);
- if (pos == std::string::npos) {
- if (errorMessage != CM_NULLPTR) {
- std::ostringstream ost;
- ost << "AutoRcc: Error: Rcc lists unparsable output:\n"
- << cmQtAutoGeneratorCommon::Quoted(eline) << "\n";
- *errorMessage = ost.str();
- }
- return false;
- }
- pos += searchString.length();
- std::string::size_type sz = eline.size() - pos - 1;
- files.push_back(eline.substr(pos, sz));
- }
- }
- }
-
- return true;
-}
-
-// - Class definitions
-
-const char* cmQtAutoGeneratorCommon::listSep = "@LSEP@";
-
-std::string cmQtAutoGeneratorCommon::Quoted(const std::string& text)
-{
- static const char* rep[18] = { "\\", "\\\\", "\"", "\\\"", "\a", "\\a",
- "\b", "\\b", "\f", "\\f", "\n", "\\n",
- "\r", "\\r", "\t", "\\t", "\v", "\\v" };
-
- std::string res = text;
- for (const char* const* it = cmArrayBegin(rep); it != cmArrayEnd(rep);
- it += 2) {
- cmSystemTools::ReplaceString(res, *it, *(it + 1));
- }
- res = '"' + res;
- res += '"';
- return res;
-}
-
-bool cmQtAutoGeneratorCommon::RccListInputs(const std::string& qtMajorVersion,
- const std::string& rccCommand,
- const std::string& fileName,
- std::vector<std::string>& files,
- std::string* errorMessage)
-{
- bool allGood = false;
- if (cmsys::SystemTools::FileExists(fileName.c_str())) {
- if (qtMajorVersion == "4") {
- allGood = RccListInputsQt4(fileName, files, errorMessage);
- } else {
- allGood = RccListInputsQt5(rccCommand, fileName, files, errorMessage);
- }
- } else {
- if (errorMessage != CM_NULLPTR) {
- std::ostringstream ost;
- ost << "AutoRcc: Error: Rcc file does not exist:\n"
- << cmQtAutoGeneratorCommon::Quoted(fileName) << "\n";
- *errorMessage = ost.str();
- }
- }
- return allGood;
-}
diff --git a/Source/cmQtAutoGeneratorCommon.h b/Source/cmQtAutoGeneratorCommon.h
deleted file mode 100644
index a131baf20..000000000
--- a/Source/cmQtAutoGeneratorCommon.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmQtAutoGeneratorCommon_h
-#define cmQtAutoGeneratorCommon_h
-
-#include "cmConfigure.h"
-
-#include <string>
-#include <vector>
-
-class cmQtAutoGeneratorCommon
-{
- // - Types and statics
-public:
- static const char* listSep;
-
- enum GeneratorType
- {
- MOC,
- UIC,
- RCC
- };
-
-public:
- /// @brief Returns a the string escaped and enclosed in quotes
- ///
- static std::string Quoted(const std::string& text);
-
- /// @brief Reads the resource files list from from a .qrc file
- /// @arg fileName Must be the absolute path of the .qrc file
- /// @return True if the rcc file was successfully parsed
- static bool RccListInputs(const std::string& qtMajorVersion,
- const std::string& rccCommand,
- const std::string& fileName,
- std::vector<std::string>& files,
- std::string* errorMessage = CM_NULLPTR);
-};
-
-#endif
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
deleted file mode 100644
index 3e3be54d1..000000000
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ /dev/null
@@ -1,1131 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmQtAutoGeneratorInitializer.h"
-#include "cmQtAutoGeneratorCommon.h"
-
-#include "cmAlgorithms.h"
-#include "cmCustomCommandLines.h"
-#include "cmFilePathChecksum.h"
-#include "cmGeneratorTarget.h"
-#include "cmGlobalGenerator.h"
-#include "cmLocalGenerator.h"
-#include "cmMakefile.h"
-#include "cmOutputConverter.h"
-#include "cmSourceFile.h"
-#include "cmSourceGroup.h"
-#include "cmState.h"
-#include "cmSystemTools.h"
-#include "cmTarget.h"
-#include "cm_sys_stat.h"
-#include "cmake.h"
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#include "cmGlobalVisualStudioGenerator.h"
-#endif
-
-#include "cmConfigure.h"
-#include "cmsys/FStream.hxx"
-#include <algorithm>
-#include <map>
-#include <set>
-#include <string>
-#include <utility>
-#include <vector>
-
-static void utilCopyTargetProperty(cmTarget* destinationTarget,
- cmTarget* sourceTarget,
- const std::string& propertyName)
-{
- const char* propertyValue = sourceTarget->GetProperty(propertyName);
- if (propertyValue) {
- destinationTarget->SetProperty(propertyName, propertyValue);
- }
-}
-
-inline static bool PropertyEnabled(cmSourceFile* sourceFile, const char* key)
-{
- return cmSystemTools::IsOn(sourceFile->GetPropertyForUser(key));
-}
-
-static std::string GetSafeProperty(cmGeneratorTarget const* target,
- const char* key)
-{
- const char* tmp = target->GetProperty(key);
- return std::string((tmp != CM_NULLPTR) ? tmp : "");
-}
-
-static std::string GetAutogenTargetName(cmGeneratorTarget const* target)
-{
- std::string autogenTargetName = target->GetName();
- autogenTargetName += "_autogen";
- return autogenTargetName;
-}
-
-static std::string GetAutogenTargetFilesDir(cmGeneratorTarget const* target)
-{
- cmMakefile* makefile = target->Target->GetMakefile();
- std::string targetDir = makefile->GetCurrentBinaryDirectory();
- targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
- targetDir += "/";
- targetDir += GetAutogenTargetName(target);
- targetDir += ".dir";
- return targetDir;
-}
-
-static std::string GetAutogenTargetBuildDir(cmGeneratorTarget const* target)
-{
- std::string targetDir = GetSafeProperty(target, "AUTOGEN_BUILD_DIR");
- if (targetDir.empty()) {
- cmMakefile* makefile = target->Target->GetMakefile();
- targetDir = makefile->GetCurrentBinaryDirectory();
- targetDir += "/";
- targetDir += GetAutogenTargetName(target);
- }
- return targetDir;
-}
-
-static std::string GetQtMajorVersion(cmGeneratorTarget const* target)
-{
- cmMakefile* makefile = target->Target->GetMakefile();
- std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
- if (qtMajorVersion.empty()) {
- qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
- }
- const char* targetQtVersion =
- target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "");
- if (targetQtVersion != CM_NULLPTR) {
- qtMajorVersion = targetQtVersion;
- }
- return qtMajorVersion;
-}
-
-static std::string GetQtMinorVersion(cmGeneratorTarget const* target,
- const std::string& qtMajorVersion)
-{
- cmMakefile* makefile = target->Target->GetMakefile();
- std::string qtMinorVersion;
- if (qtMajorVersion == "5") {
- qtMinorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MINOR");
- }
- if (qtMinorVersion.empty()) {
- qtMinorVersion = makefile->GetSafeDefinition("QT_VERSION_MINOR");
- }
-
- const char* targetQtVersion =
- target->GetLinkInterfaceDependentStringProperty("QT_MINOR_VERSION", "");
- if (targetQtVersion != CM_NULLPTR) {
- qtMinorVersion = targetQtVersion;
- }
- return qtMinorVersion;
-}
-
-static bool QtVersionGreaterOrEqual(const std::string& major,
- const std::string& minor,
- unsigned long requestMajor,
- unsigned long requestMinor)
-{
- unsigned long majorUL(0);
- unsigned long minorUL(0);
- if (cmSystemTools::StringToULong(major.c_str(), &majorUL) &&
- cmSystemTools::StringToULong(minor.c_str(), &minorUL)) {
- return (majorUL > requestMajor) ||
- (majorUL == requestMajor && minorUL >= requestMinor);
- }
- return false;
-}
-
-static void GetCompileDefinitionsAndDirectories(
- cmGeneratorTarget const* target, const std::string& config,
- std::string& incs, std::string& defs)
-{
- cmLocalGenerator* localGen = target->GetLocalGenerator();
- {
- std::vector<std::string> includeDirs;
- // Get the include dirs for this target, without stripping the implicit
- // include dirs off, see
- // https://gitlab.kitware.com/cmake/cmake/issues/13667
- localGen->GetIncludeDirectories(includeDirs, target, "CXX", config, false);
- incs = cmJoin(includeDirs, ";");
- }
- {
- std::set<std::string> defines;
- localGen->AddCompileDefinitions(defines, target, config, "CXX");
- defs += cmJoin(defines, ";");
- }
-}
-
-static bool IsMultiConfig(cmGlobalGenerator* globalGen)
-{
- // FIXME: Xcode does not support per-config sources, yet.
- // (EXCLUDED_SOURCE_FILE_NAMES)
- // Treat it as a single configuration generator meanwhile.
- if (globalGen->GetName().find("Xcode") != std::string::npos) {
- return false;
- }
- // FIXME: Visual Studio does not fully support per-config sources yet.
- if (globalGen->GetName().find("Visual Studio") != std::string::npos) {
- return false;
- }
- return globalGen->IsMultiConfig();
-}
-
-static std::vector<std::string> GetConfigurations(
- cmMakefile* makefile, std::string* config = CM_NULLPTR)
-{
- std::vector<std::string> configs;
- {
- std::string cfg = makefile->GetConfigurations(configs);
- if (config != CM_NULLPTR) {
- *config = cfg;
- }
- }
- // Add empty configuration on demand
- if (configs.empty()) {
- configs.push_back("");
- }
- return configs;
-}
-
-static std::vector<std::string> GetConfigurationSuffixes(cmMakefile* makefile)
-{
- std::vector<std::string> suffixes;
- if (IsMultiConfig(makefile->GetGlobalGenerator())) {
- makefile->GetConfigurations(suffixes);
- for (std::vector<std::string>::iterator it = suffixes.begin();
- it != suffixes.end(); ++it) {
- it->insert(0, "_");
- }
- }
- if (suffixes.empty()) {
- suffixes.push_back("");
- }
- return suffixes;
-}
-
-static void AddDefinitionEscaped(cmMakefile* makefile, const char* key,
- const std::string& value)
-{
- makefile->AddDefinition(key,
- cmOutputConverter::EscapeForCMake(value).c_str());
-}
-
-static void AddDefinitionEscaped(cmMakefile* makefile, const char* key,
- const std::vector<std::string>& values)
-{
- makefile->AddDefinition(
- key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str());
-}
-
-static bool AddToSourceGroup(cmMakefile* makefile, const std::string& fileName,
- cmQtAutoGeneratorCommon::GeneratorType genType)
-{
- cmSourceGroup* sourceGroup = CM_NULLPTR;
- // Acquire source group
- {
- const char* groupName = CM_NULLPTR;
- // Use generator specific group name
- switch (genType) {
- case cmQtAutoGeneratorCommon::MOC:
- groupName =
- makefile->GetState()->GetGlobalProperty("AUTOMOC_SOURCE_GROUP");
- break;
- case cmQtAutoGeneratorCommon::RCC:
- groupName =
- makefile->GetState()->GetGlobalProperty("AUTORCC_SOURCE_GROUP");
- break;
- default:
- break;
- }
- // Use default group name on demand
- if ((groupName == CM_NULLPTR) || (*groupName == 0)) {
- groupName =
- makefile->GetState()->GetGlobalProperty("AUTOGEN_SOURCE_GROUP");
- }
- // Generate a source group on demand
- if ((groupName != CM_NULLPTR) && (*groupName != 0)) {
- {
- const char* delimiter =
- makefile->GetDefinition("SOURCE_GROUP_DELIMITER");
- if (delimiter == CM_NULLPTR) {
- delimiter = "\\";
- }
- std::vector<std::string> folders =
- cmSystemTools::tokenize(groupName, delimiter);
- sourceGroup = makefile->GetSourceGroup(folders);
- if (sourceGroup == CM_NULLPTR) {
- makefile->AddSourceGroup(folders);
- sourceGroup = makefile->GetSourceGroup(folders);
- }
- }
- if (sourceGroup == CM_NULLPTR) {
- cmSystemTools::Error(
- "Autogen: Could not create or find source group: ",
- cmQtAutoGeneratorCommon::Quoted(groupName).c_str());
- return false;
- }
- }
- }
- if (sourceGroup != CM_NULLPTR) {
- sourceGroup->AddGroupFile(fileName);
- }
- return true;
-}
-
-static void AddGeneratedSource(cmMakefile* makefile,
- const std::string& filename,
- cmQtAutoGeneratorCommon::GeneratorType genType)
-{
- cmSourceFile* gFile = makefile->GetOrCreateSource(filename, true);
- gFile->SetProperty("GENERATED", "1");
- gFile->SetProperty("SKIP_AUTOGEN", "On");
-
- AddToSourceGroup(makefile, filename, genType);
-}
-
-static void AcquireScanFiles(cmGeneratorTarget const* target,
- std::vector<std::string>& mocUicSources,
- std::vector<std::string>& mocUicHeaders,
- std::vector<std::string>& mocSkipList,
- std::vector<std::string>& uicSkipList)
-{
- const bool mocTarget = target->GetPropertyAsBool("AUTOMOC");
- const bool uicTarget = target->GetPropertyAsBool("AUTOUIC");
-
- std::vector<cmSourceFile*> srcFiles;
- target->GetConfigCommonSourceFiles(srcFiles);
- for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
- fileIt != srcFiles.end(); ++fileIt) {
- cmSourceFile* sf = *fileIt;
- const cmSystemTools::FileFormat fileType =
- cmSystemTools::GetFileFormat(sf->GetExtension().c_str());
-
- if (!(fileType == cmSystemTools::CXX_FILE_FORMAT) &&
- !(fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
- continue;
- }
- if (PropertyEnabled(sf, "GENERATED") &&
- !target->GetPropertyAsBool("__UNDOCUMENTED_AUTOGEN_GENERATED_FILES")) {
- // FIXME: Add a policy whose NEW behavior allows generated files.
- // The implementation already works. We disable it here to avoid
- // changing behavior for existing projects that do not expect it.
- continue;
- }
- const std::string absFile =
- cmsys::SystemTools::GetRealPath(sf->GetFullPath());
- // Skip flags
- const bool skipAll = PropertyEnabled(sf, "SKIP_AUTOGEN");
- const bool mocSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOMOC");
- const bool uicSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOUIC");
- // Add file name to skip lists.
- // Do this even when the file is not added to the sources/headers lists
- // because the file name may be extracted from an other file when
- // processing
- if (mocSkip) {
- mocSkipList.push_back(absFile);
- }
- if (uicSkip) {
- uicSkipList.push_back(absFile);
- }
-
- if ((mocTarget && !mocSkip) || (uicTarget && !uicSkip)) {
- // Add file name to sources or headers list
- switch (fileType) {
- case cmSystemTools::CXX_FILE_FORMAT:
- mocUicSources.push_back(absFile);
- break;
- case cmSystemTools::HEADER_FILE_FORMAT:
- mocUicHeaders.push_back(absFile);
- break;
- default:
- break;
- }
- }
- }
-}
-
-static void MocSetupAutoTarget(
- cmGeneratorTarget const* target, const std::string& autogenTargetName,
- std::string const& qtMajorVersion, std::string const& config,
- std::vector<std::string> const& configs,
- std::vector<std::string> const& mocSkipList,
- std::map<std::string, std::string>& configMocIncludes,
- std::map<std::string, std::string>& configMocDefines)
-{
- cmLocalGenerator* lg = target->GetLocalGenerator();
- cmMakefile* makefile = target->Target->GetMakefile();
-
- AddDefinitionEscaped(makefile, "_moc_options",
- GetSafeProperty(target, "AUTOMOC_MOC_OPTIONS"));
- AddDefinitionEscaped(makefile, "_moc_skip", mocSkipList);
- AddDefinitionEscaped(makefile, "_moc_relaxed_mode",
- makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE") ? "TRUE"
- : "FALSE");
- AddDefinitionEscaped(makefile, "_moc_depend_filters",
- GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS"));
-
- if (QtVersionGreaterOrEqual(
- qtMajorVersion, GetQtMinorVersion(target, qtMajorVersion), 5, 8)) {
- AddDefinitionEscaped(
- makefile, "_moc_predefs_cmd",
- makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND"));
- }
- // Moc includes and compile definitions
- {
- // Default settings
- std::string incs;
- std::string compileDefs;
- GetCompileDefinitionsAndDirectories(target, config, incs, compileDefs);
- AddDefinitionEscaped(makefile, "_moc_incs", incs);
- AddDefinitionEscaped(makefile, "_moc_compile_defs", compileDefs);
-
- // Configuration specific settings
- for (std::vector<std::string>::const_iterator li = configs.begin();
- li != configs.end(); ++li) {
- std::string configIncs;
- std::string configCompileDefs;
- GetCompileDefinitionsAndDirectories(target, *li, configIncs,
- configCompileDefs);
- if (configIncs != incs) {
- configMocIncludes[*li] = cmOutputConverter::EscapeForCMake(configIncs);
- }
- if (configCompileDefs != compileDefs) {
- configMocDefines[*li] =
- cmOutputConverter::EscapeForCMake(configCompileDefs);
- }
- }
- }
-
- // Moc executable
- {
- std::string err;
- const char* mocExec = CM_NULLPTR;
- if (qtMajorVersion == "5") {
- cmGeneratorTarget* qt5Moc = lg->FindGeneratorTargetToUse("Qt5::moc");
- if (qt5Moc != CM_NULLPTR) {
- mocExec = qt5Moc->ImportedGetLocation("");
- } else {
- err = "Qt5::moc target not found " + autogenTargetName;
- }
- } else if (qtMajorVersion == "4") {
- cmGeneratorTarget* qt4Moc = lg->FindGeneratorTargetToUse("Qt4::moc");
- if (qt4Moc != CM_NULLPTR) {
- mocExec = qt4Moc->ImportedGetLocation("");
- } else {
- err = "Qt4::moc target not found " + autogenTargetName;
- }
- } else {
- err = "The CMAKE_AUTOMOC feature supports only Qt 4 and Qt 5 ";
- err += autogenTargetName;
- }
- // Add definition or error
- if (err.empty()) {
- AddDefinitionEscaped(makefile, "_qt_moc_executable",
- mocExec ? mocExec : "");
- } else {
- cmSystemTools::Error(err.c_str());
- }
- }
-}
-
-static void UicGetOpts(cmGeneratorTarget const* target,
- const std::string& config, std::string& optString)
-{
- std::vector<std::string> opts;
- target->GetAutoUicOptions(opts, config);
- optString = cmJoin(opts, ";");
-}
-
-static void UicSetupAutoTarget(
- cmGeneratorTarget const* target, std::string const& qtMajorVersion,
- std::string const& config, std::vector<std::string> const& configs,
- std::vector<std::string> const& uicSkipList,
- std::map<std::string, std::string>& configUicOptions)
-{
- cmLocalGenerator* lg = target->GetLocalGenerator();
- cmMakefile* makefile = target->Target->GetMakefile();
-
- AddDefinitionEscaped(makefile, "_uic_skip", uicSkipList);
-
- // Uic search paths
- {
- std::vector<std::string> uicSearchPaths;
- cmSystemTools::ExpandListArgument(
- GetSafeProperty(target, "AUTOUIC_SEARCH_PATHS"), uicSearchPaths);
- const std::string srcDir = makefile->GetCurrentSourceDirectory();
- for (std::vector<std::string>::iterator it = uicSearchPaths.begin();
- it != uicSearchPaths.end(); ++it) {
- *it = cmSystemTools::CollapseFullPath(*it, srcDir);
- }
- AddDefinitionEscaped(makefile, "_uic_search_paths", uicSearchPaths);
- }
- // Uic target options
- {
- // Default settings
- std::string uicOpts;
- UicGetOpts(target, config, uicOpts);
- AddDefinitionEscaped(makefile, "_uic_target_options", uicOpts);
-
- // Configuration specific settings
- for (std::vector<std::string>::const_iterator li = configs.begin();
- li != configs.end(); ++li) {
- std::string configUicOpts;
- UicGetOpts(target, *li, configUicOpts);
- if (configUicOpts != uicOpts) {
- configUicOptions[*li] =
- cmOutputConverter::EscapeForCMake(configUicOpts);
- }
- }
- }
- // Uic files options
- {
- std::vector<std::string> uiFileFiles;
- std::vector<std::string> uiFileOptions;
- {
- std::set<std::string> skipped;
- skipped.insert(uicSkipList.begin(), uicSkipList.end());
-
- const std::vector<cmSourceFile*> uiFilesWithOptions =
- makefile->GetQtUiFilesWithOptions();
- for (std::vector<cmSourceFile*>::const_iterator fileIt =
- uiFilesWithOptions.begin();
- fileIt != uiFilesWithOptions.end(); ++fileIt) {
- cmSourceFile* sf = *fileIt;
- const std::string absFile =
- cmsys::SystemTools::GetRealPath(sf->GetFullPath());
- if (skipped.insert(absFile).second) {
- // The file wasn't skipped
- uiFileFiles.push_back(absFile);
- {
- std::string opts = sf->GetProperty("AUTOUIC_OPTIONS");
- cmSystemTools::ReplaceString(opts, ";",
- cmQtAutoGeneratorCommon::listSep);
- uiFileOptions.push_back(opts);
- }
- }
- }
- }
- AddDefinitionEscaped(makefile, "_qt_uic_options_files", uiFileFiles);
- AddDefinitionEscaped(makefile, "_qt_uic_options_options", uiFileOptions);
- }
-
- // Uic executable
- {
- std::string err;
- const char* uicExec = CM_NULLPTR;
- if (qtMajorVersion == "5") {
- cmGeneratorTarget* qt5Uic = lg->FindGeneratorTargetToUse("Qt5::uic");
- if (qt5Uic != CM_NULLPTR) {
- uicExec = qt5Uic->ImportedGetLocation("");
- } else {
- // Project does not use Qt5Widgets, but has AUTOUIC ON anyway
- }
- } else if (qtMajorVersion == "4") {
- cmGeneratorTarget* qt4Uic = lg->FindGeneratorTargetToUse("Qt4::uic");
- if (qt4Uic != CM_NULLPTR) {
- uicExec = qt4Uic->ImportedGetLocation("");
- } else {
- err = "Qt4::uic target not found " + target->GetName();
- }
- } else {
- err = "The CMAKE_AUTOUIC feature supports only Qt 4 and Qt 5 ";
- err += target->GetName();
- }
- // Add definition or error
- if (err.empty()) {
- AddDefinitionEscaped(makefile, "_qt_uic_executable",
- uicExec ? uicExec : "");
- } else {
- cmSystemTools::Error(err.c_str());
- }
- }
-}
-
-static std::string RccGetExecutable(cmGeneratorTarget const* target,
- const std::string& qtMajorVersion)
-{
- std::string rccExec;
- cmLocalGenerator* lg = target->GetLocalGenerator();
- if (qtMajorVersion == "5") {
- cmGeneratorTarget* qt5Rcc = lg->FindGeneratorTargetToUse("Qt5::rcc");
- if (qt5Rcc != CM_NULLPTR) {
- rccExec = qt5Rcc->ImportedGetLocation("");
- } else {
- cmSystemTools::Error("Qt5::rcc target not found ",
- target->GetName().c_str());
- }
- } else if (qtMajorVersion == "4") {
- cmGeneratorTarget* qt4Rcc = lg->FindGeneratorTargetToUse("Qt4::rcc");
- if (qt4Rcc != CM_NULLPTR) {
- rccExec = qt4Rcc->ImportedGetLocation("");
- } else {
- cmSystemTools::Error("Qt4::rcc target not found ",
- target->GetName().c_str());
- }
- } else {
- cmSystemTools::Error(
- "The CMAKE_AUTORCC feature supports only Qt 4 and Qt 5 ",
- target->GetName().c_str());
- }
- return rccExec;
-}
-
-static void RccMergeOptions(std::vector<std::string>& opts,
- const std::vector<std::string>& fileOpts,
- bool isQt5)
-{
- static const char* valueOptions[] = { "name", "root", "compress",
- "threshold" };
- std::vector<std::string> extraOpts;
- for (std::vector<std::string>::const_iterator fit = fileOpts.begin();
- fit != fileOpts.end(); ++fit) {
- std::vector<std::string>::iterator existingIt =
- std::find(opts.begin(), opts.end(), *fit);
- if (existingIt != opts.end()) {
- const char* optName = fit->c_str();
- if (*optName == '-') {
- ++optName;
- if (isQt5 && *optName == '-') {
- ++optName;
- }
- }
- // Test if this is a value option and change the existing value
- if ((optName != fit->c_str()) &&
- std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions),
- cmStrCmp(optName)) != cmArrayEnd(valueOptions)) {
- const std::vector<std::string>::iterator existValueIt(existingIt + 1);
- const std::vector<std::string>::const_iterator fileValueIt(fit + 1);
- if ((existValueIt != opts.end()) && (fileValueIt != fileOpts.end())) {
- *existValueIt = *fileValueIt;
- ++fit;
- }
- }
- } else {
- extraOpts.push_back(*fit);
- }
- }
- opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
-}
-
-static void RccSetupAutoTarget(cmGeneratorTarget const* target,
- const std::string& qtMajorVersion)
-{
- cmMakefile* makefile = target->Target->GetMakefile();
- const bool qtMajorVersion5 = (qtMajorVersion == "5");
- const std::string rccCommand = RccGetExecutable(target, qtMajorVersion);
- std::vector<std::string> _rcc_files;
- std::vector<std::string> _rcc_inputs;
- std::vector<std::string> rccFileFiles;
- std::vector<std::string> rccFileOptions;
- std::vector<std::string> rccOptionsTarget;
- if (const char* opts = target->GetProperty("AUTORCC_OPTIONS")) {
- cmSystemTools::ExpandListArgument(opts, rccOptionsTarget);
- }
-
- std::vector<cmSourceFile*> srcFiles;
- target->GetConfigCommonSourceFiles(srcFiles);
- for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
- fileIt != srcFiles.end(); ++fileIt) {
- cmSourceFile* sf = *fileIt;
- if ((sf->GetExtension() == "qrc") &&
- !PropertyEnabled(sf, "SKIP_AUTOGEN") &&
- !PropertyEnabled(sf, "SKIP_AUTORCC")) {
- const std::string absFile =
- cmsys::SystemTools::GetRealPath(sf->GetFullPath());
- // qrc file
- _rcc_files.push_back(absFile);
- // qrc file entries
- {
- std::string entriesList = "{";
- // Read input file list only for non generated .qrc files.
- if (!PropertyEnabled(sf, "GENERATED")) {
- std::string error;
- std::vector<std::string> files;
- if (cmQtAutoGeneratorCommon::RccListInputs(
- qtMajorVersion, rccCommand, absFile, files, &error)) {
- entriesList += cmJoin(files, cmQtAutoGeneratorCommon::listSep);
- } else {
- cmSystemTools::Error(error.c_str());
- }
- }
- entriesList += "}";
- _rcc_inputs.push_back(entriesList);
- }
- // rcc options for this qrc file
- {
- // Merged target and file options
- std::vector<std::string> rccOptions(rccOptionsTarget);
- if (const char* prop = sf->GetProperty("AUTORCC_OPTIONS")) {
- std::vector<std::string> optsVec;
- cmSystemTools::ExpandListArgument(prop, optsVec);
- RccMergeOptions(rccOptions, optsVec, qtMajorVersion5);
- }
- // Only store non empty options lists
- if (!rccOptions.empty()) {
- rccFileFiles.push_back(absFile);
- rccFileOptions.push_back(
- cmJoin(rccOptions, cmQtAutoGeneratorCommon::listSep));
- }
- }
- }
- }
-
- AddDefinitionEscaped(makefile, "_qt_rcc_executable", rccCommand);
- AddDefinitionEscaped(makefile, "_rcc_files", _rcc_files);
- AddDefinitionEscaped(makefile, "_rcc_inputs", _rcc_inputs);
- AddDefinitionEscaped(makefile, "_rcc_options_files", rccFileFiles);
- AddDefinitionEscaped(makefile, "_rcc_options_options", rccFileOptions);
-}
-
-void cmQtAutoGeneratorInitializer::InitializeAutogenSources(
- cmGeneratorTarget* target)
-{
- if (target->GetPropertyAsBool("AUTOMOC")) {
- cmMakefile* makefile = target->Target->GetMakefile();
- const std::vector<std::string> suffixes =
- GetConfigurationSuffixes(makefile);
- // Get build directory
- const std::string autogenBuildDir = GetAutogenTargetBuildDir(target);
- // Register all compilation files as generated
- for (std::vector<std::string>::const_iterator it = suffixes.begin();
- it != suffixes.end(); ++it) {
- std::string mcFile = autogenBuildDir + "/mocs_compilation";
- mcFile += *it;
- mcFile += ".cpp";
- AddGeneratedSource(makefile, mcFile, cmQtAutoGeneratorCommon::MOC);
- }
- // Mocs compilation file
- if (IsMultiConfig(target->GetGlobalGenerator())) {
- target->AddSource(autogenBuildDir + "/mocs_compilation_$<CONFIG>.cpp");
- } else {
- target->AddSource(autogenBuildDir + "/mocs_compilation.cpp");
- }
- }
-}
-
-void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
- cmLocalGenerator* lg, cmGeneratorTarget* target)
-{
- cmMakefile* makefile = target->Target->GetMakefile();
-
- // Create a custom target for running generators at buildtime
- const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC");
- const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC");
- const bool rccEnabled = target->GetPropertyAsBool("AUTORCC");
- const bool multiConfig = IsMultiConfig(target->GetGlobalGenerator());
- const std::string autogenTargetName = GetAutogenTargetName(target);
- const std::string autogenBuildDir = GetAutogenTargetBuildDir(target);
- const std::string workingDirectory =
- cmSystemTools::CollapseFullPath("", makefile->GetCurrentBinaryDirectory());
- const std::string qtMajorVersion = GetQtMajorVersion(target);
- const std::string rccCommand = RccGetExecutable(target, qtMajorVersion);
- const std::vector<std::string> suffixes = GetConfigurationSuffixes(makefile);
- std::vector<std::string> autogenDependFiles;
- std::vector<std::string> autogenDependTargets;
- std::vector<std::string> autogenProvides;
-
- // Remove build directories on cleanup
- makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
- autogenBuildDir.c_str(), false);
-
- // Remove old settings on cleanup
- {
- std::string base = GetAutogenTargetFilesDir(target);
- for (std::vector<std::string>::const_iterator it = suffixes.begin();
- it != suffixes.end(); ++it) {
- std::string fname = base + "/AutogenOldSettings" + *it + ".cmake";
- makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", fname.c_str(),
- false);
- }
- }
-
- // Compose command lines
- cmCustomCommandLines commandLines;
- {
- cmCustomCommandLine currentLine;
- currentLine.push_back(cmSystemTools::GetCMakeCommand());
- currentLine.push_back("-E");
- currentLine.push_back("cmake_autogen");
- currentLine.push_back(GetAutogenTargetFilesDir(target));
- currentLine.push_back("$<CONFIGURATION>");
- commandLines.push_back(currentLine);
- }
-
- // Compose target comment
- std::string autogenComment;
- {
- std::vector<std::string> toolNames;
- if (mocEnabled) {
- toolNames.push_back("MOC");
- }
- if (uicEnabled) {
- toolNames.push_back("UIC");
- }
- if (rccEnabled) {
- toolNames.push_back("RCC");
- }
-
- std::string tools = toolNames[0];
- toolNames.erase(toolNames.begin());
- while (toolNames.size() > 1) {
- tools += ", " + toolNames[0];
- toolNames.erase(toolNames.begin());
- }
- if (toolNames.size() == 1) {
- tools += " and " + toolNames[0];
- }
- autogenComment = "Automatic " + tools + " for target " + target->GetName();
- }
-
- // Add moc compilation to generated files list
- if (mocEnabled) {
- for (std::vector<std::string>::const_iterator it = suffixes.begin();
- it != suffixes.end(); ++it) {
- std::string mcFile = autogenBuildDir + "/mocs_compilation";
- mcFile += *it;
- mcFile += ".cpp";
- autogenProvides.push_back(mcFile);
- }
- }
-
- // Add autogen includes directory to the origin target INCLUDE_DIRECTORIES
- if (mocEnabled || uicEnabled) {
- if (multiConfig) {
- target->AddIncludeDirectory(autogenBuildDir + "/include_$<CONFIG>",
- true);
-
- } else {
- target->AddIncludeDirectory(autogenBuildDir + "/include", true);
- }
- }
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
- bool usePRE_BUILD = false;
- cmGlobalGenerator* gg = lg->GetGlobalGenerator();
- if (gg->GetName().find("Visual Studio") != std::string::npos) {
- // Under VS use a PRE_BUILD event instead of a separate target to
- // reduce the number of targets loaded into the IDE.
- // This also works around a VS 11 bug that may skip updating the target:
- // https://connect.microsoft.com/VisualStudio/feedback/details/769495
- usePRE_BUILD = true;
- }
-#endif
-
- // Initialize autogen target dependencies
- if (const char* extraDeps = target->GetProperty("AUTOGEN_TARGET_DEPENDS")) {
- std::vector<std::string> deps;
- cmSystemTools::ExpandListArgument(extraDeps, deps);
- for (std::vector<std::string>::const_iterator itC = deps.begin(),
- itE = deps.end();
- itC != itE; ++itC) {
- if (makefile->FindTargetToUse(*itC) != CM_NULLPTR) {
- autogenDependTargets.push_back(*itC);
- } else {
- autogenDependFiles.push_back(*itC);
- }
- }
- }
- {
- cmFilePathChecksum fpathCheckSum(makefile);
- // Iterate over all source files
- std::vector<cmSourceFile*> srcFiles;
- target->GetConfigCommonSourceFiles(srcFiles);
- for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
- fileIt != srcFiles.end(); ++fileIt) {
- cmSourceFile* sf = *fileIt;
- if (!PropertyEnabled(sf, "SKIP_AUTOGEN")) {
- std::string const& ext = sf->GetExtension();
- // Add generated file that will be scanned by moc or uic to
- // the dependencies
- if (mocEnabled || uicEnabled) {
- const cmSystemTools::FileFormat fileType =
- cmSystemTools::GetFileFormat(ext.c_str());
- if ((fileType == cmSystemTools::CXX_FILE_FORMAT) ||
- (fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
- if (PropertyEnabled(sf, "GENERATED")) {
- if ((mocEnabled && !PropertyEnabled(sf, "SKIP_AUTOMOC")) ||
- (uicEnabled && !PropertyEnabled(sf, "SKIP_AUTOUIC"))) {
- autogenDependFiles.push_back(
- cmsys::SystemTools::GetRealPath(sf->GetFullPath()));
-#if defined(_WIN32) && !defined(__CYGWIN__)
- // Cannot use PRE_BUILD with generated files
- usePRE_BUILD = false;
-#endif
- }
- }
- }
- }
- // Process rcc enabled files
- if (rccEnabled && (ext == "qrc") &&
- !PropertyEnabled(sf, "SKIP_AUTORCC")) {
- const std::string absFile =
- cmsys::SystemTools::GetRealPath(sf->GetFullPath());
-
- // Compose rcc output file name
- {
- std::string rccOutBase = autogenBuildDir + "/";
- rccOutBase += fpathCheckSum.getPart(absFile);
- rccOutBase += "/qrc_";
- rccOutBase +=
- cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile);
-
- // Register rcc ouput file as generated
- for (std::vector<std::string>::const_iterator it =
- suffixes.begin();
- it != suffixes.end(); ++it) {
- std::string rccOutCfg = rccOutBase;
- rccOutCfg += *it;
- rccOutCfg += ".cpp";
- AddGeneratedSource(makefile, rccOutCfg,
- cmQtAutoGeneratorCommon::RCC);
- autogenProvides.push_back(rccOutCfg);
- }
- // Add rcc output file to origin target sources
- if (multiConfig) {
- target->AddSource(rccOutBase + "_$<CONFIG>.cpp");
- } else {
- target->AddSource(rccOutBase + ".cpp");
- }
- }
-
- if (PropertyEnabled(sf, "GENERATED")) {
- // Add generated qrc file to the dependencies
- autogenDependFiles.push_back(absFile);
- } else {
- // Run cmake again when .qrc file changes
- makefile->AddCMakeDependFile(absFile);
-
- // Add the qrc input files to the dependencies
- std::string error;
- if (!cmQtAutoGeneratorCommon::RccListInputs(
- qtMajorVersion, rccCommand, absFile, autogenDependFiles,
- &error)) {
- cmSystemTools::Error(error.c_str());
- }
- }
-#if defined(_WIN32) && !defined(__CYGWIN__)
- // Cannot use PRE_BUILD because the resource files themselves
- // may not be sources within the target so VS may not know the
- // target needs to re-build at all.
- usePRE_BUILD = false;
-#endif
- }
- }
- }
- }
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
- if (usePRE_BUILD) {
- // We can't use pre-build if we depend on additional files
- if (!autogenDependFiles.empty()) {
- usePRE_BUILD = false;
- }
- }
- if (usePRE_BUILD) {
- // Add the pre-build command directly to bypass the OBJECT_LIBRARY
- // rejection in cmMakefile::AddCustomCommandToTarget because we know
- // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case.
- std::vector<std::string> no_output;
- std::vector<std::string> no_depends;
- cmCustomCommand cc(makefile, no_output, autogenProvides, no_depends,
- commandLines, autogenComment.c_str(),
- workingDirectory.c_str());
- cc.SetEscapeOldStyle(false);
- cc.SetEscapeAllowMakeVars(true);
- target->Target->AddPreBuildCommand(cc);
-
- // Add additional target dependencies to the origin target
- for (std::vector<std::string>::const_iterator
- itC = autogenDependTargets.begin(),
- itE = autogenDependTargets.end();
- itC != itE; ++itC) {
- target->Target->AddUtility(*itC);
- }
- } else
-#endif
- {
- cmTarget* autogenTarget = makefile->AddUtilityCommand(
- autogenTargetName, true, workingDirectory.c_str(),
- /*byproducts=*/autogenProvides, autogenDependFiles, commandLines, false,
- autogenComment.c_str());
-
- cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
- lg->AddGeneratorTarget(gt);
-
- // Add origin link library targets to the autogen target dependencies
- {
- const cmTarget::LinkLibraryVectorType& libVec =
- target->Target->GetOriginalLinkLibraries();
- for (cmTarget::LinkLibraryVectorType::const_iterator
- itC = libVec.begin(),
- itE = libVec.end();
- itC != itE; ++itC) {
- const std::string& libName = itC->first;
- if (makefile->FindTargetToUse(libName) != CM_NULLPTR) {
- autogenDependTargets.push_back(libName);
- }
- }
- }
- // Add origin utility targets to the autogen target dependencies
- {
- const std::set<std::string>& utils = target->Target->GetUtilities();
- for (std::set<std::string>::const_iterator itC = utils.begin(),
- itE = utils.end();
- itC != itE; ++itC) {
- autogenDependTargets.push_back(*itC);
- }
- }
- // Add additional target dependencies to the autogen target
- for (std::vector<std::string>::const_iterator
- itC = autogenDependTargets.begin(),
- itE = autogenDependTargets.end();
- itC != itE; ++itC) {
- autogenTarget->AddUtility(*itC);
- }
-
- // Set target folder
- const char* autogenFolder =
- makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");
- if (!autogenFolder) {
- autogenFolder =
- makefile->GetState()->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER");
- }
- if (autogenFolder && *autogenFolder) {
- autogenTarget->SetProperty("FOLDER", autogenFolder);
- } else {
- // inherit FOLDER property from target (#13688)
- utilCopyTargetProperty(gt->Target, target->Target, "FOLDER");
- }
-
- target->Target->AddUtility(autogenTargetName);
- }
-}
-
-void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
- cmGeneratorTarget const* target)
-{
- cmMakefile* makefile = target->Target->GetMakefile();
-
- // forget the variables added here afterwards again:
- cmMakefile::ScopePushPop varScope(makefile);
- static_cast<void>(varScope);
-
- // Get configurations
- std::string config;
- const std::vector<std::string> configs(GetConfigurations(makefile, &config));
-
- // Configurations settings buffers
- std::map<std::string, std::string> configSuffix;
- std::map<std::string, std::string> configMocIncludes;
- std::map<std::string, std::string> configMocDefines;
- std::map<std::string, std::string> configUicOptions;
-
- // Configuration suffix
- if (IsMultiConfig(target->GetGlobalGenerator())) {
- for (std::vector<std::string>::const_iterator it = configs.begin();
- it != configs.end(); ++it) {
- configSuffix[*it] = "_" + *it;
- }
- }
-
- // Basic setup
- {
- const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC");
- const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC");
- const bool rccEnabled = target->GetPropertyAsBool("AUTORCC");
- const std::string autogenTargetName = GetAutogenTargetName(target);
- const std::string qtMajorVersion = GetQtMajorVersion(target);
-
- std::vector<std::string> sources;
- std::vector<std::string> headers;
-
- if (mocEnabled || uicEnabled || rccEnabled) {
- std::vector<std::string> mocSkipList;
- std::vector<std::string> uicSkipList;
- AcquireScanFiles(target, sources, headers, mocSkipList, uicSkipList);
- if (mocEnabled) {
- MocSetupAutoTarget(target, autogenTargetName, qtMajorVersion, config,
- configs, mocSkipList, configMocIncludes,
- configMocDefines);
- }
- if (uicEnabled) {
- UicSetupAutoTarget(target, qtMajorVersion, config, configs,
- uicSkipList, configUicOptions);
- }
- if (rccEnabled) {
- RccSetupAutoTarget(target, qtMajorVersion);
- }
- }
-
- AddDefinitionEscaped(makefile, "_autogen_build_dir",
- GetAutogenTargetBuildDir(target));
- AddDefinitionEscaped(makefile, "_qt_version_major", qtMajorVersion);
- AddDefinitionEscaped(makefile, "_sources", sources);
- AddDefinitionEscaped(makefile, "_headers", headers);
- }
-
- // Generate info file
- std::string infoFile = GetAutogenTargetFilesDir(target);
- infoFile += "/AutogenInfo.cmake";
- {
- std::string inf = cmSystemTools::GetCMakeRoot();
- inf += "/Modules/AutogenInfo.cmake.in";
- makefile->ConfigureFile(inf.c_str(), infoFile.c_str(), false, true, false);
- }
-
- // Append custom definitions to info file on demand
- if (!configSuffix.empty() || !configMocDefines.empty() ||
- !configMocIncludes.empty() || !configUicOptions.empty()) {
-
- // Ensure we have write permission in case .in was read-only.
- mode_t perm = 0;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- mode_t mode_write = S_IWRITE;
-#else
- mode_t mode_write = S_IWUSR;
-#endif
- cmSystemTools::GetPermissions(infoFile, perm);
- if (!(perm & mode_write)) {
- cmSystemTools::SetPermissions(infoFile, perm | mode_write);
- }
-
- // Open and write file
- cmsys::ofstream ofs(infoFile.c_str(), std::ios::app);
- if (ofs) {
- ofs << "# Configuration specific options\n";
- for (std::map<std::string, std::string>::iterator
- it = configSuffix.begin(),
- end = configSuffix.end();
- it != end; ++it) {
- ofs << "set(AM_CONFIG_SUFFIX_" << it->first << " " << it->second
- << ")\n";
- }
- for (std::map<std::string, std::string>::iterator
- it = configMocDefines.begin(),
- end = configMocDefines.end();
- it != end; ++it) {
- ofs << "set(AM_MOC_DEFINITIONS_" << it->first << " " << it->second
- << ")\n";
- }
- for (std::map<std::string, std::string>::iterator
- it = configMocIncludes.begin(),
- end = configMocIncludes.end();
- it != end; ++it) {
- ofs << "set(AM_MOC_INCLUDES_" << it->first << " " << it->second
- << ")\n";
- }
- for (std::map<std::string, std::string>::iterator
- it = configUicOptions.begin(),
- end = configUicOptions.end();
- it != end; ++it) {
- ofs << "set(AM_UIC_TARGET_OPTIONS_" << it->first << " " << it->second
- << ")\n";
- }
- } else {
- // File open error
- std::string error = "Internal CMake error when trying to open file: ";
- error += cmQtAutoGeneratorCommon::Quoted(infoFile);
- error += " for writing.";
- cmSystemTools::Error(error.c_str());
- }
- }
-}
diff --git a/Source/cmQtAutoGeneratorInitializer.h b/Source/cmQtAutoGeneratorInitializer.h
deleted file mode 100644
index ca806f5a9..000000000
--- a/Source/cmQtAutoGeneratorInitializer.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmQtAutoGeneratorInitializer_h
-#define cmQtAutoGeneratorInitializer_h
-
-#include "cmConfigure.h" // IWYU pragma: keep
-
-class cmGeneratorTarget;
-class cmLocalGenerator;
-
-class cmQtAutoGeneratorInitializer
-{
-public:
- static void InitializeAutogenSources(cmGeneratorTarget* target);
- static void InitializeAutogenTarget(cmLocalGenerator* lg,
- cmGeneratorTarget* target);
- static void SetupAutoGenerateTarget(cmGeneratorTarget const* target);
-};
-
-#endif
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
deleted file mode 100644
index d12d96dcb..000000000
--- a/Source/cmQtAutoGenerators.cxx
+++ /dev/null
@@ -1,2066 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmQtAutoGenerators.h"
-#include "cmQtAutoGeneratorCommon.h"
-
-#include "cmConfigure.h"
-#include "cmsys/FStream.hxx"
-#include "cmsys/Terminal.h"
-#include <algorithm>
-#include <assert.h>
-#include <list>
-#include <sstream>
-#include <stdlib.h>
-#include <string.h>
-#include <utility>
-
-#include "cmAlgorithms.h"
-#include "cmCryptoHash.h"
-#include "cmFilePathChecksum.h"
-#include "cmGlobalGenerator.h"
-#include "cmMakefile.h"
-#include "cmOutputConverter.h"
-#include "cmStateDirectory.h"
-#include "cmStateSnapshot.h"
-#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
-#include "cmake.h"
-
-#if defined(__APPLE__)
-#include <unistd.h>
-#endif
-
-// -- Static variables
-
-static const char* SettingsKeyMoc = "AM_MOC_SETTINGS_HASH";
-static const char* SettingsKeyUic = "AM_UIC_SETTINGS_HASH";
-static const char* SettingsKeyRcc = "AM_RCC_SETTINGS_HASH";
-
-// -- Static functions
-
-inline static std::string Quoted(const std::string& text)
-{
- return cmQtAutoGeneratorCommon::Quoted(text);
-}
-
-static std::string QuotedCommand(const std::vector<std::string>& command)
-{
- std::string res;
- for (std::vector<std::string>::const_iterator cit = command.begin();
- cit != command.end(); ++cit) {
- if (!res.empty()) {
- res.push_back(' ');
- }
- const std::string cesc = Quoted(*cit);
- if (cit->empty() || (cesc.size() > (cit->size() + 2)) ||
- (cesc.find(' ') != std::string::npos)) {
- res += cesc;
- } else {
- res += *cit;
- }
- }
- return res;
-}
-
-static void InfoGet(cmMakefile* makefile, const char* key, std::string& value)
-{
- value = makefile->GetSafeDefinition(key);
-}
-
-static void InfoGet(cmMakefile* makefile, const char* key, bool& value)
-{
- value = makefile->IsOn(key);
-}
-
-static void InfoGet(cmMakefile* makefile, const char* key,
- std::vector<std::string>& list)
-{
- cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition(key), list);
-}
-
-static void InfoGetConfig(cmMakefile* makefile, const char* key,
- const std::string& config, std::string& value)
-{
- const char* valueConf = CM_NULLPTR;
- {
- std::string keyConf = key;
- if (!config.empty()) {
- keyConf += "_";
- keyConf += config;
- }
- valueConf = makefile->GetDefinition(keyConf);
- }
- if (valueConf == CM_NULLPTR) {
- valueConf = makefile->GetSafeDefinition(key);
- }
- value = valueConf;
-}
-
-static void InfoGetConfig(cmMakefile* makefile, const char* key,
- const std::string& config,
- std::vector<std::string>& list)
-{
- std::string value;
- InfoGetConfig(makefile, key, config, value);
- cmSystemTools::ExpandListArgument(value, list);
-}
-
-inline static bool SettingsMatch(cmMakefile* makefile, const char* key,
- const std::string& value)
-{
- return (value == makefile->GetSafeDefinition(key));
-}
-
-static void SettingAppend(std::string& str, const char* key,
- const std::string& value)
-{
- if (!value.empty()) {
- str += "set(";
- str += key;
- str += " ";
- str += cmOutputConverter::EscapeForCMake(value);
- str += ")\n";
- }
-}
-
-static std::string SubDirPrefix(const std::string& fileName)
-{
- std::string res(cmsys::SystemTools::GetFilenamePath(fileName));
- if (!res.empty()) {
- res += '/';
- }
- return res;
-}
-
-static bool FileNameIsUnique(const std::string& filePath,
- const std::map<std::string, std::string>& fileMap)
-{
- size_t count(0);
- const std::string fileName = cmsys::SystemTools::GetFilenameName(filePath);
- for (std::map<std::string, std::string>::const_iterator si = fileMap.begin();
- si != fileMap.end(); ++si) {
- if (cmsys::SystemTools::GetFilenameName(si->first) == fileName) {
- ++count;
- if (count > 1) {
- return false;
- }
- }
- }
- return true;
-}
-
-static bool ReadAll(std::string& content, const std::string& filename)
-{
- bool success = false;
- {
- cmsys::ifstream ifs(filename.c_str());
- if (ifs) {
- std::ostringstream osst;
- osst << ifs.rdbuf();
- content = osst.str();
- success = true;
- }
- }
- return success;
-}
-
-/**
- * @brief Tests if buildFile doesn't exist or is older than sourceFile
- * @return True if buildFile doesn't exist or is older than sourceFile
- */
-static bool FileAbsentOrOlder(const std::string& buildFile,
- const std::string& sourceFile)
-{
- int result = 0;
- bool success =
- cmsys::SystemTools::FileTimeCompare(buildFile, sourceFile, &result);
- return (!success || (result <= 0));
-}
-
-static bool ListContains(const std::vector<std::string>& list,
- const std::string& entry)
-{
- return (std::find(list.begin(), list.end(), entry) != list.end());
-}
-
-static std::string JoinOptionsList(const std::vector<std::string>& opts)
-{
- return cmOutputConverter::EscapeForCMake(cmJoin(opts, ";"));
-}
-
-static std::string JoinOptionsMap(
- const std::map<std::string, std::string>& opts)
-{
- std::string result;
- for (std::map<std::string, std::string>::const_iterator it = opts.begin();
- it != opts.end(); ++it) {
- if (it != opts.begin()) {
- result += cmQtAutoGeneratorCommon::listSep;
- }
- result += it->first;
- result += "===";
- result += it->second;
- }
- return result;
-}
-
-static std::string JoinExts(const std::vector<std::string>& lst)
-{
- std::string result;
- if (!lst.empty()) {
- const std::string separator = ",";
- for (std::vector<std::string>::const_iterator it = lst.begin();
- it != lst.end(); ++it) {
- if (it != lst.begin()) {
- result += separator;
- }
- result += '.';
- result += *it;
- }
- }
- return result;
-}
-
-static void UicMergeOptions(std::vector<std::string>& opts,
- const std::vector<std::string>& fileOpts,
- bool isQt5)
-{
- static const char* valueOptions[] = { "tr", "translate",
- "postfix", "generator",
- "include", // Since Qt 5.3
- "g" };
- std::vector<std::string> extraOpts;
- for (std::vector<std::string>::const_iterator it = fileOpts.begin();
- it != fileOpts.end(); ++it) {
- std::vector<std::string>::iterator existingIt =
- std::find(opts.begin(), opts.end(), *it);
- if (existingIt != opts.end()) {
- const char* o = it->c_str();
- if (*o == '-') {
- ++o;
- }
- if (isQt5 && *o == '-') {
- ++o;
- }
- if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions),
- cmStrCmp(*it)) != cmArrayEnd(valueOptions)) {
- assert(existingIt + 1 != opts.end());
- *(existingIt + 1) = *(it + 1);
- ++it;
- }
- } else {
- extraOpts.push_back(*it);
- }
- }
- opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
-}
-
-// -- Class methods
-
-cmQtAutoGenerators::cmQtAutoGenerators()
- : Verbose(cmsys::SystemTools::HasEnv("VERBOSE"))
- , ColorOutput(true)
- , MocSettingsChanged(false)
- , MocPredefsChanged(false)
- , MocRunFailed(false)
- , UicSettingsChanged(false)
- , UicRunFailed(false)
- , RccSettingsChanged(false)
- , RccRunFailed(false)
-{
-
- std::string colorEnv;
- cmsys::SystemTools::GetEnv("COLOR", colorEnv);
- if (!colorEnv.empty()) {
- if (cmSystemTools::IsOn(colorEnv.c_str())) {
- this->ColorOutput = true;
- } else {
- this->ColorOutput = false;
- }
- }
-
- // Moc macro filters
- this->MocMacroFilters[0].first = "Q_OBJECT";
- this->MocMacroFilters[0].second.compile("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
- this->MocMacroFilters[1].first = "Q_GADGET";
- this->MocMacroFilters[1].second.compile("[\n][ \t]*Q_GADGET[^a-zA-Z0-9_]");
-
- // Precompile regular expressions
- this->MocRegExpInclude.compile(
- "[\n][ \t]*#[ \t]*include[ \t]+"
- "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]");
- this->UicRegExpInclude.compile("[\n][ \t]*#[ \t]*include[ \t]+"
- "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]");
-}
-
-bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
- const std::string& config)
-{
- cmake cm(cmake::RoleScript);
- cm.SetHomeOutputDirectory(targetDirectory);
- cm.SetHomeDirectory(targetDirectory);
- cm.GetCurrentSnapshot().SetDefaultDefinitions();
- cmGlobalGenerator gg(&cm);
-
- cmStateSnapshot snapshot = cm.GetCurrentSnapshot();
- snapshot.GetDirectory().SetCurrentBinary(targetDirectory);
- snapshot.GetDirectory().SetCurrentSource(targetDirectory);
-
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, snapshot));
- gg.SetCurrentMakefile(mf.get());
-
- bool success = false;
- if (this->ReadAutogenInfoFile(mf.get(), targetDirectory, config)) {
- // Read old settings
- this->SettingsFileRead(mf.get());
- // Init and run
- this->Init(mf.get());
- if (this->RunAutogen()) {
- // Write current settings
- if (this->SettingsFileWrite()) {
- success = true;
- }
- }
- }
- return success;
-}
-
-bool cmQtAutoGenerators::MocDependFilterPush(const std::string& key,
- const std::string& regExp)
-{
- bool success = false;
- if (!key.empty()) {
- if (!regExp.empty()) {
- MocDependFilter filter;
- filter.key = key;
- if (filter.regExp.compile(regExp)) {
- this->MocDependFilters.push_back(filter);
- success = true;
- } else {
- this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Compiling "
- "regular expression failed.\nKey: " +
- Quoted(key) + "\nExp.: " + Quoted(regExp));
- }
- } else {
- this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Regular "
- "expression is empty");
- }
- } else {
- this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Key is empty");
- }
- return success;
-}
-
-bool cmQtAutoGenerators::ReadAutogenInfoFile(
- cmMakefile* makefile, const std::string& targetDirectory,
- const std::string& config)
-{
- std::string filename(cmSystemTools::CollapseFullPath(targetDirectory));
- cmSystemTools::ConvertToUnixSlashes(filename);
- filename += "/AutogenInfo.cmake";
-
- if (!makefile->ReadListFile(filename.c_str())) {
- this->LogError("AutoGen: Error processing file: " + filename);
- return false;
- }
-
- // - Old settings file
- {
- this->SettingsFile = cmSystemTools::CollapseFullPath(targetDirectory);
- cmSystemTools::ConvertToUnixSlashes(this->SettingsFile);
- this->SettingsFile += "/AutogenOldSettings";
- this->SettingsFile += this->ConfigSuffix;
- this->SettingsFile += ".cmake";
- }
-
- // -- Meta
- InfoGetConfig(makefile, "AM_CONFIG_SUFFIX", config, this->ConfigSuffix);
-
- // - Files and directories
- InfoGet(makefile, "AM_CMAKE_SOURCE_DIR", this->ProjectSourceDir);
- InfoGet(makefile, "AM_CMAKE_BINARY_DIR", this->ProjectBinaryDir);
- InfoGet(makefile, "AM_CMAKE_CURRENT_SOURCE_DIR", this->CurrentSourceDir);
- InfoGet(makefile, "AM_CMAKE_CURRENT_BINARY_DIR", this->CurrentBinaryDir);
- InfoGet(makefile, "AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE",
- this->IncludeProjectDirsBefore);
- InfoGet(makefile, "AM_BUILD_DIR", this->AutogenBuildDir);
- if (this->AutogenBuildDir.empty()) {
- this->LogError("AutoGen: Error: Missing autogen build directory ");
- return false;
- }
- InfoGet(makefile, "AM_SOURCES", this->Sources);
- InfoGet(makefile, "AM_HEADERS", this->Headers);
-
- // - Qt environment
- InfoGet(makefile, "AM_QT_VERSION_MAJOR", this->QtMajorVersion);
- if (this->QtMajorVersion.empty()) {
- InfoGet(makefile, "AM_Qt5Core_VERSION_MAJOR", this->QtMajorVersion);
- }
- InfoGet(makefile, "AM_QT_MOC_EXECUTABLE", this->MocExecutable);
- InfoGet(makefile, "AM_QT_UIC_EXECUTABLE", this->UicExecutable);
- InfoGet(makefile, "AM_QT_RCC_EXECUTABLE", this->RccExecutable);
-
- InfoGet(makefile, "AM_MOC_PREDEFS_CMD", this->MocPredefsCmd);
- // Check Qt version
- if ((this->QtMajorVersion != "4") && (this->QtMajorVersion != "5")) {
- this->LogError("AutoGen: Error: Unsupported Qt version: " +
- Quoted(this->QtMajorVersion));
- return false;
- }
-
- // - Moc
- if (this->MocEnabled()) {
- InfoGet(makefile, "AM_MOC_SKIP", this->MocSkipList);
- InfoGetConfig(makefile, "AM_MOC_DEFINITIONS", config,
- this->MocDefinitions);
-#ifdef _WIN32
- {
- const std::string win32("WIN32");
- if (!ListContains(this->MocDefinitions, win32)) {
- this->MocDefinitions.push_back(win32);
- }
- }
-#endif
- InfoGetConfig(makefile, "AM_MOC_INCLUDES", config, this->MocIncludePaths);
- InfoGet(makefile, "AM_MOC_OPTIONS", this->MocOptions);
- InfoGet(makefile, "AM_MOC_RELAXED_MODE", this->MocRelaxedMode);
- {
- std::vector<std::string> mocDependFilters;
- InfoGet(makefile, "AM_MOC_DEPEND_FILTERS", mocDependFilters);
- // Insert Q_PLUGIN_METADATA dependency filter
- if (this->QtMajorVersion != "4") {
- this->MocDependFilterPush("Q_PLUGIN_METADATA",
- "[\n][ \t]*Q_PLUGIN_METADATA[ \t]*\\("
- "[^\\)]*FILE[ \t]*\"([^\"]+)\"");
- }
- // Insert user defined dependency filters
- if ((mocDependFilters.size() % 2) == 0) {
- for (std::vector<std::string>::const_iterator dit =
- mocDependFilters.begin();
- dit != mocDependFilters.end(); dit += 2) {
- if (!this->MocDependFilterPush(*dit, *(dit + 1))) {
- return false;
- }
- }
- } else {
- this->LogError(
- "AutoMoc: Error: AUTOMOC_DEPEND_FILTERS list size is not "
- "a multiple of 2 in:\n" +
- Quoted(filename));
- return false;
- }
- }
- }
-
- // - Uic
- if (this->UicEnabled()) {
- InfoGet(makefile, "AM_UIC_SKIP", this->UicSkipList);
- InfoGet(makefile, "AM_UIC_SEARCH_PATHS", this->UicSearchPaths);
- InfoGetConfig(makefile, "AM_UIC_TARGET_OPTIONS", config,
- this->UicTargetOptions);
- {
- std::vector<std::string> uicFilesVec;
- std::vector<std::string> uicOptionsVec;
- InfoGet(makefile, "AM_UIC_OPTIONS_FILES", uicFilesVec);
- InfoGet(makefile, "AM_UIC_OPTIONS_OPTIONS", uicOptionsVec);
- // Compare list sizes
- if (uicFilesVec.size() == uicOptionsVec.size()) {
- for (std::vector<std::string>::iterator
- fileIt = uicFilesVec.begin(),
- optionIt = uicOptionsVec.begin();
- fileIt != uicFilesVec.end(); ++fileIt, ++optionIt) {
- cmSystemTools::ReplaceString(*optionIt,
- cmQtAutoGeneratorCommon::listSep, ";");
- this->UicOptions[*fileIt] = *optionIt;
- }
- } else {
- this->LogError(
- "AutoGen: Error: Uic files/options lists size missmatch in:\n" +
- Quoted(filename));
- return false;
- }
- }
- }
-
- // - Rcc
- if (this->RccEnabled()) {
- InfoGet(makefile, "AM_RCC_SOURCES", this->RccSources);
- // File options
- {
- std::vector<std::string> rccFilesVec;
- std::vector<std::string> rccOptionsVec;
- InfoGet(makefile, "AM_RCC_OPTIONS_FILES", rccFilesVec);
- InfoGet(makefile, "AM_RCC_OPTIONS_OPTIONS", rccOptionsVec);
- if (rccFilesVec.size() == rccOptionsVec.size()) {
- for (std::vector<std::string>::iterator
- fileIt = rccFilesVec.begin(),
- optionIt = rccOptionsVec.begin();
- fileIt != rccFilesVec.end(); ++fileIt, ++optionIt) {
- // Replace item separator
- cmSystemTools::ReplaceString(*optionIt,
- cmQtAutoGeneratorCommon::listSep, ";");
- this->RccOptions[*fileIt] = *optionIt;
- }
- } else {
- this->LogError(
- "AutoGen: Error: RCC files/options lists size missmatch in:\n" +
- Quoted(filename));
- return false;
- }
- }
- // File lists
- {
- std::vector<std::string> rccInputLists;
- InfoGet(makefile, "AM_RCC_INPUTS", rccInputLists);
- if (this->RccSources.size() == rccInputLists.size()) {
- for (std::vector<std::string>::iterator
- fileIt = this->RccSources.begin(),
- inputIt = rccInputLists.begin();
- fileIt != this->RccSources.end(); ++fileIt, ++inputIt) {
- // Remove braces
- *inputIt = inputIt->substr(1, inputIt->size() - 2);
- // Replace item separator
- cmSystemTools::ReplaceString(*inputIt,
- cmQtAutoGeneratorCommon::listSep, ";");
- std::vector<std::string> rccInputFiles;
- cmSystemTools::ExpandListArgument(*inputIt, rccInputFiles);
- this->RccInputs[*fileIt] = rccInputFiles;
- }
- } else {
- this->LogError(
- "AutoGen: Error: RCC sources/inputs lists size missmatch in:\n" +
- Quoted(filename));
- return false;
- }
- }
- }
-
- return true;
-}
-
-void cmQtAutoGenerators::SettingsFileRead(cmMakefile* makefile)
-{
- // Compose current settings strings
- {
- cmCryptoHash crypt(cmCryptoHash::AlgoSHA256);
- const std::string sep(" ~~~ ");
- if (this->MocEnabled()) {
- std::string str;
- str += this->MocExecutable;
- str += sep;
- str += JoinOptionsList(this->MocDefinitions);
- str += sep;
- str += JoinOptionsList(this->MocIncludePaths);
- str += sep;
- str += JoinOptionsList(this->MocOptions);
- str += sep;
- str += this->IncludeProjectDirsBefore ? "TRUE" : "FALSE";
- str += sep;
- str += JoinOptionsList(this->MocPredefsCmd);
- str += sep;
- this->SettingsStringMoc = crypt.HashString(str);
- }
- if (this->UicEnabled()) {
- std::string str;
- str += this->UicExecutable;
- str += sep;
- str += JoinOptionsList(this->UicTargetOptions);
- str += sep;
- str += JoinOptionsMap(this->UicOptions);
- str += sep;
- this->SettingsStringUic = crypt.HashString(str);
- }
- if (this->RccEnabled()) {
- std::string str;
- str += this->RccExecutable;
- str += sep;
- str += JoinOptionsMap(this->RccOptions);
- str += sep;
- this->SettingsStringRcc = crypt.HashString(str);
- }
- }
-
- // Read old settings
- if (makefile->ReadListFile(this->SettingsFile.c_str())) {
- if (!SettingsMatch(makefile, SettingsKeyMoc, this->SettingsStringMoc)) {
- this->MocSettingsChanged = true;
- }
- if (!SettingsMatch(makefile, SettingsKeyUic, this->SettingsStringUic)) {
- this->UicSettingsChanged = true;
- }
- if (!SettingsMatch(makefile, SettingsKeyRcc, this->SettingsStringRcc)) {
- this->RccSettingsChanged = true;
- }
- // In case any setting changed remove the old settings file.
- // This triggers a full rebuild on the next run if the current
- // build is aborted before writing the current settings in the end.
- if (this->AnySettingsChanged()) {
- cmSystemTools::RemoveFile(this->SettingsFile);
- }
- } else {
- // If the file could not be read re-generate everythiung.
- this->MocSettingsChanged = true;
- this->UicSettingsChanged = true;
- this->RccSettingsChanged = true;
- }
-}
-
-bool cmQtAutoGenerators::SettingsFileWrite()
-{
- bool success = true;
- // Only write if any setting changed
- if (this->AnySettingsChanged()) {
- if (this->Verbose) {
- this->LogInfo("AutoGen: Writing settings file " +
- Quoted(this->SettingsFile));
- }
- // Compose settings file content
- std::string settings;
- SettingAppend(settings, SettingsKeyMoc, this->SettingsStringMoc);
- SettingAppend(settings, SettingsKeyUic, this->SettingsStringUic);
- SettingAppend(settings, SettingsKeyRcc, this->SettingsStringRcc);
- // Write settings file
- if (!this->FileWrite("AutoGen", this->SettingsFile, settings)) {
- this->LogError("AutoGen: Error: Could not write old settings file " +
- Quoted(this->SettingsFile));
- // Remove old settings file to trigger a full rebuild on the next run
- cmSystemTools::RemoveFile(this->SettingsFile);
- success = false;
- }
- }
- return success;
-}
-
-void cmQtAutoGenerators::Init(cmMakefile* makefile)
-{
- // Mocs compilation file
- this->MocCompFileRel = "mocs_compilation";
- this->MocCompFileRel += this->ConfigSuffix;
- this->MocCompFileRel += ".cpp";
- this->MocCompFileAbs = cmSystemTools::CollapseCombinedPath(
- this->AutogenBuildDir, this->MocCompFileRel);
-
- // Mocs include directory
- this->AutogenIncludeDir = "include";
- this->AutogenIncludeDir += this->ConfigSuffix;
- this->AutogenIncludeDir += "/";
-
- // Moc predefs file
- if (!this->MocPredefsCmd.empty()) {
- this->MocPredefsFileRel = "moc_predefs.h";
- this->MocPredefsFileAbs = cmSystemTools::CollapseCombinedPath(
- this->AutogenBuildDir, this->MocPredefsFileRel);
- }
-
- // Init file path checksum generator
- FPathChecksum.setupParentDirs(this->CurrentSourceDir, this->CurrentBinaryDir,
- this->ProjectSourceDir,
- this->ProjectBinaryDir);
-
- // Acquire header extensions
- this->HeaderExtensions = makefile->GetCMakeInstance()->GetHeaderExtensions();
-
- // Sort include directories on demand
- if (this->IncludeProjectDirsBefore) {
- // Move strings to temporary list
- std::list<std::string> includes;
- includes.insert(includes.end(), this->MocIncludePaths.begin(),
- this->MocIncludePaths.end());
- this->MocIncludePaths.clear();
- this->MocIncludePaths.reserve(includes.size());
- // Append project directories only
- {
- const char* movePaths[2] = { this->ProjectBinaryDir.c_str(),
- this->ProjectSourceDir.c_str() };
- for (const char* const* mpit = cmArrayBegin(movePaths);
- mpit != cmArrayEnd(movePaths); ++mpit) {
- std::list<std::string>::iterator it = includes.begin();
- while (it != includes.end()) {
- const std::string& path = *it;
- if (cmsys::SystemTools::StringStartsWith(path, *mpit)) {
- this->MocIncludePaths.push_back(path);
- it = includes.erase(it);
- } else {
- ++it;
- }
- }
- }
- }
- // Append remaining directories
- this->MocIncludePaths.insert(this->MocIncludePaths.end(), includes.begin(),
- includes.end());
- }
- // Compose moc includes list
- {
- std::set<std::string> frameworkPaths;
- for (std::vector<std::string>::const_iterator it =
- this->MocIncludePaths.begin();
- it != this->MocIncludePaths.end(); ++it) {
- const std::string& path = *it;
- this->MocIncludes.push_back("-I" + path);
- // Extract framework path
- if (cmHasLiteralSuffix(path, ".framework/Headers")) {
- // Go up twice to get to the framework root
- std::vector<std::string> pathComponents;
- cmsys::SystemTools::SplitPath(path, pathComponents);
- std::string frameworkPath = cmsys::SystemTools::JoinPath(
- pathComponents.begin(), pathComponents.end() - 2);
- frameworkPaths.insert(frameworkPath);
- }
- }
- // Append framework includes
- for (std::set<std::string>::const_iterator it = frameworkPaths.begin();
- it != frameworkPaths.end(); ++it) {
- this->MocIncludes.push_back("-F");
- this->MocIncludes.push_back(*it);
- }
- }
-}
-
-bool cmQtAutoGenerators::RunAutogen()
-{
- // the program goes through all .cpp files to see which moc files are
- // included. It is not really interesting how the moc file is named, but
- // what file the moc is created from. Once a moc is included the same moc
- // may not be included in the mocs_compilation_$<CONFIG>.cpp file anymore.
- // OTOH if there's a header containing Q_OBJECT where no corresponding
- // moc file is included anywhere a moc_<filename>.cpp file is created and
- // included in the mocs_compilation_$<CONFIG>.cpp file.
-
- // Create AUTOGEN include directory
- {
- const std::string incDirAbs = cmSystemTools::CollapseCombinedPath(
- this->AutogenBuildDir, this->AutogenIncludeDir);
- if (!cmsys::SystemTools::MakeDirectory(incDirAbs)) {
- this->LogError("AutoGen: Error: Could not create include directory " +
- Quoted(incDirAbs));
- return false;
- }
- }
-
- // key = moc source filepath, value = moc output filepath
- std::map<std::string, std::string> mocsIncluded;
- std::map<std::string, std::string> mocsNotIncluded;
- std::map<std::string, std::set<std::string> > mocDepends;
- std::map<std::string, std::vector<std::string> > uisIncluded;
- // collects all headers which may need to be mocced
- std::set<std::string> mocHeaderFiles;
- std::set<std::string> uicHeaderFiles;
-
- // Parse sources
- for (std::vector<std::string>::const_iterator it = this->Sources.begin();
- it != this->Sources.end(); ++it) {
- const std::string& absFilename = cmsys::SystemTools::GetRealPath(*it);
- // Parse source file for MOC/UIC
- if (!this->ParseSourceFile(absFilename, mocsIncluded, mocDepends,
- uisIncluded, this->MocRelaxedMode)) {
- return false;
- }
- // Find additional headers
- this->SearchHeadersForSourceFile(absFilename, mocHeaderFiles,
- uicHeaderFiles);
- }
-
- // Parse headers
- for (std::vector<std::string>::const_iterator it = this->Headers.begin();
- it != this->Headers.end(); ++it) {
- const std::string& headerName = cmsys::SystemTools::GetRealPath(*it);
- if (!this->MocSkip(headerName)) {
- mocHeaderFiles.insert(headerName);
- }
- if (!this->UicSkip(headerName)) {
- uicHeaderFiles.insert(headerName);
- }
- }
- if (!this->ParseHeaders(mocHeaderFiles, uicHeaderFiles, mocsIncluded,
- mocsNotIncluded, mocDepends, uisIncluded)) {
- return false;
- };
-
- // Generate files
- if (!this->MocGenerateAll(mocsIncluded, mocsNotIncluded, mocDepends)) {
- return false;
- }
- if (!this->UicGenerateAll(uisIncluded)) {
- return false;
- }
- if (!this->RccGenerateAll()) {
- return false;
- }
-
- return true;
-}
-
-/**
- * @brief Tests if the C++ content requires moc processing
- * @return True if moc is required
- */
-bool cmQtAutoGenerators::MocRequired(const std::string& contentText,
- std::string* macroName)
-{
- for (unsigned int ii = 0; ii != cmArraySize(this->MocMacroFilters); ++ii) {
- MocMacroFilter& filter = this->MocMacroFilters[ii];
- // Run a simple find string operation before the expensive
- // regular expression check
- if (contentText.find(filter.first) != std::string::npos) {
- if (filter.second.find(contentText)) {
- // Return macro name on demand
- if (macroName != CM_NULLPTR) {
- *macroName = filter.first;
- }
- return true;
- }
- }
- }
- return false;
-}
-
-void cmQtAutoGenerators::MocFindDepends(
- const std::string& absFilename, const std::string& contentText,
- std::map<std::string, std::set<std::string> >& mocDepends)
-{
- for (std::vector<MocDependFilter>::iterator fit =
- this->MocDependFilters.begin();
- fit != this->MocDependFilters.end(); ++fit) {
- MocDependFilter& filter = *fit;
- // Run a simple find string operation before the expensive
- // regular expression check
- if (contentText.find(filter.key) != std::string::npos) {
- // Run regular expression check loop
- const std::string sourcePath = SubDirPrefix(absFilename);
- const char* contentChars = contentText.c_str();
- while (filter.regExp.find(contentChars)) {
- // Evaluate match
- const std::string match = filter.regExp.match(1);
- if (!match.empty()) {
- // Find the dependency file
- std::string incFile;
- if (this->MocFindIncludedFile(incFile, sourcePath, match)) {
- mocDepends[absFilename].insert(incFile);
- if (this->Verbose) {
- this->LogInfo("AutoMoc: Found dependency:\n " +
- Quoted(absFilename) + "\n " + Quoted(incFile));
- }
- } else {
- this->LogWarning("AutoMoc: Warning: " + Quoted(absFilename) +
- "\n" + "Could not find dependency file " +
- Quoted(match));
- }
- }
- contentChars += filter.regExp.end();
- }
- }
- }
-}
-
-/**
- * @brief Tests if the file should be ignored for moc scanning
- * @return True if the file should be ignored
- */
-bool cmQtAutoGenerators::MocSkip(const std::string& absFilename) const
-{
- if (this->MocEnabled()) {
- // Test if the file name is on the skip list
- if (!ListContains(this->MocSkipList, absFilename)) {
- return false;
- }
- }
- return true;
-}
-
-/**
- * @brief Tests if the file name is in the skip list
- */
-bool cmQtAutoGenerators::UicSkip(const std::string& absFilename) const
-{
- if (this->UicEnabled()) {
- // Test if the file name is on the skip list
- if (!ListContains(this->UicSkipList, absFilename)) {
- return false;
- }
- }
- return true;
-}
-
-/**
- * @return True on success
- */
-bool cmQtAutoGenerators::ParseSourceFile(
- const std::string& absFilename,
- std::map<std::string, std::string>& mocsIncluded,
- std::map<std::string, std::set<std::string> >& mocDepends,
- std::map<std::string, std::vector<std::string> >& uisIncluded, bool relaxed)
-{
- std::string contentText;
- bool success = ReadAll(contentText, absFilename);
- if (success) {
- if (!contentText.empty()) {
- // Parse source contents for MOC
- if (success && !this->MocSkip(absFilename)) {
- success = this->MocParseSourceContent(
- absFilename, contentText, mocsIncluded, mocDepends, relaxed);
- }
- // Parse source contents for UIC
- if (success && !this->UicSkip(absFilename)) {
- this->UicParseContent(absFilename, contentText, uisIncluded);
- }
- } else {
- std::ostringstream ost;
- ost << "AutoGen: Warning: The file is empty:\n"
- << Quoted(absFilename) << "\n";
- this->LogWarning(ost.str());
- }
- } else {
- std::ostringstream ost;
- ost << "AutoGen: Error: Could not read file:\n" << Quoted(absFilename);
- this->LogError(ost.str());
- }
- return success;
-}
-
-void cmQtAutoGenerators::UicParseContent(
- const std::string& absFilename, const std::string& contentText,
- std::map<std::string, std::vector<std::string> >& uisIncluded)
-{
- if (this->Verbose) {
- this->LogInfo("AutoUic: Checking " + absFilename);
- }
-
- const char* contentChars = contentText.c_str();
- if (strstr(contentChars, "ui_") != CM_NULLPTR) {
- while (this->UicRegExpInclude.find(contentChars)) {
- uisIncluded[absFilename].push_back(this->UicRegExpInclude.match(1));
- contentChars += this->UicRegExpInclude.end();
- }
- }
-}
-
-/**
- * @return True on success
- */
-bool cmQtAutoGenerators::MocParseSourceContent(
- const std::string& absFilename, const std::string& contentText,
- std::map<std::string, std::string>& mocsIncluded,
- std::map<std::string, std::set<std::string> >& mocDepends, bool relaxed)
-{
- if (this->Verbose) {
- this->LogInfo("AutoMoc: Checking " + absFilename);
- }
-
- const std::string scannedFileAbsPath = SubDirPrefix(absFilename);
- const std::string scannedFileBasename =
- cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
-
- std::string macroName;
- const bool requiresMoc = this->MocRequired(contentText, &macroName);
- bool ownDotMocIncluded = false;
- std::string ownMocUnderscoreInclude;
- std::string ownMocUnderscoreHeader;
-
- // first a simple string check for "moc" is *much* faster than the regexp,
- // and if the string search already fails, we don't have to try the
- // expensive regexp
- const char* contentChars = contentText.c_str();
- if (strstr(contentChars, "moc") != CM_NULLPTR) {
- // Iterate over all included moc files
- while (this->MocRegExpInclude.find(contentChars)) {
- const std::string incString = this->MocRegExpInclude.match(1);
- // Basename of the moc include
- const std::string incSubDir(SubDirPrefix(incString));
- const std::string incBasename =
- cmsys::SystemTools::GetFilenameWithoutLastExtension(incString);
-
- // If the moc include is of the moc_foo.cpp style we expect
- // the Q_OBJECT class declaration in a header file.
- // If the moc include is of the foo.moc style we need to look for
- // a Q_OBJECT macro in the current source file, if it contains the
- // macro we generate the moc file from the source file.
- if (cmHasLiteralPrefix(incBasename, "moc_")) {
- // Include: moc_FOO.cxx
- // Remove the moc_ part
- const std::string incRealBasename = incBasename.substr(4);
- const std::string headerToMoc =
- this->MocFindHeader(scannedFileAbsPath, incSubDir + incRealBasename);
- if (!headerToMoc.empty()) {
- if (!this->MocSkip(headerToMoc)) {
- // Register moc job
- mocsIncluded[headerToMoc] = incString;
- this->MocFindDepends(headerToMoc, contentText, mocDepends);
- // Store meta information for relaxed mode
- if (relaxed && (incRealBasename == scannedFileBasename)) {
- ownMocUnderscoreInclude = incString;
- ownMocUnderscoreHeader = headerToMoc;
- }
- }
- } else {
- std::ostringstream ost;
- ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n"
- << "The file includes the moc file " << Quoted(incString)
- << ", but could not find header "
- << Quoted(incRealBasename + "{" +
- JoinExts(this->HeaderExtensions) + "}");
- ;
- this->LogError(ost.str());
- return false;
- }
- } else {
- // Include: FOO.moc
- std::string fileToMoc;
- if (relaxed) {
- // Mode: Relaxed
- if (requiresMoc && (incBasename == scannedFileBasename)) {
- // Include self
- fileToMoc = absFilename;
- ownDotMocIncluded = true;
- } else {
- // In relaxed mode try to find a header instead but issue a warning
- const std::string headerToMoc =
- this->MocFindHeader(scannedFileAbsPath, incSubDir + incBasename);
- if (!headerToMoc.empty()) {
- if (!this->MocSkip(headerToMoc)) {
- // This is for KDE4 compatibility:
- fileToMoc = headerToMoc;
- if (!requiresMoc && (incBasename == scannedFileBasename)) {
- std::ostringstream ost;
- ost
- << "AutoMoc: Warning: " << Quoted(absFilename) << "\n"
- << "The file includes the moc file " << Quoted(incString)
- << ", but does not contain a Q_OBJECT or Q_GADGET macro.\n"
- << "Running moc on " << Quoted(headerToMoc) << "!\n"
- << "Include " << Quoted("moc_" + incBasename + ".cpp")
- << " for a compatibility with strict mode (see "
- "CMAKE_AUTOMOC_RELAXED_MODE).\n";
- this->LogWarning(ost.str());
- } else {
- std::ostringstream ost;
- ost << "AutoMoc: Warning: " << Quoted(absFilename) << "\n"
- << "The file includes the moc file " << Quoted(incString)
- << " instead of "
- << Quoted("moc_" + incBasename + ".cpp") << ".\n"
- << "Running moc on " << Quoted(headerToMoc) << "!\n"
- << "Include " << Quoted("moc_" + incBasename + ".cpp")
- << " for compatibility with strict mode (see "
- "CMAKE_AUTOMOC_RELAXED_MODE).\n";
- this->LogWarning(ost.str());
- }
- }
- } else {
- std::ostringstream ost;
- ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n"
- << "The file includes the moc file " << Quoted(incString)
- << ", which seems to be the moc file from a different "
- "source file. CMake also could not find a matching "
- "header.";
- this->LogError(ost.str());
- return false;
- }
- }
- } else {
- // Mode: Strict
- if (incBasename == scannedFileBasename) {
- // Include self
- fileToMoc = absFilename;
- ownDotMocIncluded = true;
- // Accept but issue a warning if moc isn't required
- if (!requiresMoc) {
- std::ostringstream ost;
- ost << "AutoMoc: Warning: " << Quoted(absFilename) << "\n"
- << "The file includes the moc file " << Quoted(incString)
- << ", but does not contain a Q_OBJECT or Q_GADGET "
- "macro.";
- this->LogWarning(ost.str());
- }
- } else {
- // Don't allow FOO.moc include other than self in strict mode
- std::ostringstream ost;
- ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n"
- << "The file includes the moc file " << Quoted(incString)
- << ", which seems to be the moc file from a different "
- "source file. This is not supported. Include "
- << Quoted(scannedFileBasename + ".moc")
- << " to run moc on this source file.";
- this->LogError(ost.str());
- return false;
- }
- }
- if (!fileToMoc.empty()) {
- mocsIncluded[fileToMoc] = incString;
- this->MocFindDepends(fileToMoc, contentText, mocDepends);
- }
- }
- // Forward content pointer
- contentChars += this->MocRegExpInclude.end();
- }
- }
-
- if (requiresMoc && !ownDotMocIncluded) {
- // In this case, check whether the scanned file itself contains a Q_OBJECT.
- // If this is the case, the moc_foo.cpp should probably be generated from
- // foo.cpp instead of foo.h, because otherwise it won't build.
- // But warn, since this is not how it is supposed to be used.
- if (relaxed && !ownMocUnderscoreInclude.empty()) {
- // This is for KDE4 compatibility:
- std::ostringstream ost;
- ost << "AutoMoc: Warning: " << Quoted(absFilename) << "\n"
- << "The file contains a " << macroName
- << " macro, but does not include "
- << Quoted(scannedFileBasename + ".moc") << ", but instead includes "
- << Quoted(ownMocUnderscoreInclude) << ".\n"
- << "Running moc on " << Quoted(absFilename) << "!\n"
- << "Better include " << Quoted(scannedFileBasename + ".moc")
- << " for compatibility with strict mode (see "
- "CMAKE_AUTOMOC_RELAXED_MODE).";
- this->LogWarning(ost.str());
-
- // Use scanned source file instead of scanned header file as moc source
- mocsIncluded[absFilename] = ownMocUnderscoreInclude;
- this->MocFindDepends(absFilename, contentText, mocDepends);
- // Remove
- mocsIncluded.erase(ownMocUnderscoreHeader);
- } else {
- // Otherwise always error out since it will not compile:
- std::ostringstream ost;
- ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n"
- << "The file contains a " << macroName
- << " macro, but does not include "
- << Quoted(scannedFileBasename + ".moc") << "!\n"
- << "Consider adding the include or enabling SKIP_AUTOMOC for this "
- "file.";
- this->LogError(ost.str());
- return false;
- }
- }
-
- return true;
-}
-
-void cmQtAutoGenerators::MocParseHeaderContent(
- const std::string& absFilename, const std::string& contentText,
- std::map<std::string, std::string>& mocsNotIncluded,
- std::map<std::string, std::set<std::string> >& mocDepends)
-{
- // Log
- if (this->Verbose) {
- this->LogInfo("AutoMoc: Checking " + absFilename);
- }
- if (this->MocRequired(contentText)) {
- // Register moc job
- mocsNotIncluded[absFilename] =
- this->ChecksumedPath(absFilename, "moc_", this->ConfigSuffix + ".cpp");
- this->MocFindDepends(absFilename, contentText, mocDepends);
- }
-}
-
-void cmQtAutoGenerators::SearchHeadersForSourceFile(
- const std::string& absFilename, std::set<std::string>& mocHeaderFiles,
- std::set<std::string>& uicHeaderFiles) const
-{
- std::string basepaths[2];
- {
- std::string bpath = SubDirPrefix(absFilename);
- bpath += cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
- // search for default header files and private header files
- basepaths[0] = bpath;
- basepaths[1] = bpath + "_p";
- }
-
- for (const std::string* bpit = cmArrayBegin(basepaths);
- bpit != cmArrayEnd(basepaths); ++bpit) {
- std::string headerName;
- if (this->FindHeader(headerName, *bpit)) {
- // Moc headers
- if (!this->MocSkip(absFilename) && !this->MocSkip(headerName)) {
- mocHeaderFiles.insert(headerName);
- }
- // Uic headers
- if (!this->UicSkip(absFilename) && !this->UicSkip(headerName)) {
- uicHeaderFiles.insert(headerName);
- }
- }
- }
-}
-
-bool cmQtAutoGenerators::ParseHeaders(
- const std::set<std::string>& mocHeaderFiles,
- const std::set<std::string>& uicHeaderFiles,
- const std::map<std::string, std::string>& mocsIncluded,
- std::map<std::string, std::string>& mocsNotIncluded,
- std::map<std::string, std::set<std::string> >& mocDepends,
- std::map<std::string, std::vector<std::string> >& uisIncluded)
-{
- bool success = true;
- // Merged header files list to read files only once
- std::set<std::string> headerFiles;
- headerFiles.insert(mocHeaderFiles.begin(), mocHeaderFiles.end());
- headerFiles.insert(uicHeaderFiles.begin(), uicHeaderFiles.end());
-
- for (std::set<std::string>::const_iterator hIt = headerFiles.begin();
- hIt != headerFiles.end(); ++hIt) {
- const std::string& headerName = *hIt;
- std::string contentText;
- if (ReadAll(contentText, headerName)) {
- // Parse header content for MOC
- if ((mocHeaderFiles.find(headerName) != mocHeaderFiles.end()) &&
- (mocsIncluded.find(headerName) == mocsIncluded.end())) {
- this->MocParseHeaderContent(headerName, contentText, mocsNotIncluded,
- mocDepends);
- }
- // Parse header content for UIC
- if (uicHeaderFiles.find(headerName) != uicHeaderFiles.end()) {
- this->UicParseContent(headerName, contentText, uisIncluded);
- }
- } else {
- std::ostringstream ost;
- ost << "AutoGen: Error: Could not read header file:\n"
- << Quoted(headerName);
- this->LogError(ost.str());
- success = false;
- break;
- }
- }
- return success;
-}
-
-bool cmQtAutoGenerators::MocGenerateAll(
- const std::map<std::string, std::string>& mocsIncluded,
- const std::map<std::string, std::string>& mocsNotIncluded,
- const std::map<std::string, std::set<std::string> >& mocDepends)
-{
- if (!this->MocEnabled()) {
- return true;
- }
-
- // Look for name collisions
- {
- std::multimap<std::string, std::string> collisions;
- // Test merged map of included and notIncluded
- std::map<std::string, std::string> mergedMocs(mocsIncluded);
- mergedMocs.insert(mocsNotIncluded.begin(), mocsNotIncluded.end());
- if (this->NameCollisionTest(mergedMocs, collisions)) {
- std::ostringstream ost;
- ost << "AutoMoc: Error: "
- "The same moc file will be generated "
- "from different sources.\n"
- "To avoid this error either\n"
- "- rename the source files or\n"
- "- do not include the (moc_NAME.cpp|NAME.moc) file";
- this->LogErrorNameCollision(ost.str(), collisions);
- return false;
- }
- }
-
- // Generate moc_predefs
- if (!this->MocPredefsCmd.empty()) {
- if (this->MocSettingsChanged ||
- FileAbsentOrOlder(this->MocPredefsFileAbs, this->SettingsFile)) {
- this->LogBold("Generating MOC predefs " + this->MocPredefsFileRel);
-
- std::string output;
- {
- // Compose command
- std::vector<std::string> cmd = this->MocPredefsCmd;
- // Add includes
- cmd.insert(cmd.end(), this->MocIncludes.begin(),
- this->MocIncludes.end());
- // Add definitions
- for (std::vector<std::string>::const_iterator it =
- this->MocDefinitions.begin();
- it != this->MocDefinitions.end(); ++it) {
- cmd.push_back("-D" + (*it));
- }
- // Add options
- cmd.insert(cmd.end(), this->MocOptions.begin(),
- this->MocOptions.end());
- // Execute command
- if (!this->RunCommand(cmd, output, false)) {
- {
- std::ostringstream ost;
- ost << "AutoMoc: Error: moc predefs generation command failed\n";
- ost << "AutoMoc: Command:\n" << QuotedCommand(cmd) << "\n";
- ost << "AutoMoc: Command output:\n" << output << "\n";
- this->LogError(ost.str());
- }
- return false;
- }
- }
- // (Re)write predefs file only on demand
- if (this->FileDiffers(this->MocPredefsFileAbs, output)) {
- if (this->FileWrite("AutoMoc", this->MocPredefsFileAbs, output)) {
- this->MocPredefsChanged = true;
- } else {
- return false;
- }
- }
- }
- }
-
- // Generate moc files that are included by source files.
- for (std::map<std::string, std::string>::const_iterator it =
- mocsIncluded.begin();
- it != mocsIncluded.end(); ++it) {
- if (!this->MocGenerateFile(it->first, it->second, mocDepends, true)) {
- if (this->MocRunFailed) {
- return false;
- }
- }
- }
-
- // Generate moc files that are _not_ included by source files.
- bool mocCompFileGenerated = false;
- for (std::map<std::string, std::string>::const_iterator it =
- mocsNotIncluded.begin();
- it != mocsNotIncluded.end(); ++it) {
- if (this->MocGenerateFile(it->first, it->second, mocDepends, false)) {
- mocCompFileGenerated = true;
- } else {
- if (this->MocRunFailed) {
- return false;
- }
- }
- }
-
- // Compose mocs compilation file content
- std::string automocSource;
- {
- std::ostringstream ost;
- ost << "/* This file is autogenerated, do not edit*/\n";
- if (mocsNotIncluded.empty()) {
- // Dummy content
- ost << "enum some_compilers { need_more_than_nothing };\n";
- } else {
- // Valid content
- for (std::map<std::string, std::string>::const_iterator it =
- mocsNotIncluded.begin();
- it != mocsNotIncluded.end(); ++it) {
- ost << "#include \"" << it->second << "\"\n";
- }
- }
- automocSource = ost.str();
- }
-
- if (this->FileDiffers(this->MocCompFileAbs, automocSource)) {
- // Actually write mocs compilation file
- this->LogBold("Generating MOC compilation " + this->MocCompFileRel);
- if (!this->FileWrite("AutoMoc", this->MocCompFileAbs, automocSource)) {
- return false;
- }
- } else if (mocCompFileGenerated) {
- // Only touch mocs compilation file
- if (this->Verbose) {
- this->LogInfo("Touching MOC compilation " + this->MocCompFileRel);
- }
- cmSystemTools::Touch(this->MocCompFileAbs, false);
- }
-
- return true;
-}
-
-/**
- * @return True if a moc file was created. False may indicate an error.
- */
-bool cmQtAutoGenerators::MocGenerateFile(
- const std::string& sourceFile, const std::string& mocFileName,
- const std::map<std::string, std::set<std::string> >& mocDepends,
- bool included)
-{
- bool mocGenerated = false;
- bool generateMoc = this->MocSettingsChanged || this->MocPredefsChanged;
-
- const std::string mocFileRel =
- included ? (this->AutogenIncludeDir + mocFileName) : mocFileName;
- const std::string mocFileAbs =
- cmSystemTools::CollapseCombinedPath(this->AutogenBuildDir, mocFileRel);
-
- if (!generateMoc) {
- // Test if the source file is newer that the build file
- generateMoc = FileAbsentOrOlder(mocFileAbs, sourceFile);
- if (!generateMoc) {
- // Test if a dependency file changed
- std::map<std::string, std::set<std::string> >::const_iterator dit =
- mocDepends.find(sourceFile);
- if (dit != mocDepends.end()) {
- for (std::set<std::string>::const_iterator fit = dit->second.begin();
- fit != dit->second.end(); ++fit) {
- if (FileAbsentOrOlder(mocFileAbs, *fit)) {
- generateMoc = true;
- break;
- }
- }
- }
- }
- }
- if (generateMoc) {
- // Log
- this->LogBold("Generating MOC source " + mocFileRel);
-
- // Make sure the parent directory exists
- if (this->MakeParentDirectory("AutoMoc", mocFileAbs)) {
- // Compose moc command
- std::vector<std::string> cmd;
- cmd.push_back(this->MocExecutable);
- // Add includes
- cmd.insert(cmd.end(), this->MocIncludes.begin(),
- this->MocIncludes.end());
- // Add definitions
- for (std::vector<std::string>::const_iterator it =
- this->MocDefinitions.begin();
- it != this->MocDefinitions.end(); ++it) {
- cmd.push_back("-D" + (*it));
- }
- // Add options
- cmd.insert(cmd.end(), this->MocOptions.begin(), this->MocOptions.end());
- // Add predefs include
- if (!this->MocPredefsFileAbs.empty()) {
- cmd.push_back("--include");
- cmd.push_back(this->MocPredefsFileAbs);
- }
- cmd.push_back("-o");
- cmd.push_back(mocFileAbs);
- cmd.push_back(sourceFile);
-
- // Execute moc command
- std::string output;
- if (this->RunCommand(cmd, output)) {
- // Success
- mocGenerated = true;
- } else {
- // Command failed
- {
- std::ostringstream ost;
- ost << "AutoMoc: Error: moc process failed for\n";
- ost << Quoted(mocFileRel) << "\n";
- ost << "AutoMoc: Command:\n" << QuotedCommand(cmd) << "\n";
- ost << "AutoMoc: Command output:\n" << output << "\n";
- this->LogError(ost.str());
- }
- cmSystemTools::RemoveFile(mocFileAbs);
- this->MocRunFailed = true;
- }
- } else {
- // Parent directory creation failed
- this->MocRunFailed = true;
- }
- }
- return mocGenerated;
-}
-
-bool cmQtAutoGenerators::UicFindIncludedFile(std::string& absFile,
- const std::string& sourceFile,
- const std::string& searchPath,
- const std::string& searchFile)
-{
- bool success = false;
- std::vector<std::string> testFiles;
- // Collect search paths list
- {
- const std::string searchFileFull = searchPath + searchFile;
- // Vicinity of the source
- {
- const std::string sourcePath = SubDirPrefix(sourceFile);
- testFiles.push_back(sourcePath + searchFile);
- if (!searchPath.empty()) {
- testFiles.push_back(sourcePath + searchFileFull);
- }
- }
- // AUTOUIC search paths
- if (!this->UicSearchPaths.empty()) {
- for (std::vector<std::string>::const_iterator iit =
- this->UicSearchPaths.begin();
- iit != this->UicSearchPaths.end(); ++iit) {
- testFiles.push_back(*iit + "/" + searchFile);
- }
- if (!searchPath.empty()) {
- for (std::vector<std::string>::const_iterator iit =
- this->UicSearchPaths.begin();
- iit != this->UicSearchPaths.end(); ++iit) {
- testFiles.push_back(*iit + "/" + searchFileFull);
- }
- }
- }
- }
-
- // Search for the .ui file!
- for (std::vector<std::string>::const_iterator iit = testFiles.begin();
- iit != testFiles.end(); ++iit) {
- const std::string& testFile = *iit;
- if (cmsys::SystemTools::FileExists(testFile.c_str())) {
- absFile = cmsys::SystemTools::GetRealPath(testFile);
- success = true;
- break;
- }
- }
-
- // Log error
- if (!success) {
- std::ostringstream ost;
- ost << "AutoUic: Error: " << Quoted(sourceFile) << "\n";
- ost << "Could not find " << Quoted(searchFile) << " in\n";
- for (std::vector<std::string>::const_iterator iit = testFiles.begin();
- iit != testFiles.end(); ++iit) {
- ost << " " << Quoted(*iit) << "\n";
- }
- this->LogError(ost.str());
- }
-
- return success;
-}
-
-bool cmQtAutoGenerators::UicGenerateAll(
- const std::map<std::string, std::vector<std::string> >& uisIncluded)
-{
- if (!this->UicEnabled()) {
- return true;
- }
-
- // single map with input / output names
- std::map<std::string, std::map<std::string, std::string> > sourceGenMap;
- {
- // Collision lookup map
- std::map<std::string, std::string> testMap;
- // Compile maps
- for (std::map<std::string, std::vector<std::string> >::const_iterator sit =
- uisIncluded.begin();
- sit != uisIncluded.end(); ++sit) {
- const std::string& source(sit->first);
- const std::vector<std::string>& sourceIncs(sit->second);
- // insert new source/destination map
- std::map<std::string, std::string>& uiGenMap = sourceGenMap[source];
- for (std::vector<std::string>::const_iterator uit = sourceIncs.begin();
- uit != sourceIncs.end(); ++uit) {
- // Remove ui_ from the begin filename by substr()
- const std::string uiBasePath = SubDirPrefix(*uit);
- const std::string uiBaseName =
- cmsys::SystemTools::GetFilenameWithoutLastExtension(*uit).substr(3);
- const std::string uiFileName = uiBaseName + ".ui";
- std::string uiInputFile;
- if (UicFindIncludedFile(uiInputFile, source, uiBasePath, uiFileName)) {
- std::string uiOutputFile = uiBasePath + "ui_" + uiBaseName + ".h";
- cmSystemTools::ReplaceString(uiOutputFile, "..", "__");
- uiGenMap[uiInputFile] = uiOutputFile;
- testMap[uiInputFile] = uiOutputFile;
- } else {
- return false;
- }
- }
- }
- // look for name collisions
- {
- std::multimap<std::string, std::string> collisions;
- if (this->NameCollisionTest(testMap, collisions)) {
- std::ostringstream ost;
- ost << "AutoUic: Error: The same ui_NAME.h file will be generated "
- "from different sources.\n"
- "To avoid this error rename the source files.\n";
- this->LogErrorNameCollision(ost.str(), collisions);
- return false;
- }
- }
- }
-
- // generate ui files
- for (std::map<std::string,
- std::map<std::string, std::string> >::const_iterator it =
- sourceGenMap.begin();
- it != sourceGenMap.end(); ++it) {
- for (std::map<std::string, std::string>::const_iterator sit =
- it->second.begin();
- sit != it->second.end(); ++sit) {
- if (!this->UicGenerateFile(it->first, sit->first, sit->second)) {
- if (this->UicRunFailed) {
- return false;
- }
- }
- }
- }
-
- return true;
-}
-
-/**
- * @return True if a uic file was created. False may indicate an error.
- */
-bool cmQtAutoGenerators::UicGenerateFile(const std::string& realName,
- const std::string& uiInputFile,
- const std::string& uiOutputFile)
-{
- bool uicGenerated = false;
- bool generateUic = this->UicSettingsChanged;
-
- const std::string uicFileRel = this->AutogenIncludeDir + uiOutputFile;
- const std::string uicFileAbs =
- cmSystemTools::CollapseCombinedPath(this->AutogenBuildDir, uicFileRel);
-
- if (!generateUic) {
- // Test if the source file is newer that the build file
- generateUic = FileAbsentOrOlder(uicFileAbs, uiInputFile);
- }
- if (generateUic) {
- // Log
- this->LogBold("Generating UIC header " + uicFileRel);
-
- // Make sure the parent directory exists
- if (this->MakeParentDirectory("AutoUic", uicFileAbs)) {
- // Compose uic command
- std::vector<std::string> cmd;
- cmd.push_back(this->UicExecutable);
- {
- std::vector<std::string> allOpts = this->UicTargetOptions;
- std::map<std::string, std::string>::const_iterator optionIt =
- this->UicOptions.find(uiInputFile);
- if (optionIt != this->UicOptions.end()) {
- std::vector<std::string> fileOpts;
- cmSystemTools::ExpandListArgument(optionIt->second, fileOpts);
- UicMergeOptions(allOpts, fileOpts, (this->QtMajorVersion == "5"));
- }
- cmd.insert(cmd.end(), allOpts.begin(), allOpts.end());
- }
- cmd.push_back("-o");
- cmd.push_back(uicFileAbs);
- cmd.push_back(uiInputFile);
-
- std::string output;
- if (this->RunCommand(cmd, output)) {
- // Success
- uicGenerated = true;
- } else {
- // Command failed
- {
- std::ostringstream ost;
- ost << "AutoUic: Error: uic process failed for\n";
- ost << Quoted(uicFileRel) << " needed by\n";
- ost << Quoted(realName) << "\n";
- ost << "AutoUic: Command:\n" << QuotedCommand(cmd) << "\n";
- ost << "AutoUic: Command output:\n" << output << "\n";
- this->LogError(ost.str());
- }
- cmSystemTools::RemoveFile(uicFileAbs);
- this->UicRunFailed = true;
- }
- } else {
- // Parent directory creation failed
- this->UicRunFailed = true;
- }
- }
- return uicGenerated;
-}
-
-bool cmQtAutoGenerators::RccGenerateAll()
-{
- if (!this->RccEnabled()) {
- return true;
- }
-
- // generate single map with input / output names
- std::map<std::string, std::string> qrcGenMap;
- {
- const std::string qrcPrefix = "qrc_";
- const std::string qrcSuffix = this->ConfigSuffix + ".cpp";
- for (std::vector<std::string>::const_iterator si =
- this->RccSources.begin();
- si != this->RccSources.end(); ++si) {
- const std::string ext =
- cmsys::SystemTools::GetFilenameLastExtension(*si);
- if (ext == ".qrc") {
- qrcGenMap[*si] = this->ChecksumedPath(*si, qrcPrefix, qrcSuffix);
- }
- }
- }
-
- // look for name collisions
- {
- std::multimap<std::string, std::string> collisions;
- if (this->NameCollisionTest(qrcGenMap, collisions)) {
- std::ostringstream ost;
- ost << "AutoRcc: Error: The same qrc_NAME.cpp file"
- " will be generated from different sources.\n"
- "To avoid this error rename the source .qrc files.\n";
- this->LogErrorNameCollision(ost.str(), collisions);
- return false;
- }
- }
-
- // generate qrc files
- for (std::map<std::string, std::string>::const_iterator si =
- qrcGenMap.begin();
- si != qrcGenMap.end(); ++si) {
- bool unique = FileNameIsUnique(si->first, qrcGenMap);
- if (!this->RccGenerateFile(si->first, si->second, unique)) {
- if (this->RccRunFailed) {
- return false;
- }
- }
- }
- return true;
-}
-
-/**
- * @return True if a rcc file was created. False may indicate an error.
- */
-bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
- const std::string& rccOutputFile,
- bool unique_n)
-{
- bool rccGenerated = false;
- bool generateRcc = this->RccSettingsChanged;
-
- const std::string rccBuildFile =
- cmSystemTools::CollapseCombinedPath(this->AutogenBuildDir, rccOutputFile);
-
- if (!generateRcc) {
- // Test if the resources list file is newer than build file
- generateRcc = FileAbsentOrOlder(rccBuildFile, rccInputFile);
- if (!generateRcc) {
- // Acquire input file list
- std::vector<std::string> readFiles;
- const std::vector<std::string>* files = &this->RccInputs[rccInputFile];
- if (files->empty()) {
- // Read input file list from qrc file
- std::string error;
- if (cmQtAutoGeneratorCommon::RccListInputs(
- this->QtMajorVersion, this->RccExecutable, rccInputFile,
- readFiles, &error)) {
- files = &readFiles;
- } else {
- files = CM_NULLPTR;
- this->LogError(error);
- this->RccRunFailed = true;
- }
- }
- // Test if any input file is newer than the build file
- if (files != CM_NULLPTR) {
- for (std::vector<std::string>::const_iterator it = files->begin();
- it != files->end(); ++it) {
- if (FileAbsentOrOlder(rccBuildFile, *it)) {
- generateRcc = true;
- break;
- }
- }
- }
- }
- }
- if (generateRcc) {
- // Log
- this->LogBold("Generating RCC source " + rccOutputFile);
-
- // Make sure the parent directory exists
- if (this->MakeParentDirectory("AutoRcc", rccBuildFile)) {
- // Compose symbol name
- std::string symbolName =
- cmsys::SystemTools::GetFilenameWithoutLastExtension(rccInputFile);
- if (!unique_n) {
- symbolName += "_";
- symbolName += FPathChecksum.getPart(rccInputFile);
- }
- // Replace '-' with '_'. The former is valid for
- // file names but not for symbol names.
- std::replace(symbolName.begin(), symbolName.end(), '-', '_');
-
- // Compose rcc command
- std::vector<std::string> cmd;
- cmd.push_back(this->RccExecutable);
- {
- std::map<std::string, std::string>::const_iterator optionIt =
- this->RccOptions.find(rccInputFile);
- if (optionIt != this->RccOptions.end()) {
- cmSystemTools::ExpandListArgument(optionIt->second, cmd);
- }
- }
- cmd.push_back("-name");
- cmd.push_back(symbolName);
- cmd.push_back("-o");
- cmd.push_back(rccBuildFile);
- cmd.push_back(rccInputFile);
-
- std::string output;
- if (this->RunCommand(cmd, output)) {
- // Success
- rccGenerated = true;
- } else {
- // Command failed
- {
- std::ostringstream ost;
- ost << "AutoRcc: Error: rcc process failed for\n";
- ost << Quoted(rccOutputFile) << "\n";
- ost << "AutoRcc: Command:\n" << QuotedCommand(cmd) << "\n";
- ost << "AutoRcc: Command output:\n" << output << "\n";
- this->LogError(ost.str());
- }
- cmSystemTools::RemoveFile(rccBuildFile);
- this->RccRunFailed = true;
- }
- } else {
- // Parent directory creation failed
- this->RccRunFailed = true;
- }
- }
- return rccGenerated;
-}
-
-void cmQtAutoGenerators::LogErrorNameCollision(
- const std::string& message,
- const std::multimap<std::string, std::string>& collisions) const
-{
- typedef std::multimap<std::string, std::string>::const_iterator Iter;
-
- std::ostringstream ost;
- // Add message
- if (!message.empty()) {
- ost << message;
- if (message[message.size() - 1] != '\n') {
- ost << '\n';
- }
- }
- // Append collision list
- for (Iter it = collisions.begin(); it != collisions.end(); ++it) {
- ost << it->first << " : " << it->second << '\n';
- }
- this->LogError(ost.str());
-}
-
-void cmQtAutoGenerators::LogBold(const std::string& message) const
-{
- cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue |
- cmsysTerminal_Color_ForegroundBold,
- message.c_str(), true, this->ColorOutput);
-}
-
-void cmQtAutoGenerators::LogInfo(const std::string& message) const
-{
- std::string msg(message);
- if (!msg.empty()) {
- if (msg[msg.size() - 1] != '\n') {
- msg.push_back('\n');
- }
- cmSystemTools::Stdout(msg.c_str(), msg.size());
- }
-}
-
-void cmQtAutoGenerators::LogWarning(const std::string& message) const
-{
- std::string msg(message);
- if (!msg.empty()) {
- if (msg[msg.size() - 1] != '\n') {
- msg.push_back('\n');
- }
- // Append empty line
- msg.push_back('\n');
- cmSystemTools::Stdout(msg.c_str(), msg.size());
- }
-}
-
-void cmQtAutoGenerators::LogError(const std::string& message) const
-{
- std::string msg(message);
- if (!msg.empty()) {
- if (msg[msg.size() - 1] != '\n') {
- msg.push_back('\n');
- }
- // Append empty line
- msg.push_back('\n');
- cmSystemTools::Stderr(msg.c_str(), msg.size());
- }
-}
-
-/**
- * @brief Collects name collisions as output/input pairs
- * @return True if there were collisions
- */
-bool cmQtAutoGenerators::NameCollisionTest(
- const std::map<std::string, std::string>& genFiles,
- std::multimap<std::string, std::string>& collisions) const
-{
- typedef std::map<std::string, std::string>::const_iterator Iter;
- typedef std::map<std::string, std::string>::value_type VType;
- for (Iter ait = genFiles.begin(); ait != genFiles.end(); ++ait) {
- bool first_match(true);
- for (Iter bit = (++Iter(ait)); bit != genFiles.end(); ++bit) {
- if (ait->second == bit->second) {
- if (first_match) {
- if (collisions.find(ait->second) != collisions.end()) {
- // We already know of this collision from before
- break;
- }
- collisions.insert(VType(ait->second, ait->first));
- first_match = false;
- }
- collisions.insert(VType(bit->second, bit->first));
- }
- }
- }
-
- return !collisions.empty();
-}
-
-/**
- * @brief Generates a file path based on the checksum of the source file path
- * @return The path
- */
-std::string cmQtAutoGenerators::ChecksumedPath(
- const std::string& sourceFile, const std::string& basePrefix,
- const std::string& baseSuffix) const
-{
- std::string res = FPathChecksum.getPart(sourceFile);
- res += "/";
- res += basePrefix;
- res += cmsys::SystemTools::GetFilenameWithoutLastExtension(sourceFile);
- res += baseSuffix;
- return res;
-}
-
-/**
- * @brief Generates the parent directory of the given file on demand
- * @return True on success
- */
-bool cmQtAutoGenerators::MakeParentDirectory(const char* logPrefix,
- const std::string& filename) const
-{
- bool success = true;
- const std::string dirName = cmSystemTools::GetFilenamePath(filename);
- if (!dirName.empty()) {
- success = cmsys::SystemTools::MakeDirectory(dirName);
- if (!success) {
- std::string error = logPrefix;
- error += ": Error: Parent directory creation failed for ";
- error += Quoted(filename);
- this->LogError(error);
- }
- }
- return success;
-}
-
-bool cmQtAutoGenerators::FileDiffers(const std::string& filename,
- const std::string& content)
-{
- bool differs = true;
- {
- std::string oldContents;
- if (ReadAll(oldContents, filename)) {
- differs = (oldContents != content);
- }
- }
- return differs;
-}
-
-bool cmQtAutoGenerators::FileWrite(const char* logPrefix,
- const std::string& filename,
- const std::string& content)
-{
- std::string error;
- // Make sure the parent directory exists
- if (this->MakeParentDirectory(logPrefix, filename)) {
- cmsys::ofstream outfile;
- outfile.open(filename.c_str(), std::ios::trunc);
- if (outfile) {
- outfile << content;
- // Check for write errors
- if (!outfile.good()) {
- error = logPrefix;
- error += ": Error writing ";
- error += Quoted(filename);
- }
- } else {
- error = logPrefix;
- error = ": Error opening ";
- error += Quoted(filename);
- }
- }
- if (!error.empty()) {
- this->LogError(error);
- return false;
- }
- return true;
-}
-
-/**
- * @brief Runs a command and returns true on success
- * @return True on success
- */
-bool cmQtAutoGenerators::RunCommand(const std::vector<std::string>& command,
- std::string& output, bool verbose) const
-{
- // Log command
- if (this->Verbose) {
- this->LogInfo(QuotedCommand(command));
- }
- // Execute command
- int retVal = 0;
- bool res = cmSystemTools::RunSingleCommand(
- command, &output, &output, &retVal, CM_NULLPTR,
- verbose ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE);
- return (res && (retVal == 0));
-}
-
-/**
- * @brief Tries to find the header file to the given file base path by
- * appending different header extensions
- * @return True on success
- */
-bool cmQtAutoGenerators::FindHeader(std::string& header,
- const std::string& testBasePath) const
-{
- for (std::vector<std::string>::const_iterator ext =
- this->HeaderExtensions.begin();
- ext != this->HeaderExtensions.end(); ++ext) {
- std::string testFilePath(testBasePath);
- testFilePath += '.';
- testFilePath += (*ext);
- if (cmsys::SystemTools::FileExists(testFilePath.c_str())) {
- header = testFilePath;
- return true;
- }
- }
- return false;
-}
-
-std::string cmQtAutoGenerators::MocFindHeader(
- const std::string& sourcePath, const std::string& includeBase) const
-{
- std::string header;
- // Search in vicinity of the source
- if (!this->FindHeader(header, sourcePath + includeBase)) {
- // Search in include directories
- for (std::vector<std::string>::const_iterator iit =
- this->MocIncludePaths.begin();
- iit != this->MocIncludePaths.end(); ++iit) {
- const std::string fullPath = ((*iit) + '/' + includeBase);
- if (FindHeader(header, fullPath)) {
- break;
- }
- }
- }
- // Sanitize
- if (!header.empty()) {
- header = cmsys::SystemTools::GetRealPath(header);
- }
- return header;
-}
-
-bool cmQtAutoGenerators::MocFindIncludedFile(
- std::string& absFile, const std::string& sourcePath,
- const std::string& includeString) const
-{
- bool success = false;
- // Search in vicinity of the source
- {
- std::string testPath = sourcePath;
- testPath += includeString;
- if (cmsys::SystemTools::FileExists(testPath.c_str())) {
- absFile = cmsys::SystemTools::GetRealPath(testPath);
- success = true;
- }
- }
- // Search in include directories
- if (!success) {
- for (std::vector<std::string>::const_iterator iit =
- this->MocIncludePaths.begin();
- iit != this->MocIncludePaths.end(); ++iit) {
- const std::string fullPath = ((*iit) + '/' + includeString);
- if (cmsys::SystemTools::FileExists(fullPath.c_str())) {
- absFile = cmsys::SystemTools::GetRealPath(fullPath);
- success = true;
- break;
- }
- }
- }
- return success;
-}
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
deleted file mode 100644
index 337aa17fd..000000000
--- a/Source/cmQtAutoGenerators.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmQtAutoGenerators_h
-#define cmQtAutoGenerators_h
-
-#include "cmConfigure.h" // IWYU pragma: keep
-
-#include "cmFilePathChecksum.h"
-#include "cmsys/RegularExpression.hxx"
-
-#include <map>
-#include <set>
-#include <string>
-#include <utility>
-#include <vector>
-
-class cmMakefile;
-
-class cmQtAutoGenerators
-{
-public:
- cmQtAutoGenerators();
- bool Run(const std::string& targetDirectory, const std::string& config);
-
-private:
- // -- Types
-
- /// @brief Used to extract additional dependencies from content text
- struct MocDependFilter
- {
- std::string key;
- cmsys::RegularExpression regExp;
- };
- typedef std::pair<std::string, cmsys::RegularExpression> MocMacroFilter;
-
- // -- Configuration
- bool MocDependFilterPush(const std::string& key, const std::string& regExp);
- bool ReadAutogenInfoFile(cmMakefile* makefile,
- const std::string& targetDirectory,
- const std::string& config);
-
- bool MocEnabled() const { return !this->MocExecutable.empty(); }
- bool UicEnabled() const { return !this->UicExecutable.empty(); }
- bool RccEnabled() const { return !this->RccExecutable.empty(); }
-
- // -- Settings file
- void SettingsFileRead(cmMakefile* makefile);
- bool SettingsFileWrite();
-
- bool AnySettingsChanged() const
- {
- return (this->MocSettingsChanged || this->RccSettingsChanged ||
- this->UicSettingsChanged);
- }
-
- // -- Init and run
- void Init(cmMakefile* makefile);
- bool RunAutogen();
-
- // -- Content analysis
- bool MocRequired(const std::string& contentText,
- std::string* macroName = CM_NULLPTR);
- void MocFindDepends(
- const std::string& absFilename, const std::string& contentText,
- std::map<std::string, std::set<std::string> >& mocDepends);
-
- bool MocSkip(const std::string& absFilename) const;
- bool UicSkip(const std::string& absFilename) const;
-
- bool ParseSourceFile(
- const std::string& absFilename,
- std::map<std::string, std::string>& mocsIncluded,
- std::map<std::string, std::set<std::string> >& mocDepends,
- std::map<std::string, std::vector<std::string> >& includedUis,
- bool relaxed);
-
- void SearchHeadersForSourceFile(const std::string& absFilename,
- std::set<std::string>& mocHeaderFiles,
- std::set<std::string>& uicHeaderFiles) const;
-
- bool ParseHeaders(
- const std::set<std::string>& mocHeaderFiles,
- const std::set<std::string>& uicHeaderFiles,
- const std::map<std::string, std::string>& mocsIncluded,
- std::map<std::string, std::string>& mocsNotIncluded,
- std::map<std::string, std::set<std::string> >& mocDepends,
- std::map<std::string, std::vector<std::string> >& includedUis);
-
- void UicParseContent(
- const std::string& fileName, const std::string& contentText,
- std::map<std::string, std::vector<std::string> >& includedUis);
-
- bool MocParseSourceContent(
- const std::string& absFilename, const std::string& contentText,
- std::map<std::string, std::string>& mocsIncluded,
- std::map<std::string, std::set<std::string> >& mocDepends, bool relaxed);
-
- void MocParseHeaderContent(
- const std::string& absFilename, const std::string& contentText,
- std::map<std::string, std::string>& mocsNotIncluded,
- std::map<std::string, std::set<std::string> >& mocDepends);
-
- // -- Moc file generation
- bool MocGenerateAll(
- const std::map<std::string, std::string>& mocsIncluded,
- const std::map<std::string, std::string>& mocsNotIncluded,
- const std::map<std::string, std::set<std::string> >& mocDepends);
- bool MocGenerateFile(
- const std::string& sourceFile, const std::string& mocFileName,
- const std::map<std::string, std::set<std::string> >& mocDepends,
- bool included);
-
- // -- Uic file generation
- bool UicFindIncludedFile(std::string& absFile, const std::string& sourceFile,
- const std::string& searchPath,
- const std::string& searchFile);
- bool UicGenerateAll(
- const std::map<std::string, std::vector<std::string> >& includedUis);
- bool UicGenerateFile(const std::string& realName,
- const std::string& uiInputFile,
- const std::string& uiOutputFile);
-
- // -- Rcc file generation
- bool RccGenerateAll();
- bool RccGenerateFile(const std::string& qrcInputFile,
- const std::string& qrcOutputFile, bool unique_n);
-
- // -- Logging
- void LogErrorNameCollision(
- const std::string& message,
- const std::multimap<std::string, std::string>& collisions) const;
- void LogBold(const std::string& message) const;
- void LogInfo(const std::string& message) const;
- void LogWarning(const std::string& message) const;
- void LogError(const std::string& message) const;
- void LogCommand(const std::vector<std::string>& command) const;
-
- // -- Utility
- bool NameCollisionTest(
- const std::map<std::string, std::string>& genFiles,
- std::multimap<std::string, std::string>& collisions) const;
- std::string ChecksumedPath(const std::string& sourceFile,
- const std::string& basePrefix,
- const std::string& baseSuffix) const;
- bool MakeParentDirectory(const char* logPrefix,
- const std::string& filename) const;
- bool FileDiffers(const std::string& filename, const std::string& content);
- bool FileWrite(const char* logPrefix, const std::string& filename,
- const std::string& content);
-
- bool RunCommand(const std::vector<std::string>& command, std::string& output,
- bool verbose = true) const;
-
- bool FindHeader(std::string& header, const std::string& testBasePath) const;
-
- std::string MocFindHeader(const std::string& sourcePath,
- const std::string& includeBase) const;
- bool MocFindIncludedFile(std::string& absFile, const std::string& sourceFile,
- const std::string& includeString) const;
-
- // -- Meta
- std::string ConfigSuffix;
- // -- Directories
- std::string ProjectSourceDir;
- std::string ProjectBinaryDir;
- std::string CurrentSourceDir;
- std::string CurrentBinaryDir;
- std::string AutogenBuildDir;
- std::string AutogenIncludeDir;
- // -- Qt environment
- std::string QtMajorVersion;
- std::string MocExecutable;
- std::string UicExecutable;
- std::string RccExecutable;
- // -- File lists
- std::vector<std::string> Sources;
- std::vector<std::string> Headers;
- std::vector<std::string> HeaderExtensions;
- cmFilePathChecksum FPathChecksum;
- // -- Settings
- bool IncludeProjectDirsBefore;
- bool Verbose;
- bool ColorOutput;
- std::string SettingsFile;
- std::string SettingsStringMoc;
- std::string SettingsStringUic;
- std::string SettingsStringRcc;
- // -- Moc
- bool MocSettingsChanged;
- bool MocPredefsChanged;
- bool MocRelaxedMode;
- bool MocRunFailed;
- std::string MocCompFileRel;
- std::string MocCompFileAbs;
- std::string MocPredefsFileRel;
- std::string MocPredefsFileAbs;
- std::vector<std::string> MocSkipList;
- std::vector<std::string> MocIncludePaths;
- std::vector<std::string> MocIncludes;
- std::vector<std::string> MocDefinitions;
- std::vector<std::string> MocOptions;
- std::vector<std::string> MocPredefsCmd;
- std::vector<MocDependFilter> MocDependFilters;
- MocMacroFilter MocMacroFilters[2];
- cmsys::RegularExpression MocRegExpInclude;
- // -- Uic
- bool UicSettingsChanged;
- bool UicRunFailed;
- std::vector<std::string> UicSkipList;
- std::vector<std::string> UicTargetOptions;
- std::map<std::string, std::string> UicOptions;
- std::vector<std::string> UicSearchPaths;
- cmsys::RegularExpression UicRegExpInclude;
- // -- Rcc
- bool RccSettingsChanged;
- bool RccRunFailed;
- std::vector<std::string> RccSources;
- std::map<std::string, std::string> RccOptions;
- std::map<std::string, std::vector<std::string> > RccInputs;
-};
-
-#endif
diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx
new file mode 100644
index 000000000..f8b898152
--- /dev/null
+++ b/Source/cmQtAutoMocUic.cxx
@@ -0,0 +1,2688 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmQtAutoMocUic.h"
+
+#include <algorithm>
+#include <atomic>
+#include <cstddef>
+#include <map>
+#include <mutex>
+#include <set>
+#include <string>
+#include <unordered_map>
+#include <unordered_set>
+#include <utility>
+#include <vector>
+
+#include <cm/memory>
+#include <cm/string_view>
+
+#include "cmsys/FStream.hxx"
+#include "cmsys/RegularExpression.hxx"
+
+#include "cm_jsoncpp_value.h"
+
+#include "cmAlgorithms.h"
+#include "cmCryptoHash.h"
+#include "cmFileTime.h"
+#include "cmGeneratedFileStream.h"
+#include "cmQtAutoGen.h"
+#include "cmQtAutoGenerator.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmWorkerPool.h"
+
+#if defined(__APPLE__)
+# include <unistd.h>
+#endif
+
+namespace {
+
+constexpr std::size_t MocUnderscoreLength = 4; // Length of "moc_"
+constexpr std::size_t UiUnderscoreLength = 3; // Length of "ui_"
+
+/** \class cmQtAutoMocUicT
+ * \brief AUTOMOC and AUTOUIC generator
+ */
+class cmQtAutoMocUicT : public cmQtAutoGenerator
+{
+public:
+ cmQtAutoMocUicT();
+ ~cmQtAutoMocUicT() override;
+
+ cmQtAutoMocUicT(cmQtAutoMocUicT const&) = delete;
+ cmQtAutoMocUicT& operator=(cmQtAutoMocUicT const&) = delete;
+
+public:
+ // -- Types
+
+ /** Include string with sub parts. */
+ struct IncludeKeyT
+ {
+ IncludeKeyT(std::string const& key, std::size_t basePrefixLength);
+
+ std::string Key; // Full include string
+ std::string Dir; // Include directory
+ std::string Base; // Base part of the include file name
+ };
+
+ /** Search key plus regular expression pair. */
+ struct KeyExpT
+ {
+ KeyExpT(std::string key, std::string const& exp)
+ : Key(std::move(key))
+ , Exp(exp)
+ {
+ }
+
+ std::string Key;
+ cmsys::RegularExpression Exp;
+ };
+
+ /** Source file parsing cache. */
+ class ParseCacheT
+ {
+ public:
+ // -- Types
+
+ /** Entry of the file parsing cache. */
+ struct FileT
+ {
+ void Clear();
+
+ struct MocT
+ {
+ std::string Macro;
+ struct IncludeT
+ {
+ std::vector<IncludeKeyT> Underscore;
+ std::vector<IncludeKeyT> Dot;
+ } Include;
+ std::vector<std::string> Depends;
+ } Moc;
+
+ struct UicT
+ {
+ std::vector<IncludeKeyT> Include;
+ std::vector<std::string> Depends;
+ } Uic;
+ };
+ using FileHandleT = std::shared_ptr<FileT>;
+ using GetOrInsertT = std::pair<FileHandleT, bool>;
+
+ public:
+ ParseCacheT();
+ ~ParseCacheT();
+
+ bool ReadFromFile(std::string const& fileName);
+ bool WriteToFile(std::string const& fileName);
+
+ //! Always returns a valid handle
+ GetOrInsertT GetOrInsert(std::string const& fileName);
+
+ private:
+ std::unordered_map<std::string, FileHandleT> Map_;
+ };
+
+ /** Source file data. */
+ class SourceFileT
+ {
+ public:
+ SourceFileT(std::string fileName)
+ : FileName(std::move(fileName))
+ {
+ }
+
+ public:
+ std::string FileName;
+ cmFileTime FileTime;
+ ParseCacheT::FileHandleT ParseData;
+ std::string BuildPath;
+ bool IsHeader = false;
+ bool Moc = false;
+ bool Uic = false;
+ };
+ using SourceFileHandleT = std::shared_ptr<SourceFileT>;
+ using SourceFileMapT = std::map<std::string, SourceFileHandleT>;
+
+ /** Meta compiler file mapping information. */
+ struct MappingT
+ {
+ SourceFileHandleT SourceFile;
+ std::string OutputFile;
+ std::string IncludeString;
+ std::vector<SourceFileHandleT> IncluderFiles;
+ };
+ using MappingHandleT = std::shared_ptr<MappingT>;
+ using MappingMapT = std::map<std::string, MappingHandleT>;
+
+ /** Common settings. */
+ class BaseSettingsT
+ {
+ public:
+ // -- Constructors
+ BaseSettingsT();
+ ~BaseSettingsT();
+
+ BaseSettingsT(BaseSettingsT const&) = delete;
+ BaseSettingsT& operator=(BaseSettingsT const&) = delete;
+
+ // -- Attributes
+ // - Config
+ bool MultiConfig = false;
+ unsigned int QtVersionMajor = 4;
+ unsigned int ThreadCount = 0;
+ // - Directories
+ std::string AutogenBuildDir;
+ std::string AutogenIncludeDir;
+ // - Files
+ std::string CMakeExecutable;
+ cmFileTime CMakeExecutableTime;
+ std::string ParseCacheFile;
+ std::vector<std::string> HeaderExtensions;
+ };
+
+ /** Shared common variables. */
+ class BaseEvalT
+ {
+ public:
+ // -- Parse Cache
+ bool ParseCacheChanged = false;
+ cmFileTime ParseCacheTime;
+ ParseCacheT ParseCache;
+
+ // -- Sources
+ SourceFileMapT Headers;
+ SourceFileMapT Sources;
+ };
+
+ /** Moc settings. */
+ class MocSettingsT
+ {
+ public:
+ // -- Constructors
+ MocSettingsT();
+ ~MocSettingsT();
+
+ MocSettingsT(MocSettingsT const&) = delete;
+ MocSettingsT& operator=(MocSettingsT const&) = delete;
+
+ // -- Const methods
+ bool skipped(std::string const& fileName) const;
+ std::string MacrosString() const;
+
+ // -- Attributes
+ bool Enabled = false;
+ bool SettingsChanged = false;
+ bool RelaxedMode = false;
+ bool PathPrefix = false;
+ cmFileTime ExecutableTime;
+ std::string Executable;
+ std::string CompFileAbs;
+ std::string PredefsFileAbs;
+ std::unordered_set<std::string> SkipList;
+ std::vector<std::string> IncludePaths;
+ std::vector<std::string> Definitions;
+ std::vector<std::string> OptionsIncludes;
+ std::vector<std::string> OptionsDefinitions;
+ std::vector<std::string> OptionsExtra;
+ std::vector<std::string> PredefsCmd;
+ std::vector<KeyExpT> DependFilters;
+ std::vector<KeyExpT> MacroFilters;
+ cmsys::RegularExpression RegExpInclude;
+ };
+
+ /** Moc shared variables. */
+ class MocEvalT
+ {
+ public:
+ // -- predefines file
+ cmFileTime PredefsTime;
+ // -- Mappings
+ MappingMapT HeaderMappings;
+ MappingMapT SourceMappings;
+ MappingMapT Includes;
+ // -- Discovered files
+ SourceFileMapT HeadersDiscovered;
+ // -- Output directories
+ std::unordered_set<std::string> OutputDirs;
+ // -- Mocs compilation
+ bool CompUpdated = false;
+ std::vector<std::string> CompFiles;
+ };
+
+ /** Uic settings. */
+ class UicSettingsT
+ {
+ public:
+ struct UiFile
+ {
+ std::vector<std::string> Options;
+ };
+
+ public:
+ UicSettingsT();
+ ~UicSettingsT();
+
+ UicSettingsT(UicSettingsT const&) = delete;
+ UicSettingsT& operator=(UicSettingsT const&) = delete;
+
+ // -- Const methods
+ bool skipped(std::string const& fileName) const;
+
+ // -- Attributes
+ bool Enabled = false;
+ bool SettingsChanged = false;
+ cmFileTime ExecutableTime;
+ std::string Executable;
+ std::unordered_set<std::string> SkipList;
+ std::vector<std::string> Options;
+ std::unordered_map<std::string, UiFile> UiFiles;
+ std::vector<std::string> SearchPaths;
+ cmsys::RegularExpression RegExpInclude;
+ };
+
+ /** Uic shared variables. */
+ class UicEvalT
+ {
+ public:
+ // -- Discovered files
+ SourceFileMapT UiFiles;
+ // -- Mappings
+ MappingMapT Includes;
+ // -- Output directories
+ std::unordered_set<std::string> OutputDirs;
+ };
+
+ /** Abstract job class for concurrent job processing. */
+ class JobT : public cmWorkerPool::JobT
+ {
+ protected:
+ /** Protected default constructor. */
+ JobT(bool fence = false)
+ : cmWorkerPool::JobT(fence)
+ {
+ }
+
+ //! Get the generator. Only valid during Process() call!
+ cmQtAutoMocUicT* Gen() const
+ {
+ return static_cast<cmQtAutoMocUicT*>(UserData());
+ };
+
+ // -- Accessors. Only valid during Process() call!
+ Logger const& Log() const { return Gen()->Log(); }
+ BaseSettingsT const& BaseConst() const { return Gen()->BaseConst(); }
+ BaseEvalT& BaseEval() const { return Gen()->BaseEval(); }
+ MocSettingsT const& MocConst() const { return Gen()->MocConst(); }
+ MocEvalT& MocEval() const { return Gen()->MocEval(); }
+ UicSettingsT const& UicConst() const { return Gen()->UicConst(); }
+ UicEvalT& UicEval() const { return Gen()->UicEval(); }
+
+ // -- Logging
+ std::string MessagePath(cm::string_view path) const
+ {
+ return Gen()->MessagePath(path);
+ }
+ // - Error logging with automatic abort
+ void LogError(GenT genType, cm::string_view message) const;
+ void LogCommandError(GenT genType, cm::string_view message,
+ std::vector<std::string> const& command,
+ std::string const& output) const;
+
+ /** @brief Run an external process. Use only during Process() call! */
+ bool RunProcess(GenT genType, cmWorkerPool::ProcessResultT& result,
+ std::vector<std::string> const& command,
+ std::string* infoMessage = nullptr);
+ };
+
+ /** Fence job utility class. */
+ class JobFenceT : public JobT
+ {
+ public:
+ JobFenceT()
+ : JobT(true)
+ {
+ }
+ void Process() override{};
+ };
+
+ /** Generate moc_predefs.h. */
+ class JobMocPredefsT : public JobFenceT
+ {
+ void Process() override;
+ bool Update(std::string* reason) const;
+ };
+
+ /** File parse job base class. */
+ class JobParseT : public JobT
+ {
+ public:
+ JobParseT(SourceFileHandleT fileHandle)
+ : FileHandle(std::move(fileHandle))
+ {
+ }
+
+ protected:
+ bool ReadFile();
+ void CreateKeys(std::vector<IncludeKeyT>& container,
+ std::set<std::string> const& source,
+ std::size_t basePrefixLength);
+ void MocMacro();
+ void MocDependecies();
+ void MocIncludes();
+ void UicIncludes();
+
+ protected:
+ SourceFileHandleT FileHandle;
+ std::string Content;
+ };
+
+ /** Header file parse job. */
+ class JobParseHeaderT : public JobParseT
+ {
+ public:
+ using JobParseT::JobParseT;
+ void Process() override;
+ };
+
+ /** Source file parse job. */
+ class JobParseSourceT : public JobParseT
+ {
+ public:
+ using JobParseT::JobParseT;
+ void Process() override;
+ };
+
+ /** Evaluate cached file parse data - moc. */
+ class JobEvalCacheT : public JobT
+ {
+ protected:
+ std::string MessageSearchLocations() const;
+ std::vector<std::string> SearchLocations;
+ };
+
+ /** Evaluate cached file parse data - moc. */
+ class JobEvalCacheMocT : public JobEvalCacheT
+ {
+ void Process() override;
+ bool EvalHeader(SourceFileHandleT source);
+ bool EvalSource(SourceFileHandleT const& source);
+ bool FindIncludedHeader(SourceFileHandleT& headerHandle,
+ cm::string_view includerDir,
+ cm::string_view includeBase);
+ bool RegisterIncluded(std::string const& includeString,
+ SourceFileHandleT includerFileHandle,
+ SourceFileHandleT sourceFileHandle) const;
+ void RegisterMapping(MappingHandleT mappingHandle) const;
+ std::string MessageHeader(cm::string_view headerBase) const;
+ };
+
+ /** Evaluate cached file parse data - uic. */
+ class JobEvalCacheUicT : public JobEvalCacheT
+ {
+ void Process() override;
+ bool EvalFile(SourceFileHandleT const& sourceFileHandle);
+ bool FindIncludedUi(cm::string_view sourceDirPrefix,
+ cm::string_view includePrefix);
+ bool RegisterMapping(std::string const& includeString,
+ SourceFileHandleT includerFileHandle);
+
+ std::string UiName;
+ SourceFileHandleT UiFileHandle;
+ };
+
+ /** Evaluate cached file parse data - finish */
+ class JobEvalCacheFinishT : public JobFenceT
+ {
+ void Process() override;
+ };
+
+ /** Dependency probing base job. */
+ class JobProbeDepsT : public JobT
+ {
+ };
+
+ /** Probes file dependencies and generates moc compile jobs. */
+ class JobProbeDepsMocT : public JobProbeDepsT
+ {
+ void Process() override;
+ bool Generate(MappingHandleT const& mapping, bool compFile) const;
+ bool Probe(MappingT const& mapping, std::string* reason) const;
+ std::pair<std::string, cmFileTime> FindDependency(
+ std::string const& sourceDir, std::string const& includeString) const;
+ };
+
+ /** Probes file dependencies and generates uic compile jobs. */
+ class JobProbeDepsUicT : public JobProbeDepsT
+ {
+ void Process() override;
+ bool Probe(MappingT const& mapping, std::string* reason) const;
+ };
+
+ /** Dependency probing finish job. */
+ class JobProbeDepsFinishT : public JobFenceT
+ {
+ void Process() override;
+ };
+
+ /** Meta compiler base job. */
+ class JobCompileT : public JobT
+ {
+ public:
+ JobCompileT(MappingHandleT uicMapping, std::unique_ptr<std::string> reason)
+ : Mapping(std::move(uicMapping))
+ , Reason(std::move(reason))
+ {
+ }
+
+ protected:
+ MappingHandleT Mapping;
+ std::unique_ptr<std::string> Reason;
+ };
+
+ /** moc compiles a file. */
+ class JobCompileMocT : public JobCompileT
+ {
+ public:
+ using JobCompileT::JobCompileT;
+ void Process() override;
+ };
+
+ /** uic compiles a file. */
+ class JobCompileUicT : public JobCompileT
+ {
+ public:
+ using JobCompileT::JobCompileT;
+ void Process() override;
+ };
+
+ /** Generate mocs_compilation.cpp. */
+ class JobMocsCompilationT : public JobFenceT
+ {
+ private:
+ void Process() override;
+ };
+
+ /** @brief The last job. */
+ class JobFinishT : public JobFenceT
+ {
+ private:
+ void Process() override;
+ };
+
+ // -- Const settings interface
+ BaseSettingsT const& BaseConst() const { return this->BaseConst_; }
+ BaseEvalT& BaseEval() { return this->BaseEval_; }
+ MocSettingsT const& MocConst() const { return this->MocConst_; }
+ MocEvalT& MocEval() { return this->MocEval_; }
+ UicSettingsT const& UicConst() const { return this->UicConst_; }
+ UicEvalT& UicEval() { return this->UicEval_; }
+
+ // -- Parallel job processing interface
+ cmWorkerPool& WorkerPool() { return WorkerPool_; }
+ void AbortError() { Abort(true); }
+ void AbortSuccess() { Abort(false); }
+
+ // -- Utility
+ std::string AbsoluteBuildPath(cm::string_view relativePath) const;
+ std::string AbsoluteIncludePath(cm::string_view relativePath) const;
+ template <class JOBTYPE>
+ void CreateParseJobs(SourceFileMapT const& sourceMap);
+ std::string CollapseFullPathTS(std::string const& path) const;
+
+private:
+ // -- Abstract processing interface
+ bool InitFromInfo(InfoT const& info) override;
+ void InitJobs();
+ bool Process() override;
+ // -- Settings file
+ void SettingsFileRead();
+ bool SettingsFileWrite();
+ // -- Parse cache
+ void ParseCacheRead();
+ bool ParseCacheWrite();
+ // -- Thread processing
+ void Abort(bool error);
+ // -- Generation
+ bool CreateDirectories();
+
+private:
+ // -- Settings
+ BaseSettingsT BaseConst_;
+ BaseEvalT BaseEval_;
+ MocSettingsT MocConst_;
+ MocEvalT MocEval_;
+ UicSettingsT UicConst_;
+ UicEvalT UicEval_;
+ // -- Settings file
+ std::string SettingsFile_;
+ std::string SettingsStringMoc_;
+ std::string SettingsStringUic_;
+ // -- Worker thread pool
+ std::atomic<bool> JobError_ = ATOMIC_VAR_INIT(false);
+ cmWorkerPool WorkerPool_;
+ // -- Concurrent processing
+ mutable std::mutex CMakeLibMutex_;
+};
+
+cmQtAutoMocUicT::IncludeKeyT::IncludeKeyT(std::string const& key,
+ std::size_t basePrefixLength)
+ : Key(key)
+ , Dir(SubDirPrefix(key))
+ , Base(cmSystemTools::GetFilenameWithoutLastExtension(key))
+{
+ if (basePrefixLength != 0) {
+ Base = Base.substr(basePrefixLength);
+ }
+}
+
+void cmQtAutoMocUicT::ParseCacheT::FileT::Clear()
+{
+ Moc.Macro.clear();
+ Moc.Include.Underscore.clear();
+ Moc.Include.Dot.clear();
+ Moc.Depends.clear();
+
+ Uic.Include.clear();
+ Uic.Depends.clear();
+}
+
+cmQtAutoMocUicT::ParseCacheT::GetOrInsertT
+cmQtAutoMocUicT::ParseCacheT::GetOrInsert(std::string const& fileName)
+{
+ // Find existing entry
+ {
+ auto it = Map_.find(fileName);
+ if (it != Map_.end()) {
+ return GetOrInsertT{ it->second, false };
+ }
+ }
+
+ // Insert new entry
+ return GetOrInsertT{
+ Map_.emplace(fileName, std::make_shared<FileT>()).first->second, true
+ };
+}
+
+cmQtAutoMocUicT::ParseCacheT::ParseCacheT() = default;
+cmQtAutoMocUicT::ParseCacheT::~ParseCacheT() = default;
+
+bool cmQtAutoMocUicT::ParseCacheT::ReadFromFile(std::string const& fileName)
+{
+ cmsys::ifstream fin(fileName.c_str());
+ if (!fin) {
+ return false;
+ }
+ FileHandleT fileHandle;
+
+ std::string line;
+ while (std::getline(fin, line)) {
+ // Check if this an empty or a comment line
+ if (line.empty() || line.front() == '#') {
+ continue;
+ }
+ // Drop carriage return character at the end
+ if (line.back() == '\r') {
+ line.pop_back();
+ if (line.empty()) {
+ continue;
+ }
+ }
+ // Check if this a file name line
+ if (line.front() != ' ') {
+ fileHandle = GetOrInsert(line).first;
+ continue;
+ }
+
+ // Bad line or bad file handle
+ if (!fileHandle || (line.size() < 6)) {
+ continue;
+ }
+
+ constexpr std::size_t offset = 5;
+ if (cmHasLiteralPrefix(line, " mmc:")) {
+ fileHandle->Moc.Macro = line.substr(offset);
+ continue;
+ }
+ if (cmHasLiteralPrefix(line, " miu:")) {
+ fileHandle->Moc.Include.Underscore.emplace_back(line.substr(offset),
+ MocUnderscoreLength);
+ continue;
+ }
+ if (cmHasLiteralPrefix(line, " mid:")) {
+ fileHandle->Moc.Include.Dot.emplace_back(line.substr(offset), 0);
+ continue;
+ }
+ if (cmHasLiteralPrefix(line, " mdp:")) {
+ fileHandle->Moc.Depends.emplace_back(line.substr(offset));
+ continue;
+ }
+ if (cmHasLiteralPrefix(line, " uic:")) {
+ fileHandle->Uic.Include.emplace_back(line.substr(offset),
+ UiUnderscoreLength);
+ continue;
+ }
+ if (cmHasLiteralPrefix(line, " udp:")) {
+ fileHandle->Uic.Depends.emplace_back(line.substr(offset));
+ continue;
+ }
+ }
+ return true;
+}
+
+bool cmQtAutoMocUicT::ParseCacheT::WriteToFile(std::string const& fileName)
+{
+ cmGeneratedFileStream ofs(fileName);
+ if (!ofs) {
+ return false;
+ }
+ ofs << "# Generated by CMake. Changes will be overwritten." << std::endl;
+ for (auto const& pair : Map_) {
+ ofs << pair.first << std::endl;
+ FileT const& file = *pair.second;
+ if (!file.Moc.Macro.empty()) {
+ ofs << " mmc:" << file.Moc.Macro << std::endl;
+ }
+ for (IncludeKeyT const& item : file.Moc.Include.Underscore) {
+ ofs << " miu:" << item.Key << std::endl;
+ }
+ for (IncludeKeyT const& item : file.Moc.Include.Dot) {
+ ofs << " mid:" << item.Key << std::endl;
+ }
+ for (std::string const& item : file.Moc.Depends) {
+ ofs << " mdp:" << item << std::endl;
+ }
+ for (IncludeKeyT const& item : file.Uic.Include) {
+ ofs << " uic:" << item.Key << std::endl;
+ }
+ for (std::string const& item : file.Uic.Depends) {
+ ofs << " udp:" << item << std::endl;
+ }
+ }
+ return ofs.Close();
+}
+
+cmQtAutoMocUicT::BaseSettingsT::BaseSettingsT() = default;
+cmQtAutoMocUicT::BaseSettingsT::~BaseSettingsT() = default;
+
+cmQtAutoMocUicT::MocSettingsT::MocSettingsT()
+{
+ RegExpInclude.compile(
+ "(^|\n)[ \t]*#[ \t]*include[ \t]+"
+ "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]");
+}
+
+cmQtAutoMocUicT::MocSettingsT::~MocSettingsT() = default;
+
+bool cmQtAutoMocUicT::MocSettingsT::skipped(std::string const& fileName) const
+{
+ return (!Enabled || (SkipList.find(fileName) != SkipList.end()));
+}
+
+std::string cmQtAutoMocUicT::MocSettingsT::MacrosString() const
+{
+ std::string res;
+ const auto itB = MacroFilters.cbegin();
+ const auto itE = MacroFilters.cend();
+ const auto itL = itE - 1;
+ auto itC = itB;
+ for (; itC != itE; ++itC) {
+ // Separator
+ if (itC != itB) {
+ if (itC != itL) {
+ res += ", ";
+ } else {
+ res += " or ";
+ }
+ }
+ // Key
+ res += itC->Key;
+ }
+ return res;
+}
+
+cmQtAutoMocUicT::UicSettingsT::UicSettingsT()
+{
+ RegExpInclude.compile("(^|\n)[ \t]*#[ \t]*include[ \t]+"
+ "[\"<](([^ \">]+/)?ui_[^ \">/]+\\.h)[\">]");
+}
+
+cmQtAutoMocUicT::UicSettingsT::~UicSettingsT() = default;
+
+bool cmQtAutoMocUicT::UicSettingsT::skipped(std::string const& fileName) const
+{
+ return (!Enabled || (SkipList.find(fileName) != SkipList.end()));
+}
+
+void cmQtAutoMocUicT::JobT::LogError(GenT genType,
+ cm::string_view message) const
+{
+ Gen()->AbortError();
+ Gen()->Log().Error(genType, message);
+}
+
+void cmQtAutoMocUicT::JobT::LogCommandError(
+ GenT genType, cm::string_view message,
+ std::vector<std::string> const& command, std::string const& output) const
+{
+ Gen()->AbortError();
+ Gen()->Log().ErrorCommand(genType, message, command, output);
+}
+
+bool cmQtAutoMocUicT::JobT::RunProcess(GenT genType,
+ cmWorkerPool::ProcessResultT& result,
+ std::vector<std::string> const& command,
+ std::string* infoMessage)
+{
+ // Log command
+ if (Log().Verbose()) {
+ cm::string_view info;
+ if (infoMessage != nullptr) {
+ info = *infoMessage;
+ }
+ Log().Info(genType,
+ cmStrCat(info,
+ info.empty() || cmHasSuffix(info, '\n') ? "" : "\n",
+ QuotedCommand(command), '\n'));
+ }
+ // Run command
+ return cmWorkerPool::JobT::RunProcess(result, command,
+ BaseConst().AutogenBuildDir);
+}
+
+void cmQtAutoMocUicT::JobMocPredefsT::Process()
+{
+ // (Re)generate moc_predefs.h on demand
+ std::unique_ptr<std::string> reason;
+ if (Log().Verbose()) {
+ reason = cm::make_unique<std::string>();
+ }
+ if (!Update(reason.get())) {
+ return;
+ }
+ std::string const& predefsFileAbs = MocConst().PredefsFileAbs;
+ {
+ cmWorkerPool::ProcessResultT result;
+ {
+ // Compose command
+ std::vector<std::string> cmd = MocConst().PredefsCmd;
+ // Add definitions
+ cmAppend(cmd, MocConst().OptionsDefinitions);
+ // Add includes
+ cmAppend(cmd, MocConst().OptionsIncludes);
+ // Execute command
+ if (!RunProcess(GenT::MOC, result, cmd, reason.get())) {
+ LogCommandError(GenT::MOC,
+ cmStrCat("The content generation command for ",
+ MessagePath(predefsFileAbs), " failed.\n",
+ result.ErrorMessage),
+ cmd, result.StdOut);
+ return;
+ }
+ }
+
+ // (Re)write predefs file only on demand
+ if (cmQtAutoGenerator::FileDiffers(predefsFileAbs, result.StdOut)) {
+ if (!cmQtAutoGenerator::FileWrite(predefsFileAbs, result.StdOut)) {
+ LogError(
+ GenT::MOC,
+ cmStrCat("Writing ", MessagePath(predefsFileAbs), " failed."));
+ return;
+ }
+ } else {
+ // Touch to update the time stamp
+ if (Log().Verbose()) {
+ Log().Info(GenT::MOC, "Touching " + MessagePath(predefsFileAbs));
+ }
+ if (!cmSystemTools::Touch(predefsFileAbs, false)) {
+ LogError(
+ GenT::MOC,
+ cmStrCat("Touching ", MessagePath(predefsFileAbs), " failed."));
+ return;
+ }
+ }
+ }
+
+ // Read file time afterwards
+ if (!MocEval().PredefsTime.Load(predefsFileAbs)) {
+ LogError(GenT::MOC,
+ cmStrCat("Reading the file time of ", MessagePath(predefsFileAbs),
+ " failed."));
+ return;
+ }
+}
+
+bool cmQtAutoMocUicT::JobMocPredefsT::Update(std::string* reason) const
+{
+ // Test if the file exists
+ if (!MocEval().PredefsTime.Load(MocConst().PredefsFileAbs)) {
+ if (reason != nullptr) {
+ *reason = cmStrCat("Generating ", MessagePath(MocConst().PredefsFileAbs),
+ ", because it doesn't exist.");
+ }
+ return true;
+ }
+
+ // Test if the settings changed
+ if (MocConst().SettingsChanged) {
+ if (reason != nullptr) {
+ *reason = cmStrCat("Generating ", MessagePath(MocConst().PredefsFileAbs),
+ ", because the moc settings changed.");
+ }
+ return true;
+ }
+
+ // Test if the executable is newer
+ {
+ std::string const& exec = MocConst().PredefsCmd.at(0);
+ cmFileTime execTime;
+ if (execTime.Load(exec)) {
+ if (MocEval().PredefsTime.Older(execTime)) {
+ if (reason != nullptr) {
+ *reason =
+ cmStrCat("Generating ", MessagePath(MocConst().PredefsFileAbs),
+ " because it is older than ", MessagePath(exec), '.');
+ }
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool cmQtAutoMocUicT::JobParseT::ReadFile()
+{
+ // Clear old parse information
+ FileHandle->ParseData->Clear();
+ std::string const& fileName = FileHandle->FileName;
+ // Write info
+ if (Log().Verbose()) {
+ Log().Info(GenT::GEN, cmStrCat("Parsing ", MessagePath(fileName)));
+ }
+ // Read file content
+ {
+ std::string error;
+ if (!cmQtAutoGenerator::FileRead(Content, fileName, &error)) {
+ LogError(
+ GenT::GEN,
+ cmStrCat("Could not read ", MessagePath(fileName), ".\n", error));
+ return false;
+ }
+ }
+ // Warn if empty
+ if (Content.empty()) {
+ Log().Warning(GenT::GEN, cmStrCat(MessagePath(fileName), " is empty."));
+ return false;
+ }
+ return true;
+}
+
+void cmQtAutoMocUicT::JobParseT::CreateKeys(
+ std::vector<IncludeKeyT>& container, std::set<std::string> const& source,
+ std::size_t basePrefixLength)
+{
+ if (source.empty()) {
+ return;
+ }
+ container.reserve(source.size());
+ for (std::string const& src : source) {
+ container.emplace_back(src, basePrefixLength);
+ }
+}
+
+void cmQtAutoMocUicT::JobParseT::MocMacro()
+{
+ for (KeyExpT const& filter : MocConst().MacroFilters) {
+ // Run a simple find string check
+ if (Content.find(filter.Key) == std::string::npos) {
+ continue;
+ }
+ // Run the expensive regular expression check loop
+ cmsys::RegularExpressionMatch match;
+ if (filter.Exp.find(Content.c_str(), match)) {
+ // Keep detected macro name
+ FileHandle->ParseData->Moc.Macro = filter.Key;
+ return;
+ }
+ }
+}
+
+void cmQtAutoMocUicT::JobParseT::MocDependecies()
+{
+ if (MocConst().DependFilters.empty()) {
+ return;
+ }
+
+ // Find dependency strings
+ std::set<std::string> parseDepends;
+ for (KeyExpT const& filter : MocConst().DependFilters) {
+ // Run a simple find string check
+ if (Content.find(filter.Key) == std::string::npos) {
+ continue;
+ }
+ // Run the expensive regular expression check loop
+ const char* contentChars = Content.c_str();
+ cmsys::RegularExpressionMatch match;
+ while (filter.Exp.find(contentChars, match)) {
+ {
+ std::string dep = match.match(1);
+ if (!dep.empty()) {
+ parseDepends.emplace(std::move(dep));
+ }
+ }
+ contentChars += match.end();
+ }
+ }
+
+ // Store dependency strings
+ {
+ auto& Depends = FileHandle->ParseData->Moc.Depends;
+ Depends.reserve(parseDepends.size());
+ for (std::string const& item : parseDepends) {
+ Depends.emplace_back(item);
+ // Replace end of line characters in filenames
+ std::string& path = Depends.back();
+ std::replace(path.begin(), path.end(), '\n', ' ');
+ std::replace(path.begin(), path.end(), '\r', ' ');
+ }
+ }
+}
+
+void cmQtAutoMocUicT::JobParseT::MocIncludes()
+{
+ if (Content.find("moc") == std::string::npos) {
+ return;
+ }
+
+ std::set<std::string> underscore;
+ std::set<std::string> dot;
+ {
+ const char* contentChars = Content.c_str();
+ cmsys::RegularExpression const& regExp = MocConst().RegExpInclude;
+ cmsys::RegularExpressionMatch match;
+ while (regExp.find(contentChars, match)) {
+ std::string incString = match.match(2);
+ std::string const incBase =
+ cmSystemTools::GetFilenameWithoutLastExtension(incString);
+ if (cmHasLiteralPrefix(incBase, "moc_")) {
+ // moc_<BASE>.cpp
+ // Remove the moc_ part from the base name
+ underscore.emplace(std::move(incString));
+ } else {
+ // <BASE>.moc
+ dot.emplace(std::move(incString));
+ }
+ // Forward content pointer
+ contentChars += match.end();
+ }
+ }
+ auto& Include = FileHandle->ParseData->Moc.Include;
+ CreateKeys(Include.Underscore, underscore, MocUnderscoreLength);
+ CreateKeys(Include.Dot, dot, 0);
+}
+
+void cmQtAutoMocUicT::JobParseT::UicIncludes()
+{
+ if (Content.find("ui_") == std::string::npos) {
+ return;
+ }
+
+ std::set<std::string> includes;
+ {
+ const char* contentChars = Content.c_str();
+ cmsys::RegularExpression const& regExp = UicConst().RegExpInclude;
+ cmsys::RegularExpressionMatch match;
+ while (regExp.find(contentChars, match)) {
+ includes.emplace(match.match(2));
+ // Forward content pointer
+ contentChars += match.end();
+ }
+ }
+ CreateKeys(FileHandle->ParseData->Uic.Include, includes, UiUnderscoreLength);
+}
+
+void cmQtAutoMocUicT::JobParseHeaderT::Process()
+{
+ if (!ReadFile()) {
+ return;
+ }
+ // Moc parsing
+ if (FileHandle->Moc) {
+ MocMacro();
+ MocDependecies();
+ }
+ // Uic parsing
+ if (FileHandle->Uic) {
+ UicIncludes();
+ }
+}
+
+void cmQtAutoMocUicT::JobParseSourceT::Process()
+{
+ if (!ReadFile()) {
+ return;
+ }
+ // Moc parsing
+ if (FileHandle->Moc) {
+ MocMacro();
+ MocDependecies();
+ MocIncludes();
+ }
+ // Uic parsing
+ if (FileHandle->Uic) {
+ UicIncludes();
+ }
+}
+
+std::string cmQtAutoMocUicT::JobEvalCacheT::MessageSearchLocations() const
+{
+ std::string res;
+ res.reserve(512);
+ for (std::string const& path : SearchLocations) {
+ res += " ";
+ res += MessagePath(path);
+ res += '\n';
+ }
+ return res;
+}
+
+void cmQtAutoMocUicT::JobEvalCacheMocT::Process()
+{
+ // Evaluate headers
+ for (auto const& pair : BaseEval().Headers) {
+ if (!EvalHeader(pair.second)) {
+ return;
+ }
+ }
+ // Evaluate sources
+ for (auto const& pair : BaseEval().Sources) {
+ if (!EvalSource(pair.second)) {
+ return;
+ }
+ }
+}
+
+bool cmQtAutoMocUicT::JobEvalCacheMocT::EvalHeader(SourceFileHandleT source)
+{
+ SourceFileT const& sourceFile = *source;
+ auto const& parseData = sourceFile.ParseData->Moc;
+ if (!source->Moc) {
+ return true;
+ }
+
+ if (!parseData.Macro.empty()) {
+ // Create a new mapping
+ MappingHandleT handle = std::make_shared<MappingT>();
+ handle->SourceFile = std::move(source);
+
+ // Absolute build path
+ if (BaseConst().MultiConfig) {
+ handle->OutputFile = Gen()->AbsoluteIncludePath(sourceFile.BuildPath);
+ } else {
+ handle->OutputFile = Gen()->AbsoluteBuildPath(sourceFile.BuildPath);
+ }
+
+ // Register mapping in headers map
+ RegisterMapping(handle);
+ }
+
+ return true;
+}
+
+bool cmQtAutoMocUicT::JobEvalCacheMocT::EvalSource(
+ SourceFileHandleT const& source)
+{
+ SourceFileT const& sourceFile = *source;
+ auto const& parseData = sourceFile.ParseData->Moc;
+ if (!sourceFile.Moc ||
+ (parseData.Macro.empty() && parseData.Include.Underscore.empty() &&
+ parseData.Include.Dot.empty())) {
+ return true;
+ }
+
+ std::string const sourceDirPrefix = SubDirPrefix(sourceFile.FileName);
+ std::string const sourceBase =
+ cmSystemTools::GetFilenameWithoutLastExtension(sourceFile.FileName);
+
+ // For relaxed mode check if the own "moc_" or ".moc" file is included
+ bool const relaxedMode = MocConst().RelaxedMode;
+ bool sourceIncludesMocUnderscore = false;
+ bool sourceIncludesDotMoc = false;
+ // Check if the sources own "moc_" or ".moc" file is included
+ if (relaxedMode) {
+ for (IncludeKeyT const& incKey : parseData.Include.Underscore) {
+ if (incKey.Base == sourceBase) {
+ sourceIncludesMocUnderscore = true;
+ break;
+ }
+ }
+ }
+ for (IncludeKeyT const& incKey : parseData.Include.Dot) {
+ if (incKey.Base == sourceBase) {
+ sourceIncludesDotMoc = true;
+ break;
+ }
+ }
+
+ // Check if this source needs to be moc processed but doesn't.
+ if (!sourceIncludesDotMoc && !parseData.Macro.empty() &&
+ !(relaxedMode && sourceIncludesMocUnderscore)) {
+ LogError(GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName), "\ncontains a ",
+ Quoted(parseData.Macro), " macro, but does not include ",
+ MessagePath(sourceBase + ".moc"),
+ "!\nConsider to\n - add #include \"", sourceBase,
+ ".moc\"\n - enable SKIP_AUTOMOC for this file"));
+ return false;
+ }
+
+ // Evaluate "moc_" includes
+ for (IncludeKeyT const& incKey : parseData.Include.Underscore) {
+ SourceFileHandleT headerHandle;
+ {
+ std::string const headerBase = cmStrCat(incKey.Dir, incKey.Base);
+ if (!FindIncludedHeader(headerHandle, sourceDirPrefix, headerBase)) {
+ LogError(GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName),
+ "\nincludes the moc file ", MessagePath(incKey.Key),
+ ",\nbut a header ", MessageHeader(headerBase),
+ "\ncould not be found "
+ "in the following directories\n",
+ MessageSearchLocations()));
+ return false;
+ }
+ }
+ // The include might be handled differently in relaxed mode
+ if (relaxedMode && !sourceIncludesDotMoc && !parseData.Macro.empty() &&
+ (incKey.Base == sourceBase)) {
+ // The <BASE>.cpp file includes a Qt macro but does not include the
+ // <BASE>.moc file. In this case, the moc_<BASE>.cpp should probably
+ // be generated from <BASE>.cpp instead of <BASE>.h, because otherwise
+ // it won't build. But warn, since this is not how it is supposed to be
+ // used. This is for KDE4 compatibility.
+
+ // Issue a warning
+ Log().Warning(
+ GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName), "\ncontains a ",
+ Quoted(parseData.Macro), " macro, but does not include ",
+ MessagePath(sourceBase + ".moc"), ".\nInstead it includes ",
+ MessagePath(incKey.Key), ".\nRunning moc on the source\n ",
+ MessagePath(sourceFile.FileName), "!\nBetter include ",
+ MessagePath(sourceBase + ".moc"),
+ " for compatibility with regular mode.\n",
+ "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"));
+
+ // Create mapping
+ if (!RegisterIncluded(incKey.Key, source, source)) {
+ return false;
+ }
+ continue;
+ }
+
+ // Check if header is skipped
+ if (MocConst().skipped(headerHandle->FileName)) {
+ continue;
+ }
+ // Create mapping
+ if (!RegisterIncluded(incKey.Key, source, std::move(headerHandle))) {
+ return false;
+ }
+ }
+
+ // Evaluate ".moc" includes
+ if (relaxedMode) {
+ // Relaxed mode
+ for (IncludeKeyT const& incKey : parseData.Include.Dot) {
+ // Check if this is the sources own .moc file
+ bool const ownMoc = (incKey.Base == sourceBase);
+ if (ownMoc && !parseData.Macro.empty()) {
+ // Create mapping for the regular use case
+ if (!RegisterIncluded(incKey.Key, source, source)) {
+ return false;
+ }
+ continue;
+ }
+ // Try to find a header instead but issue a warning.
+ // This is for KDE4 compatibility.
+ SourceFileHandleT headerHandle;
+ {
+ std::string const headerBase = cmStrCat(incKey.Dir, incKey.Base);
+ if (!FindIncludedHeader(headerHandle, sourceDirPrefix, headerBase)) {
+ LogError(
+ GenT::MOC,
+ cmStrCat(
+ MessagePath(sourceFile.FileName), "\nincludes the moc file ",
+ MessagePath(incKey.Key),
+ ",\nwhich seems to be the moc file from a different source "
+ "file.\nCMAKE_AUTOMOC_RELAXED_MODE:\nAlso a matching header ",
+ MessageHeader(headerBase),
+ "\ncould not be found in the following directories\n",
+ MessageSearchLocations()));
+ return false;
+ }
+ }
+ // Check if header is skipped
+ if (MocConst().skipped(headerHandle->FileName)) {
+ continue;
+ }
+ // Issue a warning
+ if (ownMoc && parseData.Macro.empty()) {
+ Log().Warning(
+ GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName),
+ "\nincludes the moc file ", MessagePath(incKey.Key),
+ ", but does not contain a\n", MocConst().MacrosString(),
+ " macro.\nRunning moc on the header\n ",
+ MessagePath(headerHandle->FileName), "!\nBetter include ",
+ MessagePath("moc_" + incKey.Base + ".cpp"),
+ " for a compatibility with regular mode.\n",
+ "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"));
+ } else {
+ Log().Warning(
+ GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName),
+ "\nincludes the moc file ", MessagePath(incKey.Key),
+ " instead of ", MessagePath("moc_" + incKey.Base + ".cpp"),
+ ".\nRunning moc on the header\n ",
+ MessagePath(headerHandle->FileName), "!\nBetter include ",
+ MessagePath("moc_" + incKey.Base + ".cpp"),
+ " for compatibility with regular mode.\n",
+ "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"));
+ }
+ // Create mapping
+ if (!RegisterIncluded(incKey.Key, source, std::move(headerHandle))) {
+ return false;
+ }
+ }
+ } else {
+ // Strict mode
+ for (IncludeKeyT const& incKey : parseData.Include.Dot) {
+ // Check if this is the sources own .moc file
+ bool const ownMoc = (incKey.Base == sourceBase);
+ if (!ownMoc) {
+ // Don't allow <BASE>.moc include other than own in regular mode
+ LogError(GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName),
+ "\nincludes the moc file ", MessagePath(incKey.Key),
+ ",\nwhich seems to be the moc file from a different "
+ "source file.\nThis is not supported. Include ",
+ MessagePath(sourceBase + ".moc"),
+ " to run moc on this source file."));
+ return false;
+ }
+ // Accept but issue a warning if moc isn't required
+ if (parseData.Macro.empty()) {
+ Log().Warning(GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName),
+ "\nincludes the moc file ",
+ MessagePath(incKey.Key),
+ ", but does not contain a ",
+ MocConst().MacrosString(), " macro."));
+ }
+ // Create mapping
+ if (!RegisterIncluded(incKey.Key, source, source)) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+bool cmQtAutoMocUicT::JobEvalCacheMocT::FindIncludedHeader(
+ SourceFileHandleT& headerHandle, cm::string_view includerDir,
+ cm::string_view includeBase)
+{
+ // Clear search locations
+ SearchLocations.clear();
+
+ auto findHeader = [this,
+ &headerHandle](std::string const& basePath) -> bool {
+ bool found = false;
+ for (std::string const& ext : this->BaseConst().HeaderExtensions) {
+ std::string const testPath =
+ this->Gen()->CollapseFullPathTS(cmStrCat(basePath, '.', ext));
+ cmFileTime fileTime;
+ if (!fileTime.Load(testPath)) {
+ // File not found
+ continue;
+ }
+
+ // Return a known file if it exists already
+ {
+ auto it = BaseEval().Headers.find(testPath);
+ if (it != BaseEval().Headers.end()) {
+ headerHandle = it->second;
+ found = true;
+ break;
+ }
+ }
+
+ // Created and return discovered file entry
+ {
+ SourceFileHandleT& handle = MocEval().HeadersDiscovered[testPath];
+ if (!handle) {
+ handle = std::make_shared<SourceFileT>(testPath);
+ handle->FileTime = fileTime;
+ handle->IsHeader = true;
+ handle->Moc = true;
+ }
+ headerHandle = handle;
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ this->SearchLocations.emplace_back(cmQtAutoGen::ParentDir(basePath));
+ }
+ return found;
+ };
+
+ // Search in vicinity of the source
+ if (findHeader(cmStrCat(includerDir, includeBase))) {
+ return true;
+ }
+ // Search in include directories
+ for (std::string const& path : MocConst().IncludePaths) {
+ if (findHeader(cmStrCat(path, '/', includeBase))) {
+ return true;
+ }
+ }
+ // Return without success
+ return false;
+}
+
+bool cmQtAutoMocUicT::JobEvalCacheMocT::RegisterIncluded(
+ std::string const& includeString, SourceFileHandleT includerFileHandle,
+ SourceFileHandleT sourceFileHandle) const
+{
+ // Check if this file is already included
+ MappingHandleT& handle = MocEval().Includes[includeString];
+ if (handle) {
+ // Check if the output file would be generated from different source files
+ if (handle->SourceFile != sourceFileHandle) {
+ std::string files =
+ cmStrCat(" ", MessagePath(includerFileHandle->FileName), '\n');
+ for (auto const& item : handle->IncluderFiles) {
+ files += cmStrCat(" ", MessagePath(item->FileName), '\n');
+ }
+ LogError(
+ GenT::MOC,
+ cmStrCat("The source files\n", files,
+ "contain the same include string ",
+ MessagePath(includeString),
+ ", but\nthe moc file would be generated from different "
+ "source files\n ",
+ MessagePath(sourceFileHandle->FileName), " and\n ",
+ MessagePath(handle->SourceFile->FileName),
+ ".\nConsider to\n"
+ " - not include the \"moc_<NAME>.cpp\" file\n"
+ " - add a directory prefix to a \"<NAME>.moc\" include "
+ "(e.g \"sub/<NAME>.moc\")\n"
+ " - rename the source file(s)\n"));
+ return false;
+ }
+
+ // The same mapping already exists. Just add to the includers list.
+ handle->IncluderFiles.emplace_back(std::move(includerFileHandle));
+ return true;
+ }
+
+ // Create a new mapping
+ handle = std::make_shared<MappingT>();
+ handle->IncludeString = includeString;
+ handle->IncluderFiles.emplace_back(std::move(includerFileHandle));
+ handle->SourceFile = std::move(sourceFileHandle);
+ handle->OutputFile = Gen()->AbsoluteIncludePath(includeString);
+
+ // Register mapping in sources/headers map
+ RegisterMapping(handle);
+ return true;
+}
+
+void cmQtAutoMocUicT::JobEvalCacheMocT::RegisterMapping(
+ MappingHandleT mappingHandle) const
+{
+ auto& regMap = mappingHandle->SourceFile->IsHeader
+ ? MocEval().HeaderMappings
+ : MocEval().SourceMappings;
+ // Check if source file already gets mapped
+ auto& regHandle = regMap[mappingHandle->SourceFile->FileName];
+ if (!regHandle) {
+ // Yet unknown mapping
+ regHandle = std::move(mappingHandle);
+ } else {
+ // Mappings with include string override those without
+ if (!mappingHandle->IncludeString.empty()) {
+ regHandle = std::move(mappingHandle);
+ }
+ }
+}
+
+std::string cmQtAutoMocUicT::JobEvalCacheMocT::MessageHeader(
+ cm::string_view headerBase) const
+{
+ return MessagePath(cmStrCat(
+ headerBase, ".{", cmJoin(this->BaseConst().HeaderExtensions, ","), '}'));
+}
+
+void cmQtAutoMocUicT::JobEvalCacheUicT::Process()
+{
+ // Prepare buffers
+ SearchLocations.reserve((UicConst().SearchPaths.size() + 1) * 2);
+
+ // Evaluate headers
+ for (auto const& pair : BaseEval().Headers) {
+ if (!EvalFile(pair.second)) {
+ return;
+ }
+ }
+ // Evaluate sources
+ for (auto const& pair : BaseEval().Sources) {
+ if (!EvalFile(pair.second)) {
+ return;
+ }
+ }
+}
+
+bool cmQtAutoMocUicT::JobEvalCacheUicT::EvalFile(
+ SourceFileHandleT const& sourceFileHandle)
+{
+ SourceFileT const& sourceFile = *sourceFileHandle;
+ auto const& Include = sourceFile.ParseData->Uic.Include;
+ if (!sourceFile.Uic || Include.empty()) {
+ return true;
+ }
+
+ std::string const sourceDirPrefix = SubDirPrefix(sourceFile.FileName);
+ for (IncludeKeyT const& incKey : Include) {
+ // Find .ui file
+ UiName = cmStrCat(incKey.Base, ".ui");
+ if (!FindIncludedUi(sourceDirPrefix, incKey.Dir)) {
+ LogError(GenT::UIC,
+ cmStrCat(MessagePath(sourceFile.FileName),
+ "\nincludes the uic file ", MessagePath(incKey.Key),
+ ",\nbut the user interface file ", MessagePath(UiName),
+ "\ncould not be found in the following directories\n",
+ MessageSearchLocations()));
+ return false;
+ }
+ // Check if the file is skipped
+ if (UicConst().skipped(UiFileHandle->FileName)) {
+ continue;
+ }
+ // Register mapping
+ if (!RegisterMapping(incKey.Key, sourceFileHandle)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool cmQtAutoMocUicT::JobEvalCacheUicT::FindIncludedUi(
+ cm::string_view sourceDirPrefix, cm::string_view includePrefix)
+{
+ // Clear locations buffer
+ SearchLocations.clear();
+
+ auto findUi = [this](std::string const& testPath) -> bool {
+ std::string const fullPath = this->Gen()->CollapseFullPathTS(testPath);
+ cmFileTime fileTime;
+ if (!fileTime.Load(fullPath)) {
+ this->SearchLocations.emplace_back(cmQtAutoGen::ParentDir(fullPath));
+ return false;
+ }
+ // .ui file found in files system!
+ // Get or create .ui file handle
+ SourceFileHandleT& handle = this->UicEval().UiFiles[fullPath];
+ if (!handle) {
+ // The file wasn't registered, yet
+ handle = std::make_shared<SourceFileT>(fullPath);
+ handle->FileTime = fileTime;
+ }
+ this->UiFileHandle = handle;
+ return true;
+ };
+
+ // Vicinity of the source
+ if (findUi(cmStrCat(sourceDirPrefix, UiName))) {
+ return true;
+ }
+ if (!includePrefix.empty()) {
+ if (findUi(cmStrCat(sourceDirPrefix, includePrefix, UiName))) {
+ return true;
+ }
+ }
+ // Additional AUTOUIC search paths
+ auto const& searchPaths = UicConst().SearchPaths;
+ if (!searchPaths.empty()) {
+ for (std::string const& sPath : searchPaths) {
+ if (findUi(cmStrCat(sPath, '/', UiName))) {
+ return true;
+ }
+ }
+ if (!includePrefix.empty()) {
+ for (std::string const& sPath : searchPaths) {
+ if (findUi(cmStrCat(sPath, '/', includePrefix, UiName))) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+bool cmQtAutoMocUicT::JobEvalCacheUicT::RegisterMapping(
+ std::string const& includeString, SourceFileHandleT includerFileHandle)
+{
+ auto& Includes = Gen()->UicEval().Includes;
+ auto it = Includes.find(includeString);
+ if (it != Includes.end()) {
+ MappingHandleT const& handle = it->second;
+ if (handle->SourceFile != UiFileHandle) {
+ // The output file already gets generated - from a different .ui file!
+ std::string files =
+ cmStrCat(" ", MessagePath(includerFileHandle->FileName), '\n');
+ for (auto const& item : handle->IncluderFiles) {
+ files += cmStrCat(" ", MessagePath(item->FileName), '\n');
+ }
+ LogError(
+ GenT::UIC,
+ cmStrCat(
+ "The source files\n", files, "contain the same include string ",
+ Quoted(includeString),
+ ", but\nthe uic file would be generated from different "
+ "user interface files\n ",
+ MessagePath(UiFileHandle->FileName), " and\n ",
+ MessagePath(handle->SourceFile->FileName),
+ ".\nConsider to\n"
+ " - add a directory prefix to a \"ui_<NAME>.h\" include "
+ "(e.g \"sub/ui_<NAME>.h\")\n"
+ " - rename the <NAME>.ui file(s) and adjust the \"ui_<NAME>.h\" "
+ "include(s)\n"));
+ return false;
+ }
+ // Add includer file to existing mapping
+ handle->IncluderFiles.emplace_back(std::move(includerFileHandle));
+ } else {
+ // New mapping handle
+ MappingHandleT handle = std::make_shared<MappingT>();
+ handle->IncludeString = includeString;
+ handle->IncluderFiles.emplace_back(std::move(includerFileHandle));
+ handle->SourceFile = UiFileHandle;
+ handle->OutputFile = Gen()->AbsoluteIncludePath(includeString);
+ // Register mapping
+ Includes.emplace(includeString, std::move(handle));
+ }
+ return true;
+}
+
+void cmQtAutoMocUicT::JobEvalCacheFinishT::Process()
+{
+ // Add discovered header parse jobs
+ Gen()->CreateParseJobs<JobParseHeaderT>(MocEval().HeadersDiscovered);
+
+ // Add dependency probing jobs
+ {
+ // Add fence job to ensure all parsing has finished
+ Gen()->WorkerPool().EmplaceJob<JobFenceT>();
+ if (MocConst().Enabled) {
+ Gen()->WorkerPool().EmplaceJob<JobProbeDepsMocT>();
+ }
+ if (UicConst().Enabled) {
+ Gen()->WorkerPool().EmplaceJob<JobProbeDepsUicT>();
+ }
+ // Add probe finish job
+ Gen()->WorkerPool().EmplaceJob<JobProbeDepsFinishT>();
+ }
+}
+
+void cmQtAutoMocUicT::JobProbeDepsMocT::Process()
+{
+ // Create moc header jobs
+ for (auto const& pair : MocEval().HeaderMappings) {
+ // Register if this mapping is a candidate for mocs_compilation.cpp
+ bool const compFile = pair.second->IncludeString.empty();
+ if (compFile) {
+ MocEval().CompFiles.emplace_back(pair.second->SourceFile->BuildPath);
+ }
+ if (!Generate(pair.second, compFile)) {
+ return;
+ }
+ }
+
+ // Create moc source jobs
+ for (auto const& pair : MocEval().SourceMappings) {
+ if (!Generate(pair.second, false)) {
+ return;
+ }
+ }
+}
+
+bool cmQtAutoMocUicT::JobProbeDepsMocT::Generate(MappingHandleT const& mapping,
+ bool compFile) const
+{
+ std::unique_ptr<std::string> reason;
+ if (Log().Verbose()) {
+ reason = cm::make_unique<std::string>();
+ }
+ if (Probe(*mapping, reason.get())) {
+ // Register the parent directory for creation
+ MocEval().OutputDirs.emplace(cmQtAutoGen::ParentDir(mapping->OutputFile));
+ // Add moc job
+ Gen()->WorkerPool().EmplaceJob<JobCompileMocT>(mapping, std::move(reason));
+ // Check if a moc job for a mocs_compilation.cpp entry was generated
+ if (compFile) {
+ MocEval().CompUpdated = true;
+ }
+ }
+ return true;
+}
+
+bool cmQtAutoMocUicT::JobProbeDepsMocT::Probe(MappingT const& mapping,
+ std::string* reason) const
+{
+ std::string const& sourceFile = mapping.SourceFile->FileName;
+ std::string const& outputFile = mapping.OutputFile;
+
+ // Test if the output file exists
+ cmFileTime outputFileTime;
+ if (!outputFileTime.Load(outputFile)) {
+ if (reason != nullptr) {
+ *reason =
+ cmStrCat("Generating ", MessagePath(outputFile),
+ ", because it doesn't exist, from ", MessagePath(sourceFile));
+ }
+ return true;
+ }
+
+ // Test if any setting changed
+ if (MocConst().SettingsChanged) {
+ if (reason != nullptr) {
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
+ ", because the uic settings changed, from ",
+ MessagePath(sourceFile));
+ }
+ return true;
+ }
+
+ // Test if the source file is newer
+ if (outputFileTime.Older(mapping.SourceFile->FileTime)) {
+ if (reason != nullptr) {
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
+ ", because it's older than its source file, from ",
+ MessagePath(sourceFile));
+ }
+ return true;
+ }
+
+ // Test if the moc_predefs file is newer
+ if (!MocConst().PredefsFileAbs.empty()) {
+ if (outputFileTime.Older(MocEval().PredefsTime)) {
+ if (reason != nullptr) {
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
+ ", because it's older than ",
+ MessagePath(MocConst().PredefsFileAbs), ", from ",
+ MessagePath(sourceFile));
+ }
+ return true;
+ }
+ }
+
+ // Test if the moc executable is newer
+ if (outputFileTime.Older(MocConst().ExecutableTime)) {
+ if (reason != nullptr) {
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
+ ", because it's older than the moc executable, from ",
+ MessagePath(sourceFile));
+ }
+ return true;
+ }
+
+ // Test if a dependency file is newer
+ {
+ // Check dependency timestamps
+ std::string const sourceDir = SubDirPrefix(sourceFile);
+ for (std::string const& dep : mapping.SourceFile->ParseData->Moc.Depends) {
+ // Find dependency file
+ auto const depMatch = FindDependency(sourceDir, dep);
+ if (depMatch.first.empty()) {
+ Log().Warning(GenT::MOC,
+ cmStrCat(MessagePath(sourceFile), " depends on ",
+ MessagePath(dep),
+ " but the file does not exist."));
+ continue;
+ }
+ // Test if dependency file is older
+ if (outputFileTime.Older(depMatch.second)) {
+ if (reason != nullptr) {
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
+ ", because it's older than its dependency file ",
+ MessagePath(depMatch.first), ", from ",
+ MessagePath(sourceFile));
+ }
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+std::pair<std::string, cmFileTime>
+cmQtAutoMocUicT::JobProbeDepsMocT::FindDependency(
+ std::string const& sourceDir, std::string const& includeString) const
+{
+ using ResPair = std::pair<std::string, cmFileTime>;
+ // Search in vicinity of the source
+ {
+ ResPair res{ sourceDir + includeString, {} };
+ if (res.second.Load(res.first)) {
+ return res;
+ }
+ }
+ // Search in include directories
+ for (std::string const& includePath : MocConst().IncludePaths) {
+ ResPair res{ cmStrCat(includePath, '/', includeString), {} };
+ if (res.second.Load(res.first)) {
+ return res;
+ }
+ }
+ // Return empty
+ return ResPair();
+}
+
+void cmQtAutoMocUicT::JobProbeDepsUicT::Process()
+{
+ for (auto const& pair : Gen()->UicEval().Includes) {
+ MappingHandleT const& mapping = pair.second;
+ std::unique_ptr<std::string> reason;
+ if (Log().Verbose()) {
+ reason = cm::make_unique<std::string>();
+ }
+ if (!Probe(*mapping, reason.get())) {
+ continue;
+ }
+
+ // Register the parent directory for creation
+ UicEval().OutputDirs.emplace(cmQtAutoGen::ParentDir(mapping->OutputFile));
+ // Add uic job
+ Gen()->WorkerPool().EmplaceJob<JobCompileUicT>(mapping, std::move(reason));
+ }
+}
+
+bool cmQtAutoMocUicT::JobProbeDepsUicT::Probe(MappingT const& mapping,
+ std::string* reason) const
+{
+ std::string const& sourceFile = mapping.SourceFile->FileName;
+ std::string const& outputFile = mapping.OutputFile;
+
+ // Test if the build file exists
+ cmFileTime outputFileTime;
+ if (!outputFileTime.Load(outputFile)) {
+ if (reason != nullptr) {
+ *reason =
+ cmStrCat("Generating ", MessagePath(outputFile),
+ ", because it doesn't exist, from ", MessagePath(sourceFile));
+ }
+ return true;
+ }
+
+ // Test if the uic settings changed
+ if (UicConst().SettingsChanged) {
+ if (reason != nullptr) {
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
+ ", because the uic settings changed, from ",
+ MessagePath(sourceFile));
+ }
+ return true;
+ }
+
+ // Test if the source file is newer
+ if (outputFileTime.Older(mapping.SourceFile->FileTime)) {
+ if (reason != nullptr) {
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
+ " because it's older than the source file ",
+ MessagePath(sourceFile));
+ }
+ return true;
+ }
+
+ // Test if the uic executable is newer
+ if (outputFileTime.Older(UicConst().ExecutableTime)) {
+ if (reason != nullptr) {
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
+ ", because it's older than the uic executable, from ",
+ MessagePath(sourceFile));
+ }
+ return true;
+ }
+
+ return false;
+}
+
+void cmQtAutoMocUicT::JobProbeDepsFinishT::Process()
+{
+ // Create output directories
+ {
+ using StringSet = std::unordered_set<std::string>;
+ auto createDirs = [this](GenT genType, StringSet const& dirSet) {
+ for (std::string const& dirName : dirSet) {
+ if (!cmSystemTools::MakeDirectory(dirName)) {
+ this->LogError(
+ genType,
+ cmStrCat("Creating directory ", MessagePath(dirName), " failed."));
+ return;
+ }
+ }
+ };
+ if (MocConst().Enabled && UicConst().Enabled) {
+ StringSet outputDirs = MocEval().OutputDirs;
+ outputDirs.insert(UicEval().OutputDirs.begin(),
+ UicEval().OutputDirs.end());
+ createDirs(GenT::GEN, outputDirs);
+ } else if (MocConst().Enabled) {
+ createDirs(GenT::MOC, MocEval().OutputDirs);
+ } else if (UicConst().Enabled) {
+ createDirs(GenT::UIC, UicEval().OutputDirs);
+ }
+ }
+
+ if (MocConst().Enabled) {
+ // Add mocs compilations job
+ Gen()->WorkerPool().EmplaceJob<JobMocsCompilationT>();
+ }
+
+ // Add finish job
+ Gen()->WorkerPool().EmplaceJob<JobFinishT>();
+}
+
+void cmQtAutoMocUicT::JobCompileMocT::Process()
+{
+ std::string const& sourceFile = Mapping->SourceFile->FileName;
+ std::string const& outputFile = Mapping->OutputFile;
+
+ // Compose moc command
+ std::vector<std::string> cmd;
+ {
+ // Reserve large enough
+ cmd.reserve(MocConst().OptionsDefinitions.size() +
+ MocConst().OptionsIncludes.size() +
+ MocConst().OptionsExtra.size() + 16);
+ cmd.push_back(MocConst().Executable);
+ // Add definitions
+ cmAppend(cmd, MocConst().OptionsDefinitions);
+ // Add includes
+ cmAppend(cmd, MocConst().OptionsIncludes);
+ // Add predefs include
+ if (!MocConst().PredefsFileAbs.empty()) {
+ cmd.emplace_back("--include");
+ cmd.push_back(MocConst().PredefsFileAbs);
+ }
+ // Add path prefix on demand
+ if (MocConst().PathPrefix && Mapping->SourceFile->IsHeader) {
+ for (std::string const& dir : MocConst().IncludePaths) {
+ cm::string_view prefix = sourceFile;
+ if (cmHasPrefix(prefix, dir)) {
+ prefix.remove_prefix(dir.size());
+ if (cmHasPrefix(prefix, '/')) {
+ prefix.remove_prefix(1);
+ auto slashPos = prefix.rfind('/');
+ if (slashPos != cm::string_view::npos) {
+ cmd.emplace_back("-p");
+ cmd.emplace_back(prefix.substr(0, slashPos));
+ } else {
+ cmd.emplace_back("-p");
+ cmd.emplace_back("./");
+ }
+ break;
+ }
+ }
+ }
+ }
+ // Add extra options
+ cmAppend(cmd, MocConst().OptionsExtra);
+ // Add output file
+ cmd.emplace_back("-o");
+ cmd.push_back(outputFile);
+ // Add source file
+ cmd.push_back(sourceFile);
+ }
+
+ // Execute moc command
+ cmWorkerPool::ProcessResultT result;
+ if (RunProcess(GenT::MOC, result, cmd, Reason.get())) {
+ // Moc command success. Print moc output.
+ if (!result.StdOut.empty()) {
+ Log().Info(GenT::MOC, result.StdOut);
+ }
+ } else {
+ // Moc command failed
+ std::string includers;
+ if (!Mapping->IncluderFiles.empty()) {
+ includers = "included by\n";
+ for (auto const& item : Mapping->IncluderFiles) {
+ includers += cmStrCat(" ", MessagePath(item->FileName), '\n');
+ }
+ }
+ LogCommandError(GenT::MOC,
+ cmStrCat("The moc process failed to compile\n ",
+ MessagePath(sourceFile), "\ninto\n ",
+ MessagePath(outputFile), '\n', includers,
+ result.ErrorMessage),
+ cmd, result.StdOut);
+ }
+}
+
+void cmQtAutoMocUicT::JobCompileUicT::Process()
+{
+ std::string const& sourceFile = Mapping->SourceFile->FileName;
+ std::string const& outputFile = Mapping->OutputFile;
+
+ // Compose uic command
+ std::vector<std::string> cmd;
+ cmd.push_back(UicConst().Executable);
+ {
+ std::vector<std::string> allOpts = UicConst().Options;
+ auto optionIt = UicConst().UiFiles.find(sourceFile);
+ if (optionIt != UicConst().UiFiles.end()) {
+ UicMergeOptions(allOpts, optionIt->second.Options,
+ (BaseConst().QtVersionMajor == 5));
+ }
+ cmAppend(cmd, allOpts);
+ }
+ cmd.emplace_back("-o");
+ cmd.emplace_back(outputFile);
+ cmd.emplace_back(sourceFile);
+
+ cmWorkerPool::ProcessResultT result;
+ if (RunProcess(GenT::UIC, result, cmd, Reason.get())) {
+ // Uic command success
+ // Print uic output
+ if (!result.StdOut.empty()) {
+ Log().Info(GenT::UIC, result.StdOut);
+ }
+ } else {
+ // Uic command failed
+ std::string includers;
+ for (auto const& item : Mapping->IncluderFiles) {
+ includers += cmStrCat(" ", MessagePath(item->FileName), '\n');
+ }
+ LogCommandError(GenT::UIC,
+ cmStrCat("The uic process failed to compile\n ",
+ MessagePath(sourceFile), "\ninto\n ",
+ MessagePath(outputFile), "\nincluded by\n",
+ includers, result.ErrorMessage),
+ cmd, result.StdOut);
+ }
+}
+
+void cmQtAutoMocUicT::JobMocsCompilationT::Process()
+{
+ // Compose mocs compilation file content
+ std::string content =
+ "// This file is autogenerated. Changes will be overwritten.\n";
+
+ if (MocEval().CompFiles.empty()) {
+ // Placeholder content
+ content += "// No files found that require moc or the moc files are "
+ "included\n"
+ "enum some_compilers { need_more_than_nothing };\n";
+ } else {
+ // Valid content
+ const bool mc = BaseConst().MultiConfig;
+ cm::string_view const wrapFront = mc ? "#include <" : "#include \"";
+ cm::string_view const wrapBack = mc ? ">\n" : "\"\n";
+ content += cmWrap(wrapFront, MocEval().CompFiles, wrapBack, "");
+ }
+
+ std::string const& compAbs = MocConst().CompFileAbs;
+ if (cmQtAutoGenerator::FileDiffers(compAbs, content)) {
+ // Actually write mocs compilation file
+ if (Log().Verbose()) {
+ Log().Info(GenT::MOC,
+ "Generating MOC compilation " + MessagePath(compAbs));
+ }
+ if (!FileWrite(compAbs, content)) {
+ LogError(GenT::MOC,
+ cmStrCat("Writing MOC compilation ", MessagePath(compAbs),
+ " failed."));
+ }
+ } else if (MocEval().CompUpdated) {
+ // Only touch mocs compilation file
+ if (Log().Verbose()) {
+ Log().Info(GenT::MOC,
+ "Touching MOC compilation " + MessagePath(compAbs));
+ }
+ if (!cmSystemTools::Touch(compAbs, false)) {
+ LogError(GenT::MOC,
+ cmStrCat("Touching MOC compilation ", MessagePath(compAbs),
+ " failed."));
+ }
+ }
+}
+
+void cmQtAutoMocUicT::JobFinishT::Process()
+{
+ Gen()->AbortSuccess();
+}
+
+cmQtAutoMocUicT::cmQtAutoMocUicT()
+ : cmQtAutoGenerator(GenT::GEN)
+{
+}
+cmQtAutoMocUicT::~cmQtAutoMocUicT() = default;
+
+bool cmQtAutoMocUicT::InitFromInfo(InfoT const& info)
+{
+ // -- Required settings
+ if (!info.GetBool("MULTI_CONFIG", BaseConst_.MultiConfig, true) ||
+ !info.GetUInt("QT_VERSION_MAJOR", BaseConst_.QtVersionMajor, true) ||
+ !info.GetUInt("PARALLEL", BaseConst_.ThreadCount, false) ||
+ !info.GetString("BUILD_DIR", BaseConst_.AutogenBuildDir, true) ||
+ !info.GetStringConfig("INCLUDE_DIR", BaseConst_.AutogenIncludeDir,
+ true) ||
+ !info.GetString("CMAKE_EXECUTABLE", BaseConst_.CMakeExecutable, true) ||
+ !info.GetStringConfig("PARSE_CACHE_FILE", BaseConst_.ParseCacheFile,
+ true) ||
+ !info.GetStringConfig("SETTINGS_FILE", SettingsFile_, true) ||
+ !info.GetArray("HEADER_EXTENSIONS", BaseConst_.HeaderExtensions, true) ||
+ !info.GetString("QT_MOC_EXECUTABLE", MocConst_.Executable, false) ||
+ !info.GetString("QT_UIC_EXECUTABLE", UicConst_.Executable, false)) {
+ return false;
+ }
+
+ // -- Checks
+ if (!BaseConst_.CMakeExecutableTime.Load(BaseConst_.CMakeExecutable)) {
+ return info.LogError(cmStrCat("The CMake executable ",
+ MessagePath(BaseConst_.CMakeExecutable),
+ " does not exist."));
+ }
+
+ // -- Evaluate values
+ BaseConst_.ThreadCount = std::min(BaseConst_.ThreadCount, ParallelMax);
+ WorkerPool_.SetThreadCount(BaseConst_.ThreadCount);
+
+ // -- Moc
+ if (!MocConst_.Executable.empty()) {
+ // -- Moc is enabled
+ MocConst_.Enabled = true;
+
+ // -- Temporary buffers
+ struct
+ {
+ std::vector<std::string> MacroNames;
+ std::vector<std::string> DependFilters;
+ } tmp;
+
+ // -- Required settings
+ if (!info.GetBool("MOC_RELAXED_MODE", MocConst_.RelaxedMode, false) ||
+ !info.GetBool("MOC_PATH_PREFIX", MocConst_.PathPrefix, true) ||
+ !info.GetArray("MOC_SKIP", MocConst_.SkipList, false) ||
+ !info.GetArrayConfig("MOC_DEFINITIONS", MocConst_.Definitions,
+ false) ||
+ !info.GetArrayConfig("MOC_INCLUDES", MocConst_.IncludePaths, false) ||
+ !info.GetArray("MOC_OPTIONS", MocConst_.OptionsExtra, false) ||
+ !info.GetStringConfig("MOC_COMPILATION_FILE", MocConst_.CompFileAbs,
+ true) ||
+ !info.GetArray("MOC_PREDEFS_CMD", MocConst_.PredefsCmd, false) ||
+ !info.GetStringConfig("MOC_PREDEFS_FILE", MocConst_.PredefsFileAbs,
+ !MocConst_.PredefsCmd.empty()) ||
+ !info.GetArray("MOC_MACRO_NAMES", tmp.MacroNames, true) ||
+ !info.GetArray("MOC_DEPEND_FILTERS", tmp.DependFilters, false)) {
+ return false;
+ }
+
+ // -- Evaluate settings
+ for (std::string const& item : tmp.MacroNames) {
+ MocConst_.MacroFilters.emplace_back(
+ item, ("[\n][ \t]*{?[ \t]*" + item).append("[^a-zA-Z0-9_]"));
+ }
+ // Dependency filters
+ {
+ Json::Value const& val = info.GetValue("MOC_DEPEND_FILTERS");
+ if (!val.isArray()) {
+ return info.LogError("MOC_DEPEND_FILTERS JSON value is not an array.");
+ }
+ Json::ArrayIndex const arraySize = val.size();
+ for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) {
+ // Test entry closure
+ auto testEntry = [&info, ii](bool test, cm::string_view msg) -> bool {
+ if (!test) {
+ info.LogError(
+ cmStrCat("MOC_DEPEND_FILTERS filter ", ii, ": ", msg));
+ }
+ return !test;
+ };
+
+ Json::Value const& pairVal = val[ii];
+
+ if (testEntry(pairVal.isArray(), "JSON value is not an array.") ||
+ testEntry(pairVal.size() == 2, "JSON array size invalid.")) {
+ return false;
+ }
+
+ Json::Value const& keyVal = pairVal[0u];
+ Json::Value const& expVal = pairVal[1u];
+ if (testEntry(keyVal.isString(),
+ "JSON value for keyword is not a string.") ||
+ testEntry(expVal.isString(),
+ "JSON value for regular expression is not a string.")) {
+ return false;
+ }
+
+ std::string const key = keyVal.asString();
+ std::string const exp = expVal.asString();
+ if (testEntry(!key.empty(), "Keyword is empty.") ||
+ testEntry(!exp.empty(), "Regular expression is empty.")) {
+ return false;
+ }
+
+ this->MocConst_.DependFilters.emplace_back(key, exp);
+ if (testEntry(
+ this->MocConst_.DependFilters.back().Exp.is_valid(),
+ cmStrCat("Regular expression compilation failed.\nKeyword: ",
+ Quoted(key), "\nExpression: ", Quoted(exp)))) {
+ return false;
+ }
+ }
+ }
+ // Check if moc executable exists (by reading the file time)
+ if (!MocConst_.ExecutableTime.Load(MocConst_.Executable)) {
+ return info.LogError(cmStrCat("The moc executable ",
+ MessagePath(MocConst_.Executable),
+ " does not exist."));
+ }
+ }
+
+ // -- Uic
+ if (!UicConst_.Executable.empty()) {
+ // Uic is enabled
+ UicConst_.Enabled = true;
+
+ // -- Required settings
+ if (!info.GetArray("UIC_SKIP", UicConst_.SkipList, false) ||
+ !info.GetArray("UIC_SEARCH_PATHS", UicConst_.SearchPaths, false) ||
+ !info.GetArrayConfig("UIC_OPTIONS", UicConst_.Options, false)) {
+ return false;
+ }
+ // .ui files
+ {
+ Json::Value const& val = info.GetValue("UIC_UI_FILES");
+ if (!val.isArray()) {
+ return info.LogError("UIC_UI_FILES JSON value is not an array.");
+ }
+ Json::ArrayIndex const arraySize = val.size();
+ for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) {
+ // Test entry closure
+ auto testEntry = [&info, ii](bool test, cm::string_view msg) -> bool {
+ if (!test) {
+ info.LogError(cmStrCat("UIC_UI_FILES entry ", ii, ": ", msg));
+ }
+ return !test;
+ };
+
+ Json::Value const& entry = val[ii];
+ if (testEntry(entry.isArray(), "JSON value is not an array.") ||
+ testEntry(entry.size() == 2, "JSON array size invalid.")) {
+ return false;
+ }
+
+ Json::Value const& entryName = entry[0u];
+ Json::Value const& entryOptions = entry[1u];
+ if (testEntry(entryName.isString(),
+ "JSON value for name is not a string.") ||
+ testEntry(entryOptions.isArray(),
+ "JSON value for options is not an array.")) {
+ return false;
+ }
+
+ auto& uiFile = UicConst_.UiFiles[entryName.asString()];
+ InfoT::GetJsonArray(uiFile.Options, entryOptions);
+ }
+ }
+
+ // -- Evaluate settings
+ // Check if uic executable exists (by reading the file time)
+ if (!UicConst_.ExecutableTime.Load(UicConst_.Executable)) {
+ return info.LogError(cmStrCat("The uic executable ",
+ MessagePath(UicConst_.Executable),
+ " does not exist."));
+ }
+ }
+
+ // -- Headers
+ {
+ Json::Value const& val = info.GetValue("HEADERS");
+ if (!val.isArray()) {
+ return info.LogError("HEADERS JSON value is not an array.");
+ }
+ Json::ArrayIndex const arraySize = val.size();
+ for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) {
+ // Test entry closure
+ auto testEntry = [&info, ii](bool test, cm::string_view msg) -> bool {
+ if (!test) {
+ info.LogError(cmStrCat("HEADERS entry ", ii, ": ", msg));
+ }
+ return !test;
+ };
+
+ Json::Value const& entry = val[ii];
+ if (testEntry(entry.isArray(), "JSON value is not an array.") ||
+ testEntry(entry.size() == 3, "JSON array size invalid.")) {
+ return false;
+ }
+
+ Json::Value const& entryName = entry[0u];
+ Json::Value const& entryFlags = entry[1u];
+ Json::Value const& entryBuild = entry[2u];
+ if (testEntry(entryName.isString(),
+ "JSON value for name is not a string.") ||
+ testEntry(entryFlags.isString(),
+ "JSON value for flags is not a string.") ||
+ testEntry(entryBuild.isString(),
+ "JSON value for build path is not a string.")) {
+ return false;
+ }
+
+ std::string name = entryName.asString();
+ std::string flags = entryFlags.asString();
+ std::string build = entryBuild.asString();
+ if (testEntry(flags.size() == 2, "Invalid flags string size")) {
+ return false;
+ }
+
+ cmFileTime fileTime;
+ if (!fileTime.Load(name)) {
+ return info.LogError(cmStrCat(
+ "The header file ", this->MessagePath(name), " does not exist."));
+ }
+
+ SourceFileHandleT sourceHandle = std::make_shared<SourceFileT>(name);
+ sourceHandle->FileTime = fileTime;
+ sourceHandle->IsHeader = true;
+ sourceHandle->Moc = (flags[0] == 'M');
+ sourceHandle->Uic = (flags[1] == 'U');
+ if (sourceHandle->Moc && MocConst().Enabled) {
+ if (build.empty()) {
+ return info.LogError(
+ cmStrCat("Header file ", ii, " build path is empty"));
+ }
+ sourceHandle->BuildPath = std::move(build);
+ }
+ BaseEval().Headers.emplace(std::move(name), std::move(sourceHandle));
+ }
+ }
+
+ // -- Sources
+ {
+ Json::Value const& val = info.GetValue("SOURCES");
+ if (!val.isArray()) {
+ return info.LogError("SOURCES JSON value is not an array.");
+ }
+ Json::ArrayIndex const arraySize = val.size();
+ for (Json::ArrayIndex ii = 0; ii != arraySize; ++ii) {
+ // Test entry closure
+ auto testEntry = [&info, ii](bool test, cm::string_view msg) -> bool {
+ if (!test) {
+ info.LogError(cmStrCat("SOURCES entry ", ii, ": ", msg));
+ }
+ return !test;
+ };
+
+ Json::Value const& entry = val[ii];
+ if (testEntry(entry.isArray(), "JSON value is not an array.") ||
+ testEntry(entry.size() == 2, "JSON array size invalid.")) {
+ return false;
+ }
+
+ Json::Value const& entryName = entry[0u];
+ Json::Value const& entryFlags = entry[1u];
+ if (testEntry(entryName.isString(),
+ "JSON value for name is not a string.") ||
+ testEntry(entryFlags.isString(),
+ "JSON value for flags is not a string.")) {
+ return false;
+ }
+
+ std::string name = entryName.asString();
+ std::string flags = entryFlags.asString();
+ if (testEntry(flags.size() == 2, "Invalid flags string size")) {
+ return false;
+ }
+
+ cmFileTime fileTime;
+ if (!fileTime.Load(name)) {
+ return info.LogError(cmStrCat(
+ "The source file ", this->MessagePath(name), " does not exist."));
+ }
+
+ SourceFileHandleT sourceHandle = std::make_shared<SourceFileT>(name);
+ sourceHandle->FileTime = fileTime;
+ sourceHandle->IsHeader = false;
+ sourceHandle->Moc = (flags[0] == 'M');
+ sourceHandle->Uic = (flags[1] == 'U');
+ BaseEval().Sources.emplace(std::move(name), std::move(sourceHandle));
+ }
+ }
+
+ // -- Init derived information
+ // Moc variables
+ if (MocConst().Enabled) {
+ // Compose moc includes list
+ {
+ // Compute framework paths
+ std::set<std::string> frameworkPaths;
+ for (std::string const& path : MocConst().IncludePaths) {
+ // Extract framework path
+ if (cmHasLiteralSuffix(path, ".framework/Headers")) {
+ // Go up twice to get to the framework root
+ std::vector<std::string> pathComponents;
+ cmSystemTools::SplitPath(path, pathComponents);
+ frameworkPaths.emplace(cmSystemTools::JoinPath(
+ pathComponents.begin(), pathComponents.end() - 2));
+ }
+ }
+ // Reserve options
+ MocConst_.OptionsIncludes.reserve(MocConst().IncludePaths.size() +
+ frameworkPaths.size() * 2);
+ // Append includes
+ for (std::string const& path : MocConst().IncludePaths) {
+ MocConst_.OptionsIncludes.emplace_back("-I" + path);
+ }
+ // Append framework includes
+ for (std::string const& path : frameworkPaths) {
+ MocConst_.OptionsIncludes.emplace_back("-F");
+ MocConst_.OptionsIncludes.push_back(path);
+ }
+ }
+
+ // Compose moc definitions list
+ {
+ MocConst_.OptionsDefinitions.reserve(MocConst().Definitions.size());
+ for (std::string const& def : MocConst().Definitions) {
+ MocConst_.OptionsDefinitions.emplace_back("-D" + def);
+ }
+ }
+ }
+
+ return true;
+}
+
+template <class JOBTYPE>
+void cmQtAutoMocUicT::CreateParseJobs(SourceFileMapT const& sourceMap)
+{
+ cmFileTime const parseCacheTime = BaseEval().ParseCacheTime;
+ ParseCacheT& parseCache = BaseEval().ParseCache;
+ for (auto& src : sourceMap) {
+ // Get or create the file parse data reference
+ ParseCacheT::GetOrInsertT cacheEntry = parseCache.GetOrInsert(src.first);
+ src.second->ParseData = std::move(cacheEntry.first);
+ // Create a parse job if the cache file was missing or is older
+ if (cacheEntry.second || src.second->FileTime.Newer(parseCacheTime)) {
+ BaseEval().ParseCacheChanged = true;
+ WorkerPool().EmplaceJob<JOBTYPE>(src.second);
+ }
+ }
+}
+
+/** Concurrently callable implementation of cmSystemTools::CollapseFullPath */
+std::string cmQtAutoMocUicT::CollapseFullPathTS(std::string const& path) const
+{
+ std::lock_guard<std::mutex> guard(CMakeLibMutex_);
+ return cmSystemTools::CollapseFullPath(path, ProjectDirs().CurrentSource);
+}
+
+void cmQtAutoMocUicT::InitJobs()
+{
+ // Add moc_predefs.h job
+ if (MocConst().Enabled && !MocConst().PredefsCmd.empty()) {
+ WorkerPool().EmplaceJob<JobMocPredefsT>();
+ }
+
+ // Add header parse jobs
+ CreateParseJobs<JobParseHeaderT>(BaseEval().Headers);
+ // Add source parse jobs
+ CreateParseJobs<JobParseSourceT>(BaseEval().Sources);
+
+ // Add parse cache evaluations jobs
+ {
+ // Add a fence job to ensure all parsing has finished
+ WorkerPool().EmplaceJob<JobFenceT>();
+ if (MocConst().Enabled) {
+ WorkerPool().EmplaceJob<JobEvalCacheMocT>();
+ }
+ if (UicConst().Enabled) {
+ WorkerPool().EmplaceJob<JobEvalCacheUicT>();
+ }
+ // Add evaluate job
+ WorkerPool().EmplaceJob<JobEvalCacheFinishT>();
+ }
+}
+
+bool cmQtAutoMocUicT::Process()
+{
+ SettingsFileRead();
+ ParseCacheRead();
+ if (!CreateDirectories()) {
+ return false;
+ }
+ InitJobs();
+ if (!WorkerPool_.Process(this)) {
+ return false;
+ }
+ if (JobError_) {
+ return false;
+ }
+ if (!ParseCacheWrite()) {
+ return false;
+ }
+ if (!SettingsFileWrite()) {
+ return false;
+ }
+ return true;
+}
+
+void cmQtAutoMocUicT::SettingsFileRead()
+{
+ // Compose current settings strings
+ {
+ cmCryptoHash cryptoHash(cmCryptoHash::AlgoSHA256);
+ auto cha = [&cryptoHash](cm::string_view value) {
+ cryptoHash.Append(value);
+ cryptoHash.Append(";");
+ };
+
+ if (MocConst_.Enabled) {
+ cryptoHash.Initialize();
+ cha(MocConst().Executable);
+ for (auto const& item : MocConst().OptionsDefinitions) {
+ cha(item);
+ }
+ for (auto const& item : MocConst().OptionsIncludes) {
+ cha(item);
+ }
+ for (auto const& item : MocConst().OptionsExtra) {
+ cha(item);
+ }
+ for (auto const& item : MocConst().PredefsCmd) {
+ cha(item);
+ }
+ for (auto const& filter : MocConst().DependFilters) {
+ cha(filter.Key);
+ }
+ for (auto const& filter : MocConst().MacroFilters) {
+ cha(filter.Key);
+ }
+ SettingsStringMoc_ = cryptoHash.FinalizeHex();
+ }
+
+ if (UicConst().Enabled) {
+ cryptoHash.Initialize();
+ cha(UicConst().Executable);
+ std::for_each(UicConst().Options.begin(), UicConst().Options.end(), cha);
+ for (const auto& item : UicConst().UiFiles) {
+ cha(item.first);
+ auto const& opts = item.second.Options;
+ std::for_each(opts.begin(), opts.end(), cha);
+ }
+ SettingsStringUic_ = cryptoHash.FinalizeHex();
+ }
+ }
+
+ // Read old settings and compare
+ {
+ std::string content;
+ if (cmQtAutoGenerator::FileRead(content, SettingsFile_)) {
+ if (MocConst().Enabled) {
+ if (SettingsStringMoc_ != SettingsFind(content, "moc")) {
+ MocConst_.SettingsChanged = true;
+ }
+ }
+ if (UicConst().Enabled) {
+ if (SettingsStringUic_ != SettingsFind(content, "uic")) {
+ UicConst_.SettingsChanged = true;
+ }
+ }
+ // In case any setting changed remove the old settings file.
+ // This triggers a full rebuild on the next run if the current
+ // build is aborted before writing the current settings in the end.
+ if (MocConst().SettingsChanged || UicConst().SettingsChanged) {
+ cmSystemTools::RemoveFile(SettingsFile_);
+ }
+ } else {
+ // Settings file read failed
+ if (MocConst().Enabled) {
+ MocConst_.SettingsChanged = true;
+ }
+ if (UicConst().Enabled) {
+ UicConst_.SettingsChanged = true;
+ }
+ }
+ }
+}
+
+bool cmQtAutoMocUicT::SettingsFileWrite()
+{
+ // Only write if any setting changed
+ if (MocConst().SettingsChanged || UicConst().SettingsChanged) {
+ if (Log().Verbose()) {
+ Log().Info(
+ GenT::GEN,
+ cmStrCat("Writing the settings file ", MessagePath(SettingsFile_)));
+ }
+ // Compose settings file content
+ std::string content;
+ {
+ auto SettingAppend = [&content](cm::string_view key,
+ cm::string_view value) {
+ if (!value.empty()) {
+ content += cmStrCat(key, ':', value, '\n');
+ }
+ };
+ SettingAppend("moc", SettingsStringMoc_);
+ SettingAppend("uic", SettingsStringUic_);
+ }
+ // Write settings file
+ std::string error;
+ if (!cmQtAutoGenerator::FileWrite(SettingsFile_, content, &error)) {
+ Log().Error(GenT::GEN,
+ cmStrCat("Writing the settings file ",
+ MessagePath(SettingsFile_), " failed.\n", error));
+ // Remove old settings file to trigger a full rebuild on the next run
+ cmSystemTools::RemoveFile(SettingsFile_);
+ return false;
+ }
+ }
+ return true;
+}
+
+void cmQtAutoMocUicT::ParseCacheRead()
+{
+ cm::string_view reason;
+ // Don't read the cache if it is invalid
+ if (!BaseEval().ParseCacheTime.Load(BaseConst().ParseCacheFile)) {
+ reason = "Refreshing parse cache because it doesn't exist.";
+ } else if (MocConst().SettingsChanged || UicConst().SettingsChanged) {
+ reason = "Refreshing parse cache because the settings changed.";
+ } else if (BaseEval().ParseCacheTime.Older(
+ BaseConst().CMakeExecutableTime)) {
+ reason =
+ "Refreshing parse cache because it is older than the CMake executable.";
+ }
+
+ if (!reason.empty()) {
+ // Don't read but refresh the complete parse cache
+ if (Log().Verbose()) {
+ Log().Info(GenT::GEN, reason);
+ }
+ BaseEval().ParseCacheChanged = true;
+ } else {
+ // Read parse cache
+ BaseEval().ParseCache.ReadFromFile(BaseConst().ParseCacheFile);
+ }
+}
+
+bool cmQtAutoMocUicT::ParseCacheWrite()
+{
+ if (BaseEval().ParseCacheChanged) {
+ if (Log().Verbose()) {
+ Log().Info(GenT::GEN,
+ cmStrCat("Writing the parse cache file ",
+ MessagePath(BaseConst().ParseCacheFile)));
+ }
+ if (!BaseEval().ParseCache.WriteToFile(BaseConst().ParseCacheFile)) {
+ Log().Error(GenT::GEN,
+ cmStrCat("Writing the parse cache file ",
+ MessagePath(BaseConst().ParseCacheFile),
+ " failed."));
+ return false;
+ }
+ }
+ return true;
+}
+
+bool cmQtAutoMocUicT::CreateDirectories()
+{
+ // Create AUTOGEN include directory
+ if (!cmSystemTools::MakeDirectory(BaseConst().AutogenIncludeDir)) {
+ Log().Error(GenT::GEN,
+ cmStrCat("Creating the AUTOGEN include directory ",
+ MessagePath(BaseConst().AutogenIncludeDir),
+ " failed."));
+ return false;
+ }
+ return true;
+}
+
+void cmQtAutoMocUicT::Abort(bool error)
+{
+ if (error) {
+ JobError_.store(true);
+ }
+ WorkerPool_.Abort();
+}
+
+std::string cmQtAutoMocUicT::AbsoluteBuildPath(
+ cm::string_view relativePath) const
+{
+ return cmStrCat(BaseConst().AutogenBuildDir, '/', relativePath);
+}
+
+std::string cmQtAutoMocUicT::AbsoluteIncludePath(
+ cm::string_view relativePath) const
+{
+ return cmStrCat(BaseConst().AutogenIncludeDir, '/', relativePath);
+}
+
+} // End of unnamed namespace
+
+bool cmQtAutoMocUic(cm::string_view infoFile, cm::string_view config)
+{
+ return cmQtAutoMocUicT().Run(infoFile, config);
+}
diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h
new file mode 100644
index 000000000..ffcc2db70
--- /dev/null
+++ b/Source/cmQtAutoMocUic.h
@@ -0,0 +1,16 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmQtAutoMocUic_h
+#define cmQtAutoMocUic_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <cm/string_view>
+
+/**
+ * Process AUTOMOC and AUTOUIC
+ * @return true on success
+ */
+bool cmQtAutoMocUic(cm::string_view infoFile, cm::string_view config);
+
+#endif
diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx
new file mode 100644
index 000000000..3af81ad38
--- /dev/null
+++ b/Source/cmQtAutoRcc.cxx
@@ -0,0 +1,503 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmQtAutoRcc.h"
+
+#include <algorithm>
+#include <string>
+#include <vector>
+
+#include "cmAlgorithms.h"
+#include "cmCryptoHash.h"
+#include "cmDuration.h"
+#include "cmFileLock.h"
+#include "cmFileLockResult.h"
+#include "cmFileTime.h"
+#include "cmProcessOutput.h"
+#include "cmQtAutoGen.h"
+#include "cmQtAutoGenerator.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+namespace {
+
+/** \class cmQtAutoRccT
+ * \brief AUTORCC generator
+ */
+class cmQtAutoRccT : public cmQtAutoGenerator
+{
+public:
+ cmQtAutoRccT();
+ ~cmQtAutoRccT() override;
+
+ cmQtAutoRccT(cmQtAutoRccT const&) = delete;
+ cmQtAutoRccT& operator=(cmQtAutoRccT const&) = delete;
+
+private:
+ // -- Utility
+ bool IsMultiConfig() const { return MultiConfig_; }
+ std::string MultiConfigOutput() const;
+
+ // -- Abstract processing interface
+ bool InitFromInfo(InfoT const& info) override;
+ bool Process() override;
+ // -- Settings file
+ bool SettingsFileRead();
+ bool SettingsFileWrite();
+ // -- Tests
+ bool TestQrcRccFiles(bool& generate);
+ bool TestResources(bool& generate);
+ bool TestInfoFile();
+ // -- Generation
+ bool GenerateRcc();
+ bool GenerateWrapper();
+
+private:
+ // -- Config settings
+ bool MultiConfig_ = false;
+ // -- Directories
+ std::string AutogenBuildDir_;
+ std::string IncludeDir_;
+ // -- Qt environment
+ std::string RccExecutable_;
+ cmFileTime RccExecutableTime_;
+ std::vector<std::string> RccListOptions_;
+ // -- Job
+ std::string LockFile_;
+ cmFileLock LockFileLock_;
+ std::string QrcFile_;
+ std::string QrcFileName_;
+ std::string QrcFileDir_;
+ cmFileTime QrcFileTime_;
+ std::string RccPathChecksum_;
+ std::string RccFileName_;
+ std::string RccFileOutput_;
+ std::string RccFilePublic_;
+ cmFileTime RccFileTime_;
+ std::string Reason;
+ std::vector<std::string> Options_;
+ std::vector<std::string> Inputs_;
+ // -- Settings file
+ std::string SettingsFile_;
+ std::string SettingsString_;
+ bool SettingsChanged_ = false;
+ bool BuildFileChanged_ = false;
+};
+
+cmQtAutoRccT::cmQtAutoRccT()
+ : cmQtAutoGenerator(GenT::RCC)
+{
+}
+cmQtAutoRccT::~cmQtAutoRccT() = default;
+
+bool cmQtAutoRccT::InitFromInfo(InfoT const& info)
+{
+ // -- Required settings
+ if (!info.GetBool("MULTI_CONFIG", MultiConfig_, true) ||
+ !info.GetString("BUILD_DIR", AutogenBuildDir_, true) ||
+ !info.GetStringConfig("INCLUDE_DIR", IncludeDir_, true) ||
+ !info.GetString("RCC_EXECUTABLE", RccExecutable_, true) ||
+ !info.GetArray("RCC_LIST_OPTIONS", RccListOptions_, false) ||
+ !info.GetString("LOCK_FILE", LockFile_, true) ||
+ !info.GetStringConfig("SETTINGS_FILE", SettingsFile_, true) ||
+ !info.GetString("SOURCE", QrcFile_, true) ||
+ !info.GetString("OUTPUT_CHECKSUM", RccPathChecksum_, true) ||
+ !info.GetString("OUTPUT_NAME", RccFileName_, true) ||
+ !info.GetArray("OPTIONS", Options_, false) ||
+ !info.GetArray("INPUTS", Inputs_, false)) {
+ return false;
+ }
+
+ // -- Derive information
+ QrcFileName_ = cmSystemTools::GetFilenameName(QrcFile_);
+ QrcFileDir_ = cmSystemTools::GetFilenamePath(QrcFile_);
+ RccFilePublic_ =
+ cmStrCat(AutogenBuildDir_, '/', RccPathChecksum_, '/', RccFileName_);
+
+ // rcc output file name
+ if (IsMultiConfig()) {
+ RccFileOutput_ = cmStrCat(IncludeDir_, '/', MultiConfigOutput());
+ } else {
+ RccFileOutput_ = RccFilePublic_;
+ }
+
+ // -- Checks
+ if (!RccExecutableTime_.Load(RccExecutable_)) {
+ return info.LogError(cmStrCat(
+ "The rcc executable ", MessagePath(RccExecutable_), " does not exist."));
+ }
+
+ return true;
+}
+
+bool cmQtAutoRccT::Process()
+{
+ if (!SettingsFileRead()) {
+ return false;
+ }
+
+ // Test if the rcc output needs to be regenerated
+ bool generate = false;
+ if (!TestQrcRccFiles(generate)) {
+ return false;
+ }
+ if (!generate && !TestResources(generate)) {
+ return false;
+ }
+ // Generate on demand
+ if (generate) {
+ if (!GenerateRcc()) {
+ return false;
+ }
+ } else {
+ // Test if the info file is newer than the output file
+ if (!TestInfoFile()) {
+ return false;
+ }
+ }
+
+ if (!GenerateWrapper()) {
+ return false;
+ }
+
+ return SettingsFileWrite();
+}
+
+std::string cmQtAutoRccT::MultiConfigOutput() const
+{
+ return cmStrCat(RccPathChecksum_, '/',
+ AppendFilenameSuffix(RccFileName_, "_CMAKE_"));
+}
+
+bool cmQtAutoRccT::SettingsFileRead()
+{
+ // Compose current settings strings
+ {
+ cmCryptoHash cryptoHash(cmCryptoHash::AlgoSHA256);
+ auto cha = [&cryptoHash](cm::string_view value) {
+ cryptoHash.Append(value);
+ cryptoHash.Append(";");
+ };
+ cha(RccExecutable_);
+ std::for_each(RccListOptions_.begin(), RccListOptions_.end(), cha);
+ cha(QrcFile_);
+ cha(RccPathChecksum_);
+ cha(RccFileName_);
+ std::for_each(Options_.begin(), Options_.end(), cha);
+ std::for_each(Inputs_.begin(), Inputs_.end(), cha);
+ SettingsString_ = cryptoHash.FinalizeHex();
+ }
+
+ // Make sure the settings file exists
+ if (!cmSystemTools::FileExists(SettingsFile_, true)) {
+ // Touch the settings file to make sure it exists
+ if (!cmSystemTools::Touch(SettingsFile_, true)) {
+ Log().Error(GenT::RCC,
+ cmStrCat("Touching the settings file ",
+ MessagePath(SettingsFile_), " failed."));
+ return false;
+ }
+ }
+
+ // Lock the lock file
+ {
+ // Make sure the lock file exists
+ if (!cmSystemTools::FileExists(LockFile_, true)) {
+ if (!cmSystemTools::Touch(LockFile_, true)) {
+ Log().Error(GenT::RCC,
+ cmStrCat("Touching the lock file ", MessagePath(LockFile_),
+ " failed."));
+ return false;
+ }
+ }
+ // Lock the lock file
+ cmFileLockResult lockResult =
+ LockFileLock_.Lock(LockFile_, static_cast<unsigned long>(-1));
+ if (!lockResult.IsOk()) {
+ Log().Error(GenT::RCC,
+ cmStrCat("Locking of the lock file ", MessagePath(LockFile_),
+ " failed.\n", lockResult.GetOutputMessage()));
+ return false;
+ }
+ }
+
+ // Read old settings
+ {
+ std::string content;
+ if (FileRead(content, SettingsFile_)) {
+ SettingsChanged_ = (SettingsString_ != SettingsFind(content, "rcc"));
+ // In case any setting changed clear the old settings file.
+ // This triggers a full rebuild on the next run if the current
+ // build is aborted before writing the current settings in the end.
+ if (SettingsChanged_) {
+ std::string error;
+ if (!FileWrite(SettingsFile_, "", &error)) {
+ Log().Error(GenT::RCC,
+ cmStrCat("Clearing of the settings file ",
+ MessagePath(SettingsFile_), " failed.\n",
+ error));
+ return false;
+ }
+ }
+ } else {
+ SettingsChanged_ = true;
+ }
+ }
+
+ return true;
+}
+
+bool cmQtAutoRccT::SettingsFileWrite()
+{
+ // Only write if any setting changed
+ if (SettingsChanged_) {
+ if (Log().Verbose()) {
+ Log().Info(GenT::RCC,
+ "Writing settings file " + MessagePath(SettingsFile_));
+ }
+ // Write settings file
+ std::string content = cmStrCat("rcc:", SettingsString_, '\n');
+ std::string error;
+ if (!FileWrite(SettingsFile_, content, &error)) {
+ Log().Error(GenT::RCC,
+ cmStrCat("Writing of the settings file ",
+ MessagePath(SettingsFile_), " failed.\n", error));
+ // Remove old settings file to trigger a full rebuild on the next run
+ cmSystemTools::RemoveFile(SettingsFile_);
+ return false;
+ }
+ }
+
+ // Unlock the lock file
+ LockFileLock_.Release();
+ return true;
+}
+
+/// Do basic checks if rcc generation is required
+bool cmQtAutoRccT::TestQrcRccFiles(bool& generate)
+{
+ // Test if the rcc input file exists
+ if (!QrcFileTime_.Load(QrcFile_)) {
+ Log().Error(GenT::RCC,
+ cmStrCat("The resources file ", MessagePath(QrcFile_),
+ " does not exist"));
+ return false;
+ }
+
+ // Test if the rcc output file exists
+ if (!RccFileTime_.Load(RccFileOutput_)) {
+ if (Log().Verbose()) {
+ Reason =
+ cmStrCat("Generating ", MessagePath(RccFileOutput_),
+ ", because it doesn't exist, from ", MessagePath(QrcFile_));
+ }
+ generate = true;
+ return true;
+ }
+
+ // Test if the settings changed
+ if (SettingsChanged_) {
+ if (Log().Verbose()) {
+ Reason = cmStrCat("Generating ", MessagePath(RccFileOutput_),
+ ", because the rcc settings changed, from ",
+ MessagePath(QrcFile_));
+ }
+ generate = true;
+ return true;
+ }
+
+ // Test if the rcc output file is older than the .qrc file
+ if (RccFileTime_.Older(QrcFileTime_)) {
+ if (Log().Verbose()) {
+ Reason = cmStrCat("Generating ", MessagePath(RccFileOutput_),
+ ", because it is older than ", MessagePath(QrcFile_),
+ ", from ", MessagePath(QrcFile_));
+ }
+ generate = true;
+ return true;
+ }
+
+ // Test if the rcc output file is older than the rcc executable
+ if (RccFileTime_.Older(RccExecutableTime_)) {
+ if (Log().Verbose()) {
+ Reason = cmStrCat("Generating ", MessagePath(RccFileOutput_),
+ ", because it is older than the rcc executable, from ",
+ MessagePath(QrcFile_));
+ }
+ generate = true;
+ return true;
+ }
+
+ return true;
+}
+
+bool cmQtAutoRccT::TestResources(bool& generate)
+{
+ // Read resource files list
+ if (Inputs_.empty()) {
+ std::string error;
+ RccLister const lister(RccExecutable_, RccListOptions_);
+ if (!lister.list(QrcFile_, Inputs_, error, Log().Verbose())) {
+ Log().Error(
+ GenT::RCC,
+ cmStrCat("Listing of ", MessagePath(QrcFile_), " failed.\n", error));
+ return false;
+ }
+ }
+
+ // Check if any resource file is newer than the rcc output file
+ for (std::string const& resFile : Inputs_) {
+ // Check if the resource file exists
+ cmFileTime fileTime;
+ if (!fileTime.Load(resFile)) {
+ Log().Error(GenT::RCC,
+ cmStrCat("The resource file ", MessagePath(resFile),
+ " listed in ", MessagePath(QrcFile_),
+ " does not exist."));
+ return false;
+ }
+ // Check if the resource file is newer than the rcc output file
+ if (RccFileTime_.Older(fileTime)) {
+ if (Log().Verbose()) {
+ Reason = cmStrCat("Generating ", MessagePath(RccFileOutput_),
+ ", because it is older than ", MessagePath(resFile),
+ ", from ", MessagePath(QrcFile_));
+ }
+ generate = true;
+ break;
+ }
+ }
+ return true;
+}
+
+bool cmQtAutoRccT::TestInfoFile()
+{
+ // Test if the rcc output file is older than the info file
+ if (RccFileTime_.Older(InfoFileTime())) {
+ if (Log().Verbose()) {
+ Log().Info(GenT::RCC,
+ cmStrCat("Touching ", MessagePath(RccFileOutput_),
+ " because it is older than ",
+ MessagePath(InfoFile())));
+ }
+ // Touch build file
+ if (!cmSystemTools::Touch(RccFileOutput_, false)) {
+ Log().Error(
+ GenT::RCC,
+ cmStrCat("Touching ", MessagePath(RccFileOutput_), " failed."));
+ return false;
+ }
+ BuildFileChanged_ = true;
+ }
+
+ return true;
+}
+
+bool cmQtAutoRccT::GenerateRcc()
+{
+ // Make parent directory
+ if (!MakeParentDirectory(RccFileOutput_)) {
+ Log().Error(GenT::RCC,
+ cmStrCat("Could not create parent directory of ",
+ MessagePath(RccFileOutput_)));
+ return false;
+ }
+
+ // Compose rcc command
+ std::vector<std::string> cmd;
+ cmd.push_back(RccExecutable_);
+ cmAppend(cmd, Options_);
+ cmd.emplace_back("-o");
+ cmd.push_back(RccFileOutput_);
+ cmd.push_back(QrcFile_);
+
+ // Log reason and command
+ if (Log().Verbose()) {
+ Log().Info(GenT::RCC,
+ cmStrCat(Reason, cmHasSuffix(Reason, '\n') ? "" : "\n",
+ QuotedCommand(cmd), '\n'));
+ }
+
+ std::string rccStdOut;
+ std::string rccStdErr;
+ int retVal = 0;
+ bool result = cmSystemTools::RunSingleCommand(
+ cmd, &rccStdOut, &rccStdErr, &retVal, AutogenBuildDir_.c_str(),
+ cmSystemTools::OUTPUT_NONE, cmDuration::zero(), cmProcessOutput::Auto);
+ if (!result || (retVal != 0)) {
+ // rcc process failed
+ Log().ErrorCommand(GenT::RCC,
+ cmStrCat("The rcc process failed to compile\n ",
+ MessagePath(QrcFile_), "\ninto\n ",
+ MessagePath(RccFileOutput_)),
+ cmd, rccStdOut + rccStdErr);
+ cmSystemTools::RemoveFile(RccFileOutput_);
+ return false;
+ }
+
+ // rcc process success
+ // Print rcc output
+ if (!rccStdOut.empty()) {
+ Log().Info(GenT::RCC, rccStdOut);
+ }
+ BuildFileChanged_ = true;
+
+ return true;
+}
+
+bool cmQtAutoRccT::GenerateWrapper()
+{
+ // Generate a wrapper source file on demand
+ if (IsMultiConfig()) {
+ // Wrapper file content
+ std::string content =
+ cmStrCat("// This is an autogenerated configuration wrapper file.\n",
+ "// Changes will be overwritten.\n", "#include <",
+ MultiConfigOutput(), ">\n");
+
+ // Compare with existing file content
+ bool fileDiffers = true;
+ {
+ std::string oldContents;
+ if (FileRead(oldContents, RccFilePublic_)) {
+ fileDiffers = (oldContents != content);
+ }
+ }
+ if (fileDiffers) {
+ // Write new wrapper file
+ if (Log().Verbose()) {
+ Log().Info(GenT::RCC,
+ cmStrCat("Generating RCC wrapper file ",
+ MessagePath(RccFilePublic_)));
+ }
+ std::string error;
+ if (!FileWrite(RccFilePublic_, content, &error)) {
+ Log().Error(GenT::RCC,
+ cmStrCat("Generating RCC wrapper file ",
+ MessagePath(RccFilePublic_), " failed.\n",
+ error));
+ return false;
+ }
+ } else if (BuildFileChanged_) {
+ // Just touch the wrapper file
+ if (Log().Verbose()) {
+ Log().Info(
+ GenT::RCC,
+ cmStrCat("Touching RCC wrapper file ", MessagePath(RccFilePublic_)));
+ }
+ if (!cmSystemTools::Touch(RccFilePublic_, false)) {
+ Log().Error(GenT::RCC,
+ cmStrCat("Touching RCC wrapper file ",
+ MessagePath(RccFilePublic_), " failed."));
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+} // End of unnamed namespace
+
+bool cmQtAutoRcc(cm::string_view infoFile, cm::string_view config)
+{
+ return cmQtAutoRccT().Run(infoFile, config);
+}
diff --git a/Source/cmQtAutoRcc.h b/Source/cmQtAutoRcc.h
new file mode 100644
index 000000000..a74b33ae4
--- /dev/null
+++ b/Source/cmQtAutoRcc.h
@@ -0,0 +1,16 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmQtAutoRcc_h
+#define cmQtAutoRcc_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <cm/string_view>
+
+/**
+ * Process AUTORCC
+ * @return true on success
+ */
+bool cmQtAutoRcc(cm::string_view infoFile, cm::string_view config);
+
+#endif
diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index 5364f76f4..7f4abf904 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -2,20 +2,23 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmRST.h"
-#include "cmAlgorithms.h"
-#include "cmSystemTools.h"
-#include "cmVersion.h"
-
-#include "cmsys/FStream.hxx"
#include <algorithm>
-#include <ctype.h>
+#include <cctype>
+#include <cstddef>
#include <iterator>
-#include <stddef.h>
#include <utility>
-cmRST::cmRST(std::ostream& os, std::string const& docroot)
+#include "cmsys/FStream.hxx"
+
+#include "cmAlgorithms.h"
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmVersion.h"
+
+cmRST::cmRST(std::ostream& os, std::string docroot)
: OS(os)
- , DocRoot(docroot)
+ , DocRoot(std::move(docroot))
, IncludeDepth(0)
, OutputLinePending(false)
, LastLineEndedInColonColon(false)
@@ -32,13 +35,15 @@ cmRST::cmRST(std::ostream& os, std::string const& docroot)
, TocTreeDirective("^.. toctree::[ \t]*(.*)$")
, ProductionListDirective("^.. productionlist::[ \t]*(.*)$")
, NoteDirective("^.. note::[ \t]*(.*)$")
- , ModuleRST("^#\\[(=*)\\[\\.rst:$")
+ , ModuleRST(R"(^#\[(=*)\[\.rst:$)")
, CMakeRole("(:cmake)?:("
- "command|generator|variable|module|policy|"
+ "command|cpack_gen|generator|variable|envvar|module|policy|"
"prop_cache|prop_dir|prop_gbl|prop_inst|prop_sf|"
"prop_test|prop_tgt|"
"manual"
"):`(<*([^`<]|[^` \t]<)*)([ \t]+<[^`]*>)?`")
+ , InlineLink("`(<*([^`<]|[^` \t]<)*)([ \t]+<[^`]*>)?`_")
+ , InlineLiteral("``([^`]*)``")
, Substitution("(^|[^A-Za-z0-9_])"
"((\\|[^| \t\r\n]([^|\r\n]*[^| \t\r\n])?\\|)(__|_|))"
"([^A-Za-z0-9_]|$)")
@@ -86,7 +91,7 @@ void cmRST::ProcessModule(std::istream& is)
if (line[0] != '#') {
this->ProcessLine(line.substr(0, pos));
}
- rst = "";
+ rst.clear();
this->Reset();
this->OutputLinePending = true;
}
@@ -101,7 +106,7 @@ void cmRST::ProcessModule(std::istream& is)
this->ProcessLine(line.substr(2));
continue;
}
- rst = "";
+ rst.clear();
this->Reset();
this->OutputLinePending = true;
}
@@ -120,7 +125,7 @@ void cmRST::ProcessModule(std::istream& is)
void cmRST::Reset()
{
if (!this->MarkupLines.empty()) {
- this->UnindentLines(this->MarkupLines);
+ cmRST::UnindentLines(this->MarkupLines);
}
switch (this->Directive) {
case DirectiveNone:
@@ -152,8 +157,9 @@ void cmRST::ProcessLine(std::string const& line)
this->LastLineEndedInColonColon = false;
// A line starting in .. is an explicit markup start.
- if (line == ".." || (line.size() >= 3 && line[0] == '.' && line[1] == '.' &&
- isspace(line[2]))) {
+ if (line == ".." ||
+ (line.size() >= 3 && line[0] == '.' && line[1] == '.' &&
+ isspace(line[2]))) {
this->Reset();
this->Markup =
(line.find_first_not_of(" \t", 2) == std::string::npos ? MarkupEmpty
@@ -175,7 +181,7 @@ void cmRST::ProcessLine(std::string const& line)
// Record the literal lines to output after whole block.
// Ignore the language spec and record the opening line as blank.
this->Directive = DirectiveCodeBlock;
- this->MarkupLines.push_back("");
+ this->MarkupLines.emplace_back();
} else if (this->ReplaceDirective.find(line)) {
// Record the replace directive content.
this->Directive = DirectiveReplace;
@@ -218,15 +224,14 @@ void cmRST::ProcessLine(std::string const& line)
// Record the literal lines to output after whole block.
this->Markup = MarkupNormal;
this->Directive = DirectiveLiteralBlock;
- this->MarkupLines.push_back("");
+ this->MarkupLines.emplace_back();
this->OutputLine("", false);
}
// Print non-markup lines.
else {
this->NormalLine(line);
this->LastLineEndedInColonColon =
- (line.size() >= 2 && line[line.size() - 2] == ':' &&
- line[line.size() - 1] == ':');
+ (line.size() >= 2 && line[line.size() - 2] == ':' && line.back() == ':');
}
}
@@ -245,18 +250,62 @@ void cmRST::OutputLine(std::string const& line_in, bool inlineMarkup)
if (inlineMarkup) {
std::string line = this->ReplaceSubstitutions(line_in);
std::string::size_type pos = 0;
- while (this->CMakeRole.find(line.c_str() + pos)) {
- this->OS << line.substr(pos, this->CMakeRole.start());
- std::string text = this->CMakeRole.match(3);
- // If a command reference has no explicit target and
- // no explicit "(...)" then add "()" to the text.
- if (this->CMakeRole.match(2) == "command" &&
- this->CMakeRole.match(5).empty() &&
- text.find_first_of("()") == std::string::npos) {
- text += "()";
+ for (;;) {
+ std::string::size_type* first = nullptr;
+ std::string::size_type role_start = std::string::npos;
+ std::string::size_type link_start = std::string::npos;
+ std::string::size_type lit_start = std::string::npos;
+ if (this->CMakeRole.find(line.c_str() + pos)) {
+ role_start = this->CMakeRole.start();
+ first = &role_start;
+ }
+ if (this->InlineLiteral.find(line.c_str() + pos)) {
+ lit_start = this->InlineLiteral.start();
+ if (!first || lit_start < *first) {
+ first = &lit_start;
+ }
+ }
+ if (this->InlineLink.find(line.c_str() + pos)) {
+ link_start = this->InlineLink.start();
+ if (!first || link_start < *first) {
+ first = &link_start;
+ }
+ }
+ if (first == &role_start) {
+ this->OS << line.substr(pos, role_start);
+ std::string text = this->CMakeRole.match(3);
+ // If a command reference has no explicit target and
+ // no explicit "(...)" then add "()" to the text.
+ if (this->CMakeRole.match(2) == "command" &&
+ this->CMakeRole.match(5).empty() &&
+ text.find_first_of("()") == std::string::npos) {
+ text += "()";
+ }
+ this->OS << "``" << text << "``";
+ pos += this->CMakeRole.end();
+ } else if (first == &lit_start) {
+ this->OS << line.substr(pos, lit_start);
+ std::string text = this->InlineLiteral.match(1);
+ pos += this->InlineLiteral.end();
+ this->OS << "``" << text << "``";
+ } else if (first == &link_start) {
+ this->OS << line.substr(pos, link_start);
+ std::string text = this->InlineLink.match(1);
+ bool escaped = false;
+ for (char c : text) {
+ if (escaped) {
+ escaped = false;
+ this->OS << c;
+ } else if (c == '\\') {
+ escaped = true;
+ } else {
+ this->OS << c;
+ }
+ }
+ pos += this->InlineLink.end();
+ } else {
+ break;
}
- this->OS << "``" << text << "``";
- pos += this->CMakeRole.end();
}
this->OS << line.substr(pos) << "\n";
} else {
@@ -272,8 +321,7 @@ std::string cmRST::ReplaceSubstitutions(std::string const& line)
std::string::size_type start = this->Substitution.start(2);
std::string::size_type end = this->Substitution.end(2);
std::string substitute = this->Substitution.match(3);
- std::map<std::string, std::string>::iterator replace =
- this->Replace.find(substitute);
+ auto replace = this->Replace.find(substitute);
if (replace != this->Replace.end()) {
std::pair<std::set<std::string>::iterator, bool> replaced =
this->Replaced.insert(substitute);
@@ -292,11 +340,9 @@ std::string cmRST::ReplaceSubstitutions(std::string const& line)
void cmRST::OutputMarkupLines(bool inlineMarkup)
{
- for (std::vector<std::string>::iterator i = this->MarkupLines.begin();
- i != this->MarkupLines.end(); ++i) {
- std::string line = *i;
+ for (auto line : this->MarkupLines) {
if (!line.empty()) {
- line = " " + line;
+ line = cmStrCat(" ", line);
}
this->OutputLine(line, inlineMarkup);
}
@@ -347,15 +393,13 @@ void cmRST::ProcessDirectiveReplace()
// Record markup lines as replacement text.
std::string& replacement = this->Replace[this->ReplaceName];
replacement += cmJoin(this->MarkupLines, " ");
- this->ReplaceName = "";
+ this->ReplaceName.clear();
}
void cmRST::ProcessDirectiveTocTree()
{
// Process documents referenced by toctree directive.
- for (std::vector<std::string>::iterator i = this->MarkupLines.begin();
- i != this->MarkupLines.end(); ++i) {
- std::string const& line = *i;
+ for (std::string const& line : this->MarkupLines) {
if (!line.empty() && line[0] != ':') {
if (this->TocTreeLink.find(line)) {
std::string const& link = this->TocTreeLink.match(1);
@@ -407,14 +451,20 @@ void cmRST::UnindentLines(std::vector<std::string>& lines)
}
}
- std::vector<std::string>::const_iterator it = lines.begin();
+ auto it = lines.cbegin();
size_t leadingEmpty = std::distance(it, cmFindNot(lines, std::string()));
- std::vector<std::string>::const_reverse_iterator rit = lines.rbegin();
+ auto rit = lines.crbegin();
size_t trailingEmpty =
std::distance(rit, cmFindNot(cmReverseRange(lines), std::string()));
- std::vector<std::string>::iterator contentEnd = cmRotate(
- lines.begin(), lines.begin() + leadingEmpty, lines.end() - trailingEmpty);
+ if ((leadingEmpty + trailingEmpty) >= lines.size()) {
+ // All lines are empty. The markup block is empty. Leave only one.
+ lines.resize(1);
+ return;
+ }
+
+ auto contentEnd = cmRotate(lines.begin(), lines.begin() + leadingEmpty,
+ lines.end() - trailingEmpty);
lines.erase(contentEnd, lines.end());
}
diff --git a/Source/cmRST.h b/Source/cmRST.h
index d1a8e2711..6b5d416d8 100644
--- a/Source/cmRST.h
+++ b/Source/cmRST.h
@@ -5,13 +5,14 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmsys/RegularExpression.hxx"
#include <iosfwd>
#include <map>
#include <set>
#include <string>
#include <vector>
+#include "cmsys/RegularExpression.hxx"
+
/** \class cmRST
* \brief Perform basic .rst processing for command-line help
*
@@ -25,7 +26,7 @@
class cmRST
{
public:
- cmRST(std::ostream& os, std::string const& docroot);
+ cmRST(std::ostream& os, std::string docroot);
bool ProcessFile(std::string const& fname, bool isModule = false);
private:
@@ -85,6 +86,8 @@ private:
cmsys::RegularExpression NoteDirective;
cmsys::RegularExpression ModuleRST;
cmsys::RegularExpression CMakeRole;
+ cmsys::RegularExpression InlineLink;
+ cmsys::RegularExpression InlineLiteral;
cmsys::RegularExpression Substitution;
cmsys::RegularExpression TocTreeLink;
diff --git a/Source/cmRange.h b/Source/cmRange.h
new file mode 100644
index 000000000..3be5193e7
--- /dev/null
+++ b/Source/cmRange.h
@@ -0,0 +1,239 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmRange_h
+#define cmRange_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <algorithm>
+#include <functional>
+#include <iterator>
+
+namespace RangeIterators {
+
+template <typename Iter, typename UnaryPredicate>
+class FilterIterator
+{
+public:
+ using iterator_category = std::bidirectional_iterator_tag;
+ using value_type = typename std::iterator_traits<Iter>::value_type;
+ using difference_type = typename std::iterator_traits<Iter>::difference_type;
+ using pointer = typename std::iterator_traits<Iter>::pointer;
+ using reference = typename std::iterator_traits<Iter>::reference;
+
+ FilterIterator(Iter b, Iter e, UnaryPredicate p)
+ : Cur(std::move(b))
+ , End(std::move(e))
+ , Pred(std::move(p))
+ {
+ this->SatisfyPredicate();
+ }
+
+ FilterIterator& operator++()
+ {
+ ++this->Cur;
+ this->SatisfyPredicate();
+ return *this;
+ }
+
+ FilterIterator& operator--()
+ {
+ do {
+ --this->Cur;
+ } while (!this->Pred(*this->Cur));
+ return *this;
+ }
+
+ bool operator==(FilterIterator const& other) const
+ {
+ return this->Cur == other.Cur;
+ }
+
+ bool operator!=(FilterIterator const& other) const
+ {
+ return !this->operator==(other);
+ }
+
+ auto operator*() const -> decltype(*std::declval<Iter>())
+ {
+ return *this->Cur;
+ }
+
+private:
+ void SatisfyPredicate()
+ {
+ while (this->Cur != this->End && !this->Pred(*this->Cur)) {
+ ++this->Cur;
+ }
+ }
+
+ Iter Cur;
+ Iter End;
+ UnaryPredicate Pred;
+};
+
+template <typename Iter, typename UnaryFunction>
+class TransformIterator
+{
+public:
+ using iterator_category = std::bidirectional_iterator_tag;
+ using value_type =
+ typename std::remove_cv<typename std::remove_reference<decltype(
+ std::declval<UnaryFunction>()(*std::declval<Iter>()))>::type>::type;
+ using difference_type = typename std::iterator_traits<Iter>::difference_type;
+ using pointer = value_type const*;
+ using reference = value_type const&;
+
+ TransformIterator(Iter i, UnaryFunction f)
+ : Base(std::move(i))
+ , Func(std::move(f))
+ {
+ }
+
+ TransformIterator& operator++()
+ {
+ ++this->Base;
+ return *this;
+ }
+
+ TransformIterator& operator--()
+ {
+ --this->Base;
+ return *this;
+ }
+
+ bool operator==(TransformIterator const& other) const
+ {
+ return this->Base == other.Base;
+ }
+
+ bool operator!=(TransformIterator const& other) const
+ {
+ return !this->operator==(other);
+ }
+
+ auto operator*() const
+ -> decltype(std::declval<UnaryFunction>()(*std::declval<Iter>()))
+ {
+ return this->Func(*this->Base);
+ }
+
+private:
+ Iter Base;
+ UnaryFunction Func;
+};
+
+} // namespace RangeIterators
+
+template <typename Iter>
+class cmRange
+{
+public:
+ using const_iterator = Iter;
+ using value_type = typename std::iterator_traits<Iter>::value_type;
+ using difference_type = typename std::iterator_traits<Iter>::difference_type;
+
+ cmRange(Iter b, Iter e)
+ : Begin(std::move(b))
+ , End(std::move(e))
+ {
+ }
+
+ Iter begin() const { return this->Begin; }
+ Iter end() const { return this->End; }
+ bool empty() const { return this->Begin == this->End; }
+
+ difference_type size() const
+ {
+ return std::distance(this->Begin, this->End);
+ }
+
+ cmRange& advance(difference_type amount) &
+ {
+ std::advance(this->Begin, amount);
+ return *this;
+ }
+
+ cmRange advance(difference_type amount) &&
+ {
+ std::advance(this->Begin, amount);
+ return std::move(*this);
+ }
+
+ cmRange& retreat(difference_type amount) &
+ {
+ std::advance(this->End, -amount);
+ return *this;
+ }
+
+ cmRange retreat(difference_type amount) &&
+ {
+ std::advance(this->End, -amount);
+ return std::move(*this);
+ }
+
+ template <typename UnaryPredicate>
+ bool all_of(UnaryPredicate p) const
+ {
+ return std::all_of(this->Begin, this->End, std::ref(p));
+ }
+
+ template <typename UnaryPredicate>
+ bool any_of(UnaryPredicate p) const
+ {
+ return std::any_of(this->Begin, this->End, std::ref(p));
+ }
+
+ template <typename UnaryPredicate>
+ bool none_of(UnaryPredicate p) const
+ {
+ return std::none_of(this->Begin, this->End, std::ref(p));
+ }
+
+ template <typename UnaryPredicate>
+ auto filter(UnaryPredicate p) const
+ -> cmRange<RangeIterators::FilterIterator<Iter, UnaryPredicate>>
+ {
+ using It = RangeIterators::FilterIterator<Iter, UnaryPredicate>;
+ return { It(this->Begin, this->End, p), It(this->End, this->End, p) };
+ }
+
+ template <typename UnaryFunction>
+ auto transform(UnaryFunction f) const
+ -> cmRange<RangeIterators::TransformIterator<Iter, UnaryFunction>>
+ {
+ using It = RangeIterators::TransformIterator<Iter, UnaryFunction>;
+ return { It(this->Begin, f), It(this->End, f) };
+ }
+
+private:
+ Iter Begin;
+ Iter End;
+};
+
+template <typename Iter1, typename Iter2>
+bool operator==(cmRange<Iter1> const& left, cmRange<Iter2> const& right)
+{
+ return left.size() == right.size() &&
+ std::equal(left.begin(), left.end(), right.begin());
+}
+
+template <typename Iter1, typename Iter2>
+auto cmMakeRange(Iter1 begin, Iter2 end) -> cmRange<Iter1>
+{
+ return { begin, end };
+}
+
+template <typename Range>
+auto cmMakeRange(Range const& range) -> cmRange<decltype(range.begin())>
+{
+ return { range.begin(), range.end() };
+}
+
+template <typename Range>
+auto cmReverseRange(Range const& range) -> cmRange<decltype(range.rbegin())>
+{
+ return { range.rbegin(), range.rend() };
+}
+
+#endif
diff --git a/Source/cmRemoveCommand.cxx b/Source/cmRemoveCommand.cxx
index 1db84414a..457b70848 100644
--- a/Source/cmRemoveCommand.cxx
+++ b/Source/cmRemoveCommand.cxx
@@ -2,14 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmRemoveCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-#include "cmSystemTools.h"
-
-class cmExecutionStatus;
+#include "cmStringAlgorithms.h"
// cmRemoveCommand
-bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmRemoveCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
return true;
@@ -17,7 +16,7 @@ bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args,
std::string const& variable = args[0]; // VAR is always first
// get the old value
- const char* cacheValue = this->Makefile->GetDefinition(variable);
+ const char* cacheValue = status.GetMakefile().GetDefinition(variable);
// if there is no old value then return
if (!cacheValue) {
@@ -25,22 +24,19 @@ bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args,
}
// expand the variable
- std::vector<std::string> varArgsExpanded;
- cmSystemTools::ExpandListArgument(cacheValue, varArgsExpanded);
+ std::vector<std::string> const varArgsExpanded = cmExpandedList(cacheValue);
// expand the args
// check for REMOVE(VAR v1 v2 ... vn)
- std::vector<std::string> argsExpanded;
- std::vector<std::string> temp;
- temp.insert(temp.end(), args.begin() + 1, args.end());
- cmSystemTools::ExpandList(temp, argsExpanded);
+ std::vector<std::string> const argsExpanded =
+ cmExpandedLists(args.begin() + 1, args.end());
// now create the new value
std::string value;
- for (unsigned int j = 0; j < varArgsExpanded.size(); ++j) {
+ for (std::string const& varArgExpanded : varArgsExpanded) {
int found = 0;
- for (unsigned int k = 0; k < argsExpanded.size(); ++k) {
- if (varArgsExpanded[j] == argsExpanded[k]) {
+ for (std::string const& argExpanded : argsExpanded) {
+ if (varArgExpanded == argExpanded) {
found = 1;
break;
}
@@ -49,12 +45,12 @@ bool cmRemoveCommand::InitialPass(std::vector<std::string> const& args,
if (!value.empty()) {
value += ";";
}
- value += varArgsExpanded[j];
+ value += varArgExpanded;
}
}
// add the definition
- this->Makefile->AddDefinition(variable, value.c_str());
+ status.GetMakefile().AddDefinition(variable, value);
return true;
}
diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h
index f2e89f6e1..fb72ab5f7 100644
--- a/Source/cmRemoveCommand.h
+++ b/Source/cmRemoveCommand.h
@@ -3,34 +3,19 @@
#ifndef cmRemoveCommand_h
#define cmRemoveCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmRemoveCommand
+/**
* \brief remove command
*
* cmRemoveCommand implements the remove CMake command
*/
-class cmRemoveCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmRemoveCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmRemoveCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmRemoveDefinitionsCommand.cxx b/Source/cmRemoveDefinitionsCommand.cxx
index f5fe2dfb7..339ff9d35 100644
--- a/Source/cmRemoveDefinitionsCommand.cxx
+++ b/Source/cmRemoveDefinitionsCommand.cxx
@@ -2,22 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmRemoveDefinitionsCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-class cmExecutionStatus;
-
-// cmRemoveDefinitionsCommand
-bool cmRemoveDefinitionsCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmRemoveDefinitionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- // it is OK to have no arguments
- if (args.empty()) {
- return true;
- }
-
- for (std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i) {
- this->Makefile->RemoveDefineFlag(i->c_str());
+ cmMakefile& mf = status.GetMakefile();
+ for (std::string const& i : args) {
+ mf.RemoveDefineFlag(i);
}
return true;
}
diff --git a/Source/cmRemoveDefinitionsCommand.h b/Source/cmRemoveDefinitionsCommand.h
index 9a9a5d535..868416bc1 100644
--- a/Source/cmRemoveDefinitionsCommand.h
+++ b/Source/cmRemoveDefinitionsCommand.h
@@ -3,36 +3,14 @@
#ifndef cmRemoveDefinitionsCommand_h
#define cmRemoveDefinitionsCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmRemoveDefinitionsCommand
- * \brief Specify a list of compiler defines
- *
- * cmRemoveDefinitionsCommand specifies a list of compiler defines.
- * These defines will
- * be removed from the compile command.
- */
-class cmRemoveDefinitionsCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmRemoveDefinitionsCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmRemoveDefinitionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmReturnCommand.cxx b/Source/cmReturnCommand.cxx
index ceea8b4d9..59056690c 100644
--- a/Source/cmReturnCommand.cxx
+++ b/Source/cmReturnCommand.cxx
@@ -5,8 +5,8 @@
#include "cmExecutionStatus.h"
// cmReturnCommand
-bool cmReturnCommand::InitialPass(std::vector<std::string> const&,
- cmExecutionStatus& status)
+bool cmReturnCommand(std::vector<std::string> const&,
+ cmExecutionStatus& status)
{
status.SetReturnInvoked();
return true;
diff --git a/Source/cmReturnCommand.h b/Source/cmReturnCommand.h
index 87900e7e9..2404a363d 100644
--- a/Source/cmReturnCommand.h
+++ b/Source/cmReturnCommand.h
@@ -3,34 +3,15 @@
#ifndef cmReturnCommand_h
#define cmReturnCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmReturnCommand
- * \brief Return from a directory or function
- *
- * cmReturnCommand returns from a directory or function
- */
-class cmReturnCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmReturnCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+/// Return from a directory or function
+bool cmReturnCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx
index a71861af7..0a1d109d5 100644
--- a/Source/cmRulePlaceholderExpander.cxx
+++ b/Source/cmRulePlaceholderExpander.cxx
@@ -2,21 +2,21 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmRulePlaceholderExpander.h"
-#include <ctype.h>
-#include <string.h>
+#include <cctype>
+#include <cstring>
#include <utility>
#include "cmOutputConverter.h"
#include "cmSystemTools.h"
cmRulePlaceholderExpander::cmRulePlaceholderExpander(
- std::map<std::string, std::string> const& compilers,
- std::map<std::string, std::string> const& variableMappings,
- std::string const& compilerSysroot, std::string const& linkerSysroot)
- : Compilers(compilers)
- , VariableMappings(variableMappings)
- , CompilerSysroot(compilerSysroot)
- , LinkerSysroot(linkerSysroot)
+ std::map<std::string, std::string> compilers,
+ std::map<std::string, std::string> variableMappings,
+ std::string compilerSysroot, std::string linkerSysroot)
+ : Compilers(std::move(compilers))
+ , VariableMappings(std::move(variableMappings))
+ , CompilerSysroot(std::move(compilerSysroot))
+ , LinkerSysroot(std::move(linkerSysroot))
{
}
@@ -91,6 +91,31 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable(
if (replaceValues.Includes && variable == "INCLUDES") {
return replaceValues.Includes;
}
+ if (replaceValues.SwiftLibraryName) {
+ if (variable == "SWIFT_LIBRARY_NAME") {
+ return replaceValues.SwiftLibraryName;
+ }
+ }
+ if (replaceValues.SwiftModule) {
+ if (variable == "SWIFT_MODULE") {
+ return replaceValues.SwiftModule;
+ }
+ }
+ if (replaceValues.SwiftModuleName) {
+ if (variable == "SWIFT_MODULE_NAME") {
+ return replaceValues.SwiftModuleName;
+ }
+ }
+ if (replaceValues.SwiftOutputFileMap) {
+ if (variable == "SWIFT_OUTPUT_FILE_MAP") {
+ return replaceValues.SwiftOutputFileMap;
+ }
+ }
+ if (replaceValues.SwiftSources) {
+ if (variable == "SWIFT_SOURCES") {
+ return replaceValues.SwiftSources;
+ }
+ }
if (replaceValues.TargetPDB) {
if (variable == "TARGET_PDB") {
return replaceValues.TargetPDB;
@@ -110,7 +135,7 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable(
if (replaceValues.Target) {
if (variable == "TARGET_QUOTED") {
std::string targetQuoted = replaceValues.Target;
- if (!targetQuoted.empty() && targetQuoted[0] != '\"') {
+ if (!targetQuoted.empty() && targetQuoted.front() != '\"') {
targetQuoted = '\"';
targetQuoted += replaceValues.Target;
targetQuoted += '\"';
@@ -120,7 +145,7 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable(
if (variable == "TARGET_UNQUOTED") {
std::string unquoted = replaceValues.Target;
std::string::size_type sz = unquoted.size();
- if (sz > 2 && unquoted[0] == '\"' && unquoted[sz - 1] == '\"') {
+ if (sz > 2 && unquoted.front() == '\"' && unquoted.back() == '\"') {
unquoted = unquoted.substr(1, sz - 2);
}
return unquoted;
@@ -210,8 +235,7 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable(
cmOutputConverter::SHELL);
}
- std::map<std::string, std::string>::iterator compIt =
- this->Compilers.find(variable);
+ auto compIt = this->Compilers.find(variable);
if (compIt != this->Compilers.end()) {
std::string ret = outputConverter->ConvertToOutputForExisting(
@@ -267,8 +291,7 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable(
return ret;
}
- std::map<std::string, std::string>::iterator mapIt =
- this->VariableMappings.find(variable);
+ auto mapIt = this->VariableMappings.find(variable);
if (mapIt != this->VariableMappings.end()) {
if (variable.find("_FLAG") == std::string::npos) {
return outputConverter->ConvertToOutputForExisting(mapIt->second);
diff --git a/Source/cmRulePlaceholderExpander.h b/Source/cmRulePlaceholderExpander.h
index 7b19210d3..8f361967b 100644
--- a/Source/cmRulePlaceholderExpander.h
+++ b/Source/cmRulePlaceholderExpander.h
@@ -15,16 +15,16 @@ class cmRulePlaceholderExpander
{
public:
cmRulePlaceholderExpander(
- std::map<std::string, std::string> const& compilers,
- std::map<std::string, std::string> const& variableMappings,
- std::string const& compilerSysroot, std::string const& linkerSysroot);
+ std::map<std::string, std::string> compilers,
+ std::map<std::string, std::string> variableMappings,
+ std::string compilerSysroot, std::string linkerSysroot);
void SetTargetImpLib(std::string const& targetImpLib)
{
this->TargetImpLib = targetImpLib;
}
- // Create a struct to hold the varibles passed into
+ // Create a struct to hold the variables passed into
// ExpandRuleVariables
struct RuleVariables
{
@@ -58,6 +58,11 @@ public:
const char* Includes;
const char* DependencyFile;
const char* FilterPrefix;
+ const char* SwiftLibraryName;
+ const char* SwiftModule;
+ const char* SwiftModuleName;
+ const char* SwiftOutputFileMap;
+ const char* SwiftSources;
};
// Expand rule variables in CMake of the type found in language rules
diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx
new file mode 100644
index 000000000..7a987c27e
--- /dev/null
+++ b/Source/cmRuntimeDependencyArchive.cxx
@@ -0,0 +1,378 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmRuntimeDependencyArchive.h"
+
+#include "cmBinUtilsLinuxELFLinker.h"
+#include "cmBinUtilsMacOSMachOLinker.h"
+#include "cmBinUtilsWindowsPELinker.h"
+#include "cmExecutionStatus.h"
+#include "cmMakefile.h"
+#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+#if defined(_WIN32)
+# include "cmGlobalGenerator.h"
+# ifndef CMAKE_BOOTSTRAP
+# include "cmGlobalVisualStudioVersionedGenerator.h"
+# endif
+# include "cmsys/Glob.hxx"
+
+# 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,
+ unsigned int version, cmGlobalGenerator* gg)
+{
+ // If generating for the VS IDE, use the same instance.
+ std::string vsloc;
+ bool found = false;
+# ifndef CMAKE_BOOTSTRAP
+ if (gg->GetName().find(prefix) == 0) {
+ cmGlobalVisualStudioVersionedGenerator* vsgen =
+ static_cast<cmGlobalVisualStudioVersionedGenerator*>(gg);
+ if (vsgen->GetVSInstance(vsloc)) {
+ found = true;
+ }
+ }
+# endif
+
+ // Otherwise, find a VS instance ourselves.
+ if (!found) {
+ cmVSSetupAPIHelper vsSetupAPIHelper(version);
+ if (vsSetupAPIHelper.GetVSInstanceInfo(vsloc)) {
+ cmSystemTools::ConvertToUnixSlashes(vsloc);
+ found = true;
+ }
+ }
+
+ if (found) {
+ cmsys::Glob glob;
+ glob.SetListDirs(true);
+ glob.FindFiles(vsloc + "/VC/Tools/MSVC/*");
+ for (auto const& vcdir : glob.GetFiles()) {
+ paths.push_back(vcdir + "/bin/Hostx64/x64");
+ paths.push_back(vcdir + "/bin/Hostx86/x64");
+ paths.push_back(vcdir + "/bin/Hostx64/x86");
+ paths.push_back(vcdir + "/bin/Hostx86/x86");
+ }
+ }
+}
+
+static void AddRegistryPath(std::vector<std::string>& paths,
+ const std::string& path, cmMakefile* mf)
+{
+ // We should view the registry as the target application would view
+ // it.
+ cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32;
+ cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64;
+ if (mf->PlatformIs64Bit()) {
+ view = cmSystemTools::KeyWOW64_64;
+ other_view = cmSystemTools::KeyWOW64_32;
+ }
+
+ // Expand using the view of the target application.
+ std::string expanded = path;
+ cmSystemTools::ExpandRegistryValues(expanded, view);
+ cmSystemTools::GlobDirs(expanded, paths);
+
+ // Executables can be either 32-bit or 64-bit, so expand using the
+ // alternative view.
+ expanded = path;
+ cmSystemTools::ExpandRegistryValues(expanded, other_view);
+ cmSystemTools::GlobDirs(expanded, paths);
+}
+
+static void AddEnvPath(std::vector<std::string>& paths, const std::string& var,
+ const std::string& suffix)
+{
+ std::string value;
+ if (cmSystemTools::GetEnv(var, value)) {
+ paths.push_back(value + suffix);
+ }
+}
+#endif
+
+static cmsys::RegularExpression TransformCompile(const std::string& str)
+{
+ return cmsys::RegularExpression(str);
+}
+
+cmRuntimeDependencyArchive::cmRuntimeDependencyArchive(
+ cmExecutionStatus& status, std::vector<std::string> searchDirectories,
+ std::string bundleExecutable,
+ const std::vector<std::string>& preIncludeRegexes,
+ const std::vector<std::string>& preExcludeRegexes,
+ const std::vector<std::string>& postIncludeRegexes,
+ const std::vector<std::string>& postExcludeRegexes)
+ : Status(status)
+ , SearchDirectories(std::move(searchDirectories))
+ , BundleExecutable(std::move(bundleExecutable))
+ , PreIncludeRegexes(preIncludeRegexes.size())
+ , PreExcludeRegexes(preExcludeRegexes.size())
+ , PostIncludeRegexes(postIncludeRegexes.size())
+ , PostExcludeRegexes(postExcludeRegexes.size())
+{
+ std::transform(preIncludeRegexes.begin(), preIncludeRegexes.end(),
+ this->PreIncludeRegexes.begin(), TransformCompile);
+ std::transform(preExcludeRegexes.begin(), preExcludeRegexes.end(),
+ this->PreExcludeRegexes.begin(), TransformCompile);
+ std::transform(postIncludeRegexes.begin(), postIncludeRegexes.end(),
+ this->PostIncludeRegexes.begin(), TransformCompile);
+ std::transform(postExcludeRegexes.begin(), postExcludeRegexes.end(),
+ this->PostExcludeRegexes.begin(), TransformCompile);
+}
+
+bool cmRuntimeDependencyArchive::Prepare()
+{
+ std::string platform = this->GetMakefile()->GetSafeDefinition(
+ "CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM");
+ if (platform.empty()) {
+ std::string systemName =
+ this->GetMakefile()->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME");
+ if (systemName == "Windows") {
+ platform = "windows+pe";
+ } else if (systemName == "Darwin") {
+ platform = "macos+macho";
+ } else if (systemName == "Linux") {
+ platform = "linux+elf";
+ }
+ }
+ if (platform == "linux+elf") {
+ this->Linker = cm::make_unique<cmBinUtilsLinuxELFLinker>(this);
+ } else if (platform == "windows+pe") {
+ this->Linker = cm::make_unique<cmBinUtilsWindowsPELinker>(this);
+ } else if (platform == "macos+macho") {
+ this->Linker = cm::make_unique<cmBinUtilsMacOSMachOLinker>(this);
+ } else {
+ std::ostringstream e;
+ e << "Invalid value for CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM: "
+ << platform;
+ this->SetError(e.str());
+ return false;
+ }
+
+ return this->Linker->Prepare();
+}
+
+bool cmRuntimeDependencyArchive::GetRuntimeDependencies(
+ const std::vector<std::string>& executables,
+ const std::vector<std::string>& libraries,
+ const std::vector<std::string>& modules)
+{
+ for (auto const& exe : executables) {
+ if (!this->Linker->ScanDependencies(exe, cmStateEnums::EXECUTABLE)) {
+ return false;
+ }
+ }
+ for (auto const& lib : libraries) {
+ if (!this->Linker->ScanDependencies(lib, cmStateEnums::SHARED_LIBRARY)) {
+ return false;
+ }
+ }
+ for (auto const& mod : modules) {
+ if (!this->Linker->ScanDependencies(mod, cmStateEnums::MODULE_LIBRARY)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void cmRuntimeDependencyArchive::SetError(const std::string& e)
+{
+ this->Status.SetError(e);
+}
+
+std::string cmRuntimeDependencyArchive::GetBundleExecutable()
+{
+ return this->BundleExecutable;
+}
+
+const std::vector<std::string>&
+cmRuntimeDependencyArchive::GetSearchDirectories()
+{
+ return this->SearchDirectories;
+}
+
+std::string cmRuntimeDependencyArchive::GetGetRuntimeDependenciesTool()
+{
+ return this->GetMakefile()->GetSafeDefinition(
+ "CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL");
+}
+
+bool cmRuntimeDependencyArchive::GetGetRuntimeDependenciesCommand(
+ const std::string& search, std::vector<std::string>& command)
+{
+ // First see if it was supplied by the user
+ std::string toolCommand = this->GetMakefile()->GetSafeDefinition(
+ "CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND");
+ if (!toolCommand.empty()) {
+ cmExpandList(toolCommand, command);
+ return true;
+ }
+
+ // Now go searching for it
+ std::vector<std::string> paths;
+#ifdef _WIN32
+ cmGlobalGenerator* gg = this->GetMakefile()->GetGlobalGenerator();
+
+ // Add newer Visual Studio paths
+ AddVisualStudioPath(paths, "Visual Studio 16 ", 16, gg);
+ AddVisualStudioPath(paths, "Visual Studio 15 ", 15, gg);
+
+ // Add older Visual Studio paths
+ AddRegistryPath(
+ paths,
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0;InstallDir]/"
+ "../../VC/bin",
+ this->GetMakefile());
+ AddEnvPath(paths, "VS140COMNTOOLS", "/../../VC/bin");
+ paths.push_back(
+ "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin");
+ AddRegistryPath(
+ paths,
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0;InstallDir]/"
+ "../../VC/bin",
+ this->GetMakefile());
+ AddEnvPath(paths, "VS120COMNTOOLS", "/../../VC/bin");
+ paths.push_back(
+ "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin");
+ AddRegistryPath(
+ paths,
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;InstallDir]/"
+ "../../VC/bin",
+ this->GetMakefile());
+ AddEnvPath(paths, "VS110COMNTOOLS", "/../../VC/bin");
+ paths.push_back(
+ "C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin");
+ AddRegistryPath(
+ paths,
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]/"
+ "../../VC/bin",
+ this->GetMakefile());
+ AddEnvPath(paths, "VS100COMNTOOLS", "/../../VC/bin");
+ paths.push_back(
+ "C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin");
+ AddRegistryPath(
+ paths,
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0;InstallDir]/"
+ "../../VC/bin",
+ this->GetMakefile());
+ AddEnvPath(paths, "VS90COMNTOOLS", "/../../VC/bin");
+ paths.push_back("C:/Program Files/Microsoft Visual Studio 9.0/VC/bin");
+ paths.push_back("C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin");
+ AddRegistryPath(
+ paths,
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]/"
+ "../../VC/bin",
+ this->GetMakefile());
+ AddEnvPath(paths, "VS80COMNTOOLS", "/../../VC/bin");
+ paths.push_back("C:/Program Files/Microsoft Visual Studio 8/VC/BIN");
+ paths.push_back("C:/Program Files (x86)/Microsoft Visual Studio 8/VC/BIN");
+ AddRegistryPath(
+ paths,
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1;InstallDir]/"
+ "../../VC7/bin",
+ this->GetMakefile());
+ AddEnvPath(paths, "VS71COMNTOOLS", "/../../VC7/bin");
+ paths.push_back(
+ "C:/Program Files/Microsoft Visual Studio .NET 2003/VC7/BIN");
+ paths.push_back(
+ "C:/Program Files (x86)/Microsoft Visual Studio .NET 2003/VC7/BIN");
+#endif
+
+ std::string program = cmSystemTools::FindProgram(search, paths);
+ if (!program.empty()) {
+ command = { program };
+ return true;
+ }
+
+ // Couldn't find it
+ return false;
+}
+
+bool cmRuntimeDependencyArchive::IsPreExcluded(const std::string& name)
+{
+ cmsys::RegularExpressionMatch match;
+
+ for (auto const& regex : this->PreIncludeRegexes) {
+ if (regex.find(name.c_str(), match)) {
+ return false;
+ }
+ }
+
+ for (auto const& regex : this->PreExcludeRegexes) {
+ if (regex.find(name.c_str(), match)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool cmRuntimeDependencyArchive::IsPostExcluded(const std::string& name)
+{
+ cmsys::RegularExpressionMatch match;
+
+ for (auto const& regex : this->PostIncludeRegexes) {
+ if (regex.find(name.c_str(), match)) {
+ return false;
+ }
+ }
+
+ for (auto const& regex : this->PostExcludeRegexes) {
+ if (regex.find(name.c_str(), match)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void cmRuntimeDependencyArchive::AddResolvedPath(const std::string& name,
+ const std::string& path,
+ bool& unique)
+{
+ auto it = this->ResolvedPaths.emplace(name, std::set<std::string>{}).first;
+ unique = true;
+ for (auto const& other : it->second) {
+ if (cmSystemTools::SameFile(path, other)) {
+ unique = false;
+ break;
+ }
+ }
+ it->second.insert(path);
+}
+
+void cmRuntimeDependencyArchive::AddUnresolvedPath(const std::string& name)
+{
+ this->UnresolvedPaths.insert(name);
+}
+
+cmMakefile* cmRuntimeDependencyArchive::GetMakefile()
+{
+ return &this->Status.GetMakefile();
+}
+
+const std::map<std::string, std::set<std::string>>&
+cmRuntimeDependencyArchive::GetResolvedPaths()
+{
+ return this->ResolvedPaths;
+}
+
+const std::set<std::string>& cmRuntimeDependencyArchive::GetUnresolvedPaths()
+{
+ return this->UnresolvedPaths;
+}
diff --git a/Source/cmRuntimeDependencyArchive.h b/Source/cmRuntimeDependencyArchive.h
new file mode 100644
index 000000000..9e2dfb6c2
--- /dev/null
+++ b/Source/cmRuntimeDependencyArchive.h
@@ -0,0 +1,70 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#ifndef cmRuntimeDependencyArchive_h
+#define cmRuntimeDependencyArchive_h
+
+#include <map>
+#include <memory>
+#include <set>
+#include <string>
+#include <vector>
+
+#include "cmsys/RegularExpression.hxx"
+
+#include "cmBinUtilsLinker.h"
+
+class cmExecutionStatus;
+class cmMakefile;
+
+class cmRuntimeDependencyArchive
+{
+public:
+ explicit cmRuntimeDependencyArchive(
+ cmExecutionStatus& status, std::vector<std::string> searchDirectories,
+ std::string bundleExecutable,
+ const std::vector<std::string>& preIncludeRegexes,
+ const std::vector<std::string>& preExcludeRegexes,
+ const std::vector<std::string>& postIncludeRegexes,
+ const std::vector<std::string>& postExcludeRegexes);
+ bool Prepare();
+ bool GetRuntimeDependencies(const std::vector<std::string>& executables,
+ const std::vector<std::string>& libraries,
+ const std::vector<std::string>& modules);
+
+ void SetError(const std::string& e);
+
+ std::string GetBundleExecutable();
+ const std::vector<std::string>& GetSearchDirectories();
+ std::string GetGetRuntimeDependenciesTool();
+ bool GetGetRuntimeDependenciesCommand(const std::string& search,
+ std::vector<std::string>& command);
+ bool IsPreExcluded(const std::string& name);
+ bool IsPostExcluded(const std::string& name);
+
+ void AddResolvedPath(const std::string& name, const std::string& path,
+ bool& unique);
+ void AddUnresolvedPath(const std::string& name);
+
+ cmMakefile* GetMakefile();
+ const std::map<std::string, std::set<std::string>>& GetResolvedPaths();
+ const std::set<std::string>& GetUnresolvedPaths();
+
+private:
+ cmExecutionStatus& Status;
+ std::unique_ptr<cmBinUtilsLinker> Linker;
+
+ std::string GetRuntimeDependenciesTool;
+ std::vector<std::string> GetRuntimeDependenciesCommand;
+
+ std::vector<std::string> SearchDirectories;
+ std::string BundleExecutable;
+ std::vector<cmsys::RegularExpression> PreIncludeRegexes;
+ std::vector<cmsys::RegularExpression> PreExcludeRegexes;
+ std::vector<cmsys::RegularExpression> PostIncludeRegexes;
+ std::vector<cmsys::RegularExpression> PostExcludeRegexes;
+ std::map<std::string, std::set<std::string>> ResolvedPaths;
+ std::set<std::string> UnresolvedPaths;
+};
+
+#endif // cmRuntimeDependencyArchive_h
diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx
index 753a1ba6f..adc06792d 100644
--- a/Source/cmScriptGenerator.cxx
+++ b/Source/cmScriptGenerator.cxx
@@ -2,22 +2,22 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmScriptGenerator.h"
+#include <utility>
+
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-cmScriptGenerator::cmScriptGenerator(
- const std::string& config_var,
- std::vector<std::string> const& configurations)
- : RuntimeConfigVariable(config_var)
- , Configurations(configurations)
+cmScriptGenerator::cmScriptGenerator(std::string config_var,
+ std::vector<std::string> configurations)
+ : RuntimeConfigVariable(std::move(config_var))
+ , Configurations(std::move(configurations))
, ConfigurationName("")
- , ConfigurationTypes(CM_NULLPTR)
+ , ConfigurationTypes(nullptr)
, ActionsPerConfig(false)
{
}
-cmScriptGenerator::~cmScriptGenerator()
-{
-}
+cmScriptGenerator::~cmScriptGenerator() = default;
void cmScriptGenerator::Generate(
std::ostream& os, const std::string& config,
@@ -26,8 +26,8 @@ void cmScriptGenerator::Generate(
this->ConfigurationName = config;
this->ConfigurationTypes = &configurationTypes;
this->GenerateScript(os);
- this->ConfigurationName = "";
- this->ConfigurationTypes = CM_NULLPTR;
+ this->ConfigurationName.clear();
+ this->ConfigurationTypes = nullptr;
}
static void cmScriptGeneratorEncodeConfig(const std::string& config,
@@ -52,9 +52,8 @@ static void cmScriptGeneratorEncodeConfig(const std::string& config,
std::string cmScriptGenerator::CreateConfigTest(const std::string& config)
{
- std::string result = "\"${";
- result += this->RuntimeConfigVariable;
- result += "}\" MATCHES \"^(";
+ std::string result =
+ cmStrCat("\"${", this->RuntimeConfigVariable, "}\" MATCHES \"^(");
if (!config.empty()) {
cmScriptGeneratorEncodeConfig(config, result);
}
@@ -65,15 +64,13 @@ std::string cmScriptGenerator::CreateConfigTest(const std::string& config)
std::string cmScriptGenerator::CreateConfigTest(
std::vector<std::string> const& configs)
{
- std::string result = "\"${";
- result += this->RuntimeConfigVariable;
- result += "}\" MATCHES \"^(";
+ std::string result =
+ cmStrCat("\"${", this->RuntimeConfigVariable, "}\" MATCHES \"^(");
const char* sep = "";
- for (std::vector<std::string>::const_iterator ci = configs.begin();
- ci != configs.end(); ++ci) {
+ for (std::string const& config : configs) {
result += sep;
sep = "|";
- cmScriptGeneratorEncodeConfig(*ci, result);
+ cmScriptGeneratorEncodeConfig(config, result);
}
result += ")$\"";
return result;
@@ -123,10 +120,8 @@ bool cmScriptGenerator::GeneratesForConfig(const std::string& config)
// This is a configuration-specific rule. Check if the config
// matches this rule.
std::string config_upper = cmSystemTools::UpperCase(config);
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (cmSystemTools::UpperCase(*i) == config_upper) {
+ for (std::string const& cfg : this->Configurations) {
+ if (cmSystemTools::UpperCase(cfg) == config_upper) {
return true;
}
}
@@ -163,15 +158,12 @@ void cmScriptGenerator::GenerateScriptActionsPerConfig(std::ostream& os,
// in a block for each configuration that is built. We restrict
// the list of configurations to those to which this rule applies.
bool first = true;
- for (std::vector<std::string>::const_iterator i =
- this->ConfigurationTypes->begin();
- i != this->ConfigurationTypes->end(); ++i) {
- const char* config = i->c_str();
- if (this->GeneratesForConfig(config)) {
+ for (std::string const& cfgType : *this->ConfigurationTypes) {
+ if (this->GeneratesForConfig(cfgType)) {
// Generate a per-configuration block.
- std::string config_test = this->CreateConfigTest(config);
+ std::string config_test = this->CreateConfigTest(cfgType);
os << indent << (first ? "if(" : "elseif(") << config_test << ")\n";
- this->GenerateScriptForConfig(os, config, indent.Next());
+ this->GenerateScriptForConfig(os, cfgType, indent.Next());
first = false;
}
}
diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h
index d0879c687..c8bb1ab15 100644
--- a/Source/cmScriptGenerator.h
+++ b/Source/cmScriptGenerator.h
@@ -3,7 +3,7 @@
#ifndef cmScriptGenerator_h
#define cmScriptGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <ostream>
#include <string>
@@ -12,10 +12,7 @@
class cmScriptGeneratorIndent
{
public:
- cmScriptGeneratorIndent()
- : Level(0)
- {
- }
+ cmScriptGeneratorIndent() = default;
cmScriptGeneratorIndent(int level)
: Level(level)
{
@@ -28,11 +25,11 @@ public:
}
cmScriptGeneratorIndent Next(int step = 2) const
{
- return cmScriptGeneratorIndent(this->Level + step);
+ return { this->Level + step };
}
private:
- int Level;
+ int Level = 0;
};
inline std::ostream& operator<<(std::ostream& os,
cmScriptGeneratorIndent indent)
@@ -47,18 +44,19 @@ inline std::ostream& operator<<(std::ostream& os,
*/
class cmScriptGenerator
{
- CM_DISABLE_COPY(cmScriptGenerator)
-
public:
- cmScriptGenerator(const std::string& config_var,
- std::vector<std::string> const& configurations);
+ cmScriptGenerator(std::string config_var,
+ std::vector<std::string> configurations);
virtual ~cmScriptGenerator();
+ cmScriptGenerator(cmScriptGenerator const&) = delete;
+ cmScriptGenerator& operator=(cmScriptGenerator const&) = delete;
+
void Generate(std::ostream& os, const std::string& config,
std::vector<std::string> const& configurationTypes);
protected:
- typedef cmScriptGeneratorIndent Indent;
+ using Indent = cmScriptGeneratorIndent;
virtual void GenerateScript(std::ostream& os);
virtual void GenerateScriptConfigs(std::ostream& os, Indent indent);
virtual void GenerateScriptActions(std::ostream& os, Indent indent);
diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx
index 0df6e0c06..d15ce5749 100644
--- a/Source/cmSearchPath.cxx
+++ b/Source/cmSearchPath.cxx
@@ -6,9 +6,9 @@
#include <cassert>
#include <utility>
-#include "cmAlgorithms.h"
#include "cmFindCommon.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
cmSearchPath::cmSearchPath(cmFindCommon* findCmd)
@@ -16,9 +16,7 @@ cmSearchPath::cmSearchPath(cmFindCommon* findCmd)
{
}
-cmSearchPath::~cmSearchPath()
-{
-}
+cmSearchPath::~cmSearchPath() = default;
void cmSearchPath::ExtractWithout(const std::set<std::string>& ignore,
std::vector<std::string>& outPaths,
@@ -27,10 +25,9 @@ void cmSearchPath::ExtractWithout(const std::set<std::string>& ignore,
if (clear) {
outPaths.clear();
}
- for (std::vector<std::string>::const_iterator p = this->Paths.begin();
- p != this->Paths.end(); ++p) {
- if (ignore.count(*p) == 0) {
- outPaths.push_back(*p);
+ for (std::string const& path : this->Paths) {
+ if (ignore.count(path) == 0) {
+ outPaths.push_back(path);
}
}
}
@@ -42,7 +39,7 @@ void cmSearchPath::AddPath(const std::string& path)
void cmSearchPath::AddUserPath(const std::string& path)
{
- assert(this->FC != CM_NULLPTR);
+ assert(this->FC != nullptr);
std::vector<std::string> outPaths;
@@ -69,25 +66,23 @@ void cmSearchPath::AddUserPath(const std::string& path)
}
// Process them all from the current directory
- for (std::vector<std::string>::const_iterator p = outPaths.begin();
- p != outPaths.end(); ++p) {
- this->AddPathInternal(*p, this->FC->Makefile->GetCurrentSourceDirectory());
+ for (std::string const& p : outPaths) {
+ this->AddPathInternal(
+ p, this->FC->Makefile->GetCurrentSourceDirectory().c_str());
}
}
void cmSearchPath::AddCMakePath(const std::string& variable)
{
- assert(this->FC != CM_NULLPTR);
+ assert(this->FC != nullptr);
// Get a path from a CMake variable.
if (const char* value = this->FC->Makefile->GetDefinition(variable)) {
- std::vector<std::string> expanded;
- cmSystemTools::ExpandListArgument(value, expanded);
+ std::vector<std::string> expanded = cmExpandedList(value);
- for (std::vector<std::string>::const_iterator p = expanded.begin();
- p != expanded.end(); ++p) {
- this->AddPathInternal(*p,
- this->FC->Makefile->GetCurrentSourceDirectory());
+ for (std::string const& p : expanded) {
+ this->AddPathInternal(
+ p, this->FC->Makefile->GetCurrentSourceDirectory().c_str());
}
}
}
@@ -96,23 +91,21 @@ void cmSearchPath::AddEnvPath(const std::string& variable)
{
std::vector<std::string> expanded;
cmSystemTools::GetPath(expanded, variable.c_str());
- for (std::vector<std::string>::const_iterator p = expanded.begin();
- p != expanded.end(); ++p) {
- this->AddPathInternal(*p);
+ for (std::string const& p : expanded) {
+ this->AddPathInternal(p);
}
}
void cmSearchPath::AddCMakePrefixPath(const std::string& variable)
{
- assert(this->FC != CM_NULLPTR);
+ assert(this->FC != nullptr);
// Get a path from a CMake variable.
if (const char* value = this->FC->Makefile->GetDefinition(variable)) {
- std::vector<std::string> expanded;
- cmSystemTools::ExpandListArgument(value, expanded);
+ std::vector<std::string> expanded = cmExpandedList(value);
- this->AddPrefixPaths(expanded,
- this->FC->Makefile->GetCurrentSourceDirectory());
+ this->AddPrefixPaths(
+ expanded, this->FC->Makefile->GetCurrentSourceDirectory().c_str());
}
}
@@ -142,33 +135,31 @@ void cmSearchPath::AddSuffixes(const std::vector<std::string>& suffixes)
inPaths.swap(this->Paths);
this->Paths.reserve(inPaths.size() * (suffixes.size() + 1));
- for (std::vector<std::string>::iterator ip = inPaths.begin();
- ip != inPaths.end(); ++ip) {
- cmSystemTools::ConvertToUnixSlashes(*ip);
+ for (std::string& inPath : inPaths) {
+ cmSystemTools::ConvertToUnixSlashes(inPath);
// if *i is only / then do not add a //
// this will get incorrectly considered a network
// path on windows and cause huge delays.
- std::string p = *ip;
- if (!p.empty() && *p.rbegin() != '/') {
+ std::string p = inPath;
+ if (!p.empty() && p.back() != '/') {
p += "/";
}
// Combine with all the suffixes
- for (std::vector<std::string>::const_iterator s = suffixes.begin();
- s != suffixes.end(); ++s) {
- this->Paths.push_back(p + *s);
+ for (std::string const& suffix : suffixes) {
+ this->Paths.push_back(p + suffix);
}
// And now the original w/o any suffix
- this->Paths.push_back(*ip);
+ this->Paths.push_back(std::move(inPath));
}
}
void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths,
const char* base)
{
- assert(this->FC != CM_NULLPTR);
+ assert(this->FC != nullptr);
// default for programs
std::string subdir = "bin";
@@ -178,13 +169,12 @@ void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths,
} else if (this->FC->CMakePathName == "LIBRARY") {
subdir = "lib";
} else if (this->FC->CMakePathName == "FRAMEWORK") {
- subdir = ""; // ? what to do for frameworks ?
+ subdir.clear(); // ? what to do for frameworks ?
}
- for (std::vector<std::string>::const_iterator p = paths.begin();
- p != paths.end(); ++p) {
- std::string dir = *p;
- if (!subdir.empty() && !dir.empty() && *dir.rbegin() != '/') {
+ for (std::string const& path : paths) {
+ std::string dir = path;
+ if (!subdir.empty() && !dir.empty() && dir.back() != '/') {
dir += "/";
}
if (subdir == "include" || subdir == "lib") {
@@ -201,15 +191,15 @@ void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths,
if (subdir == "bin") {
this->AddPathInternal(dir + "sbin", base);
}
- if (!subdir.empty() && *p != "/") {
- this->AddPathInternal(*p, base);
+ if (!subdir.empty() && path != "/") {
+ this->AddPathInternal(path, base);
}
}
}
void cmSearchPath::AddPathInternal(const std::string& path, const char* base)
{
- assert(this->FC != CM_NULLPTR);
+ assert(this->FC != nullptr);
std::string collapsed = cmSystemTools::CollapseFullPath(path, base);
@@ -219,6 +209,6 @@ void cmSearchPath::AddPathInternal(const std::string& path, const char* base)
// Insert the path if has not already been emitted.
if (this->FC->SearchPathsEmitted.insert(collapsed).second) {
- this->Paths.push_back(collapsed);
+ this->Paths.push_back(std::move(collapsed));
}
}
diff --git a/Source/cmSearchPath.h b/Source/cmSearchPath.h
index 932022aa1..2a576ed59 100644
--- a/Source/cmSearchPath.h
+++ b/Source/cmSearchPath.h
@@ -3,7 +3,7 @@
#ifndef cmSearchPath_h
#define cmSearchPath_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <set>
#include <string>
@@ -23,7 +23,7 @@ public:
// cmSearchPath must be initialized from a valid pointer. The only reason
// for the default is to allow it to be easily used in stl containers.
// Attempting to initialize with a NULL value will fail an assertion
- cmSearchPath(cmFindCommon* findCmd = CM_NULLPTR);
+ cmSearchPath(cmFindCommon* findCmd = nullptr);
~cmSearchPath();
const std::vector<std::string>& GetPaths() const { return this->Paths; }
@@ -39,11 +39,11 @@ public:
void AddCMakePrefixPath(const std::string& variable);
void AddEnvPrefixPath(const std::string& variable, bool stripBin = false);
void AddSuffixes(const std::vector<std::string>& suffixes);
+ void AddPrefixPaths(const std::vector<std::string>& paths,
+ const char* base = nullptr);
protected:
- void AddPrefixPaths(const std::vector<std::string>& paths,
- const char* base = CM_NULLPTR);
- void AddPathInternal(const std::string& path, const char* base = CM_NULLPTR);
+ void AddPathInternal(const std::string& path, const char* base = nullptr);
cmFindCommon* FC;
std::vector<std::string> Paths;
diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx
index 7b222a041..52bde7c5c 100644
--- a/Source/cmSeparateArgumentsCommand.cxx
+++ b/Source/cmSeparateArgumentsCommand.cxx
@@ -3,19 +3,18 @@
#include "cmSeparateArgumentsCommand.h"
#include <algorithm>
-#include <sstream>
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
// cmSeparateArgumentsCommand
-bool cmSeparateArgumentsCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmSeparateArgumentsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("must be given at least one argument.");
+ status.SetError("must be given at least one argument.");
return false;
}
@@ -36,40 +35,38 @@ bool cmSeparateArgumentsCommand::InitialPass(
DoingCommand
};
Doing doing = DoingVariable;
- for (unsigned int i = 0; i < args.size(); ++i) {
+ for (std::string const& arg : args) {
if (doing == DoingVariable) {
- var = args[i];
+ var = arg;
doing = DoingMode;
- } else if (doing == DoingMode && args[i] == "NATIVE_COMMAND") {
+ } else if (doing == DoingMode && arg == "NATIVE_COMMAND") {
#ifdef _WIN32
mode = ModeWindows;
#else
mode = ModeUnix;
#endif
doing = DoingCommand;
- } else if (doing == DoingMode && args[i] == "UNIX_COMMAND") {
+ } else if (doing == DoingMode && arg == "UNIX_COMMAND") {
mode = ModeUnix;
doing = DoingCommand;
- } else if (doing == DoingMode && args[i] == "WINDOWS_COMMAND") {
+ } else if (doing == DoingMode && arg == "WINDOWS_COMMAND") {
mode = ModeWindows;
doing = DoingCommand;
} else if (doing == DoingCommand) {
- command = args[i];
+ command = arg;
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "given unknown argument " << args[i];
- this->SetError(e.str());
+ status.SetError(cmStrCat("given unknown argument ", arg));
return false;
}
}
if (mode == ModeOld) {
// Original space-replacement version of command.
- if (const char* def = this->Makefile->GetDefinition(var)) {
+ if (const char* def = status.GetMakefile().GetDefinition(var)) {
std::string value = def;
std::replace(value.begin(), value.end(), ' ', ';');
- this->Makefile->AddDefinition(var, value.c_str());
+ status.GetMakefile().AddDefinition(var, value);
}
} else {
// Parse the command line.
@@ -84,22 +81,20 @@ bool cmSeparateArgumentsCommand::InitialPass(
// Construct the result list value.
std::string value;
const char* sep = "";
- for (std::vector<std::string>::const_iterator vi = vec.begin();
- vi != vec.end(); ++vi) {
+ for (std::string const& vi : vec) {
// Separate from the previous argument.
value += sep;
sep = ";";
// Preserve semicolons.
- for (std::string::const_iterator si = vi->begin(); si != vi->end();
- ++si) {
- if (*si == ';') {
+ for (char si : vi) {
+ if (si == ';') {
value += '\\';
}
- value += *si;
+ value += si;
}
}
- this->Makefile->AddDefinition(var, value.c_str());
+ status.GetMakefile().AddDefinition(var, value);
}
return true;
diff --git a/Source/cmSeparateArgumentsCommand.h b/Source/cmSeparateArgumentsCommand.h
index 6bf8549cf..e000c511d 100644
--- a/Source/cmSeparateArgumentsCommand.h
+++ b/Source/cmSeparateArgumentsCommand.h
@@ -3,34 +3,19 @@
#ifndef cmSeparateArgumentsCommand_h
#define cmSeparateArgumentsCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmSeparateArgumentsCommand
+/**
* \brief separate_arguments command
*
* cmSeparateArgumentsCommand implements the separate_arguments CMake command
*/
-class cmSeparateArgumentsCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmSeparateArgumentsCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmSeparateArgumentsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index 7fc6ed755..3b2e5f322 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -2,19 +2,43 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmServer.h"
-#include "cmServerConnection.h"
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
+#include <iostream>
+#include <mutex>
+#include <utility>
+
+#include <cm/memory>
+#include <cm/shared_mutex>
+
+#include "cmsys/FStream.hxx"
+
+#include "cm_jsoncpp_reader.h"
+#include "cm_jsoncpp_writer.h"
+
+#include "cmConnection.h"
+#include "cmFileMonitor.h"
+#include "cmJsonObjectDictionary.h"
#include "cmServerDictionary.h"
#include "cmServerProtocol.h"
#include "cmSystemTools.h"
-#include "cm_jsoncpp_reader.h"
-#include "cm_jsoncpp_writer.h"
#include "cmake.h"
-#include "cmsys/FStream.hxx"
-#include <algorithm>
-#include <cassert>
-#include <cstdint>
-#include <utility>
+void on_signal(uv_signal_t* signal, int signum)
+{
+ auto conn = static_cast<cmServerBase*>(signal->data);
+ conn->OnSignal(signum);
+}
+
+static void on_walk_to_shutdown(uv_handle_t* handle, void* arg)
+{
+ (void)arg;
+ assert(uv_is_closing(handle));
+ if (!uv_is_closing(handle)) {
+ uv_close(handle, &cmEventBasedConnection::on_close);
+ }
+}
class cmServer::DebugInfo
{
@@ -30,76 +54,73 @@ public:
uint64_t StartTime;
};
-cmServer::cmServer(cmServerConnection* conn, bool supportExperimental)
- : Connection(conn)
+cmServer::cmServer(cmConnection* conn, bool supportExperimental)
+ : cmServerBase(conn)
, SupportExperimental(supportExperimental)
{
- this->Connection->SetServer(this);
// Register supported protocols:
- this->RegisterProtocol(new cmServerProtocol1_0);
+ this->RegisterProtocol(new cmServerProtocol1);
}
cmServer::~cmServer()
{
- if (!this->Protocol) { // Server was never fully started!
- return;
- }
+ Close();
for (cmServerProtocol* p : this->SupportedProtocols) {
delete p;
}
-
- delete this->Connection;
}
-void cmServer::PopOne()
+void cmServer::ProcessRequest(cmConnection* connection,
+ const std::string& input)
{
- if (this->Queue.empty()) {
- return;
- }
-
Json::Reader reader;
Json::Value value;
- const std::string input = this->Queue.front();
- this->Queue.erase(this->Queue.begin());
-
if (!reader.parse(input, value)) {
- this->WriteParseError("Failed to parse JSON input.");
+ this->WriteParseError(connection, "Failed to parse JSON input.");
return;
}
std::unique_ptr<DebugInfo> debug;
Json::Value debugValue = value["debug"];
if (!debugValue.isNull()) {
- debug = std::make_unique<DebugInfo>();
+ debug = cm::make_unique<DebugInfo>();
debug->OutputFile = debugValue["dumpToFile"].asString();
debug->PrintStatistics = debugValue["showStats"].asBool();
}
- const cmServerRequest request(this, value[kTYPE_KEY].asString(),
+ const cmServerRequest request(this, connection, value[kTYPE_KEY].asString(),
value[kCOOKIE_KEY].asString(), value);
- if (request.Type == "") {
+ if (request.Type.empty()) {
cmServerResponse response(request);
response.SetError("No type given in request.");
- this->WriteResponse(response, nullptr);
+ this->WriteResponse(connection, response, nullptr);
return;
}
- cmSystemTools::SetMessageCallback(reportMessage,
- const_cast<cmServerRequest*>(&request));
+ cmSystemTools::SetMessageCallback(
+ [&request](const std::string& msg, const char* title) {
+ reportMessage(msg, title, request);
+ });
+
if (this->Protocol) {
this->Protocol->CMakeInstance()->SetProgressCallback(
- reportProgress, const_cast<cmServerRequest*>(&request));
- this->WriteResponse(this->Protocol->Process(request), debug.get());
+ [&request](const std::string& msg, float prog) {
+ reportProgress(msg, prog, request);
+ });
+ this->WriteResponse(connection, this->Protocol->Process(request),
+ debug.get());
} else {
- this->WriteResponse(this->SetProtocolVersion(request), debug.get());
+ this->WriteResponse(connection, this->SetProtocolVersion(request),
+ debug.get());
}
}
void cmServer::RegisterProtocol(cmServerProtocol* protocol)
{
if (protocol->IsExperimental() && !this->SupportExperimental) {
+ delete protocol;
return;
}
auto version = protocol->ProtocolVersion();
@@ -115,7 +136,7 @@ void cmServer::RegisterProtocol(cmServerProtocol* protocol)
}
}
-void cmServer::PrintHello() const
+void cmServer::PrintHello(cmConnection* connection) const
{
Json::Value hello = Json::objectValue;
hello[kTYPE_KEY] = "hello";
@@ -134,37 +155,27 @@ void cmServer::PrintHello() const
protocolVersions.append(tmp);
}
- this->WriteJsonObject(hello, nullptr);
-}
-
-void cmServer::QueueRequest(const std::string& request)
-{
- this->Queue.push_back(request);
- this->PopOne();
+ this->WriteJsonObject(connection, hello, nullptr);
}
-void cmServer::reportProgress(const char* msg, float progress, void* data)
+void cmServer::reportProgress(const std::string& msg, float progress,
+ const cmServerRequest& request)
{
- const cmServerRequest* request = static_cast<const cmServerRequest*>(data);
- assert(request);
if (progress < 0.0f || progress > 1.0f) {
- request->ReportMessage(msg, "");
+ request.ReportMessage(msg, "");
} else {
- request->ReportProgress(0, static_cast<int>(progress * 1000), 1000, msg);
+ request.ReportProgress(0, static_cast<int>(progress * 1000), 1000, msg);
}
}
-void cmServer::reportMessage(const char* msg, const char* title,
- bool& /* cancel */, void* data)
+void cmServer::reportMessage(const std::string& msg, const char* title,
+ const cmServerRequest& request)
{
- const cmServerRequest* request = static_cast<const cmServerRequest*>(data);
- assert(request);
- assert(msg);
std::string titleString;
if (title) {
titleString = title;
}
- request->ReportMessage(std::string(msg), titleString);
+ request.ReportMessage(msg, titleString);
}
cmServerResponse cmServer::SetProtocolVersion(const cmServerRequest& request)
@@ -209,14 +220,14 @@ cmServerResponse cmServer::SetProtocolVersion(const cmServerRequest& request)
}
this->Protocol =
- this->FindMatchingProtocol(this->SupportedProtocols, major, minor);
+ cmServer::FindMatchingProtocol(this->SupportedProtocols, major, minor);
if (!this->Protocol) {
return request.ReportError("Protocol version not supported.");
}
std::string errorMessage;
if (!this->Protocol->Activate(this, request, &errorMessage)) {
- this->Protocol = CM_NULLPTR;
+ this->Protocol = nullptr;
return request.ReportError("Failed to activate protocol version: " +
errorMessage);
}
@@ -232,17 +243,27 @@ bool cmServer::Serve(std::string* errorMessage)
}
assert(!this->Protocol);
- return Connection->ProcessEvents(errorMessage);
+ return cmServerBase::Serve(errorMessage);
}
cmFileMonitor* cmServer::FileMonitor() const
{
- return Connection->FileMonitor();
+ return fileMonitor.get();
}
void cmServer::WriteJsonObject(const Json::Value& jsonValue,
const DebugInfo* debug) const
{
+ cm::shared_lock<cm::shared_mutex> lock(ConnectionsMutex);
+ for (auto& connection : this->Connections) {
+ WriteJsonObject(connection.get(), jsonValue, debug);
+ }
+}
+
+void cmServer::WriteJsonObject(cmConnection* connection,
+ const Json::Value& jsonValue,
+ const DebugInfo* debug) const
+{
Json::FastWriter writer;
auto beforeJson = uv_hrtime();
@@ -272,8 +293,7 @@ void cmServer::WriteJsonObject(const Json::Value& jsonValue,
}
}
- Connection->WriteData(std::string("\n") + kSTART_MAGIC + std::string("\n") +
- result + kEND_MAGIC + std::string("\n"));
+ connection->WriteData(result);
}
cmServerProtocol* cmServer::FindMatchingProtocol(
@@ -311,7 +331,7 @@ void cmServer::WriteProgress(const cmServerRequest& request, int min,
obj[kPROGRESS_MAXIMUM_KEY] = max;
obj[kPROGRESS_CURRENT_KEY] = current;
- this->WriteJsonObject(obj, nullptr);
+ this->WriteJsonObject(request.Connection, obj, nullptr);
}
void cmServer::WriteMessage(const cmServerRequest& request,
@@ -331,10 +351,11 @@ void cmServer::WriteMessage(const cmServerRequest& request,
obj[kTITLE_KEY] = title;
}
- WriteJsonObject(obj, nullptr);
+ WriteJsonObject(request.Connection, obj, nullptr);
}
-void cmServer::WriteParseError(const std::string& message) const
+void cmServer::WriteParseError(cmConnection* connection,
+ const std::string& message) const
{
Json::Value obj = Json::objectValue;
obj[kTYPE_KEY] = kERROR_TYPE;
@@ -342,7 +363,7 @@ void cmServer::WriteParseError(const std::string& message) const
obj[kREPLY_TO_KEY] = "";
obj[kCOOKIE_KEY] = "";
- this->WriteJsonObject(obj, nullptr);
+ this->WriteJsonObject(connection, obj, nullptr);
}
void cmServer::WriteSignal(const std::string& name,
@@ -358,7 +379,8 @@ void cmServer::WriteSignal(const std::string& name,
WriteJsonObject(obj, nullptr);
}
-void cmServer::WriteResponse(const cmServerResponse& response,
+void cmServer::WriteResponse(cmConnection* connection,
+ const cmServerResponse& response,
const DebugInfo* debug) const
{
assert(response.IsComplete());
@@ -371,5 +393,180 @@ void cmServer::WriteResponse(const cmServerResponse& response,
obj[kERROR_MESSAGE_KEY] = response.ErrorMessage();
}
- this->WriteJsonObject(obj, debug);
+ this->WriteJsonObject(connection, obj, debug);
+}
+
+void cmServer::OnConnected(cmConnection* connection)
+{
+ PrintHello(connection);
+}
+
+void cmServer::OnServeStart()
+{
+ cmServerBase::OnServeStart();
+ fileMonitor = std::make_shared<cmFileMonitor>(GetLoop());
+}
+
+void cmServer::StartShutDown()
+{
+ if (fileMonitor) {
+ fileMonitor->StopMonitoring();
+ fileMonitor.reset();
+ }
+ cmServerBase::StartShutDown();
+}
+
+static void __start_thread(void* arg)
+{
+ auto server = static_cast<cmServerBase*>(arg);
+ std::string error;
+ bool success = server->Serve(&error);
+ if (!success || !error.empty()) {
+ std::cerr << "Error during serve: " << error << std::endl;
+ }
+}
+
+bool cmServerBase::StartServeThread()
+{
+ ServeThreadRunning = true;
+ uv_thread_create(&ServeThread, __start_thread, this);
+ return true;
+}
+
+static void __shutdownThread(uv_async_t* arg)
+{
+ auto server = static_cast<cmServerBase*>(arg->data);
+ server->StartShutDown();
+}
+
+bool cmServerBase::Serve(std::string* errorMessage)
+{
+#ifndef NDEBUG
+ uv_thread_t blank_thread_t = {};
+ assert(uv_thread_equal(&blank_thread_t, &ServeThreadId));
+ ServeThreadId = uv_thread_self();
+#endif
+
+ errorMessage->clear();
+
+ ShutdownSignal.init(Loop, __shutdownThread, this);
+
+ SIGINTHandler.init(Loop, this);
+ SIGHUPHandler.init(Loop, this);
+
+ SIGINTHandler.start(&on_signal, SIGINT);
+ SIGHUPHandler.start(&on_signal, SIGHUP);
+
+ OnServeStart();
+
+ {
+ cm::shared_lock<cm::shared_mutex> lock(ConnectionsMutex);
+ for (auto& connection : Connections) {
+ if (!connection->OnServeStart(errorMessage)) {
+ return false;
+ }
+ }
+ }
+
+ if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) {
+ // It is important we don't ever let the event loop exit with open handles
+ // at best this is a memory leak, but it can also introduce race conditions
+ // which can hang the program.
+ assert(false && "Event loop stopped in unclean state.");
+
+ *errorMessage = "Internal Error: Event loop stopped in unclean state.";
+ return false;
+ }
+
+ return true;
+}
+
+void cmServerBase::OnConnected(cmConnection*)
+{
+}
+
+void cmServerBase::OnServeStart()
+{
+}
+
+void cmServerBase::StartShutDown()
+{
+ ShutdownSignal.reset();
+ SIGINTHandler.reset();
+ SIGHUPHandler.reset();
+
+ {
+ std::unique_lock<cm::shared_mutex> lock(ConnectionsMutex);
+ for (auto& connection : Connections) {
+ connection->OnConnectionShuttingDown();
+ }
+ Connections.clear();
+ }
+
+ uv_walk(&Loop, on_walk_to_shutdown, nullptr);
+}
+
+bool cmServerBase::OnSignal(int signum)
+{
+ (void)signum;
+ StartShutDown();
+ return true;
+}
+
+cmServerBase::cmServerBase(cmConnection* connection)
+{
+ auto err = uv_loop_init(&Loop);
+ (void)err;
+ Loop.data = this;
+ assert(err == 0);
+
+ AddNewConnection(connection);
+}
+
+void cmServerBase::Close()
+{
+ if (Loop.data) {
+ if (ServeThreadRunning) {
+ this->ShutdownSignal.send();
+ uv_thread_join(&ServeThread);
+ }
+
+ uv_loop_close(&Loop);
+ Loop.data = nullptr;
+ }
+}
+cmServerBase::~cmServerBase()
+{
+ Close();
+}
+
+void cmServerBase::AddNewConnection(cmConnection* ownedConnection)
+{
+ {
+ std::unique_lock<cm::shared_mutex> lock(ConnectionsMutex);
+ Connections.emplace_back(ownedConnection);
+ }
+ ownedConnection->SetServer(this);
+}
+
+uv_loop_t* cmServerBase::GetLoop()
+{
+ return &Loop;
+}
+
+void cmServerBase::OnDisconnect(cmConnection* pConnection)
+{
+ auto pred = [pConnection](const std::unique_ptr<cmConnection>& m) {
+ return m.get() == pConnection;
+ };
+ {
+ std::unique_lock<cm::shared_mutex> lock(ConnectionsMutex);
+ Connections.erase(
+ std::remove_if(Connections.begin(), Connections.end(), pred),
+ Connections.end());
+ }
+
+ if (Connections.empty()) {
+ this->ShutdownSignal.send();
+ }
}
diff --git a/Source/cmServer.h b/Source/cmServer.h
index b8140504c..3d7027b39 100644
--- a/Source/cmServer.h
+++ b/Source/cmServer.h
@@ -2,31 +2,103 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include <cm/shared_mutex>
#include "cm_jsoncpp_value.h"
#include "cm_uv.h"
-#include <string>
-#include <vector>
+#include "cmUVHandlePtr.h"
+class cmConnection;
class cmFileMonitor;
-class cmServerConnection;
class cmServerProtocol;
class cmServerRequest;
class cmServerResponse;
-class cmServer
+/***
+ * This essentially hold and manages a libuv event queue and responds to
+ * messages
+ * on any of its connections.
+ */
+class cmServerBase
{
- CM_DISABLE_COPY(cmServer)
+public:
+ cmServerBase(cmConnection* connection);
+ virtual ~cmServerBase();
+
+ virtual void AddNewConnection(cmConnection* ownedConnection);
+
+ /***
+ * The main override responsible for tailoring behavior towards
+ * whatever the given server is supposed to do
+ *
+ * This should almost always be called by the given connections
+ * directly.
+ *
+ * @param connection The connection the request was received on
+ * @param request The actual request
+ */
+ virtual void ProcessRequest(cmConnection* connection,
+ const std::string& request) = 0;
+ virtual void OnConnected(cmConnection* connection);
+
+ /***
+ * Start a dedicated thread. If this is used to start the server, it will
+ * join on the
+ * servers dtor.
+ */
+ virtual bool StartServeThread();
+ virtual bool Serve(std::string* errorMessage);
+
+ virtual void OnServeStart();
+ virtual void StartShutDown();
+
+ virtual bool OnSignal(int signum);
+ uv_loop_t* GetLoop();
+ void Close();
+ void OnDisconnect(cmConnection* pConnection);
+
+protected:
+ mutable cm::shared_mutex ConnectionsMutex;
+ std::vector<std::unique_ptr<cmConnection>> Connections;
+
+ bool ServeThreadRunning = false;
+ uv_thread_t ServeThread;
+ cm::uv_async_ptr ShutdownSignal;
+#ifndef NDEBUG
+public:
+ // When the server starts it will mark down it's current thread ID,
+ // which is useful in other contexts to just assert that operations
+ // are performed on that same thread.
+ uv_thread_t ServeThreadId = {};
+
+protected:
+#endif
+ uv_loop_t Loop;
+
+ cm::uv_signal_ptr SIGINTHandler;
+ cm::uv_signal_ptr SIGHUPHandler;
+};
+
+class cmServer : public cmServerBase
+{
public:
class DebugInfo;
- cmServer(cmServerConnection* conn, bool supportExperimental);
- ~cmServer();
+ cmServer(cmConnection* conn, bool supportExperimental);
+ ~cmServer() override;
+
+ cmServer(cmServer const&) = delete;
+ cmServer& operator=(cmServer const&) = delete;
- bool Serve(std::string* errorMessage);
+ bool Serve(std::string* errorMessage) override;
cmFileMonitor* FileMonitor() const;
@@ -34,60 +106,56 @@ private:
void RegisterProtocol(cmServerProtocol* protocol);
// Callbacks from cmServerConnection:
- void PopOne();
- void QueueRequest(const std::string& request);
- static void reportProgress(const char* msg, float progress, void* data);
- static void reportMessage(const char* msg, const char* title, bool& cancel,
- void* data);
+ void ProcessRequest(cmConnection* connection,
+ const std::string& request) override;
+ std::shared_ptr<cmFileMonitor> fileMonitor;
+
+public:
+ void OnServeStart() override;
+
+ void StartShutDown() override;
+
+public:
+ void OnConnected(cmConnection* connection) override;
+
+private:
+ static void reportProgress(const std::string& msg, float progress,
+ const cmServerRequest& request);
+ static void reportMessage(const std::string& msg, const char* title,
+ const cmServerRequest& request);
// Handle requests:
cmServerResponse SetProtocolVersion(const cmServerRequest& request);
- void PrintHello() const;
+ void PrintHello(cmConnection* connection) const;
// Write responses:
void WriteProgress(const cmServerRequest& request, int min, int current,
int max, const std::string& message) const;
void WriteMessage(const cmServerRequest& request, const std::string& message,
const std::string& title) const;
- void WriteResponse(const cmServerResponse& response,
+ void WriteResponse(cmConnection* connection,
+ const cmServerResponse& response,
const DebugInfo* debug) const;
- void WriteParseError(const std::string& message) const;
+ void WriteParseError(cmConnection* connection,
+ const std::string& message) const;
void WriteSignal(const std::string& name, const Json::Value& obj) const;
void WriteJsonObject(Json::Value const& jsonValue,
const DebugInfo* debug) const;
+ void WriteJsonObject(cmConnection* connection, Json::Value const& jsonValue,
+ const DebugInfo* debug) const;
+
static cmServerProtocol* FindMatchingProtocol(
const std::vector<cmServerProtocol*>& protocols, int major, int minor);
- cmServerConnection* Connection = nullptr;
const bool SupportExperimental;
cmServerProtocol* Protocol = nullptr;
std::vector<cmServerProtocol*> SupportedProtocols;
- std::vector<std::string> Queue;
-
- std::string DataBuffer;
- std::string JsonData;
-
- uv_loop_t* Loop = nullptr;
-
- typedef union
- {
- uv_tty_t tty;
- uv_pipe_t pipe;
- } InOutUnion;
-
- InOutUnion Input;
- InOutUnion Output;
- uv_stream_t* InputStream = nullptr;
- uv_stream_t* OutputStream = nullptr;
-
- mutable bool Writing = false;
- friend class cmServerConnection;
friend class cmServerProtocol;
friend class cmServerRequest;
};
diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx
index 36312edf4..279197214 100644
--- a/Source/cmServerConnection.cxx
+++ b/Source/cmServerConnection.cxx
@@ -1,377 +1,165 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmConfigure.h"
+
#include "cmServerConnection.h"
-#include "cmFileMonitor.h"
+#include "cm_uv.h"
+
#include "cmServer.h"
#include "cmServerDictionary.h"
-#include <assert.h>
-#include <string.h>
+#ifdef _WIN32
+# include "io.h"
+#else
+# include <unistd.h>
+#endif
+#include <cassert>
+#include <utility>
-namespace {
-
-struct write_req_t
+cmStdIoConnection::cmStdIoConnection(
+ cmConnectionBufferStrategy* bufferStrategy)
+ : cmEventBasedConnection(bufferStrategy)
{
- uv_write_t req;
- uv_buf_t buf;
-};
-
-void on_alloc_buffer(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf)
-{
- (void)(handle);
- char* rawBuffer = new char[suggested_size];
- *buf = uv_buf_init(rawBuffer, static_cast<unsigned int>(suggested_size));
}
-void on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf)
+cm::uv_stream_ptr cmStdIoConnection::SetupStream(int file_id)
{
- auto conn = reinterpret_cast<cmServerConnection*>(stream->data);
- if (nread >= 0) {
- conn->ReadData(std::string(buf->base, buf->base + nread));
- } else {
- conn->TriggerShutdown();
+ switch (uv_guess_handle(file_id)) {
+ case UV_TTY: {
+ cm::uv_tty_ptr tty;
+ tty.init(*this->Server->GetLoop(), file_id, file_id == 0,
+ static_cast<cmEventBasedConnection*>(this));
+ uv_tty_set_mode(tty, UV_TTY_MODE_NORMAL);
+ return { std::move(tty) };
+ }
+ case UV_FILE:
+ if (file_id == 0) {
+ return nullptr;
+ }
+ // Intentional fallthrough; stdin can _not_ be treated as a named
+ // pipe, however stdout can be.
+ CM_FALLTHROUGH;
+ case UV_NAMED_PIPE: {
+ cm::uv_pipe_ptr pipe;
+ pipe.init(*this->Server->GetLoop(), 0,
+ static_cast<cmEventBasedConnection*>(this));
+ uv_pipe_open(pipe, file_id);
+ return { std::move(pipe) };
+ }
+ default:
+ assert(false && "Unable to determine stream type");
+ return nullptr;
}
-
- delete[](buf->base);
}
-void on_write(uv_write_t* req, int status)
+void cmStdIoConnection::SetServer(cmServerBase* s)
{
- (void)(status);
- auto conn = reinterpret_cast<cmServerConnection*>(req->data);
-
- // Free req and buffer
- write_req_t* wr = reinterpret_cast<write_req_t*>(req);
- delete[](wr->buf.base);
- delete wr;
-
- conn->ProcessNextRequest();
-}
+ cmConnection::SetServer(s);
+ if (!s) {
+ return;
+ }
-void on_new_connection(uv_stream_t* stream, int status)
-{
- (void)(status);
- auto conn = reinterpret_cast<cmServerConnection*>(stream->data);
- conn->Connect(stream);
+ this->ReadStream = SetupStream(0);
+ this->WriteStream = SetupStream(1);
}
-void on_signal(uv_signal_t* signal, int signum)
+void shutdown_connection(uv_prepare_t* prepare)
{
- auto conn = reinterpret_cast<cmServerConnection*>(signal->data);
- (void)(signum);
- conn->TriggerShutdown();
-}
+ cmStdIoConnection* connection =
+ static_cast<cmStdIoConnection*>(prepare->data);
-void on_signal_close(uv_handle_t* handle)
-{
- delete reinterpret_cast<uv_signal_t*>(handle);
+ if (!uv_is_closing(reinterpret_cast<uv_handle_t*>(prepare))) {
+ uv_close(reinterpret_cast<uv_handle_t*>(prepare),
+ &cmEventBasedConnection::on_close_delete<uv_prepare_t>);
+ }
+ connection->OnDisconnect(0);
}
-void on_pipe_close(uv_handle_t* handle)
+bool cmStdIoConnection::OnServeStart(std::string* pString)
{
- delete reinterpret_cast<uv_pipe_t*>(handle);
-}
+ Server->OnConnected(this);
+ if (this->ReadStream.get()) {
+ uv_read_start(this->ReadStream, on_alloc_buffer, on_read);
+ } else if (uv_guess_handle(0) == UV_FILE) {
+ char buffer[1024];
+ while (auto len = read(0, buffer, sizeof(buffer))) {
+ ReadData(std::string(buffer, buffer + len));
+ }
-void on_tty_close(uv_handle_t* handle)
-{
- delete reinterpret_cast<uv_tty_t*>(handle);
+ // We can't start the disconnect from here, add a prepare hook to do that
+ // for us
+ auto prepare = new uv_prepare_t();
+ prepare->data = this;
+ uv_prepare_init(Server->GetLoop(), prepare);
+ uv_prepare_start(prepare, shutdown_connection);
+ }
+ return cmConnection::OnServeStart(pString);
}
-} // namespace
-
-class LoopGuard
+bool cmStdIoConnection::OnConnectionShuttingDown()
{
-public:
- LoopGuard(cmServerConnection* connection)
- : Connection(connection)
- {
- this->Connection->mLoop = uv_default_loop();
- if (!this->Connection->mLoop) {
- return;
- }
- this->Connection->mFileMonitor =
- new cmFileMonitor(this->Connection->mLoop);
+ if (ReadStream.get()) {
+ uv_read_stop(ReadStream);
+ ReadStream->data = nullptr;
}
- ~LoopGuard()
- {
- if (!this->Connection->mLoop) {
- return;
- }
+ this->ReadStream.reset();
- if (this->Connection->mFileMonitor) {
- delete this->Connection->mFileMonitor;
- }
- uv_loop_close(this->Connection->mLoop);
- this->Connection->mLoop = nullptr;
- }
+ cmEventBasedConnection::OnConnectionShuttingDown();
-private:
- cmServerConnection* Connection;
-};
+ return true;
+}
-cmServerConnection::cmServerConnection()
+cmServerPipeConnection::cmServerPipeConnection(const std::string& name)
+ : cmPipeConnection(name, new cmServerBufferStrategy)
{
}
-cmServerConnection::~cmServerConnection()
+cmServerStdIoConnection::cmServerStdIoConnection()
+ : cmStdIoConnection(new cmServerBufferStrategy)
{
}
-void cmServerConnection::SetServer(cmServer* s)
+cmConnectionBufferStrategy::~cmConnectionBufferStrategy() = default;
+
+void cmConnectionBufferStrategy::clear()
{
- this->Server = s;
}
-bool cmServerConnection::ProcessEvents(std::string* errorMessage)
+std::string cmServerBufferStrategy::BufferOutMessage(
+ const std::string& rawBuffer) const
{
- assert(this->Server);
- errorMessage->clear();
-
- this->RawReadBuffer.clear();
- this->RequestBuffer.clear();
-
- LoopGuard guard(this);
- (void)(guard);
- if (!this->mLoop) {
- *errorMessage = "Internal Error: Failed to create event loop.";
- return false;
- }
-
- this->SIGINTHandler = new uv_signal_t;
- uv_signal_init(this->mLoop, this->SIGINTHandler);
- this->SIGINTHandler->data = static_cast<void*>(this);
- uv_signal_start(this->SIGINTHandler, &on_signal, SIGINT);
-
- this->SIGHUPHandler = new uv_signal_t;
- uv_signal_init(this->mLoop, this->SIGHUPHandler);
- this->SIGHUPHandler->data = static_cast<void*>(this);
- uv_signal_start(this->SIGHUPHandler, &on_signal, SIGHUP);
-
- if (!DoSetup(errorMessage)) {
- return false;
- }
-
- if (uv_run(this->mLoop, UV_RUN_DEFAULT) != 0) {
- *errorMessage = "Internal Error: Event loop stopped in unclean state.";
- return false;
- }
-
- // These need to be cleaned up by now:
- assert(!this->ReadStream);
- assert(!this->WriteStream);
-
- this->RawReadBuffer.clear();
- this->RequestBuffer.clear();
-
- return true;
+ return std::string("\n") + kSTART_MAGIC + std::string("\n") + rawBuffer +
+ kEND_MAGIC + std::string("\n");
}
-void cmServerConnection::ReadData(const std::string& data)
+std::string cmServerBufferStrategy::BufferMessage(std::string& RawReadBuffer)
{
- this->RawReadBuffer += data;
-
for (;;) {
- auto needle = this->RawReadBuffer.find('\n');
+ auto needle = RawReadBuffer.find('\n');
if (needle == std::string::npos) {
- return;
+ return "";
}
- std::string line = this->RawReadBuffer.substr(0, needle);
+ std::string line = RawReadBuffer.substr(0, needle);
const auto ls = line.size();
if (ls > 1 && line.at(ls - 1) == '\r') {
line.erase(ls - 1, 1);
}
- this->RawReadBuffer.erase(this->RawReadBuffer.begin(),
- this->RawReadBuffer.begin() +
- static_cast<long>(needle) + 1);
+ RawReadBuffer.erase(RawReadBuffer.begin(),
+ RawReadBuffer.begin() + static_cast<long>(needle) + 1);
if (line == kSTART_MAGIC) {
- this->RequestBuffer.clear();
+ RequestBuffer.clear();
continue;
}
if (line == kEND_MAGIC) {
- this->Server->QueueRequest(this->RequestBuffer);
- this->RequestBuffer.clear();
- } else {
- this->RequestBuffer += line;
- this->RequestBuffer += "\n";
+ std::string rtn;
+ rtn.swap(this->RequestBuffer);
+ return rtn;
}
- }
-}
-
-void cmServerConnection::TriggerShutdown()
-{
- this->FileMonitor()->StopMonitoring();
- uv_signal_stop(this->SIGINTHandler);
- uv_signal_stop(this->SIGHUPHandler);
-
- uv_close(reinterpret_cast<uv_handle_t*>(this->SIGINTHandler),
- &on_signal_close); // delete handle
- uv_close(reinterpret_cast<uv_handle_t*>(this->SIGHUPHandler),
- &on_signal_close); // delete handle
-
- this->SIGINTHandler = nullptr;
- this->SIGHUPHandler = nullptr;
-
- this->TearDown();
-}
-
-void cmServerConnection::WriteData(const std::string& data)
-{
- assert(this->WriteStream);
-
- auto ds = data.size();
-
- write_req_t* req = new write_req_t;
- req->req.data = this;
- req->buf = uv_buf_init(new char[ds], static_cast<unsigned int>(ds));
- memcpy(req->buf.base, data.c_str(), ds);
-
- uv_write(reinterpret_cast<uv_write_t*>(req),
- static_cast<uv_stream_t*>(this->WriteStream), &req->buf, 1,
- on_write);
-}
-
-void cmServerConnection::ProcessNextRequest()
-{
- Server->PopOne();
-}
-
-void cmServerConnection::SendGreetings()
-{
- Server->PrintHello();
-}
-
-cmServerStdIoConnection::cmServerStdIoConnection()
-{
- this->Input.tty = nullptr;
- this->Output.tty = nullptr;
-}
-
-bool cmServerStdIoConnection::DoSetup(std::string* errorMessage)
-{
- (void)(errorMessage);
-
- if (uv_guess_handle(1) == UV_TTY) {
- usesTty = true;
- this->Input.tty = new uv_tty_t;
- uv_tty_init(this->Loop(), this->Input.tty, 0, 1);
- uv_tty_set_mode(this->Input.tty, UV_TTY_MODE_NORMAL);
- Input.tty->data = this;
- this->ReadStream = reinterpret_cast<uv_stream_t*>(this->Input.tty);
-
- this->Output.tty = new uv_tty_t;
- uv_tty_init(this->Loop(), this->Output.tty, 1, 0);
- uv_tty_set_mode(this->Output.tty, UV_TTY_MODE_NORMAL);
- Output.tty->data = this;
- this->WriteStream = reinterpret_cast<uv_stream_t*>(this->Output.tty);
- } else {
- usesTty = false;
- this->Input.pipe = new uv_pipe_t;
- uv_pipe_init(this->Loop(), this->Input.pipe, 0);
- uv_pipe_open(this->Input.pipe, 0);
- Input.pipe->data = this;
- this->ReadStream = reinterpret_cast<uv_stream_t*>(this->Input.pipe);
-
- this->Output.pipe = new uv_pipe_t;
- uv_pipe_init(this->Loop(), this->Output.pipe, 0);
- uv_pipe_open(this->Output.pipe, 1);
- Output.pipe->data = this;
- this->WriteStream = reinterpret_cast<uv_stream_t*>(this->Output.pipe);
- }
-
- SendGreetings();
- uv_read_start(this->ReadStream, on_alloc_buffer, on_read);
-
- return true;
-}
-
-void cmServerStdIoConnection::TearDown()
-{
- if (usesTty) {
- uv_close(reinterpret_cast<uv_handle_t*>(this->Input.tty), &on_tty_close);
- uv_close(reinterpret_cast<uv_handle_t*>(this->Output.tty), &on_tty_close);
- this->Input.tty = nullptr;
- this->Output.tty = nullptr;
- } else {
- uv_close(reinterpret_cast<uv_handle_t*>(this->Input.pipe), &on_pipe_close);
- uv_close(reinterpret_cast<uv_handle_t*>(this->Output.pipe),
- &on_pipe_close);
- this->Input.pipe = nullptr;
- this->Input.pipe = nullptr;
- }
- this->ReadStream = nullptr;
- this->WriteStream = nullptr;
-}
-
-cmServerPipeConnection::cmServerPipeConnection(const std::string& name)
- : PipeName(name)
-{
-}
-
-bool cmServerPipeConnection::DoSetup(std::string* errorMessage)
-{
- this->ServerPipe = new uv_pipe_t;
- uv_pipe_init(this->Loop(), this->ServerPipe, 0);
- this->ServerPipe->data = this;
-
- int r;
- if ((r = uv_pipe_bind(this->ServerPipe, this->PipeName.c_str())) != 0) {
- *errorMessage = std::string("Internal Error with ") + this->PipeName +
- ": " + uv_err_name(r);
- return false;
- }
- auto serverStream = reinterpret_cast<uv_stream_t*>(this->ServerPipe);
- if ((r = uv_listen(serverStream, 1, on_new_connection)) != 0) {
- *errorMessage = std::string("Internal Error listening on ") +
- this->PipeName + ": " + uv_err_name(r);
- return false;
+ this->RequestBuffer += line;
+ this->RequestBuffer += "\n";
}
-
- return true;
-}
-
-void cmServerPipeConnection::TearDown()
-{
- if (this->ClientPipe) {
- uv_close(reinterpret_cast<uv_handle_t*>(this->ClientPipe), &on_pipe_close);
- this->WriteStream->data = nullptr;
- }
- uv_close(reinterpret_cast<uv_handle_t*>(this->ServerPipe), &on_pipe_close);
-
- this->ClientPipe = nullptr;
- this->ServerPipe = nullptr;
- this->WriteStream = nullptr;
- this->ReadStream = nullptr;
-}
-
-void cmServerPipeConnection::Connect(uv_stream_t* server)
-{
- if (this->ClientPipe) {
- // Accept and close all pipes but the first:
- uv_pipe_t* rejectPipe = new uv_pipe_t;
-
- uv_pipe_init(this->Loop(), rejectPipe, 0);
- auto rejecter = reinterpret_cast<uv_stream_t*>(rejectPipe);
- uv_accept(server, rejecter);
- uv_close(reinterpret_cast<uv_handle_t*>(rejecter), &on_pipe_close);
- return;
- }
-
- this->ClientPipe = new uv_pipe_t;
- uv_pipe_init(this->Loop(), this->ClientPipe, 0);
- this->ClientPipe->data = this;
- auto client = reinterpret_cast<uv_stream_t*>(this->ClientPipe);
- if (uv_accept(server, client) != 0) {
- uv_close(reinterpret_cast<uv_handle_t*>(client), nullptr);
- return;
- }
- this->ReadStream = client;
- this->WriteStream = client;
-
- uv_read_start(this->ReadStream, on_alloc_buffer, on_read);
-
- this->SendGreetings();
}
diff --git a/Source/cmServerConnection.h b/Source/cmServerConnection.h
index b96bf3c54..a70edb4b5 100644
--- a/Source/cmServerConnection.h
+++ b/Source/cmServerConnection.h
@@ -2,94 +2,66 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once
-#include "cmConfigure.h"
-
-#include "cm_uv.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
-class cmFileMonitor;
-class cmServer;
+#include "cmConnection.h"
+#include "cmPipeConnection.h"
+#include "cmUVHandlePtr.h"
-class cmServerConnection
-{
- CM_DISABLE_COPY(cmServerConnection)
+class cmServerBase;
+/***
+ * This connection buffer strategy accepts messages in the form of
+ * [== "CMake Server" ==[
+{
+ ... some JSON message ...
+}
+]== "CMake Server" ==]
+ * and only passes on the core json; it discards the envelope.
+ */
+class cmServerBufferStrategy : public cmConnectionBufferStrategy
+{
public:
- cmServerConnection();
- virtual ~cmServerConnection();
-
- void SetServer(cmServer* s);
-
- bool ProcessEvents(std::string* errorMessage);
-
- void ReadData(const std::string& data);
- void TriggerShutdown();
- void WriteData(const std::string& data);
- void ProcessNextRequest();
+ std::string BufferMessage(std::string& rawBuffer) override;
+ std::string BufferOutMessage(const std::string& rawBuffer) const override;
- virtual void Connect(uv_stream_t* server) { (void)(server); }
-
- cmFileMonitor* FileMonitor() const { return this->mFileMonitor; }
-
-protected:
- virtual bool DoSetup(std::string* errorMessage) = 0;
- virtual void TearDown() = 0;
+private:
+ std::string RequestBuffer;
+};
- void SendGreetings();
+/***
+ * Generic connection over std io interfaces -- tty
+ */
+class cmStdIoConnection : public cmEventBasedConnection
+{
+public:
+ cmStdIoConnection(cmConnectionBufferStrategy* bufferStrategy);
- uv_loop_t* Loop() const { return mLoop; }
+ void SetServer(cmServerBase* s) override;
-protected:
- std::string RawReadBuffer;
- std::string RequestBuffer;
+ bool OnConnectionShuttingDown() override;
- uv_stream_t* ReadStream = nullptr;
- uv_stream_t* WriteStream = nullptr;
+ bool OnServeStart(std::string* pString) override;
private:
- uv_loop_t* mLoop = nullptr;
- cmFileMonitor* mFileMonitor = nullptr;
- cmServer* Server = nullptr;
- uv_signal_t* SIGINTHandler = nullptr;
- uv_signal_t* SIGHUPHandler = nullptr;
-
- friend class LoopGuard;
+ cm::uv_stream_ptr SetupStream(int file_id);
+ cm::uv_stream_ptr ReadStream;
};
-class cmServerStdIoConnection : public cmServerConnection
+/***
+ * These specific connections use the cmake server
+ * buffering strategy.
+ */
+class cmServerStdIoConnection : public cmStdIoConnection
{
public:
cmServerStdIoConnection();
- bool DoSetup(std::string* errorMessage) override;
-
- void TearDown() override;
-
-private:
- typedef union
- {
- uv_tty_t* tty;
- uv_pipe_t* pipe;
- } InOutUnion;
-
- bool usesTty = false;
-
- InOutUnion Input;
- InOutUnion Output;
};
-class cmServerPipeConnection : public cmServerConnection
+class cmServerPipeConnection : public cmPipeConnection
{
public:
cmServerPipeConnection(const std::string& name);
- bool DoSetup(std::string* errorMessage) override;
-
- void TearDown() override;
-
- void Connect(uv_stream_t* server) override;
-
-private:
- const std::string PipeName;
- uv_pipe_t* ServerPipe = nullptr;
- uv_pipe_t* ClientPipe = nullptr;
};
diff --git a/Source/cmServerDictionary.h b/Source/cmServerDictionary.h
index e6a7ae6ca..961e4b7ea 100644
--- a/Source/cmServerDictionary.h
+++ b/Source/cmServerDictionary.h
@@ -23,66 +23,37 @@ static const std::string kPROGRESS_TYPE = "progress";
static const std::string kREPLY_TYPE = "reply";
static const std::string kSET_GLOBAL_SETTINGS_TYPE = "setGlobalSettings";
static const std::string kSIGNAL_TYPE = "signal";
+static const std::string kCTEST_INFO_TYPE = "ctestInfo";
-static const std::string kARTIFACTS_KEY = "artifacts";
-static const std::string kBUILD_DIRECTORY_KEY = "buildDirectory";
static const std::string kBUILD_FILES_KEY = "buildFiles";
static const std::string kCACHE_ARGUMENTS_KEY = "cacheArguments";
static const std::string kCACHE_KEY = "cache";
static const std::string kCAPABILITIES_KEY = "capabilities";
static const std::string kCHECK_SYSTEM_VARS_KEY = "checkSystemVars";
static const std::string kCMAKE_ROOT_DIRECTORY_KEY = "cmakeRootDirectory";
-static const std::string kCOMPILE_FLAGS_KEY = "compileFlags";
-static const std::string kCONFIGURATIONS_KEY = "configurations";
static const std::string kCOOKIE_KEY = "cookie";
static const std::string kDEBUG_OUTPUT_KEY = "debugOutput";
-static const std::string kDEFINES_KEY = "defines";
static const std::string kERROR_MESSAGE_KEY = "errorMessage";
static const std::string kEXTRA_GENERATOR_KEY = "extraGenerator";
-static const std::string kFILE_GROUPS_KEY = "fileGroups";
-static const std::string kFRAMEWORK_PATH_KEY = "frameworkPath";
-static const std::string kFULL_NAME_KEY = "fullName";
static const std::string kGENERATOR_KEY = "generator";
-static const std::string kINCLUDE_PATH_KEY = "includePath";
-static const std::string kIS_CMAKE_KEY = "isCMake";
static const std::string kIS_EXPERIMENTAL_KEY = "isExperimental";
-static const std::string kIS_GENERATED_KEY = "isGenerated";
-static const std::string kIS_SYSTEM_KEY = "isSystem";
-static const std::string kIS_TEMPORARY_KEY = "isTemporary";
-static const std::string kKEY_KEY = "key";
static const std::string kKEYS_KEY = "keys";
-static const std::string kLANGUAGE_KEY = "language";
-static const std::string kLINKER_LANGUAGE_KEY = "linkerLanguage";
-static const std::string kLINK_FLAGS_KEY = "linkFlags";
-static const std::string kLINK_LANGUAGE_FLAGS_KEY = "linkLanguageFlags";
-static const std::string kLINK_LIBRARIES_KEY = "linkLibraries";
-static const std::string kLINK_PATH_KEY = "linkPath";
static const std::string kMAJOR_KEY = "major";
static const std::string kMESSAGE_KEY = "message";
static const std::string kMINOR_KEY = "minor";
-static const std::string kNAME_KEY = "name";
-static const std::string kPATH_KEY = "path";
static const std::string kPLATFORM_KEY = "platform";
static const std::string kPROGRESS_CURRENT_KEY = "progressCurrent";
static const std::string kPROGRESS_MAXIMUM_KEY = "progressMaximum";
static const std::string kPROGRESS_MESSAGE_KEY = "progressMessage";
static const std::string kPROGRESS_MINIMUM_KEY = "progressMinimum";
-static const std::string kPROJECTS_KEY = "projects";
-static const std::string kPROPERTIES_KEY = "properties";
static const std::string kPROTOCOL_VERSION_KEY = "protocolVersion";
static const std::string kREPLY_TO_KEY = "inReplyTo";
-static const std::string kSOURCE_DIRECTORY_KEY = "sourceDirectory";
-static const std::string kSOURCES_KEY = "sources";
static const std::string kSUPPORTED_PROTOCOL_VERSIONS =
"supportedProtocolVersions";
-static const std::string kSYSROOT_KEY = "sysroot";
-static const std::string kTARGETS_KEY = "targets";
static const std::string kTITLE_KEY = "title";
static const std::string kTOOLSET_KEY = "toolset";
static const std::string kTRACE_EXPAND_KEY = "traceExpand";
static const std::string kTRACE_KEY = "trace";
-static const std::string kTYPE_KEY = "type";
-static const std::string kVALUE_KEY = "value";
static const std::string kWARN_UNINITIALIZED_KEY = "warnUninitialized";
static const std::string kWARN_UNUSED_CLI_KEY = "warnUnusedCli";
static const std::string kWARN_UNUSED_KEY = "warnUnused";
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index c5b7f6064..56003df75 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -2,134 +2,52 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmServerProtocol.h"
+#include <algorithm>
+#include <cassert>
+#include <functional>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include <cm/memory>
+
+#include "cm_uv.h"
+
+#include "cmAlgorithms.h"
#include "cmExternalMakefileProjectGenerator.h"
#include "cmFileMonitor.h"
-#include "cmGeneratorExpression.h"
-#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
-#include "cmLinkLineComputer.h"
-#include "cmLocalGenerator.h"
-#include "cmMakefile.h"
+#include "cmJsonObjectDictionary.h"
+#include "cmJsonObjects.h"
+#include "cmMessageType.h"
#include "cmServer.h"
#include "cmServerDictionary.h"
-#include "cmSourceFile.h"
#include "cmState.h"
-#include "cmStateDirectory.h"
-#include "cmStateSnapshot.h"
-#include "cmStateTypes.h"
#include "cmSystemTools.h"
-#include "cm_uv.h"
#include "cmake.h"
-#include <algorithm>
-#include <cassert>
-#include <cstddef>
-#include <functional>
-#include <limits>
-#include <map>
-#include <set>
-#include <string>
-#include <unordered_map>
-#include <vector>
-
// Get rid of some windows macros:
#undef max
namespace {
-std::vector<std::string> getConfigurations(const cmake* cm)
-{
- std::vector<std::string> configurations;
- auto makefiles = cm->GetGlobalGenerator()->GetMakefiles();
- if (makefiles.empty()) {
- return configurations;
- }
-
- makefiles[0]->GetConfigurations(configurations);
- if (configurations.empty()) {
- configurations.push_back("");
- }
- return configurations;
-}
-
-bool hasString(const Json::Value& v, const std::string& s)
-{
- return !v.isNull() &&
- std::any_of(v.begin(), v.end(),
- [s](const Json::Value& i) { return i.asString() == s; });
-}
-
-template <class T>
-Json::Value fromStringList(const T& in)
-{
- Json::Value result = Json::arrayValue;
- for (const std::string& i : in) {
- result.append(i);
- }
- return result;
-}
-
std::vector<std::string> toStringList(const Json::Value& in)
{
std::vector<std::string> result;
- for (const auto& it : in) {
+ for (auto const& it : in) {
result.push_back(it.asString());
}
return result;
}
-void getCMakeInputs(const cmGlobalGenerator* gg, const std::string& sourceDir,
- const std::string& buildDir,
- std::vector<std::string>* internalFiles,
- std::vector<std::string>* explicitFiles,
- std::vector<std::string>* tmpFiles)
-{
- const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot() + '/';
- std::vector<cmMakefile*> const& makefiles = gg->GetMakefiles();
- for (auto it = makefiles.begin(); it != makefiles.end(); ++it) {
- const std::vector<std::string> listFiles = (*it)->GetListFiles();
-
- for (auto jt = listFiles.begin(); jt != listFiles.end(); ++jt) {
-
- const std::string startOfFile = jt->substr(0, cmakeRootDir.size());
- const bool isInternal = (startOfFile == cmakeRootDir);
- const bool isTemporary = !isInternal && (jt->find(buildDir + '/') == 0);
-
- std::string toAdd = *jt;
- if (!sourceDir.empty()) {
- const std::string& relative =
- cmSystemTools::RelativePath(sourceDir.c_str(), jt->c_str());
- if (toAdd.size() > relative.size()) {
- toAdd = relative;
- }
- }
-
- if (isInternal) {
- if (internalFiles) {
- internalFiles->push_back(toAdd);
- }
- } else {
- if (isTemporary) {
- if (tmpFiles) {
- tmpFiles->push_back(toAdd);
- }
- } else {
- if (explicitFiles) {
- explicitFiles->push_back(toAdd);
- }
- }
- }
- }
- }
-}
-
} // namespace
-cmServerRequest::cmServerRequest(cmServer* server, const std::string& t,
- const std::string& c, const Json::Value& d)
- : Type(t)
- , Cookie(c)
- , Data(d)
+cmServerRequest::cmServerRequest(cmServer* server, cmConnection* connection,
+ std::string t, std::string c, Json::Value d)
+ : Type(std::move(t))
+ , Cookie(std::move(c))
+ , Data(std::move(d))
+ , Connection(connection)
, m_Server(server)
{
}
@@ -215,10 +133,11 @@ bool cmServerProtocol::Activate(cmServer* server,
{
assert(server);
this->m_Server = server;
- this->m_CMakeInstance = std::make_unique<cmake>(cmake::RoleProject);
+ this->m_CMakeInstance =
+ cm::make_unique<cmake>(cmake::RoleProject, cmState::Project);
const bool result = this->DoActivate(request, errorMessage);
if (!result) {
- this->m_CMakeInstance = CM_NULLPTR;
+ this->m_CMakeInstance = nullptr;
}
return result;
}
@@ -247,9 +166,9 @@ bool cmServerProtocol::DoActivate(const cmServerRequest& /*request*/,
return true;
}
-std::pair<int, int> cmServerProtocol1_0::ProtocolVersion() const
+std::pair<int, int> cmServerProtocol1::ProtocolVersion() const
{
- return std::make_pair(1, 0);
+ return { 1, 2 };
}
static void setErrorMessage(std::string* errorMessage, const std::string& text)
@@ -259,11 +178,15 @@ static void setErrorMessage(std::string* errorMessage, const std::string& text)
}
}
-static bool testHomeDirectory(cmState* state, std::string& value,
- std::string* errorMessage)
+static bool getOrTestHomeDirectory(cmState* state, std::string& value,
+ std::string* errorMessage)
{
const std::string cachedValue =
std::string(state->GetCacheEntryValue("CMAKE_HOME_DIRECTORY"));
+ if (value.empty()) {
+ value = cachedValue;
+ return true;
+ }
const std::string suffix = "/CMakeLists.txt";
const std::string cachedValueCML = cachedValue + suffix;
const std::string valueCML = value + suffix;
@@ -274,44 +197,53 @@ static bool testHomeDirectory(cmState* state, std::string& value,
"source directory value."));
return false;
}
- if (value.empty()) {
- value = cachedValue;
- }
return true;
}
-static bool testValue(cmState* state, const std::string& key,
- std::string& value, const std::string& keyDescription,
- std::string* errorMessage)
+static bool getOrTestValue(cmState* state, const std::string& key,
+ std::string& value,
+ const std::string& keyDescription,
+ std::string* errorMessage)
{
const char* entry = state->GetCacheEntryValue(key);
const std::string cachedValue =
entry == nullptr ? std::string() : std::string(entry);
- if (!cachedValue.empty() && !value.empty() && cachedValue != value) {
- setErrorMessage(errorMessage, std::string("\"") + key +
+ if (value.empty()) {
+ value = cachedValue;
+ }
+ if (!cachedValue.empty() && cachedValue != value) {
+ setErrorMessage(errorMessage,
+ std::string("\"") + key +
"\" is set but incompatible with configured " +
keyDescription + " value.");
return false;
}
- if (value.empty()) {
- value = cachedValue;
- }
return true;
}
-bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request,
- std::string* errorMessage)
+bool cmServerProtocol1::DoActivate(const cmServerRequest& request,
+ std::string* errorMessage)
{
std::string sourceDirectory = request.Data[kSOURCE_DIRECTORY_KEY].asString();
- const std::string buildDirectory =
- request.Data[kBUILD_DIRECTORY_KEY].asString();
+ std::string buildDirectory = request.Data[kBUILD_DIRECTORY_KEY].asString();
std::string generator = request.Data[kGENERATOR_KEY].asString();
std::string extraGenerator = request.Data[kEXTRA_GENERATOR_KEY].asString();
std::string toolset = request.Data[kTOOLSET_KEY].asString();
std::string platform = request.Data[kPLATFORM_KEY].asString();
+ // normalize source and build directory
+ if (!sourceDirectory.empty()) {
+ sourceDirectory = cmSystemTools::CollapseFullPath(sourceDirectory);
+ cmSystemTools::ConvertToUnixSlashes(sourceDirectory);
+ }
+ if (!buildDirectory.empty()) {
+ buildDirectory = cmSystemTools::CollapseFullPath(buildDirectory);
+ cmSystemTools::ConvertToUnixSlashes(buildDirectory);
+ }
+
if (buildDirectory.empty()) {
- setErrorMessage(errorMessage, std::string("\"") + kBUILD_DIRECTORY_KEY +
+ setErrorMessage(errorMessage,
+ std::string("\"") + kBUILD_DIRECTORY_KEY +
"\" is missing.");
return false;
}
@@ -319,58 +251,62 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request,
cmake* cm = CMakeInstance();
if (cmSystemTools::PathExists(buildDirectory)) {
if (!cmSystemTools::FileIsDirectory(buildDirectory)) {
- setErrorMessage(errorMessage, std::string("\"") + kBUILD_DIRECTORY_KEY +
+ setErrorMessage(errorMessage,
+ std::string("\"") + kBUILD_DIRECTORY_KEY +
"\" exists but is not a directory.");
return false;
}
- const std::string cachePath = cm->FindCacheFile(buildDirectory);
+ const std::string cachePath = cmake::FindCacheFile(buildDirectory);
if (cm->LoadCache(cachePath)) {
cmState* state = cm->GetState();
// Check generator:
- if (!testValue(state, "CMAKE_GENERATOR", generator, "generator",
- errorMessage)) {
+ if (!getOrTestValue(state, "CMAKE_GENERATOR", generator, "generator",
+ errorMessage)) {
return false;
}
// check extra generator:
- if (!testValue(state, "CMAKE_EXTRA_GENERATOR", extraGenerator,
- "extra generator", errorMessage)) {
+ if (!getOrTestValue(state, "CMAKE_EXTRA_GENERATOR", extraGenerator,
+ "extra generator", errorMessage)) {
return false;
}
// check sourcedir:
- if (!testHomeDirectory(state, sourceDirectory, errorMessage)) {
+ if (!getOrTestHomeDirectory(state, sourceDirectory, errorMessage)) {
return false;
}
// check toolset:
- if (!testValue(state, "CMAKE_GENERATOR_TOOLSET", toolset, "toolset",
- errorMessage)) {
+ if (!getOrTestValue(state, "CMAKE_GENERATOR_TOOLSET", toolset, "toolset",
+ errorMessage)) {
return false;
}
// check platform:
- if (!testValue(state, "CMAKE_GENERATOR_PLATFORM", platform, "platform",
- errorMessage)) {
+ if (!getOrTestValue(state, "CMAKE_GENERATOR_PLATFORM", platform,
+ "platform", errorMessage)) {
return false;
}
}
}
if (sourceDirectory.empty()) {
- setErrorMessage(errorMessage, std::string("\"") + kSOURCE_DIRECTORY_KEY +
+ setErrorMessage(errorMessage,
+ std::string("\"") + kSOURCE_DIRECTORY_KEY +
"\" is unset but required.");
return false;
}
if (!cmSystemTools::FileIsDirectory(sourceDirectory)) {
- setErrorMessage(errorMessage, std::string("\"") + kSOURCE_DIRECTORY_KEY +
+ setErrorMessage(errorMessage,
+ std::string("\"") + kSOURCE_DIRECTORY_KEY +
"\" is not a directory.");
return false;
}
if (generator.empty()) {
- setErrorMessage(errorMessage, std::string("\"") + kGENERATOR_KEY +
+ setErrorMessage(errorMessage,
+ std::string("\"") + kGENERATOR_KEY +
"\" is unset but required.");
return false;
}
@@ -382,7 +318,8 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request,
return info.name == generator;
});
if (baseIt == generators.end()) {
- setErrorMessage(errorMessage, std::string("Generator \"") + generator +
+ setErrorMessage(errorMessage,
+ std::string("Generator \"") + generator +
"\" not supported.");
return false;
}
@@ -419,8 +356,8 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request,
return true;
}
-void cmServerProtocol1_0::HandleCMakeFileChanges(const std::string& path,
- int event, int status)
+void cmServerProtocol1::HandleCMakeFileChanges(const std::string& path,
+ int event, int status)
{
assert(status == 0);
static_cast<void>(status);
@@ -443,8 +380,7 @@ void cmServerProtocol1_0::HandleCMakeFileChanges(const std::string& path,
SendSignal(kFILE_CHANGE_SIGNAL, obj);
}
-const cmServerResponse cmServerProtocol1_0::Process(
- const cmServerRequest& request)
+cmServerResponse cmServerProtocol1::Process(const cmServerRequest& request)
{
assert(this->m_State >= STATE_ACTIVE);
@@ -472,22 +408,21 @@ const cmServerResponse cmServerProtocol1_0::Process(
if (request.Type == kSET_GLOBAL_SETTINGS_TYPE) {
return this->ProcessSetGlobalSettings(request);
}
+ if (request.Type == kCTEST_INFO_TYPE) {
+ return this->ProcessCTests(request);
+ }
return request.ReportError("Unknown command!");
}
-bool cmServerProtocol1_0::IsExperimental() const
+bool cmServerProtocol1::IsExperimental() const
{
return true;
}
-cmServerResponse cmServerProtocol1_0::ProcessCache(
+cmServerResponse cmServerProtocol1::ProcessCache(
const cmServerRequest& request)
{
- if (this->m_State < STATE_CONFIGURED) {
- return request.ReportError("This project was not configured yet.");
- }
-
cmState* state = this->CMakeInstance()->GetState();
Json::Value result = Json::objectValue;
@@ -499,14 +434,14 @@ cmServerResponse cmServerProtocol1_0::ProcessCache(
if (keys.empty()) {
keys = allKeys;
} else {
- for (const auto& i : keys) {
- if (std::find(allKeys.begin(), allKeys.end(), i) == allKeys.end()) {
+ for (auto const& i : keys) {
+ if (!cmContains(allKeys, i)) {
return request.ReportError("Key \"" + i + "\" not found in cache.");
}
}
}
std::sort(keys.begin(), keys.end());
- for (const auto& key : keys) {
+ for (auto const& key : keys) {
Json::Value entry = Json::objectValue;
entry[kKEY_KEY] = key;
entry[kTYPE_KEY] =
@@ -515,7 +450,7 @@ cmServerResponse cmServerProtocol1_0::ProcessCache(
Json::Value props = Json::objectValue;
bool haveProperties = false;
- for (const auto& prop : state->GetCacheEntryPropertyList(key)) {
+ for (auto const& prop : state->GetCacheEntryPropertyList(key)) {
haveProperties = true;
props[prop] = state->GetCacheEntryProperty(key, prop);
}
@@ -530,7 +465,7 @@ cmServerResponse cmServerProtocol1_0::ProcessCache(
return request.Reply(result);
}
-cmServerResponse cmServerProtocol1_0::ProcessCMakeInputs(
+cmServerResponse cmServerProtocol1::ProcessCMakeInputs(
const cmServerRequest& request)
{
if (this->m_State < STATE_CONFIGURED) {
@@ -538,398 +473,27 @@ cmServerResponse cmServerProtocol1_0::ProcessCMakeInputs(
}
const cmake* cm = this->CMakeInstance();
- const cmGlobalGenerator* gg = cm->GetGlobalGenerator();
const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot();
- const std::string buildDir = cm->GetHomeOutputDirectory();
- const std::string sourceDir = cm->GetHomeDirectory();
+ const std::string& sourceDir = cm->GetHomeDirectory();
Json::Value result = Json::objectValue;
result[kSOURCE_DIRECTORY_KEY] = sourceDir;
result[kCMAKE_ROOT_DIRECTORY_KEY] = cmakeRootDir;
-
- std::vector<std::string> internalFiles;
- std::vector<std::string> explicitFiles;
- std::vector<std::string> tmpFiles;
- getCMakeInputs(gg, sourceDir, buildDir, &internalFiles, &explicitFiles,
- &tmpFiles);
-
- Json::Value array = Json::arrayValue;
-
- Json::Value tmp = Json::objectValue;
- tmp[kIS_CMAKE_KEY] = true;
- tmp[kIS_TEMPORARY_KEY] = false;
- tmp[kSOURCES_KEY] = fromStringList(internalFiles);
- array.append(tmp);
-
- tmp = Json::objectValue;
- tmp[kIS_CMAKE_KEY] = false;
- tmp[kIS_TEMPORARY_KEY] = false;
- tmp[kSOURCES_KEY] = fromStringList(explicitFiles);
- array.append(tmp);
-
- tmp = Json::objectValue;
- tmp[kIS_CMAKE_KEY] = false;
- tmp[kIS_TEMPORARY_KEY] = true;
- tmp[kSOURCES_KEY] = fromStringList(tmpFiles);
- array.append(tmp);
-
- result[kBUILD_FILES_KEY] = array;
-
+ result[kBUILD_FILES_KEY] = cmDumpCMakeInputs(cm);
return request.Reply(result);
}
-class LanguageData
-{
-public:
- bool operator==(const LanguageData& other) const;
-
- void SetDefines(const std::set<std::string>& defines);
-
- bool IsGenerated = false;
- std::string Language;
- std::string Flags;
- std::vector<std::string> Defines;
- std::vector<std::pair<std::string, bool> > IncludePathList;
-};
-
-bool LanguageData::operator==(const LanguageData& other) const
-{
- return Language == other.Language && Defines == other.Defines &&
- Flags == other.Flags && IncludePathList == other.IncludePathList &&
- IsGenerated == other.IsGenerated;
-}
-
-void LanguageData::SetDefines(const std::set<std::string>& defines)
-{
- std::vector<std::string> result;
- for (const auto& i : defines) {
- result.push_back(i);
- }
- std::sort(result.begin(), result.end());
- Defines = result;
-}
-
-namespace std {
-
-template <>
-struct hash<LanguageData>
-{
- std::size_t operator()(const LanguageData& in) const
- {
- using std::hash;
- size_t result =
- hash<std::string>()(in.Language) ^ hash<std::string>()(in.Flags);
- for (const auto& i : in.IncludePathList) {
- result = result ^ (hash<std::string>()(i.first) ^
- (i.second ? std::numeric_limits<size_t>::max() : 0));
- }
- for (const auto& i : in.Defines) {
- result = result ^ hash<std::string>()(i);
- }
- result =
- result ^ (in.IsGenerated ? std::numeric_limits<size_t>::max() : 0);
- return result;
- }
-};
-
-} // namespace std
-
-static Json::Value DumpSourceFileGroup(const LanguageData& data,
- const std::vector<std::string>& files,
- const std::string& baseDir)
-{
- Json::Value result = Json::objectValue;
-
- if (!data.Language.empty()) {
- result[kLANGUAGE_KEY] = data.Language;
- if (!data.Flags.empty()) {
- result[kCOMPILE_FLAGS_KEY] = data.Flags;
- }
- if (!data.IncludePathList.empty()) {
- Json::Value includes = Json::arrayValue;
- for (const auto& i : data.IncludePathList) {
- Json::Value tmp = Json::objectValue;
- tmp[kPATH_KEY] = i.first;
- if (i.second) {
- tmp[kIS_SYSTEM_KEY] = i.second;
- }
- includes.append(tmp);
- }
- result[kINCLUDE_PATH_KEY] = includes;
- }
- if (!data.Defines.empty()) {
- result[kDEFINES_KEY] = fromStringList(data.Defines);
- }
- }
-
- result[kIS_GENERATED_KEY] = data.IsGenerated;
-
- Json::Value sourcesValue = Json::arrayValue;
- for (const auto& i : files) {
- const std::string relPath =
- cmSystemTools::RelativePath(baseDir.c_str(), i.c_str());
- sourcesValue.append(relPath.size() < i.size() ? relPath : i);
- }
-
- result[kSOURCES_KEY] = sourcesValue;
- return result;
-}
-
-static Json::Value DumpSourceFilesList(
- cmGeneratorTarget* target, const std::string& config,
- const std::map<std::string, LanguageData>& languageDataMap)
-{
- // Collect sourcefile groups:
-
- std::vector<cmSourceFile*> files;
- target->GetSourceFiles(files, config);
-
- std::unordered_map<LanguageData, std::vector<std::string> > fileGroups;
- for (cmSourceFile* file : files) {
- LanguageData fileData;
- fileData.Language = file->GetLanguage();
- if (!fileData.Language.empty()) {
- const LanguageData& ld = languageDataMap.at(fileData.Language);
- cmLocalGenerator* lg = target->GetLocalGenerator();
-
- std::string compileFlags = ld.Flags;
- if (const char* cflags = file->GetProperty("COMPILE_FLAGS")) {
- cmGeneratorExpression ge;
- auto cge = ge.Parse(cflags);
- const char* processed =
- cge->Evaluate(target->GetLocalGenerator(), config);
- lg->AppendFlags(compileFlags, processed);
- }
- fileData.Flags = compileFlags;
-
- fileData.IncludePathList = ld.IncludePathList;
-
- std::set<std::string> defines;
- lg->AppendDefines(defines, file->GetProperty("COMPILE_DEFINITIONS"));
- const std::string defPropName =
- "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config);
- lg->AppendDefines(defines, file->GetProperty(defPropName));
- defines.insert(ld.Defines.begin(), ld.Defines.end());
-
- fileData.SetDefines(defines);
- }
-
- fileData.IsGenerated = file->GetPropertyAsBool("GENERATED");
- std::vector<std::string>& groupFileList = fileGroups[fileData];
- groupFileList.push_back(file->GetFullPath());
- }
-
- const std::string baseDir = target->Makefile->GetCurrentSourceDirectory();
- Json::Value result = Json::arrayValue;
- for (auto it = fileGroups.begin(); it != fileGroups.end(); ++it) {
- Json::Value group = DumpSourceFileGroup(it->first, it->second, baseDir);
- if (!group.isNull()) {
- result.append(group);
- }
- }
-
- return result;
-}
-
-static Json::Value DumpTarget(cmGeneratorTarget* target,
- const std::string& config)
-{
- cmLocalGenerator* lg = target->GetLocalGenerator();
- const cmState* state = lg->GetState();
-
- const cmStateEnums::TargetType type = target->GetType();
- const std::string typeName = state->GetTargetTypeName(type);
-
- Json::Value ttl = Json::arrayValue;
- ttl.append("EXECUTABLE");
- ttl.append("STATIC_LIBRARY");
- ttl.append("SHARED_LIBRARY");
- ttl.append("MODULE_LIBRARY");
- ttl.append("OBJECT_LIBRARY");
- ttl.append("UTILITY");
- ttl.append("INTERFACE_LIBRARY");
-
- if (!hasString(ttl, typeName) || target->IsImported()) {
- return Json::Value();
- }
-
- Json::Value result = Json::objectValue;
- result[kNAME_KEY] = target->GetName();
- result[kTYPE_KEY] = typeName;
- result[kSOURCE_DIRECTORY_KEY] = lg->GetCurrentSourceDirectory();
- result[kBUILD_DIRECTORY_KEY] = lg->GetCurrentBinaryDirectory();
-
- if (type == cmStateEnums::INTERFACE_LIBRARY) {
- return result;
- }
-
- result[kFULL_NAME_KEY] = target->GetFullName(config);
-
- if (target->HaveWellDefinedOutputFiles()) {
- Json::Value artifacts = Json::arrayValue;
- artifacts.append(
- target->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact));
- if (target->IsDLLPlatform()) {
- artifacts.append(
- target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact));
- const cmGeneratorTarget::OutputInfo* output =
- target->GetOutputInfo(config);
- if (output && !output->PdbDir.empty()) {
- artifacts.append(output->PdbDir + '/' + target->GetPDBName(config));
- }
- }
- result[kARTIFACTS_KEY] = artifacts;
-
- result[kLINKER_LANGUAGE_KEY] = target->GetLinkerLanguage(config);
-
- std::string linkLibs;
- std::string linkFlags;
- std::string linkLanguageFlags;
- std::string frameworkPath;
- std::string linkPath;
- cmLinkLineComputer linkLineComputer(lg,
- lg->GetStateSnapshot().GetDirectory());
- lg->GetTargetFlags(&linkLineComputer, config, linkLibs, linkLanguageFlags,
- linkFlags, frameworkPath, linkPath, target);
-
- linkLibs = cmSystemTools::TrimWhitespace(linkLibs);
- linkFlags = cmSystemTools::TrimWhitespace(linkFlags);
- linkLanguageFlags = cmSystemTools::TrimWhitespace(linkLanguageFlags);
- frameworkPath = cmSystemTools::TrimWhitespace(frameworkPath);
- linkPath = cmSystemTools::TrimWhitespace(linkPath);
-
- if (!cmSystemTools::TrimWhitespace(linkLibs).empty()) {
- result[kLINK_LIBRARIES_KEY] = linkLibs;
- }
- if (!cmSystemTools::TrimWhitespace(linkFlags).empty()) {
- result[kLINK_FLAGS_KEY] = linkFlags;
- }
- if (!cmSystemTools::TrimWhitespace(linkLanguageFlags).empty()) {
- result[kLINK_LANGUAGE_FLAGS_KEY] = linkLanguageFlags;
- }
- if (!frameworkPath.empty()) {
- result[kFRAMEWORK_PATH_KEY] = frameworkPath;
- }
- if (!linkPath.empty()) {
- result[kLINK_PATH_KEY] = linkPath;
- }
- const std::string sysroot =
- lg->GetMakefile()->GetSafeDefinition("CMAKE_SYSROOT");
- if (!sysroot.empty()) {
- result[kSYSROOT_KEY] = sysroot;
- }
- }
-
- std::set<std::string> languages;
- target->GetLanguages(languages, config);
- std::map<std::string, LanguageData> languageDataMap;
- for (const auto& lang : languages) {
- LanguageData& ld = languageDataMap[lang];
- ld.Language = lang;
- lg->GetTargetCompileFlags(target, config, lang, ld.Flags);
- std::set<std::string> defines;
- lg->GetTargetDefines(target, config, lang, defines);
- ld.SetDefines(defines);
- std::vector<std::string> includePathList;
- lg->GetIncludeDirectories(includePathList, target, lang, config, true);
- for (auto i : includePathList) {
- ld.IncludePathList.push_back(
- std::make_pair(i, target->IsSystemIncludeDirectory(i, config)));
- }
- }
-
- Json::Value sourceGroupsValue =
- DumpSourceFilesList(target, config, languageDataMap);
- if (!sourceGroupsValue.empty()) {
- result[kFILE_GROUPS_KEY] = sourceGroupsValue;
- }
-
- return result;
-}
-
-static Json::Value DumpTargetsList(
- const std::vector<cmLocalGenerator*>& generators, const std::string& config)
-{
- Json::Value result = Json::arrayValue;
-
- std::vector<cmGeneratorTarget*> targetList;
- for (const auto& lgIt : generators) {
- auto list = lgIt->GetGeneratorTargets();
- targetList.insert(targetList.end(), list.begin(), list.end());
- }
- std::sort(targetList.begin(), targetList.end());
-
- for (cmGeneratorTarget* target : targetList) {
- Json::Value tmp = DumpTarget(target, config);
- if (!tmp.isNull()) {
- result.append(tmp);
- }
- }
-
- return result;
-}
-
-static Json::Value DumpProjectList(const cmake* cm, std::string const& config)
-{
- Json::Value result = Json::arrayValue;
-
- auto globalGen = cm->GetGlobalGenerator();
-
- for (const auto& projectIt : globalGen->GetProjectMap()) {
- Json::Value pObj = Json::objectValue;
- pObj[kNAME_KEY] = projectIt.first;
-
- // All Projects must have at least one local generator
- assert(!projectIt.second.empty());
- const cmLocalGenerator* lg = projectIt.second.at(0);
-
- // Project structure information:
- const cmMakefile* mf = lg->GetMakefile();
- pObj[kSOURCE_DIRECTORY_KEY] = mf->GetCurrentSourceDirectory();
- pObj[kBUILD_DIRECTORY_KEY] = mf->GetCurrentBinaryDirectory();
- pObj[kTARGETS_KEY] = DumpTargetsList(projectIt.second, config);
-
- result.append(pObj);
- }
-
- return result;
-}
-
-static Json::Value DumpConfiguration(const cmake* cm,
- const std::string& config)
-{
- Json::Value result = Json::objectValue;
- result[kNAME_KEY] = config;
-
- result[kPROJECTS_KEY] = DumpProjectList(cm, config);
-
- return result;
-}
-
-static Json::Value DumpConfigurationsList(const cmake* cm)
-{
- Json::Value result = Json::arrayValue;
-
- for (const std::string& c : getConfigurations(cm)) {
- result.append(DumpConfiguration(cm, c));
- }
-
- return result;
-}
-
-cmServerResponse cmServerProtocol1_0::ProcessCodeModel(
+cmServerResponse cmServerProtocol1::ProcessCodeModel(
const cmServerRequest& request)
{
if (this->m_State != STATE_COMPUTED) {
return request.ReportError("No build system was generated yet.");
}
- Json::Value result = Json::objectValue;
- result[kCONFIGURATIONS_KEY] = DumpConfigurationsList(this->CMakeInstance());
- return request.Reply(result);
+ return request.Reply(cmDumpCodeModel(this->CMakeInstance()));
}
-cmServerResponse cmServerProtocol1_0::ProcessCompute(
+cmServerResponse cmServerProtocol1::ProcessCompute(
const cmServerRequest& request)
{
if (this->m_State > STATE_CONFIGURED) {
@@ -949,7 +513,7 @@ cmServerResponse cmServerProtocol1_0::ProcessCompute(
return request.Reply(Json::Value());
}
-cmServerResponse cmServerProtocol1_0::ProcessConfigure(
+cmServerResponse cmServerProtocol1::ProcessConfigure(
const cmServerRequest& request)
{
if (this->m_State == STATE_INACTIVE) {
@@ -973,12 +537,12 @@ cmServerResponse cmServerProtocol1_0::ProcessConfigure(
if (passedArgs.isString()) {
cacheArgs.push_back(passedArgs.asString());
} else if (passedArgs.isArray()) {
- for (auto i = passedArgs.begin(); i != passedArgs.end(); ++i) {
- if (!i->isString()) {
+ for (auto const& arg : passedArgs) {
+ if (!arg.isString()) {
cacheArgumentsError = true;
break;
}
- cacheArgs.push_back(i->asString());
+ cacheArgs.push_back(arg.asString());
}
} else {
cacheArgumentsError = true;
@@ -1000,20 +564,20 @@ cmServerResponse cmServerProtocol1_0::ProcessConfigure(
if (cm->LoadCache(buildDir)) {
// build directory has been set up before
- const char* cachedSourceDir =
+ const std::string* cachedSourceDir =
cm->GetState()->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY");
if (!cachedSourceDir) {
return request.ReportError("No CMAKE_HOME_DIRECTORY found in cache.");
}
if (sourceDir.empty()) {
- sourceDir = std::string(cachedSourceDir);
+ sourceDir = *cachedSourceDir;
cm->SetHomeDirectory(sourceDir);
}
- const char* cachedGenerator =
+ const std::string* cachedGenerator =
cm->GetState()->GetInitializedCacheValue("CMAKE_GENERATOR");
if (cachedGenerator) {
- if (gg && gg->GetName() != cachedGenerator) {
+ if (gg && gg->GetName() != *cachedGenerator) {
return request.ReportError("Configured generator does not match with "
"CMAKE_GENERATOR found in cache.");
}
@@ -1038,12 +602,17 @@ cmServerResponse cmServerProtocol1_0::ProcessConfigure(
}
int ret = cm->Configure();
+ cm->IssueMessage(
+ MessageType::DEPRECATION_WARNING,
+ "The 'cmake-server(7)' is deprecated. "
+ "Please port clients to use the 'cmake-file-api(7)' instead.");
if (ret < 0) {
return request.ReportError("Configuration failed.");
}
std::vector<std::string> toWatchList;
- getCMakeInputs(gg, std::string(), buildDir, nullptr, &toWatchList, nullptr);
+ cmGetCMakeInputs(gg, std::string(), buildDir, nullptr, &toWatchList,
+ nullptr);
FileMonitor()->MonitorPaths(toWatchList,
[this](const std::string& p, int e, int s) {
@@ -1055,14 +624,14 @@ cmServerResponse cmServerProtocol1_0::ProcessConfigure(
return request.Reply(Json::Value());
}
-cmServerResponse cmServerProtocol1_0::ProcessGlobalSettings(
+cmServerResponse cmServerProtocol1::ProcessGlobalSettings(
const cmServerRequest& request)
{
cmake* cm = this->CMakeInstance();
Json::Value obj = Json::objectValue;
// Capabilities information:
- obj[kCAPABILITIES_KEY] = cm->ReportCapabilitiesJson(true);
+ obj[kCAPABILITIES_KEY] = cm->ReportCapabilitiesJson();
obj[kDEBUG_OUTPUT_KEY] = cm->GetDebugOutput();
obj[kTRACE_KEY] = cm->GetTrace();
@@ -1091,7 +660,7 @@ static void setBool(const cmServerRequest& request, const std::string& key,
setter(request.Data[key].asBool());
}
-cmServerResponse cmServerProtocol1_0::ProcessSetGlobalSettings(
+cmServerResponse cmServerProtocol1::ProcessSetGlobalSettings(
const cmServerRequest& request)
{
const std::vector<std::string> boolValues = {
@@ -1099,7 +668,7 @@ cmServerResponse cmServerProtocol1_0::ProcessSetGlobalSettings(
kWARN_UNINITIALIZED_KEY, kWARN_UNUSED_KEY, kWARN_UNUSED_CLI_KEY,
kCHECK_SYSTEM_VARS_KEY
};
- for (const auto& i : boolValues) {
+ for (std::string const& i : boolValues) {
if (!request.Data[i].isNull() && !request.Data[i].isBool()) {
return request.ReportError("\"" + i +
"\" must be unset or a bool value.");
@@ -1123,17 +692,17 @@ cmServerResponse cmServerProtocol1_0::ProcessSetGlobalSettings(
return request.Reply(Json::Value());
}
-cmServerResponse cmServerProtocol1_0::ProcessFileSystemWatchers(
+cmServerResponse cmServerProtocol1::ProcessFileSystemWatchers(
const cmServerRequest& request)
{
const cmFileMonitor* const fm = FileMonitor();
Json::Value result = Json::objectValue;
Json::Value files = Json::arrayValue;
- for (const auto& f : fm->WatchedFiles()) {
+ for (auto const& f : fm->WatchedFiles()) {
files.append(f);
}
Json::Value directories = Json::arrayValue;
- for (const auto& d : fm->WatchedDirectories()) {
+ for (auto const& d : fm->WatchedDirectories()) {
directories.append(d);
}
result[kWATCHED_FILES_KEY] = files;
@@ -1142,20 +711,30 @@ cmServerResponse cmServerProtocol1_0::ProcessFileSystemWatchers(
return request.Reply(result);
}
-cmServerProtocol1_0::GeneratorInformation::GeneratorInformation(
- const std::string& generatorName, const std::string& extraGeneratorName,
- const std::string& toolset, const std::string& platform,
- const std::string& sourceDirectory, const std::string& buildDirectory)
- : GeneratorName(generatorName)
- , ExtraGeneratorName(extraGeneratorName)
- , Toolset(toolset)
- , Platform(platform)
- , SourceDirectory(sourceDirectory)
- , BuildDirectory(buildDirectory)
+cmServerResponse cmServerProtocol1::ProcessCTests(
+ const cmServerRequest& request)
+{
+ if (this->m_State < STATE_COMPUTED) {
+ return request.ReportError("This instance was not yet computed.");
+ }
+
+ return request.Reply(cmDumpCTestInfo(this->CMakeInstance()));
+}
+
+cmServerProtocol1::GeneratorInformation::GeneratorInformation(
+ std::string generatorName, std::string extraGeneratorName,
+ std::string toolset, std::string platform, std::string sourceDirectory,
+ std::string buildDirectory)
+ : GeneratorName(std::move(generatorName))
+ , ExtraGeneratorName(std::move(extraGeneratorName))
+ , Toolset(std::move(toolset))
+ , Platform(std::move(platform))
+ , SourceDirectory(std::move(sourceDirectory))
+ , BuildDirectory(std::move(buildDirectory))
{
}
-void cmServerProtocol1_0::GeneratorInformation::SetupGenerator(
+void cmServerProtocol1::GeneratorInformation::SetupGenerator(
cmake* cm, std::string* errorMessage)
{
const std::string fullGeneratorName =
diff --git a/Source/cmServerProtocol.h b/Source/cmServerProtocol.h
index 83b3d58de..8446c3e76 100644
--- a/Source/cmServerProtocol.h
+++ b/Source/cmServerProtocol.h
@@ -2,15 +2,17 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once
-#include "cmConfigure.h"
-
-#include "cm_jsoncpp_value.h"
-#include "cmake.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <memory>
#include <string>
#include <utility>
+#include "cm_jsoncpp_value.h"
+
+#include "cmake.h"
+
+class cmConnection;
class cmFileMonitor;
class cmServer;
class cmServerRequest;
@@ -52,10 +54,11 @@ public:
const std::string Type;
const std::string Cookie;
const Json::Value Data;
+ cmConnection* Connection;
private:
- cmServerRequest(cmServer* server, const std::string& t, const std::string& c,
- const Json::Value& d);
+ cmServerRequest(cmServer* server, cmConnection* connection, std::string t,
+ std::string c, Json::Value d);
void ReportProgress(int min, int current, int max,
const std::string& message) const;
@@ -69,15 +72,16 @@ private:
class cmServerProtocol
{
- CM_DISABLE_COPY(cmServerProtocol)
-
public:
cmServerProtocol() = default;
virtual ~cmServerProtocol() = default;
+ cmServerProtocol(cmServerProtocol const&) = delete;
+ cmServerProtocol& operator=(cmServerProtocol const&) = delete;
+
virtual std::pair<int, int> ProtocolVersion() const = 0;
virtual bool IsExperimental() const = 0;
- virtual const cmServerResponse Process(const cmServerRequest& request) = 0;
+ virtual cmServerResponse Process(const cmServerRequest& request) = 0;
bool Activate(cmServer* server, const cmServerRequest& request,
std::string* errorMessage);
@@ -98,12 +102,12 @@ private:
friend class cmServer;
};
-class cmServerProtocol1_0 : public cmServerProtocol
+class cmServerProtocol1 : public cmServerProtocol
{
public:
std::pair<int, int> ProtocolVersion() const override;
bool IsExperimental() const override;
- const cmServerResponse Process(const cmServerRequest& request) override;
+ cmServerResponse Process(const cmServerRequest& request) override;
private:
bool DoActivate(const cmServerRequest& request,
@@ -120,6 +124,7 @@ private:
cmServerResponse ProcessGlobalSettings(const cmServerRequest& request);
cmServerResponse ProcessSetGlobalSettings(const cmServerRequest& request);
cmServerResponse ProcessFileSystemWatchers(const cmServerRequest& request);
+ cmServerResponse ProcessCTests(const cmServerRequest& request);
enum State
{
@@ -136,12 +141,10 @@ private:
{
public:
GeneratorInformation() = default;
- GeneratorInformation(const std::string& generatorName,
- const std::string& extraGeneratorName,
- const std::string& toolset,
- const std::string& platform,
- const std::string& sourceDirectory,
- const std::string& buildDirectory);
+ GeneratorInformation(std::string generatorName,
+ std::string extraGeneratorName, std::string toolset,
+ std::string platform, std::string sourceDirectory,
+ std::string buildDirectory);
void SetupGenerator(cmake* cm, std::string* errorMessage);
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index 820e7f695..8c3a4cb48 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -2,39 +2,34 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSetCommand.h"
-#include <string.h>
-
-#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmRange.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
// cmSetCommand
-bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmSetCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
// watch for ENV signatures
- const char* variable = args[0].c_str(); // VAR is always first
- if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5) {
+ auto const& variable = args[0]; // VAR is always first
+ if (cmHasLiteralPrefix(variable, "ENV{") && variable.size() > 5) {
// what is the variable name
- char* varName = new char[strlen(variable)];
- strncpy(varName, variable + 4, strlen(variable) - 5);
- varName[strlen(variable) - 5] = '\0';
- std::string putEnvArg = varName;
- putEnvArg += "=";
+ auto const& varName = variable.substr(4, variable.size() - 5);
+ std::string putEnvArg = varName + "=";
// what is the current value if any
std::string currValue;
const bool currValueSet = cmSystemTools::GetEnv(varName, currValue);
- delete[] varName;
// will it be set to something, then set it
if (args.size() > 1 && !args[1].empty()) {
@@ -43,6 +38,14 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
putEnvArg += args[1];
cmSystemTools::PutEnv(putEnvArg);
}
+ // if there's extra arguments, warn user
+ // that they are ignored by this command.
+ if (args.size() > 2) {
+ std::string m = "Only the first value argument is used when setting "
+ "an environment variable. Argument '" +
+ args[2] + "' and later are unused.";
+ status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, m);
+ }
return true;
}
@@ -55,13 +58,13 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
// SET (VAR) // Removes the definition of VAR.
if (args.size() == 1) {
- this->Makefile->RemoveDefinition(variable);
+ status.GetMakefile().RemoveDefinition(variable);
return true;
}
// SET (VAR PARENT_SCOPE) // Removes the definition of VAR
// in the parent scope.
- if (args.size() == 2 && args[args.size() - 1] == "PARENT_SCOPE") {
- this->Makefile->RaiseScope(variable, CM_NULLPTR);
+ if (args.size() == 2 && args.back() == "PARENT_SCOPE") {
+ status.GetMakefile().RaiseScope(variable, nullptr);
return true;
}
@@ -75,17 +78,17 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
bool force = false; // optional
bool parentScope = false;
cmStateEnums::CacheEntryType type =
- cmStateEnums::STRING; // required if cache
- const char* docstring = CM_NULLPTR; // required if cache
+ cmStateEnums::STRING; // required if cache
+ const char* docstring = nullptr; // required if cache
unsigned int ignoreLastArgs = 0;
// look for PARENT_SCOPE argument
- if (args.size() > 1 && args[args.size() - 1] == "PARENT_SCOPE") {
+ if (args.size() > 1 && args.back() == "PARENT_SCOPE") {
parentScope = true;
ignoreLastArgs++;
} else {
// look for FORCE argument
- if (args.size() > 4 && args[args.size() - 1] == "FORCE") {
+ if (args.size() > 4 && args.back() == "FORCE") {
force = true;
ignoreLastArgs++;
}
@@ -102,28 +105,36 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
value = cmJoin(cmMakeRange(args).advance(1).retreat(ignoreLastArgs), ";");
if (parentScope) {
- this->Makefile->RaiseScope(variable, value.c_str());
+ status.GetMakefile().RaiseScope(variable, value.c_str());
return true;
}
// we should be nice and try to catch some simple screwups if the last or
// next to last args are CACHE then they screwed up. If they used FORCE
// without CACHE they screwed up
- if ((args[args.size() - 1] == "CACHE") ||
+ if ((args.back() == "CACHE") ||
(args.size() > 1 && args[args.size() - 2] == "CACHE") ||
(force && !cache)) {
- this->SetError("given invalid arguments for CACHE mode.");
+ status.SetError("given invalid arguments for CACHE mode.");
return false;
}
if (cache) {
std::string::size_type cacheStart = args.size() - 3 - (force ? 1 : 0);
- type = cmState::StringToCacheEntryType(args[cacheStart + 1].c_str());
+ if (!cmState::StringToCacheEntryType(args[cacheStart + 1].c_str(), type)) {
+ std::string m = "implicitly converting '" + args[cacheStart + 1] +
+ "' to 'STRING' type.";
+ status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, m);
+ // Setting this may not be required, since it's
+ // initialized as a string. Keeping this here to
+ // ensure that the type is actually converting to a string.
+ type = cmStateEnums::STRING;
+ }
docstring = args[cacheStart + 2].c_str();
}
// see if this is already in the cache
- cmState* state = this->Makefile->GetState();
+ cmState* state = status.GetMakefile().GetState();
const char* existingValue = state->GetCacheEntryValue(variable);
if (existingValue &&
(state->GetCacheEntryType(variable) != cmStateEnums::UNINITIALIZED)) {
@@ -138,11 +149,11 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
// if it is meant to be in the cache then define it in the cache
if (cache) {
- this->Makefile->AddCacheDefinition(variable, value.c_str(), docstring,
- type, force);
+ status.GetMakefile().AddCacheDefinition(variable, value.c_str(), docstring,
+ type, force);
} else {
// add the definition
- this->Makefile->AddDefinition(variable, value.c_str());
+ status.GetMakefile().AddDefinition(variable, value);
}
return true;
}
diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h
index c0858b15b..0973d33aa 100644
--- a/Source/cmSetCommand.h
+++ b/Source/cmSetCommand.h
@@ -3,34 +3,19 @@
#ifndef cmSetCommand_h
#define cmSetCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmSetCommand
+/**
* \brief Set a CMAKE variable
*
* cmSetCommand sets a variable to a value with expansion.
*/
-class cmSetCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmSetCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmSetCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmSetDirectoryPropertiesCommand.cxx b/Source/cmSetDirectoryPropertiesCommand.cxx
index 8d3961a79..35daca6ff 100644
--- a/Source/cmSetDirectoryPropertiesCommand.cxx
+++ b/Source/cmSetDirectoryPropertiesCommand.cxx
@@ -2,31 +2,37 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSetDirectoryPropertiesCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-class cmExecutionStatus;
+namespace {
+bool RunCommand(cmMakefile& mf, std::vector<std::string>::const_iterator ait,
+ std::vector<std::string>::const_iterator aitend,
+ std::string& errors);
+}
// cmSetDirectoryPropertiesCommand
-bool cmSetDirectoryPropertiesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmSetDirectoryPropertiesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
std::string errors;
- bool ret = cmSetDirectoryPropertiesCommand::RunCommand(
- this->Makefile, args.begin() + 1, args.end(), errors);
+ bool ret =
+ RunCommand(status.GetMakefile(), args.begin() + 1, args.end(), errors);
if (!ret) {
- this->SetError(errors);
+ status.SetError(errors);
}
return ret;
}
-bool cmSetDirectoryPropertiesCommand::RunCommand(
- cmMakefile* mf, std::vector<std::string>::const_iterator ait,
- std::vector<std::string>::const_iterator aitend, std::string& errors)
+namespace {
+bool RunCommand(cmMakefile& mf, std::vector<std::string>::const_iterator ait,
+ std::vector<std::string>::const_iterator aitend,
+ std::string& errors)
{
for (; ait != aitend; ait += 2) {
if (ait + 1 == aitend) {
@@ -43,8 +49,9 @@ bool cmSetDirectoryPropertiesCommand::RunCommand(
errors = "Commands and macros cannot be set using SET_CMAKE_PROPERTIES";
return false;
}
- mf->SetProperty(prop, value.c_str());
+ mf.SetProperty(prop, value.c_str());
}
return true;
}
+}
diff --git a/Source/cmSetDirectoryPropertiesCommand.h b/Source/cmSetDirectoryPropertiesCommand.h
index 8832b3389..c243dd70f 100644
--- a/Source/cmSetDirectoryPropertiesCommand.h
+++ b/Source/cmSetDirectoryPropertiesCommand.h
@@ -3,38 +3,14 @@
#ifndef cmSetDirectoryPropertiesCommand_h
#define cmSetDirectoryPropertiesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmMakefile;
-
-class cmSetDirectoryPropertiesCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE
- {
- return new cmSetDirectoryPropertiesCommand;
- }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
- /**
- * Static entry point for use by other commands
- */
- static bool RunCommand(cmMakefile* mf,
- std::vector<std::string>::const_iterator ait,
- std::vector<std::string>::const_iterator aitend,
- std::string& errors);
-};
+bool cmSetDirectoryPropertiesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index b57f62a50..112d832e6 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -2,62 +2,118 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSetPropertyCommand.h"
+#include <set>
#include <sstream>
+#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmInstalledFile.h"
#include "cmMakefile.h"
#include "cmProperty.h"
+#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTest.h"
#include "cmake.h"
-class cmExecutionStatus;
-
-cmSetPropertyCommand::cmSetPropertyCommand()
-{
- this->AppendMode = false;
- this->AppendAsString = false;
- this->Remove = true;
+namespace {
+bool HandleGlobalMode(cmExecutionStatus& status,
+ const std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue, bool appendAsString,
+ bool appendMode, bool remove);
+bool HandleDirectoryMode(cmExecutionStatus& status,
+ const std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue, bool appendAsString,
+ bool appendMode, bool remove);
+bool HandleTargetMode(cmExecutionStatus& status,
+ const std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue, bool appendAsString,
+ bool appendMode, bool remove);
+bool HandleTarget(cmTarget* target, cmMakefile& makefile,
+ const std::string& propertyName,
+ const std::string& propertyValue, bool appendAsString,
+ bool appendMode, bool remove);
+bool HandleSourceMode(cmExecutionStatus& status,
+ const std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue, bool appendAsString,
+ bool appendMode, bool remove);
+bool HandleSource(cmSourceFile* sf, const std::string& propertyName,
+ const std::string& propertyValue, bool appendAsString,
+ bool appendMode, bool remove);
+bool HandleTestMode(cmExecutionStatus& status, std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue, bool appendAsString,
+ bool appendMode, bool remove);
+bool HandleTest(cmTest* test, const std::string& propertyName,
+ const std::string& propertyValue, bool appendAsString,
+ bool appendMode, bool remove);
+bool HandleCacheMode(cmExecutionStatus& status,
+ const std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue, bool appendAsString,
+ bool appendMode, bool remove);
+bool HandleCacheEntry(std::string const& cacheKey, const cmMakefile& makefile,
+ const std::string& propertyName,
+ const std::string& propertyValue, bool appendAsString,
+ bool appendMode, bool remove);
+bool HandleInstallMode(cmExecutionStatus& status,
+ const std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue, bool appendAsString,
+ bool appendMode, bool remove);
+bool HandleInstall(cmInstalledFile* file, cmMakefile& makefile,
+ const std::string& propertyName,
+ const std::string& propertyValue, bool appendAsString,
+ bool appendMode, bool remove);
}
-bool cmSetPropertyCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmSetPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
// Get the scope on which to set the property.
- std::vector<std::string>::const_iterator arg = args.begin();
+ std::string const& scopeName = args.front();
cmProperty::ScopeType scope;
- if (*arg == "GLOBAL") {
+ if (scopeName == "GLOBAL") {
scope = cmProperty::GLOBAL;
- } else if (*arg == "DIRECTORY") {
+ } else if (scopeName == "DIRECTORY") {
scope = cmProperty::DIRECTORY;
- } else if (*arg == "TARGET") {
+ } else if (scopeName == "TARGET") {
scope = cmProperty::TARGET;
- } else if (*arg == "SOURCE") {
+ } else if (scopeName == "SOURCE") {
scope = cmProperty::SOURCE_FILE;
- } else if (*arg == "TEST") {
+ } else if (scopeName == "TEST") {
scope = cmProperty::TEST;
- } else if (*arg == "CACHE") {
+ } else if (scopeName == "CACHE") {
scope = cmProperty::CACHE;
- } else if (*arg == "INSTALL") {
+ } else if (scopeName == "INSTALL") {
scope = cmProperty::INSTALL;
} else {
- std::ostringstream e;
- e << "given invalid scope " << *arg << ". "
- << "Valid scopes are GLOBAL, DIRECTORY, "
- "TARGET, SOURCE, TEST, CACHE, INSTALL.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("given invalid scope ", scopeName,
+ ". "
+ "Valid scopes are GLOBAL, DIRECTORY, "
+ "TARGET, SOURCE, TEST, CACHE, INSTALL."));
return false;
}
+ bool appendAsString = false;
+ bool appendMode = false;
+ bool remove = true;
+ std::set<std::string> names;
+ std::string propertyName;
+ std::string propertyValue;
+
// Parse the rest of the arguments up to the values.
enum Doing
{
@@ -68,59 +124,64 @@ bool cmSetPropertyCommand::InitialPass(std::vector<std::string> const& args,
};
Doing doing = DoingNames;
const char* sep = "";
- for (++arg; arg != args.end(); ++arg) {
- if (*arg == "PROPERTY") {
+ for (std::string const& arg : cmMakeRange(args).advance(1)) {
+ if (arg == "PROPERTY") {
doing = DoingProperty;
- } else if (*arg == "APPEND") {
+ } else if (arg == "APPEND") {
doing = DoingNone;
- this->AppendMode = true;
- this->Remove = false;
- this->AppendAsString = false;
- } else if (*arg == "APPEND_STRING") {
+ appendMode = true;
+ remove = false;
+ appendAsString = false;
+ } else if (arg == "APPEND_STRING") {
doing = DoingNone;
- this->AppendMode = true;
- this->Remove = false;
- this->AppendAsString = true;
+ appendMode = true;
+ remove = false;
+ appendAsString = true;
} else if (doing == DoingNames) {
- this->Names.insert(*arg);
+ names.insert(arg);
} else if (doing == DoingProperty) {
- this->PropertyName = *arg;
+ propertyName = arg;
doing = DoingValues;
} else if (doing == DoingValues) {
- this->PropertyValue += sep;
+ propertyValue += sep;
sep = ";";
- this->PropertyValue += *arg;
- this->Remove = false;
+ propertyValue += arg;
+ remove = false;
} else {
- std::ostringstream e;
- e << "given invalid argument \"" << *arg << "\".";
- this->SetError(e.str());
+ status.SetError(cmStrCat("given invalid argument \"", arg, "\"."));
return false;
}
}
// Make sure a property name was found.
- if (this->PropertyName.empty()) {
- this->SetError("not given a PROPERTY <name> argument.");
+ if (propertyName.empty()) {
+ status.SetError("not given a PROPERTY <name> argument.");
return false;
}
// Dispatch property setting.
switch (scope) {
case cmProperty::GLOBAL:
- return this->HandleGlobalMode();
+ return HandleGlobalMode(status, names, propertyName, propertyValue,
+ appendAsString, appendMode, remove);
case cmProperty::DIRECTORY:
- return this->HandleDirectoryMode();
+ return HandleDirectoryMode(status, names, propertyName, propertyValue,
+ appendAsString, appendMode, remove);
case cmProperty::TARGET:
- return this->HandleTargetMode();
+ return HandleTargetMode(status, names, propertyName, propertyValue,
+ appendAsString, appendMode, remove);
case cmProperty::SOURCE_FILE:
- return this->HandleSourceMode();
+ return HandleSourceMode(status, names, propertyName, propertyValue,
+ appendAsString, appendMode, remove);
case cmProperty::TEST:
- return this->HandleTestMode();
+ return HandleTestMode(status, names, propertyName, propertyValue,
+ appendAsString, appendMode, remove);
case cmProperty::CACHE:
- return this->HandleCacheMode();
+ return HandleCacheMode(status, names, propertyName, propertyValue,
+ appendAsString, appendMode, remove);
case cmProperty::INSTALL:
- return this->HandleInstallMode();
+ return HandleInstallMode(status, names, propertyName, propertyValue,
+ appendAsString, appendMode, remove);
case cmProperty::VARIABLE:
case cmProperty::CACHED_VARIABLE:
@@ -129,57 +190,66 @@ bool cmSetPropertyCommand::InitialPass(std::vector<std::string> const& args,
return true;
}
-bool cmSetPropertyCommand::HandleGlobalMode()
+namespace {
+bool HandleGlobalMode(cmExecutionStatus& status,
+ const std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue,
+ const bool appendAsString, const bool appendMode,
+ const bool remove)
{
- if (!this->Names.empty()) {
- this->SetError("given names for GLOBAL scope.");
+ if (!names.empty()) {
+ status.SetError("given names for GLOBAL scope.");
return false;
}
// Set or append the property.
- cmake* cm = this->Makefile->GetCMakeInstance();
- std::string const& name = this->PropertyName;
- const char* value = this->PropertyValue.c_str();
- if (this->Remove) {
- value = CM_NULLPTR;
+ cmake* cm = status.GetMakefile().GetCMakeInstance();
+ const char* value = propertyValue.c_str();
+ if (remove) {
+ value = nullptr;
}
- if (this->AppendMode) {
- cm->AppendProperty(name, value ? value : "", this->AppendAsString);
+ if (appendMode) {
+ cm->AppendProperty(propertyName, value ? value : "", appendAsString);
} else {
- cm->SetProperty(name, value);
+ cm->SetProperty(propertyName, value);
}
return true;
}
-bool cmSetPropertyCommand::HandleDirectoryMode()
+bool HandleDirectoryMode(cmExecutionStatus& status,
+ const std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue,
+ const bool appendAsString, const bool appendMode,
+ const bool remove)
{
- if (this->Names.size() > 1) {
- this->SetError("allows at most one name for DIRECTORY scope.");
+ if (names.size() > 1) {
+ status.SetError("allows at most one name for DIRECTORY scope.");
return false;
}
// Default to the current directory.
- cmMakefile* mf = this->Makefile;
+ cmMakefile* mf = &status.GetMakefile();
// Lookup the directory if given.
- if (!this->Names.empty()) {
+ if (!names.empty()) {
// Construct the directory name. Interpret relative paths with
// respect to the current directory.
- std::string dir = *this->Names.begin();
- if (!cmSystemTools::FileIsFullPath(dir.c_str())) {
- dir = this->Makefile->GetCurrentSourceDirectory();
- dir += "/";
- dir += *this->Names.begin();
+ std::string dir = *names.begin();
+ if (!cmSystemTools::FileIsFullPath(dir)) {
+ dir = cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/',
+ *names.begin());
}
// The local generators are associated with collapsed paths.
dir = cmSystemTools::CollapseFullPath(dir);
- mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir);
+ mf = status.GetMakefile().GetGlobalGenerator()->FindMakefile(dir);
if (!mf) {
// Could not find the directory.
- this->SetError(
+ status.SetError(
"DIRECTORY scope provided but requested directory was not found. "
"This could be because the directory argument was invalid or, "
"it is valid but has not been processed yet.");
@@ -188,111 +258,124 @@ bool cmSetPropertyCommand::HandleDirectoryMode()
}
// Set or append the property.
- std::string const& name = this->PropertyName;
- const char* value = this->PropertyValue.c_str();
- if (this->Remove) {
- value = CM_NULLPTR;
+ const char* value = propertyValue.c_str();
+ if (remove) {
+ value = nullptr;
}
- if (this->AppendMode) {
- mf->AppendProperty(name, value ? value : "", this->AppendAsString);
+ if (appendMode) {
+ mf->AppendProperty(propertyName, value ? value : "", appendAsString);
} else {
- mf->SetProperty(name, value);
+ mf->SetProperty(propertyName, value);
}
return true;
}
-bool cmSetPropertyCommand::HandleTargetMode()
+bool HandleTargetMode(cmExecutionStatus& status,
+ const std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue,
+ const bool appendAsString, const bool appendMode,
+ const bool remove)
{
- for (std::set<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- if (this->Makefile->IsAlias(*ni)) {
- this->SetError("can not be used on an ALIAS target.");
+ for (std::string const& name : names) {
+ if (status.GetMakefile().IsAlias(name)) {
+ status.SetError("can not be used on an ALIAS target.");
return false;
}
- if (cmTarget* target = this->Makefile->FindTargetToUse(*ni)) {
+ if (cmTarget* target = status.GetMakefile().FindTargetToUse(name)) {
// Handle the current target.
- if (!this->HandleTarget(target)) {
+ if (!HandleTarget(target, status.GetMakefile(), propertyName,
+ propertyValue, appendAsString, appendMode, remove)) {
return false;
}
} else {
- std::ostringstream e;
- e << "could not find TARGET " << *ni
- << ". Perhaps it has not yet been created.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("could not find TARGET ", name,
+ ". Perhaps it has not yet been created."));
return false;
}
}
return true;
}
-bool cmSetPropertyCommand::HandleTarget(cmTarget* target)
+bool HandleTarget(cmTarget* target, cmMakefile& makefile,
+ const std::string& propertyName,
+ const std::string& propertyValue, const bool appendAsString,
+ const bool appendMode, const bool remove)
{
// Set or append the property.
- std::string const& name = this->PropertyName;
- const char* value = this->PropertyValue.c_str();
- if (this->Remove) {
- value = CM_NULLPTR;
+ const char* value = propertyValue.c_str();
+ if (remove) {
+ value = nullptr;
}
- if (this->AppendMode) {
- target->AppendProperty(name, value, this->AppendAsString);
+ if (appendMode) {
+ target->AppendProperty(propertyName, value, appendAsString);
} else {
- target->SetProperty(name, value);
+ target->SetProperty(propertyName, value);
}
// Check the resulting value.
- target->CheckProperty(name, this->Makefile);
+ target->CheckProperty(propertyName, &makefile);
return true;
}
-bool cmSetPropertyCommand::HandleSourceMode()
+bool HandleSourceMode(cmExecutionStatus& status,
+ const std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue,
+ const bool appendAsString, const bool appendMode,
+ const bool remove)
{
- for (std::set<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
+ for (std::string const& name : names) {
// Get the source file.
- if (cmSourceFile* sf = this->Makefile->GetOrCreateSource(*ni)) {
- if (!this->HandleSource(sf)) {
+ if (cmSourceFile* sf = status.GetMakefile().GetOrCreateSource(name)) {
+ if (!HandleSource(sf, propertyName, propertyValue, appendAsString,
+ appendMode, remove)) {
return false;
}
} else {
- std::ostringstream e;
- e << "given SOURCE name that could not be found or created: " << *ni;
- this->SetError(e.str());
+ status.SetError(cmStrCat(
+ "given SOURCE name that could not be found or created: ", name));
return false;
}
}
return true;
}
-bool cmSetPropertyCommand::HandleSource(cmSourceFile* sf)
+bool HandleSource(cmSourceFile* sf, const std::string& propertyName,
+ const std::string& propertyValue, const bool appendAsString,
+ const bool appendMode, const bool remove)
{
// Set or append the property.
- std::string const& name = this->PropertyName;
- const char* value = this->PropertyValue.c_str();
- if (this->Remove) {
- value = CM_NULLPTR;
+ const char* value = propertyValue.c_str();
+ if (remove) {
+ value = nullptr;
}
- if (this->AppendMode) {
- sf->AppendProperty(name, value, this->AppendAsString);
+ if (appendMode) {
+ sf->AppendProperty(propertyName, value, appendAsString);
} else {
- sf->SetProperty(name, value);
+ sf->SetProperty(propertyName, value);
}
return true;
}
-bool cmSetPropertyCommand::HandleTestMode()
+bool HandleTestMode(cmExecutionStatus& status, std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue,
+ const bool appendAsString, const bool appendMode,
+ const bool remove)
{
// Look for tests with all names given.
std::set<std::string>::iterator next;
- for (std::set<std::string>::iterator ni = this->Names.begin();
- ni != this->Names.end(); ni = next) {
+ for (auto ni = names.begin(); ni != names.end(); ni = next) {
next = ni;
++next;
- if (cmTest* test = this->Makefile->GetTest(*ni)) {
- if (this->HandleTest(test)) {
- this->Names.erase(ni);
+ if (cmTest* test = status.GetMakefile().GetTest(*ni)) {
+ if (HandleTest(test, propertyName, propertyValue, appendAsString,
+ appendMode, remove)) {
+ names.erase(ni);
} else {
return false;
}
@@ -300,140 +383,145 @@ bool cmSetPropertyCommand::HandleTestMode()
}
// Names that are still left were not found.
- if (!this->Names.empty()) {
+ if (!names.empty()) {
std::ostringstream e;
e << "given TEST names that do not exist:\n";
- for (std::set<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
- e << " " << *ni << "\n";
+ for (std::string const& name : names) {
+ e << " " << name << "\n";
}
- this->SetError(e.str());
+ status.SetError(e.str());
return false;
}
return true;
}
-bool cmSetPropertyCommand::HandleTest(cmTest* test)
+bool HandleTest(cmTest* test, const std::string& propertyName,
+ const std::string& propertyValue, const bool appendAsString,
+ const bool appendMode, const bool remove)
{
// Set or append the property.
- std::string const& name = this->PropertyName;
- const char* value = this->PropertyValue.c_str();
- if (this->Remove) {
- value = CM_NULLPTR;
+ const char* value = propertyValue.c_str();
+ if (remove) {
+ value = nullptr;
}
- if (this->AppendMode) {
- test->AppendProperty(name, value, this->AppendAsString);
+ if (appendMode) {
+ test->AppendProperty(propertyName, value, appendAsString);
} else {
- test->SetProperty(name, value);
+ test->SetProperty(propertyName, value);
}
return true;
}
-bool cmSetPropertyCommand::HandleCacheMode()
+bool HandleCacheMode(cmExecutionStatus& status,
+ const std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue,
+ const bool appendAsString, const bool appendMode,
+ const bool remove)
{
- if (this->PropertyName == "ADVANCED") {
- if (!this->Remove && !cmSystemTools::IsOn(this->PropertyValue.c_str()) &&
- !cmSystemTools::IsOff(this->PropertyValue.c_str())) {
- std::ostringstream e;
- e << "given non-boolean value \"" << this->PropertyValue
- << "\" for CACHE property \"ADVANCED\". ";
- this->SetError(e.str());
+ if (propertyName == "ADVANCED") {
+ if (!remove && !cmIsOn(propertyValue) && !cmIsOff(propertyValue)) {
+ status.SetError(cmStrCat("given non-boolean value \"", propertyValue,
+ R"(" for CACHE property "ADVANCED". )"));
return false;
}
- } else if (this->PropertyName == "TYPE") {
- if (!cmState::IsCacheEntryType(this->PropertyValue)) {
- std::ostringstream e;
- e << "given invalid CACHE entry TYPE \"" << this->PropertyValue << "\"";
- this->SetError(e.str());
+ } else if (propertyName == "TYPE") {
+ if (!cmState::IsCacheEntryType(propertyValue)) {
+ status.SetError(
+ cmStrCat("given invalid CACHE entry TYPE \"", propertyValue, "\""));
return false;
}
- } else if (this->PropertyName != "HELPSTRING" &&
- this->PropertyName != "STRINGS" &&
- this->PropertyName != "VALUE") {
- std::ostringstream e;
- e << "given invalid CACHE property " << this->PropertyName << ". "
- << "Settable CACHE properties are: "
- << "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE.";
- this->SetError(e.str());
+ } else if (propertyName != "HELPSTRING" && propertyName != "STRINGS" &&
+ propertyName != "VALUE") {
+ status.SetError(
+ cmStrCat("given invalid CACHE property ", propertyName,
+ ". "
+ "Settable CACHE properties are: "
+ "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE."));
return false;
}
- for (std::set<std::string>::const_iterator ni = this->Names.begin();
- ni != this->Names.end(); ++ni) {
+ for (std::string const& name : names) {
// Get the source file.
- cmMakefile* mf = this->GetMakefile();
- cmake* cm = mf->GetCMakeInstance();
- const char* existingValue = cm->GetState()->GetCacheEntryValue(*ni);
+ cmake* cm = status.GetMakefile().GetCMakeInstance();
+ const char* existingValue = cm->GetState()->GetCacheEntryValue(name);
if (existingValue) {
- if (!this->HandleCacheEntry(*ni)) {
+ if (!HandleCacheEntry(name, status.GetMakefile(), propertyName,
+ propertyValue, appendAsString, appendMode,
+ remove)) {
return false;
}
} else {
- std::ostringstream e;
- e << "could not find CACHE variable " << *ni
- << ". Perhaps it has not yet been created.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("could not find CACHE variable ", name,
+ ". Perhaps it has not yet been created."));
return false;
}
}
return true;
}
-bool cmSetPropertyCommand::HandleCacheEntry(std::string const& cacheKey)
+bool HandleCacheEntry(std::string const& cacheKey, const cmMakefile& makefile,
+ const std::string& propertyName,
+ const std::string& propertyValue,
+ const bool appendAsString, const bool appendMode,
+ const bool remove)
{
// Set or append the property.
- std::string const& name = this->PropertyName;
- const char* value = this->PropertyValue.c_str();
- cmState* state = this->Makefile->GetState();
- if (this->Remove) {
- state->RemoveCacheEntryProperty(cacheKey, name);
+ const char* value = propertyValue.c_str();
+ cmState* state = makefile.GetState();
+ if (remove) {
+ state->RemoveCacheEntryProperty(cacheKey, propertyName);
}
- if (this->AppendMode) {
- state->AppendCacheEntryProperty(cacheKey, name, value,
- this->AppendAsString);
+ if (appendMode) {
+ state->AppendCacheEntryProperty(cacheKey, propertyName, value,
+ appendAsString);
} else {
- state->SetCacheEntryProperty(cacheKey, name, value);
+ state->SetCacheEntryProperty(cacheKey, propertyName, value);
}
return true;
}
-bool cmSetPropertyCommand::HandleInstallMode()
+bool HandleInstallMode(cmExecutionStatus& status,
+ const std::set<std::string>& names,
+ const std::string& propertyName,
+ const std::string& propertyValue,
+ const bool appendAsString, const bool appendMode,
+ const bool remove)
{
- cmake* cm = this->Makefile->GetCMakeInstance();
+ cmake* cm = status.GetMakefile().GetCMakeInstance();
- for (std::set<std::string>::const_iterator i = this->Names.begin();
- i != this->Names.end(); ++i) {
+ for (std::string const& name : names) {
if (cmInstalledFile* file =
- cm->GetOrCreateInstalledFile(this->Makefile, *i)) {
- if (!this->HandleInstall(file)) {
+ cm->GetOrCreateInstalledFile(&status.GetMakefile(), name)) {
+ if (!HandleInstall(file, status.GetMakefile(), propertyName,
+ propertyValue, appendAsString, appendMode, remove)) {
return false;
}
} else {
- std::ostringstream e;
- e << "given INSTALL name that could not be found or created: " << *i;
- this->SetError(e.str());
+ status.SetError(cmStrCat(
+ "given INSTALL name that could not be found or created: ", name));
return false;
}
}
return true;
}
-bool cmSetPropertyCommand::HandleInstall(cmInstalledFile* file)
+bool HandleInstall(cmInstalledFile* file, cmMakefile& makefile,
+ const std::string& propertyName,
+ const std::string& propertyValue, const bool appendAsString,
+ const bool appendMode, const bool remove)
{
// Set or append the property.
- std::string const& name = this->PropertyName;
-
- cmMakefile* mf = this->Makefile;
-
- const char* value = this->PropertyValue.c_str();
- if (this->Remove) {
- file->RemoveProperty(name);
- } else if (this->AppendMode) {
- file->AppendProperty(mf, name, value, this->AppendAsString);
+ const char* value = propertyValue.c_str();
+ if (remove) {
+ file->RemoveProperty(propertyName);
+ } else if (appendMode) {
+ file->AppendProperty(&makefile, propertyName, value, appendAsString);
} else {
- file->SetProperty(mf, name, value);
+ file->SetProperty(&makefile, propertyName, value);
}
return true;
}
+}
diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h
index 08158244a..ec36f849e 100644
--- a/Source/cmSetPropertyCommand.h
+++ b/Source/cmSetPropertyCommand.h
@@ -3,55 +3,14 @@
#ifndef cmSetsPropertiesCommand_h
#define cmSetsPropertiesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include <set>
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmInstalledFile;
-class cmSourceFile;
-class cmTarget;
-class cmTest;
-
-class cmSetPropertyCommand : public cmCommand
-{
-public:
- cmSetPropertyCommand();
-
- cmCommand* Clone() CM_OVERRIDE { return new cmSetPropertyCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- std::set<std::string> Names;
- std::string PropertyName;
- std::string PropertyValue;
- bool Remove;
- bool AppendMode;
- bool AppendAsString;
- // Implementation of each property type.
- bool HandleGlobalMode();
- bool HandleDirectoryMode();
- bool HandleTargetMode();
- bool HandleTarget(cmTarget* target);
- bool HandleSourceMode();
- bool HandleSource(cmSourceFile* sf);
- bool HandleTestMode();
- bool HandleTest(cmTest* test);
- bool HandleCacheMode();
- bool HandleCacheEntry(std::string const&);
- bool HandleInstallMode();
- bool HandleInstall(cmInstalledFile* file);
-};
+bool cmSetPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx
index 33e1b2e06..7ff604be0 100644
--- a/Source/cmSetSourceFilesPropertiesCommand.cxx
+++ b/Source/cmSetSourceFilesPropertiesCommand.cxx
@@ -2,18 +2,23 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSetSourceFilesPropertiesCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
-#include "cmSystemTools.h"
+#include "cmStringAlgorithms.h"
-class cmExecutionStatus;
+static bool RunCommand(cmMakefile* mf,
+ std::vector<std::string>::const_iterator filebeg,
+ std::vector<std::string>::const_iterator fileend,
+ std::vector<std::string>::const_iterator propbeg,
+ std::vector<std::string>::const_iterator propend,
+ std::string& errors);
-// cmSetSourceFilesPropertiesCommand
-bool cmSetSourceFilesPropertiesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmSetSourceFilesPropertiesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
@@ -29,22 +34,24 @@ bool cmSetSourceFilesPropertiesCommand::InitialPass(
++j;
}
+ cmMakefile& mf = status.GetMakefile();
+
// now call the worker function
std::string errors;
- bool ret = cmSetSourceFilesPropertiesCommand::RunCommand(
- this->Makefile, args.begin(), args.begin() + numFiles,
- args.begin() + numFiles, args.end(), errors);
+ bool ret = RunCommand(&mf, args.begin(), args.begin() + numFiles,
+ args.begin() + numFiles, args.end(), errors);
if (!ret) {
- this->SetError(errors);
+ status.SetError(errors);
}
return ret;
}
-bool cmSetSourceFilesPropertiesCommand::RunCommand(
- cmMakefile* mf, std::vector<std::string>::const_iterator filebeg,
- std::vector<std::string>::const_iterator fileend,
- std::vector<std::string>::const_iterator propbeg,
- std::vector<std::string>::const_iterator propend, std::string& errors)
+static bool RunCommand(cmMakefile* mf,
+ std::vector<std::string>::const_iterator filebeg,
+ std::vector<std::string>::const_iterator fileend,
+ std::vector<std::string>::const_iterator propbeg,
+ std::vector<std::string>::const_iterator propend,
+ std::string& errors)
{
std::vector<std::string> propertyPairs;
bool generated = false;
@@ -53,17 +60,17 @@ bool cmSetSourceFilesPropertiesCommand::RunCommand(
for (j = propbeg; j != propend; ++j) {
// old style allows for specifier before PROPERTIES keyword
if (*j == "ABSTRACT") {
- propertyPairs.push_back("ABSTRACT");
- propertyPairs.push_back("1");
+ propertyPairs.emplace_back("ABSTRACT");
+ propertyPairs.emplace_back("1");
} else if (*j == "WRAP_EXCLUDE") {
- propertyPairs.push_back("WRAP_EXCLUDE");
- propertyPairs.push_back("1");
+ propertyPairs.emplace_back("WRAP_EXCLUDE");
+ propertyPairs.emplace_back("1");
} else if (*j == "GENERATED") {
generated = true;
- propertyPairs.push_back("GENERATED");
- propertyPairs.push_back("1");
+ propertyPairs.emplace_back("GENERATED");
+ propertyPairs.emplace_back("1");
} else if (*j == "COMPILE_FLAGS") {
- propertyPairs.push_back("COMPILE_FLAGS");
+ propertyPairs.emplace_back("COMPILE_FLAGS");
++j;
if (j == propend) {
errors = "called with incorrect number of arguments "
@@ -72,7 +79,7 @@ bool cmSetSourceFilesPropertiesCommand::RunCommand(
}
propertyPairs.push_back(*j);
} else if (*j == "OBJECT_DEPENDS") {
- propertyPairs.push_back("OBJECT_DEPENDS");
+ propertyPairs.emplace_back("OBJECT_DEPENDS");
++j;
if (j == propend) {
errors = "called with incorrect number of arguments "
@@ -87,7 +94,7 @@ bool cmSetSourceFilesPropertiesCommand::RunCommand(
propertyPairs.push_back(*j);
if (*j == "GENERATED") {
++j;
- if (j != propend && cmSystemTools::IsOn(j->c_str())) {
+ if (j != propend && cmIsOn(*j)) {
generated = true;
}
} else {
diff --git a/Source/cmSetSourceFilesPropertiesCommand.h b/Source/cmSetSourceFilesPropertiesCommand.h
index 2e22dc9ef..5eef7859a 100644
--- a/Source/cmSetSourceFilesPropertiesCommand.h
+++ b/Source/cmSetSourceFilesPropertiesCommand.h
@@ -3,37 +3,14 @@
#ifndef cmSetSourceFilesPropertiesCommand_h
#define cmSetSourceFilesPropertiesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmMakefile;
-
-class cmSetSourceFilesPropertiesCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE
- {
- return new cmSetSourceFilesPropertiesCommand;
- }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
- static bool RunCommand(cmMakefile* mf,
- std::vector<std::string>::const_iterator filebeg,
- std::vector<std::string>::const_iterator fileend,
- std::vector<std::string>::const_iterator propbeg,
- std::vector<std::string>::const_iterator propend,
- std::string& errors);
-};
+bool cmSetSourceFilesPropertiesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx
index 642591337..8d917dbe5 100644
--- a/Source/cmSetTargetPropertiesCommand.cxx
+++ b/Source/cmSetTargetPropertiesCommand.cxx
@@ -4,65 +4,67 @@
#include <iterator>
+#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
-class cmExecutionStatus;
+static bool SetOneTarget(const std::string& tname,
+ std::vector<std::string>& propertyPairs,
+ cmMakefile* mf);
-// cmSetTargetPropertiesCommand
-bool cmSetTargetPropertiesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmSetTargetPropertiesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
// first collect up the list of files
std::vector<std::string> propertyPairs;
int numFiles = 0;
- std::vector<std::string>::const_iterator j;
- for (j = args.begin(); j != args.end(); ++j) {
+ for (auto j = args.begin(); j != args.end(); ++j) {
if (*j == "PROPERTIES") {
// now loop through the rest of the arguments, new style
++j;
if (std::distance(j, args.end()) % 2 != 0) {
- this->SetError("called with incorrect number of arguments.");
+ status.SetError("called with incorrect number of arguments.");
return false;
}
- propertyPairs.insert(propertyPairs.end(), j, args.end());
+ cmAppend(propertyPairs, j, args.end());
break;
}
numFiles++;
}
if (propertyPairs.empty()) {
- this->SetError("called with illegal arguments, maybe missing "
- "a PROPERTIES specifier?");
+ status.SetError("called with illegal arguments, maybe missing "
+ "a PROPERTIES specifier?");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// now loop over all the targets
- int i;
- for (i = 0; i < numFiles; ++i) {
- if (this->Makefile->IsAlias(args[i])) {
- this->SetError("can not be used on an ALIAS target.");
+ for (int i = 0; i < numFiles; ++i) {
+ if (mf.IsAlias(args[i])) {
+ status.SetError("can not be used on an ALIAS target.");
return false;
}
- bool ret = cmSetTargetPropertiesCommand::SetOneTarget(
- args[i], propertyPairs, this->Makefile);
+ bool ret = SetOneTarget(args[i], propertyPairs, &mf);
if (!ret) {
- std::string message = "Can not find target to add properties to: ";
- message += args[i];
- this->SetError(message);
+ status.SetError(
+ cmStrCat("Can not find target to add properties to: ", args[i]));
return false;
}
}
return true;
}
-bool cmSetTargetPropertiesCommand::SetOneTarget(
- const std::string& tname, std::vector<std::string>& propertyPairs,
- cmMakefile* mf)
+static bool SetOneTarget(const std::string& tname,
+ std::vector<std::string>& propertyPairs,
+ cmMakefile* mf)
{
if (cmTarget* target = mf->FindTargetToUse(tname)) {
// now loop through all the props and set them
diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h
index 425618157..9d40c7498 100644
--- a/Source/cmSetTargetPropertiesCommand.h
+++ b/Source/cmSetTargetPropertiesCommand.h
@@ -3,34 +3,14 @@
#ifndef cmSetTargetsPropertiesCommand_h
#define cmSetTargetsPropertiesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmMakefile;
-
-class cmSetTargetPropertiesCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmSetTargetPropertiesCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
- /**
- * Used by this command and cmSetPropertiesCommand
- */
- static bool SetOneTarget(const std::string& tname,
- std::vector<std::string>& propertyPairs,
- cmMakefile* mf);
-};
+bool cmSetTargetPropertiesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx
index e27c675c6..de61edaf0 100644
--- a/Source/cmSetTestsPropertiesCommand.cxx
+++ b/Source/cmSetTestsPropertiesCommand.cxx
@@ -4,20 +4,26 @@
#include <iterator>
+#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmTest.h"
-class cmExecutionStatus;
+static bool SetOneTest(const std::string& tname,
+ std::vector<std::string>& propertyPairs, cmMakefile* mf,
+ std::string& errors);
-// cmSetTestsPropertiesCommand
-bool cmSetTestsPropertiesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmSetTestsPropertiesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// first collect up the list of files
std::vector<std::string> propertyPairs;
int numFiles = 0;
@@ -27,17 +33,17 @@ bool cmSetTestsPropertiesCommand::InitialPass(
// now loop through the rest of the arguments, new style
++j;
if (std::distance(j, args.end()) % 2 != 0) {
- this->SetError("called with incorrect number of arguments.");
+ status.SetError("called with incorrect number of arguments.");
return false;
}
- propertyPairs.insert(propertyPairs.end(), j, args.end());
+ cmAppend(propertyPairs, j, args.end());
break;
}
numFiles++;
}
if (propertyPairs.empty()) {
- this->SetError("called with illegal arguments, maybe "
- "missing a PROPERTIES specifier?");
+ status.SetError("called with illegal arguments, maybe "
+ "missing a PROPERTIES specifier?");
return false;
}
@@ -45,10 +51,9 @@ bool cmSetTestsPropertiesCommand::InitialPass(
int i;
for (i = 0; i < numFiles; ++i) {
std::string errors;
- bool ret = cmSetTestsPropertiesCommand::SetOneTest(args[i], propertyPairs,
- this->Makefile, errors);
+ bool ret = SetOneTest(args[i], propertyPairs, &mf, errors);
if (!ret) {
- this->SetError(errors);
+ status.SetError(errors);
return ret;
}
}
@@ -56,9 +61,9 @@ bool cmSetTestsPropertiesCommand::InitialPass(
return true;
}
-bool cmSetTestsPropertiesCommand::SetOneTest(
- const std::string& tname, std::vector<std::string>& propertyPairs,
- cmMakefile* mf, std::string& errors)
+static bool SetOneTest(const std::string& tname,
+ std::vector<std::string>& propertyPairs, cmMakefile* mf,
+ std::string& errors)
{
if (cmTest* test = mf->GetTest(tname)) {
// now loop through all the props and set them
@@ -69,8 +74,7 @@ bool cmSetTestsPropertiesCommand::SetOneTest(
}
}
} else {
- errors = "Can not find test to add properties to: ";
- errors += tname;
+ errors = cmStrCat("Can not find test to add properties to: ", tname);
return false;
}
diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h
index 90f004c34..4b754641b 100644
--- a/Source/cmSetTestsPropertiesCommand.h
+++ b/Source/cmSetTestsPropertiesCommand.h
@@ -3,31 +3,14 @@
#ifndef cmSetTestsPropertiesCommand_h
#define cmSetTestsPropertiesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmMakefile;
-
-class cmSetTestsPropertiesCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmSetTestsPropertiesCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
- static bool SetOneTest(const std::string& tname,
- std::vector<std::string>& propertyPairs,
- cmMakefile* mf, std::string& errors);
-};
+bool cmSetTestsPropertiesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx
index 7eace268f..d47f121e0 100644
--- a/Source/cmSiteNameCommand.cxx
+++ b/Source/cmSiteNameCommand.cxx
@@ -4,34 +4,34 @@
#include "cmsys/RegularExpression.hxx"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
// cmSiteNameCommand
-bool cmSiteNameCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmSiteNameCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 1) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string> paths;
- paths.push_back("/usr/bsd");
- paths.push_back("/usr/sbin");
- paths.push_back("/usr/bin");
- paths.push_back("/bin");
- paths.push_back("/sbin");
- paths.push_back("/usr/local/bin");
+ paths.emplace_back("/usr/bsd");
+ paths.emplace_back("/usr/sbin");
+ paths.emplace_back("/usr/bin");
+ paths.emplace_back("/bin");
+ paths.emplace_back("/sbin");
+ paths.emplace_back("/usr/local/bin");
- const char* cacheValue = this->Makefile->GetDefinition(args[0]);
+ const char* cacheValue = status.GetMakefile().GetDefinition(args[0]);
if (cacheValue) {
return true;
}
- const char* temp = this->Makefile->GetDefinition("HOSTNAME");
+ const char* temp = status.GetMakefile().GetDefinition("HOSTNAME");
std::string hostname_cmd;
if (temp) {
hostname_cmd = temp;
@@ -50,11 +50,10 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string> const& args,
}
#else
// try to find the hostname for this computer
- if (!cmSystemTools::IsOff(hostname_cmd.c_str())) {
+ if (!cmIsOff(hostname_cmd)) {
std::string host;
- cmSystemTools::RunSingleCommand(hostname_cmd.c_str(), &host, CM_NULLPTR,
- CM_NULLPTR, CM_NULLPTR,
- cmSystemTools::OUTPUT_NONE);
+ cmSystemTools::RunSingleCommand(hostname_cmd, &host, nullptr, nullptr,
+ nullptr, cmSystemTools::OUTPUT_NONE);
// got the hostname
if (!host.empty()) {
@@ -72,7 +71,7 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string> const& args,
}
}
#endif
- this->Makefile->AddCacheDefinition(
+ status.GetMakefile().AddCacheDefinition(
args[0], siteName.c_str(),
"Name of the computer/site where compile is being run",
cmStateEnums::STRING);
diff --git a/Source/cmSiteNameCommand.h b/Source/cmSiteNameCommand.h
index 6c65480ed..e8fc60807 100644
--- a/Source/cmSiteNameCommand.h
+++ b/Source/cmSiteNameCommand.h
@@ -3,34 +3,19 @@
#ifndef cmSiteNameCommand_h
#define cmSiteNameCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmSiteNameCommand
+/**
* \brief site_name command
*
* cmSiteNameCommand implements the site_name CMake command
*/
-class cmSiteNameCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmSiteNameCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmSiteNameCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 5c4f18b40..2a345eb85 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -2,28 +2,23 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSourceFile.h"
-#include <sstream>
+#include <array>
+#include <utility>
-#include "cmCustomCommand.h"
#include "cmGlobalGenerator.h"
+#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmProperty.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
-cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name)
- : Location(mf, name)
+cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name,
+ cmSourceFileLocationKind kind)
+ : Location(mf, name, kind)
{
- this->CustomCommand = CM_NULLPTR;
- this->FindFullPathFailed = false;
- this->IsUiFile = (".ui" == cmSystemTools::GetFilenameLastExtension(
- this->Location.GetName()));
-}
-
-cmSourceFile::~cmSourceFile()
-{
- this->SetCustomCommand(CM_NULLPTR);
}
std::string const& cmSourceFile::GetExtension() const
@@ -32,6 +27,13 @@ std::string const& cmSourceFile::GetExtension() const
}
const std::string cmSourceFile::propLANGUAGE = "LANGUAGE";
+const std::string cmSourceFile::propLOCATION = "LOCATION";
+const std::string cmSourceFile::propGENERATED = "GENERATED";
+const std::string cmSourceFile::propCOMPILE_DEFINITIONS =
+ "COMPILE_DEFINITIONS";
+const std::string cmSourceFile::propCOMPILE_OPTIONS = "COMPILE_OPTIONS";
+const std::string cmSourceFile::propINCLUDE_DIRECTORIES =
+ "INCLUDE_DIRECTORIES";
void cmSourceFile::SetObjectLibrary(std::string const& objlib)
{
@@ -43,11 +45,13 @@ std::string cmSourceFile::GetObjectLibrary() const
return this->ObjectLibrary;
}
-std::string cmSourceFile::GetLanguage()
+std::string const& cmSourceFile::GetOrDetermineLanguage()
{
// If the language was set explicitly by the user then use it.
if (const char* lang = this->GetProperty(propLANGUAGE)) {
- return lang;
+ // Assign to member in order to return a reference.
+ this->Language = lang;
+ return this->Language;
}
// Perform computation needed to get the language if necessary.
@@ -61,7 +65,7 @@ std::string cmSourceFile::GetLanguage()
this->Location.DirectoryIsAmbiguous()) {
// Finalize the file location to get the extension and set the
// language.
- this->GetFullPath();
+ this->ResolveFullPath();
} else {
// Use the known extension to get the language if possible.
std::string ext =
@@ -70,8 +74,8 @@ std::string cmSourceFile::GetLanguage()
}
}
- // Now try to determine the language.
- return static_cast<cmSourceFile const*>(this)->GetLanguage();
+ // Use the language determined from the file extension.
+ return this->Language;
}
std::string cmSourceFile::GetLanguage() const
@@ -81,13 +85,8 @@ std::string cmSourceFile::GetLanguage() const
return lang;
}
- // If the language was determined from the source file extension use it.
- if (!this->Language.empty()) {
- return this->Language;
- }
-
- // The language is not known.
- return "";
+ // Use the language determined from the file extension.
+ return this->Language;
}
cmSourceFileLocation const& cmSourceFile::GetLocation() const
@@ -95,7 +94,7 @@ cmSourceFileLocation const& cmSourceFile::GetLocation() const
return this->Location;
}
-std::string const& cmSourceFile::GetFullPath(std::string* error)
+std::string const& cmSourceFile::ResolveFullPath(std::string* error)
{
if (this->FullPath.empty()) {
if (this->FindFullPath(error)) {
@@ -112,95 +111,84 @@ std::string const& cmSourceFile::GetFullPath() const
bool cmSourceFile::FindFullPath(std::string* error)
{
- // If thie method has already failed once do not try again.
- if (this->FindFullPathFailed) {
- return false;
- }
-
- // If the file is generated compute the location without checking on
- // disk.
- if (this->GetPropertyAsBool("GENERATED")) {
+ // If the file is generated compute the location without checking on disk.
+ if (this->GetIsGenerated()) {
// The file is either already a full path or is relative to the
// build directory for the target.
this->Location.DirectoryUseBinary();
- this->FullPath = this->Location.GetDirectory();
- this->FullPath += "/";
- this->FullPath += this->Location.GetName();
+ this->FullPath = this->Location.GetFullPath();
return true;
}
- // The file is not generated. It must exist on disk.
- cmMakefile const* mf = this->Location.GetMakefile();
- const char* tryDirs[3] = { CM_NULLPTR, CM_NULLPTR, CM_NULLPTR };
- if (this->Location.DirectoryIsAmbiguous()) {
- tryDirs[0] = mf->GetCurrentSourceDirectory();
- tryDirs[1] = mf->GetCurrentBinaryDirectory();
- } else {
- tryDirs[0] = "";
+ // If this method has already failed once do not try again.
+ if (this->FindFullPathFailed) {
+ return false;
}
- const std::vector<std::string>& srcExts =
- mf->GetCMakeInstance()->GetSourceExtensions();
- std::vector<std::string> hdrExts =
- mf->GetCMakeInstance()->GetHeaderExtensions();
- for (const char* const* di = tryDirs; *di; ++di) {
- std::string tryPath = this->Location.GetDirectory();
- if (!tryPath.empty()) {
- tryPath += "/";
- }
- tryPath += this->Location.GetName();
- tryPath = cmSystemTools::CollapseFullPath(tryPath, *di);
- if (this->TryFullPath(tryPath, "")) {
+
+ // The file is not generated. It must exist on disk.
+ cmMakefile const* makefile = this->Location.GetMakefile();
+ // Location path
+ std::string const lPath = this->Location.GetFullPath();
+ // List of extension lists
+ std::array<std::vector<std::string> const*, 2> const extsLists = {
+ { &makefile->GetCMakeInstance()->GetSourceExtensions(),
+ &makefile->GetCMakeInstance()->GetHeaderExtensions() }
+ };
+
+ // Tries to find the file in a given directory
+ auto findInDir = [this, &extsLists, &lPath](std::string const& dir) -> bool {
+ // Compute full path
+ std::string const fullPath = cmSystemTools::CollapseFullPath(lPath, dir);
+ // Try full path
+ if (cmSystemTools::FileExists(fullPath)) {
+ this->FullPath = fullPath;
return true;
}
- for (std::vector<std::string>::const_iterator ei = srcExts.begin();
- ei != srcExts.end(); ++ei) {
- if (this->TryFullPath(tryPath, *ei)) {
- return true;
+ // Try full path with extension
+ for (auto exts : extsLists) {
+ for (std::string const& ext : *exts) {
+ if (!ext.empty()) {
+ std::string extPath = cmStrCat(fullPath, '.', ext);
+ if (cmSystemTools::FileExists(extPath)) {
+ this->FullPath = extPath;
+ return true;
+ }
+ }
}
}
- for (std::vector<std::string>::const_iterator ei = hdrExts.begin();
- ei != hdrExts.end(); ++ei) {
- if (this->TryFullPath(tryPath, *ei)) {
- return true;
- }
+ // File not found
+ return false;
+ };
+
+ // Try to find the file in various directories
+ if (this->Location.DirectoryIsAmbiguous()) {
+ if (findInDir(makefile->GetCurrentSourceDirectory()) ||
+ findInDir(makefile->GetCurrentBinaryDirectory())) {
+ return true;
+ }
+ } else {
+ if (findInDir({})) {
+ return true;
}
}
- std::ostringstream e;
- std::string missing = this->Location.GetDirectory();
- if (!missing.empty()) {
- missing += "/";
- }
- missing += this->Location.GetName();
- e << "Cannot find source file:\n " << missing << "\nTried extensions";
- for (std::vector<std::string>::const_iterator ext = srcExts.begin();
- ext != srcExts.end(); ++ext) {
- e << " ." << *ext;
- }
- for (std::vector<std::string>::const_iterator ext = hdrExts.begin();
- ext != hdrExts.end(); ++ext) {
- e << " ." << *ext;
+ // Compose error
+ std::string err =
+ cmStrCat("Cannot find source file:\n ", lPath, "\nTried extensions");
+ for (auto exts : extsLists) {
+ for (std::string const& ext : *exts) {
+ err += " .";
+ err += ext;
+ }
}
- if (error) {
- *error = e.str();
+ if (error != nullptr) {
+ *error = std::move(err);
} else {
- this->Location.GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str());
+ makefile->IssueMessage(MessageType::FATAL_ERROR, err);
}
this->FindFullPathFailed = true;
- return false;
-}
-bool cmSourceFile::TryFullPath(const std::string& path, const std::string& ext)
-{
- std::string tryPath = path;
- if (!ext.empty()) {
- tryPath += ".";
- tryPath += ext;
- }
- if (cmSystemTools::FileExists(tryPath.c_str())) {
- this->FullPath = tryPath;
- return true;
- }
+ // File not found
return false;
}
@@ -244,20 +232,60 @@ bool cmSourceFile::Matches(cmSourceFileLocation const& loc)
void cmSourceFile::SetProperty(const std::string& prop, const char* value)
{
- this->Properties.SetProperty(prop, value);
-
- if (this->IsUiFile) {
- cmMakefile const* mf = this->Location.GetMakefile();
- if (prop == "AUTOUIC_OPTIONS") {
- const_cast<cmMakefile*>(mf)->AddQtUiFileWithOptions(this);
+ if (prop == propINCLUDE_DIRECTORIES) {
+ this->IncludeDirectories.clear();
+ if (value) {
+ cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
+ this->IncludeDirectories.emplace_back(value, lfbt);
+ }
+ } else if (prop == propCOMPILE_OPTIONS) {
+ this->CompileOptions.clear();
+ if (value) {
+ cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
+ this->CompileOptions.emplace_back(value, lfbt);
}
+ } else if (prop == propCOMPILE_DEFINITIONS) {
+ this->CompileDefinitions.clear();
+ if (value) {
+ cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
+ this->CompileDefinitions.emplace_back(value, lfbt);
+ }
+ } else {
+ this->Properties.SetProperty(prop, value);
+ }
+
+ // Update IsGenerated flag
+ if (prop == propGENERATED) {
+ this->IsGenerated = cmIsOn(value);
}
}
void cmSourceFile::AppendProperty(const std::string& prop, const char* value,
bool asString)
{
- this->Properties.AppendProperty(prop, value, asString);
+ if (prop == propINCLUDE_DIRECTORIES) {
+ if (value && *value) {
+ cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
+ this->IncludeDirectories.emplace_back(value, lfbt);
+ }
+ } else if (prop == propCOMPILE_OPTIONS) {
+ if (value && *value) {
+ cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
+ this->CompileOptions.emplace_back(value, lfbt);
+ }
+ } else if (prop == propCOMPILE_DEFINITIONS) {
+ if (value && *value) {
+ cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
+ this->CompileDefinitions.emplace_back(value, lfbt);
+ }
+ } else {
+ this->Properties.AppendProperty(prop, value, asString);
+ }
+
+ // Update IsGenerated flag
+ if (prop == propGENERATED) {
+ this->IsGenerated = this->GetPropertyAsBool(propGENERATED);
+ }
}
const char* cmSourceFile::GetPropertyForUser(const std::string& prop)
@@ -276,9 +304,16 @@ const char* cmSourceFile::GetPropertyForUser(const std::string& prop)
// cmSourceFileLocation class to commit to a particular full path to
// the source file as late as possible. If the users requests the
// LOCATION property we must commit now.
- if (prop == "LOCATION") {
+ if (prop == propLOCATION) {
// Commit to a location.
- this->GetFullPath();
+ this->ResolveFullPath();
+ }
+
+ // Similarly, LANGUAGE can be determined by the file extension
+ // if it is requested by the user.
+ if (prop == propLANGUAGE) {
+ // The c_str pointer is valid until `this->Language` is modified.
+ return this->GetOrDetermineLanguage().c_str();
}
// Perform the normal property lookup.
@@ -288,13 +323,44 @@ const char* cmSourceFile::GetPropertyForUser(const std::string& prop)
const char* cmSourceFile::GetProperty(const std::string& prop) const
{
// Check for computed properties.
- if (prop == "LOCATION") {
+ if (prop == propLOCATION) {
if (this->FullPath.empty()) {
- return CM_NULLPTR;
+ return nullptr;
}
return this->FullPath.c_str();
}
+ // Check for the properties with backtraces.
+ if (prop == propINCLUDE_DIRECTORIES) {
+ if (this->IncludeDirectories.empty()) {
+ return nullptr;
+ }
+
+ static std::string output;
+ output = cmJoin(this->IncludeDirectories, ";");
+ return output.c_str();
+ }
+
+ if (prop == propCOMPILE_OPTIONS) {
+ if (this->CompileOptions.empty()) {
+ return nullptr;
+ }
+
+ static std::string output;
+ output = cmJoin(this->CompileOptions, ";");
+ return output.c_str();
+ }
+
+ if (prop == propCOMPILE_DEFINITIONS) {
+ if (this->CompileDefinitions.empty()) {
+ return nullptr;
+ }
+
+ static std::string output;
+ output = cmJoin(this->CompileDefinitions, ";");
+ return output.c_str();
+ }
+
const char* retVal = this->Properties.GetPropertyValue(prop);
if (!retVal) {
cmMakefile const* mf = this->Location.GetMakefile();
@@ -308,24 +374,33 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const
return retVal;
}
+const char* cmSourceFile::GetSafeProperty(const std::string& prop) const
+{
+ const char* ret = this->GetProperty(prop);
+ if (!ret) {
+ return "";
+ }
+ return ret;
+}
+
bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const
{
- return cmSystemTools::IsOn(this->GetProperty(prop));
+ return cmIsOn(this->GetProperty(prop));
}
-cmCustomCommand* cmSourceFile::GetCustomCommand()
+void cmSourceFile::SetProperties(cmPropertyMap properties)
{
- return this->CustomCommand;
+ this->Properties = std::move(properties);
+
+ this->IsGenerated = this->GetPropertyAsBool(propGENERATED);
}
-cmCustomCommand const* cmSourceFile::GetCustomCommand() const
+cmCustomCommand* cmSourceFile::GetCustomCommand() const
{
- return this->CustomCommand;
+ return this->CustomCommand.get();
}
-void cmSourceFile::SetCustomCommand(cmCustomCommand* cc)
+void cmSourceFile::SetCustomCommand(std::unique_ptr<cmCustomCommand> cc)
{
- cmCustomCommand* old = this->CustomCommand;
- this->CustomCommand = cc;
- delete old;
+ this->CustomCommand = std::move(cc);
}
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index 0be659c5f..82a3625b8 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -3,15 +3,18 @@
#ifndef cmSourceFile_h
#define cmSourceFile_h
-#include "cmConfigure.h"
-
-#include "cmPropertyMap.h"
-#include "cmSourceFileLocation.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <memory>
#include <string>
#include <vector>
-class cmCustomCommand;
+#include "cmCustomCommand.h"
+#include "cmListFileCache.h"
+#include "cmPropertyMap.h"
+#include "cmSourceFileLocation.h"
+#include "cmSourceFileLocationKind.h"
+
class cmMakefile;
/** \class cmSourceFile
@@ -27,37 +30,59 @@ public:
* Construct with the makefile storing the source and the initial
* name referencing it.
*/
- cmSourceFile(cmMakefile* mf, const std::string& name);
-
- ~cmSourceFile();
+ cmSourceFile(
+ cmMakefile* mf, const std::string& name,
+ cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous);
/**
- * Get the list of the custom commands for this source file
+ * Get the custom command for this source file
*/
- cmCustomCommand* GetCustomCommand();
- cmCustomCommand const* GetCustomCommand() const;
- void SetCustomCommand(cmCustomCommand* cc);
+ cmCustomCommand* GetCustomCommand() const;
+ void SetCustomCommand(std::unique_ptr<cmCustomCommand> cc);
- ///! Set/Get a property of this source file
+ //! Set/Get a property of this source file
void SetProperty(const std::string& prop, const char* value);
void AppendProperty(const std::string& prop, const char* value,
bool asString = false);
+ //! Might return a nullptr if the property is not set or invalid
const char* GetProperty(const std::string& prop) const;
+ //! Always returns a valid pointer
+ const char* GetSafeProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;
/** Implement getting a property when called from a CMake language
command like get_property or get_source_file_property. */
const char* GetPropertyForUser(const std::string& prop);
+ //! Checks is the GENERATED property is set and true
+ /// @return Equivalent to GetPropertyAsBool("GENERATED")
+ bool GetIsGenerated() const { return this->IsGenerated; }
+
+ const std::vector<BT<std::string>>& GetCompileOptions() const
+ {
+ return this->CompileOptions;
+ }
+
+ const std::vector<BT<std::string>>& GetCompileDefinitions() const
+ {
+ return this->CompileDefinitions;
+ }
+
+ const std::vector<BT<std::string>>& GetIncludeDirectories() const
+ {
+ return this->IncludeDirectories;
+ }
+
+ /**
+ * Resolves the full path to the file. Attempts to locate the file on disk
+ * and finalizes its location.
+ */
+ std::string const& ResolveFullPath(std::string* error = nullptr);
+
/**
- * The full path to the file. The non-const version of this method
- * may attempt to locate the file on disk and finalize its location.
- * The const version of this method may return an empty string if
- * the non-const version has not yet been called (yes this is a
- * horrible interface, but is necessary for backwards
- * compatibility).
+ * The resolved full path to the file. The returned file name might be empty
+ * if the path has not yet been resolved.
*/
- std::string const& GetFullPath(std::string* error = CM_NULLPTR);
std::string const& GetFullPath() const;
/**
@@ -75,7 +100,7 @@ public:
/**
* Get the language of the compiler to use for this source file.
*/
- std::string GetLanguage();
+ std::string const& GetOrDetermineLanguage();
std::string GetLanguage() const;
/**
@@ -85,8 +110,9 @@ public:
void AddDepend(const std::string& d) { this->Depends.push_back(d); }
// Get the properties
- cmPropertyMap& GetProperties() { return this->Properties; }
const cmPropertyMap& GetProperties() const { return this->Properties; }
+ // Set the properties
+ void SetProperties(cmPropertyMap properties);
/**
* Check whether the given source file location could refer to this
@@ -100,24 +126,40 @@ public:
private:
cmSourceFileLocation Location;
cmPropertyMap Properties;
- cmCustomCommand* CustomCommand;
+ std::unique_ptr<cmCustomCommand> CustomCommand;
std::string Extension;
std::string Language;
std::string FullPath;
std::string ObjectLibrary;
std::vector<std::string> Depends;
- bool FindFullPathFailed;
- bool IsUiFile;
+ std::vector<BT<std::string>> CompileOptions;
+ std::vector<BT<std::string>> CompileDefinitions;
+ std::vector<BT<std::string>> IncludeDirectories;
+ bool FindFullPathFailed = false;
+ bool IsGenerated = false;
bool FindFullPath(std::string* error);
- bool TryFullPath(const std::string& path, const std::string& ext);
void CheckExtension();
void CheckLanguage(std::string const& ext);
static const std::string propLANGUAGE;
+ static const std::string propLOCATION;
+ static const std::string propGENERATED;
+ static const std::string propCOMPILE_DEFINITIONS;
+ static const std::string propCOMPILE_OPTIONS;
+ static const std::string propINCLUDE_DIRECTORIES;
};
// TODO: Factor out into platform information modules.
#define CM_HEADER_REGEX "\\.(h|hh|h\\+\\+|hm|hpp|hxx|in|txx|inl)$"
+#define CM_SOURCE_REGEX \
+ "\\.(C|M|c|c\\+\\+|cc|cpp|cxx|cu|f|f90|for|fpp|ftn|m|mm|rc|def|r|odl|idl|" \
+ "hpj" \
+ "|bat)$"
+
+#define CM_PCH_REGEX "cmake_pch\\.(h|hxx)$"
+
+#define CM_RESOURCE_REGEX "\\.(pdf|plist|png|jpeg|jpg|storyboard|xcassets)$"
+
#endif
diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx
index 86711d784..df702b050 100644
--- a/Source/cmSourceFileLocation.cxx
+++ b/Source/cmSourceFileLocation.cxx
@@ -2,24 +2,16 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSourceFileLocation.h"
-#include "cmConfigure.h"
+#include <cassert>
-#include "cmAlgorithms.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
-#include <algorithm>
-#include <assert.h>
-#include <vector>
-
-cmSourceFileLocation::cmSourceFileLocation()
- : Makefile(CM_NULLPTR)
- , AmbiguousDirectory(true)
- , AmbiguousExtension(true)
-{
-}
+cmSourceFileLocation::cmSourceFileLocation() = default;
cmSourceFileLocation::cmSourceFileLocation(const cmSourceFileLocation& loc)
: Makefile(loc.Makefile)
@@ -30,33 +22,34 @@ cmSourceFileLocation::cmSourceFileLocation(const cmSourceFileLocation& loc)
this->Name = loc.Name;
}
-cmSourceFileLocation& cmSourceFileLocation::operator=(
- const cmSourceFileLocation& loc)
-{
- if (this == &loc) {
- return *this;
- }
- this->Makefile = loc.Makefile;
- this->AmbiguousDirectory = loc.AmbiguousDirectory;
- this->AmbiguousExtension = loc.AmbiguousExtension;
- this->Directory = loc.Directory;
- this->Name = loc.Name;
- this->UpdateExtension(this->Name);
- return *this;
-}
-
cmSourceFileLocation::cmSourceFileLocation(cmMakefile const* mf,
- const std::string& name)
+ const std::string& name,
+ cmSourceFileLocationKind kind)
: Makefile(mf)
{
- this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name.c_str());
+ this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name);
this->AmbiguousExtension = true;
this->Directory = cmSystemTools::GetFilenamePath(name);
- if (cmSystemTools::FileIsFullPath(this->Directory.c_str())) {
+ if (cmSystemTools::FileIsFullPath(this->Directory)) {
this->Directory = cmSystemTools::CollapseFullPath(this->Directory);
}
this->Name = cmSystemTools::GetFilenameName(name);
- this->UpdateExtension(name);
+ if (kind == cmSourceFileLocationKind::Known) {
+ this->DirectoryUseSource();
+ this->AmbiguousExtension = false;
+ } else {
+ this->UpdateExtension(name);
+ }
+}
+
+std::string cmSourceFileLocation::GetFullPath() const
+{
+ std::string path = this->GetDirectory();
+ if (!path.empty()) {
+ path += '/';
+ }
+ path += this->GetName();
+ return path;
}
void cmSourceFileLocation::Update(cmSourceFileLocation const& loc)
@@ -103,13 +96,9 @@ void cmSourceFileLocation::UpdateExtension(const std::string& name)
// The global generator checks extensions of enabled languages.
cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
cmMakefile const* mf = this->Makefile;
- const std::vector<std::string>& srcExts =
- mf->GetCMakeInstance()->GetSourceExtensions();
- const std::vector<std::string>& hdrExts =
- mf->GetCMakeInstance()->GetHeaderExtensions();
+ auto cm = mf->GetCMakeInstance();
if (!gg->GetLanguageFromExtension(ext.c_str()).empty() ||
- std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() ||
- std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end()) {
+ cm->IsSourceExtension(ext) || cm->IsHeaderExtension(ext)) {
// This is a known extension. Use the given filename with extension.
this->Name = cmSystemTools::GetFilenameName(name);
this->AmbiguousExtension = false;
@@ -121,15 +110,14 @@ void cmSourceFileLocation::UpdateExtension(const std::string& name)
// Check the source tree only because a file in the build tree should
// be specified by full path at least once. We do not want this
// detection to depend on whether the project has already been built.
- tryPath = this->Makefile->GetCurrentSourceDirectory();
- tryPath += "/";
+ tryPath = cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/');
}
if (!this->Directory.empty()) {
tryPath += this->Directory;
tryPath += "/";
}
tryPath += this->Name;
- if (cmSystemTools::FileExists(tryPath.c_str(), true)) {
+ if (cmSystemTools::FileExists(tryPath, true)) {
// We found a source file named by the user on disk. Trust it's
// extension.
this->Name = cmSystemTools::GetFilenameName(name);
@@ -157,8 +145,7 @@ bool cmSourceFileLocation::MatchesAmbiguousExtension(
// adding an extension.
if (!(this->Name.size() > loc.Name.size() &&
this->Name[loc.Name.size()] == '.' &&
- cmHasLiteralPrefixImpl(this->Name.c_str(), loc.Name.c_str(),
- loc.Name.size()))) {
+ cmHasPrefix(this->Name, loc.Name))) {
return false;
}
@@ -166,14 +153,8 @@ bool cmSourceFileLocation::MatchesAmbiguousExtension(
// disk. One of these must match if loc refers to this source file.
std::string const& ext = this->Name.substr(loc.Name.size() + 1);
cmMakefile const* mf = this->Makefile;
- const std::vector<std::string>& srcExts =
- mf->GetCMakeInstance()->GetSourceExtensions();
- if (std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end()) {
- return true;
- }
- std::vector<std::string> hdrExts =
- mf->GetCMakeInstance()->GetHeaderExtensions();
- return std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end();
+ auto cm = mf->GetCMakeInstance();
+ return cm->IsSourceExtension(ext) || cm->IsHeaderExtension(ext);
}
bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
@@ -220,7 +201,7 @@ bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
// This can occur when referencing a source file from a different
// directory. This is not yet allowed.
this->Makefile->IssueMessage(
- cmake::INTERNAL_ERROR,
+ MessageType::INTERNAL_ERROR,
"Matches error: Each side has a directory relative to a different "
"location. This can occur when referencing a source file from a "
"different directory. This is not yet allowed.");
@@ -228,18 +209,18 @@ bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
}
} else if (this->AmbiguousDirectory) {
// Compare possible directory combinations.
- std::string const& srcDir = cmSystemTools::CollapseFullPath(
+ std::string const srcDir = cmSystemTools::CollapseFullPath(
this->Directory, this->Makefile->GetCurrentSourceDirectory());
- std::string const& binDir = cmSystemTools::CollapseFullPath(
+ std::string const binDir = cmSystemTools::CollapseFullPath(
this->Directory, this->Makefile->GetCurrentBinaryDirectory());
if (srcDir != loc.Directory && binDir != loc.Directory) {
return false;
}
} else if (loc.AmbiguousDirectory) {
// Compare possible directory combinations.
- std::string const& srcDir = cmSystemTools::CollapseFullPath(
+ std::string const srcDir = cmSystemTools::CollapseFullPath(
loc.Directory, loc.Makefile->GetCurrentSourceDirectory());
- std::string const& binDir = cmSystemTools::CollapseFullPath(
+ std::string const binDir = cmSystemTools::CollapseFullPath(
loc.Directory, loc.Makefile->GetCurrentBinaryDirectory());
if (srcDir != this->Directory && binDir != this->Directory) {
return false;
diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h
index 6dbc2daed..87040b882 100644
--- a/Source/cmSourceFileLocation.h
+++ b/Source/cmSourceFileLocation.h
@@ -7,6 +7,8 @@
#include <string>
+#include "cmSourceFileLocationKind.h"
+
class cmMakefile;
/** \class cmSourceFileLocation
@@ -26,10 +28,13 @@ public:
* Construct for a source file created in a given cmMakefile
* instance with an initial name.
*/
- cmSourceFileLocation(cmMakefile const* mf, const std::string& name);
+ cmSourceFileLocation(
+ cmMakefile const* mf, const std::string& name,
+ cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous);
cmSourceFileLocation();
cmSourceFileLocation(const cmSourceFileLocation& loc);
- cmSourceFileLocation& operator=(const cmSourceFileLocation& loc);
+
+ cmSourceFileLocation& operator=(cmSourceFileLocation const&) = delete;
/**
* Return whether the given source file location could refers to the
@@ -39,12 +44,12 @@ public:
bool Matches(cmSourceFileLocation const& loc);
/**
- * Explicity state that the source file is located in the source tree.
+ * Explicitly state that the source file is located in the source tree.
*/
void DirectoryUseSource();
/**
- * Explicity state that the source file is located in the build tree.
+ * Explicitly state that the source file is located in the build tree.
*/
void DirectoryUseBinary();
@@ -75,13 +80,19 @@ public:
const std::string& GetName() const { return this->Name; }
/**
+ * Get the full file path composed of GetDirectory() and GetName().
+ */
+ std::string GetFullPath() const;
+
+ /**
* Get the cmMakefile instance for which the source file was created.
*/
cmMakefile const* GetMakefile() const { return this->Makefile; }
+
private:
- cmMakefile const* Makefile;
- bool AmbiguousDirectory;
- bool AmbiguousExtension;
+ cmMakefile const* const Makefile = nullptr;
+ bool AmbiguousDirectory = true;
+ bool AmbiguousExtension = true;
std::string Directory;
std::string Name;
diff --git a/Source/cmSourceFileLocationKind.h b/Source/cmSourceFileLocationKind.h
new file mode 100644
index 000000000..dd4c6dd4f
--- /dev/null
+++ b/Source/cmSourceFileLocationKind.h
@@ -0,0 +1,15 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmSourceFileLocationKind_h
+#define cmSourceFileLocationKind_h
+
+enum class cmSourceFileLocationKind
+{
+ // The location is user-specified and may be ambiguous.
+ Ambiguous,
+ // The location is known to be at the given location; do not try to guess at
+ // extensions or absolute path.
+ Known
+};
+
+#endif
diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx
index 104e959a9..8c3ec9fec 100644
--- a/Source/cmSourceGroup.cxx
+++ b/Source/cmSourceGroup.cxx
@@ -2,21 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSourceGroup.h"
+#include <utility>
+
+#include "cmStringAlgorithms.h"
+
class cmSourceGroupInternals
{
public:
std::vector<cmSourceGroup> GroupChildren;
};
-cmSourceGroup::cmSourceGroup(const char* name, const char* regex,
+cmSourceGroup::cmSourceGroup(std::string name, const char* regex,
const char* parentName)
- : Name(name)
+ : Name(std::move(name))
{
this->Internal = new cmSourceGroupInternals;
this->SetGroupRegex(regex);
if (parentName) {
- this->FullName = parentName;
- this->FullName += "\\";
+ this->FullName = cmStrCat(parentName, '\\');
}
this->FullName += this->Name;
}
@@ -60,24 +63,24 @@ void cmSourceGroup::AddGroupFile(const std::string& name)
this->GroupFiles.insert(name);
}
-const char* cmSourceGroup::GetName() const
+std::string const& cmSourceGroup::GetName() const
{
- return this->Name.c_str();
+ return this->Name;
}
-const char* cmSourceGroup::GetFullName() const
+std::string const& cmSourceGroup::GetFullName() const
{
- return this->FullName.c_str();
+ return this->FullName;
}
-bool cmSourceGroup::MatchesRegex(const char* name)
+bool cmSourceGroup::MatchesRegex(const std::string& name)
{
return this->GroupRegex.find(name);
}
-bool cmSourceGroup::MatchesFiles(const char* name)
+bool cmSourceGroup::MatchesFiles(const std::string& name) const
{
- return this->GroupFiles.find(name) != this->GroupFiles.end();
+ return this->GroupFiles.find(name) != this->GroupFiles.cend();
}
void cmSourceGroup::AssignSource(const cmSourceFile* sf)
@@ -95,58 +98,37 @@ void cmSourceGroup::AddChild(cmSourceGroup const& child)
this->Internal->GroupChildren.push_back(child);
}
-cmSourceGroup* cmSourceGroup::LookupChild(const char* name) const
+cmSourceGroup* cmSourceGroup::LookupChild(const std::string& name)
{
- // initializing iterators
- std::vector<cmSourceGroup>::const_iterator iter =
- this->Internal->GroupChildren.begin();
- const std::vector<cmSourceGroup>::const_iterator end =
- this->Internal->GroupChildren.end();
-
- // st
- for (; iter != end; ++iter) {
- std::string sgName = iter->GetName();
-
+ for (cmSourceGroup& group : this->Internal->GroupChildren) {
// look if descenened is the one were looking for
- if (sgName == name) {
- return const_cast<cmSourceGroup*>(&(*iter)); // if it so return it
+ if (group.GetName() == name) {
+ return (&group); // if it so return it
}
}
// if no child with this name was found return NULL
- return CM_NULLPTR;
+ return nullptr;
}
-cmSourceGroup* cmSourceGroup::MatchChildrenFiles(const char* name)
+cmSourceGroup* cmSourceGroup::MatchChildrenFiles(const std::string& name)
{
- // initializing iterators
- std::vector<cmSourceGroup>::iterator iter =
- this->Internal->GroupChildren.begin();
- std::vector<cmSourceGroup>::iterator end =
- this->Internal->GroupChildren.end();
-
if (this->MatchesFiles(name)) {
return this;
}
- for (; iter != end; ++iter) {
- cmSourceGroup* result = iter->MatchChildrenFiles(name);
+ for (cmSourceGroup& group : this->Internal->GroupChildren) {
+ cmSourceGroup* result = group.MatchChildrenFiles(name);
if (result) {
return result;
}
}
- return CM_NULLPTR;
+ return nullptr;
}
-cmSourceGroup* cmSourceGroup::MatchChildrenRegex(const char* name)
+cmSourceGroup* cmSourceGroup::MatchChildrenRegex(const std::string& name)
{
- // initializing iterators
- std::vector<cmSourceGroup>::iterator iter =
- this->Internal->GroupChildren.begin();
- std::vector<cmSourceGroup>::iterator end =
- this->Internal->GroupChildren.end();
-
- for (; iter != end; ++iter) {
- cmSourceGroup* result = iter->MatchChildrenRegex(name);
+ for (cmSourceGroup& group : this->Internal->GroupChildren) {
+ cmSourceGroup* result = group.MatchChildrenRegex(name);
if (result) {
return result;
}
@@ -155,7 +137,7 @@ cmSourceGroup* cmSourceGroup::MatchChildrenRegex(const char* name)
return this;
}
- return CM_NULLPTR;
+ return nullptr;
}
std::vector<cmSourceGroup> const& cmSourceGroup::GetGroupChildren() const
diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h
index 97affed6e..581dc5dee 100644
--- a/Source/cmSourceGroup.h
+++ b/Source/cmSourceGroup.h
@@ -3,13 +3,14 @@
#ifndef cmSourceGroup_h
#define cmSourceGroup_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmsys/RegularExpression.hxx"
#include <set>
#include <string>
#include <vector>
+#include "cmsys/RegularExpression.hxx"
+
class cmSourceFile;
class cmSourceGroupInternals;
@@ -26,8 +27,8 @@ class cmSourceGroupInternals;
class cmSourceGroup
{
public:
- cmSourceGroup(const char* name, const char* regex,
- const char* parentName = CM_NULLPTR);
+ cmSourceGroup(std::string name, const char* regex,
+ const char* parentName = nullptr);
cmSourceGroup(cmSourceGroup const& r);
~cmSourceGroup();
cmSourceGroup& operator=(cmSourceGroup const&);
@@ -50,38 +51,38 @@ public:
/**
* Looks up child and returns it
*/
- cmSourceGroup* LookupChild(const char* name) const;
+ cmSourceGroup* LookupChild(const std::string& name);
/**
* Get the name of this group.
*/
- const char* GetName() const;
+ std::string const& GetName() const;
/**
* Get the full path name for group.
*/
- const char* GetFullName() const;
+ std::string const& GetFullName() const;
/**
* Check if the given name matches this group's regex.
*/
- bool MatchesRegex(const char* name);
+ bool MatchesRegex(const std::string& name);
/**
* Check if the given name matches this group's explicit file list.
*/
- bool MatchesFiles(const char* name);
+ bool MatchesFiles(const std::string& name) const;
/**
* Check if the given name matches this group's explicit file list
* in children.
*/
- cmSourceGroup* MatchChildrenFiles(const char* name);
+ cmSourceGroup* MatchChildrenFiles(const std::string& name);
/**
* Check if the given name matches this group's regex in children.
*/
- cmSourceGroup* MatchChildrenRegex(const char* name);
+ cmSourceGroup* MatchChildrenRegex(const std::string& name);
/**
* Assign the given source file to this group. Used only by
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index a966300c0..cc62952d8 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -2,23 +2,32 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSourceGroupCommand.h"
+#include <cstddef>
+#include <map>
#include <set>
-#include <sstream>
-#include <stddef.h>
+#include <utility>
+#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmSourceGroup.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
namespace {
-const size_t RootIndex = 1;
-const size_t FilesWithoutPrefixKeywordIndex = 2;
-const size_t FilesWithPrefixKeywordIndex = 4;
-const size_t PrefixKeywordIndex = 2;
+
+using ParsedArguments = std::map<std::string, std::vector<std::string>>;
+using ExpectedOptions = std::vector<std::string>;
+
+const std::string kTreeOptionName = "TREE";
+const std::string kPrefixOptionName = "PREFIX";
+const std::string kFilesOptionName = "FILES";
+const std::string kRegexOptionName = "REGULAR_EXPRESSION";
+const std::string kSourceGroupOptionName = "<sg_name>";
std::vector<std::string> tokenizePath(const std::string& path)
{
- return cmSystemTools::tokenize(path, "\\/");
+ return cmTokenize(path, "\\/");
}
std::string getFullFilePath(const std::string& currentPath,
@@ -26,10 +35,8 @@ std::string getFullFilePath(const std::string& currentPath,
{
std::string fullPath = path;
- if (!cmSystemTools::FileIsFullPath(path.c_str())) {
- fullPath = currentPath;
- fullPath += "/";
- fullPath += path;
+ if (!cmSystemTools::FileIsFullPath(path)) {
+ fullPath = cmStrCat(currentPath, '/', path);
}
return cmSystemTools::CollapseFullPath(fullPath);
@@ -41,8 +48,8 @@ std::set<std::string> getSourceGroupFilesPaths(
std::set<std::string> ret;
const std::string::size_type rootLength = root.length();
- for (size_t i = 0; i < files.size(); ++i) {
- ret.insert(files[i].substr(rootLength + 1)); // +1 to also omnit last '/'
+ for (std::string const& file : files) {
+ ret.insert(file.substr(rootLength + 1)); // +1 to also omnit last '/'
}
return ret;
@@ -51,9 +58,9 @@ std::set<std::string> getSourceGroupFilesPaths(
bool rootIsPrefix(const std::string& root,
const std::vector<std::string>& files, std::string& error)
{
- for (size_t i = 0; i < files.size(); ++i) {
- if (!cmSystemTools::StringStartsWith(files[i], root.c_str())) {
- error = "ROOT: " + root + " is not a prefix of file: " + files[i];
+ for (std::string const& file : files) {
+ if (!cmHasPrefix(file, root)) {
+ error = cmStrCat("ROOT: ", root, " is not a prefix of file: ", file);
return false;
}
}
@@ -61,41 +68,28 @@ bool rootIsPrefix(const std::string& root,
return true;
}
-cmSourceGroup* addSourceGroup(const std::vector<std::string>& tokenizedPath,
- cmMakefile& makefile)
-{
- cmSourceGroup* sg;
-
- sg = makefile.GetSourceGroup(tokenizedPath);
- if (!sg) {
- makefile.AddSourceGroup(tokenizedPath);
- sg = makefile.GetSourceGroup(tokenizedPath);
- if (!sg) {
- return CM_NULLPTR;
- }
- }
-
- return sg;
-}
-
-std::string prepareFilePathForTree(const std::string& path,
- const std::string& currentSourceDir)
-{
- if (!cmSystemTools::FileIsFullPath(path)) {
- return cmSystemTools::CollapseFullPath(currentSourceDir + "/" + path);
- }
- return cmSystemTools::CollapseFullPath(path);
-}
-
std::vector<std::string> prepareFilesPathsForTree(
- std::vector<std::string>::const_iterator begin,
- std::vector<std::string>::const_iterator end,
+ const std::vector<std::string>& filesPaths,
const std::string& currentSourceDir)
{
std::vector<std::string> prepared;
+ prepared.reserve(filesPaths.size());
+
+ for (auto const& filePath : filesPaths) {
+ std::string fullPath =
+ cmSystemTools::CollapseFullPath(filePath, currentSourceDir);
+ // If provided file path is actually not a directory, silently ignore it.
+ if (cmSystemTools::FileIsDirectory(fullPath)) {
+ continue;
+ }
- for (; begin != end; ++begin) {
- prepared.push_back(prepareFilePathForTree(*begin, currentSourceDir));
+ // Handle directory that doesn't exist yet.
+ if (!fullPath.empty() &&
+ (fullPath.back() == '/' || fullPath.back() == '\\')) {
+ continue;
+ }
+
+ prepared.emplace_back(std::move(fullPath));
}
return prepared;
@@ -108,167 +102,192 @@ bool addFilesToItsSourceGroups(const std::string& root,
{
cmSourceGroup* sg;
- for (std::set<std::string>::const_iterator it = sgFilesPaths.begin();
- it != sgFilesPaths.end(); ++it) {
+ for (std::string const& sgFilesPath : sgFilesPaths) {
std::vector<std::string> tokenizedPath;
if (!prefix.empty()) {
- tokenizedPath = tokenizePath(prefix + '/' + *it);
+ tokenizedPath = tokenizePath(cmStrCat(prefix, '/', sgFilesPath));
} else {
- tokenizedPath = tokenizePath(*it);
+ tokenizedPath = tokenizePath(sgFilesPath);
}
- if (tokenizedPath.size() > 1) {
+ if (!tokenizedPath.empty()) {
tokenizedPath.pop_back();
- sg = addSourceGroup(tokenizedPath, makefile);
+ if (tokenizedPath.empty()) {
+ tokenizedPath.emplace_back();
+ }
+
+ sg = makefile.GetOrCreateSourceGroup(tokenizedPath);
if (!sg) {
- errorMsg = "Could not create source group for file: " + *it;
+ errorMsg = "Could not create source group for file: " + sgFilesPath;
return false;
}
- const std::string fullPath = getFullFilePath(root, *it);
+ const std::string fullPath = getFullFilePath(root, sgFilesPath);
sg->AddGroupFile(fullPath);
}
}
return true;
}
+
+ExpectedOptions getExpectedOptions()
+{
+ ExpectedOptions options;
+
+ options.push_back(kTreeOptionName);
+ options.push_back(kPrefixOptionName);
+ options.push_back(kFilesOptionName);
+ options.push_back(kRegexOptionName);
+
+ return options;
}
-class cmExecutionStatus;
+bool isExpectedOption(const std::string& argument,
+ const ExpectedOptions& expectedOptions)
+{
+ return cmContains(expectedOptions, argument);
+}
-// cmSourceGroupCommand
-bool cmSourceGroupCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+void parseArguments(const std::vector<std::string>& args,
+ ParsedArguments& parsedArguments)
{
- if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
- return false;
+ const ExpectedOptions expectedOptions = getExpectedOptions();
+ size_t i = 0;
+
+ // at this point we know that args vector is not empty
+
+ // if first argument is not one of expected options it's source group name
+ if (!isExpectedOption(args[0], expectedOptions)) {
+ // get source group name and go to next argument
+ parsedArguments[kSourceGroupOptionName].push_back(args[0]);
+ ++i;
}
- if (args[0] == "TREE") {
- std::string error;
+ for (; i < args.size();) {
+ // get current option and increment index to go to next argument
+ const std::string& currentOption = args[i++];
- if (!processTree(args, error)) {
- this->SetError(error);
- return false;
- }
+ // create current option entry in parsed arguments
+ std::vector<std::string>& currentOptionArguments =
+ parsedArguments[currentOption];
- return true;
+ // collect option arguments while we won't find another expected option
+ while (i < args.size() && !isExpectedOption(args[i], expectedOptions)) {
+ currentOptionArguments.push_back(args[i++]);
+ }
}
+}
- std::string delimiter = "\\";
- if (this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER")) {
- delimiter = this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER");
- }
+} // namespace
- std::vector<std::string> folders =
- cmSystemTools::tokenize(args[0], delimiter);
+static bool checkArgumentsPreconditions(const ParsedArguments& parsedArguments,
+ std::string& errorMsg);
- cmSourceGroup* sg = CM_NULLPTR;
- sg = this->Makefile->GetSourceGroup(folders);
- if (!sg) {
- this->Makefile->AddSourceGroup(folders);
- sg = this->Makefile->GetSourceGroup(folders);
- }
+static bool processTree(cmMakefile& mf, ParsedArguments& parsedArguments,
+ std::string& errorMsg);
- if (!sg) {
- this->SetError("Could not create or find source group");
+static bool checkSingleParameterArgumentPreconditions(
+ const std::string& argument, const ParsedArguments& parsedArguments,
+ std::string& errorMsg);
+
+bool cmSourceGroupCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.empty()) {
+ status.SetError("called with incorrect number of arguments");
return false;
}
+
+ cmMakefile& mf = status.GetMakefile();
+
// If only two arguments are given, the pre-1.8 version of the
// command is being invoked.
if (args.size() == 2 && args[1] != "FILES") {
- sg->SetGroupRegex(args[1].c_str());
- return true;
- }
+ cmSourceGroup* sg = mf.GetOrCreateSourceGroup(args[0]);
- // Process arguments.
- bool doingFiles = false;
- for (unsigned int i = 1; i < args.size(); ++i) {
- if (args[i] == "REGULAR_EXPRESSION") {
- // Next argument must specify the regex.
- if (i + 1 < args.size()) {
- ++i;
- sg->SetGroupRegex(args[i].c_str());
- } else {
- this->SetError("REGULAR_EXPRESSION argument given without a regex.");
- return false;
- }
- doingFiles = false;
- } else if (args[i] == "FILES") {
- // Next arguments will specify files.
- doingFiles = true;
- } else if (doingFiles) {
- // Convert name to full path and add to the group's list.
- std::string src = args[i];
- if (!cmSystemTools::FileIsFullPath(src.c_str())) {
- src = this->Makefile->GetCurrentSourceDirectory();
- src += "/";
- src += args[i];
- }
- src = cmSystemTools::CollapseFullPath(src);
- sg->AddGroupFile(src);
- } else {
- std::ostringstream err;
- err << "Unknown argument \"" << args[i] << "\". "
- << "Perhaps the FILES keyword is missing.\n";
- this->SetError(err.str());
+ if (!sg) {
+ status.SetError("Could not create or find source group");
return false;
}
+
+ sg->SetGroupRegex(args[1].c_str());
+ return true;
}
- return true;
-}
+ ParsedArguments parsedArguments;
+ std::string errorMsg;
-bool cmSourceGroupCommand::checkTreeArgumentsPreconditions(
- const std::vector<std::string>& args, std::string& errorMsg) const
-{
- if (args.size() == 1) {
- errorMsg = "TREE argument given without a root.";
- return false;
- }
+ parseArguments(args, parsedArguments);
- if (args.size() < 3) {
- errorMsg = "Missing FILES arguments.";
+ if (!checkArgumentsPreconditions(parsedArguments, errorMsg)) {
return false;
}
- if (args[FilesWithoutPrefixKeywordIndex] != "FILES" &&
- args[PrefixKeywordIndex] != "PREFIX") {
- errorMsg = "Unknown argument \"" + args[2] +
- "\". Perhaps the FILES keyword is missing.\n";
- return false;
- }
+ if (parsedArguments.find(kTreeOptionName) != parsedArguments.end()) {
+ if (!processTree(mf, parsedArguments, errorMsg)) {
+ status.SetError(errorMsg);
+ return false;
+ }
+ } else {
+ if (parsedArguments.find(kSourceGroupOptionName) ==
+ parsedArguments.end()) {
+ status.SetError("Missing source group name.");
+ return false;
+ }
- if (args[PrefixKeywordIndex] == "PREFIX" &&
- (args.size() < 5 || args[FilesWithPrefixKeywordIndex] != "FILES")) {
- errorMsg = "Missing FILES arguments.";
- return false;
+ cmSourceGroup* sg = mf.GetOrCreateSourceGroup(args[0]);
+
+ if (!sg) {
+ status.SetError("Could not create or find source group");
+ return false;
+ }
+
+ // handle regex
+ if (parsedArguments.find(kRegexOptionName) != parsedArguments.end()) {
+ const std::string& sgRegex = parsedArguments[kRegexOptionName].front();
+ sg->SetGroupRegex(sgRegex.c_str());
+ }
+
+ // handle files
+ const std::vector<std::string>& filesArguments =
+ parsedArguments[kFilesOptionName];
+ for (auto const& filesArg : filesArguments) {
+ std::string src = filesArg;
+ if (!cmSystemTools::FileIsFullPath(src)) {
+ src = cmStrCat(mf.GetCurrentSourceDirectory(), '/', filesArg);
+ }
+ src = cmSystemTools::CollapseFullPath(src);
+ sg->AddGroupFile(src);
+ }
}
return true;
}
-bool cmSourceGroupCommand::processTree(const std::vector<std::string>& args,
- std::string& errorMsg)
+static bool checkArgumentsPreconditions(const ParsedArguments& parsedArguments,
+ std::string& errorMsg)
{
- if (!checkTreeArgumentsPreconditions(args, errorMsg)) {
- return false;
- }
+ return checkSingleParameterArgumentPreconditions(
+ kPrefixOptionName, parsedArguments, errorMsg) &&
+ checkSingleParameterArgumentPreconditions(kTreeOptionName, parsedArguments,
+ errorMsg) &&
+ checkSingleParameterArgumentPreconditions(kRegexOptionName,
+ parsedArguments, errorMsg);
+}
- const std::string root = cmSystemTools::CollapseFullPath(args[RootIndex]);
- std::string prefix;
- size_t filesBegin = FilesWithoutPrefixKeywordIndex + 1;
- if (args[PrefixKeywordIndex] == "PREFIX") {
- prefix = args[PrefixKeywordIndex + 1];
- filesBegin = FilesWithPrefixKeywordIndex + 1;
- }
+static bool processTree(cmMakefile& mf, ParsedArguments& parsedArguments,
+ std::string& errorMsg)
+{
+ const std::string root =
+ cmSystemTools::CollapseFullPath(parsedArguments[kTreeOptionName].front());
+ std::string prefix = parsedArguments[kPrefixOptionName].empty()
+ ? ""
+ : parsedArguments[kPrefixOptionName].front();
- const std::vector<std::string> filesVector =
- prepareFilesPathsForTree(args.begin() + filesBegin, args.end(),
- this->Makefile->GetCurrentSourceDirectory());
+ const std::vector<std::string> filesVector = prepareFilesPathsForTree(
+ parsedArguments[kFilesOptionName], mf.GetCurrentSourceDirectory());
if (!rootIsPrefix(root, filesVector, errorMsg)) {
return false;
@@ -277,9 +296,26 @@ bool cmSourceGroupCommand::processTree(const std::vector<std::string>& args,
std::set<std::string> sourceGroupPaths =
getSourceGroupFilesPaths(root, filesVector);
- if (!addFilesToItsSourceGroups(root, sourceGroupPaths, prefix,
- *(this->Makefile), errorMsg)) {
- return false;
+ return addFilesToItsSourceGroups(root, sourceGroupPaths, prefix, mf,
+ errorMsg);
+}
+
+static bool checkSingleParameterArgumentPreconditions(
+ const std::string& argument, const ParsedArguments& parsedArguments,
+ std::string& errorMsg)
+{
+ auto foundArgument = parsedArguments.find(argument);
+ if (foundArgument != parsedArguments.end()) {
+ const std::vector<std::string>& optionArguments = foundArgument->second;
+
+ if (optionArguments.empty()) {
+ errorMsg = argument + " argument given without an argument.";
+ return false;
+ }
+ if (optionArguments.size() > 1) {
+ errorMsg = "too many arguments passed to " + argument + ".";
+ return false;
+ }
}
return true;
diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h
index 7d56b0d65..ad3970157 100644
--- a/Source/cmSourceGroupCommand.h
+++ b/Source/cmSourceGroupCommand.h
@@ -3,41 +3,14 @@
#ifndef cmSourceGroupCommand_h
#define cmSourceGroupCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmSourceGroupCommand
- * \brief Adds a cmSourceGroup to the cmMakefile.
- *
- * cmSourceGroupCommand is used to define cmSourceGroups which split up
- * source files in to named, organized groups in the generated makefiles.
- */
-class cmSourceGroupCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmSourceGroupCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- bool processTree(const std::vector<std::string>& args,
- std::string& errorMsg);
- bool checkTreeArgumentsPreconditions(const std::vector<std::string>& args,
- std::string& errorMsg) const;
-};
+bool cmSourceGroupCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmStandardLexer.h b/Source/cmStandardLexer.h
index c9f42e4ce..13f7622a7 100644
--- a/Source/cmStandardLexer.h
+++ b/Source/cmStandardLexer.h
@@ -3,45 +3,45 @@
#ifndef cmStandardLexer_h
#define cmStandardLexer_h
-#include "cmConfigure.h" // IWYU pragma: keep
+#include "cmsys/Configure.h" // IWYU pragma: keep
/* Disable some warnings. */
#if defined(_MSC_VER)
-#pragma warning(disable : 4018)
-#pragma warning(disable : 4127)
-#pragma warning(disable : 4131)
-#pragma warning(disable : 4244)
-#pragma warning(disable : 4251)
-#pragma warning(disable : 4267)
-#pragma warning(disable : 4305)
-#pragma warning(disable : 4309)
-#pragma warning(disable : 4706)
-#pragma warning(disable : 4786)
+# pragma warning(disable : 4018)
+# pragma warning(disable : 4127)
+# pragma warning(disable : 4131)
+# pragma warning(disable : 4244)
+# pragma warning(disable : 4251)
+# pragma warning(disable : 4267)
+# pragma warning(disable : 4305)
+# pragma warning(disable : 4309)
+# pragma warning(disable : 4706)
+# pragma warning(disable : 4786)
#endif
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
-#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
-#pragma GCC diagnostic ignored "-Wconversion"
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#endif
-#if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 403
-#pragma GCC diagnostic ignored "-Wsign-conversion"
-#endif
+# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 402
+# pragma GCC diagnostic ignored "-Wconversion"
+# pragma GCC diagnostic ignored "-Wsign-compare"
+# endif
+# if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 403
+# pragma GCC diagnostic ignored "-Wsign-conversion"
+# endif
#endif
/* Make sure isatty is available. */
#if defined(_WIN32) && !defined(__CYGWIN__)
-#include <io.h>
-#if defined(_MSC_VER)
-#define isatty _isatty
-#endif
+# include <io.h>
+# if defined(_MSC_VER)
+# define isatty _isatty
+# endif
#else
-#include <unistd.h> // IWYU pragma: export
+# include <unistd.h> // IWYU pragma: export
#endif
/* Make sure malloc and free are available on QNX. */
#ifdef __QNX__
-#include <malloc.h>
+# include <malloc.h>
#endif
/* Disable features we do not need. */
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 92e47f748..f9b5ed1c0 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -2,43 +2,37 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmState.h"
-#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
-#include <string.h>
+#include <cassert>
+#include <cstdlib>
+#include <cstring>
#include <utility>
-#include "cmAlgorithms.h"
+#include <cm/memory>
+
+#include "cmsys/RegularExpression.hxx"
+
#include "cmCacheManager.h"
#include "cmCommand.h"
#include "cmDefinitions.h"
-#include "cmDisallowedCommand.h"
+#include "cmExecutionStatus.h"
+#include "cmGlobVerificationManager.h"
#include "cmListFileCache.h"
+#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmStatePrivate.h"
#include "cmStateSnapshot.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include "cmUnexpectedCommand.h"
#include "cmake.h"
cmState::cmState()
- : IsInTryCompile(false)
- , IsGeneratorMultiConfig(false)
- , WindowsShell(false)
- , WindowsVSIDE(false)
- , WatcomWMake(false)
- , MinGWMake(false)
- , NMake(false)
- , MSYSShell(false)
{
- this->CacheManager = new cmCacheManager;
+ this->CacheManager = cm::make_unique<cmCacheManager>();
+ this->GlobVerificationManager = cm::make_unique<cmGlobVerificationManager>();
}
-cmState::~cmState()
-{
- delete this->CacheManager;
- cmDeleteAll(this->BuiltinCommands);
- cmDeleteAll(this->ScriptedCommands);
-}
+cmState::~cmState() = default;
const char* cmState::GetTargetTypeName(cmStateEnums::TargetType targetType)
{
@@ -63,12 +57,12 @@ const char* cmState::GetTargetTypeName(cmStateEnums::TargetType targetType)
return "UNKNOWN_LIBRARY";
}
assert(false && "Unexpected target type");
- return CM_NULLPTR;
+ return nullptr;
}
const char* cmCacheEntryTypes[] = { "BOOL", "PATH", "FILEPATH",
"STRING", "INTERNAL", "STATIC",
- "UNINITIALIZED", CM_NULLPTR };
+ "UNINITIALIZED", nullptr };
const char* cmState::CacheEntryTypeToString(cmStateEnums::CacheEntryType type)
{
@@ -80,20 +74,29 @@ const char* cmState::CacheEntryTypeToString(cmStateEnums::CacheEntryType type)
cmStateEnums::CacheEntryType cmState::StringToCacheEntryType(const char* s)
{
+ cmStateEnums::CacheEntryType type = cmStateEnums::STRING;
+ StringToCacheEntryType(s, type);
+ return type;
+}
+
+bool cmState::StringToCacheEntryType(const char* s,
+ cmStateEnums::CacheEntryType& type)
+{
int i = 0;
while (cmCacheEntryTypes[i]) {
if (strcmp(s, cmCacheEntryTypes[i]) == 0) {
- return static_cast<cmStateEnums::CacheEntryType>(i);
+ type = static_cast<cmStateEnums::CacheEntryType>(i);
+ return true;
}
++i;
}
- return cmStateEnums::STRING;
+ return false;
}
bool cmState::IsCacheEntryType(std::string const& key)
{
for (int i = 0; cmCacheEntryTypes[i]; ++i) {
- if (strcmp(key.c_str(), cmCacheEntryTypes[i]) == 0) {
+ if (key == cmCacheEntryTypes[i]) {
return true;
}
}
@@ -107,9 +110,9 @@ bool cmState::LoadCache(const std::string& path, bool internal,
return this->CacheManager->LoadCache(path, internal, excludes, includes);
}
-bool cmState::SaveCache(const std::string& path)
+bool cmState::SaveCache(const std::string& path, cmMessenger* messenger)
{
- return this->CacheManager->SaveCache(path);
+ return this->CacheManager->SaveCache(path, messenger);
}
bool cmState::DeleteCache(const std::string& path)
@@ -132,12 +135,13 @@ const char* cmState::GetCacheEntryValue(std::string const& key) const
{
cmCacheManager::CacheEntry* e = this->CacheManager->GetCacheEntry(key);
if (!e) {
- return CM_NULLPTR;
+ return nullptr;
}
return e->Value.c_str();
}
-const char* cmState::GetInitializedCacheValue(std::string const& key) const
+const std::string* cmState::GetInitializedCacheValue(
+ std::string const& key) const
{
return this->CacheManager->GetInitializedCacheValue(key);
}
@@ -188,7 +192,7 @@ const char* cmState::GetCacheEntryProperty(std::string const& key,
cmCacheManager::CacheIterator it =
this->CacheManager->GetCacheIterator(key.c_str());
if (!it.PropertyExists(propertyName)) {
- return CM_NULLPTR;
+ return nullptr;
}
return it.GetProperty(propertyName);
}
@@ -207,6 +211,39 @@ void cmState::AddCacheEntry(const std::string& key, const char* value,
this->CacheManager->AddCacheEntry(key, value, helpString, type);
}
+bool cmState::DoWriteGlobVerifyTarget() const
+{
+ return this->GlobVerificationManager->DoWriteVerifyTarget();
+}
+
+std::string const& cmState::GetGlobVerifyScript() const
+{
+ return this->GlobVerificationManager->GetVerifyScript();
+}
+
+std::string const& cmState::GetGlobVerifyStamp() const
+{
+ return this->GlobVerificationManager->GetVerifyStamp();
+}
+
+bool cmState::SaveVerificationScript(const std::string& path)
+{
+ return this->GlobVerificationManager->SaveVerificationScript(path);
+}
+
+void cmState::AddGlobCacheEntry(bool recurse, bool listDirectories,
+ bool followSymlinks,
+ const std::string& relative,
+ const std::string& expression,
+ const std::vector<std::string>& files,
+ const std::string& variable,
+ cmListFileBacktrace const& backtrace)
+{
+ this->GlobVerificationManager->AddCacheEntry(
+ recurse, listDirectories, followSymlinks, relative, expression, files,
+ variable, backtrace);
+}
+
void cmState::RemoveCacheEntry(std::string const& key)
{
this->CacheManager->RemoveCacheEntry(key);
@@ -224,13 +261,14 @@ void cmState::RemoveCacheEntryProperty(std::string const& key,
std::string const& propertyName)
{
this->CacheManager->GetCacheIterator(key.c_str())
- .SetProperty(propertyName, (void*)CM_NULLPTR);
+ .SetProperty(propertyName, nullptr);
}
cmStateSnapshot cmState::Reset()
{
- this->GlobalProperties.clear();
+ this->GlobalProperties.Clear();
this->PropertyDefinitions.clear();
+ this->GlobVerificationManager->Reset();
cmStateDetail::PositionType pos = this->SnapshotData.Truncate();
this->ExecutionListFiles.Truncate();
@@ -244,9 +282,13 @@ cmStateSnapshot cmState::Reset()
it->CompileDefinitionsBacktraces.clear();
it->CompileOptions.clear();
it->CompileOptionsBacktraces.clear();
+ it->LinkOptions.clear();
+ it->LinkOptionsBacktraces.clear();
+ it->LinkDirectories.clear();
+ it->LinkDirectoriesBacktraces.clear();
it->DirectoryEnd = pos;
it->NormalTargetNames.clear();
- it->Properties.clear();
+ it->Properties.Clear();
it->Children.clear();
}
@@ -259,16 +301,16 @@ cmStateSnapshot cmState::Reset()
{
std::string srcDir =
- cmDefinitions::Get("CMAKE_SOURCE_DIR", pos->Vars, pos->Root);
+ *cmDefinitions::Get("CMAKE_SOURCE_DIR", pos->Vars, pos->Root);
std::string binDir =
- cmDefinitions::Get("CMAKE_BINARY_DIR", pos->Vars, pos->Root);
+ *cmDefinitions::Get("CMAKE_BINARY_DIR", pos->Vars, pos->Root);
this->VarTree.Clear();
pos->Vars = this->VarTree.Push(this->VarTree.Root());
pos->Parent = this->VarTree.Root();
pos->Root = this->VarTree.Root();
- pos->Vars->Set("CMAKE_SOURCE_DIR", srcDir.c_str());
- pos->Vars->Set("CMAKE_BINARY_DIR", binDir.c_str());
+ pos->Vars->Set("CMAKE_SOURCE_DIR", srcDir);
+ pos->Vars->Set("CMAKE_BINARY_DIR", binDir);
}
this->DefineProperty("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, "", "",
@@ -283,7 +325,7 @@ cmStateSnapshot cmState::Reset()
this->DefineProperty("RULE_LAUNCH_LINK", cmProperty::TARGET, "", "", true);
this->DefineProperty("RULE_LAUNCH_CUSTOM", cmProperty::TARGET, "", "", true);
- return cmStateSnapshot(this, pos);
+ return { this, pos };
}
void cmState::DefineProperty(const std::string& name,
@@ -303,14 +345,13 @@ cmPropertyDefinition const* cmState::GetPropertyDefinition(
this->PropertyDefinitions.find(scope)->second;
return &defs.find(name)->second;
}
- return CM_NULLPTR;
+ return nullptr;
}
bool cmState::IsPropertyDefined(const std::string& name,
cmProperty::ScopeType scope) const
{
- std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::const_iterator it =
- this->PropertyDefinitions.find(scope);
+ auto it = this->PropertyDefinitions.find(scope);
if (it == this->PropertyDefinitions.end()) {
return false;
}
@@ -320,8 +361,7 @@ bool cmState::IsPropertyDefined(const std::string& name,
bool cmState::IsPropertyChained(const std::string& name,
cmProperty::ScopeType scope) const
{
- std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>::const_iterator it =
- this->PropertyDefinitions.find(scope);
+ auto it = this->PropertyDefinitions.find(scope);
if (it == this->PropertyDefinitions.end()) {
return false;
}
@@ -330,8 +370,8 @@ bool cmState::IsPropertyChained(const std::string& name,
void cmState::SetLanguageEnabled(std::string const& l)
{
- std::vector<std::string>::iterator it = std::lower_bound(
- this->EnabledLanguages.begin(), this->EnabledLanguages.end(), l);
+ auto it = std::lower_bound(this->EnabledLanguages.begin(),
+ this->EnabledLanguages.end(), l);
if (it == this->EnabledLanguages.end() || *it != l) {
this->EnabledLanguages.insert(it, l);
}
@@ -378,65 +418,115 @@ void cmState::SetIsGeneratorMultiConfig(bool b)
this->IsGeneratorMultiConfig = b;
}
-void cmState::AddBuiltinCommand(std::string const& name, cmCommand* command)
+void cmState::AddBuiltinCommand(std::string const& name,
+ std::unique_ptr<cmCommand> command)
+{
+ this->AddBuiltinCommand(name, cmLegacyCommandWrapper(std::move(command)));
+}
+
+void cmState::AddBuiltinCommand(std::string const& name, Command command)
{
assert(name == cmSystemTools::LowerCase(name));
assert(this->BuiltinCommands.find(name) == this->BuiltinCommands.end());
- this->BuiltinCommands.insert(std::make_pair(name, command));
+ this->BuiltinCommands.emplace(name, std::move(command));
+}
+
+static bool InvokeBuiltinCommand(cmState::BuiltinCommand command,
+ std::vector<cmListFileArgument> const& args,
+ cmExecutionStatus& status)
+{
+ cmMakefile& mf = status.GetMakefile();
+ std::vector<std::string> expandedArguments;
+ if (!mf.ExpandArguments(args, expandedArguments)) {
+ // There was an error expanding arguments. It was already
+ // reported, so we can skip this command without error.
+ return true;
+ }
+ return command(expandedArguments, status);
+}
+
+void cmState::AddBuiltinCommand(std::string const& name,
+ BuiltinCommand command)
+{
+ this->AddBuiltinCommand(
+ name,
+ [command](const std::vector<cmListFileArgument>& args,
+ cmExecutionStatus& status) -> bool {
+ return InvokeBuiltinCommand(command, args, status);
+ });
}
-void cmState::AddDisallowedCommand(std::string const& name, cmCommand* command,
+void cmState::AddDisallowedCommand(std::string const& name,
+ BuiltinCommand command,
cmPolicies::PolicyID policy,
const char* message)
{
- this->AddBuiltinCommand(name,
- new cmDisallowedCommand(command, policy, message));
+ this->AddBuiltinCommand(
+ name,
+ [command, policy, message](const std::vector<cmListFileArgument>& args,
+ cmExecutionStatus& status) -> bool {
+ cmMakefile& mf = status.GetMakefile();
+ switch (mf.GetPolicyStatus(policy)) {
+ case cmPolicies::WARN:
+ mf.IssueMessage(MessageType::AUTHOR_WARNING,
+ cmPolicies::GetPolicyWarning(policy));
+ break;
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ mf.IssueMessage(MessageType::FATAL_ERROR, message);
+ return true;
+ }
+ return InvokeBuiltinCommand(command, args, status);
+ });
}
void cmState::AddUnexpectedCommand(std::string const& name, const char* error)
{
- this->AddBuiltinCommand(name, new cmUnexpectedCommand(name, error));
+ this->AddBuiltinCommand(
+ name,
+ [name, error](std::vector<cmListFileArgument> const&,
+ cmExecutionStatus& status) -> bool {
+ const char* versionValue =
+ status.GetMakefile().GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
+ if (name == "endif" && (!versionValue || atof(versionValue) <= 1.4)) {
+ return true;
+ }
+ status.SetError(error);
+ return false;
+ });
}
-void cmState::AddScriptedCommand(std::string const& name, cmCommand* command)
+void cmState::AddScriptedCommand(std::string const& name, Command command)
{
std::string sName = cmSystemTools::LowerCase(name);
// if the command already exists, give a new name to the old command.
- if (cmCommand* oldCmd = this->GetCommand(sName)) {
- std::string const newName = "_" + sName;
- std::map<std::string, cmCommand*>::iterator pos =
- this->ScriptedCommands.find(newName);
- if (pos != this->ScriptedCommands.end()) {
- delete pos->second;
- this->ScriptedCommands.erase(pos);
- }
- this->ScriptedCommands.insert(std::make_pair(newName, oldCmd->Clone()));
+ if (Command oldCmd = this->GetCommandByExactName(sName)) {
+ this->ScriptedCommands["_" + sName] = oldCmd;
}
- // if the command already exists, free the old one
- std::map<std::string, cmCommand*>::iterator pos =
- this->ScriptedCommands.find(sName);
- if (pos != this->ScriptedCommands.end()) {
- delete pos->second;
- this->ScriptedCommands.erase(pos);
- }
- this->ScriptedCommands.insert(std::make_pair(sName, command));
+ this->ScriptedCommands[sName] = std::move(command);
}
-cmCommand* cmState::GetCommand(std::string const& name) const
+cmState::Command cmState::GetCommand(std::string const& name) const
{
- std::string sName = cmSystemTools::LowerCase(name);
- std::map<std::string, cmCommand*>::const_iterator pos;
- pos = this->ScriptedCommands.find(sName);
+ return GetCommandByExactName(cmSystemTools::LowerCase(name));
+}
+
+cmState::Command cmState::GetCommandByExactName(std::string const& name) const
+{
+ auto pos = this->ScriptedCommands.find(name);
if (pos != this->ScriptedCommands.end()) {
return pos->second;
}
- pos = this->BuiltinCommands.find(sName);
+ pos = this->BuiltinCommands.find(name);
if (pos != this->BuiltinCommands.end()) {
return pos->second;
}
- return CM_NULLPTR;
+ return nullptr;
}
std::vector<std::string> cmState::GetCommandNames() const
@@ -444,15 +534,11 @@ std::vector<std::string> cmState::GetCommandNames() const
std::vector<std::string> commandNames;
commandNames.reserve(this->BuiltinCommands.size() +
this->ScriptedCommands.size());
- for (std::map<std::string, cmCommand*>::const_iterator cmds =
- this->BuiltinCommands.begin();
- cmds != this->BuiltinCommands.end(); ++cmds) {
- commandNames.push_back(cmds->first);
+ for (auto const& bc : this->BuiltinCommands) {
+ commandNames.push_back(bc.first);
}
- for (std::map<std::string, cmCommand*>::const_iterator cmds =
- this->ScriptedCommands.begin();
- cmds != this->ScriptedCommands.end(); ++cmds) {
- commandNames.push_back(cmds->first);
+ for (auto const& sc : this->ScriptedCommands) {
+ commandNames.push_back(sc.first);
}
std::sort(commandNames.begin(), commandNames.end());
commandNames.erase(std::unique(commandNames.begin(), commandNames.end()),
@@ -460,9 +546,14 @@ std::vector<std::string> cmState::GetCommandNames() const
return commandNames;
}
+void cmState::RemoveBuiltinCommand(std::string const& name)
+{
+ assert(name == cmSystemTools::LowerCase(name));
+ this->BuiltinCommands.erase(name);
+}
+
void cmState::RemoveUserDefinedCommands()
{
- cmDeleteAll(this->ScriptedCommands);
this->ScriptedCommands.clear();
}
@@ -495,21 +586,43 @@ const char* cmState::GetGlobalProperty(const std::string& prop)
std::string langs;
langs = cmJoin(this->EnabledLanguages, ";");
this->SetGlobalProperty("ENABLED_LANGUAGES", langs.c_str());
+ } else if (prop == "CMAKE_ROLE") {
+ std::string mode = this->GetModeString();
+ this->SetGlobalProperty("CMAKE_ROLE", mode.c_str());
}
#define STRING_LIST_ELEMENT(F) ";" #F
if (prop == "CMAKE_C_KNOWN_FEATURES") {
- return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1;
+ return &FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT)[1];
+ }
+ if (prop == "CMAKE_C90_KNOWN_FEATURES") {
+ return &FOR_EACH_C90_FEATURE(STRING_LIST_ELEMENT)[1];
+ }
+ if (prop == "CMAKE_C99_KNOWN_FEATURES") {
+ return &FOR_EACH_C99_FEATURE(STRING_LIST_ELEMENT)[1];
+ }
+ if (prop == "CMAKE_C11_KNOWN_FEATURES") {
+ return &FOR_EACH_C11_FEATURE(STRING_LIST_ELEMENT)[1];
}
if (prop == "CMAKE_CXX_KNOWN_FEATURES") {
- return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
+ return &FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT)[1];
+ }
+ if (prop == "CMAKE_CXX98_KNOWN_FEATURES") {
+ return &FOR_EACH_CXX98_FEATURE(STRING_LIST_ELEMENT)[1];
}
+ if (prop == "CMAKE_CXX11_KNOWN_FEATURES") {
+ return &FOR_EACH_CXX11_FEATURE(STRING_LIST_ELEMENT)[1];
+ }
+ if (prop == "CMAKE_CXX14_KNOWN_FEATURES") {
+ return &FOR_EACH_CXX14_FEATURE(STRING_LIST_ELEMENT)[1];
+ }
+
#undef STRING_LIST_ELEMENT
return this->GlobalProperties.GetPropertyValue(prop);
}
bool cmState::GetGlobalPropertyAsBool(const std::string& prop)
{
- return cmSystemTools::IsOn(this->GetGlobalProperty(prop));
+ return cmIsOn(this->GetGlobalProperty(prop));
}
void cmState::SetSourceDirectory(std::string const& sourceDirectory)
@@ -518,9 +631,9 @@ void cmState::SetSourceDirectory(std::string const& sourceDirectory)
cmSystemTools::ConvertToUnixSlashes(this->SourceDirectory);
}
-const char* cmState::GetSourceDirectory() const
+std::string const& cmState::GetSourceDirectory() const
{
- return this->SourceDirectory.c_str();
+ return this->SourceDirectory;
}
void cmState::SetBinaryDirectory(std::string const& binaryDirectory)
@@ -549,6 +662,16 @@ bool cmState::UseWindowsVSIDE() const
return this->WindowsVSIDE;
}
+void cmState::SetGhsMultiIDE(bool ghsMultiIDE)
+{
+ this->GhsMultiIDE = ghsMultiIDE;
+}
+
+bool cmState::UseGhsMultiIDE() const
+{
+ return this->GhsMultiIDE;
+}
+
void cmState::SetWatcomWMake(bool watcomWMake)
{
this->WatcomWMake = watcomWMake;
@@ -599,9 +722,43 @@ unsigned int cmState::GetCacheMinorVersion() const
return this->CacheManager->GetCacheMinorVersion();
}
-const char* cmState::GetBinaryDirectory() const
+cmState::Mode cmState::GetMode() const
+{
+ return this->CurrentMode;
+}
+
+std::string cmState::GetModeString() const
+{
+ return ModeToString(this->CurrentMode);
+}
+
+void cmState::SetMode(cmState::Mode mode)
+{
+ this->CurrentMode = mode;
+}
+
+std::string cmState::ModeToString(cmState::Mode mode)
+{
+ switch (mode) {
+ case Project:
+ return "PROJECT";
+ case Script:
+ return "SCRIPT";
+ case FindPackage:
+ return "FIND_PACKAGE";
+ case CTest:
+ return "CTEST";
+ case CPack:
+ return "CPACK";
+ case Unknown:
+ return "UNKNOWN";
+ }
+ return "UNKNOWN";
+}
+
+std::string const& cmState::GetBinaryDirectory() const
{
- return this->BinaryDirectory.c_str();
+ return this->BinaryDirectory;
}
cmStateSnapshot cmState::CreateBaseSnapshot()
@@ -619,6 +776,8 @@ cmStateSnapshot cmState::CreateBaseSnapshot()
pos->IncludeDirectoryPosition = 0;
pos->CompileDefinitionsPosition = 0;
pos->CompileOptionsPosition = 0;
+ pos->LinkOptionsPosition = 0;
+ pos->LinkDirectoriesPosition = 0;
pos->BuildSystemDirectory->DirectoryEnd = pos;
pos->Policies = this->PolicyStack.Root();
pos->PolicyRoot = this->PolicyStack.Root();
@@ -629,7 +788,7 @@ cmStateSnapshot cmState::CreateBaseSnapshot()
assert(pos->Vars.IsValid());
pos->Parent = this->VarTree.Root();
pos->Root = this->VarTree.Root();
- return cmStateSnapshot(this, pos);
+ return { this, pos };
}
cmStateSnapshot cmState::CreateBuildsystemDirectorySnapshot(
@@ -682,7 +841,7 @@ cmStateSnapshot cmState::CreateFunctionCallSnapshot(
cmLinkedTree<cmDefinitions>::iterator origin = originSnapshot.Position->Vars;
pos->Parent = origin;
pos->Vars = this->VarTree.Push(origin);
- return cmStateSnapshot(this, pos);
+ return { this, pos };
}
cmStateSnapshot cmState::CreateMacroCallSnapshot(
@@ -697,7 +856,7 @@ cmStateSnapshot cmState::CreateMacroCallSnapshot(
assert(originSnapshot.Position->Vars.IsValid());
pos->BuildSystemDirectory->DirectoryEnd = pos;
pos->PolicyScope = originSnapshot.Position->Policies;
- return cmStateSnapshot(this, pos);
+ return { this, pos };
}
cmStateSnapshot cmState::CreateIncludeFileSnapshot(
@@ -712,7 +871,7 @@ cmStateSnapshot cmState::CreateIncludeFileSnapshot(
assert(originSnapshot.Position->Vars.IsValid());
pos->BuildSystemDirectory->DirectoryEnd = pos;
pos->PolicyScope = originSnapshot.Position->Policies;
- return cmStateSnapshot(this, pos);
+ return { this, pos };
}
cmStateSnapshot cmState::CreateVariableScopeSnapshot(
@@ -730,7 +889,7 @@ cmStateSnapshot cmState::CreateVariableScopeSnapshot(
pos->Parent = origin;
pos->Vars = this->VarTree.Push(origin);
assert(pos->Vars.IsValid());
- return cmStateSnapshot(this, pos);
+ return { this, pos };
}
cmStateSnapshot cmState::CreateInlineListFileSnapshot(
@@ -744,7 +903,7 @@ cmStateSnapshot cmState::CreateInlineListFileSnapshot(
originSnapshot.Position->ExecutionListFile, fileName);
pos->BuildSystemDirectory->DirectoryEnd = pos;
pos->PolicyScope = originSnapshot.Position->Policies;
- return cmStateSnapshot(this, pos);
+ return { this, pos };
}
cmStateSnapshot cmState::CreatePolicyScopeSnapshot(
@@ -756,7 +915,7 @@ cmStateSnapshot cmState::CreatePolicyScopeSnapshot(
pos->Keep = false;
pos->BuildSystemDirectory->DirectoryEnd = pos;
pos->PolicyScope = originSnapshot.Position->Policies;
- return cmStateSnapshot(this, pos);
+ return { this, pos };
}
cmStateSnapshot cmState::Pop(cmStateSnapshot const& originSnapshot)
@@ -770,6 +929,10 @@ cmStateSnapshot cmState::Pop(cmStateSnapshot const& originSnapshot)
prevPos->BuildSystemDirectory->CompileDefinitions.size();
prevPos->CompileOptionsPosition =
prevPos->BuildSystemDirectory->CompileOptions.size();
+ prevPos->LinkOptionsPosition =
+ prevPos->BuildSystemDirectory->LinkOptions.size();
+ prevPos->LinkDirectoriesPosition =
+ prevPos->BuildSystemDirectory->LinkDirectories.size();
prevPos->BuildSystemDirectory->DirectoryEnd = prevPos;
if (!pos->Keep && this->SnapshotData.IsLast(pos)) {
@@ -784,7 +947,7 @@ cmStateSnapshot cmState::Pop(cmStateSnapshot const& originSnapshot)
this->SnapshotData.Pop(pos);
}
- return cmStateSnapshot(this, prevPos);
+ return { this, prevPos };
}
static bool ParseEntryWithoutType(const std::string& entry, std::string& var,
@@ -809,8 +972,8 @@ static bool ParseEntryWithoutType(const std::string& entry, std::string& var,
// if value is enclosed in single quotes ('foo') then remove them
// it is used to enclose trailing space or tab
- if (flag && value.size() >= 2 && value[0] == '\'' &&
- value[value.size() - 1] == '\'') {
+ if (flag && value.size() >= 2 && value.front() == '\'' &&
+ value.back() == '\'') {
value = value.substr(1, value.size() - 2);
}
@@ -842,8 +1005,8 @@ bool cmState::ParseCacheEntry(const std::string& entry, std::string& var,
// if value is enclosed in single quotes ('foo') then remove them
// it is used to enclose trailing space or tab
- if (flag && value.size() >= 2 && value[0] == '\'' &&
- value[value.size() - 1] == '\'') {
+ if (flag && value.size() >= 2 && value.front() == '\'' &&
+ value.back() == '\'') {
value = value.substr(1, value.size() - 2);
}
diff --git a/Source/cmState.h b/Source/cmState.h
index e03ad8981..a7ca015c1 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -5,13 +5,16 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <functional>
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <vector>
#include "cmDefinitions.h"
#include "cmLinkedTree.h"
+#include "cmListFileCache.h"
#include "cmPolicies.h"
#include "cmProperty.h"
#include "cmPropertyDefinitionMap.h"
@@ -21,8 +24,11 @@
class cmCacheManager;
class cmCommand;
+class cmGlobVerificationManager;
class cmPropertyDefinition;
class cmStateSnapshot;
+class cmMessenger;
+class cmExecutionStatus;
class cmState
{
@@ -32,6 +38,19 @@ public:
cmState();
~cmState();
+ cmState(const cmState&) = delete;
+ cmState& operator=(const cmState&) = delete;
+
+ enum Mode
+ {
+ Unknown,
+ Project,
+ Script,
+ FindPackage,
+ CTest,
+ CPack,
+ };
+
static const char* GetTargetTypeName(cmStateEnums::TargetType targetType);
cmStateSnapshot CreateBaseSnapshot();
@@ -52,6 +71,8 @@ public:
cmStateSnapshot Pop(cmStateSnapshot const& originSnapshot);
static cmStateEnums::CacheEntryType StringToCacheEntryType(const char*);
+ static bool StringToCacheEntryType(const char*,
+ cmStateEnums::CacheEntryType& type);
static const char* CacheEntryTypeToString(cmStateEnums::CacheEntryType);
static bool IsCacheEntryType(std::string const& key);
@@ -59,13 +80,13 @@ public:
std::set<std::string>& excludes,
std::set<std::string>& includes);
- bool SaveCache(const std::string& path);
+ bool SaveCache(const std::string& path, cmMessenger* messenger);
bool DeleteCache(const std::string& path);
std::vector<std::string> GetCacheEntryKeys() const;
const char* GetCacheEntryValue(std::string const& key) const;
- const char* GetInitializedCacheValue(std::string const& key) const;
+ const std::string* GetInitializedCacheValue(std::string const& key) const;
cmStateEnums::CacheEntryType GetCacheEntryType(std::string const& key) const;
void SetCacheEntryValue(std::string const& key, std::string const& value);
void SetCacheValue(std::string const& key, std::string const& value);
@@ -89,7 +110,7 @@ public:
void RemoveCacheEntryProperty(std::string const& key,
std::string const& propertyName);
- ///! Break up a line like VAR:type="value" into var, type and value
+ //! Break up a line like VAR:type="value" into var, type and value
static bool ParseCacheEntry(const std::string& entry, std::string& var,
std::string& value,
cmStateEnums::CacheEntryType& type);
@@ -122,12 +143,25 @@ public:
bool GetIsGeneratorMultiConfig() const;
void SetIsGeneratorMultiConfig(bool b);
- cmCommand* GetCommand(std::string const& name) const;
- void AddBuiltinCommand(std::string const& name, cmCommand* command);
- void AddDisallowedCommand(std::string const& name, cmCommand* command,
+ using Command = std::function<bool(std::vector<cmListFileArgument> const&,
+ cmExecutionStatus&)>;
+ using BuiltinCommand = bool (*)(std::vector<std::string> const&,
+ cmExecutionStatus&);
+
+ // Returns a command from its name, case insensitive, or nullptr
+ Command GetCommand(std::string const& name) const;
+ // Returns a command from its name, or nullptr
+ Command GetCommandByExactName(std::string const& name) const;
+
+ void AddBuiltinCommand(std::string const& name,
+ std::unique_ptr<cmCommand> command);
+ void AddBuiltinCommand(std::string const& name, Command command);
+ void AddBuiltinCommand(std::string const& name, BuiltinCommand command);
+ void AddDisallowedCommand(std::string const& name, BuiltinCommand command,
cmPolicies::PolicyID policy, const char* message);
void AddUnexpectedCommand(std::string const& name, const char* error);
- void AddScriptedCommand(std::string const& name, cmCommand* command);
+ void AddScriptedCommand(std::string const& name, Command command);
+ void RemoveBuiltinCommand(std::string const& name);
void RemoveUserDefinedCommands();
std::vector<std::string> GetCommandNames() const;
@@ -137,15 +171,17 @@ public:
const char* GetGlobalProperty(const std::string& prop);
bool GetGlobalPropertyAsBool(const std::string& prop);
- const char* GetSourceDirectory() const;
+ std::string const& GetSourceDirectory() const;
void SetSourceDirectory(std::string const& sourceDirectory);
- const char* GetBinaryDirectory() const;
+ std::string const& GetBinaryDirectory() const;
void SetBinaryDirectory(std::string const& binaryDirectory);
void SetWindowsShell(bool windowsShell);
bool UseWindowsShell() const;
void SetWindowsVSIDE(bool windowsVSIDE);
bool UseWindowsVSIDE() const;
+ void SetGhsMultiIDE(bool ghsMultiIDE);
+ bool UseGhsMultiIDE() const;
void SetWatcomWMake(bool watcomWMake);
bool UseWatcomWMake() const;
void SetMinGWMake(bool minGWMake);
@@ -158,18 +194,36 @@ public:
unsigned int GetCacheMajorVersion() const;
unsigned int GetCacheMinorVersion() const;
+ Mode GetMode() const;
+ std::string GetModeString() const;
+ void SetMode(Mode mode);
+
+ static std::string ModeToString(Mode mode);
+
private:
friend class cmake;
void AddCacheEntry(const std::string& key, const char* value,
const char* helpString,
cmStateEnums::CacheEntryType type);
+ bool DoWriteGlobVerifyTarget() const;
+ std::string const& GetGlobVerifyScript() const;
+ std::string const& GetGlobVerifyStamp() const;
+ bool SaveVerificationScript(const std::string& path);
+ void AddGlobCacheEntry(bool recurse, bool listDirectories,
+ bool followSymlinks, const std::string& relative,
+ const std::string& expression,
+ const std::vector<std::string>& files,
+ const std::string& variable,
+ cmListFileBacktrace const& bt);
+
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions;
std::vector<std::string> EnabledLanguages;
- std::map<std::string, cmCommand*> BuiltinCommands;
- std::map<std::string, cmCommand*> ScriptedCommands;
+ std::map<std::string, Command> BuiltinCommands;
+ std::map<std::string, Command> ScriptedCommands;
cmPropertyMap GlobalProperties;
- cmCacheManager* CacheManager;
+ std::unique_ptr<cmCacheManager> CacheManager;
+ std::unique_ptr<cmGlobVerificationManager> GlobVerificationManager;
cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>
BuildsystemDirectory;
@@ -182,14 +236,16 @@ private:
std::string SourceDirectory;
std::string BinaryDirectory;
- bool IsInTryCompile;
- bool IsGeneratorMultiConfig;
- bool WindowsShell;
- bool WindowsVSIDE;
- bool WatcomWMake;
- bool MinGWMake;
- bool NMake;
- bool MSYSShell;
+ bool IsInTryCompile = false;
+ bool IsGeneratorMultiConfig = false;
+ bool WindowsShell = false;
+ bool WindowsVSIDE = false;
+ bool GhsMultiIDE = false;
+ bool WatcomWMake = false;
+ bool MinGWMake = false;
+ bool NMake = false;
+ bool MSYSShell = false;
+ Mode CurrentMode = Unknown;
};
#endif
diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx
index 46a185848..1262f53d9 100644
--- a/Source/cmStateDirectory.cxx
+++ b/Source/cmStateDirectory.cxx
@@ -4,13 +4,15 @@
#include "cmStateDirectory.h"
#include <algorithm>
-#include <assert.h>
-#include <iterator>
-#include <map>
-#include <utility>
+#include <cassert>
+#include <vector>
+#include <cm/iterator>
+
+#include "cmAlgorithms.h"
#include "cmProperty.h"
#include "cmPropertyMap.h"
+#include "cmRange.h"
#include "cmState.h"
#include "cmStatePrivate.h"
#include "cmStateTypes.h"
@@ -41,9 +43,8 @@ void cmStateDirectory::ComputeRelativePathTopSource()
std::string result = snapshots.front().GetDirectory().GetCurrentSource();
- for (std::vector<cmStateSnapshot>::const_iterator it = snapshots.begin() + 1;
- it != snapshots.end(); ++it) {
- std::string currentSource = it->GetDirectory().GetCurrentSource();
+ for (cmStateSnapshot const& snp : cmMakeRange(snapshots).advance(1)) {
+ std::string currentSource = snp.GetDirectory().GetCurrentSource();
if (cmSystemTools::IsSubDirectory(result, currentSource)) {
result = currentSource;
}
@@ -67,9 +68,8 @@ void cmStateDirectory::ComputeRelativePathTopBinary()
std::string result = snapshots.front().GetDirectory().GetCurrentBinary();
- for (std::vector<cmStateSnapshot>::const_iterator it = snapshots.begin() + 1;
- it != snapshots.end(); ++it) {
- std::string currentBinary = it->GetDirectory().GetCurrentBinary();
+ for (cmStateSnapshot const& snp : cmMakeRange(snapshots).advance(1)) {
+ std::string currentBinary = snp.GetDirectory().GetCurrentBinary();
if (cmSystemTools::IsSubDirectory(result, currentBinary)) {
result = currentBinary;
}
@@ -81,13 +81,13 @@ void cmStateDirectory::ComputeRelativePathTopBinary()
if (result.size() < 2 || result.substr(0, 2) != "//") {
this->DirectoryState->RelativePathTopBinary = result;
} else {
- this->DirectoryState->RelativePathTopBinary = "";
+ this->DirectoryState->RelativePathTopBinary.clear();
}
}
-const char* cmStateDirectory::GetCurrentSource() const
+std::string const& cmStateDirectory::GetCurrentSource() const
{
- return this->DirectoryState->Location.c_str();
+ return this->DirectoryState->Location;
}
void cmStateDirectory::SetCurrentSource(std::string const& dir)
@@ -102,9 +102,9 @@ void cmStateDirectory::SetCurrentSource(std::string const& dir)
this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc);
}
-const char* cmStateDirectory::GetCurrentBinary() const
+std::string const& cmStateDirectory::GetCurrentBinary() const
{
- return this->DirectoryState->OutputLocation.c_str();
+ return this->DirectoryState->OutputLocation;
}
void cmStateDirectory::SetCurrentBinary(std::string const& dir)
@@ -119,14 +119,14 @@ void cmStateDirectory::SetCurrentBinary(std::string const& dir)
this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc);
}
-const char* cmStateDirectory::GetRelativePathTopSource() const
+std::string const& cmStateDirectory::GetRelativePathTopSource() const
{
- return this->DirectoryState->RelativePathTopSource.c_str();
+ return this->DirectoryState->RelativePathTopSource;
}
-const char* cmStateDirectory::GetRelativePathTopBinary() const
+std::string const& cmStateDirectory::GetRelativePathTopBinary() const
{
- return this->DirectoryState->RelativePathTopBinary.c_str();
+ return this->DirectoryState->RelativePathTopBinary;
}
void cmStateDirectory::SetRelativePathTopSource(const char* dir)
@@ -139,6 +139,32 @@ void cmStateDirectory::SetRelativePathTopBinary(const char* dir)
this->DirectoryState->RelativePathTopBinary = dir;
}
+bool cmStateDirectory::ContainsBoth(std::string const& local_path,
+ std::string const& remote_path) const
+{
+ auto PathEqOrSubDir = [](std::string const& a, std::string const& b) {
+ return (cmSystemTools::ComparePath(a, b) ||
+ cmSystemTools::IsSubDirectory(a, b));
+ };
+
+ bool bothInBinary = PathEqOrSubDir(local_path, GetRelativePathTopBinary()) &&
+ PathEqOrSubDir(remote_path, GetRelativePathTopBinary());
+
+ bool bothInSource = PathEqOrSubDir(local_path, GetRelativePathTopSource()) &&
+ PathEqOrSubDir(remote_path, GetRelativePathTopSource());
+
+ return bothInBinary || bothInSource;
+}
+
+std::string cmStateDirectory::ConvertToRelPathIfNotContained(
+ std::string const& local_path, std::string const& remote_path) const
+{
+ if (!this->ContainsBoth(local_path, remote_path)) {
+ return remote_path;
+ }
+ return cmSystemTools::ForceToRelativePath(local_path, remote_path);
+}
+
cmStateDirectory::cmStateDirectory(
cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator iter,
const cmStateSnapshot& snapshot)
@@ -150,11 +176,9 @@ cmStateDirectory::cmStateDirectory(
template <typename T, typename U>
cmStringRange GetPropertyContent(T const& content, U contentEndPosition)
{
- std::vector<std::string>::const_iterator end =
- content.begin() + contentEndPosition;
+ auto end = content.begin() + contentEndPosition;
- std::vector<std::string>::const_reverse_iterator rbegin =
- cmMakeReverseIterator(end);
+ auto rbegin = cm::make_reverse_iterator(end);
rbegin = std::find(rbegin, content.rend(), cmPropertySentinal);
return cmMakeRange(rbegin.base(), end);
@@ -164,17 +188,14 @@ template <typename T, typename U, typename V>
cmBacktraceRange GetPropertyBacktraces(T const& content, U const& backtraces,
V contentEndPosition)
{
- std::vector<std::string>::const_iterator entryEnd =
- content.begin() + contentEndPosition;
+ auto entryEnd = content.begin() + contentEndPosition;
- std::vector<std::string>::const_reverse_iterator rbegin =
- cmMakeReverseIterator(entryEnd);
+ auto rbegin = cm::make_reverse_iterator(entryEnd);
rbegin = std::find(rbegin, content.rend(), cmPropertySentinal);
- std::vector<cmListFileBacktrace>::const_iterator it =
- backtraces.begin() + std::distance(content.begin(), rbegin.base());
+ auto it = backtraces.begin() + std::distance(content.begin(), rbegin.base());
- std::vector<cmListFileBacktrace>::const_iterator end = backtraces.end();
+ auto end = backtraces.end();
return cmMakeRange(it, end);
}
@@ -246,22 +267,17 @@ void cmStateDirectory::AppendIncludeDirectoriesEntry(
void cmStateDirectory::PrependIncludeDirectoriesEntry(
const std::string& vec, const cmListFileBacktrace& lfbt)
{
- std::vector<std::string>::iterator entryEnd =
- this->DirectoryState->IncludeDirectories.begin() +
+ auto entryEnd = this->DirectoryState->IncludeDirectories.begin() +
this->Snapshot_.Position->IncludeDirectoryPosition;
- std::vector<std::string>::reverse_iterator rend =
- this->DirectoryState->IncludeDirectories.rend();
- std::vector<std::string>::reverse_iterator rbegin =
- cmMakeReverseIterator(entryEnd);
+ auto rend = this->DirectoryState->IncludeDirectories.rend();
+ auto rbegin = cm::make_reverse_iterator(entryEnd);
rbegin = std::find(rbegin, rend, cmPropertySentinal);
- std::vector<std::string>::iterator entryIt = rbegin.base();
- std::vector<std::string>::iterator entryBegin =
- this->DirectoryState->IncludeDirectories.begin();
+ auto entryIt = rbegin.base();
+ auto entryBegin = this->DirectoryState->IncludeDirectories.begin();
- std::vector<cmListFileBacktrace>::iterator btIt =
- this->DirectoryState->IncludeDirectoryBacktraces.begin() +
+ auto btIt = this->DirectoryState->IncludeDirectoryBacktraces.begin() +
std::distance(entryBegin, entryIt);
this->DirectoryState->IncludeDirectories.insert(entryIt, vec);
@@ -361,6 +377,101 @@ void cmStateDirectory::ClearCompileOptions()
this->Snapshot_.Position->CompileOptionsPosition);
}
+cmStringRange cmStateDirectory::GetLinkOptionsEntries() const
+{
+ return GetPropertyContent(this->DirectoryState->LinkOptions,
+ this->Snapshot_.Position->LinkOptionsPosition);
+}
+
+cmBacktraceRange cmStateDirectory::GetLinkOptionsEntryBacktraces() const
+{
+ return GetPropertyBacktraces(this->DirectoryState->LinkOptions,
+ this->DirectoryState->LinkOptionsBacktraces,
+ this->Snapshot_.Position->LinkOptionsPosition);
+}
+
+void cmStateDirectory::AppendLinkOptionsEntry(const std::string& vec,
+ const cmListFileBacktrace& lfbt)
+{
+ AppendEntry(this->DirectoryState->LinkOptions,
+ this->DirectoryState->LinkOptionsBacktraces,
+ this->Snapshot_.Position->LinkOptionsPosition, vec, lfbt);
+}
+
+void cmStateDirectory::SetLinkOptions(const std::string& vec,
+ const cmListFileBacktrace& lfbt)
+{
+ SetContent(this->DirectoryState->LinkOptions,
+ this->DirectoryState->LinkOptionsBacktraces,
+ this->Snapshot_.Position->LinkOptionsPosition, vec, lfbt);
+}
+
+void cmStateDirectory::ClearLinkOptions()
+{
+ ClearContent(this->DirectoryState->LinkOptions,
+ this->DirectoryState->LinkOptionsBacktraces,
+ this->Snapshot_.Position->LinkOptionsPosition);
+}
+
+cmStringRange cmStateDirectory::GetLinkDirectoriesEntries() const
+{
+ return GetPropertyContent(this->DirectoryState->LinkDirectories,
+ this->Snapshot_.Position->LinkDirectoriesPosition);
+}
+
+cmBacktraceRange cmStateDirectory::GetLinkDirectoriesEntryBacktraces() const
+{
+ return GetPropertyBacktraces(
+ this->DirectoryState->LinkDirectories,
+ this->DirectoryState->LinkDirectoriesBacktraces,
+ this->Snapshot_.Position->LinkDirectoriesPosition);
+}
+
+void cmStateDirectory::AppendLinkDirectoriesEntry(
+ const std::string& vec, const cmListFileBacktrace& lfbt)
+{
+ AppendEntry(this->DirectoryState->LinkDirectories,
+ this->DirectoryState->LinkDirectoriesBacktraces,
+ this->Snapshot_.Position->LinkDirectoriesPosition, vec, lfbt);
+}
+void cmStateDirectory::PrependLinkDirectoriesEntry(
+ const std::string& vec, const cmListFileBacktrace& lfbt)
+{
+ auto entryEnd = this->DirectoryState->LinkDirectories.begin() +
+ this->Snapshot_.Position->LinkDirectoriesPosition;
+
+ auto rend = this->DirectoryState->LinkDirectories.rend();
+ auto rbegin = cm::make_reverse_iterator(entryEnd);
+ rbegin = std::find(rbegin, rend, cmPropertySentinal);
+
+ auto entryIt = rbegin.base();
+ auto entryBegin = this->DirectoryState->LinkDirectories.begin();
+
+ auto btIt = this->DirectoryState->LinkDirectoriesBacktraces.begin() +
+ std::distance(entryBegin, entryIt);
+
+ this->DirectoryState->LinkDirectories.insert(entryIt, vec);
+ this->DirectoryState->LinkDirectoriesBacktraces.insert(btIt, lfbt);
+
+ this->Snapshot_.Position->LinkDirectoriesPosition =
+ this->DirectoryState->LinkDirectories.size();
+}
+
+void cmStateDirectory::SetLinkDirectories(const std::string& vec,
+ const cmListFileBacktrace& lfbt)
+{
+ SetContent(this->DirectoryState->LinkDirectories,
+ this->DirectoryState->LinkDirectoriesBacktraces,
+ this->Snapshot_.Position->LinkDirectoriesPosition, vec, lfbt);
+}
+
+void cmStateDirectory::ClearLinkDirectories()
+{
+ ClearContent(this->DirectoryState->LinkDirectories,
+ this->DirectoryState->LinkDirectoriesBacktraces,
+ this->Snapshot_.Position->LinkDirectoriesPosition);
+}
+
void cmStateDirectory::SetProperty(const std::string& prop, const char* value,
cmListFileBacktrace const& lfbt)
{
@@ -388,6 +499,22 @@ void cmStateDirectory::SetProperty(const std::string& prop, const char* value,
this->SetCompileDefinitions(value, lfbt);
return;
}
+ if (prop == "LINK_OPTIONS") {
+ if (!value) {
+ this->ClearLinkOptions();
+ return;
+ }
+ this->SetLinkOptions(value, lfbt);
+ return;
+ }
+ if (prop == "LINK_DIRECTORIES") {
+ if (!value) {
+ this->ClearLinkDirectories();
+ return;
+ }
+ this->SetLinkDirectories(value, lfbt);
+ return;
+ }
this->DirectoryState->Properties.SetProperty(prop, value);
}
@@ -408,6 +535,14 @@ void cmStateDirectory::AppendProperty(const std::string& prop,
this->AppendCompileDefinitionsEntry(value, lfbt);
return;
}
+ if (prop == "LINK_OPTIONS") {
+ this->AppendLinkOptionsEntry(value, lfbt);
+ return;
+ }
+ if (prop == "LINK_DIRECTORIES") {
+ this->AppendLinkDirectoriesEntry(value, lfbt);
+ return;
+ }
this->DirectoryState->Properties.AppendProperty(prop, value, asString);
}
@@ -423,11 +558,11 @@ const char* cmStateDirectory::GetProperty(const std::string& prop,
bool chain) const
{
static std::string output;
- output = "";
+ output.clear();
if (prop == "PARENT_DIRECTORY") {
cmStateSnapshot parent = this->Snapshot_.GetBuildsystemDirectoryParent();
if (parent.IsValid()) {
- return parent.GetDirectory().GetCurrentSource();
+ return parent.GetDirectory().GetCurrentSource().c_str();
}
return "";
}
@@ -443,9 +578,9 @@ const char* cmStateDirectory::GetProperty(const std::string& prop,
std::vector<std::string> child_dirs;
std::vector<cmStateSnapshot> const& children =
this->DirectoryState->Children;
- for (std::vector<cmStateSnapshot>::const_iterator ci = children.begin();
- ci != children.end(); ++ci) {
- child_dirs.push_back(ci->GetDirectory().GetCurrentSource());
+ child_dirs.reserve(children.size());
+ for (cmStateSnapshot const& ci : children) {
+ child_dirs.push_back(ci.GetDirectory().GetCurrentSource());
}
output = cmJoin(child_dirs, ";");
return output.c_str();
@@ -472,9 +607,7 @@ const char* cmStateDirectory::GetProperty(const std::string& prop,
}
if (prop == "VARIABLES") {
std::vector<std::string> res = this->Snapshot_.ClosureKeys();
- std::vector<std::string> cacheKeys =
- this->Snapshot_.State->GetCacheEntryKeys();
- res.insert(res.end(), cacheKeys.begin(), cacheKeys.end());
+ cmAppend(res, this->Snapshot_.State->GetCacheEntryKeys());
std::sort(res.begin(), res.end());
output = cmJoin(res, ";");
return output.c_str();
@@ -491,6 +624,14 @@ const char* cmStateDirectory::GetProperty(const std::string& prop,
output = cmJoin(this->GetCompileDefinitionsEntries(), ";");
return output.c_str();
}
+ if (prop == "LINK_OPTIONS") {
+ output = cmJoin(this->GetLinkOptionsEntries(), ";");
+ return output.c_str();
+ }
+ if (prop == "LINK_DIRECTORIES") {
+ output = cmJoin(this->GetLinkDirectoriesEntries(), ";");
+ return output.c_str();
+ }
const char* retVal = this->DirectoryState->Properties.GetPropertyValue(prop);
if (!retVal && chain) {
@@ -507,19 +648,12 @@ const char* cmStateDirectory::GetProperty(const std::string& prop,
bool cmStateDirectory::GetPropertyAsBool(const std::string& prop) const
{
- return cmSystemTools::IsOn(this->GetProperty(prop));
+ return cmIsOn(this->GetProperty(prop));
}
std::vector<std::string> cmStateDirectory::GetPropertyKeys() const
{
- std::vector<std::string> keys;
- keys.reserve(this->DirectoryState->Properties.size());
- for (cmPropertyMap::const_iterator it =
- this->DirectoryState->Properties.begin();
- it != this->DirectoryState->Properties.end(); ++it) {
- keys.push_back(it->first);
- }
- return keys;
+ return this->DirectoryState->Properties.GetKeys();
}
void cmStateDirectory::AddNormalTargetName(std::string const& name)
diff --git a/Source/cmStateDirectory.h b/Source/cmStateDirectory.h
index 79bb36943..fe15563cb 100644
--- a/Source/cmStateDirectory.h
+++ b/Source/cmStateDirectory.h
@@ -14,6 +14,7 @@
#include "cmListFileCache.h"
#include "cmStatePrivate.h"
#include "cmStateSnapshot.h"
+#include "cmStringAlgorithms.h"
class cmStateDirectory
{
@@ -22,16 +23,22 @@ class cmStateDirectory
cmStateSnapshot const& snapshot);
public:
- const char* GetCurrentSource() const;
+ std::string const& GetCurrentSource() const;
void SetCurrentSource(std::string const& dir);
- const char* GetCurrentBinary() const;
+ std::string const& GetCurrentBinary() const;
void SetCurrentBinary(std::string const& dir);
- const char* GetRelativePathTopSource() const;
- const char* GetRelativePathTopBinary() const;
+ std::string const& GetRelativePathTopSource() const;
+ std::string const& GetRelativePathTopBinary() const;
void SetRelativePathTopSource(const char* dir);
void SetRelativePathTopBinary(const char* dir);
+ bool ContainsBoth(std::string const& local_path,
+ std::string const& remote_path) const;
+
+ std::string ConvertToRelPathIfNotContained(
+ std::string const& local_path, std::string const& remote_path) const;
+
cmStringRange GetIncludeDirectoriesEntries() const;
cmBacktraceRange GetIncludeDirectoriesEntryBacktraces() const;
void AppendIncludeDirectoriesEntry(std::string const& vec,
@@ -58,6 +65,23 @@ public:
cmListFileBacktrace const& lfbt);
void ClearCompileOptions();
+ cmStringRange GetLinkOptionsEntries() const;
+ cmBacktraceRange GetLinkOptionsEntryBacktraces() const;
+ void AppendLinkOptionsEntry(std::string const& vec,
+ cmListFileBacktrace const& lfbt);
+ void PrependLinkDirectoriesEntry(std::string const& vec,
+ cmListFileBacktrace const& lfbt);
+ void SetLinkOptions(std::string const& vec, cmListFileBacktrace const& lfbt);
+ void ClearLinkOptions();
+
+ cmStringRange GetLinkDirectoriesEntries() const;
+ cmBacktraceRange GetLinkDirectoriesEntryBacktraces() const;
+ void AppendLinkDirectoriesEntry(std::string const& vec,
+ cmListFileBacktrace const& lfbt);
+ void SetLinkDirectories(std::string const& vec,
+ cmListFileBacktrace const& lfbt);
+ void ClearLinkDirectories();
+
void SetProperty(const std::string& prop, const char* value,
cmListFileBacktrace const& lfbt);
void AppendProperty(const std::string& prop, const char* value,
diff --git a/Source/cmStatePrivate.h b/Source/cmStatePrivate.h
index f36ee37ea..4efaf97eb 100644
--- a/Source/cmStatePrivate.h
+++ b/Source/cmStatePrivate.h
@@ -42,14 +42,15 @@ struct cmStateDetail::SnapshotDataType
std::vector<std::string>::size_type IncludeDirectoryPosition;
std::vector<std::string>::size_type CompileDefinitionsPosition;
std::vector<std::string>::size_type CompileOptionsPosition;
+ std::vector<std::string>::size_type LinkOptionsPosition;
+ std::vector<std::string>::size_type LinkDirectoriesPosition;
};
struct cmStateDetail::PolicyStackEntry : public cmPolicies::PolicyMap
{
- typedef cmPolicies::PolicyMap derived;
+ using derived = cmPolicies::PolicyMap;
PolicyStackEntry(bool w = false)
- : derived()
- , Weak(w)
+ : Weak(w)
{
}
PolicyStackEntry(derived const& d, bool w)
@@ -84,6 +85,12 @@ struct cmStateDetail::BuildsystemDirectoryStateType
std::vector<std::string> CompileOptions;
std::vector<cmListFileBacktrace> CompileOptionsBacktraces;
+ std::vector<std::string> LinkOptions;
+ std::vector<cmListFileBacktrace> LinkOptionsBacktraces;
+
+ std::vector<std::string> LinkDirectories;
+ std::vector<cmListFileBacktrace> LinkDirectoriesBacktraces;
+
std::vector<std::string> NormalTargetNames;
std::string ProjectName;
diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx
index 77413c7b5..645907c21 100644
--- a/Source/cmStateSnapshot.cxx
+++ b/Source/cmStateSnapshot.cxx
@@ -4,11 +4,11 @@
#include "cmStateSnapshot.h"
#include <algorithm>
-#include <assert.h>
-#include <iterator>
-#include <stdio.h>
+#include <cassert>
+#include <string>
+
+#include <cm/iterator>
-#include "cmAlgorithms.h"
#include "cmDefinitions.h"
#include "cmListFileCache.h"
#include "cmPropertyMap.h"
@@ -16,19 +16,17 @@
#include "cmStateDirectory.h"
#include "cmStatePrivate.h"
#include "cmVersion.h"
-#include "cmake.h"
#if !defined(_WIN32)
-#include <sys/utsname.h>
+# include <sys/utsname.h>
#endif
#if defined(__CYGWIN__)
-#include "cmSystemTools.h"
+# include "cmSystemTools.h"
#endif
cmStateSnapshot::cmStateSnapshot(cmState* state)
: State(state)
- , Position()
{
}
@@ -66,6 +64,11 @@ bool cmStateSnapshot::IsValid() const
: false;
}
+cmStateSnapshot cmStateSnapshot::GetBuildsystemDirectory() const
+{
+ return { this->State, this->Position->BuildSystemDirectory->DirectoryEnd };
+}
+
cmStateSnapshot cmStateSnapshot::GetBuildsystemDirectoryParent() const
{
cmStateSnapshot snapshot;
@@ -122,7 +125,7 @@ cmStateSnapshot cmStateSnapshot::GetCallStackBottom() const
pos != this->State->SnapshotData.Root()) {
++pos;
}
- return cmStateSnapshot(this->State, pos);
+ return { this->State, pos };
}
void cmStateSnapshot::PushPolicy(cmPolicies::PolicyMap const& entry, bool weak)
@@ -160,8 +163,8 @@ void cmStateSnapshot::SetPolicy(cmPolicies::PolicyID id,
}
}
-cmPolicies::PolicyStatus cmStateSnapshot::GetPolicy(
- cmPolicies::PolicyID id) const
+cmPolicies::PolicyStatus cmStateSnapshot::GetPolicy(cmPolicies::PolicyID id,
+ bool parent_scope) const
{
cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id);
@@ -180,6 +183,10 @@ cmPolicies::PolicyStatus cmStateSnapshot::GetPolicy(
cmLinkedTree<cmStateDetail::PolicyStackEntry>::iterator root =
dir->DirectoryEnd->PolicyRoot;
for (; leaf != root; ++leaf) {
+ if (parent_scope) {
+ parent_scope = false;
+ continue;
+ }
if (leaf->IsDefined(id)) {
status = leaf->Get(id);
return status;
@@ -200,7 +207,8 @@ bool cmStateSnapshot::HasDefinedPolicyCMP0011()
return !this->Position->Policies->IsEmpty();
}
-const char* cmStateSnapshot::GetDefinition(std::string const& name) const
+std::string const* cmStateSnapshot::GetDefinition(
+ std::string const& name) const
{
assert(this->Position->Vars.IsValid());
return cmDefinitions::Get(name, this->Position->Vars, this->Position->Root);
@@ -213,14 +221,14 @@ bool cmStateSnapshot::IsInitialized(std::string const& name) const
}
void cmStateSnapshot::SetDefinition(std::string const& name,
- std::string const& value)
+ cm::string_view value)
{
- this->Position->Vars->Set(name, value.c_str());
+ this->Position->Vars->Set(name, value);
}
void cmStateSnapshot::RemoveDefinition(std::string const& name)
{
- this->Position->Vars->Set(name, CM_NULLPTR);
+ this->Position->Vars->Unset(name);
}
std::vector<std::string> cmStateSnapshot::UnusedKeys() const
@@ -255,7 +263,11 @@ bool cmStateSnapshot::RaiseScope(std::string const& var, const char* varDef)
cmDefinitions::Raise(var, this->Position->Vars, this->Position->Root);
// Now update the definition in the parent scope.
- this->Position->Parent->Set(var, varDef);
+ if (varDef) {
+ this->Position->Parent->Set(var, varDef);
+ } else {
+ this->Position->Parent->Unset(var);
+ }
return true;
}
@@ -264,22 +276,18 @@ void InitializeContentFromParent(T& parentContent, T& thisContent,
U& parentBacktraces, U& thisBacktraces,
V& contentEndPosition)
{
- std::vector<std::string>::const_iterator parentBegin = parentContent.begin();
- std::vector<std::string>::const_iterator parentEnd = parentContent.end();
+ auto parentBegin = parentContent.begin();
+ auto parentEnd = parentContent.end();
- std::vector<std::string>::const_reverse_iterator parentRbegin =
- cmMakeReverseIterator(parentEnd);
- std::vector<std::string>::const_reverse_iterator parentRend =
- parentContent.rend();
+ auto parentRbegin = cm::make_reverse_iterator(parentEnd);
+ auto parentRend = parentContent.rend();
parentRbegin = std::find(parentRbegin, parentRend, cmPropertySentinal);
- std::vector<std::string>::const_iterator parentIt = parentRbegin.base();
+ auto parentIt = parentRbegin.base();
thisContent = std::vector<std::string>(parentIt, parentEnd);
- std::vector<cmListFileBacktrace>::const_iterator btIt =
- parentBacktraces.begin() + std::distance(parentBegin, parentIt);
- std::vector<cmListFileBacktrace>::const_iterator btEnd =
- parentBacktraces.end();
+ auto btIt = parentBacktraces.begin() + std::distance(parentBegin, parentIt);
+ auto btEnd = parentBacktraces.end();
thisBacktraces = std::vector<cmListFileBacktrace>(btIt, btEnd);
@@ -315,7 +323,7 @@ void cmStateSnapshot::SetDefaultDefinitions()
#if defined(__CYGWIN__)
std::string legacy;
if (cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32", legacy) &&
- cmSystemTools::IsOn(legacy.c_str())) {
+ cmIsOn(legacy.c_str())) {
this->SetDefinition("WIN32", "1");
this->SetDefinition("CMAKE_HOST_WIN32", "1");
}
@@ -328,19 +336,17 @@ void cmStateSnapshot::SetDefaultDefinitions()
this->SetDefinition("CMAKE_HOST_SOLARIS", "1");
#endif
- char temp[1024];
- sprintf(temp, "%d", cmVersion::GetMinorVersion());
- this->SetDefinition("CMAKE_MINOR_VERSION", temp);
- sprintf(temp, "%d", cmVersion::GetMajorVersion());
- this->SetDefinition("CMAKE_MAJOR_VERSION", temp);
- sprintf(temp, "%d", cmVersion::GetPatchVersion());
- this->SetDefinition("CMAKE_PATCH_VERSION", temp);
- sprintf(temp, "%d", cmVersion::GetTweakVersion());
- this->SetDefinition("CMAKE_TWEAK_VERSION", temp);
+ this->SetDefinition("CMAKE_MAJOR_VERSION",
+ std::to_string(cmVersion::GetMajorVersion()));
+ this->SetDefinition("CMAKE_MINOR_VERSION",
+ std::to_string(cmVersion::GetMinorVersion()));
+ this->SetDefinition("CMAKE_PATCH_VERSION",
+ std::to_string(cmVersion::GetPatchVersion()));
+ this->SetDefinition("CMAKE_TWEAK_VERSION",
+ std::to_string(cmVersion::GetTweakVersion()));
this->SetDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion());
- this->SetDefinition("CMAKE_FILES_DIRECTORY",
- cmake::GetCMakeFilesDirectory());
+ this->SetDefinition("CMAKE_FILES_DIRECTORY", "/CMakeFiles");
// Setup the default include file regular expression (match everything).
this->Position->BuildSystemDirectory->Properties.SetProperty(
@@ -386,6 +392,26 @@ void cmStateSnapshot::InitializeFromParent()
parent->BuildSystemDirectory->CompileOptionsBacktraces,
this->Position->BuildSystemDirectory->CompileOptionsBacktraces,
this->Position->CompileOptionsPosition);
+
+ InitializeContentFromParent(
+ parent->BuildSystemDirectory->LinkOptions,
+ this->Position->BuildSystemDirectory->LinkOptions,
+ parent->BuildSystemDirectory->LinkOptionsBacktraces,
+ this->Position->BuildSystemDirectory->LinkOptionsBacktraces,
+ this->Position->LinkOptionsPosition);
+
+ InitializeContentFromParent(
+ parent->BuildSystemDirectory->LinkDirectories,
+ this->Position->BuildSystemDirectory->LinkDirectories,
+ parent->BuildSystemDirectory->LinkDirectoriesBacktraces,
+ this->Position->BuildSystemDirectory->LinkDirectoriesBacktraces,
+ this->Position->LinkDirectoriesPosition);
+
+ const char* include_regex =
+ parent->BuildSystemDirectory->Properties.GetPropertyValue(
+ "INCLUDE_REGULAR_EXPRESSION");
+ this->Position->BuildSystemDirectory->Properties.SetProperty(
+ "INCLUDE_REGULAR_EXPRESSION", include_regex);
}
cmState* cmStateSnapshot::GetState() const
@@ -395,7 +421,7 @@ cmState* cmStateSnapshot::GetState() const
cmStateDirectory cmStateSnapshot::GetDirectory() const
{
- return cmStateDirectory(this->Position->BuildSystemDirectory, *this);
+ return { this->Position->BuildSystemDirectory, *this };
}
void cmStateSnapshot::SetProjectName(const std::string& name)
@@ -410,8 +436,8 @@ std::string cmStateSnapshot::GetProjectName() const
void cmStateSnapshot::InitializeFromParent_ForSubdirsCommand()
{
- std::string currentSrcDir = this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR");
- std::string currentBinDir = this->GetDefinition("CMAKE_CURRENT_BINARY_DIR");
+ std::string currentSrcDir = *this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR");
+ std::string currentBinDir = *this->GetDefinition("CMAKE_CURRENT_BINARY_DIR");
this->InitializeFromParent();
this->SetDefinition("CMAKE_SOURCE_DIR", this->State->GetSourceDirectory());
this->SetDefinition("CMAKE_BINARY_DIR", this->State->GetBinaryDirectory());
diff --git a/Source/cmStateSnapshot.h b/Source/cmStateSnapshot.h
index 6293803b9..021fd53c1 100644
--- a/Source/cmStateSnapshot.h
+++ b/Source/cmStateSnapshot.h
@@ -9,6 +9,8 @@
#include <string>
#include <vector>
+#include <cm/string_view>
+
#include "cmLinkedTree.h"
#include "cmPolicies.h"
#include "cmStateTypes.h"
@@ -19,12 +21,12 @@ class cmStateDirectory;
class cmStateSnapshot
{
public:
- cmStateSnapshot(cmState* state = CM_NULLPTR);
+ cmStateSnapshot(cmState* state = nullptr);
cmStateSnapshot(cmState* state, cmStateDetail::PositionType position);
- const char* GetDefinition(std::string const& name) const;
+ std::string const* GetDefinition(std::string const& name) const;
bool IsInitialized(std::string const& name) const;
- void SetDefinition(std::string const& name, std::string const& value);
+ void SetDefinition(std::string const& name, cm::string_view value);
void RemoveDefinition(std::string const& name);
std::vector<std::string> UnusedKeys() const;
std::vector<std::string> ClosureKeys() const;
@@ -37,13 +39,15 @@ public:
std::vector<cmStateSnapshot> GetChildren();
bool IsValid() const;
+ cmStateSnapshot GetBuildsystemDirectory() const;
cmStateSnapshot GetBuildsystemDirectoryParent() const;
cmStateSnapshot GetCallStackParent() const;
cmStateSnapshot GetCallStackBottom() const;
cmStateEnums::SnapshotType GetType() const;
void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
- cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id) const;
+ cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id,
+ bool parent_scope = false) const;
bool HasDefinedPolicyCMP0011();
void PushPolicy(cmPolicies::PolicyMap const& entry, bool weak);
bool PopPolicy();
diff --git a/Source/cmStateTypes.h b/Source/cmStateTypes.h
index 7d6158e33..d089ea73d 100644
--- a/Source/cmStateTypes.h
+++ b/Source/cmStateTypes.h
@@ -10,7 +10,7 @@
namespace cmStateDetail {
struct SnapshotDataType;
-typedef cmLinkedTree<cmStateDetail::SnapshotDataType>::iterator PositionType;
+using PositionType = cmLinkedTree<cmStateDetail::SnapshotDataType>::iterator;
}
namespace cmStateEnums {
diff --git a/Source/cmString.cxx b/Source/cmString.cxx
new file mode 100644
index 000000000..2a0c125e6
--- /dev/null
+++ b/Source/cmString.cxx
@@ -0,0 +1,152 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#define _SCL_SECURE_NO_WARNINGS
+
+#include "cmString.hxx"
+
+#include <memory>
+#include <ostream>
+#include <stdexcept>
+#include <string>
+#include <type_traits>
+
+namespace cm {
+
+static std::string const empty_string_;
+
+void String::internally_mutate_to_stable_string()
+{
+ // We assume that only one thread mutates this instance at
+ // a time even if we point to a shared string buffer refernced
+ // by other threads.
+ *this = String(data(), size());
+}
+
+bool String::is_stable() const
+{
+ return str_if_stable() != nullptr;
+}
+
+void String::stabilize()
+{
+ if (is_stable()) {
+ return;
+ }
+ this->internally_mutate_to_stable_string();
+}
+
+std::string const* String::str_if_stable() const
+{
+ if (!data()) {
+ // We view no string.
+ // This is stable for the lifetime of our current value.
+ return &empty_string_;
+ }
+
+ if (string_ && data() == string_->data() && size() == string_->size()) {
+ // We view an entire string.
+ // This is stable for the lifetime of our current value.
+ return string_.get();
+ }
+
+ return nullptr;
+}
+
+std::string const& String::str()
+{
+ if (std::string const* s = str_if_stable()) {
+ return *s;
+ }
+ // Mutate to hold a std::string that is stable for the lifetime
+ // of our current value.
+ this->internally_mutate_to_stable_string();
+ return *string_;
+}
+
+const char* String::c_str()
+{
+ const char* c = data();
+ if (c == nullptr) {
+ return c;
+ }
+
+ // We always point into a null-terminated string so it is safe to
+ // access one past the end. If it is a null byte then we can use
+ // the pointer directly.
+ if (c[size()] == '\0') {
+ return c;
+ }
+
+ // Mutate to hold a std::string so we can get a null terminator.
+ this->internally_mutate_to_stable_string();
+ c = string_->c_str();
+ return c;
+}
+
+String& String::insert(size_type index, size_type count, char ch)
+{
+ std::string s;
+ s.reserve(size() + count);
+ s.assign(data(), size());
+ s.insert(index, count, ch);
+ return *this = std::move(s);
+}
+
+String& String::erase(size_type index, size_type count)
+{
+ if (index > size()) {
+ throw std::out_of_range("Index out of range in String::erase");
+ }
+ size_type const rcount = std::min(count, size() - index);
+ size_type const rindex = index + rcount;
+ std::string s;
+ s.reserve(size() - rcount);
+ s.assign(data(), index);
+ s.append(data() + rindex, size() - rindex);
+ return *this = std::move(s);
+}
+
+String String::substr(size_type pos, size_type count) const
+{
+ if (pos > size()) {
+ throw std::out_of_range("Index out of range in String::substr");
+ }
+ return String(*this, pos, count);
+}
+
+String::String(std::string&& s, Private)
+ : string_(std::make_shared<std::string>(std::move(s)))
+ , view_(string_->data(), string_->size())
+{
+}
+
+String::size_type String::copy(char* dest, size_type count,
+ size_type pos) const
+{
+ return view_.copy(dest, count, pos);
+}
+
+std::ostream& operator<<(std::ostream& os, String const& s)
+{
+ return os.write(s.data(), s.size());
+}
+
+std::string& operator+=(std::string& self, String const& s)
+{
+ return self += s.view();
+}
+
+String IntoString<char*>::into_string(const char* s)
+{
+ if (!s) {
+ return String();
+ }
+ return std::string(s);
+}
+
+string_view AsStringView<String>::view(String const& s)
+{
+ return s.view();
+}
+
+} // namespace cm
diff --git a/Source/cmString.hxx b/Source/cmString.hxx
new file mode 100644
index 000000000..073f4c940
--- /dev/null
+++ b/Source/cmString.hxx
@@ -0,0 +1,817 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmString_hxx
+#define cmString_hxx
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <algorithm>
+#include <cstddef>
+#include <functional>
+#include <initializer_list>
+#include <memory>
+#include <ostream>
+#include <string>
+#include <type_traits>
+#include <utility>
+
+#include <cm/string_view>
+
+#include "cm_static_string_view.hxx"
+
+namespace cm {
+
+class String;
+
+/**
+ * Trait to convert type T into a String.
+ * Implementations must derive from 'std::true_type'
+ * and define an 'into_string' member that accepts
+ * type T (by value or reference) and returns one of:
+ *
+ * - 'std::string' to construct an owned instance.
+ * - 'cm::string_view' to construct a borrowed or null instances.
+ * The buffer from which the view is borrowed must outlive
+ * all copies of the resulting String, e.g. static storage.
+ * - 'cm::String' for already-constructed instances.
+ */
+template <typename T>
+struct IntoString : std::false_type
+{
+};
+
+template <typename T>
+struct IntoString<T&> : IntoString<T>
+{
+};
+
+template <typename T>
+struct IntoString<T const> : IntoString<T>
+{
+};
+
+template <typename T>
+struct IntoString<T const*> : IntoString<T*>
+{
+};
+
+template <typename T, std::string::size_type N>
+struct IntoString<T const[N]> : IntoString<T[N]>
+{
+};
+
+template <>
+struct IntoString<char*> : std::true_type
+{
+ static String into_string(const char* s);
+};
+
+template <>
+struct IntoString<std::nullptr_t> : std::true_type
+{
+ static string_view into_string(std::nullptr_t) { return string_view(); }
+};
+
+template <std::string::size_type N>
+struct IntoString<char[N]> : std::true_type
+{
+ static std::string into_string(char const (&s)[N])
+ {
+ return std::string(s, N - 1);
+ }
+};
+
+template <>
+struct IntoString<std::string> : std::true_type
+{
+ static std::string into_string(std::string s) { return s; }
+};
+
+template <>
+struct IntoString<string_view> : std::true_type
+{
+ static std::string into_string(string_view s) { return std::string(s); }
+};
+
+template <>
+struct IntoString<static_string_view> : std::true_type
+{
+ static string_view into_string(static_string_view s) { return s; }
+};
+
+template <>
+struct IntoString<char> : std::true_type
+{
+ static std::string into_string(char const& c) { return std::string(1, c); }
+};
+
+/**
+ * Trait to convert type T into a 'cm::string_view'.
+ * Implementations must derive from 'std::true_type' and
+ * define a 'view' member that accepts type T (by reference)
+ * and returns a 'cm::string_view'.
+ */
+template <typename T>
+struct AsStringView : std::false_type
+{
+};
+
+template <typename T>
+struct AsStringView<T&> : AsStringView<T>
+{
+};
+
+template <typename T>
+struct AsStringView<T const> : AsStringView<T>
+{
+};
+
+template <typename T>
+struct AsStringView<T const*> : AsStringView<T*>
+{
+};
+
+template <typename T, std::string::size_type N>
+struct AsStringView<T const[N]> : AsStringView<T[N]>
+{
+};
+
+template <>
+struct AsStringView<char*> : std::true_type
+{
+ static string_view view(const char* s) { return s; }
+};
+
+template <std::string::size_type N>
+struct AsStringView<char[N]> : std::true_type
+{
+ static string_view view(char const (&s)[N]) { return string_view(s, N - 1); }
+};
+
+template <>
+struct AsStringView<std::string> : std::true_type
+{
+ static string_view view(std::string const& s) { return s; }
+};
+
+template <>
+struct AsStringView<char> : std::true_type
+{
+ static string_view view(const char& s) { return string_view(&s, 1); }
+};
+
+template <>
+struct AsStringView<string_view> : std::true_type
+{
+ static string_view view(string_view const& s) { return s; }
+};
+
+template <>
+struct AsStringView<static_string_view> : std::true_type
+{
+ static string_view view(static_string_view const& s) { return s; }
+};
+
+template <>
+struct AsStringView<String> : std::true_type
+{
+ static string_view view(String const& s);
+};
+
+/**
+ * \class String
+ *
+ * A custom string type that holds a view of a string buffer
+ * and optionally shares ownership of the buffer. Instances
+ * may have one of the following states:
+ *
+ * - null: views and owns nothing.
+ * Conversion to 'bool' is 'false'.
+ * 'data()' and 'c_str()' return nullptr.
+ * 'size()' returns 0.
+ * 'str()' returns an empty string.
+ *
+ * - borrowed: views a string but does not own it. This is used
+ * to bind to static storage (e.g. string literals) or for
+ * temporary instances that do not outlive the borrowed buffer.
+ * Copies and substrings still borrow the original buffer.
+ * Mutation allocates a new internal string and converts to
+ * the 'owned' state.
+ * Conversion to 'bool' is 'true'.
+ * 'c_str()' may internally mutate to the 'owned' state.
+ * 'str()' internally mutates to the 'owned' state.
+ *
+ * - owned: views an immutable 'std::string' instance owned internally.
+ * Copies and substrings share ownership of the internal string.
+ * Mutation allocates a new internal string.
+ * Conversion to 'bool' is 'true'.
+ */
+class String
+{
+ enum class Private
+ {
+ };
+
+public:
+ using traits_type = std::string::traits_type;
+ using value_type = string_view::value_type;
+ using pointer = string_view::pointer;
+ using const_pointer = string_view::const_pointer;
+ using reference = string_view::reference;
+ using const_reference = string_view::const_reference;
+ using const_iterator = string_view::const_iterator;
+ using iterator = string_view::const_iterator;
+ using const_reverse_iterator = string_view::const_reverse_iterator;
+ using reverse_iterator = string_view::const_reverse_iterator;
+ using difference_type = string_view::difference_type;
+ using size_type = string_view::size_type;
+
+ static size_type const npos = string_view::npos;
+
+ /** Construct a null string. */
+ String() = default;
+
+ /** Construct from any type implementing the IntoString trait. */
+ template <typename T,
+ typename = typename std::enable_if<IntoString<T>::value>::type>
+ String(T&& s)
+ : String(IntoString<T>::into_string(std::forward<T>(s)), Private())
+ {
+ }
+
+ /** Construct via std::string initializer list constructor. */
+ String(std::initializer_list<char> il)
+ : String(std::string(il))
+ {
+ }
+
+ /** Construct by copying the specified buffer. */
+ String(const char* d, size_type s)
+ : String(std::string(d, s))
+ {
+ }
+
+ /** Construct by copying from input iterator range. */
+ template <typename InputIterator>
+ String(InputIterator first, InputIterator last)
+ : String(std::string(first, last))
+ {
+ }
+
+ /** Construct a string with 'n' copies of character 'c'. */
+ String(size_type n, char c)
+ : String(std::string(n, c))
+ {
+ }
+
+ /** Construct from a substring of another String instance.
+ This shares ownership of the other string's buffer
+ but views only a substring. */
+ String(String const& s, size_type pos, size_type count = npos)
+ : string_(s.string_)
+ , view_(s.data() + pos, std::min(count, s.size() - pos))
+ {
+ }
+
+ /** Construct by moving from another String instance.
+ The other instance is left as a null string. */
+ String(String&& s) noexcept
+ : string_(std::move(s.string_))
+ , view_(s.view_)
+ {
+ s.view_ = string_view();
+ }
+
+ /** Construct by copying from another String instance.
+ This shares ownership of the other string's buffer. */
+ String(String const&) noexcept = default;
+
+ ~String() = default;
+
+ /** Construct by borrowing an externally-owned buffer. The buffer
+ must outlive the returned instance and all copies of it. */
+ static String borrow(string_view v) { return String(v, Private()); }
+
+ /** Assign by moving from another String instance.
+ The other instance is left as a null string. */
+ String& operator=(String&& s) noexcept
+ {
+ string_ = std::move(s.string_);
+ view_ = s.view_;
+ s.view_ = string_view();
+ return *this;
+ }
+
+ /** Assign by copying from another String instance.
+ This shares ownership of the other string's buffer. */
+ String& operator=(String const&) noexcept = default;
+
+ /** Assign from any type implementing the IntoString trait. */
+ template <typename T>
+ typename // NOLINT(*)
+ std::enable_if<IntoString<T>::value, String&>::type
+ operator=(T&& s)
+ {
+ *this = String(std::forward<T>(s));
+ return *this;
+ }
+
+ /** Assign via std::string initializer list constructor. */
+ String& operator=(std::initializer_list<char> il)
+ {
+ *this = String(il);
+ return *this;
+ }
+
+ /** Return true if the instance is not a null string. */
+ explicit operator bool() const noexcept { return data() != nullptr; }
+
+ /** Return a view of the string. */
+ string_view view() const noexcept { return view_; }
+
+ /** Return true if the instance is an empty stringn or null string. */
+ bool empty() const noexcept { return view_.empty(); }
+
+ /** Return a pointer to the start of the string. */
+ const char* data() const noexcept { return view_.data(); }
+
+ /** Return the length of the string in bytes. */
+ size_type size() const noexcept { return view_.size(); }
+ size_type length() const noexcept { return view_.length(); }
+
+ /** Return the character at the given position.
+ No bounds checking is performed. */
+ char operator[](size_type pos) const noexcept { return view_[pos]; }
+
+ /** Return the character at the given position.
+ If the position is out of bounds, throws std::out_of_range. */
+ char at(size_type pos) const { return view_.at(pos); }
+
+ char front() const noexcept { return view_.front(); }
+
+ char back() const noexcept { return view_.back(); }
+
+ /** Return true if this instance is stable and otherwise false.
+ An instance is stable if it is in the 'null' state or if it is
+ an 'owned' state not produced by substring operations, or
+ after a call to 'stabilize()' or 'str()'. */
+ bool is_stable() const;
+
+ /** If 'is_stable()' does not return true, mutate so it does. */
+ void stabilize();
+
+ /** Get a pointer to a normal std::string if 'is_stable()' returns
+ true and otherwise nullptr. The pointer is valid until this
+ instance is mutated or destroyed. */
+ std::string const* str_if_stable() const;
+
+ /** Get a refernce to a normal std::string. The reference
+ is valid until this instance is mutated or destroyed. */
+ std::string const& str();
+
+ /** Get a pointer to a C-style null-terminated string
+ containing the same value as this instance. The pointer
+ is valid until this instance is mutated, destroyed,
+ or str() is called. */
+ const char* c_str();
+
+ const_iterator begin() const noexcept { return view_.begin(); }
+ const_iterator end() const noexcept { return view_.end(); }
+ const_iterator cbegin() const noexcept { return begin(); }
+ const_iterator cend() const noexcept { return end(); }
+
+ const_reverse_iterator rbegin() const noexcept { return view_.rbegin(); }
+ const_reverse_iterator rend() const noexcept { return view_.rend(); }
+ const_reverse_iterator crbegin() const noexcept { return rbegin(); }
+ const_reverse_iterator crend() const noexcept { return rend(); }
+
+ /** Append to the string using any type that implements the
+ AsStringView trait. */
+ template <typename T>
+ typename std::enable_if<AsStringView<T>::value, String&>::type operator+=(
+ T&& s)
+ {
+ string_view v = AsStringView<T>::view(std::forward<T>(s));
+ std::string r;
+ r.reserve(size() + v.size());
+ r.assign(data(), size());
+ r.append(v.data(), v.size());
+ return *this = std::move(r);
+ }
+
+ /** Assign to an empty string. */
+ void clear() { *this = ""_s; }
+
+ /** Insert 'count' copies of 'ch' at position 'index'. */
+ String& insert(size_type index, size_type count, char ch);
+
+ /** Erase 'count' characters starting at position 'index'. */
+ String& erase(size_type index = 0, size_type count = npos);
+
+ void push_back(char ch)
+ {
+ std::string s;
+ s.reserve(size() + 1);
+ s.assign(data(), size());
+ s.push_back(ch);
+ *this = std::move(s);
+ }
+
+ void pop_back() { *this = String(*this, 0, size() - 1); }
+
+ template <typename T>
+ typename std::enable_if<AsStringView<T>::value, String&>::type replace(
+ size_type pos, size_type count, T&& s)
+ {
+ const_iterator first = begin() + pos;
+ const_iterator last = first + count;
+ return replace(first, last, std::forward<T>(s));
+ }
+
+ template <typename InputIterator>
+ String& replace(const_iterator first, const_iterator last,
+ InputIterator first2, InputIterator last2)
+ {
+ std::string out;
+ out.append(view_.begin(), first);
+ out.append(first2, last2);
+ out.append(last, view_.end());
+ return *this = std::move(out);
+ }
+
+ template <typename T>
+ typename std::enable_if<AsStringView<T>::value, String&>::type replace(
+ const_iterator first, const_iterator last, T&& s)
+ {
+ string_view v = AsStringView<T>::view(std::forward<T>(s));
+ std::string out;
+ out.reserve((first - view_.begin()) + v.size() + (view_.end() - last));
+ out.append(view_.begin(), first);
+ out.append(v.data(), v.size());
+ out.append(last, view_.end());
+ return *this = std::move(out);
+ }
+
+ template <typename T>
+ typename std::enable_if<AsStringView<T>::value, String&>::type replace(
+ size_type pos, size_type count, T&& s, size_type pos2,
+ size_type count2 = npos)
+ {
+ string_view v = AsStringView<T>::view(std::forward<T>(s));
+ v = v.substr(pos2, count2);
+ return replace(pos, count, v);
+ }
+
+ String& replace(size_type pos, size_type count, size_type count2, char ch)
+ {
+ const_iterator first = begin() + pos;
+ const_iterator last = first + count;
+ return replace(first, last, count2, ch);
+ }
+
+ String& replace(const_iterator first, const_iterator last, size_type count2,
+ char ch)
+ {
+ std::string out;
+ out.reserve((first - view_.begin()) + count2 + (view_.end() - last));
+ out.append(view_.begin(), first);
+ out.append(count2, ch);
+ out.append(last, view_.end());
+ return *this = std::move(out);
+ }
+
+ size_type copy(char* dest, size_type count, size_type pos = 0) const;
+
+ void resize(size_type count) { resize(count, char()); }
+
+ void resize(size_type count, char ch)
+ {
+ std::string s;
+ s.reserve(count);
+ if (count <= size()) {
+ s.assign(data(), count);
+ } else {
+ s.assign(data(), size());
+ s.resize(count, ch);
+ }
+ *this = std::move(s);
+ }
+
+ void swap(String& other)
+ {
+ std::swap(string_, other.string_);
+ std::swap(view_, other.view_);
+ }
+
+ /** Return a substring starting at position 'pos' and
+ consisting of at most 'count' characters. */
+ String substr(size_type pos = 0, size_type count = npos) const;
+
+ template <typename T>
+ typename std::enable_if<AsStringView<T>::value, int>::type compare(
+ T&& s) const
+ {
+ return view_.compare(AsStringView<T>::view(std::forward<T>(s)));
+ }
+
+ int compare(size_type pos1, size_type count1, string_view v) const
+ {
+ return view_.compare(pos1, count1, v);
+ }
+
+ int compare(size_type pos1, size_type count1, string_view v, size_type pos2,
+ size_type count2) const
+ {
+ return view_.compare(pos1, count1, v, pos2, count2);
+ }
+
+ int compare(size_type pos1, size_type count1, const char* s) const
+ {
+ return view_.compare(pos1, count1, s);
+ }
+
+ int compare(size_type pos1, size_type count1, const char* s,
+ size_type count2) const
+ {
+ return view_.compare(pos1, count1, s, count2);
+ }
+
+ template <typename T>
+ typename std::enable_if<AsStringView<T>::value, size_type>::type find(
+ T&& s, size_type pos = 0) const
+ {
+ string_view v = AsStringView<T>::view(std::forward<T>(s));
+ return view_.find(v, pos);
+ }
+
+ size_type find(const char* s, size_type pos, size_type count) const
+ {
+ return view_.find(s, pos, count);
+ }
+
+ template <typename T>
+ typename std::enable_if<AsStringView<T>::value, size_type>::type rfind(
+ T&& s, size_type pos = npos) const
+ {
+ string_view v = AsStringView<T>::view(std::forward<T>(s));
+ return view_.rfind(v, pos);
+ }
+
+ size_type rfind(const char* s, size_type pos, size_type count) const
+ {
+ return view_.rfind(s, pos, count);
+ }
+
+ template <typename T>
+ typename std::enable_if<AsStringView<T>::value, size_type>::type
+ find_first_of(T&& s, size_type pos = 0) const
+ {
+ string_view v = AsStringView<T>::view(std::forward<T>(s));
+ return view_.find_first_of(v, pos);
+ }
+
+ size_type find_first_of(const char* s, size_type pos, size_type count) const
+ {
+ return view_.find_first_of(s, pos, count);
+ }
+
+ template <typename T>
+ typename std::enable_if<AsStringView<T>::value, size_type>::type
+ find_first_not_of(T&& s, size_type pos = 0) const
+ {
+ string_view v = AsStringView<T>::view(std::forward<T>(s));
+ return view_.find_first_not_of(v, pos);
+ }
+
+ size_type find_first_not_of(const char* s, size_type pos,
+ size_type count) const
+ {
+ return view_.find_first_not_of(s, pos, count);
+ }
+
+ template <typename T>
+ typename std::enable_if<AsStringView<T>::value, size_type>::type
+ find_last_of(T&& s, size_type pos = npos) const
+ {
+ string_view v = AsStringView<T>::view(std::forward<T>(s));
+ return view_.find_last_of(v, pos);
+ }
+
+ size_type find_last_of(const char* s, size_type pos, size_type count) const
+ {
+ return view_.find_last_of(s, pos, count);
+ }
+
+ template <typename T>
+ typename std::enable_if<AsStringView<T>::value, size_type>::type
+ find_last_not_of(T&& s, size_type pos = npos) const
+ {
+ string_view v = AsStringView<T>::view(std::forward<T>(s));
+ return view_.find_last_not_of(v, pos);
+ }
+
+ size_type find_last_not_of(const char* s, size_type pos,
+ size_type count) const
+ {
+ return view_.find_last_not_of(s, pos, count);
+ }
+
+private:
+ // Internal constructor to move from existing String.
+ String(String&& s, Private) noexcept
+ : String(std::move(s))
+ {
+ }
+
+ // Internal constructor for dynamically allocated string.
+ String(std::string&& s, Private);
+
+ // Internal constructor for view of statically allocated string.
+ String(string_view v, Private)
+ : view_(v)
+ {
+ }
+
+ void internally_mutate_to_stable_string();
+
+ std::shared_ptr<std::string const> string_;
+ string_view view_;
+};
+
+template <typename L, typename R>
+typename std::enable_if<AsStringView<L>::value && AsStringView<R>::value,
+ bool>::type
+operator==(L&& l, R&& r)
+{
+ return (AsStringView<L>::view(std::forward<L>(l)) ==
+ AsStringView<R>::view(std::forward<R>(r)));
+}
+
+template <typename L, typename R>
+typename std::enable_if<AsStringView<L>::value && AsStringView<R>::value,
+ bool>::type
+operator!=(L&& l, R&& r)
+{
+ return (AsStringView<L>::view(std::forward<L>(l)) !=
+ AsStringView<R>::view(std::forward<R>(r)));
+}
+
+template <typename L, typename R>
+typename std::enable_if<AsStringView<L>::value && AsStringView<R>::value,
+ bool>::type
+operator<(L&& l, R&& r)
+{
+ return (AsStringView<L>::view(std::forward<L>(l)) <
+ AsStringView<R>::view(std::forward<R>(r)));
+}
+
+template <typename L, typename R>
+typename std::enable_if<AsStringView<L>::value && AsStringView<R>::value,
+ bool>::type
+operator<=(L&& l, R&& r)
+{
+ return (AsStringView<L>::view(std::forward<L>(l)) <=
+ AsStringView<R>::view(std::forward<R>(r)));
+}
+
+template <typename L, typename R>
+typename std::enable_if<AsStringView<L>::value && AsStringView<R>::value,
+ bool>::type
+operator>(L&& l, R&& r)
+{
+ return (AsStringView<L>::view(std::forward<L>(l)) >
+ AsStringView<R>::view(std::forward<R>(r)));
+}
+
+template <typename L, typename R>
+typename std::enable_if<AsStringView<L>::value && AsStringView<R>::value,
+ bool>::type
+operator>=(L&& l, R&& r)
+{
+ return (AsStringView<L>::view(std::forward<L>(l)) >=
+ AsStringView<R>::view(std::forward<R>(r)));
+}
+
+std::ostream& operator<<(std::ostream& os, String const& s);
+std::string& operator+=(std::string& self, String const& s);
+
+template <typename L, typename R>
+struct StringOpPlus
+{
+ L l;
+ R r;
+#if defined(__SUNPRO_CC)
+ StringOpPlus(L in_l, R in_r)
+ : l(in_l)
+ , r(in_r)
+ {
+ }
+#endif
+ operator std::string() const;
+ std::string::size_type size() const { return l.size() + r.size(); }
+};
+
+template <typename T>
+struct StringAdd
+{
+ static const bool value = AsStringView<T>::value;
+ using temp_type = string_view;
+ template <typename S>
+ static temp_type temp(S&& s)
+ {
+ return AsStringView<T>::view(std::forward<S>(s));
+ }
+};
+
+template <typename L, typename R>
+struct StringAdd<StringOpPlus<L, R>> : std::true_type
+{
+ using temp_type = StringOpPlus<L, R> const&;
+ static temp_type temp(temp_type s) { return s; }
+};
+
+template <typename L, typename R>
+StringOpPlus<L, R>::operator std::string() const
+{
+ std::string s;
+ s.reserve(size());
+ s += *this;
+ return s;
+}
+
+template <typename L, typename R>
+std::string& operator+=(std::string& s, StringOpPlus<L, R> const& a)
+{
+ s.reserve(s.size() + a.size());
+ s += a.l;
+ s += a.r;
+ return s;
+}
+
+template <typename L, typename R>
+String& operator+=(String& s, StringOpPlus<L, R> const& a)
+{
+ std::string r;
+ r.reserve(s.size() + a.size());
+ r.assign(s.data(), s.size());
+ r += a.l;
+ r += a.r;
+ s = std::move(r);
+ return s;
+}
+
+template <typename L, typename R>
+std::ostream& operator<<(std::ostream& os, StringOpPlus<L, R> const& a)
+{
+ return os << a.l << a.r;
+}
+
+template <typename L, typename R>
+struct IntoString<StringOpPlus<L, R>> : std::true_type
+{
+ static std::string into_string(StringOpPlus<L, R> const& a) { return a; }
+};
+
+template <typename L, typename R>
+typename std::enable_if<StringAdd<L>::value && StringAdd<R>::value,
+ StringOpPlus<typename StringAdd<L>::temp_type,
+ typename StringAdd<R>::temp_type>>::type
+operator+(L&& l, R&& r)
+{
+ return { StringAdd<L>::temp(std::forward<L>(l)),
+ StringAdd<R>::temp(std::forward<R>(r)) };
+}
+
+template <typename LL, typename LR, typename R>
+typename std::enable_if<AsStringView<R>::value, bool>::type operator==(
+ StringOpPlus<LL, LR> const& l, R&& r)
+{
+ return std::string(l) == AsStringView<R>::view(std::forward<R>(r));
+}
+
+template <typename L, typename RL, typename RR>
+typename std::enable_if<AsStringView<L>::value, bool>::type operator==(
+ L&& l, StringOpPlus<RL, RR> const& r)
+{
+ return AsStringView<L>::view(std::forward<L>(l)) == std::string(r);
+}
+
+} // namespace cm
+
+namespace std {
+
+template <>
+struct hash<cm::String>
+{
+ using argument_type = cm::String;
+ using result_type = size_t;
+
+ result_type operator()(argument_type const& s) const noexcept
+ {
+ result_type const h(std::hash<cm::string_view>{}(s.view()));
+ return h;
+ }
+};
+}
+
+#endif
diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx
new file mode 100644
index 000000000..bb6dcd734
--- /dev/null
+++ b/Source/cmStringAlgorithms.cxx
@@ -0,0 +1,325 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmStringAlgorithms.h"
+
+#include <algorithm>
+#include <cerrno>
+#include <cstddef>
+#include <cstdio>
+#include <cstdlib>
+
+std::string cmTrimWhitespace(cm::string_view str)
+{
+ auto start = str.begin();
+ while (start != str.end() && cmIsSpace(*start)) {
+ ++start;
+ }
+ if (start == str.end()) {
+ return std::string();
+ }
+ auto stop = str.end() - 1;
+ while (cmIsSpace(*stop)) {
+ --stop;
+ }
+ return std::string(start, stop + 1);
+}
+
+std::string cmRemoveQuotes(cm::string_view str)
+{
+ // We process only strings that have two quotes at least.
+ // Also front() and back() are only defined behavior on non empty strings.
+ if (str.size() >= 2 && //
+ str.front() == '"' && //
+ str.back() == '"') {
+ // Remove a quote from the front and back
+ str.remove_prefix(1);
+ str.remove_suffix(1);
+ }
+ return std::string(str);
+}
+
+std::string cmEscapeQuotes(cm::string_view str)
+{
+ std::string result;
+ result.reserve(str.size());
+ for (const char ch : str) {
+ if (ch == '"') {
+ result += '\\';
+ }
+ result += ch;
+ }
+ return result;
+}
+
+std::vector<std::string> cmTokenize(cm::string_view str, cm::string_view sep)
+{
+ std::vector<std::string> tokens;
+ cm::string_view::size_type tokend = 0;
+
+ do {
+ cm::string_view::size_type tokstart = str.find_first_not_of(sep, tokend);
+ if (tokstart == cm::string_view::npos) {
+ break; // no more tokens
+ }
+ tokend = str.find_first_of(sep, tokstart);
+ if (tokend == cm::string_view::npos) {
+ tokens.emplace_back(str.substr(tokstart));
+ } else {
+ tokens.emplace_back(str.substr(tokstart, tokend - tokstart));
+ }
+ } while (tokend != cm::string_view::npos);
+
+ if (tokens.empty()) {
+ tokens.emplace_back();
+ }
+ return tokens;
+}
+
+void cmExpandList(cm::string_view arg, std::vector<std::string>& argsOut,
+ bool emptyArgs)
+{
+ // If argument is empty, it is an empty list.
+ if (!emptyArgs && arg.empty()) {
+ return;
+ }
+
+ // if there are no ; in the name then just copy the current string
+ if (arg.find(';') == cm::string_view::npos) {
+ argsOut.emplace_back(arg);
+ return;
+ }
+
+ std::string newArg;
+ // Break the string at non-escaped semicolons not nested in [].
+ int squareNesting = 0;
+ cm::string_view::iterator last = arg.begin();
+ cm::string_view::iterator const cend = arg.end();
+ for (cm::string_view::iterator c = last; c != cend; ++c) {
+ switch (*c) {
+ case '\\': {
+ // We only want to allow escaping of semicolons. Other
+ // escapes should not be processed here.
+ cm::string_view::iterator cnext = c + 1;
+ if ((cnext != cend) && *cnext == ';') {
+ newArg.append(last, c);
+ // Skip over the escape character
+ last = cnext;
+ c = cnext;
+ }
+ } break;
+ case '[': {
+ ++squareNesting;
+ } break;
+ case ']': {
+ --squareNesting;
+ } break;
+ case ';': {
+ // Break the string here if we are not nested inside square
+ // brackets.
+ if (squareNesting == 0) {
+ newArg.append(last, c);
+ // Skip over the semicolon
+ last = c + 1;
+ if (!newArg.empty() || emptyArgs) {
+ // Add the last argument if the string is not empty.
+ argsOut.push_back(newArg);
+ newArg.clear();
+ }
+ }
+ } break;
+ default: {
+ // Just append this character.
+ } break;
+ }
+ }
+ newArg.append(last, cend);
+ if (!newArg.empty() || emptyArgs) {
+ // Add the last argument if the string is not empty.
+ argsOut.push_back(std::move(newArg));
+ }
+}
+
+std::vector<std::string> cmExpandedList(cm::string_view arg, bool emptyArgs)
+{
+ std::vector<std::string> argsOut;
+ cmExpandList(arg, argsOut, emptyArgs);
+ return argsOut;
+}
+
+namespace {
+template <std::size_t N, typename T>
+inline void MakeDigits(cm::string_view& view, char (&digits)[N],
+ const char* pattern, T value)
+{
+ int res = std::snprintf(digits, N, pattern, value);
+ if (res > 0 && res < static_cast<int>(N)) {
+ view = cm::string_view(digits, static_cast<std::size_t>(res));
+ }
+}
+} // unnamed namespace
+
+cmAlphaNum::cmAlphaNum(int val)
+{
+ MakeDigits(View_, Digits_, "%i", val);
+}
+
+cmAlphaNum::cmAlphaNum(unsigned int val)
+{
+ MakeDigits(View_, Digits_, "%u", val);
+}
+
+cmAlphaNum::cmAlphaNum(long int val)
+{
+ MakeDigits(View_, Digits_, "%li", val);
+}
+
+cmAlphaNum::cmAlphaNum(unsigned long int val)
+{
+ MakeDigits(View_, Digits_, "%lu", val);
+}
+
+cmAlphaNum::cmAlphaNum(long long int val)
+{
+ MakeDigits(View_, Digits_, "%lli", val);
+}
+
+cmAlphaNum::cmAlphaNum(unsigned long long int val)
+{
+ MakeDigits(View_, Digits_, "%llu", val);
+}
+
+cmAlphaNum::cmAlphaNum(float val)
+{
+ MakeDigits(View_, Digits_, "%g", static_cast<double>(val));
+}
+
+cmAlphaNum::cmAlphaNum(double val)
+{
+ MakeDigits(View_, Digits_, "%g", val);
+}
+
+std::string cmCatViews(std::initializer_list<cm::string_view> views)
+{
+ std::size_t total_size = 0;
+ for (cm::string_view const& view : views) {
+ total_size += view.size();
+ }
+
+ std::string result(total_size, '\0');
+ std::string::iterator sit = result.begin();
+ for (cm::string_view const& view : views) {
+ sit = std::copy_n(view.data(), view.size(), sit);
+ }
+ return result;
+}
+
+bool cmIsInternallyOn(cm::string_view val)
+{
+ return (val.size() == 4) && //
+ (val[0] == 'I' || val[0] == 'i') && //
+ (val[1] == '_') && //
+ (val[2] == 'O' || val[2] == 'o') && //
+ (val[3] == 'N' || val[3] == 'n');
+}
+
+bool cmIsNOTFOUND(cm::string_view val)
+{
+ return (val == "NOTFOUND") || cmHasLiteralSuffix(val, "-NOTFOUND");
+}
+
+bool cmIsOn(cm::string_view val)
+{
+ switch (val.size()) {
+ case 1:
+ return val[0] == '1' || val[0] == 'Y' || val[0] == 'y';
+ case 2:
+ return //
+ (val[0] == 'O' || val[0] == 'o') && //
+ (val[1] == 'N' || val[1] == 'n');
+ case 3:
+ return //
+ (val[0] == 'Y' || val[0] == 'y') && //
+ (val[1] == 'E' || val[1] == 'e') && //
+ (val[2] == 'S' || val[2] == 's');
+ case 4:
+ return //
+ (val[0] == 'T' || val[0] == 't') && //
+ (val[1] == 'R' || val[1] == 'r') && //
+ (val[2] == 'U' || val[2] == 'u') && //
+ (val[3] == 'E' || val[3] == 'e');
+ default:
+ break;
+ }
+
+ return false;
+}
+
+bool cmIsOff(cm::string_view val)
+{
+ switch (val.size()) {
+ case 0:
+ return true;
+ case 1:
+ return val[0] == '0' || val[0] == 'N' || val[0] == 'n';
+ case 2:
+ return //
+ (val[0] == 'N' || val[0] == 'n') && //
+ (val[1] == 'O' || val[1] == 'o');
+ case 3:
+ return //
+ (val[0] == 'O' || val[0] == 'o') && //
+ (val[1] == 'F' || val[1] == 'f') && //
+ (val[2] == 'F' || val[2] == 'f');
+ case 5:
+ return //
+ (val[0] == 'F' || val[0] == 'f') && //
+ (val[1] == 'A' || val[1] == 'a') && //
+ (val[2] == 'L' || val[2] == 'l') && //
+ (val[3] == 'S' || val[3] == 's') && //
+ (val[4] == 'E' || val[4] == 'e');
+ case 6:
+ return //
+ (val[0] == 'I' || val[0] == 'i') && //
+ (val[1] == 'G' || val[1] == 'g') && //
+ (val[2] == 'N' || val[2] == 'n') && //
+ (val[3] == 'O' || val[3] == 'o') && //
+ (val[4] == 'R' || val[4] == 'r') && //
+ (val[5] == 'E' || val[5] == 'e');
+ default:
+ break;
+ }
+
+ return cmIsNOTFOUND(val);
+}
+
+bool cmStrToLong(const char* str, long* value)
+{
+ errno = 0;
+ char* endp;
+ *value = strtol(str, &endp, 10);
+ return (*endp == '\0') && (endp != str) && (errno == 0);
+}
+
+bool cmStrToLong(std::string const& str, long* value)
+{
+ return cmStrToLong(str.c_str(), value);
+}
+
+bool cmStrToULong(const char* str, unsigned long* value)
+{
+ errno = 0;
+ char* endp;
+ while (cmIsSpace(*str)) {
+ ++str;
+ }
+ if (*str == '-') {
+ return false;
+ }
+ *value = strtoul(str, &endp, 10);
+ return (*endp == '\0') && (endp != str) && (errno == 0);
+}
+
+bool cmStrToULong(std::string const& str, unsigned long* value)
+{
+ return cmStrToULong(str.c_str(), value);
+}
diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h
new file mode 100644
index 000000000..0e405dea6
--- /dev/null
+++ b/Source/cmStringAlgorithms.h
@@ -0,0 +1,294 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmStringAlgorithms_h
+#define cmStringAlgorithms_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <cctype>
+#include <cstring>
+#include <initializer_list>
+#include <sstream>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include <cm/string_view>
+
+#include "cmRange.h"
+
+/** String range type. */
+using cmStringRange = cmRange<std::vector<std::string>::const_iterator>;
+
+/** Callable string comparison struct. */
+struct cmStrCmp
+{
+ cmStrCmp(std::string str)
+ : Test_(std::move(str))
+ {
+ }
+
+ bool operator()(cm::string_view sv) const { return Test_ == sv; }
+
+private:
+ std::string const Test_;
+};
+
+/** Returns true if the character @a ch is a whitespace character. **/
+inline bool cmIsSpace(char ch)
+{
+ return ((ch & 0x80) == 0) && std::isspace(ch);
+}
+
+/** Returns a string that has whitespace removed from the start and the end. */
+std::string cmTrimWhitespace(cm::string_view str);
+
+/** Returns a string that has quotes removed from the start and the end. */
+std::string cmRemoveQuotes(cm::string_view str);
+
+/** Escape quotes in a string. */
+std::string cmEscapeQuotes(cm::string_view str);
+
+/** Joins elements of a range with separator into a single string. */
+template <typename Range>
+std::string cmJoin(Range const& rng, cm::string_view separator)
+{
+ if (rng.empty()) {
+ return std::string();
+ }
+
+ std::ostringstream os;
+ auto it = rng.begin();
+ auto const end = rng.end();
+ os << *it;
+ while (++it != end) {
+ os << separator << *it;
+ }
+ return os.str();
+}
+
+/** 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.
+ */
+void cmExpandList(cm::string_view arg, std::vector<std::string>& argsOut,
+ bool emptyArgs = false);
+
+/**
+ * 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)
+{
+ for (; first != last; ++first) {
+ ExpandList(*first, argsOut);
+ }
+}
+
+/**
+ * Same as cmExpandList but a new vector is created containing
+ * the expanded arguments from the string @a arg.
+ */
+std::vector<std::string> cmExpandedList(cm::string_view arg,
+ bool emptyArgs = false);
+
+/**
+ * Same as cmExpandList but a new vector is created containing the expanded
+ * versions of all arguments in the string range [@a first, @a last).
+ */
+template <class InputIt>
+std::vector<std::string> cmExpandedLists(InputIt first, InputIt last)
+{
+ std::vector<std::string> argsOut;
+ for (; first != last; ++first) {
+ cmExpandList(*first, argsOut);
+ }
+ return argsOut;
+}
+
+/** Concatenate string pieces into a single string. */
+std::string cmCatViews(std::initializer_list<cm::string_view> views);
+
+/** Utility class for cmStrCat. */
+class cmAlphaNum
+{
+public:
+ cmAlphaNum(cm::string_view view)
+ : View_(view)
+ {
+ }
+ cmAlphaNum(std::string const& str)
+ : View_(str)
+ {
+ }
+ cmAlphaNum(const char* str)
+ : View_(str)
+ {
+ }
+ cmAlphaNum(char ch)
+ : View_(Digits_, 1)
+ {
+ Digits_[0] = ch;
+ }
+ cmAlphaNum(int val);
+ cmAlphaNum(unsigned int val);
+ cmAlphaNum(long int val);
+ cmAlphaNum(unsigned long int val);
+ cmAlphaNum(long long int val);
+ cmAlphaNum(unsigned long long int val);
+ cmAlphaNum(float val);
+ cmAlphaNum(double val);
+
+ cm::string_view View() const { return View_; }
+
+private:
+ cm::string_view View_;
+ char Digits_[32];
+};
+
+/** Concatenate string pieces and numbers into a single string. */
+template <typename... AV>
+inline std::string cmStrCat(cmAlphaNum const& a, cmAlphaNum const& b,
+ AV const&... args)
+{
+ return cmCatViews(
+ { a.View(), b.View(), static_cast<cmAlphaNum const&>(args).View()... });
+}
+
+/** Joins wrapped elements of a range with separator into a single string. */
+template <typename Range>
+std::string cmWrap(cm::string_view prefix, Range const& rng,
+ cm::string_view suffix, cm::string_view sep)
+{
+ if (rng.empty()) {
+ return std::string();
+ }
+ return cmCatViews(
+ { prefix, cmJoin(rng, cmCatViews({ suffix, sep, prefix })), suffix });
+}
+
+/** Joins wrapped elements of a range with separator into a single string. */
+template <typename Range>
+std::string cmWrap(char prefix, Range const& rng, char suffix,
+ cm::string_view sep)
+{
+ return cmWrap(cm::string_view(&prefix, 1), rng, cm::string_view(&suffix, 1),
+ sep);
+}
+
+/**
+ * Does a string indicates that CMake/CPack/CTest internally
+ * forced this value. This is not the same as On, but this
+ * may be considered as "internally switched on".
+ */
+bool cmIsInternallyOn(cm::string_view val);
+inline bool cmIsInternallyOn(const char* val)
+{
+ if (!val) {
+ return false;
+ }
+ return cmIsInternallyOn(cm::string_view(val));
+}
+
+/** Return true if value is NOTFOUND or ends in -NOTFOUND. */
+bool cmIsNOTFOUND(cm::string_view val);
+
+/**
+ * Does a string indicate a true or ON value? This is not the same as ifdef.
+ */
+bool cmIsOn(cm::string_view val);
+inline bool cmIsOn(const char* val)
+{
+ if (!val) {
+ return false;
+ }
+ return cmIsOn(cm::string_view(val));
+}
+
+/**
+ * Does a string indicate a false or off value ? Note that this is
+ * not the same as !IsOn(...) because there are a number of
+ * ambiguous values such as "/usr/local/bin" a path will result in
+ * IsON and IsOff both returning false. Note that the special path
+ * NOTFOUND, *-NOTFOUND or IGNORE will cause IsOff to return true.
+ */
+bool cmIsOff(cm::string_view val);
+inline bool cmIsOff(const char* val)
+{
+ if (!val) {
+ return true;
+ }
+ return cmIsOff(cm::string_view(val));
+}
+
+/** Returns true if string @a str starts with the character @a prefix. */
+inline bool cmHasPrefix(cm::string_view str, char prefix)
+{
+ return !str.empty() && (str.front() == prefix);
+}
+
+/** Returns true if string @a str starts with string @a prefix. */
+inline bool cmHasPrefix(cm::string_view str, cm::string_view prefix)
+{
+ return str.compare(0, prefix.size(), prefix) == 0;
+}
+
+/** Returns true if string @a str starts with string @a prefix. */
+template <size_t N>
+inline bool cmHasLiteralPrefix(cm::string_view str, const char (&prefix)[N])
+{
+ return cmHasPrefix(str, cm::string_view(prefix, N - 1));
+}
+
+/** Returns true if string @a str ends with the character @a suffix. */
+inline bool cmHasSuffix(cm::string_view str, char suffix)
+{
+ return !str.empty() && (str.back() == suffix);
+}
+
+/** Returns true if string @a str ends with string @a suffix. */
+inline bool cmHasSuffix(cm::string_view str, cm::string_view suffix)
+{
+ return str.size() >= suffix.size() &&
+ str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
+}
+
+/** Returns true if string @a str ends with string @a suffix. */
+template <size_t N>
+inline bool cmHasLiteralSuffix(cm::string_view str, const char (&suffix)[N])
+{
+ return cmHasSuffix(str, cm::string_view(suffix, N - 1));
+}
+
+/** Removes an existing suffix character of from the string @a str. */
+inline void cmStripSuffixIfExists(std::string& str, char suffix)
+{
+ if (cmHasSuffix(str, suffix)) {
+ str.pop_back();
+ }
+}
+
+/** Removes an existing suffix string of from the string @a str. */
+inline void cmStripSuffixIfExists(std::string& str, cm::string_view suffix)
+{
+ if (cmHasSuffix(str, suffix)) {
+ str.resize(str.size() - suffix.size());
+ }
+}
+
+/** Converts a string to long. Expects that the whole string is an integer. */
+bool cmStrToLong(const char* str, long* value);
+bool cmStrToLong(std::string const& str, long* value);
+
+/** Converts a string to unsigned long. Expects that the whole string is an
+ * integer */
+bool cmStrToULong(const char* str, unsigned long* value);
+bool cmStrToULong(std::string const& str, unsigned long* value);
+
+#endif
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 7a097ba21..9212195f5 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -1,130 +1,74 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
+#define _SCL_SECURE_NO_WARNINGS
+
#include "cmStringCommand.h"
+#include <algorithm>
+#include <cctype>
+#include <cstdio>
+#include <cstdlib>
+#include <memory>
+
+#include <cm/iterator>
+
#include "cmsys/RegularExpression.hxx"
-#include <ctype.h>
-#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include "cmAlgorithms.h"
+#include "cm_static_string_view.hxx"
+
#include "cmCryptoHash.h"
+#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
+#include "cmStringReplaceHelper.h"
+#include "cmSubcommandTable.h"
#include "cmSystemTools.h"
#include "cmTimestamp.h"
#include "cmUuid.h"
-#include "cm_auto_ptr.hxx"
-class cmExecutionStatus;
+namespace {
-bool cmStringCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
-{
- if (args.empty()) {
- this->SetError("must be called with at least one argument.");
- return false;
- }
+bool RegexMatch(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+bool RegexMatchAll(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+bool RegexReplace(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
- const std::string& subCommand = args[0];
- if (subCommand == "REGEX") {
- return this->HandleRegexCommand(args);
- }
- if (subCommand == "REPLACE") {
- return this->HandleReplaceCommand(args);
- }
- if (subCommand == "MD5" || subCommand == "SHA1" || subCommand == "SHA224" ||
- subCommand == "SHA256" || subCommand == "SHA384" ||
- subCommand == "SHA512" || subCommand == "SHA3_224" ||
- subCommand == "SHA3_256" || subCommand == "SHA3_384" ||
- subCommand == "SHA3_512") {
- return this->HandleHashCommand(args);
- }
- if (subCommand == "TOLOWER") {
- return this->HandleToUpperLowerCommand(args, false);
- }
- if (subCommand == "TOUPPER") {
- return this->HandleToUpperLowerCommand(args, true);
- }
- if (subCommand == "COMPARE") {
- return this->HandleCompareCommand(args);
- }
- if (subCommand == "ASCII") {
- return this->HandleAsciiCommand(args);
- }
- if (subCommand == "CONFIGURE") {
- return this->HandleConfigureCommand(args);
- }
- if (subCommand == "LENGTH") {
- return this->HandleLengthCommand(args);
- }
- if (subCommand == "APPEND") {
- return this->HandleAppendCommand(args);
- }
- if (subCommand == "CONCAT") {
- return this->HandleConcatCommand(args);
- }
- if (subCommand == "SUBSTRING") {
- return this->HandleSubstringCommand(args);
- }
- if (subCommand == "STRIP") {
- return this->HandleStripCommand(args);
- }
- if (subCommand == "RANDOM") {
- return this->HandleRandomCommand(args);
- }
- if (subCommand == "FIND") {
- return this->HandleFindCommand(args);
- }
- if (subCommand == "TIMESTAMP") {
- return this->HandleTimestampCommand(args);
- }
- if (subCommand == "MAKE_C_IDENTIFIER") {
- return this->HandleMakeCIdentifierCommand(args);
- }
- if (subCommand == "GENEX_STRIP") {
- return this->HandleGenexStripCommand(args);
- }
- if (subCommand == "UUID") {
- return this->HandleUuidCommand(args);
- }
+bool joinImpl(std::vector<std::string> const& args, std::string const& glue,
+ size_t varIdx, cmMakefile& makefile);
- std::string e = "does not recognize sub-command " + subCommand;
- this->SetError(e);
- return false;
-}
-
-bool cmStringCommand::HandleHashCommand(std::vector<std::string> const& args)
+bool HandleHashCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
if (args.size() != 3) {
- std::ostringstream e;
- e << args[0] << " requires an output variable and an input string";
- this->SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " requires an output variable and an input string"));
return false;
}
- CM_AUTO_PTR<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
- if (hash.get()) {
+ std::unique_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0]));
+ if (hash) {
std::string out = hash->HashString(args[2]);
- this->Makefile->AddDefinition(args[1], out.c_str());
+ status.GetMakefile().AddDefinition(args[1], out);
return true;
}
return false;
#else
- std::ostringstream e;
- e << args[0] << " not available during bootstrap";
- this->SetError(e.str().c_str());
+ status.SetError(cmStrCat(args[0], " not available during bootstrap"));
return false;
#endif
}
-bool cmStringCommand::HandleToUpperLowerCommand(
- std::vector<std::string> const& args, bool toUpper)
+bool HandleToUpperLowerCommand(std::vector<std::string> const& args,
+ bool toUpper, cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("no output variable specified");
+ status.SetError("no output variable specified");
return false;
}
@@ -138,45 +82,57 @@ bool cmStringCommand::HandleToUpperLowerCommand(
}
// Store the output in the provided variable.
- this->Makefile->AddDefinition(outvar, output.c_str());
+ status.GetMakefile().AddDefinition(outvar, output);
return true;
}
-bool cmStringCommand::HandleAsciiCommand(std::vector<std::string> const& args)
+bool HandleToUpperCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleToUpperLowerCommand(args, true, status);
+}
+
+bool HandleToLowerCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return HandleToUpperLowerCommand(args, false, status);
+}
+
+bool HandleAsciiCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("No output variable specified");
+ status.SetError("No output variable specified");
return false;
}
std::string::size_type cc;
- std::string const& outvar = args[args.size() - 1];
+ std::string const& outvar = args.back();
std::string output;
for (cc = 1; cc < args.size() - 1; cc++) {
int ch = atoi(args[cc].c_str());
if (ch > 0 && ch < 256) {
output += static_cast<char>(ch);
} else {
- std::string error = "Character with code ";
- error += args[cc];
- error += " does not exist.";
- this->SetError(error);
+ std::string error =
+ cmStrCat("Character with code ", args[cc], " does not exist.");
+ status.SetError(error);
return false;
}
}
// Store the output in the provided variable.
- this->Makefile->AddDefinition(outvar, output.c_str());
+ status.GetMakefile().AddDefinition(outvar, output);
return true;
}
-bool cmStringCommand::HandleConfigureCommand(
- std::vector<std::string> const& args)
+bool HandleConfigureCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("No input string specified.");
+ status.SetError("No input string specified.");
return false;
}
if (args.size() < 3) {
- this->SetError("No output variable specified.");
+ status.SetError("No output variable specified.");
return false;
}
@@ -189,75 +145,75 @@ bool cmStringCommand::HandleConfigureCommand(
} else if (args[i] == "ESCAPE_QUOTES") {
escapeQuotes = true;
} else {
- std::ostringstream err;
- err << "Unrecognized argument \"" << args[i] << "\"";
- this->SetError(err.str());
+ status.SetError(cmStrCat("Unrecognized argument \"", args[i], "\""));
return false;
}
}
// Configure the string.
std::string output;
- this->Makefile->ConfigureString(args[1], output, atOnly, escapeQuotes);
+ status.GetMakefile().ConfigureString(args[1], output, atOnly, escapeQuotes);
// Store the output in the provided variable.
- this->Makefile->AddDefinition(args[2], output.c_str());
+ status.GetMakefile().AddDefinition(args[2], output);
return true;
}
-bool cmStringCommand::HandleRegexCommand(std::vector<std::string> const& args)
+bool HandleRegexCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("sub-command REGEX requires a mode to be specified.");
+ status.SetError("sub-command REGEX requires a mode to be specified.");
return false;
}
std::string const& mode = args[1];
if (mode == "MATCH") {
if (args.size() < 5) {
- this->SetError("sub-command REGEX, mode MATCH needs "
- "at least 5 arguments total to command.");
+ status.SetError("sub-command REGEX, mode MATCH needs "
+ "at least 5 arguments total to command.");
return false;
}
- return this->RegexMatch(args);
+ return RegexMatch(args, status);
}
if (mode == "MATCHALL") {
if (args.size() < 5) {
- this->SetError("sub-command REGEX, mode MATCHALL needs "
- "at least 5 arguments total to command.");
+ status.SetError("sub-command REGEX, mode MATCHALL needs "
+ "at least 5 arguments total to command.");
return false;
}
- return this->RegexMatchAll(args);
+ return RegexMatchAll(args, status);
}
if (mode == "REPLACE") {
if (args.size() < 6) {
- this->SetError("sub-command REGEX, mode REPLACE needs "
- "at least 6 arguments total to command.");
+ status.SetError("sub-command REGEX, mode REPLACE needs "
+ "at least 6 arguments total to command.");
return false;
}
- return this->RegexReplace(args);
+ return RegexReplace(args, status);
}
std::string e = "sub-command REGEX does not recognize mode " + mode;
- this->SetError(e);
+ status.SetError(e);
return false;
}
-bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
+bool RegexMatch(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
//"STRING(REGEX MATCH <regular_expression> <output variable>
// <input> [<input>...])\n";
std::string const& regex = args[2];
std::string const& outvar = args[3];
- this->Makefile->ClearMatches();
+ status.GetMakefile().ClearMatches();
// Compile the regular expression.
cmsys::RegularExpression re;
if (!re.compile(regex.c_str())) {
std::string e =
"sub-command REGEX, mode MATCH failed to compile regex \"" + regex +
"\".";
- this->SetError(e);
+ status.SetError(e);
return false;
}
@@ -266,39 +222,40 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
// Scan through the input for all matches.
std::string output;
- if (re.find(input.c_str())) {
- this->Makefile->StoreMatches(re);
+ if (re.find(input)) {
+ status.GetMakefile().StoreMatches(re);
std::string::size_type l = re.start();
std::string::size_type r = re.end();
if (r - l == 0) {
std::string e = "sub-command REGEX, mode MATCH regex \"" + regex +
"\" matched an empty string.";
- this->SetError(e);
+ status.SetError(e);
return false;
}
output = input.substr(l, r - l);
}
// Store the output in the provided variable.
- this->Makefile->AddDefinition(outvar, output.c_str());
+ status.GetMakefile().AddDefinition(outvar, output);
return true;
}
-bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
+bool RegexMatchAll(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
//"STRING(REGEX MATCHALL <regular_expression> <output variable> <input>
// [<input>...])\n";
std::string const& regex = args[2];
std::string const& outvar = args[3];
- this->Makefile->ClearMatches();
+ status.GetMakefile().ClearMatches();
// Compile the regular expression.
cmsys::RegularExpression re;
if (!re.compile(regex.c_str())) {
std::string e =
"sub-command REGEX, mode MATCHALL failed to compile regex \"" + regex +
"\".";
- this->SetError(e);
+ status.SetError(e);
return false;
}
@@ -309,13 +266,14 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
std::string output;
const char* p = input.c_str();
while (re.find(p)) {
- this->Makefile->StoreMatches(re);
+ status.GetMakefile().ClearMatches();
+ status.GetMakefile().StoreMatches(re);
std::string::size_type l = re.start();
std::string::size_type r = re.end();
if (r - l == 0) {
std::string e = "sub-command REGEX, mode MATCHALL regex \"" + regex +
"\" matched an empty string.";
- this->SetError(e);
+ status.SetError(e);
return false;
}
if (!output.empty()) {
@@ -326,128 +284,58 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
}
// Store the output in the provided variable.
- this->Makefile->AddDefinition(outvar, output.c_str());
+ status.GetMakefile().AddDefinition(outvar, output);
return true;
}
-bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
+bool RegexReplace(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
//"STRING(REGEX REPLACE <regular_expression> <replace_expression>
// <output variable> <input> [<input>...])\n"
std::string const& regex = args[2];
std::string const& replace = args[3];
std::string const& outvar = args[4];
+ cmStringReplaceHelper replaceHelper(regex, replace, &status.GetMakefile());
- // Pull apart the replace expression to find the escaped [0-9] values.
- std::vector<RegexReplacement> replacement;
- std::string::size_type l = 0;
- while (l < replace.length()) {
- std::string::size_type r = replace.find('\\', l);
- if (r == std::string::npos) {
- r = replace.length();
- replacement.push_back(replace.substr(l, r - l));
- } else {
- if (r - l > 0) {
- replacement.push_back(replace.substr(l, r - l));
- }
- if (r == (replace.length() - 1)) {
- this->SetError("sub-command REGEX, mode REPLACE: "
- "replace-expression ends in a backslash.");
- return false;
- }
- if ((replace[r + 1] >= '0') && (replace[r + 1] <= '9')) {
- replacement.push_back(replace[r + 1] - '0');
- } else if (replace[r + 1] == 'n') {
- replacement.push_back("\n");
- } else if (replace[r + 1] == '\\') {
- replacement.push_back("\\");
- } else {
- std::string e = "sub-command REGEX, mode REPLACE: Unknown escape \"";
- e += replace.substr(r, 2);
- e += "\" in replace-expression.";
- this->SetError(e);
- return false;
- }
- r += 2;
- }
- l = r;
+ if (!replaceHelper.IsReplaceExpressionValid()) {
+ status.SetError(
+ "sub-command REGEX, mode REPLACE: " + replaceHelper.GetError() + ".");
+ return false;
}
- this->Makefile->ClearMatches();
- // Compile the regular expression.
- cmsys::RegularExpression re;
- if (!re.compile(regex.c_str())) {
+ status.GetMakefile().ClearMatches();
+
+ if (!replaceHelper.IsRegularExpressionValid()) {
std::string e =
"sub-command REGEX, mode REPLACE failed to compile regex \"" + regex +
"\".";
- this->SetError(e);
+ status.SetError(e);
return false;
}
// Concatenate all the last arguments together.
- std::string input = cmJoin(cmMakeRange(args).advance(5), std::string());
-
- // Scan through the input for all matches.
+ const std::string input =
+ cmJoin(cmMakeRange(args).advance(5), std::string());
std::string output;
- std::string::size_type base = 0;
- while (re.find(input.c_str() + base)) {
- this->Makefile->StoreMatches(re);
- std::string::size_type l2 = re.start();
- std::string::size_type r = re.end();
-
- // Concatenate the part of the input that was not matched.
- output += input.substr(base, l2);
-
- // Make sure the match had some text.
- if (r - l2 == 0) {
- std::string e = "sub-command REGEX, mode REPLACE regex \"" + regex +
- "\" matched an empty string.";
- this->SetError(e);
- return false;
- }
- // Concatenate the replacement for the match.
- for (unsigned int i = 0; i < replacement.size(); ++i) {
- if (replacement[i].number < 0) {
- // This is just a plain-text part of the replacement.
- output += replacement[i].value;
- } else {
- // Replace with part of the match.
- int n = replacement[i].number;
- std::string::size_type start = re.start(n);
- std::string::size_type end = re.end(n);
- std::string::size_type len = input.length() - base;
- if ((start != std::string::npos) && (end != std::string::npos) &&
- (start <= len) && (end <= len)) {
- output += input.substr(base + start, end - start);
- } else {
- std::string e =
- "sub-command REGEX, mode REPLACE: replace expression \"" +
- replace + "\" contains an out-of-range escape for regex \"" +
- regex + "\".";
- this->SetError(e);
- return false;
- }
- }
- }
-
- // Move past the match.
- base += r;
+ if (!replaceHelper.Replace(input, output)) {
+ status.SetError(
+ "sub-command REGEX, mode REPLACE: " + replaceHelper.GetError() + ".");
+ return false;
}
- // Concatenate the text after the last match.
- output += input.substr(base, input.length() - base);
-
// Store the output in the provided variable.
- this->Makefile->AddDefinition(outvar, output.c_str());
+ status.GetMakefile().AddDefinition(outvar, output);
return true;
}
-bool cmStringCommand::HandleFindCommand(std::vector<std::string> const& args)
+bool HandleFindCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// check if all required parameters were passed
if (args.size() < 4 || args.size() > 5) {
- this->SetError("sub-command FIND requires 3 or 4 parameters.");
+ status.SetError("sub-command FIND requires 3 or 4 parameters.");
return false;
}
@@ -459,7 +347,7 @@ bool cmStringCommand::HandleFindCommand(std::vector<std::string> const& args)
// if we have 5 arguments the last one must be REVERSE
if (args.size() == 5 && args[4] != "REVERSE") {
- this->SetError("sub-command FIND: unknown last parameter");
+ status.SetError("sub-command FIND: unknown last parameter");
return false;
}
@@ -470,9 +358,9 @@ bool cmStringCommand::HandleFindCommand(std::vector<std::string> const& args)
// ensure that the user cannot accidentally specify REVERSE as a variable
if (outvar == "REVERSE") {
- this->SetError("sub-command FIND does not allow one to select REVERSE as "
- "the output variable. "
- "Maybe you missed the actual output variable?");
+ status.SetError("sub-command FIND does not allow one to select REVERSE as "
+ "the output variable. "
+ "Maybe you missed the actual output variable?");
return false;
}
@@ -484,22 +372,20 @@ bool cmStringCommand::HandleFindCommand(std::vector<std::string> const& args)
pos = sstring.rfind(schar);
}
if (std::string::npos != pos) {
- std::ostringstream s;
- s << pos;
- this->Makefile->AddDefinition(outvar, s.str().c_str());
+ status.GetMakefile().AddDefinition(outvar, std::to_string(pos));
return true;
}
// the character was not found, but this is not really an error
- this->Makefile->AddDefinition(outvar, "-1");
+ status.GetMakefile().AddDefinition(outvar, "-1");
return true;
}
-bool cmStringCommand::HandleCompareCommand(
- std::vector<std::string> const& args)
+bool HandleCompareCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("sub-command COMPARE requires a mode to be specified.");
+ status.SetError("sub-command COMPARE requires a mode to be specified.");
return false;
}
std::string const& mode = args[1];
@@ -507,10 +393,10 @@ bool cmStringCommand::HandleCompareCommand(
(mode == "LESS_EQUAL") || (mode == "GREATER") ||
(mode == "GREATER_EQUAL")) {
if (args.size() < 5) {
- std::string e = "sub-command COMPARE, mode ";
- e += mode;
- e += " needs at least 5 arguments total to command.";
- this->SetError(e);
+ std::string e =
+ cmStrCat("sub-command COMPARE, mode ", mode,
+ " needs at least 5 arguments total to command.");
+ status.SetError(e);
return false;
}
@@ -533,22 +419,22 @@ bool cmStringCommand::HandleCompareCommand(
result = !(left == right);
}
if (result) {
- this->Makefile->AddDefinition(outvar, "1");
+ status.GetMakefile().AddDefinition(outvar, "1");
} else {
- this->Makefile->AddDefinition(outvar, "0");
+ status.GetMakefile().AddDefinition(outvar, "0");
}
return true;
}
std::string e = "sub-command COMPARE does not recognize mode " + mode;
- this->SetError(e);
+ status.SetError(e);
return false;
}
-bool cmStringCommand::HandleReplaceCommand(
- std::vector<std::string> const& args)
+bool HandleReplaceCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 5) {
- this->SetError("sub-command REPLACE requires at least four arguments.");
+ status.SetError("sub-command REPLACE requires at least four arguments.");
return false;
}
@@ -561,15 +447,15 @@ bool cmStringCommand::HandleReplaceCommand(
cmsys::SystemTools::ReplaceString(input, matchExpression.c_str(),
replaceExpression.c_str());
- this->Makefile->AddDefinition(variableName, input.c_str());
+ status.GetMakefile().AddDefinition(variableName, input);
return true;
}
-bool cmStringCommand::HandleSubstringCommand(
- std::vector<std::string> const& args)
+bool HandleSubstringCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 5) {
- this->SetError("sub-command SUBSTRING requires four arguments.");
+ status.SetError("sub-command SUBSTRING requires four arguments.");
return false;
}
@@ -581,28 +467,25 @@ bool cmStringCommand::HandleSubstringCommand(
size_t stringLength = stringValue.size();
int intStringLength = static_cast<int>(stringLength);
if (begin < 0 || begin > intStringLength) {
- std::ostringstream ostr;
- ostr << "begin index: " << begin << " is out of range 0 - "
- << stringLength;
- this->SetError(ostr.str());
+ status.SetError(
+ cmStrCat("begin index: ", begin, " is out of range 0 - ", stringLength));
return false;
}
if (end < -1) {
- std::ostringstream ostr;
- ostr << "end index: " << end << " should be -1 or greater";
- this->SetError(ostr.str());
+ status.SetError(cmStrCat("end index: ", end, " should be -1 or greater"));
return false;
}
- this->Makefile->AddDefinition(variableName,
- stringValue.substr(begin, end).c_str());
+ status.GetMakefile().AddDefinition(variableName,
+ stringValue.substr(begin, end));
return true;
}
-bool cmStringCommand::HandleLengthCommand(std::vector<std::string> const& args)
+bool HandleLengthCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
- this->SetError("sub-command LENGTH requires two arguments.");
+ status.SetError("sub-command LENGTH requires two arguments.");
return false;
}
@@ -613,14 +496,15 @@ bool cmStringCommand::HandleLengthCommand(std::vector<std::string> const& args)
char buffer[1024];
sprintf(buffer, "%d", static_cast<int>(length));
- this->Makefile->AddDefinition(variableName, buffer);
+ status.GetMakefile().AddDefinition(variableName, buffer);
return true;
}
-bool cmStringCommand::HandleAppendCommand(std::vector<std::string> const& args)
+bool HandleAppendCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("sub-command APPEND requires at least one argument.");
+ status.SetError("sub-command APPEND requires at least one argument.");
return false;
}
@@ -632,50 +516,94 @@ bool cmStringCommand::HandleAppendCommand(std::vector<std::string> const& args)
const std::string& variable = args[1];
std::string value;
- const char* oldValue = this->Makefile->GetDefinition(variable);
+ const char* oldValue = status.GetMakefile().GetDefinition(variable);
if (oldValue) {
value = oldValue;
}
value += cmJoin(cmMakeRange(args).advance(2), std::string());
- this->Makefile->AddDefinition(variable, value.c_str());
+ status.GetMakefile().AddDefinition(variable, value);
return true;
}
-bool cmStringCommand::HandleConcatCommand(std::vector<std::string> const& args)
+bool HandlePrependCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("sub-command CONCAT requires at least one argument.");
+ status.SetError("sub-command PREPEND requires at least one argument.");
return false;
}
- std::string const& variableName = args[1];
+ // Skip if nothing to prepend.
+ if (args.size() < 3) {
+ return true;
+ }
+
+ const std::string& variable = args[1];
+
std::string value = cmJoin(cmMakeRange(args).advance(2), std::string());
+ const char* oldValue = status.GetMakefile().GetDefinition(variable);
+ if (oldValue) {
+ value += oldValue;
+ }
+ status.GetMakefile().AddDefinition(variable, value);
+ return true;
+}
- this->Makefile->AddDefinition(variableName, value.c_str());
+bool HandleConcatCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() < 2) {
+ status.SetError("sub-command CONCAT requires at least one argument.");
+ return false;
+ }
+
+ return joinImpl(args, std::string(), 1, status.GetMakefile());
+}
+
+bool HandleJoinCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.size() < 3) {
+ status.SetError("sub-command JOIN requires at least two arguments.");
+ return false;
+ }
+
+ return joinImpl(args, args[1], 2, status.GetMakefile());
+}
+
+bool joinImpl(std::vector<std::string> const& args, std::string const& glue,
+ const size_t varIdx, cmMakefile& makefile)
+{
+ std::string const& variableName = args[varIdx];
+ // NOTE Items to concat/join placed right after the variable for
+ // both `CONCAT` and `JOIN` sub-commands.
+ std::string value = cmJoin(cmMakeRange(args).advance(varIdx + 1), glue);
+
+ makefile.AddDefinition(variableName, value);
return true;
}
-bool cmStringCommand::HandleMakeCIdentifierCommand(
- std::vector<std::string> const& args)
+bool HandleMakeCIdentifierCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
- this->SetError("sub-command MAKE_C_IDENTIFIER requires two arguments.");
+ status.SetError("sub-command MAKE_C_IDENTIFIER requires two arguments.");
return false;
}
const std::string& input = args[1];
const std::string& variableName = args[2];
- this->Makefile->AddDefinition(variableName,
- cmSystemTools::MakeCidentifier(input).c_str());
+ status.GetMakefile().AddDefinition(variableName,
+ cmSystemTools::MakeCidentifier(input));
return true;
}
-bool cmStringCommand::HandleGenexStripCommand(
- std::vector<std::string> const& args)
+bool HandleGenexStripCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
- this->SetError("sub-command GENEX_STRIP requires two arguments.");
+ status.SetError("sub-command GENEX_STRIP requires two arguments.");
return false;
}
@@ -686,14 +614,15 @@ bool cmStringCommand::HandleGenexStripCommand(
const std::string& variableName = args[2];
- this->Makefile->AddDefinition(variableName, result.c_str());
+ status.GetMakefile().AddDefinition(variableName, result);
return true;
}
-bool cmStringCommand::HandleStripCommand(std::vector<std::string> const& args)
+bool HandleStripCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
- this->SetError("sub-command STRIP requires two arguments.");
+ status.SetError("sub-command STRIP requires two arguments.");
return false;
}
@@ -725,15 +654,71 @@ bool cmStringCommand::HandleStripCommand(std::vector<std::string> const& args)
outLength = endPos - startPos + 1;
}
- this->Makefile->AddDefinition(
- variableName, stringValue.substr(startPos, outLength).c_str());
+ status.GetMakefile().AddDefinition(variableName,
+ stringValue.substr(startPos, outLength));
+ return true;
+}
+
+bool HandleRepeatCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ cmMakefile& makefile = status.GetMakefile();
+
+ // `string(REPEAT "<str>" <times> OUTPUT_VARIABLE)`
+ enum ArgPos : std::size_t
+ {
+ SUB_COMMAND,
+ VALUE,
+ TIMES,
+ OUTPUT_VARIABLE,
+ TOTAL_ARGS
+ };
+
+ if (args.size() != ArgPos::TOTAL_ARGS) {
+ makefile.IssueMessage(MessageType::FATAL_ERROR,
+ "sub-command REPEAT requires three arguments.");
+ return true;
+ }
+
+ unsigned long times;
+ if (!cmStrToULong(args[ArgPos::TIMES], &times)) {
+ makefile.IssueMessage(MessageType::FATAL_ERROR,
+ "repeat count is not a positive number.");
+ return true;
+ }
+
+ const auto& stringValue = args[ArgPos::VALUE];
+ const auto& variableName = args[ArgPos::OUTPUT_VARIABLE];
+ const auto inStringLength = stringValue.size();
+
+ std::string result;
+ switch (inStringLength) {
+ case 0u:
+ // Nothing to do for zero length input strings
+ break;
+ case 1u:
+ // NOTE If the string to repeat consists of the only character,
+ // use the appropriate constructor.
+ result = std::string(times, stringValue[0]);
+ break;
+ default:
+ result = std::string(inStringLength * times, char{});
+ for (auto i = 0u; i < times; ++i) {
+ std::copy(cm::cbegin(stringValue), cm::cend(stringValue),
+ &result[i * inStringLength]);
+ }
+ break;
+ }
+
+ makefile.AddDefinition(variableName, result);
return true;
}
-bool cmStringCommand::HandleRandomCommand(std::vector<std::string> const& args)
+bool HandleRandomCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2 || args.size() == 3 || args.size() == 5) {
- this->SetError("sub-command RANDOM requires at least one argument.");
+ status.SetError("sub-command RANDOM requires at least one argument.");
return false;
}
@@ -770,14 +755,14 @@ bool cmStringCommand::HandleRandomCommand(std::vector<std::string> const& args)
double sizeofAlphabet = static_cast<double>(alphabet.size());
if (sizeofAlphabet < 1) {
- this->SetError("sub-command RANDOM invoked with bad alphabet.");
+ status.SetError("sub-command RANDOM invoked with bad alphabet.");
return false;
}
if (length < 1) {
- this->SetError("sub-command RANDOM invoked with bad length.");
+ status.SetError("sub-command RANDOM invoked with bad length.");
return false;
}
- const std::string& variableName = args[args.size() - 1];
+ const std::string& variableName = args.back();
std::vector<char> result;
@@ -787,26 +772,25 @@ bool cmStringCommand::HandleRandomCommand(std::vector<std::string> const& args)
}
const char* alphaPtr = alphabet.c_str();
- int cc;
- for (cc = 0; cc < length; cc++) {
- int idx = (int)(sizeofAlphabet * rand() / (RAND_MAX + 1.0));
+ for (int cc = 0; cc < length; cc++) {
+ int idx = static_cast<int>(sizeofAlphabet * rand() / (RAND_MAX + 1.0));
result.push_back(*(alphaPtr + idx));
}
result.push_back(0);
- this->Makefile->AddDefinition(variableName, &*result.begin());
+ status.GetMakefile().AddDefinition(variableName, result.data());
return true;
}
-bool cmStringCommand::HandleTimestampCommand(
- std::vector<std::string> const& args)
+bool HandleTimestampCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("sub-command TIMESTAMP requires at least one argument.");
+ status.SetError("sub-command TIMESTAMP requires at least one argument.");
return false;
}
if (args.size() > 4) {
- this->SetError("sub-command TIMESTAMP takes at most three arguments.");
+ status.SetError("sub-command TIMESTAMP takes at most three arguments.");
return false;
}
@@ -826,25 +810,26 @@ bool cmStringCommand::HandleTimestampCommand(
} else {
std::string e = " TIMESTAMP sub-command does not recognize option " +
args[argsIndex] + ".";
- this->SetError(e);
+ status.SetError(e);
return false;
}
}
cmTimestamp timestamp;
std::string result = timestamp.CurrentTime(formatString, utcFlag);
- this->Makefile->AddDefinition(outputVariable, result.c_str());
+ status.GetMakefile().AddDefinition(outputVariable, result);
return true;
}
-bool cmStringCommand::HandleUuidCommand(std::vector<std::string> const& args)
+bool HandleUuidCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
unsigned int argsIndex = 1;
if (args.size() < 2) {
- this->SetError("UUID sub-command requires an output variable.");
+ status.SetError("UUID sub-command requires an output variable.");
return false;
}
@@ -859,21 +844,21 @@ bool cmStringCommand::HandleUuidCommand(std::vector<std::string> const& args)
if (args[argsIndex] == "NAMESPACE") {
++argsIndex;
if (argsIndex >= args.size()) {
- this->SetError("UUID sub-command, NAMESPACE requires a value.");
+ status.SetError("UUID sub-command, NAMESPACE requires a value.");
return false;
}
uuidNamespaceString = args[argsIndex++];
} else if (args[argsIndex] == "NAME") {
++argsIndex;
if (argsIndex >= args.size()) {
- this->SetError("UUID sub-command, NAME requires a value.");
+ status.SetError("UUID sub-command, NAME requires a value.");
return false;
}
uuidName = args[argsIndex++];
} else if (args[argsIndex] == "TYPE") {
++argsIndex;
if (argsIndex >= args.size()) {
- this->SetError("UUID sub-command, TYPE requires a value.");
+ status.SetError("UUID sub-command, TYPE requires a value.");
return false;
}
uuidType = args[argsIndex++];
@@ -883,7 +868,7 @@ bool cmStringCommand::HandleUuidCommand(std::vector<std::string> const& args)
} else {
std::string e =
"UUID sub-command does not recognize option " + args[argsIndex] + ".";
- this->SetError(e);
+ status.SetError(e);
return false;
}
}
@@ -893,7 +878,7 @@ bool cmStringCommand::HandleUuidCommand(std::vector<std::string> const& args)
std::vector<unsigned char> uuidNamespace;
if (!uuidGenerator.StringToBinary(uuidNamespaceString, uuidNamespace)) {
- this->SetError("UUID sub-command, malformed NAMESPACE UUID.");
+ status.SetError("UUID sub-command, malformed NAMESPACE UUID.");
return false;
}
@@ -903,12 +888,12 @@ bool cmStringCommand::HandleUuidCommand(std::vector<std::string> const& args)
uuid = uuidGenerator.FromSha1(uuidNamespace, uuidName);
} else {
std::string e = "UUID sub-command, unknown TYPE '" + uuidType + "'.";
- this->SetError(e);
+ status.SetError(e);
return false;
}
if (uuid.empty()) {
- this->SetError("UUID sub-command, generation failed.");
+ status.SetError("UUID sub-command, generation failed.");
return false;
}
@@ -916,12 +901,57 @@ bool cmStringCommand::HandleUuidCommand(std::vector<std::string> const& args)
uuid = cmSystemTools::UpperCase(uuid);
}
- this->Makefile->AddDefinition(outputVariable, uuid.c_str());
+ status.GetMakefile().AddDefinition(outputVariable, uuid);
return true;
#else
- std::ostringstream e;
- e << args[0] << " not available during bootstrap";
- this->SetError(e.str().c_str());
+ status.SetError(cmStrCat(args[0], " not available during bootstrap"));
return false;
#endif
}
+
+} // namespace
+
+bool cmStringCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ if (args.empty()) {
+ status.SetError("must be called with at least one argument.");
+ return false;
+ }
+
+ static cmSubcommandTable const subcommand{
+ { "REGEX"_s, HandleRegexCommand },
+ { "REPLACE"_s, HandleReplaceCommand },
+ { "MD5"_s, HandleHashCommand },
+ { "SHA1"_s, HandleHashCommand },
+ { "SHA224"_s, HandleHashCommand },
+ { "SHA256"_s, HandleHashCommand },
+ { "SHA384"_s, HandleHashCommand },
+ { "SHA512"_s, HandleHashCommand },
+ { "SHA3_224"_s, HandleHashCommand },
+ { "SHA3_256"_s, HandleHashCommand },
+ { "SHA3_384"_s, HandleHashCommand },
+ { "SHA3_512"_s, HandleHashCommand },
+ { "TOLOWER"_s, HandleToLowerCommand },
+ { "TOUPPER"_s, HandleToUpperCommand },
+ { "COMPARE"_s, HandleCompareCommand },
+ { "ASCII"_s, HandleAsciiCommand },
+ { "CONFIGURE"_s, HandleConfigureCommand },
+ { "LENGTH"_s, HandleLengthCommand },
+ { "APPEND"_s, HandleAppendCommand },
+ { "PREPEND"_s, HandlePrependCommand },
+ { "CONCAT"_s, HandleConcatCommand },
+ { "JOIN"_s, HandleJoinCommand },
+ { "SUBSTRING"_s, HandleSubstringCommand },
+ { "STRIP"_s, HandleStripCommand },
+ { "REPEAT"_s, HandleRepeatCommand },
+ { "RANDOM"_s, HandleRandomCommand },
+ { "FIND"_s, HandleFindCommand },
+ { "TIMESTAMP"_s, HandleTimestampCommand },
+ { "MAKE_C_IDENTIFIER"_s, HandleMakeCIdentifierCommand },
+ { "GENEX_STRIP"_s, HandleGenexStripCommand },
+ { "UUID"_s, HandleUuidCommand },
+ };
+
+ return subcommand(args[0], args, status);
+}
diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h
index 88015ad5e..bd71ba293 100644
--- a/Source/cmStringCommand.h
+++ b/Source/cmStringCommand.h
@@ -3,80 +3,18 @@
#ifndef cmStringCommand_h
#define cmStringCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmStringCommand
+/**
* \brief Common string operations
*
*/
-class cmStringCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmStringCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-protected:
- bool HandleConfigureCommand(std::vector<std::string> const& args);
- bool HandleAsciiCommand(std::vector<std::string> const& args);
- bool HandleRegexCommand(std::vector<std::string> const& args);
- bool RegexMatch(std::vector<std::string> const& args);
- bool RegexMatchAll(std::vector<std::string> const& args);
- bool RegexReplace(std::vector<std::string> const& args);
- bool HandleHashCommand(std::vector<std::string> const& args);
- bool HandleToUpperLowerCommand(std::vector<std::string> const& args,
- bool toUpper);
- bool HandleCompareCommand(std::vector<std::string> const& args);
- bool HandleReplaceCommand(std::vector<std::string> const& args);
- bool HandleLengthCommand(std::vector<std::string> const& args);
- bool HandleSubstringCommand(std::vector<std::string> const& args);
- bool HandleAppendCommand(std::vector<std::string> const& args);
- bool HandleConcatCommand(std::vector<std::string> const& args);
- bool HandleStripCommand(std::vector<std::string> const& args);
- bool HandleRandomCommand(std::vector<std::string> const& args);
- bool HandleFindCommand(std::vector<std::string> const& args);
- bool HandleTimestampCommand(std::vector<std::string> const& args);
- bool HandleMakeCIdentifierCommand(std::vector<std::string> const& args);
- bool HandleGenexStripCommand(std::vector<std::string> const& args);
- bool HandleUuidCommand(std::vector<std::string> const& args);
-
- class RegexReplacement
- {
- public:
- RegexReplacement(const char* s)
- : number(-1)
- , value(s)
- {
- }
- RegexReplacement(const std::string& s)
- : number(-1)
- , value(s)
- {
- }
- RegexReplacement(int n)
- : number(n)
- , value()
- {
- }
- RegexReplacement() {}
- int number;
- std::string value;
- };
-};
+bool cmStringCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmStringReplaceHelper.cxx b/Source/cmStringReplaceHelper.cxx
new file mode 100644
index 000000000..998c135e8
--- /dev/null
+++ b/Source/cmStringReplaceHelper.cxx
@@ -0,0 +1,121 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include "cmStringReplaceHelper.h"
+
+#include <sstream>
+#include <utility>
+
+#include "cmMakefile.h"
+
+cmStringReplaceHelper::cmStringReplaceHelper(const std::string& regex,
+ std::string replace_expr,
+ cmMakefile* makefile)
+ : RegExString(regex)
+ , RegularExpression(regex)
+ , ReplaceExpression(std::move(replace_expr))
+ , Makefile(makefile)
+{
+ this->ParseReplaceExpression();
+}
+
+bool cmStringReplaceHelper::Replace(const std::string& input,
+ std::string& output)
+{
+ output.clear();
+
+ // Scan through the input for all matches.
+ std::string::size_type base = 0;
+ while (this->RegularExpression.find(input.c_str() + base)) {
+ if (this->Makefile != nullptr) {
+ this->Makefile->ClearMatches();
+ this->Makefile->StoreMatches(this->RegularExpression);
+ }
+ auto l2 = this->RegularExpression.start();
+ auto r = this->RegularExpression.end();
+
+ // Concatenate the part of the input that was not matched.
+ output += input.substr(base, l2);
+
+ // Make sure the match had some text.
+ if (r - l2 == 0) {
+ std::ostringstream error;
+ error << "regex \"" << this->RegExString << "\" matched an empty string";
+ this->ErrorString = error.str();
+ return false;
+ }
+
+ // Concatenate the replacement for the match.
+ for (const auto& replacement : this->Replacements) {
+ if (replacement.Number < 0) {
+ // This is just a plain-text part of the replacement.
+ output += replacement.Value;
+ } else {
+ // Replace with part of the match.
+ auto n = replacement.Number;
+ auto start = this->RegularExpression.start(n);
+ auto end = this->RegularExpression.end(n);
+ auto len = input.length() - base;
+ if ((start != std::string::npos) && (end != std::string::npos) &&
+ (start <= len) && (end <= len)) {
+ output += input.substr(base + start, end - start);
+ } else {
+ std::ostringstream error;
+ error << "replace expression \"" << this->ReplaceExpression
+ << "\" contains an out-of-range escape for regex \""
+ << this->RegExString << "\"";
+ this->ErrorString = error.str();
+ return false;
+ }
+ }
+ }
+
+ // Move past the match.
+ base += r;
+ }
+
+ // Concatenate the text after the last match.
+ output += input.substr(base, input.length() - base);
+
+ return true;
+}
+
+void cmStringReplaceHelper::ParseReplaceExpression()
+{
+ std::string::size_type l = 0;
+ while (l < this->ReplaceExpression.length()) {
+ auto r = this->ReplaceExpression.find('\\', l);
+ if (r == std::string::npos) {
+ r = this->ReplaceExpression.length();
+ this->Replacements.emplace_back(
+ this->ReplaceExpression.substr(l, r - l));
+ } else {
+ if (r - l > 0) {
+ this->Replacements.emplace_back(
+ this->ReplaceExpression.substr(l, r - l));
+ }
+ if (r == (this->ReplaceExpression.length() - 1)) {
+ this->ValidReplaceExpression = false;
+ this->ErrorString = "replace-expression ends in a backslash";
+ return;
+ }
+ if ((this->ReplaceExpression[r + 1] >= '0') &&
+ (this->ReplaceExpression[r + 1] <= '9')) {
+ this->Replacements.emplace_back(this->ReplaceExpression[r + 1] - '0');
+ } else if (this->ReplaceExpression[r + 1] == 'n') {
+ this->Replacements.emplace_back("\n");
+ } else if (this->ReplaceExpression[r + 1] == '\\') {
+ this->Replacements.emplace_back("\\");
+ } else {
+ this->ValidReplaceExpression = false;
+ std::ostringstream error;
+ error << "Unknown escape \"" << this->ReplaceExpression.substr(r, 2)
+ << "\" in replace-expression";
+ this->ErrorString = error.str();
+ return;
+ }
+ r += 2;
+ }
+ l = r;
+ }
+}
diff --git a/Source/cmStringReplaceHelper.h b/Source/cmStringReplaceHelper.h
new file mode 100644
index 000000000..74d481d70
--- /dev/null
+++ b/Source/cmStringReplaceHelper.h
@@ -0,0 +1,68 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmStringReplaceHelper_h
+#define cmStringReplaceHelper_h
+
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "cmsys/RegularExpression.hxx"
+
+class cmMakefile;
+
+class cmStringReplaceHelper
+{
+public:
+ cmStringReplaceHelper(const std::string& regex, std::string replace_expr,
+ cmMakefile* makefile = nullptr);
+
+ bool IsRegularExpressionValid() const
+ {
+ return this->RegularExpression.is_valid();
+ }
+ bool IsReplaceExpressionValid() const
+ {
+ return this->ValidReplaceExpression;
+ }
+
+ bool Replace(const std::string& input, std::string& output);
+
+ const std::string& GetError() { return this->ErrorString; }
+
+private:
+ class RegexReplacement
+ {
+ public:
+ RegexReplacement(const char* s)
+ : Number(-1)
+ , Value(s)
+ {
+ }
+ RegexReplacement(std::string s)
+ : Number(-1)
+ , Value(std::move(s))
+ {
+ }
+ RegexReplacement(int n)
+ : Number(n)
+ {
+ }
+ RegexReplacement() = default;
+
+ int Number;
+ std::string Value;
+ };
+
+ void ParseReplaceExpression();
+
+ std::string ErrorString;
+ std::string RegExString;
+ cmsys::RegularExpression RegularExpression;
+ bool ValidReplaceExpression = true;
+ std::string ReplaceExpression;
+ std::vector<RegexReplacement> Replacements;
+ cmMakefile* Makefile = nullptr;
+};
+
+#endif
diff --git a/Source/cmSubcommandTable.cxx b/Source/cmSubcommandTable.cxx
new file mode 100644
index 000000000..f6194f816
--- /dev/null
+++ b/Source/cmSubcommandTable.cxx
@@ -0,0 +1,31 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmSubcommandTable.h"
+
+#include <algorithm>
+
+#include "cmExecutionStatus.h"
+#include "cmStringAlgorithms.h"
+
+cmSubcommandTable::cmSubcommandTable(std::initializer_list<InitElem> init)
+ : Impl(init.begin(), init.end())
+{
+ std::sort(this->Impl.begin(), this->Impl.end(),
+ [](Elem const& left, Elem const& right) {
+ return left.first < right.first;
+ });
+}
+
+bool cmSubcommandTable::operator()(cm::string_view key,
+ std::vector<std::string> const& args,
+ cmExecutionStatus& status) const
+{
+ auto const it = std::lower_bound(
+ this->Impl.begin(), this->Impl.end(), key,
+ [](Elem const& elem, cm::string_view k) { return elem.first < k; });
+ if (it != this->Impl.end() && it->first == key) {
+ return it->second(args, status);
+ }
+ status.SetError(cmStrCat("does not recognize sub-command ", key));
+ return false;
+}
diff --git a/Source/cmSubcommandTable.h b/Source/cmSubcommandTable.h
new file mode 100644
index 000000000..65eb8c794
--- /dev/null
+++ b/Source/cmSubcommandTable.h
@@ -0,0 +1,37 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmSubcommandTable_h
+#define cmSubcommandTable_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <initializer_list>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include <cm/string_view>
+
+#include "cm_static_string_view.hxx"
+
+class cmExecutionStatus;
+
+class cmSubcommandTable
+{
+public:
+ using Command = bool (*)(std::vector<std::string> const&,
+ cmExecutionStatus&);
+
+ using Elem = std::pair<cm::string_view, Command>;
+ using InitElem = std::pair<cm::static_string_view, Command>;
+
+ cmSubcommandTable(std::initializer_list<InitElem> init);
+
+ bool operator()(cm::string_view key, std::vector<std::string> const& args,
+ cmExecutionStatus& status) const;
+
+private:
+ std::vector<Elem> Impl;
+};
+
+#endif
diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx
index 3727dfa25..2477d7a33 100644
--- a/Source/cmSubdirCommand.cxx
+++ b/Source/cmSubdirCommand.cxx
@@ -2,53 +2,48 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSubdirCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
-// cmSubdirCommand
-bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmSubdirCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
bool res = true;
bool excludeFromAll = false;
+ cmMakefile& mf = status.GetMakefile();
- for (std::vector<std::string>::const_iterator i = args.begin();
- i != args.end(); ++i) {
- if (*i == "EXCLUDE_FROM_ALL") {
+ for (std::string const& i : args) {
+ if (i == "EXCLUDE_FROM_ALL") {
excludeFromAll = true;
continue;
}
- if (*i == "PREORDER") {
+ if (i == "PREORDER") {
// Ignored
continue;
}
// if they specified a relative path then compute the full
- std::string srcPath =
- std::string(this->Makefile->GetCurrentSourceDirectory()) + "/" + *i;
+ std::string srcPath = mf.GetCurrentSourceDirectory() + "/" + i;
if (cmSystemTools::FileIsDirectory(srcPath)) {
- std::string binPath =
- std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" + *i;
- this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, false);
+ std::string binPath = mf.GetCurrentBinaryDirectory() + "/" + i;
+ mf.AddSubDirectory(srcPath, binPath, excludeFromAll, false);
}
// otherwise it is a full path
- else if (cmSystemTools::FileIsDirectory(*i)) {
+ else if (cmSystemTools::FileIsDirectory(i)) {
// we must compute the binPath from the srcPath, we just take the last
// element from the source path and use that
- std::string binPath =
- std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" +
- cmSystemTools::GetFilenameName(*i);
- this->Makefile->AddSubDirectory(*i, binPath, excludeFromAll, false);
+ std::string binPath = mf.GetCurrentBinaryDirectory() + "/" +
+ cmSystemTools::GetFilenameName(i);
+ mf.AddSubDirectory(i, binPath, excludeFromAll, false);
} else {
- std::string error = "Incorrect SUBDIRS command. Directory: ";
- error += *i + " does not exist.";
- this->SetError(error);
+ status.SetError(cmStrCat("Incorrect SUBDIRS command. Directory: ", i,
+ " does not exist."));
res = false;
}
}
diff --git a/Source/cmSubdirCommand.h b/Source/cmSubdirCommand.h
index a2af0fd58..3254e842e 100644
--- a/Source/cmSubdirCommand.h
+++ b/Source/cmSubdirCommand.h
@@ -3,36 +3,14 @@
#ifndef cmSubdirCommand_h
#define cmSubdirCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmSubdirCommand
- * \brief Specify a list of subdirectories to build.
- *
- * cmSubdirCommand specifies a list of subdirectories to process
- * by CMake. For each subdirectory listed, CMake will descend
- * into that subdirectory and process any CMakeLists.txt found.
- */
-class cmSubdirCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmSubdirCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmSubdirCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmSubdirDependsCommand.cxx b/Source/cmSubdirDependsCommand.cxx
index 0bb2c0ac4..496c60da7 100644
--- a/Source/cmSubdirDependsCommand.cxx
+++ b/Source/cmSubdirDependsCommand.cxx
@@ -4,8 +4,8 @@
class cmExecutionStatus;
-bool cmSubdirDependsCommand::InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&)
+bool cmSubdirDependsCommand(std::vector<std::string> const&,
+ cmExecutionStatus&)
{
return true;
}
diff --git a/Source/cmSubdirDependsCommand.h b/Source/cmSubdirDependsCommand.h
index d8ea9284f..bf99bd17d 100644
--- a/Source/cmSubdirDependsCommand.h
+++ b/Source/cmSubdirDependsCommand.h
@@ -3,21 +3,14 @@
#ifndef cmSubdirDependsCommand_h
#define cmSubdirDependsCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmSubdirDependsCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmSubdirDependsCommand; }
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmSubdirDependsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index f7192e0b6..c4a4220f8 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2,164 +2,137 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSystemTools.h"
+#include "cm_uv.h"
+
#include "cmAlgorithms.h"
+#include "cmDuration.h"
#include "cmProcessOutput.h"
-#include "cm_sys_stat.h"
-
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmArchiveWrite.h"
-#include "cmLocale.h"
-#include "cm_libarchive.h"
-#ifndef __LA_INT64_T
-#define __LA_INT64_T la_int64_t
-#endif
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
+
+#if !defined(CMAKE_BOOTSTRAP)
+# include "cm_libarchive.h"
+
+# include "cmArchiveWrite.h"
+# include "cmLocale.h"
+# ifndef __LA_INT64_T
+# define __LA_INT64_T la_int64_t
+# endif
+# ifndef __LA_SSIZE_T
+# define __LA_SSIZE_T la_ssize_t
+# endif
#endif
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmCryptoHash.h"
+#if !defined(CMAKE_BOOTSTRAP)
+# include "cmCryptoHash.h"
#endif
#if defined(CMAKE_USE_ELF_PARSER)
-#include "cmELF.h"
+# include "cmELF.h"
#endif
#if defined(CMAKE_USE_MACH_PARSER)
-#include "cmMachO.h"
+# include "cmMachO.h"
#endif
+#include <algorithm>
+#include <cassert>
+#include <cctype>
+#include <cerrno>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
+#include <iostream>
+#include <sstream>
+#include <utility>
+#include <vector>
+
+#include <fcntl.h>
+
#include "cmsys/Directory.hxx"
#include "cmsys/Encoding.hxx"
#include "cmsys/FStream.hxx"
#include "cmsys/RegularExpression.hxx"
#include "cmsys/System.h"
#include "cmsys/Terminal.h"
-#include <algorithm>
-#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
-#include <iostream>
-#include <set>
-#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <utility>
#if defined(_WIN32)
-#include <windows.h>
+# include <windows.h>
// include wincrypt.h after windows.h
-#include <wincrypt.h>
+# include <wincrypt.h>
#else
-#include <sys/time.h>
-#include <unistd.h>
-#include <utime.h>
+# include <unistd.h>
+
+# include <sys/time.h>
#endif
#if defined(_WIN32) && \
(defined(_MSC_VER) || defined(__WATCOMC__) || defined(__MINGW32__))
-#include <io.h>
+# include <io.h>
#endif
#if defined(__APPLE__)
-#include <mach-o/dyld.h>
+# include <mach-o/dyld.h>
#endif
#ifdef __QNX__
-#include <malloc.h> /* for malloc/free on QNX */
+# include <malloc.h> /* for malloc/free on QNX */
#endif
-static bool cm_isspace(char c)
-{
- return ((c & 0x80) == 0) && isspace(c);
-}
+namespace {
-class cmSystemToolsFileTime
-{
-public:
-#if defined(_WIN32) && !defined(__CYGWIN__)
- FILETIME timeCreation;
- FILETIME timeLastAccess;
- FILETIME timeLastWrite;
-#else
- struct utimbuf timeBuf;
-#endif
-};
+cmSystemTools::InterruptCallback s_InterruptCallback;
+cmSystemTools::MessageCallback s_MessageCallback;
+cmSystemTools::OutputCallback s_StderrCallback;
+cmSystemTools::OutputCallback s_StdoutCallback;
+
+} // namespace
#if !defined(HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
// For GetEnvironmentVariables
-#if defined(_WIN32)
+# if defined(_WIN32)
extern __declspec(dllimport) char** environ;
-#else
+# else
extern char** environ;
-#endif
+# endif
#endif
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
static std::string cm_archive_entry_pathname(struct archive_entry* entry)
{
-#if cmsys_STL_HAS_WSTRING
+# if cmsys_STL_HAS_WSTRING
return cmsys::Encoding::ToNarrow(archive_entry_pathname_w(entry));
-#else
+# else
return archive_entry_pathname(entry);
-#endif
+# endif
}
static int cm_archive_read_open_file(struct archive* a, const char* file,
int block_size)
{
-#if cmsys_STL_HAS_WSTRING
+# if cmsys_STL_HAS_WSTRING
std::wstring wfile = cmsys::Encoding::ToWide(file);
return archive_read_open_filename_w(a, wfile.c_str(), block_size);
-#else
+# else
return archive_read_open_filename(a, file, block_size);
-#endif
+# endif
}
#endif
#ifdef _WIN32
-class cmSystemToolsWindowsHandle
-{
-public:
- cmSystemToolsWindowsHandle(HANDLE h)
- : handle_(h)
- {
- }
- ~cmSystemToolsWindowsHandle()
- {
- if (this->handle_ != INVALID_HANDLE_VALUE) {
- CloseHandle(this->handle_);
- }
- }
- operator bool() const { return this->handle_ != INVALID_HANDLE_VALUE; }
- bool operator!() const { return this->handle_ == INVALID_HANDLE_VALUE; }
- operator HANDLE() const { return this->handle_; }
-
-private:
- HANDLE handle_;
-};
#elif defined(__APPLE__)
-#include <crt_externs.h>
+# include <crt_externs.h>
-#define environ (*_NSGetEnviron())
+# define environ (*_NSGetEnviron())
#endif
bool cmSystemTools::s_RunCommandHideConsole = false;
bool cmSystemTools::s_DisableRunCommandOutput = false;
bool cmSystemTools::s_ErrorOccured = false;
bool cmSystemTools::s_FatalErrorOccured = false;
-bool cmSystemTools::s_DisableMessages = false;
bool cmSystemTools::s_ForceUnixPaths = false;
-cmSystemTools::MessageCallback cmSystemTools::s_MessageCallback;
-cmSystemTools::OutputCallback cmSystemTools::s_StdoutCallback;
-cmSystemTools::OutputCallback cmSystemTools::s_StderrCallback;
-cmSystemTools::InterruptCallback cmSystemTools::s_InterruptCallback;
-void* cmSystemTools::s_MessageCallbackClientData;
-void* cmSystemTools::s_StdoutCallbackClientData;
-void* cmSystemTools::s_StderrCallbackClientData;
-void* cmSystemTools::s_InterruptCallbackClientData;
-
// replace replace with with as many times as it shows up in source.
// write the result into source.
#if defined(_WIN32) && !defined(__CYGWIN__)
@@ -179,12 +152,10 @@ void cmSystemTools::ExpandRegistryValues(std::string& source, KeyWOW64 view)
std::string key = regEntry.match(1);
std::string val;
if (ReadRegistryValue(key.c_str(), val, view)) {
- std::string reg = "[";
- reg += key + "]";
+ std::string reg = cmStrCat('[', key, ']');
cmSystemTools::ReplaceString(source, reg.c_str(), val.c_str());
} else {
- std::string reg = "[";
- reg += key + "]";
+ std::string reg = cmStrCat('[', key, ']');
cmSystemTools::ReplaceString(source, reg.c_str(), "/registry");
}
}
@@ -197,227 +168,87 @@ void cmSystemTools::ExpandRegistryValues(std::string& source,
while (regEntry.find(source)) {
// the arguments are the second match
std::string key = regEntry.match(1);
- std::string reg = "[";
- reg += key + "]";
+ std::string reg = cmStrCat('[', key, ']');
cmSystemTools::ReplaceString(source, reg.c_str(), "/registry");
}
}
#endif
-std::string cmSystemTools::EscapeQuotes(const std::string& str)
-{
- std::string result;
- result.reserve(str.size());
- for (const char* ch = str.c_str(); *ch != '\0'; ++ch) {
- if (*ch == '"') {
- result += '\\';
- }
- result += *ch;
- }
- return result;
-}
-
-std::string cmSystemTools::HelpFileName(std::string name)
+std::string cmSystemTools::HelpFileName(cm::string_view str)
{
+ std::string name(str);
cmSystemTools::ReplaceString(name, "<", "");
cmSystemTools::ReplaceString(name, ">", "");
return name;
}
-std::string cmSystemTools::TrimWhitespace(const std::string& s)
-{
- std::string::const_iterator start = s.begin();
- while (start != s.end() && cm_isspace(*start)) {
- ++start;
- }
- if (start == s.end()) {
- return "";
- }
- std::string::const_iterator stop = s.end() - 1;
- while (cm_isspace(*stop)) {
- --stop;
- }
- return std::string(start, stop + 1);
-}
-
-void cmSystemTools::Error(const char* m1, const char* m2, const char* m3,
- const char* m4)
+void cmSystemTools::Error(const std::string& m)
{
- std::string message = "CMake Error: ";
- if (m1) {
- message += m1;
- }
- if (m2) {
- message += m2;
- }
- if (m3) {
- message += m3;
- }
- if (m4) {
- message += m4;
- }
+ std::string message = "CMake Error: " + m;
cmSystemTools::s_ErrorOccured = true;
- cmSystemTools::Message(message.c_str(), "Error");
+ cmSystemTools::Message(message, "Error");
}
-void cmSystemTools::SetInterruptCallback(InterruptCallback f, void* clientData)
+void cmSystemTools::SetInterruptCallback(InterruptCallback f)
{
- s_InterruptCallback = f;
- s_InterruptCallbackClientData = clientData;
+ s_InterruptCallback = std::move(f);
}
bool cmSystemTools::GetInterruptFlag()
{
if (s_InterruptCallback) {
- return (*s_InterruptCallback)(s_InterruptCallbackClientData);
+ return s_InterruptCallback();
}
return false;
}
-void cmSystemTools::SetMessageCallback(MessageCallback f, void* clientData)
-{
- s_MessageCallback = f;
- s_MessageCallbackClientData = clientData;
-}
-
-void cmSystemTools::SetStdoutCallback(OutputCallback f, void* clientData)
-{
- s_StdoutCallback = f;
- s_StdoutCallbackClientData = clientData;
-}
-
-void cmSystemTools::SetStderrCallback(OutputCallback f, void* clientData)
+void cmSystemTools::SetMessageCallback(MessageCallback f)
{
- s_StderrCallback = f;
- s_StderrCallbackClientData = clientData;
+ s_MessageCallback = std::move(f);
}
-void cmSystemTools::Stdout(const char* s)
+void cmSystemTools::SetStdoutCallback(OutputCallback f)
{
- cmSystemTools::Stdout(s, strlen(s));
+ s_StdoutCallback = std::move(f);
}
-void cmSystemTools::Stderr(const char* s)
+void cmSystemTools::SetStderrCallback(OutputCallback f)
{
- cmSystemTools::Stderr(s, strlen(s));
+ s_StderrCallback = std::move(f);
}
-void cmSystemTools::Stderr(const char* s, size_t length)
+void cmSystemTools::Stderr(const std::string& s)
{
if (s_StderrCallback) {
- (*s_StderrCallback)(s, length, s_StderrCallbackClientData);
+ s_StderrCallback(s);
} else {
- std::cerr.write(s, length);
- std::cerr.flush();
+ std::cerr << s << std::flush;
}
}
-void cmSystemTools::Stdout(const char* s, size_t length)
+void cmSystemTools::Stdout(const std::string& s)
{
if (s_StdoutCallback) {
- (*s_StdoutCallback)(s, length, s_StdoutCallbackClientData);
+ s_StdoutCallback(s);
} else {
- std::cout.write(s, length);
- std::cout.flush();
+ std::cout << s << std::flush;
}
}
-void cmSystemTools::Message(const char* m1, const char* title)
+void cmSystemTools::Message(const std::string& m, const char* title)
{
- if (s_DisableMessages) {
- return;
- }
if (s_MessageCallback) {
- (*s_MessageCallback)(m1, title, s_DisableMessages,
- s_MessageCallbackClientData);
- return;
+ s_MessageCallback(m, title);
+ } else {
+ std::cerr << m << std::endl;
}
- std::cerr << m1 << std::endl << std::flush;
}
void cmSystemTools::ReportLastSystemError(const char* msg)
{
- std::string m = msg;
- m += ": System Error: ";
- m += Superclass::GetLastSystemError();
- cmSystemTools::Error(m.c_str());
-}
-
-bool cmSystemTools::IsInternallyOn(const char* val)
-{
- if (!val) {
- return false;
- }
- std::string v = val;
- if (v.size() > 4) {
- return false;
- }
-
- for (std::string::iterator c = v.begin(); c != v.end(); c++) {
- *c = static_cast<char>(toupper(*c));
- }
- return v == "I_ON";
-}
-
-bool cmSystemTools::IsOn(const char* val)
-{
- if (!val) {
- return false;
- }
- size_t len = strlen(val);
- if (len > 4) {
- return false;
- }
- std::string v(val, len);
-
- static std::set<std::string> onValues;
- if (onValues.empty()) {
- onValues.insert("ON");
- onValues.insert("1");
- onValues.insert("YES");
- onValues.insert("TRUE");
- onValues.insert("Y");
- }
- for (std::string::iterator c = v.begin(); c != v.end(); c++) {
- *c = static_cast<char>(toupper(*c));
- }
- return (onValues.count(v) > 0);
-}
-
-bool cmSystemTools::IsNOTFOUND(const char* val)
-{
- if (strcmp(val, "NOTFOUND") == 0) {
- return true;
- }
- return cmHasLiteralSuffix(val, "-NOTFOUND");
-}
-
-bool cmSystemTools::IsOff(const char* val)
-{
- if (!val || !*val) {
- return true;
- }
- size_t len = strlen(val);
- // Try and avoid toupper() for large strings.
- if (len > 6) {
- return cmSystemTools::IsNOTFOUND(val);
- }
-
- static std::set<std::string> offValues;
- if (offValues.empty()) {
- offValues.insert("OFF");
- offValues.insert("0");
- offValues.insert("NO");
- offValues.insert("FALSE");
- offValues.insert("N");
- offValues.insert("IGNORE");
- }
- // Try and avoid toupper().
- std::string v(val, len);
- for (std::string::iterator c = v.begin(); c != v.end(); c++) {
- *c = static_cast<char>(toupper(*c));
- }
- return (offValues.count(v) > 0);
+ std::string m =
+ cmStrCat(msg, ": System Error: ", Superclass::GetLastSystemError());
+ cmSystemTools::Error(m);
}
void cmSystemTools::ParseWindowsCommandLine(const char* command,
@@ -453,12 +284,12 @@ void cmSystemTools::ParseWindowsCommandLine(const char* command,
} else {
arg.append(backslashes, '\\');
backslashes = 0;
- if (cm_isspace(*c)) {
+ if (cmIsSpace(*c)) {
if (in_quotes) {
arg.append(1, *c);
} else if (in_argument) {
args.push_back(arg);
- arg = "";
+ arg.clear();
in_argument = false;
}
} else {
@@ -489,10 +320,12 @@ public:
}
free(this->ArgV);
}
+ cmSystemToolsArgV(const cmSystemToolsArgV&) = delete;
+ cmSystemToolsArgV& operator=(const cmSystemToolsArgV&) = delete;
void Store(std::vector<std::string>& args) const
{
for (char** arg = this->ArgV; arg && *arg; ++arg) {
- args.push_back(*arg);
+ args.emplace_back(*arg);
}
}
};
@@ -501,7 +334,7 @@ void cmSystemTools::ParseUnixCommandLine(const char* command,
std::vector<std::string>& args)
{
// Invoke the underlying parser.
- cmSystemToolsArgV argv = cmsysSystem_Parse_CommandForUnix(command, 0);
+ cmSystemToolsArgV argv(cmsysSystem_Parse_CommandForUnix(command, 0));
argv.Store(args);
}
@@ -510,16 +343,14 @@ std::vector<std::string> cmSystemTools::HandleResponseFile(
std::vector<std::string>::const_iterator argEnd)
{
std::vector<std::string> arg_full;
- for (std::vector<std::string>::const_iterator a = argBeg; a != argEnd; ++a) {
- std::string const& arg = *a;
+ for (std::string const& arg : cmMakeRange(argBeg, argEnd)) {
if (cmHasLiteralPrefix(arg, "@")) {
cmsys::ifstream responseFile(arg.substr(1).c_str(), std::ios::in);
if (!responseFile) {
- std::string error = "failed to open for reading (";
- error += cmSystemTools::GetLastSystemError();
- error += "):\n ";
- error += arg.substr(1);
- cmSystemTools::Error(error.c_str());
+ std::string error = cmStrCat("failed to open for reading (",
+ cmSystemTools::GetLastSystemError(),
+ "):\n ", cm::string_view(arg).substr(1));
+ cmSystemTools::Error(error);
} else {
std::string line;
cmSystemTools::GetLineFromStream(responseFile, line);
@@ -529,7 +360,7 @@ std::vector<std::string> cmSystemTools::HandleResponseFile(
#else
cmSystemTools::ParseUnixCommandLine(line.c_str(), args2);
#endif
- arg_full.insert(arg_full.end(), args2.begin(), args2.end());
+ cmAppend(arg_full, args2);
}
} else {
arg_full.push_back(arg);
@@ -538,19 +369,21 @@ std::vector<std::string> cmSystemTools::HandleResponseFile(
return arg_full;
}
-std::vector<std::string> cmSystemTools::ParseArguments(const char* command)
+std::vector<std::string> cmSystemTools::ParseArguments(const std::string& cmd)
{
std::vector<std::string> args;
std::string arg;
bool win_path = false;
- if ((command[0] != '/' && command[1] == ':' && command[2] == '\\') ||
- (command[0] == '\"' && command[1] != '/' && command[2] == ':' &&
- command[3] == '\\') ||
- (command[0] == '\'' && command[1] != '/' && command[2] == ':' &&
- command[3] == '\\') ||
- (command[0] == '\\' && command[1] == '\\')) {
+ const char* command = cmd.c_str();
+ if (command[0] && command[1] &&
+ ((command[0] != '/' && command[1] == ':' && command[2] == '\\') ||
+ (command[0] == '\"' && command[1] != '/' && command[2] == ':' &&
+ command[3] == '\\') ||
+ (command[0] == '\'' && command[1] != '/' && command[2] == ':' &&
+ command[3] == '\\') ||
+ (command[0] == '\\' && command[1] == '\\'))) {
win_path = true;
}
// Split the command into an argv array.
@@ -559,7 +392,7 @@ std::vector<std::string> cmSystemTools::ParseArguments(const char* command)
while (*c == ' ' || *c == '\t') {
++c;
}
- arg = "";
+ arg.clear();
if (*c == '"') {
// Parse a quoted argument.
++c;
@@ -603,6 +436,56 @@ std::vector<std::string> cmSystemTools::ParseArguments(const char* command)
return args;
}
+bool cmSystemTools::SplitProgramFromArgs(std::string const& command,
+ std::string& program,
+ std::string& args)
+{
+ const char* c = command.c_str();
+
+ // Skip leading whitespace.
+ while (isspace(static_cast<unsigned char>(*c))) {
+ ++c;
+ }
+
+ // Parse one command-line element up to an unquoted space.
+ bool in_escape = false;
+ bool in_double = false;
+ bool in_single = false;
+ for (; *c; ++c) {
+ if (in_single) {
+ if (*c == '\'') {
+ in_single = false;
+ } else {
+ program += *c;
+ }
+ } else if (in_escape) {
+ in_escape = false;
+ program += *c;
+ } else if (*c == '\\') {
+ in_escape = true;
+ } else if (in_double) {
+ if (*c == '"') {
+ in_double = false;
+ } else {
+ program += *c;
+ }
+ } else if (*c == '"') {
+ in_double = true;
+ } else if (*c == '\'') {
+ in_single = true;
+ } else if (isspace(static_cast<unsigned char>(*c))) {
+ break;
+ } else {
+ program += *c;
+ }
+ }
+
+ // The remainder of the command line holds unparsed arguments.
+ args = c;
+
+ return !in_single && !in_escape && !in_double;
+}
+
size_t cmSystemTools::CalculateCommandLineLengthLimit()
{
size_t sz =
@@ -633,11 +516,11 @@ size_t cmSystemTools::CalculateCommandLineLengthLimit()
// We estimate the size of the environment block to be 1000.
// This isn't accurate at all, but leaves some headroom.
szArgMax = szArgMax < 1000 ? 0 : szArgMax - 1000;
-#if defined(_WIN32) || defined(__linux)
+# if defined(_WIN32) || defined(__linux)
sz = std::min(sz, static_cast<size_t>(szArgMax));
-#else
+# else
sz = static_cast<size_t>(szArgMax);
-#endif
+# endif
}
#endif
return sz;
@@ -647,17 +530,17 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
std::string* captureStdOut,
std::string* captureStdErr, int* retVal,
const char* dir, OutputOption outputflag,
- double timeout, Encoding encoding)
+ cmDuration timeout, Encoding encoding)
{
std::vector<const char*> argv;
- for (std::vector<std::string>::const_iterator a = command.begin();
- a != command.end(); ++a) {
- argv.push_back(a->c_str());
+ argv.reserve(command.size() + 1);
+ for (std::string const& cmd : command) {
+ argv.push_back(cmd.c_str());
}
- argv.push_back(CM_NULLPTR);
+ argv.push_back(nullptr);
cmsysProcess* cp = cmsysProcess_New();
- cmsysProcess_SetCommand(cp, &*argv.begin());
+ cmsysProcess_SetCommand(cp, argv.data());
cmsysProcess_SetWorkingDirectory(cp, dir);
if (cmSystemTools::GetRunCommandHideConsole()) {
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
@@ -666,16 +549,16 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
if (outputflag == OUTPUT_PASSTHROUGH) {
cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1);
cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1);
- captureStdOut = CM_NULLPTR;
- captureStdErr = CM_NULLPTR;
+ captureStdOut = nullptr;
+ captureStdErr = nullptr;
} else if (outputflag == OUTPUT_MERGE ||
(captureStdErr && captureStdErr == captureStdOut)) {
cmsysProcess_SetOption(cp, cmsysProcess_Option_MergeOutput, 1);
- captureStdErr = CM_NULLPTR;
+ captureStdErr = nullptr;
}
assert(!captureStdErr || captureStdErr != captureStdOut);
- cmsysProcess_SetTimeout(cp, timeout);
+ cmsysProcess_SetTimeout(cp, timeout.count());
cmsysProcess_Execute(cp);
std::vector<char> tempStdOut;
@@ -687,7 +570,7 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
std::string strdata;
if (outputflag != OUTPUT_PASSTHROUGH &&
(captureStdOut || captureStdErr || outputflag != OUTPUT_NONE)) {
- while ((pipe = cmsysProcess_WaitForData(cp, &data, &length, CM_NULLPTR)) >
+ while ((pipe = cmsysProcess_WaitForData(cp, &data, &length, nullptr)) >
0) {
// Translate NULL characters in the output into valid text.
for (int i = 0; i < length; ++i) {
@@ -699,18 +582,18 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
if (pipe == cmsysProcess_Pipe_STDOUT) {
if (outputflag != OUTPUT_NONE) {
processOutput.DecodeText(data, length, strdata, 1);
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
if (captureStdOut) {
- tempStdOut.insert(tempStdOut.end(), data, data + length);
+ cmAppend(tempStdOut, data, data + length);
}
} else if (pipe == cmsysProcess_Pipe_STDERR) {
if (outputflag != OUTPUT_NONE) {
processOutput.DecodeText(data, length, strdata, 2);
- cmSystemTools::Stderr(strdata.c_str(), strdata.size());
+ cmSystemTools::Stderr(strdata);
}
if (captureStdErr) {
- tempStdErr.insert(tempStdErr.end(), data, data + length);
+ cmAppend(tempStdErr, data, data + length);
}
}
}
@@ -718,16 +601,16 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
if (outputflag != OUTPUT_NONE) {
processOutput.DecodeText(std::string(), strdata, 1);
if (!strdata.empty()) {
- cmSystemTools::Stdout(strdata.c_str(), strdata.size());
+ cmSystemTools::Stdout(strdata);
}
processOutput.DecodeText(std::string(), strdata, 2);
if (!strdata.empty()) {
- cmSystemTools::Stderr(strdata.c_str(), strdata.size());
+ cmSystemTools::Stderr(strdata);
}
}
}
- cmsysProcess_WaitForExit(cp, CM_NULLPTR);
+ cmsysProcess_WaitForExit(cp, nullptr);
if (captureStdOut) {
captureStdOut->assign(tempStdOut.begin(), tempStdOut.end());
@@ -754,6 +637,8 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
}
if (captureStdErr) {
captureStdErr->append(exception_str, strlen(exception_str));
+ } else if (captureStdOut) {
+ captureStdOut->append(exception_str, strlen(exception_str));
}
result = false;
} else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Error) {
@@ -763,6 +648,8 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
}
if (captureStdErr) {
captureStdErr->append(error_str, strlen(error_str));
+ } else if (captureStdOut) {
+ captureStdOut->append(error_str, strlen(error_str));
}
result = false;
} else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Expired) {
@@ -780,11 +667,11 @@ bool cmSystemTools::RunSingleCommand(std::vector<std::string> const& command,
return result;
}
-bool cmSystemTools::RunSingleCommand(const char* command,
+bool cmSystemTools::RunSingleCommand(const std::string& command,
std::string* captureStdOut,
std::string* captureStdErr, int* retVal,
const char* dir, OutputOption outputflag,
- double timeout)
+ cmDuration timeout)
{
if (s_DisableRunCommandOutput) {
outputflag = OUTPUT_NONE;
@@ -810,25 +697,22 @@ std::string cmSystemTools::PrintSingleCommand(
}
bool cmSystemTools::DoesFileExistWithExtensions(
- const char* name, const std::vector<std::string>& headerExts)
+ const std::string& name, const std::vector<std::string>& headerExts)
{
std::string hname;
- for (std::vector<std::string>::const_iterator ext = headerExts.begin();
- ext != headerExts.end(); ++ext) {
- hname = name;
- hname += ".";
- hname += *ext;
- if (cmSystemTools::FileExists(hname.c_str())) {
+ for (std::string const& headerExt : headerExts) {
+ hname = cmStrCat(name, '.', headerExt);
+ if (cmSystemTools::FileExists(hname)) {
return true;
}
}
return false;
}
-std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
- const char* directory,
- const char* toplevel)
+std::string cmSystemTools::FileExistsInParentDirectories(
+ const std::string& fname, const std::string& directory,
+ const std::string& toplevel)
{
std::string file = fname;
cmSystemTools::ConvertToUnixSlashes(file);
@@ -836,11 +720,11 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
cmSystemTools::ConvertToUnixSlashes(dir);
std::string prevDir;
while (dir != prevDir) {
- std::string path = dir + "/" + file;
- if (cmSystemTools::FileExists(path.c_str())) {
+ std::string path = cmStrCat(dir, "/", file);
+ if (cmSystemTools::FileExists(path)) {
return path;
}
- if (dir.size() < strlen(toplevel)) {
+ if (dir.size() < toplevel.size()) {
break;
}
prevDir = dir;
@@ -849,17 +733,6 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
return "";
}
-bool cmSystemTools::cmCopyFile(const char* source, const char* destination)
-{
- return Superclass::CopyFileAlways(source, destination);
-}
-
-bool cmSystemTools::CopyFileIfDifferent(const char* source,
- const char* destination)
-{
- return Superclass::CopyFileIfDifferent(source, destination);
-}
-
#ifdef _WIN32
cmSystemTools::WindowsFileRetry cmSystemTools::GetWindowsFileRetry()
{
@@ -892,12 +765,65 @@ cmSystemTools::WindowsFileRetry cmSystemTools::GetWindowsFileRetry()
}
#endif
-bool cmSystemTools::RenameFile(const char* oldname, const char* newname)
+std::string cmSystemTools::GetRealPathResolvingWindowsSubst(
+ const std::string& path, std::string* errorMessage)
{
#ifdef _WIN32
-#ifndef INVALID_FILE_ATTRIBUTES
-#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
+ // uv_fs_realpath uses Windows Vista API so fallback to kwsys if not found
+ std::string resolved_path;
+ uv_fs_t req;
+ int err = uv_fs_realpath(NULL, &req, path.c_str(), NULL);
+ if (!err) {
+ resolved_path = std::string((char*)req.ptr);
+ cmSystemTools::ConvertToUnixSlashes(resolved_path);
+ // Normalize to upper-case drive letter as GetActualCaseForPath does.
+ if (resolved_path.size() > 1 && resolved_path[1] == ':') {
+ resolved_path[0] = toupper(resolved_path[0]);
+ }
+ } else if (err == UV_ENOSYS) {
+ resolved_path = cmsys::SystemTools::GetRealPath(path, errorMessage);
+ } else if (errorMessage) {
+ LPSTR message = NULL;
+ DWORD size = FormatMessageA(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&message, 0,
+ NULL);
+ *errorMessage = std::string(message, size);
+ LocalFree(message);
+
+ resolved_path = "";
+ } else {
+ resolved_path = path;
+ }
+ return resolved_path;
+#else
+ return cmsys::SystemTools::GetRealPath(path, errorMessage);
#endif
+}
+
+void cmSystemTools::InitializeLibUV()
+{
+#if defined(_WIN32)
+ // Perform libuv one-time initialization now, and then un-do its
+ // global _fmode setting so that using libuv does not change the
+ // default file text/binary mode. See libuv issue 840.
+ uv_loop_close(uv_default_loop());
+# ifdef _MSC_VER
+ _set_fmode(_O_TEXT);
+# else
+ _fmode = _O_TEXT;
+# endif
+#endif
+}
+
+bool cmSystemTools::RenameFile(const std::string& oldname,
+ const std::string& newname)
+{
+#ifdef _WIN32
+# ifndef INVALID_FILE_ATTRIBUTES
+# define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
+# endif
/* Windows MoveFileEx may not replace read-only or in-use files. If it
fails then remove the read-only attribute from any existing destination.
Try multiple times since we may be racing against another process
@@ -930,29 +856,39 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname)
return retry.Count > 0;
#else
/* On UNIX we have an OS-provided call to do this atomically. */
- return rename(oldname, newname) == 0;
+ return rename(oldname.c_str(), newname.c_str()) == 0;
#endif
}
-bool cmSystemTools::ComputeFileMD5(const std::string& source, char* md5out)
+void cmSystemTools::MoveFileIfDifferent(const std::string& source,
+ const std::string& destination)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
- cmCryptoHash md5(cmCryptoHash::AlgoMD5);
- std::string const str = md5.HashFile(source);
- strncpy(md5out, str.c_str(), 32);
- return !str.empty();
+ if (FilesDiffer(source, destination)) {
+ if (RenameFile(source, destination)) {
+ return;
+ }
+ CopyFileAlways(source, destination);
+ }
+ RemoveFile(source);
+}
+
+std::string cmSystemTools::ComputeFileHash(const std::string& source,
+ cmCryptoHash::Algo algo)
+{
+#if !defined(CMAKE_BOOTSTRAP)
+ cmCryptoHash hash(algo);
+ return hash.HashFile(source);
#else
(void)source;
- (void)md5out;
- cmSystemTools::Message("md5sum not supported in bootstrapping mode",
+ cmSystemTools::Message("hashsum not supported in bootstrapping mode",
"Error");
- return false;
+ return std::string();
#endif
}
std::string cmSystemTools::ComputeStringMD5(const std::string& input)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
cmCryptoHash md5(cmCryptoHash::AlgoMD5);
return md5.HashString(input);
#else
@@ -968,7 +904,7 @@ std::string cmSystemTools::ComputeCertificateThumbprint(
{
std::string thumbprint;
-#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32)
+#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32)
BYTE* certData = NULL;
CRYPT_INTEGER_BLOB cryptBlob;
HCERTSTORE certStore = NULL;
@@ -1050,7 +986,7 @@ void cmSystemTools::Glob(const std::string& directory,
for (i = 0; i < numf; i++) {
std::string fname = d.GetFile(i);
if (reg.find(fname)) {
- files.push_back(fname);
+ files.push_back(std::move(fname));
}
}
}
@@ -1072,9 +1008,7 @@ void cmSystemTools::GlobDirs(const std::string& path,
for (unsigned int i = 0; i < d.GetNumberOfFiles(); ++i) {
if ((std::string(d.GetFile(i)) != ".") &&
(std::string(d.GetFile(i)) != "..")) {
- std::string fname = startPath;
- fname += "/";
- fname += d.GetFile(i);
+ std::string fname = cmStrCat(startPath, '/', d.GetFile(i));
if (cmSystemTools::FileIsDirectory(fname)) {
fname += finishPath;
cmSystemTools::GlobDirs(fname, files);
@@ -1084,82 +1018,12 @@ void cmSystemTools::GlobDirs(const std::string& path,
}
}
-void cmSystemTools::ExpandList(std::vector<std::string> const& arguments,
- std::vector<std::string>& newargs)
-{
- std::vector<std::string>::const_iterator i;
- for (i = arguments.begin(); i != arguments.end(); ++i) {
- cmSystemTools::ExpandListArgument(*i, newargs);
- }
-}
-
-void cmSystemTools::ExpandListArgument(const std::string& arg,
- std::vector<std::string>& newargs,
- bool emptyArgs)
-{
- // If argument is empty, it is an empty list.
- if (!emptyArgs && arg.empty()) {
- return;
- }
- // if there are no ; in the name then just copy the current string
- if (arg.find(';') == std::string::npos) {
- newargs.push_back(arg);
- return;
- }
- std::string newArg;
- const char* last = arg.c_str();
- // Break the string at non-escaped semicolons not nested in [].
- int squareNesting = 0;
- for (const char* c = last; *c; ++c) {
- switch (*c) {
- case '\\': {
- // We only want to allow escaping of semicolons. Other
- // escapes should not be processed here.
- const char* next = c + 1;
- if (*next == ';') {
- newArg.append(last, c - last);
- // Skip over the escape character
- last = c = next;
- }
- } break;
- case '[': {
- ++squareNesting;
- } break;
- case ']': {
- --squareNesting;
- } break;
- case ';': {
- // Break the string here if we are not nested inside square
- // brackets.
- if (squareNesting == 0) {
- newArg.append(last, c - last);
- // Skip over the semicolon
- last = c + 1;
- if (!newArg.empty() || emptyArgs) {
- // Add the last argument if the string is not empty.
- newargs.push_back(newArg);
- newArg = "";
- }
- }
- } break;
- default: {
- // Just append this character.
- } break;
- }
- }
- newArg.append(last);
- if (!newArg.empty() || emptyArgs) {
- // Add the last argument if the string is not empty.
- newargs.push_back(newArg);
- }
-}
-
bool cmSystemTools::SimpleGlob(const std::string& glob,
std::vector<std::string>& files,
int type /* = 0 */)
{
files.clear();
- if (glob[glob.size() - 1] != '*') {
+ if (glob.back() != '*') {
return false;
}
std::string path = cmSystemTools::GetFilenamePath(glob);
@@ -1176,7 +1040,7 @@ bool cmSystemTools::SimpleGlob(const std::string& glob,
if ((std::string(d.GetFile(i)) != ".") &&
(std::string(d.GetFile(i)) != "..")) {
std::string fname = path;
- if (path[path.size() - 1] != '/') {
+ if (path.back() != '/') {
fname += "/";
}
fname += d.GetFile(i);
@@ -1198,73 +1062,7 @@ bool cmSystemTools::SimpleGlob(const std::string& glob,
return res;
}
-cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext)
-{
- if (!cext || *cext == 0) {
- return cmSystemTools::NO_FILE_FORMAT;
- }
- // std::string ext = cmSystemTools::LowerCase(cext);
- std::string ext = cext;
- if (ext == "c" || ext == ".c" || ext == "m" || ext == ".m") {
- return cmSystemTools::C_FILE_FORMAT;
- }
- if (ext == "C" || ext == ".C" || ext == "M" || ext == ".M" || ext == "c++" ||
- ext == ".c++" || ext == "cc" || ext == ".cc" || ext == "cpp" ||
- ext == ".cpp" || ext == "cxx" || ext == ".cxx" || ext == "mm" ||
- ext == ".mm") {
- return cmSystemTools::CXX_FILE_FORMAT;
- }
- if (ext == "f" || ext == ".f" || ext == "F" || ext == ".F" || ext == "f77" ||
- ext == ".f77" || ext == "f90" || ext == ".f90" || ext == "for" ||
- ext == ".for" || ext == "f95" || ext == ".f95") {
- return cmSystemTools::FORTRAN_FILE_FORMAT;
- }
- if (ext == "java" || ext == ".java") {
- return cmSystemTools::JAVA_FILE_FORMAT;
- }
- if (ext == "H" || ext == ".H" || ext == "h" || ext == ".h" || ext == "h++" ||
- ext == ".h++" || ext == "hm" || ext == ".hm" || ext == "hpp" ||
- ext == ".hpp" || ext == "hxx" || ext == ".hxx" || ext == "in" ||
- ext == ".in" || ext == "txx" || ext == ".txx") {
- return cmSystemTools::HEADER_FILE_FORMAT;
- }
- if (ext == "rc" || ext == ".rc") {
- return cmSystemTools::RESOURCE_FILE_FORMAT;
- }
- if (ext == "def" || ext == ".def") {
- return cmSystemTools::DEFINITION_FILE_FORMAT;
- }
- if (ext == "lib" || ext == ".lib" || ext == "a" || ext == ".a") {
- return cmSystemTools::STATIC_LIBRARY_FILE_FORMAT;
- }
- if (ext == "o" || ext == ".o" || ext == "obj" || ext == ".obj") {
- return cmSystemTools::OBJECT_FILE_FORMAT;
- }
-#ifdef __APPLE__
- if (ext == "dylib" || ext == ".dylib") {
- return cmSystemTools::SHARED_LIBRARY_FILE_FORMAT;
- }
- if (ext == "so" || ext == ".so" || ext == "bundle" || ext == ".bundle") {
- return cmSystemTools::MODULE_FILE_FORMAT;
- }
-#else // __APPLE__
- if (ext == "so" || ext == ".so" || ext == "sl" || ext == ".sl" ||
- ext == "dll" || ext == ".dll") {
- return cmSystemTools::SHARED_LIBRARY_FILE_FORMAT;
- }
-#endif // __APPLE__
- return cmSystemTools::UNKNOWN_FILE_FORMAT;
-}
-
-bool cmSystemTools::Split(const char* s, std::vector<std::string>& l)
-{
- std::vector<std::string> temp;
- bool res = Superclass::Split(s, temp);
- l.insert(l.end(), temp.begin(), temp.end());
- return res;
-}
-
-std::string cmSystemTools::ConvertToOutputPath(const char* path)
+std::string cmSystemTools::ConvertToOutputPath(std::string const& path)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
if (s_ForceUnixPaths) {
@@ -1291,7 +1089,7 @@ void cmSystemTools::ConvertToOutputSlashes(std::string& path)
#endif
}
-std::string cmSystemTools::ConvertToRunCommandPath(const char* path)
+std::string cmSystemTools::ConvertToRunCommandPath(const std::string& path)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
return cmSystemTools::ConvertToWindowsOutputPath(path);
@@ -1301,60 +1099,109 @@ std::string cmSystemTools::ConvertToRunCommandPath(const char* path)
}
// compute the relative path from here to there
-std::string cmSystemTools::RelativePath(const char* local, const char* remote)
+std::string cmSystemTools::RelativePath(std::string const& local,
+ std::string const& remote)
{
if (!cmSystemTools::FileIsFullPath(local)) {
- cmSystemTools::Error("RelativePath must be passed a full path to local: ",
+ cmSystemTools::Error("RelativePath must be passed a full path to local: " +
local);
}
if (!cmSystemTools::FileIsFullPath(remote)) {
- cmSystemTools::Error("RelativePath must be passed a full path to remote: ",
- remote);
+ cmSystemTools::Error(
+ "RelativePath must be passed a full path to remote: " + remote);
}
return cmsys::SystemTools::RelativePath(local, remote);
}
-std::string cmSystemTools::CollapseCombinedPath(std::string const& dir,
- std::string const& file)
+std::string cmSystemTools::ForceToRelativePath(std::string const& local_path,
+ std::string const& remote_path)
{
- if (dir.empty() || dir == ".") {
- return file;
+ // The paths should never be quoted.
+ assert(local_path.front() != '\"');
+ assert(remote_path.front() != '\"');
+
+ // The local path should never have a trailing slash except if it is just the
+ // bare root directory
+ assert(local_path.empty() || local_path.back() != '/' ||
+ local_path.size() == 1 ||
+ (local_path.size() == 3 && local_path[1] == ':' &&
+ ((local_path[0] >= 'A' && local_path[0] <= 'Z') ||
+ (local_path[0] >= 'a' && local_path[0] <= 'z'))));
+
+ // If the path is already relative then just return the path.
+ if (!cmSystemTools::FileIsFullPath(remote_path)) {
+ return remote_path;
+ }
+
+ // Identify the longest shared path component between the remote
+ // path and the local path.
+ std::vector<std::string> local;
+ cmSystemTools::SplitPath(local_path, local);
+ std::vector<std::string> remote;
+ cmSystemTools::SplitPath(remote_path, remote);
+ unsigned int common = 0;
+ while (common < remote.size() && common < local.size() &&
+ cmSystemTools::ComparePath(remote[common], local[common])) {
+ ++common;
+ }
+
+ // If no part of the path is in common then return the full path.
+ if (common == 0) {
+ return remote_path;
}
- std::vector<std::string> dirComponents;
- std::vector<std::string> fileComponents;
- cmSystemTools::SplitPath(dir, dirComponents);
- cmSystemTools::SplitPath(file, fileComponents);
+ // If the entire path is in common then just return a ".".
+ if (common == remote.size() && common == local.size()) {
+ return ".";
+ }
- if (fileComponents.empty()) {
- return dir;
+ // If the entire path is in common except for a trailing slash then
+ // just return a "./".
+ if (common + 1 == remote.size() && remote[common].empty() &&
+ common == local.size()) {
+ return "./";
}
- if (fileComponents[0] != "") {
- // File is not a relative path.
- return file;
+
+ // Construct the relative path.
+ std::string relative;
+
+ // First add enough ../ to get up to the level of the shared portion
+ // of the path. Leave off the trailing slash. Note that the last
+ // component of local will never be empty because local should never
+ // have a trailing slash.
+ for (unsigned int i = common; i < local.size(); ++i) {
+ relative += "..";
+ if (i < local.size() - 1) {
+ relative += "/";
+ }
}
- std::vector<std::string>::iterator i = fileComponents.begin() + 1;
- while (i != fileComponents.end() && *i == ".." && dirComponents.size() > 1) {
- ++i; // Remove ".." file component.
- dirComponents.pop_back(); // Remove last dir component.
+ // Now add the portion of the destination path that is not included
+ // in the shared portion of the path. Add a slash the first time
+ // only if there was already something in the path. If there was a
+ // trailing slash in the input then the last iteration of the loop
+ // will add a slash followed by an empty string which will preserve
+ // the trailing slash in the output.
+
+ if (!relative.empty() && !remote.empty()) {
+ relative += "/";
}
+ relative += cmJoin(cmMakeRange(remote).advance(common), "/");
- dirComponents.insert(dirComponents.end(), i, fileComponents.end());
- return cmSystemTools::JoinPath(dirComponents);
+ // Finally return the path.
+ return relative;
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
bool cmSystemTools::UnsetEnv(const char* value)
{
-#if !defined(HAVE_UNSETENV)
- std::string var = value;
- var += "=";
+# if !defined(HAVE_UNSETENV)
+ std::string var = cmStrCat(value, '=');
return cmSystemTools::PutEnv(var.c_str());
-#else
+# else
unsetenv(value);
return true;
-#endif
+# endif
}
std::vector<std::string> cmSystemTools::GetEnvironmentVariables()
@@ -1362,16 +1209,15 @@ std::vector<std::string> cmSystemTools::GetEnvironmentVariables()
std::vector<std::string> env;
int cc;
for (cc = 0; environ[cc]; ++cc) {
- env.push_back(environ[cc]);
+ env.emplace_back(environ[cc]);
}
return env;
}
void cmSystemTools::AppendEnv(std::vector<std::string> const& env)
{
- for (std::vector<std::string>::const_iterator eit = env.begin();
- eit != env.end(); ++eit) {
- cmSystemTools::PutEnv(*eit);
+ for (std::string const& eit : env) {
+ cmSystemTools::PutEnv(eit);
}
}
@@ -1384,10 +1230,7 @@ cmSystemTools::SaveRestoreEnvironment::~SaveRestoreEnvironment()
{
// First clear everything in the current environment:
std::vector<std::string> currentEnv = GetEnvironmentVariables();
- for (std::vector<std::string>::const_iterator eit = currentEnv.begin();
- eit != currentEnv.end(); ++eit) {
- std::string var(*eit);
-
+ for (std::string var : currentEnv) {
std::string::size_type pos = var.find('=');
if (pos != std::string::npos) {
var = var.substr(0, pos);
@@ -1404,7 +1247,7 @@ cmSystemTools::SaveRestoreEnvironment::~SaveRestoreEnvironment()
void cmSystemTools::EnableVSConsoleOutput()
{
#ifdef _WIN32
- // Visual Studio 8 2005 (devenv.exe or VCExpress.exe) will not
+ // Visual Studio tools like devenv may not
// display output to the console unless this environment variable is
// set. We need it to capture the output of these build tools.
// Note for future work that one could pass "/out \\.\pipe\NAME" to
@@ -1413,37 +1256,35 @@ void cmSystemTools::EnableVSConsoleOutput()
// output and allow it to be captured on the fly.
cmSystemTools::PutEnv("vsconsoleoutput=1");
-#ifdef CMAKE_BUILD_WITH_CMAKE
+# ifndef CMAKE_BOOTSTRAP
// VS sets an environment variable to tell MS tools like "cl" to report
// output through a backdoor pipe instead of stdout/stderr. Unset the
// environment variable to close this backdoor for any path of process
// invocations that passes through CMake so we can capture the output.
cmSystemTools::UnsetEnv("VS_UNICODE_OUTPUT");
-#endif
+# endif
#endif
}
-bool cmSystemTools::IsPathToFramework(const char* path)
+bool cmSystemTools::IsPathToFramework(const std::string& path)
{
return (cmSystemTools::FileIsFullPath(path) &&
cmHasLiteralSuffix(path, ".framework"));
}
-bool cmSystemTools::CreateTar(const char* outFileName,
+bool cmSystemTools::CreateTar(const std::string& outFileName,
const std::vector<std::string>& files,
cmTarCompression compressType, bool verbose,
std::string const& mtime,
std::string const& format)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- cmsys::ofstream fout(outFileName, std::ios::out | std::ios::binary);
+ cmsys::ofstream fout(outFileName.c_str(), std::ios::out | std::ios::binary);
if (!fout) {
- std::string e = "Cannot open output file \"";
- e += outFileName;
- e += "\": ";
- e += cmSystemTools::GetLastSystemError();
- cmSystemTools::Error(e.c_str());
+ std::string e = cmStrCat("Cannot open output file \"", outFileName,
+ "\": ", cmSystemTools::GetLastSystemError());
+ cmSystemTools::Error(e);
return false;
}
cmArchiveWrite::Compress compress = cmArchiveWrite::CompressNone;
@@ -1457,6 +1298,9 @@ bool cmSystemTools::CreateTar(const char* outFileName,
case TarCompressXZ:
compress = cmArchiveWrite::CompressXZ;
break;
+ case TarCompressZstd:
+ compress = cmArchiveWrite::CompressZstd;
+ break;
case TarCompressNone:
compress = cmArchiveWrite::CompressNone;
break;
@@ -1466,22 +1310,18 @@ bool cmSystemTools::CreateTar(const char* outFileName,
a.SetMTime(mtime);
a.SetVerbose(verbose);
- for (std::vector<std::string>::const_iterator i = files.begin();
- i != files.end(); ++i) {
- std::string path = *i;
- if (cmSystemTools::FileIsFullPath(path.c_str())) {
+ bool tarCreatedSuccessfully = true;
+ for (auto path : files) {
+ if (cmSystemTools::FileIsFullPath(path)) {
// Get the relative path to the file.
- path = cmSystemTools::RelativePath(cwd.c_str(), path.c_str());
+ path = cmSystemTools::RelativePath(cwd, path);
}
if (!a.Add(path)) {
- break;
+ cmSystemTools::Error(a.GetError());
+ tarCreatedSuccessfully = false;
}
}
- if (!a) {
- cmSystemTools::Error(a.GetError().c_str());
- return false;
- }
- return true;
+ return tarCreatedSuccessfully;
#else
(void)outFileName;
(void)files;
@@ -1490,10 +1330,10 @@ bool cmSystemTools::CreateTar(const char* outFileName,
#endif
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
namespace {
-#define BSDTAR_FILESIZE_PRINTF "%lu"
-#define BSDTAR_FILESIZE_TYPE unsigned long
+# define BSDTAR_FILESIZE_PRINTF "%lu"
+# define BSDTAR_FILESIZE_TYPE unsigned long
void list_item_verbose(FILE* out, struct archive_entry* entry)
{
char tmp[100];
@@ -1520,22 +1360,22 @@ void list_item_verbose(FILE* out, struct archive_entry* entry)
/* Use uname if it's present, else uid. */
p = archive_entry_uname(entry);
- if ((p == CM_NULLPTR) || (*p == '\0')) {
- sprintf(tmp, "%lu ", (unsigned long)archive_entry_uid(entry));
+ if ((p == nullptr) || (*p == '\0')) {
+ sprintf(tmp, "%lu ", static_cast<unsigned long>(archive_entry_uid(entry)));
p = tmp;
}
w = strlen(p);
if (w > u_width) {
u_width = w;
}
- fprintf(out, "%-*s ", (int)u_width, p);
+ fprintf(out, "%-*s ", static_cast<int>(u_width), p);
/* Use gname if it's present, else gid. */
p = archive_entry_gname(entry);
- if (p != CM_NULLPTR && p[0] != '\0') {
+ if (p != nullptr && p[0] != '\0') {
fprintf(out, "%s", p);
w = strlen(p);
} else {
- sprintf(tmp, "%lu", (unsigned long)archive_entry_gid(entry));
+ sprintf(tmp, "%lu", static_cast<unsigned long>(archive_entry_gid(entry)));
w = strlen(tmp);
fprintf(out, "%s", tmp);
}
@@ -1547,8 +1387,9 @@ void list_item_verbose(FILE* out, struct archive_entry* entry)
*/
if (archive_entry_filetype(entry) == AE_IFCHR ||
archive_entry_filetype(entry) == AE_IFBLK) {
- sprintf(tmp, "%lu,%lu", (unsigned long)archive_entry_rdevmajor(entry),
- (unsigned long)archive_entry_rdevminor(entry));
+ unsigned long rdevmajor = archive_entry_rdevmajor(entry);
+ unsigned long rdevminor = archive_entry_rdevminor(entry);
+ sprintf(tmp, "%lu,%lu", rdevmajor, rdevminor);
} else {
/*
* Note the use of platform-dependent macros to format
@@ -1556,22 +1397,22 @@ void list_item_verbose(FILE* out, struct archive_entry* entry)
* corresponding type for the cast.
*/
sprintf(tmp, BSDTAR_FILESIZE_PRINTF,
- (BSDTAR_FILESIZE_TYPE)archive_entry_size(entry));
+ static_cast<BSDTAR_FILESIZE_TYPE>(archive_entry_size(entry)));
}
if (w + strlen(tmp) >= gs_width) {
gs_width = w + strlen(tmp) + 1;
}
- fprintf(out, "%*s", (int)(gs_width - w), tmp);
+ fprintf(out, "%*s", static_cast<int>(gs_width - w), tmp);
/* Format the time using 'ls -l' conventions. */
tim = archive_entry_mtime(entry);
-#define HALF_YEAR ((time_t)365 * 86400 / 2)
-#if defined(_WIN32) && !defined(__CYGWIN__)
+# define HALF_YEAR ((time_t)365 * 86400 / 2)
+# if defined(_WIN32) && !defined(__CYGWIN__)
/* Windows' strftime function does not support %e format. */
-#define DAY_FMT "%d"
-#else
-#define DAY_FMT "%e" /* Day number without leading zeros */
-#endif
+# define DAY_FMT "%d"
+# else
+# define DAY_FMT "%e" /* Day number without leading zeros */
+# endif
if (tim < now - HALF_YEAR || tim > now + HALF_YEAR) {
fmt = DAY_FMT " %b %Y";
} else {
@@ -1592,38 +1433,77 @@ void list_item_verbose(FILE* out, struct archive_entry* entry)
fflush(out);
}
-long copy_data(struct archive* ar, struct archive* aw)
+void ArchiveError(const char* m1, struct archive* a)
+{
+ std::string message(m1);
+ const char* m2 = archive_error_string(a);
+ if (m2) {
+ message += m2;
+ }
+ cmSystemTools::Error(message);
+}
+
+bool la_diagnostic(struct archive* ar, __LA_SSIZE_T r)
+{
+ // See archive.h definition of ARCHIVE_OK for return values.
+
+ if (r >= ARCHIVE_OK) {
+ return true;
+ }
+
+ if (r >= ARCHIVE_WARN) {
+ const char* warn = archive_error_string(ar);
+ if (!warn) {
+ warn = "unknown warning";
+ }
+ std::cerr << "cmake -E tar: warning: " << warn << '\n';
+ return true;
+ }
+
+ // Error.
+ const char* err = archive_error_string(ar);
+ if (!err) {
+ err = "unknown error";
+ }
+ std::cerr << "cmake -E tar: error: " << err << '\n';
+ return false;
+}
+
+// Return 'true' on success
+bool copy_data(struct archive* ar, struct archive* aw)
{
long r;
const void* buff;
size_t size;
-#if defined(ARCHIVE_VERSION_NUMBER) && ARCHIVE_VERSION_NUMBER >= 3000000
+# if defined(ARCHIVE_VERSION_NUMBER) && ARCHIVE_VERSION_NUMBER >= 3000000
__LA_INT64_T offset;
-#else
+# else
off_t offset;
-#endif
+# endif
for (;;) {
+ // See archive.h definition of ARCHIVE_OK for return values.
r = archive_read_data_block(ar, &buff, &size, &offset);
if (r == ARCHIVE_EOF) {
- return (ARCHIVE_OK);
+ return true;
}
- if (r != ARCHIVE_OK) {
- return (r);
+ if (!la_diagnostic(ar, r)) {
+ return false;
}
- r = archive_write_data_block(aw, buff, size, offset);
- if (r != ARCHIVE_OK) {
- cmSystemTools::Message("archive_write_data_block()",
- archive_error_string(aw));
- return (r);
+ // See archive.h definition of ARCHIVE_OK for return values.
+ __LA_SSIZE_T const w = archive_write_data_block(aw, buff, size, offset);
+ if (!la_diagnostic(ar, w)) {
+ return false;
}
}
-#if !defined(__clang__) && !defined(__HP_aCC)
- return r; /* this should not happen but it quiets some compilers */
-#endif
+# if !defined(__clang__) && !defined(__HP_aCC)
+ return false; /* this should not happen but it quiets some compilers */
+# endif
}
-bool extract_tar(const char* outFileName, bool verbose, bool extract)
+bool extract_tar(const std::string& outFileName,
+ const std::vector<std::string>& files, bool verbose,
+ bool extract)
{
cmLocaleRAII localeRAII;
static_cast<void>(localeRAII);
@@ -1632,10 +1512,24 @@ bool extract_tar(const char* outFileName, bool verbose, bool extract)
archive_read_support_filter_all(a);
archive_read_support_format_all(a);
struct archive_entry* entry;
- int r = cm_archive_read_open_file(a, outFileName, 10240);
+
+ struct archive* matching = archive_match_new();
+ if (matching == nullptr) {
+ cmSystemTools::Error("Out of memory");
+ return false;
+ }
+
+ for (const auto& filename : files) {
+ if (archive_match_include_pattern(matching, filename.c_str()) !=
+ ARCHIVE_OK) {
+ cmSystemTools::Error("Failed to add to inclusion list: " + filename);
+ return false;
+ }
+ }
+
+ int r = cm_archive_read_open_file(a, outFileName.c_str(), 10240);
if (r) {
- cmSystemTools::Error("Problem with archive_read_open_file(): ",
- archive_error_string(a));
+ ArchiveError("Problem with archive_read_open_file(): ", a);
archive_write_free(ext);
archive_read_close(a);
return false;
@@ -1646,56 +1540,80 @@ bool extract_tar(const char* outFileName, bool verbose, bool extract)
break;
}
if (r != ARCHIVE_OK) {
- cmSystemTools::Error("Problem with archive_read_next_header(): ",
- archive_error_string(a));
+ ArchiveError("Problem with archive_read_next_header(): ", a);
break;
}
+
+ if (archive_match_excluded(matching, entry)) {
+ continue;
+ }
+
if (verbose) {
if (extract) {
cmSystemTools::Stdout("x ");
- cmSystemTools::Stdout(cm_archive_entry_pathname(entry).c_str());
+ cmSystemTools::Stdout(cm_archive_entry_pathname(entry));
} else {
list_item_verbose(stdout, entry);
}
cmSystemTools::Stdout("\n");
} else if (!extract) {
- cmSystemTools::Stdout(cm_archive_entry_pathname(entry).c_str());
+ cmSystemTools::Stdout(cm_archive_entry_pathname(entry));
cmSystemTools::Stdout("\n");
}
if (extract) {
r = archive_write_disk_set_options(ext, ARCHIVE_EXTRACT_TIME);
if (r != ARCHIVE_OK) {
- cmSystemTools::Error("Problem with archive_write_disk_set_options(): ",
- archive_error_string(ext));
+ ArchiveError("Problem with archive_write_disk_set_options(): ", ext);
break;
}
r = archive_write_header(ext, entry);
if (r == ARCHIVE_OK) {
- copy_data(a, ext);
+ if (!copy_data(a, ext)) {
+ break;
+ }
r = archive_write_finish_entry(ext);
if (r != ARCHIVE_OK) {
- cmSystemTools::Error("Problem with archive_write_finish_entry(): ",
- archive_error_string(ext));
+ ArchiveError("Problem with archive_write_finish_entry(): ", ext);
break;
}
}
-#ifdef _WIN32
+# ifdef _WIN32
else if (const char* linktext = archive_entry_symlink(entry)) {
std::cerr << "cmake -E tar: warning: skipping symbolic link \""
<< cm_archive_entry_pathname(entry) << "\" -> \"" << linktext
<< "\"." << std::endl;
}
-#endif
+# endif
else {
- cmSystemTools::Error("Problem with archive_write_header(): ",
- archive_error_string(ext));
- cmSystemTools::Error("Current file: ",
- cm_archive_entry_pathname(entry).c_str());
+ ArchiveError("Problem with archive_write_header(): ", ext);
+ cmSystemTools::Error("Current file: " +
+ cm_archive_entry_pathname(entry));
break;
}
}
}
+
+ bool error_occured = false;
+ if (matching != nullptr) {
+ const char* p;
+ int ar;
+
+ while ((ar = archive_match_path_unmatched_inclusions_next(matching, &p)) ==
+ ARCHIVE_OK) {
+ cmSystemTools::Error("tar: " + std::string(p) +
+ ": Not found in archive");
+ error_occured = true;
+ }
+ if (error_occured) {
+ return false;
+ }
+ if (ar == ARCHIVE_FATAL) {
+ cmSystemTools::Error("tar: Out of memory");
+ return false;
+ }
+ }
+ archive_match_free(matching);
archive_write_free(ext);
archive_read_close(a);
archive_read_free(a);
@@ -1704,35 +1622,41 @@ bool extract_tar(const char* outFileName, bool verbose, bool extract)
}
#endif
-bool cmSystemTools::ExtractTar(const char* outFileName, bool verbose)
+bool cmSystemTools::ExtractTar(const std::string& outFileName,
+ const std::vector<std::string>& files,
+ bool verbose)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
- return extract_tar(outFileName, verbose, true);
+#if !defined(CMAKE_BOOTSTRAP)
+ return extract_tar(outFileName, files, verbose, true);
#else
(void)outFileName;
+ (void)files;
(void)verbose;
return false;
#endif
}
-bool cmSystemTools::ListTar(const char* outFileName, bool verbose)
+bool cmSystemTools::ListTar(const std::string& outFileName,
+ const std::vector<std::string>& files,
+ bool verbose)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
- return extract_tar(outFileName, verbose, false);
+#if !defined(CMAKE_BOOTSTRAP)
+ return extract_tar(outFileName, files, verbose, false);
#else
(void)outFileName;
+ (void)files;
(void)verbose;
return false;
#endif
}
int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
- double timeout, std::vector<char>& out,
+ cmDuration timeout, std::vector<char>& out,
std::vector<char>& err)
{
- line = "";
- std::vector<char>::iterator outiter = out.begin();
- std::vector<char>::iterator erriter = err.begin();
+ line.clear();
+ auto outiter = out.begin();
+ auto erriter = err.begin();
cmProcessOutput processOutput;
std::string strdata;
while (true) {
@@ -1775,7 +1699,9 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
// No newlines found. Wait for more data from the process.
int length;
char* data;
- int pipe = cmsysProcess_WaitForData(process, &data, &length, &timeout);
+ double timeoutAsDbl = timeout.count();
+ int pipe =
+ cmsysProcess_WaitForData(process, &data, &length, &timeoutAsDbl);
if (pipe == cmsysProcess_Pipe_Timeout) {
// Timeout has been exceeded.
return pipe;
@@ -1784,26 +1710,26 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
processOutput.DecodeText(data, length, strdata, 1);
// Append to the stdout buffer.
std::vector<char>::size_type size = out.size();
- out.insert(out.end(), strdata.begin(), strdata.end());
+ cmAppend(out, strdata);
outiter = out.begin() + size;
} else if (pipe == cmsysProcess_Pipe_STDERR) {
processOutput.DecodeText(data, length, strdata, 2);
// Append to the stderr buffer.
std::vector<char>::size_type size = err.size();
- err.insert(err.end(), strdata.begin(), strdata.end());
+ cmAppend(err, strdata);
erriter = err.begin() + size;
} else if (pipe == cmsysProcess_Pipe_None) {
// Both stdout and stderr pipes have broken. Return leftover data.
processOutput.DecodeText(std::string(), strdata, 1);
if (!strdata.empty()) {
std::vector<char>::size_type size = out.size();
- out.insert(out.end(), strdata.begin(), strdata.end());
+ cmAppend(out, strdata);
outiter = out.begin() + size;
}
processOutput.DecodeText(std::string(), strdata, 2);
if (!strdata.empty()) {
std::vector<char>::size_type size = err.size();
- err.insert(err.end(), strdata.begin(), strdata.end());
+ cmAppend(err, strdata);
erriter = err.begin() + size;
}
if (!out.empty()) {
@@ -1821,6 +1747,71 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line,
}
}
+#ifdef _WIN32
+static void EnsureStdPipe(DWORD fd)
+{
+ if (GetStdHandle(fd) != INVALID_HANDLE_VALUE) {
+ return;
+ }
+ SECURITY_ATTRIBUTES sa;
+ sa.nLength = sizeof(sa);
+ sa.lpSecurityDescriptor = NULL;
+ sa.bInheritHandle = TRUE;
+
+ HANDLE h = CreateFileW(
+ L"NUL",
+ fd == STD_INPUT_HANDLE ? FILE_GENERIC_READ
+ : FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, &sa, OPEN_EXISTING, 0, NULL);
+
+ if (h == INVALID_HANDLE_VALUE) {
+ LPSTR message = NULL;
+ DWORD size = FormatMessageA(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPSTR)&message, 0, NULL);
+ std::string msg = std::string(message, size);
+ LocalFree(message);
+ std::cerr << "failed to open NUL for missing stdio pipe: " << msg;
+ abort();
+ }
+
+ SetStdHandle(fd, h);
+}
+
+void cmSystemTools::EnsureStdPipes()
+{
+ EnsureStdPipe(STD_INPUT_HANDLE);
+ EnsureStdPipe(STD_OUTPUT_HANDLE);
+ EnsureStdPipe(STD_ERROR_HANDLE);
+}
+#else
+static void EnsureStdPipe(int fd)
+{
+ if (fcntl(fd, F_GETFD) != -1 || errno != EBADF) {
+ return;
+ }
+
+ int f = open("/dev/null", fd == STDIN_FILENO ? O_RDONLY : O_WRONLY);
+ if (f == -1) {
+ perror("failed to open /dev/null for missing stdio pipe");
+ abort();
+ }
+ if (f != fd) {
+ dup2(f, fd);
+ close(f);
+ }
+}
+
+void cmSystemTools::EnsureStdPipes()
+{
+ EnsureStdPipe(STDIN_FILENO);
+ EnsureStdPipe(STDOUT_FILENO);
+ EnsureStdPipe(STDERR_FILENO);
+}
+#endif
+
void cmSystemTools::DoNotInheritStdPipes()
{
#ifdef _WIN32
@@ -1848,92 +1839,10 @@ void cmSystemTools::DoNotInheritStdPipes()
#endif
}
-bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile)
-{
-#if defined(_WIN32) && !defined(__CYGWIN__)
- cmSystemToolsWindowsHandle hFrom = CreateFileW(
- SystemTools::ConvertToWindowsExtendedPath(fromFile).c_str(), GENERIC_READ,
- FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
- cmSystemToolsWindowsHandle hTo = CreateFileW(
- SystemTools::ConvertToWindowsExtendedPath(toFile).c_str(),
- FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
- if (!hFrom || !hTo) {
- return false;
- }
- FILETIME timeCreation;
- FILETIME timeLastAccess;
- FILETIME timeLastWrite;
- if (!GetFileTime(hFrom, &timeCreation, &timeLastAccess, &timeLastWrite)) {
- return false;
- }
- return SetFileTime(hTo, &timeCreation, &timeLastAccess, &timeLastWrite) != 0;
-#else
- struct stat fromStat;
- if (stat(fromFile, &fromStat) < 0) {
- return false;
- }
-
- struct utimbuf buf;
- buf.actime = fromStat.st_atime;
- buf.modtime = fromStat.st_mtime;
- return utime(toFile, &buf) >= 0;
-#endif
-}
-
-cmSystemToolsFileTime* cmSystemTools::FileTimeNew()
-{
- return new cmSystemToolsFileTime;
-}
-
-void cmSystemTools::FileTimeDelete(cmSystemToolsFileTime* t)
-{
- delete t;
-}
-
-bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t)
-{
-#if defined(_WIN32) && !defined(__CYGWIN__)
- cmSystemToolsWindowsHandle h = CreateFileW(
- SystemTools::ConvertToWindowsExtendedPath(fname).c_str(), GENERIC_READ,
- FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
- if (!h) {
- return false;
- }
- if (!GetFileTime(h, &t->timeCreation, &t->timeLastAccess,
- &t->timeLastWrite)) {
- return false;
- }
-#else
- struct stat st;
- if (stat(fname, &st) < 0) {
- return false;
- }
- t->timeBuf.actime = st.st_atime;
- t->timeBuf.modtime = st.st_mtime;
-#endif
- return true;
-}
-
-bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t)
-{
-#if defined(_WIN32) && !defined(__CYGWIN__)
- cmSystemToolsWindowsHandle h = CreateFileW(
- SystemTools::ConvertToWindowsExtendedPath(fname).c_str(),
- FILE_WRITE_ATTRIBUTES, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
- if (!h) {
- return false;
- }
- return SetFileTime(h, &t->timeCreation, &t->timeLastAccess,
- &t->timeLastWrite) != 0;
-#else
- return utime(fname, &t->timeBuf) >= 0;
-#endif
-}
-
#ifdef _WIN32
-#ifndef CRYPT_SILENT
-#define CRYPT_SILENT 0x40 /* Not defined by VS 6 version of header. */
-#endif
+# ifndef CRYPT_SILENT
+# define CRYPT_SILENT 0x40 /* Not defined by VS 6 version of header. */
+# endif
static int WinCryptRandom(void* data, size_t size)
{
int result = 0;
@@ -1973,7 +1882,7 @@ unsigned int cmSystemTools::RandomSeed()
// Try using a real random source.
cmsys::ifstream fin;
- fin.rdbuf()->pubsetbuf(CM_NULLPTR, 0); // Unbuffered read.
+ fin.rdbuf()->pubsetbuf(nullptr, 0); // Unbuffered read.
fin.open("/dev/urandom");
if (fin.good() && fin.read(seed.bytes, sizeof(seed)) &&
fin.gcount() == sizeof(seed)) {
@@ -1982,7 +1891,7 @@ unsigned int cmSystemTools::RandomSeed()
// Fall back to the time and pid.
struct timeval t;
- gettimeofday(&t, CM_NULLPTR);
+ gettimeofday(&t, nullptr);
unsigned int pid = static_cast<unsigned int>(getpid());
unsigned int tv_sec = static_cast<unsigned int>(t.tv_sec);
unsigned int tv_usec = static_cast<unsigned int>(t.tv_usec);
@@ -2006,21 +1915,26 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
(void)argv0; // ignore this on windows
wchar_t modulepath[_MAX_PATH];
::GetModuleFileNameW(NULL, modulepath, sizeof(modulepath));
- exe_dir =
- cmSystemTools::GetFilenamePath(cmsys::Encoding::ToNarrow(modulepath));
+ std::string path = cmsys::Encoding::ToNarrow(modulepath);
+ std::string realPath =
+ cmSystemTools::GetRealPathResolvingWindowsSubst(path, NULL);
+ if (realPath.empty()) {
+ realPath = path;
+ }
+ exe_dir = cmSystemTools::GetFilenamePath(realPath);
#elif defined(__APPLE__)
(void)argv0; // ignore this on OS X
-#define CM_EXE_PATH_LOCAL_SIZE 16384
+# define CM_EXE_PATH_LOCAL_SIZE 16384
char exe_path_local[CM_EXE_PATH_LOCAL_SIZE];
-#if defined(MAC_OS_X_VERSION_10_3) && !defined(MAC_OS_X_VERSION_10_4)
+# if defined(MAC_OS_X_VERSION_10_3) && !defined(MAC_OS_X_VERSION_10_4)
unsigned long exe_path_size = CM_EXE_PATH_LOCAL_SIZE;
-#else
+# else
uint32_t exe_path_size = CM_EXE_PATH_LOCAL_SIZE;
-#endif
-#undef CM_EXE_PATH_LOCAL_SIZE
+# endif
+# undef CM_EXE_PATH_LOCAL_SIZE
char* exe_path = exe_path_local;
if (_NSGetExecutablePath(exe_path, &exe_path_size) < 0) {
- exe_path = (char*)malloc(exe_path_size);
+ exe_path = static_cast<char*>(malloc(exe_path_size));
_NSGetExecutablePath(exe_path, &exe_path_size);
}
exe_dir =
@@ -2052,40 +1966,34 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
}
#endif
exe_dir = cmSystemTools::GetActualCaseForPath(exe_dir);
- cmSystemToolsCMakeCommand = exe_dir;
- cmSystemToolsCMakeCommand += "/cmake";
- cmSystemToolsCMakeCommand += cmSystemTools::GetExecutableExtension();
-#ifndef CMAKE_BUILD_WITH_CMAKE
+ cmSystemToolsCMakeCommand =
+ cmStrCat(exe_dir, "/cmake", cmSystemTools::GetExecutableExtension());
+#ifdef CMAKE_BOOTSTRAP
// The bootstrap cmake does not provide the other tools,
// so use the directory where they are about to be built.
exe_dir = CMAKE_BOOTSTRAP_BINARY_DIR "/bin";
#endif
- cmSystemToolsCTestCommand = exe_dir;
- cmSystemToolsCTestCommand += "/ctest";
- cmSystemToolsCTestCommand += cmSystemTools::GetExecutableExtension();
- cmSystemToolsCPackCommand = exe_dir;
- cmSystemToolsCPackCommand += "/cpack";
- cmSystemToolsCPackCommand += cmSystemTools::GetExecutableExtension();
- cmSystemToolsCMakeGUICommand = exe_dir;
- cmSystemToolsCMakeGUICommand += "/cmake-gui";
- cmSystemToolsCMakeGUICommand += cmSystemTools::GetExecutableExtension();
- if (!cmSystemTools::FileExists(cmSystemToolsCMakeGUICommand.c_str())) {
- cmSystemToolsCMakeGUICommand = "";
- }
- cmSystemToolsCMakeCursesCommand = exe_dir;
- cmSystemToolsCMakeCursesCommand += "/ccmake";
- cmSystemToolsCMakeCursesCommand += cmSystemTools::GetExecutableExtension();
- if (!cmSystemTools::FileExists(cmSystemToolsCMakeCursesCommand.c_str())) {
- cmSystemToolsCMakeCursesCommand = "";
- }
- cmSystemToolsCMClDepsCommand = exe_dir;
- cmSystemToolsCMClDepsCommand += "/cmcldeps";
- cmSystemToolsCMClDepsCommand += cmSystemTools::GetExecutableExtension();
- if (!cmSystemTools::FileExists(cmSystemToolsCMClDepsCommand.c_str())) {
- cmSystemToolsCMClDepsCommand = "";
- }
-
-#ifdef CMAKE_BUILD_WITH_CMAKE
+ cmSystemToolsCTestCommand =
+ cmStrCat(exe_dir, "/ctest", cmSystemTools::GetExecutableExtension());
+ cmSystemToolsCPackCommand =
+ cmStrCat(exe_dir, "/cpack", cmSystemTools::GetExecutableExtension());
+ cmSystemToolsCMakeGUICommand =
+ cmStrCat(exe_dir, "/cmake-gui", cmSystemTools::GetExecutableExtension());
+ if (!cmSystemTools::FileExists(cmSystemToolsCMakeGUICommand)) {
+ cmSystemToolsCMakeGUICommand.clear();
+ }
+ cmSystemToolsCMakeCursesCommand =
+ cmStrCat(exe_dir, "/ccmake", cmSystemTools::GetExecutableExtension());
+ if (!cmSystemTools::FileExists(cmSystemToolsCMakeCursesCommand)) {
+ cmSystemToolsCMakeCursesCommand.clear();
+ }
+ cmSystemToolsCMClDepsCommand =
+ cmStrCat(exe_dir, "/cmcldeps", cmSystemTools::GetExecutableExtension());
+ if (!cmSystemTools::FileExists(cmSystemToolsCMClDepsCommand)) {
+ cmSystemToolsCMClDepsCommand.clear();
+ }
+
+#ifndef CMAKE_BOOTSTRAP
// Install tree has
// - "<prefix><CMAKE_BIN_DIR>/cmake"
// - "<prefix><CMAKE_DATA_DIR>"
@@ -2096,7 +2004,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
}
if (cmSystemToolsCMakeRoot.empty() ||
!cmSystemTools::FileExists(
- (cmSystemToolsCMakeRoot + "/Modules/CMake.cmake").c_str())) {
+ (cmSystemToolsCMakeRoot + "/Modules/CMake.cmake"))) {
// Build tree has "<build>/bin[/<config>]/cmake" and
// "<build>/CMakeFiles/CMakeSourceDir.txt".
std::string dir = cmSystemTools::GetFilenamePath(exe_dir);
@@ -2280,12 +2188,13 @@ struct cmSystemToolsRPathInfo
};
#endif
+#if defined(CMAKE_USE_ELF_PARSER)
bool cmSystemTools::ChangeRPath(std::string const& file,
std::string const& oldRPath,
- std::string const& newRPath, std::string* emsg,
+ std::string const& newRPath,
+ bool removeEnvironmentRPath, std::string* emsg,
bool* changed)
{
-#if defined(CMAKE_USE_ELF_PARSER)
if (changed) {
*changed = false;
}
@@ -2298,8 +2207,8 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
// Get the RPATH and RUNPATH entries from it.
int se_count = 0;
- cmELF::StringEntry const* se[2] = { CM_NULLPTR, CM_NULLPTR };
- const char* se_name[2] = { CM_NULLPTR, CM_NULLPTR };
+ cmELF::StringEntry const* se[2] = { nullptr, nullptr };
+ const char* se_name[2] = { nullptr, nullptr };
if (cmELF::StringEntry const* se_rpath = elf.GetRPath()) {
se[se_count] = se_rpath;
se_name[se_count] = "RPATH";
@@ -2317,8 +2226,9 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
return true;
}
if (emsg) {
- *emsg = "No valid ELF RPATH or RUNPATH entry exists in the file; ";
- *emsg += elf.GetErrorMessage();
+ *emsg =
+ cmStrCat("No valid ELF RPATH or RUNPATH entry exists in the file; ",
+ elf.GetErrorMessage());
}
return false;
}
@@ -2370,7 +2280,9 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
// Construct the new value which preserves the part of the path
// not being changed.
- rp[rp_count].Value = se[i]->Value.substr(0, prefix_len);
+ if (!removeEnvironmentRPath) {
+ rp[rp_count].Value = se[i]->Value.substr(0, prefix_len);
+ }
rp[rp_count].Value += newRPath;
rp[rp_count].Value += se[i]->Value.substr(pos + oldRPath.length());
@@ -2382,9 +2294,8 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
// least one null terminator.
if (rp[rp_count].Size < rp[rp_count].Value.length() + 1) {
if (emsg) {
- *emsg = "The replacement path is too long for the ";
- *emsg += se_name[i];
- *emsg += " entry.";
+ *emsg = cmStrCat("The replacement path is too long for the ",
+ se_name[i], " entry.");
}
return false;
}
@@ -2420,9 +2331,7 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
// Seek to the RPATH position.
if (!f.seekp(rp[i].Position)) {
if (emsg) {
- *emsg = "Error seeking to ";
- *emsg += rp[i].Name;
- *emsg += " position.";
+ *emsg = cmStrCat("Error seeking to ", rp[i].Name, " position.");
}
return false;
}
@@ -2437,9 +2346,8 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
// Make sure it wrote correctly.
if (!f) {
if (emsg) {
- *emsg = "Error writing the new ";
- *emsg += rp[i].Name;
- *emsg += " string to the file.";
+ *emsg = cmStrCat("Error writing the new ", rp[i].Name,
+ " string to the file.");
}
return false;
}
@@ -2451,22 +2359,25 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
*changed = true;
}
return true;
+}
#else
- (void)file;
- (void)oldRPath;
- (void)newRPath;
- (void)emsg;
- (void)changed;
+bool cmSystemTools::ChangeRPath(std::string const& /*file*/,
+ std::string const& /*oldRPath*/,
+ std::string const& /*newRPath*/,
+ bool /*removeEnvironmentRPath*/,
+ std::string* /*emsg*/, bool* /*changed*/)
+{
return false;
-#endif
}
+#endif
bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op,
const char* lhss, const char* rhss)
{
const char* endl = lhss;
const char* endr = rhss;
- unsigned long lhs, rhs;
+ unsigned long lhs;
+ unsigned long rhs;
while (((*endl >= '0') && (*endl <= '9')) ||
((*endr >= '0') && (*endr <= '9'))) {
@@ -2593,10 +2504,10 @@ int cmSystemTools::strverscmp(std::string const& lhs, std::string const& rhs)
return cm_strverscmp(lhs.c_str(), rhs.c_str());
}
+#if defined(CMAKE_USE_ELF_PARSER)
bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
bool* removed)
{
-#if defined(CMAKE_USE_ELF_PARSER)
if (removed) {
*removed = false;
}
@@ -2612,7 +2523,7 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
// Get the RPATH and RUNPATH entries from it and sort them by index
// in the dynamic section header.
int se_count = 0;
- cmELF::StringEntry const* se[2] = { CM_NULLPTR, CM_NULLPTR };
+ cmELF::StringEntry const* se[2] = { nullptr, nullptr };
if (cmELF::StringEntry const* se_rpath = elf.GetRPath()) {
se[se_count++] = se_rpath;
}
@@ -2651,8 +2562,7 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
// Adjust the entry list as necessary to remove the run path
unsigned long entriesErased = 0;
- for (cmELF::DynamicEntryList::iterator it = dentries.begin();
- it != dentries.end();) {
+ for (auto it = dentries.begin(); it != dentries.end();) {
if (it->first == cmELF::TagRPath || it->first == cmELF::TagRunPath) {
it = dentries.erase(it);
entriesErased++;
@@ -2666,11 +2576,11 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
// contain the location of the linker map, however on MIPS the
// .dynamic section is always read-only so this is not possible. MIPS
// objects instead contain a DT_MIPS_RLD_MAP tag which contains the
- // address where the dyanmic linker will write to (an indirect
+ // address where the dynamic linker will write to (an indirect
// version of DT_DEBUG). Since this doesn't work when using PIE, a
// relative equivalent was created - DT_MIPS_RLD_MAP_REL. Since this
// version contains a relative offset, moving it changes the
- // calculated address. This may cause the dyanmic linker to write
+ // calculated address. This may cause the dynamic linker to write
// into memory it should not be changing.
//
// To fix this, we adjust the value of DT_MIPS_RLD_MAP_REL here. If
@@ -2734,13 +2644,14 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg,
*removed = true;
}
return true;
+}
#else
- (void)file;
- (void)emsg;
- (void)removed;
+bool cmSystemTools::RemoveRPath(std::string const& /*file*/,
+ std::string* /*emsg*/, bool* /*removed*/)
+{
return false;
-#endif
}
+#endif
bool cmSystemTools::CheckRPath(std::string const& file,
std::string const& newRPath)
@@ -2774,55 +2685,97 @@ bool cmSystemTools::CheckRPath(std::string const& file,
#endif
}
-bool cmSystemTools::RepeatedRemoveDirectory(const char* dir)
+bool cmSystemTools::RepeatedRemoveDirectory(const std::string& dir)
{
+#ifdef _WIN32
// Windows sometimes locks files temporarily so try a few times.
- for (int i = 0; i < 10; ++i) {
+ WindowsFileRetry retry = cmSystemTools::GetWindowsFileRetry();
+
+ for (unsigned int i = 0; i < retry.Count; ++i) {
if (cmSystemTools::RemoveADirectory(dir)) {
return true;
}
- cmSystemTools::Delay(100);
+ cmSystemTools::Delay(retry.Delay);
}
return false;
+#else
+ return cmSystemTools::RemoveADirectory(dir);
+#endif
}
-std::vector<std::string> cmSystemTools::tokenize(const std::string& str,
- const std::string& sep)
-{
- std::vector<std::string> tokens;
- std::string::size_type tokend = 0;
-
- do {
- std::string::size_type tokstart = str.find_first_not_of(sep, tokend);
- if (tokstart == std::string::npos) {
- break; // no more tokens
- }
- tokend = str.find_first_of(sep, tokstart);
- if (tokend == std::string::npos) {
- tokens.push_back(str.substr(tokstart));
- } else {
- tokens.push_back(str.substr(tokstart, tokend - tokstart));
+std::string cmSystemTools::EncodeURL(std::string const& in, bool escapeSlashes)
+{
+ std::string out;
+ for (char c : in) {
+ char hexCh[4] = { 0, 0, 0, 0 };
+ hexCh[0] = c;
+ switch (c) {
+ case '+':
+ case '?':
+ case '\\':
+ case '&':
+ case ' ':
+ case '=':
+ case '%':
+ sprintf(hexCh, "%%%02X", static_cast<int>(c));
+ break;
+ case '/':
+ if (escapeSlashes) {
+ strcpy(hexCh, "%2F");
+ }
+ break;
+ default:
+ break;
}
- } while (tokend != std::string::npos);
-
- if (tokens.empty()) {
- tokens.push_back("");
+ out.append(hexCh);
}
- return tokens;
+ return out;
}
-bool cmSystemTools::StringToLong(const char* str, long* value)
+bool cmSystemTools::CreateSymlink(const std::string& origName,
+ const std::string& newName,
+ std::string* errorMessage)
{
- errno = 0;
- char* endp;
- *value = strtol(str, &endp, 10);
- return (*endp == '\0') && (endp != str) && (errno == 0);
+ uv_fs_t req;
+ int flags = 0;
+#if defined(_WIN32)
+ if (cmsys::SystemTools::FileIsDirectory(origName)) {
+ flags |= UV_FS_SYMLINK_DIR;
+ }
+#endif
+ int err = uv_fs_symlink(nullptr, &req, origName.c_str(), newName.c_str(),
+ flags, nullptr);
+ if (err) {
+ std::string e =
+ "failed to create symbolic link '" + newName + "': " + uv_strerror(err);
+ if (errorMessage) {
+ *errorMessage = std::move(e);
+ } else {
+ cmSystemTools::Error(e);
+ }
+ return false;
+ }
+
+ return true;
}
-bool cmSystemTools::StringToULong(const char* str, unsigned long* value)
+bool cmSystemTools::CreateLink(const std::string& origName,
+ const std::string& newName,
+ std::string* errorMessage)
{
- errno = 0;
- char* endp;
- *value = strtoul(str, &endp, 10);
- return (*endp == '\0') && (endp != str) && (errno == 0);
+ uv_fs_t req;
+ int err =
+ uv_fs_link(nullptr, &req, origName.c_str(), newName.c_str(), nullptr);
+ if (err) {
+ std::string e =
+ "failed to create link '" + newName + "': " + uv_strerror(err);
+ if (errorMessage) {
+ *errorMessage = std::move(e);
+ } else {
+ cmSystemTools::Error(e);
+ }
+ return false;
+ }
+
+ return true;
}
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 9de796728..ee149a029 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -3,16 +3,21 @@
#ifndef cmSystemTools_h
#define cmSystemTools_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmProcessOutput.h"
-#include "cmsys/Process.h"
-#include "cmsys/SystemTools.hxx" // IWYU pragma: export
-#include <stddef.h>
+#include <cstddef>
+#include <functional>
#include <string>
#include <vector>
-class cmSystemToolsFileTime;
+#include <cm/string_view>
+
+#include "cmsys/Process.h"
+#include "cmsys/SystemTools.hxx" // IWYU pragma: export
+
+#include "cmCryptoHash.h"
+#include "cmDuration.h"
+#include "cmProcessOutput.h"
/** \class cmSystemTools
* \brief A collection of useful functions for CMake.
@@ -23,18 +28,8 @@ class cmSystemToolsFileTime;
class cmSystemTools : public cmsys::SystemTools
{
public:
- typedef cmsys::SystemTools Superclass;
- typedef cmProcessOutput::Encoding Encoding;
-
- /** Expand out any arguments in the vector that have ; separated
- * strings into multiple arguments. A new vector is created
- * containing the expanded versions of all arguments in argsIn.
- */
- static void ExpandList(std::vector<std::string> const& argsIn,
- std::vector<std::string>& argsOut);
- static void ExpandListArgument(const std::string& arg,
- std::vector<std::string>& argsOut,
- bool emptyArgs = false);
+ using Superclass = cmsys::SystemTools;
+ using Encoding = cmProcessOutput::Encoding;
/**
* Look for and replace registry values in a string
@@ -42,117 +37,80 @@ public:
static void ExpandRegistryValues(std::string& source,
KeyWOW64 view = KeyWOW64_Default);
- ///! Escape quotes in a string.
- static std::string EscapeQuotes(const std::string& str);
-
/** Map help document name to file name. */
- static std::string HelpFileName(std::string);
+ static std::string HelpFileName(cm::string_view);
- /**
- * Returns a string that has whitespace removed from the start and the end.
- */
- static std::string TrimWhitespace(const std::string& s);
-
- typedef void (*MessageCallback)(const char*, const char*, bool&, void*);
+ using MessageCallback = std::function<void(const std::string&, const char*)>;
/**
* Set the function used by GUIs to display error messages
* Function gets passed: message as a const char*,
- * title as a const char*, and a reference to bool that when
- * set to false, will disable furthur messages (cancel).
+ * title as a const char*.
*/
- static void SetMessageCallback(MessageCallback f,
- void* clientData = CM_NULLPTR);
+ static void SetMessageCallback(MessageCallback f);
/**
* Display an error message.
*/
- static void Error(const char* m, const char* m2 = CM_NULLPTR,
- const char* m3 = CM_NULLPTR, const char* m4 = CM_NULLPTR);
+ static void Error(const std::string& m);
/**
* Display a message.
*/
- static void Message(const char* m, const char* title = CM_NULLPTR);
+ static void Message(const std::string& m, const char* title = nullptr);
- typedef void (*OutputCallback)(const char*, size_t length, void*);
+ using OutputCallback = std::function<void(std::string const&)>;
- ///! Send a string to stdout
- static void Stdout(const char* s);
- static void Stdout(const char* s, size_t length);
- static void SetStdoutCallback(OutputCallback, void* clientData = CM_NULLPTR);
+ //! Send a string to stdout
+ static void Stdout(const std::string& s);
+ static void SetStdoutCallback(OutputCallback f);
- ///! Send a string to stderr
- static void Stderr(const char* s);
- static void Stderr(const char* s, size_t length);
- static void SetStderrCallback(OutputCallback, void* clientData = CM_NULLPTR);
+ //! Send a string to stderr
+ static void Stderr(const std::string& s);
+ static void SetStderrCallback(OutputCallback f);
- typedef bool (*InterruptCallback)(void*);
- static void SetInterruptCallback(InterruptCallback f,
- void* clientData = CM_NULLPTR);
+ using InterruptCallback = std::function<bool()>;
+ static void SetInterruptCallback(InterruptCallback f);
static bool GetInterruptFlag();
- ///! Return true if there was an error at any point.
+ //! Return true if there was an error at any point.
static bool GetErrorOccuredFlag()
{
return cmSystemTools::s_ErrorOccured ||
cmSystemTools::s_FatalErrorOccured || GetInterruptFlag();
}
- ///! If this is set to true, cmake stops processing commands.
+ //! If this is set to true, cmake stops processing commands.
static void SetFatalErrorOccured()
{
cmSystemTools::s_FatalErrorOccured = true;
}
static void SetErrorOccured() { cmSystemTools::s_ErrorOccured = true; }
- ///! Return true if there was an error at any point.
+ //! Return true if there was an error at any point.
static bool GetFatalErrorOccured()
{
return cmSystemTools::s_FatalErrorOccured || GetInterruptFlag();
}
- ///! Set the error occurred flag and fatal error back to false
+ //! Set the error occurred flag and fatal error back to false
static void ResetErrorOccuredFlag()
{
cmSystemTools::s_FatalErrorOccured = false;
cmSystemTools::s_ErrorOccured = false;
}
- /**
- * Does a string indicates that CMake/CPack/CTest internally
- * forced this value. This is not the same as On, but this
- * may be considered as "internally switched on".
- */
- static bool IsInternallyOn(const char* val);
- /**
- * does a string indicate a true or on value ? This is not the same
- * as ifdef.
- */
- static bool IsOn(const char* val);
-
- /**
- * does a string indicate a false or off value ? Note that this is
- * not the same as !IsOn(...) because there are a number of
- * ambiguous values such as "/usr/local/bin" a path will result in
- * IsON and IsOff both returning false. Note that the special path
- * NOTFOUND, *-NOTFOUND or IGNORE will cause IsOff to return true.
- */
- static bool IsOff(const char* val);
-
- ///! Return true if value is NOTFOUND or ends in -NOTFOUND.
- static bool IsNOTFOUND(const char* value);
- ///! Return true if the path is a framework
- static bool IsPathToFramework(const char* value);
+ //! Return true if the path is a framework
+ static bool IsPathToFramework(const std::string& value);
static bool DoesFileExistWithExtensions(
- const char* name, const std::vector<std::string>& sourceExts);
+ const std::string& name, const std::vector<std::string>& sourceExts);
/**
* Check if the given file exists in one of the parent directory of the
* given file or directory and if it does, return the name of the file.
* Toplevel specifies the top-most directory to where it will look.
*/
- static std::string FileExistsInParentDirectories(const char* fname,
- const char* directory,
- const char* toplevel);
+ static std::string FileExistsInParentDirectories(
+ const std::string& fname, const std::string& directory,
+ const std::string& toplevel);
static void Glob(const std::string& directory, const std::string& regexp,
std::vector<std::string>& files);
@@ -166,26 +124,28 @@ public:
* to be at the end of the string and it does not support ?
* []... The optional argument type specifies what kind of files you
* want to find. 0 means all files, -1 means directories, 1 means
- * files only. This method returns true if search was succesfull.
+ * files only. This method returns true if search was successful.
*/
static bool SimpleGlob(const std::string& glob,
std::vector<std::string>& files, int type = 0);
- ///! Copy a file.
- static bool cmCopyFile(const char* source, const char* destination);
- static bool CopyFileIfDifferent(const char* source, const char* destination);
-
/** Rename a file or directory within a single disk volume (atomic
if possible). */
- static bool RenameFile(const char* oldname, const char* newname);
+ static bool RenameFile(const std::string& oldname,
+ const std::string& newname);
- ///! Compute the md5sum of a file
- static bool ComputeFileMD5(const std::string& source, char* md5out);
+ //! Rename a file if contents are different, delete the source otherwise
+ static void MoveFileIfDifferent(const std::string& source,
+ const std::string& destination);
+
+ //! Compute the hash of a file
+ static std::string ComputeFileHash(const std::string& source,
+ cmCryptoHash::Algo algo);
/** Compute the md5sum of a string. */
static std::string ComputeStringMD5(const std::string& input);
- ///! Get the SHA thumbprint for a certificate file
+ //! Get the SHA thumbprint for a certificate file
static std::string ComputeCertificateThumbprint(const std::string& source);
/**
@@ -217,25 +177,25 @@ public:
OUTPUT_FORWARD,
OUTPUT_PASSTHROUGH
};
- static bool RunSingleCommand(const char* command,
- std::string* captureStdOut = CM_NULLPTR,
- std::string* captureStdErr = CM_NULLPTR,
- int* retVal = CM_NULLPTR,
- const char* dir = CM_NULLPTR,
+ static bool RunSingleCommand(const std::string& command,
+ std::string* captureStdOut = nullptr,
+ std::string* captureStdErr = nullptr,
+ int* retVal = nullptr,
+ const char* dir = nullptr,
OutputOption outputflag = OUTPUT_MERGE,
- double timeout = 0.0);
+ cmDuration timeout = cmDuration::zero());
/**
* In this version of RunSingleCommand, command[0] should be
* the command to run, and each argument to the command should
- * be in comand[1]...command[command.size()]
+ * be in command[1]...command[command.size()]
*/
static bool RunSingleCommand(std::vector<std::string> const& command,
- std::string* captureStdOut = CM_NULLPTR,
- std::string* captureStdErr = CM_NULLPTR,
- int* retVal = CM_NULLPTR,
- const char* dir = CM_NULLPTR,
+ std::string* captureStdOut = nullptr,
+ std::string* captureStdErr = nullptr,
+ int* retVal = nullptr,
+ const char* dir = nullptr,
OutputOption outputflag = OUTPUT_MERGE,
- double timeout = 0.0,
+ cmDuration timeout = cmDuration::zero(),
Encoding encoding = cmProcessOutput::Auto);
static std::string PrintSingleCommand(std::vector<std::string> const&);
@@ -243,7 +203,7 @@ public:
/**
* Parse arguments out of a single string command
*/
- static std::vector<std::string> ParseArguments(const char* command);
+ static std::vector<std::string> ParseArguments(const std::string& command);
/** Parse arguments out of a windows command line string. */
static void ParseWindowsCommandLine(const char* command,
@@ -253,6 +213,11 @@ public:
static void ParseUnixCommandLine(const char* command,
std::vector<std::string>& args);
+ /** Split a command-line string into the parsed command and the unparsed
+ arguments. Returns false on unfinished quoting or escaping. */
+ static bool SplitProgramFromArgs(std::string const& command,
+ std::string& program, std::string& args);
+
/**
* Handle response file in an argument list and return a new argument list
* **/
@@ -262,32 +227,10 @@ public:
static size_t CalculateCommandLineLengthLimit();
- static void EnableMessages() { s_DisableMessages = false; }
- static void DisableMessages() { s_DisableMessages = true; }
static void DisableRunCommandOutput() { s_DisableRunCommandOutput = true; }
static void EnableRunCommandOutput() { s_DisableRunCommandOutput = false; }
static bool GetRunCommandOutput() { return s_DisableRunCommandOutput; }
- /**
- * Some constants for different file formats.
- */
- enum FileFormat
- {
- NO_FILE_FORMAT = 0,
- C_FILE_FORMAT,
- CXX_FILE_FORMAT,
- FORTRAN_FILE_FORMAT,
- JAVA_FILE_FORMAT,
- HEADER_FILE_FORMAT,
- RESOURCE_FILE_FORMAT,
- DEFINITION_FILE_FORMAT,
- STATIC_LIBRARY_FILE_FORMAT,
- SHARED_LIBRARY_FILE_FORMAT,
- MODULE_FILE_FORMAT,
- OBJECT_FILE_FORMAT,
- UNKNOWN_FILE_FORMAT
- };
-
enum CompareOp
{
OP_EQUAL = 1,
@@ -318,13 +261,8 @@ public:
*/
static int strverscmp(std::string const& lhs, std::string const& rhs);
- /**
- * Determine the file type based on the extension
- */
- static FileFormat GetFileFormat(const char* ext);
-
/** Windows if this is true, the CreateProcess in RunCommand will
- * not show new consol windows when running programs.
+ * not show new console windows when running programs.
*/
static void SetRunCommandHideConsole(bool v) { s_RunCommandHideConsole = v; }
static bool GetRunCommandHideConsole() { return s_RunCommandHideConsole; }
@@ -335,23 +273,20 @@ public:
/** a general output handler for cmsysProcess */
static int WaitForLine(cmsysProcess* process, std::string& line,
- double timeout, std::vector<char>& out,
+ cmDuration timeout, std::vector<char>& out,
std::vector<char>& err);
- /** Split a string on its newlines into multiple lines. Returns
- false only if the last line stored had no newline. */
- static bool Split(const char* s, std::vector<std::string>& l);
static void SetForceUnixPaths(bool v) { s_ForceUnixPaths = v; }
static bool GetForceUnixPaths() { return s_ForceUnixPaths; }
// ConvertToOutputPath use s_ForceUnixPaths
- static std::string ConvertToOutputPath(const char* path);
+ static std::string ConvertToOutputPath(std::string const& path);
static void ConvertToOutputSlashes(std::string& path);
// ConvertToRunCommandPath does not use s_ForceUnixPaths and should
// be used when RunCommand is called from cmake, because the
// running cmake needs paths to be in its format
- static std::string ConvertToRunCommandPath(const char* path);
+ static std::string ConvertToRunCommandPath(const std::string& path);
/** compute the relative path from local to remote. local must
be a directory. remote can be a file or a directory.
@@ -361,15 +296,18 @@ public:
/a/b/c/d to /a/b/c1/d1 -> ../../c1/d1
from /usr/src to /usr/src/test/blah/foo.cpp -> test/blah/foo.cpp
*/
- static std::string RelativePath(const char* local, const char* remote);
+ static std::string RelativePath(std::string const& local,
+ std::string const& remote);
- /** Joins two paths while collapsing x/../ parts
- * For example CollapseCombinedPath("a/b/c", "../../d") results in "a/d"
+ /**
+ * Convert the given remote path to a relative path with respect to
+ * the given local path. Both paths must use forward slashes and not
+ * already be escaped or quoted.
*/
- static std::string CollapseCombinedPath(std::string const& dir,
- std::string const& file);
+ static std::string ForceToRelativePath(std::string const& local_path,
+ std::string const& remote_path);
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
/** Remove an environment variable */
static bool UnsetEnv(const char* value);
@@ -386,11 +324,13 @@ public:
original environment. */
class SaveRestoreEnvironment
{
- CM_DISABLE_COPY(SaveRestoreEnvironment)
public:
SaveRestoreEnvironment();
~SaveRestoreEnvironment();
+ SaveRestoreEnvironment(SaveRestoreEnvironment const&) = delete;
+ SaveRestoreEnvironment& operator=(SaveRestoreEnvironment const&) = delete;
+
private:
std::vector<std::string> Env;
};
@@ -399,21 +339,33 @@ public:
/** Setup the environment to enable VS 8 IDE output. */
static void EnableVSConsoleOutput();
+ enum cmTarAction
+ {
+ TarActionCreate,
+ TarActionList,
+ TarActionExtract,
+ TarActionNone
+ };
+
/** Create tar */
enum cmTarCompression
{
TarCompressGZip,
TarCompressBZip2,
TarCompressXZ,
+ TarCompressZstd,
TarCompressNone
};
- static bool ListTar(const char* outFileName, bool verbose);
- static bool CreateTar(const char* outFileName,
+
+ static bool ListTar(const std::string& outFileName,
+ const std::vector<std::string>& files, bool verbose);
+ static bool CreateTar(const std::string& outFileName,
const std::vector<std::string>& files,
cmTarCompression compressType, bool verbose,
std::string const& mtime = std::string(),
std::string const& format = std::string());
- static bool ExtractTar(const char* inFileName, bool verbose);
+ static bool ExtractTar(const std::string& inFileName,
+ const std::vector<std::string>& files, bool verbose);
// This should be called first thing in main
// it will keep child processes from inheriting the
// stdin and stdout of this process. This is important
@@ -421,15 +373,7 @@ public:
// not get stuck waiting for all the output on the pipes.
static void DoNotInheritStdPipes();
- /** Copy the file create/access/modify times from the file named by
- the first argument to that named by the second. */
- static bool CopyFileTime(const char* fromFile, const char* toFile);
-
- /** Save and restore file times. */
- static cmSystemToolsFileTime* FileTimeNew();
- static void FileTimeDelete(cmSystemToolsFileTime*);
- static bool FileTimeGet(const char* fname, cmSystemToolsFileTime* t);
- static bool FileTimeSet(const char* fname, cmSystemToolsFileTime* t);
+ static void EnsureStdPipes();
/** Random seed generation. */
static unsigned int RandomSeed();
@@ -461,28 +405,24 @@ public:
/** Try to set the RPATH in an ELF binary. */
static bool ChangeRPath(std::string const& file, std::string const& oldRPath,
std::string const& newRPath,
- std::string* emsg = CM_NULLPTR,
- bool* changed = CM_NULLPTR);
+ bool removeEnvironmentRPath,
+ std::string* emsg = nullptr,
+ bool* changed = nullptr);
/** Try to remove the RPATH from an ELF binary. */
- static bool RemoveRPath(std::string const& file,
- std::string* emsg = CM_NULLPTR,
- bool* removed = CM_NULLPTR);
+ static bool RemoveRPath(std::string const& file, std::string* emsg = nullptr,
+ bool* removed = nullptr);
/** Check whether the RPATH in an ELF binary contains the path
given. */
static bool CheckRPath(std::string const& file, std::string const& newRPath);
/** Remove a directory; repeat a few times in case of locked files. */
- static bool RepeatedRemoveDirectory(const char* dir);
-
- /** Tokenize a string */
- static std::vector<std::string> tokenize(const std::string& str,
- const std::string& sep);
+ static bool RepeatedRemoveDirectory(const std::string& dir);
- /** Convert string to long. Expected that the whole string is an integer */
- static bool StringToLong(const char* str, long* value);
- static bool StringToULong(const char* str, unsigned long* value);
+ /** Encode a string as a URL. */
+ static std::string EncodeURL(std::string const& in,
+ bool escapeSlashes = true);
#ifdef _WIN32
struct WindowsFileRetry
@@ -492,21 +432,34 @@ public:
};
static WindowsFileRetry GetWindowsFileRetry();
#endif
+
+ /** Get the real path for a given path, removing all symlinks.
+ This variant of GetRealPath also works on Windows but will
+ resolve subst drives too. */
+ static std::string GetRealPathResolvingWindowsSubst(
+ const std::string& path, std::string* errorMessage = nullptr);
+
+ /** Perform one-time initialization of libuv. */
+ static void InitializeLibUV();
+
+ /** Create a symbolic link if the platform supports it. Returns whether
+ creation succeeded. */
+ static bool CreateSymlink(const std::string& origName,
+ const std::string& newName,
+ std::string* errorMessage = nullptr);
+
+ /** Create a hard link if the platform supports it. Returns whether
+ creation succeeded. */
+ static bool CreateLink(const std::string& origName,
+ const std::string& newName,
+ std::string* errorMessage = nullptr);
+
private:
static bool s_ForceUnixPaths;
static bool s_RunCommandHideConsole;
static bool s_ErrorOccured;
static bool s_FatalErrorOccured;
- static bool s_DisableMessages;
static bool s_DisableRunCommandOutput;
- static MessageCallback s_MessageCallback;
- static OutputCallback s_StdoutCallback;
- static OutputCallback s_StderrCallback;
- static InterruptCallback s_InterruptCallback;
- static void* s_MessageCallbackClientData;
- static void* s_StdoutCallbackClientData;
- static void* s_StderrCallbackClientData;
- static void* s_InterruptCallbackClientData;
};
#endif
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index c95a3ca2c..80986fca4 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -2,31 +2,39 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTarget.h"
-#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
-#include <map>
+#include <cassert>
+#include <cstring>
+#include <initializer_list>
+#include <iterator>
#include <set>
#include <sstream>
-#include <string.h>
+#include <unordered_set>
+
+#include <cm/memory>
+
+#include "cmsys/RegularExpression.hxx"
#include "cmAlgorithms.h"
+#include "cmCustomCommand.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmMessenger.h"
-#include "cmOutputConverter.h"
#include "cmProperty.h"
+#include "cmPropertyMap.h"
+#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmSourceFileLocation.h"
+#include "cmSourceFileLocationKind.h"
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
#include "cmSystemTools.h"
#include "cmTargetPropertyComputer.h"
-#include "cm_unordered_set.hxx"
#include "cmake.h"
template <>
@@ -75,34 +83,29 @@ const char* cmTargetPropertyComputer::GetSources<cmTarget>(
{
cmStringRange entries = tgt->GetSourceEntries();
if (entries.empty()) {
- return CM_NULLPTR;
+ return nullptr;
}
std::ostringstream ss;
const char* sep = "";
- for (std::vector<std::string>::const_iterator i = entries.begin();
- i != entries.end(); ++i) {
- std::string const& entry = *i;
-
- std::vector<std::string> files;
- cmSystemTools::ExpandListArgument(entry, files);
- for (std::vector<std::string>::const_iterator li = files.begin();
- li != files.end(); ++li) {
- if (cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
- (*li)[li->size() - 1] == '>') {
- std::string objLibName = li->substr(17, li->size() - 18);
+ for (std::string const& entry : entries) {
+ std::vector<std::string> files = cmExpandedList(entry);
+ for (std::string const& file : files) {
+ if (cmHasLiteralPrefix(file, "$<TARGET_OBJECTS:") &&
+ file.back() == '>') {
+ std::string objLibName = file.substr(17, file.size() - 18);
if (cmGeneratorExpression::Find(objLibName) != std::string::npos) {
ss << sep;
sep = ";";
- ss << *li;
+ ss << file;
continue;
}
bool addContent = false;
bool noMessage = true;
std::ostringstream e;
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ MessageType messageType = MessageType::AUTHOR_WARNING;
switch (context.GetBottom().GetPolicy(cmPolicies::CMP0051)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0051) << "\n";
@@ -116,28 +119,25 @@ const char* cmTargetPropertyComputer::GetSources<cmTarget>(
}
if (!noMessage) {
e << "Target \"" << tgt->GetName()
- << "\" contains "
- "$<TARGET_OBJECTS> generator expression in its sources "
- "list. "
- "This content was not previously part of the SOURCES "
- "property "
- "when that property was read at configure time. Code "
- "reading "
- "that property needs to be adapted to ignore the generator "
- "expression using the string(GENEX_STRIP) command.";
+ << "\" contains $<TARGET_OBJECTS> generator expression in its "
+ "sources list. This content was not previously part of the "
+ "SOURCES property when that property was read at configure "
+ "time. Code reading that property needs to be adapted to "
+ "ignore the generator expression using the string(GENEX_STRIP) "
+ "command.";
messenger->IssueMessage(messageType, e.str(), context);
}
if (addContent) {
ss << sep;
sep = ";";
- ss << *li;
+ ss << file;
}
- } else if (cmGeneratorExpression::Find(*li) == std::string::npos) {
+ } else if (cmGeneratorExpression::Find(file) == std::string::npos) {
ss << sep;
sep = ";";
- ss << *li;
+ ss << file;
} else {
- cmSourceFile* sf = tgt->GetMakefile()->GetOrCreateSource(*li);
+ cmSourceFile* sf = tgt->GetMakefile()->GetOrCreateSource(file);
// Construct what is known about this source file location.
cmSourceFileLocation const& location = sf->GetLocation();
std::string sname = location.GetDirectory();
@@ -161,6 +161,28 @@ const char* cmTargetPropertyComputer::GetSources<cmTarget>(
class cmTargetInternals
{
public:
+ cmStateEnums::TargetType TargetType;
+ cmMakefile* Makefile;
+ cmPolicies::PolicyMap PolicyMap;
+ std::string Name;
+ std::string InstallPath;
+ std::string RuntimeInstallPath;
+ cmPropertyMap Properties;
+ bool IsGeneratorProvided;
+ bool HaveInstallRule;
+ bool IsDLLPlatform;
+ bool IsAIX;
+ bool IsAndroid;
+ bool IsImportedTarget;
+ bool ImportedGloballyVisible;
+ bool BuildInterfaceIncludesAppended;
+ std::set<BT<std::string>> Utilities;
+ std::vector<cmCustomCommand> PreBuildCommands;
+ std::vector<cmCustomCommand> PreLinkCommands;
+ std::vector<cmCustomCommand> PostBuildCommands;
+ std::vector<cmInstallTargetGenerator*> InstallGenerators;
+ std::set<std::string> SystemIncludeDirectories;
+ cmTarget::LinkLibraryVectorType OriginalLinkLibraries;
std::vector<std::string> IncludeDirectoriesEntries;
std::vector<cmListFileBacktrace> IncludeDirectoriesBacktraces;
std::vector<std::string> CompileOptionsEntries;
@@ -169,147 +191,230 @@ public:
std::vector<cmListFileBacktrace> CompileFeaturesBacktraces;
std::vector<std::string> CompileDefinitionsEntries;
std::vector<cmListFileBacktrace> CompileDefinitionsBacktraces;
+ std::vector<std::string> PrecompileHeadersEntries;
+ std::vector<cmListFileBacktrace> PrecompileHeadersBacktraces;
std::vector<std::string> SourceEntries;
std::vector<cmListFileBacktrace> SourceBacktraces;
+ std::vector<std::string> LinkOptionsEntries;
+ std::vector<cmListFileBacktrace> LinkOptionsBacktraces;
+ std::vector<std::string> LinkDirectoriesEntries;
+ std::vector<cmListFileBacktrace> LinkDirectoriesBacktraces;
std::vector<std::string> LinkImplementationPropertyEntries;
std::vector<cmListFileBacktrace> LinkImplementationPropertyBacktraces;
+ std::vector<std::pair<cmTarget::TLLSignature, cmListFileContext>>
+ TLLCommands;
+ cmListFileBacktrace Backtrace;
+
+public:
+ bool CheckImportedLibName(std::string const& prop,
+ std::string const& value) const;
+
+ std::string ProcessSourceItemCMP0049(const std::string& s);
};
cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
Visibility vis, cmMakefile* mf)
+ : impl(cm::make_unique<cmTargetInternals>())
{
assert(mf);
- this->Name = name;
- this->TargetTypeValue = type;
- this->Makefile = mf;
- this->HaveInstallRule = false;
- this->DLLPlatform = false;
- this->IsAndroid = false;
- this->IsImportedTarget =
+ impl->TargetType = type;
+ impl->Makefile = mf;
+ impl->Name = name;
+ impl->IsGeneratorProvided = false;
+ impl->HaveInstallRule = false;
+ impl->IsDLLPlatform = false;
+ impl->IsAIX = false;
+ impl->IsAndroid = false;
+ impl->IsImportedTarget =
(vis == VisibilityImported || vis == VisibilityImportedGlobally);
- this->ImportedGloballyVisible = vis == VisibilityImportedGlobally;
- this->BuildInterfaceIncludesAppended = false;
-
- // only add dependency information for library targets
- if (this->TargetTypeValue >= cmStateEnums::STATIC_LIBRARY &&
- this->TargetTypeValue <= cmStateEnums::MODULE_LIBRARY) {
- this->RecordDependencies = true;
- } else {
- this->RecordDependencies = false;
- }
+ impl->ImportedGloballyVisible = vis == VisibilityImportedGlobally;
+ impl->BuildInterfaceIncludesAppended = false;
// Check whether this is a DLL platform.
- this->DLLPlatform =
- (this->Makefile->IsOn("WIN32") || this->Makefile->IsOn("CYGWIN") ||
- this->Makefile->IsOn("MINGW"));
+ impl->IsDLLPlatform =
+ !impl->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty();
+
+ // Check whether we are targeting AIX.
+ impl->IsAIX =
+ (impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "AIX");
// Check whether we are targeting an Android platform.
- this->IsAndroid =
- strcmp(this->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME"),
- "Android") == 0;
+ impl->IsAndroid =
+ (impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "Android");
+
+ std::string defKey;
+ defKey.reserve(128);
+ defKey += "CMAKE_";
+ auto initProp = [this, mf, &defKey](const std::string& property) {
+ // Replace everything after "CMAKE_"
+ defKey.replace(defKey.begin() + 6, defKey.end(), property);
+ if (const char* value = mf->GetDefinition(defKey)) {
+ this->SetProperty(property, value);
+ }
+ };
+ auto initPropValue = [this, mf, &defKey](const std::string& property,
+ const char* default_value) {
+ // Replace everything after "CMAKE_"
+ defKey.replace(defKey.begin() + 6, defKey.end(), property);
+ if (const char* value = mf->GetDefinition(defKey)) {
+ this->SetProperty(property, value);
+ } else if (default_value) {
+ this->SetProperty(property, default_value);
+ }
+ };
// Setup default property values.
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
this->GetType() != cmStateEnums::UTILITY) {
- this->SetPropertyDefault("ANDROID_API", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_API_MIN", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_ARCH", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_STL_TYPE", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_SKIP_ANT_STEP", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_PROCESS_MAX", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_PROGUARD", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_PROGUARD_CONFIG_PATH", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_SECURE_PROPS_PATH", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_NATIVE_LIB_DIRECTORIES", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_NATIVE_LIB_DEPENDENCIES", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_JAVA_SOURCE_DIR", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_JAR_DIRECTORIES", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_JAR_DEPENDENCIES", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_ASSETS_DIRECTORIES", CM_NULLPTR);
- this->SetPropertyDefault("ANDROID_ANT_ADDITIONAL_OPTIONS", CM_NULLPTR);
- this->SetPropertyDefault("BUILD_RPATH", CM_NULLPTR);
- this->SetPropertyDefault("INSTALL_NAME_DIR", CM_NULLPTR);
- this->SetPropertyDefault("INSTALL_RPATH", "");
- this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF");
- this->SetPropertyDefault("INTERPROCEDURAL_OPTIMIZATION", CM_NULLPTR);
- this->SetPropertyDefault("SKIP_BUILD_RPATH", "OFF");
- this->SetPropertyDefault("BUILD_WITH_INSTALL_RPATH", "OFF");
- this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", CM_NULLPTR);
- this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", CM_NULLPTR);
- this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", CM_NULLPTR);
- this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", CM_NULLPTR);
- this->SetPropertyDefault("COMPILE_PDB_OUTPUT_DIRECTORY", CM_NULLPTR);
- this->SetPropertyDefault("Fortran_FORMAT", CM_NULLPTR);
- this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", CM_NULLPTR);
- this->SetPropertyDefault("GNUtoMS", CM_NULLPTR);
- this->SetPropertyDefault("OSX_ARCHITECTURES", CM_NULLPTR);
- this->SetPropertyDefault("IOS_INSTALL_COMBINED", CM_NULLPTR);
- this->SetPropertyDefault("AUTOMOC", CM_NULLPTR);
- this->SetPropertyDefault("AUTOUIC", CM_NULLPTR);
- this->SetPropertyDefault("AUTORCC", CM_NULLPTR);
- this->SetPropertyDefault("AUTOMOC_DEPEND_FILTERS", CM_NULLPTR);
- this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", CM_NULLPTR);
- this->SetPropertyDefault("AUTOUIC_OPTIONS", CM_NULLPTR);
- this->SetPropertyDefault("AUTOUIC_SEARCH_PATHS", CM_NULLPTR);
- this->SetPropertyDefault("AUTORCC_OPTIONS", CM_NULLPTR);
- this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", CM_NULLPTR);
- this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", CM_NULLPTR);
- this->SetPropertyDefault("WIN32_EXECUTABLE", CM_NULLPTR);
- this->SetPropertyDefault("MACOSX_BUNDLE", CM_NULLPTR);
- this->SetPropertyDefault("MACOSX_RPATH", CM_NULLPTR);
- this->SetPropertyDefault("BUILD_WITH_INSTALL_NAME_DIR", CM_NULLPTR);
- this->SetPropertyDefault("C_CLANG_TIDY", CM_NULLPTR);
- this->SetPropertyDefault("C_COMPILER_LAUNCHER", CM_NULLPTR);
- this->SetPropertyDefault("C_CPPLINT", CM_NULLPTR);
- this->SetPropertyDefault("C_INCLUDE_WHAT_YOU_USE", CM_NULLPTR);
- this->SetPropertyDefault("LINK_WHAT_YOU_USE", CM_NULLPTR);
- this->SetPropertyDefault("C_STANDARD", CM_NULLPTR);
- this->SetPropertyDefault("C_STANDARD_REQUIRED", CM_NULLPTR);
- this->SetPropertyDefault("C_EXTENSIONS", CM_NULLPTR);
- this->SetPropertyDefault("CXX_CLANG_TIDY", CM_NULLPTR);
- this->SetPropertyDefault("CXX_COMPILER_LAUNCHER", CM_NULLPTR);
- this->SetPropertyDefault("CXX_CPPLINT", CM_NULLPTR);
- this->SetPropertyDefault("CXX_INCLUDE_WHAT_YOU_USE", CM_NULLPTR);
- this->SetPropertyDefault("CXX_STANDARD", CM_NULLPTR);
- this->SetPropertyDefault("CXX_STANDARD_REQUIRED", CM_NULLPTR);
- this->SetPropertyDefault("CXX_EXTENSIONS", CM_NULLPTR);
- this->SetPropertyDefault("CUDA_STANDARD", CM_NULLPTR);
- this->SetPropertyDefault("CUDA_STANDARD_REQUIRED", CM_NULLPTR);
- this->SetPropertyDefault("CUDA_EXTENSIONS", CM_NULLPTR);
- this->SetPropertyDefault("LINK_SEARCH_START_STATIC", CM_NULLPTR);
- this->SetPropertyDefault("LINK_SEARCH_END_STATIC", CM_NULLPTR);
+ initProp("ANDROID_API");
+ initProp("ANDROID_API_MIN");
+ initProp("ANDROID_ARCH");
+ initProp("ANDROID_STL_TYPE");
+ initProp("ANDROID_SKIP_ANT_STEP");
+ initProp("ANDROID_PROCESS_MAX");
+ initProp("ANDROID_PROGUARD");
+ initProp("ANDROID_PROGUARD_CONFIG_PATH");
+ initProp("ANDROID_SECURE_PROPS_PATH");
+ initProp("ANDROID_NATIVE_LIB_DIRECTORIES");
+ initProp("ANDROID_NATIVE_LIB_DEPENDENCIES");
+ initProp("ANDROID_JAVA_SOURCE_DIR");
+ initProp("ANDROID_JAR_DIRECTORIES");
+ initProp("ANDROID_JAR_DEPENDENCIES");
+ initProp("ANDROID_ASSETS_DIRECTORIES");
+ initProp("ANDROID_ANT_ADDITIONAL_OPTIONS");
+ initProp("BUILD_RPATH");
+ initProp("BUILD_RPATH_USE_ORIGIN");
+ initProp("INSTALL_NAME_DIR");
+ initProp("INSTALL_REMOVE_ENVIRONMENT_RPATH");
+ initPropValue("INSTALL_RPATH", "");
+ initPropValue("INSTALL_RPATH_USE_LINK_PATH", "OFF");
+ initProp("INTERPROCEDURAL_OPTIMIZATION");
+ initPropValue("SKIP_BUILD_RPATH", "OFF");
+ initPropValue("BUILD_WITH_INSTALL_RPATH", "OFF");
+ initProp("ARCHIVE_OUTPUT_DIRECTORY");
+ initProp("LIBRARY_OUTPUT_DIRECTORY");
+ initProp("RUNTIME_OUTPUT_DIRECTORY");
+ initProp("PDB_OUTPUT_DIRECTORY");
+ initProp("COMPILE_PDB_OUTPUT_DIRECTORY");
+ initProp("FRAMEWORK");
+ initProp("Fortran_FORMAT");
+ initProp("Fortran_MODULE_DIRECTORY");
+ initProp("Fortran_COMPILER_LAUNCHER");
+ initProp("GNUtoMS");
+ initProp("OSX_ARCHITECTURES");
+ initProp("IOS_INSTALL_COMBINED");
+ initProp("AUTOMOC");
+ initProp("AUTOUIC");
+ initProp("AUTORCC");
+ initProp("AUTOGEN_ORIGIN_DEPENDS");
+ initProp("AUTOGEN_PARALLEL");
+ initProp("AUTOMOC_COMPILER_PREDEFINES");
+ initProp("AUTOMOC_DEPEND_FILTERS");
+ initProp("AUTOMOC_MACRO_NAMES");
+ initProp("AUTOMOC_MOC_OPTIONS");
+ initProp("AUTOUIC_OPTIONS");
+ initProp("AUTOMOC_PATH_PREFIX");
+ initProp("AUTOUIC_SEARCH_PATHS");
+ initProp("AUTORCC_OPTIONS");
+ initProp("LINK_DEPENDS_NO_SHARED");
+ initProp("LINK_INTERFACE_LIBRARIES");
+ initProp("MSVC_RUNTIME_LIBRARY");
+ initProp("WIN32_EXECUTABLE");
+ initProp("MACOSX_BUNDLE");
+ initProp("MACOSX_RPATH");
+ initProp("NO_SYSTEM_FROM_IMPORTED");
+ initProp("BUILD_WITH_INSTALL_NAME_DIR");
+ initProp("C_CLANG_TIDY");
+ initProp("C_COMPILER_LAUNCHER");
+ initProp("C_CPPLINT");
+ initProp("C_CPPCHECK");
+ initProp("C_INCLUDE_WHAT_YOU_USE");
+ initProp("LINK_WHAT_YOU_USE");
+ initProp("C_STANDARD");
+ initProp("C_STANDARD_REQUIRED");
+ initProp("C_EXTENSIONS");
+ initProp("OBJC_COMPILER_LAUNCHER");
+ initProp("OBJC_STANDARD");
+ initProp("OBJC_STANDARD_REQUIRED");
+ initProp("OBJC_EXTENSIONS");
+ initProp("CXX_CLANG_TIDY");
+ initProp("CXX_COMPILER_LAUNCHER");
+ initProp("CXX_CPPLINT");
+ initProp("CXX_CPPCHECK");
+ initProp("CXX_INCLUDE_WHAT_YOU_USE");
+ initProp("CXX_STANDARD");
+ initProp("CXX_STANDARD_REQUIRED");
+ initProp("CXX_EXTENSIONS");
+ initProp("OBJCXX_COMPILER_LAUNCHER");
+ initProp("OBJCXX_STANDARD");
+ initProp("OBJCXX_STANDARD_REQUIRED");
+ initProp("OBJCXX_EXTENSIONS");
+ initProp("CUDA_STANDARD");
+ initProp("CUDA_STANDARD_REQUIRED");
+ initProp("CUDA_EXTENSIONS");
+ initProp("CUDA_COMPILER_LAUNCHER");
+ initProp("CUDA_SEPARABLE_COMPILATION");
+ initProp("CUDA_RESOLVE_DEVICE_SYMBOLS");
+ initProp("LINK_SEARCH_START_STATIC");
+ initProp("LINK_SEARCH_END_STATIC");
+ initProp("FOLDER");
+ initProp("Swift_LANGUAGE_VERSION");
+ initProp("Swift_MODULE_DIRECTORY");
+ initProp("VS_JUST_MY_CODE_DEBUGGING");
+ initProp("DISABLE_PRECOMPILE_HEADERS");
+ initProp("UNITY_BUILD");
+ initPropValue("UNITY_BUILD_BATCH_SIZE", "8");
+#ifdef __APPLE__
+ if (this->GetGlobalGenerator()->IsXcode()) {
+ initProp("XCODE_SCHEME_ADDRESS_SANITIZER");
+ initProp("XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN");
+ initProp("XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING");
+ initProp("XCODE_SCHEME_THREAD_SANITIZER");
+ initProp("XCODE_SCHEME_THREAD_SANITIZER_STOP");
+ initProp("XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER");
+ initProp("XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP");
+ initProp("XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER");
+ initProp("XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP");
+ initProp("XCODE_SCHEME_MALLOC_SCRIBBLE");
+ initProp("XCODE_SCHEME_MALLOC_GUARD_EDGES");
+ initProp("XCODE_SCHEME_GUARD_MALLOC");
+ initProp("XCODE_SCHEME_ZOMBIE_OBJECTS");
+ initProp("XCODE_SCHEME_MALLOC_STACK");
+ initProp("XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE");
+ initProp("XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS");
+ }
+#endif
}
- if (this->GetType() != cmStateEnums::UTILITY) {
- this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", CM_NULLPTR);
+ if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ if (this->GetGlobalGenerator()->IsXcode()) {
+ initProp("XCODE_GENERATE_SCHEME");
+ }
}
- // Collect the set of configuration types.
- std::vector<std::string> configNames;
- mf->GetConfigurations(configNames);
-
// Setup per-configuration property default values.
if (this->GetType() != cmStateEnums::UTILITY) {
- const char* configProps[] = {
+ static const auto configProps = {
/* clang-format needs this comment to break after the opening brace */
"ARCHIVE_OUTPUT_DIRECTORY_", "LIBRARY_OUTPUT_DIRECTORY_",
"RUNTIME_OUTPUT_DIRECTORY_", "PDB_OUTPUT_DIRECTORY_",
"COMPILE_PDB_OUTPUT_DIRECTORY_", "MAP_IMPORTED_CONFIG_",
- "INTERPROCEDURAL_OPTIMIZATION_", CM_NULLPTR
+ "INTERPROCEDURAL_OPTIMIZATION_"
};
- for (std::vector<std::string>::iterator ci = configNames.begin();
- ci != configNames.end(); ++ci) {
- std::string configUpper = cmSystemTools::UpperCase(*ci);
- for (const char** p = configProps; *p; ++p) {
+ // Collect the set of configuration types.
+ std::vector<std::string> configNames;
+ mf->GetConfigurations(configNames);
+ for (std::string const& configName : configNames) {
+ std::string configUpper = cmSystemTools::UpperCase(configName);
+ for (auto const& prop : configProps) {
// Interface libraries have no output locations, so honor only
// the configuration map.
- if (this->TargetTypeValue == cmStateEnums::INTERFACE_LIBRARY &&
- strcmp(*p, "MAP_IMPORTED_CONFIG_") != 0) {
+ if (impl->TargetType == cmStateEnums::INTERFACE_LIBRARY &&
+ strcmp(prop, "MAP_IMPORTED_CONFIG_") != 0) {
continue;
}
- std::string property = *p;
- property += configUpper;
- this->SetPropertyDefault(property, CM_NULLPTR);
+ std::string property = cmStrCat(prop, configUpper);
+ initProp(property);
}
// Initialize per-configuration name postfix property from the
@@ -317,125 +422,172 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
// compatibility with previous CMake versions in which executables
// did not support this variable. Projects may still specify the
// property directly.
- if (this->TargetTypeValue != cmStateEnums::EXECUTABLE &&
- this->TargetTypeValue != cmStateEnums::INTERFACE_LIBRARY) {
- std::string property = cmSystemTools::UpperCase(*ci);
- property += "_POSTFIX";
- this->SetPropertyDefault(property, CM_NULLPTR);
+ if (impl->TargetType != cmStateEnums::EXECUTABLE &&
+ impl->TargetType != cmStateEnums::INTERFACE_LIBRARY) {
+ std::string property =
+ cmStrCat(cmSystemTools::UpperCase(configName), "_POSTFIX");
+ initProp(property);
}
}
}
// Save the backtrace of target construction.
- this->Backtrace = this->Makefile->GetBacktrace();
+ impl->Backtrace = impl->Makefile->GetBacktrace();
if (!this->IsImported()) {
// Initialize the INCLUDE_DIRECTORIES property based on the current value
// of the same directory property:
- const cmStringRange parentIncludes =
- this->Makefile->GetIncludeDirectoriesEntries();
- const cmBacktraceRange parentIncludesBts =
- this->Makefile->GetIncludeDirectoriesBacktraces();
-
- this->Internal->IncludeDirectoriesEntries.insert(
- this->Internal->IncludeDirectoriesEntries.end(), parentIncludes.begin(),
- parentIncludes.end());
- this->Internal->IncludeDirectoriesBacktraces.insert(
- this->Internal->IncludeDirectoriesBacktraces.end(),
- parentIncludesBts.begin(), parentIncludesBts.end());
-
- const std::set<std::string> parentSystemIncludes =
- this->Makefile->GetSystemIncludeDirectories();
+ cmAppend(impl->IncludeDirectoriesEntries,
+ impl->Makefile->GetIncludeDirectoriesEntries());
+ cmAppend(impl->IncludeDirectoriesBacktraces,
+ impl->Makefile->GetIncludeDirectoriesBacktraces());
+
+ {
+ auto const& sysInc = impl->Makefile->GetSystemIncludeDirectories();
+ impl->SystemIncludeDirectories.insert(sysInc.begin(), sysInc.end());
+ }
- this->SystemIncludeDirectories.insert(parentSystemIncludes.begin(),
- parentSystemIncludes.end());
+ cmAppend(impl->CompileOptionsEntries,
+ impl->Makefile->GetCompileOptionsEntries());
+ cmAppend(impl->CompileOptionsBacktraces,
+ impl->Makefile->GetCompileOptionsBacktraces());
- const cmStringRange parentOptions =
- this->Makefile->GetCompileOptionsEntries();
- const cmBacktraceRange parentOptionsBts =
- this->Makefile->GetCompileOptionsBacktraces();
+ cmAppend(impl->LinkOptionsEntries,
+ impl->Makefile->GetLinkOptionsEntries());
+ cmAppend(impl->LinkOptionsBacktraces,
+ impl->Makefile->GetLinkOptionsBacktraces());
- this->Internal->CompileOptionsEntries.insert(
- this->Internal->CompileOptionsEntries.end(), parentOptions.begin(),
- parentOptions.end());
- this->Internal->CompileOptionsBacktraces.insert(
- this->Internal->CompileOptionsBacktraces.end(), parentOptionsBts.begin(),
- parentOptionsBts.end());
+ cmAppend(impl->LinkDirectoriesEntries,
+ impl->Makefile->GetLinkDirectoriesEntries());
+ cmAppend(impl->LinkDirectoriesBacktraces,
+ impl->Makefile->GetLinkDirectoriesBacktraces());
}
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
this->GetType() != cmStateEnums::UTILITY) {
- this->SetPropertyDefault("C_VISIBILITY_PRESET", CM_NULLPTR);
- this->SetPropertyDefault("CXX_VISIBILITY_PRESET", CM_NULLPTR);
- this->SetPropertyDefault("CUDA_VISIBILITY_PRESET", CM_NULLPTR);
- this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", CM_NULLPTR);
+ initProp("C_VISIBILITY_PRESET");
+ initProp("CXX_VISIBILITY_PRESET");
+ initProp("OBJC_VISIBILITY_PRESET");
+ initProp("OBJCXX_VISIBILITY_PRESET");
+ initProp("CUDA_VISIBILITY_PRESET");
+ initProp("VISIBILITY_INLINES_HIDDEN");
}
- if (this->TargetTypeValue == cmStateEnums::EXECUTABLE) {
- this->SetPropertyDefault("ANDROID_GUI", CM_NULLPTR);
- this->SetPropertyDefault("CROSSCOMPILING_EMULATOR", CM_NULLPTR);
- this->SetPropertyDefault("ENABLE_EXPORTS", CM_NULLPTR);
+ if (impl->TargetType == cmStateEnums::EXECUTABLE) {
+ initProp("ANDROID_GUI");
+ initProp("CROSSCOMPILING_EMULATOR");
+ initProp("ENABLE_EXPORTS");
}
- if (this->TargetTypeValue == cmStateEnums::SHARED_LIBRARY ||
- this->TargetTypeValue == cmStateEnums::MODULE_LIBRARY) {
+ if (impl->TargetType == cmStateEnums::SHARED_LIBRARY ||
+ impl->TargetType == cmStateEnums::MODULE_LIBRARY) {
this->SetProperty("POSITION_INDEPENDENT_CODE", "True");
}
- if (this->TargetTypeValue == cmStateEnums::SHARED_LIBRARY ||
- this->TargetTypeValue == cmStateEnums::EXECUTABLE) {
- this->SetPropertyDefault("WINDOWS_EXPORT_ALL_SYMBOLS", CM_NULLPTR);
+ if (impl->TargetType == cmStateEnums::SHARED_LIBRARY ||
+ impl->TargetType == cmStateEnums::EXECUTABLE) {
+ initProp("WINDOWS_EXPORT_ALL_SYMBOLS");
}
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
this->GetType() != cmStateEnums::UTILITY) {
- this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", CM_NULLPTR);
+ initProp("POSITION_INDEPENDENT_CODE");
}
// Record current policies for later use.
- this->Makefile->RecordPolicies(this->PolicyMap);
+ impl->Makefile->RecordPolicies(impl->PolicyMap);
- if (this->TargetTypeValue == cmStateEnums::INTERFACE_LIBRARY) {
+ if (impl->TargetType == cmStateEnums::INTERFACE_LIBRARY) {
// This policy is checked in a few conditions. The properties relevant
// to the policy are always ignored for cmStateEnums::INTERFACE_LIBRARY
// targets,
// so ensure that the conditions don't lead to nonsense.
- this->PolicyMap.Set(cmPolicies::CMP0022, cmPolicies::NEW);
+ impl->PolicyMap.Set(cmPolicies::CMP0022, cmPolicies::NEW);
}
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
this->GetType() != cmStateEnums::UTILITY) {
- this->SetPropertyDefault("JOB_POOL_COMPILE", CM_NULLPTR);
- this->SetPropertyDefault("JOB_POOL_LINK", CM_NULLPTR);
+ initProp("JOB_POOL_COMPILE");
+ initProp("JOB_POOL_LINK");
+ }
+
+ if (impl->TargetType <= cmStateEnums::UTILITY) {
+ initProp("DOTNET_TARGET_FRAMEWORK_VERSION");
+ }
+
+ if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
+ this->GetType() != cmStateEnums::UTILITY) {
+
+ // check for "CMAKE_VS_GLOBALS" variable and set up target properties
+ // if any
+ const char* globals = mf->GetDefinition("CMAKE_VS_GLOBALS");
+ if (globals) {
+ const std::string genName = mf->GetGlobalGenerator()->GetName();
+ if (cmHasLiteralPrefix(genName, "Visual Studio")) {
+ std::vector<std::string> props = cmExpandedList(globals);
+ const std::string vsGlobal = "VS_GLOBAL_";
+ for (const std::string& i : props) {
+ // split NAME=VALUE
+ const std::string::size_type assignment = i.find('=');
+ if (assignment != std::string::npos) {
+ const std::string propName = vsGlobal + i.substr(0, assignment);
+ const std::string propValue = i.substr(assignment + 1);
+ initPropValue(propName, propValue.c_str());
+ }
+ }
+ }
+ }
}
}
-cmGlobalGenerator* cmTarget::GetGlobalGenerator() const
+cmTarget::cmTarget(cmTarget&&) noexcept = default;
+cmTarget::~cmTarget() = default;
+
+cmTarget& cmTarget::operator=(cmTarget&&) noexcept = default;
+
+cmStateEnums::TargetType cmTarget::GetType() const
{
- return this->GetMakefile()->GetGlobalGenerator();
+ return impl->TargetType;
}
-void cmTarget::AddUtility(const std::string& u, cmMakefile* makefile)
+cmMakefile* cmTarget::GetMakefile() const
{
- if (this->Utilities.insert(u).second && makefile) {
- this->UtilityBacktraces.insert(
- std::make_pair(u, makefile->GetBacktrace()));
- }
+ return impl->Makefile;
}
-cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(
- const std::string& u) const
+cmPolicies::PolicyMap const& cmTarget::GetPolicyMap() const
{
- std::map<std::string, cmListFileBacktrace>::const_iterator i =
- this->UtilityBacktraces.find(u);
- if (i == this->UtilityBacktraces.end()) {
- return CM_NULLPTR;
- }
+ return impl->PolicyMap;
+}
+
+const std::string& cmTarget::GetName() const
+{
+ return impl->Name;
+}
+
+cmPolicies::PolicyStatus cmTarget::GetPolicyStatus(
+ cmPolicies::PolicyID policy) const
+{
+ return impl->PolicyMap.Get(policy);
+}
+
+cmGlobalGenerator* cmTarget::GetGlobalGenerator() const
+{
+ return impl->Makefile->GetGlobalGenerator();
+}
- return &i->second;
+void cmTarget::AddUtility(std::string const& name, cmMakefile* mf)
+{
+ impl->Utilities.insert(
+ BT<std::string>(name, mf ? mf->GetBacktrace() : cmListFileBacktrace()));
+}
+
+std::set<BT<std::string>> const& cmTarget::GetUtilities() const
+{
+ return impl->Utilities;
}
cmListFileBacktrace const& cmTarget::GetBacktrace() const
{
- return this->Backtrace;
+ return impl->Backtrace;
}
bool cmTarget::IsExecutableWithExports() const
@@ -444,34 +596,72 @@ bool cmTarget::IsExecutableWithExports() const
this->GetPropertyAsBool("ENABLE_EXPORTS"));
}
-bool cmTarget::HasImportLibrary() const
-{
- return (this->DLLPlatform &&
- (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
- this->IsExecutableWithExports()));
-}
-
bool cmTarget::IsFrameworkOnApple() const
{
return ((this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->GetType() == cmStateEnums::STATIC_LIBRARY) &&
- this->Makefile->IsOn("APPLE") &&
+ impl->Makefile->IsOn("APPLE") &&
this->GetPropertyAsBool("FRAMEWORK"));
}
bool cmTarget::IsAppBundleOnApple() const
{
return (this->GetType() == cmStateEnums::EXECUTABLE &&
- this->Makefile->IsOn("APPLE") &&
+ impl->Makefile->IsOn("APPLE") &&
this->GetPropertyAsBool("MACOSX_BUNDLE"));
}
+std::vector<cmCustomCommand> const& cmTarget::GetPreBuildCommands() const
+{
+ return impl->PreBuildCommands;
+}
+
+void cmTarget::AddPreBuildCommand(cmCustomCommand const& cmd)
+{
+ impl->PreBuildCommands.push_back(cmd);
+}
+
+void cmTarget::AddPreBuildCommand(cmCustomCommand&& cmd)
+{
+ impl->PreBuildCommands.push_back(std::move(cmd));
+}
+
+std::vector<cmCustomCommand> const& cmTarget::GetPreLinkCommands() const
+{
+ return impl->PreLinkCommands;
+}
+
+void cmTarget::AddPreLinkCommand(cmCustomCommand const& cmd)
+{
+ impl->PreLinkCommands.push_back(cmd);
+}
+
+void cmTarget::AddPreLinkCommand(cmCustomCommand&& cmd)
+{
+ impl->PreLinkCommands.push_back(std::move(cmd));
+}
+
+std::vector<cmCustomCommand> const& cmTarget::GetPostBuildCommands() const
+{
+ return impl->PostBuildCommands;
+}
+
+void cmTarget::AddPostBuildCommand(cmCustomCommand const& cmd)
+{
+ impl->PostBuildCommands.push_back(cmd);
+}
+
+void cmTarget::AddPostBuildCommand(cmCustomCommand&& cmd)
+{
+ impl->PostBuildCommands.push_back(std::move(cmd));
+}
+
void cmTarget::AddTracedSources(std::vector<std::string> const& srcs)
{
if (!srcs.empty()) {
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->SourceEntries.push_back(cmJoin(srcs, ";"));
- this->Internal->SourceBacktraces.push_back(lfbt);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->SourceEntries.push_back(cmJoin(srcs, ";"));
+ impl->SourceBacktraces.push_back(lfbt);
}
}
@@ -479,42 +669,38 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs)
{
std::string srcFiles;
const char* sep = "";
- for (std::vector<std::string>::const_iterator i = srcs.begin();
- i != srcs.end(); ++i) {
- std::string filename = *i;
- const char* src = filename.c_str();
-
- if (!(src[0] == '$' && src[1] == '<')) {
+ for (auto filename : srcs) {
+ if (!cmGeneratorExpression::StartsWithGeneratorExpression(filename)) {
if (!filename.empty()) {
- filename = this->ProcessSourceItemCMP0049(filename);
+ filename = impl->ProcessSourceItemCMP0049(filename);
if (filename.empty()) {
return;
}
}
- this->Makefile->GetOrCreateSource(filename);
+ impl->Makefile->GetOrCreateSource(filename);
}
srcFiles += sep;
srcFiles += filename;
sep = ";";
}
if (!srcFiles.empty()) {
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->SourceEntries.push_back(srcFiles);
- this->Internal->SourceBacktraces.push_back(lfbt);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->SourceEntries.push_back(std::move(srcFiles));
+ impl->SourceBacktraces.push_back(lfbt);
}
}
-std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s)
+std::string cmTargetInternals::ProcessSourceItemCMP0049(const std::string& s)
{
std::string src = s;
- // For backwards compatibility replace varibles in source names.
+ // For backwards compatibility replace variables in source names.
// This should eventually be removed.
this->Makefile->ExpandVariablesInString(src);
if (src != s) {
std::ostringstream e;
bool noMessage = false;
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ MessageType messageType = MessageType::AUTHOR_WARNING;
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0049)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0049) << "\n";
@@ -525,15 +711,15 @@ std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s)
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::NEW:
- messageType = cmake::FATAL_ERROR;
+ messageType = MessageType::FATAL_ERROR;
}
if (!noMessage) {
e << "Legacy variable expansion in source file \"" << s
- << "\" expanded to \"" << src << "\" in target \"" << this->GetName()
+ << "\" expanded to \"" << src << "\" in target \"" << this->Name
<< "\". This behavior will be removed in a "
"future version of CMake.";
this->Makefile->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR) {
+ if (messageType == MessageType::FATAL_ERROR) {
return "";
}
}
@@ -541,13 +727,9 @@ std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s)
return src;
}
-cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s)
+std::string cmTarget::GetSourceCMP0049(const std::string& s)
{
- std::string src = this->ProcessSourceItemCMP0049(s);
- if (!s.empty() && src.empty()) {
- return CM_NULLPTR;
- }
- return this->AddSource(src);
+ return impl->ProcessSourceItemCMP0049(s);
}
struct CreateLocation
@@ -593,10 +775,10 @@ public:
bool operator()(std::string const& entry)
{
- std::vector<std::string> files;
- cmSystemTools::ExpandListArgument(entry, files);
- std::vector<cmSourceFileLocation> locations(files.size());
- std::transform(files.begin(), files.end(), locations.begin(),
+ std::vector<std::string> files = cmExpandedList(entry);
+ std::vector<cmSourceFileLocation> locations;
+ locations.reserve(files.size());
+ std::transform(files.begin(), files.end(), std::back_inserter(locations),
CreateLocation(this->Needle.GetMakefile()));
return std::find_if(locations.begin(), locations.end(),
@@ -604,57 +786,31 @@ public:
}
};
-cmSourceFile* cmTarget::AddSource(const std::string& src)
+cmSourceFile* cmTarget::AddSource(const std::string& src, bool before)
{
- cmSourceFileLocation sfl(this->Makefile, src);
- if (std::find_if(this->Internal->SourceEntries.begin(),
- this->Internal->SourceEntries.end(),
+ cmSourceFileLocation sfl(impl->Makefile, src,
+ cmSourceFileLocationKind::Known);
+ if (std::find_if(impl->SourceEntries.begin(), impl->SourceEntries.end(),
TargetPropertyEntryFinder(sfl)) ==
- this->Internal->SourceEntries.end()) {
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->SourceEntries.push_back(src);
- this->Internal->SourceBacktraces.push_back(lfbt);
+ impl->SourceEntries.end()) {
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->SourceEntries.insert(
+ before ? impl->SourceEntries.begin() : impl->SourceEntries.end(), src);
+ impl->SourceBacktraces.insert(before ? impl->SourceBacktraces.begin()
+ : impl->SourceBacktraces.end(),
+ lfbt);
}
if (cmGeneratorExpression::Find(src) != std::string::npos) {
- return CM_NULLPTR;
+ return nullptr;
}
- return this->Makefile->GetOrCreateSource(src);
-}
-
-void cmTarget::AddLinkDirectory(const std::string& d)
-{
- // Make sure we don't add unnecessary search directories.
- if (this->LinkDirectoriesEmmitted.insert(d).second) {
- this->LinkDirectories.push_back(d);
- }
-}
-
-const std::vector<std::string>& cmTarget::GetLinkDirectories() const
-{
- return this->LinkDirectories;
+ return impl->Makefile->GetOrCreateSource(src, false,
+ cmSourceFileLocationKind::Known);
}
-void cmTarget::ClearDependencyInformation(cmMakefile& mf,
- const std::string& target)
+void cmTarget::ClearDependencyInformation(cmMakefile& mf)
{
- // Clear the dependencies. The cache variable must exist iff we are
- // recording dependency information for this target.
- std::string depname = target;
- depname += "_LIB_DEPENDS";
- if (this->RecordDependencies) {
- mf.AddCacheDefinition(depname, "", "Dependencies for target",
- cmStateEnums::STATIC);
- } else {
- if (mf.GetDefinition(depname)) {
- std::string message = "Target ";
- message += target;
- message += " has dependency information when it shouldn't.\n";
- message += "Your cache is probably stale. Please remove the entry\n ";
- message += depname;
- message += "\nfrom the cache.";
- cmSystemTools::Error(message.c_str());
- }
- }
+ std::string depname = cmStrCat(this->GetName(), "_LIB_DEPENDS");
+ mf.RemoveCacheDefinition(depname);
}
std::string cmTarget::GetDebugGeneratorExpressions(
@@ -666,15 +822,13 @@ std::string cmTarget::GetDebugGeneratorExpressions(
// Get the list of configurations considered to be DEBUG.
std::vector<std::string> debugConfigs =
- this->Makefile->GetCMakeInstance()->GetDebugConfigs();
+ impl->Makefile->GetCMakeInstance()->GetDebugConfigs();
std::string configString = "$<CONFIG:" + debugConfigs[0] + ">";
if (debugConfigs.size() > 1) {
- for (std::vector<std::string>::const_iterator li =
- debugConfigs.begin() + 1;
- li != debugConfigs.end(); ++li) {
- configString += ",$<CONFIG:" + *li + ">";
+ for (std::string const& conf : cmMakeRange(debugConfigs).advance(1)) {
+ configString += ",$<CONFIG:" + conf + ">";
}
configString = "$<OR:" + configString + ">";
}
@@ -694,13 +848,13 @@ bool cmTarget::PushTLLCommandTrace(TLLSignature signature,
cmListFileContext const& lfc)
{
bool ret = true;
- if (!this->TLLCommands.empty()) {
- if (this->TLLCommands.back().first != signature) {
+ if (!impl->TLLCommands.empty()) {
+ if (impl->TLLCommands.back().first != signature) {
ret = false;
}
}
- if (this->TLLCommands.empty() || this->TLLCommands.back().second != lfc) {
- this->TLLCommands.push_back(std::make_pair(signature, lfc));
+ if (impl->TLLCommands.empty() || impl->TLLCommands.back().second != lfc) {
+ impl->TLLCommands.emplace_back(signature, lfc);
}
return ret;
}
@@ -710,47 +864,108 @@ void cmTarget::GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const
const char* sigString =
(sig == cmTarget::KeywordTLLSignature ? "keyword" : "plain");
s << "The uses of the " << sigString << " signature are here:\n";
- typedef std::vector<std::pair<TLLSignature, cmListFileContext> > Container;
- cmOutputConverter converter(this->GetMakefile()->GetStateSnapshot());
- for (Container::const_iterator it = this->TLLCommands.begin();
- it != this->TLLCommands.end(); ++it) {
- if (it->first == sig) {
- cmListFileContext lfc = it->second;
- lfc.FilePath = converter.ConvertToRelativePath(
- this->Makefile->GetState()->GetSourceDirectory(), lfc.FilePath);
+ cmStateDirectory cmDir = impl->Makefile->GetStateSnapshot().GetDirectory();
+ for (auto const& cmd : impl->TLLCommands) {
+ if (cmd.first == sig) {
+ cmListFileContext lfc = cmd.second;
+ lfc.FilePath = cmDir.ConvertToRelPathIfNotContained(
+ impl->Makefile->GetState()->GetSourceDirectory(), lfc.FilePath);
s << " * " << lfc << std::endl;
}
}
}
+std::string const& cmTarget::GetInstallPath() const
+{
+ return impl->InstallPath;
+}
+
+void cmTarget::SetInstallPath(std::string const& name)
+{
+ impl->InstallPath = name;
+}
+
+std::string const& cmTarget::GetRuntimeInstallPath() const
+{
+ return impl->RuntimeInstallPath;
+}
+
+void cmTarget::SetRuntimeInstallPath(std::string const& name)
+{
+ impl->RuntimeInstallPath = name;
+}
+
+bool cmTarget::GetHaveInstallRule() const
+{
+ return impl->HaveInstallRule;
+}
+
+void cmTarget::SetHaveInstallRule(bool hir)
+{
+ impl->HaveInstallRule = hir;
+}
+
+void cmTarget::AddInstallGenerator(cmInstallTargetGenerator* g)
+{
+ impl->InstallGenerators.emplace_back(g);
+}
+
+std::vector<cmInstallTargetGenerator*> const& cmTarget::GetInstallGenerators()
+ const
+{
+ return impl->InstallGenerators;
+}
+
+bool cmTarget::GetIsGeneratorProvided() const
+{
+ return impl->IsGeneratorProvided;
+}
+
+void cmTarget::SetIsGeneratorProvided(bool igp)
+{
+ impl->IsGeneratorProvided = igp;
+}
+
+cmTarget::LinkLibraryVectorType const& cmTarget::GetOriginalLinkLibraries()
+ const
+{
+ return impl->OriginalLinkLibraries;
+}
+
void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& lib,
cmTargetLinkLibraryType llt)
{
- cmTarget* tgt = this->Makefile->FindTargetToUse(lib);
+ this->AddLinkLibrary(mf, lib, lib, llt);
+}
+
+void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib,
+ std::string const& libRef,
+ cmTargetLinkLibraryType llt)
+{
+ cmTarget* tgt = mf.FindTargetToUse(lib);
{
const bool isNonImportedTarget = tgt && !tgt->IsImported();
const std::string libName =
(isNonImportedTarget && llt != GENERAL_LibraryType)
- ? targetNameGenex(lib)
- : lib;
+ ? targetNameGenex(libRef)
+ : libRef;
this->AppendProperty(
"LINK_LIBRARIES",
this->GetDebugGeneratorExpressions(libName, llt).c_str());
}
- if (cmGeneratorExpression::Find(lib) != std::string::npos ||
- (tgt && tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) ||
- (this->Name == lib)) {
+ if (cmGeneratorExpression::Find(lib) != std::string::npos || lib != libRef ||
+ (tgt &&
+ (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
+ tgt->GetType() == cmStateEnums::OBJECT_LIBRARY)) ||
+ (impl->Name == lib)) {
return;
}
- cmTarget::LibraryID tmp;
- tmp.first = lib;
- tmp.second = llt;
- this->OriginalLinkLibraries.push_back(tmp);
+ impl->OriginalLinkLibraries.emplace_back(lib, llt);
- // Add the explicit dependency information for this target. This is
+ // Add the explicit dependency information for libraries. This is
// simply a set of libraries separated by ";". There should always
// be a trailing ";". These library names are not canonical, in that
// they may be "-framework x", "-ly", "/path/libz.a", etc.
@@ -758,9 +973,11 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& lib,
// may be purposefully duplicated to handle recursive dependencies,
// and we removing one instance will break the link line. Duplicates
// will be appropriately eliminated at emit time.
- if (this->RecordDependencies) {
- std::string targetEntry = this->Name;
- targetEntry += "_LIB_DEPENDS";
+ if (impl->TargetType >= cmStateEnums::STATIC_LIBRARY &&
+ impl->TargetType <= cmStateEnums::MODULE_LIBRARY &&
+ (this->GetPolicyStatusCMP0073() == cmPolicies::OLD ||
+ this->GetPolicyStatusCMP0073() == cmPolicies::WARN)) {
+ std::string targetEntry = cmStrCat(impl->Name, "_LIB_DEPENDS");
std::string dependencies;
const char* old_val = mf.GetDefinition(targetEntry);
if (old_val) {
@@ -787,170 +1004,297 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& lib,
void cmTarget::AddSystemIncludeDirectories(const std::set<std::string>& incs)
{
- this->SystemIncludeDirectories.insert(incs.begin(), incs.end());
+ impl->SystemIncludeDirectories.insert(incs.begin(), incs.end());
+}
+
+std::set<std::string> const& cmTarget::GetSystemIncludeDirectories() const
+{
+ return impl->SystemIncludeDirectories;
}
cmStringRange cmTarget::GetIncludeDirectoriesEntries() const
{
- return cmMakeRange(this->Internal->IncludeDirectoriesEntries);
+ return cmMakeRange(impl->IncludeDirectoriesEntries);
}
cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const
{
- return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces);
+ return cmMakeRange(impl->IncludeDirectoriesBacktraces);
}
cmStringRange cmTarget::GetCompileOptionsEntries() const
{
- return cmMakeRange(this->Internal->CompileOptionsEntries);
+ return cmMakeRange(impl->CompileOptionsEntries);
}
cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const
{
- return cmMakeRange(this->Internal->CompileOptionsBacktraces);
+ return cmMakeRange(impl->CompileOptionsBacktraces);
}
cmStringRange cmTarget::GetCompileFeaturesEntries() const
{
- return cmMakeRange(this->Internal->CompileFeaturesEntries);
+ return cmMakeRange(impl->CompileFeaturesEntries);
}
cmBacktraceRange cmTarget::GetCompileFeaturesBacktraces() const
{
- return cmMakeRange(this->Internal->CompileFeaturesBacktraces);
+ return cmMakeRange(impl->CompileFeaturesBacktraces);
}
cmStringRange cmTarget::GetCompileDefinitionsEntries() const
{
- return cmMakeRange(this->Internal->CompileDefinitionsEntries);
+ return cmMakeRange(impl->CompileDefinitionsEntries);
}
cmBacktraceRange cmTarget::GetCompileDefinitionsBacktraces() const
{
- return cmMakeRange(this->Internal->CompileDefinitionsBacktraces);
+ return cmMakeRange(impl->CompileDefinitionsBacktraces);
+}
+
+cmStringRange cmTarget::GetPrecompileHeadersEntries() const
+{
+ return cmMakeRange(impl->PrecompileHeadersEntries);
+}
+
+cmBacktraceRange cmTarget::GetPrecompileHeadersBacktraces() const
+{
+ return cmMakeRange(impl->PrecompileHeadersBacktraces);
}
cmStringRange cmTarget::GetSourceEntries() const
{
- return cmMakeRange(this->Internal->SourceEntries);
+ return cmMakeRange(impl->SourceEntries);
}
cmBacktraceRange cmTarget::GetSourceBacktraces() const
{
- return cmMakeRange(this->Internal->SourceBacktraces);
+ return cmMakeRange(impl->SourceBacktraces);
+}
+
+cmStringRange cmTarget::GetLinkOptionsEntries() const
+{
+ return cmMakeRange(impl->LinkOptionsEntries);
+}
+
+cmBacktraceRange cmTarget::GetLinkOptionsBacktraces() const
+{
+ return cmMakeRange(impl->LinkOptionsBacktraces);
+}
+
+cmStringRange cmTarget::GetLinkDirectoriesEntries() const
+{
+ return cmMakeRange(impl->LinkDirectoriesEntries);
+}
+
+cmBacktraceRange cmTarget::GetLinkDirectoriesBacktraces() const
+{
+ return cmMakeRange(impl->LinkDirectoriesBacktraces);
}
cmStringRange cmTarget::GetLinkImplementationEntries() const
{
- return cmMakeRange(this->Internal->LinkImplementationPropertyEntries);
+ return cmMakeRange(impl->LinkImplementationPropertyEntries);
}
cmBacktraceRange cmTarget::GetLinkImplementationBacktraces() const
{
- return cmMakeRange(this->Internal->LinkImplementationPropertyBacktraces);
+ return cmMakeRange(impl->LinkImplementationPropertyBacktraces);
}
void cmTarget::SetProperty(const std::string& prop, const char* value)
{
if (!cmTargetPropertyComputer::PassesWhitelist(
- this->GetType(), prop, this->Makefile->GetMessenger(),
- this->Makefile->GetBacktrace())) {
+ this->GetType(), prop, impl->Makefile->GetMessenger(),
+ impl->Makefile->GetBacktrace())) {
return;
}
- if (prop == "MANUALLY_ADDED_DEPENDENCIES") {
- std::ostringstream e;
- e << "MANUALLY_ADDED_DEPENDENCIES property is read-only\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+#define MAKE_STATIC_PROP(PROP) static const std::string prop##PROP = #PROP
+ MAKE_STATIC_PROP(COMPILE_DEFINITIONS);
+ MAKE_STATIC_PROP(COMPILE_FEATURES);
+ MAKE_STATIC_PROP(COMPILE_OPTIONS);
+ MAKE_STATIC_PROP(PRECOMPILE_HEADERS);
+ MAKE_STATIC_PROP(PRECOMPILE_HEADERS_REUSE_FROM);
+ MAKE_STATIC_PROP(CUDA_PTX_COMPILATION);
+ MAKE_STATIC_PROP(EXPORT_NAME);
+ MAKE_STATIC_PROP(IMPORTED_GLOBAL);
+ MAKE_STATIC_PROP(INCLUDE_DIRECTORIES);
+ MAKE_STATIC_PROP(LINK_OPTIONS);
+ MAKE_STATIC_PROP(LINK_DIRECTORIES);
+ MAKE_STATIC_PROP(LINK_LIBRARIES);
+ MAKE_STATIC_PROP(MANUALLY_ADDED_DEPENDENCIES);
+ MAKE_STATIC_PROP(NAME);
+ MAKE_STATIC_PROP(SOURCES);
+ MAKE_STATIC_PROP(TYPE);
+#undef MAKE_STATIC_PROP
+ if (prop == propMANUALLY_ADDED_DEPENDENCIES) {
+ impl->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ "MANUALLY_ADDED_DEPENDENCIES property is read-only\n");
return;
}
- if (prop == "NAME") {
- std::ostringstream e;
- e << "NAME property is read-only\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ if (prop == propNAME) {
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR,
+ "NAME property is read-only\n");
return;
}
- if (prop == "TYPE") {
- std::ostringstream e;
- e << "TYPE property is read-only\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ if (prop == propTYPE) {
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR,
+ "TYPE property is read-only\n");
return;
}
- if (prop == "EXPORT_NAME" && this->IsImported()) {
+ if (prop == propEXPORT_NAME && this->IsImported()) {
std::ostringstream e;
e << "EXPORT_NAME property can't be set on imported targets (\""
- << this->Name << "\")\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ << impl->Name << "\")\n";
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
- if (prop == "SOURCES" && this->IsImported()) {
+ if (prop == propSOURCES && this->IsImported()) {
std::ostringstream e;
- e << "SOURCES property can't be set on imported targets (\"" << this->Name
+ e << "SOURCES property can't be set on imported targets (\"" << impl->Name
<< "\")\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return;
+ }
+ if (prop == propIMPORTED_GLOBAL && !this->IsImported()) {
+ std::ostringstream e;
+ e << "IMPORTED_GLOBAL property can't be set on non-imported targets (\""
+ << impl->Name << "\")\n";
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
- if (prop == "INCLUDE_DIRECTORIES") {
- this->Internal->IncludeDirectoriesEntries.clear();
- this->Internal->IncludeDirectoriesBacktraces.clear();
+ if (prop == propINCLUDE_DIRECTORIES) {
+ impl->IncludeDirectoriesEntries.clear();
+ impl->IncludeDirectoriesBacktraces.clear();
if (value) {
- this->Internal->IncludeDirectoriesEntries.push_back(value);
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt);
+ impl->IncludeDirectoriesEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->IncludeDirectoriesBacktraces.push_back(lfbt);
}
- } else if (prop == "COMPILE_OPTIONS") {
- this->Internal->CompileOptionsEntries.clear();
- this->Internal->CompileOptionsBacktraces.clear();
+ } else if (prop == propCOMPILE_OPTIONS) {
+ impl->CompileOptionsEntries.clear();
+ impl->CompileOptionsBacktraces.clear();
if (value) {
- this->Internal->CompileOptionsEntries.push_back(value);
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->CompileOptionsBacktraces.push_back(lfbt);
+ impl->CompileOptionsEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->CompileOptionsBacktraces.push_back(lfbt);
}
- } else if (prop == "COMPILE_FEATURES") {
- this->Internal->CompileFeaturesEntries.clear();
- this->Internal->CompileFeaturesBacktraces.clear();
+ } else if (prop == propCOMPILE_FEATURES) {
+ impl->CompileFeaturesEntries.clear();
+ impl->CompileFeaturesBacktraces.clear();
if (value) {
- this->Internal->CompileFeaturesEntries.push_back(value);
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->CompileFeaturesBacktraces.push_back(lfbt);
+ impl->CompileFeaturesEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->CompileFeaturesBacktraces.push_back(lfbt);
}
- } else if (prop == "COMPILE_DEFINITIONS") {
- this->Internal->CompileDefinitionsEntries.clear();
- this->Internal->CompileDefinitionsBacktraces.clear();
+ } else if (prop == propCOMPILE_DEFINITIONS) {
+ impl->CompileDefinitionsEntries.clear();
+ impl->CompileDefinitionsBacktraces.clear();
if (value) {
- this->Internal->CompileDefinitionsEntries.push_back(value);
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->CompileDefinitionsBacktraces.push_back(lfbt);
+ impl->CompileDefinitionsEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->CompileDefinitionsBacktraces.push_back(lfbt);
}
- } else if (prop == "LINK_LIBRARIES") {
- this->Internal->LinkImplementationPropertyEntries.clear();
- this->Internal->LinkImplementationPropertyBacktraces.clear();
+ } else if (prop == propLINK_OPTIONS) {
+ impl->LinkOptionsEntries.clear();
+ impl->LinkOptionsBacktraces.clear();
if (value) {
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->LinkImplementationPropertyEntries.push_back(value);
- this->Internal->LinkImplementationPropertyBacktraces.push_back(lfbt);
+ impl->LinkOptionsEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->LinkOptionsBacktraces.push_back(lfbt);
}
- } else if (prop == "SOURCES") {
- this->Internal->SourceEntries.clear();
- this->Internal->SourceBacktraces.clear();
+ } else if (prop == propLINK_DIRECTORIES) {
+ impl->LinkDirectoriesEntries.clear();
+ impl->LinkDirectoriesBacktraces.clear();
if (value) {
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->SourceEntries.push_back(value);
- this->Internal->SourceBacktraces.push_back(lfbt);
+ impl->LinkDirectoriesEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->LinkDirectoriesBacktraces.push_back(lfbt);
+ }
+ } else if (prop == propPRECOMPILE_HEADERS) {
+ impl->PrecompileHeadersEntries.clear();
+ impl->PrecompileHeadersBacktraces.clear();
+ if (value) {
+ impl->PrecompileHeadersEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->PrecompileHeadersBacktraces.push_back(lfbt);
+ }
+ } else if (prop == propLINK_LIBRARIES) {
+ impl->LinkImplementationPropertyEntries.clear();
+ impl->LinkImplementationPropertyBacktraces.clear();
+ if (value) {
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->LinkImplementationPropertyEntries.emplace_back(value);
+ impl->LinkImplementationPropertyBacktraces.push_back(lfbt);
+ }
+ } else if (prop == propSOURCES) {
+ impl->SourceEntries.clear();
+ impl->SourceBacktraces.clear();
+ if (value) {
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->SourceEntries.emplace_back(value);
+ impl->SourceBacktraces.push_back(lfbt);
+ }
+ } else if (prop == propIMPORTED_GLOBAL) {
+ if (!cmIsOn(value)) {
+ std::ostringstream e;
+ e << "IMPORTED_GLOBAL property can't be set to FALSE on targets (\""
+ << impl->Name << "\")\n";
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return;
+ }
+ /* no need to change anything if value does not change */
+ if (!impl->ImportedGloballyVisible) {
+ impl->ImportedGloballyVisible = true;
+ this->GetGlobalGenerator()->IndexTarget(this);
}
} else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME") &&
- !this->CheckImportedLibName(prop, value ? value : "")) {
+ !impl->CheckImportedLibName(prop, value ? value : "")) {
/* error was reported by check method */
- } else if (prop == "CUDA_PTX_COMPILATION" &&
+ } else if (prop == propCUDA_PTX_COMPILATION &&
this->GetType() != cmStateEnums::OBJECT_LIBRARY) {
std::ostringstream e;
e << "CUDA_PTX_COMPILATION property can only be applied to OBJECT "
"targets (\""
- << this->Name << "\")\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ << impl->Name << "\")\n";
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
+ } else if (prop == propPRECOMPILE_HEADERS_REUSE_FROM) {
+ if (this->GetProperty("PRECOMPILE_HEADERS")) {
+ std::ostringstream e;
+ e << "PRECOMPILE_HEADERS property is already set on target (\""
+ << impl->Name << "\")\n";
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return;
+ }
+ auto reusedTarget =
+ impl->Makefile->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(
+ value);
+ if (!reusedTarget) {
+ const std::string e(
+ "PRECOMPILE_HEADERS_REUSE_FROM set with non existing target");
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e);
+ return;
+ }
+
+ std::string reusedFrom = reusedTarget->GetSafeProperty(prop);
+ if (reusedFrom.empty()) {
+ reusedFrom = value;
+ }
+
+ impl->Properties.SetProperty(prop, reusedFrom.c_str());
+
+ reusedTarget->SetProperty("COMPILE_PDB_NAME", reusedFrom.c_str());
+ reusedTarget->SetProperty("COMPILE_PDB_OUTPUT_DIRECTORY",
+ cmStrCat(reusedFrom, ".dir/").c_str());
+
+ this->SetProperty("COMPILE_PDB_NAME",
+ reusedTarget->GetProperty("COMPILE_PDB_NAME"));
+ this->AddUtility(reusedFrom, impl->Makefile);
} else {
- this->Properties.SetProperty(prop, value);
+ impl->Properties.SetProperty(prop, value);
}
}
@@ -958,69 +1302,102 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
bool asString)
{
if (!cmTargetPropertyComputer::PassesWhitelist(
- this->GetType(), prop, this->Makefile->GetMessenger(),
- this->Makefile->GetBacktrace())) {
+ this->GetType(), prop, impl->Makefile->GetMessenger(),
+ impl->Makefile->GetBacktrace())) {
return;
}
if (prop == "NAME") {
- std::ostringstream e;
- e << "NAME property is read-only\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR,
+ "NAME property is read-only\n");
return;
}
if (prop == "EXPORT_NAME" && this->IsImported()) {
std::ostringstream e;
e << "EXPORT_NAME property can't be set on imported targets (\""
- << this->Name << "\")\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ << impl->Name << "\")\n";
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
if (prop == "SOURCES" && this->IsImported()) {
std::ostringstream e;
- e << "SOURCES property can't be set on imported targets (\"" << this->Name
+ e << "SOURCES property can't be set on imported targets (\"" << impl->Name
<< "\")\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return;
+ }
+ if (prop == "IMPORTED_GLOBAL") {
+ std::ostringstream e;
+ e << "IMPORTED_GLOBAL property can't be appended, only set on imported "
+ "targets (\""
+ << impl->Name << "\")\n";
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
}
if (prop == "INCLUDE_DIRECTORIES") {
if (value && *value) {
- this->Internal->IncludeDirectoriesEntries.push_back(value);
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt);
+ impl->IncludeDirectoriesEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->IncludeDirectoriesBacktraces.push_back(lfbt);
}
} else if (prop == "COMPILE_OPTIONS") {
if (value && *value) {
- this->Internal->CompileOptionsEntries.push_back(value);
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->CompileOptionsBacktraces.push_back(lfbt);
+ impl->CompileOptionsEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->CompileOptionsBacktraces.push_back(lfbt);
}
} else if (prop == "COMPILE_FEATURES") {
if (value && *value) {
- this->Internal->CompileFeaturesEntries.push_back(value);
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->CompileFeaturesBacktraces.push_back(lfbt);
+ impl->CompileFeaturesEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->CompileFeaturesBacktraces.push_back(lfbt);
}
} else if (prop == "COMPILE_DEFINITIONS") {
if (value && *value) {
- this->Internal->CompileDefinitionsEntries.push_back(value);
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->CompileDefinitionsBacktraces.push_back(lfbt);
+ impl->CompileDefinitionsEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->CompileDefinitionsBacktraces.push_back(lfbt);
+ }
+ } else if (prop == "LINK_OPTIONS") {
+ if (value && *value) {
+ impl->LinkOptionsEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->LinkOptionsBacktraces.push_back(lfbt);
+ }
+ } else if (prop == "LINK_DIRECTORIES") {
+ if (value && *value) {
+ impl->LinkDirectoriesEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->LinkDirectoriesBacktraces.push_back(lfbt);
+ }
+ } else if (prop == "PRECOMPILE_HEADERS") {
+ if (this->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM")) {
+ std::ostringstream e;
+ e << "PRECOMPILE_HEADERS_REUSE_FROM property is already set on target "
+ "(\""
+ << impl->Name << "\")\n";
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return;
+ }
+ if (value && *value) {
+ impl->PrecompileHeadersEntries.emplace_back(value);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->PrecompileHeadersBacktraces.push_back(lfbt);
}
} else if (prop == "LINK_LIBRARIES") {
if (value && *value) {
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->LinkImplementationPropertyEntries.push_back(value);
- this->Internal->LinkImplementationPropertyBacktraces.push_back(lfbt);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->LinkImplementationPropertyEntries.emplace_back(value);
+ impl->LinkImplementationPropertyBacktraces.push_back(lfbt);
}
} else if (prop == "SOURCES") {
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- this->Internal->SourceEntries.push_back(value);
- this->Internal->SourceBacktraces.push_back(lfbt);
+ cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
+ impl->SourceEntries.emplace_back(value);
+ impl->SourceBacktraces.push_back(lfbt);
} else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME")) {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR,
prop + " property may not be APPENDed.");
} else {
- this->Properties.AppendProperty(prop, value, asString);
+ impl->Properties.AppendProperty(prop, value, asString);
}
}
@@ -1033,16 +1410,17 @@ void cmTarget::AppendBuildInterfaceIncludes()
!this->IsExecutableWithExports()) {
return;
}
- if (this->BuildInterfaceIncludesAppended) {
+ if (impl->BuildInterfaceIncludesAppended) {
return;
}
- this->BuildInterfaceIncludesAppended = true;
+ impl->BuildInterfaceIncludesAppended = true;
- if (this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE")) {
- const char* binDir = this->Makefile->GetCurrentBinaryDirectory();
- const char* srcDir = this->Makefile->GetCurrentSourceDirectory();
- const std::string dirs = std::string(binDir ? binDir : "") +
- std::string(binDir ? ";" : "") + std::string(srcDir ? srcDir : "");
+ if (impl->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE")) {
+ std::string dirs = impl->Makefile->GetCurrentBinaryDirectory();
+ if (!dirs.empty()) {
+ dirs += ';';
+ }
+ dirs += impl->Makefile->GetCurrentSourceDirectory();
if (!dirs.empty()) {
this->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES",
("$<BUILD_INTERFACE:" + dirs + ">").c_str());
@@ -1053,38 +1431,67 @@ void cmTarget::AppendBuildInterfaceIncludes()
void cmTarget::InsertInclude(std::string const& entry,
cmListFileBacktrace const& bt, bool before)
{
- std::vector<std::string>::iterator position = before
- ? this->Internal->IncludeDirectoriesEntries.begin()
- : this->Internal->IncludeDirectoriesEntries.end();
+ auto position = before ? impl->IncludeDirectoriesEntries.begin()
+ : impl->IncludeDirectoriesEntries.end();
- std::vector<cmListFileBacktrace>::iterator btPosition = before
- ? this->Internal->IncludeDirectoriesBacktraces.begin()
- : this->Internal->IncludeDirectoriesBacktraces.end();
+ auto btPosition = before ? impl->IncludeDirectoriesBacktraces.begin()
+ : impl->IncludeDirectoriesBacktraces.end();
- this->Internal->IncludeDirectoriesEntries.insert(position, entry);
- this->Internal->IncludeDirectoriesBacktraces.insert(btPosition, bt);
+ impl->IncludeDirectoriesEntries.insert(position, entry);
+ impl->IncludeDirectoriesBacktraces.insert(btPosition, bt);
}
void cmTarget::InsertCompileOption(std::string const& entry,
cmListFileBacktrace const& bt, bool before)
{
- std::vector<std::string>::iterator position = before
- ? this->Internal->CompileOptionsEntries.begin()
- : this->Internal->CompileOptionsEntries.end();
+ auto position = before ? impl->CompileOptionsEntries.begin()
+ : impl->CompileOptionsEntries.end();
- std::vector<cmListFileBacktrace>::iterator btPosition = before
- ? this->Internal->CompileOptionsBacktraces.begin()
- : this->Internal->CompileOptionsBacktraces.end();
+ auto btPosition = before ? impl->CompileOptionsBacktraces.begin()
+ : impl->CompileOptionsBacktraces.end();
- this->Internal->CompileOptionsEntries.insert(position, entry);
- this->Internal->CompileOptionsBacktraces.insert(btPosition, bt);
+ impl->CompileOptionsEntries.insert(position, entry);
+ impl->CompileOptionsBacktraces.insert(btPosition, bt);
}
void cmTarget::InsertCompileDefinition(std::string const& entry,
cmListFileBacktrace const& bt)
{
- this->Internal->CompileDefinitionsEntries.push_back(entry);
- this->Internal->CompileDefinitionsBacktraces.push_back(bt);
+ impl->CompileDefinitionsEntries.push_back(entry);
+ impl->CompileDefinitionsBacktraces.push_back(bt);
+}
+
+void cmTarget::InsertLinkOption(std::string const& entry,
+ cmListFileBacktrace const& bt, bool before)
+{
+ auto position =
+ before ? impl->LinkOptionsEntries.begin() : impl->LinkOptionsEntries.end();
+
+ auto btPosition = before ? impl->LinkOptionsBacktraces.begin()
+ : impl->LinkOptionsBacktraces.end();
+
+ impl->LinkOptionsEntries.insert(position, entry);
+ impl->LinkOptionsBacktraces.insert(btPosition, bt);
+}
+
+void cmTarget::InsertLinkDirectory(std::string const& entry,
+ cmListFileBacktrace const& bt, bool before)
+{
+ auto position = before ? impl->LinkDirectoriesEntries.begin()
+ : impl->LinkDirectoriesEntries.end();
+
+ auto btPosition = before ? impl->LinkDirectoriesBacktraces.begin()
+ : impl->LinkDirectoriesBacktraces.end();
+
+ impl->LinkDirectoriesEntries.insert(position, entry);
+ impl->LinkDirectoriesBacktraces.insert(btPosition, bt);
+}
+
+void cmTarget::InsertPrecompileHeader(std::string const& entry,
+ cmListFileBacktrace const& bt)
+{
+ impl->PrecompileHeadersEntries.push_back(entry);
+ impl->PrecompileHeadersBacktraces.push_back(bt);
}
static void cmTargetCheckLINK_INTERFACE_LIBRARIES(const std::string& prop,
@@ -1123,7 +1530,7 @@ static void cmTargetCheckLINK_INTERFACE_LIBRARIES(const std::string& prop,
<< "the LINK_INTERFACE_LIBRARIES and LINK_INTERFACE_LIBRARIES_DEBUG "
<< "properties accordingly.";
}
- context->IssueMessage(cmake::FATAL_ERROR, e.str());
+ context->IssueMessage(MessageType::FATAL_ERROR, e.str());
}
static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value,
@@ -1145,7 +1552,21 @@ static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value,
"property may contain configuration-sensitive generator-expressions "
"which may be used to specify per-configuration rules.";
- context->IssueMessage(cmake::FATAL_ERROR, e.str());
+ context->IssueMessage(MessageType::FATAL_ERROR, e.str());
+}
+
+static void cmTargetCheckIMPORTED_GLOBAL(const cmTarget* target,
+ cmMakefile* context)
+{
+ std::vector<cmTarget*> targets = context->GetOwnedImportedTargets();
+ auto it = std::find(targets.begin(), targets.end(), target);
+ if (it == targets.end()) {
+ std::ostringstream e;
+ e << "Attempt to promote imported target \"" << target->GetName()
+ << "\" to global scope (by setting IMPORTED_GLOBAL) "
+ "which is not built in this directory.";
+ context->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ }
}
void cmTarget::CheckProperty(const std::string& prop,
@@ -1162,11 +1583,16 @@ void cmTarget::CheckProperty(const std::string& prop,
cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, true);
}
}
- if (cmHasLiteralPrefix(prop, "INTERFACE_LINK_LIBRARIES")) {
+ if (prop == "INTERFACE_LINK_LIBRARIES") {
if (const char* value = this->GetProperty(prop)) {
cmTargetCheckINTERFACE_LINK_LIBRARIES(value, context);
}
}
+ if (prop == "IMPORTED_GLOBAL") {
+ if (this->IsImported()) {
+ cmTargetCheckIMPORTED_GLOBAL(this, context);
+ }
+ }
}
const char* cmTarget::GetComputedProperty(
@@ -1178,7 +1604,6 @@ const char* cmTarget::GetComputedProperty(
const char* cmTarget::GetProperty(const std::string& prop) const
{
- static CM_UNORDERED_SET<std::string> specialProps;
#define MAKE_STATIC_PROP(PROP) static const std::string prop##PROP = #PROP
MAKE_STATIC_PROP(LINK_LIBRARIES);
MAKE_STATIC_PROP(TYPE);
@@ -1186,35 +1611,43 @@ const char* cmTarget::GetProperty(const std::string& prop) const
MAKE_STATIC_PROP(COMPILE_FEATURES);
MAKE_STATIC_PROP(COMPILE_OPTIONS);
MAKE_STATIC_PROP(COMPILE_DEFINITIONS);
+ MAKE_STATIC_PROP(LINK_OPTIONS);
+ MAKE_STATIC_PROP(LINK_DIRECTORIES);
+ MAKE_STATIC_PROP(PRECOMPILE_HEADERS);
MAKE_STATIC_PROP(IMPORTED);
+ MAKE_STATIC_PROP(IMPORTED_GLOBAL);
MAKE_STATIC_PROP(MANUALLY_ADDED_DEPENDENCIES);
MAKE_STATIC_PROP(NAME);
MAKE_STATIC_PROP(BINARY_DIR);
MAKE_STATIC_PROP(SOURCE_DIR);
MAKE_STATIC_PROP(SOURCES);
#undef MAKE_STATIC_PROP
- if (specialProps.empty()) {
- specialProps.insert(propLINK_LIBRARIES);
- specialProps.insert(propTYPE);
- specialProps.insert(propINCLUDE_DIRECTORIES);
- specialProps.insert(propCOMPILE_FEATURES);
- specialProps.insert(propCOMPILE_OPTIONS);
- specialProps.insert(propCOMPILE_DEFINITIONS);
- specialProps.insert(propIMPORTED);
- specialProps.insert(propMANUALLY_ADDED_DEPENDENCIES);
- specialProps.insert(propNAME);
- specialProps.insert(propBINARY_DIR);
- specialProps.insert(propSOURCE_DIR);
- specialProps.insert(propSOURCES);
- }
+ static std::unordered_set<std::string> const specialProps{
+ propLINK_LIBRARIES,
+ propTYPE,
+ propINCLUDE_DIRECTORIES,
+ propCOMPILE_FEATURES,
+ propCOMPILE_OPTIONS,
+ propCOMPILE_DEFINITIONS,
+ propPRECOMPILE_HEADERS,
+ propLINK_OPTIONS,
+ propLINK_DIRECTORIES,
+ propIMPORTED,
+ propIMPORTED_GLOBAL,
+ propMANUALLY_ADDED_DEPENDENCIES,
+ propNAME,
+ propBINARY_DIR,
+ propSOURCE_DIR,
+ propSOURCES
+ };
if (specialProps.count(prop)) {
if (prop == propLINK_LIBRARIES) {
- if (this->Internal->LinkImplementationPropertyEntries.empty()) {
- return CM_NULLPTR;
+ if (impl->LinkImplementationPropertyEntries.empty()) {
+ return nullptr;
}
static std::string output;
- output = cmJoin(this->Internal->LinkImplementationPropertyEntries, ";");
+ output = cmJoin(impl->LinkImplementationPropertyEntries, ";");
return output.c_str();
}
// the type property returns what type the target is
@@ -1222,85 +1655,150 @@ const char* cmTarget::GetProperty(const std::string& prop) const
return cmState::GetTargetTypeName(this->GetType());
}
if (prop == propINCLUDE_DIRECTORIES) {
- if (this->Internal->IncludeDirectoriesEntries.empty()) {
- return CM_NULLPTR;
+ if (impl->IncludeDirectoriesEntries.empty()) {
+ return nullptr;
}
static std::string output;
- output = cmJoin(this->Internal->IncludeDirectoriesEntries, ";");
+ output = cmJoin(impl->IncludeDirectoriesEntries, ";");
return output.c_str();
}
if (prop == propCOMPILE_FEATURES) {
- if (this->Internal->CompileFeaturesEntries.empty()) {
- return CM_NULLPTR;
+ if (impl->CompileFeaturesEntries.empty()) {
+ return nullptr;
}
static std::string output;
- output = cmJoin(this->Internal->CompileFeaturesEntries, ";");
+ output = cmJoin(impl->CompileFeaturesEntries, ";");
return output.c_str();
}
if (prop == propCOMPILE_OPTIONS) {
- if (this->Internal->CompileOptionsEntries.empty()) {
- return CM_NULLPTR;
+ if (impl->CompileOptionsEntries.empty()) {
+ return nullptr;
}
static std::string output;
- output = cmJoin(this->Internal->CompileOptionsEntries, ";");
+ output = cmJoin(impl->CompileOptionsEntries, ";");
return output.c_str();
}
if (prop == propCOMPILE_DEFINITIONS) {
- if (this->Internal->CompileDefinitionsEntries.empty()) {
- return CM_NULLPTR;
+ if (impl->CompileDefinitionsEntries.empty()) {
+ return nullptr;
+ }
+
+ static std::string output;
+ output = cmJoin(impl->CompileDefinitionsEntries, ";");
+ return output.c_str();
+ }
+ if (prop == propLINK_OPTIONS) {
+ if (impl->LinkOptionsEntries.empty()) {
+ return nullptr;
}
static std::string output;
- output = cmJoin(this->Internal->CompileDefinitionsEntries, ";");
+ output = cmJoin(impl->LinkOptionsEntries, ";");
+ return output.c_str();
+ }
+ if (prop == propLINK_DIRECTORIES) {
+ if (impl->LinkDirectoriesEntries.empty()) {
+ return nullptr;
+ }
+
+ static std::string output;
+ output = cmJoin(impl->LinkDirectoriesEntries, ";");
+
return output.c_str();
}
if (prop == propMANUALLY_ADDED_DEPENDENCIES) {
- if (this->Utilities.empty()) {
- return CM_NULLPTR;
+ if (impl->Utilities.empty()) {
+ return nullptr;
+ }
+
+ static std::string output;
+ output = cmJoin(impl->Utilities, ";");
+ return output.c_str();
+ }
+ if (prop == propPRECOMPILE_HEADERS) {
+ if (impl->PrecompileHeadersEntries.empty()) {
+ return nullptr;
}
static std::string output;
- output = cmJoin(this->Utilities, ";");
+ output = cmJoin(impl->PrecompileHeadersEntries, ";");
return output.c_str();
}
if (prop == propIMPORTED) {
return this->IsImported() ? "TRUE" : "FALSE";
}
+ if (prop == propIMPORTED_GLOBAL) {
+ return this->IsImportedGloballyVisible() ? "TRUE" : "FALSE";
+ }
if (prop == propNAME) {
return this->GetName().c_str();
}
if (prop == propBINARY_DIR) {
- return this->GetMakefile()
- ->GetStateSnapshot()
+ return impl->Makefile->GetStateSnapshot()
.GetDirectory()
- .GetCurrentBinary();
+ .GetCurrentBinary()
+ .c_str();
}
if (prop == propSOURCE_DIR) {
- return this->GetMakefile()
- ->GetStateSnapshot()
+ return impl->Makefile->GetStateSnapshot()
.GetDirectory()
- .GetCurrentSource();
+ .GetCurrentSource()
+ .c_str();
}
}
- const char* retVal = this->Properties.GetPropertyValue(prop);
+ const char* retVal = impl->Properties.GetPropertyValue(prop);
if (!retVal) {
- const bool chain = this->GetMakefile()->GetState()->IsPropertyChained(
- prop, cmProperty::TARGET);
+ const bool chain =
+ impl->Makefile->GetState()->IsPropertyChained(prop, cmProperty::TARGET);
if (chain) {
- return this->Makefile->GetStateSnapshot().GetDirectory().GetProperty(
+ return impl->Makefile->GetStateSnapshot().GetDirectory().GetProperty(
prop, chain);
}
}
return retVal;
}
+const char* cmTarget::GetSafeProperty(const std::string& prop) const
+{
+ const char* ret = this->GetProperty(prop);
+ if (!ret) {
+ return "";
+ }
+ return ret;
+}
+
bool cmTarget::GetPropertyAsBool(const std::string& prop) const
{
- return cmSystemTools::IsOn(this->GetProperty(prop));
+ return cmIsOn(this->GetProperty(prop));
+}
+
+cmPropertyMap const& cmTarget::GetProperties() const
+{
+ return impl->Properties;
+}
+
+bool cmTarget::IsDLLPlatform() const
+{
+ return impl->IsDLLPlatform;
+}
+
+bool cmTarget::IsAIX() const
+{
+ return impl->IsAIX;
+}
+
+bool cmTarget::IsImported() const
+{
+ return impl->IsImportedTarget;
+}
+
+bool cmTarget::IsImportedGloballyVisible() const
+{
+ return impl->ImportedGloballyVisible;
}
const char* cmTarget::GetSuffixVariableInternal(
@@ -1330,11 +1828,12 @@ const char* cmTarget::GetSuffixVariableInternal(
case cmStateEnums::RuntimeBinaryArtifact:
// Android GUI application packages store the native
// binary as a shared library.
- return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")
+ return (impl->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")
? "CMAKE_SHARED_LIBRARY_SUFFIX"
: "CMAKE_EXECUTABLE_SUFFIX");
case cmStateEnums::ImportLibraryArtifact:
- return "CMAKE_IMPORT_LIBRARY_SUFFIX";
+ return (impl->IsAIX ? "CMAKE_AIX_IMPORT_FILE_SUFFIX"
+ : "CMAKE_IMPORT_LIBRARY_SUFFIX");
}
break;
default:
@@ -1370,11 +1869,12 @@ const char* cmTarget::GetPrefixVariableInternal(
case cmStateEnums::RuntimeBinaryArtifact:
// Android GUI application packages store the native
// binary as a shared library.
- return (this->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")
+ return (impl->IsAndroid && this->GetPropertyAsBool("ANDROID_GUI")
? "CMAKE_SHARED_LIBRARY_PREFIX"
: "");
case cmStateEnums::ImportLibraryArtifact:
- return "CMAKE_IMPORT_LIBRARY_PREFIX";
+ return (impl->IsAIX ? "CMAKE_AIX_IMPORT_FILE_PREFIX"
+ : "CMAKE_IMPORT_LIBRARY_PREFIX");
}
break;
default:
@@ -1397,8 +1897,8 @@ std::string cmTarget::ImportedGetFullPath(
std::string result;
- const char* loc = CM_NULLPTR;
- const char* imp = CM_NULLPTR;
+ const char* loc = nullptr;
+ const char* imp = nullptr;
std::string suffix;
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
@@ -1408,8 +1908,7 @@ std::string cmTarget::ImportedGetFullPath(
if (loc) {
result = loc;
} else {
- std::string impProp = "IMPORTED_LOCATION";
- impProp += suffix;
+ std::string impProp = cmStrCat("IMPORTED_LOCATION", suffix);
if (const char* config_location = this->GetProperty(impProp)) {
result = config_location;
} else if (const char* location =
@@ -1424,8 +1923,7 @@ std::string cmTarget::ImportedGetFullPath(
result = imp;
} else if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->IsExecutableWithExports()) {
- std::string impProp = "IMPORTED_IMPLIB";
- impProp += suffix;
+ std::string impProp = cmStrCat("IMPORTED_IMPLIB", suffix);
if (const char* config_implib = this->GetProperty(impProp)) {
result = config_implib;
} else if (const char* implib =
@@ -1438,48 +1936,35 @@ std::string cmTarget::ImportedGetFullPath(
}
if (result.empty()) {
- result = this->GetName();
- result += "-NOTFOUND";
+ result = cmStrCat(this->GetName(), "-NOTFOUND");
}
return result;
}
-void cmTarget::SetPropertyDefault(const std::string& property,
- const char* default_value)
+bool cmTargetInternals::CheckImportedLibName(std::string const& prop,
+ std::string const& value) const
{
- // Compute the name of the variable holding the default value.
- std::string var = "CMAKE_";
- var += property;
-
- if (const char* value = this->Makefile->GetDefinition(var)) {
- this->SetProperty(property, value);
- } else if (default_value) {
- this->SetProperty(property, default_value);
- }
-}
-
-bool cmTarget::CheckImportedLibName(std::string const& prop,
- std::string const& value) const
-{
- if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY ||
- !this->IsImported()) {
+ if (this->TargetType != cmStateEnums::INTERFACE_LIBRARY ||
+ !this->IsImportedTarget) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR, prop +
+ MessageType::FATAL_ERROR,
+ prop +
" property may be set only on imported INTERFACE library targets.");
return false;
}
if (!value.empty()) {
if (value[0] == '-') {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, prop +
- " property value\n " + value +
+ this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
+ prop + " property value\n " + value +
"\nmay not start with '-'.");
return false;
}
std::string::size_type bad = value.find_first_of(":/\\;");
if (bad != std::string::npos) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR, prop + " property value\n " + value +
- "\nmay not contain '" + value.substr(bad, 1) + "'.");
+ this->Makefile->IssueMessage(MessageType::FATAL_ERROR,
+ prop + " property value\n " + value +
+ "\nmay not contain '" +
+ value.substr(bad, 1) + "'.");
return false;
}
}
@@ -1505,25 +1990,26 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
}
// Track the configuration-specific property suffix.
- suffix = "_";
- suffix += config_upper;
+ suffix = cmStrCat('_', config_upper);
std::vector<std::string> mappedConfigs;
{
- std::string mapProp = "MAP_IMPORTED_CONFIG_";
- mapProp += config_upper;
+ std::string mapProp = cmStrCat("MAP_IMPORTED_CONFIG_", config_upper);
if (const char* mapValue = this->GetProperty(mapProp)) {
- cmSystemTools::ExpandListArgument(mapValue, mappedConfigs, true);
+ cmExpandList(mapValue, mappedConfigs, true);
}
}
// If we needed to find one of the mapped configurations but did not
// On a DLL platform there may be only IMPORTED_IMPLIB for a shared
// library or an executable with exports.
- bool allowImp = this->HasImportLibrary();
+ bool allowImp = (this->IsDLLPlatform() &&
+ (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
+ this->IsExecutableWithExports())) ||
+ (this->IsAIX() && this->IsExecutableWithExports());
// If a mapping was found, check its configurations.
- for (std::vector<std::string>::const_iterator mci = mappedConfigs.begin();
+ for (auto mci = mappedConfigs.begin();
!*loc && !*imp && mci != mappedConfigs.end(); ++mci) {
// Look for this configuration.
if (mci->empty()) {
@@ -1535,23 +2021,20 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
}
// If it was found, set the suffix.
if (*loc || *imp) {
- suffix = "";
+ suffix.clear();
}
} else {
std::string mcUpper = cmSystemTools::UpperCase(*mci);
- std::string locProp = locPropBase + "_";
- locProp += mcUpper;
+ std::string locProp = cmStrCat(locPropBase, '_', mcUpper);
*loc = this->GetProperty(locProp);
if (allowImp) {
- std::string impProp = "IMPORTED_IMPLIB_";
- impProp += mcUpper;
+ std::string impProp = cmStrCat("IMPORTED_IMPLIB_", mcUpper);
*imp = this->GetProperty(impProp);
}
// If it was found, use it for all properties below.
if (*loc || *imp) {
- suffix = "_";
- suffix += mcUpper;
+ suffix = cmStrCat('_', mcUpper);
}
}
}
@@ -1568,12 +2051,10 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
// If we have not yet found it then there are no mapped
// configurations. Look for an exact-match.
if (!*loc && !*imp) {
- std::string locProp = locPropBase;
- locProp += suffix;
+ std::string locProp = cmStrCat(locPropBase, suffix);
*loc = this->GetProperty(locProp);
if (allowImp) {
- std::string impProp = "IMPORTED_IMPLIB";
- impProp += suffix;
+ std::string impProp = cmStrCat("IMPORTED_IMPLIB", suffix);
*imp = this->GetProperty(impProp);
}
}
@@ -1582,7 +2063,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
// configurations and no exact match.
if (!*loc && !*imp) {
// The suffix computed above is not useful.
- suffix = "";
+ suffix.clear();
// Look for a configuration-less location. This may be set by
// manually-written code.
@@ -1597,19 +2078,15 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
if (!*loc && !*imp) {
std::vector<std::string> availableConfigs;
if (const char* iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) {
- cmSystemTools::ExpandListArgument(iconfigs, availableConfigs);
+ cmExpandList(iconfigs, availableConfigs);
}
- for (std::vector<std::string>::const_iterator aci =
- availableConfigs.begin();
+ for (auto aci = availableConfigs.begin();
!*loc && !*imp && aci != availableConfigs.end(); ++aci) {
- suffix = "_";
- suffix += cmSystemTools::UpperCase(*aci);
- std::string locProp = locPropBase;
- locProp += suffix;
+ suffix = cmStrCat('_', cmSystemTools::UpperCase(*aci));
+ std::string locProp = cmStrCat(locPropBase, suffix);
*loc = this->GetProperty(locProp);
if (allowImp) {
- std::string impProp = "IMPORTED_IMPLIB";
- impProp += suffix;
+ std::string impProp = cmStrCat("IMPORTED_IMPLIB", suffix);
*imp = this->GetProperty(impProp);
}
}
@@ -1623,37 +2100,3 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
return true;
}
-
-cmTargetInternalPointer::cmTargetInternalPointer()
-{
- this->Pointer = new cmTargetInternals;
-}
-
-cmTargetInternalPointer::cmTargetInternalPointer(
- cmTargetInternalPointer const& r)
-{
- // Ideally cmTarget instances should never be copied. However until
- // we can make a sweep to remove that, this copy constructor avoids
- // allowing the resources (Internals) to be copied.
- this->Pointer = new cmTargetInternals(*r.Pointer);
-}
-
-cmTargetInternalPointer::~cmTargetInternalPointer()
-{
- delete this->Pointer;
-}
-
-cmTargetInternalPointer& cmTargetInternalPointer::operator=(
- cmTargetInternalPointer const& r)
-{
- if (this == &r) {
- return *this;
- } // avoid warning on HP about self check
- // Ideally cmTarget instances should never be copied. However until
- // we can make a sweep to remove that, this copy constructor avoids
- // allowing the resources (Internals) to be copied.
- cmTargetInternals* oldPointer = this->Pointer;
- this->Pointer = new cmTargetInternals(*r.Pointer);
- delete oldPointer;
- return *this;
-}
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 1f00c0155..65a1ce36f 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -6,45 +6,32 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
-#include <map>
+#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "cmAlgorithms.h"
-#include "cmCustomCommand.h"
#include "cmListFileCache.h"
#include "cmPolicies.h"
-#include "cmPropertyMap.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmTargetLinkLibraryType.h"
-#include "cm_unordered_map.hxx"
+class cmCustomCommand;
class cmGlobalGenerator;
+class cmInstallTargetGenerator;
class cmMakefile;
class cmMessenger;
+class cmPropertyMap;
class cmSourceFile;
class cmTargetInternals;
-class cmTargetInternalPointer
-{
-public:
- cmTargetInternalPointer();
- cmTargetInternalPointer(cmTargetInternalPointer const& r);
- ~cmTargetInternalPointer();
- cmTargetInternalPointer& operator=(cmTargetInternalPointer const& r);
- cmTargetInternals* operator->() const { return this->Pointer; }
- cmTargetInternals* Get() const { return this->Pointer; }
-private:
- cmTargetInternals* Pointer;
-};
-
/** \class cmTarget
* \brief Represent a library or executable target loaded from a makefile.
*
- * cmTarget represents a target loaded from
- * a makefile.
+ * cmTarget represents a target loaded from a makefile.
*/
class cmTarget
{
@@ -59,88 +46,75 @@ public:
cmTarget(std::string const& name, cmStateEnums::TargetType type,
Visibility vis, cmMakefile* mf);
- enum CustomCommandType
- {
- PRE_BUILD,
- PRE_LINK,
- POST_BUILD
- };
+ cmTarget(cmTarget const&) = delete;
+ cmTarget(cmTarget&&) noexcept;
+ ~cmTarget();
- /**
- * Return the type of target.
- */
- cmStateEnums::TargetType GetType() const { return this->TargetTypeValue; }
+ cmTarget& operator=(cmTarget const&) = delete;
+ cmTarget& operator=(cmTarget&&) noexcept;
+
+ //! Return the type of target.
+ cmStateEnums::TargetType GetType() const;
+ //! Get the cmMakefile that owns this target.
+ cmMakefile* GetMakefile() const;
+
+ //! Return the global generator.
cmGlobalGenerator* GetGlobalGenerator() const;
- ///! Set/Get the name of the target
- const std::string& GetName() const { return this->Name; }
+ //! Set/Get the name of the target
+ const std::string& GetName() const;
+
+ //! Get the policy map
+ cmPolicies::PolicyMap const& GetPolicyMap() const;
- /** Get the cmMakefile that owns this target. */
- cmMakefile* GetMakefile() const { return this->Makefile; }
+ //! Get policy status
+ cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID policy) const;
#define DECLARE_TARGET_POLICY(POLICY) \
cmPolicies::PolicyStatus GetPolicyStatus##POLICY() const \
{ \
- return this->PolicyMap.Get(cmPolicies::POLICY); \
+ return this->GetPolicyStatus(cmPolicies::POLICY); \
}
CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY)
#undef DECLARE_TARGET_POLICY
- /**
- * Get the list of the custom commands for this target
- */
- std::vector<cmCustomCommand> const& GetPreBuildCommands() const
- {
- return this->PreBuildCommands;
- }
- std::vector<cmCustomCommand> const& GetPreLinkCommands() const
- {
- return this->PreLinkCommands;
- }
- std::vector<cmCustomCommand> const& GetPostBuildCommands() const
- {
- return this->PostBuildCommands;
- }
- void AddPreBuildCommand(cmCustomCommand const& cmd)
- {
- this->PreBuildCommands.push_back(cmd);
- }
- void AddPreLinkCommand(cmCustomCommand const& cmd)
- {
- this->PreLinkCommands.push_back(cmd);
- }
- void AddPostBuildCommand(cmCustomCommand const& cmd)
- {
- this->PostBuildCommands.push_back(cmd);
- }
+ //! Get the list of the PRE_BUILD custom commands for this target
+ std::vector<cmCustomCommand> const& GetPreBuildCommands() const;
+ void AddPreBuildCommand(cmCustomCommand const& cmd);
+ void AddPreBuildCommand(cmCustomCommand&& cmd);
- /**
- * Add sources to the target.
- */
+ //! Get the list of the PRE_LINK custom commands for this target
+ std::vector<cmCustomCommand> const& GetPreLinkCommands() const;
+ void AddPreLinkCommand(cmCustomCommand const& cmd);
+ void AddPreLinkCommand(cmCustomCommand&& cmd);
+
+ //! Get the list of the POST_BUILD custom commands for this target
+ std::vector<cmCustomCommand> const& GetPostBuildCommands() const;
+ void AddPostBuildCommand(cmCustomCommand const& cmd);
+ void AddPostBuildCommand(cmCustomCommand&& cmd);
+
+ //! Add sources to the target.
void AddSources(std::vector<std::string> const& srcs);
void AddTracedSources(std::vector<std::string> const& srcs);
- cmSourceFile* AddSourceCMP0049(const std::string& src);
- cmSourceFile* AddSource(const std::string& src);
+ std::string GetSourceCMP0049(const std::string& src);
+ cmSourceFile* AddSource(const std::string& src, bool before = false);
- //* how we identify a library, by name and type
- typedef std::pair<std::string, cmTargetLinkLibraryType> LibraryID;
+ //! how we identify a library, by name and type
+ using LibraryID = std::pair<std::string, cmTargetLinkLibraryType>;
+ using LinkLibraryVectorType = std::vector<LibraryID>;
+ LinkLibraryVectorType const& GetOriginalLinkLibraries() const;
- typedef std::vector<LibraryID> LinkLibraryVectorType;
- const LinkLibraryVectorType& GetOriginalLinkLibraries() const
- {
- return this->OriginalLinkLibraries;
- }
-
- /**
- * Clear the dependency information recorded for this target, if any.
- */
- void ClearDependencyInformation(cmMakefile& mf, const std::string& target);
+ //! Clear the dependency information recorded for this target, if any.
+ void ClearDependencyInformation(cmMakefile& mf);
void AddLinkLibrary(cmMakefile& mf, const std::string& lib,
cmTargetLinkLibraryType llt);
+ void AddLinkLibrary(cmMakefile& mf, std::string const& lib,
+ std::string const& libRef, cmTargetLinkLibraryType llt);
+
enum TLLSignature
{
KeywordTLLSignature,
@@ -150,80 +124,82 @@ public:
cmListFileContext const& lfc);
void GetTllSignatureTraces(std::ostream& s, TLLSignature sig) const;
- const std::vector<std::string>& GetLinkDirectories() const;
-
- void AddLinkDirectory(const std::string& d);
-
/**
* Set the path where this target should be installed. This is relative to
* INSTALL_PREFIX
*/
- std::string GetInstallPath() const { return this->InstallPath; }
- void SetInstallPath(const char* name) { this->InstallPath = name; }
+ std::string const& GetInstallPath() const;
+ void SetInstallPath(std::string const& name);
/**
* Set the path where this target (if it has a runtime part) should be
* installed. This is relative to INSTALL_PREFIX
*/
- std::string GetRuntimeInstallPath() const
- {
- return this->RuntimeInstallPath;
- }
- void SetRuntimeInstallPath(const char* name)
- {
- this->RuntimeInstallPath = name;
- }
+ std::string const& GetRuntimeInstallPath() const;
+ void SetRuntimeInstallPath(std::string const& name);
/**
* Get/Set whether there is an install rule for this target.
*/
- bool GetHaveInstallRule() const { return this->HaveInstallRule; }
- void SetHaveInstallRule(bool h) { this->HaveInstallRule = h; }
+ bool GetHaveInstallRule() const;
+ void SetHaveInstallRule(bool hir);
+
+ void AddInstallGenerator(cmInstallTargetGenerator* g);
+ std::vector<cmInstallTargetGenerator*> const& GetInstallGenerators() const;
+
+ /**
+ * Get/Set whether this target was auto-created by a generator.
+ */
+ bool GetIsGeneratorProvided() const;
+ void SetIsGeneratorProvided(bool igp);
- /** Add a utility on which this project depends. A utility is an executable
+ /**
+ * Add a utility on which this project depends. A utility is an executable
* name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE
* commands. It is not a full path nor does it have an extension.
*/
- void AddUtility(const std::string& u, cmMakefile* makefile = CM_NULLPTR);
- ///! Get the utilities used by this target
- std::set<std::string> const& GetUtilities() const { return this->Utilities; }
- cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
+ void AddUtility(std::string const& name, cmMakefile* mf = nullptr);
+ //! Get the utilities used by this target
+ std::set<BT<std::string>> const& GetUtilities() const;
- ///! Set/Get a property of this target file
+ //! Set/Get a property of this target file
void SetProperty(const std::string& prop, const char* value);
void AppendProperty(const std::string& prop, const char* value,
bool asString = false);
+ //! Might return a nullptr if the property is not set or invalid
const char* GetProperty(const std::string& prop) const;
+ //! Always returns a valid pointer
+ const char* GetSafeProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;
void CheckProperty(const std::string& prop, cmMakefile* context) const;
const char* GetComputedProperty(const std::string& prop,
cmMessenger* messenger,
cmListFileBacktrace const& context) const;
+ //! Get all properties
+ cmPropertyMap const& GetProperties() const;
- bool IsImported() const { return this->IsImportedTarget; }
- bool IsImportedGloballyVisible() const
- {
- return this->ImportedGloballyVisible;
- }
+ //! Return whether or not the target is for a DLL platform.
+ bool IsDLLPlatform() const;
- // Get the properties
- cmPropertyMap const& GetProperties() const { return this->Properties; }
+ //! Return whether or not we are targeting AIX.
+ bool IsAIX() const;
+
+ bool IsImported() const;
+ bool IsImportedGloballyVisible() const;
bool GetMappedConfig(std::string const& desired_config, const char** loc,
const char** imp, std::string& suffix) const;
- /** Return whether this target is an executable with symbol exports
- enabled. */
+ //! Return whether this target is an executable with symbol exports enabled.
bool IsExecutableWithExports() const;
- /** Return whether this target is a shared library Framework on
- Apple. */
+ //! Return whether this target is a shared library Framework on Apple.
bool IsFrameworkOnApple() const;
- /** Return whether this target is an executable Bundle on Apple. */
+ //! Return whether this target is an executable Bundle on Apple.
bool IsAppBundleOnApple() const;
- /** Get a backtrace from the creation of the target. */
+ //! Get a backtrace from the creation of the target.
cmListFileBacktrace const& GetBacktrace() const;
void InsertInclude(std::string const& entry, cmListFileBacktrace const& bt,
@@ -232,17 +208,20 @@ public:
cmListFileBacktrace const& bt, bool before = false);
void InsertCompileDefinition(std::string const& entry,
cmListFileBacktrace const& bt);
+ void InsertLinkOption(std::string const& entry,
+ cmListFileBacktrace const& bt, bool before = false);
+ void InsertLinkDirectory(std::string const& entry,
+ cmListFileBacktrace const& bt, bool before = false);
+ void InsertPrecompileHeader(std::string const& entry,
+ cmListFileBacktrace const& bt);
void AppendBuildInterfaceIncludes();
std::string GetDebugGeneratorExpressions(const std::string& value,
cmTargetLinkLibraryType llt) const;
- void AddSystemIncludeDirectories(const std::set<std::string>& incs);
- std::set<std::string> const& GetSystemIncludeDirectories() const
- {
- return this->SystemIncludeDirectories;
- }
+ void AddSystemIncludeDirectories(std::set<std::string> const& incs);
+ std::set<std::string> const& GetSystemIncludeDirectories() const;
cmStringRange GetIncludeDirectoriesEntries() const;
cmBacktraceRange GetIncludeDirectoriesBacktraces() const;
@@ -256,80 +235,40 @@ public:
cmStringRange GetCompileDefinitionsEntries() const;
cmBacktraceRange GetCompileDefinitionsBacktraces() const;
+ cmStringRange GetPrecompileHeadersEntries() const;
+ cmBacktraceRange GetPrecompileHeadersBacktraces() const;
+
cmStringRange GetSourceEntries() const;
cmBacktraceRange GetSourceBacktraces() const;
+
+ cmStringRange GetLinkOptionsEntries() const;
+ cmBacktraceRange GetLinkOptionsBacktraces() const;
+
+ cmStringRange GetLinkDirectoriesEntries() const;
+ cmBacktraceRange GetLinkDirectoriesBacktraces() const;
+
cmStringRange GetLinkImplementationEntries() const;
cmBacktraceRange GetLinkImplementationBacktraces() const;
+ std::string ImportedGetFullPath(const std::string& config,
+ cmStateEnums::ArtifactType artifact) const;
+
struct StrictTargetComparison
{
bool operator()(cmTarget const* t1, cmTarget const* t2) const;
};
- std::string ImportedGetFullPath(const std::string& config,
- cmStateEnums::ArtifactType artifact) const;
-
private:
+ // Internal representation details.
+ friend class cmGeneratorTarget;
+
const char* GetSuffixVariableInternal(
cmStateEnums::ArtifactType artifact) const;
const char* GetPrefixVariableInternal(
cmStateEnums::ArtifactType artifact) const;
- // Use a makefile variable to set a default for the given property.
- // If the variable is not defined use the given default instead.
- void SetPropertyDefault(const std::string& property,
- const char* default_value);
-
- bool CheckImportedLibName(std::string const& prop,
- std::string const& value) const;
-
private:
- cmPropertyMap Properties;
- std::set<std::string> SystemIncludeDirectories;
- std::set<std::string> LinkDirectoriesEmmitted;
- std::set<std::string> Utilities;
- std::map<std::string, cmListFileBacktrace> UtilityBacktraces;
- cmPolicies::PolicyMap PolicyMap;
- std::string Name;
- std::string InstallPath;
- std::string RuntimeInstallPath;
- std::vector<std::string> LinkDirectories;
- std::vector<cmCustomCommand> PreBuildCommands;
- std::vector<cmCustomCommand> PreLinkCommands;
- std::vector<cmCustomCommand> PostBuildCommands;
- std::vector<std::pair<TLLSignature, cmListFileContext> > TLLCommands;
- LinkLibraryVectorType OriginalLinkLibraries;
- cmMakefile* Makefile;
- cmTargetInternalPointer Internal;
- cmStateEnums::TargetType TargetTypeValue;
- bool HaveInstallRule;
- bool RecordDependencies;
- bool DLLPlatform;
- bool IsAndroid;
- bool IsImportedTarget;
- bool ImportedGloballyVisible;
- bool BuildInterfaceIncludesAppended;
-
- std::string ProcessSourceItemCMP0049(const std::string& s);
-
- /** Return whether or not the target has a DLL import library. */
- bool HasImportLibrary() const;
-
- // Internal representation details.
- friend class cmTargetInternals;
- friend class cmGeneratorTarget;
- friend class cmTargetTraceDependencies;
-
- cmListFileBacktrace Backtrace;
-};
-
-typedef CM_UNORDERED_MAP<std::string, cmTarget> cmTargets;
-
-class cmTargetSet : public std::set<std::string>
-{
-};
-class cmTargetManifest : public std::map<std::string, cmTargetSet>
-{
+ std::unique_ptr<cmTargetInternals> impl;
};
#endif
diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx
index 008d1a210..edee16700 100644
--- a/Source/cmTargetCompileDefinitionsCommand.cxx
+++ b/Source/cmTargetCompileDefinitionsCommand.cxx
@@ -2,60 +2,57 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetCompileDefinitionsCommand.h"
-#include <sstream>
-
-#include "cmAlgorithms.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
-#include "cmake.h"
-
-class cmExecutionStatus;
+#include "cmTargetPropCommandBase.h"
-bool cmTargetCompileDefinitionsCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
-{
- return this->HandleArguments(args, "COMPILE_DEFINITIONS");
-}
+namespace {
-void cmTargetCompileDefinitionsCommand::HandleImportedTarget(
- const std::string& tgt)
+class TargetCompileDefinitionsImpl : public cmTargetPropCommandBase
{
- std::ostringstream e;
- e << "Cannot specify compile definitions for imported target \"" << tgt
- << "\".";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-}
+public:
+ using cmTargetPropCommandBase::cmTargetPropCommandBase;
+
+private:
+ void HandleMissingTarget(const std::string& name) override
+ {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify compile definitions for target \"", name,
+ "\" which is not built by this project."));
+ }
-void cmTargetCompileDefinitionsCommand::HandleMissingTarget(
- const std::string& name)
-{
- std::ostringstream e;
- e << "Cannot specify compile definitions for target \"" << name
- << "\" "
- "which is not built by this project.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-}
+ bool HandleDirectContent(cmTarget* tgt,
+ const std::vector<std::string>& content,
+ bool /*prepend*/, bool /*system*/) override
+ {
+ tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str());
+ return true; // Successfully handled.
+ }
-std::string cmTargetCompileDefinitionsCommand::Join(
- const std::vector<std::string>& content)
-{
- std::string defs;
- std::string sep;
- for (std::vector<std::string>::const_iterator it = content.begin();
- it != content.end(); ++it) {
- if (cmHasLiteralPrefix(it->c_str(), "-D")) {
- defs += sep + it->substr(2);
- } else {
- defs += sep + *it;
+ std::string Join(const std::vector<std::string>& content) override
+ {
+ std::string defs;
+ std::string sep;
+ for (std::string const& it : content) {
+ if (cmHasLiteralPrefix(it, "-D")) {
+ defs += sep + it.substr(2);
+ } else {
+ defs += sep + it;
+ }
+ sep = ";";
}
- sep = ";";
+ return defs;
}
- return defs;
-}
+};
+
+} // namespace
-bool cmTargetCompileDefinitionsCommand::HandleDirectContent(
- cmTarget* tgt, const std::vector<std::string>& content, bool, bool)
+bool cmTargetCompileDefinitionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str());
- return true;
+ return TargetCompileDefinitionsImpl(status).HandleArguments(
+ args, "COMPILE_DEFINITIONS");
}
diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h
index 11abf571c..05ff092e8 100644
--- a/Source/cmTargetCompileDefinitionsCommand.h
+++ b/Source/cmTargetCompileDefinitionsCommand.h
@@ -3,43 +3,14 @@
#ifndef cmTargetCompileDefinitionsCommand_h
#define cmTargetCompileDefinitionsCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmTargetPropCommandBase.h"
-
-class cmCommand;
class cmExecutionStatus;
-class cmTarget;
-
-class cmTargetCompileDefinitionsCommand : public cmTargetPropCommandBase
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE
- {
- return new cmTargetCompileDefinitionsCommand;
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- void HandleImportedTarget(const std::string& tgt) CM_OVERRIDE;
- void HandleMissingTarget(const std::string& name) CM_OVERRIDE;
- bool HandleDirectContent(cmTarget* tgt,
- const std::vector<std::string>& content,
- bool prepend, bool system) CM_OVERRIDE;
- std::string Join(const std::vector<std::string>& content) CM_OVERRIDE;
-};
+bool cmTargetCompileDefinitionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx
index 1b6c00887..06be4f0dd 100644
--- a/Source/cmTargetCompileFeaturesCommand.cxx
+++ b/Source/cmTargetCompileFeaturesCommand.cxx
@@ -2,56 +2,54 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetCompileFeaturesCommand.h"
-#include <sstream>
-
-#include "cmAlgorithms.h"
#include "cmMakefile.h"
-#include "cmake.h"
+#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
+#include "cmTargetPropCommandBase.h"
-class cmExecutionStatus;
class cmTarget;
-bool cmTargetCompileFeaturesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
-{
- return this->HandleArguments(args, "COMPILE_FEATURES", NO_FLAGS);
-}
+namespace {
-void cmTargetCompileFeaturesCommand::HandleImportedTarget(
- const std::string& tgt)
+class TargetCompileFeaturesImpl : public cmTargetPropCommandBase
{
- std::ostringstream e;
- e << "Cannot specify compile features for imported target \"" << tgt
- << "\".";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-}
+public:
+ using cmTargetPropCommandBase::cmTargetPropCommandBase;
+
+private:
+ void HandleMissingTarget(const std::string& name) override
+ {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify compile features for target \"", name,
+ "\" which is not built by this project."));
+ }
-void cmTargetCompileFeaturesCommand::HandleMissingTarget(
- const std::string& name)
-{
- std::ostringstream e;
- e << "Cannot specify compile features for target \"" << name
- << "\" "
- "which is not built by this project.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-}
+ bool HandleDirectContent(cmTarget* tgt,
+ const std::vector<std::string>& content,
+ bool /*prepend*/, bool /*system*/) override
+ {
+ for (std::string const& it : content) {
+ std::string error;
+ if (!this->Makefile->AddRequiredTargetFeature(tgt, it, &error)) {
+ this->SetError(error);
+ return false; // Not (successfully) handled.
+ }
+ }
+ return true; // Successfully handled.
+ }
-std::string cmTargetCompileFeaturesCommand::Join(
- const std::vector<std::string>& content)
-{
- return cmJoin(content, ";");
-}
+ std::string Join(const std::vector<std::string>& content) override
+ {
+ return cmJoin(content, ";");
+ }
+};
-bool cmTargetCompileFeaturesCommand::HandleDirectContent(
- cmTarget* tgt, const std::vector<std::string>& content, bool, bool)
+} // namespace
+
+bool cmTargetCompileFeaturesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- for (std::vector<std::string>::const_iterator it = content.begin();
- it != content.end(); ++it) {
- std::string error;
- if (!this->Makefile->AddRequiredTargetFeature(tgt, *it, &error)) {
- this->SetError(error);
- return false;
- }
- }
- return true;
+ return TargetCompileFeaturesImpl(status).HandleArguments(args,
+ "COMPILE_FEATURES");
}
diff --git a/Source/cmTargetCompileFeaturesCommand.h b/Source/cmTargetCompileFeaturesCommand.h
index 990868004..db0c04b7e 100644
--- a/Source/cmTargetCompileFeaturesCommand.h
+++ b/Source/cmTargetCompileFeaturesCommand.h
@@ -3,32 +3,14 @@
#ifndef cmTargetCompileFeaturesCommand_h
#define cmTargetCompileFeaturesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmTargetPropCommandBase.h"
-
-class cmCommand;
class cmExecutionStatus;
-class cmTarget;
-
-class cmTargetCompileFeaturesCommand : public cmTargetPropCommandBase
-{
- cmCommand* Clone() CM_OVERRIDE { return new cmTargetCompileFeaturesCommand; }
-
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- void HandleImportedTarget(const std::string& tgt) CM_OVERRIDE;
- void HandleMissingTarget(const std::string& name) CM_OVERRIDE;
- bool HandleDirectContent(cmTarget* tgt,
- const std::vector<std::string>& content,
- bool prepend, bool system) CM_OVERRIDE;
- std::string Join(const std::vector<std::string>& content) CM_OVERRIDE;
-};
+bool cmTargetCompileFeaturesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx
index 1b4056d76..e39b72670 100644
--- a/Source/cmTargetCompileOptionsCommand.cxx
+++ b/Source/cmTargetCompileOptionsCommand.cxx
@@ -2,50 +2,49 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetCompileOptionsCommand.h"
-#include <sstream>
-
-#include "cmAlgorithms.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
-#include "cmake.h"
-
-class cmExecutionStatus;
-
-bool cmTargetCompileOptionsCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
-{
- return this->HandleArguments(args, "COMPILE_OPTIONS", PROCESS_BEFORE);
-}
-
-void cmTargetCompileOptionsCommand::HandleImportedTarget(
- const std::string& tgt)
-{
- std::ostringstream e;
- e << "Cannot specify compile options for imported target \"" << tgt << "\".";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-}
+#include "cmTargetPropCommandBase.h"
-void cmTargetCompileOptionsCommand::HandleMissingTarget(
- const std::string& name)
-{
- std::ostringstream e;
- e << "Cannot specify compile options for target \"" << name
- << "\" "
- "which is not built by this project.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-}
+namespace {
-std::string cmTargetCompileOptionsCommand::Join(
- const std::vector<std::string>& content)
+class TargetCompileOptionsImpl : public cmTargetPropCommandBase
{
- return cmJoin(content, ";");
-}
-
-bool cmTargetCompileOptionsCommand::HandleDirectContent(
- cmTarget* tgt, const std::vector<std::string>& content, bool, bool)
+public:
+ using cmTargetPropCommandBase::cmTargetPropCommandBase;
+
+private:
+ void HandleMissingTarget(const std::string& name) override
+ {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify compile options for target \"", name,
+ "\" which is not built by this project."));
+ }
+
+ bool HandleDirectContent(cmTarget* tgt,
+ const std::vector<std::string>& content,
+ bool /*prepend*/, bool /*system*/) override
+ {
+ cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+ tgt->InsertCompileOption(this->Join(content), lfbt);
+ return true; // Successfully handled.
+ }
+
+ std::string Join(const std::vector<std::string>& content) override
+ {
+ return cmJoin(content, ";");
+ }
+};
+
+} // namespace
+
+bool cmTargetCompileOptionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- tgt->InsertCompileOption(this->Join(content), lfbt);
- return true;
+ return TargetCompileOptionsImpl(status).HandleArguments(
+ args, "COMPILE_OPTIONS", TargetCompileOptionsImpl::PROCESS_BEFORE);
}
diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h
index b5408f7cb..3ab1a89c5 100644
--- a/Source/cmTargetCompileOptionsCommand.h
+++ b/Source/cmTargetCompileOptionsCommand.h
@@ -3,40 +3,14 @@
#ifndef cmTargetCompileOptionsCommand_h
#define cmTargetCompileOptionsCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmTargetPropCommandBase.h"
-
-class cmCommand;
class cmExecutionStatus;
-class cmTarget;
-
-class cmTargetCompileOptionsCommand : public cmTargetPropCommandBase
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmTargetCompileOptionsCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- void HandleImportedTarget(const std::string& tgt) CM_OVERRIDE;
- void HandleMissingTarget(const std::string& name) CM_OVERRIDE;
- bool HandleDirectContent(cmTarget* tgt,
- const std::vector<std::string>& content,
- bool prepend, bool system) CM_OVERRIDE;
- std::string Join(const std::vector<std::string>& content) CM_OVERRIDE;
-};
+bool cmTargetCompileOptionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmTargetDepend.h b/Source/cmTargetDepend.h
index daa902ecf..4ca78faa9 100644
--- a/Source/cmTargetDepend.h
+++ b/Source/cmTargetDepend.h
@@ -16,9 +16,10 @@ class cmTargetDepend
cmGeneratorTarget const* Target;
// The set order depends only on the Target, so we use
- // mutable members to acheive a map with set syntax.
+ // mutable members to achieve a map with set syntax.
mutable bool Link;
mutable bool Util;
+ mutable cmListFileBacktrace Backtrace;
public:
cmTargetDepend(cmGeneratorTarget const* t)
@@ -30,7 +31,7 @@ public:
operator cmGeneratorTarget const*() const { return this->Target; }
cmGeneratorTarget const* operator->() const { return this->Target; }
cmGeneratorTarget const& operator*() const { return *this->Target; }
- friend bool operator<(cmTargetDepend l, cmTargetDepend r)
+ friend bool operator<(cmTargetDepend const& l, cmTargetDepend const& r)
{
return l.Target < r.Target;
}
@@ -42,8 +43,13 @@ public:
this->Link = true;
}
}
+ void SetBacktrace(cmListFileBacktrace const& bt) const
+ {
+ this->Backtrace = bt;
+ }
bool IsLink() const { return this->Link; }
bool IsUtil() const { return this->Util; }
+ cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
};
/** Unordered set of (direct) dependencies of a target. */
diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx
index 65a31490f..95b69f399 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.cxx
+++ b/Source/cmTargetIncludeDirectoriesCommand.cxx
@@ -3,97 +3,104 @@
#include "cmTargetIncludeDirectoriesCommand.h"
#include <set>
-#include <sstream>
#include "cmGeneratorExpression.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cmake.h"
+#include "cmTargetPropCommandBase.h"
-class cmExecutionStatus;
+namespace {
-bool cmTargetIncludeDirectoriesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+class TargetIncludeDirectoriesImpl : public cmTargetPropCommandBase
{
- return this->HandleArguments(args, "INCLUDE_DIRECTORIES",
- ArgumentFlags(PROCESS_BEFORE | PROCESS_SYSTEM));
-}
+public:
+ using cmTargetPropCommandBase::cmTargetPropCommandBase;
-void cmTargetIncludeDirectoriesCommand::HandleImportedTarget(
- const std::string& tgt)
-{
- std::ostringstream e;
- e << "Cannot specify include directories for imported target \"" << tgt
- << "\".";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-}
+private:
+ void HandleMissingTarget(const std::string& name) override
+ {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify include directories for target \"", name,
+ "\" which is not built by this project."));
+ }
-void cmTargetIncludeDirectoriesCommand::HandleMissingTarget(
- const std::string& name)
-{
- std::ostringstream e;
- e << "Cannot specify include directories for target \"" << name
- << "\" "
- "which is not built by this project.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-}
+ bool HandleDirectContent(cmTarget* tgt,
+ const std::vector<std::string>& content,
+ bool prepend, bool system) override;
+
+ void HandleInterfaceContent(cmTarget* tgt,
+ const std::vector<std::string>& content,
+ bool prepend, bool system) override;
-std::string cmTargetIncludeDirectoriesCommand::Join(
+ std::string Join(const std::vector<std::string>& content) override;
+};
+
+std::string TargetIncludeDirectoriesImpl::Join(
const std::vector<std::string>& content)
{
std::string dirs;
std::string sep;
- std::string prefix =
- this->Makefile->GetCurrentSourceDirectory() + std::string("/");
- for (std::vector<std::string>::const_iterator it = content.begin();
- it != content.end(); ++it) {
- if (cmSystemTools::FileIsFullPath(it->c_str()) ||
- cmGeneratorExpression::Find(*it) == 0) {
- dirs += sep + *it;
+ std::string prefix = this->Makefile->GetCurrentSourceDirectory() + "/";
+ for (std::string const& it : content) {
+ if (cmSystemTools::FileIsFullPath(it) ||
+ cmGeneratorExpression::Find(it) == 0) {
+ dirs += cmStrCat(sep, it);
} else {
- dirs += sep + prefix + *it;
+ dirs += cmStrCat(sep, prefix, it);
}
sep = ";";
}
return dirs;
}
-bool cmTargetIncludeDirectoriesCommand::HandleDirectContent(
+bool TargetIncludeDirectoriesImpl::HandleDirectContent(
cmTarget* tgt, const std::vector<std::string>& content, bool prepend,
bool system)
{
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
tgt->InsertInclude(this->Join(content), lfbt, prepend);
if (system) {
- std::string prefix =
- this->Makefile->GetCurrentSourceDirectory() + std::string("/");
+ std::string prefix = this->Makefile->GetCurrentSourceDirectory() + "/";
std::set<std::string> sdirs;
- for (std::vector<std::string>::const_iterator it = content.begin();
- it != content.end(); ++it) {
- if (cmSystemTools::FileIsFullPath(it->c_str()) ||
- cmGeneratorExpression::Find(*it) == 0) {
- sdirs.insert(*it);
+ for (std::string const& it : content) {
+ if (cmSystemTools::FileIsFullPath(it) ||
+ cmGeneratorExpression::Find(it) == 0) {
+ sdirs.insert(it);
} else {
- sdirs.insert(prefix + *it);
+ sdirs.insert(prefix + it);
}
}
tgt->AddSystemIncludeDirectories(sdirs);
}
- return true;
+ return true; // Successfully handled.
}
-void cmTargetIncludeDirectoriesCommand::HandleInterfaceContent(
+void TargetIncludeDirectoriesImpl::HandleInterfaceContent(
cmTarget* tgt, const std::vector<std::string>& content, bool prepend,
bool system)
{
cmTargetPropCommandBase::HandleInterfaceContent(tgt, content, prepend,
system);
-
if (system) {
std::string joined = this->Join(content);
tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
joined.c_str());
}
}
+
+} // namespace
+
+bool cmTargetIncludeDirectoriesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return TargetIncludeDirectoriesImpl(status).HandleArguments(
+ args, "INCLUDE_DIRECTORIES",
+ TargetIncludeDirectoriesImpl::ArgumentFlags(
+ TargetIncludeDirectoriesImpl::PROCESS_BEFORE |
+ TargetIncludeDirectoriesImpl::PROCESS_SYSTEM));
+}
diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h
index 374a867dc..9958f419a 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.h
+++ b/Source/cmTargetIncludeDirectoriesCommand.h
@@ -3,47 +3,14 @@
#ifndef cmTargetIncludeDirectoriesCommand_h
#define cmTargetIncludeDirectoriesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmTargetPropCommandBase.h"
-
-class cmCommand;
class cmExecutionStatus;
-class cmTarget;
-
-class cmTargetIncludeDirectoriesCommand : public cmTargetPropCommandBase
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE
- {
- return new cmTargetIncludeDirectoriesCommand;
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- void HandleImportedTarget(const std::string& tgt) CM_OVERRIDE;
- void HandleMissingTarget(const std::string& name) CM_OVERRIDE;
-
- bool HandleDirectContent(cmTarget* tgt,
- const std::vector<std::string>& content,
- bool prepend, bool system) CM_OVERRIDE;
- void HandleInterfaceContent(cmTarget* tgt,
- const std::vector<std::string>& content,
- bool prepend, bool system) CM_OVERRIDE;
- std::string Join(const std::vector<std::string>& content) CM_OVERRIDE;
-};
+bool cmTargetIncludeDirectoriesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmTargetLinkDirectoriesCommand.cxx b/Source/cmTargetLinkDirectoriesCommand.cxx
new file mode 100644
index 000000000..0c68d604c
--- /dev/null
+++ b/Source/cmTargetLinkDirectoriesCommand.cxx
@@ -0,0 +1,70 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmTargetLinkDirectoriesCommand.h"
+
+#include "cmGeneratorExpression.h"
+#include "cmListFileCache.h"
+#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmTarget.h"
+#include "cmTargetPropCommandBase.h"
+
+namespace {
+
+class TargetLinkDirectoriesImpl : public cmTargetPropCommandBase
+{
+public:
+ using cmTargetPropCommandBase::cmTargetPropCommandBase;
+
+private:
+ void HandleMissingTarget(const std::string& name) override
+ {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify link directories for target \"", name,
+ "\" which is not built by this project."));
+ }
+
+ std::string Join(const std::vector<std::string>& content) override;
+
+ bool HandleDirectContent(cmTarget* tgt,
+ const std::vector<std::string>& content,
+ bool prepend, bool /*system*/) override
+ {
+ cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+ tgt->InsertLinkDirectory(this->Join(content), lfbt, prepend);
+ return true; // Successfully handled.
+ }
+};
+
+std::string TargetLinkDirectoriesImpl::Join(
+ const std::vector<std::string>& content)
+{
+ std::vector<std::string> directories;
+
+ for (const auto& dir : content) {
+ auto unixPath = dir;
+ cmSystemTools::ConvertToUnixSlashes(unixPath);
+ if (!cmSystemTools::FileIsFullPath(unixPath) &&
+ !cmGeneratorExpression::StartsWithGeneratorExpression(unixPath)) {
+ auto tmp = this->Makefile->GetCurrentSourceDirectory();
+ tmp += "/";
+ tmp += unixPath;
+ unixPath = tmp;
+ }
+ directories.push_back(unixPath);
+ }
+
+ return cmJoin(directories, ";");
+}
+
+} // namespace
+
+bool cmTargetLinkDirectoriesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return TargetLinkDirectoriesImpl(status).HandleArguments(
+ args, "LINK_DIRECTORIES", TargetLinkDirectoriesImpl::PROCESS_BEFORE);
+}
diff --git a/Source/cmTargetLinkDirectoriesCommand.h b/Source/cmTargetLinkDirectoriesCommand.h
new file mode 100644
index 000000000..3724d6cf8
--- /dev/null
+++ b/Source/cmTargetLinkDirectoriesCommand.h
@@ -0,0 +1,16 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmTargetLinkDirectoriesCommand_h
+#define cmTargetLinkDirectoriesCommand_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+#include <vector>
+
+class cmExecutionStatus;
+
+bool cmTargetLinkDirectoriesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+
+#endif
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index e17303645..0d2383a1c 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -2,54 +2,88 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetLinkLibrariesCommand.h"
+#include <cstring>
#include <sstream>
-#include <string.h>
+#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
+#include "cmTargetLinkLibraryType.h"
#include "cmake.h"
-class cmExecutionStatus;
+namespace {
-const char* cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[3] = {
- "general", "debug", "optimized"
+enum ProcessingState
+{
+ ProcessingLinkLibraries,
+ ProcessingPlainLinkInterface,
+ ProcessingKeywordLinkInterface,
+ ProcessingPlainPublicInterface,
+ ProcessingKeywordPublicInterface,
+ ProcessingPlainPrivateInterface,
+ ProcessingKeywordPrivateInterface
};
-// cmTargetLinkLibrariesCommand
-bool cmTargetLinkLibrariesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+const char* LinkLibraryTypeNames[3] = { "general", "debug", "optimized" };
+
+} // namespace
+
+static void LinkLibraryTypeSpecifierWarning(cmMakefile& mf, int left,
+ int right);
+
+static bool HandleLibrary(cmMakefile& mf, cmTarget* target,
+ ProcessingState currentProcessingState,
+ const std::string& lib, cmTargetLinkLibraryType llt);
+
+bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- // must have one argument
+ // Must have at least one argument.
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- if (this->Makefile->IsAlias(args[0])) {
- this->SetError("can not be used on an ALIAS target.");
+ cmMakefile& mf = status.GetMakefile();
+
+ // Alias targets cannot be on the LHS of this command.
+ if (mf.IsAlias(args[0])) {
+ status.SetError("can not be used on an ALIAS target.");
return false;
}
+
// Lookup the target for which libraries are specified.
- this->Target =
- this->Makefile->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(
- args[0]);
- if (!this->Target) {
- cmake::MessageType t = cmake::FATAL_ERROR; // fail by default
+ cmTarget* target =
+ mf.GetCMakeInstance()->GetGlobalGenerator()->FindTarget(args[0]);
+ if (!target) {
+ const std::vector<cmTarget*>& importedTargets =
+ mf.GetOwnedImportedTargets();
+ for (cmTarget* importedTarget : importedTargets) {
+ if (importedTarget->GetName() == args[0]) {
+ target = importedTarget;
+ break;
+ }
+ }
+ }
+ if (!target) {
+ MessageType t = MessageType::FATAL_ERROR; // fail by default
std::ostringstream e;
e << "Cannot specify link libraries for target \"" << args[0] << "\" "
<< "which is not built by this project.";
// The bad target is the only argument. Check how policy CMP0016 is set,
// and accept, warn or fail respectively:
if (args.size() < 2) {
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0016)) {
+ switch (mf.GetPolicyStatus(cmPolicies::CMP0016)) {
case cmPolicies::WARN:
- t = cmake::AUTHOR_WARNING;
+ t = MessageType::AUTHOR_WARNING;
// Print the warning.
e << "\n"
<< "CMake does not support this but it used to work accidentally "
@@ -58,7 +92,7 @@ bool cmTargetLinkLibrariesCommand::InitialPass(
<< cmPolicies::GetPolicyWarning(cmPolicies::CMP0016);
break;
case cmPolicies::OLD: // OLD behavior does not warn.
- t = cmake::MESSAGE;
+ t = MessageType::MESSAGE;
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
@@ -68,14 +102,13 @@ bool cmTargetLinkLibrariesCommand::InitialPass(
break;
}
}
-
- // now actually print the message
+ // Now actually print the message.
switch (t) {
- case cmake::AUTHOR_WARNING:
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ case MessageType::AUTHOR_WARNING:
+ mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
break;
- case cmake::FATAL_ERROR:
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ case MessageType::FATAL_ERROR:
+ mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
cmSystemTools::SetFatalErrorOccured();
break;
default:
@@ -84,20 +117,12 @@ bool cmTargetLinkLibrariesCommand::InitialPass(
return true;
}
- if (this->Target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
+ // Having a UTILITY library on the LHS is a bug.
+ if (target->GetType() == cmStateEnums::UTILITY) {
std::ostringstream e;
- e << "Object library target \"" << args[0] << "\" "
- << "may not link to anything.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
- cmSystemTools::SetFatalErrorOccured();
- return true;
- }
-
- if (this->Target->GetType() == cmStateEnums::UTILITY) {
- std::ostringstream e;
- const char* modal = CM_NULLPTR;
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0039)) {
+ const char* modal = nullptr;
+ MessageType messageType = MessageType::AUTHOR_WARNING;
+ switch (mf.GetPolicyStatus(cmPolicies::CMP0039)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0039) << "\n";
modal = "should";
@@ -107,19 +132,19 @@ bool cmTargetLinkLibrariesCommand::InitialPass(
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::NEW:
modal = "must";
- messageType = cmake::FATAL_ERROR;
+ messageType = MessageType::FATAL_ERROR;
}
if (modal) {
- e << "Utility target \"" << this->Target->GetName() << "\" " << modal
+ e << "Utility target \"" << target->GetName() << "\" " << modal
<< " not be used as the target of a target_link_libraries call.";
- this->Makefile->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR) {
+ mf.IssueMessage(messageType, e.str());
+ if (messageType == MessageType::FATAL_ERROR) {
return false;
}
}
}
- // but we might not have any libs after variable expansion
+ // But we might not have any libs after variable expansion.
if (args.size() < 2) {
return true;
}
@@ -130,112 +155,111 @@ bool cmTargetLinkLibrariesCommand::InitialPass(
// Start with primary linking and switch to link interface
// specification if the keyword is encountered as the first argument.
- this->CurrentProcessingState = ProcessingLinkLibraries;
+ ProcessingState currentProcessingState = ProcessingLinkLibraries;
- // add libraries, note that there is an optional prefix
- // of debug and optimized that can be used
+ // Add libraries, note that there is an optional prefix
+ // of debug and optimized that can be used.
for (unsigned int i = 1; i < args.size(); ++i) {
if (args[i] == "LINK_INTERFACE_LIBRARIES") {
- this->CurrentProcessingState = ProcessingPlainLinkInterface;
+ currentProcessingState = ProcessingPlainLinkInterface;
if (i != 1) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
"The LINK_INTERFACE_LIBRARIES option must appear as the second "
"argument, just after the target name.");
return true;
}
} else if (args[i] == "INTERFACE") {
if (i != 1 &&
- this->CurrentProcessingState != ProcessingKeywordPrivateInterface &&
- this->CurrentProcessingState != ProcessingKeywordPublicInterface &&
- this->CurrentProcessingState != ProcessingKeywordLinkInterface) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR, "The INTERFACE option must appear as the second "
- "argument, just after the target name.");
+ currentProcessingState != ProcessingKeywordPrivateInterface &&
+ currentProcessingState != ProcessingKeywordPublicInterface &&
+ currentProcessingState != ProcessingKeywordLinkInterface) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ "The INTERFACE, PUBLIC or PRIVATE option must appear as the second "
+ "argument, just after the target name.");
return true;
}
- this->CurrentProcessingState = ProcessingKeywordLinkInterface;
+ currentProcessingState = ProcessingKeywordLinkInterface;
} else if (args[i] == "LINK_PUBLIC") {
if (i != 1 &&
- this->CurrentProcessingState != ProcessingPlainPrivateInterface &&
- this->CurrentProcessingState != ProcessingPlainPublicInterface) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ currentProcessingState != ProcessingPlainPrivateInterface &&
+ currentProcessingState != ProcessingPlainPublicInterface) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
"The LINK_PUBLIC or LINK_PRIVATE option must appear as the second "
"argument, just after the target name.");
return true;
}
- this->CurrentProcessingState = ProcessingPlainPublicInterface;
+ currentProcessingState = ProcessingPlainPublicInterface;
} else if (args[i] == "PUBLIC") {
if (i != 1 &&
- this->CurrentProcessingState != ProcessingKeywordPrivateInterface &&
- this->CurrentProcessingState != ProcessingKeywordPublicInterface &&
- this->CurrentProcessingState != ProcessingKeywordLinkInterface) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
- "The PUBLIC or PRIVATE option must appear as the second "
+ currentProcessingState != ProcessingKeywordPrivateInterface &&
+ currentProcessingState != ProcessingKeywordPublicInterface &&
+ currentProcessingState != ProcessingKeywordLinkInterface) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ "The INTERFACE, PUBLIC or PRIVATE option must appear as the second "
"argument, just after the target name.");
return true;
}
- this->CurrentProcessingState = ProcessingKeywordPublicInterface;
+ currentProcessingState = ProcessingKeywordPublicInterface;
} else if (args[i] == "LINK_PRIVATE") {
- if (i != 1 &&
- this->CurrentProcessingState != ProcessingPlainPublicInterface &&
- this->CurrentProcessingState != ProcessingPlainPrivateInterface) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ if (i != 1 && currentProcessingState != ProcessingPlainPublicInterface &&
+ currentProcessingState != ProcessingPlainPrivateInterface) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
"The LINK_PUBLIC or LINK_PRIVATE option must appear as the second "
"argument, just after the target name.");
return true;
}
- this->CurrentProcessingState = ProcessingPlainPrivateInterface;
+ currentProcessingState = ProcessingPlainPrivateInterface;
} else if (args[i] == "PRIVATE") {
if (i != 1 &&
- this->CurrentProcessingState != ProcessingKeywordPrivateInterface &&
- this->CurrentProcessingState != ProcessingKeywordPublicInterface &&
- this->CurrentProcessingState != ProcessingKeywordLinkInterface) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
- "The PUBLIC or PRIVATE option must appear as the second "
+ currentProcessingState != ProcessingKeywordPrivateInterface &&
+ currentProcessingState != ProcessingKeywordPublicInterface &&
+ currentProcessingState != ProcessingKeywordLinkInterface) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ "The INTERFACE, PUBLIC or PRIVATE option must appear as the second "
"argument, just after the target name.");
return true;
}
- this->CurrentProcessingState = ProcessingKeywordPrivateInterface;
+ currentProcessingState = ProcessingKeywordPrivateInterface;
} else if (args[i] == "debug") {
if (haveLLT) {
- this->LinkLibraryTypeSpecifierWarning(llt, DEBUG_LibraryType);
+ LinkLibraryTypeSpecifierWarning(mf, llt, DEBUG_LibraryType);
}
llt = DEBUG_LibraryType;
haveLLT = true;
} else if (args[i] == "optimized") {
if (haveLLT) {
- this->LinkLibraryTypeSpecifierWarning(llt, OPTIMIZED_LibraryType);
+ LinkLibraryTypeSpecifierWarning(mf, llt, OPTIMIZED_LibraryType);
}
llt = OPTIMIZED_LibraryType;
haveLLT = true;
} else if (args[i] == "general") {
if (haveLLT) {
- this->LinkLibraryTypeSpecifierWarning(llt, GENERAL_LibraryType);
+ LinkLibraryTypeSpecifierWarning(mf, llt, GENERAL_LibraryType);
}
llt = GENERAL_LibraryType;
haveLLT = true;
} else if (haveLLT) {
// The link type was specified by the previous argument.
haveLLT = false;
- if (!this->HandleLibrary(args[i], llt)) {
+ if (!HandleLibrary(mf, target, currentProcessingState, args[i], llt)) {
return false;
}
} else {
// Lookup old-style cache entry if type is unspecified. So if you
// do a target_link_libraries(foo optimized bar) it will stay optimized
- // and not use the lookup. As there maybe the case where someone has
- // specifed that a library is both debug and optimized. (this check is
+ // and not use the lookup. As there may be the case where someone has
+ // specified that a library is both debug and optimized. (this check is
// only there for backwards compatibility when mixing projects built
// with old versions of CMake and new)
llt = GENERAL_LibraryType;
- std::string linkType = args[0];
- linkType += "_LINK_TYPE";
- const char* linkTypeString = this->Makefile->GetDefinition(linkType);
+ std::string linkType = cmStrCat(args[0], "_LINK_TYPE");
+ const char* linkTypeString = mf.GetDefinition(linkType);
if (linkTypeString) {
if (strcmp(linkTypeString, "debug") == 0) {
llt = DEBUG_LibraryType;
@@ -244,7 +268,7 @@ bool cmTargetLinkLibrariesCommand::InitialPass(
llt = OPTIMIZED_LibraryType;
}
}
- if (!this->HandleLibrary(args[i], llt)) {
+ if (!HandleLibrary(mf, target, currentProcessingState, args[i], llt)) {
return false;
}
}
@@ -252,15 +276,14 @@ bool cmTargetLinkLibrariesCommand::InitialPass(
// Make sure the last argument was not a library type specifier.
if (haveLLT) {
- std::ostringstream e;
- e << "The \"" << this->LinkLibraryTypeNames[llt]
- << "\" argument must be followed by a library.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ mf.IssueMessage(MessageType::FATAL_ERROR,
+ cmStrCat("The \"", LinkLibraryTypeNames[llt],
+ "\" argument must be followed by a library."));
cmSystemTools::SetFatalErrorOccured();
}
const cmPolicies::PolicyStatus policy22Status =
- this->Target->GetPolicyStatusCMP0022();
+ target->GetPolicyStatusCMP0022();
// If any of the LINK_ options were given, make sure the
// LINK_INTERFACE_LIBRARIES target property exists.
@@ -269,51 +292,59 @@ bool cmTargetLinkLibrariesCommand::InitialPass(
// result in an empty link interface.
if ((policy22Status == cmPolicies::OLD ||
policy22Status == cmPolicies::WARN) &&
- this->CurrentProcessingState != ProcessingLinkLibraries &&
- !this->Target->GetProperty("LINK_INTERFACE_LIBRARIES")) {
- this->Target->SetProperty("LINK_INTERFACE_LIBRARIES", "");
+ currentProcessingState != ProcessingLinkLibraries &&
+ !target->GetProperty("LINK_INTERFACE_LIBRARIES")) {
+ target->SetProperty("LINK_INTERFACE_LIBRARIES", "");
}
return true;
}
-void cmTargetLinkLibrariesCommand::LinkLibraryTypeSpecifierWarning(int left,
- int right)
+static void LinkLibraryTypeSpecifierWarning(cmMakefile& mf, int left,
+ int right)
{
- std::ostringstream w;
- w << "Link library type specifier \"" << this->LinkLibraryTypeNames[left]
- << "\" is followed by specifier \"" << this->LinkLibraryTypeNames[right]
- << "\" instead of a library name. "
- << "The first specifier will be ignored.";
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ mf.IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(
+ "Link library type specifier \"", LinkLibraryTypeNames[left],
+ "\" is followed by specifier \"", LinkLibraryTypeNames[right],
+ "\" instead of a library name. The first specifier will be ignored."));
}
-bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
- cmTargetLinkLibraryType llt)
+static bool HandleLibrary(cmMakefile& mf, cmTarget* target,
+ ProcessingState currentProcessingState,
+ const std::string& lib, cmTargetLinkLibraryType llt)
{
- if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY &&
- this->CurrentProcessingState != ProcessingKeywordLinkInterface) {
- this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY &&
+ currentProcessingState != ProcessingKeywordLinkInterface) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
"INTERFACE library can only be used with the INTERFACE keyword of "
"target_link_libraries");
return false;
}
+ if (target->IsImported() &&
+ currentProcessingState != ProcessingKeywordLinkInterface) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ "IMPORTED library can only be used with the INTERFACE keyword of "
+ "target_link_libraries");
+ return false;
+ }
cmTarget::TLLSignature sig =
- (this->CurrentProcessingState == ProcessingPlainPrivateInterface ||
- this->CurrentProcessingState == ProcessingPlainPublicInterface ||
- this->CurrentProcessingState == ProcessingKeywordPrivateInterface ||
- this->CurrentProcessingState == ProcessingKeywordPublicInterface ||
- this->CurrentProcessingState == ProcessingKeywordLinkInterface)
+ (currentProcessingState == ProcessingPlainPrivateInterface ||
+ currentProcessingState == ProcessingPlainPublicInterface ||
+ currentProcessingState == ProcessingKeywordPrivateInterface ||
+ currentProcessingState == ProcessingKeywordPublicInterface ||
+ currentProcessingState == ProcessingKeywordLinkInterface)
? cmTarget::KeywordTLLSignature
: cmTarget::PlainTLLSignature;
- if (!this->Target->PushTLLCommandTrace(
- sig, this->Makefile->GetExecutionContext())) {
+ if (!target->PushTLLCommandTrace(sig, mf.GetExecutionContext())) {
std::ostringstream e;
- const char* modal = CM_NULLPTR;
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0023)) {
+ const char* modal = nullptr;
+ MessageType messageType = MessageType::AUTHOR_WARNING;
+ switch (mf.GetPolicyStatus(cmPolicies::CMP0023)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0023) << "\n";
modal = "should";
@@ -323,7 +354,7 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::NEW:
modal = "must";
- messageType = cmake::FATAL_ERROR;
+ messageType = MessageType::FATAL_ERROR;
}
if (modal) {
@@ -331,122 +362,180 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
// form must be the plain form.
const char* existingSig =
(sig == cmTarget::KeywordTLLSignature ? "plain" : "keyword");
- e << "The " << existingSig << " signature for target_link_libraries "
- "has already been used with the target \""
- << this->Target->GetName() << "\". All uses of "
- "target_link_libraries with a target "
- << modal << " be either "
- "all-keyword or all-plain.\n";
- this->Target->GetTllSignatureTraces(e,
- sig == cmTarget::KeywordTLLSignature
- ? cmTarget::PlainTLLSignature
- : cmTarget::KeywordTLLSignature);
- this->Makefile->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR) {
+ e << "The " << existingSig
+ << " signature for target_link_libraries has "
+ "already been used with the target \""
+ << target->GetName()
+ << "\". All uses of target_link_libraries with a target " << modal
+ << " be either all-keyword or all-plain.\n";
+ target->GetTllSignatureTraces(e,
+ sig == cmTarget::KeywordTLLSignature
+ ? cmTarget::PlainTLLSignature
+ : cmTarget::KeywordTLLSignature);
+ mf.IssueMessage(messageType, e.str());
+ if (messageType == MessageType::FATAL_ERROR) {
return false;
}
}
}
- // Handle normal case first.
- if (this->CurrentProcessingState != ProcessingKeywordLinkInterface &&
- this->CurrentProcessingState != ProcessingPlainLinkInterface) {
-
- cmTarget* t =
- this->Makefile->FindLocalNonAliasTarget(this->Target->GetName());
- if (!t) {
- std::ostringstream e;
- e << "Attempt to add link library \"" << lib << "\" to target \""
- << this->Target->GetName()
- << "\" which is not built in this directory.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
- } else {
+ bool warnRemoteInterface = false;
+ bool rejectRemoteLinking = false;
+ bool encodeRemoteReference = false;
+ if (&mf != target->GetMakefile()) {
+ // The LHS target was created in another directory.
+ switch (mf.GetPolicyStatus(cmPolicies::CMP0079)) {
+ case cmPolicies::WARN:
+ warnRemoteInterface = true;
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ rejectRemoteLinking = true;
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ encodeRemoteReference = true;
+ break;
+ }
+ }
- cmTarget* tgt = this->Makefile->GetGlobalGenerator()->FindTarget(lib);
-
- if (tgt && (tgt->GetType() != cmStateEnums::STATIC_LIBRARY) &&
- (tgt->GetType() != cmStateEnums::SHARED_LIBRARY) &&
- (tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
- !tgt->IsExecutableWithExports()) {
- std::ostringstream e;
- e << "Target \"" << lib << "\" of type "
- << cmState::GetTargetTypeName(tgt->GetType())
- << " may not be linked into another target. "
- << "One may link only to STATIC or SHARED libraries, or "
- << "to executables with the ENABLE_EXPORTS property set.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
- }
+ std::string libRef;
+ if (encodeRemoteReference && !cmSystemTools::FileIsFullPath(lib)) {
+ // This is a library name added by a caller that is not in the
+ // same directory as the target was created. Add a suffix to
+ // the name to tell ResolveLinkItem to look up the name in the
+ // caller's directory.
+ cmDirectoryId const dirId = mf.GetDirectoryId();
+ libRef = lib + CMAKE_DIRECTORY_ID_SEP + dirId.String;
+ } else {
+ // This is an absolute path or a library name added by a caller
+ // in the same directory as the target was created. We can use
+ // the original name directly.
+ libRef = lib;
+ }
- this->Target->AddLinkLibrary(*this->Makefile, lib, llt);
+ // Handle normal case where the command was called with another keyword than
+ // INTERFACE / LINK_INTERFACE_LIBRARIES or none at all. (The "LINK_LIBRARIES"
+ // property of the target on the LHS shall be populated.)
+ if (currentProcessingState != ProcessingKeywordLinkInterface &&
+ currentProcessingState != ProcessingPlainLinkInterface) {
+
+ if (rejectRemoteLinking) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Attempt to add link library \"", lib, "\" to target \"",
+ target->GetName(),
+ "\" which is not built in this "
+ "directory.\nThis is allowed only when policy CMP0079 "
+ "is set to NEW."));
+ return false;
}
- if (this->CurrentProcessingState == ProcessingLinkLibraries) {
- this->Target->AppendProperty(
- "INTERFACE_LINK_LIBRARIES",
- this->Target->GetDebugGeneratorExpressions(lib, llt).c_str());
- return true;
+ cmTarget* tgt = mf.GetGlobalGenerator()->FindTarget(lib);
+
+ if (tgt && (tgt->GetType() != cmStateEnums::STATIC_LIBRARY) &&
+ (tgt->GetType() != cmStateEnums::SHARED_LIBRARY) &&
+ (tgt->GetType() != cmStateEnums::UNKNOWN_LIBRARY) &&
+ (tgt->GetType() != cmStateEnums::OBJECT_LIBRARY) &&
+ (tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
+ !tgt->IsExecutableWithExports()) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ "Target \"", lib, "\" of type ",
+ cmState::GetTargetTypeName(tgt->GetType()),
+ " may not be linked into another target. One may link only to "
+ "INTERFACE, OBJECT, STATIC or SHARED libraries, or to ",
+ "executables with the ENABLE_EXPORTS property set."));
}
- if (this->CurrentProcessingState != ProcessingKeywordPublicInterface &&
- this->CurrentProcessingState != ProcessingPlainPublicInterface) {
- if (this->Target->GetType() == cmStateEnums::STATIC_LIBRARY) {
- std::string configLib =
- this->Target->GetDebugGeneratorExpressions(lib, llt);
- if (cmGeneratorExpression::IsValidTargetName(lib) ||
- cmGeneratorExpression::Find(lib) != std::string::npos) {
- configLib = "$<LINK_ONLY:" + configLib + ">";
- }
- this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES",
- configLib.c_str());
+
+ target->AddLinkLibrary(mf, lib, libRef, llt);
+ }
+
+ if (warnRemoteInterface) {
+ mf.IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0079), "\nTarget\n ",
+ target->GetName(),
+ "\nis not created in this "
+ "directory. For compatibility with older versions of CMake, link "
+ "library\n ",
+ lib,
+ "\nwill be looked up in the directory in which "
+ "the target was created rather than in this calling directory."));
+ }
+
+ // Handle (additional) case where the command was called with PRIVATE /
+ // LINK_PRIVATE and stop its processing. (The "INTERFACE_LINK_LIBRARIES"
+ // property of the target on the LHS shall only be populated if it is a
+ // STATIC library.)
+ if (currentProcessingState == ProcessingKeywordPrivateInterface ||
+ currentProcessingState == ProcessingPlainPrivateInterface) {
+ if (target->GetType() == cmStateEnums::STATIC_LIBRARY ||
+ target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
+ std::string configLib =
+ target->GetDebugGeneratorExpressions(libRef, llt);
+ if (cmGeneratorExpression::IsValidTargetName(lib) ||
+ cmGeneratorExpression::Find(lib) != std::string::npos) {
+ configLib = "$<LINK_ONLY:" + configLib + ">";
}
- // Not a 'public' or 'interface' library. Do not add to interface
- // property.
- return true;
+ target->AppendProperty("INTERFACE_LINK_LIBRARIES", configLib.c_str());
}
+ return true;
}
- this->Target->AppendProperty(
+ // Handle general case where the command was called with another keyword than
+ // PRIVATE / LINK_PRIVATE or none at all. (The "INTERFACE_LINK_LIBRARIES"
+ // property of the target on the LHS shall be populated.)
+ target->AppendProperty(
"INTERFACE_LINK_LIBRARIES",
- this->Target->GetDebugGeneratorExpressions(lib, llt).c_str());
+ target->GetDebugGeneratorExpressions(libRef, llt).c_str());
+ // Stop processing if called without any keyword.
+ if (currentProcessingState == ProcessingLinkLibraries) {
+ return true;
+ }
+ // Stop processing if policy CMP0022 is set to NEW.
const cmPolicies::PolicyStatus policy22Status =
- this->Target->GetPolicyStatusCMP0022();
-
+ target->GetPolicyStatusCMP0022();
if (policy22Status != cmPolicies::OLD &&
policy22Status != cmPolicies::WARN) {
return true;
}
-
- if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ // Stop processing if called with an INTERFACE library on the LHS.
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
return true;
}
- // Get the list of configurations considered to be DEBUG.
- std::vector<std::string> debugConfigs =
- this->Makefile->GetCMakeInstance()->GetDebugConfigs();
- std::string prop;
-
- // Include this library in the link interface for the target.
- if (llt == DEBUG_LibraryType || llt == GENERAL_LibraryType) {
- // Put in the DEBUG configuration interfaces.
- for (std::vector<std::string>::const_iterator i = debugConfigs.begin();
- i != debugConfigs.end(); ++i) {
- prop = "LINK_INTERFACE_LIBRARIES_";
- prop += *i;
- this->Target->AppendProperty(prop, lib.c_str());
+ // Handle (additional) backward-compatibility case where the command was
+ // called with PUBLIC / INTERFACE / LINK_PUBLIC / LINK_INTERFACE_LIBRARIES.
+ // (The policy CMP0022 is not set to NEW.)
+ {
+ // Get the list of configurations considered to be DEBUG.
+ std::vector<std::string> debugConfigs =
+ mf.GetCMakeInstance()->GetDebugConfigs();
+ std::string prop;
+
+ // Include this library in the link interface for the target.
+ if (llt == DEBUG_LibraryType || llt == GENERAL_LibraryType) {
+ // Put in the DEBUG configuration interfaces.
+ for (std::string const& dc : debugConfigs) {
+ prop = cmStrCat("LINK_INTERFACE_LIBRARIES_", dc);
+ target->AppendProperty(prop, libRef.c_str());
+ }
}
- }
- if (llt == OPTIMIZED_LibraryType || llt == GENERAL_LibraryType) {
- // Put in the non-DEBUG configuration interfaces.
- this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib.c_str());
-
- // Make sure the DEBUG configuration interfaces exist so that the
- // general one will not be used as a fall-back.
- for (std::vector<std::string>::const_iterator i = debugConfigs.begin();
- i != debugConfigs.end(); ++i) {
- prop = "LINK_INTERFACE_LIBRARIES_";
- prop += *i;
- if (!this->Target->GetProperty(prop)) {
- this->Target->SetProperty(prop, "");
+ if (llt == OPTIMIZED_LibraryType || llt == GENERAL_LibraryType) {
+ // Put in the non-DEBUG configuration interfaces.
+ target->AppendProperty("LINK_INTERFACE_LIBRARIES", libRef.c_str());
+
+ // Make sure the DEBUG configuration interfaces exist so that the
+ // general one will not be used as a fall-back.
+ for (std::string const& dc : debugConfigs) {
+ prop = cmStrCat("LINK_INTERFACE_LIBRARIES_", dc);
+ if (!target->GetProperty(prop)) {
+ target->SetProperty(prop, "");
+ }
}
}
}
diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h
index 3fd20accd..4b2deabea 100644
--- a/Source/cmTargetLinkLibrariesCommand.h
+++ b/Source/cmTargetLinkLibrariesCommand.h
@@ -3,58 +3,14 @@
#ifndef cmTargetLinkLibrariesCommand_h
#define cmTargetLinkLibrariesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-#include "cmTargetLinkLibraryType.h"
-
class cmExecutionStatus;
-class cmTarget;
-
-/** \class cmTargetLinkLibrariesCommand
- * \brief Specify a list of libraries to link into executables.
- *
- * cmTargetLinkLibrariesCommand is used to specify a list of libraries to link
- * into executable(s) or shared objects. The names of the libraries
- * should be those defined by the LIBRARY(library) command(s).
- */
-class cmTargetLinkLibrariesCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmTargetLinkLibrariesCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- void LinkLibraryTypeSpecifierWarning(int left, int right);
- static const char* LinkLibraryTypeNames[3];
-
- cmTarget* Target;
- enum ProcessingState
- {
- ProcessingLinkLibraries,
- ProcessingPlainLinkInterface,
- ProcessingKeywordLinkInterface,
- ProcessingPlainPublicInterface,
- ProcessingKeywordPublicInterface,
- ProcessingPlainPrivateInterface,
- ProcessingKeywordPrivateInterface
- };
-
- ProcessingState CurrentProcessingState;
- bool HandleLibrary(const std::string& lib, cmTargetLinkLibraryType llt);
-};
+bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmTargetLinkOptionsCommand.cxx b/Source/cmTargetLinkOptionsCommand.cxx
new file mode 100644
index 000000000..df9416fad
--- /dev/null
+++ b/Source/cmTargetLinkOptionsCommand.cxx
@@ -0,0 +1,50 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmTargetLinkOptionsCommand.h"
+
+#include "cmListFileCache.h"
+#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
+#include "cmTarget.h"
+#include "cmTargetPropCommandBase.h"
+
+namespace {
+
+class TargetLinkOptionsImpl : public cmTargetPropCommandBase
+{
+public:
+ using cmTargetPropCommandBase::cmTargetPropCommandBase;
+
+private:
+ void HandleMissingTarget(const std::string& name) override
+ {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify link options for target \"", name,
+ "\" which is not built by this project."));
+ }
+
+ bool HandleDirectContent(cmTarget* tgt,
+ const std::vector<std::string>& content,
+ bool prepend, bool /*system*/) override
+ {
+ cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+ tgt->InsertLinkOption(this->Join(content), lfbt, prepend);
+ return true; // Successfully handled.
+ }
+
+ std::string Join(const std::vector<std::string>& content) override
+ {
+ return cmJoin(content, ";");
+ }
+};
+
+} // namespace
+
+bool cmTargetLinkOptionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return TargetLinkOptionsImpl(status).HandleArguments(
+ args, "LINK_OPTIONS", TargetLinkOptionsImpl::PROCESS_BEFORE);
+}
diff --git a/Source/cmTargetLinkOptionsCommand.h b/Source/cmTargetLinkOptionsCommand.h
new file mode 100644
index 000000000..13fb40cb6
--- /dev/null
+++ b/Source/cmTargetLinkOptionsCommand.h
@@ -0,0 +1,16 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmTargetLinkOptionsCommand_h
+#define cmTargetLinkOptionsCommand_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+#include <vector>
+
+class cmExecutionStatus;
+
+bool cmTargetLinkOptionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+
+#endif
diff --git a/Source/cmTargetPrecompileHeadersCommand.cxx b/Source/cmTargetPrecompileHeadersCommand.cxx
new file mode 100644
index 000000000..c6e2e5c4f
--- /dev/null
+++ b/Source/cmTargetPrecompileHeadersCommand.cxx
@@ -0,0 +1,87 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmTargetPrecompileHeadersCommand.h"
+
+#include <utility>
+
+#include "cmGeneratorExpression.h"
+#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmTarget.h"
+#include "cmTargetPropCommandBase.h"
+
+namespace {
+
+std::vector<std::string> ConvertToAbsoluteContent(
+ const std::vector<std::string>& content, std::string const& baseDir)
+{
+ std::vector<std::string> absoluteContent;
+ absoluteContent.reserve(content.size());
+ for (std::string const& src : content) {
+ std::string absoluteSrc;
+ // Use '<foo.h>' and '"foo.h"' includes and absolute paths as-is.
+ // Interpret relative paths with respect to the source directory.
+ // If the path starts in a generator expression, assume it is absolute.
+ if (cmHasLiteralPrefix(src, "<") || cmHasLiteralPrefix(src, "\"") ||
+ cmSystemTools::FileIsFullPath(src) ||
+ cmGeneratorExpression::Find(src) == 0) {
+ absoluteSrc = src;
+ } else {
+ absoluteSrc = cmStrCat(baseDir, '/', src);
+ }
+ absoluteContent.emplace_back(std::move(absoluteSrc));
+ }
+ return absoluteContent;
+}
+
+class TargetPrecompileHeadersImpl : public cmTargetPropCommandBase
+{
+public:
+ using cmTargetPropCommandBase::cmTargetPropCommandBase;
+
+private:
+ bool HandleDirectContent(cmTarget* tgt,
+ const std::vector<std::string>& content,
+ bool /*prepend*/, bool /*system*/) override
+ {
+ std::string const& base = this->Makefile->GetCurrentSourceDirectory();
+ tgt->AppendProperty(
+ "PRECOMPILE_HEADERS",
+ this->Join(ConvertToAbsoluteContent(content, base)).c_str());
+ return true;
+ }
+
+ void HandleInterfaceContent(cmTarget* tgt,
+ const std::vector<std::string>& content,
+ bool prepend, bool system) override
+ {
+ std::string const& base = this->Makefile->GetCurrentSourceDirectory();
+ cmTargetPropCommandBase::HandleInterfaceContent(
+ tgt, ConvertToAbsoluteContent(content, base), prepend, system);
+ }
+
+ void HandleMissingTarget(const std::string& name) override
+ {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify precompile headers for target \"", name,
+ "\" which is not built by this project."));
+ }
+
+ std::string Join(const std::vector<std::string>& content) override
+ {
+ return cmJoin(content, ";");
+ }
+};
+
+} // namespace
+
+bool cmTargetPrecompileHeadersCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ return TargetPrecompileHeadersImpl(status).HandleArguments(
+ args, "PRECOMPILE_HEADERS",
+ TargetPrecompileHeadersImpl::PROCESS_REUSE_FROM);
+}
diff --git a/Source/cmTargetPrecompileHeadersCommand.h b/Source/cmTargetPrecompileHeadersCommand.h
new file mode 100644
index 000000000..8b0ac9777
--- /dev/null
+++ b/Source/cmTargetPrecompileHeadersCommand.h
@@ -0,0 +1,16 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmTargetPrecompileHeadersCommand_h
+#define cmTargetPrecompileHeadersCommand_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+#include <vector>
+
+class cmExecutionStatus;
+
+bool cmTargetPrecompileHeadersCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
+
+#endif
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index 45fe430c1..bbc1e16f7 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -2,12 +2,24 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetPropCommandBase.h"
+#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
#include "cmTarget.h"
#include "cmake.h"
+cmTargetPropCommandBase::cmTargetPropCommandBase(cmExecutionStatus& status)
+ : Makefile(&status.GetMakefile())
+ , Status(status)
+{
+}
+
+void cmTargetPropCommandBase::SetError(std::string const& e)
+{
+ this->Status.SetError(e);
+}
+
bool cmTargetPropCommandBase::HandleArguments(
std::vector<std::string> const& args, const std::string& prop,
ArgumentFlags flags)
@@ -17,11 +29,11 @@ bool cmTargetPropCommandBase::HandleArguments(
return false;
}
- // Lookup the target for which libraries are specified.
if (this->Makefile->IsAlias(args[0])) {
this->SetError("can not be used on an ALIAS target.");
return false;
}
+ // Lookup the target for which property-values are specified.
this->Target =
this->Makefile->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(
args[0]);
@@ -32,12 +44,13 @@ bool cmTargetPropCommandBase::HandleArguments(
this->HandleMissingTarget(args[0]);
return false;
}
- if ((this->Target->GetType() != cmStateEnums::SHARED_LIBRARY) &&
+ if ((this->Target->GetType() != cmStateEnums::EXECUTABLE) &&
(this->Target->GetType() != cmStateEnums::STATIC_LIBRARY) &&
- (this->Target->GetType() != cmStateEnums::OBJECT_LIBRARY) &&
+ (this->Target->GetType() != cmStateEnums::SHARED_LIBRARY) &&
(this->Target->GetType() != cmStateEnums::MODULE_LIBRARY) &&
+ (this->Target->GetType() != cmStateEnums::OBJECT_LIBRARY) &&
(this->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
- (this->Target->GetType() != cmStateEnums::EXECUTABLE)) {
+ (this->Target->GetType() != cmStateEnums::UNKNOWN_LIBRARY)) {
this->SetError("called with non-compilable target type");
return false;
}
@@ -64,6 +77,19 @@ bool cmTargetPropCommandBase::HandleArguments(
++argIndex;
}
+ if ((flags & PROCESS_REUSE_FROM) && args[argIndex] == "REUSE_FROM") {
+ if (args.size() != 3) {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ ++argIndex;
+
+ this->Target->SetProperty("PRECOMPILE_HEADERS_REUSE_FROM",
+ args[argIndex].c_str());
+
+ ++argIndex;
+ }
+
this->Property = prop;
while (argIndex < args.size()) {
@@ -85,18 +111,6 @@ bool cmTargetPropCommandBase::ProcessContentArgs(
return false;
}
- if (this->Target->IsImported()) {
- this->HandleImportedTarget(args[0]);
- return false;
- }
-
- if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY &&
- scope != "INTERFACE") {
- this->SetError("may only be set INTERFACE properties on INTERFACE "
- "targets");
- return false;
- }
-
++argIndex;
std::vector<std::string> content;
@@ -104,10 +118,21 @@ bool cmTargetPropCommandBase::ProcessContentArgs(
for (unsigned int i = argIndex; i < args.size(); ++i, ++argIndex) {
if (args[i] == "PUBLIC" || args[i] == "PRIVATE" ||
args[i] == "INTERFACE") {
- return this->PopulateTargetProperies(scope, content, prepend, system);
+ break;
}
content.push_back(args[i]);
}
+ if (!content.empty()) {
+ if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY &&
+ scope != "INTERFACE") {
+ this->SetError("may only set INTERFACE properties on INTERFACE targets");
+ return false;
+ }
+ if (this->Target->IsImported() && scope != "INTERFACE") {
+ this->SetError("may only set INTERFACE properties on IMPORTED targets");
+ return false;
+ }
+ }
return this->PopulateTargetProperies(scope, content, prepend, system);
}
@@ -115,6 +140,9 @@ bool cmTargetPropCommandBase::PopulateTargetProperies(
const std::string& scope, const std::vector<std::string>& content,
bool prepend, bool system)
{
+ if (content.empty()) {
+ return true;
+ }
if (scope == "PRIVATE" || scope == "PUBLIC") {
if (!this->HandleDirectContent(this->Target, content, prepend, system)) {
return false;
diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h
index 46a2f6b07..601ad0113 100644
--- a/Source/cmTargetPropCommandBase.h
+++ b/Source/cmTargetPropCommandBase.h
@@ -8,18 +8,24 @@
#include <string>
#include <vector>
-#include "cmCommand.h"
-
+class cmExecutionStatus;
+class cmMakefile;
class cmTarget;
-class cmTargetPropCommandBase : public cmCommand
+class cmTargetPropCommandBase
{
public:
+ cmTargetPropCommandBase(cmExecutionStatus& status);
+ virtual ~cmTargetPropCommandBase() = default;
+
+ void SetError(std::string const& e);
+
enum ArgumentFlags
{
- NO_FLAGS = 0,
- PROCESS_BEFORE = 1,
- PROCESS_SYSTEM = 2
+ NO_FLAGS = 0x0,
+ PROCESS_BEFORE = 0x1,
+ PROCESS_SYSTEM = 0x2,
+ PROCESS_REUSE_FROM = 0x3
};
bool HandleArguments(std::vector<std::string> const& args,
@@ -28,14 +34,14 @@ public:
protected:
std::string Property;
- cmTarget* Target;
+ cmTarget* Target = nullptr;
+ cmMakefile* Makefile;
virtual void HandleInterfaceContent(cmTarget* tgt,
const std::vector<std::string>& content,
bool prepend, bool system);
private:
- virtual void HandleImportedTarget(const std::string& tgt) = 0;
virtual void HandleMissingTarget(const std::string& name) = 0;
virtual bool HandleDirectContent(cmTarget* tgt,
@@ -49,6 +55,8 @@ private:
bool PopulateTargetProperies(const std::string& scope,
const std::vector<std::string>& content,
bool prepend, bool system);
+
+ cmExecutionStatus& Status;
};
#endif
diff --git a/Source/cmTargetPropertyComputer.cxx b/Source/cmTargetPropertyComputer.cxx
index a57bc5aea..baab8da0a 100644
--- a/Source/cmTargetPropertyComputer.cxx
+++ b/Source/cmTargetPropertyComputer.cxx
@@ -3,21 +3,23 @@
#include "cmTargetPropertyComputer.h"
+#include <cctype>
#include <sstream>
+#include <unordered_set>
+#include "cmMessageType.h"
#include "cmMessenger.h"
#include "cmPolicies.h"
#include "cmStateSnapshot.h"
-#include "cm_unordered_set.hxx"
-#include "cmake.h"
+#include "cmStringAlgorithms.h"
bool cmTargetPropertyComputer::HandleLocationPropertyPolicy(
std::string const& tgtName, cmMessenger* messenger,
cmListFileBacktrace const& context)
{
std::ostringstream e;
- const char* modal = CM_NULLPTR;
- cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ const char* modal = nullptr;
+ MessageType messageType = MessageType::AUTHOR_WARNING;
switch (context.GetBottom().GetPolicy(cmPolicies::CMP0026)) {
case cmPolicies::WARN:
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0026) << "\n";
@@ -28,7 +30,7 @@ bool cmTargetPropertyComputer::HandleLocationPropertyPolicy(
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::NEW:
modal = "may";
- messageType = cmake::FATAL_ERROR;
+ messageType = MessageType::FATAL_ERROR;
}
if (modal) {
@@ -40,7 +42,7 @@ bool cmTargetPropertyComputer::HandleLocationPropertyPolicy(
messenger->IssueMessage(messageType, e.str(), context);
}
- return messageType != cmake::FATAL_ERROR;
+ return messageType != MessageType::FATAL_ERROR;
}
bool cmTargetPropertyComputer::WhiteListedInterfaceProperty(
@@ -49,29 +51,46 @@ bool cmTargetPropertyComputer::WhiteListedInterfaceProperty(
if (cmHasLiteralPrefix(prop, "INTERFACE_")) {
return true;
}
- static CM_UNORDERED_SET<std::string> builtIns;
- if (builtIns.empty()) {
- builtIns.insert("COMPATIBLE_INTERFACE_BOOL");
- builtIns.insert("COMPATIBLE_INTERFACE_NUMBER_MAX");
- builtIns.insert("COMPATIBLE_INTERFACE_NUMBER_MIN");
- builtIns.insert("COMPATIBLE_INTERFACE_STRING");
- builtIns.insert("EXPORT_NAME");
- builtIns.insert("IMPORTED");
- builtIns.insert("NAME");
- builtIns.insert("TYPE");
+ if (cmHasLiteralPrefix(prop, "_")) {
+ return true;
+ }
+ if (std::islower(prop[0])) {
+ return true;
}
+ static std::unordered_set<std::string> const builtIns{
+ "COMPATIBLE_INTERFACE_BOOL",
+ "COMPATIBLE_INTERFACE_NUMBER_MAX",
+ "COMPATIBLE_INTERFACE_NUMBER_MIN",
+ "COMPATIBLE_INTERFACE_STRING",
+ "EXPORT_NAME",
+ "EXPORT_PROPERTIES",
+ "IMPORTED",
+ "IMPORTED_GLOBAL",
+ "MANUALLY_ADDED_DEPENDENCIES",
+ "NAME",
+ "PRIVATE_HEADER",
+ "PUBLIC_HEADER",
+ "TYPE"
+ };
if (builtIns.count(prop)) {
return true;
}
if (prop == "IMPORTED_CONFIGURATIONS" || prop == "IMPORTED_LIBNAME" ||
- prop == "NO_SYSTEM_FROM_IMPORTED" ||
cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME_") ||
cmHasLiteralPrefix(prop, "MAP_IMPORTED_CONFIG_")) {
return true;
}
+ // This property should not be allowed but was incorrectly added in
+ // CMake 3.8. We can't remove it from the whitelist without breaking
+ // projects that try to set it. One day we could warn about this, but
+ // for now silently accept it.
+ if (prop == "NO_SYSTEM_FROM_IMPORTED") {
+ return true;
+ }
+
return false;
}
@@ -85,7 +104,7 @@ bool cmTargetPropertyComputer::PassesWhitelist(
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
"The property \""
<< prop << "\" is not allowed.";
- messenger->IssueMessage(cmake::FATAL_ERROR, e.str(), context);
+ messenger->IssueMessage(MessageType::FATAL_ERROR, e.str(), context);
return false;
}
return true;
diff --git a/Source/cmTargetPropertyComputer.h b/Source/cmTargetPropertyComputer.h
index 94688e313..3b11acdc1 100644
--- a/Source/cmTargetPropertyComputer.h
+++ b/Source/cmTargetPropertyComputer.h
@@ -7,9 +7,9 @@
#include <string>
-#include "cmAlgorithms.h"
#include "cmListFileCache.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
class cmMessenger;
@@ -26,12 +26,12 @@ public:
return loc;
}
if (cmSystemTools::GetFatalErrorOccured()) {
- return CM_NULLPTR;
+ return nullptr;
}
if (prop == "SOURCES") {
return GetSources(tgt, messenger, context);
}
- return CM_NULLPTR;
+ return nullptr;
}
static bool WhiteListedInterfaceProperty(const std::string& prop);
@@ -69,7 +69,7 @@ private:
if (!tgt->IsImported() &&
!HandleLocationPropertyPolicy(tgt->GetName(), messenger,
context)) {
- return CM_NULLPTR;
+ return nullptr;
}
return ComputeLocationForBuild(tgt);
}
@@ -79,9 +79,9 @@ private:
if (!tgt->IsImported() &&
!HandleLocationPropertyPolicy(tgt->GetName(), messenger,
context)) {
- return CM_NULLPTR;
+ return nullptr;
}
- const char* configName = prop.c_str() + 9;
+ std::string configName = prop.substr(9);
return ComputeLocation(tgt, configName);
}
@@ -93,13 +93,13 @@ private:
if (!tgt->IsImported() &&
!HandleLocationPropertyPolicy(tgt->GetName(), messenger,
context)) {
- return CM_NULLPTR;
+ return nullptr;
}
return ComputeLocation(tgt, configName);
}
}
}
- return CM_NULLPTR;
+ return nullptr;
}
template <typename Target>
diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx
index 058659a52..c2e0b28fe 100644
--- a/Source/cmTargetSourcesCommand.cxx
+++ b/Source/cmTargetSourcesCommand.cxx
@@ -4,44 +4,134 @@
#include <sstream>
-#include "cmAlgorithms.h"
+#include "cmGeneratorExpression.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmPolicies.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cmake.h"
+#include "cmTargetPropCommandBase.h"
-class cmExecutionStatus;
+namespace {
-bool cmTargetSourcesCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+class TargetSourcesImpl : public cmTargetPropCommandBase
{
- return this->HandleArguments(args, "SOURCES");
-}
+public:
+ using cmTargetPropCommandBase::cmTargetPropCommandBase;
-void cmTargetSourcesCommand::HandleImportedTarget(const std::string& tgt)
-{
- std::ostringstream e;
- e << "Cannot specify sources for imported target \"" << tgt << "\".";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-}
+protected:
+ void HandleInterfaceContent(cmTarget* tgt,
+ const std::vector<std::string>& content,
+ bool prepend, bool system) override
+ {
+ cmTargetPropCommandBase::HandleInterfaceContent(
+ tgt, ConvertToAbsoluteContent(tgt, content, true), prepend, system);
+ }
+
+private:
+ void HandleMissingTarget(const std::string& name) override
+ {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify sources for target \"", name,
+ "\" which is not built by this project."));
+ }
+
+ bool HandleDirectContent(cmTarget* tgt,
+ const std::vector<std::string>& content,
+ bool /*prepend*/, bool /*system*/) override
+ {
+ tgt->AppendProperty(
+ "SOURCES",
+ this->Join(ConvertToAbsoluteContent(tgt, content, false)).c_str());
+ return true; // Successfully handled.
+ }
+
+ std::string Join(const std::vector<std::string>& content) override
+ {
+ return cmJoin(content, ";");
+ }
+
+ std::vector<std::string> ConvertToAbsoluteContent(
+ cmTarget* tgt, const std::vector<std::string>& content,
+ bool isInterfaceContent);
+};
-void cmTargetSourcesCommand::HandleMissingTarget(const std::string& name)
+std::vector<std::string> TargetSourcesImpl::ConvertToAbsoluteContent(
+ cmTarget* tgt, const std::vector<std::string>& content,
+ bool isInterfaceContent)
{
+ // Skip conversion in case old behavior has been explicitly requested
+ if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0076) ==
+ cmPolicies::OLD) {
+ return content;
+ }
+
+ bool changedPath = false;
+ std::vector<std::string> absoluteContent;
+ absoluteContent.reserve(content.size());
+ for (std::string const& src : content) {
+ std::string absoluteSrc;
+ if (cmSystemTools::FileIsFullPath(src) ||
+ cmGeneratorExpression::Find(src) == 0 ||
+ (!isInterfaceContent &&
+ (this->Makefile->GetCurrentSourceDirectory() ==
+ tgt->GetMakefile()->GetCurrentSourceDirectory()))) {
+ absoluteSrc = src;
+ } else {
+ changedPath = true;
+ absoluteSrc =
+ cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', src);
+ }
+ absoluteContent.push_back(absoluteSrc);
+ }
+
+ if (!changedPath) {
+ return content;
+ }
+
+ bool issueMessage = true;
+ bool useAbsoluteContent = false;
std::ostringstream e;
- e << "Cannot specify sources for target \"" << name
- << "\" "
- "which is not built by this project.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
-}
+ switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0076)) {
+ case cmPolicies::WARN:
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0076) << "\n";
+ break;
+ case cmPolicies::OLD:
+ issueMessage = false;
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0076));
+ break;
+ case cmPolicies::NEW: {
+ issueMessage = false;
+ useAbsoluteContent = true;
+ break;
+ }
+ }
-std::string cmTargetSourcesCommand::Join(
- const std::vector<std::string>& content)
-{
- return cmJoin(content, ";");
+ if (issueMessage) {
+ if (isInterfaceContent) {
+ e << "An interface source of target \"" << tgt->GetName()
+ << "\" has a relative path.";
+ } else {
+ e << "A private source from a directory other than that of target \""
+ << tgt->GetName() << "\" has a relative path.";
+ }
+ this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, e.str());
+ }
+
+ return useAbsoluteContent ? absoluteContent : content;
}
-bool cmTargetSourcesCommand::HandleDirectContent(
- cmTarget* tgt, const std::vector<std::string>& content, bool, bool)
+} // namespace
+
+bool cmTargetSourcesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- tgt->AppendProperty("SOURCES", this->Join(content).c_str());
- return true;
+ return TargetSourcesImpl(status).HandleArguments(args, "SOURCES");
}
diff --git a/Source/cmTargetSourcesCommand.h b/Source/cmTargetSourcesCommand.h
index 09ba72915..5eecf3454 100644
--- a/Source/cmTargetSourcesCommand.h
+++ b/Source/cmTargetSourcesCommand.h
@@ -3,41 +3,14 @@
#ifndef cmTargetSourcesCommand_h
#define cmTargetSourcesCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmTargetPropCommandBase.h"
-
-class cmCommand;
class cmExecutionStatus;
-class cmTarget;
-
-class cmTargetSourcesCommand : public cmTargetPropCommandBase
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmTargetSourcesCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- void HandleImportedTarget(const std::string& tgt) CM_OVERRIDE;
- void HandleMissingTarget(const std::string& name) CM_OVERRIDE;
-
- bool HandleDirectContent(cmTarget* tgt,
- const std::vector<std::string>& content,
- bool prepend, bool system) CM_OVERRIDE;
- std::string Join(const std::vector<std::string>& content) CM_OVERRIDE;
-};
+bool cmTargetSourcesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx
index 4d0cbaafc..d5c61c173 100644
--- a/Source/cmTest.cxx
+++ b/Source/cmTest.cxx
@@ -5,18 +5,17 @@
#include "cmMakefile.h"
#include "cmProperty.h"
#include "cmState.h"
-#include "cmSystemTools.h"
+#include "cmStringAlgorithms.h"
cmTest::cmTest(cmMakefile* mf)
- : Backtrace(mf->GetBacktrace())
+ : CommandExpandLists(false)
+ , Backtrace(mf->GetBacktrace())
{
this->Makefile = mf;
this->OldStyle = true;
}
-cmTest::~cmTest()
-{
-}
+cmTest::~cmTest() = default;
cmListFileBacktrace const& cmTest::GetBacktrace() const
{
@@ -48,7 +47,7 @@ const char* cmTest::GetProperty(const std::string& prop) const
bool cmTest::GetPropertyAsBool(const std::string& prop) const
{
- return cmSystemTools::IsOn(this->GetProperty(prop));
+ return cmIsOn(this->GetProperty(prop));
}
void cmTest::SetProperty(const std::string& prop, const char* value)
@@ -61,3 +60,13 @@ void cmTest::AppendProperty(const std::string& prop, const char* value,
{
this->Properties.AppendProperty(prop, value, asString);
}
+
+bool cmTest::GetCommandExpandLists() const
+{
+ return this->CommandExpandLists;
+}
+
+void cmTest::SetCommandExpandLists(bool b)
+{
+ this->CommandExpandLists = b;
+}
diff --git a/Source/cmTest.h b/Source/cmTest.h
index d4839d171..dd246c4e6 100644
--- a/Source/cmTest.h
+++ b/Source/cmTest.h
@@ -5,12 +5,12 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmListFileCache.h"
-#include "cmPropertyMap.h"
-
#include <string>
#include <vector>
+#include "cmListFileCache.h"
+#include "cmPropertyMap.h"
+
class cmMakefile;
/** \class cmTest
@@ -26,14 +26,14 @@ public:
cmTest(cmMakefile* mf);
~cmTest();
- ///! Set the test name
+ //! Set the test name
void SetName(const std::string& name);
std::string GetName() const { return this->Name; }
void SetCommand(std::vector<std::string> const& command);
std::vector<std::string> const& GetCommand() const { return this->Command; }
- ///! Set/Get a property of this source file
+ //! Set/Get a property of this source file
void SetProperty(const std::string& prop, const char* value);
void AppendProperty(const std::string& prop, const char* value,
bool asString = false);
@@ -51,10 +51,15 @@ public:
bool GetOldStyle() const { return this->OldStyle; }
void SetOldStyle(bool b) { this->OldStyle = b; }
+ /** Set/Get whether lists in command lines should be expanded. */
+ bool GetCommandExpandLists() const;
+ void SetCommandExpandLists(bool b);
+
private:
cmPropertyMap Properties;
std::string Name;
std::vector<std::string> Command;
+ bool CommandExpandLists;
bool OldStyle;
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index be4b37847..333d4d5ee 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -2,17 +2,20 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTestGenerator.h"
-#include <map>
+#include <memory>
#include <ostream>
#include <utility>
+#include <vector>
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
+#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmOutputConverter.h"
-#include "cmProperty.h"
#include "cmPropertyMap.h"
+#include "cmRange.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTest.h"
@@ -23,18 +26,26 @@ cmTestGenerator::cmTestGenerator(
{
this->ActionsPerConfig = !test->GetOldStyle();
this->TestGenerated = false;
- this->LG = CM_NULLPTR;
+ this->LG = nullptr;
}
-cmTestGenerator::~cmTestGenerator()
-{
-}
+cmTestGenerator::~cmTestGenerator() = default;
void cmTestGenerator::Compute(cmLocalGenerator* lg)
{
this->LG = lg;
}
+bool cmTestGenerator::TestsForConfig(const std::string& config)
+{
+ return this->GeneratesForConfig(config);
+}
+
+cmTest* cmTestGenerator::GetTest() const
+{
+ return this->Test;
+}
+
void cmTestGenerator::GenerateScriptConfigs(std::ostream& os, Indent indent)
{
// Create the tests.
@@ -67,12 +78,22 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
// Start the test command.
os << indent << "add_test(" << this->Test->GetName() << " ";
- // Get the test command line to be executed.
- std::vector<std::string> const& command = this->Test->GetCommand();
+ // Evaluate command line arguments
+ std::vector<std::string> argv =
+ EvaluateCommandLineArguments(this->Test->GetCommand(), ge, config);
+
+ // Expand arguments if COMMAND_EXPAND_LISTS is set
+ if (this->Test->GetCommandExpandLists()) {
+ argv = cmExpandedLists(argv.begin(), argv.end());
+ // Expanding lists on an empty command may have left it empty
+ if (argv.empty()) {
+ argv.emplace_back();
+ }
+ }
// Check whether the command executable is a target whose name is to
// be translated.
- std::string exe = command[0];
+ std::string exe = argv[0];
cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(exe);
if (target && target->GetType() == cmStateEnums::EXECUTABLE) {
// Use the target file on disk.
@@ -80,47 +101,40 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
// Prepend with the emulator when cross compiling if required.
const char* emulator = target->GetProperty("CROSSCOMPILING_EMULATOR");
- if (emulator != CM_NULLPTR) {
- std::vector<std::string> emulatorWithArgs;
- cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs);
+ if (emulator != nullptr && *emulator) {
+ std::vector<std::string> emulatorWithArgs = cmExpandedList(emulator);
std::string emulatorExe(emulatorWithArgs[0]);
cmSystemTools::ConvertToUnixSlashes(emulatorExe);
os << cmOutputConverter::EscapeForCMake(emulatorExe) << " ";
- for (std::vector<std::string>::const_iterator ei =
- emulatorWithArgs.begin() + 1;
- ei != emulatorWithArgs.end(); ++ei) {
- os << cmOutputConverter::EscapeForCMake(*ei) << " ";
+ for (std::string const& arg : cmMakeRange(emulatorWithArgs).advance(1)) {
+ os << cmOutputConverter::EscapeForCMake(arg) << " ";
}
}
} else {
// Use the command name given.
- exe = ge.Parse(exe.c_str())->Evaluate(this->LG, config);
cmSystemTools::ConvertToUnixSlashes(exe);
}
// Generate the command line with full escapes.
os << cmOutputConverter::EscapeForCMake(exe);
- for (std::vector<std::string>::const_iterator ci = command.begin() + 1;
- ci != command.end(); ++ci) {
- os << " " << cmOutputConverter::EscapeForCMake(
- ge.Parse(*ci)->Evaluate(this->LG, config));
+
+ for (auto const& arg : cmMakeRange(argv).advance(1)) {
+ os << " " << cmOutputConverter::EscapeForCMake(arg);
}
// Finish the test command.
os << ")\n";
// Output properties for the test.
- cmPropertyMap& pm = this->Test->GetProperties();
- if (!pm.empty()) {
- os << indent << "set_tests_properties(" << this->Test->GetName()
- << " PROPERTIES ";
- for (cmPropertyMap::const_iterator i = pm.begin(); i != pm.end(); ++i) {
- os << " " << i->first << " "
- << cmOutputConverter::EscapeForCMake(
- ge.Parse(i->second.GetValue())->Evaluate(this->LG, config));
- }
- os << ")" << std::endl;
+ os << indent << "set_tests_properties(" << this->Test->GetName()
+ << " PROPERTIES ";
+ for (auto const& i : this->Test->GetProperties().GetList()) {
+ os << " " << i.first << " "
+ << cmOutputConverter::EscapeForCMake(
+ ge.Parse(i.second)->Evaluate(this->LG, config));
}
+ this->GenerateInternalProperties(os);
+ os << ")" << std::endl;
}
void cmTestGenerator::GenerateScriptNoConfig(std::ostream& os, Indent indent)
@@ -149,34 +163,68 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout, Indent indent)
fout << "add_test(";
fout << this->Test->GetName() << " \"" << exe << "\"";
- for (std::vector<std::string>::const_iterator argit = command.begin() + 1;
- argit != command.end(); ++argit) {
+ for (std::string const& arg : cmMakeRange(command).advance(1)) {
// Just double-quote all arguments so they are re-parsed
// correctly by the test system.
fout << " \"";
- for (std::string::const_iterator c = argit->begin(); c != argit->end();
- ++c) {
+ for (char c : arg) {
// Escape quotes within arguments. We should escape
// backslashes too but we cannot because it makes the result
// inconsistent with previous behavior of this command.
- if ((*c == '"')) {
+ if (c == '"') {
fout << '\\';
}
- fout << *c;
+ fout << c;
}
fout << "\"";
}
fout << ")" << std::endl;
// Output properties for the test.
- cmPropertyMap& pm = this->Test->GetProperties();
- if (!pm.empty()) {
- fout << indent << "set_tests_properties(" << this->Test->GetName()
- << " PROPERTIES ";
- for (cmPropertyMap::const_iterator i = pm.begin(); i != pm.end(); ++i) {
- fout << " " << i->first << " "
- << cmOutputConverter::EscapeForCMake(i->second.GetValue());
+ fout << indent << "set_tests_properties(" << this->Test->GetName()
+ << " PROPERTIES ";
+ for (auto const& i : this->Test->GetProperties().GetList()) {
+ fout << " " << i.first << " "
+ << cmOutputConverter::EscapeForCMake(i.second);
+ }
+ this->GenerateInternalProperties(fout);
+ fout << ")" << std::endl;
+}
+
+void cmTestGenerator::GenerateInternalProperties(std::ostream& os)
+{
+ cmListFileBacktrace bt = this->Test->GetBacktrace();
+ if (bt.Empty()) {
+ return;
+ }
+
+ os << " "
+ << "_BACKTRACE_TRIPLES"
+ << " \"";
+
+ bool prependTripleSeparator = false;
+ while (!bt.Empty()) {
+ const auto& entry = bt.Top();
+ if (prependTripleSeparator) {
+ os << ";";
}
- fout << ")" << std::endl;
+ os << entry.FilePath << ";" << entry.Line << ";" << entry.Name;
+ bt = bt.Pop();
+ prependTripleSeparator = true;
}
+
+ os << "\"";
+}
+
+std::vector<std::string> cmTestGenerator::EvaluateCommandLineArguments(
+ const std::vector<std::string>& argv, cmGeneratorExpression& ge,
+ const std::string& config) const
+{
+ // Evaluate executable name and arguments
+ auto evaluatedRange =
+ cmMakeRange(argv).transform([&](const std::string& arg) {
+ return ge.Parse(arg)->Evaluate(this->LG, config);
+ });
+
+ return { evaluatedRange.begin(), evaluatedRange.end() };
}
diff --git a/Source/cmTestGenerator.h b/Source/cmTestGenerator.h
index b2273050f..e388c1643 100644
--- a/Source/cmTestGenerator.h
+++ b/Source/cmTestGenerator.h
@@ -3,14 +3,15 @@
#ifndef cmTestGenerator_h
#define cmTestGenerator_h
-#include "cmConfigure.h"
-
-#include "cmScriptGenerator.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
#include <vector>
+#include "cmScriptGenerator.h"
+
+class cmGeneratorExpression;
class cmLocalGenerator;
class cmTest;
@@ -20,23 +21,35 @@ class cmTest;
*/
class cmTestGenerator : public cmScriptGenerator
{
- CM_DISABLE_COPY(cmTestGenerator)
-
public:
cmTestGenerator(cmTest* test,
std::vector<std::string> const& configurations =
std::vector<std::string>());
- ~cmTestGenerator() CM_OVERRIDE;
+ ~cmTestGenerator() override;
+
+ cmTestGenerator(cmTestGenerator const&) = delete;
+ cmTestGenerator& operator=(cmTestGenerator const&) = delete;
void Compute(cmLocalGenerator* lg);
+ /** Test if this generator installs the test for a given configuration. */
+ bool TestsForConfig(const std::string& config);
+
+ cmTest* GetTest() const;
+
+private:
+ void GenerateInternalProperties(std::ostream& os);
+ std::vector<std::string> EvaluateCommandLineArguments(
+ const std::vector<std::string>& argv, cmGeneratorExpression& ge,
+ const std::string& config) const;
+
protected:
- void GenerateScriptConfigs(std::ostream& os, Indent indent) CM_OVERRIDE;
- void GenerateScriptActions(std::ostream& os, Indent indent) CM_OVERRIDE;
+ void GenerateScriptConfigs(std::ostream& os, Indent indent) override;
+ void GenerateScriptActions(std::ostream& os, Indent indent) override;
void GenerateScriptForConfig(std::ostream& os, const std::string& config,
- Indent indent) CM_OVERRIDE;
- void GenerateScriptNoConfig(std::ostream& os, Indent indent) CM_OVERRIDE;
- bool NeedsScriptNoConfig() const CM_OVERRIDE;
+ Indent indent) override;
+ void GenerateScriptNoConfig(std::ostream& os, Indent indent) override;
+ bool NeedsScriptNoConfig() const override;
void GenerateOldStyle(std::ostream& os, Indent indent);
cmLocalGenerator* LG;
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx
index 4b9718847..390fd16b0 100644
--- a/Source/cmTimestamp.cxx
+++ b/Source/cmTimestamp.cxx
@@ -2,17 +2,17 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTimestamp.h"
-#include "cmConfigure.h"
+#include <cstdlib>
#include <cstring>
#include <sstream>
-#include <stdlib.h>
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
std::string cmTimestamp::CurrentTime(const std::string& formatString,
bool utcFlag)
{
- time_t currentTimeT = time(CM_NULLPTR);
+ time_t currentTimeT = time(nullptr);
std::string source_date_epoch;
cmSystemTools::GetEnv("SOURCE_DATE_EPOCH", source_date_epoch);
if (!source_date_epoch.empty()) {
@@ -34,11 +34,14 @@ std::string cmTimestamp::FileModificationTime(const char* path,
const std::string& formatString,
bool utcFlag)
{
- if (!cmsys::SystemTools::FileExists(path)) {
+ std::string real_path =
+ cmSystemTools::GetRealPathResolvingWindowsSubst(path);
+
+ if (!cmsys::SystemTools::FileExists(real_path)) {
return std::string();
}
- time_t mtime = cmsys::SystemTools::ModifiedTime(path);
+ time_t mtime = cmsys::SystemTools::ModifiedTime(real_path);
return CreateTimestampFromTimeT(mtime, formatString, utcFlag);
}
@@ -56,14 +59,14 @@ std::string cmTimestamp::CreateTimestampFromTimeT(time_t timeT,
struct tm timeStruct;
memset(&timeStruct, 0, sizeof(timeStruct));
- struct tm* ptr = (struct tm*)CM_NULLPTR;
+ struct tm* ptr = nullptr;
if (utcFlag) {
ptr = gmtime(&timeT);
} else {
ptr = localtime(&timeT);
}
- if (ptr == CM_NULLPTR) {
+ if (ptr == nullptr) {
return std::string();
}
@@ -94,7 +97,7 @@ time_t cmTimestamp::CreateUtcTimeTFromTm(struct tm& tm) const
// From Linux timegm() manpage.
std::string tz_old;
- cmSystemTools::GetEnv("TZ", tz_old);
+ bool const tz_was_set = cmSystemTools::GetEnv("TZ", tz_old);
tz_old = "TZ=" + tz_old;
// The standard says that "TZ=" or "TZ=[UNRECOGNIZED_TZ]" means UTC.
@@ -107,7 +110,17 @@ time_t cmTimestamp::CreateUtcTimeTFromTm(struct tm& tm) const
time_t result = mktime(&tm);
+# ifndef CMAKE_BOOTSTRAP
+ if (tz_was_set) {
+ cmSystemTools::PutEnv(tz_old);
+ } else {
+ cmSystemTools::UnsetEnv("TZ");
+ }
+# else
+ // No UnsetEnv during bootstrap. This is good enough for CMake itself.
cmSystemTools::PutEnv(tz_old);
+ static_cast<void>(tz_was_set);
+# endif
tzset();
@@ -119,12 +132,13 @@ std::string cmTimestamp::AddTimestampComponent(char flag,
struct tm& timeStruct,
const time_t timeT) const
{
- std::string formatString = "%";
- formatString += flag;
+ std::string formatString = cmStrCat('%', flag);
switch (flag) {
case 'a':
+ case 'A':
case 'b':
+ case 'B':
case 'd':
case 'H':
case 'I':
@@ -150,13 +164,11 @@ std::string cmTimestamp::AddTimestampComponent(char flag,
if (unixEpoch == -1) {
cmSystemTools::Error(
"Error generating UNIX epoch in "
- "STRING(TIMESTAMP ...). Please, file a bug report aginst CMake");
+ "STRING(TIMESTAMP ...). Please, file a bug report against CMake");
return std::string();
}
- std::ostringstream ss;
- ss << static_cast<long int>(difftime(timeT, unixEpoch));
- return ss.str();
+ return std::to_string(static_cast<long int>(difftime(timeT, unixEpoch)));
}
default: {
return formatString;
diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h
index 8dd499a3e..40338f8b2 100644
--- a/Source/cmTimestamp.h
+++ b/Source/cmTimestamp.h
@@ -5,8 +5,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <ctime>
#include <string>
-#include <time.h>
/** \class cmTimestamp
* \brief Utility class to generate string representation of a timestamp
@@ -15,20 +15,18 @@
class cmTimestamp
{
public:
- cmTimestamp() {}
-
std::string CurrentTime(const std::string& formatString, bool utcFlag);
std::string FileModificationTime(const char* path,
const std::string& formatString,
bool utcFlag);
-private:
- time_t CreateUtcTimeTFromTm(struct tm& timeStruct) const;
-
std::string CreateTimestampFromTimeT(time_t timeT, std::string formatString,
bool utcFlag) const;
+private:
+ time_t CreateUtcTimeTFromTm(struct tm& timeStruct) const;
+
std::string AddTimestampComponent(char flag, struct tm& timeStruct,
time_t timeT) const;
};
diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx
index b6bfbfa69..05b3f0587 100644
--- a/Source/cmTryCompileCommand.cxx
+++ b/Source/cmTryCompileCommand.cxx
@@ -3,6 +3,7 @@
#include "cmTryCompileCommand.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmake.h"
class cmExecutionStatus;
@@ -18,7 +19,7 @@ bool cmTryCompileCommand::InitialPass(std::vector<std::string> const& argv,
if (this->Makefile->GetCMakeInstance()->GetWorkingMode() ==
cmake::FIND_PACKAGE_MODE) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"The TRY_COMPILE() command is not supported in --find-package mode.");
return false;
}
@@ -28,7 +29,7 @@ bool cmTryCompileCommand::InitialPass(std::vector<std::string> const& argv,
// if They specified clean then we clean up what we can
if (this->SrcFileSignature) {
if (!this->Makefile->GetCMakeInstance()->GetDebugTryCompile()) {
- this->CleanupFiles(this->BinaryDirectory.c_str());
+ this->CleanupFiles(this->BinaryDirectory);
}
}
return true;
diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h
index 483654822..e525e851f 100644
--- a/Source/cmTryCompileCommand.h
+++ b/Source/cmTryCompileCommand.h
@@ -3,20 +3,22 @@
#ifndef cmTryCompileCommand_h
#define cmTryCompileCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
+#include <cm/memory>
+
+#include "cmCommand.h"
#include "cmCoreTryCompile.h"
-class cmCommand;
class cmExecutionStatus;
/** \class cmTryCompileCommand
* \brief Specifies where to install some files
*
- * cmTryCompileCommand is used to test if soucre code can be compiled
+ * cmTryCompileCommand is used to test if source code can be compiled
*/
class cmTryCompileCommand : public cmCoreTryCompile
{
@@ -24,14 +26,17 @@ public:
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE { return new cmTryCompileCommand; }
+ std::unique_ptr<cmCommand> Clone() override
+ {
+ return cm::make_unique<cmTryCompileCommand>();
+ }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
+ cmExecutionStatus& status) override;
};
#endif
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index 07e20e62f..0e8e986ab 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -2,13 +2,17 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTryRunCommand.h"
+#include <cstdio>
+
#include "cmsys/FStream.hxx"
-#include <stdio.h>
-#include <string.h>
+#include "cmDuration.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmRange.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
@@ -25,7 +29,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv,
if (this->Makefile->GetCMakeInstance()->GetWorkingMode() ==
cmake::FIND_PACKAGE_MODE) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR,
+ MessageType::FATAL_ERROR,
"The TRY_RUN() command is not supported in --find-package mode.");
return false;
}
@@ -33,11 +37,11 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv,
// build an arg list for TryCompile and extract the runArgs,
std::vector<std::string> tryCompile;
- this->CompileResultVariable = "";
- this->RunResultVariable = "";
- this->OutputVariable = "";
- this->RunOutputVariable = "";
- this->CompileOutputVariable = "";
+ this->CompileResultVariable.clear();
+ this->RunResultVariable.clear();
+ this->OutputVariable.clear();
+ this->RunOutputVariable.clear();
+ this->CompileOutputVariable.clear();
std::string runArgs;
unsigned int i;
@@ -45,7 +49,8 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv,
if (argv[i] == "ARGS") {
++i;
while (i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" &&
- argv[i] != "CMAKE_FLAGS" && argv[i] != "LINK_LIBRARIES") {
+ argv[i] != "CMAKE_FLAGS" && argv[i] != "LINK_OPTIONS" &&
+ argv[i] != "LINK_LIBRARIES") {
runArgs += " ";
runArgs += argv[i];
++i;
@@ -99,11 +104,11 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv,
bool captureRunOutput = false;
if (!this->OutputVariable.empty()) {
captureRunOutput = true;
- tryCompile.push_back("OUTPUT_VARIABLE");
+ tryCompile.emplace_back("OUTPUT_VARIABLE");
tryCompile.push_back(this->OutputVariable);
}
if (!this->CompileOutputVariable.empty()) {
- tryCompile.push_back("OUTPUT_VARIABLE");
+ tryCompile.emplace_back("OUTPUT_VARIABLE");
tryCompile.push_back(this->CompileOutputVariable);
}
if (!this->RunOutputVariable.empty()) {
@@ -119,15 +124,14 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv,
// now try running the command if it compiled
if (!res) {
if (this->OutputFile.empty()) {
- cmSystemTools::Error(this->FindErrorMessage.c_str());
+ cmSystemTools::Error(this->FindErrorMessage);
} else {
// "run" it and capture the output
std::string runOutputContents;
if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING") &&
!this->Makefile->IsDefinitionSet("CMAKE_CROSSCOMPILING_EMULATOR")) {
- this->DoNotRunExecutable(runArgs, argv[3], captureRunOutput
- ? &runOutputContents
- : CM_NULLPTR);
+ this->DoNotRunExecutable(
+ runArgs, argv[3], captureRunOutput ? &runOutputContents : nullptr);
} else {
this->RunExecutable(runArgs, &runOutputContents);
}
@@ -135,7 +139,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv,
// now put the output into the variables
if (!this->RunOutputVariable.empty()) {
this->Makefile->AddDefinition(this->RunOutputVariable,
- runOutputContents.c_str());
+ runOutputContents);
}
if (!this->OutputVariable.empty()) {
@@ -144,17 +148,16 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv,
const char* compileOutput =
this->Makefile->GetDefinition(this->OutputVariable);
if (compileOutput) {
- runOutputContents = std::string(compileOutput) + runOutputContents;
+ runOutputContents = compileOutput + runOutputContents;
}
- this->Makefile->AddDefinition(this->OutputVariable,
- runOutputContents.c_str());
+ this->Makefile->AddDefinition(this->OutputVariable, runOutputContents);
}
}
}
// if we created a directory etc, then cleanup after ourselves
if (!this->Makefile->GetCMakeInstance()->GetDebugTryCompile()) {
- this->CleanupFiles(this->BinaryDirectory.c_str());
+ this->CleanupFiles(this->BinaryDirectory);
}
return true;
}
@@ -165,40 +168,37 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
int retVal = -1;
std::string finalCommand;
- const std::string emulator =
+ const std::string& emulator =
this->Makefile->GetSafeDefinition("CMAKE_CROSSCOMPILING_EMULATOR");
if (!emulator.empty()) {
- std::vector<std::string> emulatorWithArgs;
- cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs);
+ std::vector<std::string> emulatorWithArgs = cmExpandedList(emulator);
finalCommand +=
- cmSystemTools::ConvertToRunCommandPath(emulatorWithArgs[0].c_str());
+ cmSystemTools::ConvertToRunCommandPath(emulatorWithArgs[0]);
finalCommand += " ";
- for (std::vector<std::string>::const_iterator ei =
- emulatorWithArgs.begin() + 1;
- ei != emulatorWithArgs.end(); ++ei) {
+ for (std::string const& arg : cmMakeRange(emulatorWithArgs).advance(1)) {
finalCommand += "\"";
- finalCommand += *ei;
+ finalCommand += arg;
finalCommand += "\"";
finalCommand += " ";
}
}
- finalCommand +=
- cmSystemTools::ConvertToRunCommandPath(this->OutputFile.c_str());
+ finalCommand += cmSystemTools::ConvertToRunCommandPath(this->OutputFile);
if (!runArgs.empty()) {
finalCommand += runArgs;
}
- int timeout = 0;
bool worked = cmSystemTools::RunSingleCommand(
- finalCommand.c_str(), out, out, &retVal, CM_NULLPTR,
- cmSystemTools::OUTPUT_NONE, timeout);
+ finalCommand, out, out, &retVal, nullptr, cmSystemTools::OUTPUT_NONE,
+ cmDuration::zero());
// set the run var
- char retChar[1000];
+ char retChar[16];
+ const char* retStr;
if (worked) {
sprintf(retChar, "%i", retVal);
+ retStr = retChar;
} else {
- strcpy(retChar, "FAILED_TO_RUN");
+ retStr = "FAILED_TO_RUN";
}
- this->Makefile->AddCacheDefinition(this->RunResultVariable, retChar,
+ this->Makefile->AddCacheDefinition(this->RunResultVariable, retStr,
"Result of TRY_RUN",
cmStateEnums::INTERNAL);
}
@@ -214,32 +214,29 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
// copy the executable out of the CMakeFiles/ directory, so it is not
// removed at the end of TRY_RUN and the user can run it manually
// on the target platform.
- std::string copyDest = this->Makefile->GetHomeOutputDirectory();
- copyDest += cmake::GetCMakeFilesDirectory();
- copyDest += "/";
- copyDest += cmSystemTools::GetFilenameWithoutExtension(this->OutputFile);
- copyDest += "-";
- copyDest += this->RunResultVariable;
- copyDest += cmSystemTools::GetFilenameExtension(this->OutputFile);
+ std::string copyDest =
+ cmStrCat(this->Makefile->GetHomeOutputDirectory(), "/CMakeFiles/",
+ cmSystemTools::GetFilenameWithoutExtension(this->OutputFile), '-',
+ this->RunResultVariable,
+ cmSystemTools::GetFilenameExtension(this->OutputFile));
cmSystemTools::CopyFileAlways(this->OutputFile, copyDest);
- std::string resultFileName = this->Makefile->GetHomeOutputDirectory();
- resultFileName += "/TryRunResults.cmake";
+ std::string resultFileName =
+ cmStrCat(this->Makefile->GetHomeOutputDirectory(), "/TryRunResults.cmake");
- std::string detailsString = "For details see ";
- detailsString += resultFileName;
+ std::string detailsString = cmStrCat("For details see ", resultFileName);
std::string internalRunOutputName =
this->RunResultVariable + "__TRYRUN_OUTPUT";
bool error = false;
- if (this->Makefile->GetDefinition(this->RunResultVariable) == CM_NULLPTR) {
+ if (!this->Makefile->GetDefinition(this->RunResultVariable)) {
// if the variables doesn't exist, create it with a helpful error text
// and mark it as advanced
- std::string comment;
- comment += "Run result of TRY_RUN(), indicates whether the executable "
- "would have been able to run on its target platform.\n";
- comment += detailsString;
+ std::string comment =
+ cmStrCat("Run result of TRY_RUN(), indicates whether the executable "
+ "would have been able to run on its target platform.\n",
+ detailsString);
this->Makefile->AddCacheDefinition(this->RunResultVariable,
"PLEASE_FILL_OUT-FAILED_TO_RUN",
comment.c_str(), cmStateEnums::STRING);
@@ -255,15 +252,14 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
}
// is the output from the executable used ?
- if (out != CM_NULLPTR) {
- if (this->Makefile->GetDefinition(internalRunOutputName) == CM_NULLPTR) {
+ if (out) {
+ if (!this->Makefile->GetDefinition(internalRunOutputName)) {
// if the variables doesn't exist, create it with a helpful error text
// and mark it as advanced
- std::string comment;
- comment +=
+ std::string comment = cmStrCat(
"Output of TRY_RUN(), contains the text, which the executable "
- "would have printed on stdout and stderr on its target platform.\n";
- comment += detailsString;
+ "would have printed on stdout and stderr on its target platform.\n",
+ detailsString);
this->Makefile->AddCacheDefinition(
internalRunOutputName, "PLEASE_FILL_OUT-NOTFOUND", comment.c_str(),
@@ -295,16 +291,16 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
/* clang-format on */
}
- std::string comment = "\n";
- comment += this->RunResultVariable;
- comment += "\n indicates whether the executable would have been able "
+ std::string comment =
+ cmStrCat('\n', this->RunResultVariable,
+ "\n indicates whether the executable would have been able "
"to run on its\n"
- " target platform. If so, set ";
- comment += this->RunResultVariable;
- comment += " to\n"
+ " target platform. If so, set ",
+ this->RunResultVariable,
+ " to\n"
" the exit code (in many cases 0 for success), otherwise "
- "enter \"FAILED_TO_RUN\".\n";
- if (out != CM_NULLPTR) {
+ "enter \"FAILED_TO_RUN\".\n");
+ if (out) {
comment += internalRunOutputName;
comment +=
"\n contains the text the executable "
@@ -335,7 +331,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
<< this->Makefile->GetDefinition(this->RunResultVariable)
<< "\"\n CACHE STRING \"Result from TRY_RUN\" FORCE)\n\n";
- if (out != CM_NULLPTR) {
+ if (out) {
file << "set( " << internalRunOutputName << " \n \""
<< this->Makefile->GetDefinition(internalRunOutputName)
<< "\"\n CACHE STRING \"Output from TRY_RUN\" FORCE)\n\n";
@@ -344,19 +340,20 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
}
firstTryRun = false;
- std::string errorMessage = "TRY_RUN() invoked in cross-compiling mode, "
- "please set the following cache variables "
- "appropriately:\n";
- errorMessage += " " + this->RunResultVariable + " (advanced)\n";
- if (out != CM_NULLPTR) {
+ std::string errorMessage =
+ cmStrCat("TRY_RUN() invoked in cross-compiling mode, "
+ "please set the following cache variables "
+ "appropriately:\n ",
+ this->RunResultVariable, " (advanced)\n");
+ if (out) {
errorMessage += " " + internalRunOutputName + " (advanced)\n";
}
errorMessage += detailsString;
- cmSystemTools::Error(errorMessage.c_str());
+ cmSystemTools::Error(errorMessage);
return;
}
- if (out != CM_NULLPTR) {
+ if (out) {
(*out) = this->Makefile->GetDefinition(internalRunOutputName);
}
}
diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h
index c27b026ad..c53a69474 100644
--- a/Source/cmTryRunCommand.h
+++ b/Source/cmTryRunCommand.h
@@ -3,20 +3,22 @@
#ifndef cmTryRunCommand_h
#define cmTryRunCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
+#include <cm/memory>
+
+#include "cmCommand.h"
#include "cmCoreTryCompile.h"
-class cmCommand;
class cmExecutionStatus;
/** \class cmTryRunCommand
* \brief Specifies where to install some files
*
- * cmTryRunCommand is used to test if soucre code can be compiled
+ * cmTryRunCommand is used to test if source code can be compiled
*/
class cmTryRunCommand : public cmCoreTryCompile
{
@@ -24,14 +26,17 @@ public:
/**
* This is a virtual constructor for the command.
*/
- cmCommand* Clone() CM_OVERRIDE { return new cmTryRunCommand; }
+ std::unique_ptr<cmCommand> Clone() override
+ {
+ return cm::make_unique<cmTryRunCommand>();
+ }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
+ cmExecutionStatus& status) override;
private:
void RunExecutable(const std::string& runArgs,
diff --git a/Source/cmUVHandlePtr.cxx b/Source/cmUVHandlePtr.cxx
new file mode 100644
index 000000000..23dabb770
--- /dev/null
+++ b/Source/cmUVHandlePtr.cxx
@@ -0,0 +1,267 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#define cmUVHandlePtr_cxx
+#include "cmUVHandlePtr.h"
+
+#include <cassert>
+#include <cstdlib>
+#include <mutex>
+
+#include "cm_uv.h"
+
+namespace cm {
+
+struct uv_loop_deleter
+{
+ void operator()(uv_loop_t* loop) const;
+};
+
+void uv_loop_deleter::operator()(uv_loop_t* loop) const
+{
+ uv_run(loop, UV_RUN_DEFAULT);
+ int result = uv_loop_close(loop);
+ (void)result;
+ assert(result >= 0);
+ free(loop);
+}
+
+int uv_loop_ptr::init(void* data)
+{
+ this->reset();
+
+ this->loop.reset(static_cast<uv_loop_t*>(calloc(1, sizeof(uv_loop_t))),
+ uv_loop_deleter());
+ this->loop->data = data;
+
+ return uv_loop_init(this->loop.get());
+}
+
+void uv_loop_ptr::reset()
+{
+ this->loop.reset();
+}
+
+uv_loop_ptr::operator uv_loop_t*()
+{
+ return this->loop.get();
+}
+
+uv_loop_t* uv_loop_ptr::operator->() const noexcept
+{
+ return this->loop.get();
+}
+
+uv_loop_t* uv_loop_ptr::get() const
+{
+ return this->loop.get();
+}
+
+template <typename T>
+static void handle_default_delete(T* type_handle)
+{
+ auto handle = reinterpret_cast<uv_handle_t*>(type_handle);
+ if (handle) {
+ assert(!uv_is_closing(handle));
+ if (!uv_is_closing(handle)) {
+ uv_close(handle, [](uv_handle_t* h) { free(h); });
+ }
+ }
+}
+
+/**
+ * Encapsulates delete logic for a given handle type T
+ */
+template <typename T>
+struct uv_handle_deleter
+{
+ void operator()(T* type_handle) const { handle_default_delete(type_handle); }
+};
+
+template <typename T>
+void uv_handle_ptr_base_<T>::allocate(void* data)
+{
+ reset();
+
+ /*
+ We use calloc since we know all these types are c structs
+ and we just want to 0 init them. New would do the same thing;
+ but casting from uv_handle_t to certain other types -- namely
+ uv_timer_t -- triggers a cast_align warning on certain systems.
+ */
+ handle.reset(static_cast<T*>(calloc(1, sizeof(T))), uv_handle_deleter<T>());
+ handle->data = data;
+}
+
+template <typename T>
+void uv_handle_ptr_base_<T>::reset()
+{
+ handle.reset();
+}
+
+template <typename T>
+uv_handle_ptr_base_<T>::operator uv_handle_t*()
+{
+ return reinterpret_cast<uv_handle_t*>(handle.get());
+}
+
+template <typename T>
+T* uv_handle_ptr_base_<T>::operator->() const noexcept
+{
+ return handle.get();
+}
+
+template <typename T>
+T* uv_handle_ptr_base_<T>::get() const
+{
+ return handle.get();
+}
+
+template <typename T>
+uv_handle_ptr_<T>::operator T*() const
+{
+ return this->handle.get();
+}
+
+#ifndef CMAKE_BOOTSTRAP
+template <>
+struct uv_handle_deleter<uv_async_t>
+{
+ /***
+ * Wile uv_async_send is itself thread-safe, there are
+ * no strong guarantees that close hasn't already been
+ * called on the handle; and that it might be deleted
+ * as the send call goes through. This mutex guards
+ * against that.
+ *
+ * The shared_ptr here is to allow for copy construction
+ * which is mandated by the standard for Deleter on
+ * shared_ptrs.
+ */
+ std::shared_ptr<std::mutex> handleMutex;
+
+ uv_handle_deleter()
+ : handleMutex(std::make_shared<std::mutex>())
+ {
+ }
+
+ void operator()(uv_async_t* handle)
+ {
+ std::lock_guard<std::mutex> lock(*handleMutex);
+ handle_default_delete(handle);
+ }
+};
+
+void uv_async_ptr::send()
+{
+ auto deleter = std::get_deleter<uv_handle_deleter<uv_async_t>>(this->handle);
+ assert(deleter);
+
+ std::lock_guard<std::mutex> lock(*deleter->handleMutex);
+ if (this->handle) {
+ uv_async_send(*this);
+ }
+}
+
+int uv_async_ptr::init(uv_loop_t& loop, uv_async_cb async_cb, void* data)
+{
+ allocate(data);
+ return uv_async_init(&loop, handle.get(), async_cb);
+}
+#endif
+
+template <>
+struct uv_handle_deleter<uv_signal_t>
+{
+ void operator()(uv_signal_t* handle) const
+ {
+ if (handle) {
+ uv_signal_stop(handle);
+ handle_default_delete(handle);
+ }
+ }
+};
+
+int uv_signal_ptr::init(uv_loop_t& loop, void* data)
+{
+ allocate(data);
+ return uv_signal_init(&loop, handle.get());
+}
+
+int uv_signal_ptr::start(uv_signal_cb cb, int signum)
+{
+ assert(handle);
+ return uv_signal_start(*this, cb, signum);
+}
+
+void uv_signal_ptr::stop()
+{
+ if (handle) {
+ uv_signal_stop(*this);
+ }
+}
+
+int uv_pipe_ptr::init(uv_loop_t& loop, int ipc, void* data)
+{
+ allocate(data);
+ return uv_pipe_init(&loop, *this, ipc);
+}
+
+uv_pipe_ptr::operator uv_stream_t*() const
+{
+ return reinterpret_cast<uv_stream_t*>(handle.get());
+}
+
+int uv_process_ptr::spawn(uv_loop_t& loop, uv_process_options_t const& options,
+ void* data)
+{
+ allocate(data);
+ return uv_spawn(&loop, *this, &options);
+}
+
+int uv_timer_ptr::init(uv_loop_t& loop, void* data)
+{
+ allocate(data);
+ return uv_timer_init(&loop, *this);
+}
+
+int uv_timer_ptr::start(uv_timer_cb cb, uint64_t timeout, uint64_t repeat)
+{
+ assert(handle);
+ return uv_timer_start(*this, cb, timeout, repeat);
+}
+
+#ifndef CMAKE_BOOTSTRAP
+uv_tty_ptr::operator uv_stream_t*() const
+{
+ return reinterpret_cast<uv_stream_t*>(handle.get());
+}
+
+int uv_tty_ptr::init(uv_loop_t& loop, int fd, int readable, void* data)
+{
+ allocate(data);
+ return uv_tty_init(&loop, *this, fd, readable);
+}
+#endif
+
+template class uv_handle_ptr_base_<uv_handle_t>;
+
+#define UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(NAME) \
+ template class uv_handle_ptr_base_<uv_##NAME##_t>; \
+ template class uv_handle_ptr_<uv_##NAME##_t>;
+
+UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(signal)
+
+UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(pipe)
+
+UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(stream)
+
+UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(process)
+
+UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(timer)
+
+#ifndef CMAKE_BOOTSTRAP
+UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(async)
+
+UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(tty)
+#endif
+}
diff --git a/Source/cmUVHandlePtr.h b/Source/cmUVHandlePtr.h
new file mode 100644
index 000000000..3083b60c8
--- /dev/null
+++ b/Source/cmUVHandlePtr.h
@@ -0,0 +1,271 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#pragma once
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <cstddef>
+#include <cstdint>
+#include <memory>
+#include <type_traits>
+
+#include "cm_uv.h"
+
+#if defined(__SUNPRO_CC)
+
+# include <utility>
+
+# define CM_INHERIT_CTOR(Class, Base, Tpl) \
+ template <typename... Args> \
+ Class(Args&&... args) \
+ : Base Tpl(std::forward<Args>(args)...) \
+ { \
+ }
+
+#else
+
+# define CM_INHERIT_CTOR(Class, Base, Tpl) using Base Tpl ::Base;
+
+#endif
+
+namespace cm {
+
+/***
+ * RAII class to simplify and ensure the safe usage of uv_loop_t. This includes
+ * making sure resources are properly freed.
+ */
+class uv_loop_ptr
+{
+protected:
+ std::shared_ptr<uv_loop_t> loop;
+
+public:
+ uv_loop_ptr(uv_loop_ptr const&) = delete;
+ uv_loop_ptr& operator=(uv_loop_ptr const&) = delete;
+ uv_loop_ptr(uv_loop_ptr&&) noexcept;
+ uv_loop_ptr& operator=(uv_loop_ptr&&) noexcept;
+
+ // Dtor and ctor need to be inline defined like this for default ctors and
+ // dtors to work. Some compilers do not like '= default' here.
+ uv_loop_ptr() {} // NOLINT(modernize-use-equals-default)
+ uv_loop_ptr(std::nullptr_t) {}
+ ~uv_loop_ptr() { this->reset(); }
+
+ int init(void* data = nullptr);
+
+ /**
+ * Properly close the handle if needed and sets the inner handle to nullptr
+ */
+ void reset();
+
+ /**
+ * Allow less verbose calling of uv_loop_* functions
+ * @return reinterpreted handle
+ */
+ operator uv_loop_t*();
+
+ uv_loop_t* get() const;
+ uv_loop_t* operator->() const noexcept;
+};
+
+/***
+ * RAII class to simplify and ensure the safe usage of uv_*_t types. This
+ * includes making sure resources are properly freed and contains casting
+ * operators which allow for passing into relevant uv_* functions.
+ *
+ *@tparam T actual uv_*_t type represented.
+ */
+template <typename T>
+class uv_handle_ptr_base_
+{
+protected:
+ template <typename _T>
+ friend class uv_handle_ptr_base_;
+
+ /**
+ * This must be a pointer type since the handle can outlive this class.
+ * When uv_close is eventually called on the handle, the memory the
+ * handle inhabits must be valid until the close callback is called
+ * which can be later on in the loop.
+ */
+ std::shared_ptr<T> handle;
+
+ /**
+ * Allocate memory for the type and optionally set it's 'data' pointer.
+ * Protected since this should only be called for an appropriate 'init'
+ * call.
+ *
+ * @param data data pointer to set
+ */
+ void allocate(void* data = nullptr);
+
+public:
+ uv_handle_ptr_base_(uv_handle_ptr_base_ const&) = delete;
+ uv_handle_ptr_base_& operator=(uv_handle_ptr_base_ const&) = delete;
+ uv_handle_ptr_base_(uv_handle_ptr_base_&&) noexcept;
+ uv_handle_ptr_base_& operator=(uv_handle_ptr_base_&&) noexcept;
+
+ /**
+ * This move constructor allows us to move out of a more specialized
+ * uv type into a less specialized one. The only constraint is that
+ * the right hand side is castable to T.
+ *
+ * This allows you to return uv_handle_ptr or uv_stream_ptr from a function
+ * that initializes something like uv_pipe_ptr or uv_tcp_ptr and interact
+ * and clean up after it without caring about the exact type.
+ */
+ template <typename S,
+ typename = typename std::enable_if<
+ std::is_rvalue_reference<S&&>::value>::type>
+ uv_handle_ptr_base_(S&& rhs)
+ {
+ // This will force a compiler error if rhs doesn't have a casting
+ // operator to get T*
+ this->handle = std::shared_ptr<T>(rhs.handle, rhs);
+ rhs.handle.reset();
+ }
+
+ // Dtor and ctor need to be inline defined like this for default ctors and
+ // dtors to work. Some compilers do not like '= default' here.
+ uv_handle_ptr_base_() {} // NOLINT(modernize-use-equals-default)
+ uv_handle_ptr_base_(std::nullptr_t) {}
+ ~uv_handle_ptr_base_() { reset(); }
+
+ /**
+ * Properly close the handle if needed and sets the inner handle to nullptr
+ */
+ void reset();
+
+ /**
+ * Allow less verbose calling of uv_handle_* functions
+ * @return reinterpreted handle
+ */
+ operator uv_handle_t*();
+
+ T* get() const;
+ T* operator->() const noexcept;
+};
+
+template <typename T>
+inline uv_handle_ptr_base_<T>::uv_handle_ptr_base_(
+ uv_handle_ptr_base_<T>&&) noexcept = default;
+template <typename T>
+inline uv_handle_ptr_base_<T>& uv_handle_ptr_base_<T>::operator=(
+ uv_handle_ptr_base_<T>&&) noexcept = default;
+
+/**
+ * While uv_handle_ptr_base_ only exposes uv_handle_t*, this exposes uv_T_t*
+ * too. It is broken out like this so we can reuse most of the code for the
+ * uv_handle_ptr class.
+ */
+template <typename T>
+class uv_handle_ptr_ : public uv_handle_ptr_base_<T>
+{
+ template <typename _T>
+ friend class uv_handle_ptr_;
+
+public:
+ CM_INHERIT_CTOR(uv_handle_ptr_, uv_handle_ptr_base_, <T>);
+
+ /***
+ * Allow less verbose calling of uv_<T> functions
+ * @return reinterpreted handle
+ */
+ operator T*() const;
+};
+
+/***
+ * This specialization is required to avoid duplicate 'operator uv_handle_t*()'
+ * declarations
+ */
+template <>
+class uv_handle_ptr_<uv_handle_t> : public uv_handle_ptr_base_<uv_handle_t>
+{
+public:
+ CM_INHERIT_CTOR(uv_handle_ptr_, uv_handle_ptr_base_, <uv_handle_t>);
+};
+
+class uv_async_ptr : public uv_handle_ptr_<uv_async_t>
+{
+public:
+ CM_INHERIT_CTOR(uv_async_ptr, uv_handle_ptr_, <uv_async_t>);
+
+ int init(uv_loop_t& loop, uv_async_cb async_cb, void* data = nullptr);
+
+ void send();
+};
+
+struct uv_signal_ptr : public uv_handle_ptr_<uv_signal_t>
+{
+ CM_INHERIT_CTOR(uv_signal_ptr, uv_handle_ptr_, <uv_signal_t>);
+
+ int init(uv_loop_t& loop, void* data = nullptr);
+
+ int start(uv_signal_cb cb, int signum);
+
+ void stop();
+};
+
+struct uv_pipe_ptr : public uv_handle_ptr_<uv_pipe_t>
+{
+ CM_INHERIT_CTOR(uv_pipe_ptr, uv_handle_ptr_, <uv_pipe_t>);
+
+ operator uv_stream_t*() const;
+
+ int init(uv_loop_t& loop, int ipc, void* data = nullptr);
+};
+
+struct uv_process_ptr : public uv_handle_ptr_<uv_process_t>
+{
+ CM_INHERIT_CTOR(uv_process_ptr, uv_handle_ptr_, <uv_process_t>);
+
+ int spawn(uv_loop_t& loop, uv_process_options_t const& options,
+ void* data = nullptr);
+};
+
+struct uv_timer_ptr : public uv_handle_ptr_<uv_timer_t>
+{
+ CM_INHERIT_CTOR(uv_timer_ptr, uv_handle_ptr_, <uv_timer_t>);
+
+ int init(uv_loop_t& loop, void* data = nullptr);
+
+ int start(uv_timer_cb cb, uint64_t timeout, uint64_t repeat);
+};
+
+struct uv_tty_ptr : public uv_handle_ptr_<uv_tty_t>
+{
+ CM_INHERIT_CTOR(uv_tty_ptr, uv_handle_ptr_, <uv_tty_t>);
+
+ operator uv_stream_t*() const;
+
+ int init(uv_loop_t& loop, int fd, int readable, void* data = nullptr);
+};
+
+using uv_stream_ptr = uv_handle_ptr_<uv_stream_t>;
+using uv_handle_ptr = uv_handle_ptr_<uv_handle_t>;
+
+#ifndef cmUVHandlePtr_cxx
+
+extern template class uv_handle_ptr_base_<uv_handle_t>;
+
+# define UV_HANDLE_PTR_INSTANTIATE_EXTERN(NAME) \
+ extern template class uv_handle_ptr_base_<uv_##NAME##_t>; \
+ extern template class uv_handle_ptr_<uv_##NAME##_t>;
+
+UV_HANDLE_PTR_INSTANTIATE_EXTERN(async)
+
+UV_HANDLE_PTR_INSTANTIATE_EXTERN(signal)
+
+UV_HANDLE_PTR_INSTANTIATE_EXTERN(pipe)
+
+UV_HANDLE_PTR_INSTANTIATE_EXTERN(process)
+
+UV_HANDLE_PTR_INSTANTIATE_EXTERN(stream)
+
+UV_HANDLE_PTR_INSTANTIATE_EXTERN(timer)
+
+UV_HANDLE_PTR_INSTANTIATE_EXTERN(tty)
+
+# undef UV_HANDLE_PTR_INSTANTIATE_EXTERN
+
+#endif
+}
diff --git a/Source/cmUVProcessChain.cxx b/Source/cmUVProcessChain.cxx
new file mode 100644
index 000000000..543c3308a
--- /dev/null
+++ b/Source/cmUVProcessChain.cxx
@@ -0,0 +1,396 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmUVProcessChain.h"
+
+#include <cassert>
+#include <istream> // IWYU pragma: keep
+#include <iterator>
+#include <utility>
+
+#include <cm/memory>
+
+#include "cm_uv.h"
+
+#include "cmGetPipes.h"
+#include "cmUVHandlePtr.h"
+#include "cmUVStreambuf.h"
+
+struct cmUVProcessChain::InternalData
+{
+ struct BasicStreamData
+ {
+ cmUVStreambuf Streambuf;
+ cm::uv_pipe_ptr BuiltinStream;
+ uv_stdio_container_t Stdio;
+ };
+
+ template <typename IOStream>
+ struct StreamData : public BasicStreamData
+ {
+ StreamData()
+ : BuiltinIOStream(&this->Streambuf)
+ {
+ }
+
+ IOStream BuiltinIOStream;
+
+ IOStream* GetBuiltinStream()
+ {
+ if (this->BuiltinStream.get()) {
+ return &this->BuiltinIOStream;
+ }
+ return nullptr;
+ }
+ };
+
+ struct ProcessData
+ {
+ cmUVProcessChain::InternalData* Data;
+ cm::uv_process_ptr Process;
+ cm::uv_pipe_ptr OutputPipe;
+ bool Finished = false;
+ Status ProcessStatus;
+ };
+
+ const cmUVProcessChainBuilder* Builder = nullptr;
+
+ bool Valid = false;
+
+ cm::uv_loop_ptr Loop;
+
+ StreamData<std::istream> OutputStreamData;
+ StreamData<std::istream> ErrorStreamData;
+
+ unsigned int ProcessesCompleted = 0;
+ std::vector<std::unique_ptr<ProcessData>> Processes;
+
+ bool Prepare(const cmUVProcessChainBuilder* builder);
+ bool AddCommand(const cmUVProcessChainBuilder::ProcessConfiguration& config,
+ bool first, bool last);
+ bool Finish();
+
+ static const Status* GetStatus(const ProcessData& data);
+};
+
+cmUVProcessChainBuilder::cmUVProcessChainBuilder()
+{
+ this->SetNoStream(Stream_INPUT)
+ .SetNoStream(Stream_OUTPUT)
+ .SetNoStream(Stream_ERROR);
+}
+
+cmUVProcessChainBuilder& cmUVProcessChainBuilder::AddCommand(
+ const std::vector<std::string>& arguments)
+{
+ if (!arguments.empty()) {
+ this->Processes.emplace_back();
+ this->Processes.back().Arguments = arguments;
+ }
+ return *this;
+}
+
+cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetNoStream(Stream stdio)
+{
+ switch (stdio) {
+ case Stream_INPUT:
+ case Stream_OUTPUT:
+ case Stream_ERROR: {
+ auto& streamData = this->Stdio[stdio];
+ streamData.Type = None;
+ break;
+ }
+ }
+ return *this;
+}
+
+cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetBuiltinStream(
+ Stream stdio)
+{
+ switch (stdio) {
+ case Stream_INPUT:
+ // FIXME
+ break;
+
+ case Stream_OUTPUT:
+ case Stream_ERROR: {
+ auto& streamData = this->Stdio[stdio];
+ streamData.Type = Builtin;
+ break;
+ }
+ }
+ return *this;
+}
+
+cmUVProcessChainBuilder& cmUVProcessChainBuilder::SetExternalStream(
+ Stream stdio, int fd)
+{
+ switch (stdio) {
+ case Stream_INPUT:
+ // FIXME
+ break;
+
+ case Stream_OUTPUT:
+ case Stream_ERROR: {
+ auto& streamData = this->Stdio[stdio];
+ streamData.Type = External;
+ streamData.FileDescriptor = fd;
+ break;
+ }
+ }
+ return *this;
+}
+
+cmUVProcessChain cmUVProcessChainBuilder::Start() const
+{
+ cmUVProcessChain chain;
+
+ if (!chain.Data->Prepare(this)) {
+ return chain;
+ }
+
+ for (auto it = this->Processes.begin(); it != this->Processes.end(); ++it) {
+ if (!chain.Data->AddCommand(*it, it == this->Processes.begin(),
+ it == std::prev(this->Processes.end()))) {
+ return chain;
+ }
+ }
+
+ chain.Data->Finish();
+
+ return chain;
+}
+
+const cmUVProcessChain::Status* cmUVProcessChain::InternalData::GetStatus(
+ const cmUVProcessChain::InternalData::ProcessData& data)
+{
+ if (data.Finished) {
+ return &data.ProcessStatus;
+ }
+ return nullptr;
+}
+
+bool cmUVProcessChain::InternalData::Prepare(
+ const cmUVProcessChainBuilder* builder)
+{
+ this->Builder = builder;
+
+ auto const& output =
+ this->Builder->Stdio[cmUVProcessChainBuilder::Stream_OUTPUT];
+ auto& outputData = this->OutputStreamData;
+ switch (output.Type) {
+ case cmUVProcessChainBuilder::None:
+ outputData.Stdio.flags = UV_IGNORE;
+ break;
+
+ case cmUVProcessChainBuilder::Builtin:
+ outputData.BuiltinStream.init(*this->Loop, 0);
+ outputData.Stdio.flags =
+ static_cast<uv_stdio_flags>(UV_CREATE_PIPE | UV_WRITABLE_PIPE);
+ outputData.Stdio.data.stream = outputData.BuiltinStream;
+ break;
+
+ case cmUVProcessChainBuilder::External:
+ outputData.Stdio.flags = UV_INHERIT_FD;
+ outputData.Stdio.data.fd = output.FileDescriptor;
+ break;
+ }
+
+ auto const& error =
+ this->Builder->Stdio[cmUVProcessChainBuilder::Stream_ERROR];
+ auto& errorData = this->ErrorStreamData;
+ switch (error.Type) {
+ case cmUVProcessChainBuilder::None:
+ errorData.Stdio.flags = UV_IGNORE;
+ break;
+
+ case cmUVProcessChainBuilder::Builtin: {
+ int pipeFd[2];
+ if (cmGetPipes(pipeFd) < 0) {
+ return false;
+ }
+
+ errorData.BuiltinStream.init(*this->Loop, 0);
+ if (uv_pipe_open(errorData.BuiltinStream, pipeFd[0]) < 0) {
+ return false;
+ }
+ errorData.Stdio.flags = UV_INHERIT_FD;
+ errorData.Stdio.data.fd = pipeFd[1];
+ break;
+ }
+
+ case cmUVProcessChainBuilder::External:
+ errorData.Stdio.flags = UV_INHERIT_FD;
+ errorData.Stdio.data.fd = error.FileDescriptor;
+ break;
+ }
+
+ return true;
+}
+
+bool cmUVProcessChain::InternalData::AddCommand(
+ const cmUVProcessChainBuilder::ProcessConfiguration& config, bool first,
+ bool last)
+{
+ this->Processes.emplace_back(cm::make_unique<ProcessData>());
+ auto& process = *this->Processes.back();
+ process.Data = this;
+
+ auto options = uv_process_options_t();
+
+ // Bounds were checked at add time, first element is guaranteed to exist
+ options.file = config.Arguments[0].c_str();
+
+ std::vector<const char*> arguments;
+ for (auto const& arg : config.Arguments) {
+ arguments.push_back(arg.c_str());
+ }
+ arguments.push_back(nullptr);
+ options.args = const_cast<char**>(arguments.data());
+ options.flags = UV_PROCESS_WINDOWS_HIDE;
+
+ std::array<uv_stdio_container_t, 3> stdio;
+ stdio[0] = uv_stdio_container_t();
+ if (first) {
+ stdio[0].flags = UV_IGNORE;
+ } else {
+ assert(this->Processes.size() >= 2);
+ auto& prev = *this->Processes[this->Processes.size() - 2];
+ stdio[0].flags = UV_INHERIT_STREAM;
+ stdio[0].data.stream = prev.OutputPipe;
+ }
+ if (last) {
+ stdio[1] = this->OutputStreamData.Stdio;
+ } else {
+ if (process.OutputPipe.init(*this->Loop, 0) < 0) {
+ return false;
+ }
+ stdio[1] = uv_stdio_container_t();
+ stdio[1].flags =
+ static_cast<uv_stdio_flags>(UV_CREATE_PIPE | UV_WRITABLE_PIPE);
+ stdio[1].data.stream = process.OutputPipe;
+ }
+ stdio[2] = this->ErrorStreamData.Stdio;
+
+ options.stdio = stdio.data();
+ options.stdio_count = 3;
+ options.exit_cb = [](uv_process_t* handle, int64_t exitStatus,
+ int termSignal) {
+ auto* processData = static_cast<ProcessData*>(handle->data);
+ processData->Finished = true;
+ processData->ProcessStatus.ExitStatus = exitStatus;
+ processData->ProcessStatus.TermSignal = termSignal;
+ processData->Data->ProcessesCompleted++;
+ };
+
+ return process.Process.spawn(*this->Loop, options, &process) >= 0;
+}
+
+bool cmUVProcessChain::InternalData::Finish()
+{
+ if (this->Builder->Stdio[cmUVProcessChainBuilder::Stream_OUTPUT].Type ==
+ cmUVProcessChainBuilder::Builtin) {
+ this->OutputStreamData.Streambuf.open(
+ this->OutputStreamData.BuiltinStream);
+ }
+
+ if (this->Builder->Stdio[cmUVProcessChainBuilder::Stream_ERROR].Type ==
+ cmUVProcessChainBuilder::Builtin) {
+ cm::uv_pipe_ptr tmpPipe;
+ if (tmpPipe.init(*this->Loop, 0) < 0) {
+ return false;
+ }
+ if (uv_pipe_open(tmpPipe, this->ErrorStreamData.Stdio.data.fd) < 0) {
+ return false;
+ }
+ tmpPipe.reset();
+
+ this->ErrorStreamData.Streambuf.open(this->ErrorStreamData.BuiltinStream);
+ }
+
+ this->Valid = true;
+ return true;
+}
+
+cmUVProcessChain::cmUVProcessChain()
+ : Data(cm::make_unique<InternalData>())
+{
+ this->Data->Loop.init();
+}
+
+cmUVProcessChain::cmUVProcessChain(cmUVProcessChain&& other) noexcept
+ : Data(std::move(other.Data))
+{
+}
+
+cmUVProcessChain::~cmUVProcessChain() = default;
+
+cmUVProcessChain& cmUVProcessChain::operator=(
+ cmUVProcessChain&& other) noexcept
+{
+ this->Data = std::move(other.Data);
+ return *this;
+}
+
+uv_loop_t& cmUVProcessChain::GetLoop()
+{
+ return *this->Data->Loop;
+}
+
+std::istream* cmUVProcessChain::OutputStream()
+{
+ return this->Data->OutputStreamData.GetBuiltinStream();
+}
+
+std::istream* cmUVProcessChain::ErrorStream()
+{
+ return this->Data->ErrorStreamData.GetBuiltinStream();
+}
+
+bool cmUVProcessChain::Valid() const
+{
+ return this->Data->Valid;
+}
+
+bool cmUVProcessChain::Wait(int64_t milliseconds)
+{
+ bool timeout = false;
+ cm::uv_timer_ptr timer;
+
+ if (milliseconds >= 0) {
+ timer.init(*this->Data->Loop, &timeout);
+ timer.start(
+ [](uv_timer_t* handle) {
+ auto* timeoutPtr = static_cast<bool*>(handle->data);
+ *timeoutPtr = true;
+ },
+ milliseconds, 0);
+ }
+
+ while (!timeout &&
+ this->Data->ProcessesCompleted < this->Data->Processes.size()) {
+ uv_run(this->Data->Loop, UV_RUN_ONCE);
+ }
+
+ return !timeout;
+}
+
+std::vector<const cmUVProcessChain::Status*> cmUVProcessChain::GetStatus()
+ const
+{
+ std::vector<const cmUVProcessChain::Status*> statuses(
+ this->Data->Processes.size(), nullptr);
+ for (std::size_t i = 0; i < statuses.size(); i++) {
+ statuses[i] = this->GetStatus(i);
+ }
+ return statuses;
+}
+
+const cmUVProcessChain::Status* cmUVProcessChain::GetStatus(
+ std::size_t index) const
+{
+ auto const& process = *this->Data->Processes[index];
+ if (process.Finished) {
+ return &process.ProcessStatus;
+ }
+ return nullptr;
+}
diff --git a/Source/cmUVProcessChain.h b/Source/cmUVProcessChain.h
new file mode 100644
index 000000000..05a7cc82c
--- /dev/null
+++ b/Source/cmUVProcessChain.h
@@ -0,0 +1,100 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmUVProcessChain_h
+#define cmUVProcessChain_h
+
+#include <array>
+#include <cstddef>
+#include <cstdint>
+#include <iosfwd>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "cm_uv.h"
+
+class cmUVProcessChain;
+
+class cmUVProcessChainBuilder
+{
+public:
+ enum Stream
+ {
+ Stream_INPUT = 0,
+ Stream_OUTPUT = 1,
+ Stream_ERROR = 2,
+ };
+
+ cmUVProcessChainBuilder();
+
+ cmUVProcessChainBuilder& AddCommand(
+ const std::vector<std::string>& arguments);
+ cmUVProcessChainBuilder& SetNoStream(Stream stdio);
+ cmUVProcessChainBuilder& SetBuiltinStream(Stream stdio);
+ cmUVProcessChainBuilder& SetExternalStream(Stream stdio, int fd);
+
+ cmUVProcessChain Start() const;
+
+private:
+ enum StdioType
+ {
+ None,
+ Builtin,
+ External,
+ };
+
+ friend class cmUVProcessChain;
+
+ struct StdioConfiguration
+ {
+ StdioType Type;
+ int FileDescriptor;
+ };
+
+ struct ProcessConfiguration
+ {
+ std::vector<std::string> Arguments;
+ };
+
+ std::array<StdioConfiguration, 3> Stdio;
+ std::vector<ProcessConfiguration> Processes;
+};
+
+class cmUVProcessChain
+{
+public:
+ struct Status
+ {
+ int64_t ExitStatus;
+ int TermSignal;
+ };
+
+ cmUVProcessChain(const cmUVProcessChain& other) = delete;
+ cmUVProcessChain(cmUVProcessChain&& other) noexcept;
+
+ ~cmUVProcessChain();
+
+ cmUVProcessChain& operator=(const cmUVProcessChain& other) = delete;
+ cmUVProcessChain& operator=(cmUVProcessChain&& other) noexcept;
+
+ uv_loop_t& GetLoop();
+
+ // FIXME: Add stdin support
+ std::istream* OutputStream();
+ std::istream* ErrorStream();
+
+ bool Valid() const;
+ bool Wait(int64_t milliseconds = -1);
+ std::vector<const Status*> GetStatus() const;
+ const Status* GetStatus(std::size_t index) const;
+
+private:
+ friend class cmUVProcessChainBuilder;
+
+ cmUVProcessChain();
+
+ struct InternalData;
+ std::unique_ptr<InternalData> Data;
+};
+
+#endif
diff --git a/Source/cmUVSignalHackRAII.h b/Source/cmUVSignalHackRAII.h
new file mode 100644
index 000000000..63599db82
--- /dev/null
+++ b/Source/cmUVSignalHackRAII.h
@@ -0,0 +1,45 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#pragma once
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include "cm_uv.h"
+
+#if defined(CMAKE_USE_SYSTEM_LIBUV) && !defined(_WIN32) && \
+ UV_VERSION_MAJOR == 1 && UV_VERSION_MINOR < 19
+# define CMAKE_UV_SIGNAL_HACK
+# include "cmUVHandlePtr.h"
+/*
+ libuv does not use SA_RESTART on its signal handler, but C++ streams
+ depend on it for reliable i/o operations. This RAII helper convinces
+ libuv to install its handler, and then revises the handler to add the
+ SA_RESTART flag. We use a distinct uv loop that never runs to avoid
+ ever really getting a callback. libuv may fill the hack loop's signal
+ pipe and then stop writing, but that won't break any real loops.
+ */
+class cmUVSignalHackRAII
+{
+ uv_loop_t HackLoop;
+ cm::uv_signal_ptr HackSignal;
+ static void HackCB(uv_signal_t*, int) {}
+
+public:
+ cmUVSignalHackRAII()
+ {
+ uv_loop_init(&this->HackLoop);
+ this->HackSignal.init(this->HackLoop);
+ this->HackSignal.start(HackCB, SIGCHLD);
+ struct sigaction hack_sa;
+ sigaction(SIGCHLD, nullptr, &hack_sa);
+ if (!(hack_sa.sa_flags & SA_RESTART)) {
+ hack_sa.sa_flags |= SA_RESTART;
+ sigaction(SIGCHLD, &hack_sa, nullptr);
+ }
+ }
+ ~cmUVSignalHackRAII()
+ {
+ this->HackSignal.stop();
+ uv_loop_close(&this->HackLoop);
+ }
+};
+#endif
diff --git a/Source/cmUVStreambuf.h b/Source/cmUVStreambuf.h
new file mode 100644
index 000000000..1c8a7717c
--- /dev/null
+++ b/Source/cmUVStreambuf.h
@@ -0,0 +1,219 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmUVStreambuf_h
+#define cmUVStreambuf_h
+
+#include <algorithm>
+#include <cstring>
+#include <streambuf>
+#include <vector>
+
+#include "cm_uv.h"
+
+#include "cmUVHandlePtr.h"
+
+/*
+ * This file is based on example code from:
+ *
+ * http://www.voidcn.com/article/p-vjnlygmc-gy.html
+ *
+ * The example code was distributed under the following license:
+ *
+ * Copyright 2007 Edd Dawson.
+ * Distributed under the Boost Software License, Version 1.0.
+ *
+ * Boost Software License - Version 1.0 - August 17th, 2003
+ *
+ * Permission is hereby granted, free of charge, to any person or organization
+ * obtaining a copy of the software and accompanying documentation covered by
+ * this license (the "Software") to use, reproduce, display, distribute,
+ * execute, and transmit the Software, and to prepare derivative works of the
+ * Software, and to permit third-parties to whom the Software is furnished to
+ * do so, all subject to the following:
+ *
+ * The copyright notices in the Software and this entire statement, including
+ * the above license grant, this restriction and the following disclaimer,
+ * must be included in all copies of the Software, in whole or in part, and
+ * all derivative works of the Software, unless such copies or derivative
+ * works are solely in the form of machine-executable object code generated by
+ * a source language processor.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+ * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+ * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+template <typename CharT, typename Traits = std::char_traits<CharT>>
+class cmBasicUVStreambuf : public std::basic_streambuf<CharT, Traits>
+{
+public:
+ cmBasicUVStreambuf(std::size_t bufSize = 256, std::size_t putBack = 8);
+ ~cmBasicUVStreambuf() override;
+
+ bool is_open() const;
+
+ cmBasicUVStreambuf* open(uv_stream_t* stream);
+
+ cmBasicUVStreambuf* close();
+
+protected:
+ typename cmBasicUVStreambuf<CharT, Traits>::int_type underflow() override;
+ std::streamsize showmanyc() override;
+
+ // FIXME: Add write support
+
+private:
+ uv_stream_t* Stream = nullptr;
+ void* OldStreamData = nullptr;
+ const std::size_t PutBack = 0;
+ std::vector<CharT> InputBuffer;
+ bool EndOfFile = false;
+
+ void StreamReadStartStop();
+
+ void StreamRead(ssize_t nread);
+ void HandleAlloc(uv_buf_t* buf);
+};
+
+template <typename CharT, typename Traits>
+cmBasicUVStreambuf<CharT, Traits>::cmBasicUVStreambuf(std::size_t bufSize,
+ std::size_t putBack)
+ : PutBack(std::max<std::size_t>(putBack, 1))
+ , InputBuffer(std::max<std::size_t>(this->PutBack, bufSize) + this->PutBack)
+{
+ this->close();
+}
+
+template <typename CharT, typename Traits>
+cmBasicUVStreambuf<CharT, Traits>::~cmBasicUVStreambuf()
+{
+ this->close();
+}
+
+template <typename CharT, typename Traits>
+bool cmBasicUVStreambuf<CharT, Traits>::is_open() const
+{
+ return this->Stream != nullptr;
+}
+
+template <typename CharT, typename Traits>
+cmBasicUVStreambuf<CharT, Traits>* cmBasicUVStreambuf<CharT, Traits>::open(
+ uv_stream_t* stream)
+{
+ this->close();
+ this->Stream = stream;
+ this->EndOfFile = false;
+ if (this->Stream) {
+ this->OldStreamData = this->Stream->data;
+ this->Stream->data = this;
+ }
+ this->StreamReadStartStop();
+ return this;
+}
+
+template <typename CharT, typename Traits>
+cmBasicUVStreambuf<CharT, Traits>* cmBasicUVStreambuf<CharT, Traits>::close()
+{
+ if (this->Stream) {
+ uv_read_stop(this->Stream);
+ this->Stream->data = this->OldStreamData;
+ }
+ this->Stream = nullptr;
+ CharT* readEnd = this->InputBuffer.data() + this->InputBuffer.size();
+ this->setg(readEnd, readEnd, readEnd);
+ return this;
+}
+
+template <typename CharT, typename Traits>
+typename cmBasicUVStreambuf<CharT, Traits>::int_type
+cmBasicUVStreambuf<CharT, Traits>::underflow()
+{
+ if (!this->is_open()) {
+ return Traits::eof();
+ }
+
+ if (this->gptr() < this->egptr()) {
+ return Traits::to_int_type(*this->gptr());
+ }
+
+ this->StreamReadStartStop();
+ while (this->in_avail() == 0) {
+ uv_run(this->Stream->loop, UV_RUN_ONCE);
+ }
+ if (this->in_avail() == -1) {
+ return Traits::eof();
+ }
+ return Traits::to_int_type(*this->gptr());
+}
+
+template <typename CharT, typename Traits>
+std::streamsize cmBasicUVStreambuf<CharT, Traits>::showmanyc()
+{
+ if (!this->is_open() || this->EndOfFile) {
+ return -1;
+ }
+ return 0;
+}
+
+template <typename CharT, typename Traits>
+void cmBasicUVStreambuf<CharT, Traits>::StreamReadStartStop()
+{
+ if (this->Stream) {
+ uv_read_stop(this->Stream);
+ if (this->gptr() >= this->egptr()) {
+ uv_read_start(
+ this->Stream,
+ [](uv_handle_t* handle, size_t /* unused */, uv_buf_t* buf) {
+ auto streambuf =
+ static_cast<cmBasicUVStreambuf<CharT, Traits>*>(handle->data);
+ streambuf->HandleAlloc(buf);
+ },
+ [](uv_stream_t* stream2, ssize_t nread, const uv_buf_t* /* unused */) {
+ auto streambuf =
+ static_cast<cmBasicUVStreambuf<CharT, Traits>*>(stream2->data);
+ streambuf->StreamRead(nread);
+ });
+ }
+ }
+}
+
+template <typename CharT, typename Traits>
+void cmBasicUVStreambuf<CharT, Traits>::HandleAlloc(uv_buf_t* buf)
+{
+ auto size = this->egptr() - this->gptr();
+ std::memmove(this->InputBuffer.data(), this->gptr(),
+ this->egptr() - this->gptr());
+ this->setg(this->InputBuffer.data(), this->InputBuffer.data(),
+ this->InputBuffer.data() + size);
+ buf->base = this->egptr();
+#ifdef _WIN32
+# define BUF_LEN_TYPE ULONG
+#else
+# define BUF_LEN_TYPE size_t
+#endif
+ buf->len = BUF_LEN_TYPE(
+ (this->InputBuffer.data() + this->InputBuffer.size() - this->egptr()) *
+ sizeof(CharT));
+#undef BUF_LEN_TYPE
+}
+
+template <typename CharT, typename Traits>
+void cmBasicUVStreambuf<CharT, Traits>::StreamRead(ssize_t nread)
+{
+ if (nread > 0) {
+ this->setg(this->eback(), this->gptr(),
+ this->egptr() + nread / sizeof(CharT));
+ uv_read_stop(this->Stream);
+ } else if (nread < 0 /*|| nread == UV_EOF*/) {
+ this->EndOfFile = true;
+ uv_read_stop(this->Stream);
+ }
+}
+
+using cmUVStreambuf = cmBasicUVStreambuf<char>;
+
+#endif
diff --git a/Source/cmUnexpectedCommand.cxx b/Source/cmUnexpectedCommand.cxx
deleted file mode 100644
index a8de9e689..000000000
--- a/Source/cmUnexpectedCommand.cxx
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmUnexpectedCommand.h"
-
-#include <stdlib.h>
-
-#include "cmMakefile.h"
-
-class cmExecutionStatus;
-
-bool cmUnexpectedCommand::InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&)
-{
- const char* versionValue =
- this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
- if (this->Name == "endif" && (!versionValue || atof(versionValue) <= 1.4)) {
- return true;
- }
-
- this->SetError(this->Error);
- return false;
-}
diff --git a/Source/cmUnexpectedCommand.h b/Source/cmUnexpectedCommand.h
deleted file mode 100644
index 995d8a5d6..000000000
--- a/Source/cmUnexpectedCommand.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmUnexpectedCommand_h
-#define cmUnexpectedCommand_h
-
-#include "cmConfigure.h"
-
-#include <string>
-#include <vector>
-
-#include "cmCommand.h"
-
-class cmExecutionStatus;
-
-class cmUnexpectedCommand : public cmCommand
-{
-public:
- cmUnexpectedCommand(std::string const& name, const char* error)
- : Name(name)
- , Error(error)
- {
- }
-
- cmCommand* Clone() CM_OVERRIDE
- {
- return new cmUnexpectedCommand(this->Name, this->Error);
- }
-
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-private:
- std::string Name;
- const char* Error;
-};
-
-#endif
diff --git a/Source/cmUnsetCommand.cxx b/Source/cmUnsetCommand.cxx
index 31525ba4a..3ba95e99f 100644
--- a/Source/cmUnsetCommand.cxx
+++ b/Source/cmUnsetCommand.cxx
@@ -2,54 +2,48 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmUnsetCommand.h"
-#include <string.h>
-
-#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
// cmUnsetCommand
-bool cmUnsetCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmUnsetCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty() || args.size() > 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- const char* variable = args[0].c_str();
+ auto const& variable = args[0];
// unset(ENV{VAR})
- if (cmHasLiteralPrefix(variable, "ENV{") && strlen(variable) > 5) {
+ if (cmHasLiteralPrefix(variable, "ENV{") && variable.size() > 5) {
// what is the variable name
- char* envVarName = new char[strlen(variable)];
- strncpy(envVarName, variable + 4, strlen(variable) - 5);
- envVarName[strlen(variable) - 5] = '\0';
+ auto const& envVarName = variable.substr(4, variable.size() - 5);
-#ifdef CMAKE_BUILD_WITH_CMAKE
- cmSystemTools::UnsetEnv(envVarName);
+#ifndef CMAKE_BOOTSTRAP
+ cmSystemTools::UnsetEnv(envVarName.c_str());
#endif
- delete[] envVarName;
return true;
}
// unset(VAR)
if (args.size() == 1) {
- this->Makefile->RemoveDefinition(variable);
+ status.GetMakefile().RemoveDefinition(variable);
return true;
}
// unset(VAR CACHE)
if ((args.size() == 2) && (args[1] == "CACHE")) {
- this->Makefile->RemoveCacheDefinition(variable);
+ status.GetMakefile().RemoveCacheDefinition(variable);
return true;
}
// unset(VAR PARENT_SCOPE)
if ((args.size() == 2) && (args[1] == "PARENT_SCOPE")) {
- this->Makefile->RaiseScope(variable, CM_NULLPTR);
+ status.GetMakefile().RaiseScope(variable, nullptr);
return true;
}
// ERROR: second argument isn't CACHE or PARENT_SCOPE
- this->SetError("called with an invalid second argument");
+ status.SetError("called with an invalid second argument");
return false;
}
diff --git a/Source/cmUnsetCommand.h b/Source/cmUnsetCommand.h
index 2a1f3f0a6..be4c166e8 100644
--- a/Source/cmUnsetCommand.h
+++ b/Source/cmUnsetCommand.h
@@ -3,34 +3,19 @@
#ifndef cmUnsetCommand_h
#define cmUnsetCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmUnsetCommand
+/**
* \brief Unset a CMAKE variable
*
* cmUnsetCommand unsets or removes a variable.
*/
-class cmUnsetCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmUnsetCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmUnsetCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx
index 07095b137..1fd386bda 100644
--- a/Source/cmUseMangledMesaCommand.cxx
+++ b/Source/cmUseMangledMesaCommand.cxx
@@ -5,70 +5,67 @@
#include "cmsys/FStream.hxx"
#include "cmsys/RegularExpression.hxx"
+#include "cmExecutionStatus.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
+namespace {
+void CopyAndFullPathMesaHeader(const std::string& source,
+ const std::string& outdir);
+}
-bool cmUseMangledMesaCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmUseMangledMesaCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
// expected two arguments:
- // arguement one: the full path to gl_mangle.h
- // arguement two : directory for output of edited headers
+ // argument one: the full path to gl_mangle.h
+ // argument two : directory for output of edited headers
if (args.size() != 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- const char* inputDir = args[0].c_str();
- std::string glh = inputDir;
- glh += "/";
- glh += "gl.h";
- if (!cmSystemTools::FileExists(glh.c_str())) {
- std::string e = "Bad path to Mesa, could not find: ";
- e += glh;
- e += " ";
- this->SetError(e);
+ const std::string& inputDir = args[0];
+ std::string glh = cmStrCat(inputDir, "/gl.h");
+ if (!cmSystemTools::FileExists(glh)) {
+ std::string e = cmStrCat("Bad path to Mesa, could not find: ", glh, ' ');
+ status.SetError(e);
return false;
}
- const char* destDir = args[1].c_str();
+ const std::string& destDir = args[1];
std::vector<std::string> files;
cmSystemTools::Glob(inputDir, "\\.h$", files);
if (files.empty()) {
- cmSystemTools::Error("Could not open Mesa Directory ", inputDir);
+ cmSystemTools::Error("Could not open Mesa Directory " + inputDir);
return false;
}
cmSystemTools::MakeDirectory(destDir);
- for (std::vector<std::string>::iterator i = files.begin(); i != files.end();
- ++i) {
- std::string path = inputDir;
- path += "/";
- path += *i;
- this->CopyAndFullPathMesaHeader(path.c_str(), destDir);
+ for (std::string const& f : files) {
+ std::string path = cmStrCat(inputDir, '/', f);
+ CopyAndFullPathMesaHeader(path, destDir);
}
return true;
}
-void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(const char* source,
- const char* outdir)
+namespace {
+void CopyAndFullPathMesaHeader(const std::string& source,
+ const std::string& outdir)
{
- std::string dir, file;
+ std::string dir;
+ std::string file;
cmSystemTools::SplitProgramPath(source, dir, file);
- std::string outFile = outdir;
- outFile += "/";
- outFile += file;
- std::string tempOutputFile = outFile;
- tempOutputFile += ".tmp";
+ std::string outFile = cmStrCat(outdir, '/', file);
+ std::string tempOutputFile = cmStrCat(outFile, ".tmp");
cmsys::ofstream fout(tempOutputFile.c_str());
if (!fout) {
- cmSystemTools::Error("Could not open file for write in copy operation: ",
- tempOutputFile.c_str(), outdir);
+ cmSystemTools::Error("Could not open file for write in copy operation: " +
+ tempOutputFile + outdir);
cmSystemTools::ReportLastSystemError("");
return;
}
- cmsys::ifstream fin(source);
+ cmsys::ifstream fin(source.c_str());
if (!fin) {
- cmSystemTools::Error("Could not open file for read in copy operation",
+ cmSystemTools::Error("Could not open file for read in copy operation" +
source);
return;
}
@@ -79,16 +76,16 @@ void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(const char* source,
cmsys::RegularExpression includeLine(
"^[ \t]*#[ \t]*include[ \t]*[<\"]([^\">]+)[\">]");
// regular expression for gl/ or GL/ in a file (match(1) of above)
- cmsys::RegularExpression glDirLine("(gl|GL)(/|\\\\)([^<\"]+)");
+ cmsys::RegularExpression glDirLine(R"((gl|GL)(/|\\)([^<"]+))");
// regular expression for gl GL or xmesa in a file (match(1) of above)
cmsys::RegularExpression glLine("(gl|GL|xmesa)");
while (cmSystemTools::GetLineFromStream(fin, inLine)) {
- if (includeLine.find(inLine.c_str())) {
+ if (includeLine.find(inLine)) {
std::string includeFile = includeLine.match(1);
- if (glDirLine.find(includeFile.c_str())) {
+ if (glDirLine.find(includeFile)) {
std::string gfile = glDirLine.match(3);
fout << "#include \"" << outdir << "/" << gfile << "\"\n";
- } else if (glLine.find(includeFile.c_str())) {
+ } else if (glLine.find(includeFile)) {
fout << "#include \"" << outdir << "/" << includeLine.match(1)
<< "\"\n";
} else {
@@ -101,6 +98,6 @@ void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(const char* source,
// close the files before attempting to copy
fin.close();
fout.close();
- cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(), outFile.c_str());
- cmSystemTools::RemoveFile(tempOutputFile);
+ cmSystemTools::MoveFileIfDifferent(tempOutputFile, outFile);
+}
}
diff --git a/Source/cmUseMangledMesaCommand.h b/Source/cmUseMangledMesaCommand.h
index 511882989..215e4a3cc 100644
--- a/Source/cmUseMangledMesaCommand.h
+++ b/Source/cmUseMangledMesaCommand.h
@@ -3,24 +3,14 @@
#ifndef cmUseMangledMesaCommand_h
#define cmUseMangledMesaCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmUseMangledMesaCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmUseMangledMesaCommand; }
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
-protected:
- void CopyAndFullPathMesaHeader(const char* source, const char* outdir);
-};
+bool cmUseMangledMesaCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx
index eabd7ef31..a43165cce 100644
--- a/Source/cmUtilitySourceCommand.cxx
+++ b/Source/cmUtilitySourceCommand.cxx
@@ -2,53 +2,53 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmUtilitySourceCommand.h"
-#include <string.h>
+#include <cstring>
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
// cmUtilitySourceCommand
-bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmUtilitySourceCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
- std::vector<std::string>::const_iterator arg = args.begin();
+ auto arg = args.begin();
// The first argument is the cache entry name.
std::string const& cacheEntry = *arg++;
- const char* cacheValue = this->Makefile->GetDefinition(cacheEntry);
+ const char* cacheValue = status.GetMakefile().GetDefinition(cacheEntry);
// If it exists already and appears up to date then we are done. If
// the string contains "(IntDir)" but that is not the
// CMAKE_CFG_INTDIR setting then the value is out of date.
- const char* intDir =
- this->Makefile->GetRequiredDefinition("CMAKE_CFG_INTDIR");
+ std::string const& intDir =
+ status.GetMakefile().GetRequiredDefinition("CMAKE_CFG_INTDIR");
bool haveCacheValue = false;
- if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING")) {
- haveCacheValue = (cacheValue != CM_NULLPTR);
+ if (status.GetMakefile().IsOn("CMAKE_CROSSCOMPILING")) {
+ haveCacheValue = (cacheValue != nullptr);
if (!haveCacheValue) {
- std::string msg = "UTILITY_SOURCE is used in cross compiling mode for ";
- msg += cacheEntry;
- msg += ". If your intention is to run this executable, you need to "
- "preload the cache with the full path to a version of that "
- "program, which runs on this build machine.";
- cmSystemTools::Message(msg.c_str(), "Warning");
+ std::string msg = cmStrCat(
+ "UTILITY_SOURCE is used in cross compiling mode for ", cacheEntry,
+ ". If your intention is to run this executable, you need to "
+ "preload the cache with the full path to a version of that "
+ "program, which runs on this build machine.");
+ cmSystemTools::Message(msg, "Warning");
}
} else {
- cmState* state = this->Makefile->GetState();
- haveCacheValue =
- (cacheValue && (strstr(cacheValue, "(IntDir)") == CM_NULLPTR ||
- (intDir && strcmp(intDir, "$(IntDir)") == 0)) &&
- (state->GetCacheMajorVersion() != 0 &&
- state->GetCacheMinorVersion() != 0));
+ cmState* state = status.GetMakefile().GetState();
+ haveCacheValue = (cacheValue &&
+ (strstr(cacheValue, "(IntDir)") == nullptr ||
+ (intDir == "$(IntDir)")) &&
+ (state->GetCacheMajorVersion() != 0 &&
+ state->GetCacheMinorVersion() != 0));
}
if (haveCacheValue) {
@@ -62,29 +62,30 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
// The third argument specifies the relative directory of the source
// of the utility.
std::string const& relativeSource = *arg++;
- std::string utilitySource = this->Makefile->GetCurrentSourceDirectory();
+ std::string utilitySource = status.GetMakefile().GetCurrentSourceDirectory();
utilitySource = utilitySource + "/" + relativeSource;
// If the directory doesn't exist, the source has not been included.
- if (!cmSystemTools::FileExists(utilitySource.c_str())) {
+ if (!cmSystemTools::FileExists(utilitySource)) {
return true;
}
// Make sure all the files exist in the source directory.
while (arg != args.end()) {
std::string file = utilitySource + "/" + *arg++;
- if (!cmSystemTools::FileExists(file.c_str())) {
+ if (!cmSystemTools::FileExists(file)) {
return true;
}
}
// The source exists.
- std::string cmakeCFGout =
- this->Makefile->GetRequiredDefinition("CMAKE_CFG_INTDIR");
- std::string utilityDirectory = this->Makefile->GetCurrentBinaryDirectory();
+ const std::string& cmakeCFGout =
+ status.GetMakefile().GetRequiredDefinition("CMAKE_CFG_INTDIR");
+ std::string utilityDirectory =
+ status.GetMakefile().GetCurrentBinaryDirectory();
std::string exePath;
- if (this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) {
- exePath = this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
+ if (status.GetMakefile().GetDefinition("EXECUTABLE_OUTPUT_PATH")) {
+ exePath = status.GetMakefile().GetDefinition("EXECUTABLE_OUTPUT_PATH");
}
if (!exePath.empty()) {
utilityDirectory = exePath;
@@ -94,21 +95,22 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args,
// Construct the cache entry for the executable's location.
std::string utilityExecutable = utilityDirectory + "/" + cmakeCFGout + "/" +
- utilityName + this->Makefile->GetDefinition("CMAKE_EXECUTABLE_SUFFIX");
+ utilityName +
+ status.GetMakefile().GetDefinition("CMAKE_EXECUTABLE_SUFFIX");
// make sure we remove any /./ in the name
cmSystemTools::ReplaceString(utilityExecutable, "/./", "/");
// Enter the value into the cache.
- this->Makefile->AddCacheDefinition(cacheEntry, utilityExecutable.c_str(),
- "Path to an internal program.",
- cmStateEnums::FILEPATH);
+ status.GetMakefile().AddCacheDefinition(
+ cacheEntry, utilityExecutable.c_str(), "Path to an internal program.",
+ cmStateEnums::FILEPATH);
// add a value into the cache that maps from the
// full path to the name of the project
cmSystemTools::ConvertToUnixSlashes(utilityExecutable);
- this->Makefile->AddCacheDefinition(utilityExecutable, utilityName.c_str(),
- "Executable to project name.",
- cmStateEnums::INTERNAL);
+ status.GetMakefile().AddCacheDefinition(
+ utilityExecutable, utilityName.c_str(), "Executable to project name.",
+ cmStateEnums::INTERNAL);
return true;
}
diff --git a/Source/cmUtilitySourceCommand.h b/Source/cmUtilitySourceCommand.h
index a95b48d6a..934d53905 100644
--- a/Source/cmUtilitySourceCommand.h
+++ b/Source/cmUtilitySourceCommand.h
@@ -3,21 +3,14 @@
#ifndef cmUtilitySourceCommand_h
#define cmUtilitySourceCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmUtilitySourceCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmUtilitySourceCommand; }
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmUtilitySourceCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmUtils.hxx b/Source/cmUtils.hxx
index c5c767c02..a7a3e81f6 100644
--- a/Source/cmUtils.hxx
+++ b/Source/cmUtils.hxx
@@ -7,7 +7,7 @@
// Use the make system's VERBOSE environment variable to enable
// verbose output. This can be skipped by also setting CMAKE_NO_VERBOSE
-// (which is set by the Eclipse and KDevelop generators).
+// (which is set by the Eclipse generator).
inline bool isCMakeVerbose()
{
return (cmSystemTools::HasEnv("VERBOSE") &&
diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx
index 201e1ccef..cd52b3f30 100644
--- a/Source/cmUuid.cxx
+++ b/Source/cmUuid.cxx
@@ -2,18 +2,12 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmUuid.h"
-#include "cmCryptoHash.h"
+#include <array>
+#include <cstring>
-#include <string.h>
+#include "cmCryptoHash.h"
-cmUuid::cmUuid()
-{
- Groups.push_back(4);
- Groups.push_back(2);
- Groups.push_back(2);
- Groups.push_back(2);
- Groups.push_back(6);
-}
+static const std::array<int, 5> kUuidGroups = { { 4, 2, 2, 2, 6 } };
std::string cmUuid::FromMd5(std::vector<unsigned char> const& uuidNamespace,
std::string const& name) const
@@ -59,7 +53,7 @@ void cmUuid::CreateHashInput(std::vector<unsigned char> const& uuidNamespace,
std::string cmUuid::FromDigest(const unsigned char* digest,
unsigned char version) const
{
- typedef unsigned char byte_t;
+ using byte_t = unsigned char;
byte_t uuid[16] = { 0 };
memcpy(uuid, digest, 16);
@@ -83,11 +77,11 @@ bool cmUuid::StringToBinary(std::string const& input,
return false;
}
size_t index = 0;
- for (size_t i = 0; i < this->Groups.size(); ++i) {
+ for (size_t i = 0; i < kUuidGroups.size(); ++i) {
if (i != 0 && input[index++] != '-') {
return false;
}
- size_t digits = this->Groups[i] * 2;
+ size_t digits = kUuidGroups[i] * 2;
if (!StringToBinaryImpl(input.substr(index, digits), output)) {
return false;
}
@@ -103,12 +97,12 @@ std::string cmUuid::BinaryToString(const unsigned char* input) const
std::string output;
size_t inputIndex = 0;
- for (size_t i = 0; i < this->Groups.size(); ++i) {
+ for (size_t i = 0; i < kUuidGroups.size(); ++i) {
if (i != 0) {
output += '-';
}
- size_t bytes = this->Groups[i];
+ size_t bytes = kUuidGroups[i];
for (size_t j = 0; j < bytes; ++j) {
unsigned char byte = input[inputIndex++];
output += this->ByteToHex(byte);
@@ -120,14 +114,12 @@ std::string cmUuid::BinaryToString(const unsigned char* input) const
std::string cmUuid::ByteToHex(unsigned char byte) const
{
- std::string result;
+ std::string result(" ");
for (int i = 0; i < 2; ++i) {
unsigned char rest = byte % 16;
byte /= 16;
-
char c = (rest < 0xA) ? char('0' + rest) : char('a' + (rest - 0xA));
-
- result = c + result;
+ result.at(1 - i) = c;
}
return result;
diff --git a/Source/cmUuid.h b/Source/cmUuid.h
index 158ce6ee4..7de20dd29 100644
--- a/Source/cmUuid.h
+++ b/Source/cmUuid.h
@@ -15,8 +15,6 @@
class cmUuid
{
public:
- cmUuid();
-
std::string FromMd5(std::vector<unsigned char> const& uuidNamespace,
std::string const& name) const;
@@ -42,8 +40,6 @@ private:
std::string BinaryToString(const unsigned char* input) const;
bool IntFromHexDigit(char input, char& output) const;
-
- std::vector<int> Groups;
};
#endif
diff --git a/Source/cmVS10CLFlagTable.h b/Source/cmVS10CLFlagTable.h
deleted file mode 100644
index dbd760ed1..000000000
--- a/Source/cmVS10CLFlagTable.h
+++ /dev/null
@@ -1,204 +0,0 @@
-static cmVS7FlagTable cmVS10CLFlagTable[] = {
-
- // Enum Properties
- { "DebugInformationFormat", "Z7", "C7 compatible", "OldStyle", 0 },
- { "DebugInformationFormat", "Zi", "Program Database", "ProgramDatabase", 0 },
- { "DebugInformationFormat", "ZI", "Program Database for Edit And Continue",
- "EditAndContinue", 0 },
-
- { "WarningLevel", "W0", "Turn Off All Warnings", "TurnOffAllWarnings", 0 },
- { "WarningLevel", "W1", "Level1", "Level1", 0 },
- { "WarningLevel", "W2", "Level2", "Level2", 0 },
- { "WarningLevel", "W3", "Level3", "Level3", 0 },
- { "WarningLevel", "W4", "Level4", "Level4", 0 },
- { "WarningLevel", "Wall", "EnableAllWarnings", "EnableAllWarnings", 0 },
-
- { "Optimization", "Od", "Disabled", "Disabled", 0 },
- { "Optimization", "O1", "Minimize Size", "MinSpace", 0 },
- { "Optimization", "O2", "Maximize Speed", "MaxSpeed", 0 },
- { "Optimization", "Ox", "Full Optimization", "Full", 0 },
-
- { "InlineFunctionExpansion", "", "Default", "Default", 0 },
- { "InlineFunctionExpansion", "Ob0", "Disabled", "Disabled", 0 },
- { "InlineFunctionExpansion", "Ob1", "Only __inline", "OnlyExplicitInline",
- 0 },
- { "InlineFunctionExpansion", "Ob2", "Any Suitable", "AnySuitable", 0 },
-
- { "FavorSizeOrSpeed", "Os", "Favor small code", "Size", 0 },
- { "FavorSizeOrSpeed", "Ot", "Favor fast code", "Speed", 0 },
- { "FavorSizeOrSpeed", "", "Neither", "Neither", 0 },
-
- { "ExceptionHandling", "EHa", "Yes with SEH Exceptions", "Async", 0 },
- { "ExceptionHandling", "EHsc", "Yes", "Sync", 0 },
- { "ExceptionHandling", "EHs", "Yes with Extern C functions", "SyncCThrow",
- 0 },
- { "ExceptionHandling", "", "No", "false", 0 },
-
- { "BasicRuntimeChecks", "RTCs", "Stack Frames", "StackFrameRuntimeCheck",
- 0 },
- { "BasicRuntimeChecks", "RTCu", "Uninitialized variables",
- "UninitializedLocalUsageCheck", 0 },
- { "BasicRuntimeChecks", "RTC1", "Both (/RTC1, equiv. to /RTCsu)",
- "EnableFastChecks", 0 },
- { "BasicRuntimeChecks", "", "Default", "Default", 0 },
-
- { "RuntimeLibrary", "MT", "Multi-threaded", "MultiThreaded", 0 },
- { "RuntimeLibrary", "MTd", "Multi-threaded Debug", "MultiThreadedDebug", 0 },
- { "RuntimeLibrary", "MD", "Multi-threaded DLL", "MultiThreadedDLL", 0 },
- { "RuntimeLibrary", "MDd", "Multi-threaded Debug DLL",
- "MultiThreadedDebugDLL", 0 },
-
- { "StructMemberAlignment", "Zp1", "1 Byte", "1Byte", 0 },
- { "StructMemberAlignment", "Zp2", "2 Bytes", "2Bytes", 0 },
- { "StructMemberAlignment", "Zp4", "4 Byte", "4Bytes", 0 },
- { "StructMemberAlignment", "Zp8", "8 Bytes", "8Bytes", 0 },
- { "StructMemberAlignment", "Zp16", "16 Bytes", "16Bytes", 0 },
- { "StructMemberAlignment", "", "Default", "Default", 0 },
-
- { "EnableEnhancedInstructionSet", "arch:SSE",
- "Streaming SIMD Extensions (/arch:SSE)", "StreamingSIMDExtensions", 0 },
- { "EnableEnhancedInstructionSet", "arch:SSE2",
- "Streaming SIMD Extensions 2 (/arch:SSE2)", "StreamingSIMDExtensions2",
- 0 },
- { "EnableEnhancedInstructionSet", "", "Not Set", "NotSet", 0 },
-
- { "FloatingPointModel", "fp:precise", "Precise", "Precise", 0 },
- { "FloatingPointModel", "fp:strict", "Strict", "Strict", 0 },
- { "FloatingPointModel", "fp:fast", "Fast", "Fast", 0 },
-
- { "PrecompiledHeader", "Yc", "Create", "Create",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "PrecompiledHeader", "Yu", "Use", "Use",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 },
-
- { "AssemblerOutput", "", "No Listing", "NoListing", 0 },
- { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 },
- { "AssemblerOutput", "FAc", "Assembly With Machine Code",
- "AssemblyAndMachineCode", 0 },
- { "AssemblerOutput", "FAs", "Assembly With Source Code",
- "AssemblyAndSourceCode", 0 },
- { "AssemblerOutput", "FAcs", "Assembly, Machine Code and Source", "All", 0 },
-
- { "CallingConvention", "Gd", "__cdecl", "Cdecl", 0 },
- { "CallingConvention", "Gr", "__fastcall", "FastCall", 0 },
- { "CallingConvention", "Gz", "__stdcall", "StdCall", 0 },
-
- { "CompileAs", "", "Default", "Default", 0 },
- { "CompileAs", "TC", "Compile as C Code", "CompileAsC", 0 },
- { "CompileAs", "TP", "Compile as C++ Code", "CompileAsCpp", 0 },
-
- { "ErrorReporting", "errorReport:none", "Do Not Send Report", "None", 0 },
- { "ErrorReporting", "errorReport:prompt", "Prompt Immediately", "Prompt",
- 0 },
- { "ErrorReporting", "errorReport:queue", "Queue For Next Login", "Queue",
- 0 },
- { "ErrorReporting", "errorReport:send", "Send Automatically", "Send", 0 },
-
- { "CompileAsManaged", "", "No Common Language RunTime Support", "false", 0 },
- { "CompileAsManaged", "clr", "Common Language RunTime Support", "true", 0 },
- { "CompileAsManaged", "clr:pure",
- "Pure MSIL Common Language RunTime Support", "Pure", 0 },
- { "CompileAsManaged", "clr:safe",
- "Safe MSIL Common Language RunTime Support", "Safe", 0 },
- { "CompileAsManaged", "clr:oldSyntax",
- "Common Language RunTime Support, Old Syntax", "OldSyntax", 0 },
-
- // Bool Properties
- { "SuppressStartupBanner", "nologo-", "", "false", 0 },
- { "SuppressStartupBanner", "nologo", "", "true", 0 },
- { "TreatWarningAsError", "WX-", "", "false", 0 },
- { "TreatWarningAsError", "WX", "", "true", 0 },
- { "IntrinsicFunctions", "Oi", "", "true", 0 },
- { "OmitFramePointers", "Oy-", "", "false", 0 },
- { "OmitFramePointers", "Oy", "", "true", 0 },
- { "EnableFiberSafeOptimizations", "GT", "", "true", 0 },
- { "WholeProgramOptimization", "GL", "", "true", 0 },
- { "UndefineAllPreprocessorDefinitions", "u", "", "true", 0 },
- { "IgnoreStandardIncludePath", "X", "", "true", 0 },
- { "PreprocessToFile", "P", "", "true", 0 },
- { "PreprocessSuppressLineNumbers", "EP", "", "true", 0 },
- { "PreprocessKeepComments", "C", "", "true", 0 },
- { "StringPooling", "GF-", "", "false", 0 },
- { "StringPooling", "GF", "", "true", 0 },
- { "MinimalRebuild", "Gm-", "", "false", 0 },
- { "MinimalRebuild", "Gm", "", "true", 0 },
- { "SmallerTypeCheck", "RTCc", "", "true", 0 },
- { "BufferSecurityCheck", "GS-", "", "false", 0 },
- { "BufferSecurityCheck", "GS", "", "true", 0 },
- { "FunctionLevelLinking", "Gy-", "", "false", 0 },
- { "FunctionLevelLinking", "Gy", "", "true", 0 },
- { "FloatingPointExceptions", "fp:except-", "", "false", 0 },
- { "FloatingPointExceptions", "fp:except", "", "true", 0 },
- { "CreateHotpatchableImage", "hotpatch", "", "true", 0 },
- { "DisableLanguageExtensions", "Za", "", "true", 0 },
- { "TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0 },
- { "TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0 },
- { "ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0 },
- { "ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0 },
- { "RuntimeTypeInfo", "GR-", "", "false", 0 },
- { "RuntimeTypeInfo", "GR", "", "true", 0 },
- { "OpenMPSupport", "openmp-", "", "false", 0 },
- { "OpenMPSupport", "openmp", "", "true", 0 },
- { "ExpandAttributedSource", "Fx", "", "true", 0 },
- { "ShowIncludes", "showIncludes", "", "true", 0 },
- { "EnablePREfast", "analyze-", "", "false", 0 },
- { "EnablePREfast", "analyze", "", "true", 0 },
- { "UseFullPaths", "FC", "", "true", 0 },
- { "OmitDefaultLibName", "Zl", "", "true", 0 },
- { "UseUnicodeForAssemblerListing", "FAu", "", "true", 0 },
-
- // Bool Properties With Argument
- { "MultiProcessorCompilation", "MP", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "ProcessorNumber", "MP", "Multi-processor Compilation", "",
- cmVS7FlagTable::UserValueRequired },
- { "GenerateXMLDocumentationFiles", "doc", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "",
- cmVS7FlagTable::UserValueRequired },
- { "BrowseInformation", "FR", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "BrowseInformationFile", "FR", "Enable Browse Information", "",
- cmVS7FlagTable::UserValueRequired },
-
- // String List Properties
- { "AdditionalIncludeDirectories", "I", "Additional Include Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AdditionalUsingDirectories", "AI", "Resolve #using References", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "PreprocessorDefinitions", "D ", "Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "UndefinePreprocessorDefinitions", "U",
- "Undefine Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "DisableSpecificWarnings", "wd", "Disable Specific Warnings", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForcedIncludeFiles", "FI", "Forced Include File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForcedUsingFiles", "FU", "Forced #using File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "TreatSpecificWarningsAsErrors", "we", "Treat Specific Warnings As Errors",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- // Skip [TrackerLogDirectory] - no command line Switch.
- { "PreprocessOutputPath", "Fi", "Preprocess Output Path", "",
- cmVS7FlagTable::UserValue },
- { "PrecompiledHeaderFile", "Yc", "Precompiled Header Name", "",
- cmVS7FlagTable::UserValueRequired },
- { "PrecompiledHeaderFile", "Yu", "Precompiled Header Name", "",
- cmVS7FlagTable::UserValueRequired },
- { "PrecompiledHeaderOutputFile", "Fp", "Precompiled Header Output File", "",
- cmVS7FlagTable::UserValue },
- { "AssemblerListingLocation", "Fa", "ASM List Location", "",
- cmVS7FlagTable::UserValue },
- { "ObjectFileName", "Fo", "Object File Name", "",
- cmVS7FlagTable::UserValue },
- { "ProgramDataBaseFileName", "Fd", "Program Database File Name", "",
- cmVS7FlagTable::UserValue },
- // Skip [XMLDocumentationFileName] - no command line Switch.
- // Skip [BrowseInformationFile] - no command line Switch.
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS10CSharpFlagTable.h b/Source/cmVS10CSharpFlagTable.h
deleted file mode 100644
index 493ec2b12..000000000
--- a/Source/cmVS10CSharpFlagTable.h
+++ /dev/null
@@ -1,120 +0,0 @@
-static cmVS7FlagTable cmVS10CSharpFlagTable[] = {
- { "ProjectName", "out:", "", "", cmIDEFlagTable::UserValueRequired },
-
- { "OutputType", "target:exe", "", "Exe", 0 },
- { "OutputType", "target:winexe", "", "Winexe", 0 },
- { "OutputType", "target:library", "", "Library", 0 },
- { "OutputType", "target:module", "", "Module", 0 },
-
- { "DocumentationFile", "doc", "", "", cmIDEFlagTable::UserValueRequired },
-
- { "Platform", "platform:x86", "", "x86", 0 },
- { "Platform", "platform:Itanium", "", "Itanium", 0 },
- { "Platform", "platform:x64", "", "x64", 0 },
- { "Platform", "platform:arm", "", "arm", 0 },
- { "Platform", "platform:anycpu32bitpreferred", "", "anycpu32bitpreferred",
- 0 },
- { "Platform", "platform:anycpu", "", "anycpu", 0 },
-
- { "References", "reference:", "mit alias", "", 0 },
- { "References", "reference:", "dateiliste", "", 0 },
- { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable },
- { "", "link", "", "", 0 },
-
- { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired },
- { "ApplicationIcon", "win32icon", "", "",
- cmIDEFlagTable::UserValueRequired },
-
- { "Win32Manifest", "win32manifest:", "", "true", 0 },
-
- { "NoWin32Manifest", "nowin32manifest", "", "true", 0 },
-
- { "DefineDebug", "debug", "", "true", cmIDEFlagTable::Continue },
-
- { "DebugSymbols", "debug", "", "true", 0 },
- { "DebugSymbols", "debug-", "", "false", 0 },
- { "DebugSymbols", "debug+", "", "true", 0 },
-
- { "DebugType", "debug:none", "", "none", 0 },
- { "DebugType", "debug:full", "", "full", 0 },
- { "DebugType", "debug:pdbonly", "", "pdbonly", 0 },
-
- { "Optimize", "optimize", "", "true", 0 },
- { "Optimize", "optimize-", "", "false", 0 },
- { "Optimize", "optimize+", "", "true", 0 },
-
- { "TreatWarningsAsErrors", "warnaserror", "", "true", 0 },
- { "TreatWarningsAsErrors", "warnaserror-", "", "false", 0 },
- { "TreatWarningsAsErrors", "warnaserror+", "", "true", 0 },
-
- { "WarningsAsErrors", "warnaserror", "", "", 0 },
- { "WarningsAsErrors", "warnaserror-", "", "", 0 },
- { "WarningsAsErrors", "warnaserror+", "", "", 0 },
-
- { "WarningLevel", "warn:0", "", "0", 0 },
- { "WarningLevel", "warn:1", "", "1", 0 },
- { "WarningLevel", "warn:2", "", "2", 0 },
- { "WarningLevel", "warn:3", "", "3", 0 },
- { "WarningLevel", "warn:4", "", "4", 0 },
- { "DisabledWarnings", "nowarn", "", "", 0 },
-
- { "CheckForOverflowUnderflow", "checked", "", "true", 0 },
- { "CheckForOverflowUnderflow", "checked-", "", "false", 0 },
- { "CheckForOverflowUnderflow", "checked+", "", "true", 0 },
-
- { "AllowUnsafeBlocks", "unsafe", "", "true", 0 },
- { "AllowUnsafeBlocks", "unsafe-", "", "false", 0 },
- { "AllowUnsafeBlocks", "unsafe+", "", "true", 0 },
-
- { "DefineConstants", "define:", "", "",
- cmIDEFlagTable::SemicolonAppendable | cmIDEFlagTable::UserValue },
-
- { "LangVersion", "langversion:ISO-1", "", "ISO-1", 0 },
- { "LangVersion", "langversion:ISO-2", "", "ISO-2", 0 },
- { "LangVersion", "langversion:3", "", "3", 0 },
- { "LangVersion", "langversion:4", "", "4", 0 },
- { "LangVersion", "langversion:5", "", "5", 0 },
- { "LangVersion", "langversion:6", "", "6", 0 },
- { "LangVersion", "langversion:default", "", "default", 0 },
-
- { "DelaySign", "delaysign", "", "true", 0 },
- { "DelaySign", "delaysign-", "", "false", 0 },
- { "DelaySign", "delaysign+", "", "true", 0 },
-
- { "AssemblyOriginatorKeyFile", "keyfile", "", "", 0 },
-
- { "KeyContainerName", "keycontainer", "", "", 0 },
-
- { "NoLogo", "nologo", "", "", 0 },
-
- { "NoConfig", "noconfig", "", "true", 0 },
-
- { "BaseAddress", "baseaddress:", "", "", 0 },
-
- { "CodePage", "codepage", "", "", 0 },
-
- { "Utf8Output", "utf8output", "", "", 0 },
-
- { "MainEntryPoint", "main:", "", "", 0 },
-
- { "GenerateFullPaths", "fullpaths", "", "true", 0 },
-
- { "FileAlignment", "filealign", "", "", 0 },
-
- { "PdbFile", "pdb:", "", "", 0 },
-
- { "NoStandardLib", "nostdlib", "", "true", 0 },
- { "NoStandardLib", "nostdlib-", "", "false", 0 },
- { "NoStandardLib", "nostdlib+", "", "true", 0 },
-
- { "SubsystemVersion", "subsystemversion", "", "", 0 },
-
- { "AdditionalLibPaths", "lib:", "", "", 0 },
-
- { "ErrorReport", "errorreport:none", "Do Not Send Report", "none", 0 },
- { "ErrorReport", "errorreport:prompt", "Prompt Immediately", "prompt", 0 },
- { "ErrorReport", "errorreport:queue", "Queue For Next Login", "queue", 0 },
- { "ErrorReport", "errorreport:send", "Send Automatically", "send", 0 },
-
- { 0, 0, 0, 0, 0 },
-};
diff --git a/Source/cmVS10CudaFlagTable.h b/Source/cmVS10CudaFlagTable.h
deleted file mode 100644
index da19d649b..000000000
--- a/Source/cmVS10CudaFlagTable.h
+++ /dev/null
@@ -1,51 +0,0 @@
-static cmVS7FlagTable cmVS10CudaFlagTable[] = {
- // Collect options meant for the host compiler.
- { "AdditionalCompilerOptions", "Xcompiler=", "Host compiler options", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SpaceAppendable },
- { "AdditionalCompilerOptions", "Xcompiler", "Host compiler options", "",
- cmVS7FlagTable::UserFollowing | cmVS7FlagTable::SpaceAppendable },
-
- // Select the CUDA runtime library.
- { "CudaRuntime", "cudart=none", "No CUDA runtime library", "None", 0 },
- { "CudaRuntime", "cudart=shared", "Shared/dynamic CUDA runtime library",
- "Shared", 0 },
- { "CudaRuntime", "cudart=static", "Static CUDA runtime library", "Static",
- 0 },
- { "CudaRuntime", "cudart", "CUDA runtime library", "",
- cmVS7FlagTable::UserFollowing },
-
- // Capture arch/code arguments into temporaries for post-processing.
- { "cmake-temp-gencode", "gencode=", "", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "cmake-temp-gencode", "gencode", "", "",
- cmVS7FlagTable::UserFollowing | cmVS7FlagTable::SemicolonAppendable },
- { "cmake-temp-gencode", "-generate-code=", "", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "cmake-temp-gencode", "-generate-code", "", "",
- cmVS7FlagTable::UserFollowing | cmVS7FlagTable::SemicolonAppendable },
-
- { "cmake-temp-code", "code=", "", "", cmVS7FlagTable::UserValue },
- { "cmake-temp-code", "code", "", "", cmVS7FlagTable::UserFollowing },
- { "cmake-temp-code", "-gpu-code=", "", "", cmVS7FlagTable::UserValue },
- { "cmake-temp-code", "-gpu-code", "", "", cmVS7FlagTable::UserFollowing },
-
- { "cmake-temp-arch", "arch=", "", "", cmVS7FlagTable::UserValue },
- { "cmake-temp-arch", "arch", "", "", cmVS7FlagTable::UserFollowing },
- { "cmake-temp-arch", "-gpu-architecture=", "", "",
- cmVS7FlagTable::UserValue },
- { "cmake-temp-arch", "-gpu-architecture", "", "",
- cmVS7FlagTable::UserFollowing },
-
- // Other flags.
-
- { "FastMath", "use_fast_math", "", "true", 0 },
- { "FastMath", "-use_fast_math", "", "true", 0 },
-
- { "GPUDebugInfo", "G", "", "true", 0 },
- { "GPUDebugInfo", "-device-debug", "", "true", 0 },
-
- { "HostDebugInfo", "g", "", "true", 0 },
- { "HostDebugInfo", "-debug", "", "true", 0 },
-
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS10CudaHostFlagTable.h b/Source/cmVS10CudaHostFlagTable.h
deleted file mode 100644
index 5b61066ca..000000000
--- a/Source/cmVS10CudaHostFlagTable.h
+++ /dev/null
@@ -1,35 +0,0 @@
-static cmVS7FlagTable cmVS10CudaHostFlagTable[] = {
- //{"Optimization", "", "<inherit from host>", "InheritFromHost", 0},
- { "Optimization", "Od", "Disabled", "Od", 0 },
- { "Optimization", "O1", "Minimize Size", "O1", 0 },
- { "Optimization", "O2", "Maximize Speed", "O2", 0 },
- { "Optimization", "Ox", "Full Optimization", "O3", 0 },
-
- //{"Runtime", "", "<inherit from host>", "InheritFromHost", 0},
- { "Runtime", "MT", "Multi-Threaded", "MT", 0 },
- { "Runtime", "MTd", "Multi-Threaded Debug", "MTd", 0 },
- { "Runtime", "MD", "Multi-Threaded DLL", "MD", 0 },
- { "Runtime", "MDd", "Multi-threaded Debug DLL", "MDd", 0 },
- { "Runtime", "ML", "Single-Threaded", "ML", 0 },
- { "Runtime", "MLd", "Single-Threaded Debug", "MLd", 0 },
-
- //{"RuntimeChecks", "", "<inherit from host>", "InheritFromHost", 0},
- //{"RuntimeChecks", "", "Default", "Default", 0},
- { "RuntimeChecks", "RTCs", "Stack Frames", "RTCs", 0 },
- { "RuntimeChecks", "RTCu", "Uninitialized Variables", "RTCu", 0 },
- { "RuntimeChecks", "RTC1", "Both", "RTC1", 0 },
-
- //{"TypeInfo", "", "<inherit from host>", "InheritFromHost", 0},
- { "TypeInfo", "GR", "Yes", "true", 0 },
- { "TypeInfo", "GR-", "No", "false", 0 },
-
- //{"Warning", "", "<inherit from host>", "InheritFromHost", 0},
- { "Warning", "W0", "Off: Turn Off All Warnings", "W0", 0 },
- { "Warning", "W1", "Level 1", "W1", 0 },
- { "Warning", "W2", "Level 2", "W2", 0 },
- { "Warning", "W3", "Level 3", "W3", 0 },
- { "Warning", "W4", "Level 4", "W4", 0 },
- { "Warning", "Wall", "Enable All Warnings", "Wall", 0 },
-
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS10LibFlagTable.h b/Source/cmVS10LibFlagTable.h
deleted file mode 100644
index 65f28ef40..000000000
--- a/Source/cmVS10LibFlagTable.h
+++ /dev/null
@@ -1,76 +0,0 @@
-static cmVS7FlagTable cmVS10LibFlagTable[] = {
-
- // Enum Properties
- { "ErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
- "PromptImmediately", 0 },
- { "ErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
- "QueueForNextLogin", 0 },
- { "ErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
- "SendErrorReport", 0 },
- { "ErrorReporting", "ERRORREPORT:NONE", "No Error Report", "NoErrorReport",
- 0 },
-
- { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
- { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
- { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
- { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
- { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
- { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
- 0 },
- { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
- "MachineMIPSFPU16", 0 },
- { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
- { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
- { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
- { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
-
- { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
- { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
- "EFI Application", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
- "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
- 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWSCE", "WindowsCE", "WindowsCE", 0 },
- { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
-
- // Bool Properties
- { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
- { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
- { "TreatLibWarningAsErrors", "WX:NO", "", "false", 0 },
- { "TreatLibWarningAsErrors", "WX", "", "true", 0 },
- { "Verbose", "VERBOSE", "", "true", 0 },
- { "LinkTimeCodeGeneration", "LTCG", "", "true", 0 },
-
- // Bool Properties With Argument
-
- // String List Properties
- // Skip [AdditionalDependencies] - no command line Switch.
- { "AdditionalLibraryDirectories", "LIBPATH:",
- "Additional Library Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
- "Ignore Specific Default Libraries", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ExportNamedFunctions", "EXPORT:", "Export Named Functions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "RemoveObjects", "REMOVE:", "Remove Objects", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
- { "ModuleDefinitionFile", "DEF:", "Module Definition File Name", "",
- cmVS7FlagTable::UserValue },
- { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
- cmVS7FlagTable::UserValue },
- { "DisplayLibrary", "LIST:", "Display Library to standard output", "",
- cmVS7FlagTable::UserValue },
- // Skip [MinimumRequiredVersion] - no command line Switch.
- { "Name", "NAME:", "Name", "", cmVS7FlagTable::UserValue },
- // Skip [TrackerLogDirectory] - no command line Switch.
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS10LinkFlagTable.h b/Source/cmVS10LinkFlagTable.h
deleted file mode 100644
index c30ea9a66..000000000
--- a/Source/cmVS10LinkFlagTable.h
+++ /dev/null
@@ -1,244 +0,0 @@
-static cmVS7FlagTable cmVS10LinkFlagTable[] = {
-
- // Enum Properties
- { "ShowProgress", "", "Not Set", "NotSet", 0 },
- { "ShowProgress", "VERBOSE", "Display all progress messages", "LinkVerbose",
- 0 },
- { "ShowProgress", "VERBOSE:Lib", "For Libraries Searched", "LinkVerboseLib",
- 0 },
- { "ShowProgress", "VERBOSE:ICF",
- "About COMDAT folding during optimized linking", "LinkVerboseICF", 0 },
- { "ShowProgress", "VERBOSE:REF",
- "About data removed during optimized linking", "LinkVerboseREF", 0 },
- { "ShowProgress", "VERBOSE:SAFESEH", "About Modules incompatible with SEH",
- "LinkVerboseSAFESEH", 0 },
- { "ShowProgress", "VERBOSE:CLR",
- "About linker activity related to managed code", "LinkVerboseCLR", 0 },
-
- { "ForceFileOutput", "FORCE", "Enabled", "Enabled", 0 },
- { "ForceFileOutput", "FORCE:MULTIPLE", "Multiply Defined Symbol Only",
- "MultiplyDefinedSymbolOnly", 0 },
- { "ForceFileOutput", "FORCE:UNRESOLVED", "Undefined Symbol Only",
- "UndefinedSymbolOnly", 0 },
-
- { "CreateHotPatchableImage", "FUNCTIONPADMIN", "Enabled", "Enabled", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:5", "X86 Image Only",
- "X86Image", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:6", "X64 Image Only",
- "X64Image", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only",
- "ItaniumImage", 0 },
-
- { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 },
- { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable",
- "HighestAvailable", 0 },
- { "UACExecutionLevel", "level='requireAdministrator'",
- "requireAdministrator", "RequireAdministrator", 0 },
-
- { "SubSystem", "", "Not Set", "NotSet", 0 },
- { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
- { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
- "EFI Application", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
- "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
- 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWSCE", "WindowsCE", "WindowsCE", 0 },
- { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
-
- { "Driver", "", "Not Set", "NotSet", 0 },
- { "Driver", "Driver", "Driver", "Driver", 0 },
- { "Driver", "DRIVER:UPONLY", "UP Only", "UpOnly", 0 },
- { "Driver", "DRIVER:WDM", "WDM", "WDM", 0 },
-
- { "LinkTimeCodeGeneration", "", "Default", "Default", 0 },
- { "LinkTimeCodeGeneration", "LTCG", "Use Link Time Code Generation",
- "UseLinkTimeCodeGeneration", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGInstrument",
- "Profile Guided Optimization - Instrument", "PGInstrument", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGOptimize",
- "Profile Guided Optimization - Optimization", "PGOptimization", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGUpdate",
- "Profile Guided Optimization - Update", "PGUpdate", 0 },
-
- { "TargetMachine", "", "Not Set", "NotSet", 0 },
- { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
- { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
- { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
- { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
- { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
- { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
- 0 },
- { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
- "MachineMIPSFPU16", 0 },
- { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
- { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
- { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
- { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
-
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA", "MTA threading attribute",
- "MTAThreadingAttribute", 0 },
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA", "STA threading attribute",
- "STAThreadingAttribute", 0 },
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE",
- "Default threading attribute", "DefaultThreadingAttribute", 0 },
-
- { "CLRImageType", "CLRIMAGETYPE:IJW", "Force IJW image", "ForceIJWImage",
- 0 },
- { "CLRImageType", "CLRIMAGETYPE:PURE", "Force Pure IL Image",
- "ForcePureILImage", 0 },
- { "CLRImageType", "CLRIMAGETYPE:SAFE", "Force Safe IL Image",
- "ForceSafeILImage", 0 },
- { "CLRImageType", "", "Default image type", "Default", 0 },
-
- { "LinkErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
- "PromptImmediately", 0 },
- { "LinkErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
- "QueueForNextLogin", 0 },
- { "LinkErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
- "SendErrorReport", 0 },
- { "LinkErrorReporting", "ERRORREPORT:NONE", "No Error Report",
- "NoErrorReport", 0 },
-
- { "CLRSupportLastError", "CLRSupportLastError", "Enabled", "Enabled", 0 },
- { "CLRSupportLastError", "CLRSupportLastError:NO", "Disabled", "Disabled",
- 0 },
- { "CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL", "System Dlls Only",
- "SystemDlls", 0 },
-
- // Bool Properties
- { "LinkIncremental", "INCREMENTAL:NO", "", "false", 0 },
- { "LinkIncremental", "INCREMENTAL", "", "true", 0 },
- { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
- { "LinkStatus", "LTCG:NOSTATUS", "", "false", 0 },
- { "LinkStatus", "LTCG:STATUS", "", "true", 0 },
- { "PreventDllBinding", "ALLOWBIND:NO", "", "false", 0 },
- { "PreventDllBinding", "ALLOWBIND", "", "true", 0 },
- { "TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0 },
- { "TreatLinkerWarningAsErrors", "WX", "", "true", 0 },
- { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
- { "GenerateManifest", "MANIFEST:NO", "", "false", 0 },
- { "GenerateManifest", "MANIFEST", "", "true", 0 },
- { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 },
- { "UACUIAccess", "uiAccess='false'", "", "false", 0 },
- { "UACUIAccess", "uiAccess='true'", "", "true", 0 },
- { "GenerateDebugInformation", "DEBUG", "", "true",
- cmVS7FlagTable::CaseInsensitive },
- { "MapExports", "MAPINFO:EXPORTS", "", "true", 0 },
- { "AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0 },
- { "AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0 },
- { "LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0 },
- { "LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0 },
- { "TerminalServerAware", "TSAWARE:NO", "", "false", 0 },
- { "TerminalServerAware", "TSAWARE", "", "true", 0 },
- { "SwapRunFromCD", "SWAPRUN:CD", "", "true", 0 },
- { "SwapRunFromNET", "SWAPRUN:NET", "", "true", 0 },
- { "OptimizeReferences", "OPT:NOREF", "", "false", 0 },
- { "OptimizeReferences", "OPT:REF", "", "true", 0 },
- { "EnableCOMDATFolding", "OPT:NOICF", "", "false", 0 },
- { "EnableCOMDATFolding", "OPT:ICF", "", "true", 0 },
- { "IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0 },
- { "NoEntryPoint", "NOENTRY", "", "true", 0 },
- { "SetChecksum", "RELEASE", "", "true", 0 },
- { "RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0 },
- { "RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0 },
- { "FixedBaseAddress", "FIXED:NO", "", "false", 0 },
- { "FixedBaseAddress", "FIXED", "", "true", 0 },
- { "DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0 },
- { "DataExecutionPrevention", "NXCOMPAT", "", "true", 0 },
- { "TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0 },
- { "SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0 },
- { "SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0 },
- { "Profile", "PROFILE", "", "true", 0 },
- { "LinkDelaySign", "DELAYSIGN:NO", "", "false", 0 },
- { "LinkDelaySign", "DELAYSIGN", "", "true", 0 },
- { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0 },
- { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0 },
- { "ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0 },
- { "ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0 },
- { "LinkDLL", "DLL", "", "true", 0 },
-
- // Bool Properties With Argument
- { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 },
- { "EnableUAC", "MANIFESTUAC:", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
- cmVS7FlagTable::UserValueRequired },
- { "GenerateMapFile", "MAP", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "MapFileName", "MAP:", "Generate Map File", "",
- cmVS7FlagTable::UserValueRequired },
-
- // String List Properties
- { "AdditionalLibraryDirectories", "LIBPATH:",
- "Additional Library Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- // Skip [AdditionalDependencies] - no command line Switch.
- { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
- "Ignore Specific Default Libraries", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AddModuleNamesToAssembly", "ASSEMBLYMODULE:", "Add Module to Assembly",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "EmbedManagedResourceFile", "ASSEMBLYRESOURCE:",
- "Embed Managed Resource File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "DelayLoadDLLs", "DELAYLOAD:", "Delay Loaded Dlls", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:", "Assembly Link Resource",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AdditionalManifestDependencies", "MANIFESTDEPENDENCY:",
- "Additional Manifest Dependencies", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
- { "Version", "VERSION:", "Version", "", cmVS7FlagTable::UserValue },
- { "SpecifySectionAttributes", "SECTION:", "Specify Section Attributes", "",
- cmVS7FlagTable::UserValue },
- { "MSDOSStubFileName", "STUB:", "MS-DOS Stub File Name", "",
- cmVS7FlagTable::UserValue },
- // Skip [TrackerLogDirectory] - no command line Switch.
- { "ModuleDefinitionFile", "DEF:", "Module Definition File", "",
- cmVS7FlagTable::UserValue },
- { "ManifestFile", "ManifestFile:", "Manifest File", "",
- cmVS7FlagTable::UserValue },
- { "ProgramDatabaseFile", "PDB:", "Generate Program Database File", "",
- cmVS7FlagTable::UserValue },
- { "StripPrivateSymbols", "PDBSTRIPPED:", "Strip Private Symbols", "",
- cmVS7FlagTable::UserValue },
- // Skip [MapFileName] - no command line Switch.
- // Skip [MinimumRequiredVersion] - no command line Switch.
- { "HeapReserveSize", "HEAP:", "Heap Reserve Size", "",
- cmVS7FlagTable::UserValue },
- // Skip [HeapCommitSize] - no command line Switch.
- { "StackReserveSize", "STACK:", "Stack Reserve Size", "",
- cmVS7FlagTable::UserValue },
- // Skip [StackCommitSize] - no command line Switch.
- { "FunctionOrder", "ORDER:@", "Function Order", "",
- cmVS7FlagTable::UserValue },
- { "ProfileGuidedDatabase", "PGD:", "Profile Guided Database", "",
- cmVS7FlagTable::UserValue },
- { "MidlCommandFile", "MIDL:@", "MIDL Commands", "",
- cmVS7FlagTable::UserValue },
- { "MergedIDLBaseFileName", "IDLOUT:", "Merged IDL Base File Name", "",
- cmVS7FlagTable::UserValue },
- { "TypeLibraryFile", "TLBOUT:", "Type Library", "",
- cmVS7FlagTable::UserValue },
- { "EntryPointSymbol", "ENTRY:", "Entry Point", "",
- cmVS7FlagTable::UserValue },
- { "BaseAddress", "BASE:", "Base Address", "", cmVS7FlagTable::UserValue },
- { "ImportLibrary", "IMPLIB:", "Import Library", "",
- cmVS7FlagTable::UserValue },
- { "MergeSections", "MERGE:", "Merge Sections", "",
- cmVS7FlagTable::UserValue },
- { "LinkKeyFile", "KEYFILE:", "Key File", "", cmVS7FlagTable::UserValue },
- { "KeyContainer", "KEYCONTAINER:", "Key Container", "",
- cmVS7FlagTable::UserValue },
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS10MASMFlagTable.h b/Source/cmVS10MASMFlagTable.h
deleted file mode 100644
index 0a452453f..000000000
--- a/Source/cmVS10MASMFlagTable.h
+++ /dev/null
@@ -1,76 +0,0 @@
-static cmVS7FlagTable cmVS10MASMFlagTable[] = {
-
- // Enum Properties
- { "PreserveIdentifierCase", "", "Default", "0", 0 },
- { "PreserveIdentifierCase", "Cp", "Preserves Identifier Case (/Cp)", "1",
- 0 },
- { "PreserveIdentifierCase", "Cu",
- "Maps all identifiers to upper case. (/Cu)", "2", 0 },
- { "PreserveIdentifierCase", "Cx",
- "Preserves case in public and extern symbols. (/Cx)", "3", 0 },
-
- { "WarningLevel", "W0", "Warning Level 0 (/W0)", "0", 0 },
- { "WarningLevel", "W1", "Warning Level 1 (/W1)", "1", 0 },
- { "WarningLevel", "W2", "Warning Level 2 (/W2)", "2", 0 },
- { "WarningLevel", "W3", "Warning Level 3 (/W3)", "3", 0 },
-
- { "PackAlignmentBoundary", "", "Default", "0", 0 },
- { "PackAlignmentBoundary", "Zp1", "One Byte Boundary (/Zp1)", "1", 0 },
- { "PackAlignmentBoundary", "Zp2", "Two Byte Boundary (/Zp2)", "2", 0 },
- { "PackAlignmentBoundary", "Zp4", "Four Byte Boundary (/Zp4)", "3", 0 },
- { "PackAlignmentBoundary", "Zp8", "Eight Byte Boundary (/Zp8)", "4", 0 },
- { "PackAlignmentBoundary", "Zp16", "Sixteen Byte Boundary (/Zp16)", "5", 0 },
-
- { "CallingConvention", "", "Default", "0", 0 },
- { "CallingConvention", "Gd", "Use C-style Calling Convention (/Gd)", "1",
- 0 },
- { "CallingConvention", "Gz", "Use stdcall Calling Convention (/Gz)", "2",
- 0 },
- { "CallingConvention", "Gc", "Use Pascal Calling Convention (/Gc)", "3", 0 },
-
- { "ErrorReporting", "errorReport:prompt",
- "Prompt to send report immediately (/errorReport:prompt)", "0", 0 },
- { "ErrorReporting", "errorReport:queue",
- "Prompt to send report at the next logon (/errorReport:queue)", "1", 0 },
- { "ErrorReporting", "errorReport:send",
- "Automatically send report (/errorReport:send)", "2", 0 },
- { "ErrorReporting", "errorReport:none",
- "Do not send report (/errorReport:none)", "3", 0 },
-
- // Bool Properties
- { "NoLogo", "nologo", "", "true", 0 },
- { "GeneratePreprocessedSourceListing", "EP", "", "true", 0 },
- { "ListAllAvailableInformation", "Sa", "", "true", 0 },
- { "UseSafeExceptionHandlers", "safeseh", "", "true", 0 },
- { "AddFirstPassListing", "Sf", "", "true", 0 },
- { "EnableAssemblyGeneratedCodeListing", "Sg", "", "true", 0 },
- { "DisableSymbolTable", "Sn", "", "true", 0 },
- { "EnableFalseConditionalsInListing", "Sx", "", "true", 0 },
- { "TreatWarningsAsErrors", "WX", "", "true", 0 },
- { "MakeAllSymbolsPublic", "Zf", "", "true", 0 },
- { "GenerateDebugInformation", "Zi", "", "true", 0 },
- { "EnableMASM51Compatibility", "Zm", "", "true", 0 },
- { "PerformSyntaxCheckOnly", "Zs", "", "true", 0 },
-
- // Bool Properties With Argument
-
- // String List Properties
- { "PreprocessorDefinitions", "D", "Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "IncludePaths", "I", "Include Paths", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "BrowseFile", "FR", "Generate Browse Information File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- // Skip [AdditionalDependencies] - no command line Switch.
-
- // String Properties
- // Skip [Inputs] - no command line Switch.
- { "ObjectFileName", "Fo", "Object File Name", "",
- cmVS7FlagTable::UserValue },
- { "AssembledCodeListingFile", "Fl", "Assembled Code Listing File", "",
- cmVS7FlagTable::UserValue },
- // Skip [CommandLineTemplate] - no command line Switch.
- // Skip [ExecutionDescription] - no command line Switch.
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS10NASMFlagTable.h b/Source/cmVS10NASMFlagTable.h
deleted file mode 100644
index b91af9270..000000000
--- a/Source/cmVS10NASMFlagTable.h
+++ /dev/null
@@ -1,50 +0,0 @@
-static cmVS7FlagTable cmVS10NASMFlagTable[] = {
-
- // Enum Properties
- { "Outputswitch", "fwin32", "", "0", 0 },
- { "Outputswitch", "fwin", "", "0", 0 },
- { "Outputswitch", "fwin64", "", "1", 0 },
- { "Outputswitch", "felf", "", "2", 0 },
- { "Outputswitch", "felf32", "", "2", 0 },
- { "Outputswitch", "felf64", "", "3", 0 },
-
- { "ErrorReportingFormat", "Xgnu", "", "-Xgnu GNU format: Default format",
- 0 },
- { "ErrorReportingFormat", "Xvc", "",
- "-Xvc Style used by Microsoft Visual C++", 0 },
-
- // Bool Properties
- { "TreatWarningsAsErrors", "Werror", "", "true", 0 },
- { "GenerateDebugInformation", "g", "", "true", 0 },
- { "floatunderflow", "w+float-underflow", "", "true", 0 },
- { "macrodefaults", "w-macro-defaults", "", "true", 0 },
- { "user", "w-user", "%warning directives (default on)", "true", 0 },
- { "floatoverflow", "w-float-overflow", "", "true", 0 },
- { "floatdenorm", "w+float-denorm", "", "true", 0 },
- { "numberoverflow", "w-number-overflow", "", "true", 0 },
- { "macroselfref", "w+macro-selfref", "", "true", 0 },
- { "floattoolong", "w-float-toolong", "", "true", 0 },
- { "orphanlabels", "w-orphan-labels", "", "true", 0 },
- { "tasmmode", "t", "", "true", 0 },
-
- // Bool Properties With Argument
-
- // String List Properties
- { "PreprocessorDefinitions", "D", "Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "UndefinePreprocessorDefinitions", "U",
- "Undefine Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "IncludePaths", "I", "Include Paths", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AssembledCodeListingFile", "l",
- "Generates an assembled code listing file.", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- // Skip [Inputs] - no command line Switch.
- // Skip [CommandLineTemplate] - no command line Switch.
- // Skip [ExecutionDescription] - no command line Switch.
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS10RCFlagTable.h b/Source/cmVS10RCFlagTable.h
deleted file mode 100644
index 6e2b8344c..000000000
--- a/Source/cmVS10RCFlagTable.h
+++ /dev/null
@@ -1,7 +0,0 @@
-static cmVS7FlagTable cmVS10RCFlagTable[] = {
- // Bool Properties
- { "NullTerminateStrings", "n", "", "true", 0 },
- { "SuppressStartupBanner", "nologo", "", "true", 0 },
-
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS11CLFlagTable.h b/Source/cmVS11CLFlagTable.h
deleted file mode 100644
index 75317093f..000000000
--- a/Source/cmVS11CLFlagTable.h
+++ /dev/null
@@ -1,219 +0,0 @@
-static cmVS7FlagTable cmVS11CLFlagTable[] = {
-
- // Enum Properties
- { "DebugInformationFormat", "", "None", "None", 0 },
- { "DebugInformationFormat", "Z7", "C7 compatible", "OldStyle", 0 },
- { "DebugInformationFormat", "Zi", "Program Database", "ProgramDatabase", 0 },
- { "DebugInformationFormat", "ZI", "Program Database for Edit And Continue",
- "EditAndContinue", 0 },
-
- { "WarningLevel", "W0", "Turn Off All Warnings", "TurnOffAllWarnings", 0 },
- { "WarningLevel", "W1", "Level1", "Level1", 0 },
- { "WarningLevel", "W2", "Level2", "Level2", 0 },
- { "WarningLevel", "W3", "Level3", "Level3", 0 },
- { "WarningLevel", "W4", "Level4", "Level4", 0 },
- { "WarningLevel", "Wall", "EnableAllWarnings", "EnableAllWarnings", 0 },
-
- { "Optimization", "Od", "Disabled", "Disabled", 0 },
- { "Optimization", "O1", "Minimize Size", "MinSpace", 0 },
- { "Optimization", "O2", "Maximize Speed", "MaxSpeed", 0 },
- { "Optimization", "Ox", "Full Optimization", "Full", 0 },
-
- { "InlineFunctionExpansion", "", "Default", "Default", 0 },
- { "InlineFunctionExpansion", "Ob0", "Disabled", "Disabled", 0 },
- { "InlineFunctionExpansion", "Ob1", "Only __inline", "OnlyExplicitInline",
- 0 },
- { "InlineFunctionExpansion", "Ob2", "Any Suitable", "AnySuitable", 0 },
-
- { "FavorSizeOrSpeed", "Os", "Favor small code", "Size", 0 },
- { "FavorSizeOrSpeed", "Ot", "Favor fast code", "Speed", 0 },
- { "FavorSizeOrSpeed", "", "Neither", "Neither", 0 },
-
- { "ExceptionHandling", "EHa", "Yes with SEH Exceptions", "Async", 0 },
- { "ExceptionHandling", "EHsc", "Yes", "Sync", 0 },
- { "ExceptionHandling", "EHs", "Yes with Extern C functions", "SyncCThrow",
- 0 },
- { "ExceptionHandling", "", "No", "false", 0 },
-
- { "BasicRuntimeChecks", "RTCs", "Stack Frames", "StackFrameRuntimeCheck",
- 0 },
- { "BasicRuntimeChecks", "RTCu", "Uninitialized variables",
- "UninitializedLocalUsageCheck", 0 },
- { "BasicRuntimeChecks", "RTC1", "Both (/RTC1, equiv. to /RTCsu)",
- "EnableFastChecks", 0 },
- { "BasicRuntimeChecks", "", "Default", "Default", 0 },
-
- { "RuntimeLibrary", "MT", "Multi-threaded", "MultiThreaded", 0 },
- { "RuntimeLibrary", "MTd", "Multi-threaded Debug", "MultiThreadedDebug", 0 },
- { "RuntimeLibrary", "MD", "Multi-threaded DLL", "MultiThreadedDLL", 0 },
- { "RuntimeLibrary", "MDd", "Multi-threaded Debug DLL",
- "MultiThreadedDebugDLL", 0 },
-
- { "StructMemberAlignment", "Zp1", "1 Byte", "1Byte", 0 },
- { "StructMemberAlignment", "Zp2", "2 Bytes", "2Bytes", 0 },
- { "StructMemberAlignment", "Zp4", "4 Byte", "4Bytes", 0 },
- { "StructMemberAlignment", "Zp8", "8 Bytes", "8Bytes", 0 },
- { "StructMemberAlignment", "Zp16", "16 Bytes", "16Bytes", 0 },
- { "StructMemberAlignment", "", "Default", "Default", 0 },
-
- { "EnableEnhancedInstructionSet", "arch:SSE", "Streaming SIMD Extensions",
- "StreamingSIMDExtensions", 0 },
- { "EnableEnhancedInstructionSet", "arch:SSE2", "Streaming SIMD Extensions 2",
- "StreamingSIMDExtensions2", 0 },
- { "EnableEnhancedInstructionSet", "arch:AVX", "Advanced Vector Extensions",
- "AdvancedVectorExtensions", 0 },
- { "EnableEnhancedInstructionSet", "arch:IA32", "No Enhanced Instructions",
- "NoExtensions", 0 },
- { "EnableEnhancedInstructionSet", "", "Not Set", "NotSet", 0 },
-
- { "FloatingPointModel", "fp:precise", "Precise", "Precise", 0 },
- { "FloatingPointModel", "fp:strict", "Strict", "Strict", 0 },
- { "FloatingPointModel", "fp:fast", "Fast", "Fast", 0 },
-
- { "PrecompiledHeader", "Yc", "Create", "Create",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "PrecompiledHeader", "Yu", "Use", "Use",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 },
-
- { "AssemblerOutput", "", "No Listing", "NoListing", 0 },
- { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 },
- { "AssemblerOutput", "FAc", "Assembly With Machine Code",
- "AssemblyAndMachineCode", 0 },
- { "AssemblerOutput", "FAs", "Assembly With Source Code",
- "AssemblyAndSourceCode", 0 },
- { "AssemblerOutput", "FAcs", "Assembly, Machine Code and Source", "All", 0 },
-
- { "CallingConvention", "Gd", "__cdecl", "Cdecl", 0 },
- { "CallingConvention", "Gr", "__fastcall", "FastCall", 0 },
- { "CallingConvention", "Gz", "__stdcall", "StdCall", 0 },
-
- { "CompileAs", "", "Default", "Default", 0 },
- { "CompileAs", "TC", "Compile as C Code", "CompileAsC", 0 },
- { "CompileAs", "TP", "Compile as C++ Code", "CompileAsCpp", 0 },
-
- { "ErrorReporting", "errorReport:none", "Do Not Send Report", "None", 0 },
- { "ErrorReporting", "errorReport:prompt", "Prompt Immediately", "Prompt",
- 0 },
- { "ErrorReporting", "errorReport:queue", "Queue For Next Login", "Queue",
- 0 },
- { "ErrorReporting", "errorReport:send", "Send Automatically", "Send", 0 },
-
- { "CompileAsManaged", "", "No Common Language RunTime Support", "false", 0 },
- { "CompileAsManaged", "clr", "Common Language RunTime Support", "true", 0 },
- { "CompileAsManaged", "clr:pure",
- "Pure MSIL Common Language RunTime Support", "Pure", 0 },
- { "CompileAsManaged", "clr:safe",
- "Safe MSIL Common Language RunTime Support", "Safe", 0 },
- { "CompileAsManaged", "clr:oldSyntax",
- "Common Language RunTime Support, Old Syntax", "OldSyntax", 0 },
-
- // Bool Properties
- { "CompileAsWinRT", "ZW", "", "true", 0 },
- { "WinRTNoStdLib", "ZW:nostdlib", "", "true", 0 },
- { "SuppressStartupBanner", "nologo-", "", "false", 0 },
- { "SuppressStartupBanner", "nologo", "", "true", 0 },
- { "TreatWarningAsError", "WX-", "", "false", 0 },
- { "TreatWarningAsError", "WX", "", "true", 0 },
- { "SDLCheck", "sdl-", "", "false", 0 },
- { "SDLCheck", "sdl", "", "true", 0 },
- { "IntrinsicFunctions", "Oi", "", "true", 0 },
- { "OmitFramePointers", "Oy-", "", "false", 0 },
- { "OmitFramePointers", "Oy", "", "true", 0 },
- { "EnableFiberSafeOptimizations", "GT", "", "true", 0 },
- { "WholeProgramOptimization", "GL", "", "true", 0 },
- { "UndefineAllPreprocessorDefinitions", "u", "", "true", 0 },
- { "IgnoreStandardIncludePath", "X", "", "true", 0 },
- { "PreprocessToFile", "P", "", "true", 0 },
- { "PreprocessSuppressLineNumbers", "EP", "", "true", 0 },
- { "PreprocessKeepComments", "C", "", "true", 0 },
- { "StringPooling", "GF-", "", "false", 0 },
- { "StringPooling", "GF", "", "true", 0 },
- { "MinimalRebuild", "Gm-", "", "false", 0 },
- { "MinimalRebuild", "Gm", "", "true", 0 },
- { "SmallerTypeCheck", "RTCc", "", "true", 0 },
- { "BufferSecurityCheck", "GS-", "", "false", 0 },
- { "BufferSecurityCheck", "GS", "", "true", 0 },
- { "FunctionLevelLinking", "Gy-", "", "false", 0 },
- { "FunctionLevelLinking", "Gy", "", "true", 0 },
- { "EnableParallelCodeGeneration", "Qpar-", "", "false", 0 },
- { "EnableParallelCodeGeneration", "Qpar", "", "true", 0 },
- { "FloatingPointExceptions", "fp:except-", "", "false", 0 },
- { "FloatingPointExceptions", "fp:except", "", "true", 0 },
- { "CreateHotpatchableImage", "hotpatch", "", "true", 0 },
- { "DisableLanguageExtensions", "Za", "", "true", 0 },
- { "TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0 },
- { "TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0 },
- { "ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0 },
- { "ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0 },
- { "RuntimeTypeInfo", "GR-", "", "false", 0 },
- { "RuntimeTypeInfo", "GR", "", "true", 0 },
- { "OpenMPSupport", "openmp-", "", "false", 0 },
- { "OpenMPSupport", "openmp", "", "true", 0 },
- { "ExpandAttributedSource", "Fx", "", "true", 0 },
- { "UseUnicodeForAssemblerListing", "FAu", "", "true", 0 },
- { "ShowIncludes", "showIncludes", "", "true", 0 },
- { "EnablePREfast", "analyze-", "", "false", 0 },
- { "EnablePREfast", "analyze", "", "true", 0 },
- { "UseFullPaths", "FC", "", "true", 0 },
- { "OmitDefaultLibName", "Zl", "", "true", 0 },
-
- // Bool Properties With Argument
- { "MultiProcessorCompilation", "MP", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "ProcessorNumber", "MP", "Multi-processor Compilation", "",
- cmVS7FlagTable::UserValueRequired },
- { "GenerateXMLDocumentationFiles", "doc", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "",
- cmVS7FlagTable::UserValueRequired },
- { "BrowseInformation", "FR", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "BrowseInformationFile", "FR", "Enable Browse Information", "",
- cmVS7FlagTable::UserValueRequired },
-
- // String List Properties
- { "AdditionalIncludeDirectories", "I", "Additional Include Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AdditionalUsingDirectories", "AI", "Additional #using Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "PreprocessorDefinitions", "D ", "Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "UndefinePreprocessorDefinitions", "U",
- "Undefine Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "DisableSpecificWarnings", "wd", "Disable Specific Warnings", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForcedIncludeFiles", "FI", "Forced Include File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForcedUsingFiles", "FU", "Forced #using File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "PREfastLog", "analyze:log", "Code Analysis Log", "",
- cmVS7FlagTable::UserFollowing },
- { "PREfastAdditionalPlugins", "analyze:plugin",
- "Additional Code Analysis Native plugins", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "TreatSpecificWarningsAsErrors", "we", "Treat Specific Warnings As Errors",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- // Skip [TrackerLogDirectory] - no command line Switch.
- { "PreprocessOutputPath", "Fi", "Preprocess Output Path", "",
- cmVS7FlagTable::UserValue },
- { "PrecompiledHeaderFile", "Yc", "Precompiled Header Name", "",
- cmVS7FlagTable::UserValueRequired },
- { "PrecompiledHeaderFile", "Yu", "Precompiled Header Name", "",
- cmVS7FlagTable::UserValueRequired },
- { "PrecompiledHeaderOutputFile", "Fp", "Precompiled Header Output File", "",
- cmVS7FlagTable::UserValue },
- { "AssemblerListingLocation", "Fa", "ASM List Location", "",
- cmVS7FlagTable::UserValue },
- { "ObjectFileName", "Fo", "Object File Name", "",
- cmVS7FlagTable::UserValue },
- { "ProgramDataBaseFileName", "Fd", "Program Database File Name", "",
- cmVS7FlagTable::UserValue },
- // Skip [XMLDocumentationFileName] - no command line Switch.
- // Skip [BrowseInformationFile] - no command line Switch.
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS11CSharpFlagTable.h b/Source/cmVS11CSharpFlagTable.h
deleted file mode 100644
index 71870b698..000000000
--- a/Source/cmVS11CSharpFlagTable.h
+++ /dev/null
@@ -1,120 +0,0 @@
-static cmVS7FlagTable cmVS11CSharpFlagTable[] = {
- { "ProjectName", "out:", "", "", cmIDEFlagTable::UserValueRequired },
-
- { "OutputType", "target:exe", "", "Exe", 0 },
- { "OutputType", "target:winexe", "", "Winexe", 0 },
- { "OutputType", "target:library", "", "Library", 0 },
- { "OutputType", "target:module", "", "Module", 0 },
-
- { "DocumentationFile", "doc", "", "", cmIDEFlagTable::UserValueRequired },
-
- { "Platform", "platform:x86", "", "x86", 0 },
- { "Platform", "platform:Itanium", "", "Itanium", 0 },
- { "Platform", "platform:x64", "", "x64", 0 },
- { "Platform", "platform:arm", "", "arm", 0 },
- { "Platform", "platform:anycpu32bitpreferred", "", "anycpu32bitpreferred",
- 0 },
- { "Platform", "platform:anycpu", "", "anycpu", 0 },
-
- { "References", "reference:", "mit alias", "", 0 },
- { "References", "reference:", "dateiliste", "", 0 },
- { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable },
- { "", "link", "", "", 0 },
-
- { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired },
- { "ApplicationIcon", "win32icon", "", "",
- cmIDEFlagTable::UserValueRequired },
-
- { "Win32Manifest", "win32manifest:", "", "true", 0 },
-
- { "NoWin32Manifest", "nowin32manifest", "", "true", 0 },
-
- { "DefineDebug", "debug", "", "true", cmIDEFlagTable::Continue },
-
- { "DebugSymbols", "debug", "", "true", 0 },
- { "DebugSymbols", "debug-", "", "false", 0 },
- { "DebugSymbols", "debug+", "", "true", 0 },
-
- { "DebugType", "debug:none", "", "none", 0 },
- { "DebugType", "debug:full", "", "full", 0 },
- { "DebugType", "debug:pdbonly", "", "pdbonly", 0 },
-
- { "Optimize", "optimize", "", "true", 0 },
- { "Optimize", "optimize-", "", "false", 0 },
- { "Optimize", "optimize+", "", "true", 0 },
-
- { "TreatWarningsAsErrors", "warnaserror", "", "true", 0 },
- { "TreatWarningsAsErrors", "warnaserror-", "", "false", 0 },
- { "TreatWarningsAsErrors", "warnaserror+", "", "true", 0 },
-
- { "WarningsAsErrors", "warnaserror", "", "", 0 },
- { "WarningsAsErrors", "warnaserror-", "", "", 0 },
- { "WarningsAsErrors", "warnaserror+", "", "", 0 },
-
- { "WarningLevel", "warn:0", "", "0", 0 },
- { "WarningLevel", "warn:1", "", "1", 0 },
- { "WarningLevel", "warn:2", "", "2", 0 },
- { "WarningLevel", "warn:3", "", "3", 0 },
- { "WarningLevel", "warn:4", "", "4", 0 },
- { "DisabledWarnings", "nowarn", "", "", 0 },
-
- { "CheckForOverflowUnderflow", "checked", "", "true", 0 },
- { "CheckForOverflowUnderflow", "checked-", "", "false", 0 },
- { "CheckForOverflowUnderflow", "checked+", "", "true", 0 },
-
- { "AllowUnsafeBlocks", "unsafe", "", "true", 0 },
- { "AllowUnsafeBlocks", "unsafe-", "", "false", 0 },
- { "AllowUnsafeBlocks", "unsafe+", "", "true", 0 },
-
- { "DefineConstants", "define:", "", "",
- cmIDEFlagTable::SemicolonAppendable | cmIDEFlagTable::UserValue },
-
- { "LangVersion", "langversion:ISO-1", "", "ISO-1", 0 },
- { "LangVersion", "langversion:ISO-2", "", "ISO-2", 0 },
- { "LangVersion", "langversion:3", "", "3", 0 },
- { "LangVersion", "langversion:4", "", "4", 0 },
- { "LangVersion", "langversion:5", "", "5", 0 },
- { "LangVersion", "langversion:6", "", "6", 0 },
- { "LangVersion", "langversion:default", "", "default", 0 },
-
- { "DelaySign", "delaysign", "", "true", 0 },
- { "DelaySign", "delaysign-", "", "false", 0 },
- { "DelaySign", "delaysign+", "", "true", 0 },
-
- { "AssemblyOriginatorKeyFile", "keyfile", "", "", 0 },
-
- { "KeyContainerName", "keycontainer", "", "", 0 },
-
- { "NoLogo", "nologo", "", "", 0 },
-
- { "NoConfig", "noconfig", "", "true", 0 },
-
- { "BaseAddress", "baseaddress:", "", "", 0 },
-
- { "CodePage", "codepage", "", "", 0 },
-
- { "Utf8Output", "utf8output", "", "", 0 },
-
- { "MainEntryPoint", "main:", "", "", 0 },
-
- { "GenerateFullPaths", "fullpaths", "", "true", 0 },
-
- { "FileAlignment", "filealign", "", "", 0 },
-
- { "PdbFile", "pdb:", "", "", 0 },
-
- { "NoStandardLib", "nostdlib", "", "true", 0 },
- { "NoStandardLib", "nostdlib-", "", "false", 0 },
- { "NoStandardLib", "nostdlib+", "", "true", 0 },
-
- { "SubsystemVersion", "subsystemversion", "", "", 0 },
-
- { "AdditionalLibPaths", "lib:", "", "", 0 },
-
- { "ErrorReport", "errorreport:none", "Do Not Send Report", "none", 0 },
- { "ErrorReport", "errorreport:prompt", "Prompt Immediately", "prompt", 0 },
- { "ErrorReport", "errorreport:queue", "Queue For Next Login", "queue", 0 },
- { "ErrorReport", "errorreport:send", "Send Automatically", "send", 0 },
-
- { 0, 0, 0, 0, 0 },
-};
diff --git a/Source/cmVS11LibFlagTable.h b/Source/cmVS11LibFlagTable.h
deleted file mode 100644
index 8aacaacd3..000000000
--- a/Source/cmVS11LibFlagTable.h
+++ /dev/null
@@ -1,76 +0,0 @@
-static cmVS7FlagTable cmVS11LibFlagTable[] = {
-
- // Enum Properties
- { "ErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
- "PromptImmediately", 0 },
- { "ErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
- "QueueForNextLogin", 0 },
- { "ErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
- "SendErrorReport", 0 },
- { "ErrorReporting", "ERRORREPORT:NONE", "No Error Report", "NoErrorReport",
- 0 },
-
- { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
- { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
- { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
- { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
- { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
- { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
- 0 },
- { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
- "MachineMIPSFPU16", 0 },
- { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
- { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
- { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
- { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
-
- { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
- { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
- "EFI Application", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
- "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
- 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWSCE", "WindowsCE", "WindowsCE", 0 },
- { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
-
- // Bool Properties
- { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
- { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
- { "TreatLibWarningAsErrors", "WX:NO", "", "false", 0 },
- { "TreatLibWarningAsErrors", "WX", "", "true", 0 },
- { "Verbose", "VERBOSE", "", "true", 0 },
- { "LinkTimeCodeGeneration", "LTCG", "", "true", 0 },
-
- // Bool Properties With Argument
-
- // String List Properties
- // Skip [AdditionalDependencies] - no command line Switch.
- { "AdditionalLibraryDirectories", "LIBPATH:",
- "Additional Library Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
- "Ignore Specific Default Libraries", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ExportNamedFunctions", "EXPORT:", "Export Named Functions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "RemoveObjects", "REMOVE:", "Remove Objects", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
- { "ModuleDefinitionFile", "DEF:", "Module Definition File Name", "",
- cmVS7FlagTable::UserValue },
- { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
- cmVS7FlagTable::UserValue },
- { "DisplayLibrary", "LIST:", "Display Library to standard output", "",
- cmVS7FlagTable::UserValue },
- // Skip [MinimumRequiredVersion] - no command line Switch.
- { "Name", "NAME:", "Name", "", cmVS7FlagTable::UserValue },
- // Skip [AdditionalOptions] - no command line Switch.
- // Skip [TrackerLogDirectory] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS11LinkFlagTable.h b/Source/cmVS11LinkFlagTable.h
deleted file mode 100644
index 1b3a046f6..000000000
--- a/Source/cmVS11LinkFlagTable.h
+++ /dev/null
@@ -1,269 +0,0 @@
-static cmVS7FlagTable cmVS11LinkFlagTable[] = {
-
- // Enum Properties
- { "ShowProgress", "", "Not Set", "NotSet", 0 },
- { "ShowProgress", "VERBOSE", "Display all progress messages", "LinkVerbose",
- 0 },
- { "ShowProgress", "VERBOSE:Lib", "For Libraries Searched", "LinkVerboseLib",
- 0 },
- { "ShowProgress", "VERBOSE:ICF",
- "About COMDAT folding during optimized linking", "LinkVerboseICF", 0 },
- { "ShowProgress", "VERBOSE:REF",
- "About data removed during optimized linking", "LinkVerboseREF", 0 },
- { "ShowProgress", "VERBOSE:SAFESEH", "About Modules incompatible with SEH",
- "LinkVerboseSAFESEH", 0 },
- { "ShowProgress", "VERBOSE:CLR",
- "About linker activity related to managed code", "LinkVerboseCLR", 0 },
-
- { "ForceFileOutput", "FORCE", "Enabled", "Enabled", 0 },
- { "ForceFileOutput", "FORCE:MULTIPLE", "Multiply Defined Symbol Only",
- "MultiplyDefinedSymbolOnly", 0 },
- { "ForceFileOutput", "FORCE:UNRESOLVED", "Undefined Symbol Only",
- "UndefinedSymbolOnly", 0 },
-
- { "CreateHotPatchableImage", "FUNCTIONPADMIN", "Enabled", "Enabled", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:5", "X86 Image Only",
- "X86Image", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:6", "X64 Image Only",
- "X64Image", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only",
- "ItaniumImage", 0 },
-
- { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 },
- { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable",
- "HighestAvailable", 0 },
- { "UACExecutionLevel", "level='requireAdministrator'",
- "requireAdministrator", "RequireAdministrator", 0 },
-
- { "SubSystem", "", "Not Set", "NotSet", 0 },
- { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
- { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
- "EFI Application", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
- "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
- 0 },
- { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
-
- { "Driver", "", "Not Set", "NotSet", 0 },
- { "Driver", "Driver", "Driver", "Driver", 0 },
- { "Driver", "DRIVER:UPONLY", "UP Only", "UpOnly", 0 },
- { "Driver", "DRIVER:WDM", "WDM", "WDM", 0 },
-
- { "LinkTimeCodeGeneration", "", "Default", "Default", 0 },
- { "LinkTimeCodeGeneration", "LTCG", "Use Link Time Code Generation",
- "UseLinkTimeCodeGeneration", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGInstrument",
- "Profile Guided Optimization - Instrument", "PGInstrument", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGOptimize",
- "Profile Guided Optimization - Optimization", "PGOptimization", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGUpdate",
- "Profile Guided Optimization - Update", "PGUpdate", 0 },
-
- { "GenerateWindowsMetadata", "WINMD", "Yes", "true", 0 },
- { "GenerateWindowsMetadata", "WINMD:NO", "No", "false", 0 },
-
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
-
- { "TargetMachine", "", "Not Set", "NotSet", 0 },
- { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
- { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
- { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
- { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
- { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
- { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
- 0 },
- { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
- "MachineMIPSFPU16", 0 },
- { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
- { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
- { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
- { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
-
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA", "MTA threading attribute",
- "MTAThreadingAttribute", 0 },
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA", "STA threading attribute",
- "STAThreadingAttribute", 0 },
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE",
- "Default threading attribute", "DefaultThreadingAttribute", 0 },
-
- { "CLRImageType", "CLRIMAGETYPE:IJW", "Force IJW image", "ForceIJWImage",
- 0 },
- { "CLRImageType", "CLRIMAGETYPE:PURE", "Force Pure IL Image",
- "ForcePureILImage", 0 },
- { "CLRImageType", "CLRIMAGETYPE:SAFE", "Force Safe IL Image",
- "ForceSafeILImage", 0 },
- { "CLRImageType", "", "Default image type", "Default", 0 },
-
- { "SignHash", "CLRSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
- { "SignHash", "CLRSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
- { "SignHash", "CLRSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
- { "SignHash", "CLRSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
-
- { "LinkErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
- "PromptImmediately", 0 },
- { "LinkErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
- "QueueForNextLogin", 0 },
- { "LinkErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
- "SendErrorReport", 0 },
- { "LinkErrorReporting", "ERRORREPORT:NONE", "No Error Report",
- "NoErrorReport", 0 },
-
- { "CLRSupportLastError", "CLRSupportLastError", "Enabled", "Enabled", 0 },
- { "CLRSupportLastError", "CLRSupportLastError:NO", "Disabled", "Disabled",
- 0 },
- { "CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL", "System Dlls Only",
- "SystemDlls", 0 },
-
- // Bool Properties
- { "LinkIncremental", "INCREMENTAL:NO", "", "false", 0 },
- { "LinkIncremental", "INCREMENTAL", "", "true", 0 },
- { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
- { "LinkStatus", "LTCG:NOSTATUS", "", "false", 0 },
- { "LinkStatus", "LTCG:STATUS", "", "true", 0 },
- { "PreventDllBinding", "ALLOWBIND:NO", "", "false", 0 },
- { "PreventDllBinding", "ALLOWBIND", "", "true", 0 },
- { "TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0 },
- { "TreatLinkerWarningAsErrors", "WX", "", "true", 0 },
- { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
- { "GenerateManifest", "MANIFEST:NO", "", "false", 0 },
- { "GenerateManifest", "MANIFEST", "", "true", 0 },
- { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 },
- { "UACUIAccess", "uiAccess='false'", "", "false", 0 },
- { "UACUIAccess", "uiAccess='true'", "", "true", 0 },
- { "ManifestEmbed", "manifest:embed", "", "true", 0 },
- { "GenerateDebugInformation", "DEBUG", "", "true",
- cmVS7FlagTable::CaseInsensitive },
- { "MapExports", "MAPINFO:EXPORTS", "", "true", 0 },
- { "AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0 },
- { "AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0 },
- { "LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0 },
- { "LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0 },
- { "TerminalServerAware", "TSAWARE:NO", "", "false", 0 },
- { "TerminalServerAware", "TSAWARE", "", "true", 0 },
- { "SwapRunFromCD", "SWAPRUN:CD", "", "true", 0 },
- { "SwapRunFromNET", "SWAPRUN:NET", "", "true", 0 },
- { "OptimizeReferences", "OPT:NOREF", "", "false", 0 },
- { "OptimizeReferences", "OPT:REF", "", "true", 0 },
- { "EnableCOMDATFolding", "OPT:NOICF", "", "false", 0 },
- { "EnableCOMDATFolding", "OPT:ICF", "", "true", 0 },
- { "IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0 },
- { "AppContainer", "APPCONTAINER", "", "true", 0 },
- { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN:NO", "", "false", 0 },
- { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN", "", "true", 0 },
- { "NoEntryPoint", "NOENTRY", "", "true", 0 },
- { "SetChecksum", "RELEASE", "", "true", 0 },
- { "RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0 },
- { "RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0 },
- { "FixedBaseAddress", "FIXED:NO", "", "false", 0 },
- { "FixedBaseAddress", "FIXED", "", "true", 0 },
- { "DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0 },
- { "DataExecutionPrevention", "NXCOMPAT", "", "true", 0 },
- { "TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0 },
- { "SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0 },
- { "SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0 },
- { "Profile", "PROFILE", "", "true", 0 },
- { "LinkDelaySign", "DELAYSIGN:NO", "", "false", 0 },
- { "LinkDelaySign", "DELAYSIGN", "", "true", 0 },
- { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0 },
- { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0 },
- { "DetectOneDefinitionRule", "ODR", "", "true", 0 },
- { "ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0 },
- { "ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0 },
- { "LinkDLL", "DLL", "", "true", 0 },
-
- // Bool Properties With Argument
- { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 },
- { "EnableUAC", "MANIFESTUAC:", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
- cmVS7FlagTable::UserValueRequired },
- { "GenerateMapFile", "MAP", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "MapFileName", "MAP:", "Generate Map File", "",
- cmVS7FlagTable::UserValueRequired },
-
- // String List Properties
- { "AdditionalLibraryDirectories", "LIBPATH:",
- "Additional Library Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- // Skip [AdditionalDependencies] - no command line Switch.
- { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
- "Ignore Specific Default Libraries", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AddModuleNamesToAssembly", "ASSEMBLYMODULE:", "Add Module to Assembly",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "EmbedManagedResourceFile", "ASSEMBLYRESOURCE:",
- "Embed Managed Resource File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "DelayLoadDLLs", "DELAYLOAD:", "Delay Loaded Dlls", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:", "Assembly Link Resource",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AdditionalManifestDependencies", "MANIFESTDEPENDENCY:",
- "Additional Manifest Dependencies", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ManifestInput", "manifestinput:", "Manifest Input", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
- { "Version", "VERSION:", "Version", "", cmVS7FlagTable::UserValue },
- { "SpecifySectionAttributes", "SECTION:", "Specify Section Attributes", "",
- cmVS7FlagTable::UserValue },
- { "MSDOSStubFileName", "STUB:", "MS-DOS Stub File Name", "",
- cmVS7FlagTable::UserValue },
- // Skip [TrackerLogDirectory] - no command line Switch.
- { "ModuleDefinitionFile", "DEF:", "Module Definition File", "",
- cmVS7FlagTable::UserValue },
- { "ManifestFile", "ManifestFile:", "Manifest File", "",
- cmVS7FlagTable::UserValue },
- { "ProgramDatabaseFile", "PDB:", "Generate Program Database File", "",
- cmVS7FlagTable::UserValue },
- { "StripPrivateSymbols", "PDBSTRIPPED:", "Strip Private Symbols", "",
- cmVS7FlagTable::UserValue },
- // Skip [MapFileName] - no command line Switch.
- // Skip [MinimumRequiredVersion] - no command line Switch.
- { "HeapReserveSize", "HEAP:", "Heap Reserve Size", "",
- cmVS7FlagTable::UserValue },
- // Skip [HeapCommitSize] - no command line Switch.
- { "StackReserveSize", "STACK:", "Stack Reserve Size", "",
- cmVS7FlagTable::UserValue },
- // Skip [StackCommitSize] - no command line Switch.
- { "FunctionOrder", "ORDER:@", "Function Order", "",
- cmVS7FlagTable::UserValue },
- { "ProfileGuidedDatabase", "PGD:", "Profile Guided Database", "",
- cmVS7FlagTable::UserValue },
- { "MidlCommandFile", "MIDL:@", "MIDL Commands", "",
- cmVS7FlagTable::UserValue },
- { "MergedIDLBaseFileName", "IDLOUT:", "Merged IDL Base File Name", "",
- cmVS7FlagTable::UserValue },
- { "TypeLibraryFile", "TLBOUT:", "Type Library", "",
- cmVS7FlagTable::UserValue },
- { "WindowsMetadataFile", "WINMDFILE:", "Windows Metadata File", "",
- cmVS7FlagTable::UserValue },
- { "WindowsMetadataLinkKeyFile", "WINMDKEYFILE:", "Windows Metadata Key File",
- "", cmVS7FlagTable::UserValue },
- { "WindowsMetadataKeyContainer", "WINMDKEYCONTAINER:",
- "Windows Metadata Key Container", "", cmVS7FlagTable::UserValue },
- { "EntryPointSymbol", "ENTRY:", "Entry Point", "",
- cmVS7FlagTable::UserValue },
- { "BaseAddress", "BASE:", "Base Address", "", cmVS7FlagTable::UserValue },
- { "ImportLibrary", "IMPLIB:", "Import Library", "",
- cmVS7FlagTable::UserValue },
- { "MergeSections", "MERGE:", "Merge Sections", "",
- cmVS7FlagTable::UserValue },
- { "LinkKeyFile", "KEYFILE:", "Key File", "", cmVS7FlagTable::UserValue },
- { "KeyContainer", "KEYCONTAINER:", "Key Container", "",
- cmVS7FlagTable::UserValue },
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS11MASMFlagTable.h b/Source/cmVS11MASMFlagTable.h
deleted file mode 100644
index fdf8239da..000000000
--- a/Source/cmVS11MASMFlagTable.h
+++ /dev/null
@@ -1,76 +0,0 @@
-static cmVS7FlagTable cmVS11MASMFlagTable[] = {
-
- // Enum Properties
- { "PreserveIdentifierCase", "", "Default", "0", 0 },
- { "PreserveIdentifierCase", "Cp", "Preserves Identifier Case (/Cp)", "1",
- 0 },
- { "PreserveIdentifierCase", "Cu",
- "Maps all identifiers to upper case. (/Cu)", "2", 0 },
- { "PreserveIdentifierCase", "Cx",
- "Preserves case in public and extern symbols. (/Cx)", "3", 0 },
-
- { "WarningLevel", "W0", "Warning Level 0 (/W0)", "0", 0 },
- { "WarningLevel", "W1", "Warning Level 1 (/W1)", "1", 0 },
- { "WarningLevel", "W2", "Warning Level 2 (/W2)", "2", 0 },
- { "WarningLevel", "W3", "Warning Level 3 (/W3)", "3", 0 },
-
- { "PackAlignmentBoundary", "", "Default", "0", 0 },
- { "PackAlignmentBoundary", "Zp1", "One Byte Boundary (/Zp1)", "1", 0 },
- { "PackAlignmentBoundary", "Zp2", "Two Byte Boundary (/Zp2)", "2", 0 },
- { "PackAlignmentBoundary", "Zp4", "Four Byte Boundary (/Zp4)", "3", 0 },
- { "PackAlignmentBoundary", "Zp8", "Eight Byte Boundary (/Zp8)", "4", 0 },
- { "PackAlignmentBoundary", "Zp16", "Sixteen Byte Boundary (/Zp16)", "5", 0 },
-
- { "CallingConvention", "", "Default", "0", 0 },
- { "CallingConvention", "Gd", "Use C-style Calling Convention (/Gd)", "1",
- 0 },
- { "CallingConvention", "Gz", "Use stdcall Calling Convention (/Gz)", "2",
- 0 },
- { "CallingConvention", "Gc", "Use Pascal Calling Convention (/Gc)", "3", 0 },
-
- { "ErrorReporting", "errorReport:prompt",
- "Prompt to send report immediately (/errorReport:prompt)", "0", 0 },
- { "ErrorReporting", "errorReport:queue",
- "Prompt to send report at the next logon (/errorReport:queue)", "1", 0 },
- { "ErrorReporting", "errorReport:send",
- "Automatically send report (/errorReport:send)", "2", 0 },
- { "ErrorReporting", "errorReport:none",
- "Do not send report (/errorReport:none)", "3", 0 },
-
- // Bool Properties
- { "NoLogo", "nologo", "", "true", 0 },
- { "GeneratePreprocessedSourceListing", "EP", "", "true", 0 },
- { "ListAllAvailableInformation", "Sa", "", "true", 0 },
- { "UseSafeExceptionHandlers", "safeseh", "", "true", 0 },
- { "AddFirstPassListing", "Sf", "", "true", 0 },
- { "EnableAssemblyGeneratedCodeListing", "Sg", "", "true", 0 },
- { "DisableSymbolTable", "Sn", "", "true", 0 },
- { "EnableFalseConditionalsInListing", "Sx", "", "true", 0 },
- { "TreatWarningsAsErrors", "WX", "", "true", 0 },
- { "MakeAllSymbolsPublic", "Zf", "", "true", 0 },
- { "GenerateDebugInformation", "Zi", "", "true", 0 },
- { "EnableMASM51Compatibility", "Zm", "", "true", 0 },
- { "PerformSyntaxCheckOnly", "Zs", "", "true", 0 },
-
- // Bool Properties With Argument
-
- // String List Properties
- { "PreprocessorDefinitions", "D", "Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "IncludePaths", "I", "Include Paths", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "BrowseFile", "FR", "Generate Browse Information File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- // Skip [AdditionalDependencies] - no command line Switch.
-
- // String Properties
- // Skip [Inputs] - no command line Switch.
- { "ObjectFileName", "Fo", "Object File Name", "",
- cmVS7FlagTable::UserValue },
- { "AssembledCodeListingFile", "Fl", "Assembled Code Listing File", "",
- cmVS7FlagTable::UserValue },
- // Skip [CommandLineTemplate] - no command line Switch.
- // Skip [ExecutionDescription] - no command line Switch.
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS11RCFlagTable.h b/Source/cmVS11RCFlagTable.h
deleted file mode 100644
index 4997fe115..000000000
--- a/Source/cmVS11RCFlagTable.h
+++ /dev/null
@@ -1,7 +0,0 @@
-static cmVS7FlagTable cmVS11RCFlagTable[] = {
- // Bool Properties
- { "NullTerminateStrings", "n", "", "true", 0 },
- { "SuppressStartupBanner", "nologo", "", "true", 0 },
-
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS12CLFlagTable.h b/Source/cmVS12CLFlagTable.h
deleted file mode 100644
index 9515c91b8..000000000
--- a/Source/cmVS12CLFlagTable.h
+++ /dev/null
@@ -1,221 +0,0 @@
-static cmVS7FlagTable cmVS12CLFlagTable[] = {
-
- // Enum Properties
- { "DebugInformationFormat", "", "None", "None", 0 },
- { "DebugInformationFormat", "Z7", "C7 compatible", "OldStyle", 0 },
- { "DebugInformationFormat", "Zi", "Program Database", "ProgramDatabase", 0 },
- { "DebugInformationFormat", "ZI", "Program Database for Edit And Continue",
- "EditAndContinue", 0 },
-
- { "WarningLevel", "W0", "Turn Off All Warnings", "TurnOffAllWarnings", 0 },
- { "WarningLevel", "W1", "Level1", "Level1", 0 },
- { "WarningLevel", "W2", "Level2", "Level2", 0 },
- { "WarningLevel", "W3", "Level3", "Level3", 0 },
- { "WarningLevel", "W4", "Level4", "Level4", 0 },
- { "WarningLevel", "Wall", "EnableAllWarnings", "EnableAllWarnings", 0 },
-
- { "Optimization", "", "Custom", "Custom", 0 },
- { "Optimization", "Od", "Disabled", "Disabled", 0 },
- { "Optimization", "O1", "Minimize Size", "MinSpace", 0 },
- { "Optimization", "O2", "Maximize Speed", "MaxSpeed", 0 },
- { "Optimization", "Ox", "Full Optimization", "Full", 0 },
-
- { "InlineFunctionExpansion", "", "Default", "Default", 0 },
- { "InlineFunctionExpansion", "Ob0", "Disabled", "Disabled", 0 },
- { "InlineFunctionExpansion", "Ob1", "Only __inline", "OnlyExplicitInline",
- 0 },
- { "InlineFunctionExpansion", "Ob2", "Any Suitable", "AnySuitable", 0 },
-
- { "FavorSizeOrSpeed", "Os", "Favor small code", "Size", 0 },
- { "FavorSizeOrSpeed", "Ot", "Favor fast code", "Speed", 0 },
- { "FavorSizeOrSpeed", "", "Neither", "Neither", 0 },
-
- { "ExceptionHandling", "EHa", "Yes with SEH Exceptions", "Async", 0 },
- { "ExceptionHandling", "EHsc", "Yes", "Sync", 0 },
- { "ExceptionHandling", "EHs", "Yes with Extern C functions", "SyncCThrow",
- 0 },
- { "ExceptionHandling", "", "No", "false", 0 },
-
- { "BasicRuntimeChecks", "RTCs", "Stack Frames", "StackFrameRuntimeCheck",
- 0 },
- { "BasicRuntimeChecks", "RTCu", "Uninitialized variables",
- "UninitializedLocalUsageCheck", 0 },
- { "BasicRuntimeChecks", "RTC1", "Both (/RTC1, equiv. to /RTCsu)",
- "EnableFastChecks", 0 },
- { "BasicRuntimeChecks", "", "Default", "Default", 0 },
-
- { "RuntimeLibrary", "MT", "Multi-threaded", "MultiThreaded", 0 },
- { "RuntimeLibrary", "MTd", "Multi-threaded Debug", "MultiThreadedDebug", 0 },
- { "RuntimeLibrary", "MD", "Multi-threaded DLL", "MultiThreadedDLL", 0 },
- { "RuntimeLibrary", "MDd", "Multi-threaded Debug DLL",
- "MultiThreadedDebugDLL", 0 },
-
- { "StructMemberAlignment", "Zp1", "1 Byte", "1Byte", 0 },
- { "StructMemberAlignment", "Zp2", "2 Bytes", "2Bytes", 0 },
- { "StructMemberAlignment", "Zp4", "4 Byte", "4Bytes", 0 },
- { "StructMemberAlignment", "Zp8", "8 Bytes", "8Bytes", 0 },
- { "StructMemberAlignment", "Zp16", "16 Bytes", "16Bytes", 0 },
- { "StructMemberAlignment", "", "Default", "Default", 0 },
-
- { "BufferSecurityCheck", "GS-", "Disable Security Check", "false", 0 },
- { "BufferSecurityCheck", "GS", "Enable Security Check", "true", 0 },
-
- { "EnableEnhancedInstructionSet", "arch:SSE", "Streaming SIMD Extensions",
- "StreamingSIMDExtensions", 0 },
- { "EnableEnhancedInstructionSet", "arch:SSE2", "Streaming SIMD Extensions 2",
- "StreamingSIMDExtensions2", 0 },
- { "EnableEnhancedInstructionSet", "arch:AVX", "Advanced Vector Extensions",
- "AdvancedVectorExtensions", 0 },
- { "EnableEnhancedInstructionSet", "arch:IA32", "No Enhanced Instructions",
- "NoExtensions", 0 },
- { "EnableEnhancedInstructionSet", "", "Not Set", "NotSet", 0 },
-
- { "FloatingPointModel", "fp:precise", "Precise", "Precise", 0 },
- { "FloatingPointModel", "fp:strict", "Strict", "Strict", 0 },
- { "FloatingPointModel", "fp:fast", "Fast", "Fast", 0 },
-
- { "PrecompiledHeader", "Yc", "Create", "Create",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "PrecompiledHeader", "Yu", "Use", "Use",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 },
-
- { "AssemblerOutput", "", "No Listing", "NoListing", 0 },
- { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 },
- { "AssemblerOutput", "FAc", "Assembly With Machine Code",
- "AssemblyAndMachineCode", 0 },
- { "AssemblerOutput", "FAs", "Assembly With Source Code",
- "AssemblyAndSourceCode", 0 },
- { "AssemblerOutput", "FAcs", "Assembly, Machine Code and Source", "All", 0 },
-
- { "CallingConvention", "Gd", "__cdecl", "Cdecl", 0 },
- { "CallingConvention", "Gr", "__fastcall", "FastCall", 0 },
- { "CallingConvention", "Gz", "__stdcall", "StdCall", 0 },
- { "CallingConvention", "Gv", "__vectorcall", "VectorCall", 0 },
-
- { "CompileAs", "", "Default", "Default", 0 },
- { "CompileAs", "TC", "Compile as C Code", "CompileAsC", 0 },
- { "CompileAs", "TP", "Compile as C++ Code", "CompileAsCpp", 0 },
-
- { "ErrorReporting", "errorReport:none", "Do Not Send Report", "None", 0 },
- { "ErrorReporting", "errorReport:prompt", "Prompt Immediately", "Prompt",
- 0 },
- { "ErrorReporting", "errorReport:queue", "Queue For Next Login", "Queue",
- 0 },
- { "ErrorReporting", "errorReport:send", "Send Automatically", "Send", 0 },
-
- { "CompileAsManaged", "", "No Common Language RunTime Support", "false", 0 },
- { "CompileAsManaged", "clr", "Common Language RunTime Support", "true", 0 },
- { "CompileAsManaged", "clr:pure",
- "Pure MSIL Common Language RunTime Support", "Pure", 0 },
- { "CompileAsManaged", "clr:safe",
- "Safe MSIL Common Language RunTime Support", "Safe", 0 },
- { "CompileAsManaged", "clr:oldSyntax",
- "Common Language RunTime Support, Old Syntax", "OldSyntax", 0 },
-
- // Bool Properties
- { "CompileAsWinRT", "ZW", "", "true", 0 },
- { "WinRTNoStdLib", "ZW:nostdlib", "", "true", 0 },
- { "SuppressStartupBanner", "nologo", "", "true", 0 },
- { "TreatWarningAsError", "WX-", "", "false", 0 },
- { "TreatWarningAsError", "WX", "", "true", 0 },
- { "SDLCheck", "sdl-", "", "false", 0 },
- { "SDLCheck", "sdl", "", "true", 0 },
- { "IntrinsicFunctions", "Oi", "", "true", 0 },
- { "OmitFramePointers", "Oy-", "", "false", 0 },
- { "OmitFramePointers", "Oy", "", "true", 0 },
- { "EnableFiberSafeOptimizations", "GT", "", "true", 0 },
- { "WholeProgramOptimization", "GL", "", "true", 0 },
- { "UndefineAllPreprocessorDefinitions", "u", "", "true", 0 },
- { "IgnoreStandardIncludePath", "X", "", "true", 0 },
- { "PreprocessToFile", "P", "", "true", 0 },
- { "PreprocessSuppressLineNumbers", "EP", "", "true", 0 },
- { "PreprocessKeepComments", "C", "", "true", 0 },
- { "StringPooling", "GF-", "", "false", 0 },
- { "StringPooling", "GF", "", "true", 0 },
- { "MinimalRebuild", "Gm-", "", "false", 0 },
- { "MinimalRebuild", "Gm", "", "true", 0 },
- { "SmallerTypeCheck", "RTCc", "", "true", 0 },
- { "FunctionLevelLinking", "Gy-", "", "false", 0 },
- { "FunctionLevelLinking", "Gy", "", "true", 0 },
- { "EnableParallelCodeGeneration", "Qpar-", "", "false", 0 },
- { "EnableParallelCodeGeneration", "Qpar", "", "true", 0 },
- { "FloatingPointExceptions", "fp:except-", "", "false", 0 },
- { "FloatingPointExceptions", "fp:except", "", "true", 0 },
- { "CreateHotpatchableImage", "hotpatch", "", "true", 0 },
- { "DisableLanguageExtensions", "Za", "", "true", 0 },
- { "TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0 },
- { "TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0 },
- { "ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0 },
- { "ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0 },
- { "RuntimeTypeInfo", "GR-", "", "false", 0 },
- { "RuntimeTypeInfo", "GR", "", "true", 0 },
- { "OpenMPSupport", "openmp-", "", "false", 0 },
- { "OpenMPSupport", "openmp", "", "true", 0 },
- { "ExpandAttributedSource", "Fx", "", "true", 0 },
- { "UseUnicodeForAssemblerListing", "FAu", "", "true", 0 },
- { "ShowIncludes", "showIncludes", "", "true", 0 },
- { "EnablePREfast", "analyze-", "", "false", 0 },
- { "EnablePREfast", "analyze", "", "true", 0 },
- { "UseFullPaths", "FC", "", "true", 0 },
- { "OmitDefaultLibName", "Zl", "", "true", 0 },
-
- // Bool Properties With Argument
- { "MultiProcessorCompilation", "MP", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "ProcessorNumber", "MP", "Multi-processor Compilation", "",
- cmVS7FlagTable::UserValueRequired },
- { "GenerateXMLDocumentationFiles", "doc", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "",
- cmVS7FlagTable::UserValueRequired },
- { "BrowseInformation", "FR", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "BrowseInformationFile", "FR", "Enable Browse Information", "",
- cmVS7FlagTable::UserValueRequired },
-
- // String List Properties
- { "AdditionalIncludeDirectories", "I", "Additional Include Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AdditionalUsingDirectories", "AI", "Additional #using Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "PreprocessorDefinitions", "D ", "Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "UndefinePreprocessorDefinitions", "U",
- "Undefine Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "DisableSpecificWarnings", "wd", "Disable Specific Warnings", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForcedIncludeFiles", "FI", "Forced Include File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForcedUsingFiles", "FU", "Forced #using File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "PREfastLog", "analyze:log", "Code Analysis Log", "",
- cmVS7FlagTable::UserFollowing },
- { "PREfastAdditionalPlugins", "analyze:plugin",
- "Additional Code Analysis Native plugins", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "TreatSpecificWarningsAsErrors", "we", "Treat Specific Warnings As Errors",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- // Skip [TrackerLogDirectory] - no command line Switch.
- { "PreprocessOutputPath", "Fi", "Preprocess Output Path", "",
- cmVS7FlagTable::UserValue },
- { "PrecompiledHeaderFile", "Yc", "Precompiled Header Name", "",
- cmVS7FlagTable::UserValueRequired },
- { "PrecompiledHeaderFile", "Yu", "Precompiled Header Name", "",
- cmVS7FlagTable::UserValueRequired },
- { "PrecompiledHeaderOutputFile", "Fp", "Precompiled Header Output File", "",
- cmVS7FlagTable::UserValue },
- { "AssemblerListingLocation", "Fa", "ASM List Location", "",
- cmVS7FlagTable::UserValue },
- { "ObjectFileName", "Fo", "Object File Name", "",
- cmVS7FlagTable::UserValue },
- { "ProgramDataBaseFileName", "Fd", "Program Database File Name", "",
- cmVS7FlagTable::UserValue },
- // Skip [XMLDocumentationFileName] - no command line Switch.
- // Skip [BrowseInformationFile] - no command line Switch.
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS12CSharpFlagTable.h b/Source/cmVS12CSharpFlagTable.h
deleted file mode 100644
index f98b1840d..000000000
--- a/Source/cmVS12CSharpFlagTable.h
+++ /dev/null
@@ -1,120 +0,0 @@
-static cmVS7FlagTable cmVS12CSharpFlagTable[] = {
- { "ProjectName", "out:", "", "", cmIDEFlagTable::UserValueRequired },
-
- { "OutputType", "target:exe", "", "Exe", 0 },
- { "OutputType", "target:winexe", "", "Winexe", 0 },
- { "OutputType", "target:library", "", "Library", 0 },
- { "OutputType", "target:module", "", "Module", 0 },
-
- { "DocumentationFile", "doc", "", "", cmIDEFlagTable::UserValueRequired },
-
- { "Platform", "platform:x86", "", "x86", 0 },
- { "Platform", "platform:Itanium", "", "Itanium", 0 },
- { "Platform", "platform:x64", "", "x64", 0 },
- { "Platform", "platform:arm", "", "arm", 0 },
- { "Platform", "platform:anycpu32bitpreferred", "", "anycpu32bitpreferred",
- 0 },
- { "Platform", "platform:anycpu", "", "anycpu", 0 },
-
- { "References", "reference:", "mit alias", "", 0 },
- { "References", "reference:", "dateiliste", "", 0 },
- { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable },
- { "", "link", "", "", 0 },
-
- { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired },
- { "ApplicationIcon", "win32icon", "", "",
- cmIDEFlagTable::UserValueRequired },
-
- { "Win32Manifest", "win32manifest:", "", "true", 0 },
-
- { "NoWin32Manifest", "nowin32manifest", "", "true", 0 },
-
- { "DefineDebug", "debug", "", "true", cmIDEFlagTable::Continue },
-
- { "DebugSymbols", "debug", "", "true", 0 },
- { "DebugSymbols", "debug-", "", "false", 0 },
- { "DebugSymbols", "debug+", "", "true", 0 },
-
- { "DebugType", "debug:none", "", "none", 0 },
- { "DebugType", "debug:full", "", "full", 0 },
- { "DebugType", "debug:pdbonly", "", "pdbonly", 0 },
-
- { "Optimize", "optimize", "", "true", 0 },
- { "Optimize", "optimize-", "", "false", 0 },
- { "Optimize", "optimize+", "", "true", 0 },
-
- { "TreatWarningsAsErrors", "warnaserror", "", "true", 0 },
- { "TreatWarningsAsErrors", "warnaserror-", "", "false", 0 },
- { "TreatWarningsAsErrors", "warnaserror+", "", "true", 0 },
-
- { "WarningsAsErrors", "warnaserror", "", "", 0 },
- { "WarningsAsErrors", "warnaserror-", "", "", 0 },
- { "WarningsAsErrors", "warnaserror+", "", "", 0 },
-
- { "WarningLevel", "warn:0", "", "0", 0 },
- { "WarningLevel", "warn:1", "", "1", 0 },
- { "WarningLevel", "warn:2", "", "2", 0 },
- { "WarningLevel", "warn:3", "", "3", 0 },
- { "WarningLevel", "warn:4", "", "4", 0 },
- { "DisabledWarnings", "nowarn", "", "", 0 },
-
- { "CheckForOverflowUnderflow", "checked", "", "true", 0 },
- { "CheckForOverflowUnderflow", "checked-", "", "false", 0 },
- { "CheckForOverflowUnderflow", "checked+", "", "true", 0 },
-
- { "AllowUnsafeBlocks", "unsafe", "", "true", 0 },
- { "AllowUnsafeBlocks", "unsafe-", "", "false", 0 },
- { "AllowUnsafeBlocks", "unsafe+", "", "true", 0 },
-
- { "DefineConstants", "define:", "", "",
- cmIDEFlagTable::SemicolonAppendable | cmIDEFlagTable::UserValue },
-
- { "LangVersion", "langversion:ISO-1", "", "ISO-1", 0 },
- { "LangVersion", "langversion:ISO-2", "", "ISO-2", 0 },
- { "LangVersion", "langversion:3", "", "3", 0 },
- { "LangVersion", "langversion:4", "", "4", 0 },
- { "LangVersion", "langversion:5", "", "5", 0 },
- { "LangVersion", "langversion:6", "", "6", 0 },
- { "LangVersion", "langversion:default", "", "default", 0 },
-
- { "DelaySign", "delaysign", "", "true", 0 },
- { "DelaySign", "delaysign-", "", "false", 0 },
- { "DelaySign", "delaysign+", "", "true", 0 },
-
- { "AssemblyOriginatorKeyFile", "keyfile", "", "", 0 },
-
- { "KeyContainerName", "keycontainer", "", "", 0 },
-
- { "NoLogo", "nologo", "", "", 0 },
-
- { "NoConfig", "noconfig", "", "true", 0 },
-
- { "BaseAddress", "baseaddress:", "", "", 0 },
-
- { "CodePage", "codepage", "", "", 0 },
-
- { "Utf8Output", "utf8output", "", "", 0 },
-
- { "MainEntryPoint", "main:", "", "", 0 },
-
- { "GenerateFullPaths", "fullpaths", "", "true", 0 },
-
- { "FileAlignment", "filealign", "", "", 0 },
-
- { "PdbFile", "pdb:", "", "", 0 },
-
- { "NoStandardLib", "nostdlib", "", "true", 0 },
- { "NoStandardLib", "nostdlib-", "", "false", 0 },
- { "NoStandardLib", "nostdlib+", "", "true", 0 },
-
- { "SubsystemVersion", "subsystemversion", "", "", 0 },
-
- { "AdditionalLibPaths", "lib:", "", "", 0 },
-
- { "ErrorReport", "errorreport:none", "Do Not Send Report", "none", 0 },
- { "ErrorReport", "errorreport:prompt", "Prompt Immediately", "prompt", 0 },
- { "ErrorReport", "errorreport:queue", "Queue For Next Login", "queue", 0 },
- { "ErrorReport", "errorreport:send", "Send Automatically", "send", 0 },
-
- { 0, 0, 0, 0, 0 },
-};
diff --git a/Source/cmVS12LibFlagTable.h b/Source/cmVS12LibFlagTable.h
deleted file mode 100644
index 0f7a25955..000000000
--- a/Source/cmVS12LibFlagTable.h
+++ /dev/null
@@ -1,76 +0,0 @@
-static cmVS7FlagTable cmVS12LibFlagTable[] = {
-
- // Enum Properties
- { "ErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
- "PromptImmediately", 0 },
- { "ErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
- "QueueForNextLogin", 0 },
- { "ErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
- "SendErrorReport", 0 },
- { "ErrorReporting", "ERRORREPORT:NONE", "No Error Report", "NoErrorReport",
- 0 },
-
- { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
- { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
- { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
- { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
- { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
- { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
- 0 },
- { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
- "MachineMIPSFPU16", 0 },
- { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
- { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
- { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
- { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
-
- { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
- { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
- "EFI Application", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
- "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
- 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWSCE", "WindowsCE", "WindowsCE", 0 },
- { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
-
- // Bool Properties
- { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
- { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
- { "TreatLibWarningAsErrors", "WX:NO", "", "false", 0 },
- { "TreatLibWarningAsErrors", "WX", "", "true", 0 },
- { "Verbose", "VERBOSE", "", "true", 0 },
- { "LinkTimeCodeGeneration", "LTCG", "", "true", 0 },
-
- // Bool Properties With Argument
-
- // String List Properties
- // Skip [AdditionalDependencies] - no command line Switch.
- { "AdditionalLibraryDirectories", "LIBPATH:",
- "Additional Library Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
- "Ignore Specific Default Libraries", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ExportNamedFunctions", "EXPORT:", "Export Named Functions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "RemoveObjects", "REMOVE:", "Remove Objects", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
- { "ModuleDefinitionFile", "DEF:", "Module Definition File Name", "",
- cmVS7FlagTable::UserValue },
- { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
- cmVS7FlagTable::UserValue },
- { "DisplayLibrary", "LIST:", "Display Library to standard output", "",
- cmVS7FlagTable::UserValue },
- // Skip [MinimumRequiredVersion] - no command line Switch.
- { "Name", "NAME:", "Name", "", cmVS7FlagTable::UserValue },
- // Skip [AdditionalOptions] - no command line Switch.
- // Skip [TrackerLogDirectory] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS12LinkFlagTable.h b/Source/cmVS12LinkFlagTable.h
deleted file mode 100644
index 168c34c22..000000000
--- a/Source/cmVS12LinkFlagTable.h
+++ /dev/null
@@ -1,269 +0,0 @@
-static cmVS7FlagTable cmVS12LinkFlagTable[] = {
-
- // Enum Properties
- { "ShowProgress", "", "Not Set", "NotSet", 0 },
- { "ShowProgress", "VERBOSE", "Display all progress messages", "LinkVerbose",
- 0 },
- { "ShowProgress", "VERBOSE:Lib", "For Libraries Searched", "LinkVerboseLib",
- 0 },
- { "ShowProgress", "VERBOSE:ICF",
- "About COMDAT folding during optimized linking", "LinkVerboseICF", 0 },
- { "ShowProgress", "VERBOSE:REF",
- "About data removed during optimized linking", "LinkVerboseREF", 0 },
- { "ShowProgress", "VERBOSE:SAFESEH", "About Modules incompatible with SEH",
- "LinkVerboseSAFESEH", 0 },
- { "ShowProgress", "VERBOSE:CLR",
- "About linker activity related to managed code", "LinkVerboseCLR", 0 },
-
- { "ForceFileOutput", "FORCE", "Enabled", "Enabled", 0 },
- { "ForceFileOutput", "FORCE:MULTIPLE", "Multiply Defined Symbol Only",
- "MultiplyDefinedSymbolOnly", 0 },
- { "ForceFileOutput", "FORCE:UNRESOLVED", "Undefined Symbol Only",
- "UndefinedSymbolOnly", 0 },
-
- { "CreateHotPatchableImage", "FUNCTIONPADMIN", "Enabled", "Enabled", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:5", "X86 Image Only",
- "X86Image", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:6", "X64 Image Only",
- "X64Image", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only",
- "ItaniumImage", 0 },
-
- { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 },
- { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable",
- "HighestAvailable", 0 },
- { "UACExecutionLevel", "level='requireAdministrator'",
- "requireAdministrator", "RequireAdministrator", 0 },
-
- { "SubSystem", "", "Not Set", "NotSet", 0 },
- { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
- { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
- "EFI Application", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
- "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
- 0 },
- { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
-
- { "Driver", "", "Not Set", "NotSet", 0 },
- { "Driver", "Driver", "Driver", "Driver", 0 },
- { "Driver", "DRIVER:UPONLY", "UP Only", "UpOnly", 0 },
- { "Driver", "DRIVER:WDM", "WDM", "WDM", 0 },
-
- { "LinkTimeCodeGeneration", "", "Default", "Default", 0 },
- { "LinkTimeCodeGeneration", "LTCG", "Use Link Time Code Generation",
- "UseLinkTimeCodeGeneration", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGInstrument",
- "Profile Guided Optimization - Instrument", "PGInstrument", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGOptimize",
- "Profile Guided Optimization - Optimization", "PGOptimization", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGUpdate",
- "Profile Guided Optimization - Update", "PGUpdate", 0 },
-
- { "GenerateWindowsMetadata", "WINMD", "Yes", "true", 0 },
- { "GenerateWindowsMetadata", "WINMD:NO", "No", "false", 0 },
-
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
-
- { "TargetMachine", "", "Not Set", "NotSet", 0 },
- { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
- { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
- { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
- { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
- { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
- { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
- 0 },
- { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
- "MachineMIPSFPU16", 0 },
- { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
- { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
- { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
- { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
-
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA", "MTA threading attribute",
- "MTAThreadingAttribute", 0 },
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA", "STA threading attribute",
- "STAThreadingAttribute", 0 },
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE",
- "Default threading attribute", "DefaultThreadingAttribute", 0 },
-
- { "CLRImageType", "CLRIMAGETYPE:IJW", "Force IJW image", "ForceIJWImage",
- 0 },
- { "CLRImageType", "CLRIMAGETYPE:PURE", "Force Pure IL Image",
- "ForcePureILImage", 0 },
- { "CLRImageType", "CLRIMAGETYPE:SAFE", "Force Safe IL Image",
- "ForceSafeILImage", 0 },
- { "CLRImageType", "", "Default image type", "Default", 0 },
-
- { "SignHash", "CLRSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
- { "SignHash", "CLRSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
- { "SignHash", "CLRSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
- { "SignHash", "CLRSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
-
- { "LinkErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
- "PromptImmediately", 0 },
- { "LinkErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
- "QueueForNextLogin", 0 },
- { "LinkErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
- "SendErrorReport", 0 },
- { "LinkErrorReporting", "ERRORREPORT:NONE", "No Error Report",
- "NoErrorReport", 0 },
-
- { "CLRSupportLastError", "CLRSupportLastError", "Enabled", "Enabled", 0 },
- { "CLRSupportLastError", "CLRSupportLastError:NO", "Disabled", "Disabled",
- 0 },
- { "CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL", "System Dlls Only",
- "SystemDlls", 0 },
-
- // Bool Properties
- { "LinkIncremental", "INCREMENTAL:NO", "", "false", 0 },
- { "LinkIncremental", "INCREMENTAL", "", "true", 0 },
- { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
- { "LinkStatus", "LTCG:NOSTATUS", "", "false", 0 },
- { "LinkStatus", "LTCG:STATUS", "", "true", 0 },
- { "PreventDllBinding", "ALLOWBIND:NO", "", "false", 0 },
- { "PreventDllBinding", "ALLOWBIND", "", "true", 0 },
- { "TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0 },
- { "TreatLinkerWarningAsErrors", "WX", "", "true", 0 },
- { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
- { "GenerateManifest", "MANIFEST:NO", "", "false", 0 },
- { "GenerateManifest", "MANIFEST", "", "true", 0 },
- { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 },
- { "UACUIAccess", "uiAccess='false'", "", "false", 0 },
- { "UACUIAccess", "uiAccess='true'", "", "true", 0 },
- { "ManifestEmbed", "manifest:embed", "", "true", 0 },
- { "GenerateDebugInformation", "DEBUG", "", "true",
- cmVS7FlagTable::CaseInsensitive },
- { "MapExports", "MAPINFO:EXPORTS", "", "true", 0 },
- { "AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0 },
- { "AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0 },
- { "LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0 },
- { "LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0 },
- { "TerminalServerAware", "TSAWARE:NO", "", "false", 0 },
- { "TerminalServerAware", "TSAWARE", "", "true", 0 },
- { "SwapRunFromCD", "SWAPRUN:CD", "", "true", 0 },
- { "SwapRunFromNET", "SWAPRUN:NET", "", "true", 0 },
- { "OptimizeReferences", "OPT:NOREF", "", "false", 0 },
- { "OptimizeReferences", "OPT:REF", "", "true", 0 },
- { "EnableCOMDATFolding", "OPT:NOICF", "", "false", 0 },
- { "EnableCOMDATFolding", "OPT:ICF", "", "true", 0 },
- { "IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0 },
- { "AppContainer", "APPCONTAINER", "", "true", 0 },
- { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN:NO", "", "false", 0 },
- { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN", "", "true", 0 },
- { "NoEntryPoint", "NOENTRY", "", "true", 0 },
- { "SetChecksum", "RELEASE", "", "true", 0 },
- { "RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0 },
- { "RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0 },
- { "FixedBaseAddress", "FIXED:NO", "", "false", 0 },
- { "FixedBaseAddress", "FIXED", "", "true", 0 },
- { "DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0 },
- { "DataExecutionPrevention", "NXCOMPAT", "", "true", 0 },
- { "TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0 },
- { "SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0 },
- { "SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0 },
- { "Profile", "PROFILE", "", "true", 0 },
- { "LinkDelaySign", "DELAYSIGN:NO", "", "false", 0 },
- { "LinkDelaySign", "DELAYSIGN", "", "true", 0 },
- { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0 },
- { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0 },
- { "DetectOneDefinitionRule", "ODR", "", "true", 0 },
- { "ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0 },
- { "ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0 },
- { "LinkDLL", "DLL", "", "true", 0 },
-
- // Bool Properties With Argument
- { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 },
- { "EnableUAC", "MANIFESTUAC:", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
- cmVS7FlagTable::UserValueRequired },
- { "GenerateMapFile", "MAP", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "MapFileName", "MAP:", "Generate Map File", "",
- cmVS7FlagTable::UserValueRequired },
-
- // String List Properties
- { "AdditionalLibraryDirectories", "LIBPATH:",
- "Additional Library Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- // Skip [AdditionalDependencies] - no command line Switch.
- { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
- "Ignore Specific Default Libraries", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AddModuleNamesToAssembly", "ASSEMBLYMODULE:", "Add Module to Assembly",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "EmbedManagedResourceFile", "ASSEMBLYRESOURCE:",
- "Embed Managed Resource File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "DelayLoadDLLs", "DELAYLOAD:", "Delay Loaded Dlls", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:", "Assembly Link Resource",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AdditionalManifestDependencies", "MANIFESTDEPENDENCY:",
- "Additional Manifest Dependencies", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ManifestInput", "manifestinput:", "Manifest Input", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
- { "Version", "VERSION:", "Version", "", cmVS7FlagTable::UserValue },
- { "SpecifySectionAttributes", "SECTION:", "Specify Section Attributes", "",
- cmVS7FlagTable::UserValue },
- { "MSDOSStubFileName", "STUB:", "MS-DOS Stub File Name", "",
- cmVS7FlagTable::UserValue },
- // Skip [TrackerLogDirectory] - no command line Switch.
- { "ModuleDefinitionFile", "DEF:", "Module Definition File", "",
- cmVS7FlagTable::UserValue },
- { "ManifestFile", "ManifestFile:", "Manifest File", "",
- cmVS7FlagTable::UserValue },
- { "ProgramDatabaseFile", "PDB:", "Generate Program Database File", "",
- cmVS7FlagTable::UserValue },
- { "StripPrivateSymbols", "PDBSTRIPPED:", "Strip Private Symbols", "",
- cmVS7FlagTable::UserValue },
- // Skip [MapFileName] - no command line Switch.
- // Skip [MinimumRequiredVersion] - no command line Switch.
- { "HeapReserveSize", "HEAP:", "Heap Reserve Size", "",
- cmVS7FlagTable::UserValue },
- // Skip [HeapCommitSize] - no command line Switch.
- { "StackReserveSize", "STACK:", "Stack Reserve Size", "",
- cmVS7FlagTable::UserValue },
- // Skip [StackCommitSize] - no command line Switch.
- { "FunctionOrder", "ORDER:@", "Function Order", "",
- cmVS7FlagTable::UserValue },
- { "ProfileGuidedDatabase", "PGD:", "Profile Guided Database", "",
- cmVS7FlagTable::UserValue },
- { "MidlCommandFile", "MIDL:@", "MIDL Commands", "",
- cmVS7FlagTable::UserValue },
- { "MergedIDLBaseFileName", "IDLOUT:", "Merged IDL Base File Name", "",
- cmVS7FlagTable::UserValue },
- { "TypeLibraryFile", "TLBOUT:", "Type Library", "",
- cmVS7FlagTable::UserValue },
- { "WindowsMetadataFile", "WINMDFILE:", "Windows Metadata File", "",
- cmVS7FlagTable::UserValue },
- { "WindowsMetadataLinkKeyFile", "WINMDKEYFILE:", "Windows Metadata Key File",
- "", cmVS7FlagTable::UserValue },
- { "WindowsMetadataKeyContainer", "WINMDKEYCONTAINER:",
- "Windows Metadata Key Container", "", cmVS7FlagTable::UserValue },
- { "EntryPointSymbol", "ENTRY:", "Entry Point", "",
- cmVS7FlagTable::UserValue },
- { "BaseAddress", "BASE:", "Base Address", "", cmVS7FlagTable::UserValue },
- { "ImportLibrary", "IMPLIB:", "Import Library", "",
- cmVS7FlagTable::UserValue },
- { "MergeSections", "MERGE:", "Merge Sections", "",
- cmVS7FlagTable::UserValue },
- { "LinkKeyFile", "KEYFILE:", "Key File", "", cmVS7FlagTable::UserValue },
- { "KeyContainer", "KEYCONTAINER:", "Key Container", "",
- cmVS7FlagTable::UserValue },
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS12MASMFlagTable.h b/Source/cmVS12MASMFlagTable.h
deleted file mode 100644
index acc0d48e1..000000000
--- a/Source/cmVS12MASMFlagTable.h
+++ /dev/null
@@ -1,76 +0,0 @@
-static cmVS7FlagTable cmVS12MASMFlagTable[] = {
-
- // Enum Properties
- { "PreserveIdentifierCase", "", "Default", "0", 0 },
- { "PreserveIdentifierCase", "Cp", "Preserves Identifier Case (/Cp)", "1",
- 0 },
- { "PreserveIdentifierCase", "Cu",
- "Maps all identifiers to upper case. (/Cu)", "2", 0 },
- { "PreserveIdentifierCase", "Cx",
- "Preserves case in public and extern symbols. (/Cx)", "3", 0 },
-
- { "WarningLevel", "W0", "Warning Level 0 (/W0)", "0", 0 },
- { "WarningLevel", "W1", "Warning Level 1 (/W1)", "1", 0 },
- { "WarningLevel", "W2", "Warning Level 2 (/W2)", "2", 0 },
- { "WarningLevel", "W3", "Warning Level 3 (/W3)", "3", 0 },
-
- { "PackAlignmentBoundary", "", "Default", "0", 0 },
- { "PackAlignmentBoundary", "Zp1", "One Byte Boundary (/Zp1)", "1", 0 },
- { "PackAlignmentBoundary", "Zp2", "Two Byte Boundary (/Zp2)", "2", 0 },
- { "PackAlignmentBoundary", "Zp4", "Four Byte Boundary (/Zp4)", "3", 0 },
- { "PackAlignmentBoundary", "Zp8", "Eight Byte Boundary (/Zp8)", "4", 0 },
- { "PackAlignmentBoundary", "Zp16", "Sixteen Byte Boundary (/Zp16)", "5", 0 },
-
- { "CallingConvention", "", "Default", "0", 0 },
- { "CallingConvention", "Gd", "Use C-style Calling Convention (/Gd)", "1",
- 0 },
- { "CallingConvention", "Gz", "Use stdcall Calling Convention (/Gz)", "2",
- 0 },
- { "CallingConvention", "Gc", "Use Pascal Calling Convention (/Gc)", "3", 0 },
-
- { "ErrorReporting", "errorReport:prompt",
- "Prompt to send report immediately (/errorReport:prompt)", "0", 0 },
- { "ErrorReporting", "errorReport:queue",
- "Prompt to send report at the next logon (/errorReport:queue)", "1", 0 },
- { "ErrorReporting", "errorReport:send",
- "Automatically send report (/errorReport:send)", "2", 0 },
- { "ErrorReporting", "errorReport:none",
- "Do not send report (/errorReport:none)", "3", 0 },
-
- // Bool Properties
- { "NoLogo", "nologo", "", "true", 0 },
- { "GeneratePreprocessedSourceListing", "EP", "", "true", 0 },
- { "ListAllAvailableInformation", "Sa", "", "true", 0 },
- { "UseSafeExceptionHandlers", "safeseh", "", "true", 0 },
- { "AddFirstPassListing", "Sf", "", "true", 0 },
- { "EnableAssemblyGeneratedCodeListing", "Sg", "", "true", 0 },
- { "DisableSymbolTable", "Sn", "", "true", 0 },
- { "EnableFalseConditionalsInListing", "Sx", "", "true", 0 },
- { "TreatWarningsAsErrors", "WX", "", "true", 0 },
- { "MakeAllSymbolsPublic", "Zf", "", "true", 0 },
- { "GenerateDebugInformation", "Zi", "", "true", 0 },
- { "EnableMASM51Compatibility", "Zm", "", "true", 0 },
- { "PerformSyntaxCheckOnly", "Zs", "", "true", 0 },
-
- // Bool Properties With Argument
-
- // String List Properties
- { "PreprocessorDefinitions", "D", "Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "IncludePaths", "I", "Include Paths", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "BrowseFile", "FR", "Generate Browse Information File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- // Skip [AdditionalDependencies] - no command line Switch.
-
- // String Properties
- // Skip [Inputs] - no command line Switch.
- { "ObjectFileName", "Fo", "Object File Name", "",
- cmVS7FlagTable::UserValue },
- { "AssembledCodeListingFile", "Fl", "Assembled Code Listing File", "",
- cmVS7FlagTable::UserValue },
- // Skip [CommandLineTemplate] - no command line Switch.
- // Skip [ExecutionDescription] - no command line Switch.
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS12RCFlagTable.h b/Source/cmVS12RCFlagTable.h
deleted file mode 100644
index a650f8522..000000000
--- a/Source/cmVS12RCFlagTable.h
+++ /dev/null
@@ -1,7 +0,0 @@
-static cmVS7FlagTable cmVS12RCFlagTable[] = {
- // Bool Properties
- { "NullTerminateStrings", "n", "", "true", 0 },
- { "SuppressStartupBanner", "nologo", "", "true", 0 },
-
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS140CLFlagTable.h b/Source/cmVS140CLFlagTable.h
deleted file mode 100644
index 60b437974..000000000
--- a/Source/cmVS140CLFlagTable.h
+++ /dev/null
@@ -1,239 +0,0 @@
-static cmVS7FlagTable cmVS140CLFlagTable[] = {
-
- // Enum Properties
- { "DebugInformationFormat", "", "None", "None", 0 },
- { "DebugInformationFormat", "Z7", "C7 compatible", "OldStyle", 0 },
- { "DebugInformationFormat", "Zi", "Program Database", "ProgramDatabase", 0 },
- { "DebugInformationFormat", "ZI", "Program Database for Edit And Continue",
- "EditAndContinue", 0 },
-
- { "WarningLevel", "W0", "Turn Off All Warnings", "TurnOffAllWarnings", 0 },
- { "WarningLevel", "W1", "Level1", "Level1", 0 },
- { "WarningLevel", "W2", "Level2", "Level2", 0 },
- { "WarningLevel", "W3", "Level3", "Level3", 0 },
- { "WarningLevel", "W4", "Level4", "Level4", 0 },
- { "WarningLevel", "Wall", "EnableAllWarnings", "EnableAllWarnings", 0 },
-
- { "Optimization", "", "Custom", "Custom", 0 },
- { "Optimization", "Od", "Disabled", "Disabled", 0 },
- { "Optimization", "O1", "Minimize Size", "MinSpace", 0 },
- { "Optimization", "O2", "Maximize Speed", "MaxSpeed", 0 },
- { "Optimization", "Ox", "Full Optimization", "Full", 0 },
-
- { "InlineFunctionExpansion", "", "Default", "Default", 0 },
- { "InlineFunctionExpansion", "Ob0", "Disabled", "Disabled", 0 },
- { "InlineFunctionExpansion", "Ob1", "Only __inline", "OnlyExplicitInline",
- 0 },
- { "InlineFunctionExpansion", "Ob2", "Any Suitable", "AnySuitable", 0 },
-
- { "FavorSizeOrSpeed", "Os", "Favor small code", "Size", 0 },
- { "FavorSizeOrSpeed", "Ot", "Favor fast code", "Speed", 0 },
- { "FavorSizeOrSpeed", "", "Neither", "Neither", 0 },
-
- { "ExceptionHandling", "EHa", "Yes with SEH Exceptions", "Async", 0 },
- { "ExceptionHandling", "EHsc", "Yes", "Sync", 0 },
- { "ExceptionHandling", "EHs", "Yes with Extern C functions", "SyncCThrow",
- 0 },
- { "ExceptionHandling", "", "No", "false", 0 },
-
- { "BasicRuntimeChecks", "RTCs", "Stack Frames", "StackFrameRuntimeCheck",
- 0 },
- { "BasicRuntimeChecks", "RTCu", "Uninitialized variables",
- "UninitializedLocalUsageCheck", 0 },
- { "BasicRuntimeChecks", "RTC1", "Both (/RTC1, equiv. to /RTCsu)",
- "EnableFastChecks", 0 },
- { "BasicRuntimeChecks", "", "Default", "Default", 0 },
-
- { "RuntimeLibrary", "MT", "Multi-threaded", "MultiThreaded", 0 },
- { "RuntimeLibrary", "MTd", "Multi-threaded Debug", "MultiThreadedDebug", 0 },
- { "RuntimeLibrary", "MD", "Multi-threaded DLL", "MultiThreadedDLL", 0 },
- { "RuntimeLibrary", "MDd", "Multi-threaded Debug DLL",
- "MultiThreadedDebugDLL", 0 },
-
- { "StructMemberAlignment", "Zp1", "1 Byte", "1Byte", 0 },
- { "StructMemberAlignment", "Zp2", "2 Bytes", "2Bytes", 0 },
- { "StructMemberAlignment", "Zp4", "4 Byte", "4Bytes", 0 },
- { "StructMemberAlignment", "Zp8", "8 Bytes", "8Bytes", 0 },
- { "StructMemberAlignment", "Zp16", "16 Bytes", "16Bytes", 0 },
- { "StructMemberAlignment", "", "Default", "Default", 0 },
-
- { "BufferSecurityCheck", "GS-", "Disable Security Check", "false", 0 },
- { "BufferSecurityCheck", "GS", "Enable Security Check", "true", 0 },
-
- { "EnableEnhancedInstructionSet", "arch:SSE", "Streaming SIMD Extensions",
- "StreamingSIMDExtensions", 0 },
- { "EnableEnhancedInstructionSet", "arch:SSE2", "Streaming SIMD Extensions 2",
- "StreamingSIMDExtensions2", 0 },
- { "EnableEnhancedInstructionSet", "arch:AVX", "Advanced Vector Extensions",
- "AdvancedVectorExtensions", 0 },
- { "EnableEnhancedInstructionSet", "arch:AVX2",
- "Advanced Vector Extensions 2", "AdvancedVectorExtensions2", 0 },
- { "EnableEnhancedInstructionSet", "arch:IA32", "No Enhanced Instructions",
- "NoExtensions", 0 },
- { "EnableEnhancedInstructionSet", "", "Not Set", "NotSet", 0 },
-
- { "FloatingPointModel", "fp:precise", "Precise", "Precise", 0 },
- { "FloatingPointModel", "fp:strict", "Strict", "Strict", 0 },
- { "FloatingPointModel", "fp:fast", "Fast", "Fast", 0 },
-
- { "PrecompiledHeader", "Yc", "Create", "Create",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "PrecompiledHeader", "Yu", "Use", "Use",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 },
-
- { "AssemblerOutput", "", "No Listing", "NoListing", 0 },
- { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 },
- { "AssemblerOutput", "FAc", "Assembly With Machine Code",
- "AssemblyAndMachineCode", 0 },
- { "AssemblerOutput", "FAs", "Assembly With Source Code",
- "AssemblyAndSourceCode", 0 },
- { "AssemblerOutput", "FAcs", "Assembly, Machine Code and Source", "All", 0 },
-
- { "CallingConvention", "Gd", "__cdecl", "Cdecl", 0 },
- { "CallingConvention", "Gr", "__fastcall", "FastCall", 0 },
- { "CallingConvention", "Gz", "__stdcall", "StdCall", 0 },
- { "CallingConvention", "Gv", "__vectorcall", "VectorCall", 0 },
-
- { "CompileAs", "", "Default", "Default", 0 },
- { "CompileAs", "TC", "Compile as C Code", "CompileAsC", 0 },
- { "CompileAs", "TP", "Compile as C++ Code", "CompileAsCpp", 0 },
-
- { "ErrorReporting", "errorReport:none", "Do Not Send Report", "None", 0 },
- { "ErrorReporting", "errorReport:prompt", "Prompt Immediately", "Prompt",
- 0 },
- { "ErrorReporting", "errorReport:queue", "Queue For Next Login", "Queue",
- 0 },
- { "ErrorReporting", "errorReport:send", "Send Automatically", "Send", 0 },
-
- { "CompileAsManaged", "", "No Common Language RunTime Support", "false", 0 },
- { "CompileAsManaged", "clr", "Common Language RunTime Support", "true", 0 },
- { "CompileAsManaged", "clr:pure",
- "Pure MSIL Common Language RunTime Support", "Pure", 0 },
- { "CompileAsManaged", "clr:safe",
- "Safe MSIL Common Language RunTime Support", "Safe", 0 },
- { "CompileAsManaged", "clr:oldSyntax",
- "Common Language RunTime Support, Old Syntax", "OldSyntax", 0 },
-
- { "CppLanguageStandard", "", "Default", "Default", 0 },
- { "CppLanguageStandard", "std=c++98", "C++03", "c++98", 0 },
- { "CppLanguageStandard", "std=c++11", "C++11", "c++11", 0 },
- { "CppLanguageStandard", "std=c++1y", "C++14", "c++1y", 0 },
- { "CppLanguageStandard", "std=c++14", "C++14", "c++1y", 0 },
- { "CppLanguageStandard", "std=gnu++98", "C++03 (GNU Dialect)", "gnu++98",
- 0 },
- { "CppLanguageStandard", "std=gnu++11", "C++11 (GNU Dialect)", "gnu++11",
- 0 },
- { "CppLanguageStandard", "std=gnu++1y", "C++14 (GNU Dialect)", "gnu++1y",
- 0 },
- { "CppLanguageStandard", "std=gnu++14", "C++14 (GNU Dialect)", "gnu++1y",
- 0 },
-
- // Bool Properties
- { "CompileAsWinRT", "ZW", "", "true", 0 },
- { "WinRTNoStdLib", "ZW:nostdlib", "", "true", 0 },
- { "SuppressStartupBanner", "nologo", "", "true", 0 },
- { "TreatWarningAsError", "WX-", "", "false", 0 },
- { "TreatWarningAsError", "WX", "", "true", 0 },
- { "SDLCheck", "sdl-", "", "false", 0 },
- { "SDLCheck", "sdl", "", "true", 0 },
- { "IntrinsicFunctions", "Oi", "", "true", 0 },
- { "OmitFramePointers", "Oy-", "", "false", 0 },
- { "OmitFramePointers", "Oy", "", "true", 0 },
- { "EnableFiberSafeOptimizations", "GT", "", "true", 0 },
- { "WholeProgramOptimization", "GL", "", "true", 0 },
- { "UndefineAllPreprocessorDefinitions", "u", "", "true", 0 },
- { "IgnoreStandardIncludePath", "X", "", "true", 0 },
- { "PreprocessToFile", "P", "", "true", 0 },
- { "PreprocessSuppressLineNumbers", "EP", "", "true", 0 },
- { "PreprocessKeepComments", "C", "", "true", 0 },
- { "StringPooling", "GF-", "", "false", 0 },
- { "StringPooling", "GF", "", "true", 0 },
- { "MinimalRebuild", "Gm-", "", "false", 0 },
- { "MinimalRebuild", "Gm", "", "true", 0 },
- { "SmallerTypeCheck", "RTCc", "", "true", 0 },
- { "FunctionLevelLinking", "Gy-", "", "false", 0 },
- { "FunctionLevelLinking", "Gy", "", "true", 0 },
- { "EnableParallelCodeGeneration", "Qpar-", "", "false", 0 },
- { "EnableParallelCodeGeneration", "Qpar", "", "true", 0 },
- { "FloatingPointExceptions", "fp:except-", "", "false", 0 },
- { "FloatingPointExceptions", "fp:except", "", "true", 0 },
- { "CreateHotpatchableImage", "hotpatch", "", "true", 0 },
- { "DisableLanguageExtensions", "Za", "", "true", 0 },
- { "TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0 },
- { "TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0 },
- { "ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0 },
- { "ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0 },
- { "RemoveUnreferencedCodeData", "Zc:inline-", "", "false", 0 },
- { "RemoveUnreferencedCodeData", "Zc:inline", "", "true", 0 },
- { "RuntimeTypeInfo", "GR-", "", "false", 0 },
- { "RuntimeTypeInfo", "GR", "", "true", 0 },
- { "OpenMPSupport", "openmp-", "", "false", 0 },
- { "OpenMPSupport", "openmp", "", "true", 0 },
- { "ExpandAttributedSource", "Fx", "", "true", 0 },
- { "UseUnicodeForAssemblerListing", "FAu", "", "true", 0 },
- { "ShowIncludes", "showIncludes", "", "true", 0 },
- { "EnablePREfast", "analyze-", "", "false", 0 },
- { "EnablePREfast", "analyze", "", "true", 0 },
- { "UseFullPaths", "FC", "", "true", 0 },
- { "OmitDefaultLibName", "Zl", "", "true", 0 },
-
- // Bool Properties With Argument
- { "MultiProcessorCompilation", "MP", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "ProcessorNumber", "MP", "Multi-processor Compilation", "",
- cmVS7FlagTable::UserValueRequired },
- { "GenerateXMLDocumentationFiles", "doc", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "",
- cmVS7FlagTable::UserValueRequired },
- { "BrowseInformation", "FR", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "BrowseInformationFile", "FR", "Enable Browse Information", "",
- cmVS7FlagTable::UserValueRequired },
-
- // String List Properties
- { "AdditionalIncludeDirectories", "I", "Additional Include Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AdditionalUsingDirectories", "AI", "Additional #using Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "PreprocessorDefinitions", "D ", "Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "UndefinePreprocessorDefinitions", "U",
- "Undefine Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "DisableSpecificWarnings", "wd", "Disable Specific Warnings", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForcedIncludeFiles", "FI", "Forced Include File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForcedUsingFiles", "FU", "Forced #using File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "PREfastLog", "analyze:log", "Code Analysis Log", "",
- cmVS7FlagTable::UserFollowing },
- { "PREfastAdditionalPlugins", "analyze:plugin",
- "Additional Code Analysis Native plugins", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "TreatSpecificWarningsAsErrors", "we", "Treat Specific Warnings As Errors",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- // Skip [TrackerLogDirectory] - no command line Switch.
- { "PreprocessOutputPath", "Fi", "Preprocess Output Path", "",
- cmVS7FlagTable::UserValue },
- { "PrecompiledHeaderFile", "Yc", "Precompiled Header Name", "",
- cmVS7FlagTable::UserValueRequired },
- { "PrecompiledHeaderFile", "Yu", "Precompiled Header Name", "",
- cmVS7FlagTable::UserValueRequired },
- { "PrecompiledHeaderOutputFile", "Fp", "Precompiled Header Output File", "",
- cmVS7FlagTable::UserValue },
- { "AssemblerListingLocation", "Fa", "ASM List Location", "",
- cmVS7FlagTable::UserValue },
- { "ObjectFileName", "Fo", "Object File Name", "",
- cmVS7FlagTable::UserValue },
- { "ProgramDataBaseFileName", "Fd", "Program Database File Name", "",
- cmVS7FlagTable::UserValue },
- // Skip [XMLDocumentationFileName] - no command line Switch.
- // Skip [BrowseInformationFile] - no command line Switch.
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS140CSharpFlagTable.h b/Source/cmVS140CSharpFlagTable.h
deleted file mode 100644
index 256c35f70..000000000
--- a/Source/cmVS140CSharpFlagTable.h
+++ /dev/null
@@ -1,120 +0,0 @@
-static cmVS7FlagTable cmVS140CSharpFlagTable[] = {
- { "ProjectName", "out:", "", "", cmIDEFlagTable::UserValueRequired },
-
- { "OutputType", "target:exe", "", "Exe", 0 },
- { "OutputType", "target:winexe", "", "Winexe", 0 },
- { "OutputType", "target:library", "", "Library", 0 },
- { "OutputType", "target:module", "", "Module", 0 },
-
- { "DocumentationFile", "doc", "", "", cmIDEFlagTable::UserValueRequired },
-
- { "Platform", "platform:x86", "", "x86", 0 },
- { "Platform", "platform:Itanium", "", "Itanium", 0 },
- { "Platform", "platform:x64", "", "x64", 0 },
- { "Platform", "platform:arm", "", "arm", 0 },
- { "Platform", "platform:anycpu32bitpreferred", "", "anycpu32bitpreferred",
- 0 },
- { "Platform", "platform:anycpu", "", "anycpu", 0 },
-
- { "References", "reference:", "mit alias", "", 0 },
- { "References", "reference:", "dateiliste", "", 0 },
- { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable },
- { "", "link", "", "", 0 },
-
- { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired },
- { "ApplicationIcon", "win32icon", "", "",
- cmIDEFlagTable::UserValueRequired },
-
- { "Win32Manifest", "win32manifest:", "", "true", 0 },
-
- { "NoWin32Manifest", "nowin32manifest", "", "true", 0 },
-
- { "DefineDebug", "debug", "", "true", cmIDEFlagTable::Continue },
-
- { "DebugSymbols", "debug", "", "true", 0 },
- { "DebugSymbols", "debug-", "", "false", 0 },
- { "DebugSymbols", "debug+", "", "true", 0 },
-
- { "DebugType", "debug:none", "", "none", 0 },
- { "DebugType", "debug:full", "", "full", 0 },
- { "DebugType", "debug:pdbonly", "", "pdbonly", 0 },
-
- { "Optimize", "optimize", "", "true", 0 },
- { "Optimize", "optimize-", "", "false", 0 },
- { "Optimize", "optimize+", "", "true", 0 },
-
- { "TreatWarningsAsErrors", "warnaserror", "", "true", 0 },
- { "TreatWarningsAsErrors", "warnaserror-", "", "false", 0 },
- { "TreatWarningsAsErrors", "warnaserror+", "", "true", 0 },
-
- { "WarningsAsErrors", "warnaserror", "", "", 0 },
- { "WarningsAsErrors", "warnaserror-", "", "", 0 },
- { "WarningsAsErrors", "warnaserror+", "", "", 0 },
-
- { "WarningLevel", "warn:0", "", "0", 0 },
- { "WarningLevel", "warn:1", "", "1", 0 },
- { "WarningLevel", "warn:2", "", "2", 0 },
- { "WarningLevel", "warn:3", "", "3", 0 },
- { "WarningLevel", "warn:4", "", "4", 0 },
- { "DisabledWarnings", "nowarn", "", "", 0 },
-
- { "CheckForOverflowUnderflow", "checked", "", "true", 0 },
- { "CheckForOverflowUnderflow", "checked-", "", "false", 0 },
- { "CheckForOverflowUnderflow", "checked+", "", "true", 0 },
-
- { "AllowUnsafeBlocks", "unsafe", "", "true", 0 },
- { "AllowUnsafeBlocks", "unsafe-", "", "false", 0 },
- { "AllowUnsafeBlocks", "unsafe+", "", "true", 0 },
-
- { "DefineConstants", "define:", "", "",
- cmIDEFlagTable::SemicolonAppendable | cmIDEFlagTable::UserValue },
-
- { "LangVersion", "langversion:ISO-1", "", "ISO-1", 0 },
- { "LangVersion", "langversion:ISO-2", "", "ISO-2", 0 },
- { "LangVersion", "langversion:3", "", "3", 0 },
- { "LangVersion", "langversion:4", "", "4", 0 },
- { "LangVersion", "langversion:5", "", "5", 0 },
- { "LangVersion", "langversion:6", "", "6", 0 },
- { "LangVersion", "langversion:default", "", "default", 0 },
-
- { "DelaySign", "delaysign", "", "true", 0 },
- { "DelaySign", "delaysign-", "", "false", 0 },
- { "DelaySign", "delaysign+", "", "true", 0 },
-
- { "AssemblyOriginatorKeyFile", "keyfile", "", "", 0 },
-
- { "KeyContainerName", "keycontainer", "", "", 0 },
-
- { "NoLogo", "nologo", "", "", 0 },
-
- { "NoConfig", "noconfig", "", "true", 0 },
-
- { "BaseAddress", "baseaddress:", "", "", 0 },
-
- { "CodePage", "codepage", "", "", 0 },
-
- { "Utf8Output", "utf8output", "", "", 0 },
-
- { "MainEntryPoint", "main:", "", "", 0 },
-
- { "GenerateFullPaths", "fullpaths", "", "true", 0 },
-
- { "FileAlignment", "filealign", "", "", 0 },
-
- { "PdbFile", "pdb:", "", "", 0 },
-
- { "NoStandardLib", "nostdlib", "", "true", 0 },
- { "NoStandardLib", "nostdlib-", "", "false", 0 },
- { "NoStandardLib", "nostdlib+", "", "true", 0 },
-
- { "SubsystemVersion", "subsystemversion", "", "", 0 },
-
- { "AdditionalLibPaths", "lib:", "", "", 0 },
-
- { "ErrorReport", "errorreport:none", "Do Not Send Report", "none", 0 },
- { "ErrorReport", "errorreport:prompt", "Prompt Immediately", "prompt", 0 },
- { "ErrorReport", "errorreport:queue", "Queue For Next Login", "queue", 0 },
- { "ErrorReport", "errorreport:send", "Send Automatically", "send", 0 },
-
- { 0, 0, 0, 0, 0 },
-};
diff --git a/Source/cmVS140LinkFlagTable.h b/Source/cmVS140LinkFlagTable.h
deleted file mode 100644
index b9a4dc30a..000000000
--- a/Source/cmVS140LinkFlagTable.h
+++ /dev/null
@@ -1,282 +0,0 @@
-static cmVS7FlagTable cmVS140LinkFlagTable[] = {
-
- // Enum Properties
- { "ShowProgress", "", "Not Set", "NotSet", 0 },
- { "ShowProgress", "VERBOSE", "Display all progress messages", "LinkVerbose",
- 0 },
- { "ShowProgress", "VERBOSE:Lib", "For Libraries Searched", "LinkVerboseLib",
- 0 },
- { "ShowProgress", "VERBOSE:ICF",
- "About COMDAT folding during optimized linking", "LinkVerboseICF", 0 },
- { "ShowProgress", "VERBOSE:REF",
- "About data removed during optimized linking", "LinkVerboseREF", 0 },
- { "ShowProgress", "VERBOSE:SAFESEH", "About Modules incompatible with SEH",
- "LinkVerboseSAFESEH", 0 },
- { "ShowProgress", "VERBOSE:CLR",
- "About linker activity related to managed code", "LinkVerboseCLR", 0 },
-
- { "ForceFileOutput", "FORCE", "Enabled", "Enabled", 0 },
- { "ForceFileOutput", "FORCE:MULTIPLE", "Multiply Defined Symbol Only",
- "MultiplyDefinedSymbolOnly", 0 },
- { "ForceFileOutput", "FORCE:UNRESOLVED", "Undefined Symbol Only",
- "UndefinedSymbolOnly", 0 },
-
- { "CreateHotPatchableImage", "FUNCTIONPADMIN", "Enabled", "Enabled", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:5", "X86 Image Only",
- "X86Image", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:6", "X64 Image Only",
- "X64Image", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only",
- "ItaniumImage", 0 },
-
- { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 },
- { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable",
- "HighestAvailable", 0 },
- { "UACExecutionLevel", "level='requireAdministrator'",
- "requireAdministrator", "RequireAdministrator", 0 },
-
- { "GenerateDebugInformation", "DEBUG:FASTLINK",
- "Optimize for faster linking", "DebugFastLink",
- cmVS7FlagTable::CaseInsensitive },
- { "GenerateDebugInformation", "DEBUG:FULL", "Optimize for debugging", "true",
- cmVS7FlagTable::CaseInsensitive },
- { "GenerateDebugInformation", "DEBUG:NONE",
- "Produces no debugging information", "false",
- cmVS7FlagTable::CaseInsensitive },
- { "GenerateDebugInformation", "DEBUG", "Optimize for debugging", "true",
- cmVS7FlagTable::CaseInsensitive },
-
- { "SubSystem", "", "Not Set", "NotSet", 0 },
- { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
- { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
- "EFI Application", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
- "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
- 0 },
- { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
-
- { "Driver", "", "Not Set", "NotSet", 0 },
- { "Driver", "Driver", "Driver", "Driver", 0 },
- { "Driver", "DRIVER:UPONLY", "UP Only", "UpOnly", 0 },
- { "Driver", "DRIVER:WDM", "WDM", "WDM", 0 },
-
- { "LinkTimeCodeGeneration", "", "Default", "Default", 0 },
- { "LinkTimeCodeGeneration", "LTCG:incremental",
- "Use Fast Link Time Code Generation", "UseFastLinkTimeCodeGeneration", 0 },
- { "LinkTimeCodeGeneration", "LTCG", "Use Link Time Code Generation",
- "UseLinkTimeCodeGeneration", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGInstrument",
- "Profile Guided Optimization - Instrument", "PGInstrument", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGOptimize",
- "Profile Guided Optimization - Optimization", "PGOptimization", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGUpdate",
- "Profile Guided Optimization - Update", "PGUpdate", 0 },
-
- { "GenerateWindowsMetadata", "WINMD", "Yes", "true", 0 },
- { "GenerateWindowsMetadata", "WINMD:NO", "No", "false", 0 },
-
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
-
- { "TargetMachine", "", "Not Set", "NotSet", 0 },
- { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
- { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
- { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
- { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
- { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
- { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
- 0 },
- { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
- "MachineMIPSFPU16", 0 },
- { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
- { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
- { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
- { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
-
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA", "MTA threading attribute",
- "MTAThreadingAttribute", 0 },
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA", "STA threading attribute",
- "STAThreadingAttribute", 0 },
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE",
- "Default threading attribute", "DefaultThreadingAttribute", 0 },
-
- { "CLRImageType", "CLRIMAGETYPE:IJW", "Force IJW image", "ForceIJWImage",
- 0 },
- { "CLRImageType", "CLRIMAGETYPE:PURE", "Force Pure IL Image",
- "ForcePureILImage", 0 },
- { "CLRImageType", "CLRIMAGETYPE:SAFE", "Force Safe IL Image",
- "ForceSafeILImage", 0 },
- { "CLRImageType", "", "Default image type", "Default", 0 },
-
- { "SignHash", "CLRSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
- { "SignHash", "CLRSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
- { "SignHash", "CLRSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
- { "SignHash", "CLRSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
-
- { "LinkErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
- "PromptImmediately", 0 },
- { "LinkErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
- "QueueForNextLogin", 0 },
- { "LinkErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
- "SendErrorReport", 0 },
- { "LinkErrorReporting", "ERRORREPORT:NONE", "No Error Report",
- "NoErrorReport", 0 },
-
- { "CLRSupportLastError", "CLRSupportLastError", "Enabled", "Enabled", 0 },
- { "CLRSupportLastError", "CLRSupportLastError:NO", "Disabled", "Disabled",
- 0 },
- { "CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL", "System Dlls Only",
- "SystemDlls", 0 },
-
- // Bool Properties
- { "LinkIncremental", "INCREMENTAL:NO", "", "false", 0 },
- { "LinkIncremental", "INCREMENTAL", "", "true", 0 },
- { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
- { "LinkStatus", "LTCG:NOSTATUS", "", "false", 0 },
- { "LinkStatus", "LTCG:STATUS", "", "true", 0 },
- { "PreventDllBinding", "ALLOWBIND:NO", "", "false", 0 },
- { "PreventDllBinding", "ALLOWBIND", "", "true", 0 },
- { "TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0 },
- { "TreatLinkerWarningAsErrors", "WX", "", "true", 0 },
- { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
- { "GenerateManifest", "MANIFEST:NO", "", "false", 0 },
- { "GenerateManifest", "MANIFEST", "", "true", 0 },
- { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 },
- { "UACUIAccess", "uiAccess='false'", "", "false", 0 },
- { "UACUIAccess", "uiAccess='true'", "", "true", 0 },
- { "ManifestEmbed", "manifest:embed", "", "true", 0 },
- { "MapExports", "MAPINFO:EXPORTS", "", "true", 0 },
- { "AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0 },
- { "AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0 },
- { "LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0 },
- { "LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0 },
- { "TerminalServerAware", "TSAWARE:NO", "", "false", 0 },
- { "TerminalServerAware", "TSAWARE", "", "true", 0 },
- { "SwapRunFromCD", "SWAPRUN:CD", "", "true", 0 },
- { "SwapRunFromNET", "SWAPRUN:NET", "", "true", 0 },
- { "OptimizeReferences", "OPT:NOREF", "", "false", 0 },
- { "OptimizeReferences", "OPT:REF", "", "true", 0 },
- { "EnableCOMDATFolding", "OPT:NOICF", "", "false", 0 },
- { "EnableCOMDATFolding", "OPT:ICF", "", "true", 0 },
- { "IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0 },
- { "AppContainer", "APPCONTAINER", "", "true", 0 },
- { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN:NO", "", "false", 0 },
- { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN", "", "true", 0 },
- { "NoEntryPoint", "NOENTRY", "", "true", 0 },
- { "SetChecksum", "RELEASE", "", "true", 0 },
- { "RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0 },
- { "RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0 },
- { "FixedBaseAddress", "FIXED:NO", "", "false", 0 },
- { "FixedBaseAddress", "FIXED", "", "true", 0 },
- { "DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0 },
- { "DataExecutionPrevention", "NXCOMPAT", "", "true", 0 },
- { "TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0 },
- { "SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0 },
- { "SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0 },
- { "Profile", "PROFILE", "", "true", 0 },
- { "LinkDelaySign", "DELAYSIGN:NO", "", "false", 0 },
- { "LinkDelaySign", "DELAYSIGN", "", "true", 0 },
- { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0 },
- { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0 },
- { "DetectOneDefinitionRule", "ODR", "", "true", 0 },
- { "ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0 },
- { "ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0 },
- { "LinkDLL", "DLL", "", "true", 0 },
-
- // Bool Properties With Argument
- { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 },
- { "EnableUAC", "MANIFESTUAC:", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
- cmVS7FlagTable::UserValueRequired },
- { "GenerateMapFile", "MAP", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "MapFileName", "MAP:", "Generate Map File", "",
- cmVS7FlagTable::UserValueRequired },
-
- // String List Properties
- { "AdditionalLibraryDirectories", "LIBPATH:",
- "Additional Library Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "Natvis", "NATVIS:", "Natvis files", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- // Skip [AdditionalDependencies] - no command line Switch.
- { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
- "Ignore Specific Default Libraries", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AddModuleNamesToAssembly", "ASSEMBLYMODULE:", "Add Module to Assembly",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "EmbedManagedResourceFile", "ASSEMBLYRESOURCE:",
- "Embed Managed Resource File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "DelayLoadDLLs", "DELAYLOAD:", "Delay Loaded Dlls", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:", "Assembly Link Resource",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AdditionalManifestDependencies", "MANIFESTDEPENDENCY:",
- "Additional Manifest Dependencies", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ManifestInput", "manifestinput:", "Manifest Input", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
- { "Version", "VERSION:", "Version", "", cmVS7FlagTable::UserValue },
- { "SpecifySectionAttributes", "SECTION:", "Specify Section Attributes", "",
- cmVS7FlagTable::UserValue },
- { "MSDOSStubFileName", "STUB:", "MS-DOS Stub File Name", "",
- cmVS7FlagTable::UserValue },
- // Skip [TrackerLogDirectory] - no command line Switch.
- { "ModuleDefinitionFile", "DEF:", "Module Definition File", "",
- cmVS7FlagTable::UserValue },
- { "ManifestFile", "ManifestFile:", "Manifest File", "",
- cmVS7FlagTable::UserValue },
- { "ProgramDatabaseFile", "PDB:", "Generate Program Database File", "",
- cmVS7FlagTable::UserValue },
- { "StripPrivateSymbols", "PDBSTRIPPED:", "Strip Private Symbols", "",
- cmVS7FlagTable::UserValue },
- // Skip [MapFileName] - no command line Switch.
- // Skip [MinimumRequiredVersion] - no command line Switch.
- { "HeapReserveSize", "HEAP:", "Heap Reserve Size", "",
- cmVS7FlagTable::UserValue },
- // Skip [HeapCommitSize] - no command line Switch.
- { "StackReserveSize", "STACK:", "Stack Reserve Size", "",
- cmVS7FlagTable::UserValue },
- // Skip [StackCommitSize] - no command line Switch.
- { "FunctionOrder", "ORDER:@", "Function Order", "",
- cmVS7FlagTable::UserValue },
- { "ProfileGuidedDatabase", "PGD:", "Profile Guided Database", "",
- cmVS7FlagTable::UserValue },
- { "MidlCommandFile", "MIDL:@", "MIDL Commands", "",
- cmVS7FlagTable::UserValue },
- { "MergedIDLBaseFileName", "IDLOUT:", "Merged IDL Base File Name", "",
- cmVS7FlagTable::UserValue },
- { "TypeLibraryFile", "TLBOUT:", "Type Library", "",
- cmVS7FlagTable::UserValue },
- { "WindowsMetadataFile", "WINMDFILE:", "Windows Metadata File", "",
- cmVS7FlagTable::UserValue },
- { "WindowsMetadataLinkKeyFile", "WINMDKEYFILE:", "Windows Metadata Key File",
- "", cmVS7FlagTable::UserValue },
- { "WindowsMetadataKeyContainer", "WINMDKEYCONTAINER:",
- "Windows Metadata Key Container", "", cmVS7FlagTable::UserValue },
- { "EntryPointSymbol", "ENTRY:", "Entry Point", "",
- cmVS7FlagTable::UserValue },
- { "BaseAddress", "BASE:", "Base Address", "", cmVS7FlagTable::UserValue },
- { "ImportLibrary", "IMPLIB:", "Import Library", "",
- cmVS7FlagTable::UserValue },
- { "MergeSections", "MERGE:", "Merge Sections", "",
- cmVS7FlagTable::UserValue },
- { "LinkKeyFile", "KEYFILE:", "Key File", "", cmVS7FlagTable::UserValue },
- { "KeyContainer", "KEYCONTAINER:", "Key Container", "",
- cmVS7FlagTable::UserValue },
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS141CLFlagTable.h b/Source/cmVS141CLFlagTable.h
deleted file mode 100644
index f751fc875..000000000
--- a/Source/cmVS141CLFlagTable.h
+++ /dev/null
@@ -1,250 +0,0 @@
-static cmVS7FlagTable cmVS141CLFlagTable[] = {
-
- // Enum Properties
- { "DebugInformationFormat", "", "None", "None", 0 },
- { "DebugInformationFormat", "Z7", "C7 compatible", "OldStyle", 0 },
- { "DebugInformationFormat", "Zi", "Program Database", "ProgramDatabase", 0 },
- { "DebugInformationFormat", "ZI", "Program Database for Edit And Continue",
- "EditAndContinue", 0 },
-
- { "WarningLevel", "W0", "Turn Off All Warnings", "TurnOffAllWarnings", 0 },
- { "WarningLevel", "W1", "Level1", "Level1", 0 },
- { "WarningLevel", "W2", "Level2", "Level2", 0 },
- { "WarningLevel", "W3", "Level3", "Level3", 0 },
- { "WarningLevel", "W4", "Level4", "Level4", 0 },
- { "WarningLevel", "Wall", "EnableAllWarnings", "EnableAllWarnings", 0 },
-
- { "Optimization", "", "Custom", "Custom", 0 },
- { "Optimization", "Od", "Disabled", "Disabled", 0 },
- { "Optimization", "O1", "Minimize Size", "MinSpace", 0 },
- { "Optimization", "O2", "Maximize Speed", "MaxSpeed", 0 },
- { "Optimization", "Ox", "Full Optimization", "Full", 0 },
-
- { "InlineFunctionExpansion", "", "Default", "Default", 0 },
- { "InlineFunctionExpansion", "Ob0", "Disabled", "Disabled", 0 },
- { "InlineFunctionExpansion", "Ob1", "Only __inline", "OnlyExplicitInline",
- 0 },
- { "InlineFunctionExpansion", "Ob2", "Any Suitable", "AnySuitable", 0 },
-
- { "FavorSizeOrSpeed", "Os", "Favor small code", "Size", 0 },
- { "FavorSizeOrSpeed", "Ot", "Favor fast code", "Speed", 0 },
- { "FavorSizeOrSpeed", "", "Neither", "Neither", 0 },
-
- { "ExceptionHandling", "EHa", "Yes with SEH Exceptions", "Async", 0 },
- { "ExceptionHandling", "EHsc", "Yes", "Sync", 0 },
- { "ExceptionHandling", "EHs", "Yes with Extern C functions", "SyncCThrow",
- 0 },
- { "ExceptionHandling", "", "No", "false", 0 },
-
- { "BasicRuntimeChecks", "RTCs", "Stack Frames", "StackFrameRuntimeCheck",
- 0 },
- { "BasicRuntimeChecks", "RTCu", "Uninitialized variables",
- "UninitializedLocalUsageCheck", 0 },
- { "BasicRuntimeChecks", "RTC1", "Both (/RTC1, equiv. to /RTCsu)",
- "EnableFastChecks", 0 },
- { "BasicRuntimeChecks", "", "Default", "Default", 0 },
-
- { "RuntimeLibrary", "MT", "Multi-threaded", "MultiThreaded", 0 },
- { "RuntimeLibrary", "MTd", "Multi-threaded Debug", "MultiThreadedDebug", 0 },
- { "RuntimeLibrary", "MD", "Multi-threaded DLL", "MultiThreadedDLL", 0 },
- { "RuntimeLibrary", "MDd", "Multi-threaded Debug DLL",
- "MultiThreadedDebugDLL", 0 },
-
- { "StructMemberAlignment", "Zp1", "1 Byte", "1Byte", 0 },
- { "StructMemberAlignment", "Zp2", "2 Bytes", "2Bytes", 0 },
- { "StructMemberAlignment", "Zp4", "4 Byte", "4Bytes", 0 },
- { "StructMemberAlignment", "Zp8", "8 Bytes", "8Bytes", 0 },
- { "StructMemberAlignment", "Zp16", "16 Bytes", "16Bytes", 0 },
- { "StructMemberAlignment", "", "Default", "Default", 0 },
-
- { "BufferSecurityCheck", "GS-", "Disable Security Check", "false", 0 },
- { "BufferSecurityCheck", "GS", "Enable Security Check", "true", 0 },
-
- { "ControlFlowGuard", "guard:cf", "Yes", "Guard", 0 },
- { "ControlFlowGuard", "", "No", "false", 0 },
-
- { "EnableEnhancedInstructionSet", "arch:SSE", "Streaming SIMD Extensions",
- "StreamingSIMDExtensions", 0 },
- { "EnableEnhancedInstructionSet", "arch:SSE2", "Streaming SIMD Extensions 2",
- "StreamingSIMDExtensions2", 0 },
- { "EnableEnhancedInstructionSet", "arch:AVX", "Advanced Vector Extensions",
- "AdvancedVectorExtensions", 0 },
- { "EnableEnhancedInstructionSet", "arch:AVX2",
- "Advanced Vector Extensions 2", "AdvancedVectorExtensions2", 0 },
- { "EnableEnhancedInstructionSet", "arch:IA32", "No Enhanced Instructions",
- "NoExtensions", 0 },
- { "EnableEnhancedInstructionSet", "", "Not Set", "NotSet", 0 },
-
- { "FloatingPointModel", "fp:precise", "Precise", "Precise", 0 },
- { "FloatingPointModel", "fp:strict", "Strict", "Strict", 0 },
- { "FloatingPointModel", "fp:fast", "Fast", "Fast", 0 },
-
- { "LanguageStandard", "std:c++14", "ISO C++14 Standard", "stdcpp14", 0 },
- { "LanguageStandard", "std:c++latest", "ISO C++ Latest Draft Standard",
- "stdcpplatest", 0 },
-
- { "PrecompiledHeader", "Yc", "Create", "Create",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "PrecompiledHeader", "Yu", "Use", "Use",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0 },
-
- { "AssemblerOutput", "", "No Listing", "NoListing", 0 },
- { "AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0 },
- { "AssemblerOutput", "FAc", "Assembly With Machine Code",
- "AssemblyAndMachineCode", 0 },
- { "AssemblerOutput", "FAs", "Assembly With Source Code",
- "AssemblyAndSourceCode", 0 },
- { "AssemblerOutput", "FAcs", "Assembly, Machine Code and Source", "All", 0 },
-
- { "CallingConvention", "Gd", "__cdecl", "Cdecl", 0 },
- { "CallingConvention", "Gr", "__fastcall", "FastCall", 0 },
- { "CallingConvention", "Gz", "__stdcall", "StdCall", 0 },
- { "CallingConvention", "Gv", "__vectorcall", "VectorCall", 0 },
-
- { "CompileAs", "", "Default", "Default", 0 },
- { "CompileAs", "TC", "Compile as C Code", "CompileAsC", 0 },
- { "CompileAs", "TP", "Compile as C++ Code", "CompileAsCpp", 0 },
-
- { "ErrorReporting", "errorReport:none", "Do Not Send Report", "None", 0 },
- { "ErrorReporting", "errorReport:prompt", "Prompt Immediately", "Prompt",
- 0 },
- { "ErrorReporting", "errorReport:queue", "Queue For Next Login", "Queue",
- 0 },
- { "ErrorReporting", "errorReport:send", "Send Automatically", "Send", 0 },
-
- { "CompileAsManaged", "", "No Common Language RunTime Support", "false", 0 },
- { "CompileAsManaged", "clr", "Common Language RunTime Support", "true", 0 },
- { "CompileAsManaged", "clr:pure",
- "Pure MSIL Common Language RunTime Support", "Pure", 0 },
- { "CompileAsManaged", "clr:safe",
- "Safe MSIL Common Language RunTime Support", "Safe", 0 },
- { "CompileAsManaged", "clr:oldSyntax",
- "Common Language RunTime Support, Old Syntax", "OldSyntax", 0 },
-
- { "CppLanguageStandard", "", "Default", "Default", 0 },
- { "CppLanguageStandard", "std=c++98", "C++03", "c++98", 0 },
- { "CppLanguageStandard", "std=c++11", "C++11", "c++11", 0 },
- { "CppLanguageStandard", "std=c++1y", "C++14", "c++1y", 0 },
- { "CppLanguageStandard", "std=c++14", "C++14", "c++1y", 0 },
- { "CppLanguageStandard", "std=gnu++98", "C++03 (GNU Dialect)", "gnu++98",
- 0 },
- { "CppLanguageStandard", "std=gnu++11", "C++11 (GNU Dialect)", "gnu++11",
- 0 },
- { "CppLanguageStandard", "std=gnu++1y", "C++14 (GNU Dialect)", "gnu++1y",
- 0 },
- { "CppLanguageStandard", "std=gnu++14", "C++14 (GNU Dialect)", "gnu++1y",
- 0 },
-
- // Bool Properties
- { "CompileAsWinRT", "ZW", "", "true", 0 },
- { "WinRTNoStdLib", "ZW:nostdlib", "", "true", 0 },
- { "SuppressStartupBanner", "nologo", "", "true", 0 },
- { "TreatWarningAsError", "WX-", "", "false", 0 },
- { "TreatWarningAsError", "WX", "", "true", 0 },
- { "SDLCheck", "sdl-", "", "false", 0 },
- { "SDLCheck", "sdl", "", "true", 0 },
- { "IntrinsicFunctions", "Oi", "", "true", 0 },
- { "OmitFramePointers", "Oy-", "", "false", 0 },
- { "OmitFramePointers", "Oy", "", "true", 0 },
- { "EnableFiberSafeOptimizations", "GT", "", "true", 0 },
- { "WholeProgramOptimization", "GL", "", "true", 0 },
- { "UndefineAllPreprocessorDefinitions", "u", "", "true", 0 },
- { "IgnoreStandardIncludePath", "X", "", "true", 0 },
- { "PreprocessToFile", "P", "", "true", 0 },
- { "PreprocessSuppressLineNumbers", "EP", "", "true", 0 },
- { "PreprocessKeepComments", "C", "", "true", 0 },
- { "StringPooling", "GF-", "", "false", 0 },
- { "StringPooling", "GF", "", "true", 0 },
- { "MinimalRebuild", "Gm-", "", "false", 0 },
- { "MinimalRebuild", "Gm", "", "true", 0 },
- { "SmallerTypeCheck", "RTCc", "", "true", 0 },
- { "FunctionLevelLinking", "Gy-", "", "false", 0 },
- { "FunctionLevelLinking", "Gy", "", "true", 0 },
- { "EnableParallelCodeGeneration", "Qpar-", "", "false", 0 },
- { "EnableParallelCodeGeneration", "Qpar", "", "true", 0 },
- { "FloatingPointExceptions", "fp:except-", "", "false", 0 },
- { "FloatingPointExceptions", "fp:except", "", "true", 0 },
- { "CreateHotpatchableImage", "hotpatch", "", "true", 0 },
- { "DisableLanguageExtensions", "Za", "", "true", 0 },
- { "TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0 },
- { "TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0 },
- { "ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0 },
- { "ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0 },
- { "RemoveUnreferencedCodeData", "Zc:inline-", "", "false", 0 },
- { "RemoveUnreferencedCodeData", "Zc:inline", "", "true", 0 },
- { "EnforceTypeConversionRules", "Zc:rvalueCast-", "", "false", 0 },
- { "EnforceTypeConversionRules", "Zc:rvalueCast", "", "true", 0 },
- { "RuntimeTypeInfo", "GR-", "", "false", 0 },
- { "RuntimeTypeInfo", "GR", "", "true", 0 },
- { "OpenMPSupport", "openmp-", "", "false", 0 },
- { "OpenMPSupport", "openmp", "", "true", 0 },
- { "ExpandAttributedSource", "Fx", "", "true", 0 },
- { "UseUnicodeForAssemblerListing", "FAu", "", "true", 0 },
- { "ShowIncludes", "showIncludes", "", "true", 0 },
- { "EnablePREfast", "analyze-", "", "false", 0 },
- { "EnablePREfast", "analyze", "", "true", 0 },
- { "UseFullPaths", "FC", "", "true", 0 },
- { "OmitDefaultLibName", "Zl", "", "true", 0 },
-
- // Bool Properties With Argument
- { "MultiProcessorCompilation", "MP", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "ProcessorNumber", "MP", "Multi-processor Compilation", "",
- cmVS7FlagTable::UserValueRequired },
- { "GenerateXMLDocumentationFiles", "doc", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "",
- cmVS7FlagTable::UserValueRequired },
- { "BrowseInformation", "FR", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "BrowseInformationFile", "FR", "Enable Browse Information", "",
- cmVS7FlagTable::UserValueRequired },
-
- // String List Properties
- { "AdditionalIncludeDirectories", "I", "Additional Include Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AdditionalUsingDirectories", "AI", "Additional #using Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "PreprocessorDefinitions", "D ", "Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "UndefinePreprocessorDefinitions", "U",
- "Undefine Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "DisableSpecificWarnings", "wd", "Disable Specific Warnings", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForcedIncludeFiles", "FI", "Forced Include File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForcedUsingFiles", "FU", "Forced #using File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "PREfastLog", "analyze:log", "Code Analysis Log", "",
- cmVS7FlagTable::UserFollowing },
- { "PREfastAdditionalPlugins", "analyze:plugin",
- "Additional Code Analysis Native plugins", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "TreatSpecificWarningsAsErrors", "we", "Treat Specific Warnings As Errors",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- { "WarningVersion", "Wv:", "Warning Version", "",
- cmVS7FlagTable::UserValue },
- // Skip [TrackerLogDirectory] - no command line Switch.
- { "PreprocessOutputPath", "Fi", "Preprocess Output Path", "",
- cmVS7FlagTable::UserValue },
- { "PrecompiledHeaderFile", "Yc", "Precompiled Header Name", "",
- cmVS7FlagTable::UserValueRequired },
- { "PrecompiledHeaderFile", "Yu", "Precompiled Header Name", "",
- cmVS7FlagTable::UserValueRequired },
- { "PrecompiledHeaderOutputFile", "Fp", "Precompiled Header Output File", "",
- cmVS7FlagTable::UserValue },
- { "AssemblerListingLocation", "Fa", "ASM List Location", "",
- cmVS7FlagTable::UserValue },
- { "ObjectFileName", "Fo", "Object File Name", "",
- cmVS7FlagTable::UserValue },
- { "ProgramDataBaseFileName", "Fd", "Program Database File Name", "",
- cmVS7FlagTable::UserValue },
- // Skip [XMLDocumentationFileName] - no command line Switch.
- // Skip [BrowseInformationFile] - no command line Switch.
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS141CSharpFlagTable.h b/Source/cmVS141CSharpFlagTable.h
deleted file mode 100644
index 85085817c..000000000
--- a/Source/cmVS141CSharpFlagTable.h
+++ /dev/null
@@ -1,120 +0,0 @@
-static cmVS7FlagTable cmVS141CSharpFlagTable[] = {
- { "ProjectName", "out:", "", "", cmIDEFlagTable::UserValueRequired },
-
- { "OutputType", "target:exe", "", "Exe", 0 },
- { "OutputType", "target:winexe", "", "Winexe", 0 },
- { "OutputType", "target:library", "", "Library", 0 },
- { "OutputType", "target:module", "", "Module", 0 },
-
- { "DocumentationFile", "doc", "", "", cmIDEFlagTable::UserValueRequired },
-
- { "Platform", "platform:x86", "", "x86", 0 },
- { "Platform", "platform:Itanium", "", "Itanium", 0 },
- { "Platform", "platform:x64", "", "x64", 0 },
- { "Platform", "platform:arm", "", "arm", 0 },
- { "Platform", "platform:anycpu32bitpreferred", "", "anycpu32bitpreferred",
- 0 },
- { "Platform", "platform:anycpu", "", "anycpu", 0 },
-
- { "References", "reference:", "mit alias", "", 0 },
- { "References", "reference:", "dateiliste", "", 0 },
- { "AddModules", "addmodule:", "", "", cmIDEFlagTable::SemicolonAppendable },
- { "", "link", "", "", 0 },
-
- { "Win32Resource", "win32res", "", "", cmIDEFlagTable::UserValueRequired },
- { "ApplicationIcon", "win32icon", "", "",
- cmIDEFlagTable::UserValueRequired },
-
- { "Win32Manifest", "win32manifest:", "", "true", 0 },
-
- { "NoWin32Manifest", "nowin32manifest", "", "true", 0 },
-
- { "DefineDebug", "debug", "", "true", cmIDEFlagTable::Continue },
-
- { "DebugSymbols", "debug", "", "true", 0 },
- { "DebugSymbols", "debug-", "", "false", 0 },
- { "DebugSymbols", "debug+", "", "true", 0 },
-
- { "DebugType", "debug:none", "", "none", 0 },
- { "DebugType", "debug:full", "", "full", 0 },
- { "DebugType", "debug:pdbonly", "", "pdbonly", 0 },
-
- { "Optimize", "optimize", "", "true", 0 },
- { "Optimize", "optimize-", "", "false", 0 },
- { "Optimize", "optimize+", "", "true", 0 },
-
- { "TreatWarningsAsErrors", "warnaserror", "", "true", 0 },
- { "TreatWarningsAsErrors", "warnaserror-", "", "false", 0 },
- { "TreatWarningsAsErrors", "warnaserror+", "", "true", 0 },
-
- { "WarningsAsErrors", "warnaserror", "", "", 0 },
- { "WarningsAsErrors", "warnaserror-", "", "", 0 },
- { "WarningsAsErrors", "warnaserror+", "", "", 0 },
-
- { "WarningLevel", "warn:0", "", "0", 0 },
- { "WarningLevel", "warn:1", "", "1", 0 },
- { "WarningLevel", "warn:2", "", "2", 0 },
- { "WarningLevel", "warn:3", "", "3", 0 },
- { "WarningLevel", "warn:4", "", "4", 0 },
- { "DisabledWarnings", "nowarn", "", "", 0 },
-
- { "CheckForOverflowUnderflow", "checked", "", "true", 0 },
- { "CheckForOverflowUnderflow", "checked-", "", "false", 0 },
- { "CheckForOverflowUnderflow", "checked+", "", "true", 0 },
-
- { "AllowUnsafeBlocks", "unsafe", "", "true", 0 },
- { "AllowUnsafeBlocks", "unsafe-", "", "false", 0 },
- { "AllowUnsafeBlocks", "unsafe+", "", "true", 0 },
-
- { "DefineConstants", "define:", "", "",
- cmIDEFlagTable::SemicolonAppendable | cmIDEFlagTable::UserValue },
-
- { "LangVersion", "langversion:ISO-1", "", "ISO-1", 0 },
- { "LangVersion", "langversion:ISO-2", "", "ISO-2", 0 },
- { "LangVersion", "langversion:3", "", "3", 0 },
- { "LangVersion", "langversion:4", "", "4", 0 },
- { "LangVersion", "langversion:5", "", "5", 0 },
- { "LangVersion", "langversion:6", "", "6", 0 },
- { "LangVersion", "langversion:default", "", "default", 0 },
-
- { "DelaySign", "delaysign", "", "true", 0 },
- { "DelaySign", "delaysign-", "", "false", 0 },
- { "DelaySign", "delaysign+", "", "true", 0 },
-
- { "AssemblyOriginatorKeyFile", "keyfile", "", "", 0 },
-
- { "KeyContainerName", "keycontainer", "", "", 0 },
-
- { "NoLogo", "nologo", "", "", 0 },
-
- { "NoConfig", "noconfig", "", "true", 0 },
-
- { "BaseAddress", "baseaddress:", "", "", 0 },
-
- { "CodePage", "codepage", "", "", 0 },
-
- { "Utf8Output", "utf8output", "", "", 0 },
-
- { "MainEntryPoint", "main:", "", "", 0 },
-
- { "GenerateFullPaths", "fullpaths", "", "true", 0 },
-
- { "FileAlignment", "filealign", "", "", 0 },
-
- { "PdbFile", "pdb:", "", "", 0 },
-
- { "NoStandardLib", "nostdlib", "", "true", 0 },
- { "NoStandardLib", "nostdlib-", "", "false", 0 },
- { "NoStandardLib", "nostdlib+", "", "true", 0 },
-
- { "SubsystemVersion", "subsystemversion", "", "", 0 },
-
- { "AdditionalLibPaths", "lib:", "", "", 0 },
-
- { "ErrorReport", "errorreport:none", "Do Not Send Report", "none", 0 },
- { "ErrorReport", "errorreport:prompt", "Prompt Immediately", "prompt", 0 },
- { "ErrorReport", "errorreport:queue", "Queue For Next Login", "queue", 0 },
- { "ErrorReport", "errorreport:send", "Send Automatically", "send", 0 },
-
- { 0, 0, 0, 0, 0 },
-};
diff --git a/Source/cmVS141LinkFlagTable.h b/Source/cmVS141LinkFlagTable.h
deleted file mode 100644
index 8f0f1f42d..000000000
--- a/Source/cmVS141LinkFlagTable.h
+++ /dev/null
@@ -1,283 +0,0 @@
-static cmVS7FlagTable cmVS141LinkFlagTable[] = {
-
- // Enum Properties
- { "ShowProgress", "", "Not Set", "NotSet", 0 },
- { "ShowProgress", "VERBOSE", "Display all progress messages", "LinkVerbose",
- 0 },
- { "ShowProgress", "VERBOSE:Lib", "For Libraries Searched", "LinkVerboseLib",
- 0 },
- { "ShowProgress", "VERBOSE:ICF",
- "About COMDAT folding during optimized linking", "LinkVerboseICF", 0 },
- { "ShowProgress", "VERBOSE:REF",
- "About data removed during optimized linking", "LinkVerboseREF", 0 },
- { "ShowProgress", "VERBOSE:SAFESEH", "About Modules incompatible with SEH",
- "LinkVerboseSAFESEH", 0 },
- { "ShowProgress", "VERBOSE:CLR",
- "About linker activity related to managed code", "LinkVerboseCLR", 0 },
-
- { "ForceFileOutput", "FORCE", "Enabled", "Enabled", 0 },
- { "ForceFileOutput", "FORCE:MULTIPLE", "Multiply Defined Symbol Only",
- "MultiplyDefinedSymbolOnly", 0 },
- { "ForceFileOutput", "FORCE:UNRESOLVED", "Undefined Symbol Only",
- "UndefinedSymbolOnly", 0 },
-
- { "CreateHotPatchableImage", "FUNCTIONPADMIN", "Enabled", "Enabled", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:5", "X86 Image Only",
- "X86Image", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:6", "X64 Image Only",
- "X64Image", 0 },
- { "CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only",
- "ItaniumImage", 0 },
-
- { "UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0 },
- { "UACExecutionLevel", "level='highestAvailable'", "highestAvailable",
- "HighestAvailable", 0 },
- { "UACExecutionLevel", "level='requireAdministrator'",
- "requireAdministrator", "RequireAdministrator", 0 },
-
- { "GenerateDebugInformation", "DEBUG:FASTLINK",
- "Generate Debug Information optimized for faster links", "DebugFastLink",
- cmVS7FlagTable::CaseInsensitive },
- { "GenerateDebugInformation", "DEBUG:FULL",
- "Generate Debug Information optimized for sharing and publishing",
- "DebugFull", cmVS7FlagTable::CaseInsensitive },
- { "GenerateDebugInformation", "DEBUG:NONE",
- "Produces no debugging information", "false",
- cmVS7FlagTable::CaseInsensitive },
- { "GenerateDebugInformation", "DEBUG", "Generate Debug Information", "true",
- cmVS7FlagTable::CaseInsensitive },
-
- { "SubSystem", "", "Not Set", "NotSet", 0 },
- { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
- { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
- "EFI Application", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
- "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
- 0 },
- { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
-
- { "Driver", "", "Not Set", "NotSet", 0 },
- { "Driver", "Driver", "Driver", "Driver", 0 },
- { "Driver", "DRIVER:UPONLY", "UP Only", "UpOnly", 0 },
- { "Driver", "DRIVER:WDM", "WDM", "WDM", 0 },
-
- { "LinkTimeCodeGeneration", "", "Default", "Default", 0 },
- { "LinkTimeCodeGeneration", "LTCG:incremental",
- "Use Fast Link Time Code Generation", "UseFastLinkTimeCodeGeneration", 0 },
- { "LinkTimeCodeGeneration", "LTCG", "Use Link Time Code Generation",
- "UseLinkTimeCodeGeneration", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGInstrument",
- "Profile Guided Optimization - Instrument", "PGInstrument", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGOptimize",
- "Profile Guided Optimization - Optimization", "PGOptimization", 0 },
- { "LinkTimeCodeGeneration", "LTCG:PGUpdate",
- "Profile Guided Optimization - Update", "PGUpdate", 0 },
-
- { "GenerateWindowsMetadata", "WINMD", "Yes", "true", 0 },
- { "GenerateWindowsMetadata", "WINMD:NO", "No", "false", 0 },
-
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
- { "WindowsMetadataSignHash", "WINMDSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
-
- { "TargetMachine", "", "Not Set", "NotSet", 0 },
- { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
- { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
- { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
- { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
- { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
- { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
- 0 },
- { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
- "MachineMIPSFPU16", 0 },
- { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
- { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
- { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
- { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
-
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA", "MTA threading attribute",
- "MTAThreadingAttribute", 0 },
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA", "STA threading attribute",
- "STAThreadingAttribute", 0 },
- { "CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE",
- "Default threading attribute", "DefaultThreadingAttribute", 0 },
-
- { "CLRImageType", "CLRIMAGETYPE:IJW", "Force IJW image", "ForceIJWImage",
- 0 },
- { "CLRImageType", "CLRIMAGETYPE:PURE", "Force Pure IL Image",
- "ForcePureILImage", 0 },
- { "CLRImageType", "CLRIMAGETYPE:SAFE", "Force Safe IL Image",
- "ForceSafeILImage", 0 },
- { "CLRImageType", "", "Default image type", "Default", 0 },
-
- { "SignHash", "CLRSIGNHASH:SHA1", "SHA1", "SHA1", 0 },
- { "SignHash", "CLRSIGNHASH:SHA256", "SHA256", "SHA256", 0 },
- { "SignHash", "CLRSIGNHASH:SHA384", "SHA384", "SHA384", 0 },
- { "SignHash", "CLRSIGNHASH:SHA512", "SHA512", "SHA512", 0 },
-
- { "LinkErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
- "PromptImmediately", 0 },
- { "LinkErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
- "QueueForNextLogin", 0 },
- { "LinkErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
- "SendErrorReport", 0 },
- { "LinkErrorReporting", "ERRORREPORT:NONE", "No Error Report",
- "NoErrorReport", 0 },
-
- { "CLRSupportLastError", "CLRSupportLastError", "Enabled", "Enabled", 0 },
- { "CLRSupportLastError", "CLRSupportLastError:NO", "Disabled", "Disabled",
- 0 },
- { "CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL", "System Dlls Only",
- "SystemDlls", 0 },
-
- // Bool Properties
- { "LinkIncremental", "INCREMENTAL:NO", "", "false", 0 },
- { "LinkIncremental", "INCREMENTAL", "", "true", 0 },
- { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
- { "LinkStatus", "LTCG:NOSTATUS", "", "false", 0 },
- { "LinkStatus", "LTCG:STATUS", "", "true", 0 },
- { "PreventDllBinding", "ALLOWBIND:NO", "", "false", 0 },
- { "PreventDllBinding", "ALLOWBIND", "", "true", 0 },
- { "TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0 },
- { "TreatLinkerWarningAsErrors", "WX", "", "true", 0 },
- { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
- { "GenerateManifest", "MANIFEST:NO", "", "false", 0 },
- { "GenerateManifest", "MANIFEST", "", "true", 0 },
- { "AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0 },
- { "UACUIAccess", "uiAccess='false'", "", "false", 0 },
- { "UACUIAccess", "uiAccess='true'", "", "true", 0 },
- { "ManifestEmbed", "manifest:embed", "", "true", 0 },
- { "MapExports", "MAPINFO:EXPORTS", "", "true", 0 },
- { "AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0 },
- { "AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0 },
- { "LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0 },
- { "LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0 },
- { "TerminalServerAware", "TSAWARE:NO", "", "false", 0 },
- { "TerminalServerAware", "TSAWARE", "", "true", 0 },
- { "SwapRunFromCD", "SWAPRUN:CD", "", "true", 0 },
- { "SwapRunFromNET", "SWAPRUN:NET", "", "true", 0 },
- { "OptimizeReferences", "OPT:NOREF", "", "false", 0 },
- { "OptimizeReferences", "OPT:REF", "", "true", 0 },
- { "EnableCOMDATFolding", "OPT:NOICF", "", "false", 0 },
- { "EnableCOMDATFolding", "OPT:ICF", "", "true", 0 },
- { "IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0 },
- { "AppContainer", "APPCONTAINER", "", "true", 0 },
- { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN:NO", "", "false", 0 },
- { "WindowsMetadataLinkDelaySign", "WINMDDELAYSIGN", "", "true", 0 },
- { "NoEntryPoint", "NOENTRY", "", "true", 0 },
- { "SetChecksum", "RELEASE", "", "true", 0 },
- { "RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0 },
- { "RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0 },
- { "FixedBaseAddress", "FIXED:NO", "", "false", 0 },
- { "FixedBaseAddress", "FIXED", "", "true", 0 },
- { "DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0 },
- { "DataExecutionPrevention", "NXCOMPAT", "", "true", 0 },
- { "TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0 },
- { "SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0 },
- { "SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0 },
- { "Profile", "PROFILE", "", "true", 0 },
- { "LinkDelaySign", "DELAYSIGN:NO", "", "false", 0 },
- { "LinkDelaySign", "DELAYSIGN", "", "true", 0 },
- { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0 },
- { "CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0 },
- { "DetectOneDefinitionRule", "ODR", "", "true", 0 },
- { "ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0 },
- { "ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0 },
- { "LinkDLL", "DLL", "", "true", 0 },
-
- // Bool Properties With Argument
- { "EnableUAC", "MANIFESTUAC:NO", "", "false", 0 },
- { "EnableUAC", "MANIFESTUAC:", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "",
- cmVS7FlagTable::UserValueRequired },
- { "GenerateMapFile", "MAP", "", "true",
- cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue },
- { "MapFileName", "MAP:", "Generate Map File", "",
- cmVS7FlagTable::UserValueRequired },
-
- // String List Properties
- { "AdditionalLibraryDirectories", "LIBPATH:",
- "Additional Library Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "Natvis", "NATVIS:", "Natvis files", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- // Skip [AdditionalDependencies] - no command line Switch.
- { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
- "Ignore Specific Default Libraries", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AddModuleNamesToAssembly", "ASSEMBLYMODULE:", "Add Module to Assembly",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "EmbedManagedResourceFile", "ASSEMBLYRESOURCE:",
- "Embed Managed Resource File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "DelayLoadDLLs", "DELAYLOAD:", "Delay Loaded Dlls", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:", "Assembly Link Resource",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "AdditionalManifestDependencies", "MANIFESTDEPENDENCY:",
- "Additional Manifest Dependencies", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ManifestInput", "manifestinput:", "Manifest Input", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
- { "Version", "VERSION:", "Version", "", cmVS7FlagTable::UserValue },
- { "SpecifySectionAttributes", "SECTION:", "Specify Section Attributes", "",
- cmVS7FlagTable::UserValue },
- { "MSDOSStubFileName", "STUB:", "MS-DOS Stub File Name", "",
- cmVS7FlagTable::UserValue },
- // Skip [TrackerLogDirectory] - no command line Switch.
- { "ModuleDefinitionFile", "DEF:", "Module Definition File", "",
- cmVS7FlagTable::UserValue },
- { "ManifestFile", "ManifestFile:", "Manifest File", "",
- cmVS7FlagTable::UserValue },
- { "ProgramDatabaseFile", "PDB:", "Generate Program Database File", "",
- cmVS7FlagTable::UserValue },
- { "StripPrivateSymbols", "PDBSTRIPPED:", "Strip Private Symbols", "",
- cmVS7FlagTable::UserValue },
- // Skip [MapFileName] - no command line Switch.
- // Skip [MinimumRequiredVersion] - no command line Switch.
- { "HeapReserveSize", "HEAP:", "Heap Reserve Size", "",
- cmVS7FlagTable::UserValue },
- // Skip [HeapCommitSize] - no command line Switch.
- { "StackReserveSize", "STACK:", "Stack Reserve Size", "",
- cmVS7FlagTable::UserValue },
- // Skip [StackCommitSize] - no command line Switch.
- { "FunctionOrder", "ORDER:@", "Function Order", "",
- cmVS7FlagTable::UserValue },
- { "ProfileGuidedDatabase", "PGD:", "Profile Guided Database", "",
- cmVS7FlagTable::UserValue },
- { "MidlCommandFile", "MIDL:@", "MIDL Commands", "",
- cmVS7FlagTable::UserValue },
- { "MergedIDLBaseFileName", "IDLOUT:", "Merged IDL Base File Name", "",
- cmVS7FlagTable::UserValue },
- { "TypeLibraryFile", "TLBOUT:", "Type Library", "",
- cmVS7FlagTable::UserValue },
- { "WindowsMetadataFile", "WINMDFILE:", "Windows Metadata File", "",
- cmVS7FlagTable::UserValue },
- { "WindowsMetadataLinkKeyFile", "WINMDKEYFILE:", "Windows Metadata Key File",
- "", cmVS7FlagTable::UserValue },
- { "WindowsMetadataKeyContainer", "WINMDKEYCONTAINER:",
- "Windows Metadata Key Container", "", cmVS7FlagTable::UserValue },
- { "EntryPointSymbol", "ENTRY:", "Entry Point", "",
- cmVS7FlagTable::UserValue },
- { "BaseAddress", "BASE:", "Base Address", "", cmVS7FlagTable::UserValue },
- { "ImportLibrary", "IMPLIB:", "Import Library", "",
- cmVS7FlagTable::UserValue },
- { "MergeSections", "MERGE:", "Merge Sections", "",
- cmVS7FlagTable::UserValue },
- { "LinkKeyFile", "KEYFILE:", "Key File", "", cmVS7FlagTable::UserValue },
- { "KeyContainer", "KEYCONTAINER:", "Key Container", "",
- cmVS7FlagTable::UserValue },
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS14LibFlagTable.h b/Source/cmVS14LibFlagTable.h
deleted file mode 100644
index 7fa713893..000000000
--- a/Source/cmVS14LibFlagTable.h
+++ /dev/null
@@ -1,76 +0,0 @@
-static cmVS7FlagTable cmVS14LibFlagTable[] = {
-
- // Enum Properties
- { "ErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately",
- "PromptImmediately", 0 },
- { "ErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login",
- "QueueForNextLogin", 0 },
- { "ErrorReporting", "ERRORREPORT:SEND", "Send Error Report",
- "SendErrorReport", 0 },
- { "ErrorReporting", "ERRORREPORT:NONE", "No Error Report", "NoErrorReport",
- 0 },
-
- { "TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0 },
- { "TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0 },
- { "TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0 },
- { "TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0 },
- { "TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0 },
- { "TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU",
- 0 },
- { "TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16",
- "MachineMIPSFPU16", 0 },
- { "TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0 },
- { "TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0 },
- { "TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0 },
- { "TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0 },
-
- { "SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0 },
- { "SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application",
- "EFI Application", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
- "EFI Boot Service Driver", "EFI Boot Service Driver", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0 },
- { "SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime",
- 0 },
- { "SubSystem", "SUBSYSTEM:WINDOWSCE", "WindowsCE", "WindowsCE", 0 },
- { "SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0 },
-
- // Bool Properties
- { "SuppressStartupBanner", "NOLOGO", "", "true", 0 },
- { "IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0 },
- { "TreatLibWarningAsErrors", "WX:NO", "", "false", 0 },
- { "TreatLibWarningAsErrors", "WX", "", "true", 0 },
- { "Verbose", "VERBOSE", "", "true", 0 },
- { "LinkTimeCodeGeneration", "LTCG", "", "true", 0 },
-
- // Bool Properties With Argument
-
- // String List Properties
- // Skip [AdditionalDependencies] - no command line Switch.
- { "AdditionalLibraryDirectories", "LIBPATH:",
- "Additional Library Directories", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:",
- "Ignore Specific Default Libraries", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "ExportNamedFunctions", "EXPORT:", "Export Named Functions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "RemoveObjects", "REMOVE:", "Remove Objects", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
-
- // String Properties
- { "OutputFile", "OUT:", "Output File", "", cmVS7FlagTable::UserValue },
- { "ModuleDefinitionFile", "DEF:", "Module Definition File Name", "",
- cmVS7FlagTable::UserValue },
- { "ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "",
- cmVS7FlagTable::UserValue },
- { "DisplayLibrary", "LIST:", "Display Library to standard output", "",
- cmVS7FlagTable::UserValue },
- // Skip [MinimumRequiredVersion] - no command line Switch.
- { "Name", "NAME:", "Name", "", cmVS7FlagTable::UserValue },
- // Skip [AdditionalOptions] - no command line Switch.
- // Skip [TrackerLogDirectory] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS14MASMFlagTable.h b/Source/cmVS14MASMFlagTable.h
deleted file mode 100644
index 82ec9f1d0..000000000
--- a/Source/cmVS14MASMFlagTable.h
+++ /dev/null
@@ -1,76 +0,0 @@
-static cmVS7FlagTable cmVS14MASMFlagTable[] = {
-
- // Enum Properties
- { "PreserveIdentifierCase", "", "Default", "0", 0 },
- { "PreserveIdentifierCase", "Cp", "Preserves Identifier Case (/Cp)", "1",
- 0 },
- { "PreserveIdentifierCase", "Cu",
- "Maps all identifiers to upper case. (/Cu)", "2", 0 },
- { "PreserveIdentifierCase", "Cx",
- "Preserves case in public and extern symbols. (/Cx)", "3", 0 },
-
- { "WarningLevel", "W0", "Warning Level 0 (/W0)", "0", 0 },
- { "WarningLevel", "W1", "Warning Level 1 (/W1)", "1", 0 },
- { "WarningLevel", "W2", "Warning Level 2 (/W2)", "2", 0 },
- { "WarningLevel", "W3", "Warning Level 3 (/W3)", "3", 0 },
-
- { "PackAlignmentBoundary", "", "Default", "0", 0 },
- { "PackAlignmentBoundary", "Zp1", "One Byte Boundary (/Zp1)", "1", 0 },
- { "PackAlignmentBoundary", "Zp2", "Two Byte Boundary (/Zp2)", "2", 0 },
- { "PackAlignmentBoundary", "Zp4", "Four Byte Boundary (/Zp4)", "3", 0 },
- { "PackAlignmentBoundary", "Zp8", "Eight Byte Boundary (/Zp8)", "4", 0 },
- { "PackAlignmentBoundary", "Zp16", "Sixteen Byte Boundary (/Zp16)", "5", 0 },
-
- { "CallingConvention", "", "Default", "0", 0 },
- { "CallingConvention", "Gd", "Use C-style Calling Convention (/Gd)", "1",
- 0 },
- { "CallingConvention", "Gz", "Use stdcall Calling Convention (/Gz)", "2",
- 0 },
- { "CallingConvention", "Gc", "Use Pascal Calling Convention (/Gc)", "3", 0 },
-
- { "ErrorReporting", "errorReport:prompt",
- "Prompt to send report immediately (/errorReport:prompt)", "0", 0 },
- { "ErrorReporting", "errorReport:queue",
- "Prompt to send report at the next logon (/errorReport:queue)", "1", 0 },
- { "ErrorReporting", "errorReport:send",
- "Automatically send report (/errorReport:send)", "2", 0 },
- { "ErrorReporting", "errorReport:none",
- "Do not send report (/errorReport:none)", "3", 0 },
-
- // Bool Properties
- { "NoLogo", "nologo", "", "true", 0 },
- { "GeneratePreprocessedSourceListing", "EP", "", "true", 0 },
- { "ListAllAvailableInformation", "Sa", "", "true", 0 },
- { "UseSafeExceptionHandlers", "safeseh", "", "true", 0 },
- { "AddFirstPassListing", "Sf", "", "true", 0 },
- { "EnableAssemblyGeneratedCodeListing", "Sg", "", "true", 0 },
- { "DisableSymbolTable", "Sn", "", "true", 0 },
- { "EnableFalseConditionalsInListing", "Sx", "", "true", 0 },
- { "TreatWarningsAsErrors", "WX", "", "true", 0 },
- { "MakeAllSymbolsPublic", "Zf", "", "true", 0 },
- { "GenerateDebugInformation", "Zi", "", "true", 0 },
- { "EnableMASM51Compatibility", "Zm", "", "true", 0 },
- { "PerformSyntaxCheckOnly", "Zs", "", "true", 0 },
-
- // Bool Properties With Argument
-
- // String List Properties
- { "PreprocessorDefinitions", "D", "Preprocessor Definitions", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "IncludePaths", "I", "Include Paths", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- { "BrowseFile", "FR", "Generate Browse Information File", "",
- cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
- // Skip [AdditionalDependencies] - no command line Switch.
-
- // String Properties
- // Skip [Inputs] - no command line Switch.
- { "ObjectFileName", "Fo", "Object File Name", "",
- cmVS7FlagTable::UserValue },
- { "AssembledCodeListingFile", "Fl", "Assembled Code Listing File", "",
- cmVS7FlagTable::UserValue },
- // Skip [CommandLineTemplate] - no command line Switch.
- // Skip [ExecutionDescription] - no command line Switch.
- // Skip [AdditionalOptions] - no command line Switch.
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVS14RCFlagTable.h b/Source/cmVS14RCFlagTable.h
deleted file mode 100644
index 5dc8d5ada..000000000
--- a/Source/cmVS14RCFlagTable.h
+++ /dev/null
@@ -1,7 +0,0 @@
-static cmVS7FlagTable cmVS14RCFlagTable[] = {
- // Bool Properties
- { "NullTerminateStrings", "n", "", "true", 0 },
- { "SuppressStartupBanner", "nologo", "", "true", 0 },
-
- { 0, 0, 0, 0, 0 }
-};
diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx
index 7168f266c..dd9f058b8 100644
--- a/Source/cmVSSetupHelper.cxx
+++ b/Source/cmVSSetupHelper.cxx
@@ -1,10 +1,15 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmVSSetupHelper.h"
+
+#include "cmsys/Encoding.hxx"
+#include "cmsys/FStream.hxx"
+
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#ifndef VSSetupConstants
-#define VSSetupConstants
+# define VSSetupConstants
/* clang-format off */
const IID IID_ISetupConfiguration = {
0x42843719, 0xDB4C, 0x46C2,
@@ -41,16 +46,22 @@ const CLSID CLSID_SetupConfiguration = {
/* clang-format on */
#endif
-const WCHAR* VCToolsetComponent =
- L"Microsoft.VisualStudio.Component.VC.Tools.x86.x64";
const WCHAR* Win10SDKComponent =
L"Microsoft.VisualStudio.Component.Windows10SDK";
const WCHAR* Win81SDKComponent =
L"Microsoft.VisualStudio.Component.Windows81SDK";
const WCHAR* ComponentType = L"Component";
-cmVSSetupAPIHelper::cmVSSetupAPIHelper()
- : setupConfig(NULL)
+std::string VSInstanceInfo::GetInstallLocation() const
+{
+ std::string loc = cmsys::Encoding::ToNarrow(this->VSInstallLocation);
+ cmSystemTools::ConvertToUnixSlashes(loc);
+ return loc;
+}
+
+cmVSSetupAPIHelper::cmVSSetupAPIHelper(unsigned int version)
+ : Version(version)
+ , setupConfig(NULL)
, setupConfig2(NULL)
, setupHelper(NULL)
, initializationFailure(false)
@@ -72,7 +83,15 @@ cmVSSetupAPIHelper::~cmVSSetupAPIHelper()
CoUninitialize();
}
-bool cmVSSetupAPIHelper::IsVS2017Installed()
+bool cmVSSetupAPIHelper::SetVSInstance(std::string const& vsInstallLocation)
+{
+ this->SpecifiedVSInstallLocation = vsInstallLocation;
+ cmSystemTools::ConvertToUnixSlashes(this->SpecifiedVSInstallLocation);
+ chosenInstanceInfo = VSInstanceInfo();
+ return this->EnumerateAndChooseVSInstance();
+}
+
+bool cmVSSetupAPIHelper::IsVSInstalled()
{
return this->EnumerateAndChooseVSInstance();
}
@@ -90,11 +109,11 @@ bool cmVSSetupAPIHelper::IsWin81SDKInstalled()
}
bool cmVSSetupAPIHelper::CheckInstalledComponent(
- SmartCOMPtr<ISetupPackageReference> package, bool& bVCToolset,
- bool& bWin10SDK, bool& bWin81SDK)
+ SmartCOMPtr<ISetupPackageReference> package, bool& bWin10SDK,
+ bool& bWin81SDK)
{
bool ret = false;
- bVCToolset = bWin10SDK = bWin81SDK = false;
+ bWin10SDK = bWin81SDK = false;
SmartBSTR bstrId;
if (FAILED(package->GetId(&bstrId))) {
return ret;
@@ -107,11 +126,6 @@ bool cmVSSetupAPIHelper::CheckInstalledComponent(
std::wstring id = std::wstring(bstrId);
std::wstring type = std::wstring(bstrType);
- if (id.compare(VCToolsetComponent) == 0 &&
- type.compare(ComponentType) == 0) {
- bVCToolset = true;
- ret = true;
- }
// Checks for any version of Win10 SDK. The version is appended at the end of
// the
@@ -135,7 +149,6 @@ bool cmVSSetupAPIHelper::CheckInstalledComponent(
bool cmVSSetupAPIHelper::GetVSInstanceInfo(
SmartCOMPtr<ISetupInstance2> pInstance, VSInstanceInfo& vsInstanceInfo)
{
- bool isVCToolSetInstalled = false;
if (pInstance == NULL)
return false;
@@ -174,6 +187,24 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo(
}
}
+ // Check if a compiler is installed with this instance.
+ {
+ std::string const vcRoot = vsInstanceInfo.GetInstallLocation();
+ std::string vcToolsVersionFile =
+ vcRoot + "/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt";
+ std::string vcToolsVersion;
+ cmsys::ifstream fin(vcToolsVersionFile.c_str());
+ if (!fin || !cmSystemTools::GetLineFromStream(fin, vcToolsVersion)) {
+ return false;
+ }
+ vcToolsVersion = cmTrimWhitespace(vcToolsVersion);
+ std::string const vcToolsDir = vcRoot + "/VC/Tools/MSVC/" + vcToolsVersion;
+ if (!cmSystemTools::FileIsDirectory(vcToolsDir)) {
+ return false;
+ }
+ vsInstanceInfo.VCToolsetVersion = vcToolsVersion;
+ }
+
// Reboot may have been required before the product package was registered
// (last).
if ((eRegistered & state) == eRegistered) {
@@ -199,12 +230,11 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo(
package == NULL)
continue;
- bool vcToolsetInstalled = false, win10SDKInstalled = false,
- win81SDkInstalled = false;
- bool ret = CheckInstalledComponent(package, vcToolsetInstalled,
- win10SDKInstalled, win81SDkInstalled);
+ bool win10SDKInstalled = false;
+ bool win81SDkInstalled = false;
+ bool ret =
+ CheckInstalledComponent(package, win10SDKInstalled, win81SDkInstalled);
if (ret) {
- isVCToolSetInstalled |= vcToolsetInstalled;
vsInstanceInfo.IsWin10SDKInstalled |= win10SDKInstalled;
vsInstanceInfo.IsWin81SDKInstalled |= win81SDkInstalled;
}
@@ -213,23 +243,46 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo(
SafeArrayDestroy(lpsaPackages);
}
- return isVCToolSetInstalled;
+ return true;
}
bool cmVSSetupAPIHelper::GetVSInstanceInfo(std::string& vsInstallLocation)
{
- vsInstallLocation = "";
+ vsInstallLocation.clear();
bool isInstalled = this->EnumerateAndChooseVSInstance();
if (isInstalled) {
- std::string str(chosenInstanceInfo.VSInstallLocation.begin(),
- chosenInstanceInfo.VSInstallLocation.end());
- vsInstallLocation = str;
+ vsInstallLocation = chosenInstanceInfo.GetInstallLocation();
}
return isInstalled;
}
+bool cmVSSetupAPIHelper::GetVCToolsetVersion(std::string& vsToolsetVersion)
+{
+ vsToolsetVersion.clear();
+ bool isInstalled = this->EnumerateAndChooseVSInstance();
+
+ if (isInstalled) {
+ vsToolsetVersion = chosenInstanceInfo.VCToolsetVersion;
+ }
+
+ return isInstalled && !vsToolsetVersion.empty();
+}
+
+bool cmVSSetupAPIHelper::IsEWDKEnabled()
+{
+ std::string envEnterpriseWDK, envDisableRegistryUse;
+ cmSystemTools::GetEnv("EnterpriseWDK", envEnterpriseWDK);
+ cmSystemTools::GetEnv("DisableRegistryUse", envDisableRegistryUse);
+ if (!cmSystemTools::Strucmp(envEnterpriseWDK.c_str(), "True") &&
+ !cmSystemTools::Strucmp(envDisableRegistryUse.c_str(), "True")) {
+ return true;
+ }
+
+ return false;
+}
+
bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
{
bool isVSInstanceExists = false;
@@ -237,25 +290,38 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
return true;
}
+ if (this->IsEWDKEnabled()) {
+ std::string envWindowsSdkDir81, envVSVersion, envVsInstallDir;
+
+ cmSystemTools::GetEnv("WindowsSdkDir_81", envWindowsSdkDir81);
+ cmSystemTools::GetEnv("VisualStudioVersion", envVSVersion);
+ cmSystemTools::GetEnv("VSINSTALLDIR", envVsInstallDir);
+ if (envVSVersion.empty() || envVsInstallDir.empty())
+ return false;
+
+ chosenInstanceInfo.VSInstallLocation =
+ std::wstring(envVsInstallDir.begin(), envVsInstallDir.end());
+ chosenInstanceInfo.Version =
+ std::wstring(envVSVersion.begin(), envVSVersion.end());
+ chosenInstanceInfo.VCToolsetVersion = envVSVersion;
+ chosenInstanceInfo.ullVersion = std::stoi(envVSVersion);
+ chosenInstanceInfo.IsWin10SDKInstalled = true;
+ chosenInstanceInfo.IsWin81SDKInstalled = !envWindowsSdkDir81.empty();
+ return true;
+ }
+
if (initializationFailure || setupConfig == NULL || setupConfig2 == NULL ||
setupHelper == NULL)
return false;
std::string envVSCommonToolsDir;
+ std::string envVSCommonToolsDirEnvName =
+ "VS" + std::to_string(this->Version) + "0COMNTOOLS";
- // FIXME: When we support VS versions beyond 2017, the version
- // to choose will be passed in by the caller. We need to map that
- // to a per-version name of this environment variable.
- if (cmSystemTools::GetEnv("VS150COMNTOOLS", envVSCommonToolsDir)) {
+ if (cmSystemTools::GetEnv(envVSCommonToolsDirEnvName.c_str(),
+ envVSCommonToolsDir)) {
cmSystemTools::ConvertToUnixSlashes(envVSCommonToolsDir);
}
- // FIXME: If the environment variable value changes between runs
- // of CMake within a given build tree the results are not defined.
- // Instead we should save a CMAKE_GENERATOR_INSTANCE value in the cache
- // (similar to CMAKE_GENERATOR_TOOLSET) to hold it persistently.
- // Unfortunately doing so will require refactoring elsewhere in
- // order to make sure the value is available in time to create
- // the generator.
std::vector<VSInstanceInfo> vecVSInstances;
SmartCOMPtr<IEnumSetupInstances> enumInstances = NULL;
@@ -265,6 +331,8 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
return false;
}
+ std::wstring const wantVersion = std::to_wstring(this->Version) + L'.';
+
SmartCOMPtr<ISetupInstance> instance;
while (SUCCEEDED(enumInstances->Next(1, &instance, NULL)) && instance) {
SmartCOMPtr<ISetupInstance2> instance2 = NULL;
@@ -280,18 +348,35 @@ bool cmVSSetupAPIHelper::EnumerateAndChooseVSInstance()
instance = instance2 = NULL;
if (isInstalled) {
- if (!envVSCommonToolsDir.empty()) {
- std::string currentVSLocation(instanceInfo.VSInstallLocation.begin(),
- instanceInfo.VSInstallLocation.end());
- cmSystemTools::ConvertToUnixSlashes(currentVSLocation);
- currentVSLocation += "/Common7/Tools";
+ // We are looking for a specific major version.
+ if (instanceInfo.Version.size() < wantVersion.size() ||
+ instanceInfo.Version.substr(0, wantVersion.size()) != wantVersion) {
+ continue;
+ }
+
+ if (!this->SpecifiedVSInstallLocation.empty()) {
+ // We are looking for a specific instance.
+ std::string currentVSLocation = instanceInfo.GetInstallLocation();
if (cmSystemTools::ComparePath(currentVSLocation,
- envVSCommonToolsDir)) {
+ this->SpecifiedVSInstallLocation)) {
chosenInstanceInfo = instanceInfo;
return true;
}
+ } else {
+ // We are not looking for a specific instance.
+ // If we've been given a hint then use it.
+ if (!envVSCommonToolsDir.empty()) {
+ std::string currentVSLocation =
+ cmStrCat(instanceInfo.GetInstallLocation(), "/Common7/Tools");
+ if (cmSystemTools::ComparePath(currentVSLocation,
+ envVSCommonToolsDir)) {
+ chosenInstanceInfo = instanceInfo;
+ return true;
+ }
+ }
+ // Otherwise, add this to the list of candidates.
+ vecVSInstances.push_back(instanceInfo);
}
- vecVSInstances.push_back(instanceInfo);
}
}
diff --git a/Source/cmVSSetupHelper.h b/Source/cmVSSetupHelper.h
index d2f514c63..0980cef53 100644
--- a/Source/cmVSSetupHelper.h
+++ b/Source/cmVSSetupHelper.h
@@ -4,17 +4,17 @@
#define cmVSSetupHelper_h
#ifndef NOMINMAX
-#define NOMINMAX // Undefine min and max defined by windows.h
+# define NOMINMAX // Undefine min and max defined by windows.h
#endif
// Published by Visual Studio Setup team
-#include "cmvssetup/Setup.Configuration.h"
-
#include <string>
#include <vector>
#include <windows.h>
+#include "cmvssetup/Setup.Configuration.h"
+
template <class T>
class SmartCOMPtr
{
@@ -74,29 +74,12 @@ class SmartBSTR
{
public:
SmartBSTR() { str = NULL; }
- SmartBSTR(const SmartBSTR& src)
- {
- if (src.str != NULL) {
- str = ::SysAllocStringByteLen((char*)str, ::SysStringByteLen(str));
- } else {
- str = ::SysAllocStringByteLen(NULL, 0);
- }
- }
- SmartBSTR& operator=(const SmartBSTR& src)
- {
- if (str != src.str) {
- ::SysFreeString(str);
- if (src.str != NULL) {
- str = ::SysAllocStringByteLen((char*)str, ::SysStringByteLen(str));
- } else {
- str = ::SysAllocStringByteLen(NULL, 0);
- }
- }
- return *this;
- }
+ SmartBSTR(const SmartBSTR& src) = delete;
+ SmartBSTR& operator=(const SmartBSTR& src) = delete;
operator BSTR() const { return str; }
BSTR* operator&() throw() { return &str; }
~SmartBSTR() throw() { ::SysFreeString(str); }
+
private:
BSTR str;
};
@@ -106,26 +89,25 @@ struct VSInstanceInfo
std::wstring InstanceId;
std::wstring VSInstallLocation;
std::wstring Version;
- ULONGLONG ullVersion;
- bool IsWin10SDKInstalled;
- bool IsWin81SDKInstalled;
+ std::string VCToolsetVersion;
+ ULONGLONG ullVersion = 0;
+ bool IsWin10SDKInstalled = false;
+ bool IsWin81SDKInstalled = false;
- VSInstanceInfo()
- {
- InstanceId = VSInstallLocation = Version = L"";
- ullVersion = 0;
- IsWin10SDKInstalled = IsWin81SDKInstalled = false;
- }
+ std::string GetInstallLocation() const;
};
class cmVSSetupAPIHelper
{
public:
- cmVSSetupAPIHelper();
+ cmVSSetupAPIHelper(unsigned int version);
~cmVSSetupAPIHelper();
- bool IsVS2017Installed();
+ bool SetVSInstance(std::string const& vsInstallLocation);
+
+ bool IsVSInstalled();
bool GetVSInstanceInfo(std::string& vsInstallLocation);
+ bool GetVCToolsetVersion(std::string& vsToolsetVersion);
bool IsWin10SDKInstalled();
bool IsWin81SDKInstalled();
@@ -134,11 +116,12 @@ private:
bool GetVSInstanceInfo(SmartCOMPtr<ISetupInstance2> instance2,
VSInstanceInfo& vsInstanceInfo);
bool CheckInstalledComponent(SmartCOMPtr<ISetupPackageReference> package,
- bool& bVCToolset, bool& bWin10SDK,
- bool& bWin81SDK);
+ bool& bWin10SDK, bool& bWin81SDK);
int ChooseVSInstance(const std::vector<VSInstanceInfo>& vecVSInstances);
bool EnumerateAndChooseVSInstance();
+ unsigned int Version;
+
// COM ptrs to query about VS instances
SmartCOMPtr<ISetupConfiguration> setupConfig;
SmartCOMPtr<ISetupConfiguration2> setupConfig2;
@@ -149,6 +132,9 @@ private:
HRESULT comInitialized;
// current best instance of VS selected
VSInstanceInfo chosenInstanceInfo;
+ bool IsEWDKEnabled();
+
+ std::string SpecifiedVSInstallLocation;
};
#endif
diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx
index 06ca53c0a..6b93c636a 100644
--- a/Source/cmVariableRequiresCommand.cxx
+++ b/Source/cmVariableRequiresCommand.cxx
@@ -2,32 +2,32 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmVariableRequiresCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
// cmLibraryCommand
-bool cmVariableRequiresCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmVariableRequiresCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
std::string const& testVariable = args[0];
- if (!this->Makefile->IsOn(testVariable)) {
+ if (!status.GetMakefile().IsOn(testVariable)) {
return true;
}
std::string const& resultVariable = args[1];
bool requirementsMet = true;
std::string notSet;
bool hasAdvanced = false;
- cmState* state = this->Makefile->GetState();
+ cmState* state = status.GetMakefile().GetState();
for (unsigned int i = 2; i < args.size(); ++i) {
- if (!this->Makefile->IsOn(args[i])) {
+ if (!status.GetMakefile().IsOn(args[i])) {
requirementsMet = false;
notSet += args[i];
notSet += "\n";
@@ -37,27 +37,26 @@ bool cmVariableRequiresCommand::InitialPass(
}
}
}
- const char* reqVar = this->Makefile->GetDefinition(resultVariable);
+ const char* reqVar = status.GetMakefile().GetDefinition(resultVariable);
// if reqVar is unset, then set it to requirementsMet
// if reqVar is set to true, but requirementsMet is false , then
// set reqVar to false.
- if (!reqVar || (!requirementsMet && this->Makefile->IsOn(reqVar))) {
- this->Makefile->AddDefinition(resultVariable, requirementsMet);
+ if (!reqVar || (!requirementsMet && status.GetMakefile().IsOn(reqVar))) {
+ status.GetMakefile().AddDefinitionBool(resultVariable, requirementsMet);
}
if (!requirementsMet) {
- std::string message = "Variable assertion failed:\n";
- message +=
- testVariable + " Requires that the following unset variables are set:\n";
- message += notSet;
- message += "\nPlease set them, or set ";
- message += testVariable + " to false, and re-configure.\n";
+ std::string message =
+ cmStrCat("Variable assertion failed:\n", testVariable,
+ " Requires that the following unset variables are set:\n",
+ notSet, "\nPlease set them, or set ", testVariable,
+ " to false, and re-configure.\n");
if (hasAdvanced) {
message +=
"One or more of the required variables is advanced."
" To set the variable, you must turn on advanced mode in cmake.";
}
- cmSystemTools::Error(message.c_str());
+ cmSystemTools::Error(message);
}
return true;
diff --git a/Source/cmVariableRequiresCommand.h b/Source/cmVariableRequiresCommand.h
index 9808d5f0c..fb0520ed7 100644
--- a/Source/cmVariableRequiresCommand.h
+++ b/Source/cmVariableRequiresCommand.h
@@ -3,21 +3,14 @@
#ifndef cmVariableRequiresCommand_h
#define cmVariableRequiresCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmVariableRequiresCommand : public cmCommand
-{
-public:
- cmCommand* Clone() CM_OVERRIDE { return new cmVariableRequiresCommand; }
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmVariableRequiresCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index 419e1a411..4995da972 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -2,11 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmVariableWatch.h"
-#include "cmAlgorithms.h"
-
-#include "cm_auto_ptr.hxx"
-#include <algorithm>
+#include <memory>
#include <utility>
+#include <vector>
static const char* const cmVariableWatchAccessStrings[] = {
"READ_ACCESS", "UNKNOWN_READ_ACCESS", "UNKNOWN_DEFINED_ACCESS",
@@ -21,41 +19,27 @@ const char* cmVariableWatch::GetAccessAsString(int access_type)
return cmVariableWatchAccessStrings[access_type];
}
-cmVariableWatch::cmVariableWatch()
-{
-}
+cmVariableWatch::cmVariableWatch() = default;
-template <typename C>
-void deleteAllSecond(typename C::value_type it)
-{
- cmDeleteAll(it.second);
-}
-
-cmVariableWatch::~cmVariableWatch()
-{
- std::for_each(this->WatchMap.begin(), this->WatchMap.end(),
- deleteAllSecond<cmVariableWatch::StringToVectorOfPairs>);
-}
+cmVariableWatch::~cmVariableWatch() = default;
bool cmVariableWatch::AddWatch(const std::string& variable, WatchMethod method,
void* client_data /*=0*/,
DeleteData delete_data /*=0*/)
{
- CM_AUTO_PTR<cmVariableWatch::Pair> p(new cmVariableWatch::Pair);
+ auto p = std::make_shared<cmVariableWatch::Pair>();
p->Method = method;
p->ClientData = client_data;
p->DeleteDataCall = delete_data;
- cmVariableWatch::VectorOfPairs* vp = &this->WatchMap[variable];
- cmVariableWatch::VectorOfPairs::size_type cc;
- for (cc = 0; cc < vp->size(); cc++) {
- cmVariableWatch::Pair* pair = (*vp)[cc];
+ cmVariableWatch::VectorOfPairs& vp = this->WatchMap[variable];
+ for (auto& pair : vp) {
if (pair->Method == method && client_data &&
client_data == pair->ClientData) {
// Callback already exists
return false;
}
}
- vp->push_back(p.release());
+ vp.push_back(std::move(p));
return true;
}
@@ -72,7 +56,6 @@ void cmVariableWatch::RemoveWatch(const std::string& variable,
// If client_data is NULL, we want to disconnect all watches against
// the given method; otherwise match ClientData as well.
(!client_data || (client_data == (*it)->ClientData))) {
- delete *it;
vp->erase(it);
return;
}
@@ -83,13 +66,19 @@ bool cmVariableWatch::VariableAccessed(const std::string& variable,
int access_type, const char* newValue,
const cmMakefile* mf) const
{
- cmVariableWatch::StringToVectorOfPairs::const_iterator mit =
- this->WatchMap.find(variable);
+ auto mit = this->WatchMap.find(variable);
if (mit != this->WatchMap.end()) {
- const cmVariableWatch::VectorOfPairs* vp = &mit->second;
- cmVariableWatch::VectorOfPairs::const_iterator it;
- for (it = vp->begin(); it != vp->end(); it++) {
- (*it)->Method(variable, access_type, (*it)->ClientData, newValue, mf);
+ // The strategy here is to copy the list of callbacks, and ignore
+ // new callbacks that existing ones may add.
+ std::vector<std::weak_ptr<Pair>> vp(mit->second.begin(),
+ mit->second.end());
+ for (auto& weak_it : vp) {
+ // In the case where a callback was removed, the weak_ptr will not be
+ // lockable, and so this ensures we don't attempt to call into freed
+ // memory
+ if (auto it = weak_it.lock()) {
+ it->Method(variable, access_type, it->ClientData, newValue, mf);
+ }
}
return true;
}
diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h
index a575afe9d..e4b3b7c47 100644
--- a/Source/cmVariableWatch.h
+++ b/Source/cmVariableWatch.h
@@ -6,6 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
+#include <memory>
#include <string>
#include <vector>
@@ -19,10 +20,9 @@ class cmMakefile;
class cmVariableWatch
{
public:
- typedef void (*WatchMethod)(const std::string& variable, int access_type,
- void* client_data, const char* newValue,
- const cmMakefile* mf);
- typedef void (*DeleteData)(void* client_data);
+ using WatchMethod = void (*)(const std::string&, int, void*, const char*,
+ const cmMakefile*);
+ using DeleteData = void (*)(void*);
cmVariableWatch();
~cmVariableWatch();
@@ -31,10 +31,9 @@ public:
* Add watch to the variable
*/
bool AddWatch(const std::string& variable, WatchMethod method,
- void* client_data = CM_NULLPTR,
- DeleteData delete_data = CM_NULLPTR);
+ void* client_data = nullptr, DeleteData delete_data = nullptr);
void RemoveWatch(const std::string& variable, WatchMethod method,
- void* client_data = CM_NULLPTR);
+ void* client_data = nullptr);
/**
* This method is called when variable is accessed
@@ -63,25 +62,22 @@ public:
protected:
struct Pair
{
- WatchMethod Method;
- void* ClientData;
- DeleteData DeleteDataCall;
- Pair()
- : Method(CM_NULLPTR)
- , ClientData(CM_NULLPTR)
- , DeleteDataCall(CM_NULLPTR)
- {
- }
+ WatchMethod Method = nullptr;
+ void* ClientData = nullptr;
+ DeleteData DeleteDataCall = nullptr;
~Pair()
{
if (this->DeleteDataCall && this->ClientData) {
this->DeleteDataCall(this->ClientData);
}
}
+ Pair() = default;
+ Pair(const Pair&) = delete;
+ Pair& operator=(const Pair&) = delete;
};
- typedef std::vector<Pair*> VectorOfPairs;
- typedef std::map<std::string, VectorOfPairs> StringToVectorOfPairs;
+ using VectorOfPairs = std::vector<std::shared_ptr<Pair>>;
+ using StringToVectorOfPairs = std::map<std::string, VectorOfPairs>;
StringToVectorOfPairs WatchMap;
};
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index 281850ecc..f2c8f3cdb 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -2,11 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmVariableWatchCommand.h"
-#include <sstream>
+#include <memory>
+#include <utility>
#include "cmExecutionStatus.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmVariableWatch.h"
#include "cmake.h"
@@ -43,36 +46,32 @@ static void cmVariableWatchCommandVariableAccessed(const std::string& variable,
std::string stack = makefile->GetProperty("LISTFILE_STACK");
if (!data->Command.empty()) {
newLFF.Arguments.clear();
- newLFF.Arguments.push_back(
- cmListFileArgument(variable, cmListFileArgument::Quoted, 9999));
- newLFF.Arguments.push_back(
- cmListFileArgument(accessString, cmListFileArgument::Quoted, 9999));
- newLFF.Arguments.push_back(cmListFileArgument(
- newValue ? newValue : "", cmListFileArgument::Quoted, 9999));
- newLFF.Arguments.push_back(
- cmListFileArgument(currentListFile, cmListFileArgument::Quoted, 9999));
- newLFF.Arguments.push_back(
- cmListFileArgument(stack, cmListFileArgument::Quoted, 9999));
+ newLFF.Arguments.emplace_back(variable, cmListFileArgument::Quoted, 9999);
+ newLFF.Arguments.emplace_back(accessString, cmListFileArgument::Quoted,
+ 9999);
+ newLFF.Arguments.emplace_back(newValue ? newValue : "",
+ cmListFileArgument::Quoted, 9999);
+ newLFF.Arguments.emplace_back(currentListFile, cmListFileArgument::Quoted,
+ 9999);
+ newLFF.Arguments.emplace_back(stack, cmListFileArgument::Quoted, 9999);
newLFF.Name = data->Command;
newLFF.Line = 9999;
- cmExecutionStatus status;
+ cmExecutionStatus status(*makefile);
if (!makefile->ExecuteCommand(newLFF, status)) {
- std::ostringstream error;
- error << "Error in cmake code at\nUnknown:0:\n"
- << "A command failed during the invocation of callback \""
- << data->Command << "\".";
- cmSystemTools::Error(error.str().c_str());
+ cmSystemTools::Error(
+ cmStrCat("Error in cmake code at\nUnknown:0:\nA command failed "
+ "during the invocation of callback \"",
+ data->Command, "\"."));
data->InCallback = false;
return;
}
processed = true;
}
if (!processed) {
- std::ostringstream msg;
- msg << "Variable \"" << variable << "\" was accessed using "
- << accessString << " with value \"" << (newValue ? newValue : "")
- << "\".";
- makefile->IssueMessage(cmake::LOG, msg.str());
+ makefile->IssueMessage(
+ MessageType::LOG,
+ cmStrCat("Variable \"", variable, "\" was accessed using ", accessString,
+ " with value \"", (newValue ? newValue : ""), "\"."));
}
data->InCallback = false;
@@ -85,25 +84,46 @@ static void deleteVariableWatchCallbackData(void* client_data)
delete data;
}
-cmVariableWatchCommand::cmVariableWatchCommand()
+/** This command does not really have a final pass but it needs to
+ stay alive since it owns variable watch callback information. */
+class FinalAction
{
-}
-
-cmVariableWatchCommand::~cmVariableWatchCommand()
-{
- std::set<std::string>::const_iterator it;
- for (it = this->WatchedVariables.begin(); it != this->WatchedVariables.end();
- ++it) {
- this->Makefile->GetCMakeInstance()->GetVariableWatch()->RemoveWatch(
- *it, cmVariableWatchCommandVariableAccessed);
+public:
+ /* NOLINTNEXTLINE(performance-unnecessary-value-param) */
+ FinalAction(cmMakefile* makefile, std::string variable)
+ : Action(std::make_shared<Impl>(makefile, std::move(variable)))
+ {
}
-}
-bool cmVariableWatchCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+ void operator()(cmMakefile&) const {}
+
+private:
+ struct Impl
+ {
+ Impl(cmMakefile* makefile, std::string variable)
+ : Makefile(makefile)
+ , Variable(std::move(variable))
+ {
+ }
+
+ ~Impl()
+ {
+ this->Makefile->GetCMakeInstance()->GetVariableWatch()->RemoveWatch(
+ this->Variable, cmVariableWatchCommandVariableAccessed);
+ }
+
+ cmMakefile* Makefile;
+ std::string Variable;
+ };
+
+ std::shared_ptr<Impl const> Action;
+};
+
+bool cmVariableWatchCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("must be called with at least one argument.");
+ status.SetError("must be called with at least one argument.");
return false;
}
std::string const& variable = args[0];
@@ -112,9 +132,7 @@ bool cmVariableWatchCommand::InitialPass(std::vector<std::string> const& args,
command = args[1];
}
if (variable == "CMAKE_CURRENT_LIST_FILE") {
- std::ostringstream ostr;
- ostr << "cannot be set on the variable: " << variable;
- this->SetError(ostr.str());
+ status.SetError(cmStrCat("cannot be set on the variable: ", variable));
return false;
}
@@ -123,13 +141,14 @@ bool cmVariableWatchCommand::InitialPass(std::vector<std::string> const& args,
data->InCallback = false;
data->Command = command;
- this->WatchedVariables.insert(variable);
- if (!this->Makefile->GetCMakeInstance()->GetVariableWatch()->AddWatch(
+ if (!status.GetMakefile().GetCMakeInstance()->GetVariableWatch()->AddWatch(
variable, cmVariableWatchCommandVariableAccessed, data,
deleteVariableWatchCallbackData)) {
deleteVariableWatchCallbackData(data);
return false;
}
+ status.GetMakefile().AddFinalAction(
+ FinalAction(&status.GetMakefile(), variable));
return true;
}
diff --git a/Source/cmVariableWatchCommand.h b/Source/cmVariableWatchCommand.h
index 9f0439175..3f9f2443a 100644
--- a/Source/cmVariableWatchCommand.h
+++ b/Source/cmVariableWatchCommand.h
@@ -3,47 +3,18 @@
#ifndef cmVariableWatchCommand_h
#define cmVariableWatchCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include <set>
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmVariableWatchCommand
+/**
* \brief Watch when the variable changes and invoke command
*
*/
-class cmVariableWatchCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmVariableWatchCommand; }
-
- //! Default constructor
- cmVariableWatchCommand();
-
- //! Destructor.
- ~cmVariableWatchCommand() CM_OVERRIDE;
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-
- /** This command does not really have a final pass but it needs to
- stay alive since it owns variable watch callback information. */
- bool HasFinalPass() const CM_OVERRIDE { return true; }
-
-protected:
- std::set<std::string> WatchedVariables;
-};
+bool cmVariableWatchCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmVersionMacros.h b/Source/cmVersionMacros.h
index 1b617bd2b..e8ac4f862 100644
--- a/Source/cmVersionMacros.h
+++ b/Source/cmVersionMacros.h
@@ -7,7 +7,7 @@
#define CMake_VERSION_PATCH_IS_RELEASE(patch) ((patch) < 20000000)
#if CMake_VERSION_PATCH_IS_RELEASE(CMake_VERSION_PATCH)
-#define CMake_VERSION_IS_RELEASE 1
+# define CMake_VERSION_IS_RELEASE 1
#endif
#endif
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index dee153f6b..58574776e 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2,20 +2,29 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmVisualStudio10TargetGenerator.h"
+#include <iterator>
+#include <set>
+
+#include <cm/memory>
+
+#include "windows.h"
+
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
+#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
#include "cmGeneratedFileStream.h"
+#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalVisualStudio10Generator.h"
-#include "cmLocalVisualStudio7Generator.h"
+#include "cmLinkLineDeviceComputer.h"
+#include "cmLocalVisualStudio10Generator.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmSystemTools.h"
#include "cmVisualStudioGeneratorOptions.h"
-#include "windows.h"
-#include "cm_auto_ptr.hxx"
+static void ConvertToWindowsSlash(std::string& s);
static std::string cmVS10EscapeXML(std::string arg)
{
@@ -25,14 +34,157 @@ static std::string cmVS10EscapeXML(std::string arg)
return arg;
}
+static std::string cmVS10EscapeAttr(std::string arg)
+{
+ cmSystemTools::ReplaceString(arg, "&", "&amp;");
+ cmSystemTools::ReplaceString(arg, "<", "&lt;");
+ cmSystemTools::ReplaceString(arg, ">", "&gt;");
+ cmSystemTools::ReplaceString(arg, "\"", "&quot;");
+ cmSystemTools::ReplaceString(arg, "\n", "&#10;");
+ return arg;
+}
+
+struct cmVisualStudio10TargetGenerator::Elem
+{
+ std::ostream& S;
+ const int Indent;
+ bool HasElements = false;
+ bool HasContent = false;
+ std::string Tag;
+
+ Elem(std::ostream& s, const char* tag)
+ : S(s)
+ , Indent(0)
+ , Tag(tag)
+ {
+ this->StartElement();
+ }
+ Elem(const Elem&) = delete;
+ Elem(Elem& par, const char* tag)
+ : S(par.S)
+ , Indent(par.Indent + 1)
+ , Tag(tag)
+ {
+ par.SetHasElements();
+ this->StartElement();
+ }
+ void SetHasElements()
+ {
+ if (!HasElements) {
+ this->S << ">\n";
+ HasElements = true;
+ }
+ }
+ std::ostream& WriteString(const char* line);
+ void StartElement() { this->WriteString("<") << this->Tag; }
+ void Element(const char* tag, const std::string& val)
+ {
+ Elem(*this, tag).Content(val);
+ }
+ Elem& Attribute(const char* an, const std::string& av)
+ {
+ this->S << " " << an << "=\"" << cmVS10EscapeAttr(av) << "\"";
+ return *this;
+ }
+ void Content(const std::string& val)
+ {
+ if (!this->HasContent) {
+ this->S << ">";
+ this->HasContent = true;
+ }
+ this->S << cmVS10EscapeXML(val);
+ }
+ ~Elem()
+ {
+ // Do not emit element which has not been started
+ if (Tag.empty()) {
+ return;
+ }
+
+ if (HasElements) {
+ this->WriteString("</") << this->Tag << ">";
+ if (this->Indent > 0) {
+ this->S << '\n';
+ } else {
+ // special case: don't print EOL at EOF
+ }
+ } else if (HasContent) {
+ this->S << "</" << this->Tag << ">\n";
+ } else {
+ this->S << " />\n";
+ }
+ }
+
+ void WritePlatformConfigTag(const char* tag, const std::string& cond,
+ const std::string& content);
+};
+
+class cmVS10GeneratorOptions : public cmVisualStudioGeneratorOptions
+{
+public:
+ using Elem = cmVisualStudio10TargetGenerator::Elem;
+ cmVS10GeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
+ cmVS7FlagTable const* table,
+ cmVisualStudio10TargetGenerator* g = nullptr)
+ : cmVisualStudioGeneratorOptions(lg, tool, table)
+ , TargetGenerator(g)
+ {
+ }
+
+ void OutputFlag(std::ostream& /*fout*/, int /*indent*/, const char* tag,
+ const std::string& content) override
+ {
+ if (!this->GetConfiguration().empty()) {
+ // if there are configuration specific flags, then
+ // use the configuration specific tag for PreprocessorDefinitions
+ const std::string cond =
+ this->TargetGenerator->CalcCondition(this->GetConfiguration());
+ this->Parent->WritePlatformConfigTag(tag, cond, content);
+ } else {
+ this->Parent->Element(tag, content);
+ }
+ }
+
+private:
+ cmVisualStudio10TargetGenerator* const TargetGenerator;
+ Elem* Parent = nullptr;
+ friend cmVisualStudio10TargetGenerator::OptionsHelper;
+};
+
+struct cmVisualStudio10TargetGenerator::OptionsHelper
+{
+ cmVS10GeneratorOptions& O;
+ OptionsHelper(cmVS10GeneratorOptions& o, Elem& e)
+ : O(o)
+ {
+ O.Parent = &e;
+ }
+ ~OptionsHelper() { O.Parent = nullptr; }
+
+ void OutputPreprocessorDefinitions(const std::string& lang)
+ {
+ O.OutputPreprocessorDefinitions(O.Parent->S, O.Parent->Indent + 1, lang);
+ }
+ void OutputAdditionalIncludeDirectories(const std::string& lang)
+ {
+ O.OutputAdditionalIncludeDirectories(O.Parent->S, O.Parent->Indent + 1,
+ lang);
+ }
+ void OutputFlagMap() { O.OutputFlagMap(O.Parent->S, O.Parent->Indent + 1); }
+ void PrependInheritedString(std::string const& key)
+ {
+ O.PrependInheritedString(key);
+ }
+};
+
static std::string cmVS10EscapeComment(std::string comment)
{
// MSBuild takes the CDATA of a <Message></Message> element and just
// does "echo $CDATA" with no escapes. We must encode the string.
// http://technet.microsoft.com/en-us/library/cc772462%28WS.10%29.aspx
std::string echoable;
- for (std::string::iterator c = comment.begin(); c != comment.end(); ++c) {
- switch (*c) {
+ for (char c : comment) {
+ switch (c) {
case '\r':
break;
case '\n':
@@ -45,8 +197,9 @@ static std::string cmVS10EscapeComment(std::string comment)
case '>': /* no break */
case '^':
echoable += '^'; /* no break */
+ CM_FALLTHROUGH;
default:
- echoable += *c;
+ echoable += c;
break;
}
}
@@ -63,7 +216,7 @@ static std::string computeProjectFileExtension(cmGeneratorTarget const* t)
{
std::string res;
res = ".vcxproj";
- if (cmGlobalVisualStudioGenerator::TargetIsCSharpOnly(t)) {
+ if (t->IsCSharpOnly()) {
res = ".csproj";
}
return res;
@@ -71,16 +224,16 @@ static std::string computeProjectFileExtension(cmGeneratorTarget const* t)
cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
cmGeneratorTarget* target, cmGlobalVisualStudio10Generator* gg)
+ : GeneratorTarget(target)
+ , Makefile(target->Target->GetMakefile())
+ , Platform(gg->GetPlatformName())
+ , Name(target->GetName())
+ , GUID(gg->GetGUID(this->Name))
+ , GlobalGenerator(gg)
+ , LocalGenerator(
+ (cmLocalVisualStudio10Generator*)target->GetLocalGenerator())
{
- this->GlobalGenerator = gg;
- this->GeneratorTarget = target;
- this->Makefile = target->Target->GetMakefile();
this->Makefile->GetConfigurations(this->Configurations);
- this->LocalGenerator =
- (cmLocalVisualStudio7Generator*)this->GeneratorTarget->GetLocalGenerator();
- this->Name = this->GeneratorTarget->GetName();
- this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str());
- this->Platform = gg->GetPlatformName();
this->NsightTegra = gg->IsNsightTegra();
for (int i = 0; i < 4; ++i) {
this->NsightTegraVersion[i] = 0;
@@ -91,84 +244,50 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
this->MSTools = !this->NsightTegra;
this->Managed = false;
this->TargetCompileAsWinRT = false;
- this->BuildFileStream = 0;
this->IsMissingFiles = false;
this->DefaultArtifactDir =
- this->LocalGenerator->GetCurrentBinaryDirectory() + std::string("/") +
+ this->LocalGenerator->GetCurrentBinaryDirectory() + "/" +
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- this->InSourceBuild =
- (strcmp(this->Makefile->GetCurrentSourceDirectory(),
- this->Makefile->GetCurrentBinaryDirectory()) == 0);
+ this->InSourceBuild = (this->Makefile->GetCurrentSourceDirectory() ==
+ this->Makefile->GetCurrentBinaryDirectory());
}
cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
{
- for (OptionsMap::iterator i = this->ClOptions.begin();
- i != this->ClOptions.end(); ++i) {
- delete i->second;
- }
- for (OptionsMap::iterator i = this->LinkOptions.begin();
- i != this->LinkOptions.end(); ++i) {
- delete i->second;
- }
- for (OptionsMap::iterator i = this->CudaOptions.begin();
- i != this->CudaOptions.end(); ++i) {
- delete i->second;
- }
- for (OptionsMap::iterator i = this->CudaLinkOptions.begin();
- i != this->CudaLinkOptions.end(); ++i) {
- delete i->second;
- }
- if (!this->BuildFileStream) {
- return;
- }
- if (this->BuildFileStream->Close()) {
- this->GlobalGenerator->FileReplacedDuringGenerate(this->PathToProjectFile);
- }
- delete this->BuildFileStream;
}
-void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
- const char* tag, const std::string& config, int indentLevel,
- const char* attribute, const char* end, std::ostream* stream)
-
+std::string cmVisualStudio10TargetGenerator::CalcCondition(
+ const std::string& config) const
{
- if (!stream) {
- stream = this->BuildFileStream;
- }
- stream->fill(' ');
- stream->width(indentLevel * 2);
- (*stream) << ""; // applies indentation
- (*stream) << "<" << tag << " Condition=\"";
- (*stream) << "'$(Configuration)|$(Platform)'=='";
- (*stream) << config << "|" << this->Platform;
- (*stream) << "'";
+ std::ostringstream oss;
+ oss << "'$(Configuration)|$(Platform)'=='";
+ oss << config << "|" << this->Platform;
+ oss << "'";
// handle special case for 32 bit C# targets
- if (csproj == this->ProjectType && this->Platform == "Win32") {
- (*stream) << " Or ";
- (*stream) << "'$(Configuration)|$(Platform)'=='";
- (*stream) << config << "|x86";
- (*stream) << "'";
- }
- (*stream) << "\"";
- if (attribute) {
- (*stream) << attribute;
- }
- // close the tag
- (*stream) << ">";
- if (end) {
- (*stream) << end;
+ if (this->ProjectType == csproj && this->Platform == "Win32") {
+ oss << " Or ";
+ oss << "'$(Configuration)|$(Platform)'=='";
+ oss << config << "|x86";
+ oss << "'";
}
+ return oss.str();
}
-void cmVisualStudio10TargetGenerator::WriteString(const char* line,
- int indentLevel)
+void cmVisualStudio10TargetGenerator::Elem::WritePlatformConfigTag(
+ const char* tag, const std::string& cond, const std::string& content)
{
- this->BuildFileStream->fill(' ');
- this->BuildFileStream->width(indentLevel * 2);
+ Elem(*this, tag).Attribute("Condition", cond).Content(content);
+}
+
+std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString(
+ const char* line)
+{
+ this->S.fill(' ');
+ this->S.width(this->Indent * 2);
// write an empty string to get the fill level indent to print
- (*this->BuildFileStream) << "";
- (*this->BuildFileStream) << line;
+ this->S << "";
+ this->S << line;
+ return this->S;
}
#define VS10_CXX_DEFAULT_PROPS "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"
@@ -185,6 +304,11 @@ void cmVisualStudio10TargetGenerator::WriteString(const char* line,
"$(UserRootDir)\\Microsoft.CSharp.$(Platform).user.props"
#define VS10_CSharp_TARGETS "$(MSBuildToolsPath)\\Microsoft.CSharp.targets"
+#define VS10_CSharp_NETCF_TARGETS \
+ "$(MSBuildExtensionsPath)\\Microsoft\\$(TargetFrameworkIdentifier)\\" \
+ "$(TargetFrameworkTargetsVersion)\\Microsoft.$(TargetFrameworkIdentifier)" \
+ ".CSharp.targets"
+
void cmVisualStudio10TargetGenerator::Generate()
{
// do not generate external ms projects
@@ -192,20 +316,29 @@ void cmVisualStudio10TargetGenerator::Generate()
this->GeneratorTarget->GetProperty("EXTERNAL_MSPROJECT")) {
return;
}
- this->ProjectFileExtension =
+ const std::string ProjectFileExtension =
computeProjectFileExtension(this->GeneratorTarget);
- if (this->ProjectFileExtension == ".vcxproj") {
+ if (ProjectFileExtension == ".vcxproj") {
this->ProjectType = vcxproj;
this->Managed = false;
- } else if (this->ProjectFileExtension == ".csproj") {
+ } else if (ProjectFileExtension == ".csproj") {
+ if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
+ std::string message = "The C# target \"" +
+ this->GeneratorTarget->GetName() +
+ "\" is of type STATIC_LIBRARY. This is discouraged (and may be "
+ "disabled in future). Make it a SHARED library instead.";
+ this->Makefile->IssueMessage(MessageType::DEPRECATION_WARNING, message);
+ }
this->ProjectType = csproj;
this->Managed = true;
}
// Tell the global generator the name of the project file
this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME",
this->Name.c_str());
- this->GeneratorTarget->Target->SetProperty(
- "GENERATOR_FILE_NAME_EXT", this->ProjectFileExtension.c_str());
+ this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME_EXT",
+ ProjectFileExtension.c_str());
+ this->DotNetHintReferences.clear();
+ this->AdditionalUsingDirectories.clear();
if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
if (!this->ComputeClOptions()) {
return;
@@ -232,483 +365,594 @@ void cmVisualStudio10TargetGenerator::Generate()
return;
}
}
- std::string path = this->LocalGenerator->GetCurrentBinaryDirectory();
- path += "/";
- path += this->Name;
- path += this->ProjectFileExtension;
- this->BuildFileStream = new cmGeneratedFileStream(path.c_str());
- this->PathToProjectFile = path;
- this->BuildFileStream->SetCopyIfDifferent(true);
+ std::string path =
+ cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
+ this->Name, ProjectFileExtension);
+ cmGeneratedFileStream BuildFileStream(path);
+ const std::string PathToProjectFile = path;
+ BuildFileStream.SetCopyIfDifferent(true);
// Write the encoding header into the file
char magic[] = { char(0xEF), char(0xBB), char(0xBF) };
- this->BuildFileStream->write(magic, 3);
-
- // get the tools version to use
- const std::string toolsVer(this->GlobalGenerator->GetToolsVersion());
- std::string project_defaults = "<?xml version=\"1.0\" encoding=\"" +
- this->GlobalGenerator->Encoding() + "\"?>\n";
- project_defaults.append("<Project DefaultTargets=\"Build\" ToolsVersion=\"");
- project_defaults.append(toolsVer + "\" ");
- project_defaults.append(
- "xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n");
- this->WriteString(project_defaults.c_str(), 0);
-
- if (this->NsightTegra) {
- this->WriteString("<PropertyGroup Label=\"NsightTegraProject\">\n", 1);
- const int nsightTegraMajorVersion = this->NsightTegraVersion[0];
- const int nsightTegraMinorVersion = this->NsightTegraVersion[1];
- if (nsightTegraMajorVersion >= 2) {
- this->WriteString("<NsightTegraProjectRevisionNumber>", 2);
- if (nsightTegraMajorVersion > 3 ||
- (nsightTegraMajorVersion == 3 && nsightTegraMinorVersion >= 1)) {
- (*this->BuildFileStream) << "11";
+ BuildFileStream.write(magic, 3);
+ BuildFileStream << "<?xml version=\"1.0\" encoding=\""
+ << this->GlobalGenerator->Encoding() << "\"?>"
+ << "\n";
+ {
+ Elem e0(BuildFileStream, "Project");
+ e0.Attribute("DefaultTargets", "Build");
+ const char* toolsVersion = this->GlobalGenerator->GetToolsVersion();
+ if (this->GlobalGenerator->GetVersion() ==
+ cmGlobalVisualStudioGenerator::VS12 &&
+ this->GlobalGenerator->TargetsWindowsCE()) {
+ toolsVersion = "4.0";
+ }
+ e0.Attribute("ToolsVersion", toolsVersion);
+ e0.Attribute("xmlns",
+ "http://schemas.microsoft.com/developer/msbuild/2003");
+
+ if (this->NsightTegra) {
+ Elem e1(e0, "PropertyGroup");
+ e1.Attribute("Label", "NsightTegraProject");
+ const unsigned int nsightTegraMajorVersion = this->NsightTegraVersion[0];
+ const unsigned int nsightTegraMinorVersion = this->NsightTegraVersion[1];
+ if (nsightTegraMajorVersion >= 2) {
+ if (nsightTegraMajorVersion > 3 ||
+ (nsightTegraMajorVersion == 3 && nsightTegraMinorVersion >= 1)) {
+ e1.Element("NsightTegraProjectRevisionNumber", "11");
+ } else {
+ // Nsight Tegra 2.0 uses project revision 9.
+ e1.Element("NsightTegraProjectRevisionNumber", "9");
+ }
+ // Tell newer versions to upgrade silently when loading.
+ e1.Element("NsightTegraUpgradeOnceWithoutPrompt", "true");
} else {
- // Nsight Tegra 2.0 uses project revision 9.
- (*this->BuildFileStream) << "9";
+ // Require Nsight Tegra 1.6 for JCompile support.
+ e1.Element("NsightTegraProjectRevisionNumber", "7");
}
- (*this->BuildFileStream) << "</NsightTegraProjectRevisionNumber>\n";
- // Tell newer versions to upgrade silently when loading.
- this->WriteString("<NsightTegraUpgradeOnceWithoutPrompt>"
- "true"
- "</NsightTegraUpgradeOnceWithoutPrompt>\n",
- 2);
- } else {
- // Require Nsight Tegra 1.6 for JCompile support.
- this->WriteString("<NsightTegraProjectRevisionNumber>"
- "7"
- "</NsightTegraProjectRevisionNumber>\n",
- 2);
}
- this->WriteString("</PropertyGroup>\n", 1);
- }
- if (const char* hostArch =
- this->GlobalGenerator->GetPlatformToolsetHostArchitecture()) {
- this->WriteString("<PropertyGroup>\n", 1);
- this->WriteString("<PreferredToolArchitecture>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(hostArch)
- << "</PreferredToolArchitecture>\n";
- this->WriteString("</PropertyGroup>\n", 1);
- }
+ if (const char* hostArch =
+ this->GlobalGenerator->GetPlatformToolsetHostArchitecture()) {
+ Elem e1(e0, "PropertyGroup");
+ e1.Element("PreferredToolArchitecture", hostArch);
+ }
- if (csproj != this->ProjectType) {
- this->WriteProjectConfigurations();
- }
- this->WriteString("<PropertyGroup Label=\"Globals\">\n", 1);
- this->WriteString("<ProjectGuid>", 2);
- (*this->BuildFileStream) << "{" << this->GUID << "}</ProjectGuid>\n";
+ if (this->ProjectType != csproj) {
+ this->WriteProjectConfigurations(e0);
+ }
- if (this->MSTools &&
- this->GeneratorTarget->GetType() <= cmStateEnums::GLOBAL_TARGET) {
- this->WriteApplicationTypeSettings();
- this->VerifyNecessaryFiles();
- }
+ {
+ Elem e1(e0, "PropertyGroup");
+ e1.Attribute("Label", "Globals");
+ e1.Element("ProjectGuid", "{" + this->GUID + "}");
+
+ if (this->MSTools &&
+ this->GeneratorTarget->GetType() <= cmStateEnums::GLOBAL_TARGET) {
+ this->WriteApplicationTypeSettings(e1);
+ this->VerifyNecessaryFiles();
+ }
- const char* vsProjectTypes =
- this->GeneratorTarget->GetProperty("VS_GLOBAL_PROJECT_TYPES");
- if (vsProjectTypes) {
- std::string tagName = "ProjectTypes";
- if (csproj == this->ProjectType) {
- tagName = "ProjectTypeGuids";
- }
- this->WriteString("", 2);
- (*this->BuildFileStream) << "<" << tagName << ">"
- << cmVS10EscapeXML(vsProjectTypes) << "</"
- << tagName << ">\n";
- }
+ const char* vsProjectTypes =
+ this->GeneratorTarget->GetProperty("VS_GLOBAL_PROJECT_TYPES");
+ if (vsProjectTypes) {
+ const char* tagName = "ProjectTypes";
+ if (this->ProjectType == csproj) {
+ tagName = "ProjectTypeGuids";
+ }
+ e1.Element(tagName, vsProjectTypes);
+ }
- const char* vsProjectName =
- this->GeneratorTarget->GetProperty("VS_SCC_PROJECTNAME");
- const char* vsLocalPath =
- this->GeneratorTarget->GetProperty("VS_SCC_LOCALPATH");
- const char* vsProvider =
- this->GeneratorTarget->GetProperty("VS_SCC_PROVIDER");
+ const char* vsProjectName =
+ this->GeneratorTarget->GetProperty("VS_SCC_PROJECTNAME");
+ const char* vsLocalPath =
+ this->GeneratorTarget->GetProperty("VS_SCC_LOCALPATH");
+ const char* vsProvider =
+ this->GeneratorTarget->GetProperty("VS_SCC_PROVIDER");
+
+ if (vsProjectName && vsLocalPath && vsProvider) {
+ e1.Element("SccProjectName", vsProjectName);
+ e1.Element("SccLocalPath", vsLocalPath);
+ e1.Element("SccProvider", vsProvider);
+
+ const char* vsAuxPath =
+ this->GeneratorTarget->GetProperty("VS_SCC_AUXPATH");
+ if (vsAuxPath) {
+ e1.Element("SccAuxPath", vsAuxPath);
+ }
+ }
- if (vsProjectName && vsLocalPath && vsProvider) {
- this->WriteString("<SccProjectName>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectName)
- << "</SccProjectName>\n";
- this->WriteString("<SccLocalPath>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(vsLocalPath)
- << "</SccLocalPath>\n";
- this->WriteString("<SccProvider>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(vsProvider)
- << "</SccProvider>\n";
+ if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) {
+ e1.Element("WinMDAssembly", "true");
+ }
- const char* vsAuxPath =
- this->GeneratorTarget->GetProperty("VS_SCC_AUXPATH");
- if (vsAuxPath) {
- this->WriteString("<SccAuxPath>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(vsAuxPath)
- << "</SccAuxPath>\n";
- }
- }
+ const char* vsGlobalKeyword =
+ this->GeneratorTarget->GetProperty("VS_GLOBAL_KEYWORD");
+ if (!vsGlobalKeyword) {
+ e1.Element("Keyword", "Win32Proj");
+ } else {
+ e1.Element("Keyword", vsGlobalKeyword);
+ }
- if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) {
- this->WriteString("<WinMDAssembly>true</WinMDAssembly>\n", 2);
- }
+ const char* vsGlobalRootNamespace =
+ this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE");
+ if (vsGlobalRootNamespace) {
+ e1.Element("RootNamespace", vsGlobalRootNamespace);
+ }
- const char* vsGlobalKeyword =
- this->GeneratorTarget->GetProperty("VS_GLOBAL_KEYWORD");
- if (!vsGlobalKeyword) {
- this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2);
- } else {
- this->WriteString("<Keyword>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalKeyword)
- << "</Keyword>\n";
- }
-
- const char* vsGlobalRootNamespace =
- this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE");
- if (vsGlobalRootNamespace) {
- this->WriteString("<RootNamespace>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalRootNamespace)
- << "</RootNamespace>\n";
- }
-
- this->WriteString("<Platform>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(this->Platform)
- << "</Platform>\n";
- const char* projLabel = this->GeneratorTarget->GetProperty("PROJECT_LABEL");
- if (!projLabel) {
- projLabel = this->Name.c_str();
- }
- this->WriteString("<ProjectName>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(projLabel) << "</ProjectName>\n";
- if (const char* targetFrameworkVersion = this->GeneratorTarget->GetProperty(
- "VS_DOTNET_TARGET_FRAMEWORK_VERSION")) {
- this->WriteString("<TargetFrameworkVersion>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(targetFrameworkVersion)
- << "</TargetFrameworkVersion>\n";
- }
-
- // Disable the project upgrade prompt that is displayed the first time a
- // project using an older toolset version is opened in a newer version of
- // the IDE (respected by VS 2013 and above).
- if (this->GlobalGenerator->GetVersion() >=
- cmGlobalVisualStudioGenerator::VS12) {
- this->WriteString("<VCProjectUpgraderObjectName>NoUpgrade"
- "</VCProjectUpgraderObjectName>\n",
- 2);
- }
-
- std::vector<std::string> keys = this->GeneratorTarget->GetPropertyKeys();
- for (std::vector<std::string>::const_iterator keyIt = keys.begin();
- keyIt != keys.end(); ++keyIt) {
- static const char* prefix = "VS_GLOBAL_";
- if (keyIt->find(prefix) != 0)
- continue;
- std::string globalKey = keyIt->substr(strlen(prefix));
- // Skip invalid or separately-handled properties.
- if (globalKey == "" || globalKey == "PROJECT_TYPES" ||
- globalKey == "ROOTNAMESPACE" || globalKey == "KEYWORD") {
- continue;
+ e1.Element("Platform", this->Platform);
+ const char* projLabel =
+ this->GeneratorTarget->GetProperty("PROJECT_LABEL");
+ if (!projLabel) {
+ projLabel = this->Name.c_str();
+ }
+ e1.Element("ProjectName", projLabel);
+ {
+ // TODO: add deprecation warning for VS_* property?
+ const char* targetFrameworkVersion =
+ this->GeneratorTarget->GetProperty(
+ "VS_DOTNET_TARGET_FRAMEWORK_VERSION");
+ if (!targetFrameworkVersion) {
+ targetFrameworkVersion = this->GeneratorTarget->GetProperty(
+ "DOTNET_TARGET_FRAMEWORK_VERSION");
+ }
+ if (!targetFrameworkVersion && this->ProjectType == csproj &&
+ this->GlobalGenerator->TargetsWindowsCE() &&
+ this->GlobalGenerator->GetVersion() ==
+ cmGlobalVisualStudioGenerator::VS12) {
+ // VS12 .NETCF default to .NET framework 3.9
+ targetFrameworkVersion = "v3.9";
+ }
+ if (targetFrameworkVersion) {
+ e1.Element("TargetFrameworkVersion", targetFrameworkVersion);
+ }
+ if (this->ProjectType == vcxproj &&
+ this->GlobalGenerator->TargetsWindowsCE()) {
+ e1.Element("EnableRedirectPlatform", "true");
+ e1.Element("RedirectPlatformValue", this->Platform);
+ }
+ if (this->ProjectType == csproj &&
+ this->GlobalGenerator->TargetsWindowsCE()) {
+ const char* targetFrameworkId = this->GeneratorTarget->GetProperty(
+ "VS_TARGET_FRAMEWORK_IDENTIFIER");
+ if (!targetFrameworkId) {
+ targetFrameworkId = "WindowsEmbeddedCompact";
+ }
+ e1.Element("TargetFrameworkIdentifier", targetFrameworkId);
+ const char* targetFrameworkVer = this->GeneratorTarget->GetProperty(
+ "VS_TARGET_FRAMEWORKS_TARGET_VERSION");
+ if (!targetFrameworkVer) {
+ targetFrameworkVer = "v8.0";
+ }
+ e1.Element("TargetFrameworkTargetsVersion", targetFrameworkVer);
+ }
+ if (!this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString()
+ .empty()) {
+ e1.Element(
+ "CudaToolkitCustomDir",
+ this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString() +
+ "nvcc");
+ }
+ }
+
+ // Disable the project upgrade prompt that is displayed the first time a
+ // project using an older toolset version is opened in a newer version of
+ // the IDE (respected by VS 2013 and above).
+ if (this->GlobalGenerator->GetVersion() >=
+ cmGlobalVisualStudioGenerator::VS12) {
+ e1.Element("VCProjectUpgraderObjectName", "NoUpgrade");
+ }
+
+ std::vector<std::string> keys = this->GeneratorTarget->GetPropertyKeys();
+ for (std::string const& keyIt : keys) {
+ static const char* prefix = "VS_GLOBAL_";
+ if (keyIt.find(prefix) != 0)
+ continue;
+ std::string globalKey = keyIt.substr(strlen(prefix));
+ // Skip invalid or separately-handled properties.
+ if (globalKey.empty() || globalKey == "PROJECT_TYPES" ||
+ globalKey == "ROOTNAMESPACE" || globalKey == "KEYWORD") {
+ continue;
+ }
+ const char* value = this->GeneratorTarget->GetProperty(keyIt);
+ if (!value)
+ continue;
+ e1.Element(globalKey.c_str(), value);
+ }
+
+ if (this->Managed) {
+ std::string outputType;
+ switch (this->GeneratorTarget->GetType()) {
+ case cmStateEnums::OBJECT_LIBRARY:
+ case cmStateEnums::STATIC_LIBRARY:
+ case cmStateEnums::SHARED_LIBRARY:
+ outputType = "Library";
+ break;
+ case cmStateEnums::MODULE_LIBRARY:
+ outputType = "Module";
+ break;
+ case cmStateEnums::EXECUTABLE:
+ if (this->GeneratorTarget->Target->GetPropertyAsBool(
+ "WIN32_EXECUTABLE")) {
+ outputType = "WinExe";
+ } else {
+ outputType = "Exe";
+ }
+ break;
+ case cmStateEnums::UTILITY:
+ case cmStateEnums::GLOBAL_TARGET:
+ outputType = "Utility";
+ break;
+ case cmStateEnums::UNKNOWN_LIBRARY:
+ case cmStateEnums::INTERFACE_LIBRARY:
+ break;
+ }
+ e1.Element("OutputType", outputType);
+ e1.Element("AppDesignerFolder", "Properties");
+ }
}
- const char* value = this->GeneratorTarget->GetProperty(keyIt->c_str());
- if (!value)
- continue;
- this->WriteString("<", 2);
- (*this->BuildFileStream) << globalKey << ">" << cmVS10EscapeXML(value)
- << "</" << globalKey << ">\n";
- }
- if (this->Managed) {
- std::string outputType = "<OutputType>";
- switch (this->GeneratorTarget->GetType()) {
- case cmStateEnums::OBJECT_LIBRARY:
- case cmStateEnums::STATIC_LIBRARY:
- case cmStateEnums::SHARED_LIBRARY:
- outputType += "Library";
- break;
- case cmStateEnums::MODULE_LIBRARY:
- outputType += "Module";
- break;
- case cmStateEnums::EXECUTABLE:
- if (this->GeneratorTarget->Target->GetPropertyAsBool(
- "WIN32_EXECUTABLE")) {
- outputType += "WinExe";
- } else {
- outputType += "Exe";
+ switch (this->ProjectType) {
+ case vcxproj:
+ if (this->GlobalGenerator->GetPlatformToolsetVersion()) {
+ Elem(e0, "Import")
+ .Attribute("Project",
+ this->GlobalGenerator->GetAuxiliaryToolset());
}
+ Elem(e0, "Import").Attribute("Project", VS10_CXX_DEFAULT_PROPS);
break;
- case cmStateEnums::UTILITY:
- case cmStateEnums::GLOBAL_TARGET:
- outputType += "Utility";
- break;
- case cmStateEnums::UNKNOWN_LIBRARY:
- case cmStateEnums::INTERFACE_LIBRARY:
+ case csproj:
+ Elem(e0, "Import")
+ .Attribute("Project", VS10_CSharp_DEFAULT_PROPS)
+ .Attribute("Condition", "Exists('" VS10_CSharp_DEFAULT_PROPS "')");
break;
}
- outputType += "</OutputType>\n";
- this->WriteString(outputType.c_str(), 2);
- this->WriteString("<AppDesignerFolder>Properties</AppDesignerFolder>\n",
- 2);
- }
- this->WriteString("</PropertyGroup>\n", 1);
+ this->WriteProjectConfigurationValues(e0);
- switch (this->ProjectType) {
- case vcxproj:
- this->WriteString("<Import Project=\"" VS10_CXX_DEFAULT_PROPS "\" />\n",
- 1);
- break;
- case csproj:
- this->WriteString("<Import Project=\"" VS10_CSharp_DEFAULT_PROPS "\" "
- "Condition=\"Exists('" VS10_CSharp_DEFAULT_PROPS "')\""
- "/>\n",
- 1);
- break;
- }
+ if (this->ProjectType == vcxproj) {
+ Elem(e0, "Import").Attribute("Project", VS10_CXX_PROPS);
+ }
+ {
+ Elem e1(e0, "ImportGroup");
+ e1.Attribute("Label", "ExtensionSettings");
+ e1.SetHasElements();
+
+ if (this->GlobalGenerator->IsCudaEnabled()) {
+ auto customDir =
+ this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString();
+ std::string cudaPath = customDir.empty()
+ ? "$(VCTargetsPath)\\BuildCustomizations\\"
+ : customDir +
+ "CUDAVisualStudioIntegration\\extras\\"
+ "visual_studio_integration\\MSBuildExtensions\\";
+ Elem(e1, "Import")
+ .Attribute("Project",
+ std::move(cudaPath) + "CUDA " +
+ this->GlobalGenerator->GetPlatformToolsetCuda() +
+ ".props");
+ }
+ if (this->GlobalGenerator->IsMasmEnabled()) {
+ Elem(e1, "Import")
+ .Attribute("Project",
+ "$(VCTargetsPath)\\BuildCustomizations\\masm.props");
+ }
+ if (this->GlobalGenerator->IsNasmEnabled()) {
+ // Always search in the standard modules location.
+ std::string propsTemplate =
+ GetCMakeFilePath("Templates/MSBuild/nasm.props.in");
+
+ std::string propsLocal =
+ cmStrCat(this->DefaultArtifactDir, "\\nasm.props");
+ ConvertToWindowsSlash(propsLocal);
+ this->Makefile->ConfigureFile(propsTemplate, propsLocal, false, true,
+ true);
+ Elem(e1, "Import").Attribute("Project", propsLocal);
+ }
+ }
+ {
+ Elem e1(e0, "ImportGroup");
+ e1.Attribute("Label", "PropertySheets");
+ std::string props;
+ switch (this->ProjectType) {
+ case vcxproj:
+ props = VS10_CXX_USER_PROPS;
+ break;
+ case csproj:
+ props = VS10_CSharp_USER_PROPS;
+ break;
+ }
+ if (const char* p =
+ this->GeneratorTarget->GetProperty("VS_USER_PROPS")) {
+ props = p;
+ }
+ if (!props.empty()) {
+ ConvertToWindowsSlash(props);
+ Elem(e1, "Import")
+ .Attribute("Project", props)
+ .Attribute("Condition", "exists('" + props + "')")
+ .Attribute("Label", "LocalAppDataPlatform");
+ }
- this->WriteProjectConfigurationValues();
-
- if (vcxproj == this->ProjectType) {
- this->WriteString("<Import Project=\"" VS10_CXX_PROPS "\" />\n", 1);
- }
- this->WriteString("<ImportGroup Label=\"ExtensionSettings\">\n", 1);
- if (this->GlobalGenerator->IsCudaEnabled()) {
- this->WriteString("<Import Project=\"$(VCTargetsPath)\\"
- "BuildCustomizations\\CUDA ",
- 2);
- (*this->BuildFileStream)
- << cmVS10EscapeXML(this->GlobalGenerator->GetPlatformToolsetCudaString())
- << ".props\" />\n";
- }
- if (this->GlobalGenerator->IsMasmEnabled()) {
- this->WriteString("<Import Project=\"$(VCTargetsPath)\\"
- "BuildCustomizations\\masm.props\" />\n",
- 2);
- }
- if (this->GlobalGenerator->IsNasmEnabled()) {
- // Always search in the standard modules location.
- std::string propsTemplate =
- GetCMakeFilePath("Templates/MSBuild/nasm.props.in");
-
- std::string propsLocal;
- propsLocal += this->DefaultArtifactDir;
- propsLocal += "\\nasm.props";
- this->ConvertToWindowsSlash(propsLocal);
- this->Makefile->ConfigureFile(propsTemplate.c_str(), propsLocal.c_str(),
- false, true, true);
- std::string import = std::string("<Import Project=\"") +
- cmVS10EscapeXML(propsLocal) + "\" />\n";
- this->WriteString(import.c_str(), 2);
- }
- this->WriteString("</ImportGroup>\n", 1);
- this->WriteString("<ImportGroup Label=\"PropertySheets\">\n", 1);
- {
- std::string props;
+ this->WritePlatformExtensions(e1);
+ }
+ Elem(e0, "PropertyGroup").Attribute("Label", "UserMacros");
+ this->WriteWinRTPackageCertificateKeyFile(e0);
+ this->WritePathAndIncrementalLinkOptions(e0);
+ this->WriteCEDebugProjectConfigurationValues(e0);
+ this->WriteItemDefinitionGroups(e0);
+ this->WriteCustomCommands(e0);
+ this->WriteAllSources(e0);
+ this->WriteDotNetReferences(e0);
+ this->WritePackageReferences(e0);
+ this->WriteImports(e0);
+ this->WriteEmbeddedResourceGroup(e0);
+ this->WriteXamlFilesGroup(e0);
+ this->WriteWinRTReferences(e0);
+ this->WriteProjectReferences(e0);
+ this->WriteSDKReferences(e0);
switch (this->ProjectType) {
case vcxproj:
- props = VS10_CXX_USER_PROPS;
+ Elem(e0, "Import").Attribute("Project", VS10_CXX_TARGETS);
break;
case csproj:
- props = VS10_CSharp_USER_PROPS;
+ if (this->GlobalGenerator->TargetsWindowsCE()) {
+ Elem(e0, "Import").Attribute("Project", VS10_CSharp_NETCF_TARGETS);
+ } else {
+ Elem(e0, "Import").Attribute("Project", VS10_CSharp_TARGETS);
+ }
break;
}
- if (const char* p = this->GeneratorTarget->GetProperty("VS_USER_PROPS")) {
- props = p;
- }
- if (!props.empty()) {
- this->ConvertToWindowsSlash(props);
- this->WriteString("", 2);
- (*this->BuildFileStream)
- << "<Import Project=\"" << cmVS10EscapeXML(props) << "\""
- << " Condition=\"exists('" << cmVS10EscapeXML(props) << "')\""
- << " Label=\"LocalAppDataPlatform\" />\n";
- }
- }
- this->WritePlatformExtensions();
- this->WriteString("</ImportGroup>\n", 1);
- this->WriteString("<PropertyGroup Label=\"UserMacros\" />\n", 1);
- this->WriteWinRTPackageCertificateKeyFile();
- this->WritePathAndIncrementalLinkOptions();
- this->WriteItemDefinitionGroups();
- this->WriteCustomCommands();
- this->WriteAllSources();
- this->WriteDotNetReferences();
- this->WriteEmbeddedResourceGroup();
- this->WriteXamlFilesGroup();
- this->WriteWinRTReferences();
- this->WriteProjectReferences();
- this->WriteSDKReferences();
- switch (this->ProjectType) {
- case vcxproj:
- this->WriteString("<Import Project=\"" VS10_CXX_TARGETS "\" />\n", 1);
- break;
- case csproj:
- this->WriteString("<Import Project=\"" VS10_CSharp_TARGETS "\" />\n", 1);
- break;
+
+ this->WriteTargetSpecificReferences(e0);
+ {
+ Elem e1(e0, "ImportGroup");
+ e1.Attribute("Label", "ExtensionTargets");
+ e1.SetHasElements();
+ this->WriteTargetsFileReferences(e1);
+ if (this->GlobalGenerator->IsCudaEnabled()) {
+ auto customDir =
+ this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString();
+ std::string cudaPath = customDir.empty()
+ ? "$(VCTargetsPath)\\BuildCustomizations\\"
+ : customDir +
+ "CUDAVisualStudioIntegration\\extras\\"
+ "visual_studio_integration\\MSBuildExtensions\\";
+ Elem(e1, "Import")
+ .Attribute("Project",
+ std::move(cudaPath) + "CUDA " +
+ this->GlobalGenerator->GetPlatformToolsetCuda() +
+ ".targets");
+ }
+ if (this->GlobalGenerator->IsMasmEnabled()) {
+ Elem(e1, "Import")
+ .Attribute("Project",
+ "$(VCTargetsPath)\\BuildCustomizations\\masm.targets");
+ }
+ if (this->GlobalGenerator->IsNasmEnabled()) {
+ std::string nasmTargets =
+ GetCMakeFilePath("Templates/MSBuild/nasm.targets");
+ Elem(e1, "Import").Attribute("Project", nasmTargets);
+ }
+ }
+ if (this->ProjectType == csproj) {
+ for (std::string const& c : this->Configurations) {
+ Elem e1(e0, "PropertyGroup");
+ e1.Attribute("Condition", "'$(Configuration)' == '" + c + "'");
+ e1.SetHasElements();
+ this->WriteEvents(e1, c);
+ }
+ // make sure custom commands are executed before build (if necessary)
+ {
+ Elem e1(e0, "PropertyGroup");
+ std::ostringstream oss;
+ oss << "\n";
+ for (std::string const& i : this->CSharpCustomCommandNames) {
+ oss << " " << i << ";\n";
+ }
+ oss << " "
+ << "$(BuildDependsOn)\n";
+ e1.Element("BuildDependsOn", oss.str());
+ }
+ }
+ }
+
+ if (BuildFileStream.Close()) {
+ this->GlobalGenerator->FileReplacedDuringGenerate(PathToProjectFile);
}
- this->WriteTargetSpecificReferences();
- this->WriteString("<ImportGroup Label=\"ExtensionTargets\">\n", 1);
- this->WriteTargetsFileReferences();
- if (this->GlobalGenerator->IsCudaEnabled()) {
- this->WriteString("<Import Project=\"$(VCTargetsPath)\\"
- "BuildCustomizations\\CUDA ",
- 2);
- (*this->BuildFileStream)
- << cmVS10EscapeXML(this->GlobalGenerator->GetPlatformToolsetCudaString())
- << ".targets\" />\n";
- }
- if (this->GlobalGenerator->IsMasmEnabled()) {
- this->WriteString("<Import Project=\"$(VCTargetsPath)\\"
- "BuildCustomizations\\masm.targets\" />\n",
- 2);
- }
- if (this->GlobalGenerator->IsNasmEnabled()) {
- std::string nasmTargets =
- GetCMakeFilePath("Templates/MSBuild/nasm.targets");
- std::string import = "<Import Project=\"";
- import += cmVS10EscapeXML(nasmTargets) + "\" />\n";
- this->WriteString(import.c_str(), 2);
- }
- this->WriteString("</ImportGroup>\n", 1);
- if (csproj == this->ProjectType) {
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- this->WriteString("<PropertyGroup Condition=\"'$(Configuration)' == '",
- 1);
- (*this->BuildFileStream) << *i << "'\">\n";
- this->WriteEvents(*i);
- this->WriteString("</PropertyGroup>\n", 1);
- }
- }
- this->WriteString("</Project>", 0);
// The groups are stored in a separate file for VS 10
this->WriteGroups();
}
-void cmVisualStudio10TargetGenerator::WriteDotNetReferences()
+void cmVisualStudio10TargetGenerator::WritePackageReferences(Elem& e0)
+{
+ std::vector<std::string> packageReferences;
+ if (const char* vsPackageReferences =
+ this->GeneratorTarget->GetProperty("VS_PACKAGE_REFERENCES")) {
+ cmExpandList(vsPackageReferences, packageReferences);
+ }
+ if (!packageReferences.empty()) {
+ Elem e1(e0, "ItemGroup");
+ for (std::string const& ri : packageReferences) {
+ size_t versionIndex = ri.find_last_of('_');
+ if (versionIndex != std::string::npos) {
+ WritePackageReference(e1, ri.substr(0, versionIndex),
+ ri.substr(versionIndex + 1));
+ }
+ }
+ }
+}
+
+void cmVisualStudio10TargetGenerator::WritePackageReference(
+ Elem& e1, std::string const& ref, std::string const& version)
+{
+ Elem e2(e1, "PackageReference");
+ e2.Attribute("Include", ref);
+ e2.Attribute("Version", version);
+}
+
+void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0)
{
std::vector<std::string> references;
- typedef std::pair<std::string, std::string> HintReference;
- std::vector<HintReference> hintReferences;
if (const char* vsDotNetReferences =
this->GeneratorTarget->GetProperty("VS_DOTNET_REFERENCES")) {
- cmSystemTools::ExpandListArgument(vsDotNetReferences, references);
+ cmExpandList(vsDotNetReferences, references);
}
cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties();
- for (cmPropertyMap::const_iterator i = props.begin(); i != props.end();
- ++i) {
- if (i->first.find("VS_DOTNET_REFERENCE_") == 0) {
- std::string name = i->first.substr(20);
- if (name != "") {
- std::string path = i->second.GetValue();
+ for (auto const& i : props.GetList()) {
+ if (i.first.find("VS_DOTNET_REFERENCE_") == 0) {
+ std::string name = i.first.substr(20);
+ if (!name.empty()) {
+ std::string path = i.second;
if (!cmsys::SystemTools::FileIsFullPath(path)) {
- path = std::string(this->GeneratorTarget->Target->GetMakefile()
- ->GetCurrentSourceDirectory()) +
- "/" + path;
+ path = this->Makefile->GetCurrentSourceDirectory() + "/" + path;
}
- this->ConvertToWindowsSlash(path);
- hintReferences.push_back(HintReference(name, path));
+ ConvertToWindowsSlash(path);
+ this->DotNetHintReferences[""].push_back(
+ DotNetHintReference(name, path));
}
}
}
- if (!references.empty() || !hintReferences.empty()) {
- this->WriteString("<ItemGroup>\n", 1);
- for (std::vector<std::string>::iterator ri = references.begin();
- ri != references.end(); ++ri) {
+ if (!references.empty() || !this->DotNetHintReferences.empty()) {
+ Elem e1(e0, "ItemGroup");
+ for (std::string 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)) {
+ if (cmsys::SystemTools::FileExists(ri, true)) {
std::string name =
- cmsys::SystemTools::GetFilenameWithoutExtension(*ri);
- std::string path = *ri;
- this->ConvertToWindowsSlash(path);
- hintReferences.push_back(HintReference(name, path));
+ cmsys::SystemTools::GetFilenameWithoutLastExtension(ri);
+ std::string path = ri;
+ ConvertToWindowsSlash(path);
+ this->DotNetHintReferences[""].push_back(
+ DotNetHintReference(name, path));
} else {
- this->WriteDotNetReference(*ri, "");
+ this->WriteDotNetReference(e1, ri, "", "");
}
}
- for (std::vector<std::pair<std::string, std::string> >::const_iterator i =
- hintReferences.begin();
- i != hintReferences.end(); ++i) {
- this->WriteDotNetReference(i->first, i->second);
+ for (const auto& h : this->DotNetHintReferences) {
+ // DotNetHintReferences is also populated from AddLibraries().
+ // The configuration specific hint references are added there.
+ for (const auto& i : h.second) {
+ this->WriteDotNetReference(e1, i.first, i.second, h.first);
+ }
}
- this->WriteString("</ItemGroup>\n", 1);
}
}
void cmVisualStudio10TargetGenerator::WriteDotNetReference(
- std::string const& ref, std::string const& hint)
+ Elem& e1, std::string const& ref, std::string const& hint,
+ std::string const& config)
{
- this->WriteString("<Reference Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(ref) << "\">\n";
- this->WriteString("<CopyLocalSatelliteAssemblies>true"
- "</CopyLocalSatelliteAssemblies>\n",
- 3);
- this->WriteString("<ReferenceOutputAssembly>true"
- "</ReferenceOutputAssembly>\n",
- 3);
+ Elem e2(e1, "Reference");
+ // If 'config' is not empty, the reference is only added for the given
+ // configuration. This is used when referencing imported managed assemblies.
+ // See also cmVisualStudio10TargetGenerator::AddLibraries().
+ if (!config.empty()) {
+ e2.Attribute("Condition", this->CalcCondition(config));
+ }
+ e2.Attribute("Include", ref);
+ e2.Element("CopyLocalSatelliteAssemblies", "true");
+ e2.Element("ReferenceOutputAssembly", "true");
if (!hint.empty()) {
const char* privateReference = "True";
if (const char* value = this->GeneratorTarget->GetProperty(
"VS_DOTNET_REFERENCES_COPY_LOCAL")) {
- if (cmSystemTools::IsOff(value)) {
+ if (cmIsOff(value)) {
privateReference = "False";
}
}
- this->WriteString("<Private>", 3);
- (*this->BuildFileStream) << privateReference << "</Private>\n";
- this->WriteString("<HintPath>", 3);
- (*this->BuildFileStream) << hint << "</HintPath>\n";
+ e2.Element("Private", privateReference);
+ e2.Element("HintPath", hint);
}
- this->WriteString("</Reference>\n", 2);
+ this->WriteDotNetReferenceCustomTags(e2, ref);
}
-void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
+void cmVisualStudio10TargetGenerator::WriteImports(Elem& e0)
+{
+ const char* imports =
+ this->GeneratorTarget->Target->GetProperty("VS_PROJECT_IMPORT");
+ if (imports) {
+ std::vector<std::string> argsSplit =
+ cmExpandedList(std::string(imports), false);
+ for (auto& path : argsSplit) {
+ if (!cmsys::SystemTools::FileIsFullPath(path)) {
+ path = this->Makefile->GetCurrentSourceDirectory() + "/" + path;
+ }
+ ConvertToWindowsSlash(path);
+ Elem e1(e0, "Import");
+ e1.Attribute("Project", path);
+ }
+ }
+}
+
+void cmVisualStudio10TargetGenerator::WriteDotNetReferenceCustomTags(
+ Elem& e2, std::string const& ref)
+{
+
+ static const std::string refpropPrefix = "VS_DOTNET_REFERENCEPROP_";
+ static const std::string refpropInfix = "_TAG_";
+ const std::string refPropFullPrefix = refpropPrefix + ref + refpropInfix;
+ using CustomTags = std::map<std::string, std::string>;
+ CustomTags tags;
+ cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties();
+ for (const auto& i : props.GetList()) {
+ if (i.first.find(refPropFullPrefix) == 0) {
+ std::string refTag = i.first.substr(refPropFullPrefix.length());
+ std::string refVal = i.second;
+ if (!refTag.empty() && !refVal.empty()) {
+ tags[refTag] = refVal;
+ }
+ }
+ }
+ for (auto const& tag : tags) {
+ e2.Element(tag.first.c_str(), tag.second);
+ }
+}
+
+void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0)
{
std::vector<cmSourceFile const*> resxObjs;
this->GeneratorTarget->GetResxSources(resxObjs, "");
if (!resxObjs.empty()) {
- this->WriteString("<ItemGroup>\n", 1);
+ Elem e1(e0, "ItemGroup");
std::string srcDir = this->Makefile->GetCurrentSourceDirectory();
- this->ConvertToWindowsSlash(srcDir);
- for (std::vector<cmSourceFile const*>::const_iterator oi =
- resxObjs.begin();
- oi != resxObjs.end(); ++oi) {
- std::string obj = (*oi)->GetFullPath();
- this->WriteString("<EmbeddedResource Include=\"", 2);
- this->ConvertToWindowsSlash(obj);
+ ConvertToWindowsSlash(srcDir);
+ for (cmSourceFile const* oi : resxObjs) {
+ std::string obj = oi->GetFullPath();
+ ConvertToWindowsSlash(obj);
bool useRelativePath = false;
- if (csproj == this->ProjectType && this->InSourceBuild) {
+ if (this->ProjectType == csproj && this->InSourceBuild) {
// If we do an in-source build and the resource file is in a
// subdirectory
// of the .csproj file, we have to use relative pathnames, otherwise
// visual studio does not show the file in the IDE. Sorry.
if (obj.find(srcDir) == 0) {
obj = this->ConvertPath(obj, true);
- this->ConvertToWindowsSlash(obj);
+ ConvertToWindowsSlash(obj);
useRelativePath = true;
}
}
- (*this->BuildFileStream) << obj << "\">\n";
+ Elem e2(e1, "EmbeddedResource");
+ e2.Attribute("Include", obj);
- if (csproj != this->ProjectType) {
- this->WriteString("<DependentUpon>", 3);
+ if (this->ProjectType != csproj) {
std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h";
- (*this->BuildFileStream) << hFileName << "</DependentUpon>\n";
+ e2.Element("DependentUpon", hFileName);
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- this->WritePlatformConfigTag("LogicalName", i->c_str(), 3);
+ for (std::string const& c : this->Configurations) {
+ std::string s;
if (this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE") ||
// Handle variant of VS_GLOBAL_<variable> for RootNamespace.
this->GeneratorTarget->GetProperty("VS_GLOBAL_RootNamespace")) {
- (*this->BuildFileStream) << "$(RootNamespace).";
+ s = "$(RootNamespace).";
}
- (*this->BuildFileStream) << "%(Filename)";
- (*this->BuildFileStream) << ".resources";
- (*this->BuildFileStream) << "</LogicalName>\n";
+ s += "%(Filename).resources";
+ e2.WritePlatformConfigTag("LogicalName", this->CalcCondition(c), s);
}
} else {
std::string binDir = this->Makefile->GetCurrentBinaryDirectory();
- this->ConvertToWindowsSlash(binDir);
+ ConvertToWindowsSlash(binDir);
// If the resource was NOT added using a relative path (which should
// be the default), we have to provide a link here
if (!useRelativePath) {
@@ -721,25 +965,21 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
link = cmsys::SystemTools::GetFilenameName(obj);
}
if (!link.empty()) {
- this->WriteString("<Link>", 3);
- (*this->BuildFileStream) << link << "</Link>\n";
+ e2.Element("Link", link);
}
}
// Determine if this is a generated resource from a .Designer.cs file
std::string designerResource =
- cmSystemTools::GetFilenamePath((*oi)->GetFullPath()) + "/" +
- cmSystemTools::GetFilenameWithoutLastExtension(
- (*oi)->GetFullPath()) +
+ cmSystemTools::GetFilenamePath(oi->GetFullPath()) + "/" +
+ cmSystemTools::GetFilenameWithoutLastExtension(oi->GetFullPath()) +
".Designer.cs";
if (cmsys::SystemTools::FileExists(designerResource)) {
std::string generator = "PublicResXFileCodeGenerator";
- if (const char* g = (*oi)->GetProperty("VS_RESOURCE_GENERATOR")) {
+ if (const char* g = oi->GetProperty("VS_RESOURCE_GENERATOR")) {
generator = g;
}
if (!generator.empty()) {
- this->WriteString("<Generator>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(generator)
- << "</Generator>\n";
+ e2.Element("Generator", generator);
if (designerResource.find(srcDir) == 0) {
designerResource = designerResource.substr(srcDir.length() + 1);
} else if (designerResource.find(binDir) == 0) {
@@ -748,60 +988,53 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
designerResource =
cmsys::SystemTools::GetFilenameName(designerResource);
}
- this->ConvertToWindowsSlash(designerResource);
- this->WriteString("<LastGenOutput>", 3);
- (*this->BuildFileStream) << designerResource
- << "</LastGenOutput>\n";
+ ConvertToWindowsSlash(designerResource);
+ e2.Element("LastGenOutput", designerResource);
}
}
- const cmPropertyMap& props = (*oi)->GetProperties();
- for (cmPropertyMap::const_iterator p = props.begin(); p != props.end();
- ++p) {
+ const cmPropertyMap& props = oi->GetProperties();
+ for (const std::string& p : props.GetKeys()) {
static const std::string propNamePrefix = "VS_CSHARP_";
- if (p->first.find(propNamePrefix.c_str()) == 0) {
- std::string tagName = p->first.substr(propNamePrefix.length());
+ if (p.find(propNamePrefix) == 0) {
+ std::string tagName = p.substr(propNamePrefix.length());
if (!tagName.empty()) {
- std::string value = props.GetPropertyValue(p->first);
+ std::string value = props.GetPropertyValue(p);
if (!value.empty()) {
- this->WriteString("<", 3);
- (*this->BuildFileStream) << tagName << ">";
- (*this->BuildFileStream) << cmVS10EscapeXML(value);
- (*this->BuildFileStream) << "</" << tagName << ">\n";
+ e2.Element(tagName.c_str(), value);
}
}
}
}
}
-
- this->WriteString("</EmbeddedResource>\n", 2);
}
- this->WriteString("</ItemGroup>\n", 1);
}
}
-void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup()
+void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup(Elem& e0)
{
std::vector<cmSourceFile const*> xamlObjs;
this->GeneratorTarget->GetXamlSources(xamlObjs, "");
if (!xamlObjs.empty()) {
- this->WriteString("<ItemGroup>\n", 1);
- for (std::vector<cmSourceFile const*>::const_iterator oi =
- xamlObjs.begin();
- oi != xamlObjs.end(); ++oi) {
- std::string obj = (*oi)->GetFullPath();
- std::string xamlType;
- const char* xamlTypeProperty = (*oi)->GetProperty("VS_XAML_TYPE");
+ Elem e1(e0, "ItemGroup");
+ for (cmSourceFile const* oi : xamlObjs) {
+ std::string obj = oi->GetFullPath();
+ const char* xamlType;
+ const char* xamlTypeProperty = oi->GetProperty("VS_XAML_TYPE");
if (xamlTypeProperty) {
xamlType = xamlTypeProperty;
} else {
xamlType = "Page";
}
- this->WriteSource(xamlType, *oi, ">\n");
- if (csproj == this->ProjectType && !this->InSourceBuild) {
+ Elem e2(e1, xamlType);
+ this->WriteSource(e2, oi);
+ e2.SetHasElements();
+ if (this->ProjectType == csproj && !this->InSourceBuild) {
// add <Link> tag to written XAML source if necessary
- const std::string srcDir = this->Makefile->GetCurrentSourceDirectory();
- const std::string binDir = this->Makefile->GetCurrentBinaryDirectory();
+ const std::string& srcDir =
+ this->Makefile->GetCurrentSourceDirectory();
+ const std::string& binDir =
+ this->Makefile->GetCurrentBinaryDirectory();
std::string link;
if (obj.find(srcDir) == 0) {
link = obj.substr(srcDir.length() + 1);
@@ -811,64 +1044,57 @@ void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup()
link = cmsys::SystemTools::GetFilenameName(obj);
}
if (!link.empty()) {
- this->ConvertToWindowsSlash(link);
- this->WriteString("<Link>", 3);
- (*this->BuildFileStream) << link << "</Link>\n";
+ ConvertToWindowsSlash(link);
+ e2.Element("Link", link);
}
}
- this->WriteString("<SubType>Designer</SubType>\n", 3);
- this->WriteString("</", 2);
- (*this->BuildFileStream) << xamlType << ">\n";
+ e2.Element("SubType", "Designer");
}
- this->WriteString("</ItemGroup>\n", 1);
}
}
-void cmVisualStudio10TargetGenerator::WriteTargetSpecificReferences()
+void cmVisualStudio10TargetGenerator::WriteTargetSpecificReferences(Elem& e0)
{
if (this->MSTools) {
if (this->GlobalGenerator->TargetsWindowsPhone() &&
this->GlobalGenerator->GetSystemVersion() == "8.0") {
- this->WriteString("<Import Project=\""
- "$(MSBuildExtensionsPath)\\Microsoft\\WindowsPhone\\v"
- "$(TargetPlatformVersion)\\Microsoft.Cpp.WindowsPhone."
- "$(TargetPlatformVersion).targets\" />\n",
- 1);
+ Elem(e0, "Import")
+ .Attribute("Project",
+ "$(MSBuildExtensionsPath)\\Microsoft\\WindowsPhone\\v"
+ "$(TargetPlatformVersion)\\Microsoft.Cpp.WindowsPhone."
+ "$(TargetPlatformVersion).targets");
}
}
}
-void cmVisualStudio10TargetGenerator::WriteTargetsFileReferences()
+void cmVisualStudio10TargetGenerator::WriteTargetsFileReferences(Elem& e1)
{
- for (std::vector<TargetsFileAndConfigs>::iterator i =
- this->TargetsFileAndConfigsVec.begin();
- i != this->TargetsFileAndConfigsVec.end(); ++i) {
- TargetsFileAndConfigs const& tac = *i;
- this->WriteString("<Import Project=\"", 3);
- (*this->BuildFileStream) << tac.File << "\" ";
- (*this->BuildFileStream) << "Condition=\"";
- (*this->BuildFileStream) << "Exists('" << tac.File << "')";
+ for (TargetsFileAndConfigs const& tac : this->TargetsFileAndConfigsVec) {
+ std::ostringstream oss;
+ oss << "Exists('" << tac.File << "')";
if (!tac.Configs.empty()) {
- (*this->BuildFileStream) << " And (";
+ oss << " And (";
for (size_t j = 0; j < tac.Configs.size(); ++j) {
if (j > 0) {
- (*this->BuildFileStream) << " Or ";
+ oss << " Or ";
}
- (*this->BuildFileStream) << "'$(Configuration)'=='" << tac.Configs[j]
- << "'";
+ oss << "'$(Configuration)'=='" << tac.Configs[j] << "'";
}
- (*this->BuildFileStream) << ")";
+ oss << ")";
}
- (*this->BuildFileStream) << "\" />\n";
+
+ Elem(e1, "Import")
+ .Attribute("Project", tac.File)
+ .Attribute("Condition", oss.str());
}
}
-void cmVisualStudio10TargetGenerator::WriteWinRTReferences()
+void cmVisualStudio10TargetGenerator::WriteWinRTReferences(Elem& e0)
{
std::vector<std::string> references;
if (const char* vsWinRTReferences =
this->GeneratorTarget->GetProperty("VS_WINRT_REFERENCES")) {
- cmSystemTools::ExpandListArgument(vsWinRTReferences, references);
+ cmExpandList(vsWinRTReferences, references);
}
if (this->GlobalGenerator->TargetsWindowsPhone() &&
@@ -877,77 +1103,68 @@ void cmVisualStudio10TargetGenerator::WriteWinRTReferences()
references.push_back("platform.winmd");
}
if (!references.empty()) {
- this->WriteString("<ItemGroup>\n", 1);
- for (std::vector<std::string>::iterator ri = references.begin();
- ri != references.end(); ++ri) {
- this->WriteString("<Reference Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(*ri) << "\">\n";
- this->WriteString("<IsWinMDFile>true</IsWinMDFile>\n", 3);
- this->WriteString("</Reference>\n", 2);
+ Elem e1(e0, "ItemGroup");
+ for (std::string const& ri : references) {
+ Elem e2(e1, "Reference");
+ e2.Attribute("Include", ri);
+ e2.Element("IsWinMDFile", "true");
}
- this->WriteString("</ItemGroup>\n", 1);
}
}
// ConfigurationType Application, Utility StaticLibrary DynamicLibrary
-void cmVisualStudio10TargetGenerator::WriteProjectConfigurations()
+void cmVisualStudio10TargetGenerator::WriteProjectConfigurations(Elem& e0)
{
- this->WriteString("<ItemGroup Label=\"ProjectConfigurations\">\n", 1);
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- this->WriteString("<ProjectConfiguration Include=\"", 2);
- (*this->BuildFileStream) << *i << "|" << this->Platform << "\">\n";
- this->WriteString("<Configuration>", 3);
- (*this->BuildFileStream) << *i << "</Configuration>\n";
- this->WriteString("<Platform>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(this->Platform)
- << "</Platform>\n";
- this->WriteString("</ProjectConfiguration>\n", 2);
- }
- this->WriteString("</ItemGroup>\n", 1);
+ Elem e1(e0, "ItemGroup");
+ e1.Attribute("Label", "ProjectConfigurations");
+ for (std::string const& c : this->Configurations) {
+ Elem e2(e1, "ProjectConfiguration");
+ e2.Attribute("Include", c + "|" + this->Platform);
+ e2.Element("Configuration", c);
+ e2.Element("Platform", this->Platform);
+ }
}
-void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
+void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues(Elem& e0)
{
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- this->WritePlatformConfigTag("PropertyGroup", i->c_str(), 1,
- " Label=\"Configuration\"", "\n");
-
- if (csproj != this->ProjectType) {
- std::string configType = "<ConfigurationType>";
+ for (std::string const& c : this->Configurations) {
+ Elem e1(e0, "PropertyGroup");
+ e1.Attribute("Condition", this->CalcCondition(c));
+ e1.Attribute("Label", "Configuration");
+
+ if (this->ProjectType != csproj) {
+ std::string configType;
if (const char* vsConfigurationType =
this->GeneratorTarget->GetProperty("VS_CONFIGURATION_TYPE")) {
- configType += cmVS10EscapeXML(vsConfigurationType);
+ configType = cmGeneratorExpression::Evaluate(vsConfigurationType,
+ this->LocalGenerator, c);
} else {
switch (this->GeneratorTarget->GetType()) {
case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY:
- configType += "DynamicLibrary";
+ configType = "DynamicLibrary";
break;
case cmStateEnums::OBJECT_LIBRARY:
case cmStateEnums::STATIC_LIBRARY:
- configType += "StaticLibrary";
+ configType = "StaticLibrary";
break;
case cmStateEnums::EXECUTABLE:
if (this->NsightTegra &&
!this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) {
// Android executables are .so too.
- configType += "DynamicLibrary";
+ configType = "DynamicLibrary";
} else {
- configType += "Application";
+ configType = "Application";
}
break;
case cmStateEnums::UTILITY:
case cmStateEnums::GLOBAL_TARGET:
if (this->NsightTegra) {
// Tegra-Android platform does not understand "Utility".
- configType += "StaticLibrary";
+ configType = "StaticLibrary";
} else {
- configType += "Utility";
+ configType = "Utility";
}
break;
case cmStateEnums::UNKNOWN_LIBRARY:
@@ -955,32 +1172,52 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
break;
}
}
- configType += "</ConfigurationType>\n";
- this->WriteString(configType.c_str(), 2);
+ e1.Element("ConfigurationType", configType);
}
if (this->MSTools) {
if (!this->Managed) {
- this->WriteMSToolConfigurationValues(*i);
+ this->WriteMSToolConfigurationValues(e1, c);
} else {
- this->WriteMSToolConfigurationValuesManaged(*i);
+ this->WriteMSToolConfigurationValuesManaged(e1, c);
}
} else if (this->NsightTegra) {
- this->WriteNsightTegraConfigurationValues(*i);
+ this->WriteNsightTegraConfigurationValues(e1, c);
}
+ }
+}
- this->WriteString("</PropertyGroup>\n", 1);
+void cmVisualStudio10TargetGenerator::WriteCEDebugProjectConfigurationValues(
+ Elem& e0)
+{
+ if (!this->GlobalGenerator->TargetsWindowsCE()) {
+ return;
+ }
+ const char* additionalFiles =
+ this->GeneratorTarget->GetProperty("DEPLOYMENT_ADDITIONAL_FILES");
+ const char* remoteDirectory =
+ this->GeneratorTarget->GetProperty("DEPLOYMENT_REMOTE_DIRECTORY");
+ if (!(additionalFiles || remoteDirectory)) {
+ return;
+ }
+ for (std::string const& c : this->Configurations) {
+ Elem e1(e0, "PropertyGroup");
+ e1.Attribute("Condition", this->CalcCondition(c));
+
+ if (remoteDirectory) {
+ e1.Element("RemoteDirectory", remoteDirectory);
+ }
+ if (additionalFiles) {
+ e1.Element("CEAdditionalFiles", additionalFiles);
+ }
}
}
void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
- std::string const& config)
+ Elem& e1, std::string const& config)
{
- cmGlobalVisualStudio10Generator* gg =
- static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- const char* mfcFlag =
- this->GeneratorTarget->Target->GetMakefile()->GetDefinition(
- "CMAKE_MFC_FLAG");
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
+ const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG");
if (mfcFlag) {
std::string const mfcFlagValue = mfcFlag;
@@ -992,9 +1229,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
useOfMfcValue = "Dynamic";
}
}
- std::string mfcLine = "<UseOfMfc>";
- mfcLine += useOfMfcValue + "</UseOfMfc>\n";
- this->WriteString(mfcLine.c_str(), 2);
+ e1.Element("UseOfMfc", useOfMfcValue);
}
if ((this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY &&
@@ -1003,161 +1238,158 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
this->GlobalGenerator->TargetsWindowsPhone() ||
this->GlobalGenerator->TargetsWindowsStore() ||
this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) {
- this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
+ e1.Element("CharacterSet", "Unicode");
} else if (this->GeneratorTarget->GetType() <=
- cmStateEnums::MODULE_LIBRARY &&
+ cmStateEnums::OBJECT_LIBRARY &&
this->ClOptions[config]->UsingSBCS()) {
- this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2);
+ e1.Element("CharacterSet", "NotSet");
} else {
- this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
+ e1.Element("CharacterSet", "MultiByte");
}
if (const char* toolset = gg->GetPlatformToolset()) {
- std::string pts = "<PlatformToolset>";
- pts += toolset;
- pts += "</PlatformToolset>\n";
- this->WriteString(pts.c_str(), 2);
+ e1.Element("PlatformToolset", toolset);
}
if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) {
- this->WriteString("<WindowsAppContainer>true"
- "</WindowsAppContainer>\n",
- 2);
+ e1.Element("WindowsAppContainer", "true");
+ }
+ if (this->IPOEnabledConfigurations.count(config) > 0) {
+ e1.Element("WholeProgramOptimization", "true");
+ }
+ {
+ auto s = this->SpectreMitigation.find(config);
+ if (s != this->SpectreMitigation.end()) {
+ e1.Element("SpectreMitigation", s->second);
+ }
}
}
void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
- std::string const& config)
+ Elem& e1, std::string const& config)
{
- cmGlobalVisualStudio10Generator* gg =
- static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
+ if (this->GeneratorTarget->GetType() > cmStateEnums::OBJECT_LIBRARY) {
+ return;
+ }
+
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
Options& o = *(this->ClOptions[config]);
if (o.IsDebug()) {
- this->WriteString("<DebugSymbols>true</DebugSymbols>\n", 2);
- this->WriteString("<DefineDebug>true</DefineDebug>\n", 2);
+ e1.Element("DebugSymbols", "true");
+ e1.Element("DefineDebug", "true");
}
- std::string outDir =
- this->GeneratorTarget->GetDirectory(config.c_str()) + "/";
- this->ConvertToWindowsSlash(outDir);
- this->WriteString("<OutputPath>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(outDir) << "</OutputPath>\n";
+ std::string outDir = this->GeneratorTarget->GetDirectory(config) + "/";
+ ConvertToWindowsSlash(outDir);
+ e1.Element("OutputPath", outDir);
if (o.HasFlag("Platform")) {
- this->WriteString("<PlatformTarget>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(o.GetFlag("Platform"))
- << "</PlatformTarget>\n";
+ e1.Element("PlatformTarget", o.GetFlag("Platform"));
o.RemoveFlag("Platform");
}
if (const char* toolset = gg->GetPlatformToolset()) {
- this->WriteString("<PlatformToolset>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(toolset)
- << "</PlatformToolset>\n";
+ e1.Element("PlatformToolset", toolset);
}
- std::string postfixName = cmSystemTools::UpperCase(config);
- postfixName += "_POSTFIX";
+ std::string postfixName =
+ cmStrCat(cmSystemTools::UpperCase(config), "_POSTFIX");
std::string assemblyName = this->GeneratorTarget->GetOutputName(
config, cmStateEnums::RuntimeBinaryArtifact);
if (const char* postfix = this->GeneratorTarget->GetProperty(postfixName)) {
assemblyName += postfix;
}
- this->WriteString("<AssemblyName>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(assemblyName)
- << "</AssemblyName>\n";
+ e1.Element("AssemblyName", assemblyName);
if (cmStateEnums::EXECUTABLE == this->GeneratorTarget->GetType()) {
- this->WriteString("<StartAction>Program</StartAction>\n", 2);
- this->WriteString("<StartProgram>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(outDir)
- << cmVS10EscapeXML(assemblyName)
- << ".exe</StartProgram>\n";
+ e1.Element("StartAction", "Program");
+ e1.Element("StartProgram", outDir + assemblyName + ".exe");
}
- o.OutputFlagMap(*this->BuildFileStream, " ");
+ OptionsHelper oh(o, e1);
+ oh.OutputFlagMap();
}
//----------------------------------------------------------------------------
void cmVisualStudio10TargetGenerator::WriteNsightTegraConfigurationValues(
- std::string const&)
+ Elem& e1, std::string const&)
{
- cmGlobalVisualStudio10Generator* gg =
- static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
const char* toolset = gg->GetPlatformToolset();
- std::string ntv = "<NdkToolchainVersion>";
- ntv += toolset ? toolset : "Default";
- ntv += "</NdkToolchainVersion>\n";
- this->WriteString(ntv.c_str(), 2);
+ e1.Element("NdkToolchainVersion", toolset ? toolset : "Default");
if (const char* minApi =
this->GeneratorTarget->GetProperty("ANDROID_API_MIN")) {
- this->WriteString("<AndroidMinAPI>", 2);
- (*this->BuildFileStream) << "android-" << cmVS10EscapeXML(minApi)
- << "</AndroidMinAPI>\n";
+ e1.Element("AndroidMinAPI", "android-" + std::string(minApi));
}
if (const char* api = this->GeneratorTarget->GetProperty("ANDROID_API")) {
- this->WriteString("<AndroidTargetAPI>", 2);
- (*this->BuildFileStream) << "android-" << cmVS10EscapeXML(api)
- << "</AndroidTargetAPI>\n";
+ e1.Element("AndroidTargetAPI", "android-" + std::string(api));
}
if (const char* cpuArch =
this->GeneratorTarget->GetProperty("ANDROID_ARCH")) {
- this->WriteString("<AndroidArch>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(cpuArch) << "</AndroidArch>\n";
+ e1.Element("AndroidArch", cpuArch);
}
if (const char* stlType =
this->GeneratorTarget->GetProperty("ANDROID_STL_TYPE")) {
- this->WriteString("<AndroidStlType>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(stlType)
- << "</AndroidStlType>\n";
+ e1.Element("AndroidStlType", stlType);
}
}
-void cmVisualStudio10TargetGenerator::WriteCustomCommands()
+void cmVisualStudio10TargetGenerator::WriteCustomCommands(Elem& e0)
{
- this->SourcesVisited.clear();
+ this->CSharpCustomCommandNames.clear();
std::vector<cmSourceFile const*> customCommands;
this->GeneratorTarget->GetCustomCommands(customCommands, "");
- for (std::vector<cmSourceFile const*>::const_iterator si =
- customCommands.begin();
- si != customCommands.end(); ++si) {
- this->WriteCustomCommand(*si);
+ for (cmSourceFile const* si : customCommands) {
+ this->WriteCustomCommand(e0, si);
+ }
+
+ // Add CMakeLists.txt file with rule to re-run CMake for user convenience.
+ if (this->GeneratorTarget->GetType() != cmStateEnums::GLOBAL_TARGET &&
+ this->GeneratorTarget->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
+ if (cmSourceFile const* sf =
+ this->LocalGenerator->CreateVCProjBuildRule()) {
+ // Write directly rather than through WriteCustomCommand because
+ // we do not want the de-duplication and it has no dependencies.
+ if (cmCustomCommand const* command = sf->GetCustomCommand()) {
+ this->WriteCustomRule(e0, sf, *command);
+ }
+ }
}
}
void cmVisualStudio10TargetGenerator::WriteCustomCommand(
- cmSourceFile const* sf)
+ Elem& e0, cmSourceFile const* sf)
{
- if (this->SourcesVisited.insert(sf).second) {
+ if (this->LocalGenerator->GetSourcesVisited(this->GeneratorTarget)
+ .insert(sf)
+ .second) {
if (std::vector<cmSourceFile*> const* depends =
this->GeneratorTarget->GetSourceDepends(sf)) {
- for (std::vector<cmSourceFile*>::const_iterator di = depends->begin();
- di != depends->end(); ++di) {
- this->WriteCustomCommand(*di);
+ for (cmSourceFile const* di : *depends) {
+ this->WriteCustomCommand(e0, di);
}
}
if (cmCustomCommand const* command = sf->GetCustomCommand()) {
- this->WriteString("<ItemGroup>\n", 1);
- this->WriteCustomRule(sf, *command);
- this->WriteString("</ItemGroup>\n", 1);
+ // C# projects write their <Target> within WriteCustomRule()
+ this->WriteCustomRule(e0, sf, *command);
}
}
}
void cmVisualStudio10TargetGenerator::WriteCustomRule(
- cmSourceFile const* source, cmCustomCommand const& command)
+ Elem& e0, cmSourceFile const* source, cmCustomCommand const& command)
{
std::string sourcePath = source->GetFullPath();
// VS 10 will always rebuild a custom command attached to a .rule
// file that doesn't exist so create the file explicitly.
if (source->GetPropertyAsBool("__CMAKE_RULE")) {
- if (!cmSystemTools::FileExists(sourcePath.c_str())) {
+ if (!cmSystemTools::FileExists(sourcePath)) {
// Make sure the path exists for the file
std::string path = cmSystemTools::GetFilenamePath(sourcePath);
- cmSystemTools::MakeDirectory(path.c_str());
+ cmSystemTools::MakeDirectory(path);
cmsys::ofstream fout(sourcePath.c_str());
if (fout) {
fout << "# generated from CMake\n";
@@ -1167,60 +1399,144 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
// preventing dependent rebuilds.
this->ForceOld(sourcePath);
} else {
- std::string error = "Could not create file: [";
- error += sourcePath;
- error += "] ";
- cmSystemTools::Error(error.c_str(),
- cmSystemTools::GetLastSystemError().c_str());
+ std::string error =
+ cmStrCat("Could not create file: [", sourcePath, "] ");
+ cmSystemTools::Error(error + cmSystemTools::GetLastSystemError());
}
}
}
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
- this->WriteSource("CustomBuild", source, ">\n");
-
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- cmCustomCommandGenerator ccg(command, *i, this->LocalGenerator);
+ std::unique_ptr<Elem> spe1;
+ std::unique_ptr<Elem> spe2;
+ if (this->ProjectType != csproj) {
+ spe1 = cm::make_unique<Elem>(e0, "ItemGroup");
+ spe2 = cm::make_unique<Elem>(*spe1, "CustomBuild");
+ this->WriteSource(*spe2, source);
+ spe2->SetHasElements();
+ } else {
+ Elem e1(e0, "ItemGroup");
+ Elem e2(e1, "None");
+ std::string link;
+ this->GetCSharpSourceLink(source, link);
+ this->WriteSource(e2, source);
+ e2.SetHasElements();
+ if (!link.empty()) {
+ e2.Element("Link", link);
+ }
+ }
+ for (std::string const& c : this->Configurations) {
+ cmCustomCommandGenerator ccg(command, c, lg);
std::string comment = lg->ConstructComment(ccg);
comment = cmVS10EscapeComment(comment);
- std::string script = cmVS10EscapeXML(lg->ConstructScript(ccg));
- this->WritePlatformConfigTag("Message", i->c_str(), 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(comment) << "</Message>\n";
- this->WritePlatformConfigTag("Command", i->c_str(), 3);
- (*this->BuildFileStream) << script << "</Command>\n";
- this->WritePlatformConfigTag("AdditionalInputs", i->c_str(), 3);
-
- (*this->BuildFileStream) << cmVS10EscapeXML(source->GetFullPath());
- for (std::vector<std::string>::const_iterator d = ccg.GetDepends().begin();
- d != ccg.GetDepends().end(); ++d) {
- std::string dep;
- if (this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(),
- dep)) {
- this->ConvertToWindowsSlash(dep);
- (*this->BuildFileStream) << ";" << cmVS10EscapeXML(dep);
+ std::string script = lg->ConstructScript(ccg);
+ bool symbolic = false;
+ // input files for custom command
+ std::stringstream additional_inputs;
+ {
+ const char* sep = "";
+ if (this->ProjectType == csproj) {
+ // csproj files do not attach the command to a specific file
+ // so the primary input must be listed explicitly.
+ additional_inputs << source->GetFullPath();
+ sep = ";";
+ }
+
+ // Avoid listing an input more than once.
+ std::set<std::string> unique_inputs;
+ // The source is either implicit an input or has been added above.
+ unique_inputs.insert(source->GetFullPath());
+
+ for (std::string const& d : ccg.GetDepends()) {
+ std::string dep;
+ if (lg->GetRealDependency(d, c, dep)) {
+ if (!unique_inputs.insert(dep).second) {
+ // already listed
+ continue;
+ }
+ ConvertToWindowsSlash(dep);
+ additional_inputs << sep << dep;
+ sep = ";";
+ if (!symbolic) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(
+ dep, cmSourceFileLocationKind::Known)) {
+ symbolic = sf->GetPropertyAsBool("SYMBOLIC");
+ }
+ }
+ }
+ }
+ if (this->ProjectType != csproj) {
+ additional_inputs << sep << "%(AdditionalInputs)";
}
}
- (*this->BuildFileStream) << ";%(AdditionalInputs)</AdditionalInputs>\n";
- this->WritePlatformConfigTag("Outputs", i->c_str(), 3);
- const char* sep = "";
- for (std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin();
- o != ccg.GetOutputs().end(); ++o) {
- std::string out = *o;
- this->ConvertToWindowsSlash(out);
- (*this->BuildFileStream) << sep << cmVS10EscapeXML(out);
- sep = ";";
- }
- (*this->BuildFileStream) << "</Outputs>\n";
- if (this->LocalGenerator->GetVersion() >
- cmGlobalVisualStudioGenerator::VS10) {
- // VS >= 11 let us turn off linking of custom command outputs.
- this->WritePlatformConfigTag("LinkObjects", i->c_str(), 3);
- (*this->BuildFileStream) << "false</LinkObjects>\n";
- }
- }
- this->WriteString("</CustomBuild>\n", 2);
+ // output files for custom command
+ std::stringstream outputs;
+ {
+ const char* sep = "";
+ for (std::string const& o : ccg.GetOutputs()) {
+ std::string out = o;
+ ConvertToWindowsSlash(out);
+ outputs << sep << out;
+ sep = ";";
+ if (!symbolic) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(
+ o, cmSourceFileLocationKind::Known)) {
+ symbolic = sf->GetPropertyAsBool("SYMBOLIC");
+ }
+ }
+ }
+ }
+ if (this->ProjectType == csproj) {
+ std::string name = "CustomCommand_" + c + "_" +
+ cmSystemTools::ComputeStringMD5(sourcePath);
+ this->WriteCustomRuleCSharp(e0, c, name, script, additional_inputs.str(),
+ outputs.str(), comment);
+ } else {
+ this->WriteCustomRuleCpp(*spe2, c, script, additional_inputs.str(),
+ outputs.str(), comment, symbolic);
+ }
+ }
+}
+
+void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp(
+ Elem& e2, std::string const& config, std::string const& script,
+ std::string const& additional_inputs, std::string const& outputs,
+ std::string const& comment, bool symbolic)
+{
+ const std::string cond = this->CalcCondition(config);
+ e2.WritePlatformConfigTag("Message", cond, comment);
+ e2.WritePlatformConfigTag("Command", cond, script);
+ e2.WritePlatformConfigTag("AdditionalInputs", cond, additional_inputs);
+ e2.WritePlatformConfigTag("Outputs", cond, outputs);
+ if (this->LocalGenerator->GetVersion() >
+ cmGlobalVisualStudioGenerator::VS10) {
+ // VS >= 11 let us turn off linking of custom command outputs.
+ e2.WritePlatformConfigTag("LinkObjects", cond, "false");
+ }
+ if (symbolic &&
+ this->LocalGenerator->GetVersion() >=
+ cmGlobalVisualStudioGenerator::VS16) {
+ // VS >= 16.4 warn if outputs are not created, but one of our
+ // outputs is marked SYMBOLIC and not expected to be created.
+ e2.WritePlatformConfigTag("VerifyInputsAndOutputsExist", cond, "false");
+ }
+}
+
+void cmVisualStudio10TargetGenerator::WriteCustomRuleCSharp(
+ Elem& e0, std::string const& config, std::string const& name,
+ std::string const& script, std::string const& inputs,
+ std::string const& outputs, std::string const& comment)
+{
+ this->CSharpCustomCommandNames.insert(name);
+ Elem e1(e0, "Target");
+ e1.Attribute("Condition", this->CalcCondition(config));
+ e1.S << "\n Name=\"" << name << "\"";
+ e1.S << "\n Inputs=\"" << cmVS10EscapeAttr(inputs) << "\"";
+ e1.S << "\n Outputs=\"" << cmVS10EscapeAttr(outputs) << "\"";
+ if (!comment.empty()) {
+ Elem(e1, "Exec").Attribute("Command", "echo " + comment);
+ }
+ Elem(e1, "Exec").Attribute("Command", script);
}
std::string cmVisualStudio10TargetGenerator::ConvertPath(
@@ -1228,22 +1544,23 @@ std::string cmVisualStudio10TargetGenerator::ConvertPath(
{
return forceRelative
? cmSystemTools::RelativePath(
- this->LocalGenerator->GetCurrentBinaryDirectory(), path.c_str())
- : path.c_str();
+ this->LocalGenerator->GetCurrentBinaryDirectory(), path)
+ : path;
}
-void cmVisualStudio10TargetGenerator::ConvertToWindowsSlash(std::string& s)
+static void ConvertToWindowsSlash(std::string& s)
{
// first convert all of the slashes
- std::string::size_type pos = 0;
- while ((pos = s.find('/', pos)) != std::string::npos) {
- s[pos] = '\\';
- pos++;
+ for (auto& ch : s) {
+ if (ch == '/') {
+ ch = '\\';
+ }
}
}
+
void cmVisualStudio10TargetGenerator::WriteGroups()
{
- if (csproj == this->ProjectType) {
+ if (this->ProjectType == csproj) {
return;
}
@@ -1253,132 +1570,119 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
std::vector<cmGeneratorTarget::AllConfigSource> const& sources =
this->GeneratorTarget->GetAllConfigSources();
- std::set<cmSourceGroup*> groupsUsed;
- for (std::vector<cmGeneratorTarget::AllConfigSource>::const_iterator si =
- sources.begin();
- si != sources.end(); ++si) {
- std::string const& source = si->Source->GetFullPath();
+ std::set<cmSourceGroup const*> groupsUsed;
+ for (cmGeneratorTarget::AllConfigSource const& si : sources) {
+ std::string const& source = si.Source->GetFullPath();
cmSourceGroup* sourceGroup =
- this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
+ this->Makefile->FindSourceGroup(source, sourceGroups);
+ groupsUsed.insert(sourceGroup);
+ }
+
+ if (cmSourceFile const* srcCMakeLists =
+ this->LocalGenerator->CreateVCProjBuildRule()) {
+ std::string const& source = srcCMakeLists->GetFullPath();
+ cmSourceGroup* sourceGroup =
+ this->Makefile->FindSourceGroup(source, sourceGroups);
groupsUsed.insert(sourceGroup);
}
this->AddMissingSourceGroups(groupsUsed, sourceGroups);
// Write out group file
- std::string path = this->LocalGenerator->GetCurrentBinaryDirectory();
- path += "/";
- path += this->Name;
- path += computeProjectFileExtension(this->GeneratorTarget);
- path += ".filters";
- cmGeneratedFileStream fout(path.c_str());
+ std::string path = cmStrCat(
+ this->LocalGenerator->GetCurrentBinaryDirectory(), '/', this->Name,
+ computeProjectFileExtension(this->GeneratorTarget), ".filters");
+ cmGeneratedFileStream fout(path);
fout.SetCopyIfDifferent(true);
char magic[] = { char(0xEF), char(0xBB), char(0xBF) };
fout.write(magic, 3);
- cmGeneratedFileStream* save = this->BuildFileStream;
- this->BuildFileStream = &fout;
-
- // get the tools version to use
- const std::string toolsVer(this->GlobalGenerator->GetToolsVersion());
- std::string project_defaults = "<?xml version=\"1.0\" encoding=\"" +
- this->GlobalGenerator->Encoding() + "\"?>\n";
- project_defaults.append("<Project ToolsVersion=\"");
- project_defaults.append(toolsVer + "\" ");
- project_defaults.append(
- "xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n");
- this->WriteString(project_defaults.c_str(), 0);
-
- for (ToolSourceMap::const_iterator ti = this->Tools.begin();
- ti != this->Tools.end(); ++ti) {
- this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups);
- }
-
- // Added files are images and the manifest.
- if (!this->AddedFiles.empty()) {
- this->WriteString("<ItemGroup>\n", 1);
- for (std::vector<std::string>::const_iterator oi =
- this->AddedFiles.begin();
- oi != this->AddedFiles.end(); ++oi) {
- std::string fileName =
- cmSystemTools::LowerCase(cmSystemTools::GetFilenameName(*oi));
- if (fileName == "wmappmanifest.xml") {
- this->WriteString("<XML Include=\"", 2);
- (*this->BuildFileStream) << *oi << "\">\n";
- this->WriteString("<Filter>Resource Files</Filter>\n", 3);
- this->WriteString("</XML>\n", 2);
- } else if (cmSystemTools::GetFilenameExtension(fileName) ==
- ".appxmanifest") {
- this->WriteString("<AppxManifest Include=\"", 2);
- (*this->BuildFileStream) << *oi << "\">\n";
- this->WriteString("<Filter>Resource Files</Filter>\n", 3);
- this->WriteString("</AppxManifest>\n", 2);
- } else if (cmSystemTools::GetFilenameExtension(fileName) == ".pfx") {
- this->WriteString("<None Include=\"", 2);
- (*this->BuildFileStream) << *oi << "\">\n";
- this->WriteString("<Filter>Resource Files</Filter>\n", 3);
- this->WriteString("</None>\n", 2);
- } else {
- this->WriteString("<Image Include=\"", 2);
- (*this->BuildFileStream) << *oi << "\">\n";
- this->WriteString("<Filter>Resource Files</Filter>\n", 3);
- this->WriteString("</Image>\n", 2);
+
+ fout << "<?xml version=\"1.0\" encoding=\""
+ << this->GlobalGenerator->Encoding() << "\"?>"
+ << "\n";
+ {
+ Elem e0(fout, "Project");
+ e0.Attribute("ToolsVersion", this->GlobalGenerator->GetToolsVersion());
+ e0.Attribute("xmlns",
+ "http://schemas.microsoft.com/developer/msbuild/2003");
+
+ for (auto const& ti : this->Tools) {
+ this->WriteGroupSources(e0, ti.first, ti.second, sourceGroups);
+ }
+
+ // Added files are images and the manifest.
+ if (!this->AddedFiles.empty()) {
+ Elem e1(e0, "ItemGroup");
+ e1.SetHasElements();
+ for (std::string const& oi : this->AddedFiles) {
+ std::string fileName =
+ cmSystemTools::LowerCase(cmSystemTools::GetFilenameName(oi));
+ if (fileName == "wmappmanifest.xml") {
+ Elem e2(e1, "XML");
+ e2.Attribute("Include", oi);
+ e2.Element("Filter", "Resource Files");
+ } else if (cmSystemTools::GetFilenameExtension(fileName) ==
+ ".appxmanifest") {
+ Elem e2(e1, "AppxManifest");
+ e2.Attribute("Include", oi);
+ e2.Element("Filter", "Resource Files");
+ } else if (cmSystemTools::GetFilenameExtension(fileName) == ".pfx") {
+ Elem e2(e1, "None");
+ e2.Attribute("Include", oi);
+ e2.Element("Filter", "Resource Files");
+ } else {
+ Elem e2(e1, "Image");
+ e2.Attribute("Include", oi);
+ e2.Element("Filter", "Resource Files");
+ }
}
}
- this->WriteString("</ItemGroup>\n", 1);
- }
- std::vector<cmSourceFile const*> resxObjs;
- this->GeneratorTarget->GetResxSources(resxObjs, "");
- if (!resxObjs.empty()) {
- this->WriteString("<ItemGroup>\n", 1);
- for (std::vector<cmSourceFile const*>::const_iterator oi =
- resxObjs.begin();
- oi != resxObjs.end(); ++oi) {
- std::string obj = (*oi)->GetFullPath();
- this->WriteString("<EmbeddedResource Include=\"", 2);
- this->ConvertToWindowsSlash(obj);
- (*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\">\n";
- this->WriteString("<Filter>Resource Files</Filter>\n", 3);
- this->WriteString("</EmbeddedResource>\n", 2);
- }
- this->WriteString("</ItemGroup>\n", 1);
- }
-
- this->WriteString("<ItemGroup>\n", 1);
- for (std::set<cmSourceGroup*>::iterator g = groupsUsed.begin();
- g != groupsUsed.end(); ++g) {
- cmSourceGroup* sg = *g;
- const char* name = sg->GetFullName();
- if (strlen(name) != 0) {
- this->WriteString("<Filter Include=\"", 2);
- (*this->BuildFileStream) << name << "\">\n";
- std::string guidName = "SG_Filter_";
- guidName += name;
- this->WriteString("<UniqueIdentifier>", 3);
- std::string guid = this->GlobalGenerator->GetGUID(guidName.c_str());
- (*this->BuildFileStream) << "{" << guid << "}"
- << "</UniqueIdentifier>\n";
- this->WriteString("</Filter>\n", 2);
- }
- }
-
- if (!resxObjs.empty() || !this->AddedFiles.empty()) {
- this->WriteString("<Filter Include=\"Resource Files\">\n", 2);
- std::string guidName = "SG_Filter_Resource Files";
- this->WriteString("<UniqueIdentifier>", 3);
- std::string guid = this->GlobalGenerator->GetGUID(guidName.c_str());
- (*this->BuildFileStream) << "{" << guid << "}"
- << "</UniqueIdentifier>\n";
- this->WriteString("<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;", 3);
- (*this->BuildFileStream) << "gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;";
- (*this->BuildFileStream) << "mfcribbon-ms</Extensions>\n";
- this->WriteString("</Filter>\n", 2);
- }
-
- this->WriteString("</ItemGroup>\n", 1);
- this->WriteString("</Project>\n", 0);
- // restore stream pointer
- this->BuildFileStream = save;
+ std::vector<cmSourceFile const*> resxObjs;
+ this->GeneratorTarget->GetResxSources(resxObjs, "");
+ if (!resxObjs.empty()) {
+ Elem e1(e0, "ItemGroup");
+ for (cmSourceFile const* oi : resxObjs) {
+ std::string obj = oi->GetFullPath();
+ ConvertToWindowsSlash(obj);
+ Elem e2(e1, "EmbeddedResource");
+ e2.Attribute("Include", obj);
+ e2.Element("Filter", "Resource Files");
+ }
+ }
+ {
+ Elem e1(e0, "ItemGroup");
+ e1.SetHasElements();
+ std::vector<cmSourceGroup const*> groupsVec(groupsUsed.begin(),
+ groupsUsed.end());
+ std::sort(groupsVec.begin(), groupsVec.end(),
+ [](cmSourceGroup const* l, cmSourceGroup const* r) {
+ return l->GetFullName() < r->GetFullName();
+ });
+ for (cmSourceGroup const* sg : groupsVec) {
+ std::string const& name = sg->GetFullName();
+ if (!name.empty()) {
+ std::string guidName = "SG_Filter_" + name;
+ std::string guid = this->GlobalGenerator->GetGUID(guidName);
+ Elem e2(e1, "Filter");
+ e2.Attribute("Include", name);
+ e2.Element("UniqueIdentifier", "{" + guid + "}");
+ }
+ }
+
+ if (!resxObjs.empty() || !this->AddedFiles.empty()) {
+ std::string guidName = "SG_Filter_Resource Files";
+ std::string guid = this->GlobalGenerator->GetGUID(guidName);
+ Elem e2(e1, "Filter");
+ e2.Attribute("Include", "Resource Files");
+ e2.Element("UniqueIdentifier", "{" + guid + "}");
+ e2.Element("Extensions",
+ "rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;"
+ "gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms");
+ }
+ }
+ }
+ fout << '\n';
if (fout.Close()) {
this->GlobalGenerator->FileReplacedDuringGenerate(path);
@@ -1387,29 +1691,26 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
// Add to groupsUsed empty source groups that have non-empty children.
void cmVisualStudio10TargetGenerator::AddMissingSourceGroups(
- std::set<cmSourceGroup*>& groupsUsed,
+ std::set<cmSourceGroup const*>& groupsUsed,
const std::vector<cmSourceGroup>& allGroups)
{
- for (std::vector<cmSourceGroup>::const_iterator current = allGroups.begin();
- current != allGroups.end(); ++current) {
- std::vector<cmSourceGroup> const& children = current->GetGroupChildren();
+ for (cmSourceGroup const& current : allGroups) {
+ std::vector<cmSourceGroup> const& children = current.GetGroupChildren();
if (children.empty()) {
continue; // the group is really empty
}
this->AddMissingSourceGroups(groupsUsed, children);
- cmSourceGroup* current_ptr = const_cast<cmSourceGroup*>(&(*current));
- if (groupsUsed.find(current_ptr) != groupsUsed.end()) {
+ if (groupsUsed.count(&current) > 0) {
continue; // group has already been added to set
}
// check if it least one of the group's descendants is not empty
// (at least one child must already have been added)
- std::vector<cmSourceGroup>::const_iterator child_it = children.begin();
+ auto child_it = children.begin();
while (child_it != children.end()) {
- cmSourceGroup* child_ptr = const_cast<cmSourceGroup*>(&(*child_it));
- if (groupsUsed.find(child_ptr) != groupsUsed.end()) {
+ if (groupsUsed.count(&(*child_it)) > 0) {
break; // found a child that was already added => add current group too
}
child_it++;
@@ -1419,65 +1720,60 @@ void cmVisualStudio10TargetGenerator::AddMissingSourceGroups(
continue; // no descendants have source files => ignore this group
}
- groupsUsed.insert(current_ptr);
+ groupsUsed.insert(&current);
}
}
void cmVisualStudio10TargetGenerator::WriteGroupSources(
- const char* name, ToolSources const& sources,
+ Elem& e0, std::string const& name, ToolSources const& sources,
std::vector<cmSourceGroup>& sourceGroups)
{
- this->WriteString("<ItemGroup>\n", 1);
- for (ToolSources::const_iterator s = sources.begin(); s != sources.end();
- ++s) {
- cmSourceFile const* sf = s->SourceFile;
+ Elem e1(e0, "ItemGroup");
+ e1.SetHasElements();
+ for (ToolSource const& s : sources) {
+ cmSourceFile const* sf = s.SourceFile;
std::string const& source = sf->GetFullPath();
cmSourceGroup* sourceGroup =
- this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
- const char* filter = sourceGroup->GetFullName();
- this->WriteString("<", 2);
- std::string path = this->ConvertPath(source, s->RelativePath);
- this->ConvertToWindowsSlash(path);
- (*this->BuildFileStream) << name << " Include=\"" << cmVS10EscapeXML(path);
- if (strlen(filter)) {
- (*this->BuildFileStream) << "\">\n";
- this->WriteString("<Filter>", 3);
- (*this->BuildFileStream) << filter << "</Filter>\n";
- this->WriteString("</", 2);
- (*this->BuildFileStream) << name << ">\n";
- } else {
- (*this->BuildFileStream) << "\" />\n";
+ this->Makefile->FindSourceGroup(source, sourceGroups);
+ std::string const& filter = sourceGroup->GetFullName();
+ std::string path = this->ConvertPath(source, s.RelativePath);
+ ConvertToWindowsSlash(path);
+ Elem e2(e1, name.c_str());
+ e2.Attribute("Include", path);
+ if (!filter.empty()) {
+ e2.Element("Filter", filter);
}
}
- this->WriteString("</ItemGroup>\n", 1);
}
-void cmVisualStudio10TargetGenerator::WriteHeaderSource(cmSourceFile const* sf)
+void cmVisualStudio10TargetGenerator::WriteHeaderSource(Elem& e1,
+ cmSourceFile const* sf)
{
std::string const& fileName = sf->GetFullPath();
+ Elem e2(e1, "ClInclude");
+ this->WriteSource(e2, sf);
if (this->IsResxHeader(fileName)) {
- this->WriteSource("ClInclude", sf, ">\n");
- this->WriteString("<FileType>CppForm</FileType>\n", 3);
- this->WriteString("</ClInclude>\n", 2);
+ e2.Element("FileType", "CppForm");
} else if (this->IsXamlHeader(fileName)) {
- this->WriteSource("ClInclude", sf, ">\n");
- this->WriteString("<DependentUpon>", 3);
std::string xamlFileName = fileName.substr(0, fileName.find_last_of("."));
- (*this->BuildFileStream) << xamlFileName << "</DependentUpon>\n";
- this->WriteString("</ClInclude>\n", 2);
- } else {
- this->WriteSource("ClInclude", sf);
+ e2.Element("DependentUpon", xamlFileName);
}
}
-void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
+void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
+ cmSourceFile const* sf)
{
bool toolHasSettings = false;
- std::string tool = "None";
+ const char* tool = "None";
std::string shaderType;
std::string shaderEntryPoint;
std::string shaderModel;
std::string shaderAdditionalFlags;
+ std::string shaderDisableOptimizations;
+ std::string shaderEnableDebug;
+ std::string shaderObjectFileName;
+ std::string outputHeaderFile;
+ std::string variableName;
std::string settingsGenerator;
std::string settingsLastGenOutput;
std::string sourceLink;
@@ -1485,7 +1781,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
std::string copyToOutDir;
std::string includeInVsix;
std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
- if (csproj == this->ProjectType) {
+ if (this->ProjectType == csproj) {
// EVERY extra source file must have a <Link>, otherwise it might not
// be visible in Visual Studio at all. The path relative to current
// source- or binary-dir is used within the link, if the file is
@@ -1498,7 +1794,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
std::string srcDir = this->Makefile->GetCurrentSourceDirectory();
std::string binDir = this->Makefile->GetCurrentBinaryDirectory();
if (fullFileName.find(binDir) != std::string::npos) {
- sourceLink = "";
+ sourceLink.clear();
} else if (fullFileName.find(srcDir) != std::string::npos) {
sourceLink = fullFileName.substr(srcDir.length() + 1);
} else {
@@ -1506,7 +1802,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
sourceLink = cmsys::SystemTools::GetFilenameName(fullFileName);
}
if (!sourceLink.empty()) {
- this->ConvertToWindowsSlash(sourceLink);
+ ConvertToWindowsSlash(sourceLink);
}
}
}
@@ -1527,11 +1823,35 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
shaderModel = sm;
toolHasSettings = true;
}
+ // Figure out which output header file to use if any
+ if (const char* ohf = sf->GetProperty("VS_SHADER_OUTPUT_HEADER_FILE")) {
+ outputHeaderFile = ohf;
+ toolHasSettings = true;
+ }
+ // Figure out which variable name to use if any
+ if (const char* vn = sf->GetProperty("VS_SHADER_VARIABLE_NAME")) {
+ variableName = vn;
+ toolHasSettings = true;
+ }
// Figure out if there's any additional flags to use
if (const char* saf = sf->GetProperty("VS_SHADER_FLAGS")) {
shaderAdditionalFlags = saf;
toolHasSettings = true;
}
+ // Figure out if debug information should be generated
+ if (const char* sed = sf->GetProperty("VS_SHADER_ENABLE_DEBUG")) {
+ shaderEnableDebug = sed;
+ toolHasSettings = true;
+ }
+ // Figure out if optimizations should be disabled
+ if (const char* sdo = sf->GetProperty("VS_SHADER_DISABLE_OPTIMIZATIONS")) {
+ shaderDisableOptimizations = sdo;
+ toolHasSettings = true;
+ }
+ if (const char* sofn = sf->GetProperty("VS_SHADER_OBJECT_FILE_NAME")) {
+ shaderObjectFileName = sofn;
+ toolHasSettings = true;
+ }
} else if (ext == "jpg" || ext == "png") {
tool = "Image";
} else if (ext == "resw") {
@@ -1541,12 +1861,8 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
} else if (ext == "natvis") {
tool = "Natvis";
} else if (ext == "settings") {
- // remove path to current source dir (if files are in current source dir)
- if (!sourceLink.empty()) {
- settingsLastGenOutput = sourceLink;
- } else {
- settingsLastGenOutput = sf->GetFullPath();
- }
+ settingsLastGenOutput =
+ cmsys::SystemTools::GetFilenameName(sf->GetFullPath());
std::size_t pos = settingsLastGenOutput.find(".settings");
settingsLastGenOutput.replace(pos, 9, ".Designer.cs");
settingsGenerator = "SettingsSingleFileGenerator";
@@ -1555,6 +1871,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
subType = "Designer";
}
if (const char* c = sf->GetProperty("VS_COPY_TO_OUT_DIR")) {
+ tool = "Content";
copyToOutDir = c;
toolHasSettings = true;
}
@@ -1564,6 +1881,10 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
toolHasSettings = true;
}
+ // Collect VS_CSHARP_* property values (if some are set)
+ std::map<std::string, std::string> sourceFileTags;
+ this->GetCSharpSourceProperties(sf, sourceFileTags);
+
if (this->NsightTegra) {
// Nsight Tegra needs specific file types to check up-to-dateness.
std::string name = cmSystemTools::LowerCase(sf->GetLocation().GetName());
@@ -1599,98 +1920,128 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
}
}
+ Elem e2(e1, tool);
+ this->WriteSource(e2, sf);
if (toolHasSettings) {
- this->WriteSource(tool, sf, ">\n");
+ e2.SetHasElements();
if (!deployContent.empty()) {
cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(deployContent);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
+ ge.Parse(deployContent);
// Deployment location cannot be set on a configuration basis
if (!deployLocation.empty()) {
- this->WriteString("<Link>", 3);
- (*this->BuildFileStream) << deployLocation
- << "\\%(FileName)%(Extension)";
- this->WriteString("</Link>\n", 0);
+ e2.Element("Link", deployLocation + "\\%(FileName)%(Extension)");
}
for (size_t i = 0; i != this->Configurations.size(); ++i) {
- if (0 == strcmp(cge->Evaluate(this->LocalGenerator,
- this->Configurations[i]),
- "1")) {
- this->WriteString("<DeploymentContent Condition=\""
- "'$(Configuration)|$(Platform)'=='",
- 3);
- (*this->BuildFileStream) << this->Configurations[i] << "|"
- << this->Platform << "'\">true";
- this->WriteString("</DeploymentContent>\n", 0);
+ if (cge->Evaluate(this->LocalGenerator, this->Configurations[i]) ==
+ "1") {
+ e2.WritePlatformConfigTag("DeploymentContent",
+ "'$(Configuration)|$(Platform)'=='" +
+ this->Configurations[i] + "|" +
+ this->Platform + "'",
+ "true");
} else {
- this->WriteString("<ExcludedFromBuild Condition=\""
- "'$(Configuration)|$(Platform)'=='",
- 3);
- (*this->BuildFileStream) << this->Configurations[i] << "|"
- << this->Platform << "'\">true";
- this->WriteString("</ExcludedFromBuild>\n", 0);
+ e2.WritePlatformConfigTag("ExcludedFromBuild",
+ "'$(Configuration)|$(Platform)'=='" +
+ this->Configurations[i] + "|" +
+ this->Platform + "'",
+ "true");
}
}
}
if (!shaderType.empty()) {
- this->WriteString("<ShaderType>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(shaderType)
- << "</ShaderType>\n";
+ e2.Element("ShaderType", shaderType);
}
if (!shaderEntryPoint.empty()) {
- this->WriteString("<EntryPointName>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(shaderEntryPoint)
- << "</EntryPointName>\n";
+ e2.Element("EntryPointName", shaderEntryPoint);
}
if (!shaderModel.empty()) {
- this->WriteString("<ShaderModel>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(shaderModel)
- << "</ShaderModel>\n";
+ e2.Element("ShaderModel", shaderModel);
+ }
+ if (!outputHeaderFile.empty()) {
+ for (size_t i = 0; i != this->Configurations.size(); ++i) {
+ e2.WritePlatformConfigTag("HeaderFileOutput",
+ "'$(Configuration)|$(Platform)'=='" +
+ this->Configurations[i] + "|" +
+ this->Platform + "'",
+ outputHeaderFile);
+ }
+ }
+ if (!variableName.empty()) {
+ for (size_t i = 0; i != this->Configurations.size(); ++i) {
+ e2.WritePlatformConfigTag("VariableName",
+ "'$(Configuration)|$(Platform)'=='" +
+ this->Configurations[i] + "|" +
+ this->Platform + "'",
+ variableName);
+ }
+ }
+ if (!shaderEnableDebug.empty()) {
+ cmGeneratorExpression ge;
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
+ ge.Parse(shaderEnableDebug);
+
+ for (size_t i = 0; i != this->Configurations.size(); ++i) {
+ const std::string& enableDebug =
+ cge->Evaluate(this->LocalGenerator, this->Configurations[i]);
+ if (!enableDebug.empty()) {
+ e2.WritePlatformConfigTag("EnableDebuggingInformation",
+ "'$(Configuration)|$(Platform)'=='" +
+ this->Configurations[i] + "|" +
+ this->Platform + "'",
+ cmIsOn(enableDebug) ? "true" : "false");
+ }
+ }
+ }
+ if (!shaderDisableOptimizations.empty()) {
+ cmGeneratorExpression ge;
+ std::unique_ptr<cmCompiledGeneratorExpression> cge =
+ ge.Parse(shaderDisableOptimizations);
+
+ for (size_t i = 0; i != this->Configurations.size(); ++i) {
+ const std::string& disableOptimizations =
+ cge->Evaluate(this->LocalGenerator, this->Configurations[i]);
+ if (!disableOptimizations.empty()) {
+ e2.WritePlatformConfigTag(
+ "DisableOptimizations",
+ "'$(Configuration)|$(Platform)'=='" + this->Configurations[i] +
+ "|" + this->Platform + "'",
+ (cmIsOn(disableOptimizations) ? "true" : "false"));
+ }
+ }
+ }
+ if (!shaderObjectFileName.empty()) {
+ e2.Element("ObjectFileOutput", shaderObjectFileName);
}
if (!shaderAdditionalFlags.empty()) {
- this->WriteString("<AdditionalOptions>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(shaderAdditionalFlags)
- << "</AdditionalOptions>\n";
+ e2.Element("AdditionalOptions", shaderAdditionalFlags);
}
if (!settingsGenerator.empty()) {
- this->WriteString("<Generator>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(settingsGenerator)
- << "</Generator>\n";
+ e2.Element("Generator", settingsGenerator);
}
if (!settingsLastGenOutput.empty()) {
- this->WriteString("<LastGenOutput>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(settingsLastGenOutput)
- << "</LastGenOutput>\n";
+ e2.Element("LastGenOutput", settingsLastGenOutput);
}
if (!sourceLink.empty()) {
- this->WriteString("<Link>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(sourceLink) << "</Link>\n";
+ e2.Element("Link", sourceLink);
}
if (!subType.empty()) {
- this->WriteString("<SubType>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(subType) << "</SubType>\n";
+ e2.Element("SubType", subType);
}
if (!copyToOutDir.empty()) {
- this->WriteString("<CopyToOutputDirectory>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(copyToOutDir)
- << "</CopyToOutputDirectory>\n";
+ e2.Element("CopyToOutputDirectory", copyToOutDir);
}
if (!includeInVsix.empty()) {
- this->WriteString("<IncludeInVSIX>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(includeInVsix)
- << "</IncludeInVSIX>\n";
+ e2.Element("IncludeInVSIX", includeInVsix);
}
-
- this->WriteString("</", 2);
- (*this->BuildFileStream) << tool << ">\n";
- } else {
- this->WriteSource(tool, sf);
+ // write source file specific tags
+ this->WriteCSharpSourceProperties(e2, sourceFileTags);
}
}
-void cmVisualStudio10TargetGenerator::WriteSource(std::string const& tool,
- cmSourceFile const* sf,
- const char* end)
+void cmVisualStudio10TargetGenerator::WriteSource(Elem& e2,
+ cmSourceFile const* sf)
{
// Visual Studio tools append relative paths to the current dir, as in:
//
@@ -1704,7 +2055,7 @@ void cmVisualStudio10TargetGenerator::WriteSource(std::string const& tool,
std::string sourceFile = this->ConvertPath(sf->GetFullPath(), forceRelative);
if (this->LocalGenerator->GetVersion() ==
cmGlobalVisualStudioGenerator::VS10 &&
- cmSystemTools::FileIsFullPath(sourceFile.c_str())) {
+ cmSystemTools::FileIsFullPath(sourceFile)) {
// Normal path conversion resulted in a full path. VS 10 (but not 11)
// refuses to show the property page in the IDE for a source file with a
// full path (not starting in a '.' or '/' AFAICT). CMake <= 2.8.4 used a
@@ -1716,7 +2067,7 @@ void cmVisualStudio10TargetGenerator::WriteSource(std::string const& tool,
std::string sourceRel = this->ConvertPath(sf->GetFullPath(), true);
size_t const maxLen = 250;
if (sf->GetCustomCommand() ||
- ((strlen(this->LocalGenerator->GetCurrentBinaryDirectory()) + 1 +
+ ((this->LocalGenerator->GetCurrentBinaryDirectory().length() + 1 +
sourceRel.length()) <= maxLen)) {
forceRelative = true;
sourceFile = sourceRel;
@@ -1724,22 +2075,29 @@ void cmVisualStudio10TargetGenerator::WriteSource(std::string const& tool,
this->GlobalGenerator->PathTooLong(this->GeneratorTarget, sf, sourceRel);
}
}
- this->ConvertToWindowsSlash(sourceFile);
- this->WriteString("<", 2);
- (*this->BuildFileStream) << tool << " Include=\""
- << cmVS10EscapeXML(sourceFile) << "\""
- << (end ? end : " />\n");
+ ConvertToWindowsSlash(sourceFile);
+ e2.Attribute("Include", sourceFile);
ToolSource toolSource = { sf, forceRelative };
- this->Tools[tool].push_back(toolSource);
+ this->Tools[e2.Tag].push_back(toolSource);
}
-void cmVisualStudio10TargetGenerator::WriteAllSources()
+void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
{
if (this->GeneratorTarget->GetType() > cmStateEnums::UTILITY) {
return;
}
- this->WriteString("<ItemGroup>\n", 1);
+
+ const bool haveUnityBuild =
+ this->GeneratorTarget->GetPropertyAsBool("UNITY_BUILD");
+
+ if (haveUnityBuild && this->GlobalGenerator->GetSupportsUnityBuilds()) {
+ Elem e1(e0, "PropertyGroup");
+ e1.Element("EnableUnitySupport", "true");
+ }
+
+ Elem e1(e0, "ItemGroup");
+ e1.SetHasElements();
std::vector<size_t> all_configs;
for (size_t ci = 0; ci < this->Configurations.size(); ++ci) {
@@ -1749,11 +2107,16 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
std::vector<cmGeneratorTarget::AllConfigSource> const& sources =
this->GeneratorTarget->GetAllConfigSources();
- for (std::vector<cmGeneratorTarget::AllConfigSource>::const_iterator si =
- sources.begin();
- si != sources.end(); ++si) {
- std::string tool;
- switch (si->Kind) {
+ cmSourceFile const* srcCMakeLists =
+ this->LocalGenerator->CreateVCProjBuildRule();
+
+ for (cmGeneratorTarget::AllConfigSource const& si : sources) {
+ if (si.Source == srcCMakeLists) {
+ // Skip explicit reference to CMakeLists.txt source.
+ continue;
+ }
+ const char* tool = nullptr;
+ switch (si.Kind) {
case cmGeneratorTarget::SourceKindAppManifest:
tool = "AppxManifest";
break;
@@ -1772,17 +2135,17 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
// then vs10 will use it in the build, and we have to list it as
// None instead of Object.
std::vector<cmSourceFile*> const* d =
- this->GeneratorTarget->GetSourceDepends(si->Source);
+ this->GeneratorTarget->GetSourceDepends(si.Source);
if (d && !d->empty()) {
tool = "None";
}
}
break;
case cmGeneratorTarget::SourceKindExtra:
- this->WriteExtraSource(si->Source);
+ this->WriteExtraSource(e1, si.Source);
break;
case cmGeneratorTarget::SourceKindHeader:
- this->WriteHeaderSource(si->Source);
+ this->WriteHeaderSource(e1, si.Source);
break;
case cmGeneratorTarget::SourceKindIDL:
tool = "Midl";
@@ -1793,8 +2156,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
case cmGeneratorTarget::SourceKindModuleDefinition:
tool = "None";
break;
+ case cmGeneratorTarget::SourceKindUnityBatched:
case cmGeneratorTarget::SourceKindObjectSource: {
- const std::string& lang = si->Source->GetLanguage();
+ const std::string& lang = si.Source->GetLanguage();
if (lang == "C" || lang == "CXX") {
tool = "ClCompile";
} else if (lang == "ASM_MASM" &&
@@ -1821,51 +2185,72 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
break;
}
- if (!tool.empty()) {
+ if (tool) {
// Compute set of configurations to exclude, if any.
- std::vector<size_t> const& include_configs = si->Configs;
+ std::vector<size_t> const& include_configs = si.Configs;
std::vector<size_t> exclude_configs;
std::set_difference(all_configs.begin(), all_configs.end(),
include_configs.begin(), include_configs.end(),
std::back_inserter(exclude_configs));
- if (si->Kind == cmGeneratorTarget::SourceKindObjectSource) {
- // FIXME: refactor generation to avoid tracking XML syntax state.
- this->WriteSource(tool, si->Source, " ");
- bool have_nested = this->OutputSourceSpecificFlags(si->Source);
- if (!exclude_configs.empty()) {
- if (!have_nested) {
- (*this->BuildFileStream) << ">\n";
- }
- this->WriteExcludeFromBuild(exclude_configs);
- have_nested = true;
+ Elem e2(e1, tool);
+ this->WriteSource(e2, si.Source);
+
+ bool useNativeUnityBuild = false;
+ if (haveUnityBuild && this->GlobalGenerator->GetSupportsUnityBuilds()) {
+ // Magic value taken from cmGlobalVisualStudioVersionedGenerator.cxx
+ static const std::string vs15 = "141";
+ std::string toolset =
+ this->GlobalGenerator->GetPlatformToolsetString();
+ cmSystemTools::ReplaceString(toolset, "v", "");
+
+ if (toolset.empty() ||
+ cmSystemTools::VersionCompareGreaterEq(toolset, vs15)) {
+ useNativeUnityBuild = true;
}
- if (have_nested) {
- this->WriteString("</", 2);
- (*this->BuildFileStream) << tool << ">\n";
+ }
+
+ if (haveUnityBuild && strcmp(tool, "ClCompile") == 0 &&
+ si.Source->GetProperty("UNITY_SOURCE_FILE")) {
+ if (useNativeUnityBuild) {
+ e2.Attribute(
+ "IncludeInUnityFile",
+ si.Source->GetPropertyAsBool("SKIP_UNITY_BUILD_INCLUSION")
+ ? "false"
+ : "true");
+ e2.Attribute("CustomUnityFile", "true");
+
+ std::string unityDir = cmSystemTools::GetFilenamePath(
+ si.Source->GetProperty("UNITY_SOURCE_FILE"));
+ e2.Attribute("UnityFilesDirectory", unityDir);
} else {
- (*this->BuildFileStream) << " />\n";
+ // Visual Studio versions prior to 2017 15.8 do not know about unity
+ // builds, thus we exclude the files alredy part of unity sources.
+ if (!si.Source->GetPropertyAsBool("SKIP_UNITY_BUILD_INCLUSION")) {
+ exclude_configs = si.Configs;
+ }
}
- } else if (!exclude_configs.empty()) {
- this->WriteSource(tool, si->Source, ">\n");
- this->WriteExcludeFromBuild(exclude_configs);
- this->WriteString("</", 2);
- (*this->BuildFileStream) << tool << ">\n";
- } else {
- this->WriteSource(tool, si->Source);
+ }
+
+ if (si.Kind == cmGeneratorTarget::SourceKindObjectSource) {
+ this->OutputSourceSpecificFlags(e2, si.Source);
+ }
+ if (si.Source->GetPropertyAsBool("SKIP_PRECOMPILE_HEADERS")) {
+ e2.Element("PrecompiledHeader", "NotUsing");
+ }
+ if (!exclude_configs.empty()) {
+ this->WriteExcludeFromBuild(e2, exclude_configs);
}
}
}
if (this->IsMissingFiles) {
- this->WriteMissingFiles();
+ this->WriteMissingFiles(e1);
}
-
- this->WriteString("</ItemGroup>\n", 1);
}
-bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
- cmSourceFile const* source)
+void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
+ Elem& e2, cmSourceFile const* source)
{
cmSourceFile const& sf = *source;
@@ -1875,17 +2260,32 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
}
std::string flags;
bool configDependentFlags = false;
+ std::string options;
+ bool configDependentOptions = false;
std::string defines;
+ bool configDependentDefines = false;
+ std::string includes;
+ bool configDependentIncludes = false;
if (const char* cflags = sf.GetProperty("COMPILE_FLAGS")) {
-
- if (cmGeneratorExpression::Find(cflags) != std::string::npos) {
- configDependentFlags = true;
- }
+ configDependentFlags =
+ cmGeneratorExpression::Find(cflags) != std::string::npos;
flags += cflags;
}
+ if (const char* coptions = sf.GetProperty("COMPILE_OPTIONS")) {
+ configDependentOptions =
+ cmGeneratorExpression::Find(coptions) != std::string::npos;
+ options += coptions;
+ }
if (const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) {
+ configDependentDefines =
+ cmGeneratorExpression::Find(cdefs) != std::string::npos;
defines += cdefs;
}
+ if (const char* cincludes = sf.GetProperty("INCLUDE_DIRECTORIES")) {
+ configDependentIncludes =
+ cmGeneratorExpression::Find(cincludes) != std::string::npos;
+ includes += cincludes;
+ }
std::string lang =
this->GlobalGenerator->GetLanguageFromExtension(sf.GetExtension().c_str());
std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
@@ -1910,41 +2310,51 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
}
}
bool noWinRT = this->TargetCompileAsWinRT && lang == "C";
- bool hasFlags = false;
// for the first time we need a new line if there is something
// produced here.
- const char* firstString = ">\n";
if (!objectName.empty()) {
- (*this->BuildFileStream) << firstString;
- firstString = "";
- hasFlags = true;
- this->WriteString("<ObjectFileName>", 3);
- (*this->BuildFileStream) << "$(IntDir)/" << objectName
- << "</ObjectFileName>\n";
- }
- for (std::vector<std::string>::const_iterator config =
- this->Configurations.begin();
- config != this->Configurations.end(); ++config) {
- std::string configUpper = cmSystemTools::UpperCase(*config);
+ if (lang == "CUDA") {
+ e2.Element("CompileOut", "$(IntDir)/" + objectName);
+ } else {
+ e2.Element("ObjectFileName", "$(IntDir)/" + objectName);
+ }
+ }
+ for (std::string const& config : this->Configurations) {
+ std::string configUpper = cmSystemTools::UpperCase(config);
std::string configDefines = defines;
- std::string defPropName = "COMPILE_DEFINITIONS_";
- defPropName += configUpper;
- if (const char* ccdefs = sf.GetProperty(defPropName.c_str())) {
+ std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper);
+ if (const char* ccdefs = sf.GetProperty(defPropName)) {
if (!configDefines.empty()) {
configDefines += ";";
}
+ configDependentDefines |=
+ cmGeneratorExpression::Find(ccdefs) != std::string::npos;
configDefines += ccdefs;
}
+
+ // Add precompile headers compile options.
+ std::string customAndPchOptions = options;
+ const std::string pchSource =
+ this->GeneratorTarget->GetPchSource(config, lang);
+ if (!pchSource.empty() && !sf.GetProperty("SKIP_PRECOMPILE_HEADERS")) {
+ std::string pchOptions;
+ if (sf.GetFullPath() == pchSource) {
+ pchOptions =
+ this->GeneratorTarget->GetPchCreateCompileOptions(config, lang);
+ } else {
+ pchOptions =
+ this->GeneratorTarget->GetPchUseCompileOptions(config, lang);
+ }
+ customAndPchOptions += pchOptions;
+ }
+
// if we have flags or defines for this config then
// use them
- if (!flags.empty() || configDependentFlags || !configDefines.empty() ||
- compileAs || noWinRT) {
- (*this->BuildFileStream) << firstString;
- firstString = ""; // only do firstString once
- hasFlags = true;
- cmGlobalVisualStudio10Generator* gg =
- static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- cmIDEFlagTable const* flagtable = CM_NULLPTR;
+ if (!flags.empty() || !options.empty() || !configDefines.empty() ||
+ !includes.empty() || compileAs || noWinRT ||
+ !customAndPchOptions.empty()) {
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
+ cmIDEFlagTable const* flagtable = nullptr;
const std::string& srclang = source->GetLanguage();
if (srclang == "C" || srclang == "CXX") {
flagtable = gg->GetClFlagTable();
@@ -1959,9 +2369,11 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
} else if (srclang == "CSharp") {
flagtable = gg->GetCSharpFlagTable();
}
- cmVisualStudioGeneratorOptions clOptions(
+ cmGeneratorExpressionInterpreter genexInterpreter(
+ this->LocalGenerator, config, this->GeneratorTarget, lang);
+ cmVS10GeneratorOptions clOptions(
this->LocalGenerator, cmVisualStudioGeneratorOptions::Compiler,
- flagtable, 0, this);
+ flagtable, this);
if (compileAs) {
clOptions.AddFlag("CompileAs", compileAs);
}
@@ -1969,160 +2381,202 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
clOptions.AddFlag("CompileAsWinRT", "false");
}
if (configDependentFlags) {
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(flags);
- std::string evaluatedFlags =
- cge->Evaluate(this->LocalGenerator, *config);
- clOptions.Parse(evaluatedFlags.c_str());
+ clOptions.Parse(genexInterpreter.Evaluate(flags, "COMPILE_FLAGS"));
} else {
- clOptions.Parse(flags.c_str());
+ clOptions.Parse(flags);
}
- if (clOptions.HasFlag("AdditionalIncludeDirectories")) {
- clOptions.AppendFlag("AdditionalIncludeDirectories",
- "%(AdditionalIncludeDirectories)");
+ if (!customAndPchOptions.empty()) {
+ std::string expandedOptions;
+ if (configDependentOptions) {
+ this->LocalGenerator->AppendCompileOptions(
+ expandedOptions,
+ genexInterpreter.Evaluate(customAndPchOptions, "COMPILE_OPTIONS"));
+ } else {
+ this->LocalGenerator->AppendCompileOptions(expandedOptions,
+ customAndPchOptions);
+ }
+ clOptions.Parse(expandedOptions);
}
if (clOptions.HasFlag("DisableSpecificWarnings")) {
clOptions.AppendFlag("DisableSpecificWarnings",
"%(DisableSpecificWarnings)");
}
- clOptions.AddDefines(configDefines.c_str());
- clOptions.SetConfiguration((*config).c_str());
- clOptions.PrependInheritedString("AdditionalOptions");
- clOptions.OutputFlagMap(*this->BuildFileStream, " ");
- clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
- "\n", lang);
+ if (clOptions.HasFlag("ForcedIncludeFiles")) {
+ clOptions.AppendFlag("ForcedIncludeFiles", "%(ForcedIncludeFiles)");
+ }
+ if (configDependentDefines) {
+ clOptions.AddDefines(
+ genexInterpreter.Evaluate(configDefines, "COMPILE_DEFINITIONS"));
+ } else {
+ clOptions.AddDefines(configDefines);
+ }
+ std::vector<std::string> includeList;
+ if (configDependentIncludes) {
+ this->LocalGenerator->AppendIncludeDirectories(
+ includeList,
+ genexInterpreter.Evaluate(includes, "INCLUDE_DIRECTORIES"), *source);
+ } else {
+ this->LocalGenerator->AppendIncludeDirectories(includeList, includes,
+ *source);
+ }
+ clOptions.AddIncludes(includeList);
+ clOptions.SetConfiguration(config);
+ OptionsHelper oh(clOptions, e2);
+ oh.PrependInheritedString("AdditionalOptions");
+ oh.OutputAdditionalIncludeDirectories(lang);
+ oh.OutputFlagMap();
+ oh.OutputPreprocessorDefinitions(lang);
}
}
if (this->IsXamlSource(source->GetFullPath())) {
- (*this->BuildFileStream) << firstString;
- firstString = ""; // only do firstString once
- hasFlags = true;
- this->WriteString("<DependentUpon>", 3);
const std::string& fileName = source->GetFullPath();
std::string xamlFileName = fileName.substr(0, fileName.find_last_of("."));
- (*this->BuildFileStream) << xamlFileName << "</DependentUpon>\n";
+ e2.Element("DependentUpon", xamlFileName);
}
- if (csproj == this->ProjectType) {
+ if (this->ProjectType == csproj) {
std::string f = source->GetFullPath();
- typedef std::map<std::string, std::string> CsPropMap;
+ using CsPropMap = std::map<std::string, std::string>;
CsPropMap sourceFileTags;
// set <Link> tag if necessary
- if (!this->InSourceBuild) {
- const std::string stripFromPath =
- this->Makefile->GetCurrentSourceDirectory();
- if (f.find(stripFromPath) != std::string::npos) {
- std::string link = f.substr(stripFromPath.length() + 1);
- this->ConvertToWindowsSlash(link);
- sourceFileTags["Link"] = link;
- }
- }
- const cmPropertyMap& props = sf.GetProperties();
- for (cmPropertyMap::const_iterator p = props.begin(); p != props.end();
- ++p) {
- static const std::string propNamePrefix = "VS_CSHARP_";
- if (p->first.find(propNamePrefix.c_str()) == 0) {
- std::string tagName = p->first.substr(propNamePrefix.length());
- if (!tagName.empty()) {
- const std::string val = props.GetPropertyValue(p->first);
- if (!val.empty()) {
- sourceFileTags[tagName] = val;
- } else {
- sourceFileTags.erase(tagName);
- }
- }
- }
+ std::string link;
+ this->GetCSharpSourceLink(source, link);
+ if (!link.empty()) {
+ sourceFileTags["Link"] = link;
}
+ this->GetCSharpSourceProperties(&sf, sourceFileTags);
// write source file specific tags
if (!sourceFileTags.empty()) {
- hasFlags = true;
- (*this->BuildFileStream) << firstString;
- firstString = "";
- for (CsPropMap::const_iterator i = sourceFileTags.begin();
- i != sourceFileTags.end(); ++i) {
- this->WriteString("<", 3);
- (*this->BuildFileStream)
- << i->first << ">" << cmVS10EscapeXML(i->second) << "</" << i->first
- << ">\n";
- }
+ this->WriteCSharpSourceProperties(e2, sourceFileTags);
}
}
-
- return hasFlags;
}
void cmVisualStudio10TargetGenerator::WriteExcludeFromBuild(
- std::vector<size_t> const& exclude_configs)
+ Elem& e2, std::vector<size_t> const& exclude_configs)
{
- for (std::vector<size_t>::const_iterator ci = exclude_configs.begin();
- ci != exclude_configs.end(); ++ci) {
- this->WriteString("", 3);
- (*this->BuildFileStream)
- << "<ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='"
- << cmVS10EscapeXML(this->Configurations[*ci]) << "|"
- << cmVS10EscapeXML(this->Platform) << "'\">true</ExcludedFromBuild>\n";
+ for (size_t ci : exclude_configs) {
+ e2.WritePlatformConfigTag("ExcludedFromBuild",
+ "'$(Configuration)|$(Platform)'=='" +
+ this->Configurations[ci] + "|" +
+ this->Platform + "'",
+ "true");
}
}
-void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
+void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
+ Elem& e0)
{
cmStateEnums::TargetType ttype = this->GeneratorTarget->GetType();
if (ttype > cmStateEnums::GLOBAL_TARGET) {
return;
}
- if (csproj == this->ProjectType) {
+ if (this->ProjectType == csproj) {
return;
}
- this->WriteString("<PropertyGroup>\n", 1);
- this->WriteString("<_ProjectFileVersion>10.0.20506.1"
- "</_ProjectFileVersion>\n",
- 2);
- for (std::vector<std::string>::const_iterator config =
- this->Configurations.begin();
- config != this->Configurations.end(); ++config) {
+ Elem e1(e0, "PropertyGroup");
+ e1.Element("_ProjectFileVersion", "10.0.20506.1");
+ for (std::string const& config : this->Configurations) {
+ const std::string cond = this->CalcCondition(config);
+
+ if (ttype <= cmStateEnums::UTILITY) {
+ if (const char* workingDir = this->GeneratorTarget->GetProperty(
+ "VS_DEBUGGER_WORKING_DIRECTORY")) {
+ std::string genWorkingDir = cmGeneratorExpression::Evaluate(
+ workingDir, this->LocalGenerator, config);
+ e1.WritePlatformConfigTag("LocalDebuggerWorkingDirectory", cond,
+ genWorkingDir);
+ }
+
+ if (const char* environment =
+ this->GeneratorTarget->GetProperty("VS_DEBUGGER_ENVIRONMENT")) {
+ std::string genEnvironment = cmGeneratorExpression::Evaluate(
+ environment, this->LocalGenerator, config);
+ e1.WritePlatformConfigTag("LocalDebuggerEnvironment", cond,
+ genEnvironment);
+ }
+
+ if (const char* debuggerCommand =
+ this->GeneratorTarget->GetProperty("VS_DEBUGGER_COMMAND")) {
+ std::string genDebuggerCommand = cmGeneratorExpression::Evaluate(
+ debuggerCommand, this->LocalGenerator, config);
+ e1.WritePlatformConfigTag("LocalDebuggerCommand", cond,
+ genDebuggerCommand);
+ }
+
+ if (const char* commandArguments = this->GeneratorTarget->GetProperty(
+ "VS_DEBUGGER_COMMAND_ARGUMENTS")) {
+ std::string genCommandArguments = cmGeneratorExpression::Evaluate(
+ commandArguments, this->LocalGenerator, config);
+ e1.WritePlatformConfigTag("LocalDebuggerCommandArguments", cond,
+ genCommandArguments);
+ }
+ }
+
if (ttype >= cmStateEnums::UTILITY) {
- this->WritePlatformConfigTag("IntDir", config->c_str(), 2);
- *this->BuildFileStream
- << "$(Platform)\\$(Configuration)\\$(ProjectName)\\"
- << "</IntDir>\n";
+ e1.WritePlatformConfigTag(
+ "IntDir", cond, "$(Platform)\\$(Configuration)\\$(ProjectName)\\");
} else {
- std::string intermediateDir =
- this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- intermediateDir += "/";
- intermediateDir += *config;
- intermediateDir += "/";
+ std::string intermediateDir = cmStrCat(
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), '/',
+ config, '/');
std::string outDir;
std::string targetNameFull;
if (ttype == cmStateEnums::OBJECT_LIBRARY) {
outDir = intermediateDir;
- targetNameFull = this->GeneratorTarget->GetName();
- targetNameFull += ".lib";
+ targetNameFull = cmStrCat(this->GeneratorTarget->GetName(), ".lib");
} else {
- outDir = this->GeneratorTarget->GetDirectory(config->c_str()) + "/";
- targetNameFull = this->GeneratorTarget->GetFullName(config->c_str());
+ outDir = this->GeneratorTarget->GetDirectory(config) + "/";
+ targetNameFull = this->GeneratorTarget->GetFullName(config);
}
- this->ConvertToWindowsSlash(intermediateDir);
- this->ConvertToWindowsSlash(outDir);
+ ConvertToWindowsSlash(intermediateDir);
+ ConvertToWindowsSlash(outDir);
- this->WritePlatformConfigTag("OutDir", config->c_str(), 2);
- *this->BuildFileStream << cmVS10EscapeXML(outDir) << "</OutDir>\n";
+ e1.WritePlatformConfigTag("OutDir", cond, outDir);
- this->WritePlatformConfigTag("IntDir", config->c_str(), 2);
- *this->BuildFileStream << cmVS10EscapeXML(intermediateDir)
- << "</IntDir>\n";
+ e1.WritePlatformConfigTag("IntDir", cond, intermediateDir);
- if (const char* workingDir = this->GeneratorTarget->GetProperty(
- "VS_DEBUGGER_WORKING_DIRECTORY")) {
- this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory",
- config->c_str(), 2);
- *this->BuildFileStream << cmVS10EscapeXML(workingDir)
- << "</LocalDebuggerWorkingDirectory>\n";
+ if (const char* sdkExecutableDirectories = this->Makefile->GetDefinition(
+ "CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES")) {
+ e1.WritePlatformConfigTag("ExecutablePath", cond,
+ sdkExecutableDirectories);
+ }
+
+ if (const char* sdkIncludeDirectories = this->Makefile->GetDefinition(
+ "CMAKE_VS_SDK_INCLUDE_DIRECTORIES")) {
+ e1.WritePlatformConfigTag("IncludePath", cond, sdkIncludeDirectories);
+ }
+
+ if (const char* sdkReferenceDirectories = this->Makefile->GetDefinition(
+ "CMAKE_VS_SDK_REFERENCE_DIRECTORIES")) {
+ e1.WritePlatformConfigTag("ReferencePath", cond,
+ sdkReferenceDirectories);
+ }
+
+ if (const char* sdkLibraryDirectories = this->Makefile->GetDefinition(
+ "CMAKE_VS_SDK_LIBRARY_DIRECTORIES")) {
+ e1.WritePlatformConfigTag("LibraryPath", cond, sdkLibraryDirectories);
+ }
+
+ if (const char* sdkLibraryWDirectories = this->Makefile->GetDefinition(
+ "CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES")) {
+ e1.WritePlatformConfigTag("LibraryWPath", cond,
+ sdkLibraryWDirectories);
+ }
+
+ if (const char* sdkSourceDirectories =
+ this->Makefile->GetDefinition("CMAKE_VS_SDK_SOURCE_DIRECTORIES")) {
+ e1.WritePlatformConfigTag("SourcePath", cond, sdkSourceDirectories);
+ }
+
+ if (const char* sdkExcludeDirectories = this->Makefile->GetDefinition(
+ "CMAKE_VS_SDK_EXCLUDE_DIRECTORIES")) {
+ e1.WritePlatformConfigTag("ExcludePath", cond, sdkExcludeDirectories);
}
std::string name =
cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull);
- this->WritePlatformConfigTag("TargetName", config->c_str(), 2);
- *this->BuildFileStream << cmVS10EscapeXML(name) << "</TargetName>\n";
+ e1.WritePlatformConfigTag("TargetName", cond, name);
std::string ext =
cmSystemTools::GetFilenameLastExtension(targetNameFull);
@@ -2131,22 +2585,20 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
// A single "." appears to be treated as an empty extension.
ext = ".";
}
- this->WritePlatformConfigTag("TargetExt", config->c_str(), 2);
- *this->BuildFileStream << cmVS10EscapeXML(ext) << "</TargetExt>\n";
+ e1.WritePlatformConfigTag("TargetExt", cond, ext);
- this->OutputLinkIncremental(*config);
+ this->OutputLinkIncremental(e1, config);
}
}
- this->WriteString("</PropertyGroup>\n", 1);
}
void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
- std::string const& configName)
+ Elem& e1, std::string const& configName)
{
if (!this->MSTools) {
return;
}
- if (csproj == this->ProjectType) {
+ if (this->ProjectType == csproj) {
return;
}
// static libraries and things greater than modules do not need
@@ -2156,17 +2608,18 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
return;
}
Options& linkOptions = *(this->LinkOptions[configName]);
+ const std::string cond = this->CalcCondition(configName);
- const char* incremental = linkOptions.GetFlag("LinkIncremental");
- this->WritePlatformConfigTag("LinkIncremental", configName.c_str(), 2);
- *this->BuildFileStream << (incremental ? incremental : "true")
- << "</LinkIncremental>\n";
+ if (this->IPOEnabledConfigurations.count(configName) == 0) {
+ const char* incremental = linkOptions.GetFlag("LinkIncremental");
+ e1.WritePlatformConfigTag("LinkIncremental", cond,
+ (incremental ? incremental : "true"));
+ }
linkOptions.RemoveFlag("LinkIncremental");
const char* manifest = linkOptions.GetFlag("GenerateManifest");
- this->WritePlatformConfigTag("GenerateManifest", configName.c_str(), 2);
- *this->BuildFileStream << (manifest ? manifest : "true")
- << "</GenerateManifest>\n";
+ e1.WritePlatformConfigTag("GenerateManifest", cond,
+ (manifest ? manifest : "true"));
linkOptions.RemoveFlag("GenerateManifest");
// Some link options belong here. Use them now and remove them so that
@@ -2175,19 +2628,28 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
for (const char** f = flags; *f; ++f) {
const char* flag = *f;
if (const char* value = linkOptions.GetFlag(flag)) {
- this->WritePlatformConfigTag(flag, configName.c_str(), 2);
- *this->BuildFileStream << value << "</" << flag << ">\n";
+ e1.WritePlatformConfigTag(flag, cond, value);
linkOptions.RemoveFlag(flag);
}
}
}
+std::vector<std::string> cmVisualStudio10TargetGenerator::GetIncludes(
+ std::string const& config, std::string const& lang) const
+{
+ std::vector<std::string> includes;
+ this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
+ lang, config);
+ for (std::string& i : includes) {
+ ConvertToWindowsSlash(i);
+ }
+ return includes;
+}
+
bool cmVisualStudio10TargetGenerator::ComputeClOptions()
{
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeClOptions(*i)) {
+ for (std::string const& c : this->Configurations) {
+ if (!this->ComputeClOptions(c)) {
return false;
}
}
@@ -2201,62 +2663,51 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
// copied from cmLocalVisualStudio7Generator.cxx 805
// TODO: Integrate code below with cmLocalVisualStudio7Generator.
- cmGlobalVisualStudio10Generator* gg =
- static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions;
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
+ std::unique_ptr<Options> pOptions;
switch (this->ProjectType) {
case vcxproj:
- pOptions = CM_AUTO_PTR<Options>(new Options(
- this->LocalGenerator, Options::Compiler, gg->GetClFlagTable()));
+ pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::Compiler, gg->GetClFlagTable());
break;
case csproj:
- pOptions = CM_AUTO_PTR<Options>(new Options(this->LocalGenerator,
- Options::CSharpCompiler,
- gg->GetCSharpFlagTable()));
+ pOptions =
+ cm::make_unique<Options>(this->LocalGenerator, Options::CSharpCompiler,
+ gg->GetCSharpFlagTable());
break;
}
Options& clOptions = *pOptions;
std::string flags;
const std::string& linkLanguage =
- this->GeneratorTarget->GetLinkerLanguage(configName.c_str());
+ this->GeneratorTarget->GetLinkerLanguage(configName);
if (linkLanguage.empty()) {
cmSystemTools::Error(
- "CMake can not determine linker language for target: ",
- this->Name.c_str());
+ "CMake can not determine linker language for target: " + this->Name);
return false;
}
// Choose a language whose flags to use for ClCompile.
- static const char* clLangs[] = { "CXX", "C", "Fortran", "CSharp" };
+ static const char* clLangs[] = { "CXX", "C", "Fortran" };
std::string langForClCompile;
- if (std::find(cmArrayBegin(clLangs), cmArrayEnd(clLangs), linkLanguage) !=
- cmArrayEnd(clLangs)) {
+ if (this->ProjectType == csproj) {
+ langForClCompile = "CSharp";
+ } else if (cmContains(clLangs, linkLanguage)) {
langForClCompile = linkLanguage;
} else {
std::set<std::string> languages;
this->GeneratorTarget->GetLanguages(languages, configName);
- for (const char* const* l = cmArrayBegin(clLangs);
- l != cmArrayEnd(clLangs); ++l) {
- if (languages.find(*l) != languages.end()) {
- langForClCompile = *l;
+ for (const char* l : clLangs) {
+ if (languages.count(l)) {
+ langForClCompile = l;
break;
}
}
}
+ this->LangForClCompile = langForClCompile;
if (!langForClCompile.empty()) {
- std::string baseFlagVar = "CMAKE_";
- baseFlagVar += langForClCompile;
- baseFlagVar += "_FLAGS";
- flags =
- this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
- baseFlagVar.c_str());
- std::string flagVar =
- baseFlagVar + std::string("_") + cmSystemTools::UpperCase(configName);
- flags += " ";
- flags +=
- this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
- flagVar.c_str());
+ this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget,
+ langForClCompile, configName);
this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
langForClCompile, configName);
}
@@ -2268,51 +2719,109 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
clOptions.AddFlag("CompileAs", "CompileAsCpp");
}
- // Check IPO related warning/error.
- this->GeneratorTarget->IsIPOEnabled(linkLanguage, configName);
+ // Put the IPO enabled configurations into a set.
+ if (this->GeneratorTarget->IsIPOEnabled(linkLanguage, configName)) {
+ this->IPOEnabledConfigurations.insert(configName);
+ }
+
+ // Precompile Headers
+ std::string pchHeader =
+ this->GeneratorTarget->GetPchHeader(configName, linkLanguage);
+ if (this->MSTools && vcxproj == this->ProjectType && pchHeader.empty()) {
+ clOptions.AddFlag("PrecompiledHeader", "NotUsing");
+ }
// Get preprocessor definitions for this directory.
- std::string defineFlags =
- this->GeneratorTarget->Target->GetMakefile()->GetDefineFlags();
+ std::string defineFlags = this->Makefile->GetDefineFlags();
if (this->MSTools) {
- if (vcxproj == this->ProjectType) {
+ if (this->ProjectType == vcxproj) {
clOptions.FixExceptionHandlingDefault();
- clOptions.AddFlag("PrecompiledHeader", "NotUsing");
- std::string asmLocation = configName + "/";
- clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
+ if (this->GlobalGenerator->GetVersion() >=
+ cmGlobalVisualStudioGenerator::VS15) {
+ // Toolsets that come with VS 2017 may now enable UseFullPaths
+ // by default and there is no negative /FC option that projects
+ // can use to switch it back. Older toolsets disable this by
+ // default anyway so this will not hurt them. If the project
+ // is using an explicit /FC option then parsing flags will
+ // replace this setting with "true" below.
+ clOptions.AddFlag("UseFullPaths", "false");
+ }
+ clOptions.AddFlag("AssemblerListingLocation", "$(IntDir)");
+ }
+ }
+
+ // check for managed C++ assembly compiler flag. This overrides any
+ // /clr* compiler flags which may be defined in the flags variable(s).
+ if (this->ProjectType != csproj) {
+ // Warn if /clr was added manually. This should not be done
+ // anymore, because cmGeneratorTarget may not be aware that the
+ // target uses C++/CLI.
+ if (flags.find("/clr") != std::string::npos ||
+ defineFlags.find("/clr") != std::string::npos) {
+ if (configName == this->Configurations[0]) {
+ std::string message = "For the target \"" +
+ this->GeneratorTarget->GetName() +
+ "\" the /clr compiler flag was added manually. " +
+ "Set usage of C++/CLI by setting COMMON_LANGUAGE_RUNTIME "
+ "target property.";
+ this->Makefile->IssueMessage(MessageType::WARNING, message);
+ }
+ }
+ if (auto* clr =
+ this->GeneratorTarget->GetProperty("COMMON_LANGUAGE_RUNTIME")) {
+ std::string clrString = clr;
+ if (!clrString.empty()) {
+ clrString = ":" + clrString;
+ }
+ flags += " /clr" + clrString;
}
}
- clOptions.Parse(flags.c_str());
- clOptions.Parse(defineFlags.c_str());
+
+ clOptions.Parse(flags);
+ clOptions.Parse(defineFlags);
std::vector<std::string> targetDefines;
switch (this->ProjectType) {
case vcxproj:
- this->GeneratorTarget->GetCompileDefinitions(targetDefines,
- configName.c_str(), "CXX");
+ if (!langForClCompile.empty()) {
+ this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName,
+ langForClCompile);
+ }
break;
case csproj:
- this->GeneratorTarget->GetCompileDefinitions(
- targetDefines, configName.c_str(), "CSharp");
+ this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName,
+ "CSharp");
break;
}
clOptions.AddDefines(targetDefines);
+
+ if (this->ProjectType == csproj) {
+ clOptions.AppendFlag("DefineConstants", targetDefines);
+ }
+
+ // Get includes for this target
+ if (!this->LangForClCompile.empty()) {
+ clOptions.AddIncludes(
+ this->GetIncludes(configName, this->LangForClCompile));
+ }
+
if (this->MSTools) {
clOptions.SetVerboseMakefile(
this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
}
// Add a definition for the configuration name.
- std::string configDefine = "CMAKE_INTDIR=\"";
- configDefine += configName;
- configDefine += "\"";
+ std::string configDefine = cmStrCat("CMAKE_INTDIR=\"", configName, '"');
clOptions.AddDefine(configDefine);
- if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) {
- clOptions.AddDefine(exportMacro);
+ if (const std::string* exportMacro =
+ this->GeneratorTarget->GetExportMacro()) {
+ clOptions.AddDefine(*exportMacro);
}
if (this->MSTools) {
- // If we have the VS_WINRT_COMPONENT set then force Compile as WinRT.
- if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) {
+ // If we have the VS_WINRT_COMPONENT or CMAKE_VS_WINRT_BY_DEFAULT
+ // set then force Compile as WinRT.
+ if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
+ this->Makefile->IsOn("CMAKE_VS_WINRT_BY_DEFAULT")) {
clOptions.AddFlag("CompileAsWinRT", "true");
// For WinRT components, add the _WINRT_DLL define to produce a lib
if (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
@@ -2326,91 +2835,112 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
}
}
if (const char* winRT = clOptions.GetFlag("CompileAsWinRT")) {
- if (cmSystemTools::IsOn(winRT)) {
+ if (cmIsOn(winRT)) {
this->TargetCompileAsWinRT = true;
}
}
}
- if (csproj != this->ProjectType && clOptions.IsManaged()) {
+ if (this->ProjectType != csproj && clOptions.IsManaged()) {
this->Managed = true;
std::string managedType = clOptions.GetFlag("CompileAsManaged");
- if (managedType == "Safe") {
+ if (managedType == "Safe" || managedType == "Pure") {
// force empty calling convention if safe clr is used
clOptions.AddFlag("CallingConvention", "");
}
+ // The default values of these flags are incompatible to
+ // managed assemblies. We have to force valid values if
+ // the target is a managed C++ target.
+ clOptions.AddFlag("ExceptionHandling", "Async");
+ clOptions.AddFlag("BasicRuntimeChecks", "Default");
+ }
+ if (this->ProjectType == csproj) {
+ // /nowin32manifest overrides /win32manifest: parameter
+ if (clOptions.HasFlag("NoWin32Manifest")) {
+ clOptions.RemoveFlag("ApplicationManifest");
+ }
}
- this->ClOptions[configName] = pOptions.release();
+ if (const char* s = clOptions.GetFlag("SpectreMitigation")) {
+ this->SpectreMitigation[configName] = s;
+ clOptions.RemoveFlag("SpectreMitigation");
+ }
+
+ this->ClOptions[configName] = std::move(pOptions);
return true;
}
void cmVisualStudio10TargetGenerator::WriteClOptions(
- std::string const& configName, std::vector<std::string> const& includes)
+ Elem& e1, std::string const& configName)
{
Options& clOptions = *(this->ClOptions[configName]);
if (this->ProjectType == csproj) {
return;
}
- this->WriteString("<ClCompile>\n", 2);
- clOptions.PrependInheritedString("AdditionalOptions");
- clOptions.AppendFlag("AdditionalIncludeDirectories", includes);
- clOptions.AppendFlag("AdditionalIncludeDirectories",
- "%(AdditionalIncludeDirectories)");
- clOptions.OutputFlagMap(*this->BuildFileStream, " ");
- clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
- "\n", "CXX");
+ Elem e2(e1, "ClCompile");
+ OptionsHelper oh(clOptions, e2);
+ oh.PrependInheritedString("AdditionalOptions");
+ oh.OutputAdditionalIncludeDirectories(this->LangForClCompile);
+ oh.OutputFlagMap();
+ oh.OutputPreprocessorDefinitions(this->LangForClCompile);
if (this->NsightTegra) {
if (const char* processMax =
this->GeneratorTarget->GetProperty("ANDROID_PROCESS_MAX")) {
- this->WriteString("<ProcessMax>", 3);
- *this->BuildFileStream << cmVS10EscapeXML(processMax)
- << "</ProcessMax>\n";
+ e2.Element("ProcessMax", processMax);
}
}
if (this->MSTools) {
- cmsys::RegularExpression clangToolset(
- "(v[0-9]+_clang_.*|LLVM-vs[0-9]+.*)");
+ cmsys::RegularExpression clangToolset("v[0-9]+_clang_.*");
const char* toolset = this->GlobalGenerator->GetPlatformToolset();
if (toolset && clangToolset.find(toolset)) {
- this->WriteString("<ObjectFileName>"
- "$(IntDir)%(filename).obj"
- "</ObjectFileName>\n",
- 3);
+ e2.Element("ObjectFileName", "$(IntDir)%(filename).obj");
} else {
- this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
+ e2.Element("ObjectFileName", "$(IntDir)");
}
// If not in debug mode, write the DebugInformationFormat field
- // without value so PDBs don't get generated uselessly.
+ // without value so PDBs don't get generated uselessly. Each tag
+ // goes on its own line because Visual Studio corrects it this
+ // way when saving the project after CMake generates it.
if (!clOptions.IsDebug()) {
- this->WriteString("<DebugInformationFormat>"
- "</DebugInformationFormat>\n",
- 3);
+ Elem e3(e2, "DebugInformationFormat");
+ e3.SetHasElements();
}
// Specify the compiler program database file if configured.
- std::string pdb =
- this->GeneratorTarget->GetCompilePDBPath(configName.c_str());
+ std::string pdb = this->GeneratorTarget->GetCompilePDBPath(configName);
if (!pdb.empty()) {
- this->ConvertToWindowsSlash(pdb);
- this->WriteString("<ProgramDataBaseFileName>", 3);
- *this->BuildFileStream << cmVS10EscapeXML(pdb)
- << "</ProgramDataBaseFileName>\n";
+ if (this->GlobalGenerator->IsCudaEnabled()) {
+ // CUDA does not quote paths with spaces correctly when forwarding
+ // this to the host compiler. Use a relative path to avoid spaces.
+ // FIXME: We can likely do this even when CUDA is not involved,
+ // but for now we will make a minimal change.
+ pdb = this->ConvertPath(pdb, true);
+ }
+ ConvertToWindowsSlash(pdb);
+ e2.Element("ProgramDataBaseFileName", pdb);
}
- }
- this->WriteString("</ClCompile>\n", 2);
+ // add AdditionalUsingDirectories
+ if (this->AdditionalUsingDirectories.count(configName) > 0) {
+ std::string dirs;
+ for (auto u : this->AdditionalUsingDirectories[configName]) {
+ if (!dirs.empty()) {
+ dirs.append(";");
+ }
+ dirs.append(u);
+ }
+ e2.Element("AdditionalUsingDirectories", dirs);
+ }
+ }
}
bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
{
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeRcOptions(*i)) {
+ for (std::string const& c : this->Configurations) {
+ if (!this->ComputeRcOptions(c)) {
return false;
}
}
@@ -2420,47 +2950,42 @@ bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
bool cmVisualStudio10TargetGenerator::ComputeRcOptions(
std::string const& configName)
{
- cmGlobalVisualStudio10Generator* gg =
- static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::ResourceCompiler, gg->GetRcFlagTable()));
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
+ auto pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::ResourceCompiler, gg->GetRcFlagTable());
Options& rcOptions = *pOptions;
std::string CONFIG = cmSystemTools::UpperCase(configName);
- std::string rcConfigFlagsVar = std::string("CMAKE_RC_FLAGS_") + CONFIG;
- std::string flags =
- std::string(this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS")) +
- std::string(" ") +
- std::string(this->Makefile->GetSafeDefinition(rcConfigFlagsVar));
+ std::string rcConfigFlagsVar = "CMAKE_RC_FLAGS_" + CONFIG;
+ std::string flags = this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS") +
+ " " + this->Makefile->GetSafeDefinition(rcConfigFlagsVar);
- rcOptions.Parse(flags.c_str());
+ rcOptions.Parse(flags);
// For historical reasons, add the C preprocessor defines to RC.
Options& clOptions = *(this->ClOptions[configName]);
rcOptions.AddDefines(clOptions.GetDefines());
- this->RcOptions[configName] = pOptions.release();
+ // Get includes for this target
+ rcOptions.AddIncludes(this->GetIncludes(configName, "RC"));
+
+ this->RcOptions[configName] = std::move(pOptions);
return true;
}
void cmVisualStudio10TargetGenerator::WriteRCOptions(
- std::string const& configName, std::vector<std::string> const& includes)
+ Elem& e1, std::string const& configName)
{
if (!this->MSTools) {
return;
}
- this->WriteString("<ResourceCompile>\n", 2);
+ Elem e2(e1, "ResourceCompile");
- Options& rcOptions = *(this->RcOptions[configName]);
- rcOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
- "\n", "RC");
- rcOptions.AppendFlag("AdditionalIncludeDirectories", includes);
- rcOptions.AppendFlag("AdditionalIncludeDirectories",
- "%(AdditionalIncludeDirectories)");
+ OptionsHelper rcOptions(*(this->RcOptions[configName]), e2);
+ rcOptions.OutputPreprocessorDefinitions("RC");
+ rcOptions.OutputAdditionalIncludeDirectories("RC");
rcOptions.PrependInheritedString("AdditionalOptions");
- rcOptions.OutputFlagMap(*this->BuildFileStream, " ");
-
- this->WriteString("</ResourceCompile>\n", 2);
+ rcOptions.OutputFlagMap();
}
bool cmVisualStudio10TargetGenerator::ComputeCudaOptions()
@@ -2468,10 +2993,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions()
if (!this->GlobalGenerator->IsCudaEnabled()) {
return true;
}
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeCudaOptions(*i)) {
+ for (std::string const& c : this->Configurations) {
+ if (!this->ComputeCudaOptions(c)) {
return false;
}
}
@@ -2481,30 +3004,37 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions()
bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
std::string const& configName)
{
- cmGlobalVisualStudio10Generator* gg =
- static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable()));
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
+ auto pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable());
Options& cudaOptions = *pOptions;
// Get compile flags for CUDA in this directory.
- std::string CONFIG = cmSystemTools::UpperCase(configName);
- std::string configFlagsVar = std::string("CMAKE_CUDA_FLAGS_") + CONFIG;
- std::string flags =
- std::string(this->Makefile->GetSafeDefinition("CMAKE_CUDA_FLAGS")) +
- std::string(" ") +
- std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
+ std::string flags;
+ this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget, "CUDA",
+ configName);
this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, "CUDA",
configName);
// Get preprocessor definitions for this directory.
- std::string defineFlags =
- this->GeneratorTarget->Target->GetMakefile()->GetDefineFlags();
+ std::string defineFlags = this->Makefile->GetDefineFlags();
- cudaOptions.Parse(flags.c_str());
- cudaOptions.Parse(defineFlags.c_str());
+ cudaOptions.Parse(flags);
+ cudaOptions.Parse(defineFlags);
cudaOptions.ParseFinish();
+ // If we haven't explicitly enabled GPU debug information
+ // explicitly disable it
+ if (!cudaOptions.HasFlag("GPUDebugInfo")) {
+ cudaOptions.AddFlag("GPUDebugInfo", "false");
+ }
+
+ // The extension on object libraries the CUDA gives isn't
+ // consistent with how MSVC generates object libraries for C+, so set
+ // the default to not have any extension
+ cudaOptions.AddFlag("CompileOut", "$(IntDir)%(Filename).obj");
+
+ bool notPtx = true;
if (this->GeneratorTarget->GetPropertyAsBool("CUDA_SEPARABLE_COMPILATION")) {
cudaOptions.AddFlag("GenerateRelocatableDeviceCode", "true");
} else if (this->GeneratorTarget->GetPropertyAsBool(
@@ -2513,6 +3043,41 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
// We drop the %(Extension) component as CMake expects all PTX files
// to not have the source file extension at all
cudaOptions.AddFlag("CompileOut", "$(IntDir)%(Filename).ptx");
+ notPtx = false;
+ }
+
+ if (notPtx &&
+ cmSystemTools::VersionCompareGreaterEq(
+ "8.0", this->GlobalGenerator->GetPlatformToolsetCudaString())) {
+ // Explicitly state that we want this file to be treated as a
+ // CUDA file no matter what the file extensions is
+ // This is only needed for < CUDA 9
+ cudaOptions.AppendFlagString("AdditionalOptions", "-x cu");
+ }
+
+ // Specify the compiler program database file if configured.
+ std::string pdb = this->GeneratorTarget->GetCompilePDBPath(configName);
+ if (!pdb.empty()) {
+ // CUDA does not make the directory if it is non-standard.
+ std::string const pdbDir = cmSystemTools::GetFilenamePath(pdb);
+ cmSystemTools::MakeDirectory(pdbDir);
+ if (cmSystemTools::VersionCompareGreaterEq(
+ "9.2", this->GlobalGenerator->GetPlatformToolsetCudaString())) {
+ // CUDA does not have a field for this and does not honor the
+ // ProgramDataBaseFileName field in ClCompile. Work around this
+ // limitation by creating the directory and passing the flag ourselves.
+ pdb = this->ConvertPath(pdb, true);
+ ConvertToWindowsSlash(pdb);
+ std::string const clFd = "-Xcompiler=\"-Fd\\\"" + pdb + "\\\"\"";
+ cudaOptions.AppendFlagString("AdditionalOptions", clFd);
+ }
+ }
+
+ // CUDA automatically passes the proper '--machine' flag to nvcc
+ // for the current architecture, but does not reflect this default
+ // in the user-visible IDE settings. Set it explicitly.
+ if (this->Platform == "x64") {
+ cudaOptions.AddFlag("TargetMachinePlatform", "64");
}
// Convert the host compiler options to the toolset's abstractions
@@ -2535,40 +3100,39 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
cudaOptions.FixCudaCodeGeneration();
std::vector<std::string> targetDefines;
- this->GeneratorTarget->GetCompileDefinitions(targetDefines,
- configName.c_str(), "CUDA");
+ this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName,
+ "CUDA");
cudaOptions.AddDefines(targetDefines);
// Add a definition for the configuration name.
- std::string configDefine = "CMAKE_INTDIR=\"";
- configDefine += configName;
- configDefine += "\"";
+ std::string configDefine = cmStrCat("CMAKE_INTDIR=\"", configName, '"');
cudaOptions.AddDefine(configDefine);
- if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) {
- cudaOptions.AddDefine(exportMacro);
+ if (const std::string* exportMacro =
+ this->GeneratorTarget->GetExportMacro()) {
+ cudaOptions.AddDefine(*exportMacro);
}
- this->CudaOptions[configName] = pOptions.release();
+ // Get includes for this target
+ cudaOptions.AddIncludes(this->GetIncludes(configName, "CUDA"));
+ cudaOptions.AddFlag("UseHostInclude", "false");
+
+ this->CudaOptions[configName] = std::move(pOptions);
return true;
}
void cmVisualStudio10TargetGenerator::WriteCudaOptions(
- std::string const& configName, std::vector<std::string> const& includes)
+ Elem& e1, std::string const& configName)
{
if (!this->MSTools || !this->GlobalGenerator->IsCudaEnabled()) {
return;
}
- this->WriteString("<CudaCompile>\n", 2);
+ Elem e2(e1, "CudaCompile");
- Options& cudaOptions = *(this->CudaOptions[configName]);
- cudaOptions.AppendFlag("Include", includes);
- cudaOptions.AppendFlag("Include", "%(Include)");
- cudaOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
- "\n", "CUDA");
+ OptionsHelper cudaOptions(*(this->CudaOptions[configName]), e2);
+ cudaOptions.OutputAdditionalIncludeDirectories("CUDA");
+ cudaOptions.OutputPreprocessorDefinitions("CUDA");
cudaOptions.PrependInheritedString("AdditionalOptions");
- cudaOptions.OutputFlagMap(*this->BuildFileStream, " ");
-
- this->WriteString("</CudaCompile>\n", 2);
+ cudaOptions.OutputFlagMap();
}
bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions()
@@ -2576,10 +3140,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions()
if (!this->GlobalGenerator->IsCudaEnabled()) {
return true;
}
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeCudaLinkOptions(*i)) {
+ for (std::string const& c : this->Configurations) {
+ if (!this->ComputeCudaLinkOptions(c)) {
return false;
}
}
@@ -2589,27 +3151,14 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions()
bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions(
std::string const& configName)
{
- cmGlobalVisualStudio10Generator* gg =
- static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable()));
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
+ auto pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable());
Options& cudaLinkOptions = *pOptions;
// Determine if we need to do a device link
- bool doDeviceLinking = false;
- switch (this->GeneratorTarget->GetType()) {
- case cmStateEnums::SHARED_LIBRARY:
- case cmStateEnums::MODULE_LIBRARY:
- case cmStateEnums::EXECUTABLE:
- doDeviceLinking = true;
- break;
- case cmStateEnums::STATIC_LIBRARY:
- doDeviceLinking = this->GeneratorTarget->GetPropertyAsBool(
- "CUDA_RESOLVE_DEVICE_SYMBOLS");
- break;
- default:
- break;
- }
+ const bool doDeviceLinking = requireDeviceLinking(
+ *this->GeneratorTarget, *this->LocalGenerator, configName);
cudaLinkOptions.AddFlag("PerformDeviceLink",
doDeviceLinking ? "true" : "false");
@@ -2621,12 +3170,88 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions(
"-Wno-deprecated-gpu-targets");
}
- this->CudaLinkOptions[configName] = pOptions.release();
+ // For static libraries that have device linking enabled compute
+ // the libraries
+ if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY &&
+ doDeviceLinking) {
+ cmComputeLinkInformation* pcli =
+ this->GeneratorTarget->GetLinkInformation(configName);
+ if (!pcli) {
+ cmSystemTools::Error(
+ "CMake can not compute cmComputeLinkInformation for target: " +
+ this->Name);
+ return false;
+ }
+
+ // Would like to use:
+ // cmLinkLineDeviceComputer computer(this->LocalGenerator,
+ // this->LocalGenerator->GetStateSnapshot().GetDirectory());
+ // std::string computed_libs = computer.ComputeLinkLibraries(cli,
+ // std::string{}); but it outputs in "<libA> <libB>" format instead of
+ // "<libA>;<libB>"
+ // Note:
+ // Any modification of this algorithm should be reflected also in
+ // cmLinkLineDeviceComputer
+ cmComputeLinkInformation& cli = *pcli;
+ std::vector<std::string> libVec;
+ const std::string currentBinDir =
+ this->LocalGenerator->GetCurrentBinaryDirectory();
+ const auto& libs = cli.GetItems();
+ for (cmComputeLinkInformation::Item const& l : libs) {
+
+ if (l.Target) {
+ auto managedType = l.Target->GetManagedType(configName);
+ // Do not allow C# targets to be added to the LIB listing. LIB files
+ // are used for linking C++ dependencies. C# libraries do not have lib
+ // files. Instead, they compile down to C# reference libraries (DLL
+ // files). The
+ // `<ProjectReference>` elements added to the vcxproj are enough for
+ // the IDE to deduce the DLL file required by other C# projects that
+ // need its reference library.
+ if (managedType == cmGeneratorTarget::ManagedType::Managed) {
+ continue;
+ }
+ const auto type = l.Target->GetType();
+
+ bool skip = false;
+ switch (type) {
+ case cmStateEnums::SHARED_LIBRARY:
+ case cmStateEnums::MODULE_LIBRARY:
+ case cmStateEnums::INTERFACE_LIBRARY:
+ skip = true;
+ break;
+ case cmStateEnums::STATIC_LIBRARY:
+ skip = l.Target->GetPropertyAsBool("CUDA_RESOLVE_DEVICE_SYMBOLS");
+ break;
+ default:
+ break;
+ }
+ if (skip) {
+ continue;
+ }
+ }
+
+ if (l.IsPath) {
+ std::string path = this->LocalGenerator->MaybeConvertToRelativePath(
+ currentBinDir, l.Value);
+ ConvertToWindowsSlash(path);
+ if (!cmVS10IsTargetsFile(l.Value)) {
+ libVec.push_back(path);
+ }
+ } else {
+ libVec.push_back(l.Value);
+ }
+ }
+
+ cudaLinkOptions.AddFlag("AdditionalDependencies", libVec);
+ }
+
+ this->CudaLinkOptions[configName] = std::move(pOptions);
return true;
}
void cmVisualStudio10TargetGenerator::WriteCudaLinkOptions(
- std::string const& configName)
+ Elem& e1, std::string const& configName)
{
if (this->GeneratorTarget->GetType() > cmStateEnums::MODULE_LIBRARY) {
return;
@@ -2636,10 +3261,9 @@ void cmVisualStudio10TargetGenerator::WriteCudaLinkOptions(
return;
}
- this->WriteString("<CudaLink>\n", 2);
- Options& cudaLinkOptions = *(this->CudaLinkOptions[configName]);
- cudaLinkOptions.OutputFlagMap(*this->BuildFileStream, " ");
- this->WriteString("</CudaLink>\n", 2);
+ Elem e2(e1, "CudaLink");
+ OptionsHelper cudaLinkOptions(*(this->CudaLinkOptions[configName]), e2);
+ cudaLinkOptions.OutputFlagMap();
}
bool cmVisualStudio10TargetGenerator::ComputeMasmOptions()
@@ -2647,10 +3271,8 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions()
if (!this->GlobalGenerator->IsMasmEnabled()) {
return true;
}
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeMasmOptions(*i)) {
+ for (std::string const& c : this->Configurations) {
+ if (!this->ComputeMasmOptions(c)) {
return false;
}
}
@@ -2660,44 +3282,40 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions()
bool cmVisualStudio10TargetGenerator::ComputeMasmOptions(
std::string const& configName)
{
- cmGlobalVisualStudio10Generator* gg =
- static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::MasmCompiler, gg->GetMasmFlagTable()));
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
+ auto pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::MasmCompiler, gg->GetMasmFlagTable());
Options& masmOptions = *pOptions;
- std::string CONFIG = cmSystemTools::UpperCase(configName);
- std::string configFlagsVar = std::string("CMAKE_ASM_MASM_FLAGS_") + CONFIG;
- std::string flags =
- std::string(this->Makefile->GetSafeDefinition("CMAKE_ASM_MASM_FLAGS")) +
- std::string(" ") +
- std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
-
- masmOptions.Parse(flags.c_str());
- this->MasmOptions[configName] = pOptions.release();
+ std::string flags;
+ this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget,
+ "ASM_MASM", configName);
+
+ masmOptions.Parse(flags);
+
+ // Get includes for this target
+ masmOptions.AddIncludes(this->GetIncludes(configName, "ASM_MASM"));
+
+ this->MasmOptions[configName] = std::move(pOptions);
return true;
}
void cmVisualStudio10TargetGenerator::WriteMasmOptions(
- std::string const& configName, std::vector<std::string> const& includes)
+ Elem& e1, std::string const& configName)
{
if (!this->MSTools || !this->GlobalGenerator->IsMasmEnabled()) {
return;
}
- this->WriteString("<MASM>\n", 2);
+ Elem e2(e1, "MASM");
// Preprocessor definitions and includes are shared with clOptions.
- Options& clOptions = *(this->ClOptions[configName]);
- clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
- "\n", "ASM_MASM");
+ OptionsHelper clOptions(*(this->ClOptions[configName]), e2);
+ clOptions.OutputPreprocessorDefinitions("ASM_MASM");
- Options& masmOptions = *(this->MasmOptions[configName]);
- masmOptions.AppendFlag("IncludePaths", includes);
- masmOptions.AppendFlag("IncludePaths", "%(IncludePaths)");
+ OptionsHelper masmOptions(*(this->MasmOptions[configName]), e2);
+ masmOptions.OutputAdditionalIncludeDirectories("ASM_MASM");
masmOptions.PrependInheritedString("AdditionalOptions");
- masmOptions.OutputFlagMap(*this->BuildFileStream, " ");
-
- this->WriteString("</MASM>\n", 2);
+ masmOptions.OutputFlagMap();
}
bool cmVisualStudio10TargetGenerator::ComputeNasmOptions()
@@ -2705,10 +3323,8 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions()
if (!this->GlobalGenerator->IsNasmEnabled()) {
return true;
}
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeNasmOptions(*i)) {
+ for (std::string const& c : this->Configurations) {
+ if (!this->ComputeNasmOptions(c)) {
return false;
}
}
@@ -2718,74 +3334,71 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions()
bool cmVisualStudio10TargetGenerator::ComputeNasmOptions(
std::string const& configName)
{
- cmGlobalVisualStudio10Generator* gg =
- static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::NasmCompiler, gg->GetNasmFlagTable()));
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
+ auto pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::NasmCompiler, gg->GetNasmFlagTable());
Options& nasmOptions = *pOptions;
- std::string CONFIG = cmSystemTools::UpperCase(configName);
- std::string configFlagsVar = std::string("CMAKE_ASM_NASM_FLAGS_") + CONFIG;
- std::string flags =
- std::string(this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_FLAGS")) +
- std::string(" -f") + std::string(this->Makefile->GetSafeDefinition(
- "CMAKE_ASM_NASM_OBJECT_FORMAT")) +
- std::string(" ") +
- std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
- nasmOptions.Parse(flags.c_str());
- this->NasmOptions[configName] = pOptions.release();
+ std::string flags;
+ this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget,
+ "ASM_NASM", configName);
+ flags += " -f";
+ flags += this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_OBJECT_FORMAT");
+ nasmOptions.Parse(flags);
+
+ // Get includes for this target
+ nasmOptions.AddIncludes(this->GetIncludes(configName, "ASM_NASM"));
+
+ this->NasmOptions[configName] = std::move(pOptions);
return true;
}
void cmVisualStudio10TargetGenerator::WriteNasmOptions(
- std::string const& configName, std::vector<std::string> includes)
+ Elem& e1, std::string const& configName)
{
if (!this->GlobalGenerator->IsNasmEnabled()) {
return;
}
- this->WriteString("<NASM>\n", 2);
-
- Options& nasmOptions = *(this->NasmOptions[configName]);
- for (size_t i = 0; i < includes.size(); i++) {
- includes[i] += "\\";
- }
+ Elem e2(e1, "NASM");
- nasmOptions.AppendFlag("IncludePaths", includes);
- nasmOptions.AppendFlag("IncludePaths", "%(IncludePaths)");
- nasmOptions.OutputFlagMap(*this->BuildFileStream, " ");
+ std::vector<std::string> includes =
+ this->GetIncludes(configName, "ASM_NASM");
+ OptionsHelper nasmOptions(*(this->NasmOptions[configName]), e2);
+ nasmOptions.OutputAdditionalIncludeDirectories("ASM_NASM");
+ nasmOptions.OutputFlagMap();
nasmOptions.PrependInheritedString("AdditionalOptions");
- nasmOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
- "\n", "ASM_NASM");
+ nasmOptions.OutputPreprocessorDefinitions("ASM_NASM");
// Preprocessor definitions and includes are shared with clOptions.
- Options& clOptions = *(this->ClOptions[configName]);
- clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
- "\n", "ASM_NASM");
-
- this->WriteString("</NASM>\n", 2);
+ OptionsHelper clOptions(*(this->ClOptions[configName]), e2);
+ clOptions.OutputPreprocessorDefinitions("ASM_NASM");
}
void cmVisualStudio10TargetGenerator::WriteLibOptions(
- std::string const& config)
+ Elem& e1, std::string const& config)
{
if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY &&
this->GeneratorTarget->GetType() != cmStateEnums::OBJECT_LIBRARY) {
return;
}
+
+ const std::string& linkLanguage =
+ this->GeneratorTarget->GetLinkClosure(config)->LinkerLanguage;
+
std::string libflags;
this->LocalGenerator->GetStaticLibraryFlags(
- libflags, cmSystemTools::UpperCase(config), this->GeneratorTarget);
+ libflags, cmSystemTools::UpperCase(config), linkLanguage,
+ this->GeneratorTarget);
if (!libflags.empty()) {
- this->WriteString("<Lib>\n", 2);
- cmGlobalVisualStudio10Generator* gg =
- static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- cmVisualStudioGeneratorOptions libOptions(
- this->LocalGenerator, cmVisualStudioGeneratorOptions::Linker,
- gg->GetLibFlagTable(), 0, this);
- libOptions.Parse(libflags.c_str());
- libOptions.PrependInheritedString("AdditionalOptions");
- libOptions.OutputFlagMap(*this->BuildFileStream, " ");
- this->WriteString("</Lib>\n", 2);
+ Elem e2(e1, "Lib");
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
+ cmVS10GeneratorOptions libOptions(this->LocalGenerator,
+ cmVisualStudioGeneratorOptions::Linker,
+ gg->GetLibFlagTable(), this);
+ libOptions.Parse(libflags);
+ OptionsHelper oh(libOptions, e2);
+ oh.PrependInheritedString("AdditionalOptions");
+ oh.OutputFlagMap();
}
// We cannot generate metadata for static libraries. WindowsPhone
@@ -2793,16 +3406,13 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions(
// Link tool options even for static libraries.
if (this->GlobalGenerator->TargetsWindowsPhone() ||
this->GlobalGenerator->TargetsWindowsStore()) {
- this->WriteString("<Link>\n", 2);
- this->WriteString("<GenerateWindowsMetadata>false"
- "</GenerateWindowsMetadata>\n",
- 3);
- this->WriteString("</Link>\n", 2);
+ Elem e2(e1, "Link");
+ e2.Element("GenerateWindowsMetadata", "false");
}
}
void cmVisualStudio10TargetGenerator::WriteManifestOptions(
- std::string const& config)
+ Elem& e1, std::string const& config)
{
if (this->GeneratorTarget->GetType() != cmStateEnums::EXECUTABLE &&
this->GeneratorTarget->GetType() != cmStateEnums::SHARED_LIBRARY &&
@@ -2812,23 +3422,37 @@ void cmVisualStudio10TargetGenerator::WriteManifestOptions(
std::vector<cmSourceFile const*> manifest_srcs;
this->GeneratorTarget->GetManifests(manifest_srcs, config);
- if (!manifest_srcs.empty()) {
- this->WriteString("<Manifest>\n", 2);
- this->WriteString("<AdditionalManifestFiles>", 3);
- for (std::vector<cmSourceFile const*>::const_iterator mi =
- manifest_srcs.begin();
- mi != manifest_srcs.end(); ++mi) {
- std::string m = this->ConvertPath((*mi)->GetFullPath(), false);
- this->ConvertToWindowsSlash(m);
- (*this->BuildFileStream) << m << ";";
- }
- (*this->BuildFileStream) << "</AdditionalManifestFiles>\n";
- this->WriteString("</Manifest>\n", 2);
+
+ const char* dpiAware = this->GeneratorTarget->GetProperty("VS_DPI_AWARE");
+
+ if (!manifest_srcs.empty() || dpiAware) {
+ Elem e2(e1, "Manifest");
+ if (!manifest_srcs.empty()) {
+ std::ostringstream oss;
+ for (cmSourceFile const* mi : manifest_srcs) {
+ std::string m = this->ConvertPath(mi->GetFullPath(), false);
+ ConvertToWindowsSlash(m);
+ oss << m << ";";
+ }
+ e2.Element("AdditionalManifestFiles", oss.str());
+ }
+ if (dpiAware) {
+ if (!strcmp(dpiAware, "PerMonitor")) {
+ e2.Element("EnableDpiAwareness", "PerMonitorHighDPIAware");
+ } else if (cmIsOn(dpiAware)) {
+ e2.Element("EnableDpiAwareness", "true");
+ } else if (cmIsOff(dpiAware)) {
+ e2.Element("EnableDpiAwareness", "false");
+ } else {
+ cmSystemTools::Error("Bad parameter for VS_DPI_AWARE: " +
+ std::string(dpiAware));
+ }
+ }
}
}
void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
- std::string const& configName)
+ Elem& e1, std::string const& configName)
{
// Look through the sources for AndroidManifest.xml and use
// its location as the root source directory.
@@ -2836,123 +3460,89 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
{
std::vector<cmSourceFile const*> extraSources;
this->GeneratorTarget->GetExtraSources(extraSources, "");
- for (std::vector<cmSourceFile const*>::const_iterator si =
- extraSources.begin();
- si != extraSources.end(); ++si) {
+ for (cmSourceFile const* si : extraSources) {
if ("androidmanifest.xml" ==
- cmSystemTools::LowerCase((*si)->GetLocation().GetName())) {
- rootDir = (*si)->GetLocation().GetDirectory();
+ cmSystemTools::LowerCase(si->GetLocation().GetName())) {
+ rootDir = si->GetLocation().GetDirectory();
break;
}
}
}
// Tell MSBuild to launch Ant.
+ Elem e2(e1, "AntBuild");
{
std::string antBuildPath = rootDir;
- this->WriteString("<AntBuild>\n", 2);
- this->WriteString("<AntBuildPath>", 3);
- this->ConvertToWindowsSlash(antBuildPath);
- (*this->BuildFileStream) << cmVS10EscapeXML(antBuildPath)
- << "</AntBuildPath>\n";
+ ConvertToWindowsSlash(antBuildPath);
+ e2.Element("AntBuildPath", antBuildPath);
}
if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_SKIP_ANT_STEP")) {
- this->WriteString("<SkipAntStep>true</SkipAntStep>\n", 3);
+ e2.Element("SkipAntStep", "true");
}
if (this->GeneratorTarget->GetPropertyAsBool("ANDROID_PROGUARD")) {
- this->WriteString("<EnableProGuard>true</EnableProGuard>\n", 3);
+ e2.Element("EnableProGuard", "true");
}
if (const char* proGuardConfigLocation =
this->GeneratorTarget->GetProperty("ANDROID_PROGUARD_CONFIG_PATH")) {
- this->WriteString("<ProGuardConfigLocation>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(proGuardConfigLocation)
- << "</ProGuardConfigLocation>\n";
+ e2.Element("ProGuardConfigLocation", proGuardConfigLocation);
}
if (const char* securePropertiesLocation =
this->GeneratorTarget->GetProperty("ANDROID_SECURE_PROPS_PATH")) {
- this->WriteString("<SecurePropertiesLocation>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(securePropertiesLocation)
- << "</SecurePropertiesLocation>\n";
+ e2.Element("SecurePropertiesLocation", securePropertiesLocation);
}
if (const char* nativeLibDirectoriesExpression =
this->GeneratorTarget->GetProperty("ANDROID_NATIVE_LIB_DIRECTORIES")) {
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
- ge.Parse(nativeLibDirectoriesExpression);
- std::string nativeLibDirs =
- cge->Evaluate(this->LocalGenerator, configName);
- this->WriteString("<NativeLibDirectories>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(nativeLibDirs)
- << "</NativeLibDirectories>\n";
+ std::string nativeLibDirs = cmGeneratorExpression::Evaluate(
+ nativeLibDirectoriesExpression, this->LocalGenerator, configName);
+ e2.Element("NativeLibDirectories", nativeLibDirs);
}
if (const char* nativeLibDependenciesExpression =
this->GeneratorTarget->GetProperty(
"ANDROID_NATIVE_LIB_DEPENDENCIES")) {
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
- ge.Parse(nativeLibDependenciesExpression);
- std::string nativeLibDeps =
- cge->Evaluate(this->LocalGenerator, configName);
- this->WriteString("<NativeLibDependencies>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(nativeLibDeps)
- << "</NativeLibDependencies>\n";
+ std::string nativeLibDeps = cmGeneratorExpression::Evaluate(
+ nativeLibDependenciesExpression, this->LocalGenerator, configName);
+ e2.Element("NativeLibDependencies", nativeLibDeps);
}
if (const char* javaSourceDir =
this->GeneratorTarget->GetProperty("ANDROID_JAVA_SOURCE_DIR")) {
- this->WriteString("<JavaSourceDir>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(javaSourceDir)
- << "</JavaSourceDir>\n";
+ e2.Element("JavaSourceDir", javaSourceDir);
}
if (const char* jarDirectoriesExpression =
this->GeneratorTarget->GetProperty("ANDROID_JAR_DIRECTORIES")) {
- cmGeneratorExpression ge;
- CM_AUTO_PTR<cmCompiledGeneratorExpression> cge =
- ge.Parse(jarDirectoriesExpression);
- std::string jarDirectories =
- cge->Evaluate(this->LocalGenerator, configName);
- this->WriteString("<JarDirectories>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(jarDirectories)
- << "</JarDirectories>\n";
+ std::string jarDirectories = cmGeneratorExpression::Evaluate(
+ jarDirectoriesExpression, this->LocalGenerator, configName);
+ e2.Element("JarDirectories", jarDirectories);
}
if (const char* jarDeps =
this->GeneratorTarget->GetProperty("ANDROID_JAR_DEPENDENCIES")) {
- this->WriteString("<JarDependencies>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(jarDeps)
- << "</JarDependencies>\n";
+ e2.Element("JarDependencies", jarDeps);
}
if (const char* assetsDirectories =
this->GeneratorTarget->GetProperty("ANDROID_ASSETS_DIRECTORIES")) {
- this->WriteString("<AssetsDirectories>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(assetsDirectories)
- << "</AssetsDirectories>\n";
+ e2.Element("AssetsDirectories", assetsDirectories);
}
{
std::string manifest_xml = rootDir + "/AndroidManifest.xml";
- this->ConvertToWindowsSlash(manifest_xml);
- this->WriteString("<AndroidManifestLocation>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(manifest_xml)
- << "</AndroidManifestLocation>\n";
+ ConvertToWindowsSlash(manifest_xml);
+ e2.Element("AndroidManifestLocation", manifest_xml);
}
if (const char* antAdditionalOptions =
this->GeneratorTarget->GetProperty("ANDROID_ANT_ADDITIONAL_OPTIONS")) {
- this->WriteString("<AdditionalOptions>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(antAdditionalOptions)
- << " %(AdditionalOptions)</AdditionalOptions>\n";
+ e2.Element("AdditionalOptions",
+ std::string(antAdditionalOptions) + " %(AdditionalOptions)");
}
-
- this->WriteString("</AntBuild>\n", 2);
}
bool cmVisualStudio10TargetGenerator::ComputeLinkOptions()
@@ -2960,10 +3550,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions()
if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE ||
this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) {
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeLinkOptions(*i)) {
+ for (std::string const& c : this->Configurations) {
+ if (!this->ComputeLinkOptions(c)) {
return false;
}
}
@@ -2974,10 +3562,9 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions()
bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
std::string const& config)
{
- cmGlobalVisualStudio10Generator* gg =
- static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
- CM_AUTO_PTR<Options> pOptions(new Options(
- this->LocalGenerator, Options::Linker, gg->GetLinkFlagTable(), 0, this));
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
+ auto pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::Linker, gg->GetLinkFlagTable(), this);
Options& linkOptions = *pOptions;
cmGeneratorTarget::LinkClosure const* linkClosure =
@@ -2986,8 +3573,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
const std::string& linkLanguage = linkClosure->LinkerLanguage;
if (linkLanguage.empty()) {
cmSystemTools::Error(
- "CMake can not determine linker language for target: ",
- this->Name.c_str());
+ "CMake can not determine linker language for target: " + this->Name);
return false;
}
@@ -3001,100 +3587,88 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
linkType = "EXE";
}
std::string flags;
- std::string linkFlagVarBase = "CMAKE_";
- linkFlagVarBase += linkType;
- linkFlagVarBase += "_LINKER_FLAGS";
+ std::string linkFlagVarBase = cmStrCat("CMAKE_", linkType, "_LINKER_FLAGS");
flags += " ";
- flags += this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
- linkFlagVarBase.c_str());
+ flags += this->Makefile->GetRequiredDefinition(linkFlagVarBase);
std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG;
flags += " ";
- flags += this->GeneratorTarget->Target->GetMakefile()->GetRequiredDefinition(
- linkFlagVar.c_str());
+ flags += this->Makefile->GetRequiredDefinition(linkFlagVar);
const char* targetLinkFlags =
this->GeneratorTarget->GetProperty("LINK_FLAGS");
if (targetLinkFlags) {
flags += " ";
flags += targetLinkFlags;
}
- std::string flagsProp = "LINK_FLAGS_";
- flagsProp += CONFIG;
+ std::string flagsProp = cmStrCat("LINK_FLAGS_", CONFIG);
if (const char* flagsConfig =
- this->GeneratorTarget->GetProperty(flagsProp.c_str())) {
+ this->GeneratorTarget->GetProperty(flagsProp)) {
flags += " ";
flags += flagsConfig;
}
+ std::vector<std::string> opts;
+ this->GeneratorTarget->GetLinkOptions(opts, config, linkLanguage);
+ // LINK_OPTIONS are escaped.
+ this->LocalGenerator->AppendCompileOptions(flags, opts);
+
cmComputeLinkInformation* pcli =
- this->GeneratorTarget->GetLinkInformation(config.c_str());
+ this->GeneratorTarget->GetLinkInformation(config);
if (!pcli) {
cmSystemTools::Error(
- "CMake can not compute cmComputeLinkInformation for target: ",
- this->Name.c_str());
+ "CMake can not compute cmComputeLinkInformation for target: " +
+ this->Name);
return false;
}
cmComputeLinkInformation& cli = *pcli;
std::vector<std::string> libVec;
std::vector<std::string> vsTargetVec;
- this->AddLibraries(cli, libVec, vsTargetVec);
- if (std::find(linkClosure->Languages.begin(), linkClosure->Languages.end(),
- "CUDA") != linkClosure->Languages.end()) {
+ this->AddLibraries(cli, libVec, vsTargetVec, config);
+ if (cmContains(linkClosure->Languages, "CUDA") &&
+ this->CudaOptions[config] != nullptr) {
switch (this->CudaOptions[config]->GetCudaRuntime()) {
case cmVisualStudioGeneratorOptions::CudaRuntimeStatic:
+ libVec.push_back("cudadevrt.lib");
libVec.push_back("cudart_static.lib");
break;
case cmVisualStudioGeneratorOptions::CudaRuntimeShared:
+ libVec.push_back("cudadevrt.lib");
libVec.push_back("cudart.lib");
break;
case cmVisualStudioGeneratorOptions::CudaRuntimeNone:
break;
}
}
- std::string standardLibsVar = "CMAKE_";
- standardLibsVar += linkLanguage;
- standardLibsVar += "_STANDARD_LIBRARIES";
- std::string const libs =
- this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
+ std::string standardLibsVar =
+ cmStrCat("CMAKE_", linkLanguage, "_STANDARD_LIBRARIES");
+ std::string const& libs = this->Makefile->GetSafeDefinition(standardLibsVar);
cmSystemTools::ParseWindowsCommandLine(libs.c_str(), libVec);
linkOptions.AddFlag("AdditionalDependencies", libVec);
// Populate TargetsFileAndConfigsVec
- for (std::vector<std::string>::iterator ti = vsTargetVec.begin();
- ti != vsTargetVec.end(); ++ti) {
- this->AddTargetsFileAndConfigPair(*ti, config);
+ for (std::string const& ti : vsTargetVec) {
+ this->AddTargetsFileAndConfigPair(ti, config);
}
std::vector<std::string> const& ldirs = cli.GetDirectories();
std::vector<std::string> linkDirs;
- for (std::vector<std::string>::const_iterator d = ldirs.begin();
- d != ldirs.end(); ++d) {
+ for (std::string const& d : ldirs) {
// first just full path
- linkDirs.push_back(*d);
+ linkDirs.push_back(d);
// next path with configuration type Debug, Release, etc
- linkDirs.push_back(*d + "/$(Configuration)");
+ linkDirs.push_back(d + "/$(Configuration)");
}
linkDirs.push_back("%(AdditionalLibraryDirectories)");
linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs);
- std::string targetName;
- std::string targetNameSO;
- std::string targetNameFull;
- std::string targetNameImport;
- std::string targetNamePDB;
+ cmGeneratorTarget::Names targetNames;
if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) {
- this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull,
- targetNameImport, targetNamePDB,
- config.c_str());
+ targetNames = this->GeneratorTarget->GetExecutableNames(config);
} else {
- this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO,
- targetNameFull, targetNameImport,
- targetNamePDB, config.c_str());
+ targetNames = this->GeneratorTarget->GetLibraryNames(config);
}
if (this->MSTools) {
- linkOptions.AddFlag("Version", "");
-
if (this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) {
if (this->GlobalGenerator->TargetsWindowsCE()) {
linkOptions.AddFlag("SubSystem", "WindowsCE");
@@ -3130,16 +3704,15 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
linkOptions.AddFlag("GenerateDebugInformation", "false");
- std::string pdb = this->GeneratorTarget->GetPDBDirectory(config.c_str());
- pdb += "/";
- pdb += targetNamePDB;
- std::string imLib = this->GeneratorTarget->GetDirectory(
- config.c_str(), cmStateEnums::ImportLibraryArtifact);
- imLib += "/";
- imLib += targetNameImport;
+ std::string pdb = cmStrCat(this->GeneratorTarget->GetPDBDirectory(config),
+ '/', targetNames.PDB);
+ std::string imLib =
+ cmStrCat(this->GeneratorTarget->GetDirectory(
+ config, cmStateEnums::ImportLibraryArtifact),
+ '/', targetNames.ImportLibrary);
- linkOptions.AddFlag("ImportLibrary", imLib.c_str());
- linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
+ linkOptions.AddFlag("ImportLibrary", imLib);
+ linkOptions.AddFlag("ProgramDataBaseFile", pdb);
// A Windows Runtime component uses internal .NET metadata,
// so does not have an import library.
@@ -3160,16 +3733,17 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", "ole32.lib");
}
} else if (this->NsightTegra) {
- linkOptions.AddFlag("SoName", targetNameSO.c_str());
+ linkOptions.AddFlag("SoName", targetNames.SharedObject);
}
- linkOptions.Parse(flags.c_str());
+ linkOptions.Parse(flags);
+ linkOptions.FixManifestUACFlags();
if (this->MSTools) {
cmGeneratorTarget::ModuleDefinitionInfo const* mdi =
this->GeneratorTarget->GetModuleDefinitionInfo(config);
if (mdi && !mdi->DefFile.empty()) {
- linkOptions.AddFlag("ModuleDefinitionFile", mdi->DefFile.c_str());
+ linkOptions.AddFlag("ModuleDefinitionFile", mdi->DefFile);
}
linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries",
"%(IgnoreSpecificDefaultLibraries)");
@@ -3187,17 +3761,24 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
}
}
- this->LinkOptions[config] = pOptions.release();
+ // Managed code cannot be linked with /DEBUG:FASTLINK
+ if (this->Managed) {
+ if (const char* debug = linkOptions.GetFlag("GenerateDebugInformation")) {
+ if (strcmp(debug, "DebugFastLink") == 0) {
+ linkOptions.AddFlag("GenerateDebugInformation", "Debug");
+ }
+ }
+ }
+
+ this->LinkOptions[config] = std::move(pOptions);
return true;
}
bool cmVisualStudio10TargetGenerator::ComputeLibOptions()
{
if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeLibOptions(*i)) {
+ for (std::string const& c : this->Configurations) {
+ if (!this->ComputeLibOptions(c)) {
return false;
}
}
@@ -3209,24 +3790,24 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions(
std::string const& config)
{
cmComputeLinkInformation* pcli =
- this->GeneratorTarget->GetLinkInformation(config.c_str());
+ this->GeneratorTarget->GetLinkInformation(config);
if (!pcli) {
cmSystemTools::Error(
- "CMake can not compute cmComputeLinkInformation for target: ",
- this->Name.c_str());
+ "CMake can not compute cmComputeLinkInformation for target: " +
+ this->Name);
return false;
}
cmComputeLinkInformation& cli = *pcli;
- typedef cmComputeLinkInformation::ItemVector ItemVector;
+ using ItemVector = cmComputeLinkInformation::ItemVector;
const ItemVector& libs = cli.GetItems();
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
- for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
- if (l->IsPath && cmVS10IsTargetsFile(l->Value)) {
- std::string path = this->LocalGenerator->ConvertToRelativePath(
- currentBinDir, l->Value.c_str());
- this->ConvertToWindowsSlash(path);
+ for (cmComputeLinkInformation::Item const& l : libs) {
+ if (l.IsPath && cmVS10IsTargetsFile(l.Value)) {
+ std::string path = this->LocalGenerator->MaybeConvertToRelativePath(
+ currentBinDir, l.Value);
+ ConvertToWindowsSlash(path);
this->AddTargetsFileAndConfigPair(path, config);
}
}
@@ -3235,52 +3816,90 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions(
}
void cmVisualStudio10TargetGenerator::WriteLinkOptions(
- std::string const& config)
+ Elem& e1, std::string const& config)
{
if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY ||
this->GeneratorTarget->GetType() > cmStateEnums::MODULE_LIBRARY) {
return;
}
- if (csproj == this->ProjectType) {
+ if (this->ProjectType == csproj) {
return;
}
- Options& linkOptions = *(this->LinkOptions[config]);
- this->WriteString("<Link>\n", 2);
- linkOptions.PrependInheritedString("AdditionalOptions");
- linkOptions.OutputFlagMap(*this->BuildFileStream, " ");
+ {
+ Elem e2(e1, "Link");
+ OptionsHelper linkOptions(*(this->LinkOptions[config]), e2);
+ linkOptions.PrependInheritedString("AdditionalOptions");
+ linkOptions.OutputFlagMap();
+ }
- this->WriteString("</Link>\n", 2);
if (!this->GlobalGenerator->NeedLinkLibraryDependencies(
this->GeneratorTarget)) {
- this->WriteString("<ProjectReference>\n", 2);
- this->WriteString(
- "<LinkLibraryDependencies>false</LinkLibraryDependencies>\n", 3);
- this->WriteString("</ProjectReference>\n", 2);
+ Elem e2(e1, "ProjectReference");
+ e2.Element("LinkLibraryDependencies", "false");
}
}
void cmVisualStudio10TargetGenerator::AddLibraries(
- cmComputeLinkInformation& cli, std::vector<std::string>& libVec,
- std::vector<std::string>& vsTargetVec)
+ const cmComputeLinkInformation& cli, std::vector<std::string>& libVec,
+ std::vector<std::string>& vsTargetVec, const std::string& config)
{
- typedef cmComputeLinkInformation::ItemVector ItemVector;
+ using ItemVector = cmComputeLinkInformation::ItemVector;
ItemVector const& libs = cli.GetItems();
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
- for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
- if (l->IsPath) {
- std::string path = this->LocalGenerator->ConvertToRelativePath(
- currentBinDir, l->Value.c_str());
- this->ConvertToWindowsSlash(path);
- if (cmVS10IsTargetsFile(l->Value)) {
+ for (cmComputeLinkInformation::Item const& l : libs) {
+ if (l.Target) {
+ auto managedType = l.Target->GetManagedType(config);
+ if (managedType != cmGeneratorTarget::ManagedType::Native &&
+ this->GeneratorTarget->GetManagedType(config) !=
+ cmGeneratorTarget::ManagedType::Native &&
+ l.Target->IsImported()) {
+ auto location = l.Target->GetFullPath(config);
+ if (!location.empty()) {
+ ConvertToWindowsSlash(location);
+ switch (this->ProjectType) {
+ case csproj:
+ // If the target we want to "link" to is an imported managed
+ // target and this is a C# project, we add a hint reference. This
+ // reference is written to project file in
+ // WriteDotNetReferences().
+ this->DotNetHintReferences[config].push_back(
+ DotNetHintReference(l.Target->GetName(), location));
+ break;
+ case vcxproj:
+ // Add path of assembly to list of using-directories, so the
+ // managed assembly can be used by '#using <assembly.dll>' in
+ // code.
+ this->AdditionalUsingDirectories[config].insert(
+ cmSystemTools::GetFilenamePath(location));
+ break;
+ }
+ }
+ }
+ // Do not allow C# targets to be added to the LIB listing. LIB files are
+ // used for linking C++ dependencies. C# libraries do not have lib files.
+ // Instead, they compile down to C# reference libraries (DLL files). The
+ // `<ProjectReference>` elements added to the vcxproj are enough for the
+ // IDE to deduce the DLL file required by other C# projects that need its
+ // reference library.
+ if (managedType == cmGeneratorTarget::ManagedType::Managed) {
+ continue;
+ }
+ }
+
+ if (l.IsPath) {
+ std::string path = this->LocalGenerator->MaybeConvertToRelativePath(
+ currentBinDir, l.Value);
+ ConvertToWindowsSlash(path);
+ if (cmVS10IsTargetsFile(l.Value)) {
vsTargetVec.push_back(path);
} else {
libVec.push_back(path);
}
- } else if (!l->Target ||
- l->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
- libVec.push_back(l->Value);
+ } else if (!l.Target ||
+ l.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ libVec.push_back(l.Value);
}
}
}
@@ -3288,13 +3907,10 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
void cmVisualStudio10TargetGenerator::AddTargetsFileAndConfigPair(
std::string const& targetsFile, std::string const& config)
{
- for (std::vector<TargetsFileAndConfigs>::iterator i =
- this->TargetsFileAndConfigsVec.begin();
- i != this->TargetsFileAndConfigsVec.end(); ++i) {
- if (cmSystemTools::ComparePath(targetsFile, i->File)) {
- if (std::find(i->Configs.begin(), i->Configs.end(), config) ==
- i->Configs.end()) {
- i->Configs.push_back(config);
+ for (TargetsFileAndConfigs& i : this->TargetsFileAndConfigsVec) {
+ if (cmSystemTools::ComparePath(targetsFile, i.File)) {
+ if (!cmContains(i.Configs, config)) {
+ i.Configs.push_back(config);
}
return;
}
@@ -3306,12 +3922,12 @@ void cmVisualStudio10TargetGenerator::AddTargetsFileAndConfigPair(
}
void cmVisualStudio10TargetGenerator::WriteMidlOptions(
- std::string const& /*config*/, std::vector<std::string> const& includes)
+ Elem& e1, std::string const& configName)
{
if (!this->MSTools) {
return;
}
- if (csproj == this->ProjectType) {
+ if (this->ProjectType == csproj) {
return;
}
@@ -3330,74 +3946,64 @@ void cmVisualStudio10TargetGenerator::WriteMidlOptions(
// up (for non-directory form, it ends up looking in project binary dir
// only). Perhaps there's something to be done to make this more automatic
// on the CMake side?
- this->WriteString("<Midl>\n", 2);
- this->WriteString("<AdditionalIncludeDirectories>", 3);
- for (std::vector<std::string>::const_iterator i = includes.begin();
- i != includes.end(); ++i) {
- *this->BuildFileStream << cmVS10EscapeXML(*i) << ";";
- }
- this->WriteString("%(AdditionalIncludeDirectories)"
- "</AdditionalIncludeDirectories>\n",
- 0);
- this->WriteString("<OutputDirectory>$(ProjectDir)/$(IntDir)"
- "</OutputDirectory>\n",
- 3);
- this->WriteString("<HeaderFileName>%(Filename).h</HeaderFileName>\n", 3);
- this->WriteString("<TypeLibraryName>%(Filename).tlb</TypeLibraryName>\n", 3);
- this->WriteString("<InterfaceIdentifierFileName>"
- "%(Filename)_i.c</InterfaceIdentifierFileName>\n",
- 3);
- this->WriteString("<ProxyFileName>%(Filename)_p.c</ProxyFileName>\n", 3);
- this->WriteString("</Midl>\n", 2);
+ std::vector<std::string> const includes =
+ this->GetIncludes(configName, "MIDL");
+ std::ostringstream oss;
+ for (std::string const& i : includes) {
+ oss << i << ";";
+ }
+ oss << "%(AdditionalIncludeDirectories)";
+
+ Elem e2(e1, "Midl");
+ e2.Element("AdditionalIncludeDirectories", oss.str());
+ e2.Element("OutputDirectory", "$(ProjectDir)/$(IntDir)");
+ e2.Element("HeaderFileName", "%(Filename).h");
+ e2.Element("TypeLibraryName", "%(Filename).tlb");
+ e2.Element("InterfaceIdentifierFileName", "%(Filename)_i.c");
+ e2.Element("ProxyFileName", "%(Filename)_p.c");
}
-void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
+void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups(Elem& e0)
{
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- std::vector<std::string> includes;
- this->LocalGenerator->GetIncludeDirectories(
- includes, this->GeneratorTarget, "C", i->c_str());
- for (std::vector<std::string>::iterator ii = includes.begin();
- ii != includes.end(); ++ii) {
- this->ConvertToWindowsSlash(*ii);
- }
- this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1);
- *this->BuildFileStream << "\n";
+ if (this->ProjectType == csproj) {
+ return;
+ }
+ for (const std::string& c : this->Configurations) {
+ Elem e1(e0, "ItemDefinitionGroup");
+ e1.Attribute("Condition", this->CalcCondition(c));
+
// output cl compile flags <ClCompile></ClCompile>
if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
- this->WriteClOptions(*i, includes);
+ this->WriteClOptions(e1, c);
// output rc compile flags <ResourceCompile></ResourceCompile>
- this->WriteRCOptions(*i, includes);
- this->WriteCudaOptions(*i, includes);
- this->WriteMasmOptions(*i, includes);
- this->WriteNasmOptions(*i, includes);
+ this->WriteRCOptions(e1, c);
+ this->WriteCudaOptions(e1, c);
+ this->WriteMasmOptions(e1, c);
+ this->WriteNasmOptions(e1, c);
}
// output midl flags <Midl></Midl>
- this->WriteMidlOptions(*i, includes);
+ this->WriteMidlOptions(e1, c);
// write events
- if (csproj != this->ProjectType) {
- this->WriteEvents(*i);
+ if (this->ProjectType != csproj) {
+ this->WriteEvents(e1, c);
}
// output link flags <Link></Link>
- this->WriteLinkOptions(*i);
- this->WriteCudaLinkOptions(*i);
+ this->WriteLinkOptions(e1, c);
+ this->WriteCudaLinkOptions(e1, c);
// output lib flags <Lib></Lib>
- this->WriteLibOptions(*i);
+ this->WriteLibOptions(e1, c);
// output manifest flags <Manifest></Manifest>
- this->WriteManifestOptions(*i);
+ this->WriteManifestOptions(e1, c);
if (this->NsightTegra &&
this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE &&
this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) {
- this->WriteAntBuildOptions(*i);
+ this->WriteAntBuildOptions(e1, c);
}
- this->WriteString("</ItemDefinitionGroup>\n", 1);
}
}
void cmVisualStudio10TargetGenerator::WriteEvents(
- std::string const& configName)
+ Elem& e1, std::string const& configName)
{
bool addedPrelink = false;
cmGeneratorTarget::ModuleDefinitionInfo const* mdi =
@@ -3408,80 +4014,76 @@ void cmVisualStudio10TargetGenerator::WriteEvents(
this->GeneratorTarget->GetPreLinkCommands();
this->GlobalGenerator->AddSymbolExportCommand(this->GeneratorTarget,
commands, configName);
- this->WriteEvent("PreLinkEvent", commands, configName);
+ this->WriteEvent(e1, "PreLinkEvent", commands, configName);
}
if (!addedPrelink) {
- this->WriteEvent("PreLinkEvent",
+ this->WriteEvent(e1, "PreLinkEvent",
this->GeneratorTarget->GetPreLinkCommands(), configName);
}
- this->WriteEvent("PreBuildEvent",
+ this->WriteEvent(e1, "PreBuildEvent",
this->GeneratorTarget->GetPreBuildCommands(), configName);
- this->WriteEvent("PostBuildEvent",
+ this->WriteEvent(e1, "PostBuildEvent",
this->GeneratorTarget->GetPostBuildCommands(), configName);
}
void cmVisualStudio10TargetGenerator::WriteEvent(
- const char* name, std::vector<cmCustomCommand> const& commands,
+ Elem& e1, const char* name, std::vector<cmCustomCommand> const& commands,
std::string const& configName)
{
if (commands.empty()) {
return;
}
- this->WriteString("<", 2);
- (*this->BuildFileStream) << name << ">\n";
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
std::string script;
const char* pre = "";
std::string comment;
- for (std::vector<cmCustomCommand>::const_iterator i = commands.begin();
- i != commands.end(); ++i) {
- cmCustomCommandGenerator ccg(*i, configName, this->LocalGenerator);
- comment += pre;
- comment += lg->ConstructComment(ccg);
- script += pre;
- pre = "\n";
- script += cmVS10EscapeXML(lg->ConstructScript(ccg));
+ for (cmCustomCommand const& cc : commands) {
+ cmCustomCommandGenerator ccg(cc, configName, lg);
+ if (!ccg.HasOnlyEmptyCommandLines()) {
+ comment += pre;
+ comment += lg->ConstructComment(ccg);
+ script += pre;
+ pre = "\n";
+ script += lg->ConstructScript(ccg);
+ }
}
comment = cmVS10EscapeComment(comment);
- if (csproj != this->ProjectType) {
- this->WriteString("<Message>", 3);
- (*this->BuildFileStream) << cmVS10EscapeXML(comment) << "</Message>\n";
- this->WriteString("<Command>", 3);
+ if (this->ProjectType != csproj) {
+ Elem e2(e1, name);
+ e2.Element("Message", comment);
+ e2.Element("Command", script);
} else {
- if (!comment.empty()) {
- (*this->BuildFileStream) << "echo " << cmVS10EscapeXML(comment) << "\n";
+ std::string strippedComment = comment;
+ strippedComment.erase(
+ std::remove(strippedComment.begin(), strippedComment.end(), '\t'),
+ strippedComment.end());
+ std::ostringstream oss;
+ if (!comment.empty() && !strippedComment.empty()) {
+ oss << "echo " << comment << "\n";
}
+ oss << script << "\n";
+ e1.Element(name, oss.str());
}
- (*this->BuildFileStream) << script;
- if (csproj != this->ProjectType) {
- (*this->BuildFileStream) << "</Command>";
- }
- (*this->BuildFileStream) << "\n";
- this->WriteString("</", 2);
- (*this->BuildFileStream) << name << ">\n";
}
-void cmVisualStudio10TargetGenerator::WriteProjectReferences()
+void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
{
cmGlobalGenerator::TargetDependSet const& unordered =
this->GlobalGenerator->GetTargetDirectDepends(this->GeneratorTarget);
- typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet
- OrderedTargetDependSet;
+ using OrderedTargetDependSet =
+ cmGlobalVisualStudioGenerator::OrderedTargetDependSet;
OrderedTargetDependSet depends(unordered, CMAKE_CHECK_BUILD_SYSTEM_TARGET);
- this->WriteString("<ItemGroup>\n", 1);
- for (OrderedTargetDependSet::const_iterator i = depends.begin();
- i != depends.end(); ++i) {
- cmGeneratorTarget const* dt = *i;
+ Elem e1(e0, "ItemGroup");
+ e1.SetHasElements();
+ for (cmGeneratorTarget const* dt : depends) {
if (dt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
// skip fortran targets as they can not be processed by MSBuild
// the only reference will be in the .sln file
- if (static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
- ->TargetIsFortranOnly(dt)) {
+ if (this->GlobalGenerator->TargetIsFortranOnly(dt)) {
continue;
}
- this->WriteString("<ProjectReference Include=\"", 2);
cmLocalGenerator* lg = dt->GetLocalGenerator();
std::string name = dt->GetName();
std::string path;
@@ -3489,32 +4091,25 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
if (p) {
path = p;
} else {
- path = lg->GetCurrentBinaryDirectory();
- path += "/";
- path += dt->GetName();
- path += computeProjectFileExtension(dt);
- }
- this->ConvertToWindowsSlash(path);
- (*this->BuildFileStream) << cmVS10EscapeXML(path) << "\">\n";
- this->WriteString("<Project>", 3);
- (*this->BuildFileStream)
- << "{" << this->GlobalGenerator->GetGUID(name.c_str()) << "}";
- (*this->BuildFileStream) << "</Project>\n";
- this->WriteString("<Name>", 3);
- (*this->BuildFileStream) << name << "</Name>\n";
- if (csproj == this->ProjectType) {
- if (!static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
- ->TargetCanBeReferenced(dt)) {
- this->WriteString(
- "<ReferenceOutputAssembly>false</ReferenceOutputAssembly>\n", 3);
- }
+ path = cmStrCat(lg->GetCurrentBinaryDirectory(), '/', dt->GetName(),
+ computeProjectFileExtension(dt));
+ }
+ ConvertToWindowsSlash(path);
+ Elem e2(e1, "ProjectReference");
+ e2.Attribute("Include", path);
+ e2.Element("Project", "{" + this->GlobalGenerator->GetGUID(name) + "}");
+ e2.Element("Name", name);
+ this->WriteDotNetReferenceCustomTags(e2, name);
+
+ // Don't reference targets that don't produce any output.
+ if (dt->GetManagedType("") == cmGeneratorTarget::ManagedType::Undefined) {
+ e2.Element("ReferenceOutputAssembly", "false");
+ e2.Element("CopyToOutputDirectory", "Never");
}
- this->WriteString("</ProjectReference>\n", 2);
}
- this->WriteString("</ItemGroup>\n", 1);
}
-void cmVisualStudio10TargetGenerator::WritePlatformExtensions()
+void cmVisualStudio10TargetGenerator::WritePlatformExtensions(Elem& e1)
{
// This only applies to Windows 10 apps
if (this->GlobalGenerator->TargetsWindowsStore() &&
@@ -3522,53 +4117,44 @@ void cmVisualStudio10TargetGenerator::WritePlatformExtensions()
const char* desktopExtensionsVersion =
this->GeneratorTarget->GetProperty("VS_DESKTOP_EXTENSIONS_VERSION");
if (desktopExtensionsVersion) {
- this->WriteSinglePlatformExtension("WindowsDesktop",
+ this->WriteSinglePlatformExtension(e1, "WindowsDesktop",
desktopExtensionsVersion);
}
const char* mobileExtensionsVersion =
this->GeneratorTarget->GetProperty("VS_MOBILE_EXTENSIONS_VERSION");
if (mobileExtensionsVersion) {
- this->WriteSinglePlatformExtension("WindowsMobile",
+ this->WriteSinglePlatformExtension(e1, "WindowsMobile",
mobileExtensionsVersion);
}
}
}
void cmVisualStudio10TargetGenerator::WriteSinglePlatformExtension(
- std::string const& extension, std::string const& version)
+ Elem& e1, std::string const& extension, std::string const& version)
{
- this->WriteString("<Import Project=", 2);
- (*this->BuildFileStream)
- << "\"$([Microsoft.Build.Utilities.ToolLocationHelper]"
- << "::GetPlatformExtensionSDKLocation(`" << extension
- << ", Version=" << version
- << "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, "
- << "$(ExtensionSDKDirectoryRoot), null))"
- << "\\DesignTime\\CommonConfiguration\\Neutral\\" << extension
- << ".props\" "
- << "Condition=\"exists('$("
- << "[Microsoft.Build.Utilities.ToolLocationHelper]"
- << "::GetPlatformExtensionSDKLocation(`" << extension
- << ", Version=" << version
- << "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, "
- << "$(ExtensionSDKDirectoryRoot), null))"
- << "\\DesignTime\\CommonConfiguration\\Neutral\\" << extension
- << ".props')\" />\n";
+ const std::string s = "$([Microsoft.Build.Utilities.ToolLocationHelper]"
+ "::GetPlatformExtensionSDKLocation(`" +
+ extension + ", Version=" + version +
+ "`, $(TargetPlatformIdentifier), $(TargetPlatformVersion), null, "
+ "$(ExtensionSDKDirectoryRoot), null))"
+ "\\DesignTime\\CommonConfiguration\\Neutral\\" +
+ extension + ".props";
+
+ Elem e2(e1, "Import");
+ e2.Attribute("Project", s);
+ e2.Attribute("Condition", "exists('" + s + "')");
}
-void cmVisualStudio10TargetGenerator::WriteSDKReferences()
+void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0)
{
std::vector<std::string> sdkReferences;
- bool hasWrittenItemGroup = false;
+ std::unique_ptr<Elem> spe1;
if (const char* vsSDKReferences =
this->GeneratorTarget->GetProperty("VS_SDK_REFERENCES")) {
- cmSystemTools::ExpandListArgument(vsSDKReferences, sdkReferences);
- this->WriteString("<ItemGroup>\n", 1);
- hasWrittenItemGroup = true;
- for (std::vector<std::string>::iterator ri = sdkReferences.begin();
- ri != sdkReferences.end(); ++ri) {
- this->WriteString("<SDKReference Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(*ri) << "\"/>\n";
+ cmExpandList(vsSDKReferences, sdkReferences);
+ spe1 = cm::make_unique<Elem>(e0, "ItemGroup");
+ for (std::string const& ri : sdkReferences) {
+ Elem(*spe1, "SDKReference").Attribute("Include", ri);
}
}
@@ -3584,38 +4170,34 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences()
if (desktopExtensionsVersion || mobileExtensionsVersion ||
iotExtensionsVersion) {
- if (!hasWrittenItemGroup) {
- this->WriteString("<ItemGroup>\n", 1);
- hasWrittenItemGroup = true;
+ if (!spe1) {
+ spe1 = cm::make_unique<Elem>(e0, "ItemGroup");
}
if (desktopExtensionsVersion) {
- this->WriteSingleSDKReference("WindowsDesktop",
+ this->WriteSingleSDKReference(*spe1, "WindowsDesktop",
desktopExtensionsVersion);
}
if (mobileExtensionsVersion) {
- this->WriteSingleSDKReference("WindowsMobile",
+ this->WriteSingleSDKReference(*spe1, "WindowsMobile",
mobileExtensionsVersion);
}
if (iotExtensionsVersion) {
- this->WriteSingleSDKReference("WindowsIoT", iotExtensionsVersion);
+ this->WriteSingleSDKReference(*spe1, "WindowsIoT",
+ iotExtensionsVersion);
}
}
-
- if (hasWrittenItemGroup) {
- this->WriteString("</ItemGroup>\n", 1);
- }
}
}
void cmVisualStudio10TargetGenerator::WriteSingleSDKReference(
- std::string const& extension, std::string const& version)
+ Elem& e1, std::string const& extension, std::string const& version)
{
- this->WriteString("<SDKReference Include=\"", 2);
- (*this->BuildFileStream) << extension << ", Version=" << version
- << "\" />\n";
+ Elem(e1, "SDKReference")
+ .Attribute("Include", extension + ", Version=" + version);
}
-void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
+void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile(
+ Elem& e0)
{
if ((this->GlobalGenerator->TargetsWindowsStore() ||
this->GlobalGenerator->TargetsWindowsPhone()) &&
@@ -3623,11 +4205,9 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
std::string pfxFile;
std::vector<cmSourceFile const*> certificates;
this->GeneratorTarget->GetCertificates(certificates, "");
- for (std::vector<cmSourceFile const*>::const_iterator si =
- certificates.begin();
- si != certificates.end(); ++si) {
- pfxFile = this->ConvertPath((*si)->GetFullPath(), false);
- this->ConvertToWindowsSlash(pfxFile);
+ for (cmSourceFile const* si : certificates) {
+ pfxFile = this->ConvertPath(si->GetFullPath(), false);
+ ConvertToWindowsSlash(pfxFile);
break;
}
@@ -3637,16 +4217,13 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
// Move the manifest to a project directory to avoid clashes
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- this->ConvertToWindowsSlash(artifactDir);
- this->WriteString("<PropertyGroup>\n", 1);
- this->WriteString("<AppxPackageArtifactsDir>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(artifactDir)
- << "\\</AppxPackageArtifactsDir>\n";
- this->WriteString("<ProjectPriFullPath>", 2);
+ ConvertToWindowsSlash(artifactDir);
+ Elem e1(e0, "PropertyGroup");
+ e1.Element("AppxPackageArtifactsDir", artifactDir + "\\");
std::string resourcePriFile =
this->DefaultArtifactDir + "/resources.pri";
- this->ConvertToWindowsSlash(resourcePriFile);
- (*this->BuildFileStream) << resourcePriFile << "</ProjectPriFullPath>\n";
+ ConvertToWindowsSlash(resourcePriFile);
+ e1.Element("ProjectPriFullPath", resourcePriFile);
// If we are missing files and we don't have a certificate and
// aren't targeting WP8.0, add a default certificate
@@ -3656,32 +4233,23 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
pfxFile = this->DefaultArtifactDir + "/Windows_TemporaryKey.pfx";
cmSystemTools::CopyAFile(templateFolder + "/Windows_TemporaryKey.pfx",
pfxFile, false);
- this->ConvertToWindowsSlash(pfxFile);
+ ConvertToWindowsSlash(pfxFile);
this->AddedFiles.push_back(pfxFile);
+ this->AddedDefaultCertificate = true;
}
- this->WriteString("<", 2);
- (*this->BuildFileStream) << "PackageCertificateKeyFile>" << pfxFile
- << "</PackageCertificateKeyFile>\n";
+ e1.Element("PackageCertificateKeyFile", pfxFile);
std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile);
if (!thumb.empty()) {
- this->WriteString("<PackageCertificateThumbprint>", 2);
- (*this->BuildFileStream) << thumb
- << "</PackageCertificateThumbprint>\n";
+ e1.Element("PackageCertificateThumbprint", thumb);
}
- this->WriteString("</PropertyGroup>\n", 1);
} else if (!pfxFile.empty()) {
- this->WriteString("<PropertyGroup>\n", 1);
- this->WriteString("<", 2);
- (*this->BuildFileStream) << "PackageCertificateKeyFile>" << pfxFile
- << "</PackageCertificateKeyFile>\n";
+ Elem e1(e0, "PropertyGroup");
+ e1.Element("PackageCertificateKeyFile", pfxFile);
std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile);
if (!thumb.empty()) {
- this->WriteString("<PackageCertificateThumbprint>", 2);
- (*this->BuildFileStream) << thumb
- << "</PackageCertificateThumbprint>\n";
+ e1.Element("PackageCertificateThumbprint", thumb);
}
- this->WriteString("</PropertyGroup>\n", 1);
}
}
}
@@ -3691,10 +4259,7 @@ bool cmVisualStudio10TargetGenerator::IsResxHeader(
{
std::set<std::string> expectedResxHeaders;
this->GeneratorTarget->GetExpectedResxHeaders(expectedResxHeaders, "");
-
- std::set<std::string>::const_iterator it =
- expectedResxHeaders.find(headerFile);
- return it != expectedResxHeaders.end();
+ return expectedResxHeaders.count(headerFile) > 0;
}
bool cmVisualStudio10TargetGenerator::IsXamlHeader(
@@ -3702,10 +4267,7 @@ bool cmVisualStudio10TargetGenerator::IsXamlHeader(
{
std::set<std::string> expectedXamlHeaders;
this->GeneratorTarget->GetExpectedXamlHeaders(expectedXamlHeaders, "");
-
- std::set<std::string>::const_iterator it =
- expectedXamlHeaders.find(headerFile);
- return it != expectedXamlHeaders.end();
+ return expectedXamlHeaders.count(headerFile) > 0;
}
bool cmVisualStudio10TargetGenerator::IsXamlSource(
@@ -3713,60 +4275,40 @@ bool cmVisualStudio10TargetGenerator::IsXamlSource(
{
std::set<std::string> expectedXamlSources;
this->GeneratorTarget->GetExpectedXamlSources(expectedXamlSources, "");
-
- std::set<std::string>::const_iterator it =
- expectedXamlSources.find(sourceFile);
- return it != expectedXamlSources.end();
+ return expectedXamlSources.count(sourceFile) > 0;
}
-void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
+void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1)
{
- cmGlobalVisualStudio10Generator* gg =
- static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
bool isAppContainer = false;
bool const isWindowsPhone = this->GlobalGenerator->TargetsWindowsPhone();
bool const isWindowsStore = this->GlobalGenerator->TargetsWindowsStore();
- std::string const& v = this->GlobalGenerator->GetSystemVersion();
+ std::string const& rev = this->GlobalGenerator->GetApplicationTypeRevision();
if (isWindowsPhone || isWindowsStore) {
- this->WriteString("<ApplicationType>", 2);
- (*this->BuildFileStream)
- << (isWindowsPhone ? "Windows Phone" : "Windows Store")
- << "</ApplicationType>\n";
- this->WriteString("<DefaultLanguage>en-US"
- "</DefaultLanguage>\n",
- 2);
- if (cmHasLiteralPrefix(v, "10.0")) {
- this->WriteString("<ApplicationTypeRevision>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML("10.0")
- << "</ApplicationTypeRevision>\n";
+ e1.Element("ApplicationType",
+ (isWindowsPhone ? "Windows Phone" : "Windows Store"));
+ e1.Element("DefaultLanguage", "en-US");
+ if (rev == "10.0") {
+ e1.Element("ApplicationTypeRevision", rev);
// Visual Studio 14.0 is necessary for building 10.0 apps
- this->WriteString("<MinimumVisualStudioVersion>14.0"
- "</MinimumVisualStudioVersion>\n",
- 2);
+ e1.Element("MinimumVisualStudioVersion", "14.0");
if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) {
isAppContainer = true;
}
- } else if (v == "8.1") {
- this->WriteString("<ApplicationTypeRevision>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(v)
- << "</ApplicationTypeRevision>\n";
+ } else if (rev == "8.1") {
+ e1.Element("ApplicationTypeRevision", rev);
// Visual Studio 12.0 is necessary for building 8.1 apps
- this->WriteString("<MinimumVisualStudioVersion>12.0"
- "</MinimumVisualStudioVersion>\n",
- 2);
+ e1.Element("MinimumVisualStudioVersion", "12.0");
if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) {
isAppContainer = true;
}
- } else if (v == "8.0") {
- this->WriteString("<ApplicationTypeRevision>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(v)
- << "</ApplicationTypeRevision>\n";
+ } else if (rev == "8.0") {
+ e1.Element("ApplicationTypeRevision", rev);
// Visual Studio 11.0 is necessary for building 8.0 apps
- this->WriteString("<MinimumVisualStudioVersion>11.0"
- "</MinimumVisualStudioVersion>\n",
- 2);
+ e1.Element("MinimumVisualStudioVersion", "11.0");
if (isWindowsStore &&
this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) {
@@ -3774,48 +4316,38 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
} else if (isWindowsPhone &&
this->GeneratorTarget->GetType() ==
cmStateEnums::EXECUTABLE) {
- this->WriteString("<XapOutputs>true</XapOutputs>\n", 2);
- this->WriteString("<XapFilename>", 2);
- (*this->BuildFileStream)
- << cmVS10EscapeXML(this->Name.c_str())
- << "_$(Configuration)_$(Platform).xap</XapFilename>\n";
+ e1.Element("XapOutputs", "true");
+ e1.Element("XapFilename",
+ this->Name + "_$(Configuration)_$(Platform).xap");
}
}
}
if (isAppContainer) {
- this->WriteString("<AppContainerApplication>true"
- "</AppContainerApplication>\n",
- 2);
+ e1.Element("AppContainerApplication", "true");
+ } else if (this->Platform == "ARM64") {
+ e1.Element("WindowsSDKDesktopARM64Support", "true");
} else if (this->Platform == "ARM") {
- this->WriteString("<WindowsSDKDesktopARMSupport>true"
- "</WindowsSDKDesktopARMSupport>\n",
- 2);
+ e1.Element("WindowsSDKDesktopARMSupport", "true");
}
std::string const& targetPlatformVersion =
gg->GetWindowsTargetPlatformVersion();
if (!targetPlatformVersion.empty()) {
- this->WriteString("<WindowsTargetPlatformVersion>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion)
- << "</WindowsTargetPlatformVersion>\n";
+ e1.Element("WindowsTargetPlatformVersion", targetPlatformVersion);
}
const char* targetPlatformMinVersion = this->GeneratorTarget->GetProperty(
"VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION");
if (targetPlatformMinVersion) {
- this->WriteString("<WindowsTargetPlatformMinVersion>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformMinVersion)
- << "</WindowsTargetPlatformMinVersion>\n";
- } else if (isWindowsStore && cmHasLiteralPrefix(v, "10.0")) {
+ e1.Element("WindowsTargetPlatformMinVersion", targetPlatformMinVersion);
+ } else if (isWindowsStore && rev == "10.0") {
// If the min version is not set, then use the TargetPlatformVersion
if (!targetPlatformVersion.empty()) {
- this->WriteString("<WindowsTargetPlatformMinVersion>", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion)
- << "</WindowsTargetPlatformMinVersion>\n";
+ e1.Element("WindowsTargetPlatformMinVersion", targetPlatformVersion);
}
}
// Added IoT Startup Task support
if (this->GeneratorTarget->GetPropertyAsBool("VS_IOT_STARTUP_TASK")) {
- this->WriteString("<ContainsStartupTask>true</ContainsStartupTask>\n", 2);
+ e1.Element("ContainsStartupTask", "true");
}
}
@@ -3834,12 +4366,10 @@ void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles()
std::vector<cmSourceFile const*> extraSources;
this->GeneratorTarget->GetExtraSources(extraSources, "");
bool foundManifest = false;
- for (std::vector<cmSourceFile const*>::const_iterator si =
- extraSources.begin();
- si != extraSources.end(); ++si) {
+ for (cmSourceFile const* si : extraSources) {
// Need to do a lowercase comparison on the filename
if ("wmappmanifest.xml" ==
- cmSystemTools::LowerCase((*si)->GetLocation().GetName())) {
+ cmSystemTools::LowerCase(si->GetLocation().GetName())) {
foundManifest = true;
break;
}
@@ -3865,27 +4395,27 @@ void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles()
}
}
-void cmVisualStudio10TargetGenerator::WriteMissingFiles()
+void cmVisualStudio10TargetGenerator::WriteMissingFiles(Elem& e1)
{
std::string const& v = this->GlobalGenerator->GetSystemVersion();
if (this->GlobalGenerator->TargetsWindowsPhone()) {
if (v == "8.0") {
- this->WriteMissingFilesWP80();
+ this->WriteMissingFilesWP80(e1);
} else if (v == "8.1") {
- this->WriteMissingFilesWP81();
+ this->WriteMissingFilesWP81(e1);
}
} else if (this->GlobalGenerator->TargetsWindowsStore()) {
if (v == "8.0") {
- this->WriteMissingFilesWS80();
+ this->WriteMissingFilesWS80(e1);
} else if (v == "8.1") {
- this->WriteMissingFilesWS81();
+ this->WriteMissingFilesWS81(e1);
} else if (cmHasLiteralPrefix(v, "10.0")) {
- this->WriteMissingFilesWS10_0();
+ this->WriteMissingFilesWS10_0(e1);
}
}
}
-void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80()
+void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80(Elem& e1)
{
std::string templateFolder =
cmSystemTools::GetCMakeRoot() + "/Templates/Windows";
@@ -3894,16 +4424,15 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80()
// this can cause an overwrite problem if projects aren't organized in
// folders
std::string manifestFile =
- this->LocalGenerator->GetCurrentBinaryDirectory() +
- std::string("/WMAppManifest.xml");
+ this->LocalGenerator->GetCurrentBinaryDirectory() + "/WMAppManifest.xml";
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- this->ConvertToWindowsSlash(artifactDir);
+ ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string targetNameXML =
cmVS10EscapeXML(this->GeneratorTarget->GetName());
- cmGeneratedFileStream fout(manifestFile.c_str());
+ cmGeneratedFileStream fout(manifestFile);
fout.SetCopyIfDifferent(true);
/* clang-format off */
@@ -3945,50 +4474,48 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80()
/* clang-format on */
std::string sourceFile = this->ConvertPath(manifestFile, false);
- this->ConvertToWindowsSlash(sourceFile);
- this->WriteString("<Xml Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(sourceFile) << "\">\n";
- this->WriteString("<SubType>Designer</SubType>\n", 3);
- this->WriteString("</Xml>\n", 2);
+ ConvertToWindowsSlash(sourceFile);
+ {
+ Elem e2(e1, "Xml");
+ e2.Attribute("Include", sourceFile);
+ e2.Element("SubType", "Designer");
+ }
this->AddedFiles.push_back(sourceFile);
std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png";
cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png", smallLogo,
false);
- this->ConvertToWindowsSlash(smallLogo);
- this->WriteString("<Image Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo) << "\" />\n";
+ ConvertToWindowsSlash(smallLogo);
+ Elem(e1, "Image").Attribute("Include", smallLogo);
this->AddedFiles.push_back(smallLogo);
std::string logo = this->DefaultArtifactDir + "/Logo.png";
cmSystemTools::CopyAFile(templateFolder + "/Logo.png", logo, false);
- this->ConvertToWindowsSlash(logo);
- this->WriteString("<Image Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(logo) << "\" />\n";
+ ConvertToWindowsSlash(logo);
+ Elem(e1, "Image").Attribute("Include", logo);
this->AddedFiles.push_back(logo);
std::string applicationIcon =
this->DefaultArtifactDir + "/ApplicationIcon.png";
cmSystemTools::CopyAFile(templateFolder + "/ApplicationIcon.png",
applicationIcon, false);
- this->ConvertToWindowsSlash(applicationIcon);
- this->WriteString("<Image Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(applicationIcon) << "\" />\n";
+ ConvertToWindowsSlash(applicationIcon);
+ Elem(e1, "Image").Attribute("Include", applicationIcon);
this->AddedFiles.push_back(applicationIcon);
}
-void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81()
+void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81(Elem& e1)
{
std::string manifestFile =
this->DefaultArtifactDir + "/package.appxManifest";
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- this->ConvertToWindowsSlash(artifactDir);
+ ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string targetNameXML =
cmVS10EscapeXML(this->GeneratorTarget->GetName());
- cmGeneratedFileStream fout(manifestFile.c_str());
+ cmGeneratedFileStream fout(manifestFile);
fout.SetCopyIfDifferent(true);
/* clang-format off */
@@ -4037,21 +4564,21 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81()
"</Package>\n";
/* clang-format on */
- this->WriteCommonMissingFiles(manifestFile);
+ this->WriteCommonMissingFiles(e1, manifestFile);
}
-void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80()
+void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80(Elem& e1)
{
std::string manifestFile =
this->DefaultArtifactDir + "/package.appxManifest";
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- this->ConvertToWindowsSlash(artifactDir);
+ ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string targetNameXML =
cmVS10EscapeXML(this->GeneratorTarget->GetName());
- cmGeneratedFileStream fout(manifestFile.c_str());
+ cmGeneratedFileStream fout(manifestFile);
fout.SetCopyIfDifferent(true);
/* clang-format off */
@@ -4092,21 +4619,21 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80()
"</Package>\n";
/* clang-format on */
- this->WriteCommonMissingFiles(manifestFile);
+ this->WriteCommonMissingFiles(e1, manifestFile);
}
-void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81()
+void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81(Elem& e1)
{
std::string manifestFile =
this->DefaultArtifactDir + "/package.appxManifest";
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- this->ConvertToWindowsSlash(artifactDir);
+ ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string targetNameXML =
cmVS10EscapeXML(this->GeneratorTarget->GetName());
- cmGeneratedFileStream fout(manifestFile.c_str());
+ cmGeneratedFileStream fout(manifestFile);
fout.SetCopyIfDifferent(true);
/* clang-format off */
@@ -4152,21 +4679,21 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81()
"</Package>\n";
/* clang-format on */
- this->WriteCommonMissingFiles(manifestFile);
+ this->WriteCommonMissingFiles(e1, manifestFile);
}
-void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0()
+void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0(Elem& e1)
{
std::string manifestFile =
this->DefaultArtifactDir + "/package.appxManifest";
std::string artifactDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- this->ConvertToWindowsSlash(artifactDir);
+ ConvertToWindowsSlash(artifactDir);
std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
std::string targetNameXML =
cmVS10EscapeXML(this->GeneratorTarget->GetName());
- cmGeneratedFileStream fout(manifestFile.c_str());
+ cmGeneratedFileStream fout(manifestFile);
fout.SetCopyIfDifferent(true);
/* clang-format off */
@@ -4213,67 +4740,65 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWS10_0()
"</Package>\n";
/* clang-format on */
- this->WriteCommonMissingFiles(manifestFile);
+ this->WriteCommonMissingFiles(e1, manifestFile);
}
void cmVisualStudio10TargetGenerator::WriteCommonMissingFiles(
- const std::string& manifestFile)
+ Elem& e1, const std::string& manifestFile)
{
std::string templateFolder =
cmSystemTools::GetCMakeRoot() + "/Templates/Windows";
std::string sourceFile = this->ConvertPath(manifestFile, false);
- this->ConvertToWindowsSlash(sourceFile);
- this->WriteString("<AppxManifest Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(sourceFile) << "\">\n";
- this->WriteString("<SubType>Designer</SubType>\n", 3);
- this->WriteString("</AppxManifest>\n", 2);
+ ConvertToWindowsSlash(sourceFile);
+ {
+ Elem e2(e1, "AppxManifest");
+ e2.Attribute("Include", sourceFile);
+ e2.Element("SubType", "Designer");
+ }
this->AddedFiles.push_back(sourceFile);
std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png";
cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png", smallLogo,
false);
- this->ConvertToWindowsSlash(smallLogo);
- this->WriteString("<Image Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo) << "\" />\n";
+ ConvertToWindowsSlash(smallLogo);
+ Elem(e1, "Image").Attribute("Include", smallLogo);
this->AddedFiles.push_back(smallLogo);
std::string smallLogo44 = this->DefaultArtifactDir + "/SmallLogo44x44.png";
cmSystemTools::CopyAFile(templateFolder + "/SmallLogo44x44.png", smallLogo44,
false);
- this->ConvertToWindowsSlash(smallLogo44);
- this->WriteString("<Image Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo44) << "\" />\n";
+ ConvertToWindowsSlash(smallLogo44);
+ Elem(e1, "Image").Attribute("Include", smallLogo44);
this->AddedFiles.push_back(smallLogo44);
std::string logo = this->DefaultArtifactDir + "/Logo.png";
cmSystemTools::CopyAFile(templateFolder + "/Logo.png", logo, false);
- this->ConvertToWindowsSlash(logo);
- this->WriteString("<Image Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(logo) << "\" />\n";
+ ConvertToWindowsSlash(logo);
+ Elem(e1, "Image").Attribute("Include", logo);
this->AddedFiles.push_back(logo);
std::string storeLogo = this->DefaultArtifactDir + "/StoreLogo.png";
cmSystemTools::CopyAFile(templateFolder + "/StoreLogo.png", storeLogo,
false);
- this->ConvertToWindowsSlash(storeLogo);
- this->WriteString("<Image Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(storeLogo) << "\" />\n";
+ ConvertToWindowsSlash(storeLogo);
+ Elem(e1, "Image").Attribute("Include", storeLogo);
this->AddedFiles.push_back(storeLogo);
std::string splashScreen = this->DefaultArtifactDir + "/SplashScreen.png";
cmSystemTools::CopyAFile(templateFolder + "/SplashScreen.png", splashScreen,
false);
- this->ConvertToWindowsSlash(splashScreen);
- this->WriteString("<Image Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(splashScreen) << "\" />\n";
+ ConvertToWindowsSlash(splashScreen);
+ Elem(e1, "Image").Attribute("Include", splashScreen);
this->AddedFiles.push_back(splashScreen);
- // This file has already been added to the build so don't copy it
- std::string keyFile = this->DefaultArtifactDir + "/Windows_TemporaryKey.pfx";
- this->ConvertToWindowsSlash(keyFile);
- this->WriteString("<None Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(keyFile) << "\" />\n";
+ if (this->AddedDefaultCertificate) {
+ // This file has already been added to the build so don't copy it
+ std::string keyFile =
+ this->DefaultArtifactDir + "/Windows_TemporaryKey.pfx";
+ ConvertToWindowsSlash(keyFile);
+ Elem(e1, "None").Attribute("Include", keyFile);
+ }
}
bool cmVisualStudio10TargetGenerator::ForceOld(const std::string& source) const
@@ -4296,13 +4821,63 @@ bool cmVisualStudio10TargetGenerator::ForceOld(const std::string& source) const
return true;
}
+void cmVisualStudio10TargetGenerator::GetCSharpSourceProperties(
+ cmSourceFile const* sf, std::map<std::string, std::string>& tags)
+{
+ if (this->ProjectType == csproj) {
+ const cmPropertyMap& props = sf->GetProperties();
+ for (const std::string& p : props.GetKeys()) {
+ static const std::string propNamePrefix = "VS_CSHARP_";
+ if (p.find(propNamePrefix) == 0) {
+ std::string tagName = p.substr(propNamePrefix.length());
+ if (!tagName.empty()) {
+ const std::string val = props.GetPropertyValue(p);
+ if (!val.empty()) {
+ tags[tagName] = val;
+ } else {
+ tags.erase(tagName);
+ }
+ }
+ }
+ }
+ }
+}
+
+void cmVisualStudio10TargetGenerator::WriteCSharpSourceProperties(
+ Elem& e2, const std::map<std::string, std::string>& tags)
+{
+ for (const auto& i : tags) {
+ e2.Element(i.first.c_str(), i.second);
+ }
+}
+
+void cmVisualStudio10TargetGenerator::GetCSharpSourceLink(
+ cmSourceFile const* sf, std::string& link)
+{
+ std::string const& sourceFilePath = sf->GetFullPath();
+ std::string const& binaryDir = LocalGenerator->GetCurrentBinaryDirectory();
+
+ if (!cmSystemTools::IsSubDirectory(sourceFilePath, binaryDir)) {
+ const std::string& stripFromPath =
+ this->Makefile->GetCurrentSourceDirectory();
+ if (sourceFilePath.find(stripFromPath) == 0) {
+ if (const char* l = sf->GetProperty("VS_CSHARP_Link")) {
+ link = l;
+ } else {
+ link = sourceFilePath.substr(stripFromPath.length() + 1);
+ }
+ ConvertToWindowsSlash(link);
+ }
+ }
+}
+
std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath(
const char* relativeFilePath) const
{
// Always search in the standard modules location.
- std::string path = cmSystemTools::GetCMakeRoot() + "/";
- path += relativeFilePath;
- this->ConvertToWindowsSlash(path);
+ std::string path =
+ cmStrCat(cmSystemTools::GetCMakeRoot(), '/', relativeFilePath);
+ ConvertToWindowsSlash(path);
return path;
}
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 61066158c..a18a33dd8 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -3,10 +3,11 @@
#ifndef cmVisualStudioTargetGenerator_h
#define cmVisualStudioTargetGenerator_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <map>
+#include <memory>
#include <set>
#include <string>
#include <vector>
@@ -16,11 +17,11 @@ class cmCustomCommand;
class cmGeneratedFileStream;
class cmGeneratorTarget;
class cmGlobalVisualStudio10Generator;
-class cmLocalVisualStudio7Generator;
+class cmLocalVisualStudio10Generator;
class cmMakefile;
class cmSourceFile;
class cmSourceGroup;
-class cmVisualStudioGeneratorOptions;
+class cmVS10GeneratorOptions;
class cmVisualStudio10TargetGenerator
{
@@ -28,11 +29,13 @@ public:
cmVisualStudio10TargetGenerator(cmGeneratorTarget* target,
cmGlobalVisualStudio10Generator* gg);
~cmVisualStudio10TargetGenerator();
+
+ cmVisualStudio10TargetGenerator(cmVisualStudio10TargetGenerator const&) =
+ delete;
+ cmVisualStudio10TargetGenerator& operator=(
+ cmVisualStudio10TargetGenerator const&) = delete;
+
void Generate();
- // used by cmVisualStudioGeneratorOptions
- void WritePlatformConfigTag(const char* tag, const std::string& config,
- int indentLevel, const char* attribute = 0,
- const char* end = 0, std::ostream* strm = 0);
private:
struct ToolSource
@@ -50,102 +53,124 @@ private:
std::vector<std::string> Configs;
};
+ struct Elem;
+ struct OptionsHelper;
+
std::string ConvertPath(std::string const& path, bool forceRelative);
- static void ConvertToWindowsSlash(std::string& s);
- void WriteString(const char* line, int indentLevel);
- void WriteProjectConfigurations();
- void WriteProjectConfigurationValues();
- void WriteMSToolConfigurationValues(std::string const& config);
- void WriteMSToolConfigurationValuesManaged(std::string const& config);
- void WriteHeaderSource(cmSourceFile const* sf);
- void WriteExtraSource(cmSourceFile const* sf);
- void WriteNsightTegraConfigurationValues(std::string const& config);
- void WriteSource(std::string const& tool, cmSourceFile const* sf,
- const char* end = 0);
- void WriteExcludeFromBuild(std::vector<size_t> const& exclude_configs);
- void WriteAllSources();
- void WriteDotNetReferences();
- void WriteDotNetReference(std::string const& ref, std::string const& hint);
- void WriteEmbeddedResourceGroup();
- void WriteWinRTReferences();
- void WriteWinRTPackageCertificateKeyFile();
- void WriteXamlFilesGroup();
- void WritePathAndIncrementalLinkOptions();
- void WriteItemDefinitionGroups();
+ std::string CalcCondition(const std::string& config) const;
+ void WriteProjectConfigurations(Elem& e0);
+ void WriteProjectConfigurationValues(Elem& e0);
+ void WriteMSToolConfigurationValues(Elem& e1, std::string const& config);
+ void WriteCEDebugProjectConfigurationValues(Elem& e0);
+ void WriteMSToolConfigurationValuesManaged(Elem& e1,
+ std::string const& config);
+ void WriteHeaderSource(Elem& e1, cmSourceFile const* sf);
+ void WriteExtraSource(Elem& e1, cmSourceFile const* sf);
+ void WriteNsightTegraConfigurationValues(Elem& e1,
+ std::string const& config);
+ void WriteSource(Elem& e2, cmSourceFile const* sf);
+ void WriteExcludeFromBuild(Elem& e2,
+ std::vector<size_t> const& exclude_configs);
+ void WriteAllSources(Elem& e0);
+ void WritePackageReferences(Elem& e0);
+ void WritePackageReference(Elem& e1, std::string const& ref,
+ std::string const& version);
+ void WriteDotNetReferences(Elem& e0);
+ void WriteDotNetReference(Elem& e1, std::string const& ref,
+ std::string const& hint,
+ std::string const& config);
+ void WriteImports(Elem& e0);
+ void WriteDotNetReferenceCustomTags(Elem& e2, std::string const& ref);
+ void WriteEmbeddedResourceGroup(Elem& e0);
+ void WriteWinRTReferences(Elem& e0);
+ void WriteWinRTPackageCertificateKeyFile(Elem& e0);
+ void WriteXamlFilesGroup(Elem& e0);
+ void WritePathAndIncrementalLinkOptions(Elem& e0);
+ void WriteItemDefinitionGroups(Elem& e0);
void VerifyNecessaryFiles();
- void WriteMissingFiles();
- void WriteMissingFilesWP80();
- void WriteMissingFilesWP81();
- void WriteMissingFilesWS80();
- void WriteMissingFilesWS81();
- void WriteMissingFilesWS10_0();
- void WritePlatformExtensions();
- void WriteSinglePlatformExtension(std::string const& extension,
+ void WriteMissingFiles(Elem& e1);
+ void WriteMissingFilesWP80(Elem& e1);
+ void WriteMissingFilesWP81(Elem& e1);
+ void WriteMissingFilesWS80(Elem& e1);
+ void WriteMissingFilesWS81(Elem& e1);
+ void WriteMissingFilesWS10_0(Elem& e1);
+ void WritePlatformExtensions(Elem& e1);
+ void WriteSinglePlatformExtension(Elem& e1, std::string const& extension,
std::string const& version);
- void WriteSDKReferences();
- void WriteSingleSDKReference(std::string const& extension,
+ void WriteSDKReferences(Elem& e0);
+ void WriteSingleSDKReference(Elem& e1, std::string const& extension,
std::string const& version);
- void WriteCommonMissingFiles(const std::string& manifestFile);
- void WriteTargetSpecificReferences();
- void WriteTargetsFileReferences();
+ void WriteCommonMissingFiles(Elem& e1, const std::string& manifestFile);
+ void WriteTargetSpecificReferences(Elem& e0);
+ void WriteTargetsFileReferences(Elem& e1);
+
+ std::vector<std::string> GetIncludes(std::string const& config,
+ std::string const& lang) const;
bool ComputeClOptions();
bool ComputeClOptions(std::string const& configName);
- void WriteClOptions(std::string const& config,
- std::vector<std::string> const& includes);
+ void WriteClOptions(Elem& e1, std::string const& config);
bool ComputeRcOptions();
bool ComputeRcOptions(std::string const& config);
- void WriteRCOptions(std::string const& config,
- std::vector<std::string> const& includes);
+ void WriteRCOptions(Elem& e1, std::string const& config);
bool ComputeCudaOptions();
bool ComputeCudaOptions(std::string const& config);
- void WriteCudaOptions(std::string const& config,
- std::vector<std::string> const& includes);
+ void WriteCudaOptions(Elem& e1, std::string const& config);
bool ComputeCudaLinkOptions();
bool ComputeCudaLinkOptions(std::string const& config);
- void WriteCudaLinkOptions(std::string const& config);
+ void WriteCudaLinkOptions(Elem& e1, std::string const& config);
bool ComputeMasmOptions();
bool ComputeMasmOptions(std::string const& config);
- void WriteMasmOptions(std::string const& config,
- std::vector<std::string> const& includes);
+ void WriteMasmOptions(Elem& e1, std::string const& config);
bool ComputeNasmOptions();
bool ComputeNasmOptions(std::string const& config);
- void WriteNasmOptions(std::string const& config,
- std::vector<std::string> includes);
+ void WriteNasmOptions(Elem& e1, std::string const& config);
bool ComputeLinkOptions();
bool ComputeLinkOptions(std::string const& config);
bool ComputeLibOptions();
bool ComputeLibOptions(std::string const& config);
- void WriteLinkOptions(std::string const& config);
- void WriteMidlOptions(std::string const& config,
- std::vector<std::string> const& includes);
- void WriteAntBuildOptions(std::string const& config);
- void OutputLinkIncremental(std::string const& configName);
- void WriteCustomRule(cmSourceFile const* source,
+ void WriteLinkOptions(Elem& e1, std::string const& config);
+ void WriteMidlOptions(Elem& e1, std::string const& config);
+ void WriteAntBuildOptions(Elem& e1, std::string const& config);
+ void OutputLinkIncremental(Elem& e1, std::string const& configName);
+ void WriteCustomRule(Elem& e0, cmSourceFile const* source,
cmCustomCommand const& command);
- void WriteCustomCommands();
- void WriteCustomCommand(cmSourceFile const* sf);
+ void WriteCustomRuleCpp(Elem& e2, std::string const& config,
+ std::string const& script,
+ std::string const& additional_inputs,
+ std::string const& outputs,
+ std::string const& comment, bool symbolic);
+ void WriteCustomRuleCSharp(Elem& e0, std::string const& config,
+ std::string const& commandName,
+ std::string const& script,
+ std::string const& inputs,
+ std::string const& outputs,
+ std::string const& comment);
+ void WriteCustomCommands(Elem& e0);
+ void WriteCustomCommand(Elem& e0, cmSourceFile const* sf);
void WriteGroups();
- void WriteProjectReferences();
- void WriteApplicationTypeSettings();
- bool OutputSourceSpecificFlags(cmSourceFile const* source);
- void AddLibraries(cmComputeLinkInformation& cli,
+ void WriteProjectReferences(Elem& e0);
+ void WriteApplicationTypeSettings(Elem& e1);
+ void OutputSourceSpecificFlags(Elem& e2, cmSourceFile const* source);
+ void AddLibraries(const cmComputeLinkInformation& cli,
std::vector<std::string>& libVec,
- std::vector<std::string>& vsTargetVec);
+ std::vector<std::string>& vsTargetVec,
+ const std::string& config);
void AddTargetsFileAndConfigPair(std::string const& targetsFile,
std::string const& config);
- void WriteLibOptions(std::string const& config);
- void WriteManifestOptions(std::string const& config);
- void WriteEvents(std::string const& configName);
- void WriteEvent(const char* name,
+ void WriteLibOptions(Elem& e1, std::string const& config);
+ void WriteManifestOptions(Elem& e1, std::string const& config);
+ void WriteEvents(Elem& e1, std::string const& configName);
+ void WriteEvent(Elem& e1, const char* name,
std::vector<cmCustomCommand> const& commands,
std::string const& configName);
- void WriteGroupSources(const char* name, ToolSources const& sources,
+ void WriteGroupSources(Elem& e0, std::string const& name,
+ ToolSources const& sources,
std::vector<cmSourceGroup>&);
- void AddMissingSourceGroups(std::set<cmSourceGroup*>& groupsUsed,
+ void AddMissingSourceGroups(std::set<cmSourceGroup const*>& groupsUsed,
const std::vector<cmSourceGroup>& allGroups);
bool IsResxHeader(const std::string& headerFile);
bool IsXamlHeader(const std::string& headerFile);
@@ -153,9 +178,16 @@ private:
bool ForceOld(const std::string& source) const;
+ void GetCSharpSourceProperties(cmSourceFile const* sf,
+ std::map<std::string, std::string>& tags);
+ void WriteCSharpSourceProperties(
+ Elem& e2, const std::map<std::string, std::string>& tags);
+ void GetCSharpSourceLink(cmSourceFile const* sf, std::string& link);
+
private:
- typedef cmVisualStudioGeneratorOptions Options;
- typedef std::map<std::string, Options*> OptionsMap;
+ friend class cmVS10GeneratorOptions;
+ using Options = cmVS10GeneratorOptions;
+ using OptionsMap = std::map<std::string, std::unique_ptr<Options>>;
OptionsMap ClOptions;
OptionsMap RcOptions;
OptionsMap CudaOptions;
@@ -163,8 +195,7 @@ private:
OptionsMap MasmOptions;
OptionsMap NasmOptions;
OptionsMap LinkOptions;
- std::string PathToProjectFile;
- std::string ProjectFileExtension;
+ std::string LangForClCompile;
enum VsProjectType
{
vcxproj,
@@ -173,25 +204,36 @@ private:
bool InSourceBuild;
std::vector<std::string> Configurations;
std::vector<TargetsFileAndConfigs> TargetsFileAndConfigsVec;
- cmGeneratorTarget* GeneratorTarget;
- cmMakefile* Makefile;
- std::string Platform;
- std::string GUID;
- std::string Name;
+ cmGeneratorTarget* const GeneratorTarget;
+ cmMakefile* const Makefile;
+ std::string const Platform;
+ std::string const Name;
+ std::string const GUID;
bool MSTools;
bool Managed;
bool NsightTegra;
- int NsightTegraVersion[4];
+ unsigned int NsightTegraVersion[4];
bool TargetCompileAsWinRT;
- cmGlobalVisualStudio10Generator* GlobalGenerator;
- cmGeneratedFileStream* BuildFileStream;
- cmLocalVisualStudio7Generator* LocalGenerator;
- std::set<cmSourceFile const*> SourcesVisited;
+ std::set<std::string> IPOEnabledConfigurations;
+ std::map<std::string, std::string> SpectreMitigation;
+ cmGlobalVisualStudio10Generator* const GlobalGenerator;
+ cmLocalVisualStudio10Generator* const LocalGenerator;
+ std::set<std::string> CSharpCustomCommandNames;
bool IsMissingFiles;
std::vector<std::string> AddedFiles;
std::string DefaultArtifactDir;
+ bool AddedDefaultCertificate = false;
+ // managed C++/C# relevant members
+ using DotNetHintReference = std::pair<std::string, std::string>;
+ using DotNetHintReferenceList = std::vector<DotNetHintReference>;
+ using DotNetHintReferenceMap =
+ std::map<std::string, DotNetHintReferenceList>;
+ DotNetHintReferenceMap DotNetHintReferences;
+ using UsingDirectories = std::set<std::string>;
+ using UsingDirectoriesMap = std::map<std::string, UsingDirectories>;
+ UsingDirectoriesMap AdditionalUsingDirectories;
- typedef std::map<std::string, ToolSources> ToolSourceMap;
+ using ToolSourceMap = std::map<std::string, ToolSources>;
ToolSourceMap Tools;
std::string GetCMakeFilePath(const char* name) const;
};
diff --git a/Source/cmVisualStudio10ToolsetOptions.cxx b/Source/cmVisualStudio10ToolsetOptions.cxx
index 9a1d95078..7fc33e63e 100644
--- a/Source/cmVisualStudio10ToolsetOptions.cxx
+++ b/Source/cmVisualStudio10ToolsetOptions.cxx
@@ -6,145 +6,126 @@
#include "cmIDEFlagTable.h"
#include "cmVisualStudioGeneratorOptions.h"
-#include "cmVS10CLFlagTable.h"
-#include "cmVS10CSharpFlagTable.h"
-#include "cmVS10LibFlagTable.h"
-#include "cmVS10LinkFlagTable.h"
-#include "cmVS10MASMFlagTable.h"
-#include "cmVS10RCFlagTable.h"
-#include "cmVS11CLFlagTable.h"
-#include "cmVS11CSharpFlagTable.h"
-#include "cmVS11LibFlagTable.h"
-#include "cmVS11LinkFlagTable.h"
-#include "cmVS11MASMFlagTable.h"
-#include "cmVS11RCFlagTable.h"
-#include "cmVS12CLFlagTable.h"
-#include "cmVS12CSharpFlagTable.h"
-#include "cmVS12LibFlagTable.h"
-#include "cmVS12LinkFlagTable.h"
-#include "cmVS12MASMFlagTable.h"
-#include "cmVS12RCFlagTable.h"
-#include "cmVS140CLFlagTable.h"
-#include "cmVS140CSharpFlagTable.h"
-#include "cmVS140LinkFlagTable.h"
-#include "cmVS141CLFlagTable.h"
-#include "cmVS141CSharpFlagTable.h"
-#include "cmVS141LinkFlagTable.h"
-#include "cmVS14LibFlagTable.h"
-#include "cmVS14MASMFlagTable.h"
-#include "cmVS14RCFlagTable.h"
-
-cmIDEFlagTable const* cmVisualStudio10ToolsetOptions::GetClFlagTable(
+std::string cmVisualStudio10ToolsetOptions::GetClFlagTableName(
std::string const& name, std::string const& toolset) const
{
std::string const useToolset = this->GetToolsetName(name, toolset);
- if (toolset == "v141") {
- return cmVS141CLFlagTable;
+ if (toolset == "v142") {
+ return "v142";
+ } else if (toolset == "v141") {
+ return "v141";
} else if (useToolset == "v140") {
- return cmVS140CLFlagTable;
+ return "v140";
} else if (useToolset == "v120") {
- return cmVS12CLFlagTable;
+ return "v12";
} else if (useToolset == "v110") {
- return cmVS11CLFlagTable;
+ return "v11";
} else if (useToolset == "v100") {
- return cmVS10CLFlagTable;
+ return "v10";
} else {
- return 0;
+ return "";
}
}
-cmIDEFlagTable const* cmVisualStudio10ToolsetOptions::GetCSharpFlagTable(
+std::string cmVisualStudio10ToolsetOptions::GetCSharpFlagTableName(
std::string const& name, std::string const& toolset) const
{
std::string const useToolset = this->GetToolsetName(name, toolset);
- if ((useToolset == "v141")) {
- return cmVS141CSharpFlagTable;
+ if (useToolset == "v142") {
+ return "v142";
+ } else if (useToolset == "v141") {
+ return "v141";
} else if (useToolset == "v140") {
- return cmVS140CSharpFlagTable;
+ return "v140";
} else if (useToolset == "v120") {
- return cmVS12CSharpFlagTable;
+ return "v12";
} else if (useToolset == "v110") {
- return cmVS11CSharpFlagTable;
+ return "v11";
} else if (useToolset == "v100") {
- return cmVS10CSharpFlagTable;
+ return "v10";
} else {
- return 0;
+ return "";
}
}
-cmIDEFlagTable const* cmVisualStudio10ToolsetOptions::GetRcFlagTable(
+std::string cmVisualStudio10ToolsetOptions::GetRcFlagTableName(
std::string const& name, std::string const& toolset) const
{
std::string const useToolset = this->GetToolsetName(name, toolset);
- if ((useToolset == "v140") || (useToolset == "v141")) {
- return cmVS14RCFlagTable;
+ if ((useToolset == "v140") || (useToolset == "v141") ||
+ (useToolset == "v142")) {
+ return "v14";
} else if (useToolset == "v120") {
- return cmVS12RCFlagTable;
+ return "v12";
} else if (useToolset == "v110") {
- return cmVS11RCFlagTable;
+ return "v11";
} else if (useToolset == "v100") {
- return cmVS10RCFlagTable;
+ return "v10";
} else {
- return 0;
+ return "";
}
}
-cmIDEFlagTable const* cmVisualStudio10ToolsetOptions::GetLibFlagTable(
+std::string cmVisualStudio10ToolsetOptions::GetLibFlagTableName(
std::string const& name, std::string const& toolset) const
{
std::string const useToolset = this->GetToolsetName(name, toolset);
- if ((useToolset == "v140") || (useToolset == "v141")) {
- return cmVS14LibFlagTable;
+ if ((useToolset == "v140") || (useToolset == "v141") ||
+ (useToolset == "v142")) {
+ return "v14";
} else if (useToolset == "v120") {
- return cmVS12LibFlagTable;
+ return "v12";
} else if (useToolset == "v110") {
- return cmVS11LibFlagTable;
+ return "v11";
} else if (useToolset == "v100") {
- return cmVS10LibFlagTable;
+ return "v10";
} else {
- return 0;
+ return "";
}
}
-cmIDEFlagTable const* cmVisualStudio10ToolsetOptions::GetLinkFlagTable(
+std::string cmVisualStudio10ToolsetOptions::GetLinkFlagTableName(
std::string const& name, std::string const& toolset) const
{
std::string const useToolset = this->GetToolsetName(name, toolset);
- if (useToolset == "v141") {
- return cmVS141LinkFlagTable;
+ if (useToolset == "v142") {
+ return "v142";
+ } else if (useToolset == "v141") {
+ return "v141";
} else if (useToolset == "v140") {
- return cmVS140LinkFlagTable;
+ return "v140";
} else if (useToolset == "v120") {
- return cmVS12LinkFlagTable;
+ return "v12";
} else if (useToolset == "v110") {
- return cmVS11LinkFlagTable;
+ return "v11";
} else if (useToolset == "v100") {
- return cmVS10LinkFlagTable;
+ return "v10";
} else {
- return 0;
+ return "";
}
}
-cmIDEFlagTable const* cmVisualStudio10ToolsetOptions::GetMasmFlagTable(
+std::string cmVisualStudio10ToolsetOptions::GetMasmFlagTableName(
std::string const& name, std::string const& toolset) const
{
std::string const useToolset = this->GetToolsetName(name, toolset);
- if ((useToolset == "v140") || (useToolset == "v141")) {
- return cmVS14MASMFlagTable;
+ if ((useToolset == "v140") || (useToolset == "v141") ||
+ (useToolset == "v142")) {
+ return "v14";
} else if (useToolset == "v120") {
- return cmVS12MASMFlagTable;
+ return "v12";
} else if (useToolset == "v110") {
- return cmVS11MASMFlagTable;
+ return "v11";
} else if (useToolset == "v100") {
- return cmVS10MASMFlagTable;
+ return "v10";
} else {
- return 0;
+ return "";
}
}
diff --git a/Source/cmVisualStudio10ToolsetOptions.h b/Source/cmVisualStudio10ToolsetOptions.h
index 4233337ba..875a35b24 100644
--- a/Source/cmVisualStudio10ToolsetOptions.h
+++ b/Source/cmVisualStudio10ToolsetOptions.h
@@ -3,12 +3,10 @@
#ifndef cmVisualStudio10ToolsetOptions_h
#define cmVisualStudio10ToolsetOptions_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
-struct cmIDEFlagTable;
-
/** \class cmVisualStudio10ToolsetOptions
* \brief Retrieves toolset options for MSBuild.
*
@@ -17,20 +15,18 @@ struct cmIDEFlagTable;
class cmVisualStudio10ToolsetOptions
{
public:
- cmIDEFlagTable const* GetClFlagTable(std::string const& name,
- std::string const& toolset) const;
- cmIDEFlagTable const* GetCSharpFlagTable(std::string const& name,
- std::string const& toolset) const;
- cmIDEFlagTable const* GetRcFlagTable(std::string const& name,
- std::string const& toolset) const;
- cmIDEFlagTable const* GetLibFlagTable(std::string const& name,
- std::string const& toolset) const;
- cmIDEFlagTable const* GetLinkFlagTable(std::string const& name,
- std::string const& toolset) const;
- cmIDEFlagTable const* GetMasmFlagTable(std::string const& name,
- std::string const& toolset) const;
-
-private:
+ std::string GetClFlagTableName(std::string const& name,
+ std::string const& toolset) const;
+ std::string GetCSharpFlagTableName(std::string const& name,
+ std::string const& toolset) const;
+ std::string GetRcFlagTableName(std::string const& name,
+ std::string const& toolset) const;
+ std::string GetLibFlagTableName(std::string const& name,
+ std::string const& toolset) const;
+ std::string GetLinkFlagTableName(std::string const& name,
+ std::string const& toolset) const;
+ std::string GetMasmFlagTableName(std::string const& name,
+ std::string const& toolset) const;
std::string GetToolsetName(std::string const& name,
std::string const& toolset) const;
};
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 1f808c8b2..1139aa974 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -1,61 +1,24 @@
#include "cmVisualStudioGeneratorOptions.h"
+#include <cm/iterator>
+
#include "cmAlgorithms.h"
#include "cmLocalVisualStudioGenerator.h"
#include "cmOutputConverter.h"
#include "cmSystemTools.h"
-#include "cmVisualStudio10TargetGenerator.h"
-static std::string cmVisualStudio10GeneratorOptionsEscapeForXML(
- std::string ret)
+static void cmVS10EscapeForMSBuild(std::string& ret)
{
cmSystemTools::ReplaceString(ret, ";", "%3B");
- cmSystemTools::ReplaceString(ret, "&", "&amp;");
- cmSystemTools::ReplaceString(ret, "<", "&lt;");
- cmSystemTools::ReplaceString(ret, ">", "&gt;");
- return ret;
-}
-
-static std::string cmVisualStudioGeneratorOptionsEscapeForXML(std::string ret)
-{
- cmSystemTools::ReplaceString(ret, "&", "&amp;");
- cmSystemTools::ReplaceString(ret, "\"", "&quot;");
- cmSystemTools::ReplaceString(ret, "<", "&lt;");
- cmSystemTools::ReplaceString(ret, ">", "&gt;");
- cmSystemTools::ReplaceString(ret, "\n", "&#x0D;&#x0A;");
- return ret;
-}
-
-cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions(
- cmLocalVisualStudioGenerator* lg, Tool tool,
- cmVisualStudio10TargetGenerator* g)
- : cmIDEOptions()
- , LocalGenerator(lg)
- , Version(lg->GetVersion())
- , CurrentTool(tool)
- , TargetGenerator(g)
-{
- // Preprocessor definitions are not allowed for linker tools.
- this->AllowDefine = (tool != Linker);
-
- // Slash options are allowed for VS.
- this->AllowSlash = true;
-
- this->FortranRuntimeDebug = false;
- this->FortranRuntimeDLL = false;
- this->FortranRuntimeMT = false;
-
- this->UnknownFlagField = "AdditionalOptions";
}
cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions(
cmLocalVisualStudioGenerator* lg, Tool tool, cmVS7FlagTable const* table,
- cmVS7FlagTable const* extraTable, cmVisualStudio10TargetGenerator* g)
+ cmVS7FlagTable const* extraTable)
: cmIDEOptions()
, LocalGenerator(lg)
, Version(lg->GetVersion())
, CurrentTool(tool)
- , TargetGenerator(g)
{
// Store the given flag tables.
this->AddTable(table);
@@ -64,6 +27,9 @@ cmVisualStudioGeneratorOptions::cmVisualStudioGeneratorOptions(
// Preprocessor definitions are not allowed for linker tools.
this->AllowDefine = (tool != Linker);
+ // include directories are not allowed for linker tools.
+ this->AllowInclude = (tool != Linker);
+
// Slash options are allowed for VS.
this->AllowSlash = true;
@@ -89,7 +55,7 @@ void cmVisualStudioGeneratorOptions::AddTable(cmVS7FlagTable const* table)
void cmVisualStudioGeneratorOptions::ClearTables()
{
for (int i = 0; i < FlagTableCount; ++i) {
- this->FlagTable[i] = CM_NULLPTR;
+ this->FlagTable[i] = nullptr;
}
}
@@ -106,6 +72,7 @@ void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault()
case cmGlobalVisualStudioGenerator::VS12:
case cmGlobalVisualStudioGenerator::VS14:
case cmGlobalVisualStudioGenerator::VS15:
+ case cmGlobalVisualStudioGenerator::VS16:
// by default VS puts <ExceptionHandling></ExceptionHandling> empty
// for a project, to make our projects look the same put a new line
// and space over for the closing </ExceptionHandling> as the default
@@ -163,10 +130,9 @@ bool cmVisualStudioGeneratorOptions::IsManaged() const
bool cmVisualStudioGeneratorOptions::UsingUnicode() const
{
- // Look for the a _UNICODE definition.
- for (std::vector<std::string>::const_iterator di = this->Defines.begin();
- di != this->Defines.end(); ++di) {
- if (*di == "_UNICODE") {
+ // Look for a _UNICODE definition.
+ for (std::string const& di : this->Defines) {
+ if (di == "_UNICODE") {
return true;
}
}
@@ -174,10 +140,9 @@ bool cmVisualStudioGeneratorOptions::UsingUnicode() const
}
bool cmVisualStudioGeneratorOptions::UsingSBCS() const
{
- // Look for the a _SBCS definition.
- for (std::vector<std::string>::const_iterator di = this->Defines.begin();
- di != this->Defines.end(); ++di) {
- if (*di == "_SBCS") {
+ // Look for a _SBCS definition.
+ for (std::string const& di : this->Defines) {
+ if (di == "_SBCS") {
return true;
}
}
@@ -230,7 +195,7 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration()
std::string arch_name = arch[0];
std::vector<std::string> codes;
if (!code.empty()) {
- codes = cmSystemTools::tokenize(code[0], ",");
+ codes = cmTokenize(code[0], ",");
}
if (codes.empty()) {
codes.push_back(arch_name);
@@ -239,35 +204,113 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration()
// It translates to -arch=<virtual> -code=<real>.
cmSystemTools::ReplaceString(arch_name, "sm_", "compute_");
}
- for (std::vector<std::string>::iterator ci = codes.begin();
- ci != codes.end(); ++ci) {
- std::string entry = arch_name + "," + *ci;
+ for (std::string const& c : codes) {
+ std::string entry = arch_name + "," + c;
result.push_back(entry);
}
}
- // Now add entries for the -gencode=<arch>,<code> pairs.
- for (std::vector<std::string>::iterator ei = gencode.begin();
- ei != gencode.end(); ++ei) {
- std::string entry = *ei;
+ // Now add entries for the following signatures:
+ // -gencode=<arch>,<code>
+ // -gencode=<arch>,[<code1>,<code2>]
+ // -gencode=<arch>,"<code1>,<code2>"
+ for (std::string const& e : gencode) {
+ std::string entry = e;
cmSystemTools::ReplaceString(entry, "arch=", "");
cmSystemTools::ReplaceString(entry, "code=", "");
- result.push_back(entry);
+ cmSystemTools::ReplaceString(entry, "[", "");
+ cmSystemTools::ReplaceString(entry, "]", "");
+ cmSystemTools::ReplaceString(entry, "\"", "");
+
+ std::vector<std::string> codes = cmTokenize(entry, ",");
+ if (codes.size() >= 2) {
+ auto gencode_arch = cm::cbegin(codes);
+ for (auto ci = gencode_arch + 1; ci != cm::cend(codes); ++ci) {
+ std::string code_entry = *gencode_arch + "," + *ci;
+ result.push_back(code_entry);
+ }
+ }
}
}
-void cmVisualStudioGeneratorOptions::Parse(const char* flags)
+void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
+{
+ static std::string const ENABLE_UAC = "EnableUAC";
+ if (!HasFlag(ENABLE_UAC)) {
+ return;
+ }
+
+ const std::string uacFlag = GetFlag(ENABLE_UAC);
+ std::vector<std::string> subOptions;
+ cmsys::SystemTools::Split(uacFlag, subOptions, ' ');
+ if (subOptions.empty()) {
+ AddFlag(ENABLE_UAC, "true");
+ return;
+ }
+
+ if (subOptions.size() == 1 && subOptions[0] == "NO") {
+ AddFlag(ENABLE_UAC, "false");
+ return;
+ }
+
+ std::map<std::string, std::string> uacMap;
+ uacMap["level"] = "UACExecutionLevel";
+ uacMap["uiAccess"] = "UACUIAccess";
+
+ std::map<std::string, std::string> uacExecuteLevelMap;
+ uacExecuteLevelMap["asInvoker"] = "AsInvoker";
+ uacExecuteLevelMap["highestAvailable"] = "HighestAvailable";
+ uacExecuteLevelMap["requireAdministrator"] = "RequireAdministrator";
+
+ for (std::string const& subopt : subOptions) {
+ std::vector<std::string> keyValue;
+ cmsys::SystemTools::Split(subopt, keyValue, '=');
+ if (keyValue.size() != 2 || (uacMap.find(keyValue[0]) == uacMap.end())) {
+ // ignore none key=value option or unknown flags
+ continue;
+ }
+
+ if (keyValue[1].front() == '\'' && keyValue[1].back() == '\'') {
+ keyValue[1] = keyValue[1].substr(
+ 1, std::max(std::string::size_type(0), keyValue[1].length() - 2));
+ }
+
+ if (keyValue[0] == "level") {
+ if (uacExecuteLevelMap.find(keyValue[1]) == uacExecuteLevelMap.end()) {
+ // unknown level value
+ continue;
+ }
+
+ AddFlag(uacMap[keyValue[0]], uacExecuteLevelMap[keyValue[1]]);
+ continue;
+ }
+
+ if (keyValue[0] == "uiAccess") {
+ if (keyValue[1] != "true" && keyValue[1] != "false") {
+ // unknown uiAccess value
+ continue;
+ }
+ AddFlag(uacMap[keyValue[0]], keyValue[1]);
+ continue;
+ }
+
+ // unknown sub option
+ }
+
+ AddFlag(ENABLE_UAC, "true");
+}
+
+void cmVisualStudioGeneratorOptions::Parse(const std::string& flags)
{
// Parse the input string as a windows command line since the string
// is intended for writing directly into the build files.
std::vector<std::string> args;
- cmSystemTools::ParseWindowsCommandLine(flags, args);
+ cmSystemTools::ParseWindowsCommandLine(flags.c_str(), args);
// Process flags that need to be represented specially in the IDE
// project file.
- for (std::vector<std::string>::iterator ai = args.begin(); ai != args.end();
- ++ai) {
- this->HandleFlag(ai->c_str());
+ for (std::string const& ai : args) {
+ this->HandleFlag(ai);
}
}
@@ -284,9 +327,9 @@ void cmVisualStudioGeneratorOptions::ParseFinish()
// "rtSingleThreadedDLL", "10", /libs:dll
// "rtSingleThreadedDebug", "5", /dbglibs /libs:static
// "rtSingleThreadedDebugDLL", "11", /dbglibs /libs:dll
- std::string rl = "rtMultiThreaded";
- rl += this->FortranRuntimeDebug ? "Debug" : "";
- rl += this->FortranRuntimeDLL ? "DLL" : "";
+ std::string rl =
+ cmStrCat("rtMultiThreaded", this->FortranRuntimeDebug ? "Debug" : "",
+ this->FortranRuntimeDLL ? "DLL" : "");
this->FlagMap["RuntimeLibrary"] = rl;
}
@@ -326,26 +369,26 @@ void cmVisualStudioGeneratorOptions::Reparse(std::string const& key)
std::string const original = i->second[0];
i->second[0] = "";
this->UnknownFlagField = key;
- this->Parse(original.c_str());
+ this->Parse(original);
}
-void cmVisualStudioGeneratorOptions::StoreUnknownFlag(const char* flag)
+void cmVisualStudioGeneratorOptions::StoreUnknownFlag(std::string const& flag)
{
// Look for Intel Fortran flags that do not map well in the flag table.
if (this->CurrentTool == FortranCompiler) {
- if (strcmp(flag, "/dbglibs") == 0) {
+ if (flag == "/dbglibs" || flag == "-dbglibs") {
this->FortranRuntimeDebug = true;
return;
}
- if (strcmp(flag, "/threads") == 0) {
+ if (flag == "/threads" || flag == "-threads") {
this->FortranRuntimeMT = true;
return;
}
- if (strcmp(flag, "/libs:dll") == 0) {
+ if (flag == "/libs:dll" || flag == "-libs:dll") {
this->FortranRuntimeDLL = true;
return;
}
- if (strcmp(flag, "/libs:static") == 0) {
+ if (flag == "/libs:static" || flag == "-libs:static") {
this->FortranRuntimeDLL = false;
return;
}
@@ -353,7 +396,8 @@ void cmVisualStudioGeneratorOptions::StoreUnknownFlag(const char* flag)
// This option is not known. Store it in the output flags.
std::string const opts = cmOutputConverter::EscapeWindowsShellArgument(
- flag, cmOutputConverter::Shell_Flag_AllowMakeVariables |
+ flag.c_str(),
+ cmOutputConverter::Shell_Flag_AllowMakeVariables |
cmOutputConverter::Shell_Flag_VSIDE);
this->AppendFlagString(this->UnknownFlagField, opts);
}
@@ -370,14 +414,19 @@ cmIDEOptions::FlagValue cmVisualStudioGeneratorOptions::TakeFlag(
return value;
}
-void cmVisualStudioGeneratorOptions::SetConfiguration(const char* config)
+void cmVisualStudioGeneratorOptions::SetConfiguration(
+ const std::string& config)
{
this->Configuration = config;
}
+const std::string& cmVisualStudioGeneratorOptions::GetConfiguration() const
+{
+ return this->Configuration;
+}
+
void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
- std::ostream& fout, const char* prefix, const char* suffix,
- const std::string& lang)
+ std::ostream& fout, int indent, const std::string& lang)
{
if (this->Defines.empty()) {
return;
@@ -386,84 +435,99 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
if (lang == "CUDA") {
tag = "Defines";
}
- if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
- // if there are configuration specific flags, then
- // use the configuration specific tag for PreprocessorDefinitions
- if (!this->Configuration.empty()) {
- fout << prefix;
- this->TargetGenerator->WritePlatformConfigTag(
- tag, this->Configuration.c_str(), 0, 0, 0, &fout);
- } else {
- fout << prefix << "<" << tag << ">";
- }
- } else {
- fout << prefix << tag << "=\"";
- }
+
+ std::ostringstream oss;
const char* sep = "";
std::vector<std::string>::const_iterator de =
cmRemoveDuplicates(this->Defines);
- for (std::vector<std::string>::const_iterator di = this->Defines.begin();
- di != de; ++di) {
+ for (std::string const& di : cmMakeRange(this->Defines.cbegin(), de)) {
// Escape the definition for the compiler.
std::string define;
if (this->Version < cmGlobalVisualStudioGenerator::VS10) {
- define = this->LocalGenerator->EscapeForShell(di->c_str(), true);
+ define = this->LocalGenerator->EscapeForShell(di, true);
} else {
- define = *di;
+ define = di;
}
- // Escape this flag for the IDE.
+ // Escape this flag for the MSBuild.
if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
- define = cmVisualStudio10GeneratorOptionsEscapeForXML(define);
-
+ cmVS10EscapeForMSBuild(define);
if (lang == "RC") {
cmSystemTools::ReplaceString(define, "\"", "\\\"");
}
- } else {
- define = cmVisualStudioGeneratorOptionsEscapeForXML(define);
}
// Store the flag in the project file.
- fout << sep << define;
+ oss << sep << define;
sep = ";";
}
if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
- fout << ";%(" << tag << ")</" << tag << ">" << suffix;
- } else {
- fout << "\"" << suffix;
+ oss << ";%(" << tag << ")";
}
+
+ this->OutputFlag(fout, indent, tag, oss.str());
}
-void cmVisualStudioGeneratorOptions::OutputFlagMap(std::ostream& fout,
- const char* indent)
+void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories(
+ std::ostream& fout, int indent, const std::string& lang)
{
- if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
- for (std::map<std::string, FlagValue>::iterator m = this->FlagMap.begin();
- m != this->FlagMap.end(); ++m) {
- fout << indent;
- if (!this->Configuration.empty()) {
- this->TargetGenerator->WritePlatformConfigTag(
- m->first.c_str(), this->Configuration.c_str(), 0, 0, 0, &fout);
- } else {
- fout << "<" << m->first << ">";
- }
- const char* sep = "";
- for (std::vector<std::string>::iterator i = m->second.begin();
- i != m->second.end(); ++i) {
- fout << sep << cmVisualStudio10GeneratorOptionsEscapeForXML(*i);
- sep = ";";
- }
- fout << "</" << m->first << ">\n";
+ if (this->Includes.empty()) {
+ return;
+ }
+
+ const char* tag = "AdditionalIncludeDirectories";
+ if (lang == "CUDA") {
+ tag = "Include";
+ } else if (lang == "ASM_MASM" || lang == "ASM_NASM") {
+ tag = "IncludePaths";
+ }
+
+ std::ostringstream oss;
+ const char* sep = "";
+ for (std::string include : this->Includes) {
+ // first convert all of the slashes
+ std::string::size_type pos = 0;
+ while ((pos = include.find('/', pos)) != std::string::npos) {
+ include[pos] = '\\';
+ pos++;
+ }
+
+ if (lang == "ASM_NASM") {
+ include += "\\";
+ }
+
+ // Escape this include for the MSBuild.
+ if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
+ cmVS10EscapeForMSBuild(include);
+ }
+ oss << sep << include;
+ sep = ";";
+
+ if (lang == "Fortran") {
+ include += "/$(ConfigurationName)";
+ oss << sep << include;
}
- } else {
- for (std::map<std::string, FlagValue>::iterator m = this->FlagMap.begin();
- m != this->FlagMap.end(); ++m) {
- fout << indent << m->first << "=\"";
- const char* sep = "";
- for (std::vector<std::string>::iterator i = m->second.begin();
- i != m->second.end(); ++i) {
- fout << sep << cmVisualStudioGeneratorOptionsEscapeForXML(*i);
- sep = ";";
+ }
+
+ if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
+ oss << sep << "%(" << tag << ")";
+ }
+
+ this->OutputFlag(fout, indent, tag, oss.str());
+}
+
+void cmVisualStudioGeneratorOptions::OutputFlagMap(std::ostream& fout,
+ int indent)
+{
+ for (auto const& m : this->FlagMap) {
+ std::ostringstream oss;
+ const char* sep = "";
+ for (std::string i : m.second) {
+ if (this->Version >= cmGlobalVisualStudioGenerator::VS10) {
+ cmVS10EscapeForMSBuild(i);
}
- fout << "\"\n";
+ oss << sep << i;
+ sep = ";";
}
+
+ this->OutputFlag(fout, indent, m.first.c_str(), oss.str());
}
}
diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h
index 44d271908..560593e01 100644
--- a/Source/cmVisualStudioGeneratorOptions.h
+++ b/Source/cmVisualStudioGeneratorOptions.h
@@ -3,7 +3,7 @@
#ifndef cmVisualStudioGeneratorOptions_h
#define cmVisualStudioGeneratorOptions_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
#include <string>
@@ -14,9 +14,7 @@
class cmLocalVisualStudioGenerator;
-typedef cmIDEFlagTable cmVS7FlagTable;
-
-class cmVisualStudio10TargetGenerator;
+using cmVS7FlagTable = cmIDEFlagTable;
class cmVisualStudioGeneratorOptions : public cmIDEOptions
{
@@ -34,12 +32,8 @@ public:
CSharpCompiler
};
cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
- cmVS7FlagTable const* table,
- cmVS7FlagTable const* extraTable = 0,
- cmVisualStudio10TargetGenerator* g = 0);
-
- cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
- cmVisualStudio10TargetGenerator* g = 0);
+ cmVS7FlagTable const* table = nullptr,
+ cmVS7FlagTable const* extraTable = nullptr);
// Add a table of flags.
void AddTable(cmVS7FlagTable const* table);
@@ -48,7 +42,7 @@ public:
void ClearTables();
// Store options from command line flags.
- void Parse(const char* flags);
+ void Parse(const std::string& flags);
void ParseFinish();
void PrependInheritedString(std::string const& key);
@@ -77,15 +71,23 @@ public:
void FixCudaCodeGeneration();
+ void FixManifestUACFlags();
+
bool IsDebug() const;
bool IsWinRt() const;
bool IsManaged() const;
// Write options to output.
- void OutputPreprocessorDefinitions(std::ostream& fout, const char* prefix,
- const char* suffix,
+ void OutputPreprocessorDefinitions(std::ostream& fout, int indent,
const std::string& lang);
- void OutputFlagMap(std::ostream& fout, const char* indent);
- void SetConfiguration(const char* config);
+ void OutputAdditionalIncludeDirectories(std::ostream& fout, int indent,
+ const std::string& lang);
+ void OutputFlagMap(std::ostream& fout, int indent);
+ void SetConfiguration(const std::string& config);
+ const std::string& GetConfiguration() const;
+
+protected:
+ virtual void OutputFlag(std::ostream& fout, int indent, const char* tag,
+ const std::string& content) = 0;
private:
cmLocalVisualStudioGenerator* LocalGenerator;
@@ -93,7 +95,6 @@ private:
std::string Configuration;
Tool CurrentTool;
- cmVisualStudio10TargetGenerator* TargetGenerator;
bool FortranRuntimeDebug;
bool FortranRuntimeDLL;
@@ -101,7 +102,7 @@ private:
std::string UnknownFlagField;
- virtual void StoreUnknownFlag(const char* flag);
+ void StoreUnknownFlag(std::string const& flag) override;
FlagValue TakeFlag(std::string const& key);
};
diff --git a/Source/cmVisualStudioSlnData.h b/Source/cmVisualStudioSlnData.h
index e12047fb5..5ce7d74f8 100644
--- a/Source/cmVisualStudioSlnData.h
+++ b/Source/cmVisualStudioSlnData.h
@@ -3,7 +3,7 @@
#ifndef cmVisualStudioSlnData_h
#define cmVisualStudioSlnData_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
#include <string>
@@ -45,9 +45,9 @@ public:
const std::string& projectRelativePath);
private:
- typedef std::map<std::string, cmSlnProjectEntry> ProjectStorage;
+ using ProjectStorage = std::map<std::string, cmSlnProjectEntry>;
ProjectStorage ProjectsByGUID;
- typedef std::map<std::string, ProjectStorage::iterator> ProjectStringIndex;
+ using ProjectStringIndex = std::map<std::string, ProjectStorage::iterator>;
ProjectStringIndex ProjectNameIndex;
};
diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx
index 1a32abacf..4533e9b69 100644
--- a/Source/cmVisualStudioSlnParser.cxx
+++ b/Source/cmVisualStudioSlnParser.cxx
@@ -2,13 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmVisualStudioSlnParser.h"
-#include "cmSystemTools.h"
-#include "cmVisualStudioSlnData.h"
-#include "cmsys/FStream.hxx"
-
#include <cassert>
#include <stack>
+#include "cmsys/FStream.hxx"
+
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+#include "cmVisualStudioSlnData.h"
+
namespace {
enum LineFormat
{
@@ -50,7 +52,7 @@ public:
void CopyVerbatim(const std::string& line) { this->Tag = line; }
private:
- typedef std::pair<std::string, bool> StringData;
+ using StringData = std::pair<std::string, bool>;
std::string Tag;
StringData Arg;
std::vector<StringData> Values;
@@ -192,8 +194,8 @@ bool cmVisualStudioSlnParser::State::Process(
assert(!line.IsComment());
switch (this->Stack.top()) {
case FileStateStart:
- if (!cmSystemTools::StringStartsWith(
- line.GetTag().c_str(), "Microsoft Visual Studio Solution File")) {
+ if (!cmHasLiteralPrefix(line.GetTag(),
+ "Microsoft Visual Studio Solution File")) {
result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
return false;
}
@@ -329,7 +331,7 @@ bool cmVisualStudioSlnParser::State::Process(
case FileStateIgnore:
if (line.GetTag() == this->EndIgnoreTag) {
this->Stack.pop();
- this->EndIgnoreTag = "";
+ this->EndIgnoreTag.clear();
}
break;
default:
@@ -462,7 +464,7 @@ bool cmVisualStudioSlnParser::ParseImpl(std::istream& input, cmSlnData& output,
if (!this->ParseBOM(input, line, state))
return false;
do {
- line = cmSystemTools::TrimWhitespace(line);
+ line = cmTrimWhitespace(line);
if (line.empty())
continue;
ParsedLine parsedLine;
@@ -578,9 +580,9 @@ bool cmVisualStudioSlnParser::ParseKeyValuePair(const std::string& line,
return true;
}
const std::string& key = line.substr(0, idxEqualSign);
- parsedLine.SetTag(cmSystemTools::TrimWhitespace(key));
+ parsedLine.SetTag(cmTrimWhitespace(key));
const std::string& value = line.substr(idxEqualSign + 1);
- parsedLine.AddValue(cmSystemTools::TrimWhitespace(value));
+ parsedLine.AddValue(cmTrimWhitespace(value));
return true;
}
@@ -589,21 +591,20 @@ bool cmVisualStudioSlnParser::ParseTag(const std::string& fullTag,
{
size_t idxLeftParen = fullTag.find('(');
if (idxLeftParen == fullTag.npos) {
- parsedLine.SetTag(cmSystemTools::TrimWhitespace(fullTag));
+ parsedLine.SetTag(cmTrimWhitespace(fullTag));
return true;
}
- parsedLine.SetTag(
- cmSystemTools::TrimWhitespace(fullTag.substr(0, idxLeftParen)));
+ parsedLine.SetTag(cmTrimWhitespace(fullTag.substr(0, idxLeftParen)));
size_t idxRightParen = fullTag.rfind(')');
if (idxRightParen == fullTag.npos) {
this->LastResult.SetError(ResultErrorInputStructure,
state.GetCurrentLine());
return false;
}
- const std::string& arg = cmSystemTools::TrimWhitespace(
+ const std::string& arg = cmTrimWhitespace(
fullTag.substr(idxLeftParen + 1, idxRightParen - idxLeftParen - 1));
- if (arg[0] == '"') {
- if (arg[arg.size() - 1] != '"') {
+ if (arg.front() == '"') {
+ if (arg.back() != '"') {
this->LastResult.SetError(ResultErrorInputStructure,
state.GetCurrentLine());
return false;
@@ -617,10 +618,10 @@ bool cmVisualStudioSlnParser::ParseTag(const std::string& fullTag,
bool cmVisualStudioSlnParser::ParseValue(const std::string& value,
ParsedLine& parsedLine)
{
- const std::string& trimmed = cmSystemTools::TrimWhitespace(value);
+ const std::string& trimmed = cmTrimWhitespace(value);
if (trimmed.empty())
parsedLine.AddValue(trimmed);
- else if (trimmed[0] == '"' && trimmed[trimmed.size() - 1] == '"')
+ else if (trimmed.front() == '"' && trimmed.back() == '"')
parsedLine.AddQuotedValue(trimmed.substr(1, trimmed.size() - 2));
else
parsedLine.AddValue(trimmed);
diff --git a/Source/cmVisualStudioSlnParser.h b/Source/cmVisualStudioSlnParser.h
index d51732407..6c05633b8 100644
--- a/Source/cmVisualStudioSlnParser.h
+++ b/Source/cmVisualStudioSlnParser.h
@@ -3,13 +3,14 @@
#ifndef cmVisualStudioSlnParser_h
#define cmVisualStudioSlnParser_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <bitset>
#include <iosfwd>
-#include <stddef.h>
#include <string>
+#include <stddef.h>
+
class cmSlnData;
class cmVisualStudioSlnParser
@@ -42,7 +43,7 @@ public:
DataGroupCount
};
- typedef std::bitset<DataGroupCount> DataGroupSet;
+ using DataGroupSet = std::bitset<DataGroupCount>;
static const DataGroupSet DataGroupProjects;
static const DataGroupSet DataGroupProjectDependencies;
diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx
index fc64d0fb0..3b113aadb 100644
--- a/Source/cmVisualStudioWCEPlatformParser.cxx
+++ b/Source/cmVisualStudioWCEPlatformParser.cxx
@@ -56,12 +56,12 @@ void cmVisualStudioWCEPlatformParser::StartElement(const std::string& name,
return;
}
- this->CharacterData = "";
+ this->CharacterData.clear();
if (name == "PlatformData") {
- this->PlatformName = "";
- this->OSMajorVersion = "";
- this->OSMinorVersion = "";
+ this->PlatformName.clear();
+ this->OSMajorVersion.clear();
+ this->OSMinorVersion.clear();
this->Macros.clear();
}
diff --git a/Source/cmVisualStudioWCEPlatformParser.h b/Source/cmVisualStudioWCEPlatformParser.h
index 75c3d1a39..60a66113e 100644
--- a/Source/cmVisualStudioWCEPlatformParser.h
+++ b/Source/cmVisualStudioWCEPlatformParser.h
@@ -3,13 +3,14 @@
#ifndef cmVisualStudioWCEPlatformParser_h
#define cmVisualStudioWCEPlatformParser_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
-#include <stddef.h>
#include <string>
#include <vector>
+#include <stddef.h>
+
#include "cmXMLParser.h"
// This class is used to parse XML with configuration
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index 24d7bf1bf..26e7c7537 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -2,17 +2,46 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmWhileCommand.h"
+#include <string>
+#include <utility>
+
+#include <cm/memory>
+#include <cm/string_view>
+
+#include "cm_static_string_view.hxx"
+
#include "cmConditionEvaluator.h"
#include "cmExecutionStatus.h"
#include "cmExpandedCommandArgument.h"
+#include "cmFunctionBlocker.h"
+#include "cmListFileCache.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmSystemTools.h"
-#include "cm_auto_ptr.hxx"
-#include "cmake.h"
+
+class cmWhileFunctionBlocker : public cmFunctionBlocker
+{
+public:
+ cmWhileFunctionBlocker(cmMakefile* mf);
+ ~cmWhileFunctionBlocker() override;
+
+ cm::string_view StartCommandName() const override { return "while"_s; }
+ cm::string_view EndCommandName() const override { return "endwhile"_s; }
+
+ bool ArgumentsMatch(cmListFileFunction const& lff,
+ cmMakefile& mf) const override;
+
+ bool Replay(std::vector<cmListFileFunction> functions,
+ cmExecutionStatus& inStatus) override;
+
+ std::vector<cmListFileArgument> Args;
+
+private:
+ cmMakefile* Makefile;
+};
cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf)
: Makefile(mf)
- , Depth(0)
{
this->Makefile->PushLoopBlock();
}
@@ -22,122 +51,93 @@ cmWhileFunctionBlocker::~cmWhileFunctionBlocker()
this->Makefile->PopLoopBlock();
}
-bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
- cmMakefile& mf,
- cmExecutionStatus& inStatus)
+bool cmWhileFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff,
+ cmMakefile&) const
{
- // at end of for each execute recorded commands
- if (!cmSystemTools::Strucmp(lff.Name.c_str(), "while")) {
- // record the number of while commands past this one
- this->Depth++;
- } else if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endwhile")) {
- // if this is the endwhile for this while loop then execute
- if (!this->Depth) {
- // Remove the function blocker for this scope or bail.
- CM_AUTO_PTR<cmFunctionBlocker> fb(mf.RemoveFunctionBlocker(this, lff));
- if (!fb.get()) {
- return false;
- }
+ return lff.Arguments.empty() || lff.Arguments == this->Args;
+}
- std::string errorString;
-
- std::vector<cmExpandedCommandArgument> expandedArguments;
- mf.ExpandArguments(this->Args, expandedArguments);
- cmake::MessageType messageType;
-
- cmListFileContext execContext = this->GetStartingContext();
-
- cmCommandContext commandContext;
- commandContext.Line = execContext.Line;
- commandContext.Name = execContext.Name;
-
- cmConditionEvaluator conditionEvaluator(mf, this->GetStartingContext(),
- mf.GetBacktrace(commandContext));
-
- bool isTrue =
- conditionEvaluator.IsTrue(expandedArguments, errorString, messageType);
-
- while (isTrue) {
- if (!errorString.empty()) {
- std::string err = "had incorrect arguments: ";
- unsigned int i;
- for (i = 0; i < this->Args.size(); ++i) {
- err += (this->Args[i].Delim ? "\"" : "");
- err += this->Args[i].Value;
- err += (this->Args[i].Delim ? "\"" : "");
- err += " ";
- }
- err += "(";
- err += errorString;
- err += ").";
- mf.IssueMessage(messageType, err);
- if (messageType == cmake::FATAL_ERROR) {
- cmSystemTools::SetFatalErrorOccured();
- return true;
- }
- }
-
- // Invoke all the functions that were collected in the block.
- for (unsigned int c = 0; c < this->Functions.size(); ++c) {
- cmExecutionStatus status;
- mf.ExecuteCommand(this->Functions[c], status);
- if (status.GetReturnInvoked()) {
- inStatus.SetReturnInvoked();
- return true;
- }
- if (status.GetBreakInvoked()) {
- return true;
- }
- if (status.GetContinueInvoked()) {
- break;
- }
- if (cmSystemTools::GetFatalErrorOccured()) {
- return true;
- }
- }
- expandedArguments.clear();
- mf.ExpandArguments(this->Args, expandedArguments);
- isTrue = conditionEvaluator.IsTrue(expandedArguments, errorString,
- messageType);
- }
- return true;
- }
- // decrement for each nested while that ends
- this->Depth--;
- }
+bool cmWhileFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
+ cmExecutionStatus& inStatus)
+{
+ cmMakefile& mf = inStatus.GetMakefile();
+ std::string errorString;
- // record the command
- this->Functions.push_back(lff);
+ std::vector<cmExpandedCommandArgument> expandedArguments;
+ mf.ExpandArguments(this->Args, expandedArguments);
+ MessageType messageType;
- // always return true
- return true;
-}
+ cmListFileContext execContext = this->GetStartingContext();
-bool cmWhileFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
- cmMakefile&)
-{
- if (!cmSystemTools::Strucmp(lff.Name.c_str(), "endwhile")) {
- // if the endwhile has arguments, then make sure
- // they match the arguments of the matching while
- if (lff.Arguments.empty() || lff.Arguments == this->Args) {
- return true;
+ cmCommandContext commandContext;
+ commandContext.Line = execContext.Line;
+ commandContext.Name = execContext.Name;
+
+ cmConditionEvaluator conditionEvaluator(mf, this->GetStartingContext(),
+ mf.GetBacktrace(commandContext));
+
+ bool isTrue =
+ conditionEvaluator.IsTrue(expandedArguments, errorString, messageType);
+
+ while (isTrue) {
+ if (!errorString.empty()) {
+ std::string err = "had incorrect arguments: ";
+ for (cmListFileArgument const& arg : this->Args) {
+ err += (arg.Delim ? "\"" : "");
+ err += arg.Value;
+ err += (arg.Delim ? "\"" : "");
+ err += " ";
+ }
+ err += "(";
+ err += errorString;
+ err += ").";
+ mf.IssueMessage(messageType, err);
+ if (messageType == MessageType::FATAL_ERROR) {
+ cmSystemTools::SetFatalErrorOccured();
+ return true;
+ }
+ }
+
+ // Invoke all the functions that were collected in the block.
+ for (cmListFileFunction const& fn : functions) {
+ cmExecutionStatus status(mf);
+ mf.ExecuteCommand(fn, status);
+ if (status.GetReturnInvoked()) {
+ inStatus.SetReturnInvoked();
+ return true;
+ }
+ if (status.GetBreakInvoked()) {
+ return true;
+ }
+ if (status.GetContinueInvoked()) {
+ break;
+ }
+ if (cmSystemTools::GetFatalErrorOccured()) {
+ return true;
+ }
}
+ expandedArguments.clear();
+ mf.ExpandArguments(this->Args, expandedArguments);
+ isTrue =
+ conditionEvaluator.IsTrue(expandedArguments, errorString, messageType);
}
- return false;
+ return true;
}
-bool cmWhileCommand::InvokeInitialPass(
- const std::vector<cmListFileArgument>& args, cmExecutionStatus&)
+bool cmWhileCommand(std::vector<cmListFileArgument> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
// create a function blocker
- cmWhileFunctionBlocker* f = new cmWhileFunctionBlocker(this->Makefile);
- f->Args = args;
- this->Makefile->AddFunctionBlocker(f);
-
+ {
+ cmMakefile& makefile = status.GetMakefile();
+ auto fb = cm::make_unique<cmWhileFunctionBlocker>(&makefile);
+ fb->Args = args;
+ makefile.AddFunctionBlocker(std::move(fb));
+ }
return true;
}
diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h
index a95e4c30c..beca652c6 100644
--- a/Source/cmWhileCommand.h
+++ b/Source/cmWhileCommand.h
@@ -3,60 +3,15 @@
#ifndef cmWhileCommand_h
#define cmWhileCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
-#include <string>
#include <vector>
-#include "cmCommand.h"
-#include "cmFunctionBlocker.h"
-#include "cmListFileCache.h"
-
class cmExecutionStatus;
-class cmMakefile;
-
-class cmWhileFunctionBlocker : public cmFunctionBlocker
-{
-public:
- cmWhileFunctionBlocker(cmMakefile* mf);
- ~cmWhileFunctionBlocker() CM_OVERRIDE;
- bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
- cmExecutionStatus&) CM_OVERRIDE;
- bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) CM_OVERRIDE;
-
- std::vector<cmListFileArgument> Args;
- std::vector<cmListFileFunction> Functions;
-
-private:
- cmMakefile* Makefile;
- int Depth;
-};
+struct cmListFileArgument;
/// \brief Starts a while loop
-class cmWhileCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmWhileCommand; }
-
- /**
- * This overrides the default InvokeInitialPass implementation.
- * It records the arguments before expansion.
- */
- bool InvokeInitialPass(const std::vector<cmListFileArgument>& args,
- cmExecutionStatus&) CM_OVERRIDE;
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus&) CM_OVERRIDE
- {
- return false;
- }
-};
+bool cmWhileCommand(std::vector<cmListFileArgument> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmWorkerPool.cxx b/Source/cmWorkerPool.cxx
new file mode 100644
index 000000000..aa0d6b3d5
--- /dev/null
+++ b/Source/cmWorkerPool.cxx
@@ -0,0 +1,763 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmWorkerPool.h"
+
+#include <algorithm>
+#include <array>
+#include <condition_variable>
+#include <cstddef>
+#include <deque>
+#include <functional>
+#include <mutex>
+#include <thread>
+
+#include <cm/memory>
+
+#include "cm_uv.h"
+
+#include "cmRange.h"
+#include "cmStringAlgorithms.h"
+#include "cmUVHandlePtr.h"
+#include "cmUVSignalHackRAII.h" // IWYU pragma: keep
+
+/**
+ * @brief libuv pipe buffer class
+ */
+class cmUVPipeBuffer
+{
+public:
+ using DataRange = cmRange<const char*>;
+ using DataFunction = std::function<void(DataRange)>;
+ /// On error the ssize_t argument is a non zero libuv error code
+ using EndFunction = std::function<void(ssize_t)>;
+
+public:
+ /**
+ * Reset to construction state
+ */
+ void reset();
+
+ /**
+ * Initializes uv_pipe(), uv_stream() and uv_handle()
+ * @return true on success
+ */
+ bool init(uv_loop_t* uv_loop);
+
+ /**
+ * Start reading
+ * @return true on success
+ */
+ bool startRead(DataFunction dataFunction, EndFunction endFunction);
+
+ //! libuv pipe
+ uv_pipe_t* uv_pipe() const { return UVPipe_.get(); }
+ //! uv_pipe() casted to libuv stream
+ uv_stream_t* uv_stream() const { return static_cast<uv_stream_t*>(UVPipe_); }
+ //! uv_pipe() casted to libuv handle
+ uv_handle_t* uv_handle() { return static_cast<uv_handle_t*>(UVPipe_); }
+
+private:
+ // -- Libuv callbacks
+ static void UVAlloc(uv_handle_t* handle, size_t suggestedSize,
+ uv_buf_t* buf);
+ static void UVData(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf);
+
+private:
+ cm::uv_pipe_ptr UVPipe_;
+ std::vector<char> Buffer_;
+ DataFunction DataFunction_;
+ EndFunction EndFunction_;
+};
+
+void cmUVPipeBuffer::reset()
+{
+ if (UVPipe_.get() != nullptr) {
+ EndFunction_ = nullptr;
+ DataFunction_ = nullptr;
+ Buffer_.clear();
+ Buffer_.shrink_to_fit();
+ UVPipe_.reset();
+ }
+}
+
+bool cmUVPipeBuffer::init(uv_loop_t* uv_loop)
+{
+ reset();
+ if (uv_loop == nullptr) {
+ return false;
+ }
+ int ret = UVPipe_.init(*uv_loop, 0, this);
+ return (ret == 0);
+}
+
+bool cmUVPipeBuffer::startRead(DataFunction dataFunction,
+ EndFunction endFunction)
+{
+ if (UVPipe_.get() == nullptr) {
+ return false;
+ }
+ if (!dataFunction || !endFunction) {
+ return false;
+ }
+ DataFunction_ = std::move(dataFunction);
+ EndFunction_ = std::move(endFunction);
+ int ret = uv_read_start(uv_stream(), &cmUVPipeBuffer::UVAlloc,
+ &cmUVPipeBuffer::UVData);
+ return (ret == 0);
+}
+
+void cmUVPipeBuffer::UVAlloc(uv_handle_t* handle, size_t suggestedSize,
+ uv_buf_t* buf)
+{
+ auto& pipe = *reinterpret_cast<cmUVPipeBuffer*>(handle->data);
+ pipe.Buffer_.resize(suggestedSize);
+ buf->base = pipe.Buffer_.data();
+ buf->len = static_cast<unsigned long>(pipe.Buffer_.size());
+}
+
+void cmUVPipeBuffer::UVData(uv_stream_t* stream, ssize_t nread,
+ const uv_buf_t* buf)
+{
+ auto& pipe = *reinterpret_cast<cmUVPipeBuffer*>(stream->data);
+ if (nread > 0) {
+ if (buf->base != nullptr) {
+ // Call data function
+ pipe.DataFunction_(DataRange(buf->base, buf->base + nread));
+ }
+ } else if (nread < 0) {
+ // Save the end function on the stack before resetting the pipe
+ EndFunction efunc;
+ efunc.swap(pipe.EndFunction_);
+ // Reset pipe before calling the end function
+ pipe.reset();
+ // Call end function
+ efunc((nread == UV_EOF) ? 0 : nread);
+ }
+}
+
+/**
+ * @brief External process management class
+ */
+class cmUVReadOnlyProcess
+{
+public:
+ // -- Types
+ //! @brief Process settings
+ struct SetupT
+ {
+ std::string WorkingDirectory;
+ std::vector<std::string> Command;
+ cmWorkerPool::ProcessResultT* Result = nullptr;
+ bool MergedOutput = false;
+ };
+
+public:
+ // -- Const accessors
+ SetupT const& Setup() const { return Setup_; }
+ cmWorkerPool::ProcessResultT* Result() const { return Setup_.Result; }
+ bool IsStarted() const { return IsStarted_; }
+ bool IsFinished() const { return IsFinished_; }
+
+ // -- Runtime
+ void setup(cmWorkerPool::ProcessResultT* result, bool mergedOutput,
+ std::vector<std::string> const& command,
+ std::string const& workingDirectory = std::string());
+ bool start(uv_loop_t* uv_loop, std::function<void()> finishedCallback);
+
+private:
+ // -- Libuv callbacks
+ static void UVExit(uv_process_t* handle, int64_t exitStatus, int termSignal);
+ void UVPipeOutData(cmUVPipeBuffer::DataRange data);
+ void UVPipeOutEnd(ssize_t error);
+ void UVPipeErrData(cmUVPipeBuffer::DataRange data);
+ void UVPipeErrEnd(ssize_t error);
+ void UVTryFinish();
+
+private:
+ // -- Setup
+ SetupT Setup_;
+ // -- Runtime
+ bool IsStarted_ = false;
+ bool IsFinished_ = false;
+ std::function<void()> FinishedCallback_;
+ std::vector<const char*> CommandPtr_;
+ std::array<uv_stdio_container_t, 3> UVOptionsStdIO_;
+ uv_process_options_t UVOptions_;
+ cm::uv_process_ptr UVProcess_;
+ cmUVPipeBuffer UVPipeOut_;
+ cmUVPipeBuffer UVPipeErr_;
+};
+
+void cmUVReadOnlyProcess::setup(cmWorkerPool::ProcessResultT* result,
+ bool mergedOutput,
+ std::vector<std::string> const& command,
+ std::string const& workingDirectory)
+{
+ Setup_.WorkingDirectory = workingDirectory;
+ Setup_.Command = command;
+ Setup_.Result = result;
+ Setup_.MergedOutput = mergedOutput;
+}
+
+bool cmUVReadOnlyProcess::start(uv_loop_t* uv_loop,
+ std::function<void()> finishedCallback)
+{
+ if (IsStarted() || (Result() == nullptr)) {
+ return false;
+ }
+
+ // Reset result before the start
+ Result()->reset();
+
+ // Fill command string pointers
+ if (!Setup().Command.empty()) {
+ CommandPtr_.reserve(Setup().Command.size() + 1);
+ for (std::string const& arg : Setup().Command) {
+ CommandPtr_.push_back(arg.c_str());
+ }
+ CommandPtr_.push_back(nullptr);
+ } else {
+ Result()->ErrorMessage = "Empty command";
+ }
+
+ if (!Result()->error()) {
+ if (!UVPipeOut_.init(uv_loop)) {
+ Result()->ErrorMessage = "libuv stdout pipe initialization failed";
+ }
+ }
+ if (!Result()->error()) {
+ if (!UVPipeErr_.init(uv_loop)) {
+ Result()->ErrorMessage = "libuv stderr pipe initialization failed";
+ }
+ }
+ if (!Result()->error()) {
+ // -- Setup process stdio options
+ // stdin
+ UVOptionsStdIO_[0].flags = UV_IGNORE;
+ UVOptionsStdIO_[0].data.stream = nullptr;
+ // stdout
+ UVOptionsStdIO_[1].flags =
+ static_cast<uv_stdio_flags>(UV_CREATE_PIPE | UV_WRITABLE_PIPE);
+ UVOptionsStdIO_[1].data.stream = UVPipeOut_.uv_stream();
+ // stderr
+ UVOptionsStdIO_[2].flags =
+ static_cast<uv_stdio_flags>(UV_CREATE_PIPE | UV_WRITABLE_PIPE);
+ UVOptionsStdIO_[2].data.stream = UVPipeErr_.uv_stream();
+
+ // -- Setup process options
+ std::fill_n(reinterpret_cast<char*>(&UVOptions_), sizeof(UVOptions_), 0);
+ UVOptions_.exit_cb = &cmUVReadOnlyProcess::UVExit;
+ UVOptions_.file = CommandPtr_[0];
+ UVOptions_.args = const_cast<char**>(CommandPtr_.data());
+ UVOptions_.cwd = Setup_.WorkingDirectory.c_str();
+ UVOptions_.flags = UV_PROCESS_WINDOWS_HIDE;
+ UVOptions_.stdio_count = static_cast<int>(UVOptionsStdIO_.size());
+ UVOptions_.stdio = UVOptionsStdIO_.data();
+
+ // -- Spawn process
+ int uvErrorCode = UVProcess_.spawn(*uv_loop, UVOptions_, this);
+ if (uvErrorCode != 0) {
+ Result()->ErrorMessage = "libuv process spawn failed";
+ if (const char* uvErr = uv_strerror(uvErrorCode)) {
+ Result()->ErrorMessage += ": ";
+ Result()->ErrorMessage += uvErr;
+ }
+ }
+ }
+ // -- Start reading from stdio streams
+ if (!Result()->error()) {
+ if (!UVPipeOut_.startRead(
+ [this](cmUVPipeBuffer::DataRange range) {
+ this->UVPipeOutData(range);
+ },
+ [this](ssize_t error) { this->UVPipeOutEnd(error); })) {
+ Result()->ErrorMessage = "libuv start reading from stdout pipe failed";
+ }
+ }
+ if (!Result()->error()) {
+ if (!UVPipeErr_.startRead(
+ [this](cmUVPipeBuffer::DataRange range) {
+ this->UVPipeErrData(range);
+ },
+ [this](ssize_t error) { this->UVPipeErrEnd(error); })) {
+ Result()->ErrorMessage = "libuv start reading from stderr pipe failed";
+ }
+ }
+
+ if (!Result()->error()) {
+ IsStarted_ = true;
+ FinishedCallback_ = std::move(finishedCallback);
+ } else {
+ // Clear libuv handles and finish
+ UVProcess_.reset();
+ UVPipeOut_.reset();
+ UVPipeErr_.reset();
+ CommandPtr_.clear();
+ }
+
+ return IsStarted();
+}
+
+void cmUVReadOnlyProcess::UVExit(uv_process_t* handle, int64_t exitStatus,
+ int termSignal)
+{
+ auto& proc = *reinterpret_cast<cmUVReadOnlyProcess*>(handle->data);
+ if (proc.IsStarted() && !proc.IsFinished()) {
+ // Set error message on demand
+ proc.Result()->ExitStatus = exitStatus;
+ proc.Result()->TermSignal = termSignal;
+ if (!proc.Result()->error()) {
+ if (termSignal != 0) {
+ proc.Result()->ErrorMessage = cmStrCat(
+ "Process was terminated by signal ", proc.Result()->TermSignal);
+ } else if (exitStatus != 0) {
+ proc.Result()->ErrorMessage = cmStrCat(
+ "Process failed with return value ", proc.Result()->ExitStatus);
+ }
+ }
+
+ // Reset process handle
+ proc.UVProcess_.reset();
+ // Try finish
+ proc.UVTryFinish();
+ }
+}
+
+void cmUVReadOnlyProcess::UVPipeOutData(cmUVPipeBuffer::DataRange data)
+{
+ Result()->StdOut.append(data.begin(), data.end());
+}
+
+void cmUVReadOnlyProcess::UVPipeOutEnd(ssize_t error)
+{
+ // Process pipe error
+ if ((error != 0) && !Result()->error()) {
+ Result()->ErrorMessage = cmStrCat(
+ "Reading from stdout pipe failed with libuv error code ", error);
+ }
+ // Try finish
+ UVTryFinish();
+}
+
+void cmUVReadOnlyProcess::UVPipeErrData(cmUVPipeBuffer::DataRange data)
+{
+ std::string* str =
+ Setup_.MergedOutput ? &Result()->StdOut : &Result()->StdErr;
+ str->append(data.begin(), data.end());
+}
+
+void cmUVReadOnlyProcess::UVPipeErrEnd(ssize_t error)
+{
+ // Process pipe error
+ if ((error != 0) && !Result()->error()) {
+ Result()->ErrorMessage = cmStrCat(
+ "Reading from stderr pipe failed with libuv error code ", error);
+ }
+ // Try finish
+ UVTryFinish();
+}
+
+void cmUVReadOnlyProcess::UVTryFinish()
+{
+ // There still might be data in the pipes after the process has finished.
+ // Therefore check if the process is finished AND all pipes are closed
+ // before signaling the worker thread to continue.
+ if ((UVProcess_.get() != nullptr) || (UVPipeOut_.uv_pipe() != nullptr) ||
+ (UVPipeErr_.uv_pipe() != nullptr)) {
+ return;
+ }
+ IsFinished_ = true;
+ FinishedCallback_();
+}
+
+/**
+ * @brief Worker pool worker thread
+ */
+class cmWorkerPoolWorker
+{
+public:
+ cmWorkerPoolWorker(uv_loop_t& uvLoop);
+ ~cmWorkerPoolWorker();
+
+ cmWorkerPoolWorker(cmWorkerPoolWorker const&) = delete;
+ cmWorkerPoolWorker& operator=(cmWorkerPoolWorker const&) = delete;
+
+ /**
+ * Set the internal thread
+ */
+ void SetThread(std::thread&& aThread) { Thread_ = std::move(aThread); }
+
+ /**
+ * Run an external process
+ */
+ bool RunProcess(cmWorkerPool::ProcessResultT& result,
+ std::vector<std::string> const& command,
+ std::string const& workingDirectory);
+
+private:
+ // -- Libuv callbacks
+ static void UVProcessStart(uv_async_t* handle);
+ void UVProcessFinished();
+
+private:
+ // -- Process management
+ struct
+ {
+ std::mutex Mutex;
+ cm::uv_async_ptr Request;
+ std::condition_variable Condition;
+ std::unique_ptr<cmUVReadOnlyProcess> ROP;
+ } Proc_;
+ // -- System thread
+ std::thread Thread_;
+};
+
+cmWorkerPoolWorker::cmWorkerPoolWorker(uv_loop_t& uvLoop)
+{
+ Proc_.Request.init(uvLoop, &cmWorkerPoolWorker::UVProcessStart, this);
+}
+
+cmWorkerPoolWorker::~cmWorkerPoolWorker()
+{
+ if (Thread_.joinable()) {
+ Thread_.join();
+ }
+}
+
+bool cmWorkerPoolWorker::RunProcess(cmWorkerPool::ProcessResultT& result,
+ std::vector<std::string> const& command,
+ std::string const& workingDirectory)
+{
+ if (command.empty()) {
+ return false;
+ }
+ // Create process instance
+ {
+ std::lock_guard<std::mutex> lock(Proc_.Mutex);
+ Proc_.ROP = cm::make_unique<cmUVReadOnlyProcess>();
+ Proc_.ROP->setup(&result, true, command, workingDirectory);
+ }
+ // Send asynchronous process start request to libuv loop
+ Proc_.Request.send();
+ // Wait until the process has been finished and destroyed
+ {
+ std::unique_lock<std::mutex> ulock(Proc_.Mutex);
+ while (Proc_.ROP) {
+ Proc_.Condition.wait(ulock);
+ }
+ }
+ return !result.error();
+}
+
+void cmWorkerPoolWorker::UVProcessStart(uv_async_t* handle)
+{
+ auto* wrk = reinterpret_cast<cmWorkerPoolWorker*>(handle->data);
+ bool startFailed = false;
+ {
+ auto& Proc = wrk->Proc_;
+ std::lock_guard<std::mutex> lock(Proc.Mutex);
+ if (Proc.ROP && !Proc.ROP->IsStarted()) {
+ startFailed =
+ !Proc.ROP->start(handle->loop, [wrk] { wrk->UVProcessFinished(); });
+ }
+ }
+ // Clean up if starting of the process failed
+ if (startFailed) {
+ wrk->UVProcessFinished();
+ }
+}
+
+void cmWorkerPoolWorker::UVProcessFinished()
+{
+ {
+ std::lock_guard<std::mutex> lock(Proc_.Mutex);
+ if (Proc_.ROP && (Proc_.ROP->IsFinished() || !Proc_.ROP->IsStarted())) {
+ Proc_.ROP.reset();
+ }
+ }
+ // Notify idling thread
+ Proc_.Condition.notify_one();
+}
+
+/**
+ * @brief Private worker pool internals
+ */
+class cmWorkerPoolInternal
+{
+public:
+ // -- Constructors
+ cmWorkerPoolInternal(cmWorkerPool* pool);
+ ~cmWorkerPoolInternal();
+
+ /**
+ * Runs the libuv loop.
+ */
+ bool Process();
+
+ /**
+ * Clear queue and abort threads.
+ */
+ void Abort();
+
+ /**
+ * Push a job to the queue and notify a worker.
+ */
+ bool PushJob(cmWorkerPool::JobHandleT&& jobHandle);
+
+ /**
+ * Worker thread main loop method.
+ */
+ void Work(unsigned int workerIndex);
+
+ // -- Request slots
+ static void UVSlotBegin(uv_async_t* handle);
+ static void UVSlotEnd(uv_async_t* handle);
+
+public:
+ // -- UV loop
+#ifdef CMAKE_UV_SIGNAL_HACK
+ std::unique_ptr<cmUVSignalHackRAII> UVHackRAII;
+#endif
+ std::unique_ptr<uv_loop_t> UVLoop;
+ cm::uv_async_ptr UVRequestBegin;
+ cm::uv_async_ptr UVRequestEnd;
+
+ // -- Thread pool and job queue
+ std::mutex Mutex;
+ bool Processing = false;
+ bool Aborting = false;
+ bool FenceProcessing = false;
+ unsigned int WorkersRunning = 0;
+ unsigned int WorkersIdle = 0;
+ unsigned int JobsProcessing = 0;
+ std::deque<cmWorkerPool::JobHandleT> Queue;
+ std::condition_variable Condition;
+ std::vector<std::unique_ptr<cmWorkerPoolWorker>> Workers;
+
+ // -- References
+ cmWorkerPool* Pool = nullptr;
+};
+
+void cmWorkerPool::ProcessResultT::reset()
+{
+ ExitStatus = 0;
+ TermSignal = 0;
+ if (!StdOut.empty()) {
+ StdOut.clear();
+ StdOut.shrink_to_fit();
+ }
+ if (!StdErr.empty()) {
+ StdErr.clear();
+ StdErr.shrink_to_fit();
+ }
+ if (!ErrorMessage.empty()) {
+ ErrorMessage.clear();
+ ErrorMessage.shrink_to_fit();
+ }
+}
+
+cmWorkerPoolInternal::cmWorkerPoolInternal(cmWorkerPool* pool)
+ : Pool(pool)
+{
+ // Initialize libuv loop
+ uv_disable_stdio_inheritance();
+#ifdef CMAKE_UV_SIGNAL_HACK
+ UVHackRAII = cm::make_unique<cmUVSignalHackRAII>();
+#endif
+ UVLoop = cm::make_unique<uv_loop_t>();
+ uv_loop_init(UVLoop.get());
+}
+
+cmWorkerPoolInternal::~cmWorkerPoolInternal()
+{
+ uv_loop_close(UVLoop.get());
+}
+
+bool cmWorkerPoolInternal::Process()
+{
+ // Reset state flags
+ Processing = true;
+ Aborting = false;
+ // Initialize libuv asynchronous request
+ UVRequestBegin.init(*UVLoop, &cmWorkerPoolInternal::UVSlotBegin, this);
+ UVRequestEnd.init(*UVLoop, &cmWorkerPoolInternal::UVSlotEnd, this);
+ // Send begin request
+ UVRequestBegin.send();
+ // Run libuv loop
+ bool success = (uv_run(UVLoop.get(), UV_RUN_DEFAULT) == 0);
+ // Update state flags
+ Processing = false;
+ Aborting = false;
+ return success;
+}
+
+void cmWorkerPoolInternal::Abort()
+{
+ bool notifyThreads = false;
+ // Clear all jobs and set abort flag
+ {
+ std::lock_guard<std::mutex> guard(Mutex);
+ if (Processing && !Aborting) {
+ // Register abort and clear queue
+ Aborting = true;
+ Queue.clear();
+ notifyThreads = true;
+ }
+ }
+ if (notifyThreads) {
+ // Wake threads
+ Condition.notify_all();
+ }
+}
+
+inline bool cmWorkerPoolInternal::PushJob(cmWorkerPool::JobHandleT&& jobHandle)
+{
+ std::lock_guard<std::mutex> guard(Mutex);
+ if (Aborting) {
+ return false;
+ }
+ // Append the job to the queue
+ Queue.emplace_back(std::move(jobHandle));
+ // Notify an idle worker if there's one
+ if (WorkersIdle != 0) {
+ Condition.notify_one();
+ }
+ // Return success
+ return true;
+}
+
+void cmWorkerPoolInternal::UVSlotBegin(uv_async_t* handle)
+{
+ auto& gint = *reinterpret_cast<cmWorkerPoolInternal*>(handle->data);
+ // Create worker threads
+ {
+ unsigned int const num = gint.Pool->ThreadCount();
+ // Create workers
+ gint.Workers.reserve(num);
+ for (unsigned int ii = 0; ii != num; ++ii) {
+ gint.Workers.emplace_back(
+ cm::make_unique<cmWorkerPoolWorker>(*gint.UVLoop));
+ }
+ // Start worker threads
+ for (unsigned int ii = 0; ii != num; ++ii) {
+ gint.Workers[ii]->SetThread(
+ std::thread(&cmWorkerPoolInternal::Work, &gint, ii));
+ }
+ }
+ // Destroy begin request
+ gint.UVRequestBegin.reset();
+}
+
+void cmWorkerPoolInternal::UVSlotEnd(uv_async_t* handle)
+{
+ auto& gint = *reinterpret_cast<cmWorkerPoolInternal*>(handle->data);
+ // Join and destroy worker threads
+ gint.Workers.clear();
+ // Destroy end request
+ gint.UVRequestEnd.reset();
+}
+
+void cmWorkerPoolInternal::Work(unsigned int workerIndex)
+{
+ cmWorkerPool::JobHandleT jobHandle;
+ std::unique_lock<std::mutex> uLock(Mutex);
+ // Increment running workers count
+ ++WorkersRunning;
+ // Enter worker main loop
+ while (true) {
+ // Abort on request
+ if (Aborting) {
+ break;
+ }
+ // Wait for new jobs
+ if (Queue.empty()) {
+ ++WorkersIdle;
+ Condition.wait(uLock);
+ --WorkersIdle;
+ continue;
+ }
+
+ // Check for fence jobs
+ if (FenceProcessing || Queue.front()->IsFence()) {
+ if (JobsProcessing != 0) {
+ Condition.wait(uLock);
+ continue;
+ }
+ // No jobs get processed. Set the fence job processing flag.
+ FenceProcessing = true;
+ }
+
+ // Pop next job from queue
+ jobHandle = std::move(Queue.front());
+ Queue.pop_front();
+
+ // Unlocked scope for job processing
+ ++JobsProcessing;
+ {
+ uLock.unlock();
+ jobHandle->Work(Pool, workerIndex); // Process job
+ jobHandle.reset(); // Destroy job
+ uLock.lock();
+ }
+ --JobsProcessing;
+
+ // Was this a fence job?
+ if (FenceProcessing) {
+ FenceProcessing = false;
+ Condition.notify_all();
+ }
+ }
+
+ // Decrement running workers count
+ if (--WorkersRunning == 0) {
+ // Last worker thread about to finish. Send libuv event.
+ UVRequestEnd.send();
+ }
+}
+
+cmWorkerPool::JobT::~JobT() = default;
+
+bool cmWorkerPool::JobT::RunProcess(ProcessResultT& result,
+ std::vector<std::string> const& command,
+ std::string const& workingDirectory)
+{
+ // Get worker by index
+ auto* wrk = Pool_->Int_->Workers.at(WorkerIndex_).get();
+ return wrk->RunProcess(result, command, workingDirectory);
+}
+
+cmWorkerPool::cmWorkerPool()
+ : Int_(cm::make_unique<cmWorkerPoolInternal>(this))
+{
+}
+
+cmWorkerPool::~cmWorkerPool() = default;
+
+void cmWorkerPool::SetThreadCount(unsigned int threadCount)
+{
+ if (!Int_->Processing) {
+ ThreadCount_ = (threadCount > 0) ? threadCount : 1u;
+ }
+}
+
+bool cmWorkerPool::Process(void* userData)
+{
+ // Setup user data
+ UserData_ = userData;
+ // Run libuv loop
+ bool success = Int_->Process();
+ // Clear user data
+ UserData_ = nullptr;
+ // Return
+ return success;
+}
+
+bool cmWorkerPool::PushJob(JobHandleT&& jobHandle)
+{
+ return Int_->PushJob(std::move(jobHandle));
+}
+
+void cmWorkerPool::Abort()
+{
+ Int_->Abort();
+}
diff --git a/Source/cmWorkerPool.h b/Source/cmWorkerPool.h
new file mode 100644
index 000000000..91799223a
--- /dev/null
+++ b/Source/cmWorkerPool.h
@@ -0,0 +1,225 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmWorkerPool_h
+#define cmWorkerPool_h
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <cstdint>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include <cm/memory>
+
+// -- Types
+class cmWorkerPoolInternal;
+
+/** @class cmWorkerPool
+ * @brief Thread pool with job queue
+ */
+class cmWorkerPool
+{
+public:
+ /**
+ * Return value and output of an external process.
+ */
+ struct ProcessResultT
+ {
+ void reset();
+ bool error() const
+ {
+ return (ExitStatus != 0) || (TermSignal != 0) || !ErrorMessage.empty();
+ }
+
+ std::int64_t ExitStatus = 0;
+ int TermSignal = 0;
+ std::string StdOut;
+ std::string StdErr;
+ std::string ErrorMessage;
+ };
+
+ /**
+ * Abstract job class for concurrent job processing.
+ */
+ class JobT
+ {
+ public:
+ JobT(JobT const&) = delete;
+ JobT& operator=(JobT const&) = delete;
+
+ /**
+ * Virtual destructor.
+ */
+ virtual ~JobT();
+
+ /**
+ * Fence job flag
+ *
+ * Fence jobs require that:
+ * - all jobs before in the queue have been processed
+ * - no jobs later in the queue will be processed before this job was
+ * processed
+ */
+ bool IsFence() const { return Fence_; }
+
+ protected:
+ /**
+ * Protected default constructor
+ */
+ JobT(bool fence = false)
+ : Fence_(fence)
+ {
+ }
+
+ /**
+ * Abstract processing interface that must be implement in derived classes.
+ */
+ virtual void Process() = 0;
+
+ /**
+ * Get the worker pool.
+ * Only valid during the JobT::Process() call!
+ */
+ cmWorkerPool* Pool() const { return Pool_; }
+
+ /**
+ * Get the user data.
+ * Only valid during the JobT::Process() call!
+ */
+ void* UserData() const { return Pool_->UserData(); };
+
+ /**
+ * Get the worker index.
+ * This is the index of the thread processing this job and is in the range
+ * [0..ThreadCount).
+ * Concurrently processing jobs will never have the same WorkerIndex().
+ * Only valid during the JobT::Process() call!
+ */
+ unsigned int WorkerIndex() const { return WorkerIndex_; }
+
+ /**
+ * Run an external read only process.
+ * Use only during JobT::Process() call!
+ */
+ bool RunProcess(ProcessResultT& result,
+ std::vector<std::string> const& command,
+ std::string const& workingDirectory);
+
+ private:
+ //! Needs access to Work()
+ friend class cmWorkerPoolInternal;
+ //! Worker thread entry method.
+ void Work(cmWorkerPool* pool, unsigned int workerIndex)
+ {
+ Pool_ = pool;
+ WorkerIndex_ = workerIndex;
+ this->Process();
+ }
+
+ private:
+ cmWorkerPool* Pool_ = nullptr;
+ unsigned int WorkerIndex_ = 0;
+ bool Fence_ = false;
+ };
+
+ /**
+ * Job handle type
+ */
+ using JobHandleT = std::unique_ptr<JobT>;
+
+ /**
+ * Fence job base class
+ */
+ class JobFenceT : public JobT
+ {
+ public:
+ JobFenceT()
+ : JobT(true)
+ {
+ }
+ //! Does nothing
+ void Process() override{};
+ };
+
+ /**
+ * Fence job that aborts the worker pool.
+ *
+ * Useful as the last job in the job queue.
+ */
+ class JobEndT : JobFenceT
+ {
+ public:
+ //! Does nothing
+ void Process() override { Pool()->Abort(); }
+ };
+
+public:
+ // -- Methods
+ cmWorkerPool();
+ ~cmWorkerPool();
+
+ /**
+ * Number of worker threads.
+ */
+ unsigned int ThreadCount() const { return ThreadCount_; }
+
+ /**
+ * Set the number of worker threads.
+ *
+ * Calling this method during Process() has no effect.
+ */
+ void SetThreadCount(unsigned int threadCount);
+
+ /**
+ * Blocking function that starts threads to process all Jobs in the queue.
+ *
+ * This method blocks until a job calls the Abort() method.
+ * @arg threadCount Number of threads to process jobs.
+ * @arg userData Common user data pointer available in all Jobs.
+ */
+ bool Process(void* userData = nullptr);
+
+ /**
+ * User data reference passed to Process().
+ *
+ * Only valid during Process().
+ */
+ void* UserData() const { return UserData_; }
+
+ // -- Job processing interface
+
+ /**
+ * Clears the job queue and aborts all worker threads.
+ *
+ * This method is thread safe and can be called from inside a job.
+ */
+ void Abort();
+
+ /**
+ * Push job to the queue.
+ *
+ * This method is thread safe and can be called from inside a job or before
+ * Process().
+ */
+ bool PushJob(JobHandleT&& jobHandle);
+
+ /**
+ * Push job to the queue
+ *
+ * This method is thread safe and can be called from inside a job or before
+ * Process().
+ */
+ template <class T, typename... Args>
+ bool EmplaceJob(Args&&... args)
+ {
+ return PushJob(cm::make_unique<T>(std::forward<Args>(args)...));
+ }
+
+private:
+ void* UserData_ = nullptr;
+ unsigned int ThreadCount_ = 1;
+ std::unique_ptr<cmWorkerPoolInternal> Int_;
+};
+
+#endif
diff --git a/Source/cmWorkingDirectory.cxx b/Source/cmWorkingDirectory.cxx
index 99c9ba86a..5700b1cc7 100644
--- a/Source/cmWorkingDirectory.cxx
+++ b/Source/cmWorkingDirectory.cxx
@@ -2,12 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmWorkingDirectory.h"
+#include <cerrno>
+
#include "cmSystemTools.h"
cmWorkingDirectory::cmWorkingDirectory(std::string const& newdir)
{
this->OldDir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(newdir);
+ this->SetDirectory(newdir);
}
cmWorkingDirectory::~cmWorkingDirectory()
@@ -15,10 +17,20 @@ cmWorkingDirectory::~cmWorkingDirectory()
this->Pop();
}
+bool cmWorkingDirectory::SetDirectory(std::string const& newdir)
+{
+ if (cmSystemTools::ChangeDirectory(newdir) == 0) {
+ this->ResultCode = 0;
+ return true;
+ }
+ this->ResultCode = errno;
+ return false;
+}
+
void cmWorkingDirectory::Pop()
{
if (!this->OldDir.empty()) {
- cmSystemTools::ChangeDirectory(this->OldDir);
+ this->SetDirectory(this->OldDir);
this->OldDir.clear();
}
}
diff --git a/Source/cmWorkingDirectory.h b/Source/cmWorkingDirectory.h
index aff926755..d4a164de6 100644
--- a/Source/cmWorkingDirectory.h
+++ b/Source/cmWorkingDirectory.h
@@ -9,6 +9,12 @@
/** \class cmWorkingDirectory
* \brief An RAII class to manipulate the working directory.
+ *
+ * The current working directory is set to the location given to the
+ * constructor. The working directory can be changed again as needed
+ * by calling SetDirectory(). When the object is destroyed, the destructor
+ * will restore the working directory to what it was when the object was
+ * created, regardless of any calls to SetDirectory() in the meantime.
*/
class cmWorkingDirectory
{
@@ -16,10 +22,24 @@ public:
cmWorkingDirectory(std::string const& newdir);
~cmWorkingDirectory();
+ cmWorkingDirectory(const cmWorkingDirectory&) = delete;
+ cmWorkingDirectory& operator=(const cmWorkingDirectory&) = delete;
+
+ bool SetDirectory(std::string const& newdir);
void Pop();
+ bool Failed() const { return ResultCode != 0; }
+
+ /** \return 0 if the last attempt to set the working directory was
+ * successful. If it failed, the value returned will be the
+ * \c errno value associated with the failure. A description
+ * of the error code can be obtained by passing the result
+ * to \c std::strerror().
+ */
+ int GetLastResult() const { return ResultCode; }
private:
std::string OldDir;
+ int ResultCode;
};
#endif
diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx
index fc5fd2111..34e21b2f2 100644
--- a/Source/cmWriteFileCommand.cxx
+++ b/Source/cmWriteFileCommand.cxx
@@ -4,22 +4,23 @@
#include "cmsys/FStream.hxx"
-#include "cmMakefile.h"
-#include "cmSystemTools.h"
#include "cm_sys_stat.h"
-class cmExecutionStatus;
+#include "cmExecutionStatus.h"
+#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
// cmLibraryCommand
-bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmWriteFileCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
std::string message;
- std::vector<std::string>::const_iterator i = args.begin();
+ auto i = args.begin();
std::string const& fileName = *i;
bool overwrite = true;
@@ -33,43 +34,47 @@ bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& args,
}
}
- if (!this->Makefile->CanIWriteThisFile(fileName.c_str())) {
+ if (!status.GetMakefile().CanIWriteThisFile(fileName)) {
std::string e =
"attempted to write a file: " + fileName + " into a source directory.";
- this->SetError(e);
+ status.SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
std::string dir = cmSystemTools::GetFilenamePath(fileName);
- cmSystemTools::MakeDirectory(dir.c_str());
+ cmSystemTools::MakeDirectory(dir);
mode_t mode = 0;
+ bool writable = false;
// Set permissions to writable
if (cmSystemTools::GetPermissions(fileName.c_str(), mode)) {
- cmSystemTools::SetPermissions(fileName.c_str(),
#if defined(_MSC_VER) || defined(__MINGW32__)
- mode | S_IWRITE
+ writable = (mode & S_IWRITE) != 0;
+ mode_t newMode = mode | S_IWRITE;
#else
- mode | S_IWUSR | S_IWGRP
+ writable = mode & S_IWUSR;
+ mode_t newMode = mode | S_IWUSR | S_IWGRP;
#endif
- );
+ if (!writable) {
+ cmSystemTools::SetPermissions(fileName.c_str(), newMode);
+ }
}
// If GetPermissions fails, pretend like it is ok. File open will fail if
// the file is not writable
cmsys::ofstream file(fileName.c_str(),
overwrite ? std::ios::out : std::ios::app);
if (!file) {
- std::string error = "Internal CMake error when trying to open file: ";
- error += fileName;
- error += " for writing.";
- this->SetError(error);
+ std::string error =
+ cmStrCat("Internal CMake error when trying to open file: ", fileName,
+ " for writing.");
+ status.SetError(error);
return false;
}
file << message << std::endl;
file.close();
- if (mode) {
+ if (mode && !writable) {
cmSystemTools::SetPermissions(fileName.c_str(), mode);
}
diff --git a/Source/cmWriteFileCommand.h b/Source/cmWriteFileCommand.h
index 19922cdf3..3e0e04376 100644
--- a/Source/cmWriteFileCommand.h
+++ b/Source/cmWriteFileCommand.h
@@ -3,33 +3,18 @@
#ifndef cmWriteFileCommand_h
#define cmWriteFileCommand_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmWriteFileCommand
+/**
* \brief Writes a message to a file
*
*/
-class cmWriteFileCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- cmCommand* Clone() CM_OVERRIDE { return new cmWriteFileCommand; }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) CM_OVERRIDE;
-};
+bool cmWriteFileCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmXCode21Object.cxx b/Source/cmXCode21Object.cxx
index 719e62765..a9bb2ef54 100644
--- a/Source/cmXCode21Object.cxx
+++ b/Source/cmXCode21Object.cxx
@@ -34,9 +34,7 @@ void cmXCode21Object::PrintList(std::vector<cmXCodeObject*> const& v,
std::ostream& out, PBXType t)
{
bool hasOne = false;
- for (std::vector<cmXCodeObject*>::const_iterator i = v.begin(); i != v.end();
- ++i) {
- cmXCodeObject* obj = *i;
+ for (auto obj : v) {
if (obj->GetType() == OBJECT && obj->GetIsA() == t) {
hasOne = true;
break;
@@ -46,9 +44,7 @@ void cmXCode21Object::PrintList(std::vector<cmXCodeObject*> const& v,
return;
}
out << "\n/* Begin " << PBXTypeNames[t] << " section */\n";
- for (std::vector<cmXCodeObject*>::const_iterator i = v.begin(); i != v.end();
- ++i) {
- cmXCodeObject* obj = *i;
+ for (auto obj : v) {
if (obj->GetType() == OBJECT && obj->GetIsA() == t) {
obj->Print(out);
}
diff --git a/Source/cmXCode21Object.h b/Source/cmXCode21Object.h
index bcd8d93e1..8e4b80fc1 100644
--- a/Source/cmXCode21Object.h
+++ b/Source/cmXCode21Object.h
@@ -14,7 +14,7 @@ class cmXCode21Object : public cmXCodeObject
{
public:
cmXCode21Object(PBXType ptype, Type type);
- virtual void PrintComment(std::ostream&);
+ void PrintComment(std::ostream&) override;
static void PrintList(std::vector<cmXCodeObject*> const&, std::ostream& out,
PBXType t);
static void PrintList(std::vector<cmXCodeObject*> const&, std::ostream& out);
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx
index 0def8c321..b301ab121 100644
--- a/Source/cmXCodeObject.cxx
+++ b/Source/cmXCodeObject.cxx
@@ -2,9 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmXCodeObject.h"
-#include <CoreFoundation/CoreFoundation.h>
#include <ostream>
+#include <CoreFoundation/CoreFoundation.h>
+
#include "cmSystemTools.h"
const char* cmXCodeObject::PBXTypeNames[] = {
@@ -42,8 +43,8 @@ cmXCodeObject::~cmXCodeObject()
cmXCodeObject::cmXCodeObject(PBXType ptype, Type type)
{
this->Version = 15;
- this->Target = 0;
- this->Object = 0;
+ this->Target = nullptr;
+ this->Object = nullptr;
this->IsA = ptype;
@@ -71,7 +72,7 @@ cmXCodeObject::cmXCodeObject(PBXType ptype, Type type)
this->TypeValue = type;
if (this->TypeValue == OBJECT) {
- this->AddAttribute("isa", 0);
+ this->AddAttribute("isa", nullptr);
}
}
@@ -86,7 +87,7 @@ bool cmXCodeObject::IsEmpty() const
return this->ObjectAttributes.empty();
case OBJECT_REF:
case OBJECT:
- return this->Object == 0;
+ return this->Object == nullptr;
}
return true; // unreachable, but quiets warnings
}
@@ -115,23 +116,23 @@ void cmXCodeObject::Print(std::ostream& out)
if (separator == "\n") {
out << separator;
}
- std::map<std::string, cmXCodeObject*>::iterator i;
cmXCodeObject::Indent(3 * indentFactor, out);
out << "isa = " << PBXTypeNames[this->IsA] << ";" << separator;
- for (i = this->ObjectAttributes.begin(); i != this->ObjectAttributes.end();
- ++i) {
- if (i->first == "isa")
+ for (const auto& keyVal : this->ObjectAttributes) {
+ if (keyVal.first == "isa") {
continue;
+ }
- PrintAttribute(out, 3, separator, indentFactor, i->first, i->second, this);
+ PrintAttribute(out, 3, separator, indentFactor, keyVal.first,
+ keyVal.second, this);
}
cmXCodeObject::Indent(2 * indentFactor, out);
out << "};\n";
}
-void cmXCodeObject::PrintAttribute(std::ostream& out, const int level,
- const std::string separator,
- const int factor, const std::string& name,
+void cmXCodeObject::PrintAttribute(std::ostream& out, int level,
+ const std::string& separator, int factor,
+ const std::string& name,
const cmXCodeObject* object,
const cmXCodeObject* parent)
{
@@ -166,11 +167,9 @@ void cmXCodeObject::PrintAttribute(std::ostream& out, const int level,
if (separator == "\n") {
out << separator;
}
- std::map<std::string, cmXCodeObject*>::const_iterator i;
- for (i = object->ObjectAttributes.begin();
- i != object->ObjectAttributes.end(); ++i) {
- PrintAttribute(out, (level + 1) * factor, separator, factor, i->first,
- i->second, object);
+ for (const auto& keyVal : object->ObjectAttributes) {
+ PrintAttribute(out, (level + 1) * factor, separator, factor,
+ keyVal.first, keyVal.second, object);
}
cmXCodeObject::Indent(level * factor, out);
out << "};" << separator;
@@ -203,9 +202,9 @@ void cmXCodeObject::PrintList(std::vector<cmXCodeObject*> const& objs,
{
cmXCodeObject::Indent(1, out);
out << "objects = {\n";
- for (unsigned int i = 0; i < objs.size(); ++i) {
- if (objs[i]->TypeValue == OBJECT) {
- objs[i]->Print(out);
+ for (auto obj : objs) {
+ if (obj->TypeValue == OBJECT) {
+ obj->Print(out);
}
}
cmXCodeObject::Indent(1, out);
@@ -220,7 +219,7 @@ void cmXCodeObject::CopyAttributes(cmXCodeObject* copy)
this->Object = copy->Object;
}
-void cmXCodeObject::PrintString(std::ostream& os, std::string String)
+void cmXCodeObject::PrintString(std::ostream& os, const std::string& String)
{
// The string needs to be quoted if it contains any characters
// considered special by the Xcode project file parser.
@@ -233,13 +232,12 @@ void cmXCodeObject::PrintString(std::ostream& os, std::string String)
// Print the string, quoted and escaped as necessary.
os << quote;
- for (std::string::const_iterator i = String.begin(); i != String.end();
- ++i) {
- if (*i == '"' || *i == '\\') {
+ for (auto c : String) {
+ if (c == '"' || c == '\\') {
// Escape double-quotes and backslashes.
os << '\\';
}
- os << *i;
+ os << c;
}
os << quote;
}
diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h
index b92e6e33e..d9be3d2db 100644
--- a/Source/cmXCodeObject.h
+++ b/Source/cmXCodeObject.h
@@ -12,6 +12,8 @@
#include <utility>
#include <vector>
+#include "cmAlgorithms.h"
+
class cmGeneratorTarget;
class cmXCodeObject
@@ -80,22 +82,17 @@ public:
void SetObject(cmXCodeObject* value) { this->Object = value; }
cmXCodeObject* GetObject() { return this->Object; }
void AddObject(cmXCodeObject* value) { this->List.push_back(value); }
- bool HasObject(cmXCodeObject* o) const
- {
- return !(std::find(this->List.begin(), this->List.end(), o) ==
- this->List.end());
- }
+ bool HasObject(cmXCodeObject* o) const { return cmContains(this->List, o); }
void AddUniqueObject(cmXCodeObject* value)
{
- if (std::find(this->List.begin(), this->List.end(), value) ==
- this->List.end()) {
+ if (!cmContains(this->List, value)) {
this->List.push_back(value);
}
}
static void Indent(int level, std::ostream& out);
void Print(std::ostream& out);
- void PrintAttribute(std::ostream& out, const int level,
- const std::string separator, const int factor,
+ void PrintAttribute(std::ostream& out, int level,
+ const std::string& separator, int factor,
const std::string& name, const cmXCodeObject* object,
const cmXCodeObject* parent);
virtual void PrintComment(std::ostream&) {}
@@ -109,24 +106,21 @@ public:
bool HasComment() const { return (!this->Comment.empty()); }
cmXCodeObject* GetObject(const char* name) const
{
- std::map<std::string, cmXCodeObject*>::const_iterator i =
- this->ObjectAttributes.find(name);
+ auto const i = this->ObjectAttributes.find(name);
if (i != this->ObjectAttributes.end()) {
return i->second;
}
- return 0;
+ return nullptr;
}
// search the attribute list for an object of the specified type
cmXCodeObject* GetObject(cmXCodeObject::PBXType t) const
{
- for (std::vector<cmXCodeObject*>::const_iterator i = this->List.begin();
- i != this->List.end(); ++i) {
- cmXCodeObject* o = *i;
+ for (auto o : this->List) {
if (o->IsA == t) {
return o;
}
}
- return 0;
+ return nullptr;
}
void CopyAttributes(cmXCodeObject*);
@@ -152,7 +146,7 @@ public:
return this->List;
}
void SetComment(const std::string& c) { this->Comment = c; }
- static void PrintString(std::ostream& os, std::string String);
+ static void PrintString(std::ostream& os, const std::string& String);
protected:
void PrintString(std::ostream& os) const;
diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx
index 5c22531d4..afc95f56c 100644
--- a/Source/cmXCodeScheme.cxx
+++ b/Source/cmXCodeScheme.cxx
@@ -5,18 +5,18 @@
#include <iomanip>
#include <iostream>
#include <sstream>
+#include <utility>
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmXMLSafe.h"
-cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj,
+cmXCodeScheme::cmXCodeScheme(cmXCodeObject* xcObj, TestObjects tests,
const std::vector<std::string>& configList,
unsigned int xcVersion)
: Target(xcObj)
+ , Tests(std::move(tests))
, TargetName(xcObj->GetTarget()->GetName())
- , BuildableName(xcObj->GetTarget()->GetFullName())
- , TargetId(xcObj->GetId())
, ConfigList(configList)
, XcodeVersion(xcVersion)
{
@@ -27,16 +27,13 @@ void cmXCodeScheme::WriteXCodeSharedScheme(const std::string& xcProjDir,
{
// Create shared scheme sub-directory tree
//
- std::string xcodeSchemeDir = xcProjDir;
- xcodeSchemeDir += "/xcshareddata/xcschemes";
+ std::string xcodeSchemeDir = cmStrCat(xcProjDir, "/xcshareddata/xcschemes");
cmSystemTools::MakeDirectory(xcodeSchemeDir.c_str());
- std::string xcodeSchemeFile = xcodeSchemeDir;
- xcodeSchemeFile += "/";
- xcodeSchemeFile += this->TargetName;
- xcodeSchemeFile += ".xcscheme";
+ std::string xcodeSchemeFile =
+ cmStrCat(xcodeSchemeDir, '/', this->TargetName, ".xcscheme");
- cmGeneratedFileStream fout(xcodeSchemeFile.c_str());
+ cmGeneratedFileStream fout(xcodeSchemeFile);
fout.SetCopyIfDifferent(true);
if (!fout) {
return;
@@ -58,7 +55,7 @@ void cmXCodeScheme::WriteXCodeXCScheme(std::ostream& fout,
xout.Attribute("version", "1.3");
WriteBuildAction(xout, container);
- WriteTestAction(xout, FindConfiguration("Debug"));
+ WriteTestAction(xout, FindConfiguration("Debug"), container);
WriteLaunchAction(xout, FindConfiguration("Debug"), container);
WriteProfileAction(xout, FindConfiguration("Release"));
WriteAnalyzeAction(xout, FindConfiguration("Debug"));
@@ -84,14 +81,7 @@ void cmXCodeScheme::WriteBuildAction(cmXMLWriter& xout,
xout.Attribute("buildForArchiving", "YES");
xout.Attribute("buildForAnalyzing", "YES");
- xout.StartElement("BuildableReference");
- xout.BreakAttributes();
- xout.Attribute("BuildableIdentifier", "primary");
- xout.Attribute("BlueprintIdentifier", this->TargetId);
- xout.Attribute("BuildableName", this->BuildableName);
- xout.Attribute("BlueprintName", this->TargetName);
- xout.Attribute("ReferencedContainer", "container:" + container);
- xout.EndElement();
+ WriteBuildableReference(xout, this->Target, container);
xout.EndElement(); // BuildActionEntry
xout.EndElement(); // BuildActionEntries
@@ -99,7 +89,8 @@ void cmXCodeScheme::WriteBuildAction(cmXMLWriter& xout,
}
void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout,
- std::string configuration)
+ const std::string& configuration,
+ const std::string& container)
{
xout.StartElement("TestAction");
xout.BreakAttributes();
@@ -111,8 +102,21 @@ void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout,
xout.Attribute("shouldUseLaunchSchemeArgsEnv", "YES");
xout.StartElement("Testables");
+ for (auto test : this->Tests) {
+ xout.StartElement("TestableReference");
+ xout.BreakAttributes();
+ xout.Attribute("skipped", "NO");
+ WriteBuildableReference(xout, test, container);
+ xout.EndElement(); // TestableReference
+ }
xout.EndElement();
+ if (IsTestable()) {
+ xout.StartElement("MacroExpansion");
+ WriteBuildableReference(xout, this->Target, container);
+ xout.EndElement(); // MacroExpansion
+ }
+
xout.StartElement("AdditionalOptions");
xout.EndElement();
@@ -120,7 +124,7 @@ void cmXCodeScheme::WriteTestAction(cmXMLWriter& xout,
}
void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout,
- std::string configuration,
+ const std::string& configuration,
const std::string& container)
{
xout.StartElement("LaunchAction");
@@ -133,10 +137,52 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout,
xout.Attribute("launchStyle", "0");
xout.Attribute("useCustomWorkingDirectory", "NO");
xout.Attribute("ignoresPersistentStateOnLaunch", "NO");
- xout.Attribute("debugDocumentVersioning", "YES");
+ WriteLaunchActionBooleanAttribute(xout, "debugDocumentVersioning",
+ "XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING",
+ true);
xout.Attribute("debugServiceExtension", "internal");
xout.Attribute("allowLocationSimulation", "YES");
+ // Diagnostics tab begin
+
+ bool useAddressSanitizer = WriteLaunchActionAttribute(
+ xout, "enableAddressSanitizer",
+ "XCODE_SCHEME_ADDRESS_SANITIZER"); // not allowed with
+ // enableThreadSanitizer=YES
+ WriteLaunchActionAttribute(
+ xout, "enableASanStackUseAfterReturn",
+ "XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN");
+
+ bool useThreadSanitizer = false;
+ if (!useAddressSanitizer) {
+ useThreadSanitizer = WriteLaunchActionAttribute(
+ xout, "enableThreadSanitizer",
+ "XCODE_SCHEME_THREAD_SANITIZER"); // not allowed with
+ // enableAddressSanitizer=YES
+ }
+
+ WriteLaunchActionAttribute(xout, "stopOnEveryThreadSanitizerIssue",
+ "XCODE_SCHEME_THREAD_SANITIZER_STOP");
+
+ WriteLaunchActionAttribute(xout, "enableUBSanitizer",
+ "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER");
+ WriteLaunchActionAttribute(
+ xout, "stopOnEveryUBSanitizerIssue",
+ "XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER_STOP");
+
+ WriteLaunchActionAttribute(
+ xout, "disableMainThreadChecker",
+ "XCODE_SCHEME_DISABLE_MAIN_THREAD_CHECKER"); // negative enabled!
+ WriteLaunchActionAttribute(xout, "stopOnEveryMainThreadCheckerIssue",
+ "XCODE_SCHEME_MAIN_THREAD_CHECKER_STOP");
+
+ if (this->Target->GetTarget()->GetPropertyAsBool(
+ "XCODE_SCHEME_DEBUG_AS_ROOT")) {
+ xout.Attribute("debugAsWhichUser", "root");
+ }
+
+ // Diagnostics tab end
+
if (IsExecutable(this->Target)) {
xout.StartElement("BuildableProductRunnable");
xout.BreakAttributes();
@@ -146,25 +192,163 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout,
xout.StartElement("MacroExpansion");
}
- xout.StartElement("BuildableReference");
- xout.BreakAttributes();
- xout.Attribute("BuildableIdentifier", "primary");
- xout.Attribute("BlueprintIdentifier", this->TargetId);
- xout.Attribute("BuildableName", this->BuildableName);
- xout.Attribute("BlueprintName", this->TargetName);
- xout.Attribute("ReferencedContainer", "container:" + container);
- xout.EndElement();
+ WriteBuildableReference(xout, this->Target, container);
xout.EndElement(); // MacroExpansion
+ // Info tab begin
+
+ if (const char* exe =
+ this->Target->GetTarget()->GetProperty("XCODE_SCHEME_EXECUTABLE")) {
+
+ xout.StartElement("PathRunnable");
+ xout.BreakAttributes();
+
+ xout.Attribute("runnableDebuggingMode", "0");
+ xout.Attribute("FilePath", exe);
+
+ xout.EndElement(); // PathRunnable
+ }
+
+ // Info tab end
+
+ // Arguments tab begin
+
+ if (const char* argList =
+ this->Target->GetTarget()->GetProperty("XCODE_SCHEME_ARGUMENTS")) {
+ std::vector<std::string> arguments = cmExpandedList(argList);
+ if (!arguments.empty()) {
+ xout.StartElement("CommandLineArguments");
+
+ for (auto const& argument : arguments) {
+ xout.StartElement("CommandLineArgument");
+ xout.BreakAttributes();
+
+ xout.Attribute("argument", argument);
+ xout.Attribute("isEnabled", "YES");
+
+ xout.EndElement(); // CommandLineArgument
+ }
+
+ xout.EndElement(); // CommandLineArguments
+ }
+ }
+
+ if (const char* envList =
+ this->Target->GetTarget()->GetProperty("XCODE_SCHEME_ENVIRONMENT")) {
+ std::vector<std::string> envs = cmExpandedList(envList);
+ if (!envs.empty()) {
+ xout.StartElement("EnvironmentVariables");
+
+ for (auto env : envs) {
+
+ xout.StartElement("EnvironmentVariable");
+ xout.BreakAttributes();
+
+ std::string envValue;
+ const auto p = env.find_first_of('=');
+ if (p != std::string::npos) {
+ envValue = env.substr(p + 1);
+ env.resize(p);
+ }
+
+ xout.Attribute("key", env);
+ xout.Attribute("value", envValue);
+ xout.Attribute("isEnabled", "YES");
+
+ xout.EndElement(); // EnvironmentVariable
+ }
+
+ xout.EndElement(); // EnvironmentVariables
+ }
+ }
+
+ // Arguments tab end
+
xout.StartElement("AdditionalOptions");
+
+ if (!useThreadSanitizer) {
+ WriteLaunchActionAdditionalOption(xout, "MallocScribble", "",
+ "XCODE_SCHEME_MALLOC_SCRIBBLE");
+ }
+
+ if (!useThreadSanitizer && !useAddressSanitizer) {
+ WriteLaunchActionAdditionalOption(xout, "MallocGuardEdges", "",
+ "XCODE_SCHEME_MALLOC_GUARD_EDGES");
+ }
+
+ if (!useThreadSanitizer && !useAddressSanitizer) {
+ WriteLaunchActionAdditionalOption(xout, "DYLD_INSERT_LIBRARIES",
+ "/usr/lib/libgmalloc.dylib",
+ "XCODE_SCHEME_GUARD_MALLOC");
+ }
+
+ WriteLaunchActionAdditionalOption(xout, "NSZombieEnabled", "YES",
+ "XCODE_SCHEME_ZOMBIE_OBJECTS");
+
+ if (!useThreadSanitizer && !useAddressSanitizer) {
+ WriteLaunchActionAdditionalOption(xout, "MallocStackLogging", "",
+ "XCODE_SCHEME_MALLOC_STACK");
+ }
+
+ WriteLaunchActionAdditionalOption(xout, "DYLD_PRINT_APIS", "",
+ "XCODE_SCHEME_DYNAMIC_LINKER_API_USAGE");
+
+ WriteLaunchActionAdditionalOption(xout, "DYLD_PRINT_LIBRARIES", "",
+ "XCODE_SCHEME_DYNAMIC_LIBRARY_LOADS");
+
xout.EndElement();
xout.EndElement(); // LaunchAction
}
+bool cmXCodeScheme::WriteLaunchActionAttribute(cmXMLWriter& xout,
+ const std::string& attrName,
+ const std::string& varName)
+{
+ if (Target->GetTarget()->GetPropertyAsBool(varName)) {
+ xout.Attribute(attrName.c_str(), "YES");
+ return true;
+ }
+ return false;
+}
+
+bool cmXCodeScheme::WriteLaunchActionBooleanAttribute(
+ cmXMLWriter& xout, const std::string& attrName, const std::string& varName,
+ bool defaultValue)
+{
+ auto property = Target->GetTarget()->GetProperty(varName);
+ bool isOn = (property == nullptr && defaultValue) || cmIsOn(property);
+
+ if (isOn) {
+ xout.Attribute(attrName.c_str(), "YES");
+ } else {
+ xout.Attribute(attrName.c_str(), "NO");
+ }
+ return isOn;
+}
+
+bool cmXCodeScheme::WriteLaunchActionAdditionalOption(
+ cmXMLWriter& xout, const std::string& key, const std::string& value,
+ const std::string& varName)
+{
+ if (Target->GetTarget()->GetPropertyAsBool(varName)) {
+ xout.StartElement("AdditionalOption");
+ xout.BreakAttributes();
+
+ xout.Attribute("key", key);
+ xout.Attribute("value", value);
+ xout.Attribute("isEnabled", "YES");
+
+ xout.EndElement(); // AdditionalOption
+
+ return true;
+ }
+ return false;
+}
+
void cmXCodeScheme::WriteProfileAction(cmXMLWriter& xout,
- std::string configuration)
+ const std::string& configuration)
{
xout.StartElement("ProfileAction");
xout.BreakAttributes();
@@ -172,12 +356,14 @@ void cmXCodeScheme::WriteProfileAction(cmXMLWriter& xout,
xout.Attribute("shouldUseLaunchSchemeArgsEnv", "YES");
xout.Attribute("savedToolIdentifier", "");
xout.Attribute("useCustomWorkingDirectory", "NO");
- xout.Attribute("debugDocumentVersioning", "YES");
+ WriteLaunchActionBooleanAttribute(xout, "debugDocumentVersioning",
+ "XCODE_SCHEME_DEBUG_DOCUMENT_VERSIONING",
+ true);
xout.EndElement();
}
void cmXCodeScheme::WriteAnalyzeAction(cmXMLWriter& xout,
- std::string configuration)
+ const std::string& configuration)
{
xout.StartElement("AnalyzeAction");
xout.BreakAttributes();
@@ -186,7 +372,7 @@ void cmXCodeScheme::WriteAnalyzeAction(cmXMLWriter& xout,
}
void cmXCodeScheme::WriteArchiveAction(cmXMLWriter& xout,
- std::string configuration)
+ const std::string& configuration)
{
xout.StartElement("ArchiveAction");
xout.BreakAttributes();
@@ -195,6 +381,20 @@ void cmXCodeScheme::WriteArchiveAction(cmXMLWriter& xout,
xout.EndElement();
}
+void cmXCodeScheme::WriteBuildableReference(cmXMLWriter& xout,
+ const cmXCodeObject* xcObj,
+ const std::string& container)
+{
+ xout.StartElement("BuildableReference");
+ xout.BreakAttributes();
+ xout.Attribute("BuildableIdentifier", "primary");
+ xout.Attribute("BlueprintIdentifier", xcObj->GetId());
+ xout.Attribute("BuildableName", xcObj->GetTarget()->GetFullName());
+ xout.Attribute("BlueprintName", xcObj->GetTarget()->GetName());
+ xout.Attribute("ReferencedContainer", "container:" + container);
+ xout.EndElement();
+}
+
std::string cmXCodeScheme::WriteVersionString()
{
std::ostringstream v;
@@ -207,14 +407,18 @@ std::string cmXCodeScheme::FindConfiguration(const std::string& name)
// Try to find the desired configuration by name,
// and if it's not found return first from the list
//
- if (std::find(this->ConfigList.begin(), this->ConfigList.end(), name) ==
- this->ConfigList.end() &&
- this->ConfigList.size() > 0)
+ if (!cmContains(this->ConfigList, name) && !this->ConfigList.empty()) {
return this->ConfigList[0];
+ }
return name;
}
+bool cmXCodeScheme::IsTestable() const
+{
+ return !this->Tests.empty() || IsExecutable(this->Target);
+}
+
bool cmXCodeScheme::IsExecutable(const cmXCodeObject* target)
{
cmGeneratorTarget* gt = target->GetTarget();
diff --git a/Source/cmXCodeScheme.h b/Source/cmXCodeScheme.h
index 379afed42..dff5e35e3 100644
--- a/Source/cmXCodeScheme.h
+++ b/Source/cmXCodeScheme.h
@@ -5,6 +5,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <vector>
+
#include "cmGlobalXCodeGenerator.h"
#include "cmSystemTools.h"
#include "cmXCodeObject.h"
@@ -16,7 +18,9 @@
class cmXCodeScheme
{
public:
- cmXCodeScheme(cmXCodeObject* xcObj,
+ using TestObjects = std::vector<const cmXCodeObject*>;
+
+ cmXCodeScheme(cmXCodeObject* xcObj, TestObjects tests,
const std::vector<std::string>& configList,
unsigned int xcVersion);
@@ -25,25 +29,45 @@ public:
private:
const cmXCodeObject* const Target;
+ const TestObjects Tests;
const std::string& TargetName;
- const std::string BuildableName;
- const std::string& TargetId;
const std::vector<std::string>& ConfigList;
const unsigned int XcodeVersion;
void WriteXCodeXCScheme(std::ostream& fout, const std::string& container);
void WriteBuildAction(cmXMLWriter& xout, const std::string& container);
- void WriteTestAction(cmXMLWriter& xout, std::string configuration);
- void WriteLaunchAction(cmXMLWriter& xout, std::string configuration,
+ void WriteTestAction(cmXMLWriter& xout, const std::string& configuration,
+ const std::string& container);
+ void WriteLaunchAction(cmXMLWriter& xout, const std::string& configuration,
const std::string& container);
- void WriteProfileAction(cmXMLWriter& xout, std::string configuration);
- void WriteAnalyzeAction(cmXMLWriter& xout, std::string configuration);
- void WriteArchiveAction(cmXMLWriter& xout, std::string configuration);
+
+ bool WriteLaunchActionAttribute(cmXMLWriter& xout,
+ const std::string& attrName,
+ const std::string& varName);
+
+ bool WriteLaunchActionBooleanAttribute(cmXMLWriter& xout,
+ const std::string& attrName,
+ const std::string& varName,
+ bool defaultValue);
+
+ bool WriteLaunchActionAdditionalOption(cmXMLWriter& xout,
+ const std::string& attrName,
+ const std::string& value,
+ const std::string& varName);
+
+ void WriteProfileAction(cmXMLWriter& xout, const std::string& configuration);
+ void WriteAnalyzeAction(cmXMLWriter& xout, const std::string& configuration);
+ void WriteArchiveAction(cmXMLWriter& xout, const std::string& configuration);
+
+ void WriteBuildableReference(cmXMLWriter& xout, const cmXCodeObject* xcObj,
+ const std::string& container);
std::string WriteVersionString();
std::string FindConfiguration(const std::string& name);
+ bool IsTestable() const;
+
static bool IsExecutable(const cmXCodeObject* target);
};
diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx
index 18afbf370..ad5c4ba28 100644
--- a/Source/cmXMLParser.cxx
+++ b/Source/cmXMLParser.cxx
@@ -2,19 +2,21 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmXMLParser.h"
-#include "cm_expat.h"
-#include "cmsys/FStream.hxx"
-#include <ctype.h>
+#include <cctype>
+#include <cstring>
#include <iostream>
#include <sstream>
-#include <string.h>
+
+#include "cmsys/FStream.hxx"
+
+#include "cm_expat.h"
cmXMLParser::cmXMLParser()
{
- this->Parser = CM_NULLPTR;
+ this->Parser = nullptr;
this->ParseError = 0;
- this->ReportCallback = CM_NULLPTR;
- this->ReportCallbackData = CM_NULLPTR;
+ this->ReportCallback = nullptr;
+ this->ReportCallbackData = nullptr;
}
cmXMLParser::~cmXMLParser()
@@ -26,7 +28,7 @@ cmXMLParser::~cmXMLParser()
int cmXMLParser::Parse(const char* string)
{
- return (int)this->InitializeParser() &&
+ return this->InitializeParser() &&
this->ParseChunk(string, strlen(string)) && this->CleanupParser();
}
@@ -55,7 +57,7 @@ int cmXMLParser::InitializeParser()
}
// Create the expat XML parser.
- this->Parser = XML_ParserCreate(CM_NULLPTR);
+ this->Parser = XML_ParserCreate(nullptr);
XML_SetElementHandler(static_cast<XML_Parser>(this->Parser),
&cmXMLParserStartElement, &cmXMLParserEndElement);
XML_SetCharacterDataHandler(static_cast<XML_Parser>(this->Parser),
@@ -99,7 +101,7 @@ int cmXMLParser::CleanupParser()
// Clean up the parser.
XML_ParserFree(static_cast<XML_Parser>(this->Parser));
- this->Parser = CM_NULLPTR;
+ this->Parser = nullptr;
return result;
}
@@ -156,7 +158,7 @@ const char* cmXMLParser::FindAttribute(const char** atts,
}
}
}
- return CM_NULLPTR;
+ return nullptr;
}
void cmXMLParserStartElement(void* parser, const char* name, const char** atts)
@@ -186,8 +188,8 @@ void cmXMLParserCharacterDataHandler(void* parser, const char* data,
void cmXMLParser::ReportXmlParseError()
{
XML_Parser parser = static_cast<XML_Parser>(this->Parser);
- this->ReportError(XML_GetCurrentLineNumber(parser),
- XML_GetCurrentColumnNumber(parser),
+ this->ReportError(static_cast<int>(XML_GetCurrentLineNumber(parser)),
+ static_cast<int>(XML_GetCurrentColumnNumber(parser)),
XML_ErrorString(XML_GetErrorCode(parser)));
}
diff --git a/Source/cmXMLParser.h b/Source/cmXMLParser.h
index 98ba04956..1bc8d6469 100644
--- a/Source/cmXMLParser.h
+++ b/Source/cmXMLParser.h
@@ -42,7 +42,7 @@ public:
virtual int ParseChunk(const char* inputString,
std::string::size_type length);
virtual int CleanupParser();
- typedef void (*ReportFunction)(int, const char*, void*);
+ using ReportFunction = void (*)(int, const char*, void*);
void SetErrorCallback(ReportFunction f, void* d)
{
this->ReportCallback = f;
diff --git a/Source/cmXMLSafe.cxx b/Source/cmXMLSafe.cxx
index d9bdc023b..8cd5f6e0d 100644
--- a/Source/cmXMLSafe.cxx
+++ b/Source/cmXMLSafe.cxx
@@ -2,11 +2,11 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmXMLSafe.h"
-#include "cm_utf8.h"
-
+#include <cstdio>
+#include <cstring>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
+
+#include "cm_utf8.h"
cmXMLSafe::cmXMLSafe(const char* s)
: Data(s)
diff --git a/Source/cmXMLWriter.cxx b/Source/cmXMLWriter.cxx
index 3cbc70dbd..0811bd029 100644
--- a/Source/cmXMLWriter.cxx
+++ b/Source/cmXMLWriter.cxx
@@ -2,13 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmXMLWriter.h"
-#include "cmsys/FStream.hxx"
#include <cassert>
+#include "cmsys/FStream.hxx"
+
cmXMLWriter::cmXMLWriter(std::ostream& output, std::size_t level)
: Output(output)
, IndentationElement(1, '\t')
, Level(level)
+ , Indent(0)
, ElementOpen(false)
, BreakAttrib(false)
, IsContent(false)
@@ -17,37 +19,39 @@ cmXMLWriter::cmXMLWriter(std::ostream& output, std::size_t level)
cmXMLWriter::~cmXMLWriter()
{
- assert(this->Elements.empty());
+ assert(this->Indent == 0);
}
void cmXMLWriter::StartDocument(const char* encoding)
{
- this->Output << "<?xml version=\"1.0\" encoding=\"" << encoding << "\"?>";
+ this->Output << R"(<?xml version="1.0" encoding=")" << encoding << "\"?>";
}
void cmXMLWriter::EndDocument()
{
- assert(this->Elements.empty());
+ assert(this->Indent == 0);
this->Output << '\n';
}
void cmXMLWriter::StartElement(std::string const& name)
{
this->CloseStartElement();
- this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
+ this->ConditionalLineBreak(!this->IsContent);
this->Output << '<' << name;
this->Elements.push(name);
+ ++this->Indent;
this->ElementOpen = true;
this->BreakAttrib = false;
}
void cmXMLWriter::EndElement()
{
- assert(!this->Elements.empty());
+ assert(this->Indent > 0);
+ --this->Indent;
if (this->ElementOpen) {
this->Output << "/>";
} else {
- this->ConditionalLineBreak(!this->IsContent, this->Elements.size() - 1);
+ this->ConditionalLineBreak(!this->IsContent);
this->IsContent = false;
this->Output << "</" << this->Elements.top() << '>';
}
@@ -58,7 +62,7 @@ void cmXMLWriter::EndElement()
void cmXMLWriter::Element(const char* name)
{
this->CloseStartElement();
- this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
+ this->ConditionalLineBreak(!this->IsContent);
this->Output << '<' << name << "/>";
}
@@ -70,7 +74,7 @@ void cmXMLWriter::BreakAttributes()
void cmXMLWriter::Comment(const char* comment)
{
this->CloseStartElement();
- this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
+ this->ConditionalLineBreak(!this->IsContent);
this->Output << "<!-- " << comment << " -->";
}
@@ -83,14 +87,14 @@ void cmXMLWriter::CData(std::string const& data)
void cmXMLWriter::Doctype(const char* doctype)
{
this->CloseStartElement();
- this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
+ this->ConditionalLineBreak(!this->IsContent);
this->Output << "<!DOCTYPE " << doctype << ">";
}
void cmXMLWriter::ProcessingInstruction(const char* target, const char* data)
{
this->CloseStartElement();
- this->ConditionalLineBreak(!this->IsContent, this->Elements.size());
+ this->ConditionalLineBreak(!this->IsContent);
this->Output << "<?" << target << ' ' << data << "?>";
}
@@ -106,11 +110,11 @@ void cmXMLWriter::SetIndentationElement(std::string const& element)
this->IndentationElement = element;
}
-void cmXMLWriter::ConditionalLineBreak(bool condition, std::size_t indent)
+void cmXMLWriter::ConditionalLineBreak(bool condition)
{
if (condition) {
this->Output << '\n';
- for (std::size_t i = 0; i < indent + this->Level; ++i) {
+ for (std::size_t i = 0; i < this->Indent + this->Level; ++i) {
this->Output << this->IndentationElement;
}
}
@@ -119,7 +123,7 @@ void cmXMLWriter::ConditionalLineBreak(bool condition, std::size_t indent)
void cmXMLWriter::PreAttribute()
{
assert(this->ElementOpen);
- this->ConditionalLineBreak(this->BreakAttrib, this->Elements.size());
+ this->ConditionalLineBreak(this->BreakAttrib);
if (!this->BreakAttrib) {
this->Output << ' ';
}
@@ -134,7 +138,7 @@ void cmXMLWriter::PreContent()
void cmXMLWriter::CloseStartElement()
{
if (this->ElementOpen) {
- this->ConditionalLineBreak(this->BreakAttrib, this->Elements.size());
+ this->ConditionalLineBreak(this->BreakAttrib);
this->Output << '>';
this->ElementOpen = false;
}
diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h
index ed76a88c7..bc445aa5b 100644
--- a/Source/cmXMLWriter.h
+++ b/Source/cmXMLWriter.h
@@ -3,23 +3,27 @@
#ifndef cmXMLWiter_h
#define cmXMLWiter_h
-#include "cmConfigure.h"
-
-#include "cmXMLSafe.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <chrono>
+#include <cstddef>
+#include <ctime>
#include <ostream>
#include <stack>
#include <string>
#include <vector>
+#include "cmXMLSafe.h"
+
class cmXMLWriter
{
- CM_DISABLE_COPY(cmXMLWriter)
-
public:
cmXMLWriter(std::ostream& output, std::size_t level = 0);
~cmXMLWriter();
+ cmXMLWriter(cmXMLWriter const&) = delete;
+ cmXMLWriter& operator=(cmXMLWriter const&) = delete;
+
void StartDocument(const char* encoding = "UTF-8");
void EndDocument();
@@ -65,7 +69,7 @@ public:
void SetIndentationElement(std::string const& element);
private:
- void ConditionalLineBreak(bool condition, std::size_t indent);
+ void ConditionalLineBreak(bool condition);
void PreAttribute();
void PreContent();
@@ -73,14 +77,11 @@ private:
void CloseStartElement();
private:
- static cmXMLSafe SafeAttribute(const char* value)
- {
- return cmXMLSafe(value);
- }
+ static cmXMLSafe SafeAttribute(const char* value) { return { value }; }
static cmXMLSafe SafeAttribute(std::string const& value)
{
- return cmXMLSafe(value);
+ return { value };
}
template <typename T>
@@ -99,6 +100,22 @@ private:
return cmXMLSafe(value).Quotes(false);
}
+ /*
+ * Convert a std::chrono::system::time_point to the number of seconds since
+ * the UN*X epoch.
+ *
+ * It would be tempting to convert a time_point to number of seconds by
+ * using time_since_epoch(). Unfortunately the C++11 standard does not
+ * specify what the epoch of the system_clock must be.
+ * Therefore we must assume it is an arbitrary point in time. Instead of this
+ * method, it is recommended to convert it by means of the to_time_t method.
+ */
+ static std::time_t SafeContent(
+ std::chrono::system_clock::time_point const& value)
+ {
+ return std::chrono::system_clock::to_time_t(value);
+ }
+
template <typename T>
static T SafeContent(T value)
{
@@ -107,12 +124,77 @@ private:
private:
std::ostream& Output;
- std::stack<std::string, std::vector<std::string> > Elements;
+ std::stack<std::string, std::vector<std::string>> Elements;
std::string IndentationElement;
std::size_t Level;
+ std::size_t Indent;
bool ElementOpen;
bool BreakAttrib;
bool IsContent;
};
+class cmXMLElement; // IWYU pragma: keep
+
+class cmXMLDocument
+{
+public:
+ cmXMLDocument(cmXMLWriter& xml)
+ : xmlwr(xml)
+ {
+ xmlwr.StartDocument();
+ }
+ ~cmXMLDocument() { xmlwr.EndDocument(); }
+ cmXMLDocument(const cmXMLDocument&) = delete;
+ cmXMLDocument& operator=(const cmXMLDocument&) = delete;
+
+private:
+ friend class cmXMLElement;
+ cmXMLWriter& xmlwr;
+};
+
+class cmXMLElement
+{
+public:
+ cmXMLElement(cmXMLWriter& xml, const char* tag)
+ : xmlwr(xml)
+ {
+ xmlwr.StartElement(tag);
+ }
+ cmXMLElement(cmXMLElement& par, const char* tag)
+ : xmlwr(par.xmlwr)
+ {
+ xmlwr.StartElement(tag);
+ }
+ cmXMLElement(cmXMLDocument& doc, const char* tag)
+ : xmlwr(doc.xmlwr)
+ {
+ xmlwr.StartElement(tag);
+ }
+ ~cmXMLElement() { xmlwr.EndElement(); }
+
+ cmXMLElement(const cmXMLElement&) = delete;
+ cmXMLElement& operator=(const cmXMLElement&) = delete;
+
+ template <typename T>
+ cmXMLElement& Attribute(const char* name, T const& value)
+ {
+ xmlwr.Attribute(name, value);
+ return *this;
+ }
+ template <typename T>
+ void Content(T const& content)
+ {
+ xmlwr.Content(content);
+ }
+ template <typename T>
+ void Element(std::string const& name, T const& value)
+ {
+ xmlwr.Element(name, value);
+ }
+ void Comment(const char* comment) { xmlwr.Comment(comment); }
+
+private:
+ cmXMLWriter& xmlwr;
+};
+
#endif
diff --git a/Source/cm_auto_ptr.hxx b/Source/cm_auto_ptr.hxx
deleted file mode 100644
index 773602af9..000000000
--- a/Source/cm_auto_ptr.hxx
+++ /dev/null
@@ -1,220 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef CM_AUTO_PTR_HXX
-#define CM_AUTO_PTR_HXX
-
-#include "cmConfigure.h"
-
-#ifdef CMake_HAVE_CXX_AUTO_PTR
-
-#include <memory>
-#define CM_AUTO_PTR std::auto_ptr
-
-#else
-
-#define CM_AUTO_PTR cm::auto_ptr
-
-// The HP compiler cannot handle the conversions necessary to use
-// auto_ptr_ref to pass an auto_ptr returned from one function
-// directly to another function as in use_auto_ptr(get_auto_ptr()).
-// We instead use const_cast to achieve the syntax on those platforms.
-// We do not use const_cast on other platforms to maintain the C++
-// standard design and guarantee that if an auto_ptr is bound
-// to a reference-to-const then ownership will be maintained.
-#if defined(__HP_aCC)
-#define cm_AUTO_PTR_REF 0
-#define cm_AUTO_PTR_CONST const
-#define cm_AUTO_PTR_CAST(a) cast(a)
-#else
-#define cm_AUTO_PTR_REF 1
-#define cm_AUTO_PTR_CONST
-#define cm_AUTO_PTR_CAST(a) a
-#endif
-
-// In C++11, clang will warn about using dynamic exception specifications
-// as they are deprecated. But as this class is trying to faithfully
-// mimic std::auto_ptr, we want to keep the 'throw()' decorations below.
-// So we suppress the warning.
-#if defined(__clang__) && defined(__has_warning)
-#if __has_warning("-Wdeprecated")
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated"
-#endif
-#endif
-
-namespace cm {
-
-template <class X>
-class auto_ptr;
-
-#if cm_AUTO_PTR_REF
-namespace detail {
-// The auto_ptr_ref template is supposed to be a private member of
-// auto_ptr but Borland 5.8 cannot handle it. Instead put it in
-// a private namespace.
-template <class Y>
-struct auto_ptr_ref
-{
- Y* p_;
-
- // The extra constructor argument prevents implicit conversion to
- // auto_ptr_ref from auto_ptr through the constructor. Normally
- // this should be done with the explicit keyword but Borland 5.x
- // generates code in the conversion operator to call itself
- // infinately.
- auto_ptr_ref(Y* p, int)
- : p_(p)
- {
- }
-};
-}
-#endif
-
-/** C++98 Standard Section 20.4.5 - Template class auto_ptr. */
-template <class X>
-class auto_ptr
-{
-#if !cm_AUTO_PTR_REF
- template <typename Y>
- static inline auto_ptr<Y>& cast(auto_ptr<Y> const& a)
- {
- return const_cast<auto_ptr<Y>&>(a);
- }
-#endif
-
- /** The pointer to the object held. */
- X* x_;
-
-public:
- /** The type of object held by the auto_ptr. */
- typedef X element_type;
-
- /** Construct from an auto_ptr holding a compatible object. This
- transfers ownership to the newly constructed auto_ptr. */
- template <class Y>
- auto_ptr(auto_ptr<Y> cm_AUTO_PTR_CONST& a) throw()
- : x_(cm_AUTO_PTR_CAST(a).release())
- {
- }
-
- /** Assign from an auto_ptr holding a compatible object. This
- transfers ownership to the left-hand-side of the assignment. */
- template <class Y>
- auto_ptr& operator=(auto_ptr<Y> cm_AUTO_PTR_CONST& a) throw() // NOLINT
- {
- this->reset(cm_AUTO_PTR_CAST(a).release());
- return *this; // NOLINT
- }
-
- /**
- * Explicitly construct from a raw pointer. This is typically
- * called with the result of operator new. For example:
- *
- * auto_ptr<X> ptr(new X());
- */
- explicit auto_ptr(X* p = CM_NULLPTR) throw()
- : x_(p)
- {
- }
-
- /** Construct from another auto_ptr holding an object of the same
- type. This transfers ownership to the newly constructed
- auto_ptr. */
- auto_ptr(auto_ptr cm_AUTO_PTR_CONST& a) throw()
- : x_(cm_AUTO_PTR_CAST(a).release())
- {
- }
-
- /** Assign from another auto_ptr holding an object of the same type.
- This transfers ownership to the newly constructed auto_ptr. */
- auto_ptr& operator=(auto_ptr cm_AUTO_PTR_CONST& a) throw() // NOLINT
- {
- this->reset(cm_AUTO_PTR_CAST(a).release());
- return *this; // NOLINT
- }
-
- /** Destruct and delete the object held. */
- ~auto_ptr() throw()
- {
- // Assume object destructor is nothrow.
- delete this->x_;
- }
-
- /** Dereference and return a reference to the object held. */
- X& operator*() const throw() { return *this->x_; }
-
- /** Return a pointer to the object held. */
- X* operator->() const throw() { return this->x_; }
-
- /** Return a pointer to the object held. */
- X* get() const throw() { return this->x_; }
-
- /** Return a pointer to the object held and reset to hold no object.
- This transfers ownership to the caller. */
- X* release() throw()
- {
- X* x = this->x_;
- this->x_ = CM_NULLPTR;
- return x;
- }
-
- /** Assume ownership of the given object. The object previously
- held is deleted. */
- void reset(X* p = 0) throw()
- {
- if (this->x_ != p) {
- // Assume object destructor is nothrow.
- delete this->x_;
- this->x_ = p;
- }
- }
-
- /** Convert to an auto_ptr holding an object of a compatible type.
- This transfers ownership to the returned auto_ptr. */
- template <class Y>
- operator auto_ptr<Y>() throw()
- {
- return auto_ptr<Y>(this->release());
- }
-
-#if cm_AUTO_PTR_REF
- /** Construct from an auto_ptr_ref. This is used when the
- constructor argument is a call to a function returning an
- auto_ptr. */
- auto_ptr(detail::auto_ptr_ref<X> r) throw()
- : x_(r.p_)
- {
- }
-
- /** Assign from an auto_ptr_ref. This is used when a function
- returning an auto_ptr is passed on the right-hand-side of an
- assignment. */
- auto_ptr& operator=(detail::auto_ptr_ref<X> r) throw()
- {
- this->reset(r.p_);
- return *this; // NOLINT
- }
-
- /** Convert to an auto_ptr_ref. This is used when a function
- returning an auto_ptr is the argument to the constructor of
- another auto_ptr. */
- template <class Y>
- operator detail::auto_ptr_ref<Y>() throw()
- {
- return detail::auto_ptr_ref<Y>(this->release(), 1);
- }
-#endif
-};
-
-} // namespace cm
-
-// Undo warning suppression.
-#if defined(__clang__) && defined(__has_warning)
-#if __has_warning("-Wdeprecated")
-#pragma clang diagnostic pop
-#endif
-#endif
-
-#endif
-
-#endif
diff --git a/Source/cm_codecvt.cxx b/Source/cm_codecvt.cxx
index cf55741a7..122e02283 100644
--- a/Source/cm_codecvt.cxx
+++ b/Source/cm_codecvt.cxx
@@ -3,11 +3,12 @@
#include "cm_codecvt.hxx"
#if defined(_WIN32)
-#include <assert.h>
-#include <string.h>
-#include <windows.h>
-#undef max
-#include "cmsys/Encoding.hxx"
+# include <windows.h>
+
+# include <assert.h>
+# include <string.h>
+# undef max
+# include "cmsys/Encoding.hxx"
#endif
#if defined(_WIN32)
@@ -38,12 +39,12 @@ codecvt::codecvt(Encoding e)
}
}
-codecvt::~codecvt(){};
+codecvt::~codecvt() = default;
bool codecvt::do_always_noconv() const throw()
{
return m_noconv;
-};
+}
std::codecvt_base::result codecvt::do_out(mbstate_t& state, const char* from,
const char* from_end,
@@ -122,7 +123,7 @@ std::codecvt_base::result codecvt::do_out(mbstate_t& state, const char* from,
static_cast<void>(to_next);
return std::codecvt_base::noconv;
#endif
-};
+}
std::codecvt_base::result codecvt::do_unshift(mbstate_t& state, char* to,
char* to_end,
@@ -143,7 +144,7 @@ std::codecvt_base::result codecvt::do_unshift(mbstate_t& state, char* to,
static_cast<void>(to_end);
return std::codecvt_base::ok;
#endif
-};
+}
#if defined(_WIN32)
std::codecvt_base::result codecvt::Decode(mbstate_t& state, int size,
@@ -235,9 +236,9 @@ void codecvt::BufferPartial(mbstate_t& state, int size,
int codecvt::do_max_length() const throw()
{
return 4;
-};
+}
int codecvt::do_encoding() const throw()
{
return 0;
-};
+}
diff --git a/Source/cm_codecvt.hxx b/Source/cm_codecvt.hxx
index 30c6d5407..b2cb9e6a3 100644
--- a/Source/cm_codecvt.hxx
+++ b/Source/cm_codecvt.hxx
@@ -3,10 +3,10 @@
#ifndef cm_codecvt_hxx
#define cm_codecvt_hxx
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <cwchar>
#include <locale>
-#include <wchar.h>
class codecvt : public std::codecvt<char, char, mbstate_t>
{
@@ -18,20 +18,20 @@ public:
ANSI
};
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
codecvt(Encoding e);
protected:
- ~codecvt() CM_OVERRIDE;
- bool do_always_noconv() const throw() CM_OVERRIDE;
+ ~codecvt() override;
+ bool do_always_noconv() const throw() override;
result do_out(mbstate_t& state, const char* from, const char* from_end,
const char*& from_next, char* to, char* to_end,
- char*& to_next) const CM_OVERRIDE;
+ char*& to_next) const override;
result do_unshift(mbstate_t& state, char* to, char*,
- char*& to_next) const CM_OVERRIDE;
- int do_max_length() const throw() CM_OVERRIDE;
- int do_encoding() const throw() CM_OVERRIDE;
+ char*& to_next) const override;
+ int do_max_length() const throw() override;
+ int do_encoding() const throw() override;
private:
// The mbstate_t argument to do_out and do_unshift is responsible
@@ -52,13 +52,13 @@ private:
};
bool m_noconv;
-#if defined(_WIN32)
+# if defined(_WIN32)
unsigned int m_codepage;
result Decode(mbstate_t& state, int need, const char*& from_next,
char*& to_next, char* to_end) const;
result DecodePartial(mbstate_t& state, char*& to_next, char* to_end) const;
void BufferPartial(mbstate_t& state, int need, const char*& from_next) const;
-#endif
+# endif
#endif
};
diff --git a/Source/cm_get_date.h b/Source/cm_get_date.h
index 6acf8dea3..38a690ee0 100644
--- a/Source/cm_get_date.h
+++ b/Source/cm_get_date.h
@@ -3,7 +3,7 @@
#ifndef cm_get_date_h
#define cm_get_date_h
-#include <time.h>
+#include <time.h> /* NOLINT(modernize-deprecated-headers) */
#ifdef __cplusplus
extern "C" {
diff --git a/Source/cm_static_string_view.hxx b/Source/cm_static_string_view.hxx
new file mode 100644
index 000000000..708ac9579
--- /dev/null
+++ b/Source/cm_static_string_view.hxx
@@ -0,0 +1,41 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cm_static_string_view_hxx
+#define cm_static_string_view_hxx
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <cstddef>
+
+#include <cm/string_view>
+
+namespace cm {
+
+/** A string_view that only binds to static storage.
+ *
+ * This is used together with the `""_s` user-defined literal operator
+ * to construct a type-safe abstraction of a string_view that only views
+ * statically allocated strings. These strings are const and available
+ * for the entire lifetime of the program.
+ */
+class static_string_view : public string_view
+{
+ static_string_view(string_view v)
+ : string_view(v)
+ {
+ }
+
+ friend static_string_view operator"" _s(const char* data, size_t size);
+};
+
+/** Create a static_string_view using `""_s` literal syntax. */
+inline static_string_view operator"" _s(const char* data, size_t size)
+{
+ return string_view(data, size);
+}
+
+} // namespace cm
+
+using cm::operator"" _s;
+
+#endif
diff --git a/Source/cm_sys_stat.h b/Source/cm_sys_stat.h
index 26e4baa03..919428634 100644
--- a/Source/cm_sys_stat.h
+++ b/Source/cm_sys_stat.h
@@ -4,11 +4,11 @@
#define cm_sys_stat_h
#if defined(_MSC_VER)
-typedef unsigned short mode_t;
+using mode_t = unsigned short;
#endif
#include <sys/types.h>
// include sys/stat.h after sys/types.h
-#include <sys/stat.h>
+#include <sys/stat.h> // IWYU pragma: export
#endif
diff --git a/Source/cm_unordered_map.hxx b/Source/cm_unordered_map.hxx
deleted file mode 100644
index bf3890314..000000000
--- a/Source/cm_unordered_map.hxx
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef CM_UNORDERED_MAP_HXX
-#define CM_UNORDERED_MAP_HXX
-
-#include "cmConfigure.h"
-
-#if defined(CMake_HAVE_CXX_UNORDERED_MAP)
-
-#include <unordered_map>
-#define CM_UNORDERED_MAP std::unordered_map
-
-#elif defined(CMAKE_BUILD_WITH_CMAKE)
-
-#include "cmsys/hash_map.hxx"
-#define CM_UNORDERED_MAP cmsys::hash_map
-
-#else
-
-#include <map>
-#define CM_UNORDERED_MAP std::map
-
-#endif
-
-#endif
diff --git a/Source/cm_unordered_set.hxx b/Source/cm_unordered_set.hxx
deleted file mode 100644
index dd1a9a115..000000000
--- a/Source/cm_unordered_set.hxx
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef CM_UNORDERED_SET_HXX
-#define CM_UNORDERED_SET_HXX
-
-#include "cmConfigure.h"
-
-#if defined(CMake_HAVE_CXX_UNORDERED_SET)
-
-#include <unordered_set>
-#define CM_UNORDERED_SET std::unordered_set
-
-#elif defined(CMAKE_BUILD_WITH_CMAKE)
-
-#include "cmsys/hash_set.hxx"
-#define CM_UNORDERED_SET cmsys::hash_set
-
-#else
-
-#include <set>
-#define CM_UNORDERED_SET std::set
-
-#endif
-
-#endif
diff --git a/Source/cm_utf8.c b/Source/cm_utf8.c
index 52af4a6f4..62e7e8c8c 100644
--- a/Source/cm_utf8.c
+++ b/Source/cm_utf8.c
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cm_utf8.h"
+#include <string.h>
+
/*
RFC 3629
07-bit: 0xxxxxxx
@@ -71,7 +73,34 @@ const char* cm_utf8_decode_character(const char* first, const char* last,
return 0;
}
+ /* UTF-16 surrogate halves. */
+ if (0xD800 <= uc && uc <= 0xDFFF) {
+ return 0;
+ }
+
+ /* Invalid codepoints. */
+ if (0x10FFFF < uc) {
+ return 0;
+ }
+
*pc = uc;
return first;
}
}
+
+int cm_utf8_is_valid(const char* s)
+{
+ if (!s) {
+ return 0;
+ }
+
+ const char* last = s + strlen(s);
+ const char* pos = s;
+ unsigned int pc;
+
+ while (pos != last && (pos = cm_utf8_decode_character(pos, last, &pc))) {
+ /* Nothing to do. */
+ }
+
+ return pos == last;
+}
diff --git a/Source/cm_utf8.h b/Source/cm_utf8.h
index fcb43e0e4..27dc5591f 100644
--- a/Source/cm_utf8.h
+++ b/Source/cm_utf8.h
@@ -13,6 +13,10 @@ extern "C" {
const char* cm_utf8_decode_character(const char* first, const char* last,
unsigned int* pc);
+/** Returns whether a C string is a sequence of valid UTF-8 encoded Unicode
+ codepoints. Returns non-zero on success. */
+int cm_utf8_is_valid(const char* s);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 689439378..f63a26400 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2,13 +2,22 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmake.h"
+#include <cm/memory>
+#include <cm/string_view>
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW)
+# include <cm/iterator>
+#endif
+
+#include "cm_sys_stat.h"
+
#include "cmAlgorithms.h"
#include "cmCommands.h"
#include "cmDocumentation.h"
#include "cmDocumentationEntry.h"
#include "cmDocumentationFormatter.h"
+#include "cmDuration.h"
#include "cmExternalMakefileProjectGenerator.h"
-#include "cmFileTimeComparison.h"
+#include "cmFileTimeCache.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
#include "cmGlobalGeneratorFactory.h"
@@ -18,140 +27,128 @@
#include "cmMessenger.h"
#include "cmState.h"
#include "cmStateDirectory.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetLinkLibraryType.h"
#include "cmUtils.hxx"
#include "cmVersionConfig.h"
#include "cmWorkingDirectory.h"
-#include "cm_auto_ptr.hxx"
-#include "cm_sys_stat.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cm_jsoncpp_writer.h"
+#if !defined(CMAKE_BOOTSTRAP)
+# include <unordered_map>
-#include "cmGraphVizWriter.h"
-#include "cmVariableWatch.h"
-#include "cm_unordered_map.hxx"
-#endif
+# include "cm_jsoncpp_writer.h"
-// only build kdevelop generator on non-windows platforms
-// when not bootstrapping cmake
-#if !defined(_WIN32)
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#define CMAKE_USE_KDEVELOP
-#endif
+# include "cmFileAPI.h"
+# include "cmGraphVizWriter.h"
+# include "cmVariableWatch.h"
#endif
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#define CMAKE_USE_ECLIPSE
+#if !defined(CMAKE_BOOTSTRAP)
+# define CMAKE_USE_ECLIPSE
#endif
-#if defined(__MINGW32__) && !defined(CMAKE_BUILD_WITH_CMAKE)
-#define CMAKE_BOOT_MINGW
+#if defined(__MINGW32__) && defined(CMAKE_BOOTSTRAP)
+# define CMAKE_BOOT_MINGW
#endif
// include the generator
#if defined(_WIN32) && !defined(__CYGWIN__)
-#if !defined(CMAKE_BOOT_MINGW)
-#include "cmGlobalBorlandMakefileGenerator.h"
-#include "cmGlobalGhsMultiGenerator.h"
-#include "cmGlobalJOMMakefileGenerator.h"
-#include "cmGlobalNMakeMakefileGenerator.h"
-#include "cmGlobalVisualStudio10Generator.h"
-#include "cmGlobalVisualStudio11Generator.h"
-#include "cmGlobalVisualStudio12Generator.h"
-#include "cmGlobalVisualStudio14Generator.h"
-#include "cmGlobalVisualStudio15Generator.h"
-#include "cmGlobalVisualStudio8Generator.h"
-#include "cmGlobalVisualStudio9Generator.h"
-#include "cmVSSetupHelper.h"
-
-#define CMAKE_HAVE_VS_GENERATORS
-#endif
-#include "cmGlobalMSYSMakefileGenerator.h"
-#include "cmGlobalMinGWMakefileGenerator.h"
+# if !defined(CMAKE_BOOT_MINGW)
+# include "cmGlobalBorlandMakefileGenerator.h"
+# include "cmGlobalJOMMakefileGenerator.h"
+# include "cmGlobalNMakeMakefileGenerator.h"
+# include "cmGlobalVisualStudio10Generator.h"
+# include "cmGlobalVisualStudio11Generator.h"
+# include "cmGlobalVisualStudio12Generator.h"
+# include "cmGlobalVisualStudio14Generator.h"
+# include "cmGlobalVisualStudio9Generator.h"
+# include "cmGlobalVisualStudioVersionedGenerator.h"
+# include "cmVSSetupHelper.h"
+
+# define CMAKE_HAVE_VS_GENERATORS
+# endif
+# include "cmGlobalMSYSMakefileGenerator.h"
+# include "cmGlobalMinGWMakefileGenerator.h"
#else
#endif
#if defined(CMAKE_USE_WMAKE)
-#include "cmGlobalWatcomWMakeGenerator.h"
+# include "cmGlobalWatcomWMakeGenerator.h"
#endif
#include "cmGlobalUnixMakefileGenerator3.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmGlobalNinjaGenerator.h"
+#if !defined(CMAKE_BOOTSTRAP)
+# include "cmGlobalNinjaGenerator.h"
#endif
#include "cmExtraCodeLiteGenerator.h"
#if !defined(CMAKE_BOOT_MINGW)
-#include "cmExtraCodeBlocksGenerator.h"
+# include "cmExtraCodeBlocksGenerator.h"
#endif
#include "cmExtraKateGenerator.h"
#include "cmExtraSublimeTextGenerator.h"
-#ifdef CMAKE_USE_KDEVELOP
-#include "cmGlobalKdevelopGenerator.h"
+#ifdef CMAKE_USE_ECLIPSE
+# include "cmExtraEclipseCDT4Generator.h"
#endif
-#ifdef CMAKE_USE_ECLIPSE
-#include "cmExtraEclipseCDT4Generator.h"
+#if defined(__linux__) || defined(_WIN32)
+# include "cmGlobalGhsMultiGenerator.h"
#endif
#if defined(__APPLE__)
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmGlobalXCodeGenerator.h"
+# if !defined(CMAKE_BOOTSTRAP)
+# include "cmGlobalXCodeGenerator.h"
-#define CMAKE_USE_XCODE 1
-#endif
-#include <sys/resource.h>
-#include <sys/time.h>
+# define CMAKE_USE_XCODE 1
+# endif
+# include <sys/resource.h>
+# include <sys/time.h>
#endif
-#include "cmsys/FStream.hxx"
-#include "cmsys/Glob.hxx"
-#include "cmsys/RegularExpression.hxx"
#include <algorithm>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <initializer_list>
#include <iostream>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <utility>
+#include "cmsys/FStream.hxx"
+#include "cmsys/Glob.hxx"
+#include "cmsys/RegularExpression.hxx"
+
namespace {
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-typedef CM_UNORDERED_MAP<std::string, Json::Value> JsonValueMapType;
+#if !defined(CMAKE_BOOTSTRAP)
+using JsonValueMapType = std::unordered_map<std::string, Json::Value>;
#endif
} // namespace
-static bool cmakeCheckStampFile(const char* stampName, bool verbose = true);
-static bool cmakeCheckStampList(const char* stampList, bool verbose = true);
+static bool cmakeCheckStampFile(const std::string& stampName);
+static bool cmakeCheckStampList(const std::string& stampList);
-void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/,
- void* ctx, const char* /*unused*/,
- const cmMakefile* /*unused*/)
+static void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/,
+ void* ctx, const char* /*unused*/,
+ const cmMakefile* /*unused*/)
{
cmake* cm = reinterpret_cast<cmake*>(ctx);
cm->MarkCliAsUsed(variable);
}
-cmake::cmake(Role role)
+cmake::cmake(Role role, cmState::Mode mode)
+ : FileTimeCache(cm::make_unique<cmFileTimeCache>())
+#ifndef CMAKE_BOOTSTRAP
+ , VariableWatch(cm::make_unique<cmVariableWatch>())
+#endif
+ , State(cm::make_unique<cmState>())
+ , Messenger(cm::make_unique<cmMessenger>())
{
- this->Trace = false;
- this->TraceExpand = false;
- this->WarnUninitialized = false;
- this->WarnUnused = false;
- this->WarnUnusedCli = true;
- this->CheckSystemVars = false;
- this->DebugOutput = false;
- this->DebugTryCompile = false;
- this->ClearBuildSystem = false;
- this->FileComparison = new cmFileTimeComparison;
-
- this->State = new cmState;
+ this->TraceFile.close();
+ this->State->SetMode(mode);
this->CurrentSnapshot = this->State->CreateBaseSnapshot();
- this->Messenger = new cmMessenger(this->State);
#ifdef __APPLE__
struct rlimit rlp;
@@ -163,15 +160,6 @@ cmake::cmake(Role role)
}
#endif
- this->GlobalGenerator = CM_NULLPTR;
- this->ProgressCallback = CM_NULLPTR;
- this->ProgressCallbackClientData = CM_NULLPTR;
- this->CurrentWorkingMode = NORMAL_MODE;
-
-#ifdef CMAKE_BUILD_WITH_CMAKE
- this->VariableWatch = new cmVariableWatch;
-#endif
-
this->AddDefaultGenerators();
this->AddDefaultExtraGenerators();
if (role == RoleScript || role == RoleProject) {
@@ -181,54 +169,50 @@ cmake::cmake(Role role)
this->AddProjectCommands();
}
+ if (mode == cmState::Project) {
+ this->LoadEnvironmentPresets();
+ }
+
// Make sure we can capture the build tool output.
cmSystemTools::EnableVSConsoleOutput();
- // Set up a list of source and header extensions
- // these are used to find files when the extension
- // is not given
- // The "c" extension MUST precede the "C" extension.
- this->SourceFileExtensions.push_back("c");
- this->SourceFileExtensions.push_back("C");
-
- this->SourceFileExtensions.push_back("c++");
- this->SourceFileExtensions.push_back("cc");
- this->SourceFileExtensions.push_back("cpp");
- this->SourceFileExtensions.push_back("cxx");
- this->SourceFileExtensions.push_back("m");
- this->SourceFileExtensions.push_back("M");
- this->SourceFileExtensions.push_back("mm");
-
- this->HeaderFileExtensions.push_back("h");
- this->HeaderFileExtensions.push_back("hh");
- this->HeaderFileExtensions.push_back("h++");
- this->HeaderFileExtensions.push_back("hm");
- this->HeaderFileExtensions.push_back("hpp");
- this->HeaderFileExtensions.push_back("hxx");
- this->HeaderFileExtensions.push_back("in");
- this->HeaderFileExtensions.push_back("txx");
+ // Set up a list of source and header extensions.
+ // These are used to find files when the extension is not given.
+ {
+ auto setupExts = [](FileExtensions& exts,
+ std::initializer_list<cm::string_view> extList) {
+ // Fill ordered vector
+ exts.ordered.reserve(extList.size());
+ for (cm::string_view ext : extList) {
+ exts.ordered.emplace_back(ext);
+ };
+ // Fill unordered set
+ exts.unordered.insert(exts.ordered.begin(), exts.ordered.end());
+ };
+
+ // The "c" extension MUST precede the "C" extension.
+ setupExts(this->SourceFileExtensions,
+ { "c", "C", "c++", "cc", "cpp", "cxx", "cu", "m", "M", "mm" });
+ setupExts(this->HeaderFileExtensions,
+ { "h", "hh", "h++", "hm", "hpp", "hxx", "in", "txx" });
+ setupExts(this->CudaFileExtensions, { "cu" });
+ setupExts(this->FortranFileExtensions,
+ { "f", "F", "for", "f77", "f90", "f95", "f03" });
+ }
}
cmake::~cmake()
{
- delete this->State;
- delete this->Messenger;
if (this->GlobalGenerator) {
delete this->GlobalGenerator;
- this->GlobalGenerator = CM_NULLPTR;
+ this->GlobalGenerator = nullptr;
}
cmDeleteAll(this->Generators);
-#ifdef CMAKE_BUILD_WITH_CMAKE
- delete this->VariableWatch;
-#endif
- delete this->FileComparison;
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-Json::Value cmake::ReportCapabilitiesJson(bool haveServerMode) const
+#if !defined(CMAKE_BOOTSTRAP)
+Json::Value cmake::ReportVersionJson() const
{
- Json::Value obj = Json::objectValue;
- // Version information:
Json::Value version = Json::objectValue;
version["string"] = CMake_VERSION;
version["major"] = CMake_VERSION_MAJOR;
@@ -236,53 +220,58 @@ Json::Value cmake::ReportCapabilitiesJson(bool haveServerMode) const
version["suffix"] = CMake_VERSION_SUFFIX;
version["isDirty"] = (CMake_VERSION_IS_DIRTY == 1);
version["patch"] = CMake_VERSION_PATCH;
+ return version;
+}
- obj["version"] = version;
+Json::Value cmake::ReportCapabilitiesJson() const
+{
+ Json::Value obj = Json::objectValue;
+
+ // Version information:
+ obj["version"] = this->ReportVersionJson();
// Generators:
std::vector<cmake::GeneratorInfo> generatorInfoList;
this->GetRegisteredGenerators(generatorInfoList);
JsonValueMapType generatorMap;
- for (std::vector<cmake::GeneratorInfo>::const_iterator i =
- generatorInfoList.begin();
- i != generatorInfoList.end(); ++i) {
- if (i->isAlias) { // skip aliases, they are there for compatibility reasons
+ for (cmake::GeneratorInfo const& gi : generatorInfoList) {
+ if (gi.isAlias) { // skip aliases, they are there for compatibility reasons
// only
continue;
}
- if (i->extraName.empty()) {
+ if (gi.extraName.empty()) {
Json::Value gen = Json::objectValue;
- gen["name"] = i->name;
- gen["toolsetSupport"] = i->supportsToolset;
- gen["platformSupport"] = i->supportsPlatform;
+ gen["name"] = gi.name;
+ gen["toolsetSupport"] = gi.supportsToolset;
+ gen["platformSupport"] = gi.supportsPlatform;
gen["extraGenerators"] = Json::arrayValue;
- generatorMap[i->name] = gen;
+ generatorMap[gi.name] = gen;
} else {
- Json::Value& gen = generatorMap[i->baseName];
- gen["extraGenerators"].append(i->extraName);
+ Json::Value& gen = generatorMap[gi.baseName];
+ gen["extraGenerators"].append(gi.extraName);
}
}
Json::Value generators = Json::arrayValue;
- for (JsonValueMapType::const_iterator i = generatorMap.begin();
- i != generatorMap.end(); ++i) {
- generators.append(i->second);
+ for (auto const& i : generatorMap) {
+ generators.append(i.second);
}
obj["generators"] = generators;
- obj["serverMode"] = haveServerMode;
+ obj["fileApi"] = cmFileAPI::ReportCapabilities();
+ obj["serverMode"] = true;
return obj;
}
#endif
-std::string cmake::ReportCapabilities(bool haveServerMode) const
+std::string cmake::ReportCapabilities() const
{
std::string result;
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
Json::FastWriter writer;
- result = writer.write(this->ReportCapabilitiesJson(haveServerMode));
+ result = writer.write(this->ReportCapabilitiesJson());
#else
result = "Not supported";
#endif
@@ -313,7 +302,8 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
return false;
}
}
- std::string var, value;
+ std::string var;
+ std::string value;
cmStateEnums::CacheEntryType type = cmStateEnums::UNINITIALIZED;
if (cmState::ParseCacheEntry(entry, var, value, type)) {
// The value is transformed if it is a filepath for example, so
@@ -322,9 +312,10 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
bool haveValue = false;
std::string cachedValue;
if (this->WarnUnusedCli) {
- if (const char* v = this->State->GetInitializedCacheValue(var)) {
+ if (const std::string* v =
+ this->State->GetInitializedCacheValue(var)) {
haveValue = true;
- cachedValue = v;
+ cachedValue = *v;
}
}
@@ -334,7 +325,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
if (this->WarnUnusedCli) {
if (!haveValue ||
- cachedValue != this->State->GetInitializedCacheValue(var)) {
+ cachedValue != *this->State->GetInitializedCacheValue(var)) {
this->WatchUnusedCli(var);
}
}
@@ -407,21 +398,18 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
// removed
std::vector<std::string> entriesToDelete;
std::vector<std::string> cacheKeys = this->State->GetCacheEntryKeys();
- for (std::vector<std::string>::const_iterator it = cacheKeys.begin();
- it != cacheKeys.end(); ++it) {
- cmStateEnums::CacheEntryType t = this->State->GetCacheEntryType(*it);
+ for (std::string const& ck : cacheKeys) {
+ cmStateEnums::CacheEntryType t = this->State->GetCacheEntryType(ck);
if (t != cmStateEnums::STATIC) {
- if (regex.find(it->c_str())) {
- entriesToDelete.push_back(*it);
+ if (regex.find(ck)) {
+ entriesToDelete.push_back(ck);
}
}
}
// now remove them from the cache
- for (std::vector<std::string>::const_iterator currentEntry =
- entriesToDelete.begin();
- currentEntry != entriesToDelete.end(); ++currentEntry) {
- this->State->RemoveCacheEntry(*currentEntry);
+ for (std::string const& currentEntry : entriesToDelete) {
+ this->State->RemoveCacheEntry(currentEntry);
}
} else if (arg.find("-C", 0) == 0) {
std::string path = arg.substr(2);
@@ -435,7 +423,9 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
}
}
std::cout << "loading initial cache file " << path << "\n";
- this->ReadListFile(args, path.c_str());
+ // Resolve script path specified on command line relative to $PWD.
+ path = cmSystemTools::CollapseFullPath(path);
+ this->ReadListFile(args, path);
} else if (arg.find("-P", 0) == 0) {
i++;
if (i >= args.size()) {
@@ -448,8 +438,13 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
return false;
}
// Register fake project commands that hint misuse in script mode.
- GetProjectCommandsInScriptMode(this->State);
- this->ReadListFile(args, path.c_str());
+ GetProjectCommandsInScriptMode(this->GetState());
+ // Documented behaviour of CMAKE{,_CURRENT}_{SOURCE,BINARY}_DIR is to be
+ // set to $PWD for -P mode.
+ this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
+ this->SetHomeOutputDirectory(
+ cmSystemTools::GetCurrentWorkingDirectory());
+ this->ReadListFile(args, path);
} else if (arg.find("--find-package", 0) == 0) {
findPackageMode = true;
}
@@ -463,7 +458,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
}
void cmake::ReadListFile(const std::vector<std::string>& args,
- const char* path)
+ const std::string& path)
{
// if a generator was not yet created, temporarily create one
cmGlobalGenerator* gg = this->GetGlobalGenerator();
@@ -476,31 +471,23 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
}
// read in the list file to fill the cache
- if (path) {
+ if (!path.empty()) {
this->CurrentSnapshot = this->State->Reset();
- std::string homeDir = this->GetHomeDirectory();
- std::string homeOutputDir = this->GetHomeOutputDirectory();
- this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
- this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
cmStateSnapshot snapshot = this->GetCurrentSnapshot();
- snapshot.GetDirectory().SetCurrentBinary(
- cmSystemTools::GetCurrentWorkingDirectory());
- snapshot.GetDirectory().SetCurrentSource(
- cmSystemTools::GetCurrentWorkingDirectory());
+ snapshot.GetDirectory().SetCurrentBinary(this->GetHomeOutputDirectory());
+ snapshot.GetDirectory().SetCurrentSource(this->GetHomeDirectory());
snapshot.SetDefaultDefinitions();
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(gg, snapshot));
+ cmMakefile mf(gg, snapshot);
if (this->GetWorkingMode() != NORMAL_MODE) {
std::string file(cmSystemTools::CollapseFullPath(path));
cmSystemTools::ConvertToUnixSlashes(file);
- mf->SetScriptModeFile(file.c_str());
+ mf.SetScriptModeFile(file);
- mf->SetArgcArgv(args);
+ mf.SetArgcArgv(args);
}
- if (!mf->ReadListFile(path)) {
- cmSystemTools::Error("Error processing file: ", path);
+ if (!mf.ReadListFile(path)) {
+ cmSystemTools::Error("Error processing file: " + path);
}
- this->SetHomeDirectory(homeDir);
- this->SetHomeOutputDirectory(homeOutputDir);
}
// free generic one if generated
@@ -531,7 +518,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
mf->SetArgcArgv(args);
std::string systemFile = mf->GetModulesFile("CMakeFindPackageMode.cmake");
- mf->ReadListFile(systemFile.c_str());
+ mf->ReadListFile(systemFile);
std::string language = mf->GetSafeDefinition("LANGUAGE");
std::string mode = mf->GetSafeDefinition("MODE");
@@ -549,13 +536,12 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
}
} else if (mode == "COMPILE") {
std::string includes = mf->GetSafeDefinition("PACKAGE_INCLUDE_DIRS");
- std::vector<std::string> includeDirs;
- cmSystemTools::ExpandListArgument(includes, includeDirs);
+ std::vector<std::string> includeDirs = cmExpandedList(includes);
gg->CreateGenerationObjects();
cmLocalGenerator* lg = gg->LocalGenerators[0];
std::string includeFlags =
- lg->GetIncludeFlags(includeDirs, CM_NULLPTR, language);
+ lg->GetIncludeFlags(includeDirs, nullptr, language);
std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS");
printf("%s %s\n", includeFlags.c_str(), definitions.c_str());
@@ -566,11 +552,9 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
tgt->SetProperty("LINKER_LANGUAGE", language.c_str());
std::string libs = mf->GetSafeDefinition("PACKAGE_LIBRARIES");
- std::vector<std::string> libList;
- cmSystemTools::ExpandListArgument(libs, libList);
- for (std::vector<std::string>::const_iterator libIt = libList.begin();
- libIt != libList.end(); ++libIt) {
- tgt->AddLinkLibrary(*mf, *libIt, GENERAL_LibraryType);
+ std::vector<std::string> libList = cmExpandedList(libs);
+ for (std::string const& lib : libList) {
+ tgt->AddLinkLibrary(*mf, lib, GENERAL_LibraryType);
}
std::string buildType = mf->GetSafeDefinition("CMAKE_BUILD_TYPE");
@@ -609,28 +593,76 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
return packageFound;
}
+void cmake::LoadEnvironmentPresets()
+{
+ std::string envGenVar;
+ bool hasEnvironmentGenerator = false;
+ if (cmSystemTools::GetEnv("CMAKE_GENERATOR", envGenVar)) {
+ hasEnvironmentGenerator = true;
+ this->EnvironmentGenerator = envGenVar;
+ }
+
+ auto readGeneratorVar = [&](std::string const& name, std::string& key) {
+ std::string varValue;
+ if (cmSystemTools::GetEnv(name, varValue)) {
+ if (hasEnvironmentGenerator) {
+ key = varValue;
+ } else if (!this->GetIsInTryCompile()) {
+ std::string message =
+ cmStrCat("Warning: Environment variable ", name,
+ " will be ignored, because CMAKE_GENERATOR is not set.");
+ cmSystemTools::Message(message, "Warning");
+ }
+ }
+ };
+
+ readGeneratorVar("CMAKE_GENERATOR_INSTANCE", this->GeneratorInstance);
+ readGeneratorVar("CMAKE_GENERATOR_PLATFORM", this->GeneratorPlatform);
+ readGeneratorVar("CMAKE_GENERATOR_TOOLSET", this->GeneratorToolset);
+}
+
// Parse the args
-void cmake::SetArgs(const std::vector<std::string>& args,
- bool directoriesSetBefore)
+void cmake::SetArgs(const std::vector<std::string>& args)
{
- bool directoriesSet = directoriesSetBefore;
bool haveToolset = false;
bool havePlatform = false;
for (unsigned int i = 1; i < args.size(); ++i) {
std::string const& arg = args[i];
- if (arg.find("-H", 0) == 0) {
- directoriesSet = true;
+ if (arg.find("-H", 0) == 0 || arg.find("-S", 0) == 0) {
std::string path = arg.substr(2);
+ if (path.empty()) {
+ ++i;
+ if (i >= args.size()) {
+ cmSystemTools::Error("No source directory specified for -S");
+ return;
+ }
+ path = args[i];
+ if (path[0] == '-') {
+ cmSystemTools::Error("No source directory specified for -S");
+ return;
+ }
+ }
+
path = cmSystemTools::CollapseFullPath(path);
cmSystemTools::ConvertToUnixSlashes(path);
this->SetHomeDirectory(path);
- } else if (arg.find("-S", 0) == 0) {
- // There is no local generate anymore. Ignore -S option.
} else if (arg.find("-O", 0) == 0) {
// There is no local generate anymore. Ignore -O option.
} else if (arg.find("-B", 0) == 0) {
- directoriesSet = true;
std::string path = arg.substr(2);
+ if (path.empty()) {
+ ++i;
+ if (i >= args.size()) {
+ cmSystemTools::Error("No build directory specified for -B");
+ return;
+ }
+ path = args[i];
+ if (path[0] == '-') {
+ cmSystemTools::Error("No build directory specified for -B");
+ return;
+ }
+ }
+
path = cmSystemTools::CollapseFullPath(path);
cmSystemTools::ConvertToUnixSlashes(path);
this->SetHomeOutputDirectory(path);
@@ -653,10 +685,25 @@ void cmake::SetArgs(const std::vector<std::string>& args,
#endif
else if (arg.find("-D", 0) == 0) {
// skip for now
+ // in case '-D var=val' is given, also skip the next
+ // in case '-Dvar=val' is given, don't skip the next
+ if (arg.size() == 2) {
+ ++i;
+ }
} else if (arg.find("-U", 0) == 0) {
// skip for now
+ // in case '-U var' is given, also skip the next
+ // in case '-Uvar' is given, don't skip the next
+ if (arg.size() == 2) {
+ ++i;
+ }
} else if (arg.find("-C", 0) == 0) {
// skip for now
+ // in case '-C path' is given, also skip the next
+ // in case '-Cpath' is given, don't skip the next
+ if (arg.size() == 2) {
+ ++i;
+ }
} else if (arg.find("-P", 0) == 0) {
// skip for now
i++;
@@ -672,6 +719,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
this->GraphVizFile = path;
if (this->GraphVizFile.empty()) {
cmSystemTools::Error("No file specified for --graphviz");
+ return;
}
} else if (arg.find("--debug-trycompile", 0) == 0) {
std::cout << "debug trycompile on\n";
@@ -679,6 +727,25 @@ void cmake::SetArgs(const std::vector<std::string>& args,
} else if (arg.find("--debug-output", 0) == 0) {
std::cout << "Running with debug output on.\n";
this->SetDebugOutputOn(true);
+ } else if (arg.find("--log-level=", 0) == 0) {
+ const auto logLevel =
+ StringToLogLevel(arg.substr(sizeof("--log-level=") - 1));
+ if (logLevel == LogLevel::LOG_UNDEFINED) {
+ cmSystemTools::Error("Invalid level specified for --log-level");
+ return;
+ }
+ this->SetLogLevel(logLevel);
+ } else if (arg.find("--loglevel=", 0) == 0) {
+ // This is supported for backward compatibility. This option only
+ // appeared in the 3.15.x release series and was renamed to
+ // --log-level in 3.16.0
+ const auto logLevel =
+ StringToLogLevel(arg.substr(sizeof("--loglevel=") - 1));
+ if (logLevel == LogLevel::LOG_UNDEFINED) {
+ cmSystemTools::Error("Invalid level specified for --loglevel");
+ return;
+ }
+ this->SetLogLevel(logLevel);
} else if (arg.find("--trace-expand", 0) == 0) {
std::cout << "Running with expanded trace output on.\n";
this->SetTrace(true);
@@ -688,6 +755,11 @@ void cmake::SetArgs(const std::vector<std::string>& args,
cmSystemTools::ConvertToUnixSlashes(file);
this->AddTraceSource(file);
this->SetTrace(true);
+ } else if (arg.find("--trace-redirect=", 0) == 0) {
+ std::string file = arg.substr(strlen("--trace-redirect="));
+ cmSystemTools::ConvertToUnixSlashes(file);
+ this->SetTraceFile(file);
+ this->SetTrace(true);
} else if (arg.find("--trace", 0) == 0) {
std::cout << "Running with trace output on.\n";
this->SetTrace(true);
@@ -720,7 +792,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
cmSystemTools::Error("Multiple -A options not allowed");
return;
}
- this->GeneratorPlatform = value;
+ this->SetGeneratorPlatform(value);
havePlatform = true;
} else if (arg.find("-T", 0) == 0) {
std::string value = arg.substr(2);
@@ -736,7 +808,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
cmSystemTools::Error("Multiple -T options not allowed");
return;
}
- this->GeneratorToolset = value;
+ this->SetGeneratorToolset(value);
haveToolset = true;
} else if (arg.find("-G", 0) == 0) {
std::string value = arg.substr(2);
@@ -751,26 +823,88 @@ void cmake::SetArgs(const std::vector<std::string>& args,
}
cmGlobalGenerator* gen = this->CreateGlobalGenerator(value);
if (!gen) {
- cmSystemTools::Error("Could not create named generator ",
- value.c_str());
+ std::string kdevError;
+ if (value.find("KDevelop3", 0) != std::string::npos) {
+ kdevError = "\nThe KDevelop3 generator is not supported anymore.";
+ }
+
+ cmSystemTools::Error(
+ cmStrCat("Could not create named generator ", value, kdevError));
this->PrintGeneratorList();
- } else {
- this->SetGlobalGenerator(gen);
+ return;
}
+ this->SetGlobalGenerator(gen);
}
- // no option assume it is the path to the source
+ // no option assume it is the path to the source or an existing build
else {
- directoriesSet = true;
- this->SetDirectoriesFromFile(arg.c_str());
+ this->SetDirectoriesFromFile(arg);
+ }
+ // Empty instance, platform and toolset if only a generator is specified
+ if (this->GlobalGenerator) {
+ this->GeneratorInstance = "";
+ if (!this->GeneratorPlatformSet) {
+ this->GeneratorPlatform = "";
+ }
+ if (!this->GeneratorToolsetSet) {
+ this->GeneratorToolset = "";
+ }
}
}
- if (!directoriesSet) {
- this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
+
+ const bool haveSourceDir = !this->GetHomeDirectory().empty();
+ const bool haveBinaryDir = !this->GetHomeOutputDirectory().empty();
+
+ if (this->CurrentWorkingMode == cmake::NORMAL_MODE && !haveSourceDir &&
+ !haveBinaryDir) {
+ this->IssueMessage(
+ MessageType::WARNING,
+ "No source or binary directory provided. Both will be assumed to be "
+ "the same as the current working directory, but note that this "
+ "warning will become a fatal error in future CMake releases.");
+ }
+
+ if (!haveSourceDir) {
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
}
+ if (!haveBinaryDir) {
+ this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
+ }
+}
+
+cmake::LogLevel cmake::StringToLogLevel(const std::string& levelStr)
+{
+ using LevelsPair = std::pair<std::string, LogLevel>;
+ static const std::vector<LevelsPair> levels = {
+ { "error", LogLevel::LOG_ERROR }, { "warning", LogLevel::LOG_WARNING },
+ { "notice", LogLevel::LOG_NOTICE }, { "status", LogLevel::LOG_STATUS },
+ { "verbose", LogLevel::LOG_VERBOSE }, { "debug", LogLevel::LOG_DEBUG },
+ { "trace", LogLevel::LOG_TRACE }
+ };
+
+ const auto levelStrLowCase = cmSystemTools::LowerCase(levelStr);
+
+ const auto it = std::find_if(levels.cbegin(), levels.cend(),
+ [&levelStrLowCase](const LevelsPair& p) {
+ return p.first == levelStrLowCase;
+ });
+ return (it != levels.cend()) ? it->second : LogLevel::LOG_UNDEFINED;
+}
+
+void cmake::SetTraceFile(const std::string& file)
+{
+ this->TraceFile.close();
+ this->TraceFile.open(file.c_str());
+ if (!this->TraceFile) {
+ std::stringstream ss;
+ ss << "Error opening trace file " << file << ": "
+ << cmSystemTools::GetLastSystemError();
+ cmSystemTools::Error(ss.str());
+ return;
+ }
+ std::cout << "Trace will be written to " << file << "\n";
}
-void cmake::SetDirectoriesFromFile(const char* arg)
+void cmake::SetDirectoriesFromFile(const std::string& arg)
{
// Check if the argument refers to a CMakeCache.txt or
// CMakeLists.txt file.
@@ -780,14 +914,12 @@ void cmake::SetDirectoriesFromFile(const char* arg)
if (cmSystemTools::FileIsDirectory(arg)) {
std::string path = cmSystemTools::CollapseFullPath(arg);
cmSystemTools::ConvertToUnixSlashes(path);
- std::string cacheFile = path;
- cacheFile += "/CMakeCache.txt";
- std::string listFile = path;
- listFile += "/CMakeLists.txt";
- if (cmSystemTools::FileExists(cacheFile.c_str())) {
+ std::string cacheFile = cmStrCat(path, "/CMakeCache.txt");
+ std::string listFile = cmStrCat(path, "/CMakeLists.txt");
+ if (cmSystemTools::FileExists(cacheFile)) {
cachePath = path;
}
- if (cmSystemTools::FileExists(listFile.c_str())) {
+ if (cmSystemTools::FileExists(listFile)) {
listPath = path;
}
} else if (cmSystemTools::FileExists(arg)) {
@@ -837,20 +969,27 @@ void cmake::SetDirectoriesFromFile(const char* arg)
this->SetHomeOutputDirectory(listPath);
} else {
// Source directory given on command line. Use current working
- // directory as build tree.
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- this->SetHomeOutputDirectory(cwd);
+ // directory as build tree if -B hasn't been given already
+ if (this->GetHomeOutputDirectory().empty()) {
+ std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
+ this->SetHomeOutputDirectory(cwd);
+ }
}
return;
}
- // We didn't find a CMakeLists.txt or CMakeCache.txt file from the
- // argument. Assume it is the path to the source tree, and use the
- // current working directory as the build tree.
- std::string full = cmSystemTools::CollapseFullPath(arg);
- std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- this->SetHomeDirectory(full);
- this->SetHomeOutputDirectory(cwd);
+ if (this->GetHomeDirectory().empty()) {
+ // We didn't find a CMakeLists.txt and it wasn't specified
+ // with -S. Assume it is the path to the source tree
+ std::string full = cmSystemTools::CollapseFullPath(arg);
+ this->SetHomeDirectory(full);
+ }
+ if (this->GetHomeOutputDirectory().empty()) {
+ // We didn't find a CMakeCache.txt and it wasn't specified
+ // with -B. Assume the current working directory as the build tree.
+ std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
+ this->SetHomeOutputDirectory(cwd);
+ }
}
// at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the
@@ -861,7 +1000,7 @@ int cmake::AddCMakePaths()
this->AddCacheEntry("CMAKE_COMMAND",
cmSystemTools::GetCMakeCommand().c_str(),
"Path to CMake executable.", cmStateEnums::INTERNAL);
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
this->AddCacheEntry(
"CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(),
"Path to ctest program executable.", cmStateEnums::INTERNAL);
@@ -870,13 +1009,13 @@ int cmake::AddCMakePaths()
"Path to cpack program executable.", cmStateEnums::INTERNAL);
#endif
if (!cmSystemTools::FileExists(
- (cmSystemTools::GetCMakeRoot() + "/Modules/CMake.cmake").c_str())) {
+ (cmSystemTools::GetCMakeRoot() + "/Modules/CMake.cmake"))) {
// couldn't find modules
cmSystemTools::Error(
"Could not find CMAKE_ROOT !!!\n"
"CMake has most likely not been installed correctly.\n"
- "Modules directory not found in\n",
- cmSystemTools::GetCMakeRoot().c_str());
+ "Modules directory not found in\n" +
+ cmSystemTools::GetCMakeRoot());
return 0;
}
this->AddCacheEntry("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(),
@@ -887,72 +1026,67 @@ int cmake::AddCMakePaths()
void cmake::AddDefaultExtraGenerators()
{
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
this->ExtraGenerators.push_back(cmExtraCodeBlocksGenerator::GetFactory());
this->ExtraGenerators.push_back(cmExtraCodeLiteGenerator::GetFactory());
this->ExtraGenerators.push_back(cmExtraSublimeTextGenerator::GetFactory());
this->ExtraGenerators.push_back(cmExtraKateGenerator::GetFactory());
-#ifdef CMAKE_USE_ECLIPSE
+# ifdef CMAKE_USE_ECLIPSE
this->ExtraGenerators.push_back(cmExtraEclipseCDT4Generator::GetFactory());
-#endif
+# endif
-#ifdef CMAKE_USE_KDEVELOP
- this->ExtraGenerators.push_back(cmGlobalKdevelopGenerator::GetFactory());
-#endif
#endif
}
-void cmake::GetRegisteredGenerators(
- std::vector<GeneratorInfo>& generators) const
+void cmake::GetRegisteredGenerators(std::vector<GeneratorInfo>& generators,
+ bool includeNamesWithPlatform) const
{
- for (RegisteredGeneratorsVector::const_iterator i = this->Generators.begin(),
- e = this->Generators.end();
- i != e; ++i) {
- std::vector<std::string> names;
- (*i)->GetGenerators(names);
+ for (cmGlobalGeneratorFactory* gen : this->Generators) {
+ std::vector<std::string> names = gen->GetGeneratorNames();
+
+ if (includeNamesWithPlatform) {
+ cmAppend(names, gen->GetGeneratorNamesWithPlatform());
+ }
- for (size_t j = 0; j < names.size(); ++j) {
+ for (std::string const& name : names) {
GeneratorInfo info;
- info.supportsToolset = (*i)->SupportsToolset();
- info.supportsPlatform = (*i)->SupportsPlatform();
- info.name = names[j];
- info.baseName = names[j];
+ info.supportsToolset = gen->SupportsToolset();
+ info.supportsPlatform = gen->SupportsPlatform();
+ info.supportedPlatforms = gen->GetKnownPlatforms();
+ info.defaultPlatform = gen->GetDefaultPlatformName();
+ info.name = name;
+ info.baseName = name;
info.isAlias = false;
- generators.push_back(info);
+ generators.push_back(std::move(info));
}
}
- for (RegisteredExtraGeneratorsVector::const_iterator
- i = this->ExtraGenerators.begin(),
- e = this->ExtraGenerators.end();
- i != e; ++i) {
+ for (cmExternalMakefileProjectGeneratorFactory* eg : this->ExtraGenerators) {
const std::vector<std::string> genList =
- (*i)->GetSupportedGlobalGenerators();
- for (std::vector<std::string>::const_iterator gen = genList.begin();
- gen != genList.end(); ++gen) {
+ eg->GetSupportedGlobalGenerators();
+ for (std::string const& gen : genList) {
GeneratorInfo info;
info.name = cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
- *gen, (*i)->GetName());
- info.baseName = *gen;
- info.extraName = (*i)->GetName();
+ gen, eg->GetName());
+ info.baseName = gen;
+ info.extraName = eg->GetName();
info.supportsPlatform = false;
info.supportsToolset = false;
info.isAlias = false;
- generators.push_back(info);
+ generators.push_back(std::move(info));
}
- for (std::vector<std::string>::const_iterator a = (*i)->Aliases.begin();
- a != (*i)->Aliases.end(); ++a) {
+ for (std::string const& a : eg->Aliases) {
GeneratorInfo info;
- info.name = *a;
+ info.name = a;
if (!genList.empty()) {
info.baseName = genList.at(0);
}
- info.extraName = (*i)->GetName();
+ info.extraName = eg->GetName();
info.supportsPlatform = false;
info.supportsToolset = false;
info.isAlias = true;
- generators.push_back(info);
+ generators.push_back(std::move(info));
}
}
}
@@ -962,28 +1096,22 @@ createExtraGenerator(
const std::vector<cmExternalMakefileProjectGeneratorFactory*>& in,
const std::string& name)
{
- for (std::vector<cmExternalMakefileProjectGeneratorFactory*>::const_iterator
- i = in.begin();
- i != in.end(); ++i) {
+ for (cmExternalMakefileProjectGeneratorFactory* i : in) {
const std::vector<std::string> generators =
- (*i)->GetSupportedGlobalGenerators();
- if ((*i)->GetName() == name) { // Match aliases
- return std::make_pair((*i)->CreateExternalMakefileProjectGenerator(),
- generators.at(0));
+ i->GetSupportedGlobalGenerators();
+ if (i->GetName() == name) { // Match aliases
+ return { i->CreateExternalMakefileProjectGenerator(), generators.at(0) };
}
- for (std::vector<std::string>::const_iterator g = generators.begin();
- g != generators.end(); ++g) {
+ for (std::string const& g : generators) {
const std::string fullName =
cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
- *g, (*i)->GetName());
+ g, i->GetName());
if (fullName == name) {
- return std::make_pair((*i)->CreateExternalMakefileProjectGenerator(),
- *g);
+ return { i->CreateExternalMakefileProjectGenerator(), g };
}
}
}
- return std::make_pair(
- static_cast<cmExternalMakefileProjectGenerator*>(CM_NULLPTR), name);
+ return { nullptr, name };
}
cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname)
@@ -993,10 +1121,9 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname)
cmExternalMakefileProjectGenerator* extraGenerator = extra.first;
const std::string name = extra.second;
- cmGlobalGenerator* generator = CM_NULLPTR;
- for (RegisteredGeneratorsVector::const_iterator i = this->Generators.begin();
- i != this->Generators.end(); ++i) {
- generator = (*i)->CreateGlobalGenerator(name, this);
+ cmGlobalGenerator* generator = nullptr;
+ for (cmGlobalGeneratorFactory* g : this->Generators) {
+ generator = g->CreateGlobalGenerator(name, this);
if (generator) {
break;
}
@@ -1019,7 +1146,7 @@ void cmake::SetHomeDirectory(const std::string& dir)
}
}
-const char* cmake::GetHomeDirectory() const
+std::string const& cmake::GetHomeDirectory() const
{
return this->State->GetSourceDirectory();
}
@@ -1032,7 +1159,7 @@ void cmake::SetHomeOutputDirectory(const std::string& dir)
}
}
-const char* cmake::GetHomeOutputDirectory() const
+std::string const& cmake::GetHomeOutputDirectory() const
{
return this->State->GetBinaryDirectory();
}
@@ -1041,16 +1168,14 @@ std::string cmake::FindCacheFile(const std::string& binaryDir)
{
std::string cachePath = binaryDir;
cmSystemTools::ConvertToUnixSlashes(cachePath);
- std::string cacheFile = cachePath;
- cacheFile += "/CMakeCache.txt";
- if (!cmSystemTools::FileExists(cacheFile.c_str())) {
+ std::string cacheFile = cmStrCat(cachePath, "/CMakeCache.txt");
+ if (!cmSystemTools::FileExists(cacheFile)) {
// search in parent directories for cache
- std::string cmakeFiles = cachePath;
- cmakeFiles += "/CMakeFiles";
- if (cmSystemTools::FileExists(cmakeFiles.c_str())) {
+ std::string cmakeFiles = cmStrCat(cachePath, "/CMakeFiles");
+ if (cmSystemTools::FileExists(cmakeFiles)) {
std::string cachePathFound =
cmSystemTools::FileExistsInParentDirectories("CMakeCache.txt",
- cachePath.c_str(), "/");
+ cachePath, "/");
if (!cachePathFound.empty()) {
cachePath = cmSystemTools::GetFilenamePath(cachePathFound);
}
@@ -1091,19 +1216,18 @@ void cmake::SetGlobalGenerator(cmGlobalGenerator* gg)
// Save the environment variables CXX and CC
if (!cmSystemTools::GetEnv("CXX", this->CXXEnvironment)) {
- this->CXXEnvironment = "";
+ this->CXXEnvironment.clear();
}
if (!cmSystemTools::GetEnv("CC", this->CCEnvironment)) {
- this->CCEnvironment = "";
+ this->CCEnvironment.clear();
}
}
int cmake::DoPreConfigureChecks()
{
// Make sure the Source directory contains a CMakeLists.txt file.
- std::string srcList = this->GetHomeDirectory();
- srcList += "/CMakeLists.txt";
- if (!cmSystemTools::FileExists(srcList.c_str())) {
+ std::string srcList = cmStrCat(this->GetHomeDirectory(), "/CMakeLists.txt");
+ if (!cmSystemTools::FileExists(srcList)) {
std::ostringstream err;
if (cmSystemTools::FileIsDirectory(this->GetHomeDirectory())) {
err << "The source directory \"" << this->GetHomeDirectory()
@@ -1117,25 +1241,24 @@ int cmake::DoPreConfigureChecks()
}
err << "Specify --help for usage, or press the help button on the CMake "
"GUI.";
- cmSystemTools::Error(err.str().c_str());
+ cmSystemTools::Error(err.str());
return -2;
}
// do a sanity check on some values
if (this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) {
std::string cacheStart =
- this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY");
- cacheStart += "/CMakeLists.txt";
- std::string currentStart = this->GetHomeDirectory();
- currentStart += "/CMakeLists.txt";
+ cmStrCat(*this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"),
+ "/CMakeLists.txt");
+ std::string currentStart =
+ cmStrCat(this->GetHomeDirectory(), "/CMakeLists.txt");
if (!cmSystemTools::SameFile(cacheStart, currentStart)) {
- std::string message = "The source \"";
- message += currentStart;
- message += "\" does not match the source \"";
- message += cacheStart;
- message += "\" used to generate cache. ";
- message += "Re-run cmake with a different source directory.";
- cmSystemTools::Error(message.c_str());
+ std::string message =
+ cmStrCat("The source \"", currentStart,
+ "\" does not match the source \"", cacheStart,
+ "\" used to generate cache. Re-run cmake with a different "
+ "source directory.");
+ cmSystemTools::Error(message);
return -2;
}
} else {
@@ -1153,8 +1276,7 @@ struct SaveCacheEntry
int cmake::HandleDeleteCacheVariables(const std::string& var)
{
- std::vector<std::string> argsSplit;
- cmSystemTools::ExpandListArgument(std::string(var), argsSplit, true);
+ std::vector<std::string> argsSplit = cmExpandedList(std::string(var), true);
// erase the property to avoid infinite recursion
this->State->SetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_", "");
if (this->State->GetIsInTryCompile()) {
@@ -1168,8 +1290,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
<< "Configure will be re-run and you may have to reset some variables.\n"
<< "The following variables have changed:\n";
/* clang-format on */
- for (std::vector<std::string>::iterator i = argsSplit.begin();
- i != argsSplit.end(); ++i) {
+ for (auto i = argsSplit.begin(); i != argsSplit.end(); ++i) {
SaveCacheEntry save;
save.key = *i;
warning << *i << "= ";
@@ -1184,7 +1305,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
save.help = help;
}
}
- saved.push_back(save);
+ saved.push_back(std::move(save));
}
// remove the cache
@@ -1192,11 +1313,10 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
// load the empty cache
this->LoadCache();
// restore the changed compilers
- for (std::vector<SaveCacheEntry>::iterator i = saved.begin();
- i != saved.end(); ++i) {
- this->AddCacheEntry(i->key, i->value.c_str(), i->help.c_str(), i->type);
+ for (SaveCacheEntry const& i : saved) {
+ this->AddCacheEntry(i.key, i.value.c_str(), i.help.c_str(), i.type);
}
- cmSystemTools::Message(warning.str().c_str());
+ cmSystemTools::Message(warning.str());
// avoid reconfigure if there were errors
if (!cmSystemTools::GetErrorOccuredFlag()) {
// re-run configure
@@ -1265,6 +1385,21 @@ int cmake::Configure()
}
}
+ // Cache variables may have already been set by a previous invocation,
+ // so we cannot rely on command line options alone. Always ensure our
+ // messenger is in sync with the cache.
+ const char* value = this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED");
+ this->Messenger->SetSuppressDeprecatedWarnings(value && cmIsOff(value));
+
+ value = this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED");
+ this->Messenger->SetDeprecatedWarningsAsErrors(cmIsOn(value));
+
+ value = this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
+ this->Messenger->SetSuppressDevWarnings(cmIsOn(value));
+
+ value = this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_ERRORS");
+ this->Messenger->SetDevWarningsAsErrors(value && cmIsOff(value));
+
int ret = this->ActualConfigure();
const char* delCacheVars =
this->State->GetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_");
@@ -1280,16 +1415,13 @@ int cmake::ActualConfigure()
this->UpdateConversionPathTable();
this->CleanupCommandsAndMacros();
- int res = 0;
- if (this->GetWorkingMode() == NORMAL_MODE) {
- res = this->DoPreConfigureChecks();
- }
+ int res = this->DoPreConfigureChecks();
if (res < 0) {
return -2;
}
if (!res) {
this->AddCacheEntry(
- "CMAKE_HOME_DIRECTORY", this->GetHomeDirectory(),
+ "CMAKE_HOME_DIRECTORY", this->GetHomeDirectory().c_str(),
"Source directory with the top level CMakeLists.txt file for this "
"project",
cmStateEnums::INTERNAL);
@@ -1297,14 +1429,14 @@ int cmake::ActualConfigure()
// no generator specified on the command line
if (!this->GlobalGenerator) {
- const char* genName =
+ const std::string* genName =
this->State->GetInitializedCacheValue("CMAKE_GENERATOR");
- const char* extraGenName =
+ const std::string* extraGenName =
this->State->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
if (genName) {
std::string fullName =
cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
- genName, extraGenName ? extraGenName : "");
+ *genName, extraGenName ? *extraGenName : "");
this->GlobalGenerator = this->CreateGlobalGenerator(fullName);
}
if (this->GlobalGenerator) {
@@ -1322,17 +1454,16 @@ int cmake::ActualConfigure()
}
}
- const char* genName =
+ const std::string* genName =
this->State->GetInitializedCacheValue("CMAKE_GENERATOR");
if (genName) {
- if (!this->GlobalGenerator->MatchesGeneratorName(genName)) {
- std::string message = "Error: generator : ";
- message += this->GlobalGenerator->GetName();
- message += "\nDoes not match the generator used previously: ";
- message += genName;
- message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
- "directory or choose a different binary directory.";
- cmSystemTools::Error(message.c_str());
+ if (!this->GlobalGenerator->MatchesGeneratorName(*genName)) {
+ std::string message =
+ cmStrCat("Error: generator : ", this->GlobalGenerator->GetName(),
+ "\nDoes not match the generator used previously: ", *genName,
+ "\nEither remove the CMakeCache.txt file and CMakeFiles "
+ "directory or choose a different binary directory.");
+ cmSystemTools::Error(message);
return -2;
}
}
@@ -1346,18 +1477,33 @@ int cmake::ActualConfigure()
cmStateEnums::INTERNAL);
}
- if (const char* platformName =
+ if (const std::string* instance =
+ this->State->GetInitializedCacheValue("CMAKE_GENERATOR_INSTANCE")) {
+ if (this->GeneratorInstanceSet && this->GeneratorInstance != *instance) {
+ std::string message =
+ cmStrCat("Error: generator instance: ", this->GeneratorInstance,
+ "\nDoes not match the instance used previously: ", *instance,
+ "\nEither remove the CMakeCache.txt file and CMakeFiles "
+ "directory or choose a different binary directory.");
+ cmSystemTools::Error(message);
+ return -2;
+ }
+ } else {
+ this->AddCacheEntry(
+ "CMAKE_GENERATOR_INSTANCE", this->GeneratorInstance.c_str(),
+ "Generator instance identifier.", cmStateEnums::INTERNAL);
+ }
+
+ if (const std::string* platformName =
this->State->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM")) {
- if (this->GeneratorPlatform.empty()) {
- this->GeneratorPlatform = platformName;
- } else if (this->GeneratorPlatform != platformName) {
- std::string message = "Error: generator platform: ";
- message += this->GeneratorPlatform;
- message += "\nDoes not match the platform used previously: ";
- message += platformName;
- message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
- "directory or choose a different binary directory.";
- cmSystemTools::Error(message.c_str());
+ if (this->GeneratorPlatformSet &&
+ this->GeneratorPlatform != *platformName) {
+ std::string message = cmStrCat(
+ "Error: generator platform: ", this->GeneratorPlatform,
+ "\nDoes not match the platform used previously: ", *platformName,
+ "\nEither remove the CMakeCache.txt file and CMakeFiles "
+ "directory or choose a different binary directory.");
+ cmSystemTools::Error(message);
return -2;
}
} else {
@@ -1366,18 +1512,15 @@ int cmake::ActualConfigure()
"Name of generator platform.", cmStateEnums::INTERNAL);
}
- if (const char* tsName =
+ if (const std::string* tsName =
this->State->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET")) {
- if (this->GeneratorToolset.empty()) {
- this->GeneratorToolset = tsName;
- } else if (this->GeneratorToolset != tsName) {
- std::string message = "Error: generator toolset: ";
- message += this->GeneratorToolset;
- message += "\nDoes not match the toolset used previously: ";
- message += tsName;
- message += "\nEither remove the CMakeCache.txt file and CMakeFiles "
- "directory or choose a different binary directory.";
- cmSystemTools::Error(message.c_str());
+ if (this->GeneratorToolsetSet && this->GeneratorToolset != *tsName) {
+ std::string message =
+ cmStrCat("Error: generator toolset: ", this->GeneratorToolset,
+ "\nDoes not match the toolset used previously: ", *tsName,
+ "\nEither remove the CMakeCache.txt file and CMakeFiles "
+ "directory or choose a different binary directory.");
+ cmSystemTools::Error(message);
return -2;
}
} else {
@@ -1396,6 +1539,11 @@ int cmake::ActualConfigure()
this->TruncateOutputLog("CMakeError.log");
}
+#if !defined(CMAKE_BOOTSTRAP)
+ this->FileAPI = cm::make_unique<cmFileAPI>(this);
+ this->FileAPI->ReadQueries();
+#endif
+
// actually do the configure
this->GlobalGenerator->Configure();
// Before saving the cache
@@ -1433,18 +1581,26 @@ int cmake::ActualConfigure()
"CMakeLists.txt ?");
}
- // only save the cache if there were no fatal errors
- if (this->GetWorkingMode() == NORMAL_MODE) {
- this->SaveCache(this->GetHomeOutputDirectory());
- }
+ this->State->SaveVerificationScript(this->GetHomeOutputDirectory());
+ this->SaveCache(this->GetHomeOutputDirectory());
if (cmSystemTools::GetErrorOccuredFlag()) {
return -1;
}
return 0;
}
-void cmake::CreateDefaultGlobalGenerator()
+std::unique_ptr<cmGlobalGenerator> cmake::EvaluateDefaultGlobalGenerator()
{
+ if (!this->EnvironmentGenerator.empty()) {
+ cmGlobalGenerator* gen =
+ this->CreateGlobalGenerator(this->EnvironmentGenerator);
+ if (!gen) {
+ cmSystemTools::Error("CMAKE_GENERATOR was set but the specified "
+ "generator doesn't exist. Using CMake default.");
+ } else {
+ return std::unique_ptr<cmGlobalGenerator>(gen);
+ }
+ }
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW)
std::string found;
// Try to find the newest VS installed on the computer and
@@ -1460,28 +1616,27 @@ void cmake::CreateDefaultGlobalGenerator()
const char* GeneratorName;
};
static VSVersionedGenerator const vsGenerators[] = {
- { "15.0", "Visual Studio 15 2017" }, //
{ "14.0", "Visual Studio 14 2015" }, //
{ "12.0", "Visual Studio 12 2013" }, //
{ "11.0", "Visual Studio 11 2012" }, //
{ "10.0", "Visual Studio 10 2010" }, //
- { "9.0", "Visual Studio 9 2008" }, //
- { "8.0", "Visual Studio 8 2005" }
+ { "9.0", "Visual Studio 9 2008" }
};
static const char* const vsEntries[] = {
"\\Setup\\VC;ProductDir", //
";InstallDir" //
};
- cmVSSetupAPIHelper vsSetupAPIHelper;
- if (vsSetupAPIHelper.IsVS2017Installed()) {
+ if (cmVSSetupAPIHelper(16).IsVSInstalled()) {
+ found = "Visual Studio 16 2019";
+ } else if (cmVSSetupAPIHelper(15).IsVSInstalled()) {
found = "Visual Studio 15 2017";
} else {
- for (VSVersionedGenerator const* g = cmArrayBegin(vsGenerators);
- found.empty() && g != cmArrayEnd(vsGenerators); ++g) {
- for (const char* const* v = cmArrayBegin(vsVariants);
- found.empty() && v != cmArrayEnd(vsVariants); ++v) {
- for (const char* const* e = cmArrayBegin(vsEntries);
- found.empty() && e != cmArrayEnd(vsEntries); ++e) {
+ for (VSVersionedGenerator const* g = cm::cbegin(vsGenerators);
+ found.empty() && g != cm::cend(vsGenerators); ++g) {
+ for (const char* const* v = cm::cbegin(vsVariants);
+ found.empty() && v != cm::cend(vsVariants); ++v) {
+ for (const char* const* e = cm::cbegin(vsEntries);
+ found.empty() && e != cm::cend(vsEntries); ++e) {
std::string const reg = vsregBase + *v + g->MSVersion + *e;
std::string dir;
if (cmSystemTools::ReadRegistryValue(reg, dir,
@@ -1497,11 +1652,20 @@ void cmake::CreateDefaultGlobalGenerator()
if (!gen) {
gen = new cmGlobalNMakeMakefileGenerator(this);
}
- this->SetGlobalGenerator(gen);
- std::cout << "-- Building for: " << gen->GetName() << "\n";
+ return std::unique_ptr<cmGlobalGenerator>(gen);
#else
- this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator3(this));
+ return cm::make_unique<cmGlobalUnixMakefileGenerator3>(this);
+#endif
+}
+
+void cmake::CreateDefaultGlobalGenerator()
+{
+ auto gen = this->EvaluateDefaultGlobalGenerator();
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW)
+ // This print could be unified for all platforms
+ std::cout << "-- Building for: " << gen->GetName() << "\n";
#endif
+ this->SetGlobalGenerator(gen.release());
}
void cmake::PreLoadCMakeFiles()
@@ -1510,15 +1674,15 @@ void cmake::PreLoadCMakeFiles()
std::string pre_load = this->GetHomeDirectory();
if (!pre_load.empty()) {
pre_load += "/PreLoad.cmake";
- if (cmSystemTools::FileExists(pre_load.c_str())) {
- this->ReadListFile(args, pre_load.c_str());
+ if (cmSystemTools::FileExists(pre_load)) {
+ this->ReadListFile(args, pre_load);
}
}
pre_load = this->GetHomeOutputDirectory();
if (!pre_load.empty()) {
pre_load += "/PreLoad.cmake";
- if (cmSystemTools::FileExists(pre_load.c_str())) {
- this->ReadListFile(args, pre_load.c_str());
+ if (cmSystemTools::FileExists(pre_load)) {
+ this->ReadListFile(args, pre_load);
}
}
}
@@ -1534,13 +1698,13 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
// If we are given a stamp list file check if it is really out of date.
if (!this->CheckStampList.empty() &&
- cmakeCheckStampList(this->CheckStampList.c_str())) {
+ cmakeCheckStampList(this->CheckStampList)) {
return 0;
}
// If we are given a stamp file check if it is really out of date.
if (!this->CheckStampFile.empty() &&
- cmakeCheckStampFile(this->CheckStampFile.c_str())) {
+ cmakeCheckStampFile(this->CheckStampFile)) {
return 0;
}
@@ -1590,7 +1754,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
}
int ret = this->Configure();
- if (ret || this->GetWorkingMode() != NORMAL_MODE) {
+ if (ret) {
#if defined(CMAKE_HAVE_VS_GENERATORS)
if (!this->VSSolutionFile.empty() && this->GlobalGenerator) {
// CMake is running to regenerate a Visual Studio build tree
@@ -1602,15 +1766,20 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
cmGlobalVisualStudioGenerator* gg =
static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator);
gg->CallVisualStudioMacro(cmGlobalVisualStudioGenerator::MacroStop,
- this->VSSolutionFile.c_str());
+ this->VSSolutionFile);
}
#endif
return ret;
}
ret = this->Generate();
- std::string message = "Build files have been written to: ";
- message += this->GetHomeOutputDirectory();
- this->UpdateProgress(message.c_str(), -1);
+ if (ret) {
+ cmSystemTools::Message("CMake Generate step failed. "
+ "Build files cannot be regenerated correctly.");
+ return ret;
+ }
+ std::string message = cmStrCat("Build files have been written to: ",
+ this->GetHomeOutputDirectory());
+ this->UpdateProgress(message, -1);
return ret;
}
@@ -1625,7 +1794,7 @@ int cmake::Generate()
this->GlobalGenerator->Generate();
if (!this->GraphVizFile.empty()) {
std::cout << "Generate graphviz: " << this->GraphVizFile << std::endl;
- this->GenerateGraphViz(this->GraphVizFile.c_str());
+ this->GenerateGraphViz(this->GraphVizFile);
}
if (this->WarnUnusedCli) {
this->RunCheckForUnusedVariables();
@@ -1636,9 +1805,12 @@ int cmake::Generate()
// Save the cache again after a successful Generate so that any internal
// variables created during Generate are saved. (Specifically target GUIDs
// for the Visual Studio and Xcode generators.)
- if (this->GetWorkingMode() == NORMAL_MODE) {
- this->SaveCache(this->GetHomeOutputDirectory());
- }
+ this->SaveCache(this->GetHomeOutputDirectory());
+
+#if !defined(CMAKE_BOOTSTRAP)
+ this->FileAPI->WriteReplies();
+#endif
+
return 0;
}
@@ -1648,44 +1820,101 @@ void cmake::AddCacheEntry(const std::string& key, const char* value,
this->State->AddCacheEntry(key, value, helpString,
cmStateEnums::CacheEntryType(type));
this->UnwatchUnusedCli(key);
+
+ if (key == "CMAKE_WARN_DEPRECATED") {
+ this->Messenger->SetSuppressDeprecatedWarnings(value && cmIsOff(value));
+ } else if (key == "CMAKE_ERROR_DEPRECATED") {
+ this->Messenger->SetDeprecatedWarningsAsErrors(cmIsOn(value));
+ } else if (key == "CMAKE_SUPPRESS_DEVELOPER_WARNINGS") {
+ this->Messenger->SetSuppressDevWarnings(cmIsOn(value));
+ } else if (key == "CMAKE_SUPPRESS_DEVELOPER_ERRORS") {
+ this->Messenger->SetDevWarningsAsErrors(value && cmIsOff(value));
+ }
+}
+
+bool cmake::DoWriteGlobVerifyTarget() const
+{
+ return this->State->DoWriteGlobVerifyTarget();
+}
+
+std::string const& cmake::GetGlobVerifyScript() const
+{
+ return this->State->GetGlobVerifyScript();
+}
+
+std::string const& cmake::GetGlobVerifyStamp() const
+{
+ return this->State->GetGlobVerifyStamp();
+}
+
+void cmake::AddGlobCacheEntry(bool recurse, bool listDirectories,
+ bool followSymlinks, const std::string& relative,
+ const std::string& expression,
+ const std::vector<std::string>& files,
+ const std::string& variable,
+ cmListFileBacktrace const& backtrace)
+{
+ this->State->AddGlobCacheEntry(recurse, listDirectories, followSymlinks,
+ relative, expression, files, variable,
+ backtrace);
+}
+
+std::string cmake::StripExtension(const std::string& file) const
+{
+ auto dotpos = file.rfind('.');
+ if (dotpos != std::string::npos) {
+ auto ext = file.substr(dotpos + 1);
+#if defined(_WIN32) || defined(__APPLE__)
+ ext = cmSystemTools::LowerCase(ext);
+#endif
+ if (this->IsSourceExtension(ext) || this->IsHeaderExtension(ext)) {
+ return file.substr(0, dotpos);
+ }
+ }
+ return file;
}
const char* cmake::GetCacheDefinition(const std::string& name) const
{
- return this->State->GetInitializedCacheValue(name);
+ const std::string* p = this->State->GetInitializedCacheValue(name);
+ return p ? p->c_str() : nullptr;
}
void cmake::AddScriptingCommands()
{
- GetScriptingCommands(this->State);
+ GetScriptingCommands(this->GetState());
}
void cmake::AddProjectCommands()
{
- GetProjectCommands(this->State);
+ GetProjectCommands(this->GetState());
}
void cmake::AddDefaultGenerators()
{
#if defined(_WIN32) && !defined(__CYGWIN__)
-#if !defined(CMAKE_BOOT_MINGW)
- this->Generators.push_back(cmGlobalVisualStudio15Generator::NewFactory());
+# if !defined(CMAKE_BOOT_MINGW)
+ this->Generators.push_back(
+ cmGlobalVisualStudioVersionedGenerator::NewFactory16());
+ this->Generators.push_back(
+ cmGlobalVisualStudioVersionedGenerator::NewFactory15());
this->Generators.push_back(cmGlobalVisualStudio14Generator::NewFactory());
this->Generators.push_back(cmGlobalVisualStudio12Generator::NewFactory());
this->Generators.push_back(cmGlobalVisualStudio11Generator::NewFactory());
this->Generators.push_back(cmGlobalVisualStudio10Generator::NewFactory());
this->Generators.push_back(cmGlobalVisualStudio9Generator::NewFactory());
- this->Generators.push_back(cmGlobalVisualStudio8Generator::NewFactory());
this->Generators.push_back(cmGlobalBorlandMakefileGenerator::NewFactory());
this->Generators.push_back(cmGlobalNMakeMakefileGenerator::NewFactory());
this->Generators.push_back(cmGlobalJOMMakefileGenerator::NewFactory());
- this->Generators.push_back(cmGlobalGhsMultiGenerator::NewFactory());
-#endif
+# endif
this->Generators.push_back(cmGlobalMSYSMakefileGenerator::NewFactory());
this->Generators.push_back(cmGlobalMinGWMakefileGenerator::NewFactory());
#endif
this->Generators.push_back(cmGlobalUnixMakefileGenerator3::NewFactory());
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
+# if defined(__linux__) || defined(_WIN32)
+ this->Generators.push_back(cmGlobalGhsMultiGenerator::NewFactory());
+# endif
this->Generators.push_back(cmGlobalNinjaGenerator::NewFactory());
#endif
#if defined(CMAKE_USE_WMAKE)
@@ -1708,9 +1937,9 @@ int cmake::LoadCache()
// could we not read the cache
if (!this->LoadCache(this->GetHomeOutputDirectory())) {
// if it does exist, but isn't readable then warn the user
- std::string cacheFile = this->GetHomeOutputDirectory();
- cacheFile += "/CMakeCache.txt";
- if (cmSystemTools::FileExists(cacheFile.c_str())) {
+ std::string cacheFile =
+ cmStrCat(this->GetHomeOutputDirectory(), "/CMakeCache.txt");
+ if (cmSystemTools::FileExists(cacheFile)) {
cmSystemTools::Error(
"There is a CMakeCache.txt file for the current binary tree but "
"cmake does not have permission to read it. Please check the "
@@ -1737,25 +1966,23 @@ bool cmake::LoadCache(const std::string& path, bool internal,
std::set<std::string>& includes)
{
bool result = this->State->LoadCache(path, internal, excludes, includes);
- static const char* entries[] = { "CMAKE_CACHE_MAJOR_VERSION",
- "CMAKE_CACHE_MINOR_VERSION" };
- for (const char* const* nameIt = cmArrayBegin(entries);
- nameIt != cmArrayEnd(entries); ++nameIt) {
- this->UnwatchUnusedCli(*nameIt);
+ static const auto entries = { "CMAKE_CACHE_MAJOR_VERSION",
+ "CMAKE_CACHE_MINOR_VERSION" };
+ for (auto const& entry : entries) {
+ this->UnwatchUnusedCli(entry);
}
return result;
}
bool cmake::SaveCache(const std::string& path)
{
- bool result = this->State->SaveCache(path);
- static const char* entries[] = { "CMAKE_CACHE_MAJOR_VERSION",
- "CMAKE_CACHE_MINOR_VERSION",
- "CMAKE_CACHE_PATCH_VERSION",
- "CMAKE_CACHEFILE_DIR" };
- for (const char* const* nameIt = cmArrayBegin(entries);
- nameIt != cmArrayEnd(entries); ++nameIt) {
- this->UnwatchUnusedCli(*nameIt);
+ bool result = this->State->SaveCache(path, this->GetMessenger());
+ static const auto entries = { "CMAKE_CACHE_MAJOR_VERSION",
+ "CMAKE_CACHE_MINOR_VERSION",
+ "CMAKE_CACHE_PATCH_VERSION",
+ "CMAKE_CACHEFILE_DIR" };
+ for (auto const& entry : entries) {
+ this->UnwatchUnusedCli(entry);
}
return result;
}
@@ -1765,17 +1992,15 @@ bool cmake::DeleteCache(const std::string& path)
return this->State->DeleteCache(path);
}
-void cmake::SetProgressCallback(ProgressCallbackType f, void* cd)
+void cmake::SetProgressCallback(ProgressCallbackType f)
{
- this->ProgressCallback = f;
- this->ProgressCallbackClientData = cd;
+ this->ProgressCallback = std::move(f);
}
-void cmake::UpdateProgress(const char* msg, float prog)
+void cmake::UpdateProgress(const std::string& msg, float prog)
{
if (this->ProgressCallback && !this->State->GetIsInTryCompile()) {
- (*this->ProgressCallback)(msg, prog, this->ProgressCallbackClientData);
- return;
+ this->ProgressCallback(msg, prog);
}
}
@@ -1789,49 +2014,65 @@ void cmake::SetIsInTryCompile(bool b)
this->State->SetIsInTryCompile(b);
}
-void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
+void cmake::AppendGlobalGeneratorsDocumentation(
+ std::vector<cmDocumentationEntry>& v)
{
- for (RegisteredGeneratorsVector::const_iterator i = this->Generators.begin();
- i != this->Generators.end(); ++i) {
+ const auto defaultGenerator = this->EvaluateDefaultGlobalGenerator();
+ const std::string defaultName = defaultGenerator->GetName();
+ bool foundDefaultOne = false;
+
+ for (cmGlobalGeneratorFactory* g : this->Generators) {
cmDocumentationEntry e;
- (*i)->GetDocumentation(e);
- v.push_back(e);
+ g->GetDocumentation(e);
+ if (!foundDefaultOne && cmHasPrefix(e.Name, defaultName)) {
+ e.CustomNamePrefix = '*';
+ foundDefaultOne = true;
+ }
+ v.push_back(std::move(e));
}
- for (RegisteredExtraGeneratorsVector::const_iterator i =
- this->ExtraGenerators.begin();
- i != this->ExtraGenerators.end(); ++i) {
- const std::string doc = (*i)->GetDocumentation();
- const std::string name = (*i)->GetName();
+}
+
+void cmake::AppendExtraGeneratorsDocumentation(
+ std::vector<cmDocumentationEntry>& v)
+{
+ for (cmExternalMakefileProjectGeneratorFactory* eg : this->ExtraGenerators) {
+ const std::string doc = eg->GetDocumentation();
+ const std::string name = eg->GetName();
// Aliases:
- for (std::vector<std::string>::const_iterator a = (*i)->Aliases.begin();
- a != (*i)->Aliases.end(); ++a) {
+ for (std::string const& a : eg->Aliases) {
cmDocumentationEntry e;
- e.Name = *a;
+ e.Name = a;
e.Brief = doc;
- v.push_back(e);
+ v.push_back(std::move(e));
}
// Full names:
const std::vector<std::string> generators =
- (*i)->GetSupportedGlobalGenerators();
- for (std::vector<std::string>::const_iterator g = generators.begin();
- g != generators.end(); ++g) {
+ eg->GetSupportedGlobalGenerators();
+ for (std::string const& g : generators) {
cmDocumentationEntry e;
e.Name =
- cmExternalMakefileProjectGenerator::CreateFullGeneratorName(*g, name);
+ cmExternalMakefileProjectGenerator::CreateFullGeneratorName(g, name);
e.Brief = doc;
- v.push_back(e);
+ v.push_back(std::move(e));
}
}
}
+std::vector<cmDocumentationEntry> cmake::GetGeneratorsDocumentation()
+{
+ std::vector<cmDocumentationEntry> v;
+ this->AppendGlobalGeneratorsDocumentation(v);
+ this->AppendExtraGeneratorsDocumentation(v);
+ return v;
+}
+
void cmake::PrintGeneratorList()
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmDocumentation doc;
- std::vector<cmDocumentationEntry> generators;
- this->GetGeneratorDocumentation(generators);
+ auto generators = this->GetGeneratorsDocumentation();
doc.AppendSection("Generators", generators);
std::cerr << "\n";
doc.PrintDocumentation(cmDocumentation::ListGenerators, std::cerr);
@@ -1841,17 +2082,18 @@ void cmake::PrintGeneratorList()
void cmake::UpdateConversionPathTable()
{
// Update the path conversion table with any specified file:
- const char* tablepath =
+ const std::string* tablepath =
this->State->GetInitializedCacheValue("CMAKE_PATH_TRANSLATION_FILE");
if (tablepath) {
- cmsys::ifstream table(tablepath);
+ cmsys::ifstream table(tablepath->c_str());
if (!table) {
- cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to ", tablepath,
+ cmSystemTools::Error("CMAKE_PATH_TRANSLATION_FILE set to " + *tablepath +
". CMake can not open file.");
cmSystemTools::ReportLastSystemError("CMake can not open file.");
} else {
- std::string a, b;
+ std::string a;
+ std::string b;
while (!table.eof()) {
// two entries per line
table >> a;
@@ -1874,39 +2116,38 @@ int cmake::CheckBuildSystem()
// If no file is provided for the check, we have to rerun.
if (this->CheckBuildSystemArgument.empty()) {
if (verbose) {
- std::ostringstream msg;
- msg << "Re-run cmake no build system arguments\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout("Re-run cmake no build system arguments\n");
}
return 1;
}
// If the file provided does not exist, we have to rerun.
- if (!cmSystemTools::FileExists(this->CheckBuildSystemArgument.c_str())) {
+ if (!cmSystemTools::FileExists(this->CheckBuildSystemArgument)) {
if (verbose) {
std::ostringstream msg;
msg << "Re-run cmake missing file: " << this->CheckBuildSystemArgument
<< "\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
return 1;
}
// Read the rerun check file and use it to decide whether to do the
// global generate.
- cmake cm(RoleScript); // Actually, all we need is the `set` command.
+ // Actually, all we need is the `set` command.
+ cmake cm(RoleScript, cmState::Unknown);
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
cm.GetCurrentSnapshot().SetDefaultDefinitions();
cmGlobalGenerator gg(&cm);
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
- if (!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) ||
+ cmMakefile mf(&gg, cm.GetCurrentSnapshot());
+ if (!mf.ReadListFile(this->CheckBuildSystemArgument) ||
cmSystemTools::GetErrorOccuredFlag()) {
if (verbose) {
std::ostringstream msg;
msg << "Re-run cmake error reading : " << this->CheckBuildSystemArgument
<< "\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
// There was an error reading the file. Just rerun.
return 1;
@@ -1914,35 +2155,33 @@ int cmake::CheckBuildSystem()
if (this->ClearBuildSystem) {
// Get the generator used for this build system.
- const char* genName = mf->GetDefinition("CMAKE_DEPENDS_GENERATOR");
+ const char* genName = mf.GetDefinition("CMAKE_DEPENDS_GENERATOR");
if (!genName || genName[0] == '\0') {
genName = "Unix Makefiles";
}
// Create the generator and use it to clear the dependencies.
- CM_AUTO_PTR<cmGlobalGenerator> ggd(this->CreateGlobalGenerator(genName));
- if (ggd.get()) {
+ std::unique_ptr<cmGlobalGenerator> ggd(
+ this->CreateGlobalGenerator(genName));
+ if (ggd) {
cm.GetCurrentSnapshot().SetDefaultDefinitions();
- CM_AUTO_PTR<cmMakefile> mfd(
- new cmMakefile(ggd.get(), cm.GetCurrentSnapshot()));
- CM_AUTO_PTR<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(mfd.get()));
- lgd->ClearDependencies(mfd.get(), verbose);
+ cmMakefile mfd(ggd.get(), cm.GetCurrentSnapshot());
+ std::unique_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(&mfd));
+ lgd->ClearDependencies(&mfd, verbose);
}
}
// If any byproduct of makefile generation is missing we must re-run.
std::vector<std::string> products;
- if (const char* productStr = mf->GetDefinition("CMAKE_MAKEFILE_PRODUCTS")) {
- cmSystemTools::ExpandListArgument(productStr, products);
+ if (const char* productStr = mf.GetDefinition("CMAKE_MAKEFILE_PRODUCTS")) {
+ cmExpandList(productStr, products);
}
- for (std::vector<std::string>::const_iterator pi = products.begin();
- pi != products.end(); ++pi) {
- if (!(cmSystemTools::FileExists(pi->c_str()) ||
- cmSystemTools::FileIsSymlink(*pi))) {
+ for (std::string const& p : products) {
+ if (!(cmSystemTools::FileExists(p) || cmSystemTools::FileIsSymlink(p))) {
if (verbose) {
std::ostringstream msg;
- msg << "Re-run cmake, missing byproduct: " << *pi << "\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ msg << "Re-run cmake, missing byproduct: " << p << "\n";
+ cmSystemTools::Stdout(msg.str());
}
return 1;
}
@@ -1951,58 +2190,52 @@ int cmake::CheckBuildSystem()
// Get the set of dependencies and outputs.
std::vector<std::string> depends;
std::vector<std::string> outputs;
- const char* dependsStr = mf->GetDefinition("CMAKE_MAKEFILE_DEPENDS");
- const char* outputsStr = mf->GetDefinition("CMAKE_MAKEFILE_OUTPUTS");
+ const char* dependsStr = mf.GetDefinition("CMAKE_MAKEFILE_DEPENDS");
+ const char* outputsStr = mf.GetDefinition("CMAKE_MAKEFILE_OUTPUTS");
if (dependsStr && outputsStr) {
- cmSystemTools::ExpandListArgument(dependsStr, depends);
- cmSystemTools::ExpandListArgument(outputsStr, outputs);
+ cmExpandList(dependsStr, depends);
+ cmExpandList(outputsStr, outputs);
}
if (depends.empty() || outputs.empty()) {
// Not enough information was provided to do the test. Just rerun.
if (verbose) {
- std::ostringstream msg;
- msg << "Re-run cmake no CMAKE_MAKEFILE_DEPENDS "
- "or CMAKE_MAKEFILE_OUTPUTS :\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout("Re-run cmake no CMAKE_MAKEFILE_DEPENDS "
+ "or CMAKE_MAKEFILE_OUTPUTS :\n");
}
return 1;
}
// Find the newest dependency.
- std::vector<std::string>::iterator dep = depends.begin();
+ auto dep = depends.begin();
std::string dep_newest = *dep++;
for (; dep != depends.end(); ++dep) {
int result = 0;
- if (this->FileComparison->FileTimeCompare(dep_newest.c_str(), dep->c_str(),
- &result)) {
+ if (this->FileTimeCache->Compare(dep_newest, *dep, &result)) {
if (result < 0) {
dep_newest = *dep;
}
} else {
if (verbose) {
- std::ostringstream msg;
- msg << "Re-run cmake: build system dependency is missing\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(
+ "Re-run cmake: build system dependency is missing\n");
}
return 1;
}
}
// Find the oldest output.
- std::vector<std::string>::iterator out = outputs.begin();
+ auto out = outputs.begin();
std::string out_oldest = *out++;
for (; out != outputs.end(); ++out) {
int result = 0;
- if (this->FileComparison->FileTimeCompare(out_oldest.c_str(), out->c_str(),
- &result)) {
+ if (this->FileTimeCache->Compare(out_oldest, *out, &result)) {
if (result > 0) {
out_oldest = *out;
}
} else {
if (verbose) {
- std::ostringstream msg;
- msg << "Re-run cmake: build system output is missing\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(
+ "Re-run cmake: build system output is missing\n");
}
return 1;
}
@@ -2011,14 +2244,13 @@ int cmake::CheckBuildSystem()
// If any output is older than any dependency then rerun.
{
int result = 0;
- if (!this->FileComparison->FileTimeCompare(out_oldest.c_str(),
- dep_newest.c_str(), &result) ||
+ if (!this->FileTimeCache->Compare(out_oldest, dep_newest, &result) ||
result < 0) {
if (verbose) {
std::ostringstream msg;
msg << "Re-run cmake file: " << out_oldest
<< " older than: " << dep_newest << "\n";
- cmSystemTools::Stdout(msg.str().c_str());
+ cmSystemTools::Stdout(msg.str());
}
return 1;
}
@@ -2030,9 +2262,7 @@ int cmake::CheckBuildSystem()
void cmake::TruncateOutputLog(const char* fname)
{
- std::string fullPath = this->GetHomeOutputDirectory();
- fullPath += "/";
- fullPath += fname;
+ std::string fullPath = cmStrCat(this->GetHomeOutputDirectory(), '/', fname);
struct stat st;
if (::stat(fullPath.c_str(), &st)) {
return;
@@ -2049,35 +2279,25 @@ void cmake::TruncateOutputLog(const char* fname)
}
}
-inline std::string removeQuotes(const std::string& s)
-{
- if (s[0] == '\"' && s[s.size() - 1] == '\"') {
- return s.substr(1, s.size() - 2);
- }
- return s;
-}
-
void cmake::MarkCliAsUsed(const std::string& variable)
{
this->UsedCliVariables[variable] = true;
}
-void cmake::GenerateGraphViz(const char* fileName) const
+void cmake::GenerateGraphViz(const std::string& fileName) const
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
- CM_AUTO_PTR<cmGraphVizWriter> gvWriter(
- new cmGraphVizWriter(this->GetGlobalGenerator()->GetLocalGenerators()));
+#ifndef CMAKE_BOOTSTRAP
+ cmGraphVizWriter gvWriter(this->GetGlobalGenerator());
- std::string settingsFile = this->GetHomeOutputDirectory();
- settingsFile += "/CMakeGraphVizOptions.cmake";
- std::string fallbackSettingsFile = this->GetHomeDirectory();
- fallbackSettingsFile += "/CMakeGraphVizOptions.cmake";
+ std::string settingsFile =
+ cmStrCat(this->GetHomeOutputDirectory(), "/CMakeGraphVizOptions.cmake");
+ std::string fallbackSettingsFile =
+ cmStrCat(this->GetHomeDirectory(), "/CMakeGraphVizOptions.cmake");
- gvWriter->ReadSettings(settingsFile.c_str(), fallbackSettingsFile.c_str());
-
- gvWriter->WritePerTargetFiles(fileName);
- gvWriter->WriteTargetDependersFiles(fileName);
- gvWriter->WriteGlobalFile(fileName);
+ gvWriter.ReadSettings(settingsFile, fallbackSettingsFile);
+ gvWriter.WritePerTargetFiles(fileName);
+ gvWriter.WriteTargetDependersFiles(fileName);
+ gvWriter.WriteGlobalFile(fileName);
#endif
}
@@ -2106,8 +2326,7 @@ bool cmake::GetPropertyAsBool(const std::string& prop)
cmInstalledFile* cmake::GetOrCreateInstalledFile(cmMakefile* mf,
const std::string& name)
{
- std::map<std::string, cmInstalledFile>::iterator i =
- this->InstalledFiles.find(name);
+ auto i = this->InstalledFiles.find(name);
if (i != this->InstalledFiles.end()) {
cmInstalledFile& file = i->second;
@@ -2120,14 +2339,13 @@ cmInstalledFile* cmake::GetOrCreateInstalledFile(cmMakefile* mf,
cmInstalledFile const* cmake::GetInstalledFile(const std::string& name) const
{
- std::map<std::string, cmInstalledFile>::const_iterator i =
- this->InstalledFiles.find(name);
+ auto i = this->InstalledFiles.find(name);
if (i != this->InstalledFiles.end()) {
cmInstalledFile const& file = i->second;
return &file;
}
- return CM_NULLPTR;
+ return nullptr;
}
int cmake::GetSystemInformation(std::vector<std::string>& args)
@@ -2137,7 +2355,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
std::string destPath = cwd + "/__cmake_systeminformation";
cmSystemTools::RemoveADirectory(destPath);
- if (!cmSystemTools::MakeDirectory(destPath.c_str())) {
+ if (!cmSystemTools::MakeDirectory(destPath)) {
std::cerr << "Error: --system-information must be run from a "
"writable directory!\n";
return 1;
@@ -2160,8 +2378,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
}
cmGlobalGenerator* gen = this->CreateGlobalGenerator(value);
if (!gen) {
- cmSystemTools::Error("Could not create named generator ",
- value.c_str());
+ cmSystemTools::Error("Could not create named generator " + value);
this->PrintGeneratorList();
} else {
this->SetGlobalGenerator(gen);
@@ -2169,9 +2386,8 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
}
// no option assume it is the output file
else {
- if (!cmSystemTools::FileIsFullPath(arg.c_str())) {
- resultFile = cwd;
- resultFile += "/";
+ if (!cmSystemTools::FileIsFullPath(arg)) {
+ resultFile = cmStrCat(cwd, '/');
}
resultFile += arg;
writeToStdout = false;
@@ -2180,15 +2396,13 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
// we have to find the module directory, so we can copy the files
this->AddCMakePaths();
- std::string modulesPath = cmSystemTools::GetCMakeRoot();
- modulesPath += "/Modules";
- std::string inFile = modulesPath;
- inFile += "/SystemInformation.cmake";
- std::string outFile = destPath;
- outFile += "/CMakeLists.txt";
+ std::string modulesPath =
+ cmStrCat(cmSystemTools::GetCMakeRoot(), "/Modules");
+ std::string inFile = cmStrCat(modulesPath, "/SystemInformation.cmake");
+ std::string outFile = cmStrCat(destPath, "/CMakeLists.txt");
// Copy file
- if (!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str())) {
+ if (!cmsys::SystemTools::CopyFileAlways(inFile, outFile)) {
std::cerr << "Error copying file \"" << inFile << "\" to \"" << outFile
<< "\".\n";
return 1;
@@ -2196,19 +2410,25 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
// do we write to a file or to stdout?
if (resultFile.empty()) {
- resultFile = cwd;
- resultFile += "/__cmake_systeminformation/results.txt";
+ resultFile = cmStrCat(cwd, "/__cmake_systeminformation/results.txt");
}
{
// now run cmake on the CMakeLists file
cmWorkingDirectory workdir(destPath);
+ if (workdir.Failed()) {
+ // We created the directory and we were able to copy the CMakeLists.txt
+ // file to it, so we wouldn't expect to get here unless the default
+ // permissions are questionable or some other process has deleted the
+ // directory
+ std::cerr << "Failed to change to directory " << destPath << " : "
+ << std::strerror(workdir.GetLastResult()) << std::endl;
+ return 1;
+ }
std::vector<std::string> args2;
args2.push_back(args[0]);
args2.push_back(destPath);
- std::string resultArg = "-DRESULT_FILE=";
- resultArg += resultFile;
- args2.push_back(resultArg);
+ args2.push_back("-DRESULT_FILE=" + resultFile);
int res = this->Run(args2, false);
if (res != 0) {
@@ -2239,15 +2459,14 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
return 0;
}
-static bool cmakeCheckStampFile(const char* stampName, bool verbose)
+static bool cmakeCheckStampFile(const std::string& stampName)
{
// The stamp file does not exist. Use the stamp dependencies to
// determine whether it is really out of date. This works in
// conjunction with cmLocalVisualStudio7Generator to avoid
// repeatedly re-running CMake when the user rebuilds the entire
// solution.
- std::string stampDepends = stampName;
- stampDepends += ".depend";
+ std::string stampDepends = cmStrCat(stampName, ".depend");
#if defined(_WIN32) || defined(__CYGWIN__)
cmsys::ifstream fin(stampDepends.c_str(), std::ios::in | std::ios::binary);
#else
@@ -2262,21 +2481,22 @@ static bool cmakeCheckStampFile(const char* stampName, bool verbose)
}
// Compare the stamp dependencies against the dependency file itself.
- cmFileTimeComparison ftc;
- std::string dep;
- while (cmSystemTools::GetLineFromStream(fin, dep)) {
- int result;
- if (!dep.empty() && dep[0] != '#' &&
- (!ftc.FileTimeCompare(stampDepends.c_str(), dep.c_str(), &result) ||
- result < 0)) {
- // The stamp depends file is older than this dependency. The
- // build system is really out of date.
- std::cout << "CMake is re-running because " << stampName
- << " is out-of-date.\n";
- std::cout << " the file '" << dep << "'\n";
- std::cout << " is newer than '" << stampDepends << "'\n";
- std::cout << " result='" << result << "'\n";
- return false;
+ {
+ cmFileTimeCache ftc;
+ std::string dep;
+ while (cmSystemTools::GetLineFromStream(fin, dep)) {
+ int result;
+ if (!dep.empty() && dep[0] != '#' &&
+ (!ftc.Compare(stampDepends, dep, &result) || result < 0)) {
+ // The stamp depends file is older than this dependency. The
+ // build system is really out of date.
+ std::cout << "CMake is re-running because " << stampName
+ << " is out-of-date.\n";
+ std::cout << " the file '" << dep << "'\n";
+ std::cout << " is newer than '" << stampDepends << "'\n";
+ std::cout << " result='" << result << "'\n";
+ return false;
+ }
}
}
@@ -2284,30 +2504,23 @@ static bool cmakeCheckStampFile(const char* stampName, bool verbose)
// by the VS IDE due to a "rebuild" request. Restore it atomically.
std::ostringstream stampTempStream;
stampTempStream << stampName << ".tmp" << cmSystemTools::RandomSeed();
- std::string stampTempString = stampTempStream.str();
- const char* stampTemp = stampTempString.c_str();
+ std::string stampTemp = stampTempStream.str();
{
// TODO: Teach cmGeneratedFileStream to use a random temp file (with
// multiple tries in unlikely case of conflict) and use that here.
- cmsys::ofstream stamp(stampTemp);
+ cmsys::ofstream stamp(stampTemp.c_str());
stamp << "# CMake generation timestamp file for this directory.\n";
}
if (cmSystemTools::RenameFile(stampTemp, stampName)) {
- if (verbose) {
- // Notify the user why CMake is not re-running. It is safe to
- // just print to stdout here because this code is only reachable
- // through an undocumented flag used by the VS generator.
- std::cout << "CMake does not need to re-run because " << stampName
- << " is up-to-date.\n";
- }
+ // CMake does not need to re-run because the stamp file is up-to-date.
return true;
}
cmSystemTools::RemoveFile(stampTemp);
- cmSystemTools::Error("Cannot restore timestamp ", stampName);
+ cmSystemTools::Error("Cannot restore timestamp " + stampName);
return false;
}
-static bool cmakeCheckStampList(const char* stampList, bool verbose)
+static bool cmakeCheckStampList(const std::string& stampList)
{
// If the stamp list does not exist CMake must rerun to generate it.
if (!cmSystemTools::FileExists(stampList)) {
@@ -2315,7 +2528,7 @@ static bool cmakeCheckStampList(const char* stampList, bool verbose)
<< "is missing.\n";
return false;
}
- cmsys::ifstream fin(stampList);
+ cmsys::ifstream fin(stampList.c_str());
if (!fin) {
std::cout << "CMake is re-running because generate.stamp.list "
<< "could not be read.\n";
@@ -2325,14 +2538,14 @@ static bool cmakeCheckStampList(const char* stampList, bool verbose)
// Check each stamp.
std::string stampName;
while (cmSystemTools::GetLineFromStream(fin, stampName)) {
- if (!cmakeCheckStampFile(stampName.c_str(), verbose)) {
+ if (!cmakeCheckStampFile(stampName)) {
return false;
}
}
return true;
}
-void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
+void cmake::IssueMessage(MessageType t, std::string const& text,
cmListFileBacktrace const& backtrace) const
{
this->Messenger->IssueMessage(t, text, backtrace);
@@ -2344,25 +2557,22 @@ std::vector<std::string> cmake::GetDebugConfigs()
if (const char* config_list =
this->State->GetGlobalProperty("DEBUG_CONFIGURATIONS")) {
// Expand the specified list and convert to upper-case.
- cmSystemTools::ExpandListArgument(config_list, configs);
+ cmExpandList(config_list, configs);
std::transform(configs.begin(), configs.end(), configs.begin(),
cmSystemTools::UpperCase);
}
// If no configurations were specified, use a default list.
if (configs.empty()) {
- configs.push_back("DEBUG");
+ configs.emplace_back("DEBUG");
}
return configs;
}
-cmMessenger* cmake::GetMessenger() const
-{
- return this->Messenger;
-}
-
-int cmake::Build(const std::string& dir, const std::string& target,
+int cmake::Build(int jobs, const std::string& dir,
+ const std::vector<std::string>& targets,
const std::string& config,
- const std::vector<std::string>& nativeOptions, bool clean)
+ const std::vector<std::string>& nativeOptions, bool clean,
+ bool verbose)
{
this->SetHomeDirectory("");
@@ -2383,13 +2593,29 @@ int cmake::Build(const std::string& dir, const std::string& target,
std::cerr << "Error: could not find CMAKE_GENERATOR in Cache\n";
return 1;
}
- CM_AUTO_PTR<cmGlobalGenerator> gen(
- this->CreateGlobalGenerator(cachedGenerator));
- if (!gen.get()) {
+ cmGlobalGenerator* gen = this->CreateGlobalGenerator(cachedGenerator);
+ if (!gen) {
std::cerr << "Error: could create CMAKE_GENERATOR \"" << cachedGenerator
<< "\"\n";
return 1;
}
+ this->SetGlobalGenerator(gen);
+ const char* cachedGeneratorInstance =
+ this->State->GetCacheEntryValue("CMAKE_GENERATOR_INSTANCE");
+ if (cachedGeneratorInstance) {
+ cmMakefile mf(gen, this->GetCurrentSnapshot());
+ if (!gen->SetGeneratorInstance(cachedGeneratorInstance, &mf)) {
+ return 1;
+ }
+ }
+ const char* cachedGeneratorPlatform =
+ this->State->GetCacheEntryValue("CMAKE_GENERATOR_PLATFORM");
+ if (cachedGeneratorPlatform) {
+ cmMakefile mf(gen, this->GetCurrentSnapshot());
+ if (!gen->SetGeneratorPlatform(cachedGeneratorPlatform, &mf)) {
+ return 1;
+ }
+ }
std::string output;
std::string projName;
const char* cachedProjectName =
@@ -2399,11 +2625,11 @@ int cmake::Build(const std::string& dir, const std::string& target,
return 1;
}
projName = cachedProjectName;
- bool verbose = false;
+
const char* cachedVerbose =
this->State->GetCacheEntryValue("CMAKE_VERBOSE_MAKEFILE");
- if (cachedVerbose) {
- verbose = cmSystemTools::IsOn(cachedVerbose);
+ if (cmIsOn(cachedVerbose)) {
+ verbose = true;
}
#ifdef CMAKE_HAVE_VS_GENERATORS
@@ -2411,55 +2637,110 @@ int cmake::Build(const std::string& dir, const std::string& target,
// actually starting the build. If not done separately from the build
// itself, there is the risk of building an out-of-date solution file due
// to limitations of the underlying build system.
- std::string const stampList = cachePath + "/" +
- GetCMakeFilesDirectoryPostSlash() +
- cmGlobalVisualStudio8Generator::GetGenerateStampList();
+ std::string const stampList = cachePath + "/" + "CMakeFiles/" +
+ cmGlobalVisualStudio9Generator::GetGenerateStampList();
// Note that the stampList file only exists for VS generators.
- if (cmSystemTools::FileExists(stampList.c_str()) &&
- !cmakeCheckStampList(stampList.c_str(), false)) {
-
- // Correctly initialize the home (=source) and home output (=binary)
- // directories, which is required for running the generation step.
- std::string homeOrig = this->GetHomeDirectory();
- std::string homeOutputOrig = this->GetHomeOutputDirectory();
- this->SetDirectoriesFromFile(cachePath.c_str());
+ if (cmSystemTools::FileExists(stampList)) {
+ // Check if running for Visual Studio 9 - we need to explicitly run
+ // the glob verification script before starting the build
this->AddScriptingCommands();
- this->AddProjectCommands();
-
- int ret = this->Configure();
- if (ret) {
- cmSystemTools::Message("CMake Configure step failed. "
- "Build files cannot be regenerated correctly.");
- return ret;
- }
- ret = this->Generate();
- if (ret) {
- cmSystemTools::Message("CMake Generate step failed. "
- "Build files cannot be regenerated correctly.");
- return ret;
+ if (this->GlobalGenerator->MatchesGeneratorName("Visual Studio 9 2008")) {
+ std::string const globVerifyScript =
+ cachePath + "/" + "CMakeFiles/" + "VerifyGlobs.cmake";
+ if (cmSystemTools::FileExists(globVerifyScript)) {
+ std::vector<std::string> args;
+ this->ReadListFile(args, globVerifyScript);
+ }
}
- std::string message = "Build files have been written to: ";
- message += this->GetHomeOutputDirectory();
- this->UpdateProgress(message.c_str(), -1);
- // Restore the previously set directories to their original value.
- this->SetHomeDirectory(homeOrig);
- this->SetHomeOutputDirectory(homeOutputOrig);
+ if (!cmakeCheckStampList(stampList)) {
+ // Correctly initialize the home (=source) and home output (=binary)
+ // directories, which is required for running the generation step.
+ std::string homeOrig = this->GetHomeDirectory();
+ std::string homeOutputOrig = this->GetHomeOutputDirectory();
+ this->SetDirectoriesFromFile(cachePath);
+
+ this->AddProjectCommands();
+
+ int ret = this->Configure();
+ if (ret) {
+ cmSystemTools::Message("CMake Configure step failed. "
+ "Build files cannot be regenerated correctly.");
+ return ret;
+ }
+ ret = this->Generate();
+ if (ret) {
+ cmSystemTools::Message("CMake Generate step failed. "
+ "Build files cannot be regenerated correctly.");
+ return ret;
+ }
+ std::string message = cmStrCat("Build files have been written to: ",
+ this->GetHomeOutputDirectory());
+ this->UpdateProgress(message, -1);
+
+ // Restore the previously set directories to their original value.
+ this->SetHomeDirectory(homeOrig);
+ this->SetHomeOutputDirectory(homeOutputOrig);
+ }
}
#endif
- return gen->Build("", dir, projName, target, output, "", config, clean,
- false, verbose, 0, cmSystemTools::OUTPUT_PASSTHROUGH,
- nativeOptions);
+ gen->PrintBuildCommandAdvice(std::cerr, jobs);
+ return gen->Build(jobs, "", dir, projName, targets, output, "", config,
+ clean, false, verbose, cmDuration::zero(),
+ cmSystemTools::OUTPUT_PASSTHROUGH, nativeOptions);
+}
+
+bool cmake::Open(const std::string& dir, bool dryRun)
+{
+ this->SetHomeDirectory("");
+ this->SetHomeOutputDirectory("");
+ if (!cmSystemTools::FileIsDirectory(dir)) {
+ std::cerr << "Error: " << dir << " is not a directory\n";
+ return false;
+ }
+
+ std::string cachePath = FindCacheFile(dir);
+ if (!this->LoadCache(cachePath)) {
+ std::cerr << "Error: could not load cache\n";
+ return false;
+ }
+ const char* genName = this->State->GetCacheEntryValue("CMAKE_GENERATOR");
+ if (!genName) {
+ std::cerr << "Error: could not find CMAKE_GENERATOR in Cache\n";
+ return false;
+ }
+ const std::string* extraGenName =
+ this->State->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR");
+ std::string fullName =
+ cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
+ genName, extraGenName ? *extraGenName : "");
+
+ std::unique_ptr<cmGlobalGenerator> gen(
+ this->CreateGlobalGenerator(fullName));
+ if (!gen) {
+ std::cerr << "Error: could create CMAKE_GENERATOR \"" << fullName
+ << "\"\n";
+ return false;
+ }
+
+ const char* cachedProjectName =
+ this->State->GetCacheEntryValue("CMAKE_PROJECT_NAME");
+ if (!cachedProjectName) {
+ std::cerr << "Error: could not find CMAKE_PROJECT_NAME in Cache\n";
+ return false;
+ }
+
+ return gen->Open(dir, cachedProjectName, dryRun);
}
void cmake::WatchUnusedCli(const std::string& var)
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this);
- if (this->UsedCliVariables.find(var) == this->UsedCliVariables.end()) {
+ if (!cmContains(this->UsedCliVariables, var)) {
this->UsedCliVariables[var] = false;
}
#endif
@@ -2467,7 +2748,7 @@ void cmake::WatchUnusedCli(const std::string& var)
void cmake::UnwatchUnusedCli(const std::string& var)
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
this->VariableWatch->RemoveWatch(var, cmWarnUnusedCliWarning);
this->UsedCliVariables.erase(var);
#endif
@@ -2475,20 +2756,18 @@ void cmake::UnwatchUnusedCli(const std::string& var)
void cmake::RunCheckForUnusedVariables()
{
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
bool haveUnused = false;
std::ostringstream msg;
msg << "Manually-specified variables were not used by the project:";
- for (std::map<std::string, bool>::const_iterator it =
- this->UsedCliVariables.begin();
- it != this->UsedCliVariables.end(); ++it) {
- if (!it->second) {
+ for (auto const& it : this->UsedCliVariables) {
+ if (!it.second) {
haveUnused = true;
- msg << "\n " << it->first;
+ msg << "\n " << it.first;
}
}
if (haveUnused) {
- this->IssueMessage(cmake::WARNING, msg.str());
+ this->IssueMessage(MessageType::WARNING, msg.str());
}
#endif
}
diff --git a/Source/cmake.h b/Source/cmake.h
index 4ddacf701..687c1056b 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -3,29 +3,35 @@
#ifndef cmake_h
#define cmake_h
-#include "cmConfigure.h"
+#include "cmConfigure.h" // IWYU pragma: keep
+#include <functional>
#include <map>
+#include <memory>
#include <set>
#include <string>
+#include <unordered_set>
#include <vector>
+#include "cmGeneratedFileStream.h"
#include "cmInstalledFile.h"
#include "cmListFileCache.h"
+#include "cmMessageType.h"
+#include "cmState.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cm_jsoncpp_value.h"
+#if !defined(CMAKE_BOOTSTRAP)
+# include "cm_jsoncpp_value.h"
#endif
class cmExternalMakefileProjectGeneratorFactory;
-class cmFileTimeComparison;
+class cmFileAPI;
+class cmFileTimeCache;
class cmGlobalGenerator;
class cmGlobalGeneratorFactory;
class cmMakefile;
class cmMessenger;
-class cmState;
class cmVariableWatch;
struct cmDocumentationEntry;
@@ -55,8 +61,6 @@ struct cmDocumentationEntry;
class cmake
{
- CM_DISABLE_COPY(cmake)
-
public:
enum Role
{
@@ -65,19 +69,6 @@ public:
RoleProject // all commands
};
- enum MessageType
- {
- AUTHOR_WARNING,
- AUTHOR_ERROR,
- FATAL_ERROR,
- INTERNAL_ERROR,
- MESSAGE,
- WARNING,
- LOG,
- DEPRECATION_ERROR,
- DEPRECATION_WARNING
- };
-
enum DiagLevel
{
DIAG_IGNORE,
@@ -106,6 +97,19 @@ public:
FIND_PACKAGE_MODE
};
+ /** \brief Define log level constants. */
+ enum LogLevel
+ {
+ LOG_UNDEFINED,
+ LOG_ERROR,
+ LOG_WARNING,
+ LOG_NOTICE,
+ LOG_STATUS,
+ LOG_VERBOSE,
+ LOG_DEBUG,
+ LOG_TRACE
+ };
+
struct GeneratorInfo
{
std::string name;
@@ -113,26 +117,40 @@ public:
std::string extraName;
bool supportsToolset;
bool supportsPlatform;
+ std::vector<std::string> supportedPlatforms;
+ std::string defaultPlatform;
bool isAlias;
};
- typedef std::map<std::string, cmInstalledFile> InstalledFilesMap;
+ struct FileExtensions
+ {
+ bool Test(std::string const& ext) const
+ {
+ return (this->unordered.find(ext) != this->unordered.end());
+ }
+
+ std::vector<std::string> ordered;
+ std::unordered_set<std::string> unordered;
+ };
+
+ using InstalledFilesMap = std::map<std::string, cmInstalledFile>;
+
+ static const int NO_BUILD_PARALLEL_LEVEL = -1;
+ static const int DEFAULT_BUILD_PARALLEL_LEVEL = 0;
/// Default constructor
- cmake(Role role);
+ cmake(Role role, cmState::Mode mode);
/// Destructor
~cmake();
-#if defined(CMAKE_BUILD_WITH_CMAKE)
- Json::Value ReportCapabilitiesJson(bool haveServerMode) const;
-#endif
- std::string ReportCapabilities(bool haveServerMode) const;
+ cmake(cmake const&) = delete;
+ cmake& operator=(cmake const&) = delete;
- static const char* GetCMakeFilesDirectory() { return "/CMakeFiles"; }
- static const char* GetCMakeFilesDirectoryPostSlash()
- {
- return "CMakeFiles/";
- }
+#if !defined(CMAKE_BOOTSTRAP)
+ Json::Value ReportVersionJson() const;
+ Json::Value ReportCapabilitiesJson() const;
+#endif
+ std::string ReportCapabilities() const;
//@{
/**
@@ -141,9 +159,9 @@ public:
* path-to-source cmake was run with.
*/
void SetHomeDirectory(const std::string& dir);
- const char* GetHomeDirectory() const;
+ std::string const& GetHomeDirectory() const;
void SetHomeOutputDirectory(const std::string& dir);
- const char* GetHomeOutputDirectory() const;
+ std::string const& GetHomeOutputDirectory() const;
//@}
/**
@@ -169,7 +187,7 @@ public:
int Configure();
int ActualConfigure();
- ///! Break up a line like VAR:type="value" into var, type and value
+ //! Break up a line like VAR:type="value" into var, type and value
static bool ParseCacheEntry(const std::string& entry, std::string& var,
std::string& value,
cmStateEnums::CacheEntryType& type);
@@ -183,84 +201,128 @@ public:
bool DeleteCache(const std::string& path);
void PreLoadCMakeFiles();
- ///! Create a GlobalGenerator
+ //! Create a GlobalGenerator
cmGlobalGenerator* CreateGlobalGenerator(const std::string& name);
- ///! Return the global generator assigned to this instance of cmake
+ //! Return the global generator assigned to this instance of cmake
cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; }
- ///! Return the global generator assigned to this instance of cmake, const
+ //! Return the global generator assigned to this instance of cmake, const
const cmGlobalGenerator* GetGlobalGenerator() const
{
return this->GlobalGenerator;
}
- ///! Return the full path to where the CMakeCache.txt file should be.
+ //! Return the full path to where the CMakeCache.txt file should be.
static std::string FindCacheFile(const std::string& binaryDir);
- ///! Return the global generator assigned to this instance of cmake
+ //! Return the global generator assigned to this instance of cmake
void SetGlobalGenerator(cmGlobalGenerator*);
- ///! Get the names of the current registered generators
- void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators) const;
+ //! Get the names of the current registered generators
+ void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators,
+ bool includeNamesWithPlatform = true) const;
- ///! Set the name of the selected generator-specific platform.
- void SetGeneratorPlatform(std::string const& ts)
+ //! Set the name of the selected generator-specific instance.
+ void SetGeneratorInstance(std::string const& instance)
{
- this->GeneratorPlatform = ts;
+ this->GeneratorInstance = instance;
+ this->GeneratorInstanceSet = true;
}
- ///! Get the name of the selected generator-specific platform.
- std::string const& GetGeneratorPlatform() const
+ //! Set the name of the selected generator-specific platform.
+ void SetGeneratorPlatform(std::string const& ts)
{
- return this->GeneratorPlatform;
+ this->GeneratorPlatform = ts;
+ this->GeneratorPlatformSet = true;
}
- ///! Set the name of the selected generator-specific toolset.
+ //! Set the name of the selected generator-specific toolset.
void SetGeneratorToolset(std::string const& ts)
{
this->GeneratorToolset = ts;
+ this->GeneratorToolsetSet = true;
}
- ///! Get the name of the selected generator-specific toolset.
- std::string const& GetGeneratorToolset() const
+ const std::vector<std::string>& GetSourceExtensions() const
{
- return this->GeneratorToolset;
+ return this->SourceFileExtensions.ordered;
}
- const std::vector<std::string>& GetSourceExtensions() const
+ bool IsSourceExtension(const std::string& ext) const
{
- return this->SourceFileExtensions;
+ return this->SourceFileExtensions.Test(ext);
}
+
const std::vector<std::string>& GetHeaderExtensions() const
{
- return this->HeaderFileExtensions;
+ return this->HeaderFileExtensions.ordered;
+ }
+
+ bool IsHeaderExtension(const std::string& ext) const
+ {
+ return this->HeaderFileExtensions.Test(ext);
+ }
+
+ const std::vector<std::string>& GetCudaExtensions() const
+ {
+ return this->CudaFileExtensions.ordered;
+ }
+
+ bool IsCudaExtension(const std::string& ext) const
+ {
+ return this->CudaFileExtensions.Test(ext);
+ }
+
+ const std::vector<std::string>& GetFortranExtensions() const
+ {
+ return this->FortranFileExtensions.ordered;
+ }
+
+ bool IsFortranExtension(const std::string& ext) const
+ {
+ return this->FortranFileExtensions.Test(ext);
}
+ // Strips the extension (if present and known) from a filename
+ std::string StripExtension(const std::string& file) const;
+
/**
* Given a variable name, return its value (as a string).
*/
const char* GetCacheDefinition(const std::string&) const;
- ///! Add an entry into the cache
+ //! Add an entry into the cache
void AddCacheEntry(const std::string& key, const char* value,
const char* helpString, int type);
+ bool DoWriteGlobVerifyTarget() const;
+ std::string const& GetGlobVerifyScript() const;
+ std::string const& GetGlobVerifyStamp() const;
+ void AddGlobCacheEntry(bool recurse, bool listDirectories,
+ bool followSymlinks, const std::string& relative,
+ const std::string& expression,
+ const std::vector<std::string>& files,
+ const std::string& variable,
+ cmListFileBacktrace const& bt);
+
/**
* Get the system information and write it to the file specified
*/
int GetSystemInformation(std::vector<std::string>&);
- ///! Parse command line arguments
- void SetArgs(const std::vector<std::string>&,
- bool directoriesSetBefore = false);
+ //! Parse environment variables
+ void LoadEnvironmentPresets();
+
+ //! Parse command line arguments
+ void SetArgs(const std::vector<std::string>& args);
- ///! Is this cmake running as a result of a TRY_COMPILE command
+ //! Is this cmake running as a result of a TRY_COMPILE command
bool GetIsInTryCompile() const;
void SetIsInTryCompile(bool b);
- ///! Parse command line arguments that might set cache values
+ //! Parse command line arguments that might set cache values
bool SetCacheArgs(const std::vector<std::string>&);
- typedef void (*ProgressCallbackType)(const char* msg, float progress, void*);
+ using ProgressCallbackType = std::function<void(const std::string&, float)>;
/**
* Set the function used by GUIs to receive progress updates
* Function gets passed: message as a const char*, a progress
@@ -268,25 +330,26 @@ public:
* number provided may be negative in cases where a message is
* to be displayed without any progress percentage.
*/
- void SetProgressCallback(ProgressCallbackType f,
- void* clientData = CM_NULLPTR);
+ void SetProgressCallback(ProgressCallbackType f);
- ///! this is called by generators to update the progress
- void UpdateProgress(const char* msg, float prog);
+ //! this is called by generators to update the progress
+ void UpdateProgress(const std::string& msg, float prog);
- ///! Get the variable watch object
- cmVariableWatch* GetVariableWatch() { return this->VariableWatch; }
+#if !defined(CMAKE_BOOTSTRAP)
+ //! Get the variable watch object
+ cmVariableWatch* GetVariableWatch() { return this->VariableWatch.get(); }
+#endif
- void GetGeneratorDocumentation(std::vector<cmDocumentationEntry>&);
+ std::vector<cmDocumentationEntry> GetGeneratorsDocumentation();
- ///! Set/Get a property of this target file
+ //! Set/Get a property of this target file
void SetProperty(const std::string& prop, const char* value);
void AppendProperty(const std::string& prop, const char* value,
bool asString = false);
const char* GetProperty(const std::string& prop);
bool GetPropertyAsBool(const std::string& prop);
- ///! Get or create an cmInstalledFile instance and return a pointer to it
+ //! Get or create an cmInstalledFile instance and return a pointer to it
cmInstalledFile* GetOrCreateInstalledFile(cmMakefile* mf,
const std::string& name);
@@ -297,13 +360,13 @@ public:
return this->InstalledFiles;
}
- ///! Do all the checks before running configure
+ //! Do all the checks before running configure
int DoPreConfigureChecks();
void SetWorkingMode(WorkingMode mode) { this->CurrentWorkingMode = mode; }
WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; }
- ///! Debug the try compile stuff by not deleting the files
+ //! Debug the try compile stuff by not deleting the files
bool GetDebugTryCompile() { return this->DebugTryCompile; }
void DebugTryCompileOn() { this->DebugTryCompile = true; }
@@ -315,13 +378,18 @@ public:
/**
* Get the file comparison class
*/
- cmFileTimeComparison* GetFileComparison() { return this->FileComparison; }
+ cmFileTimeCache* GetFileTimeCache() { return this->FileTimeCache.get(); }
+
+ //! Get the selected log level for `message()` commands during the cmake run.
+ LogLevel GetLogLevel() const { return this->MessageLogLevel; }
+ void SetLogLevel(LogLevel level) { this->MessageLogLevel = level; }
+ static LogLevel StringToLogLevel(const std::string& levelStr);
- // Do we want debug output during the cmake run.
+ //! Do we want debug output during the cmake run.
bool GetDebugOutput() { return this->DebugOutput; }
void SetDebugOutputOn(bool b) { this->DebugOutput = b; }
- // Do we want trace output during the cmake run.
+ //! Do we want trace output during the cmake run.
bool GetTrace() { return this->Trace; }
void SetTrace(bool b) { this->Trace = b; }
bool GetTraceExpand() { return this->TraceExpand; }
@@ -334,6 +402,9 @@ public:
{
return this->TraceOnlyThisSources;
}
+ cmGeneratedFileStream& GetTraceFile() { return this->TraceFile; }
+ void SetTraceFile(std::string const& file);
+
bool GetWarnUninitialized() { return this->WarnUninitialized; }
void SetWarnUninitialized(bool b) { this->WarnUninitialized = b; }
bool GetWarnUnused() { return this->WarnUnused; }
@@ -358,31 +429,31 @@ public:
return this->CMakeEditCommand;
}
- cmMessenger* GetMessenger() const;
+ cmMessenger* GetMessenger() const { return this->Messenger.get(); }
- /*
+ /**
* Get the state of the suppression of developer (author) warnings.
* Returns false, by default, if developer warnings should be shown, true
* otherwise.
*/
bool GetSuppressDevWarnings() const;
- /*
+ /**
* Set the state of the suppression of developer (author) warnings.
*/
void SetSuppressDevWarnings(bool v);
- /*
+ /**
* Get the state of the suppression of deprecated warnings.
* Returns false, by default, if deprecated warnings should be shown, true
* otherwise.
*/
bool GetSuppressDeprecatedWarnings() const;
- /*
+ /**
* Set the state of the suppression of deprecated warnings.
*/
void SetSuppressDeprecatedWarnings(bool v);
- /*
+ /**
* Get the state of treating developer (author) warnings as errors.
* Returns false, by default, if warnings should not be treated as errors,
* true otherwise.
@@ -393,7 +464,7 @@ public:
*/
void SetDevWarningsAsErrors(bool v);
- /*
+ /**
* Get the state of treating deprecated warnings as errors.
* Returns false, by default, if warnings should not be treated as errors,
* true otherwise.
@@ -406,18 +477,22 @@ public:
/** Display a message to the user. */
void IssueMessage(
- cmake::MessageType t, std::string const& text,
+ MessageType t, std::string const& text,
cmListFileBacktrace const& backtrace = cmListFileBacktrace()) const;
- ///! run the --build option
- int Build(const std::string& dir, const std::string& target,
- const std::string& config,
- const std::vector<std::string>& nativeOptions, bool clean);
+ //! run the --build option
+ int Build(int jobs, const std::string& dir,
+ const std::vector<std::string>& targets, const std::string& config,
+ const std::vector<std::string>& nativeOptions, bool clean,
+ bool verbose);
+
+ //! run the --open option
+ bool Open(const std::string& dir, bool dryRun);
void UnwatchUnusedCli(const std::string& var);
void WatchUnusedCli(const std::string& var);
- cmState* GetState() const { return this->State; }
+ cmState* GetState() const { return this->State.get(); }
void SetCurrentSnapshot(cmStateSnapshot const& snapshot)
{
this->CurrentSnapshot = snapshot;
@@ -426,29 +501,33 @@ public:
protected:
void RunCheckForUnusedVariables();
- void InitializeProperties();
int HandleDeleteCacheVariables(const std::string& var);
- typedef std::vector<cmGlobalGeneratorFactory*> RegisteredGeneratorsVector;
+ using RegisteredGeneratorsVector = std::vector<cmGlobalGeneratorFactory*>;
RegisteredGeneratorsVector Generators;
- typedef std::vector<cmExternalMakefileProjectGeneratorFactory*>
- RegisteredExtraGeneratorsVector;
+ using RegisteredExtraGeneratorsVector =
+ std::vector<cmExternalMakefileProjectGeneratorFactory*>;
RegisteredExtraGeneratorsVector ExtraGenerators;
void AddScriptingCommands();
void AddProjectCommands();
void AddDefaultGenerators();
void AddDefaultExtraGenerators();
- cmGlobalGenerator* GlobalGenerator;
+ cmGlobalGenerator* GlobalGenerator = nullptr;
std::map<std::string, DiagLevel> DiagLevels;
+ std::string GeneratorInstance;
std::string GeneratorPlatform;
std::string GeneratorToolset;
+ bool GeneratorInstanceSet = false;
+ bool GeneratorPlatformSet = false;
+ bool GeneratorToolsetSet = false;
- ///! read in a cmake list file to initialize the cache
- void ReadListFile(const std::vector<std::string>& args, const char* path);
+ //! read in a cmake list file to initialize the cache
+ void ReadListFile(const std::vector<std::string>& args,
+ const std::string& path);
bool FindPackage(const std::vector<std::string>& args);
- ///! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file.
+ //! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file.
/// If it is set, truncate it to 50kb
void TruncateOutputLog(const char* fname);
@@ -458,28 +537,25 @@ protected:
*/
int CheckBuildSystem();
- void SetDirectoriesFromFile(const char* arg);
+ void SetDirectoriesFromFile(const std::string& arg);
//! Make sure all commands are what they say they are and there is no
/// macros.
void CleanupCommandsAndMacros();
- void GenerateGraphViz(const char* fileName) const;
-
- cmVariableWatch* VariableWatch;
+ void GenerateGraphViz(const std::string& fileName) const;
private:
ProgressCallbackType ProgressCallback;
- void* ProgressCallbackClientData;
- bool InTryCompile;
- WorkingMode CurrentWorkingMode;
- bool DebugOutput;
- bool Trace;
- bool TraceExpand;
- bool WarnUninitialized;
- bool WarnUnused;
- bool WarnUnusedCli;
- bool CheckSystemVars;
+ WorkingMode CurrentWorkingMode = NORMAL_MODE;
+ bool DebugOutput = false;
+ bool Trace = false;
+ bool TraceExpand = false;
+ cmGeneratedFileStream TraceFile;
+ bool WarnUninitialized = false;
+ bool WarnUnused = false;
+ bool WarnUnusedCli = true;
+ bool CheckSystemVars = false;
std::map<std::string, bool> UsedCliVariables;
std::string CMakeEditCommand;
std::string CXXEnvironment;
@@ -488,43 +564,47 @@ private:
std::string CheckStampFile;
std::string CheckStampList;
std::string VSSolutionFile;
- std::vector<std::string> SourceFileExtensions;
- std::vector<std::string> HeaderFileExtensions;
- bool ClearBuildSystem;
- bool DebugTryCompile;
- cmFileTimeComparison* FileComparison;
+ std::string EnvironmentGenerator;
+ FileExtensions SourceFileExtensions;
+ FileExtensions HeaderFileExtensions;
+ FileExtensions CudaFileExtensions;
+ FileExtensions FortranFileExtensions;
+ bool ClearBuildSystem = false;
+ bool DebugTryCompile = false;
+ std::unique_ptr<cmFileTimeCache> FileTimeCache;
std::string GraphVizFile;
InstalledFilesMap InstalledFiles;
- cmState* State;
+#if !defined(CMAKE_BOOTSTRAP)
+ std::unique_ptr<cmVariableWatch> VariableWatch;
+ std::unique_ptr<cmFileAPI> FileAPI;
+#endif
+
+ std::unique_ptr<cmState> State;
cmStateSnapshot CurrentSnapshot;
- cmMessenger* Messenger;
+ std::unique_ptr<cmMessenger> Messenger;
std::vector<std::string> TraceOnlyThisSources;
+ LogLevel MessageLogLevel = LogLevel::LOG_STATUS;
+
void UpdateConversionPathTable();
- // Print a list of valid generators to stderr.
+ //! Print a list of valid generators to stderr.
void PrintGeneratorList();
+ std::unique_ptr<cmGlobalGenerator> EvaluateDefaultGlobalGenerator();
void CreateDefaultGlobalGenerator();
- /**
- * Convert a message type between a warning and an error, based on the state
- * of the error output CMake variables, in the cache.
- */
- cmake::MessageType ConvertMessageType(cmake::MessageType t) const;
-
- /*
- * Check if messages of this type should be output, based on the state of the
- * warning and error output CMake variables, in the cache.
- */
- bool IsMessageTypeVisible(cmake::MessageType t) const;
+ void AppendGlobalGeneratorsDocumentation(std::vector<cmDocumentationEntry>&);
+ void AppendExtraGeneratorsDocumentation(std::vector<cmDocumentationEntry>&);
};
#define CMAKE_STANDARD_OPTIONS_TABLE \
- { "-C <initial-cache>", "Pre-load a script to populate the cache." }, \
- { "-D <var>[:<type>]=<value>", "Create a cmake cache entry." }, \
+ { "-S <path-to-source>", "Explicitly specify a source directory." }, \
+ { "-B <path-to-build>", "Explicitly specify a build directory." }, \
+ { "-C <initial-cache>", "Pre-load a script to populate the cache." }, \
+ { "-D <var>[:<type>]=<value>", "Create or update a cmake cache entry." }, \
{ "-U <globbing_expr>", "Remove matching entries from CMake cache." }, \
{ "-G <generator-name>", "Specify a build system generator." }, \
{ "-T <toolset-name>", \
@@ -537,46 +617,47 @@ private:
{ "-Wno-error=dev", "Make developer warnings not errors." }, \
{ "-Wdeprecated", "Enable deprecation warnings." }, \
{ "-Wno-deprecated", "Suppress deprecation warnings." }, \
- { "-Werror=deprecated", "Make deprecated macro and function warnings " \
- "errors." }, \
+ { "-Werror=deprecated", \
+ "Make deprecated macro and function warnings " \
+ "errors." }, \
{ \
- "-Wno-error=deprecated", "Make deprecated macro and function warnings " \
- "not errors." \
+ "-Wno-error=deprecated", \
+ "Make deprecated macro and function warnings " \
+ "not errors." \
}
+#define FOR_EACH_C90_FEATURE(F) F(c_function_prototypes)
+
+#define FOR_EACH_C99_FEATURE(F) \
+ F(c_restrict) \
+ F(c_variadic_macros)
+
+#define FOR_EACH_C11_FEATURE(F) F(c_static_assert)
+
#define FOR_EACH_C_FEATURE(F) \
F(c_std_90) \
F(c_std_99) \
F(c_std_11) \
- F(c_function_prototypes) \
- F(c_restrict) \
- F(c_static_assert) \
- F(c_variadic_macros)
+ FOR_EACH_C90_FEATURE(F) \
+ FOR_EACH_C99_FEATURE(F) \
+ FOR_EACH_C11_FEATURE(F)
-#define FOR_EACH_CXX_FEATURE(F) \
- F(cxx_std_98) \
- F(cxx_std_11) \
- F(cxx_std_14) \
- F(cxx_std_17) \
- F(cxx_aggregate_default_initializers) \
+#define FOR_EACH_CXX98_FEATURE(F) F(cxx_template_template_parameters)
+
+#define FOR_EACH_CXX11_FEATURE(F) \
F(cxx_alias_templates) \
F(cxx_alignas) \
F(cxx_alignof) \
F(cxx_attributes) \
- F(cxx_attribute_deprecated) \
F(cxx_auto_type) \
- F(cxx_binary_literals) \
F(cxx_constexpr) \
- F(cxx_contextual_conversions) \
F(cxx_decltype) \
- F(cxx_decltype_auto) \
F(cxx_decltype_incomplete_return_types) \
F(cxx_default_function_template_args) \
F(cxx_defaulted_functions) \
F(cxx_defaulted_move_initializers) \
F(cxx_delegating_constructors) \
F(cxx_deleted_functions) \
- F(cxx_digit_separators) \
F(cxx_enum_forward_declarations) \
F(cxx_explicit_conversions) \
F(cxx_extended_friend_declarations) \
@@ -584,11 +665,9 @@ private:
F(cxx_final) \
F(cxx_func_identifier) \
F(cxx_generalized_initializers) \
- F(cxx_generic_lambdas) \
F(cxx_inheriting_constructors) \
F(cxx_inline_namespaces) \
F(cxx_lambdas) \
- F(cxx_lambda_init_captures) \
F(cxx_local_type_template_args) \
F(cxx_long_long_type) \
F(cxx_noexcept) \
@@ -598,22 +677,41 @@ private:
F(cxx_range_for) \
F(cxx_raw_string_literals) \
F(cxx_reference_qualified_functions) \
- F(cxx_relaxed_constexpr) \
- F(cxx_return_type_deduction) \
F(cxx_right_angle_brackets) \
F(cxx_rvalue_references) \
F(cxx_sizeof_member) \
F(cxx_static_assert) \
F(cxx_strong_enums) \
- F(cxx_template_template_parameters) \
F(cxx_thread_local) \
F(cxx_trailing_return_types) \
F(cxx_unicode_literals) \
F(cxx_uniform_initialization) \
F(cxx_unrestricted_unions) \
F(cxx_user_literals) \
- F(cxx_variable_templates) \
F(cxx_variadic_macros) \
F(cxx_variadic_templates)
+#define FOR_EACH_CXX14_FEATURE(F) \
+ F(cxx_aggregate_default_initializers) \
+ F(cxx_attribute_deprecated) \
+ F(cxx_binary_literals) \
+ F(cxx_contextual_conversions) \
+ F(cxx_decltype_auto) \
+ F(cxx_digit_separators) \
+ F(cxx_generic_lambdas) \
+ F(cxx_lambda_init_captures) \
+ F(cxx_relaxed_constexpr) \
+ F(cxx_return_type_deduction) \
+ F(cxx_variable_templates)
+
+#define FOR_EACH_CXX_FEATURE(F) \
+ F(cxx_std_98) \
+ F(cxx_std_11) \
+ F(cxx_std_14) \
+ F(cxx_std_17) \
+ F(cxx_std_20) \
+ FOR_EACH_CXX98_FEATURE(F) \
+ FOR_EACH_CXX11_FEATURE(F) \
+ FOR_EACH_CXX14_FEATURE(F)
+
#endif
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index da1fe6d64..6d3e6ee30 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -1,126 +1,123 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmConfigure.h"
#include "cmAlgorithms.h"
-#include "cmDocumentationEntry.h"
+#include "cmDocumentationEntry.h" // IWYU pragma: keep
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
#include "cmcmd.h"
-#ifdef CMAKE_BUILD_WITH_CMAKE
-#include "cmDocumentation.h"
-#include "cmDynamicLoader.h"
+#ifndef CMAKE_BOOTSTRAP
+# include "cmDocumentation.h"
+# include "cmDynamicLoader.h"
#endif
#include "cmsys/Encoding.hxx"
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmsys/ConsoleBuf.hxx"
+
+#include "cm_uv.h"
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
+# include "cmsys/ConsoleBuf.hxx"
#endif
+
+#include <cassert>
+#include <cctype>
+#include <climits>
+#include <cstring>
#include <iostream>
-#include <string.h>
#include <string>
#include <vector>
-#ifdef CMAKE_USE_LIBUV
-#ifdef _WIN32
-#include <fcntl.h> /* _O_TEXT */
-#include <stdlib.h> /* _set_fmode, _fmode */
-#endif
-#include "cm_uv.h"
-#endif
-
-#ifdef CMAKE_BUILD_WITH_CMAKE
-static const char* cmDocumentationName[][2] = {
- { CM_NULLPTR, " cmake - Cross-Platform Makefile Generator." },
- { CM_NULLPTR, CM_NULLPTR }
+namespace {
+#ifndef CMAKE_BOOTSTRAP
+const char* cmDocumentationName[][2] = {
+ { nullptr, " cmake - Cross-Platform Makefile Generator." },
+ { nullptr, nullptr }
};
-static const char* cmDocumentationUsage[][2] = {
- { CM_NULLPTR, " cmake [options] <path-to-source>\n"
- " cmake [options] <path-to-existing-build>" },
- { CM_NULLPTR,
+const char* cmDocumentationUsage[][2] = {
+ { nullptr,
+ " cmake [options] <path-to-source>\n"
+ " cmake [options] <path-to-existing-build>\n"
+ " cmake [options] -S <path-to-source> -B <path-to-build>" },
+ { nullptr,
"Specify a source directory to (re-)generate a build system for "
"it in the current working directory. Specify an existing build "
"directory to re-generate its build system." },
- { CM_NULLPTR, CM_NULLPTR }
+ { nullptr, nullptr }
};
-static const char* cmDocumentationUsageNote[][2] = {
- { CM_NULLPTR, "Run 'cmake --help' for more information." },
- { CM_NULLPTR, CM_NULLPTR }
+const char* cmDocumentationUsageNote[][2] = {
+ { nullptr, "Run 'cmake --help' for more information." },
+ { nullptr, nullptr }
};
-#define CMAKE_BUILD_OPTIONS \
- " <dir> = Project binary directory to be built.\n" \
- " --target <tgt> = Build <tgt> instead of default targets.\n" \
- " May only be specified once.\n" \
- " --config <cfg> = For multi-configuration tools, choose <cfg>.\n" \
- " --clean-first = Build target 'clean' first, then build.\n" \
- " (To clean only, use --target 'clean'.)\n" \
- " --use-stderr = Ignored. Behavior is default in CMake >= 3.0.\n" \
- " -- = Pass remaining options to the native tool.\n"
-
-static const char* cmDocumentationOptions[][2] = {
+const char* cmDocumentationOptions[][2] = {
CMAKE_STANDARD_OPTIONS_TABLE,
{ "-E", "CMake command mode." },
{ "-L[A][H]", "List non-advanced cached variables." },
{ "--build <dir>", "Build a CMake-generated project binary tree." },
+ { "--install <dir>", "Install a CMake-generated project binary tree." },
+ { "--open <dir>", "Open generated project in the associated application." },
{ "-N", "View mode only." },
{ "-P <file>", "Process script mode." },
{ "--find-package", "Run in pkg-config like mode." },
- { "--graphviz=[file]", "Generate graphviz of dependencies, see "
- "CMakeGraphVizOptions.cmake for more." },
+ { "--graphviz=[file]",
+ "Generate graphviz of dependencies, see "
+ "CMakeGraphVizOptions.cmake for more." },
{ "--system-information [file]", "Dump information about this system." },
- { "--debug-trycompile", "Do not delete the try_compile build tree. Only "
- "useful on one try_compile at a time." },
+ { "--log-level=<ERROR|WARNING|NOTICE|STATUS|VERBOSE|DEBUG|TRACE>",
+ "Set the verbosity of messages from CMake files. "
+ "--loglevel is also accepted for backward compatibility reasons." },
+ { "--debug-trycompile",
+ "Do not delete the try_compile build tree. Only "
+ "useful on one try_compile at a time." },
{ "--debug-output", "Put cmake in a debug mode." },
{ "--trace", "Put cmake in trace mode." },
{ "--trace-expand", "Put cmake in trace mode with variable expansion." },
{ "--trace-source=<file>",
"Trace only this CMake file/module. Multiple options allowed." },
+ { "--trace-redirect=<file>",
+ "Redirect trace output to a file instead of stderr." },
{ "--warn-uninitialized", "Warn about uninitialized values." },
{ "--warn-unused-vars", "Warn about unused variables." },
{ "--no-warn-unused-cli", "Don't warn about command line options." },
- { "--check-system-vars", "Find problems with variable usage in system "
- "files." },
- { CM_NULLPTR, CM_NULLPTR }
+ { "--check-system-vars",
+ "Find problems with variable usage in system "
+ "files." },
+ { nullptr, nullptr }
};
#endif
-static int do_command(int ac, char const* const* av)
+int do_command(int ac, char const* const* av)
{
std::vector<std::string> args;
args.reserve(ac - 1);
- args.push_back(av[0]);
- args.insert(args.end(), av + 2, av + ac);
+ args.emplace_back(av[0]);
+ cmAppend(args, av + 2, av + ac);
return cmcmd::ExecuteCMakeCommand(args);
}
-int do_cmake(int ac, char const* const* av);
-static int do_build(int ac, char const* const* av);
-
-static cmMakefile* cmakemainGetMakefile(void* clientdata)
+cmMakefile* cmakemainGetMakefile(cmake* cm)
{
- cmake* cm = (cmake*)clientdata;
if (cm && cm->GetDebugOutput()) {
cmGlobalGenerator* gg = cm->GetGlobalGenerator();
if (gg) {
return gg->GetCurrentMakefile();
}
}
- return CM_NULLPTR;
+ return nullptr;
}
-static std::string cmakemainGetStack(void* clientdata)
+std::string cmakemainGetStack(cmake* cm)
{
std::string msg;
- cmMakefile* mf = cmakemainGetMakefile(clientdata);
+ cmMakefile* mf = cmakemainGetMakefile(cm);
if (mf) {
msg = mf->FormatListFileStack();
if (!msg.empty()) {
@@ -131,77 +128,25 @@ static std::string cmakemainGetStack(void* clientdata)
return msg;
}
-static void cmakemainMessageCallback(const char* m, const char* /*unused*/,
- bool& /*unused*/, void* clientdata)
+void cmakemainMessageCallback(const std::string& m, const char* /*unused*/,
+ cmake* cm)
{
- std::cerr << m << cmakemainGetStack(clientdata) << std::endl << std::flush;
+ std::cerr << m << cmakemainGetStack(cm) << std::endl;
}
-static void cmakemainProgressCallback(const char* m, float prog,
- void* clientdata)
+void cmakemainProgressCallback(const std::string& m, float prog, cmake* cm)
{
- cmMakefile* mf = cmakemainGetMakefile(clientdata);
+ cmMakefile* mf = cmakemainGetMakefile(cm);
std::string dir;
- if ((mf) && (strstr(m, "Configuring") == m) && (prog < 0)) {
- dir = " ";
- dir += mf->GetCurrentSourceDirectory();
- } else if ((mf) && (strstr(m, "Generating") == m)) {
- dir = " ";
- dir += mf->GetCurrentBinaryDirectory();
+ if (mf && cmHasLiteralPrefix(m, "Configuring") && (prog < 0)) {
+ dir = cmStrCat(' ', mf->GetCurrentSourceDirectory());
+ } else if (mf && cmHasLiteralPrefix(m, "Generating")) {
+ dir = cmStrCat(' ', mf->GetCurrentBinaryDirectory());
}
if ((prog < 0) || (!dir.empty())) {
- std::cout << "-- " << m << dir << cmakemainGetStack(clientdata)
- << std::endl;
+ std::cout << "-- " << m << dir << cmakemainGetStack(cm) << std::endl;
}
-
- std::cout.flush();
-}
-
-int main(int ac, char const* const* av)
-{
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
- // Replace streambuf so we can output Unicode to console
- cmsys::ConsoleBuf::Manager consoleOut(std::cout);
- consoleOut.SetUTF8Pipes();
- cmsys::ConsoleBuf::Manager consoleErr(std::cerr, true);
- consoleErr.SetUTF8Pipes();
-#endif
- cmsys::Encoding::CommandLineArguments args =
- cmsys::Encoding::CommandLineArguments::Main(ac, av);
- ac = args.argc();
- av = args.argv();
-
-#if defined(CMAKE_USE_LIBUV) && defined(_WIN32)
- // Perform libuv one-time initialization now, and then un-do its
- // global _fmode setting so that using libuv does not change the
- // default file text/binary mode. See libuv issue 840.
- uv_loop_close(uv_default_loop());
-#ifdef _MSC_VER
- _set_fmode(_O_TEXT);
-#else
- _fmode = _O_TEXT;
-#endif
-#endif
-
- cmSystemTools::EnableMSVCDebugHook();
- cmSystemTools::FindCMakeResources(av[0]);
- if (ac > 1) {
- if (strcmp(av[1], "--build") == 0) {
- return do_build(ac, av);
- }
- if (strcmp(av[1], "-E") == 0) {
- return do_command(ac, av);
- }
- }
- int ret = do_cmake(ac, av);
-#ifdef CMAKE_BUILD_WITH_CMAKE
- cmDynamicLoader::FlushCache();
-#endif
-#ifdef CMAKE_USE_LIBUV
- uv_loop_close(uv_default_loop());
-#endif
- return ret;
}
int do_cmake(int ac, char const* const* av)
@@ -212,12 +157,12 @@ int do_cmake(int ac, char const* const* av)
return 1;
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
cmDocumentation doc;
doc.addCMakeStandardDocSections();
if (doc.CheckOptions(ac, av)) {
// Construct and print requested documentation.
- cmake hcm(cmake::RoleInternal);
+ cmake hcm(cmake::RoleInternal, cmState::Unknown);
hcm.SetHomeDirectory("");
hcm.SetHomeOutputDirectory("");
hcm.AddCMakePaths();
@@ -227,9 +172,7 @@ int do_cmake(int ac, char const* const* av)
std::vector<std::string> args(av, av + ac);
hcm.SetCacheArgs(args);
- std::vector<cmDocumentationEntry> generators;
-
- hcm.GetGeneratorDocumentation(generators);
+ auto generators = hcm.GetGeneratorsDocumentation();
doc.SetName("cmake");
doc.SetSection("Name", cmDocumentationName);
@@ -285,21 +228,21 @@ int do_cmake(int ac, char const* const* av)
} else if (cmHasLiteralPrefix(av[i], "-P")) {
if (i == ac - 1) {
cmSystemTools::Error("No script specified for argument -P");
- } else {
- workingMode = cmake::SCRIPT_MODE;
- args.push_back(av[i]);
- i++;
- args.push_back(av[i]);
+ return 1;
}
+ workingMode = cmake::SCRIPT_MODE;
+ args.emplace_back(av[i]);
+ i++;
+ args.emplace_back(av[i]);
} else if (cmHasLiteralPrefix(av[i], "--find-package")) {
workingMode = cmake::FIND_PACKAGE_MODE;
- args.push_back(av[i]);
+ args.emplace_back(av[i]);
} else {
- args.push_back(av[i]);
+ args.emplace_back(av[i]);
}
}
if (sysinfo) {
- cmake cm(cmake::RoleProject);
+ cmake cm(cmake::RoleProject, cmState::Project);
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
int ret = cm.GetSystemInformation(args);
@@ -307,33 +250,48 @@ int do_cmake(int ac, char const* const* av)
}
cmake::Role const role =
workingMode == cmake::SCRIPT_MODE ? cmake::RoleScript : cmake::RoleProject;
- cmake cm(role);
+ cmState::Mode mode = cmState::Unknown;
+ switch (workingMode) {
+ case cmake::NORMAL_MODE:
+ mode = cmState::Project;
+ break;
+ case cmake::SCRIPT_MODE:
+ mode = cmState::Script;
+ break;
+ case cmake::FIND_PACKAGE_MODE:
+ mode = cmState::FindPackage;
+ break;
+ }
+ cmake cm(role, mode);
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
- cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void*)&cm);
- cm.SetProgressCallback(cmakemainProgressCallback, (void*)&cm);
+ cmSystemTools::SetMessageCallback(
+ [&cm](const std::string& msg, const char* title) {
+ cmakemainMessageCallback(msg, title, &cm);
+ });
+ cm.SetProgressCallback([&cm](const std::string& msg, float prog) {
+ cmakemainProgressCallback(msg, prog, &cm);
+ });
cm.SetWorkingMode(workingMode);
int res = cm.Run(args, view_only);
if (list_cached || list_all_cached) {
std::cout << "-- Cache values" << std::endl;
std::vector<std::string> keys = cm.GetState()->GetCacheEntryKeys();
- for (std::vector<std::string>::const_iterator it = keys.begin();
- it != keys.end(); ++it) {
- cmStateEnums::CacheEntryType t = cm.GetState()->GetCacheEntryType(*it);
+ for (std::string const& k : keys) {
+ cmStateEnums::CacheEntryType t = cm.GetState()->GetCacheEntryType(k);
if (t != cmStateEnums::INTERNAL && t != cmStateEnums::STATIC &&
t != cmStateEnums::UNINITIALIZED) {
const char* advancedProp =
- cm.GetState()->GetCacheEntryProperty(*it, "ADVANCED");
+ cm.GetState()->GetCacheEntryProperty(k, "ADVANCED");
if (list_all_cached || !advancedProp) {
if (list_help) {
std::cout << "// "
- << cm.GetState()->GetCacheEntryProperty(*it,
- "HELPSTRING")
+ << cm.GetState()->GetCacheEntryProperty(k, "HELPSTRING")
<< std::endl;
}
- std::cout << *it << ":" << cmState::CacheEntryTypeToString(t) << "="
- << cm.GetState()->GetCacheEntryValue(*it) << std::endl;
+ std::cout << k << ":" << cmState::CacheEntryTypeToString(t) << "="
+ << cm.GetState()->GetCacheEntryValue(k) << std::endl;
if (list_help) {
std::cout << std::endl;
}
@@ -350,18 +308,51 @@ int do_cmake(int ac, char const* const* av)
return 0;
}
-static int do_build(int ac, char const* const* av)
+int extract_job_number(int& index, char const* current, char const* next,
+ int len_of_flag)
{
-#ifndef CMAKE_BUILD_WITH_CMAKE
+ std::string command(current);
+ std::string jobString = command.substr(len_of_flag);
+ if (jobString.empty() && next && isdigit(next[0])) {
+ ++index; // skip parsing the job number
+ jobString = std::string(next);
+ }
+
+ int jobs = -1;
+ unsigned long numJobs = 0;
+ if (jobString.empty()) {
+ jobs = cmake::DEFAULT_BUILD_PARALLEL_LEVEL;
+ } else if (cmStrToULong(jobString, &numJobs)) {
+ if (numJobs == 0) {
+ std::cerr
+ << "The <jobs> value requires a positive integer argument.\n\n";
+ } else if (numJobs > INT_MAX) {
+ std::cerr << "The <jobs> value is too large.\n\n";
+ } else {
+ jobs = int(numJobs);
+ }
+ } else {
+ std::cerr << "'" << command.substr(0, len_of_flag) << "' invalid number '"
+ << jobString << "' given.\n\n";
+ }
+ return jobs;
+}
+
+int do_build(int ac, char const* const* av)
+{
+#ifdef CMAKE_BOOTSTRAP
std::cerr << "This cmake does not support --build\n";
return -1;
#else
- std::string target;
+ int jobs = cmake::NO_BUILD_PARALLEL_LEVEL;
+ std::vector<std::string> targets;
std::string config = "Debug";
std::string dir;
std::vector<std::string> nativeOptions;
- bool clean = false;
- bool hasTarget = false;
+ bool cleanFirst = false;
+ bool foundClean = false;
+ bool foundNonClean = false;
+ bool verbose = cmSystemTools::HasEnv("VERBOSE");
enum Doing
{
@@ -374,20 +365,32 @@ static int do_build(int ac, char const* const* av)
Doing doing = DoingDir;
for (int i = 2; i < ac; ++i) {
if (doing == DoingNative) {
- nativeOptions.push_back(av[i]);
- } else if (strcmp(av[i], "--target") == 0) {
- if (!hasTarget) {
- doing = DoingTarget;
- hasTarget = true;
- } else {
- std::cerr << "'--target' may not be specified more than once.\n\n";
- dir = "";
- break;
+ nativeOptions.emplace_back(av[i]);
+ } else if (cmHasLiteralPrefix(av[i], "-j")) {
+ const char* nextArg = ((i + 1 < ac) ? av[i + 1] : nullptr);
+ jobs = extract_job_number(i, av[i], nextArg, sizeof("-j") - 1);
+ if (jobs < 0) {
+ dir.clear();
}
+ doing = DoingNone;
+ } else if (cmHasLiteralPrefix(av[i], "--parallel")) {
+ const char* nextArg = ((i + 1 < ac) ? av[i + 1] : nullptr);
+ jobs = extract_job_number(i, av[i], nextArg, sizeof("--parallel") - 1);
+ if (jobs < 0) {
+ dir.clear();
+ }
+ doing = DoingNone;
+ } else if ((strcmp(av[i], "--target") == 0) ||
+ (strcmp(av[i], "-t") == 0)) {
+ doing = DoingTarget;
} else if (strcmp(av[i], "--config") == 0) {
doing = DoingConfig;
} else if (strcmp(av[i], "--clean-first") == 0) {
- clean = true;
+ cleanFirst = true;
+ doing = DoingNone;
+ } else if ((strcmp(av[i], "--verbose") == 0) ||
+ (strcmp(av[i], "-v") == 0)) {
+ verbose = true;
doing = DoingNone;
} else if (strcmp(av[i], "--use-stderr") == 0) {
/* tolerate legacy option */
@@ -400,8 +403,23 @@ static int do_build(int ac, char const* const* av)
doing = DoingNone;
break;
case DoingTarget:
- target = av[i];
- doing = DoingNone;
+ if (strlen(av[i]) == 0) {
+ std::cerr << "Warning: Argument number " << i
+ << " after --target option is empty." << std::endl;
+ } else {
+ targets.emplace_back(av[i]);
+ if (strcmp(av[i], "clean") == 0) {
+ foundClean = true;
+ } else {
+ foundNonClean = true;
+ }
+ }
+ if (foundClean && foundNonClean) {
+ std::cerr << "Error: Building 'clean' and other targets together "
+ "is not supported."
+ << std::endl;
+ dir.clear();
+ }
break;
case DoingConfig:
config = av[i];
@@ -409,25 +427,282 @@ static int do_build(int ac, char const* const* av)
break;
default:
std::cerr << "Unknown argument " << av[i] << std::endl;
- dir = "";
+ dir.clear();
break;
}
}
}
+
+ if (jobs == cmake::NO_BUILD_PARALLEL_LEVEL) {
+ std::string parallel;
+ if (cmSystemTools::GetEnv("CMAKE_BUILD_PARALLEL_LEVEL", parallel)) {
+ if (parallel.empty()) {
+ jobs = cmake::DEFAULT_BUILD_PARALLEL_LEVEL;
+ } else {
+ unsigned long numJobs = 0;
+ if (cmStrToULong(parallel, &numJobs)) {
+ if (numJobs == 0) {
+ std::cerr << "The CMAKE_BUILD_PARALLEL_LEVEL environment variable "
+ "requires a positive integer argument.\n\n";
+ dir.clear();
+ } else if (numJobs > INT_MAX) {
+ std::cerr << "The CMAKE_BUILD_PARALLEL_LEVEL environment variable "
+ "is too large.\n\n";
+ dir.clear();
+ } else {
+ jobs = int(numJobs);
+ }
+ } else {
+ std::cerr << "'CMAKE_BUILD_PARALLEL_LEVEL' environment variable\n"
+ << "invalid number '" << parallel << "' given.\n\n";
+ dir.clear();
+ }
+ }
+ }
+ }
+
if (dir.empty()) {
/* clang-format off */
std::cerr <<
"Usage: cmake --build <dir> [options] [-- [native-options]]\n"
"Options:\n"
- CMAKE_BUILD_OPTIONS
+ " <dir> = Project binary directory to be built.\n"
+ " --parallel [<jobs>], -j [<jobs>]\n"
+ " = Build in parallel using the given number of jobs. \n"
+ " If <jobs> is omitted the native build tool's \n"
+ " default number is used.\n"
+ " The CMAKE_BUILD_PARALLEL_LEVEL environment "
+ "variable\n"
+ " specifies a default parallel level when this "
+ "option\n"
+ " is not given.\n"
+ " --target <tgt>..., -t <tgt>... \n"
+ " = Build <tgt> instead of default targets.\n"
+ " --config <cfg> = For multi-configuration tools, choose <cfg>.\n"
+ " --clean-first = Build target 'clean' first, then build.\n"
+ " (To clean only, use --target 'clean'.)\n"
+ " --verbose, -v = Enable verbose output - if supported - including\n"
+ " the build commands to be executed. \n"
+ " -- = Pass remaining options to the native tool.\n"
+ ;
+ /* clang-format on */
+ return 1;
+ }
+
+ cmake cm(cmake::RoleInternal, cmState::Project);
+ cmSystemTools::SetMessageCallback(
+ [&cm](const std::string& msg, const char* title) {
+ cmakemainMessageCallback(msg, title, &cm);
+ });
+ cm.SetProgressCallback([&cm](const std::string& msg, float prog) {
+ cmakemainProgressCallback(msg, prog, &cm);
+ });
+ return cm.Build(jobs, dir, targets, config, nativeOptions, cleanFirst,
+ verbose);
+#endif
+}
+
+int do_install(int ac, char const* const* av)
+{
+#ifdef CMAKE_BOOTSTRAP
+ std::cerr << "This cmake does not support --install\n";
+ return -1;
+#else
+ assert(1 < ac);
+
+ std::string config;
+ std::string component;
+ std::string prefix;
+ std::string dir;
+ bool strip = false;
+ bool verbose = cmSystemTools::HasEnv("VERBOSE");
+
+ enum Doing
+ {
+ DoingNone,
+ DoingDir,
+ DoingConfig,
+ DoingComponent,
+ DoingPrefix,
+ };
+
+ Doing doing = DoingDir;
+
+ for (int i = 2; i < ac; ++i) {
+ if (strcmp(av[i], "--config") == 0) {
+ doing = DoingConfig;
+ } else if (strcmp(av[i], "--component") == 0) {
+ doing = DoingComponent;
+ } else if (strcmp(av[i], "--prefix") == 0) {
+ doing = DoingPrefix;
+ } else if (strcmp(av[i], "--strip") == 0) {
+ strip = true;
+ doing = DoingNone;
+ } else if ((strcmp(av[i], "--verbose") == 0) ||
+ (strcmp(av[i], "-v") == 0)) {
+ verbose = true;
+ doing = DoingNone;
+ } else {
+ switch (doing) {
+ case DoingDir:
+ dir = cmSystemTools::CollapseFullPath(av[i]);
+ doing = DoingNone;
+ break;
+ case DoingConfig:
+ config = av[i];
+ doing = DoingNone;
+ break;
+ case DoingComponent:
+ component = av[i];
+ doing = DoingNone;
+ break;
+ case DoingPrefix:
+ prefix = av[i];
+ doing = DoingNone;
+ break;
+ default:
+ std::cerr << "Unknown argument " << av[i] << std::endl;
+ dir.clear();
+ break;
+ }
+ }
+ }
+
+ if (dir.empty()) {
+ /* clang-format off */
+ std::cerr <<
+ "Usage: cmake --install <dir> [options]\n"
+ "Options:\n"
+ " <dir> = Project binary directory to install.\n"
+ " --config <cfg> = For multi-configuration tools, choose <cfg>.\n"
+ " --component <comp> = Component-based install. Only install <comp>.\n"
+ " --prefix <prefix> = The installation prefix CMAKE_INSTALL_PREFIX.\n"
+ " --strip = Performing install/strip.\n"
+ " -v --verbose = Enable verbose output.\n"
;
/* clang-format on */
return 1;
}
- cmake cm(cmake::RoleInternal);
- cmSystemTools::SetMessageCallback(cmakemainMessageCallback, (void*)&cm);
- cm.SetProgressCallback(cmakemainProgressCallback, (void*)&cm);
- return cm.Build(dir, target, config, nativeOptions, clean);
+ cmake cm(cmake::RoleScript, cmState::Script);
+
+ cmSystemTools::SetMessageCallback(
+ [&cm](const std::string& msg, const char* title) {
+ cmakemainMessageCallback(msg, title, &cm);
+ });
+ cm.SetProgressCallback([&cm](const std::string& msg, float prog) {
+ cmakemainProgressCallback(msg, prog, &cm);
+ });
+ cm.SetHomeDirectory("");
+ cm.SetHomeOutputDirectory("");
+ cm.SetDebugOutputOn(verbose);
+ cm.SetWorkingMode(cmake::SCRIPT_MODE);
+
+ std::vector<std::string> args{ av[0] };
+
+ if (!prefix.empty()) {
+ args.emplace_back("-DCMAKE_INSTALL_PREFIX=" + prefix);
+ }
+
+ if (!component.empty()) {
+ args.emplace_back("-DCMAKE_INSTALL_COMPONENT=" + component);
+ }
+
+ if (strip) {
+ args.emplace_back("-DCMAKE_INSTALL_DO_STRIP=1");
+ }
+
+ if (!config.empty()) {
+ args.emplace_back("-DCMAKE_INSTALL_CONFIG_NAME=" + config);
+ }
+
+ args.emplace_back("-P");
+ args.emplace_back(dir + "/cmake_install.cmake");
+
+ return cm.Run(args) ? 1 : 0;
+#endif
+}
+
+int do_open(int ac, char const* const* av)
+{
+#ifdef CMAKE_BOOTSTRAP
+ std::cerr << "This cmake does not support --open\n";
+ return -1;
+#else
+ std::string dir;
+
+ enum Doing
+ {
+ DoingNone,
+ DoingDir,
+ };
+ Doing doing = DoingDir;
+ for (int i = 2; i < ac; ++i) {
+ switch (doing) {
+ case DoingDir:
+ dir = cmSystemTools::CollapseFullPath(av[i]);
+ doing = DoingNone;
+ break;
+ default:
+ std::cerr << "Unknown argument " << av[i] << std::endl;
+ dir.clear();
+ break;
+ }
+ }
+ if (dir.empty()) {
+ std::cerr << "Usage: cmake --open <dir>\n";
+ return 1;
+ }
+
+ cmake cm(cmake::RoleInternal, cmState::Unknown);
+ cmSystemTools::SetMessageCallback(
+ [&cm](const std::string& msg, const char* title) {
+ cmakemainMessageCallback(msg, title, &cm);
+ });
+ cm.SetProgressCallback([&cm](const std::string& msg, float prog) {
+ cmakemainProgressCallback(msg, prog, &cm);
+ });
+ return cm.Open(dir, false) ? 0 : 1;
#endif
}
+} // namespace
+
+int main(int ac, char const* const* av)
+{
+ cmSystemTools::EnsureStdPipes();
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
+ // Replace streambuf so we can output Unicode to console
+ cmsys::ConsoleBuf::Manager consoleOut(std::cout);
+ consoleOut.SetUTF8Pipes();
+ cmsys::ConsoleBuf::Manager consoleErr(std::cerr, true);
+ consoleErr.SetUTF8Pipes();
+#endif
+ cmsys::Encoding::CommandLineArguments args =
+ cmsys::Encoding::CommandLineArguments::Main(ac, av);
+ ac = args.argc();
+ av = args.argv();
+
+ cmSystemTools::EnableMSVCDebugHook();
+ cmSystemTools::InitializeLibUV();
+ cmSystemTools::FindCMakeResources(av[0]);
+ if (ac > 1) {
+ if (strcmp(av[1], "--build") == 0) {
+ return do_build(ac, av);
+ }
+ if (strcmp(av[1], "--install") == 0) {
+ return do_install(ac, av);
+ }
+ if (strcmp(av[1], "--open") == 0) {
+ return do_open(ac, av);
+ }
+ if (strcmp(av[1], "-E") == 0) {
+ return do_command(ac, av);
+ }
+ }
+ int ret = do_cmake(ac, av);
+#ifndef CMAKE_BOOTSTRAP
+ cmDynamicLoader::FlushCache();
+#endif
+ uv_loop_close(uv_default_loop());
+ return ret;
+}
diff --git a/Source/cmakexbuild.cxx b/Source/cmakexbuild.cxx
deleted file mode 100644
index 72da456d4..000000000
--- a/Source/cmakexbuild.cxx
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-
-#include "cmConfigure.h" // IWYU pragma: keep
-
-#include "cmsys/Process.h"
-#include <iostream>
-#include <string>
-#include <vector>
-
-#include "cmSystemTools.h"
-
-// This is a wrapper program for xcodebuild
-// it calls xcodebuild, and does two things
-// it removes much of the output, all the setenv
-// stuff. Also, it checks for the text file busy
-// error, and re-runs xcodebuild until that error does
-// not show up.
-
-int RunXCode(std::vector<const char*>& argv, bool& hitbug)
-{
- hitbug = false;
- cmsysProcess* cp = cmsysProcess_New();
- cmsysProcess_SetCommand(cp, &*argv.begin());
- cmsysProcess_SetTimeout(cp, 0);
- cmsysProcess_Execute(cp);
- std::vector<char> out;
- std::vector<char> err;
- std::string line;
- int pipe = cmSystemTools::WaitForLine(cp, line, 100.0, out, err);
- while (pipe != cmsysProcess_Pipe_None) {
- if (line.find("/bin/sh: bad interpreter: Text file busy") !=
- std::string::npos) {
- hitbug = true;
- std::cerr << "Hit xcodebuild bug : " << line << "\n";
- }
- // if the bug is hit, no more output should be generated
- // because it may contain bogus errors
- // also remove all output with setenv in it to tone down
- // the verbosity of xcodebuild
- if (!hitbug && (line.find("setenv") == std::string::npos)) {
- if (pipe == cmsysProcess_Pipe_STDERR) {
- std::cerr << line << "\n";
- } else if (pipe == cmsysProcess_Pipe_STDOUT) {
- std::cout << line << "\n";
- }
- }
- pipe = cmSystemTools::WaitForLine(cp, line, 100, out, err);
- }
- cmsysProcess_WaitForExit(cp, 0);
- if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) {
- return cmsysProcess_GetExitValue(cp);
- }
- if (cmsysProcess_GetState(cp) == cmsysProcess_State_Error) {
- return -1;
- }
- return -1;
-}
-
-int main(int ac, char* av[])
-{
- std::vector<const char*> argv;
- argv.push_back("xcodebuild");
- for (int i = 1; i < ac; i++) {
- argv.push_back(av[i]);
- }
- argv.push_back(0);
- bool hitbug = true;
- int ret = 0;
- while (hitbug) {
- ret = RunXCode(argv, hitbug);
- }
- if (ret < 0) {
- return 255;
- }
- return ret;
-}
diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx
index 0c5bbe2df..caf645301 100644
--- a/Source/cmcldeps.cxx
+++ b/Source/cmcldeps.cxx
@@ -18,13 +18,15 @@
// /showIncludes is equivalent to -MD, not -MMD, that is, system headers are
// included.
-#include "cmSystemTools.h"
-#include "cmsys/Encoding.hxx"
-
#include <algorithm>
#include <sstream>
+
#include <windows.h>
+#include "cmsys/Encoding.hxx"
+
+#include "cmSystemTools.h"
+
// We don't want any wildcard expansion.
// See http://msdn.microsoft.com/en-us/library/zay8tzh6(v=vs.85).aspx
void _setargv()
@@ -221,7 +223,7 @@ static int process(const std::string& srcfilename, const std::string& dfile,
while (std::getline(ss, line)) {
if (startsWith(line, prefix)) {
std::string inc = trimLeadingSpace(line.substr(prefix.size()).c_str());
- if (inc[inc.size() - 1] == '\r') // blech, stupid \r\n
+ if (inc.back() == '\r') // blech, stupid \r\n
inc = inc.substr(0, inc.size() - 1);
includes.push_back(inc);
} else {
@@ -276,7 +278,7 @@ int main()
std::string clrest = rest;
// rc: /fo x.dir\x.rc.res -> cl: /out:x.dir\x.rc.res.dep.obj
- clrest = replace(clrest, "/fo", "/out:");
+ clrest = replace(clrest, "/fo ", "/out:");
clrest = replace(clrest, objfile, objfile + ".dep.obj ");
cl = "\"" + cl + "\" /P /DRC_INVOKED /TC ";
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index d5b086174..d05e3c81b 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -3,46 +3,58 @@
#include "cmcmd.h"
#include "cmAlgorithms.h"
+#include "cmDuration.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
-#include "cmQtAutoGenerators.h"
+#include "cmQtAutoMocUic.h"
+#include "cmQtAutoRcc.h"
+#include "cmRange.h"
+#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmUtils.hxx"
#include "cmVersion.h"
-#include "cm_auto_ptr.hxx"
#include "cmake.h"
-#if defined(HAVE_SERVER_MODE) && HAVE_SERVER_MODE
-#include "cmServer.h"
-#include "cmServerConnection.h"
+#if !defined(CMAKE_BOOTSTRAP)
+# include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback.
+# include "cmServer.h"
+# include "cmServerConnection.h"
#endif
-#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback.
-#endif
+#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32)
+# include "cmsys/ConsoleBuf.hxx"
+
+# include "cmFileTime.h"
-#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32)
-#include "bindexplib.h"
+# include "bindexplib.h"
#endif
-#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32) && !defined(__CYGWIN__)
-#include "cmVisualStudioWCEPlatformParser.h"
+#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32) && !defined(__CYGWIN__)
+# include "cmVisualStudioWCEPlatformParser.h"
#endif
-#include "cmConfigure.h"
+#include <array>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
+#include <iostream>
+#include <memory>
+#include <sstream>
+#include <utility>
+
+#include <cm/string_view>
+
#include "cmsys/Directory.hxx"
#include "cmsys/FStream.hxx"
#include "cmsys/Process.h"
#include "cmsys/Terminal.h"
-#include <algorithm>
-#include <iostream>
-#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
+
+class cmConnection;
int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
std::vector<std::string>::const_iterator argEnd);
@@ -53,7 +65,7 @@ void CMakeCommandUsage(const char* program)
{
std::ostringstream errorStream;
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
/* clang-format off */
errorStream
<< "cmake version " << cmVersion::GetCMakeVersion() << "\n";
@@ -73,7 +85,8 @@ void CMakeCommandUsage(const char* program)
<< " capabilities - Report capabilities built into cmake "
"in JSON format\n"
<< " chdir dir cmd [args...] - run command in a given directory\n"
- << " compare_files file1 file2 - check if file1 is same as file2\n"
+ << " compare_files [--ignore-eol] file1 file2\n"
+ << " - check if file1 is same as file2\n"
<< " copy <file>... destination - copy files to destination "
"(either file or directory)\n"
<< " copy_directory <dir>... destination - copy content of <dir>... "
@@ -88,18 +101,26 @@ void CMakeCommandUsage(const char* program)
<< " environment - display the current environment\n"
<< " make_directory <dir>... - create parent and <dir> directories\n"
<< " md5sum <file>... - create MD5 checksum of files\n"
+ << " sha1sum <file>... - create SHA1 checksum of files\n"
+ << " sha224sum <file>... - create SHA224 checksum of files\n"
+ << " sha256sum <file>... - create SHA256 checksum of files\n"
+ << " sha384sum <file>... - create SHA384 checksum of files\n"
+ << " sha512sum <file>... - create SHA512 checksum of files\n"
<< " remove [-f] <file>... - remove the file(s), use -f to force "
"it\n"
- << " remove_directory dir - remove a directory and its contents\n"
+ << " remove_directory <dir>... - remove directories and their contents\n"
<< " rename oldname newname - rename a file or directory "
"(on one volume)\n"
<< " server - start cmake in server mode\n"
<< " sleep <number>... - sleep for given number of seconds\n"
<< " tar [cxt][vf][zjJ] file.tar [file/dir1 file/dir2 ...]\n"
<< " - create or extract a tar or zip archive\n"
- << " time command [args...] - run command and return elapsed time\n"
- << " touch file - touch a file.\n"
- << " touch_nocreate file - touch a file but do not create it.\n"
+ << " time command [args...] - run command and display elapsed time\n"
+ << " touch <file>... - touch a <file>.\n"
+ << " touch_nocreate <file>... - touch a <file> but do not create it.\n"
+ << " create_symlink old new - create a symbolic link new -> old\n"
+ << " true - do nothing with an exit code of 0\n"
+ << " false - do nothing with an exit code of 1\n"
#if defined(_WIN32) && !defined(__CYGWIN__)
<< "Available on Windows only:\n"
<< " delete_regv key - delete registry value\n"
@@ -108,14 +129,11 @@ void CMakeCommandUsage(const char* program)
<< " env_vs9_wince sdkname - displays a batch file which sets the "
"environment for the provided Windows CE SDK installed in VS2008\n"
<< " write_regv key value - write registry value\n"
-#else
- << "Available on UNIX only:\n"
- << " create_symlink old new - create a symbolic link new -> old\n"
#endif
;
/* clang-format on */
- cmSystemTools::Error(errorStream.str().c_str());
+ cmSystemTools::Error(errorStream.str());
}
static bool cmTarFilesFrom(std::string const& file,
@@ -124,14 +142,14 @@ static bool cmTarFilesFrom(std::string const& file,
if (cmSystemTools::FileIsDirectory(file)) {
std::ostringstream e;
e << "-E tar --files-from= file '" << file << "' is a directory";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
}
cmsys::ifstream fin(file.c_str());
if (!fin) {
std::ostringstream e;
e << "-E tar --files-from= file '" << file << "' not found";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
}
std::string line;
@@ -145,7 +163,7 @@ static bool cmTarFilesFrom(std::string const& file,
std::ostringstream e;
e << "-E tar --files-from='" << file << "' file invalid line:\n"
<< line << "\n";
- cmSystemTools::Error(e.str().c_str());
+ cmSystemTools::Error(e.str());
return false;
} else {
files.push_back(line);
@@ -154,7 +172,303 @@ static bool cmTarFilesFrom(std::string const& file,
return true;
}
-int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
+static int HandleIWYU(const std::string& runCmd,
+ const std::string& /* sourceFile */,
+ const std::vector<std::string>& orig_cmd)
+{
+ // Construct the iwyu command line by taking what was given
+ // and adding all the arguments we give to the compiler.
+ std::vector<std::string> iwyu_cmd = cmExpandedList(runCmd, true);
+ cmAppend(iwyu_cmd, orig_cmd.begin() + 1, orig_cmd.end());
+ // Run the iwyu command line. Capture its stderr and hide its stdout.
+ // Ignore its return code because the tool always returns non-zero.
+ std::string stdErr;
+ int ret;
+ if (!cmSystemTools::RunSingleCommand(iwyu_cmd, nullptr, &stdErr, &ret,
+ nullptr, cmSystemTools::OUTPUT_NONE)) {
+ std::cerr << "Error running '" << iwyu_cmd[0] << "': " << stdErr << "\n";
+ return 1;
+ }
+ // Warn if iwyu reported anything.
+ if (stdErr.find("should remove these lines:") != std::string::npos ||
+ stdErr.find("should add these lines:") != std::string::npos) {
+ std::cerr << "Warning: include-what-you-use reported diagnostics:\n"
+ << stdErr << "\n";
+ }
+ // always return 0 we don't want to break the compile
+ return 0;
+}
+
+static int HandleTidy(const std::string& runCmd, const std::string& sourceFile,
+ const std::vector<std::string>& orig_cmd)
+{
+ // Construct the clang-tidy command line by taking what was given
+ // and adding our compiler command line. The clang-tidy tool will
+ // automatically skip over the compiler itself and extract the
+ // options.
+ int ret;
+ std::vector<std::string> tidy_cmd = cmExpandedList(runCmd, true);
+ tidy_cmd.push_back(sourceFile);
+ tidy_cmd.emplace_back("--");
+ cmAppend(tidy_cmd, orig_cmd);
+
+ // Run the tidy command line. Capture its stdout and hide its stderr.
+ std::string stdOut;
+ std::string stdErr;
+ if (!cmSystemTools::RunSingleCommand(tidy_cmd, &stdOut, &stdErr, &ret,
+ nullptr, cmSystemTools::OUTPUT_NONE)) {
+ std::cerr << "Error running '" << tidy_cmd[0] << "': " << stdErr << "\n";
+ return 1;
+ }
+ // Output the stdout from clang-tidy to stderr
+ std::cerr << stdOut;
+ // If clang-tidy exited with an error do the same.
+ if (ret != 0) {
+ std::cerr << stdErr;
+ }
+ return ret;
+}
+
+static int HandleLWYU(const std::string& runCmd,
+ const std::string& /* sourceFile */,
+ const std::vector<std::string>&)
+{
+ // Construct the ldd -r -u (link what you use lwyu) command line
+ // ldd -u -r lwuy target
+ std::vector<std::string> lwyu_cmd;
+ lwyu_cmd.emplace_back("ldd");
+ lwyu_cmd.emplace_back("-u");
+ lwyu_cmd.emplace_back("-r");
+ lwyu_cmd.push_back(runCmd);
+
+ // Run the ldd -u -r command line.
+ // Capture its stdout and hide its stderr.
+ // Ignore its return code because the tool always returns non-zero
+ // if there are any warnings, but we just want to warn.
+ std::string stdOut;
+ std::string stdErr;
+ int ret;
+ if (!cmSystemTools::RunSingleCommand(lwyu_cmd, &stdOut, &stdErr, &ret,
+ nullptr, cmSystemTools::OUTPUT_NONE)) {
+ std::cerr << "Error running '" << lwyu_cmd[0] << "': " << stdErr << "\n";
+ return 1;
+ }
+
+ // Output the stdout from ldd -r -u to stderr
+ // Warn if lwyu reported anything.
+ if (stdOut.find("Unused direct dependencies:") != std::string::npos) {
+ std::cerr << "Warning: " << stdOut;
+ }
+ return 0;
+}
+
+static int HandleCppLint(const std::string& runCmd,
+ const std::string& sourceFile,
+ const std::vector<std::string>&)
+{
+ // Construct the cpplint command line.
+ std::vector<std::string> cpplint_cmd = cmExpandedList(runCmd, true);
+ cpplint_cmd.push_back(sourceFile);
+
+ // Run the cpplint command line. Capture its output.
+ std::string stdOut;
+ int ret;
+ if (!cmSystemTools::RunSingleCommand(cpplint_cmd, &stdOut, &stdOut, &ret,
+ nullptr, cmSystemTools::OUTPUT_NONE)) {
+ std::cerr << "Error running '" << cpplint_cmd[0] << "': " << stdOut
+ << "\n";
+ return 1;
+ }
+ if (!stdOut.empty()) {
+ std::cerr << "Warning: cpplint diagnostics:\n";
+ // Output the output from cpplint to stderr
+ std::cerr << stdOut;
+ }
+
+ // always return 0 so the build can continue as cpplint returns non-zero
+ // for any warning
+ return 0;
+}
+
+static int HandleCppCheck(const std::string& runCmd,
+ const std::string& sourceFile,
+ const std::vector<std::string>& orig_cmd)
+{
+ // Construct the cpplint command line.
+ std::vector<std::string> cppcheck_cmd = cmExpandedList(runCmd, true);
+ // extract all the -D, -U, and -I options from the compile line
+ for (auto const& opt : orig_cmd) {
+ if (opt.size() > 2) {
+ if ((opt[0] == '-') &&
+ ((opt[1] == 'D') || (opt[1] == 'I') || (opt[1] == 'U'))) {
+ cppcheck_cmd.push_back(opt);
+// convert cl / options to - options if needed
+#if defined(_WIN32)
+ } else if ((opt[0] == '/') &&
+ ((opt[1] == 'D') || (opt[1] == 'I') || (opt[1] == 'U'))) {
+ std::string optcopy = opt;
+ optcopy[0] = '-';
+ cppcheck_cmd.push_back(optcopy);
+#endif
+ }
+ }
+ }
+ // add the source file
+ cppcheck_cmd.push_back(sourceFile);
+
+ // Run the cpplint command line. Capture its output.
+ std::string stdOut;
+ std::string stdErr;
+ int ret;
+ if (!cmSystemTools::RunSingleCommand(cppcheck_cmd, &stdOut, &stdErr, &ret,
+ nullptr, cmSystemTools::OUTPUT_NONE)) {
+ std::cerr << "Error running '" << cppcheck_cmd[0] << "': " << stdOut
+ << "\n";
+ return 1;
+ }
+ std::cerr << stdOut;
+ // Output the output from cpplint to stderr
+ if (stdErr.find("(error)") != std::string::npos ||
+ stdErr.find("(warning)") != std::string::npos ||
+ stdErr.find("(style)") != std::string::npos ||
+ stdErr.find("(performance)") != std::string::npos ||
+ stdErr.find("(portability)") != std::string::npos ||
+ stdErr.find("(information)") != std::string::npos) {
+ if (ret == 0) {
+ std::cerr << "Warning: cppcheck reported diagnostics:\n";
+ } else {
+ std::cerr << "Error: cppcheck reported failure:\n";
+ }
+ }
+ std::cerr << stdErr;
+
+ return ret;
+}
+
+using CoCompileHandler = int (*)(const std::string&, const std::string&,
+ const std::vector<std::string>&);
+
+struct CoCompiler
+{
+ const char* Option;
+ CoCompileHandler Handler;
+ bool NoOriginalCommand;
+};
+
+static const std::array<CoCompiler, 5> CoCompilers = {
+ { // Table of options and handlers.
+ { "--cppcheck=", HandleCppCheck, false },
+ { "--cpplint=", HandleCppLint, false },
+ { "--iwyu=", HandleIWYU, false },
+ { "--lwyu=", HandleLWYU, true },
+ { "--tidy=", HandleTidy, false } }
+};
+
+struct CoCompileJob
+{
+ std::string Command;
+ CoCompileHandler Handler;
+};
+
+// called when args[0] == "__run_co_compile"
+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=
+
+ // 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
+ // lwyu does that.
+ bool runOriginalCmd = true;
+
+ std::vector<std::string> orig_cmd;
+ bool doing_options = true;
+ for (std::string const& arg : cmMakeRange(args).advance(2)) {
+ // if the arg is -- then the rest of the args after
+ // go into orig_cmd
+ if (arg == "--") {
+ doing_options = false;
+ } else if (doing_options) {
+ bool optionFound = false;
+ for (CoCompiler const& cc : CoCompilers) {
+ size_t optionLen = strlen(cc.Option);
+ if (arg.compare(0, optionLen, cc.Option) == 0) {
+ optionFound = true;
+ CoCompileJob job;
+ job.Command = arg.substr(optionLen);
+ job.Handler = cc.Handler;
+ jobs.push_back(std::move(job));
+ if (cc.NoOriginalCommand) {
+ runOriginalCmd = false;
+ }
+ }
+ }
+ if (!optionFound) {
+ if (cmHasLiteralPrefix(arg, "--source=")) {
+ sourceFile = arg.substr(9);
+ } else if (cmHasLiteralPrefix(arg, "--launcher=")) {
+ cmExpandList(arg.substr(11), launchers, true);
+ } else {
+ // if it was not a co-compiler or --source/--launcher then error
+ std::cerr << "__run_co_compile given unknown argument: " << arg
+ << "\n";
+ return 1;
+ }
+ }
+ } else { // if not doing_options then push to orig_cmd
+ orig_cmd.push_back(arg);
+ }
+ }
+ if (jobs.empty()) {
+ std::cerr << "__run_co_compile missing command to run. "
+ "Looking for one or more of the following:\n";
+ for (CoCompiler const& cc : CoCompilers) {
+ std::cerr << cc.Option << "\n";
+ }
+ return 1;
+ }
+
+ if (runOriginalCmd && orig_cmd.empty()) {
+ std::cerr << "__run_co_compile missing compile command after --\n";
+ return 1;
+ }
+
+ for (CoCompileJob const& job : jobs) {
+ // call the command handler here
+ int ret = job.Handler(job.Command, sourceFile, orig_cmd);
+
+ // if the command returns non-zero then return and fail.
+ // for commands that do not want to break the build, they should return
+ // 0 no matter what.
+ if (ret != 0) {
+ return ret;
+ }
+ }
+
+ // if there is no original command to run return now
+ if (!runOriginalCmd) {
+ return 0;
+ }
+
+ // Prepend launcher argument(s), if any
+ if (!launchers.empty()) {
+ orig_cmd.insert(orig_cmd.begin(), launchers.begin(), launchers.end());
+ }
+
+ // Now run the real compiler command and return its result value
+ int ret;
+ if (!cmSystemTools::RunSingleCommand(orig_cmd, nullptr, nullptr, &ret,
+ nullptr,
+ cmSystemTools::OUTPUT_PASSTHROUGH)) {
+ std::cerr << "Error running '" << orig_cmd[0] << "'\n";
+ return 1;
+ }
+ // return the return value from the original compiler command
+ return ret;
+}
+
+int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
{
// IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx
if (args.size() > 1) {
@@ -163,18 +477,17 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// If multiple source files specified,
// then destination must be directory
if ((args.size() > 4) &&
- (!cmSystemTools::FileIsDirectory(args[args.size() - 1]))) {
- std::cerr << "Error: Target (for copy command) \""
- << args[args.size() - 1] << "\" is not a directory.\n";
+ (!cmSystemTools::FileIsDirectory(args.back()))) {
+ std::cerr << "Error: Target (for copy command) \"" << args.back()
+ << "\" is not a directory.\n";
return 1;
}
// If error occurs we want to continue copying next files.
bool return_value = false;
- for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
- if (!cmSystemTools::cmCopyFile(args[cc].c_str(),
- args[args.size() - 1].c_str())) {
- std::cerr << "Error copying file \"" << args[cc] << "\" to \""
- << args[args.size() - 1] << "\".\n";
+ for (auto const& arg : cmMakeRange(args).advance(2).retreat(1)) {
+ if (!cmsys::SystemTools::CopyFileAlways(arg, args.back())) {
+ std::cerr << "Error copying file \"" << arg << "\" to \""
+ << args.back() << "\".\n";
return_value = true;
}
}
@@ -186,18 +499,17 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// If multiple source files specified,
// then destination must be directory
if ((args.size() > 4) &&
- (!cmSystemTools::FileIsDirectory(args[args.size() - 1]))) {
+ (!cmSystemTools::FileIsDirectory(args.back()))) {
std::cerr << "Error: Target (for copy_if_different command) \""
- << args[args.size() - 1] << "\" is not a directory.\n";
+ << args.back() << "\" is not a directory.\n";
return 1;
}
// If error occurs we want to continue copying next files.
bool return_value = false;
- for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
- if (!cmSystemTools::CopyFileIfDifferent(
- args[cc].c_str(), args[args.size() - 1].c_str())) {
- std::cerr << "Error copying file (if different) from \"" << args[cc]
- << "\" to \"" << args[args.size() - 1] << "\".\n";
+ for (auto const& arg : cmMakeRange(args).advance(2).retreat(1)) {
+ if (!cmSystemTools::CopyFileIfDifferent(arg, args.back())) {
+ std::cerr << "Error copying file (if different) from \"" << arg
+ << "\" to \"" << args.back() << "\".\n";
return_value = true;
}
}
@@ -208,10 +520,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if (args[1] == "copy_directory" && args.size() > 3) {
// If error occurs we want to continue copying next files.
bool return_value = false;
- for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
- if (!cmSystemTools::CopyADirectory(args[cc], args[args.size() - 1])) {
- std::cerr << "Error copying directory from \"" << args[cc]
- << "\" to \"" << args[args.size() - 1] << "\".\n";
+ for (auto const& arg : cmMakeRange(args).advance(2).retreat(1)) {
+ if (!cmSystemTools::CopyADirectory(arg, args.back())) {
+ std::cerr << "Error copying directory from \"" << arg << "\" to \""
+ << args.back() << "\".\n";
return_value = true;
}
}
@@ -220,7 +532,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Rename a file or directory
if (args[1] == "rename" && args.size() == 4) {
- if (!cmSystemTools::RenameFile(args[2].c_str(), args[3].c_str())) {
+ if (!cmSystemTools::RenameFile(args[2], args[3])) {
std::string e = cmSystemTools::GetLastSystemError();
std::cerr << "Error renaming from \"" << args[2] << "\" to \""
<< args[3] << "\": " << e << "\n";
@@ -230,26 +542,30 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
}
// Compare files
- if (args[1] == "compare_files" && args.size() == 4) {
- if (cmSystemTools::FilesDiffer(args[2], args[3])) {
- std::cerr << "Files \"" << args[2] << "\" to \"" << args[3]
- << "\" are different.\n";
+ if (args[1] == "compare_files" && (args.size() == 4 || args.size() == 5)) {
+ bool filesDiffer;
+ if (args.size() == 4) {
+ filesDiffer = cmSystemTools::FilesDiffer(args[2], args[3]);
+ } else if (args[2] == "--ignore-eol") {
+ filesDiffer = cmsys::SystemTools::TextFilesDiffer(args[3], args[4]);
+ } else {
+ ::CMakeCommandUsage(args[0].c_str());
+ return 1;
+ }
+
+ if (filesDiffer) {
+ std::cerr << "Files \"" << args[args.size() - 2] << "\" to \""
+ << args[args.size() - 1] << "\" are different.\n";
return 1;
}
return 0;
}
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
else if (args[1] == "__create_def") {
if (args.size() < 4) {
- std::cerr
- << "__create_def Usage: -E __create_def outfile.def objlistfile\n";
- return 1;
- }
- FILE* fout = cmsys::SystemTools::Fopen(args[2].c_str(), "w+");
- if (!fout) {
- std::cerr << "could not open output .def file: " << args[2].c_str()
- << "\n";
+ std::cerr << "__create_def Usage: -E __create_def outfile.def "
+ "objlistfile [-nm=nm-path]\n";
return 1;
}
cmsys::ifstream fin(args[3].c_str(), std::ios::in | std::ios::binary);
@@ -258,9 +574,41 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
<< "\n";
return 1;
}
- std::string file;
+ std::vector<std::string> files;
+ {
+ std::string file;
+ cmFileTime outTime;
+ bool outValid = outTime.Load(args[2]);
+ while (cmSystemTools::GetLineFromStream(fin, file)) {
+ files.push_back(file);
+ if (outValid) {
+ cmFileTime inTime;
+ outValid = inTime.Load(file) && inTime.Older(outTime);
+ }
+ }
+ if (outValid) {
+ // The def file already exists and all input files are older than the
+ // existing def file.
+ return 0;
+ }
+ }
+ FILE* fout = cmsys::SystemTools::Fopen(args[2].c_str(), "w+");
+ if (!fout) {
+ std::cerr << "could not open output .def file: " << args[2].c_str()
+ << "\n";
+ return 1;
+ }
bindexplib deffile;
- while (cmSystemTools::GetLineFromStream(fin, file)) {
+ if (args.size() >= 5) {
+ auto a = args[4];
+ if (cmHasLiteralPrefix(a, "--nm=")) {
+ deffile.SetNmPath(a.substr(5));
+ std::cerr << a.substr(5) << "\n";
+ } else {
+ std::cerr << "unknown argument: " << a << "\n";
+ }
+ }
+ for (auto const& file : files) {
std::string const& ext = cmSystemTools::GetFilenameLastExtension(file);
if (cmSystemTools::LowerCase(ext) == ".def") {
if (!deffile.AddDefinitionFile(file.c_str())) {
@@ -277,181 +625,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return 0;
}
#endif
- // run include what you use command and then run the compile
- // command. This is an internal undocumented option and should
- // only be used by CMake itself when running iwyu.
- if (args[1] == "__run_iwyu") {
- if (args.size() < 3) {
- std::cerr << "__run_iwyu Usage: -E __run_iwyu [--iwyu=/path/iwyu]"
- " [--cpplint=/path/cpplint] [--tidy=/path/tidy]"
- " -- compile command\n";
- return 1;
- }
- bool doing_options = true;
- std::vector<std::string> orig_cmd;
- std::string iwyu;
- std::string tidy;
- std::string sourceFile;
- std::string lwyu;
- std::string cpplint;
- for (std::string::size_type cc = 2; cc < args.size(); cc++) {
- std::string const& arg = args[cc];
- if (arg == "--") {
- doing_options = false;
- } else if (doing_options && cmHasLiteralPrefix(arg, "--iwyu=")) {
- iwyu = arg.substr(7);
- } else if (doing_options && cmHasLiteralPrefix(arg, "--tidy=")) {
- tidy = arg.substr(7);
- } else if (doing_options && cmHasLiteralPrefix(arg, "--source=")) {
- sourceFile = arg.substr(9);
- } else if (doing_options && cmHasLiteralPrefix(arg, "--lwyu=")) {
- lwyu = arg.substr(7);
- } else if (doing_options && cmHasLiteralPrefix(arg, "--cpplint=")) {
- cpplint = arg.substr(10);
- } else if (doing_options) {
- std::cerr << "__run_iwyu given unknown argument: " << arg << "\n";
- return 1;
- } else {
- orig_cmd.push_back(arg);
- }
- }
- if (tidy.empty() && iwyu.empty() && lwyu.empty() && cpplint.empty()) {
- std::cerr << "__run_iwyu missing --cpplint=, --iwyu=, --lwyu=, and/or"
- " --tidy=\n";
- return 1;
- }
- if ((!cpplint.empty() || !tidy.empty()) && sourceFile.empty()) {
- std::cerr << "__run_iwyu --cpplint= and/or __run_iwyu --tidy="
- " require --source=\n";
- return 1;
- }
- if (orig_cmd.empty() && lwyu.empty()) {
- std::cerr << "__run_iwyu missing compile command after --\n";
- return 1;
- }
-
- int ret = 0;
-
- if (!iwyu.empty()) {
- // Construct the iwyu command line by taking what was given
- // and adding all the arguments we give to the compiler.
- std::vector<std::string> iwyu_cmd;
- cmSystemTools::ExpandListArgument(iwyu, iwyu_cmd, true);
- iwyu_cmd.insert(iwyu_cmd.end(), orig_cmd.begin() + 1, orig_cmd.end());
-
- // Run the iwyu command line. Capture its stderr and hide its stdout.
- // Ignore its return code because the tool always returns non-zero.
- std::string stdErr;
- if (!cmSystemTools::RunSingleCommand(iwyu_cmd, CM_NULLPTR, &stdErr,
- &ret, CM_NULLPTR,
- cmSystemTools::OUTPUT_NONE)) {
- std::cerr << "Error running '" << iwyu_cmd[0] << "': " << stdErr
- << "\n";
- return 1;
- }
-
- // Warn if iwyu reported anything.
- if (stdErr.find("should remove these lines:") != std::string::npos ||
- stdErr.find("should add these lines:") != std::string::npos) {
- std::cerr << "Warning: include-what-you-use reported diagnostics:\n"
- << stdErr << "\n";
- }
- }
-
- if (!tidy.empty()) {
- // Construct the clang-tidy command line by taking what was given
- // and adding our compiler command line. The clang-tidy tool will
- // automatically skip over the compiler itself and extract the
- // options.
- std::vector<std::string> tidy_cmd;
- cmSystemTools::ExpandListArgument(tidy, tidy_cmd, true);
- tidy_cmd.push_back(sourceFile);
- tidy_cmd.push_back("--");
- tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin(), orig_cmd.end());
-
- // Run the tidy command line. Capture its stdout and hide its stderr.
- std::string stdOut;
- std::string stdErr;
- if (!cmSystemTools::RunSingleCommand(tidy_cmd, &stdOut, &stdErr, &ret,
- CM_NULLPTR,
- cmSystemTools::OUTPUT_NONE)) {
- std::cerr << "Error running '" << tidy_cmd[0] << "': " << stdErr
- << "\n";
- return 1;
- }
- // Output the stdout from clang-tidy to stderr
- std::cerr << stdOut;
- // If clang-tidy exited with an error do the same.
- if (ret != 0) {
- std::cerr << stdErr;
- return ret;
- }
- }
- if (!lwyu.empty()) {
- // Construct the ldd -r -u (link what you use lwyu) command line
- // ldd -u -r lwuy target
- std::vector<std::string> lwyu_cmd;
- lwyu_cmd.push_back("ldd");
- lwyu_cmd.push_back("-u");
- lwyu_cmd.push_back("-r");
- lwyu_cmd.push_back(lwyu);
-
- // Run the ldd -u -r command line.
- // Capture its stdout and hide its stderr.
- // Ignore its return code because the tool always returns non-zero
- // if there are any warnings, but we just want to warn.
- std::string stdOut;
- std::string stdErr;
- if (!cmSystemTools::RunSingleCommand(lwyu_cmd, &stdOut, &stdErr, &ret,
- CM_NULLPTR,
- cmSystemTools::OUTPUT_NONE)) {
- std::cerr << "Error running '" << lwyu_cmd[0] << "': " << stdErr
- << "\n";
- return 1;
- }
-
- // Output the stdout from ldd -r -u to stderr
- // Warn if lwyu reported anything.
- if (stdOut.find("Unused direct dependencies:") != std::string::npos) {
- std::cerr << "Warning: " << stdOut;
- }
- }
-
- if (!cpplint.empty()) {
- // Construct the cpplint command line.
- std::vector<std::string> cpplint_cmd;
- cmSystemTools::ExpandListArgument(cpplint, cpplint_cmd, true);
- cpplint_cmd.push_back(sourceFile);
-
- // Run the cpplint command line. Capture its output.
- std::string stdOut;
- if (!cmSystemTools::RunSingleCommand(cpplint_cmd, &stdOut, &stdOut,
- &ret, CM_NULLPTR,
- cmSystemTools::OUTPUT_NONE)) {
- std::cerr << "Error running '" << cpplint_cmd[0] << "': " << stdOut
- << "\n";
- return 1;
- }
-
- // Output the output from cpplint to stderr
- std::cerr << stdOut;
-
- // If cpplint exited with an error do the same.
- if (ret != 0) {
- return ret;
- }
- }
-
- ret = 0;
- // Now run the real compiler command and return its result value.
- if (lwyu.empty() &&
- !cmSystemTools::RunSingleCommand(
- orig_cmd, CM_NULLPTR, CM_NULLPTR, &ret, CM_NULLPTR,
- cmSystemTools::OUTPUT_PASSTHROUGH)) {
- std::cerr << "Error running '" << orig_cmd[0] << "'\n";
- return 1;
- }
- return ret;
+ if (args[1] == "__run_co_compile") {
+ return cmcmd::HandleCoCompileCommands(args);
}
// Echo string
@@ -467,13 +642,13 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
}
if (args[1] == "env") {
- std::vector<std::string>::const_iterator ai = args.begin() + 2;
- std::vector<std::string>::const_iterator ae = args.end();
+ auto ai = args.cbegin() + 2;
+ auto ae = args.cend();
for (; ai != ae; ++ai) {
std::string const& a = *ai;
if (cmHasLiteralPrefix(a, "--unset=")) {
// Unset environment variable.
- cmSystemTools::UnPutEnv(a.c_str() + 8);
+ cmSystemTools::UnPutEnv(a.substr(8));
} else if (!a.empty() && a[0] == '-') {
// Environment variable and command names cannot start in '-',
// so this must be an unknown option.
@@ -497,57 +672,66 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Execute command from remaining arguments.
std::vector<std::string> cmd(ai, ae);
int retval;
- if (cmSystemTools::RunSingleCommand(cmd, CM_NULLPTR, CM_NULLPTR, &retval,
- CM_NULLPTR,
+ if (cmSystemTools::RunSingleCommand(cmd, nullptr, nullptr, &retval,
+ nullptr,
cmSystemTools::OUTPUT_PASSTHROUGH)) {
return retval;
}
return 1;
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
if (args[1] == "environment") {
- std::vector<std::string> env = cmSystemTools::GetEnvironmentVariables();
- std::vector<std::string>::iterator it;
- for (it = env.begin(); it != env.end(); ++it) {
- std::cout << *it << std::endl;
+ for (auto const& env : cmSystemTools::GetEnvironmentVariables()) {
+ std::cout << env << std::endl;
}
return 0;
}
#endif
if (args[1] == "make_directory" && args.size() > 2) {
- // If error occurs we want to continue copying next files.
+ // If an error occurs, we want to continue making directories.
bool return_value = false;
- for (std::string::size_type cc = 2; cc < args.size(); cc++) {
- if (!cmSystemTools::MakeDirectory(args[cc].c_str())) {
- std::cerr << "Error creating directory \"" << args[cc] << "\".\n";
+ for (auto const& arg : cmMakeRange(args).advance(2)) {
+ if (!cmSystemTools::MakeDirectory(arg)) {
+ std::cerr << "Error creating directory \"" << arg << "\".\n";
return_value = true;
}
}
return return_value;
}
- if (args[1] == "remove_directory" && args.size() == 3) {
- if (cmSystemTools::FileIsDirectory(args[2]) &&
- !cmSystemTools::RemoveADirectory(args[2])) {
- std::cerr << "Error removing directory \"" << args[2] << "\".\n";
- return 1;
+ if (args[1] == "remove_directory" && args.size() > 2) {
+ // If an error occurs, we want to continue removing directories.
+ bool return_value = false;
+ for (auto const& arg : cmMakeRange(args).advance(2)) {
+ if (cmSystemTools::FileIsDirectory(arg)) {
+ if (cmSystemTools::FileIsSymlink(arg)) {
+ if (!cmSystemTools::RemoveFile(arg)) {
+ std::cerr << "Error removing directory symlink \"" << arg
+ << "\".\n";
+ return_value = true;
+ }
+ } else if (!cmSystemTools::RemoveADirectory(arg)) {
+ std::cerr << "Error removing directory \"" << arg << "\".\n";
+ return_value = true;
+ }
+ }
}
- return 0;
+ return return_value;
}
// Remove file
if (args[1] == "remove" && args.size() > 2) {
bool force = false;
- for (std::string::size_type cc = 2; cc < args.size(); cc++) {
- if (args[cc] == "\\-f" || args[cc] == "-f") {
+ for (auto const& arg : cmMakeRange(args).advance(2)) {
+ if (arg == "\\-f" || arg == "-f") {
force = true;
} else {
// Complain if the file could not be removed, still exists,
// and the -f option was not given.
- if (!cmSystemTools::RemoveFile(args[cc]) && !force &&
- cmSystemTools::FileExists(args[cc].c_str())) {
+ if (!cmSystemTools::RemoveFile(arg) && !force &&
+ cmSystemTools::FileExists(arg)) {
return 1;
}
}
@@ -557,8 +741,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Touch file
if (args[1] == "touch" && args.size() > 2) {
- for (std::string::size_type cc = 2; cc < args.size(); cc++) {
- if (!cmSystemTools::Touch(args[cc], true)) {
+ for (auto const& arg : cmMakeRange(args).advance(2)) {
+ if (!cmSystemTools::Touch(arg, true)) {
+ std::cerr << "cmake -E touch: failed to update \"";
+ std::cerr << arg << "\".\n";
return 1;
}
}
@@ -567,10 +753,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Touch file
if (args[1] == "touch_nocreate" && args.size() > 2) {
- for (std::string::size_type cc = 2; cc < args.size(); cc++) {
- // Complain if the file could not be removed, still exists,
- // and the -f option was not given.
- if (!cmSystemTools::Touch(args[cc], false)) {
+ for (auto const& arg : cmMakeRange(args).advance(2)) {
+ if (!cmSystemTools::Touch(arg, false)) {
+ std::cerr << "cmake -E touch_nocreate: failed to update \"";
+ std::cerr << arg << "\".\n";
return 1;
}
}
@@ -583,27 +769,23 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
std::cerr << "-E capabilities accepts no additional arguments\n";
return 1;
}
- cmake cm(cmake::RoleInternal);
-#if defined(HAVE_SERVER_MODE) && HAVE_SERVER_MODE
- std::cout << cm.ReportCapabilities(true);
-#else
- std::cout << cm.ReportCapabilities(false);
-#endif
+ cmake cm(cmake::RoleInternal, cmState::Unknown);
+ std::cout << cm.ReportCapabilities();
return 0;
}
// Sleep command
if (args[1] == "sleep" && args.size() > 2) {
double total = 0;
- for (size_t i = 2; i < args.size(); ++i) {
+ for (auto const& arg : cmMakeRange(args).advance(2)) {
double num = 0.0;
char unit;
char extra;
- int n = sscanf(args[i].c_str(), "%lg%c%c", &num, &unit, &extra);
+ int n = sscanf(arg.c_str(), "%lg%c%c", &num, &unit, &extra);
if ((n == 1 || (n == 2 && unit == 's')) && num >= 0) {
total += num;
} else {
- std::cerr << "Unknown sleep time format \"" << args[i] << "\".\n";
+ std::cerr << "Unknown sleep time format \"" << arg << "\".\n";
return 1;
}
}
@@ -617,13 +799,15 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if (args[1] == "time" && args.size() > 2) {
std::vector<std::string> command(args.begin() + 2, args.end());
- clock_t clock_start, clock_finish;
- time_t time_start, time_finish;
+ clock_t clock_start;
+ clock_t clock_finish;
+ time_t time_start;
+ time_t time_finish;
time(&time_start);
clock_start = clock();
int ret = 0;
- cmSystemTools::RunSingleCommand(command, CM_NULLPTR, CM_NULLPTR, &ret);
+ cmSystemTools::RunSingleCommand(command, nullptr, nullptr, &ret);
clock_finish = clock();
time(&time_finish);
@@ -641,42 +825,45 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Command to calculate the md5sum of a file
if (args[1] == "md5sum" && args.size() >= 3) {
- char md5out[32];
- int retval = 0;
- for (std::string::size_type cc = 2; cc < args.size(); cc++) {
- const char* filename = args[cc].c_str();
- // Cannot compute md5sum of a directory
- if (cmSystemTools::FileIsDirectory(filename)) {
- std::cerr << "Error: " << filename << " is a directory" << std::endl;
- retval++;
- } else if (!cmSystemTools::ComputeFileMD5(filename, md5out)) {
- // To mimic md5sum behavior in a shell:
- std::cerr << filename << ": No such file or directory" << std::endl;
- retval++;
- } else {
- std::cout << std::string(md5out, 32) << " " << filename
- << std::endl;
- }
- }
- return retval;
+ return HashSumFile(args, cmCryptoHash::AlgoMD5);
+ }
+
+ // Command to calculate the sha1sum of a file
+ if (args[1] == "sha1sum" && args.size() >= 3) {
+ return HashSumFile(args, cmCryptoHash::AlgoSHA1);
+ }
+
+ if (args[1] == "sha224sum" && args.size() >= 3) {
+ return HashSumFile(args, cmCryptoHash::AlgoSHA224);
+ }
+
+ if (args[1] == "sha256sum" && args.size() >= 3) {
+ return HashSumFile(args, cmCryptoHash::AlgoSHA256);
+ }
+
+ if (args[1] == "sha384sum" && args.size() >= 3) {
+ return HashSumFile(args, cmCryptoHash::AlgoSHA384);
+ }
+
+ if (args[1] == "sha512sum" && args.size() >= 3) {
+ return HashSumFile(args, cmCryptoHash::AlgoSHA512);
}
// Command to change directory and run a program.
if (args[1] == "chdir" && args.size() >= 4) {
std::string const& directory = args[2];
- if (!cmSystemTools::FileExists(directory.c_str())) {
- cmSystemTools::Error("Directory does not exist for chdir command: ",
- args[2].c_str());
+ if (!cmSystemTools::FileExists(directory)) {
+ cmSystemTools::Error("Directory does not exist for chdir command: " +
+ args[2]);
return 1;
}
std::string command =
cmWrap('"', cmMakeRange(args).advance(3), '"', " ");
int retval = 0;
- int timeout = 0;
if (cmSystemTools::RunSingleCommand(
- command.c_str(), CM_NULLPTR, CM_NULLPTR, &retval,
- directory.c_str(), cmSystemTools::OUTPUT_PASSTHROUGH, timeout)) {
+ command, nullptr, nullptr, &retval, directory.c_str(),
+ cmSystemTools::OUTPUT_PASSTHROUGH, cmDuration::zero())) {
return retval;
}
@@ -686,8 +873,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Command to start progress for a build
if (args[1] == "cmake_progress_start" && args.size() == 4) {
// basically remove the directory
- std::string dirName = args[2];
- dirName += "/Progress";
+ std::string dirName = cmStrCat(args[2], "/Progress");
cmSystemTools::RemoveADirectory(dirName);
// is the last argument a filename that exists?
@@ -702,10 +888,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
count = atoi(args[3].c_str());
}
if (count) {
- cmSystemTools::MakeDirectory(dirName.c_str());
+ cmSystemTools::MakeDirectory(dirName);
// write the count into the directory
- std::string fName = dirName;
- fName += "/count.txt";
+ std::string fName = cmStrCat(dirName, "/count.txt");
FILE* progFile = cmsys::SystemTools::Fopen(fName, "w");
if (progFile) {
fprintf(progFile, "%i\n", count);
@@ -737,14 +922,21 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return 1;
}
if (!cmSystemTools::CreateSymlink(args[2], args[3])) {
- std::string emsg = cmSystemTools::GetLastSystemError();
- std::cerr << "failed to create symbolic link '" << destinationFileName
- << "': " << emsg << "\n";
return 1;
}
return 0;
}
+ // Command to do nothing with an exit code of 0.
+ if (args[1] == "true") {
+ return 0;
+ }
+
+ // Command to do nothing with an exit code of 1.
+ if (args[1] == "false") {
+ return 1;
+ }
+
// Internal CMake shared library support.
if (args[1] == "cmake_symlink_library" && args.size() == 5) {
return cmcmd::SymlinkLibrary(args);
@@ -760,7 +952,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
const bool verbose = isCMakeVerbose();
// Create a cmake object instance to process dependencies.
- cmake cm(cmake::RoleScript); // All we need is the `set` command.
+ // All we need is the `set` command.
+ cmake cm(cmake::RoleScript, cmState::Unknown);
std::string gen;
std::string homeDir;
std::string startDir;
@@ -786,8 +979,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if (args.size() >= 9 && args[8].length() >= 8 &&
args[8].substr(0, 8) == "--color=") {
// Enable or disable color based on the switch value.
- color = (args[8].size() == 8 ||
- cmSystemTools::IsOn(args[8].substr(8).c_str()));
+ color = (args[8].size() == 8 || cmIsOn(args[8].substr(8)));
}
} else {
// Support older signature for existing makefiles:
@@ -820,12 +1012,11 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
cmStateSnapshot snapshot = cm.GetCurrentSnapshot();
snapshot.GetDirectory().SetCurrentBinary(startOutDir);
snapshot.GetDirectory().SetCurrentSource(startDir);
- CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(ggd, snapshot));
- CM_AUTO_PTR<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(mf.get()));
+ cmMakefile mf(ggd, snapshot);
+ std::unique_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator(&mf));
// Actually scan dependencies.
- return lgd->UpdateDependencies(depInfo.c_str(), verbose, color) ? 0
- : 2;
+ return lgd->UpdateDependencies(depInfo, verbose, color) ? 0 : 2;
}
return 1;
}
@@ -835,7 +1026,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return cmcmd::ExecuteLinkScript(args);
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
+#ifndef CMAKE_BOOTSTRAP
// Internal CMake ninja dependency scanning support.
if (args[1] == "cmake_ninja_depends") {
return cmcmd_cmake_ninja_depends(args.begin() + 2, args.end());
@@ -870,12 +1061,17 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return cmcmd::ExecuteEchoColor(args);
}
-#ifdef CMAKE_BUILD_WITH_CMAKE
- if (args[1] == "cmake_autogen" && args.size() >= 4) {
- cmQtAutoGenerators autogen;
- std::string const& config = args[3];
- bool autogenSuccess = autogen.Run(args[2], config);
- return autogenSuccess ? 0 : 1;
+#ifndef CMAKE_BOOTSTRAP
+ if ((args[1] == "cmake_autogen") && (args.size() >= 4)) {
+ cm::string_view const infoFile = args[2];
+ cm::string_view const config = args[3];
+ return cmQtAutoMocUic(infoFile, config) ? 0 : 1;
+ }
+ if ((args[1] == "cmake_autorcc") && (args.size() >= 3)) {
+ cm::string_view const infoFile = args[2];
+ cm::string_view const config =
+ (args.size() > 3) ? cm::string_view(args[3]) : cm::string_view();
+ return cmQtAutoRcc(infoFile, config) ? 0 : 1;
}
#endif
@@ -888,12 +1084,17 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
std::vector<std::string> files;
std::string mtime;
std::string format;
+ cmSystemTools::cmTarCompression compress =
+ cmSystemTools::TarCompressNone;
+ int nCompress = 0;
bool doing_options = true;
- for (std::string::size_type cc = 4; cc < args.size(); cc++) {
- std::string const& arg = args[cc];
+ for (auto const& arg : cmMakeRange(args).advance(4)) {
if (doing_options && cmHasLiteralPrefix(arg, "--")) {
if (arg == "--") {
doing_options = false;
+ } else if (arg == "--zstd") {
+ compress = cmSystemTools::TarCompressZstd;
+ ++nCompress;
} else if (cmHasLiteralPrefix(arg, "--mtime=")) {
mtime = arg.substr(8);
} else if (cmHasLiteralPrefix(arg, "--files-from=")) {
@@ -903,42 +1104,61 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
}
} else if (cmHasLiteralPrefix(arg, "--format=")) {
format = arg.substr(9);
- bool isKnown =
- std::find(cmArrayBegin(knownFormats), cmArrayEnd(knownFormats),
- format) != cmArrayEnd(knownFormats);
-
- if (!isKnown) {
- cmSystemTools::Error("Unknown -E tar --format= argument: ",
- format.c_str());
+ if (!cmContains(knownFormats, format)) {
+ cmSystemTools::Error("Unknown -E tar --format= argument: " +
+ format);
return 1;
}
} else {
- cmSystemTools::Error("Unknown option to -E tar: ", arg.c_str());
+ cmSystemTools::Error("Unknown option to -E tar: " + arg);
return 1;
}
} else {
files.push_back(arg);
}
}
- cmSystemTools::cmTarCompression compress =
- cmSystemTools::TarCompressNone;
+ cmSystemTools::cmTarAction action = cmSystemTools::TarActionNone;
bool verbose = false;
- int nCompress = 0;
- if (flags.find_first_of('j') != std::string::npos) {
- compress = cmSystemTools::TarCompressBZip2;
- ++nCompress;
- }
- if (flags.find_first_of('J') != std::string::npos) {
- compress = cmSystemTools::TarCompressXZ;
- ++nCompress;
- }
- if (flags.find_first_of('z') != std::string::npos) {
- compress = cmSystemTools::TarCompressGZip;
- ++nCompress;
+
+ for (auto flag : flags) {
+ switch (flag) {
+ case '-':
+ case 'f': {
+ // Keep for backward compatibility. Ignored
+ } break;
+ case 'j': {
+ compress = cmSystemTools::TarCompressBZip2;
+ ++nCompress;
+ } break;
+ case 'J': {
+ compress = cmSystemTools::TarCompressXZ;
+ ++nCompress;
+ } break;
+ case 'z': {
+ compress = cmSystemTools::TarCompressGZip;
+ ++nCompress;
+ } break;
+ case 'v': {
+ verbose = true;
+ } break;
+ case 't': {
+ action = cmSystemTools::TarActionList;
+ } break;
+ case 'c': {
+ action = cmSystemTools::TarActionCreate;
+ } break;
+ case 'x': {
+ action = cmSystemTools::TarActionExtract;
+ } break;
+ default: {
+ cmSystemTools::Message(
+ std::string("tar: Unknown argument: ") + flag, "Warning");
+ }
+ }
}
if ((format == "7zip" || format == "zip") && nCompress > 0) {
- cmSystemTools::Error("Can not use compression flags with format: ",
- format.c_str());
+ cmSystemTools::Error("Can not use compression flags with format: " +
+ format);
return 1;
}
if (nCompress > 1) {
@@ -946,24 +1166,24 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
"at most one flag of z, j, or J may be used");
return 1;
}
- if (flags.find_first_of('v') != std::string::npos) {
- verbose = true;
- }
-
- if (flags.find_first_of('t') != std::string::npos) {
- if (!cmSystemTools::ListTar(outFile.c_str(), verbose)) {
- cmSystemTools::Error("Problem listing tar: ", outFile.c_str());
+ if (action == cmSystemTools::TarActionList) {
+ if (!cmSystemTools::ListTar(outFile, files, verbose)) {
+ cmSystemTools::Error("Problem listing tar: " + outFile);
return 1;
}
- } else if (flags.find_first_of('c') != std::string::npos) {
- if (!cmSystemTools::CreateTar(outFile.c_str(), files, compress,
- verbose, mtime, format)) {
- cmSystemTools::Error("Problem creating tar: ", outFile.c_str());
+ } else if (action == cmSystemTools::TarActionCreate) {
+ if (files.empty()) {
+ cmSystemTools::Message("tar: No files or directories specified",
+ "Warning");
+ }
+ if (!cmSystemTools::CreateTar(outFile, files, compress, verbose, mtime,
+ format)) {
+ cmSystemTools::Error("Problem creating tar: " + outFile);
return 1;
}
- } else if (flags.find_first_of('x') != std::string::npos) {
- if (!cmSystemTools::ExtractTar(outFile.c_str(), verbose)) {
- cmSystemTools::Error("Problem extracting tar: ", outFile.c_str());
+ } else if (action == cmSystemTools::TarActionExtract) {
+ if (!cmSystemTools::ExtractTar(outFile, files, verbose)) {
+ cmSystemTools::Error("Problem extracting tar: " + outFile);
return 1;
}
#ifdef WIN32
@@ -982,6 +1202,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
cmSystemTools::Delay(delay);
}
#endif
+ } else {
+ cmSystemTools::Error("tar: No action specified. Please choose: 't' "
+ "(list), 'c' (create) or 'x' (extract)");
+ return 1;
}
return 0;
}
@@ -992,17 +1216,15 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
bool isDebug = false;
std::string pipe;
- for (size_t i = 2; i < args.size(); ++i) {
- const std::string& a = args[i];
-
- if (a == "--experimental") {
+ for (auto const& arg : cmMakeRange(args).advance(2)) {
+ if (arg == "--experimental") {
supportExperimental = true;
- } else if (a == "--debug") {
+ } else if (arg == "--debug") {
pipe.clear();
isDebug = true;
- } else if (a.substr(0, pipePrefix.size()) == pipePrefix) {
+ } else if (arg.substr(0, pipePrefix.size()) == pipePrefix) {
isDebug = false;
- pipe = a.substr(pipePrefix.size());
+ pipe = arg.substr(pipePrefix.size());
if (pipe.empty()) {
cmSystemTools::Error("No pipe given after --pipe=");
return 2;
@@ -1012,8 +1234,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return 1;
}
}
-#if defined(HAVE_SERVER_MODE) && HAVE_SERVER_MODE
- cmServerConnection* conn;
+#if !defined(CMAKE_BOOTSTRAP)
+ cmConnection* conn;
if (isDebug) {
conn = new cmServerStdIoConnection;
} else {
@@ -1024,7 +1246,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if (server.Serve(&errorMessage)) {
return 0;
}
- cmSystemTools::Error(errorMessage.c_str());
+ cmSystemTools::Error(errorMessage);
#else
static_cast<void>(supportExperimental);
static_cast<void>(isDebug);
@@ -1033,7 +1255,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return 1;
}
-#if defined(CMAKE_BUILD_WITH_CMAKE)
+#if !defined(CMAKE_BOOTSTRAP)
// Internal CMake Fortran module support.
if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4) {
return cmDependsFortran::CopyModule(args) ? 0 : 1;
@@ -1074,12 +1296,42 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
return 1;
}
-int cmcmd::SymlinkLibrary(std::vector<std::string>& args)
+int cmcmd::HashSumFile(std::vector<std::string> const& args,
+ cmCryptoHash::Algo algo)
+{
+ if (args.size() < 3) {
+ return -1;
+ }
+ int retval = 0;
+
+ for (auto const& filename : cmMakeRange(args).advance(2)) {
+ // Cannot compute sum of a directory
+ if (cmSystemTools::FileIsDirectory(filename)) {
+ std::cerr << "Error: " << filename << " is a directory" << std::endl;
+ retval++;
+ } else {
+ std::string value = cmSystemTools::ComputeFileHash(filename, algo);
+ if (value.empty()) {
+ // To mimic "md5sum/shasum" behavior in a shell:
+ std::cerr << filename << ": No such file or directory" << std::endl;
+ retval++;
+ } else {
+ std::cout << value << " " << filename << std::endl;
+ }
+ }
+ }
+ return retval;
+}
+
+int cmcmd::SymlinkLibrary(std::vector<std::string> const& args)
{
int result = 0;
- std::string const& realName = args[2];
- std::string const& soName = args[3];
- std::string const& name = args[4];
+ std::string realName = args[2];
+ std::string soName = args[3];
+ std::string name = args[4];
+ cmSystemTools::ConvertToUnixSlashes(realName);
+ cmSystemTools::ConvertToUnixSlashes(soName);
+ cmSystemTools::ConvertToUnixSlashes(name);
if (soName != realName) {
if (!cmcmd::SymlinkInternal(realName, soName)) {
cmSystemTools::ReportLastSystemError("cmake_symlink_library");
@@ -1095,7 +1347,7 @@ int cmcmd::SymlinkLibrary(std::vector<std::string>& args)
return result;
}
-int cmcmd::SymlinkExecutable(std::vector<std::string>& args)
+int cmcmd::SymlinkExecutable(std::vector<std::string> const& args)
{
int result = 0;
std::string const& realName = args[2];
@@ -1111,12 +1363,11 @@ int cmcmd::SymlinkExecutable(std::vector<std::string>& args)
bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link)
{
- if (cmSystemTools::FileExists(link.c_str()) ||
- cmSystemTools::FileIsSymlink(link)) {
+ if (cmSystemTools::FileExists(link) || cmSystemTools::FileIsSymlink(link)) {
cmSystemTools::RemoveFile(link);
}
#if defined(_WIN32) && !defined(__CYGWIN__)
- return cmSystemTools::CopyFileAlways(file.c_str(), link.c_str());
+ return cmSystemTools::CopyFileAlways(file, link);
#else
std::string linktext = cmSystemTools::GetFilenameName(file);
return cmSystemTools::CreateSymlink(linktext, link);
@@ -1125,14 +1376,12 @@ bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link)
static void cmcmdProgressReport(std::string const& dir, std::string const& num)
{
- std::string dirName = dir;
- dirName += "/Progress";
+ std::string dirName = cmStrCat(dir, "/Progress");
std::string fName;
FILE* progFile;
// read the count
- fName = dirName;
- fName += "/count.txt";
+ fName = cmStrCat(dirName, "/count.txt");
progFile = cmsys::SystemTools::Fopen(fName, "r");
int count = 0;
if (!progFile) {
@@ -1147,8 +1396,7 @@ static void cmcmdProgressReport(std::string const& dir, std::string const& num)
for (const char* c = last;; ++c) {
if (*c == ',' || *c == '\0') {
if (c != last) {
- fName = dirName;
- fName += "/";
+ fName = cmStrCat(dirName, '/');
fName.append(last, c - last);
progFile = cmsys::SystemTools::Fopen(fName, "w");
if (progFile) {
@@ -1170,75 +1418,74 @@ static void cmcmdProgressReport(std::string const& dir, std::string const& num)
}
}
-int cmcmd::ExecuteEchoColor(std::vector<std::string>& args)
+int cmcmd::ExecuteEchoColor(std::vector<std::string> const& args)
{
// The arguments are
- // argv[0] == <cmake-executable>
- // argv[1] == cmake_echo_color
+ // args[0] == <cmake-executable>
+ // args[1] == cmake_echo_color
bool enabled = true;
int color = cmsysTerminal_Color_Normal;
bool newline = true;
std::string progressDir;
- for (unsigned int i = 2; i < args.size(); ++i) {
- if (args[i].find("--switch=") == 0) {
+ for (auto const& arg : cmMakeRange(args).advance(2)) {
+ if (arg.find("--switch=") == 0) {
// Enable or disable color based on the switch value.
- std::string value = args[i].substr(9);
+ std::string value = arg.substr(9);
if (!value.empty()) {
- enabled = cmSystemTools::IsOn(value.c_str());
+ enabled = cmIsOn(value);
}
- } else if (cmHasLiteralPrefix(args[i], "--progress-dir=")) {
- progressDir = args[i].substr(15);
- } else if (cmHasLiteralPrefix(args[i], "--progress-num=")) {
+ } else if (cmHasLiteralPrefix(arg, "--progress-dir=")) {
+ progressDir = arg.substr(15);
+ } else if (cmHasLiteralPrefix(arg, "--progress-num=")) {
if (!progressDir.empty()) {
- std::string const& progressNum = args[i].substr(15);
+ std::string const& progressNum = arg.substr(15);
cmcmdProgressReport(progressDir, progressNum);
}
- } else if (args[i] == "--normal") {
+ } else if (arg == "--normal") {
color = cmsysTerminal_Color_Normal;
- } else if (args[i] == "--black") {
+ } else if (arg == "--black") {
color = cmsysTerminal_Color_ForegroundBlack;
- } else if (args[i] == "--red") {
+ } else if (arg == "--red") {
color = cmsysTerminal_Color_ForegroundRed;
- } else if (args[i] == "--green") {
+ } else if (arg == "--green") {
color = cmsysTerminal_Color_ForegroundGreen;
- } else if (args[i] == "--yellow") {
+ } else if (arg == "--yellow") {
color = cmsysTerminal_Color_ForegroundYellow;
- } else if (args[i] == "--blue") {
+ } else if (arg == "--blue") {
color = cmsysTerminal_Color_ForegroundBlue;
- } else if (args[i] == "--magenta") {
+ } else if (arg == "--magenta") {
color = cmsysTerminal_Color_ForegroundMagenta;
- } else if (args[i] == "--cyan") {
+ } else if (arg == "--cyan") {
color = cmsysTerminal_Color_ForegroundCyan;
- } else if (args[i] == "--white") {
+ } else if (arg == "--white") {
color = cmsysTerminal_Color_ForegroundWhite;
- } else if (args[i] == "--bold") {
+ } else if (arg == "--bold") {
color |= cmsysTerminal_Color_ForegroundBold;
- } else if (args[i] == "--no-newline") {
+ } else if (arg == "--no-newline") {
newline = false;
- } else if (args[i] == "--newline") {
+ } else if (arg == "--newline") {
newline = true;
} else {
// Color is enabled. Print with the current color.
- cmSystemTools::MakefileColorEcho(color, args[i].c_str(), newline,
- enabled);
+ cmSystemTools::MakefileColorEcho(color, arg.c_str(), newline, enabled);
}
}
return 0;
}
-int cmcmd::ExecuteLinkScript(std::vector<std::string>& args)
+int cmcmd::ExecuteLinkScript(std::vector<std::string> const& args)
{
// The arguments are
- // argv[0] == <cmake-executable>
- // argv[1] == cmake_link_script
- // argv[2] == <link-script-name>
- // argv[3] == --verbose=?
+ // args[0] == <cmake-executable>
+ // args[1] == cmake_link_script
+ // args[2] == <link-script-name>
+ // args[3] == --verbose=?
bool verbose = false;
if (args.size() >= 4) {
if (args[3].find("--verbose=") == 0) {
- if (!cmSystemTools::IsOff(args[3].substr(10).c_str())) {
+ if (!cmIsOff(args[3].substr(10))) {
verbose = true;
}
}
@@ -1277,7 +1524,7 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string>& args)
}
// Setup this command line.
- const char* cmd[2] = { command.c_str(), CM_NULLPTR };
+ const char* cmd[2] = { command.c_str(), nullptr };
cmsysProcess_SetCommand(cp, cmd);
// Report the command if verbose output is enabled.
@@ -1287,7 +1534,7 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string>& args)
// Run the command and wait for it to exit.
cmsysProcess_Execute(cp);
- cmsysProcess_WaitForExit(cp, CM_NULLPTR);
+ cmsysProcess_WaitForExit(cp, nullptr);
// Report failure if any.
switch (cmsysProcess_GetState(cp)) {
@@ -1309,7 +1556,7 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string>& args)
break;
default:
break;
- };
+ }
}
// Free the process instance.
@@ -1321,7 +1568,7 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string>& args)
int cmcmd::WindowsCEEnvironment(const char* version, const std::string& name)
{
-#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32) && !defined(__CYGWIN__)
+#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32) && !defined(__CYGWIN__)
cmVisualStudioWCEPlatformParser parser(name.c_str());
parser.ParseVersion(version);
if (parser.Found()) {
@@ -1353,6 +1600,8 @@ class cmVSLink
std::string ManifestFileRC;
std::string ManifestFileRes;
std::string TargetFile;
+ std::string MtPath;
+ std::string RcPath;
public:
cmVSLink(int type, bool verbose)
@@ -1375,24 +1624,32 @@ private:
// For visual studio 2005 and newer manifest files need to be embedded into
// exe and dll's. This code does that in such a way that incremental linking
// still works.
-int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type)
+int cmcmd::VisualStudioLink(std::vector<std::string> const& args, int type)
{
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
+ // Replace streambuf so we output in the system codepage. CMake is set up
+ // to output in Unicode (see SetUTF8Pipes) but the Visual Studio linker
+ // outputs using the system codepage so we need to change behavior when
+ // we run the link command.
+ cmsys::ConsoleBuf::Manager consoleOut(std::cout);
+ cmsys::ConsoleBuf::Manager consoleErr(std::cerr, true);
+#endif
+
if (args.size() < 2) {
return -1;
}
const bool verbose = cmSystemTools::HasEnv("VERBOSE");
std::vector<std::string> expandedArgs;
- for (std::vector<std::string>::iterator i = args.begin(); i != args.end();
- ++i) {
+ for (std::string const& i : args) {
// check for nmake temporary files
- if ((*i)[0] == '@' && i->find("@CMakeFiles") != 0) {
- cmsys::ifstream fin(i->substr(1).c_str());
+ if (i[0] == '@' && i.find("@CMakeFiles") != 0) {
+ cmsys::ifstream fin(i.substr(1).c_str());
std::string line;
while (cmSystemTools::GetLineFromStream(fin, line)) {
cmSystemTools::ParseWindowsCommandLine(line.c_str(), expandedArgs);
}
} else {
- expandedArgs.push_back(*i);
+ expandedArgs.push_back(i);
}
}
@@ -1403,8 +1660,38 @@ int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type)
return vsLink.Link();
}
-static bool RunCommand(const char* comment, std::vector<std::string>& command,
- bool verbose, int* retCodeOut = CM_NULLPTR)
+enum NumberFormat
+{
+ FORMAT_DECIMAL,
+ FORMAT_HEX
+};
+struct NumberFormatter
+{
+ NumberFormat Format;
+ int Value;
+ NumberFormatter(NumberFormat format, int value)
+ : Format(format)
+ , Value(value)
+ {
+ }
+};
+std::ostream& operator<<(std::ostream& stream,
+ NumberFormatter const& formatter)
+{
+ auto const& flags = stream.flags();
+ if (formatter.Format == FORMAT_DECIMAL) {
+ stream << std::dec << formatter.Value;
+ } else {
+ stream << "0x" << std::hex << formatter.Value;
+ }
+ stream.flags(flags);
+ return stream;
+}
+
+static bool RunCommand(const char* comment,
+ std::vector<std::string> const& command, bool verbose,
+ NumberFormat exitFormat, int* retCodeOut = nullptr,
+ bool (*retCodeOkay)(int) = nullptr)
{
if (verbose) {
std::cout << comment << ":\n";
@@ -1412,32 +1699,32 @@ static bool RunCommand(const char* comment, std::vector<std::string>& command,
}
std::string output;
int retCode = 0;
- // use rc command to create .res file
- bool res =
- cmSystemTools::RunSingleCommand(command, &output, &output, &retCode,
- CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
- // always print the output of the command, unless
- // it is the dumb rc command banner, but if the command
- // returned an error code then print the output anyway as
- // the banner may be mixed with some other important information.
- if (output.find("Resource Compiler Version") == std::string::npos || !res ||
- retCode) {
- std::cout << output;
- }
- if (!res) {
- std::cout << comment << " failed to run." << std::endl;
- return false;
- }
- // if retCodeOut is requested then always return true
- // and set the retCodeOut to retCode
+ bool commandResult = cmSystemTools::RunSingleCommand(
+ command, &output, &output, &retCode, nullptr, cmSystemTools::OUTPUT_NONE);
+ bool const retCodeSuccess =
+ retCode == 0 || (retCodeOkay && retCodeOkay(retCode));
+ bool const success = commandResult && retCodeSuccess;
if (retCodeOut) {
- *retCodeOut = retCode;
- return true;
+ if (commandResult || !retCodeSuccess) {
+ *retCodeOut = retCode;
+ } else {
+ *retCodeOut = -1;
+ }
}
- if (retCode != 0) {
- std::cout << comment << " failed. with " << retCode << "\n";
+ if (!success) {
+ std::cout << comment << ": command \"" << cmJoin(command, " ")
+ << "\" failed (exit code "
+ << NumberFormatter(exitFormat, retCode)
+ << ") with the following output:\n"
+ << output;
+ } else {
+ // always print the output of the command, unless
+ // it is the dumb rc command banner
+ if (output.find("Resource Compiler Version") == std::string::npos) {
+ std::cout << output;
+ }
}
- return retCode == 0;
+ return success;
}
bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg,
@@ -1445,7 +1732,7 @@ bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg,
{
// Parse our own arguments.
std::string intDir;
- std::vector<std::string>::const_iterator arg = argBeg;
+ auto arg = argBeg;
while (arg != argEnd && cmHasLiteralPrefix(*arg, "-")) {
if (*arg == "--") {
++arg;
@@ -1458,6 +1745,12 @@ bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg,
} else if (cmHasLiteralPrefix(*arg, "--intdir=")) {
intDir = arg->substr(9);
++arg;
+ } else if (cmHasLiteralPrefix(*arg, "--rc=")) {
+ this->RcPath = arg->substr(5);
+ ++arg;
+ } else if (cmHasLiteralPrefix(*arg, "--mt=")) {
+ this->MtPath = arg->substr(5);
+ ++arg;
} else {
std::cerr << "unknown argument '" << *arg << "'\n";
return false;
@@ -1509,7 +1802,7 @@ bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg,
}
if (this->LinkGeneratesManifest) {
- this->LinkCommand.push_back("/MANIFEST");
+ this->LinkCommand.emplace_back("/MANIFEST");
this->LinkCommand.push_back("/MANIFESTFILE:" + this->LinkerManifestFile);
}
@@ -1535,6 +1828,13 @@ int cmVSLink::Link()
return LinkNonIncremental();
}
+static bool mtRetIsUpdate(int mtRet)
+{
+ // 'mt /notify_update' returns a special value (differing between
+ // Windows and POSIX hosts) when it updated the manifest file.
+ return mtRet == 0x41020001 || mtRet == 0xbb;
+}
+
int cmVSLink::LinkIncremental()
{
// This follows the steps listed here:
@@ -1571,8 +1871,11 @@ int cmVSLink::LinkIncremental()
if (!fout) {
return -1;
}
- fout << this->Type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ "
- "24 /* RT_MANIFEST */ \""
+ // Insert a pragma statement to specify utf-8 encoding.
+ fout << "#pragma code_page(65001)\n";
+ fout << this->Type
+ << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ "
+ "24 /* RT_MANIFEST */ \""
<< absManifestFile << "\"";
}
@@ -1587,10 +1890,11 @@ int cmVSLink::LinkIncremental()
// Compile the resource file.
std::vector<std::string> rcCommand;
- rcCommand.push_back(cmSystemTools::FindProgram("rc.exe"));
- rcCommand.push_back("/fo" + this->ManifestFileRes);
+ rcCommand.push_back(this->RcPath.empty() ? "rc" : this->RcPath);
+ rcCommand.emplace_back("/fo");
+ rcCommand.push_back(this->ManifestFileRes);
rcCommand.push_back(this->ManifestFileRC);
- if (!RunCommand("RC Pass 1", rcCommand, this->Verbose)) {
+ if (!RunCommand("RC Pass 1", rcCommand, this->Verbose, FORMAT_DECIMAL)) {
return -1;
}
@@ -1598,26 +1902,28 @@ int cmVSLink::LinkIncremental()
this->LinkCommand.push_back(this->ManifestFileRes);
// Run the link command (possibly generates intermediate manifest).
- if (!RunCommand("LINK Pass 1", this->LinkCommand, this->Verbose)) {
+ if (!RunCommand("LINK Pass 1", this->LinkCommand, this->Verbose,
+ FORMAT_DECIMAL)) {
return -1;
}
// Run the manifest tool to create the final manifest.
int mtRet = this->RunMT("/out:" + this->ManifestFile, true);
- // If mt returns 1090650113 (or 187 on a posix host) then it updated the
- // manifest file so we need to embed it again. Otherwise we are done.
- if (mtRet != 1090650113 && mtRet != 187) {
+ // If mt returns a special value then it updated the manifest file so
+ // we need to embed it again. Otherwise we are done.
+ if (!mtRetIsUpdate(mtRet)) {
return mtRet;
}
// Compile the resource file again.
- if (!RunCommand("RC Pass 2", rcCommand, this->Verbose)) {
+ if (!RunCommand("RC Pass 2", rcCommand, this->Verbose, FORMAT_DECIMAL)) {
return -1;
}
// Link incrementally again to use the updated resource.
- if (!RunCommand("FINAL LINK", this->LinkCommand, this->Verbose)) {
+ if (!RunCommand("FINAL LINK", this->LinkCommand, this->Verbose,
+ FORMAT_DECIMAL)) {
return -1;
}
return 0;
@@ -1626,7 +1932,7 @@ int cmVSLink::LinkIncremental()
int cmVSLink::LinkNonIncremental()
{
// Run the link command (possibly generates intermediate manifest).
- if (!RunCommand("LINK", this->LinkCommand, this->Verbose)) {
+ if (!RunCommand("LINK", this->LinkCommand, this->Verbose, FORMAT_DECIMAL)) {
return -1;
}
@@ -1644,22 +1950,22 @@ int cmVSLink::LinkNonIncremental()
int cmVSLink::RunMT(std::string const& out, bool notify)
{
std::vector<std::string> mtCommand;
- mtCommand.push_back(cmSystemTools::FindProgram("mt.exe"));
- mtCommand.push_back("/nologo");
- mtCommand.push_back("/manifest");
+ mtCommand.push_back(this->MtPath.empty() ? "mt" : this->MtPath);
+ mtCommand.emplace_back("/nologo");
+ mtCommand.emplace_back("/manifest");
if (this->LinkGeneratesManifest) {
mtCommand.push_back(this->LinkerManifestFile);
}
- mtCommand.insert(mtCommand.end(), this->UserManifests.begin(),
- this->UserManifests.end());
+ cmAppend(mtCommand, this->UserManifests);
mtCommand.push_back(out);
if (notify) {
// Add an undocumented option that enables a special return
// code to notify us when the manifest is modified.
- mtCommand.push_back("/notify_update");
+ mtCommand.emplace_back("/notify_update");
}
int mtRet = 0;
- if (!RunCommand("MT", mtCommand, this->Verbose, &mtRet)) {
+ if (!RunCommand("MT", mtCommand, this->Verbose, FORMAT_HEX, &mtRet,
+ mtRetIsUpdate)) {
return -1;
}
return mtRet;
diff --git a/Source/cmcmd.h b/Source/cmcmd.h
index 929f1ae47..17f2f9a52 100644
--- a/Source/cmcmd.h
+++ b/Source/cmcmd.h
@@ -8,6 +8,8 @@
#include <string>
#include <vector>
+#include "cmCryptoHash.h"
+
class cmcmd
{
public:
@@ -15,18 +17,21 @@ public:
* Execute commands during the build process. Supports options such
* as echo, remove file etc.
*/
- static int ExecuteCMakeCommand(std::vector<std::string>&);
+ static int ExecuteCMakeCommand(std::vector<std::string> const&);
protected:
- static int SymlinkLibrary(std::vector<std::string>& args);
- static int SymlinkExecutable(std::vector<std::string>& args);
+ static int HandleCoCompileCommands(std::vector<std::string> const& args);
+ static int HashSumFile(std::vector<std::string> const& args,
+ cmCryptoHash::Algo algo);
+ static int SymlinkLibrary(std::vector<std::string> const& args);
+ static int SymlinkExecutable(std::vector<std::string> const& args);
static bool SymlinkInternal(std::string const& file,
std::string const& link);
- static int ExecuteEchoColor(std::vector<std::string>& args);
- static int ExecuteLinkScript(std::vector<std::string>& args);
+ static int ExecuteEchoColor(std::vector<std::string> const& args);
+ static int ExecuteLinkScript(std::vector<std::string> const& args);
static int WindowsCEEnvironment(const char* version,
const std::string& name);
- static int VisualStudioLink(std::vector<std::string>& args, int type);
+ static int VisualStudioLink(std::vector<std::string> const& args, int type);
};
#endif
diff --git a/Source/cmparseMSBuildXML.py b/Source/cmparseMSBuildXML.py
deleted file mode 100755
index 1b38d1547..000000000
--- a/Source/cmparseMSBuildXML.py
+++ /dev/null
@@ -1,341 +0,0 @@
-# This python script parses the spec files from MSBuild to create
-# mappings from compiler options to IDE XML specifications. For
-# more information see here:
-
-# http://blogs.msdn.com/vcblog/archive/2008/12/16/msbuild-task.aspx
-# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/1033/cl.xml"
-# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/1033/lib.xml"
-# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/1033/link.xml"
-# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/V110/1033/cl.xml"
-# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/V110/1033/lib.xml"
-# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/V110/1033/link.xml"
-# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/v120/1033/cl.xml"
-# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/v120/1033/lib.xml"
-# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/v120/1033/link.xml"
-# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/V140/1033/cl.xml"
-# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/V140/1033/lib.xml"
-# "${PROGRAMFILES}/MSBuild/Microsoft.Cpp/v4.0/V140/1033/link.xml"
-# "${PROGRAMFILES}/Microsoft Visual Studio/VS15Preview/Common7/IDE/VC/VCTargets/1033/cl.xml"
-# "${PROGRAMFILES}/Microsoft Visual Studio/VS15Preview/Common7/IDE/VC/VCTargets/1033/lib.xml"
-# "${PROGRAMFILES}/Microsoft Visual Studio/VS15Preview/Common7/IDE/VC/VCTargets/1033/link.xml"
-#
-# BoolProperty <Name>true|false</Name>
-# simple example:
-# <BoolProperty ReverseSwitch="Oy-" Name="OmitFramePointers"
-# Category="Optimization" Switch="Oy">
-# <BoolProperty.DisplayName> <BoolProperty.Description>
-# <CLCompile>
-# <OmitFramePointers>true</OmitFramePointers>
-# </ClCompile>
-#
-# argument means it might be this: /MP3
-# example with argument:
-# <BoolProperty Name="MultiProcessorCompilation" Category="General" Switch="MP">
-# <BoolProperty.DisplayName>
-# <sys:String>Multi-processor Compilation</sys:String>
-# </BoolProperty.DisplayName>
-# <BoolProperty.Description>
-# <sys:String>Multi-processor Compilation</sys:String>
-# </BoolProperty.Description>
-# <Argument Property="ProcessorNumber" IsRequired="false" />
-# </BoolProperty>
-# <CLCompile>
-# <MultiProcessorCompilation>true</MultiProcessorCompilation>
-# <ProcessorNumber>4</ProcessorNumber>
-# </ClCompile>
-# IntProperty
-# not used AFIT
-# <IntProperty Name="ProcessorNumber" Category="General" Visible="false">
-
-
-# per config options example
-# <EnableFiberSafeOptimizations Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</EnableFiberSafeOptimizations>
-#
-# EnumProperty
-# <EnumProperty Name="Optimization" Category="Optimization">
-# <EnumProperty.DisplayName>
-# <sys:String>Optimization</sys:String>
-# </EnumProperty.DisplayName>
-# <EnumProperty.Description>
-# <sys:String>Select option for code optimization; choose Custom to use specific optimization options. (/Od, /O1, /O2, /Ox)</sys:String>
-# </EnumProperty.Description>
-# <EnumValue Name="MaxSpeed" Switch="O2">
-# <EnumValue.DisplayName>
-# <sys:String>Maximize Speed</sys:String>
-# </EnumValue.DisplayName>
-# <EnumValue.Description>
-# <sys:String>Equivalent to /Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy</sys:String>
-# </EnumValue.Description>
-# </EnumValue>
-# <EnumValue Name="MinSpace" Switch="O1">
-# <EnumValue.DisplayName>
-# <sys:String>Minimize Size</sys:String>
-# </EnumValue.DisplayName>
-# <EnumValue.Description>
-# <sys:String>Equivalent to /Og /Os /Oy /Ob2 /Gs /GF /Gy</sys:String>
-# </EnumValue.Description>
-# </EnumValue>
-# example for O2 would be this:
-# <Optimization>MaxSpeed</Optimization>
-# example for O1 would be this:
-# <Optimization>MinSpace</Optimization>
-#
-# StringListProperty
-# <StringListProperty Name="PreprocessorDefinitions" Category="Preprocessor" Switch="D ">
-# <StringListProperty.DisplayName>
-# <sys:String>Preprocessor Definitions</sys:String>
-# </StringListProperty.DisplayName>
-# <StringListProperty.Description>
-# <sys:String>Defines a preprocessing symbols for your source file.</sys:String>
-# </StringListProperty.Description>
-# </StringListProperty>
-
-# <StringListProperty Subtype="folder" Name="AdditionalIncludeDirectories" Category="General" Switch="I">
-# <StringListProperty.DisplayName>
-# <sys:String>Additional Include Directories</sys:String>
-# </StringListProperty.DisplayName>
-# <StringListProperty.Description>
-# <sys:String>Specifies one or more directories to add to the include path; separate with semi-colons if more than one. (/I[path])</sys:String>
-# </StringListProperty.Description>
-# </StringListProperty>
-# StringProperty
-
-# Example add bill include:
-
-# <AdditionalIncludeDirectories>..\..\..\..\..\..\bill;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-
-
-import sys
-from xml.dom.minidom import parse, parseString
-
-def getText(node):
- nodelist = node.childNodes
- rc = ""
- for child in nodelist:
- if child.nodeType == child.TEXT_NODE:
- rc = rc + child.data
- return rc
-
-def print_tree(document, spaces=""):
- for i in range(len(document.childNodes)):
- if document.childNodes[i].nodeType == document.childNodes[i].ELEMENT_NODE:
- print spaces+str(document.childNodes[i].nodeName )
- print_tree(document.childNodes[i],spaces+"----")
- pass
-
-###########################################################################################
-#Data structure that stores a property of MSBuild
-class Property:
- #type = type of MSBuild property (ex. if the property is EnumProperty type should be "Enum")
- #attributeNames = a list of any attributes that this property could have (ex. if this was a EnumProperty it should be ["Name","Category"])
- #document = the dom file that's root node is the Property node (ex. if you were parsing a BoolProperty the root node should be something like <BoolProperty Name="RegisterOutput" Category="General" IncludeInCommandLine="false">
- def __init__(self,type,attributeNames,document=None):
- self.suffix_type = "Property"
- self.prefix_type = type
- self.attributeNames = attributeNames
- self.attributes = {}
- self.DisplayName = ""
- self.Description = ""
- self.argumentProperty = ""
- self.argumentIsRequired = ""
- self.values = []
- if document is not None:
- self.populate(document)
- pass
-
- #document = the dom file that's root node is the Property node (ex. if you were parsing a BoolProperty the root node should be something like <BoolProperty Name="RegisterOutput" Category="General" IncludeInCommandLine="false">
- #spaces = do not use
- def populate(self,document, spaces = ""):
- if document.nodeName == self.prefix_type+self.suffix_type:
- for i in self.attributeNames:
- self.attributes[i] = document.getAttribute(i)
- for i in range(len(document.childNodes)):
- child = document.childNodes[i]
- if child.nodeType == child.ELEMENT_NODE:
- if child.nodeName == self.prefix_type+self.suffix_type+".DisplayName":
- self.DisplayName = getText(child.childNodes[1])
- if child.nodeName == self.prefix_type+self.suffix_type+".Description":
- self.Description = getText(child.childNodes[1])
- if child.nodeName == "Argument":
- self.argumentProperty = child.getAttribute("Property")
- self.argumentIsRequired = child.getAttribute("IsRequired")
- if child.nodeName == self.prefix_type+"Value":
- va = Property(self.prefix_type,["Name","DisplayName","Switch"])
- va.suffix_type = "Value"
- va.populate(child)
- self.values.append(va)
- self.populate(child,spaces+"----")
- pass
-
- #toString function
- def __str__(self):
- toReturn = self.prefix_type+self.suffix_type+":"
- for i in self.attributeNames:
- toReturn += "\n "+i+": "+self.attributes[i]
- if self.argumentProperty != "":
- toReturn += "\n Argument:\n Property: "+self.argumentProperty+"\n IsRequired: "+self.argumentIsRequired
- for i in self.values:
- toReturn+="\n "+str(i).replace("\n","\n ")
- return toReturn
-###########################################################################################
-
-###########################################################################################
-#Class that populates itself from an MSBuild file and outputs it in CMake
-#format
-
-class MSBuildToCMake:
- #document = the entire MSBuild xml file
- def __init__(self,document=None):
- self.enumProperties = []
- self.stringProperties = []
- self.stringListProperties = []
- self.boolProperties = []
- self.intProperties = []
- if document!=None :
- self.populate(document)
- pass
-
- #document = the entire MSBuild xml file
- #spaces = don't use
- #To add a new property (if they exist) copy and paste this code and fill in appropriate places
- #
- #if child.nodeName == "<Name>Property":
- # self.<Name>Properties.append(Property("<Name>",[<List of attributes>],child))
- #
- #Replace <Name> with the name of the new property (ex. if property is StringProperty replace <Name> with String)
- #Replace <List of attributes> with a list of attributes in your property's root node
- #in the __init__ function add the line self.<Name>Properties = []
- #
- #That is all that is required to add new properties
- #
- def populate(self,document, spaces=""):
- for i in range(len(document.childNodes)):
- child = document.childNodes[i]
- if child.nodeType == child.ELEMENT_NODE:
- if child.nodeName == "EnumProperty":
- self.enumProperties.append(Property("Enum",["Name","Category"],child))
- if child.nodeName == "StringProperty":
- self.stringProperties.append(Property("String",["Name","Subtype","Separator","Category","Visible","IncludeInCommandLine","Switch","DisplayName","ReadOnly"],child))
- if child.nodeName == "StringListProperty":
- self.stringListProperties.append(Property("StringList",["Name","Category","Switch","DisplayName","Subtype"],child))
- if child.nodeName == "BoolProperty":
- self.boolProperties.append(Property("Bool",["ReverseSwitch","Name","Category","Switch","DisplayName","SwitchPrefix","IncludeInCommandLine"],child))
- if child.nodeName == "IntProperty":
- self.intProperties.append(Property("Int",["Name","Category","Visible"],child))
- self.populate(child,spaces+"----")
- pass
-
- #outputs information that CMake needs to know about MSBuild xml files
- def toCMake(self):
- toReturn = "static cmVS7FlagTable cmVS10CxxTable[] =\n{\n"
- toReturn += "\n //Enum Properties\n"
- lastProp = {}
- for i in self.enumProperties:
- if i.attributes["Name"] == "CompileAsManaged":
- #write these out after the rest of the enumProperties
- lastProp = i
- continue
- for j in i.values:
- #hardcore Brad King's manual fixes for cmVS10CLFlagTable.h
- if i.attributes["Name"] == "PrecompiledHeader" and j.attributes["Switch"] != "":
- toReturn+=" {\""+i.attributes["Name"]+"\", \""+j.attributes["Switch"]+"\",\n \""+j.attributes["DisplayName"]+"\", \""+j.attributes["Name"]+"\",\n cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},\n"
- else:
- #default (normal, non-hardcoded) case
- toReturn+=" {\""+i.attributes["Name"]+"\", \""+j.attributes["Switch"]+"\",\n \""+j.attributes["DisplayName"]+"\", \""+j.attributes["Name"]+"\", 0},\n"
- toReturn += "\n"
-
- if lastProp != {}:
- for j in lastProp.values:
- toReturn+=" {\""+lastProp.attributes["Name"]+"\", \""+j.attributes["Switch"]+"\",\n \""+j.attributes["DisplayName"]+"\", \""+j.attributes["Name"]+"\", 0},\n"
- toReturn += "\n"
-
- toReturn += "\n //Bool Properties\n"
- for i in self.boolProperties:
- if i.argumentProperty == "":
- if i.attributes["ReverseSwitch"] != "":
- toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["ReverseSwitch"]+"\", \"\", \"false\", 0},\n"
- if i.attributes["Switch"] != "":
- toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+"\", \"\", \"true\", 0},\n"
-
- toReturn += "\n //Bool Properties With Argument\n"
- for i in self.boolProperties:
- if i.argumentProperty != "":
- if i.attributes["ReverseSwitch"] != "":
- toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["ReverseSwitch"]+"\", \"\", \"false\",\n cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},\n"
- toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["ReverseSwitch"]+"\", \""+i.attributes["DisplayName"]+"\", \"\",\n cmVS7FlagTable::UserValueRequired},\n"
- if i.attributes["Switch"] != "":
- toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+"\", \"\", \"true\",\n cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue},\n"
- toReturn += " {\""+i.argumentProperty+"\", \""+i.attributes["Switch"]+"\", \""+i.attributes["DisplayName"]+"\", \"\",\n cmVS7FlagTable::UserValueRequired},\n"
-
- toReturn += "\n //String List Properties\n"
- for i in self.stringListProperties:
- if i.attributes["Switch"] == "":
- toReturn += " // Skip [" + i.attributes["Name"] + "] - no command line Switch.\n";
- else:
- toReturn +=" {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+"\",\n \""+i.attributes["DisplayName"]+"\",\n \"\", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},\n"
-
- toReturn += "\n //String Properties\n"
- for i in self.stringProperties:
- if i.attributes["Switch"] == "":
- if i.attributes["Name"] == "PrecompiledHeaderFile":
- #more hardcoding
- toReturn += " {\"PrecompiledHeaderFile\", \"Yc\",\n"
- toReturn += " \"Precompiled Header Name\",\n"
- toReturn += " \"\", cmVS7FlagTable::UserValueRequired},\n"
- toReturn += " {\"PrecompiledHeaderFile\", \"Yu\",\n"
- toReturn += " \"Precompiled Header Name\",\n"
- toReturn += " \"\", cmVS7FlagTable::UserValueRequired},\n"
- else:
- toReturn += " // Skip [" + i.attributes["Name"] + "] - no command line Switch.\n";
- else:
- toReturn +=" {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+i.attributes["Separator"]+"\",\n \""+i.attributes["DisplayName"]+"\",\n \"\", cmVS7FlagTable::UserValue},\n"
-
- toReturn += " {0,0,0,0,0}\n};"
- return toReturn
- pass
-
- #toString function
- def __str__(self):
- toReturn = ""
- allList = [self.enumProperties,self.stringProperties,self.stringListProperties,self.boolProperties,self.intProperties]
- for p in allList:
- for i in p:
- toReturn += "==================================================\n"+str(i).replace("\n","\n ")+"\n==================================================\n"
-
- return toReturn
-###########################################################################################
-
-###########################################################################################
-# main function
-def main(argv):
- xml_file = None
- help = """
- Please specify an input xml file with -x
-
- Exiting...
- Have a nice day :)"""
- for i in range(0,len(argv)):
- if argv[i] == "-x":
- xml_file = argv[i+1]
- if argv[i] == "-h":
- print help
- sys.exit(0)
- pass
- if xml_file == None:
- print help
- sys.exit(1)
-
- f = open(xml_file,"r")
- xml_str = f.read()
- xml_dom = parseString(xml_str)
-
- convertor = MSBuildToCMake(xml_dom)
- print convertor.toCMake()
-
- xml_dom.unlink()
-###########################################################################################
-# main entry point
-if __name__ == "__main__":
- main(sys.argv)
-
-sys.exit(0)
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index 84e815d1d..0d65902ef 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -1,88 +1,113 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmConfigure.h"
-#include "CTest/cmCTestLaunch.h"
-#include "CTest/cmCTestScriptHandler.h"
+#include "cmsys/Encoding.hxx"
+
#include "cmCTest.h"
#include "cmDocumentation.h"
#include "cmSystemTools.h"
-#include "cmsys/Encoding.hxx"
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cmsys/ConsoleBuf.hxx"
+#include "CTest/cmCTestLaunch.h"
+#include "CTest/cmCTestScriptHandler.h"
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
+# include "cmsys/ConsoleBuf.hxx"
#endif
+#include <cstring>
#include <iostream>
-#include <string.h>
#include <string>
#include <vector>
static const char* cmDocumentationName[][2] = {
- { CM_NULLPTR, " ctest - Testing driver provided by CMake." },
- { CM_NULLPTR, CM_NULLPTR }
+ { nullptr, " ctest - Testing driver provided by CMake." },
+ { nullptr, nullptr }
};
-static const char* cmDocumentationUsage[][2] = { { CM_NULLPTR,
+static const char* cmDocumentationUsage[][2] = { { nullptr,
" ctest [options]" },
- { CM_NULLPTR, CM_NULLPTR } };
+ { nullptr, nullptr } };
static const char* cmDocumentationOptions[][2] = {
{ "-C <cfg>, --build-config <cfg>", "Choose configuration to test." },
+ { "--progress", "Enable short progress output from tests." },
{ "-V,--verbose", "Enable verbose output from tests." },
{ "-VV,--extra-verbose", "Enable more verbose output from tests." },
{ "--debug", "Displaying more verbose internals of CTest." },
- { "--output-on-failure", "Output anything outputted by the test program "
- "if the test should fail." },
- { "--test-output-size-passed <size>", "Limit the output for passed tests "
- "to <size> bytes" },
- { "--test-output-size-failed <size>", "Limit the output for failed tests "
- "to <size> bytes" },
+ { "--output-on-failure",
+ "Output anything outputted by the test program "
+ "if the test should fail." },
+ { "--test-output-size-passed <size>",
+ "Limit the output for passed tests "
+ "to <size> bytes" },
+ { "--test-output-size-failed <size>",
+ "Limit the output for failed tests "
+ "to <size> bytes" },
{ "-F", "Enable failover." },
- { "-j <jobs>, --parallel <jobs>", "Run the tests in parallel using the "
- "given number of jobs." },
+ { "-j <jobs>, --parallel <jobs>",
+ "Run the tests in parallel using the "
+ "given number of jobs." },
{ "-Q,--quiet", "Make ctest quiet." },
{ "-O <file>, --output-log <file>", "Output to log file" },
- { "-N,--show-only", "Disable actual execution of tests." },
- { "-L <regex>, --label-regex <regex>", "Run tests with labels matching "
- "regular expression." },
- { "-R <regex>, --tests-regex <regex>", "Run tests matching regular "
- "expression." },
- { "-E <regex>, --exclude-regex <regex>", "Exclude tests matching regular "
- "expression." },
- { "-LE <regex>, --label-exclude <regex>", "Exclude tests with labels "
- "matching regular expression." },
- { "-FA <regex>, --fixture-exclude-any <regex>", "Do not automatically "
- "add any tests for "
- "fixtures matching "
- "regular expression." },
- { "-FS <regex>, --fixture-exclude-setup <regex>", "Do not automatically "
- "add setup tests for "
- "fixtures matching "
- "regular expression." },
- { "-FC <regex>, --fixture-exclude-cleanup <regex>", "Do not automatically "
- "add cleanup tests for "
- "fixtures matching "
- "regular expression." },
+ { "-N,--show-only[=format]",
+ "Disable actual execution of tests. The optional 'format' defines the "
+ "format of the test information and can be 'human' for the current text "
+ "format or 'json-v1' for json format. Defaults to 'human'." },
+ { "-L <regex>, --label-regex <regex>",
+ "Run tests with labels matching "
+ "regular expression." },
+ { "-R <regex>, --tests-regex <regex>",
+ "Run tests matching regular "
+ "expression." },
+ { "-E <regex>, --exclude-regex <regex>",
+ "Exclude tests matching regular "
+ "expression." },
+ { "-LE <regex>, --label-exclude <regex>",
+ "Exclude tests with labels "
+ "matching regular expression." },
+ { "-FA <regex>, --fixture-exclude-any <regex>",
+ "Do not automatically "
+ "add any tests for "
+ "fixtures matching "
+ "regular expression." },
+ { "-FS <regex>, --fixture-exclude-setup <regex>",
+ "Do not automatically "
+ "add setup tests for "
+ "fixtures matching "
+ "regular expression." },
+ { "-FC <regex>, --fixture-exclude-cleanup <regex>",
+ "Do not automatically "
+ "add cleanup tests for "
+ "fixtures matching "
+ "regular expression." },
{ "-D <dashboard>, --dashboard <dashboard>", "Execute dashboard test" },
{ "-D <var>:<type>=<value>", "Define a variable for script mode" },
{ "-M <model>, --test-model <model>", "Sets the model for a dashboard" },
- { "-T <action>, --test-action <action>", "Sets the dashboard action to "
- "perform" },
- { "--track <track>", "Specify the track to submit dashboard to" },
- { "-S <script>, --script <script>", "Execute a dashboard for a "
- "configuration" },
- { "-SP <script>, --script-new-process <script>", "Execute a dashboard for a "
- "configuration" },
+ { "-T <action>, --test-action <action>",
+ "Sets the dashboard action to "
+ "perform" },
+ { "--group <group>",
+ "Specify what build group on the dashboard you'd like to "
+ "submit results to." },
+ { "-S <script>, --script <script>",
+ "Execute a dashboard for a "
+ "configuration" },
+ { "-SP <script>, --script-new-process <script>",
+ "Execute a dashboard for a "
+ "configuration" },
{ "-A <file>, --add-notes <file>", "Add a notes file with submission" },
{ "-I [Start,End,Stride,test#,test#|Test file], --tests-information",
"Run a specific number of tests by number." },
{ "-U, --union", "Take the Union of -I and -R" },
{ "--rerun-failed", "Run only the tests that failed previously" },
- { "--repeat-until-fail <n>", "Require each test to run <n> "
- "times without failing in order to pass" },
+ { "--repeat-until-fail <n>",
+ "Require each test to run <n> "
+ "times without failing in order to pass" },
{ "--max-width <width>", "Set the max width for a test name to output" },
{ "--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1." },
+ { "--resource-spec-file <file>", "Set the resource spec file to use." },
{ "--no-label-summary", "Disable timing summary information for labels." },
+ { "--no-subproject-summary",
+ "Disable timing summary information for "
+ "subprojects." },
{ "--build-and-test", "Configure, build and run a test." },
{ "--build-target", "Specify a specific target to build." },
{ "--build-nocmake", "Run the build without running cmake first." },
@@ -103,8 +128,6 @@ static const char* cmDocumentationOptions[][2] = {
{ "--test-timeout", "The time limit in seconds, internal use only." },
{ "--test-load", "CPU load threshold for starting new parallel tests." },
{ "--tomorrow-tag", "Nightly or experimental starts with next day tag." },
- { "--ctest-config", "The configuration file used to initialize CTest state "
- "when submitting dashboards." },
{ "--overwrite", "Overwrite CTest configuration option." },
{ "--extra-submit <file>[;<file>]", "Submit extra files to the dashboard." },
{ "--force-new-ctest-process",
@@ -112,19 +135,20 @@ static const char* cmDocumentationOptions[][2] = {
{ "--schedule-random", "Use a random order for scheduling tests" },
{ "--submit-index",
"Submit individual dashboard tests with specific index" },
- { "--timeout <seconds>", "Set a global timeout on all tests." },
+ { "--timeout <seconds>", "Set the default test timeout." },
{ "--stop-time <time>",
"Set a time at which all tests should stop running." },
{ "--http1.0", "Submit using HTTP 1.0." },
{ "--no-compress-output", "Do not compress test output when submitting." },
{ "--print-labels", "Print all available test labels." },
- { CM_NULLPTR, CM_NULLPTR }
+ { nullptr, nullptr }
};
// this is a test driver program for cmCTest.
int main(int argc, char const* const* argv)
{
-#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE)
+ cmSystemTools::EnsureStdPipes();
+#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
// Replace streambuf so we can output Unicode to console
cmsys::ConsoleBuf::Manager consoleOut(std::cout);
consoleOut.SetUTF8Pipes();
@@ -138,6 +162,7 @@ int main(int argc, char const* const* argv)
cmSystemTools::DoNotInheritStdPipes();
cmSystemTools::EnableMSVCDebugHook();
+ cmSystemTools::InitializeLibUV();
cmSystemTools::FindCMakeResources(argv[0]);
// Dispatch 'ctest --launch' mode directly.
@@ -161,7 +186,8 @@ int main(int argc, char const* const* argv)
!(cmSystemTools::FileExists("CTestTestfile.cmake") ||
cmSystemTools::FileExists("DartTestfile.txt"))) {
if (argc == 1) {
- cmCTestLog(&inst, ERROR_MESSAGE, "*********************************"
+ cmCTestLog(&inst, ERROR_MESSAGE,
+ "*********************************"
<< std::endl
<< "No test configuration file found!" << std::endl
<< "*********************************" << std::endl);
@@ -170,8 +196,7 @@ int main(int argc, char const* const* argv)
doc.addCTestStandardDocSections();
if (doc.CheckOptions(argc, argv)) {
// Construct and print requested documentation.
- cmCTestScriptHandler* ch =
- static_cast<cmCTestScriptHandler*>(inst.GetHandler("script"));
+ cmCTestScriptHandler* ch = inst.GetScriptHandler();
ch->CreateCMake();
doc.SetShowGenerators(false);
@@ -185,8 +210,9 @@ int main(int argc, char const* const* argv)
// copy the args to a vector
std::vector<std::string> args;
+ args.reserve(argc);
for (int i = 0; i < argc; ++i) {
- args.push_back(argv[i]);
+ args.emplace_back(argv[i]);
}
// run ctest
std::string output;
diff --git a/Source/kwsys/Base64.c b/Source/kwsys/Base64.c
index 99f008e59..bf876f2d5 100644
--- a/Source/kwsys/Base64.c
+++ b/Source/kwsys/Base64.c
@@ -6,7 +6,7 @@
/* Work-around CMake dependency scanning limitation. This must
duplicate the above list of headers. */
#if 0
-#include "Base64.h.in"
+# include "Base64.h.in"
#endif
static const unsigned char kwsysBase64EncodeTable[65] =
diff --git a/Source/kwsys/Base64.h.in b/Source/kwsys/Base64.h.in
index 35367574a..729f97297 100644
--- a/Source/kwsys/Base64.h.in
+++ b/Source/kwsys/Base64.h.in
@@ -12,17 +12,17 @@
not visible to user code. Use kwsysHeaderDump.pl to reproduce
these macros after making changes to the interface. */
#if !defined(KWSYS_NAMESPACE)
-#define kwsys_ns(x) @KWSYS_NAMESPACE@##x
-#define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
+# define kwsys_ns(x) @KWSYS_NAMESPACE@##x
+# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#define kwsysBase64 kwsys_ns(Base64)
-#define kwsysBase64_Decode kwsys_ns(Base64_Decode)
-#define kwsysBase64_Decode3 kwsys_ns(Base64_Decode3)
-#define kwsysBase64_Encode kwsys_ns(Base64_Encode)
-#define kwsysBase64_Encode1 kwsys_ns(Base64_Encode1)
-#define kwsysBase64_Encode2 kwsys_ns(Base64_Encode2)
-#define kwsysBase64_Encode3 kwsys_ns(Base64_Encode3)
+# define kwsysBase64 kwsys_ns(Base64)
+# define kwsysBase64_Decode kwsys_ns(Base64_Decode)
+# define kwsysBase64_Decode3 kwsys_ns(Base64_Decode3)
+# define kwsysBase64_Encode kwsys_ns(Base64_Encode)
+# define kwsysBase64_Encode1 kwsys_ns(Base64_Encode1)
+# define kwsysBase64_Encode2 kwsys_ns(Base64_Encode2)
+# define kwsysBase64_Encode3 kwsys_ns(Base64_Encode3)
#endif
#if defined(__cplusplus)
@@ -94,17 +94,17 @@ kwsysEXPORT size_t kwsysBase64_Decode(const unsigned char* input,
/* If we are building a kwsys .c or .cxx file, let it use these macros.
Otherwise, undefine them to keep the namespace clean. */
#if !defined(KWSYS_NAMESPACE)
-#undef kwsys_ns
-#undef kwsysEXPORT
-#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#undef kwsysBase64
-#undef kwsysBase64_Decode
-#undef kwsysBase64_Decode3
-#undef kwsysBase64_Encode
-#undef kwsysBase64_Encode1
-#undef kwsysBase64_Encode2
-#undef kwsysBase64_Encode3
-#endif
+# undef kwsys_ns
+# undef kwsysEXPORT
+# if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
+# undef kwsysBase64
+# undef kwsysBase64_Decode
+# undef kwsysBase64_Decode3
+# undef kwsysBase64_Encode
+# undef kwsysBase64_Encode1
+# undef kwsysBase64_Encode2
+# undef kwsysBase64_Encode3
+# endif
#endif
#endif
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index e915b1a80..09bcdb943 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -20,12 +20,32 @@
# KWSYS_HEADER_ROOT = The directory into which to generate the kwsys headers.
# A directory called "${KWSYS_NAMESPACE}" will be
# created under this root directory to hold the files.
+# KWSYS_SPLIT_OBJECTS_FROM_INTERFACE
+# = Instead of creating a single ${KWSYS_NAMESPACE} library
+# target, create three separate targets:
+# ${KWSYS_NAMESPACE}
+# - An INTERFACE library only containing usage
+# requirements.
+# ${KWSYS_NAMESPACE}_objects
+# - An OBJECT library for the built kwsys objects.
+# Note: This is omitted from the install rules
+# ${KWSYS_NAMESPACE}_private
+# - An INTERFACE library combining both that is
+# appropriate for use with PRIVATE linking in
+# target_link_libraries. Because of how interface
+# properties propagate, this target is not suitable
+# for use with PUBLIC or INTERFACE linking.
+# KWSYS_ALIAS_TARGET = The name of an alias target to create to the actual target.
#
# Example:
#
# SET(KWSYS_HEADER_ROOT ${PROJECT_BINARY_DIR})
# INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
#
+# KWSYS_CXX_STANDARD = A value for CMAKE_CXX_STANDARD within KWSys.
+# Set to empty string to use no default value.
+# KWSYS_CXX_COMPILE_FEATURES = target_compile_features arguments for KWSys.
+#
# Optional settings to setup install rules are as follows:
#
# KWSYS_INSTALL_BIN_DIR = The installation target directories into
@@ -66,18 +86,17 @@
# any outside mailing list and no documentation of the change will be
# written.
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR)
+CMAKE_MINIMUM_REQUIRED(VERSION 3.1 FATAL_ERROR)
FOREACH(p
- CMP0025 # CMake 3.0, Compiler id for Apple Clang is now AppleClang.
- CMP0048 # CMake 3.0, Let the project command manage version variables.
CMP0056 # CMake 3.2, Honor link flags in try_compile() source-file signature.
CMP0063 # CMake 3.3, Honor visibility properties for all target types.
+ CMP0067 # CMake 3.8, Honor language standard in try_compile source-file signature.
+ CMP0069 # CMake 3.9, INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.
)
IF(POLICY ${p})
CMAKE_POLICY(SET ${p} NEW)
ENDIF()
ENDFOREACH()
-SET(CMAKE_LEGACY_CYGWIN_WIN32 0)
#-----------------------------------------------------------------------------
# If a namespace is not specified, use "kwsys" and enable testing.
@@ -98,6 +117,19 @@ SET_PROPERTY(DIRECTORY
"KWSYS_HEADER(%)=<${KWSYS_NAMESPACE}/%>"
)
+if(KWSYS_CXX_STANDARD)
+ set(CMAKE_CXX_STANDARD "${KWSYS_CXX_STANDARD}")
+elseif(NOT DEFINED CMAKE_CXX_STANDARD AND NOT DEFINED KWSYS_CXX_STANDARD)
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
+ AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"
+ AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU"
+ )
+ set(CMAKE_CXX_STANDARD 14)
+ else()
+ set(CMAKE_CXX_STANDARD 11)
+ endif()
+endif()
+
# Select library components.
IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
SET(KWSYS_ENABLE_C 1)
@@ -147,6 +179,9 @@ ENDIF()
IF(KWSYS_USE_Directory)
SET(KWSYS_USE_Encoding 1)
ENDIF()
+IF(KWSYS_USE_DynamicLoader)
+ SET(KWSYS_USE_Encoding 1)
+ENDIF()
IF(KWSYS_USE_FStream)
SET(KWSYS_USE_Encoding 1)
ENDIF()
@@ -154,13 +189,6 @@ IF(KWSYS_USE_ConsoleBuf)
SET(KWSYS_USE_Encoding 1)
ENDIF()
-# Setup the large file support default.
-IF(KWSYS_LFS_DISABLE)
- SET(KWSYS_LFS_REQUESTED 0)
-ELSE()
- SET(KWSYS_LFS_REQUESTED 1)
-ENDIF()
-
# Specify default 8 bit encoding for Windows
IF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE)
SET(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_ACP)
@@ -175,6 +203,11 @@ IF(KWSYS_STANDALONE)
ENDIF()
ENDIF()
+# Choose default shared/static build if not specified.
+IF(NOT DEFINED KWSYS_BUILD_SHARED)
+ SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS})
+ENDIF()
+
# Include helper macros.
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformTests.cmake)
INCLUDE(CheckTypeSize)
@@ -209,13 +242,14 @@ ENDIF()
# Setup library install rules.
SET(KWSYS_INSTALL_LIBRARY_RULE)
+SET(KWSYS_INSTALL_NAMELINK_RULE)
IF(KWSYS_INSTALL_LIB_DIR)
IF(KWSYS_INSTALL_EXPORT_NAME)
LIST(APPEND KWSYS_INSTALL_LIBRARY_RULE EXPORT ${KWSYS_INSTALL_EXPORT_NAME})
ENDIF()
# Install the shared library to the lib directory.
SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
- LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR}
+ LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR} NAMELINK_SKIP
)
# Assign the shared library to the runtime component.
IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
@@ -223,6 +257,17 @@ IF(KWSYS_INSTALL_LIB_DIR)
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
)
ENDIF()
+ IF(KWSYS_BUILD_SHARED)
+ SET(KWSYS_INSTALL_NAMELINK_RULE ${KWSYS_INSTALL_NAMELINK_RULE}
+ LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR} NAMELINK_ONLY
+ )
+ # Assign the namelink to the development component.
+ IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
+ SET(KWSYS_INSTALL_NAMELINK_RULE ${KWSYS_INSTALL_NAMELINK_RULE}
+ COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
+ )
+ ENDIF()
+ ENDIF()
# Install the archive to the lib directory.
SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
@@ -311,30 +356,6 @@ IF(KWSYS_STANDALONE)
ENDIF()
#-----------------------------------------------------------------------------
-# Configure Large File Support.
-KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CSTDIO
- "Checking whether header cstdio is available" DIRECT)
-SET(KWSYS_LFS_AVAILABLE 0)
-IF(KWSYS_LFS_REQUESTED)
- # Large File Support is requested.
- SET(KWSYS_LFS_REQUESTED 1)
-
- # Check for large file support.
- SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
- -DKWSYS_CXX_HAS_CSTDIO=${KWSYS_CXX_HAS_CSTDIO})
- KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_LFS_WORKS
- "Checking for Large File Support" DIRECT)
- SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)
-
- IF(KWSYS_LFS_WORKS)
- SET(KWSYS_LFS_AVAILABLE 1)
- ENDIF()
-ELSE()
- # Large File Support is not requested.
- SET(KWSYS_LFS_REQUESTED 0)
-ENDIF()
-
-#-----------------------------------------------------------------------------
# Configure the standard library header wrappers based on compiler's
# capabilities and parent project's request. Enforce 0/1 as only
# possible values for configuration into Configure.hxx.
@@ -406,11 +427,6 @@ ELSE()
SET(KWSYS_NAME_IS_KWSYS 0)
ENDIF()
-# Choose default shared/static build if not specified.
-IF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$")
- SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS})
-ENDIF()
-
IF(KWSYS_BUILD_SHARED)
SET(KWSYS_BUILD_SHARED 1)
SET(KWSYS_LIBRARY_TYPE SHARED)
@@ -419,6 +435,10 @@ ELSE()
SET(KWSYS_LIBRARY_TYPE STATIC)
ENDIF()
+if(NOT DEFINED KWSYS_BUILD_PIC)
+ set(KWSYS_BUILD_PIC 0)
+endif()
+
#-----------------------------------------------------------------------------
# Configure some implementation details.
@@ -426,10 +446,20 @@ KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_PTRDIFF_T
"Checking whether C compiler has ptrdiff_t in stddef.h" DIRECT)
KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_SSIZE_T
"Checking whether C compiler has ssize_t in unistd.h" DIRECT)
+IF(KWSYS_USE_Process)
+ KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC
+ "Checking whether C compiler has clock_gettime" DIRECT)
+ENDIF()
+
SET_SOURCE_FILES_PROPERTIES(ProcessUNIX.c System.c PROPERTIES
- COMPILE_FLAGS "-DKWSYS_C_HAS_PTRDIFF_T=${KWSYS_C_HAS_PTRDIFF_T} -DKWSYS_C_HAS_SSIZE_T=${KWSYS_C_HAS_SSIZE_T}"
+ COMPILE_FLAGS "-DKWSYS_C_HAS_PTRDIFF_T=${KWSYS_C_HAS_PTRDIFF_T} -DKWSYS_C_HAS_SSIZE_T=${KWSYS_C_HAS_SSIZE_T} -DKWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC=${KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC}"
)
+IF(DEFINED KWSYS_PROCESS_USE_SELECT)
+ GET_PROPERTY(ProcessUNIX_FLAGS SOURCE ProcessUNIX.c PROPERTY COMPILE_FLAGS)
+ SET_PROPERTY(SOURCE ProcessUNIX.c PROPERTY COMPILE_FLAGS "${ProcessUNIX_FLAGS} -DKWSYSPE_USE_SELECT=${KWSYSPE_USE_SELECT}")
+ENDIF()
+
IF(KWSYS_USE_DynamicLoader)
GET_PROPERTY(KWSYS_SUPPORTS_SHARED_LIBS GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
IF(KWSYS_SUPPORTS_SHARED_LIBS)
@@ -442,6 +472,14 @@ IF(KWSYS_USE_DynamicLoader)
ENDIF()
IF(KWSYS_USE_SystemTools)
+ if (NOT DEFINED KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP)
+ set(KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP 1)
+ endif ()
+ if (KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP)
+ set(KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP 1)
+ else ()
+ set(KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP 0)
+ endif ()
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_SETENV
"Checking whether CXX compiler has setenv" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UNSETENV
@@ -465,6 +503,24 @@ IF(KWSYS_USE_SystemTools)
KWSYS_CXX_STAT_HAS_ST_MTIM=${KWSYS_CXX_STAT_HAS_ST_MTIM}
KWSYS_CXX_STAT_HAS_ST_MTIMESPEC=${KWSYS_CXX_STAT_HAS_ST_MTIMESPEC}
)
+ IF(NOT WIN32)
+ IF(KWSYS_STANDALONE)
+ OPTION(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES "If true, Windows paths will be supported on Unix as well" ON)
+ ENDIF()
+ IF(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES)
+ SET_PROPERTY(SOURCE SystemTools.cxx testSystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
+ KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES
+ )
+ ENDIF()
+ ENDIF()
+
+ # Disable getpwnam for static linux builds since it depends on shared glibc
+ GET_PROPERTY(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
+ IF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT SHARED_LIBS_SUPPORTED)
+ SET_PROPERTY(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
+ HAVE_GETPWNAM=0
+ )
+ ENDIF()
ENDIF()
IF(KWSYS_USE_SystemInformation)
@@ -506,9 +562,6 @@ IF(KWSYS_USE_SystemInformation)
COMPILE_DEFINITIONS KWSYS_SYS_HAS_MACHINE_CPU_H=1)
ENDIF()
ENDIF()
- IF(KWSYS_LFS_AVAILABLE AND NOT KWSYS_LFS_DISABLE)
- SET(KWSYS_PLATFORM_CXX_TEST_DEFINES -DKWSYS_HAS_LFS=1)
- ENDIF()
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_RLIMIT64
"Checking whether CXX compiler has rlimit64" DIRECT)
SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)
@@ -547,7 +600,7 @@ IF(KWSYS_USE_SystemInformation)
CHECK_INCLUDE_FILE_CXX("execinfo.h" KWSYS_CXX_HAS_EXECINFOH)
IF (KWSYS_CXX_HAS_EXECINFOH)
# we have the backtrace header check if it
- # can be used with this compiler
+ # can be used with this compiler
SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES ${EXECINFO_LIB})
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BACKTRACE
"Checking whether backtrace works with this C++ compiler" DIRECT)
@@ -676,9 +729,13 @@ ENDIF()
# selected components. Initialize with required components.
SET(KWSYS_CLASSES)
SET(KWSYS_H_FILES Configure SharedForward)
-SET(KWSYS_HXX_FILES Configure String
- hashtable hash_fun hash_map hash_set
- )
+SET(KWSYS_HXX_FILES Configure String)
+
+IF(NOT CMake_SOURCE_DIR)
+ SET(KWSYS_HXX_FILES ${KWSYS_HXX_FILES}
+ hashtable hash_fun hash_map hash_set
+ )
+ENDIF()
# Add selected C++ classes.
SET(cppclasses
@@ -795,68 +852,158 @@ ENDFOREACH()
#-----------------------------------------------------------------------------
# Add the library with the configured name and list of sources.
IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
- ADD_LIBRARY(${KWSYS_NAMESPACE} ${KWSYS_LIBRARY_TYPE}
- ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
- SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY C_CLANG_TIDY "")
- SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY CXX_CLANG_TIDY "")
- SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY C_INCLUDE_WHAT_YOU_USE "")
- SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY CXX_INCLUDE_WHAT_YOU_USE "")
- SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY LABELS ${KWSYS_LABELS_LIB})
+ IF(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE)
+ SET(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE})
+ SET(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE}_objects)
+ SET(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE}_private)
+ SET(KWSYS_TARGET_INSTALL ${KWSYS_TARGET_INTERFACE} ${KWSYS_TARGET_LINK})
+ SET(KWSYS_LINK_DEPENDENCY INTERFACE)
+ ADD_LIBRARY(${KWSYS_TARGET_OBJECT} OBJECT
+ ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
+ IF(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC)
+ SET_PROPERTY(TARGET ${KWSYS_TARGET_OBJECT} PROPERTY
+ POSITION_INDEPENDENT_CODE TRUE)
+ ENDIF()
+ ADD_LIBRARY(${KWSYS_TARGET_INTERFACE} INTERFACE)
+ ADD_LIBRARY(${KWSYS_TARGET_LINK} INTERFACE)
+ TARGET_LINK_LIBRARIES(${KWSYS_TARGET_LINK} INTERFACE
+ ${KWSYS_TARGET_INTERFACE})
+ TARGET_SOURCES(${KWSYS_TARGET_LINK} INTERFACE
+ $<TARGET_OBJECTS:${KWSYS_TARGET_OBJECT}>)
+ target_compile_features(${KWSYS_TARGET_OBJECT} PRIVATE ${KWSYS_CXX_COMPILE_FEATURES})
+ target_compile_features(${KWSYS_TARGET_INTERFACE} INTERFACE ${KWSYS_CXX_COMPILE_FEATURES})
+ ELSE()
+ SET(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE})
+ SET(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE})
+ SET(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE})
+ set(KWSYS_TARGET_INSTALL ${KWSYS_TARGET_LINK})
+ SET(KWSYS_LINK_DEPENDENCY PUBLIC)
+ ADD_LIBRARY(${KWSYS_TARGET_INTERFACE} ${KWSYS_LIBRARY_TYPE}
+ ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
+ target_compile_features(${KWSYS_TARGET_INTERFACE} PUBLIC ${KWSYS_CXX_COMPILE_FEATURES})
+ ENDIF()
+ if (KWSYS_ALIAS_TARGET)
+ add_library(${KWSYS_ALIAS_TARGET} ALIAS ${KWSYS_TARGET_INTERFACE})
+ endif ()
+ SET_TARGET_PROPERTIES(${KWSYS_TARGET_OBJECT} PROPERTIES
+ C_CLANG_TIDY ""
+ CXX_CLANG_TIDY ""
+ C_INCLUDE_WHAT_YOU_USE ""
+ CXX_INCLUDE_WHAT_YOU_USE ""
+ LABELS "${KWSYS_LABELS_LIB}")
IF(KWSYS_USE_DynamicLoader)
IF(UNIX)
- TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS})
+ TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
+ ${CMAKE_DL_LIBS})
ENDIF()
ENDIF()
IF(KWSYS_USE_SystemInformation)
IF(WIN32)
- TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ws2_32)
+ TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} ws2_32)
+ # link in dbghelp.dll for symbol lookup if MSVC 1800 or later
+ # Note that the dbghelp runtime is part of MS Windows OS
+ IF(MSVC_VERSION AND NOT MSVC_VERSION VERSION_LESS 1800)
+ TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} dbghelp)
+ ENDIF()
IF(KWSYS_SYS_HAS_PSAPI)
- TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} Psapi)
+ TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
+ Psapi)
ENDIF()
ELSEIF(UNIX)
IF (EXECINFO_LIB AND KWSYS_CXX_HAS_BACKTRACE)
# backtrace on FreeBSD is not in libc
- TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${EXECINFO_LIB})
+ TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
+ ${EXECINFO_LIB})
ENDIF()
IF (KWSYS_CXX_HAS_DLADDR)
# for symbol lookup using dladdr
- TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS})
+ TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
+ ${CMAKE_DL_LIBS})
ENDIF()
IF (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
- TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} socket)
+ TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
+ socket)
ENDIF()
ENDIF()
ENDIF()
# Apply user-defined target properties to the library.
IF(KWSYS_PROPERTIES_CXX)
- SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES
- ${KWSYS_PROPERTIES_CXX}
- )
+ SET_TARGET_PROPERTIES(${KWSYS_TARGET_INTERFACE} PROPERTIES
+ ${KWSYS_PROPERTIES_CXX})
+ ENDIF()
+
+ # Set up include usage requirement
+ IF(COMMAND TARGET_INCLUDE_DIRECTORIES)
+ TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_INTERFACE} INTERFACE
+ $<BUILD_INTERFACE:${KWSYS_HEADER_ROOT}>)
+ IF(KWSYS_INSTALL_INCLUDE_DIR)
+ TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_INTERFACE} INTERFACE
+ $<INSTALL_INTERFACE:${KWSYS_INSTALL_INCLUDE_DIR}>)
+ ENDIF()
ENDIF()
# Create an install target for the library.
IF(KWSYS_INSTALL_LIBRARY_RULE)
- INSTALL(TARGETS ${KWSYS_NAMESPACE} ${KWSYS_INSTALL_LIBRARY_RULE})
+ INSTALL(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_LIBRARY_RULE})
+ ENDIF()
+ IF(KWSYS_INSTALL_NAMELINK_RULE)
+ INSTALL(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_NAMELINK_RULE})
ENDIF()
ENDIF()
# Add a C-only library if requested.
IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
- ADD_LIBRARY(${KWSYS_NAMESPACE}_c ${KWSYS_LIBRARY_TYPE} ${KWSYS_C_SRCS})
- SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}_c PROPERTY LABELS ${KWSYS_LABELS_LIB})
+ IF(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE)
+ SET(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c)
+ SET(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c_objects)
+ SET(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c_private)
+ SET(KWSYS_TARGET_C_INSTALL
+ ${KWSYS_TARGET_C_INTERFACE} ${KWSYS_TARGET_C_LINK})
+ SET(KWSYS_LINK_DEPENDENCY INTERFACE)
+ ADD_LIBRARY(${KWSYS_TARGET_C_OBJECT} OBJECT ${KWSYS_C_SRCS})
+ IF(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC)
+ SET_PROPERTY(TARGET ${KWSYS_TARGET_C_OBJECT} PROPERTY
+ POSITION_INDEPENDENT_CODE TRUE)
+ ENDIF()
+ ADD_LIBRARY(${KWSYS_TARGET_C_INTERFACE} INTERFACE)
+ ADD_LIBRARY(${KWSYS_TARGET_C_LINK} INTERFACE)
+ TARGET_LINK_LIBRARIES(${KWSYS_TARGET_C_LINK} INTERFACE
+ ${KWSYS_TARGET_C_INTERFACE})
+ TARGET_SOURCES(${KWSYS_TARGET_C_LINK} INTERFACE
+ $<TARGET_OBJECTS:${KWSYS_TARGET_C_OBJECT}>)
+ ELSE()
+ SET(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c)
+ SET(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c)
+ SET(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c)
+ SET(KWSYS_TARGET_C_INSTALL ${KWSYS_TARGET_C_LINK})
+ SET(KWSYS_LINK_DEPENDENCY PUBLIC)
+ ADD_LIBRARY(${KWSYS_TARGET_C_INTERFACE} ${KWSYS_LIBRARY_TYPE}
+ ${KWSYS_C_SRCS})
+ ENDIF()
+ SET_TARGET_PROPERTIES(${KWSYS_TARGET_C_OBJECT} PROPERTIES
+ LABELS "${KWSYS_LABELS_LIB}")
# Apply user-defined target properties to the library.
IF(KWSYS_PROPERTIES_C)
- SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE}_c PROPERTIES
- ${KWSYS_PROPERTIES_C}
- )
+ SET_TARGET_PROPERTIES(${KWSYS_TARGET_C_INTERFACE} PROPERTIES
+ ${KWSYS_PROPERTIES_C})
+ ENDIF()
+
+ # Set up include usage requirement
+ IF(COMMAND TARGET_INCLUDE_DIRECTORIES)
+ TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_C_INTERFACE} INTERFACE
+ $<BUILD_INTERFACE:${KWSYS_HEADER_ROOT}>)
+ IF(KWSYS_INSTALL_INCLUDE_DIR)
+ TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_C_INTERFACE} INTERFACE
+ $<INSTALL_INTERFACE:${KWSYS_INSTALL_INCLUDE_DIR}>)
+ ENDIF()
ENDIF()
# Create an install target for the library.
IF(KWSYS_INSTALL_LIBRARY_RULE)
- INSTALL(TARGETS ${KWSYS_NAMESPACE}_c ${KWSYS_INSTALL_LIBRARY_RULE})
+ INSTALL(TARGETS ${KWSYS_TARGET_C_INSTALL})
ENDIF()
ENDIF()
@@ -865,7 +1012,8 @@ ENDIF()
ADD_DEFINITIONS("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}")
# Disable deprecation warnings for standard C functions.
-IF(MSVC OR (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel"))
+IF(MSVC OR (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "Intel" OR
+ (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))))
ADD_DEFINITIONS(
-D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE
@@ -903,11 +1051,11 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
# C tests
SET(KWSYS_C_TESTS
- testEncode
- testTerminal
+ testEncode.c
+ testTerminal.c
)
IF(KWSYS_STANDALONE)
- SET(KWSYS_C_TESTS ${KWSYS_C_TESTS} testFail)
+ SET(KWSYS_C_TESTS ${KWSYS_C_TESTS} testFail.c)
ENDIF()
CREATE_TEST_SOURCELIST(
KWSYS_C_TEST_SRCS ${KWSYS_NAMESPACE}TestsC.c
@@ -915,32 +1063,34 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
)
ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS})
SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsC PROPERTY LABELS ${KWSYS_LABELS_EXE})
- TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsC ${KWSYS_NAMESPACE}_c)
- FOREACH(test ${KWSYS_C_TESTS})
+ TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsC ${KWSYS_TARGET_C_LINK})
+ FOREACH(testfile ${KWSYS_C_TESTS})
+ get_filename_component(test "${testfile}" NAME_WE)
ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}})
SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
ENDFOREACH()
# C++ tests
- IF(NOT WATCOM)
+ IF(NOT WATCOM AND NOT CMake_SOURCE_DIR)
SET(KWSYS_CXX_TESTS
- testHashSTL
+ testHashSTL.cxx
)
ENDIF()
SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
- testIOS
- testSystemTools
- testCommandLineArguments
- testCommandLineArguments1
+ testConfigure.cxx
+ testSystemTools.cxx
+ testCommandLineArguments.cxx
+ testCommandLineArguments1.cxx
+ testDirectory.cxx
)
IF(KWSYS_STL_HAS_WSTRING)
SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
- testEncoding
+ testEncoding.cxx
)
ENDIF()
IF(KWSYS_USE_FStream)
SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
- testFStream
+ testFStream.cxx
)
ENDIF()
IF(KWSYS_USE_ConsoleBuf)
@@ -950,11 +1100,11 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
SET_PROPERTY(TARGET testConsoleBufChild PROPERTY C_INCLUDE_WHAT_YOU_USE "")
SET_PROPERTY(TARGET testConsoleBufChild PROPERTY CXX_INCLUDE_WHAT_YOU_USE "")
SET_PROPERTY(TARGET testConsoleBufChild PROPERTY LABELS ${KWSYS_LABELS_EXE})
- TARGET_LINK_LIBRARIES(testConsoleBufChild ${KWSYS_NAMESPACE})
+ TARGET_LINK_LIBRARIES(testConsoleBufChild ${KWSYS_TARGET_LINK})
SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
- testConsoleBuf
+ testConsoleBuf.cxx
)
- IF("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" AND
+ IF(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "19.0.23506")
set_property(SOURCE testConsoleBuf.cxx testConsoleBufChild.cxx PROPERTY COMPILE_FLAGS /utf-8)
ENDIF()
@@ -962,14 +1112,28 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE})
ENDIF()
IF(KWSYS_USE_SystemInformation)
- SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation)
+ SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation.cxx)
ENDIF()
IF(KWSYS_USE_DynamicLoader)
- SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader)
+ SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader.cxx)
# If kwsys contains the DynamicLoader, need extra library
ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c)
SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB})
- ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestDynload ${KWSYS_NAMESPACE})
+ ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestDynload ${KWSYS_TARGET_INTERFACE})
+
+ if (WIN32)
+ # Windows tests supported flags.
+ add_library(${KWSYS_NAMESPACE}TestDynloadImpl SHARED testDynloadImpl.c)
+ set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadImpl PROPERTY LABELS ${KWSYS_LABELS_LIB})
+ set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadImpl PROPERTY DEFINE_SYMBOL BUILDING_TestDynloadImpl)
+ set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadImpl PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dynloaddir")
+ add_dependencies(${KWSYS_NAMESPACE}TestDynloadImpl ${KWSYS_TARGET_INTERFACE})
+ add_library(${KWSYS_NAMESPACE}TestDynloadUse MODULE testDynloadUse.c)
+ set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadUse PROPERTY LABELS ${KWSYS_LABELS_LIB})
+ set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadUse PROPERTY LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dynloaddir")
+ add_dependencies(${KWSYS_NAMESPACE}TestDynloadUse ${KWSYS_TARGET_INTERFACE})
+ target_link_libraries(${KWSYS_NAMESPACE}TestDynloadUse PRIVATE ${KWSYS_NAMESPACE}TestDynloadImpl)
+ endif ()
ENDIF()
CREATE_TEST_SOURCELIST(
KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx
@@ -981,7 +1145,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY C_INCLUDE_WHAT_YOU_USE "")
SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY CXX_INCLUDE_WHAT_YOU_USE "")
SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY LABELS ${KWSYS_LABELS_EXE})
- TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_NAMESPACE})
+ TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_TARGET_LINK})
SET(TEST_SYSTEMTOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
SET(TEST_SYSTEMTOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
@@ -1024,7 +1188,8 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
-p
some junk at the end
)
- FOREACH(test ${KWSYS_CXX_TESTS})
+ FOREACH(testfile ${KWSYS_CXX_TESTS})
+ get_filename_component(test "${testfile}" NAME_WE)
ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}})
SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
ENDFOREACH()
@@ -1032,7 +1197,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
# Process tests.
ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestProcess testProcess.c)
SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestProcess PROPERTY LABELS ${KWSYS_LABELS_EXE})
- TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestProcess ${KWSYS_NAMESPACE}_c)
+ TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestProcess ${KWSYS_TARGET_C_LINK})
IF(NOT CYGWIN)
SET(KWSYS_TEST_PROCESS_7 7)
ENDIF()
@@ -1042,17 +1207,26 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
SET_TESTS_PROPERTIES(kwsys.testProcess-${n} PROPERTIES TIMEOUT 120)
ENDFOREACH()
+ SET(testProcess_COMPILE_FLAGS "")
# Some Apple compilers produce bad optimizations in this source.
IF(APPLE AND CMAKE_C_COMPILER_ID MATCHES "^(GNU|LLVM)$")
- SET_SOURCE_FILES_PROPERTIES(testProcess.c PROPERTIES COMPILE_FLAGS -O0)
- ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "XL" AND
- NOT (CMAKE_SYSTEM MATCHES "Linux.*ppc64le" AND
- NOT CMAKE_C_COMPILER_VERSION VERSION_LESS "13.1.1"))
+ SET(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -O0")
+ ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "XL")
# Tell IBM XL not to warn about our test infinite loop
- # v13.1.1 and newer on Linux ppc64le is clang based and does not accept
- # the -qsuppress option
- SET_PROPERTY(SOURCE testProcess.c PROPERTY COMPILE_FLAGS -qsuppress=1500-010)
+ IF(CMAKE_SYSTEM MATCHES "Linux.*ppc64le"
+ AND CMAKE_C_COMPILER_VERSION VERSION_LESS "16.1.0"
+ AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS "13.1.1")
+ # v13.1.[1-6] on Linux ppc64le is clang based and does not accept
+ # the -qsuppress option, so just suppress all warnings.
+ SET(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -w")
+ ELSE()
+ SET(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -qsuppress=1500-010")
+ ENDIF()
+ ENDIF()
+ IF(CMAKE_C_FLAGS MATCHES "-fsanitize=")
+ SET(testProcess_COMPILE_FLAGS "${testProcess_COMPILE_FLAGS} -DCRASH_USING_ABORT")
ENDIF()
+ SET_PROPERTY(SOURCE testProcess.c PROPERTY COMPILE_FLAGS "${testProcess_COMPILE_FLAGS}")
# Test SharedForward
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/testSharedForward.c.in
@@ -1060,7 +1234,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestSharedForward
${PROJECT_BINARY_DIR}/testSharedForward.c)
SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestSharedForward PROPERTY LABELS ${KWSYS_LABELS_EXE})
- ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestSharedForward ${KWSYS_NAMESPACE}_c)
+ ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestSharedForward ${KWSYS_TARGET_C_LINK})
ADD_TEST(kwsys.testSharedForward ${EXEC_DIR}/${KWSYS_NAMESPACE}TestSharedForward 1)
SET_PROPERTY(TEST kwsys.testSharedForward PROPERTY LABELS ${KWSYS_LABELS_TEST})
diff --git a/Source/kwsys/CONTRIBUTING.rst b/Source/kwsys/CONTRIBUTING.rst
index 70a313e05..32e7b83c5 100644
--- a/Source/kwsys/CONTRIBUTING.rst
+++ b/Source/kwsys/CONTRIBUTING.rst
@@ -27,7 +27,7 @@ copies of KWSys within dependent projects can be updated to get the changes.
Code Style
==========
-We use `clang-format`_ version **3.8** to define our style for C++ code in
+We use `clang-format`_ version **6.0** to define our style for C++ code in
the KWSys source tree. See the `.clang-format`_ configuration file for
our style settings. Use the `clang-format.bash`_ script to format source
code. It automatically runs ``clang-format`` on the set of source files
diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx
index 5613bd7ab..3fd195561 100644
--- a/Source/kwsys/CommandLineArguments.cxx
+++ b/Source/kwsys/CommandLineArguments.cxx
@@ -9,9 +9,9 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "CommandLineArguments.hxx.in"
-#include "Configure.hxx.in"
-#include "String.hxx.in"
+# include "CommandLineArguments.hxx.in"
+# include "Configure.hxx.in"
+# include "String.hxx.in"
#endif
#include <iostream>
@@ -25,18 +25,18 @@
#include <string.h>
#ifdef _MSC_VER
-#pragma warning(disable : 4786)
+# pragma warning(disable : 4786)
#endif
#if defined(__sgi) && !defined(__GNUC__)
-#pragma set woff 1375 /* base class destructor not virtual */
+# pragma set woff 1375 /* base class destructor not virtual */
#endif
#if 0
-#define CommandLineArguments_DEBUG(x) \
- std::cout << __LINE__ << " CLA: " << x << std::endl
+# define CommandLineArguments_DEBUG(x) \
+ std::cout << __LINE__ << " CLA: " << x << std::endl
#else
-#define CommandLineArguments_DEBUG(x)
+# define CommandLineArguments_DEBUG(x)
#endif
namespace KWSYS_NAMESPACE {
@@ -67,10 +67,10 @@ class CommandLineArgumentsInternal
{
public:
CommandLineArgumentsInternal()
+ : UnknownArgumentCallback{ nullptr }
+ , ClientData{ nullptr }
+ , LastArgument{ 0 }
{
- this->UnknownArgumentCallback = 0;
- this->ClientData = 0;
- this->LastArgument = 0;
}
typedef CommandLineArgumentsVectorOfStrings VectorOfStrings;
@@ -187,7 +187,7 @@ int CommandLineArguments::Parse()
switch (cs->ArgumentType) {
case NO_ARGUMENT:
// No value
- if (!this->PopulateVariable(cs, 0)) {
+ if (!this->PopulateVariable(cs, nullptr)) {
return 0;
}
break;
@@ -340,7 +340,7 @@ void CommandLineArguments::AddCallback(const char* argument,
s.Callback = callback;
s.CallData = call_data;
s.VariableType = CommandLineArguments::NO_VARIABLE_TYPE;
- s.Variable = 0;
+ s.Variable = nullptr;
s.Help = help;
this->Internals->Callbacks[argument] = s;
@@ -355,8 +355,8 @@ void CommandLineArguments::AddArgument(const char* argument,
CommandLineArgumentsCallbackStructure s;
s.Argument = argument;
s.ArgumentType = type;
- s.Callback = 0;
- s.CallData = 0;
+ s.Callback = nullptr;
+ s.CallData = nullptr;
s.VariableType = vtype;
s.Variable = variable;
s.Help = help;
@@ -427,7 +427,7 @@ const char* CommandLineArguments::GetHelp(const char* arg)
CommandLineArguments::Internal::CallbacksMap::iterator it =
this->Internals->Callbacks.find(arg);
if (it == this->Internals->Callbacks.end()) {
- return 0;
+ return nullptr;
}
// Since several arguments may point to the same argument, find the one this
@@ -529,10 +529,7 @@ void CommandLineArguments::GenerateHelp()
}
}
- // Create format for that string
- char format[80];
- sprintf(format, " %%-%us ", static_cast<unsigned int>(maxlen));
-
+ CommandLineArguments::Internal::String::size_type maxstrlen = maxlen;
maxlen += 4; // For the space before and after the option
// Print help for each option
@@ -540,27 +537,24 @@ void CommandLineArguments::GenerateHelp()
CommandLineArguments::Internal::SetOfStrings::iterator sit;
for (sit = mpit->second.begin(); sit != mpit->second.end(); sit++) {
str << std::endl;
- char argument[100];
- sprintf(argument, "%s", sit->c_str());
+ std::string argument = *sit;
switch (this->Internals->Callbacks[*sit].ArgumentType) {
case CommandLineArguments::NO_ARGUMENT:
break;
case CommandLineArguments::CONCAT_ARGUMENT:
- strcat(argument, "opt");
+ argument += "opt";
break;
case CommandLineArguments::SPACE_ARGUMENT:
- strcat(argument, " opt");
+ argument += " opt";
break;
case CommandLineArguments::EQUAL_ARGUMENT:
- strcat(argument, "=opt");
+ argument += "=opt";
break;
case CommandLineArguments::MULTI_ARGUMENT:
- strcat(argument, " opt opt ...");
+ argument += " opt opt ...";
break;
}
- char buffer[80];
- sprintf(buffer, format, argument);
- str << buffer;
+ str << " " << argument.substr(0, maxstrlen) << " ";
}
const char* ptr = this->Internals->Callbacks[mpit->first].Help;
size_t len = strlen(ptr);
@@ -627,7 +621,7 @@ void CommandLineArguments::PopulateVariable(bool* variable,
void CommandLineArguments::PopulateVariable(int* variable,
const std::string& value)
{
- char* res = 0;
+ char* res = nullptr;
*variable = static_cast<int>(strtol(value.c_str(), &res, 10));
// if ( res && *res )
// {
@@ -638,7 +632,7 @@ void CommandLineArguments::PopulateVariable(int* variable,
void CommandLineArguments::PopulateVariable(double* variable,
const std::string& value)
{
- char* res = 0;
+ char* res = nullptr;
*variable = strtod(value.c_str(), &res);
// if ( res && *res )
// {
@@ -649,10 +643,7 @@ void CommandLineArguments::PopulateVariable(double* variable,
void CommandLineArguments::PopulateVariable(char** variable,
const std::string& value)
{
- if (*variable) {
- delete[] * variable;
- *variable = 0;
- }
+ delete[] * variable;
*variable = new char[value.size() + 1];
strcpy(*variable, value.c_str());
}
@@ -678,7 +669,7 @@ void CommandLineArguments::PopulateVariable(std::vector<bool>* variable,
void CommandLineArguments::PopulateVariable(std::vector<int>* variable,
const std::string& value)
{
- char* res = 0;
+ char* res = nullptr;
variable->push_back(static_cast<int>(strtol(value.c_str(), &res, 10)));
// if ( res && *res )
// {
@@ -689,7 +680,7 @@ void CommandLineArguments::PopulateVariable(std::vector<int>* variable,
void CommandLineArguments::PopulateVariable(std::vector<double>* variable,
const std::string& value)
{
- char* res = 0;
+ char* res = nullptr;
variable->push_back(strtod(value.c_str(), &res));
// if ( res && *res )
// {
diff --git a/Source/kwsys/CommandLineArguments.hxx.in b/Source/kwsys/CommandLineArguments.hxx.in
index 31115e51f..7db901556 100644
--- a/Source/kwsys/CommandLineArguments.hxx.in
+++ b/Source/kwsys/CommandLineArguments.hxx.in
@@ -62,6 +62,9 @@ public:
CommandLineArguments();
~CommandLineArguments();
+ CommandLineArguments(const CommandLineArguments&) = delete;
+ CommandLineArguments& operator=(const CommandLineArguments&) = delete;
+
/**
* Various argument types.
*/
diff --git a/Source/kwsys/Configure.h.in b/Source/kwsys/Configure.h.in
index 0afcae781..5323c57be 100644
--- a/Source/kwsys/Configure.h.in
+++ b/Source/kwsys/Configure.h.in
@@ -7,110 +7,72 @@
namespace. When not building a kwsys source file these macros are
temporarily defined inside the headers that use them. */
#if defined(KWSYS_NAMESPACE)
-#define kwsys_ns(x) @KWSYS_NAMESPACE@##x
-#define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
+# define kwsys_ns(x) @KWSYS_NAMESPACE@##x
+# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
/* Disable some warnings inside kwsys source files. */
#if defined(KWSYS_NAMESPACE)
-#if defined(__BORLANDC__)
-#pragma warn - 8027 /* function not inlined. */
-#endif
-#if defined(__INTEL_COMPILER)
-#pragma warning(disable : 1572) /* floating-point equality test */
-#endif
-#if defined(__sgi) && !defined(__GNUC__)
-#pragma set woff 3970 /* pointer to int conversion */
-#pragma set woff 3968 /* 64 bit conversion */
-#endif
+# if defined(__BORLANDC__)
+# pragma warn - 8027 /* function not inlined. */
+# endif
+# if defined(__INTEL_COMPILER)
+# pragma warning(disable : 1572) /* floating-point equality test */
+# endif
+# if defined(__sgi) && !defined(__GNUC__)
+# pragma set woff 3970 /* pointer to int conversion */
+# pragma set woff 3968 /* 64 bit conversion */
+# endif
#endif
/* Whether kwsys namespace is "kwsys". */
#define @KWSYS_NAMESPACE@_NAME_IS_KWSYS @KWSYS_NAME_IS_KWSYS@
-/* Whether Large File Support is requested. */
-#define @KWSYS_NAMESPACE@_LFS_REQUESTED @KWSYS_LFS_REQUESTED@
-
-/* Whether Large File Support is available. */
-#if @KWSYS_NAMESPACE@_LFS_REQUESTED
-#define @KWSYS_NAMESPACE@_LFS_AVAILABLE @KWSYS_LFS_AVAILABLE@
-#endif
-
-/* Setup Large File Support if requested. */
-#if @KWSYS_NAMESPACE@_LFS_REQUESTED
-/* Since LFS is requested this header must be included before system
- headers whether or not LFS is available. */
-#if 0 && (defined(_SYS_TYPES_H) || defined(_SYS_TYPES_INCLUDED))
-#error "@KWSYS_NAMESPACE@/Configure.h must be included before sys/types.h"
-#endif
-/* Enable the large file API if it is available. */
-#if @KWSYS_NAMESPACE@_LFS_AVAILABLE && \
- !defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINES)
-#if !defined(_LARGEFILE_SOURCE) && \
- !defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGEFILE_SOURCE)
-#define _LARGEFILE_SOURCE
-#endif
-#if !defined(_LARGEFILE64_SOURCE) && \
- !defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGEFILE64_SOURCE)
-#define _LARGEFILE64_SOURCE
-#endif
-#if !defined(_LARGE_FILES) && \
- !defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_LARGE_FILES)
-#define _LARGE_FILES
-#endif
-#if !defined(_FILE_OFFSET_BITS) && \
- !defined(@KWSYS_NAMESPACE@_LFS_NO_DEFINE_FILE_OFFSET_BITS)
-#define _FILE_OFFSET_BITS 64
-#endif
-#if 0 && (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS < 64)
-#error "_FILE_OFFSET_BITS must be defined to at least 64"
-#endif
-#endif
-#endif
-
/* Setup the export macro. */
#if @KWSYS_BUILD_SHARED@
-#if defined(_WIN32) || defined(__CYGWIN__)
-#if defined(@KWSYS_NAMESPACE@_EXPORTS)
-#define @KWSYS_NAMESPACE@_EXPORT __declspec(dllexport)
+# if defined(_WIN32) || defined(__CYGWIN__)
+# if defined(@KWSYS_NAMESPACE@_EXPORTS)
+# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllexport)
+# else
+# define @KWSYS_NAMESPACE@_EXPORT __declspec(dllimport)
+# endif
+# elif __GNUC__ >= 4
+# define @KWSYS_NAMESPACE@_EXPORT __attribute__((visibility("default")))
+# else
+# define @KWSYS_NAMESPACE@_EXPORT
+# endif
#else
-#define @KWSYS_NAMESPACE@_EXPORT __declspec(dllimport)
-#endif
-#elif __GNUC__ >= 4
-#define @KWSYS_NAMESPACE@_EXPORT __attribute__((visibility("default")))
-#else
-#define @KWSYS_NAMESPACE@_EXPORT
-#endif
-#else
-#define @KWSYS_NAMESPACE@_EXPORT
+# define @KWSYS_NAMESPACE@_EXPORT
#endif
/* Enable warnings that are off by default but are useful. */
#if !defined(@KWSYS_NAMESPACE@_NO_WARNING_ENABLE)
-#if defined(_MSC_VER)
-#pragma warning(default : 4263) /* no override, call convention differs */
-#endif
+# if defined(_MSC_VER)
+# pragma warning(default : 4263) /* no override, call convention differs \
+ */
+# endif
#endif
/* Disable warnings that are on by default but occur in valid code. */
#if !defined(@KWSYS_NAMESPACE@_NO_WARNING_DISABLE)
-#if defined(_MSC_VER)
-#pragma warning(disable : 4097) /* typedef is synonym for class */
-#pragma warning(disable : 4127) /* conditional expression is constant */
-#pragma warning(disable : 4244) /* possible loss in conversion */
-#pragma warning(disable : 4251) /* missing DLL-interface */
-#pragma warning(disable : 4305) /* truncation from type1 to type2 */
-#pragma warning(disable : 4309) /* truncation of constant value */
-#pragma warning(disable : 4514) /* unreferenced inline function */
-#pragma warning(disable : 4706) /* assignment in conditional expression */
-#pragma warning(disable : 4710) /* function not inlined */
-#pragma warning(disable : 4786) /* identifier truncated in debug info */
-#endif
-#if defined(__BORLANDC__) && !defined(__cplusplus)
+# if defined(_MSC_VER)
+# pragma warning(disable : 4097) /* typedef is synonym for class */
+# pragma warning(disable : 4127) /* conditional expression is constant */
+# pragma warning(disable : 4244) /* possible loss in conversion */
+# pragma warning(disable : 4251) /* missing DLL-interface */
+# pragma warning(disable : 4305) /* truncation from type1 to type2 */
+# pragma warning(disable : 4309) /* truncation of constant value */
+# pragma warning(disable : 4514) /* unreferenced inline function */
+# pragma warning(disable : 4706) /* assignment in conditional expression \
+ */
+# pragma warning(disable : 4710) /* function not inlined */
+# pragma warning(disable : 4786) /* identifier truncated in debug info */
+# endif
+# if defined(__BORLANDC__) && !defined(__cplusplus)
/* Code has no effect; raised by winnt.h in C (not C++) when ignoring an
unused parameter using "(param)" syntax (i.e. no cast to void). */
-#pragma warn - 8019
-#endif
+# pragma warn - 8019
+# endif
#endif
/* MSVC 6.0 in release mode will warn about code it produces with its
@@ -118,10 +80,10 @@
configuration. Real warnings will be revealed by a debug build or
by other compilers. */
#if !defined(@KWSYS_NAMESPACE@_NO_WARNING_DISABLE_BOGUS)
-#if defined(_MSC_VER) && (_MSC_VER < 1300) && defined(NDEBUG)
-#pragma warning(disable : 4701) /* Variable may be used uninitialized. */
-#pragma warning(disable : 4702) /* Unreachable code. */
-#endif
+# if defined(_MSC_VER) && (_MSC_VER < 1300) && defined(NDEBUG)
+# pragma warning(disable : 4701) /* Variable may be used uninitialized. */
+# pragma warning(disable : 4702) /* Unreachable code. */
+# endif
#endif
#endif
diff --git a/Source/kwsys/Configure.hxx.in b/Source/kwsys/Configure.hxx.in
index 1c07a4ef7..29a2dd11e 100644
--- a/Source/kwsys/Configure.hxx.in
+++ b/Source/kwsys/Configure.hxx.in
@@ -11,17 +11,55 @@
/* Whether <ext/stdio_filebuf.h> is available. */
#define @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H \
@KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H@
+/* Whether the translation map is available or not. */
+#define @KWSYS_NAMESPACE@_SYSTEMTOOLS_USE_TRANSLATION_MAP \
+ @KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP@
+
+#if defined(__SUNPRO_CC) && __SUNPRO_CC > 0x5130 && defined(__has_attribute)
+# define @KWSYS_NAMESPACE@__has_cpp_attribute(x) __has_attribute(x)
+#elif defined(__has_cpp_attribute)
+# define @KWSYS_NAMESPACE@__has_cpp_attribute(x) __has_cpp_attribute(x)
+#else
+# define @KWSYS_NAMESPACE@__has_cpp_attribute(x) 0
+#endif
+
+#if __cplusplus >= 201103L
+# define @KWSYS_NAMESPACE@_NULLPTR nullptr
+#else
+# define @KWSYS_NAMESPACE@_NULLPTR 0
+#endif
+
+#ifndef @KWSYS_NAMESPACE@_FALLTHROUGH
+# if __cplusplus >= 201703L && \
+ @KWSYS_NAMESPACE@__has_cpp_attribute(fallthrough)
+# define @KWSYS_NAMESPACE@_FALLTHROUGH [[fallthrough]]
+# elif __cplusplus >= 201103L && \
+ @KWSYS_NAMESPACE@__has_cpp_attribute(gnu::fallthrough)
+# define @KWSYS_NAMESPACE@_FALLTHROUGH [[gnu::fallthrough]]
+# elif __cplusplus >= 201103L && \
+ @KWSYS_NAMESPACE@__has_cpp_attribute(clang::fallthrough)
+# define @KWSYS_NAMESPACE@_FALLTHROUGH [[clang::fallthrough]]
+# endif
+#endif
+#ifndef @KWSYS_NAMESPACE@_FALLTHROUGH
+# define @KWSYS_NAMESPACE@_FALLTHROUGH static_cast<void>(0)
+#endif
+
+#undef @KWSYS_NAMESPACE@__has_cpp_attribute
/* If building a C++ file in kwsys itself, give the source file
access to the macros without a configured namespace. */
#if defined(KWSYS_NAMESPACE)
-#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#define kwsys @KWSYS_NAMESPACE@
-#endif
-#define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING
-#define KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H \
- @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H
+# if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
+# define kwsys @KWSYS_NAMESPACE@
+# endif
+# define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS
+# define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING
+# define KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H \
+ @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H
+# define KWSYS_FALLTHROUGH @KWSYS_NAMESPACE@_FALLTHROUGH
+# define KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP \
+ @KWSYS_NAMESPACE@_SYSTEMTOOLS_USE_TRANSLATION_MAP
#endif
#endif
diff --git a/Source/kwsys/ConsoleBuf.hxx.in b/Source/kwsys/ConsoleBuf.hxx.in
index 46d65a865..49dbdf7ea 100644
--- a/Source/kwsys/ConsoleBuf.hxx.in
+++ b/Source/kwsys/ConsoleBuf.hxx.in
@@ -15,10 +15,10 @@
#include <string>
#if defined(_WIN32)
-#include <windows.h>
-#if __cplusplus >= 201103L
-#include <system_error>
-#endif
+# include <windows.h>
+# if __cplusplus >= 201103L
+# include <system_error>
+# endif
#endif
namespace @KWSYS_NAMESPACE@ {
@@ -116,7 +116,7 @@ protected:
DWORD charsWritten;
success =
::WriteConsoleW(m_hOutput, wbuffer.c_str(), (DWORD)wbuffer.size(),
- &charsWritten, NULL) == 0
+ &charsWritten, nullptr) == 0
? false
: true;
} else {
@@ -124,8 +124,9 @@ protected:
std::string buffer;
success = encodeOutputBuffer(wbuffer, buffer);
if (success) {
- success = ::WriteFile(m_hOutput, buffer.c_str(),
- (DWORD)buffer.size(), &bytesWritten, NULL) == 0
+ success =
+ ::WriteFile(m_hOutput, buffer.c_str(), (DWORD)buffer.size(),
+ &bytesWritten, nullptr) == 0
? false
: true;
}
@@ -152,7 +153,7 @@ protected:
DWORD charsRead;
if (ReadConsoleW(m_hInput, wbuffer,
(sizeof(wbuffer) / sizeof(wbuffer[0])), &charsRead,
- NULL) == 0 ||
+ nullptr) == 0 ||
charsRead == 0) {
_setg(true);
return Traits::eof();
@@ -168,7 +169,7 @@ protected:
return Traits::eof();
}
char* buffer = new char[size.LowPart];
- while (ReadFile(m_hInput, buffer, size.LowPart, &bytesRead, NULL) ==
+ while (ReadFile(m_hInput, buffer, size.LowPart, &bytesRead, nullptr) ==
0) {
if (GetLastError() == ERROR_MORE_DATA) {
strbuffer += std::string(buffer, bytesRead);
@@ -231,12 +232,12 @@ private:
(!input && m_hOutput == INVALID_HANDLE_VALUE)) {
std::string errmsg =
"GetStdHandle(" + handleName + ") returned INVALID_HANDLE_VALUE";
-#if __cplusplus >= 201103L
+# if __cplusplus >= 201103L
throw std::system_error(::GetLastError(), std::system_category(),
errmsg);
-#else
+# else
throw std::runtime_error(errmsg);
-#endif
+# endif
}
}
UINT getConsolesCodepage()
@@ -264,6 +265,7 @@ private:
if (m_isConsoleInput) {
break;
}
+ @KWSYS_NAMESPACE@_FALLTHROUGH;
case FILE_TYPE_PIPE:
m_activeInputCodepage = input_pipe_codepage;
break;
@@ -290,6 +292,7 @@ private:
if (m_isConsoleOutput) {
break;
}
+ @KWSYS_NAMESPACE@_FALLTHROUGH;
case FILE_TYPE_PIPE:
m_activeOutputCodepage = output_pipe_codepage;
break;
@@ -325,11 +328,12 @@ private:
}
const int length =
WideCharToMultiByte(m_activeOutputCodepage, 0, wbuffer.c_str(),
- (int)wbuffer.size(), NULL, 0, NULL, NULL);
+ (int)wbuffer.size(), nullptr, 0, nullptr, nullptr);
char* buf = new char[length];
const bool success =
WideCharToMultiByte(m_activeOutputCodepage, 0, wbuffer.c_str(),
- (int)wbuffer.size(), buf, length, NULL, NULL) > 0
+ (int)wbuffer.size(), buf, length, nullptr,
+ nullptr) > 0
? true
: false;
buffer = std::string(buf, length);
@@ -354,7 +358,7 @@ private:
length -= BOMsize;
}
const size_t wlength = static_cast<size_t>(MultiByteToWideChar(
- actualCodepage, 0, data, static_cast<int>(length), NULL, 0));
+ actualCodepage, 0, data, static_cast<int>(length), nullptr, 0));
wchar_t* wbuf = new wchar_t[wlength];
const bool success =
MultiByteToWideChar(actualCodepage, 0, data, static_cast<int>(length),
diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx
index 5141d4519..e3791826b 100644
--- a/Source/kwsys/Directory.cxx
+++ b/Source/kwsys/Directory.cxx
@@ -10,9 +10,9 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "Configure.hxx.in"
-#include "Directory.hxx.in"
-#include "Encoding.hxx.in"
+# include "Configure.hxx.in"
+# include "Directory.hxx.in"
+# include "Encoding.hxx.in"
#endif
#include <string>
@@ -48,7 +48,7 @@ unsigned long Directory::GetNumberOfFiles() const
const char* Directory::GetFile(unsigned long dindex) const
{
if (dindex >= this->Internal->Files.size()) {
- return 0;
+ return nullptr;
}
return this->Internal->Files[dindex].c_str();
}
@@ -69,40 +69,40 @@ void Directory::Clear()
// First Windows platforms
#if defined(_WIN32) && !defined(__CYGWIN__)
-#include <windows.h>
+# include <windows.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <io.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
+# include <ctype.h>
+# include <fcntl.h>
+# include <io.h>
+# include <stdio.h>
+# include <stdlib.h>
+# include <string.h>
+# include <sys/stat.h>
+# include <sys/types.h>
// Wide function names can vary depending on compiler:
-#ifdef __BORLANDC__
-#define _wfindfirst_func __wfindfirst
-#define _wfindnext_func __wfindnext
-#else
-#define _wfindfirst_func _wfindfirst
-#define _wfindnext_func _wfindnext
-#endif
+# ifdef __BORLANDC__
+# define _wfindfirst_func __wfindfirst
+# define _wfindnext_func __wfindnext
+# else
+# define _wfindfirst_func _wfindfirst
+# define _wfindnext_func _wfindnext
+# endif
namespace KWSYS_NAMESPACE {
bool Directory::Load(const std::string& name)
{
this->Clear();
-#if (defined(_MSC_VER) && _MSC_VER < 1300) || defined(__BORLANDC__)
+# if (defined(_MSC_VER) && _MSC_VER < 1300) || defined(__BORLANDC__)
// Older Visual C++ and Embarcadero compilers.
long srchHandle;
-#else // Newer Visual C++
+# else // Newer Visual C++
intptr_t srchHandle;
-#endif
+# endif
char* buf;
size_t n = name.size();
- if (*name.rbegin() == '/' || *name.rbegin() == '\\') {
+ if (name.back() == '/' || name.back() == '\\') {
buf = new char[n + 1 + 1];
sprintf(buf, "%s*", name.c_str());
} else {
@@ -118,8 +118,8 @@ bool Directory::Load(const std::string& name)
struct _wfinddata_t data; // data of current file
// Now put them into the file array
- srchHandle =
- _wfindfirst_func((wchar_t*)Encoding::ToWide(buf).c_str(), &data);
+ srchHandle = _wfindfirst_func(
+ (wchar_t*)Encoding::ToWindowsExtendedPath(buf).c_str(), &data);
delete[] buf;
if (srchHandle == -1) {
@@ -136,15 +136,15 @@ bool Directory::Load(const std::string& name)
unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
{
-#if (defined(_MSC_VER) && _MSC_VER < 1300) || defined(__BORLANDC__)
+# if (defined(_MSC_VER) && _MSC_VER < 1300) || defined(__BORLANDC__)
// Older Visual C++ and Embarcadero compilers.
long srchHandle;
-#else // Newer Visual C++
+# else // Newer Visual C++
intptr_t srchHandle;
-#endif
+# endif
char* buf;
size_t n = name.size();
- if (*name.rbegin() == '/') {
+ if (name.back() == '/') {
buf = new char[n + 1 + 1];
sprintf(buf, "%s*", name.c_str());
} else {
@@ -177,23 +177,23 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name)
// Now the POSIX style directory access
-#include <sys/types.h>
+# include <sys/types.h>
-#include <dirent.h>
+# include <dirent.h>
// PGI with glibc has trouble with dirent and large file support:
// http://www.pgroup.com/userforum/viewtopic.php?
// p=1992&sid=f16167f51964f1a68fe5041b8eb213b6
// Work around the problem by mapping dirent the same way as readdir.
-#if defined(__PGI) && defined(__GLIBC__)
-#define kwsys_dirent_readdir dirent
-#define kwsys_dirent_readdir64 dirent64
-#define kwsys_dirent kwsys_dirent_lookup(readdir)
-#define kwsys_dirent_lookup(x) kwsys_dirent_lookup_delay(x)
-#define kwsys_dirent_lookup_delay(x) kwsys_dirent_##x
-#else
-#define kwsys_dirent dirent
-#endif
+# if defined(__PGI) && defined(__GLIBC__)
+# define kwsys_dirent_readdir dirent
+# define kwsys_dirent_readdir64 dirent64
+# define kwsys_dirent kwsys_dirent_lookup(readdir)
+# define kwsys_dirent_lookup(x) kwsys_dirent_lookup_delay(x)
+# define kwsys_dirent_lookup_delay(x) kwsys_dirent_##x
+# else
+# define kwsys_dirent dirent
+# endif
namespace KWSYS_NAMESPACE {
diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx
index 1b4596a4e..a4b864118 100644
--- a/Source/kwsys/DynamicLoader.cxx
+++ b/Source/kwsys/DynamicLoader.cxx
@@ -1,15 +1,20 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
+#if defined(_WIN32)
+# define NOMINMAX // hide min,max to not conflict with <limits>
+#endif
+
#include "kwsysPrivate.h"
#include KWSYS_HEADER(DynamicLoader.hxx)
#include KWSYS_HEADER(Configure.hxx)
+#include KWSYS_HEADER(Encoding.hxx)
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "Configure.hxx.in"
-#include "DynamicLoader.hxx.in"
+# include "Configure.hxx.in"
+# include "DynamicLoader.hxx.in"
#endif
// This file actually contains several different implementations:
@@ -25,14 +30,36 @@
// Each part of the ifdef contains a complete implementation for
// the static methods of DynamicLoader.
+#define CHECK_OPEN_FLAGS(var, supported, ret) \
+ do { \
+ /* Check for unknown flags. */ \
+ if ((var & AllOpenFlags) != var) { \
+ return ret; \
+ } \
+ \
+ /* Check for unsupported flags. */ \
+ if ((var & (supported)) != var) { \
+ return ret; \
+ } \
+ } while (0)
+
+namespace KWSYS_NAMESPACE {
+
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
+ const std::string& libname)
+{
+ return DynamicLoader::OpenLibrary(libname, 0);
+}
+}
+
#if !KWSYS_SUPPORTS_SHARED_LIBS
// Implementation for environments without dynamic libs
-#include <string.h> // for strerror()
+# include <string.h> // for strerror()
namespace KWSYS_NAMESPACE {
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
- const std::string& libname)
+ const std::string& libname, int flags)
{
return 0;
}
@@ -60,15 +87,17 @@ const char* DynamicLoader::LastError()
} // namespace KWSYS_NAMESPACE
#elif defined(__hpux)
-// Implementation for HPUX machines
-#include <dl.h>
-#include <errno.h>
+// Implementation for HPUX machines
+# include <dl.h>
+# include <errno.h>
namespace KWSYS_NAMESPACE {
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
- const std::string& libname)
+ const std::string& libname, int flags)
{
+ CHECK_OPEN_FLAGS(flags, 0, 0);
+
return shl_load(libname.c_str(), BIND_DEFERRED | DYNAMIC_PATH, 0L);
}
@@ -124,14 +153,16 @@ const char* DynamicLoader::LastError()
#elif defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED < 1030)
// Implementation for Mac OS X 10.2.x and earlier
-#include <mach-o/dyld.h>
-#include <string.h> // for strlen
+# include <mach-o/dyld.h>
+# include <string.h> // for strlen
namespace KWSYS_NAMESPACE {
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
- const std::string& libname)
+ const std::string& libname, int flags)
{
+ CHECK_OPEN_FLAGS(flags, 0, 0);
+
NSObjectFileImageReturnCode rc;
NSObjectFileImage image = 0;
@@ -140,9 +171,9 @@ DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
if (rc != NSObjectFileImageSuccess) {
return 0;
}
- NSModule handle =
- NSLinkModule(image, libname.c_str(), NSLINKMODULE_OPTION_BINDNOW |
- NSLINKMODULE_OPTION_RETURN_ON_ERROR);
+ NSModule handle = NSLinkModule(image, libname.c_str(),
+ NSLINKMODULE_OPTION_BINDNOW |
+ NSLINKMODULE_OPTION_RETURN_ON_ERROR);
NSDestroyObjectFileImage(image);
return handle;
}
@@ -163,17 +194,13 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
{
void* result = 0;
// Need to prepend symbols with '_' on Apple-gcc compilers
- size_t len = sym.size();
- char* rsym = new char[len + 1 + 1];
- strcpy(rsym, "_");
- strcat(rsym + 1, sym.c_str());
+ std::string rsym = '_' + sym;
- NSSymbol symbol = NSLookupSymbolInModule(lib, rsym);
+ NSSymbol symbol = NSLookupSymbolInModule(lib, rsym.c_str());
if (symbol) {
result = NSAddressOfSymbol(symbol);
}
- delete[] rsym;
// Hack to cast pointer-to-data to pointer-to-function.
return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
}
@@ -187,21 +214,24 @@ const char* DynamicLoader::LastError()
#elif defined(_WIN32) && !defined(__CYGWIN__)
// Implementation for Windows win32 code but not cygwin
-#include <windows.h>
+# include <windows.h>
+
+# include <stdio.h>
namespace KWSYS_NAMESPACE {
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
- const std::string& libname)
+ const std::string& libname, int flags)
{
- DynamicLoader::LibraryHandle lh;
- int length = MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, NULL, 0);
- wchar_t* wchars = new wchar_t[length + 1];
- wchars[0] = '\0';
- MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, wchars, length);
- lh = LoadLibraryW(wchars);
- delete[] wchars;
- return lh;
+ CHECK_OPEN_FLAGS(flags, SearchBesideLibrary, nullptr);
+
+ DWORD llFlags = 0;
+ if (flags & SearchBesideLibrary) {
+ llFlags |= LOAD_WITH_ALTERED_SEARCH_PATH;
+ }
+
+ return LoadLibraryExW(Encoding::ToWindowsExtendedPath(libname).c_str(),
+ nullptr, llFlags);
}
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
@@ -235,45 +265,54 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
// Note that the "@X" part of the name above is the total size (in
// bytes) of the arguments on the stack.
void* result;
-#if defined(__BORLANDC__) || defined(__WATCOMC__)
+# if defined(__BORLANDC__) || defined(__WATCOMC__)
// Need to prepend symbols with '_'
- size_t len = sym.size();
- char* rsym = new char[len + 1 + 1];
- strcpy(rsym, "_");
- strcat(rsym, sym.c_str());
-#else
+ std::string ssym = '_' + sym;
+ const char* rsym = ssym.c_str();
+# else
const char* rsym = sym.c_str();
-#endif
+# endif
result = (void*)GetProcAddress(lib, rsym);
-#if defined(__BORLANDC__) || defined(__WATCOMC__)
- delete[] rsym;
-#endif
// Hack to cast pointer-to-data to pointer-to-function.
-#ifdef __WATCOMC__
+# ifdef __WATCOMC__
return *(DynamicLoader::SymbolPointer*)(&result);
-#else
+# else
return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
-#endif
+# endif
}
+# define DYNLOAD_ERROR_BUFFER_SIZE 1024
+
const char* DynamicLoader::LastError()
{
- LPVOID lpMsgBuf = NULL;
-
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR)&lpMsgBuf, 0, NULL);
+ wchar_t lpMsgBuf[DYNLOAD_ERROR_BUFFER_SIZE + 1];
+
+ DWORD error = GetLastError();
+ DWORD length = FormatMessageW(
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, error,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ lpMsgBuf, DYNLOAD_ERROR_BUFFER_SIZE, nullptr);
+
+ static char str[DYNLOAD_ERROR_BUFFER_SIZE + 1];
+
+ if (length < 1) {
+ /* FormatMessage failed. Use a default message. */
+ _snprintf(str, DYNLOAD_ERROR_BUFFER_SIZE,
+ "DynamicLoader encountered error 0x%X. "
+ "FormatMessage failed with error 0x%X",
+ error, GetLastError());
+ return str;
+ }
- if (!lpMsgBuf) {
- return NULL;
+ if (!WideCharToMultiByte(CP_UTF8, 0, lpMsgBuf, -1, str,
+ DYNLOAD_ERROR_BUFFER_SIZE, nullptr, nullptr)) {
+ /* WideCharToMultiByte failed. Use a default message. */
+ _snprintf(str, DYNLOAD_ERROR_BUFFER_SIZE,
+ "DynamicLoader encountered error 0x%X. "
+ "WideCharToMultiByte failed with error 0x%X",
+ error, GetLastError());
}
- static char* str = 0;
- delete[] str;
- str = strcpy(new char[strlen((char*)lpMsgBuf) + 1], (char*)lpMsgBuf);
- // Free the buffer.
- LocalFree(lpMsgBuf);
return str;
}
@@ -281,18 +320,20 @@ const char* DynamicLoader::LastError()
#elif defined(__BEOS__)
// Implementation for BeOS / Haiku
-#include <string.h> // for strerror()
+# include <string.h> // for strerror()
-#include <be/kernel/image.h>
-#include <be/support/Errors.h>
+# include <be/kernel/image.h>
+# include <be/support/Errors.h>
namespace KWSYS_NAMESPACE {
static image_id last_dynamic_err = B_OK;
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
- const std::string& libname)
+ const std::string& libname, int flags)
{
+ CHECK_OPEN_FLAGS(flags, 0, 0);
+
// image_id's are integers, errors are negative. Add one just in case we
// get a valid image_id of zero (is that even possible?).
image_id rc = load_add_on(libname.c_str());
@@ -331,7 +372,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
DynamicLoader::SymbolPointer psym;
} result;
- result.psym = NULL;
+ result.psym = nullptr;
if (!lib) {
last_dynamic_err = B_BAD_VALUE;
@@ -343,7 +384,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
get_image_symbol(lib - 1, sym.c_str(), B_SYMBOL_TYPE_ANY, &result.pvoid);
if (rc != B_OK) {
last_dynamic_err = rc;
- result.psym = NULL;
+ result.psym = nullptr;
}
}
return result.psym;
@@ -360,17 +401,19 @@ const char* DynamicLoader::LastError()
#elif defined(__MINT__)
// Implementation for FreeMiNT on Atari
-#define _GNU_SOURCE /* for program_invocation_name */
-#include <dld.h>
-#include <errno.h>
-#include <malloc.h>
-#include <string.h>
+# define _GNU_SOURCE /* for program_invocation_name */
+# include <dld.h>
+# include <errno.h>
+# include <malloc.h>
+# include <string.h>
namespace KWSYS_NAMESPACE {
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
- const std::string& libname)
+ const std::string& libname, int flags)
{
+ CHECK_OPEN_FLAGS(flags, 0, nullptr);
+
char* name = (char*)calloc(1, libname.size() + 1);
dld_init(program_invocation_name);
strncpy(name, libname.c_str(), libname.size());
@@ -408,13 +451,15 @@ const char* DynamicLoader::LastError()
#else
// Default implementation for *NIX systems (including Mac OS X 10.3 and
// later) which use dlopen
-#include <dlfcn.h>
+# include <dlfcn.h>
namespace KWSYS_NAMESPACE {
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
- const std::string& libname)
+ const std::string& libname, int flags)
{
+ CHECK_OPEN_FLAGS(flags, 0, nullptr);
+
return dlopen(libname.c_str(), RTLD_LAZY);
}
diff --git a/Source/kwsys/DynamicLoader.hxx.in b/Source/kwsys/DynamicLoader.hxx.in
index 7e71a4593..539c74259 100644
--- a/Source/kwsys/DynamicLoader.hxx.in
+++ b/Source/kwsys/DynamicLoader.hxx.in
@@ -8,16 +8,16 @@
#include <string>
#if defined(__hpux)
-#include <dl.h>
+# include <dl.h>
#elif defined(_WIN32) && !defined(__CYGWIN__)
-#include <windows.h>
+# include <windows.h>
#elif defined(__APPLE__)
-#include <AvailabilityMacros.h>
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
-#include <mach-o/dyld.h>
-#endif
+# include <AvailabilityMacros.h>
+# if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
+# include <mach-o/dyld.h>
+# endif
#elif defined(__BEOS__)
-#include <be/kernel/image.h>
+# include <be/kernel/image.h>
#endif
namespace @KWSYS_NAMESPACE@ {
@@ -35,7 +35,7 @@ namespace @KWSYS_NAMESPACE@ {
* or absolute) pathname. Otherwise, the dynamic linker searches for the
* library as follows : see ld.so(8) for further details):
* Whereas this distinction does not exist on Win32. Therefore ideally you
- * should be doing full path to garantee to have a consistent way of dealing
+ * should be doing full path to guarantee to have a consistent way of dealing
* with dynamic loading of shared library.
*
* \warning the Cygwin implementation do not use the Win32 HMODULE. Put extra
@@ -52,11 +52,11 @@ public:
#elif defined(_WIN32) && !defined(__CYGWIN__)
typedef HMODULE LibraryHandle;
#elif defined(__APPLE__)
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
+# if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
typedef NSModule LibraryHandle;
-#else
+# else
typedef void* LibraryHandle;
-#endif
+# endif
#elif defined(__BEOS__)
typedef image_id LibraryHandle;
#else // POSIX
@@ -66,13 +66,26 @@ public:
// Return type from DynamicLoader::GetSymbolAddress.
typedef void (*SymbolPointer)();
+ enum OpenFlags
+ {
+ // Search for dependent libraries beside the library being loaded.
+ //
+ // This is currently only supported on Windows.
+ SearchBesideLibrary = 0x00000001,
+
+ AllOpenFlags = SearchBesideLibrary
+ };
+
/** Load a dynamic library into the current process.
* The returned LibraryHandle can be used to access the symbols in the
- * library. */
+ * library. The optional second argument is a set of flags to use when
+ * opening the library. If unrecognized or unsupported flags are specified,
+ * the library is not opened. */
static LibraryHandle OpenLibrary(const std::string&);
+ static LibraryHandle OpenLibrary(const std::string&, int);
/** Attempt to detach a dynamic library from the
- * process. A value of true is returned if it is sucessful. */
+ * process. A value of true is returned if it is successful. */
static int CloseLibrary(LibraryHandle);
/** Find the address of the symbol in the given library. */
diff --git a/Source/kwsys/Encoding.h.in b/Source/kwsys/Encoding.h.in
index 7b6ed10f8..86a26692a 100644
--- a/Source/kwsys/Encoding.h.in
+++ b/Source/kwsys/Encoding.h.in
@@ -12,15 +12,15 @@
not visible to user code. Use kwsysHeaderDump.pl to reproduce
these macros after making changes to the interface. */
#if !defined(KWSYS_NAMESPACE)
-#define kwsys_ns(x) @KWSYS_NAMESPACE@##x
-#define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
+# define kwsys_ns(x) @KWSYS_NAMESPACE@##x
+# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#define kwsysEncoding kwsys_ns(Encoding)
-#define kwsysEncoding_mbstowcs kwsys_ns(Encoding_mbstowcs)
-#define kwsysEncoding_DupToWide kwsys_ns(Encoding_DupToWide)
-#define kwsysEncoding_wcstombs kwsys_ns(Encoding_wcstombs)
-#define kwsysEncoding_DupToNarrow kwsys_ns(Encoding_DupToNarrow)
+# define kwsysEncoding kwsys_ns(Encoding)
+# define kwsysEncoding_mbstowcs kwsys_ns(Encoding_mbstowcs)
+# define kwsysEncoding_DupToWide kwsys_ns(Encoding_DupToWide)
+# define kwsysEncoding_wcstombs kwsys_ns(Encoding_wcstombs)
+# define kwsysEncoding_DupToNarrow kwsys_ns(Encoding_DupToNarrow)
#endif
#if defined(__cplusplus)
@@ -55,15 +55,15 @@ kwsysEXPORT char* kwsysEncoding_DupToNarrow(const wchar_t* str);
/* If we are building a kwsys .c or .cxx file, let it use these macros.
Otherwise, undefine them to keep the namespace clean. */
#if !defined(KWSYS_NAMESPACE)
-#undef kwsys_ns
-#undef kwsysEXPORT
-#if !defined(KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#undef kwsysEncoding
-#undef kwsysEncoding_mbstowcs
-#undef kwsysEncoding_DupToWide
-#undef kwsysEncoding_wcstombs
-#undef kwsysEncoding_DupToNarrow
-#endif
+# undef kwsys_ns
+# undef kwsysEXPORT
+# if !defined(KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
+# undef kwsysEncoding
+# undef kwsysEncoding_mbstowcs
+# undef kwsysEncoding_DupToWide
+# undef kwsysEncoding_wcstombs
+# undef kwsysEncoding_DupToNarrow
+# endif
#endif
#endif
diff --git a/Source/kwsys/Encoding.hxx.in b/Source/kwsys/Encoding.hxx.in
index 09691fd3f..b06752115 100644
--- a/Source/kwsys/Encoding.hxx.in
+++ b/Source/kwsys/Encoding.hxx.in
@@ -41,9 +41,9 @@ public:
std::vector<char*> argv_;
};
-/**
- * Convert between char and wchar_t
- */
+ /**
+ * Convert between char and wchar_t
+ */
#if @KWSYS_NAMESPACE@_STL_HAS_WSTRING
@@ -59,7 +59,7 @@ public:
static std::string ToNarrow(const std::wstring& str);
static std::string ToNarrow(const wchar_t* str);
-#if defined(_WIN32)
+# if defined(_WIN32)
/**
* Convert the path to an extended length path to avoid MAX_PATH length
* limitations on Windows. If the input is a local path the result will be
@@ -68,7 +68,7 @@ public:
* absolute paths with Windows-style backslashes.
**/
static std::wstring ToWindowsExtendedPath(std::string const&);
-#endif
+# endif
#endif // @KWSYS_NAMESPACE@_STL_HAS_WSTRING
diff --git a/Source/kwsys/EncodingC.c b/Source/kwsys/EncodingC.c
index c1315b2d5..e12236afe 100644
--- a/Source/kwsys/EncodingC.c
+++ b/Source/kwsys/EncodingC.c
@@ -6,13 +6,13 @@
/* Work-around CMake dependency scanning limitation. This must
duplicate the above list of headers. */
#if 0
-#include "Encoding.h.in"
+# include "Encoding.h.in"
#endif
#include <stdlib.h>
#ifdef _WIN32
-#include <windows.h>
+# include <windows.h>
#endif
size_t kwsysEncoding_mbstowcs(wchar_t* dest, const char* str, size_t n)
diff --git a/Source/kwsys/EncodingCXX.cxx b/Source/kwsys/EncodingCXX.cxx
index b1e54c958..4593c9251 100644
--- a/Source/kwsys/EncodingCXX.cxx
+++ b/Source/kwsys/EncodingCXX.cxx
@@ -1,9 +1,9 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#ifdef __osf__
-#define _OSF_SOURCE
-#define _POSIX_C_SOURCE 199506L
-#define _XOPEN_SOURCE_EXTENDED
+# define _OSF_SOURCE
+# define _POSIX_C_SOURCE 199506L
+# define _XOPEN_SOURCE_EXTENDED
#endif
#include "kwsysPrivate.h"
@@ -13,8 +13,8 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "Encoding.h.in"
-#include "Encoding.hxx.in"
+# include "Encoding.h.in"
+# include "Encoding.hxx.in"
#endif
#include <stdlib.h>
@@ -22,15 +22,15 @@
#include <vector>
#ifdef _MSC_VER
-#pragma warning(disable : 4786)
+# pragma warning(disable : 4786)
#endif
// Windows API.
#if defined(_WIN32)
-#include <windows.h>
+# include <windows.h>
-#include <ctype.h>
-#include <shellapi.h>
+# include <ctype.h>
+# include <shellapi.h>
#endif
namespace KWSYS_NAMESPACE {
@@ -65,7 +65,7 @@ Encoding::CommandLineArguments::CommandLineArguments(int ac,
for (int i = 0; i < ac; i++) {
this->argv_[i] = strdup(av[i]);
}
- this->argv_[ac] = 0;
+ this->argv_[ac] = nullptr;
}
Encoding::CommandLineArguments::CommandLineArguments(int ac,
@@ -75,7 +75,7 @@ Encoding::CommandLineArguments::CommandLineArguments(int ac,
for (int i = 0; i < ac; i++) {
this->argv_[i] = kwsysEncoding_DupToNarrow(av[i]);
}
- this->argv_[ac] = 0;
+ this->argv_[ac] = nullptr;
}
Encoding::CommandLineArguments::~CommandLineArguments()
@@ -90,7 +90,7 @@ Encoding::CommandLineArguments::CommandLineArguments(
{
this->argv_.resize(other.argv_.size());
for (size_t i = 0; i < this->argv_.size(); i++) {
- this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0;
+ this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : nullptr;
}
}
@@ -105,7 +105,7 @@ Encoding::CommandLineArguments& Encoding::CommandLineArguments::operator=(
this->argv_.resize(other.argv_.size());
for (i = 0; i < this->argv_.size(); i++) {
- this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0;
+ this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : nullptr;
}
}
@@ -127,9 +127,10 @@ char const* const* Encoding::CommandLineArguments::argv() const
std::wstring Encoding::ToWide(const std::string& str)
{
std::wstring wstr;
-#if defined(_WIN32)
- const int wlength = MultiByteToWideChar(
- KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(), int(str.size()), NULL, 0);
+# if defined(_WIN32)
+ const int wlength =
+ MultiByteToWideChar(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(),
+ int(str.size()), nullptr, 0);
if (wlength > 0) {
wchar_t* wdata = new wchar_t[wlength];
int r = MultiByteToWideChar(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(),
@@ -139,7 +140,7 @@ std::wstring Encoding::ToWide(const std::string& str)
}
delete[] wdata;
}
-#else
+# else
size_t pos = 0;
size_t nullPos = 0;
do {
@@ -152,28 +153,28 @@ std::wstring Encoding::ToWide(const std::string& str)
wstr += wchar_t('\0');
}
} while (nullPos != std::string::npos);
-#endif
+# endif
return wstr;
}
std::string Encoding::ToNarrow(const std::wstring& str)
{
std::string nstr;
-#if defined(_WIN32)
+# if defined(_WIN32)
int length =
WideCharToMultiByte(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.c_str(),
- int(str.size()), NULL, 0, NULL, NULL);
+ int(str.size()), nullptr, 0, nullptr, nullptr);
if (length > 0) {
char* data = new char[length];
int r =
WideCharToMultiByte(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.c_str(),
- int(str.size()), data, length, NULL, NULL);
+ int(str.size()), data, length, nullptr, nullptr);
if (r > 0) {
nstr = std::string(data, length);
}
delete[] data;
}
-#else
+# else
size_t pos = 0;
size_t nullPos = 0;
do {
@@ -186,14 +187,14 @@ std::string Encoding::ToNarrow(const std::wstring& str)
nstr += '\0';
}
} while (nullPos != std::string::npos);
-#endif
+# endif
return nstr;
}
std::wstring Encoding::ToWide(const char* cstr)
{
std::wstring wstr;
- size_t length = kwsysEncoding_mbstowcs(0, cstr, 0) + 1;
+ size_t length = kwsysEncoding_mbstowcs(nullptr, cstr, 0) + 1;
if (length > 0) {
std::vector<wchar_t> wchars(length);
if (kwsysEncoding_mbstowcs(&wchars[0], cstr, length) > 0) {
@@ -206,7 +207,7 @@ std::wstring Encoding::ToWide(const char* cstr)
std::string Encoding::ToNarrow(const wchar_t* wcstr)
{
std::string str;
- size_t length = kwsysEncoding_wcstombs(0, wcstr, 0) + 1;
+ size_t length = kwsysEncoding_wcstombs(nullptr, wcstr, 0) + 1;
if (length > 0) {
std::vector<char> chars(length);
if (kwsysEncoding_wcstombs(&chars[0], wcstr, length) > 0) {
@@ -216,7 +217,7 @@ std::string Encoding::ToNarrow(const wchar_t* wcstr)
return str;
}
-#if defined(_WIN32)
+# if defined(_WIN32)
// Convert local paths to UNC style paths
std::wstring Encoding::ToWindowsExtendedPath(std::string const& source)
{
@@ -227,9 +228,9 @@ std::wstring Encoding::ToWindowsExtendedPath(std::string const& source)
/* The +3 is a workaround for a bug in some versions of GetFullPathNameW that
* won't return a large enough buffer size if the input is too small */
- wfull_len = GetFullPathNameW(wsource.c_str(), 0, NULL, NULL) + 3;
+ wfull_len = GetFullPathNameW(wsource.c_str(), 0, nullptr, nullptr) + 3;
std::vector<wchar_t> wfull(wfull_len);
- GetFullPathNameW(wsource.c_str(), wfull_len, &wfull[0], NULL);
+ GetFullPathNameW(wsource.c_str(), wfull_len, &wfull[0], nullptr);
/* This should get the correct size without any extra padding from the
* previous size workaround. */
@@ -270,7 +271,7 @@ std::wstring Encoding::ToWindowsExtendedPath(std::string const& source)
// unchanged
return Encoding::ToWide(source);
}
-#endif
+# endif
#endif // KWSYS_STL_HAS_WSTRING
diff --git a/Source/kwsys/FStream.cxx b/Source/kwsys/FStream.cxx
index 3c44a6fa0..5e4133ac5 100644
--- a/Source/kwsys/FStream.cxx
+++ b/Source/kwsys/FStream.cxx
@@ -6,7 +6,7 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "FStream.hxx.in"
+# include "FStream.hxx.in"
#endif
namespace KWSYS_NAMESPACE {
diff --git a/Source/kwsys/FStream.hxx.in b/Source/kwsys/FStream.hxx.in
index a4c65fe30..d79bbdf16 100644
--- a/Source/kwsys/FStream.hxx.in
+++ b/Source/kwsys/FStream.hxx.in
@@ -9,26 +9,26 @@
#include <fstream>
#if defined(_WIN32)
-#if !defined(_MSC_VER) && @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H
-#include <ext/stdio_filebuf.h>
-#endif
+# if !defined(_MSC_VER) && @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H
+# include <ext/stdio_filebuf.h>
+# endif
#endif
namespace @KWSYS_NAMESPACE@ {
#if defined(_WIN32) && \
(defined(_MSC_VER) || @KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H)
-#if defined(_NOEXCEPT)
-#define @KWSYS_NAMESPACE@_FStream_NOEXCEPT _NOEXCEPT
-#else
-#define @KWSYS_NAMESPACE@_FStream_NOEXCEPT
-#endif
+# if defined(_NOEXCEPT)
+# define @KWSYS_NAMESPACE@_FStream_NOEXCEPT _NOEXCEPT
+# else
+# define @KWSYS_NAMESPACE@_FStream_NOEXCEPT
+# endif
-#if defined(_MSC_VER)
+# if defined(_MSC_VER)
template <typename CharType, typename Traits>
class basic_filebuf : public std::basic_filebuf<CharType, Traits>
{
-#if _MSC_VER >= 1400
+# if _MSC_VER >= 1400
public:
typedef std::basic_filebuf<CharType, Traits> my_base_type;
basic_filebuf* open(char const* s, std::ios_base::openmode mode)
@@ -36,10 +36,10 @@ public:
const std::wstring wstr = Encoding::ToWindowsExtendedPath(s);
return static_cast<basic_filebuf*>(my_base_type::open(wstr.c_str(), mode));
}
-#endif
+# endif
};
-#else
+# else
inline std::wstring getcmode(const std::ios_base::openmode mode)
{
@@ -67,17 +67,17 @@ inline std::wstring getcmode(const std::ios_base::openmode mode)
return cmode;
};
-#endif
+# endif
template <typename CharType, typename Traits = std::char_traits<CharType> >
class basic_efilebuf
{
public:
-#if defined(_MSC_VER)
+# if defined(_MSC_VER)
typedef basic_filebuf<CharType, Traits> internal_buffer_type;
-#else
+# else
typedef __gnu_cxx::stdio_filebuf<CharType, Traits> internal_buffer_type;
-#endif
+# endif
basic_efilebuf()
: file_(0)
@@ -90,9 +90,9 @@ public:
if (is_open() || file_) {
return false;
}
-#if defined(_MSC_VER)
+# if defined(_MSC_VER)
const bool success = buf_->open(file_name, mode) != 0;
-#else
+# else
const std::wstring wstr = Encoding::ToWindowsExtendedPath(file_name);
bool success = false;
std::wstring cmode = getcmode(mode);
@@ -104,7 +104,7 @@ public:
buf_ = new internal_buffer_type(file_, mode);
success = true;
}
-#endif
+# endif
return success;
}
@@ -129,12 +129,12 @@ public:
bool success = false;
if (buf_) {
success = buf_->close() != 0;
-#if !defined(_MSC_VER)
+# if !defined(_MSC_VER)
if (file_) {
success = fclose(file_) == 0 ? success : false;
file_ = 0;
}
-#endif
+# endif
}
return success;
}
@@ -142,11 +142,11 @@ public:
static void _set_state(bool success, std::basic_ios<CharType, Traits>* ios,
basic_efilebuf* efilebuf)
{
-#if !defined(_MSC_VER)
+# if !defined(_MSC_VER)
ios->rdbuf(efilebuf->buf_);
-#else
+# else
static_cast<void>(efilebuf);
-#endif
+# endif
if (!success) {
ios->setstate(std::ios_base::failbit);
} else {
@@ -167,8 +167,9 @@ protected:
};
template <typename CharType, typename Traits = std::char_traits<CharType> >
-class basic_ifstream : public std::basic_istream<CharType, Traits>,
- public basic_efilebuf<CharType, Traits>
+class basic_ifstream
+ : public std::basic_istream<CharType, Traits>
+ , public basic_efilebuf<CharType, Traits>
{
public:
typedef typename basic_efilebuf<CharType, Traits>::internal_buffer_type
@@ -207,8 +208,9 @@ public:
};
template <typename CharType, typename Traits = std::char_traits<CharType> >
-class basic_ofstream : public std::basic_ostream<CharType, Traits>,
- public basic_efilebuf<CharType, Traits>
+class basic_ofstream
+ : public std::basic_ostream<CharType, Traits>
+ , public basic_efilebuf<CharType, Traits>
{
using basic_efilebuf<CharType, Traits>::is_open;
@@ -248,7 +250,7 @@ public:
typedef basic_ifstream<char> ifstream;
typedef basic_ofstream<char> ofstream;
-#undef @KWSYS_NAMESPACE@_FStream_NOEXCEPT
+# undef @KWSYS_NAMESPACE@_FStream_NOEXCEPT
#else
using std::ofstream;
using std::ifstream;
diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx
index d2f0b8516..34bb0d0fe 100644
--- a/Source/kwsys/Glob.cxx
+++ b/Source/kwsys/Glob.cxx
@@ -12,11 +12,11 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "Configure.hxx.in"
-#include "Directory.hxx.in"
-#include "Glob.hxx.in"
-#include "RegularExpression.hxx.in"
-#include "SystemTools.hxx.in"
+# include "Configure.hxx.in"
+# include "Directory.hxx.in"
+# include "Glob.hxx.in"
+# include "RegularExpression.hxx.in"
+# include "SystemTools.hxx.in"
#endif
#include <algorithm>
@@ -28,13 +28,13 @@
#include <string.h>
namespace KWSYS_NAMESPACE {
#if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
-// On Windows and apple, no difference between lower and upper case
-#define KWSYS_GLOB_CASE_INDEPENDENT
+// On Windows and Apple, no difference between lower and upper case
+# define KWSYS_GLOB_CASE_INDEPENDENT
#endif
#if defined(_WIN32) || defined(__CYGWIN__)
// Handle network paths
-#define KWSYS_GLOB_SUPPORT_NETWORK_PATHS
+# define KWSYS_GLOB_SUPPORT_NETWORK_PATHS
#endif
class GlobInternals
@@ -81,13 +81,13 @@ std::string Glob::PatternToRegex(const std::string& pattern,
int c = *i;
if (c == '*') {
// A '*' (not between brackets) matches any string.
- // We modify this to not match slashes since the orignal glob
+ // We modify this to not match slashes since the original glob
// pattern documentation was meant for matching file name
// components separated by slashes.
regex += "[^/]*";
} else if (c == '?') {
// A '?' (not between brackets) matches any single character.
- // We modify this to not match slashes since the orignal glob
+ // We modify this to not match slashes since the original glob
// pattern documentation was meant for matching file name
// components separated by slashes.
regex += "[^/]";
@@ -201,7 +201,7 @@ bool Glob::RecurseDirectory(std::string::size_type start,
}
#if defined(KWSYS_GLOB_CASE_INDEPENDENT)
- // On Windows and apple, no difference between lower and upper case
+ // On Windows and Apple, no difference between lower and upper case
fname = kwsys::SystemTools::LowerCase(fname);
#endif
@@ -217,9 +217,10 @@ bool Glob::RecurseDirectory(std::string::size_type start,
if (!realPathErrorMessage.empty()) {
if (messages) {
- messages->push_back(Message(
- Glob::error, "Canonical path generation from path '" + dir +
- "' failed! Reason: '" + realPathErrorMessage + "'"));
+ messages->push_back(
+ Message(Glob::error,
+ "Canonical path generation from path '" + dir +
+ "' failed! Reason: '" + realPathErrorMessage + "'"));
}
return false;
}
@@ -262,7 +263,7 @@ bool Glob::RecurseDirectory(std::string::size_type start,
}
} else {
if (!this->Internals->Expressions.empty() &&
- this->Internals->Expressions.rbegin()->find(fname)) {
+ this->Internals->Expressions.back().find(fname)) {
this->AddFile(this->Internals->Files, realname);
}
}
@@ -430,7 +431,7 @@ void Glob::SetRelative(const char* dir)
const char* Glob::GetRelative()
{
if (this->Relative.empty()) {
- return 0;
+ return nullptr;
}
return this->Relative.c_str();
}
diff --git a/Source/kwsys/Glob.hxx.in b/Source/kwsys/Glob.hxx.in
index bd4a17616..170766f4b 100644
--- a/Source/kwsys/Glob.hxx.in
+++ b/Source/kwsys/Glob.hxx.in
@@ -41,17 +41,9 @@ public:
, content(c)
{
}
- Message(const Message& msg)
- : type(msg.type)
- , content(msg.content)
- {
- }
- Message& operator=(Message const& msg)
- {
- this->type = msg.type;
- this->content = msg.content;
- return *this;
- }
+ ~Message() = default;
+ Message(const Message& msg) = default;
+ Message& operator=(Message const& msg) = default;
};
typedef std::vector<Message> GlobMessages;
@@ -62,7 +54,7 @@ public:
~Glob();
//! Find all files that match the pattern.
- bool FindFiles(const std::string& inexpr, GlobMessages* messages = 0);
+ bool FindFiles(const std::string& inexpr, GlobMessages* messages = nullptr);
//! Return the list of files that matched.
std::vector<std::string>& GetFiles();
diff --git a/Source/kwsys/IOStream.cxx b/Source/kwsys/IOStream.cxx
index 01ada1f2f..e21f87d45 100644
--- a/Source/kwsys/IOStream.cxx
+++ b/Source/kwsys/IOStream.cxx
@@ -10,21 +10,21 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "Configure.hxx.in"
-#include "IOStream.hxx.in"
+# include "Configure.hxx.in"
+# include "IOStream.hxx.in"
#endif
// Implement the rest of this file only if it is needed.
#if KWSYS_IOS_NEED_OPERATORS_LL
-#include <stdio.h> // sscanf, sprintf
-#include <string.h> // memchr
+# include <stdio.h> // sscanf, sprintf
+# include <string.h> // memchr
-#if defined(_MAX_INT_DIG)
-#define KWSYS_IOS_INT64_MAX_DIG _MAX_INT_DIG
-#else
-#define KWSYS_IOS_INT64_MAX_DIG 32
-#endif
+# if defined(_MAX_INT_DIG)
+# define KWSYS_IOS_INT64_MAX_DIG _MAX_INT_DIG
+# else
+# define KWSYS_IOS_INT64_MAX_DIG 32
+# endif
namespace KWSYS_NAMESPACE {
@@ -118,13 +118,13 @@ std::istream& IOStreamScanTemplate(std::istream& is, T& value, char type)
try {
// Copy the string to a buffer and construct the format string.
char buffer[KWSYS_IOS_INT64_MAX_DIG];
-#if defined(_MSC_VER)
+# if defined(_MSC_VER)
char format[] = "%I64_";
const int typeIndex = 4;
-#else
+# else
char format[] = "%ll_";
const int typeIndex = 3;
-#endif
+# endif
switch (IOStreamScanStream(is, buffer)) {
case 8:
format[typeIndex] = 'o';
@@ -177,14 +177,14 @@ std::ostream& IOStreamPrintTemplate(std::ostream& os, T value, char type)
if (os.flags() & std::ios_base::showbase) {
*f++ = '#';
}
-#if defined(_MSC_VER)
+# if defined(_MSC_VER)
*f++ = 'I';
*f++ = '6';
*f++ = '4';
-#else
+# else
*f++ = 'l';
*f++ = 'l';
-#endif
+# endif
long bflags = os.flags() & std::ios_base::basefield;
if (bflags == std::ios_base::oct) {
*f++ = 'o';
@@ -209,7 +209,7 @@ std::ostream& IOStreamPrintTemplate(std::ostream& os, T value, char type)
return os;
}
-#if !KWSYS_IOS_HAS_ISTREAM_LONG_LONG
+# if !KWSYS_IOS_HAS_ISTREAM_LONG_LONG
// Implement input stream operator for IOStreamSLL.
std::istream& IOStreamScan(std::istream& is, IOStreamSLL& value)
{
@@ -221,9 +221,9 @@ std::istream& IOStreamScan(std::istream& is, IOStreamULL& value)
{
return IOStreamScanTemplate(is, value, 'u');
}
-#endif
+# endif
-#if !KWSYS_IOS_HAS_OSTREAM_LONG_LONG
+# if !KWSYS_IOS_HAS_OSTREAM_LONG_LONG
// Implement output stream operator for IOStreamSLL.
std::ostream& IOStreamPrint(std::ostream& os, IOStreamSLL value)
{
@@ -235,7 +235,7 @@ std::ostream& IOStreamPrint(std::ostream& os, IOStreamULL value)
{
return IOStreamPrintTemplate(os, value, 'u');
}
-#endif
+# endif
} // namespace KWSYS_NAMESPACE
diff --git a/Source/kwsys/IOStream.hxx.in b/Source/kwsys/IOStream.hxx.in
index de3a2e634..db8a23ef5 100644
--- a/Source/kwsys/IOStream.hxx.in
+++ b/Source/kwsys/IOStream.hxx.in
@@ -7,7 +7,7 @@
/* Define these macros temporarily to keep the code readable. */
#if !defined(KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
+# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
/* Whether istream supports long long. */
@@ -21,27 +21,27 @@
/* Determine whether we need to define the streaming operators for
long long or __int64. */
#if @KWSYS_USE_LONG_LONG@
-#if !@KWSYS_NAMESPACE@_IOS_HAS_ISTREAM_LONG_LONG || \
- !@KWSYS_NAMESPACE@_IOS_HAS_OSTREAM_LONG_LONG
-#define @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL 1
+# if !@KWSYS_NAMESPACE@_IOS_HAS_ISTREAM_LONG_LONG || \
+ !@KWSYS_NAMESPACE@_IOS_HAS_OSTREAM_LONG_LONG
+# define @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL 1
namespace @KWSYS_NAMESPACE@ {
typedef long long IOStreamSLL;
typedef unsigned long long IOStreamULL;
}
-#endif
+# endif
#elif defined(_MSC_VER) && _MSC_VER < 1300
-#define @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL 1
+# define @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL 1
namespace @KWSYS_NAMESPACE@ {
typedef __int64 IOStreamSLL;
typedef unsigned __int64 IOStreamULL;
}
#endif
#if !defined(@KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL)
-#define @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL 0
+# define @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL 0
#endif
#if @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL
-#if !@KWSYS_NAMESPACE@_IOS_HAS_ISTREAM_LONG_LONG
+# if !@KWSYS_NAMESPACE@_IOS_HAS_ISTREAM_LONG_LONG
/* Input stream operator implementation functions. */
namespace @KWSYS_NAMESPACE@ {
@@ -50,31 +50,31 @@ kwsysEXPORT std::istream& IOStreamScan(std::istream&, IOStreamULL&);
}
/* Provide input stream operator for long long. */
-#if !defined(@KWSYS_NAMESPACE@_IOS_NO_ISTREAM_LONG_LONG) && \
- !defined(KWSYS_IOS_ISTREAM_LONG_LONG_DEFINED)
-#define KWSYS_IOS_ISTREAM_LONG_LONG_DEFINED
-#define @KWSYS_NAMESPACE@_IOS_ISTREAM_LONG_LONG_DEFINED
+# if !defined(@KWSYS_NAMESPACE@_IOS_NO_ISTREAM_LONG_LONG) && \
+ !defined(KWSYS_IOS_ISTREAM_LONG_LONG_DEFINED)
+# define KWSYS_IOS_ISTREAM_LONG_LONG_DEFINED
+# define @KWSYS_NAMESPACE@_IOS_ISTREAM_LONG_LONG_DEFINED
inline std::istream& operator>>(std::istream& is,
@KWSYS_NAMESPACE@::IOStreamSLL& value)
{
return @KWSYS_NAMESPACE@::IOStreamScan(is, value);
}
-#endif
+# endif
/* Provide input stream operator for unsigned long long. */
-#if !defined(@KWSYS_NAMESPACE@_IOS_NO_ISTREAM_UNSIGNED_LONG_LONG) && \
- !defined(KWSYS_IOS_ISTREAM_UNSIGNED_LONG_LONG_DEFINED)
-#define KWSYS_IOS_ISTREAM_UNSIGNED_LONG_LONG_DEFINED
-#define @KWSYS_NAMESPACE@_IOS_ISTREAM_UNSIGNED_LONG_LONG_DEFINED
+# if !defined(@KWSYS_NAMESPACE@_IOS_NO_ISTREAM_UNSIGNED_LONG_LONG) && \
+ !defined(KWSYS_IOS_ISTREAM_UNSIGNED_LONG_LONG_DEFINED)
+# define KWSYS_IOS_ISTREAM_UNSIGNED_LONG_LONG_DEFINED
+# define @KWSYS_NAMESPACE@_IOS_ISTREAM_UNSIGNED_LONG_LONG_DEFINED
inline std::istream& operator>>(std::istream& is,
@KWSYS_NAMESPACE@::IOStreamULL& value)
{
return @KWSYS_NAMESPACE@::IOStreamScan(is, value);
}
-#endif
-#endif /* !@KWSYS_NAMESPACE@_IOS_HAS_ISTREAM_LONG_LONG */
+# endif
+# endif /* !@KWSYS_NAMESPACE@_IOS_HAS_ISTREAM_LONG_LONG */
-#if !@KWSYS_NAMESPACE@_IOS_HAS_OSTREAM_LONG_LONG
+# if !@KWSYS_NAMESPACE@_IOS_HAS_OSTREAM_LONG_LONG
/* Output stream operator implementation functions. */
namespace @KWSYS_NAMESPACE@ {
@@ -83,44 +83,44 @@ kwsysEXPORT std::ostream& IOStreamPrint(std::ostream&, IOStreamULL);
}
/* Provide output stream operator for long long. */
-#if !defined(@KWSYS_NAMESPACE@_IOS_NO_OSTREAM_LONG_LONG) && \
- !defined(KWSYS_IOS_OSTREAM_LONG_LONG_DEFINED)
-#define KWSYS_IOS_OSTREAM_LONG_LONG_DEFINED
-#define @KWSYS_NAMESPACE@_IOS_OSTREAM_LONG_LONG_DEFINED
+# if !defined(@KWSYS_NAMESPACE@_IOS_NO_OSTREAM_LONG_LONG) && \
+ !defined(KWSYS_IOS_OSTREAM_LONG_LONG_DEFINED)
+# define KWSYS_IOS_OSTREAM_LONG_LONG_DEFINED
+# define @KWSYS_NAMESPACE@_IOS_OSTREAM_LONG_LONG_DEFINED
inline std::ostream& operator<<(std::ostream& os,
@KWSYS_NAMESPACE@::IOStreamSLL value)
{
return @KWSYS_NAMESPACE@::IOStreamPrint(os, value);
}
-#endif
+# endif
/* Provide output stream operator for unsigned long long. */
-#if !defined(@KWSYS_NAMESPACE@_IOS_NO_OSTREAM_UNSIGNED_LONG_LONG) && \
- !defined(KWSYS_IOS_OSTREAM_UNSIGNED_LONG_LONG_DEFINED)
-#define KWSYS_IOS_OSTREAM_UNSIGNED_LONG_LONG_DEFINED
-#define @KWSYS_NAMESPACE@_IOS_OSTREAM_UNSIGNED_LONG_LONG_DEFINED
+# if !defined(@KWSYS_NAMESPACE@_IOS_NO_OSTREAM_UNSIGNED_LONG_LONG) && \
+ !defined(KWSYS_IOS_OSTREAM_UNSIGNED_LONG_LONG_DEFINED)
+# define KWSYS_IOS_OSTREAM_UNSIGNED_LONG_LONG_DEFINED
+# define @KWSYS_NAMESPACE@_IOS_OSTREAM_UNSIGNED_LONG_LONG_DEFINED
inline std::ostream& operator<<(std::ostream& os,
@KWSYS_NAMESPACE@::IOStreamULL value)
{
return @KWSYS_NAMESPACE@::IOStreamPrint(os, value);
}
-#endif
-#endif /* !@KWSYS_NAMESPACE@_IOS_HAS_OSTREAM_LONG_LONG */
-#endif /* @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL */
+# endif
+# endif /* !@KWSYS_NAMESPACE@_IOS_HAS_OSTREAM_LONG_LONG */
+#endif /* @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL */
/* Undefine temporary macros. */
#if !defined(KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#undef kwsysEXPORT
+# undef kwsysEXPORT
#endif
/* If building a C++ file in kwsys itself, give the source file
access to the macros without a configured namespace. */
#if defined(KWSYS_NAMESPACE)
-#define KWSYS_IOS_HAS_ISTREAM_LONG_LONG \
- @KWSYS_NAMESPACE@_IOS_HAS_ISTREAM_LONG_LONG
-#define KWSYS_IOS_HAS_OSTREAM_LONG_LONG \
- @KWSYS_NAMESPACE@_IOS_HAS_OSTREAM_LONG_LONG
-#define KWSYS_IOS_NEED_OPERATORS_LL @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL
+# define KWSYS_IOS_HAS_ISTREAM_LONG_LONG \
+ @KWSYS_NAMESPACE@_IOS_HAS_ISTREAM_LONG_LONG
+# define KWSYS_IOS_HAS_OSTREAM_LONG_LONG \
+ @KWSYS_NAMESPACE@_IOS_HAS_OSTREAM_LONG_LONG
+# define KWSYS_IOS_NEED_OPERATORS_LL @KWSYS_NAMESPACE@_IOS_NEED_OPERATORS_LL
#endif
#endif
diff --git a/Source/kwsys/MD5.c b/Source/kwsys/MD5.c
index 3188fb67a..97cf9ba68 100644
--- a/Source/kwsys/MD5.c
+++ b/Source/kwsys/MD5.c
@@ -6,7 +6,7 @@
/* Work-around CMake dependency scanning limitation. This must
duplicate the above list of headers. */
#if 0
-#include "MD5.h.in"
+# include "MD5.h.in"
#endif
#include <stddef.h> /* size_t */
@@ -19,8 +19,8 @@
implementation file. */
#if defined(__clang__) && !defined(__INTEL_COMPILER)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wcast-align"
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wcast-align"
#endif
/*
@@ -98,9 +98,9 @@ typedef struct md5_state_s
#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
#ifdef ARCH_IS_BIG_ENDIAN
-#define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1)
+# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1)
#else
-#define BYTE_ORDER 0
+# define BYTE_ORDER 0
#endif
#define T_MASK ((md5_word_t)~0)
@@ -222,11 +222,11 @@ static void md5_process(md5_state_t* pms, const md5_byte_t* data /*[64]*/)
const md5_byte_t* xp = data;
int i;
-#if BYTE_ORDER == 0
+# if BYTE_ORDER == 0
X = xbuf; /* (dynamic only) */
-#else
-#define xbuf X /* (static only) */
-#endif
+# else
+# define xbuf X /* (static only) */
+# endif
for (i = 0; i < 16; ++i, xp += 4)
xbuf[i] =
(md5_word_t)(xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24));
@@ -420,7 +420,7 @@ static void md5_finish(md5_state_t* pms, md5_byte_t digest[16])
}
#if defined(__clang__) && !defined(__INTEL_COMPILER)
-#pragma clang diagnostic pop
+# pragma clang diagnostic pop
#endif
/* Wrap up the MD5 state in our opaque structure. */
diff --git a/Source/kwsys/MD5.h.in b/Source/kwsys/MD5.h.in
index c257f7f9a..7646f1297 100644
--- a/Source/kwsys/MD5.h.in
+++ b/Source/kwsys/MD5.h.in
@@ -10,19 +10,19 @@
not visible to user code. Use kwsysHeaderDump.pl to reproduce
these macros after making changes to the interface. */
#if !defined(KWSYS_NAMESPACE)
-#define kwsys_ns(x) @KWSYS_NAMESPACE@##x
-#define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
+# define kwsys_ns(x) @KWSYS_NAMESPACE@##x
+# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#define kwsysMD5 kwsys_ns(MD5)
-#define kwsysMD5_s kwsys_ns(MD5_s)
-#define kwsysMD5_New kwsys_ns(MD5_New)
-#define kwsysMD5_Delete kwsys_ns(MD5_Delete)
-#define kwsysMD5_Initialize kwsys_ns(MD5_Initialize)
-#define kwsysMD5_Append kwsys_ns(MD5_Append)
-#define kwsysMD5_Finalize kwsys_ns(MD5_Finalize)
-#define kwsysMD5_FinalizeHex kwsys_ns(MD5_FinalizeHex)
-#define kwsysMD5_DigestToHex kwsys_ns(MD5_DigestToHex)
+# define kwsysMD5 kwsys_ns(MD5)
+# define kwsysMD5_s kwsys_ns(MD5_s)
+# define kwsysMD5_New kwsys_ns(MD5_New)
+# define kwsysMD5_Delete kwsys_ns(MD5_Delete)
+# define kwsysMD5_Initialize kwsys_ns(MD5_Initialize)
+# define kwsysMD5_Append kwsys_ns(MD5_Append)
+# define kwsysMD5_Finalize kwsys_ns(MD5_Finalize)
+# define kwsysMD5_FinalizeHex kwsys_ns(MD5_FinalizeHex)
+# define kwsysMD5_DigestToHex kwsys_ns(MD5_DigestToHex)
#endif
#if defined(__cplusplus)
@@ -79,19 +79,19 @@ kwsysEXPORT void kwsysMD5_DigestToHex(unsigned char const digest[16],
/* If we are building a kwsys .c or .cxx file, let it use these macros.
Otherwise, undefine them to keep the namespace clean. */
#if !defined(KWSYS_NAMESPACE)
-#undef kwsys_ns
-#undef kwsysEXPORT
-#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#undef kwsysMD5
-#undef kwsysMD5_s
-#undef kwsysMD5_New
-#undef kwsysMD5_Delete
-#undef kwsysMD5_Initialize
-#undef kwsysMD5_Append
-#undef kwsysMD5_Finalize
-#undef kwsysMD5_FinalizeHex
-#undef kwsysMD5_DigestToHex
-#endif
+# undef kwsys_ns
+# undef kwsysEXPORT
+# if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
+# undef kwsysMD5
+# undef kwsysMD5_s
+# undef kwsysMD5_New
+# undef kwsysMD5_Delete
+# undef kwsysMD5_Initialize
+# undef kwsysMD5_Append
+# undef kwsysMD5_Finalize
+# undef kwsysMD5_FinalizeHex
+# undef kwsysMD5_DigestToHex
+# endif
#endif
#endif
diff --git a/Source/kwsys/Process.h.in b/Source/kwsys/Process.h.in
index 237001c60..73ea9dbfc 100644
--- a/Source/kwsys/Process.h.in
+++ b/Source/kwsys/Process.h.in
@@ -10,74 +10,79 @@
not visible to user code. Use kwsysHeaderDump.pl to reproduce
these macros after making changes to the interface. */
#if !defined(KWSYS_NAMESPACE)
-#define kwsys_ns(x) @KWSYS_NAMESPACE@##x
-#define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
+# define kwsys_ns(x) @KWSYS_NAMESPACE@##x
+# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#define kwsysProcess kwsys_ns(Process)
-#define kwsysProcess_s kwsys_ns(Process_s)
-#define kwsysProcess_New kwsys_ns(Process_New)
-#define kwsysProcess_Delete kwsys_ns(Process_Delete)
-#define kwsysProcess_SetCommand kwsys_ns(Process_SetCommand)
-#define kwsysProcess_AddCommand kwsys_ns(Process_AddCommand)
-#define kwsysProcess_SetTimeout kwsys_ns(Process_SetTimeout)
-#define kwsysProcess_SetWorkingDirectory kwsys_ns(Process_SetWorkingDirectory)
-#define kwsysProcess_SetPipeFile kwsys_ns(Process_SetPipeFile)
-#define kwsysProcess_SetPipeNative kwsys_ns(Process_SetPipeNative)
-#define kwsysProcess_SetPipeShared kwsys_ns(Process_SetPipeShared)
-#define kwsysProcess_Option_Detach kwsys_ns(Process_Option_Detach)
-#define kwsysProcess_Option_HideWindow kwsys_ns(Process_Option_HideWindow)
-#define kwsysProcess_Option_MergeOutput kwsys_ns(Process_Option_MergeOutput)
-#define kwsysProcess_Option_Verbatim kwsys_ns(Process_Option_Verbatim)
-#define kwsysProcess_Option_CreateProcessGroup \
- kwsys_ns(Process_Option_CreateProcessGroup)
-#define kwsysProcess_GetOption kwsys_ns(Process_GetOption)
-#define kwsysProcess_SetOption kwsys_ns(Process_SetOption)
-#define kwsysProcess_Option_e kwsys_ns(Process_Option_e)
-#define kwsysProcess_State_Starting kwsys_ns(Process_State_Starting)
-#define kwsysProcess_State_Error kwsys_ns(Process_State_Error)
-#define kwsysProcess_State_Exception kwsys_ns(Process_State_Exception)
-#define kwsysProcess_State_Executing kwsys_ns(Process_State_Executing)
-#define kwsysProcess_State_Exited kwsys_ns(Process_State_Exited)
-#define kwsysProcess_State_Expired kwsys_ns(Process_State_Expired)
-#define kwsysProcess_State_Killed kwsys_ns(Process_State_Killed)
-#define kwsysProcess_State_Disowned kwsys_ns(Process_State_Disowned)
-#define kwsysProcess_State_e kwsys_ns(Process_State_e)
-#define kwsysProcess_Exception_None kwsys_ns(Process_Exception_None)
-#define kwsysProcess_Exception_Fault kwsys_ns(Process_Exception_Fault)
-#define kwsysProcess_Exception_Illegal kwsys_ns(Process_Exception_Illegal)
-#define kwsysProcess_Exception_Interrupt kwsys_ns(Process_Exception_Interrupt)
-#define kwsysProcess_Exception_Numerical kwsys_ns(Process_Exception_Numerical)
-#define kwsysProcess_Exception_Other kwsys_ns(Process_Exception_Other)
-#define kwsysProcess_Exception_e kwsys_ns(Process_Exception_e)
-#define kwsysProcess_GetState kwsys_ns(Process_GetState)
-#define kwsysProcess_GetExitException kwsys_ns(Process_GetExitException)
-#define kwsysProcess_GetExitCode kwsys_ns(Process_GetExitCode)
-#define kwsysProcess_GetExitValue kwsys_ns(Process_GetExitValue)
-#define kwsysProcess_GetErrorString kwsys_ns(Process_GetErrorString)
-#define kwsysProcess_GetExceptionString kwsys_ns(Process_GetExceptionString)
-#define kwsysProcess_GetStateByIndex kwsys_ns(Process_GetStateByIndex)
-#define kwsysProcess_GetExitExceptionByIndex \
- kwsys_ns(Process_GetExitExceptionByIndex)
-#define kwsysProcess_GetExitCodeByIndex kwsys_ns(Process_GetExitCodeByIndex)
-#define kwsysProcess_GetExitValueByIndex kwsys_ns(Process_GetExitValueByIndex)
-#define kwsysProcess_GetExceptionStringByIndex \
- kwsys_ns(Process_GetExceptionStringByIndex)
-#define kwsysProcess_GetExitCodeByIndex kwsys_ns(Process_GetExitCodeByIndex)
-#define kwsysProcess_Execute kwsys_ns(Process_Execute)
-#define kwsysProcess_Disown kwsys_ns(Process_Disown)
-#define kwsysProcess_WaitForData kwsys_ns(Process_WaitForData)
-#define kwsysProcess_Pipes_e kwsys_ns(Process_Pipes_e)
-#define kwsysProcess_Pipe_None kwsys_ns(Process_Pipe_None)
-#define kwsysProcess_Pipe_STDIN kwsys_ns(Process_Pipe_STDIN)
-#define kwsysProcess_Pipe_STDOUT kwsys_ns(Process_Pipe_STDOUT)
-#define kwsysProcess_Pipe_STDERR kwsys_ns(Process_Pipe_STDERR)
-#define kwsysProcess_Pipe_Timeout kwsys_ns(Process_Pipe_Timeout)
-#define kwsysProcess_Pipe_Handle kwsys_ns(Process_Pipe_Handle)
-#define kwsysProcess_WaitForExit kwsys_ns(Process_WaitForExit)
-#define kwsysProcess_Interrupt kwsys_ns(Process_Interrupt)
-#define kwsysProcess_Kill kwsys_ns(Process_Kill)
-#define kwsysProcess_ResetStartTime kwsys_ns(Process_ResetStartTime)
+# define kwsysProcess kwsys_ns(Process)
+# define kwsysProcess_s kwsys_ns(Process_s)
+# define kwsysProcess_New kwsys_ns(Process_New)
+# define kwsysProcess_Delete kwsys_ns(Process_Delete)
+# define kwsysProcess_SetCommand kwsys_ns(Process_SetCommand)
+# define kwsysProcess_AddCommand kwsys_ns(Process_AddCommand)
+# define kwsysProcess_SetTimeout kwsys_ns(Process_SetTimeout)
+# define kwsysProcess_SetWorkingDirectory \
+ kwsys_ns(Process_SetWorkingDirectory)
+# define kwsysProcess_SetPipeFile kwsys_ns(Process_SetPipeFile)
+# define kwsysProcess_SetPipeNative kwsys_ns(Process_SetPipeNative)
+# define kwsysProcess_SetPipeShared kwsys_ns(Process_SetPipeShared)
+# define kwsysProcess_Option_Detach kwsys_ns(Process_Option_Detach)
+# define kwsysProcess_Option_HideWindow kwsys_ns(Process_Option_HideWindow)
+# define kwsysProcess_Option_MergeOutput kwsys_ns(Process_Option_MergeOutput)
+# define kwsysProcess_Option_Verbatim kwsys_ns(Process_Option_Verbatim)
+# define kwsysProcess_Option_CreateProcessGroup \
+ kwsys_ns(Process_Option_CreateProcessGroup)
+# define kwsysProcess_GetOption kwsys_ns(Process_GetOption)
+# define kwsysProcess_SetOption kwsys_ns(Process_SetOption)
+# define kwsysProcess_Option_e kwsys_ns(Process_Option_e)
+# define kwsysProcess_State_Starting kwsys_ns(Process_State_Starting)
+# define kwsysProcess_State_Error kwsys_ns(Process_State_Error)
+# define kwsysProcess_State_Exception kwsys_ns(Process_State_Exception)
+# define kwsysProcess_State_Executing kwsys_ns(Process_State_Executing)
+# define kwsysProcess_State_Exited kwsys_ns(Process_State_Exited)
+# define kwsysProcess_State_Expired kwsys_ns(Process_State_Expired)
+# define kwsysProcess_State_Killed kwsys_ns(Process_State_Killed)
+# define kwsysProcess_State_Disowned kwsys_ns(Process_State_Disowned)
+# define kwsysProcess_State_e kwsys_ns(Process_State_e)
+# define kwsysProcess_Exception_None kwsys_ns(Process_Exception_None)
+# define kwsysProcess_Exception_Fault kwsys_ns(Process_Exception_Fault)
+# define kwsysProcess_Exception_Illegal kwsys_ns(Process_Exception_Illegal)
+# define kwsysProcess_Exception_Interrupt \
+ kwsys_ns(Process_Exception_Interrupt)
+# define kwsysProcess_Exception_Numerical \
+ kwsys_ns(Process_Exception_Numerical)
+# define kwsysProcess_Exception_Other kwsys_ns(Process_Exception_Other)
+# define kwsysProcess_Exception_e kwsys_ns(Process_Exception_e)
+# define kwsysProcess_GetState kwsys_ns(Process_GetState)
+# define kwsysProcess_GetExitException kwsys_ns(Process_GetExitException)
+# define kwsysProcess_GetExitCode kwsys_ns(Process_GetExitCode)
+# define kwsysProcess_GetExitValue kwsys_ns(Process_GetExitValue)
+# define kwsysProcess_GetErrorString kwsys_ns(Process_GetErrorString)
+# define kwsysProcess_GetExceptionString kwsys_ns(Process_GetExceptionString)
+# define kwsysProcess_GetStateByIndex kwsys_ns(Process_GetStateByIndex)
+# define kwsysProcess_GetExitExceptionByIndex \
+ kwsys_ns(Process_GetExitExceptionByIndex)
+# define kwsysProcess_GetExitCodeByIndex kwsys_ns(Process_GetExitCodeByIndex)
+# define kwsysProcess_GetExitValueByIndex \
+ kwsys_ns(Process_GetExitValueByIndex)
+# define kwsysProcess_GetExceptionStringByIndex \
+ kwsys_ns(Process_GetExceptionStringByIndex)
+# define kwsysProcess_GetExitCodeByIndex kwsys_ns(Process_GetExitCodeByIndex)
+# define kwsysProcess_Execute kwsys_ns(Process_Execute)
+# define kwsysProcess_Disown kwsys_ns(Process_Disown)
+# define kwsysProcess_WaitForData kwsys_ns(Process_WaitForData)
+# define kwsysProcess_Pipes_e kwsys_ns(Process_Pipes_e)
+# define kwsysProcess_Pipe_None kwsys_ns(Process_Pipe_None)
+# define kwsysProcess_Pipe_STDIN kwsys_ns(Process_Pipe_STDIN)
+# define kwsysProcess_Pipe_STDOUT kwsys_ns(Process_Pipe_STDOUT)
+# define kwsysProcess_Pipe_STDERR kwsys_ns(Process_Pipe_STDERR)
+# define kwsysProcess_Pipe_Timeout kwsys_ns(Process_Pipe_Timeout)
+# define kwsysProcess_Pipe_Handle kwsys_ns(Process_Pipe_Handle)
+# define kwsysProcess_WaitForExit kwsys_ns(Process_WaitForExit)
+# define kwsysProcess_Interrupt kwsys_ns(Process_Interrupt)
+# define kwsysProcess_Kill kwsys_ns(Process_Kill)
+# define kwsysProcess_KillPID kwsys_ns(Process_KillPID)
+# define kwsysProcess_ResetStartTime kwsys_ns(Process_ResetStartTime)
#endif
#if defined(__cplusplus)
@@ -306,13 +311,13 @@ kwsysEXPORT const char* kwsysProcess_GetErrorString(kwsysProcess* cp);
kwsysEXPORT const char* kwsysProcess_GetExceptionString(kwsysProcess* cp);
/**
-* Get the current state of the Process instance. Possible states are:
-*
-* kwsysProcess_StateByIndex_Starting = Execute has not yet been called.
-* kwsysProcess_StateByIndex_Exception = Child process exited abnormally.
-* kwsysProcess_StateByIndex_Exited = Child process exited normally.
-* kwsysProcess_StateByIndex_Error = Error getting the child return code.
-*/
+ * Get the current state of the Process instance. Possible states are:
+ *
+ * kwsysProcess_StateByIndex_Starting = Execute has not yet been called.
+ * kwsysProcess_StateByIndex_Exception = Child process exited abnormally.
+ * kwsysProcess_StateByIndex_Exited = Child process exited normally.
+ * kwsysProcess_StateByIndex_Error = Error getting the child return code.
+ */
kwsysEXPORT int kwsysProcess_GetStateByIndex(kwsysProcess* cp, int idx);
enum kwsysProcess_StateByIndex_e
{
@@ -323,46 +328,46 @@ enum kwsysProcess_StateByIndex_e
};
/**
-* When GetState returns "Exception", this method returns a
-* platform-independent description of the exceptional behavior that
-* caused the child to terminate abnormally. Possible exceptions are:
-*
-* kwsysProcess_Exception_None = No exceptional behavior occurred.
-* kwsysProcess_Exception_Fault = Child crashed with a memory fault.
-* kwsysProcess_Exception_Illegal = Child crashed with an illegal
-* instruction.
-* kwsysProcess_Exception_Interrupt = Child was interrupted by user
-* (Cntl-C/Break).
-* kwsysProcess_Exception_Numerical = Child crashed with a numerical
-* exception.
-* kwsysProcess_Exception_Other = Child terminated for another reason.
-*/
+ * When GetState returns "Exception", this method returns a
+ * platform-independent description of the exceptional behavior that
+ * caused the child to terminate abnormally. Possible exceptions are:
+ *
+ * kwsysProcess_Exception_None = No exceptional behavior occurred.
+ * kwsysProcess_Exception_Fault = Child crashed with a memory fault.
+ * kwsysProcess_Exception_Illegal = Child crashed with an illegal
+ * instruction.
+ * kwsysProcess_Exception_Interrupt = Child was interrupted by user
+ * (Cntl-C/Break).
+ * kwsysProcess_Exception_Numerical = Child crashed with a numerical
+ * exception.
+ * kwsysProcess_Exception_Other = Child terminated for another reason.
+ */
kwsysEXPORT int kwsysProcess_GetExitExceptionByIndex(kwsysProcess* cp,
int idx);
/**
-* When GetState returns "Exited" or "Exception", this method returns
-* the platform-specific raw exit code of the process. UNIX platforms
-* should use WIFEXITED/WEXITSTATUS and WIFSIGNALED/WTERMSIG to access
-* this value. Windows users should compare the value to the various
-* EXCEPTION_* values.
-*
-* If GetState returns "Exited", use GetExitValue to get the
-* platform-independent child return value.
-*/
+ * When GetState returns "Exited" or "Exception", this method returns
+ * the platform-specific raw exit code of the process. UNIX platforms
+ * should use WIFEXITED/WEXITSTATUS and WIFSIGNALED/WTERMSIG to access
+ * this value. Windows users should compare the value to the various
+ * EXCEPTION_* values.
+ *
+ * If GetState returns "Exited", use GetExitValue to get the
+ * platform-independent child return value.
+ */
kwsysEXPORT int kwsysProcess_GetExitCodeByIndex(kwsysProcess* cp, int idx);
/**
-* When GetState returns "Exited", this method returns the child's
-* platform-independent exit code (such as the value returned by the
-* child's main).
-*/
+ * When GetState returns "Exited", this method returns the child's
+ * platform-independent exit code (such as the value returned by the
+ * child's main).
+ */
kwsysEXPORT int kwsysProcess_GetExitValueByIndex(kwsysProcess* cp, int idx);
/**
-* When GetState returns "Exception", this method returns a string
-* describing the problem. Otherwise, it returns NULL.
-*/
+ * When GetState returns "Exception", this method returns a string
+ * describing the problem. Otherwise, it returns NULL.
+ */
kwsysEXPORT const char* kwsysProcess_GetExceptionStringByIndex(
kwsysProcess* cp, int idx);
@@ -420,7 +425,7 @@ enum kwsysProcess_Pipes_e
/**
* Block until the child process terminates or the given timeout
- * expires. If no process is running, returns immediatly. The
+ * expires. If no process is running, returns immediately. The
* argument is:
*
* timeout = Specifies the maximum time this call may block. Upon
@@ -457,6 +462,13 @@ kwsysEXPORT void kwsysProcess_Interrupt(kwsysProcess* cp);
kwsysEXPORT void kwsysProcess_Kill(kwsysProcess* cp);
/**
+ * Same as kwsysProcess_Kill using process ID to locate process to
+ * terminate.
+ * @see kwsysProcess_Kill(kwsysProcess* cp)
+ */
+kwsysEXPORT void kwsysProcess_KillPID(unsigned long);
+
+/**
* Reset the start time of the child process to the current time.
*/
kwsysEXPORT void kwsysProcess_ResetStartTime(kwsysProcess* cp);
@@ -468,65 +480,65 @@ kwsysEXPORT void kwsysProcess_ResetStartTime(kwsysProcess* cp);
/* If we are building a kwsys .c or .cxx file, let it use these macros.
Otherwise, undefine them to keep the namespace clean. */
#if !defined(KWSYS_NAMESPACE)
-#undef kwsys_ns
-#undef kwsysEXPORT
-#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#undef kwsysProcess
-#undef kwsysProcess_s
-#undef kwsysProcess_New
-#undef kwsysProcess_Delete
-#undef kwsysProcess_SetCommand
-#undef kwsysProcess_AddCommand
-#undef kwsysProcess_SetTimeout
-#undef kwsysProcess_SetWorkingDirectory
-#undef kwsysProcess_SetPipeFile
-#undef kwsysProcess_SetPipeNative
-#undef kwsysProcess_SetPipeShared
-#undef kwsysProcess_Option_Detach
-#undef kwsysProcess_Option_HideWindow
-#undef kwsysProcess_Option_MergeOutput
-#undef kwsysProcess_Option_Verbatim
-#undef kwsysProcess_Option_CreateProcessGroup
-#undef kwsysProcess_GetOption
-#undef kwsysProcess_SetOption
-#undef kwsysProcess_Option_e
-#undef kwsysProcess_State_Starting
-#undef kwsysProcess_State_Error
-#undef kwsysProcess_State_Exception
-#undef kwsysProcess_State_Executing
-#undef kwsysProcess_State_Exited
-#undef kwsysProcess_State_Expired
-#undef kwsysProcess_State_Killed
-#undef kwsysProcess_State_Disowned
-#undef kwsysProcess_GetState
-#undef kwsysProcess_State_e
-#undef kwsysProcess_Exception_None
-#undef kwsysProcess_Exception_Fault
-#undef kwsysProcess_Exception_Illegal
-#undef kwsysProcess_Exception_Interrupt
-#undef kwsysProcess_Exception_Numerical
-#undef kwsysProcess_Exception_Other
-#undef kwsysProcess_GetExitException
-#undef kwsysProcess_Exception_e
-#undef kwsysProcess_GetExitCode
-#undef kwsysProcess_GetExitValue
-#undef kwsysProcess_GetErrorString
-#undef kwsysProcess_GetExceptionString
-#undef kwsysProcess_Execute
-#undef kwsysProcess_Disown
-#undef kwsysProcess_WaitForData
-#undef kwsysProcess_Pipes_e
-#undef kwsysProcess_Pipe_None
-#undef kwsysProcess_Pipe_STDIN
-#undef kwsysProcess_Pipe_STDOUT
-#undef kwsysProcess_Pipe_STDERR
-#undef kwsysProcess_Pipe_Timeout
-#undef kwsysProcess_Pipe_Handle
-#undef kwsysProcess_WaitForExit
-#undef kwsysProcess_Interrupt
-#undef kwsysProcess_Kill
-#undef kwsysProcess_ResetStartTime
-#endif
+# undef kwsys_ns
+# undef kwsysEXPORT
+# if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
+# undef kwsysProcess
+# undef kwsysProcess_s
+# undef kwsysProcess_New
+# undef kwsysProcess_Delete
+# undef kwsysProcess_SetCommand
+# undef kwsysProcess_AddCommand
+# undef kwsysProcess_SetTimeout
+# undef kwsysProcess_SetWorkingDirectory
+# undef kwsysProcess_SetPipeFile
+# undef kwsysProcess_SetPipeNative
+# undef kwsysProcess_SetPipeShared
+# undef kwsysProcess_Option_Detach
+# undef kwsysProcess_Option_HideWindow
+# undef kwsysProcess_Option_MergeOutput
+# undef kwsysProcess_Option_Verbatim
+# undef kwsysProcess_Option_CreateProcessGroup
+# undef kwsysProcess_GetOption
+# undef kwsysProcess_SetOption
+# undef kwsysProcess_Option_e
+# undef kwsysProcess_State_Starting
+# undef kwsysProcess_State_Error
+# undef kwsysProcess_State_Exception
+# undef kwsysProcess_State_Executing
+# undef kwsysProcess_State_Exited
+# undef kwsysProcess_State_Expired
+# undef kwsysProcess_State_Killed
+# undef kwsysProcess_State_Disowned
+# undef kwsysProcess_GetState
+# undef kwsysProcess_State_e
+# undef kwsysProcess_Exception_None
+# undef kwsysProcess_Exception_Fault
+# undef kwsysProcess_Exception_Illegal
+# undef kwsysProcess_Exception_Interrupt
+# undef kwsysProcess_Exception_Numerical
+# undef kwsysProcess_Exception_Other
+# undef kwsysProcess_GetExitException
+# undef kwsysProcess_Exception_e
+# undef kwsysProcess_GetExitCode
+# undef kwsysProcess_GetExitValue
+# undef kwsysProcess_GetErrorString
+# undef kwsysProcess_GetExceptionString
+# undef kwsysProcess_Execute
+# undef kwsysProcess_Disown
+# undef kwsysProcess_WaitForData
+# undef kwsysProcess_Pipes_e
+# undef kwsysProcess_Pipe_None
+# undef kwsysProcess_Pipe_STDIN
+# undef kwsysProcess_Pipe_STDOUT
+# undef kwsysProcess_Pipe_STDERR
+# undef kwsysProcess_Pipe_Timeout
+# undef kwsysProcess_Pipe_Handle
+# undef kwsysProcess_WaitForExit
+# undef kwsysProcess_Interrupt
+# undef kwsysProcess_Kill
+# undef kwsysProcess_ResetStartTime
+# endif
#endif
#endif
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index 9ebcfce59..f65690b31 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -7,8 +7,8 @@
/* Work-around CMake dependency scanning limitation. This must
duplicate the above list of headers. */
#if 0
-#include "Process.h.in"
-#include "System.h.in"
+# include "Process.h.in"
+# include "System.h.in"
#endif
/*
@@ -40,7 +40,7 @@ do.
#if defined(__CYGWIN__)
/* Increase the file descriptor limit for select() before including
related system headers. (Default: 64) */
-#define FD_SETSIZE 16384
+# define FD_SETSIZE 16384
#endif
#include <assert.h> /* assert */
@@ -61,9 +61,9 @@ do.
#include <unistd.h> /* pipe, close, fork, execvp, select, _exit */
#if defined(__VMS)
-#define KWSYSPE_VMS_NONBLOCK , O_NONBLOCK
+# define KWSYSPE_VMS_NONBLOCK , O_NONBLOCK
#else
-#define KWSYSPE_VMS_NONBLOCK
+# define KWSYSPE_VMS_NONBLOCK
#endif
#if defined(KWSYS_C_HAS_PTRDIFF_T) && KWSYS_C_HAS_PTRDIFF_T
@@ -80,13 +80,13 @@ typedef int kwsysProcess_ssize_t;
#if defined(__BEOS__) && !defined(__ZETA__)
/* BeOS 5 doesn't have usleep(), but it has snooze(), which is identical. */
-#include <be/kernel/OS.h>
+# include <be/kernel/OS.h>
static inline void kwsysProcess_usleep(unsigned int msec)
{
snooze(msec);
}
#else
-#define kwsysProcess_usleep usleep
+# define kwsysProcess_usleep usleep
#endif
/*
@@ -99,13 +99,14 @@ static inline void kwsysProcess_usleep(unsigned int msec)
* pipes' file handles to be non-blocking and just poll them directly
* without select().
*/
-#if !defined(__BEOS__) && !defined(__VMS) && !defined(__MINT__)
-#define KWSYSPE_USE_SELECT 1
+#if !defined(__BEOS__) && !defined(__VMS) && !defined(__MINT__) && \
+ !defined(KWSYSPE_USE_SELECT)
+# define KWSYSPE_USE_SELECT 1
#endif
/* Some platforms do not have siginfo on their signal handlers. */
#if defined(SA_SIGINFO) && !defined(__BEOS__)
-#define KWSYSPE_USE_SIGINFO 1
+# define KWSYSPE_USE_SIGINFO 1
#endif
/* The number of pipes for the child's output. The standard stdout
@@ -230,7 +231,7 @@ struct kwsysProcess_s
when reaping PIDs or modifying this array to avoid race conditions. */
volatile pid_t* volatile ForkPIDs;
- /* Flag for whether the children were terminated by a faild select. */
+ /* Flag for whether the children were terminated by a failed select. */
int SelectError;
/* The timeout length. */
@@ -358,9 +359,7 @@ void kwsysProcess_Delete(kwsysProcess* cp)
kwsysProcess_SetPipeFile(cp, kwsysProcess_Pipe_STDIN, 0);
kwsysProcess_SetPipeFile(cp, kwsysProcess_Pipe_STDOUT, 0);
kwsysProcess_SetPipeFile(cp, kwsysProcess_Pipe_STDERR, 0);
- if (cp->CommandExitCodes) {
- free(cp->CommandExitCodes);
- }
+ free(cp->CommandExitCodes);
free(cp->ProcessResults);
free(cp);
}
@@ -497,11 +496,10 @@ int kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, const char* dir)
cp->WorkingDirectory = 0;
}
if (dir) {
- cp->WorkingDirectory = (char*)malloc(strlen(dir) + 1);
+ cp->WorkingDirectory = strdup(dir);
if (!cp->WorkingDirectory) {
return 0;
}
- strcpy(cp->WorkingDirectory, dir);
}
return 1;
}
@@ -530,11 +528,10 @@ int kwsysProcess_SetPipeFile(kwsysProcess* cp, int prPipe, const char* file)
*pfile = 0;
}
if (file) {
- *pfile = (char*)malloc(strlen(file) + 1);
+ *pfile = strdup(file);
if (!*pfile) {
return 0;
}
- strcpy(*pfile, file);
}
/* If we are redirecting the pipe, do not share it or use a native
@@ -1165,7 +1162,7 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
case KWSYSPE_PIPE_STDERR:
wd->PipeId = kwsysProcess_Pipe_STDERR;
break;
- };
+ }
return 1;
}
} else if (n < 0 && errno == EAGAIN) {
@@ -1269,21 +1266,21 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
} else if (n == 0) /* EOF */
{
/* We are done reading from this pipe. */
-#if defined(__VMS)
+# if defined(__VMS)
if (!cp->CommandsLeft)
-#endif
+# endif
{
kwsysProcessCleanupDescriptor(&cp->PipeReadEnds[i]);
--cp->PipesLeft;
}
} else if (n < 0) /* error */
{
-#if defined(__VMS)
+# if defined(__VMS)
if (!cp->CommandsLeft) {
kwsysProcessCleanupDescriptor(&cp->PipeReadEnds[i]);
--cp->PipesLeft;
} else
-#endif
+# endif
if ((errno != EINTR) && (errno != EAGAIN)) {
strncpy(cp->ErrorMessage, strerror(errno), KWSYSPE_PIPE_BUFFER_SIZE);
/* Kill the children now. */
@@ -1474,12 +1471,12 @@ static void kwsysProcessVolatileFree(volatile void* p)
/* clang has made it impossible to free memory that points to volatile
without first using special pragmas to disable a warning... */
#if defined(__clang__) && !defined(__INTEL_COMPILER)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wcast-qual"
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wcast-qual"
#endif
free((void*)p); /* The cast will silence most compilers, but not clang. */
#if defined(__clang__) && !defined(__INTEL_COMPILER)
-#pragma clang diagnostic pop
+# pragma clang diagnostic pop
#endif
}
@@ -1513,9 +1510,7 @@ static int kwsysProcessInitialize(kwsysProcess* cp)
oldForkPIDs = cp->ForkPIDs;
cp->ForkPIDs = (volatile pid_t*)malloc(sizeof(volatile pid_t) *
(size_t)(cp->NumberOfCommands));
- if (oldForkPIDs) {
- kwsysProcessVolatileFree(oldForkPIDs);
- }
+ kwsysProcessVolatileFree(oldForkPIDs);
if (!cp->ForkPIDs) {
return 0;
}
@@ -1523,9 +1518,7 @@ static int kwsysProcessInitialize(kwsysProcess* cp)
cp->ForkPIDs[i] = 0; /* can't use memset due to volatile */
}
- if (cp->CommandExitCodes) {
- free(cp->CommandExitCodes);
- }
+ free(cp->CommandExitCodes);
cp->CommandExitCodes =
(int*)malloc(sizeof(int) * (size_t)(cp->NumberOfCommands));
if (!cp->CommandExitCodes) {
@@ -1937,6 +1930,7 @@ static int kwsysProcessSetupOutputPipeFile(int* p, const char* name)
/* Set close-on-exec flag on the pipe's end. */
if (fcntl(fout, F_SETFD, FD_CLOEXEC) < 0) {
+ close(fout);
return 0;
}
@@ -2032,7 +2026,15 @@ static kwsysProcessTime kwsysProcessTimeGetCurrent(void)
{
kwsysProcessTime current;
kwsysProcessTimeNative current_native;
+#if KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC
+ struct timespec current_timespec;
+ clock_gettime(CLOCK_MONOTONIC, &current_timespec);
+
+ current_native.tv_sec = current_timespec.tv_sec;
+ current_native.tv_usec = current_timespec.tv_nsec / 1000;
+#else
gettimeofday(&current_native, 0);
+#endif
current.tv_sec = (long)current_native.tv_sec;
current.tv_usec = (long)current_native.tv_usec;
return current;
@@ -2096,11 +2098,11 @@ static void kwsysProcessSetExitExceptionByIndex(kwsysProcess* cp, int sig,
break;
#endif
#ifdef SIGBUS
-#if !defined(SIGSEGV) || SIGBUS != SIGSEGV
+# if !defined(SIGSEGV) || SIGBUS != SIGSEGV
case SIGBUS:
KWSYSPE_CASE(Fault, "Bus error");
break;
-#endif
+# endif
#endif
#ifdef SIGFPE
case SIGFPE:
@@ -2148,11 +2150,11 @@ static void kwsysProcessSetExitExceptionByIndex(kwsysProcess* cp, int sig,
break;
#endif
#ifdef SIGIOT
-#if !defined(SIGABRT) || SIGIOT != SIGABRT
+# if !defined(SIGABRT) || SIGIOT != SIGABRT
case SIGIOT:
KWSYSPE_CASE(Other, "SIGIOT");
break;
-#endif
+# endif
#endif
#ifdef SIGUSR1
case SIGUSR1:
@@ -2249,11 +2251,11 @@ static void kwsysProcessSetExitExceptionByIndex(kwsysProcess* cp, int sig,
break;
#endif
#ifdef SIGIO
-#if !defined(SIGPOLL) || SIGIO != SIGPOLL
+# if !defined(SIGPOLL) || SIGIO != SIGPOLL
case SIGIO:
KWSYSPE_CASE(Other, "SIGIO");
break;
-#endif
+# endif
#endif
#ifdef SIGPWR
case SIGPWR:
@@ -2266,11 +2268,11 @@ static void kwsysProcessSetExitExceptionByIndex(kwsysProcess* cp, int sig,
break;
#endif
#ifdef SIGUNUSED
-#if !defined(SIGSYS) || SIGUNUSED != SIGSYS
+# if !defined(SIGSYS) || SIGUNUSED != SIGSYS
case SIGUNUSED:
KWSYSPE_CASE(Other, "SIGUNUSED");
break;
-#endif
+# endif
#endif
default:
cp->ProcessResults[idx].ExitException = kwsysProcess_Exception_Other;
@@ -2289,6 +2291,7 @@ static void kwsysProcessChildErrorExit(int errorPipe)
char buffer[KWSYSPE_PIPE_BUFFER_SIZE];
kwsysProcess_ssize_t result;
strncpy(buffer, strerror(errno), KWSYSPE_PIPE_BUFFER_SIZE);
+ buffer[KWSYSPE_PIPE_BUFFER_SIZE - 1] = '\0';
/* Report the error to the parent through the special pipe. */
result = write(errorPipe, buffer, strlen(buffer));
@@ -2465,23 +2468,28 @@ static pid_t kwsysProcessFork(kwsysProcess* cp,
have two integers to store: the pid and then the ppid. */
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
defined(__OpenBSD__) || defined(__GLIBC__) || defined(__GNU__)
-#define KWSYSPE_PS_COMMAND "ps axo pid,ppid"
-#define KWSYSPE_PS_FORMAT "%d %d\n"
+# define KWSYSPE_PS_COMMAND "ps axo pid,ppid"
+# define KWSYSPE_PS_FORMAT "%d %d\n"
#elif defined(__sun) && (defined(__SVR4) || defined(__svr4__)) /* Solaris */
-#define KWSYSPE_PS_COMMAND "ps -e -o pid,ppid"
-#define KWSYSPE_PS_FORMAT "%d %d\n"
+# define KWSYSPE_PS_COMMAND "ps -e -o pid,ppid"
+# define KWSYSPE_PS_FORMAT "%d %d\n"
#elif defined(__hpux) || defined(__sun__) || defined(__sgi) || \
defined(_AIX) || defined(__sparc)
-#define KWSYSPE_PS_COMMAND "ps -ef"
-#define KWSYSPE_PS_FORMAT "%*s %d %d %*[^\n]\n"
+# define KWSYSPE_PS_COMMAND "ps -ef"
+# define KWSYSPE_PS_FORMAT "%*s %d %d %*[^\n]\n"
#elif defined(__QNX__)
-#define KWSYSPE_PS_COMMAND "ps -Af"
-#define KWSYSPE_PS_FORMAT "%*d %d %d %*[^\n]\n"
+# define KWSYSPE_PS_COMMAND "ps -Af"
+# define KWSYSPE_PS_FORMAT "%*d %d %d %*[^\n]\n"
#elif defined(__CYGWIN__)
-#define KWSYSPE_PS_COMMAND "ps aux"
-#define KWSYSPE_PS_FORMAT "%d %d %*[^\n]\n"
+# define KWSYSPE_PS_COMMAND "ps aux"
+# define KWSYSPE_PS_FORMAT "%d %d %*[^\n]\n"
#endif
+void kwsysProcess_KillPID(unsigned long process_id)
+{
+ kwsysProcessKill((pid_t)process_id);
+}
+
static void kwsysProcessKill(pid_t process_id)
{
#if defined(__linux__) || defined(__CYGWIN__)
@@ -2501,13 +2509,13 @@ static void kwsysProcessKill(pid_t process_id)
#if defined(__linux__) || defined(__CYGWIN__)
/* First try using the /proc filesystem. */
if ((procdir = opendir("/proc")) != NULL) {
-#if defined(MAXPATHLEN)
+# if defined(MAXPATHLEN)
char fname[MAXPATHLEN];
-#elif defined(PATH_MAX)
+# elif defined(PATH_MAX)
char fname[PATH_MAX];
-#else
+# else
char fname[4096];
-#endif
+# endif
char buffer[KWSYSPE_PIPE_BUFFER_SIZE + 1];
struct dirent* d;
@@ -2707,9 +2715,9 @@ static int kwsysProcessesAdd(kwsysProcess* cp)
#if KWSYSPE_USE_SIGINFO
newSigAction.sa_sigaction = kwsysProcessesSignalHandler;
newSigAction.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
-#ifdef SA_RESTART
+# ifdef SA_RESTART
newSigAction.sa_flags |= SA_RESTART;
-#endif
+# endif
#else
newSigAction.sa_handler = kwsysProcessesSignalHandler;
newSigAction.sa_flags = SA_NOCLDSTOP;
@@ -2796,7 +2804,7 @@ static void kwsysProcessesSignalHandler(int signum
,
siginfo_t* info, void* ucontext
#endif
- )
+)
{
int i, j, procStatus, old_errno = errno;
#if KWSYSPE_USE_SIGINFO
diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c
index 5183e3d2c..68c52185e 100644
--- a/Source/kwsys/ProcessWin32.c
+++ b/Source/kwsys/ProcessWin32.c
@@ -7,8 +7,8 @@
/* Work-around CMake dependency scanning limitation. This must
duplicate the above list of headers. */
#if 0
-#include "Encoding.h.in"
-#include "Process.h.in"
+# include "Encoding.h.in"
+# include "Process.h.in"
#endif
/*
@@ -22,35 +22,35 @@ a UNIX-style select system call.
*/
#ifdef _MSC_VER
-#pragma warning(push, 1)
+# pragma warning(push, 1)
#endif
#include <windows.h> /* Windows API */
#if defined(_MSC_VER) && _MSC_VER >= 1800
-#define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+# define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
#endif
#include <io.h> /* _unlink */
#include <stdio.h> /* sprintf */
#include <string.h> /* strlen, strdup */
#ifdef __WATCOMC__
-#define _unlink unlink
+# define _unlink unlink
#endif
#ifndef _MAX_FNAME
-#define _MAX_FNAME 4096
+# define _MAX_FNAME 4096
#endif
#ifndef _MAX_PATH
-#define _MAX_PATH 4096
+# define _MAX_PATH 4096
#endif
#ifdef _MSC_VER
-#pragma warning(pop)
-#pragma warning(disable : 4514)
-#pragma warning(disable : 4706)
+# pragma warning(pop)
+# pragma warning(disable : 4514)
+# pragma warning(disable : 4706)
#endif
#if defined(__BORLANDC__)
-#pragma warn - 8004 /* assigned a value that is never used */
-#pragma warn - 8060 /* Assignment inside if() condition. */
+# pragma warn - 8004 /* assigned a value that is never used */
+# pragma warn - 8060 /* Assignment inside if() condition. */
#endif
/* There are pipes for the process pipeline's stdout and stderr. */
@@ -63,14 +63,14 @@ a UNIX-style select system call.
/* Debug output macro. */
#if 0
-#define KWSYSPE_DEBUG(x) \
- ((void*)cp == (void*)0x00226DE0 \
- ? (fprintf(stderr, "%d/%p/%d ", (int)GetCurrentProcessId(), cp, \
- __LINE__), \
- fprintf x, fflush(stderr), 1) \
- : (1))
+# define KWSYSPE_DEBUG(x) \
+ ((void*)cp == (void*)0x00226DE0 \
+ ? (fprintf(stderr, "%d/%p/%d ", (int)GetCurrentProcessId(), cp, \
+ __LINE__), \
+ fprintf x, fflush(stderr), 1) \
+ : (1))
#else
-#define KWSYSPE_DEBUG(x) (void)1
+# define KWSYSPE_DEBUG(x) (void)1
#endif
typedef LARGE_INTEGER kwsysProcessTime;
@@ -117,7 +117,6 @@ static kwsysProcessTime kwsysProcessTimeAdd(kwsysProcessTime in1,
kwsysProcessTime in2);
static kwsysProcessTime kwsysProcessTimeSubtract(kwsysProcessTime in1,
kwsysProcessTime in2);
-static void kwsysProcessSetExitException(kwsysProcess* cp, int code);
static void kwsysProcessSetExitExceptionByIndex(kwsysProcess* cp, int code,
int idx);
static void kwsysProcessKillTree(int pid);
@@ -355,16 +354,23 @@ kwsysProcess* kwsysProcess_New(void)
ZeroMemory(&osv, sizeof(osv));
osv.dwOSVersionInfoSize = sizeof(osv);
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-#pragma warning(push)
-#ifdef __INTEL_COMPILER
-#pragma warning(disable : 1478)
-#else
-#pragma warning(disable : 4996)
-#endif
+# pragma warning(push)
+# ifdef __INTEL_COMPILER
+# pragma warning(disable : 1478)
+# elif defined __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wdeprecated-declarations"
+# else
+# pragma warning(disable : 4996)
+# endif
#endif
GetVersionEx(&osv);
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-#pragma warning(pop)
+# ifdef __clang__
+# pragma clang diagnostic pop
+# else
+# pragma warning(pop)
+# endif
#endif
if (osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
/* Win9x no longer supported. */
@@ -523,9 +529,7 @@ void kwsysProcess_Delete(kwsysProcess* cp)
kwsysProcess_SetPipeFile(cp, kwsysProcess_Pipe_STDIN, 0);
kwsysProcess_SetPipeFile(cp, kwsysProcess_Pipe_STDOUT, 0);
kwsysProcess_SetPipeFile(cp, kwsysProcess_Pipe_STDERR, 0);
- if (cp->CommandExitCodes) {
- free(cp->CommandExitCodes);
- }
+ free(cp->CommandExitCodes);
free(cp->ProcessResults);
free(cp);
}
@@ -713,11 +717,10 @@ int kwsysProcess_SetPipeFile(kwsysProcess* cp, int pipe, const char* file)
*pfile = 0;
}
if (file) {
- *pfile = (char*)malloc(strlen(file) + 1);
+ *pfile = strdup(file);
if (!*pfile) {
return 0;
}
- strcpy(*pfile, file);
}
/* If we are redirecting the pipe, do not share it or use a native
@@ -976,8 +979,8 @@ void kwsysProcess_Execute(kwsysProcess* cp)
wchar_t* wstdin = kwsysEncoding_DupToWide(cp->PipeFileSTDIN);
DWORD error;
cp->PipeChildStd[0] =
- CreateFileW(wstdin, GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
+ CreateFileW(wstdin, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
+ OPEN_EXISTING, 0, 0);
error = GetLastError(); /* Check now in case free changes this. */
free(wstdin);
if (cp->PipeChildStd[0] == INVALID_HANDLE_VALUE) {
@@ -1469,6 +1472,11 @@ void kwsysProcess_Kill(kwsysProcess* cp)
for them to exit. */
}
+void kwsysProcess_KillPID(unsigned long process_id)
+{
+ kwsysProcessKillTree((DWORD)process_id);
+}
+
/*
Function executed for each pipe's thread. Argument is a pointer to
the kwsysProcessPipeData instance for this thread.
@@ -1607,9 +1615,7 @@ int kwsysProcessInitialize(kwsysProcess* cp)
}
ZeroMemory(cp->ProcessInformation,
sizeof(PROCESS_INFORMATION) * cp->NumberOfCommands);
- if (cp->CommandExitCodes) {
- free(cp->CommandExitCodes);
- }
+ free(cp->CommandExitCodes);
cp->CommandExitCodes = (DWORD*)malloc(sizeof(DWORD) * cp->NumberOfCommands);
if (!cp->CommandExitCodes) {
return 0;
@@ -2266,16 +2272,23 @@ static kwsysProcess_List* kwsysProcess_List_New(void)
ZeroMemory(&osv, sizeof(osv));
osv.dwOSVersionInfoSize = sizeof(osv);
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-#pragma warning(push)
-#ifdef __INTEL_COMPILER
-#pragma warning(disable : 1478)
-#else
-#pragma warning(disable : 4996)
-#endif
+# pragma warning(push)
+# ifdef __INTEL_COMPILER
+# pragma warning(disable : 1478)
+# elif defined __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wdeprecated-declarations"
+# else
+# pragma warning(disable : 4996)
+# endif
#endif
GetVersionEx(&osv);
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-#pragma warning(pop)
+# ifdef __clang__
+# pragma clang diagnostic pop
+# else
+# pragma warning(pop)
+# endif
#endif
self->NT4 =
(osv.dwPlatformId == VER_PLATFORM_WIN32_NT && osv.dwMajorVersion < 5) ? 1
@@ -2362,9 +2375,7 @@ static int kwsysProcess_List__New_NT4(kwsysProcess_List* self)
static void kwsysProcess_List__Delete_NT4(kwsysProcess_List* self)
{
/* Free the process information buffer. */
- if (self->Buffer) {
- free(self->Buffer);
- }
+ free(self->Buffer);
}
static int kwsysProcess_List__Update_NT4(kwsysProcess_List* self)
@@ -2661,8 +2672,8 @@ static int kwsysProcessesAdd(HANDLE hProcess, DWORD dwProcessid,
newSize = kwsysProcesses.Size ? kwsysProcesses.Size * 2 : 4;
/* Try allocating the new block of memory. */
- if (newArray = (kwsysProcessInstance*)malloc(
- newSize * sizeof(kwsysProcessInstance))) {
+ if ((newArray = (kwsysProcessInstance*)malloc(
+ newSize * sizeof(kwsysProcessInstance)))) {
/* Copy the old process handles to the new memory. */
if (kwsysProcesses.Count > 0) {
memcpy(newArray, kwsysProcesses.Processes,
diff --git a/Source/kwsys/RegularExpression.cxx b/Source/kwsys/RegularExpression.cxx
index 6d7f83295..5e6f8da50 100644
--- a/Source/kwsys/RegularExpression.cxx
+++ b/Source/kwsys/RegularExpression.cxx
@@ -25,7 +25,7 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "RegularExpression.hxx.in"
+# include "RegularExpression.hxx.in"
#endif
#include <stdio.h>
@@ -37,18 +37,18 @@ namespace KWSYS_NAMESPACE {
RegularExpression::RegularExpression(const RegularExpression& rxp)
{
if (!rxp.program) {
- this->program = 0;
+ this->program = nullptr;
return;
}
int ind;
this->progsize = rxp.progsize; // Copy regular expression size
this->program = new char[this->progsize]; // Allocate storage
- for (ind = this->progsize; ind-- != 0;) // Copy regular expresion
+ for (ind = this->progsize; ind-- != 0;) // Copy regular expression
this->program[ind] = rxp.program[ind];
- this->startp[0] = rxp.startp[0]; // Copy pointers into last
- this->endp[0] = rxp.endp[0]; // Successful "find" operation
- this->regmust = rxp.regmust; // Copy field
- if (rxp.regmust != 0) {
+ // Copy pointers into last successful "find" operation
+ this->regmatch = rxp.regmatch;
+ this->regmust = rxp.regmust; // Copy field
+ if (rxp.regmust != nullptr) {
char* dum = rxp.program;
ind = 0;
while (dum != rxp.regmust) {
@@ -69,19 +69,19 @@ RegularExpression& RegularExpression::operator=(const RegularExpression& rxp)
return *this;
}
if (!rxp.program) {
- this->program = 0;
+ this->program = nullptr;
return *this;
}
int ind;
this->progsize = rxp.progsize; // Copy regular expression size
delete[] this->program;
this->program = new char[this->progsize]; // Allocate storage
- for (ind = this->progsize; ind-- != 0;) // Copy regular expresion
+ for (ind = this->progsize; ind-- != 0;) // Copy regular expression
this->program[ind] = rxp.program[ind];
- this->startp[0] = rxp.startp[0]; // Copy pointers into last
- this->endp[0] = rxp.endp[0]; // Successful "find" operation
- this->regmust = rxp.regmust; // Copy field
- if (rxp.regmust != 0) {
+ // Copy pointers into last successful "find" operation
+ this->regmatch = rxp.regmatch;
+ this->regmust = rxp.regmust; // Copy field
+ if (rxp.regmust != nullptr) {
char* dum = rxp.program;
ind = 0;
while (dum != rxp.regmust) {
@@ -123,12 +123,13 @@ bool RegularExpression::deep_equal(const RegularExpression& rxp) const
while (ind-- != 0) // Else while still characters
if (this->program[ind] != rxp.program[ind]) // If regexp are different
return false; // Return failure
- return (this->startp[0] == rxp.startp[0] && // Else if same start/end ptrs,
- this->endp[0] == rxp.endp[0]); // Return true
+ // Else if same start/end ptrs, return true
+ return (this->regmatch.start() == rxp.regmatch.start() &&
+ this->regmatch.end() == rxp.regmatch.end());
}
-// The remaining code in this file is derived from the regular expression code
-// whose copyright statement appears below. It has been changed to work
+// The remaining code in this file is derived from the regular expression code
+// whose copyright statement appears below. It has been changed to work
// with the class concepts of C++ and COOL.
/*
@@ -163,8 +164,8 @@ bool RegularExpression::deep_equal(const RegularExpression& rxp) const
*
* regstart char that must begin a match; '\0' if none obvious
* reganch is the match anchored (at beginning-of-line only)?
- * regmust string (pointer into program) that match must include, or NULL
- * regmlen length of regmust string
+ * regmust string (pointer into program) that match must include, or
+ * nullptr regmlen length of regmust string
*
* Regstart and reganch permit very fast decisions on suitable starting points
* for a match, cutting down the work a lot. Regmust permits fast rejection
@@ -193,24 +194,29 @@ bool RegularExpression::deep_equal(const RegularExpression& rxp) const
*/
// definition number opnd? meaning
-#define END 0 // no End of program.
-#define BOL 1 // no Match "" at beginning of line.
-#define EOL 2 // no Match "" at end of line.
-#define ANY 3 // no Match any one character.
-#define ANYOF 4 // str Match any character in this string.
-#define ANYBUT 5 // str Match any character not in this
- // string.
-#define BRANCH 6 // node Match this alternative, or the
+#define END 0 // no End of program.
+#define BOL 1 // no Match "" at beginning of line.
+#define EOL 2 // no Match "" at end of line.
+#define ANY 3 // no Match any one character.
+#define ANYOF 4 // str Match any character in this string.
+#define ANYBUT \
+ 5 // str Match any character not in this
+ // string.
+#define BRANCH \
+ 6 // node Match this alternative, or the
// next...
#define BACK 7 // no Match "", "next" ptr points backward.
#define EXACTLY 8 // str Match this string.
#define NOTHING 9 // no Match empty string.
-#define STAR 10 // node Match this (simple) thing 0 or more
- // times.
-#define PLUS 11 // node Match this (simple) thing 1 or more
- // times.
-#define OPEN 20 // no Mark this point in input as start of
- // #n.
+#define STAR \
+ 10 // node Match this (simple) thing 0 or more
+ // times.
+#define PLUS \
+ 11 // node Match this (simple) thing 1 or more
+ // times.
+#define OPEN \
+ 20 // no Mark this point in input as start of
+ // #n.
// OPEN+1 is number 1, etc.
#define CLOSE 30 // no Analogous to OPEN.
@@ -258,11 +264,6 @@ const unsigned char MAGIC = 0234;
#define UCHARAT(p) (reinterpret_cast<const unsigned char*>(p))[0]
-#define FAIL(m) \
- { \
- regerror(m); \
- return (0); \
- }
#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?')
#define META "^$.[()|?+*\\"
@@ -281,31 +282,35 @@ const unsigned char MAGIC = 0234;
/////////////////////////////////////////////////////////////////////////
/*
- * Global work variables for compile().
+ * Read only utility variables.
*/
-static const char* regparse; // Input-scan pointer.
-static int regnpar; // () count.
static char regdummy;
-static char* regcode; // Code-emit pointer; &regdummy = don't.
-static long regsize; // Code size.
+static char* const regdummyptr = &regdummy;
/*
- * Forward declarations for compile()'s friends.
+ * Utility class for RegularExpression::compile().
*/
-// #ifndef static
-// #define static static
-// #endif
-static char* reg(int, int*);
-static char* regbranch(int*);
-static char* regpiece(int*);
-static char* regatom(int*);
-static char* regnode(char);
+class RegExpCompile
+{
+public:
+ const char* regparse; // Input-scan pointer.
+ int regnpar; // () count.
+ char* regcode; // Code-emit pointer; regdummyptr = don't.
+ long regsize; // Code size.
+
+ char* reg(int, int*);
+ char* regbranch(int*);
+ char* regpiece(int*);
+ char* regatom(int*);
+ char* regnode(char);
+ void regc(char);
+ void reginsert(char, char*);
+ static void regtail(char*, const char*);
+ static void regoptail(char*, const char*);
+};
+
static const char* regnext(const char*);
static char* regnext(char*);
-static void regc(char);
-static void reginsert(char, char*);
-static void regtail(char*, const char*);
-static void regoptail(char*, const char*);
#ifdef STRCSPN
static int strcspn();
@@ -332,29 +337,29 @@ bool RegularExpression::compile(const char* exp)
{
const char* scan;
const char* longest;
- size_t len;
int flags;
- if (exp == 0) {
+ if (exp == nullptr) {
// RAISE Error, SYM(RegularExpression), SYM(No_Expr),
printf("RegularExpression::compile(): No expression supplied.\n");
return false;
}
// First pass: determine size, legality.
- regparse = exp;
- regnpar = 1;
- regsize = 0L;
- regcode = &regdummy;
- regc(static_cast<char>(MAGIC));
- if (!reg(0, &flags)) {
+ RegExpCompile comp;
+ comp.regparse = exp;
+ comp.regnpar = 1;
+ comp.regsize = 0L;
+ comp.regcode = regdummyptr;
+ comp.regc(static_cast<char>(MAGIC));
+ if (!comp.reg(0, &flags)) {
printf("RegularExpression::compile(): Error in compile.\n");
return false;
}
- this->startp[0] = this->endp[0] = this->searchstring = 0;
+ this->regmatch.clear();
// Small enough for pointer-storage convention?
- if (regsize >= 32767L) { // Probably could be 65535L.
+ if (comp.regsize >= 32767L) { // Probably could be 65535L.
// RAISE Error, SYM(RegularExpression), SYM(Expr_Too_Big),
printf("RegularExpression::compile(): Expression too big.\n");
return false;
@@ -362,29 +367,29 @@ bool RegularExpression::compile(const char* exp)
// Allocate space.
//#ifndef _WIN32
- if (this->program != 0)
+ if (this->program != nullptr)
delete[] this->program;
//#endif
- this->program = new char[regsize];
- this->progsize = static_cast<int>(regsize);
+ this->program = new char[comp.regsize];
+ this->progsize = static_cast<int>(comp.regsize);
- if (this->program == 0) {
+ if (this->program == nullptr) {
// RAISE Error, SYM(RegularExpression), SYM(Out_Of_Memory),
printf("RegularExpression::compile(): Out of memory.\n");
return false;
}
// Second pass: emit code.
- regparse = exp;
- regnpar = 1;
- regcode = this->program;
- regc(static_cast<char>(MAGIC));
- reg(0, &flags);
+ comp.regparse = exp;
+ comp.regnpar = 1;
+ comp.regcode = this->program;
+ comp.regc(static_cast<char>(MAGIC));
+ comp.reg(0, &flags);
// Dig out information for optimizations.
this->regstart = '\0'; // Worst-case defaults.
this->reganch = 0;
- this->regmust = 0;
+ this->regmust = nullptr;
this->regmlen = 0;
scan = this->program + 1; // First BRANCH.
if (OP(regnext(scan)) == END) { // Only one top-level choice.
@@ -405,9 +410,9 @@ bool RegularExpression::compile(const char* exp)
// absence of others.
//
if (flags & SPSTART) {
- longest = 0;
- len = 0;
- for (; scan != 0; scan = regnext(scan))
+ longest = nullptr;
+ size_t len = 0;
+ for (; scan != nullptr; scan = regnext(scan))
if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) {
longest = OPERAND(scan);
len = strlen(OPERAND(scan));
@@ -428,7 +433,7 @@ bool RegularExpression::compile(const char* exp)
* is a trifle forced, but the need to tie the tails of the branches to what
* follows makes it hard to avoid.
*/
-static char* reg(int paren, int* flagp)
+char* RegExpCompile::reg(int paren, int* flagp)
{
char* ret;
char* br;
@@ -440,22 +445,22 @@ static char* reg(int paren, int* flagp)
// Make an OPEN node, if parenthesized.
if (paren) {
- if (regnpar >= RegularExpression::NSUBEXP) {
+ if (regnpar >= RegularExpressionMatch::NSUBEXP) {
// RAISE Error, SYM(RegularExpression), SYM(Too_Many_Parens),
printf("RegularExpression::compile(): Too many parentheses.\n");
- return 0;
+ return nullptr;
}
parno = regnpar;
regnpar++;
ret = regnode(static_cast<char>(OPEN + parno));
} else
- ret = 0;
+ ret = nullptr;
// Pick up the branches, linking them together.
br = regbranch(&flags);
- if (br == 0)
- return (0);
- if (ret != 0)
+ if (br == nullptr)
+ return (nullptr);
+ if (ret != nullptr)
regtail(ret, br); // OPEN -> first.
else
ret = br;
@@ -465,8 +470,8 @@ static char* reg(int paren, int* flagp)
while (*regparse == '|') {
regparse++;
br = regbranch(&flags);
- if (br == 0)
- return (0);
+ if (br == nullptr)
+ return (nullptr);
regtail(ret, br); // BRANCH -> BRANCH.
if (!(flags & HASWIDTH))
*flagp &= ~HASWIDTH;
@@ -478,23 +483,23 @@ static char* reg(int paren, int* flagp)
regtail(ret, ender);
// Hook the tails of the branches to the closing node.
- for (br = ret; br != 0; br = regnext(br))
+ for (br = ret; br != nullptr; br = regnext(br))
regoptail(br, ender);
// Check for proper termination.
if (paren && *regparse++ != ')') {
// RAISE Error, SYM(RegularExpression), SYM(Unmatched_Parens),
printf("RegularExpression::compile(): Unmatched parentheses.\n");
- return 0;
+ return nullptr;
} else if (!paren && *regparse != '\0') {
if (*regparse == ')') {
// RAISE Error, SYM(RegularExpression), SYM(Unmatched_Parens),
printf("RegularExpression::compile(): Unmatched parentheses.\n");
- return 0;
+ return nullptr;
} else {
// RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
printf("RegularExpression::compile(): Internal error.\n");
- return 0;
+ return nullptr;
}
// NOTREACHED
}
@@ -506,7 +511,7 @@ static char* reg(int paren, int* flagp)
*
* Implements the concatenation operator.
*/
-static char* regbranch(int* flagp)
+char* RegExpCompile::regbranch(int* flagp)
{
char* ret;
char* chain;
@@ -516,19 +521,19 @@ static char* regbranch(int* flagp)
*flagp = WORST; // Tentatively.
ret = regnode(BRANCH);
- chain = 0;
+ chain = nullptr;
while (*regparse != '\0' && *regparse != '|' && *regparse != ')') {
latest = regpiece(&flags);
- if (latest == 0)
- return (0);
+ if (latest == nullptr)
+ return (nullptr);
*flagp |= flags & HASWIDTH;
- if (chain == 0) // First piece.
+ if (chain == nullptr) // First piece.
*flagp |= flags & SPSTART;
else
regtail(chain, latest);
chain = latest;
}
- if (chain == 0) // Loop ran zero times.
+ if (chain == nullptr) // Loop ran zero times.
regnode(NOTHING);
return (ret);
@@ -543,7 +548,7 @@ static char* regbranch(int* flagp)
* It might seem that this node could be dispensed with entirely, but the
* endmarker role is not redundant.
*/
-static char* regpiece(int* flagp)
+char* RegExpCompile::regpiece(int* flagp)
{
char* ret;
char op;
@@ -551,8 +556,8 @@ static char* regpiece(int* flagp)
int flags;
ret = regatom(&flags);
- if (ret == 0)
- return (0);
+ if (ret == nullptr)
+ return (nullptr);
op = *regparse;
if (!ISMULT(op)) {
@@ -563,7 +568,7 @@ static char* regpiece(int* flagp)
if (!(flags & HASWIDTH) && op != '?') {
// RAISE Error, SYM(RegularExpression), SYM(Empty_Operand),
printf("RegularExpression::compile() : *+ operand could be empty.\n");
- return 0;
+ return nullptr;
}
*flagp = (op != '+') ? (WORST | SPSTART) : (WORST | HASWIDTH);
@@ -597,7 +602,7 @@ static char* regpiece(int* flagp)
if (ISMULT(*regparse)) {
// RAISE Error, SYM(RegularExpression), SYM(Nested_Operand),
printf("RegularExpression::compile(): Nested *?+.\n");
- return 0;
+ return nullptr;
}
return (ret);
}
@@ -610,7 +615,7 @@ static char* regpiece(int* flagp)
* faster to run. Backslashed characters are exceptions, each becoming a
* separate node; the code is simpler that way and it's not worth fixing.
*/
-static char* regatom(int* flagp)
+char* RegExpCompile::regatom(int* flagp)
{
char* ret;
int flags;
@@ -650,7 +655,7 @@ static char* regatom(int* flagp)
if (rxpclass > rxpclassend + 1) {
// RAISE Error, SYM(RegularExpression), SYM(Invalid_Range),
printf("RegularExpression::compile(): Invalid range in [].\n");
- return 0;
+ return nullptr;
}
for (; rxpclass <= rxpclassend; rxpclass++)
regc(static_cast<char>(rxpclass));
@@ -663,15 +668,15 @@ static char* regatom(int* flagp)
if (*regparse != ']') {
// RAISE Error, SYM(RegularExpression), SYM(Unmatched_Bracket),
printf("RegularExpression::compile(): Unmatched [].\n");
- return 0;
+ return nullptr;
}
regparse++;
*flagp |= HASWIDTH | SIMPLE;
} break;
case '(':
ret = reg(1, &flags);
- if (ret == 0)
- return (0);
+ if (ret == nullptr)
+ return (nullptr);
*flagp |= flags & (HASWIDTH | SPSTART);
break;
case '\0':
@@ -679,18 +684,18 @@ static char* regatom(int* flagp)
case ')':
// RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
printf("RegularExpression::compile(): Internal error.\n"); // Never here
- return 0;
+ return nullptr;
case '?':
case '+':
case '*':
// RAISE Error, SYM(RegularExpression), SYM(No_Operand),
printf("RegularExpression::compile(): ?+* follows nothing.\n");
- return 0;
+ return nullptr;
case '\\':
if (*regparse == '\0') {
// RAISE Error, SYM(RegularExpression), SYM(Trailing_Backslash),
printf("RegularExpression::compile(): Trailing backslash.\n");
- return 0;
+ return nullptr;
}
ret = regnode(EXACTLY);
regc(*regparse++);
@@ -706,7 +711,7 @@ static char* regatom(int* flagp)
if (len <= 0) {
// RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
printf("RegularExpression::compile(): Internal error.\n");
- return 0;
+ return nullptr;
}
ender = *(regparse + len);
if (len > 1 && ISMULT(ender))
@@ -729,13 +734,13 @@ static char* regatom(int* flagp)
- regnode - emit a node
Location.
*/
-static char* regnode(char op)
+char* RegExpCompile::regnode(char op)
{
char* ret;
char* ptr;
ret = regcode;
- if (ret == &regdummy) {
+ if (ret == regdummyptr) {
regsize += 3;
return (ret);
}
@@ -752,9 +757,9 @@ static char* regnode(char op)
/*
- regc - emit (if appropriate) a byte of code
*/
-static void regc(char b)
+void RegExpCompile::regc(char b)
{
- if (regcode != &regdummy)
+ if (regcode != regdummyptr)
*regcode++ = b;
else
regsize++;
@@ -765,13 +770,13 @@ static void regc(char b)
*
* Means relocating the operand.
*/
-static void reginsert(char op, char* opnd)
+void RegExpCompile::reginsert(char op, char* opnd)
{
char* src;
char* dst;
char* place;
- if (regcode == &regdummy) {
+ if (regcode == regdummyptr) {
regsize += 3;
return;
}
@@ -791,20 +796,20 @@ static void reginsert(char op, char* opnd)
/*
- regtail - set the next-pointer at the end of a node chain
*/
-static void regtail(char* p, const char* val)
+void RegExpCompile::regtail(char* p, const char* val)
{
char* scan;
char* temp;
int offset;
- if (p == &regdummy)
+ if (p == regdummyptr)
return;
// Find last node.
scan = p;
for (;;) {
temp = regnext(scan);
- if (temp == 0)
+ if (temp == nullptr)
break;
scan = temp;
}
@@ -820,10 +825,10 @@ static void regtail(char* p, const char* val)
/*
- regoptail - regtail on operand of first argument; nop if operandless
*/
-static void regoptail(char* p, const char* val)
+void RegExpCompile::regoptail(char* p, const char* val)
{
// "Operandless" and "op != BRANCH" are synonymous in practice.
- if (p == 0 || p == &regdummy || OP(p) != BRANCH)
+ if (p == nullptr || p == regdummyptr || OP(p) != BRANCH)
return;
regtail(OPERAND(p), val);
}
@@ -835,34 +840,30 @@ static void regoptail(char* p, const char* val)
////////////////////////////////////////////////////////////////////////
/*
- * Global work variables for find().
+ * Utility class for RegularExpression::find().
*/
-static const char* reginput; // String-input pointer.
-static const char* regbol; // Beginning of input, for ^ check.
-static const char** regstartp; // Pointer to startp array.
-static const char** regendp; // Ditto for endp.
+class RegExpFind
+{
+public:
+ const char* reginput; // String-input pointer.
+ const char* regbol; // Beginning of input, for ^ check.
+ const char** regstartp; // Pointer to startp array.
+ const char** regendp; // Ditto for endp.
-/*
- * Forwards.
- */
-static int regtry(const char*, const char**, const char**, const char*);
-static int regmatch(const char*);
-static int regrepeat(const char*);
-
-#ifdef DEBUG
-int regnarrate = 0;
-void regdump();
-static char* regprop();
-#endif
+ int regtry(const char*, const char**, const char**, const char*);
+ int regmatch(const char*);
+ int regrepeat(const char*);
+};
// find -- Matches the regular expression to the given string.
// Returns true if found, and sets start and end indexes accordingly.
-
-bool RegularExpression::find(const char* string)
+bool RegularExpression::find(char const* string,
+ RegularExpressionMatch& rmatch) const
{
const char* s;
- this->searchstring = string;
+ rmatch.clear();
+ rmatch.searchstring = string;
if (!this->program) {
return false;
@@ -873,54 +874,57 @@ bool RegularExpression::find(const char* string)
// RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
printf(
"RegularExpression::find(): Compiled regular expression corrupted.\n");
- return 0;
+ return false;
}
// If there is a "must appear" string, look for it.
- if (this->regmust != 0) {
+ if (this->regmust != nullptr) {
s = string;
- while ((s = strchr(s, this->regmust[0])) != 0) {
+ while ((s = strchr(s, this->regmust[0])) != nullptr) {
if (strncmp(s, this->regmust, this->regmlen) == 0)
break; // Found it.
s++;
}
- if (s == 0) // Not present.
- return (0);
+ if (s == nullptr) // Not present.
+ return false;
}
+ RegExpFind regFind;
+
// Mark beginning of line for ^ .
- regbol = string;
+ regFind.regbol = string;
// Simplest case: anchored match need be tried only once.
if (this->reganch)
- return (regtry(string, this->startp, this->endp, this->program) != 0);
+ return (
+ regFind.regtry(string, rmatch.startp, rmatch.endp, this->program) != 0);
// Messy cases: unanchored match.
s = string;
if (this->regstart != '\0')
// We know what char it must start with.
- while ((s = strchr(s, this->regstart)) != 0) {
- if (regtry(s, this->startp, this->endp, this->program))
- return (1);
+ while ((s = strchr(s, this->regstart)) != nullptr) {
+ if (regFind.regtry(s, rmatch.startp, rmatch.endp, this->program))
+ return true;
s++;
}
else
// We don't -- general case.
do {
- if (regtry(s, this->startp, this->endp, this->program))
- return (1);
+ if (regFind.regtry(s, rmatch.startp, rmatch.endp, this->program))
+ return true;
} while (*s++ != '\0');
// Failure.
- return (0);
+ return false;
}
/*
- regtry - try match at specific point
0 failure, 1 success
*/
-static int regtry(const char* string, const char** start, const char** end,
- const char* prog)
+int RegExpFind::regtry(const char* string, const char** start,
+ const char** end, const char* prog)
{
int i;
const char** sp1;
@@ -932,9 +936,9 @@ static int regtry(const char* string, const char** start, const char** end,
sp1 = start;
ep = end;
- for (i = RegularExpression::NSUBEXP; i > 0; i--) {
- *sp1++ = 0;
- *ep++ = 0;
+ for (i = RegularExpressionMatch::NSUBEXP; i > 0; i--) {
+ *sp1++ = nullptr;
+ *ep++ = nullptr;
}
if (regmatch(prog + 1)) {
start[0] = string;
@@ -955,14 +959,14 @@ static int regtry(const char* string, const char** start, const char** end,
* by recursion.
* 0 failure, 1 success
*/
-static int regmatch(const char* prog)
+int RegExpFind::regmatch(const char* prog)
{
const char* scan; // Current node.
const char* next; // Next node.
scan = prog;
- while (scan != 0) {
+ while (scan != nullptr) {
next = regnext(scan);
@@ -994,12 +998,12 @@ static int regmatch(const char* prog)
reginput += len;
} break;
case ANYOF:
- if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == 0)
+ if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == nullptr)
return (0);
reginput++;
break;
case ANYBUT:
- if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != 0)
+ if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != nullptr)
return (0);
reginput++;
break;
@@ -1028,7 +1032,7 @@ static int regmatch(const char* prog)
// Don't set startp if some later invocation of the
// same parentheses already has.
//
- if (regstartp[no] == 0)
+ if (regstartp[no] == nullptr)
regstartp[no] = save;
return (1);
} else
@@ -1056,7 +1060,7 @@ static int regmatch(const char* prog)
// Don't set endp if some later invocation of the
// same parentheses already has.
//
- if (regendp[no] == 0)
+ if (regendp[no] == nullptr)
regendp[no] = save;
return (1);
} else
@@ -1076,7 +1080,7 @@ static int regmatch(const char* prog)
return (1);
reginput = save;
scan = regnext(scan);
- } while (scan != 0 && OP(scan) == BRANCH);
+ } while (scan != nullptr && OP(scan) == BRANCH);
return (0);
// NOTREACHED
}
@@ -1134,7 +1138,7 @@ static int regmatch(const char* prog)
/*
- regrepeat - repeatedly match something simple, report how many
*/
-static int regrepeat(const char* p)
+int RegExpFind::regrepeat(const char* p)
{
int count = 0;
const char* scan;
@@ -1154,13 +1158,13 @@ static int regrepeat(const char* p)
}
break;
case ANYOF:
- while (*scan != '\0' && strchr(opnd, *scan) != 0) {
+ while (*scan != '\0' && strchr(opnd, *scan) != nullptr) {
count++;
scan++;
}
break;
case ANYBUT:
- while (*scan != '\0' && strchr(opnd, *scan) == 0) {
+ while (*scan != '\0' && strchr(opnd, *scan) == nullptr) {
count++;
scan++;
}
@@ -1181,12 +1185,12 @@ static const char* regnext(const char* p)
{
int offset;
- if (p == &regdummy)
- return (0);
+ if (p == regdummyptr)
+ return (nullptr);
offset = NEXT(p);
if (offset == 0)
- return (0);
+ return (nullptr);
if (OP(p) == BACK)
return (p - offset);
@@ -1198,12 +1202,12 @@ static char* regnext(char* p)
{
int offset;
- if (p == &regdummy)
- return (0);
+ if (p == regdummyptr)
+ return (nullptr);
offset = NEXT(p);
if (offset == 0)
- return (0);
+ return (nullptr);
if (OP(p) == BACK)
return (p - offset);
diff --git a/Source/kwsys/RegularExpression.hxx.in b/Source/kwsys/RegularExpression.hxx.in
index 606e3da6e..df7eb4558 100644
--- a/Source/kwsys/RegularExpression.hxx.in
+++ b/Source/kwsys/RegularExpression.hxx.in
@@ -29,11 +29,121 @@
/* Disable useless Borland warnings. KWSys tries not to force things
on its includers, but there is no choice here. */
#if defined(__BORLANDC__)
-#pragma warn - 8027 /* function not inlined. */
+# pragma warn - 8027 /* function not inlined. */
#endif
namespace @KWSYS_NAMESPACE@ {
+// Forward declaration
+class RegularExpression;
+
+/** \class RegularExpressionMatch
+ * \brief Stores the pattern matches of a RegularExpression
+ */
+class @KWSYS_NAMESPACE@_EXPORT RegularExpressionMatch
+{
+public:
+ RegularExpressionMatch();
+
+ bool isValid() const;
+ void clear();
+
+ std::string::size_type start() const;
+ std::string::size_type end() const;
+ std::string::size_type start(int n) const;
+ std::string::size_type end(int n) const;
+ std::string match(int n) const;
+
+ enum
+ {
+ NSUBEXP = 10
+ };
+
+private:
+ friend class RegularExpression;
+ const char* startp[NSUBEXP];
+ const char* endp[NSUBEXP];
+ const char* searchstring;
+};
+
+/**
+ * \brief Creates an invalid match object
+ */
+inline RegularExpressionMatch::RegularExpressionMatch()
+{
+ startp[0] = nullptr;
+ endp[0] = nullptr;
+ searchstring = nullptr;
+}
+
+/**
+ * \brief Returns true if the match pointers are valid
+ */
+inline bool RegularExpressionMatch::isValid() const
+{
+ return (this->startp[0] != nullptr);
+}
+
+/**
+ * \brief Resets to the (invalid) construction state.
+ */
+inline void RegularExpressionMatch::clear()
+{
+ startp[0] = nullptr;
+ endp[0] = nullptr;
+ searchstring = nullptr;
+}
+
+/**
+ * \brief Returns the start index of the full match.
+ */
+inline std::string::size_type RegularExpressionMatch::start() const
+{
+ return static_cast<std::string::size_type>(this->startp[0] - searchstring);
+}
+
+/**
+ * \brief Returns the end index of the full match.
+ */
+inline std::string::size_type RegularExpressionMatch::end() const
+{
+ return static_cast<std::string::size_type>(this->endp[0] - searchstring);
+}
+
+/**
+ * \brief Returns the start index of nth submatch.
+ * start(0) is the start of the full match.
+ */
+inline std::string::size_type RegularExpressionMatch::start(int n) const
+{
+ return static_cast<std::string::size_type>(this->startp[n] -
+ this->searchstring);
+}
+
+/**
+ * \brief Returns the end index of nth submatch.
+ * end(0) is the end of the full match.
+ */
+inline std::string::size_type RegularExpressionMatch::end(int n) const
+{
+ return static_cast<std::string::size_type>(this->endp[n] -
+ this->searchstring);
+}
+
+/**
+ * \brief Returns the nth submatch as a string.
+ */
+inline std::string RegularExpressionMatch::match(int n) const
+{
+ if (this->startp[n] == nullptr) {
+ return std::string();
+ } else {
+ return std::string(
+ this->startp[n],
+ static_cast<std::string::size_type>(this->endp[n] - this->startp[n]));
+ }
+}
+
/** \class RegularExpression
* \brief Implements pattern matching with regular expressions.
*
@@ -93,7 +203,7 @@ namespace @KWSYS_NAMESPACE@ {
*
* ? Matches preceding pattern zero or once only
*
- * () Saves a matched expression and uses it in a later match
+ * () Saves a matched expression and uses it in a later match
*
* Note that more than one of these metacharacters can be used
* in a single regular expression in order to create complex
@@ -109,21 +219,22 @@ namespace @KWSYS_NAMESPACE@ {
* object as an argument and creates an object initialized with the
* information from the given RegularExpression object.
*
- * The find member function finds the first occurence of the regualr
+ * The find member function finds the first occurrence of the regular
* expression of that object in the string given to find as an argument. Find
* returns a boolean, and if true, mutates the private data appropriately.
* Find sets pointers to the beginning and end of the thing last found, they
* are pointers into the actual string that was searched. The start and end
- * member functions return indicies into the searched string that correspond
+ * member functions return indices into the searched string that correspond
* to the beginning and end pointers respectively. The compile member
* function takes a char* and puts the compiled version of the char* argument
* into the object's private data fields. The == and != operators only check
* the to see if the compiled regular expression is the same, and the
* deep_equal functions also checks to see if the start and end pointers are
- * the same. The is_valid function returns false if program is set to NULL,
- * (i.e. there is no valid compiled exression). The set_invalid function sets
- * the program to NULL (Warning: this deletes the compiled expression). The
- * following examples may help clarify regular expression usage:
+ * the same. The is_valid function returns false if program is set to
+ * nullptr, (i.e. there is no valid compiled expression). The set_invalid
+ * function sets the program to nullptr (Warning: this deletes the compiled
+ * expression). The following examples may help clarify regular expression
+ * usage:
*
* * The regular expression "^hello" matches a "hello" only at the
* beginning of a line. It would match "hello there" but not "hi,
@@ -161,21 +272,24 @@ namespace @KWSYS_NAMESPACE@ {
*
* * The regular expression "(..p)b" matches something ending with pb
* and beginning with whatever the two characters before the first p
- * encounterd in the line were. It would find "repb" in "rep drepa
+ * encountered in the line were. It would find "repb" in "rep drepa
* qrepb". The regular expression "(..p)a" would find "repa qrepb"
* in "rep drepa qrepb"
*
* * The regular expression "d(..p)" matches something ending with p,
* beginning with d, and having two characters in between that are
- * the same as the two characters before the first p encounterd in
+ * the same as the two characters before the first p encountered in
* the line. It would match "drepa qrepb" in "rep drepa qrepb".
*
+ * All methods of RegularExpression can be called simultaneously from
+ * different threads but only if each invocation uses an own instance of
+ * RegularExpression.
*/
class @KWSYS_NAMESPACE@_EXPORT RegularExpression
{
public:
/**
- * Instantiate RegularExpression with program=NULL.
+ * Instantiate RegularExpression with program=nullptr.
*/
inline RegularExpression();
@@ -213,9 +327,19 @@ public:
/**
* Matches the regular expression to the given string.
+ * Returns true if found, and sets start and end indexes
+ * in the RegularExpressionMatch instance accordingly.
+ *
+ * This method is thread safe when called with different
+ * RegularExpressionMatch instances.
+ */
+ bool find(char const*, RegularExpressionMatch&) const;
+
+ /**
+ * Matches the regular expression to the given string.
* Returns true if found, and sets start and end indexes accordingly.
*/
- bool find(char const*);
+ inline bool find(char const*);
/**
* Matches the regular expression to the given std string.
@@ -224,14 +348,18 @@ public:
inline bool find(std::string const&);
/**
- * Index to start of first find.
+ * Match indices
*/
+ inline RegularExpressionMatch const& regMatch() const;
inline std::string::size_type start() const;
+ inline std::string::size_type end() const;
+ inline std::string::size_type start(int n) const;
+ inline std::string::size_type end(int n) const;
/**
- * Index to end of first find.
+ * Match strings
*/
- inline std::string::size_type end() const;
+ inline std::string match(int n) const;
/**
* Copy the given regular expression.
@@ -266,37 +394,26 @@ public:
*/
inline void set_invalid();
- /**
- * Destructor.
- */
- // awf added
- std::string::size_type start(int n) const;
- std::string::size_type end(int n) const;
- std::string match(int n) const;
-
- enum
- {
- NSUBEXP = 10
- };
-
private:
- const char* startp[NSUBEXP];
- const char* endp[NSUBEXP];
+ RegularExpressionMatch regmatch;
char regstart; // Internal use only
char reganch; // Internal use only
const char* regmust; // Internal use only
std::string::size_type regmlen; // Internal use only
char* program;
int progsize;
- const char* searchstring;
};
/**
* Create an empty regular expression.
*/
inline RegularExpression::RegularExpression()
+ : regstart{}
+ , reganch{}
+ , regmust{}
+ , program{ nullptr }
+ , progsize{}
{
- this->program = 0;
}
/**
@@ -304,8 +421,12 @@ inline RegularExpression::RegularExpression()
* compiles s.
*/
inline RegularExpression::RegularExpression(const char* s)
+ : regstart{}
+ , reganch{}
+ , regmust{}
+ , program{ nullptr }
+ , progsize{}
{
- this->program = 0;
if (s) {
this->compile(s);
}
@@ -316,8 +437,12 @@ inline RegularExpression::RegularExpression(const char* s)
* compiles s.
*/
inline RegularExpression::RegularExpression(const std::string& s)
+ : regstart{}
+ , reganch{}
+ , regmust{}
+ , program{ nullptr }
+ , progsize{}
{
- this->program = 0;
this->compile(s);
}
@@ -344,51 +469,42 @@ inline bool RegularExpression::compile(std::string const& s)
* Matches the regular expression to the given std string.
* Returns true if found, and sets start and end indexes accordingly.
*/
-inline bool RegularExpression::find(std::string const& s)
+inline bool RegularExpression::find(const char* s)
{
- return this->find(s.c_str());
+ return this->find(s, this->regmatch);
}
/**
- * Set the start position for the regular expression.
+ * Matches the regular expression to the given std string.
+ * Returns true if found, and sets start and end indexes accordingly.
*/
-inline std::string::size_type RegularExpression::start() const
+inline bool RegularExpression::find(std::string const& s)
{
- return static_cast<std::string::size_type>(this->startp[0] - searchstring);
+ return this->find(s.c_str());
}
/**
- * Returns the start/end index of the last item found.
+ * Returns the internal match object
*/
-inline std::string::size_type RegularExpression::end() const
+inline RegularExpressionMatch const& RegularExpression::regMatch() const
{
- return static_cast<std::string::size_type>(this->endp[0] - searchstring);
+ return this->regmatch;
}
/**
- * Returns true if two regular expressions have different
- * compiled program for pattern matching.
+ * Returns the start index of the full match.
*/
-inline bool RegularExpression::operator!=(const RegularExpression& r) const
+inline std::string::size_type RegularExpression::start() const
{
- return (!(*this == r));
+ return regmatch.start();
}
/**
- * Returns true if a valid regular expression is compiled
- * and ready for pattern matching.
+ * Returns the end index of the full match.
*/
-inline bool RegularExpression::is_valid() const
+inline std::string::size_type RegularExpression::end() const
{
- return (this->program != 0);
-}
-
-inline void RegularExpression::set_invalid()
-{
- //#ifndef _WIN32
- delete[] this->program;
- //#endif
- this->program = 0;
+ return regmatch.end();
}
/**
@@ -396,7 +512,7 @@ inline void RegularExpression::set_invalid()
*/
inline std::string::size_type RegularExpression::start(int n) const
{
- return static_cast<std::string::size_type>(this->startp[n] - searchstring);
+ return regmatch.start(n);
}
/**
@@ -404,7 +520,7 @@ inline std::string::size_type RegularExpression::start(int n) const
*/
inline std::string::size_type RegularExpression::end(int n) const
{
- return static_cast<std::string::size_type>(this->endp[n] - searchstring);
+ return regmatch.end(n);
}
/**
@@ -412,12 +528,33 @@ inline std::string::size_type RegularExpression::end(int n) const
*/
inline std::string RegularExpression::match(int n) const
{
- if (this->startp[n] == 0) {
- return std::string("");
- } else {
- return std::string(this->startp[n], static_cast<std::string::size_type>(
- this->endp[n] - this->startp[n]));
- }
+ return regmatch.match(n);
+}
+
+/**
+ * Returns true if two regular expressions have different
+ * compiled program for pattern matching.
+ */
+inline bool RegularExpression::operator!=(const RegularExpression& r) const
+{
+ return (!(*this == r));
+}
+
+/**
+ * Returns true if a valid regular expression is compiled
+ * and ready for pattern matching.
+ */
+inline bool RegularExpression::is_valid() const
+{
+ return (this->program != nullptr);
+}
+
+inline void RegularExpression::set_invalid()
+{
+ //#ifndef _WIN32
+ delete[] this->program;
+ //#endif
+ this->program = nullptr;
}
} // namespace @KWSYS_NAMESPACE@
diff --git a/Source/kwsys/SharedForward.h.in b/Source/kwsys/SharedForward.h.in
index f638267ec..5716cd4f1 100644
--- a/Source/kwsys/SharedForward.h.in
+++ b/Source/kwsys/SharedForward.h.in
@@ -1,7 +1,7 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#ifndef @KWSYS_NAMESPACE@_SharedForward_h
-#define @KWSYS_NAMESPACE@_SharedForward_h
+# define @KWSYS_NAMESPACE@_SharedForward_h
/*
This header is used to create a forwarding executable sets up the
@@ -59,134 +59,134 @@
/* Disable -Wcast-qual warnings since they are too hard to fix in a
cross-platform way. */
-#if defined(__clang__) && defined(__has_warning)
-#if __has_warning("-Wcast-qual")
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wcast-qual"
-#endif
-#endif
-
-#if defined(__BORLANDC__) && !defined(__cplusplus)
+# if defined(__clang__) && defined(__has_warning)
+# if __has_warning("-Wcast-qual")
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wcast-qual"
+# endif
+# endif
+
+# if defined(__BORLANDC__) && !defined(__cplusplus)
/* Code has no effect; raised by winnt.h in C (not C++) when ignoring an
unused parameter using "(param)" syntax (i.e. no cast to void). */
-#pragma warn - 8019
-#endif
+# pragma warn - 8019
+# endif
/* Full path to the directory in which this executable is built. Do
not include a trailing slash. */
-#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD)
-#error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD"
-#endif
-#if !defined(KWSYS_SHARED_FORWARD_DIR_BUILD)
-#define KWSYS_SHARED_FORWARD_DIR_BUILD \
- @KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD
-#endif
+# if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD)
+# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD"
+# endif
+# if !defined(KWSYS_SHARED_FORWARD_DIR_BUILD)
+# define KWSYS_SHARED_FORWARD_DIR_BUILD \
+ @KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD
+# endif
/* Library search path for build tree. */
-#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD)
-#error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD"
-#endif
-#if !defined(KWSYS_SHARED_FORWARD_PATH_BUILD)
-#define KWSYS_SHARED_FORWARD_PATH_BUILD \
- @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD
-#endif
+# if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD)
+# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD"
+# endif
+# if !defined(KWSYS_SHARED_FORWARD_PATH_BUILD)
+# define KWSYS_SHARED_FORWARD_PATH_BUILD \
+ @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD
+# endif
/* Library search path for install tree. */
-#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL)
-#error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL"
-#endif
-#if !defined(KWSYS_SHARED_FORWARD_PATH_INSTALL)
-#define KWSYS_SHARED_FORWARD_PATH_INSTALL \
- @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL
-#endif
+# if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL)
+# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL"
+# endif
+# if !defined(KWSYS_SHARED_FORWARD_PATH_INSTALL)
+# define KWSYS_SHARED_FORWARD_PATH_INSTALL \
+ @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_INSTALL
+# endif
/* The real executable to which to forward in the build tree. */
-#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD)
-#error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD"
-#endif
-#if !defined(KWSYS_SHARED_FORWARD_EXE_BUILD)
-#define KWSYS_SHARED_FORWARD_EXE_BUILD \
- @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD
-#endif
+# if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD)
+# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD"
+# endif
+# if !defined(KWSYS_SHARED_FORWARD_EXE_BUILD)
+# define KWSYS_SHARED_FORWARD_EXE_BUILD \
+ @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_BUILD
+# endif
/* The real executable to which to forward in the install tree. */
-#if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL)
-#error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL"
-#endif
-#if !defined(KWSYS_SHARED_FORWARD_EXE_INSTALL)
-#define KWSYS_SHARED_FORWARD_EXE_INSTALL \
- @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL
-#endif
+# if !defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL)
+# error "Must define @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL"
+# endif
+# if !defined(KWSYS_SHARED_FORWARD_EXE_INSTALL)
+# define KWSYS_SHARED_FORWARD_EXE_INSTALL \
+ @KWSYS_NAMESPACE@_SHARED_FORWARD_EXE_INSTALL
+# endif
/* The configuration name with which this executable was built (Debug/Release).
*/
-#if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_CONFIG_NAME)
-#define KWSYS_SHARED_FORWARD_CONFIG_NAME \
- @KWSYS_NAMESPACE@_SHARED_FORWARD_CONFIG_NAME
-#else
-#undef KWSYS_SHARED_FORWARD_CONFIG_NAME
-#endif
+# if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_CONFIG_NAME)
+# define KWSYS_SHARED_FORWARD_CONFIG_NAME \
+ @KWSYS_NAMESPACE@_SHARED_FORWARD_CONFIG_NAME
+# else
+# undef KWSYS_SHARED_FORWARD_CONFIG_NAME
+# endif
/* Create command line option to replace executable. */
-#if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_COMMAND)
-#if !defined(KWSYS_SHARED_FORWARD_OPTION_COMMAND)
-#define KWSYS_SHARED_FORWARD_OPTION_COMMAND \
- @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_COMMAND
-#endif
-#else
-#undef KWSYS_SHARED_FORWARD_OPTION_COMMAND
-#endif
+# if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_COMMAND)
+# if !defined(KWSYS_SHARED_FORWARD_OPTION_COMMAND)
+# define KWSYS_SHARED_FORWARD_OPTION_COMMAND \
+ @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_COMMAND
+# endif
+# else
+# undef KWSYS_SHARED_FORWARD_OPTION_COMMAND
+# endif
/* Create command line option to print environment setting and exit. */
-#if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_PRINT)
-#if !defined(KWSYS_SHARED_FORWARD_OPTION_PRINT)
-#define KWSYS_SHARED_FORWARD_OPTION_PRINT \
- @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_PRINT
-#endif
-#else
-#undef KWSYS_SHARED_FORWARD_OPTION_PRINT
-#endif
+# if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_PRINT)
+# if !defined(KWSYS_SHARED_FORWARD_OPTION_PRINT)
+# define KWSYS_SHARED_FORWARD_OPTION_PRINT \
+ @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_PRINT
+# endif
+# else
+# undef KWSYS_SHARED_FORWARD_OPTION_PRINT
+# endif
/* Create command line option to run ldd or equivalent. */
-#if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_LDD)
-#if !defined(KWSYS_SHARED_FORWARD_OPTION_LDD)
-#define KWSYS_SHARED_FORWARD_OPTION_LDD \
- @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_LDD
-#endif
-#else
-#undef KWSYS_SHARED_FORWARD_OPTION_LDD
-#endif
+# if defined(@KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_LDD)
+# if !defined(KWSYS_SHARED_FORWARD_OPTION_LDD)
+# define KWSYS_SHARED_FORWARD_OPTION_LDD \
+ @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_LDD
+# endif
+# else
+# undef KWSYS_SHARED_FORWARD_OPTION_LDD
+# endif
/* Include needed system headers. */
-#include <errno.h>
-#include <limits.h>
-#include <stddef.h> /* size_t */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+# include <errno.h>
+# include <limits.h>
+# include <stddef.h> /* size_t */
+# include <stdio.h>
+# include <stdlib.h>
+# include <string.h>
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#include <windows.h>
+# if defined(_WIN32) && !defined(__CYGWIN__)
+# include <windows.h>
-#include <io.h>
-#include <process.h>
-#define KWSYS_SHARED_FORWARD_ESCAPE_ARGV /* re-escape argv for execvp */
-#else
-#include <sys/stat.h>
-#include <unistd.h>
-#endif
+# include <io.h>
+# include <process.h>
+# define KWSYS_SHARED_FORWARD_ESCAPE_ARGV /* re-escape argv for execvp */
+# else
+# include <sys/stat.h>
+# include <unistd.h>
+# endif
/* Configuration for this platform. */
/* The path separator for this platform. */
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#define KWSYS_SHARED_FORWARD_PATH_SEP ';'
-#define KWSYS_SHARED_FORWARD_PATH_SLASH '\\'
-#else
-#define KWSYS_SHARED_FORWARD_PATH_SEP ':'
-#define KWSYS_SHARED_FORWARD_PATH_SLASH '/'
-#endif
+# if defined(_WIN32) && !defined(__CYGWIN__)
+# define KWSYS_SHARED_FORWARD_PATH_SEP ';'
+# define KWSYS_SHARED_FORWARD_PATH_SLASH '\\'
+# else
+# define KWSYS_SHARED_FORWARD_PATH_SEP ':'
+# define KWSYS_SHARED_FORWARD_PATH_SLASH '/'
+# endif
static const char kwsys_shared_forward_path_sep[2] = {
KWSYS_SHARED_FORWARD_PATH_SEP, 0
};
@@ -195,99 +195,101 @@ static const char kwsys_shared_forward_path_slash[2] = {
};
/* The maximum length of a file name. */
-#if defined(PATH_MAX)
-#define KWSYS_SHARED_FORWARD_MAXPATH PATH_MAX
-#elif defined(MAXPATHLEN)
-#define KWSYS_SHARED_FORWARD_MAXPATH MAXPATHLEN
-#else
-#define KWSYS_SHARED_FORWARD_MAXPATH 16384
-#endif
+# if defined(PATH_MAX)
+# define KWSYS_SHARED_FORWARD_MAXPATH PATH_MAX
+# elif defined(MAXPATHLEN)
+# define KWSYS_SHARED_FORWARD_MAXPATH MAXPATHLEN
+# else
+# define KWSYS_SHARED_FORWARD_MAXPATH 16384
+# endif
/* Select the environment variable holding the shared library runtime
search path for this platform and build configuration. Also select
ldd command equivalent. */
/* Linux */
-#if defined(__linux)
-#define KWSYS_SHARED_FORWARD_LDD "ldd"
-#define KWSYS_SHARED_FORWARD_LDD_N 1
-#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
+# if defined(__linux)
+# define KWSYS_SHARED_FORWARD_LDD "ldd"
+# define KWSYS_SHARED_FORWARD_LDD_N 1
+# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
/* FreeBSD */
-#elif defined(__FreeBSD__)
-#define KWSYS_SHARED_FORWARD_LDD "ldd"
-#define KWSYS_SHARED_FORWARD_LDD_N 1
-#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
+# elif defined(__FreeBSD__)
+# define KWSYS_SHARED_FORWARD_LDD "ldd"
+# define KWSYS_SHARED_FORWARD_LDD_N 1
+# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
/* OpenBSD */
-#elif defined(__OpenBSD__)
-#define KWSYS_SHARED_FORWARD_LDD "ldd"
-#define KWSYS_SHARED_FORWARD_LDD_N 1
-#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
+# elif defined(__OpenBSD__)
+# define KWSYS_SHARED_FORWARD_LDD "ldd"
+# define KWSYS_SHARED_FORWARD_LDD_N 1
+# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
-/* OSX */
-#elif defined(__APPLE__)
-#define KWSYS_SHARED_FORWARD_LDD "otool", "-L"
-#define KWSYS_SHARED_FORWARD_LDD_N 2
-#define KWSYS_SHARED_FORWARD_LDPATH "DYLD_LIBRARY_PATH"
+/* OS X */
+# elif defined(__APPLE__)
+# define KWSYS_SHARED_FORWARD_LDD "otool", "-L"
+# define KWSYS_SHARED_FORWARD_LDD_N 2
+# define KWSYS_SHARED_FORWARD_LDPATH "DYLD_LIBRARY_PATH"
/* AIX */
-#elif defined(_AIX)
-#define KWSYS_SHARED_FORWARD_LDD "dump", "-H"
-#define KWSYS_SHARED_FORWARD_LDD_N 2
-#define KWSYS_SHARED_FORWARD_LDPATH "LIBPATH"
+# elif defined(_AIX)
+# define KWSYS_SHARED_FORWARD_LDD "dump", "-H"
+# define KWSYS_SHARED_FORWARD_LDD_N 2
+# define KWSYS_SHARED_FORWARD_LDPATH "LIBPATH"
/* SUN */
-#elif defined(__sun)
-#define KWSYS_SHARED_FORWARD_LDD "ldd"
-#define KWSYS_SHARED_FORWARD_LDD_N 1
-#include <sys/isa_defs.h>
-#if defined(_ILP32)
-#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
-#elif defined(_LP64)
-#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH_64"
-#endif
+# elif defined(__sun)
+# define KWSYS_SHARED_FORWARD_LDD "ldd"
+# define KWSYS_SHARED_FORWARD_LDD_N 1
+# include <sys/isa_defs.h>
+# if defined(_ILP32)
+# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
+# elif defined(_LP64)
+# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH_64"
+# endif
/* HP-UX */
-#elif defined(__hpux)
-#define KWSYS_SHARED_FORWARD_LDD "chatr"
-#define KWSYS_SHARED_FORWARD_LDD_N 1
-#if defined(__LP64__)
-#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
-#else
-#define KWSYS_SHARED_FORWARD_LDPATH "SHLIB_PATH"
-#endif
+# elif defined(__hpux)
+# define KWSYS_SHARED_FORWARD_LDD "chatr"
+# define KWSYS_SHARED_FORWARD_LDD_N 1
+# if defined(__LP64__)
+# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
+# else
+# define KWSYS_SHARED_FORWARD_LDPATH "SHLIB_PATH"
+# endif
/* SGI MIPS */
-#elif defined(__sgi) && defined(_MIPS_SIM)
-#define KWSYS_SHARED_FORWARD_LDD "ldd"
-#define KWSYS_SHARED_FORWARD_LDD_N 1
-#if _MIPS_SIM == _ABIO32
-#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
-#elif _MIPS_SIM == _ABIN32
-#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARYN32_PATH"
-#elif _MIPS_SIM == _ABI64
-#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY64_PATH"
-#endif
+# elif defined(__sgi) && defined(_MIPS_SIM)
+# define KWSYS_SHARED_FORWARD_LDD "ldd"
+# define KWSYS_SHARED_FORWARD_LDD_N 1
+# if _MIPS_SIM == _ABIO32
+# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
+# elif _MIPS_SIM == _ABIN32
+# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARYN32_PATH"
+# elif _MIPS_SIM == _ABI64
+# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY64_PATH"
+# endif
/* Cygwin */
-#elif defined(__CYGWIN__)
-#define KWSYS_SHARED_FORWARD_LDD "cygcheck" /* TODO: cygwin 1.7 has ldd */
-#define KWSYS_SHARED_FORWARD_LDD_N 1
-#define KWSYS_SHARED_FORWARD_LDPATH "PATH"
+# elif defined(__CYGWIN__)
+# define KWSYS_SHARED_FORWARD_LDD \
+ "cygcheck" /* TODO: cygwin 1.7 has ldd \
+ */
+# define KWSYS_SHARED_FORWARD_LDD_N 1
+# define KWSYS_SHARED_FORWARD_LDPATH "PATH"
/* Windows */
-#elif defined(_WIN32)
-#define KWSYS_SHARED_FORWARD_LDPATH "PATH"
+# elif defined(_WIN32)
+# define KWSYS_SHARED_FORWARD_LDPATH "PATH"
/* Guess on this unknown system. */
-#else
-#define KWSYS_SHARED_FORWARD_LDD "ldd"
-#define KWSYS_SHARED_FORWARD_LDD_N 1
-#define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
-#endif
+# else
+# define KWSYS_SHARED_FORWARD_LDD "ldd"
+# define KWSYS_SHARED_FORWARD_LDD_N 1
+# define KWSYS_SHARED_FORWARD_LDPATH "LD_LIBRARY_PATH"
+# endif
-#ifdef KWSYS_SHARED_FORWARD_ESCAPE_ARGV
+# ifdef KWSYS_SHARED_FORWARD_ESCAPE_ARGV
typedef struct kwsys_sf_arg_info_s
{
const char* arg;
@@ -404,25 +406,25 @@ static char* kwsys_sf_get_arg(kwsys_sf_arg_info info, char* out)
return out;
}
-#endif
+# endif
/* Function to convert a logical or relative path to a physical full path. */
static int kwsys_shared_forward_realpath(const char* in_path, char* out_path)
{
-#if defined(_WIN32) && !defined(__CYGWIN__)
+# if defined(_WIN32) && !defined(__CYGWIN__)
/* Implementation for Windows. */
DWORD n =
GetFullPathNameA(in_path, KWSYS_SHARED_FORWARD_MAXPATH, out_path, 0);
return n > 0 && n <= KWSYS_SHARED_FORWARD_MAXPATH;
-#else
+# else
/* Implementation for UNIX. */
return realpath(in_path, out_path) != 0;
-#endif
+# endif
}
static int kwsys_shared_forward_samepath(const char* file1, const char* file2)
{
-#if defined(_WIN32)
+# if defined(_WIN32)
int result = 0;
HANDLE h1 = CreateFileA(file1, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
@@ -440,19 +442,19 @@ static int kwsys_shared_forward_samepath(const char* file1, const char* file2)
CloseHandle(h1);
CloseHandle(h2);
return result;
-#else
+# else
struct stat fs1, fs2;
return (stat(file1, &fs1) == 0 && stat(file2, &fs2) == 0 &&
memcmp(&fs2.st_dev, &fs1.st_dev, sizeof(fs1.st_dev)) == 0 &&
memcmp(&fs2.st_ino, &fs1.st_ino, sizeof(fs1.st_ino)) == 0 &&
fs2.st_size == fs1.st_size);
-#endif
+# endif
}
/* Function to report a system error message. */
static void kwsys_shared_forward_strerror(char* message)
{
-#if defined(_WIN32) && !defined(__CYGWIN__)
+# if defined(_WIN32) && !defined(__CYGWIN__)
/* Implementation for Windows. */
DWORD original = GetLastError();
DWORD length =
@@ -465,17 +467,17 @@ static void kwsys_shared_forward_strerror(char* message)
"Error 0x%X (FormatMessage failed with error 0x%X)", original,
GetLastError());
}
-#else
+# else
/* Implementation for UNIX. */
strcpy(message, strerror(errno));
-#endif
+# endif
}
/* Functions to execute a child process. */
static void kwsys_shared_forward_execvp(const char* cmd,
char const* const* argv)
{
-#ifdef KWSYS_SHARED_FORWARD_ESCAPE_ARGV
+# ifdef KWSYS_SHARED_FORWARD_ESCAPE_ARGV
/* Count the number of arguments. */
int argc = 0;
{
@@ -498,16 +500,16 @@ static void kwsys_shared_forward_execvp(const char* cmd,
/* Replace the command line to be used. */
argv = (char const* const*)nargv;
}
-#endif
+# endif
/* Invoke the child process. */
-#if defined(_MSC_VER)
+# if defined(_MSC_VER)
_execvp(cmd, argv);
-#elif defined(__MINGW32__) && !defined(__MINGW64__)
+# elif defined(__MINGW32__) && !defined(__MINGW64__)
execvp(cmd, argv);
-#else
+# else
execvp(cmd, (char* const*)argv);
-#endif
+# endif
}
/* Function to get the directory containing the given file or directory. */
@@ -530,14 +532,14 @@ static void kwsys_shared_forward_dirname(const char* begin, char* result)
/* Only one leading slash. */
strcpy(result, kwsys_shared_forward_path_slash);
}
-#if defined(_WIN32)
+# if defined(_WIN32)
else if (last_slash_index == 2 && begin[1] == ':') {
/* Only one leading drive letter and slash. */
strncpy(result, begin, (size_t)last_slash_index);
result[last_slash_index] = KWSYS_SHARED_FORWARD_PATH_SLASH;
result[last_slash_index + 1] = 0;
}
-#endif
+# endif
else {
/* A non-leading slash. */
strncpy(result, begin, (size_t)last_slash_index);
@@ -548,16 +550,16 @@ static void kwsys_shared_forward_dirname(const char* begin, char* result)
/* Function to check if a file exists and is executable. */
static int kwsys_shared_forward_is_executable(const char* f)
{
-#if defined(_MSC_VER)
-#define KWSYS_SHARED_FORWARD_ACCESS _access
-#else
-#define KWSYS_SHARED_FORWARD_ACCESS access
-#endif
-#if defined(X_OK)
-#define KWSYS_SHARED_FORWARD_ACCESS_OK X_OK
-#else
-#define KWSYS_SHARED_FORWARD_ACCESS_OK 04
-#endif
+# if defined(_MSC_VER)
+# define KWSYS_SHARED_FORWARD_ACCESS _access
+# else
+# define KWSYS_SHARED_FORWARD_ACCESS access
+# endif
+# if defined(X_OK)
+# define KWSYS_SHARED_FORWARD_ACCESS_OK X_OK
+# else
+# define KWSYS_SHARED_FORWARD_ACCESS_OK 04
+# endif
if (KWSYS_SHARED_FORWARD_ACCESS(f, KWSYS_SHARED_FORWARD_ACCESS_OK) == 0) {
return 1;
} else {
@@ -641,12 +643,12 @@ static int kwsys_shared_forward_fullpath(const char* self_path,
/* Already a full path. */
strcpy(result, in_path);
}
-#if defined(_WIN32)
+# if defined(_WIN32)
else if (in_path[0] && in_path[1] == ':') {
/* Already a full path. */
strcpy(result, in_path);
}
-#endif
+# endif
else {
/* Relative to self path. */
char temp_path[KWSYS_SHARED_FORWARD_MAXPATH];
@@ -683,14 +685,14 @@ static int kwsys_shared_forward_get_settings(const char* self_path,
const char* exe_path;
/* Get the real name of the build and self paths. */
-#if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME)
+# if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME)
char build_path[] =
KWSYS_SHARED_FORWARD_DIR_BUILD "/" KWSYS_SHARED_FORWARD_CONFIG_NAME;
char self_path_logical[KWSYS_SHARED_FORWARD_MAXPATH];
-#else
+# else
char build_path[] = KWSYS_SHARED_FORWARD_DIR_BUILD;
const char* self_path_logical = self_path;
-#endif
+# endif
char build_path_real[KWSYS_SHARED_FORWARD_MAXPATH];
char self_path_real[KWSYS_SHARED_FORWARD_MAXPATH];
if (!kwsys_shared_forward_realpath(self_path, self_path_real)) {
@@ -706,29 +708,29 @@ static int kwsys_shared_forward_get_settings(const char* self_path,
kwsys_shared_forward_samepath(self_path_real, build_path_real)) {
/* Running in build tree. Use the build path and exe. */
search_path = search_path_build;
-#if defined(_WIN32)
+# if defined(_WIN32)
exe_path = KWSYS_SHARED_FORWARD_EXE_BUILD ".exe";
-#else
+# else
exe_path = KWSYS_SHARED_FORWARD_EXE_BUILD;
-#endif
+# endif
-#if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME)
+# if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME)
/* Remove the configuration directory from self_path. */
kwsys_shared_forward_dirname(self_path, self_path_logical);
-#endif
+# endif
} else {
/* Running in install tree. Use the install path and exe. */
search_path = search_path_install;
-#if defined(_WIN32)
+# if defined(_WIN32)
exe_path = KWSYS_SHARED_FORWARD_EXE_INSTALL ".exe";
-#else
+# else
exe_path = KWSYS_SHARED_FORWARD_EXE_INSTALL;
-#endif
+# endif
-#if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME)
+# if defined(KWSYS_SHARED_FORWARD_CONFIG_NAME)
/* Use the original self path directory. */
strcpy(self_path_logical, self_path);
-#endif
+# endif
}
/* Construct the runtime search path. */
@@ -795,7 +797,7 @@ static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in)
/* Store the environment variable. */
putenv(kwsys_shared_forward_ldpath);
-#if defined(KWSYS_SHARED_FORWARD_OPTION_COMMAND)
+# if defined(KWSYS_SHARED_FORWARD_OPTION_COMMAND)
/* Look for the command line replacement option. */
if (argc > 1 &&
strcmp(argv[1], KWSYS_SHARED_FORWARD_OPTION_COMMAND) == 0) {
@@ -806,14 +808,15 @@ static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in)
argc -= 2;
} else {
/* The option was not given an executable. */
- fprintf(stderr, "Option " KWSYS_SHARED_FORWARD_OPTION_COMMAND
- " must be followed by a command line.\n");
+ fprintf(stderr,
+ "Option " KWSYS_SHARED_FORWARD_OPTION_COMMAND
+ " must be followed by a command line.\n");
return 1;
}
}
-#endif
+# endif
-#if defined(KWSYS_SHARED_FORWARD_OPTION_PRINT)
+# if defined(KWSYS_SHARED_FORWARD_OPTION_PRINT)
/* Look for the print command line option. */
if (argc > 1 &&
strcmp(argv[1], KWSYS_SHARED_FORWARD_OPTION_PRINT) == 0) {
@@ -821,12 +824,12 @@ static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in)
fprintf(stdout, "%s\n", exe);
return 0;
}
-#endif
+# endif
-#if defined(KWSYS_SHARED_FORWARD_OPTION_LDD)
+# if defined(KWSYS_SHARED_FORWARD_OPTION_LDD)
/* Look for the ldd command line option. */
if (argc > 1 && strcmp(argv[1], KWSYS_SHARED_FORWARD_OPTION_LDD) == 0) {
-#if defined(KWSYS_SHARED_FORWARD_LDD)
+# if defined(KWSYS_SHARED_FORWARD_LDD)
/* Use the named ldd-like executable and arguments. */
char const* ldd_argv[] = { KWSYS_SHARED_FORWARD_LDD, 0, 0 };
ldd_argv[KWSYS_SHARED_FORWARD_LDD_N] = exe;
@@ -835,13 +838,13 @@ static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in)
/* Report why execution failed. */
kwsys_shared_forward_print_failure(ldd_argv);
return 1;
-#else
+# else
/* We have no ldd-like executable available on this platform. */
fprintf(stderr, "No ldd-like tool is known to this executable.\n");
return 1;
-#endif
+# endif
}
-#endif
+# endif
/* Replace this process with the real executable. */
argv[0] = exe;
@@ -865,12 +868,12 @@ static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in)
}
/* Restore warning stack. */
-#if defined(__clang__) && defined(__has_warning)
-#if __has_warning("-Wcast-qual")
-#pragma clang diagnostic pop
-#endif
-#endif
+# if defined(__clang__) && defined(__has_warning)
+# if __has_warning("-Wcast-qual")
+# pragma clang diagnostic pop
+# endif
+# endif
#else
-#error "@KWSYS_NAMESPACE@/SharedForward.h should be included only once."
+# error "@KWSYS_NAMESPACE@/SharedForward.h should be included only once."
#endif
diff --git a/Source/kwsys/String.c b/Source/kwsys/String.c
index 048222968..daf7ad1a0 100644
--- a/Source/kwsys/String.c
+++ b/Source/kwsys/String.c
@@ -8,23 +8,23 @@ directory that use the stl string cause the compiler to load this
source to try to get the definition of the string template. This
condition blocks the compiler from seeing the symbols defined here.
*/
-#include "kwsysPrivate.h"
-#include KWSYS_HEADER(String.h)
+# include "kwsysPrivate.h"
+# include KWSYS_HEADER(String.h)
/* Work-around CMake dependency scanning limitation. This must
duplicate the above list of headers. */
-#if 0
-#include "String.h.in"
-#endif
+# if 0
+# include "String.h.in"
+# endif
/* Select an implementation for strcasecmp. */
-#if defined(_MSC_VER)
-#define KWSYS_STRING_USE_STRICMP
-#include <string.h>
-#elif defined(__GNUC__)
-#define KWSYS_STRING_USE_STRCASECMP
-#include <strings.h>
-#else
+# if defined(_MSC_VER)
+# define KWSYS_STRING_USE_STRICMP
+# include <string.h>
+# elif defined(__GNUC__)
+# define KWSYS_STRING_USE_STRCASECMP
+# include <strings.h>
+# else
/* Table to convert upper case letters to lower case and leave all
other characters alone. */
static char kwsysString_strcasecmp_tolower[] = {
@@ -58,16 +58,16 @@ static char kwsysString_strcasecmp_tolower[] = {
'\363', '\364', '\365', '\366', '\367', '\370', '\371', '\372', '\373',
'\374', '\375', '\376', '\377'
};
-#endif
+# endif
/*--------------------------------------------------------------------------*/
int kwsysString_strcasecmp(const char* lhs, const char* rhs)
{
-#if defined(KWSYS_STRING_USE_STRICMP)
+# if defined(KWSYS_STRING_USE_STRICMP)
return _stricmp(lhs, rhs);
-#elif defined(KWSYS_STRING_USE_STRCASECMP)
+# elif defined(KWSYS_STRING_USE_STRCASECMP)
return strcasecmp(lhs, rhs);
-#else
+# else
const char* const lower = kwsysString_strcasecmp_tolower;
unsigned char const* us1 = (unsigned char const*)lhs;
unsigned char const* us2 = (unsigned char const*)rhs;
@@ -75,17 +75,17 @@ int kwsysString_strcasecmp(const char* lhs, const char* rhs)
while ((result = lower[*us1] - lower[*us2++], result == 0) && *us1++) {
}
return result;
-#endif
+# endif
}
/*--------------------------------------------------------------------------*/
int kwsysString_strncasecmp(const char* lhs, const char* rhs, size_t n)
{
-#if defined(KWSYS_STRING_USE_STRICMP)
+# if defined(KWSYS_STRING_USE_STRICMP)
return _strnicmp(lhs, rhs, n);
-#elif defined(KWSYS_STRING_USE_STRCASECMP)
+# elif defined(KWSYS_STRING_USE_STRCASECMP)
return strncasecmp(lhs, rhs, n);
-#else
+# else
const char* const lower = kwsysString_strcasecmp_tolower;
unsigned char const* us1 = (unsigned char const*)lhs;
unsigned char const* us2 = (unsigned char const*)rhs;
@@ -94,7 +94,7 @@ int kwsysString_strncasecmp(const char* lhs, const char* rhs, size_t n)
--n;
}
return result;
-#endif
+# endif
}
#endif /* KWSYS_STRING_C */
diff --git a/Source/kwsys/String.h.in b/Source/kwsys/String.h.in
index 3c1d571c0..7c9348af1 100644
--- a/Source/kwsys/String.h.in
+++ b/Source/kwsys/String.h.in
@@ -12,12 +12,12 @@
not visible to user code. Use kwsysHeaderDump.pl to reproduce
these macros after making changes to the interface. */
#if !defined(KWSYS_NAMESPACE)
-#define kwsys_ns(x) @KWSYS_NAMESPACE@##x
-#define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
+# define kwsys_ns(x) @KWSYS_NAMESPACE@##x
+# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#define kwsysString_strcasecmp kwsys_ns(String_strcasecmp)
-#define kwsysString_strncasecmp kwsys_ns(String_strncasecmp)
+# define kwsysString_strcasecmp kwsys_ns(String_strcasecmp)
+# define kwsysString_strncasecmp kwsys_ns(String_strncasecmp)
#endif
#if defined(__cplusplus)
@@ -46,12 +46,12 @@ kwsysEXPORT int kwsysString_strncasecmp(const char* lhs, const char* rhs,
/* If we are building a kwsys .c or .cxx file, let it use these macros.
Otherwise, undefine them to keep the namespace clean. */
#if !defined(KWSYS_NAMESPACE)
-#undef kwsys_ns
-#undef kwsysEXPORT
-#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#undef kwsysString_strcasecmp
-#undef kwsysString_strncasecmp
-#endif
+# undef kwsys_ns
+# undef kwsysEXPORT
+# if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
+# undef kwsysString_strcasecmp
+# undef kwsysString_strncasecmp
+# endif
#endif
#endif
diff --git a/Source/kwsys/System.c b/Source/kwsys/System.c
index b9af8e9d9..d43cc6fbb 100644
--- a/Source/kwsys/System.c
+++ b/Source/kwsys/System.c
@@ -6,7 +6,7 @@
/* Work-around CMake dependency scanning limitation. This must
duplicate the above list of headers. */
#if 0
-#include "System.h.in"
+# include "System.h.in"
#endif
#include <ctype.h> /* isspace */
diff --git a/Source/kwsys/System.h.in b/Source/kwsys/System.h.in
index 102974db7..a9d4f5e69 100644
--- a/Source/kwsys/System.h.in
+++ b/Source/kwsys/System.h.in
@@ -10,11 +10,12 @@
not visible to user code. Use kwsysHeaderDump.pl to reproduce
these macros after making changes to the interface. */
#if !defined(KWSYS_NAMESPACE)
-#define kwsys_ns(x) @KWSYS_NAMESPACE@##x
-#define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
+# define kwsys_ns(x) @KWSYS_NAMESPACE@##x
+# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#define kwsysSystem_Parse_CommandForUnix kwsys_ns(System_Parse_CommandForUnix)
+# define kwsysSystem_Parse_CommandForUnix \
+ kwsys_ns(System_Parse_CommandForUnix)
#endif
#if defined(__cplusplus)
@@ -49,11 +50,11 @@ kwsysEXPORT char** kwsysSystem_Parse_CommandForUnix(const char* command,
/* If we are building a kwsys .c or .cxx file, let it use these macros.
Otherwise, undefine them to keep the namespace clean. */
#if !defined(KWSYS_NAMESPACE)
-#undef kwsys_ns
-#undef kwsysEXPORT
-#if !defined(KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#undef kwsysSystem_Parse_CommandForUnix
-#endif
+# undef kwsys_ns
+# undef kwsysEXPORT
+# if !defined(KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
+# undef kwsysSystem_Parse_CommandForUnix
+# endif
#endif
#endif
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index 86fdccdc7..6ec6e48ff 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -1,15 +1,18 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#if defined(_WIN32)
-#define NOMINMAX // use our min,max
-#if !defined(_WIN32_WINNT) && !(defined(_MSC_VER) && _MSC_VER < 1300)
-#define _WIN32_WINNT 0x0501
-#endif
-#include <winsock.h> // WSADATA, include before sys/types.h
+# define NOMINMAX // use our min,max
+# if !defined(_WIN32_WINNT) && defined(_MSC_VER) && _MSC_VER >= 1800
+# define _WIN32_WINNT 0x0600 // vista
+# endif
+# if !defined(_WIN32_WINNT) && !(defined(_MSC_VER) && _MSC_VER < 1300)
+# define _WIN32_WINNT 0x0501
+# endif
+# include <winsock.h> // WSADATA, include before sys/types.h
#endif
#if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
-#define _GNU_SOURCE
+# define _GNU_SOURCE
#endif
// TODO:
@@ -31,8 +34,8 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "Process.h.in"
-#include "SystemInformation.hxx.in"
+# include "Process.h.in"
+# include "SystemInformation.hxx.in"
#endif
#include <algorithm>
@@ -47,114 +50,117 @@
#include <vector>
#if defined(_WIN32)
-#include <windows.h>
-#if defined(_MSC_VER) && _MSC_VER >= 1800
-#define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-#endif
-#include <errno.h>
-#if defined(KWSYS_SYS_HAS_PSAPI)
-#include <psapi.h>
-#endif
-#if !defined(siginfo_t)
+# include <windows.h>
+# if defined(_MSC_VER) && _MSC_VER >= 1800
+# define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+# endif
+# include <errno.h>
+# if defined(KWSYS_SYS_HAS_PSAPI)
+# include <psapi.h>
+# endif
+# if !defined(siginfo_t)
typedef int siginfo_t;
-#endif
+# endif
#else
-#include <sys/types.h>
-
-#include <errno.h> // extern int errno;
-#include <fcntl.h>
-#include <signal.h>
-#include <sys/resource.h> // getrlimit
-#include <sys/time.h>
-#include <sys/utsname.h> // int uname(struct utsname *buf);
-#include <unistd.h>
+# include <sys/types.h>
+
+# include <errno.h> // extern int errno;
+# include <fcntl.h>
+# include <signal.h>
+# include <sys/resource.h> // getrlimit
+# include <sys/time.h>
+# include <sys/utsname.h> // int uname(struct utsname *buf);
+# include <unistd.h>
#endif
#if defined(__CYGWIN__) && !defined(_WIN32)
-#include <windows.h>
-#undef _WIN32
+# include <windows.h>
+# undef _WIN32
#endif
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__DragonFly__)
-#include <netdb.h>
-#include <netinet/in.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/sysctl.h>
-#if defined(KWSYS_SYS_HAS_IFADDRS_H)
-#include <ifaddrs.h>
-#include <net/if.h>
-#define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN
-#endif
+# include <netdb.h>
+# include <netinet/in.h>
+# include <sys/param.h>
+# include <sys/socket.h>
+# include <sys/sysctl.h>
+# if defined(KWSYS_SYS_HAS_IFADDRS_H)
+# include <ifaddrs.h>
+# include <net/if.h>
+# define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN
+# endif
#endif
#if defined(KWSYS_SYS_HAS_MACHINE_CPU_H)
-#include <machine/cpu.h>
+# include <machine/cpu.h>
#endif
#ifdef __APPLE__
-#include <fenv.h>
-#include <mach/host_info.h>
-#include <mach/mach.h>
-#include <mach/mach_types.h>
-#include <mach/vm_statistics.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <sys/sysctl.h>
-#if defined(KWSYS_SYS_HAS_IFADDRS_H)
-#include <ifaddrs.h>
-#include <net/if.h>
-#define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN
-#endif
-#if !(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - 0 >= 1050)
-#undef KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE
-#endif
-#endif
-
-#if defined(__linux) || defined(__sun) || defined(_SCO_DS)
-#include <fenv.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#if defined(KWSYS_SYS_HAS_IFADDRS_H)
-#include <ifaddrs.h>
-#include <net/if.h>
-#if !defined(__LSB_VERSION__) /* LSB has no getifaddrs */
-#define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN
-#endif
-#endif
-#if defined(KWSYS_CXX_HAS_RLIMIT64)
+# include <mach/host_info.h>
+# include <mach/mach.h>
+# include <mach/mach_types.h>
+# include <mach/vm_statistics.h>
+# include <netdb.h>
+# include <netinet/in.h>
+# include <sys/socket.h>
+# include <sys/sysctl.h>
+# if defined(KWSYS_SYS_HAS_IFADDRS_H)
+# include <ifaddrs.h>
+# include <net/if.h>
+# define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN
+# endif
+# if !(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ - 0 >= 1050)
+# undef KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE
+# endif
+#endif
+
+#if defined(__linux) || defined(__sun) || defined(_SCO_DS) || \
+ defined(__GLIBC__) || defined(__GNU__)
+# include <netdb.h>
+# include <netinet/in.h>
+# include <sys/socket.h>
+# if defined(KWSYS_SYS_HAS_IFADDRS_H)
+# include <ifaddrs.h>
+# include <net/if.h>
+# if defined(__LSB_VERSION__)
+/* LSB has no getifaddrs */
+# elif defined(__ANDROID_API__) && __ANDROID_API__ < 24
+/* Android has no getifaddrs prior to API 24. */
+# else
+# define KWSYS_SYSTEMINFORMATION_IMPLEMENT_FQDN
+# endif
+# endif
+# if defined(KWSYS_CXX_HAS_RLIMIT64)
typedef struct rlimit64 ResourceLimitType;
-#define GetResourceLimit getrlimit64
-#else
+# define GetResourceLimit getrlimit64
+# else
typedef struct rlimit ResourceLimitType;
-#define GetResourceLimit getrlimit
-#endif
+# define GetResourceLimit getrlimit
+# endif
#elif defined(__hpux)
-#include <sys/param.h>
-#include <sys/pstat.h>
-#if defined(KWSYS_SYS_HAS_MPCTL_H)
-#include <sys/mpctl.h>
-#endif
+# include <sys/param.h>
+# include <sys/pstat.h>
+# if defined(KWSYS_SYS_HAS_MPCTL_H)
+# include <sys/mpctl.h>
+# endif
#endif
#ifdef __HAIKU__
-#include <OS.h>
+# include <OS.h>
#endif
#if defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE)
-#include <execinfo.h>
-#if defined(KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE)
-#include <cxxabi.h>
-#endif
-#if defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP)
-#include <dlfcn.h>
-#endif
+# include <execinfo.h>
+# if defined(KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE)
+# include <cxxabi.h>
+# endif
+# if defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP)
+# include <dlfcn.h>
+# endif
#else
-#undef KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE
-#undef KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP
+# undef KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE
+# undef KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP
#endif
#include <ctype.h> // int isdigit(int c);
@@ -164,57 +170,57 @@ typedef struct rlimit ResourceLimitType;
#include <string.h>
#if defined(KWSYS_USE_LONG_LONG)
-#if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG)
-#define iostreamLongLong(x) (x)
-#else
-#define iostreamLongLong(x) ((long)(x))
-#endif
+# if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG)
+# define iostreamLongLong(x) (x)
+# else
+# define iostreamLongLong(x) ((long)(x))
+# endif
#elif defined(KWSYS_USE___INT64)
-#if defined(KWSYS_IOS_HAS_OSTREAM___INT64)
-#define iostreamLongLong(x) (x)
+# if defined(KWSYS_IOS_HAS_OSTREAM___INT64)
+# define iostreamLongLong(x) (x)
+# else
+# define iostreamLongLong(x) ((long)(x))
+# endif
#else
-#define iostreamLongLong(x) ((long)(x))
-#endif
-#else
-#error "No Long Long"
+# error "No Long Long"
#endif
#if defined(KWSYS_CXX_HAS_ATOLL)
-#define atoLongLong atoll
-#else
-#if defined(KWSYS_CXX_HAS__ATOI64)
-#define atoLongLong _atoi64
-#elif defined(KWSYS_CXX_HAS_ATOL)
-#define atoLongLong atol
+# define atoLongLong atoll
#else
-#define atoLongLong atoi
-#endif
+# if defined(KWSYS_CXX_HAS__ATOI64)
+# define atoLongLong _atoi64
+# elif defined(KWSYS_CXX_HAS_ATOL)
+# define atoLongLong atol
+# else
+# define atoLongLong atoi
+# endif
#endif
#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(_WIN64) && \
!defined(__clang__)
-#define USE_ASM_INSTRUCTIONS 1
+# define USE_ASM_INSTRUCTIONS 1
#else
-#define USE_ASM_INSTRUCTIONS 0
+# define USE_ASM_INSTRUCTIONS 0
#endif
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__clang__)
-#include <intrin.h>
-#define USE_CPUID_INTRINSICS 1
+# include <intrin.h>
+# define USE_CPUID_INTRINSICS 1
#else
-#define USE_CPUID_INTRINSICS 0
+# define USE_CPUID_INTRINSICS 0
#endif
#if USE_ASM_INSTRUCTIONS || USE_CPUID_INTRINSICS || \
defined(KWSYS_CXX_HAS_BORLAND_ASM_CPUID)
-#define USE_CPUID 1
+# define USE_CPUID 1
#else
-#define USE_CPUID 0
+# define USE_CPUID 0
#endif
#if USE_CPUID
-#define CPUID_AWARE_COMPILER
+# define CPUID_AWARE_COMPILER
/**
* call CPUID instruction
@@ -223,16 +229,16 @@ typedef struct rlimit ResourceLimitType;
*/
static bool call_cpuid(int select, int result[4])
{
-#if USE_CPUID_INTRINSICS
+# if USE_CPUID_INTRINSICS
__cpuid(result, select);
return true;
-#else
+# else
int tmp[4];
-#if defined(_MSC_VER)
+# if defined(_MSC_VER)
// Use SEH to determine CPUID presence
__try {
_asm {
-#ifdef CPUID_AWARE_COMPILER
+# ifdef CPUID_AWARE_COMPILER
; we must push/pop the registers <<CPUID>> writes to, as the
; optimiser does not know about <<CPUID>>, and so does not expect
; these registers to change.
@@ -240,33 +246,33 @@ static bool call_cpuid(int select, int result[4])
push ebx
push ecx
push edx
-#endif
+# endif
; <<CPUID>>
mov eax, select
-#ifdef CPUID_AWARE_COMPILER
+# ifdef CPUID_AWARE_COMPILER
cpuid
-#else
+# else
_asm _emit 0x0f
_asm _emit 0xa2
-#endif
+# endif
mov tmp[0 * TYPE int], eax
mov tmp[1 * TYPE int], ebx
mov tmp[2 * TYPE int], ecx
mov tmp[3 * TYPE int], edx
-#ifdef CPUID_AWARE_COMPILER
+# ifdef CPUID_AWARE_COMPILER
pop edx
pop ecx
pop ebx
pop eax
-#endif
+# endif
}
} __except (1) {
return false;
}
memcpy(result, tmp, sizeof(tmp));
-#elif defined(KWSYS_CXX_HAS_BORLAND_ASM_CPUID)
+# elif defined(KWSYS_CXX_HAS_BORLAND_ASM_CPUID)
unsigned int a, b, c, d;
__asm {
mov EAX, select;
@@ -281,11 +287,11 @@ static bool call_cpuid(int select, int result[4])
result[1] = b;
result[2] = c;
result[3] = d;
-#endif
+# endif
// The cpuid instruction succeeded.
return true;
-#endif
+# endif
}
#endif
@@ -340,7 +346,7 @@ public:
bool DoesCPUSupportCPUID();
- // Retrieve memory information in megabyte.
+ // Retrieve memory information in MiB.
size_t GetTotalVirtualMemory();
size_t GetAvailableVirtualMemory();
size_t GetTotalPhysicalMemory();
@@ -348,7 +354,7 @@ public:
LongLong GetProcessId();
- // Retrieve memory information in kib
+ // Retrieve memory information in KiB.
LongLong GetHostMemoryTotal();
LongLong GetHostMemoryAvailable(const char* envVarName);
LongLong GetHostMemoryUsed();
@@ -441,6 +447,7 @@ public:
IBM,
Motorola,
HP,
+ Hygon,
UnknownManufacturer
};
@@ -736,7 +743,7 @@ bool SystemInformation::DoesCPUSupportCPUID()
return this->Implementation->DoesCPUSupportCPUID();
}
-// Retrieve memory information in megabyte.
+// Retrieve memory information in MiB.
size_t SystemInformation::GetTotalVirtualMemory()
{
return this->Implementation->GetTotalVirtualMemory();
@@ -840,31 +847,16 @@ void SystemInformation::RunMemoryCheck()
// SystemInformationImplementation starts here
-#define STORE_TLBCACHE_INFO(x, y) x = (x < (y)) ? (y) : x
-#define TLBCACHE_INFO_UNITS (15)
-#define CLASSICAL_CPU_FREQ_LOOP 10000000
-#define RDTSC_INSTRUCTION _asm _emit 0x0f _asm _emit 0x31
-
-// Status Flag
-#define HT_NOT_CAPABLE 0
-#define HT_ENABLED 1
-#define HT_DISABLED 2
-#define HT_SUPPORTED_NOT_ENABLED 3
-#define HT_CANNOT_DETECT 4
-
-// EDX[28] Bit 28 is set if HT is supported
-#define HT_BIT 0x10000000
-
-// EAX[11:8] Bit 8-11 contains family processor ID.
-#define FAMILY_ID 0x0F00
-#define PENTIUM4_ID 0x0F00
-// EAX[23:20] Bit 20-23 contains extended family processor ID
-#define EXT_FAMILY_ID 0x0F00000
-// EBX[23:16] Bit 16-23 in ebx contains the number of logical
-#define NUM_LOGICAL_BITS 0x00FF0000
-// processors per physical processor when execute cpuid with
-// eax set to 1
-// EBX[31:24] Bits 24-31 (8 bits) return the 8-bit unique
+#if USE_CPUID
+# define STORE_TLBCACHE_INFO(x, y) x = (x < (y)) ? (y) : x
+# define TLBCACHE_INFO_UNITS (15)
+#endif
+
+#if USE_ASM_INSTRUCTIONS
+# define CLASSICAL_CPU_FREQ_LOOP 10000000
+# define RDTSC_INSTRUCTION _asm _emit 0x0f _asm _emit 0x31
+#endif
+
#define INITIAL_APIC_ID_BITS 0xFF000000
// initial APIC ID for the processor this code is running on.
// Default value = 0xff if HT is not supported
@@ -881,7 +873,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines)
char buf[bufSize] = { '\0' };
while (!feof(file) && !ferror(file)) {
errno = 0;
- if (fgets(buf, bufSize, file) == 0) {
+ if (fgets(buf, bufSize, file) == nullptr) {
if (ferror(file) && (errno == EINTR)) {
clearerr(file);
}
@@ -902,7 +894,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines)
return nRead;
}
-#if defined(__linux)
+# if defined(__linux)
// *****************************************************************************
int LoadLines(const char* fileName, std::vector<std::string>& lines)
{
@@ -914,7 +906,7 @@ int LoadLines(const char* fileName, std::vector<std::string>& lines)
fclose(file);
return nRead;
}
-#endif
+# endif
// ****************************************************************************
template <typename T>
@@ -945,7 +937,7 @@ int GetFieldsFromFile(const char* fileName, const char** fieldNames, T* values)
return -1;
}
int i = 0;
- while (fieldNames[i] != NULL) {
+ while (fieldNames[i] != nullptr) {
int ierr = NameValue(fields, fieldNames[i], values[i]);
if (ierr) {
return -(i + 2);
@@ -959,7 +951,7 @@ int GetFieldsFromFile(const char* fileName, const char** fieldNames, T* values)
template <typename T>
int GetFieldFromFile(const char* fileName, const char* fieldName, T& value)
{
- const char* fieldNames[2] = { fieldName, NULL };
+ const char* fieldNames[2] = { fieldName, nullptr };
T values[1] = { T(0) };
int ierr = GetFieldsFromFile(fileName, fieldNames, values);
if (ierr) {
@@ -977,7 +969,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames,
T* values)
{
FILE* file = popen(command, "r");
- if (file == 0) {
+ if (file == nullptr) {
return -1;
}
std::vector<std::string> fields;
@@ -987,7 +979,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames,
return -1;
}
int i = 0;
- while (fieldNames[i] != NULL) {
+ while (fieldNames[i] != nullptr) {
int ierr = NameValue(fields, fieldNames[i], values[i]);
if (ierr) {
return -(i + 2);
@@ -1003,7 +995,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames,
void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
void* /*sigContext*/)
{
-#if defined(__linux) || defined(__APPLE__)
+# if defined(__linux) || defined(__APPLE__)
std::ostringstream oss;
oss << std::endl
<< "========================================================="
@@ -1023,20 +1015,20 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
break;
case SIGFPE:
- oss << "Caught SIGFPE at " << (sigInfo->si_addr == 0 ? "0x" : "")
+ oss << "Caught SIGFPE at " << (sigInfo->si_addr == nullptr ? "0x" : "")
<< sigInfo->si_addr << " ";
switch (sigInfo->si_code) {
-#if defined(FPE_INTDIV)
+# if defined(FPE_INTDIV)
case FPE_INTDIV:
oss << "integer division by zero";
break;
-#endif
+# endif
-#if defined(FPE_INTOVF)
+# if defined(FPE_INTOVF)
case FPE_INTOVF:
oss << "integer overflow";
break;
-#endif
+# endif
case FPE_FLTDIV:
oss << "floating point divide by zero";
@@ -1058,11 +1050,11 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
oss << "floating point invalid operation";
break;
-#if defined(FPE_FLTSUB)
+# if defined(FPE_FLTSUB)
case FPE_FLTSUB:
oss << "floating point subscript out of range";
break;
-#endif
+# endif
default:
oss << "code " << sigInfo->si_code;
@@ -1071,7 +1063,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
break;
case SIGSEGV:
- oss << "Caught SIGSEGV at " << (sigInfo->si_addr == 0 ? "0x" : "")
+ oss << "Caught SIGSEGV at " << (sigInfo->si_addr == nullptr ? "0x" : "")
<< sigInfo->si_addr << " ";
switch (sigInfo->si_code) {
case SEGV_MAPERR:
@@ -1089,38 +1081,38 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
break;
case SIGBUS:
- oss << "Caught SIGBUS at " << (sigInfo->si_addr == 0 ? "0x" : "")
+ oss << "Caught SIGBUS at " << (sigInfo->si_addr == nullptr ? "0x" : "")
<< sigInfo->si_addr << " ";
switch (sigInfo->si_code) {
case BUS_ADRALN:
oss << "invalid address alignment";
break;
-#if defined(BUS_ADRERR)
+# if defined(BUS_ADRERR)
case BUS_ADRERR:
oss << "nonexistent physical address";
break;
-#endif
+# endif
-#if defined(BUS_OBJERR)
+# if defined(BUS_OBJERR)
case BUS_OBJERR:
oss << "object-specific hardware error";
break;
-#endif
+# endif
-#if defined(BUS_MCEERR_AR)
+# if defined(BUS_MCEERR_AR)
case BUS_MCEERR_AR:
oss << "Hardware memory error consumed on a machine check; action "
"required.";
break;
-#endif
+# endif
-#if defined(BUS_MCEERR_AO)
+# if defined(BUS_MCEERR_AO)
case BUS_MCEERR_AO:
oss << "Hardware memory error detected in process but not consumed; "
"action optional.";
break;
-#endif
+# endif
default:
oss << "code " << sigInfo->si_code;
@@ -1129,24 +1121,24 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
break;
case SIGILL:
- oss << "Caught SIGILL at " << (sigInfo->si_addr == 0 ? "0x" : "")
+ oss << "Caught SIGILL at " << (sigInfo->si_addr == nullptr ? "0x" : "")
<< sigInfo->si_addr << " ";
switch (sigInfo->si_code) {
case ILL_ILLOPC:
oss << "illegal opcode";
break;
-#if defined(ILL_ILLOPN)
+# if defined(ILL_ILLOPN)
case ILL_ILLOPN:
oss << "illegal operand";
break;
-#endif
+# endif
-#if defined(ILL_ILLADR)
+# if defined(ILL_ILLADR)
case ILL_ILLADR:
oss << "illegal addressing mode.";
break;
-#endif
+# endif
case ILL_ILLTRP:
oss << "illegal trap";
@@ -1156,23 +1148,23 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
oss << "privileged opcode";
break;
-#if defined(ILL_PRVREG)
+# if defined(ILL_PRVREG)
case ILL_PRVREG:
oss << "privileged register";
break;
-#endif
+# endif
-#if defined(ILL_COPROC)
+# if defined(ILL_COPROC)
case ILL_COPROC:
oss << "co-processor error";
break;
-#endif
+# endif
-#if defined(ILL_BADSTK)
+# if defined(ILL_BADSTK)
case ILL_BADSTK:
oss << "internal stack error";
break;
-#endif
+# endif
default:
oss << "code " << sigInfo->si_code;
@@ -1195,16 +1187,16 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
// and abort
SystemInformationImplementation::SetStackTraceOnError(0);
abort();
-#else
+# else
// avoid warning C4100
(void)sigNo;
(void)sigInfo;
-#endif
+# endif
}
#endif
#if defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE)
-#define safes(_arg) ((_arg) ? (_arg) : "???")
+# define safes(_arg) ((_arg) ? (_arg) : "???")
// Description:
// A container for symbol properties. Each instance
@@ -1264,7 +1256,7 @@ public:
long GetLineNumber() const { return this->LineNumber; }
// Description:
- // Set the address where the biinary image is mapped
+ // Set the address where the binary image is mapped
// into memory.
void SetBinaryBaseAddress(void* address)
{
@@ -1292,19 +1284,19 @@ private:
std::ostream& operator<<(std::ostream& os, const SymbolProperties& sp)
{
-#if defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP)
+# if defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP)
os << std::hex << sp.GetAddress() << " : " << sp.GetFunction() << " [("
<< sp.GetBinary() << ") " << sp.GetSourceFile() << ":" << std::dec
<< sp.GetLineNumber() << "]";
-#elif defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE)
+# elif defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE)
void* addr = sp.GetAddress();
char** syminfo = backtrace_symbols(&addr, 1);
os << safes(syminfo[0]);
free(syminfo);
-#else
+# else
(void)os;
(void)sp;
-#endif
+# endif
return os;
}
@@ -1313,8 +1305,8 @@ SymbolProperties::SymbolProperties()
// not using an initializer list
// to avoid some PGI compiler warnings
this->SetBinary("???");
- this->SetBinaryBaseAddress(NULL);
- this->Address = NULL;
+ this->SetBinaryBaseAddress(nullptr);
+ this->Address = nullptr;
this->SetSourceFile("???");
this->SetFunction("???");
this->SetLineNumber(-1);
@@ -1341,12 +1333,12 @@ std::string SymbolProperties::GetFileName(const std::string& path) const
std::string SymbolProperties::GetBinary() const
{
// only linux has proc fs
-#if defined(__linux__)
+# if defined(__linux__)
if (this->Binary == "/proc/self/exe") {
std::string binary;
char buf[1024] = { '\0' };
ssize_t ll = 0;
- if ((ll = readlink("/proc/self/exe", buf, 1024)) > 0) {
+ if ((ll = readlink("/proc/self/exe", buf, 1024)) > 0 && ll < 1024) {
buf[ll] = '\0';
binary = buf;
} else {
@@ -1354,14 +1346,14 @@ std::string SymbolProperties::GetBinary() const
}
return this->GetFileName(binary);
}
-#endif
+# endif
return this->GetFileName(this->Binary);
}
std::string SymbolProperties::Demangle(const char* symbol) const
{
std::string result = safes(symbol);
-#if defined(KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE)
+# if defined(KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE)
int status = 0;
size_t bufferLen = 1024;
char* buffer = (char*)malloc(1024);
@@ -1371,16 +1363,16 @@ std::string SymbolProperties::Demangle(const char* symbol) const
result = demangledSymbol;
}
free(buffer);
-#else
+# else
(void)symbol;
-#endif
+# endif
return result;
}
void SymbolProperties::Initialize(void* address)
{
this->Address = address;
-#if defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP)
+# if defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP)
// first fallback option can demangle c++ functions
Dl_info info;
int ierr = dladdr(this->Address, &info);
@@ -1388,18 +1380,18 @@ void SymbolProperties::Initialize(void* address)
this->SetBinary(info.dli_fname);
this->SetFunction(info.dli_sname);
}
-#else
+# else
// second fallback use builtin backtrace_symbols
// to decode the bactrace.
-#endif
+# endif
}
#endif // don't define this class if we're not using it
#if defined(_WIN32) || defined(__CYGWIN__)
-#define KWSYS_SYSTEMINFORMATION_USE_GetSystemTimes
+# define KWSYS_SYSTEMINFORMATION_USE_GetSystemTimes
#endif
#if defined(_MSC_VER) && _MSC_VER < 1310
-#undef KWSYS_SYSTEMINFORMATION_USE_GetSystemTimes
+# undef KWSYS_SYSTEMINFORMATION_USE_GetSystemTimes
#endif
#if defined(KWSYS_SYSTEMINFORMATION_USE_GetSystemTimes)
double calculateCPULoad(unsigned __int64 idleTicks,
@@ -1649,7 +1641,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName(
// any number of interfaces on this system we look for the
// first of these that contains the name returned by gethostname
// and is longer. failing that we return gethostname and indicate
- // with a failure code. Return of a failure code is not necessarilly
+ // with a failure code. Return of a failure code is not necessarily
// an indication of an error. for instance gethostname may return
// the fully qualified domain name, or there may not be one if the
// system lives on a private network such as in the case of a cluster
@@ -1671,7 +1663,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName(
return -2;
}
- for (ifa = ifas; ifa != NULL; ifa = ifa->ifa_next) {
+ for (ifa = ifas; ifa != nullptr; ifa = ifa->ifa_next) {
int fam = ifa->ifa_addr ? ifa->ifa_addr->sa_family : -1;
// Skip Loopback interfaces
if (((fam == AF_INET) || (fam == AF_INET6)) &&
@@ -1682,7 +1674,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName(
: sizeof(struct sockaddr_in6));
ierr = getnameinfo(ifa->ifa_addr, static_cast<socklen_t>(addrlen), host,
- NI_MAXHOST, NULL, 0, NI_NAMEREQD);
+ NI_MAXHOST, nullptr, 0, NI_NAMEREQD);
if (ierr) {
// don't report the failure now since we may succeed on another
// interface. If all attempts fail then return the failure code.
@@ -1759,6 +1751,8 @@ const char* SystemInformationImplementation::GetVendorID()
return "Motorola";
case HP:
return "Hewlett-Packard";
+ case Hygon:
+ return "Chengdu Haiguang IC Design Co., Ltd.";
case UnknownManufacturer:
default:
return "Unknown Manufacturer";
@@ -2004,12 +1998,12 @@ bool SystemInformationImplementation::DoesCPUSupportCPUID()
#if USE_CPUID
int dummy[4] = { 0, 0, 0, 0 };
-#if USE_ASM_INSTRUCTIONS
+# if USE_ASM_INSTRUCTIONS
return call_cpuid(0, dummy);
-#else
+# else
call_cpuid(0, dummy);
return dummy[0] || dummy[1] || dummy[2] || dummy[3];
-#endif
+# endif
#else
// Assume no cpuid instruction.
return false;
@@ -2051,7 +2045,7 @@ bool SystemInformationImplementation::RetrieveCPUFeatures()
this->Features.HasIA64 =
((cpuinfo[3] & 0x40000000) != 0); // IA64 Present --> Bit 30
-#if USE_ASM_INSTRUCTIONS
+# if USE_ASM_INSTRUCTIONS
// Retrieve extended SSE capabilities if SSE is available.
if (this->Features.HasSSE) {
@@ -2075,9 +2069,9 @@ bool SystemInformationImplementation::RetrieveCPUFeatures()
// Set the advanced SSE capabilities to not available.
this->Features.HasSSEFP = false;
}
-#else
+# else
this->Features.HasSSEFP = false;
-#endif
+# endif
// Retrieve Intel specific extended features.
if (this->ChipManufacturer == Intel) {
@@ -2110,6 +2104,8 @@ void SystemInformationImplementation::FindManufacturer(
this->ChipManufacturer = AMD; // Advanced Micro Devices
else if (this->ChipID.Vendor == "AMD ISBETTER")
this->ChipManufacturer = AMD; // Advanced Micro Devices (1994)
+ else if (this->ChipID.Vendor == "HygonGenuine")
+ this->ChipManufacturer = Hygon; // Chengdu Haiguang IC Design Co., Ltd.
else if (this->ChipID.Vendor == "CyrixInstead")
this->ChipManufacturer = Cyrix; // Cyrix Corp., VIA Inc.
else if (this->ChipID.Vendor == "NexGenDriven")
@@ -2562,7 +2558,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed()
// If RDTSC is not supported, we fallback to trying to read this value
// from the registry:
if (!retrieved) {
- HKEY hKey = NULL;
+ HKEY hKey = nullptr;
LONG err =
RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0,
@@ -2582,7 +2578,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed()
}
RegCloseKey(hKey);
- hKey = NULL;
+ hKey = nullptr;
}
}
#endif
@@ -2744,7 +2740,7 @@ bool SystemInformationImplementation::RetrieveExtendedCPUFeatures()
0); // MP Capable -- > Bit 19.
// Retrieve AMD specific extended features.
- if (this->ChipManufacturer == AMD) {
+ if (this->ChipManufacturer == AMD || this->ChipManufacturer == Hygon) {
this->Features.ExtendedFeatures.HasMMXPlus =
((localCPUExtendedFeatures[3] & 0x00400000) !=
0); // AMD specific: MMX-SSE --> Bit 22
@@ -3151,6 +3147,10 @@ bool SystemInformationImplementation::RetrieveClassicalCPUIdentity()
}
break;
+ case Hygon:
+ this->ChipID.ProcessorName = "Unknown Hygon family";
+ return false;
+
case Transmeta:
switch (this->ChipID.Family) {
case 5:
@@ -3489,7 +3489,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
// Chip Model Name
this->ChipID.ModelName =
- this->ExtractValueFromCpuInfoFile(buffer, "model name").c_str();
+ this->ExtractValueFromCpuInfoFile(buffer, "model name");
// L1 Cache size
// Different architectures may show different names for the caches.
@@ -3558,7 +3558,7 @@ bool SystemInformationImplementation::QueryProcessorBySysconf()
{
#if defined(_SC_NPROC_ONLN) && !defined(_SC_NPROCESSORS_ONLN)
// IRIX names this slightly different
-#define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
+# define _SC_NPROCESSORS_ONLN _SC_NPROC_ONLN
#endif
#ifdef _SC_NPROCESSORS_ONLN
@@ -3588,17 +3588,17 @@ SystemInformation::LongLong
SystemInformationImplementation::GetHostMemoryTotal()
{
#if defined(_WIN32)
-#if defined(_MSC_VER) && _MSC_VER < 1300
+# if defined(_MSC_VER) && _MSC_VER < 1300
MEMORYSTATUS stat;
stat.dwLength = sizeof(stat);
GlobalMemoryStatus(&stat);
return stat.dwTotalPhys / 1024;
-#else
+# else
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
GlobalMemoryStatusEx(&statex);
return statex.ullTotalPhys / 1024;
-#endif
+# endif
#elif defined(__linux)
SystemInformation::LongLong memTotal = 0;
int ierr = GetFieldFromFile("/proc/meminfo", "MemTotal:", memTotal);
@@ -3609,7 +3609,7 @@ SystemInformationImplementation::GetHostMemoryTotal()
#elif defined(__APPLE__)
uint64_t mem;
size_t len = sizeof(mem);
- int ierr = sysctlbyname("hw.memsize", &mem, &len, NULL, 0);
+ int ierr = sysctlbyname("hw.memsize", &mem, &len, nullptr, 0);
if (ierr) {
return -1;
}
@@ -3633,7 +3633,7 @@ SystemInformationImplementation::GetHostMemoryAvailable(
// apply resource limits across groups of processes.
// this is of use on certain SMP systems (eg. SGI UV)
// where the host has a large amount of ram but a given user's
- // access to it is severly restricted. The system will
+ // access to it is severely restricted. The system will
// apply a limit across a set of processes. Units are in KiB.
if (hostLimitEnvVarName) {
const char* hostLimitEnvVarValue = getenv(hostLimitEnvVarName);
@@ -3713,25 +3713,25 @@ SystemInformation::LongLong
SystemInformationImplementation::GetHostMemoryUsed()
{
#if defined(_WIN32)
-#if defined(_MSC_VER) && _MSC_VER < 1300
+# if defined(_MSC_VER) && _MSC_VER < 1300
MEMORYSTATUS stat;
stat.dwLength = sizeof(stat);
GlobalMemoryStatus(&stat);
return (stat.dwTotalPhys - stat.dwAvailPhys) / 1024;
-#else
+# else
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
GlobalMemoryStatusEx(&statex);
return (statex.ullTotalPhys - statex.ullAvailPhys) / 1024;
-#endif
+# endif
#elif defined(__linux)
// First try to use MemAvailable, but it only works on newer kernels
- const char* names2[3] = { "MemTotal:", "MemAvailable:", NULL };
+ const char* names2[3] = { "MemTotal:", "MemAvailable:", nullptr };
SystemInformation::LongLong values2[2] = { SystemInformation::LongLong(0) };
int ierr = GetFieldsFromFile("/proc/meminfo", names2, values2);
if (ierr) {
const char* names4[5] = { "MemTotal:", "MemFree:", "Buffers:", "Cached:",
- NULL };
+ nullptr };
SystemInformation::LongLong values4[4] = { SystemInformation::LongLong(
0) };
ierr = GetFieldsFromFile("/proc/meminfo", names4, values4);
@@ -3752,7 +3752,7 @@ SystemInformationImplementation::GetHostMemoryUsed()
if (psz < 1) {
return -1;
}
- const char* names[3] = { "Pages wired down:", "Pages active:", NULL };
+ const char* names[3] = { "Pages wired down:", "Pages active:", nullptr };
SystemInformation::LongLong values[2] = { SystemInformation::LongLong(0) };
int ierr = GetFieldsFromCommand("vm_stat", names, values);
if (ierr) {
@@ -3800,7 +3800,7 @@ SystemInformationImplementation::GetProcMemoryUsed()
std::ostringstream oss;
oss << "ps -o rss= -p " << pid;
FILE* file = popen(oss.str().c_str(), "r");
- if (file == 0) {
+ if (file == nullptr) {
return -1;
}
oss.str("");
@@ -3863,7 +3863,8 @@ SystemInformation::LongLong SystemInformationImplementation::GetProcessId()
{
#if defined(_WIN32)
return GetCurrentProcessId();
-#elif defined(__linux) || defined(__APPLE__)
+#elif defined(__linux) || defined(__APPLE__) || defined(__OpenBSD__) || \
+ defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
return getpid();
#else
return -1;
@@ -3871,34 +3872,78 @@ SystemInformation::LongLong SystemInformationImplementation::GetProcessId()
}
/**
+ * Used in GetProgramStack(...) below
+ */
+#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600 && defined(_MSC_VER) && \
+ _MSC_VER >= 1800
+# define KWSYS_SYSTEMINFORMATION_HAS_DBGHELP
+# define TRACE_MAX_STACK_FRAMES 1024
+# define TRACE_MAX_FUNCTION_NAME_LENGTH 1024
+# pragma warning(push)
+# pragma warning(disable : 4091) /* 'typedef ': ignored on left of '' */
+# include "dbghelp.h"
+# pragma warning(pop)
+#endif
+
+/**
return current program stack in a string
demangle cxx symbols if possible.
*/
std::string SystemInformationImplementation::GetProgramStack(int firstFrame,
int wholePath)
{
- std::string programStack = ""
-#if !defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE)
- "WARNING: The stack could not be examined "
- "because backtrace is not supported.\n"
-#elif !defined(KWSYS_SYSTEMINFORMATION_HAS_DEBUG_BUILD)
- "WARNING: The stack trace will not use advanced "
- "capabilities because this is a release build.\n"
+ std::ostringstream oss;
+ std::string programStack = "";
+
+#ifdef KWSYS_SYSTEMINFORMATION_HAS_DBGHELP
+ (void)wholePath;
+
+ void* stack[TRACE_MAX_STACK_FRAMES];
+ HANDLE process = GetCurrentProcess();
+ SymInitialize(process, nullptr, TRUE);
+ WORD numberOfFrames =
+ CaptureStackBackTrace(firstFrame, TRACE_MAX_STACK_FRAMES, stack, nullptr);
+ SYMBOL_INFO* symbol = static_cast<SYMBOL_INFO*>(
+ malloc(sizeof(SYMBOL_INFO) +
+ (TRACE_MAX_FUNCTION_NAME_LENGTH - 1) * sizeof(TCHAR)));
+ symbol->MaxNameLen = TRACE_MAX_FUNCTION_NAME_LENGTH;
+ symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
+ DWORD displacement;
+ IMAGEHLP_LINE64 line;
+ line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
+ for (int i = 0; i < numberOfFrames; i++) {
+ DWORD64 address = reinterpret_cast<DWORD64>(stack[i]);
+ SymFromAddr(process, address, nullptr, symbol);
+ if (SymGetLineFromAddr64(process, address, &displacement, &line)) {
+ oss << " at " << symbol->Name << " in " << line.FileName << " line "
+ << line.LineNumber << std::endl;
+ } else {
+ oss << " at " << symbol->Name << std::endl;
+ }
+ }
+ free(symbol);
+
#else
-#if !defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP)
- "WARNING: Function names will not be demangled "
- "because "
- "dladdr is not available.\n"
-#endif
-#if !defined(KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE)
- "WARNING: Function names will not be demangled "
- "because cxxabi is not available.\n"
-#endif
-#endif
+ programStack += ""
+# if !defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE)
+ "WARNING: The stack could not be examined "
+ "because backtrace is not supported.\n"
+# elif !defined(KWSYS_SYSTEMINFORMATION_HAS_DEBUG_BUILD)
+ "WARNING: The stack trace will not use advanced "
+ "capabilities because this is a release build.\n"
+# else
+# if !defined(KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP)
+ "WARNING: Function names will not be demangled "
+ "because dladdr is not available.\n"
+# endif
+# if !defined(KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE)
+ "WARNING: Function names will not be demangled "
+ "because cxxabi is not available.\n"
+# endif
+# endif
;
- std::ostringstream oss;
-#if defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE)
+# if defined(KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE)
void* stackSymbols[256];
int nFrames = backtrace(stackSymbols, 256);
for (int i = firstFrame; i < nFrames; ++i) {
@@ -3907,10 +3952,12 @@ std::string SystemInformationImplementation::GetProgramStack(int firstFrame,
symProps.Initialize(stackSymbols[i]);
oss << symProps << std::endl;
}
-#else
+# else
(void)firstFrame;
(void)wholePath;
+# endif
#endif
+
programStack += oss.str();
return programStack;
@@ -3933,13 +3980,13 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable)
if (enable && !saOrigValid) {
// save the current actions
- sigaction(SIGABRT, 0, &saABRTOrig);
- sigaction(SIGSEGV, 0, &saSEGVOrig);
- sigaction(SIGTERM, 0, &saTERMOrig);
- sigaction(SIGINT, 0, &saINTOrig);
- sigaction(SIGILL, 0, &saILLOrig);
- sigaction(SIGBUS, 0, &saBUSOrig);
- sigaction(SIGFPE, 0, &saFPEOrig);
+ sigaction(SIGABRT, nullptr, &saABRTOrig);
+ sigaction(SIGSEGV, nullptr, &saSEGVOrig);
+ sigaction(SIGTERM, nullptr, &saTERMOrig);
+ sigaction(SIGINT, nullptr, &saINTOrig);
+ sigaction(SIGILL, nullptr, &saILLOrig);
+ sigaction(SIGBUS, nullptr, &saBUSOrig);
+ sigaction(SIGFPE, nullptr, &saFPEOrig);
// enable read, disable write
saOrigValid = 1;
@@ -3948,27 +3995,27 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable)
struct sigaction sa;
sa.sa_sigaction = (SigAction)StacktraceSignalHandler;
sa.sa_flags = SA_SIGINFO | SA_RESETHAND;
-#ifdef SA_RESTART
+# ifdef SA_RESTART
sa.sa_flags |= SA_RESTART;
-#endif
+# endif
sigemptyset(&sa.sa_mask);
- sigaction(SIGABRT, &sa, 0);
- sigaction(SIGSEGV, &sa, 0);
- sigaction(SIGTERM, &sa, 0);
- sigaction(SIGINT, &sa, 0);
- sigaction(SIGILL, &sa, 0);
- sigaction(SIGBUS, &sa, 0);
- sigaction(SIGFPE, &sa, 0);
+ sigaction(SIGABRT, &sa, nullptr);
+ sigaction(SIGSEGV, &sa, nullptr);
+ sigaction(SIGTERM, &sa, nullptr);
+ sigaction(SIGINT, &sa, nullptr);
+ sigaction(SIGILL, &sa, nullptr);
+ sigaction(SIGBUS, &sa, nullptr);
+ sigaction(SIGFPE, &sa, nullptr);
} else if (!enable && saOrigValid) {
// restore previous actions
- sigaction(SIGABRT, &saABRTOrig, 0);
- sigaction(SIGSEGV, &saSEGVOrig, 0);
- sigaction(SIGTERM, &saTERMOrig, 0);
- sigaction(SIGINT, &saINTOrig, 0);
- sigaction(SIGILL, &saILLOrig, 0);
- sigaction(SIGBUS, &saBUSOrig, 0);
- sigaction(SIGFPE, &saFPEOrig, 0);
+ sigaction(SIGABRT, &saABRTOrig, nullptr);
+ sigaction(SIGSEGV, &saSEGVOrig, nullptr);
+ sigaction(SIGTERM, &saTERMOrig, nullptr);
+ sigaction(SIGINT, &saINTOrig, nullptr);
+ sigaction(SIGILL, &saILLOrig, nullptr);
+ sigaction(SIGBUS, &saBUSOrig, nullptr);
+ sigaction(SIGFPE, &saFPEOrig, nullptr);
// enable write, disable read
saOrigValid = 0;
@@ -3982,21 +4029,21 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable)
bool SystemInformationImplementation::QueryWindowsMemory()
{
#if defined(_WIN32)
-#if defined(_MSC_VER) && _MSC_VER < 1300
+# if defined(_MSC_VER) && _MSC_VER < 1300
MEMORYSTATUS ms;
unsigned long tv, tp, av, ap;
ms.dwLength = sizeof(ms);
GlobalMemoryStatus(&ms);
-#define MEM_VAL(value) dw##value
-#else
+# define MEM_VAL(value) dw##value
+# else
MEMORYSTATUSEX ms;
DWORDLONG tv, tp, av, ap;
ms.dwLength = sizeof(ms);
if (0 == GlobalMemoryStatusEx(&ms)) {
return 0;
}
-#define MEM_VAL(value) ull##value
-#endif
+# define MEM_VAL(value) ull##value
+# endif
tv = ms.MEM_VAL(TotalPageFile);
tp = ms.MEM_VAL(TotalPhys);
av = ms.MEM_VAL(AvailPageFile);
@@ -4054,7 +4101,7 @@ bool SystemInformationImplementation::QueryLinuxMemory()
if (linuxMajor >= 3 || ((linuxMajor >= 2) && (linuxMinor >= 6))) {
// new /proc/meminfo format since kernel 2.6.x
- // Rigorously, this test should check from the developping version 2.5.x
+ // Rigorously, this test should check from the developing version 2.5.x
// that introduced the new format...
enum
@@ -4179,7 +4226,7 @@ bool SystemInformationImplementation::QueryMemoryBySysconf()
this->TotalPhysicalMemory = p;
this->TotalPhysicalMemory /= pagediv;
-#if defined(_SC_AVPHYS_PAGES)
+# if defined(_SC_AVPHYS_PAGES)
p = sysconf(_SC_AVPHYS_PAGES);
if (p < 0) {
return false;
@@ -4187,7 +4234,7 @@ bool SystemInformationImplementation::QueryMemoryBySysconf()
this->AvailablePhysicalMemory = p;
this->AvailablePhysicalMemory /= pagediv;
-#endif
+# endif
return true;
#else
@@ -4350,7 +4397,7 @@ void SystemInformationImplementation::CPUCountWindows()
std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION> ProcInfo;
{
DWORD Length = 0;
- DWORD rc = pGetLogicalProcessorInformation(NULL, &Length);
+ DWORD rc = pGetLogicalProcessorInformation(nullptr, &Length);
assert(FALSE == rc);
(void)rc; // Silence unused variable warning in Borland C++ 5.81
assert(GetLastError() == ERROR_INSUFFICIENT_BUFFER);
@@ -4404,7 +4451,7 @@ bool SystemInformationImplementation::ParseSysCtl()
int err = 0;
uint64_t value = 0;
size_t len = sizeof(value);
- sysctlbyname("hw.memsize", &value, &len, NULL, 0);
+ sysctlbyname("hw.memsize", &value, &len, nullptr, 0);
this->TotalPhysicalMemory = static_cast<size_t>(value / 1048576);
// Parse values for Mac
@@ -4414,45 +4461,47 @@ bool SystemInformationImplementation::ParseSysCtl()
if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmstat,
&count) == KERN_SUCCESS) {
len = sizeof(value);
- err = sysctlbyname("hw.pagesize", &value, &len, NULL, 0);
- int64_t available_memory = vmstat.free_count * value;
+ err = sysctlbyname("hw.pagesize", &value, &len, nullptr, 0);
+ int64_t available_memory =
+ (vmstat.free_count + vmstat.inactive_count) * value;
this->AvailablePhysicalMemory =
static_cast<size_t>(available_memory / 1048576);
}
-#ifdef VM_SWAPUSAGE
+# ifdef VM_SWAPUSAGE
// Virtual memory.
int mib[2] = { CTL_VM, VM_SWAPUSAGE };
- size_t miblen = sizeof(mib) / sizeof(mib[0]);
+ unsigned int miblen =
+ static_cast<unsigned int>(sizeof(mib) / sizeof(mib[0]));
struct xsw_usage swap;
len = sizeof(swap);
- err = sysctl(mib, miblen, &swap, &len, NULL, 0);
+ err = sysctl(mib, miblen, &swap, &len, nullptr, 0);
if (err == 0) {
this->AvailableVirtualMemory =
static_cast<size_t>(swap.xsu_avail / 1048576);
this->TotalVirtualMemory = static_cast<size_t>(swap.xsu_total / 1048576);
}
-#else
+# else
this->AvailableVirtualMemory = 0;
this->TotalVirtualMemory = 0;
-#endif
+# endif
// CPU Info
len = sizeof(this->NumberOfPhysicalCPU);
- sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len, NULL, 0);
+ sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len, nullptr, 0);
len = sizeof(this->NumberOfLogicalCPU);
- sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, NULL, 0);
+ sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, nullptr, 0);
int cores_per_package = 0;
len = sizeof(cores_per_package);
err = sysctlbyname("machdep.cpu.cores_per_package", &cores_per_package, &len,
- NULL, 0);
+ nullptr, 0);
// That name was not found, default to 1
this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical =
err != 0 ? 1 : static_cast<unsigned char>(cores_per_package);
len = sizeof(value);
- sysctlbyname("hw.cpufrequency", &value, &len, NULL, 0);
+ sysctlbyname("hw.cpufrequency", &value, &len, nullptr, 0);
this->CPUSpeedInMHz = static_cast<float>(value) / 1000000;
// Chip family
@@ -4460,50 +4509,51 @@ bool SystemInformationImplementation::ParseSysCtl()
// Seems only the intel chips will have this name so if this fails it is
// probably a PPC machine
err =
- sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, NULL, 0);
+ sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, nullptr, 0);
if (err != 0) // Go back to names we know but are less descriptive
{
this->ChipID.Family = 0;
::memset(retBuf, 0, 128);
len = 32;
- err = sysctlbyname("hw.machine", &retBuf, &len, NULL, 0);
+ err = sysctlbyname("hw.machine", &retBuf, &len, nullptr, 0);
std::string machineBuf(retBuf);
if (machineBuf.find_first_of("Power") != std::string::npos) {
this->ChipID.Vendor = "IBM";
len = sizeof(this->ChipID.Family);
- err = sysctlbyname("hw.cputype", &this->ChipID.Family, &len, NULL, 0);
+ err = sysctlbyname("hw.cputype", &this->ChipID.Family, &len, nullptr, 0);
len = sizeof(this->ChipID.Model);
- err = sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len, NULL, 0);
+ err =
+ sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len, nullptr, 0);
this->FindManufacturer();
}
} else // Should be an Intel Chip.
{
len = sizeof(this->ChipID.Family);
- err =
- sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, NULL, 0);
+ err = sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len,
+ nullptr, 0);
::memset(retBuf, 0, 128);
len = 128;
- err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, NULL, 0);
+ err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, nullptr, 0);
// Chip Vendor
this->ChipID.Vendor = retBuf;
this->FindManufacturer();
// Chip Model
len = sizeof(value);
- err = sysctlbyname("machdep.cpu.model", &value, &len, NULL, 0);
+ err = sysctlbyname("machdep.cpu.model", &value, &len, nullptr, 0);
this->ChipID.Model = static_cast<int>(value);
// Chip Stepping
len = sizeof(value);
value = 0;
- err = sysctlbyname("machdep.cpu.stepping", &value, &len, NULL, 0);
+ err = sysctlbyname("machdep.cpu.stepping", &value, &len, nullptr, 0);
if (!err) {
this->ChipID.Revision = static_cast<int>(value);
}
// feature string
- char* buf = 0;
+ char* buf = nullptr;
size_t allocSize = 128;
err = 0;
@@ -4520,7 +4570,7 @@ bool SystemInformationImplementation::ParseSysCtl()
}
buf[0] = ' ';
len = allocSize - 2; // keep space for leading and trailing space
- err = sysctlbyname("machdep.cpu.features", buf + 1, &len, NULL, 0);
+ err = sysctlbyname("machdep.cpu.features", buf + 1, &len, nullptr, 0);
}
if (!err && buf && len) {
// now we can match every flags as space + flag + space
@@ -4561,7 +4611,7 @@ bool SystemInformationImplementation::ParseSysCtl()
// brand string
::memset(retBuf, 0, sizeof(retBuf));
len = sizeof(retBuf);
- err = sysctlbyname("machdep.cpu.brand_string", retBuf, &len, NULL, 0);
+ err = sysctlbyname("machdep.cpu.brand_string", retBuf, &len, nullptr, 0);
if (!err) {
this->ChipID.ProcessorName = retBuf;
this->ChipID.ModelName = retBuf;
@@ -4569,10 +4619,10 @@ bool SystemInformationImplementation::ParseSysCtl()
// Cache size
len = sizeof(value);
- err = sysctlbyname("hw.l1icachesize", &value, &len, NULL, 0);
+ err = sysctlbyname("hw.l1icachesize", &value, &len, nullptr, 0);
this->Features.L1CacheSize = static_cast<int>(value);
len = sizeof(value);
- err = sysctlbyname("hw.l2cachesize", &value, &len, NULL, 0);
+ err = sysctlbyname("hw.l2cachesize", &value, &len, nullptr, 0);
this->Features.L2CacheSize = static_cast<int>(value);
return true;
@@ -4600,16 +4650,16 @@ std::string SystemInformationImplementation::ExtractValueFromSysCtl(
std::string SystemInformationImplementation::RunProcess(
std::vector<const char*> args)
{
- std::string buffer = "";
+ std::string buffer;
// Run the application
kwsysProcess* gp = kwsysProcess_New();
- kwsysProcess_SetCommand(gp, &*args.begin());
+ kwsysProcess_SetCommand(gp, args.data());
kwsysProcess_SetOption(gp, kwsysProcess_Option_HideWindow, 1);
kwsysProcess_Execute(gp);
- char* data = NULL;
+ char* data = nullptr;
int length;
double timeout = 255;
int pipe; // pipe id as returned by kwsysProcess_WaitForData()
@@ -4621,7 +4671,7 @@ std::string SystemInformationImplementation::RunProcess(
{
buffer.append(data, length);
}
- kwsysProcess_WaitForExit(gp, 0);
+ kwsysProcess_WaitForExit(gp, nullptr);
int result = 0;
switch (kwsysProcess_GetState(gp)) {
@@ -4655,11 +4705,7 @@ std::string SystemInformationImplementation::RunProcess(
std::string SystemInformationImplementation::ParseValueFromKStat(
const char* arguments)
{
- std::vector<const char*> args;
- args.clear();
- args.push_back("kstat");
- args.push_back("-p");
-
+ std::vector<std::string> args_string;
std::string command = arguments;
size_t start = std::string::npos;
size_t pos = command.find(' ', 0);
@@ -4678,35 +4724,35 @@ std::string SystemInformationImplementation::ParseValueFromKStat(
}
if (!inQuotes) {
- std::string arg = command.substr(start + 1, pos - start - 1);
+ args_string.push_back(command.substr(start + 1, pos - start - 1));
+ std::string& arg = args_string.back();
// Remove the quotes if any
- size_t quotes = arg.find('"');
- while (quotes != std::string::npos) {
- arg.erase(quotes, 1);
- quotes = arg.find('"');
- }
- args.push_back(arg.c_str());
+ arg.erase(std::remove(arg.begin(), arg.end(), '"'), arg.end());
start = pos;
}
pos = command.find(' ', pos + 1);
}
- std::string lastArg = command.substr(start + 1, command.size() - start - 1);
- args.push_back(lastArg.c_str());
+ args_string.push_back(command.substr(start + 1, command.size() - start - 1));
- args.push_back(0);
+ std::vector<const char*> args;
+ args.reserve(3 + args_string.size());
+ args.push_back("kstat");
+ args.push_back("-p");
+ for (size_t i = 0; i < args_string.size(); ++i) {
+ args.push_back(args_string[i].c_str());
+ }
+ args.push_back(nullptr);
std::string buffer = this->RunProcess(args);
- std::string value = "";
+ std::string value;
for (size_t i = buffer.size() - 1; i > 0; i--) {
if (buffer[i] == ' ' || buffer[i] == '\t') {
break;
}
if (buffer[i] != '\n' && buffer[i] != '\r') {
- std::string val = value;
- value = buffer[i];
- value += val;
+ value.insert(0u, 1, buffer[i]);
}
}
return value;
@@ -4720,11 +4766,11 @@ bool SystemInformationImplementation::QuerySolarisMemory()
// a 32 bit process on a 64 bit host the returned memory will be
// limited to 4GiB. So if this is a 32 bit process or if the sysconf
// method fails use the kstat interface.
-#if SIZEOF_VOID_P == 8
+# if SIZEOF_VOID_P == 8
if (this->QueryMemoryBySysconf()) {
return true;
}
-#endif
+# endif
char* tail;
unsigned long totalMemory =
@@ -4887,15 +4933,15 @@ bool SystemInformationImplementation::QueryBSDMemory()
#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__DragonFly__)
int ctrl[2] = { CTL_HW, HW_PHYSMEM };
-#if defined(HW_PHYSMEM64)
+# if defined(HW_PHYSMEM64)
int64_t k;
ctrl[1] = HW_PHYSMEM64;
-#else
+# else
int k;
-#endif
+# endif
size_t sz = sizeof(k);
- if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
+ if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
@@ -4966,58 +5012,58 @@ bool SystemInformationImplementation::QueryBSDProcessor()
size_t sz = sizeof(k);
int ctrl[2] = { CTL_HW, HW_NCPU };
- if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
+ if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
this->NumberOfPhysicalCPU = k;
this->NumberOfLogicalCPU = this->NumberOfPhysicalCPU;
-#if defined(HW_CPUSPEED)
+# if defined(HW_CPUSPEED)
ctrl[1] = HW_CPUSPEED;
- if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
+ if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
this->CPUSpeedInMHz = (float)k;
-#endif
+# endif
-#if defined(CPU_SSE)
+# if defined(CPU_SSE)
ctrl[0] = CTL_MACHDEP;
ctrl[1] = CPU_SSE;
- if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
+ if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
this->Features.HasSSE = (k > 0);
-#endif
+# endif
-#if defined(CPU_SSE2)
+# if defined(CPU_SSE2)
ctrl[0] = CTL_MACHDEP;
ctrl[1] = CPU_SSE2;
- if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
+ if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
this->Features.HasSSE2 = (k > 0);
-#endif
+# endif
-#if defined(CPU_CPUVENDOR)
+# if defined(CPU_CPUVENDOR)
ctrl[0] = CTL_MACHDEP;
ctrl[1] = CPU_CPUVENDOR;
char vbuf[25];
::memset(vbuf, 0, sizeof(vbuf));
sz = sizeof(vbuf) - 1;
- if (sysctl(ctrl, 2, vbuf, &sz, NULL, 0) != 0) {
+ if (sysctl(ctrl, 2, vbuf, &sz, nullptr, 0) != 0) {
return false;
}
this->ChipID.Vendor = vbuf;
this->FindManufacturer();
-#endif
+# endif
return true;
#else
@@ -5062,7 +5108,7 @@ bool SystemInformationImplementation::QueryHPUXMemory()
bool SystemInformationImplementation::QueryHPUXProcessor()
{
#if defined(__hpux)
-#if defined(KWSYS_SYS_HAS_MPCTL_H)
+# if defined(KWSYS_SYS_HAS_MPCTL_H)
int c = mpctl(MPC_GETNUMSPUS_SYS, 0, 0);
if (c <= 0) {
return false;
@@ -5090,17 +5136,17 @@ bool SystemInformationImplementation::QueryHPUXProcessor()
this->ChipID.Vendor = "Hewlett-Packard";
this->ChipID.Family = 0x200;
break;
-#if defined(CPU_HP_INTEL_EM_1_0) || defined(CPU_IA64_ARCHREV_0)
-#ifdef CPU_HP_INTEL_EM_1_0
+# if defined(CPU_HP_INTEL_EM_1_0) || defined(CPU_IA64_ARCHREV_0)
+# ifdef CPU_HP_INTEL_EM_1_0
case CPU_HP_INTEL_EM_1_0:
-#endif
-#ifdef CPU_IA64_ARCHREV_0
+# endif
+# ifdef CPU_IA64_ARCHREV_0
case CPU_IA64_ARCHREV_0:
-#endif
+# endif
this->ChipID.Vendor = "GenuineIntel";
this->Features.HasIA64 = true;
break;
-#endif
+# endif
default:
return false;
}
@@ -5108,9 +5154,9 @@ bool SystemInformationImplementation::QueryHPUXProcessor()
this->FindManufacturer();
return true;
-#else
+# else
return false;
-#endif
+# endif
#else
return false;
#endif
@@ -5131,14 +5177,17 @@ bool SystemInformationImplementation::QueryOSInformation()
// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEXW));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
-#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-#pragma warning(push)
-#ifdef __INTEL_COMPILER
-#pragma warning(disable : 1478)
-#else
-#pragma warning(disable : 4996)
-#endif
-#endif
+# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+# pragma warning(push)
+# ifdef __INTEL_COMPILER
+# pragma warning(disable : 1478)
+# elif defined __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wdeprecated-declarations"
+# else
+# pragma warning(disable : 4996)
+# endif
+# endif
bOsVersionInfoEx = GetVersionExW((OSVERSIONINFOW*)&osvi);
if (!bOsVersionInfoEx) {
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
@@ -5146,9 +5195,13 @@ bool SystemInformationImplementation::QueryOSInformation()
return false;
}
}
-#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-#pragma warning(pop)
-#endif
+# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+# ifdef __clang__
+# pragma clang diagnostic pop
+# else
+# pragma warning(pop)
+# endif
+# endif
switch (osvi.dwPlatformId) {
case VER_PLATFORM_WIN32_NT:
@@ -5166,7 +5219,7 @@ bool SystemInformationImplementation::QueryOSInformation()
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) {
this->OSRelease = "XP";
}
-#ifdef VER_NT_WORKSTATION
+# ifdef VER_NT_WORKSTATION
// Test for product type.
if (bOsVersionInfoEx) {
if (osvi.wProductType == VER_NT_WORKSTATION) {
@@ -5177,7 +5230,7 @@ bool SystemInformationImplementation::QueryOSInformation()
this->OSRelease = "7";
}
// VER_SUITE_PERSONAL may not be defined
-#ifdef VER_SUITE_PERSONAL
+# ifdef VER_SUITE_PERSONAL
else {
if (osvi.wSuiteMask & VER_SUITE_PERSONAL) {
this->OSRelease += " Personal";
@@ -5185,7 +5238,7 @@ bool SystemInformationImplementation::QueryOSInformation()
this->OSRelease += " Professional";
}
}
-#endif
+# endif
} else if (osvi.wProductType == VER_NT_SERVER) {
// Check for .NET Server instead of Windows XP.
if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) {
@@ -5206,7 +5259,7 @@ bool SystemInformationImplementation::QueryOSInformation()
osvi.dwBuildNumber & 0xFFFF);
this->OSVersion = operatingSystem;
} else
-#endif // VER_NT_WORKSTATION
+# endif // VER_NT_WORKSTATION
{
HKEY hKey;
wchar_t szProductType[80];
@@ -5216,7 +5269,7 @@ bool SystemInformationImplementation::QueryOSInformation()
RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions", 0,
KEY_QUERY_VALUE, &hKey);
- RegQueryValueExW(hKey, L"ProductType", NULL, NULL,
+ RegQueryValueExW(hKey, L"ProductType", nullptr, nullptr,
(LPBYTE)szProductType, &dwBufLen);
RegCloseKey(hKey);
@@ -5258,13 +5311,13 @@ bool SystemInformationImplementation::QueryOSInformation()
// Load the Kernel32 DLL.
hKernelDLL = LoadLibraryW(L"kernel32");
- if (hKernelDLL != NULL) {
+ if (hKernelDLL != nullptr) {
// Only XP and .NET Server support IsWOW64Process so... Load
// dynamically!
DLLProc = (LPFNPROC)GetProcAddress(hKernelDLL, "IsWow64Process");
// If the function address is valid, call the function.
- if (DLLProc != NULL)
+ if (DLLProc != nullptr)
(DLLProc)(GetCurrentProcess(), &bIsWindows64Bit);
else
bIsWindows64Bit = false;
@@ -5357,7 +5410,7 @@ bool SystemInformationImplementation::QueryOSInformation()
}
}
-#ifdef __APPLE__
+# ifdef __APPLE__
this->OSName = "Unknown Apple OS";
this->OSRelease = "Unknown product version";
this->OSVersion = "Unknown build version";
@@ -5365,7 +5418,7 @@ bool SystemInformationImplementation::QueryOSInformation()
this->CallSwVers("-productName", this->OSName);
this->CallSwVers("-productVersion", this->OSRelease);
this->CallSwVers("-buildVersion", this->OSVersion);
-#endif
+# endif
#endif
@@ -5379,7 +5432,7 @@ int SystemInformationImplementation::CallSwVers(const char* arg,
std::vector<const char*> args;
args.push_back("sw_vers");
args.push_back(arg);
- args.push_back(0);
+ args.push_back(nullptr);
ver = this->RunProcess(args);
this->TrimNewline(ver);
#else
diff --git a/Source/kwsys/SystemInformation.hxx.in b/Source/kwsys/SystemInformation.hxx.in
index 516c505c5..fc42e9dc7 100644
--- a/Source/kwsys/SystemInformation.hxx.in
+++ b/Source/kwsys/SystemInformation.hxx.in
@@ -20,7 +20,7 @@ class @KWSYS_NAMESPACE@_EXPORT SystemInformation
#elif @KWSYS_USE___INT64@
typedef __int64 LongLong;
#else
-#error "No Long Long"
+# error "No Long Long"
#endif
friend class SystemInformationImplementation;
SystemInformationImplementation* Implementation;
@@ -56,6 +56,9 @@ public:
SystemInformation();
~SystemInformation();
+ SystemInformation(const SystemInformation&) = delete;
+ SystemInformation& operator=(const SystemInformation&) = delete;
+
const char* GetVendorString();
const char* GetVendorID();
std::string GetTypeID();
@@ -103,17 +106,17 @@ public:
// Retrieve id of the current running process
LongLong GetProcessId();
- // Retrieve memory information in megabyte.
+ // Retrieve memory information in MiB.
size_t GetTotalVirtualMemory();
size_t GetAvailableVirtualMemory();
size_t GetTotalPhysicalMemory();
size_t GetAvailablePhysicalMemory();
// returns an informative general description if the installed and
- // available ram on this system. See the GetHostMmeoryTotal, and
+ // available ram on this system. See the GetHostMemoryTotal, and
// Get{Host,Proc}MemoryAvailable methods for more information.
- std::string GetMemoryDescription(const char* hostLimitEnvVarName = NULL,
- const char* procLimitEnvVarName = NULL);
+ std::string GetMemoryDescription(const char* hostLimitEnvVarName = nullptr,
+ const char* procLimitEnvVarName = nullptr);
// Retrieve amount of physical memory installed on the system in KiB
// units.
@@ -124,8 +127,8 @@ public:
// are the processes comprising an mpi program which is running in
// parallel. The amount of memory reported may differ from the host
// total if a host wide resource limit is applied. Such reource limits
- // are reported to us via an applicaiton specified environment variable.
- LongLong GetHostMemoryAvailable(const char* hostLimitEnvVarName = NULL);
+ // are reported to us via an application specified environment variable.
+ LongLong GetHostMemoryAvailable(const char* hostLimitEnvVarName = nullptr);
// Get total system RAM in units of KiB available to this process.
// This may differ from the host available if a per-process resource
@@ -133,8 +136,8 @@ public:
// system via rlimit API. Resource limits that are not imposed via
// rlimit API may be reported to us via an application specified
// environment variable.
- LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName = NULL,
- const char* procLimitEnvVarName = NULL);
+ LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName = nullptr,
+ const char* procLimitEnvVarName = nullptr);
// Get the system RAM used by all processes on the host, in units of KiB.
LongLong GetHostMemoryUsed();
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 1c4fe3389..ce4d6ef95 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -1,18 +1,19 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#ifdef __osf__
-#define _OSF_SOURCE
-#define _POSIX_C_SOURCE 199506L
-#define _XOPEN_SOURCE_EXTENDED
+# define _OSF_SOURCE
+# define _POSIX_C_SOURCE 199506L
+# define _XOPEN_SOURCE_EXTENDED
#endif
-#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || \
- defined(__BORLANDC__) || defined(__MINGW32__))
-#define KWSYS_WINDOWS_DIRS
+#if defined(_WIN32) && \
+ (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || \
+ defined(__MINGW32__))
+# define KWSYS_WINDOWS_DIRS
#else
-#if defined(__SUNPRO_CC)
-#include <fcntl.h>
-#endif
+# if defined(__SUNPRO_CC)
+# include <fcntl.h>
+# endif
#endif
#include "kwsysPrivate.h"
@@ -20,37 +21,38 @@
#include KWSYS_HEADER(SystemTools.hxx)
#include KWSYS_HEADER(Directory.hxx)
#include KWSYS_HEADER(FStream.hxx)
+#include KWSYS_HEADER(Encoding.h)
#include KWSYS_HEADER(Encoding.hxx)
-#include <algorithm>
#include <fstream>
#include <iostream>
#include <set>
#include <sstream>
+#include <utility>
#include <vector>
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "Directory.hxx.in"
-#include "Encoding.hxx.in"
-#include "FStream.hxx.in"
-#include "RegularExpression.hxx.in"
-#include "SystemTools.hxx.in"
+# include "Directory.hxx.in"
+# include "Encoding.hxx.in"
+# include "FStream.hxx.in"
+# include "RegularExpression.hxx.in"
+# include "SystemTools.hxx.in"
#endif
#ifdef _MSC_VER
-#pragma warning(disable : 4786)
+# pragma warning(disable : 4786)
#endif
#if defined(__sgi) && !defined(__GNUC__)
-#pragma set woff 1375 /* base class destructor not virtual */
+# pragma set woff 1375 /* base class destructor not virtual */
#endif
#include <ctype.h>
#include <errno.h>
#ifdef __QNX__
-#include <malloc.h> /* for malloc/free on QNX */
+# include <malloc.h> /* for malloc/free on QNX */
#endif
#include <stdio.h>
#include <stdlib.h>
@@ -58,42 +60,46 @@
#include <time.h>
#if defined(_WIN32) && !defined(_MSC_VER) && defined(__GNUC__)
-#include <strings.h> /* for strcasecmp */
+# include <strings.h> /* for strcasecmp */
#endif
#ifdef _MSC_VER
-#define umask _umask // Note this is still umask on Borland
+# define umask _umask // Note this is still umask on Borland
#endif
// support for realpath call
#ifndef _WIN32
-#include <limits.h>
-#include <pwd.h>
-#include <sys/ioctl.h>
-#include <sys/time.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <utime.h>
-#ifndef __VMS
-#include <sys/param.h>
-#include <termios.h>
+# include <limits.h>
+# include <pwd.h>
+# include <sys/ioctl.h>
+# include <sys/time.h>
+# include <sys/wait.h>
+# include <unistd.h>
+# include <utime.h>
+# ifndef __VMS
+# include <sys/param.h>
+# include <termios.h>
+# endif
+# include <signal.h> /* sigprocmask */
#endif
-#include <signal.h> /* sigprocmask */
+
+#ifdef __linux
+# include <linux/fs.h>
#endif
// Windows API.
#if defined(_WIN32)
-#include <windows.h>
-#include <winioctl.h>
-#ifndef INVALID_FILE_ATTRIBUTES
-#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
-#endif
-#if defined(_MSC_VER) && _MSC_VER >= 1800
-#define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-#endif
+# include <windows.h>
+# include <winioctl.h>
+# ifndef INVALID_FILE_ATTRIBUTES
+# define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
+# endif
+# if defined(_MSC_VER) && _MSC_VER >= 1800
+# define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+# endif
#elif defined(__CYGWIN__)
-#include <windows.h>
-#undef _WIN32
+# include <windows.h>
+# undef _WIN32
#endif
#if !KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H
@@ -101,17 +107,18 @@ extern char** environ;
#endif
#ifdef __CYGWIN__
-#include <sys/cygwin.h>
+# include <sys/cygwin.h>
#endif
// getpwnam doesn't exist on Windows and Cray Xt3/Catamount
// same for TIOCGWINSZ
-#if defined(_WIN32) || defined(__LIBCATAMOUNT__)
-#undef HAVE_GETPWNAM
-#undef HAVE_TTY_INFO
+#if defined(_WIN32) || defined(__LIBCATAMOUNT__) || \
+ (defined(HAVE_GETPWNAM) && HAVE_GETPWNAM == 0)
+# undef HAVE_GETPWNAM
+# undef HAVE_TTY_INFO
#else
-#define HAVE_GETPWNAM 1
-#define HAVE_TTY_INFO 1
+# define HAVE_GETPWNAM 1
+# define HAVE_TTY_INFO 1
#endif
#define VTK_URL_PROTOCOL_REGEX "([a-zA-Z0-9]*)://(.*)"
@@ -120,15 +127,15 @@ extern char** environ;
"(.+)?"
#ifdef _MSC_VER
-#include <sys/utime.h>
+# include <sys/utime.h>
#else
-#include <utime.h>
+# include <utime.h>
#endif
// This is a hack to prevent warnings about these functions being
// declared but not referenced.
#if defined(__sgi) && !defined(__GNUC__)
-#include <sys/termios.h>
+# include <sys/termios.h>
namespace KWSYS_NAMESPACE {
class SystemToolsHack
{
@@ -146,32 +153,33 @@ public:
}
#endif
-#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || \
- defined(__BORLANDC__) || defined(__MINGW32__))
-#include <direct.h>
-#include <io.h>
-#define _unlink unlink
+#if defined(_WIN32) && \
+ (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || \
+ defined(__MINGW32__))
+# include <direct.h>
+# include <io.h>
+# define _unlink unlink
#endif
/* The maximum length of a file name. */
#if defined(PATH_MAX)
-#define KWSYS_SYSTEMTOOLS_MAXPATH PATH_MAX
+# define KWSYS_SYSTEMTOOLS_MAXPATH PATH_MAX
#elif defined(MAXPATHLEN)
-#define KWSYS_SYSTEMTOOLS_MAXPATH MAXPATHLEN
+# define KWSYS_SYSTEMTOOLS_MAXPATH MAXPATHLEN
#else
-#define KWSYS_SYSTEMTOOLS_MAXPATH 16384
+# define KWSYS_SYSTEMTOOLS_MAXPATH 16384
#endif
#if defined(__WATCOMC__)
-#include <direct.h>
-#define _mkdir mkdir
-#define _rmdir rmdir
-#define _getcwd getcwd
-#define _chdir chdir
+# include <direct.h>
+# define _mkdir mkdir
+# define _rmdir rmdir
+# define _getcwd getcwd
+# define _chdir chdir
#endif
#if defined(__BEOS__) && !defined(__ZETA__)
-#include <be/kernel/OS.h>
-#include <be/storage/Path.h>
+# include <be/kernel/OS.h>
+# include <be/storage/Path.h>
// BeOS 5 doesn't have usleep(), but it has snooze(), which is identical.
static inline void usleep(unsigned int msec)
@@ -184,15 +192,15 @@ static inline char* realpath(const char* path, char* resolved_path)
{
const size_t maxlen = KWSYS_SYSTEMTOOLS_MAXPATH;
snprintf(resolved_path, maxlen, "%s", path);
- BPath normalized(resolved_path, NULL, true);
+ BPath normalized(resolved_path, nullptr, true);
const char* resolved = normalized.Path();
- if (resolved != NULL) // NULL == No such file.
+ if (resolved != nullptr) // nullptr == No such file.
{
if (snprintf(resolved_path, maxlen, "%s", resolved) < maxlen) {
return resolved_path;
}
}
- return NULL; // something went wrong.
+ return nullptr; // something went wrong.
}
#endif
@@ -212,7 +220,7 @@ static time_t windows_filetime_to_posix_time(const FILETIME& ft)
#endif
#ifdef KWSYS_WINDOWS_DIRS
-#include <wctype.h>
+# include <wctype.h>
inline int Mkdir(const std::string& dir)
{
@@ -228,23 +236,27 @@ inline const char* Getcwd(char* buf, unsigned int len)
{
std::vector<wchar_t> w_buf(len);
if (_wgetcwd(&w_buf[0], len)) {
- // make sure the drive letter is capital
- if (wcslen(&w_buf[0]) > 1 && w_buf[1] == L':') {
- w_buf[0] = towupper(w_buf[0]);
+ size_t nlen = kwsysEncoding_wcstombs(buf, &w_buf[0], len);
+ if (nlen == static_cast<size_t>(-1)) {
+ return 0;
+ }
+ if (nlen < len) {
+ // make sure the drive letter is capital
+ if (nlen > 1 && buf[1] == ':') {
+ buf[0] = toupper(buf[0]);
+ }
+ return buf;
}
- std::string tmp = KWSYS_NAMESPACE::Encoding::ToNarrow(&w_buf[0]);
- strcpy(buf, tmp.c_str());
- return buf;
}
return 0;
}
inline int Chdir(const std::string& dir)
{
-#if defined(__BORLANDC__)
+# if defined(__BORLANDC__)
return chdir(dir.c_str());
-#else
+# else
return _wchdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str());
-#endif
+# endif
}
inline void Realpath(const std::string& path, std::string& resolved_path,
std::string* errorMessage = 0)
@@ -261,12 +273,12 @@ inline void Realpath(const std::string& path, std::string& resolved_path,
if (bufferLen) {
*errorMessage = "Destination path buffer size too small.";
} else if (unsigned int errorId = GetLastError()) {
- LPSTR message = NULL;
+ LPSTR message = nullptr;
DWORD size = FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, errorId, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPSTR)&message, 0, NULL);
+ nullptr, errorId, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPSTR)&message, 0, nullptr);
*errorMessage = std::string(message, size);
LocalFree(message);
} else {
@@ -279,10 +291,10 @@ inline void Realpath(const std::string& path, std::string& resolved_path,
}
}
#else
-#include <sys/types.h>
+# include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
+# include <fcntl.h>
+# include <unistd.h>
inline int Mkdir(const std::string& dir)
{
return mkdir(dir.c_str(), 00777);
@@ -301,7 +313,7 @@ inline int Chdir(const std::string& dir)
return chdir(dir.c_str());
}
inline void Realpath(const std::string& path, std::string& resolved_path,
- std::string* errorMessage = 0)
+ std::string* errorMessage = nullptr)
{
char resolved_name[KWSYS_SYSTEMTOOLS_MAXPATH];
@@ -347,15 +359,11 @@ double SystemTools::GetTime(void)
11644473600.0);
#else
struct timeval t;
- gettimeofday(&t, 0);
+ gettimeofday(&t, nullptr);
return 1.0 * double(t.tv_sec) + 0.000001 * double(t.tv_usec);
#endif
}
-class SystemToolsTranslationMap : public std::map<std::string, std::string>
-{
-};
-
/* Type of character storing the environment. */
#if defined(_WIN32)
typedef wchar_t envchar;
@@ -381,8 +389,8 @@ struct kwsysEnvCompare
#else
const char* leq = strchr(l, '=');
const char* req = strchr(r, '=');
- size_t llen = leq ? (leq - l) : strlen(l);
- size_t rlen = req ? (req - r) : strlen(r);
+ size_t llen = leq ? static_cast<size_t>(leq - l) : strlen(l);
+ size_t rlen = req ? static_cast<size_t>(req - r) : strlen(r);
if (llen == rlen) {
return strncmp(l, r, llen) < 0;
} else {
@@ -405,11 +413,14 @@ public:
{
}
~Free() { free(const_cast<envchar*>(this->Env)); }
+
+ Free(const Free&) = delete;
+ Free& operator=(const Free&) = delete;
};
const envchar* Release(const envchar* env)
{
- const envchar* old = 0;
+ const envchar* old = nullptr;
iterator i = this->find(env);
if (i != this->end()) {
old = *i;
@@ -424,24 +435,150 @@ struct SystemToolsPathCaseCmp
{
bool operator()(std::string const& l, std::string const& r) const
{
-#ifdef _MSC_VER
+# ifdef _MSC_VER
return _stricmp(l.c_str(), r.c_str()) < 0;
-#elif defined(__GNUC__)
+# elif defined(__GNUC__)
return strcasecmp(l.c_str(), r.c_str()) < 0;
-#else
+# else
return SystemTools::Strucmp(l.c_str(), r.c_str()) < 0;
-#endif
+# endif
}
};
+#endif
-class SystemToolsPathCaseMap
- : public std::map<std::string, std::string, SystemToolsPathCaseCmp>
+/**
+ * SystemTools static variables singleton class.
+ */
+class SystemToolsStatic
{
+public:
+ typedef std::map<std::string, std::string> StringMap;
+#if KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP
+ /**
+ * Path translation table from dir to refdir
+ * Each time 'dir' will be found it will be replace by 'refdir'
+ */
+ StringMap TranslationMap;
+#endif
+#ifdef _WIN32
+ static std::string GetCasePathName(std::string const& pathIn);
+ static std::string GetActualCaseForPathCached(std::string const& path);
+ static const char* GetEnvBuffered(const char* key);
+ std::map<std::string, std::string, SystemToolsPathCaseCmp> PathCaseMap;
+ std::map<std::string, std::string> EnvMap;
+#endif
+#ifdef __CYGWIN__
+ StringMap Cyg2Win32Map;
+#endif
+
+ /**
+ * Actual implementation of ReplaceString.
+ */
+ static void ReplaceString(std::string& source, const char* replace,
+ size_t replaceSize, const std::string& with);
+
+ /**
+ * Actual implementation of FileIsFullPath.
+ */
+ static bool FileIsFullPath(const char*, size_t);
+
+ /**
+ * Find a filename (file or directory) in the system PATH, with
+ * optional extra paths.
+ */
+ static std::string FindName(
+ const std::string& name,
+ const std::vector<std::string>& path = std::vector<std::string>(),
+ bool no_system_path = false);
};
-class SystemToolsEnvMap : public std::map<std::string, std::string>
+#ifdef _WIN32
+std::string SystemToolsStatic::GetCasePathName(std::string const& pathIn)
{
-};
+ std::string casePath;
+
+ // First check if the file is relative. We don't fix relative paths since the
+ // real case depends on the root directory and the given path fragment may
+ // have meaning elsewhere in the project.
+ if (!SystemTools::FileIsFullPath(pathIn)) {
+ // This looks unnecessary, but it allows for the return value optimization
+ // since all return paths return the same local variable.
+ casePath = pathIn;
+ return casePath;
+ }
+
+ std::vector<std::string> path_components;
+ SystemTools::SplitPath(pathIn, path_components);
+
+ // Start with root component.
+ std::vector<std::string>::size_type idx = 0;
+ casePath = path_components[idx++];
+ // make sure drive letter is always upper case
+ if (casePath.size() > 1 && casePath[1] == ':') {
+ casePath[0] = toupper(casePath[0]);
+ }
+ const char* sep = "";
+
+ // If network path, fill casePath with server/share so FindFirstFile
+ // will work after that. Maybe someday call other APIs to get
+ // actual case of servers and shares.
+ if (path_components.size() > 2 && path_components[0] == "//") {
+ casePath += path_components[idx++];
+ casePath += "/";
+ casePath += path_components[idx++];
+ sep = "/";
+ }
+
+ // Convert case of all components that exist.
+ bool converting = true;
+ for (; idx < path_components.size(); idx++) {
+ casePath += sep;
+ sep = "/";
+
+ if (converting) {
+ // If path component contains wildcards, we skip matching
+ // because these filenames are not allowed on windows,
+ // and we do not want to match a different file.
+ if (path_components[idx].find('*') != std::string::npos ||
+ path_components[idx].find('?') != std::string::npos) {
+ converting = false;
+ } else {
+ std::string test_str = casePath;
+ test_str += path_components[idx];
+ WIN32_FIND_DATAW findData;
+ HANDLE hFind =
+ ::FindFirstFileW(Encoding::ToWide(test_str).c_str(), &findData);
+ if (INVALID_HANDLE_VALUE != hFind) {
+ path_components[idx] = Encoding::ToNarrow(findData.cFileName);
+ ::FindClose(hFind);
+ } else {
+ converting = false;
+ }
+ }
+ }
+
+ casePath += path_components[idx];
+ }
+ return casePath;
+}
+
+std::string SystemToolsStatic::GetActualCaseForPathCached(std::string const& p)
+{
+ // Check to see if actual case has already been called
+ // for this path, and the result is stored in the PathCaseMap
+ auto& pcm = SystemTools::Statics->PathCaseMap;
+ {
+ auto itr = pcm.find(p);
+ if (itr != pcm.end()) {
+ return itr->second;
+ }
+ }
+ std::string casePath = SystemToolsStatic::GetCasePathName(p);
+ if (casePath.size() <= MAX_PATH) {
+ pcm[p] = casePath;
+ }
+ return casePath;
+}
#endif
// adds the elements of the env variable path to the arg passed in
@@ -462,7 +599,7 @@ void SystemTools::GetPath(std::vector<std::string>& path, const char* env)
}
// A hack to make the below algorithm work.
- if (!pathEnv.empty() && *pathEnv.rbegin() != pathSep) {
+ if (!pathEnv.empty() && pathEnv.back() != pathSep) {
pathEnv += pathSep;
}
std::string::size_type start = 0;
@@ -482,30 +619,37 @@ void SystemTools::GetPath(std::vector<std::string>& path, const char* env)
}
}
-const char* SystemTools::GetEnvImpl(const char* key)
-{
- const char* v = 0;
#if defined(_WIN32)
+const char* SystemToolsStatic::GetEnvBuffered(const char* key)
+{
std::string env;
if (SystemTools::GetEnv(key, env)) {
- std::string& menv = (*SystemTools::EnvMap)[key];
- menv = env;
- v = menv.c_str();
+ std::string& menv = SystemTools::Statics->EnvMap[key];
+ if (menv != env) {
+ menv = std::move(env);
+ }
+ return menv.c_str();
}
-#else
- v = getenv(key);
-#endif
- return v;
+ return nullptr;
}
+#endif
const char* SystemTools::GetEnv(const char* key)
{
- return SystemTools::GetEnvImpl(key);
+#if defined(_WIN32)
+ return SystemToolsStatic::GetEnvBuffered(key);
+#else
+ return getenv(key);
+#endif
}
const char* SystemTools::GetEnv(const std::string& key)
{
- return SystemTools::GetEnvImpl(key.c_str());
+#if defined(_WIN32)
+ return SystemToolsStatic::GetEnvBuffered(key.c_str());
+#else
+ return getenv(key.c_str());
+#endif
}
bool SystemTools::GetEnv(const char* key, std::string& result)
@@ -540,7 +684,7 @@ bool SystemTools::HasEnv(const char* key)
#else
const char* v = getenv(key);
#endif
- return v != 0;
+ return v != nullptr;
}
bool SystemTools::HasEnv(const std::string& key)
@@ -667,9 +811,9 @@ bool SystemTools::UnPutEnv(const std::string& env)
environment values that may still reference memory we allocated. Then free
the memory. This will not affect any environment values we never set. */
-#ifdef __INTEL_COMPILER
-#pragma warning disable 444 /* base has non-virtual destructor */
-#endif
+# ifdef __INTEL_COMPILER
+# pragma warning disable 444 /* base has non-virtual destructor */
+# endif
class kwsysEnv : public kwsysEnvSet
{
@@ -677,39 +821,39 @@ public:
~kwsysEnv()
{
for (iterator i = this->begin(); i != this->end(); ++i) {
-#if defined(_WIN32)
+# if defined(_WIN32)
const std::string s = Encoding::ToNarrow(*i);
- kwsysUnPutEnv(s.c_str());
-#else
+ kwsysUnPutEnv(s);
+# else
kwsysUnPutEnv(*i);
-#endif
+# endif
free(const_cast<envchar*>(*i));
}
}
bool Put(const char* env)
{
-#if defined(_WIN32)
+# if defined(_WIN32)
const std::wstring wEnv = Encoding::ToWide(env);
wchar_t* newEnv = _wcsdup(wEnv.c_str());
-#else
+# else
char* newEnv = strdup(env);
-#endif
+# endif
Free oldEnv(this->Release(newEnv));
this->insert(newEnv);
-#if defined(_WIN32)
+# if defined(_WIN32)
return _wputenv(newEnv) == 0;
-#else
+# else
return putenv(newEnv) == 0;
-#endif
+# endif
}
bool UnPut(const char* env)
{
-#if defined(_WIN32)
+# if defined(_WIN32)
const std::wstring wEnv = Encoding::ToWide(env);
Free oldEnv(this->Release(wEnv.c_str()));
-#else
+# else
Free oldEnv(this->Release(env));
-#endif
+# endif
return kwsysUnPutEnv(env) == 0;
}
};
@@ -747,15 +891,15 @@ FILE* SystemTools::Fopen(const std::string& file, const char* mode)
#endif
}
-bool SystemTools::MakeDirectory(const char* path)
+bool SystemTools::MakeDirectory(const char* path, const mode_t* mode)
{
if (!path) {
return false;
}
- return SystemTools::MakeDirectory(std::string(path));
+ return SystemTools::MakeDirectory(std::string(path), mode);
}
-bool SystemTools::MakeDirectory(const std::string& path)
+bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode)
{
if (SystemTools::PathExists(path)) {
return SystemTools::FileIsDirectory(path);
@@ -770,8 +914,12 @@ bool SystemTools::MakeDirectory(const std::string& path)
std::string topdir;
while ((pos = dir.find('/', pos)) != std::string::npos) {
topdir = dir.substr(0, pos);
- Mkdir(topdir);
- pos++;
+
+ if (Mkdir(topdir) == 0 && mode != nullptr) {
+ SystemTools::SetPermissions(topdir, *mode);
+ }
+
+ ++pos;
}
topdir = dir;
if (Mkdir(topdir) != 0) {
@@ -783,10 +931,13 @@ bool SystemTools::MakeDirectory(const std::string& path)
#ifdef __BORLANDC__
&& (errno != EACCES)
#endif
- ) {
+ ) {
return false;
}
+ } else if (mode != nullptr) {
+ SystemTools::SetPermissions(topdir, *mode);
}
+
return true;
}
@@ -801,7 +952,8 @@ void SystemTools::ReplaceString(std::string& source,
return;
}
- SystemTools::ReplaceString(source, replace.c_str(), replace.size(), with);
+ SystemToolsStatic::ReplaceString(source, replace.c_str(), replace.size(),
+ with);
}
void SystemTools::ReplaceString(std::string& source, const char* replace,
@@ -812,12 +964,13 @@ void SystemTools::ReplaceString(std::string& source, const char* replace,
return;
}
- SystemTools::ReplaceString(source, replace, strlen(replace),
- with ? with : "");
+ SystemToolsStatic::ReplaceString(source, replace, strlen(replace),
+ with ? with : "");
}
-void SystemTools::ReplaceString(std::string& source, const char* replace,
- size_t replaceSize, const std::string& with)
+void SystemToolsStatic::ReplaceString(std::string& source, const char* replace,
+ size_t replaceSize,
+ const std::string& with)
{
const char* src = source.c_str();
char* searchPos = const_cast<char*>(strstr(src, replace));
@@ -848,15 +1001,16 @@ void SystemTools::ReplaceString(std::string& source, const char* replace,
free(orig);
}
-#if defined(KEY_WOW64_32KEY) && defined(KEY_WOW64_64KEY)
-#define KWSYS_ST_KEY_WOW64_32KEY KEY_WOW64_32KEY
-#define KWSYS_ST_KEY_WOW64_64KEY KEY_WOW64_64KEY
-#else
-#define KWSYS_ST_KEY_WOW64_32KEY 0x0200
-#define KWSYS_ST_KEY_WOW64_64KEY 0x0100
-#endif
-
#if defined(_WIN32) && !defined(__CYGWIN__)
+
+# if defined(KEY_WOW64_32KEY) && defined(KEY_WOW64_64KEY)
+# define KWSYS_ST_KEY_WOW64_32KEY KEY_WOW64_32KEY
+# define KWSYS_ST_KEY_WOW64_64KEY KEY_WOW64_64KEY
+# else
+# define KWSYS_ST_KEY_WOW64_32KEY 0x0200
+# define KWSYS_ST_KEY_WOW64_64KEY 0x0100
+# endif
+
static bool SystemToolsParseRegistryKey(const std::string& key,
HKEY& primaryKey, std::string& second,
std::string& valuename)
@@ -901,7 +1055,7 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode,
// only add the modes when on a system that supports Wow64.
static FARPROC wow64p =
GetProcAddress(GetModuleHandleW(L"kernel32"), "IsWow64Process");
- if (wow64p == NULL) {
+ if (wow64p == nullptr) {
return mode;
}
@@ -982,7 +1136,7 @@ bool SystemTools::ReadRegistryValue(const std::string& key, std::string& value,
DWORD dwType, dwSize;
dwSize = 1023;
wchar_t data[1024];
- if (RegQueryValueExW(hKey, Encoding::ToWide(valuename).c_str(), NULL,
+ if (RegQueryValueExW(hKey, Encoding::ToWide(valuename).c_str(), nullptr,
&dwType, (BYTE*)data, &dwSize) == ERROR_SUCCESS) {
if (dwType == REG_SZ) {
value = Encoding::ToNarrow(data);
@@ -1032,7 +1186,7 @@ bool SystemTools::WriteRegistryValue(const std::string& key,
wchar_t lpClass[] = L"";
if (RegCreateKeyExW(primaryKey, Encoding::ToWide(second).c_str(), 0, lpClass,
REG_OPTION_NON_VOLATILE,
- SystemToolsMakeRegistryMode(KEY_WRITE, view), NULL,
+ SystemToolsMakeRegistryMode(KEY_WRITE, view), nullptr,
&hKey, &dwDummy) != ERROR_SUCCESS) {
return false;
}
@@ -1059,7 +1213,7 @@ bool SystemTools::WriteRegistryValue(const std::string&, const std::string&,
// HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath
// => will delete the data of the "default" value of the key
// HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root
-// => will delete the data of the "Root" value of the key
+// => will delete the data of the "Root" value of the key
#if defined(_WIN32) && !defined(__CYGWIN__)
bool SystemTools::DeleteRegistryValue(const std::string& key, KeyWOW64 view)
@@ -1098,10 +1252,10 @@ bool SystemTools::SameFile(const std::string& file1, const std::string& file2)
hFile1 =
CreateFileW(Encoding::ToWide(file1).c_str(), GENERIC_READ, FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
hFile2 =
CreateFileW(Encoding::ToWide(file2).c_str(), GENERIC_READ, FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (hFile1 == INVALID_HANDLE_VALUE || hFile2 == INVALID_HANDLE_VALUE) {
if (hFile1 != INVALID_HANDLE_VALUE) {
CloseHandle(hFile1);
@@ -1182,16 +1336,34 @@ bool SystemTools::FileExists(const std::string& filename)
}
return access(filename.c_str(), R_OK) == 0;
#elif defined(_WIN32)
- return (
- GetFileAttributesW(Encoding::ToWindowsExtendedPath(filename).c_str()) !=
- INVALID_FILE_ATTRIBUTES);
+ DWORD attr =
+ GetFileAttributesW(Encoding::ToWindowsExtendedPath(filename).c_str());
+ if (attr == INVALID_FILE_ATTRIBUTES) {
+ return false;
+ }
+
+ if (attr & FILE_ATTRIBUTE_REPARSE_POINT) {
+ // Using 0 instead of GENERIC_READ as it allows reading of file attributes
+ // even if we do not have permission to read the file itself
+ HANDLE handle =
+ CreateFileW(Encoding::ToWindowsExtendedPath(filename).c_str(), 0, 0,
+ nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
+
+ if (handle == INVALID_HANDLE_VALUE) {
+ return false;
+ }
+
+ CloseHandle(handle);
+ }
+
+ return true;
#else
// SCO OpenServer 5.0.7/3.2's command has 711 permission.
-#if defined(_SCO_DS)
+# if defined(_SCO_DS)
return access(filename.c_str(), F_OK) == 0;
-#else
+# else
return access(filename.c_str(), R_OK) == 0;
-#endif
+# endif
#endif
}
@@ -1263,11 +1435,11 @@ int SystemTools::Stat(const std::string& path, SystemTools::Stat_t* buf)
// long paths, but _wstat64 rejects paths with '?' in them, thinking
// they are wildcards.
std::wstring const& wpath = Encoding::ToWide(path);
-#if defined(__BORLANDC__)
+# if defined(__BORLANDC__)
return _wstati64(wpath.c_str(), buf);
-#else
+# else
return _wstat64(wpath.c_str(), buf);
-#endif
+# endif
#else
return stat(path.c_str(), buf);
#endif
@@ -1276,18 +1448,16 @@ int SystemTools::Stat(const std::string& path, SystemTools::Stat_t* buf)
#ifdef __CYGWIN__
bool SystemTools::PathCygwinToWin32(const char* path, char* win32_path)
{
- SystemToolsTranslationMap::iterator i =
- SystemTools::Cyg2Win32Map->find(path);
-
- if (i != SystemTools::Cyg2Win32Map->end()) {
- strncpy(win32_path, i->second.c_str(), MAX_PATH);
+ auto itr = SystemTools::Statics->Cyg2Win32Map.find(path);
+ if (itr != SystemTools::Statics->Cyg2Win32Map.end()) {
+ strncpy(win32_path, itr->second.c_str(), MAX_PATH);
} else {
if (cygwin_conv_path(CCP_POSIX_TO_WIN_A, path, win32_path, MAX_PATH) !=
0) {
win32_path[0] = 0;
}
- SystemToolsTranslationMap::value_type entry(path, win32_path);
- SystemTools::Cyg2Win32Map->insert(entry);
+ SystemTools::Statics->Cyg2Win32Map.insert(
+ SystemToolsStatic::StringMap::value_type(path, win32_path));
}
return win32_path[0] != 0;
}
@@ -1322,39 +1492,15 @@ bool SystemTools::Touch(const std::string& filename, bool create)
}
CloseHandle(h);
#elif KWSYS_CXX_HAS_UTIMENSAT
- struct timespec times[2] = { { 0, UTIME_OMIT }, { 0, UTIME_NOW } };
- if (utimensat(AT_FDCWD, filename.c_str(), times, 0) < 0) {
- return false;
- }
-#else
- struct stat st;
- if (stat(filename.c_str(), &st) < 0) {
+ // utimensat is only available on newer Unixes and macOS 10.13+
+ if (utimensat(AT_FDCWD, filename.c_str(), nullptr, 0) < 0) {
return false;
}
- struct timeval mtime;
- gettimeofday(&mtime, 0);
-#if KWSYS_CXX_HAS_UTIMES
- struct timeval atime;
-#if KWSYS_CXX_STAT_HAS_ST_MTIM
- atime.tv_sec = st.st_atim.tv_sec;
- atime.tv_usec = st.st_atim.tv_nsec / 1000;
-#elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
- atime.tv_sec = st.st_atimespec.tv_sec;
- atime.tv_usec = st.st_atimespec.tv_nsec / 1000;
#else
- atime.tv_sec = st.st_atime;
- atime.tv_usec = 0;
-#endif
- struct timeval times[2] = { atime, mtime };
- if (utimes(filename.c_str(), times) < 0) {
+ // fall back to utimes
+ if (utimes(filename.c_str(), nullptr) < 0) {
return false;
}
-#else
- struct utimbuf times = { st.st_atime, mtime.tv_sec };
- if (utime(filename.c_str(), &times) < 0) {
- return false;
- }
-#endif
#endif
return true;
}
@@ -1374,7 +1520,7 @@ bool SystemTools::FileTimeCompare(const std::string& f1, const std::string& f2,
if (stat(f2.c_str(), &s2) != 0) {
return false;
}
-#if KWSYS_CXX_STAT_HAS_ST_MTIM
+# if KWSYS_CXX_STAT_HAS_ST_MTIM
// Compare using nanosecond resolution.
if (s1.st_mtim.tv_sec < s2.st_mtim.tv_sec) {
*result = -1;
@@ -1385,7 +1531,7 @@ bool SystemTools::FileTimeCompare(const std::string& f1, const std::string& f2,
} else if (s1.st_mtim.tv_nsec > s2.st_mtim.tv_nsec) {
*result = 1;
}
-#elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
+# elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
// Compare using nanosecond resolution.
if (s1.st_mtimespec.tv_sec < s2.st_mtimespec.tv_sec) {
*result = -1;
@@ -1396,14 +1542,14 @@ bool SystemTools::FileTimeCompare(const std::string& f1, const std::string& f2,
} else if (s1.st_mtimespec.tv_nsec > s2.st_mtimespec.tv_nsec) {
*result = 1;
}
-#else
+# else
// Compare using 1 second resolution.
if (s1.st_mtime < s2.st_mtime) {
*result = -1;
} else if (s1.st_mtime > s2.st_mtime) {
*result = 1;
}
-#endif
+# endif
#else
// Windows version. Get the modification time from extended file attributes.
WIN32_FILE_ATTRIBUTE_DATA f1d;
@@ -1507,7 +1653,7 @@ char* SystemTools::AppendStrings(const char* str1, const char* str2)
size_t len1 = strlen(str1);
char* newstr = new char[len1 + strlen(str2) + 1];
if (!newstr) {
- return 0;
+ return nullptr;
}
strcpy(newstr, str1);
strcat(newstr + len1, str2);
@@ -1530,7 +1676,7 @@ char* SystemTools::AppendStrings(const char* str1, const char* str2,
size_t len1 = strlen(str1), len2 = strlen(str2);
char* newstr = new char[len1 + len2 + strlen(str3) + 1];
if (!newstr) {
- return 0;
+ return nullptr;
}
strcpy(newstr, str1);
strcat(newstr + len1, str2);
@@ -1580,7 +1726,7 @@ size_t SystemTools::CountChar(const char* str, char c)
char* SystemTools::RemoveChars(const char* str, const char* toremove)
{
if (!str) {
- return NULL;
+ return nullptr;
}
char* clean_str = new char[strlen(str) + 1];
char* ptr = clean_str;
@@ -1602,7 +1748,7 @@ char* SystemTools::RemoveChars(const char* str, const char* toremove)
char* SystemTools::RemoveCharsButUpperHex(const char* str)
{
if (!str) {
- return 0;
+ return nullptr;
}
char* clean_str = new char[strlen(str) + 1];
char* ptr = clean_str;
@@ -1679,11 +1825,11 @@ bool SystemTools::StringEndsWith(const std::string& str1, const char* str2)
: false;
}
-// Returns a pointer to the last occurence of str2 in str1
+// Returns a pointer to the last occurrence of str2 in str1
const char* SystemTools::FindLastString(const char* str1, const char* str2)
{
if (!str1 || !str2) {
- return NULL;
+ return nullptr;
}
size_t len1 = strlen(str1), len2 = strlen(str2);
@@ -1696,7 +1842,7 @@ const char* SystemTools::FindLastString(const char* str1, const char* str2)
} while (ptr-- != str1);
}
- return NULL;
+ return nullptr;
}
// Duplicate string
@@ -1706,7 +1852,7 @@ char* SystemTools::DuplicateString(const char* str)
char* newstr = new char[strlen(str) + 1];
return strcpy(newstr, str);
}
- return NULL;
+ return nullptr;
}
// Return a cropped string
@@ -1737,11 +1883,11 @@ std::string SystemTools::CropString(const std::string& s, size_t max_len)
return n;
}
-std::vector<kwsys::String> SystemTools::SplitString(const std::string& p,
- char sep, bool isPath)
+std::vector<std::string> SystemTools::SplitString(const std::string& p,
+ char sep, bool isPath)
{
std::string path = p;
- std::vector<kwsys::String> paths;
+ std::vector<std::string> paths;
if (path.empty()) {
return paths;
}
@@ -1870,70 +2016,70 @@ static void ConvertVMSToUnix(std::string& path)
// convert windows slashes to unix slashes
void SystemTools::ConvertToUnixSlashes(std::string& path)
{
+ if (path.empty()) {
+ return;
+ }
+
const char* pathCString = path.c_str();
bool hasDoubleSlash = false;
#ifdef __VMS
ConvertVMSToUnix(path);
#else
const char* pos0 = pathCString;
- const char* pos1 = pathCString + 1;
for (std::string::size_type pos = 0; *pos0; ++pos) {
- // make sure we don't convert an escaped space to a unix slash
- if (*pos0 == '\\' && *pos1 != ' ') {
+ if (*pos0 == '\\') {
path[pos] = '/';
}
// Also, reuse the loop to check for slash followed by another slash
- if (*pos1 == '/' && *(pos1 + 1) == '/' && !hasDoubleSlash) {
-#ifdef _WIN32
+ if (!hasDoubleSlash && *(pos0 + 1) == '/' && *(pos0 + 2) == '/') {
+# ifdef _WIN32
// However, on windows if the first characters are both slashes,
// then keep them that way, so that network paths can be handled.
if (pos > 0) {
hasDoubleSlash = true;
}
-#else
+# else
hasDoubleSlash = true;
-#endif
+# endif
}
pos0++;
- pos1++;
}
if (hasDoubleSlash) {
SystemTools::ReplaceString(path, "//", "/");
}
#endif
+
// remove any trailing slash
- if (!path.empty()) {
- // if there is a tilda ~ then replace it with HOME
- pathCString = path.c_str();
- if (pathCString[0] == '~' &&
- (pathCString[1] == '/' || pathCString[1] == '\0')) {
- std::string homeEnv;
- if (SystemTools::GetEnv("HOME", homeEnv)) {
- path.replace(0, 1, homeEnv);
- }
+ // if there is a tilda ~ then replace it with HOME
+ pathCString = path.c_str();
+ if (pathCString[0] == '~' &&
+ (pathCString[1] == '/' || pathCString[1] == '\0')) {
+ std::string homeEnv;
+ if (SystemTools::GetEnv("HOME", homeEnv)) {
+ path.replace(0, 1, homeEnv);
}
+ }
#ifdef HAVE_GETPWNAM
- else if (pathCString[0] == '~') {
- std::string::size_type idx = path.find_first_of("/\0");
- std::string user = path.substr(1, idx - 1);
- passwd* pw = getpwnam(user.c_str());
- if (pw) {
- path.replace(0, idx, pw->pw_dir);
- }
+ else if (pathCString[0] == '~') {
+ std::string::size_type idx = path.find_first_of("/\0");
+ std::string user = path.substr(1, idx - 1);
+ passwd* pw = getpwnam(user.c_str());
+ if (pw) {
+ path.replace(0, idx, pw->pw_dir);
}
+ }
#endif
- // remove trailing slash if the path is more than
- // a single /
- pathCString = path.c_str();
- size_t size = path.size();
- if (size > 1 && *path.rbegin() == '/') {
- // if it is c:/ then do not remove the trailing slash
- if (!((size == 3 && pathCString[1] == ':'))) {
- path.resize(size - 1);
- }
+ // remove trailing slash if the path is more than
+ // a single /
+ pathCString = path.c_str();
+ size_t size = path.size();
+ if (size > 1 && path.back() == '/') {
+ // if it is c:/ then do not remove the trailing slash
+ if (!((size == 3 && pathCString[1] == ':'))) {
+ path.resize(size - 1);
}
}
}
@@ -1958,7 +2104,7 @@ std::string SystemTools::ConvertToUnixOutputPath(const std::string& path)
}
// escape spaces and () in the path
if (ret.find_first_of(" ") != std::string::npos) {
- std::string result = "";
+ std::string result;
char lastch = 1;
for (const char* ch = ret.c_str(); *ch != '\0'; ++ch) {
// if it is already escaped then don't try to escape it again
@@ -2023,24 +2169,24 @@ std::string SystemTools::ConvertToWindowsOutputPath(const std::string& path)
return ret;
}
+/**
+ * Append the filename from the path source to the directory name dir.
+ */
+static std::string FileInDir(const std::string& source, const std::string& dir)
+{
+ std::string new_destination = dir;
+ SystemTools::ConvertToUnixSlashes(new_destination);
+ return new_destination + '/' + SystemTools::GetFilenameName(source);
+}
+
bool SystemTools::CopyFileIfDifferent(const std::string& source,
const std::string& destination)
{
// special check for a destination that is a directory
// FilesDiffer does not handle file to directory compare
if (SystemTools::FileIsDirectory(destination)) {
- std::string new_destination = destination;
- SystemTools::ConvertToUnixSlashes(new_destination);
- new_destination += '/';
- std::string source_name = source;
- new_destination += SystemTools::GetFilenameName(source_name);
- if (SystemTools::FilesDiffer(source, new_destination)) {
- return SystemTools::CopyFileAlways(source, destination);
- } else {
- // the files are the same so the copy is done return
- // true
- return true;
- }
+ const std::string new_destination = FileInDir(source, destination);
+ return SystemTools::CopyFileIfDifferent(source, new_destination);
}
// source and destination are files so do a copy if they
// are different
@@ -2148,16 +2294,152 @@ bool SystemTools::FilesDiffer(const std::string& source,
return false;
}
+bool SystemTools::TextFilesDiffer(const std::string& path1,
+ const std::string& path2)
+{
+ kwsys::ifstream if1(path1.c_str());
+ kwsys::ifstream if2(path2.c_str());
+ if (!if1 || !if2) {
+ return true;
+ }
+
+ for (;;) {
+ std::string line1, line2;
+ bool hasData1 = GetLineFromStream(if1, line1);
+ bool hasData2 = GetLineFromStream(if2, line2);
+ if (hasData1 != hasData2) {
+ return true;
+ }
+ if (!hasData1) {
+ break;
+ }
+ if (line1 != line2) {
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * Blockwise copy source to destination file
+ */
+static bool CopyFileContentBlockwise(const std::string& source,
+ const std::string& destination)
+{
+// Open files
+#if defined(_WIN32)
+ kwsys::ifstream fin(
+ Encoding::ToNarrow(Encoding::ToWindowsExtendedPath(source)).c_str(),
+ std::ios::in | std::ios::binary);
+#else
+ kwsys::ifstream fin(source.c_str(), std::ios::in | std::ios::binary);
+#endif
+ if (!fin) {
+ return false;
+ }
+
+ // try and remove the destination file so that read only destination files
+ // can be written to.
+ // If the remove fails continue so that files in read only directories
+ // that do not allow file removal can be modified.
+ SystemTools::RemoveFile(destination);
+
+#if defined(_WIN32)
+ kwsys::ofstream fout(
+ Encoding::ToNarrow(Encoding::ToWindowsExtendedPath(destination)).c_str(),
+ std::ios::out | std::ios::trunc | std::ios::binary);
+#else
+ kwsys::ofstream fout(destination.c_str(),
+ std::ios::out | std::ios::trunc | std::ios::binary);
+#endif
+ if (!fout) {
+ return false;
+ }
+
+ // This copy loop is very sensitive on certain platforms with
+ // slightly broken stream libraries (like HPUX). Normally, it is
+ // incorrect to not check the error condition on the fin.read()
+ // before using the data, but the fin.gcount() will be zero if an
+ // error occurred. Therefore, the loop should be safe everywhere.
+ while (fin) {
+ const int bufferSize = 4096;
+ char buffer[bufferSize];
+
+ fin.read(buffer, bufferSize);
+ if (fin.gcount()) {
+ fout.write(buffer, fin.gcount());
+ } else {
+ break;
+ }
+ }
+
+ // Make sure the operating system has finished writing the file
+ // before closing it. This will ensure the file is finished before
+ // the check below.
+ fout.flush();
+
+ fin.close();
+ fout.close();
+
+ if (!fout) {
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Clone the source file to the destination file
+ *
+ * If available, the Linux FICLONE ioctl is used to create a check
+ * copy-on-write clone of the source file.
+ *
+ * The method returns false for the following cases:
+ * - The code has not been compiled on Linux or the ioctl was unknown
+ * - The source and destination is on different file systems
+ * - The underlying filesystem does not support file cloning
+ * - An unspecified error occurred
+ */
+static bool CloneFileContent(const std::string& source,
+ const std::string& destination)
+{
+#if defined(__linux) && defined(FICLONE)
+ int in = open(source.c_str(), O_RDONLY);
+ if (in < 0) {
+ return false;
+ }
+
+ SystemTools::RemoveFile(destination);
+
+ int out =
+ open(destination.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
+ if (out < 0) {
+ close(in);
+ return false;
+ }
+
+ int result = ioctl(out, FICLONE, in);
+ close(in);
+ close(out);
+
+ if (result < 0) {
+ return false;
+ }
+
+ return true;
+#else
+ (void)source;
+ (void)destination;
+ return false;
+#endif
+}
+
/**
* Copy a file named by "source" to the file named by "destination".
*/
bool SystemTools::CopyFileAlways(const std::string& source,
const std::string& destination)
{
- // If files are the same do not copy
- if (SystemTools::SameFile(source, destination)) {
- return true;
- }
mode_t perm = 0;
bool perms = SystemTools::GetPermissions(source, perm);
std::string real_destination = destination;
@@ -2165,9 +2447,6 @@ bool SystemTools::CopyFileAlways(const std::string& source,
if (SystemTools::FileIsDirectory(source)) {
SystemTools::MakeDirectory(destination);
} else {
- const int bufferSize = 4096;
- char buffer[bufferSize];
-
// If destination is a directory, try to create a file with the same
// name as the source in that directory.
@@ -2181,67 +2460,21 @@ bool SystemTools::CopyFileAlways(const std::string& source,
} else {
destination_dir = SystemTools::GetFilenamePath(destination);
}
+ // If files are the same do not copy
+ if (SystemTools::SameFile(source, real_destination)) {
+ return true;
+ }
// Create destination directory
SystemTools::MakeDirectory(destination_dir);
-// Open files
-#if defined(_WIN32)
- kwsys::ifstream fin(
- Encoding::ToNarrow(Encoding::ToWindowsExtendedPath(source)).c_str(),
- std::ios::in | std::ios::binary);
-#else
- kwsys::ifstream fin(source.c_str(), std::ios::in | std::ios::binary);
-#endif
- if (!fin) {
- return false;
- }
-
- // try and remove the destination file so that read only destination files
- // can be written to.
- // If the remove fails continue so that files in read only directories
- // that do not allow file removal can be modified.
- SystemTools::RemoveFile(real_destination);
-
-#if defined(_WIN32)
- kwsys::ofstream fout(
- Encoding::ToNarrow(Encoding::ToWindowsExtendedPath(real_destination))
- .c_str(),
- std::ios::out | std::ios::trunc | std::ios::binary);
-#else
- kwsys::ofstream fout(real_destination.c_str(),
- std::ios::out | std::ios::trunc | std::ios::binary);
-#endif
- if (!fout) {
- return false;
- }
-
- // This copy loop is very sensitive on certain platforms with
- // slightly broken stream libraries (like HPUX). Normally, it is
- // incorrect to not check the error condition on the fin.read()
- // before using the data, but the fin.gcount() will be zero if an
- // error occurred. Therefore, the loop should be safe everywhere.
- while (fin) {
- fin.read(buffer, bufferSize);
- if (fin.gcount()) {
- fout.write(buffer, fin.gcount());
- } else {
- break;
+ if (!CloneFileContent(source, real_destination)) {
+ // if cloning did not succeed, fall back to blockwise copy
+ if (!CopyFileContentBlockwise(source, real_destination)) {
+ return false;
}
}
-
- // Make sure the operating system has finished writing the file
- // before closing it. This will ensure the file is finished before
- // the check below.
- fout.flush();
-
- fin.close();
- fout.close();
-
- if (!fout) {
- return false;
- }
}
if (perms) {
if (!SystemTools::SetPermissions(real_destination, perm)) {
@@ -2269,11 +2502,9 @@ bool SystemTools::CopyADirectory(const std::string& source,
const std::string& destination, bool always)
{
Directory dir;
-#ifdef _WIN32
- dir.Load(Encoding::ToNarrow(Encoding::ToWindowsExtendedPath(source)));
-#else
- dir.Load(source);
-#endif
+ if (dir.Load(source) == 0) {
+ return false;
+ }
size_t fileNum;
if (!SystemTools::MakeDirectory(destination)) {
return false;
@@ -2375,205 +2606,12 @@ long int SystemTools::CreationTime(const std::string& filename)
return ct;
}
-bool SystemTools::ConvertDateMacroString(const char* str, time_t* tmt)
-{
- if (!str || !tmt || strlen(str) > 11) {
- return false;
- }
-
- struct tm tmt2;
-
- // __DATE__
- // The compilation date of the current source file. The date is a string
- // literal of the form Mmm dd yyyy. The month name Mmm is the same as for
- // dates generated by the library function asctime declared in TIME.H.
-
- // index: 012345678901
- // format: Mmm dd yyyy
- // example: Dec 19 2003
-
- static char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
-
- char buffer[12];
- strcpy(buffer, str);
-
- buffer[3] = 0;
- char* ptr = strstr(month_names, buffer);
- if (!ptr) {
- return false;
- }
-
- int month = static_cast<int>((ptr - month_names) / 3);
- int day = atoi(buffer + 4);
- int year = atoi(buffer + 7);
-
- tmt2.tm_isdst = -1;
- tmt2.tm_hour = 0;
- tmt2.tm_min = 0;
- tmt2.tm_sec = 0;
- tmt2.tm_wday = 0;
- tmt2.tm_yday = 0;
- tmt2.tm_mday = day;
- tmt2.tm_mon = month;
- tmt2.tm_year = year - 1900;
-
- *tmt = mktime(&tmt2);
- return true;
-}
-
-bool SystemTools::ConvertTimeStampMacroString(const char* str, time_t* tmt)
-{
- if (!str || !tmt || strlen(str) > 26) {
- return false;
- }
-
- struct tm tmt2;
-
- // __TIMESTAMP__
- // The date and time of the last modification of the current source file,
- // expressed as a string literal in the form Ddd Mmm Date hh:mm:ss yyyy,
- /// where Ddd is the abbreviated day of the week and Date is an integer
- // from 1 to 31.
-
- // index: 0123456789
- // 0123456789
- // 0123456789
- // format: Ddd Mmm Date hh:mm:ss yyyy
- // example: Fri Dec 19 14:34:58 2003
-
- static char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
-
- char buffer[27];
- strcpy(buffer, str);
-
- buffer[7] = 0;
- char* ptr = strstr(month_names, buffer + 4);
- if (!ptr) {
- return false;
- }
-
- int month = static_cast<int>((ptr - month_names) / 3);
- int day = atoi(buffer + 8);
- int hour = atoi(buffer + 11);
- int min = atoi(buffer + 14);
- int sec = atoi(buffer + 17);
- int year = atoi(buffer + 20);
-
- tmt2.tm_isdst = -1;
- tmt2.tm_hour = hour;
- tmt2.tm_min = min;
- tmt2.tm_sec = sec;
- tmt2.tm_wday = 0;
- tmt2.tm_yday = 0;
- tmt2.tm_mday = day;
- tmt2.tm_mon = month;
- tmt2.tm_year = year - 1900;
-
- *tmt = mktime(&tmt2);
- return true;
-}
-
std::string SystemTools::GetLastSystemError()
{
int e = errno;
return strerror(e);
}
-#ifdef _WIN32
-
-static bool IsJunction(const std::wstring& source)
-{
-#ifdef FSCTL_GET_REPARSE_POINT
- const DWORD JUNCTION_ATTRS =
- FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT;
- DWORD attrs = GetFileAttributesW(source.c_str());
- if (attrs == INVALID_FILE_ATTRIBUTES) {
- return false;
- }
- if ((attrs & JUNCTION_ATTRS) != JUNCTION_ATTRS) {
- return false;
- }
-
- // Adjust privileges so that we can succefully open junction points.
- HANDLE token;
- TOKEN_PRIVILEGES privs;
- OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token);
- LookupPrivilegeValue(NULL, SE_BACKUP_NAME, &privs.Privileges[0].Luid);
- privs.PrivilegeCount = 1;
- privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
- AdjustTokenPrivileges(token, FALSE, &privs, sizeof(TOKEN_PRIVILEGES), NULL,
- NULL);
- CloseHandle(token);
-
- HANDLE dir = CreateFileW(
- source.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING,
- FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
- if (dir == INVALID_HANDLE_VALUE) {
- return false;
- }
-
- // Query whether this is a reparse point or not.
- BYTE buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
- REPARSE_GUID_DATA_BUFFER* reparse_buffer = (REPARSE_GUID_DATA_BUFFER*)buffer;
- DWORD sentinel;
-
- BOOL success =
- DeviceIoControl(dir, FSCTL_GET_REPARSE_POINT, NULL, 0, reparse_buffer,
- MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &sentinel, NULL);
-
- CloseHandle(dir);
-
- return (success &&
- (reparse_buffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT));
-#else
- return false;
-#endif
-}
-
-static bool DeleteJunction(const std::wstring& source)
-{
-#ifdef FSCTL_DELETE_REPARSE_POINT
- // Adjust privileges so that we can succefully open junction points as
- // read/write.
- HANDLE token;
- TOKEN_PRIVILEGES privs;
- OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token);
- LookupPrivilegeValue(NULL, SE_RESTORE_NAME, &privs.Privileges[0].Luid);
- privs.PrivilegeCount = 1;
- privs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
- AdjustTokenPrivileges(token, FALSE, &privs, sizeof(TOKEN_PRIVILEGES), NULL,
- NULL);
- CloseHandle(token);
-
- HANDLE dir = CreateFileW(
- source.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
- FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
- if (dir == INVALID_HANDLE_VALUE) {
- return false;
- }
-
- // Set up the structure so that we can delete the junction.
- std::vector<BYTE> buffer(REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, 0);
- REPARSE_GUID_DATA_BUFFER* reparse_buffer =
- (REPARSE_GUID_DATA_BUFFER*)&buffer[0];
- DWORD sentinel;
-
- reparse_buffer->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
-
- BOOL success = DeviceIoControl(
- dir, FSCTL_DELETE_REPARSE_POINT, reparse_buffer,
- REPARSE_GUID_DATA_BUFFER_HEADER_SIZE, NULL, 0, &sentinel, NULL);
-
- CloseHandle(dir);
-
- return !!success;
-#else
- return false;
-#endif
-}
-
-#endif
-
bool SystemTools::RemoveFile(const std::string& source)
{
#ifdef _WIN32
@@ -2595,7 +2633,13 @@ bool SystemTools::RemoveFile(const std::string& source)
SetLastError(err);
return false;
}
- if (IsJunction(ws) && DeleteJunction(ws)) {
+
+ const DWORD DIRECTORY_SOFT_LINK_ATTRS =
+ FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT;
+ DWORD attrs = GetFileAttributesW(ws.c_str());
+ if (attrs != INVALID_FILE_ATTRIBUTES &&
+ (attrs & DIRECTORY_SOFT_LINK_ATTRS) == DIRECTORY_SOFT_LINK_ATTRS &&
+ RemoveDirectoryW(ws.c_str())) {
return true;
}
if (DeleteFileW(ws.c_str()) || GetLastError() == ERROR_FILE_NOT_FOUND ||
@@ -2626,11 +2670,7 @@ bool SystemTools::RemoveADirectory(const std::string& source)
}
Directory dir;
-#ifdef _WIN32
- dir.Load(Encoding::ToNarrow(Encoding::ToWindowsExtendedPath(source)));
-#else
dir.Load(source);
-#endif
size_t fileNum;
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) {
if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") &&
@@ -2666,9 +2706,9 @@ size_t SystemTools::GetMaximumFilePathLength()
* the system search path. Returns the full path to the file if it is
* found. Otherwise, the empty string is returned.
*/
-std::string SystemTools::FindName(const std::string& name,
- const std::vector<std::string>& userPaths,
- bool no_system_path)
+std::string SystemToolsStatic::FindName(
+ const std::string& name, const std::vector<std::string>& userPaths,
+ bool no_system_path)
{
// Add the system search path to our path first
std::vector<std::string> path;
@@ -2677,27 +2717,15 @@ std::string SystemTools::FindName(const std::string& name,
SystemTools::GetPath(path);
}
// now add the additional paths
- {
- for (std::vector<std::string>::const_iterator i = userPaths.begin();
- i != userPaths.end(); ++i) {
- path.push_back(*i);
- }
- }
- // Add a trailing slash to all paths to aid the search process.
- {
- for (std::vector<std::string>::iterator i = path.begin(); i != path.end();
- ++i) {
- std::string& p = *i;
- if (p.empty() || *p.rbegin() != '/') {
- p += "/";
- }
- }
- }
+ path.reserve(path.size() + userPaths.size());
+ path.insert(path.end(), userPaths.begin(), userPaths.end());
// now look for the file
std::string tryPath;
- for (std::vector<std::string>::const_iterator p = path.begin();
- p != path.end(); ++p) {
- tryPath = *p;
+ for (std::string const& p : path) {
+ tryPath = p;
+ if (tryPath.empty() || tryPath.back() != '/') {
+ tryPath += '/';
+ }
tryPath += name;
if (SystemTools::FileExists(tryPath)) {
return tryPath;
@@ -2716,7 +2744,8 @@ std::string SystemTools::FindFile(const std::string& name,
const std::vector<std::string>& userPaths,
bool no_system_path)
{
- std::string tryPath = SystemTools::FindName(name, userPaths, no_system_path);
+ std::string tryPath =
+ SystemToolsStatic::FindName(name, userPaths, no_system_path);
if (!tryPath.empty() && !SystemTools::FileIsDirectory(tryPath)) {
return SystemTools::CollapseFullPath(tryPath);
}
@@ -2733,7 +2762,8 @@ std::string SystemTools::FindDirectory(
const std::string& name, const std::vector<std::string>& userPaths,
bool no_system_path)
{
- std::string tryPath = SystemTools::FindName(name, userPaths, no_system_path);
+ std::string tryPath =
+ SystemToolsStatic::FindName(name, userPaths, no_system_path);
if (!tryPath.empty() && SystemTools::FileIsDirectory(tryPath)) {
return SystemTools::CollapseFullPath(tryPath);
}
@@ -2769,14 +2799,13 @@ std::string SystemTools::FindProgram(const std::string& name,
// the end of it
// on windows try .com then .exe
if (name.size() <= 3 || name[name.size() - 4] != '.') {
- extensions.push_back(".com");
- extensions.push_back(".exe");
+ extensions.emplace_back(".com");
+ extensions.emplace_back(".exe");
// first try with extensions if the os supports them
- for (std::vector<std::string>::iterator i = extensions.begin();
- i != extensions.end(); ++i) {
+ for (std::string const& ext : extensions) {
tryPath = name;
- tryPath += *i;
+ tryPath += ext;
if (SystemTools::FileExists(tryPath, true)) {
return SystemTools::CollapseFullPath(tryPath);
}
@@ -2795,43 +2824,33 @@ std::string SystemTools::FindProgram(const std::string& name,
SystemTools::GetPath(path);
}
// now add the additional paths
- {
- for (std::vector<std::string>::const_iterator i = userPaths.begin();
- i != userPaths.end(); ++i) {
- path.push_back(*i);
- }
- }
+ path.reserve(path.size() + userPaths.size());
+ path.insert(path.end(), userPaths.begin(), userPaths.end());
// Add a trailing slash to all paths to aid the search process.
- {
- for (std::vector<std::string>::iterator i = path.begin(); i != path.end();
- ++i) {
- std::string& p = *i;
- if (p.empty() || *p.rbegin() != '/') {
- p += "/";
- }
+ for (std::string& p : path) {
+ if (p.empty() || p.back() != '/') {
+ p += '/';
}
}
// Try each path
- for (std::vector<std::string>::iterator p = path.begin(); p != path.end();
- ++p) {
+ for (std::string& p : path) {
#ifdef _WIN32
// Remove double quotes from the path on windows
- SystemTools::ReplaceString(*p, "\"", "");
+ SystemTools::ReplaceString(p, "\"", "");
#endif
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
// first try with extensions
- for (std::vector<std::string>::iterator ext = extensions.begin();
- ext != extensions.end(); ++ext) {
- tryPath = *p;
+ for (std::string const& ext : extensions) {
+ tryPath = p;
tryPath += name;
- tryPath += *ext;
+ tryPath += ext;
if (SystemTools::FileExists(tryPath, true)) {
return SystemTools::CollapseFullPath(tryPath);
}
}
#endif
// now try it without them
- tryPath = *p;
+ tryPath = p;
tryPath += name;
if (SystemTools::FileExists(tryPath, true)) {
return SystemTools::CollapseFullPath(tryPath);
@@ -2845,10 +2864,9 @@ std::string SystemTools::FindProgram(const std::vector<std::string>& names,
const std::vector<std::string>& path,
bool noSystemPath)
{
- for (std::vector<std::string>::const_iterator it = names.begin();
- it != names.end(); ++it) {
+ for (std::string const& name : names) {
// Try to find the program.
- std::string result = SystemTools::FindProgram(*it, path, noSystemPath);
+ std::string result = SystemTools::FindProgram(name, path, noSystemPath);
if (!result.empty()) {
return result;
}
@@ -2873,27 +2891,18 @@ std::string SystemTools::FindLibrary(const std::string& name,
std::vector<std::string> path;
SystemTools::GetPath(path);
// now add the additional paths
- {
- for (std::vector<std::string>::const_iterator i = userPaths.begin();
- i != userPaths.end(); ++i) {
- path.push_back(*i);
- }
- }
+ path.reserve(path.size() + userPaths.size());
+ path.insert(path.end(), userPaths.begin(), userPaths.end());
// Add a trailing slash to all paths to aid the search process.
- {
- for (std::vector<std::string>::iterator i = path.begin(); i != path.end();
- ++i) {
- std::string& p = *i;
- if (p.empty() || *p.rbegin() != '/') {
- p += "/";
- }
+ for (std::string& p : path) {
+ if (p.empty() || p.back() != '/') {
+ p += '/';
}
}
std::string tryPath;
- for (std::vector<std::string>::const_iterator p = path.begin();
- p != path.end(); ++p) {
+ for (std::string const& p : path) {
#if defined(__APPLE__)
- tryPath = *p;
+ tryPath = p;
tryPath += name;
tryPath += ".framework";
if (SystemTools::FileIsDirectory(tryPath)) {
@@ -2901,42 +2910,42 @@ std::string SystemTools::FindLibrary(const std::string& name,
}
#endif
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
- tryPath = *p;
+ tryPath = p;
tryPath += name;
tryPath += ".lib";
if (SystemTools::FileExists(tryPath, true)) {
return SystemTools::CollapseFullPath(tryPath);
}
#else
- tryPath = *p;
+ tryPath = p;
tryPath += "lib";
tryPath += name;
tryPath += ".so";
if (SystemTools::FileExists(tryPath, true)) {
return SystemTools::CollapseFullPath(tryPath);
}
- tryPath = *p;
+ tryPath = p;
tryPath += "lib";
tryPath += name;
tryPath += ".a";
if (SystemTools::FileExists(tryPath, true)) {
return SystemTools::CollapseFullPath(tryPath);
}
- tryPath = *p;
+ tryPath = p;
tryPath += "lib";
tryPath += name;
tryPath += ".sl";
if (SystemTools::FileExists(tryPath, true)) {
return SystemTools::CollapseFullPath(tryPath);
}
- tryPath = *p;
+ tryPath = p;
tryPath += "lib";
tryPath += name;
tryPath += ".dylib";
if (SystemTools::FileExists(tryPath, true)) {
return SystemTools::CollapseFullPath(tryPath);
}
- tryPath = *p;
+ tryPath = p;
tryPath += "lib";
tryPath += name;
tryPath += ".dll";
@@ -3001,10 +3010,36 @@ bool SystemTools::FileIsDirectory(const std::string& inName)
bool SystemTools::FileIsSymlink(const std::string& name)
{
#if defined(_WIN32)
- DWORD attr =
- GetFileAttributesW(Encoding::ToWindowsExtendedPath(name).c_str());
+ std::wstring path = Encoding::ToWindowsExtendedPath(name);
+ DWORD attr = GetFileAttributesW(path.c_str());
if (attr != INVALID_FILE_ATTRIBUTES) {
- return (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0;
+ if ((attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
+ // FILE_ATTRIBUTE_REPARSE_POINT means:
+ // * a file or directory that has an associated reparse point, or
+ // * a file that is a symbolic link.
+ HANDLE hFile = CreateFileW(
+ path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING,
+ FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, nullptr);
+ if (hFile == INVALID_HANDLE_VALUE) {
+ return false;
+ }
+ byte buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
+ DWORD bytesReturned = 0;
+ if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, nullptr, 0, buffer,
+ MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bytesReturned,
+ nullptr)) {
+ CloseHandle(hFile);
+ // Since FILE_ATTRIBUTE_REPARSE_POINT is set this file must be
+ // a symbolic link if it is not a reparse point.
+ return GetLastError() == ERROR_NOT_A_REPARSE_POINT;
+ }
+ CloseHandle(hFile);
+ ULONG reparseTag =
+ reinterpret_cast<PREPARSE_GUID_DATA_BUFFER>(&buffer[0])->ReparseTag;
+ return (reparseTag == IO_REPARSE_TAG_SYMLINK) ||
+ (reparseTag == IO_REPARSE_TAG_MOUNT_POINT);
+ }
+ return false;
} else {
return false;
}
@@ -3023,7 +3058,7 @@ bool SystemTools::FileIsFIFO(const std::string& name)
#if defined(_WIN32)
HANDLE hFile =
CreateFileW(Encoding::ToWide(name).c_str(), GENERIC_READ, FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (hFile == INVALID_HANDLE_VALUE) {
return false;
}
@@ -3172,9 +3207,8 @@ bool SystemTools::FindProgramPath(const char* argv0, std::string& pathOut,
msg << " argv[0] = \"" << argv0 << "\"\n";
}
msg << " Attempted paths:\n";
- std::vector<std::string>::iterator i;
- for (i = failures.begin(); i != failures.end(); ++i) {
- msg << " \"" << *i << "\"\n";
+ for (std::string const& ff : failures) {
+ msg << " \"" << ff << "\"\n";
}
errorMsg = msg.str();
return false;
@@ -3185,9 +3219,10 @@ bool SystemTools::FindProgramPath(const char* argv0, std::string& pathOut,
std::string SystemTools::CollapseFullPath(const std::string& in_relative)
{
- return SystemTools::CollapseFullPath(in_relative, 0);
+ return SystemTools::CollapseFullPath(in_relative, nullptr);
}
+#if KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP
void SystemTools::AddTranslationPath(const std::string& a,
const std::string& b)
{
@@ -3204,15 +3239,16 @@ void SystemTools::AddTranslationPath(const std::string& a,
if (SystemTools::FileIsFullPath(path_b) &&
path_b.find("..") == std::string::npos) {
// Before inserting make sure path ends with '/'
- if (!path_a.empty() && *path_a.rbegin() != '/') {
+ if (!path_a.empty() && path_a.back() != '/') {
path_a += '/';
}
- if (!path_b.empty() && *path_b.rbegin() != '/') {
+ if (!path_b.empty() && path_b.back() != '/') {
path_b += '/';
}
if (!(path_a == path_b)) {
- SystemTools::TranslationMap->insert(
- SystemToolsTranslationMap::value_type(path_a, path_b));
+ SystemTools::Statics->TranslationMap.insert(
+ SystemToolsStatic::StringMap::value_type(std::move(path_a),
+ std::move(path_b)));
}
}
}
@@ -3221,7 +3257,7 @@ void SystemTools::AddTranslationPath(const std::string& a,
void SystemTools::AddKeepPath(const std::string& dir)
{
std::string cdir;
- Realpath(SystemTools::CollapseFullPath(dir).c_str(), cdir);
+ Realpath(SystemTools::CollapseFullPath(dir), cdir);
SystemTools::AddTranslationPath(cdir, dir);
}
@@ -3236,37 +3272,41 @@ void SystemTools::CheckTranslationPath(std::string& path)
// Always add a trailing slash before translation. It does not
// matter if this adds an extra slash, but we do not want to
// translate part of a directory (like the foo part of foo-dir).
- path += "/";
+ path += '/';
// In case a file was specified we still have to go through this:
// Now convert any path found in the table back to the one desired:
- std::map<std::string, std::string>::const_iterator it;
- for (it = SystemTools::TranslationMap->begin();
- it != SystemTools::TranslationMap->end(); ++it) {
+ for (auto const& pair : SystemTools::Statics->TranslationMap) {
// We need to check of the path is a substring of the other path
- if (path.find(it->first) == 0) {
- path = path.replace(0, it->first.size(), it->second);
+ if (path.find(pair.first) == 0) {
+ path = path.replace(0, pair.first.size(), pair.second);
}
}
// Remove the trailing slash we added before.
- path.erase(path.end() - 1, path.end());
+ path.pop_back();
}
+#endif
static void SystemToolsAppendComponents(
std::vector<std::string>& out_components,
- std::vector<std::string>::const_iterator first,
- std::vector<std::string>::const_iterator last)
+ std::vector<std::string>::iterator first,
+ std::vector<std::string>::iterator last)
{
static const std::string up = "..";
static const std::string cur = ".";
for (std::vector<std::string>::const_iterator i = first; i != last; ++i) {
if (*i == up) {
- if (out_components.size() > 1) {
+ // Remove the previous component if possible. Ignore ../ components
+ // that try to go above the root. Keep ../ components if they are
+ // at the beginning of a relative path (base path is relative).
+ if (out_components.size() > 1 && out_components.back() != up) {
out_components.resize(out_components.size() - 1);
+ } else if (!out_components.empty() && out_components[0].empty()) {
+ out_components.emplace_back(std::move(*i));
}
} else if (!i->empty() && *i != cur) {
- out_components.push_back(*i);
+ out_components.emplace_back(std::move(*i));
}
}
}
@@ -3274,63 +3314,18 @@ static void SystemToolsAppendComponents(
std::string SystemTools::CollapseFullPath(const std::string& in_path,
const char* in_base)
{
- // Collect the output path components.
- std::vector<std::string> out_components;
-
- // Split the input path components.
- std::vector<std::string> path_components;
- SystemTools::SplitPath(in_path, path_components);
-
- // If the input path is relative, start with a base path.
- if (path_components[0].empty()) {
- std::vector<std::string> base_components;
- if (in_base) {
- // Use the given base path.
- SystemTools::SplitPath(in_base, base_components);
+ // Use the current working directory as a base path.
+ char buf[2048];
+ const char* res_in_base = in_base;
+ if (!res_in_base) {
+ if (const char* cwd = Getcwd(buf, 2048)) {
+ res_in_base = cwd;
} else {
- // Use the current working directory as a base path.
- char buf[2048];
- if (const char* cwd = Getcwd(buf, 2048)) {
- SystemTools::SplitPath(cwd, base_components);
- } else {
- base_components.push_back("");
- }
+ res_in_base = "";
}
-
- // Append base path components to the output path.
- out_components.push_back(base_components[0]);
- SystemToolsAppendComponents(out_components, base_components.begin() + 1,
- base_components.end());
}
- // Append input path components to the output path.
- SystemToolsAppendComponents(out_components, path_components.begin(),
- path_components.end());
-
- // Transform the path back to a string.
- std::string newPath = SystemTools::JoinPath(out_components);
-
- // Update the translation table with this potentially new path. I am not
- // sure why this line is here, it seems really questionable, but yet I
- // would put good money that if I remove it something will break, basically
- // from what I can see it created a mapping from the collapsed path, to be
- // replaced by the input path, which almost completely does the opposite of
- // this function, the only thing preventing this from happening a lot is
- // that if the in_path has a .. in it, then it is not added to the
- // translation table. So for most calls this either does nothing due to the
- // .. or it adds a translation between identical paths as nothing was
- // collapsed, so I am going to try to comment it out, and see what hits the
- // fan, hopefully quickly.
- // Commented out line below:
- // SystemTools::AddTranslationPath(newPath, in_path);
-
- SystemTools::CheckTranslationPath(newPath);
-#ifdef _WIN32
- newPath = SystemTools::GetActualCaseForPath(newPath);
- SystemTools::ConvertToUnixSlashes(newPath);
-#endif
- // Return the reconstructed path.
- return newPath;
+ return SystemTools::CollapseFullPath(in_path, std::string(res_in_base));
}
std::string SystemTools::CollapseFullPath(const std::string& in_path,
@@ -3342,9 +3337,10 @@ std::string SystemTools::CollapseFullPath(const std::string& in_path,
// Split the input path components.
std::vector<std::string> path_components;
SystemTools::SplitPath(in_path, path_components);
+ out_components.reserve(path_components.size());
// If the input path is relative, start with a base path.
- if (path_components[0].length() == 0) {
+ if (path_components[0].empty()) {
std::vector<std::string> base_components;
// Use the given base path.
SystemTools::SplitPath(in_base, base_components);
@@ -3362,6 +3358,7 @@ std::string SystemTools::CollapseFullPath(const std::string& in_path,
// Transform the path back to a string.
std::string newPath = SystemTools::JoinPath(out_components);
+#if KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP
// Update the translation table with this potentially new path. I am not
// sure why this line is here, it seems really questionable, but yet I
// would put good money that if I remove it something will break, basically
@@ -3377,8 +3374,9 @@ std::string SystemTools::CollapseFullPath(const std::string& in_path,
// SystemTools::AddTranslationPath(newPath, in_path);
SystemTools::CheckTranslationPath(newPath);
+#endif
#ifdef _WIN32
- newPath = SystemTools::GetActualCaseForPath(newPath);
+ newPath = SystemTools::Statics->GetActualCaseForPathCached(newPath);
SystemTools::ConvertToUnixSlashes(newPath);
#endif
// Return the reconstructed path.
@@ -3400,25 +3398,24 @@ std::string SystemTools::RelativePath(const std::string& local,
std::string r = SystemTools::CollapseFullPath(remote);
// split up both paths into arrays of strings using / as a separator
- std::vector<kwsys::String> localSplit =
- SystemTools::SplitString(l, '/', true);
- std::vector<kwsys::String> remoteSplit =
+ std::vector<std::string> localSplit = SystemTools::SplitString(l, '/', true);
+ std::vector<std::string> remoteSplit =
SystemTools::SplitString(r, '/', true);
- std::vector<kwsys::String>
+ std::vector<std::string>
commonPath; // store shared parts of path in this array
- std::vector<kwsys::String> finalPath; // store the final relative path here
+ std::vector<std::string> finalPath; // store the final relative path here
// count up how many matching directory names there are from the start
unsigned int sameCount = 0;
while (((sameCount <= (localSplit.size() - 1)) &&
(sameCount <= (remoteSplit.size() - 1))) &&
-// for windows and apple do a case insensitive string compare
+// for Windows and Apple do a case insensitive string compare
#if defined(_WIN32) || defined(__APPLE__)
SystemTools::Strucmp(localSplit[sameCount].c_str(),
remoteSplit[sameCount].c_str()) == 0
#else
localSplit[sameCount] == remoteSplit[sameCount]
#endif
- ) {
+ ) {
// put the common parts of the path into the commonPath array
commonPath.push_back(localSplit[sameCount]);
// erase the common parts of the path from the original path arrays
@@ -3439,115 +3436,36 @@ std::string SystemTools::RelativePath(const std::string& local,
// for each entry that is not common in the local path
// add a ../ to the finalpath array, this gets us out of the local
// path into the remote dir
- for (unsigned int i = 0; i < localSplit.size(); ++i) {
- if (!localSplit[i].empty()) {
- finalPath.push_back("../");
+ for (std::string const& lp : localSplit) {
+ if (!lp.empty()) {
+ finalPath.emplace_back("../");
}
}
// for each entry that is not common in the remote path add it
// to the final path.
- for (std::vector<String>::iterator vit = remoteSplit.begin();
- vit != remoteSplit.end(); ++vit) {
- if (!vit->empty()) {
- finalPath.push_back(*vit);
+ for (std::string const& rp : remoteSplit) {
+ if (!rp.empty()) {
+ finalPath.push_back(rp);
}
}
std::string relativePath; // result string
// now turn the array of directories into a unix path by puttint /
// between each entry that does not already have one
- for (std::vector<String>::iterator vit1 = finalPath.begin();
- vit1 != finalPath.end(); ++vit1) {
- if (!relativePath.empty() && *relativePath.rbegin() != '/') {
- relativePath += "/";
+ for (std::string const& fp : finalPath) {
+ if (!relativePath.empty() && relativePath.back() != '/') {
+ relativePath += '/';
}
- relativePath += *vit1;
+ relativePath += fp;
}
return relativePath;
}
-#ifdef _WIN32
-static std::string GetCasePathName(std::string const& pathIn)
-{
- std::string casePath;
- std::vector<std::string> path_components;
- SystemTools::SplitPath(pathIn, path_components);
- if (path_components[0].empty()) // First component always exists.
- {
- // Relative paths cannot be converted.
- casePath = pathIn;
- return casePath;
- }
-
- // Start with root component.
- std::vector<std::string>::size_type idx = 0;
- casePath = path_components[idx++];
- // make sure drive letter is always upper case
- if (casePath.size() > 1 && casePath[1] == ':') {
- casePath[0] = toupper(casePath[0]);
- }
- const char* sep = "";
-
- // If network path, fill casePath with server/share so FindFirstFile
- // will work after that. Maybe someday call other APIs to get
- // actual case of servers and shares.
- if (path_components.size() > 2 && path_components[0] == "//") {
- casePath += path_components[idx++];
- casePath += "/";
- casePath += path_components[idx++];
- sep = "/";
- }
-
- // Convert case of all components that exist.
- bool converting = true;
- for (; idx < path_components.size(); idx++) {
- casePath += sep;
- sep = "/";
-
- if (converting) {
- // If path component contains wildcards, we skip matching
- // because these filenames are not allowed on windows,
- // and we do not want to match a different file.
- if (path_components[idx].find('*') != std::string::npos ||
- path_components[idx].find('?') != std::string::npos) {
- converting = false;
- } else {
- std::string test_str = casePath;
- test_str += path_components[idx];
- WIN32_FIND_DATAW findData;
- HANDLE hFind =
- ::FindFirstFileW(Encoding::ToWide(test_str).c_str(), &findData);
- if (INVALID_HANDLE_VALUE != hFind) {
- path_components[idx] = Encoding::ToNarrow(findData.cFileName);
- ::FindClose(hFind);
- } else {
- converting = false;
- }
- }
- }
-
- casePath += path_components[idx];
- }
- return casePath;
-}
-#endif
-
std::string SystemTools::GetActualCaseForPath(const std::string& p)
{
-#ifndef _WIN32
- return p;
+#ifdef _WIN32
+ return SystemToolsStatic::GetCasePathName(p);
#else
- // Check to see if actual case has already been called
- // for this path, and the result is stored in the PathCaseMap
- SystemToolsPathCaseMap::iterator i = SystemTools::PathCaseMap->find(p);
- if (i != SystemTools::PathCaseMap->end()) {
- return i->second;
- }
- std::string casePath = GetCasePathName(p);
- if (casePath.size() > MAX_PATH) {
- return casePath;
- }
- (*SystemTools::PathCaseMap)[p] = casePath;
- return casePath;
+ return p;
#endif
}
@@ -3647,7 +3565,7 @@ void SystemTools::SplitPath(const std::string& p,
}
#endif
if (!homedir.empty() &&
- (*homedir.rbegin() == '/' || *homedir.rbegin() == '\\')) {
+ (homedir.back() == '/' || homedir.back() == '\\')) {
homedir.resize(homedir.size() - 1);
}
SystemTools::SplitPath(homedir, components);
@@ -3685,8 +3603,7 @@ std::string SystemTools::JoinPath(
// Construct result in a single string.
std::string result;
size_t len = 0;
- std::vector<std::string>::const_iterator i;
- for (i = first; i != last; ++i) {
+ for (std::vector<std::string>::const_iterator i = first; i != last; ++i) {
len += 1 + i->size();
}
result.reserve(len);
@@ -3701,7 +3618,7 @@ std::string SystemTools::JoinPath(
// All remaining components are always separated with a slash.
while (first != last) {
- result.append("/");
+ result.push_back('/');
result.append((*first++));
}
@@ -3709,26 +3626,16 @@ std::string SystemTools::JoinPath(
return result;
}
-void SystemTools::RemoveEmptyPathElements(std::vector<std::string>& path)
-{
- if (path.empty()) {
- return;
- }
-
- path.erase(std::remove(path.begin() + 1, path.end(), std::string("")),
- path.end());
-}
-
bool SystemTools::ComparePath(const std::string& c1, const std::string& c2)
{
#if defined(_WIN32) || defined(__APPLE__)
-#ifdef _MSC_VER
+# ifdef _MSC_VER
return _stricmp(c1.c_str(), c2.c_str()) == 0;
-#elif defined(__APPLE__) || defined(__GNUC__)
+# elif defined(__APPLE__) || defined(__GNUC__)
return strcasecmp(c1.c_str(), c2.c_str()) == 0;
-#else
+# else
return SystemTools::Strucmp(c1.c_str(), c2.c_str()) == 0;
-#endif
+# endif
#else
return c1 == c2;
#endif
@@ -3742,11 +3649,11 @@ bool SystemTools::Split(const std::string& str,
while (lpos < data.length()) {
std::string::size_type rpos = data.find_first_of(separator, lpos);
if (rpos == std::string::npos) {
- // Line ends at end of string without a newline.
+ // String ends at end of string without a separator.
lines.push_back(data.substr(lpos));
return false;
} else {
- // Line ends in a "\n", remove the character.
+ // String ends in a separator, remove the character.
lines.push_back(data.substr(lpos, rpos - lpos));
}
lpos = rpos + 1;
@@ -3760,7 +3667,7 @@ bool SystemTools::Split(const std::string& str,
std::string data(str);
std::string::size_type lpos = 0;
while (lpos < data.length()) {
- std::string::size_type rpos = data.find_first_of("\n", lpos);
+ std::string::size_type rpos = data.find_first_of('\n', lpos);
if (rpos == std::string::npos) {
// Line ends at end of string without a newline.
lines.push_back(data.substr(lpos));
@@ -3807,11 +3714,12 @@ std::string SystemTools::GetFilenamePath(const std::string& filename)
*/
std::string SystemTools::GetFilenameName(const std::string& filename)
{
-#if defined(_WIN32)
- std::string::size_type slash_pos = filename.find_last_of("/\\");
+#if defined(_WIN32) || defined(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES)
+ const char* separators = "/\\";
#else
- std::string::size_type slash_pos = filename.rfind('/');
+ char separators = '/';
#endif
+ std::string::size_type slash_pos = filename.find_last_of(separators);
if (slash_pos != std::string::npos) {
return filename.substr(slash_pos + 1);
} else {
@@ -4024,7 +3932,7 @@ bool SystemTools::LocateFileInDir(const char* filename, const char* dir,
filename_dir = SystemTools::GetFilenamePath(filename_dir);
filename_dir_base = SystemTools::GetFilenameName(filename_dir);
#if defined(_WIN32)
- if (filename_dir_base.empty() || *filename_dir_base.rbegin() == ':')
+ if (filename_dir_base.empty() || filename_dir_base.back() == ':')
#else
if (filename_dir_base.empty())
#endif
@@ -4052,16 +3960,16 @@ bool SystemTools::LocateFileInDir(const char* filename, const char* dir,
bool SystemTools::FileIsFullPath(const std::string& in_name)
{
- return SystemTools::FileIsFullPath(in_name.c_str(), in_name.size());
+ return SystemToolsStatic::FileIsFullPath(in_name.c_str(), in_name.size());
}
bool SystemTools::FileIsFullPath(const char* in_name)
{
- return SystemTools::FileIsFullPath(in_name,
- in_name[0] ? (in_name[1] ? 2 : 1) : 0);
+ return SystemToolsStatic::FileIsFullPath(
+ in_name, in_name[0] ? (in_name[1] ? 2 : 1) : 0);
}
-bool SystemTools::FileIsFullPath(const char* in_name, size_t len)
+bool SystemToolsStatic::FileIsFullPath(const char* in_name, size_t len)
{
#if defined(_WIN32) || defined(__CYGWIN__)
// On Windows, the name must be at least two characters long.
@@ -4100,12 +4008,12 @@ bool SystemTools::GetShortPath(const std::string& path, std::string& shortPath)
std::string tempPath = path; // create a buffer
// if the path passed in has quotes around it, first remove the quotes
- if (!path.empty() && path[0] == '"' && *path.rbegin() == '"') {
+ if (!path.empty() && path[0] == '"' && path.back() == '"') {
tempPath = path.substr(1, path.length() - 2);
}
std::wstring wtempPath = Encoding::ToWide(tempPath);
- DWORD ret = GetShortPathNameW(wtempPath.c_str(), NULL, 0);
+ DWORD ret = GetShortPathNameW(wtempPath.c_str(), nullptr, 0);
std::vector<wchar_t> buffer(ret);
if (ret != 0) {
ret = GetShortPathNameW(wtempPath.c_str(), &buffer[0],
@@ -4124,66 +4032,6 @@ bool SystemTools::GetShortPath(const std::string& path, std::string& shortPath)
#endif
}
-void SystemTools::SplitProgramFromArgs(const std::string& path,
- std::string& program, std::string& args)
-{
- // see if this is a full path to a program
- // if so then set program to path and args to nothing
- if (SystemTools::FileExists(path)) {
- program = path;
- args = "";
- return;
- }
- // Try to find the program in the path, note the program
- // may have spaces in its name so we have to look for it
- std::vector<std::string> e;
- std::string findProg = SystemTools::FindProgram(path, e);
- if (!findProg.empty()) {
- program = findProg;
- args = "";
- return;
- }
-
- // Now try and peel off space separated chunks from the end of the string
- // so the largest path possible is found allowing for spaces in the path
- std::string dir = path;
- std::string::size_type spacePos = dir.rfind(' ');
- while (spacePos != std::string::npos) {
- std::string tryProg = dir.substr(0, spacePos);
- // See if the file exists
- if (SystemTools::FileExists(tryProg)) {
- program = tryProg;
- // remove trailing spaces from program
- std::string::size_type pos = program.size() - 1;
- while (program[pos] == ' ') {
- program.erase(pos);
- pos--;
- }
- args = dir.substr(spacePos, dir.size() - spacePos);
- return;
- }
- // Now try and find the program in the path
- findProg = SystemTools::FindProgram(tryProg, e);
- if (!findProg.empty()) {
- program = findProg;
- // remove trailing spaces from program
- std::string::size_type pos = program.size() - 1;
- while (program[pos] == ' ') {
- program.erase(pos);
- pos--;
- }
- args = dir.substr(spacePos, dir.size() - spacePos);
- return;
- }
- // move past the space for the next search
- spacePos--;
- spacePos = dir.rfind(' ', spacePos);
- }
-
- program = "";
- args = "";
-}
-
std::string SystemTools::GetCurrentDateTime(const char* format)
{
char buf[1024];
@@ -4212,23 +4060,16 @@ std::string SystemTools::MakeCidentifier(const std::string& s)
return str;
}
-// Due to a buggy stream library on the HP and another on Mac OS X, we
-// need this very carefully written version of getline. Returns true
+// Convenience function around std::getline which removes a trailing carriage
+// return and can truncate the buffer as needed. Returns true
// if any data were read before the end-of-file was reached.
bool SystemTools::GetLineFromStream(std::istream& is, std::string& line,
bool* has_newline /* = 0 */,
long sizeLimit /* = -1 */)
{
- const int bufferSize = 1024;
- char buffer[bufferSize];
- bool haveData = false;
- bool haveNewline = false;
-
// Start with an empty line.
line = "";
- long leftToRead = sizeLimit;
-
// Early short circuit return if stream is no good. Just return
// false and the empty line. (Probably means caller tried to
// create a file stream with a non-existent file name...)
@@ -4240,44 +4081,23 @@ bool SystemTools::GetLineFromStream(std::istream& is, std::string& line,
return false;
}
- // If no characters are read from the stream, the end of file has
- // been reached. Clear the fail bit just before reading.
- while (!haveNewline && leftToRead != 0 &&
- (static_cast<void>(is.clear(is.rdstate() & ~std::ios::failbit)),
- static_cast<void>(is.getline(buffer, bufferSize)),
- is.gcount() > 0)) {
- // We have read at least one byte.
- haveData = true;
-
- // If newline character was read the gcount includes the character
- // but the buffer does not: the end of line has been reached.
- size_t length = strlen(buffer);
- if (length < static_cast<size_t>(is.gcount())) {
- haveNewline = true;
- }
-
+ std::getline(is, line);
+ bool haveData = !line.empty() || !is.eof();
+ if (!line.empty()) {
// Avoid storing a carriage return character.
- if (length > 0 && buffer[length - 1] == '\r') {
- buffer[length - 1] = 0;
+ if (line.back() == '\r') {
+ line.resize(line.size() - 1);
}
// if we read too much then truncate the buffer
- if (leftToRead > 0) {
- if (static_cast<long>(length) > leftToRead) {
- buffer[leftToRead] = 0;
- leftToRead = 0;
- } else {
- leftToRead -= static_cast<long>(length);
- }
+ if (sizeLimit >= 0 && line.size() >= static_cast<size_t>(sizeLimit)) {
+ line.resize(sizeLimit);
}
-
- // Append the data read to the line.
- line.append(buffer);
}
// Return the results.
if (has_newline) {
- *has_newline = haveNewline;
+ *has_newline = !is.eof();
}
return haveData;
}
@@ -4338,8 +4158,9 @@ bool SystemTools::GetPermissions(const std::string& file, mode_t& mode)
}
size_t dotPos = file.rfind('.');
const char* ext = dotPos == std::string::npos ? 0 : (file.c_str() + dotPos);
- if (ext && (Strucmp(ext, ".exe") == 0 || Strucmp(ext, ".com") == 0 ||
- Strucmp(ext, ".cmd") == 0 || Strucmp(ext, ".bat") == 0)) {
+ if (ext &&
+ (Strucmp(ext, ".exe") == 0 || Strucmp(ext, ".com") == 0 ||
+ Strucmp(ext, ".cmd") == 0 || Strucmp(ext, ".bat") == 0)) {
mode |= (_S_IEXEC | (_S_IEXEC >> 3) | (_S_IEXEC >> 6));
}
#else
@@ -4399,11 +4220,16 @@ bool SystemTools::IsSubDirectory(const std::string& cSubdir,
std::string dir = cDir;
SystemTools::ConvertToUnixSlashes(subdir);
SystemTools::ConvertToUnixSlashes(dir);
- if (subdir.size() > dir.size() && subdir[dir.size()] == '/') {
- std::string s = subdir.substr(0, dir.size());
- return SystemTools::ComparePath(s, dir);
+ if (subdir.size() <= dir.size() || dir.empty()) {
+ return false;
}
- return false;
+ bool isRootPath = dir.back() == '/'; // like "/" or "C:/"
+ size_t expectedSlashPosition = isRootPath ? dir.size() - 1u : dir.size();
+ if (subdir[expectedSlashPosition] != '/') {
+ return false;
+ }
+ std::string s = subdir.substr(0, dir.size());
+ return SystemTools::ComparePath(s, dir);
}
void SystemTools::Delay(unsigned int msec)
@@ -4440,24 +4266,31 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
ZeroMemory(&osvi, sizeof(osvi));
osvi.dwOSVersionInfoSize = sizeof(osvi);
-#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-#pragma warning(push)
-#ifdef __INTEL_COMPILER
-#pragma warning(disable : 1478)
-#else
-#pragma warning(disable : 4996)
-#endif
-#endif
+# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+# pragma warning(push)
+# ifdef __INTEL_COMPILER
+# pragma warning(disable : 1478)
+# elif defined __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wdeprecated-declarations"
+# else
+# pragma warning(disable : 4996)
+# endif
+# endif
bOsVersionInfoEx = GetVersionExA((OSVERSIONINFOA*)&osvi);
if (!bOsVersionInfoEx) {
return 0;
}
-#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
-#pragma warning(pop)
-#endif
+# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+# ifdef __clang__
+# pragma clang diagnostic pop
+# else
+# pragma warning(pop)
+# endif
+# endif
switch (osvi.dwPlatformId) {
- // Test for the Windows NT product family.
+ // Test for the Windows NT product family.
case VER_PLATFORM_WIN32_NT:
@@ -4575,7 +4408,7 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
else {
HKEY hKey;
-#define BUFSIZE 80
+# define BUFSIZE 80
wchar_t szProductType[BUFSIZE];
DWORD dwBufLen = BUFSIZE;
LONG lRet;
@@ -4588,7 +4421,7 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
return 0;
}
- lRet = RegQueryValueExW(hKey, L"ProductType", NULL, NULL,
+ lRet = RegQueryValueExW(hKey, L"ProductType", nullptr, nullptr,
(LPBYTE)szProductType, &dwBufLen);
if ((lRet != ERROR_SUCCESS) || (dwBufLen > BUFSIZE)) {
@@ -4657,7 +4490,7 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
break;
- // Test for the Windows 95 product family.
+ // Test for the Windows 95 product family.
case VER_PLATFORM_WIN32_WINDOWS:
@@ -4741,14 +4574,7 @@ bool SystemTools::ParseURL(const std::string& URL, std::string& protocol,
// These must NOT be initialized. Default initialization to zero is
// necessary.
static unsigned int SystemToolsManagerCount;
-SystemToolsTranslationMap* SystemTools::TranslationMap;
-#ifdef _WIN32
-SystemToolsPathCaseMap* SystemTools::PathCaseMap;
-SystemToolsEnvMap* SystemTools::EnvMap;
-#endif
-#ifdef __CYGWIN__
-SystemToolsTranslationMap* SystemTools::Cyg2Win32Map;
-#endif
+SystemToolsStatic* SystemTools::Statics;
// SystemToolsManager manages the SystemTools singleton.
// SystemToolsManager should be included in any translation unit
@@ -4789,20 +4615,15 @@ void SystemTools::ClassInitialize()
#ifdef __VMS
SetVMSFeature("DECC$FILENAME_UNIX_ONLY", 1);
#endif
- // Allocate the translation map first.
- SystemTools::TranslationMap = new SystemToolsTranslationMap;
-#ifdef _WIN32
- SystemTools::PathCaseMap = new SystemToolsPathCaseMap;
- SystemTools::EnvMap = new SystemToolsEnvMap;
-#endif
-#ifdef __CYGWIN__
- SystemTools::Cyg2Win32Map = new SystemToolsTranslationMap;
-#endif
+ // Create statics singleton instance
+ SystemTools::Statics = new SystemToolsStatic;
+
+#if KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP
// Add some special translation paths for unix. These are not added
// for windows because drive letters need to be maintained. Also,
// there are not sym-links and mount points on windows anyway.
-#if !defined(_WIN32) || defined(__CYGWIN__)
+# if !defined(_WIN32) || defined(__CYGWIN__)
// The tmp path is frequently a logical path so always keep it:
SystemTools::AddKeepPath("/tmp/");
@@ -4821,7 +4642,7 @@ void SystemTools::ClassInitialize()
// Test progressively shorter logical-to-physical mappings.
std::string cwd_str = cwd;
std::string pwd_path;
- Realpath(pwd_str.c_str(), pwd_path);
+ Realpath(pwd_str, pwd_path);
while (cwd_str == pwd_path && cwd_str != pwd_str) {
// The current pair of paths is a working logical mapping.
cwd_changed = cwd_str;
@@ -4831,7 +4652,7 @@ void SystemTools::ClassInitialize()
// mapping still works.
pwd_str = SystemTools::GetFilenamePath(pwd_str);
cwd_str = SystemTools::GetFilenamePath(cwd_str);
- Realpath(pwd_str.c_str(), pwd_path);
+ Realpath(pwd_str, pwd_path);
}
// Add the translation to keep the logical path name.
@@ -4840,27 +4661,21 @@ void SystemTools::ClassInitialize()
}
}
}
+# endif
#endif
}
void SystemTools::ClassFinalize()
{
- delete SystemTools::TranslationMap;
-#ifdef _WIN32
- delete SystemTools::PathCaseMap;
- delete SystemTools::EnvMap;
-#endif
-#ifdef __CYGWIN__
- delete SystemTools::Cyg2Win32Map;
-#endif
+ delete SystemTools::Statics;
}
} // namespace KWSYS_NAMESPACE
#if defined(_MSC_VER) && defined(_DEBUG)
-#include <crtdbg.h>
-#include <stdio.h>
-#include <stdlib.h>
+# include <crtdbg.h>
+# include <stdio.h>
+# include <stdlib.h>
namespace KWSYS_NAMESPACE {
static int SystemToolsDebugReport(int, char* message, int*)
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index 5e091c2af..c4ab9d4f3 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -10,14 +10,12 @@
#include <string>
#include <vector>
-#include <@KWSYS_NAMESPACE@/String.hxx>
-
#include <sys/types.h>
// include sys/stat.h after sys/types.h
#include <sys/stat.h>
#if !defined(_WIN32) || defined(__CYGWIN__)
-#include <unistd.h> // For access permissions for use with access()
+# include <unistd.h> // For access permissions for use with access()
#endif
// Required for va_list
@@ -43,9 +41,7 @@ typedef @KWSYS_NAMESPACE@_VA_LIST::hack_va_list va_list;
namespace @KWSYS_NAMESPACE@ {
-class SystemToolsTranslationMap;
-class SystemToolsPathCaseMap;
-class SystemToolsEnvMap;
+class SystemToolsStatic;
/** \class SystemToolsManager
* \brief Use to make sure SystemTools is initialized before it is used
@@ -56,6 +52,9 @@ class @KWSYS_NAMESPACE@_EXPORT SystemToolsManager
public:
SystemToolsManager();
~SystemToolsManager();
+
+ SystemToolsManager(const SystemToolsManager&) = delete;
+ SystemToolsManager& operator=(const SystemToolsManager&) = delete;
};
// This instance will show up in any translation unit that uses
@@ -107,7 +106,7 @@ public:
}
/**
- * Replace replace all occurences of the string in the source string.
+ * Replace replace all occurrences of the string in the source string.
*/
static void ReplaceString(std::string& source, const char* replace,
const char* with);
@@ -175,7 +174,7 @@ public:
static bool StringEndsWith(const std::string& str1, const char* str2);
/**
- * Returns a pointer to the last occurence of str2 in str1
+ * Returns a pointer to the last occurrence of str2 in str1
*/
static const char* FindLastString(const char* str1, const char* str2);
@@ -197,22 +196,15 @@ public:
s starts with a / then the first element of the returned array will
be /, so /foo/bar will be [/, foo, bar]
*/
- static std::vector<String> SplitString(const std::string& s,
- char separator = '/',
- bool isPath = false);
+ static std::vector<std::string> SplitString(const std::string& s,
+ char separator = '/',
+ bool isPath = false);
/**
* Perform a case-independent string comparison
*/
static int Strucmp(const char* s1, const char* s2);
/**
- * Convert a string in __DATE__ or __TIMESTAMP__ format into a time_t.
- * Return false on error, true on success
- */
- static bool ConvertDateMacroString(const char* str, time_t* tmt);
- static bool ConvertTimeStampMacroString(const char* str, time_t* tmt);
-
- /**
* Split a string on its newlines into multiple lines
* Return false only if the last line stored had no newline
*/
@@ -325,11 +317,11 @@ public:
* Cross platform wrapper for stat struct
*/
#if defined(_WIN32) && !defined(__CYGWIN__)
-#if defined(__BORLANDC__)
+# if defined(__BORLANDC__)
typedef struct stati64 Stat_t;
-#else
+# else
typedef struct _stat64 Stat_t;
-#endif
+# endif
#else
typedef struct stat Stat_t;
#endif
@@ -408,9 +400,10 @@ public:
* installPrefix is a possibly null pointer to the install directory.
*/
static bool FindProgramPath(const char* argv0, std::string& pathOut,
- std::string& errorMsg, const char* exeName = 0,
- const char* buildDir = 0,
- const char* installPrefix = 0);
+ std::string& errorMsg,
+ const char* exeName = nullptr,
+ const char* buildDir = nullptr,
+ const char* installPrefix = nullptr);
/**
* Given a path to a file or directory, convert it to a full path.
@@ -428,11 +421,11 @@ public:
* Get the real path for a given path, removing all symlinks. In
* the event of an error (non-existent path, permissions issue,
* etc.) the original path is returned if errorMessage pointer is
- * NULL. Otherwise empty string is returned and errorMessage
+ * nullptr. Otherwise empty string is returned and errorMessage
* contains error description.
*/
static std::string GetRealPath(const std::string& path,
- std::string* errorMessage = 0);
+ std::string* errorMessage = nullptr);
/**
* Split a path name into its root component and the rest of the
@@ -450,7 +443,7 @@ public:
* given.
*/
static const char* SplitPathRootComponent(const std::string& p,
- std::string* root = 0);
+ std::string* root = nullptr);
/**
* Split a path name into its basic components. The first component
@@ -461,6 +454,10 @@ public:
* produce the original path. Home directory references are
* automatically expanded if expand_home_dir is true and this
* platform supports them.
+ *
+ * This does *not* normalize the input path. All components are
+ * preserved, including empty ones. Typically callers should use
+ * this only on paths that have already been normalized.
*/
static void SplitPath(const std::string& p,
std::vector<std::string>& components,
@@ -469,15 +466,15 @@ public:
/**
* Join components of a path name into a single string. See
* SplitPath for the format of the components.
+ *
+ * This does *not* normalize the input path. All components are
+ * preserved, including empty ones. Typically callers should use
+ * this only on paths that have already been normalized.
*/
static std::string JoinPath(const std::vector<std::string>& components);
static std::string JoinPath(std::vector<std::string>::const_iterator first,
std::vector<std::string>::const_iterator last);
- /** Removes empty components from path.
- */
- static void RemoveEmptyPathElements(std::vector<std::string>& path);
-
/**
* Compare a path or components of a path.
*/
@@ -494,12 +491,6 @@ public:
static std::string GetFilenameName(const std::string&);
/**
- * Split a program from its arguments and handle spaces in the paths
- */
- static void SplitProgramFromArgs(const std::string& path,
- std::string& program, std::string& args);
-
- /**
* Return longest file extension of a full filename (dot included)
*/
static std::string GetFilenameExtension(const std::string&);
@@ -532,14 +523,14 @@ public:
static bool GetShortPath(const std::string& path, std::string& result);
/**
- * Read line from file. Make sure to get everything. Due to a buggy stream
- * library on the HP and another on Mac OS X, we need this very carefully
- * written version of getline. Returns true if any data were read before the
+ * Read line from file. Make sure to read a full line and truncates it if
+ * requested via sizeLimit. Returns true if any data were read before the
* end-of-file was reached. If the has_newline argument is specified, it will
* be true when the line read had a newline character.
*/
static bool GetLineFromStream(std::istream& istr, std::string& line,
- bool* has_newline = 0, long sizeLimit = -1);
+ bool* has_newline = nullptr,
+ long sizeLimit = -1);
/**
* Get the parent directory of the directory or file
@@ -562,13 +553,21 @@ public:
*/
static FILE* Fopen(const std::string& file, const char* mode);
+/**
+ * Visual C++ does not define mode_t (note that Borland does, however).
+ */
+#if defined(_MSC_VER)
+ typedef unsigned short mode_t;
+#endif
+
/**
* Make a new directory if it is not there. This function
* can make a full path even if none of the directories existed
* prior to calling this function.
*/
- static bool MakeDirectory(const char* path);
- static bool MakeDirectory(const std::string& path);
+ static bool MakeDirectory(const char* path, const mode_t* mode = nullptr);
+ static bool MakeDirectory(const std::string& path,
+ const mode_t* mode = nullptr);
/**
* Copy the source file to the destination file only
@@ -584,6 +583,13 @@ public:
const std::string& destination);
/**
+ * Compare the contents of two files, ignoring line ending differences.
+ * Return true if different
+ */
+ static bool TextFilesDiffer(const std::string& path1,
+ const std::string& path2);
+
+ /**
* Return true if the two files are the same file
*/
static bool SameFile(const std::string& file1, const std::string& file2);
@@ -758,13 +764,6 @@ public:
*/
static long int CreationTime(const std::string& filename);
-/**
- * Visual C++ does not define mode_t (note that Borland does, however).
- */
-#if defined(_MSC_VER)
- typedef unsigned short mode_t;
-#endif
-
/**
* Get and set permissions of the file. If honor_umask is set, the umask
* is queried and applied to the given permissions. Returns false if
@@ -846,7 +845,8 @@ public:
* string vector passed in. If env is set then the value
* of env will be used instead of PATH.
*/
- static void GetPath(std::vector<std::string>& path, const char* env = 0);
+ static void GetPath(std::vector<std::string>& path,
+ const char* env = nullptr);
/**
* Read an environment variable
@@ -890,11 +890,12 @@ public:
/**
* Get the width of the terminal window. The code may or may not work, so
- * make sure you have some resonable defaults prepared if the code returns
+ * make sure you have some reasonable defaults prepared if the code returns
* some bogus size.
*/
static int GetTerminalWidth();
+#if @KWSYS_NAMESPACE@_SYSTEMTOOLS_USE_TRANSLATION_MAP
/**
* Add an entry in the path translation table.
*/
@@ -911,10 +912,11 @@ public:
* Update path by going through the Path Translation table;
*/
static void CheckTranslationPath(std::string& path);
+#endif
/**
* Delay the execution for a specified amount of time specified
- * in miliseconds
+ * in milliseconds
*/
static void Delay(unsigned int msec);
@@ -969,40 +971,8 @@ private:
return &SystemToolsManagerInstance;
}
- /**
- * Actual implementation of ReplaceString.
- */
- static void ReplaceString(std::string& source, const char* replace,
- size_t replaceSize, const std::string& with);
-
- /**
- * Actual implementation of FileIsFullPath.
- */
- static bool FileIsFullPath(const char*, size_t);
-
- /**
- * Find a filename (file or directory) in the system PATH, with
- * optional extra paths.
- */
- static std::string FindName(
- const std::string& name,
- const std::vector<std::string>& path = std::vector<std::string>(),
- bool no_system_path = false);
-
- static const char* GetEnvImpl(const char* key);
-
- /**
- * Path translation table from dir to refdir
- * Each time 'dir' will be found it will be replace by 'refdir'
- */
- static SystemToolsTranslationMap* TranslationMap;
-#ifdef _WIN32
- static SystemToolsPathCaseMap* PathCaseMap;
- static SystemToolsEnvMap* EnvMap;
-#endif
-#ifdef __CYGWIN__
- static SystemToolsTranslationMap* Cyg2Win32Map;
-#endif
+ static SystemToolsStatic* Statics;
+ friend class SystemToolsStatic;
friend class SystemToolsManager;
};
diff --git a/Source/kwsys/Terminal.c b/Source/kwsys/Terminal.c
index eaa5c7d43..4dd246148 100644
--- a/Source/kwsys/Terminal.c
+++ b/Source/kwsys/Terminal.c
@@ -6,15 +6,15 @@
/* Work-around CMake dependency scanning limitation. This must
duplicate the above list of headers. */
#if 0
-#include "Terminal.h.in"
+# include "Terminal.h.in"
#endif
/* Configure support for this platform. */
#if defined(_WIN32) || defined(__CYGWIN__)
-#define KWSYS_TERMINAL_SUPPORT_CONSOLE
+# define KWSYS_TERMINAL_SUPPORT_CONSOLE
#endif
#if !defined(_WIN32)
-#define KWSYS_TERMINAL_ISATTY_WORKS
+# define KWSYS_TERMINAL_ISATTY_WORKS
#endif
/* Include needed system APIs. */
@@ -24,14 +24,14 @@
#include <string.h> /* strcmp */
#if defined(KWSYS_TERMINAL_SUPPORT_CONSOLE)
-#include <io.h> /* _get_osfhandle */
-#include <windows.h> /* SetConsoleTextAttribute */
+# include <io.h> /* _get_osfhandle */
+# include <windows.h> /* SetConsoleTextAttribute */
#endif
#if defined(KWSYS_TERMINAL_ISATTY_WORKS)
-#include <unistd.h> /* isatty */
+# include <unistd.h> /* isatty */
#else
-#include <sys/stat.h> /* fstat */
+# include <sys/stat.h> /* fstat */
#endif
static int kwsysTerminalStreamIsVT100(FILE* stream, int default_vt100,
@@ -103,6 +103,8 @@ static int kwsysTerminalStreamIsNotInteractive(FILE* stream)
/* List of terminal names known to support VT100 color escape sequences. */
static const char* kwsysTerminalVT100Names[] = { "Eterm",
+ "alacritty",
+ "alacritty-direct",
"ansi",
"color-xterm",
"con132x25",
@@ -153,6 +155,7 @@ static const char* kwsysTerminalVT100Names[] = { "Eterm",
"xterm-88color",
"xterm-color",
"xterm-debian",
+ "xterm-kitty",
"xterm-termite",
0 };
@@ -208,27 +211,34 @@ static int kwsysTerminalStreamIsVT100(FILE* stream, int default_vt100,
}
/* VT100 escape sequence strings. */
-#define KWSYS_TERMINAL_VT100_NORMAL "\33[0m"
-#define KWSYS_TERMINAL_VT100_BOLD "\33[1m"
-#define KWSYS_TERMINAL_VT100_UNDERLINE "\33[4m"
-#define KWSYS_TERMINAL_VT100_BLINK "\33[5m"
-#define KWSYS_TERMINAL_VT100_INVERSE "\33[7m"
-#define KWSYS_TERMINAL_VT100_FOREGROUND_BLACK "\33[30m"
-#define KWSYS_TERMINAL_VT100_FOREGROUND_RED "\33[31m"
-#define KWSYS_TERMINAL_VT100_FOREGROUND_GREEN "\33[32m"
-#define KWSYS_TERMINAL_VT100_FOREGROUND_YELLOW "\33[33m"
-#define KWSYS_TERMINAL_VT100_FOREGROUND_BLUE "\33[34m"
-#define KWSYS_TERMINAL_VT100_FOREGROUND_MAGENTA "\33[35m"
-#define KWSYS_TERMINAL_VT100_FOREGROUND_CYAN "\33[36m"
-#define KWSYS_TERMINAL_VT100_FOREGROUND_WHITE "\33[37m"
-#define KWSYS_TERMINAL_VT100_BACKGROUND_BLACK "\33[40m"
-#define KWSYS_TERMINAL_VT100_BACKGROUND_RED "\33[41m"
-#define KWSYS_TERMINAL_VT100_BACKGROUND_GREEN "\33[42m"
-#define KWSYS_TERMINAL_VT100_BACKGROUND_YELLOW "\33[43m"
-#define KWSYS_TERMINAL_VT100_BACKGROUND_BLUE "\33[44m"
-#define KWSYS_TERMINAL_VT100_BACKGROUND_MAGENTA "\33[45m"
-#define KWSYS_TERMINAL_VT100_BACKGROUND_CYAN "\33[46m"
-#define KWSYS_TERMINAL_VT100_BACKGROUND_WHITE "\33[47m"
+#if defined(__MVS__)
+/* if building on z/OS (aka MVS), assume we are using EBCDIC */
+# define ESCAPE_CHAR "\47"
+#else
+# define ESCAPE_CHAR "\33"
+#endif
+
+#define KWSYS_TERMINAL_VT100_NORMAL ESCAPE_CHAR "[0m"
+#define KWSYS_TERMINAL_VT100_BOLD ESCAPE_CHAR "[1m"
+#define KWSYS_TERMINAL_VT100_UNDERLINE ESCAPE_CHAR "[4m"
+#define KWSYS_TERMINAL_VT100_BLINK ESCAPE_CHAR "[5m"
+#define KWSYS_TERMINAL_VT100_INVERSE ESCAPE_CHAR "[7m"
+#define KWSYS_TERMINAL_VT100_FOREGROUND_BLACK ESCAPE_CHAR "[30m"
+#define KWSYS_TERMINAL_VT100_FOREGROUND_RED ESCAPE_CHAR "[31m"
+#define KWSYS_TERMINAL_VT100_FOREGROUND_GREEN ESCAPE_CHAR "[32m"
+#define KWSYS_TERMINAL_VT100_FOREGROUND_YELLOW ESCAPE_CHAR "[33m"
+#define KWSYS_TERMINAL_VT100_FOREGROUND_BLUE ESCAPE_CHAR "[34m"
+#define KWSYS_TERMINAL_VT100_FOREGROUND_MAGENTA ESCAPE_CHAR "[35m"
+#define KWSYS_TERMINAL_VT100_FOREGROUND_CYAN ESCAPE_CHAR "[36m"
+#define KWSYS_TERMINAL_VT100_FOREGROUND_WHITE ESCAPE_CHAR "[37m"
+#define KWSYS_TERMINAL_VT100_BACKGROUND_BLACK ESCAPE_CHAR "[40m"
+#define KWSYS_TERMINAL_VT100_BACKGROUND_RED ESCAPE_CHAR "[41m"
+#define KWSYS_TERMINAL_VT100_BACKGROUND_GREEN ESCAPE_CHAR "[42m"
+#define KWSYS_TERMINAL_VT100_BACKGROUND_YELLOW ESCAPE_CHAR "[43m"
+#define KWSYS_TERMINAL_VT100_BACKGROUND_BLUE ESCAPE_CHAR "[44m"
+#define KWSYS_TERMINAL_VT100_BACKGROUND_MAGENTA ESCAPE_CHAR "[45m"
+#define KWSYS_TERMINAL_VT100_BACKGROUND_CYAN ESCAPE_CHAR "[46m"
+#define KWSYS_TERMINAL_VT100_BACKGROUND_WHITE ESCAPE_CHAR "[47m"
/* Write VT100 escape sequences to the stream for the given color. */
static void kwsysTerminalSetVT100Color(FILE* stream, int color)
@@ -300,10 +310,12 @@ static void kwsysTerminalSetVT100Color(FILE* stream, int color)
#if defined(KWSYS_TERMINAL_SUPPORT_CONSOLE)
-#define KWSYS_TERMINAL_MASK_FOREGROUND \
- (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY)
-#define KWSYS_TERMINAL_MASK_BACKGROUND \
- (BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY)
+# define KWSYS_TERMINAL_MASK_FOREGROUND \
+ (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | \
+ FOREGROUND_INTENSITY)
+# define KWSYS_TERMINAL_MASK_BACKGROUND \
+ (BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | \
+ BACKGROUND_INTENSITY)
/* Get the Windows handle for a FILE stream. */
static HANDLE kwsysTerminalGetStreamHandle(FILE* stream)
@@ -311,7 +323,7 @@ static HANDLE kwsysTerminalGetStreamHandle(FILE* stream)
/* Get the C-library file descriptor from the stream. */
int fd = fileno(stream);
-#if defined(__CYGWIN__)
+# if defined(__CYGWIN__)
/* Cygwin seems to have an extra pipe level. If the file descriptor
corresponds to stdout or stderr then obtain the matching windows
handle directly. */
@@ -320,7 +332,7 @@ static HANDLE kwsysTerminalGetStreamHandle(FILE* stream)
} else if (fd == fileno(stderr)) {
return GetStdHandle(STD_ERROR_HANDLE);
}
-#endif
+# endif
/* Get the underlying Windows handle for the descriptor. */
return (HANDLE)_get_osfhandle(fd);
diff --git a/Source/kwsys/Terminal.h.in b/Source/kwsys/Terminal.h.in
index 5d2983004..1a2c7452f 100644
--- a/Source/kwsys/Terminal.h.in
+++ b/Source/kwsys/Terminal.h.in
@@ -12,57 +12,57 @@
not visible to user code. Use kwsysHeaderDump.pl to reproduce
these macros after making changes to the interface. */
#if !defined(KWSYS_NAMESPACE)
-#define kwsys_ns(x) @KWSYS_NAMESPACE@##x
-#define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
+# define kwsys_ns(x) @KWSYS_NAMESPACE@##x
+# define kwsysEXPORT @KWSYS_NAMESPACE@_EXPORT
#endif
#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#define kwsysTerminal_cfprintf kwsys_ns(Terminal_cfprintf)
-#define kwsysTerminal_Color_e kwsys_ns(Terminal_Color_e)
-#define kwsysTerminal_Color_Normal kwsys_ns(Terminal_Color_Normal)
-#define kwsysTerminal_Color_ForegroundBlack \
- kwsys_ns(Terminal_Color_ForegroundBlack)
-#define kwsysTerminal_Color_ForegroundRed \
- kwsys_ns(Terminal_Color_ForegroundRed)
-#define kwsysTerminal_Color_ForegroundGreen \
- kwsys_ns(Terminal_Color_ForegroundGreen)
-#define kwsysTerminal_Color_ForegroundYellow \
- kwsys_ns(Terminal_Color_ForegroundYellow)
-#define kwsysTerminal_Color_ForegroundBlue \
- kwsys_ns(Terminal_Color_ForegroundBlue)
-#define kwsysTerminal_Color_ForegroundMagenta \
- kwsys_ns(Terminal_Color_ForegroundMagenta)
-#define kwsysTerminal_Color_ForegroundCyan \
- kwsys_ns(Terminal_Color_ForegroundCyan)
-#define kwsysTerminal_Color_ForegroundWhite \
- kwsys_ns(Terminal_Color_ForegroundWhite)
-#define kwsysTerminal_Color_ForegroundMask \
- kwsys_ns(Terminal_Color_ForegroundMask)
-#define kwsysTerminal_Color_BackgroundBlack \
- kwsys_ns(Terminal_Color_BackgroundBlack)
-#define kwsysTerminal_Color_BackgroundRed \
- kwsys_ns(Terminal_Color_BackgroundRed)
-#define kwsysTerminal_Color_BackgroundGreen \
- kwsys_ns(Terminal_Color_BackgroundGreen)
-#define kwsysTerminal_Color_BackgroundYellow \
- kwsys_ns(Terminal_Color_BackgroundYellow)
-#define kwsysTerminal_Color_BackgroundBlue \
- kwsys_ns(Terminal_Color_BackgroundBlue)
-#define kwsysTerminal_Color_BackgroundMagenta \
- kwsys_ns(Terminal_Color_BackgroundMagenta)
-#define kwsysTerminal_Color_BackgroundCyan \
- kwsys_ns(Terminal_Color_BackgroundCyan)
-#define kwsysTerminal_Color_BackgroundWhite \
- kwsys_ns(Terminal_Color_BackgroundWhite)
-#define kwsysTerminal_Color_BackgroundMask \
- kwsys_ns(Terminal_Color_BackgroundMask)
-#define kwsysTerminal_Color_ForegroundBold \
- kwsys_ns(Terminal_Color_ForegroundBold)
-#define kwsysTerminal_Color_BackgroundBold \
- kwsys_ns(Terminal_Color_BackgroundBold)
-#define kwsysTerminal_Color_AssumeTTY kwsys_ns(Terminal_Color_AssumeTTY)
-#define kwsysTerminal_Color_AssumeVT100 kwsys_ns(Terminal_Color_AssumeVT100)
-#define kwsysTerminal_Color_AttributeMask \
- kwsys_ns(Terminal_Color_AttributeMask)
+# define kwsysTerminal_cfprintf kwsys_ns(Terminal_cfprintf)
+# define kwsysTerminal_Color_e kwsys_ns(Terminal_Color_e)
+# define kwsysTerminal_Color_Normal kwsys_ns(Terminal_Color_Normal)
+# define kwsysTerminal_Color_ForegroundBlack \
+ kwsys_ns(Terminal_Color_ForegroundBlack)
+# define kwsysTerminal_Color_ForegroundRed \
+ kwsys_ns(Terminal_Color_ForegroundRed)
+# define kwsysTerminal_Color_ForegroundGreen \
+ kwsys_ns(Terminal_Color_ForegroundGreen)
+# define kwsysTerminal_Color_ForegroundYellow \
+ kwsys_ns(Terminal_Color_ForegroundYellow)
+# define kwsysTerminal_Color_ForegroundBlue \
+ kwsys_ns(Terminal_Color_ForegroundBlue)
+# define kwsysTerminal_Color_ForegroundMagenta \
+ kwsys_ns(Terminal_Color_ForegroundMagenta)
+# define kwsysTerminal_Color_ForegroundCyan \
+ kwsys_ns(Terminal_Color_ForegroundCyan)
+# define kwsysTerminal_Color_ForegroundWhite \
+ kwsys_ns(Terminal_Color_ForegroundWhite)
+# define kwsysTerminal_Color_ForegroundMask \
+ kwsys_ns(Terminal_Color_ForegroundMask)
+# define kwsysTerminal_Color_BackgroundBlack \
+ kwsys_ns(Terminal_Color_BackgroundBlack)
+# define kwsysTerminal_Color_BackgroundRed \
+ kwsys_ns(Terminal_Color_BackgroundRed)
+# define kwsysTerminal_Color_BackgroundGreen \
+ kwsys_ns(Terminal_Color_BackgroundGreen)
+# define kwsysTerminal_Color_BackgroundYellow \
+ kwsys_ns(Terminal_Color_BackgroundYellow)
+# define kwsysTerminal_Color_BackgroundBlue \
+ kwsys_ns(Terminal_Color_BackgroundBlue)
+# define kwsysTerminal_Color_BackgroundMagenta \
+ kwsys_ns(Terminal_Color_BackgroundMagenta)
+# define kwsysTerminal_Color_BackgroundCyan \
+ kwsys_ns(Terminal_Color_BackgroundCyan)
+# define kwsysTerminal_Color_BackgroundWhite \
+ kwsys_ns(Terminal_Color_BackgroundWhite)
+# define kwsysTerminal_Color_BackgroundMask \
+ kwsys_ns(Terminal_Color_BackgroundMask)
+# define kwsysTerminal_Color_ForegroundBold \
+ kwsys_ns(Terminal_Color_ForegroundBold)
+# define kwsysTerminal_Color_BackgroundBold \
+ kwsys_ns(Terminal_Color_BackgroundBold)
+# define kwsysTerminal_Color_AssumeTTY kwsys_ns(Terminal_Color_AssumeTTY)
+# define kwsysTerminal_Color_AssumeVT100 kwsys_ns(Terminal_Color_AssumeVT100)
+# define kwsysTerminal_Color_AttributeMask \
+ kwsys_ns(Terminal_Color_AttributeMask)
#endif
#if defined(__cplusplus)
@@ -135,36 +135,36 @@ enum kwsysTerminal_Color_e
/* If we are building a kwsys .c or .cxx file, let it use these macros.
Otherwise, undefine them to keep the namespace clean. */
#if !defined(KWSYS_NAMESPACE)
-#undef kwsys_ns
-#undef kwsysEXPORT
-#if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
-#undef kwsysTerminal_cfprintf
-#undef kwsysTerminal_Color_e
-#undef kwsysTerminal_Color_Normal
-#undef kwsysTerminal_Color_ForegroundBlack
-#undef kwsysTerminal_Color_ForegroundRed
-#undef kwsysTerminal_Color_ForegroundGreen
-#undef kwsysTerminal_Color_ForegroundYellow
-#undef kwsysTerminal_Color_ForegroundBlue
-#undef kwsysTerminal_Color_ForegroundMagenta
-#undef kwsysTerminal_Color_ForegroundCyan
-#undef kwsysTerminal_Color_ForegroundWhite
-#undef kwsysTerminal_Color_ForegroundMask
-#undef kwsysTerminal_Color_BackgroundBlack
-#undef kwsysTerminal_Color_BackgroundRed
-#undef kwsysTerminal_Color_BackgroundGreen
-#undef kwsysTerminal_Color_BackgroundYellow
-#undef kwsysTerminal_Color_BackgroundBlue
-#undef kwsysTerminal_Color_BackgroundMagenta
-#undef kwsysTerminal_Color_BackgroundCyan
-#undef kwsysTerminal_Color_BackgroundWhite
-#undef kwsysTerminal_Color_BackgroundMask
-#undef kwsysTerminal_Color_ForegroundBold
-#undef kwsysTerminal_Color_BackgroundBold
-#undef kwsysTerminal_Color_AssumeTTY
-#undef kwsysTerminal_Color_AssumeVT100
-#undef kwsysTerminal_Color_AttributeMask
-#endif
+# undef kwsys_ns
+# undef kwsysEXPORT
+# if !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
+# undef kwsysTerminal_cfprintf
+# undef kwsysTerminal_Color_e
+# undef kwsysTerminal_Color_Normal
+# undef kwsysTerminal_Color_ForegroundBlack
+# undef kwsysTerminal_Color_ForegroundRed
+# undef kwsysTerminal_Color_ForegroundGreen
+# undef kwsysTerminal_Color_ForegroundYellow
+# undef kwsysTerminal_Color_ForegroundBlue
+# undef kwsysTerminal_Color_ForegroundMagenta
+# undef kwsysTerminal_Color_ForegroundCyan
+# undef kwsysTerminal_Color_ForegroundWhite
+# undef kwsysTerminal_Color_ForegroundMask
+# undef kwsysTerminal_Color_BackgroundBlack
+# undef kwsysTerminal_Color_BackgroundRed
+# undef kwsysTerminal_Color_BackgroundGreen
+# undef kwsysTerminal_Color_BackgroundYellow
+# undef kwsysTerminal_Color_BackgroundBlue
+# undef kwsysTerminal_Color_BackgroundMagenta
+# undef kwsysTerminal_Color_BackgroundCyan
+# undef kwsysTerminal_Color_BackgroundWhite
+# undef kwsysTerminal_Color_BackgroundMask
+# undef kwsysTerminal_Color_ForegroundBold
+# undef kwsysTerminal_Color_BackgroundBold
+# undef kwsysTerminal_Color_AssumeTTY
+# undef kwsysTerminal_Color_AssumeVT100
+# undef kwsysTerminal_Color_AttributeMask
+# endif
#endif
#endif
diff --git a/Source/kwsys/hash_map.hxx.in b/Source/kwsys/hash_map.hxx.in
index 3f9174f3b..5f04e9c16 100644
--- a/Source/kwsys/hash_map.hxx.in
+++ b/Source/kwsys/hash_map.hxx.in
@@ -35,21 +35,21 @@
#include <functional> // equal_to
#if defined(_MSC_VER)
-#pragma warning(push)
-#pragma warning(disable : 4284)
-#pragma warning(disable : 4786)
+# pragma warning(push)
+# pragma warning(disable : 4284)
+# pragma warning(disable : 4786)
#endif
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
-#pragma set woff 1174
-#pragma set woff 1375
+# pragma set woff 1174
+# pragma set woff 1375
#endif
namespace @KWSYS_NAMESPACE@ {
// select1st is an extension: it is not part of the standard.
template <class T1, class T2>
-struct hash_select1st : public std::unary_function<std::pair<T1, T2>, T1>
+struct hash_select1st
{
const T1& operator()(const std::pair<T1, T2>& __x) const
{
@@ -412,12 +412,12 @@ inline void swap(hash_multimap<_Key, _Tp, _HashFcn, _EqlKey, _Alloc>& __hm1,
} // namespace @KWSYS_NAMESPACE@
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
-#pragma reset woff 1174
-#pragma reset woff 1375
+# pragma reset woff 1174
+# pragma reset woff 1375
#endif
#if defined(_MSC_VER)
-#pragma warning(pop)
+# pragma warning(pop)
#endif
#endif
diff --git a/Source/kwsys/hash_set.hxx.in b/Source/kwsys/hash_set.hxx.in
index e3a0c6c44..f4a37eebd 100644
--- a/Source/kwsys/hash_set.hxx.in
+++ b/Source/kwsys/hash_set.hxx.in
@@ -35,21 +35,21 @@
#include <functional> // equal_to
#if defined(_MSC_VER)
-#pragma warning(push)
-#pragma warning(disable : 4284)
-#pragma warning(disable : 4786)
+# pragma warning(push)
+# pragma warning(disable : 4284)
+# pragma warning(disable : 4786)
#endif
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
-#pragma set woff 1174
-#pragma set woff 1375
+# pragma set woff 1174
+# pragma set woff 1375
#endif
namespace @KWSYS_NAMESPACE@ {
// identity is an extension: it is not part of the standard.
template <class _Tp>
-struct _Identity : public std::unary_function<_Tp, _Tp>
+struct _Identity
{
const _Tp& operator()(const _Tp& __x) const { return __x; }
};
@@ -381,12 +381,12 @@ inline void swap(hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
} // namespace @KWSYS_NAMESPACE@
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
-#pragma reset woff 1174
-#pragma reset woff 1375
+# pragma reset woff 1174
+# pragma reset woff 1375
#endif
#if defined(_MSC_VER)
-#pragma warning(pop)
+# pragma warning(pop)
#endif
#endif
diff --git a/Source/kwsys/hashtable.hxx.in b/Source/kwsys/hashtable.hxx.in
index dd92cb9d4..8c4b0025f 100644
--- a/Source/kwsys/hashtable.hxx.in
+++ b/Source/kwsys/hashtable.hxx.in
@@ -26,43 +26,42 @@
*
*/
#ifdef __BORLANDC__
-#pragma warn - 8027 /* 'for' not inlined. */
-#pragma warn - 8026 /* 'exception' not inlined. */
+# pragma warn - 8027 /* 'for' not inlined. */
+# pragma warn - 8026 /* 'exception' not inlined. */
#endif
#ifndef @KWSYS_NAMESPACE@_hashtable_hxx
-#define @KWSYS_NAMESPACE@_hashtable_hxx
-
-#include <@KWSYS_NAMESPACE@/Configure.hxx>
-
-#include <algorithm> // lower_bound
-#include <functional> // unary_function
-#include <iterator> // iterator_traits
-#include <memory> // allocator
-#include <stddef.h> // size_t
-#include <utility> // pair
-#include <vector> // vector
-
-#if defined(_MSC_VER)
-#pragma warning(push)
-#pragma warning(disable : 4284)
-#pragma warning(disable : 4786)
-#pragma warning(disable : 4512) /* no assignment operator for class */
-#endif
-#if defined(__sgi) && !defined(__GNUC__)
-#pragma set woff 3970 /* pointer to int conversion */ 3321 3968
-#endif
+# define @KWSYS_NAMESPACE@_hashtable_hxx
+
+# include <@KWSYS_NAMESPACE@/Configure.hxx>
+
+# include <algorithm> // lower_bound
+# include <iterator> // iterator_traits
+# include <memory> // allocator
+# include <stddef.h> // size_t
+# include <utility> // pair
+# include <vector> // vector
+
+# if defined(_MSC_VER)
+# pragma warning(push)
+# pragma warning(disable : 4284)
+# pragma warning(disable : 4786)
+# pragma warning(disable : 4512) /* no assignment operator for class */
+# endif
+# if defined(__sgi) && !defined(__GNUC__)
+# pragma set woff 3970 /* pointer to int conversion */ 3321 3968
+# endif
// In C++11, clang will warn about using dynamic exception specifications
// as they are deprecated. But as this class is trying to faithfully
// mimic unordered_set and unordered_map, we want to keep the 'throw()'
// decorations below. So we suppress the warning.
-#if defined(__clang__) && defined(__has_warning)
-#if __has_warning("-Wdeprecated")
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated"
-#endif
-#endif
+# if defined(__clang__) && defined(__has_warning)
+# if __has_warning("-Wdeprecated")
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wdeprecated"
+# endif
+# endif
namespace @KWSYS_NAMESPACE@ {
@@ -74,7 +73,7 @@ struct _Hashtable_node
void public_method_to_quiet_warning_about_all_methods_private();
private:
- void operator=(_Hashtable_node<_Val> const&); // poison node assignment
+ void operator=(_Hashtable_node<_Val> const&) = delete;
};
template <class _Val, class _Key, class _HashFcn, class _ExtractKey,
@@ -251,6 +250,7 @@ private:
public:
typedef typename _Alloc::template rebind<_Val>::other allocator_type;
allocator_type get_allocator() const { return _M_node_allocator; }
+
private:
typedef
typename _Alloc::template rebind<_Node>::other _M_node_allocator_type;
@@ -354,7 +354,7 @@ public:
return end();
}
- iterator end() { return iterator(0, this); }
+ iterator end() { return iterator(nullptr, this); }
const_iterator begin() const
{
@@ -364,7 +364,7 @@ public:
return end();
}
- const_iterator end() const { return const_iterator(0, this); }
+ const_iterator end() const { return const_iterator(nullptr, this); }
friend bool operator==<>(const hashtable&, const hashtable&);
@@ -510,7 +510,7 @@ private:
{
const size_type __n_buckets = _M_next_size(__n);
_M_buckets.reserve(__n_buckets);
- _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*)0);
+ _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*)nullptr);
_M_num_elements = 0;
}
@@ -544,7 +544,7 @@ private:
_Node* _M_new_node(const value_type& __obj)
{
_Node* __n = _M_get_node();
- __n->_M_next = 0;
+ __n->_M_next = nullptr;
try {
construct(&__n->_M_val, __obj);
return __n;
@@ -569,7 +569,7 @@ private:
template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
class _All>
_Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>&
- _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>::operator++()
+_Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>::operator++()
{
const _Node* __old = _M_cur;
_M_cur = _M_cur->_M_next;
@@ -584,7 +584,7 @@ _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>&
template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
class _All>
inline _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>
- _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>::operator++(int)
+_Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>::operator++(int)
{
iterator __tmp = *this;
++*this;
@@ -594,7 +594,7 @@ inline _Hashtable_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>
template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
class _All>
_Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>&
- _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>::operator++()
+_Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>::operator++()
{
const _Node* __old = _M_cur;
_M_cur = _M_cur->_M_next;
@@ -609,7 +609,7 @@ _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>&
template <class _Val, class _Key, class _HF, class _ExK, class _EqK,
class _All>
inline _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>
- _Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>::operator++(int)
+_Hashtable_const_iterator<_Val, _Key, _HF, _ExK, _EqK, _All>::operator++(int)
{
const_iterator __tmp = *this;
++*this;
@@ -694,8 +694,9 @@ hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::insert_equal_noresize(
}
template <class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
-typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::reference hashtable<
- _Val, _Key, _HF, _Ex, _Eq, _All>::find_or_insert(const value_type& __obj)
+typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::reference
+hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::find_or_insert(
+ const value_type& __obj)
{
resize(_M_num_elements + 1);
@@ -838,9 +839,9 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::erase(iterator __first,
else if (__f_bucket == __l_bucket)
_M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur);
else {
- _M_erase_bucket(__f_bucket, __first._M_cur, 0);
+ _M_erase_bucket(__f_bucket, __first._M_cur, nullptr);
for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n)
- _M_erase_bucket(__n, 0);
+ _M_erase_bucket(__n, nullptr);
if (__l_bucket != _M_buckets.size())
_M_erase_bucket(__l_bucket, __last._M_cur);
}
@@ -872,7 +873,8 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::resize(
if (__num_elements_hint > __old_n) {
const size_type __n = _M_next_size(__num_elements_hint);
if (__n > __old_n) {
- _M_buckets_type __tmp(__n, (_Node*)(0), _M_buckets.get_allocator());
+ _M_buckets_type __tmp(__n, (_Node*)(nullptr),
+ _M_buckets.get_allocator());
try {
for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) {
_Node* __first = _M_buckets[__bucket];
@@ -939,12 +941,12 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::clear()
{
for (size_type __i = 0; __i < _M_buckets.size(); ++__i) {
_Node* __cur = _M_buckets[__i];
- while (__cur != 0) {
+ while (__cur != nullptr) {
_Node* __next = __cur->_M_next;
_M_delete_node(__cur);
__cur = __next;
}
- _M_buckets[__i] = 0;
+ _M_buckets[__i] = nullptr;
}
_M_num_elements = 0;
}
@@ -955,7 +957,7 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_M_copy_from(
{
_M_buckets.clear();
_M_buckets.reserve(__ht._M_buckets.size());
- _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*)0);
+ _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*)nullptr);
try {
for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) {
const _Node* __cur = __ht._M_buckets[__i];
@@ -963,7 +965,7 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_M_copy_from(
_Node* __copy = _M_new_node(__cur->_M_val);
_M_buckets[__i] = __copy;
- for (_Node *__next = __cur->_M_next; __next;
+ for (_Node* __next = __cur->_M_next; __next;
__cur = __next, __next = __cur->_M_next) {
__copy->_M_next = _M_new_node(__next->_M_val);
__copy = __copy->_M_next;
@@ -980,14 +982,14 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_M_copy_from(
} // namespace @KWSYS_NAMESPACE@
// Undo warning suppression.
-#if defined(__clang__) && defined(__has_warning)
-#if __has_warning("-Wdeprecated")
-#pragma clang diagnostic pop
-#endif
-#endif
-
-#if defined(_MSC_VER)
-#pragma warning(pop)
-#endif
+# if defined(__clang__) && defined(__has_warning)
+# if __has_warning("-Wdeprecated")
+# pragma clang diagnostic pop
+# endif
+# endif
+
+# if defined(_MSC_VER)
+# pragma warning(pop)
+# endif
#endif
diff --git a/Source/kwsys/kwsysPlatformTests.cmake b/Source/kwsys/kwsysPlatformTests.cmake
index 5386a49a3..28d3f68e2 100644
--- a/Source/kwsys/kwsysPlatformTests.cmake
+++ b/Source/kwsys/kwsysPlatformTests.cmake
@@ -7,11 +7,16 @@ SET(KWSYS_PLATFORM_TEST_FILE_CXX kwsysPlatformTestsCXX.cxx)
MACRO(KWSYS_PLATFORM_TEST lang var description invert)
IF(NOT DEFINED ${var}_COMPILED)
MESSAGE(STATUS "${description}")
+ set(maybe_cxx_standard "")
+ if(CMAKE_VERSION VERSION_LESS 3.8 AND CMAKE_CXX_STANDARD)
+ set(maybe_cxx_standard "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}")
+ endif()
TRY_COMPILE(${var}_COMPILED
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/${KWSYS_PLATFORM_TEST_FILE_${lang}}
COMPILE_DEFINITIONS -DTEST_${var} ${KWSYS_PLATFORM_TEST_DEFINES} ${KWSYS_PLATFORM_TEST_EXTRA_FLAGS}
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=${KWSYS_PLATFORM_TEST_LINK_LIBRARIES}"
+ ${maybe_cxx_standard}
OUTPUT_VARIABLE OUTPUT)
IF(${var}_COMPILED)
FILE(APPEND
diff --git a/Source/kwsys/kwsysPlatformTestsC.c b/Source/kwsys/kwsysPlatformTestsC.c
index 64a361bbe..b0cf7ad3b 100644
--- a/Source/kwsys/kwsysPlatformTestsC.c
+++ b/Source/kwsys/kwsysPlatformTestsC.c
@@ -17,18 +17,18 @@
}
*/
#if defined(__CLASSIC_C__)
-#define KWSYS_PLATFORM_TEST_C_MAIN() main()
-#define KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv) \
- main(argc, argv) int argc; \
- char* argv[];
+# define KWSYS_PLATFORM_TEST_C_MAIN() main()
+# define KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv) \
+ main(argc, argv) int argc; \
+ char* argv[];
#else
-#define KWSYS_PLATFORM_TEST_C_MAIN() main(void)
-#define KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv) \
- main(int argc, char* argv[])
+# define KWSYS_PLATFORM_TEST_C_MAIN() main(void)
+# define KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv) \
+ main(int argc, char* argv[])
#endif
#ifdef TEST_KWSYS_C_HAS_PTRDIFF_T
-#include <stddef.h>
+# include <stddef.h>
int f(ptrdiff_t n)
{
return n > 0;
@@ -43,7 +43,7 @@ int KWSYS_PLATFORM_TEST_C_MAIN()
#endif
#ifdef TEST_KWSYS_C_HAS_SSIZE_T
-#include <unistd.h>
+# include <unistd.h>
int f(ssize_t n)
{
return (int)n;
@@ -55,32 +55,47 @@ int KWSYS_PLATFORM_TEST_C_MAIN()
}
#endif
+#ifdef TEST_KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC
+# if defined(__APPLE__)
+# include <AvailabilityMacros.h>
+# if MAC_OS_X_VERSION_MIN_REQUIRED < 101200
+# error "clock_gettime not available on macOS < 10.12"
+# endif
+# endif
+# include <time.h>
+int KWSYS_PLATFORM_TEST_C_MAIN()
+{
+ struct timespec ts;
+ return clock_gettime(CLOCK_MONOTONIC, &ts);
+}
+#endif
+
#ifdef TEST_KWSYS_C_TYPE_MACROS
char* info_macros =
-#if defined(__SIZEOF_SHORT__)
+# if defined(__SIZEOF_SHORT__)
"INFO:macro[__SIZEOF_SHORT__]\n"
-#endif
-#if defined(__SIZEOF_INT__)
+# endif
+# if defined(__SIZEOF_INT__)
"INFO:macro[__SIZEOF_INT__]\n"
-#endif
-#if defined(__SIZEOF_LONG__)
+# endif
+# if defined(__SIZEOF_LONG__)
"INFO:macro[__SIZEOF_LONG__]\n"
-#endif
-#if defined(__SIZEOF_LONG_LONG__)
+# endif
+# if defined(__SIZEOF_LONG_LONG__)
"INFO:macro[__SIZEOF_LONG_LONG__]\n"
-#endif
-#if defined(__SHORT_MAX__)
+# endif
+# if defined(__SHORT_MAX__)
"INFO:macro[__SHORT_MAX__]\n"
-#endif
-#if defined(__INT_MAX__)
+# endif
+# if defined(__INT_MAX__)
"INFO:macro[__INT_MAX__]\n"
-#endif
-#if defined(__LONG_MAX__)
+# endif
+# if defined(__LONG_MAX__)
"INFO:macro[__LONG_MAX__]\n"
-#endif
-#if defined(__LONG_LONG_MAX__)
+# endif
+# if defined(__LONG_LONG_MAX__)
"INFO:macro[__LONG_LONG_MAX__]\n"
-#endif
+# endif
"";
int KWSYS_PLATFORM_TEST_C_MAIN_ARGS(argc, argv)
diff --git a/Source/kwsys/kwsysPlatformTestsCXX.cxx b/Source/kwsys/kwsysPlatformTestsCXX.cxx
index 01c69514c..cfd5666f3 100644
--- a/Source/kwsys/kwsysPlatformTestsCXX.cxx
+++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx
@@ -1,7 +1,7 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#ifdef TEST_KWSYS_CXX_HAS_CSTDIO
-#include <cstdio>
+# include <cstdio>
int main()
{
return 0;
@@ -33,10 +33,10 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_STAT_HAS_ST_MTIM
-#include <sys/types.h>
+# include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
+# include <sys/stat.h>
+# include <unistd.h>
int main()
{
struct stat stat1;
@@ -47,10 +47,10 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
-#include <sys/types.h>
+# include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
+# include <sys/stat.h>
+# include <unistd.h>
int main()
{
struct stat stat1;
@@ -85,7 +85,7 @@ int main()
#endif
#ifdef TEST_KWSYS_IOS_HAS_ISTREAM_LONG_LONG
-#include <iostream>
+# include <iostream>
int test_istream(std::istream& is, long long& x)
{
return (is >> x) ? 1 : 0;
@@ -98,7 +98,7 @@ int main()
#endif
#ifdef TEST_KWSYS_IOS_HAS_OSTREAM_LONG_LONG
-#include <iostream>
+# include <iostream>
int test_ostream(std::ostream& os, long long x)
{
return (os << x) ? 1 : 0;
@@ -111,7 +111,7 @@ int main()
#endif
#ifdef TEST_KWSYS_IOS_HAS_ISTREAM___INT64
-#include <iostream>
+# include <iostream>
int test_istream(std::istream& is, __int64& x)
{
return (is >> x) ? 1 : 0;
@@ -124,7 +124,7 @@ int main()
#endif
#ifdef TEST_KWSYS_IOS_HAS_OSTREAM___INT64
-#include <iostream>
+# include <iostream>
int test_ostream(std::ostream& os, __int64 x)
{
return (os << x) ? 1 : 0;
@@ -136,44 +136,8 @@ int main()
}
#endif
-#ifdef TEST_KWSYS_LFS_WORKS
-/* Return 0 when LFS is available and 1 otherwise. */
-#define _LARGEFILE_SOURCE
-#define _LARGEFILE64_SOURCE
-#define _LARGE_FILES
-#define _FILE_OFFSET_BITS 64
-#include <sys/types.h>
-
-#include <assert.h>
-#include <sys/stat.h>
-#if KWSYS_CXX_HAS_CSTDIO
-#include <cstdio>
-#endif
-#include <stdio.h>
-
-int main(int, char** argv)
-{
-/* check that off_t can hold 2^63 - 1 and perform basic operations... */
-#define OFF_T_64 (((off_t)1 << 62) - 1 + ((off_t)1 << 62))
- if (OFF_T_64 % 2147483647 != 1)
- return 1;
-
- // stat breaks on SCO OpenServer
- struct stat buf;
- stat(argv[0], &buf);
- if (!S_ISREG(buf.st_mode))
- return 2;
-
- FILE* file = fopen(argv[0], "r");
- off_t offset = ftello(file);
- fseek(file, offset, SEEK_CUR);
- fclose(file);
- return 0;
-}
-#endif
-
#ifdef TEST_KWSYS_CXX_HAS_SETENV
-#include <stdlib.h>
+# include <stdlib.h>
int main()
{
return setenv("A", "B", 1);
@@ -181,7 +145,7 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_HAS_UNSETENV
-#include <stdlib.h>
+# include <stdlib.h>
int main()
{
unsetenv("A");
@@ -190,7 +154,7 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H
-#include <stdlib.h>
+# include <stdlib.h>
int main()
{
char* e = environ[0];
@@ -200,10 +164,10 @@ int main()
#ifdef TEST_KWSYS_CXX_HAS_GETLOADAVG
// Match feature definitions from SystemInformation.cxx
-#if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
-#define _GNU_SOURCE
-#endif
-#include <stdlib.h>
+# if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
+# define _GNU_SOURCE
+# endif
+# include <stdlib.h>
int main()
{
double loadavg[3] = { 0.0, 0.0, 0.0 };
@@ -212,13 +176,7 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_HAS_RLIMIT64
-#if defined(KWSYS_HAS_LFS)
-#define _LARGEFILE_SOURCE
-#define _LARGEFILE64_SOURCE
-#define _LARGE_FILES
-#define _FILE_OFFSET_BITS 64
-#endif
-#include <sys/resource.h>
+# include <sys/resource.h>
int main()
{
struct rlimit64 rlim;
@@ -227,7 +185,7 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_HAS_ATOLL
-#include <stdlib.h>
+# include <stdlib.h>
int main()
{
const char* str = "1024";
@@ -236,7 +194,7 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_HAS_ATOL
-#include <stdlib.h>
+# include <stdlib.h>
int main()
{
const char* str = "1024";
@@ -245,7 +203,7 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_HAS__ATOI64
-#include <stdlib.h>
+# include <stdlib.h>
int main()
{
const char* str = "1024";
@@ -254,7 +212,7 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_HAS_UTIMES
-#include <sys/time.h>
+# include <sys/time.h>
int main()
{
struct timeval* current_time = 0;
@@ -263,8 +221,14 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_HAS_UTIMENSAT
-#include <fcntl.h>
-#include <sys/stat.h>
+# include <fcntl.h>
+# include <sys/stat.h>
+# if defined(__APPLE__)
+# include <AvailabilityMacros.h>
+# if MAC_OS_X_VERSION_MIN_REQUIRED < 101300
+# error "utimensat not available on macOS < 10.13"
+# endif
+# endif
int main()
{
struct timespec times[2] = { { 0, UTIME_OMIT }, { 0, UTIME_NOW } };
@@ -273,14 +237,14 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_HAS_BACKTRACE
-#if defined(__PATHSCALE__) || defined(__PATHCC__) || \
- (defined(__LSB_VERSION__) && (__LSB_VERSION__ < 41))
-backtrace doesnt work with this compiler or os
-#endif
-#if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
-#define _GNU_SOURCE
-#endif
-#include <execinfo.h>
+# if defined(__PATHSCALE__) || defined(__PATHCC__) || \
+ (defined(__LSB_VERSION__) && (__LSB_VERSION__ < 41))
+backtrace does not work with this compiler or os
+# endif
+# if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
+# define _GNU_SOURCE
+# endif
+# include <execinfo.h>
int main()
{
void* stackSymbols[256];
@@ -291,10 +255,10 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_HAS_DLADDR
-#if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
-#define _GNU_SOURCE
-#endif
-#include <dlfcn.h>
+# if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
+# define _GNU_SOURCE
+# endif
+# include <dlfcn.h>
int main()
{
Dl_info info;
@@ -304,14 +268,14 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_HAS_CXXABI
-#if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
-#define _GNU_SOURCE
-#endif
-#if defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x5130 && __linux && \
- __SUNPRO_CC_COMPAT == 'G'
-#include <iostream>
-#endif
-#include <cxxabi.h>
+# if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
+# define _GNU_SOURCE
+# endif
+# if defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x5130 && __linux && \
+ __SUNPRO_CC_COMPAT == 'G'
+# include <iostream>
+# endif
+# include <cxxabi.h>
int main()
{
int status = 0;
@@ -352,7 +316,7 @@ int main()
#endif
#ifdef TEST_KWSYS_STL_HAS_WSTRING
-#include <string>
+# include <string>
void f(std::wstring*)
{
}
@@ -363,7 +327,7 @@ int main()
#endif
#ifdef TEST_KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H
-#include <ext/stdio_filebuf.h>
+# include <ext/stdio_filebuf.h>
int main()
{
return 0;
diff --git a/Source/kwsys/kwsysPrivate.h b/Source/kwsys/kwsysPrivate.h
index ce1b53ed8..dd9c1277f 100644
--- a/Source/kwsys/kwsysPrivate.h
+++ b/Source/kwsys/kwsysPrivate.h
@@ -1,11 +1,11 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#ifndef KWSYS_NAMESPACE
-#error "Do not include kwsysPrivate.h outside of kwsys c and cxx files."
+# error "Do not include kwsysPrivate.h outside of kwsys c and cxx files."
#endif
#ifndef _kwsysPrivate_h
-#define _kwsysPrivate_h
+# define _kwsysPrivate_h
/*
Define KWSYS_HEADER macro to help the c and cxx files include kwsys
@@ -18,17 +18,17 @@
/* clang-format off */
#define KWSYS_HEADER(x) KWSYS_HEADER0(KWSYS_NAMESPACE/x)
/* clang-format on */
-#define KWSYS_HEADER0(x) KWSYS_HEADER1(x)
-#define KWSYS_HEADER1(x) <x>
+# define KWSYS_HEADER0(x) KWSYS_HEADER1(x)
+# define KWSYS_HEADER1(x) <x>
/*
Define KWSYS_NAMESPACE_STRING to be a string constant containing the
name configured for this instance of the kwsys library.
*/
-#define KWSYS_NAMESPACE_STRING KWSYS_NAMESPACE_STRING0(KWSYS_NAMESPACE)
-#define KWSYS_NAMESPACE_STRING0(x) KWSYS_NAMESPACE_STRING1(x)
-#define KWSYS_NAMESPACE_STRING1(x) #x
+# define KWSYS_NAMESPACE_STRING KWSYS_NAMESPACE_STRING0(KWSYS_NAMESPACE)
+# define KWSYS_NAMESPACE_STRING0(x) KWSYS_NAMESPACE_STRING1(x)
+# define KWSYS_NAMESPACE_STRING1(x) # x
#else
-#error "kwsysPrivate.h included multiple times."
+# error "kwsysPrivate.h included multiple times."
#endif
diff --git a/Source/kwsys/testCommandLineArguments.cxx b/Source/kwsys/testCommandLineArguments.cxx
index d2215d62f..1778a9ba8 100644
--- a/Source/kwsys/testCommandLineArguments.cxx
+++ b/Source/kwsys/testCommandLineArguments.cxx
@@ -6,7 +6,7 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "CommandLineArguments.hxx.in"
+# include "CommandLineArguments.hxx.in"
#endif
#include <iostream>
@@ -76,8 +76,8 @@ int testCommandLineArguments(int argc, char* argv[])
int some_int_variable = 10;
double some_double_variable = 10.10;
- char* some_string_variable = 0;
- std::string some_stl_string_variable = "";
+ char* some_string_variable = nullptr;
+ std::string some_stl_string_variable;
bool some_bool_variable = false;
bool some_bool_variable1 = false;
bool bool_arg1 = false;
@@ -136,7 +136,7 @@ int testCommandLineArguments(int argc, char* argv[])
arg.AddCallback("-C", argT::EQUAL_ARGUMENT, argument, random_ptr,
"Option -C takes argument after =");
arg.AddCallback("-D", argT::CONCAT_ARGUMENT, argument, random_ptr,
- "This option takes concatinated argument");
+ "This option takes concatenated argument");
arg.AddCallback("--long1", argT::NO_ARGUMENT, argument, random_ptr, "-A");
arg.AddCallback("--long2", argT::SPACE_ARGUMENT, argument, random_ptr, "-B");
arg.AddCallback("--long3", argT::EQUAL_ARGUMENT, argument, random_ptr,
@@ -165,25 +165,26 @@ int testCommandLineArguments(int argc, char* argv[])
}
size_t cc;
#define CompareTwoLists(list1, list_valid, lsize) \
- if (list1.size() != lsize) { \
- std::cerr << "Problem setting " #list1 ". Size is: " << list1.size() \
- << " should be: " << lsize << std::endl; \
- res = 1; \
- } else { \
- std::cout << #list1 " argument set:"; \
- for (cc = 0; cc < lsize; ++cc) { \
- std::cout << " " << list1[cc]; \
- if (!CompareTwoItemsOnList(list1[cc], list_valid[cc])) { \
- std::cerr << "Problem setting " #list1 ". Value of " << cc \
- << " is: [" << list1[cc] << "] <> [" << list_valid[cc] \
- << "]" << std::endl; \
- res = 1; \
- break; \
+ do { \
+ if (list1.size() != lsize) { \
+ std::cerr << "Problem setting " #list1 ". Size is: " << list1.size() \
+ << " should be: " << lsize << std::endl; \
+ res = 1; \
+ } else { \
+ std::cout << #list1 " argument set:"; \
+ for (cc = 0; cc < lsize; ++cc) { \
+ std::cout << " " << list1[cc]; \
+ if (!CompareTwoItemsOnList(list1[cc], list_valid[cc])) { \
+ std::cerr << "Problem setting " #list1 ". Value of " << cc \
+ << " is: [" << list1[cc] << "] <> [" << list_valid[cc] \
+ << "]" << std::endl; \
+ res = 1; \
+ break; \
+ } \
} \
+ std::cout << std::endl; \
} \
- std::cout << std::endl; \
- }
-
+ } while (0)
CompareTwoLists(numbers_argument, valid_numbers, 10);
CompareTwoLists(doubles_argument, valid_doubles, 3);
CompareTwoLists(bools_argument, valid_bools, 3);
@@ -202,7 +203,7 @@ int testCommandLineArguments(int argc, char* argv[])
for (cc = 0; cc < strings_argument.size(); ++cc) {
delete[] strings_argument[cc];
- strings_argument[cc] = 0;
+ strings_argument[cc] = nullptr;
}
return res;
}
diff --git a/Source/kwsys/testCommandLineArguments1.cxx b/Source/kwsys/testCommandLineArguments1.cxx
index 5a03401bc..64561b1e3 100644
--- a/Source/kwsys/testCommandLineArguments1.cxx
+++ b/Source/kwsys/testCommandLineArguments1.cxx
@@ -6,7 +6,7 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "CommandLineArguments.hxx.in"
+# include "CommandLineArguments.hxx.in"
#endif
#include <iostream>
@@ -21,7 +21,7 @@ int testCommandLineArguments1(int argc, char* argv[])
arg.Initialize(argc, argv);
int n = 0;
- char* m = 0;
+ char* m = nullptr;
std::string p;
int res = 0;
@@ -55,11 +55,11 @@ int testCommandLineArguments1(int argc, char* argv[])
delete[] m;
}
- char** newArgv = 0;
+ char** newArgv = nullptr;
int newArgc = 0;
arg.GetUnusedArguments(&newArgc, &newArgv);
int cc;
- const char* valid_unused_args[9] = { 0,
+ const char* valid_unused_args[9] = { nullptr,
"--ignored",
"--second-ignored",
"third-ignored",
diff --git a/Source/kwsys/testConfigure.cxx b/Source/kwsys/testConfigure.cxx
new file mode 100644
index 000000000..a3c2ed3ae
--- /dev/null
+++ b/Source/kwsys/testConfigure.cxx
@@ -0,0 +1,30 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
+#include "kwsysPrivate.h"
+#include KWSYS_HEADER(Configure.hxx)
+
+// Work-around CMake dependency scanning limitation. This must
+// duplicate the above list of headers.
+#if 0
+# include "Configure.hxx.in"
+#endif
+
+static bool testFallthrough(int n)
+{
+ int r = 0;
+ switch (n) {
+ case 1:
+ ++r;
+ KWSYS_FALLTHROUGH;
+ default:
+ ++r;
+ }
+ return r == 2;
+}
+
+int testConfigure(int, char* [])
+{
+ bool res = true;
+ res = testFallthrough(1) && res;
+ return res ? 0 : 1;
+}
diff --git a/Source/kwsys/testConsoleBuf.cxx b/Source/kwsys/testConsoleBuf.cxx
index 816a4338e..4b7ddf053 100644
--- a/Source/kwsys/testConsoleBuf.cxx
+++ b/Source/kwsys/testConsoleBuf.cxx
@@ -13,24 +13,24 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "Encoding.hxx.in"
+# include "Encoding.hxx.in"
#endif
#if defined(_WIN32)
-#include <algorithm>
-#include <iomanip>
-#include <iostream>
-#include <stdexcept>
-#include <string.h>
-#include <wchar.h>
-#include <windows.h>
+# include <algorithm>
+# include <iomanip>
+# include <iostream>
+# include <stdexcept>
+# include <string.h>
+# include <wchar.h>
+# include <windows.h>
-#include "testConsoleBuf.hxx"
+# include "testConsoleBuf.hxx"
-#if defined(_MSC_VER) && _MSC_VER >= 1800
-#define KWSYS_WINDOWS_DEPRECATED_GetVersion
-#endif
+# if defined(_MSC_VER) && _MSC_VER >= 1800
+# define KWSYS_WINDOWS_DEPRECATED_GetVersion
+# endif
// يونيكود
static const WCHAR UnicodeInputTestString[] =
L"\u064A\u0648\u0646\u064A\u0643\u0648\u062F!";
@@ -51,7 +51,7 @@ static void displayError(DWORD errorCode)
LPWSTR message;
if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, errorCode, 0, (LPWSTR)&message, 0, NULL)) {
+ nullptr, errorCode, 0, (LPWSTR)&message, 0, nullptr)) {
std::cerr << "Error message: " << kwsys::Encoding::ToNarrow(message)
<< std::endl;
HeapFree(GetProcessHeap(), 0, message);
@@ -124,7 +124,7 @@ static bool createProcess(HANDLE hIn, HANDLE hOut, HANDLE hErr)
}
WCHAR cmd[MAX_PATH];
- if (GetModuleFileNameW(NULL, cmd, MAX_PATH) == 0) {
+ if (GetModuleFileNameW(nullptr, cmd, MAX_PATH) == 0) {
std::cerr << "GetModuleFileName failed!" << std::endl;
return false;
}
@@ -136,14 +136,14 @@ static bool createProcess(HANDLE hIn, HANDLE hOut, HANDLE hErr)
wcscat(cmd, L".exe");
bool success =
- CreateProcessW(NULL, // No module name (use command line)
+ CreateProcessW(nullptr, // No module name (use command line)
cmd, // Command line
- NULL, // Process handle not inheritable
- NULL, // Thread handle not inheritable
+ nullptr, // Process handle not inheritable
+ nullptr, // Thread handle not inheritable
bInheritHandles, // Set handle inheritance
dwCreationFlags,
- NULL, // Use parent's environment block
- NULL, // Use parent's starting directory
+ nullptr, // Use parent's environment block
+ nullptr, // Use parent's starting directory
&startupInfo, // Pointer to STARTUPINFO structure
&processInfo) !=
0; // Pointer to PROCESS_INFORMATION structure
@@ -174,7 +174,7 @@ static bool createPipe(PHANDLE readPipe, PHANDLE writePipe)
SECURITY_ATTRIBUTES securityAttributes;
securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
securityAttributes.bInheritHandle = TRUE;
- securityAttributes.lpSecurityDescriptor = NULL;
+ securityAttributes.lpSecurityDescriptor = nullptr;
return CreatePipe(readPipe, writePipe, &securityAttributes, 0) == 0 ? false
: true;
}
@@ -194,7 +194,7 @@ static HANDLE createFile(LPCWSTR fileName)
SECURITY_ATTRIBUTES securityAttributes;
securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
securityAttributes.bInheritHandle = TRUE;
- securityAttributes.lpSecurityDescriptor = NULL;
+ securityAttributes.lpSecurityDescriptor = nullptr;
HANDLE file =
CreateFileW(fileName, GENERIC_READ | GENERIC_WRITE,
@@ -202,7 +202,7 @@ static HANDLE createFile(LPCWSTR fileName)
&securityAttributes,
CREATE_ALWAYS, // overwrite existing
FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE,
- NULL); // no template
+ nullptr); // no template
if (file == INVALID_HANDLE_VALUE) {
DWORD lastError = GetLastError();
std::cerr << "CreateFile(" << kwsys::Encoding::ToNarrow(fileName) << ")"
@@ -219,9 +219,9 @@ static void finishFile(HANDLE file)
}
}
-#ifndef MAPVK_VK_TO_VSC
-#define MAPVK_VK_TO_VSC (0)
-#endif
+# ifndef MAPVK_VK_TO_VSC
+# define MAPVK_VK_TO_VSC (0)
+# endif
static void writeInputKeyEvent(INPUT_RECORD inputBuffer[], WCHAR chr)
{
@@ -288,7 +288,7 @@ static int testPipe()
DWORD bytesWritten = 0;
if (!WriteFile(inPipeWrite, encodedInputTestString.c_str(),
(DWORD)encodedInputTestString.size(), &bytesWritten,
- NULL) ||
+ nullptr) ||
bytesWritten == 0) {
throw std::runtime_error("WriteFile failed!");
}
@@ -305,7 +305,8 @@ static int testPipe()
throw std::runtime_error("WaitForSingleObject failed!");
}
DWORD bytesRead = 0;
- if (!ReadFile(outPipeRead, buffer, sizeof(buffer), &bytesRead, NULL) ||
+ if (!ReadFile(outPipeRead, buffer, sizeof(buffer), &bytesRead,
+ nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#1 failed!");
}
@@ -313,7 +314,7 @@ static int testPipe()
if ((bytesRead <
encodedTestString.size() + 1 + encodedInputTestString.size() &&
!ReadFile(outPipeRead, buffer + bytesRead,
- sizeof(buffer) - bytesRead, &bytesRead, NULL)) ||
+ sizeof(buffer) - bytesRead, &bytesRead, nullptr)) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#2 failed!");
}
@@ -324,7 +325,7 @@ static int testPipe()
encodedInputTestString.size()) == 0) {
bytesRead = 0;
if (!ReadFile(errPipeRead, buffer2, sizeof(buffer2), &bytesRead,
- NULL) ||
+ nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#3 failed!");
}
@@ -383,13 +384,13 @@ static int testFile()
char buffer2[200];
int length;
- if ((length =
- WideCharToMultiByte(TestCodepage, 0, UnicodeInputTestString, -1,
- buffer, sizeof(buffer), NULL, NULL)) == 0) {
+ if ((length = WideCharToMultiByte(TestCodepage, 0, UnicodeInputTestString,
+ -1, buffer, sizeof(buffer), nullptr,
+ nullptr)) == 0) {
throw std::runtime_error("WideCharToMultiByte failed!");
}
buffer[length - 1] = '\n';
- if (!WriteFile(inFile, buffer, length, &bytesWritten, NULL) ||
+ if (!WriteFile(inFile, buffer, length, &bytesWritten, nullptr) ||
bytesWritten == 0) {
throw std::runtime_error("WriteFile failed!");
}
@@ -413,7 +414,7 @@ static int testFile()
INVALID_SET_FILE_POINTER) {
throw std::runtime_error("SetFilePointer#1 failed!");
}
- if (!ReadFile(outFile, buffer, sizeof(buffer), &bytesRead, NULL) ||
+ if (!ReadFile(outFile, buffer, sizeof(buffer), &bytesRead, nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#1 failed!");
}
@@ -429,7 +430,8 @@ static int testFile()
throw std::runtime_error("SetFilePointer#2 failed!");
}
- if (!ReadFile(errFile, buffer2, sizeof(buffer2), &bytesRead, NULL) ||
+ if (!ReadFile(errFile, buffer2, sizeof(buffer2), &bytesRead,
+ nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#2 failed!");
}
@@ -470,9 +472,9 @@ static int testFile()
return didFail;
}
-#ifndef _WIN32_WINNT_VISTA
-#define _WIN32_WINNT_VISTA 0x0600
-#endif
+# ifndef _WIN32_WINNT_VISTA
+# define _WIN32_WINNT_VISTA 0x0600
+# endif
static int testConsole()
{
@@ -495,29 +497,36 @@ static int testConsole()
DWORD FaceNameSize = sizeof(FaceName);
DWORD FontFamily = TestFontFamily;
DWORD FontSize = TestFontSize;
-#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersion
-#pragma warning(push)
-#ifdef __INTEL_COMPILER
-#pragma warning(disable : 1478)
-#else
-#pragma warning(disable : 4996)
-#endif
-#endif
+# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersion
+# pragma warning(push)
+# ifdef __INTEL_COMPILER
+# pragma warning(disable : 1478)
+# elif defined __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wdeprecated-declarations"
+# else
+# pragma warning(disable : 4996)
+# endif
+# endif
const bool isVistaOrGreater =
LOBYTE(LOWORD(GetVersion())) >= HIBYTE(_WIN32_WINNT_VISTA);
-#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersion
-#pragma warning(pop)
-#endif
+# ifdef KWSYS_WINDOWS_DEPRECATED_GetVersion
+# ifdef __clang__
+# pragma clang diagnostic pop
+# else
+# pragma warning(pop)
+# endif
+# endif
if (!isVistaOrGreater) {
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Console", 0, KEY_READ | KEY_WRITE,
&hConsoleKey) == ERROR_SUCCESS) {
DWORD dwordSize = sizeof(DWORD);
- if (RegQueryValueExW(hConsoleKey, L"FontFamily", NULL, NULL,
+ if (RegQueryValueExW(hConsoleKey, L"FontFamily", nullptr, nullptr,
(LPBYTE)&FontFamily, &dwordSize) == ERROR_SUCCESS) {
if (FontFamily != TestFontFamily) {
- RegQueryValueExW(hConsoleKey, L"FaceName", NULL, NULL,
+ RegQueryValueExW(hConsoleKey, L"FaceName", nullptr, nullptr,
(LPBYTE)FaceName, &FaceNameSize);
- RegQueryValueExW(hConsoleKey, L"FontSize", NULL, NULL,
+ RegQueryValueExW(hConsoleKey, L"FontSize", nullptr, nullptr,
(LPBYTE)&FontSize, &dwordSize);
RegSetValueExW(hConsoleKey, L"FontFamily", 0, REG_DWORD,
@@ -550,10 +559,10 @@ static int testConsole()
SECURITY_ATTRIBUTES securityAttributes;
securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
securityAttributes.bInheritHandle = TRUE;
- securityAttributes.lpSecurityDescriptor = NULL;
+ securityAttributes.lpSecurityDescriptor = nullptr;
hIn = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, &securityAttributes,
- OPEN_EXISTING, 0, NULL);
+ OPEN_EXISTING, 0, nullptr);
if (hIn == INVALID_HANDLE_VALUE) {
DWORD lastError = GetLastError();
std::cerr << "CreateFile(CONIN$)" << std::endl;
@@ -561,7 +570,7 @@ static int testConsole()
}
hOut = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, &securityAttributes,
- OPEN_EXISTING, 0, NULL);
+ OPEN_EXISTING, 0, nullptr);
if (hOut == INVALID_HANDLE_VALUE) {
DWORD lastError = GetLastError();
std::cerr << "CreateFile(CONOUT$)" << std::endl;
@@ -573,7 +582,7 @@ static int testConsole()
newConsole = true;
}
-#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+# if _WIN32_WINNT >= _WIN32_WINNT_VISTA
if (isVistaOrGreater) {
CONSOLE_FONT_INFOEX consoleFont;
memset(&consoleFont, 0, sizeof(consoleFont));
@@ -603,7 +612,7 @@ static int testConsole()
std::cerr << "GetCurrentConsoleFontEx failed!" << std::endl;
}
} else {
-#endif
+# endif
if (restoreConsole &&
RegOpenKeyExW(HKEY_CURRENT_USER, L"Console", 0, KEY_WRITE,
&hConsoleKey) == ERROR_SUCCESS) {
@@ -619,11 +628,11 @@ static int testConsole()
sizeof(FontSize));
RegCloseKey(hConsoleKey);
}
-#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+# if _WIN32_WINNT >= _WIN32_WINNT_VISTA
}
-#endif
+# endif
- if (createProcess(NULL, NULL, NULL)) {
+ if (createProcess(nullptr, nullptr, nullptr)) {
try {
DWORD status;
if ((status = WaitForSingleObject(beforeInputEvent, waitTimeout)) !=
@@ -739,7 +748,7 @@ int testConsoleBuf(int, char* [])
int ret = 0;
#if defined(_WIN32)
- beforeInputEvent = CreateEventW(NULL,
+ beforeInputEvent = CreateEventW(nullptr,
FALSE, // auto-reset event
FALSE, // initial state is nonsignaled
BeforeInputEventName); // object name
@@ -748,7 +757,7 @@ int testConsoleBuf(int, char* [])
return 1;
}
- afterOutputEvent = CreateEventW(NULL, FALSE, FALSE, AfterOutputEventName);
+ afterOutputEvent = CreateEventW(nullptr, FALSE, FALSE, AfterOutputEventName);
if (!afterOutputEvent) {
std::cerr << "CreateEvent#2 failed " << GetLastError() << std::endl;
return 1;
diff --git a/Source/kwsys/testConsoleBufChild.cxx b/Source/kwsys/testConsoleBufChild.cxx
index 6a743edcd..3c8fdc2e1 100644
--- a/Source/kwsys/testConsoleBufChild.cxx
+++ b/Source/kwsys/testConsoleBufChild.cxx
@@ -8,8 +8,8 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "ConsoleBuf.hxx.in"
-#include "Encoding.hxx.in"
+# include "ConsoleBuf.hxx.in"
+# include "Encoding.hxx.in"
#endif
#include <iostream>
diff --git a/Source/kwsys/testDirectory.cxx b/Source/kwsys/testDirectory.cxx
new file mode 100644
index 000000000..b1ab0c872
--- /dev/null
+++ b/Source/kwsys/testDirectory.cxx
@@ -0,0 +1,110 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
+#include "kwsysPrivate.h"
+#include KWSYS_HEADER(Directory.hxx)
+#include KWSYS_HEADER(Encoding.hxx)
+#include KWSYS_HEADER(SystemTools.hxx)
+
+// Work-around CMake dependency scanning limitation. This must
+// duplicate the above list of headers.
+#if 0
+# include "Directory.hxx.in"
+# include "Encoding.hxx.in"
+# include "SystemTools.hxx.in"
+#endif
+
+#include <fstream>
+#include <iostream>
+#include <sstream>
+
+#include <testSystemTools.h>
+
+int _doLongPathTest()
+{
+ using namespace kwsys;
+ static const int LONG_PATH_THRESHOLD = 512;
+ int res = 0;
+ std::string topdir(TEST_SYSTEMTOOLS_BINARY_DIR "/directory_testing/");
+ std::stringstream testpathstrm;
+ std::string testdirpath;
+ std::string extendedtestdirpath;
+
+ testpathstrm << topdir;
+ size_t pathlen = testpathstrm.str().length();
+ testpathstrm.seekp(0, std::ios_base::end);
+ while (pathlen < LONG_PATH_THRESHOLD) {
+ testpathstrm << "0123456789/";
+ pathlen = testpathstrm.str().length();
+ }
+
+ testdirpath = testpathstrm.str();
+#ifdef _WIN32
+ extendedtestdirpath =
+ Encoding::ToNarrow(SystemTools::ConvertToWindowsExtendedPath(testdirpath));
+#else
+ extendedtestdirpath = testdirpath;
+#endif
+
+ if (SystemTools::MakeDirectory(extendedtestdirpath)) {
+ std::ofstream testfile1(
+ (extendedtestdirpath + "longfilepathtest1.txt").c_str());
+ std::ofstream testfile2(
+ (extendedtestdirpath + "longfilepathtest2.txt").c_str());
+ testfile1 << "foo";
+ testfile2 << "bar";
+ testfile1.close();
+ testfile2.close();
+
+ Directory testdir;
+ // Set res to failure if the directory doesn't load
+ res += !testdir.Load(testdirpath);
+ // Increment res failure if the directory appears empty
+ res += testdir.GetNumberOfFiles() == 0;
+ // Increment res failures if the path has changed from
+ // what was provided.
+ res += testdirpath != testdir.GetPath();
+
+ SystemTools::RemoveADirectory(topdir);
+ } else {
+ std::cerr << "Failed to create directory with long path: "
+ << extendedtestdirpath << std::endl;
+ res += 1;
+ }
+ return res;
+}
+
+int _copyDirectoryTest()
+{
+ using namespace kwsys;
+ const std::string source(TEST_SYSTEMTOOLS_BINARY_DIR
+ "/directory_testing/copyDirectoryTestSrc");
+ if (SystemTools::PathExists(source)) {
+ std::cerr << source << " shouldn't exist before test" << std::endl;
+ return 1;
+ }
+ const std::string destination(TEST_SYSTEMTOOLS_BINARY_DIR
+ "/directory_testing/copyDirectoryTestDst");
+ if (SystemTools::PathExists(destination)) {
+ std::cerr << destination << " shouldn't exist before test" << std::endl;
+ return 2;
+ }
+ const bool copysuccess = SystemTools::CopyADirectory(source, destination);
+ const bool destinationexists = SystemTools::PathExists(destination);
+ if (copysuccess) {
+ std::cerr << "CopyADirectory should have returned false" << std::endl;
+ SystemTools::RemoveADirectory(destination);
+ return 3;
+ }
+ if (destinationexists) {
+ std::cerr << "CopyADirectory returned false, but destination directory"
+ << " has been created" << std::endl;
+ SystemTools::RemoveADirectory(destination);
+ return 4;
+ }
+ return 0;
+}
+
+int testDirectory(int, char* [])
+{
+ return _doLongPathTest() + _copyDirectoryTest();
+}
diff --git a/Source/kwsys/testDynamicLoader.cxx b/Source/kwsys/testDynamicLoader.cxx
index b52ddda8b..2421ac0e1 100644
--- a/Source/kwsys/testDynamicLoader.cxx
+++ b/Source/kwsys/testDynamicLoader.cxx
@@ -5,13 +5,13 @@
#include KWSYS_HEADER(DynamicLoader.hxx)
#if defined(__BEOS__) || defined(__HAIKU__)
-#include <be/kernel/OS.h> /* disable_debugger() API. */
+# include <be/kernel/OS.h> /* disable_debugger() API. */
#endif
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "DynamicLoader.hxx.in"
+# include "DynamicLoader.hxx.in"
#endif
#include <iostream>
@@ -21,11 +21,15 @@
// left on disk.
#include <testSystemTools.h>
-static std::string GetLibName(const char* lname)
+static std::string GetLibName(const char* lname, const char* subdir = nullptr)
{
// Construct proper name of lib
std::string slname;
slname = EXECUTABLE_OUTPUT_PATH;
+ if (subdir) {
+ slname += "/";
+ slname += subdir;
+ }
#ifdef CMAKE_INTDIR
slname += "/";
slname += CMAKE_INTDIR;
@@ -45,26 +49,29 @@ static std::string GetLibName(const char* lname)
* r3: should CloseLibrary succeed ?
*/
static int TestDynamicLoader(const char* libname, const char* symbol, int r1,
- int r2, int r3)
+ int r2, int r3, int flags = 0)
{
std::cerr << "Testing: " << libname << std::endl;
kwsys::DynamicLoader::LibraryHandle l =
- kwsys::DynamicLoader::OpenLibrary(libname);
+ kwsys::DynamicLoader::OpenLibrary(libname, flags);
// If result is incompatible with expectation just fails (xor):
if ((r1 && !l) || (!r1 && l)) {
- std::cerr << kwsys::DynamicLoader::LastError() << std::endl;
+ std::cerr << "OpenLibrary: " << kwsys::DynamicLoader::LastError()
+ << std::endl;
return 1;
}
kwsys::DynamicLoader::SymbolPointer f =
kwsys::DynamicLoader::GetSymbolAddress(l, symbol);
if ((r2 && !f) || (!r2 && f)) {
- std::cerr << kwsys::DynamicLoader::LastError() << std::endl;
+ std::cerr << "GetSymbolAddress: " << kwsys::DynamicLoader::LastError()
+ << std::endl;
return 1;
}
#ifndef __APPLE__
int s = kwsys::DynamicLoader::CloseLibrary(l);
if ((r3 && !s) || (!r3 && s)) {
- std::cerr << kwsys::DynamicLoader::LastError() << std::endl;
+ std::cerr << "CloseLibrary: " << kwsys::DynamicLoader::LastError()
+ << std::endl;
return 1;
}
#else
@@ -113,5 +120,14 @@ int testDynamicLoader(int argc, char* argv[])
res += TestDynamicLoader(libname.c_str(), "TestDynamicLoaderData", 1, 1, 1);
res += TestDynamicLoader(libname.c_str(), "_TestDynamicLoaderData", 1, 0, 1);
+#ifdef _WIN32
+ libname = GetLibName(KWSYS_NAMESPACE_STRING "TestDynloadUse", "dynloaddir");
+ res += TestDynamicLoader(libname.c_str(), "dummy", 0, 0, 0);
+ res += TestDynamicLoader(libname.c_str(), "TestLoad", 1, 1, 1,
+ kwsys::DynamicLoader::SearchBesideLibrary);
+ res += TestDynamicLoader(libname.c_str(), "_TestLoad", 1, 0, 1,
+ kwsys::DynamicLoader::SearchBesideLibrary);
+#endif
+
return res;
}
diff --git a/Source/kwsys/testDynload.c b/Source/kwsys/testDynload.c
index cdb9e5c35..c49f747df 100644
--- a/Source/kwsys/testDynload.c
+++ b/Source/kwsys/testDynload.c
@@ -1,9 +1,9 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#ifdef _WIN32
-#define DL_EXPORT __declspec(dllexport)
+# define DL_EXPORT __declspec(dllexport)
#else
-#define DL_EXPORT
+# define DL_EXPORT
#endif
DL_EXPORT int TestDynamicLoaderData = 0;
diff --git a/Source/kwsys/testDynloadImpl.c b/Source/kwsys/testDynloadImpl.c
new file mode 100644
index 000000000..2b9069bc7
--- /dev/null
+++ b/Source/kwsys/testDynloadImpl.c
@@ -0,0 +1,10 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
+
+#include "testDynloadImpl.h"
+
+int TestDynamicLoaderImplData = 0;
+
+void TestDynamicLoaderImplSymbolPointer()
+{
+}
diff --git a/Source/kwsys/testDynloadImpl.h b/Source/kwsys/testDynloadImpl.h
new file mode 100644
index 000000000..d0c9dfb75
--- /dev/null
+++ b/Source/kwsys/testDynloadImpl.h
@@ -0,0 +1,15 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
+#ifdef _WIN32
+# ifdef BUILDING_TestDynloadImpl
+# define DLIMPL_EXPORT __declspec(dllexport)
+# else
+# define DLIMPL_EXPORT __declspec(dllimport)
+# endif
+#else
+# define DLIMPL_EXPORT
+#endif
+
+DLIMPL_EXPORT int TestDynamicLoaderImplData;
+
+DLIMPL_EXPORT void TestDynamicLoaderImplSymbolPointer();
diff --git a/Source/kwsys/testDynloadUse.c b/Source/kwsys/testDynloadUse.c
new file mode 100644
index 000000000..5402add6a
--- /dev/null
+++ b/Source/kwsys/testDynloadUse.c
@@ -0,0 +1,15 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
+#include "testDynloadImpl.h"
+
+#ifdef _WIN32
+# define DL_EXPORT __declspec(dllexport)
+#else
+# define DL_EXPORT
+#endif
+
+DL_EXPORT int TestLoad()
+{
+ TestDynamicLoaderImplSymbolPointer();
+ return TestDynamicLoaderImplData;
+}
diff --git a/Source/kwsys/testEncode.c b/Source/kwsys/testEncode.c
index a20d46fd3..b7b6dd845 100644
--- a/Source/kwsys/testEncode.c
+++ b/Source/kwsys/testEncode.c
@@ -6,7 +6,7 @@
/* Work-around CMake dependency scanning limitation. This must
duplicate the above list of headers. */
#if 0
-#include "MD5.h.in"
+# include "MD5.h.in"
#endif
#include <stdio.h>
diff --git a/Source/kwsys/testEncoding.cxx b/Source/kwsys/testEncoding.cxx
index 2c5ef46eb..988697bff 100644
--- a/Source/kwsys/testEncoding.cxx
+++ b/Source/kwsys/testEncoding.cxx
@@ -3,7 +3,7 @@
#include "kwsysPrivate.h"
#if defined(_MSC_VER)
-#pragma warning(disable : 4786)
+# pragma warning(disable : 4786)
#endif
#include KWSYS_HEADER(Encoding.hxx)
@@ -18,8 +18,8 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "Encoding.h.in"
-#include "Encoding.hxx.in"
+# include "Encoding.h.in"
+# include "Encoding.hxx.in"
#endif
static const unsigned char helloWorldStrings[][32] = {
@@ -75,12 +75,16 @@ static int testRobustEncoding()
// test that the conversion functions handle invalid
// unicode correctly/gracefully
+ // we manipulate the format flags of stdout, remember
+ // the original state here to restore before return
+ std::ios::fmtflags const& flags = std::cout.flags();
+
int ret = 0;
char cstr[] = { (char)-1, 0 };
// this conversion could fail
std::wstring wstr = kwsys::Encoding::ToWide(cstr);
- wstr = kwsys::Encoding::ToWide(NULL);
+ wstr = kwsys::Encoding::ToWide(nullptr);
if (wstr != L"") {
const wchar_t* wcstr = wstr.c_str();
std::cout << "ToWide(NULL) returned";
@@ -108,7 +112,7 @@ static int testRobustEncoding()
std::string win_str = kwsys::Encoding::ToNarrow(cwstr);
#endif
- std::string str = kwsys::Encoding::ToNarrow(NULL);
+ std::string str = kwsys::Encoding::ToNarrow(nullptr);
if (str != "") {
std::cout << "ToNarrow(NULL) returned " << str << std::endl;
ret++;
@@ -120,6 +124,7 @@ static int testRobustEncoding()
ret++;
}
+ std::cout.flags(flags);
return ret;
}
diff --git a/Source/kwsys/testFStream.cxx b/Source/kwsys/testFStream.cxx
index a92a781c3..5009e9887 100644
--- a/Source/kwsys/testFStream.cxx
+++ b/Source/kwsys/testFStream.cxx
@@ -3,19 +3,19 @@
#include "kwsysPrivate.h"
#if defined(_MSC_VER)
-#pragma warning(disable : 4786)
+# pragma warning(disable : 4786)
#endif
#include KWSYS_HEADER(FStream.hxx)
#include <string.h>
#ifdef __BORLANDC__
-#include <mem.h> /* memcmp */
+# include <mem.h> /* memcmp */
#endif
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "FStream.hxx.in"
+# include "FStream.hxx.in"
#endif
#include <iostream>
diff --git a/Source/kwsys/testHashSTL.cxx b/Source/kwsys/testHashSTL.cxx
index 044487473..4ed2f899d 100644
--- a/Source/kwsys/testHashSTL.cxx
+++ b/Source/kwsys/testHashSTL.cxx
@@ -7,18 +7,19 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "hash_map.hxx.in"
-#include "hash_set.hxx.in"
+# include "hash_map.hxx.in"
+# include "hash_set.hxx.in"
#endif
#include <iostream>
#if defined(_MSC_VER)
-#pragma warning(disable : 4786)
+# pragma warning(disable : 4786)
#endif
#if defined(__sgi) && !defined(__GNUC__)
-#pragma set woff 1468 /* inline function cannot be explicitly instantiated */
+# pragma set woff 1468 /* inline function cannot be explicitly instantiated \
+ */
#endif
template class kwsys::hash_map<const char*, int>;
diff --git a/Source/kwsys/testIOS.cxx b/Source/kwsys/testIOS.cxx
deleted file mode 100644
index 3e4c325c7..000000000
--- a/Source/kwsys/testIOS.cxx
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
-#include "kwsysPrivate.h"
-#include KWSYS_HEADER(Configure.hxx)
-
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <string.h> /* strlen */
-#include <vector>
-
-// Work-around CMake dependency scanning limitation. This must
-// duplicate the above list of headers.
-#if 0
-#include "Configure.hxx.in"
-#endif
-
-int testIOS(int, char* [])
-{
- std::ostringstream ostr;
- const char hello[] = "hello";
- ostr << hello;
- if (ostr.str() != hello) {
- std::cerr << "failed to write hello to ostr" << std::endl;
- return 1;
- }
- const char world[] = "world";
- std::ostringstream ostr2;
- ostr2.write(hello, strlen(hello)); /* I could do sizeof */
- ostr2.put('\0');
- ostr2.write(world, strlen(world));
- if (ostr2.str().size() != strlen(hello) + 1 + strlen(world)) {
- std::cerr << "failed to write hello to ostr2" << std::endl;
- return 1;
- }
- static const unsigned char array[] = {
- 0xff, 0x4f, 0xff, 0x51, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
- 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01, 0x01, 0xff, 0x52, 0x00,
- 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x04, 0x04, 0x00, 0x01, 0xff,
- 0x5c, 0x00, 0x13, 0x40, 0x40, 0x48, 0x48, 0x50, 0x48, 0x48, 0x50, 0x48,
- 0x48, 0x50, 0x48, 0x48, 0x50, 0x48, 0x48, 0x50, 0xff, 0x64, 0x00, 0x2c,
- 0x00, 0x00, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x62, 0x79,
- 0x20, 0x49, 0x54, 0x4b, 0x2f, 0x47, 0x44, 0x43, 0x4d, 0x2f, 0x4f, 0x70,
- 0x65, 0x6e, 0x4a, 0x50, 0x45, 0x47, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69,
- 0x6f, 0x6e, 0x20, 0x31, 0x2e, 0x30, 0xff, 0x90, 0x00, 0x0a, 0x00, 0x00,
- 0x00, 0x00, 0x06, 0x2c, 0x00, 0x01, 0xff, 0x93, 0xcf, 0xb0, 0x18, 0x08,
- 0x7f, 0xc6, 0x99, 0xbf, 0xff, 0xc0, 0xf8, 0xc1, 0xc1, 0xf3, 0x05, 0x81,
- 0xf2, 0x83, 0x0a, 0xa5, 0xff, 0x10, 0x90, 0xbf, 0x2f, 0xff, 0x04, 0xa8,
- 0x7f, 0xc0, 0xf8, 0xc4, 0xc1, 0xf3, 0x09, 0x81, 0xf3, 0x0c, 0x19, 0x34
- };
- const size_t narray = sizeof(array); // 180
- std::stringstream strstr;
- strstr.write((char*)array, narray);
- // strstr.seekp( narray / 2 ); // set position of put pointer in mid string
- if (strstr.str().size() != narray) {
- std::cerr << "failed to write array to strstr" << std::endl;
- return 1;
- }
-
- std::istringstream istr(" 10 20 str ");
- std::string s;
- int x;
- if (istr >> x) {
- if (x != 10) {
- std::cerr << "x != 10" << std::endl;
- return 1;
- }
- } else {
- std::cerr << "Failed to read 10 from istr" << std::endl;
- return 1;
- }
- if (istr >> x) {
- if (x != 20) {
- std::cerr << "x != 20" << std::endl;
- return 1;
- }
- } else {
- std::cerr << "Failed to read 20 from istr" << std::endl;
- return 1;
- }
- if (istr >> s) {
- if (s != "str") {
- std::cerr << "s != \"str\"" << std::endl;
- return 1;
- }
- } else {
- std::cerr << "Failed to read str from istr" << std::endl;
- return 1;
- }
- if (istr >> s) {
- std::cerr << "Able to read past end of stream" << std::endl;
- return 1;
- } else {
- // Clear the failure.
- istr.clear(istr.rdstate() & ~std::ios::eofbit);
- istr.clear(istr.rdstate() & ~std::ios::failbit);
- }
- istr.str("30");
- if (istr >> x) {
- if (x != 30) {
- std::cerr << "x != 30" << std::endl;
- return 1;
- }
- } else {
- std::cerr << "Failed to read 30 from istr" << std::endl;
- return 1;
- }
-
- std::stringstream sstr;
- sstr << "40 str2";
- if (sstr >> x) {
- if (x != 40) {
- std::cerr << "x != 40" << std::endl;
- return 1;
- }
- } else {
- std::cerr << "Failed to read 40 from sstr" << std::endl;
- return 1;
- }
- if (sstr >> s) {
- if (s != "str2") {
- std::cerr << "s != \"str2\"" << std::endl;
- return 1;
- }
- } else {
- std::cerr << "Failed to read str2 from sstr" << std::endl;
- return 1;
- }
-
- // Just try to compile this.
- if (x == 12345) {
- std::ifstream fin("/does_not_exist", std::ios::in | std::ios::binary);
- }
-
- std::cout << "IOS tests passed" << std::endl;
- return 0;
-}
diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c
index 092dd0347..39aaa23ba 100644
--- a/Source/kwsys/testProcess.c
+++ b/Source/kwsys/testProcess.c
@@ -7,8 +7,8 @@
/* Work-around CMake dependency scanning limitation. This must
duplicate the above list of headers. */
#if 0
-#include "Encoding.h.in"
-#include "Process.h.in"
+# include "Encoding.h.in"
+# include "Process.h.in"
#endif
#include <assert.h>
@@ -18,21 +18,21 @@
#include <string.h>
#if defined(_WIN32)
-#include <windows.h>
+# include <windows.h>
#else
-#include <signal.h>
-#include <unistd.h>
+# include <signal.h>
+# include <unistd.h>
#endif
#if defined(__BORLANDC__)
-#pragma warn - 8060 /* possibly incorrect assignment */
+# pragma warn - 8060 /* possibly incorrect assignment */
#endif
/* Platform-specific sleep functions. */
#if defined(__BEOS__) && !defined(__ZETA__)
/* BeOS 5 doesn't have usleep(), but it has snooze(), which is identical. */
-#include <be/kernel/OS.h>
+# include <be/kernel/OS.h>
static inline void testProcess_usleep(unsigned int usec)
{
snooze(usec);
@@ -44,7 +44,7 @@ static void testProcess_usleep(unsigned int usec)
Sleep(usec / 1000);
}
#else
-#define testProcess_usleep usleep
+# define testProcess_usleep usleep
#endif
#if defined(_WIN32)
@@ -107,6 +107,7 @@ static int test3(int argc, const char* argv[])
static int test4(int argc, const char* argv[])
{
+#ifndef CRASH_USING_ABORT
/* Prepare a pointer to an invalid address. Don't use null, because
dereferencing null is undefined behaviour and compilers are free to
do whatever they want. ex: Clang will warn at compile time, or even
@@ -114,6 +115,7 @@ static int test4(int argc, const char* argv[])
'volatile' and a slightly larger address, based on a runtime value. */
volatile int* invalidAddress = 0;
invalidAddress += argc ? 1 : 2;
+#endif
#if defined(_WIN32)
/* Avoid error diagnostic popups since we are crashing on purpose. */
@@ -128,9 +130,13 @@ static int test4(int argc, const char* argv[])
fprintf(stderr, "Output before crash on stderr from crash test.\n");
fflush(stdout);
fflush(stderr);
+#ifdef CRASH_USING_ABORT
+ abort();
+#else
assert(invalidAddress); /* Quiet Clang scan-build. */
/* Provoke deliberate crash by writing to the invalid address. */
*invalidAddress = 0;
+#endif
fprintf(stdout, "Output after crash on stdout from crash test.\n");
fprintf(stderr, "Output after crash on stderr from crash test.\n");
return 0;
@@ -149,7 +155,12 @@ static int test5(int argc, const char* argv[])
fprintf(stderr, "Output on stderr before recursive test.\n");
fflush(stdout);
fflush(stderr);
- r = runChild(cmd, kwsysProcess_State_Exception, kwsysProcess_Exception_Fault,
+ r = runChild(cmd, kwsysProcess_State_Exception,
+#ifdef CRASH_USING_ABORT
+ kwsysProcess_Exception_Other,
+#else
+ kwsysProcess_Exception_Fault,
+#endif
1, 1, 1, 0, 15, 0, 1, 0, 0, 0);
fprintf(stdout, "Output on stdout after recursive test.\n");
fprintf(stderr, "Output on stderr after recursive test.\n");
@@ -466,24 +477,27 @@ static int runChild2(kwsysProcess* kp, const char* cmd[], int state,
printf("Error in administrating child process: [%s]\n",
kwsysProcess_GetErrorString(kp));
break;
- };
+ }
if (result) {
if (exception != kwsysProcess_GetExitException(kp)) {
- fprintf(stderr, "Mismatch in exit exception. "
- "Should have been %d, was %d.\n",
+ fprintf(stderr,
+ "Mismatch in exit exception. "
+ "Should have been %d, was %d.\n",
exception, kwsysProcess_GetExitException(kp));
}
if (value != kwsysProcess_GetExitValue(kp)) {
- fprintf(stderr, "Mismatch in exit value. "
- "Should have been %d, was %d.\n",
+ fprintf(stderr,
+ "Mismatch in exit value. "
+ "Should have been %d, was %d.\n",
value, kwsysProcess_GetExitValue(kp));
}
}
if (kwsysProcess_GetState(kp) != state) {
- fprintf(stderr, "Mismatch in state. "
- "Should have been %d, was %d.\n",
+ fprintf(stderr,
+ "Mismatch in state. "
+ "Should have been %d, was %d.\n",
state, kwsysProcess_GetState(kp));
result = 1;
}
@@ -628,11 +642,16 @@ int main(int argc, const char* argv[])
kwsysProcess_State_Exception /* Process group test */
};
int exceptions[10] = {
- kwsysProcess_Exception_None, kwsysProcess_Exception_None,
- kwsysProcess_Exception_None, kwsysProcess_Exception_Fault,
- kwsysProcess_Exception_None, kwsysProcess_Exception_None,
- kwsysProcess_Exception_None, kwsysProcess_Exception_None,
- kwsysProcess_Exception_None, kwsysProcess_Exception_Interrupt
+ kwsysProcess_Exception_None, kwsysProcess_Exception_None,
+ kwsysProcess_Exception_None,
+#ifdef CRASH_USING_ABORT
+ kwsysProcess_Exception_Other,
+#else
+ kwsysProcess_Exception_Fault,
+#endif
+ kwsysProcess_Exception_None, kwsysProcess_Exception_None,
+ kwsysProcess_Exception_None, kwsysProcess_Exception_None,
+ kwsysProcess_Exception_None, kwsysProcess_Exception_Interrupt
};
int values[10] = { 0, 123, 1, 1, 0, 0, 0, 0, 1, 1 };
int shares[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1 };
@@ -687,9 +706,7 @@ int main(int argc, const char* argv[])
fflush(stdout);
fflush(stderr);
#if defined(_WIN32)
- if (argv0) {
- free(argv0);
- }
+ free(argv0);
#endif
return r;
} else if (argc > 2 && strcmp(argv[1], "0") == 0) {
diff --git a/Source/kwsys/testSharedForward.c.in b/Source/kwsys/testSharedForward.c.in
index 9a0c0c061..b3eb41382 100644
--- a/Source/kwsys/testSharedForward.c.in
+++ b/Source/kwsys/testSharedForward.c.in
@@ -1,11 +1,11 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing#kwsys for details. */
#if defined(CMAKE_INTDIR)
-#define CONFIG_DIR_PRE CMAKE_INTDIR "/"
-#define CONFIG_DIR_POST "/" CMAKE_INTDIR
+# define CONFIG_DIR_PRE CMAKE_INTDIR "/"
+# define CONFIG_DIR_POST "/" CMAKE_INTDIR
#else
-#define CONFIG_DIR_PRE ""
-#define CONFIG_DIR_POST ""
+# define CONFIG_DIR_PRE ""
+# define CONFIG_DIR_POST ""
#endif
#define @KWSYS_NAMESPACE@_SHARED_FORWARD_DIR_BUILD "@EXEC_DIR@"
#define @KWSYS_NAMESPACE@_SHARED_FORWARD_PATH_BUILD "." CONFIG_DIR_POST
@@ -18,7 +18,7 @@
#define @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_PRINT "--print"
#define @KWSYS_NAMESPACE@_SHARED_FORWARD_OPTION_LDD "--ldd"
#if defined(CMAKE_INTDIR)
-#define @KWSYS_NAMESPACE@_SHARED_FORWARD_CONFIG_NAME CMAKE_INTDIR
+# define @KWSYS_NAMESPACE@_SHARED_FORWARD_CONFIG_NAME CMAKE_INTDIR
#endif
#include <@KWSYS_NAMESPACE@/SharedForward.h>
int main(int argc, char** argv)
diff --git a/Source/kwsys/testSystemInformation.cxx b/Source/kwsys/testSystemInformation.cxx
index 3a9217f2c..154517eae 100644
--- a/Source/kwsys/testSystemInformation.cxx
+++ b/Source/kwsys/testSystemInformation.cxx
@@ -6,25 +6,25 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "SystemInformation.hxx.in"
+# include "SystemInformation.hxx.in"
#endif
#include <iostream>
#if defined(KWSYS_USE_LONG_LONG)
-#if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG)
-#define iostreamLongLong(x) (x)
-#else
-#define iostreamLongLong(x) ((long)x)
-#endif
+# if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG)
+# define iostreamLongLong(x) (x)
+# else
+# define iostreamLongLong(x) ((long)x)
+# endif
#elif defined(KWSYS_USE___INT64)
-#if defined(KWSYS_IOS_HAS_OSTREAM___INT64)
-#define iostreamLongLong(x) (x)
+# if defined(KWSYS_IOS_HAS_OSTREAM___INT64)
+# define iostreamLongLong(x) (x)
+# else
+# define iostreamLongLong(x) ((long)x)
+# endif
#else
-#define iostreamLongLong(x) ((long)x)
-#endif
-#else
-#error "No Long Long"
+# error "No Long Long"
#endif
#define printMethod(info, m) std::cout << #m << ": " << info.m() << "\n"
@@ -86,7 +86,7 @@ int testSystemInformation(int, char* [])
}
/* test stack trace
- */
+ */
std::cout << "Program Stack:" << std::endl
<< kwsys::SystemInformation::GetProgramStack(0, 0) << std::endl
<< std::endl;
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index e6fbf6cda..1f3a15b59 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -3,7 +3,7 @@
#include "kwsysPrivate.h"
#if defined(_MSC_VER)
-#pragma warning(disable : 4786)
+# pragma warning(disable : 4786)
#endif
#include KWSYS_HEADER(FStream.hxx)
@@ -12,8 +12,8 @@
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
-#include "FStream.hxx.in"
-#include "SystemTools.hxx.in"
+# include "FStream.hxx.in"
+# include "SystemTools.hxx.in"
#endif
// Include with <> instead of "" to avoid getting any in-source copy
@@ -22,12 +22,13 @@
#include <iostream>
#include <sstream>
+#include <stdlib.h> /* free */
#include <string.h> /* strcmp */
#if defined(_WIN32) && !defined(__CYGWIN__)
-#include <io.h> /* _umask (MSVC) / umask (Borland) */
-#ifdef _MSC_VER
-#define umask _umask // Note this is still umask on Borland
-#endif
+# include <io.h> /* _umask (MSVC) / umask (Borland) */
+# ifdef _MSC_VER
+# define umask _umask // Note this is still umask on Borland
+# endif
#endif
#include <sys/stat.h> /* umask (POSIX), _S_I* constants (Windows) */
// Visual C++ does not define mode_t (note that Borland does, however).
@@ -38,20 +39,20 @@ typedef unsigned short mode_t;
static const char* toUnixPaths[][2] = {
{ "/usr/local/bin/passwd", "/usr/local/bin/passwd" },
{ "/usr/lo cal/bin/pa sswd", "/usr/lo cal/bin/pa sswd" },
- { "/usr/lo\\ cal/bin/pa\\ sswd", "/usr/lo\\ cal/bin/pa\\ sswd" },
+ { "/usr/lo\\ cal/bin/pa\\ sswd", "/usr/lo/ cal/bin/pa/ sswd" },
{ "c:/usr/local/bin/passwd", "c:/usr/local/bin/passwd" },
{ "c:/usr/lo cal/bin/pa sswd", "c:/usr/lo cal/bin/pa sswd" },
- { "c:/usr/lo\\ cal/bin/pa\\ sswd", "c:/usr/lo\\ cal/bin/pa\\ sswd" },
+ { "c:/usr/lo\\ cal/bin/pa\\ sswd", "c:/usr/lo/ cal/bin/pa/ sswd" },
{ "\\usr\\local\\bin\\passwd", "/usr/local/bin/passwd" },
{ "\\usr\\lo cal\\bin\\pa sswd", "/usr/lo cal/bin/pa sswd" },
- { "\\usr\\lo\\ cal\\bin\\pa\\ sswd", "/usr/lo\\ cal/bin/pa\\ sswd" },
+ { "\\usr\\lo\\ cal\\bin\\pa\\ sswd", "/usr/lo/ cal/bin/pa/ sswd" },
{ "c:\\usr\\local\\bin\\passwd", "c:/usr/local/bin/passwd" },
{ "c:\\usr\\lo cal\\bin\\pa sswd", "c:/usr/lo cal/bin/pa sswd" },
- { "c:\\usr\\lo\\ cal\\bin\\pa\\ sswd", "c:/usr/lo\\ cal/bin/pa\\ sswd" },
+ { "c:\\usr\\lo\\ cal\\bin\\pa\\ sswd", "c:/usr/lo/ cal/bin/pa/ sswd" },
{ "\\\\usr\\local\\bin\\passwd", "//usr/local/bin/passwd" },
{ "\\\\usr\\lo cal\\bin\\pa sswd", "//usr/lo cal/bin/pa sswd" },
- { "\\\\usr\\lo\\ cal\\bin\\pa\\ sswd", "//usr/lo\\ cal/bin/pa\\ sswd" },
- { 0, 0 }
+ { "\\\\usr\\lo\\ cal\\bin\\pa\\ sswd", "//usr/lo/ cal/bin/pa/ sswd" },
+ { nullptr, nullptr }
};
static bool CheckConvertToUnixSlashes(std::string const& input,
@@ -67,10 +68,11 @@ static bool CheckConvertToUnixSlashes(std::string const& input,
return true;
}
-static const char* checkEscapeChars[][4] = { { "1 foo 2 bar 2", "12", "\\",
- "\\1 foo \\2 bar \\2" },
- { " {} ", "{}", "#", " #{#} " },
- { 0, 0, 0, 0 } };
+static const char* checkEscapeChars[][4] = {
+ { "1 foo 2 bar 2", "12", "\\", "\\1 foo \\2 bar \\2" },
+ { " {} ", "{}", "#", " #{#} " },
+ { nullptr, nullptr, nullptr, nullptr }
+};
static bool CheckEscapeChars(std::string const& input,
const char* chars_to_escape, char escape_char,
@@ -158,7 +160,7 @@ static bool CheckFileOperations()
res = false;
}
// calling with 0 pointer should return false
- if (kwsys::SystemTools::MakeDirectory(0)) {
+ if (kwsys::SystemTools::MakeDirectory(nullptr)) {
std::cerr << "Problem with MakeDirectory(0)" << std::endl;
res = false;
}
@@ -204,7 +206,7 @@ static bool CheckFileOperations()
res = false;
}
- if (!kwsys::SystemTools::Touch(testNewFile.c_str(), true)) {
+ if (!kwsys::SystemTools::Touch(testNewFile, true)) {
std::cerr << "Problem with Touch for: " << testNewFile << std::endl;
res = false;
}
@@ -216,11 +218,11 @@ static bool CheckFileOperations()
}
// calling with 0 pointer should return false
- if (kwsys::SystemTools::FileExists(0)) {
+ if (kwsys::SystemTools::FileExists(nullptr)) {
std::cerr << "Problem with FileExists(0)" << std::endl;
res = false;
}
- if (kwsys::SystemTools::FileExists(0, true)) {
+ if (kwsys::SystemTools::FileExists(nullptr, true)) {
std::cerr << "Problem with FileExists(0) as file" << std::endl;
res = false;
}
@@ -253,22 +255,22 @@ static bool CheckFileOperations()
}
// should work, was created as new file before
if (!kwsys::SystemTools::FileExists(testNewFile)) {
- std::cerr << "Problem with FileExists for: " << testNewDir << std::endl;
+ std::cerr << "Problem with FileExists for: " << testNewFile << std::endl;
res = false;
}
if (!kwsys::SystemTools::FileExists(testNewFile.c_str())) {
- std::cerr << "Problem with FileExists as C string for: " << testNewDir
+ std::cerr << "Problem with FileExists as C string for: " << testNewFile
<< std::endl;
res = false;
}
if (!kwsys::SystemTools::FileExists(testNewFile, true)) {
- std::cerr << "Problem with FileExists as file for: " << testNewDir
+ std::cerr << "Problem with FileExists as file for: " << testNewFile
<< std::endl;
res = false;
}
if (!kwsys::SystemTools::FileExists(testNewFile.c_str(), true)) {
std::cerr << "Problem with FileExists as C string and file for: "
- << testNewDir << std::endl;
+ << testNewFile << std::endl;
res = false;
}
@@ -284,7 +286,7 @@ static bool CheckFileOperations()
}
// should work, was created as new file before
if (!kwsys::SystemTools::PathExists(testNewFile)) {
- std::cerr << "Problem with PathExists for: " << testNewDir << std::endl;
+ std::cerr << "Problem with PathExists for: " << testNewFile << std::endl;
res = false;
}
@@ -413,7 +415,7 @@ static bool CheckFileOperations()
res = false;
}
- kwsys::SystemTools::Touch(testNewFile.c_str(), true);
+ kwsys::SystemTools::Touch(testNewFile, true);
if (!kwsys::SystemTools::RemoveADirectory(testNewDir)) {
std::cerr << "Problem with RemoveADirectory for: " << testNewDir
<< std::endl;
@@ -535,15 +537,14 @@ static bool CheckStringOperations()
}
delete[] cres;
- char* cres2 = new char[strlen("Mary Had A Little Lamb.") + 1];
- strcpy(cres2, "Mary Had A Little Lamb.");
+ char* cres2 = strdup("Mary Had A Little Lamb.");
kwsys::SystemTools::ReplaceChars(cres2, "aeiou", 'X');
if (strcmp(cres2, "MXry HXd A LXttlX LXmb.")) {
std::cerr << "Problem with ReplaceChars "
<< "\"Mary Had A Little Lamb.\"" << std::endl;
res = false;
}
- delete[] cres2;
+ free(cres2);
if (!kwsys::SystemTools::StringStartsWith("Mary Had A Little Lamb.",
"Mary ")) {
@@ -683,9 +684,10 @@ static bool CheckRelativePaths()
}
static bool CheckCollapsePath(const std::string& path,
- const std::string& expected)
+ const std::string& expected,
+ const char* base = nullptr)
{
- std::string result = kwsys::SystemTools::CollapseFullPath(path);
+ std::string result = kwsys::SystemTools::CollapseFullPath(path, base);
if (!kwsys::SystemTools::ComparePath(expected, result)) {
std::cerr << "CollapseFullPath(" << path << ") yielded " << result
<< " instead of " << expected << std::endl;
@@ -699,6 +701,19 @@ static bool CheckCollapsePath()
bool res = true;
res &= CheckCollapsePath("/usr/share/*", "/usr/share/*");
res &= CheckCollapsePath("C:/Windows/*", "C:/Windows/*");
+ res &= CheckCollapsePath("/usr/share/../lib", "/usr/lib");
+ res &= CheckCollapsePath("/usr/share/./lib", "/usr/share/lib");
+ res &= CheckCollapsePath("/usr/share/../../lib", "/lib");
+ res &= CheckCollapsePath("/usr/share/.././../lib", "/lib");
+ res &= CheckCollapsePath("/../lib", "/lib");
+ res &= CheckCollapsePath("/../lib/", "/lib");
+ res &= CheckCollapsePath("/", "/");
+ res &= CheckCollapsePath("C:/", "C:/");
+ res &= CheckCollapsePath("C:/../", "C:/");
+ res &= CheckCollapsePath("C:/../../", "C:/");
+ res &= CheckCollapsePath("../b", "../../b", "../");
+ res &= CheckCollapsePath("../a/../b", "../b", "../rel");
+ res &= CheckCollapsePath("a/../b", "../rel/b", "../rel");
return res;
}
@@ -727,29 +742,29 @@ static bool CheckGetPath()
#endif
const char* registryPath = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MyApp; MyKey]";
- std::vector<std::string> originalPathes;
- originalPathes.push_back(registryPath);
+ std::vector<std::string> originalPaths;
+ originalPaths.push_back(registryPath);
- std::vector<std::string> expectedPathes;
- expectedPathes.push_back(registryPath);
+ std::vector<std::string> expectedPaths;
+ expectedPaths.push_back(registryPath);
#ifdef _WIN32
- expectedPathes.push_back("C:/Somewhere/something");
- expectedPathes.push_back("D:/Temp");
+ expectedPaths.push_back("C:/Somewhere/something");
+ expectedPaths.push_back("D:/Temp");
#else
- expectedPathes.push_back("/Somewhere/something");
- expectedPathes.push_back("/tmp");
+ expectedPaths.push_back("/Somewhere/something");
+ expectedPaths.push_back("/tmp");
#endif
bool res = true;
res &= CheckPutEnv(std::string(envName) + "=" + envValue, envName, envValue);
- std::vector<std::string> pathes = originalPathes;
- kwsys::SystemTools::GetPath(pathes, envName);
+ std::vector<std::string> paths = originalPaths;
+ kwsys::SystemTools::GetPath(paths, envName);
- if (pathes != expectedPathes) {
- std::cerr << "GetPath(" << StringVectorToString(originalPathes) << ", "
- << envName << ") yielded " << StringVectorToString(pathes)
- << " instead of " << StringVectorToString(expectedPathes)
+ if (paths != expectedPaths) {
+ std::cerr << "GetPath(" << StringVectorToString(originalPaths) << ", "
+ << envName << ") yielded " << StringVectorToString(paths)
+ << " instead of " << StringVectorToString(expectedPaths)
<< std::endl;
res = false;
}
@@ -758,6 +773,36 @@ static bool CheckGetPath()
return res;
}
+static bool CheckGetFilenameName()
+{
+ const char* windowsFilepath = "C:\\somewhere\\something";
+ const char* unixFilepath = "/somewhere/something";
+
+#if defined(_WIN32) || defined(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES)
+ std::string expectedWindowsFilename = "something";
+#else
+ std::string expectedWindowsFilename = "C:\\somewhere\\something";
+#endif
+ std::string expectedUnixFilename = "something";
+
+ bool res = true;
+ std::string filename = kwsys::SystemTools::GetFilenameName(windowsFilepath);
+ if (filename != expectedWindowsFilename) {
+ std::cerr << "GetFilenameName(" << windowsFilepath << ") yielded "
+ << filename << " instead of " << expectedWindowsFilename
+ << std::endl;
+ res = false;
+ }
+
+ filename = kwsys::SystemTools::GetFilenameName(unixFilepath);
+ if (filename != expectedUnixFilename) {
+ std::cerr << "GetFilenameName(" << unixFilepath << ") yielded " << filename
+ << " instead of " << expectedUnixFilename << std::endl;
+ res = false;
+ }
+ return res;
+}
+
static bool CheckFind()
{
bool res = true;
@@ -765,7 +810,7 @@ static bool CheckFind()
const std::string testFindFile(TEST_SYSTEMTOOLS_BINARY_DIR "/" +
testFindFileName);
- if (!kwsys::SystemTools::Touch(testFindFile.c_str(), true)) {
+ if (!kwsys::SystemTools::Touch(testFindFile, true)) {
std::cerr << "Problem with Touch for: " << testFindFile << std::endl;
// abort here as the existence of the file only makes the test meaningful
return false;
@@ -789,6 +834,39 @@ static bool CheckFind()
return res;
}
+static bool CheckIsSubDirectory()
+{
+ bool res = true;
+
+ if (kwsys::SystemTools::IsSubDirectory("/foo", "/") == false) {
+ std::cerr << "Problem with IsSubDirectory (root - unix): " << std::endl;
+ res = false;
+ }
+ if (kwsys::SystemTools::IsSubDirectory("c:/foo", "c:/") == false) {
+ std::cerr << "Problem with IsSubDirectory (root - dos): " << std::endl;
+ res = false;
+ }
+ if (kwsys::SystemTools::IsSubDirectory("/foo/bar", "/foo") == false) {
+ std::cerr << "Problem with IsSubDirectory (deep): " << std::endl;
+ res = false;
+ }
+ if (kwsys::SystemTools::IsSubDirectory("/foo", "/foo") == true) {
+ std::cerr << "Problem with IsSubDirectory (identity): " << std::endl;
+ res = false;
+ }
+ if (kwsys::SystemTools::IsSubDirectory("/fooo", "/foo") == true) {
+ std::cerr << "Problem with IsSubDirectory (substring): " << std::endl;
+ res = false;
+ }
+ if (kwsys::SystemTools::IsSubDirectory("/foo/", "/foo") == true) {
+ std::cerr << "Problem with IsSubDirectory (prepended slash): "
+ << std::endl;
+ res = false;
+ }
+
+ return res;
+}
+
static bool CheckGetLineFromStream()
{
const std::string fileWithFiveCharsOnFirstLine(TEST_SYSTEMTOOLS_SOURCE_DIR
@@ -838,6 +916,167 @@ static bool CheckGetLineFromStream()
return ret;
}
+static bool CheckGetLineFromStreamLongLine()
+{
+ const std::string fileWithLongLine("longlines.txt");
+ std::string firstLine, secondLine;
+ // First line: large buffer, containing a carriage return for some reason.
+ firstLine.assign(2050, ' ');
+ firstLine += "\rfirst";
+ secondLine.assign(2050, 'y');
+ secondLine += "second";
+
+ // Create file with long lines.
+ {
+ kwsys::ofstream out(fileWithLongLine.c_str(), std::ios::binary);
+ if (!out) {
+ std::cerr << "Problem opening for write: " << fileWithLongLine
+ << std::endl;
+ return false;
+ }
+ out << firstLine << "\r\n\n" << secondLine << "\n";
+ }
+
+ kwsys::ifstream file(fileWithLongLine.c_str(), std::ios::binary);
+ if (!file) {
+ std::cerr << "Problem opening: " << fileWithLongLine << std::endl;
+ return false;
+ }
+
+ std::string line;
+ bool has_newline = false;
+ bool result;
+
+ // Read first line.
+ result = kwsys::SystemTools::GetLineFromStream(file, line, &has_newline, -1);
+ if (!result || line != firstLine) {
+ std::cerr << "First line does not match, expected " << firstLine.size()
+ << " characters, got " << line.size() << std::endl;
+ return false;
+ }
+ if (!has_newline) {
+ std::cerr << "Expected new line to be read from first line" << std::endl;
+ return false;
+ }
+
+ // Read empty line.
+ has_newline = false;
+ result = kwsys::SystemTools::GetLineFromStream(file, line, &has_newline, -1);
+ if (!result || !line.empty()) {
+ std::cerr << "Expected successful read with an empty line, got "
+ << line.size() << " characters" << std::endl;
+ return false;
+ }
+ if (!has_newline) {
+ std::cerr << "Expected new line to be read for an empty line" << std::endl;
+ return false;
+ }
+
+ // Read second line.
+ has_newline = false;
+ result = kwsys::SystemTools::GetLineFromStream(file, line, &has_newline, -1);
+ if (!result || line != secondLine) {
+ std::cerr << "Second line does not match, expected " << secondLine.size()
+ << " characters, got " << line.size() << std::endl;
+ return false;
+ }
+ if (!has_newline) {
+ std::cerr << "Expected new line to be read from second line" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+static bool writeFile(const char* fileName, const char* data)
+{
+ kwsys::ofstream out(fileName, std::ios::binary);
+ out << data;
+ if (!out) {
+ std::cerr << "Failed to write file: " << fileName << std::endl;
+ return false;
+ }
+ return true;
+}
+
+static std::string readFile(const char* fileName)
+{
+ kwsys::ifstream in(fileName, std::ios::binary);
+ std::stringstream sstr;
+ sstr << in.rdbuf();
+ std::string data = sstr.str();
+ if (!in) {
+ std::cerr << "Failed to read file: " << fileName << std::endl;
+ return std::string();
+ }
+ return data;
+}
+
+struct
+{
+ const char* a;
+ const char* b;
+ bool differ;
+} diff_test_cases[] = { { "one", "one", false },
+ { "one", "two", true },
+ { "", "", false },
+ { "\n", "\r\n", false },
+ { "one\n", "one\n", false },
+ { "one\r\n", "one\n", false },
+ { "one\n", "one", false },
+ { "one\ntwo", "one\ntwo", false },
+ { "one\ntwo", "one\r\ntwo", false } };
+
+static bool CheckTextFilesDiffer()
+{
+ const int num_test_cases =
+ sizeof(diff_test_cases) / sizeof(diff_test_cases[0]);
+ for (int i = 0; i < num_test_cases; ++i) {
+ if (!writeFile("file_a", diff_test_cases[i].a) ||
+ !writeFile("file_b", diff_test_cases[i].b)) {
+ return false;
+ }
+ if (kwsys::SystemTools::TextFilesDiffer("file_a", "file_b") !=
+ diff_test_cases[i].differ) {
+ std::cerr << "Incorrect TextFilesDiffer result for test case " << i + 1
+ << "." << std::endl;
+ return false;
+ }
+ }
+
+ return true;
+}
+
+static bool CheckCopyFileIfDifferent()
+{
+ bool ret = true;
+ const int num_test_cases =
+ sizeof(diff_test_cases) / sizeof(diff_test_cases[0]);
+ for (int i = 0; i < num_test_cases; ++i) {
+ if (!writeFile("file_a", diff_test_cases[i].a) ||
+ !writeFile("file_b", diff_test_cases[i].b)) {
+ return false;
+ }
+ const char* cptarget =
+ i < 4 ? TEST_SYSTEMTOOLS_BINARY_DIR "/file_b" : "file_b";
+ if (!kwsys::SystemTools::CopyFileIfDifferent("file_a", cptarget)) {
+ std::cerr << "CopyFileIfDifferent() returned false for test case "
+ << i + 1 << "." << std::endl;
+ ret = false;
+ continue;
+ }
+ std::string bdata = readFile("file_b");
+ if (diff_test_cases[i].a != bdata) {
+ std::cerr << "Incorrect CopyFileIfDifferent file contents in test case "
+ << i + 1 << "." << std::endl;
+ ret = false;
+ continue;
+ }
+ }
+
+ return ret;
+}
+
int testSystemTools(int, char* [])
{
bool res = true;
@@ -873,7 +1112,17 @@ int testSystemTools(int, char* [])
res &= CheckFind();
+ res &= CheckIsSubDirectory();
+
res &= CheckGetLineFromStream();
+ res &= CheckGetLineFromStreamLongLine();
+
+ res &= CheckGetFilenameName();
+
+ res &= CheckTextFilesDiffer();
+
+ res &= CheckCopyFileIfDifferent();
+
return res ? 0 : 1;
}
diff --git a/Source/kwsys/testTerminal.c b/Source/kwsys/testTerminal.c
index f6c1eddb7..652830ccd 100644
--- a/Source/kwsys/testTerminal.c
+++ b/Source/kwsys/testTerminal.c
@@ -6,7 +6,7 @@
/* Work-around CMake dependency scanning limitation. This must
duplicate the above list of headers. */
#if 0
-#include "Terminal.h.in"
+# include "Terminal.h.in"
#endif
int testTerminal(int argc, char* argv[])
diff --git a/Templates/MSBuild/FlagTables/v10_CL.json b/Templates/MSBuild/FlagTables/v10_CL.json
new file mode 100644
index 000000000..06158bee7
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v10_CL.json
@@ -0,0 +1,981 @@
+[
+ {
+ "name": "DebugInformationFormat",
+ "switch": "Z7",
+ "comment": "C7 compatible",
+ "value": "OldStyle",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "Zi",
+ "comment": "Program Database",
+ "value": "ProgramDatabase",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "ZI",
+ "comment": "Program Database for Edit And Continue",
+ "value": "EditAndContinue",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "",
+ "comment": "No Common Language RunTime Support",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr",
+ "comment": "Common Language RunTime Support",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:pure",
+ "comment": "Pure MSIL Common Language RunTime Support",
+ "value": "Pure",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:safe",
+ "comment": "Safe MSIL Common Language RunTime Support",
+ "value": "Safe",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:oldSyntax",
+ "comment": "Common Language RunTime Support, Old Syntax",
+ "value": "OldSyntax",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W0",
+ "comment": "Turn Off All Warnings",
+ "value": "TurnOffAllWarnings",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W1",
+ "comment": "Level1",
+ "value": "Level1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W2",
+ "comment": "Level2",
+ "value": "Level2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W3",
+ "comment": "Level3",
+ "value": "Level3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W4",
+ "comment": "Level4",
+ "value": "Level4",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "Wall",
+ "comment": "EnableAllWarnings",
+ "value": "EnableAllWarnings",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "Od",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O1",
+ "comment": "Minimize Size",
+ "value": "MinSpace",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O2",
+ "comment": "Maximize Speed",
+ "value": "MaxSpeed",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "Ox",
+ "comment": "Full Optimization",
+ "value": "Full",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob0",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob1",
+ "comment": "Only __inline",
+ "value": "OnlyExplicitInline",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob2",
+ "comment": "Any Suitable",
+ "value": "AnySuitable",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "Os",
+ "comment": "Favor small code",
+ "value": "Size",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "Ot",
+ "comment": "Favor fast code",
+ "value": "Speed",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "",
+ "comment": "Neither",
+ "value": "Neither",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHa",
+ "comment": "Yes with SEH Exceptions",
+ "value": "Async",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHsc",
+ "comment": "Yes",
+ "value": "Sync",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHs",
+ "comment": "Yes with Extern C functions",
+ "value": "SyncCThrow",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTCs",
+ "comment": "Stack Frames",
+ "value": "StackFrameRuntimeCheck",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTCu",
+ "comment": "Uninitialized variables",
+ "value": "UninitializedLocalUsageCheck",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTC1",
+ "comment": "Both (/RTC1, equiv. to /RTCsu)",
+ "value": "EnableFastChecks",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MT",
+ "comment": "Multi-threaded",
+ "value": "MultiThreaded",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MTd",
+ "comment": "Multi-threaded Debug",
+ "value": "MultiThreadedDebug",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MD",
+ "comment": "Multi-threaded DLL",
+ "value": "MultiThreadedDLL",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MDd",
+ "comment": "Multi-threaded Debug DLL",
+ "value": "MultiThreadedDebugDLL",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp1",
+ "comment": "1 Byte",
+ "value": "1Byte",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp2",
+ "comment": "2 Bytes",
+ "value": "2Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp4",
+ "comment": "4 Byte",
+ "value": "4Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp8",
+ "comment": "8 Bytes",
+ "value": "8Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp16",
+ "comment": "16 Bytes",
+ "value": "16Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:SSE",
+ "comment": "Streaming SIMD Extensions (/arch:SSE)",
+ "value": "StreamingSIMDExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:SSE2",
+ "comment": "Streaming SIMD Extensions 2 (/arch:SSE2)",
+ "value": "StreamingSIMDExtensions2",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:precise",
+ "comment": "Precise",
+ "value": "Precise",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:strict",
+ "comment": "Strict",
+ "value": "Strict",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:fast",
+ "comment": "Fast",
+ "value": "Fast",
+ "flags": []
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Yc",
+ "comment": "Create",
+ "value": "Create",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Yu",
+ "comment": "Use",
+ "value": "Use",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Y-",
+ "comment": "Not Using Precompiled Headers",
+ "value": "NotUsing",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "",
+ "comment": "No Listing",
+ "value": "NoListing",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FA",
+ "comment": "Assembly-Only Listing",
+ "value": "AssemblyCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAc",
+ "comment": "Assembly With Machine Code",
+ "value": "AssemblyAndMachineCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAs",
+ "comment": "Assembly With Source Code",
+ "value": "AssemblyAndSourceCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAcs",
+ "comment": "Assembly, Machine Code and Source",
+ "value": "All",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gd",
+ "comment": "__cdecl",
+ "value": "Cdecl",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gr",
+ "comment": "__fastcall",
+ "value": "FastCall",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gz",
+ "comment": "__stdcall",
+ "value": "StdCall",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "TC",
+ "comment": "Compile as C Code",
+ "value": "CompileAsC",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "TP",
+ "comment": "Compile as C++ Code",
+ "value": "CompileAsCpp",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:none",
+ "comment": "Do Not Send Report",
+ "value": "None",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:prompt",
+ "comment": "Prompt Immediately",
+ "value": "Prompt",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:queue",
+ "comment": "Queue For Next Login",
+ "value": "Queue",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:send",
+ "comment": "Send Automatically",
+ "value": "Send",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "nologo-",
+ "comment": "Suppress Startup Banner",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningAsError",
+ "switch": "WX-",
+ "comment": "Treat Warnings As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningAsError",
+ "switch": "WX",
+ "comment": "Treat Warnings As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MultiProcessorCompilation",
+ "switch": "MP",
+ "comment": "Multi-processor Compilation",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "IntrinsicFunctions",
+ "switch": "Oi",
+ "comment": "Enable Intrinsic Functions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OmitFramePointers",
+ "switch": "Oy-",
+ "comment": "Omit Frame Pointers",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OmitFramePointers",
+ "switch": "Oy",
+ "comment": "Omit Frame Pointers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableFiberSafeOptimizations",
+ "switch": "GT",
+ "comment": "Enable Fiber-Safe Optimizations",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WholeProgramOptimization",
+ "switch": "GL",
+ "comment": "Whole Program Optimization",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UndefineAllPreprocessorDefinitions",
+ "switch": "u",
+ "comment": "Undefine All Preprocessor Definitions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreStandardIncludePath",
+ "switch": "X",
+ "comment": "Ignore Standard Include Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessToFile",
+ "switch": "P",
+ "comment": "Preprocess to a File",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessSuppressLineNumbers",
+ "switch": "EP",
+ "comment": "Preprocess Suppress Line Numbers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessKeepComments",
+ "switch": "C",
+ "comment": "Keep Comments",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "StringPooling",
+ "switch": "GF-",
+ "comment": "Enable String Pooling",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "StringPooling",
+ "switch": "GF",
+ "comment": "Enable String Pooling",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MinimalRebuild",
+ "switch": "Gm-",
+ "comment": "Enable Minimal Rebuild",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "MinimalRebuild",
+ "switch": "Gm",
+ "comment": "Enable Minimal Rebuild",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SmallerTypeCheck",
+ "switch": "RTCc",
+ "comment": "Smaller Type Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "BufferSecurityCheck",
+ "switch": "GS-",
+ "comment": "Buffer Security Check",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "BufferSecurityCheck",
+ "switch": "GS",
+ "comment": "Buffer Security Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FunctionLevelLinking",
+ "switch": "Gy-",
+ "comment": "Enable Function-Level Linking",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FunctionLevelLinking",
+ "switch": "Gy",
+ "comment": "Enable Function-Level Linking",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointExceptions",
+ "switch": "fp:except-",
+ "comment": "Enable Floating Point Exceptions",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointExceptions",
+ "switch": "fp:except",
+ "comment": "Enable Floating Point Exceptions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CreateHotpatchableImage",
+ "switch": "hotpatch",
+ "comment": "Create Hotpatchable Image",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DisableLanguageExtensions",
+ "switch": "Za",
+ "comment": "Disable Language Extensions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWChar_tAsBuiltInType",
+ "switch": "Zc:wchar_t-",
+ "comment": "Treat WChar_t As Built in Type",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWChar_tAsBuiltInType",
+ "switch": "Zc:wchar_t",
+ "comment": "Treat WChar_t As Built in Type",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ForceConformanceInForLoopScope",
+ "switch": "Zc:forScope-",
+ "comment": "Force Conformance in For Loop Scope",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "ForceConformanceInForLoopScope",
+ "switch": "Zc:forScope",
+ "comment": "Force Conformance in For Loop Scope",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RuntimeTypeInfo",
+ "switch": "GR-",
+ "comment": "Enable Run-Time Type Information",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RuntimeTypeInfo",
+ "switch": "GR",
+ "comment": "Enable Run-Time Type Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OpenMPSupport",
+ "switch": "openmp-",
+ "comment": "Open MP Support",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OpenMPSupport",
+ "switch": "openmp",
+ "comment": "Open MP Support",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ExpandAttributedSource",
+ "switch": "Fx",
+ "comment": "Expand Attributed Source",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateXMLDocumentationFiles",
+ "switch": "doc",
+ "comment": "Generate XML Documentation Files",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "BrowseInformation",
+ "switch": "FR",
+ "comment": "Enable Browse Information",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "ShowIncludes",
+ "switch": "showIncludes",
+ "comment": "Show Includes",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnablePREfast",
+ "switch": "analyze-",
+ "comment": "Enable Code Analysis",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnablePREfast",
+ "switch": "analyze",
+ "comment": "Enable Code Analysis",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseFullPaths",
+ "switch": "FC",
+ "comment": "Use Full Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OmitDefaultLibName",
+ "switch": "Zl",
+ "comment": "Omit Default Library Name",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseUnicodeForAssemblerListing",
+ "switch": "FAu",
+ "comment": "Use Unicode For Assembler Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalIncludeDirectories",
+ "switch": "I",
+ "comment": "Additional Include Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalUsingDirectories",
+ "switch": "AI",
+ "comment": "Resolve #using References",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "UndefinePreprocessorDefinitions",
+ "switch": "U",
+ "comment": "Undefine Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "DisableSpecificWarnings",
+ "switch": "wd",
+ "comment": "Disable Specific Warnings",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForcedIncludeFiles",
+ "switch": "FI",
+ "comment": "Forced Include File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForcedUsingFiles",
+ "switch": "FU",
+ "comment": "Forced #using File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "TreatSpecificWarningsAsErrors",
+ "switch": "we",
+ "comment": "Treat Specific Warnings As Errors",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PreprocessOutputPath",
+ "switch": "Fi",
+ "comment": "Preprocess Output Path",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderFile",
+ "switch": "Yu",
+ "comment": "Precompiled Header File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderFile",
+ "switch": "Yc",
+ "comment": "Precompiled Header File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderOutputFile",
+ "switch": "Fp",
+ "comment": "Precompiled Header Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "AssemblerListingLocation",
+ "switch": "Fa",
+ "comment": "ASM List Location",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ObjectFileName",
+ "switch": "Fo",
+ "comment": "Object File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProgramDataBaseFileName",
+ "switch": "Fd",
+ "comment": "Program Database File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "XMLDocumentationFileName",
+ "switch": "doc",
+ "comment": "XML Documentation File Name",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "BrowseInformationFile",
+ "switch": "FR",
+ "comment": "Browse Information File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ProcessorNumber",
+ "switch": "MP",
+ "comment": "Number of processors",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v10_CSharp.json b/Templates/MSBuild/FlagTables/v10_CSharp.json
new file mode 100644
index 000000000..5989aea1e
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v10_CSharp.json
@@ -0,0 +1,574 @@
+[
+ {
+ "name": "ProjectName",
+ "switch": "out:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:exe",
+ "comment": "",
+ "value": "Exe",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:winexe",
+ "comment": "",
+ "value": "Winexe",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:library",
+ "comment": "",
+ "value": "Library",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:module",
+ "comment": "",
+ "value": "Module",
+ "flags": []
+ },
+ {
+ "name": "DocumentationFile",
+ "switch": "doc",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:x86",
+ "comment": "",
+ "value": "x86",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:Itanium",
+ "comment": "",
+ "value": "Itanium",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:x64",
+ "comment": "",
+ "value": "x64",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:arm",
+ "comment": "",
+ "value": "arm",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:anycpu32bitpreferred",
+ "comment": "",
+ "value": "anycpu32bitpreferred",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:anycpu",
+ "comment": "",
+ "value": "anycpu",
+ "flags": []
+ },
+ {
+ "name": "References",
+ "switch": "reference:",
+ "comment": "mit alias",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "References",
+ "switch": "reference:",
+ "comment": "dateiliste",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "AddModules",
+ "switch": "addmodule:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "Win32Resource",
+ "switch": "win32res:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ApplicationIcon",
+ "switch": "win32icon:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ApplicationManifest",
+ "switch": "win32manifest:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "NoWin32Manifest",
+ "switch": "nowin32manifest",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DefineDebug",
+ "switch": "debug",
+ "comment": "",
+ "value": "true",
+ "flags": [
+ "Continue"
+ ]
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:none",
+ "comment": "",
+ "value": "none",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:full",
+ "comment": "",
+ "value": "full",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:pdbonly",
+ "comment": "",
+ "value": "pdbonly",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror-",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror+",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:0",
+ "comment": "",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:1",
+ "comment": "",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:2",
+ "comment": "",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:3",
+ "comment": "",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:4",
+ "comment": "",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "NoWarn",
+ "switch": "nowarn:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired",
+ "CommaAppendable"
+ ]
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DefineConstants",
+ "switch": "define:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "SemicolonAppendable",
+ "UserValue"
+ ]
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:ISO-1",
+ "comment": "",
+ "value": "ISO-1",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:ISO-2",
+ "comment": "",
+ "value": "ISO-2",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:3",
+ "comment": "",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:4",
+ "comment": "",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:5",
+ "comment": "",
+ "value": "5",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:6",
+ "comment": "",
+ "value": "6",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:default",
+ "comment": "",
+ "value": "default",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AssemblyOriginatorKeyFile",
+ "switch": "keyfile",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "KeyContainerName",
+ "switch": "keycontainer",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoLogo",
+ "switch": "nologo",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoConfig",
+ "switch": "noconfig",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "BaseAddress",
+ "switch": "baseaddress:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "CodePage",
+ "switch": "codepage",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "Utf8Output",
+ "switch": "utf8output",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "MainEntryPoint",
+ "switch": "main:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "GenerateFullPaths",
+ "switch": "fullpaths",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FileAlignment",
+ "switch": "filealign",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "PdbFile",
+ "switch": "pdb:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SubsystemVersion",
+ "switch": "subsystemversion",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibPaths",
+ "switch": "lib:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:none",
+ "comment": "Do Not Send Report",
+ "value": "none",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:prompt",
+ "comment": "Prompt Immediately",
+ "value": "prompt",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:queue",
+ "comment": "Queue For Next Login",
+ "value": "queue",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:send",
+ "comment": "Send Automatically",
+ "value": "send",
+ "flags": []
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v10_Cuda.json b/Templates/MSBuild/FlagTables/v10_Cuda.json
new file mode 100644
index 000000000..1831b8aaf
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v10_Cuda.json
@@ -0,0 +1,224 @@
+[
+ {
+ "name": "AdditionalCompilerOptions",
+ "switch": "Xcompiler=",
+ "comment": "Host compiler options",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SpaceAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalCompilerOptions",
+ "switch": "Xcompiler",
+ "comment": "Host compiler options",
+ "value": "",
+ "flags": [
+ "UserFollowing",
+ "SpaceAppendable"
+ ]
+ },
+ {
+ "name": "CudaRuntime",
+ "switch": "cudart=none",
+ "comment": "No CUDA runtime library",
+ "value": "None",
+ "flags": []
+ },
+ {
+ "name": "CudaRuntime",
+ "switch": "cudart=shared",
+ "comment": "Shared/dynamic CUDA runtime library",
+ "value": "Shared",
+ "flags": []
+ },
+ {
+ "name": "CudaRuntime",
+ "switch": "cudart=static",
+ "comment": "Static CUDA runtime library",
+ "value": "Static",
+ "flags": []
+ },
+ {
+ "name": "CudaRuntime",
+ "switch": "cudart",
+ "comment": "CUDA runtime library",
+ "value": "",
+ "flags": [
+ "UserFollowing"
+ ]
+ },
+ {
+ "name": "cmake-temp-gencode",
+ "switch": "gencode=",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "cmake-temp-gencode",
+ "switch": "gencode",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserFollowing",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "cmake-temp-gencode",
+ "switch": "-generate-code=",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "cmake-temp-gencode",
+ "switch": "-generate-code",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserFollowing",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "cmake-temp-code",
+ "switch": "code=",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "cmake-temp-code",
+ "switch": "code",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserFollowing"
+ ]
+ },
+ {
+ "name": "cmake-temp-code",
+ "switch": "-gpu-code=",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "cmake-temp-code",
+ "switch": "-gpu-code",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserFollowing"
+ ]
+ },
+ {
+ "name": "cmake-temp-arch",
+ "switch": "arch=",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "cmake-temp-arch",
+ "switch": "arch",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserFollowing"
+ ]
+ },
+ {
+ "name": "cmake-temp-arch",
+ "switch": "-gpu-architecture=",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "cmake-temp-arch",
+ "switch": "-gpu-architecture",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserFollowing"
+ ]
+ },
+ {
+ "name": "FastMath",
+ "switch": "use_fast_math",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FastMath",
+ "switch": "-use_fast_math",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GPUDebugInfo",
+ "switch": "G",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GPUDebugInfo",
+ "switch": "-device-debug",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "HostDebugInfo",
+ "switch": "g",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "HostDebugInfo",
+ "switch": "-debug",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MaxRegCount",
+ "switch": "maxrregcount=",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MaxRegCount",
+ "switch": "maxrregcount",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserFollowing"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v10_CudaHost.json b/Templates/MSBuild/FlagTables/v10_CudaHost.json
new file mode 100644
index 000000000..2593ff146
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v10_CudaHost.json
@@ -0,0 +1,149 @@
+[
+ {
+ "name": "Optimization",
+ "switch": "Od",
+ "comment": "Disabled",
+ "value": "Od",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O1",
+ "comment": "Minimize Size",
+ "value": "O1",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O2",
+ "comment": "Maximize Speed",
+ "value": "O2",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "Ox",
+ "comment": "Full Optimization",
+ "value": "O3",
+ "flags": []
+ },
+ {
+ "name": "Runtime",
+ "switch": "MT",
+ "comment": "Multi-Threaded",
+ "value": "MT",
+ "flags": []
+ },
+ {
+ "name": "Runtime",
+ "switch": "MTd",
+ "comment": "Multi-Threaded Debug",
+ "value": "MTd",
+ "flags": []
+ },
+ {
+ "name": "Runtime",
+ "switch": "MD",
+ "comment": "Multi-Threaded DLL",
+ "value": "MD",
+ "flags": []
+ },
+ {
+ "name": "Runtime",
+ "switch": "MDd",
+ "comment": "Multi-threaded Debug DLL",
+ "value": "MDd",
+ "flags": []
+ },
+ {
+ "name": "Runtime",
+ "switch": "ML",
+ "comment": "Single-Threaded",
+ "value": "ML",
+ "flags": []
+ },
+ {
+ "name": "Runtime",
+ "switch": "MLd",
+ "comment": "Single-Threaded Debug",
+ "value": "MLd",
+ "flags": []
+ },
+ {
+ "name": "RuntimeChecks",
+ "switch": "RTCs",
+ "comment": "Stack Frames",
+ "value": "RTCs",
+ "flags": []
+ },
+ {
+ "name": "RuntimeChecks",
+ "switch": "RTCu",
+ "comment": "Uninitialized Variables",
+ "value": "RTCu",
+ "flags": []
+ },
+ {
+ "name": "RuntimeChecks",
+ "switch": "RTC1",
+ "comment": "Both",
+ "value": "RTC1",
+ "flags": []
+ },
+ {
+ "name": "TypeInfo",
+ "switch": "GR",
+ "comment": "Yes",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TypeInfo",
+ "switch": "GR-",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "Warning",
+ "switch": "W0",
+ "comment": "Off: Turn Off All Warnings",
+ "value": "W0",
+ "flags": []
+ },
+ {
+ "name": "Warning",
+ "switch": "W1",
+ "comment": "Level 1",
+ "value": "W1",
+ "flags": []
+ },
+ {
+ "name": "Warning",
+ "switch": "W2",
+ "comment": "Level 2",
+ "value": "W2",
+ "flags": []
+ },
+ {
+ "name": "Warning",
+ "switch": "W3",
+ "comment": "Level 3",
+ "value": "W3",
+ "flags": []
+ },
+ {
+ "name": "Warning",
+ "switch": "W4",
+ "comment": "Level 4",
+ "value": "W4",
+ "flags": []
+ },
+ {
+ "name": "Warning",
+ "switch": "Wall",
+ "comment": "Enable All Warnings",
+ "value": "Wall",
+ "flags": []
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v10_LIB.json b/Templates/MSBuild/FlagTables/v10_LIB.json
new file mode 100644
index 000000000..58a238c97
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v10_LIB.json
@@ -0,0 +1,297 @@
+[
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:PROMPT",
+ "comment": "PromptImmediately",
+ "value": "PromptImmediately",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:QUEUE",
+ "comment": "Queue For Next Login",
+ "value": "QueueForNextLogin",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:SEND",
+ "comment": "Send Error Report",
+ "value": "SendErrorReport",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:NONE",
+ "comment": "No Error Report",
+ "value": "NoErrorReport",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:ARM",
+ "comment": "MachineARM",
+ "value": "MachineARM",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:EBC",
+ "comment": "MachineEBC",
+ "value": "MachineEBC",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:IA64",
+ "comment": "MachineIA64",
+ "value": "MachineIA64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS",
+ "comment": "MachineMIPS",
+ "value": "MachineMIPS",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS16",
+ "comment": "MachineMIPS16",
+ "value": "MachineMIPS16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU",
+ "comment": "MachineMIPSFPU",
+ "value": "MachineMIPSFPU",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU16",
+ "comment": "MachineMIPSFPU16",
+ "value": "MachineMIPSFPU16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:SH4",
+ "comment": "MachineSH4",
+ "value": "MachineSH4",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:THUMB",
+ "comment": "MachineTHUMB",
+ "value": "MachineTHUMB",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X64",
+ "comment": "MachineX64",
+ "value": "MachineX64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X86",
+ "comment": "MachineX86",
+ "value": "MachineX86",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:CONSOLE",
+ "comment": "Console",
+ "value": "Console",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWS",
+ "comment": "Windows",
+ "value": "Windows",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:NATIVE",
+ "comment": "Native",
+ "value": "Native",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_APPLICATION",
+ "comment": "EFI Application",
+ "value": "EFI Application",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+ "comment": "EFI Boot Service Driver",
+ "value": "EFI Boot Service Driver",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_ROM",
+ "comment": "EFI ROM",
+ "value": "EFI ROM",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_RUNTIME_DRIVER",
+ "comment": "EFI Runtime",
+ "value": "EFI Runtime",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWSCE",
+ "comment": "WindowsCE",
+ "value": "WindowsCE",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:POSIX",
+ "comment": "POSIX",
+ "value": "POSIX",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "NOLOGO",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreAllDefaultLibraries",
+ "switch": "NODEFAULTLIB",
+ "comment": "Ignore All Default Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatLibWarningAsErrors",
+ "switch": "WX:NO",
+ "comment": "Treat Lib Warning As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatLibWarningAsErrors",
+ "switch": "WX",
+ "comment": "Treat Lib Warning As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Verbose",
+ "switch": "VERBOSE",
+ "comment": "Verbose",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG",
+ "comment": "Link Time Code Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibraryDirectories",
+ "switch": "LIBPATH:",
+ "comment": "Additional Library Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IgnoreSpecificDefaultLibraries",
+ "switch": "NODEFAULTLIB:",
+ "comment": "Ignore Specific Default Libraries",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ExportNamedFunctions",
+ "switch": "EXPORT:",
+ "comment": "Export Named Functions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "RemoveObjects",
+ "switch": "REMOVE:",
+ "comment": "Remove Objects",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "OutputFile",
+ "switch": "OUT:",
+ "comment": "Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ModuleDefinitionFile",
+ "switch": "DEF:",
+ "comment": "Module Definition File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ForceSymbolReferences",
+ "switch": "INCLUDE:",
+ "comment": "Force Symbol References",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "DisplayLibrary",
+ "switch": "LIST:",
+ "comment": "Display Library to standard output",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "Name",
+ "switch": "NAME:",
+ "comment": "Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v10_Link.json b/Templates/MSBuild/FlagTables/v10_Link.json
new file mode 100644
index 000000000..ac5b8b16c
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v10_Link.json
@@ -0,0 +1,1137 @@
+[
+ {
+ "name": "ShowProgress",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE",
+ "comment": "Display all progress messages",
+ "value": "LinkVerbose",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:Lib",
+ "comment": "For Libraries Searched",
+ "value": "LinkVerboseLib",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:ICF",
+ "comment": "About COMDAT folding during optimized linking",
+ "value": "LinkVerboseICF",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:REF",
+ "comment": "About data removed during optimized linking",
+ "value": "LinkVerboseREF",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:SAFESEH",
+ "comment": "About Modules incompatible with SEH",
+ "value": "LinkVerboseSAFESEH",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:CLR",
+ "comment": "About linker activity related to managed code",
+ "value": "LinkVerboseCLR",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE:MULTIPLE",
+ "comment": "Multiply Defined Symbol Only",
+ "value": "MultiplyDefinedSymbolOnly",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE:UNRESOLVED",
+ "comment": "Undefined Symbol Only",
+ "value": "UndefinedSymbolOnly",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:5",
+ "comment": "X86 Image Only",
+ "value": "X86Image",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:6",
+ "comment": "X64 Image Only",
+ "value": "X64Image",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:16",
+ "comment": "Itanium Image Only",
+ "value": "ItaniumImage",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='asInvoker'",
+ "comment": "asInvoker",
+ "value": "AsInvoker",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='highestAvailable'",
+ "comment": "highestAvailable",
+ "value": "HighestAvailable",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='requireAdministrator'",
+ "comment": "requireAdministrator",
+ "value": "RequireAdministrator",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:CONSOLE",
+ "comment": "Console",
+ "value": "Console",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWS",
+ "comment": "Windows",
+ "value": "Windows",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:NATIVE",
+ "comment": "Native",
+ "value": "Native",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_APPLICATION",
+ "comment": "EFI Application",
+ "value": "EFI Application",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+ "comment": "EFI Boot Service Driver",
+ "value": "EFI Boot Service Driver",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_ROM",
+ "comment": "EFI ROM",
+ "value": "EFI ROM",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_RUNTIME_DRIVER",
+ "comment": "EFI Runtime",
+ "value": "EFI Runtime",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWSCE",
+ "comment": "WindowsCE",
+ "value": "WindowsCE",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:POSIX",
+ "comment": "POSIX",
+ "value": "POSIX",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "Driver",
+ "comment": "Driver",
+ "value": "Driver",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "DRIVER:UPONLY",
+ "comment": "UP Only",
+ "value": "UpOnly",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "DRIVER:WDM",
+ "comment": "WDM",
+ "value": "WDM",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG",
+ "comment": "Use Link Time Code Generation",
+ "value": "UseLinkTimeCodeGeneration",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGInstrument",
+ "comment": "Profile Guided Optimization - Instrument",
+ "value": "PGInstrument",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGOptimize",
+ "comment": "Profile Guided Optimization - Optimization",
+ "value": "PGOptimization",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGUpdate",
+ "comment": "Profile Guided Optimization - Update",
+ "value": "PGUpdate",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:ARM",
+ "comment": "MachineARM",
+ "value": "MachineARM",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:EBC",
+ "comment": "MachineEBC",
+ "value": "MachineEBC",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:IA64",
+ "comment": "MachineIA64",
+ "value": "MachineIA64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS",
+ "comment": "MachineMIPS",
+ "value": "MachineMIPS",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS16",
+ "comment": "MachineMIPS16",
+ "value": "MachineMIPS16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU",
+ "comment": "MachineMIPSFPU",
+ "value": "MachineMIPSFPU",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU16",
+ "comment": "MachineMIPSFPU16",
+ "value": "MachineMIPSFPU16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:SH4",
+ "comment": "MachineSH4",
+ "value": "MachineSH4",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:THUMB",
+ "comment": "MachineTHUMB",
+ "value": "MachineTHUMB",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X64",
+ "comment": "MachineX64",
+ "value": "MachineX64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X86",
+ "comment": "MachineX86",
+ "value": "MachineX86",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:MTA",
+ "comment": "MTA threading attribute",
+ "value": "MTAThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:STA",
+ "comment": "STA threading attribute",
+ "value": "STAThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:NONE",
+ "comment": "Default threading attribute",
+ "value": "DefaultThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:IJW",
+ "comment": "Force IJW image",
+ "value": "ForceIJWImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:PURE",
+ "comment": "Force Pure IL Image",
+ "value": "ForcePureILImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:SAFE",
+ "comment": "Force Safe IL Image",
+ "value": "ForceSafeILImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "",
+ "comment": "Default image type",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:PROMPT",
+ "comment": "PromptImmediately",
+ "value": "PromptImmediately",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:QUEUE",
+ "comment": "Queue For Next Login",
+ "value": "QueueForNextLogin",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:SEND",
+ "comment": "Send Error Report",
+ "value": "SendErrorReport",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:NONE",
+ "comment": "No Error Report",
+ "value": "NoErrorReport",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError:NO",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError:SYSTEMDLL",
+ "comment": "System Dlls Only",
+ "value": "SystemDlls",
+ "flags": []
+ },
+ {
+ "name": "LinkIncremental",
+ "switch": "INCREMENTAL:NO",
+ "comment": "Enable Incremental Linking",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkIncremental",
+ "switch": "INCREMENTAL",
+ "comment": "Enable Incremental Linking",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "NOLOGO",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkStatus",
+ "switch": "LTCG:NOSTATUS",
+ "comment": "Link Status",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkStatus",
+ "switch": "LTCG:STATUS",
+ "comment": "Link Status",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreventDllBinding",
+ "switch": "ALLOWBIND:NO",
+ "comment": "Prevent Dll Binding",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "PreventDllBinding",
+ "switch": "ALLOWBIND",
+ "comment": "Prevent Dll Binding",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatLinkerWarningAsErrors",
+ "switch": "WX:NO",
+ "comment": "Treat Linker Warning As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatLinkerWarningAsErrors",
+ "switch": "WX",
+ "comment": "Treat Linker Warning As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreAllDefaultLibraries",
+ "switch": "NODEFAULTLIB",
+ "comment": "Ignore All Default Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateManifest",
+ "switch": "MANIFEST:NO",
+ "comment": "Generate Manifest",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "GenerateManifest",
+ "switch": "MANIFEST",
+ "comment": "Generate Manifest",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowIsolation",
+ "switch": "ALLOWISOLATION:NO",
+ "comment": "Allow Isolation",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AllowIsolation",
+ "switch": "ALLOWISOLATION",
+ "comment": "Allow Isolation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableUAC",
+ "switch": "MANIFESTUAC:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired",
+ "SpaceAppendable"
+ ]
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='false'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "false",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='false'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='true'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG",
+ "comment": "Generate Debug Info",
+ "value": "true",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "GenerateMapFile",
+ "switch": "MAP",
+ "comment": "Generate Map File",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "MapExports",
+ "switch": "MAPINFO:EXPORTS",
+ "comment": "Map Exports",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AssemblyDebug",
+ "switch": "ASSEMBLYDEBUG:DISABLE",
+ "comment": "Debuggable Assembly",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AssemblyDebug",
+ "switch": "ASSEMBLYDEBUG",
+ "comment": "Debuggable Assembly",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LargeAddressAware",
+ "switch": "LARGEADDRESSAWARE:NO",
+ "comment": "Enable Large Addresses",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LargeAddressAware",
+ "switch": "LARGEADDRESSAWARE",
+ "comment": "Enable Large Addresses",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TerminalServerAware",
+ "switch": "TSAWARE:NO",
+ "comment": "Terminal Server",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TerminalServerAware",
+ "switch": "TSAWARE",
+ "comment": "Terminal Server",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SwapRunFromCD",
+ "switch": "SWAPRUN:CD",
+ "comment": "Swap Run From CD",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SwapRunFromNET",
+ "switch": "SWAPRUN:NET",
+ "comment": "Swap Run From Network",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OptimizeReferences",
+ "switch": "OPT:NOREF",
+ "comment": "References",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OptimizeReferences",
+ "switch": "OPT:REF",
+ "comment": "References",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableCOMDATFolding",
+ "switch": "OPT:NOICF",
+ "comment": "Enable COMDAT Folding",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableCOMDATFolding",
+ "switch": "OPT:ICF",
+ "comment": "Enable COMDAT Folding",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreEmbeddedIDL",
+ "switch": "IGNOREIDL",
+ "comment": "Ignore Embedded IDL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NoEntryPoint",
+ "switch": "NOENTRY",
+ "comment": "No Entry Point",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SetChecksum",
+ "switch": "RELEASE",
+ "comment": "Set Checksum",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RandomizedBaseAddress",
+ "switch": "DYNAMICBASE:NO",
+ "comment": "Randomized Base Address",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RandomizedBaseAddress",
+ "switch": "DYNAMICBASE",
+ "comment": "Randomized Base Address",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FixedBaseAddress",
+ "switch": "FIXED:NO",
+ "comment": "Fixed Base Address",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FixedBaseAddress",
+ "switch": "FIXED",
+ "comment": "Fixed Base Address",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DataExecutionPrevention",
+ "switch": "NXCOMPAT:NO",
+ "comment": "Data Execution Prevention (DEP)",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DataExecutionPrevention",
+ "switch": "NXCOMPAT",
+ "comment": "Data Execution Prevention (DEP)",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TurnOffAssemblyGeneration",
+ "switch": "NOASSEMBLY",
+ "comment": "Turn Off Assembly Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SupportUnloadOfDelayLoadedDLL",
+ "switch": "DELAY:UNLOAD",
+ "comment": "Unload delay loaded DLL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SupportNobindOfDelayLoadedDLL",
+ "switch": "DELAY:NOBIND",
+ "comment": "Nobind delay loaded DLL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Profile",
+ "switch": "PROFILE",
+ "comment": "Profile",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkDelaySign",
+ "switch": "DELAYSIGN:NO",
+ "comment": "Delay Sign",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkDelaySign",
+ "switch": "DELAYSIGN",
+ "comment": "Delay Sign",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CLRUnmanagedCodeCheck",
+ "switch": "CLRUNMANAGEDCODECHECK:NO",
+ "comment": "CLR Unmanaged Code Check",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CLRUnmanagedCodeCheck",
+ "switch": "CLRUNMANAGEDCODECHECK",
+ "comment": "CLR Unmanaged Code Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ImageHasSafeExceptionHandlers",
+ "switch": "SAFESEH:NO",
+ "comment": "Image Has Safe Exception Handlers",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "ImageHasSafeExceptionHandlers",
+ "switch": "SAFESEH",
+ "comment": "Image Has Safe Exception Handlers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkDLL",
+ "switch": "DLL",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibraryDirectories",
+ "switch": "LIBPATH:",
+ "comment": "Additional Library Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IgnoreSpecificDefaultLibraries",
+ "switch": "NODEFAULTLIB:",
+ "comment": "Ignore Specific Default Libraries",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AddModuleNamesToAssembly",
+ "switch": "ASSEMBLYMODULE:",
+ "comment": "Add Module to Assembly",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "EmbedManagedResourceFile",
+ "switch": "ASSEMBLYRESOURCE:",
+ "comment": "Embed Managed Resource File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForceSymbolReferences",
+ "switch": "INCLUDE:",
+ "comment": "Force Symbol References",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "DelayLoadDLLs",
+ "switch": "DELAYLOAD:",
+ "comment": "Delay Loaded Dlls",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AssemblyLinkResource",
+ "switch": "ASSEMBLYLINKRESOURCE:",
+ "comment": "Assembly Link Resource",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalManifestDependencies",
+ "switch": "MANIFESTDEPENDENCY:",
+ "comment": "Additional Manifest Dependencies",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "OutputFile",
+ "switch": "OUT:",
+ "comment": "Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "Version",
+ "switch": "VERSION:",
+ "comment": "Version",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "SpecifySectionAttributes",
+ "switch": "SECTION:",
+ "comment": "Specify Section Attributes",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MSDOSStubFileName",
+ "switch": "STUB:",
+ "comment": "MS-DOS Stub File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ModuleDefinitionFile",
+ "switch": "DEF:",
+ "comment": "Module Definition File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ManifestFile",
+ "switch": "ManifestFile:",
+ "comment": "Manifest File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProgramDatabaseFile",
+ "switch": "PDB:",
+ "comment": "Generate Program Database File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "StripPrivateSymbols",
+ "switch": "PDBSTRIPPED:",
+ "comment": "Strip Private Symbols",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MapFileName",
+ "switch": "MAP:",
+ "comment": "Map File Name",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "HeapReserveSize",
+ "switch": "HEAP:",
+ "comment": "Heap Reserve Size",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "HeapCommitSize",
+ "switch": "HEAP",
+ "comment": "Heap Commit Size",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "StackReserveSize",
+ "switch": "STACK:",
+ "comment": "Stack Reserve Size",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "StackCommitSize",
+ "switch": "STACK",
+ "comment": "Stack Commit Size",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "FunctionOrder",
+ "switch": "ORDER:@",
+ "comment": "Function Order",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProfileGuidedDatabase",
+ "switch": "PGD:",
+ "comment": "Profile Guided Database",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MidlCommandFile",
+ "switch": "MIDL:@",
+ "comment": "MIDL Commands",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MergedIDLBaseFileName",
+ "switch": "IDLOUT:",
+ "comment": "Merged IDL Base File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "TypeLibraryFile",
+ "switch": "TLBOUT:",
+ "comment": "Type Library",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "EntryPointSymbol",
+ "switch": "ENTRY:",
+ "comment": "Entry Point",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "BaseAddress",
+ "switch": "BASE:",
+ "comment": "Base Address",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ImportLibrary",
+ "switch": "IMPLIB:",
+ "comment": "Import Library",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MergeSections",
+ "switch": "MERGE:",
+ "comment": "Merge Sections",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "LinkKeyFile",
+ "switch": "KEYFILE:",
+ "comment": "Key File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "KeyContainer",
+ "switch": "KEYCONTAINER:",
+ "comment": "Key Container",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "TypeLibraryResourceID",
+ "switch": "TLBID:",
+ "comment": "TypeLib Resource ID",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "SectionAlignment",
+ "switch": "ALIGN:",
+ "comment": "SectionAlignment",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v10_MASM.json b/Templates/MSBuild/FlagTables/v10_MASM.json
new file mode 100644
index 000000000..4634306b1
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v10_MASM.json
@@ -0,0 +1,295 @@
+[
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "",
+ "comment": "Default",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "Cp",
+ "comment": "Preserves Identifier Case (/Cp)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "Cu",
+ "comment": "Maps all identifiers to upper case. (/Cu)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "Cx",
+ "comment": "Preserves case in public and extern symbols. (/Cx)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W0",
+ "comment": "Warning Level 0 (/W0)",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W1",
+ "comment": "Warning Level 1 (/W1)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W2",
+ "comment": "Warning Level 2 (/W2)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W3",
+ "comment": "Warning Level 3 (/W3)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "",
+ "comment": "Default",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp1",
+ "comment": "One Byte Boundary (/Zp1)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp2",
+ "comment": "Two Byte Boundary (/Zp2)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp4",
+ "comment": "Four Byte Boundary (/Zp4)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp8",
+ "comment": "Eight Byte Boundary (/Zp8)",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp16",
+ "comment": "Sixteen Byte Boundary (/Zp16)",
+ "value": "5",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "",
+ "comment": "Default",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gd",
+ "comment": "Use C-style Calling Convention (/Gd)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gz",
+ "comment": "Use stdcall Calling Convention (/Gz)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gc",
+ "comment": "Use Pascal Calling Convention (/Gc)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:prompt",
+ "comment": "Prompt to send report immediately (/errorReport:prompt)",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:queue",
+ "comment": "Prompt to send report at the next logon (/errorReport:queue)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:send",
+ "comment": "Automatically send report (/errorReport:send)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:none",
+ "comment": "Do not send report (/errorReport:none)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "NoLogo",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GeneratePreprocessedSourceListing",
+ "switch": "EP",
+ "comment": "Generate Preprocessed Source Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ListAllAvailableInformation",
+ "switch": "Sa",
+ "comment": "List All Available Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseSafeExceptionHandlers",
+ "switch": "safeseh",
+ "comment": "Use Safe Exception Handlers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AddFirstPassListing",
+ "switch": "Sf",
+ "comment": "Add First Pass Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableAssemblyGeneratedCodeListing",
+ "switch": "Sg",
+ "comment": "Enable Assembly Generated Code Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DisableSymbolTable",
+ "switch": "Sn",
+ "comment": "Disable Symbol Table",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableFalseConditionalsInListing",
+ "switch": "Sx",
+ "comment": "Enable False Conditionals In Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "WX",
+ "comment": "Treat Warnings As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MakeAllSymbolsPublic",
+ "switch": "Zf",
+ "comment": "Make All Symbols Public",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "Zi",
+ "comment": "Generate Debug Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableMASM51Compatibility",
+ "switch": "Zm",
+ "comment": "Enable MASM 5.1 Compatibility",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PerformSyntaxCheckOnly",
+ "switch": "Zs",
+ "comment": "Perform Syntax Check Only",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IncludePaths",
+ "switch": "I",
+ "comment": "Include Paths",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "BrowseFile",
+ "switch": "FR",
+ "comment": "Generate Browse Information File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ObjectFileName",
+ "switch": "Fo",
+ "comment": "Object File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "AssembledCodeListingFile",
+ "switch": "Fl",
+ "comment": "Assembled Code Listing File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v10_NASM.json b/Templates/MSBuild/FlagTables/v10_NASM.json
new file mode 100644
index 000000000..434cd634e
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v10_NASM.json
@@ -0,0 +1,201 @@
+[
+ {
+ "name": "Outputswitch",
+ "switch": "fwin",
+ "comment": "Object File win32",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "Outputswitch",
+ "switch": "fwin32",
+ "comment": "Object File win32",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "Outputswitch",
+ "switch": "fwin64",
+ "comment": "Object File win64",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "Outputswitch",
+ "switch": "felf",
+ "comment": "ELF32 (i386) object files (e.g. Linux)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "Outputswitch",
+ "switch": "felf32",
+ "comment": "ELF32 (i386) object files (e.g. Linux)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "Outputswitch",
+ "switch": "felf64",
+ "comment": "ELF64 (x86_64) object files (e.g. Linux)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "ErrorReportingFormat",
+ "switch": "Xgnu",
+ "comment": "-Xgnu GNU format: Default format",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "ErrorReportingFormat",
+ "switch": "Xvc",
+ "comment": "-Xvc Style used by Microsoft Visual C++",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "tasmmode",
+ "switch": "t",
+ "comment": "SciTech TASM compatible mode",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "g",
+ "comment": "Generate Debug Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "Werror",
+ "comment": "Treat Warnings As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "floatunderflow",
+ "switch": "w+float-underflow",
+ "comment": "float-underflow",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "macrodefaults",
+ "switch": "w-macro-defaults",
+ "comment": "Disable macro-defaults",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "user",
+ "switch": "w-user",
+ "comment": "Disable user",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "floatoverflow",
+ "switch": "w-float-overflow",
+ "comment": "Disable float-overflow",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "floatdenorm",
+ "switch": "w+float-denorm",
+ "comment": "float-denorm",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "numberoverflow",
+ "switch": "w-number-overflow",
+ "comment": "Disable number-overflow",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "macroselfref",
+ "switch": "w+macro-selfref",
+ "comment": "macro-selfref",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "floattoolong",
+ "switch": "w-float-toolong",
+ "comment": "Disable float-toolong",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "orphanlabels",
+ "switch": "w-orphan-labels",
+ "comment": "Disable orphan-labels",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AssembledCodeListingFile",
+ "switch": "l",
+ "comment": "Assembled Code Listing File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "Z",
+ "comment": "Redirect Error Messages to File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IncludePaths",
+ "switch": "I",
+ "comment": "Include Paths",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "UndefinePreprocessorDefinitions",
+ "switch": "U",
+ "comment": "Undefine Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "OutputFormat",
+ "switch": "o",
+ "comment": "Output File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v10_RC.json b/Templates/MSBuild/FlagTables/v10_RC.json
new file mode 100644
index 000000000..b8c0127d1
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v10_RC.json
@@ -0,0 +1,69 @@
+[
+ {
+ "name": "IgnoreStandardIncludePath",
+ "switch": "X",
+ "comment": "Ignore Standard Include Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "v",
+ "comment": "Show Progress",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NullTerminateStrings",
+ "switch": "n",
+ "comment": "Null Terminate Strings",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "UndefinePreprocessorDefinitions",
+ "switch": "u",
+ "comment": "Undefine Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalIncludeDirectories",
+ "switch": "I",
+ "comment": "Additional Include Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ResourceOutputFileName",
+ "switch": "fo",
+ "comment": "Resource File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v11_CL.json b/Templates/MSBuild/FlagTables/v11_CL.json
new file mode 100644
index 000000000..b47ab2e98
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v11_CL.json
@@ -0,0 +1,1063 @@
+[
+ {
+ "name": "DebugInformationFormat",
+ "switch": "",
+ "comment": "None",
+ "value": "None",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "Z7",
+ "comment": "C7 compatible",
+ "value": "OldStyle",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "Zi",
+ "comment": "Program Database",
+ "value": "ProgramDatabase",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "ZI",
+ "comment": "Program Database for Edit And Continue",
+ "value": "EditAndContinue",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "",
+ "comment": "No Common Language RunTime Support",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr",
+ "comment": "Common Language RunTime Support",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:pure",
+ "comment": "Pure MSIL Common Language RunTime Support",
+ "value": "Pure",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:safe",
+ "comment": "Safe MSIL Common Language RunTime Support",
+ "value": "Safe",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:oldSyntax",
+ "comment": "Common Language RunTime Support, Old Syntax",
+ "value": "OldSyntax",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W0",
+ "comment": "Turn Off All Warnings",
+ "value": "TurnOffAllWarnings",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W1",
+ "comment": "Level1",
+ "value": "Level1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W2",
+ "comment": "Level2",
+ "value": "Level2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W3",
+ "comment": "Level3",
+ "value": "Level3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W4",
+ "comment": "Level4",
+ "value": "Level4",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "Wall",
+ "comment": "EnableAllWarnings",
+ "value": "EnableAllWarnings",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "Od",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O1",
+ "comment": "Minimize Size",
+ "value": "MinSpace",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O2",
+ "comment": "Maximize Speed",
+ "value": "MaxSpeed",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "Ox",
+ "comment": "Full Optimization",
+ "value": "Full",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob0",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob1",
+ "comment": "Only __inline",
+ "value": "OnlyExplicitInline",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob2",
+ "comment": "Any Suitable",
+ "value": "AnySuitable",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "Os",
+ "comment": "Favor small code",
+ "value": "Size",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "Ot",
+ "comment": "Favor fast code",
+ "value": "Speed",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "",
+ "comment": "Neither",
+ "value": "Neither",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHa",
+ "comment": "Yes with SEH Exceptions",
+ "value": "Async",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHsc",
+ "comment": "Yes",
+ "value": "Sync",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHs",
+ "comment": "Yes with Extern C functions",
+ "value": "SyncCThrow",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTCs",
+ "comment": "Stack Frames",
+ "value": "StackFrameRuntimeCheck",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTCu",
+ "comment": "Uninitialized variables",
+ "value": "UninitializedLocalUsageCheck",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTC1",
+ "comment": "Both (/RTC1, equiv. to /RTCsu)",
+ "value": "EnableFastChecks",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MT",
+ "comment": "Multi-threaded",
+ "value": "MultiThreaded",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MTd",
+ "comment": "Multi-threaded Debug",
+ "value": "MultiThreadedDebug",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MD",
+ "comment": "Multi-threaded DLL",
+ "value": "MultiThreadedDLL",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MDd",
+ "comment": "Multi-threaded Debug DLL",
+ "value": "MultiThreadedDebugDLL",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp1",
+ "comment": "1 Byte",
+ "value": "1Byte",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp2",
+ "comment": "2 Bytes",
+ "value": "2Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp4",
+ "comment": "4 Byte",
+ "value": "4Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp8",
+ "comment": "8 Bytes",
+ "value": "8Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp16",
+ "comment": "16 Bytes",
+ "value": "16Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:SSE",
+ "comment": "Streaming SIMD Extensions",
+ "value": "StreamingSIMDExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:SSE2",
+ "comment": "Streaming SIMD Extensions 2",
+ "value": "StreamingSIMDExtensions2",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:AVX",
+ "comment": "Advanced Vector Extensions",
+ "value": "AdvancedVectorExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:IA32",
+ "comment": "No Enhanced Instructions",
+ "value": "NoExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:precise",
+ "comment": "Precise",
+ "value": "Precise",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:strict",
+ "comment": "Strict",
+ "value": "Strict",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:fast",
+ "comment": "Fast",
+ "value": "Fast",
+ "flags": []
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Yc",
+ "comment": "Create",
+ "value": "Create",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Yu",
+ "comment": "Use",
+ "value": "Use",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Y-",
+ "comment": "Not Using Precompiled Headers",
+ "value": "NotUsing",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "",
+ "comment": "No Listing",
+ "value": "NoListing",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FA",
+ "comment": "Assembly-Only Listing",
+ "value": "AssemblyCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAc",
+ "comment": "Assembly With Machine Code",
+ "value": "AssemblyAndMachineCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAs",
+ "comment": "Assembly With Source Code",
+ "value": "AssemblyAndSourceCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAcs",
+ "comment": "Assembly, Machine Code and Source",
+ "value": "All",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gd",
+ "comment": "__cdecl",
+ "value": "Cdecl",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gr",
+ "comment": "__fastcall",
+ "value": "FastCall",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gz",
+ "comment": "__stdcall",
+ "value": "StdCall",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "TC",
+ "comment": "Compile as C Code",
+ "value": "CompileAsC",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "TP",
+ "comment": "Compile as C++ Code",
+ "value": "CompileAsCpp",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:none",
+ "comment": "Do Not Send Report",
+ "value": "None",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:prompt",
+ "comment": "Prompt Immediately",
+ "value": "Prompt",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:queue",
+ "comment": "Queue For Next Login",
+ "value": "Queue",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:send",
+ "comment": "Send Automatically",
+ "value": "Send",
+ "flags": []
+ },
+ {
+ "name": "CompileAsWinRT",
+ "switch": "ZW",
+ "comment": "Consume Windows Runtime Extension",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WinRTNoStdLib",
+ "switch": "ZW:nostdlib",
+ "comment": "No Standard WinRT Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "nologo-",
+ "comment": "Suppress Startup Banner",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningAsError",
+ "switch": "WX-",
+ "comment": "Treat Warnings As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningAsError",
+ "switch": "WX",
+ "comment": "Treat Warnings As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SDLCheck",
+ "switch": "sdl-",
+ "comment": "SDL checks",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "SDLCheck",
+ "switch": "sdl",
+ "comment": "SDL checks",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MultiProcessorCompilation",
+ "switch": "MP",
+ "comment": "Multi-processor Compilation",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "IntrinsicFunctions",
+ "switch": "Oi",
+ "comment": "Enable Intrinsic Functions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OmitFramePointers",
+ "switch": "Oy-",
+ "comment": "Omit Frame Pointers",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OmitFramePointers",
+ "switch": "Oy",
+ "comment": "Omit Frame Pointers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableFiberSafeOptimizations",
+ "switch": "GT",
+ "comment": "Enable Fiber-Safe Optimizations",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WholeProgramOptimization",
+ "switch": "GL",
+ "comment": "Whole Program Optimization",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UndefineAllPreprocessorDefinitions",
+ "switch": "u",
+ "comment": "Undefine All Preprocessor Definitions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreStandardIncludePath",
+ "switch": "X",
+ "comment": "Ignore Standard Include Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessToFile",
+ "switch": "P",
+ "comment": "Preprocess to a File",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessSuppressLineNumbers",
+ "switch": "EP",
+ "comment": "Preprocess Suppress Line Numbers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessKeepComments",
+ "switch": "C",
+ "comment": "Keep Comments",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "StringPooling",
+ "switch": "GF-",
+ "comment": "Enable String Pooling",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "StringPooling",
+ "switch": "GF",
+ "comment": "Enable String Pooling",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MinimalRebuild",
+ "switch": "Gm-",
+ "comment": "Enable Minimal Rebuild",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "MinimalRebuild",
+ "switch": "Gm",
+ "comment": "Enable Minimal Rebuild",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SmallerTypeCheck",
+ "switch": "RTCc",
+ "comment": "Smaller Type Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "BufferSecurityCheck",
+ "switch": "GS-",
+ "comment": "Security Check",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "BufferSecurityCheck",
+ "switch": "GS",
+ "comment": "Security Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FunctionLevelLinking",
+ "switch": "Gy-",
+ "comment": "Enable Function-Level Linking",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FunctionLevelLinking",
+ "switch": "Gy",
+ "comment": "Enable Function-Level Linking",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableParallelCodeGeneration",
+ "switch": "Qpar-",
+ "comment": "Enable Parallel Code Generation",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableParallelCodeGeneration",
+ "switch": "Qpar",
+ "comment": "Enable Parallel Code Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointExceptions",
+ "switch": "fp:except-",
+ "comment": "Enable Floating Point Exceptions",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointExceptions",
+ "switch": "fp:except",
+ "comment": "Enable Floating Point Exceptions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CreateHotpatchableImage",
+ "switch": "hotpatch",
+ "comment": "Create Hotpatchable Image",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DisableLanguageExtensions",
+ "switch": "Za",
+ "comment": "Disable Language Extensions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWChar_tAsBuiltInType",
+ "switch": "Zc:wchar_t-",
+ "comment": "Treat WChar_t As Built in Type",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWChar_tAsBuiltInType",
+ "switch": "Zc:wchar_t",
+ "comment": "Treat WChar_t As Built in Type",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ForceConformanceInForLoopScope",
+ "switch": "Zc:forScope-",
+ "comment": "Force Conformance in For Loop Scope",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "ForceConformanceInForLoopScope",
+ "switch": "Zc:forScope",
+ "comment": "Force Conformance in For Loop Scope",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RuntimeTypeInfo",
+ "switch": "GR-",
+ "comment": "Enable Run-Time Type Information",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RuntimeTypeInfo",
+ "switch": "GR",
+ "comment": "Enable Run-Time Type Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OpenMPSupport",
+ "switch": "openmp-",
+ "comment": "Open MP Support",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OpenMPSupport",
+ "switch": "openmp",
+ "comment": "Open MP Support",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ExpandAttributedSource",
+ "switch": "Fx",
+ "comment": "Expand Attributed Source",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseUnicodeForAssemblerListing",
+ "switch": "FAu",
+ "comment": "Use Unicode For Assembler Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateXMLDocumentationFiles",
+ "switch": "doc",
+ "comment": "Generate XML Documentation Files",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "BrowseInformation",
+ "switch": "FR",
+ "comment": "Enable Browse Information",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "ShowIncludes",
+ "switch": "showIncludes",
+ "comment": "Show Includes",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnablePREfast",
+ "switch": "analyze-",
+ "comment": "Enable Code Analysis",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnablePREfast",
+ "switch": "analyze",
+ "comment": "Enable Code Analysis",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseFullPaths",
+ "switch": "FC",
+ "comment": "Use Full Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OmitDefaultLibName",
+ "switch": "Zl",
+ "comment": "Omit Default Library Name",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalIncludeDirectories",
+ "switch": "I",
+ "comment": "Additional Include Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalUsingDirectories",
+ "switch": "AI",
+ "comment": "Additional #using Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "UndefinePreprocessorDefinitions",
+ "switch": "U",
+ "comment": "Undefine Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "DisableSpecificWarnings",
+ "switch": "wd",
+ "comment": "Disable Specific Warnings",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForcedIncludeFiles",
+ "switch": "FI",
+ "comment": "Forced Include File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForcedUsingFiles",
+ "switch": "FU",
+ "comment": "Forced #using File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PREfastLog",
+ "switch": "analyze:log",
+ "comment": "Code Analysis Log",
+ "value": "",
+ "flags": [
+ "UserFollowing"
+ ]
+ },
+ {
+ "name": "PREfastAdditionalPlugins",
+ "switch": "analyze:plugin",
+ "comment": "Additional Code Analysis Native plugins",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "TreatSpecificWarningsAsErrors",
+ "switch": "we",
+ "comment": "Treat Specific Warnings As Errors",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PreprocessOutputPath",
+ "switch": "Fi",
+ "comment": "Preprocess Output Path",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderFile",
+ "switch": "Yu",
+ "comment": "Precompiled Header File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderFile",
+ "switch": "Yc",
+ "comment": "Precompiled Header File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderOutputFile",
+ "switch": "Fp",
+ "comment": "Precompiled Header Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "AssemblerListingLocation",
+ "switch": "Fa",
+ "comment": "ASM List Location",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ObjectFileName",
+ "switch": "Fo",
+ "comment": "Object File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProgramDataBaseFileName",
+ "switch": "Fd",
+ "comment": "Program Database File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "XMLDocumentationFileName",
+ "switch": "doc",
+ "comment": "XML Documentation File Name",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "BrowseInformationFile",
+ "switch": "FR",
+ "comment": "Browse Information File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ProcessorNumber",
+ "switch": "MP",
+ "comment": "Number of processors",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v11_CSharp.json b/Templates/MSBuild/FlagTables/v11_CSharp.json
new file mode 100644
index 000000000..5989aea1e
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v11_CSharp.json
@@ -0,0 +1,574 @@
+[
+ {
+ "name": "ProjectName",
+ "switch": "out:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:exe",
+ "comment": "",
+ "value": "Exe",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:winexe",
+ "comment": "",
+ "value": "Winexe",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:library",
+ "comment": "",
+ "value": "Library",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:module",
+ "comment": "",
+ "value": "Module",
+ "flags": []
+ },
+ {
+ "name": "DocumentationFile",
+ "switch": "doc",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:x86",
+ "comment": "",
+ "value": "x86",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:Itanium",
+ "comment": "",
+ "value": "Itanium",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:x64",
+ "comment": "",
+ "value": "x64",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:arm",
+ "comment": "",
+ "value": "arm",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:anycpu32bitpreferred",
+ "comment": "",
+ "value": "anycpu32bitpreferred",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:anycpu",
+ "comment": "",
+ "value": "anycpu",
+ "flags": []
+ },
+ {
+ "name": "References",
+ "switch": "reference:",
+ "comment": "mit alias",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "References",
+ "switch": "reference:",
+ "comment": "dateiliste",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "AddModules",
+ "switch": "addmodule:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "Win32Resource",
+ "switch": "win32res:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ApplicationIcon",
+ "switch": "win32icon:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ApplicationManifest",
+ "switch": "win32manifest:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "NoWin32Manifest",
+ "switch": "nowin32manifest",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DefineDebug",
+ "switch": "debug",
+ "comment": "",
+ "value": "true",
+ "flags": [
+ "Continue"
+ ]
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:none",
+ "comment": "",
+ "value": "none",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:full",
+ "comment": "",
+ "value": "full",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:pdbonly",
+ "comment": "",
+ "value": "pdbonly",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror-",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror+",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:0",
+ "comment": "",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:1",
+ "comment": "",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:2",
+ "comment": "",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:3",
+ "comment": "",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:4",
+ "comment": "",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "NoWarn",
+ "switch": "nowarn:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired",
+ "CommaAppendable"
+ ]
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DefineConstants",
+ "switch": "define:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "SemicolonAppendable",
+ "UserValue"
+ ]
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:ISO-1",
+ "comment": "",
+ "value": "ISO-1",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:ISO-2",
+ "comment": "",
+ "value": "ISO-2",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:3",
+ "comment": "",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:4",
+ "comment": "",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:5",
+ "comment": "",
+ "value": "5",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:6",
+ "comment": "",
+ "value": "6",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:default",
+ "comment": "",
+ "value": "default",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AssemblyOriginatorKeyFile",
+ "switch": "keyfile",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "KeyContainerName",
+ "switch": "keycontainer",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoLogo",
+ "switch": "nologo",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoConfig",
+ "switch": "noconfig",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "BaseAddress",
+ "switch": "baseaddress:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "CodePage",
+ "switch": "codepage",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "Utf8Output",
+ "switch": "utf8output",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "MainEntryPoint",
+ "switch": "main:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "GenerateFullPaths",
+ "switch": "fullpaths",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FileAlignment",
+ "switch": "filealign",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "PdbFile",
+ "switch": "pdb:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SubsystemVersion",
+ "switch": "subsystemversion",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibPaths",
+ "switch": "lib:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:none",
+ "comment": "Do Not Send Report",
+ "value": "none",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:prompt",
+ "comment": "Prompt Immediately",
+ "value": "prompt",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:queue",
+ "comment": "Queue For Next Login",
+ "value": "queue",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:send",
+ "comment": "Send Automatically",
+ "value": "send",
+ "flags": []
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v11_LIB.json b/Templates/MSBuild/FlagTables/v11_LIB.json
new file mode 100644
index 000000000..58a238c97
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v11_LIB.json
@@ -0,0 +1,297 @@
+[
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:PROMPT",
+ "comment": "PromptImmediately",
+ "value": "PromptImmediately",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:QUEUE",
+ "comment": "Queue For Next Login",
+ "value": "QueueForNextLogin",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:SEND",
+ "comment": "Send Error Report",
+ "value": "SendErrorReport",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:NONE",
+ "comment": "No Error Report",
+ "value": "NoErrorReport",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:ARM",
+ "comment": "MachineARM",
+ "value": "MachineARM",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:EBC",
+ "comment": "MachineEBC",
+ "value": "MachineEBC",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:IA64",
+ "comment": "MachineIA64",
+ "value": "MachineIA64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS",
+ "comment": "MachineMIPS",
+ "value": "MachineMIPS",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS16",
+ "comment": "MachineMIPS16",
+ "value": "MachineMIPS16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU",
+ "comment": "MachineMIPSFPU",
+ "value": "MachineMIPSFPU",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU16",
+ "comment": "MachineMIPSFPU16",
+ "value": "MachineMIPSFPU16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:SH4",
+ "comment": "MachineSH4",
+ "value": "MachineSH4",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:THUMB",
+ "comment": "MachineTHUMB",
+ "value": "MachineTHUMB",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X64",
+ "comment": "MachineX64",
+ "value": "MachineX64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X86",
+ "comment": "MachineX86",
+ "value": "MachineX86",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:CONSOLE",
+ "comment": "Console",
+ "value": "Console",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWS",
+ "comment": "Windows",
+ "value": "Windows",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:NATIVE",
+ "comment": "Native",
+ "value": "Native",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_APPLICATION",
+ "comment": "EFI Application",
+ "value": "EFI Application",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+ "comment": "EFI Boot Service Driver",
+ "value": "EFI Boot Service Driver",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_ROM",
+ "comment": "EFI ROM",
+ "value": "EFI ROM",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_RUNTIME_DRIVER",
+ "comment": "EFI Runtime",
+ "value": "EFI Runtime",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWSCE",
+ "comment": "WindowsCE",
+ "value": "WindowsCE",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:POSIX",
+ "comment": "POSIX",
+ "value": "POSIX",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "NOLOGO",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreAllDefaultLibraries",
+ "switch": "NODEFAULTLIB",
+ "comment": "Ignore All Default Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatLibWarningAsErrors",
+ "switch": "WX:NO",
+ "comment": "Treat Lib Warning As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatLibWarningAsErrors",
+ "switch": "WX",
+ "comment": "Treat Lib Warning As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Verbose",
+ "switch": "VERBOSE",
+ "comment": "Verbose",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG",
+ "comment": "Link Time Code Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibraryDirectories",
+ "switch": "LIBPATH:",
+ "comment": "Additional Library Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IgnoreSpecificDefaultLibraries",
+ "switch": "NODEFAULTLIB:",
+ "comment": "Ignore Specific Default Libraries",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ExportNamedFunctions",
+ "switch": "EXPORT:",
+ "comment": "Export Named Functions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "RemoveObjects",
+ "switch": "REMOVE:",
+ "comment": "Remove Objects",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "OutputFile",
+ "switch": "OUT:",
+ "comment": "Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ModuleDefinitionFile",
+ "switch": "DEF:",
+ "comment": "Module Definition File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ForceSymbolReferences",
+ "switch": "INCLUDE:",
+ "comment": "Force Symbol References",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "DisplayLibrary",
+ "switch": "LIST:",
+ "comment": "Display Library to standard output",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "Name",
+ "switch": "NAME:",
+ "comment": "Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v11_Link.json b/Templates/MSBuild/FlagTables/v11_Link.json
new file mode 100644
index 000000000..5d5c13f21
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v11_Link.json
@@ -0,0 +1,1272 @@
+[
+ {
+ "name": "ShowProgress",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE",
+ "comment": "Display all progress messages",
+ "value": "LinkVerbose",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:Lib",
+ "comment": "For Libraries Searched",
+ "value": "LinkVerboseLib",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:ICF",
+ "comment": "About COMDAT folding during optimized linking",
+ "value": "LinkVerboseICF",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:REF",
+ "comment": "About data removed during optimized linking",
+ "value": "LinkVerboseREF",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:SAFESEH",
+ "comment": "About Modules incompatible with SEH",
+ "value": "LinkVerboseSAFESEH",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:CLR",
+ "comment": "About linker activity related to managed code",
+ "value": "LinkVerboseCLR",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE:MULTIPLE",
+ "comment": "Multiply Defined Symbol Only",
+ "value": "MultiplyDefinedSymbolOnly",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE:UNRESOLVED",
+ "comment": "Undefined Symbol Only",
+ "value": "UndefinedSymbolOnly",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:5",
+ "comment": "X86 Image Only",
+ "value": "X86Image",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:6",
+ "comment": "X64 Image Only",
+ "value": "X64Image",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:16",
+ "comment": "Itanium Image Only",
+ "value": "ItaniumImage",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='asInvoker'",
+ "comment": "asInvoker",
+ "value": "AsInvoker",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='highestAvailable'",
+ "comment": "highestAvailable",
+ "value": "HighestAvailable",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='requireAdministrator'",
+ "comment": "requireAdministrator",
+ "value": "RequireAdministrator",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:CONSOLE",
+ "comment": "Console",
+ "value": "Console",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWS",
+ "comment": "Windows",
+ "value": "Windows",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:NATIVE",
+ "comment": "Native",
+ "value": "Native",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_APPLICATION",
+ "comment": "EFI Application",
+ "value": "EFI Application",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+ "comment": "EFI Boot Service Driver",
+ "value": "EFI Boot Service Driver",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_ROM",
+ "comment": "EFI ROM",
+ "value": "EFI ROM",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_RUNTIME_DRIVER",
+ "comment": "EFI Runtime",
+ "value": "EFI Runtime",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:POSIX",
+ "comment": "POSIX",
+ "value": "POSIX",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "Driver",
+ "comment": "Driver",
+ "value": "Driver",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "DRIVER:UPONLY",
+ "comment": "UP Only",
+ "value": "UpOnly",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "DRIVER:WDM",
+ "comment": "WDM",
+ "value": "WDM",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG",
+ "comment": "Use Link Time Code Generation",
+ "value": "UseLinkTimeCodeGeneration",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGInstrument",
+ "comment": "Profile Guided Optimization - Instrument",
+ "value": "PGInstrument",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGOptimize",
+ "comment": "Profile Guided Optimization - Optimization",
+ "value": "PGOptimization",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGUpdate",
+ "comment": "Profile Guided Optimization - Update",
+ "value": "PGUpdate",
+ "flags": []
+ },
+ {
+ "name": "GenerateWindowsMetadata",
+ "switch": "WINMD",
+ "comment": "Yes",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateWindowsMetadata",
+ "switch": "WINMD:NO",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA1",
+ "comment": "SHA1",
+ "value": "SHA1",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA256",
+ "comment": "SHA256",
+ "value": "SHA256",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA384",
+ "comment": "SHA384",
+ "value": "SHA384",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA512",
+ "comment": "SHA512",
+ "value": "SHA512",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:ARM",
+ "comment": "MachineARM",
+ "value": "MachineARM",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:EBC",
+ "comment": "MachineEBC",
+ "value": "MachineEBC",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:IA64",
+ "comment": "MachineIA64",
+ "value": "MachineIA64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS",
+ "comment": "MachineMIPS",
+ "value": "MachineMIPS",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS16",
+ "comment": "MachineMIPS16",
+ "value": "MachineMIPS16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU",
+ "comment": "MachineMIPSFPU",
+ "value": "MachineMIPSFPU",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU16",
+ "comment": "MachineMIPSFPU16",
+ "value": "MachineMIPSFPU16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:SH4",
+ "comment": "MachineSH4",
+ "value": "MachineSH4",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:THUMB",
+ "comment": "MachineTHUMB",
+ "value": "MachineTHUMB",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X64",
+ "comment": "MachineX64",
+ "value": "MachineX64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X86",
+ "comment": "MachineX86",
+ "value": "MachineX86",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:MTA",
+ "comment": "MTA threading attribute",
+ "value": "MTAThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:STA",
+ "comment": "STA threading attribute",
+ "value": "STAThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:NONE",
+ "comment": "Default threading attribute",
+ "value": "DefaultThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:IJW",
+ "comment": "Force IJW image",
+ "value": "ForceIJWImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:PURE",
+ "comment": "Force Pure IL Image",
+ "value": "ForcePureILImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:SAFE",
+ "comment": "Force Safe IL Image",
+ "value": "ForceSafeILImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "",
+ "comment": "Default image type",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA1",
+ "comment": "SHA1",
+ "value": "SHA1",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA256",
+ "comment": "SHA256",
+ "value": "SHA256",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA384",
+ "comment": "SHA384",
+ "value": "SHA384",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA512",
+ "comment": "SHA512",
+ "value": "SHA512",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:PROMPT",
+ "comment": "PromptImmediately",
+ "value": "PromptImmediately",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:QUEUE",
+ "comment": "Queue For Next Login",
+ "value": "QueueForNextLogin",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:SEND",
+ "comment": "Send Error Report",
+ "value": "SendErrorReport",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:NONE",
+ "comment": "No Error Report",
+ "value": "NoErrorReport",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError:NO",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError:SYSTEMDLL",
+ "comment": "System Dlls Only",
+ "value": "SystemDlls",
+ "flags": []
+ },
+ {
+ "name": "LinkIncremental",
+ "switch": "INCREMENTAL:NO",
+ "comment": "Enable Incremental Linking",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkIncremental",
+ "switch": "INCREMENTAL",
+ "comment": "Enable Incremental Linking",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "NOLOGO",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkStatus",
+ "switch": "LTCG:NOSTATUS",
+ "comment": "Link Status",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkStatus",
+ "switch": "LTCG:STATUS",
+ "comment": "Link Status",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreventDllBinding",
+ "switch": "ALLOWBIND:NO",
+ "comment": "Prevent Dll Binding",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "PreventDllBinding",
+ "switch": "ALLOWBIND",
+ "comment": "Prevent Dll Binding",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatLinkerWarningAsErrors",
+ "switch": "WX:NO",
+ "comment": "Treat Linker Warning As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatLinkerWarningAsErrors",
+ "switch": "WX",
+ "comment": "Treat Linker Warning As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreAllDefaultLibraries",
+ "switch": "NODEFAULTLIB",
+ "comment": "Ignore All Default Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateManifest",
+ "switch": "MANIFEST:NO",
+ "comment": "Generate Manifest",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "GenerateManifest",
+ "switch": "MANIFEST",
+ "comment": "Generate Manifest",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowIsolation",
+ "switch": "ALLOWISOLATION:NO",
+ "comment": "Allow Isolation",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AllowIsolation",
+ "switch": "",
+ "comment": "Allow Isolation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableUAC",
+ "switch": "MANIFESTUAC:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired",
+ "SpaceAppendable"
+ ]
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='false'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "false",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='false'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='true'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ManifestEmbed",
+ "switch": "manifest:embed",
+ "comment": "Embed Manifest",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG",
+ "comment": "Generate Debug Info",
+ "value": "true",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "GenerateMapFile",
+ "switch": "MAP",
+ "comment": "Generate Map File",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "MapExports",
+ "switch": "MAPINFO:EXPORTS",
+ "comment": "Map Exports",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AssemblyDebug",
+ "switch": "ASSEMBLYDEBUG:DISABLE",
+ "comment": "Debuggable Assembly",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AssemblyDebug",
+ "switch": "ASSEMBLYDEBUG",
+ "comment": "Debuggable Assembly",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LargeAddressAware",
+ "switch": "LARGEADDRESSAWARE:NO",
+ "comment": "Enable Large Addresses",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LargeAddressAware",
+ "switch": "LARGEADDRESSAWARE",
+ "comment": "Enable Large Addresses",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TerminalServerAware",
+ "switch": "TSAWARE:NO",
+ "comment": "Terminal Server",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TerminalServerAware",
+ "switch": "TSAWARE",
+ "comment": "Terminal Server",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SwapRunFromCD",
+ "switch": "SWAPRUN:CD",
+ "comment": "Swap Run From CD",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SwapRunFromNET",
+ "switch": "SWAPRUN:NET",
+ "comment": "Swap Run From Network",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OptimizeReferences",
+ "switch": "OPT:NOREF",
+ "comment": "References",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OptimizeReferences",
+ "switch": "OPT:REF",
+ "comment": "References",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableCOMDATFolding",
+ "switch": "OPT:NOICF",
+ "comment": "Enable COMDAT Folding",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableCOMDATFolding",
+ "switch": "OPT:ICF",
+ "comment": "Enable COMDAT Folding",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreEmbeddedIDL",
+ "switch": "IGNOREIDL",
+ "comment": "Ignore Embedded IDL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AppContainer",
+ "switch": "APPCONTAINER",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataLinkDelaySign",
+ "switch": "WINMDDELAYSIGN:NO",
+ "comment": "Windows Metadata Delay Sign",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataLinkDelaySign",
+ "switch": "WINMDDELAYSIGN",
+ "comment": "Windows Metadata Delay Sign",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NoEntryPoint",
+ "switch": "NOENTRY",
+ "comment": "No Entry Point",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SetChecksum",
+ "switch": "RELEASE",
+ "comment": "Set Checksum",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RandomizedBaseAddress",
+ "switch": "DYNAMICBASE:NO",
+ "comment": "Randomized Base Address",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RandomizedBaseAddress",
+ "switch": "DYNAMICBASE",
+ "comment": "Randomized Base Address",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FixedBaseAddress",
+ "switch": "FIXED:NO",
+ "comment": "Fixed Base Address",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FixedBaseAddress",
+ "switch": "FIXED",
+ "comment": "Fixed Base Address",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DataExecutionPrevention",
+ "switch": "NXCOMPAT:NO",
+ "comment": "Data Execution Prevention (DEP)",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DataExecutionPrevention",
+ "switch": "NXCOMPAT",
+ "comment": "Data Execution Prevention (DEP)",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TurnOffAssemblyGeneration",
+ "switch": "NOASSEMBLY",
+ "comment": "Turn Off Assembly Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SupportUnloadOfDelayLoadedDLL",
+ "switch": "DELAY:UNLOAD",
+ "comment": "Unload delay loaded DLL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SupportNobindOfDelayLoadedDLL",
+ "switch": "DELAY:NOBIND",
+ "comment": "Nobind delay loaded DLL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Profile",
+ "switch": "PROFILE",
+ "comment": "Profile",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkDelaySign",
+ "switch": "DELAYSIGN:NO",
+ "comment": "Delay Sign",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkDelaySign",
+ "switch": "DELAYSIGN",
+ "comment": "Delay Sign",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CLRUnmanagedCodeCheck",
+ "switch": "CLRUNMANAGEDCODECHECK:NO",
+ "comment": "CLR Unmanaged Code Check",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CLRUnmanagedCodeCheck",
+ "switch": "CLRUNMANAGEDCODECHECK",
+ "comment": "CLR Unmanaged Code Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DetectOneDefinitionRule",
+ "switch": "ODR",
+ "comment": "Detect One Definition Rule violations",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ImageHasSafeExceptionHandlers",
+ "switch": "SAFESEH:NO",
+ "comment": "Image Has Safe Exception Handlers",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "ImageHasSafeExceptionHandlers",
+ "switch": "SAFESEH",
+ "comment": "Image Has Safe Exception Handlers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkDLL",
+ "switch": "DLL",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibraryDirectories",
+ "switch": "LIBPATH:",
+ "comment": "Additional Library Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IgnoreSpecificDefaultLibraries",
+ "switch": "NODEFAULTLIB:",
+ "comment": "Ignore Specific Default Libraries",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AddModuleNamesToAssembly",
+ "switch": "ASSEMBLYMODULE:",
+ "comment": "Add Module to Assembly",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "EmbedManagedResourceFile",
+ "switch": "ASSEMBLYRESOURCE:",
+ "comment": "Embed Managed Resource File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForceSymbolReferences",
+ "switch": "INCLUDE:",
+ "comment": "Force Symbol References",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "DelayLoadDLLs",
+ "switch": "DELAYLOAD:",
+ "comment": "Delay Loaded Dlls",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AssemblyLinkResource",
+ "switch": "ASSEMBLYLINKRESOURCE:",
+ "comment": "Assembly Link Resource",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalManifestDependencies",
+ "switch": "MANIFESTDEPENDENCY:",
+ "comment": "Additional Manifest Dependencies",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ManifestInput",
+ "switch": "manifestinput:",
+ "comment": "Manifest Input",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "OutputFile",
+ "switch": "OUT:",
+ "comment": "Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "Version",
+ "switch": "VERSION:",
+ "comment": "Version",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "SpecifySectionAttributes",
+ "switch": "SECTION:",
+ "comment": "Specify Section Attributes",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MSDOSStubFileName",
+ "switch": "STUB:",
+ "comment": "MS-DOS Stub File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ModuleDefinitionFile",
+ "switch": "DEF:",
+ "comment": "Module Definition File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ManifestFile",
+ "switch": "ManifestFile:",
+ "comment": "Manifest File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProgramDatabaseFile",
+ "switch": "PDB:",
+ "comment": "Generate Program Database File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "StripPrivateSymbols",
+ "switch": "PDBSTRIPPED:",
+ "comment": "Strip Private Symbols",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MapFileName",
+ "switch": "MAP:",
+ "comment": "Map File Name",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "HeapReserveSize",
+ "switch": "HEAP:",
+ "comment": "Heap Reserve Size",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "HeapCommitSize",
+ "switch": "HEAP",
+ "comment": "Heap Commit Size",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "StackReserveSize",
+ "switch": "STACK:",
+ "comment": "Stack Reserve Size",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "StackCommitSize",
+ "switch": "STACK",
+ "comment": "Stack Commit Size",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "FunctionOrder",
+ "switch": "ORDER:@",
+ "comment": "Function Order",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProfileGuidedDatabase",
+ "switch": "PGD:",
+ "comment": "Profile Guided Database",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MidlCommandFile",
+ "switch": "MIDL:@",
+ "comment": "MIDL Commands",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MergedIDLBaseFileName",
+ "switch": "IDLOUT:",
+ "comment": "Merged IDL Base File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "TypeLibraryFile",
+ "switch": "TLBOUT:",
+ "comment": "Type Library",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataFile",
+ "switch": "WINMDFILE:",
+ "comment": "Windows Metadata File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataLinkKeyFile",
+ "switch": "WINMDKEYFILE:",
+ "comment": "Windows Metadata Key File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataKeyContainer",
+ "switch": "WINMDKEYCONTAINER:",
+ "comment": "Windows Metadata Key Container",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "EntryPointSymbol",
+ "switch": "ENTRY:",
+ "comment": "Entry Point",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "BaseAddress",
+ "switch": "BASE:",
+ "comment": "Base Address",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ImportLibrary",
+ "switch": "IMPLIB:",
+ "comment": "Import Library",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MergeSections",
+ "switch": "MERGE:",
+ "comment": "Merge Sections",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "LinkKeyFile",
+ "switch": "KEYFILE:",
+ "comment": "Key File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "KeyContainer",
+ "switch": "KEYCONTAINER:",
+ "comment": "Key Container",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "TypeLibraryResourceID",
+ "switch": "TLBID:",
+ "comment": "TypeLib Resource ID",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "SectionAlignment",
+ "switch": "ALIGN:",
+ "comment": "SectionAlignment",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v11_MASM.json b/Templates/MSBuild/FlagTables/v11_MASM.json
new file mode 100644
index 000000000..4634306b1
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v11_MASM.json
@@ -0,0 +1,295 @@
+[
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "",
+ "comment": "Default",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "Cp",
+ "comment": "Preserves Identifier Case (/Cp)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "Cu",
+ "comment": "Maps all identifiers to upper case. (/Cu)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "Cx",
+ "comment": "Preserves case in public and extern symbols. (/Cx)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W0",
+ "comment": "Warning Level 0 (/W0)",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W1",
+ "comment": "Warning Level 1 (/W1)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W2",
+ "comment": "Warning Level 2 (/W2)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W3",
+ "comment": "Warning Level 3 (/W3)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "",
+ "comment": "Default",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp1",
+ "comment": "One Byte Boundary (/Zp1)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp2",
+ "comment": "Two Byte Boundary (/Zp2)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp4",
+ "comment": "Four Byte Boundary (/Zp4)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp8",
+ "comment": "Eight Byte Boundary (/Zp8)",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp16",
+ "comment": "Sixteen Byte Boundary (/Zp16)",
+ "value": "5",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "",
+ "comment": "Default",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gd",
+ "comment": "Use C-style Calling Convention (/Gd)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gz",
+ "comment": "Use stdcall Calling Convention (/Gz)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gc",
+ "comment": "Use Pascal Calling Convention (/Gc)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:prompt",
+ "comment": "Prompt to send report immediately (/errorReport:prompt)",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:queue",
+ "comment": "Prompt to send report at the next logon (/errorReport:queue)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:send",
+ "comment": "Automatically send report (/errorReport:send)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:none",
+ "comment": "Do not send report (/errorReport:none)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "NoLogo",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GeneratePreprocessedSourceListing",
+ "switch": "EP",
+ "comment": "Generate Preprocessed Source Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ListAllAvailableInformation",
+ "switch": "Sa",
+ "comment": "List All Available Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseSafeExceptionHandlers",
+ "switch": "safeseh",
+ "comment": "Use Safe Exception Handlers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AddFirstPassListing",
+ "switch": "Sf",
+ "comment": "Add First Pass Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableAssemblyGeneratedCodeListing",
+ "switch": "Sg",
+ "comment": "Enable Assembly Generated Code Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DisableSymbolTable",
+ "switch": "Sn",
+ "comment": "Disable Symbol Table",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableFalseConditionalsInListing",
+ "switch": "Sx",
+ "comment": "Enable False Conditionals In Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "WX",
+ "comment": "Treat Warnings As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MakeAllSymbolsPublic",
+ "switch": "Zf",
+ "comment": "Make All Symbols Public",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "Zi",
+ "comment": "Generate Debug Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableMASM51Compatibility",
+ "switch": "Zm",
+ "comment": "Enable MASM 5.1 Compatibility",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PerformSyntaxCheckOnly",
+ "switch": "Zs",
+ "comment": "Perform Syntax Check Only",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IncludePaths",
+ "switch": "I",
+ "comment": "Include Paths",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "BrowseFile",
+ "switch": "FR",
+ "comment": "Generate Browse Information File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ObjectFileName",
+ "switch": "Fo",
+ "comment": "Object File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "AssembledCodeListingFile",
+ "switch": "Fl",
+ "comment": "Assembled Code Listing File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v11_RC.json b/Templates/MSBuild/FlagTables/v11_RC.json
new file mode 100644
index 000000000..b8c0127d1
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v11_RC.json
@@ -0,0 +1,69 @@
+[
+ {
+ "name": "IgnoreStandardIncludePath",
+ "switch": "X",
+ "comment": "Ignore Standard Include Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "v",
+ "comment": "Show Progress",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NullTerminateStrings",
+ "switch": "n",
+ "comment": "Null Terminate Strings",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "UndefinePreprocessorDefinitions",
+ "switch": "u",
+ "comment": "Undefine Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalIncludeDirectories",
+ "switch": "I",
+ "comment": "Additional Include Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ResourceOutputFileName",
+ "switch": "fo",
+ "comment": "Resource File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v12_CL.json b/Templates/MSBuild/FlagTables/v12_CL.json
new file mode 100644
index 000000000..771a5551c
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v12_CL.json
@@ -0,0 +1,1077 @@
+[
+ {
+ "name": "DebugInformationFormat",
+ "switch": "",
+ "comment": "None",
+ "value": "None",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "Z7",
+ "comment": "C7 compatible",
+ "value": "OldStyle",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "Zi",
+ "comment": "Program Database",
+ "value": "ProgramDatabase",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "ZI",
+ "comment": "Program Database for Edit And Continue",
+ "value": "EditAndContinue",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "",
+ "comment": "No Common Language RunTime Support",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr",
+ "comment": "Common Language RunTime Support",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:pure",
+ "comment": "Pure MSIL Common Language RunTime Support",
+ "value": "Pure",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:safe",
+ "comment": "Safe MSIL Common Language RunTime Support",
+ "value": "Safe",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:oldSyntax",
+ "comment": "Common Language RunTime Support, Old Syntax",
+ "value": "OldSyntax",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W0",
+ "comment": "Turn Off All Warnings",
+ "value": "TurnOffAllWarnings",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W1",
+ "comment": "Level1",
+ "value": "Level1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W2",
+ "comment": "Level2",
+ "value": "Level2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W3",
+ "comment": "Level3",
+ "value": "Level3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W4",
+ "comment": "Level4",
+ "value": "Level4",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "Wall",
+ "comment": "EnableAllWarnings",
+ "value": "EnableAllWarnings",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "",
+ "comment": "Custom",
+ "value": "Custom",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "Od",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O1",
+ "comment": "Minimize Size",
+ "value": "MinSpace",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O2",
+ "comment": "Maximize Speed",
+ "value": "MaxSpeed",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "Ox",
+ "comment": "Full Optimization",
+ "value": "Full",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob0",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob1",
+ "comment": "Only __inline",
+ "value": "OnlyExplicitInline",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob2",
+ "comment": "Any Suitable",
+ "value": "AnySuitable",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "Os",
+ "comment": "Favor small code",
+ "value": "Size",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "Ot",
+ "comment": "Favor fast code",
+ "value": "Speed",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "",
+ "comment": "Neither",
+ "value": "Neither",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHa",
+ "comment": "Yes with SEH Exceptions",
+ "value": "Async",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHsc",
+ "comment": "Yes",
+ "value": "Sync",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHs",
+ "comment": "Yes with Extern C functions",
+ "value": "SyncCThrow",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTCs",
+ "comment": "Stack Frames",
+ "value": "StackFrameRuntimeCheck",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTCu",
+ "comment": "Uninitialized variables",
+ "value": "UninitializedLocalUsageCheck",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTC1",
+ "comment": "Both (/RTC1, equiv. to /RTCsu)",
+ "value": "EnableFastChecks",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MT",
+ "comment": "Multi-threaded",
+ "value": "MultiThreaded",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MTd",
+ "comment": "Multi-threaded Debug",
+ "value": "MultiThreadedDebug",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MD",
+ "comment": "Multi-threaded DLL",
+ "value": "MultiThreadedDLL",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MDd",
+ "comment": "Multi-threaded Debug DLL",
+ "value": "MultiThreadedDebugDLL",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp1",
+ "comment": "1 Byte",
+ "value": "1Byte",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp2",
+ "comment": "2 Bytes",
+ "value": "2Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp4",
+ "comment": "4 Byte",
+ "value": "4Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp8",
+ "comment": "8 Bytes",
+ "value": "8Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp16",
+ "comment": "16 Bytes",
+ "value": "16Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "BufferSecurityCheck",
+ "switch": "GS-",
+ "comment": "Disable Security Check",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "BufferSecurityCheck",
+ "switch": "GS",
+ "comment": "Enable Security Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:SSE",
+ "comment": "Streaming SIMD Extensions",
+ "value": "StreamingSIMDExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:SSE2",
+ "comment": "Streaming SIMD Extensions 2",
+ "value": "StreamingSIMDExtensions2",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:AVX",
+ "comment": "Advanced Vector Extensions",
+ "value": "AdvancedVectorExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:AVX2",
+ "comment": "Advanced Vector Extensions 2",
+ "value": "AdvancedVectorExtensions2",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:IA32",
+ "comment": "No Enhanced Instructions",
+ "value": "NoExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:precise",
+ "comment": "Precise",
+ "value": "Precise",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:strict",
+ "comment": "Strict",
+ "value": "Strict",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:fast",
+ "comment": "Fast",
+ "value": "Fast",
+ "flags": []
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Yc",
+ "comment": "Create",
+ "value": "Create",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Yu",
+ "comment": "Use",
+ "value": "Use",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Y-",
+ "comment": "Not Using Precompiled Headers",
+ "value": "NotUsing",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "",
+ "comment": "No Listing",
+ "value": "NoListing",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FA",
+ "comment": "Assembly-Only Listing",
+ "value": "AssemblyCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAc",
+ "comment": "Assembly With Machine Code",
+ "value": "AssemblyAndMachineCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAs",
+ "comment": "Assembly With Source Code",
+ "value": "AssemblyAndSourceCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAcs",
+ "comment": "Assembly, Machine Code and Source",
+ "value": "All",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gd",
+ "comment": "__cdecl",
+ "value": "Cdecl",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gr",
+ "comment": "__fastcall",
+ "value": "FastCall",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gz",
+ "comment": "__stdcall",
+ "value": "StdCall",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gv",
+ "comment": "__vectorcall",
+ "value": "VectorCall",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "TC",
+ "comment": "Compile as C Code",
+ "value": "CompileAsC",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "TP",
+ "comment": "Compile as C++ Code",
+ "value": "CompileAsCpp",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:none",
+ "comment": "Do Not Send Report",
+ "value": "None",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:prompt",
+ "comment": "Prompt Immediately",
+ "value": "Prompt",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:queue",
+ "comment": "Queue For Next Login",
+ "value": "Queue",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:send",
+ "comment": "Send Automatically",
+ "value": "Send",
+ "flags": []
+ },
+ {
+ "name": "CompileAsWinRT",
+ "switch": "ZW",
+ "comment": "Consume Windows Runtime Extension",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WinRTNoStdLib",
+ "switch": "ZW:nostdlib",
+ "comment": "No Standard WinRT Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningAsError",
+ "switch": "WX-",
+ "comment": "Treat Warnings As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningAsError",
+ "switch": "WX",
+ "comment": "Treat Warnings As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SDLCheck",
+ "switch": "sdl-",
+ "comment": "SDL checks",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "SDLCheck",
+ "switch": "sdl",
+ "comment": "SDL checks",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MultiProcessorCompilation",
+ "switch": "MP",
+ "comment": "Multi-processor Compilation",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "IntrinsicFunctions",
+ "switch": "Oi",
+ "comment": "Enable Intrinsic Functions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OmitFramePointers",
+ "switch": "Oy-",
+ "comment": "Omit Frame Pointers",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OmitFramePointers",
+ "switch": "Oy",
+ "comment": "Omit Frame Pointers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableFiberSafeOptimizations",
+ "switch": "GT",
+ "comment": "Enable Fiber-Safe Optimizations",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WholeProgramOptimization",
+ "switch": "GL",
+ "comment": "Whole Program Optimization",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UndefineAllPreprocessorDefinitions",
+ "switch": "u",
+ "comment": "Undefine All Preprocessor Definitions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreStandardIncludePath",
+ "switch": "X",
+ "comment": "Ignore Standard Include Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessToFile",
+ "switch": "P",
+ "comment": "Preprocess to a File",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessSuppressLineNumbers",
+ "switch": "EP",
+ "comment": "Preprocess Suppress Line Numbers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessKeepComments",
+ "switch": "C",
+ "comment": "Keep Comments",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "StringPooling",
+ "switch": "GF-",
+ "comment": "Enable String Pooling",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "StringPooling",
+ "switch": "GF",
+ "comment": "Enable String Pooling",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MinimalRebuild",
+ "switch": "Gm-",
+ "comment": "Enable Minimal Rebuild",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "MinimalRebuild",
+ "switch": "Gm",
+ "comment": "Enable Minimal Rebuild",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SmallerTypeCheck",
+ "switch": "RTCc",
+ "comment": "Smaller Type Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FunctionLevelLinking",
+ "switch": "Gy-",
+ "comment": "Enable Function-Level Linking",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FunctionLevelLinking",
+ "switch": "Gy",
+ "comment": "Enable Function-Level Linking",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableParallelCodeGeneration",
+ "switch": "Qpar-",
+ "comment": "Enable Parallel Code Generation",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableParallelCodeGeneration",
+ "switch": "Qpar",
+ "comment": "Enable Parallel Code Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointExceptions",
+ "switch": "fp:except-",
+ "comment": "Enable Floating Point Exceptions",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointExceptions",
+ "switch": "fp:except",
+ "comment": "Enable Floating Point Exceptions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CreateHotpatchableImage",
+ "switch": "hotpatch",
+ "comment": "Create Hotpatchable Image",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DisableLanguageExtensions",
+ "switch": "Za",
+ "comment": "Disable Language Extensions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWChar_tAsBuiltInType",
+ "switch": "Zc:wchar_t-",
+ "comment": "Treat WChar_t As Built in Type",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWChar_tAsBuiltInType",
+ "switch": "Zc:wchar_t",
+ "comment": "Treat WChar_t As Built in Type",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ForceConformanceInForLoopScope",
+ "switch": "Zc:forScope-",
+ "comment": "Force Conformance in For Loop Scope",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "ForceConformanceInForLoopScope",
+ "switch": "Zc:forScope",
+ "comment": "Force Conformance in For Loop Scope",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RuntimeTypeInfo",
+ "switch": "GR-",
+ "comment": "Enable Run-Time Type Information",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RuntimeTypeInfo",
+ "switch": "GR",
+ "comment": "Enable Run-Time Type Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OpenMPSupport",
+ "switch": "openmp-",
+ "comment": "Open MP Support",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OpenMPSupport",
+ "switch": "openmp",
+ "comment": "Open MP Support",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ExpandAttributedSource",
+ "switch": "Fx",
+ "comment": "Expand Attributed Source",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseUnicodeForAssemblerListing",
+ "switch": "FAu",
+ "comment": "Use Unicode For Assembler Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateXMLDocumentationFiles",
+ "switch": "doc",
+ "comment": "Generate XML Documentation Files",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "BrowseInformation",
+ "switch": "FR",
+ "comment": "Enable Browse Information",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "ShowIncludes",
+ "switch": "showIncludes",
+ "comment": "Show Includes",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnablePREfast",
+ "switch": "analyze-",
+ "comment": "Enable Code Analysis",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnablePREfast",
+ "switch": "analyze",
+ "comment": "Enable Code Analysis",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseFullPaths",
+ "switch": "FC",
+ "comment": "Use Full Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OmitDefaultLibName",
+ "switch": "Zl",
+ "comment": "Omit Default Library Name",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalIncludeDirectories",
+ "switch": "I",
+ "comment": "Additional Include Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalUsingDirectories",
+ "switch": "AI",
+ "comment": "Additional #using Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "UndefinePreprocessorDefinitions",
+ "switch": "U",
+ "comment": "Undefine Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "DisableSpecificWarnings",
+ "switch": "wd",
+ "comment": "Disable Specific Warnings",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForcedIncludeFiles",
+ "switch": "FI",
+ "comment": "Forced Include File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForcedUsingFiles",
+ "switch": "FU",
+ "comment": "Forced #using File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PREfastLog",
+ "switch": "analyze:log",
+ "comment": "Code Analysis Log",
+ "value": "",
+ "flags": [
+ "UserFollowing"
+ ]
+ },
+ {
+ "name": "PREfastAdditionalPlugins",
+ "switch": "analyze:plugin",
+ "comment": "Additional Code Analysis Native plugins",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "TreatSpecificWarningsAsErrors",
+ "switch": "we",
+ "comment": "Treat Specific Warnings As Errors",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PreprocessOutputPath",
+ "switch": "Fi",
+ "comment": "Preprocess Output Path",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderFile",
+ "switch": "Yu",
+ "comment": "Precompiled Header File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderFile",
+ "switch": "Yc",
+ "comment": "Precompiled Header File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderOutputFile",
+ "switch": "Fp",
+ "comment": "Precompiled Header Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "AssemblerListingLocation",
+ "switch": "Fa",
+ "comment": "ASM List Location",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ObjectFileName",
+ "switch": "Fo",
+ "comment": "Object File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProgramDataBaseFileName",
+ "switch": "Fd",
+ "comment": "Program Database File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "XMLDocumentationFileName",
+ "switch": "doc",
+ "comment": "XML Documentation File Name",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "BrowseInformationFile",
+ "switch": "FR",
+ "comment": "Browse Information File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ProcessorNumber",
+ "switch": "MP",
+ "comment": "Number of processors",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v12_CSharp.json b/Templates/MSBuild/FlagTables/v12_CSharp.json
new file mode 100644
index 000000000..5989aea1e
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v12_CSharp.json
@@ -0,0 +1,574 @@
+[
+ {
+ "name": "ProjectName",
+ "switch": "out:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:exe",
+ "comment": "",
+ "value": "Exe",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:winexe",
+ "comment": "",
+ "value": "Winexe",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:library",
+ "comment": "",
+ "value": "Library",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:module",
+ "comment": "",
+ "value": "Module",
+ "flags": []
+ },
+ {
+ "name": "DocumentationFile",
+ "switch": "doc",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:x86",
+ "comment": "",
+ "value": "x86",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:Itanium",
+ "comment": "",
+ "value": "Itanium",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:x64",
+ "comment": "",
+ "value": "x64",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:arm",
+ "comment": "",
+ "value": "arm",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:anycpu32bitpreferred",
+ "comment": "",
+ "value": "anycpu32bitpreferred",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:anycpu",
+ "comment": "",
+ "value": "anycpu",
+ "flags": []
+ },
+ {
+ "name": "References",
+ "switch": "reference:",
+ "comment": "mit alias",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "References",
+ "switch": "reference:",
+ "comment": "dateiliste",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "AddModules",
+ "switch": "addmodule:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "Win32Resource",
+ "switch": "win32res:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ApplicationIcon",
+ "switch": "win32icon:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ApplicationManifest",
+ "switch": "win32manifest:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "NoWin32Manifest",
+ "switch": "nowin32manifest",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DefineDebug",
+ "switch": "debug",
+ "comment": "",
+ "value": "true",
+ "flags": [
+ "Continue"
+ ]
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:none",
+ "comment": "",
+ "value": "none",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:full",
+ "comment": "",
+ "value": "full",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:pdbonly",
+ "comment": "",
+ "value": "pdbonly",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror-",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror+",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:0",
+ "comment": "",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:1",
+ "comment": "",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:2",
+ "comment": "",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:3",
+ "comment": "",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:4",
+ "comment": "",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "NoWarn",
+ "switch": "nowarn:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired",
+ "CommaAppendable"
+ ]
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DefineConstants",
+ "switch": "define:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "SemicolonAppendable",
+ "UserValue"
+ ]
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:ISO-1",
+ "comment": "",
+ "value": "ISO-1",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:ISO-2",
+ "comment": "",
+ "value": "ISO-2",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:3",
+ "comment": "",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:4",
+ "comment": "",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:5",
+ "comment": "",
+ "value": "5",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:6",
+ "comment": "",
+ "value": "6",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:default",
+ "comment": "",
+ "value": "default",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AssemblyOriginatorKeyFile",
+ "switch": "keyfile",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "KeyContainerName",
+ "switch": "keycontainer",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoLogo",
+ "switch": "nologo",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoConfig",
+ "switch": "noconfig",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "BaseAddress",
+ "switch": "baseaddress:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "CodePage",
+ "switch": "codepage",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "Utf8Output",
+ "switch": "utf8output",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "MainEntryPoint",
+ "switch": "main:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "GenerateFullPaths",
+ "switch": "fullpaths",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FileAlignment",
+ "switch": "filealign",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "PdbFile",
+ "switch": "pdb:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SubsystemVersion",
+ "switch": "subsystemversion",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibPaths",
+ "switch": "lib:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:none",
+ "comment": "Do Not Send Report",
+ "value": "none",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:prompt",
+ "comment": "Prompt Immediately",
+ "value": "prompt",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:queue",
+ "comment": "Queue For Next Login",
+ "value": "queue",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:send",
+ "comment": "Send Automatically",
+ "value": "send",
+ "flags": []
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v12_LIB.json b/Templates/MSBuild/FlagTables/v12_LIB.json
new file mode 100644
index 000000000..58a238c97
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v12_LIB.json
@@ -0,0 +1,297 @@
+[
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:PROMPT",
+ "comment": "PromptImmediately",
+ "value": "PromptImmediately",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:QUEUE",
+ "comment": "Queue For Next Login",
+ "value": "QueueForNextLogin",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:SEND",
+ "comment": "Send Error Report",
+ "value": "SendErrorReport",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:NONE",
+ "comment": "No Error Report",
+ "value": "NoErrorReport",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:ARM",
+ "comment": "MachineARM",
+ "value": "MachineARM",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:EBC",
+ "comment": "MachineEBC",
+ "value": "MachineEBC",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:IA64",
+ "comment": "MachineIA64",
+ "value": "MachineIA64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS",
+ "comment": "MachineMIPS",
+ "value": "MachineMIPS",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS16",
+ "comment": "MachineMIPS16",
+ "value": "MachineMIPS16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU",
+ "comment": "MachineMIPSFPU",
+ "value": "MachineMIPSFPU",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU16",
+ "comment": "MachineMIPSFPU16",
+ "value": "MachineMIPSFPU16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:SH4",
+ "comment": "MachineSH4",
+ "value": "MachineSH4",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:THUMB",
+ "comment": "MachineTHUMB",
+ "value": "MachineTHUMB",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X64",
+ "comment": "MachineX64",
+ "value": "MachineX64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X86",
+ "comment": "MachineX86",
+ "value": "MachineX86",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:CONSOLE",
+ "comment": "Console",
+ "value": "Console",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWS",
+ "comment": "Windows",
+ "value": "Windows",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:NATIVE",
+ "comment": "Native",
+ "value": "Native",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_APPLICATION",
+ "comment": "EFI Application",
+ "value": "EFI Application",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+ "comment": "EFI Boot Service Driver",
+ "value": "EFI Boot Service Driver",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_ROM",
+ "comment": "EFI ROM",
+ "value": "EFI ROM",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_RUNTIME_DRIVER",
+ "comment": "EFI Runtime",
+ "value": "EFI Runtime",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWSCE",
+ "comment": "WindowsCE",
+ "value": "WindowsCE",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:POSIX",
+ "comment": "POSIX",
+ "value": "POSIX",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "NOLOGO",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreAllDefaultLibraries",
+ "switch": "NODEFAULTLIB",
+ "comment": "Ignore All Default Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatLibWarningAsErrors",
+ "switch": "WX:NO",
+ "comment": "Treat Lib Warning As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatLibWarningAsErrors",
+ "switch": "WX",
+ "comment": "Treat Lib Warning As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Verbose",
+ "switch": "VERBOSE",
+ "comment": "Verbose",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG",
+ "comment": "Link Time Code Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibraryDirectories",
+ "switch": "LIBPATH:",
+ "comment": "Additional Library Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IgnoreSpecificDefaultLibraries",
+ "switch": "NODEFAULTLIB:",
+ "comment": "Ignore Specific Default Libraries",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ExportNamedFunctions",
+ "switch": "EXPORT:",
+ "comment": "Export Named Functions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "RemoveObjects",
+ "switch": "REMOVE:",
+ "comment": "Remove Objects",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "OutputFile",
+ "switch": "OUT:",
+ "comment": "Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ModuleDefinitionFile",
+ "switch": "DEF:",
+ "comment": "Module Definition File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ForceSymbolReferences",
+ "switch": "INCLUDE:",
+ "comment": "Force Symbol References",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "DisplayLibrary",
+ "switch": "LIST:",
+ "comment": "Display Library to standard output",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "Name",
+ "switch": "NAME:",
+ "comment": "Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v12_Link.json b/Templates/MSBuild/FlagTables/v12_Link.json
new file mode 100644
index 000000000..5d5c13f21
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v12_Link.json
@@ -0,0 +1,1272 @@
+[
+ {
+ "name": "ShowProgress",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE",
+ "comment": "Display all progress messages",
+ "value": "LinkVerbose",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:Lib",
+ "comment": "For Libraries Searched",
+ "value": "LinkVerboseLib",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:ICF",
+ "comment": "About COMDAT folding during optimized linking",
+ "value": "LinkVerboseICF",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:REF",
+ "comment": "About data removed during optimized linking",
+ "value": "LinkVerboseREF",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:SAFESEH",
+ "comment": "About Modules incompatible with SEH",
+ "value": "LinkVerboseSAFESEH",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:CLR",
+ "comment": "About linker activity related to managed code",
+ "value": "LinkVerboseCLR",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE:MULTIPLE",
+ "comment": "Multiply Defined Symbol Only",
+ "value": "MultiplyDefinedSymbolOnly",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE:UNRESOLVED",
+ "comment": "Undefined Symbol Only",
+ "value": "UndefinedSymbolOnly",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:5",
+ "comment": "X86 Image Only",
+ "value": "X86Image",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:6",
+ "comment": "X64 Image Only",
+ "value": "X64Image",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:16",
+ "comment": "Itanium Image Only",
+ "value": "ItaniumImage",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='asInvoker'",
+ "comment": "asInvoker",
+ "value": "AsInvoker",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='highestAvailable'",
+ "comment": "highestAvailable",
+ "value": "HighestAvailable",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='requireAdministrator'",
+ "comment": "requireAdministrator",
+ "value": "RequireAdministrator",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:CONSOLE",
+ "comment": "Console",
+ "value": "Console",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWS",
+ "comment": "Windows",
+ "value": "Windows",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:NATIVE",
+ "comment": "Native",
+ "value": "Native",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_APPLICATION",
+ "comment": "EFI Application",
+ "value": "EFI Application",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+ "comment": "EFI Boot Service Driver",
+ "value": "EFI Boot Service Driver",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_ROM",
+ "comment": "EFI ROM",
+ "value": "EFI ROM",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_RUNTIME_DRIVER",
+ "comment": "EFI Runtime",
+ "value": "EFI Runtime",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:POSIX",
+ "comment": "POSIX",
+ "value": "POSIX",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "Driver",
+ "comment": "Driver",
+ "value": "Driver",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "DRIVER:UPONLY",
+ "comment": "UP Only",
+ "value": "UpOnly",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "DRIVER:WDM",
+ "comment": "WDM",
+ "value": "WDM",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG",
+ "comment": "Use Link Time Code Generation",
+ "value": "UseLinkTimeCodeGeneration",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGInstrument",
+ "comment": "Profile Guided Optimization - Instrument",
+ "value": "PGInstrument",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGOptimize",
+ "comment": "Profile Guided Optimization - Optimization",
+ "value": "PGOptimization",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGUpdate",
+ "comment": "Profile Guided Optimization - Update",
+ "value": "PGUpdate",
+ "flags": []
+ },
+ {
+ "name": "GenerateWindowsMetadata",
+ "switch": "WINMD",
+ "comment": "Yes",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateWindowsMetadata",
+ "switch": "WINMD:NO",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA1",
+ "comment": "SHA1",
+ "value": "SHA1",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA256",
+ "comment": "SHA256",
+ "value": "SHA256",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA384",
+ "comment": "SHA384",
+ "value": "SHA384",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA512",
+ "comment": "SHA512",
+ "value": "SHA512",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:ARM",
+ "comment": "MachineARM",
+ "value": "MachineARM",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:EBC",
+ "comment": "MachineEBC",
+ "value": "MachineEBC",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:IA64",
+ "comment": "MachineIA64",
+ "value": "MachineIA64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS",
+ "comment": "MachineMIPS",
+ "value": "MachineMIPS",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS16",
+ "comment": "MachineMIPS16",
+ "value": "MachineMIPS16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU",
+ "comment": "MachineMIPSFPU",
+ "value": "MachineMIPSFPU",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU16",
+ "comment": "MachineMIPSFPU16",
+ "value": "MachineMIPSFPU16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:SH4",
+ "comment": "MachineSH4",
+ "value": "MachineSH4",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:THUMB",
+ "comment": "MachineTHUMB",
+ "value": "MachineTHUMB",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X64",
+ "comment": "MachineX64",
+ "value": "MachineX64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X86",
+ "comment": "MachineX86",
+ "value": "MachineX86",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:MTA",
+ "comment": "MTA threading attribute",
+ "value": "MTAThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:STA",
+ "comment": "STA threading attribute",
+ "value": "STAThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:NONE",
+ "comment": "Default threading attribute",
+ "value": "DefaultThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:IJW",
+ "comment": "Force IJW image",
+ "value": "ForceIJWImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:PURE",
+ "comment": "Force Pure IL Image",
+ "value": "ForcePureILImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:SAFE",
+ "comment": "Force Safe IL Image",
+ "value": "ForceSafeILImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "",
+ "comment": "Default image type",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA1",
+ "comment": "SHA1",
+ "value": "SHA1",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA256",
+ "comment": "SHA256",
+ "value": "SHA256",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA384",
+ "comment": "SHA384",
+ "value": "SHA384",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA512",
+ "comment": "SHA512",
+ "value": "SHA512",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:PROMPT",
+ "comment": "PromptImmediately",
+ "value": "PromptImmediately",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:QUEUE",
+ "comment": "Queue For Next Login",
+ "value": "QueueForNextLogin",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:SEND",
+ "comment": "Send Error Report",
+ "value": "SendErrorReport",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:NONE",
+ "comment": "No Error Report",
+ "value": "NoErrorReport",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError:NO",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError:SYSTEMDLL",
+ "comment": "System Dlls Only",
+ "value": "SystemDlls",
+ "flags": []
+ },
+ {
+ "name": "LinkIncremental",
+ "switch": "INCREMENTAL:NO",
+ "comment": "Enable Incremental Linking",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkIncremental",
+ "switch": "INCREMENTAL",
+ "comment": "Enable Incremental Linking",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "NOLOGO",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkStatus",
+ "switch": "LTCG:NOSTATUS",
+ "comment": "Link Status",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkStatus",
+ "switch": "LTCG:STATUS",
+ "comment": "Link Status",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreventDllBinding",
+ "switch": "ALLOWBIND:NO",
+ "comment": "Prevent Dll Binding",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "PreventDllBinding",
+ "switch": "ALLOWBIND",
+ "comment": "Prevent Dll Binding",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatLinkerWarningAsErrors",
+ "switch": "WX:NO",
+ "comment": "Treat Linker Warning As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatLinkerWarningAsErrors",
+ "switch": "WX",
+ "comment": "Treat Linker Warning As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreAllDefaultLibraries",
+ "switch": "NODEFAULTLIB",
+ "comment": "Ignore All Default Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateManifest",
+ "switch": "MANIFEST:NO",
+ "comment": "Generate Manifest",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "GenerateManifest",
+ "switch": "MANIFEST",
+ "comment": "Generate Manifest",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowIsolation",
+ "switch": "ALLOWISOLATION:NO",
+ "comment": "Allow Isolation",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AllowIsolation",
+ "switch": "",
+ "comment": "Allow Isolation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableUAC",
+ "switch": "MANIFESTUAC:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired",
+ "SpaceAppendable"
+ ]
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='false'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "false",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='false'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='true'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ManifestEmbed",
+ "switch": "manifest:embed",
+ "comment": "Embed Manifest",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG",
+ "comment": "Generate Debug Info",
+ "value": "true",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "GenerateMapFile",
+ "switch": "MAP",
+ "comment": "Generate Map File",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "MapExports",
+ "switch": "MAPINFO:EXPORTS",
+ "comment": "Map Exports",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AssemblyDebug",
+ "switch": "ASSEMBLYDEBUG:DISABLE",
+ "comment": "Debuggable Assembly",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AssemblyDebug",
+ "switch": "ASSEMBLYDEBUG",
+ "comment": "Debuggable Assembly",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LargeAddressAware",
+ "switch": "LARGEADDRESSAWARE:NO",
+ "comment": "Enable Large Addresses",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LargeAddressAware",
+ "switch": "LARGEADDRESSAWARE",
+ "comment": "Enable Large Addresses",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TerminalServerAware",
+ "switch": "TSAWARE:NO",
+ "comment": "Terminal Server",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TerminalServerAware",
+ "switch": "TSAWARE",
+ "comment": "Terminal Server",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SwapRunFromCD",
+ "switch": "SWAPRUN:CD",
+ "comment": "Swap Run From CD",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SwapRunFromNET",
+ "switch": "SWAPRUN:NET",
+ "comment": "Swap Run From Network",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OptimizeReferences",
+ "switch": "OPT:NOREF",
+ "comment": "References",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OptimizeReferences",
+ "switch": "OPT:REF",
+ "comment": "References",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableCOMDATFolding",
+ "switch": "OPT:NOICF",
+ "comment": "Enable COMDAT Folding",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableCOMDATFolding",
+ "switch": "OPT:ICF",
+ "comment": "Enable COMDAT Folding",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreEmbeddedIDL",
+ "switch": "IGNOREIDL",
+ "comment": "Ignore Embedded IDL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AppContainer",
+ "switch": "APPCONTAINER",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataLinkDelaySign",
+ "switch": "WINMDDELAYSIGN:NO",
+ "comment": "Windows Metadata Delay Sign",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataLinkDelaySign",
+ "switch": "WINMDDELAYSIGN",
+ "comment": "Windows Metadata Delay Sign",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NoEntryPoint",
+ "switch": "NOENTRY",
+ "comment": "No Entry Point",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SetChecksum",
+ "switch": "RELEASE",
+ "comment": "Set Checksum",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RandomizedBaseAddress",
+ "switch": "DYNAMICBASE:NO",
+ "comment": "Randomized Base Address",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RandomizedBaseAddress",
+ "switch": "DYNAMICBASE",
+ "comment": "Randomized Base Address",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FixedBaseAddress",
+ "switch": "FIXED:NO",
+ "comment": "Fixed Base Address",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FixedBaseAddress",
+ "switch": "FIXED",
+ "comment": "Fixed Base Address",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DataExecutionPrevention",
+ "switch": "NXCOMPAT:NO",
+ "comment": "Data Execution Prevention (DEP)",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DataExecutionPrevention",
+ "switch": "NXCOMPAT",
+ "comment": "Data Execution Prevention (DEP)",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TurnOffAssemblyGeneration",
+ "switch": "NOASSEMBLY",
+ "comment": "Turn Off Assembly Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SupportUnloadOfDelayLoadedDLL",
+ "switch": "DELAY:UNLOAD",
+ "comment": "Unload delay loaded DLL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SupportNobindOfDelayLoadedDLL",
+ "switch": "DELAY:NOBIND",
+ "comment": "Nobind delay loaded DLL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Profile",
+ "switch": "PROFILE",
+ "comment": "Profile",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkDelaySign",
+ "switch": "DELAYSIGN:NO",
+ "comment": "Delay Sign",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkDelaySign",
+ "switch": "DELAYSIGN",
+ "comment": "Delay Sign",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CLRUnmanagedCodeCheck",
+ "switch": "CLRUNMANAGEDCODECHECK:NO",
+ "comment": "CLR Unmanaged Code Check",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CLRUnmanagedCodeCheck",
+ "switch": "CLRUNMANAGEDCODECHECK",
+ "comment": "CLR Unmanaged Code Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DetectOneDefinitionRule",
+ "switch": "ODR",
+ "comment": "Detect One Definition Rule violations",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ImageHasSafeExceptionHandlers",
+ "switch": "SAFESEH:NO",
+ "comment": "Image Has Safe Exception Handlers",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "ImageHasSafeExceptionHandlers",
+ "switch": "SAFESEH",
+ "comment": "Image Has Safe Exception Handlers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkDLL",
+ "switch": "DLL",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibraryDirectories",
+ "switch": "LIBPATH:",
+ "comment": "Additional Library Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IgnoreSpecificDefaultLibraries",
+ "switch": "NODEFAULTLIB:",
+ "comment": "Ignore Specific Default Libraries",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AddModuleNamesToAssembly",
+ "switch": "ASSEMBLYMODULE:",
+ "comment": "Add Module to Assembly",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "EmbedManagedResourceFile",
+ "switch": "ASSEMBLYRESOURCE:",
+ "comment": "Embed Managed Resource File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForceSymbolReferences",
+ "switch": "INCLUDE:",
+ "comment": "Force Symbol References",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "DelayLoadDLLs",
+ "switch": "DELAYLOAD:",
+ "comment": "Delay Loaded Dlls",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AssemblyLinkResource",
+ "switch": "ASSEMBLYLINKRESOURCE:",
+ "comment": "Assembly Link Resource",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalManifestDependencies",
+ "switch": "MANIFESTDEPENDENCY:",
+ "comment": "Additional Manifest Dependencies",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ManifestInput",
+ "switch": "manifestinput:",
+ "comment": "Manifest Input",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "OutputFile",
+ "switch": "OUT:",
+ "comment": "Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "Version",
+ "switch": "VERSION:",
+ "comment": "Version",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "SpecifySectionAttributes",
+ "switch": "SECTION:",
+ "comment": "Specify Section Attributes",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MSDOSStubFileName",
+ "switch": "STUB:",
+ "comment": "MS-DOS Stub File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ModuleDefinitionFile",
+ "switch": "DEF:",
+ "comment": "Module Definition File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ManifestFile",
+ "switch": "ManifestFile:",
+ "comment": "Manifest File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProgramDatabaseFile",
+ "switch": "PDB:",
+ "comment": "Generate Program Database File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "StripPrivateSymbols",
+ "switch": "PDBSTRIPPED:",
+ "comment": "Strip Private Symbols",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MapFileName",
+ "switch": "MAP:",
+ "comment": "Map File Name",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "HeapReserveSize",
+ "switch": "HEAP:",
+ "comment": "Heap Reserve Size",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "HeapCommitSize",
+ "switch": "HEAP",
+ "comment": "Heap Commit Size",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "StackReserveSize",
+ "switch": "STACK:",
+ "comment": "Stack Reserve Size",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "StackCommitSize",
+ "switch": "STACK",
+ "comment": "Stack Commit Size",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "FunctionOrder",
+ "switch": "ORDER:@",
+ "comment": "Function Order",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProfileGuidedDatabase",
+ "switch": "PGD:",
+ "comment": "Profile Guided Database",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MidlCommandFile",
+ "switch": "MIDL:@",
+ "comment": "MIDL Commands",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MergedIDLBaseFileName",
+ "switch": "IDLOUT:",
+ "comment": "Merged IDL Base File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "TypeLibraryFile",
+ "switch": "TLBOUT:",
+ "comment": "Type Library",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataFile",
+ "switch": "WINMDFILE:",
+ "comment": "Windows Metadata File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataLinkKeyFile",
+ "switch": "WINMDKEYFILE:",
+ "comment": "Windows Metadata Key File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataKeyContainer",
+ "switch": "WINMDKEYCONTAINER:",
+ "comment": "Windows Metadata Key Container",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "EntryPointSymbol",
+ "switch": "ENTRY:",
+ "comment": "Entry Point",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "BaseAddress",
+ "switch": "BASE:",
+ "comment": "Base Address",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ImportLibrary",
+ "switch": "IMPLIB:",
+ "comment": "Import Library",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MergeSections",
+ "switch": "MERGE:",
+ "comment": "Merge Sections",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "LinkKeyFile",
+ "switch": "KEYFILE:",
+ "comment": "Key File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "KeyContainer",
+ "switch": "KEYCONTAINER:",
+ "comment": "Key Container",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "TypeLibraryResourceID",
+ "switch": "TLBID:",
+ "comment": "TypeLib Resource ID",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "SectionAlignment",
+ "switch": "ALIGN:",
+ "comment": "SectionAlignment",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v12_MASM.json b/Templates/MSBuild/FlagTables/v12_MASM.json
new file mode 100644
index 000000000..4634306b1
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v12_MASM.json
@@ -0,0 +1,295 @@
+[
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "",
+ "comment": "Default",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "Cp",
+ "comment": "Preserves Identifier Case (/Cp)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "Cu",
+ "comment": "Maps all identifiers to upper case. (/Cu)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "Cx",
+ "comment": "Preserves case in public and extern symbols. (/Cx)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W0",
+ "comment": "Warning Level 0 (/W0)",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W1",
+ "comment": "Warning Level 1 (/W1)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W2",
+ "comment": "Warning Level 2 (/W2)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W3",
+ "comment": "Warning Level 3 (/W3)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "",
+ "comment": "Default",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp1",
+ "comment": "One Byte Boundary (/Zp1)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp2",
+ "comment": "Two Byte Boundary (/Zp2)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp4",
+ "comment": "Four Byte Boundary (/Zp4)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp8",
+ "comment": "Eight Byte Boundary (/Zp8)",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp16",
+ "comment": "Sixteen Byte Boundary (/Zp16)",
+ "value": "5",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "",
+ "comment": "Default",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gd",
+ "comment": "Use C-style Calling Convention (/Gd)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gz",
+ "comment": "Use stdcall Calling Convention (/Gz)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gc",
+ "comment": "Use Pascal Calling Convention (/Gc)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:prompt",
+ "comment": "Prompt to send report immediately (/errorReport:prompt)",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:queue",
+ "comment": "Prompt to send report at the next logon (/errorReport:queue)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:send",
+ "comment": "Automatically send report (/errorReport:send)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:none",
+ "comment": "Do not send report (/errorReport:none)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "NoLogo",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GeneratePreprocessedSourceListing",
+ "switch": "EP",
+ "comment": "Generate Preprocessed Source Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ListAllAvailableInformation",
+ "switch": "Sa",
+ "comment": "List All Available Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseSafeExceptionHandlers",
+ "switch": "safeseh",
+ "comment": "Use Safe Exception Handlers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AddFirstPassListing",
+ "switch": "Sf",
+ "comment": "Add First Pass Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableAssemblyGeneratedCodeListing",
+ "switch": "Sg",
+ "comment": "Enable Assembly Generated Code Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DisableSymbolTable",
+ "switch": "Sn",
+ "comment": "Disable Symbol Table",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableFalseConditionalsInListing",
+ "switch": "Sx",
+ "comment": "Enable False Conditionals In Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "WX",
+ "comment": "Treat Warnings As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MakeAllSymbolsPublic",
+ "switch": "Zf",
+ "comment": "Make All Symbols Public",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "Zi",
+ "comment": "Generate Debug Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableMASM51Compatibility",
+ "switch": "Zm",
+ "comment": "Enable MASM 5.1 Compatibility",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PerformSyntaxCheckOnly",
+ "switch": "Zs",
+ "comment": "Perform Syntax Check Only",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IncludePaths",
+ "switch": "I",
+ "comment": "Include Paths",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "BrowseFile",
+ "switch": "FR",
+ "comment": "Generate Browse Information File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ObjectFileName",
+ "switch": "Fo",
+ "comment": "Object File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "AssembledCodeListingFile",
+ "switch": "Fl",
+ "comment": "Assembled Code Listing File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v12_RC.json b/Templates/MSBuild/FlagTables/v12_RC.json
new file mode 100644
index 000000000..b8c0127d1
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v12_RC.json
@@ -0,0 +1,69 @@
+[
+ {
+ "name": "IgnoreStandardIncludePath",
+ "switch": "X",
+ "comment": "Ignore Standard Include Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "v",
+ "comment": "Show Progress",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NullTerminateStrings",
+ "switch": "n",
+ "comment": "Null Terminate Strings",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "UndefinePreprocessorDefinitions",
+ "switch": "u",
+ "comment": "Undefine Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalIncludeDirectories",
+ "switch": "I",
+ "comment": "Additional Include Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ResourceOutputFileName",
+ "switch": "fo",
+ "comment": "Resource File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v140_CL.json b/Templates/MSBuild/FlagTables/v140_CL.json
new file mode 100644
index 000000000..3dc9f353d
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v140_CL.json
@@ -0,0 +1,1184 @@
+[
+ {
+ "name": "DebugInformationFormat",
+ "switch": "",
+ "comment": "None",
+ "value": "None",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "Z7",
+ "comment": "C7 compatible",
+ "value": "OldStyle",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "Zi",
+ "comment": "Program Database",
+ "value": "ProgramDatabase",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "ZI",
+ "comment": "Program Database for Edit And Continue",
+ "value": "EditAndContinue",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "",
+ "comment": "No Common Language RunTime Support",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr",
+ "comment": "Common Language RunTime Support",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:pure",
+ "comment": "Pure MSIL Common Language RunTime Support",
+ "value": "Pure",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:safe",
+ "comment": "Safe MSIL Common Language RunTime Support",
+ "value": "Safe",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W0",
+ "comment": "Turn Off All Warnings",
+ "value": "TurnOffAllWarnings",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W1",
+ "comment": "Level1",
+ "value": "Level1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W2",
+ "comment": "Level2",
+ "value": "Level2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W3",
+ "comment": "Level3",
+ "value": "Level3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W4",
+ "comment": "Level4",
+ "value": "Level4",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "Wall",
+ "comment": "EnableAllWarnings",
+ "value": "EnableAllWarnings",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "",
+ "comment": "Custom",
+ "value": "Custom",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "Od",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O1",
+ "comment": "Minimize Size",
+ "value": "MinSpace",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O2",
+ "comment": "Maximize Speed",
+ "value": "MaxSpeed",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "Ox",
+ "comment": "Full Optimization",
+ "value": "Full",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob0",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob1",
+ "comment": "Only __inline",
+ "value": "OnlyExplicitInline",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob2",
+ "comment": "Any Suitable",
+ "value": "AnySuitable",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "Os",
+ "comment": "Favor small code",
+ "value": "Size",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "Ot",
+ "comment": "Favor fast code",
+ "value": "Speed",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "",
+ "comment": "Neither",
+ "value": "Neither",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHa",
+ "comment": "Yes with SEH Exceptions",
+ "value": "Async",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHsc",
+ "comment": "Yes",
+ "value": "Sync",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHs",
+ "comment": "Yes with Extern C functions",
+ "value": "SyncCThrow",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTCs",
+ "comment": "Stack Frames",
+ "value": "StackFrameRuntimeCheck",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTCu",
+ "comment": "Uninitialized variables",
+ "value": "UninitializedLocalUsageCheck",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTC1",
+ "comment": "Both (/RTC1, equiv. to /RTCsu)",
+ "value": "EnableFastChecks",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MT",
+ "comment": "Multi-threaded",
+ "value": "MultiThreaded",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MTd",
+ "comment": "Multi-threaded Debug",
+ "value": "MultiThreadedDebug",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MD",
+ "comment": "Multi-threaded DLL",
+ "value": "MultiThreadedDLL",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MDd",
+ "comment": "Multi-threaded Debug DLL",
+ "value": "MultiThreadedDebugDLL",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp1",
+ "comment": "1 Byte",
+ "value": "1Byte",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp2",
+ "comment": "2 Bytes",
+ "value": "2Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp4",
+ "comment": "4 Byte",
+ "value": "4Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp8",
+ "comment": "8 Bytes",
+ "value": "8Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp16",
+ "comment": "16 Bytes",
+ "value": "16Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "BufferSecurityCheck",
+ "switch": "GS-",
+ "comment": "Disable Security Check",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "BufferSecurityCheck",
+ "switch": "GS",
+ "comment": "Enable Security Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ControlFlowGuard",
+ "switch": "guard:cf",
+ "comment": "Yes",
+ "value": "Guard",
+ "flags": []
+ },
+ {
+ "name": "ControlFlowGuard",
+ "switch": "",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:SSE",
+ "comment": "Streaming SIMD Extensions",
+ "value": "StreamingSIMDExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:SSE2",
+ "comment": "Streaming SIMD Extensions 2",
+ "value": "StreamingSIMDExtensions2",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:AVX",
+ "comment": "Advanced Vector Extensions",
+ "value": "AdvancedVectorExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:AVX2",
+ "comment": "Advanced Vector Extensions 2",
+ "value": "AdvancedVectorExtensions2",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:IA32",
+ "comment": "No Enhanced Instructions",
+ "value": "NoExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:precise",
+ "comment": "Precise",
+ "value": "Precise",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:strict",
+ "comment": "Strict",
+ "value": "Strict",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:fast",
+ "comment": "Fast",
+ "value": "Fast",
+ "flags": []
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Yc",
+ "comment": "Create",
+ "value": "Create",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Yu",
+ "comment": "Use",
+ "value": "Use",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Y-",
+ "comment": "Not Using Precompiled Headers",
+ "value": "NotUsing",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "",
+ "comment": "No Listing",
+ "value": "NoListing",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FA",
+ "comment": "Assembly-Only Listing",
+ "value": "AssemblyCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAc",
+ "comment": "Assembly With Machine Code",
+ "value": "AssemblyAndMachineCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAs",
+ "comment": "Assembly With Source Code",
+ "value": "AssemblyAndSourceCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAcs",
+ "comment": "Assembly, Machine Code and Source",
+ "value": "All",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gd",
+ "comment": "__cdecl",
+ "value": "Cdecl",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gr",
+ "comment": "__fastcall",
+ "value": "FastCall",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gz",
+ "comment": "__stdcall",
+ "value": "StdCall",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gv",
+ "comment": "__vectorcall",
+ "value": "VectorCall",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "TC",
+ "comment": "Compile as C Code",
+ "value": "CompileAsC",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "TP",
+ "comment": "Compile as C++ Code",
+ "value": "CompileAsCpp",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:none",
+ "comment": "Do Not Send Report",
+ "value": "None",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:prompt",
+ "comment": "Prompt Immediately",
+ "value": "Prompt",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:queue",
+ "comment": "Queue For Next Login",
+ "value": "Queue",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:send",
+ "comment": "Send Automatically",
+ "value": "Send",
+ "flags": []
+ },
+ {
+ "name": "CompileAsWinRT",
+ "switch": "ZW",
+ "comment": "Consume Windows Runtime Extension",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WinRTNoStdLib",
+ "switch": "ZW:nostdlib",
+ "comment": "No Standard WinRT Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningAsError",
+ "switch": "WX-",
+ "comment": "Treat Warnings As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningAsError",
+ "switch": "WX",
+ "comment": "Treat Warnings As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SDLCheck",
+ "switch": "sdl-",
+ "comment": "SDL checks",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "SDLCheck",
+ "switch": "sdl",
+ "comment": "SDL checks",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MultiProcessorCompilation",
+ "switch": "MP",
+ "comment": "Multi-processor Compilation",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "IntrinsicFunctions",
+ "switch": "Oi",
+ "comment": "Enable Intrinsic Functions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OmitFramePointers",
+ "switch": "Oy-",
+ "comment": "Omit Frame Pointers",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OmitFramePointers",
+ "switch": "Oy",
+ "comment": "Omit Frame Pointers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableFiberSafeOptimizations",
+ "switch": "GT",
+ "comment": "Enable Fiber-Safe Optimizations",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WholeProgramOptimization",
+ "switch": "GL",
+ "comment": "Whole Program Optimization",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UndefineAllPreprocessorDefinitions",
+ "switch": "u",
+ "comment": "Undefine All Preprocessor Definitions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreStandardIncludePath",
+ "switch": "X",
+ "comment": "Ignore Standard Include Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessToFile",
+ "switch": "P",
+ "comment": "Preprocess to a File",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessSuppressLineNumbers",
+ "switch": "EP",
+ "comment": "Preprocess Suppress Line Numbers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessKeepComments",
+ "switch": "C",
+ "comment": "Keep Comments",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "StringPooling",
+ "switch": "GF-",
+ "comment": "Enable String Pooling",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "StringPooling",
+ "switch": "GF",
+ "comment": "Enable String Pooling",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MinimalRebuild",
+ "switch": "Gm-",
+ "comment": "Enable Minimal Rebuild",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "MinimalRebuild",
+ "switch": "Gm",
+ "comment": "Enable Minimal Rebuild",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SmallerTypeCheck",
+ "switch": "RTCc",
+ "comment": "Smaller Type Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FunctionLevelLinking",
+ "switch": "Gy-",
+ "comment": "Enable Function-Level Linking",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FunctionLevelLinking",
+ "switch": "Gy",
+ "comment": "Enable Function-Level Linking",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableParallelCodeGeneration",
+ "switch": "Qpar-",
+ "comment": "Enable Parallel Code Generation",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableParallelCodeGeneration",
+ "switch": "Qpar",
+ "comment": "Enable Parallel Code Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointExceptions",
+ "switch": "fp:except-",
+ "comment": "Enable Floating Point Exceptions",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointExceptions",
+ "switch": "fp:except",
+ "comment": "Enable Floating Point Exceptions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CreateHotpatchableImage",
+ "switch": "hotpatch",
+ "comment": "Create Hotpatchable Image",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DisableLanguageExtensions",
+ "switch": "Za",
+ "comment": "Disable Language Extensions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWChar_tAsBuiltInType",
+ "switch": "Zc:wchar_t-",
+ "comment": "Treat WChar_t As Built in Type",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWChar_tAsBuiltInType",
+ "switch": "Zc:wchar_t",
+ "comment": "Treat WChar_t As Built in Type",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ForceConformanceInForLoopScope",
+ "switch": "Zc:forScope-",
+ "comment": "Force Conformance in For Loop Scope",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "ForceConformanceInForLoopScope",
+ "switch": "Zc:forScope",
+ "comment": "Force Conformance in For Loop Scope",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RemoveUnreferencedCodeData",
+ "switch": "Zc:inline-",
+ "comment": "Remove unreferenced code and data",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RemoveUnreferencedCodeData",
+ "switch": "Zc:inline",
+ "comment": "Remove unreferenced code and data",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnforceTypeConversionRules",
+ "switch": "Zc:rvalueCast-",
+ "comment": "Enforce type conversion rules",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnforceTypeConversionRules",
+ "switch": "Zc:rvalueCast",
+ "comment": "Enforce type conversion rules",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RuntimeTypeInfo",
+ "switch": "GR-",
+ "comment": "Enable Run-Time Type Information",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RuntimeTypeInfo",
+ "switch": "GR",
+ "comment": "Enable Run-Time Type Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OpenMPSupport",
+ "switch": "openmp-",
+ "comment": "Open MP Support",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OpenMPSupport",
+ "switch": "openmp",
+ "comment": "Open MP Support",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ExpandAttributedSource",
+ "switch": "Fx",
+ "comment": "Expand Attributed Source",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseUnicodeForAssemblerListing",
+ "switch": "FAu",
+ "comment": "Use Unicode For Assembler Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateXMLDocumentationFiles",
+ "switch": "doc",
+ "comment": "Generate XML Documentation Files",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "BrowseInformation",
+ "switch": "FR",
+ "comment": "Enable Browse Information",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "ShowIncludes",
+ "switch": "showIncludes",
+ "comment": "Show Includes",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnablePREfast",
+ "switch": "analyze-",
+ "comment": "Enable Code Analysis",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnablePREfast",
+ "switch": "analyze",
+ "comment": "Enable Code Analysis",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseFullPaths",
+ "switch": "FC",
+ "comment": "Use Full Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OmitDefaultLibName",
+ "switch": "Zl",
+ "comment": "Omit Default Library Name",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalIncludeDirectories",
+ "switch": "I",
+ "comment": "Additional Include Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalUsingDirectories",
+ "switch": "AI",
+ "comment": "Additional #using Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "UndefinePreprocessorDefinitions",
+ "switch": "U",
+ "comment": "Undefine Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "DisableSpecificWarnings",
+ "switch": "wd",
+ "comment": "Disable Specific Warnings",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForcedIncludeFiles",
+ "switch": "FI",
+ "comment": "Forced Include File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForcedUsingFiles",
+ "switch": "FU",
+ "comment": "Forced #using File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PREfastLog",
+ "switch": "analyze:log",
+ "comment": "Code Analysis Log",
+ "value": "",
+ "flags": [
+ "UserFollowing"
+ ]
+ },
+ {
+ "name": "PREfastAdditionalPlugins",
+ "switch": "analyze:plugin",
+ "comment": "Additional Code Analysis Native plugins",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "TreatSpecificWarningsAsErrors",
+ "switch": "we",
+ "comment": "Treat Specific Warnings As Errors",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "WarningVersion",
+ "switch": "Wv:",
+ "comment": "Warning Version",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "PreprocessOutputPath",
+ "switch": "Fi",
+ "comment": "Preprocess Output Path",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderFile",
+ "switch": "Yu",
+ "comment": "Precompiled Header File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderFile",
+ "switch": "Yc",
+ "comment": "Precompiled Header File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderOutputFile",
+ "switch": "Fp",
+ "comment": "Precompiled Header Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "AssemblerListingLocation",
+ "switch": "Fa",
+ "comment": "ASM List Location",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ObjectFileName",
+ "switch": "Fo",
+ "comment": "Object File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProgramDataBaseFileName",
+ "switch": "Fd",
+ "comment": "Program Database File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "XMLDocumentationFileName",
+ "switch": "doc",
+ "comment": "XML Documentation File Name",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "BrowseInformationFile",
+ "switch": "FR",
+ "comment": "Browse Information File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ProcessorNumber",
+ "switch": "MP",
+ "comment": "Number of processors",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=c++98",
+ "comment": "C++03",
+ "value": "c++98",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=c++11",
+ "comment": "C++11",
+ "value": "c++11",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=c++1y",
+ "comment": "C++14",
+ "value": "c++1y",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=c++14",
+ "comment": "C++14",
+ "value": "c++1y",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=gnu++98",
+ "comment": "C++03 (GNU Dialect)",
+ "value": "gnu++98",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=gnu++11",
+ "comment": "C++11 (GNU Dialect)",
+ "value": "gnu++11",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=gnu++1y",
+ "comment": "C++14 (GNU Dialect)",
+ "value": "gnu++1y",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=gnu++14",
+ "comment": "C++14 (GNU Dialect)",
+ "value": "gnu++1y",
+ "flags": []
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v140_CSharp.json b/Templates/MSBuild/FlagTables/v140_CSharp.json
new file mode 100644
index 000000000..5989aea1e
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v140_CSharp.json
@@ -0,0 +1,574 @@
+[
+ {
+ "name": "ProjectName",
+ "switch": "out:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:exe",
+ "comment": "",
+ "value": "Exe",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:winexe",
+ "comment": "",
+ "value": "Winexe",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:library",
+ "comment": "",
+ "value": "Library",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:module",
+ "comment": "",
+ "value": "Module",
+ "flags": []
+ },
+ {
+ "name": "DocumentationFile",
+ "switch": "doc",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:x86",
+ "comment": "",
+ "value": "x86",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:Itanium",
+ "comment": "",
+ "value": "Itanium",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:x64",
+ "comment": "",
+ "value": "x64",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:arm",
+ "comment": "",
+ "value": "arm",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:anycpu32bitpreferred",
+ "comment": "",
+ "value": "anycpu32bitpreferred",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:anycpu",
+ "comment": "",
+ "value": "anycpu",
+ "flags": []
+ },
+ {
+ "name": "References",
+ "switch": "reference:",
+ "comment": "mit alias",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "References",
+ "switch": "reference:",
+ "comment": "dateiliste",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "AddModules",
+ "switch": "addmodule:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "Win32Resource",
+ "switch": "win32res:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ApplicationIcon",
+ "switch": "win32icon:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ApplicationManifest",
+ "switch": "win32manifest:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "NoWin32Manifest",
+ "switch": "nowin32manifest",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DefineDebug",
+ "switch": "debug",
+ "comment": "",
+ "value": "true",
+ "flags": [
+ "Continue"
+ ]
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:none",
+ "comment": "",
+ "value": "none",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:full",
+ "comment": "",
+ "value": "full",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:pdbonly",
+ "comment": "",
+ "value": "pdbonly",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror-",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror+",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:0",
+ "comment": "",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:1",
+ "comment": "",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:2",
+ "comment": "",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:3",
+ "comment": "",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:4",
+ "comment": "",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "NoWarn",
+ "switch": "nowarn:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired",
+ "CommaAppendable"
+ ]
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DefineConstants",
+ "switch": "define:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "SemicolonAppendable",
+ "UserValue"
+ ]
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:ISO-1",
+ "comment": "",
+ "value": "ISO-1",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:ISO-2",
+ "comment": "",
+ "value": "ISO-2",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:3",
+ "comment": "",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:4",
+ "comment": "",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:5",
+ "comment": "",
+ "value": "5",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:6",
+ "comment": "",
+ "value": "6",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:default",
+ "comment": "",
+ "value": "default",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AssemblyOriginatorKeyFile",
+ "switch": "keyfile",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "KeyContainerName",
+ "switch": "keycontainer",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoLogo",
+ "switch": "nologo",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoConfig",
+ "switch": "noconfig",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "BaseAddress",
+ "switch": "baseaddress:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "CodePage",
+ "switch": "codepage",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "Utf8Output",
+ "switch": "utf8output",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "MainEntryPoint",
+ "switch": "main:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "GenerateFullPaths",
+ "switch": "fullpaths",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FileAlignment",
+ "switch": "filealign",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "PdbFile",
+ "switch": "pdb:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SubsystemVersion",
+ "switch": "subsystemversion",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibPaths",
+ "switch": "lib:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:none",
+ "comment": "Do Not Send Report",
+ "value": "none",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:prompt",
+ "comment": "Prompt Immediately",
+ "value": "prompt",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:queue",
+ "comment": "Queue For Next Login",
+ "value": "queue",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:send",
+ "comment": "Send Automatically",
+ "value": "send",
+ "flags": []
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v140_Link.json b/Templates/MSBuild/FlagTables/v140_Link.json
new file mode 100644
index 000000000..3fb072c50
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v140_Link.json
@@ -0,0 +1,1316 @@
+[
+ {
+ "name": "ShowProgress",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE",
+ "comment": "Display all progress messages",
+ "value": "LinkVerbose",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:Lib",
+ "comment": "For Libraries Searched",
+ "value": "LinkVerboseLib",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:ICF",
+ "comment": "About COMDAT folding during optimized linking",
+ "value": "LinkVerboseICF",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:REF",
+ "comment": "About data removed during optimized linking",
+ "value": "LinkVerboseREF",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:SAFESEH",
+ "comment": "About Modules incompatible with SEH",
+ "value": "LinkVerboseSAFESEH",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:CLR",
+ "comment": "About linker activity related to managed code",
+ "value": "LinkVerboseCLR",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE:MULTIPLE",
+ "comment": "Multiply Defined Symbol Only",
+ "value": "MultiplyDefinedSymbolOnly",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE:UNRESOLVED",
+ "comment": "Undefined Symbol Only",
+ "value": "UndefinedSymbolOnly",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:5",
+ "comment": "X86 Image Only",
+ "value": "X86Image",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:6",
+ "comment": "X64 Image Only",
+ "value": "X64Image",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:16",
+ "comment": "Itanium Image Only",
+ "value": "ItaniumImage",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='asInvoker'",
+ "comment": "asInvoker",
+ "value": "AsInvoker",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='highestAvailable'",
+ "comment": "highestAvailable",
+ "value": "HighestAvailable",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='requireAdministrator'",
+ "comment": "requireAdministrator",
+ "value": "RequireAdministrator",
+ "flags": []
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG",
+ "comment": "Optimize for debugging",
+ "value": "true",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG:FASTLINK",
+ "comment": "Optimize for faster linking",
+ "value": "DebugFastLink",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG:FULL",
+ "comment": "Optimize for debugging",
+ "value": "true",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG:NONE",
+ "comment": "Produces no debugging information",
+ "value": "false",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "SubSystem",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:CONSOLE",
+ "comment": "Console",
+ "value": "Console",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWS",
+ "comment": "Windows",
+ "value": "Windows",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:NATIVE",
+ "comment": "Native",
+ "value": "Native",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_APPLICATION",
+ "comment": "EFI Application",
+ "value": "EFI Application",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+ "comment": "EFI Boot Service Driver",
+ "value": "EFI Boot Service Driver",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_ROM",
+ "comment": "EFI ROM",
+ "value": "EFI ROM",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_RUNTIME_DRIVER",
+ "comment": "EFI Runtime",
+ "value": "EFI Runtime",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:POSIX",
+ "comment": "POSIX",
+ "value": "POSIX",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "Driver",
+ "comment": "Driver",
+ "value": "Driver",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "DRIVER:UPONLY",
+ "comment": "UP Only",
+ "value": "UpOnly",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "DRIVER:WDM",
+ "comment": "WDM",
+ "value": "WDM",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:incremental",
+ "comment": "Use Fast Link Time Code Generation",
+ "value": "UseFastLinkTimeCodeGeneration",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG",
+ "comment": "Use Link Time Code Generation",
+ "value": "UseLinkTimeCodeGeneration",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGInstrument",
+ "comment": "Profile Guided Optimization - Instrument",
+ "value": "PGInstrument",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGOptimize",
+ "comment": "Profile Guided Optimization - Optimization",
+ "value": "PGOptimization",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGUpdate",
+ "comment": "Profile Guided Optimization - Update",
+ "value": "PGUpdate",
+ "flags": []
+ },
+ {
+ "name": "GenerateWindowsMetadata",
+ "switch": "WINMD",
+ "comment": "Yes",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateWindowsMetadata",
+ "switch": "WINMD:NO",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA1",
+ "comment": "SHA1",
+ "value": "SHA1",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA256",
+ "comment": "SHA256",
+ "value": "SHA256",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA384",
+ "comment": "SHA384",
+ "value": "SHA384",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA512",
+ "comment": "SHA512",
+ "value": "SHA512",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:ARM",
+ "comment": "MachineARM",
+ "value": "MachineARM",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:EBC",
+ "comment": "MachineEBC",
+ "value": "MachineEBC",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:IA64",
+ "comment": "MachineIA64",
+ "value": "MachineIA64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS",
+ "comment": "MachineMIPS",
+ "value": "MachineMIPS",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS16",
+ "comment": "MachineMIPS16",
+ "value": "MachineMIPS16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU",
+ "comment": "MachineMIPSFPU",
+ "value": "MachineMIPSFPU",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU16",
+ "comment": "MachineMIPSFPU16",
+ "value": "MachineMIPSFPU16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:SH4",
+ "comment": "MachineSH4",
+ "value": "MachineSH4",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:THUMB",
+ "comment": "MachineTHUMB",
+ "value": "MachineTHUMB",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X64",
+ "comment": "MachineX64",
+ "value": "MachineX64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X86",
+ "comment": "MachineX86",
+ "value": "MachineX86",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:MTA",
+ "comment": "MTA threading attribute",
+ "value": "MTAThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:STA",
+ "comment": "STA threading attribute",
+ "value": "STAThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:NONE",
+ "comment": "Default threading attribute",
+ "value": "DefaultThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:IJW",
+ "comment": "Force IJW image",
+ "value": "ForceIJWImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:PURE",
+ "comment": "Force Pure IL Image",
+ "value": "ForcePureILImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:SAFE",
+ "comment": "Force Safe IL Image",
+ "value": "ForceSafeILImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "",
+ "comment": "Default image type",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA1",
+ "comment": "SHA1",
+ "value": "SHA1",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA256",
+ "comment": "SHA256",
+ "value": "SHA256",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA384",
+ "comment": "SHA384",
+ "value": "SHA384",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA512",
+ "comment": "SHA512",
+ "value": "SHA512",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:PROMPT",
+ "comment": "PromptImmediately",
+ "value": "PromptImmediately",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:QUEUE",
+ "comment": "Queue For Next Login",
+ "value": "QueueForNextLogin",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:SEND",
+ "comment": "Send Error Report",
+ "value": "SendErrorReport",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:NONE",
+ "comment": "No Error Report",
+ "value": "NoErrorReport",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError:NO",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError:SYSTEMDLL",
+ "comment": "System Dlls Only",
+ "value": "SystemDlls",
+ "flags": []
+ },
+ {
+ "name": "LinkIncremental",
+ "switch": "INCREMENTAL:NO",
+ "comment": "Enable Incremental Linking",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkIncremental",
+ "switch": "INCREMENTAL",
+ "comment": "Enable Incremental Linking",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "NOLOGO",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkStatus",
+ "switch": "LTCG:NOSTATUS",
+ "comment": "Link Status",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkStatus",
+ "switch": "LTCG:STATUS",
+ "comment": "Link Status",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreventDllBinding",
+ "switch": "ALLOWBIND:NO",
+ "comment": "Prevent Dll Binding",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "PreventDllBinding",
+ "switch": "ALLOWBIND",
+ "comment": "Prevent Dll Binding",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatLinkerWarningAsErrors",
+ "switch": "WX:NO",
+ "comment": "Treat Linker Warning As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatLinkerWarningAsErrors",
+ "switch": "WX",
+ "comment": "Treat Linker Warning As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreAllDefaultLibraries",
+ "switch": "NODEFAULTLIB",
+ "comment": "Ignore All Default Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateManifest",
+ "switch": "MANIFEST:NO",
+ "comment": "Generate Manifest",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "GenerateManifest",
+ "switch": "MANIFEST",
+ "comment": "Generate Manifest",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowIsolation",
+ "switch": "ALLOWISOLATION:NO",
+ "comment": "Allow Isolation",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AllowIsolation",
+ "switch": "",
+ "comment": "Allow Isolation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableUAC",
+ "switch": "MANIFESTUAC:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired",
+ "SpaceAppendable"
+ ]
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='false'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "false",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='false'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='true'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ManifestEmbed",
+ "switch": "manifest:embed",
+ "comment": "Embed Manifest",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateMapFile",
+ "switch": "MAP",
+ "comment": "Generate Map File",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "MapExports",
+ "switch": "MAPINFO:EXPORTS",
+ "comment": "Map Exports",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AssemblyDebug",
+ "switch": "ASSEMBLYDEBUG:DISABLE",
+ "comment": "Debuggable Assembly",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AssemblyDebug",
+ "switch": "ASSEMBLYDEBUG",
+ "comment": "Debuggable Assembly",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LargeAddressAware",
+ "switch": "LARGEADDRESSAWARE:NO",
+ "comment": "Enable Large Addresses",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LargeAddressAware",
+ "switch": "LARGEADDRESSAWARE",
+ "comment": "Enable Large Addresses",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TerminalServerAware",
+ "switch": "TSAWARE:NO",
+ "comment": "Terminal Server",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TerminalServerAware",
+ "switch": "TSAWARE",
+ "comment": "Terminal Server",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SwapRunFromCD",
+ "switch": "SWAPRUN:CD",
+ "comment": "Swap Run From CD",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SwapRunFromNET",
+ "switch": "SWAPRUN:NET",
+ "comment": "Swap Run From Network",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OptimizeReferences",
+ "switch": "OPT:NOREF",
+ "comment": "References",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OptimizeReferences",
+ "switch": "OPT:REF",
+ "comment": "References",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableCOMDATFolding",
+ "switch": "OPT:NOICF",
+ "comment": "Enable COMDAT Folding",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableCOMDATFolding",
+ "switch": "OPT:ICF",
+ "comment": "Enable COMDAT Folding",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreEmbeddedIDL",
+ "switch": "IGNOREIDL",
+ "comment": "Ignore Embedded IDL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AppContainer",
+ "switch": "APPCONTAINER",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataLinkDelaySign",
+ "switch": "WINMDDELAYSIGN:NO",
+ "comment": "Windows Metadata Delay Sign",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataLinkDelaySign",
+ "switch": "WINMDDELAYSIGN",
+ "comment": "Windows Metadata Delay Sign",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NoEntryPoint",
+ "switch": "NOENTRY",
+ "comment": "No Entry Point",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SetChecksum",
+ "switch": "RELEASE",
+ "comment": "Set Checksum",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RandomizedBaseAddress",
+ "switch": "DYNAMICBASE:NO",
+ "comment": "Randomized Base Address",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RandomizedBaseAddress",
+ "switch": "DYNAMICBASE",
+ "comment": "Randomized Base Address",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FixedBaseAddress",
+ "switch": "FIXED:NO",
+ "comment": "Fixed Base Address",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FixedBaseAddress",
+ "switch": "FIXED",
+ "comment": "Fixed Base Address",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DataExecutionPrevention",
+ "switch": "NXCOMPAT:NO",
+ "comment": "Data Execution Prevention (DEP)",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DataExecutionPrevention",
+ "switch": "NXCOMPAT",
+ "comment": "Data Execution Prevention (DEP)",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TurnOffAssemblyGeneration",
+ "switch": "NOASSEMBLY",
+ "comment": "Turn Off Assembly Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SupportUnloadOfDelayLoadedDLL",
+ "switch": "DELAY:UNLOAD",
+ "comment": "Unload delay loaded DLL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SupportNobindOfDelayLoadedDLL",
+ "switch": "DELAY:NOBIND",
+ "comment": "Nobind delay loaded DLL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Profile",
+ "switch": "PROFILE",
+ "comment": "Profile",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkDelaySign",
+ "switch": "DELAYSIGN:NO",
+ "comment": "Delay Sign",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkDelaySign",
+ "switch": "DELAYSIGN",
+ "comment": "Delay Sign",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CLRUnmanagedCodeCheck",
+ "switch": "CLRUNMANAGEDCODECHECK:NO",
+ "comment": "CLR Unmanaged Code Check",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CLRUnmanagedCodeCheck",
+ "switch": "CLRUNMANAGEDCODECHECK",
+ "comment": "CLR Unmanaged Code Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DetectOneDefinitionRule",
+ "switch": "ODR",
+ "comment": "Detect One Definition Rule violations",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ImageHasSafeExceptionHandlers",
+ "switch": "SAFESEH:NO",
+ "comment": "Image Has Safe Exception Handlers",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "ImageHasSafeExceptionHandlers",
+ "switch": "SAFESEH",
+ "comment": "Image Has Safe Exception Handlers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkDLL",
+ "switch": "DLL",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibraryDirectories",
+ "switch": "LIBPATH:",
+ "comment": "Additional Library Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "Natvis",
+ "switch": "NATVIS:",
+ "comment": "Natvis files",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IgnoreSpecificDefaultLibraries",
+ "switch": "NODEFAULTLIB:",
+ "comment": "Ignore Specific Default Libraries",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AddModuleNamesToAssembly",
+ "switch": "ASSEMBLYMODULE:",
+ "comment": "Add Module to Assembly",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "EmbedManagedResourceFile",
+ "switch": "ASSEMBLYRESOURCE:",
+ "comment": "Embed Managed Resource File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForceSymbolReferences",
+ "switch": "INCLUDE:",
+ "comment": "Force Symbol References",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "DelayLoadDLLs",
+ "switch": "DELAYLOAD:",
+ "comment": "Delay Loaded Dlls",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AssemblyLinkResource",
+ "switch": "ASSEMBLYLINKRESOURCE:",
+ "comment": "Assembly Link Resource",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalManifestDependencies",
+ "switch": "MANIFESTDEPENDENCY:",
+ "comment": "Additional Manifest Dependencies",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ManifestInput",
+ "switch": "manifestinput:",
+ "comment": "Manifest Input",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "OutputFile",
+ "switch": "OUT:",
+ "comment": "Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "Version",
+ "switch": "VERSION:",
+ "comment": "Version",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "SpecifySectionAttributes",
+ "switch": "SECTION:",
+ "comment": "Specify Section Attributes",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MSDOSStubFileName",
+ "switch": "STUB:",
+ "comment": "MS-DOS Stub File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ModuleDefinitionFile",
+ "switch": "DEF:",
+ "comment": "Module Definition File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ManifestFile",
+ "switch": "ManifestFile:",
+ "comment": "Manifest File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProgramDatabaseFile",
+ "switch": "PDB:",
+ "comment": "Generate Program Database File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "StripPrivateSymbols",
+ "switch": "PDBSTRIPPED:",
+ "comment": "Strip Private Symbols",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MapFileName",
+ "switch": "MAP:",
+ "comment": "Map File Name",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "HeapReserveSize",
+ "switch": "HEAP:",
+ "comment": "Heap Reserve Size",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "HeapCommitSize",
+ "switch": "HEAP",
+ "comment": "Heap Commit Size",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "StackReserveSize",
+ "switch": "STACK:",
+ "comment": "Stack Reserve Size",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "StackCommitSize",
+ "switch": "STACK",
+ "comment": "Stack Commit Size",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "FunctionOrder",
+ "switch": "ORDER:@",
+ "comment": "Function Order",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProfileGuidedDatabase",
+ "switch": "PGD:",
+ "comment": "Profile Guided Database",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MidlCommandFile",
+ "switch": "MIDL:@",
+ "comment": "MIDL Commands",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MergedIDLBaseFileName",
+ "switch": "IDLOUT:",
+ "comment": "Merged IDL Base File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "TypeLibraryFile",
+ "switch": "TLBOUT:",
+ "comment": "Type Library",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataFile",
+ "switch": "WINMDFILE:",
+ "comment": "Windows Metadata File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataLinkKeyFile",
+ "switch": "WINMDKEYFILE:",
+ "comment": "Windows Metadata Key File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataKeyContainer",
+ "switch": "WINMDKEYCONTAINER:",
+ "comment": "Windows Metadata Key Container",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "EntryPointSymbol",
+ "switch": "ENTRY:",
+ "comment": "Entry Point",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "BaseAddress",
+ "switch": "BASE:",
+ "comment": "Base Address",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ImportLibrary",
+ "switch": "IMPLIB:",
+ "comment": "Import Library",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MergeSections",
+ "switch": "MERGE:",
+ "comment": "Merge Sections",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "LinkKeyFile",
+ "switch": "KEYFILE:",
+ "comment": "Key File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "KeyContainer",
+ "switch": "KEYCONTAINER:",
+ "comment": "Key Container",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "TypeLibraryResourceID",
+ "switch": "TLBID:",
+ "comment": "TypeLib Resource ID",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "SectionAlignment",
+ "switch": "ALIGN:",
+ "comment": "SectionAlignment",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v141_CL.json b/Templates/MSBuild/FlagTables/v141_CL.json
new file mode 100644
index 000000000..01fafe48d
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v141_CL.json
@@ -0,0 +1,1268 @@
+[
+ {
+ "name": "DebugInformationFormat",
+ "switch": "",
+ "comment": "None",
+ "value": "None",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "Z7",
+ "comment": "C7 compatible",
+ "value": "OldStyle",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "Zi",
+ "comment": "Program Database",
+ "value": "ProgramDatabase",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "ZI",
+ "comment": "Program Database for Edit And Continue",
+ "value": "EditAndContinue",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "",
+ "comment": "No Common Language RunTime Support",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr",
+ "comment": "Common Language RunTime Support",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:pure",
+ "comment": "Pure MSIL Common Language RunTime Support",
+ "value": "Pure",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:safe",
+ "comment": "Safe MSIL Common Language RunTime Support",
+ "value": "Safe",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W0",
+ "comment": "Turn Off All Warnings",
+ "value": "TurnOffAllWarnings",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W1",
+ "comment": "Level1",
+ "value": "Level1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W2",
+ "comment": "Level2",
+ "value": "Level2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W3",
+ "comment": "Level3",
+ "value": "Level3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W4",
+ "comment": "Level4",
+ "value": "Level4",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "Wall",
+ "comment": "EnableAllWarnings",
+ "value": "EnableAllWarnings",
+ "flags": []
+ },
+ {
+ "name": "DiagnosticsFormat",
+ "switch": "diagnostics:caret",
+ "comment": "Caret",
+ "value": "Caret",
+ "flags": []
+ },
+ {
+ "name": "DiagnosticsFormat",
+ "switch": "diagnostics:column",
+ "comment": "Column Info",
+ "value": "Column",
+ "flags": []
+ },
+ {
+ "name": "DiagnosticsFormat",
+ "switch": "diagnostics:classic",
+ "comment": "Classic",
+ "value": "Classic",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "",
+ "comment": "Custom",
+ "value": "Custom",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "Od",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O1",
+ "comment": "Maximum Optimization (Favor Size)",
+ "value": "MinSpace",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O2",
+ "comment": "Maximum Optimization (Favor Speed)",
+ "value": "MaxSpeed",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "Ox",
+ "comment": "Optimizations (Favor Speed)",
+ "value": "Full",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob0",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob1",
+ "comment": "Only __inline",
+ "value": "OnlyExplicitInline",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob2",
+ "comment": "Any Suitable",
+ "value": "AnySuitable",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "Os",
+ "comment": "Favor small code",
+ "value": "Size",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "Ot",
+ "comment": "Favor fast code",
+ "value": "Speed",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "",
+ "comment": "Neither",
+ "value": "Neither",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHa",
+ "comment": "Yes with SEH Exceptions",
+ "value": "Async",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHsc",
+ "comment": "Yes",
+ "value": "Sync",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHs",
+ "comment": "Yes with Extern C functions",
+ "value": "SyncCThrow",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTCs",
+ "comment": "Stack Frames",
+ "value": "StackFrameRuntimeCheck",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTCu",
+ "comment": "Uninitialized variables",
+ "value": "UninitializedLocalUsageCheck",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTC1",
+ "comment": "Both (/RTC1, equiv. to /RTCsu)",
+ "value": "EnableFastChecks",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MT",
+ "comment": "Multi-threaded",
+ "value": "MultiThreaded",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MTd",
+ "comment": "Multi-threaded Debug",
+ "value": "MultiThreadedDebug",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MD",
+ "comment": "Multi-threaded DLL",
+ "value": "MultiThreadedDLL",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MDd",
+ "comment": "Multi-threaded Debug DLL",
+ "value": "MultiThreadedDebugDLL",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp1",
+ "comment": "1 Byte",
+ "value": "1Byte",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp2",
+ "comment": "2 Bytes",
+ "value": "2Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp4",
+ "comment": "4 Byte",
+ "value": "4Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp8",
+ "comment": "8 Bytes",
+ "value": "8Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp16",
+ "comment": "16 Bytes",
+ "value": "16Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "BufferSecurityCheck",
+ "switch": "GS-",
+ "comment": "Disable Security Check",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "BufferSecurityCheck",
+ "switch": "GS",
+ "comment": "Enable Security Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ControlFlowGuard",
+ "switch": "guard:cf",
+ "comment": "Yes",
+ "value": "Guard",
+ "flags": []
+ },
+ {
+ "name": "ControlFlowGuard",
+ "switch": "",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:SSE",
+ "comment": "Streaming SIMD Extensions",
+ "value": "StreamingSIMDExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:SSE2",
+ "comment": "Streaming SIMD Extensions 2",
+ "value": "StreamingSIMDExtensions2",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:AVX",
+ "comment": "Advanced Vector Extensions",
+ "value": "AdvancedVectorExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:AVX2",
+ "comment": "Advanced Vector Extensions 2",
+ "value": "AdvancedVectorExtensions2",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:IA32",
+ "comment": "No Enhanced Instructions",
+ "value": "NoExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:precise",
+ "comment": "Precise",
+ "value": "Precise",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:strict",
+ "comment": "Strict",
+ "value": "Strict",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:fast",
+ "comment": "Fast",
+ "value": "Fast",
+ "flags": []
+ },
+ {
+ "name": "SpectreMitigation",
+ "switch": "Qspectre",
+ "comment": "Spectre mitigations",
+ "value": "Spectre",
+ "flags": []
+ },
+ {
+ "name": "LanguageStandard",
+ "switch": "std:c++14",
+ "comment": "ISO C++14 Standard",
+ "value": "stdcpp14",
+ "flags": []
+ },
+ {
+ "name": "LanguageStandard",
+ "switch": "std:c++17",
+ "comment": "ISO C++17 Standard",
+ "value": "stdcpp17",
+ "flags": []
+ },
+ {
+ "name": "LanguageStandard",
+ "switch": "std:c++latest",
+ "comment": "ISO C++ Latest Draft Standard",
+ "value": "stdcpplatest",
+ "flags": []
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Yc",
+ "comment": "Create",
+ "value": "Create",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Yu",
+ "comment": "Use",
+ "value": "Use",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Y-",
+ "comment": "Not Using Precompiled Headers",
+ "value": "NotUsing",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "",
+ "comment": "No Listing",
+ "value": "NoListing",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FA",
+ "comment": "Assembly-Only Listing",
+ "value": "AssemblyCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAc",
+ "comment": "Assembly With Machine Code",
+ "value": "AssemblyAndMachineCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAs",
+ "comment": "Assembly With Source Code",
+ "value": "AssemblyAndSourceCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAcs",
+ "comment": "Assembly, Machine Code and Source",
+ "value": "All",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gd",
+ "comment": "__cdecl",
+ "value": "Cdecl",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gr",
+ "comment": "__fastcall",
+ "value": "FastCall",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gz",
+ "comment": "__stdcall",
+ "value": "StdCall",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gv",
+ "comment": "__vectorcall",
+ "value": "VectorCall",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "TC",
+ "comment": "Compile as C Code",
+ "value": "CompileAsC",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "TP",
+ "comment": "Compile as C++ Code",
+ "value": "CompileAsCpp",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:none",
+ "comment": "Do Not Send Report",
+ "value": "None",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:prompt",
+ "comment": "Prompt Immediately",
+ "value": "Prompt",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:queue",
+ "comment": "Queue For Next Login",
+ "value": "Queue",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:send",
+ "comment": "Send Automatically",
+ "value": "Send",
+ "flags": []
+ },
+ {
+ "name": "CompileAsWinRT",
+ "switch": "ZW",
+ "comment": "Consume Windows Runtime Extension",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WinRTNoStdLib",
+ "switch": "ZW:nostdlib",
+ "comment": "No Standard WinRT Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningAsError",
+ "switch": "WX-",
+ "comment": "Treat Warnings As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningAsError",
+ "switch": "WX",
+ "comment": "Treat Warnings As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SDLCheck",
+ "switch": "sdl-",
+ "comment": "SDL checks",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "SDLCheck",
+ "switch": "sdl",
+ "comment": "SDL checks",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MultiProcessorCompilation",
+ "switch": "MP",
+ "comment": "Multi-processor Compilation",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "IntrinsicFunctions",
+ "switch": "Oi",
+ "comment": "Enable Intrinsic Functions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OmitFramePointers",
+ "switch": "Oy-",
+ "comment": "Omit Frame Pointers",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OmitFramePointers",
+ "switch": "Oy",
+ "comment": "Omit Frame Pointers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableFiberSafeOptimizations",
+ "switch": "GT",
+ "comment": "Enable Fiber-Safe Optimizations",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WholeProgramOptimization",
+ "switch": "GL",
+ "comment": "Whole Program Optimization",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UndefineAllPreprocessorDefinitions",
+ "switch": "u",
+ "comment": "Undefine All Preprocessor Definitions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreStandardIncludePath",
+ "switch": "X",
+ "comment": "Ignore Standard Include Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessToFile",
+ "switch": "P",
+ "comment": "Preprocess to a File",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessSuppressLineNumbers",
+ "switch": "EP",
+ "comment": "Preprocess Suppress Line Numbers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessKeepComments",
+ "switch": "C",
+ "comment": "Keep Comments",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "StringPooling",
+ "switch": "GF-",
+ "comment": "Enable String Pooling",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "StringPooling",
+ "switch": "GF",
+ "comment": "Enable String Pooling",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MinimalRebuild",
+ "switch": "Gm-",
+ "comment": "Enable Minimal Rebuild",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "MinimalRebuild",
+ "switch": "Gm",
+ "comment": "Enable Minimal Rebuild",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SmallerTypeCheck",
+ "switch": "RTCc",
+ "comment": "Smaller Type Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FunctionLevelLinking",
+ "switch": "Gy-",
+ "comment": "Enable Function-Level Linking",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FunctionLevelLinking",
+ "switch": "Gy",
+ "comment": "Enable Function-Level Linking",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableParallelCodeGeneration",
+ "switch": "Qpar-",
+ "comment": "Enable Parallel Code Generation",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableParallelCodeGeneration",
+ "switch": "Qpar",
+ "comment": "Enable Parallel Code Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointExceptions",
+ "switch": "fp:except-",
+ "comment": "Enable Floating Point Exceptions",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointExceptions",
+ "switch": "fp:except",
+ "comment": "Enable Floating Point Exceptions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CreateHotpatchableImage",
+ "switch": "hotpatch",
+ "comment": "Create Hotpatchable Image",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DisableLanguageExtensions",
+ "switch": "Za",
+ "comment": "Disable Language Extensions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ConformanceMode",
+ "switch": "permissive-",
+ "comment": "Conformance mode enabled",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ConformanceMode",
+ "switch": "permissive",
+ "comment": "Conformance mode disabled",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWChar_tAsBuiltInType",
+ "switch": "Zc:wchar_t-",
+ "comment": "Treat WChar_t As Built in Type",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWChar_tAsBuiltInType",
+ "switch": "Zc:wchar_t",
+ "comment": "Treat WChar_t As Built in Type",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ForceConformanceInForLoopScope",
+ "switch": "Zc:forScope-",
+ "comment": "Force Conformance in For Loop Scope",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "ForceConformanceInForLoopScope",
+ "switch": "Zc:forScope",
+ "comment": "Force Conformance in For Loop Scope",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RemoveUnreferencedCodeData",
+ "switch": "Zc:inline-",
+ "comment": "Remove unreferenced code and data",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RemoveUnreferencedCodeData",
+ "switch": "Zc:inline",
+ "comment": "Remove unreferenced code and data",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnforceTypeConversionRules",
+ "switch": "Zc:rvalueCast-",
+ "comment": "Enforce type conversion rules",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnforceTypeConversionRules",
+ "switch": "Zc:rvalueCast",
+ "comment": "Enforce type conversion rules",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RuntimeTypeInfo",
+ "switch": "GR-",
+ "comment": "Enable Run-Time Type Information",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RuntimeTypeInfo",
+ "switch": "GR",
+ "comment": "Enable Run-Time Type Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OpenMPSupport",
+ "switch": "openmp-",
+ "comment": "Open MP Support",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OpenMPSupport",
+ "switch": "openmp",
+ "comment": "Open MP Support",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableModules",
+ "switch": "experimental:module",
+ "comment": "Enable C++ Modules (experimental)",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ExpandAttributedSource",
+ "switch": "Fx",
+ "comment": "Expand Attributed Source",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseUnicodeForAssemblerListing",
+ "switch": "FAu",
+ "comment": "Use Unicode For Assembler Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateXMLDocumentationFiles",
+ "switch": "doc",
+ "comment": "Generate XML Documentation Files",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "BrowseInformation",
+ "switch": "FR",
+ "comment": "Enable Browse Information",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "ShowIncludes",
+ "switch": "showIncludes",
+ "comment": "Show Includes",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnablePREfast",
+ "switch": "analyze-",
+ "comment": "Enable Code Analysis",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnablePREfast",
+ "switch": "analyze",
+ "comment": "Enable Code Analysis",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseFullPaths",
+ "switch": "FC",
+ "comment": "Use Full Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OmitDefaultLibName",
+ "switch": "Zl",
+ "comment": "Omit Default Library Name",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalIncludeDirectories",
+ "switch": "I",
+ "comment": "Additional Include Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalUsingDirectories",
+ "switch": "AI",
+ "comment": "Additional #using Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "UndefinePreprocessorDefinitions",
+ "switch": "U",
+ "comment": "Undefine Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "DisableSpecificWarnings",
+ "switch": "wd",
+ "comment": "Disable Specific Warnings",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForcedIncludeFiles",
+ "switch": "FI",
+ "comment": "Forced Include File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForcedUsingFiles",
+ "switch": "FU",
+ "comment": "Forced #using File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PREfastLog",
+ "switch": "analyze:log",
+ "comment": "Code Analysis Log",
+ "value": "",
+ "flags": [
+ "UserFollowing"
+ ]
+ },
+ {
+ "name": "PREfastAdditionalPlugins",
+ "switch": "analyze:plugin",
+ "comment": "Additional Code Analysis Native plugins",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "TreatSpecificWarningsAsErrors",
+ "switch": "we",
+ "comment": "Treat Specific Warnings As Errors",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "WarningVersion",
+ "switch": "Wv:",
+ "comment": "Warning Version",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "PreprocessOutputPath",
+ "switch": "Fi",
+ "comment": "Preprocess Output Path",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderFile",
+ "switch": "Yu",
+ "comment": "Precompiled Header File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderFile",
+ "switch": "Yc",
+ "comment": "Precompiled Header File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderOutputFile",
+ "switch": "Fp",
+ "comment": "Precompiled Header Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "AssemblerListingLocation",
+ "switch": "Fa",
+ "comment": "ASM List Location",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ObjectFileName",
+ "switch": "Fo",
+ "comment": "Object File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProgramDataBaseFileName",
+ "switch": "Fd",
+ "comment": "Program Database File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "XMLDocumentationFileName",
+ "switch": "doc",
+ "comment": "XML Documentation File Name",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "BrowseInformationFile",
+ "switch": "FR",
+ "comment": "Browse Information File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ProcessorNumber",
+ "switch": "MP",
+ "comment": "Number of processors",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=c++98",
+ "comment": "C++03",
+ "value": "c++98",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=c++11",
+ "comment": "C++11",
+ "value": "c++11",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=c++1y",
+ "comment": "C++14",
+ "value": "c++1y",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=c++14",
+ "comment": "C++14",
+ "value": "c++1y",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=gnu++98",
+ "comment": "C++03 (GNU Dialect)",
+ "value": "gnu++98",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=gnu++11",
+ "comment": "C++11 (GNU Dialect)",
+ "value": "gnu++11",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=gnu++1y",
+ "comment": "C++14 (GNU Dialect)",
+ "value": "gnu++1y",
+ "flags": []
+ },
+ {
+ "name": "CppLanguageStandard",
+ "switch": "std=gnu++14",
+ "comment": "C++14 (GNU Dialect)",
+ "value": "gnu++1y",
+ "flags": []
+ },
+ {
+ "name": "SupportJustMyCode",
+ "switch": "JMC-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "SupportJustMyCode",
+ "switch": "JMC",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v141_CSharp.json b/Templates/MSBuild/FlagTables/v141_CSharp.json
new file mode 100644
index 000000000..5989aea1e
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v141_CSharp.json
@@ -0,0 +1,574 @@
+[
+ {
+ "name": "ProjectName",
+ "switch": "out:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:exe",
+ "comment": "",
+ "value": "Exe",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:winexe",
+ "comment": "",
+ "value": "Winexe",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:library",
+ "comment": "",
+ "value": "Library",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:module",
+ "comment": "",
+ "value": "Module",
+ "flags": []
+ },
+ {
+ "name": "DocumentationFile",
+ "switch": "doc",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:x86",
+ "comment": "",
+ "value": "x86",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:Itanium",
+ "comment": "",
+ "value": "Itanium",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:x64",
+ "comment": "",
+ "value": "x64",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:arm",
+ "comment": "",
+ "value": "arm",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:anycpu32bitpreferred",
+ "comment": "",
+ "value": "anycpu32bitpreferred",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:anycpu",
+ "comment": "",
+ "value": "anycpu",
+ "flags": []
+ },
+ {
+ "name": "References",
+ "switch": "reference:",
+ "comment": "mit alias",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "References",
+ "switch": "reference:",
+ "comment": "dateiliste",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "AddModules",
+ "switch": "addmodule:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "Win32Resource",
+ "switch": "win32res:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ApplicationIcon",
+ "switch": "win32icon:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ApplicationManifest",
+ "switch": "win32manifest:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "NoWin32Manifest",
+ "switch": "nowin32manifest",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DefineDebug",
+ "switch": "debug",
+ "comment": "",
+ "value": "true",
+ "flags": [
+ "Continue"
+ ]
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:none",
+ "comment": "",
+ "value": "none",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:full",
+ "comment": "",
+ "value": "full",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:pdbonly",
+ "comment": "",
+ "value": "pdbonly",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror-",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror+",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:0",
+ "comment": "",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:1",
+ "comment": "",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:2",
+ "comment": "",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:3",
+ "comment": "",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:4",
+ "comment": "",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "NoWarn",
+ "switch": "nowarn:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired",
+ "CommaAppendable"
+ ]
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DefineConstants",
+ "switch": "define:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "SemicolonAppendable",
+ "UserValue"
+ ]
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:ISO-1",
+ "comment": "",
+ "value": "ISO-1",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:ISO-2",
+ "comment": "",
+ "value": "ISO-2",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:3",
+ "comment": "",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:4",
+ "comment": "",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:5",
+ "comment": "",
+ "value": "5",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:6",
+ "comment": "",
+ "value": "6",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:default",
+ "comment": "",
+ "value": "default",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AssemblyOriginatorKeyFile",
+ "switch": "keyfile",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "KeyContainerName",
+ "switch": "keycontainer",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoLogo",
+ "switch": "nologo",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoConfig",
+ "switch": "noconfig",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "BaseAddress",
+ "switch": "baseaddress:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "CodePage",
+ "switch": "codepage",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "Utf8Output",
+ "switch": "utf8output",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "MainEntryPoint",
+ "switch": "main:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "GenerateFullPaths",
+ "switch": "fullpaths",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FileAlignment",
+ "switch": "filealign",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "PdbFile",
+ "switch": "pdb:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SubsystemVersion",
+ "switch": "subsystemversion",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibPaths",
+ "switch": "lib:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:none",
+ "comment": "Do Not Send Report",
+ "value": "none",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:prompt",
+ "comment": "Prompt Immediately",
+ "value": "prompt",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:queue",
+ "comment": "Queue For Next Login",
+ "value": "queue",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:send",
+ "comment": "Send Automatically",
+ "value": "send",
+ "flags": []
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v141_Link.json b/Templates/MSBuild/FlagTables/v141_Link.json
new file mode 100644
index 000000000..66ee76fcb
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v141_Link.json
@@ -0,0 +1,1323 @@
+[
+ {
+ "name": "ShowProgress",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE",
+ "comment": "Display all progress messages",
+ "value": "LinkVerbose",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:Lib",
+ "comment": "For Libraries Searched",
+ "value": "LinkVerboseLib",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:ICF",
+ "comment": "About COMDAT folding during optimized linking",
+ "value": "LinkVerboseICF",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:REF",
+ "comment": "About data removed during optimized linking",
+ "value": "LinkVerboseREF",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:SAFESEH",
+ "comment": "About Modules incompatible with SEH",
+ "value": "LinkVerboseSAFESEH",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:CLR",
+ "comment": "About linker activity related to managed code",
+ "value": "LinkVerboseCLR",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE:MULTIPLE",
+ "comment": "Multiply Defined Symbol Only",
+ "value": "MultiplyDefinedSymbolOnly",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE:UNRESOLVED",
+ "comment": "Undefined Symbol Only",
+ "value": "UndefinedSymbolOnly",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:5",
+ "comment": "X86 Image Only",
+ "value": "X86Image",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:6",
+ "comment": "X64 Image Only",
+ "value": "X64Image",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:16",
+ "comment": "Itanium Image Only",
+ "value": "ItaniumImage",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='asInvoker'",
+ "comment": "asInvoker",
+ "value": "AsInvoker",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='highestAvailable'",
+ "comment": "highestAvailable",
+ "value": "HighestAvailable",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='requireAdministrator'",
+ "comment": "requireAdministrator",
+ "value": "RequireAdministrator",
+ "flags": []
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG",
+ "comment": "Generate Debug Information",
+ "value": "true",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG:FASTLINK",
+ "comment": "Generate Debug Information optimized for faster links",
+ "value": "DebugFastLink",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG:FULL",
+ "comment": "Generate Debug Information optimized for sharing and publishing",
+ "value": "DebugFull",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG:NONE",
+ "comment": "Produces no debugging information",
+ "value": "false",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "SubSystem",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:CONSOLE",
+ "comment": "Console",
+ "value": "Console",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWS",
+ "comment": "Windows",
+ "value": "Windows",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:NATIVE",
+ "comment": "Native",
+ "value": "Native",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_APPLICATION",
+ "comment": "EFI Application",
+ "value": "EFI Application",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+ "comment": "EFI Boot Service Driver",
+ "value": "EFI Boot Service Driver",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_ROM",
+ "comment": "EFI ROM",
+ "value": "EFI ROM",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_RUNTIME_DRIVER",
+ "comment": "EFI Runtime",
+ "value": "EFI Runtime",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:POSIX",
+ "comment": "POSIX",
+ "value": "POSIX",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "Driver",
+ "comment": "Driver",
+ "value": "Driver",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "DRIVER:UPONLY",
+ "comment": "UP Only",
+ "value": "UpOnly",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "DRIVER:WDM",
+ "comment": "WDM",
+ "value": "WDM",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:incremental",
+ "comment": "Use Fast Link Time Code Generation",
+ "value": "UseFastLinkTimeCodeGeneration",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG",
+ "comment": "Use Link Time Code Generation",
+ "value": "UseLinkTimeCodeGeneration",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGInstrument",
+ "comment": "Profile Guided Optimization - Instrument",
+ "value": "PGInstrument",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGOptimize",
+ "comment": "Profile Guided Optimization - Optimization",
+ "value": "PGOptimization",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGUpdate",
+ "comment": "Profile Guided Optimization - Update",
+ "value": "PGUpdate",
+ "flags": []
+ },
+ {
+ "name": "GenerateWindowsMetadata",
+ "switch": "WINMD",
+ "comment": "Yes",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateWindowsMetadata",
+ "switch": "WINMD:NO",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA1",
+ "comment": "SHA1",
+ "value": "SHA1",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA256",
+ "comment": "SHA256",
+ "value": "SHA256",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA384",
+ "comment": "SHA384",
+ "value": "SHA384",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA512",
+ "comment": "SHA512",
+ "value": "SHA512",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:ARM",
+ "comment": "MachineARM",
+ "value": "MachineARM",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:ARM64",
+ "comment": "MachineARM64",
+ "value": "MachineARM64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:EBC",
+ "comment": "MachineEBC",
+ "value": "MachineEBC",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:IA64",
+ "comment": "MachineIA64",
+ "value": "MachineIA64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS",
+ "comment": "MachineMIPS",
+ "value": "MachineMIPS",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS16",
+ "comment": "MachineMIPS16",
+ "value": "MachineMIPS16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU",
+ "comment": "MachineMIPSFPU",
+ "value": "MachineMIPSFPU",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU16",
+ "comment": "MachineMIPSFPU16",
+ "value": "MachineMIPSFPU16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:SH4",
+ "comment": "MachineSH4",
+ "value": "MachineSH4",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:THUMB",
+ "comment": "MachineTHUMB",
+ "value": "MachineTHUMB",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X64",
+ "comment": "MachineX64",
+ "value": "MachineX64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X86",
+ "comment": "MachineX86",
+ "value": "MachineX86",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:MTA",
+ "comment": "MTA threading attribute",
+ "value": "MTAThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:STA",
+ "comment": "STA threading attribute",
+ "value": "STAThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:NONE",
+ "comment": "Default threading attribute",
+ "value": "DefaultThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:IJW",
+ "comment": "Force IJW image",
+ "value": "ForceIJWImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:PURE",
+ "comment": "Force Pure IL Image",
+ "value": "ForcePureILImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:SAFE",
+ "comment": "Force Safe IL Image",
+ "value": "ForceSafeILImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "",
+ "comment": "Default image type",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA1",
+ "comment": "SHA1",
+ "value": "SHA1",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA256",
+ "comment": "SHA256",
+ "value": "SHA256",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA384",
+ "comment": "SHA384",
+ "value": "SHA384",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA512",
+ "comment": "SHA512",
+ "value": "SHA512",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:PROMPT",
+ "comment": "PromptImmediately",
+ "value": "PromptImmediately",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:QUEUE",
+ "comment": "Queue For Next Login",
+ "value": "QueueForNextLogin",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:SEND",
+ "comment": "Send Error Report",
+ "value": "SendErrorReport",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:NONE",
+ "comment": "No Error Report",
+ "value": "NoErrorReport",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError:NO",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError:SYSTEMDLL",
+ "comment": "System Dlls Only",
+ "value": "SystemDlls",
+ "flags": []
+ },
+ {
+ "name": "LinkIncremental",
+ "switch": "INCREMENTAL:NO",
+ "comment": "Enable Incremental Linking",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkIncremental",
+ "switch": "INCREMENTAL",
+ "comment": "Enable Incremental Linking",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "NOLOGO",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkStatus",
+ "switch": "LTCG:NOSTATUS",
+ "comment": "Link Status",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkStatus",
+ "switch": "LTCG:STATUS",
+ "comment": "Link Status",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreventDllBinding",
+ "switch": "ALLOWBIND:NO",
+ "comment": "Prevent Dll Binding",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "PreventDllBinding",
+ "switch": "ALLOWBIND",
+ "comment": "Prevent Dll Binding",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatLinkerWarningAsErrors",
+ "switch": "WX:NO",
+ "comment": "Treat Linker Warning As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatLinkerWarningAsErrors",
+ "switch": "WX",
+ "comment": "Treat Linker Warning As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreAllDefaultLibraries",
+ "switch": "NODEFAULTLIB",
+ "comment": "Ignore All Default Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateManifest",
+ "switch": "MANIFEST:NO",
+ "comment": "Generate Manifest",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "GenerateManifest",
+ "switch": "MANIFEST",
+ "comment": "Generate Manifest",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowIsolation",
+ "switch": "ALLOWISOLATION:NO",
+ "comment": "Allow Isolation",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AllowIsolation",
+ "switch": "",
+ "comment": "Allow Isolation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableUAC",
+ "switch": "MANIFESTUAC:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired",
+ "SpaceAppendable"
+ ]
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='false'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "false",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='false'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='true'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ManifestEmbed",
+ "switch": "manifest:embed",
+ "comment": "Embed Manifest",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateMapFile",
+ "switch": "MAP",
+ "comment": "Generate Map File",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "MapExports",
+ "switch": "MAPINFO:EXPORTS",
+ "comment": "Map Exports",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AssemblyDebug",
+ "switch": "ASSEMBLYDEBUG:DISABLE",
+ "comment": "Debuggable Assembly",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AssemblyDebug",
+ "switch": "ASSEMBLYDEBUG",
+ "comment": "Debuggable Assembly",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LargeAddressAware",
+ "switch": "LARGEADDRESSAWARE:NO",
+ "comment": "Enable Large Addresses",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LargeAddressAware",
+ "switch": "LARGEADDRESSAWARE",
+ "comment": "Enable Large Addresses",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TerminalServerAware",
+ "switch": "TSAWARE:NO",
+ "comment": "Terminal Server",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TerminalServerAware",
+ "switch": "TSAWARE",
+ "comment": "Terminal Server",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SwapRunFromCD",
+ "switch": "SWAPRUN:CD",
+ "comment": "Swap Run From CD",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SwapRunFromNET",
+ "switch": "SWAPRUN:NET",
+ "comment": "Swap Run From Network",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OptimizeReferences",
+ "switch": "OPT:NOREF",
+ "comment": "References",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OptimizeReferences",
+ "switch": "OPT:REF",
+ "comment": "References",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableCOMDATFolding",
+ "switch": "OPT:NOICF",
+ "comment": "Enable COMDAT Folding",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableCOMDATFolding",
+ "switch": "OPT:ICF",
+ "comment": "Enable COMDAT Folding",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreEmbeddedIDL",
+ "switch": "IGNOREIDL",
+ "comment": "Ignore Embedded IDL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AppContainer",
+ "switch": "APPCONTAINER",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataLinkDelaySign",
+ "switch": "WINMDDELAYSIGN:NO",
+ "comment": "Windows Metadata Delay Sign",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataLinkDelaySign",
+ "switch": "WINMDDELAYSIGN",
+ "comment": "Windows Metadata Delay Sign",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NoEntryPoint",
+ "switch": "NOENTRY",
+ "comment": "No Entry Point",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SetChecksum",
+ "switch": "RELEASE",
+ "comment": "Set Checksum",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RandomizedBaseAddress",
+ "switch": "DYNAMICBASE:NO",
+ "comment": "Randomized Base Address",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RandomizedBaseAddress",
+ "switch": "DYNAMICBASE",
+ "comment": "Randomized Base Address",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FixedBaseAddress",
+ "switch": "FIXED:NO",
+ "comment": "Fixed Base Address",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FixedBaseAddress",
+ "switch": "FIXED",
+ "comment": "Fixed Base Address",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DataExecutionPrevention",
+ "switch": "NXCOMPAT:NO",
+ "comment": "Data Execution Prevention (DEP)",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DataExecutionPrevention",
+ "switch": "NXCOMPAT",
+ "comment": "Data Execution Prevention (DEP)",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TurnOffAssemblyGeneration",
+ "switch": "NOASSEMBLY",
+ "comment": "Turn Off Assembly Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SupportUnloadOfDelayLoadedDLL",
+ "switch": "DELAY:UNLOAD",
+ "comment": "Unload delay loaded DLL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SupportNobindOfDelayLoadedDLL",
+ "switch": "DELAY:NOBIND",
+ "comment": "Nobind delay loaded DLL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Profile",
+ "switch": "PROFILE",
+ "comment": "Profile",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkDelaySign",
+ "switch": "DELAYSIGN:NO",
+ "comment": "Delay Sign",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkDelaySign",
+ "switch": "DELAYSIGN",
+ "comment": "Delay Sign",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CLRUnmanagedCodeCheck",
+ "switch": "CLRUNMANAGEDCODECHECK:NO",
+ "comment": "CLR Unmanaged Code Check",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CLRUnmanagedCodeCheck",
+ "switch": "CLRUNMANAGEDCODECHECK",
+ "comment": "CLR Unmanaged Code Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DetectOneDefinitionRule",
+ "switch": "ODR",
+ "comment": "Detect One Definition Rule violations",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ImageHasSafeExceptionHandlers",
+ "switch": "SAFESEH:NO",
+ "comment": "Image Has Safe Exception Handlers",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "ImageHasSafeExceptionHandlers",
+ "switch": "SAFESEH",
+ "comment": "Image Has Safe Exception Handlers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkDLL",
+ "switch": "DLL",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibraryDirectories",
+ "switch": "LIBPATH:",
+ "comment": "Additional Library Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "Natvis",
+ "switch": "NATVIS:",
+ "comment": "Natvis files",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IgnoreSpecificDefaultLibraries",
+ "switch": "NODEFAULTLIB:",
+ "comment": "Ignore Specific Default Libraries",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AddModuleNamesToAssembly",
+ "switch": "ASSEMBLYMODULE:",
+ "comment": "Add Module to Assembly",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "EmbedManagedResourceFile",
+ "switch": "ASSEMBLYRESOURCE:",
+ "comment": "Embed Managed Resource File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForceSymbolReferences",
+ "switch": "INCLUDE:",
+ "comment": "Force Symbol References",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "DelayLoadDLLs",
+ "switch": "DELAYLOAD:",
+ "comment": "Delay Loaded Dlls",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AssemblyLinkResource",
+ "switch": "ASSEMBLYLINKRESOURCE:",
+ "comment": "Assembly Link Resource",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalManifestDependencies",
+ "switch": "MANIFESTDEPENDENCY:",
+ "comment": "Additional Manifest Dependencies",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ManifestInput",
+ "switch": "manifestinput:",
+ "comment": "Manifest Input",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "OutputFile",
+ "switch": "OUT:",
+ "comment": "Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "Version",
+ "switch": "VERSION:",
+ "comment": "Version",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "SpecifySectionAttributes",
+ "switch": "SECTION:",
+ "comment": "Specify Section Attributes",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MSDOSStubFileName",
+ "switch": "STUB:",
+ "comment": "MS-DOS Stub File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ModuleDefinitionFile",
+ "switch": "DEF:",
+ "comment": "Module Definition File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ManifestFile",
+ "switch": "ManifestFile:",
+ "comment": "Manifest File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProgramDatabaseFile",
+ "switch": "PDB:",
+ "comment": "Generate Program Database File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "StripPrivateSymbols",
+ "switch": "PDBSTRIPPED:",
+ "comment": "Strip Private Symbols",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MapFileName",
+ "switch": "MAP:",
+ "comment": "Map File Name",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "HeapReserveSize",
+ "switch": "HEAP:",
+ "comment": "Heap Reserve Size",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "HeapCommitSize",
+ "switch": "HEAP",
+ "comment": "Heap Commit Size",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "StackReserveSize",
+ "switch": "STACK:",
+ "comment": "Stack Reserve Size",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "StackCommitSize",
+ "switch": "STACK",
+ "comment": "Stack Commit Size",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "FunctionOrder",
+ "switch": "ORDER:@",
+ "comment": "Function Order",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProfileGuidedDatabase",
+ "switch": "PGD:",
+ "comment": "Profile Guided Database",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MidlCommandFile",
+ "switch": "MIDL:@",
+ "comment": "MIDL Commands",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MergedIDLBaseFileName",
+ "switch": "IDLOUT:",
+ "comment": "Merged IDL Base File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "TypeLibraryFile",
+ "switch": "TLBOUT:",
+ "comment": "Type Library",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataFile",
+ "switch": "WINMDFILE:",
+ "comment": "Windows Metadata File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataLinkKeyFile",
+ "switch": "WINMDKEYFILE:",
+ "comment": "Windows Metadata Key File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataKeyContainer",
+ "switch": "WINMDKEYCONTAINER:",
+ "comment": "Windows Metadata Key Container",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "EntryPointSymbol",
+ "switch": "ENTRY:",
+ "comment": "Entry Point",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "BaseAddress",
+ "switch": "BASE:",
+ "comment": "Base Address",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ImportLibrary",
+ "switch": "IMPLIB:",
+ "comment": "Import Library",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MergeSections",
+ "switch": "MERGE:",
+ "comment": "Merge Sections",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "LinkKeyFile",
+ "switch": "KEYFILE:",
+ "comment": "Key File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "KeyContainer",
+ "switch": "KEYCONTAINER:",
+ "comment": "Key Container",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "TypeLibraryResourceID",
+ "switch": "TLBID:",
+ "comment": "TypeLib Resource ID",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "SectionAlignment",
+ "switch": "ALIGN:",
+ "comment": "SectionAlignment",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v142_CL.json b/Templates/MSBuild/FlagTables/v142_CL.json
new file mode 100644
index 000000000..95b9d14f6
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v142_CL.json
@@ -0,0 +1,1212 @@
+[
+ {
+ "name": "DebugInformationFormat",
+ "switch": "",
+ "comment": "None",
+ "value": "None",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "Z7",
+ "comment": "C7 compatible",
+ "value": "OldStyle",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "Zi",
+ "comment": "Program Database",
+ "value": "ProgramDatabase",
+ "flags": []
+ },
+ {
+ "name": "DebugInformationFormat",
+ "switch": "ZI",
+ "comment": "Program Database for Edit And Continue",
+ "value": "EditAndContinue",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "",
+ "comment": "No Common Language RunTime Support",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr",
+ "comment": "Common Language RunTime Support",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:pure",
+ "comment": "Pure MSIL Common Language RunTime Support",
+ "value": "Pure",
+ "flags": []
+ },
+ {
+ "name": "CompileAsManaged",
+ "switch": "clr:safe",
+ "comment": "Safe MSIL Common Language RunTime Support",
+ "value": "Safe",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W0",
+ "comment": "Turn Off All Warnings",
+ "value": "TurnOffAllWarnings",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W1",
+ "comment": "Level1",
+ "value": "Level1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W2",
+ "comment": "Level2",
+ "value": "Level2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W3",
+ "comment": "Level3",
+ "value": "Level3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W4",
+ "comment": "Level4",
+ "value": "Level4",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "Wall",
+ "comment": "EnableAllWarnings",
+ "value": "EnableAllWarnings",
+ "flags": []
+ },
+ {
+ "name": "DiagnosticsFormat",
+ "switch": "diagnostics:caret",
+ "comment": "Caret",
+ "value": "Caret",
+ "flags": []
+ },
+ {
+ "name": "DiagnosticsFormat",
+ "switch": "diagnostics:column",
+ "comment": "Column Info",
+ "value": "Column",
+ "flags": []
+ },
+ {
+ "name": "DiagnosticsFormat",
+ "switch": "diagnostics:classic",
+ "comment": "Classic",
+ "value": "Classic",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "",
+ "comment": "Custom",
+ "value": "Custom",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "Od",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O1",
+ "comment": "Maximum Optimization (Favor Size)",
+ "value": "MinSpace",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "O2",
+ "comment": "Maximum Optimization (Favor Speed)",
+ "value": "MaxSpeed",
+ "flags": []
+ },
+ {
+ "name": "Optimization",
+ "switch": "Ox",
+ "comment": "Optimizations (Favor Speed)",
+ "value": "Full",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob0",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob1",
+ "comment": "Only __inline",
+ "value": "OnlyExplicitInline",
+ "flags": []
+ },
+ {
+ "name": "InlineFunctionExpansion",
+ "switch": "Ob2",
+ "comment": "Any Suitable",
+ "value": "AnySuitable",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "Os",
+ "comment": "Favor small code",
+ "value": "Size",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "Ot",
+ "comment": "Favor fast code",
+ "value": "Speed",
+ "flags": []
+ },
+ {
+ "name": "FavorSizeOrSpeed",
+ "switch": "",
+ "comment": "Neither",
+ "value": "Neither",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHa",
+ "comment": "Yes with SEH Exceptions",
+ "value": "Async",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHsc",
+ "comment": "Yes",
+ "value": "Sync",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "EHs",
+ "comment": "Yes with Extern C functions",
+ "value": "SyncCThrow",
+ "flags": []
+ },
+ {
+ "name": "ExceptionHandling",
+ "switch": "",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTCs",
+ "comment": "Stack Frames",
+ "value": "StackFrameRuntimeCheck",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTCu",
+ "comment": "Uninitialized variables",
+ "value": "UninitializedLocalUsageCheck",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "RTC1",
+ "comment": "Both (/RTC1, equiv. to /RTCsu)",
+ "value": "EnableFastChecks",
+ "flags": []
+ },
+ {
+ "name": "BasicRuntimeChecks",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MT",
+ "comment": "Multi-threaded",
+ "value": "MultiThreaded",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MTd",
+ "comment": "Multi-threaded Debug",
+ "value": "MultiThreadedDebug",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MD",
+ "comment": "Multi-threaded DLL",
+ "value": "MultiThreadedDLL",
+ "flags": []
+ },
+ {
+ "name": "RuntimeLibrary",
+ "switch": "MDd",
+ "comment": "Multi-threaded Debug DLL",
+ "value": "MultiThreadedDebugDLL",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp1",
+ "comment": "1 Byte",
+ "value": "1Byte",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp2",
+ "comment": "2 Bytes",
+ "value": "2Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp4",
+ "comment": "4 Byte",
+ "value": "4Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp8",
+ "comment": "8 Bytes",
+ "value": "8Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "Zp16",
+ "comment": "16 Bytes",
+ "value": "16Bytes",
+ "flags": []
+ },
+ {
+ "name": "StructMemberAlignment",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "BufferSecurityCheck",
+ "switch": "GS-",
+ "comment": "Disable Security Check",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "BufferSecurityCheck",
+ "switch": "GS",
+ "comment": "Enable Security Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ControlFlowGuard",
+ "switch": "guard:cf",
+ "comment": "Yes",
+ "value": "Guard",
+ "flags": []
+ },
+ {
+ "name": "ControlFlowGuard",
+ "switch": "",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:SSE",
+ "comment": "Streaming SIMD Extensions",
+ "value": "StreamingSIMDExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:SSE2",
+ "comment": "Streaming SIMD Extensions 2",
+ "value": "StreamingSIMDExtensions2",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:AVX",
+ "comment": "Advanced Vector Extensions",
+ "value": "AdvancedVectorExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:AVX2",
+ "comment": "Advanced Vector Extensions 2",
+ "value": "AdvancedVectorExtensions2",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "arch:IA32",
+ "comment": "No Enhanced Instructions",
+ "value": "NoExtensions",
+ "flags": []
+ },
+ {
+ "name": "EnableEnhancedInstructionSet",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:precise",
+ "comment": "Precise",
+ "value": "Precise",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:strict",
+ "comment": "Strict",
+ "value": "Strict",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointModel",
+ "switch": "fp:fast",
+ "comment": "Fast",
+ "value": "Fast",
+ "flags": []
+ },
+ {
+ "name": "SpectreMitigation",
+ "switch": "Qspectre-",
+ "comment": "Spectre mitigations disabled",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "SpectreMitigation",
+ "switch": "Qspectre",
+ "comment": "Spectre mitigations enabled",
+ "value": "Spectre",
+ "flags": []
+ },
+ {
+ "name": "LanguageStandard",
+ "switch": "std:c++14",
+ "comment": "ISO C++14 Standard",
+ "value": "stdcpp14",
+ "flags": []
+ },
+ {
+ "name": "LanguageStandard",
+ "switch": "std:c++17",
+ "comment": "ISO C++17 Standard",
+ "value": "stdcpp17",
+ "flags": []
+ },
+ {
+ "name": "LanguageStandard",
+ "switch": "std:c++latest",
+ "comment": "Preview - Features from the Latest C++ Working Draft",
+ "value": "stdcpplatest",
+ "flags": []
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Yc",
+ "comment": "Create",
+ "value": "Create",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Yu",
+ "comment": "Use",
+ "value": "Use",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeader",
+ "switch": "Y-",
+ "comment": "Not Using Precompiled Headers",
+ "value": "NotUsing",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "",
+ "comment": "No Listing",
+ "value": "NoListing",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FA",
+ "comment": "Assembly-Only Listing",
+ "value": "AssemblyCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAc",
+ "comment": "Assembly With Machine Code",
+ "value": "AssemblyAndMachineCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAs",
+ "comment": "Assembly With Source Code",
+ "value": "AssemblyAndSourceCode",
+ "flags": []
+ },
+ {
+ "name": "AssemblerOutput",
+ "switch": "FAcs",
+ "comment": "Assembly, Machine Code and Source",
+ "value": "All",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gd",
+ "comment": "__cdecl",
+ "value": "Cdecl",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gr",
+ "comment": "__fastcall",
+ "value": "FastCall",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gz",
+ "comment": "__stdcall",
+ "value": "StdCall",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gv",
+ "comment": "__vectorcall",
+ "value": "VectorCall",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "TC",
+ "comment": "Compile as C Code",
+ "value": "CompileAsC",
+ "flags": []
+ },
+ {
+ "name": "CompileAs",
+ "switch": "TP",
+ "comment": "Compile as C++ Code",
+ "value": "CompileAsCpp",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:none",
+ "comment": "Do Not Send Report",
+ "value": "None",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:prompt",
+ "comment": "Prompt Immediately",
+ "value": "Prompt",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:queue",
+ "comment": "Queue For Next Login",
+ "value": "Queue",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:send",
+ "comment": "Send Automatically",
+ "value": "Send",
+ "flags": []
+ },
+ {
+ "name": "SupportJustMyCode",
+ "switch": "JMC-",
+ "comment": "Support Just My Code Debugging",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "SupportJustMyCode",
+ "switch": "JMC",
+ "comment": "Support Just My Code Debugging",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CompileAsWinRT",
+ "switch": "ZW",
+ "comment": "Consume Windows Runtime Extension",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WinRTNoStdLib",
+ "switch": "ZW:nostdlib",
+ "comment": "No Standard WinRT Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningAsError",
+ "switch": "WX-",
+ "comment": "Treat Warnings As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningAsError",
+ "switch": "WX",
+ "comment": "Treat Warnings As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SDLCheck",
+ "switch": "sdl-",
+ "comment": "SDL checks",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "SDLCheck",
+ "switch": "sdl",
+ "comment": "SDL checks",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MultiProcessorCompilation",
+ "switch": "MP",
+ "comment": "Multi-processor Compilation",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "IntrinsicFunctions",
+ "switch": "Oi",
+ "comment": "Enable Intrinsic Functions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OmitFramePointers",
+ "switch": "Oy-",
+ "comment": "Omit Frame Pointers",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OmitFramePointers",
+ "switch": "Oy",
+ "comment": "Omit Frame Pointers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableFiberSafeOptimizations",
+ "switch": "GT",
+ "comment": "Enable Fiber-Safe Optimizations",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WholeProgramOptimization",
+ "switch": "GL",
+ "comment": "Whole Program Optimization",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UndefineAllPreprocessorDefinitions",
+ "switch": "u",
+ "comment": "Undefine All Preprocessor Definitions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreStandardIncludePath",
+ "switch": "X",
+ "comment": "Ignore Standard Include Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessToFile",
+ "switch": "P",
+ "comment": "Preprocess to a File",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessSuppressLineNumbers",
+ "switch": "EP",
+ "comment": "Preprocess Suppress Line Numbers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessKeepComments",
+ "switch": "C",
+ "comment": "Keep Comments",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "StringPooling",
+ "switch": "GF-",
+ "comment": "Enable String Pooling",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "StringPooling",
+ "switch": "GF",
+ "comment": "Enable String Pooling",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MinimalRebuild",
+ "switch": "Gm-",
+ "comment": "Enable Minimal Rebuild",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "MinimalRebuild",
+ "switch": "Gm",
+ "comment": "Enable Minimal Rebuild",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SmallerTypeCheck",
+ "switch": "RTCc",
+ "comment": "Smaller Type Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FunctionLevelLinking",
+ "switch": "Gy-",
+ "comment": "Enable Function-Level Linking",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FunctionLevelLinking",
+ "switch": "Gy",
+ "comment": "Enable Function-Level Linking",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableParallelCodeGeneration",
+ "switch": "Qpar-",
+ "comment": "Enable Parallel Code Generation",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableParallelCodeGeneration",
+ "switch": "Qpar",
+ "comment": "Enable Parallel Code Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointExceptions",
+ "switch": "fp:except-",
+ "comment": "Enable Floating Point Exceptions",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FloatingPointExceptions",
+ "switch": "fp:except",
+ "comment": "Enable Floating Point Exceptions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CreateHotpatchableImage",
+ "switch": "hotpatch",
+ "comment": "Create Hotpatchable Image",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DisableLanguageExtensions",
+ "switch": "Za",
+ "comment": "Disable Language Extensions",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ConformanceMode",
+ "switch": "permissive-",
+ "comment": "Conformance mode enabled",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ConformanceMode",
+ "switch": "permissive",
+ "comment": "Conformance mode disabled",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWChar_tAsBuiltInType",
+ "switch": "Zc:wchar_t-",
+ "comment": "Treat WChar_t As Built in Type",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWChar_tAsBuiltInType",
+ "switch": "Zc:wchar_t",
+ "comment": "Treat WChar_t As Built in Type",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ForceConformanceInForLoopScope",
+ "switch": "Zc:forScope-",
+ "comment": "Force Conformance in For Loop Scope",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "ForceConformanceInForLoopScope",
+ "switch": "Zc:forScope",
+ "comment": "Force Conformance in For Loop Scope",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RemoveUnreferencedCodeData",
+ "switch": "Zc:inline-",
+ "comment": "Remove unreferenced code and data",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RemoveUnreferencedCodeData",
+ "switch": "Zc:inline",
+ "comment": "Remove unreferenced code and data",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnforceTypeConversionRules",
+ "switch": "Zc:rvalueCast-",
+ "comment": "Enforce type conversion rules",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnforceTypeConversionRules",
+ "switch": "Zc:rvalueCast",
+ "comment": "Enforce type conversion rules",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RuntimeTypeInfo",
+ "switch": "GR-",
+ "comment": "Enable Run-Time Type Information",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RuntimeTypeInfo",
+ "switch": "GR",
+ "comment": "Enable Run-Time Type Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OpenMPSupport",
+ "switch": "openmp-",
+ "comment": "Open MP Support",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OpenMPSupport",
+ "switch": "openmp",
+ "comment": "Open MP Support",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableModules",
+ "switch": "experimental:module",
+ "comment": "Enable C++ Modules (experimental)",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ExpandAttributedSource",
+ "switch": "Fx",
+ "comment": "Expand Attributed Source",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseUnicodeForAssemblerListing",
+ "switch": "FAu",
+ "comment": "Use Unicode For Assembler Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateXMLDocumentationFiles",
+ "switch": "doc",
+ "comment": "Generate XML Documentation Files",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "BrowseInformation",
+ "switch": "FR",
+ "comment": "Enable Browse Information",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "ShowIncludes",
+ "switch": "showIncludes",
+ "comment": "Show Includes",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnablePREfast",
+ "switch": "analyze-",
+ "comment": "Enable Code Analysis",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnablePREfast",
+ "switch": "analyze",
+ "comment": "Enable Code Analysis",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseFullPaths",
+ "switch": "FC",
+ "comment": "Use Full Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OmitDefaultLibName",
+ "switch": "Zl",
+ "comment": "Omit Default Library Name",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalIncludeDirectories",
+ "switch": "I",
+ "comment": "Additional Include Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalUsingDirectories",
+ "switch": "AI",
+ "comment": "Additional #using Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "UndefinePreprocessorDefinitions",
+ "switch": "U",
+ "comment": "Undefine Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "DisableSpecificWarnings",
+ "switch": "wd",
+ "comment": "Disable Specific Warnings",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForcedIncludeFiles",
+ "switch": "FI",
+ "comment": "Forced Include File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForcedUsingFiles",
+ "switch": "FU",
+ "comment": "Forced #using File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "PREfastLog",
+ "switch": "analyze:log",
+ "comment": "Code Analysis Log",
+ "value": "",
+ "flags": [
+ "UserFollowing"
+ ]
+ },
+ {
+ "name": "PREfastAdditionalPlugins",
+ "switch": "analyze:plugin",
+ "comment": "Additional Code Analysis Native plugins",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "TreatSpecificWarningsAsErrors",
+ "switch": "we",
+ "comment": "Treat Specific Warnings As Errors",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "WarningVersion",
+ "switch": "Wv:",
+ "comment": "Warning Version",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "PreprocessOutputPath",
+ "switch": "Fi",
+ "comment": "Preprocess Output Path",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderFile",
+ "switch": "Yu",
+ "comment": "Precompiled Header File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderFile",
+ "switch": "Yc",
+ "comment": "Precompiled Header File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "PrecompiledHeaderOutputFile",
+ "switch": "Fp",
+ "comment": "Precompiled Header Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "AssemblerListingLocation",
+ "switch": "Fa",
+ "comment": "ASM List Location",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ObjectFileName",
+ "switch": "Fo",
+ "comment": "Object File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProgramDataBaseFileName",
+ "switch": "Fd",
+ "comment": "Program Database File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "XMLDocumentationFileName",
+ "switch": "doc",
+ "comment": "XML Documentation File Name",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "BrowseInformationFile",
+ "switch": "FR",
+ "comment": "Browse Information File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ProcessorNumber",
+ "switch": "MP",
+ "comment": "Number of processors",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v142_CSharp.json b/Templates/MSBuild/FlagTables/v142_CSharp.json
new file mode 100644
index 000000000..5989aea1e
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v142_CSharp.json
@@ -0,0 +1,574 @@
+[
+ {
+ "name": "ProjectName",
+ "switch": "out:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:exe",
+ "comment": "",
+ "value": "Exe",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:winexe",
+ "comment": "",
+ "value": "Winexe",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:library",
+ "comment": "",
+ "value": "Library",
+ "flags": []
+ },
+ {
+ "name": "OutputType",
+ "switch": "target:module",
+ "comment": "",
+ "value": "Module",
+ "flags": []
+ },
+ {
+ "name": "DocumentationFile",
+ "switch": "doc",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:x86",
+ "comment": "",
+ "value": "x86",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:Itanium",
+ "comment": "",
+ "value": "Itanium",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:x64",
+ "comment": "",
+ "value": "x64",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:arm",
+ "comment": "",
+ "value": "arm",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:anycpu32bitpreferred",
+ "comment": "",
+ "value": "anycpu32bitpreferred",
+ "flags": []
+ },
+ {
+ "name": "Platform",
+ "switch": "platform:anycpu",
+ "comment": "",
+ "value": "anycpu",
+ "flags": []
+ },
+ {
+ "name": "References",
+ "switch": "reference:",
+ "comment": "mit alias",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "References",
+ "switch": "reference:",
+ "comment": "dateiliste",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "AddModules",
+ "switch": "addmodule:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "Win32Resource",
+ "switch": "win32res:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ApplicationIcon",
+ "switch": "win32icon:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "ApplicationManifest",
+ "switch": "win32manifest:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "NoWin32Manifest",
+ "switch": "nowin32manifest",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DefineDebug",
+ "switch": "debug",
+ "comment": "",
+ "value": "true",
+ "flags": [
+ "Continue"
+ ]
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DebugSymbols",
+ "switch": "debug+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:none",
+ "comment": "",
+ "value": "none",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:full",
+ "comment": "",
+ "value": "full",
+ "flags": []
+ },
+ {
+ "name": "DebugType",
+ "switch": "debug:pdbonly",
+ "comment": "",
+ "value": "pdbonly",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "Optimize",
+ "switch": "optimize+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "warnaserror+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror-",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningsAsErrors",
+ "switch": "warnaserror+",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:0",
+ "comment": "",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:1",
+ "comment": "",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:2",
+ "comment": "",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:3",
+ "comment": "",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "warn:4",
+ "comment": "",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "NoWarn",
+ "switch": "nowarn:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired",
+ "CommaAppendable"
+ ]
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CheckForOverflowUnderflow",
+ "switch": "checked+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AllowUnsafeBlocks",
+ "switch": "unsafe+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DefineConstants",
+ "switch": "define:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "SemicolonAppendable",
+ "UserValue"
+ ]
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:ISO-1",
+ "comment": "",
+ "value": "ISO-1",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:ISO-2",
+ "comment": "",
+ "value": "ISO-2",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:3",
+ "comment": "",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:4",
+ "comment": "",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:5",
+ "comment": "",
+ "value": "5",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:6",
+ "comment": "",
+ "value": "6",
+ "flags": []
+ },
+ {
+ "name": "LangVersion",
+ "switch": "langversion:default",
+ "comment": "",
+ "value": "default",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DelaySign",
+ "switch": "delaysign+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AssemblyOriginatorKeyFile",
+ "switch": "keyfile",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "KeyContainerName",
+ "switch": "keycontainer",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoLogo",
+ "switch": "nologo",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoConfig",
+ "switch": "noconfig",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "BaseAddress",
+ "switch": "baseaddress:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "CodePage",
+ "switch": "codepage",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "Utf8Output",
+ "switch": "utf8output",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "MainEntryPoint",
+ "switch": "main:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "GenerateFullPaths",
+ "switch": "fullpaths",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FileAlignment",
+ "switch": "filealign",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "PdbFile",
+ "switch": "pdb:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib-",
+ "comment": "",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "NoStandardLib",
+ "switch": "nostdlib+",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SubsystemVersion",
+ "switch": "subsystemversion",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibPaths",
+ "switch": "lib:",
+ "comment": "",
+ "value": "",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:none",
+ "comment": "Do Not Send Report",
+ "value": "none",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:prompt",
+ "comment": "Prompt Immediately",
+ "value": "prompt",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:queue",
+ "comment": "Queue For Next Login",
+ "value": "queue",
+ "flags": []
+ },
+ {
+ "name": "ErrorReport",
+ "switch": "errorreport:send",
+ "comment": "Send Automatically",
+ "value": "send",
+ "flags": []
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v142_Link.json b/Templates/MSBuild/FlagTables/v142_Link.json
new file mode 100644
index 000000000..66ee76fcb
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v142_Link.json
@@ -0,0 +1,1323 @@
+[
+ {
+ "name": "ShowProgress",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE",
+ "comment": "Display all progress messages",
+ "value": "LinkVerbose",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:Lib",
+ "comment": "For Libraries Searched",
+ "value": "LinkVerboseLib",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:ICF",
+ "comment": "About COMDAT folding during optimized linking",
+ "value": "LinkVerboseICF",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:REF",
+ "comment": "About data removed during optimized linking",
+ "value": "LinkVerboseREF",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:SAFESEH",
+ "comment": "About Modules incompatible with SEH",
+ "value": "LinkVerboseSAFESEH",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "VERBOSE:CLR",
+ "comment": "About linker activity related to managed code",
+ "value": "LinkVerboseCLR",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE:MULTIPLE",
+ "comment": "Multiply Defined Symbol Only",
+ "value": "MultiplyDefinedSymbolOnly",
+ "flags": []
+ },
+ {
+ "name": "ForceFileOutput",
+ "switch": "FORCE:UNRESOLVED",
+ "comment": "Undefined Symbol Only",
+ "value": "UndefinedSymbolOnly",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:5",
+ "comment": "X86 Image Only",
+ "value": "X86Image",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:6",
+ "comment": "X64 Image Only",
+ "value": "X64Image",
+ "flags": []
+ },
+ {
+ "name": "CreateHotPatchableImage",
+ "switch": "FUNCTIONPADMIN:16",
+ "comment": "Itanium Image Only",
+ "value": "ItaniumImage",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='asInvoker'",
+ "comment": "asInvoker",
+ "value": "AsInvoker",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='highestAvailable'",
+ "comment": "highestAvailable",
+ "value": "HighestAvailable",
+ "flags": []
+ },
+ {
+ "name": "UACExecutionLevel",
+ "switch": "level='requireAdministrator'",
+ "comment": "requireAdministrator",
+ "value": "RequireAdministrator",
+ "flags": []
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG",
+ "comment": "Generate Debug Information",
+ "value": "true",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG:FASTLINK",
+ "comment": "Generate Debug Information optimized for faster links",
+ "value": "DebugFastLink",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG:FULL",
+ "comment": "Generate Debug Information optimized for sharing and publishing",
+ "value": "DebugFull",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "DEBUG:NONE",
+ "comment": "Produces no debugging information",
+ "value": "false",
+ "flags": [
+ "CaseInsensitive"
+ ]
+ },
+ {
+ "name": "SubSystem",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:CONSOLE",
+ "comment": "Console",
+ "value": "Console",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWS",
+ "comment": "Windows",
+ "value": "Windows",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:NATIVE",
+ "comment": "Native",
+ "value": "Native",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_APPLICATION",
+ "comment": "EFI Application",
+ "value": "EFI Application",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+ "comment": "EFI Boot Service Driver",
+ "value": "EFI Boot Service Driver",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_ROM",
+ "comment": "EFI ROM",
+ "value": "EFI ROM",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_RUNTIME_DRIVER",
+ "comment": "EFI Runtime",
+ "value": "EFI Runtime",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:POSIX",
+ "comment": "POSIX",
+ "value": "POSIX",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "Driver",
+ "comment": "Driver",
+ "value": "Driver",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "DRIVER:UPONLY",
+ "comment": "UP Only",
+ "value": "UpOnly",
+ "flags": []
+ },
+ {
+ "name": "Driver",
+ "switch": "DRIVER:WDM",
+ "comment": "WDM",
+ "value": "WDM",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "",
+ "comment": "Default",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:incremental",
+ "comment": "Use Fast Link Time Code Generation",
+ "value": "UseFastLinkTimeCodeGeneration",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG",
+ "comment": "Use Link Time Code Generation",
+ "value": "UseLinkTimeCodeGeneration",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGInstrument",
+ "comment": "Profile Guided Optimization - Instrument",
+ "value": "PGInstrument",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGOptimize",
+ "comment": "Profile Guided Optimization - Optimization",
+ "value": "PGOptimization",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG:PGUpdate",
+ "comment": "Profile Guided Optimization - Update",
+ "value": "PGUpdate",
+ "flags": []
+ },
+ {
+ "name": "GenerateWindowsMetadata",
+ "switch": "WINMD",
+ "comment": "Yes",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateWindowsMetadata",
+ "switch": "WINMD:NO",
+ "comment": "No",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA1",
+ "comment": "SHA1",
+ "value": "SHA1",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA256",
+ "comment": "SHA256",
+ "value": "SHA256",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA384",
+ "comment": "SHA384",
+ "value": "SHA384",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataSignHash",
+ "switch": "WINMDSIGNHASH:SHA512",
+ "comment": "SHA512",
+ "value": "SHA512",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "",
+ "comment": "Not Set",
+ "value": "NotSet",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:ARM",
+ "comment": "MachineARM",
+ "value": "MachineARM",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:ARM64",
+ "comment": "MachineARM64",
+ "value": "MachineARM64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:EBC",
+ "comment": "MachineEBC",
+ "value": "MachineEBC",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:IA64",
+ "comment": "MachineIA64",
+ "value": "MachineIA64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS",
+ "comment": "MachineMIPS",
+ "value": "MachineMIPS",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS16",
+ "comment": "MachineMIPS16",
+ "value": "MachineMIPS16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU",
+ "comment": "MachineMIPSFPU",
+ "value": "MachineMIPSFPU",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU16",
+ "comment": "MachineMIPSFPU16",
+ "value": "MachineMIPSFPU16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:SH4",
+ "comment": "MachineSH4",
+ "value": "MachineSH4",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:THUMB",
+ "comment": "MachineTHUMB",
+ "value": "MachineTHUMB",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X64",
+ "comment": "MachineX64",
+ "value": "MachineX64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X86",
+ "comment": "MachineX86",
+ "value": "MachineX86",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:MTA",
+ "comment": "MTA threading attribute",
+ "value": "MTAThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:STA",
+ "comment": "STA threading attribute",
+ "value": "STAThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRThreadAttribute",
+ "switch": "CLRTHREADATTRIBUTE:NONE",
+ "comment": "Default threading attribute",
+ "value": "DefaultThreadingAttribute",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:IJW",
+ "comment": "Force IJW image",
+ "value": "ForceIJWImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:PURE",
+ "comment": "Force Pure IL Image",
+ "value": "ForcePureILImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "CLRIMAGETYPE:SAFE",
+ "comment": "Force Safe IL Image",
+ "value": "ForceSafeILImage",
+ "flags": []
+ },
+ {
+ "name": "CLRImageType",
+ "switch": "",
+ "comment": "Default image type",
+ "value": "Default",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA1",
+ "comment": "SHA1",
+ "value": "SHA1",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA256",
+ "comment": "SHA256",
+ "value": "SHA256",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA384",
+ "comment": "SHA384",
+ "value": "SHA384",
+ "flags": []
+ },
+ {
+ "name": "SignHash",
+ "switch": "CLRSIGNHASH:SHA512",
+ "comment": "SHA512",
+ "value": "SHA512",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:PROMPT",
+ "comment": "PromptImmediately",
+ "value": "PromptImmediately",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:QUEUE",
+ "comment": "Queue For Next Login",
+ "value": "QueueForNextLogin",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:SEND",
+ "comment": "Send Error Report",
+ "value": "SendErrorReport",
+ "flags": []
+ },
+ {
+ "name": "LinkErrorReporting",
+ "switch": "ERRORREPORT:NONE",
+ "comment": "No Error Report",
+ "value": "NoErrorReport",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError",
+ "comment": "Enabled",
+ "value": "Enabled",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError:NO",
+ "comment": "Disabled",
+ "value": "Disabled",
+ "flags": []
+ },
+ {
+ "name": "CLRSupportLastError",
+ "switch": "CLRSupportLastError:SYSTEMDLL",
+ "comment": "System Dlls Only",
+ "value": "SystemDlls",
+ "flags": []
+ },
+ {
+ "name": "LinkIncremental",
+ "switch": "INCREMENTAL:NO",
+ "comment": "Enable Incremental Linking",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkIncremental",
+ "switch": "INCREMENTAL",
+ "comment": "Enable Incremental Linking",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "NOLOGO",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkStatus",
+ "switch": "LTCG:NOSTATUS",
+ "comment": "Link Status",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkStatus",
+ "switch": "LTCG:STATUS",
+ "comment": "Link Status",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreventDllBinding",
+ "switch": "ALLOWBIND:NO",
+ "comment": "Prevent Dll Binding",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "PreventDllBinding",
+ "switch": "ALLOWBIND",
+ "comment": "Prevent Dll Binding",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatLinkerWarningAsErrors",
+ "switch": "WX:NO",
+ "comment": "Treat Linker Warning As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatLinkerWarningAsErrors",
+ "switch": "WX",
+ "comment": "Treat Linker Warning As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreAllDefaultLibraries",
+ "switch": "NODEFAULTLIB",
+ "comment": "Ignore All Default Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateManifest",
+ "switch": "MANIFEST:NO",
+ "comment": "Generate Manifest",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "GenerateManifest",
+ "switch": "MANIFEST",
+ "comment": "Generate Manifest",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AllowIsolation",
+ "switch": "ALLOWISOLATION:NO",
+ "comment": "Allow Isolation",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AllowIsolation",
+ "switch": "",
+ "comment": "Allow Isolation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableUAC",
+ "switch": "MANIFESTUAC:",
+ "comment": "",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired",
+ "SpaceAppendable"
+ ]
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='false'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "false",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='false'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "UACUIAccess",
+ "switch": "uiAccess='true'",
+ "comment": "UAC Bypass UI Protection",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ManifestEmbed",
+ "switch": "manifest:embed",
+ "comment": "Embed Manifest",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateMapFile",
+ "switch": "MAP",
+ "comment": "Generate Map File",
+ "value": "true",
+ "flags": [
+ "UserValue",
+ "UserIgnored",
+ "Continue"
+ ]
+ },
+ {
+ "name": "MapExports",
+ "switch": "MAPINFO:EXPORTS",
+ "comment": "Map Exports",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AssemblyDebug",
+ "switch": "ASSEMBLYDEBUG:DISABLE",
+ "comment": "Debuggable Assembly",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "AssemblyDebug",
+ "switch": "ASSEMBLYDEBUG",
+ "comment": "Debuggable Assembly",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LargeAddressAware",
+ "switch": "LARGEADDRESSAWARE:NO",
+ "comment": "Enable Large Addresses",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LargeAddressAware",
+ "switch": "LARGEADDRESSAWARE",
+ "comment": "Enable Large Addresses",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TerminalServerAware",
+ "switch": "TSAWARE:NO",
+ "comment": "Terminal Server",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TerminalServerAware",
+ "switch": "TSAWARE",
+ "comment": "Terminal Server",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SwapRunFromCD",
+ "switch": "SWAPRUN:CD",
+ "comment": "Swap Run From CD",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SwapRunFromNET",
+ "switch": "SWAPRUN:NET",
+ "comment": "Swap Run From Network",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "OptimizeReferences",
+ "switch": "OPT:NOREF",
+ "comment": "References",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "OptimizeReferences",
+ "switch": "OPT:REF",
+ "comment": "References",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableCOMDATFolding",
+ "switch": "OPT:NOICF",
+ "comment": "Enable COMDAT Folding",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "EnableCOMDATFolding",
+ "switch": "OPT:ICF",
+ "comment": "Enable COMDAT Folding",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreEmbeddedIDL",
+ "switch": "IGNOREIDL",
+ "comment": "Ignore Embedded IDL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AppContainer",
+ "switch": "APPCONTAINER",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataLinkDelaySign",
+ "switch": "WINMDDELAYSIGN:NO",
+ "comment": "Windows Metadata Delay Sign",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "WindowsMetadataLinkDelaySign",
+ "switch": "WINMDDELAYSIGN",
+ "comment": "Windows Metadata Delay Sign",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NoEntryPoint",
+ "switch": "NOENTRY",
+ "comment": "No Entry Point",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SetChecksum",
+ "switch": "RELEASE",
+ "comment": "Set Checksum",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "RandomizedBaseAddress",
+ "switch": "DYNAMICBASE:NO",
+ "comment": "Randomized Base Address",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "RandomizedBaseAddress",
+ "switch": "DYNAMICBASE",
+ "comment": "Randomized Base Address",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "FixedBaseAddress",
+ "switch": "FIXED:NO",
+ "comment": "Fixed Base Address",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "FixedBaseAddress",
+ "switch": "FIXED",
+ "comment": "Fixed Base Address",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DataExecutionPrevention",
+ "switch": "NXCOMPAT:NO",
+ "comment": "Data Execution Prevention (DEP)",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "DataExecutionPrevention",
+ "switch": "NXCOMPAT",
+ "comment": "Data Execution Prevention (DEP)",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TurnOffAssemblyGeneration",
+ "switch": "NOASSEMBLY",
+ "comment": "Turn Off Assembly Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SupportUnloadOfDelayLoadedDLL",
+ "switch": "DELAY:UNLOAD",
+ "comment": "Unload delay loaded DLL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SupportNobindOfDelayLoadedDLL",
+ "switch": "DELAY:NOBIND",
+ "comment": "Nobind delay loaded DLL",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Profile",
+ "switch": "PROFILE",
+ "comment": "Profile",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkDelaySign",
+ "switch": "DELAYSIGN:NO",
+ "comment": "Delay Sign",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "LinkDelaySign",
+ "switch": "DELAYSIGN",
+ "comment": "Delay Sign",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "CLRUnmanagedCodeCheck",
+ "switch": "CLRUNMANAGEDCODECHECK:NO",
+ "comment": "CLR Unmanaged Code Check",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "CLRUnmanagedCodeCheck",
+ "switch": "CLRUNMANAGEDCODECHECK",
+ "comment": "CLR Unmanaged Code Check",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DetectOneDefinitionRule",
+ "switch": "ODR",
+ "comment": "Detect One Definition Rule violations",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ImageHasSafeExceptionHandlers",
+ "switch": "SAFESEH:NO",
+ "comment": "Image Has Safe Exception Handlers",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "ImageHasSafeExceptionHandlers",
+ "switch": "SAFESEH",
+ "comment": "Image Has Safe Exception Handlers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkDLL",
+ "switch": "DLL",
+ "comment": "",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibraryDirectories",
+ "switch": "LIBPATH:",
+ "comment": "Additional Library Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "Natvis",
+ "switch": "NATVIS:",
+ "comment": "Natvis files",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IgnoreSpecificDefaultLibraries",
+ "switch": "NODEFAULTLIB:",
+ "comment": "Ignore Specific Default Libraries",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AddModuleNamesToAssembly",
+ "switch": "ASSEMBLYMODULE:",
+ "comment": "Add Module to Assembly",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "EmbedManagedResourceFile",
+ "switch": "ASSEMBLYRESOURCE:",
+ "comment": "Embed Managed Resource File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ForceSymbolReferences",
+ "switch": "INCLUDE:",
+ "comment": "Force Symbol References",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "DelayLoadDLLs",
+ "switch": "DELAYLOAD:",
+ "comment": "Delay Loaded Dlls",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AssemblyLinkResource",
+ "switch": "ASSEMBLYLINKRESOURCE:",
+ "comment": "Assembly Link Resource",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalManifestDependencies",
+ "switch": "MANIFESTDEPENDENCY:",
+ "comment": "Additional Manifest Dependencies",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ManifestInput",
+ "switch": "manifestinput:",
+ "comment": "Manifest Input",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "OutputFile",
+ "switch": "OUT:",
+ "comment": "Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "Version",
+ "switch": "VERSION:",
+ "comment": "Version",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "SpecifySectionAttributes",
+ "switch": "SECTION:",
+ "comment": "Specify Section Attributes",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MSDOSStubFileName",
+ "switch": "STUB:",
+ "comment": "MS-DOS Stub File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ModuleDefinitionFile",
+ "switch": "DEF:",
+ "comment": "Module Definition File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ManifestFile",
+ "switch": "ManifestFile:",
+ "comment": "Manifest File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProgramDatabaseFile",
+ "switch": "PDB:",
+ "comment": "Generate Program Database File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "StripPrivateSymbols",
+ "switch": "PDBSTRIPPED:",
+ "comment": "Strip Private Symbols",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MapFileName",
+ "switch": "MAP:",
+ "comment": "Map File Name",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "HeapReserveSize",
+ "switch": "HEAP:",
+ "comment": "Heap Reserve Size",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "HeapCommitSize",
+ "switch": "HEAP",
+ "comment": "Heap Commit Size",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "StackReserveSize",
+ "switch": "STACK:",
+ "comment": "Stack Reserve Size",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "StackCommitSize",
+ "switch": "STACK",
+ "comment": "Stack Commit Size",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "UserRequired"
+ ]
+ },
+ {
+ "name": "FunctionOrder",
+ "switch": "ORDER:@",
+ "comment": "Function Order",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ProfileGuidedDatabase",
+ "switch": "PGD:",
+ "comment": "Profile Guided Database",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MidlCommandFile",
+ "switch": "MIDL:@",
+ "comment": "MIDL Commands",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MergedIDLBaseFileName",
+ "switch": "IDLOUT:",
+ "comment": "Merged IDL Base File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "TypeLibraryFile",
+ "switch": "TLBOUT:",
+ "comment": "Type Library",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataFile",
+ "switch": "WINMDFILE:",
+ "comment": "Windows Metadata File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataLinkKeyFile",
+ "switch": "WINMDKEYFILE:",
+ "comment": "Windows Metadata Key File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "WindowsMetadataKeyContainer",
+ "switch": "WINMDKEYCONTAINER:",
+ "comment": "Windows Metadata Key Container",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "EntryPointSymbol",
+ "switch": "ENTRY:",
+ "comment": "Entry Point",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "BaseAddress",
+ "switch": "BASE:",
+ "comment": "Base Address",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ImportLibrary",
+ "switch": "IMPLIB:",
+ "comment": "Import Library",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "MergeSections",
+ "switch": "MERGE:",
+ "comment": "Merge Sections",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "LinkKeyFile",
+ "switch": "KEYFILE:",
+ "comment": "Key File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "KeyContainer",
+ "switch": "KEYCONTAINER:",
+ "comment": "Key Container",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "TypeLibraryResourceID",
+ "switch": "TLBID:",
+ "comment": "TypeLib Resource ID",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "SectionAlignment",
+ "switch": "ALIGN:",
+ "comment": "SectionAlignment",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v14_LIB.json b/Templates/MSBuild/FlagTables/v14_LIB.json
new file mode 100644
index 000000000..5990ed1b7
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v14_LIB.json
@@ -0,0 +1,304 @@
+[
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:PROMPT",
+ "comment": "PromptImmediately",
+ "value": "PromptImmediately",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:QUEUE",
+ "comment": "Queue For Next Login",
+ "value": "QueueForNextLogin",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:SEND",
+ "comment": "Send Error Report",
+ "value": "SendErrorReport",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "ERRORREPORT:NONE",
+ "comment": "No Error Report",
+ "value": "NoErrorReport",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:ARM",
+ "comment": "MachineARM",
+ "value": "MachineARM",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:ARM64",
+ "comment": "MachineARM64",
+ "value": "MachineARM64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:EBC",
+ "comment": "MachineEBC",
+ "value": "MachineEBC",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:IA64",
+ "comment": "MachineIA64",
+ "value": "MachineIA64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS",
+ "comment": "MachineMIPS",
+ "value": "MachineMIPS",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPS16",
+ "comment": "MachineMIPS16",
+ "value": "MachineMIPS16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU",
+ "comment": "MachineMIPSFPU",
+ "value": "MachineMIPSFPU",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:MIPSFPU16",
+ "comment": "MachineMIPSFPU16",
+ "value": "MachineMIPSFPU16",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:SH4",
+ "comment": "MachineSH4",
+ "value": "MachineSH4",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:THUMB",
+ "comment": "MachineTHUMB",
+ "value": "MachineTHUMB",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X64",
+ "comment": "MachineX64",
+ "value": "MachineX64",
+ "flags": []
+ },
+ {
+ "name": "TargetMachine",
+ "switch": "MACHINE:X86",
+ "comment": "MachineX86",
+ "value": "MachineX86",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:CONSOLE",
+ "comment": "Console",
+ "value": "Console",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWS",
+ "comment": "Windows",
+ "value": "Windows",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:NATIVE",
+ "comment": "Native",
+ "value": "Native",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_APPLICATION",
+ "comment": "EFI Application",
+ "value": "EFI Application",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER",
+ "comment": "EFI Boot Service Driver",
+ "value": "EFI Boot Service Driver",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_ROM",
+ "comment": "EFI ROM",
+ "value": "EFI ROM",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:EFI_RUNTIME_DRIVER",
+ "comment": "EFI Runtime",
+ "value": "EFI Runtime",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:WINDOWSCE",
+ "comment": "WindowsCE",
+ "value": "WindowsCE",
+ "flags": []
+ },
+ {
+ "name": "SubSystem",
+ "switch": "SUBSYSTEM:POSIX",
+ "comment": "POSIX",
+ "value": "POSIX",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "NOLOGO",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "IgnoreAllDefaultLibraries",
+ "switch": "NODEFAULTLIB",
+ "comment": "Ignore All Default Libraries",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatLibWarningAsErrors",
+ "switch": "WX:NO",
+ "comment": "Treat Lib Warning As Errors",
+ "value": "false",
+ "flags": []
+ },
+ {
+ "name": "TreatLibWarningAsErrors",
+ "switch": "WX",
+ "comment": "Treat Lib Warning As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "Verbose",
+ "switch": "VERBOSE",
+ "comment": "Verbose",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "LinkTimeCodeGeneration",
+ "switch": "LTCG",
+ "comment": "Link Time Code Generation",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AdditionalLibraryDirectories",
+ "switch": "LIBPATH:",
+ "comment": "Additional Library Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IgnoreSpecificDefaultLibraries",
+ "switch": "NODEFAULTLIB:",
+ "comment": "Ignore Specific Default Libraries",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ExportNamedFunctions",
+ "switch": "EXPORT:",
+ "comment": "Export Named Functions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "RemoveObjects",
+ "switch": "REMOVE:",
+ "comment": "Remove Objects",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "OutputFile",
+ "switch": "OUT:",
+ "comment": "Output File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ModuleDefinitionFile",
+ "switch": "DEF:",
+ "comment": "Module Definition File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "ForceSymbolReferences",
+ "switch": "INCLUDE:",
+ "comment": "Force Symbol References",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "DisplayLibrary",
+ "switch": "LIST:",
+ "comment": "Display Library to standard output",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "Name",
+ "switch": "NAME:",
+ "comment": "Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v14_MASM.json b/Templates/MSBuild/FlagTables/v14_MASM.json
new file mode 100644
index 000000000..4634306b1
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v14_MASM.json
@@ -0,0 +1,295 @@
+[
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "",
+ "comment": "Default",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "Cp",
+ "comment": "Preserves Identifier Case (/Cp)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "Cu",
+ "comment": "Maps all identifiers to upper case. (/Cu)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "PreserveIdentifierCase",
+ "switch": "Cx",
+ "comment": "Preserves case in public and extern symbols. (/Cx)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W0",
+ "comment": "Warning Level 0 (/W0)",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W1",
+ "comment": "Warning Level 1 (/W1)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W2",
+ "comment": "Warning Level 2 (/W2)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "WarningLevel",
+ "switch": "W3",
+ "comment": "Warning Level 3 (/W3)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "",
+ "comment": "Default",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp1",
+ "comment": "One Byte Boundary (/Zp1)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp2",
+ "comment": "Two Byte Boundary (/Zp2)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp4",
+ "comment": "Four Byte Boundary (/Zp4)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp8",
+ "comment": "Eight Byte Boundary (/Zp8)",
+ "value": "4",
+ "flags": []
+ },
+ {
+ "name": "PackAlignmentBoundary",
+ "switch": "Zp16",
+ "comment": "Sixteen Byte Boundary (/Zp16)",
+ "value": "5",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "",
+ "comment": "Default",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gd",
+ "comment": "Use C-style Calling Convention (/Gd)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gz",
+ "comment": "Use stdcall Calling Convention (/Gz)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "CallingConvention",
+ "switch": "Gc",
+ "comment": "Use Pascal Calling Convention (/Gc)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:prompt",
+ "comment": "Prompt to send report immediately (/errorReport:prompt)",
+ "value": "0",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:queue",
+ "comment": "Prompt to send report at the next logon (/errorReport:queue)",
+ "value": "1",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:send",
+ "comment": "Automatically send report (/errorReport:send)",
+ "value": "2",
+ "flags": []
+ },
+ {
+ "name": "ErrorReporting",
+ "switch": "errorReport:none",
+ "comment": "Do not send report (/errorReport:none)",
+ "value": "3",
+ "flags": []
+ },
+ {
+ "name": "NoLogo",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GeneratePreprocessedSourceListing",
+ "switch": "EP",
+ "comment": "Generate Preprocessed Source Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ListAllAvailableInformation",
+ "switch": "Sa",
+ "comment": "List All Available Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "UseSafeExceptionHandlers",
+ "switch": "safeseh",
+ "comment": "Use Safe Exception Handlers",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "AddFirstPassListing",
+ "switch": "Sf",
+ "comment": "Add First Pass Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableAssemblyGeneratedCodeListing",
+ "switch": "Sg",
+ "comment": "Enable Assembly Generated Code Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "DisableSymbolTable",
+ "switch": "Sn",
+ "comment": "Disable Symbol Table",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableFalseConditionalsInListing",
+ "switch": "Sx",
+ "comment": "Enable False Conditionals In Listing",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "TreatWarningsAsErrors",
+ "switch": "WX",
+ "comment": "Treat Warnings As Errors",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "MakeAllSymbolsPublic",
+ "switch": "Zf",
+ "comment": "Make All Symbols Public",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "GenerateDebugInformation",
+ "switch": "Zi",
+ "comment": "Generate Debug Information",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "EnableMASM51Compatibility",
+ "switch": "Zm",
+ "comment": "Enable MASM 5.1 Compatibility",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PerformSyntaxCheckOnly",
+ "switch": "Zs",
+ "comment": "Perform Syntax Check Only",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "IncludePaths",
+ "switch": "I",
+ "comment": "Include Paths",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "BrowseFile",
+ "switch": "FR",
+ "comment": "Generate Browse Information File",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ObjectFileName",
+ "switch": "Fo",
+ "comment": "Object File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ },
+ {
+ "name": "AssembledCodeListingFile",
+ "switch": "Fl",
+ "comment": "Assembled Code Listing File",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/FlagTables/v14_RC.json b/Templates/MSBuild/FlagTables/v14_RC.json
new file mode 100644
index 000000000..b8c0127d1
--- /dev/null
+++ b/Templates/MSBuild/FlagTables/v14_RC.json
@@ -0,0 +1,69 @@
+[
+ {
+ "name": "IgnoreStandardIncludePath",
+ "switch": "X",
+ "comment": "Ignore Standard Include Paths",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "ShowProgress",
+ "switch": "v",
+ "comment": "Show Progress",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "SuppressStartupBanner",
+ "switch": "nologo",
+ "comment": "Suppress Startup Banner",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "NullTerminateStrings",
+ "switch": "n",
+ "comment": "Null Terminate Strings",
+ "value": "true",
+ "flags": []
+ },
+ {
+ "name": "PreprocessorDefinitions",
+ "switch": "D",
+ "comment": "Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "UndefinePreprocessorDefinitions",
+ "switch": "u",
+ "comment": "Undefine Preprocessor Definitions",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "AdditionalIncludeDirectories",
+ "switch": "I",
+ "comment": "Additional Include Directories",
+ "value": "",
+ "flags": [
+ "UserValue",
+ "SemicolonAppendable"
+ ]
+ },
+ {
+ "name": "ResourceOutputFileName",
+ "switch": "fo",
+ "comment": "Resource File Name",
+ "value": "",
+ "flags": [
+ "UserValue"
+ ]
+ }
+]
diff --git a/Templates/MSBuild/nasm.xml b/Templates/MSBuild/nasm.xml
index 92f8548c3..a5dcdd5e2 100644
--- a/Templates/MSBuild/nasm.xml
+++ b/Templates/MSBuild/nasm.xml
@@ -36,7 +36,7 @@
<DataSource Persistence="ProjectFile" ItemType="NASM" SourceType="Item"/>
</StringProperty.DataSource>
</StringProperty>
- <StringProperty Name="OutputFormat" Category="Assembler Options" HelpUrl="http://www.nasm.us/doc/" DisplayName="Output File Name" Description="Specify Output Filename.-o [value]" Switch="-o [value]"/>
+ <StringProperty Name="OutputFormat" Category="Assembler Options" HelpUrl="http://www.nasm.us/doc/" DisplayName="Output File Name" Description="Specify Output Filename.-o [value]" Switch="-o &quot;[value]&quot;"/>
<BoolProperty Name="tasmmode" Category="Advanced" HelpUrl="http://www.nasm.us/doc/" DisplayName="SciTech TASM compatible mode" Description="assemble in SciTech TASM compatible mode" Switch="-t"/>
<EnumProperty Name="Outputswitch" Category="Assembler Options" HelpUrl="http://www.nasm.us/doc/" DisplayName="Output Switch" Description="Select the type of output format required. Linking Should be disabled for ELF and Binary ,else error will popup">
<EnumValue Name="0" DisplayName="Object File win32" Switch="-fwin32"/>
@@ -48,8 +48,8 @@
<BoolProperty Name="GenerateDebugInformation" Category="Assembler Options" DisplayName="Generate Debug Information" Description="Generates Debug Information. (-g)" HelpUrl="http://www.nasm.us/doc/" Switch="-g"/>
<StringListProperty Name="ErrorReporting" Category="Advanced" HelpUrl="http://www.nasm.us/doc/" DisplayName="Redirect Error Messages to File" Description="Drops the error Message on specified device" Switch="-Z &quot;[value]&quot;"/>
<StringListProperty Name="IncludePaths" Category="General" DisplayName="Include Paths" Description="Sets path for include file. (-I[path])" HelpUrl="http://www.nasm.us/doc/" Switch="-I&quot;[value]&quot;"/>
- <StringListProperty Name="PreprocessorDefinitions" Category="Preprocessor" HelpUrl="http://www.nasm.us/doc/" DisplayName="Preprocessor Definitions" Description="Defines a text macro with the given name. (-D[symbol])" Switch="-D[value]"/>
- <StringListProperty Name="UndefinePreprocessorDefinitions" Category="Preprocessor" HelpUrl="http://www.nasm.us/doc/" DisplayName="Undefine Preprocessor Definitions" Description="Undefines a text macro with the given name. (-U[symbol])" Switch="-U[value]"/>
+ <StringListProperty Name="PreprocessorDefinitions" Category="Preprocessor" HelpUrl="http://www.nasm.us/doc/" DisplayName="Preprocessor Definitions" Description="Defines a text macro with the given name. (-D[symbol])" Switch="-D&quot;[value]&quot;"/>
+ <StringListProperty Name="UndefinePreprocessorDefinitions" Category="Preprocessor" HelpUrl="http://www.nasm.us/doc/" DisplayName="Undefine Preprocessor Definitions" Description="Undefines a text macro with the given name. (-U[symbol])" Switch="-U&quot;[value]&quot;"/>
<EnumProperty Name="ErrorReportingFormat" Category="Advanced" HelpUrl="http://www.nasm.us/doc/" DisplayName="Error Reporting Format" Description="Select the error reporting format ie. GNU or VC">
<EnumValue Name="0" DisplayName="-Xgnu GNU format: Default format" Switch="-Xgnu"/>
<EnumValue Name="1" DisplayName="-Xvc Style used by Microsoft Visual C++" Switch="-Xvc"/>
diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in
index bf61be4c9..846a8285e 100644
--- a/Templates/TestDriver.cxx.in
+++ b/Templates/TestDriver.cxx.in
@@ -13,15 +13,21 @@
@CMAKE_FORWARD_DECLARE_TESTS@
#ifdef __cplusplus
-#define CM_CAST(TYPE, EXPR) static_cast<TYPE>(EXPR)
+# define CM_CAST(TYPE, EXPR) static_cast<TYPE>(EXPR)
+# if __cplusplus >= 201103L
+# define CM_NULL nullptr
+# else
+# define CM_NULL NULL
+# endif
#else
-#define CM_CAST(TYPE, EXPR) (TYPE)(EXPR)
+# define CM_CAST(TYPE, EXPR) (TYPE)(EXPR)
+# define CM_NULL NULL
#endif
/* Create map. */
-typedef int (*MainFuncPointer)(int, char* []);
-typedef struct
+typedef int (*MainFuncPointer)(int, char* []); /* NOLINT */
+typedef struct /* NOLINT */
{
const char* name;
MainFuncPointer func;
@@ -29,7 +35,7 @@ typedef struct
static functionMapEntry cmakeGeneratedFunctionMapEntries[] = {
@CMAKE_FUNCTION_TABLE_ENTIRES@
- { NULL, NULL } /* NOLINT */
+ { CM_NULL, CM_NULL } /* NOLINT */
};
static const int NumTests = CM_CAST(int,
@@ -45,10 +51,10 @@ static char* lowercase(const char* string)
stringSize = CM_CAST(size_t, strlen(string) + 1);
new_string = CM_CAST(char*, malloc(sizeof(char) * stringSize));
- if (new_string == NULL) { /* NOLINT */
- return NULL; /* NOLINT */
+ if (new_string == CM_NULL) { /* NOLINT */
+ return CM_NULL; /* NOLINT */
}
- strncpy(new_string, string, stringSize);
+ strcpy(new_string, string); /* NOLINT */
for (p = new_string; *p != 0; ++p) {
*p = CM_CAST(char, tolower(*p));
}
@@ -58,7 +64,7 @@ static char* lowercase(const char* string)
int main(int ac, char* av[])
{
int i, testNum = 0, partial_match;
- char *arg, *test_name;
+ char *arg;
int testToRun = -1;
@CMAKE_TESTDRIVER_ARGVC_FUNCTION@
@@ -86,7 +92,7 @@ int main(int ac, char* av[])
av++;
}
partial_match = 0;
- arg = NULL; /* NOLINT */
+ arg = CM_NULL; /* NOLINT */
/* If partial match is requested. */
if (testToRun == -1 && ac > 1) {
partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0;
@@ -99,8 +105,8 @@ int main(int ac, char* av[])
arg = lowercase(av[1 + partial_match]);
}
for (i = 0; i < NumTests && testToRun == -1; ++i) {
- test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name);
- if (partial_match != 0 && strstr(test_name, arg) != NULL) { /* NOLINT */
+ char *test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name);
+ if (partial_match != 0 && strstr(test_name, arg) != CM_NULL) { /* NOLINT */
testToRun = i;
ac -= 2;
av += 2;
diff --git a/Templates/Windows/ApplicationIcon.png b/Templates/Windows/ApplicationIcon.png
index 7d95d4e08..c715e1bc7 100644
--- a/Templates/Windows/ApplicationIcon.png
+++ b/Templates/Windows/ApplicationIcon.png
Binary files differ
diff --git a/Templates/Windows/Logo.png b/Templates/Windows/Logo.png
index e26771cb3..65f91ac0f 100644
--- a/Templates/Windows/Logo.png
+++ b/Templates/Windows/Logo.png
Binary files differ
diff --git a/Templates/Windows/SmallLogo.png b/Templates/Windows/SmallLogo.png
index 1eb0d9d52..460c0222d 100644
--- a/Templates/Windows/SmallLogo.png
+++ b/Templates/Windows/SmallLogo.png
Binary files differ
diff --git a/Templates/Windows/SmallLogo44x44.png b/Templates/Windows/SmallLogo44x44.png
index 28810b7c0..c2374581a 100644
--- a/Templates/Windows/SmallLogo44x44.png
+++ b/Templates/Windows/SmallLogo44x44.png
Binary files differ
diff --git a/Templates/Windows/SplashScreen.png b/Templates/Windows/SplashScreen.png
index c951e031b..834256580 100644
--- a/Templates/Windows/SplashScreen.png
+++ b/Templates/Windows/SplashScreen.png
Binary files differ
diff --git a/Templates/Windows/StoreLogo.png b/Templates/Windows/StoreLogo.png
index dcb672712..508c8a809 100644
--- a/Templates/Windows/StoreLogo.png
+++ b/Templates/Windows/StoreLogo.png
Binary files differ
diff --git a/Tests/AliasTarget/CMakeLists.txt b/Tests/AliasTarget/CMakeLists.txt
index e156420db..fc7013598 100644
--- a/Tests/AliasTarget/CMakeLists.txt
+++ b/Tests/AliasTarget/CMakeLists.txt
@@ -4,13 +4,6 @@ project(AliasTarget)
set(CMAKE_CXX_STANDARD 98)
-# Those versions of the HP compiler that need a flag to get proper C++98
-# template support also need a flag to use the newer C++ library.
-if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
- CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98")
- string(APPEND CMAKE_CXX_FLAGS " -AA")
-endif ()
-
# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
diff --git a/Tests/AliasTarget/bat.cpp b/Tests/AliasTarget/bat.cpp
index cb76bfe2f..14942bf1c 100644
--- a/Tests/AliasTarget/bat.cpp
+++ b/Tests/AliasTarget/bat.cpp
@@ -1,22 +1,22 @@
#ifndef FOO_DEFINE
-#error Expected FOO_DEFINE
+# error Expected FOO_DEFINE
#endif
#ifndef BAR_DEFINE
-#error Expected Bar_DEFINE
+# error Expected Bar_DEFINE
#endif
#include "commandoutput.h"
#ifndef COMMANDOUTPUT_DEFINE
-#error Expected COMMANDOUTPUT_DEFINE
+# error Expected COMMANDOUTPUT_DEFINE
#endif
#include "targetoutput.h"
#ifndef TARGETOUTPUT_DEFINE
-#error Expected TARGETOUTPUT_DEFINE
+# error Expected TARGETOUTPUT_DEFINE
#endif
#ifdef _WIN32
diff --git a/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt
index fb17ebb60..21b265cea 100644
--- a/Tests/Assembler/CMakeLists.txt
+++ b/Tests/Assembler/CMakeLists.txt
@@ -7,9 +7,10 @@ set(SRCS)
# (at least) the following toolchains can process assembler files directly
# and also generate assembler files from C:
-if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode" AND
+if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode|Ninja" AND
NOT CMAKE_OSX_ARCHITECTURES)
- if((CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang|HP|SunPro|XL)$") OR (CMAKE_C_COMPILER_ID STREQUAL "Intel" AND UNIX))
+ if((CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang|HP|SunPro|XL)$") OR (CMAKE_C_COMPILER_ID STREQUAL "Intel" AND UNIX)
+ AND NOT (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC"))
set(C_FLAGS "${CMAKE_C_FLAGS}")
separate_arguments(C_FLAGS)
if(CMAKE_OSX_SYSROOT AND CMAKE_C_SYSROOT_FLAG AND NOT ";${C_FLAGS};" MATCHES ";${CMAKE_C_SYSROOT_FLAG};")
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt
index 11978dbf8..c1ad17cd3 100644
--- a/Tests/BuildDepends/CMakeLists.txt
+++ b/Tests/BuildDepends/CMakeLists.txt
@@ -42,7 +42,7 @@ list(APPEND _cmake_options "-DTEST_LINK_DEPENDS=${TEST_LINK_DEPENDS}")
list(APPEND _cmake_options "-DCMAKE_FORCE_DEPFILES=1")
-if(NOT CMAKE_GENERATOR MATCHES "Visual Studio ([^89]|[89][0-9])")
+if(NOT CMAKE_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])")
set(TEST_MULTI3 1)
list(APPEND _cmake_options "-DTEST_MULTI3=1")
endif()
@@ -62,6 +62,12 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx
"static const char* zot_macro_dir = \"zot_macro_dir\";\n")
file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx
"static const char* zot_macro_tgt = \"zot_macro_tgt\";\n")
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_pch.hxx
+ "#ifndef ZOT_PCH_HXX\n"
+ "#define ZOT_PCH_HXX\n"
+ "static const char* zot_pch = \"zot_pch\";\n"
+ "#endif\n"
+ )
file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_lib.h
"#define link_depends_no_shared_lib_value 1\n")
@@ -155,7 +161,7 @@ execute_process(COMMAND ${zot} OUTPUT_VARIABLE out RESULT_VARIABLE runResult)
string(REGEX REPLACE "[\r\n]" " " out "${out}")
message("Run result: ${runResult} Output: \"${out}\"")
-set(VALUE_UNCHANGED "[zot] [zot_custom] [zot_macro_dir] [zot_macro_tgt] ")
+set(VALUE_UNCHANGED "[zot] [zot_custom] [zot_macro_dir] [zot_macro_tgt] [zot_pch] ")
if("${out}" STREQUAL "${VALUE_UNCHANGED}")
message("Worked!")
else()
@@ -245,6 +251,12 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx
"static const char* zot_macro_dir = \"zot_macro_dir changed\";\n")
file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx
"static const char* zot_macro_tgt = \"zot_macro_tgt changed\";\n")
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_pch.hxx
+ "#ifndef ZOT_PCH_HXX\n"
+ "#define ZOT_PCH_HXX\n"
+ "static const char* zot_pch = \"zot_pch changed\";\n"
+ "#endif\n"
+ )
file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_lib.h
"#define link_depends_no_shared_lib_value 0\n")
@@ -326,7 +338,7 @@ string(REGEX REPLACE "[\r\n]" " " out "${out}")
message("Run result: ${runResult} Output: \"${out}\"")
set(VALUE_CHANGED
- "[zot changed] [zot_custom changed] [zot_macro_dir changed] [zot_macro_tgt changed] "
+ "[zot changed] [zot_custom changed] [zot_macro_dir changed] [zot_macro_tgt changed] [zot_pch changed] "
)
if("${out}" STREQUAL "${VALUE_CHANGED}")
message("Worked!")
@@ -345,6 +357,17 @@ is not newer than dependency
${TEST_LINK_DEPENDS}
")
endif()
+
+ set(linkdep2 ${BuildDepends_BINARY_DIR}/Project/linkdep2${CMAKE_EXECUTABLE_SUFFIX})
+ if(${linkdep2} IS_NEWER_THAN ${TEST_LINK_DEPENDS})
+ message("INTERFACE_LINK_DEPENDS worked")
+ else()
+ message(SEND_ERROR "INTERFACE_LINK_DEPENDS failed. Executable
+ ${linkdep2}
+is not newer than dependency
+ ${TEST_LINK_DEPENDS}
+")
+ endif()
endif()
if(EXISTS "${link_depends_no_shared_check_txt}")
diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt
index 3aa57fc9e..833880098 100644
--- a/Tests/BuildDepends/Project/CMakeLists.txt
+++ b/Tests/BuildDepends/Project/CMakeLists.txt
@@ -1,30 +1,30 @@
cmake_minimum_required(VERSION 2.6)
project(testRebuild)
-function(test_for_xcode4 result_var)
- set(${result_var} 0 PARENT_SCOPE)
- if(APPLE)
- execute_process(COMMAND xcodebuild -version
- OUTPUT_VARIABLE ov RESULT_VARIABLE rv
+if(APPLE)
+ set(CMake_TEST_XCODE_VERSION 0)
+ if(XCODE_VERSION)
+ set(CMake_TEST_XCODE_VERSION "${XCODE_VERSION}")
+ else()
+ execute_process(
+ COMMAND xcodebuild -version
+ OUTPUT_VARIABLE _version ERROR_VARIABLE _version
)
- if("${rv}" STREQUAL "0" AND ov MATCHES "^Xcode ([0-9]+)\\.")
- if(NOT CMAKE_MATCH_1 VERSION_LESS 4)
- set(${result_var} 1 PARENT_SCOPE)
- endif()
+ if(_version MATCHES "^Xcode ([0-9]+(\\.[0-9]+)*)")
+ set(CMake_TEST_XCODE_VERSION "${CMAKE_MATCH_1}")
endif()
endif()
-endfunction()
-
-if(APPLE)
# only use multi-arch if the sysroot exists on this machine
# Ninja needs -M which could not be used with multiple -arch flags
if(EXISTS "${CMAKE_OSX_SYSROOT}" AND NOT "${CMAKE_GENERATOR}" MATCHES "Ninja")
- set(CMAKE_OSX_ARCHITECTURES "ppc;i386")
- test_for_xcode4(is_xcode4)
- if(is_xcode4)
- # Xcode 4, use modern architectures as defaults
- # Arch 'ppc' no longer works: tools no longer available starting with Xcode 4
+ if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 10)
+ # Arch 'i386' no longer works in Xcode 10.
+ set(CMAKE_OSX_ARCHITECTURES x86_64)
+ elseif(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 4)
+ # Arch 'ppc' no longer works in Xcode 4.
set(CMAKE_OSX_ARCHITECTURES i386 x86_64)
+ else()
+ set(CMAKE_OSX_ARCHITECTURES ppc i386)
endif()
endif()
endif()
@@ -93,6 +93,12 @@ add_executable(zot zot.cxx ${CMAKE_CURRENT_BINARY_DIR}/zot.hxx
zot_macro_dir.cxx zot_macro_tgt.cxx)
add_dependencies(zot zot_custom)
+add_library(zot_pch zot_pch.cxx)
+target_link_libraries(zot zot_pch)
+if(NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;$]")
+ target_precompile_headers(zot_pch PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/zot_pch.hxx)
+endif()
+
# Test the #include line macro transformation rule support.
set_property(
TARGET zot
@@ -106,7 +112,12 @@ set_property(
if(TEST_LINK_DEPENDS)
add_executable(linkdep linkdep.cxx)
- set_property(TARGET linkdep PROPERTY LINK_DEPENDS ${TEST_LINK_DEPENDS})
+ set_property(TARGET linkdep PROPERTY LINK_DEPENDS $<1:${TEST_LINK_DEPENDS}>)
+
+ add_library(foo_interface INTERFACE)
+ set_property(TARGET foo_interface PROPERTY INTERFACE_LINK_DEPENDS $<1:${TEST_LINK_DEPENDS}>)
+ add_executable(linkdep2 linkdep.cxx)
+ target_link_libraries(linkdep2 PRIVATE foo_interface)
endif()
add_library(link_depends_no_shared_lib SHARED link_depends_no_shared_lib.c
diff --git a/Tests/BuildDepends/Project/ninjadep.cpp b/Tests/BuildDepends/Project/ninjadep.cpp
index e794448f2..d3447e2e2 100644
--- a/Tests/BuildDepends/Project/ninjadep.cpp
+++ b/Tests/BuildDepends/Project/ninjadep.cpp
@@ -1,6 +1,7 @@
-#include "dir/header.h"
#include <stdio.h>
+#include "dir/header.h"
+
int main()
{
printf("HEADER_STRING: %s\n", HEADER_STRING);
diff --git a/Tests/BuildDepends/Project/zot.cxx b/Tests/BuildDepends/Project/zot.cxx
index faee7d3ce..2d08c4b78 100644
--- a/Tests/BuildDepends/Project/zot.cxx
+++ b/Tests/BuildDepends/Project/zot.cxx
@@ -4,11 +4,12 @@
const char* zot_macro_dir_f();
const char* zot_macro_tgt_f();
+const char* zot_pch_f();
int main()
{
- printf("[%s] [%s] [%s] [%s]\n", zot, zot_custom, zot_macro_dir_f(),
- zot_macro_tgt_f());
+ printf("[%s] [%s] [%s] [%s] [%s]\n", zot, zot_custom, zot_macro_dir_f(),
+ zot_macro_tgt_f(), zot_pch_f());
fflush(stdout);
return 0;
}
diff --git a/Tests/BuildDepends/Project/zot_pch.cxx b/Tests/BuildDepends/Project/zot_pch.cxx
new file mode 100644
index 000000000..d9d04c7fa
--- /dev/null
+++ b/Tests/BuildDepends/Project/zot_pch.cxx
@@ -0,0 +1,6 @@
+#include <zot_pch.hxx>
+
+const char* zot_pch_f()
+{
+ return zot_pch;
+}
diff --git a/Tests/BundleTest/BundleLib.cxx b/Tests/BundleTest/BundleLib.cxx
index 9ae802f5b..b7fd70d9a 100644
--- a/Tests/BundleTest/BundleLib.cxx
+++ b/Tests/BundleTest/BundleLib.cxx
@@ -1,14 +1,13 @@
+#include <CoreFoundation/CoreFoundation.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <CoreFoundation/CoreFoundation.h>
-
int fileExists(char* filename)
{
#ifndef R_OK
-#define R_OK 04
+# define R_OK 04
#endif
if (access(filename, R_OK) != 0) {
printf("Cannot find file: %s\n", filename);
diff --git a/Tests/BundleTest/BundleSubDir/CMakeLists.txt b/Tests/BundleTest/BundleSubDir/CMakeLists.txt
index 43c366a09..5f91f20d1 100644
--- a/Tests/BundleTest/BundleSubDir/CMakeLists.txt
+++ b/Tests/BundleTest/BundleSubDir/CMakeLists.txt
@@ -1,3 +1,5 @@
+project(BundleSubDir)
+
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist"
COMMAND /bin/cp
@@ -33,4 +35,13 @@ install(TARGETS SecondBundle DESTINATION Applications)
# installed into a location that uses this output name this will fail if the
# bundle does not respect the name. Also the executable will not be found by
# the test driver if this does not work.
-set_target_properties(SecondBundle PROPERTIES OUTPUT_NAME SecondBundleExe)
+set_target_properties(SecondBundle PROPERTIES
+ OUTPUT_NAME SecondBundleExe
+ XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
+ XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO"
+ )
+
+# Express one app bundle in terms of another's SOURCES to verify that
+# the generators do not expose the Info.plist of one to the other.
+add_executable(SubdirBundle1 MACOSX_BUNDLE EXCLUDE_FROM_ALL ../BundleTest.cxx)
+add_executable(SubdirBundle2 MACOSX_BUNDLE EXCLUDE_FROM_ALL $<TARGET_PROPERTY:SubdirBundle1,SOURCES>)
diff --git a/Tests/BundleTest/BundleTest.cxx b/Tests/BundleTest/BundleTest.cxx
index a5e8f5997..9b70e526e 100644
--- a/Tests/BundleTest/BundleTest.cxx
+++ b/Tests/BundleTest/BundleTest.cxx
@@ -1,6 +1,5 @@
-#include <stdio.h>
-
#include <CoreFoundation/CoreFoundation.h>
+#include <stdio.h>
extern int foo(char* exec);
diff --git a/Tests/BundleTest/CMakeLists.txt b/Tests/BundleTest/CMakeLists.txt
index 853da3538..1bedc708d 100644
--- a/Tests/BundleTest/CMakeLists.txt
+++ b/Tests/BundleTest/CMakeLists.txt
@@ -56,7 +56,11 @@ install(TARGETS BundleTest DESTINATION Applications)
# installed into a location that uses this output name this will fail if the
# bundle does not respect the name. Also the executable will not be found by
# the test driver if this does not work.
-set_target_properties(BundleTest PROPERTIES OUTPUT_NAME BundleTestExe)
+set_target_properties(BundleTest PROPERTIES
+ OUTPUT_NAME BundleTestExe
+ XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
+ XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO"
+ )
# Test executable versioning if it is supported.
if(NOT XCODE)
diff --git a/Tests/BundleUtilities/framework.cpp b/Tests/BundleUtilities/framework.cpp
index abda195ed..b5a95d89d 100644
--- a/Tests/BundleUtilities/framework.cpp
+++ b/Tests/BundleUtilities/framework.cpp
@@ -1,5 +1,6 @@
#include "framework.h"
+
#include "stdio.h"
void framework()
diff --git a/Tests/BundleUtilities/framework.h b/Tests/BundleUtilities/framework.h
index 343317c59..5a3cfc457 100644
--- a/Tests/BundleUtilities/framework.h
+++ b/Tests/BundleUtilities/framework.h
@@ -3,13 +3,13 @@
#define framework_h
#ifdef WIN32
-#ifdef framework_EXPORTS
-#define FRAMEWORK_EXPORT __declspec(dllexport)
+# ifdef framework_EXPORTS
+# define FRAMEWORK_EXPORT __declspec(dllexport)
+# else
+# define FRAMEWORK_EXPORT __declspec(dllimport)
+# endif
#else
-#define FRAMEWORK_EXPORT __declspec(dllimport)
-#endif
-#else
-#define FRAMEWORK_EXPORT
+# define FRAMEWORK_EXPORT
#endif
void FRAMEWORK_EXPORT framework();
diff --git a/Tests/BundleUtilities/module.cpp b/Tests/BundleUtilities/module.cpp
index 51730d9de..64bc369af 100644
--- a/Tests/BundleUtilities/module.cpp
+++ b/Tests/BundleUtilities/module.cpp
@@ -1,5 +1,6 @@
#include "module.h"
+
#include "shared2.h"
#include "stdio.h"
diff --git a/Tests/BundleUtilities/shared.cpp b/Tests/BundleUtilities/shared.cpp
index e5e7dc5ae..13791c269 100644
--- a/Tests/BundleUtilities/shared.cpp
+++ b/Tests/BundleUtilities/shared.cpp
@@ -1,5 +1,6 @@
#include "shared.h"
+
#include "stdio.h"
void shared()
diff --git a/Tests/BundleUtilities/shared.h b/Tests/BundleUtilities/shared.h
index 28904fd78..5d5b6335c 100644
--- a/Tests/BundleUtilities/shared.h
+++ b/Tests/BundleUtilities/shared.h
@@ -3,13 +3,13 @@
#define shared_h
#ifdef WIN32
-#ifdef shared_EXPORTS
-#define SHARED_EXPORT __declspec(dllexport)
+# ifdef shared_EXPORTS
+# define SHARED_EXPORT __declspec(dllexport)
+# else
+# define SHARED_EXPORT __declspec(dllimport)
+# endif
#else
-#define SHARED_EXPORT __declspec(dllimport)
-#endif
-#else
-#define SHARED_EXPORT
+# define SHARED_EXPORT
#endif
void SHARED_EXPORT shared();
diff --git a/Tests/BundleUtilities/shared2.cpp b/Tests/BundleUtilities/shared2.cpp
index 84af5d061..bed19048b 100644
--- a/Tests/BundleUtilities/shared2.cpp
+++ b/Tests/BundleUtilities/shared2.cpp
@@ -1,5 +1,6 @@
#include "shared2.h"
+
#include "stdio.h"
void shared2()
diff --git a/Tests/BundleUtilities/shared2.h b/Tests/BundleUtilities/shared2.h
index 3f0015c80..3f016c8f0 100644
--- a/Tests/BundleUtilities/shared2.h
+++ b/Tests/BundleUtilities/shared2.h
@@ -3,13 +3,13 @@
#define shared2_h
#ifdef WIN32
-#ifdef shared2_EXPORTS
-#define SHARED2_EXPORT __declspec(dllexport)
+# ifdef shared2_EXPORTS
+# define SHARED2_EXPORT __declspec(dllexport)
+# else
+# define SHARED2_EXPORT __declspec(dllimport)
+# endif
#else
-#define SHARED2_EXPORT __declspec(dllimport)
-#endif
-#else
-#define SHARED2_EXPORT
+# define SHARED2_EXPORT
#endif
void SHARED2_EXPORT shared2();
diff --git a/Tests/BundleUtilities/testbundleutils1.cpp b/Tests/BundleUtilities/testbundleutils1.cpp
index 3eb6a44bf..080157ac2 100644
--- a/Tests/BundleUtilities/testbundleutils1.cpp
+++ b/Tests/BundleUtilities/testbundleutils1.cpp
@@ -4,9 +4,9 @@
#include "stdio.h"
#if defined(WIN32)
-#include <windows.h>
+# include <windows.h>
#else
-#include "dlfcn.h"
+# include "dlfcn.h"
#endif
int main(int, char**)
diff --git a/Tests/BundleUtilities/testbundleutils2.cpp b/Tests/BundleUtilities/testbundleutils2.cpp
index c39eb52c5..e747544db 100644
--- a/Tests/BundleUtilities/testbundleutils2.cpp
+++ b/Tests/BundleUtilities/testbundleutils2.cpp
@@ -4,9 +4,9 @@
#include "stdio.h"
#if defined(WIN32)
-#include <windows.h>
+# include <windows.h>
#else
-#include "dlfcn.h"
+# include "dlfcn.h"
#endif
int main(int, char**)
diff --git a/Tests/BundleUtilities/testbundleutils3.cpp b/Tests/BundleUtilities/testbundleutils3.cpp
index 3bc8a83ec..2dee46fe5 100644
--- a/Tests/BundleUtilities/testbundleutils3.cpp
+++ b/Tests/BundleUtilities/testbundleutils3.cpp
@@ -4,9 +4,9 @@
#include "stdio.h"
#if defined(WIN32)
-#include <windows.h>
+# include <windows.h>
#else
-#include "dlfcn.h"
+# include "dlfcn.h"
#endif
int main(int, char**)
diff --git a/Tests/CFBundleTest/CMakeLists.txt b/Tests/CFBundleTest/CMakeLists.txt
index 0fe6bb771..b2b1b7316 100644
--- a/Tests/CFBundleTest/CMakeLists.txt
+++ b/Tests/CFBundleTest/CMakeLists.txt
@@ -50,6 +50,8 @@ set_source_files_properties(
set_target_properties(CFBundleTest PROPERTIES
BUNDLE 1
BUNDLE_EXTENSION plugin
+ XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
+ XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO"
XCODE_ATTRIBUTE_MACH_O_TYPE mh_bundle
XCODE_ATTRIBUTE_INFOPLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/Info.plist
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist
diff --git a/Tests/CFBundleTest/np_macmain.cpp b/Tests/CFBundleTest/np_macmain.cpp
index b5a422687..e5fd0d773 100644
--- a/Tests/CFBundleTest/np_macmain.cpp
+++ b/Tests/CFBundleTest/np_macmain.cpp
@@ -4,7 +4,7 @@
Based on the default np_macmain.cpp from FireBreath
http://firebreath.googlecode.com
- This file has been stripped to prevent it from accidently
+ This file has been stripped to prevent it from accidentally
doing anything useful.
\***********************************************************/
diff --git a/Tests/CMakeBuildTest.cmake.in b/Tests/CMakeBuildTest.cmake.in
index 71bcb183e..b4b12863d 100644
--- a/Tests/CMakeBuildTest.cmake.in
+++ b/Tests/CMakeBuildTest.cmake.in
@@ -29,11 +29,10 @@ if(RESULT)
message(FATAL_ERROR "Error running cmake --build")
endif()
-# check for configuration types
-set(CMAKE_CONFIGURATION_TYPES @CMAKE_CONFIGURATION_TYPES@)
-# run the executable out of the Debug directory if there
-# are configuration types
-if(CMAKE_CONFIGURATION_TYPES)
+# run the executable out of the Debug directory if using a
+# multi-config generator
+set(_isMultiConfig @_isMultiConfig@)
+if(_isMultiConfig)
set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/Debug/@CMAKE_BUILD_TEST_EXE@")
else()
set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/@CMAKE_BUILD_TEST_EXE@")
diff --git a/Tests/CMakeCommands/add_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/add_compile_definitions/CMakeLists.txt
new file mode 100644
index 000000000..2eb887e00
--- /dev/null
+++ b/Tests/CMakeCommands/add_compile_definitions/CMakeLists.txt
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(add_compile_definitions LANGUAGES CXX)
+
+add_compile_definitions(TEST_DEFINITION
+ $<$<COMPILE_LANGUAGE:CXX>:LANG_$<COMPILE_LANGUAGE>>
+ $<$<EQUAL:0,1>:UNEXPECTED_DEFINITION>)
+
+add_executable(add_compile_definitions main.cpp)
+
+add_library(imp UNKNOWN IMPORTED)
+get_target_property(_res imp COMPILE_DEFINITIONS)
+if (_res)
+ message(SEND_ERROR "add_compile_definitions populated the COMPILE_DEFINITIONS target property")
+endif()
diff --git a/Tests/CMakeCommands/add_compile_definitions/main.cpp b/Tests/CMakeCommands/add_compile_definitions/main.cpp
new file mode 100644
index 000000000..41ff25f4c
--- /dev/null
+++ b/Tests/CMakeCommands/add_compile_definitions/main.cpp
@@ -0,0 +1,17 @@
+
+#ifndef TEST_DEFINITION
+# error Expected TEST_DEFINITION
+#endif
+
+#ifndef LANG_CXX
+# error Expected LANG_CXX
+#endif
+
+#ifdef UNPEXTED_DEFINITION
+# error Unexpected UNPEXTED_DEFINITION
+#endif
+
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/add_compile_options/main.cpp b/Tests/CMakeCommands/add_compile_options/main.cpp
index 1d5702165..53f54b771 100644
--- a/Tests/CMakeCommands/add_compile_options/main.cpp
+++ b/Tests/CMakeCommands/add_compile_options/main.cpp
@@ -1,8 +1,8 @@
#ifdef DO_GNU_TESTS
-#ifndef TEST_OPTION
-#error Expected TEST_OPTION
-#endif
+# ifndef TEST_OPTION
+# error Expected TEST_OPTION
+# endif
#endif
int main(void)
diff --git a/Tests/CMakeCommands/add_link_options/CMakeLists.txt b/Tests/CMakeCommands/add_link_options/CMakeLists.txt
new file mode 100644
index 000000000..bb7dcbbfc
--- /dev/null
+++ b/Tests/CMakeCommands/add_link_options/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 3.11)
+
+project(add_link_options LANGUAGES C)
+
+
+add_link_options(-LINK_FLAG)
+
+add_executable(add_link_options EXCLUDE_FROM_ALL LinkOptionsExe.c)
+
+get_target_property(result add_link_options LINK_OPTIONS)
+if (NOT result MATCHES "-LINK_FLAG")
+ message(SEND_ERROR "add_link_options not populated the LINK_OPTIONS target property")
+endif()
+
+
+add_library(imp UNKNOWN IMPORTED)
+get_target_property(result imp LINK_OPTIONS)
+if (result)
+ message(FATAL_ERROR "add_link_options populated the LINK_OPTIONS target property")
+endif()
diff --git a/Tests/CMakeCommands/add_link_options/LinkOptionsExe.c b/Tests/CMakeCommands/add_link_options/LinkOptionsExe.c
new file mode 100644
index 000000000..8488f4e58
--- /dev/null
+++ b/Tests/CMakeCommands/add_link_options/LinkOptionsExe.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/link_directories/CMakeLists.txt b/Tests/CMakeCommands/link_directories/CMakeLists.txt
new file mode 100644
index 000000000..60c07b638
--- /dev/null
+++ b/Tests/CMakeCommands/link_directories/CMakeLists.txt
@@ -0,0 +1,30 @@
+cmake_minimum_required(VERSION 3.12)
+
+project(link_directories LANGUAGES C)
+
+
+link_directories(/A)
+link_directories(BEFORE /B)
+
+set(CMAKE_LINK_DIRECTORIES_BEFORE ON)
+link_directories(/C)
+
+get_directory_property(result LINK_DIRECTORIES)
+if (NOT result MATCHES "/C;/B;/A")
+ message(SEND_ERROR "link_directories not populated the LINK_DIRECTORIES directory property")
+endif()
+
+
+add_executable(link_directories EXCLUDE_FROM_ALL LinkDirectoriesExe.c)
+
+get_target_property(result link_directories LINK_DIRECTORIES)
+if (NOT result MATCHES "/C;/B;/A")
+ message(SEND_ERROR "link_directories not populated the LINK_DIRECTORIES target property")
+endif()
+
+
+add_library(imp UNKNOWN IMPORTED)
+get_target_property(result imp LINK_DIRECTORIES)
+if (result)
+ message(FATAL_ERROR "link_directories populated the LINK_DIRECTORIES target property")
+endif()
diff --git a/Tests/CMakeCommands/link_directories/LinkDirectoriesExe.c b/Tests/CMakeCommands/link_directories/LinkDirectoriesExe.c
new file mode 100644
index 000000000..8488f4e58
--- /dev/null
+++ b/Tests/CMakeCommands/link_directories/LinkDirectoriesExe.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt
index f96283d55..a5bc1e1b3 100644
--- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt
@@ -26,18 +26,19 @@ target_compile_definitions(consumer
PRIVATE
)
-if (CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja")
- target_sources(consumer PRIVATE
- "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c"
- )
- target_compile_definitions(consumer
- PRIVATE
- CONSUMER_LANG_$<COMPILE_LANGUAGE>
- LANG_IS_CXX=$<COMPILE_LANGUAGE:CXX>
- LANG_IS_C=$<COMPILE_LANGUAGE:C>
- )
+target_sources(consumer PRIVATE
+ "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c"
+)
+target_compile_definitions(consumer
+ PRIVATE
+ CONSUMER_LANG_$<COMPILE_LANGUAGE>
+ LANG_IS_CXX=$<COMPILE_LANGUAGE:CXX>
+ LANG_IS_C=$<COMPILE_LANGUAGE:C>
+ LANG_IS_C_OR_CXX=$<COMPILE_LANGUAGE:C,CXX>
+)
+if(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode")
target_compile_definitions(consumer
- PRIVATE -DTEST_LANG_DEFINES
+ PRIVATE TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE
)
endif()
diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.c b/Tests/CMakeCommands/target_compile_definitions/consumer.c
index 7931a6f0e..bb65e011b 100644
--- a/Tests/CMakeCommands/target_compile_definitions/consumer.c
+++ b/Tests/CMakeCommands/target_compile_definitions/consumer.c
@@ -1,20 +1,42 @@
-#ifdef TEST_LANG_DEFINES
-#ifdef CONSUMER_LANG_CXX
-#error Unexpected CONSUMER_LANG_CXX
-#endif
+// Visual Studio allows only one set of flags for C and C++.
+// In a target using C++ we pick the C++ flags even for C sources.
+#ifdef TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE
+# ifndef CONSUMER_LANG_CXX
+# error Expected CONSUMER_LANG_CXX
+# endif
-#ifndef CONSUMER_LANG_C
-#error Expected CONSUMER_LANG_C
-#endif
+# ifdef CONSUMER_LANG_C
+# error Unexpected CONSUMER_LANG_C
+# endif
-#if !LANG_IS_C
-#error Expected LANG_IS_C
-#endif
+# if !LANG_IS_CXX
+# error Expected LANG_IS_CXX
+# endif
+
+# if LANG_IS_C
+# error Unexpected LANG_IS_C
+# endif
+#else
+# ifdef CONSUMER_LANG_CXX
+# error Unexpected CONSUMER_LANG_CXX
+# endif
-#if LANG_IS_CXX
-#error Unexpected LANG_IS_CXX
+# ifndef CONSUMER_LANG_C
+# error Expected CONSUMER_LANG_C
+# endif
+
+# if !LANG_IS_C
+# error Expected LANG_IS_C
+# endif
+
+# if LANG_IS_CXX
+# error Unexpected LANG_IS_CXX
+# endif
#endif
+
+#if !LANG_IS_C_OR_CXX
+# error Expected LANG_IS_C_OR_CXX
#endif
void consumer_c()
diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp
index 0202c172e..099952666 100644
--- a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp
+++ b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp
@@ -1,36 +1,34 @@
#ifdef MY_PRIVATE_DEFINE
-#error Unexpected MY_PRIVATE_DEFINE
+# error Unexpected MY_PRIVATE_DEFINE
#endif
#ifndef MY_PUBLIC_DEFINE
-#error Expected MY_PUBLIC_DEFINE
+# error Expected MY_PUBLIC_DEFINE
#endif
#ifndef MY_INTERFACE_DEFINE
-#error Expected MY_INTERFACE_DEFINE
+# error Expected MY_INTERFACE_DEFINE
#endif
#ifndef DASH_D_DEFINE
-#error Expected DASH_D_DEFINE
+# error Expected DASH_D_DEFINE
#endif
-#ifdef TEST_LANG_DEFINES
#ifndef CONSUMER_LANG_CXX
-#error Expected CONSUMER_LANG_CXX
+# error Expected CONSUMER_LANG_CXX
#endif
#ifdef CONSUMER_LANG_C
-#error Unexpected CONSUMER_LANG_C
+# error Unexpected CONSUMER_LANG_C
#endif
#if !LANG_IS_CXX
-#error Expected LANG_IS_CXX
+# error Expected LANG_IS_CXX
#endif
#if LANG_IS_C
-#error Unexpected LANG_IS_C
-#endif
+# error Unexpected LANG_IS_C
#endif
int main()
diff --git a/Tests/CMakeCommands/target_compile_definitions/main.cpp b/Tests/CMakeCommands/target_compile_definitions/main.cpp
index bf08b45e3..3f64dc843 100644
--- a/Tests/CMakeCommands/target_compile_definitions/main.cpp
+++ b/Tests/CMakeCommands/target_compile_definitions/main.cpp
@@ -1,14 +1,14 @@
#ifndef MY_PRIVATE_DEFINE
-#error Expected MY_PRIVATE_DEFINE
+# error Expected MY_PRIVATE_DEFINE
#endif
#ifndef MY_PUBLIC_DEFINE
-#error Expected MY_PUBLIC_DEFINE
+# error Expected MY_PUBLIC_DEFINE
#endif
#ifdef MY_INTERFACE_DEFINE
-#error Unexpected MY_INTERFACE_DEFINE
+# error Unexpected MY_INTERFACE_DEFINE
#endif
int main()
diff --git a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt
index 5096a58bf..9664025a4 100644
--- a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt
@@ -1,5 +1,4 @@
-cmake_minimum_required(VERSION 3.0)
-cmake_policy(SET CMP0057 NEW)
+cmake_minimum_required(VERSION 3.3)
project(target_compile_features)
set(CMAKE_VERBOSE_MAKEFILE ON)
@@ -19,7 +18,8 @@ if (c_restrict IN_LIST CMAKE_C_COMPILE_FEATURES)
target_link_libraries(c_restrict_user_specific c_lib_restrict_specific)
endif()
-if (c_std_99 IN_LIST CMAKE_C_COMPILE_FEATURES)
+if (c_std_99 IN_LIST CMAKE_C_COMPILE_FEATURES AND
+ NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
add_executable(c_target_compile_features_meta main.c)
target_compile_features(c_target_compile_features_meta
PRIVATE c_std_99
diff --git a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt
index 35dd276ba..a7055b157 100644
--- a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt
@@ -7,9 +7,11 @@ add_executable(target_compile_options
"${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
)
target_compile_options(target_compile_options
- PRIVATE $<$<CXX_COMPILER_ID:GNU>:-DMY_PRIVATE_DEFINE>
- PUBLIC $<$<CXX_COMPILER_ID:GNU>:-DMY_PUBLIC_DEFINE>
+ PRIVATE $<$<CXX_COMPILER_ID:AppleClang,Clang,GNU>:-DMY_PRIVATE_DEFINE>
+ PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU>:-DMY_PUBLIC_DEFINE>
+ PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang,AppleClang>:-DMY_MUTLI_COMP_PUBLIC_DEFINE>
INTERFACE $<$<CXX_COMPILER_ID:GNU>:-DMY_INTERFACE_DEFINE>
+ INTERFACE $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-DMY_MULTI_COMP_INTERFACE_DEFINE>
)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
@@ -17,29 +19,35 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
PRIVATE
"DO_GNU_TESTS"
)
+elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ target_compile_definitions(target_compile_options
+ PRIVATE
+ "DO_CLANG_TESTS"
+ )
endif()
add_executable(consumer
"${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp"
)
-if (NOT CMAKE_GENERATOR MATCHES "Visual Studio")
- target_sources(consumer PRIVATE
- "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c"
- )
- target_compile_options(consumer
- PRIVATE
- -DCONSUMER_LANG_$<COMPILE_LANGUAGE>
- -DLANG_IS_CXX=$<COMPILE_LANGUAGE:CXX>
- -DLANG_IS_C=$<COMPILE_LANGUAGE:C>
- )
+target_sources(consumer PRIVATE
+ "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c"
+)
+target_compile_options(consumer
+ PRIVATE
+ -DCONSUMER_LANG_$<COMPILE_LANGUAGE>
+ -DLANG_IS_CXX=$<COMPILE_LANGUAGE:CXX>
+ -DLANG_IS_C=$<COMPILE_LANGUAGE:C>
+)
+
+if(CMAKE_GENERATOR MATCHES "Visual Studio")
target_compile_definitions(consumer
- PRIVATE -DTEST_LANG_DEFINES
+ PRIVATE TEST_LANG_DEFINES_FOR_VISUAL_STUDIO
)
endif()
target_compile_options(consumer
- PRIVATE $<$<CXX_COMPILER_ID:GNU>:$<TARGET_PROPERTY:target_compile_options,INTERFACE_COMPILE_OPTIONS>>
+ PRIVATE $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:$<TARGET_PROPERTY:target_compile_options,INTERFACE_COMPILE_OPTIONS>>
)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
@@ -47,6 +55,11 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
PRIVATE
"DO_GNU_TESTS"
)
+elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ target_compile_definitions(consumer
+ PRIVATE
+ "DO_CLANG_TESTS"
+ )
endif()
# Test no items
diff --git a/Tests/CMakeCommands/target_compile_options/consumer.c b/Tests/CMakeCommands/target_compile_options/consumer.c
index 7931a6f0e..f9b66543a 100644
--- a/Tests/CMakeCommands/target_compile_options/consumer.c
+++ b/Tests/CMakeCommands/target_compile_options/consumer.c
@@ -1,20 +1,38 @@
-#ifdef TEST_LANG_DEFINES
-#ifdef CONSUMER_LANG_CXX
-#error Unexpected CONSUMER_LANG_CXX
-#endif
+// Visual Studio allows only one set of flags for C and C++.
+// In a target using C++ we pick the C++ flags even for C sources.
+#ifdef TEST_LANG_DEFINES_FOR_VISUAL_STUDIO
+# ifndef CONSUMER_LANG_CXX
+# error Expected CONSUMER_LANG_CXX
+# endif
-#ifndef CONSUMER_LANG_C
-#error Expected CONSUMER_LANG_C
-#endif
+# ifdef CONSUMER_LANG_C
+# error Unexpected CONSUMER_LANG_C
+# endif
-#if !LANG_IS_C
-#error Expected LANG_IS_C
-#endif
+# if !LANG_IS_CXX
+# error Expected LANG_IS_CXX
+# endif
-#if LANG_IS_CXX
-#error Unexpected LANG_IS_CXX
-#endif
+# if LANG_IS_C
+# error Unexpected LANG_IS_C
+# endif
+#else
+# ifdef CONSUMER_LANG_CXX
+# error Unexpected CONSUMER_LANG_CXX
+# endif
+
+# ifndef CONSUMER_LANG_C
+# error Expected CONSUMER_LANG_C
+# endif
+
+# if !LANG_IS_C
+# error Expected LANG_IS_C
+# endif
+
+# if LANG_IS_CXX
+# error Unexpected LANG_IS_CXX
+# endif
#endif
void consumer_c()
diff --git a/Tests/CMakeCommands/target_compile_options/consumer.cpp b/Tests/CMakeCommands/target_compile_options/consumer.cpp
index 71a60986a..78928b42e 100644
--- a/Tests/CMakeCommands/target_compile_options/consumer.cpp
+++ b/Tests/CMakeCommands/target_compile_options/consumer.cpp
@@ -1,36 +1,58 @@
#ifdef DO_GNU_TESTS
-#ifdef MY_PRIVATE_DEFINE
-#error Unexpected MY_PRIVATE_DEFINE
-#endif
+# ifdef MY_PRIVATE_DEFINE
+# error Unexpected MY_PRIVATE_DEFINE
+# endif
-#ifndef MY_PUBLIC_DEFINE
-#error Expected MY_PUBLIC_DEFINE
-#endif
+# ifndef MY_PUBLIC_DEFINE
+# error Expected MY_PUBLIC_DEFINE
+# endif
+
+# ifndef MY_INTERFACE_DEFINE
+# error Expected MY_INTERFACE_DEFINE
+# endif
+
+# ifndef MY_MULTI_COMP_INTERFACE_DEFINE
+# error Expected MY_MULTI_COMP_INTERFACE_DEFINE
+# endif
+
+# ifndef MY_MUTLI_COMP_PUBLIC_DEFINE
+# error Expected MY_MUTLI_COMP_PUBLIC_DEFINE
+# endif
-#ifndef MY_INTERFACE_DEFINE
-#error Expected MY_INTERFACE_DEFINE
#endif
+#ifdef DO_CLANG_TESTS
+
+# ifdef MY_PRIVATE_DEFINE
+# error Unexpected MY_PRIVATE_DEFINE
+# endif
+
+# ifndef MY_MULTI_COMP_INTERFACE_DEFINE
+# error Expected MY_MULTI_COMP_INTERFACE_DEFINE
+# endif
+
+# ifndef MY_MUTLI_COMP_PUBLIC_DEFINE
+# error Expected MY_MUTLI_COMP_PUBLIC_DEFINE
+# endif
+
#endif
-#ifdef TEST_LANG_DEFINES
#ifndef CONSUMER_LANG_CXX
-#error Expected CONSUMER_LANG_CXX
+# error Expected CONSUMER_LANG_CXX
#endif
#ifdef CONSUMER_LANG_C
-#error Unexpected CONSUMER_LANG_C
+# error Unexpected CONSUMER_LANG_C
#endif
#if !LANG_IS_CXX
-#error Expected LANG_IS_CXX
+# error Expected LANG_IS_CXX
#endif
#if LANG_IS_C
-#error Unexpected LANG_IS_C
-#endif
+# error Unexpected LANG_IS_C
#endif
int main()
diff --git a/Tests/CMakeCommands/target_compile_options/main.cpp b/Tests/CMakeCommands/target_compile_options/main.cpp
index ac472aeda..7608400c4 100644
--- a/Tests/CMakeCommands/target_compile_options/main.cpp
+++ b/Tests/CMakeCommands/target_compile_options/main.cpp
@@ -1,18 +1,38 @@
#ifdef DO_GNU_TESTS
-#ifndef MY_PRIVATE_DEFINE
-#error Expected MY_PRIVATE_DEFINE
-#endif
+# ifndef MY_PRIVATE_DEFINE
+# error Expected MY_PRIVATE_DEFINE
+# endif
-#ifndef MY_PUBLIC_DEFINE
-#error Expected MY_PUBLIC_DEFINE
-#endif
+# ifndef MY_PUBLIC_DEFINE
+# error Expected MY_PUBLIC_DEFINE
+# endif
+
+# ifndef MY_MUTLI_COMP_PUBLIC_DEFINE
+# error Expected MY_MUTLI_COMP_PUBLIC_DEFINE
+# endif
+
+# ifdef MY_INTERFACE_DEFINE
+# error Unexpected MY_INTERFACE_DEFINE
+# endif
-#ifdef MY_INTERFACE_DEFINE
-#error Unexpected MY_INTERFACE_DEFINE
#endif
+#ifdef DO_CLANG_TESTS
+
+# ifndef MY_PRIVATE_DEFINE
+# error Expected MY_PRIVATE_DEFINE
+# endif
+
+# ifdef MY_PUBLIC_DEFINE
+# error Unexpected MY_PUBLIC_DEFINE
+# endif
+
+# ifndef MY_MUTLI_COMP_PUBLIC_DEFINE
+# error Expected MY_MUTLI_COMP_PUBLIC_DEFINE
+# endif
+
#endif
int main()
diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt
index d57556aad..8713d99dd 100644
--- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt
@@ -42,17 +42,17 @@ add_executable(consumer
"${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp"
)
-if (CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja")
- target_sources(consumer PRIVATE
- "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c"
- )
- target_include_directories(consumer
- PRIVATE
- $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_only>
- $<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}/c_only>
- )
+target_sources(consumer PRIVATE
+ "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c"
+)
+target_include_directories(consumer
+ PRIVATE
+ $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_only>
+ $<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}/c_only>
+)
+if(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode")
target_compile_definitions(consumer
- PRIVATE -DTEST_LANG_DEFINES
+ PRIVATE TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE
)
endif()
diff --git a/Tests/CMakeCommands/target_include_directories/consumer.c b/Tests/CMakeCommands/target_include_directories/consumer.c
index ae88f9248..7fd694b08 100644
--- a/Tests/CMakeCommands/target_include_directories/consumer.c
+++ b/Tests/CMakeCommands/target_include_directories/consumer.c
@@ -1,10 +1,18 @@
-#ifdef TEST_LANG_DEFINES
-#include "c_only.h"
+// Visual Studio allows only one set of flags for C and C++.
+// In a target using C++ we pick the C++ flags even for C sources.
+#ifdef TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE
+# include "cxx_only.h"
-#ifndef C_ONLY_DEFINE
-#error Expected C_ONLY_DEFINE
-#endif
+# ifndef CXX_ONLY_DEFINE
+# error Expected CXX_ONLY_DEFINE
+# endif
+#else
+# include "c_only.h"
+
+# ifndef C_ONLY_DEFINE
+# error Expected C_ONLY_DEFINE
+# endif
#endif
int consumer_c()
diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp
index 0f8153b83..d34965022 100644
--- a/Tests/CMakeCommands/target_include_directories/consumer.cpp
+++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp
@@ -1,41 +1,38 @@
#include "consumer.h"
+
#include "common.h"
+#include "cxx_only.h"
#include "interfaceinclude.h"
#include "publicinclude.h"
#include "relative_dir.h"
-#ifdef TEST_LANG_DEFINES
-#include "cxx_only.h"
-#endif
#ifdef PRIVATEINCLUDE_DEFINE
-#error Unexpected PRIVATEINCLUDE_DEFINE
+# error Unexpected PRIVATEINCLUDE_DEFINE
#endif
#ifndef PUBLICINCLUDE_DEFINE
-#error Expected PUBLICINCLUDE_DEFINE
+# error Expected PUBLICINCLUDE_DEFINE
#endif
#ifndef INTERFACEINCLUDE_DEFINE
-#error Expected INTERFACEINCLUDE_DEFINE
+# error Expected INTERFACEINCLUDE_DEFINE
#endif
#ifndef CURE_DEFINE
-#error Expected CURE_DEFINE
+# error Expected CURE_DEFINE
#endif
#ifndef RELATIVE_DIR_DEFINE
-#error Expected RELATIVE_DIR_DEFINE
+# error Expected RELATIVE_DIR_DEFINE
#endif
#ifndef CONSUMER_DEFINE
-#error Expected CONSUMER_DEFINE
+# error Expected CONSUMER_DEFINE
#endif
-#ifdef TEST_LANG_DEFINES
#ifndef CXX_ONLY_DEFINE
-#error Expected CXX_ONLY_DEFINE
-#endif
+# error Expected CXX_ONLY_DEFINE
#endif
int main()
diff --git a/Tests/CMakeCommands/target_include_directories/main.cpp b/Tests/CMakeCommands/target_include_directories/main.cpp
index 71298ceac..dd591bfed 100644
--- a/Tests/CMakeCommands/target_include_directories/main.cpp
+++ b/Tests/CMakeCommands/target_include_directories/main.cpp
@@ -4,19 +4,19 @@
#include "publicinclude.h"
#ifndef PRIVATEINCLUDE_DEFINE
-#error Expected PRIVATEINCLUDE_DEFINE
+# error Expected PRIVATEINCLUDE_DEFINE
#endif
#ifndef PUBLICINCLUDE_DEFINE
-#error Expected PUBLICINCLUDE_DEFINE
+# error Expected PUBLICINCLUDE_DEFINE
#endif
#ifdef INTERFACEINCLUDE_DEFINE
-#error Unexpected INTERFACEINCLUDE_DEFINE
+# error Unexpected INTERFACEINCLUDE_DEFINE
#endif
#ifndef CURE_DEFINE
-#error Expected CURE_DEFINE
+# error Expected CURE_DEFINE
#endif
int main()
diff --git a/Tests/CMakeCommands/target_link_directories/CMakeLists.txt b/Tests/CMakeCommands/target_link_directories/CMakeLists.txt
new file mode 100644
index 000000000..bc7b9b212
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_directories/CMakeLists.txt
@@ -0,0 +1,40 @@
+
+cmake_minimum_required(VERSION 3.12)
+
+project(target_link_directories LANGUAGES C)
+
+add_library(target_link_directories SHARED LinkDirectoriesLib.c)
+# Test no items
+target_link_directories(target_link_directories PRIVATE)
+
+add_library(target_link_directories_2 SHARED EXCLUDE_FROM_ALL LinkDirectoriesLib.c)
+target_link_directories(target_link_directories_2 PRIVATE /private/dir INTERFACE /interface/dir)
+get_target_property(result target_link_directories_2 LINK_DIRECTORIES)
+if (NOT result MATCHES "/private/dir")
+ message(SEND_ERROR "${result} target_link_directories not populated the LINK_DIRECTORIES target property")
+endif()
+get_target_property(result target_link_directories_2 INTERFACE_LINK_DIRECTORIES)
+if (NOT result MATCHES "/interface/dir")
+ message(SEND_ERROR "target_link_directories not populated the INTERFACE_LINK_DIRECTORIES target property of shared library")
+endif()
+
+add_library(target_link_directories_3 STATIC EXCLUDE_FROM_ALL LinkDirectoriesLib.c)
+target_link_directories(target_link_directories_3 INTERFACE /interface/dir)
+get_target_property(result target_link_directories_3 INTERFACE_LINK_DIRECTORIES)
+if (NOT result MATCHES "/interface/dir")
+ message(SEND_ERROR "target_link_directories not populated the INTERFACE_LINK_DIRECTORIES target property of static library")
+endif()
+
+add_library(target_link_directories_4 SHARED EXCLUDE_FROM_ALL LinkDirectoriesLib.c)
+target_link_directories(target_link_directories_4 PRIVATE relative/dir)
+get_target_property(result target_link_directories_4 LINK_DIRECTORIES)
+if (NOT result MATCHES "${CMAKE_CURRENT_SOURCE_DIR}/relative/dir")
+ message(SEND_ERROR "target_link_directories not populated the LINK_DIRECTORIES with relative path")
+endif()
+
+add_subdirectory(subdir)
+target_link_directories(target_link_directories_5 PRIVATE relative/dir)
+get_target_property(result target_link_directories_5 LINK_DIRECTORIES)
+if (NOT result MATCHES "${CMAKE_CURRENT_SOURCE_DIR}/relative/dir")
+ message(SEND_ERROR "target_link_directories not populated the LINK_DIRECTORIES with relative path")
+endif()
diff --git a/Tests/CMakeCommands/target_link_directories/LinkDirectoriesLib.c b/Tests/CMakeCommands/target_link_directories/LinkDirectoriesLib.c
new file mode 100644
index 000000000..9bbd24cd8
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_directories/LinkDirectoriesLib.c
@@ -0,0 +1,7 @@
+#if defined(_WIN32)
+__declspec(dllexport)
+#endif
+ int flags_lib(void)
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_link_directories/subdir/CMakeLists.txt b/Tests/CMakeCommands/target_link_directories/subdir/CMakeLists.txt
new file mode 100644
index 000000000..7e7ad2a97
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_directories/subdir/CMakeLists.txt
@@ -0,0 +1,2 @@
+
+add_library(target_link_directories_5 SHARED EXCLUDE_FROM_ALL ../LinkDirectoriesLib.c)
diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
index e11f980df..5c704ac83 100644
--- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
@@ -130,3 +130,19 @@ target_link_libraries(newsignature1 PRIVATE depC INTERFACE depD PUBLIC depB PRIV
assert_property(newsignature1 INTERFACE_LINK_LIBRARIES "depD;depB")
assert_property(newsignature1 LINK_LIBRARIES "depC;depB;subdirlib")
+
+#----------------------------------------------------------------------------
+# Test cross-directory linking.
+cmake_policy(PUSH)
+cmake_policy(SET CMP0022 NEW)
+cmake_policy(SET CMP0079 NEW)
+add_executable(TopDir TopDir.c)
+add_subdirectory(SubDirA)
+add_subdirectory(SubDirB)
+target_link_libraries(SubDirB TopDirImported)
+add_subdirectory(SubDirC)
+target_link_libraries(SubDirC PRIVATE SubDirC2)
+target_link_libraries(TopDir SubDirC)
+add_library(TopDirImported IMPORTED INTERFACE)
+target_compile_definitions(TopDirImported INTERFACE DEF_TopDirImported)
+cmake_policy(POP)
diff --git a/Tests/CMakeCommands/target_link_libraries/SubDirA/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/SubDirA/CMakeLists.txt
new file mode 100644
index 000000000..4dae10395
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/SubDirA/CMakeLists.txt
@@ -0,0 +1,15 @@
+add_executable(SubDirA SubDirA.c)
+
+# Link to a target imported in this directory that would not normally
+# be visible to the directory in which TopDir is defined.
+target_link_libraries(TopDir PUBLIC SameNameImported)
+
+# Link SubDirA to a target imported in this directory that has the same
+# name as a target imported in SubDirB's directory. SubDirB will also
+# tell us to link its copy. At compile time we verify both are linked.
+target_link_libraries(SubDirA PRIVATE SameNameImported)
+
+# Import a target with the same name as a target imported in SubDirB.
+# Distinguish this copy by having a unique usage requirement.
+add_library(SameNameImported IMPORTED INTERFACE)
+target_compile_definitions(SameNameImported INTERFACE DEF_SameNameImportedSubDirA)
diff --git a/Tests/CMakeCommands/target_link_libraries/SubDirA/SubDirA.c b/Tests/CMakeCommands/target_link_libraries/SubDirA/SubDirA.c
new file mode 100644
index 000000000..4706bb94e
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/SubDirA/SubDirA.c
@@ -0,0 +1,14 @@
+#ifndef DEF_SameNameImportedSubDirA
+# error "DEF_SameNameImportedSubDirA is not defined but should be!"
+#endif
+#ifndef DEF_SameNameImportedSubDirB
+# error "DEF_SameNameImportedSubDirB is not defined but should be!"
+#endif
+#ifdef DEF_TopDirImported
+# error "DEF_TopDirImported is defined but should not be!"
+#endif
+
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_link_libraries/SubDirB/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/SubDirB/CMakeLists.txt
new file mode 100644
index 000000000..7c918e699
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/SubDirB/CMakeLists.txt
@@ -0,0 +1,15 @@
+add_executable(SubDirB SubDirB.c)
+
+# Link to a target imported in this directory that would not normally
+# be visible to the directory in which TopDir is defined.
+target_link_libraries(TopDir PUBLIC SameNameImported)
+
+# Link SubDirA to a target imported in this directory that has the same
+# name as a target imported in SubDirA's directory. We verify when
+# compiling SubDirA that it sees our target and its own.
+target_link_libraries(SubDirA PRIVATE SameNameImported)
+
+# Import a target with the same name as a target imported in SubDirA.
+# Distinguish this copy by having a unique usage requirement.
+add_library(SameNameImported IMPORTED INTERFACE)
+target_compile_definitions(SameNameImported INTERFACE DEF_SameNameImportedSubDirB)
diff --git a/Tests/CMakeCommands/target_link_libraries/SubDirB/SubDirB.c b/Tests/CMakeCommands/target_link_libraries/SubDirB/SubDirB.c
new file mode 100644
index 000000000..6e567298c
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/SubDirB/SubDirB.c
@@ -0,0 +1,14 @@
+#ifdef DEF_SameNameImportedSubDirA
+# error "DEF_SameNameImportedSubDirA is defined but should not be!"
+#endif
+#ifdef DEF_SameNameImportedSubDirB
+# error "DEF_SameNameImportedSubDirB is defined but should not be!"
+#endif
+#ifndef DEF_TopDirImported
+# error "DEF_TopDirImported is not defined but should be!"
+#endif
+
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_link_libraries/SubDirC/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/SubDirC/CMakeLists.txt
new file mode 100644
index 000000000..54bcc5174
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/SubDirC/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_library(SubDirC STATIC SubDirC.c)
+
+add_library(SubDirC1 INTERFACE)
+target_compile_definitions(SubDirC1 INTERFACE DEF_SubDirC1)
+
+add_library(SubDirC2 INTERFACE)
+target_compile_definitions(SubDirC2 INTERFACE DEF_SubDirC2)
+
+target_link_libraries(SubDirC PRIVATE SubDirC1)
diff --git a/Tests/CMakeCommands/target_link_libraries/SubDirC/SubDirC.c b/Tests/CMakeCommands/target_link_libraries/SubDirC/SubDirC.c
new file mode 100644
index 000000000..c5536dccd
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/SubDirC/SubDirC.c
@@ -0,0 +1,11 @@
+#ifndef DEF_SubDirC1
+# error "DEF_SubDirC1 not defined"
+#endif
+#ifndef DEF_SubDirC2
+# error "DEF_SubDirC2 not defined"
+#endif
+
+int SubDirC(void)
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_link_libraries/TopDir.c b/Tests/CMakeCommands/target_link_libraries/TopDir.c
new file mode 100644
index 000000000..d8066e5ca
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_libraries/TopDir.c
@@ -0,0 +1,20 @@
+#ifndef DEF_SameNameImportedSubDirA
+# error "DEF_SameNameImportedSubDirA is not defined but should be!"
+#endif
+#ifndef DEF_SameNameImportedSubDirB
+# error "DEF_SameNameImportedSubDirB is not defined but should be!"
+#endif
+#ifdef DEF_TopDirImported
+# error "DEF_TopDirImported is defined but should not be!"
+#endif
+#ifdef DEF_SubDirC1
+# error "DEF_SubDirC1 defined but should not be"
+#endif
+#ifdef DEF_SubDirC2
+# error "DEF_SubDirC2 defined but should not be"
+#endif
+
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022lib.h b/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022lib.h
index 3235b9bf1..e93901335 100644
--- a/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022lib.h
+++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022lib.h
@@ -1,6 +1,5 @@
-#include "cmp0022lib_export.h"
-
#include "cmp0022ifacelib.h"
+#include "cmp0022lib_export.h"
CMP0022Iface CMP0022LIB_EXPORT cmp0022();
diff --git a/Tests/CMakeCommands/target_link_libraries/depB.cpp b/Tests/CMakeCommands/target_link_libraries/depB.cpp
index 4f46552d7..276a91ae4 100644
--- a/Tests/CMakeCommands/target_link_libraries/depB.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/depB.cpp
@@ -2,7 +2,6 @@
#include "depB.h"
#include "depA.h"
-
#include "libgenex.h"
int DepB::foo()
diff --git a/Tests/CMakeCommands/target_link_libraries/depC.h b/Tests/CMakeCommands/target_link_libraries/depC.h
index 01c9e06bb..af7bfa3d9 100644
--- a/Tests/CMakeCommands/target_link_libraries/depC.h
+++ b/Tests/CMakeCommands/target_link_libraries/depC.h
@@ -1,7 +1,6 @@
-#include "depc_export.h"
-
#include "depA.h"
+#include "depc_export.h"
struct DEPC_EXPORT DepC
{
diff --git a/Tests/CMakeCommands/target_link_libraries/depD.h b/Tests/CMakeCommands/target_link_libraries/depD.h
index d24ff5f7c..e3700c36a 100644
--- a/Tests/CMakeCommands/target_link_libraries/depD.h
+++ b/Tests/CMakeCommands/target_link_libraries/depD.h
@@ -1,7 +1,6 @@
-#include "depd_export.h"
-
#include "depA.h"
+#include "depd_export.h"
struct DEPD_EXPORT DepD
{
diff --git a/Tests/CMakeCommands/target_link_libraries/libgenex.h b/Tests/CMakeCommands/target_link_libraries/libgenex.h
index 733f9b6df..59ac18a33 100644
--- a/Tests/CMakeCommands/target_link_libraries/libgenex.h
+++ b/Tests/CMakeCommands/target_link_libraries/libgenex.h
@@ -2,7 +2,7 @@
#include "libgenex_export.h"
#ifndef LIBGENEX_H
-#define LIBGENEX_H
+# define LIBGENEX_H
struct LIBGENEX_EXPORT LibGenex
{
diff --git a/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp b/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp
index 1caa516ad..b23b7a0aa 100644
--- a/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/newsignature1.cpp
@@ -2,7 +2,6 @@
#include "depB.h"
#include "depC.h"
#include "depIfaceOnly.h"
-
#include "subdirlib.h"
int main(int, char**)
diff --git a/Tests/CMakeCommands/target_link_libraries/targetA.cpp b/Tests/CMakeCommands/target_link_libraries/targetA.cpp
index 1caa516ad..b23b7a0aa 100644
--- a/Tests/CMakeCommands/target_link_libraries/targetA.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/targetA.cpp
@@ -2,7 +2,6 @@
#include "depB.h"
#include "depC.h"
#include "depIfaceOnly.h"
-
#include "subdirlib.h"
int main(int, char**)
diff --git a/Tests/CMakeCommands/target_link_libraries/targetC.cpp b/Tests/CMakeCommands/target_link_libraries/targetC.cpp
index 7c5c9e426..11efb3d5f 100644
--- a/Tests/CMakeCommands/target_link_libraries/targetC.cpp
+++ b/Tests/CMakeCommands/target_link_libraries/targetC.cpp
@@ -1,11 +1,10 @@
-#include "depG.h"
-
#include "bar.h"
+#include "depG.h"
#include "foo.h"
#ifndef TEST_DEF
-#error Expected TEST_DEF definition
+# error Expected TEST_DEF definition
#endif
int main(int, char**)
diff --git a/Tests/CMakeCommands/target_link_options/CMakeLists.txt b/Tests/CMakeCommands/target_link_options/CMakeLists.txt
new file mode 100644
index 000000000..e84d0410e
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_options/CMakeLists.txt
@@ -0,0 +1,34 @@
+
+cmake_minimum_required(VERSION 3.11)
+
+project(target_link_options LANGUAGES C)
+
+add_library(target_link_options SHARED LinkOptionsLib.c)
+# Test no items
+target_link_options(target_link_options PRIVATE)
+
+add_library(target_link_options_2 SHARED EXCLUDE_FROM_ALL LinkOptionsLib.c)
+target_link_options(target_link_options_2 PRIVATE -PRIVATE_FLAG INTERFACE -INTERFACE_FLAG)
+get_target_property(result target_link_options_2 LINK_OPTIONS)
+if (NOT result MATCHES "-PRIVATE_FLAG")
+ message(SEND_ERROR "target_link_options not populated the LINK_OPTIONS target property")
+endif()
+get_target_property(result target_link_options_2 INTERFACE_LINK_OPTIONS)
+if (NOT result MATCHES "-INTERFACE_FLAG")
+ message(SEND_ERROR "target_link_options not populated the INTERFACE_LINK_OPTIONS target property of shared library")
+endif()
+
+add_library(target_link_options_3 STATIC EXCLUDE_FROM_ALL LinkOptionsLib.c)
+target_link_options(target_link_options_3 INTERFACE -INTERFACE_FLAG)
+get_target_property(result target_link_options_3 INTERFACE_LINK_OPTIONS)
+if (NOT result MATCHES "-INTERFACE_FLAG")
+ message(SEND_ERROR "target_link_options not populated the INTERFACE_LINK_OPTIONS target property of static library")
+endif()
+
+add_library(target_link_options_4 SHARED EXCLUDE_FROM_ALL LinkOptionsLib.c)
+target_link_options(target_link_options_4 PRIVATE -PRIVATE_FLAG)
+target_link_options(target_link_options_4 BEFORE PRIVATE -BEFORE_PRIVATE_FLAG)
+get_target_property(result target_link_options_4 LINK_OPTIONS)
+if (NOT result MATCHES "-BEFORE_PRIVATE_FLAG.*-PRIVATE_FLAG")
+ message(SEND_ERROR "target_link_options not managing correctly 'BEFORE' keyword")
+endif()
diff --git a/Tests/CMakeCommands/target_link_options/LinkOptionsLib.c b/Tests/CMakeCommands/target_link_options/LinkOptionsLib.c
new file mode 100644
index 000000000..9bbd24cd8
--- /dev/null
+++ b/Tests/CMakeCommands/target_link_options/LinkOptionsLib.c
@@ -0,0 +1,7 @@
+#if defined(_WIN32)
+__declspec(dllexport)
+#endif
+ int flags_lib(void)
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_sources/CMakeLists.txt b/Tests/CMakeCommands/target_sources/CMakeLists.txt
new file mode 100644
index 000000000..ab14855c7
--- /dev/null
+++ b/Tests/CMakeCommands/target_sources/CMakeLists.txt
@@ -0,0 +1,36 @@
+
+cmake_minimum_required(VERSION 3.12)
+cmake_policy(SET CMP0076 NEW)
+
+project(target_sources)
+
+add_library(target_sources_lib)
+target_compile_definitions(target_sources_lib PRIVATE "-DIS_LIB")
+add_subdirectory(subdir)
+
+set(subdir_fullpath "${CMAKE_CURRENT_LIST_DIR}/subdir")
+
+get_property(target_sources_lib_property TARGET target_sources_lib PROPERTY SOURCES)
+if (NOT "$<1:${subdir_fullpath}/subdir_empty_1.cpp>" IN_LIST target_sources_lib_property)
+ message(SEND_ERROR "target_sources_lib: Generator expression to absolute sub directory file not found")
+endif()
+if (NOT "$<1:${subdir_fullpath}/../empty_1.cpp>" IN_LIST target_sources_lib_property)
+ message(SEND_ERROR "target_sources_lib: Generator expression to absolute main directory file not found")
+endif()
+if (NOT "${subdir_fullpath}/subdir_empty_2.cpp" IN_LIST target_sources_lib_property)
+ message(SEND_ERROR "target_sources_lib: Relative sub directory file not converted to absolute")
+endif()
+if (NOT "$<1:empty_2.cpp>" IN_LIST target_sources_lib_property)
+ message(SEND_ERROR "target_sources_lib: Generator expression to relative main directory file not found")
+endif()
+if (NOT "${subdir_fullpath}/../empty_3.cpp" IN_LIST target_sources_lib_property)
+ message(SEND_ERROR "target_sources_lib: Relative main directory file not converted to absolute")
+endif()
+
+add_executable(target_sources main.cpp)
+target_link_libraries(target_sources target_sources_lib)
+
+get_property(target_sources_property TARGET target_sources PROPERTY SOURCES)
+if (NOT "main.cpp" IN_LIST target_sources_property)
+ message(SEND_ERROR "target_sources: Relative main directory file converted to absolute")
+endif()
diff --git a/Tests/CMakeCommands/target_sources/empty_1.cpp b/Tests/CMakeCommands/target_sources/empty_1.cpp
new file mode 100644
index 000000000..01e5b07ae
--- /dev/null
+++ b/Tests/CMakeCommands/target_sources/empty_1.cpp
@@ -0,0 +1,21 @@
+#ifdef IS_LIB
+
+# ifdef _WIN32
+__declspec(dllexport)
+# endif
+ int internal_empty_1()
+{
+ return 0;
+}
+
+#else
+
+# ifdef _WIN32
+__declspec(dllexport)
+# endif
+ int empty_1()
+{
+ return 0;
+}
+
+#endif
diff --git a/Tests/CMakeCommands/target_sources/empty_2.cpp b/Tests/CMakeCommands/target_sources/empty_2.cpp
new file mode 100644
index 000000000..48ae8bb23
--- /dev/null
+++ b/Tests/CMakeCommands/target_sources/empty_2.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int empty_2()
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_sources/empty_3.cpp b/Tests/CMakeCommands/target_sources/empty_3.cpp
new file mode 100644
index 000000000..bd3a6d1c8
--- /dev/null
+++ b/Tests/CMakeCommands/target_sources/empty_3.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int empty_3()
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_sources/main.cpp b/Tests/CMakeCommands/target_sources/main.cpp
new file mode 100644
index 000000000..622771cb9
--- /dev/null
+++ b/Tests/CMakeCommands/target_sources/main.cpp
@@ -0,0 +1,16 @@
+#include <iostream>
+
+int empty_1();
+int subdir_empty_1();
+int subdir_empty_2();
+
+int main()
+{
+ int e1 = empty_1();
+ int se1 = subdir_empty_1();
+ int se2 = subdir_empty_2();
+
+ std::cout << e1 << " " << se1 << " " << se2 << std::endl;
+
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_sources/subdir/CMakeLists.txt b/Tests/CMakeCommands/target_sources/subdir/CMakeLists.txt
new file mode 100644
index 000000000..f749f1d7a
--- /dev/null
+++ b/Tests/CMakeCommands/target_sources/subdir/CMakeLists.txt
@@ -0,0 +1,6 @@
+
+target_sources(target_sources_lib PUBLIC $<1:${CMAKE_CURRENT_LIST_DIR}/subdir_empty_1.cpp>
+ $<1:${CMAKE_CURRENT_LIST_DIR}/../empty_1.cpp>
+ subdir_empty_2.cpp
+ PRIVATE $<1:empty_2.cpp>
+ ../empty_3.cpp)
diff --git a/Tests/CMakeCommands/target_sources/subdir/subdir_empty_1.cpp b/Tests/CMakeCommands/target_sources/subdir/subdir_empty_1.cpp
new file mode 100644
index 000000000..3c61321a1
--- /dev/null
+++ b/Tests/CMakeCommands/target_sources/subdir/subdir_empty_1.cpp
@@ -0,0 +1,21 @@
+#ifdef IS_LIB
+
+# ifdef _WIN32
+__declspec(dllexport)
+# endif
+ int internal_subdir_empty_1()
+{
+ return 0;
+}
+
+#else
+
+# ifdef _WIN32
+__declspec(dllexport)
+# endif
+ int subdir_empty_1()
+{
+ return 0;
+}
+
+#endif
diff --git a/Tests/CMakeCommands/target_sources/subdir/subdir_empty_2.cpp b/Tests/CMakeCommands/target_sources/subdir/subdir_empty_2.cpp
new file mode 100644
index 000000000..47fa73697
--- /dev/null
+++ b/Tests/CMakeCommands/target_sources/subdir/subdir_empty_2.cpp
@@ -0,0 +1,21 @@
+#ifdef IS_LIB
+
+# ifdef _WIN32
+__declspec(dllexport)
+# endif
+ int internal_subdir_empty_2()
+{
+ return 0;
+}
+
+#else
+
+# ifdef _WIN32
+__declspec(dllexport)
+# endif
+ int subdir_empty_2()
+{
+ return 0;
+}
+
+#endif
diff --git a/Tests/CMakeInstall.cmake b/Tests/CMakeInstall.cmake
index fda8c54b3..d9d85f71b 100644
--- a/Tests/CMakeInstall.cmake
+++ b/Tests/CMakeInstall.cmake
@@ -14,7 +14,18 @@ if(CMake_TEST_INSTALL)
set(CMake_TEST_INSTALL_PREFIX ${CMake_BINARY_DIR}/Tests/CMakeInstall)
set(CMAKE_INSTALL_PREFIX "${CMake_TEST_INSTALL_PREFIX}")
- if(CMAKE_CONFIGURATION_TYPES)
+ # 3.9 or later provides a definitive answer to whether we are multi-config
+ # through a global property. Prior to 3.9, CMAKE_CONFIGURATION_TYPES being set
+ # is assumed to mean multi-config, but developers might modify it so it is
+ # technically not as reliable.
+ if(NOT CMAKE_VERSION VERSION_LESS 3.9)
+ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ elseif(CMAKE_CONFIGURATION_TYPES)
+ set(_isMultiConfig True)
+ else()
+ set(_isMultiConfig False)
+ endif()
+ if(_isMultiConfig)
# There are multiple configurations. Make sure the tested
# configuration is the one that is installed.
set(CMake_TEST_INSTALL_CONFIG --config $<CONFIGURATION>)
diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt
index d1a1df5ed..840afc168 100644
--- a/Tests/CMakeLib/CMakeLists.txt
+++ b/Tests/CMakeLib/CMakeLists.txt
@@ -2,23 +2,41 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMake_BINARY_DIR}/Source
${CMake_SOURCE_DIR}/Source
+ ${CMake_SOURCE_DIR}/Source/CTest
)
set(CMakeLib_TESTS
- testGeneratedFileStream
- testRST
- testSystemTools
- testUTF8
- testXMLParser
- testXMLSafe
- testFindPackageCommand
+ testArgumentParser.cxx
+ testCTestBinPacker.cxx
+ testCTestResourceAllocator.cxx
+ testCTestResourceSpec.cxx
+ testCTestResourceGroups.cxx
+ testGeneratedFileStream.cxx
+ testRST.cxx
+ testRange.cxx
+ testOptional.cxx
+ testString.cxx
+ testStringAlgorithms.cxx
+ testSystemTools.cxx
+ testUTF8.cxx
+ testXMLParser.cxx
+ testXMLSafe.cxx
+ testFindPackageCommand.cxx
+ testUVProcessChain.cxx
+ testUVRAII.cxx
+ testUVStreambuf.cxx
)
+add_executable(testUVProcessChainHelper testUVProcessChainHelper.cxx)
+
set(testRST_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
+set(testUVProcessChain_ARGS $<TARGET_FILE:testUVProcessChainHelper>)
+set(testUVStreambuf_ARGS $<TARGET_FILE:cmake>)
+set(testCTestResourceSpec_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
if(WIN32)
list(APPEND CMakeLib_TESTS
- testVisualStudioSlnParser
+ testVisualStudioSlnParser.cxx
)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testVisualStudioSlnParser.h.in
${CMAKE_CURRENT_BINARY_DIR}/testVisualStudioSlnParser.h @ONLY)
@@ -29,13 +47,17 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testXMLParser.h.in
create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS})
add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS})
-target_link_libraries(CMakeLibTests CMakeLib)
+target_link_libraries(CMakeLibTests CMakeLib CTestLib)
+
+set_property(TARGET CMakeLibTests PROPERTY C_CLANG_TIDY "")
+set_property(TARGET CMakeLibTests PROPERTY CXX_CLANG_TIDY "")
add_executable(testEncoding testEncoding.cxx)
target_link_libraries(testEncoding cmsys)
-foreach(test ${CMakeLib_TESTS})
- add_test(CMakeLib.${test} CMakeLibTests ${test} ${${test}_ARGS})
+foreach(testfile ${CMakeLib_TESTS})
+ get_filename_component(test "${testfile}" NAME_WE)
+ add_test(NAME CMakeLib.${test} COMMAND CMakeLibTests ${test} ${${test}_ARGS})
endforeach()
if(TEST_CompileCommandOutput)
@@ -44,3 +66,6 @@ if(TEST_CompileCommandOutput)
endif()
add_subdirectory(PseudoMemcheck)
+
+add_executable(testAffinity testAffinity.cxx)
+target_link_libraries(testAffinity CMakeLib)
diff --git a/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in
index b4c6fae44..3183bc0b6 100644
--- a/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in
+++ b/Tests/CMakeLib/PseudoMemcheck/memtester.cxx.in
@@ -15,15 +15,15 @@ int main(int ac, char** av)
std::string logarg;
bool nextarg = false;
- if (exename.find("valgrind") != exename.npos) {
+ if (exename.find("valgrind") != std::string::npos) {
logarg = "--log-file=";
- } else if (exename.find("purify") != exename.npos) {
+ } else if (exename.find("purify") != std::string::npos) {
#ifdef _WIN32
logarg = "/SAVETEXTDATA=";
#else
logarg = "-log-file=";
#endif
- } else if (exename.find("BC") != exename.npos) {
+ } else if (exename.find("BC") != std::string::npos) {
nextarg = true;
logarg = "/X";
}
diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx
index 46431bc33..2c77accf1 100644
--- a/Tests/CMakeLib/run_compile_commands.cxx
+++ b/Tests/CMakeLib/run_compile_commands.cxx
@@ -1,13 +1,14 @@
-#include <cmConfigure.h>
+#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmsys/FStream.hxx"
+#include <cstdlib>
#include <iostream>
#include <map>
-#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
+#include "cmsys/FStream.hxx"
+
#include "cmSystemTools.h"
class CompileCommandParser
@@ -18,7 +19,7 @@ public:
public:
std::string const& at(std::string const& k) const
{
- const_iterator i = this->find(k);
+ auto i = this->find(k);
if (i != this->end()) {
return i->second;
}
@@ -26,7 +27,7 @@ public:
return emptyString;
}
};
- typedef std::vector<CommandType> TranslationUnitsType;
+ using TranslationUnitsType = std::vector<CommandType>;
CompileCommandParser(std::istream& input)
: Input(input)
@@ -144,15 +145,11 @@ int main()
cmsys::ifstream file("compile_commands.json");
CompileCommandParser parser(file);
parser.Parse();
- for (CompileCommandParser::TranslationUnitsType::const_iterator
- it = parser.GetTranslationUnits().begin(),
- end = parser.GetTranslationUnits().end();
- it != end; ++it) {
+ for (auto const& tu : parser.GetTranslationUnits()) {
std::vector<std::string> command;
- cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command);
- if (!cmSystemTools::RunSingleCommand(command, CM_NULLPTR, CM_NULLPTR,
- CM_NULLPTR,
- it->at("directory").c_str())) {
+ cmSystemTools::ParseUnixCommandLine(tu.at("command").c_str(), command);
+ if (!cmSystemTools::RunSingleCommand(command, nullptr, nullptr, nullptr,
+ tu.at("directory").c_str())) {
std::cout << "ERROR: Failed to run command \"" << command[0] << "\""
<< std::endl;
exit(1);
diff --git a/Tests/CMakeLib/testAffinity.cxx b/Tests/CMakeLib/testAffinity.cxx
new file mode 100644
index 000000000..6c6857079
--- /dev/null
+++ b/Tests/CMakeLib/testAffinity.cxx
@@ -0,0 +1,18 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include <cstddef>
+#include <iostream>
+#include <set>
+
+#include "cmAffinity.h"
+
+int main()
+{
+ std::set<size_t> cpus = cmAffinity::GetProcessorsAvailable();
+ if (!cpus.empty()) {
+ std::cout << "CPU affinity mask count is '" << cpus.size() << "'.\n";
+ } else {
+ std::cout << "CPU affinity not supported on this platform.\n";
+ }
+ return 0;
+}
diff --git a/Tests/CMakeLib/testArgumentParser.cxx b/Tests/CMakeLib/testArgumentParser.cxx
new file mode 100644
index 000000000..20f98c2a2
--- /dev/null
+++ b/Tests/CMakeLib/testArgumentParser.cxx
@@ -0,0 +1,149 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include <initializer_list>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include <cm/string_view>
+
+#include "cm_static_string_view.hxx"
+
+#include "cmArgumentParser.h"
+
+namespace {
+
+struct Result
+{
+ bool Option1 = false;
+ bool Option2 = false;
+
+ std::string String1;
+ std::string String2;
+
+ std::vector<std::string> List1;
+ std::vector<std::string> List2;
+ std::vector<std::string> List3;
+
+ std::vector<std::vector<std::string>> Multi1;
+ std::vector<std::vector<std::string>> Multi2;
+ std::vector<std::vector<std::string>> Multi3;
+};
+
+std::initializer_list<cm::string_view> const args = {
+ /* clang-format off */
+ "OPTION_1", // option
+ "STRING_1", // string arg missing value
+ "STRING_2", "foo", "bar", // string arg + unparsed value
+ "LIST_1", // list arg missing values
+ "LIST_2", "foo", "bar", // list arg with 2 elems
+ "LIST_3", "bar", // list arg ...
+ "LIST_3", "foo", // ... with continuation
+ "MULTI_2", // multi list with 0 lists
+ "MULTI_3", "foo", "bar", // multi list with first list with two elems
+ "MULTI_3", "bar", "foo", // multi list with second list with two elems
+ /* clang-format on */
+};
+
+bool verifyResult(Result const& result,
+ std::vector<std::string> const& unparsedArguments,
+ std::vector<std::string> const& keywordsMissingValue)
+{
+ static std::vector<std::string> const foobar = { "foo", "bar" };
+ static std::vector<std::string> const barfoo = { "bar", "foo" };
+ static std::vector<std::string> const missing = { "STRING_1", "LIST_1" };
+
+#define ASSERT_TRUE(x) \
+ do { \
+ if (!(x)) { \
+ std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \
+ return false; \
+ } \
+ } while (false)
+
+ ASSERT_TRUE(result.Option1);
+ ASSERT_TRUE(!result.Option2);
+
+ ASSERT_TRUE(result.String1.empty());
+ ASSERT_TRUE(result.String2 == "foo");
+
+ ASSERT_TRUE(result.List1.empty());
+ ASSERT_TRUE(result.List2 == foobar);
+ ASSERT_TRUE(result.List3 == barfoo);
+
+ ASSERT_TRUE(result.Multi1.empty());
+ ASSERT_TRUE(result.Multi2.size() == 1);
+ ASSERT_TRUE(result.Multi2[0].empty());
+ ASSERT_TRUE(result.Multi3.size() == 2);
+ ASSERT_TRUE(result.Multi3[0] == foobar);
+ ASSERT_TRUE(result.Multi3[1] == barfoo);
+
+ ASSERT_TRUE(unparsedArguments.size() == 1);
+ ASSERT_TRUE(unparsedArguments[0] == "bar");
+ ASSERT_TRUE(keywordsMissingValue == missing);
+
+ return true;
+}
+
+bool testArgumentParserDynamic()
+{
+ Result result;
+ std::vector<std::string> unparsedArguments;
+ std::vector<std::string> keywordsMissingValue;
+
+ cmArgumentParser<void>{}
+ .Bind("OPTION_1"_s, result.Option1)
+ .Bind("OPTION_2"_s, result.Option2)
+ .Bind("STRING_1"_s, result.String1)
+ .Bind("STRING_2"_s, result.String2)
+ .Bind("LIST_1"_s, result.List1)
+ .Bind("LIST_2"_s, result.List2)
+ .Bind("LIST_3"_s, result.List3)
+ .Bind("MULTI_1"_s, result.Multi1)
+ .Bind("MULTI_2"_s, result.Multi2)
+ .Bind("MULTI_3"_s, result.Multi3)
+ .Parse(args, &unparsedArguments, &keywordsMissingValue);
+
+ return verifyResult(result, unparsedArguments, keywordsMissingValue);
+}
+
+bool testArgumentParserStatic()
+{
+ static auto const parser = //
+ cmArgumentParser<Result>{}
+ .Bind("OPTION_1"_s, &Result::Option1)
+ .Bind("OPTION_2"_s, &Result::Option2)
+ .Bind("STRING_1"_s, &Result::String1)
+ .Bind("STRING_2"_s, &Result::String2)
+ .Bind("LIST_1"_s, &Result::List1)
+ .Bind("LIST_2"_s, &Result::List2)
+ .Bind("LIST_3"_s, &Result::List3)
+ .Bind("MULTI_1"_s, &Result::Multi1)
+ .Bind("MULTI_2"_s, &Result::Multi2)
+ .Bind("MULTI_3"_s, &Result::Multi3);
+
+ std::vector<std::string> unparsedArguments;
+ std::vector<std::string> keywordsMissingValue;
+ Result const result =
+ parser.Parse(args, &unparsedArguments, &keywordsMissingValue);
+
+ return verifyResult(result, unparsedArguments, keywordsMissingValue);
+}
+
+} // namespace
+
+int testArgumentParser(int /*unused*/, char* /*unused*/ [])
+{
+ if (!testArgumentParserDynamic()) {
+ std::cout << "While executing testArgumentParserDynamic().\n";
+ return -1;
+ }
+
+ if (!testArgumentParserStatic()) {
+ std::cout << "While executing testArgumentParserStatic().\n";
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/Tests/CMakeLib/testCTestBinPacker.cxx b/Tests/CMakeLib/testCTestBinPacker.cxx
new file mode 100644
index 000000000..6f09af20e
--- /dev/null
+++ b/Tests/CMakeLib/testCTestBinPacker.cxx
@@ -0,0 +1,300 @@
+#include <cstddef>
+#include <iostream>
+#include <map>
+#include <string>
+#include <vector>
+
+#include "cmCTestBinPacker.h"
+#include "cmCTestResourceAllocator.h"
+
+struct ExpectedPackResult
+{
+ std::vector<int> SlotsNeeded;
+ std::map<std::string, cmCTestResourceAllocator::Resource> Resources;
+ bool ExpectedReturnValue;
+ std::vector<cmCTestBinPackerAllocation> ExpectedRoundRobinAllocations;
+ std::vector<cmCTestBinPackerAllocation> ExpectedBlockAllocations;
+};
+
+static const std::vector<ExpectedPackResult> expectedResults
+{
+ /* clang-format off */
+ {
+ { 2, 2, 2, 2 },
+ { { "0", { 4, 0 } }, { "1", { 4, 0 } }, { "2", { 4, 0 } },
+ { "3", { 4, 0 } } },
+ true,
+ {
+ { 0, 2, "0" },
+ { 1, 2, "1" },
+ { 2, 2, "2" },
+ { 3, 2, "3" },
+ },
+ {
+ { 0, 2, "0" },
+ { 1, 2, "0" },
+ { 2, 2, "1" },
+ { 3, 2, "1" },
+ },
+ },
+ {
+ { 2, 3, 2 },
+ { { "0", { 5, 0 } }, { "1", { 2, 0 } } },
+ true,
+ {
+ { 0, 2, "0" },
+ { 1, 3, "0" },
+ { 2, 2, "1" },
+ },
+ {
+ { 0, 2, "0" },
+ { 1, 3, "0" },
+ { 2, 2, "1" },
+ },
+ },
+ {
+ { 1, 2, 3 },
+ { { "0", { 1, 0 } }, { "1", { 2, 0 } }, { "2", { 2, 0 } } },
+ false,
+ { },
+ { },
+ },
+ {
+ { 48, 21, 31, 10, 40 },
+ { { "0", { 81, 0 } }, { "1", { 68, 0 } }, { "2", { 20, 0 } },
+ { "3", { 13, 0 } } },
+ true,
+ {
+ { 0, 48, "0" },
+ { 1, 21, "1" },
+ { 2, 31, "0" },
+ { 3, 10, "2" },
+ { 4, 40, "1" },
+ },
+ {
+ { 0, 48, "0" },
+ { 1, 21, "1" },
+ { 2, 31, "0" },
+ { 3, 10, "2" },
+ { 4, 40, "1" },
+ },
+ },
+ {
+ { 30, 31, 39, 67 },
+ { { "0", { 16, 0 } }, { "1", { 81, 0 } }, { "2", { 97, 0 } } },
+ true,
+ {
+ { 0, 30, "2" },
+ { 1, 31, "1" },
+ { 2, 39, "1" },
+ { 3, 67, "2" },
+ },
+ {
+ { 0, 30, "2" },
+ { 1, 31, "1" },
+ { 2, 39, "1" },
+ { 3, 67, "2" },
+ },
+ },
+ {
+ { 63, 47, 1, 9 },
+ { { "0", { 18, 0 } }, { "1", { 29, 0 } }, { "2", { 9, 0 } },
+ { "3", { 52, 0 } } },
+ false,
+ { },
+ { },
+ },
+ {
+ { 22, 29, 46, 85 },
+ { { "0", { 65, 0 } }, { "1", { 85, 0 } }, { "2", { 65, 0 } },
+ { "3", { 78, 0 } } },
+ true,
+ {
+ { 0, 22, "2" },
+ { 1, 29, "0" },
+ { 2, 46, "3" },
+ { 3, 85, "1" },
+ },
+ {
+ { 0, 22, "0" },
+ { 1, 29, "3" },
+ { 2, 46, "3" },
+ { 3, 85, "1" },
+ },
+ },
+ {
+ { 66, 11, 34, 21 },
+ { { "0", { 24, 0 } }, { "1", { 57, 0 } }, { "2", { 61, 0 } },
+ { "3", { 51, 0 } } },
+ false,
+ { },
+ { },
+ },
+ {
+ { 72, 65, 67, 45 },
+ { { "0", { 29, 0 } }, { "1", { 77, 0 } }, { "2", { 98, 0 } },
+ { "3", { 58, 0 } } },
+ false,
+ { },
+ { },
+ },
+ /*
+ * The following is a contrived attack on the bin-packing algorithm that
+ * causes it to execute with n! complexity, where n is the number of
+ * resources. This case is very unrepresentative of real-world usage, and
+ * has been documented but disabled. The bin-packing problem is NP-hard, and
+ * we may not be able to fix this case at all.
+ */
+#if 0
+ {
+ { 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 19 },
+ { { "0", { 1000, 0 } }, { "1", { 1001, 0 } }, { "2", { 1002, 0 } },
+ { "3", { 1003, 0 } }, { "4", { 1004, 0 } }, { "5", { 1005, 0 } },
+ { "6", { 1006, 0 } }, { "7", { 1007, 0 } }, { "8", { 1008, 0 } },
+ { "9", { 1009, 0 } } },
+ false,
+ { },
+ { },
+ },
+#endif
+ /*
+ * These cases are more representative of real-world usage (the resource
+ * sizes are all the same.)
+ */
+ {
+ { 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 10 },
+ { { "0", { 1000, 0 } }, { "1", { 1000, 0 } }, { "2", { 1000, 0 } },
+ { "3", { 1000, 0 } }, { "4", { 1000, 0 } }, { "5", { 1000, 0 } },
+ { "6", { 1000, 0 } }, { "7", { 1000, 0 } }, { "8", { 1000, 0 } },
+ { "9", { 1000, 0 } } },
+ false,
+ { },
+ { },
+ },
+ {
+ { 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 9 },
+ { { "0", { 1000, 0 } }, { "1", { 1000, 0 } }, { "2", { 1000, 0 } },
+ { "3", { 1000, 0 } }, { "4", { 1000, 0 } }, { "5", { 1000, 0 } },
+ { "6", { 1000, 0 } }, { "7", { 1000, 0 } }, { "8", { 1000, 0 } },
+ { "9", { 1000, 0 } } },
+ true,
+ {
+ { 0, 1000, "0" },
+ { 1, 999, "1" },
+ { 2, 998, "2" },
+ { 3, 997, "3" },
+ { 4, 996, "4" },
+ { 5, 995, "5" },
+ { 6, 994, "6" },
+ { 7, 993, "7" },
+ { 8, 992, "8" },
+ { 9, 991, "9" },
+ { 10, 9, "9" },
+ },
+ {
+ { 0, 1000, "0" },
+ { 1, 999, "1" },
+ { 2, 998, "2" },
+ { 3, 997, "3" },
+ { 4, 996, "4" },
+ { 5, 995, "5" },
+ { 6, 994, "6" },
+ { 7, 993, "7" },
+ { 8, 992, "8" },
+ { 9, 991, "9" },
+ { 10, 9, "9" },
+ },
+ },
+ /* clang-format on */
+};
+
+struct AllocationComparison
+{
+ cmCTestBinPackerAllocation First;
+ cmCTestBinPackerAllocation Second;
+ bool Equal;
+};
+
+static const std::vector<AllocationComparison> comparisons{
+ /* clang-format off */
+ { { 0, 1, "0" }, { 0, 1, "0" }, true },
+ { { 0, 1, "0" }, { 1, 1, "0" }, false },
+ { { 0, 1, "0" }, { 0, 2, "0" }, false },
+ { { 0, 1, "0" }, { 0, 1, "1" }, false },
+ /* clang-format on */
+};
+
+bool TestExpectedPackResult(const ExpectedPackResult& expected)
+{
+ std::vector<cmCTestBinPackerAllocation> roundRobinAllocations;
+ roundRobinAllocations.reserve(expected.SlotsNeeded.size());
+ std::size_t index = 0;
+ for (auto const& n : expected.SlotsNeeded) {
+ roundRobinAllocations.push_back({ index++, n, "" });
+ }
+
+ bool roundRobinResult = cmAllocateCTestResourcesRoundRobin(
+ expected.Resources, roundRobinAllocations);
+ if (roundRobinResult != expected.ExpectedReturnValue) {
+ std::cout
+ << "cmAllocateCTestResourcesRoundRobin did not return expected value"
+ << std::endl;
+ return false;
+ }
+
+ if (roundRobinResult &&
+ roundRobinAllocations != expected.ExpectedRoundRobinAllocations) {
+ std::cout << "cmAllocateCTestResourcesRoundRobin did not return expected "
+ "allocations"
+ << std::endl;
+ return false;
+ }
+
+ std::vector<cmCTestBinPackerAllocation> blockAllocations;
+ blockAllocations.reserve(expected.SlotsNeeded.size());
+ index = 0;
+ for (auto const& n : expected.SlotsNeeded) {
+ blockAllocations.push_back({ index++, n, "" });
+ }
+
+ bool blockResult =
+ cmAllocateCTestResourcesBlock(expected.Resources, blockAllocations);
+ if (blockResult != expected.ExpectedReturnValue) {
+ std::cout << "cmAllocateCTestResourcesBlock did not return expected value"
+ << std::endl;
+ return false;
+ }
+
+ if (blockResult && blockAllocations != expected.ExpectedBlockAllocations) {
+ std::cout << "cmAllocateCTestResourcesBlock did not return expected"
+ " allocations"
+ << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+int testCTestBinPacker(int /*unused*/, char* /*unused*/ [])
+{
+ int retval = 0;
+
+ for (auto const& comparison : comparisons) {
+ if ((comparison.First == comparison.Second) != comparison.Equal) {
+ std::cout << "Comparison did not match expected" << std::endl;
+ retval = 1;
+ }
+ if ((comparison.First != comparison.Second) == comparison.Equal) {
+ std::cout << "Comparison did not match expected" << std::endl;
+ retval = 1;
+ }
+ }
+
+ for (auto const& expected : expectedResults) {
+ if (!TestExpectedPackResult(expected)) {
+ retval = 1;
+ }
+ }
+
+ return retval;
+}
diff --git a/Tests/CMakeLib/testCTestResourceAllocator.cxx b/Tests/CMakeLib/testCTestResourceAllocator.cxx
new file mode 100644
index 000000000..33d6b913d
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceAllocator.cxx
@@ -0,0 +1,426 @@
+#include <iostream>
+#include <map>
+#include <string>
+#include <vector>
+
+#include "cmCTestResourceAllocator.h"
+#include "cmCTestResourceSpec.h"
+
+static const cmCTestResourceSpec spec{ { {
+ /* clang-format off */
+ { "gpus", { { "0", 4 }, { "1", 8 }, { "2", 0 }, { "3", 8 } } },
+ /* clang-format on */
+} } };
+
+bool testInitializeFromResourceSpec()
+{
+ bool retval = true;
+
+ cmCTestResourceAllocator allocator;
+ allocator.InitializeFromResourceSpec(spec);
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 0 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.GetResources() != expected) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ return retval;
+}
+
+bool testAllocateResource()
+{
+ bool retval = true;
+
+ cmCTestResourceAllocator allocator;
+ allocator.InitializeFromResourceSpec(spec);
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected1{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 2 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (!allocator.AllocateResource("gpus", "0", 2)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"0\", 2) returned false, should be "
+ "true\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected1) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected2{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 4 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (!allocator.AllocateResource("gpus", "0", 2)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"0\", 2) returned false, should be "
+ "true\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected2) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected3{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 4 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.AllocateResource("gpus", "0", 1)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"0\", 1) returned true, should be "
+ "false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected3) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected4{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 4 } },
+ { "1", { 8, 7 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (!allocator.AllocateResource("gpus", "1", 7)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"1\", 7) returned false, should be "
+ "true\n";
+ retval = false;
+ }
+ if (allocator.AllocateResource("gpus", "1", 2)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"1\", 2) returned true, should be "
+ "false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected4) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected5{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 4 } },
+ { "1", { 8, 7 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.AllocateResource("gpus", "2", 1)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"2\", 1) returned true, should be "
+ "false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected5) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected6{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 4 } },
+ { "1", { 8, 7 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.AllocateResource("gpus", "4", 1)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"4\", 1) returned true, should be "
+ "false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected6) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected7{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 4 } },
+ { "1", { 8, 7 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.AllocateResource("threads", "0", 1)) {
+ std::cout
+ << "AllocateResource(\"threads\", \"0\", 1) returned true, should be"
+ " false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected7) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ return retval;
+}
+
+bool testDeallocateResource()
+{
+ bool retval = true;
+
+ cmCTestResourceAllocator allocator;
+ allocator.InitializeFromResourceSpec(spec);
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected1{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 1 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (!allocator.AllocateResource("gpus", "0", 2)) {
+ std::cout
+ << "AllocateResource(\"gpus\", \"0\", 2) returned false, should be "
+ "true\n";
+ retval = false;
+ }
+ if (!allocator.DeallocateResource("gpus", "0", 1)) {
+ std::cout
+ << "DeallocateResource(\"gpus\", \"0\", 1) returned false, should be"
+ " true\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected1) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected2{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 1 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.DeallocateResource("gpus", "0", 2)) {
+ std::cout
+ << "DeallocateResource(\"gpus\", \"0\", 2) returned true, should be"
+ " false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected2) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected3{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 0 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (!allocator.DeallocateResource("gpus", "0", 1)) {
+ std::cout
+ << "DeallocateResource(\"gpus\", \"0\", 1) returned false, should be"
+ " true\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected3) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected4{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 0 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.DeallocateResource("gpus", "0", 1)) {
+ std::cout
+ << "DeallocateResource(\"gpus\", \"0\", 1) returned true, should be"
+ " false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected4) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected5{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 0 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.DeallocateResource("gpus", "4", 1)) {
+ std::cout
+ << "DeallocateResource(\"gpus\", \"4\", 1) returned true, should be"
+ " false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected5) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ static const std::map<
+ std::string, std::map<std::string, cmCTestResourceAllocator::Resource>>
+ expected6{
+ /* clang-format off */
+ { "gpus", {
+ { "0", { 4, 0 } },
+ { "1", { 8, 0 } },
+ { "2", { 0, 0 } },
+ { "3", { 8, 0 } },
+ } },
+ /* clang-format on */
+ };
+ if (allocator.DeallocateResource("threads", "0", 1)) {
+ std::cout
+ << "DeallocateResource(\"threads\", \"0\", 1) returned true, should be"
+ " false\n";
+ retval = false;
+ }
+ if (allocator.GetResources() != expected6) {
+ std::cout << "GetResources() did not return expected value\n";
+ retval = false;
+ }
+
+ return retval;
+}
+
+bool testResourceFree()
+{
+ bool retval = true;
+
+ const cmCTestResourceAllocator::Resource r1{ 5, 0 };
+ if (r1.Free() != 5) {
+ std::cout << "cmCTestResourceAllocator::Resource::Free() did not return "
+ "expected value for { 5, 0 }\n";
+ retval = false;
+ }
+
+ const cmCTestResourceAllocator::Resource r2{ 3, 2 };
+ if (r2.Free() != 1) {
+ std::cout << "cmCTestResourceAllocator::Resource::Free() did not return "
+ "expected value for { 3, 2 }\n";
+ retval = false;
+ }
+
+ const cmCTestResourceAllocator::Resource r3{ 4, 4 };
+ if (r3.Free() != 0) {
+ std::cout << "cmCTestResourceAllocator::Resource::Free() did not return "
+ "expected value for { 4, 4 }\n";
+ retval = false;
+ }
+
+ return retval;
+}
+
+int testCTestResourceAllocator(int, char** const)
+{
+ int retval = 0;
+
+ if (!testInitializeFromResourceSpec()) {
+ std::cout << "in testInitializeFromResourceSpec()\n";
+ retval = -1;
+ }
+
+ if (!testAllocateResource()) {
+ std::cout << "in testAllocateResource()\n";
+ retval = -1;
+ }
+
+ if (!testDeallocateResource()) {
+ std::cout << "in testDeallocateResource()\n";
+ retval = -1;
+ }
+
+ if (!testResourceFree()) {
+ std::cout << "in testResourceFree()\n";
+ retval = -1;
+ }
+
+ return retval;
+}
diff --git a/Tests/CMakeLib/testCTestResourceGroups.cxx b/Tests/CMakeLib/testCTestResourceGroups.cxx
new file mode 100644
index 000000000..c3532a68d
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceGroups.cxx
@@ -0,0 +1,141 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "cmCTestTestHandler.h"
+
+struct ExpectedParseResult
+{
+ std::string String;
+ bool ExpectedReturnValue;
+ std::vector<std::vector<cmCTestTestHandler::cmCTestTestResourceRequirement>>
+ ExpectedValue;
+};
+
+static const std::vector<ExpectedParseResult> expectedResults{
+ /* clang-format off */
+ { "threads:2", true, {
+ { { "threads", 2, 1 } },
+ } },
+ { "3,threads:2", true, {
+ { { "threads", 2, 1 } },
+ { { "threads", 2, 1 } },
+ { { "threads", 2, 1 } },
+ } },
+ { "3,threads:2,gpus:4", true, {
+ { { "threads", 2, 1 }, { "gpus", 4, 1 } },
+ { { "threads", 2, 1 }, { "gpus", 4, 1 } },
+ { { "threads", 2, 1 }, { "gpus", 4, 1 } },
+ } },
+ { "2,threads:2;gpus:4", true, {
+ { { "threads", 2, 1 } },
+ { { "threads", 2, 1 } },
+ { { "gpus", 4, 1 } },
+ } },
+ { "threads:2;2,gpus:4", true, {
+ { { "threads", 2, 1 } },
+ { { "gpus", 4, 1 } },
+ { { "gpus", 4, 1 } },
+ } },
+ { "threads:2;gpus:4", true, {
+ { { "threads", 2, 1 } },
+ { { "gpus", 4, 1 } },
+ } },
+ { "1,threads:2;0,gpus:4", true, {
+ { { "threads", 2, 1 } },
+ } },
+ { "1,_:1", true, {
+ { { "_", 1, 1 } },
+ } },
+ { "1,a:1", true, {
+ { { "a", 1, 1 } },
+ } },
+ { "2", true, {
+ {},
+ {},
+ } },
+ { "1;2,threads:1", true, {
+ {},
+ { { "threads", 1, 1 } },
+ { { "threads", 1, 1 } },
+ } },
+ { "1,,threads:1", true, {
+ { { "threads", 1, 1 } },
+ } },
+ { ";1,threads:1", true, {
+ { { "threads", 1, 1 } },
+ } },
+ { "1,threads:1;", true, {
+ { { "threads", 1, 1 } },
+ } },
+ { "1,threads:1,", true, {
+ { { "threads", 1, 1 } },
+ } },
+ { "threads:1,threads:1", true, {
+ { { "threads", 1, 1 }, { "threads", 1, 1 } },
+ } },
+ { "threads:1;;threads:2", true, {
+ { { "threads", 1, 1 } },
+ { { "threads", 2, 1 } },
+ } },
+ { "1,", true, {
+ {},
+ } },
+ { ";", true, {} },
+ { "", true, {} },
+ { ",", false, {} },
+ { "1,0:1", false, {} },
+ { "1,A:1", false, {} },
+ { "1,a-b:1", false, {} },
+ { "invalid", false, {} },
+ { ",1,invalid:1", false, {} },
+ { "1,1", false, {} },
+ { "-1,invalid:1", false, {} },
+ { "1,invalid:*", false, {} },
+ { "1,invalid:-1", false, {} },
+ { "1,invalid:-", false, {} },
+ { "1,invalid:ab2", false, {} },
+ { "1,invalid :2", false, {} },
+ { "1, invalid:2", false, {} },
+ { "1,invalid:ab", false, {} },
+ /* clang-format on */
+};
+
+bool TestExpectedParseResult(const ExpectedParseResult& expected)
+{
+ std::vector<std::vector<cmCTestTestHandler::cmCTestTestResourceRequirement>>
+ result;
+ bool retval;
+ if ((retval = cmCTestTestHandler::ParseResourceGroupsProperty(
+ expected.String, result)) != expected.ExpectedReturnValue) {
+ std::cout << "ParseResourceGroupsProperty(\"" << expected.String
+ << "\") returned " << retval << ", should be "
+ << expected.ExpectedReturnValue << std::endl;
+ return false;
+ }
+
+ if (result != expected.ExpectedValue) {
+ std::cout << "ParseResourceGroupsProperty(\"" << expected.String
+ << "\") did not yield expected set of resource groups"
+ << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+int testCTestResourceGroups(int /*unused*/, char* /*unused*/ [])
+{
+ int retval = 0;
+
+ for (auto const& expected : expectedResults) {
+ if (!TestExpectedParseResult(expected)) {
+ retval = 1;
+ }
+ }
+
+ return retval;
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec.cxx b/Tests/CMakeLib/testCTestResourceSpec.cxx
new file mode 100644
index 000000000..b49f8ff2b
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec.cxx
@@ -0,0 +1,119 @@
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "cmCTestResourceSpec.h"
+
+struct ExpectedSpec
+{
+ std::string Path;
+ cmCTestResourceSpec::ReadFileResult ParseResult;
+ cmCTestResourceSpec Expected;
+};
+
+static const std::vector<ExpectedSpec> expectedResourceSpecs = {
+ { "spec1.json",
+ cmCTestResourceSpec::ReadFileResult::READ_OK,
+ { { {
+ { "gpus",
+ {
+ { "2", 4 },
+ { "e", 1 },
+ } },
+ { "threads", {} },
+ } } } },
+ { "spec2.json", cmCTestResourceSpec::ReadFileResult::READ_OK, {} },
+ { "spec3.json",
+ cmCTestResourceSpec::ReadFileResult::INVALID_SOCKET_SPEC,
+ {} },
+ { "spec4.json",
+ cmCTestResourceSpec::ReadFileResult::INVALID_SOCKET_SPEC,
+ {} },
+ { "spec5.json",
+ cmCTestResourceSpec::ReadFileResult::INVALID_SOCKET_SPEC,
+ {} },
+ { "spec6.json",
+ cmCTestResourceSpec::ReadFileResult::INVALID_SOCKET_SPEC,
+ {} },
+ { "spec7.json",
+ cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE_TYPE,
+ {} },
+ { "spec8.json", cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE, {} },
+ { "spec9.json", cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE, {} },
+ { "spec10.json", cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE, {} },
+ { "spec11.json", cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE, {} },
+ { "spec12.json", cmCTestResourceSpec::ReadFileResult::INVALID_ROOT, {} },
+ { "spec13.json", cmCTestResourceSpec::ReadFileResult::JSON_PARSE_ERROR, {} },
+ { "spec14.json", cmCTestResourceSpec::ReadFileResult::READ_OK, {} },
+ { "spec15.json", cmCTestResourceSpec::ReadFileResult::READ_OK, {} },
+ { "spec16.json", cmCTestResourceSpec::ReadFileResult::READ_OK, {} },
+ { "spec17.json", cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE, {} },
+ { "spec18.json", cmCTestResourceSpec::ReadFileResult::INVALID_RESOURCE, {} },
+ { "spec19.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec20.json", cmCTestResourceSpec::ReadFileResult::READ_OK, {} },
+ { "spec21.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec22.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec23.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec24.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec25.json",
+ cmCTestResourceSpec::ReadFileResult::UNSUPPORTED_VERSION,
+ {} },
+ { "spec26.json",
+ cmCTestResourceSpec::ReadFileResult::UNSUPPORTED_VERSION,
+ {} },
+ { "spec27.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec28.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec29.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec30.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec31.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec32.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec33.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec34.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec35.json", cmCTestResourceSpec::ReadFileResult::INVALID_VERSION, {} },
+ { "spec36.json", cmCTestResourceSpec::ReadFileResult::NO_VERSION, {} },
+ { "noexist.json", cmCTestResourceSpec::ReadFileResult::FILE_NOT_FOUND, {} },
+};
+
+static bool testSpec(const std::string& path,
+ cmCTestResourceSpec::ReadFileResult expectedResult,
+ const cmCTestResourceSpec& expected)
+{
+ cmCTestResourceSpec actual;
+ auto result = actual.ReadFromJSONFile(path);
+ if (result != expectedResult) {
+ std::cout << "ReadFromJSONFile(\"" << path << "\") returned \""
+ << cmCTestResourceSpec::ResultToString(result)
+ << "\", should be \""
+ << cmCTestResourceSpec::ResultToString(expectedResult) << "\""
+ << std::endl;
+ return false;
+ }
+
+ if (actual != expected) {
+ std::cout << "ReadFromJSONFile(\"" << path
+ << "\") did not give expected spec" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+int testCTestResourceSpec(int argc, char** const argv)
+{
+ if (argc < 2) {
+ std::cout << "Invalid arguments.\n";
+ return -1;
+ }
+
+ int retval = 0;
+ for (auto const& spec : expectedResourceSpecs) {
+ std::string path = argv[1];
+ path += "/testCTestResourceSpec_data/";
+ path += spec.Path;
+ if (!testSpec(path, spec.ParseResult, spec.Expected)) {
+ retval = -1;
+ }
+ }
+
+ return retval;
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec1.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec1.json
new file mode 100644
index 000000000..b01aa6ba5
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec1.json
@@ -0,0 +1,27 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ {
+ "id": "2",
+ "slots": 4
+ },
+ {
+ "id": "e"
+ }
+ ],
+ ".reserved": [
+ {
+ "id": "a",
+ "slots": 3
+ }
+ ],
+ "threads": [
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec10.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec10.json
new file mode 100644
index 000000000..8764907fd
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec10.json
@@ -0,0 +1,15 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ {
+ "id": 4
+ }
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec11.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec11.json
new file mode 100644
index 000000000..7551ea2da
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec11.json
@@ -0,0 +1,16 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ {
+ "id": "4",
+ "slots": "giraffe"
+ }
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec12.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec12.json
new file mode 100644
index 000000000..fe51488c7
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec12.json
@@ -0,0 +1 @@
+[]
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec13.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec13.json
new file mode 100644
index 000000000..6b7a9f4e0
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec13.json
@@ -0,0 +1 @@
+not json
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec14.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec14.json
new file mode 100644
index 000000000..83f480ca7
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec14.json
@@ -0,0 +1,12 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "0": [
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec15.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec15.json
new file mode 100644
index 000000000..10fe2e3ff
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec15.json
@@ -0,0 +1,12 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "-": [
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec16.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec16.json
new file mode 100644
index 000000000..8546759bf
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec16.json
@@ -0,0 +1,12 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "A": [
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec17.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec17.json
new file mode 100644
index 000000000..e4cdfc977
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec17.json
@@ -0,0 +1,15 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ {
+ "id": "A"
+ }
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec18.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec18.json
new file mode 100644
index 000000000..26a7c70cc
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec18.json
@@ -0,0 +1,15 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ {
+ "id": "-"
+ }
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec19.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec19.json
new file mode 100644
index 000000000..3067f0cfc
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec19.json
@@ -0,0 +1,5 @@
+{
+ "version": 1,
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec2.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec2.json
new file mode 100644
index 000000000..df4939098
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec2.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec20.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec20.json
new file mode 100644
index 000000000..df4939098
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec20.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec21.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec21.json
new file mode 100644
index 000000000..7459ff2a9
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec21.json
@@ -0,0 +1,5 @@
+{
+ "version": [1, 0],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec22.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec22.json
new file mode 100644
index 000000000..23c57d809
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec22.json
@@ -0,0 +1,5 @@
+{
+ "version": 2,
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec23.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec23.json
new file mode 100644
index 000000000..a3d0a2748
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec23.json
@@ -0,0 +1,7 @@
+{
+ "version": {
+ "major": 1
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec24.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec24.json
new file mode 100644
index 000000000..d5f6b0821
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec24.json
@@ -0,0 +1,7 @@
+{
+ "version": {
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec25.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec25.json
new file mode 100644
index 000000000..914da4bbf
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec25.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 1
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec26.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec26.json
new file mode 100644
index 000000000..c06de22d1
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec26.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 2,
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec27.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec27.json
new file mode 100644
index 000000000..9e2b6c325
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec27.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": "1",
+ "minor": 0
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec28.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec28.json
new file mode 100644
index 000000000..ce3b76a7e
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec28.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 1,
+ "minor": "0"
+ },
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec29.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec29.json
new file mode 100644
index 000000000..58afd2b12
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec29.json
@@ -0,0 +1,5 @@
+{
+ "version": [1, 0, 0],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec3.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec3.json
new file mode 100644
index 000000000..2f1045f6c
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec3.json
@@ -0,0 +1,12 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ },
+ {
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec30.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec30.json
new file mode 100644
index 000000000..9e13ff0d5
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec30.json
@@ -0,0 +1,5 @@
+{
+ "version": [1],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec31.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec31.json
new file mode 100644
index 000000000..c0ef7f4f2
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec31.json
@@ -0,0 +1,5 @@
+{
+ "version": [1, 1],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec32.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec32.json
new file mode 100644
index 000000000..abe977eba
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec32.json
@@ -0,0 +1,5 @@
+{
+ "version": [2, 0],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec33.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec33.json
new file mode 100644
index 000000000..c6ca749a7
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec33.json
@@ -0,0 +1,5 @@
+{
+ "version": ["1", 0],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec34.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec34.json
new file mode 100644
index 000000000..be258f121
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec34.json
@@ -0,0 +1,5 @@
+{
+ "version": [1, "0"],
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec35.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec35.json
new file mode 100644
index 000000000..137648c13
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec35.json
@@ -0,0 +1,5 @@
+{
+ "version": "1",
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec36.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec36.json
new file mode 100644
index 000000000..6175b1a99
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec36.json
@@ -0,0 +1,4 @@
+{
+ "local": [
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec4.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec4.json
new file mode 100644
index 000000000..17349bda8
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec4.json
@@ -0,0 +1,8 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": {
+ }
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec5.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec5.json
new file mode 100644
index 000000000..f6e6cb4e7
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec5.json
@@ -0,0 +1,6 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ }
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec6.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec6.json
new file mode 100644
index 000000000..eb8b14c47
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec6.json
@@ -0,0 +1,9 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ []
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec7.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec7.json
new file mode 100644
index 000000000..0447981a3
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec7.json
@@ -0,0 +1,12 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": {
+ }
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec8.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec8.json
new file mode 100644
index 000000000..ee7a9c2cd
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec8.json
@@ -0,0 +1,13 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ []
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testCTestResourceSpec_data/spec9.json b/Tests/CMakeLib/testCTestResourceSpec_data/spec9.json
new file mode 100644
index 000000000..ae1117bc7
--- /dev/null
+++ b/Tests/CMakeLib/testCTestResourceSpec_data/spec9.json
@@ -0,0 +1,14 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "gpus": [
+ {
+ }
+ ]
+ }
+ ]
+}
diff --git a/Tests/CMakeLib/testEncoding.cxx b/Tests/CMakeLib/testEncoding.cxx
index 5e40638f7..4936898ed 100644
--- a/Tests/CMakeLib/testEncoding.cxx
+++ b/Tests/CMakeLib/testEncoding.cxx
@@ -1,9 +1,10 @@
-#include "cmsys/FStream.hxx"
#include <iostream>
#include <string>
+#include "cmsys/FStream.hxx"
+
#ifdef _WIN32
-#include "cmsys/ConsoleBuf.hxx"
+# include "cmsys/ConsoleBuf.hxx"
#endif
#ifdef _WIN32
@@ -31,7 +32,7 @@ int main(int argc, char* argv[])
}
const std::string encoding(argv[1]);
#ifdef _WIN32
- if (encoding == "UTF8") {
+ if ((encoding == "UTF8") || (encoding == "UTF-8")) {
setEncoding(consoleOut, CP_UTF8);
} else if (encoding == "ANSI") {
setEncoding(consoleOut, CP_ACP);
diff --git a/Tests/CMakeLib/testGeneratedFileStream.cxx b/Tests/CMakeLib/testGeneratedFileStream.cxx
index 1d2ec3266..de44a0b71 100644
--- a/Tests/CMakeLib/testGeneratedFileStream.cxx
+++ b/Tests/CMakeLib/testGeneratedFileStream.cxx
@@ -1,11 +1,11 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmGeneratedFileStream.h"
-#include "cmSystemTools.h"
-
#include <iostream>
#include <string>
+#include "cmGeneratedFileStream.h"
+#include "cmSystemTools.h"
+
#define cmFailed(m1, m2) \
std::cout << "FAILED: " << (m1) << (m2) << "\n"; \
failed = 1
diff --git a/Tests/CMakeLib/testOptional.cxx b/Tests/CMakeLib/testOptional.cxx
new file mode 100644
index 000000000..c6bc9c231
--- /dev/null
+++ b/Tests/CMakeLib/testOptional.cxx
@@ -0,0 +1,701 @@
+#include <iostream>
+#include <type_traits>
+#include <vector>
+
+#include <cm/optional>
+#include <cm/utility>
+
+class EventLogger;
+
+class Event
+{
+public:
+ enum EventType
+ {
+ DEFAULT_CONSTRUCT,
+ COPY_CONSTRUCT,
+ MOVE_CONSTRUCT,
+ VALUE_CONSTRUCT,
+
+ DESTRUCT,
+
+ COPY_ASSIGN,
+ MOVE_ASSIGN,
+ VALUE_ASSIGN,
+
+ REFERENCE,
+ CONST_REFERENCE,
+ RVALUE_REFERENCE,
+ CONST_RVALUE_REFERENCE,
+
+ SWAP,
+ };
+
+ EventType Type;
+ const EventLogger* Logger1;
+ const EventLogger* Logger2;
+ int Value;
+
+ bool operator==(const Event& other) const;
+ bool operator!=(const Event& other) const;
+};
+
+bool Event::operator==(const Event& other) const
+{
+ return this->Type == other.Type && this->Logger1 == other.Logger1 &&
+ this->Logger2 == other.Logger2 && this->Value == other.Value;
+}
+
+bool Event::operator!=(const Event& other) const
+{
+ return !(*this == other);
+}
+
+static std::vector<Event> events;
+
+class EventLogger
+{
+public:
+ EventLogger();
+ EventLogger(const EventLogger& other);
+ EventLogger(EventLogger&& other);
+ EventLogger(int value);
+
+ ~EventLogger();
+
+ EventLogger& operator=(const EventLogger& other);
+ EventLogger& operator=(EventLogger&& other);
+ EventLogger& operator=(int value);
+
+ void Reference() &;
+ void Reference() const&;
+ void Reference() &&;
+ void Reference() const&&;
+
+ int Value = 0;
+};
+
+// Certain builds of GCC generate false -Wmaybe-uninitialized warnings when
+// doing a release build with the system version of std::optional. These
+// warnings do not manifest when using our own cm::optional implementation.
+// Silence these false warnings.
+#if defined(__GNUC__) && !defined(__clang__)
+# define BEGIN_IGNORE_UNINITIALIZED \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# define END_IGNORE_UNINITIALIZED _Pragma("GCC diagnostic pop")
+#else
+# define BEGIN_IGNORE_UNINITIALIZED
+# define END_IGNORE_UNINITIALIZED
+#endif
+
+void swap(EventLogger& e1, EventLogger& e2)
+{
+ BEGIN_IGNORE_UNINITIALIZED
+ events.push_back({ Event::SWAP, &e1, &e2, e2.Value });
+ END_IGNORE_UNINITIALIZED
+ auto tmp = e1.Value;
+ e1.Value = e2.Value;
+ e2.Value = tmp;
+}
+
+EventLogger::EventLogger()
+ : Value(0)
+{
+ events.push_back({ Event::DEFAULT_CONSTRUCT, this, nullptr, 0 });
+}
+
+EventLogger::EventLogger(const EventLogger& other)
+ : Value(other.Value)
+{
+ events.push_back({ Event::COPY_CONSTRUCT, this, &other, other.Value });
+}
+
+BEGIN_IGNORE_UNINITIALIZED
+EventLogger::EventLogger(EventLogger&& other)
+ : Value(other.Value)
+{
+ events.push_back({ Event::MOVE_CONSTRUCT, this, &other, other.Value });
+}
+END_IGNORE_UNINITIALIZED
+
+EventLogger::EventLogger(int value)
+ : Value(value)
+{
+ events.push_back({ Event::VALUE_CONSTRUCT, this, nullptr, value });
+}
+
+EventLogger::~EventLogger()
+{
+ BEGIN_IGNORE_UNINITIALIZED
+ events.push_back({ Event::DESTRUCT, this, nullptr, this->Value });
+ END_IGNORE_UNINITIALIZED
+}
+
+EventLogger& EventLogger::operator=(const EventLogger& other)
+{
+ events.push_back({ Event::COPY_ASSIGN, this, &other, other.Value });
+ this->Value = other.Value;
+ return *this;
+}
+
+EventLogger& EventLogger::operator=(EventLogger&& other)
+{
+ events.push_back({ Event::MOVE_ASSIGN, this, &other, other.Value });
+ this->Value = other.Value;
+ return *this;
+}
+
+EventLogger& EventLogger::operator=(int value)
+{
+ events.push_back({ Event::VALUE_ASSIGN, this, nullptr, value });
+ this->Value = value;
+ return *this;
+}
+
+void EventLogger::Reference() &
+{
+ events.push_back({ Event::REFERENCE, this, nullptr, this->Value });
+}
+
+void EventLogger::Reference() const&
+{
+ events.push_back({ Event::CONST_REFERENCE, this, nullptr, this->Value });
+}
+
+void EventLogger::Reference() &&
+{
+ events.push_back({ Event::RVALUE_REFERENCE, this, nullptr, this->Value });
+}
+
+void EventLogger::Reference() const&&
+{
+ events.push_back(
+ { Event::CONST_RVALUE_REFERENCE, this, nullptr, this->Value });
+}
+
+static bool testDefaultConstruct(std::vector<Event>& expected)
+{
+ const cm::optional<EventLogger> o{};
+
+ expected = {};
+ return true;
+}
+
+static bool testNulloptConstruct(std::vector<Event>& expected)
+{
+ const cm::optional<EventLogger> o{ cm::nullopt };
+
+ expected = {};
+ return true;
+}
+
+static bool testValueConstruct(std::vector<Event>& expected)
+{
+ const cm::optional<EventLogger> o{ 4 };
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o, nullptr, 4 },
+ { Event::DESTRUCT, &*o, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testInPlaceConstruct(std::vector<Event>& expected)
+{
+ const cm::optional<EventLogger> o1{ cm::in_place, 4 };
+ const cm::optional<EventLogger> o2{ cm::in_place_t{}, 4 };
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
+ { Event::VALUE_CONSTRUCT, &*o2, nullptr, 4 },
+ { Event::DESTRUCT, &*o2, nullptr, 4 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testCopyConstruct(std::vector<Event>& expected)
+{
+ const cm::optional<EventLogger> o1{ 4 };
+ const cm::optional<EventLogger> o2{ o1 };
+ const cm::optional<EventLogger> o3{};
+ const cm::optional<EventLogger> o4{ o3 };
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
+ { Event::COPY_CONSTRUCT, &*o2, &o1.value(), 4 },
+ { Event::DESTRUCT, &*o2, nullptr, 4 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testMoveConstruct(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o1{ 4 };
+ const cm::optional<EventLogger> o2{ std::move(o1) };
+ cm::optional<EventLogger> o3{};
+ const cm::optional<EventLogger> o4{ std::move(o3) };
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
+ { Event::MOVE_CONSTRUCT, &*o2, &*o1, 4 },
+ { Event::DESTRUCT, &*o2, nullptr, 4 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testNulloptAssign(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o1{ 4 };
+ auto const* v1 = &*o1;
+ o1 = cm::nullopt;
+ cm::optional<EventLogger> o2{};
+ o2 = cm::nullopt;
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, v1, nullptr, 4 },
+ { Event::DESTRUCT, v1, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testCopyAssign(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o1{};
+ const cm::optional<EventLogger> o2{ 4 };
+ auto const* v2 = &*o2;
+ o1 = o2;
+ auto const* v1 = &*o1;
+ const cm::optional<EventLogger> o3{ 5 };
+ auto const* v3 = &*o3;
+ o1 = o3;
+ const cm::optional<EventLogger> o4{};
+ o1 = o4;
+ o1 = o4; // Intentionally duplicated to test assigning an empty optional to
+ // an empty optional
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, v2, nullptr, 4 },
+ { Event::COPY_CONSTRUCT, v1, v2, 4 },
+ { Event::VALUE_CONSTRUCT, v3, nullptr, 5 },
+ { Event::COPY_ASSIGN, v1, v3, 5 },
+ { Event::DESTRUCT, v1, nullptr, 5 },
+ { Event::DESTRUCT, v3, nullptr, 5 },
+ { Event::DESTRUCT, v2, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testMoveAssign(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o1{};
+ cm::optional<EventLogger> o2{ 4 };
+ auto const* v2 = &*o2;
+ o1 = std::move(o2);
+ auto const* v1 = &*o1;
+ cm::optional<EventLogger> o3{ 5 };
+ auto const* v3 = &*o3;
+ o1 = std::move(o3);
+ cm::optional<EventLogger> o4{};
+ o1 = std::move(o4);
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, v2, nullptr, 4 },
+ { Event::MOVE_CONSTRUCT, v1, v2, 4 },
+ { Event::VALUE_CONSTRUCT, v3, nullptr, 5 },
+ { Event::MOVE_ASSIGN, v1, v3, 5 },
+ { Event::DESTRUCT, v1, nullptr, 5 },
+ { Event::DESTRUCT, v3, nullptr, 5 },
+ { Event::DESTRUCT, v2, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testPointer(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o1{ 4 };
+ const cm::optional<EventLogger> o2{ 5 };
+
+ o1->Reference();
+ o2->Reference();
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
+ { Event::VALUE_CONSTRUCT, &*o2, nullptr, 5 },
+ { Event::REFERENCE, &*o1, nullptr, 4 },
+ { Event::CONST_REFERENCE, &*o2, nullptr, 5 },
+ { Event::DESTRUCT, &*o2, nullptr, 5 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ };
+ return true;
+}
+
+#if !__GNUC__ || __GNUC__ > 4
+# define ALLOW_CONST_RVALUE
+#endif
+
+static bool testDereference(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o1{ 4 };
+ auto const* v1 = &*o1;
+ const cm::optional<EventLogger> o2{ 5 };
+ auto const* v2 = &*o2;
+
+ (*o1).Reference();
+ (*o2).Reference();
+ (*std::move(o1)).Reference();
+#ifdef ALLOW_CONST_RVALUE
+ (*std::move(o2)).Reference(); // Broken in GCC 4.9.0. Sigh...
+#endif
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, v1, nullptr, 4 },
+ { Event::VALUE_CONSTRUCT, v2, nullptr, 5 },
+ { Event::REFERENCE, v1, nullptr, 4 },
+ { Event::CONST_REFERENCE, v2, nullptr, 5 },
+ { Event::RVALUE_REFERENCE, v1, nullptr, 4 },
+#ifdef ALLOW_CONST_RVALUE
+ { Event::CONST_RVALUE_REFERENCE, v2, nullptr, 5 },
+#endif
+ { Event::DESTRUCT, v2, nullptr, 5 },
+ { Event::DESTRUCT, v1, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testHasValue(std::vector<Event>& expected)
+{
+ bool retval = true;
+
+ const cm::optional<EventLogger> o1{ 4 };
+ const cm::optional<EventLogger> o2{};
+
+ if (!o1.has_value()) {
+ std::cout << "o1 should have a value" << std::endl;
+ retval = false;
+ }
+
+ if (!o1) {
+ std::cout << "(bool)o1 should be true" << std::endl;
+ retval = false;
+ }
+
+ if (o2.has_value()) {
+ std::cout << "o2 should not have a value" << std::endl;
+ retval = false;
+ }
+
+ if (o2) {
+ std::cout << "(bool)o2 should be false" << std::endl;
+ retval = false;
+ }
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ };
+ return retval;
+}
+
+static bool testValue(std::vector<Event>& expected)
+{
+ bool retval = true;
+
+ cm::optional<EventLogger> o1{ 4 };
+ const cm::optional<EventLogger> o2{ 5 };
+ cm::optional<EventLogger> o3{};
+ const cm::optional<EventLogger> o4{};
+
+ o1.value().Reference();
+ o2.value().Reference();
+
+ bool thrown = false;
+ try {
+ (void)o3.value();
+ } catch (cm::bad_optional_access&) {
+ thrown = true;
+ }
+ if (!thrown) {
+ std::cout << "o3.value() did not throw" << std::endl;
+ retval = false;
+ }
+
+ thrown = false;
+ try {
+ (void)o4.value();
+ } catch (cm::bad_optional_access&) {
+ thrown = true;
+ }
+ if (!thrown) {
+ std::cout << "o4.value() did not throw" << std::endl;
+ retval = false;
+ }
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
+ { Event::VALUE_CONSTRUCT, &*o2, nullptr, 5 },
+ { Event::REFERENCE, &*o1, nullptr, 4 },
+ { Event::CONST_REFERENCE, &*o2, nullptr, 5 },
+ { Event::DESTRUCT, &*o2, nullptr, 5 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ };
+ return retval;
+}
+
+static bool testValueOr()
+{
+ bool retval = true;
+
+ const cm::optional<EventLogger> o1{ 4 };
+ cm::optional<EventLogger> o2{ 5 };
+ const cm::optional<EventLogger> o3{};
+ cm::optional<EventLogger> o4{};
+
+ EventLogger e1{ 6 };
+ EventLogger e2{ 7 };
+ EventLogger e3{ 8 };
+ EventLogger e4{ 9 };
+
+ EventLogger r1 = o1.value_or(e1);
+ if (r1.Value != 4) {
+ std::cout << "r1.Value should be 4" << std::endl;
+ retval = false;
+ }
+ EventLogger r2 = std::move(o2).value_or(e2);
+ if (r2.Value != 5) {
+ std::cout << "r2.Value should be 5" << std::endl;
+ retval = false;
+ }
+ EventLogger r3 = o3.value_or(e3);
+ if (r3.Value != 8) {
+ std::cout << "r3.Value should be 8" << std::endl;
+ retval = false;
+ }
+ EventLogger r4 = std::move(o4).value_or(e4);
+ if (r4.Value != 9) {
+ std::cout << "r4.Value should be 9" << std::endl;
+ retval = false;
+ }
+
+ return retval;
+}
+
+static bool testSwap(std::vector<Event>& expected)
+{
+ bool retval = true;
+
+ cm::optional<EventLogger> o1{ 4 };
+ auto const* v1 = &*o1;
+ cm::optional<EventLogger> o2{};
+
+ o1.swap(o2);
+ auto const* v2 = &*o2;
+
+ if (o1.has_value()) {
+ std::cout << "o1 should not have value" << std::endl;
+ retval = false;
+ }
+ if (!o2.has_value()) {
+ std::cout << "o2 should have value" << std::endl;
+ retval = false;
+ }
+ if (o2.value().Value != 4) {
+ std::cout << "value of o2 should be 4" << std::endl;
+ retval = false;
+ }
+
+ o1.swap(o2);
+
+ if (!o1.has_value()) {
+ std::cout << "o1 should have value" << std::endl;
+ retval = false;
+ }
+ if (o1.value().Value != 4) {
+ std::cout << "value of o1 should be 4" << std::endl;
+ retval = false;
+ }
+ if (o2.has_value()) {
+ std::cout << "o2 should not have value" << std::endl;
+ retval = false;
+ }
+
+ o2.emplace(5);
+ o1.swap(o2);
+
+ if (!o1.has_value()) {
+ std::cout << "o1 should have value" << std::endl;
+ retval = false;
+ }
+ if (o1.value().Value != 5) {
+ std::cout << "value of o1 should be 5" << std::endl;
+ retval = false;
+ }
+ if (!o2.has_value()) {
+ std::cout << "o2 should not have value" << std::endl;
+ retval = false;
+ }
+ if (o2.value().Value != 4) {
+ std::cout << "value of o2 should be 4" << std::endl;
+ retval = false;
+ }
+
+ o1.reset();
+ o2.reset();
+ o1.swap(o2);
+
+ if (o1.has_value()) {
+ std::cout << "o1 should not have value" << std::endl;
+ retval = false;
+ }
+ if (o2.has_value()) {
+ std::cout << "o2 should not have value" << std::endl;
+ retval = false;
+ }
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, v1, nullptr, 4 },
+ { Event::MOVE_CONSTRUCT, v2, v1, 4 },
+ { Event::DESTRUCT, v1, nullptr, 4 },
+ { Event::MOVE_CONSTRUCT, v1, v2, 4 },
+ { Event::DESTRUCT, v2, nullptr, 4 },
+ { Event::VALUE_CONSTRUCT, v2, nullptr, 5 },
+ { Event::SWAP, v1, v2, 5 },
+ { Event::DESTRUCT, v1, nullptr, 5 },
+ { Event::DESTRUCT, v2, nullptr, 4 },
+ };
+ return retval;
+}
+
+static bool testReset(std::vector<Event>& expected)
+{
+ bool retval = true;
+
+ cm::optional<EventLogger> o{ 4 };
+ auto const* v = &*o;
+
+ o.reset();
+
+ if (o.has_value()) {
+ std::cout << "o should not have value" << std::endl;
+ retval = false;
+ }
+
+ o.reset();
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, v, nullptr, 4 },
+ { Event::DESTRUCT, v, nullptr, 4 },
+ };
+ return retval;
+}
+
+static bool testEmplace(std::vector<Event>& expected)
+{
+ cm::optional<EventLogger> o{ 4 };
+
+ o.emplace(5);
+ o.reset();
+ o.emplace();
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o, nullptr, 4 },
+ { Event::DESTRUCT, &*o, nullptr, 4 },
+ { Event::VALUE_CONSTRUCT, &*o, nullptr, 5 },
+ { Event::DESTRUCT, &*o, nullptr, 5 },
+ { Event::DEFAULT_CONSTRUCT, &*o, nullptr, 0 },
+ { Event::DESTRUCT, &*o, nullptr, 0 },
+ };
+ return true;
+}
+
+static bool testMakeOptional(std::vector<Event>& expected)
+{
+ EventLogger e{ 4 };
+ cm::optional<EventLogger> o1 = cm::make_optional<EventLogger>(e);
+ cm::optional<EventLogger> o2 = cm::make_optional<EventLogger>(5);
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &e, nullptr, 4 },
+ { Event::COPY_CONSTRUCT, &*o1, &e, 4 },
+ { Event::VALUE_CONSTRUCT, &*o2, nullptr, 5 },
+ { Event::DESTRUCT, &*o2, nullptr, 5 },
+ { Event::DESTRUCT, &*o1, nullptr, 4 },
+ { Event::DESTRUCT, &e, nullptr, 4 },
+ };
+ return true;
+}
+
+static bool testMemoryRange(std::vector<Event>& expected)
+{
+ bool retval = true;
+
+ cm::optional<EventLogger> o{ 4 };
+
+ auto* ostart = &o;
+ auto* oend = ostart + 1;
+ auto* estart = &o.value();
+ auto* eend = estart + 1;
+
+ if (static_cast<void*>(estart) < static_cast<void*>(ostart) ||
+ static_cast<void*>(eend) > static_cast<void*>(oend)) {
+ std::cout << "value is not within memory range of optional" << std::endl;
+ retval = false;
+ }
+
+ expected = {
+ { Event::VALUE_CONSTRUCT, &*o, nullptr, 4 },
+ { Event::DESTRUCT, &*o, nullptr, 4 },
+ };
+ return retval;
+}
+
+int testOptional(int /*unused*/, char* /*unused*/ [])
+{
+ int retval = 0;
+
+#define DO_EVENT_TEST(name) \
+ do { \
+ events.clear(); \
+ std::vector<Event> expected; \
+ if (!name(expected)) { \
+ std::cout << "in " #name << std::endl; \
+ retval = 1; \
+ } else if (expected != events) { \
+ std::cout << #name " did not produce expected events" << std::endl; \
+ retval = 1; \
+ } \
+ } while (0)
+
+#define DO_TEST(name) \
+ do { \
+ if (!name()) { \
+ std::cout << "in " #name << std::endl; \
+ retval = 1; \
+ } \
+ } while (0)
+
+ DO_EVENT_TEST(testDefaultConstruct);
+ DO_EVENT_TEST(testNulloptConstruct);
+ DO_EVENT_TEST(testValueConstruct);
+ DO_EVENT_TEST(testInPlaceConstruct);
+ DO_EVENT_TEST(testCopyConstruct);
+ DO_EVENT_TEST(testMoveConstruct);
+ DO_EVENT_TEST(testNulloptAssign);
+ DO_EVENT_TEST(testCopyAssign);
+ DO_EVENT_TEST(testMoveAssign);
+ DO_EVENT_TEST(testPointer);
+ DO_EVENT_TEST(testDereference);
+ DO_EVENT_TEST(testHasValue);
+ DO_EVENT_TEST(testValue);
+ DO_TEST(testValueOr);
+ DO_EVENT_TEST(testSwap);
+ DO_EVENT_TEST(testReset);
+ DO_EVENT_TEST(testEmplace);
+ DO_EVENT_TEST(testMakeOptional);
+ DO_EVENT_TEST(testMemoryRange);
+
+ return retval;
+}
diff --git a/Tests/CMakeLib/testRST.cxx b/Tests/CMakeLib/testRST.cxx
index 889127650..28d80a5f6 100644
--- a/Tests/CMakeLib/testRST.cxx
+++ b/Tests/CMakeLib/testRST.cxx
@@ -1,12 +1,13 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmRST.h"
-#include "cmSystemTools.h"
-
-#include "cmsys/FStream.hxx"
#include <iostream>
#include <string>
+#include "cmsys/FStream.hxx"
+
+#include "cmRST.h"
+#include "cmSystemTools.h"
+
void reportLine(std::ostream& os, bool ret, std::string const& line, bool eol)
{
if (ret) {
diff --git a/Tests/CMakeLib/testRST.expect b/Tests/CMakeLib/testRST.expect
index fa436cb91..c19ee9400 100644
--- a/Tests/CMakeLib/testRST.expect
+++ b/Tests/CMakeLib/testRST.expect
@@ -16,7 +16,14 @@ Variable ``<PLACEHOLDER>_VARIABLE`` with leading placeholder.
Variable ``VARIABLE_<PLACEHOLDER>`` with trailing placeholder.
Variable ``<PLACEHOLDER>_VARIABLE`` with leading placeholder and target.
Variable ``VARIABLE_<PLACEHOLDER>`` with trailing placeholder and target.
+Environment variable ``SOME_ENV_VAR``.
+Environment variable ``some env var`` with space and target.
Generator ``Some Generator`` with space.
+Generator ``Some Generator`` with space.
+Inline literal ``~!@#$%^&*( )_+-=\\[]{}'":;,<>.?/``.
+Inline link Link Text.
+Inline link Link Text <With \-escaped Brackets>.
+Inline literal ``__`` followed by inline link Link Text.
First TOC entry.
@@ -76,6 +83,10 @@ or after a paragraph ending in two colons::
but not after a line ending in two colons::
in the middle of a paragraph.
+A literal block can be empty::
+
+
+
.. productionlist::
grammar: `production`
production: "content rendered"
diff --git a/Tests/CMakeLib/testRST.rst b/Tests/CMakeLib/testRST.rst
index 54952dd9f..d2d1140f3 100644
--- a/Tests/CMakeLib/testRST.rst
+++ b/Tests/CMakeLib/testRST.rst
@@ -23,7 +23,14 @@ Variable :variable:`<PLACEHOLDER>_VARIABLE` with leading placeholder.
Variable :variable:`VARIABLE_<PLACEHOLDER>` with trailing placeholder.
Variable :variable:`<PLACEHOLDER>_VARIABLE <target>` with leading placeholder and target.
Variable :variable:`VARIABLE_<PLACEHOLDER> <target>` with trailing placeholder and target.
+Environment variable :envvar:`SOME_ENV_VAR`.
+Environment variable :envvar:`some env var <SOME_ENV_VAR>` with space and target.
Generator :generator:`Some Generator` with space.
+Generator :cpack_gen:`Some Generator` with space.
+Inline literal ``~!@#$%^&*( )_+-=\\[]{}'":;,<>.?/``.
+Inline link `Link Text <ExternalDest>`_.
+Inline link `Link Text \<With \\-escaped Brackets\> <ExternalDest>`_.
+Inline literal ``__`` followed by inline link `Link Text <InternalDest_>`_.
.. |not replaced| replace:: not replaced through toctree
.. |not replaced in literal| replace:: replaced in parsed literal
@@ -83,6 +90,10 @@ or after a paragraph ending in two colons::
but not after a line ending in two colons::
in the middle of a paragraph.
+A literal block can be empty::
+
+
+
.. productionlist::
grammar: `production`
production: "content rendered"
diff --git a/Tests/CMakeLib/testRange.cxx b/Tests/CMakeLib/testRange.cxx
new file mode 100644
index 000000000..4efe98e26
--- /dev/null
+++ b/Tests/CMakeLib/testRange.cxx
@@ -0,0 +1,45 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "cmRange.h"
+
+#define ASSERT_TRUE(x) \
+ do { \
+ if (!(x)) { \
+ std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \
+ return -1; \
+ } \
+ } while (false)
+
+int testRange(int /*unused*/, char* /*unused*/ [])
+{
+ std::vector<int> const testData = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
+
+ ASSERT_TRUE(!cmMakeRange(testData).empty());
+ ASSERT_TRUE(cmMakeRange(testData).size() == 10);
+
+ ASSERT_TRUE(!cmMakeRange(testData).advance(5).empty());
+ ASSERT_TRUE(cmMakeRange(testData).advance(5).size() == 5);
+
+ ASSERT_TRUE(cmMakeRange(testData).advance(5).retreat(5).empty());
+ ASSERT_TRUE(cmMakeRange(testData).advance(5).retreat(5).size() == 0);
+
+ ASSERT_TRUE(cmMakeRange(testData).any_of([](int n) { return n % 3 == 0; }));
+ ASSERT_TRUE(cmMakeRange(testData).all_of([](int n) { return n < 11; }));
+ ASSERT_TRUE(cmMakeRange(testData).none_of([](int n) { return n > 11; }));
+
+ std::vector<int> const evenData = { 2, 4, 6, 8, 10 };
+ ASSERT_TRUE(cmMakeRange(testData).filter([](int n) { return n % 2 == 0; }) ==
+ cmMakeRange(evenData));
+
+ std::vector<std::string> const stringRange = { "1", "2", "3", "4", "5" };
+ ASSERT_TRUE(cmMakeRange(testData)
+ .transform([](int n) { return std::to_string(n); })
+ .retreat(5) == cmMakeRange(stringRange));
+
+ return 0;
+}
diff --git a/Tests/CMakeLib/testString.cxx b/Tests/CMakeLib/testString.cxx
new file mode 100644
index 000000000..d7b320039
--- /dev/null
+++ b/Tests/CMakeLib/testString.cxx
@@ -0,0 +1,1349 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include <cstddef>
+#include <cstring>
+#include <iostream>
+#include <iterator>
+#include <sstream>
+#include <stdexcept>
+#include <string>
+#include <type_traits>
+#include <utility>
+
+#include <cm/string_view>
+
+#include "cm_static_string_view.hxx"
+
+#include "cmString.hxx"
+
+#define ASSERT_TRUE(x) \
+ do { \
+ if (!(x)) { \
+ std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \
+ return false; \
+ } \
+ } while (false)
+
+static bool testConstructDefault()
+{
+ std::cout << "testConstructDefault()\n";
+ cm::String str;
+ cm::String const& str_const = str;
+ ASSERT_TRUE(bool(str_const) == false);
+ ASSERT_TRUE(str_const.data() == nullptr);
+ ASSERT_TRUE(str_const.size() == 0);
+ ASSERT_TRUE(str_const.empty());
+ ASSERT_TRUE(str_const.is_stable());
+ ASSERT_TRUE(str.c_str() == nullptr);
+ ASSERT_TRUE(str.str().empty());
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testFromNullPtr(cm::String str)
+{
+ cm::String const& str_const = str;
+ ASSERT_TRUE(bool(str_const) == false);
+ ASSERT_TRUE(str_const.data() == nullptr);
+ ASSERT_TRUE(str_const.size() == 0);
+ ASSERT_TRUE(str_const.empty());
+ ASSERT_TRUE(str_const.is_stable());
+ ASSERT_TRUE(str.c_str() == nullptr);
+ ASSERT_TRUE(str.str().empty());
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromNullPtr()
+{
+ std::cout << "testConstructFromNullPtr()\n";
+ return testFromNullPtr(nullptr);
+}
+
+static bool testAssignFromNullPtr()
+{
+ std::cout << "testAssignFromNullPtr()\n";
+ cm::String str;
+ str = nullptr;
+ return testFromNullPtr(str);
+}
+
+static bool testFromCStrNull(cm::String str)
+{
+ cm::String const& str_const = str;
+ ASSERT_TRUE(bool(str_const) == false);
+ ASSERT_TRUE(str_const.data() == nullptr);
+ ASSERT_TRUE(str_const.size() == 0);
+ ASSERT_TRUE(str_const.empty());
+ ASSERT_TRUE(str_const.is_stable());
+ ASSERT_TRUE(str.c_str() == nullptr);
+ ASSERT_TRUE(str.str().empty());
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromCStrNull()
+{
+ std::cout << "testConstructFromCStrNull()\n";
+ const char* null = nullptr;
+ return testFromCStrNull(null);
+}
+
+static bool testAssignFromCStrNull()
+{
+ std::cout << "testAssignFromCStrNull()\n";
+ const char* null = nullptr;
+ cm::String str;
+ str = null;
+ return testFromCStrNull(str);
+}
+
+static char const charArray[] = "abc";
+
+static bool testFromCharArray(cm::String str)
+{
+ cm::String const& str_const = str;
+ ASSERT_TRUE(str_const.data() != charArray);
+ ASSERT_TRUE(str_const.size() == sizeof(charArray) - 1);
+ ASSERT_TRUE(str_const.is_stable());
+ ASSERT_TRUE(str.c_str() != charArray);
+ ASSERT_TRUE(str.is_stable());
+ cm::String substr = str.substr(1);
+ cm::String const& substr_const = substr;
+ ASSERT_TRUE(substr_const.data() != &charArray[1]);
+ ASSERT_TRUE(substr_const.size() == 2);
+ ASSERT_TRUE(!substr_const.is_stable());
+ ASSERT_TRUE(substr.c_str() != &charArray[1]);
+ ASSERT_TRUE(!substr.is_stable());
+ return true;
+}
+
+static bool testConstructFromCharArray()
+{
+ std::cout << "testConstructFromCharArray()\n";
+ return testFromCharArray(charArray);
+}
+
+static bool testAssignFromCharArray()
+{
+ std::cout << "testAssignFromCharArray()\n";
+ cm::String str;
+ str = charArray;
+ return testFromCharArray(str);
+}
+
+static const char* cstr = "abc";
+
+static bool testFromCStr(cm::String const& str)
+{
+ ASSERT_TRUE(str.data() != cstr);
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), cstr, 3) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromCStr()
+{
+ std::cout << "testConstructFromCStr()\n";
+ return testFromCStr(cstr);
+}
+
+static bool testAssignFromCStr()
+{
+ std::cout << "testAssignFromCStr()\n";
+ cm::String str;
+ str = cstr;
+ return testFromCStr(str);
+}
+
+static const std::string stdstr = "abc";
+
+static bool testFromStdString(cm::String const& str)
+{
+#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI
+ // It would be nice to check this everywhere, but several platforms
+ // still use a CoW implementation even in C++11.
+ ASSERT_TRUE(str.data() != stdstr.data());
+#endif
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), stdstr.data(), 3) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromStdString()
+{
+ std::cout << "testConstructFromStdString()\n";
+ return testFromStdString(stdstr);
+}
+
+static bool testAssignFromStdString()
+{
+ std::cout << "testAssignFromStdString()\n";
+ cm::String str;
+ str = stdstr;
+ return testFromStdString(str);
+}
+
+static bool testConstructFromView()
+{
+ std::cout << "testConstructFromView()\n";
+ cm::string_view view = cstr;
+ return testFromCStr(view);
+}
+
+static bool testAssignFromView()
+{
+ std::cout << "testAssignFromView()\n";
+ cm::string_view view = cstr;
+ cm::String str;
+ str = view;
+ return testFromCStr(str);
+}
+
+static bool testFromChar(cm::String const& str)
+{
+ ASSERT_TRUE(str.size() == 1);
+ ASSERT_TRUE(std::strncmp(str.data(), "a", 1) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromChar()
+{
+ std::cout << "testConstructFromChar()\n";
+ return testFromChar('a');
+}
+
+static bool testAssignFromChar()
+{
+ std::cout << "testAssignFromChar()\n";
+ cm::String str;
+ str = 'a';
+ return testFromChar(str);
+}
+
+static bool testConstructFromInitList()
+{
+ std::cout << "testConstructFromInitList()\n";
+ cm::String const str{ 'a', 'b', 'c' };
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), "abc", 3) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testAssignFromInitList()
+{
+ std::cout << "testAssignFromInitList()\n";
+ cm::String str;
+ str = { 'a', 'b', 'c' };
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), "abc", 3) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromBuffer()
+{
+ std::cout << "testConstructFromBuffer()\n";
+ cm::String const str(cstr, 3);
+ return testFromCStr(str);
+}
+
+static bool testConstructFromInputIterator()
+{
+ std::cout << "testConstructFromInputIterator()\n";
+ cm::String const str(cstr, cstr + 3);
+ ASSERT_TRUE(str.data() != cstr);
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), cstr, 3) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testConstructFromN()
+{
+ std::cout << "testConstructFromN()\n";
+ cm::String const str(3, 'a');
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), "aaa", 3) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static const auto staticStringView = "abc"_s;
+
+static bool testFromStaticStringView(cm::String str)
+{
+ cm::String const& str_const = str;
+ ASSERT_TRUE(str_const.data() == staticStringView.data());
+ ASSERT_TRUE(str_const.size() == staticStringView.size());
+ ASSERT_TRUE(!str_const.is_stable());
+ ASSERT_TRUE(str.c_str() == staticStringView);
+ ASSERT_TRUE(!str.is_stable());
+ cm::String substr = str.substr(1);
+ cm::String const& substr_const = substr;
+ ASSERT_TRUE(substr_const.data() == &staticStringView[1]);
+ ASSERT_TRUE(substr_const.size() == 2);
+ ASSERT_TRUE(!substr_const.is_stable());
+ ASSERT_TRUE(substr.c_str() == &staticStringView[1]);
+ ASSERT_TRUE(!substr.is_stable());
+ return true;
+}
+
+static bool testConstructFromStaticStringView()
+{
+ std::cout << "testConstructFromStaticStringView()\n";
+ return testFromStaticStringView(staticStringView);
+}
+
+static bool testAssignFromStaticStringView()
+{
+ std::cout << "testAssignFromStaticStringView()\n";
+ cm::String str;
+ str = staticStringView;
+ return testFromStaticStringView(str);
+}
+
+static bool testConstructCopy()
+{
+ std::cout << "testConstructCopy()\n";
+ cm::String s1 = std::string("abc");
+ cm::String s2 = s1;
+ ASSERT_TRUE(s1.data() == s2.data());
+ ASSERT_TRUE(s1.size() == 3);
+ ASSERT_TRUE(s2.size() == 3);
+ ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
+ ASSERT_TRUE(s1.is_stable());
+ ASSERT_TRUE(s2.is_stable());
+ return true;
+}
+
+static bool testConstructMove()
+{
+ std::cout << "testConstructMove()\n";
+ cm::String s1 = std::string("abc");
+ cm::String s2 = std::move(s1);
+ ASSERT_TRUE(s1.data() == nullptr);
+ ASSERT_TRUE(s1.size() == 0);
+ ASSERT_TRUE(s2.size() == 3);
+ ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
+ ASSERT_TRUE(s1.is_stable());
+ ASSERT_TRUE(s2.is_stable());
+ return true;
+}
+
+static bool testAssignCopy()
+{
+ std::cout << "testAssignCopy()\n";
+ cm::String s1 = std::string("abc");
+ cm::String s2;
+ s2 = s1;
+ ASSERT_TRUE(s1.data() == s2.data());
+ ASSERT_TRUE(s1.size() == 3);
+ ASSERT_TRUE(s2.size() == 3);
+ ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
+ ASSERT_TRUE(s1.is_stable());
+ ASSERT_TRUE(s2.is_stable());
+ return true;
+}
+
+static bool testAssignMove()
+{
+ std::cout << "testAssignMove()\n";
+ cm::String s1 = std::string("abc");
+ cm::String s2;
+ s2 = std::move(s1);
+ ASSERT_TRUE(s1.data() == nullptr);
+ ASSERT_TRUE(s1.size() == 0);
+ ASSERT_TRUE(s2.size() == 3);
+ ASSERT_TRUE(std::strncmp(s2.data(), "abc", 3) == 0);
+ ASSERT_TRUE(s1.is_stable());
+ ASSERT_TRUE(s2.is_stable());
+ return true;
+}
+
+static bool testOperatorBool()
+{
+ std::cout << "testOperatorBool()\n";
+ cm::String str;
+ ASSERT_TRUE(!str);
+ str = "";
+ ASSERT_TRUE(str);
+ str = static_cast<const char*>(nullptr);
+ ASSERT_TRUE(!str);
+ str = std::string();
+ ASSERT_TRUE(str);
+ str = nullptr;
+ ASSERT_TRUE(!str);
+ return true;
+}
+
+static bool testOperatorIndex()
+{
+ std::cout << "testOperatorIndex()\n";
+ cm::String str = "abc";
+ ASSERT_TRUE(str[0] == 'a');
+ ASSERT_TRUE(str[1] == 'b');
+ ASSERT_TRUE(str[2] == 'c');
+ return true;
+}
+
+static bool testOperatorPlusEqual()
+{
+ std::cout << "testOperatorPlusEqual()\n";
+ cm::String str = "a";
+ str += "b";
+ {
+ const char* c = "c";
+ str += c;
+ }
+ str += 'd';
+ str += std::string("e");
+ str += cm::string_view("f", 1);
+ str += cm::String("g");
+ ASSERT_TRUE(str.size() == 7);
+ ASSERT_TRUE(std::strncmp(str.data(), "abcdefg", 7) == 0);
+ ASSERT_TRUE(str.is_stable());
+ return true;
+}
+
+static bool testOperatorCompare()
+{
+ std::cout << "testOperatorCompare()\n";
+ cm::String str = "b";
+ {
+ ASSERT_TRUE(str == "b");
+ ASSERT_TRUE("b" == str);
+ ASSERT_TRUE(str != "a");
+ ASSERT_TRUE("a" != str);
+ ASSERT_TRUE(str < "c");
+ ASSERT_TRUE("a" < str);
+ ASSERT_TRUE(str > "a");
+ ASSERT_TRUE("c" > str);
+ ASSERT_TRUE(str <= "b");
+ ASSERT_TRUE("b" <= str);
+ ASSERT_TRUE(str >= "b");
+ ASSERT_TRUE("b" >= str);
+ }
+ {
+ const char* a = "a";
+ const char* b = "b";
+ const char* c = "c";
+ ASSERT_TRUE(str == b);
+ ASSERT_TRUE(b == str);
+ ASSERT_TRUE(str != a);
+ ASSERT_TRUE(a != str);
+ ASSERT_TRUE(str < c);
+ ASSERT_TRUE(a < str);
+ ASSERT_TRUE(str > a);
+ ASSERT_TRUE(c > str);
+ ASSERT_TRUE(str <= b);
+ ASSERT_TRUE(b <= str);
+ ASSERT_TRUE(str >= b);
+ ASSERT_TRUE(b >= str);
+ }
+ {
+ ASSERT_TRUE(str == 'b');
+ ASSERT_TRUE('b' == str);
+ ASSERT_TRUE(str != 'a');
+ ASSERT_TRUE('a' != str);
+ ASSERT_TRUE(str < 'c');
+ ASSERT_TRUE('a' < str);
+ ASSERT_TRUE(str > 'a');
+ ASSERT_TRUE('c' > str);
+ ASSERT_TRUE(str <= 'b');
+ ASSERT_TRUE('b' <= str);
+ ASSERT_TRUE(str >= 'b');
+ ASSERT_TRUE('b' >= str);
+ }
+ {
+ std::string const a = "a";
+ std::string const b = "b";
+ std::string const c = "c";
+ ASSERT_TRUE(str == b);
+ ASSERT_TRUE(b == str);
+ ASSERT_TRUE(str != a);
+ ASSERT_TRUE(a != str);
+ ASSERT_TRUE(str < c);
+ ASSERT_TRUE(a < str);
+ ASSERT_TRUE(str > a);
+ ASSERT_TRUE(c > str);
+ ASSERT_TRUE(str <= b);
+ ASSERT_TRUE(b <= str);
+ ASSERT_TRUE(str >= b);
+ ASSERT_TRUE(b >= str);
+ }
+ {
+ cm::string_view const a("a", 1);
+ cm::string_view const b("b", 1);
+ cm::string_view const c("c", 1);
+ ASSERT_TRUE(str == b);
+ ASSERT_TRUE(b == str);
+ ASSERT_TRUE(str != a);
+ ASSERT_TRUE(a != str);
+ ASSERT_TRUE(str < c);
+ ASSERT_TRUE(a < str);
+ ASSERT_TRUE(str > a);
+ ASSERT_TRUE(c > str);
+ ASSERT_TRUE(str <= b);
+ ASSERT_TRUE(b <= str);
+ ASSERT_TRUE(str >= b);
+ ASSERT_TRUE(b >= str);
+ }
+ {
+ cm::String const a("a");
+ cm::String const b("b");
+ cm::String const c("c");
+ ASSERT_TRUE(str == b);
+ ASSERT_TRUE(b == str);
+ ASSERT_TRUE(str != a);
+ ASSERT_TRUE(a != str);
+ ASSERT_TRUE(str < c);
+ ASSERT_TRUE(a < str);
+ ASSERT_TRUE(str > a);
+ ASSERT_TRUE(c > str);
+ ASSERT_TRUE(str <= b);
+ ASSERT_TRUE(b <= str);
+ ASSERT_TRUE(str >= b);
+ ASSERT_TRUE(b >= str);
+ }
+ return true;
+}
+
+static bool testOperatorStream()
+{
+ std::cout << "testOperatorStream()\n";
+ std::ostringstream ss;
+ ss << "a" << cm::String("b") << 'c';
+ ASSERT_TRUE(ss.str() == "abc");
+ return true;
+}
+
+static bool testOperatorStdStringPlusEqual()
+{
+ std::cout << "testOperatorStdStringPlusEqual()\n";
+ std::string s = "a";
+ s += cm::String("b");
+ ASSERT_TRUE(s == "ab");
+ return true;
+}
+
+static bool testMethod_borrow()
+{
+ std::cout << "testMethod_borrow()\n";
+ std::string s = "abc";
+ cm::String str = cm::String::borrow(s);
+ ASSERT_TRUE(str.data() == s.data());
+ ASSERT_TRUE(str.size() == s.size());
+ ASSERT_TRUE(str == s);
+ return true;
+}
+
+static bool testMethod_view()
+{
+ std::cout << "testMethod_view()\n";
+ cm::String str;
+ ASSERT_TRUE(str.view().data() == nullptr);
+ ASSERT_TRUE(str.view().size() == 0);
+ str = charArray;
+ ASSERT_TRUE(str.view().data() != charArray);
+ ASSERT_TRUE(str.view().size() == sizeof(charArray) - 1);
+ str = std::string("abc");
+ ASSERT_TRUE(str.view().size() == 3);
+ ASSERT_TRUE(strncmp(str.view().data(), "abc", 3) == 0);
+ return true;
+}
+
+static bool testMethod_empty()
+{
+ std::cout << "testMethod_empty()\n";
+ cm::String str;
+ ASSERT_TRUE(str.empty());
+ str = "";
+ ASSERT_TRUE(str.empty());
+ str = "abc";
+ ASSERT_TRUE(!str.empty());
+ str = std::string();
+ ASSERT_TRUE(str.empty());
+ str = std::string("abc");
+ ASSERT_TRUE(!str.empty());
+ return true;
+}
+
+static bool testMethod_length()
+{
+ std::cout << "testMethod_length()\n";
+ cm::String str;
+ ASSERT_TRUE(str.length() == 0);
+ str = "";
+ ASSERT_TRUE(str.length() == 0);
+ str = "abc";
+ ASSERT_TRUE(str.length() == 3);
+ str = std::string();
+ ASSERT_TRUE(str.length() == 0);
+ str = std::string("abc");
+ ASSERT_TRUE(str.length() == 3);
+ return true;
+}
+
+static bool testMethod_at()
+{
+ std::cout << "testMethod_at()\n";
+ cm::String str = "abc";
+ ASSERT_TRUE(str.at(0) == 'a');
+ ASSERT_TRUE(str.at(1) == 'b');
+ ASSERT_TRUE(str.at(2) == 'c');
+ bool except_out_of_range = false;
+ try {
+ str.at(3);
+ } catch (std::out_of_range&) {
+ except_out_of_range = true;
+ }
+ ASSERT_TRUE(except_out_of_range);
+ return true;
+}
+
+static bool testMethod_front_back()
+{
+ std::cout << "testMethod_front_back()\n";
+ cm::String str = "abc";
+ ASSERT_TRUE(str.front() == 'a');
+ ASSERT_TRUE(str.back() == 'c');
+ return true;
+}
+
+static bool testMethodIterators()
+{
+ std::cout << "testMethodIterators()\n";
+ cm::String str = "abc";
+ ASSERT_TRUE(*str.begin() == 'a');
+ ASSERT_TRUE(*(str.end() - 1) == 'c');
+ ASSERT_TRUE(str.end() - str.begin() == 3);
+ ASSERT_TRUE(*str.cbegin() == 'a');
+ ASSERT_TRUE(*(str.cend() - 1) == 'c');
+ ASSERT_TRUE(str.cend() - str.cbegin() == 3);
+ ASSERT_TRUE(*str.rbegin() == 'c');
+ ASSERT_TRUE(*(str.rend() - 1) == 'a');
+ ASSERT_TRUE(str.rend() - str.rbegin() == 3);
+ ASSERT_TRUE(*str.crbegin() == 'c');
+ ASSERT_TRUE(*(str.crend() - 1) == 'a');
+ ASSERT_TRUE(str.crend() - str.crbegin() == 3);
+ return true;
+}
+
+static bool testMethod_clear()
+{
+ std::cout << "testMethod_clear()\n";
+ cm::String str = "abc";
+ ASSERT_TRUE(!str.empty());
+ str.clear();
+ ASSERT_TRUE(str.empty());
+ return true;
+}
+
+static bool testMethod_insert()
+{
+ std::cout << "testMethod_insert()\n";
+ cm::String str = "abc";
+ str.insert(1, 2, 'd').insert(0, 1, '_');
+ ASSERT_TRUE(str.size() == 6);
+ ASSERT_TRUE(std::strncmp(str.data(), "_addbc", 6) == 0);
+ return true;
+}
+
+static bool testMethod_erase()
+{
+ std::cout << "testMethod_erase()\n";
+ cm::String str = "abcdefg";
+ str.erase(5).erase(1, 2);
+ ASSERT_TRUE(str.size() == 3);
+ ASSERT_TRUE(std::strncmp(str.data(), "ade", 3) == 0);
+ return true;
+}
+
+static bool testMethod_push_back()
+{
+ std::cout << "testMethod_push_back()\n";
+ cm::String str = "abc";
+ str.push_back('d');
+ ASSERT_TRUE(str == "abcd");
+ return true;
+}
+
+static bool testMethod_pop_back()
+{
+ std::cout << "testMethod_pop_back()\n";
+ cm::String str = "abc";
+ str.pop_back();
+ ASSERT_TRUE(str == "ab");
+ return true;
+}
+
+static bool testMethod_replace()
+{
+ std::cout << "testMethod_replace()\n";
+ {
+ cm::String str = "abcd";
+ const char* bc = "bc";
+ ASSERT_TRUE(str.replace(1, 2, "BC") == "aBCd");
+ ASSERT_TRUE(str.replace(1, 2, bc) == "abcd");
+ ASSERT_TRUE(str.replace(1, 2, 'x') == "axd");
+ ASSERT_TRUE(str.replace(1, 1, std::string("bc")) == "abcd");
+ ASSERT_TRUE(str.replace(1, 2, cm::string_view("BC", 2)) == "aBCd");
+ ASSERT_TRUE(str.replace(1, 2, cm::String("bc")) == "abcd");
+ }
+ {
+ cm::String str = "abcd";
+ const char* bc = "bc";
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 3, "BC") == "aBCd");
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 3, bc) == "abcd");
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 3, 'x') == "axd");
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 2,
+ std::string("bc")) == "abcd");
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 3,
+ cm::string_view("BC", 2)) == "aBCd");
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 3,
+ cm::String("bc")) == "abcd");
+ }
+ {
+ cm::String str = "abcd";
+ const char* bc = "_bc";
+ ASSERT_TRUE(str.replace(1, 2, "_BC_", 1, 2) == "aBCd");
+ ASSERT_TRUE(str.replace(1, 2, bc, 1) == "abcd");
+ ASSERT_TRUE(str.replace(1, 2, 'x', 0) == "axd");
+ ASSERT_TRUE(str.replace(1, 1, std::string("_bc_"), 1, 2) == "abcd");
+ ASSERT_TRUE(str.replace(1, 2, cm::string_view("_BC", 3), 1) == "aBCd");
+ ASSERT_TRUE(str.replace(1, 2, cm::String("_bc_"), 1, 2) == "abcd");
+ }
+ {
+ cm::String str = "abcd";
+ const char* bc = "_bc_";
+ ASSERT_TRUE(str.replace(1, 2, 2, 'x') == "axxd");
+ ASSERT_TRUE(str.replace(str.begin() + 1, str.begin() + 3, 2, 'y') ==
+ "ayyd");
+ ASSERT_TRUE(
+ str.replace(str.begin() + 1, str.begin() + 3, bc + 1, bc + 3) == "abcd");
+ }
+ return true;
+}
+
+static bool testMethod_copy()
+{
+ std::cout << "testMethod_copy()\n";
+ cm::String str = "abc";
+ char dest[2];
+ cm::String::size_type n = str.copy(dest, 2, 1);
+ ASSERT_TRUE(n == 2);
+ ASSERT_TRUE(std::strncmp(dest, "bc", 2) == 0);
+ n = str.copy(dest, 2);
+ ASSERT_TRUE(n == 2);
+ ASSERT_TRUE(std::strncmp(dest, "ab", 2) == 0);
+ return true;
+}
+
+static bool testMethod_resize()
+{
+ std::cout << "testMethod_resize()\n";
+ cm::String str = "abc";
+ str.resize(3);
+ ASSERT_TRUE(str == "abc");
+ str.resize(2);
+ ASSERT_TRUE(str == "ab");
+ str.resize(3, 'c');
+ ASSERT_TRUE(str == "abc");
+ return true;
+}
+
+static bool testMethod_swap()
+{
+ std::cout << "testMethod_swap()\n";
+ cm::String str1 = std::string("1");
+ cm::String str2 = std::string("2");
+ str1.swap(str2);
+ ASSERT_TRUE(str1 == "2");
+ ASSERT_TRUE(str2 == "1");
+ return true;
+}
+
+static bool testMethod_substr_AtEnd(cm::String str)
+{
+ cm::String substr = str.substr(1);
+ ASSERT_TRUE(substr.data() == str.data() + 1);
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(!substr.is_stable());
+
+ // c_str() at the end of the buffer does not internally mutate.
+ ASSERT_TRUE(std::strcmp(substr.c_str(), "bc") == 0);
+ ASSERT_TRUE(substr.c_str() == str.data() + 1);
+ ASSERT_TRUE(substr.data() == str.data() + 1);
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(!substr.is_stable());
+
+ // str() internally mutates.
+ ASSERT_TRUE(substr.str() == "bc");
+ ASSERT_TRUE(substr.is_stable());
+ ASSERT_TRUE(substr.data() != str.data() + 1);
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(substr.c_str() != str.data() + 1);
+ ASSERT_TRUE(std::strcmp(substr.c_str(), "bc") == 0);
+ return true;
+}
+
+static bool testMethod_substr_AtEndBorrowed()
+{
+ std::cout << "testMethod_substr_AtEndBorrowed()\n";
+ return testMethod_substr_AtEnd("abc"_s);
+}
+
+static bool testMethod_substr_AtEndOwned()
+{
+ std::cout << "testMethod_substr_AtEndOwned()\n";
+ return testMethod_substr_AtEnd(std::string("abc"));
+}
+
+static bool testMethod_substr_AtStart(cm::String str)
+{
+ {
+ cm::String substr = str.substr(0, 2);
+ ASSERT_TRUE(substr.data() == str.data());
+ ASSERT_TRUE(substr.size() == 2);
+
+ // c_str() not at the end of the buffer internally mutates.
+ const char* substr_c = substr.c_str();
+ ASSERT_TRUE(std::strcmp(substr_c, "ab") == 0);
+ ASSERT_TRUE(substr_c != str.data());
+ ASSERT_TRUE(substr.data() != str.data());
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(substr.is_stable());
+
+ // str() does not need to internally mutate after c_str() did so
+ ASSERT_TRUE(substr.str() == "ab");
+ ASSERT_TRUE(substr.is_stable());
+ ASSERT_TRUE(substr.data() == substr_c);
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(substr.c_str() == substr_c);
+ }
+
+ {
+ cm::String substr = str.substr(0, 2);
+ ASSERT_TRUE(substr.data() == str.data());
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(!substr.is_stable());
+
+ // str() internally mutates.
+ ASSERT_TRUE(substr.str() == "ab");
+ ASSERT_TRUE(substr.is_stable());
+ ASSERT_TRUE(substr.data() != str.data());
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(substr.c_str() != str.data());
+
+ // c_str() does not internally after str() did so
+ const char* substr_c = substr.c_str();
+ ASSERT_TRUE(std::strcmp(substr_c, "ab") == 0);
+ ASSERT_TRUE(substr_c == substr.data());
+ ASSERT_TRUE(substr.size() == 2);
+ ASSERT_TRUE(substr.is_stable());
+ }
+
+ return true;
+}
+
+static bool testMethod_substr_AtStartBorrowed()
+{
+ std::cout << "testMethod_substr_AtStartBorrowed()\n";
+ return testMethod_substr_AtStart("abc"_s);
+}
+
+static bool testMethod_substr_AtStartOwned()
+{
+ std::cout << "testMethod_substr_AtStartOwned()\n";
+ return testMethod_substr_AtStart(std::string("abc"));
+}
+
+static bool testMethod_compare()
+{
+ std::cout << "testMethod_compare()\n";
+ cm::String str = "b";
+ ASSERT_TRUE(str.compare("a") > 0);
+ ASSERT_TRUE(str.compare("b") == 0);
+ ASSERT_TRUE(str.compare("c") < 0);
+ {
+ const char* a = "a";
+ const char* b = "b";
+ const char* c = "c";
+ ASSERT_TRUE(str.compare(a) > 0);
+ ASSERT_TRUE(str.compare(b) == 0);
+ ASSERT_TRUE(str.compare(c) < 0);
+ }
+ ASSERT_TRUE(str.compare('a') > 0);
+ ASSERT_TRUE(str.compare('b') == 0);
+ ASSERT_TRUE(str.compare('c') < 0);
+ ASSERT_TRUE(str.compare(std::string("a")) > 0);
+ ASSERT_TRUE(str.compare(std::string("b")) == 0);
+ ASSERT_TRUE(str.compare(std::string("c")) < 0);
+ ASSERT_TRUE(str.compare(cm::string_view("a_", 1)) > 0);
+ ASSERT_TRUE(str.compare(cm::string_view("b_", 1)) == 0);
+ ASSERT_TRUE(str.compare(cm::string_view("c_", 1)) < 0);
+ ASSERT_TRUE(str.compare(cm::String("a")) > 0);
+ ASSERT_TRUE(str.compare(cm::String("b")) == 0);
+ ASSERT_TRUE(str.compare(cm::String("c")) < 0);
+ ASSERT_TRUE(str.compare(0, 1, cm::string_view("a", 1)) > 0);
+ ASSERT_TRUE(str.compare(1, 0, cm::string_view("", 0)) == 0);
+ ASSERT_TRUE(str.compare(0, 1, cm::string_view("ac", 2), 1, 1) < 0);
+ ASSERT_TRUE(str.compare(1, 0, "") == 0);
+ ASSERT_TRUE(str.compare(1, 0, "_", 0) == 0);
+ return true;
+}
+
+static bool testMethod_find()
+{
+ std::cout << "testMethod_find()\n";
+ cm::String str = "abcabc";
+ ASSERT_TRUE(str.find("a") == 0);
+ ASSERT_TRUE(str.find("a", 1) == 3);
+ {
+ const char* a = "a";
+ ASSERT_TRUE(str.find(a) == 0);
+ ASSERT_TRUE(str.find(a, 1) == 3);
+ }
+ ASSERT_TRUE(str.find('a') == 0);
+ ASSERT_TRUE(str.find('a', 1) == 3);
+ ASSERT_TRUE(str.find(std::string("a")) == 0);
+ ASSERT_TRUE(str.find(std::string("a"), 1) == 3);
+ ASSERT_TRUE(str.find(cm::string_view("a_", 1)) == 0);
+ ASSERT_TRUE(str.find(cm::string_view("a_", 1), 1) == 3);
+ ASSERT_TRUE(str.find(cm::String("a")) == 0);
+ ASSERT_TRUE(str.find(cm::String("a"), 1) == 3);
+ ASSERT_TRUE(str.find("ab_", 1, 2) == 3);
+ return true;
+}
+
+static bool testMethod_rfind()
+{
+ std::cout << "testMethod_rfind()\n";
+ cm::String str = "abcabc";
+ ASSERT_TRUE(str.rfind("a") == 3);
+ ASSERT_TRUE(str.rfind("a", 1) == 0);
+ {
+ const char* a = "a";
+ ASSERT_TRUE(str.rfind(a) == 3);
+ ASSERT_TRUE(str.rfind(a, 1) == 0);
+ }
+ ASSERT_TRUE(str.rfind('a') == 3);
+ ASSERT_TRUE(str.rfind('a', 1) == 0);
+ ASSERT_TRUE(str.rfind(std::string("a")) == 3);
+ ASSERT_TRUE(str.rfind(std::string("a"), 1) == 0);
+ ASSERT_TRUE(str.rfind(cm::string_view("a_", 1)) == 3);
+ ASSERT_TRUE(str.rfind(cm::string_view("a_", 1), 1) == 0);
+ ASSERT_TRUE(str.rfind(cm::String("a")) == 3);
+ ASSERT_TRUE(str.rfind(cm::String("a"), 1) == 0);
+ ASSERT_TRUE(str.rfind("ab_", 1, 2) == 0);
+ return true;
+}
+
+static bool testMethod_find_first_of()
+{
+ std::cout << "testMethod_find_first_of()\n";
+ cm::String str = "abcabc";
+ ASSERT_TRUE(str.find_first_of("_a") == 0);
+ ASSERT_TRUE(str.find_first_of("_a", 1) == 3);
+ {
+ const char* a = "_a";
+ ASSERT_TRUE(str.find_first_of(a) == 0);
+ ASSERT_TRUE(str.find_first_of(a, 1) == 3);
+ }
+ ASSERT_TRUE(str.find_first_of('a') == 0);
+ ASSERT_TRUE(str.find_first_of('a', 1) == 3);
+ ASSERT_TRUE(str.find_first_of(std::string("_a")) == 0);
+ ASSERT_TRUE(str.find_first_of(std::string("_a"), 1) == 3);
+ ASSERT_TRUE(str.find_first_of(cm::string_view("ba_", 1)) == 1);
+ ASSERT_TRUE(str.find_first_of(cm::string_view("ba_", 1), 2) == 4);
+ ASSERT_TRUE(str.find_first_of(cm::String("ab")) == 0);
+ ASSERT_TRUE(str.find_first_of(cm::String("ab"), 2) == 3);
+ ASSERT_TRUE(str.find_first_of("_ab", 1, 2) == 3);
+ return true;
+}
+
+static bool testMethod_find_first_not_of()
+{
+ std::cout << "testMethod_find_first_not_of()\n";
+ cm::String str = "abcabc";
+ ASSERT_TRUE(str.find_first_not_of("_a") == 1);
+ ASSERT_TRUE(str.find_first_not_of("_a", 2) == 2);
+ {
+ const char* a = "_a";
+ ASSERT_TRUE(str.find_first_not_of(a) == 1);
+ ASSERT_TRUE(str.find_first_not_of(a, 2) == 2);
+ }
+ ASSERT_TRUE(str.find_first_not_of('a') == 1);
+ ASSERT_TRUE(str.find_first_not_of('a', 2) == 2);
+ ASSERT_TRUE(str.find_first_not_of(std::string("_a")) == 1);
+ ASSERT_TRUE(str.find_first_not_of(std::string("_a"), 2) == 2);
+ ASSERT_TRUE(str.find_first_not_of(cm::string_view("ba_", 1)) == 0);
+ ASSERT_TRUE(str.find_first_not_of(cm::string_view("ba_", 1), 1) == 2);
+ ASSERT_TRUE(str.find_first_not_of(cm::String("_a")) == 1);
+ ASSERT_TRUE(str.find_first_not_of(cm::String("_a"), 2) == 2);
+ ASSERT_TRUE(str.find_first_not_of("_bca", 1, 3) == 3);
+ return true;
+}
+
+static bool testMethod_find_last_of()
+{
+ std::cout << "testMethod_find_last_of()\n";
+ cm::String str = "abcabc";
+ ASSERT_TRUE(str.find_last_of("_a") == 3);
+ ASSERT_TRUE(str.find_last_of("_a", 1) == 0);
+ {
+ const char* a = "_a";
+ ASSERT_TRUE(str.find_last_of(a) == 3);
+ ASSERT_TRUE(str.find_last_of(a, 1) == 0);
+ }
+ ASSERT_TRUE(str.find_last_of('a') == 3);
+ ASSERT_TRUE(str.find_last_of('a', 1) == 0);
+ ASSERT_TRUE(str.find_last_of(std::string("_a")) == 3);
+ ASSERT_TRUE(str.find_last_of(std::string("_a"), 1) == 0);
+ ASSERT_TRUE(str.find_last_of(cm::string_view("ba_", 1)) == 4);
+ ASSERT_TRUE(str.find_last_of(cm::string_view("ba_", 1), 2) == 1);
+ ASSERT_TRUE(str.find_last_of(cm::String("ab")) == 4);
+ ASSERT_TRUE(str.find_last_of(cm::String("ab"), 2) == 1);
+ ASSERT_TRUE(str.find_last_of("_ab", 1, 2) == 0);
+ return true;
+}
+
+static bool testMethod_find_last_not_of()
+{
+ std::cout << "testMethod_find_last_not_of()\n";
+ cm::String str = "abcabc";
+ ASSERT_TRUE(str.find_last_not_of("_a") == 5);
+ ASSERT_TRUE(str.find_last_not_of("_a", 1) == 1);
+ {
+ const char* a = "_a";
+ ASSERT_TRUE(str.find_last_not_of(a) == 5);
+ ASSERT_TRUE(str.find_last_not_of(a, 1) == 1);
+ }
+ ASSERT_TRUE(str.find_last_not_of('a') == 5);
+ ASSERT_TRUE(str.find_last_not_of('a', 1) == 1);
+ ASSERT_TRUE(str.find_last_not_of(std::string("_a")) == 5);
+ ASSERT_TRUE(str.find_last_not_of(std::string("_a"), 1) == 1);
+ ASSERT_TRUE(str.find_last_not_of(cm::string_view("cb_", 1)) == 4);
+ ASSERT_TRUE(str.find_last_not_of(cm::string_view("cb_", 1), 2) == 1);
+ ASSERT_TRUE(str.find_last_not_of(cm::String("_a")) == 5);
+ ASSERT_TRUE(str.find_last_not_of(cm::String("_a"), 1) == 1);
+ ASSERT_TRUE(str.find_last_not_of("cb_", 2, 2) == 0);
+ return true;
+}
+
+static bool testAddition()
+{
+ std::cout << "testAddition()\n";
+ {
+ ASSERT_TRUE(cm::String("a") + "b" == "ab");
+ ASSERT_TRUE("ab" == "a" + cm::String("b"));
+ ASSERT_TRUE("a" + cm::String("b") + "c" == "abc");
+ ASSERT_TRUE("abc" == "a" + cm::String("b") + "c");
+ ASSERT_TRUE("a" + (cm::String("b") + "c") + "d" == "abcd");
+ ASSERT_TRUE("abcd" == "a" + (cm::String("b") + "c") + "d");
+ }
+ {
+ ASSERT_TRUE(cm::String("a"_s) + "b"_s == "ab"_s);
+ ASSERT_TRUE("ab"_s == "a"_s + cm::String("b"_s));
+ ASSERT_TRUE("a"_s + cm::String("b"_s) + "c"_s == "abc"_s);
+ ASSERT_TRUE("abc"_s == "a"_s + cm::String("b"_s) + "c"_s);
+ ASSERT_TRUE("a"_s + (cm::String("b"_s) + "c"_s) + "d"_s == "abcd"_s);
+ ASSERT_TRUE("abcd"_s == "a"_s + (cm::String("b"_s) + "c"_s) + "d"_s);
+ }
+ {
+ const char* a = "a";
+ const char* b = "b";
+ const char* ab = "ab";
+ ASSERT_TRUE(cm::String(a) + b == ab);
+ ASSERT_TRUE(ab == a + cm::String(b));
+ const char* c = "c";
+ const char* abc = "abc";
+ ASSERT_TRUE(a + cm::String(b) + c == abc);
+ ASSERT_TRUE(abc == a + cm::String(b) + c);
+ const char* d = "d";
+ const char* abcd = "abcd";
+ ASSERT_TRUE(a + (cm::String(b) + c) + d == abcd);
+ ASSERT_TRUE(abcd == a + (cm::String(b) + c) + d);
+ }
+ {
+ ASSERT_TRUE(cm::String('a') + 'b' == "ab");
+ ASSERT_TRUE("ab" == 'a' + cm::String('b'));
+ ASSERT_TRUE('a' + cm::String('b') + 'c' == "abc");
+ ASSERT_TRUE("abc" == 'a' + cm::String('b') + 'c');
+ ASSERT_TRUE('a' + (cm::String('b') + 'c') + 'd' == "abcd");
+ ASSERT_TRUE("abcd" == 'a' + (cm::String('b') + 'c') + 'd');
+ }
+ {
+ std::string a = "a";
+ std::string b = "b";
+ std::string ab = "ab";
+ ASSERT_TRUE(cm::String(a) + b == ab);
+ ASSERT_TRUE(ab == a + cm::String(b));
+ std::string c = "c";
+ std::string abc = "abc";
+ ASSERT_TRUE(a + cm::String(b) + c == abc);
+ ASSERT_TRUE(abc == a + cm::String(b) + c);
+ std::string d = "d";
+ std::string abcd = "abcd";
+ ASSERT_TRUE(a + (cm::String(b) + c) + d == abcd);
+ ASSERT_TRUE(abcd == a + (cm::String(b) + c) + d);
+ }
+ {
+ cm::string_view a("a", 1);
+ cm::string_view b("b", 1);
+ cm::string_view ab("ab", 2);
+ ASSERT_TRUE(cm::String(a) + b == ab);
+ ASSERT_TRUE(ab == a + cm::String(b));
+ cm::string_view c("c", 1);
+ cm::string_view abc("abc", 3);
+ ASSERT_TRUE(a + cm::String(b) + c == abc);
+ ASSERT_TRUE(abc == a + cm::String(b) + c);
+ cm::string_view d("d", 1);
+ cm::string_view abcd("abcd", 4);
+ ASSERT_TRUE(a + (cm::String(b) + c) + d == abcd);
+ ASSERT_TRUE(abcd == a + (cm::String(b) + c) + d);
+ }
+ {
+ cm::String a = "a";
+ cm::String b = "b";
+ cm::String ab = "ab";
+ ASSERT_TRUE(a + b == ab);
+ ASSERT_TRUE(ab == a + b);
+ cm::String c = "c";
+ cm::String abc = "abc";
+ ASSERT_TRUE(a + cm::String(b) + c == abc);
+ ASSERT_TRUE(abc == a + cm::String(b) + c);
+ cm::String d = "d";
+ cm::String abcd = "abcd";
+ ASSERT_TRUE(a + (cm::String(b) + c) + d == abcd);
+ ASSERT_TRUE(abcd == a + (cm::String(b) + c) + d);
+ }
+ {
+ cm::String str;
+ str += "a" + cm::String("b") + 'c';
+ ASSERT_TRUE(str == "abc");
+ ASSERT_TRUE(str.is_stable());
+ }
+ {
+ std::string s;
+ s += "a" + cm::String("b") + 'c';
+ ASSERT_TRUE(s == "abc");
+ }
+ {
+ std::ostringstream ss;
+ ss << ("a" + cm::String("b") + 'c');
+ ASSERT_TRUE(ss.str() == "abc");
+ }
+ return true;
+}
+
+static bool testStability()
+{
+ std::cout << "testStability()\n";
+ cm::String str = "abc"_s;
+ ASSERT_TRUE(!str.is_stable());
+ ASSERT_TRUE(str.str_if_stable() == nullptr);
+ str.stabilize();
+ ASSERT_TRUE(str.is_stable());
+ std::string const* str_if_stable = str.str_if_stable();
+ ASSERT_TRUE(str_if_stable != nullptr);
+ ASSERT_TRUE(*str_if_stable == "abc");
+ str.stabilize();
+ ASSERT_TRUE(str.is_stable());
+ ASSERT_TRUE(str.str_if_stable() == str_if_stable);
+ return true;
+}
+
+int testString(int /*unused*/, char* /*unused*/ [])
+{
+ if (!testConstructDefault()) {
+ return 1;
+ }
+ if (!testConstructFromNullPtr()) {
+ return 1;
+ }
+ if (!testConstructFromCStrNull()) {
+ return 1;
+ }
+ if (!testConstructFromCharArray()) {
+ return 1;
+ }
+ if (!testConstructFromCStr()) {
+ return 1;
+ }
+ if (!testConstructFromStdString()) {
+ return 1;
+ }
+ if (!testConstructFromView()) {
+ return 1;
+ }
+ if (!testConstructFromChar()) {
+ return 1;
+ }
+ if (!testConstructFromInitList()) {
+ return 1;
+ }
+ if (!testConstructFromBuffer()) {
+ return 1;
+ }
+ if (!testConstructFromInputIterator()) {
+ return 1;
+ }
+ if (!testConstructFromN()) {
+ return 1;
+ }
+ if (!testConstructFromStaticStringView()) {
+ return 1;
+ }
+ if (!testConstructCopy()) {
+ return 1;
+ }
+ if (!testConstructMove()) {
+ return 1;
+ }
+ if (!testAssignCopy()) {
+ return 1;
+ }
+ if (!testAssignMove()) {
+ return 1;
+ }
+ if (!testAssignFromChar()) {
+ return 1;
+ }
+ if (!testAssignFromView()) {
+ return 1;
+ }
+ if (!testAssignFromStdString()) {
+ return 1;
+ }
+ if (!testAssignFromCStr()) {
+ return 1;
+ }
+ if (!testAssignFromCharArray()) {
+ return 1;
+ }
+ if (!testAssignFromCStrNull()) {
+ return 1;
+ }
+ if (!testAssignFromNullPtr()) {
+ return 1;
+ }
+ if (!testAssignFromInitList()) {
+ return 1;
+ }
+ if (!testAssignFromStaticStringView()) {
+ return 1;
+ }
+ if (!testOperatorBool()) {
+ return 1;
+ }
+ if (!testOperatorIndex()) {
+ return 1;
+ }
+ if (!testOperatorPlusEqual()) {
+ return 1;
+ }
+ if (!testOperatorCompare()) {
+ return 1;
+ }
+ if (!testOperatorStream()) {
+ return 1;
+ }
+ if (!testOperatorStdStringPlusEqual()) {
+ return 1;
+ }
+ if (!testMethod_borrow()) {
+ return 1;
+ }
+ if (!testMethod_view()) {
+ return 1;
+ }
+ if (!testMethod_empty()) {
+ return 1;
+ }
+ if (!testMethod_length()) {
+ return 1;
+ }
+ if (!testMethod_at()) {
+ return 1;
+ }
+ if (!testMethod_front_back()) {
+ return 1;
+ }
+ if (!testMethod_clear()) {
+ return 1;
+ }
+ if (!testMethod_insert()) {
+ return 1;
+ }
+ if (!testMethod_erase()) {
+ return 1;
+ }
+ if (!testMethod_push_back()) {
+ return 1;
+ }
+ if (!testMethod_pop_back()) {
+ return 1;
+ }
+ if (!testMethod_replace()) {
+ return 1;
+ }
+ if (!testMethod_copy()) {
+ return 1;
+ }
+ if (!testMethod_resize()) {
+ return 1;
+ }
+ if (!testMethod_swap()) {
+ return 1;
+ }
+ if (!testMethodIterators()) {
+ return 1;
+ }
+ if (!testMethod_substr_AtEndBorrowed()) {
+ return 1;
+ }
+ if (!testMethod_substr_AtEndOwned()) {
+ return 1;
+ }
+ if (!testMethod_substr_AtStartBorrowed()) {
+ return 1;
+ }
+ if (!testMethod_substr_AtStartOwned()) {
+ return 1;
+ }
+ if (!testMethod_compare()) {
+ return 1;
+ }
+ if (!testMethod_find()) {
+ return 1;
+ }
+ if (!testMethod_rfind()) {
+ return 1;
+ }
+ if (!testMethod_find_first_of()) {
+ return 1;
+ }
+ if (!testMethod_find_first_not_of()) {
+ return 1;
+ }
+ if (!testMethod_find_last_of()) {
+ return 1;
+ }
+ if (!testMethod_find_last_not_of()) {
+ return 1;
+ }
+ if (!testAddition()) {
+ return 1;
+ }
+ if (!testStability()) {
+ return 1;
+ }
+ return 0;
+}
diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx
new file mode 100644
index 000000000..63826cf28
--- /dev/null
+++ b/Tests/CMakeLib/testStringAlgorithms.cxx
@@ -0,0 +1,230 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include <cmConfigure.h> // IWYU pragma: keep
+
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include <cm/string_view>
+
+#include "cmStringAlgorithms.h"
+
+int testStringAlgorithms(int /*unused*/, char* /*unused*/ [])
+{
+ int failed = 0;
+
+ auto assert_ok = [&failed](bool test, cm::string_view title) {
+ if (test) {
+ std::cout << "Passed: " << title << "\n";
+ } else {
+ std::cout << "Failed: " << title << "\n";
+ ++failed;
+ }
+ };
+
+ auto assert_string = [&failed](cm::string_view generated,
+ cm::string_view expected,
+ cm::string_view title) {
+ if (generated == expected) {
+ std::cout << "Passed: " << title << "\n";
+ } else {
+ std::cout << "Failed: " << title << "\n";
+ std::cout << "Expected: " << expected << "\n";
+ std::cout << "Got: " << generated << "\n";
+ ++failed;
+ }
+ };
+
+ // ----------------------------------------------------------------------
+ // Test cmTrimWhitespace
+ {
+ std::string base = "base";
+ std::string spaces = " \f\f\n\n\r\r\t\t\v\v";
+ assert_string(cmTrimWhitespace(spaces + base), base,
+ "cmTrimWhitespace front");
+ assert_string(cmTrimWhitespace(base + spaces), base,
+ "cmTrimWhitespace back");
+ assert_string(cmTrimWhitespace(spaces + base + spaces), base,
+ "cmTrimWhitespace front and back");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmRemoveQuotes
+ {
+ auto test = [&assert_string](cm::string_view source,
+ cm::string_view expected,
+ cm::string_view title) {
+ assert_string(cmRemoveQuotes(source), expected, title);
+ };
+
+ test("", "", "cmRemoveQuotes empty");
+ test("\"", "\"", "cmRemoveQuotes single quote");
+ test("\"\"", "", "cmRemoveQuotes double quote");
+ test("\"a", "\"a", "cmRemoveQuotes quote char");
+ test("\"ab", "\"ab", "cmRemoveQuotes quote char char");
+ test("a\"", "a\"", "cmRemoveQuotes char quote");
+ test("ab\"", "ab\"", "cmRemoveQuotes char char quote");
+ test("a", "a", "cmRemoveQuotes single char");
+ test("ab", "ab", "cmRemoveQuotes two chars");
+ test("abc", "abc", "cmRemoveQuotes three chars");
+ test("\"abc\"", "abc", "cmRemoveQuotes quoted chars");
+ test("\"\"abc\"\"", "\"abc\"", "cmRemoveQuotes quoted quoted chars");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmEscapeQuotes
+ {
+ assert_string(cmEscapeQuotes("plain"), "plain", "cmEscapeQuotes plain");
+ std::string base = "\"base\"\"";
+ std::string result = "\\\"base\\\"\\\"";
+ assert_string(cmEscapeQuotes(base), result, "cmEscapeQuotes escaped");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmJoin
+ {
+ typedef std::string ST;
+ typedef std::vector<std::string> VT;
+ assert_string(cmJoin(ST("abc"), ";"), "a;b;c", "cmJoin std::string");
+ assert_string(cmJoin(VT{}, ";"), "", "cmJoin std::vector empty");
+ assert_string(cmJoin(VT{ "a" }, ";"), "a", "cmJoin std::vector single");
+ assert_string(cmJoin(VT{ "a", "b", "c" }, ";"), "a;b;c",
+ "cmJoin std::vector multiple");
+ assert_string(cmJoin(VT{ "a", "b", "c" }, "<=>"), "a<=>b<=>c",
+ "cmJoin std::vector long sep");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmTokenize
+ {
+ typedef std::vector<std::string> VT;
+ assert_ok(cmTokenize("", ";") == VT{ "" }, "cmTokenize empty");
+ assert_ok(cmTokenize(";", ";") == VT{ "" }, "cmTokenize sep");
+ assert_ok(cmTokenize("abc", ";") == VT{ "abc" }, "cmTokenize item");
+ assert_ok(cmTokenize("abc;", ";") == VT{ "abc" }, "cmTokenize item sep");
+ assert_ok(cmTokenize(";abc", ";") == VT{ "abc" }, "cmTokenize sep item");
+ assert_ok(cmTokenize("abc;;efg", ";") == VT{ "abc", "efg" },
+ "cmTokenize item sep sep item");
+ assert_ok(cmTokenize("a1;a2;a3;a4", ";") == VT{ "a1", "a2", "a3", "a4" },
+ "cmTokenize multiple items");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmStrCat
+ {
+ int ni = -1100;
+ unsigned int nui = 1100u;
+ long int nli = -12000l;
+ unsigned long int nuli = 12000ul;
+ long long int nlli = -130000ll;
+ unsigned long long int nulli = 130000ull;
+ std::string val =
+ cmStrCat("<test>", ni, ',', nui, ',', nli, ",", nuli, ", ", nlli,
+ std::string(", "), nulli, cm::string_view("</test>"));
+ std::string expect =
+ "<test>-1100,1100,-12000,12000, -130000, 130000</test>";
+ assert_string(val, expect, "cmStrCat strings and integers");
+ }
+ {
+ float const val = 1.5f;
+ float const div = 0.00001f;
+ float f = 0.0f;
+ std::istringstream(cmStrCat("", val)) >> f;
+ f -= val;
+ assert_ok((f < div) && (f > -div), "cmStrCat float");
+ }
+ {
+ double const val = 1.5;
+ double const div = 0.00001;
+ double d = 0.0;
+ std::istringstream(cmStrCat("", val)) >> d;
+ d -= val;
+ assert_ok((d < div) && (d > -div), "cmStrCat double");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmWrap
+ {
+ typedef std::vector<std::string> VT;
+ assert_string(cmWrap("<", VT{}, ">", "; "), //
+ "", //
+ "cmWrap empty, string prefix and suffix");
+ assert_string(cmWrap("<", VT{ "abc" }, ">", "; "), //
+ "<abc>", //
+ "cmWrap single, string prefix and suffix");
+ assert_string(cmWrap("<", VT{ "a1", "a2", "a3" }, ">", "; "), //
+ "<a1>; <a2>; <a3>", //
+ "cmWrap multiple, string prefix and suffix");
+
+ assert_string(cmWrap('<', VT{}, '>', "; "), //
+ "", //
+ "cmWrap empty, char prefix and suffix");
+ assert_string(cmWrap('<', VT{ "abc" }, '>', "; "), //
+ "<abc>", //
+ "cmWrap single, char prefix and suffix");
+ assert_string(cmWrap('<', VT{ "a1", "a2", "a3" }, '>', "; "), //
+ "<a1>; <a2>; <a3>", //
+ "cmWrap multiple, char prefix and suffix");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmHas(Literal)Prefix and cmHas(Literal)Suffix
+ {
+ std::string str("abc");
+ assert_ok(cmHasPrefix(str, 'a'), "cmHasPrefix char");
+ assert_ok(!cmHasPrefix(str, 'c'), "cmHasPrefix char not");
+ assert_ok(cmHasPrefix(str, "ab"), "cmHasPrefix string");
+ assert_ok(!cmHasPrefix(str, "bc"), "cmHasPrefix string not");
+ assert_ok(cmHasPrefix(str, str), "cmHasPrefix complete string");
+ assert_ok(cmHasLiteralPrefix(str, "ab"), "cmHasLiteralPrefix string");
+ assert_ok(!cmHasLiteralPrefix(str, "bc"), "cmHasLiteralPrefix string not");
+
+ assert_ok(cmHasSuffix(str, 'c'), "cmHasSuffix char");
+ assert_ok(!cmHasSuffix(str, 'a'), "cmHasSuffix char not");
+ assert_ok(cmHasSuffix(str, "bc"), "cmHasSuffix string");
+ assert_ok(!cmHasSuffix(str, "ab"), "cmHasSuffix string not");
+ assert_ok(cmHasSuffix(str, str), "cmHasSuffix complete string");
+ assert_ok(cmHasLiteralSuffix(str, "bc"), "cmHasLiteralSuffix string");
+ assert_ok(!cmHasLiteralSuffix(str, "ab"), "cmHasLiteralPrefix string not");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmStrToLong
+ {
+ long value;
+ assert_ok(cmStrToLong("1", &value) && value == 1,
+ "cmStrToLong parses a positive decimal integer.");
+ assert_ok(cmStrToLong(" 1", &value) && value == 1,
+ "cmStrToLong parses a decimal integer after whitespace.");
+
+ assert_ok(cmStrToLong("-1", &value) && value == -1,
+ "cmStrToLong parses a negative decimal integer.");
+ assert_ok(
+ cmStrToLong(" -1", &value) && value == -1,
+ "cmStrToLong parses a negative decimal integer after whitespace.");
+
+ assert_ok(!cmStrToLong("1x", &value),
+ "cmStrToLong rejects trailing content.");
+ }
+
+ // ----------------------------------------------------------------------
+ // Test cmStrToULong
+ {
+ unsigned long value;
+ assert_ok(cmStrToULong("1", &value) && value == 1,
+ "cmStrToULong parses a decimal integer.");
+ assert_ok(cmStrToULong(" 1", &value) && value == 1,
+ "cmStrToULong parses a decimal integer after whitespace.");
+ assert_ok(!cmStrToULong("-1", &value),
+ "cmStrToULong rejects a negative number.");
+ assert_ok(!cmStrToULong(" -1", &value),
+ "cmStrToULong rejects a negative number after whitespace.");
+ assert_ok(!cmStrToULong("1x", &value),
+ "cmStrToULong rejects trailing content.");
+ }
+
+ return failed;
+}
diff --git a/Tests/CMakeLib/testSystemTools.cxx b/Tests/CMakeLib/testSystemTools.cxx
index 0dfa326a3..92f5275cd 100644
--- a/Tests/CMakeLib/testSystemTools.cxx
+++ b/Tests/CMakeLib/testSystemTools.cxx
@@ -4,10 +4,11 @@
#include <cmConfigure.h> // IWYU pragma: keep
#include <iostream>
-#include <stddef.h>
#include <string>
#include <vector>
+#include <stddef.h>
+
#include "cmSystemTools.h"
#define cmPassed(m) std::cout << "Passed: " << (m) << "\n"
@@ -16,11 +17,13 @@
failed = 1
#define cmAssert(exp, m) \
- if ((exp)) { \
- cmPassed(m); \
- } else { \
- cmFailed(m); \
- }
+ do { \
+ if ((exp)) { \
+ cmPassed(m); \
+ } else { \
+ cmFailed(m); \
+ } \
+ } while (false)
int testSystemTools(int /*unused*/, char* /*unused*/ [])
{
@@ -52,7 +55,7 @@ int testSystemTools(int /*unused*/, char* /*unused*/ [])
cmAssert(cmSystemTools::strverscmp("99999999999999", "99999999999991") > 0,
"strverscmp natural overflow");
cmAssert(cmSystemTools::strverscmp("00000000000009", "00000000000001") > 0,
- "strverscmp deciaml precision");
+ "strverscmp decimal precision");
cmAssert(cmSystemTools::strverscmp("a.b.c.0", "a.b.c.000") > 0,
"strverscmp multiple zeros");
cmAssert(cmSystemTools::strverscmp("lib_1.2_10", "lib_1.2_2") > 0,
@@ -91,5 +94,6 @@ int testSystemTools(int /*unused*/, char* /*unused*/ [])
if (!failed) {
cmPassed("cmSystemTools::strverscmp working");
}
+
return failed;
}
diff --git a/Tests/CMakeLib/testUTF8.cxx b/Tests/CMakeLib/testUTF8.cxx
index fb5f3d815..986f5956e 100644
--- a/Tests/CMakeLib/testUTF8.cxx
+++ b/Tests/CMakeLib/testUTF8.cxx
@@ -1,15 +1,32 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#include <cm_utf8.h>
#include <stdio.h>
+#include <cm_utf8.h>
+
typedef char test_utf8_char[5];
static void test_utf8_char_print(test_utf8_char const c)
{
unsigned char const* d = reinterpret_cast<unsigned char const*>(c);
- printf("[0x%02X,0x%02X,0x%02X,0x%02X]", (int)d[0], (int)d[1], (int)d[2],
- (int)d[3]);
+ printf("[0x%02X,0x%02X,0x%02X,0x%02X]", static_cast<int>(d[0]),
+ static_cast<int>(d[1]), static_cast<int>(d[2]),
+ static_cast<int>(d[3]));
+}
+
+static void byte_array_print(char const* s)
+{
+ unsigned char const* d = reinterpret_cast<unsigned char const*>(s);
+ bool started = false;
+ printf("[");
+ for (; *d; ++d) {
+ if (started) {
+ printf(",");
+ }
+ started = true;
+ printf("0x%02X", static_cast<int>(*d));
+ }
+ printf("]");
}
struct test_utf8_entry
@@ -20,17 +37,36 @@ struct test_utf8_entry
};
static test_utf8_entry const good_entry[] = {
- { 1, "\x20\x00\x00\x00", 0x0020 }, /* Space. */
- { 2, "\xC2\xA9\x00\x00", 0x00A9 }, /* Copyright. */
- { 3, "\xE2\x80\x98\x00", 0x2018 }, /* Open-single-quote. */
- { 3, "\xE2\x80\x99\x00", 0x2019 }, /* Close-single-quote. */
- { 4, "\xF0\xA3\x8E\xB4", 0x233B4 }, /* Example from RFC 3629. */
+ { 1, "\x20\x00\x00\x00", 0x0020 }, /* Space. */
+ { 2, "\xC2\xA9\x00\x00", 0x00A9 }, /* Copyright. */
+ { 3, "\xE2\x80\x98\x00", 0x2018 }, /* Open-single-quote. */
+ { 3, "\xE2\x80\x99\x00", 0x2019 }, /* Close-single-quote. */
+ { 4, "\xF0\xA3\x8E\xB4", 0x233B4 }, /* Example from RFC 3629. */
+ { 3, "\xED\x80\x80\x00", 0xD000 }, /* Valid 0xED prefixed codepoint. */
+ { 4, "\xF4\x8F\xBF\xBF", 0x10FFFF }, /* Highest valid RFC codepoint. */
{ 0, { 0, 0, 0, 0, 0 }, 0 }
};
static test_utf8_char const bad_chars[] = {
- "\x80\x00\x00\x00", "\xC0\x00\x00\x00", "\xE0\x00\x00\x00",
- "\xE0\x80\x80\x00", "\xF0\x80\x80\x80", { 0, 0, 0, 0, 0 }
+ "\x80\x00\x00\x00", /* Leading continuation byte. */
+ "\xC0\x80\x00\x00", /* Overlong encoding. */
+ "\xC1\x80\x00\x00", /* Overlong encoding. */
+ "\xC2\x00\x00\x00", /* Missing continuation byte. */
+ "\xE0\x00\x00\x00", /* Missing continuation bytes. */
+ "\xE0\x80\x80\x00", /* Overlong encoding. */
+ "\xF0\x80\x80\x80", /* Overlong encoding. */
+ "\xED\xA0\x80\x00", /* UTF-16 surrogate half. */
+ "\xED\xBF\xBF\x00", /* UTF-16 surrogate half. */
+ "\xF4\x90\x80\x80", /* Lowest out-of-range codepoint. */
+ "\xF5\x80\x80\x80", /* Prefix forces out-of-range codepoints. */
+ { 0, 0, 0, 0, 0 }
+};
+
+static char const* good_strings[] = { "", "ASCII", "\xC2\xA9 Kitware", 0 };
+
+static char const* bad_strings[] = {
+ "\xC0\x80", /* Modified UTF-8 for embedded 0-byte. */
+ 0
};
static void report_good(bool passed, test_utf8_char const c)
@@ -86,6 +122,46 @@ static bool decode_bad(test_utf8_char const s)
return true;
}
+static void report_valid(bool passed, char const* s)
+{
+ printf("%s: validity good ", passed ? "pass" : "FAIL");
+ byte_array_print(s);
+ printf(" (%s) ", s);
+}
+
+static void report_invalid(bool passed, char const* s)
+{
+ printf("%s: validity bad ", passed ? "pass" : "FAIL");
+ byte_array_print(s);
+ printf(" ");
+}
+
+static bool is_valid(const char* s)
+{
+ bool valid = cm_utf8_is_valid(s) != 0;
+ if (!valid) {
+ report_valid(false, s);
+ printf("expected valid, reported as invalid\n");
+ return false;
+ }
+ report_valid(true, s);
+ printf("valid as expected\n");
+ return true;
+}
+
+static bool is_invalid(const char* s)
+{
+ bool valid = cm_utf8_is_valid(s) != 0;
+ if (valid) {
+ report_invalid(false, s);
+ printf("expected invalid, reported as valid\n");
+ return false;
+ }
+ report_invalid(true, s);
+ printf("invalid as expected\n");
+ return true;
+}
+
int testUTF8(int /*unused*/, char* /*unused*/ [])
{
int result = 0;
@@ -93,11 +169,27 @@ int testUTF8(int /*unused*/, char* /*unused*/ [])
if (!decode_good(*e)) {
result = 1;
}
+ if (!is_valid(e->str)) {
+ result = 1;
+ }
}
for (test_utf8_char const* c = bad_chars; (*c)[0]; ++c) {
if (!decode_bad(*c)) {
result = 1;
}
+ if (!is_invalid(*c)) {
+ result = 1;
+ }
+ }
+ for (char const** s = good_strings; *s; ++s) {
+ if (!is_valid(*s)) {
+ result = 1;
+ }
+ }
+ for (char const** s = bad_strings; *s; ++s) {
+ if (!is_invalid(*s)) {
+ result = 1;
+ }
}
return result;
}
diff --git a/Tests/CMakeLib/testUVProcessChain.cxx b/Tests/CMakeLib/testUVProcessChain.cxx
new file mode 100644
index 000000000..71a17647e
--- /dev/null
+++ b/Tests/CMakeLib/testUVProcessChain.cxx
@@ -0,0 +1,334 @@
+#include <algorithm>
+#include <csignal>
+#include <functional>
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include <cm/memory>
+
+#include "cm_uv.h"
+
+#include "cmGetPipes.h"
+#include "cmUVHandlePtr.h"
+#include "cmUVProcessChain.h"
+#include "cmUVStreambuf.h"
+
+struct ExpectedStatus
+{
+ bool Finished;
+ bool MatchExitStatus;
+ bool MatchTermSignal;
+ cmUVProcessChain::Status Status;
+};
+
+static const std::vector<ExpectedStatus> status1 = {
+ { false, false, false, { 0, 0 } },
+ { false, false, false, { 0, 0 } },
+ { false, false, false, { 0, 0 } },
+};
+
+static const std::vector<ExpectedStatus> status2 = {
+ { true, true, true, { 0, 0 } },
+ { false, false, false, { 0, 0 } },
+ { false, false, false, { 0, 0 } },
+};
+
+static const std::vector<ExpectedStatus> status3 = {
+ { true, true, true, { 0, 0 } },
+ { true, true, true, { 1, 0 } },
+#ifdef _WIN32
+ { true, true, true, { 2, 0 } },
+#else
+ { true, false, true, { 0, SIGABRT } },
+#endif
+};
+
+bool operator==(const cmUVProcessChain::Status* actual,
+ const ExpectedStatus& expected)
+{
+ if (!expected.Finished) {
+ return !actual;
+ } else if (!actual) {
+ return false;
+ }
+ if (expected.MatchExitStatus &&
+ expected.Status.ExitStatus != actual->ExitStatus) {
+ return false;
+ }
+ if (expected.MatchTermSignal &&
+ expected.Status.TermSignal != actual->TermSignal) {
+ return false;
+ }
+ return true;
+}
+
+bool resultsMatch(const std::vector<const cmUVProcessChain::Status*>& actual,
+ const std::vector<ExpectedStatus>& expected)
+{
+ return actual.size() == expected.size() &&
+ std::equal(actual.begin(), actual.end(), expected.begin());
+}
+
+std::string getInput(std::istream& input)
+{
+ char buffer[1024];
+ std::ostringstream str;
+ do {
+ input.read(buffer, 1024);
+ str.write(buffer, input.gcount());
+ } while (input.gcount() > 0);
+ return str.str();
+}
+
+template <typename T>
+std::function<std::ostream&(std::ostream&)> printExpected(bool match,
+ const T& value)
+{
+ return [match, value](std::ostream& stream) -> std::ostream& {
+ if (match) {
+ stream << value;
+ } else {
+ stream << "*";
+ }
+ return stream;
+ };
+}
+
+std::ostream& operator<<(
+ std::ostream& stream,
+ const std::function<std::ostream&(std::ostream&)>& func)
+{
+ return func(stream);
+}
+
+void printResults(const std::vector<const cmUVProcessChain::Status*>& actual,
+ const std::vector<ExpectedStatus>& expected)
+{
+ std::cout << "Expected: " << std::endl;
+ for (auto const& e : expected) {
+ if (e.Finished) {
+ std::cout << " ExitStatus: "
+ << printExpected(e.MatchExitStatus, e.Status.ExitStatus)
+ << ", TermSignal: "
+ << printExpected(e.MatchTermSignal, e.Status.TermSignal)
+ << std::endl;
+ } else {
+ std::cout << " null" << std::endl;
+ }
+ }
+ std::cout << "Actual:" << std::endl;
+ for (auto const& a : actual) {
+ if (a) {
+ std::cout << " ExitStatus: " << a->ExitStatus
+ << ", TermSignal: " << a->TermSignal << std::endl;
+ } else {
+ std::cout << " null" << std::endl;
+ }
+ }
+}
+
+bool checkExecution(cmUVProcessChainBuilder& builder,
+ std::unique_ptr<cmUVProcessChain>& chain)
+{
+ std::vector<const cmUVProcessChain::Status*> status;
+
+ chain = cm::make_unique<cmUVProcessChain>(builder.Start());
+ if (!chain->Valid()) {
+ std::cout << "Valid() returned false, should be true" << std::endl;
+ return false;
+ }
+ status = chain->GetStatus();
+ if (!resultsMatch(status, status1)) {
+ std::cout << "GetStatus() did not produce expected output" << std::endl;
+ printResults(status, status1);
+ return false;
+ }
+
+ if (chain->Wait(6000)) {
+ std::cout << "Wait() returned true, should be false" << std::endl;
+ return false;
+ }
+ status = chain->GetStatus();
+ if (!resultsMatch(status, status2)) {
+ std::cout << "GetStatus() did not produce expected output" << std::endl;
+ printResults(status, status2);
+ return false;
+ }
+
+ if (!chain->Wait()) {
+ std::cout << "Wait() returned false, should be true" << std::endl;
+ return false;
+ }
+ status = chain->GetStatus();
+ if (!resultsMatch(status, status3)) {
+ std::cout << "GetStatus() did not produce expected output" << std::endl;
+ printResults(status, status3);
+ return false;
+ }
+
+ return true;
+}
+
+bool checkOutput(std::istream& outputStream, std::istream& errorStream)
+{
+ std::string output = getInput(outputStream);
+ if (output != "HELO WRD!") {
+ std::cout << "Output was \"" << output << "\", expected \"HELO WRD!\""
+ << std::endl;
+ return false;
+ }
+
+ std::string error = getInput(errorStream);
+ if (error.length() != 3 || error.find('1') == std::string::npos ||
+ error.find('2') == std::string::npos ||
+ error.find('3') == std::string::npos) {
+ std::cout << "Error was \"" << error << "\", expected \"123\""
+ << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+bool testUVProcessChainBuiltin(const char* helperCommand)
+{
+ cmUVProcessChainBuilder builder;
+ std::unique_ptr<cmUVProcessChain> chain;
+ builder.AddCommand({ helperCommand, "echo" })
+ .AddCommand({ helperCommand, "capitalize" })
+ .AddCommand({ helperCommand, "dedup" })
+ .SetBuiltinStream(cmUVProcessChainBuilder::Stream_OUTPUT)
+ .SetBuiltinStream(cmUVProcessChainBuilder::Stream_ERROR);
+
+ if (!checkExecution(builder, chain)) {
+ return false;
+ }
+
+ if (!chain->OutputStream()) {
+ std::cout << "OutputStream() was null, expecting not null" << std::endl;
+ return false;
+ }
+ if (!chain->ErrorStream()) {
+ std::cout << "ErrorStream() was null, expecting not null" << std::endl;
+ return false;
+ }
+
+ if (!checkOutput(*chain->OutputStream(), *chain->ErrorStream())) {
+ return false;
+ }
+
+ return true;
+}
+
+bool testUVProcessChainExternal(const char* helperCommand)
+{
+ cmUVProcessChainBuilder builder;
+ std::unique_ptr<cmUVProcessChain> chain;
+ int outputPipe[2], errorPipe[2];
+ cm::uv_pipe_ptr outputInPipe, outputOutPipe, errorInPipe, errorOutPipe;
+
+ if (cmGetPipes(outputPipe) < 0) {
+ std::cout << "Error creating pipes" << std::endl;
+ return false;
+ }
+ if (cmGetPipes(errorPipe) < 0) {
+ std::cout << "Error creating pipes" << std::endl;
+ return false;
+ }
+
+ builder.AddCommand({ helperCommand, "echo" })
+ .AddCommand({ helperCommand, "capitalize" })
+ .AddCommand({ helperCommand, "dedup" })
+ .SetExternalStream(cmUVProcessChainBuilder::Stream_OUTPUT, outputPipe[1])
+ .SetExternalStream(cmUVProcessChainBuilder::Stream_ERROR, errorPipe[1]);
+
+ if (!checkExecution(builder, chain)) {
+ return false;
+ }
+
+ if (chain->OutputStream()) {
+ std::cout << "OutputStream() was not null, expecting null" << std::endl;
+ return false;
+ }
+ if (chain->ErrorStream()) {
+ std::cout << "ErrorStream() was not null, expecting null" << std::endl;
+ return false;
+ }
+
+ outputOutPipe.init(chain->GetLoop(), 0);
+ uv_pipe_open(outputOutPipe, outputPipe[1]);
+ outputOutPipe.reset();
+
+ errorOutPipe.init(chain->GetLoop(), 0);
+ uv_pipe_open(errorOutPipe, errorPipe[1]);
+ errorOutPipe.reset();
+
+ outputInPipe.init(chain->GetLoop(), 0);
+ uv_pipe_open(outputInPipe, outputPipe[0]);
+ cmUVStreambuf outputBuf;
+ outputBuf.open(outputInPipe);
+ std::istream outputStream(&outputBuf);
+
+ errorInPipe.init(chain->GetLoop(), 0);
+ uv_pipe_open(errorInPipe, errorPipe[0]);
+ cmUVStreambuf errorBuf;
+ errorBuf.open(errorInPipe);
+ std::istream errorStream(&errorBuf);
+
+ if (!checkOutput(outputStream, errorStream)) {
+ return false;
+ }
+
+ return true;
+}
+
+bool testUVProcessChainNone(const char* helperCommand)
+{
+ cmUVProcessChainBuilder builder;
+ std::unique_ptr<cmUVProcessChain> chain;
+ builder.AddCommand({ helperCommand, "echo" })
+ .AddCommand({ helperCommand, "capitalize" })
+ .AddCommand({ helperCommand, "dedup" });
+
+ if (!checkExecution(builder, chain)) {
+ return false;
+ }
+
+ if (chain->OutputStream()) {
+ std::cout << "OutputStream() was not null, expecting null" << std::endl;
+ return false;
+ }
+ if (chain->ErrorStream()) {
+ std::cout << "ErrorStream() was not null, expecting null" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+int testUVProcessChain(int argc, char** const argv)
+{
+ if (argc < 2) {
+ std::cout << "Invalid arguments.\n";
+ return -1;
+ }
+
+ if (!testUVProcessChainBuiltin(argv[1])) {
+ std::cout << "While executing testUVProcessChainBuiltin().\n";
+ return -1;
+ }
+
+ if (!testUVProcessChainExternal(argv[1])) {
+ std::cout << "While executing testUVProcessChainExternal().\n";
+ return -1;
+ }
+
+ if (!testUVProcessChainNone(argv[1])) {
+ std::cout << "While executing testUVProcessChainNone().\n";
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/Tests/CMakeLib/testUVProcessChainHelper.cxx b/Tests/CMakeLib/testUVProcessChainHelper.cxx
new file mode 100644
index 000000000..9c258342e
--- /dev/null
+++ b/Tests/CMakeLib/testUVProcessChainHelper.cxx
@@ -0,0 +1,72 @@
+#include <cctype>
+#include <chrono>
+#include <cstdlib>
+#include <iostream>
+#include <set>
+#include <sstream>
+#include <string>
+#include <thread>
+
+std::string getStdin()
+{
+ char buffer[1024];
+ std::ostringstream str;
+ do {
+ std::cin.read(buffer, 1024);
+ str.write(buffer, std::cin.gcount());
+ } while (std::cin.gcount() > 0);
+ return str.str();
+}
+
+int main(int argc, char** argv)
+{
+ if (argc < 2) {
+ return -1;
+ }
+
+ std::string command = argv[1];
+ if (command == "echo") {
+ std::this_thread::sleep_for(std::chrono::milliseconds(3000));
+ std::cout << "HELLO world!" << std::flush;
+ std::cerr << "1" << std::flush;
+ return 0;
+ }
+ if (command == "capitalize") {
+ std::this_thread::sleep_for(std::chrono::milliseconds(9000));
+ std::string input = getStdin();
+ for (auto& c : input) {
+ c = static_cast<char>(std::toupper(c));
+ }
+ std::cout << input << std::flush;
+ std::cerr << "2" << std::flush;
+ return 1;
+ }
+ if (command == "dedup") {
+ // Use a nested scope to free all resources before aborting below.
+ try {
+ std::string input = getStdin();
+ std::set<char> seen;
+ std::string output;
+ for (auto c : input) {
+ if (!seen.count(c)) {
+ seen.insert(c);
+ output += c;
+ }
+ }
+ std::cout << output << std::flush;
+ std::cerr << "3" << std::flush;
+ } catch (...) {
+ }
+
+ // On Windows, the exit code of abort() is different between debug and
+ // release builds, and does not yield a term_signal in libuv in either
+ // case. For the sake of simplicity, we just return another non-zero code.
+#ifdef _WIN32
+ return 2;
+#else
+ std::abort();
+#endif
+ }
+
+ return -1;
+}
diff --git a/Tests/CMakeLib/testUVRAII.cxx b/Tests/CMakeLib/testUVRAII.cxx
new file mode 100644
index 000000000..cb05ace15
--- /dev/null
+++ b/Tests/CMakeLib/testUVRAII.cxx
@@ -0,0 +1,230 @@
+#include <chrono>
+#include <iostream>
+#include <thread>
+#include <utility>
+
+#include "cm_uv.h"
+
+#include "cmUVHandlePtr.h"
+
+static void signal_reset_fn(uv_async_t* handle)
+{
+ auto ptr = static_cast<cm::uv_async_ptr*>(handle->data);
+ ptr->reset();
+}
+
+// A common pattern is to use an async signal to shutdown the server.
+static bool testAsyncShutdown()
+{
+ uv_loop_t Loop;
+ auto err = uv_loop_init(&Loop);
+ if (err != 0) {
+ std::cerr << "Could not init loop" << std::endl;
+ return false;
+ }
+
+ {
+ cm::uv_async_ptr signal;
+ signal.init(Loop, &signal_reset_fn, &signal);
+
+ std::thread([&] {
+ std::this_thread::sleep_for(std::chrono::seconds(2));
+ signal.send();
+ })
+ .detach();
+
+ if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) {
+ std::cerr << "Unclean exit state in testAsyncDtor" << std::endl;
+ return false;
+ }
+
+ if (signal.get()) {
+ std::cerr << "Loop exited with signal not being cleaned up" << std::endl;
+ return false;
+ }
+ }
+
+ uv_loop_close(&Loop);
+
+ return true;
+}
+
+static void signal_fn(uv_async_t*)
+{
+}
+
+// Async dtor is sort of a pain; since it locks a mutex we must be sure its
+// dtor always calls reset otherwise the mutex is deleted then locked.
+static bool testAsyncDtor()
+{
+ uv_loop_t Loop;
+ auto err = uv_loop_init(&Loop);
+ if (err != 0) {
+ std::cerr << "Could not init loop" << std::endl;
+ return false;
+ }
+
+ {
+ cm::uv_async_ptr signal;
+ signal.init(Loop, signal_fn);
+ }
+
+ if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) {
+ std::cerr << "Unclean exit state in testAsyncDtor" << std::endl;
+ return false;
+ }
+
+ uv_loop_close(&Loop);
+
+ return true;
+}
+
+// Async needs a relatively stateful deleter; make sure that is properly
+// accounted for and doesn't try to hold on to invalid state when it is
+// moved
+static bool testAsyncMove()
+{
+ uv_loop_t Loop;
+ auto err = uv_loop_init(&Loop);
+ if (err != 0) {
+ std::cerr << "Could not init loop" << std::endl;
+ return false;
+ }
+
+ {
+ cm::uv_async_ptr signal;
+ {
+ cm::uv_async_ptr signalTmp;
+ signalTmp.init(Loop, signal_fn);
+ signal = std::move(signalTmp);
+ }
+ }
+
+ if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) {
+ std::cerr << "Unclean exit state in testAsyncDtor" << std::endl;
+ return false;
+ }
+
+ uv_loop_close(&Loop);
+ return true;
+}
+
+// When a type is castable to another uv type (pipe -> stream) here,
+// and the deleter is convertible as well, we should allow moves from
+// one type to the other.
+static bool testCrossAssignment()
+{
+ uv_loop_t Loop;
+ auto err = uv_loop_init(&Loop);
+ if (err != 0) {
+ std::cerr << "Could not init loop" << std::endl;
+ return false;
+ }
+
+ {
+ cm::uv_pipe_ptr pipe;
+ pipe.init(Loop, 0);
+
+ cm::uv_stream_ptr stream = std::move(pipe);
+ if (pipe.get()) {
+ std::cerr << "Move should be sure to invalidate the previous ptr"
+ << std::endl;
+ return false;
+ }
+ cm::uv_handle_ptr handle = std::move(stream);
+ if (stream.get()) {
+ std::cerr << "Move should be sure to invalidate the previous ptr"
+ << std::endl;
+ return false;
+ }
+ }
+
+ if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) {
+ std::cerr << "Unclean exit state in testCrossAssignment" << std::endl;
+ return false;
+ }
+
+ uv_loop_close(&Loop);
+ return true;
+}
+
+// This test can't fail at run time; but this makes sure we have all our move
+// ctors created correctly.
+static bool testAllMoves()
+{
+ using namespace cm;
+ struct allTypes
+ {
+ uv_stream_ptr _7;
+ uv_timer_ptr _8;
+ uv_tty_ptr _9;
+ uv_process_ptr _11;
+ uv_pipe_ptr _12;
+ uv_async_ptr _13;
+ uv_signal_ptr _14;
+ uv_handle_ptr _15;
+ };
+
+ allTypes a;
+ allTypes b(std::move(a));
+ allTypes c = std::move(b);
+ return true;
+};
+
+static bool testLoopReset()
+{
+ bool closed = false;
+ cm::uv_loop_ptr loop;
+ loop.init();
+
+ uv_timer_t timer;
+ uv_timer_init(loop, &timer);
+ timer.data = &closed;
+ uv_close(reinterpret_cast<uv_handle_t*>(&timer), [](uv_handle_t* handle) {
+ auto closedPtr = static_cast<bool*>(handle->data);
+ *closedPtr = true;
+ });
+
+ loop.reset();
+ if (!closed) {
+ std::cerr << "uv_loop_ptr did not finish" << std::endl;
+ return false;
+ }
+
+ return true;
+};
+
+static bool testLoopDestructor()
+{
+ bool closed = false;
+
+ uv_timer_t timer;
+ {
+ cm::uv_loop_ptr loop;
+ loop.init();
+
+ uv_timer_init(loop, &timer);
+ timer.data = &closed;
+ uv_close(reinterpret_cast<uv_handle_t*>(&timer), [](uv_handle_t* handle) {
+ auto closedPtr = static_cast<bool*>(handle->data);
+ *closedPtr = true;
+ });
+ }
+
+ if (!closed) {
+ std::cerr << "uv_loop_ptr did not finish" << std::endl;
+ return false;
+ }
+
+ return true;
+};
+
+int testUVRAII(int, char** const)
+{
+ if ((testAsyncShutdown() &&
+ testAsyncDtor() & testAsyncMove() & testCrossAssignment() &
+ testAllMoves() & testLoopReset() & testLoopDestructor()) == 0) {
+ return -1;
+ }
+ return 0;
+}
diff --git a/Tests/CMakeLib/testUVStreambuf.cxx b/Tests/CMakeLib/testUVStreambuf.cxx
new file mode 100644
index 000000000..cd9c9d4fa
--- /dev/null
+++ b/Tests/CMakeLib/testUVStreambuf.cxx
@@ -0,0 +1,455 @@
+#include <cstring>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include <stdint.h>
+
+#include "cm_uv.h"
+
+#include "cmGetPipes.h"
+#include "cmUVHandlePtr.h"
+#include "cmUVStreambuf.h"
+
+#define TEST_STR_LINE_1 "This string must be exactly 128 characters long so"
+#define TEST_STR_LINE_2 "that we can test CMake's std::streambuf integration"
+#define TEST_STR_LINE_3 "with libuv's uv_stream_t."
+#define TEST_STR TEST_STR_LINE_1 "\n" TEST_STR_LINE_2 "\n" TEST_STR_LINE_3
+
+bool writeDataToStreamPipe(uv_loop_t& loop, cm::uv_pipe_ptr& inputPipe,
+ char* outputData, unsigned int outputDataLength,
+ const char* /* unused */)
+{
+ int err;
+
+ // Create the pipe
+ int pipeHandles[2];
+ if (cmGetPipes(pipeHandles) < 0) {
+ std::cout << "Could not open pipe" << std::endl;
+ return false;
+ }
+
+ cm::uv_pipe_ptr outputPipe;
+ inputPipe.init(loop, 0);
+ outputPipe.init(loop, 0);
+ uv_pipe_open(inputPipe, pipeHandles[0]);
+ uv_pipe_open(outputPipe, pipeHandles[1]);
+
+ // Write data for reading
+ uv_write_t writeReq;
+ struct WriteCallbackData
+ {
+ bool Finished = false;
+ int Status;
+ } writeData;
+ writeReq.data = &writeData;
+ uv_buf_t outputBuf;
+ outputBuf.base = outputData;
+ outputBuf.len = outputDataLength;
+ if ((err = uv_write(&writeReq, outputPipe, &outputBuf, 1,
+ [](uv_write_t* req, int status) {
+ auto data = static_cast<WriteCallbackData*>(req->data);
+ data->Finished = true;
+ data->Status = status;
+ })) < 0) {
+ std::cout << "Could not write to pipe: " << uv_strerror(err) << std::endl;
+ return false;
+ }
+ while (!writeData.Finished) {
+ uv_run(&loop, UV_RUN_ONCE);
+ }
+ if (writeData.Status < 0) {
+ std::cout << "Status is " << uv_strerror(writeData.Status)
+ << ", should be 0" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+bool writeDataToStreamProcess(uv_loop_t& loop, cm::uv_pipe_ptr& inputPipe,
+ char* outputData, unsigned int /* unused */,
+ const char* cmakeCommand)
+{
+ int err;
+
+ inputPipe.init(loop, 0);
+ std::vector<std::string> arguments = { cmakeCommand, "-E", "echo_append",
+ outputData };
+ std::vector<const char*> processArgs;
+ for (auto const& arg : arguments) {
+ processArgs.push_back(arg.c_str());
+ }
+ processArgs.push_back(nullptr);
+ std::vector<uv_stdio_container_t> stdio(3);
+ stdio[0].flags = UV_IGNORE;
+ stdio[0].data.stream = nullptr;
+ stdio[1].flags =
+ static_cast<uv_stdio_flags>(UV_CREATE_PIPE | UV_WRITABLE_PIPE);
+ stdio[1].data.stream = inputPipe;
+ stdio[2].flags = UV_IGNORE;
+ stdio[2].data.stream = nullptr;
+
+ struct ProcessExitData
+ {
+ bool Finished = false;
+ int64_t ExitStatus;
+ int TermSignal;
+ } exitData;
+ cm::uv_process_ptr process;
+ auto options = uv_process_options_t();
+ options.file = cmakeCommand;
+ options.args = const_cast<char**>(processArgs.data());
+ options.flags = UV_PROCESS_WINDOWS_HIDE;
+ options.stdio = stdio.data();
+ options.stdio_count = static_cast<int>(stdio.size());
+ options.exit_cb = [](uv_process_t* handle, int64_t exitStatus,
+ int termSignal) {
+ auto data = static_cast<ProcessExitData*>(handle->data);
+ data->Finished = true;
+ data->ExitStatus = exitStatus;
+ data->TermSignal = termSignal;
+ };
+ if ((err = process.spawn(loop, options, &exitData)) < 0) {
+ std::cout << "Could not spawn process: " << uv_strerror(err) << std::endl;
+ return false;
+ }
+ while (!exitData.Finished) {
+ uv_run(&loop, UV_RUN_ONCE);
+ }
+ if (exitData.ExitStatus != 0) {
+ std::cout << "Process exit status is " << exitData.ExitStatus
+ << ", should be 0" << std::endl;
+ return false;
+ }
+ if (exitData.TermSignal != 0) {
+ std::cout << "Process term signal is " << exitData.TermSignal
+ << ", should be 0" << std::endl;
+ return false;
+ }
+
+ return true;
+}
+
+bool testUVStreambufRead(
+ bool (*cb)(uv_loop_t& loop, cm::uv_pipe_ptr& inputPipe, char* outputData,
+ unsigned int outputDataLength, const char* cmakeCommand),
+ const char* cmakeCommand)
+{
+ char outputData[] = TEST_STR;
+ bool success = false;
+ cm::uv_loop_ptr loop;
+ loop.init();
+ cm::uv_pipe_ptr inputPipe;
+ std::vector<char> inputData(128);
+ std::streamsize readLen;
+ std::string line;
+ cm::uv_timer_ptr timer;
+
+ // Create the streambuf
+ cmUVStreambuf inputBuf(64);
+ std::istream inputStream(&inputBuf);
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform first read test - read all the data
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 128) {
+ std::cout << "sgetn() returned " << readLen << ", should be 128"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if (std::memcmp(inputData.data(), outputData, 128)) {
+ std::cout << "Read data does not match write data" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ inputData.assign(128, char{});
+ inputBuf.close();
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform second read test - read some data and then close
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 64)) != 64) {
+ std::cout << "sgetn() returned " << readLen << ", should be 64"
+ << std::endl;
+ goto end;
+ }
+ if (std::memcmp(inputData.data(), outputData, 64)) {
+ std::cout << "Read data does not match write data" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 8) {
+ std::cout << "in_avail() returned " << readLen << ", should be 8"
+ << std::endl;
+ goto end;
+ }
+ inputData.assign(128, char{});
+ inputBuf.close();
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform third read test - read line by line
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ if (!std::getline(inputStream, line)) {
+ std::cout << "getline returned false, should be true" << std::endl;
+ goto end;
+ }
+ if (line != TEST_STR_LINE_1) {
+ std::cout << "Line 1 is \"" << line
+ << "\", should be \"" TEST_STR_LINE_1 "\"" << std::endl;
+ goto end;
+ }
+
+ if (!std::getline(inputStream, line)) {
+ std::cout << "getline returned false, should be true" << std::endl;
+ goto end;
+ }
+ if (line != TEST_STR_LINE_2) {
+ std::cout << "Line 2 is \"" << line
+ << "\", should be \"" TEST_STR_LINE_2 "\"" << std::endl;
+ goto end;
+ }
+
+ if (!std::getline(inputStream, line)) {
+ std::cout << "getline returned false, should be true" << std::endl;
+ goto end;
+ }
+ if (line != TEST_STR_LINE_3) {
+ std::cout << "Line 3 is \"" << line
+ << "\", should be \"" TEST_STR_LINE_3 "\"" << std::endl;
+ goto end;
+ }
+
+ if (std::getline(inputStream, line)) {
+ std::cout << "getline returned true, should be false" << std::endl;
+ goto end;
+ }
+
+ inputBuf.close();
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform fourth read test - run the event loop outside of underflow()
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ uv_run(loop, UV_RUN_DEFAULT);
+ if ((readLen = inputBuf.in_avail()) != 72) {
+ std::cout << "in_avail() returned " << readLen << ", should be 72"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 128) {
+ std::cout << "sgetn() returned " << readLen << ", should be 128"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 128"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+
+ inputBuf.close();
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ // Perform fifth read test - close the streambuf in the middle of a read
+ timer.init(*loop, &inputBuf);
+ if (!cb(*loop, inputPipe, outputData, 128, cmakeCommand)) {
+ goto end;
+ }
+ inputBuf.open(inputPipe);
+ if (!inputBuf.is_open()) {
+ std::cout << "is_open() is false, should be true" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != 0) {
+ std::cout << "in_avail() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ uv_timer_start(timer,
+ [](uv_timer_t* handle) {
+ auto buf = static_cast<cmUVStreambuf*>(handle->data);
+ buf->close();
+ },
+ 0, 0);
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+ if (inputBuf.is_open()) {
+ std::cout << "is_open() is true, should be false" << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.in_avail()) != -1) {
+ std::cout << "in_avail() returned " << readLen << ", should be -1"
+ << std::endl;
+ goto end;
+ }
+ if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) {
+ std::cout << "sgetn() returned " << readLen << ", should be 0"
+ << std::endl;
+ goto end;
+ }
+
+ success = true;
+
+end:
+ return success;
+}
+
+int testUVStreambuf(int argc, char** const argv)
+{
+ if (argc < 2) {
+ std::cout << "Invalid arguments.\n";
+ return -1;
+ }
+
+ if (!testUVStreambufRead(writeDataToStreamPipe, argv[1])) {
+ std::cout << "While executing testUVStreambufRead() with pipe.\n";
+ return -1;
+ }
+
+ if (!testUVStreambufRead(writeDataToStreamProcess, argv[1])) {
+ std::cout << "While executing testUVStreambufRead() with process.\n";
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser.cxx b/Tests/CMakeLib/testVisualStudioSlnParser.cxx
index f8bcfae85..3c069600c 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser.cxx
+++ b/Tests/CMakeLib/testVisualStudioSlnParser.cxx
@@ -1,10 +1,10 @@
#include "testVisualStudioSlnParser.h"
+#include <iostream>
+
#include "cmVisualStudioSlnData.h"
#include "cmVisualStudioSlnParser.h"
-#include <iostream>
-
static bool parsedRight(cmVisualStudioSlnParser& parser,
const std::string& file, cmSlnData& data,
cmVisualStudioSlnParser::ParseResult expected =
@@ -45,17 +45,55 @@ int testVisualStudioSlnParser(int, char* [])
}
const std::vector<cmSlnProjectEntry>& projects = data.GetProjects();
const char* const names[] = {
- "3rdParty", "ALL_BUILD", "CMakeLib", "CMakeLibTests",
- "CMakePredefinedTargets", "CPackLib", "CTestDashboardTargets",
- "CTestLib", "Continuous", "Documentation", "Experimental", "INSTALL",
- "KWSys", "LIBCURL", "Nightly", "NightlyMemoryCheck", "PACKAGE",
- "RUN_TESTS", "Tests", "Utilities", "Win9xCompat", "ZERO_CHECK",
- "cmIML_test", "cmake", "cmbzip2", "cmcldeps", "cmcompress", "cmcurl",
- "cmexpat", "cmlibarchive", "cmsys", "cmsysEncodeExecutable",
- "cmsysProcessFwd9x", "cmsysTestDynload", "cmsysTestProcess",
- "cmsysTestSharedForward", "cmsysTestsC", "cmsysTestsCxx", "cmsys_c",
- "cmw9xcom", "cmzlib", "cpack", "ctest", "documentation", "memcheck_fail",
- "pseudo_BC", "pseudo_purify", "pseudo_valgrind", "test_clean",
+ "3rdParty",
+ "ALL_BUILD",
+ "CMakeLib",
+ "CMakeLibTests",
+ "CMakePredefinedTargets",
+ "CPackLib",
+ "CTestDashboardTargets",
+ "CTestLib",
+ "Continuous",
+ "Documentation",
+ "Experimental",
+ "INSTALL",
+ "KWSys",
+ "LIBCURL",
+ "Nightly",
+ "NightlyMemoryCheck",
+ "PACKAGE",
+ "RUN_TESTS",
+ "Tests",
+ "Utilities",
+ "Win9xCompat",
+ "ZERO_CHECK",
+ "cmIML_test",
+ "cmake",
+ "cmbzip2",
+ "cmcldeps",
+ "cmcompress",
+ "cmcurl",
+ "cmexpat",
+ "cmlibarchive",
+ "cmsys",
+ "cmsysEncodeExecutable",
+ "cmsysProcessFwd9x",
+ "cmsysTestDynload",
+ "cmsysTestProcess",
+ "cmsysTestSharedForward",
+ "cmsysTestsC",
+ "cmsysTestsCxx",
+ "cmsys_c",
+ "cmw9xcom",
+ "cmzlib",
+ "cpack",
+ "ctest",
+ "documentation",
+ "memcheck_fail",
+ "pseudo_BC",
+ "pseudo_purify",
+ "pseudo_valgrind",
+ "test_clean",
"uninstall"
/* clang-format needs this comment to break after the opening brace */
};
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/.gitattributes b/Tests/CMakeLib/testVisualStudioSlnParser_data/.gitattributes
index 5be3dc5bc..08b4ac4c8 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/.gitattributes
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/.gitattributes
@@ -1 +1 @@
-*.sln-file -crlf whitespace=cr-at-eol
+*.sln-file eol=crlf
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/bom.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/bom.sln-file
index 52c2483f4..f8c432f1c 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/bom.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/bom.sln-file
@@ -1,2 +1,2 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-data.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-data.sln-file
index bd66ed41d..465604691 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-data.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-data.sln-file
@@ -1,6 +1,6 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
-EndProject
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-global.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-global.sln-file
index 32176b882..d65d82a79 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-global.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-global.sln-file
@@ -1,9 +1,9 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Global
-EndGlobalSection
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Global
+EndGlobalSection
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-header.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-header.sln-file
index f838a7112..cc6d1b89f 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-header.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-header.sln-file
@@ -1,4 +1,4 @@
-Microsoft Visual Studio Solution2 File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
-EndProject
+Microsoft Visual Studio Solution2 File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectArgs.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectArgs.sln-file
index 3e8d35a4f..31ed7b8f1 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectArgs.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectArgs.sln-file
@@ -1,4 +1,4 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj"
-EndProject
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj"
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectContents.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectContents.sln-file
index e0d58c92b..a2eb7baef 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectContents.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectContents.sln-file
@@ -1,6 +1,6 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
- Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous2", "Continuous2.vcxproj", "{E5071091-DBFB-49E2-AF0F-E8B0FDEF6C89}"
- EndProject
-EndProject
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous2", "Continuous2.vcxproj", "{E5071091-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+ EndProject
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectSection.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectSection.sln-file
index ed0aa0259..8688e7515 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectSection.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-projectSection.sln-file
@@ -1,11 +1,11 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "ZERO_CHECK.vcxproj", "{90BC31D7-A3E8-4F04-8049-2236C239A044}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProject
-EndProject
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "ZERO_CHECK.vcxproj", "{90BC31D7-A3E8-4F04-8049-2236C239A044}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProject
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayParen.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayParen.sln-file
index d2bb9e3e5..f2a3ea14f 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayParen.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayParen.sln-file
@@ -1,4 +1,4 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}" = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
-EndProject
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}" = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote.sln-file
index 3c1a2ecca..b91dae36e 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote.sln-file
@@ -1,4 +1,4 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}
-EndProject
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote2.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote2.sln-file
index db8bbcf2c..1d01fda21 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote2.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-strayQuote2.sln-file
@@ -1,4 +1,4 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}) = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
-EndProject
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}) = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+EndProject
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-topLevel.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-topLevel.sln-file
index 1727bf378..c4069747e 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-topLevel.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-topLevel.sln-file
@@ -1,4 +1,4 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-GlobalSection(ExtensibilityGlobals) = postSolution
-EndGlobalSection
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+GlobalSection(ExtensibilityGlobals) = postSolution
+EndGlobalSection
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-unclosed.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-unclosed.sln-file
index 4e6909ef5..d814bf442 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-unclosed.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/err-structure-unclosed.sln-file
@@ -1,5 +1,5 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Global
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Global
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/nobom.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/nobom.sln-file
index fc1e4e947..8168b6b36 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/nobom.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/nobom.sln-file
@@ -1,2 +1,2 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
diff --git a/Tests/CMakeLib/testVisualStudioSlnParser_data/valid.sln-file b/Tests/CMakeLib/testVisualStudioSlnParser_data/valid.sln-file
index 7ba28a2f6..395b953d8 100644
--- a/Tests/CMakeLib/testVisualStudioSlnParser_data/valid.sln-file
+++ b/Tests/CMakeLib/testVisualStudioSlnParser_data/valid.sln-file
@@ -1,680 +1,680 @@
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ALL_BUILD", "ALL_BUILD.vcxproj", "{BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}"
- ProjectSection(ProjectDependencies) = postProject
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
- {B025BD09-8389-4D9F-9150-F33418A664B1} = {B025BD09-8389-4D9F-9150-F33418A664B1}
- {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8} = {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}
- {1002C8FC-7242-4A69-AF51-C59BB10BA6D8} = {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}
- {0283B293-0067-4D02-ADA6-892704398F48} = {0283B293-0067-4D02-ADA6-892704398F48}
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B} = {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}
- {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8} = {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
- {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84} = {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
- {4810B052-899E-4CA5-A0BC-2E383F8AEFAE} = {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}
- {29D5FCAF-20D0-4DEF-8529-F035C249E996} = {29D5FCAF-20D0-4DEF-8529-F035C249E996}
- {A0421DCA-AC3E-42D0-94AC-379A21A1E591} = {A0421DCA-AC3E-42D0-94AC-379A21A1E591}
- {C6AF7E57-CE57-4462-AE1D-BF520701480E} = {C6AF7E57-CE57-4462-AE1D-BF520701480E}
- {F2CAAAB3-9568-4284-B8E3-13955183A6D7} = {F2CAAAB3-9568-4284-B8E3-13955183A6D7}
- {D8294E4A-03C5-43D7-AE35-15603F502DC0} = {D8294E4A-03C5-43D7-AE35-15603F502DC0}
- {A4921D15-411F-436A-B6F3-F8381652A8E1} = {A4921D15-411F-436A-B6F3-F8381652A8E1}
- {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}
- {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C} = {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
- {0E9E295F-3854-415B-AE9F-7B62F17932F5} = {0E9E295F-3854-415B-AE9F-7B62F17932F5}
- {4BFA4D7C-C6F7-4270-9E87-B922DCE05644} = {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}
- {F77AD922-B4BC-43D7-B268-865312085495} = {F77AD922-B4BC-43D7-B268-865312085495}
- {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88} = {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}
- {1DFA0599-77CC-4768-B47A-107EEE86C20C} = {1DFA0599-77CC-4768-B47A-107EEE86C20C}
- {0E45A3EF-8636-46CF-94A3-7B5CE875DE48} = {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}
- {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C} = {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CMakeLib", "Source\CMakeLib.vcxproj", "{59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CMakeLibTests", "Tests\CMakeLib\CMakeLibTests.vcxproj", "{B025BD09-8389-4D9F-9150-F33418A664B1}"
- ProjectSection(ProjectDependencies) = postProject
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CPackLib", "Source\CPackLib.vcxproj", "{94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}"
- ProjectSection(ProjectDependencies) = postProject
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CTestLib", "Source\CTestLib.vcxproj", "{1002C8FC-7242-4A69-AF51-C59BB10BA6D8}"
- ProjectSection(ProjectDependencies) = postProject
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Experimental", "Experimental.vcxproj", "{B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INSTALL", "INSTALL.vcxproj", "{3B126B2D-DEAA-4CDF-9F44-28D3600F5754}"
- ProjectSection(ProjectDependencies) = postProject
- {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C} = {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LIBCURL", "Utilities\cmcurl\LIBCURL.vcxproj", "{0283B293-0067-4D02-ADA6-892704398F48}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Nightly", "Nightly.vcxproj", "{7BAF09E0-DCD4-4567-9486-79E1E5F18333}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NightlyMemoryCheck", "NightlyMemoryCheck.vcxproj", "{D0413FDA-31C5-41C2-A53A-C1B87061EC96}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PACKAGE", "PACKAGE.vcxproj", "{4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}"
- ProjectSection(ProjectDependencies) = postProject
- {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C} = {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RUN_TESTS", "RUN_TESTS.vcxproj", "{D87B08A8-638E-43FA-96C2-404B41363D3B}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "ZERO_CHECK.vcxproj", "{90BC31D7-A3E8-4F04-8049-2236C239A044}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmIML_test", "Utilities\KWIML\test\cmIML_test.vcxproj", "{48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmake", "Source\cmake.vcxproj", "{6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}"
- ProjectSection(ProjectDependencies) = postProject
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmbzip2", "Utilities\cmbzip2\cmbzip2.vcxproj", "{1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmcldeps", "Source\cmcldeps.vcxproj", "{A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}"
- ProjectSection(ProjectDependencies) = postProject
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmcompress", "Utilities\cmcompress\cmcompress.vcxproj", "{561AD1BB-6DD3-466D-B270-3696DEE8C26C}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmcurl", "Utilities\cmcurl\cmcurl.vcxproj", "{1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmexpat", "Utilities\cmexpat\cmexpat.vcxproj", "{459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmlibarchive", "Utilities\cmlibarchive\libarchive\cmlibarchive.vcxproj", "{25A91A7A-9C4E-420C-98BD-2D1F0165DA54}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsys", "Source\kwsys\cmsys.vcxproj", "{BDB424DC-15B3-4A06-A1E2-3D61380F359F}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {4810B052-899E-4CA5-A0BC-2E383F8AEFAE} = {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}
- {29D5FCAF-20D0-4DEF-8529-F035C249E996} = {29D5FCAF-20D0-4DEF-8529-F035C249E996}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysEncodeExecutable", "Source\kwsys\cmsysEncodeExecutable.vcxproj", "{4810B052-899E-4CA5-A0BC-2E383F8AEFAE}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysProcessFwd9x", "Source\kwsys\cmsysProcessFwd9x.vcxproj", "{29D5FCAF-20D0-4DEF-8529-F035C249E996}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestDynload", "Source\kwsys\cmsysTestDynload.vcxproj", "{A0421DCA-AC3E-42D0-94AC-379A21A1E591}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestProcess", "Source\kwsys\cmsysTestProcess.vcxproj", "{C6AF7E57-CE57-4462-AE1D-BF520701480E}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestSharedForward", "Source\kwsys\cmsysTestSharedForward.vcxproj", "{F2CAAAB3-9568-4284-B8E3-13955183A6D7}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestsC", "Source\kwsys\cmsysTestsC.vcxproj", "{D8294E4A-03C5-43D7-AE35-15603F502DC0}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestsCxx", "Source\kwsys\cmsysTestsCxx.vcxproj", "{A4921D15-411F-436A-B6F3-F8381652A8E1}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsys_c", "Source\kwsys\cmsys_c.vcxproj", "{60BEB3AF-B4EF-4363-8747-C40177BC2D9C}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {4810B052-899E-4CA5-A0BC-2E383F8AEFAE} = {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}
- {29D5FCAF-20D0-4DEF-8529-F035C249E996} = {29D5FCAF-20D0-4DEF-8529-F035C249E996}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmw9xcom", "Source\cmw9xcom.vcxproj", "{ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}"
- ProjectSection(ProjectDependencies) = postProject
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmzlib", "Utilities\cmzlib\cmzlib.vcxproj", "{0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpack", "Source\cpack.vcxproj", "{0E9E295F-3854-415B-AE9F-7B62F17932F5}"
- ProjectSection(ProjectDependencies) = postProject
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
- {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8} = {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ctest", "Source\ctest.vcxproj", "{4BFA4D7C-C6F7-4270-9E87-B922DCE05644}"
- ProjectSection(ProjectDependencies) = postProject
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
- {1002C8FC-7242-4A69-AF51-C59BB10BA6D8} = {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "documentation", "Utilities\documentation.vcxproj", "{F77AD922-B4BC-43D7-B268-865312085495}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8} = {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}
- {0E9E295F-3854-415B-AE9F-7B62F17932F5} = {0E9E295F-3854-415B-AE9F-7B62F17932F5}
- {4BFA4D7C-C6F7-4270-9E87-B922DCE05644} = {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memcheck_fail", "Tests\CTestTestMemcheck\memcheck_fail.vcxproj", "{8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pseudo_BC", "Tests\CTestTestMemcheck\pseudo_BC.vcxproj", "{1DFA0599-77CC-4768-B47A-107EEE86C20C}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pseudo_purify", "Tests\CTestTestMemcheck\pseudo_purify.vcxproj", "{0E45A3EF-8636-46CF-94A3-7B5CE875DE48}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pseudo_valgrind", "Tests\CTestTestMemcheck\pseudo_valgrind.vcxproj", "{CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_clean", "Tests\test_clean.vcxproj", "{02D16A66-6D59-4A0E-ABB3-BD12926934FE}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uninstall", "uninstall.vcxproj", "{B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}"
- ProjectSection(ProjectDependencies) = postProject
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
- EndProjectSection
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CMakePredefinedTargets", "CMakePredefinedTargets", "{31CE49D7-85CA-41E2-83D2-CC6962519DB6}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CTestDashboardTargets", "CTestDashboardTargets", "{BD073C58-BAED-420E-80EA-DC9F52E21AF7}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{8ECAB3CD-B434-426B-B63A-115919D393BC}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{964DC7DE-990A-4CA4-8395-10D9F9CB2A23}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{7E002D15-21D1-4927-B486-82E496444441}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3rdParty", "Utilities\3rdParty", "{0984A63C-130E-4B62-9A94-AAC28A88C137}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "KWSys", "Utilities\KWSys", "{EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Win9xCompat", "Utilities\Win9xCompat", "{2485E202-B981-41E0-98CA-CF363437A4E4}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Release|x64 = Release|x64
- MinSizeRel|x64 = MinSizeRel|x64
- RelWithDebInfo|x64 = RelWithDebInfo|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.Debug|x64.ActiveCfg = Debug|x64
- {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.Debug|x64.Build.0 = Debug|x64
- {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.Release|x64.ActiveCfg = Release|x64
- {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.Release|x64.Build.0 = Release|x64
- {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.Debug|x64.ActiveCfg = Debug|x64
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.Debug|x64.Build.0 = Debug|x64
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.Release|x64.ActiveCfg = Release|x64
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.Release|x64.Build.0 = Release|x64
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {B025BD09-8389-4D9F-9150-F33418A664B1}.Debug|x64.ActiveCfg = Debug|x64
- {B025BD09-8389-4D9F-9150-F33418A664B1}.Debug|x64.Build.0 = Debug|x64
- {B025BD09-8389-4D9F-9150-F33418A664B1}.Release|x64.ActiveCfg = Release|x64
- {B025BD09-8389-4D9F-9150-F33418A664B1}.Release|x64.Build.0 = Release|x64
- {B025BD09-8389-4D9F-9150-F33418A664B1}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {B025BD09-8389-4D9F-9150-F33418A664B1}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {B025BD09-8389-4D9F-9150-F33418A664B1}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {B025BD09-8389-4D9F-9150-F33418A664B1}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.Debug|x64.ActiveCfg = Debug|x64
- {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.Debug|x64.Build.0 = Debug|x64
- {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.Release|x64.ActiveCfg = Release|x64
- {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.Release|x64.Build.0 = Release|x64
- {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.Debug|x64.ActiveCfg = Debug|x64
- {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.Debug|x64.Build.0 = Debug|x64
- {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.Release|x64.ActiveCfg = Release|x64
- {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.Release|x64.Build.0 = Release|x64
- {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}.Debug|x64.ActiveCfg = Debug|x64
- {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}.Release|x64.ActiveCfg = Release|x64
- {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}.Debug|x64.ActiveCfg = Debug|x64
- {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}.Release|x64.ActiveCfg = Release|x64
- {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {3B126B2D-DEAA-4CDF-9F44-28D3600F5754}.Debug|x64.ActiveCfg = Debug|x64
- {3B126B2D-DEAA-4CDF-9F44-28D3600F5754}.Release|x64.ActiveCfg = Release|x64
- {3B126B2D-DEAA-4CDF-9F44-28D3600F5754}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {3B126B2D-DEAA-4CDF-9F44-28D3600F5754}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {0283B293-0067-4D02-ADA6-892704398F48}.Debug|x64.ActiveCfg = Debug|x64
- {0283B293-0067-4D02-ADA6-892704398F48}.Debug|x64.Build.0 = Debug|x64
- {0283B293-0067-4D02-ADA6-892704398F48}.Release|x64.ActiveCfg = Release|x64
- {0283B293-0067-4D02-ADA6-892704398F48}.Release|x64.Build.0 = Release|x64
- {0283B293-0067-4D02-ADA6-892704398F48}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {0283B293-0067-4D02-ADA6-892704398F48}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {0283B293-0067-4D02-ADA6-892704398F48}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {0283B293-0067-4D02-ADA6-892704398F48}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {7BAF09E0-DCD4-4567-9486-79E1E5F18333}.Debug|x64.ActiveCfg = Debug|x64
- {7BAF09E0-DCD4-4567-9486-79E1E5F18333}.Release|x64.ActiveCfg = Release|x64
- {7BAF09E0-DCD4-4567-9486-79E1E5F18333}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {7BAF09E0-DCD4-4567-9486-79E1E5F18333}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {D0413FDA-31C5-41C2-A53A-C1B87061EC96}.Debug|x64.ActiveCfg = Debug|x64
- {D0413FDA-31C5-41C2-A53A-C1B87061EC96}.Release|x64.ActiveCfg = Release|x64
- {D0413FDA-31C5-41C2-A53A-C1B87061EC96}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {D0413FDA-31C5-41C2-A53A-C1B87061EC96}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}.Debug|x64.ActiveCfg = Debug|x64
- {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}.Release|x64.ActiveCfg = Release|x64
- {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {D87B08A8-638E-43FA-96C2-404B41363D3B}.Debug|x64.ActiveCfg = Debug|x64
- {D87B08A8-638E-43FA-96C2-404B41363D3B}.Release|x64.ActiveCfg = Release|x64
- {D87B08A8-638E-43FA-96C2-404B41363D3B}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {D87B08A8-638E-43FA-96C2-404B41363D3B}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {90BC31D7-A3E8-4F04-8049-2236C239A044}.Debug|x64.ActiveCfg = Debug|x64
- {90BC31D7-A3E8-4F04-8049-2236C239A044}.Debug|x64.Build.0 = Debug|x64
- {90BC31D7-A3E8-4F04-8049-2236C239A044}.Release|x64.ActiveCfg = Release|x64
- {90BC31D7-A3E8-4F04-8049-2236C239A044}.Release|x64.Build.0 = Release|x64
- {90BC31D7-A3E8-4F04-8049-2236C239A044}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {90BC31D7-A3E8-4F04-8049-2236C239A044}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {90BC31D7-A3E8-4F04-8049-2236C239A044}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {90BC31D7-A3E8-4F04-8049-2236C239A044}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.Debug|x64.ActiveCfg = Debug|x64
- {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.Debug|x64.Build.0 = Debug|x64
- {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.Release|x64.ActiveCfg = Release|x64
- {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.Release|x64.Build.0 = Release|x64
- {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.Debug|x64.ActiveCfg = Debug|x64
- {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.Debug|x64.Build.0 = Debug|x64
- {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.Release|x64.ActiveCfg = Release|x64
- {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.Release|x64.Build.0 = Release|x64
- {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.Debug|x64.ActiveCfg = Debug|x64
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.Debug|x64.Build.0 = Debug|x64
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.Release|x64.ActiveCfg = Release|x64
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.Release|x64.Build.0 = Release|x64
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.Debug|x64.ActiveCfg = Debug|x64
- {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.Debug|x64.Build.0 = Debug|x64
- {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.Release|x64.ActiveCfg = Release|x64
- {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.Release|x64.Build.0 = Release|x64
- {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.Debug|x64.ActiveCfg = Debug|x64
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.Debug|x64.Build.0 = Debug|x64
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.Release|x64.ActiveCfg = Release|x64
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.Release|x64.Build.0 = Release|x64
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.Debug|x64.ActiveCfg = Debug|x64
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.Debug|x64.Build.0 = Debug|x64
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.Release|x64.ActiveCfg = Release|x64
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.Release|x64.Build.0 = Release|x64
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.Debug|x64.ActiveCfg = Debug|x64
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.Debug|x64.Build.0 = Debug|x64
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.Release|x64.ActiveCfg = Release|x64
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.Release|x64.Build.0 = Release|x64
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.Debug|x64.ActiveCfg = Debug|x64
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.Debug|x64.Build.0 = Debug|x64
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.Release|x64.ActiveCfg = Release|x64
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.Release|x64.Build.0 = Release|x64
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.Debug|x64.ActiveCfg = Debug|x64
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.Debug|x64.Build.0 = Debug|x64
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.Release|x64.ActiveCfg = Release|x64
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.Release|x64.Build.0 = Release|x64
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.Debug|x64.ActiveCfg = Debug|x64
- {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.Debug|x64.Build.0 = Debug|x64
- {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.Release|x64.ActiveCfg = Release|x64
- {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.Release|x64.Build.0 = Release|x64
- {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {29D5FCAF-20D0-4DEF-8529-F035C249E996}.Debug|x64.ActiveCfg = Debug|x64
- {29D5FCAF-20D0-4DEF-8529-F035C249E996}.Debug|x64.Build.0 = Debug|x64
- {29D5FCAF-20D0-4DEF-8529-F035C249E996}.Release|x64.ActiveCfg = Release|x64
- {29D5FCAF-20D0-4DEF-8529-F035C249E996}.Release|x64.Build.0 = Release|x64
- {29D5FCAF-20D0-4DEF-8529-F035C249E996}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {29D5FCAF-20D0-4DEF-8529-F035C249E996}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {29D5FCAF-20D0-4DEF-8529-F035C249E996}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {29D5FCAF-20D0-4DEF-8529-F035C249E996}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.Debug|x64.ActiveCfg = Debug|x64
- {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.Debug|x64.Build.0 = Debug|x64
- {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.Release|x64.ActiveCfg = Release|x64
- {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.Release|x64.Build.0 = Release|x64
- {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {C6AF7E57-CE57-4462-AE1D-BF520701480E}.Debug|x64.ActiveCfg = Debug|x64
- {C6AF7E57-CE57-4462-AE1D-BF520701480E}.Debug|x64.Build.0 = Debug|x64
- {C6AF7E57-CE57-4462-AE1D-BF520701480E}.Release|x64.ActiveCfg = Release|x64
- {C6AF7E57-CE57-4462-AE1D-BF520701480E}.Release|x64.Build.0 = Release|x64
- {C6AF7E57-CE57-4462-AE1D-BF520701480E}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {C6AF7E57-CE57-4462-AE1D-BF520701480E}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {C6AF7E57-CE57-4462-AE1D-BF520701480E}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {C6AF7E57-CE57-4462-AE1D-BF520701480E}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.Debug|x64.ActiveCfg = Debug|x64
- {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.Debug|x64.Build.0 = Debug|x64
- {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.Release|x64.ActiveCfg = Release|x64
- {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.Release|x64.Build.0 = Release|x64
- {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {D8294E4A-03C5-43D7-AE35-15603F502DC0}.Debug|x64.ActiveCfg = Debug|x64
- {D8294E4A-03C5-43D7-AE35-15603F502DC0}.Debug|x64.Build.0 = Debug|x64
- {D8294E4A-03C5-43D7-AE35-15603F502DC0}.Release|x64.ActiveCfg = Release|x64
- {D8294E4A-03C5-43D7-AE35-15603F502DC0}.Release|x64.Build.0 = Release|x64
- {D8294E4A-03C5-43D7-AE35-15603F502DC0}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {D8294E4A-03C5-43D7-AE35-15603F502DC0}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {D8294E4A-03C5-43D7-AE35-15603F502DC0}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {D8294E4A-03C5-43D7-AE35-15603F502DC0}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {A4921D15-411F-436A-B6F3-F8381652A8E1}.Debug|x64.ActiveCfg = Debug|x64
- {A4921D15-411F-436A-B6F3-F8381652A8E1}.Debug|x64.Build.0 = Debug|x64
- {A4921D15-411F-436A-B6F3-F8381652A8E1}.Release|x64.ActiveCfg = Release|x64
- {A4921D15-411F-436A-B6F3-F8381652A8E1}.Release|x64.Build.0 = Release|x64
- {A4921D15-411F-436A-B6F3-F8381652A8E1}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {A4921D15-411F-436A-B6F3-F8381652A8E1}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {A4921D15-411F-436A-B6F3-F8381652A8E1}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {A4921D15-411F-436A-B6F3-F8381652A8E1}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.Debug|x64.ActiveCfg = Debug|x64
- {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.Debug|x64.Build.0 = Debug|x64
- {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.Release|x64.ActiveCfg = Release|x64
- {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.Release|x64.Build.0 = Release|x64
- {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.Debug|x64.ActiveCfg = Debug|x64
- {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.Debug|x64.Build.0 = Debug|x64
- {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.Release|x64.ActiveCfg = Release|x64
- {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.Release|x64.Build.0 = Release|x64
- {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.Debug|x64.ActiveCfg = Debug|x64
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.Debug|x64.Build.0 = Debug|x64
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.Release|x64.ActiveCfg = Release|x64
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.Release|x64.Build.0 = Release|x64
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {0E9E295F-3854-415B-AE9F-7B62F17932F5}.Debug|x64.ActiveCfg = Debug|x64
- {0E9E295F-3854-415B-AE9F-7B62F17932F5}.Debug|x64.Build.0 = Debug|x64
- {0E9E295F-3854-415B-AE9F-7B62F17932F5}.Release|x64.ActiveCfg = Release|x64
- {0E9E295F-3854-415B-AE9F-7B62F17932F5}.Release|x64.Build.0 = Release|x64
- {0E9E295F-3854-415B-AE9F-7B62F17932F5}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {0E9E295F-3854-415B-AE9F-7B62F17932F5}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {0E9E295F-3854-415B-AE9F-7B62F17932F5}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {0E9E295F-3854-415B-AE9F-7B62F17932F5}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.Debug|x64.ActiveCfg = Debug|x64
- {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.Debug|x64.Build.0 = Debug|x64
- {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.Release|x64.ActiveCfg = Release|x64
- {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.Release|x64.Build.0 = Release|x64
- {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {F77AD922-B4BC-43D7-B268-865312085495}.Debug|x64.ActiveCfg = Debug|x64
- {F77AD922-B4BC-43D7-B268-865312085495}.Debug|x64.Build.0 = Debug|x64
- {F77AD922-B4BC-43D7-B268-865312085495}.Release|x64.ActiveCfg = Release|x64
- {F77AD922-B4BC-43D7-B268-865312085495}.Release|x64.Build.0 = Release|x64
- {F77AD922-B4BC-43D7-B268-865312085495}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {F77AD922-B4BC-43D7-B268-865312085495}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {F77AD922-B4BC-43D7-B268-865312085495}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {F77AD922-B4BC-43D7-B268-865312085495}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.Debug|x64.ActiveCfg = Debug|x64
- {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.Debug|x64.Build.0 = Debug|x64
- {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.Release|x64.ActiveCfg = Release|x64
- {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.Release|x64.Build.0 = Release|x64
- {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {1DFA0599-77CC-4768-B47A-107EEE86C20C}.Debug|x64.ActiveCfg = Debug|x64
- {1DFA0599-77CC-4768-B47A-107EEE86C20C}.Debug|x64.Build.0 = Debug|x64
- {1DFA0599-77CC-4768-B47A-107EEE86C20C}.Release|x64.ActiveCfg = Release|x64
- {1DFA0599-77CC-4768-B47A-107EEE86C20C}.Release|x64.Build.0 = Release|x64
- {1DFA0599-77CC-4768-B47A-107EEE86C20C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {1DFA0599-77CC-4768-B47A-107EEE86C20C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {1DFA0599-77CC-4768-B47A-107EEE86C20C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {1DFA0599-77CC-4768-B47A-107EEE86C20C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.Debug|x64.ActiveCfg = Debug|x64
- {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.Debug|x64.Build.0 = Debug|x64
- {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.Release|x64.ActiveCfg = Release|x64
- {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.Release|x64.Build.0 = Release|x64
- {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.Debug|x64.ActiveCfg = Debug|x64
- {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.Debug|x64.Build.0 = Debug|x64
- {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.Release|x64.ActiveCfg = Release|x64
- {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.Release|x64.Build.0 = Release|x64
- {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
- {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
- {02D16A66-6D59-4A0E-ABB3-BD12926934FE}.Debug|x64.ActiveCfg = Debug|x64
- {02D16A66-6D59-4A0E-ABB3-BD12926934FE}.Release|x64.ActiveCfg = Release|x64
- {02D16A66-6D59-4A0E-ABB3-BD12926934FE}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {02D16A66-6D59-4A0E-ABB3-BD12926934FE}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- {B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}.Debug|x64.ActiveCfg = Debug|x64
- {B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}.Release|x64.ActiveCfg = Release|x64
- {B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
- {B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {3B126B2D-DEAA-4CDF-9F44-28D3600F5754} = {31CE49D7-85CA-41E2-83D2-CC6962519DB6}
- {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85} = {31CE49D7-85CA-41E2-83D2-CC6962519DB6}
- {D87B08A8-638E-43FA-96C2-404B41363D3B} = {31CE49D7-85CA-41E2-83D2-CC6962519DB6}
- {90BC31D7-A3E8-4F04-8049-2236C239A044} = {31CE49D7-85CA-41E2-83D2-CC6962519DB6}
- {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89} = {BD073C58-BAED-420E-80EA-DC9F52E21AF7}
- {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1} = {BD073C58-BAED-420E-80EA-DC9F52E21AF7}
- {7BAF09E0-DCD4-4567-9486-79E1E5F18333} = {BD073C58-BAED-420E-80EA-DC9F52E21AF7}
- {D0413FDA-31C5-41C2-A53A-C1B87061EC96} = {BD073C58-BAED-420E-80EA-DC9F52E21AF7}
- {F77AD922-B4BC-43D7-B268-865312085495} = {8ECAB3CD-B434-426B-B63A-115919D393BC}
- {B025BD09-8389-4D9F-9150-F33418A664B1} = {964DC7DE-990A-4CA4-8395-10D9F9CB2A23}
- {0984A63C-130E-4B62-9A94-AAC28A88C137} = {7E002D15-21D1-4927-B486-82E496444441}
- {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54} = {7E002D15-21D1-4927-B486-82E496444441}
- {2485E202-B981-41E0-98CA-CF363437A4E4} = {7E002D15-21D1-4927-B486-82E496444441}
- {0283B293-0067-4D02-ADA6-892704398F48} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
- {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
- {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
- {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
- {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
- {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
- {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
- {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
- {4810B052-899E-4CA5-A0BC-2E383F8AEFAE} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
- {29D5FCAF-20D0-4DEF-8529-F035C249E996} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
- {A0421DCA-AC3E-42D0-94AC-379A21A1E591} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
- {C6AF7E57-CE57-4462-AE1D-BF520701480E} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
- {F2CAAAB3-9568-4284-B8E3-13955183A6D7} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
- {D8294E4A-03C5-43D7-AE35-15603F502DC0} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
- {A4921D15-411F-436A-B6F3-F8381652A8E1} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
- {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
- {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C} = {2485E202-B981-41E0-98CA-CF363437A4E4}
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ALL_BUILD", "ALL_BUILD.vcxproj", "{BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {B025BD09-8389-4D9F-9150-F33418A664B1} = {B025BD09-8389-4D9F-9150-F33418A664B1}
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8} = {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8} = {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}
+ {0283B293-0067-4D02-ADA6-892704398F48} = {0283B293-0067-4D02-ADA6-892704398F48}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B} = {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8} = {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84} = {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE} = {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996} = {29D5FCAF-20D0-4DEF-8529-F035C249E996}
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591} = {A0421DCA-AC3E-42D0-94AC-379A21A1E591}
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E} = {C6AF7E57-CE57-4462-AE1D-BF520701480E}
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7} = {F2CAAAB3-9568-4284-B8E3-13955183A6D7}
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0} = {D8294E4A-03C5-43D7-AE35-15603F502DC0}
+ {A4921D15-411F-436A-B6F3-F8381652A8E1} = {A4921D15-411F-436A-B6F3-F8381652A8E1}
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C} = {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5} = {0E9E295F-3854-415B-AE9F-7B62F17932F5}
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644} = {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}
+ {F77AD922-B4BC-43D7-B268-865312085495} = {F77AD922-B4BC-43D7-B268-865312085495}
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88} = {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C} = {1DFA0599-77CC-4768-B47A-107EEE86C20C}
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48} = {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C} = {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CMakeLib", "Source\CMakeLib.vcxproj", "{59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CMakeLibTests", "Tests\CMakeLib\CMakeLibTests.vcxproj", "{B025BD09-8389-4D9F-9150-F33418A664B1}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CPackLib", "Source\CPackLib.vcxproj", "{94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CTestLib", "Source\CTestLib.vcxproj", "{1002C8FC-7242-4A69-AF51-C59BB10BA6D8}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Continuous", "Continuous.vcxproj", "{E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Experimental", "Experimental.vcxproj", "{B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "INSTALL", "INSTALL.vcxproj", "{3B126B2D-DEAA-4CDF-9F44-28D3600F5754}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C} = {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LIBCURL", "Utilities\cmcurl\LIBCURL.vcxproj", "{0283B293-0067-4D02-ADA6-892704398F48}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Nightly", "Nightly.vcxproj", "{7BAF09E0-DCD4-4567-9486-79E1E5F18333}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NightlyMemoryCheck", "NightlyMemoryCheck.vcxproj", "{D0413FDA-31C5-41C2-A53A-C1B87061EC96}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PACKAGE", "PACKAGE.vcxproj", "{4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}"
+ ProjectSection(ProjectDependencies) = postProject
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C} = {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RUN_TESTS", "RUN_TESTS.vcxproj", "{D87B08A8-638E-43FA-96C2-404B41363D3B}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZERO_CHECK", "ZERO_CHECK.vcxproj", "{90BC31D7-A3E8-4F04-8049-2236C239A044}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmIML_test", "Utilities\KWIML\test\cmIML_test.vcxproj", "{48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmake", "Source\cmake.vcxproj", "{6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmbzip2", "Utilities\cmbzip2\cmbzip2.vcxproj", "{1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmcldeps", "Source\cmcldeps.vcxproj", "{A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmcompress", "Utilities\cmcompress\cmcompress.vcxproj", "{561AD1BB-6DD3-466D-B270-3696DEE8C26C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmcurl", "Utilities\cmcurl\cmcurl.vcxproj", "{1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmexpat", "Utilities\cmexpat\cmexpat.vcxproj", "{459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmlibarchive", "Utilities\cmlibarchive\libarchive\cmlibarchive.vcxproj", "{25A91A7A-9C4E-420C-98BD-2D1F0165DA54}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsys", "Source\kwsys\cmsys.vcxproj", "{BDB424DC-15B3-4A06-A1E2-3D61380F359F}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE} = {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996} = {29D5FCAF-20D0-4DEF-8529-F035C249E996}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysEncodeExecutable", "Source\kwsys\cmsysEncodeExecutable.vcxproj", "{4810B052-899E-4CA5-A0BC-2E383F8AEFAE}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysProcessFwd9x", "Source\kwsys\cmsysProcessFwd9x.vcxproj", "{29D5FCAF-20D0-4DEF-8529-F035C249E996}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestDynload", "Source\kwsys\cmsysTestDynload.vcxproj", "{A0421DCA-AC3E-42D0-94AC-379A21A1E591}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestProcess", "Source\kwsys\cmsysTestProcess.vcxproj", "{C6AF7E57-CE57-4462-AE1D-BF520701480E}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestSharedForward", "Source\kwsys\cmsysTestSharedForward.vcxproj", "{F2CAAAB3-9568-4284-B8E3-13955183A6D7}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestsC", "Source\kwsys\cmsysTestsC.vcxproj", "{D8294E4A-03C5-43D7-AE35-15603F502DC0}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsysTestsCxx", "Source\kwsys\cmsysTestsCxx.vcxproj", "{A4921D15-411F-436A-B6F3-F8381652A8E1}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmsys_c", "Source\kwsys\cmsys_c.vcxproj", "{60BEB3AF-B4EF-4363-8747-C40177BC2D9C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE} = {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996} = {29D5FCAF-20D0-4DEF-8529-F035C249E996}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmw9xcom", "Source\cmw9xcom.vcxproj", "{ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {561AD1BB-6DD3-466D-B270-3696DEE8C26C}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {BDB424DC-15B3-4A06-A1E2-3D61380F359F}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cmzlib", "Utilities\cmzlib\cmzlib.vcxproj", "{0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpack", "Source\cpack.vcxproj", "{0E9E295F-3854-415B-AE9F-7B62F17932F5}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8} = {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ctest", "Source\ctest.vcxproj", "{4BFA4D7C-C6F7-4270-9E87-B922DCE05644}"
+ ProjectSection(ProjectDependencies) = postProject
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2} = {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8} = {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "documentation", "Utilities\documentation.vcxproj", "{F77AD922-B4BC-43D7-B268-865312085495}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8} = {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5} = {0E9E295F-3854-415B-AE9F-7B62F17932F5}
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644} = {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "memcheck_fail", "Tests\CTestTestMemcheck\memcheck_fail.vcxproj", "{8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pseudo_BC", "Tests\CTestTestMemcheck\pseudo_BC.vcxproj", "{1DFA0599-77CC-4768-B47A-107EEE86C20C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pseudo_purify", "Tests\CTestTestMemcheck\pseudo_purify.vcxproj", "{0E45A3EF-8636-46CF-94A3-7B5CE875DE48}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pseudo_valgrind", "Tests\CTestTestMemcheck\pseudo_valgrind.vcxproj", "{CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_clean", "Tests\test_clean.vcxproj", "{02D16A66-6D59-4A0E-ABB3-BD12926934FE}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uninstall", "uninstall.vcxproj", "{B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}"
+ ProjectSection(ProjectDependencies) = postProject
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {90BC31D7-A3E8-4F04-8049-2236C239A044}
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CMakePredefinedTargets", "CMakePredefinedTargets", "{31CE49D7-85CA-41E2-83D2-CC6962519DB6}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CTestDashboardTargets", "CTestDashboardTargets", "{BD073C58-BAED-420E-80EA-DC9F52E21AF7}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{8ECAB3CD-B434-426B-B63A-115919D393BC}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{964DC7DE-990A-4CA4-8395-10D9F9CB2A23}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{7E002D15-21D1-4927-B486-82E496444441}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3rdParty", "Utilities\3rdParty", "{0984A63C-130E-4B62-9A94-AAC28A88C137}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "KWSys", "Utilities\KWSys", "{EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Win9xCompat", "Utilities\Win9xCompat", "{2485E202-B981-41E0-98CA-CF363437A4E4}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x64 = Debug|x64
+ Release|x64 = Release|x64
+ MinSizeRel|x64 = MinSizeRel|x64
+ RelWithDebInfo|x64 = RelWithDebInfo|x64
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.Debug|x64.ActiveCfg = Debug|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.Debug|x64.Build.0 = Debug|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.Release|x64.ActiveCfg = Release|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.Release|x64.Build.0 = Release|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {BC04E6F9-A1E4-43BA-88B3-6FBF45FA561C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.Debug|x64.ActiveCfg = Debug|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.Debug|x64.Build.0 = Debug|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.Release|x64.ActiveCfg = Release|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.Release|x64.Build.0 = Release|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {59BCCCCD-3AD1-4491-B8F4-C5793AC007E2}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.Debug|x64.ActiveCfg = Debug|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.Debug|x64.Build.0 = Debug|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.Release|x64.ActiveCfg = Release|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.Release|x64.Build.0 = Release|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {B025BD09-8389-4D9F-9150-F33418A664B1}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.Debug|x64.ActiveCfg = Debug|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.Debug|x64.Build.0 = Debug|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.Release|x64.ActiveCfg = Release|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.Release|x64.Build.0 = Release|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {94EAABE8-174B-4EE9-8EDF-C5FED49A31B8}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.Debug|x64.ActiveCfg = Debug|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.Debug|x64.Build.0 = Debug|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.Release|x64.ActiveCfg = Release|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.Release|x64.Build.0 = Release|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {1002C8FC-7242-4A69-AF51-C59BB10BA6D8}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}.Debug|x64.ActiveCfg = Debug|x64
+ {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}.Release|x64.ActiveCfg = Release|x64
+ {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}.Debug|x64.ActiveCfg = Debug|x64
+ {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}.Release|x64.ActiveCfg = Release|x64
+ {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {3B126B2D-DEAA-4CDF-9F44-28D3600F5754}.Debug|x64.ActiveCfg = Debug|x64
+ {3B126B2D-DEAA-4CDF-9F44-28D3600F5754}.Release|x64.ActiveCfg = Release|x64
+ {3B126B2D-DEAA-4CDF-9F44-28D3600F5754}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {3B126B2D-DEAA-4CDF-9F44-28D3600F5754}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.Debug|x64.ActiveCfg = Debug|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.Debug|x64.Build.0 = Debug|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.Release|x64.ActiveCfg = Release|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.Release|x64.Build.0 = Release|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {0283B293-0067-4D02-ADA6-892704398F48}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {7BAF09E0-DCD4-4567-9486-79E1E5F18333}.Debug|x64.ActiveCfg = Debug|x64
+ {7BAF09E0-DCD4-4567-9486-79E1E5F18333}.Release|x64.ActiveCfg = Release|x64
+ {7BAF09E0-DCD4-4567-9486-79E1E5F18333}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {7BAF09E0-DCD4-4567-9486-79E1E5F18333}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {D0413FDA-31C5-41C2-A53A-C1B87061EC96}.Debug|x64.ActiveCfg = Debug|x64
+ {D0413FDA-31C5-41C2-A53A-C1B87061EC96}.Release|x64.ActiveCfg = Release|x64
+ {D0413FDA-31C5-41C2-A53A-C1B87061EC96}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {D0413FDA-31C5-41C2-A53A-C1B87061EC96}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}.Debug|x64.ActiveCfg = Debug|x64
+ {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}.Release|x64.ActiveCfg = Release|x64
+ {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {D87B08A8-638E-43FA-96C2-404B41363D3B}.Debug|x64.ActiveCfg = Debug|x64
+ {D87B08A8-638E-43FA-96C2-404B41363D3B}.Release|x64.ActiveCfg = Release|x64
+ {D87B08A8-638E-43FA-96C2-404B41363D3B}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {D87B08A8-638E-43FA-96C2-404B41363D3B}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.Debug|x64.ActiveCfg = Debug|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.Debug|x64.Build.0 = Debug|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.Release|x64.ActiveCfg = Release|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.Release|x64.Build.0 = Release|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {90BC31D7-A3E8-4F04-8049-2236C239A044}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.Debug|x64.ActiveCfg = Debug|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.Debug|x64.Build.0 = Debug|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.Release|x64.ActiveCfg = Release|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.Release|x64.Build.0 = Release|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {48D43A03-3C1B-439A-9517-8F2A2B4CEC3B}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.Debug|x64.ActiveCfg = Debug|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.Debug|x64.Build.0 = Debug|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.Release|x64.ActiveCfg = Release|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.Release|x64.Build.0 = Release|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {6ADE54B3-3FDA-4E76-9B87-66D95E5265A8}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.Debug|x64.ActiveCfg = Debug|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.Debug|x64.Build.0 = Debug|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.Release|x64.ActiveCfg = Release|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.Release|x64.Build.0 = Release|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.Debug|x64.ActiveCfg = Debug|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.Debug|x64.Build.0 = Debug|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.Release|x64.ActiveCfg = Release|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.Release|x64.Build.0 = Release|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {A51EB64E-E1EA-4B4A-8FDC-56ADFE635E84}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.Debug|x64.ActiveCfg = Debug|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.Debug|x64.Build.0 = Debug|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.Release|x64.ActiveCfg = Release|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.Release|x64.Build.0 = Release|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.Debug|x64.ActiveCfg = Debug|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.Debug|x64.Build.0 = Debug|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.Release|x64.ActiveCfg = Release|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.Release|x64.Build.0 = Release|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.Debug|x64.ActiveCfg = Debug|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.Debug|x64.Build.0 = Debug|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.Release|x64.ActiveCfg = Release|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.Release|x64.Build.0 = Release|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.Debug|x64.ActiveCfg = Debug|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.Debug|x64.Build.0 = Debug|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.Release|x64.ActiveCfg = Release|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.Release|x64.Build.0 = Release|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.Debug|x64.ActiveCfg = Debug|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.Debug|x64.Build.0 = Debug|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.Release|x64.ActiveCfg = Release|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.Release|x64.Build.0 = Release|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.Debug|x64.ActiveCfg = Debug|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.Debug|x64.Build.0 = Debug|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.Release|x64.ActiveCfg = Release|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.Release|x64.Build.0 = Release|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.Debug|x64.ActiveCfg = Debug|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.Debug|x64.Build.0 = Debug|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.Release|x64.ActiveCfg = Release|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.Release|x64.Build.0 = Release|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.Debug|x64.ActiveCfg = Debug|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.Debug|x64.Build.0 = Debug|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.Release|x64.ActiveCfg = Release|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.Release|x64.Build.0 = Release|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.Debug|x64.ActiveCfg = Debug|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.Debug|x64.Build.0 = Debug|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.Release|x64.ActiveCfg = Release|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.Release|x64.Build.0 = Release|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.Debug|x64.ActiveCfg = Debug|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.Debug|x64.Build.0 = Debug|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.Release|x64.ActiveCfg = Release|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.Release|x64.Build.0 = Release|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.Debug|x64.ActiveCfg = Debug|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.Debug|x64.Build.0 = Debug|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.Release|x64.ActiveCfg = Release|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.Release|x64.Build.0 = Release|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.Debug|x64.ActiveCfg = Debug|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.Debug|x64.Build.0 = Debug|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.Release|x64.ActiveCfg = Release|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.Release|x64.Build.0 = Release|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {A4921D15-411F-436A-B6F3-F8381652A8E1}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.Debug|x64.ActiveCfg = Debug|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.Debug|x64.Build.0 = Debug|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.Release|x64.ActiveCfg = Release|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.Release|x64.Build.0 = Release|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.Debug|x64.ActiveCfg = Debug|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.Debug|x64.Build.0 = Debug|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.Release|x64.ActiveCfg = Release|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.Release|x64.Build.0 = Release|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.Debug|x64.ActiveCfg = Debug|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.Debug|x64.Build.0 = Debug|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.Release|x64.ActiveCfg = Release|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.Release|x64.Build.0 = Release|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.Debug|x64.ActiveCfg = Debug|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.Debug|x64.Build.0 = Debug|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.Release|x64.ActiveCfg = Release|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.Release|x64.Build.0 = Release|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {0E9E295F-3854-415B-AE9F-7B62F17932F5}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.Debug|x64.ActiveCfg = Debug|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.Debug|x64.Build.0 = Debug|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.Release|x64.ActiveCfg = Release|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.Release|x64.Build.0 = Release|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {4BFA4D7C-C6F7-4270-9E87-B922DCE05644}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.Debug|x64.ActiveCfg = Debug|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.Debug|x64.Build.0 = Debug|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.Release|x64.ActiveCfg = Release|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.Release|x64.Build.0 = Release|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {F77AD922-B4BC-43D7-B268-865312085495}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.Debug|x64.ActiveCfg = Debug|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.Debug|x64.Build.0 = Debug|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.Release|x64.ActiveCfg = Release|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.Release|x64.Build.0 = Release|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {8DF3790D-AF1B-4505-BA5B-4D61EF9FBE88}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.Debug|x64.ActiveCfg = Debug|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.Debug|x64.Build.0 = Debug|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.Release|x64.ActiveCfg = Release|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.Release|x64.Build.0 = Release|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {1DFA0599-77CC-4768-B47A-107EEE86C20C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.Debug|x64.ActiveCfg = Debug|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.Debug|x64.Build.0 = Debug|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.Release|x64.ActiveCfg = Release|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.Release|x64.Build.0 = Release|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {0E45A3EF-8636-46CF-94A3-7B5CE875DE48}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.Debug|x64.ActiveCfg = Debug|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.Debug|x64.Build.0 = Debug|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.Release|x64.ActiveCfg = Release|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.Release|x64.Build.0 = Release|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {CAEF2D10-B14D-4E0C-8B79-8AC767B12F7C}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
+ {02D16A66-6D59-4A0E-ABB3-BD12926934FE}.Debug|x64.ActiveCfg = Debug|x64
+ {02D16A66-6D59-4A0E-ABB3-BD12926934FE}.Release|x64.ActiveCfg = Release|x64
+ {02D16A66-6D59-4A0E-ABB3-BD12926934FE}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {02D16A66-6D59-4A0E-ABB3-BD12926934FE}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ {B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}.Debug|x64.ActiveCfg = Debug|x64
+ {B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}.Release|x64.ActiveCfg = Release|x64
+ {B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
+ {B5A9B8B7-53AC-46D7-9ADE-76F708A7189C}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {3B126B2D-DEAA-4CDF-9F44-28D3600F5754} = {31CE49D7-85CA-41E2-83D2-CC6962519DB6}
+ {4C488FF0-7C06-47FE-A8FD-67DAD51A3E85} = {31CE49D7-85CA-41E2-83D2-CC6962519DB6}
+ {D87B08A8-638E-43FA-96C2-404B41363D3B} = {31CE49D7-85CA-41E2-83D2-CC6962519DB6}
+ {90BC31D7-A3E8-4F04-8049-2236C239A044} = {31CE49D7-85CA-41E2-83D2-CC6962519DB6}
+ {E5071092-DBFB-49E2-AF0F-E8B0FDEF6C89} = {BD073C58-BAED-420E-80EA-DC9F52E21AF7}
+ {B28E8445-DFD2-46EA-BA6C-C2A1864F2FB1} = {BD073C58-BAED-420E-80EA-DC9F52E21AF7}
+ {7BAF09E0-DCD4-4567-9486-79E1E5F18333} = {BD073C58-BAED-420E-80EA-DC9F52E21AF7}
+ {D0413FDA-31C5-41C2-A53A-C1B87061EC96} = {BD073C58-BAED-420E-80EA-DC9F52E21AF7}
+ {F77AD922-B4BC-43D7-B268-865312085495} = {8ECAB3CD-B434-426B-B63A-115919D393BC}
+ {B025BD09-8389-4D9F-9150-F33418A664B1} = {964DC7DE-990A-4CA4-8395-10D9F9CB2A23}
+ {0984A63C-130E-4B62-9A94-AAC28A88C137} = {7E002D15-21D1-4927-B486-82E496444441}
+ {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54} = {7E002D15-21D1-4927-B486-82E496444441}
+ {2485E202-B981-41E0-98CA-CF363437A4E4} = {7E002D15-21D1-4927-B486-82E496444441}
+ {0283B293-0067-4D02-ADA6-892704398F48} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {1C5345F9-9C47-4F4B-9760-7A74C9D35DE0} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {561AD1BB-6DD3-466D-B270-3696DEE8C26C} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {1342243A-C3D9-45A0-B4BC-65A8F16BCC9D} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {459BD82A-588C-4BFD-B3E6-1E4E3BC1B1E3} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {25A91A7A-9C4E-420C-98BD-2D1F0165DA54} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {0B7FB622-7A90-490C-B4E4-2DE3112BB5E0} = {0984A63C-130E-4B62-9A94-AAC28A88C137}
+ {BDB424DC-15B3-4A06-A1E2-3D61380F359F} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {4810B052-899E-4CA5-A0BC-2E383F8AEFAE} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {29D5FCAF-20D0-4DEF-8529-F035C249E996} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {A0421DCA-AC3E-42D0-94AC-379A21A1E591} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {C6AF7E57-CE57-4462-AE1D-BF520701480E} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {F2CAAAB3-9568-4284-B8E3-13955183A6D7} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {D8294E4A-03C5-43D7-AE35-15603F502DC0} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {A4921D15-411F-436A-B6F3-F8381652A8E1} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {60BEB3AF-B4EF-4363-8747-C40177BC2D9C} = {EF1DFA45-6F7A-4760-8EB5-69A8A221FC54}
+ {ACC30B92-8B65-4A9D-9BF2-6BBD0B008C8C} = {2485E202-B981-41E0-98CA-CF363437A4E4}
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Tests/CMakeLib/testXMLParser.cxx b/Tests/CMakeLib/testXMLParser.cxx
index d5e9764f9..8617cc118 100644
--- a/Tests/CMakeLib/testXMLParser.cxx
+++ b/Tests/CMakeLib/testXMLParser.cxx
@@ -1,9 +1,9 @@
#include "testXMLParser.h"
-#include "cmXMLParser.h"
-
#include <iostream>
+#include "cmXMLParser.h"
+
int testXMLParser(int /*unused*/, char* /*unused*/ [])
{
// TODO: Derive from parser and check attributes.
diff --git a/Tests/CMakeLib/testXMLSafe.cxx b/Tests/CMakeLib/testXMLSafe.cxx
index fe776c587..dc62eb9c9 100644
--- a/Tests/CMakeLib/testXMLSafe.cxx
+++ b/Tests/CMakeLib/testXMLSafe.cxx
@@ -1,12 +1,13 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
-#include <cmConfigure.h>
+#include "cmConfigure.h" // IWYU pragma: keep
#include <sstream>
-#include <stdio.h>
#include <string>
+#include <stdio.h>
+
#include "cmXMLSafe.h"
struct test_pair
@@ -21,7 +22,7 @@ static test_pair const pairs[] = {
{ "angles <>", "angles &lt;&gt;" },
{ "ampersand &", "ampersand &amp;" },
{ "bad-byte \x80", "bad-byte [NON-UTF-8-BYTE-0x80]" },
- { CM_NULLPTR, CM_NULLPTR }
+ { nullptr, nullptr }
};
int testXMLSafe(int /*unused*/, char* /*unused*/ [])
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index d16df1cf5..57fa7fcd8 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -14,14 +14,15 @@ macro(ADD_TEST_MACRO NAME)
${build_generator_args}
--build-project ${proj}
${${NAME}_CTEST_OPTIONS}
- --build-options ${build_options}
- ${${NAME}_BUILD_OPTIONS}
+ --build-options
+ ${${NAME}_BUILD_OPTIONS}
${_test_command})
unset(_test_command)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}")
endmacro()
include(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake)
+include(${CMAKE_CURRENT_SOURCE_DIR}/CheckSwift.cmake)
# Fake a user home directory to avoid polluting the real one.
if(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME)
@@ -31,14 +32,28 @@ if(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME)
set(TEST_HOME_ENV_CODE "# Fake a user home directory to avoid polluting the real one.
# But provide original ENV{HOME} value in ENV{CTEST_REAL_HOME} for tests that
# need access to the real HOME directory.
-set(ENV{CTEST_REAL_HOME} \"\$ENV{HOME}\")
+if(NOT DEFINED ENV{CTEST_REAL_HOME})
+ set(ENV{CTEST_REAL_HOME} \"\$ENV{HOME}\")
+endif()
set(ENV{HOME} \"${TEST_HOME}\")
")
endif()
+# 3.9 or later provides a definitive answer to whether we are multi-config
+# through a global property. Prior to 3.9, CMAKE_CONFIGURATION_TYPES being set
+# is assumed to mean multi-config, but developers might modify it so it is
+# technically not as reliable.
+if(NOT CMAKE_VERSION VERSION_LESS 3.9)
+ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+elseif(CMAKE_CONFIGURATION_TYPES)
+ set(_isMultiConfig True)
+else()
+ set(_isMultiConfig False)
+endif()
+
# Choose a default configuration for CTest tests.
set(CTestTest_CONFIG Debug)
-if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE)
+if(NOT _isMultiConfig AND CMAKE_BUILD_TYPE)
set(CTestTest_CONFIG ${CMAKE_BUILD_TYPE})
endif()
@@ -50,7 +65,7 @@ if(BUILD_TESTING)
set(CMake_TEST_DEVENV "")
if(CMAKE_VS_DEVENV_COMMAND)
set(CMake_TEST_DEVENV "${CMAKE_VS_DEVENV_COMMAND}")
- elseif(CMAKE_GENERATOR MATCHES "Visual Studio [89] " AND
+ elseif(CMAKE_GENERATOR MATCHES "Visual Studio 9 " AND
NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]")
set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}")
endif()
@@ -112,9 +127,10 @@ if(BUILD_TESTING)
)
endif()
- set(build_options)
if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
- list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
+ list(APPEND build_generator_args
+ --build-makeprogram ${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
+ )
endif()
# Look for rpmbuild to use for tests.
@@ -131,8 +147,7 @@ if(BUILD_TESTING)
set(CPACK_BINARY_RPM OFF)
endif()
- # Look for rpmbuild to use for tests.
- # The tool does not work with spaces in the path.
+ # Look for dpkg to use for tests.
find_program(DPKG_EXECUTABLE NAMES dpkg)
if(DPKG_EXECUTABLE)
@@ -141,11 +156,65 @@ if(BUILD_TESTING)
set(CPACK_BINARY_DEB OFF)
endif()
+ # Look for NuGet to use for tests.
+ find_program(NUGET_EXECUTABLE NAMES NuGet nuget)
+
+ if(NUGET_EXECUTABLE)
+ set(CPACK_BINARY_NUGET ON)
+ else()
+ set(CPACK_BINARY_NUGET OFF)
+ endif()
+
+ if(WIN32)
+ # Macro to search for available Windows CE SDKs in the windows Registry
+ macro(select_wince_sdk selected_reg selected_sdk)
+ if(CMAKE_HOST_WIN32)
+ execute_process(COMMAND reg QUERY "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs"
+ OUTPUT_VARIABLE sdk_reg
+ ERROR_VARIABLE my_err)
+ string(REGEX REPLACE "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Wow6432Node\\\\Microsoft\\\\Windows CE Tools\\\\SDKs\\\\" ";" sdk_list "${sdk_reg}")
+ list(LENGTH sdk_list sdk_list_len)
+ if (${sdk_list_len} GREATER 1)
+ list(GET sdk_list 1 _sdk) # The first entry is always empty due to the regex replace above
+ string(STRIP ${_sdk} _sdk) # Make sure there is no newline in the SDK name
+ endif()
+ # Build a key to be used by get_filename_component that is pointing to the SDK directory
+ set(_reg "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs\\${_sdk}]")
+ # Set return values
+ set(${selected_reg} ${_reg})
+ set(${selected_sdk} ${_sdk})
+ endif(CMAKE_HOST_WIN32)
+ endmacro(select_wince_sdk)
+
+ set(reg_vs10 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]")
+ set(reg_vs11 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;InstallDir]")
+ set(reg_vs12 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0;InstallDir]")
+ set(reg_vs14 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0;InstallDir]")
+ set(reg_ws80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]")
+ set(reg_ws81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]")
+ set(reg_ws10_0 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0\\Setup\\Build Tools for Windows 10;srcPath]")
+ set(reg_wp80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.0;InstallationFolder]")
+ set(reg_wp81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.1;InstallationFolder]")
+ select_wince_sdk(reg_wince wince_sdk)
+ set(reg_tegra "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;sdkRoot]")
+ set(reg_nasm "[HKEY_CURRENT_USER\\SOFTWARE\\nasm]")
+ foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra nasm)
+ get_filename_component(r "${reg_${reg}}" ABSOLUTE)
+ if(IS_DIRECTORY "${r}" AND NOT "${r}" STREQUAL "/registry")
+ set(${reg} 1)
+ else()
+ set(${reg} 0)
+ endif()
+ endforeach()
+ endif()
+
#---------------------------------------------------------------------------
# Add tests below here.
if(NOT CMake_TEST_EXTERNAL_CMAKE)
add_subdirectory(CMakeLib)
+
+ add_subdirectory(CMakeServerLib)
endif()
add_subdirectory(CMakeOnly)
add_subdirectory(RunCMake)
@@ -228,6 +297,10 @@ if(BUILD_TESTING)
set(CMake_TEST_XCODE_VERSION "${CMAKE_MATCH_1}")
endif()
endif()
+ if(NOT CMake_TEST_XCODE_VERSION VERSION_LESS 10)
+ # Since Xcode 10 we do not have two supported architectures for the host.
+ set(CTEST_TEST_OSX_ARCH 0)
+ endif()
if(CMAKE_OSX_SYSROOT)
execute_process(
COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version ProductName
@@ -264,7 +337,7 @@ if(BUILD_TESTING)
endif()
add_test(NAME CMake.Copyright
- COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake)
+ COMMAND ${CMAKE_CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCopyright.cmake)
# add a bunch of standard build-and-test style tests
ADD_TEST_MACRO(CommandLineTest CommandLineTest)
@@ -294,11 +367,16 @@ if(BUILD_TESTING)
((NOT CMAKE_OSX_SDKPRODUCT STREQUAL "Mac OS X") OR
(NOT CMAKE_OSX_SDKVERSION VERSION_LESS 10.10)))
if(CMAKE_GENERATOR STREQUAL "Xcode")
- ADD_TEST_MACRO(SwiftMix SwiftMix)
- ADD_TEST_MACRO(SwiftOnly SwiftOnly)
+ set(CMake_TEST_XCODE_SWIFT 1)
endif()
endif()
endif()
+ if(CMAKE_Swift_COMPILER OR CMake_TEST_XCODE_SWIFT)
+ ADD_TEST_MACRO(SwiftOnly SwiftOnly)
+ if(CMake_TEST_XCODE_SWIFT)
+ ADD_TEST_MACRO(SwiftMix SwiftMix)
+ endif()
+ endif()
if(CMAKE_Fortran_COMPILER)
ADD_TEST_MACRO(FortranOnly FortranOnly)
endif()
@@ -325,20 +403,21 @@ if(BUILD_TESTING)
set(CMAKE_SKIP_VSGNUFortran TRUE)
endif()
if(NOT CMAKE_SKIP_VSGNUFortran)
- ADD_TEST_MACRO(VSGNUFortran ${CMAKE_COMMAND} -P runtest.cmake)
+ ADD_TEST_MACRO(VSGNUFortran ${CMAKE_CMAKE_COMMAND} -P runtest.cmake)
endif()
endif()
- if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])")
+ if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])")
ADD_TEST_MACRO(CSharpOnly CSharpOnly)
ADD_TEST_MACRO(CSharpLinkToCxx CSharpLinkToCxx)
+ ADD_TEST_MACRO(CSharpLinkFromCxx CSharpLinkFromCxx)
endif()
ADD_TEST_MACRO(COnly COnly)
ADD_TEST_MACRO(CxxOnly CxxOnly)
ADD_TEST_MACRO(CxxSubdirC CxxSubdirC)
- ADD_TEST_MACRO(IPO COnly/COnly)
ADD_TEST_MACRO(OutDir runtime/OutDir)
+ ADD_TEST_MACRO(OutName exe.OutName.exe)
ADD_TEST_MACRO(ObjectLibrary UseCshared)
ADD_TEST_MACRO(NewlineArgs NewlineArgs)
ADD_TEST_MACRO(SetLang SetLang)
@@ -363,23 +442,30 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(PolicyScope PolicyScope)
ADD_TEST_MACRO(EmptyLibrary EmptyLibrary)
ADD_TEST_MACRO(CompileDefinitions CompileDefinitions)
+ if(CMAKE_Fortran_COMPILER)
+ set(CompileOptions_BUILD_OPTIONS -DTEST_FORTRAN=1)
+ endif()
ADD_TEST_MACRO(CompileOptions CompileOptions)
ADD_TEST_MACRO(CompatibleInterface CompatibleInterface)
ADD_TEST_MACRO(AliasTarget AliasTarget)
ADD_TEST_MACRO(StagingPrefix StagingPrefix)
+ ADD_TEST_MACRO(ImportedSameName ImportedSameName)
ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary)
- if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
- set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+ if(NOT _isMultiConfig)
+ set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=$<CONFIGURATION>)
ADD_TEST_MACRO(ConfigSources ConfigSources)
endif()
ADD_TEST_MACRO(SourcesProperty SourcesProperty)
ADD_TEST_MACRO(SourceFileProperty SourceFileProperty)
+ if (NOT CMAKE_GENERATOR STREQUAL "Xcode")
+ ADD_TEST_MACRO(SourceFileIncludeDirProperty SourceFileIncludeDirProperty)
+ endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU
AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
set(runCxxDialectTest 1)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL Clang
- AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
+ AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4 AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
if(NOT APPLE OR POLICY CMP0025)
set(runCxxDialectTest 1)
endif()
@@ -403,11 +489,14 @@ if(BUILD_TESTING)
list(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX})
- if(NOT QT4_FOUND)
+ if(NOT DEFINED CMake_TEST_Qt4)
+ set(CMake_TEST_Qt4 1)
+ endif()
+ if(CMake_TEST_Qt4 AND NOT QT4_FOUND)
find_package(Qt4 QUIET)
endif()
- if(QT4_FOUND)
+ if(CMake_TEST_Qt4 AND QT4_FOUND)
# test whether the Qt4 which has been found works, on some machines
# which run nightly builds there were errors like "wrong file format"
# for libQtCore.so. So first check it works, and only if it does add
@@ -439,7 +528,6 @@ if(BUILD_TESTING)
"${CMake_BINARY_DIR}/Tests/BundleUtilities"
${build_generator_args}
--build-project BundleUtilities
- --build-options ${build_options}
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleUtilities")
@@ -452,9 +540,9 @@ if(BUILD_TESTING)
"${CMake_BINARY_DIR}/Tests/Qt4Deploy"
${build_generator_args}
--build-project Qt4Deploy
- --build-options ${build_options}
- -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
- -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
+ --build-options
+ -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+ -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Deploy")
endif()
@@ -501,7 +589,7 @@ if(BUILD_TESTING)
--build-project ExternalDataTest
--build-noclean
--force-new-ctest-process
- --build-options ${build_options}
+ --build-options
-DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES}
--test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
)
@@ -517,7 +605,6 @@ if(BUILD_TESTING)
else()
if (CMAKE_CXX_COMPILER_ID MATCHES "PGI"
OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale"
- OR CMAKE_SYSTEM_NAME MATCHES "IRIX64"
OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set(run_pic_test 0)
else()
@@ -545,7 +632,6 @@ if(BUILD_TESTING)
"${CMake_BINARY_DIR}/Tests/Visibility"
${build_generator_args}
--build-project Visibility
- --build-options ${build_options}
)
list(APPEND TEST_BUILD_DIRS
"${CMake_BINARY_DIR}/Tests/Visibility"
@@ -560,7 +646,7 @@ if(BUILD_TESTING)
${build_generator_args}
--build-project LinkFlags
--build-target LinkFlags
- --build-options ${build_options}
+ --build-options
-DTEST_CONFIG=\${CTEST_CONFIGURATION_TYPE}
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkFlags")
@@ -605,7 +691,6 @@ if(BUILD_TESTING)
"CodeLite"
"Eclipse CDT4"
"Kate"
- "KDevelop3"
"Sublime Text 2")
foreach(extraGenerator ${extraGenerators})
@@ -622,7 +707,6 @@ if(BUILD_TESTING)
--build-generator-platform "${CMAKE_GENERATOR_PLATFORM}"
--build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
--build-project Simple
- --build-options ${build_options}
--test-command Simple)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${extraGeneratorTestName}")
endif ()
@@ -642,7 +726,6 @@ if(BUILD_TESTING)
--build-project SubProject
${build_generator_args}
--build-target car
- --build-options ${build_options}
--test-command car
)
@@ -668,7 +751,6 @@ if(BUILD_TESTING)
--build-project foo
--build-target foo
--build-exe-dir "${CMake_BINARY_DIR}/Tests/SubProject/foo"
- --build-options ${build_options}
--test-command foo
)
set_tests_properties ( SubProject-Stage2 PROPERTIES DEPENDS SubProject)
@@ -681,24 +763,23 @@ if(BUILD_TESTING)
set(_TEST_DIR "${CMake_BINARY_DIR}/Tests/${name}")
file(MAKE_DIRECTORY "${_TEST_DIR}")
file(WRITE "${_TEST_DIR}/nightly-cmake.sh"
- "cd ${_TEST_DIR}
+ "set -e
+cd ${_TEST_DIR}
${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script}
-${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake
+${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGHTLY_RELEASES}'
")
add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh)
if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY)
set_tests_properties (${name} PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
endif()
endmacro()
- if(CMAKE_BUILD_NIGHTLY_RELEASES)
+ if(CMake_BUILD_NIGHTLY_RELEASES)
ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin32
win32_release.cmake)
ADD_NIGHTLY_BUILD_TEST(CMakeNightlyWin64
win64_release.cmake)
ADD_NIGHTLY_BUILD_TEST(CMakeNightlyOSX
osx_release.cmake)
- ADD_NIGHTLY_BUILD_TEST(CMakeNightlyLinux64
- linux64_release.cmake)
set_property(TEST CMakeNightlyWin64 PROPERTY DEPENDS CMakeNightlyWin32)
endif()
@@ -710,7 +791,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-two-config
${build_generator_args}
--build-project Framework
- --build-options ${build_options}
+ --build-options
"-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/Framework/Install"
--test-command bar)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Framework")
@@ -722,7 +803,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-two-config
${build_generator_args}
--build-project TargetName
- --build-options ${build_options}
--test-command ${CMAKE_CMAKE_COMMAND} -E compare_files
${CMake_SOURCE_DIR}/Tests/TargetName/scripts/hello_world
${CMake_BINARY_DIR}/Tests/TargetName/scripts/hello_world)
@@ -736,7 +816,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project LibName
--build-exe-dir "${CMake_BINARY_DIR}/Tests/LibName/lib"
- --build-options ${build_options}
--test-command foobar
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LibName")
@@ -749,7 +828,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project CustComDepend
--build-exe-dir "${CMake_BINARY_DIR}/Tests/CustComDepend/bin"
- --build-options ${build_options}
--test-command foo bar.c
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustComDepend")
@@ -761,7 +839,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project ArgumentExpansion
--build-exe-dir "${CMake_BINARY_DIR}/Tests/ArgumentExpansion/bin"
- --build-options ${build_options}
)
set_tests_properties(ArgumentExpansion PROPERTIES
FAIL_REGULAR_EXPRESSION "Unexpected: ")
@@ -774,7 +851,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/GeneratorExpression"
${build_generator_args}
--build-project GeneratorExpression
- --build-options ${build_options}
+ --build-options
-DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE}
--test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} -V
)
@@ -788,13 +865,15 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project CustomCommand
--build-exe-dir "${CMake_BINARY_DIR}/Tests/CustomCommand/bin"
- --build-options ${build_options}
+ --build-options
--test-command CustomCommand
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommand")
ADD_TEST_MACRO(CustomCommandByproducts CustomCommandByproducts)
+ ADD_TEST_MACRO(CommandLength CommandLength)
+
ADD_TEST_MACRO(EmptyDepends ${CMAKE_CTEST_COMMAND})
add_test(CustomCommandWorkingDirectory ${CMAKE_CTEST_COMMAND}
@@ -804,36 +883,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-two-config
${build_generator_args}
--build-project TestWorkingDir
- --build-options ${build_options}
--test-command working
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CustomCommandWorkingDirectory")
- #add_test(SimpleExclude ${CMAKE_CTEST_COMMAND}
- # --build-and-test
- # "${CMake_SOURCE_DIR}/Tests/SimpleExclude"
- # "${CMake_BINARY_DIR}/Tests/SimpleExclude"
- # ${build_generator_args}
- # --build-project SimpleExclude
- # --build-two-config
- # --build-options ${build_options}
- # --test-command t4
- #--test-command "${CMAKE_COMMAND}"
- #"-DCONFIGURATION=\${CTEST_CONFIGURATION_TYPE}"
- #-P "${CMake_BINARY_DIR}/Tests/SimpleExclude/run.cmake"
- #)
-
-# add_test(SameName ${CMAKE_CTEST_COMMAND}
-# --build-and-test
-# "${CMake_SOURCE_DIR}/Tests/SameName"
-# "${CMake_BINARY_DIR}/Tests/SameName"
-# ${build_generator_args}
-# --build-project SameName
-# --build-two-config
-# --build-options ${build_options}
-# --test-command
-# "${CMake_BINARY_DIR}/Tests/SameName/Exe1/mytest2")
-
add_test(OutOfSource ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/OutOfSource"
@@ -841,7 +894,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project OutOfSource
--build-two-config
- --build-options ${build_options}
--test-command
"${CMake_BINARY_DIR}/Tests/OutOfSource/SubDir/OutOfSourceSubdir/simple")
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/OutOfSource")
@@ -854,37 +906,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/BuildDepends"
${build_generator_args}
--build-project BuildDepends
- --build-options ${build_options}
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BuildDepends")
- set(SimpleInstallInstallDir
- "${CMake_BINARY_DIR}/Tests/SimpleInstall/InstallDirectory")
- add_test(SimpleInstall ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/SimpleInstall"
- "${CMake_BINARY_DIR}/Tests/SimpleInstall"
- ${build_generator_args}
- --build-project TestSimpleInstall
- --build-two-config
- --build-options ${build_options}
- "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}"
- "-DCTEST_TEST_CPACK:BOOL=${CTEST_TEST_CPACK}"
- --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExe)
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstall")
- add_test(SimpleInstall-Stage2 ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/SimpleInstallS2"
- "${CMake_BINARY_DIR}/Tests/SimpleInstallS2"
- ${build_generator_args}
- --build-project TestSimpleInstall
- --build-two-config
- --build-options ${build_options}
- "-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}"
- "-DSTAGE2:BOOL=1"
- --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExeS2)
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleInstallS2")
-
set(MissingInstallInstallDir
"${CMake_BINARY_DIR}/Tests/MissingInstall/InstallDirectory")
add_test(MissingInstall ${CMAKE_CTEST_COMMAND}
@@ -894,7 +918,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project TestMissingInstall
--build-two-config
- --build-options ${build_options}
+ --build-options
"-DCMAKE_INSTALL_PREFIX:PATH=${MissingInstallInstallDir}")
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MissingInstall")
@@ -940,7 +964,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
${build_generator_args}
--build-project CPackWiXGenerator
- --build-options ${build_options}
+ --build-options
--test-command ${CMAKE_CMAKE_COMMAND}
"-DCPackWiXGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
"-Dconfig=\${CTEST_CONFIGURATION_TYPE}"
@@ -952,6 +976,44 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
endif()
endif()
+ if(CTEST_TEST_CPACK)
+ add_test(CPackUseDefaultVersion ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/CPackUseDefaultVersion"
+ "${CMake_BINARY_DIR}/Tests/CPackUseDefaultVersion"
+ ${build_generator_args}
+ --build-project CPackUseDefaultVersion
+ --build-two-config
+ --build-options
+ ${CPackUseDefaultVersion_BUILD_OPTIONS})
+ set_tests_properties(CPackUseDefaultVersion PROPERTIES PASS_REGULAR_EXPRESSION "CPACK_PACKAGE_VERSION=0\\.1\\.1")
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackUseDefaultVersion")
+
+ add_test(CPackUseProjectVersion ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/CPackUseProjectVersion"
+ "${CMake_BINARY_DIR}/Tests/CPackUseProjectVersion"
+ ${build_generator_args}
+ --build-project CPackUseProjectVersion
+ --build-two-config
+ --build-options
+ ${CPackUseProjectVersion_BUILD_OPTIONS})
+ set_tests_properties(CPackUseProjectVersion PROPERTIES PASS_REGULAR_EXPRESSION "CPACK_PACKAGE_VERSION=1\\.2\\.3")
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackUseProjectVersion")
+
+ add_test(CPackUseShortProjectVersion ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/CPackUseShortProjectVersion"
+ "${CMake_BINARY_DIR}/Tests/CPackUseShortProjectVersion"
+ ${build_generator_args}
+ --build-project CPackUseShortProjectVersion
+ --build-two-config
+ --build-options
+ ${CPackUseProjectVersion_BUILD_OPTIONS})
+ set_tests_properties(CPackUseShortProjectVersion PROPERTIES PASS_REGULAR_EXPRESSION "CPACK_PACKAGE_VERSION=2")
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CPackUseShortProjectVersion")
+ endif()
+
if(CTEST_RUN_CPackComponents)
set(CPackComponents_BUILD_OPTIONS)
if(APPLE)
@@ -974,7 +1036,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-project CPackComponents
--build-two-config
--build-target package
- --build-options ${build_options}
+ --build-options
-DCPACK_BINARY_DEB:BOOL=${CPACK_BINARY_DEB}
-DCPACK_BINARY_RPM:BOOL=${CPACK_BINARY_RPM}
${CPackComponents_BUILD_OPTIONS}
@@ -996,6 +1058,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
if(CPACK_BINARY_DEB)
list(APPEND ACTIVE_CPACK_GENERATORS DEB)
endif()
+ # Check whether if NuGet command is found
+ # before adding NuGet tests
+ if(CPACK_BINARY_NUGET)
+ list(APPEND ACTIVE_CPACK_GENERATORS NUGET)
+ set(CPACK_GENERATOR_STRING_NUGET NuGet)
+ endif()
# ACTIVE_CPACK_GENERATORS variable
# now contains the list of 'active generators'
@@ -1015,7 +1083,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
list(APPEND CWAYLST "IgnoreGroup")
list(APPEND CWAYLST "AllInOne")
foreach(CPackGen IN LISTS ACTIVE_CPACK_GENERATORS)
- set(CPackRun_CPackGen "-DCPackGen=${CPackGen}")
+ if(NOT DEFINED CPACK_GENERATOR_STRING_${CPackGen})
+ set(CPACK_GENERATOR_STRING_${CPackGen} ${CPackGen})
+ endif()
+ set(CPackRun_CPackGen "-DCPackGen=${CPACK_GENERATOR_STRING_${CPackGen}}")
foreach(CPackComponentWay ${CWAYLST})
set(CPackRun_CPackComponentWay "-DCPackComponentWay=${CPackComponentWay}")
add_test(CPackComponentsForAll-${CPackGen}-${CPackComponentWay}
@@ -1025,8 +1096,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/CPackComponentsForAll/build${CPackGen}-${CPackComponentWay}"
${build_generator_args}
--build-project CPackComponentsForAll
- --build-options ${build_options}
- -DCPACK_GENERATOR:STRING=${CPackGen}
+ --build-options
+ -DCPACK_GENERATOR:STRING=${CPACK_GENERATOR_STRING_${CPackGen}}
-DCPACK_BINARY_${CPackGen}:BOOL=ON
${CPackRun_CPackComponentWay}
${CPackComponentsForAll_BUILD_OPTIONS}
@@ -1064,7 +1135,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/${DEB_TEST_NAMES}/build${CPackGen}-${CPackDEBConfiguration}"
${build_generator_args}
--build-project CPackComponentsDEB
- --build-options ${build_options}
+ --build-options
-DCPACK_GENERATOR:STRING=${CPackGen}
-DCPACK_BINARY_${CPackGen}:BOOL=ON
${CPackRun_CPackDEBConfiguration}
@@ -1104,7 +1175,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators"
${build_generator_args}
--build-project CPackTestAllGenerators
- --build-options ${build_options}
--test-command
${CMAKE_CMAKE_COMMAND}
-D dir=${CMake_BINARY_DIR}/Tests/CPackTestAllGenerators
@@ -1135,7 +1205,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-project CPackComponentsPrefix
--build-two-config
--build-target package
- --build-options ${build_options}
+ --build-options
-DCPACK_BINARY_DEB:BOOL=${CPACK_BINARY_DEB}
-DCPACK_BINARY_RPM:BOOL=${CPACK_BINARY_RPM}
-DCPACK_BINARY_ZIP:BOOL=ON
@@ -1158,7 +1228,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-project UseX11
--build-two-config
${X11_build_target_arg}
- --build-options ${build_options}
--test-command UseX11)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/X11")
@@ -1201,7 +1270,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig"
${build_generator_args}
--build-project LoadCommand
- --build-options ${build_options}
--test-command LoadedCommand
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig")
@@ -1216,7 +1284,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project Complex
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Complex/bin"
- --build-options ${build_options}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
--test-command complex
)
@@ -1229,7 +1296,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project Complex
--build-exe-dir "${CMake_BINARY_DIR}/Tests/ComplexOneConfig/bin"
- --build-options ${build_options}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
--test-command complex)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ComplexOneConfig")
@@ -1244,7 +1310,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-project EnvironmentProj
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Environment"
--force-new-ctest-process
- --build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -V
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment")
@@ -1255,85 +1320,22 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/QtAutomocNoQt"
${build_generator_args}
--build-project QtAutomocNoQt
- --build-options ${build_options}
+ --build-options
-DCMAKE_BUILD_TYPE=\${CTEST_CONFIGURATION_TYPE}
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt")
- # On Windows there is no RPATH, so while Qt might be available for building,
- # the required dlls may not be in the PATH, so we can't run the executables
- # on that platform.
- if(WIN32)
- set(run_autogen_test ${CMAKE_CTEST_COMMAND} -V)
- set(run_autouic_test ${CMAKE_CTEST_COMMAND} -V)
- else()
- set(run_autogen_test complex/QtAutogen)
- set(run_autouic_test QtAutoUicInterface)
+ if(NOT DEFINED CMake_TEST_Qt5)
+ set(CMake_TEST_Qt5 1)
endif()
- if(NOT CMAKE_CONFIGURATION_TYPES)
- set(QtAutogen_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=$<CONFIGURATION>)
+ if(CMake_TEST_Qt5)
+ find_package(Qt5Widgets QUIET NO_MODULE)
endif()
-
- find_package(Qt5Widgets QUIET NO_MODULE)
- if(Qt5Widgets_FOUND)
- add_test(NAME Qt5Autogen COMMAND ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/QtAutogen"
- "${CMake_BINARY_DIR}/Tests/Qt5Autogen"
- ${build_generator_args}
- --build-project QtAutogen
- --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5Autogen"
- --force-new-ctest-process
- --build-options ${build_options}
- -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5
- ${QtAutogen_BUILD_OPTIONS}
- --test-command ${run_autogen_test}
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5Autogen")
-
- add_test(Qt5AutoUicInterface ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface"
- "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface"
- ${build_generator_args}
- --build-project QtAutoUicInterface
- --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface"
- --force-new-ctest-process
- --build-options ${build_options}
- -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=5
- --test-command ${run_autouic_test}
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt5AutoUicInterface")
+ if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND)
+ add_subdirectory(Qt5Autogen)
endif()
if(QT4_WORKS AND QT_QTGUI_FOUND)
- add_test(NAME Qt4Autogen COMMAND ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/QtAutogen"
- "${CMake_BINARY_DIR}/Tests/Qt4Autogen"
- ${build_generator_args}
- --build-project QtAutogen
- --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Autogen"
- --force-new-ctest-process
- --build-options ${build_options}
- -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4
- ${QtAutogen_BUILD_OPTIONS}
- --test-command ${run_autogen_test}
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Autogen")
-
- add_test(Qt4AutoUicInterface ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/QtAutoUicInterface"
- "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface"
- ${build_generator_args}
- --build-project QtAutoUicInterface
- --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface"
- --force-new-ctest-process
- --build-options ${build_options}
- -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} -DQT_TEST_VERSION=4
- --test-command ${run_autouic_test}
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4AutoUicInterface")
+ add_subdirectory(Qt4Autogen)
add_test(Qt4Targets ${CMAKE_CTEST_COMMAND}
--build-and-test
@@ -1343,25 +1345,24 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-project Qt4Targets
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4Targets"
--force-new-ctest-process
- --build-options ${build_options}
+ --build-options
-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
--test-command ${CMAKE_CTEST_COMMAND} -V
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Targets")
if(Qt5Widgets_FOUND AND NOT Qt5Widgets_VERSION VERSION_LESS 5.1.0)
- add_test(Qt4And5Automoc ${CMAKE_CTEST_COMMAND}
+ add_test(Qt4And5AutomocForward ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/Qt4And5Automoc"
- "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc"
+ "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocForward"
${build_generator_args}
--build-project Qt4And5Automoc
- --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc"
+ --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocForward"
--force-new-ctest-process
- --build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -V
)
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc")
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocForward")
add_test(Qt4And5AutomocReverse ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/Qt4And5Automoc"
@@ -1370,115 +1371,112 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-project Qt4And5Automoc
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocReverse"
--force-new-ctest-process
- --build-options ${build_options} -DQT_REVERSE_FIND_ORDER=1
+ --build-options -DQT_REVERSE_FIND_ORDER=1
--test-command ${CMAKE_CTEST_COMMAND} -V
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5AutomocReverse")
endif()
endif()
+ # test for Find modules, simple cases
+ foreach(_mod IN ITEMS
+ ALSA
+ Boost
+ BZip2
+ CURL
+ Cups
+ Doxygen
+ EnvModules
+ EXPAT
+ Fontconfig
+ Freetype
+ GDAL
+ GIF
+ Git
+ GLEW
+ GnuTLS
+ GSL
+ GTK2
+ Iconv
+ ICU
+ JPEG
+ JsonCpp
+ LibLZMA
+ LibRHash
+ Libinput
+ LibUV
+ LibXml2
+ LTTngUST
+ ODBC
+ OpenACC
+ OpenCL
+ OpenGL
+ OpenMP
+ OpenSSL
+ MPI
+ PNG
+ Patch
+ PostgreSQL
+ Protobuf
+ SQLite3
+ TIFF
+ Vulkan
+ X11
+ XalanC
+ XercesC
+ )
+ if(CMake_TEST_Find${_mod})
+ add_subdirectory(Find${_mod})
+ endif()
+ endforeach()
+
if(CMake_TEST_CUDA)
add_subdirectory(Cuda)
add_subdirectory(CudaOnly)
endif()
- if(CMake_TEST_FindBoost)
- add_subdirectory(FindBoost)
- endif()
-
- if(CMake_TEST_FindBZip2)
- add_subdirectory(FindBZip2)
- endif()
-
- if(CMake_TEST_FindDoxygen)
- add_subdirectory(FindDoxygen)
- endif()
-
- if(CMake_TEST_FindGSL)
- add_subdirectory(FindGSL)
- endif()
-
if(CMake_TEST_FindGTest)
add_subdirectory(FindGTest)
add_subdirectory(GoogleTest)
endif()
- if(CMake_TEST_FindICU)
- add_subdirectory(FindICU)
- endif()
-
- if(CMake_TEST_FindJsonCpp)
- add_subdirectory(FindJsonCpp)
- endif()
-
- if(CMake_TEST_FindLibRHash)
- add_subdirectory(FindLibRHash)
- endif()
-
- if(CMake_TEST_FindLibUV)
- add_subdirectory(FindLibUV)
- endif()
-
- if(CMake_TEST_FindLTTngUST)
- add_subdirectory(FindLTTngUST)
- endif()
-
- if(CMake_TEST_FindOpenCL)
- add_subdirectory(FindOpenCL)
- endif()
-
- if(CMake_TEST_FindOpenGL)
- add_subdirectory(FindOpenGL)
- endif()
-
- if(CMake_TEST_FindOpenMP)
- add_subdirectory(FindOpenMP)
- endif()
-
- if(CMake_TEST_FindOpenSSL)
- add_subdirectory(FindOpenSSL)
- endif()
-
- if(CMake_TEST_FindMPI)
- add_subdirectory(FindMPI)
+ if(CMake_TEST_FindPython OR CMake_TEST_FindPython_NumPy)
+ add_subdirectory(FindPython)
endif()
- if(CMake_TEST_FindPNG)
- add_subdirectory(FindPNG)
- endif()
-
- if(CMake_TEST_FindProtobuf)
- add_subdirectory(FindProtobuf)
- endif()
-
- if(CMake_TEST_FindTIFF)
- add_subdirectory(FindTIFF)
- endif()
-
- if(CMake_TEST_FindVulkan)
- add_subdirectory(FindVulkan)
- endif()
-
- if(CMake_TEST_FindXalanC)
- add_subdirectory(FindXalanC)
- endif()
-
- if(CMake_TEST_FindXercesC)
- add_subdirectory(FindXercesC)
+ if(CMake_TEST_UseSWIG)
+ add_subdirectory(UseSWIG)
endif()
add_subdirectory(FindThreads)
# Matlab module
- if(CMake_TEST_FindMatlab)
+ # CMake_TEST_FindMatlab: indicates to look for Matlab (from PATH for Linux)
+ # CMake_TEST_FindMatlab_ROOT_DIR: indicates an optional root directory for Matlab, allows to select a version.
+ # CMake_TEST_FindMatlab_MCR: indicates the MCR is installed
+ # CMake_TEST_FindMatlab_MCR_ROOT_DIR: indicates an optional root directory for the MCR, required on Linux
+ if(CMake_TEST_FindMatlab OR CMake_TEST_FindMatlab_ROOT_DIR OR
+ CMake_TEST_FindMatlab_MCR OR CMake_TEST_FindMatlab_MCR_ROOT_DIR)
+ set(FindMatlab_additional_test_options )
+ if(CMake_TEST_FindMatlab_MCR OR CMake_TEST_FindMatlab_MCR_ROOT_DIR)
+ set(FindMatlab_additional_test_options -DIS_MCR=TRUE)
+ endif()
+ if(CMake_TEST_FindMatlab_ROOT_DIR)
+ set(FindMatlab_additional_test_options ${FindMatlab_additional_test_options} "-DMatlab_ROOT_DIR=${CMake_TEST_FindMatlab_ROOT_DIR}")
+ endif()
+ if(CMake_TEST_FindMatlab_MCR_ROOT_DIR)
+ set(FindMatlab_additional_test_options ${FindMatlab_additional_test_options} "-DMCR_ROOT:FILEPATH=${CMake_TEST_FindMatlab_MCR_ROOT_DIR}")
+ endif()
+ set(FindMatlab.basic_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options})
ADD_TEST_MACRO(FindMatlab.basic_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
+ set(FindMatlab.versions_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options})
ADD_TEST_MACRO(FindMatlab.versions_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
+ set(FindMatlab.components_checks_BUILD_OPTIONS ${FindMatlab_additional_test_options})
ADD_TEST_MACRO(FindMatlab.components_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
- endif()
-
- find_package(GTK2 QUIET)
- if(GTK2_FOUND)
- add_subdirectory(FindGTK2)
+ set(FindMatlab.failure_reports_BUILD_OPTIONS ${FindMatlab_additional_test_options})
+ ADD_TEST_MACRO(FindMatlab.failure_reports ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
+ set(FindMatlab.r2018a_check_BUILD_OPTIONS ${FindMatlab_additional_test_options})
+ ADD_TEST_MACRO(FindMatlab.r2018a_check ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
endif()
add_test(ExternalProject ${CMAKE_CTEST_COMMAND}
@@ -1489,11 +1487,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-project ExternalProjectTest
--build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProject"
--force-new-ctest-process
- --build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -V
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProject")
set_tests_properties(ExternalProject PROPERTIES
+ RUN_SERIAL 1
TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
add_test(NAME ExternalProjectSubdir
@@ -1504,7 +1502,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project ExternalProjectSubdir
--force-new-ctest-process
- --build-options ${build_options}
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectSubdir")
@@ -1516,10 +1513,20 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project ExternalProjectSourceSubdir
--force-new-ctest-process
- --build-options ${build_options}
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdir")
+ add_test(NAME ExternalProjectSourceSubdirNotCMake
+ COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/ExternalProjectSourceSubdirNotCMake"
+ "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdirNotCMake"
+ ${build_generator_args}
+ --build-project ExternalProjectSourceSubdirNotCMake
+ --force-new-ctest-process
+ )
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectSourceSubdirNotCMake")
+
add_test(ExternalProjectLocal ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/ExternalProjectLocal"
@@ -1528,11 +1535,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-project ExternalProjectLocalTest
--build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProjectLocal"
--force-new-ctest-process
- --build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -V
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectLocal")
set_tests_properties(ExternalProjectLocal PROPERTIES
+ RUN_SERIAL 1
TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
add_test(ExternalProjectUpdateSetup ${CMAKE_CTEST_COMMAND}
@@ -1543,11 +1550,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-project ExternalProjectUpdateTest
--build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate"
--force-new-ctest-process
- --build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -V
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate")
set_tests_properties(ExternalProjectUpdateSetup PROPERTIES
+ RUN_SERIAL 1
TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
add_test(NAME ExternalProjectUpdate
@@ -1562,23 +1569,43 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate")
set_tests_properties(ExternalProjectUpdate PROPERTIES
+ RUN_SERIAL 1
TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}
WORKING_DIRECTORY ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate
DEPENDS ExternalProjectUpdateSetup )
# do each of the tutorial steps
- foreach(STP RANGE 1 7)
- add_test(TutorialStep${STP} ${CMAKE_CTEST_COMMAND}
+ function(add_tutorial_test step_name use_mymath)
+ set(tutorial_test_name Tutorial${step_name})
+ set(tutorial_build_dir "${CMake_BINARY_DIR}/Tests/Tutorial/${step_name}")
+ if (use_mymath)
+ set(tutorial_build_options "")
+ else()
+ set(tutorial_test_name ${tutorial_test_name}_MYMATH)
+ set(tutorial_build_dir "${tutorial_build_dir}_MYMATH")
+ set(tutorial_build_options -DUSE_MYMATH:BOOL=OFF)
+ endif()
+ add_test(${tutorial_test_name} ${CMAKE_CTEST_COMMAND}
--build-and-test
- "${CMake_SOURCE_DIR}/Tests/Tutorial/Step${STP}"
- "${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}"
- --build-two-config
+ "${CMake_SOURCE_DIR}/Help/guide/tutorial/${step_name}"
+ ${tutorial_build_dir}_Build
${build_generator_args}
--build-project Tutorial
- --build-options ${build_options}
+ --build-options ${tutorial_build_options}
--test-command Tutorial 25.0)
- endforeach()
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Tutorial")
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/${tutorial_build_dir}_Build")
+ endfunction()
+
+ if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ foreach(STP RANGE 2 11)
+ add_tutorial_test(Step${STP} TRUE)
+ endforeach()
+ add_tutorial_test(Complete TRUE)
+ foreach(STP RANGE 3 11)
+ add_tutorial_test(Step${STP} FALSE)
+ endforeach()
+ add_tutorial_test(Complete FALSE)
+ endif()
add_test(testing ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
--build-and-test
@@ -1586,7 +1613,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/Testing"
${build_generator_args}
--build-project Testing
- --build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}
)
set_tests_properties(testing PROPERTIES PASS_REGULAR_EXPRESSION "Passed")
@@ -1599,7 +1625,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project Wrapping
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
- --build-options ${build_options}
--test-command wrapping
)
add_test(qtwrapping ${CMAKE_CTEST_COMMAND}
@@ -1609,7 +1634,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project Wrapping
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
- --build-options ${build_options}
--test-command qtwrapping
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Wrapping")
@@ -1621,7 +1645,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
--build-project TestDriverTest
- --build-options ${build_options}
--test-command TestDriverTest test1
)
@@ -1632,7 +1655,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
--build-project TestDriverTest
- --build-options ${build_options}
--test-command TestDriverTest test2
)
@@ -1643,7 +1665,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Wrapping/bin"
--build-project TestDriverTest
- --build-options ${build_options}
--test-command TestDriverTest subdir/test3
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestDriver")
@@ -1655,7 +1676,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Dependency/Exec"
${build_generator_args}
--build-project Dependency
- --build-options ${build_options}
--test-command exec
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Dependency")
@@ -1685,8 +1705,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-exe-dir "${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Executable"
--build-project Jump
${build_generator_args}
- --build-options ${build_options}
- -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Lib
+ --build-options
+ -DLIBRARY_OUTPUT_PATH:PATH=${CMake_BINARY_DIR}/Tests/Jump/WithLibOut/Lib
--test-command jumpExecutable
)
@@ -1698,7 +1718,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-run-dir "${CMake_BINARY_DIR}/Tests/Jump/NoLibOut/Executable"
--build-project Jump
${build_generator_args}
- --build-options ${build_options}
--test-command jumpExecutable
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Jump")
@@ -1710,7 +1729,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project Plugin
--build-two-config
- --build-options ${build_options}
--test-command bin/example)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Plugin")
@@ -1726,7 +1744,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/MacRuntimePath"
${build_generator_args}
--build-project MacRuntimePath
- --build-options ${build_options}
+ --build-options
-DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
)
endif()
@@ -1744,7 +1762,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/LinkLineOrder"
${build_generator_args}
--build-project LinkLineOrder
- --build-options ${build_options}
--test-command Exec1
)
@@ -1754,7 +1771,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/LinkLineOrder"
${build_generator_args}
--build-project LinkLineOrder
- --build-options ${build_options}
--test-command Exec2
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkLineOrder")
@@ -1763,7 +1779,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
set_tests_properties ( testdriver2 PROPERTIES DEPENDS testdriver1)
set_tests_properties ( testdriver3 PROPERTIES DEPENDS testdriver2)
set_tests_properties ( linkorder2 PROPERTIES DEPENDS linkorder1)
- set_tests_properties ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall)
# Test static linking on toolchains known to support it.
if(CMAKE_C_COMPILER_ID STREQUAL "GNU"
@@ -1775,7 +1790,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/LinkStatic"
${build_generator_args}
--build-project LinkStatic
- --build-options ${build_options}
+ --build-options
-DMATH_LIBRARY:FILEPATH=/usr/lib/libm.a
--test-command LinkStatic
)
@@ -1790,7 +1805,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/SubDirSpaces/Executable Sources"
${build_generator_args}
--build-project SUBDIR
- --build-options ${build_options}
--test-command test
"${CMake_BINARY_DIR}/Tests/SubDirSpaces/ShouldBeHere"
"${CMake_BINARY_DIR}/Tests/SubDirSpaces/testfromsubdir.obj"
@@ -1806,7 +1820,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable"
${build_generator_args}
--build-project SUBDIR
- --build-options ${build_options}
--test-command test
"${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere"
"${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.obj"
@@ -1819,7 +1832,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-exe-dir "${CMake_BINARY_DIR}/Tests/SubDir/Executable"
${build_generator_args}
--build-project SUBDIR
- --build-options ${build_options}
--test-command test
"${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere"
"${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.o"
@@ -1827,12 +1839,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
endif ()
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDir")
- if(MSVC)
- ADD_TEST_MACRO(ForceInclude foo)
+ if(MSVC OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_SIMULATE_ID STREQUAL "MSVC"))
ADD_TEST_MACRO(PDBDirectoryAndName myexe)
+ if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" OR NOT "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
+ ADD_TEST_MACRO(ForceInclude foo)
+ endif()
if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
ADD_TEST_MACRO(PrecompiledHeader foo)
endif()
+ set(MSVCRuntimeLibrary_BUILD_OPTIONS -DCMake_TEST_CUDA=${CMake_TEST_CUDA})
+ ADD_TEST_MACRO(MSVCRuntimeLibrary)
+ if(CMAKE_Fortran_COMPILER)
+ ADD_TEST_MACRO(MSVCRuntimeLibrary.Fortran)
+ endif()
endif()
if(MSVC OR
"${CMAKE_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles")
@@ -1841,7 +1860,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables)
- if("${CMAKE_GENERATOR}" MATCHES "Makefile")
+ if("${CMAKE_GENERATOR}" MATCHES "Makefile" OR
+ "${CMAKE_GENERATOR}" MATCHES "Ninja")
add_test(MakeClean ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/MakeClean"
@@ -1849,7 +1869,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project MakeClean
--build-exe-dir "${CMake_BINARY_DIR}/MakeClean"
- --build-options ${build_options}
--test-command check_clean
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MakeClean")
@@ -1882,6 +1901,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
message(STATUS
".vcproj file association indicates VCExpress, avoiding MFC test")
set(CTEST_RUN_MFC OFF)
+ elseif( NOT ov )
+ message(STATUS
+ ".vcproj has no file association, avoiding MFC test")
+ set(CTEST_RUN_MFC OFF)
endif()
endif()
@@ -1954,14 +1977,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-two-config
${build_generator_args}
--build-project mfc_driver
- --build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND}
-C \${CTEST_CONFIGURATION_TYPE} -VV)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC")
endif()
if(MSVC AND NOT MSVC_VERSION LESS 1310
- AND (NOT CMAKE_GENERATOR MATCHES "Visual Studio [89]( |$)"
+ AND (NOT CMAKE_GENERATOR MATCHES "Visual Studio 9 "
OR CMAKE_SIZEOF_VOID_P EQUAL 4)
)
ADD_TEST_MACRO(VSMASM VSMASM)
@@ -1972,7 +1994,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
ADD_TEST_MACRO(SBCS SBCS)
endif()
- if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio [89]( |$)"
+ if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio 9 "
AND NOT CMAKE_GENERATOR_TOOLSET)
ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx)
endif()
@@ -1984,7 +2006,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-two-config
${build_generator_args}
--build-project VSExternalInclude
- --build-options ${build_options}
--test-command VSExternalInclude)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExternalInclude")
@@ -1995,7 +2016,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-two-config
${build_generator_args}
--build-project VSMidl
- --build-options ${build_options}
--test-command VSMidl)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl")
@@ -2046,75 +2066,35 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
endif()
endif()
- if(WIN32)
- # Macro to search for available Windows CE SDKs in the windows Registry
- macro(select_wince_sdk selected_reg selected_sdk)
- if(CMAKE_HOST_WIN32)
- execute_process(COMMAND reg QUERY "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs"
- OUTPUT_VARIABLE sdk_reg
- ERROR_VARIABLE my_err)
- string(REGEX REPLACE "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Wow6432Node\\\\Microsoft\\\\Windows CE Tools\\\\SDKs\\\\" ";" sdk_list "${sdk_reg}")
- list(LENGTH sdk_list sdk_list_len)
- if (${sdk_list_len} GREATER 1)
- list(GET sdk_list 1 _sdk) # The first entry is always empty due to the regex replace above
- string(STRIP ${_sdk} _sdk) # Make sure there is no newline in the SDK name
- endif()
- # Build a key to be used by get_filename_component that is pointing to the SDK directory
- set(_reg "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows CE Tools\\SDKs\\${_sdk}]")
-
- # Set return values
- set(${selected_reg} ${_reg})
- set(${selected_sdk} ${_sdk})
- endif(CMAKE_HOST_WIN32)
- endmacro(select_wince_sdk)
-
- set(reg_vs10 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]")
- set(reg_vs11 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;InstallDir]")
- set(reg_vs12 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0;InstallDir]")
- set(reg_vs14 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]")
- set(reg_ws80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]")
- set(reg_ws81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]")
- set(reg_ws10_0 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0\\Setup\\Build Tools for Windows 10;srcPath]")
- set(reg_wp80 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.0;InstallationFolder]")
- set(reg_wp81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.1;InstallationFolder]")
- select_wince_sdk(reg_wince wince_sdk)
- set(reg_tegra "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;sdkRoot]")
- set(reg_nasm "[HKEY_CURRENT_USER\\SOFTWARE\\nasm]")
- foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra nasm)
- get_filename_component(r "${reg_${reg}}" ABSOLUTE)
- if(IS_DIRECTORY "${r}")
- set(${reg} 1)
- else()
- set(${reg} 0)
- endif()
- endforeach()
- endif()
-
get_filename_component(ntver "[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion;CurrentVersion]" NAME)
if(WIN32 AND ntver VERSION_GREATER 6.1) # Windows >= 8.0
- macro(add_test_VSWinStorePhone name generator systemName systemVersion)
+ macro(add_test_VSWinStorePhone name generator systemName systemVersion architecture)
add_test(NAME VSWinStorePhone.${name} COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/VSWinStorePhone"
"${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}"
--build-generator "${generator}"
+ --build-generator-platform "${architecture}"
--build-project VSWinStorePhone
--build-config $<CONFIGURATION>
--build-options -DCMAKE_SYSTEM_NAME=${systemName}
-DCMAKE_SYSTEM_VERSION=${systemVersion}
+ --test-command
+ ${CMAKE_CMAKE_COMMAND} -DAPP_PACKAGE_DIR="${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}"
+ -P "${CMake_SOURCE_DIR}/Tests/VSWinStorePhone/VerifyAppPackage.cmake"
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSWinStorePhone/${name}")
endmacro()
if(vs11 AND ws80)
- add_test_VSWinStorePhone(vs11-store80-X86 "Visual Studio 11 2012" WindowsStore 8.0)
- add_test_VSWinStorePhone(vs11-store80-ARM "Visual Studio 11 2012 ARM" WindowsStore 8.0)
- add_test_VSWinStorePhone(vs11-store80-X64 "Visual Studio 11 2012 Win64" WindowsStore 8.0)
+ add_test_VSWinStorePhone(vs11-store80-X86 "Visual Studio 11 2012" WindowsStore 8.0 Win32)
+ add_test_VSWinStorePhone(vs11-store80-ARM "Visual Studio 11 2012" WindowsStore 8.0 ARM)
+ add_test_VSWinStorePhone(vs11-store80-X64 "Visual Studio 11 2012" WindowsStore 8.0 x64)
endif()
if(vs12 AND ws81)
- add_test_VSWinStorePhone(vs12-store81-X86 "Visual Studio 12 2013" WindowsStore 8.1)
- add_test_VSWinStorePhone(vs12-store81-ARM "Visual Studio 12 2013 ARM" WindowsStore 8.1)
- add_test_VSWinStorePhone(vs12-store81-X64 "Visual Studio 12 2013 Win64" WindowsStore 8.1)
+ add_test_VSWinStorePhone(vs12-store81-X86 "Visual Studio 12 2013" WindowsStore 8.1 Win32)
+ add_test_VSWinStorePhone(vs12-store81-ARM "Visual Studio 12 2013" WindowsStore 8.1 ARM)
+ add_test_VSWinStorePhone(vs12-store81-X64 "Visual Studio 12 2013" WindowsStore 8.1 x64)
add_test(NAME VSXaml COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test
@@ -2127,18 +2107,24 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
-DCMAKE_SYSTEM_VERSION=8.1
)
endif()
+ if(CMake_TEST_VSWinStorePhone_VS_2017 AND ws10_0)
+ add_test_VSWinStorePhone(vs15-store10_0-X86 "Visual Studio 15 2017" WindowsStore 10.0 Win32)
+ add_test_VSWinStorePhone(vs15-store10_0-ARM "Visual Studio 15 2017" WindowsStore 10.0 ARM)
+ add_test_VSWinStorePhone(vs15-store10_0-X64 "Visual Studio 15 2017" WindowsStore 10.0 x64)
+ add_test_VSWinStorePhone(vs15-store10_0-ARM64 "Visual Studio 15 2017" WindowsStore 10.0 ARM64)
+ endif()
if(vs14 AND ws10_0)
- add_test_VSWinStorePhone(vs14-store10_0-X86 "Visual Studio 14 2015" WindowsStore 10.0)
- add_test_VSWinStorePhone(vs14-store10_0-ARM "Visual Studio 14 2015 ARM" WindowsStore 10.0)
- add_test_VSWinStorePhone(vs14-store10_0-X64 "Visual Studio 14 2015 Win64" WindowsStore 10.0)
+ add_test_VSWinStorePhone(vs14-store10_0-X86 "Visual Studio 14 2015" WindowsStore 10.0 Win32)
+ add_test_VSWinStorePhone(vs14-store10_0-ARM "Visual Studio 14 2015" WindowsStore 10.0 ARM)
+ add_test_VSWinStorePhone(vs14-store10_0-X64 "Visual Studio 14 2015" WindowsStore 10.0 x64)
endif()
if(vs11 AND wp80)
- add_test_VSWinStorePhone(vs11-phone80-X86 "Visual Studio 11 2012" WindowsPhone 8.0)
- add_test_VSWinStorePhone(vs11-phone80-ARM "Visual Studio 11 2012 ARM" WindowsPhone 8.0)
+ add_test_VSWinStorePhone(vs11-phone80-X86 "Visual Studio 11 2012" WindowsPhone 8.0 Win32)
+ add_test_VSWinStorePhone(vs11-phone80-ARM "Visual Studio 11 2012" WindowsPhone 8.0 ARM)
endif()
if(vs12 AND wp81)
- add_test_VSWinStorePhone(vs12-phone81-X86 "Visual Studio 12 2013" WindowsPhone 8.1)
- add_test_VSWinStorePhone(vs12-phone81-ARM "Visual Studio 12 2013 ARM" WindowsPhone 8.1)
+ add_test_VSWinStorePhone(vs12-phone81-X86 "Visual Studio 12 2013" WindowsPhone 8.1 Win32)
+ add_test_VSWinStorePhone(vs12-phone81-ARM "Visual Studio 12 2013" WindowsPhone 8.1 ARM)
endif()
endif()
@@ -2146,11 +2132,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
macro(add_test_VSWinCE name generator systemName systemVersion generatorPlatform)
# TODO: Fix the tutorial to make it work in cross compile
# currently the MakeTable is build for target and can not be used on the host
- # This happens in part 5 so we build only part 1-4 of the tutorial
- foreach(STP RANGE 1 4)
+ # This happens in part 5 so we build only through part 4 of the tutorial.
+ foreach(STP RANGE 2 4)
add_test(NAME "TutorialStep${STP}.${name}" COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test
- "${CMake_SOURCE_DIR}/Tests/Tutorial/Step${STP}"
+ "${CMake_SOURCE_DIR}/Help/guide/tutorial/Step${STP}"
"${CMake_BINARY_DIR}/Tests/Tutorial/Step${STP}_${name}"
--build-generator "${generator}"
--build-project Tutorial
@@ -2171,37 +2157,113 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
endif()
endif()
- if(CMAKE_GENERATOR MATCHES "Visual Studio ([^89]|[89][0-9])" AND nasm)
+ if(CMAKE_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])" AND nasm)
ADD_TEST_MACRO(VSNASM VSNASM)
endif()
if (CMake_TEST_GreenHillsMULTI)
- macro(add_test_GhsMulti name primaryTarget bspName)
- add_test(NAME GhsMulti.${name} COMMAND ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/GhsMulti"
- "${CMake_BINARY_DIR}/Tests/GhsMulti/${name}"
- --build-generator "Green Hills MULTI"
- --build-project ReturnNum
- --build-config $<CONFIGURATION>
- --build-options -DGHS_PRIMARY_TARGET=${primaryTarget}
- -DGHS_BSP_NAME=${bspName}
- )
- endmacro ()
- add_test_GhsMulti("arm_integrity_simarm" "arm_integrity.tgt" "simarm")
- add_test_GhsMulti("arm64_integrity_simarm" "arm64_integrity.tgt" "simarm")
- add_test(NAME GhsMulti.duplicate_source_filenames
+ macro(add_test_GhsMulti test_name test_dir bin_sub_dir build_opts)
+ separate_arguments(_ghs_build_opts UNIX_COMMAND ${build_opts})
+ separate_arguments(_ghs_toolset_extra UNIX_COMMAND ${ghs_toolset_extra})
+ if(${ARGC} GREATER 4)
+ set(_ghs_test_command --test-command ${ARGN})
+ endif()
+ if(ghs_config_name STREQUAL "__default__")
+ set(_ghs_test_name "${test_name}")
+ else()
+ set(_ghs_test_name "${ghs_config_name}.${test_name}")
+ endif()
+ add_test(NAME GhsMulti.${_ghs_test_name}
COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test
- "${CMake_SOURCE_DIR}/Tests/GhsMultiDuplicateSourceFilenames"
- "${CMake_BINARY_DIR}/Tests/GhsMultiDuplicateSourceFilenames"
+ "${CMake_SOURCE_DIR}/Tests/GhsMulti/${test_dir}"
+ "${CMake_BINARY_DIR}/Tests/GhsMulti/${ghs_config_name}/${test_dir}/${bin_sub_dir}"
--build-generator "Green Hills MULTI"
- --build-project ReturnNum
+ --build-project test
--build-config $<CONFIGURATION>
- --build-options -DGHS_PRIMARY_TARGET="arm_integrity.tgt"
- -DGHS_BSP_NAME="simarm"
+ --force-new-ctest-process
+ --build-options ${ghs_target_arch} ${ghs_toolset_name} ${ghs_toolset_root} ${ghs_target_platform}
+ ${ghs_os_root} ${ghs_os_dir} ${ghs_bsp_name} ${_ghs_build_opts} ${_ghs_toolset_extra}
+ ${_ghs_test_command}
)
- endif ()
+ unset(_ghs_build_opts)
+ unset(_ghs_toolset_extra)
+ unset(_ghs_test_command)
+ unset(_ghs_test_name)
+ endmacro()
+ macro(add_test_GhsMulti_rename_install test_name)
+ add_test_GhsMulti( ${test_name} GhsMultiRenameInstall ${test_name}
+ "-DCMAKE_INSTALL_PREFIX=. -DRUN_TEST=${test_name}" ${CMAKE_CMAKE_COMMAND} --build . --target install)
+ endmacro()
+ #unset ghs config variables
+ unset(ghs_config_name)
+ unset(ghs_target_arch)
+ unset(ghs_toolset_root)
+ unset(ghs_toolset_name)
+ unset(ghs_os_root)
+ unset(ghs_os_dir)
+ unset(ghs_target_platform)
+ unset(ghs_bsp_name)
+ unset(ghs_toolset_extra)
+ if(NOT CMake_TEST_GreenHillsMULTI_config)
+ #if list of config settings not defined then just run once as default
+ set(CMake_TEST_GreenHillsMULTI_config "__default__")
+ endif()
+ foreach(ghs_file IN LISTS CMake_TEST_GreenHillsMULTI_config)
+ # source GHS tools config file
+ if(NOT ghs_file STREQUAL "__default__")
+ if(IS_ABSOLUTE ${ghs_file})
+ include(${ghs_file})
+ else()
+ include(${CMAKE_BINARY_DIR}/${ghs_file})
+ endif()
+ endif()
+ if(NOT ghs_config_name)
+ set(ghs_config_name "__default__")
+ endif()
+ # test integrity build
+ if (NOT ghs_skip_integrity AND (NOT ghs_target_platform OR ghs_target_platform MATCHES "integrity"))
+ add_test_GhsMulti(integrityDDInt GhsMultiIntegrity/GhsMultiIntegrityDDInt "" "")
+ add_test_GhsMulti(integrityMonolith GhsMultiIntegrity/GhsMultiIntegrityMonolith "" "")
+ add_test_GhsMulti(integrityDD GhsMultiIntegrity/GhsMultiIntegrityDD "" "")
+ endif()
+ add_test_GhsMulti(duplicate_source_filenames GhsMultiDuplicateSourceFilenames "" "")
+ add_test_GhsMulti_rename_install(SINGLE_EXEC)
+ add_test_GhsMulti_rename_install(SINGLE_EXEC_RENAMED)
+ add_test_GhsMulti_rename_install(EXEC_AND_LIB)
+ add_test_GhsMulti(multiple_source_groups GhsMultiSrcGroups Default "")
+ add_test_GhsMulti(multiple_source_groups_folders GhsMultiSrcGroups PropFolders "-DTEST_PROP=ON")
+ add_test_GhsMulti(multiple_source_groups_all_folders GhsMultiSrcGroups AllFolders "-DCMAKE_GHS_NO_SOURCE_GROUP_FILE=ON")
+ add_test_GhsMulti(unsupported_targets GhsMultiUnsupportedTargets "" "")
+ add_test_GhsMulti(object_library GhsMultiObjectLibrary "" "")
+ add_test_GhsMulti(exclude GhsMultiExclude "" ""
+ ${CMAKE_CMAKE_COMMAND} -P ${CMake_SOURCE_DIR}/Tests/GhsMulti/GhsMultiExclude/verify.cmake)
+ add_test_GhsMulti(interface GhsMultiInterface "" "")
+ add_test_GhsMulti(transitive_link_test GhsMultiLinkTest TransitiveLink "-DRUN_TEST=NO_FLAGS")
+ add_test_GhsMulti(flags_link_test GhsMultiLinkTest FlagsCheck "-DRUN_TEST=CHECK_FLAGS")
+ add_test_GhsMulti(sub_link_test GhsMultiLinkTestSub "" "")
+ add_test_GhsMulti(multiple_projects GhsMultiMultipleProjects "" ""
+ ${CMAKE_CMAKE_COMMAND} -P ${CMake_SOURCE_DIR}/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake)
+ add_test_GhsMulti(compiler_options_none GhsMultiCompilerOptions None "-DRUN_TEST=RELEASE_FLAGS -DRUN_TEST_BUILD_TYPE=\"\"")
+ add_test_GhsMulti(compiler_options_kernel GhsMultiCompilerOptions Kernel "-DRUN_TEST=KERNEL_FLAGS -DRUN_TEST_BUILD_TYPE=DEBUG")
+ add_test_GhsMulti(try_compile_copy GhsMultiCopyFile "" "")
+ add_test_GhsMulti(ghs_platform GhsMultiPlatform "" "")
+ add_test_GhsMulti(custom_target GhsMultiCustomTarget "" "")
+ add_test_GhsMulti(dep_order GhsMultiDepOrder "" "")
+ add_test_GhsMulti(external_project GhsMultiExternalProject "" "")
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/GhsMulti/${ghs_config_name}")
+ #unset ghs config variables
+ unset(ghs_config_name)
+ unset(ghs_target_arch)
+ unset(ghs_toolset_root)
+ unset(ghs_toolset_name)
+ unset(ghs_os_root)
+ unset(ghs_os_dir)
+ unset(ghs_target_platform)
+ unset(ghs_bsp_name)
+ unset(ghs_toolset_extra)
+ endforeach()
+ endif()
if(tegra AND NOT "${CMake_SOURCE_DIR};${CMake_BINARY_DIR}" MATCHES " ")
macro(add_test_VSNsightTegra name generator)
@@ -2243,7 +2305,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-project BundleTest
--build-target install
# --build-target package
- --build-options ${build_options}
+ --build-options
"-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}"
"-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}"
--test-command
@@ -2258,7 +2320,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project CFBundleTest
--build-config $<CONFIGURATION>
- --build-options ${build_options}
--test-command
${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=$<CONFIGURATION>
-Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest
@@ -2266,7 +2327,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
-P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest")
- ADD_TEST_MACRO(ObjC++ ObjC++)
+ add_subdirectory(ObjC)
+ add_subdirectory(ObjCXX)
endif ()
endif ()
@@ -2279,7 +2341,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project BundleGeneratorTest
--build-target package
- --build-options ${build_options}
+ --build-options
"-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/BundleGeneratorTest/InstallDirectory"
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest")
@@ -2292,7 +2354,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-noclean
--build-project WarnUnusedUnusedViaSet
- --build-options ${build_options}
+ --build-options
"--warn-unused-vars")
set_tests_properties(WarnUnusedUnusedViaSet PROPERTIES
PASS_REGULAR_EXPRESSION "unused variable \\(changing definition\\) 'UNUSED_VARIABLE'")
@@ -2307,7 +2369,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-noclean
--build-project WarnUnusedUnusedViaUnset
- --build-options ${build_options}
+ --build-options
"--warn-unused-vars")
set_tests_properties(WarnUnusedUnusedViaUnset PROPERTIES
PASS_REGULAR_EXPRESSION "CMake Warning \\(dev\\) at CMakeLists.txt:7 \\(set\\):")
@@ -2315,24 +2377,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
FAIL_REGULAR_EXPRESSION "CMakeLists.txt:5 \\(set\\):")
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset")
- if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND NOT WIN32)
- # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails
- # this test. (See #13371)
- # Apparently Visual Studio does not support it either. As the MakeClean
- # test above is only run with the Makefiles generator, only run this
- # test with the Makefiles generator also.
- add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused"
- "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused"
- ${build_generator_args}
- --build-project WarnUnusedCliUnused
- --build-options ${build_options}
- "-DUNUSED_CLI_VARIABLE=Unused")
- set_tests_properties(WarnUnusedCliUnused PROPERTIES
- PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE")
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
- endif()
+ add_test(WarnUnusedCliUnused ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/WarnUnusedCliUnused"
+ "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused"
+ ${build_generator_args}
+ --build-project WarnUnusedCliUnused
+ --build-options
+ "-DUNUSED_CLI_VARIABLE=Unused")
+ set_tests_properties(WarnUnusedCliUnused PROPERTIES
+ PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE")
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused")
add_test(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND}
--build-and-test
@@ -2341,7 +2396,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-noclean
--build-project WarnUnusedCliUsed
- --build-options ${build_options}
+ --build-options
"-DUSED_VARIABLE=Usage proven")
set_tests_properties(WarnUnusedCliUsed PROPERTIES
PASS_REGULAR_EXPRESSION "Usage proven")
@@ -2356,7 +2411,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-noclean
--build-project WarnUninitialized
- --build-options ${build_options}
+ --build-options
"--warn-uninitialized")
set_tests_properties(WarnUninitialized PROPERTIES
PASS_REGULAR_EXPRESSION "uninitialized variable 'USED_VARIABLE'")
@@ -2371,7 +2426,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-project TestsWorkingDirectoryProj
--build-exe-dir "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory"
--force-new-ctest-process
- --build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -V -C \${CTEST_CONFIGURATION_TYPE}
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory")
@@ -2568,16 +2622,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
PASS_REGULAR_EXPRESSION "Could not find executable"
FAIL_REGULAR_EXPRESSION "SegFault")
- configure_file(
- "${CMake_SOURCE_DIR}/Tests/CTestTestUpload/test.cmake.in"
- "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake"
- @ONLY ESCAPE_QUOTES)
- add_test(CTestTestUpload ${CMAKE_CTEST_COMMAND}
- -S "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake" -V
- --output-log "${CMake_BINARY_DIR}/Tests/CTestTestUpload/testOut.log"
- )
- set_tests_properties(CTestTestUpload PROPERTIES
- PASS_REGULAR_EXPRESSION "Upload\\.xml")
+ if(NOT CMake_TEST_NO_NETWORK)
+ configure_file(
+ "${CMake_SOURCE_DIR}/Tests/CTestTestUpload/test.cmake.in"
+ "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake"
+ @ONLY ESCAPE_QUOTES)
+ add_test(CTestTestUpload ${CMAKE_CTEST_COMMAND}
+ -S "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake" -V
+ --output-log "${CMake_BINARY_DIR}/Tests/CTestTestUpload/testOut.log"
+ )
+ set_tests_properties(CTestTestUpload PROPERTIES
+ PASS_REGULAR_EXPRESSION "Upload\\.xml")
+ endif()
configure_file(
"${CMake_SOURCE_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake.in"
@@ -2617,12 +2673,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCoverage")
add_test(NAME CTestGTMCoverage
- COMMAND cmake -E chdir
+ COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir
${CMake_BINARY_DIR}/Testing/MumpsCoverage
$<TARGET_FILE:ctest> -T Coverage --debug)
set_tests_properties(CTestGTMCoverage PROPERTIES
PASS_REGULAR_EXPRESSION
- "Process file.*ZZCOVTST.m.*Total LOC:.*30.*Percentage Coverage: 80.00*"
+ "Process file.*ZZCOVTST.m.*Total LOC:.*32.*Percentage Coverage: 81.25*"
ENVIRONMENT COVFILE=)
configure_file(
@@ -2635,12 +2691,12 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
file(COPY "${CMake_SOURCE_DIR}/Tests/MumpsCoverage/VistA-FOIA"
DESTINATION "${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage")
add_test(NAME CTestCacheCoverage
- COMMAND cmake -E chdir
+ COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir
${CMake_BINARY_DIR}/Testing/MumpsCacheCoverage
$<TARGET_FILE:ctest> -T Coverage --debug)
set_tests_properties(CTestCacheCoverage PROPERTIES
PASS_REGULAR_EXPRESSION
- "Process file.*ZZCOVTST.m.*Total LOC:.*29.*Percentage Coverage: 86.21.*"
+ "Process file.*ZZCOVTST.m.*Total LOC:.*32.*Percentage Coverage: 87.50.*"
ENVIRONMENT COVFILE=)
# Adding a test case for Python Coverage
@@ -2653,7 +2709,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
file(COPY "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coveragetest"
DESTINATION "${CMake_BINARY_DIR}/Testing/PythonCoverage")
add_test(NAME CTestPythonCoverage
- COMMAND cmake -E chdir
+ COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir
${CMake_BINARY_DIR}/Testing/PythonCoverage
$<TARGET_FILE:ctest> -T Coverage --debug)
set_tests_properties(CTestPythonCoverage PROPERTIES
@@ -2671,7 +2727,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
file(COPY "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/src"
DESTINATION "${CMake_BINARY_DIR}/Testing/CoberturaCoverage")
add_test(NAME CTestCoberturaCoverage
- COMMAND cmake -E chdir
+ COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir
${CMake_BINARY_DIR}/Testing/CoberturaCoverage
$<TARGET_FILE:ctest> -T Coverage --debug)
set_tests_properties(CTestCoberturaCoverage PROPERTIES
@@ -2690,7 +2746,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
configure_file("${CMake_BINARY_DIR}/Testing/JacocoCoverage/Coverage/target/site/jacoco.xml.in"
"${CMake_BINARY_DIR}/Testing/JacocoCoverage/Coverage/target/site/jacoco.xml")
add_test(NAME CTestJacocoCoverage
- COMMAND cmake -E chdir
+ COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir
${CMake_BINARY_DIR}/Testing/JacocoCoverage
$<TARGET_FILE:ctest> -T Coverage --debug)
set_tests_properties(CTestJacocoCoverage PROPERTIES
@@ -2709,7 +2765,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
DESTINATION "${CMake_BINARY_DIR}/Testing/JavascriptCoverage"
FILES_MATCHING PATTERN "*.js")
add_test(NAME CTestJavascriptCoverage
- COMMAND cmake -E chdir
+ COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir
${CMake_BINARY_DIR}/Testing/JavascriptCoverage
$<TARGET_FILE:ctest> -T Coverage --debug)
set_tests_properties(CTestJavascriptCoverage PROPERTIES
@@ -2727,7 +2783,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_SOURCE_DIR}/Tests/DelphiCoverage/UTCovTest(UTCovTest.pas).html.in"
"${CMake_BINARY_DIR}/Testing/DelphiCoverage/UTCovTest(UTCovTest.pas).html")
add_test(NAME CTestDelphiCoverage
- COMMAND cmake -E chdir
+ COMMAND ${CMAKE_CMAKE_COMMAND} -E chdir
${CMake_BINARY_DIR}/Testing/DelphiCoverage
$<TARGET_FILE:ctest> -T Coverage --debug)
set_tests_properties(CTestDelphiCoverage PROPERTIES
@@ -2779,19 +2835,24 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--output-log "${CMake_BINARY_DIR}/Tests/CTestConfig/ScriptWithArgs.log"
)
+ ADD_TEST_MACRO(CMakeCommands.add_compile_definitions add_compile_definitions)
ADD_TEST_MACRO(CMakeCommands.add_compile_options add_compile_options)
ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries)
ADD_TEST_MACRO(CMakeCommands.target_include_directories target_include_directories)
ADD_TEST_MACRO(CMakeCommands.target_compile_definitions target_compile_definitions)
ADD_TEST_MACRO(CMakeCommands.target_compile_options target_compile_options)
+ ADD_TEST_MACRO(CMakeCommands.target_sources target_sources)
- if(CMake_TEST_SERVER_MODE)
- # The cmake server-mode test requires python for a simple client.
- find_package(PythonInterp QUIET)
- if(PYTHON_EXECUTABLE)
- set(Server_BUILD_OPTIONS -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE})
- ADD_TEST_MACRO(Server Server)
- endif()
+ ADD_TEST_MACRO(CMakeCommands.add_link_options)
+ ADD_TEST_MACRO(CMakeCommands.target_link_options)
+ ADD_TEST_MACRO(CMakeCommands.link_directories)
+ ADD_TEST_MACRO(CMakeCommands.target_link_directories)
+
+ # The cmake server-mode test requires python for a simple client.
+ find_package(PythonInterp QUIET)
+ if(PYTHON_EXECUTABLE)
+ set(Server_BUILD_OPTIONS -DPYTHON_EXECUTABLE:FILEPATH=${PYTHON_EXECUTABLE})
+ ADD_TEST_MACRO(Server Server)
endif()
configure_file(
@@ -2808,7 +2869,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
PASS_REGULAR_EXPRESSION "Failed")
else()
set_tests_properties(CTestTestCrash PROPERTIES
- PASS_REGULAR_EXPRESSION "(Illegal|SegFault)")
+ PASS_REGULAR_EXPRESSION "(Illegal|SegFault|Child aborted)")
endif()
configure_file(
@@ -3035,8 +3096,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
add_test(CTestTestShowOnly ${CMAKE_CTEST_COMMAND} -N)
- add_test(CTestBatchTest ${CMAKE_CTEST_COMMAND} -B)
-
configure_file(
"${CMake_SOURCE_DIR}/Tests/CTestTestFdSetSize/test.cmake.in"
"${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/test.cmake"
@@ -3071,12 +3130,14 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log"
)
- configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in"
- "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES)
- add_test(CTestTest2 ${CMAKE_CTEST_COMMAND}
- -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V
- --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log"
- )
+ if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in"
+ "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES)
+ add_test(CTestTest2 ${CMAKE_CTEST_COMMAND}
+ -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V
+ --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log"
+ )
+ endif()
if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja")
configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in"
@@ -3108,11 +3169,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
endif ()
- get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT)
- if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
- set_tests_properties ( CTestTest2
- PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
- endif ()
+ if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT)
+ if("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND)
+ set_tests_properties ( CTestTest2
+ PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT})
+ endif()
+ endif()
endif ()
if(CMake_TEST_EXTERNAL_CMAKE)
@@ -3162,7 +3225,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project testf
--build-two-config
- --build-options ${build_options}
--test-command testf)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran")
@@ -3173,9 +3235,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/FortranModules"
${build_generator_args}
--build-project FortranModules
- --build-options ${build_options}
+ --build-options
-DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
-DCMake_TEST_Fortran_SUBMODULES:BOOL=${CMake_TEST_Fortran_SUBMODULES}
+ ${CMake_TEST_FortranModules_BUILD_OPTIONS}
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranModules")
endif()
@@ -3195,7 +3258,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
${build_generator_args}
--build-project FortranC
--build-two-config
- --build-options ${build_options}
--test-command CMakeFiles/FortranCInterface/FortranCInterface)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC")
endif()
@@ -3215,61 +3277,54 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
if(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink
file(READ "${JNI_H}" JNI_FILE)
if("${JNI_FILE}" MATCHES "JDK1_2")
- add_test(Java.Jar ${CMAKE_CTEST_COMMAND}
+ add_test(NAME Java.Jar COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/Java"
"${CMake_BINARY_DIR}/Tests/JavaJar"
${build_generator_args}
--build-project hello
- --build-target hello
- --build-two-config
--build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJar/"
- --build-options ${build_options}
- --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld)
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIG>)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJar")
- add_test(Java.JarSourceList ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/Java"
- "${CMake_BINARY_DIR}/Tests/JavaJarSourceList"
- ${build_generator_args}
- --build-project hello
- --build-target hello2
- --build-two-config
- --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJarSourceList/"
- --build-options ${build_options}
- --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld)
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList")
- # For next test, java tool must have same architecture as toolchain
+ # For next tests, java tool must have same architecture as toolchain
math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8")
execute_process(
- COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version
- OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result
+ COMMAND "${Java_JAVA_EXECUTABLE}" -version
+ OUTPUT_VARIABLE _version ERROR_VARIABLE _version RESULT_VARIABLE _result
)
- if(_result EQUAL 0)
- if(CMAKE_CONFIGURATION_TYPES)
- set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$<CONFIGURATION>)
- else()
- set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah)
+ if(_result EQUAL 0 AND _version MATCHES "${_object_mode}-Bit")
+ ## next test is valid only if Java version is less than 1.10
+ if ("${Java_VERSION}" VERSION_LESS 1.10)
+ add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/JavaJavah"
+ "${CMake_BINARY_DIR}/Tests/JavaJavah"
+ ${build_generator_args}
+ --build-project helloJavah
+ --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIG>)
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah")
+ endif()
+ ## next test is valid only if Java is, at least, version 1.8
+ if (NOT "${Java_VERSION}" VERSION_LESS 1.8)
+ add_test(NAME Java.NativeHeaders COMMAND ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/JavaNativeHeaders"
+ "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders"
+ ${build_generator_args}
+ --build-project helloJavaNativeHeaders
+ --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders/"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIG>)
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaNativeHeaders")
endif()
- add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/JavaJavah"
- "${CMake_BINARY_DIR}/Tests/JavaJavah"
- ${build_generator_args}
- --build-project helloJavah
- --build-two-config
- --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/"
- --build-options ${build_options}
- --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2)
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah")
endif()
endif()
endif()
endif()
# add some cross compiler tests, for now only with makefile based generators
- if(CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "KDevelop")
+ if(CMAKE_GENERATOR MATCHES "Makefiles")
# if sdcc is found, build the SimpleCOnly project with sdcc
find_program(SDCC_EXECUTABLE sdcc)
@@ -3281,9 +3336,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc"
${build_generator_args}
--build-project SimpleC
- --build-options ${build_options}
- "-DCMAKE_SYSTEM_NAME=Generic"
- "-DCMAKE_C_COMPILER=${SDCC_EXECUTABLE}")
+ --build-options
+ "-DCMAKE_SYSTEM_NAME=Generic"
+ "-DCMAKE_C_COMPILER=${SDCC_EXECUTABLE}")
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SimpleCOnly_sdcc")
endif()
@@ -3299,11 +3354,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win"
${build_generator_args}
--build-project Simple
- --build-options ${build_options}
- "-DCMAKE_SYSTEM_NAME=Windows"
- "-DCMAKE_C_COMPILER=${MINGW_CC_LINUX2WIN_EXECUTABLE}"
- "-DCMAKE_CXX_COMPILER=${MINGW_CXX_LINUX2WIN_EXECUTABLE}"
- "-DCMAKE_RC_COMPILER=${MINGW_RC_LINUX2WIN_EXECUTABLE}"
+ --build-options
+ "-DCMAKE_SYSTEM_NAME=Windows"
+ "-DCMAKE_C_COMPILER=${MINGW_CC_LINUX2WIN_EXECUTABLE}"
+ "-DCMAKE_CXX_COMPILER=${MINGW_CXX_LINUX2WIN_EXECUTABLE}"
+ "-DCMAKE_RC_COMPILER=${MINGW_RC_LINUX2WIN_EXECUTABLE}"
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Simple_Mingw_Linux2Win")
endif()
@@ -3348,35 +3403,31 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
)
endif()
- add_test(NAME CMakeWizardTest COMMAND cmake -i)
- set_property(TEST CMakeWizardTest PROPERTY PASS_REGULAR_EXPRESSION
- "The \"cmake -i\" wizard mode is no longer supported.")
-
- # If the cache variable CMAKE_CONTRACT_PROJECTS is set
- # then the dashboard will run a contract with CMake test of that
- # name. For example CMAKE_CONTRACT_PROJECTS = vtk542 would run
- # the vtk542 contract test.
- # For each Contract test, the project should provide a directory
- # with at least one CMakeLists.txt file that uses ExternalProject
- # to download and configure the project. The directory should also
- # contain a RunTest.cmake file that has a single set of the format:
- # set(project_RUN_TEST testToRun)
- # The testToRun should be a test executable that can be run to
- # smoke test the build.
- foreach(project ${CMAKE_CONTRACT_PROJECTS})
- include(Contracts/${project}/RunTest.cmake)
- ADD_TEST_MACRO(Contracts.${project}
- ${${project}_RUN_TEST})
- # Contract test timeout in seconds.
- # Default to 6 hours.
- if(DEFINED ${project}_TEST_TIMEOUT)
- set(timeout ${${project}_TEST_TIMEOUT})
- elseif(CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT)
- set(timeout ${CMAKE_CONTRACT_TEST_TIMEOUT_DEFAULT})
- else()
- set(timeout 21600)
+ # Define a set of "contract" tests, each activated by a cache entry
+ # named "CMake_TEST_CONTRACT_<project>". For each Contract test,
+ # the project should provide a directory with a CMakeLists.txt file
+ # that uses ExternalProject to download and configure the project.
+ # The directory should also contain a Configure.cmake file that
+ # sets "CMake_TEST_CONTRACT_<project>_<var>" variables to configure
+ # the code below.
+ foreach(project
+ PLplot
+ Trilinos
+ VTK
+ )
+ if(CMake_TEST_CONTRACT_${project})
+ include(Contracts/${project}/Configure.cmake)
+ ADD_TEST_MACRO(Contracts.${project} ${CMake_TEST_CONTRACT_${project}_RUN_TEST})
+ # The external projects may take a long time to build.
+ if(DEFINED CMake_TEST_CONTRACT_${project}_TIMEOUT)
+ set(timeout ${CMake_TEST_CONTRACT_${project}_TIMEOUT})
+ elseif(CMake_TEST_CONTRACT_DEFAULT_TIMEOUT)
+ set(timeout ${CMake_TEST_CONTRACT_DEFAULT_TIMEOUT})
+ else()
+ set(timeout 21600)
+ endif()
+ set_property(TEST Contracts.${project} PROPERTY TIMEOUT "${timeout}")
endif()
- set_tests_properties(Contracts.${project} PROPERTIES TIMEOUT ${timeout})
endforeach()
if(TEST_CompileCommandOutput)
@@ -3393,10 +3444,26 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-two-config
${build_generator_args}
--build-project IncludeDirectories
- --build-options ${build_options}
--test-command IncludeDirectories)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories")
+ if(CMAKE_GENERATOR MATCHES "^((Unix|MSYS) Makefiles|Ninja)$" AND
+ ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4)
+ OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+ OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")))
+ add_test(IncludeDirectoriesCPATH ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/IncludeDirectoriesCPATH"
+ "${CMake_BINARY_DIR}/Tests/IncludeDirectoriesCPATH"
+ --build-two-config
+ ${build_generator_args}
+ --build-project IncludeDirectoriesCPATH)
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectoriesCPATH")
+ set_tests_properties(IncludeDirectoriesCPATH
+ PROPERTIES
+ ENVIRONMENT "CPATH=${CMAKE_CURRENT_SOURCE_DIR}/IncludeDirectoriesCPATH/viacpath")
+ endif()
+
add_test(InterfaceLinkLibraries ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/InterfaceLinkLibraries"
@@ -3404,7 +3471,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-two-config
${build_generator_args}
--build-project InterfaceLinkLibraries
- --build-options ${build_options}
--test-command InterfaceLinkLibraries)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/InterfaceLinkLibraries")
diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
index 443d366c4..a53e4418b 100644
--- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
+++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
@@ -86,7 +86,7 @@ foreach(VTEST ALSA ARMADILLO BZIP2 CUPS CURL EXPAT FREETYPE GETTEXT GIT HG
endforeach()
foreach(VTEST BISON Boost CUDA DOXYGEN FLEX GIF GTK2
- HDF5 LibArchive OPENSCENEGRAPH RUBY SWIG Protobuf)
+ HDF5 JPEG LibArchive OPENSCENEGRAPH RUBY SWIG Protobuf)
check_version_string(${VTEST} ${VTEST}_VERSION)
endforeach()
diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt
index c84fa748c..03babd263 100644
--- a/Tests/CMakeOnly/CMakeLists.txt
+++ b/Tests/CMakeOnly/CMakeLists.txt
@@ -30,10 +30,21 @@ add_CMakeOnly_test(CheckStructHasMember)
add_CMakeOnly_test(CompilerIdC)
add_CMakeOnly_test(CompilerIdCXX)
+
+if(CMAKE_OBJC_COMPILER)
+ add_CMakeOnly_test(CompilerIdOBJC)
+ add_CMakeOnly_test(CheckOBJCCompilerFlag)
+endif()
+
+if(CMAKE_OBJCXX_COMPILER)
+ add_CMakeOnly_test(CompilerIdOBJCXX)
+ add_CMakeOnly_test(CheckOBJCXXCompilerFlag)
+endif()
+
if(CMAKE_Fortran_COMPILER)
add_CMakeOnly_test(CompilerIdFortran)
endif()
-if(CMAKE_GENERATOR MATCHES "Visual Studio ([^89]|[89][0-9])")
+if(CMAKE_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])")
add_CMakeOnly_test(CompilerIdCSharp)
endif()
@@ -56,7 +67,19 @@ add_test(CMakeOnly.ProjectInclude ${CMAKE_CMAKE_COMMAND}
-P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake
)
-include(${CMAKE_SOURCE_DIR}/Modules/CMakeParseArguments.cmake)
+add_test(CMakeOnly.ProjectIncludeAny ${CMAKE_CMAKE_COMMAND}
+ -DTEST=ProjectIncludeAny
+ -DCMAKE_ARGS=-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectInclude/include.cmake
+ -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake
+ )
+
+add_test(CMakeOnly.ProjectIncludeBefore ${CMAKE_CMAKE_COMMAND}
+ -DTEST=ProjectIncludeBefore
+ -DCMAKE_ARGS=-DCMAKE_PROJECT_INCLUDE_BEFORE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectIncludeBefore/include.cmake
+ -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake
+ )
+
+include(CMakeParseArguments)
function(add_major_test module)
cmake_parse_arguments(MAJOR_TEST "NOLANG" "VERSION_VAR" "VERSIONS" ${ARGN})
@@ -72,5 +95,5 @@ function(add_major_test module)
endfunction()
add_major_test(PythonLibs VERSIONS 2 3 VERSION_VAR PYTHONLIBS_VERSION_STRING)
-add_major_test(PythonInterp NOLANG VERSIONS 2 3 VERSION_VAR PYTHON_VERSION_STRING)
+add_major_test(PythonInterp NOLANG VERSIONS 3 VERSION_VAR PYTHON_VERSION_STRING)
add_major_test(Qt VERSIONS 3 4 VERSION_VAR QT_VERSION_STRING)
diff --git a/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt
index 9be69f128..1f9d3acb7 100644
--- a/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt
+++ b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt
@@ -57,7 +57,7 @@ else()
message("Unhandled Platform")
endif()
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
check_cxx_compiler_flag("-x c++" HAVE_X_CXX)
if(NOT HAVE_X_CXX)
message(FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} compiler flag '-x c++' check failed")
diff --git a/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt b/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt
index f058c19fb..2028a135c 100644
--- a/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt
+++ b/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt
@@ -49,6 +49,15 @@ else ()
message(STATUS "errno found in <cerrno>")
endif ()
+check_cxx_symbol_exists("std::fopen" "cstdio" CSE_RESULT_FOPEN)
+if (NOT CSE_RESULT_FOPEN)
+ if(NOT ("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.10))
+ message(SEND_ERROR "CheckCXXSymbolExists did not find std::fopen in <cstdio>")
+ endif()
+else()
+ message(STATUS "std::fopen found in <cstdio>")
+endif()
+
if (CMAKE_COMPILER_IS_GNUCXX)
string(APPEND CMAKE_CXX_FLAGS " -O3")
unset(CSE_RESULT_O3 CACHE)
@@ -60,3 +69,8 @@ if (CMAKE_COMPILER_IS_GNUCXX)
message(SEND_ERROR "CheckCXXSymbolExists reported a nonexistent symbol as existing with optimization -O3")
endif ()
endif ()
+
+check_cxx_symbol_exists("std::non_existent_function_for_symbol_test<int*>" "algorithm" CSE_RESULT_NON_SYMBOL)
+if (CSE_RESULT_NON_SYMBOL)
+ message(SEND_ERROR "CheckCXXSymbolExists reported a nonexistent symbol.")
+endif()
diff --git a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt
index f5336dc03..90aa921f5 100644
--- a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt
+++ b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt
@@ -5,9 +5,20 @@ include(CheckLanguage)
set(langs )
set(expect_C 1)
set(expect_CXX 1)
+
+if(APPLE)
+ set(expect_OBJC 1)
+ set(expect_OBJCXX 1)
+endif()
unset(expect_Fortran)
set(expect_NoSuchLanguage 0)
-foreach(lang C CXX Fortran NoSuchLanguage)
+
+set(LANGUAGES C CXX Fortran CUDA NoSuchLanguage)
+if(APPLE)
+ list(APPEND LANGUAGES OBJC OBJCXX)
+endif()
+
+foreach(lang ${LANGUAGES})
check_language(${lang})
if(NOT DEFINED CMAKE_${lang}_COMPILER)
message(FATAL_ERROR "check_language(${lang}) did not set result")
diff --git a/Tests/CMakeOnly/CheckOBJCCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckOBJCCompilerFlag/CMakeLists.txt
new file mode 100644
index 000000000..a9a96eebb
--- /dev/null
+++ b/Tests/CMakeOnly/CheckOBJCCompilerFlag/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 2.8.12)
+
+project(CheckOBJCCompilerFlag)
+
+include(CheckOBJCCompilerFlag)
+
+if(CMAKE_COMPILER_IS_GNUOBJC)
+ set(COMPILER_FLAG -fobjc-direct-dispatch)
+else()
+ set(COMPILER_FLAG -fobjc-gc)
+endif()
+
+CHECK_OBJC_COMPILER_FLAGS(${COMPILER_FLAG} HAS_COMPILER_FLAG)
+
+if(NOT HAS_COMPILER_FLAG)
+ message(SEND_ERROR "Test fail: HAS_COMPILER_FLAG: ${COMPILER_FLAG}")
+endif
diff --git a/Tests/CMakeOnly/CheckOBJCXXCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckOBJCXXCompilerFlag/CMakeLists.txt
new file mode 100644
index 000000000..f83b738dc
--- /dev/null
+++ b/Tests/CMakeOnly/CheckOBJCXXCompilerFlag/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 2.8.12)
+
+project(CheckOBJCXXCompilerFlag)
+
+include(CheckOBJCXXCompilerFlag)
+
+if(CMAKE_COMPILER_IS_GNUOBJCXX)
+ set(COMPILER_FLAG -fobjc-direct-dispatch)
+else()
+ set(COMPILER_FLAG -fobjc-gc)
+endif()
+
+CHECK_OBJCXX_COMPILER_FLAGS(${COMPILER_FLAG} HAS_COMPILER_FLAG)
+
+if(NOT HAS_COMPILER_FLAG)
+ message(SEND_ERROR "Test fail: HAS_COMPILER_FLAG: ${COMPILER_FLAG}")
+endif()
diff --git a/Tests/CMakeOnly/CompilerIdOBJC/CMakeLists.txt b/Tests/CMakeOnly/CompilerIdOBJC/CMakeLists.txt
new file mode 100644
index 000000000..8f1378706
--- /dev/null
+++ b/Tests/CMakeOnly/CompilerIdOBJC/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 2.8.12)
+project(CompilerIdOBJC OBJC)
+
+foreach(v
+ CMAKE_OBJC_COMPILER
+ CMAKE_OBJC_COMPILER_ID
+ CMAKE_OBJC_COMPILER_VERSION
+ )
+ if(${v})
+ message(STATUS "${v}=[${${v}}]")
+ else()
+ message(SEND_ERROR "${v} not set!")
+ endif()
+endforeach()
diff --git a/Tests/CMakeOnly/CompilerIdOBJCXX/CMakeLists.txt b/Tests/CMakeOnly/CompilerIdOBJCXX/CMakeLists.txt
new file mode 100644
index 000000000..8f41db050
--- /dev/null
+++ b/Tests/CMakeOnly/CompilerIdOBJCXX/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 2.8.12)
+project(CompilerIdOBJCXX OBJCXX)
+
+foreach(v
+ CMAKE_OBJCXX_COMPILER
+ CMAKE_OBJCXX_COMPILER_ID
+ CMAKE_OBJCXX_COMPILER_VERSION
+ )
+ if(${v})
+ message(STATUS "${v}=[${${v}}]")
+ else()
+ message(SEND_ERROR "${v} not set!")
+ endif()
+endforeach()
diff --git a/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt b/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt
index a9abb4ad7..ffce488f4 100644
--- a/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt
+++ b/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt
@@ -1,4 +1,4 @@
-project(ProjectInclude)
+project(ProjectInclude LANGUAGES NONE)
if(NOT AUTO_INCLUDE)
message(FATAL_ERROR "include file not found")
endif()
diff --git a/Tests/CMakeOnly/ProjectIncludeAny/CMakeLists.txt b/Tests/CMakeOnly/ProjectIncludeAny/CMakeLists.txt
new file mode 100644
index 000000000..ffce488f4
--- /dev/null
+++ b/Tests/CMakeOnly/ProjectIncludeAny/CMakeLists.txt
@@ -0,0 +1,4 @@
+project(ProjectInclude LANGUAGES NONE)
+if(NOT AUTO_INCLUDE)
+ message(FATAL_ERROR "include file not found")
+endif()
diff --git a/Tests/CMakeOnly/ProjectIncludeBefore/CMakeLists.txt b/Tests/CMakeOnly/ProjectIncludeBefore/CMakeLists.txt
new file mode 100644
index 000000000..5cd9cba2c
--- /dev/null
+++ b/Tests/CMakeOnly/ProjectIncludeBefore/CMakeLists.txt
@@ -0,0 +1,5 @@
+set(FOO TRUE)
+project(ProjectInclude LANGUAGES NONE)
+if(NOT AUTO_INCLUDE)
+ message(FATAL_ERROR "include file not found")
+endif()
diff --git a/Tests/CMakeOnly/ProjectIncludeBefore/include.cmake b/Tests/CMakeOnly/ProjectIncludeBefore/include.cmake
new file mode 100644
index 000000000..0a4799df3
--- /dev/null
+++ b/Tests/CMakeOnly/ProjectIncludeBefore/include.cmake
@@ -0,0 +1,9 @@
+if(NOT FOO)
+ message(FATAL_ERROR "FOO is not set")
+endif()
+
+if(NOT "${PROJECT_NAME}" STREQUAL "")
+ message(FATAL_ERROR "PROJECT_NAME should be empty")
+endif()
+
+set(AUTO_INCLUDE TRUE)
diff --git a/Tests/CMakeOnly/SelectLibraryConfigurations/CMakeLists.txt b/Tests/CMakeOnly/SelectLibraryConfigurations/CMakeLists.txt
index 6d1628ae5..3676b1792 100644
--- a/Tests/CMakeOnly/SelectLibraryConfigurations/CMakeLists.txt
+++ b/Tests/CMakeOnly/SelectLibraryConfigurations/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.9)
project(SelectLibraryConfigurations NONE)
@@ -15,7 +15,8 @@ macro(check_slc basename expect)
endif ()
endmacro(check_slc)
-if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if (NOT _isMultiConfig AND NOT CMAKE_BUILD_TYPE)
set(NOTYPE_RELONLY_LIBRARY_RELEASE "opt")
check_slc(NOTYPE_RELONLY "opt")
diff --git a/Tests/CMakeServerLib/CMakeLists.txt b/Tests/CMakeServerLib/CMakeLists.txt
new file mode 100644
index 000000000..2c23c2dbe
--- /dev/null
+++ b/Tests/CMakeServerLib/CMakeLists.txt
@@ -0,0 +1,21 @@
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMake_BINARY_DIR}/Source
+ ${CMake_SOURCE_DIR}/Source
+ )
+
+set(CMakeServerLib_TESTS
+ testServerBuffering.cpp
+ )
+
+create_test_sourcelist(CMakeLib_TEST_SRCS CMakeServerLibTests.cxx ${CMakeServerLib_TESTS})
+add_executable(CMakeServerLibTests ${CMakeLib_TEST_SRCS})
+target_link_libraries(CMakeServerLibTests CMakeLib CMakeServerLib)
+
+SET_PROPERTY(TARGET CMakeServerLibTests PROPERTY C_CLANG_TIDY "")
+SET_PROPERTY(TARGET CMakeServerLibTests PROPERTY CXX_CLANG_TIDY "")
+
+foreach(testfile ${CMakeServerLib_TESTS})
+ get_filename_component(test "${testfile}" NAME_WE)
+ add_test(CMakeServerLib.${test} CMakeServerLibTests ${test} ${${test}_ARGS})
+endforeach()
diff --git a/Tests/CMakeServerLib/testServerBuffering.cpp b/Tests/CMakeServerLib/testServerBuffering.cpp
new file mode 100644
index 000000000..6f2294067
--- /dev/null
+++ b/Tests/CMakeServerLib/testServerBuffering.cpp
@@ -0,0 +1,87 @@
+#include <iostream>
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "cmConnection.h"
+#include "cmServerConnection.h"
+
+void print_error(const std::vector<std::string>& input,
+ const std::vector<std::string>& output)
+{
+ std::cerr << "Responses don't equal input messages input." << std::endl;
+ std::cerr << "Responses: " << std::endl;
+
+ for (auto& msg : output) {
+ std::cerr << "'" << msg << "'" << std::endl;
+ }
+
+ std::cerr << "Input messages" << std::endl;
+ for (auto& msg : input) {
+ std::cerr << "'" << msg << "'" << std::endl;
+ }
+}
+
+std::string trim_newline(const std::string& _buffer)
+{
+ auto buffer = _buffer;
+ while (!buffer.empty() && (buffer.back() == '\n' || buffer.back() == '\r')) {
+ buffer.pop_back();
+ }
+ return buffer;
+}
+
+int testServerBuffering(int, char** const)
+{
+ std::vector<std::string> messages = {
+ "{ \"test\": 10}", "{ \"test\": { \"test2\": false} }",
+ "{ \"test\": [1, 2, 3] }",
+ "{ \"a\": { \"1\": {}, \n\n\n \"2\":[] \t\t\t\t}}"
+ };
+
+ std::string fullMessage;
+ for (auto& msg : messages) {
+ fullMessage += "[== \"CMake Server\" ==[\n";
+ fullMessage += msg;
+ fullMessage += "\n]== \"CMake Server\" ==]\n";
+ }
+
+ // The buffering strategy should cope with any fragmentation, including
+ // just getting the characters one at a time.
+ auto bufferingStrategy =
+ std::unique_ptr<cmConnectionBufferStrategy>(new cmServerBufferStrategy);
+ std::vector<std::string> response;
+ std::string rawBuffer;
+ for (auto& messageChar : fullMessage) {
+ rawBuffer += messageChar;
+ std::string packet = bufferingStrategy->BufferMessage(rawBuffer);
+ do {
+ if (!packet.empty() && packet != "\r\n") {
+ response.push_back(trim_newline(packet));
+ }
+ packet = bufferingStrategy->BufferMessage(rawBuffer);
+ } while (!packet.empty());
+ }
+
+ if (response != messages) {
+ print_error(messages, response);
+ return 1;
+ }
+
+ // We should also be able to deal with getting a bunch at once
+ response.clear();
+ std::string packet = bufferingStrategy->BufferMessage(fullMessage);
+ do {
+ if (!packet.empty() && packet != "\r\n") {
+ response.push_back(trim_newline(packet));
+ }
+ packet = bufferingStrategy->BufferMessage(fullMessage);
+ } while (!packet.empty());
+
+ if (response != messages) {
+ print_error(messages, response);
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/Tests/CMakeTests/.gitattributes b/Tests/CMakeTests/.gitattributes
index c34e350e5..c6148fbf2 100644
--- a/Tests/CMakeTests/.gitattributes
+++ b/Tests/CMakeTests/.gitattributes
@@ -1 +1 @@
-File-HASH-Input.txt crlf=input
+File-HASH-Input.txt eol=lf
diff --git a/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in b/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in
index 3294a2f0d..a3c2b055a 100644
--- a/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in
+++ b/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in
@@ -22,6 +22,25 @@ try_and_print(TOTAL_VIRTUAL_MEMORY)
try_and_print(AVAILABLE_VIRTUAL_MEMORY)
try_and_print(TOTAL_PHYSICAL_MEMORY)
try_and_print(AVAILABLE_PHYSICAL_MEMORY)
+try_and_print(IS_64BIT)
+try_and_print(HAS_FPU)
+try_and_print(HAS_MMX)
+try_and_print(HAS_MMX_PLUS)
+try_and_print(HAS_SSE)
+try_and_print(HAS_SSE2)
+try_and_print(HAS_SSE_FP)
+try_and_print(HAS_SSE_MMX)
+try_and_print(HAS_AMD_3DNOW)
+try_and_print(HAS_AMD_3DNOW_PLUS)
+try_and_print(HAS_IA64)
+try_and_print(HAS_SERIAL_NUMBER)
+try_and_print(PROCESSOR_SERIAL_NUMBER)
+try_and_print(PROCESSOR_NAME)
+try_and_print(PROCESSOR_DESCRIPTION)
+try_and_print(OS_NAME)
+try_and_print(OS_RELEASE)
+try_and_print(OS_VERSION)
+try_and_print(OS_PLATFORM)
include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake")
diff --git a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in
index 8145db7cb..4f2aaea9c 100644
--- a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in
+++ b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in
@@ -308,13 +308,11 @@ message("=======================================================================
if("$ENV{DASHBOARD_TEST_FROM_CTEST}" STREQUAL "")
# developers are allowed to have local additions and modifications...
- set(is_dashboard 0)
message("interactive test run")
message("")
else()
- set(is_dashboard 1)
message("dashboard test run")
message("")
@@ -341,7 +339,7 @@ endif()
# Not even developers.
#
if(nonadditions)
- if(in_source_build AND is_dashboard)
+ if(in_source_build)
message("
warning: test results confounded because this is an 'in-source' build - cannot
distinguish between non-added files that are in-source build products and
diff --git a/Tests/CMakeTests/ELFTest.cmake.in b/Tests/CMakeTests/ELFTest.cmake.in
index 463577889..85c2360d3 100644
--- a/Tests/CMakeTests/ELFTest.cmake.in
+++ b/Tests/CMakeTests/ELFTest.cmake.in
@@ -25,13 +25,38 @@ foreach(f ${files})
# Change the RPATH.
file(RPATH_CHANGE FILE "${f}"
OLD_RPATH "/sample/rpath"
- NEW_RPATH "/rpath/sample")
+ NEW_RPATH "/path1:/path2")
set(rpath)
- file(STRINGS "${f}" rpath REGEX "/rpath/sample" LIMIT_COUNT 1)
+ file(STRINGS "${f}" rpath REGEX "/path1:/path2" LIMIT_COUNT 1)
if(NOT rpath)
message(FATAL_ERROR "RPATH not changed in ${f}")
endif()
+ # Change the RPATH without compiler defined rpath removed
+ file(RPATH_CHANGE FILE "${f}"
+ OLD_RPATH "/path2"
+ NEW_RPATH "/path3")
+ set(rpath)
+ file(STRINGS "${f}" rpath REGEX "/path1:/path3" LIMIT_COUNT 1)
+ if(NOT rpath)
+ message(FATAL_ERROR "RPATH not updated in ${f}")
+ endif()
+
+ # Change the RPATH with compiler defined rpath removed
+ file(RPATH_CHANGE FILE "${f}"
+ OLD_RPATH "/path3"
+ NEW_RPATH "/rpath/sample"
+ INSTALL_REMOVE_ENVIRONMENT_RPATH)
+ set(rpath)
+ file(STRINGS "${f}" rpath REGEX "/rpath/sample" LIMIT_COUNT 1)
+ if(NOT rpath)
+ message(FATAL_ERROR "RPATH not updated in ${f}")
+ endif()
+ file(STRINGS "${f}" rpath REGEX "/path1" LIMIT_COUNT 1)
+ if(rpath)
+ message(FATAL_ERROR "RPATH not removed in ${f}")
+ endif()
+
# Remove the RPATH.
file(RPATH_REMOVE FILE "${f}")
set(rpath)
diff --git a/Tests/CMakeTests/FileDownloadInput.png b/Tests/CMakeTests/FileDownloadInput.png
index 7bbcee413..9ab565a1b 100644
--- a/Tests/CMakeTests/FileDownloadInput.png
+++ b/Tests/CMakeTests/FileDownloadInput.png
Binary files differ
diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in
index f6d9ad99b..39354490b 100644
--- a/Tests/CMakeTests/FileDownloadTest.cmake.in
+++ b/Tests/CMakeTests/FileDownloadTest.cmake.in
@@ -32,7 +32,7 @@ file(DOWNLOAD
${url}
${dir}/file3.png
TIMEOUT 2
- EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1
+ EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92
)
message(STATUS "FileDownload:4")
@@ -41,7 +41,7 @@ file(DOWNLOAD
${dir}/file3.png
TIMEOUT 2
STATUS status
- EXPECTED_HASH SHA1=50c614fc28b39c1281d0517bb6d5858b4359c9b7
+ EXPECTED_HASH SHA1=67eee17f79d9ac557284fc0b8ad19f25723fb578
)
message(STATUS "FileDownload:5")
@@ -50,7 +50,7 @@ file(DOWNLOAD
${dir}/file3.png
TIMEOUT 2
STATUS status
- EXPECTED_HASH SHA224=73cd5f442b04e8320e4f907f8e1b21d4befff98b5bd77bc32526ea68
+ EXPECTED_HASH SHA224=ba283726bbb602776818b463943189afd91836cb7ee5dd6e2c7b5ae4
)
message(STATUS "FileDownload:6")
@@ -59,7 +59,7 @@ file(DOWNLOAD
${dir}/file3.png
TIMEOUT 2
STATUS status
- EXPECTED_HASH SHA256=2e067f6c09cbc7cd619c8fbcc44eb64cd6b45a95e4cddb3a585eee1f731c4da9
+ EXPECTED_HASH SHA256=cf3334b1275071e1da6e8c396ccb72cf1b2388d8c937526f3af26230affb9423
)
message(STATUS "FileDownload:7")
@@ -68,7 +68,7 @@ file(DOWNLOAD
${dir}/file3.png
TIMEOUT 2
STATUS status
- EXPECTED_HASH SHA384=398bf41902a7251c30e522b307e3e41e3fb617c765b3feaa99b2f7d063894708ad399267ccc25d877437a10e5e890d35
+ EXPECTED_HASH SHA384=43a5d13978d97c660db44481aee0604cb4ff6ca0775cd5c2cd68cd8000e107e507c4caf6c228941231041e282ffb8950
)
message(STATUS "FileDownload:8")
@@ -77,7 +77,7 @@ file(DOWNLOAD
${dir}/file3.png
TIMEOUT 2
STATUS status
- EXPECTED_HASH SHA512=c51854d21052713968b849c2b4263cf54be03bc3a7e9847a6c71c6c8d1d13cd805fe1b9fa95f9ba1d0a5631513974f6fae21e34ab5b171d94bad48df5f073e48
+ EXPECTED_HASH SHA512=6984e0909a1018030ccaa418e3be1654223cdccff0fe6adc745f9aea7e377f178be53b9fc7d54a6f81c2b62ef9ddcd38ba1978fedf4c5e7139baaf355eefad5b
)
message(STATUS "FileDownload:9")
file(DOWNLOAD
@@ -85,7 +85,7 @@ file(DOWNLOAD
${dir}/file3.png
TIMEOUT 2
STATUS status
- EXPECTED_HASH MD5=d16778650db435bda3a8c3435c3ff5d1
+ EXPECTED_HASH MD5=dbd330d52f4dbd60115d4191904ded92
)
message(STATUS "FileDownload:10")
@@ -94,7 +94,7 @@ file(DOWNLOAD
${dir}/file3.png
TIMEOUT 2
STATUS status
- EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1
+ EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92
)
message(STATUS "${status}")
diff --git a/Tests/CMakeTests/FileUploadTest.cmake.in b/Tests/CMakeTests/FileUploadTest.cmake.in
index 9e2290988..0e6f08048 100644
--- a/Tests/CMakeTests/FileUploadTest.cmake.in
+++ b/Tests/CMakeTests/FileUploadTest.cmake.in
@@ -35,7 +35,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum
"@CMAKE_CURRENT_BINARY_DIR@/uploads/file1.png"
OUTPUT_VARIABLE sum1
OUTPUT_STRIP_TRAILING_WHITESPACE)
-if(NOT sum1 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file1.png$")
+if(NOT sum1 MATCHES "^dbd330d52f4dbd60115d4191904ded92 .*/uploads/file1.png$")
message(FATAL_ERROR "file1.png did not upload correctly (sum1='${sum1}')")
endif()
@@ -43,7 +43,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum
"@CMAKE_CURRENT_BINARY_DIR@/uploads/file2.png"
OUTPUT_VARIABLE sum2
OUTPUT_STRIP_TRAILING_WHITESPACE)
-if(NOT sum2 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file2.png$")
+if(NOT sum2 MATCHES "^dbd330d52f4dbd60115d4191904ded92 .*/uploads/file2.png$")
message(FATAL_ERROR "file2.png did not upload correctly (sum2='${sum2}')")
endif()
diff --git a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in
index d7d881e79..f01e616f0 100644
--- a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in
+++ b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in
@@ -349,6 +349,12 @@ set(aix_xlf90_64_libs "xlf90;xlopt;xlf;xlomp_ser;m;c")
set(aix_xlf90_64_dirs "/usr/lpp/xlf/lib")
list(APPEND platforms aix_xlf90_64)
+# g++ dummy.c -v
+set(aix_g++_text " /prefix/libexec/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/collect2 -bpT:0x10000000 -bpD:0x20000000 -btextro /lib/crt0.o /prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/crtcxa.o /prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/crtdbase.o -L/prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0 -L/prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/../../.. /tmp//ccKROJ1f.o -lstdc++ -lm -lgcc_s /prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/libgcc.a -lc -lgcc_s /prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/libgcc.a")
+set(aix_g++_libs "stdc++;m;gcc_s;/prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/libgcc.a;c;gcc_s;/prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0/libgcc.a")
+set(aix_g++_dirs "/prefix/lib/gcc/powerpc-ibm-aix7.2.0.0/7.2.0;/prefix/lib")
+list(APPEND platforms aix_g++)
+
#-----------------------------------------------------------------------------
# HP
@@ -409,78 +415,6 @@ set(hp_f90_64_dirs "/usr/lib/hpux64;/opt/langtools/lib/hpux64")
list(APPEND platforms hp_f90_64)
#-----------------------------------------------------------------------------
-# IRIX
-
-# cc -o32 dummy.c -v
-set(irix64_cc_o32_text "/usr/lib/ld -elf -_SYSTYPE_SVR4 -require_dynamic_link _rld_new_interface -no_unresolved -Wx,-G 0 -o32 -mips2 -call_shared -g0 -KPIC -L/usr/lib/ -nocount /usr/lib/crt1.o -count dummy.o -nocount -lc /usr/lib/crtn.o")
-set(irix64_cc_o32_libs "c")
-set(irix64_cc_o32_dirs "/usr/lib")
-list(APPEND platforms irix64_cc_o32)
-
-# cc -n32 dummy.c -v
-set(irix64_cc_n32_text "/usr/lib32/cmplrs/ld32 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -n32 -L/usr/lib32/mips4/r10000 -L/usr/lib32/mips4 -L/usr/lib32 /usr/lib32/mips4/crt1.o dummy.o -dont_warn_unused -Bdynamic -lc /usr/lib32/mips4/crtn.o -warn_unused")
-set(irix64_cc_n32_libs "c")
-set(irix64_cc_n32_dirs "/usr/lib32/mips4/r10000;/usr/lib32/mips4;/usr/lib32")
-list(APPEND platforms irix64_cc_n32)
-
-# cc -64 dummy.c -v
-set(irix64_cc_64_text "/usr/lib32/cmplrs/ld64 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -64 -L/usr/lib64/mips4/r10000 -L/usr/lib64/mips4 -L/usr/lib64 /usr/lib64/mips4/crt1.o dummy.o -dont_warn_unused -Bdynamic -lc /usr/lib64/mips4/crtn.o -warn_unused")
-set(irix64_cc_64_libs "c")
-set(irix64_cc_64_dirs "/usr/lib64/mips4/r10000;/usr/lib64/mips4;/usr/lib64")
-list(APPEND platforms irix64_cc_64)
-
-# CC -o32 dummy.cxx -v
-set(irix64_CC_o32_text "/usr/lib/ld -elf -cxx -woff 134 -_SYSTYPE_SVR4 -require_dynamic_link _rld_new_interface -no_unresolved -Wx,-G 0 -o32 -mips2 -call_shared -g0 -KPIC -L/usr/lib/ -nocount /usr/lib/crt1.o /usr/lib/c++init.o -count dummy.o -nocount -dont_warn_unused -lC -warn_unused -lc /usr/lib/crtn.o")
-set(irix64_CC_o32_libs "C;c")
-set(irix64_CC_o32_dirs "/usr/lib")
-list(APPEND platforms irix64_CC_o32)
-
-# CC -n32 dummy.cxx -v
-set(irix64_CC_n32_text "/usr/lib32/cmplrs/ld32 -call_shared -init _main -fini _fini -no_unresolved -transitive_link -demangle -elf -_SYSTYPE_SVR4 -LANG:std -show -mips4 -n32 -L/usr/lib32/mips4/r10000 -L/usr/lib32/mips4 -L/usr/lib32 -cxx -woff 134 /usr/lib32/mips4/crt1.o /usr/lib32/c++init.o dummy.o -dont_warn_unused -lCsup -lC -lCio -Bdynamic -lc /usr/lib32/mips4/crtn.o -warn_unused")
-set(irix64_CC_n32_libs "Csup;C;Cio;c")
-set(irix64_CC_n32_dirs "/usr/lib32/mips4/r10000;/usr/lib32/mips4;/usr/lib32")
-list(APPEND platforms irix64_CC_n32)
-
-# CC -64 dummy.cxx -v
-set(irix64_CC_64_text "/usr/lib32/cmplrs/ld64 -call_shared -init _main -fini _fini -no_unresolved -transitive_link -demangle -elf -_SYSTYPE_SVR4 -LANG:std -show -mips4 -64 -L/usr/lib64/mips4/r10000 -L/usr/lib64/mips4 -L/usr/lib64 -cxx -woff 134 /usr/lib64/mips4/crt1.o /usr/lib64/c++init.o dummy.o -dont_warn_unused -lCsup -lC -lCio -Bdynamic -lc /usr/lib64/mips4/crtn.o -warn_unused")
-set(irix64_CC_64_libs "Csup;C;Cio;c")
-set(irix64_CC_64_dirs "/usr/lib64/mips4/r10000;/usr/lib64/mips4;/usr/lib64")
-list(APPEND platforms irix64_CC_64)
-
-# f77 -o32 dummy.f -v
-set(irix64_f77_o32_text "/usr/lib/ld -elf -_SYSTYPE_SVR4 -require_dynamic_link _rld_new_interface -no_unresolved -Wx,-G 0 -o32 -mips2 -call_shared -g0 -KPIC -L/usr/lib/ -nocount /usr/lib/crt1.o -count dummy.o -nocount -lftn -lm -lc /usr/lib/crtn.o")
-set(irix64_f77_o32_libs "ftn;m;c")
-set(irix64_f77_o32_dirs "/usr/lib")
-list(APPEND platforms irix64_f77_o32)
-
-# f77 -n32 dummy.f -v
-set(irix64_f77_n32_text "/usr/lib32/cmplrs/ld32 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -n32 -L/usr/lib32/mips4/r10000 -L/usr/lib32/mips4 -L/usr/lib32 /usr/lib32/mips4/crt1.o dummy.o -dont_warn_unused -lftn -lm -Bdynamic -lc /usr/lib32/mips4/crtn.o -warn_unused")
-set(irix64_f77_n32_libs "ftn;m;c")
-set(irix64_f77_n32_dirs "/usr/lib32/mips4/r10000;/usr/lib32/mips4;/usr/lib32")
-list(APPEND platforms irix64_f77_n32)
-
-# f77 -64 dummy.f -v
-set(irix64_f77_64_text "/usr/lib32/cmplrs/ld64 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -64 -L/usr/lib64/mips4/r10000 -L/usr/lib64/mips4 -L/usr/lib64 /usr/lib64/mips4/crt1.o dummy.o -dont_warn_unused -lftn -lm -Bdynamic -lc /usr/lib64/mips4/crtn.o -warn_unused")
-set(irix64_f77_64_libs "ftn;m;c")
-set(irix64_f77_64_dirs "/usr/lib64/mips4/r10000;/usr/lib64/mips4;/usr/lib64")
-list(APPEND platforms irix64_f77_64)
-
-# f90 -o32 dummy.f -v
-#f90 ERROR: specified abi -o32 not supported.
-
-# f90 -n32 dummy.f -v
-set(irix64_f90_n32_text "/usr/lib32/cmplrs/ld32 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -n32 -L/usr/lib32/mips4/r10000 -L/usr/lib32/mips4 -L/usr/lib32 /usr/lib32/mips4/crt1.o dummy.o -dont_warn_unused -lfortran -lffio -lftn -lm -Bdynamic -lc /usr/lib32/mips4/crtn.o -warn_unused")
-set(irix64_f90_n32_libs "fortran;ffio;ftn;m;c")
-set(irix64_f90_n32_dirs "/usr/lib32/mips4/r10000;/usr/lib32/mips4;/usr/lib32")
-list(APPEND platforms irix64_f90_n32)
-
-# f90 -64 dummy.f -v
-set(irix64_f90_64_text "/usr/lib32/cmplrs/ld64 -call_shared -no_unresolved -transitive_link -elf -_SYSTYPE_SVR4 -show -mips4 -64 -L/usr/lib64/mips4/r10000 -L/usr/lib64/mips4 -L/usr/lib64 /usr/lib64/mips4/crt1.o dummy.o -dont_warn_unused -lfortran -lffio -lftn -lm -Bdynamic -lc /usr/lib64/mips4/crtn.o -warn_unused")
-set(irix64_f90_64_libs "fortran;ffio;ftn;m;c")
-set(irix64_f90_64_dirs "/usr/lib64/mips4/r10000;/usr/lib64/mips4;/usr/lib64")
-list(APPEND platforms irix64_f90_64)
-
-#-----------------------------------------------------------------------------
# Cygwin
# gcc dummy.c -v
@@ -525,6 +459,27 @@ set(msys_g77_dirs "C:/some-mingw/lib/gcc/mingw32/3.4.5;C:/some-mingw/lib/gcc;/so
list(APPEND platforms msys_g77)
#-----------------------------------------------------------------------------
+# MSYS2
+
+# gcc dummy.c -v
+set(msys2_gcc_text " C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/collect2.exe -plugin C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/liblto_plugin-0.dll -plugin-opt=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:/msys64/tmp/ccikz9Wf.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pep -Bdynamic C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtbegin.o -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0 -LC:/msys64/mingw64/bin/../lib/gcc -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../.. C:/msys64/tmp/ccK0dTUv.o -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtend.o")
+set(msys2_gcc_libs "mingw32;gcc;moldname;mingwex;pthread;advapi32;shell32;user32;kernel32;mingw32;gcc;moldname;mingwex")
+set(msys2_gcc_dirs "C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0;C:/msys64/mingw64/lib/gcc;C:/msys64/mingw64/x86_64-w64-mingw32/lib;C:/msys64/mingw64/lib")
+list(APPEND platforms msys2_gcc)
+
+# g++ dummy.cxx -v
+set(msys2_g++_text " C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/collect2.exe -plugin C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/liblto_plugin-0.dll -plugin-opt=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:/msys64/tmp/ccJQgvbN.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pep -Bdynamic C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtbegin.o -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0 -LC:/msys64/mingw64/bin/../lib/gcc -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../.. C:/msys64/tmp/ccqPpuVS.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtend.o")
+set(msys2_g++_libs "stdc++;mingw32;gcc_s;gcc;moldname;mingwex;pthread;advapi32;shell32;user32;kernel32;mingw32;gcc_s;gcc;moldname;mingwex")
+set(msys2_g++_dirs "C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0;C:/msys64/mingw64/lib/gcc;C:/msys64/mingw64/x86_64-w64-mingw32/lib;C:/msys64/mingw64/lib")
+list(APPEND platforms msys2_g++)
+
+# gfortran dummy.f90 -v
+set(msys2_gfortran_text " C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/collect2.exe -plugin C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/liblto_plugin-0.dll -plugin-opt=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:/msys64/tmp/cczOKIDy.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lquadmath -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pep -Bdynamic C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtbegin.o -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0 -LC:/msys64/mingw64/bin/../lib/gcc -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib -LC:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../.. C:/msys64/tmp/ccyXuCgD.o -lgfortran -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lquadmath -lm -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/7.2.0/crtend.o")
+set(msys2_gfortran_libs "gfortran;mingw32;gcc_s;gcc;moldname;mingwex;quadmath;m;mingw32;gcc_s;gcc;moldname;mingwex;pthread;advapi32;shell32;user32;kernel32;mingw32;gcc_s;gcc;moldname;mingwex")
+set(msys2_gfortran_dirs "C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0;C:/msys64/mingw64/lib/gcc;C:/msys64/mingw64/x86_64-w64-mingw32/lib;C:/msys64/mingw64/lib")
+list(APPEND platforms msys2_gfortran)
+
+#-----------------------------------------------------------------------------
# MSVC from NVIDIA CUDA
set(nvcc_msvc_text [[cuda-fake-ld cl.exe -nologo "tmp/a_dlink.obj" "tmp/CMakeCUDACompilerId.obj" -link -INCREMENTAL:NO "/LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/bin/../lib/x64" cudadevrt.lib cudart_static.lib -Fe"a.exe"]])
@@ -532,7 +487,6 @@ set(nvcc_msvc_libs "cudadevrt.lib;cudart_static.lib")
set(nvcc_msvc_dirs "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64")
list(APPEND platforms nvcc_msvc)
-
#-----------------------------------------------------------------------------
# PGI on Windows
diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in
index 76f5e4f6a..f517e64a6 100644
--- a/Tests/CMakeTests/ListTest.cmake.in
+++ b/Tests/CMakeTests/ListTest.cmake.in
@@ -53,6 +53,10 @@ set(result andy brad)
list(INSERT result -1 bill ken)
TEST("INSERT result -1 bill ken" "andy;bill;ken;brad")
+set(result andy brad)
+list(INSERT result 2 bill ken)
+TEST("INSERT result 2 bill ken" "andy;brad;bill;ken")
+
set(result andy bill brad ken bob)
list(REMOVE_ITEM result bob)
TEST("REMOVE_ITEM result bob" "andy;bill;brad;ken")
diff --git a/Tests/CMakeTests/PushCheckStateTest.cmake.in b/Tests/CMakeTests/PushCheckStateTest.cmake.in
index b4c48f4f4..cbd879def 100644
--- a/Tests/CMakeTests/PushCheckStateTest.cmake.in
+++ b/Tests/CMakeTests/PushCheckStateTest.cmake.in
@@ -1,3 +1,4 @@
+cmake_minimum_required(VERSION 3.8)
include(CMakePushCheckState)
set(CMAKE_EXTRA_INCLUDE_FILES file1)
@@ -26,6 +27,27 @@ set(CMAKE_REQUIRED_LIBRARIES lib3)
set(CMAKE_REQUIRED_FLAGS flag3)
set(CMAKE_REQUIRED_QUIET 3)
+cmake_push_check_state(RESET)
+
+foreach(pair IN ITEMS
+ EXTRA_INCLUDE_FILES|
+ REQUIRED_INCLUDES|
+ REQUIRED_DEFINITIONS|
+ REQUIRED_LIBRARIES|
+ REQUIRED_FLAGS|
+ REQUIRED_QUIET|
+ )
+ string(REPLACE "|" ";" pair "${pair}")
+ list(GET pair 0 var)
+ list(GET pair 1 expected)
+ if (NOT "${CMAKE_${var}}" STREQUAL "${expected}")
+ set(fatal TRUE)
+ message("ERROR: CMAKE_${var} is \"${CMAKE_${var}}\" (expected \"${expected}\")" )
+ endif()
+endforeach()
+
+cmake_pop_check_state()
+
cmake_pop_check_state()
foreach(pair IN ITEMS
diff --git a/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake b/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake
index a93e7f546..43c93848e 100644
--- a/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake
+++ b/Tests/CMakeTests/String-TIMESTAMP-UnixTime.cmake
@@ -11,12 +11,12 @@ string(TIMESTAMP days "%j" UTC)
# see if we are somewhere in the right region.
math(EXPR years_since_epoch "${year} - 1970")
-math(EXPR lower_bound "((${years_since_epoch} * 365) + ${days}) * 86400")
+math(EXPR lower_bound "((${years_since_epoch} * 365) + ${days} - 1) * 86400")
math(EXPR upper_bound "((${years_since_epoch} * 366) + ${days}) * 86400")
-if(unix_time GREATER lower_bound AND unix_time LESS upper_bound)
+if(unix_time GREATER_EQUAL lower_bound AND unix_time LESS upper_bound)
message("~${unix_time}~")
else()
- message(FATAL_ERROR "${timestamp} unix time not in expected range [${lower_bound}, ${upper_bound}]")
+ message(FATAL_ERROR "${timestamp} unix time not in expected range [${lower_bound}, ${upper_bound})")
endif()
diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in
index 83655dae5..154afa7f8 100644
--- a/Tests/CMakeTests/StringTest.cmake.in
+++ b/Tests/CMakeTests/StringTest.cmake.in
@@ -47,7 +47,7 @@ set(TIMESTAMP-AllSpecifiers-STDERR "~[0-9]+(;[0-9]+)*~")
set(TIMESTAMP-MonthWeekNames-RESULT 0)
set(TIMESTAMP-MonthWeekNames-STDERR "~[^%]+;[^%]+~")
set(TIMESTAMP-UnixTime-RESULT 0)
-set(TIMESTAMP-UnixTime-STDERR "~[1-9][0-9]+~")
+set(TIMESTAMP-UnixTime-STDERR "~[0-9]+~")
include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake")
check_cmake_test(String
@@ -81,7 +81,7 @@ check_cmake_test(String
# Execute each test listed in StringTestScript.cmake:
#
set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/StringTestScript.cmake")
-set(number_of_tests_expected 70)
+set(number_of_tests_expected 74)
include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake")
execute_all_script_tests(${scriptname} number_of_tests_executed)
diff --git a/Tests/CMakeTests/StringTestScript.cmake b/Tests/CMakeTests/StringTestScript.cmake
index 44d56531f..e069897b6 100644
--- a/Tests/CMakeTests/StringTestScript.cmake
+++ b/Tests/CMakeTests/StringTestScript.cmake
@@ -1,5 +1,18 @@
message(STATUS "testname='${testname}'")
+function(test_configure_line_number EXPRESSION POLICY)
+ cmake_policy(PUSH)
+ cmake_policy(SET CMP0053 ${POLICY})
+ string(CONFIGURE
+ "${EXPRESSION}" v) # line should indicate string() call
+ math(EXPR vplus3 "${v} + 3")
+ if(NOT ${CMAKE_CURRENT_LIST_LINE} EQUAL ${vplus3})
+ message(SEND_ERROR "Couldn't configure CMAKE_CURRENT_LIST_LINE, evaluated into '${v}'")
+ endif()
+ message(STATUS "v='${v}'")
+ cmake_policy(POP)
+endfunction()
+
if(testname STREQUAL empty) # fail
string()
@@ -32,6 +45,18 @@ elseif(testname STREQUAL configure_escape_quotes) # pass
string(CONFIGURE "this is @testname@" v ESCAPE_QUOTES)
message(STATUS "v='${v}'")
+elseif(testname STREQUAL configure_line_number_CMP0053_old) # pass
+ test_configure_line_number("\${CMAKE_CURRENT_LIST_LINE}" OLD)
+
+elseif(testname STREQUAL configure_line_number_CMP0053_new) # pass
+ test_configure_line_number("\${CMAKE_CURRENT_LIST_LINE}" NEW)
+
+elseif(testname STREQUAL configure_line_number_CMP0053_old_use_at) # pass
+ test_configure_line_number("\@CMAKE_CURRENT_LIST_LINE\@" OLD)
+
+elseif(testname STREQUAL configure_line_number_CMP0053_new_use_at) # pass
+ test_configure_line_number("\@CMAKE_CURRENT_LIST_LINE\@" NEW)
+
elseif(testname STREQUAL configure_bogus) # fail
string(CONFIGURE "this is @testname@" v ESCAPE_QUOTES BOGUS)
diff --git a/Tests/COnly/CMakeLists.txt b/Tests/COnly/CMakeLists.txt
index b3cc43813..20615fea1 100644
--- a/Tests/COnly/CMakeLists.txt
+++ b/Tests/COnly/CMakeLists.txt
@@ -7,17 +7,11 @@ add_library(testc1 STATIC libc1.c)
add_library(testc2 SHARED libc2.c)
add_executable (COnly conly.c foo.c foo.h)
target_link_libraries(COnly testc1 testc2)
-if(MSVC_VERSION)
+if(MSVC_VERSION AND NOT CMAKE_C_COMPILER_ID STREQUAL Clang OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC")
set_target_properties(COnly PROPERTIES
LINK_FLAGS " /NODEFAULTLIB:\"libcdg.lib\" /NODEFAULTLIB:\"libcmtg.lib\" /NODEFAULTLIB:\"foomsvcrt.lib\" /NODEFAULTLIB:\"libbar.lib\" /NODEFAULTLIB:\"libfooba.lib\"")
endif()
string(ASCII 35 32 67 77 97 107 101 ASCII_STRING)
message(STATUS "String: ${ASCII_STRING}")
-get_source_file_property(LANG conly.c LANGUAGE)
-if("${LANG}" STREQUAL "C")
- message("Language is C")
-else()
- message(FATAL_ERROR "Bad language for file conly.c")
-endif()
add_library(testCModule MODULE testCModule.c)
diff --git a/Tests/COnly/conly.c b/Tests/COnly/conly.c
index 7bd8e8e15..2ae8a1acc 100644
--- a/Tests/COnly/conly.c
+++ b/Tests/COnly/conly.c
@@ -1,10 +1,9 @@
-#include "foo.h"
+#include <stdio.h>
+#include "foo.h"
#include "libc1.h"
#include "libc2.h"
-#include <stdio.h>
-
int main()
{
int class = 0;
diff --git a/Tests/COnly/libc2.h b/Tests/COnly/libc2.h
index 7bc4fb1c8..43ebce914 100644
--- a/Tests/COnly/libc2.h
+++ b/Tests/COnly/libc2.h
@@ -1,11 +1,11 @@
#ifdef _WIN32
-#ifdef testc2_EXPORTS
-#define CM_TEST_LIB_EXPORT __declspec(dllexport)
+# ifdef testc2_EXPORTS
+# define CM_TEST_LIB_EXPORT __declspec(dllexport)
+# else
+# define CM_TEST_LIB_EXPORT __declspec(dllimport)
+# endif
#else
-#define CM_TEST_LIB_EXPORT __declspec(dllimport)
-#endif
-#else
-#define CM_TEST_LIB_EXPORT
+# define CM_TEST_LIB_EXPORT
#endif
CM_TEST_LIB_EXPORT float LibC2Func();
diff --git a/Tests/COnly/testCModule.c b/Tests/COnly/testCModule.c
index 4381bd746..edeb2b1fd 100644
--- a/Tests/COnly/testCModule.c
+++ b/Tests/COnly/testCModule.c
@@ -1,7 +1,7 @@
#ifdef _WIN32
-#define TEST_EXPORT __declspec(dllexport)
+# define TEST_EXPORT __declspec(dllexport)
#else
-#define TEST_EXPORT
+# define TEST_EXPORT
#endif
TEST_EXPORT int testCModule(void)
{
diff --git a/Tests/CPackComponents/mylib.cpp b/Tests/CPackComponents/mylib.cpp
index 8ddac198c..8d6307164 100644
--- a/Tests/CPackComponents/mylib.cpp
+++ b/Tests/CPackComponents/mylib.cpp
@@ -1,4 +1,5 @@
#include "mylib.h"
+
#include "stdio.h"
void mylib_function()
diff --git a/Tests/CPackComponentsDEB/CMakeLists.txt b/Tests/CPackComponentsDEB/CMakeLists.txt
index 9d4b5e9df..bc5b6a947 100644
--- a/Tests/CPackComponentsDEB/CMakeLists.txt
+++ b/Tests/CPackComponentsDEB/CMakeLists.txt
@@ -4,8 +4,8 @@
# application (mylibapp). We create a binary installer (a CPack Generator)
# which supports CPack components.
-cmake_minimum_required(VERSION 2.8.3.20101130 FATAL_ERROR)
-project(CPackComponentsDEB)
+cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
+project(CPackComponentsDEB VERSION 1.0.3)
# Use GNUInstallDirs in order to enforce lib64 if needed
include(GNUInstallDirs)
@@ -44,10 +44,6 @@ set(CPACK_PACKAGE_NAME "MyLib")
set(CPACK_PACKAGE_CONTACT "None")
set(CPACK_PACKAGE_VENDOR "CMake.org")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyLib - CPack Component Installation Example")
-set(CPACK_PACKAGE_VERSION "1.0.2")
-set(CPACK_PACKAGE_VERSION_MAJOR "1")
-set(CPACK_PACKAGE_VERSION_MINOR "0")
-set(CPACK_PACKAGE_VERSION_PATCH "2")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example")
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/license.txt)
diff --git a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in
index 74d816cf6..67b108bef 100644
--- a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in
+++ b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in
@@ -15,8 +15,9 @@ set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
#set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
# overriding previous descriptions
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "main description")
-set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "applications_description")
-set(CPACK_COMPONENT_HEADERS_DESCRIPTION "headers_description")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "main description") # This become a summary line (the first one) of all descriptions
+set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "applications_description")
+set(CPACK_COMPONENT_HEADERS_DESCRIPTION "headers_description")
# libraries does not have any description and should inherit from CPACK_PACKAGE_DESCRIPTION_SUMMARY
+# plus content of the `CPACK_PACKAGE_DESCRIPTION_FILE`.
unset(CPACK_COMPONENT_LIBRARIES_DESCRIPTION)
diff --git a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description2.cmake.in b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description2.cmake.in
index cda79bc02..d87732558 100644
--- a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description2.cmake.in
+++ b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description2.cmake.in
@@ -15,12 +15,12 @@ set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
#set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1)
# overriding previous descriptions
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "main description 2")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "main description 2")
-# Components do not have any description
+# Components do not have any description.
+# So, content of `CPACK_PACKAGE_DESCRIPTION_FILE` gonna used
+# after summary line.
unset(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION)
unset(CPACK_COMPONENT_HEADERS_DESCRIPTION)
-unset(CPACK_COMPONENT_LIBRARIES_DESCRIPTION)
-
-set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "library description")
+set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "library description")
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake
index 70d6edf49..beccc4691 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend1.cmake
@@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.3_*.deb")
set(expected_count 3)
@@ -36,7 +36,6 @@ endif()
# dpkg-deb checks for the dependencies of the packages
find_program(DPKGDEB_EXECUTABLE dpkg-deb)
if(DPKGDEB_EXECUTABLE)
- set(dpkgdeb_output_errors_all "")
foreach(_f IN LISTS actual_output)
# extracts the metadata from the package
@@ -54,32 +53,23 @@ if(DPKGDEB_EXECUTABLE)
message(STATUS "package='${dpkg_package_name}', dependencies='${dpkg_depends}'")
- if("${dpkg_package_name}" STREQUAL "mylib-applications")
- if(NOT "${dpkg_depends}" STREQUAL "depend-application")
- set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
- "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-application'\n")
+ if(dpkg_package_name STREQUAL "mylib-applications")
+ if(NOT dpkg_depends STREQUAL "depend-application")
+ message(SEND_ERROR "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-application'\n")
endif()
- elseif("${dpkg_package_name}" STREQUAL "mylib-headers")
- if(NOT "${dpkg_depends}" STREQUAL "mylib-libraries (= 1.0.2), depend-headers")
- set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
- "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'mylib-libraries (= 1.0.2), depend-headers'\n")
+ elseif(dpkg_package_name STREQUAL "mylib-headers")
+ if(NOT dpkg_depends STREQUAL "mylib-libraries (= 1.0.3), depend-headers")
+ message(SEND_ERROR "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'mylib-libraries (= 1.0.3), depend-headers'\n")
endif()
- elseif("${dpkg_package_name}" STREQUAL "mylib-libraries")
- if(NOT "${dpkg_depends}" STREQUAL "depend-default")
- set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
- "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-default'\n")
+ elseif(dpkg_package_name STREQUAL "mylib-libraries")
+ if(NOT dpkg_depends STREQUAL "depend-default")
+ message(SEND_ERROR "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-default'\n")
endif()
else()
- set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
- "dpkg-deb: ${_f}: component name not found: ${dpkg_package_name}\n")
+ message(SEND_ERROR "dpkg-deb: ${_f}: component name not found: ${dpkg_package_name}\n")
endif()
endforeach()
-
-
- if(NOT "${dpkgdeb_output_errors_all}" STREQUAL "")
- message(FATAL_ERROR "dpkg-deb checks failed:\n${dpkgdeb_output_errors_all}")
- endif()
else()
message("dpkg-deb executable not found - skipping dpkg-deb test")
endif()
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake
index 415d5360a..88f3248d9 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-depend2.cmake
@@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.3_*.deb")
set(expected_count 3)
set(config_verbose -V)
@@ -36,7 +36,6 @@ endif()
# dpkg-deb checks for the summary of the packages
find_program(DPKGDEB_EXECUTABLE dpkg-deb)
if(DPKGDEB_EXECUTABLE)
- set(dpkgdeb_output_errors_all "")
foreach(_f IN LISTS actual_output)
# extracts the metadata from the package
@@ -54,13 +53,11 @@ if(DPKGDEB_EXECUTABLE)
message(STATUS "package='${dpkg_package_name}', dependencies='${dpkg_depends}'")
- if("${dpkg_package_name}" STREQUAL "mylib-applications")
+ if(dpkg_package_name STREQUAL "mylib-applications")
find_program(DPKG_SHLIBDEP_EXECUTABLE dpkg-shlibdeps)
if(DPKG_SHLIBDEP_EXECUTABLE)
- string(FIND "${dpkg_depends}" "lib" index_libwhatever)
- if(NOT index_libwhatever GREATER "-1")
- set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
- "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' does not contain any 'lib'\n")
+ if(NOT dpkg_depends MATCHES "lib")
+ message(SEND_ERROR "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' does not contain any 'lib'\n")
endif()
else()
message("dpkg-shlibdeps executable not found - skipping dpkg-shlibdeps test")
@@ -69,29 +66,20 @@ if(DPKGDEB_EXECUTABLE)
# should not contain the default
string(FIND "${dpkg_depends}" "depend-default" index_default)
if(index_default GREATER "0")
- set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
- "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' does contains 'depend-default'\n")
+ message(SEND_ERROR "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' does contains 'depend-default'\n")
endif()
- elseif("${dpkg_package_name}" STREQUAL "mylib-headers")
- if(NOT "${dpkg_depends}" STREQUAL "mylib-libraries (= 1.0.2), depend-headers")
- set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
- "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'mylib-libraries (= 1.0.2), depend-headers'\n")
+ elseif(dpkg_package_name STREQUAL "mylib-headers")
+ if(NOT dpkg_depends STREQUAL "mylib-libraries (= 1.0.3), depend-headers")
+ message(SEND_ERROR "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'mylib-libraries (= 1.0.3), depend-headers'\n")
endif()
- elseif("${dpkg_package_name}" STREQUAL "mylib-libraries")
- if(NOT "${dpkg_depends}" STREQUAL "depend-default")
- set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
- "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-default'\n")
+ elseif(dpkg_package_name STREQUAL "mylib-libraries")
+ if(NOT dpkg_depends STREQUAL "depend-default")
+ message(SEND_ERROR "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-default'\n")
endif()
else()
- set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
- "dpkg-deb: ${_f}: component name not found: ${dpkg_package_name}\n")
+ message(SEND_ERROR "dpkg-deb: ${_f}: component name not found: ${dpkg_package_name}\n")
endif()
-
endforeach()
-
- if(NOT "${dpkgdeb_output_errors_all}" STREQUAL "")
- message(FATAL_ERROR "dpkg-deb checks failed:\n${dpkgdeb_output_errors_all}")
- endif()
else()
message("dpkg-deb executable not found - skipping dpkg-deb test")
endif()
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake
index 337cc1675..f46a57549 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake
@@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.3_*.deb")
set(expected_count 3)
@@ -48,26 +48,27 @@ if(DPKGDEB_EXECUTABLE)
DPKGDEB_OUTPUT "${dpkg_output}"
METAENTRY "Package:")
- dpkgdeb_return_specific_metaentry(dpkg_description
- DPKGDEB_OUTPUT "${dpkg_output}"
- METAENTRY "Description:")
+ get_package_description("${dpkg_output}" dpkg_description)
message(STATUS "package='${dpkg_package_name}', description='${dpkg_description}'")
- if("${dpkg_package_name}" STREQUAL "mylib-applications")
- if(NOT "${dpkg_description}" STREQUAL "applications_description")
+ if(dpkg_package_name STREQUAL "mylib-applications")
+ set(expected_description "main description\n applications_description")
+ if(NOT dpkg_description STREQUAL expected_description)
set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
- "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != applications_description")
+ "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` != `${expected_description}`")
endif()
- elseif("${dpkg_package_name}" STREQUAL "mylib-headers")
- if(NOT "${dpkg_description}" STREQUAL "headers_description")
+ elseif(dpkg_package_name STREQUAL "mylib-headers")
+ set(expected_description "main description\n headers_description")
+ if(NOT dpkg_description STREQUAL expected_description)
set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
- "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != headers_description")
+ "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` != `${expected_description}`")
endif()
- elseif("${dpkg_package_name}" STREQUAL "mylib-libraries")
- if(NOT "${dpkg_description}" STREQUAL "main description")
+ elseif(dpkg_package_name STREQUAL "mylib-libraries")
+ set(expected_description "main description")
+ if(NOT dpkg_description STREQUAL expected_description)
set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
- "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != 'main description'")
+ "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` != `${expected_description}`")
endif()
else()
set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
@@ -77,7 +78,7 @@ if(DPKGDEB_EXECUTABLE)
endforeach()
- if(NOT "${dpkgdeb_output_errors_all}" STREQUAL "")
+ if(NOT dpkgdeb_output_errors_all STREQUAL "")
message(FATAL_ERROR "dpkg-deb checks failed:\n${dpkgdeb_output_errors_all}")
endif()
else()
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake
index 35ca74cdd..c00921a68 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake
@@ -7,7 +7,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.3_*.deb")
set(expected_count 3)
@@ -48,26 +48,21 @@ if(DPKGDEB_EXECUTABLE)
DPKGDEB_OUTPUT "${dpkg_output}"
METAENTRY "Package:")
- dpkgdeb_return_specific_metaentry(dpkg_description
- DPKGDEB_OUTPUT "${dpkg_output}"
- METAENTRY "Description:")
+ get_package_description("${dpkg_output}" dpkg_description)
message(STATUS "package='${dpkg_package_name}', description='${dpkg_description}'")
- if("${dpkg_package_name}" STREQUAL "mylib-applications")
- if(NOT "${dpkg_description}" STREQUAL "main description 2")
- set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
- "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != applications_description")
- endif()
- elseif("${dpkg_package_name}" STREQUAL "mylib-headers")
- if(NOT "${dpkg_description}" STREQUAL "main description 2")
+ if(dpkg_package_name STREQUAL "mylib-applications" OR dpkg_package_name STREQUAL "mylib-headers")
+ set(expected_description "main description 2")
+ if(NOT dpkg_description STREQUAL expected_description)
set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
- "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != headers_description")
+ "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` != `${expected_description}`")
endif()
- elseif("${dpkg_package_name}" STREQUAL "mylib-libraries")
- if(NOT "${dpkg_description}" STREQUAL "library description")
+ elseif(dpkg_package_name STREQUAL "mylib-libraries")
+ set(expected_description "main description 2\n library description")
+ if(NOT dpkg_description STREQUAL expected_description)
set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
- "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != 'main description'")
+ "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` != `${expected_description}`")
endif()
else()
set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
@@ -77,7 +72,7 @@ if(DPKGDEB_EXECUTABLE)
endforeach()
- if(NOT "${dpkgdeb_output_errors_all}" STREQUAL "")
+ if(NOT dpkgdeb_output_errors_all STREQUAL "")
message(FATAL_ERROR "dpkg-deb checks failed:\n${dpkgdeb_output_errors_all}")
endif()
else()
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake
index f1391cd73..7cfbb1655 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake
@@ -4,8 +4,8 @@ endif()
include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
-# TODO: currently debian doens't produce lower cased names
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
+# TODO: currently debian doesn't produce lower cased names
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.3_*.deb")
set(expected_count 3)
@@ -44,7 +44,7 @@ if(LINTIAN_EXECUTABLE)
string(APPEND lintian_output_errors_all "${lintian_output_errors}")
endforeach()
- if(NOT "${lintian_output_errors_all}" STREQUAL "")
+ if(NOT lintian_output_errors_all STREQUAL "")
message(FATAL_ERROR "Lintian checks failed:\n${lintian_output_errors_all}")
endif()
else()
@@ -64,13 +64,13 @@ if(DPKGDEB_EXECUTABLE)
DPKGDEB_OUTPUT "${dpkg_output}"
METAENTRY "Maintainer:")
- if(NOT "${dpkgentry}" STREQUAL "None")
+ if(NOT dpkgentry STREQUAL "None")
set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
"dpkg-deb: ${_f}: Incorrect value for Maintainer: ${dpkgentry} != None\n")
endif()
endforeach()
- if(NOT "${dpkgdeb_output_errors_all}" STREQUAL "")
+ if(NOT dpkgdeb_output_errors_all STREQUAL "")
message(FATAL_ERROR "dpkg-deb checks failed:\n${dpkgdeb_output_errors_all}")
endif()
else()
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake
index fcfc7eaee..6eff3dbff 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-shlibdeps1.cmake
@@ -9,7 +9,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# requirements
# debian now produces lower case names
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.3_*.deb")
set(expected_count 3)
@@ -39,7 +39,7 @@ endif()
# dpkg-deb checks for the summary of the packages
find_program(DPKGDEB_EXECUTABLE dpkg-deb)
if(DPKGDEB_EXECUTABLE)
- set(dpkgdeb_output_errors_all)
+ set(dpkgdeb_output_errors_all "")
foreach(_f IN LISTS actual_output)
# extracts the metadata from the package
@@ -53,11 +53,11 @@ if(DPKGDEB_EXECUTABLE)
message(STATUS "package='${dpkg_package_name}'")
- if("${dpkg_package_name}" STREQUAL "mylib-applications")
+ if(dpkg_package_name STREQUAL "mylib-applications")
# pass
- elseif("${dpkg_package_name}" STREQUAL "mylib-headers")
+ elseif(dpkg_package_name STREQUAL "mylib-headers")
# pass
- elseif("${dpkg_package_name}" STREQUAL "mylib-libraries")
+ elseif(dpkg_package_name STREQUAL "mylib-libraries")
# pass
else()
set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
@@ -67,7 +67,7 @@ if(DPKGDEB_EXECUTABLE)
endforeach()
- if(NOT "${dpkgdeb_output_errors_all}" STREQUAL "")
+ if(NOT dpkgdeb_output_errors_all STREQUAL "")
message(FATAL_ERROR "dpkg-deb checks failed:\n${dpkgdeb_output_errors_all}")
endif()
else()
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake
index 351bf2148..3454dca89 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-source.cmake
@@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.3_*.deb")
set(expected_count 3)
set(config_verbose -V)
@@ -36,7 +36,6 @@ endif()
# dpkg-deb checks for the summary of the packages
find_program(DPKGDEB_EXECUTABLE dpkg-deb)
if(DPKGDEB_EXECUTABLE)
- set(dpkgdeb_output_errors_all "")
foreach(_f IN LISTS actual_output)
# extracts the metadata from the package
@@ -54,22 +53,16 @@ if(DPKGDEB_EXECUTABLE)
message(STATUS "package='${_f}', source='${dpkg_package_source}'")
- if(NOT ("${dpkg_package_name}" STREQUAL "mylib-applications"))
- if(NOT ("${dpkg_package_source}" STREQUAL "test-source"))
- set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
- "dpkg-deb: ${_f}: Incorrect source for package '${dpkg_package_name}': '${dpkg_package_source}' instead of 'test-source'\n")
+ if(NOT dpkg_package_name STREQUAL "mylib-applications")
+ if(NOT dpkg_package_source STREQUAL "test-source")
+ message(SEND_ERROR "dpkg-deb: ${_f}: Incorrect source for package '${dpkg_package_name}': '${dpkg_package_source}' instead of 'test-source'\n")
endif()
else()
- if(NOT ("${dpkg_package_source}" STREQUAL "test-other-source"))
- set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
- "dpkg-deb: ${_f}: Incorrect source for package '${dpkg_package_name}': '${dpkg_package_source}' instead of 'test-other-source'\n")
+ if(NOT dpkg_package_source STREQUAL "test-other-source")
+ message(SEND_ERROR "dpkg-deb: ${_f}: Incorrect source for package '${dpkg_package_name}': '${dpkg_package_source}' instead of 'test-other-source'\n")
endif()
endif()
endforeach()
-
- if(NOT "${dpkgdeb_output_errors_all}" STREQUAL "")
- message(FATAL_ERROR "dpkg-deb checks failed:\n${dpkgdeb_output_errors_all}")
- endif()
else()
message("dpkg-deb executable not found - skipping dpkg-deb test")
endif()
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake
index c97ecb019..764fe9df4 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-compression.cmake
@@ -4,8 +4,8 @@ endif()
include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
-# TODO: currently debian doens't produce lower cased names
-set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib_1.0.2-1_*.deb")
+# TODO: currently debian doesn't produce lower cased names
+set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib_1.0.3_*.deb")
set(expected_count 1)
set(actual_output)
@@ -33,22 +33,16 @@ endif()
# dpkg-deb checks
find_program(DPKGDEB_EXECUTABLE dpkg-deb)
if(DPKGDEB_EXECUTABLE)
- set(dpkgdeb_output_errors_all "")
foreach(_f IN LISTS actual_output)
run_dpkgdeb(dpkg_output
FILENAME "${_f}"
)
# message(FATAL_ERROR "output = '${dpkg_output}'")
- if("${dpkg_output}" STREQUAL "")
- set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
- "dpkg-deb: ${_f}: empty content returned by dpkg-deb")
+ if(dpkg_output STREQUAL "")
+ message(SEND_ERROR "dpkg-deb: ${_f}: empty content returned by dpkg-deb")
endif()
endforeach()
-
- if(NOT "${dpkgdeb_output_errors_all}" STREQUAL "")
- message(FATAL_ERROR "dpkg-deb checks failed:\n${dpkgdeb_output_errors_all}")
- endif()
else()
message("dpkg-deb executable not found - skipping dpkg-deb test")
endif()
diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult.cmake
index 2f9e2fc92..b172da2cd 100644
--- a/Tests/CPackComponentsDEB/RunCPackVerifyResult.cmake
+++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult.cmake
@@ -119,13 +119,13 @@ function(lintian_check_specific_errors output_errors)
# regex to avoid
foreach(_s IN LISTS lintian_check_specific_errors_deb_ERROR_REGEX_STRINGS)
- if("${_s}" STREQUAL "")
+ if(_s STREQUAL "")
continue()
endif()
string(REGEX MATCHALL "${_s}" "_TMP_CHECK_ERROR" "${lintian_output}")
- if(NOT "${_TMP_CHECK_ERROR}" STREQUAL "")
+ if(NOT _TMP_CHECK_ERROR STREQUAL "")
string(APPEND ERROR_ACC "\nlintian: ${_f}: output contains an undesirable regex:\n\t${_TMP_CHECK_ERROR}")
endif()
endforeach()
@@ -167,7 +167,7 @@ function(run_dpkgdeb dpkg_deb_output)
ERROR_VARIABLE DPKGDEB_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE )
- if(NOT ("${DPKGDEB_RESULT}" EQUAL "0"))
+ if(NOT DPKGDEB_RESULT EQUAL "0")
message(FATAL_ERROR "Error '${DPKGDEB_RESULT}' returned by dpkg-deb: '${DPKGDEB_ERROR}'")
endif()
@@ -200,4 +200,29 @@ function(dpkgdeb_return_specific_metaentry output)
endif()
endfunction()
+function(get_package_description DPKG_OUTPUT RESULT_VAR)
+ string(UUID uuid NAMESPACE 00000000-0000-0000-0000-000000000000 TYPE SHA1)
+ string(REPLACE ";" "${uuid}" DPKG_OUTPUT "${DPKG_OUTPUT}")
+ string(REPLACE "\n" ";" DPKG_OUTPUT "${DPKG_OUTPUT}")
+
+ unset(_actual_description)
+ set(_parse_description FALSE)
+ foreach(_line IN LISTS DPKG_OUTPUT)
+ if(_line MATCHES " Description:.*")
+ set(_parse_description TRUE)
+ string(REPLACE " Description: " "" _line "${_line}")
+ list(APPEND _actual_description "${_line}")
+ elseif(_parse_description)
+ if(_line MATCHES " [A-Z][A-Za-z\-]+: .*")
+ set(_parse_description FALSE)
+ else()
+ list(APPEND _actual_description "${_line}")
+ endif()
+ endif()
+ endforeach()
+ list(JOIN _actual_description "\n" _actual_description)
+
+ set(${RESULT_VAR} "${_actual_description}" PARENT_SCOPE)
+endfunction()
+
cmake_policy(POP)
diff --git a/Tests/CPackComponentsDEB/mylib.cpp b/Tests/CPackComponentsDEB/mylib.cpp
index 8ddac198c..8d6307164 100644
--- a/Tests/CPackComponentsDEB/mylib.cpp
+++ b/Tests/CPackComponentsDEB/mylib.cpp
@@ -1,4 +1,5 @@
#include "mylib.h"
+
#include "stdio.h"
void mylib_function()
diff --git a/Tests/CPackComponentsForAll/CMakeLists.txt b/Tests/CPackComponentsForAll/CMakeLists.txt
index 344084317..e49138a58 100644
--- a/Tests/CPackComponentsForAll/CMakeLists.txt
+++ b/Tests/CPackComponentsForAll/CMakeLists.txt
@@ -168,6 +168,18 @@ set(CPACK_RPM_RELOCATION_PATHS "${CMAKE_INSTALL_INCLUDEDIR}"
# set CPACK_DEBIAN_FILE_NAME to use default package name format
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
+# set some tags for NuGet packages
+# 1. all in one package
+set(CPACK_NUGET_PACKAGE_TAGS "nuget" "unit" "test" "all-in-one")
+# 2. per component packages
+set(CPACK_NUGET_APPLICATIONS_PACKAGE_TAGS "nuget" "unit" "test" "applications")
+set(CPACK_NUGET_LIBRARIES_PACKAGE_TAGS "nuget" "unit" "test" "libraries")
+set(CPACK_NUGET_HEADERS_PACKAGE_TAGS "nuget" "unit" "test" "headers")
+set(CPACK_NUGET_UNSPECIFIED_PACKAGE_TAGS "nuget" "unit" "test" "uNsP3c1FiEd")
+# 3. per group packages
+set(CPACK_NUGET_RUNTIME_PACKAGE_TAGS "nuget" "unit" "test" "run-time")
+set(CPACK_NUGET_DEVELOPMENT_PACKAGE_TAGS "nuget" "unit" "test" "development")
+
# We may use the CPack specific config file in order
# to tailor CPack behavior on a CPack generator specific way
# (Behavior would be different for RPM or TGZ or DEB ...)
diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in
index 0bfbf1467..1b9e6584d 100644
--- a/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in
+++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in
@@ -13,6 +13,10 @@ if(CPACK_GENERATOR MATCHES "DEB")
set(CPACK_DEB_COMPONENT_INSTALL "ON")
endif()
+if(CPACK_GENERATOR MATCHES "NuGet")
+ set(CPACK_NUGET_COMPONENT_INSTALL "ON")
+endif()
+
#
# Choose grouping way
#
diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in
index 0ffe44d3a..a6f6ea9e8 100644
--- a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in
+++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in
@@ -52,6 +52,10 @@ if(CPACK_GENERATOR MATCHES "DEB")
set(CPACK_DEB_COMPONENT_INSTALL "ON")
endif()
+if(CPACK_GENERATOR MATCHES "NuGet")
+ set(CPACK_NUGET_COMPONENT_INSTALL "ON")
+endif()
+
#
# Choose grouping way
#
diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in
index ac65dc996..d41225d1f 100644
--- a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in
+++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in
@@ -18,6 +18,10 @@ if(CPACK_GENERATOR MATCHES "DragNDrop")
set(CPACK_COMPONENTS_GROUPING "ONE_PER_GROUP")
endif()
+if(CPACK_GENERATOR MATCHES "NuGet")
+ set(CPACK_NUGET_COMPONENT_INSTALL "ON")
+endif()
+
#
# Choose grouping way
#
diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
index a5b38fdb6..253d128f1 100644
--- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
+++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake
@@ -38,57 +38,69 @@ set(config_verbose )
if(CPackGen MATCHES "ZIP")
set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip")
- if (${CPackComponentWay} STREQUAL "default")
+ if(${CPackComponentWay} STREQUAL "default")
set(expected_count 1)
- elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
+ elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup")
set(expected_count 3)
- elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
+ elseif(${CPackComponentWay} STREQUAL "IgnoreGroup")
set(expected_count 4)
- elseif (${CPackComponentWay} STREQUAL "AllInOne")
+ elseif(${CPackComponentWay} STREQUAL "AllInOne")
set(expected_count 1)
- endif ()
-elseif (CPackGen MATCHES "RPM")
+ endif()
+elseif(CPackGen MATCHES "RPM")
set(config_verbose -D "CPACK_RPM_PACKAGE_DEBUG=1")
set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.rpm")
- if (${CPackComponentWay} STREQUAL "default")
+ if(${CPackComponentWay} STREQUAL "default")
set(expected_count 1)
- elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
+ elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup")
set(expected_count 3)
- elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
+ elseif(${CPackComponentWay} STREQUAL "IgnoreGroup")
set(expected_count 4)
- elseif (${CPackComponentWay} STREQUAL "AllInOne")
+ elseif(${CPackComponentWay} STREQUAL "AllInOne")
set(expected_count 1)
- endif ()
-elseif (CPackGen MATCHES "DEB")
- set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/mylib*_1.0.2-1_*.deb")
- if (${CPackComponentWay} STREQUAL "default")
+ endif()
+elseif(CPackGen MATCHES "DEB")
+ set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/mylib*_1.0.2_*.deb")
+ if(${CPackComponentWay} STREQUAL "default")
set(expected_count 1)
- elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
+ elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup")
set(expected_count 3)
- elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
+ elseif(${CPackComponentWay} STREQUAL "IgnoreGroup")
set(expected_count 4)
- elseif (${CPackComponentWay} STREQUAL "AllInOne")
+ elseif(${CPackComponentWay} STREQUAL "AllInOne")
set(expected_count 1)
- endif ()
+ endif()
+elseif(CPackGen MATCHES "NuGet")
+ set(config_verbose -D "CPACK_NUGET_PACKAGE_DEBUG=1")
+ set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib*1.0.2.nupkg")
+ if(${CPackComponentWay} STREQUAL "default")
+ set(expected_count 1)
+ elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup")
+ set(expected_count 3)
+ elseif(${CPackComponentWay} STREQUAL "IgnoreGroup")
+ set(expected_count 4)
+ elseif(${CPackComponentWay} STREQUAL "AllInOne")
+ set(expected_count 1)
+ endif()
endif()
if(CPackGen MATCHES "DragNDrop")
set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.dmg")
- if (${CPackComponentWay} STREQUAL "default")
+ if(${CPackComponentWay} STREQUAL "default")
set(expected_count 1)
- elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")
+ elseif(${CPackComponentWay} STREQUAL "OnePackPerGroup")
set(expected_count 3)
- elseif (${CPackComponentWay} STREQUAL "IgnoreGroup")
+ elseif(${CPackComponentWay} STREQUAL "IgnoreGroup")
set(expected_count 4)
- elseif (${CPackComponentWay} STREQUAL "AllInOne")
+ elseif(${CPackComponentWay} STREQUAL "AllInOne")
set(expected_count 1)
- endif ()
+ endif()
endif()
# clean-up previously CPack generated files
if(expected_file_mask)
file(GLOB expected_file "${expected_file_mask}")
- if (expected_file)
+ if(expected_file)
file(REMOVE ${expected_file})
endif()
endif()
@@ -101,7 +113,7 @@ execute_process(COMMAND ${CMAKE_CPACK_COMMAND} ${config_verbose} -G ${CPackGen}
ERROR_VARIABLE CPack_error
WORKING_DIRECTORY ${CPackComponentsForAll_BINARY_DIR})
-if (CPack_result)
+if(CPack_result)
message(FATAL_ERROR "error: CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}")
else ()
message(STATUS "CPack_output=${CPack_output}")
diff --git a/Tests/CPackComponentsForAll/mylib.cpp b/Tests/CPackComponentsForAll/mylib.cpp
index 8ddac198c..8d6307164 100644
--- a/Tests/CPackComponentsForAll/mylib.cpp
+++ b/Tests/CPackComponentsForAll/mylib.cpp
@@ -1,4 +1,5 @@
#include "mylib.h"
+
#include "stdio.h"
void mylib_function()
diff --git a/Tests/CPackUseDefaultVersion/CMakeLists.txt b/Tests/CPackUseDefaultVersion/CMakeLists.txt
new file mode 100644
index 000000000..9f21f3afb
--- /dev/null
+++ b/Tests/CPackUseDefaultVersion/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.2)
+project(CPackUseProjectVersion NONE)
+
+include(CPack)
+
+message("CPACK_PACKAGE_VERSION=${CPACK_PACKAGE_VERSION}")
diff --git a/Tests/CPackUseProjectVersion/CMakeLists.txt b/Tests/CPackUseProjectVersion/CMakeLists.txt
new file mode 100644
index 000000000..d4770ae75
--- /dev/null
+++ b/Tests/CPackUseProjectVersion/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.2)
+project(CPackUseProjectVersion VERSION 1.2.3 LANGUAGES NONE)
+
+include(CPack)
+
+message("CPACK_PACKAGE_VERSION=${CPACK_PACKAGE_VERSION}")
diff --git a/Tests/CPackUseShortProjectVersion/CMakeLists.txt b/Tests/CPackUseShortProjectVersion/CMakeLists.txt
new file mode 100644
index 000000000..855bc6401
--- /dev/null
+++ b/Tests/CPackUseShortProjectVersion/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.2)
+project(CPackUseProjectVersion VERSION 2 LANGUAGES NONE)
+
+include(CPack)
+
+message("CPACK_PACKAGE_VERSION=${CPACK_PACKAGE_VERSION}")
diff --git a/Tests/CPackWiXGenerator/mylib.cpp b/Tests/CPackWiXGenerator/mylib.cpp
index 8ddac198c..8d6307164 100644
--- a/Tests/CPackWiXGenerator/mylib.cpp
+++ b/Tests/CPackWiXGenerator/mylib.cpp
@@ -1,4 +1,5 @@
#include "mylib.h"
+
#include "stdio.h"
void mylib_function()
diff --git a/Tests/CSharpLinkFromCxx/.gitattributes b/Tests/CSharpLinkFromCxx/.gitattributes
new file mode 100644
index 000000000..cf9d35537
--- /dev/null
+++ b/Tests/CSharpLinkFromCxx/.gitattributes
@@ -0,0 +1 @@
+UsefulManagedCppClass.* -format.clang-format-6.0
diff --git a/Tests/CSharpLinkFromCxx/CMakeLists.txt b/Tests/CSharpLinkFromCxx/CMakeLists.txt
new file mode 100644
index 000000000..9a1a99379
--- /dev/null
+++ b/Tests/CSharpLinkFromCxx/CMakeLists.txt
@@ -0,0 +1,19 @@
+# Take a C# shared library and link it to a managed C++ shared library
+cmake_minimum_required(VERSION 3.10)
+project (CSharpLinkFromCxx CXX CSharp)
+
+add_library(CSharpLibrary SHARED UsefulCSharpClass.cs)
+
+# we have to change the default flags for the
+# managed C++ project to build
+string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
+
+# The C# project is a dependency of the C++/CLI project
+add_library(ManagedCppLibrary SHARED UsefulManagedCppClass.cpp UsefulManagedCppClass.hpp)
+target_compile_options(ManagedCppLibrary PRIVATE "/clr")
+target_link_libraries(ManagedCppLibrary PUBLIC CSharpLibrary)
+
+# Main executable for the test framework
+add_executable(CSharpLinkFromCxx CSharpLinkFromCxx.cs)
+target_link_libraries(CSharpLinkFromCxx PRIVATE ManagedCppLibrary)
diff --git a/Tests/CSharpLinkFromCxx/CSharpLinkFromCxx.cs b/Tests/CSharpLinkFromCxx/CSharpLinkFromCxx.cs
new file mode 100644
index 000000000..31a74ebf6
--- /dev/null
+++ b/Tests/CSharpLinkFromCxx/CSharpLinkFromCxx.cs
@@ -0,0 +1,16 @@
+using System;
+using CSharpLibrary;
+
+namespace CSharpLinkFromCxx
+{
+ internal class CSharpLinkFromCxx
+ {
+ public static void Main(string[] args)
+ {
+ Console.WriteLine("Starting test for CSharpLinkFromCxx");
+
+ var useful = new UsefulManagedCppClass();
+ useful.RunTest();
+ }
+ }
+}
diff --git a/Tests/CSharpLinkFromCxx/UsefulCSharpClass.cs b/Tests/CSharpLinkFromCxx/UsefulCSharpClass.cs
new file mode 100644
index 000000000..749e57dc2
--- /dev/null
+++ b/Tests/CSharpLinkFromCxx/UsefulCSharpClass.cs
@@ -0,0 +1,12 @@
+using System;
+
+namespace CSharpLibrary
+{
+ public class UsefulCSharpClass
+ {
+ public string GetSomethingUseful()
+ {
+ return "Something Useful";
+ }
+ }
+}
diff --git a/Tests/CSharpLinkFromCxx/UsefulManagedCppClass.cpp b/Tests/CSharpLinkFromCxx/UsefulManagedCppClass.cpp
new file mode 100644
index 000000000..94688125b
--- /dev/null
+++ b/Tests/CSharpLinkFromCxx/UsefulManagedCppClass.cpp
@@ -0,0 +1,15 @@
+#include "UsefulManagedCppClass.hpp"
+
+namespace CSharpLibrary
+{
+ UsefulManagedCppClass::UsefulManagedCppClass()
+ {
+ auto useful = gcnew UsefulCSharpClass();
+ m_usefulString = useful->GetSomethingUseful();
+ }
+
+ void UsefulManagedCppClass::RunTest()
+ {
+ Console::WriteLine("Printing from Managed CPP Class: " + m_usefulString);
+ }
+}
diff --git a/Tests/CSharpLinkFromCxx/UsefulManagedCppClass.hpp b/Tests/CSharpLinkFromCxx/UsefulManagedCppClass.hpp
new file mode 100644
index 000000000..def7cea0c
--- /dev/null
+++ b/Tests/CSharpLinkFromCxx/UsefulManagedCppClass.hpp
@@ -0,0 +1,16 @@
+using namespace System;
+
+namespace CSharpLibrary
+{
+ public ref class UsefulManagedCppClass
+ {
+ public:
+
+ UsefulManagedCppClass();
+ void RunTest();
+
+ private:
+
+ String^ m_usefulString;
+ };
+}
diff --git a/Tests/CSharpLinkToCxx/CMakeLists.txt b/Tests/CSharpLinkToCxx/CMakeLists.txt
index 153c57c90..a3067afa2 100644
--- a/Tests/CSharpLinkToCxx/CMakeLists.txt
+++ b/Tests/CSharpLinkToCxx/CMakeLists.txt
@@ -21,3 +21,9 @@ target_link_libraries(CSharpLinkToCxx CLIApp)
# because it is unmanaged
add_library(CppNativeApp SHARED cpp_native.hpp cpp_native.cpp)
target_link_libraries(CSharpLinkToCxx CppNativeApp)
+
+# Link a static C++ library into the CSharp executable.
+# We do not actually use any symbols but this helps cover
+# link language selection.
+add_library(CppStaticLib STATIC cpp_static.cpp)
+target_link_libraries(CSharpLinkToCxx CppStaticLib)
diff --git a/Tests/CSharpLinkToCxx/cpp_static.cpp b/Tests/CSharpLinkToCxx/cpp_static.cpp
new file mode 100644
index 000000000..9af2b6ea3
--- /dev/null
+++ b/Tests/CSharpLinkToCxx/cpp_static.cpp
@@ -0,0 +1,3 @@
+void cpp_static()
+{
+}
diff --git a/Tests/CSharpOnly/CMakeLists.txt b/Tests/CSharpOnly/CMakeLists.txt
index 0e3e39e21..82049c78d 100644
--- a/Tests/CSharpOnly/CMakeLists.txt
+++ b/Tests/CSharpOnly/CMakeLists.txt
@@ -8,3 +8,6 @@ add_library(lib2 SHARED lib2.cs)
add_executable(CSharpOnly csharponly.cs)
target_link_libraries(CSharpOnly lib1 lib2)
+
+add_custom_target(CSharpCustom ALL SOURCES empty.cs)
+add_custom_target(custom.cs ALL DEPENDS empty.txt)
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-OFF.cmake b/Tests/CSharpOnly/empty.cs
index e69de29bb..e69de29bb 100644
--- a/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-OFF.cmake
+++ b/Tests/CSharpOnly/empty.cs
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-ON.cmake b/Tests/CSharpOnly/empty.txt
index e69de29bb..e69de29bb 100644
--- a/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-ON.cmake
+++ b/Tests/CSharpOnly/empty.txt
diff --git a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in
index 670a8745f..0f5678160 100644
--- a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in
+++ b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in
@@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 2.8.10)
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/VSProjectInSubdir")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestBuildCommandProjectInSubdir/Nested")
set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
-set(CTEST_PROJECT_NAME "VSProjectInSubdir")
set(CTEST_BUILD_CONFIGURATION "@CTestTest_CONFIG@")
ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
diff --git a/Tests/CTestConfig/CMakeLists.txt b/Tests/CTestConfig/CMakeLists.txt
index f46d89a55..8c19adbe2 100644
--- a/Tests/CTestConfig/CMakeLists.txt
+++ b/Tests/CTestConfig/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.9)
project(CTestConfig)
include(CTest)
@@ -8,32 +8,41 @@ include(CTest)
# 'ctest -S script.cmake' call.
#
# In either case, we expect CMAKE_BUILD_TYPE to be defined for single-configuration
-# build trees and not defined for multi-configuration build trees.
+# build trees and not defined for multi-configuration build trees. The value of
+# CMAKE_CONFIGURATION_TYPES should not be relied upon to determine whether we
+# are using a multi-config generator or not, the GENERATOR_IS_MULTI_CONFIG
+# global property is the canonical way to do that as of CMake 3.9.
#
-if(CMAKE_CONFIGURATION_TYPES)
- # multi-configuration: expect not defined, error if defined
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
+ if(NOT DEFINED CMAKE_CONFIGURATION_TYPES OR CMAKE_CONFIGURATION_TYPES STREQUAL "")
+ message(FATAL_ERROR "CMAKE_CONFIGURATION_TYPES is not defined or is empty "
+ "(but must be defined and non-empty for a multi-configuration generator)")
+ endif()
if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "")
- message(FATAL_ERROR "CMAKE_CONFIGURATION_TYPES='${CMAKE_CONFIGURATION_TYPES}' CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}' is defined and non-empty (but should not be for a multi-configuration generator)")
+ message(FATAL_ERROR "CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}' is defined and non-empty "
+ "(but should not be for a multi-configuration generator)")
endif()
+ set(_configs ${CMAKE_CONFIGURATION_TYPES})
else()
- # single-configuration: expect defined, error if not defined
+ # Populating CMAKE_CONFIGURATION_TYPES even for single config generators is
+ # common enough for user projects that we don't want to consider it an error.
+ # We just need CMAKE_BUILD_TYPE to be set and ignore CMAKE_CONFIGURATION_TYPES.
if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
- message(FATAL_ERROR "CMAKE_BUILD_TYPE is not defined or is empty (but should be defined and non-empty for a single-configuration generator)")
+ message(FATAL_ERROR "CMAKE_BUILD_TYPE is not defined or is empty "
+ "(but should be defined and non-empty for a single-configuration generator)")
endif()
-endif()
-
-
-if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "")
add_definitions(-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}")
+ set(_configs ${CMAKE_BUILD_TYPE})
endif()
add_executable(ctc CTestConfig.cxx)
-foreach(cfg ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE})
+foreach(cfg ${_configs})
add_test(NAME ctc-${cfg} CONFIGURATIONS ${cfg} COMMAND ctc --config $<CONFIGURATION>)
- if(CMAKE_CONFIGURATION_TYPES)
+ if(_isMultiConfig)
set_property(TEST ctc-${cfg}
PROPERTY PASS_REGULAR_EXPRESSION "CMAKE_INTDIR is ${cfg}")
set_property(TEST ctc-${cfg}
diff --git a/Tests/CTestConfig/dashboard.cmake.in b/Tests/CTestConfig/dashboard.cmake.in
index 143fe717a..4bb1262c0 100644
--- a/Tests/CTestConfig/dashboard.cmake.in
+++ b/Tests/CTestConfig/dashboard.cmake.in
@@ -1,4 +1,4 @@
-set(CMAKE_CONFIGURATION_TYPES "@CMAKE_CONFIGURATION_TYPES@")
+set(_isMultiConfig "@_isMultiConfig@")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-dashboard")
@@ -11,7 +11,7 @@ message("CMAKE_COMMAND='${CMAKE_COMMAND}'")
message("CMAKE_CTEST_COMMAND='${CMAKE_CTEST_COMMAND}'")
set(arg "")
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT _isMultiConfig)
set(arg "-DCMAKE_BUILD_TYPE:STRING=@cfg@")
endif()
diff --git a/Tests/CTestConfig/script.cmake.in b/Tests/CTestConfig/script.cmake.in
index b6ccedb57..973c7b8c4 100644
--- a/Tests/CTestConfig/script.cmake.in
+++ b/Tests/CTestConfig/script.cmake.in
@@ -1,7 +1,6 @@
set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
set(CTEST_CMAKE_GENERATOR_PLATFORM "@CMAKE_GENERATOR_PLATFORM@")
set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
-set(CTEST_PROJECT_NAME "CTestConfig")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-script")
diff --git a/Tests/CTestCoverageCollectGCOV/fakegcov.cmake b/Tests/CTestCoverageCollectGCOV/fakegcov.cmake
index b0c3a9b9f..6df429256 100644
--- a/Tests/CTestCoverageCollectGCOV/fakegcov.cmake
+++ b/Tests/CTestCoverageCollectGCOV/fakegcov.cmake
@@ -1,14 +1,17 @@
+function(create_gcov_file gcda_full_path)
+ get_filename_component(gcda_name ${gcda_full_path} NAME)
+ string(REPLACE ".gcda" ".gcov" gcov_name "${gcda_name}")
+
+ file(STRINGS "${gcda_full_path}" source_file LIMIT_COUNT 1 ENCODING UTF-8)
+
+ file(WRITE "${CMAKE_SOURCE_DIR}/${gcov_name}"
+ " -: 0:Source:${source_file}"
+ )
+endfunction()
+
foreach(I RANGE 0 ${CMAKE_ARGC})
if("${CMAKE_ARGV${I}}" MATCHES ".*\\.gcda")
set(gcda_file "${CMAKE_ARGV${I}}")
+ create_gcov_file(${gcda_file})
endif()
endforeach()
-
-get_filename_component(gcda_name ${gcda_file} NAME)
-string(REPLACE ".gcda" ".gcov" gcov_name "${gcda_name}")
-
-file(STRINGS "${gcda_file}" source_file LIMIT_COUNT 1 ENCODING UTF-8)
-
-file(WRITE "${CMAKE_SOURCE_DIR}/${gcov_name}"
- " -: 0:Source:${source_file}"
-)
diff --git a/Tests/CTestCoverageCollectGCOV/test.cmake.in b/Tests/CTestCoverageCollectGCOV/test.cmake.in
index d48ef6130..2c98876b3 100644
--- a/Tests/CTestCoverageCollectGCOV/test.cmake.in
+++ b/Tests/CTestCoverageCollectGCOV/test.cmake.in
@@ -1,5 +1,4 @@
cmake_minimum_required(VERSION 2.8.12)
-set(CTEST_PROJECT_NAME "TestProject")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/TestProject")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestCoverageCollectGCOV/TestProject")
set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
diff --git a/Tests/CTestTest/test.cmake.in b/Tests/CTestTest/test.cmake.in
index bb6346b8a..23166a7e3 100644
--- a/Tests/CTestTest/test.cmake.in
+++ b/Tests/CTestTest/test.cmake.in
@@ -62,7 +62,7 @@ COVERAGE_COMMAND:FILEPATH=@COVERAGE_COMMAND@
set (CTEST_DASHBOARD_ROOT "@CMAKE_CURRENT_BINARY_DIR@/Tests/CTestTest")
-# set any extra envionment varibles here
+# set any extra environment variables here
set (CTEST_ENVIRONMENT
)
diff --git a/Tests/CTestTest2/test.cmake.in b/Tests/CTestTest2/test.cmake.in
index 825b957d7..a9bbc527d 100644
--- a/Tests/CTestTest2/test.cmake.in
+++ b/Tests/CTestTest2/test.cmake.in
@@ -34,6 +34,7 @@ CMAKE_C_COMPILER:STRING=@CMAKE_C_COMPILER@
CMAKE_CXX_COMPILER:STRING=@CMAKE_CXX_COMPILER@
CMAKE_C_COMPILER_ARG1:STRING=@CMAKE_C_COMPILER_ARG1@
CMAKE_CXX_COMPILER_ARG1:STRING=@CMAKE_CXX_COMPILER_ARG1@
+KWSYS_ENCODING_DEFAULT_CODEPAGE:STRING=CP_UTF8
# This one is needed for testing advanced ctest features
CTEST_TEST_KWSYS:BOOL=ON
diff --git a/Tests/CTestTestBadExe/CTestConfig.cmake b/Tests/CTestTestBadExe/CTestConfig.cmake
index c7286e2c5..5bc1e9e16 100644
--- a/Tests/CTestTestBadExe/CTestConfig.cmake
+++ b/Tests/CTestTestBadExe/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set (CTEST_PROJECT_NAME "CTestTestBadExe")
set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set (CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestBadGenerator/CTestConfig.cmake b/Tests/CTestTestBadGenerator/CTestConfig.cmake
index 1e61bf441..5bc1e9e16 100644
--- a/Tests/CTestTestBadGenerator/CTestConfig.cmake
+++ b/Tests/CTestTestBadGenerator/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set (CTEST_PROJECT_NAME "CTestTestBadGenerator")
set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set (CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestCostSerial/CTestConfig.cmake b/Tests/CTestTestCostSerial/CTestConfig.cmake
index 3ab99ac5e..bd265f981 100644
--- a/Tests/CTestTestCostSerial/CTestConfig.cmake
+++ b/Tests/CTestTestCostSerial/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set(CTEST_PROJECT_NAME "CTestTestCostSerial")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set(CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestCostSerial/sleep.c b/Tests/CTestTestCostSerial/sleep.c
index b7abe946b..8a174c9b8 100644
--- a/Tests/CTestTestCostSerial/sleep.c
+++ b/Tests/CTestTestCostSerial/sleep.c
@@ -1,7 +1,7 @@
#if defined(_WIN32)
-#include <windows.h>
+# include <windows.h>
#else
-#include <unistd.h>
+# include <unistd.h>
#endif
/* sleeps for 1 second */
diff --git a/Tests/CTestTestCrash/CTestConfig.cmake b/Tests/CTestTestCrash/CTestConfig.cmake
index 5c2ca0ea9..5bc1e9e16 100644
--- a/Tests/CTestTestCrash/CTestConfig.cmake
+++ b/Tests/CTestTestCrash/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set (CTEST_PROJECT_NAME "CTestTestCrash")
set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set (CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestCycle/CTestConfig.cmake b/Tests/CTestTestCycle/CTestConfig.cmake
index 8aeb09b70..5bc1e9e16 100644
--- a/Tests/CTestTestCycle/CTestConfig.cmake
+++ b/Tests/CTestTestCycle/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set (CTEST_PROJECT_NAME "CTestTestCycle")
set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set (CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestDepends/CTestConfig.cmake b/Tests/CTestTestDepends/CTestConfig.cmake
index 7af9200e2..5bc1e9e16 100644
--- a/Tests/CTestTestDepends/CTestConfig.cmake
+++ b/Tests/CTestTestDepends/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set (CTEST_PROJECT_NAME "CTestTestDepends")
set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set (CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestFailure/CTestConfig.cmake b/Tests/CTestTestFailure/CTestConfig.cmake
index 07e1be00c..5bc1e9e16 100644
--- a/Tests/CTestTestFailure/CTestConfig.cmake
+++ b/Tests/CTestTestFailure/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set (CTEST_PROJECT_NAME "CTestTestFailure")
set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set (CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestFdSetSize/CTestConfig.cmake b/Tests/CTestTestFdSetSize/CTestConfig.cmake
deleted file mode 100644
index b5f3c3363..000000000
--- a/Tests/CTestTestFdSetSize/CTestConfig.cmake
+++ /dev/null
@@ -1 +0,0 @@
-set(CTEST_PROJECT_NAME "CTestTestFdSetSize")
diff --git a/Tests/CTestTestFdSetSize/sleep.c b/Tests/CTestTestFdSetSize/sleep.c
index 6676488fb..2fb6490aa 100644
--- a/Tests/CTestTestFdSetSize/sleep.c
+++ b/Tests/CTestTestFdSetSize/sleep.c
@@ -1,7 +1,7 @@
#if defined(_WIN32)
-#include <windows.h>
+# include <windows.h>
#else
-#include <unistd.h>
+# include <unistd.h>
#endif
/* sleeps for 0.1 second */
diff --git a/Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake
index 669b0fb68..c08eded76 100644
--- a/Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake
+++ b/Tests/CTestTestLaunchers/launcher_compiler_test_project/CTestConfig.cmake
@@ -1,8 +1,5 @@
set(CTEST_USE_LAUNCHERS 1)
-set(CTEST_PROJECT_NAME "CTestTestLaunchers")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set(CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake
index 669b0fb68..c08eded76 100644
--- a/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake
+++ b/Tests/CTestTestLaunchers/launcher_custom_command_test_project/CTestConfig.cmake
@@ -1,8 +1,5 @@
set(CTEST_USE_LAUNCHERS 1)
-set(CTEST_PROJECT_NAME "CTestTestLaunchers")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set(CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake b/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake
index 669b0fb68..c08eded76 100644
--- a/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake
+++ b/Tests/CTestTestLaunchers/launcher_linker_test_project/CTestConfig.cmake
@@ -1,8 +1,5 @@
set(CTEST_USE_LAUNCHERS 1)
-set(CTEST_PROJECT_NAME "CTestTestLaunchers")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set(CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestParallel/CTestConfig.cmake b/Tests/CTestTestParallel/CTestConfig.cmake
index fc5b6668e..bd265f981 100644
--- a/Tests/CTestTestParallel/CTestConfig.cmake
+++ b/Tests/CTestTestParallel/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set(CTEST_PROJECT_NAME "CTestTestParallel")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set(CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestResourceLock/CTestConfig.cmake b/Tests/CTestTestResourceLock/CTestConfig.cmake
index c1187778d..bd265f981 100644
--- a/Tests/CTestTestResourceLock/CTestConfig.cmake
+++ b/Tests/CTestTestResourceLock/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set(CTEST_PROJECT_NAME "CTestTestResourceLock")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set(CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestScheduler/CTestConfig.cmake b/Tests/CTestTestScheduler/CTestConfig.cmake
index 797387bdd..bd265f981 100644
--- a/Tests/CTestTestScheduler/CTestConfig.cmake
+++ b/Tests/CTestTestScheduler/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set(CTEST_PROJECT_NAME "CTestTestScheduler")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set(CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestScheduler/sleep.c b/Tests/CTestTestScheduler/sleep.c
index 41a5d450b..327bff57e 100644
--- a/Tests/CTestTestScheduler/sleep.c
+++ b/Tests/CTestTestScheduler/sleep.c
@@ -1,7 +1,7 @@
#if defined(_WIN32)
-#include <windows.h>
+# include <windows.h>
#else
-#include <unistd.h>
+# include <unistd.h>
#endif
/* sleeps for 4n seconds, where n is the argument to the program */
diff --git a/Tests/CTestTestSkipReturnCode/CTestConfig.cmake b/Tests/CTestTestSkipReturnCode/CTestConfig.cmake
index da0c76b73..5bc1e9e16 100644
--- a/Tests/CTestTestSkipReturnCode/CTestConfig.cmake
+++ b/Tests/CTestTestSkipReturnCode/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set (CTEST_PROJECT_NAME "CTestTestSkipReturnCode")
set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set (CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestStopTime/CTestConfig.cmake b/Tests/CTestTestStopTime/CTestConfig.cmake
index 412283e69..5bc1e9e16 100644
--- a/Tests/CTestTestStopTime/CTestConfig.cmake
+++ b/Tests/CTestTestStopTime/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set (CTEST_PROJECT_NAME "CTestTestStopTime")
set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set (CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestStopTime/GetDate.cmake b/Tests/CTestTestStopTime/GetDate.cmake
index 46ab2fbac..64a4fb9b3 100644
--- a/Tests/CTestTestStopTime/GetDate.cmake
+++ b/Tests/CTestTestStopTime/GetDate.cmake
@@ -68,7 +68,7 @@ macro(GET_DATE)
#
# Extract six individual components by matching a regex with paren groupings.
- # Use the replace functionality and \\1 thru \\6 to extract components.
+ # Use the replace functionality and \\1 through \\6 to extract components.
#
set(${GD_PREFIX}REGEX "([^/]+)/([^/]+)/([^ ]+) +([^:]+):([^:]+):([^\\.]+)")
diff --git a/Tests/CTestTestStopTime/sleep.c b/Tests/CTestTestStopTime/sleep.c
index 3baad9ea0..b9b6e897b 100644
--- a/Tests/CTestTestStopTime/sleep.c
+++ b/Tests/CTestTestStopTime/sleep.c
@@ -1,7 +1,7 @@
#if defined(_WIN32)
-#include <windows.h>
+# include <windows.h>
#else
-#include <unistd.h>
+# include <unistd.h>
#endif
/* sleeps for n seconds, where n is the argument to the program */
diff --git a/Tests/CTestTestSubdir/CTestConfig.cmake b/Tests/CTestTestSubdir/CTestConfig.cmake
index 47ebb925c..bd265f981 100644
--- a/Tests/CTestTestSubdir/CTestConfig.cmake
+++ b/Tests/CTestTestSubdir/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set(CTEST_PROJECT_NAME "CTestTestSubdir")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set(CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestTimeout/CTestConfig.cmake b/Tests/CTestTestTimeout/CTestConfig.cmake
index 13114f1ca..bd265f981 100644
--- a/Tests/CTestTestTimeout/CTestConfig.cmake
+++ b/Tests/CTestTestTimeout/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set(CTEST_PROJECT_NAME "CTestTestTimeout")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set(CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestTimeout/sleep.c b/Tests/CTestTestTimeout/sleep.c
index a4872b52e..ebe127430 100644
--- a/Tests/CTestTestTimeout/sleep.c
+++ b/Tests/CTestTestTimeout/sleep.c
@@ -1,7 +1,7 @@
#if defined(_WIN32)
-#include <windows.h>
+# include <windows.h>
#else
-#include <unistd.h>
+# include <unistd.h>
#endif
#include <stdio.h>
diff --git a/Tests/CTestTestTimeout/timeout.cmake b/Tests/CTestTestTimeout/timeout.cmake
index 0989b65df..ba2f58b7d 100644
--- a/Tests/CTestTestTimeout/timeout.cmake
+++ b/Tests/CTestTestTimeout/timeout.cmake
@@ -1,6 +1,6 @@
# Remove the log file.
file(REMOVE ${Log})
-# Run a child that sleeps longer than the timout of this test.
+# Run a child that sleeps longer than the timeout of this test.
# Log its output so check.cmake can verify it dies.
execute_process(COMMAND ${Sleep} ERROR_FILE ${Log})
diff --git a/Tests/CTestTestUpload/CTestConfig.cmake b/Tests/CTestTestUpload/CTestConfig.cmake
index a54708838..21318b4fc 100644
--- a/Tests/CTestTestUpload/CTestConfig.cmake
+++ b/Tests/CTestTestUpload/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set (CTEST_PROJECT_NAME "CTestTestUpload")
set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set (CTEST_DART_SERVER_VERSION "2")
set (CTEST_DROP_METHOD "http")
set (CTEST_DROP_SITE "open.cdash.org")
set (CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set (CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestUpload/sleep.c b/Tests/CTestTestUpload/sleep.c
index 3baad9ea0..b9b6e897b 100644
--- a/Tests/CTestTestUpload/sleep.c
+++ b/Tests/CTestTestUpload/sleep.c
@@ -1,7 +1,7 @@
#if defined(_WIN32)
-#include <windows.h>
+# include <windows.h>
#else
-#include <unistd.h>
+# include <unistd.h>
#endif
/* sleeps for n seconds, where n is the argument to the program */
diff --git a/Tests/CTestTestVerboseOutput/CTestConfig.cmake b/Tests/CTestTestVerboseOutput/CTestConfig.cmake
index 4f96c79a9..bd265f981 100644
--- a/Tests/CTestTestVerboseOutput/CTestConfig.cmake
+++ b/Tests/CTestTestVerboseOutput/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set(CTEST_PROJECT_NAME "CTestTestVerboseOutput")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set(CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestZeroTimeout/CTestConfig.cmake b/Tests/CTestTestZeroTimeout/CTestConfig.cmake
index 60948647f..bd265f981 100644
--- a/Tests/CTestTestZeroTimeout/CTestConfig.cmake
+++ b/Tests/CTestTestZeroTimeout/CTestConfig.cmake
@@ -1,7 +1,4 @@
-set(CTEST_PROJECT_NAME "CTestTestZeroTimeout")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set(CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Tests/CTestTestZeroTimeout/sleep.c b/Tests/CTestTestZeroTimeout/sleep.c
index 0be7bbc4f..5d0b89bf7 100644
--- a/Tests/CTestTestZeroTimeout/sleep.c
+++ b/Tests/CTestTestZeroTimeout/sleep.c
@@ -1,7 +1,7 @@
#if defined(_WIN32)
-#include <windows.h>
+# include <windows.h>
#else
-#include <unistd.h>
+# include <unistd.h>
#endif
/* sleeps for 5 seconds */
diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake
index 61aa13b94..0f8ec8e27 100644
--- a/Tests/CTestUpdateCommon.cmake
+++ b/Tests/CTestUpdateCommon.cmake
@@ -130,7 +130,6 @@ function(create_content dir)
# An example CTest project configuration file.
file(WRITE ${TOP}/${dir}/CTestConfig.cmake
"# CTest Configuration File
-set(CTEST_PROJECT_NAME TestProject)
set(CTEST_NIGHTLY_START_TIME \"21:00:00 EDT\")
")
diff --git a/Tests/CheckFortran.cmake b/Tests/CheckFortran.cmake
index b1652baf1..16a8ed2c6 100644
--- a/Tests/CheckFortran.cmake
+++ b/Tests/CheckFortran.cmake
@@ -15,11 +15,18 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
\"set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 \\\"\${CMAKE_Fortran_COMPILER_SUPPORTS_F90}\\\")\\n\"
)
")
+ if(CMAKE_GENERATOR_INSTANCE)
+ set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}")
+ else()
+ set(_D_CMAKE_GENERATOR_INSTANCE "")
+ endif()
execute_process(
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran
COMMAND ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR}
-A "${CMAKE_GENERATOR_PLATFORM}"
-T "${CMAKE_GENERATOR_TOOLSET}"
+ ${_D_CMAKE_GENERATOR_INSTANCE}
+ TIMEOUT 60
OUTPUT_VARIABLE output
ERROR_VARIABLE output
RESULT_VARIABLE result
diff --git a/Tests/CheckSwift.cmake b/Tests/CheckSwift.cmake
new file mode 100644
index 000000000..fcbae7ef9
--- /dev/null
+++ b/Tests/CheckSwift.cmake
@@ -0,0 +1,61 @@
+if(NOT CMAKE_GENERATOR MATCHES "Xcode|Ninja")
+ set(CMAKE_Swift_COMPILER "")
+ return()
+endif()
+
+if(NOT DEFINED CMAKE_Swift_COMPILER)
+ set(_desc "Looking for a Swift compiler")
+ message(STATUS ${_desc})
+
+ file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckSwift)
+
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckSwift/CMakeLists.txt"
+ "cmake_minimum_required(VERSION 3.14)
+project(CheckSwift Swift)
+file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\"
+ \"set(CMAKE_Swift_COMPILER \\\"\${CMAKE_Swift_COMPILER}\\\")\\n\"
+ \"set(CMAKE_Swift_FLAGS \\\"\${CMAKE_Swift_FLAGS}\\\")\\n\")
+")
+
+ if(CMAKE_GENERATOR_INSTANCE)
+ set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}")
+ else()
+ set(_D_CMAKE_GENERATOR_INSTANCE "")
+ endif()
+
+ execute_process(WORKING_DIRECTORY
+ ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckSwift
+ COMMAND
+ ${CMAKE_COMMAND} . -G ${CMAKE_GENERATOR}
+ -A "${CMAKE_GENERATOR_PLATFORM}"
+ -T "${CMAKE_GENERATOR_TOOLSET}"
+ ${_D_CMAKE_GENERATOR_INSTANCE}
+ TIMEOUT
+ 60
+ OUTPUT_VARIABLE
+ output
+ ERROR_VARIABLE
+ output
+ RESULT_VARIABLE
+ result)
+
+ include(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckSwift/result.cmake
+ OPTIONAL)
+ if(CMAKE_Swift_COMPILER AND "${result}" STREQUAL "0")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "${_desc} passed with the following output:\n"
+ "${output}\n")
+ else()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "${_desc} failed with the following output:\n"
+ "${output}\n")
+ endif()
+
+ message(STATUS "${_desc} - ${CMAKE_Swift_COMPILER}")
+
+ set(CMAKE_Swift_COMPILER "${CMAKE_Swift_COMPILER}" CACHE FILEPATH "Swift compiler")
+ set(CMAKE_Swift_FLAGS "${CMAKE_Swift_FLAGS}" CACHE STRING "Swift flags")
+
+ mark_as_advanced(CMAKE_Swift_COMPILER)
+ mark_as_advanced(CMAKE_Swift_FLAGS)
+endif()
diff --git a/Tests/CommandLength/CMakeLists.txt b/Tests/CommandLength/CMakeLists.txt
new file mode 100644
index 000000000..68360518b
--- /dev/null
+++ b/Tests/CommandLength/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.10)
+project(CommandLength C)
+
+add_executable(CommandLength test.c)
+add_custom_command(TARGET CommandLength POST_BUILD VERBATIM
+ COMMAND ${CMAKE_COMMAND} -E make_directory log)
+
+set(msg "xxxx $$$$ yyyy")
+set(msg "${msg} ${msg}")
+set(msg "${msg} ${msg}")
+set(msg "${msg} ${msg}")
+set(msg "${msg} ${msg}")
+foreach(i RANGE 1 1000)
+ add_custom_command(TARGET CommandLength POST_BUILD VERBATIM
+ COMMAND ${CMAKE_COMMAND} -E echo "${i} ${msg}" > log/${i}
+ )
+endforeach()
diff --git a/Tests/CommandLength/test.c b/Tests/CommandLength/test.c
new file mode 100644
index 000000000..f8b643afb
--- /dev/null
+++ b/Tests/CommandLength/test.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/CompatibleInterface/main.cpp b/Tests/CompatibleInterface/main.cpp
index 93723afa0..0bccb8206 100644
--- a/Tests/CompatibleInterface/main.cpp
+++ b/Tests/CompatibleInterface/main.cpp
@@ -1,26 +1,26 @@
#ifndef BOOL_PROP1
-#error Expected BOOL_PROP1
+# error Expected BOOL_PROP1
#endif
#ifndef BOOL_PROP2
-#error Expected BOOL_PROP2
+# error Expected BOOL_PROP2
#endif
#ifndef BOOL_PROP3
-#error Expected BOOL_PROP3
+# error Expected BOOL_PROP3
#endif
#ifndef STRING_PROP1
-#error Expected STRING_PROP1
+# error Expected STRING_PROP1
#endif
#ifndef STRING_PROP2
-#error Expected STRING_PROP2
+# error Expected STRING_PROP2
#endif
#ifndef STRING_PROP3
-#error Expected STRING_PROP3
+# error Expected STRING_PROP3
#endif
template <bool test>
diff --git a/Tests/CompileCommandOutput/relative.h b/Tests/CompileCommandOutput/relative.h
index 221e35453..fa6eefff6 100644
--- a/Tests/CompileCommandOutput/relative.h
+++ b/Tests/CompileCommandOutput/relative.h
@@ -1,11 +1,11 @@
#if defined(_WIN32)
-#ifdef test2_EXPORTS
-#define TEST2_EXPORT __declspec(dllexport)
+# ifdef test2_EXPORTS
+# define TEST2_EXPORT __declspec(dllexport)
+# else
+# define TEST2_EXPORT __declspec(dllimport)
+# endif
#else
-#define TEST2_EXPORT __declspec(dllimport)
-#endif
-#else
-#define TEST2_EXPORT
+# define TEST2_EXPORT
#endif
TEST2_EXPORT void relative();
diff --git a/Tests/CompileDefinitions/compiletest.c b/Tests/CompileDefinitions/compiletest.c
index 8871750af..66248668a 100644
--- a/Tests/CompileDefinitions/compiletest.c
+++ b/Tests/CompileDefinitions/compiletest.c
@@ -1,20 +1,20 @@
#ifndef LINK_C_DEFINE
-#error Expected LINK_C_DEFINE
+# error Expected LINK_C_DEFINE
#endif
#ifndef LINK_LANGUAGE_IS_C
-#error Expected LINK_LANGUAGE_IS_C
+# error Expected LINK_LANGUAGE_IS_C
#endif
#ifdef LINK_CXX_DEFINE
-#error Unexpected LINK_CXX_DEFINE
+# error Unexpected LINK_CXX_DEFINE
#endif
#ifdef LINK_LANGUAGE_IS_CXX
-#error Unexpected LINK_LANGUAGE_IS_CXX
+# error Unexpected LINK_LANGUAGE_IS_CXX
#endif
#ifdef DEBUG_MODE
-#error Unexpected DEBUG_MODE
+# error Unexpected DEBUG_MODE
#endif
int main(void)
diff --git a/Tests/CompileDefinitions/compiletest.cpp b/Tests/CompileDefinitions/compiletest.cpp
index 640e7cf56..328e72e91 100644
--- a/Tests/CompileDefinitions/compiletest.cpp
+++ b/Tests/CompileDefinitions/compiletest.cpp
@@ -1,10 +1,10 @@
#ifndef CMAKE_IS_FUN
-#error Expect CMAKE_IS_FUN definition
+# error Expect CMAKE_IS_FUN definition
#endif
#if CMAKE_IS != Fun
-#error Expect CMAKE_IS=Fun definition
+# error Expect CMAKE_IS=Fun definition
#endif
template <bool test>
@@ -43,67 +43,67 @@ enum
};
#ifdef TEST_GENERATOR_EXPRESSIONS
-#ifndef CMAKE_IS_DECLARATIVE
-#error Expect declarative definition
-#endif
-#ifdef GE_NOT_DEFINED
-#error Expect not defined generator expression
-#endif
-
-#ifndef ARGUMENT
-#error Expected define expanded from list
-#endif
-#ifndef LIST
-#error Expected define expanded from list
-#endif
-
-#ifndef PREFIX_DEF1
-#error Expect PREFIX_DEF1
-#endif
-
-#ifndef PREFIX_DEF2
-#error Expect PREFIX_DEF2
-#endif
-
-#ifndef LINK_CXX_DEFINE
-#error Expected LINK_CXX_DEFINE
-#endif
-#ifndef LINK_LANGUAGE_IS_CXX
-#error Expected LINK_LANGUAGE_IS_CXX
-#endif
-
-#ifdef LINK_C_DEFINE
-#error Unexpected LINK_C_DEFINE
-#endif
-#ifdef LINK_LANGUAGE_IS_C
-#error Unexpected LINK_LANGUAGE_IS_C
-#endif
+# ifndef CMAKE_IS_DECLARATIVE
+# error Expect declarative definition
+# endif
+# ifdef GE_NOT_DEFINED
+# error Expect not defined generator expression
+# endif
+
+# ifndef ARGUMENT
+# error Expected define expanded from list
+# endif
+# ifndef LIST
+# error Expected define expanded from list
+# endif
+
+# ifndef PREFIX_DEF1
+# error Expect PREFIX_DEF1
+# endif
+
+# ifndef PREFIX_DEF2
+# error Expect PREFIX_DEF2
+# endif
+
+# ifndef LINK_CXX_DEFINE
+# error Expected LINK_CXX_DEFINE
+# endif
+# ifndef LINK_LANGUAGE_IS_CXX
+# error Expected LINK_LANGUAGE_IS_CXX
+# endif
+
+# ifdef LINK_C_DEFINE
+# error Unexpected LINK_C_DEFINE
+# endif
+# ifdef LINK_LANGUAGE_IS_C
+# error Unexpected LINK_LANGUAGE_IS_C
+# endif
// TEST_GENERATOR_EXPRESSIONS
#endif
#ifndef BUILD_IS_DEBUG
-#error "BUILD_IS_DEBUG not defined!"
+# error "BUILD_IS_DEBUG not defined!"
#endif
#ifndef BUILD_IS_NOT_DEBUG
-#error "BUILD_IS_NOT_DEBUG not defined!"
+# error "BUILD_IS_NOT_DEBUG not defined!"
#endif
// Check per-config definitions.
#ifdef TEST_CONFIG_DEBUG
-#if !BUILD_IS_DEBUG
-#error "BUILD_IS_DEBUG false with TEST_CONFIG_DEBUG!"
-#endif
-#if BUILD_IS_NOT_DEBUG
-#error "BUILD_IS_NOT_DEBUG true with TEST_CONFIG_DEBUG!"
-#endif
+# if !BUILD_IS_DEBUG
+# error "BUILD_IS_DEBUG false with TEST_CONFIG_DEBUG!"
+# endif
+# if BUILD_IS_NOT_DEBUG
+# error "BUILD_IS_NOT_DEBUG true with TEST_CONFIG_DEBUG!"
+# endif
#else
-#if BUILD_IS_DEBUG
-#error "BUILD_IS_DEBUG true without TEST_CONFIG_DEBUG!"
-#endif
-#if !BUILD_IS_NOT_DEBUG
-#error "BUILD_IS_NOT_DEBUG false without TEST_CONFIG_DEBUG!"
-#endif
+# if BUILD_IS_DEBUG
+# error "BUILD_IS_DEBUG true without TEST_CONFIG_DEBUG!"
+# endif
+# if !BUILD_IS_NOT_DEBUG
+# error "BUILD_IS_NOT_DEBUG false without TEST_CONFIG_DEBUG!"
+# endif
#endif
int main(int argc, char** argv)
diff --git a/Tests/CompileDefinitions/compiletest_mixed_c.c b/Tests/CompileDefinitions/compiletest_mixed_c.c
index 5fbe45f92..e4adef322 100644
--- a/Tests/CompileDefinitions/compiletest_mixed_c.c
+++ b/Tests/CompileDefinitions/compiletest_mixed_c.c
@@ -1,20 +1,20 @@
#ifndef LINK_CXX_DEFINE
-#error Expected LINK_CXX_DEFINE
+# error Expected LINK_CXX_DEFINE
#endif
#ifndef LINK_LANGUAGE_IS_CXX
-#error Expected LINK_LANGUAGE_IS_CXX
+# error Expected LINK_LANGUAGE_IS_CXX
#endif
#ifdef LINK_C_DEFINE
-#error Unexpected LINK_C_DEFINE
+# error Unexpected LINK_C_DEFINE
#endif
#ifdef LINK_LANGUAGE_IS_C
-#error Unexpected LINK_LANGUAGE_IS_C
+# error Unexpected LINK_LANGUAGE_IS_C
#endif
#ifndef C_EXECUTABLE_LINK_LANGUAGE_IS_C
-#error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define
+# error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define
#endif
void someFunc(void)
diff --git a/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp b/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp
index 4eab0999c..b50b4bf10 100644
--- a/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp
+++ b/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp
@@ -1,20 +1,20 @@
#ifndef LINK_CXX_DEFINE
-#error Expected LINK_CXX_DEFINE
+# error Expected LINK_CXX_DEFINE
#endif
#ifndef LINK_LANGUAGE_IS_CXX
-#error Expected LINK_LANGUAGE_IS_CXX
+# error Expected LINK_LANGUAGE_IS_CXX
#endif
#ifdef LINK_C_DEFINE
-#error Unexpected LINK_C_DEFINE
+# error Unexpected LINK_C_DEFINE
#endif
#ifdef LINK_LANGUAGE_IS_C
-#error Unexpected LINK_LANGUAGE_IS_C
+# error Unexpected LINK_LANGUAGE_IS_C
#endif
#ifndef C_EXECUTABLE_LINK_LANGUAGE_IS_C
-#error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define
+# error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define
#endif
int main(int argc, char** argv)
diff --git a/Tests/CompileDefinitions/runtest.c b/Tests/CompileDefinitions/runtest.c
index 7c28ab90e..c6dac4dfc 100644
--- a/Tests/CompileDefinitions/runtest.c
+++ b/Tests/CompileDefinitions/runtest.c
@@ -3,7 +3,7 @@
#include <string.h>
#ifndef BUILD_CONFIG_NAME
-#error "BUILD_CONFIG_NAME not defined!"
+# error "BUILD_CONFIG_NAME not defined!"
#endif
int main()
diff --git a/Tests/CompileDefinitions/target_prop/usetgt.c b/Tests/CompileDefinitions/target_prop/usetgt.c
index 8408a908c..56823b089 100644
--- a/Tests/CompileDefinitions/target_prop/usetgt.c
+++ b/Tests/CompileDefinitions/target_prop/usetgt.c
@@ -1,11 +1,11 @@
#ifndef TGT_DEF
-#error TGT_DEF incorrectly not defined
+# error TGT_DEF incorrectly not defined
#endif
#ifndef TGT_TYPE_STATIC_LIBRARY
-#error TGT_TYPE_STATIC_LIBRARY incorrectly not defined
+# error TGT_TYPE_STATIC_LIBRARY incorrectly not defined
#endif
#ifdef TGT_TYPE_EXECUTABLE
-#error TGT_TYPE_EXECUTABLE incorrectly defined
+# error TGT_TYPE_EXECUTABLE incorrectly defined
#endif
int main(void)
{
diff --git a/Tests/CompileFeatures/.gitattributes b/Tests/CompileFeatures/.gitattributes
index 83da28dac..95a89568a 100644
--- a/Tests/CompileFeatures/.gitattributes
+++ b/Tests/CompileFeatures/.gitattributes
@@ -1,2 +1,2 @@
# Do not format a source containing C++11 '>>' syntax as C++98.
-cxx_right_angle_brackets.cpp -format.clang-format
+cxx_right_angle_brackets.cpp -format.clang-format-6.0
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt
index 4a5558d48..ef9198d3b 100644
--- a/Tests/CompileFeatures/CMakeLists.txt
+++ b/Tests/CompileFeatures/CMakeLists.txt
@@ -15,17 +15,21 @@ macro(run_test feature lang)
endif()
endmacro()
-get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES)
-list(FILTER c_features EXCLUDE REGEX "^c_std_[0-9][0-9]")
-foreach(feature ${c_features})
- run_test(${feature} C)
-endforeach()
+if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$")
+ get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES)
+ list(FILTER c_features EXCLUDE REGEX "^c_std_[0-9][0-9]")
+ foreach(feature ${c_features})
+ run_test(${feature} C)
+ endforeach()
+endif()
-get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
-list(FILTER cxx_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]")
-foreach(feature ${cxx_features})
- run_test(${feature} CXX)
-endforeach()
+if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$")
+ get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
+ list(FILTER cxx_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]")
+ foreach(feature ${cxx_features})
+ run_test(${feature} CXX)
+ endforeach()
+endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
@@ -48,6 +52,16 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro)
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.15)
+ # SunPro 5.14 accepts -std=c++14 and compiles two features but does
+ # not define __cplusplus to a value different than with -std=c++11.
+ list(REMOVE_ITEM CXX_non_features
+ cxx_aggregate_default_initializers
+ cxx_digit_separators
+ )
+ endif()
+
+ # FIXME: Do any of these work correctly on SunPro 5.13 or above?
list(REMOVE_ITEM CXX_non_features
cxx_attribute_deprecated
cxx_contextual_conversions
@@ -116,6 +130,12 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
+ if (CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"
+ AND CMAKE_CXX_SIMULATE_VERSION VERSION_LESS 19.10)
+ list(REMOVE_ITEM CXX_non_features
+ cxx_relaxed_constexpr
+ )
+ endif()
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0)
if (CMAKE_CXX_COMIPLER_VERSION VERSION_EQUAL 15.0)
list(REMOVE_ITEM CXX_non_features
@@ -224,54 +244,22 @@ if (C_expected_features)
add_executable(CompileFeaturesGenex_C genex_test.c)
set_property(TARGET CompileFeaturesGenex_C PROPERTY C_STANDARD 11)
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
- list(APPEND expected_defs
- EXPECT_C_STATIC_ASSERT=1
- )
- else()
- list(APPEND expected_defs
- EXPECT_C_STATIC_ASSERT=0
+ foreach(f
+ c_restrict
+ c_static_assert
+ c_function_prototypes
)
- endif()
- elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang"
- OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
- list(APPEND expected_defs
- EXPECT_C_STATIC_ASSERT=1
- )
- elseif (CMAKE_C_COMPILER_ID STREQUAL "Intel")
- if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15)
- list(APPEND expected_defs
- EXPECT_C_STATIC_ASSERT=1
- )
- else()
- list(APPEND expected_defs
- EXPECT_C_STATIC_ASSERT=0
- )
- endif()
- elseif (CMAKE_C_COMPILER_ID STREQUAL "SunPro")
- if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.13)
- list(APPEND expected_defs
- EXPECT_C_STATIC_ASSERT=1
- )
+ if(${f} IN_LIST C_expected_features)
+ set(expect_${f} 1)
else()
- list(APPEND expected_defs
- EXPECT_C_STATIC_ASSERT=0
- )
+ set(expect_${f} 0)
endif()
- endif()
-
- list(APPEND expected_defs
- EXPECT_C_FUNCTION_PROTOTYPES=1
- EXPECT_C_RESTRICT=1
- )
-
- target_compile_definitions(CompileFeaturesGenex_C PRIVATE
- HAVE_C_FUNCTION_PROTOTYPES=$<COMPILE_FEATURES:c_function_prototypes>
- HAVE_C_RESTRICT=$<COMPILE_FEATURES:c_restrict>
- HAVE_C_STATIC_ASSERT=$<COMPILE_FEATURES:c_static_assert>
- ${expected_defs}
- )
+ string(TOUPPER "${f}" F)
+ target_compile_definitions(CompileFeaturesGenex_C PRIVATE
+ EXPECT_${F}=${expect_${f}}
+ HAVE_${F}=$<COMPILE_FEATURES:${f}>
+ )
+ endforeach()
endif()
if (CMAKE_CXX_COMPILE_FEATURES)
@@ -280,6 +268,7 @@ if (CMAKE_CXX_COMPILE_FEATURES)
if (std_flag_idx EQUAL -1)
add_executable(default_dialect default_dialect.cpp)
target_compile_definitions(default_dialect PRIVATE
+ DEFAULT_CXX20=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},20>
DEFAULT_CXX17=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},17>
DEFAULT_CXX14=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},14>
DEFAULT_CXX11=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},11>
@@ -318,136 +307,62 @@ else()
add_executable(IfaceCompileFeatures main.cpp)
target_link_libraries(IfaceCompileFeatures iface)
- if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
- if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
- add_definitions(
- -DEXPECT_OVERRIDE_CONTROL=1
- -DEXPECT_INHERITING_CONSTRUCTORS=1
- -DEXPECT_FINAL=1
- -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1
- )
- elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
- add_definitions(
- -DEXPECT_OVERRIDE_CONTROL=1
- -DEXPECT_INHERITING_CONSTRUCTORS=0
- -DEXPECT_FINAL=1
- -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
- )
- else()
- add_definitions(
- -DEXPECT_OVERRIDE_CONTROL=0
- -DEXPECT_INHERITING_CONSTRUCTORS=0
- -DEXPECT_FINAL=0
- -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
- )
- endif()
- elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
- add_definitions(
- -DEXPECT_OVERRIDE_CONTROL=1
- -DEXPECT_INHERITING_CONSTRUCTORS=1
- -DEXPECT_FINAL=1
- -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1
- )
- elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
- if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
- add_definitions(
- -DEXPECT_OVERRIDE_CONTROL=1
- -DEXPECT_INHERITING_CONSTRUCTORS=1
- -DEXPECT_FINAL=1
- -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1
- )
- else()
- add_definitions(
- -DEXPECT_OVERRIDE_CONTROL=1
- -DEXPECT_INHERITING_CONSTRUCTORS=0
- -DEXPECT_FINAL=1
- -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
- )
- endif()
- elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
- if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0)
- add_definitions(
- -DEXPECT_OVERRIDE_CONTROL=1
- -DEXPECT_INHERITING_CONSTRUCTORS=1
- -DEXPECT_FINAL=1
- -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1
- )
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.0)
- add_definitions(
- -DEXPECT_OVERRIDE_CONTROL=1
- -DEXPECT_INHERITING_CONSTRUCTORS=0
- -DEXPECT_FINAL=1
- -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
- )
- else()
- add_definitions(
- -DEXPECT_OVERRIDE_CONTROL=0
- -DEXPECT_INHERITING_CONSTRUCTORS=0
- -DEXPECT_FINAL=0
- -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
- )
- endif()
- elseif (CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
- add_definitions(
- -DEXPECT_OVERRIDE_CONTROL=1
- -DEXPECT_INHERITING_CONSTRUCTORS=1
- -DEXPECT_FINAL=1
- -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1
- )
- elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
- if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15)
- add_definitions(
- -DEXPECT_OVERRIDE_CONTROL=1
- -DEXPECT_INHERITING_CONSTRUCTORS=1
- -DEXPECT_FINAL=1
- -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=1
- )
- elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14)
- add_definitions(
- -DEXPECT_OVERRIDE_CONTROL=1
- -DEXPECT_INHERITING_CONSTRUCTORS=0
- -DEXPECT_FINAL=1
- -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
+ foreach(f
+ cxx_final
+ cxx_override
+ cxx_auto_type
+ cxx_inheriting_constructors
)
+ if(${f} IN_LIST CXX_expected_features)
+ set(expect_${f} 1)
else()
- add_definitions(
- -DEXPECT_OVERRIDE_CONTROL=0
- -DEXPECT_INHERITING_CONSTRUCTORS=0
- -DEXPECT_FINAL=0
- -DEXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=0
- )
+ set(expect_${f} 0)
endif()
+ endforeach()
+
+ if(expect_cxx_final AND expect_cxx_override)
+ set(expect_override_control 1)
+ else()
+ set(expect_override_control 0)
+ endif()
+ if(expect_cxx_inheriting_constructors AND expect_cxx_final)
+ set(expect_inheriting_constructors_and_final 1)
+ else()
+ set(expect_inheriting_constructors_and_final 0)
endif()
- add_executable(CompileFeaturesGenex genex_test.cpp)
- set_property(TARGET CompileFeaturesGenex PROPERTY CXX_STANDARD 11)
- target_compile_definitions(CompileFeaturesGenex PRIVATE
+ set(genex_test_defs
HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>
HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type>
HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors>
HAVE_FINAL=$<COMPILE_FEATURES:cxx_final>
HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final>
- )
+ EXPECT_OVERRIDE_CONTROL=${expect_override_control}
+ EXPECT_INHERITING_CONSTRUCTORS=${expect_cxx_inheriting_constructors}
+ EXPECT_FINAL=${expect_cxx_final}
+ EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL=${expect_inheriting_constructors_and_final}
+ )
+ if (CMAKE_CXX_STANDARD_DEFAULT)
+ list(APPEND genex_test_defs
+ TEST_CXX_STD
+ HAVE_CXX_STD_11=$<COMPILE_FEATURES:cxx_std_11>
+ HAVE_CXX_STD_14=$<COMPILE_FEATURES:cxx_std_14>
+ HAVE_CXX_STD_17=$<COMPILE_FEATURES:cxx_std_17>
+ HAVE_CXX_STD_20=$<COMPILE_FEATURES:cxx_std_20>
+ )
+ endif()
+
+ add_executable(CompileFeaturesGenex genex_test.cpp)
+ set_property(TARGET CompileFeaturesGenex PROPERTY CXX_STANDARD 11)
+ target_compile_definitions(CompileFeaturesGenex PRIVATE ${genex_test_defs})
add_executable(CompileFeaturesGenex2 genex_test.cpp)
target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_std_11)
- target_compile_definitions(CompileFeaturesGenex2 PRIVATE
- HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>
- HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type>
- HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors>
- HAVE_FINAL=$<COMPILE_FEATURES:cxx_final>
- HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final>
- )
+ target_compile_definitions(CompileFeaturesGenex2 PRIVATE ${genex_test_defs} ALLOW_LATER_STANDARDS=1)
add_library(std_11_iface INTERFACE)
target_compile_features(std_11_iface INTERFACE cxx_std_11)
add_executable(CompileFeaturesGenex3 genex_test.cpp)
target_link_libraries(CompileFeaturesGenex3 PRIVATE std_11_iface)
- target_compile_definitions(CompileFeaturesGenex3 PRIVATE
- HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>
- HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type>
- HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors>
- HAVE_FINAL=$<COMPILE_FEATURES:cxx_final>
- HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final>
- )
+ target_compile_definitions(CompileFeaturesGenex3 PRIVATE ${genex_test_defs} ALLOW_LATER_STANDARDS=1)
endif()
diff --git a/Tests/CompileFeatures/cxx_attribute_deprecated.cpp b/Tests/CompileFeatures/cxx_attribute_deprecated.cpp
index 5482db8ca..8faeca870 100644
--- a/Tests/CompileFeatures/cxx_attribute_deprecated.cpp
+++ b/Tests/CompileFeatures/cxx_attribute_deprecated.cpp
@@ -1,8 +1,5 @@
-[[deprecated]] int foo()
-{
- return 0;
-}
+[[deprecated]] int foo() { return 0; }
int someFunc()
{
diff --git a/Tests/CompileFeatures/cxx_contextual_conversions.cpp b/Tests/CompileFeatures/cxx_contextual_conversions.cpp
index cbc730417..247f13f9f 100644
--- a/Tests/CompileFeatures/cxx_contextual_conversions.cpp
+++ b/Tests/CompileFeatures/cxx_contextual_conversions.cpp
@@ -17,6 +17,7 @@ public:
}
operator T&() { return val; }
operator T() const { return val; }
+
private:
T val;
};
diff --git a/Tests/CompileFeatures/cxx_digit_separators.cpp b/Tests/CompileFeatures/cxx_digit_separators.cpp
index a40ac0aac..abcd1c8fa 100644
--- a/Tests/CompileFeatures/cxx_digit_separators.cpp
+++ b/Tests/CompileFeatures/cxx_digit_separators.cpp
@@ -1,5 +1,6 @@
int someFunc()
{
- int one_thousand = 1'000; return one_thousand - 1000;
+ int one_thousand = 1'000;
+ return one_thousand - 1000;
}
diff --git a/Tests/CompileFeatures/cxx_generalized_initializers.cpp b/Tests/CompileFeatures/cxx_generalized_initializers.cpp
index cfe9d9852..bfe0d415e 100644
--- a/Tests/CompileFeatures/cxx_generalized_initializers.cpp
+++ b/Tests/CompileFeatures/cxx_generalized_initializers.cpp
@@ -1,5 +1,5 @@
#if defined(_MSC_VER) && _MSC_VER == 1800 && _MSC_FULL_VER < 180030723
-#error "VS 2013 safely supports this only with Update 3 or greater"
+# error "VS 2013 safely supports this only with Update 3 or greater"
#endif
// Dummy implementation. Test only the compiler feature.
@@ -11,11 +11,17 @@ class initializer_list
const _E* __begin_;
size_t __size_;
+#ifdef __INTEL_COMPILER
+ // The Intel compiler internally asserts the constructor overloads, so
+ // reproduce the constructor used in its <initializer_list> header.
+ initializer_list(const _E*, size_t) {}
+#else
public:
template <typename T1, typename T2>
initializer_list(T1, T2)
{
}
+#endif
};
}
diff --git a/Tests/CompileFeatures/cxx_lambda_init_captures.cpp b/Tests/CompileFeatures/cxx_lambda_init_captures.cpp
index 46f22cb51..7e337faf4 100644
--- a/Tests/CompileFeatures/cxx_lambda_init_captures.cpp
+++ b/Tests/CompileFeatures/cxx_lambda_init_captures.cpp
@@ -2,6 +2,5 @@
int someFunc()
{
int a = 0;
- return [b = static_cast<int&&>(a)]() { return b; }
- ();
+ return [b = static_cast<int&&>(a)]() { return b; }();
}
diff --git a/Tests/CompileFeatures/cxx_raw_string_literals.cpp b/Tests/CompileFeatures/cxx_raw_string_literals.cpp
index ea4d2312c..0f83a7c9a 100644
--- a/Tests/CompileFeatures/cxx_raw_string_literals.cpp
+++ b/Tests/CompileFeatures/cxx_raw_string_literals.cpp
@@ -1,7 +1,7 @@
void someFunc()
{
-const char p[] = R"(a\
+ const char p[] = R"(a\
b
c)";
}
diff --git a/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp b/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp
index 7b3602cd5..953148d75 100644
--- a/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp
+++ b/Tests/CompileFeatures/cxx_relaxed_constexpr.cpp
@@ -22,6 +22,7 @@ constexpr int g(const int (&is)[4])
int someFunc()
{
- constexpr int k3 = g({ 4, 5, 6, 7 });
+ constexpr int values[4] = { 4, 5, 6, 7 };
+ constexpr int k3 = g(values);
return k3 - 42;
}
diff --git a/Tests/CompileFeatures/cxx_variadic_templates.cpp b/Tests/CompileFeatures/cxx_variadic_templates.cpp
index 3dc25704d..627b8d939 100644
--- a/Tests/CompileFeatures/cxx_variadic_templates.cpp
+++ b/Tests/CompileFeatures/cxx_variadic_templates.cpp
@@ -1,5 +1,5 @@
#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) < 407)
-#define OLD_GNU
+# define OLD_GNU
#endif
#ifdef OLD_GNU
@@ -35,7 +35,7 @@ struct eval
};
template <template <typename...> class T, typename... U>
-struct eval<T<U...> >
+struct eval<T<U...>>
{
enum
{
@@ -62,11 +62,11 @@ struct D
// Note: This test assumes that a compiler supporting this feature
// supports static_assert. Add a workaround if that does not hold.
-static_assert(eval<A<> >::Matched, "A Matches");
-static_assert(eval<A<int> >::Matched, "A Matches");
-static_assert(eval<A<int, char> >::Matched, "A Matches");
-static_assert(eval<B<int> >::Matched, "B Matches");
-static_assert(eval<C<int, char> >::Matched, "C Matches");
-static_assert(eval<D<int, char> >::Matched, "D Matches");
-static_assert(eval<D<int, char, bool> >::Matched, "D Matches");
-static_assert(eval<D<int, char, bool, double> >::Matched, "D Matches");
+static_assert(eval<A<>>::Matched, "A Matches");
+static_assert(eval<A<int>>::Matched, "A Matches");
+static_assert(eval<A<int, char>>::Matched, "A Matches");
+static_assert(eval<B<int>>::Matched, "B Matches");
+static_assert(eval<C<int, char>>::Matched, "C Matches");
+static_assert(eval<D<int, char>>::Matched, "D Matches");
+static_assert(eval<D<int, char, bool>>::Matched, "D Matches");
+static_assert(eval<D<int, char, bool, double>>::Matched, "D Matches");
diff --git a/Tests/CompileFeatures/default_dialect.c b/Tests/CompileFeatures/default_dialect.c
index 4debd9410..6160c2f44 100644
--- a/Tests/CompileFeatures/default_dialect.c
+++ b/Tests/CompileFeatures/default_dialect.c
@@ -1,20 +1,20 @@
#if DEFAULT_C11
-#if __STDC_VERSION__ != 201112L
-#error Unexpected value for __STDC_VERSION__.
-#endif
+# if __STDC_VERSION__ < 201112L
+# error Unexpected value for __STDC_VERSION__.
+# endif
#elif DEFAULT_C99
-#if __STDC_VERSION__ != 199901L
-#error Unexpected value for __STDC_VERSION__.
-#endif
+# if __STDC_VERSION__ != 199901L
+# error Unexpected value for __STDC_VERSION__.
+# endif
#else
-#if !DEFAULT_C90
-#error Buildsystem error
-#endif
-#if defined(__STDC_VERSION__) && \
- !(defined(__SUNPRO_C) && __STDC_VERSION__ == 199409L)
-#error Unexpected __STDC_VERSION__ definition
-#endif
+# if !DEFAULT_C90
+# error Buildsystem error
+# endif
+# if defined(__STDC_VERSION__) && \
+ !(defined(__SUNPRO_C) && __STDC_VERSION__ == 199409L)
+# error Unexpected __STDC_VERSION__ definition
+# endif
#endif
int main()
diff --git a/Tests/CompileFeatures/default_dialect.cpp b/Tests/CompileFeatures/default_dialect.cpp
index 9b65b424a..e6b3ff631 100644
--- a/Tests/CompileFeatures/default_dialect.cpp
+++ b/Tests/CompileFeatures/default_dialect.cpp
@@ -2,26 +2,46 @@
template <long l>
struct Outputter;
-#if DEFAULT_CXX17
-#if __cplusplus <= 201402L
-Outputter<__cplusplus> o;
+#if defined(__INTEL_COMPILER) && defined(_MSVC_LANG) && _MSVC_LANG < 201403L
+# if defined(__INTEL_CXX11_MODE__)
+# if defined(__cpp_aggregate_nsdmi)
+# define CXX_STD 201402L
+# else
+# define CXX_STD 201103L
+# endif
+# else
+# define CXX_STD 199711L
+# endif
+#elif defined(_MSC_VER) && defined(_MSVC_LANG)
+# define CXX_STD _MSVC_LANG
+#else
+# define CXX_STD __cplusplus
#endif
+
+#if DEFAULT_CXX20
+# if CXX_STD <= 201703L
+Outputter<CXX_STD> o;
+# endif
+#elif DEFAULT_CXX17
+# if CXX_STD <= 201402L
+Outputter<CXX_STD> o;
+# endif
#elif DEFAULT_CXX14
-#if __cplusplus != 201402L
-Outputter<__cplusplus> o;
-#endif
+# if CXX_STD != 201402L
+Outputter<CXX_STD> o;
+# endif
#elif DEFAULT_CXX11
-#if __cplusplus != 201103L
-Outputter<__cplusplus> o;
-#endif
+# if CXX_STD != 201103L
+Outputter<CXX_STD> o;
+# endif
#else
-#if !DEFAULT_CXX98
-#error Buildsystem error
-#endif
-#if __cplusplus != 199711L && __cplusplus != 1 && \
- !defined(__GXX_EXPERIMENTAL_CXX0X__)
-Outputter<__cplusplus> o;
-#endif
+# if !DEFAULT_CXX98
+# error Buildsystem error
+# endif
+# if CXX_STD != 199711L && CXX_STD != 1 && \
+ !defined(__GXX_EXPERIMENTAL_CXX0X__)
+Outputter<CXX_STD> o;
+# endif
#endif
int main()
diff --git a/Tests/CompileFeatures/genex_test.c b/Tests/CompileFeatures/genex_test.c
index 1d548406f..de408ce32 100644
--- a/Tests/CompileFeatures/genex_test.c
+++ b/Tests/CompileFeatures/genex_test.c
@@ -1,35 +1,41 @@
#ifndef EXPECT_C_STATIC_ASSERT
-#error EXPECT_C_STATIC_ASSERT not defined
+# error EXPECT_C_STATIC_ASSERT not defined
#endif
#ifndef EXPECT_C_FUNCTION_PROTOTYPES
-#error EXPECT_C_FUNCTION_PROTOTYPES not defined
+# error EXPECT_C_FUNCTION_PROTOTYPES not defined
#endif
#ifndef EXPECT_C_RESTRICT
-#error EXPECT_C_RESTRICT not defined
+# error EXPECT_C_RESTRICT not defined
#endif
-#if !EXPECT_C_STATIC_ASSERT
-#if EXPECT_C_STATIC_ASSERT
-#error "Expect c_static_assert feature"
-#endif
+#if !HAVE_C_STATIC_ASSERT
+# if EXPECT_C_STATIC_ASSERT
+# error "Expect c_static_assert feature"
+# endif
#else
-#if !EXPECT_C_STATIC_ASSERT
-#error "Expect no c_static_assert feature"
-#endif
+# if !EXPECT_C_STATIC_ASSERT
+# error "Expect no c_static_assert feature"
+# endif
#endif
-#if !EXPECT_C_FUNCTION_PROTOTYPES
-#error Expect c_function_prototypes support
+#if !HAVE_C_FUNCTION_PROTOTYPES
+# if EXPECT_C_FUNCTION_PROTOTYPES
+# error Expect c_function_prototypes support
+# endif
+#else
+# if !EXPECT_C_FUNCTION_PROTOTYPES
+# error Expect no c_function_prototypes support
+# endif
#endif
-#if !EXPECT_C_RESTRICT
-#if EXPECT_C_RESTRICT
-#error Expect c_restrict support
-#endif
+#if !HAVE_C_RESTRICT
+# if EXPECT_C_RESTRICT
+# error Expect c_restrict support
+# endif
#else
-#if !EXPECT_C_RESTRICT
-#error Expect no c_restrict support
-#endif
+# if !EXPECT_C_RESTRICT
+# error Expect no c_restrict support
+# endif
#endif
int main()
diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp
index 5ae8a7880..53dce625a 100644
--- a/Tests/CompileFeatures/genex_test.cpp
+++ b/Tests/CompileFeatures/genex_test.cpp
@@ -1,69 +1,70 @@
#ifndef EXPECT_FINAL
-#error EXPECT_FINAL not defined
+# error EXPECT_FINAL not defined
#endif
#ifndef EXPECT_INHERITING_CONSTRUCTORS
-#error EXPECT_INHERITING_CONSTRUCTORS not defined
+# error EXPECT_INHERITING_CONSTRUCTORS not defined
#endif
#ifndef EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL
-#error EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL not defined
+# error EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL not defined
#endif
#ifndef EXPECT_OVERRIDE_CONTROL
-#error EXPECT_OVERRIDE_CONTROL not defined
+# error EXPECT_OVERRIDE_CONTROL not defined
#endif
-#if !HAVE_OVERRIDE_CONTROL
-#if EXPECT_OVERRIDE_CONTROL
-#error "Expect override control feature"
-#endif
-#else
-#if !EXPECT_OVERRIDE_CONTROL
-#error "Expect no override control feature"
+#ifdef TEST_CXX_STD
+# if !HAVE_CXX_STD_11
+# error HAVE_CXX_STD_11 is false with CXX_STANDARD == 11
+# endif
+# if HAVE_CXX_STD_14 && !defined(ALLOW_LATER_STANDARDS)
+# error HAVE_CXX_STD_14 is true with CXX_STANDARD == 11
+# endif
+# if HAVE_CXX_STD_17 && !defined(ALLOW_LATER_STANDARDS)
+# error HAVE_CXX_STD_17 is true with CXX_STANDARD == 11
+# endif
#endif
-struct A
-{
- virtual int getA() { return 7; }
-};
-
-struct B final : A
-{
- int getA() override { return 42; }
-};
-
+#if !HAVE_OVERRIDE_CONTROL
+# if EXPECT_OVERRIDE_CONTROL
+# error "Expect override control feature"
+# endif
+#else
+# if !EXPECT_OVERRIDE_CONTROL
+# error "Expect no override control feature"
+# endif
#endif
#if !HAVE_AUTO_TYPE
-#error Expect cxx_auto_type support
+# error Expect cxx_auto_type support
#endif
#if !HAVE_INHERITING_CONSTRUCTORS
-#if EXPECT_INHERITING_CONSTRUCTORS
-#error Expect cxx_inheriting_constructors support
-#endif
+# if EXPECT_INHERITING_CONSTRUCTORS
+# error Expect cxx_inheriting_constructors support
+# endif
#else
-#if !EXPECT_INHERITING_CONSTRUCTORS
-#error Expect no cxx_inheriting_constructors support
-#endif
+# if !EXPECT_INHERITING_CONSTRUCTORS
+# error Expect no cxx_inheriting_constructors support
+# endif
#endif
#if !HAVE_FINAL
-#if EXPECT_FINAL
-#error Expect cxx_final support
-#endif
+# if EXPECT_FINAL
+# error Expect cxx_final support
+# endif
#else
-#if !EXPECT_FINAL
-#error Expect no cxx_final support
-#endif
+# if !EXPECT_FINAL
+# error Expect no cxx_final support
+# endif
#endif
#if !HAVE_INHERITING_CONSTRUCTORS_AND_FINAL
-#if EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL
-#error Expect cxx_inheriting_constructors and cxx_final support
-#endif
+# if EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL
+# error Expect cxx_inheriting_constructors and cxx_final support
+# endif
#else
-#if !EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL
-#error Expect no combined cxx_inheriting_constructors and cxx_final support
-#endif
+# if !EXPECT_INHERITING_CONSTRUCTORS_AND_FINAL
+# error Expect no combined cxx_inheriting_constructors and cxx_final support
+# endif
#endif
int main()
diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt
index 692e0de0c..1433462ba 100644
--- a/Tests/CompileOptions/CMakeLists.txt
+++ b/Tests/CompileOptions/CMakeLists.txt
@@ -4,6 +4,10 @@ project(CompileOptions)
add_library(testlib other.cpp)
+if(TEST_FORTRAN)
+ enable_language(Fortran)
+endif()
+
add_executable(CompileOptions main.cpp)
macro(get_compiler_test_genex lst lang)
@@ -13,16 +17,33 @@ endmacro()
get_compiler_test_genex(c_tests C)
get_compiler_test_genex(cxx_tests CXX)
+if(TEST_FORTRAN)
+ get_compiler_test_genex(fortran_tests Fortran)
+endif()
set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS
"-DTEST_DEFINE"
"-DNEEDS_ESCAPE=\"E$CAPE\""
"$<$<CXX_COMPILER_ID:GNU>:-DTEST_DEFINE_GNU>"
+ "$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-DTEST_DEFINE_CXX_AND_GNU>"
+ "SHELL:" # produces no options
${c_tests}
${cxx_tests}
+ ${fortran_tests}
)
+if(BORLAND OR WATCOM)
+ # these compilers do not support separate -D flags
+ target_compile_definitions(CompileOptions PRIVATE NO_DEF_TESTS)
+else()
+ set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS
+ "SHELL:-D DEF_A"
+ "$<1:SHELL:-D DEF_B>"
+ "SHELL:-D 'DEF_C' -D \"DEF_D\""
+ [[SHELL:-D "DEF_STR=\"string with spaces\""]]
+ )
+endif()
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland|Embarcadero")
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland|Embarcadero" AND NOT "${CMAKE_GENERATOR}" MATCHES "NMake Makefiles")
set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS
"-DTEST_OCTOTHORPE=\"#\""
)
@@ -42,3 +63,12 @@ target_compile_definitions(CompileOptions
"EXPECTED_C_COMPILER_VERSION=\"${CMAKE_C_COMPILER_VERSION}\""
"EXPECTED_CXX_COMPILER_VERSION=\"${CMAKE_CXX_COMPILER_VERSION}\""
)
+
+if(TEST_FORTRAN)
+ # Definitions for the C++ code to test the values
+ target_compile_definitions(CompileOptions
+ PRIVATE
+ "TEST_FORTRAN"
+ "EXPECTED_Fortran_COMPILER_VERSION=\"${CMAKE_Fortran_COMPILER_VERSION}\""
+ )
+endif()
diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp
index 63a0480cc..ebc101762 100644
--- a/Tests/CompileOptions/main.cpp
+++ b/Tests/CompileOptions/main.cpp
@@ -1,15 +1,40 @@
#ifndef TEST_DEFINE
-#error Expected definition TEST_DEFINE
+# error Expected definition TEST_DEFINE
#endif
#ifndef NEEDS_ESCAPE
-#error Expected definition NEEDS_ESCAPE
+# error Expected definition NEEDS_ESCAPE
#endif
#ifdef DO_GNU_TESTS
-#ifndef TEST_DEFINE_GNU
-#error Expected definition TEST_DEFINE_GNU
+# ifndef TEST_DEFINE_GNU
+# error Expected definition TEST_DEFINE_GNU
+# endif
+# ifndef TEST_DEFINE_CXX_AND_GNU
+# error Expected definition TEST_DEFINE_CXX_AND_GNU
+# endif
#endif
+
+#ifndef NO_DEF_TESTS
+# ifndef DEF_A
+# error Expected definition DEF_A
+# endif
+
+# ifndef DEF_B
+# error Expected definition DEF_B
+# endif
+
+# ifndef DEF_C
+# error Expected definition DEF_C
+# endif
+
+# ifndef DEF_D
+# error Expected definition DEF_D
+# endif
+
+# ifndef DEF_STR
+# error Expected definition DEF_STR
+# endif
#endif
#include <string.h>
@@ -20,12 +45,22 @@ int main()
#ifdef TEST_OCTOTHORPE
&& strcmp(TEST_OCTOTHORPE, "#") == 0
#endif
+#ifndef NO_DEF_TESTS
+ && strcmp(DEF_STR, "string with spaces") == 0
+#endif
&&
strcmp(EXPECTED_C_COMPILER_VERSION, TEST_C_COMPILER_VERSION) == 0 &&
- strcmp(EXPECTED_CXX_COMPILER_VERSION, TEST_CXX_COMPILER_VERSION) ==
- 0 &&
- TEST_C_COMPILER_VERSION_EQUALITY == 1 &&
- TEST_CXX_COMPILER_VERSION_EQUALITY == 1)
+ strcmp(EXPECTED_CXX_COMPILER_VERSION, TEST_CXX_COMPILER_VERSION) == 0
+#ifdef TEST_FORTRAN
+ && strcmp(EXPECTED_Fortran_COMPILER_VERSION,
+ TEST_Fortran_COMPILER_VERSION) == 0
+#endif
+ && TEST_C_COMPILER_VERSION_EQUALITY == 1 &&
+ TEST_CXX_COMPILER_VERSION_EQUALITY == 1
+#ifdef TEST_FORTRAN
+ && TEST_Fortran_COMPILER_VERSION_EQUALITY == 1
+#endif
+ )
? 0
: 1;
}
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt
index 075faa768..2e4175442 100644
--- a/Tests/Complex/CMakeLists.txt
+++ b/Tests/Complex/CMakeLists.txt
@@ -356,6 +356,8 @@ endwhile()
set(SHOULD_BE_ZERO )
set(SHOULD_BE_ONE 1)
+set(SHOULD_BE_ZERO_AND_INDENTED )
+set(SHOULD_BE_ONE_AND_INDENTED 1)
# test elseif functionality, the mess below tries to catch problem
# of clauses being executed early or late etc
@@ -438,13 +440,6 @@ set(CMAKE_CXX_STANDARD 98)
#
set(CMAKE_CXX_EXTENSIONS TRUE)
-# Those versions of the HP compiler that need a flag to get proper C++98
-# template support also need a flag to use the newer C++ library.
-if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
- CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98")
- string(APPEND CMAKE_CXX_FLAGS " -AA")
-endif ()
-
# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
diff --git a/Tests/Complex/Cache/CMakeCache.txt b/Tests/Complex/Cache/CMakeCache.txt
index 17c55aa01..727faa2e7 100644
--- a/Tests/Complex/Cache/CMakeCache.txt
+++ b/Tests/Complex/Cache/CMakeCache.txt
@@ -5,7 +5,7 @@
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
-# KEY is the name of a varible in the cache.
+# KEY is the name of a variable in the cache.
# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!.
# VALUE is the current value for the KEY.
diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx
index 3b09229ba..49e97d585 100644
--- a/Tests/Complex/Executable/complex.cxx
+++ b/Tests/Complex/Executable/complex.cxx
@@ -1,23 +1,25 @@
-#include "Aout.h"
-#include "ExtraSources/file1.h"
#include "cmTestConfigure.h"
#include "cmTestConfigureEscape.h"
#include "cmTestGeneratedHeader.h"
#include "cmVersion.h"
+
+#include "Aout.h"
+#include "ExtraSources/file1.h"
#include "file2.h"
#include "sharedFile.h"
extern "C" {
#include "testConly.h"
}
#include <iostream>
-#include <string.h>
#include <string>
#include <vector>
#include <stdio.h>
+#include <string.h>
+
#include <sys/stat.h>
#if !defined(S_ISDIR)
-#define S_ISDIR(mode) ((mode)&_S_IFDIR)
+# define S_ISDIR(mode) ((mode)&_S_IFDIR)
#endif
#ifdef COMPLEX_TEST_LINK_STATIC
@@ -45,23 +47,23 @@ void cmPassed(const char* Message, const char* m2 = "")
}
#ifndef COMPLEX_DEFINED_PRE
-#error "COMPLEX_DEFINED_PRE not defined!"
+# error "COMPLEX_DEFINED_PRE not defined!"
#endif
#ifdef COMPLEX_DEFINED
-#error "COMPLEX_DEFINED is defined but it should not!"
+# error "COMPLEX_DEFINED is defined but it should not!"
#endif
#ifndef COMPLEX_DEFINED_POST
-#error "COMPLEX_DEFINED_POST not defined!"
+# error "COMPLEX_DEFINED_POST not defined!"
#endif
#ifndef CMAKE_IS_REALLY_FUN
-#error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
+# error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
#endif
#if defined(NDEBUG) && !defined(CMAKE_IS_FUN_IN_RELEASE_MODE)
-#error Per-configuration directory-level definition not inherited.
+# error Per-configuration directory-level definition not inherited.
#endif
// ======================================================================
@@ -200,8 +202,8 @@ int main()
cmFailed(msg);
}
-// ----------------------------------------------------------------------
-// Test ADD_DEFINITIONS
+ // ----------------------------------------------------------------------
+ // Test ADD_DEFINITIONS
#ifndef CMAKE_IS_FUN
cmFailed("CMake is not fun, so it is broken and should be fixed.");
@@ -240,8 +242,8 @@ int main()
cmPassed("CMake found the listfile stack properly");
#endif
-// ----------------------------------------------------------------------
-// Test SET, VARIABLE_REQUIRES
+ // ----------------------------------------------------------------------
+ // Test SET, VARIABLE_REQUIRES
#ifdef SHOULD_NOT_BE_DEFINED
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
@@ -261,6 +263,12 @@ int main()
cmPassed("ONE_VAR is defined.");
#endif
+#ifndef ONE_VAR_AND_INDENTED
+ cmFailed("cmakedefine is broken, ONE_VAR_AND_INDENTED is not defined.");
+#else
+ cmPassed("ONE_VAR_AND_INDENTED is defined.");
+#endif
+
#ifndef ONE_VAR_IS_DEFINED
cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
"ONE_VAR_IS_DEFINED is not defined.");
@@ -274,6 +282,12 @@ int main()
cmPassed("ZERO_VAR is not defined.");
#endif
+#ifdef ZERO_VAR_AND_INDENTED
+ cmFailed("cmakedefine is broken, ZERO_VAR_AND_INDENTED is defined.");
+#else
+ cmPassed("ZERO_VAR_AND_INDENTED is not defined.");
+#endif
+
#ifndef STRING_VAR
cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
#else
@@ -285,8 +299,8 @@ int main()
}
#endif
-// ----------------------------------------------------------------------
-// Test various IF/ELSE combinations
+ // ----------------------------------------------------------------------
+ // Test various IF/ELSE combinations
#ifdef SHOULD_NOT_BE_DEFINED_NOT
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT is defined.");
@@ -728,8 +742,8 @@ int main()
cmPassed("SHOULD_BE_DEFINED_STRGREATER_EQUAL3 is defined.");
#endif
-// ----------------------------------------------------------------------
-// Test FOREACH
+ // ----------------------------------------------------------------------
+ // Test FOREACH
#ifndef FOREACH_VAR1
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
@@ -779,8 +793,8 @@ int main()
cmPassed("WHILE command is working");
}
-// ----------------------------------------------------------------------
-// Test LOAD_CACHE
+ // ----------------------------------------------------------------------
+ // Test LOAD_CACHE
#ifndef CACHE_TEST_VAR1
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
@@ -889,8 +903,8 @@ int main()
TestAndRemoveFile("Executable/Temp/complex-required.txt");
-// ----------------------------------------------------------------------
-// Test FIND_LIBRARY
+ // ----------------------------------------------------------------------
+ // Test FIND_LIBRARY
#ifndef FIND_DUMMY_LIB
cmFailed("the CONFIGURE_FILE command is broken, "
@@ -905,8 +919,8 @@ int main()
}
#endif
-// ----------------------------------------------------------------------
-// Test SET_SOURCE_FILES_PROPERTIES
+ // ----------------------------------------------------------------------
+ // Test SET_SOURCE_FILES_PROPERTIES
#ifndef FILE_HAS_EXTRA_COMPILE_FLAGS
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting "
@@ -917,9 +931,9 @@ int main()
#endif
#if 0 // Disable until implemented everywhere.
-#ifndef FILE_DEFINE_STRING
+# ifndef FILE_DEFINE_STRING
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag");
-#else
+# else
if(strcmp(FILE_DEFINE_STRING, "hello") != 0)
{
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag correctly");
@@ -928,7 +942,7 @@ int main()
{
cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_DEFINE_STRING flag");
}
-#endif
+# endif
#endif
#ifndef FILE_HAS_ABSTRACT
@@ -961,10 +975,10 @@ int main()
// ----------------------------------------------------------------------
// Test registry (win32)
#if defined(_WIN32) && !defined(__CYGWIN__)
-#ifndef REGISTRY_TEST_PATH
+# ifndef REGISTRY_TEST_PATH
cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not "
"defined.");
-#else
+# else
std::cout << "REGISTRY_TEST_PATH == " << REGISTRY_TEST_PATH << "\n";
if (stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) {
cmFailed("the 'read registry value' function or CONFIGURE_FILE command is "
@@ -973,7 +987,7 @@ int main()
} else {
cmPassed("REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH);
}
-#endif
+# endif
#endif // defined(_WIN32) && !defined(__CYGWIN__)
if (strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "2.4") == 0) {
@@ -1030,6 +1044,16 @@ int main()
} else {
cmFailed("cmakedefine01 is not working for 1");
}
+ if (SHOULD_BE_ZERO_AND_INDENTED == 0) {
+ cmPassed("cmakedefine01 is working for 0 and indented");
+ } else {
+ cmFailed("cmakedefine01 is not working for 0 and indented");
+ }
+ if (SHOULD_BE_ONE_AND_INDENTED == 1) {
+ cmPassed("cmakedefine01 is working for 1 and indented");
+ } else {
+ cmFailed("cmakedefine01 is not working for 1 and indented");
+ }
#ifdef FORCE_TEST
cmFailed("CMake SET CACHE FORCE");
#else
diff --git a/Tests/Complex/Executable/complex.file.cxx b/Tests/Complex/Executable/complex.file.cxx
index cfba9ed42..55964302d 100644
--- a/Tests/Complex/Executable/complex.file.cxx
+++ b/Tests/Complex/Executable/complex.file.cxx
@@ -1,5 +1,5 @@
#if 0
-#include "cmMissingHeader.h"
+# include "cmMissingHeader.h"
#endif
int main(int, char**)
diff --git a/Tests/Complex/Executable/notInAllExe.cxx b/Tests/Complex/Executable/notInAllExe.cxx
index 2685073d6..2b857b47c 100644
--- a/Tests/Complex/Executable/notInAllExe.cxx
+++ b/Tests/Complex/Executable/notInAllExe.cxx
@@ -6,5 +6,5 @@ int main()
}
#if 1
-#error "This target should not be compiled by ALL."
+# error "This target should not be compiled by ALL."
#endif
diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt
index dbf806e4f..64f6dc854 100644
--- a/Tests/Complex/Library/CMakeLists.txt
+++ b/Tests/Complex/Library/CMakeLists.txt
@@ -48,7 +48,7 @@ add_library(CMakeTestCLibraryShared SHARED testConly.c)
define_property(
TARGET PROPERTY FOO
BRIEF_DOCS "a test property"
- FULL_DOCS "A simple etst proerty that means nothign and is used for nothing"
+ FULL_DOCS "A simple test property that means nothing and is used for nothing"
)
set_target_properties(CMakeTestCLibraryShared PROPERTIES FOO BAR)
if(NOT BEOS AND NOT WIN32 AND NOT HAIKU) # No libm on BeOS.
diff --git a/Tests/Complex/Library/notInAllLib.cxx b/Tests/Complex/Library/notInAllLib.cxx
index e66ea056f..033988fd8 100644
--- a/Tests/Complex/Library/notInAllLib.cxx
+++ b/Tests/Complex/Library/notInAllLib.cxx
@@ -4,5 +4,5 @@ int notInAllLibFunc()
}
#if 1
-#error "This target should not be compiled by ALL."
+# error "This target should not be compiled by ALL."
#endif
diff --git a/Tests/Complex/Library/sharedFile.h b/Tests/Complex/Library/sharedFile.h
index e32fcb760..830cbd5e8 100644
--- a/Tests/Complex/Library/sharedFile.h
+++ b/Tests/Complex/Library/sharedFile.h
@@ -1,12 +1,12 @@
#if defined(_WIN32) || defined(WIN32) /* Win32 version */
-#ifdef CMakeTestLibraryShared_EXPORTS
-#define CMakeTest_EXPORT __declspec(dllexport)
-#else
-#define CMakeTest_EXPORT __declspec(dllimport)
-#endif
+# ifdef CMakeTestLibraryShared_EXPORTS
+# define CMakeTest_EXPORT __declspec(dllexport)
+# else
+# define CMakeTest_EXPORT __declspec(dllimport)
+# endif
#else
/* unix needs nothing */
-#define CMakeTest_EXPORT
+# define CMakeTest_EXPORT
#endif
CMakeTest_EXPORT int sharedFunction();
diff --git a/Tests/Complex/Library/testConly.c b/Tests/Complex/Library/testConly.c
index a7d20b0b5..eb933a26f 100644
--- a/Tests/Complex/Library/testConly.c
+++ b/Tests/Complex/Library/testConly.c
@@ -1,4 +1,5 @@
#include "testConly.h"
+
#include <stdio.h>
int CsharedFunction()
diff --git a/Tests/Complex/Library/testConly.h b/Tests/Complex/Library/testConly.h
index 9b0fb73ff..02b28ccab 100644
--- a/Tests/Complex/Library/testConly.h
+++ b/Tests/Complex/Library/testConly.h
@@ -1,12 +1,12 @@
#if defined(_WIN32) || defined(WIN32) /* Win32 version */
-#ifdef CMakeTestCLibraryShared_EXPORTS
-#define CMakeTest_EXPORT __declspec(dllexport)
-#else
-#define CMakeTest_EXPORT __declspec(dllimport)
-#endif
+# ifdef CMakeTestCLibraryShared_EXPORTS
+# define CMakeTest_EXPORT __declspec(dllexport)
+# else
+# define CMakeTest_EXPORT __declspec(dllimport)
+# endif
#else
/* unix needs nothing */
-#define CMakeTest_EXPORT
+# define CMakeTest_EXPORT
#endif
CMakeTest_EXPORT int CsharedFunction();
diff --git a/Tests/Complex/VarTests.cmake b/Tests/Complex/VarTests.cmake
index 8be59be5e..9761986ab 100644
--- a/Tests/Complex/VarTests.cmake
+++ b/Tests/Complex/VarTests.cmake
@@ -2,6 +2,7 @@
# Test SET
#
set (ZERO_VAR 0)
+set (ZERO_VAR_AND_INDENTED 0)
set (ZERO_VAR2 0)
if(ZERO_VAR)
@@ -11,6 +12,7 @@ else()
endif()
set(ONE_VAR 1)
+set(ONE_VAR_AND_INDENTED 1)
set(ONE_VAR2 1)
set(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
diff --git a/Tests/Complex/cmTestConfigure.h.in b/Tests/Complex/cmTestConfigure.h.in
index d7424b184..72317bcc8 100644
--- a/Tests/Complex/cmTestConfigure.h.in
+++ b/Tests/Complex/cmTestConfigure.h.in
@@ -1,8 +1,10 @@
// Test SET, VARIABLE_REQUIRES
#cmakedefine ONE_VAR
+# cmakedefine ONE_VAR_AND_INDENTED
#cmakedefine ONE_VAR_IS_DEFINED
#cmakedefine ZERO_VAR
+# cmakedefine ZERO_VAR_AND_INDENTED
#define STRING_VAR "${STRING_VAR}"
@@ -32,6 +34,8 @@
#cmakedefine01 SHOULD_BE_ZERO
#cmakedefine01 SHOULD_BE_ONE
+# cmakedefine01 SHOULD_BE_ZERO_AND_INDENTED
+# cmakedefine01 SHOULD_BE_ONE_AND_INDENTED
// Needed to check for files
#define BINARY_DIR "${Complex_BINARY_DIR}"
diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt
index 1b833b241..628cd4ec3 100644
--- a/Tests/ComplexOneConfig/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/CMakeLists.txt
@@ -313,6 +313,8 @@ endwhile()
set(SHOULD_BE_ZERO )
set(SHOULD_BE_ONE 1)
+set(SHOULD_BE_ZERO_AND_INDENTED )
+set(SHOULD_BE_ONE_AND_INDENTED 1)
# test elseif functionality, the mess below tries to catch problem
# of clauses being executed early or late etc
@@ -395,13 +397,6 @@ set(CMAKE_CXX_STANDARD 98)
#
set(CMAKE_CXX_EXTENSIONS TRUE)
-# Those versions of the HP compiler that need a flag to get proper C++98
-# template support also need a flag to use the newer C++ library.
-if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
- CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98")
- string(APPEND CMAKE_CXX_FLAGS " -AA")
-endif ()
-
# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
diff --git a/Tests/ComplexOneConfig/Cache/CMakeCache.txt b/Tests/ComplexOneConfig/Cache/CMakeCache.txt
index 17c55aa01..727faa2e7 100644
--- a/Tests/ComplexOneConfig/Cache/CMakeCache.txt
+++ b/Tests/ComplexOneConfig/Cache/CMakeCache.txt
@@ -5,7 +5,7 @@
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
-# KEY is the name of a varible in the cache.
+# KEY is the name of a variable in the cache.
# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!.
# VALUE is the current value for the KEY.
diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx
index 9e4eaadf7..54c18f4ab 100644
--- a/Tests/ComplexOneConfig/Executable/complex.cxx
+++ b/Tests/ComplexOneConfig/Executable/complex.cxx
@@ -1,23 +1,25 @@
-#include "Aout.h"
-#include "ExtraSources/file1.h"
#include "cmTestConfigure.h"
#include "cmTestConfigureEscape.h"
#include "cmTestGeneratedHeader.h"
#include "cmVersion.h"
+
+#include "Aout.h"
+#include "ExtraSources/file1.h"
#include "file2.h"
#include "sharedFile.h"
extern "C" {
#include "testConly.h"
}
#include <iostream>
-#include <string.h>
#include <string>
#include <vector>
#include <stdio.h>
+#include <string.h>
+
#include <sys/stat.h>
#if !defined(S_ISDIR)
-#define S_ISDIR(mode) ((mode)&_S_IFDIR)
+# define S_ISDIR(mode) ((mode)&_S_IFDIR)
#endif
#ifdef COMPLEX_TEST_LINK_STATIC
@@ -45,23 +47,23 @@ void cmPassed(const char* Message, const char* m2 = "")
}
#ifndef COMPLEX_DEFINED_PRE
-#error "COMPLEX_DEFINED_PRE not defined!"
+# error "COMPLEX_DEFINED_PRE not defined!"
#endif
#ifdef COMPLEX_DEFINED
-#error "COMPLEX_DEFINED is defined but it should not!"
+# error "COMPLEX_DEFINED is defined but it should not!"
#endif
#ifndef COMPLEX_DEFINED_POST
-#error "COMPLEX_DEFINED_POST not defined!"
+# error "COMPLEX_DEFINED_POST not defined!"
#endif
#ifndef CMAKE_IS_REALLY_FUN
-#error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
+# error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
#endif
#if defined(NDEBUG) && !defined(CMAKE_IS_FUN_IN_RELEASE_MODE)
-#error Per-configuration directory-level definition not inherited.
+# error Per-configuration directory-level definition not inherited.
#endif
// ======================================================================
@@ -200,8 +202,8 @@ int main()
cmFailed(msg);
}
-// ----------------------------------------------------------------------
-// Test ADD_DEFINITIONS
+ // ----------------------------------------------------------------------
+ // Test ADD_DEFINITIONS
#ifndef CMAKE_IS_FUN
cmFailed("CMake is not fun, so it is broken and should be fixed.");
@@ -240,8 +242,8 @@ int main()
cmPassed("CMake found the listfile stack properly");
#endif
-// ----------------------------------------------------------------------
-// Test SET, VARIABLE_REQUIRES
+ // ----------------------------------------------------------------------
+ // Test SET, VARIABLE_REQUIRES
#ifdef SHOULD_NOT_BE_DEFINED
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
@@ -261,6 +263,12 @@ int main()
cmPassed("ONE_VAR is defined.");
#endif
+#ifndef ONE_VAR_AND_INDENTED
+ cmFailed("cmakedefine is broken, ONE_VAR_AND_INDENTED is not defined.");
+#else
+ cmPassed("ONE_VAR_AND_INDENTED is defined.");
+#endif
+
#ifndef ONE_VAR_IS_DEFINED
cmFailed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
"ONE_VAR_IS_DEFINED is not defined.");
@@ -274,6 +282,12 @@ int main()
cmPassed("ZERO_VAR is not defined.");
#endif
+#ifdef ZERO_VAR_AND_INDENTED
+ cmFailed("cmakedefine is broken, ZERO_VAR_AND_INDENTED is defined.");
+#else
+ cmPassed("ZERO_VAR_AND_INDENTED is not defined.");
+#endif
+
#ifndef STRING_VAR
cmFailed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
#else
@@ -285,8 +299,8 @@ int main()
}
#endif
-// ----------------------------------------------------------------------
-// Test various IF/ELSE combinations
+ // ----------------------------------------------------------------------
+ // Test various IF/ELSE combinations
#ifdef SHOULD_NOT_BE_DEFINED_NOT
cmFailed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_NOT is defined.");
@@ -728,8 +742,8 @@ int main()
cmPassed("SHOULD_BE_DEFINED_STRGREATER_EQUAL3 is defined.");
#endif
-// ----------------------------------------------------------------------
-// Test FOREACH
+ // ----------------------------------------------------------------------
+ // Test FOREACH
#ifndef FOREACH_VAR1
cmFailed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
@@ -779,8 +793,8 @@ int main()
cmPassed("WHILE command is working");
}
-// ----------------------------------------------------------------------
-// Test LOAD_CACHE
+ // ----------------------------------------------------------------------
+ // Test LOAD_CACHE
#ifndef CACHE_TEST_VAR1
cmFailed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
@@ -889,8 +903,8 @@ int main()
TestAndRemoveFile("Executable/Temp/complex-required.txt");
-// ----------------------------------------------------------------------
-// Test FIND_LIBRARY
+ // ----------------------------------------------------------------------
+ // Test FIND_LIBRARY
#ifndef FIND_DUMMY_LIB
cmFailed("the CONFIGURE_FILE command is broken, "
@@ -905,8 +919,8 @@ int main()
}
#endif
-// ----------------------------------------------------------------------
-// Test SET_SOURCE_FILES_PROPERTIES
+ // ----------------------------------------------------------------------
+ // Test SET_SOURCE_FILES_PROPERTIES
#ifndef FILE_HAS_EXTRA_COMPILE_FLAGS
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting "
@@ -917,9 +931,9 @@ int main()
#endif
#if 0 // Disable until implemented everywhere.
-#ifndef FILE_DEFINE_STRING
+# ifndef FILE_DEFINE_STRING
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag");
-#else
+# else
if(strcmp(FILE_DEFINE_STRING, "hello") != 0)
{
cmFailed("SET_SOURCE_FILES_PROPERTIES failed at setting FILE_DEFINE_STRING flag correctly");
@@ -928,7 +942,7 @@ int main()
{
cmPassed("SET_SOURCE_FILES_PROPERTIES succeeded in setting FILE_DEFINE_STRING flag");
}
-#endif
+# endif
#endif
#ifndef FILE_HAS_ABSTRACT
@@ -961,10 +975,10 @@ int main()
// ----------------------------------------------------------------------
// Test registry (win32)
#if defined(_WIN32) && !defined(__CYGWIN__)
-#ifndef REGISTRY_TEST_PATH
+# ifndef REGISTRY_TEST_PATH
cmFailed("the CONFIGURE_FILE command is broken, REGISTRY_TEST_PATH is not "
"defined.");
-#else
+# else
std::cout << "REGISTRY_TEST_PATH == " << REGISTRY_TEST_PATH << "\n";
if (stricmp(REGISTRY_TEST_PATH, BINARY_DIR "/registry_dir") != 0) {
cmFailed("the 'read registry value' function or CONFIGURE_FILE command is "
@@ -973,7 +987,7 @@ int main()
} else {
cmPassed("REGISTRY_TEST_PATH == ", REGISTRY_TEST_PATH);
}
-#endif
+# endif
#endif // defined(_WIN32) && !defined(__CYGWIN__)
if (strcmp(CMAKE_MINIMUM_REQUIRED_VERSION, "2.4") == 0) {
@@ -1030,6 +1044,16 @@ int main()
} else {
cmFailed("cmakedefine01 is not working for 1");
}
+ if (SHOULD_BE_ZERO_AND_INDENTED == 0) {
+ cmPassed("cmakedefine01 is working for 0 and indented");
+ } else {
+ cmFailed("cmakedefine01 is not working for 0 and indented");
+ }
+ if (SHOULD_BE_ONE_AND_INDENTED == 1) {
+ cmPassed("cmakedefine01 is working for 1 and indented");
+ } else {
+ cmFailed("cmakedefine01 is not working for 1 and indented");
+ }
#ifdef FORCE_TEST
cmFailed("CMake SET CACHE FORCE");
#else
diff --git a/Tests/ComplexOneConfig/Executable/complex.file.cxx b/Tests/ComplexOneConfig/Executable/complex.file.cxx
index cfba9ed42..55964302d 100644
--- a/Tests/ComplexOneConfig/Executable/complex.file.cxx
+++ b/Tests/ComplexOneConfig/Executable/complex.file.cxx
@@ -1,5 +1,5 @@
#if 0
-#include "cmMissingHeader.h"
+# include "cmMissingHeader.h"
#endif
int main(int, char**)
diff --git a/Tests/ComplexOneConfig/Executable/notInAllExe.cxx b/Tests/ComplexOneConfig/Executable/notInAllExe.cxx
index 2685073d6..2b857b47c 100644
--- a/Tests/ComplexOneConfig/Executable/notInAllExe.cxx
+++ b/Tests/ComplexOneConfig/Executable/notInAllExe.cxx
@@ -6,5 +6,5 @@ int main()
}
#if 1
-#error "This target should not be compiled by ALL."
+# error "This target should not be compiled by ALL."
#endif
diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt
index dbf806e4f..64f6dc854 100644
--- a/Tests/ComplexOneConfig/Library/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt
@@ -48,7 +48,7 @@ add_library(CMakeTestCLibraryShared SHARED testConly.c)
define_property(
TARGET PROPERTY FOO
BRIEF_DOCS "a test property"
- FULL_DOCS "A simple etst proerty that means nothign and is used for nothing"
+ FULL_DOCS "A simple test property that means nothing and is used for nothing"
)
set_target_properties(CMakeTestCLibraryShared PROPERTIES FOO BAR)
if(NOT BEOS AND NOT WIN32 AND NOT HAIKU) # No libm on BeOS.
diff --git a/Tests/ComplexOneConfig/Library/notInAllLib.cxx b/Tests/ComplexOneConfig/Library/notInAllLib.cxx
index e66ea056f..033988fd8 100644
--- a/Tests/ComplexOneConfig/Library/notInAllLib.cxx
+++ b/Tests/ComplexOneConfig/Library/notInAllLib.cxx
@@ -4,5 +4,5 @@ int notInAllLibFunc()
}
#if 1
-#error "This target should not be compiled by ALL."
+# error "This target should not be compiled by ALL."
#endif
diff --git a/Tests/ComplexOneConfig/Library/sharedFile.h b/Tests/ComplexOneConfig/Library/sharedFile.h
index e32fcb760..830cbd5e8 100644
--- a/Tests/ComplexOneConfig/Library/sharedFile.h
+++ b/Tests/ComplexOneConfig/Library/sharedFile.h
@@ -1,12 +1,12 @@
#if defined(_WIN32) || defined(WIN32) /* Win32 version */
-#ifdef CMakeTestLibraryShared_EXPORTS
-#define CMakeTest_EXPORT __declspec(dllexport)
-#else
-#define CMakeTest_EXPORT __declspec(dllimport)
-#endif
+# ifdef CMakeTestLibraryShared_EXPORTS
+# define CMakeTest_EXPORT __declspec(dllexport)
+# else
+# define CMakeTest_EXPORT __declspec(dllimport)
+# endif
#else
/* unix needs nothing */
-#define CMakeTest_EXPORT
+# define CMakeTest_EXPORT
#endif
CMakeTest_EXPORT int sharedFunction();
diff --git a/Tests/ComplexOneConfig/Library/testConly.c b/Tests/ComplexOneConfig/Library/testConly.c
index a7d20b0b5..eb933a26f 100644
--- a/Tests/ComplexOneConfig/Library/testConly.c
+++ b/Tests/ComplexOneConfig/Library/testConly.c
@@ -1,4 +1,5 @@
#include "testConly.h"
+
#include <stdio.h>
int CsharedFunction()
diff --git a/Tests/ComplexOneConfig/Library/testConly.h b/Tests/ComplexOneConfig/Library/testConly.h
index 9b0fb73ff..02b28ccab 100644
--- a/Tests/ComplexOneConfig/Library/testConly.h
+++ b/Tests/ComplexOneConfig/Library/testConly.h
@@ -1,12 +1,12 @@
#if defined(_WIN32) || defined(WIN32) /* Win32 version */
-#ifdef CMakeTestCLibraryShared_EXPORTS
-#define CMakeTest_EXPORT __declspec(dllexport)
-#else
-#define CMakeTest_EXPORT __declspec(dllimport)
-#endif
+# ifdef CMakeTestCLibraryShared_EXPORTS
+# define CMakeTest_EXPORT __declspec(dllexport)
+# else
+# define CMakeTest_EXPORT __declspec(dllimport)
+# endif
#else
/* unix needs nothing */
-#define CMakeTest_EXPORT
+# define CMakeTest_EXPORT
#endif
CMakeTest_EXPORT int CsharedFunction();
diff --git a/Tests/ComplexOneConfig/VarTests.cmake b/Tests/ComplexOneConfig/VarTests.cmake
index 7dd851974..42afd19ea 100644
--- a/Tests/ComplexOneConfig/VarTests.cmake
+++ b/Tests/ComplexOneConfig/VarTests.cmake
@@ -2,6 +2,7 @@
# Test SET
#
set (ZERO_VAR 0)
+set (ZERO_VAR_AND_INDENTED 0)
set (ZERO_VAR2 0)
if(ZERO_VAR)
@@ -11,6 +12,7 @@ else()
endif()
set(ONE_VAR 1)
+set(ONE_VAR_AND_INDENTED 1)
set(ONE_VAR2 1)
set(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
diff --git a/Tests/ComplexOneConfig/cmTestConfigure.h.in b/Tests/ComplexOneConfig/cmTestConfigure.h.in
index d7424b184..72317bcc8 100644
--- a/Tests/ComplexOneConfig/cmTestConfigure.h.in
+++ b/Tests/ComplexOneConfig/cmTestConfigure.h.in
@@ -1,8 +1,10 @@
// Test SET, VARIABLE_REQUIRES
#cmakedefine ONE_VAR
+# cmakedefine ONE_VAR_AND_INDENTED
#cmakedefine ONE_VAR_IS_DEFINED
#cmakedefine ZERO_VAR
+# cmakedefine ZERO_VAR_AND_INDENTED
#define STRING_VAR "${STRING_VAR}"
@@ -32,6 +34,8 @@
#cmakedefine01 SHOULD_BE_ZERO
#cmakedefine01 SHOULD_BE_ONE
+# cmakedefine01 SHOULD_BE_ZERO_AND_INDENTED
+# cmakedefine01 SHOULD_BE_ONE_AND_INDENTED
// Needed to check for files
#define BINARY_DIR "${Complex_BINARY_DIR}"
diff --git a/Tests/ConfigSources/CMakeLists.txt b/Tests/ConfigSources/CMakeLists.txt
index 748aad887..f5dd2765c 100644
--- a/Tests/ConfigSources/CMakeLists.txt
+++ b/Tests/ConfigSources/CMakeLists.txt
@@ -1,17 +1,21 @@
-
cmake_minimum_required(VERSION 3.0)
-
-project(ConfigSources)
+project(ConfigSources CXX)
add_library(iface INTERFACE)
-set_property(TARGET iface PROPERTY INTERFACE_SOURCES
+target_sources(iface INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/iface_src.cpp"
"$<$<CONFIG:Debug>:${CMAKE_CURRENT_SOURCE_DIR}/iface_debug_src.cpp>"
- "$<$<CONFIG:Release>:${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist.cpp>"
-)
+ "$<$<NOT:$<CONFIG:Debug>>:${CMAKE_CURRENT_SOURCE_DIR}/iface_other_src.cpp>"
+ "$<$<CONFIG:NotAConfig>:${CMAKE_CURRENT_SOURCE_DIR}/does_not_exist.cpp>"
+ )
+target_compile_definitions(iface INTERFACE
+ "$<$<CONFIG:Debug>:CFG_DEBUG>"
+ "$<$<NOT:$<CONFIG:Debug>>:CFG_OTHER>"
+ )
add_executable(ConfigSources
- $<$<CONFIG:Debug>:main.cpp>
- $<$<CONFIG:Release>:does_not_exist.cpp>
-)
+ $<$<CONFIG:Debug>:main_debug.cpp>
+ $<$<NOT:$<CONFIG:Debug>>:main_other.cpp>
+ $<$<CONFIG:NotAConfig>:does_not_exist.cpp>
+ )
target_link_libraries(ConfigSources iface)
diff --git a/Tests/ConfigSources/iface.h b/Tests/ConfigSources/iface.h
new file mode 100644
index 000000000..810456cbc
--- /dev/null
+++ b/Tests/ConfigSources/iface.h
@@ -0,0 +1,10 @@
+
+int iface_src();
+
+#ifdef CFG_DEBUG
+int iface_debug();
+#endif
+
+#ifdef CFG_OTHER
+int iface_other();
+#endif
diff --git a/Tests/ConfigSources/iface_debug.h b/Tests/ConfigSources/iface_debug.h
deleted file mode 100644
index a23d7374b..000000000
--- a/Tests/ConfigSources/iface_debug.h
+++ /dev/null
@@ -1,4 +0,0 @@
-
-int iface_src();
-
-int iface_debug();
diff --git a/Tests/ConfigSources/iface_debug_src.cpp b/Tests/ConfigSources/iface_debug_src.cpp
index 63b22fcd1..010059f1f 100644
--- a/Tests/ConfigSources/iface_debug_src.cpp
+++ b/Tests/ConfigSources/iface_debug_src.cpp
@@ -1,5 +1,11 @@
+#ifndef CFG_DEBUG
+# error "This source should only be compiled in a Debug configuration."
+#endif
+#ifdef CFG_OTHER
+# error "This source should not be compiled in a non-Debug configuration."
+#endif
-#include "iface_debug.h"
+#include "iface.h"
int iface_debug()
{
diff --git a/Tests/ConfigSources/iface_other_src.cpp b/Tests/ConfigSources/iface_other_src.cpp
new file mode 100644
index 000000000..8ffdfbb72
--- /dev/null
+++ b/Tests/ConfigSources/iface_other_src.cpp
@@ -0,0 +1,13 @@
+#ifndef CFG_OTHER
+# error "This source should only be compiled in a non-Debug configuration."
+#endif
+#ifdef CFG_DEBUG
+# error "This source should not be compiled in a Debug configuration."
+#endif
+
+#include "iface.h"
+
+int iface_other()
+{
+ return 0;
+}
diff --git a/Tests/ConfigSources/main.cpp b/Tests/ConfigSources/main.cpp
deleted file mode 100644
index 71af72f70..000000000
--- a/Tests/ConfigSources/main.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-
-#include "iface_debug.h"
-
-int main(int argc, char** argv)
-{
- return iface_src() + iface_debug();
-}
diff --git a/Tests/ConfigSources/main_debug.cpp b/Tests/ConfigSources/main_debug.cpp
new file mode 100644
index 000000000..9b1e68a26
--- /dev/null
+++ b/Tests/ConfigSources/main_debug.cpp
@@ -0,0 +1,13 @@
+#ifndef CFG_DEBUG
+# error "This source should only be compiled in a Debug configuration."
+#endif
+#ifdef CFG_OTHER
+# error "This source should not be compiled in a non-Debug configuration."
+#endif
+
+#include "iface.h"
+
+int main(int argc, char** argv)
+{
+ return iface_src() + iface_debug();
+}
diff --git a/Tests/ConfigSources/main_other.cpp b/Tests/ConfigSources/main_other.cpp
new file mode 100644
index 000000000..3184a19d2
--- /dev/null
+++ b/Tests/ConfigSources/main_other.cpp
@@ -0,0 +1,13 @@
+#ifndef CFG_OTHER
+# error "This source should only be compiled in a non-Debug configuration."
+#endif
+#ifdef CFG_DEBUG
+# error "This source should not be compiled in a Debug configuration."
+#endif
+
+#include "iface.h"
+
+int main(int argc, char** argv)
+{
+ return iface_src() + iface_other();
+}
diff --git a/Tests/Contracts/Home.cmake b/Tests/Contracts/Home.cmake
new file mode 100644
index 000000000..8b05e8190
--- /dev/null
+++ b/Tests/Contracts/Home.cmake
@@ -0,0 +1,19 @@
+# Find a home in which to build.
+if(NOT DEFINED HOME)
+ if(DEFINED ENV{CTEST_REAL_HOME})
+ set(HOME "$ENV{CTEST_REAL_HOME}")
+ else()
+ set(HOME "$ENV{HOME}")
+ endif()
+
+ if(NOT HOME AND WIN32)
+ # Try for USERPROFILE as HOME equivalent:
+ string(REPLACE "\\" "/" HOME "$ENV{USERPROFILE}")
+
+ # But just use root of SystemDrive if USERPROFILE contains any spaces:
+ # (Default on XP and earlier...)
+ if(HOME MATCHES " ")
+ string(REPLACE "\\" "/" HOME "$ENV{SystemDrive}")
+ endif()
+ endif()
+endif()
diff --git a/Tests/Contracts/PLplot/CMakeLists.txt b/Tests/Contracts/PLplot/CMakeLists.txt
new file mode 100644
index 000000000..8e95ba36a
--- /dev/null
+++ b/Tests/Contracts/PLplot/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.9)
+project(PLplotDriver NONE)
+include(ExternalProject)
+include(${CMAKE_CURRENT_SOURCE_DIR}/../Home.cmake)
+set(PLplot_PREFIX "${HOME}/.cmake/Contracts/PLplot")
+file(REMOVE_RECURSE "${PLplot_PREFIX}")
+separate_arguments(PLplot_CMAKE_ARGS UNIX_COMMAND "${PLplot_CMAKE_FLAGS}")
+if(NOT PLplot_GIT_TAG)
+ set(PLplot_GIT_TAG "plplot-5.13.0")
+endif()
+ExternalProject_Add(PLplot
+ GIT_REPOSITORY "https://git.code.sf.net/p/plplot/plplot"
+ GIT_TAG "${PLplot_GIT_TAG}"
+ PREFIX "${PLplot_PREFIX}"
+ CMAKE_ARGS
+ -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
+ ${PLplot_CMAKE_ARGS}
+ )
diff --git a/Tests/Contracts/PLplot/Configure.cmake b/Tests/Contracts/PLplot/Configure.cmake
new file mode 100644
index 000000000..83591d4fc
--- /dev/null
+++ b/Tests/Contracts/PLplot/Configure.cmake
@@ -0,0 +1,4 @@
+set(Contracts.PLplot_BUILD_OPTIONS
+ -DPLplot_CMAKE_FLAGS=${CMake_TEST_CONTRACT_PLplot_CMAKE_FLAGS}
+ -DPLplot_GIT_TAG=${CMake_TEST_CONTRACT_PLplot_GIT_TAG}
+ )
diff --git a/Tests/Contracts/Trilinos/CMakeLists.txt b/Tests/Contracts/Trilinos/CMakeLists.txt
index 8d74ca574..4d7062bbd 100644
--- a/Tests/Contracts/Trilinos/CMakeLists.txt
+++ b/Tests/Contracts/Trilinos/CMakeLists.txt
@@ -6,24 +6,7 @@ include(ExternalProject)
include("${CMAKE_CURRENT_SOURCE_DIR}/LocalOverrides.cmake" OPTIONAL)
include("${CMAKE_CURRENT_BINARY_DIR}/LocalOverrides.cmake" OPTIONAL)
-if(NOT DEFINED HOME)
- if(DEFINED ENV{CTEST_REAL_HOME})
- set(HOME "$ENV{CTEST_REAL_HOME}")
- else()
- set(HOME "$ENV{HOME}")
- endif()
-
- if(NOT HOME AND WIN32)
- # Try for USERPROFILE as HOME equivalent:
- string(REPLACE "\\" "/" HOME "$ENV{USERPROFILE}")
-
- # But just use root of SystemDrive if USERPROFILE contains any spaces:
- # (Default on XP and earlier...)
- if(HOME MATCHES " ")
- string(REPLACE "\\" "/" HOME "$ENV{SystemDrive}")
- endif()
- endif()
-endif()
+include(${CMAKE_CURRENT_SOURCE_DIR}/../Home.cmake)
message(STATUS "HOME='${HOME}'")
if(NOT DEFINED url)
diff --git a/Tests/Contracts/Trilinos/Configure.cmake b/Tests/Contracts/Trilinos/Configure.cmake
new file mode 100644
index 000000000..d62eb7917
--- /dev/null
+++ b/Tests/Contracts/Trilinos/Configure.cmake
@@ -0,0 +1,7 @@
+# ValidateBuild.cmake is configured into this location when the test is built:
+set(dir "${CMAKE_CURRENT_BINARY_DIR}/Contracts/${project}")
+
+set(exe "${CMAKE_COMMAND}")
+set(args -P "${dir}/ValidateBuild.cmake")
+
+set(CMake_TEST_CONTRACT_Trilinos_RUN_TEST ${exe} ${args})
diff --git a/Tests/Contracts/Trilinos/EnvScript.cmake b/Tests/Contracts/Trilinos/EnvScript.cmake
deleted file mode 100644
index dacb704f7..000000000
--- a/Tests/Contracts/Trilinos/EnvScript.cmake
+++ /dev/null
@@ -1,32 +0,0 @@
-# Site specific settings:
-#
-if(CTEST_SITE MATCHES "faraway")
- set(CTEST_SITE "faraway.kitware")
- set(ENV{CTEST_SITE} "${CTEST_SITE}")
-endif()
-
-if(CTEST_SITE STREQUAL "HUT11")
- set(CTEST_SITE "hut11.kitware")
- set(ENV{CTEST_SITE} "${CTEST_SITE}")
-
- set(ENV{CLAPACK_DIR} "C:/T/clapack/b/clapack-prefix/src/clapack-build")
-endif()
-
-if(CTEST_SITE MATCHES "qwghlm")
- set(CTEST_SITE "qwghlm.kitware")
- set(ENV{CTEST_SITE} "${CTEST_SITE}")
-
- set(ENV{PATH} "/opt/local/bin:$ENV{PATH}")
- set(ENV{CC} "gcc-mp-4.3")
- set(ENV{CXX} "g++-mp-4.3")
- set(ENV{FC} "gfortran-mp-4.3")
-endif()
-
-# Submit to alternate CDash server:
-#
-#set(ENV{CTEST_DROP_SITE} "localhost")
-#set(ENV{CTEST_DROP_LOCATION} "/CDash/submit.php?project=Trilinos")
-
-# Limit packages built:
-#
-set(ENV{Trilinos_PACKAGES} "Teuchos;Kokkos")
diff --git a/Tests/Contracts/Trilinos/RunTest.cmake b/Tests/Contracts/Trilinos/RunTest.cmake
deleted file mode 100644
index d661a4c1f..000000000
--- a/Tests/Contracts/Trilinos/RunTest.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-# ValidateBuild.cmake is configured into this location when the test is built:
-set(dir "${CMAKE_CURRENT_BINARY_DIR}/Contracts/${project}")
-
-set(exe "${CMAKE_COMMAND}")
-set(args -P "${dir}/ValidateBuild.cmake")
-
-set(Trilinos_RUN_TEST ${exe} ${args})
diff --git a/Tests/Contracts/VTK/CMakeLists.txt b/Tests/Contracts/VTK/CMakeLists.txt
index ef19325a4..c946499b6 100644
--- a/Tests/Contracts/VTK/CMakeLists.txt
+++ b/Tests/Contracts/VTK/CMakeLists.txt
@@ -5,24 +5,7 @@ project(VTK)
include(ExternalProject)
# find "HOME". VTK will be downloaded & built within a subdirectory.
-if(NOT DEFINED HOME)
- if(DEFINED ENV{CTEST_REAL_HOME})
- set(HOME "$ENV{CTEST_REAL_HOME}")
- else()
- set(HOME "$ENV{HOME}")
- endif()
-
- if(NOT HOME AND WIN32)
- # Try for USERPROFILE as HOME equivalent:
- string(REPLACE "\\" "/" HOME "$ENV{USERPROFILE}")
-
- # But just use root of SystemDrive if USERPROFILE contains any spaces:
- # (Default on XP and earlier...)
- if(HOME MATCHES " ")
- string(REPLACE "\\" "/" HOME "$ENV{SystemDrive}")
- endif()
- endif()
-endif()
+include(${CMAKE_CURRENT_SOURCE_DIR}/../Home.cmake)
set(base_dir "${HOME}/.cmake/Contracts/VTK")
diff --git a/Tests/Contracts/VTK/Configure.cmake b/Tests/Contracts/VTK/Configure.cmake
new file mode 100644
index 000000000..037d75ab2
--- /dev/null
+++ b/Tests/Contracts/VTK/Configure.cmake
@@ -0,0 +1,3 @@
+set(exe "$ENV{HOME}/.cmake/Contracts/VTK/VTK-build/bin/vtkCommonCoreCxxTests")
+set(args otherArrays)
+set(CMake_TEST_CONTRACT_VTK_RUN_TEST ${exe} ${args})
diff --git a/Tests/Contracts/VTK/RunTest.cmake b/Tests/Contracts/VTK/RunTest.cmake
deleted file mode 100644
index 65285cf77..000000000
--- a/Tests/Contracts/VTK/RunTest.cmake
+++ /dev/null
@@ -1,3 +0,0 @@
-set(exe "$ENV{HOME}/.cmake/Contracts/VTK/VTK-build/bin/vtkCommonCoreCxxTests")
-set(args otherArrays)
-set(VTK_RUN_TEST ${exe} ${args})
diff --git a/Tests/Contracts/cse-snapshot/CMakeLists.txt b/Tests/Contracts/cse-snapshot/CMakeLists.txt
deleted file mode 100644
index 913421010..000000000
--- a/Tests/Contracts/cse-snapshot/CMakeLists.txt
+++ /dev/null
@@ -1,114 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-project(cse-snapshot)
-
-include(ExternalProject)
-
-include("${CMAKE_CURRENT_SOURCE_DIR}/LocalOverrides.cmake" OPTIONAL)
-include("${CMAKE_CURRENT_BINARY_DIR}/LocalOverrides.cmake" OPTIONAL)
-
-if(NOT DEFINED HOME)
- if(DEFINED ENV{CTEST_REAL_HOME})
- set(HOME "$ENV{CTEST_REAL_HOME}")
- else()
- set(HOME "$ENV{HOME}")
- endif()
-endif()
-message(STATUS "HOME='${HOME}'")
-
-if(NOT DEFINED repo)
- set(repo "git://public.kitware.com/cse.git")
-endif()
-message(STATUS "repo='${repo}'")
-
-if(NOT DEFINED tag)
- set(tag "cc1dcb95439a21ab1d58f444d93481598414196e")
-endif()
-message(STATUS "tag='${tag}'")
-
-string(SUBSTRING "${tag}" 0 8 shorttag)
-
-set(base_dir "${HOME}/.cmake/Contracts/${PROJECT_NAME}/${shorttag}")
-set(binary_dir "${base_dir}/build")
-set(script_dir "${base_dir}")
-set(source_dir "${base_dir}/src")
-
-if(NOT DEFINED BUILDNAME)
- set(BUILDNAME "CMakeContract-${shorttag}")
-endif()
-message(STATUS "BUILDNAME='${BUILDNAME}'")
-
-if(NOT DEFINED SITE)
- site_name(SITE)
-endif()
-message(STATUS "SITE='${SITE}'")
-
-if(NOT DEFINED PROCESSOR_COUNT)
- # Unknown:
- set(PROCESSOR_COUNT 0)
-
- # Linux:
- set(cpuinfo_file "/proc/cpuinfo")
- if(EXISTS "${cpuinfo_file}")
- file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$")
- list(LENGTH procs PROCESSOR_COUNT)
- endif()
-
- # Mac:
- if(APPLE)
- find_program(cmd_sysctl "sysctl")
- if(cmd_sysctl)
- execute_process(COMMAND ${cmd_sysctl} -n hw.ncpu
- OUTPUT_VARIABLE PROCESSOR_COUNT
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- endif()
- endif()
-
- # Windows:
- if(WIN32)
- set(PROCESSOR_COUNT "$ENV{NUMBER_OF_PROCESSORS}")
- endif()
-endif()
-message(STATUS "PROCESSOR_COUNT='${PROCESSOR_COUNT}'")
-
-find_package(Git)
-if(NOT GIT_EXECUTABLE)
- message(FATAL_ERROR "error: could not find git")
- # adjust PATH to find git, or set GIT_EXECUTABLE in LocalOverrides.cmake
-endif()
-message(STATUS "GIT_EXECUTABLE='${GIT_EXECUTABLE}'")
-
-configure_file(
- "${CMAKE_CURRENT_SOURCE_DIR}/Dashboard.cmake.in"
- "${script_dir}/Dashboard.cmake"
- @ONLY)
-
-# Source dir for this project exists outside the CMake build tree because it
-# is absolutely huge.
-#
-if(EXISTS "${source_dir}/.git")
- # If it exists already, download is a complete no-op:
- ExternalProject_Add(download-${PROJECT_NAME}
- DOWNLOAD_COMMAND ""
- CONFIGURE_COMMAND ""
- BUILD_COMMAND ""
- INSTALL_COMMAND ""
- )
-else()
- # If it does not yet exist, download clones the git repository:
- ExternalProject_Add(download-${PROJECT_NAME}
- SOURCE_DIR "${source_dir}"
- GIT_REPOSITORY "${repo}"
- GIT_TAG "${tag}"
- CONFIGURE_COMMAND ""
- BUILD_COMMAND ""
- INSTALL_COMMAND ""
- )
-endif()
-
-ExternalProject_Add(build-${PROJECT_NAME}
- DOWNLOAD_COMMAND ""
- CONFIGURE_COMMAND ""
- BUILD_COMMAND ${CMAKE_CTEST_COMMAND} -S "${script_dir}/Dashboard.cmake"
- INSTALL_COMMAND ""
- DEPENDS download-${PROJECT_NAME}
- )
diff --git a/Tests/Contracts/cse-snapshot/Dashboard.cmake.in b/Tests/Contracts/cse-snapshot/Dashboard.cmake.in
deleted file mode 100644
index 138eb3f81..000000000
--- a/Tests/Contracts/cse-snapshot/Dashboard.cmake.in
+++ /dev/null
@@ -1,76 +0,0 @@
-# This "ctest -S" script may be configured to drive a nightly dashboard on any
-# Linux machine.
-#
-set(CTEST_BINARY_DIRECTORY "@binary_dir@")
-set(CTEST_BUILD_NAME "@BUILDNAME@")
-set(CTEST_SITE "@SITE@")
-set(CTEST_SOURCE_DIRECTORY "@source_dir@")
-set(PROCESSOR_COUNT "@PROCESSOR_COUNT@")
-
-# Assume a Linux build, with a make that supports -j. Modify this script if
-# assumption is ever invalid.
-#
-if(PROCESSOR_COUNT)
- set(CTEST_BUILD_FLAGS "-j${PROCESSOR_COUNT}")
-endif()
-
-set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
-set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
-
-message("Cleaning binary dir '${CTEST_BINARY_DIRECTORY}'")
-ctest_empty_binary_directory("${CTEST_BINARY_DIRECTORY}")
-
-# Intentionally no ctest_update step in this script. This script is run as a
-# "Contract" test on a CMake dashboard submission using the just-built ctest
-# as the driver. The download step in the Contract CMakeLists file takes care
-# of setting up the source tree before calling this ctest -S script. The idea
-# is that the source tree will be the same every day, so there should not be
-# an "update" step for this build.
-
-message("Configuring CSE in binary dir '${CTEST_BINARY_DIRECTORY}'")
-set_property(GLOBAL PROPERTY SubProject "CSE-toplevel")
-set_property(GLOBAL PROPERTY Label "CSE-toplevel")
-
-ctest_start("Experimental")
-
-set(CSE_TOPLEVEL_OPTIONS
- -DEXTERNAL_PROJECT_DASHBOARD_BUILD:BOOL=ON
- -DEXTERNAL_PROJECT_TESTS:BOOL=ON
- -DCSE_INSTALL_PREFIX:PATH=${CTEST_BINARY_DIRECTORY}/built
- -DCSE_SUBSET:STRING=ALL
- -DCTEST_SITE:STRING=${CTEST_SITE}
-)
-
-ctest_configure(OPTIONS "${CSE_TOPLEVEL_OPTIONS}")
-
-# The configure step produces a file listing the CSE packages and dependencies.
-# This file also generates Project.xml and stores it in ${PROJECT_XML}.
-#
-set(subprojects "")
-if(EXISTS "${CTEST_BINARY_DIRECTORY}/CSEBuildtimeDepends.cmake")
- message("Including CSEBuildtimeDepends.cmake")
- include("${CTEST_BINARY_DIRECTORY}/CSEBuildtimeDepends.cmake")
- set(subprojects ${CSE_ALL_SORTED})
- message("Submitting Project.xml")
- ctest_submit(FILES ${PROJECT_XML})
-endif()
-
-message("Submitting CSE configure results")
-ctest_submit()
-
-if(subprojects)
- message("Building by looping over subprojects...")
- foreach(subproject ${subprojects})
- message("########## ${subproject} ##########")
- set_property(GLOBAL PROPERTY SubProject "${subproject}")
- set_property(GLOBAL PROPERTY Label "${subproject}")
- ctest_build(TARGET "${subproject}" APPEND)
- message("Submitting ${subproject} build results")
- ctest_submit(PARTS build)
- endforeach()
-else()
- message("Building all...")
- ctest_build(APPEND)
- message("Submitting build results")
- ctest_submit(PARTS build)
-endif()
diff --git a/Tests/Contracts/cse-snapshot/RunTest.cmake b/Tests/Contracts/cse-snapshot/RunTest.cmake
deleted file mode 100644
index 7eb630116..000000000
--- a/Tests/Contracts/cse-snapshot/RunTest.cmake
+++ /dev/null
@@ -1,3 +0,0 @@
-set(exe "$ENV{HOME}/.cmake/Contracts/cse-snapshot/510345e4/build/built/Release/git-1.6.5.2/bin/git")
-set(args help clone)
-set(cse-snapshot_RUN_TEST ${exe} ${args})
diff --git a/Tests/Cuda/.clang-format b/Tests/Cuda/.clang-format
deleted file mode 100644
index a77589a2d..000000000
--- a/Tests/Cuda/.clang-format
+++ /dev/null
@@ -1,9 +0,0 @@
----
-# This configuration requires clang-format 3.8 or higher.
-BasedOnStyle: Mozilla
-AlignOperands: false
-AlwaysBreakAfterReturnType: None
-AlwaysBreakAfterDefinitionReturnType: None
-ColumnLimit: 79
-Standard: Cpp11
-...
diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt
index de4850158..44c60052f 100644
--- a/Tests/Cuda/CMakeLists.txt
+++ b/Tests/Cuda/CMakeLists.txt
@@ -2,6 +2,10 @@
ADD_TEST_MACRO(Cuda.Complex CudaComplex)
ADD_TEST_MACRO(Cuda.ConsumeCompileFeatures CudaConsumeCompileFeatures)
ADD_TEST_MACRO(Cuda.ObjectLibrary CudaObjectLibrary)
+ADD_TEST_MACRO(Cuda.MixedStandardLevels MixedStandardLevels)
+ADD_TEST_MACRO(Cuda.NotEnabled CudaNotEnabled)
+ADD_TEST_MACRO(Cuda.SeparableCompCXXOnly SeparableCompCXXOnly)
ADD_TEST_MACRO(Cuda.ToolkitInclude CudaToolkitInclude)
+ADD_TEST_MACRO(Cuda.ProperDeviceLibraries ProperDeviceLibraries)
ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags)
ADD_TEST_MACRO(Cuda.WithC CudaWithC)
diff --git a/Tests/Cuda/Complex/CMakeLists.txt b/Tests/Cuda/Complex/CMakeLists.txt
index 450ef487c..d3d4b7c28 100644
--- a/Tests/Cuda/Complex/CMakeLists.txt
+++ b/Tests/Cuda/Complex/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.7)
-project (CudaComplex CXX CUDA)
+project (Complex CXX CUDA)
#Goal for this example:
#build a cpp dynamic library base
@@ -12,7 +12,7 @@ project (CudaComplex CXX CUDA)
#lastly build a cpp executable that uses this last cuda dynamic library
#this tests that we can properly handle linking cuda and cpp together
-#and also bulding cpp targets that need cuda implicit libraries
+#and also building cpp targets that need cuda implicit libraries
#verify that we can pass explicit cuda arch flags
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
@@ -42,7 +42,6 @@ add_executable(CudaComplex main.cpp)
target_link_libraries(CudaComplex PUBLIC CudaComplexMixedLib)
if(APPLE)
- # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
- # the static cuda runtime can find it at runtime.
- target_link_libraries(CudaComplex PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
+ # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+ set_property(TARGET CudaComplex PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif()
diff --git a/Tests/Cuda/Complex/dynamic.cpp b/Tests/Cuda/Complex/dynamic.cpp
index 3848ce7b5..38da6a6a8 100644
--- a/Tests/Cuda/Complex/dynamic.cpp
+++ b/Tests/Cuda/Complex/dynamic.cpp
@@ -1,8 +1,8 @@
#ifdef _WIN32
-#define EXPORT __declspec(dllexport)
+# define EXPORT __declspec(dllexport)
#else
-#define EXPORT
+# define EXPORT
#endif
EXPORT int dynamic_base_func(int x)
diff --git a/Tests/Cuda/Complex/dynamic.cu b/Tests/Cuda/Complex/dynamic.cu
index a76973d62..9da8853ee 100644
--- a/Tests/Cuda/Complex/dynamic.cu
+++ b/Tests/Cuda/Complex/dynamic.cu
@@ -1,12 +1,13 @@
-#include <cuda.h>
#include <iostream>
#include <string>
+#include <cuda.h>
+
#ifdef _WIN32
-#define EXPORT __declspec(dllexport)
+# define EXPORT __declspec(dllexport)
#else
-#define EXPORT
+# define EXPORT
#endif
int dynamic_base_func(int);
diff --git a/Tests/Cuda/Complex/main.cpp b/Tests/Cuda/Complex/main.cpp
index 249823535..6ca5952a5 100644
--- a/Tests/Cuda/Complex/main.cpp
+++ b/Tests/Cuda/Complex/main.cpp
@@ -4,9 +4,9 @@
#include "file2.h"
#ifdef _WIN32
-#define IMPORT __declspec(dllimport)
+# define IMPORT __declspec(dllimport)
#else
-#define IMPORT
+# define IMPORT
#endif
IMPORT int choose_cuda_device();
diff --git a/Tests/Cuda/Complex/mixed.cpp b/Tests/Cuda/Complex/mixed.cpp
index bd32e5199..38a1f0c75 100644
--- a/Tests/Cuda/Complex/mixed.cpp
+++ b/Tests/Cuda/Complex/mixed.cpp
@@ -1,10 +1,10 @@
#ifdef _WIN32
-#define EXPORT __declspec(dllexport)
-#define IMPORT __declspec(dllimport)
+# define EXPORT __declspec(dllexport)
+# define IMPORT __declspec(dllimport)
#else
-#define EXPORT
-#define IMPORT
+# define EXPORT
+# define IMPORT
#endif
int dynamic_base_func(int);
diff --git a/Tests/Cuda/Complex/mixed.cu b/Tests/Cuda/Complex/mixed.cu
index a81ccb731..5b85aecce 100644
--- a/Tests/Cuda/Complex/mixed.cu
+++ b/Tests/Cuda/Complex/mixed.cu
@@ -5,11 +5,11 @@
#include "file2.h"
#ifdef _WIN32
-#define EXPORT __declspec(dllexport)
-#define IMPORT __declspec(dllimport)
+# define EXPORT __declspec(dllexport)
+# define IMPORT __declspec(dllimport)
#else
-#define EXPORT
-#define IMPORT
+# define EXPORT
+# define IMPORT
#endif
result_type __device__ file1_func(int x);
diff --git a/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt b/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt
index 9fda2d02b..7098a7df5 100644
--- a/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt
+++ b/Tests/Cuda/ConsumeCompileFeatures/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.7)
-project (CudaConsumeCompileFeatures CXX CUDA)
+project (ConsumeCompileFeatures CXX CUDA)
#Goal for this example:
#build a c++11 library that express a c++11 public compile feature
diff --git a/Tests/Cuda/MixedStandardLevels/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels/CMakeLists.txt
new file mode 100644
index 000000000..b399662a7
--- /dev/null
+++ b/Tests/Cuda/MixedStandardLevels/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.7)
+project(MixedStandardLevels CXX CUDA)
+
+string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
+
+set(CMAKE_CXX_STANDARD 11)
+
+add_executable(MixedStandardLevels main.cu)
+target_compile_features(MixedStandardLevels PUBLIC cxx_std_11)
+
+if(APPLE)
+ # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+ set_property(TARGET MixedStandardLevels PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
+endif()
diff --git a/Tests/Cuda/MixedStandardLevels/main.cu b/Tests/Cuda/MixedStandardLevels/main.cu
new file mode 100644
index 000000000..d57c05a66
--- /dev/null
+++ b/Tests/Cuda/MixedStandardLevels/main.cu
@@ -0,0 +1,10 @@
+
+#include <type_traits>
+
+int main(int argc, char** argv)
+{
+ // Verify that issue #17519 Setting CXX_STANDARD breaks CUDA_STANDARD
+ // selection via cxx_std_11 has been corrected
+ using returnv = std::integral_constant<int, 0>;
+ return returnv::value;
+}
diff --git a/Tests/Cuda/NotEnabled/CMakeLists.txt b/Tests/Cuda/NotEnabled/CMakeLists.txt
new file mode 100644
index 000000000..968751b65
--- /dev/null
+++ b/Tests/Cuda/NotEnabled/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.7)
+project(CudaNotEnabled CXX)
+
+add_library(HasCudaProps lib.cxx)
+
+target_compile_features(HasCudaProps PUBLIC cxx_std_11)
+#Verify that setting this variables in a project that doesn't have CUDA
+#enabled allow for the project to configure and build correctly.
+#Tests the fix for #19432
+set_property(TARGET HasCudaProps PROPERTY CUDA_SEPARABLE_COMPILATION ON)
+set_property(TARGET HasCudaProps PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON)
+
+add_executable(CudaNotEnabled main.cxx)
+target_link_libraries(CudaNotEnabled PRIVATE HasCudaProps)
diff --git a/Tests/Cuda/NotEnabled/lib.cxx b/Tests/Cuda/NotEnabled/lib.cxx
new file mode 100644
index 000000000..5dae5a3f5
--- /dev/null
+++ b/Tests/Cuda/NotEnabled/lib.cxx
@@ -0,0 +1,5 @@
+
+int cxx_function(int input)
+{
+ return input;
+}
diff --git a/Tests/Cuda/NotEnabled/main.cxx b/Tests/Cuda/NotEnabled/main.cxx
new file mode 100644
index 000000000..a644207a1
--- /dev/null
+++ b/Tests/Cuda/NotEnabled/main.cxx
@@ -0,0 +1,9 @@
+
+#include <type_traits>
+
+int main(int argc, char** argv)
+{
+ // make sure we have c++11 enabled
+ using returnv = std::integral_constant<int, 0>;
+ return returnv::value;
+}
diff --git a/Tests/Cuda/ObjectLibrary/CMakeLists.txt b/Tests/Cuda/ObjectLibrary/CMakeLists.txt
index 1d93be732..395bd3881 100644
--- a/Tests/Cuda/ObjectLibrary/CMakeLists.txt
+++ b/Tests/Cuda/ObjectLibrary/CMakeLists.txt
@@ -1,17 +1,20 @@
cmake_minimum_required(VERSION 3.7)
-project (CudaObjectLibrary CUDA CXX)
+project (ObjectLibrary CUDA CXX)
#Goal for this example:
-
-#build a object files some with cuda and some without than
-#embed these into an executable
+#
+#Build C++ and CUDA object files and than use them to make an executable
+#Make sure that CMake logic to handle object output when multiple files
+#with the same name works
+add_subdirectory(Conflicts)
add_library(CudaMixedObjectLib OBJECT static.cu static.cpp)
add_executable(CudaObjectLibrary
main.cpp
- $<TARGET_OBJECTS:CudaMixedObjectLib>)
+ $<TARGET_OBJECTS:CudaMixedObjectLib>
+ $<TARGET_OBJECTS:CudaConflicts>)
+
if(APPLE)
- # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
- # the static cuda runtime can find it at runtime.
- target_link_libraries(CudaObjectLibrary PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
+ # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+ set_property(TARGET CudaObjectLibrary PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif()
diff --git a/Tests/Cuda/ObjectLibrary/Conflicts/CMakeLists.txt b/Tests/Cuda/ObjectLibrary/Conflicts/CMakeLists.txt
new file mode 100644
index 000000000..1602f8a2a
--- /dev/null
+++ b/Tests/Cuda/ObjectLibrary/Conflicts/CMakeLists.txt
@@ -0,0 +1,2 @@
+
+add_library(CudaConflicts OBJECT static.cu)
diff --git a/Tests/Cuda/ObjectLibrary/Conflicts/static.cu b/Tests/Cuda/ObjectLibrary/Conflicts/static.cu
new file mode 100644
index 000000000..30aa121b7
--- /dev/null
+++ b/Tests/Cuda/ObjectLibrary/Conflicts/static.cu
@@ -0,0 +1,18 @@
+
+#include <iostream>
+
+#include <cuda.h>
+#include <cuda_runtime.h>
+
+int __host__ cu2_sq_func(int x)
+{
+ cudaError_t err;
+ int nDevices = 0;
+ err = cudaGetDeviceCount(&nDevices);
+ if (err != cudaSuccess) {
+ std::cerr << "nDevices: " << nDevices << std::endl;
+ std::cerr << "err: " << err << std::endl;
+ return 1;
+ }
+ return x * x;
+}
diff --git a/Tests/Cuda/ObjectLibrary/main.cpp b/Tests/Cuda/ObjectLibrary/main.cpp
index 4d2f89028..e28f08851 100644
--- a/Tests/Cuda/ObjectLibrary/main.cpp
+++ b/Tests/Cuda/ObjectLibrary/main.cpp
@@ -1,22 +1,18 @@
#include <iostream>
-int static_func(int);
-int file1_sq_func(int);
+int cpp_sq_func(int);
+int cu1_sq_func(int);
+int cu2_sq_func(int);
-int test_functions()
+bool test_functions()
{
- return file1_sq_func(static_func(42));
+ return (cu1_sq_func(42) == cpp_sq_func(42)) &&
+ (cu2_sq_func(42) == cpp_sq_func(42));
}
int main(int argc, char** argv)
{
- if (test_functions() == 1) {
- return 1;
- }
- std::cout
- << "this executable doesn't use cuda code, just call methods defined"
- << std::endl;
- std::cout << "in object files that have cuda code" << std::endl;
- return 0;
+ int result = test_functions() ? 0 : 1;
+ return result;
}
diff --git a/Tests/Cuda/ObjectLibrary/static.cpp b/Tests/Cuda/ObjectLibrary/static.cpp
index 6db1f914f..527f7f554 100644
--- a/Tests/Cuda/ObjectLibrary/static.cpp
+++ b/Tests/Cuda/ObjectLibrary/static.cpp
@@ -1,6 +1,6 @@
int file1_sq_func(int);
-int static_func(int x)
+int cpp_sq_func(int x)
{
- return file1_sq_func(x);
+ return x * x;
}
diff --git a/Tests/Cuda/ObjectLibrary/static.cu b/Tests/Cuda/ObjectLibrary/static.cu
index aa357295a..530a114a5 100644
--- a/Tests/Cuda/ObjectLibrary/static.cu
+++ b/Tests/Cuda/ObjectLibrary/static.cu
@@ -1,9 +1,10 @@
+#include <iostream>
+
#include <cuda.h>
#include <cuda_runtime.h>
-#include <iostream>
-int __host__ file1_sq_func(int x)
+int __host__ cu1_sq_func(int x)
{
cudaError_t err;
int nDevices = 0;
@@ -13,9 +14,5 @@ int __host__ file1_sq_func(int x)
std::cerr << "err: " << err << std::endl;
return 1;
}
- std::cout << "this library uses cuda code" << std::endl;
- std::cout << "you have " << nDevices << " devices that support cuda"
- << std::endl;
-
return x * x;
}
diff --git a/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt
new file mode 100644
index 000000000..cb47b09b4
--- /dev/null
+++ b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.13)
+project(ProperDeviceLibraries CXX CUDA)
+
+string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35")
+set(CMAKE_CUDA_STANDARD 11)
+
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads)
+
+add_executable(ProperDeviceLibraries main.cu)
+set_target_properties(ProperDeviceLibraries
+ PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
+
+add_library(UseThreadsMixed SHARED use_pthreads.cxx use_pthreads.cu)
+target_link_libraries(UseThreadsMixed Threads::Threads)
+
+add_library(UseThreadsCuda SHARED use_pthreads.cu)
+target_link_libraries(UseThreadsCuda Threads::Threads)
+
+target_link_libraries(ProperDeviceLibraries PRIVATE UseThreadsMixed UseThreadsCuda)
+
+if(THREADS_HAVE_PTHREAD_ARG AND CMAKE_USE_PTHREADS_INIT)
+ add_library(UseExplicitPThreadsFlag SHARED use_pthreads.cu)
+ target_compile_options(UseExplicitPThreadsFlag PUBLIC "-Xcompiler=-pthread")
+ target_link_libraries(UseExplicitPThreadsFlag PUBLIC "-pthread")
+
+ add_library(UseExplicitLThreadsFlag SHARED use_pthreads.cu)
+ target_compile_options(UseExplicitLThreadsFlag PUBLIC "-Xcompiler=-pthread")
+ target_link_libraries(UseExplicitLThreadsFlag PUBLIC "-lpthread")
+
+ add_library(UseExplicitLongThreadsFlag SHARED use_pthreads.cu)
+ target_link_libraries(UseExplicitLongThreadsFlag PUBLIC "--library pthread")
+
+ target_link_libraries(ProperDeviceLibraries PRIVATE UseExplicitPThreadsFlag UseExplicitLThreadsFlag UseExplicitLongThreadsFlag)
+endif()
+
+if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10.0.0)
+ #CUDA 10 removed the cublas_device library
+ target_link_libraries(ProperDeviceLibraries PRIVATE cublas_device)
+endif()
+
+if(APPLE)
+ # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+ set_property(TARGET ProperDeviceLibraries PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
+endif()
diff --git a/Tests/Cuda/ProperDeviceLibraries/main.cu b/Tests/Cuda/ProperDeviceLibraries/main.cu
new file mode 100644
index 000000000..397804cf9
--- /dev/null
+++ b/Tests/Cuda/ProperDeviceLibraries/main.cu
@@ -0,0 +1,93 @@
+
+#include <iostream>
+
+#include <cublas_v2.h>
+#include <cuda_runtime.h>
+
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
+
+# include <pthread.h>
+static int verify_linking_to_pthread()
+{
+ return static_cast<int>(pthread_self());
+}
+#endif
+
+// this test only makes sense for versions of CUDA that ships
+// static libraries that have separable compilation device symbols
+#if __CUDACC_VER_MAJOR__ <= 9
+__global__ void deviceCublasSgemm(int n, float alpha, float beta,
+ const float* d_A, const float* d_B,
+ float* d_C)
+{
+ cublasHandle_t cnpHandle;
+ cublasStatus_t status = cublasCreate(&cnpHandle);
+
+ if (status != CUBLAS_STATUS_SUCCESS) {
+ return;
+ }
+
+ // Call function defined in the cublas_device system static library.
+ // This way we can verify that we properly pass system libraries to the
+ // device link line
+ status = cublasSgemm(cnpHandle, CUBLAS_OP_N, CUBLAS_OP_N, n, n, n, &alpha,
+ d_A, n, d_B, n, &beta, d_C, n);
+
+ cublasDestroy(cnpHandle);
+}
+#endif
+
+int choose_cuda_device()
+{
+ int nDevices = 0;
+ cudaError_t err = cudaGetDeviceCount(&nDevices);
+ if (err != cudaSuccess) {
+ std::cerr << "Failed to retrieve the number of CUDA enabled devices"
+ << std::endl;
+ return 1;
+ }
+ for (int i = 0; i < nDevices; ++i) {
+ cudaDeviceProp prop;
+ cudaError_t err = cudaGetDeviceProperties(&prop, i);
+ if (err != cudaSuccess) {
+ std::cerr << "Could not retrieve properties from CUDA device " << i
+ << std::endl;
+ return 1;
+ }
+
+ if (prop.major > 3 || (prop.major == 3 && prop.minor >= 5)) {
+ err = cudaSetDevice(i);
+ if (err != cudaSuccess) {
+ std::cout << "Could not select CUDA device " << i << std::endl;
+ } else {
+ return 0;
+ }
+ }
+ }
+
+ std::cout << "Could not find a CUDA enabled card supporting compute >=3.5"
+ << std::endl;
+ return 1;
+}
+
+int main(int argc, char** argv)
+{
+ int ret = choose_cuda_device();
+ if (ret) {
+ return 0;
+ }
+
+#if __CUDACC_VER_MAJOR__ <= 9
+ // initial values that will make sure that the cublasSgemm won't actually
+ // do any work
+ int n = 0;
+ float alpha = 1;
+ float beta = 1;
+ float* d_A = nullptr;
+ float* d_B = nullptr;
+ float* d_C = nullptr;
+ deviceCublasSgemm<<<1, 1>>>(n, alpha, beta, d_A, d_B, d_C);
+#endif
+
+ return 0;
+}
diff --git a/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cu b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cu
new file mode 100644
index 000000000..c57b8a828
--- /dev/null
+++ b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cu
@@ -0,0 +1,9 @@
+
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
+
+# include <pthread.h>
+static int verify_linking_to_pthread_cuda()
+{
+ return static_cast<int>(pthread_self());
+}
+#endif
diff --git a/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cxx b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cxx
new file mode 100644
index 000000000..dc7c208a4
--- /dev/null
+++ b/Tests/Cuda/ProperDeviceLibraries/use_pthreads.cxx
@@ -0,0 +1,9 @@
+
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
+
+# include <pthread.h>
+static int verify_linking_to_pthread_cxx()
+{
+ return static_cast<int>(pthread_self());
+}
+#endif
diff --git a/Tests/Cuda/SeparableCompCXXOnly/CMakeLists.txt b/Tests/Cuda/SeparableCompCXXOnly/CMakeLists.txt
new file mode 100644
index 000000000..97670e392
--- /dev/null
+++ b/Tests/Cuda/SeparableCompCXXOnly/CMakeLists.txt
@@ -0,0 +1,3 @@
+project(SeparableCompCXXOnly LANGUAGES CXX CUDA)
+set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
+add_executable(SeparableCompCXXOnly main.cpp)
diff --git a/Tests/Cuda/SeparableCompCXXOnly/main.cpp b/Tests/Cuda/SeparableCompCXXOnly/main.cpp
new file mode 100644
index 000000000..813524614
--- /dev/null
+++ b/Tests/Cuda/SeparableCompCXXOnly/main.cpp
@@ -0,0 +1,5 @@
+
+int main(int, char const* [])
+{
+ return 0;
+}
diff --git a/Tests/Cuda/WithC/CMakeLists.txt b/Tests/Cuda/WithC/CMakeLists.txt
index 1f25ab43e..69aa3f992 100644
--- a/Tests/Cuda/WithC/CMakeLists.txt
+++ b/Tests/Cuda/WithC/CMakeLists.txt
@@ -1,12 +1,11 @@
cmake_minimum_required(VERSION 3.7)
-project(CudaComplex CUDA C)
+project(WithC CUDA C)
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
add_executable(CudaWithC main.c cuda.cu)
if(APPLE)
- # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
- # the static cuda runtime can find it at runtime.
- target_link_libraries(CudaWithC PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
+ # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+ set_property(TARGET CudaWithC PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif()
diff --git a/Tests/Cuda/WithC/cuda.cu b/Tests/Cuda/WithC/cuda.cu
index 06bd7b975..d1be2d481 100644
--- a/Tests/Cuda/WithC/cuda.cu
+++ b/Tests/Cuda/WithC/cuda.cu
@@ -1,7 +1,7 @@
-#include <cuda.h>
-
#include <iostream>
+#include <cuda.h>
+
extern "C" int use_cuda(void)
{
int nDevices = 0;
diff --git a/Tests/Cuda/WithC/main.c b/Tests/Cuda/WithC/main.c
index cb5fddc1f..5f3c781b0 100644
--- a/Tests/Cuda/WithC/main.c
+++ b/Tests/Cuda/WithC/main.c
@@ -1,7 +1,7 @@
extern int use_cuda(void);
#ifdef _WIN32
-#include <windows.h>
+# include <windows.h>
#endif
int main()
diff --git a/Tests/CudaOnly/.clang-format b/Tests/CudaOnly/.clang-format
deleted file mode 100644
index a77589a2d..000000000
--- a/Tests/CudaOnly/.clang-format
+++ /dev/null
@@ -1,9 +0,0 @@
----
-# This configuration requires clang-format 3.8 or higher.
-BasedOnStyle: Mozilla
-AlignOperands: false
-AlwaysBreakAfterReturnType: None
-AlwaysBreakAfterDefinitionReturnType: None
-ColumnLimit: 79
-Standard: Cpp11
-...
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt
index 5f456fcf4..f1fd34487 100644
--- a/Tests/CudaOnly/CMakeLists.txt
+++ b/Tests/CudaOnly/CMakeLists.txt
@@ -1,6 +1,23 @@
+ADD_TEST_MACRO(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine)
ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard)
ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX)
+ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag)
+ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols)
ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation)
ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs)
-ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols)
+
+add_test(NAME CudaOnly.DontResolveDeviceSymbols COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMAKE_CURRENT_SOURCE_DIR}/DontResolveDeviceSymbols/"
+ "${CMAKE_CURRENT_BINARY_DIR}/DontResolveDeviceSymbols/"
+ ${build_generator_args}
+ --build-project DontResolveDeviceSymbols
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+if(MSVC)
+ ADD_TEST_MACRO(CudaOnly.PDB CudaOnlyPDB)
+endif()
diff --git a/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt
new file mode 100644
index 000000000..5e6f7abc6
--- /dev/null
+++ b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt
@@ -0,0 +1,34 @@
+cmake_minimum_required(VERSION 3.7)
+project (CircularLinkLine CUDA)
+
+#Goal for this example:
+# Verify that we de-duplicate the device link line
+# Verify that a de-duplicated link line still works with circular static libraries
+
+string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30]")
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CUDA_STANDARD 11)
+
+add_library(CUDACircularDeviceLinking1 STATIC file1.cu)
+add_library(CUDACircularDeviceLinking2 STATIC file2.cu)
+add_library(CUDACircularDeviceLinking3 STATIC file3.cu)
+add_executable(CudaOnlyCircularLinkLine main.cu)
+
+target_link_libraries(CUDACircularDeviceLinking1 PUBLIC CUDACircularDeviceLinking2)
+target_link_libraries(CUDACircularDeviceLinking2 PUBLIC CUDACircularDeviceLinking3)
+target_link_libraries(CUDACircularDeviceLinking3 PUBLIC CUDACircularDeviceLinking1)
+
+target_link_libraries(CudaOnlyCircularLinkLine PRIVATE CUDACircularDeviceLinking3)
+
+
+set_target_properties(CUDACircularDeviceLinking1
+ PROPERTIES
+ CUDA_SEPARABLE_COMPILATION ON)
+
+set_target_properties(CUDACircularDeviceLinking2
+ PROPERTIES
+ CUDA_SEPARABLE_COMPILATION ON)
+
+set_target_properties(CUDACircularDeviceLinking3
+ PROPERTIES
+ CUDA_SEPARABLE_COMPILATION ON)
diff --git a/Tests/CudaOnly/CircularLinkLine/file1.cu b/Tests/CudaOnly/CircularLinkLine/file1.cu
new file mode 100644
index 000000000..88ac4e3cb
--- /dev/null
+++ b/Tests/CudaOnly/CircularLinkLine/file1.cu
@@ -0,0 +1,6 @@
+
+extern __device__ int file2_func(int);
+int __device__ file1_func(int x)
+{
+ return file2_func(x);
+}
diff --git a/Tests/CudaOnly/CircularLinkLine/file2.cu b/Tests/CudaOnly/CircularLinkLine/file2.cu
new file mode 100644
index 000000000..b32dbffe4
--- /dev/null
+++ b/Tests/CudaOnly/CircularLinkLine/file2.cu
@@ -0,0 +1,6 @@
+
+extern __device__ int file3_func(int);
+int __device__ file2_func(int x)
+{
+ return x + file3_func(x);
+}
diff --git a/Tests/CudaOnly/CircularLinkLine/file3.cu b/Tests/CudaOnly/CircularLinkLine/file3.cu
new file mode 100644
index 000000000..7f67187ed
--- /dev/null
+++ b/Tests/CudaOnly/CircularLinkLine/file3.cu
@@ -0,0 +1,8 @@
+
+extern __device__ int file1_func(int);
+int __device__ file3_func(int x)
+{
+ if (x > 0)
+ return file1_func(-x);
+ return x;
+}
diff --git a/Tests/CudaOnly/CircularLinkLine/main.cu b/Tests/CudaOnly/CircularLinkLine/main.cu
new file mode 100644
index 000000000..1c19e8dc3
--- /dev/null
+++ b/Tests/CudaOnly/CircularLinkLine/main.cu
@@ -0,0 +1,5 @@
+
+int main(int argc, char** argv)
+{
+ return 0;
+}
diff --git a/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt
new file mode 100644
index 000000000..6e3697fe5
--- /dev/null
+++ b/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt
@@ -0,0 +1,50 @@
+cmake_minimum_required(VERSION 3.13)
+project (DontResolveDeviceSymbols CUDA)
+
+# Find nm and dumpbin
+if(CMAKE_NM)
+ set(dump_command ${CMAKE_NM})
+ set(dump_args --defined-only)
+ set(symbol_name cudaRegisterLinkedBinary)
+else()
+ include(GetPrerequisites)
+ message(STATUS "calling list_prerequisites to find dumpbin")
+ list_prerequisites("${CMAKE_COMMAND}" 0 0 0)
+ if(gp_dumpbin)
+ set(dump_command ${gp_dumpbin})
+ set(dump_args /SYMBOLS)
+ set(symbol_name nv_fatb)
+ endif()
+endif()
+
+
+#Goal for this example:
+# Build a static library that defines multiple methods and kernels that
+# use each other.
+# Don't resolve the device symbols in the static library
+# Don't resolve the device symbols in the executable library
+# Verify that we can't use those device symbols from anything
+string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30] -gencode arch=compute_50,code=\\\"compute_50\\\"")
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CUDA_STANDARD 11)
+set(CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS OFF)
+
+add_library(CUDANoDeviceResolve SHARED file1.cu)
+set_target_properties(CUDANoDeviceResolve
+ PROPERTIES
+ CUDA_SEPARABLE_COMPILATION ON
+ POSITION_INDEPENDENT_CODE ON)
+if(MSVC)
+ target_link_options(CUDANoDeviceResolve PRIVATE "/FORCE:UNRESOLVED")
+endif()
+
+if(dump_command)
+add_custom_command(TARGET CUDANoDeviceResolve POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ -DDUMP_COMMAND=${dump_command}
+ -DDUMP_ARGS=${dump_args}
+ -DSYMBOL_NAME=${symbol_name}
+ -DTEST_LIBRARY_PATH=$<TARGET_FILE:CUDANoDeviceResolve>
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/verify.cmake
+ )
+endif()
diff --git a/Tests/CudaOnly/DontResolveDeviceSymbols/file1.cu b/Tests/CudaOnly/DontResolveDeviceSymbols/file1.cu
new file mode 100644
index 000000000..3924f67c6
--- /dev/null
+++ b/Tests/CudaOnly/DontResolveDeviceSymbols/file1.cu
@@ -0,0 +1,69 @@
+
+#include <iostream>
+
+static __global__ void file1_kernel(int in, int* out)
+{
+ *out = in * in;
+}
+
+int choose_cuda_device()
+{
+ int nDevices = 0;
+ cudaError_t err = cudaGetDeviceCount(&nDevices);
+ if (err != cudaSuccess) {
+ std::cerr << "Failed to retrieve the number of CUDA enabled devices"
+ << std::endl;
+ return 1;
+ }
+ for (int i = 0; i < nDevices; ++i) {
+ cudaDeviceProp prop;
+ cudaError_t err = cudaGetDeviceProperties(&prop, i);
+ if (err != cudaSuccess) {
+ std::cerr << "Could not retrieve properties from CUDA device " << i
+ << std::endl;
+ return 1;
+ }
+ std::cout << "prop.major: " << prop.major << std::endl;
+ if (prop.major >= 3) {
+ err = cudaSetDevice(i);
+ if (err != cudaSuccess) {
+ std::cout << "Could not select CUDA device " << i << std::endl;
+ } else {
+ return 0;
+ }
+ }
+ }
+
+ std::cout << "Could not find a CUDA enabled card supporting compute >=3.0"
+ << std::endl;
+
+ return 1;
+}
+
+int file1_launch_kernel()
+{
+ int ret = choose_cuda_device();
+ if (ret) {
+ return 0;
+ }
+
+ int input = 4;
+
+ int* output;
+ cudaError_t err = cudaMallocManaged(&output, sizeof(int));
+ cudaDeviceSynchronize();
+ if (err != cudaSuccess) {
+ return 1;
+ }
+
+ file1_kernel<<<1, 1>>>(input, output);
+ cudaDeviceSynchronize();
+ err = cudaGetLastError();
+ std::cout << err << " " << cudaGetErrorString(err) << std::endl;
+ if (err == cudaSuccess) {
+ // This kernel launch should failed as the device linking never occured
+ std::cerr << "file1_kernel: kernel launch should have failed" << std::endl;
+ return 1;
+ }
+ return 0;
+}
diff --git a/Tests/CudaOnly/DontResolveDeviceSymbols/main.cu b/Tests/CudaOnly/DontResolveDeviceSymbols/main.cu
new file mode 100644
index 000000000..84a7a19eb
--- /dev/null
+++ b/Tests/CudaOnly/DontResolveDeviceSymbols/main.cu
@@ -0,0 +1,7 @@
+
+#include <iostream>
+
+int main(int argc, char** argv)
+{
+ return 0;
+}
diff --git a/Tests/CudaOnly/DontResolveDeviceSymbols/verify.cmake b/Tests/CudaOnly/DontResolveDeviceSymbols/verify.cmake
new file mode 100644
index 000000000..9bb426da0
--- /dev/null
+++ b/Tests/CudaOnly/DontResolveDeviceSymbols/verify.cmake
@@ -0,0 +1,14 @@
+execute_process(COMMAND ${DUMP_COMMAND} ${DUMP_ARGS} ${TEST_LIBRARY_PATH}
+ RESULT_VARIABLE RESULT
+ OUTPUT_VARIABLE OUTPUT
+ ERROR_VARIABLE ERROR
+)
+
+if(NOT "${RESULT}" STREQUAL "0")
+ message(FATAL_ERROR "${DUMP_COMMAND} failed [${RESULT}] [${OUTPUT}] [${ERROR}]")
+endif()
+
+if("${OUTPUT}" MATCHES "${SYMBOL_NAME}")
+ message(FATAL_ERROR
+ "The '${SYMBOL_NAME}' symbol is defined; device linking occurred!")
+endif()
diff --git a/Tests/CudaOnly/EnableStandard/CMakeLists.txt b/Tests/CudaOnly/EnableStandard/CMakeLists.txt
index 35a1deb69..54e2c1413 100644
--- a/Tests/CudaOnly/EnableStandard/CMakeLists.txt
+++ b/Tests/CudaOnly/EnableStandard/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.7)
-project (CudaOnlyEnableStandard CUDA)
+project (EnableStandard CUDA)
#Goal for this example:
#build cuda sources that require C++11 to be enabled.
diff --git a/Tests/CudaOnly/EnableStandard/main.cu b/Tests/CudaOnly/EnableStandard/main.cu
index f21958371..740c832a6 100644
--- a/Tests/CudaOnly/EnableStandard/main.cu
+++ b/Tests/CudaOnly/EnableStandard/main.cu
@@ -2,9 +2,9 @@
#include <iostream>
#ifdef _WIN32
-#define IMPORT __declspec(dllimport)
+# define IMPORT __declspec(dllimport)
#else
-#define IMPORT
+# define IMPORT
#endif
int static_cuda11_func(int);
diff --git a/Tests/CudaOnly/EnableStandard/shared.cu b/Tests/CudaOnly/EnableStandard/shared.cu
index ccdd0b28e..004cb8372 100644
--- a/Tests/CudaOnly/EnableStandard/shared.cu
+++ b/Tests/CudaOnly/EnableStandard/shared.cu
@@ -2,9 +2,9 @@
#include <type_traits>
#ifdef _WIN32
-#define EXPORT __declspec(dllexport)
+# define EXPORT __declspec(dllexport)
#else
-#define EXPORT
+# define EXPORT
#endif
using tt = std::true_type;
diff --git a/Tests/CudaOnly/ExportPTX/CMakeLists.txt b/Tests/CudaOnly/ExportPTX/CMakeLists.txt
index 10249c614..ff6e77c33 100644
--- a/Tests/CudaOnly/ExportPTX/CMakeLists.txt
+++ b/Tests/CudaOnly/ExportPTX/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.8)
-project (CudaOnlyExportPTX CUDA)
+project (ExportPTX CUDA)
#Goal for this example:
# How to generate PTX files instead of OBJECT files
@@ -67,9 +67,8 @@ target_compile_definitions(CudaOnlyExportPTX PRIVATE
"CONFIG_TYPE=gen_$<LOWER_CASE:$<CONFIG>>")
if(APPLE)
- # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
- # the static cuda runtime can find it at runtime.
- target_link_libraries(CudaOnlyExportPTX PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
+ # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+ set_property(TARGET CudaOnlyExportPTX PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif()
#Verify that we can install object targets properly
diff --git a/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt b/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt
new file mode 100644
index 000000000..fbef15f9e
--- /dev/null
+++ b/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+cmake_minimum_required(VERSION 3.7)
+project (GPUDebugFlag CUDA)
+
+#Goal for this example:
+#verify that -G enables gpu debug flags
+string(APPEND CMAKE_CUDA_FLAGS " -gencode=arch=compute_30,code=compute_30")
+string(APPEND CMAKE_CUDA_FLAGS " -G")
+set(CMAKE_CUDA_STANDARD 11)
+
+add_executable(CudaOnlyGPUDebugFlag main.cu)
+
+if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0.0)
+ #CUDA's __CUDACC_DEBUG__ define was added in 9.0
+ #so if we are below 9.0.0 we will manually add the define so that the test
+ #passes
+ target_compile_definitions(CudaOnlyGPUDebugFlag PRIVATE "__CUDACC_DEBUG__")
+endif()
+
+if(APPLE)
+ # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+ set_property(TARGET CudaOnlyGPUDebugFlag PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
+endif()
diff --git a/Tests/CudaOnly/GPUDebugFlag/main.cu b/Tests/CudaOnly/GPUDebugFlag/main.cu
new file mode 100644
index 000000000..ced378912
--- /dev/null
+++ b/Tests/CudaOnly/GPUDebugFlag/main.cu
@@ -0,0 +1,72 @@
+#include <iostream>
+
+#include <cuda.h>
+#include <cuda_runtime.h>
+
+static __global__ void debug_kernel(bool* has_debug)
+{
+// Verify using the return code if we have GPU debug flag enabled
+#if defined(__CUDACC__) && defined(__CUDACC_DEBUG__)
+ *has_debug = true;
+#else
+ *has_debug = false;
+#endif
+}
+
+int choose_cuda_device()
+{
+ int nDevices = 0;
+ cudaError_t err = cudaGetDeviceCount(&nDevices);
+ if (err != cudaSuccess) {
+ std::cerr << "Failed to retrieve the number of CUDA enabled devices"
+ << std::endl;
+ return 1;
+ }
+ for (int i = 0; i < nDevices; ++i) {
+ cudaDeviceProp prop;
+ cudaError_t err = cudaGetDeviceProperties(&prop, i);
+ if (err != cudaSuccess) {
+ std::cerr << "Could not retrieve properties from CUDA device " << i
+ << std::endl;
+ return 1;
+ }
+ if (prop.major >= 3) {
+ err = cudaSetDevice(i);
+ if (err != cudaSuccess) {
+ std::cout << "Could not select CUDA device " << i << std::endl;
+ } else {
+ return 0;
+ }
+ }
+ }
+
+ std::cout << "Could not find a CUDA enabled card supporting compute >=3.0"
+ << std::endl;
+
+ return 1;
+}
+
+int main(int argc, char** argv)
+{
+ bool* has_debug;
+ cudaError_t err = cudaMallocManaged(&has_debug, sizeof(bool));
+ if (err != cudaSuccess) {
+ std::cerr << "cudaMallocManaged failed:\n"
+ << " " << cudaGetErrorString(err) << std::endl;
+ return 1;
+ }
+
+ debug_kernel<<<1, 1>>>(has_debug);
+ err = cudaDeviceSynchronize();
+ if (err != cudaSuccess) {
+ std::cerr << "debug_kernel: kernel launch shouldn't have failed\n"
+ << "reason:\t" << cudaGetErrorString(err) << std::endl;
+ return 1;
+ }
+ if (*has_debug == false) {
+ std::cerr << "debug_kernel: kernel not compiled with device debug"
+ << std::endl;
+ return 1;
+ }
+ return 0;
+}
diff --git a/Tests/CudaOnly/PDB/CMakeLists.txt b/Tests/CudaOnly/PDB/CMakeLists.txt
new file mode 100644
index 000000000..6ecf98935
--- /dev/null
+++ b/Tests/CudaOnly/PDB/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 3.11)
+project (PDB CUDA)
+
+add_executable(CudaOnlyPDB main.cu)
+set_target_properties(CudaOnlyPDB PROPERTIES
+ PDB_NAME LinkPDBName
+ PDB_OUTPUT_DIRECTORY LinkPDBDir
+ COMPILE_PDB_NAME CompPDBName
+ COMPILE_PDB_OUTPUT_DIRECTORY CompPDBDir
+ )
+
+set(pdbs
+ ${CMAKE_CURRENT_BINARY_DIR}/CompPDBDir/${CMAKE_CFG_INTDIR}/CompPDBName.pdb
+ ${CMAKE_CURRENT_BINARY_DIR}/LinkPDBDir/${CMAKE_CFG_INTDIR}/LinkPDBName.pdb
+ )
+add_custom_command(TARGET CudaOnlyPDB POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -Dconfig=$<CONFIG> "-Dpdbs=${pdbs}"
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/check_pdbs.cmake
+ )
diff --git a/Tests/CudaOnly/PDB/check_pdbs.cmake b/Tests/CudaOnly/PDB/check_pdbs.cmake
new file mode 100644
index 000000000..5e01ca722
--- /dev/null
+++ b/Tests/CudaOnly/PDB/check_pdbs.cmake
@@ -0,0 +1,10 @@
+if(NOT "${config}" MATCHES "[Dd][Ee][Bb]")
+ return()
+endif()
+foreach(pdb ${pdbs})
+ if(EXISTS "${pdb}")
+ message(STATUS "PDB Exists: ${pdb}")
+ else()
+ message(SEND_ERROR "PDB MISSING:\n ${pdb}")
+ endif()
+endforeach()
diff --git a/Tests/CudaOnly/PDB/main.cu b/Tests/CudaOnly/PDB/main.cu
new file mode 100644
index 000000000..f8b643afb
--- /dev/null
+++ b/Tests/CudaOnly/PDB/main.cu
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt
index b96bb984b..64845c5ce 100644
--- a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt
+++ b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.7)
-project (CudaOnlyResolveDeviceSymbols CUDA)
+project (ResolveDeviceSymbols CUDA)
# Find nm and dumpbin
if(CMAKE_NM)
@@ -16,21 +16,29 @@ else()
endif()
#Goal for this example:
-#Build a static library that defines multiple methods and kernels that
-#use each other.
-#Use a custom command to build an executable that uses this static library
-#We do these together to verify that we can get a static library to do
-#device symbol linking, and not have it done when the executable is made
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
+# 1. Build two static libraries that defines multiple methods and kernels
+# 2. Resolve the device symbols into the second static library, therefore
+# confirming that the first static library is on the device link line
+# 3. Verify that we can't use those device symbols from anything that links
+# to the static library
+string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[sm_30] -gencode arch=compute_50,code=\\\"compute_50\\\"")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CUDA_STANDARD 11)
-add_library(CUDAResolveDeviceLib STATIC file1.cu file2.cu)
+add_library(CUDAResolveDeviceDepsA STATIC file1.cu)
+add_library(CUDAResolveDeviceDepsB STATIC file2.cu)
+set_target_properties(CUDAResolveDeviceDepsA CUDAResolveDeviceDepsB
+ PROPERTIES
+ CUDA_SEPARABLE_COMPILATION ON
+ POSITION_INDEPENDENT_CODE ON)
+
+add_library(CUDAResolveDeviceLib STATIC file2_launch.cu)
set_target_properties(CUDAResolveDeviceLib
PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
CUDA_RESOLVE_DEVICE_SYMBOLS ON
POSITION_INDEPENDENT_CODE ON)
+target_link_libraries(CUDAResolveDeviceLib PRIVATE CUDAResolveDeviceDepsA CUDAResolveDeviceDepsB)
if(dump_command)
add_custom_command(TARGET CUDAResolveDeviceLib POST_BUILD
@@ -43,10 +51,14 @@ add_custom_command(TARGET CUDAResolveDeviceLib POST_BUILD
endif()
add_executable(CudaOnlyResolveDeviceSymbols main.cu)
+set_target_properties(CudaOnlyResolveDeviceSymbols
+ PROPERTIES
+ CUDA_SEPARABLE_COMPILATION OFF
+ CUDA_RESOLVE_DEVICE_SYMBOLS OFF)
+
target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE CUDAResolveDeviceLib)
if(APPLE)
- # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
- # the static cuda runtime can find it at runtime.
- target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
+ # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+ set_property(TARGET CudaOnlyResolveDeviceSymbols PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif()
diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/file1.h b/Tests/CudaOnly/ResolveDeviceSymbols/file1.h
index ff1945c0a..b33bcaef3 100644
--- a/Tests/CudaOnly/ResolveDeviceSymbols/file1.h
+++ b/Tests/CudaOnly/ResolveDeviceSymbols/file1.h
@@ -1,7 +1,10 @@
#pragma once
+
struct result_type
{
int input;
int sum;
};
+
+result_type __device__ file1_func(int x);
diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/file2.cu b/Tests/CudaOnly/ResolveDeviceSymbols/file2.cu
index 278fd6cce..0e5e7aa49 100644
--- a/Tests/CudaOnly/ResolveDeviceSymbols/file2.cu
+++ b/Tests/CudaOnly/ResolveDeviceSymbols/file2.cu
@@ -1,25 +1,9 @@
#include "file2.h"
-result_type __device__ file1_func(int x);
-
result_type_dynamic __device__ file2_func(int x)
{
const result_type r = file1_func(x);
const result_type_dynamic rd{ r.input, r.sum, true };
return rd;
}
-
-static __global__ void file2_kernel(result_type_dynamic& r, int x)
-{
- // call static_func which is a method that is defined in the
- // static library that is always out of date
- r = file2_func(x);
-}
-
-int file2_launch_kernel(int x)
-{
- result_type_dynamic r;
- file2_kernel<<<1, 1>>>(r, x);
- return r.sum;
-}
diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/file2.h b/Tests/CudaOnly/ResolveDeviceSymbols/file2.h
index d2dbaa4de..c6e287510 100644
--- a/Tests/CudaOnly/ResolveDeviceSymbols/file2.h
+++ b/Tests/CudaOnly/ResolveDeviceSymbols/file2.h
@@ -8,3 +8,5 @@ struct result_type_dynamic
int sum;
bool from_static;
};
+
+result_type_dynamic __device__ file2_func(int x);
diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/file2_launch.cu b/Tests/CudaOnly/ResolveDeviceSymbols/file2_launch.cu
new file mode 100644
index 000000000..4e8da1371
--- /dev/null
+++ b/Tests/CudaOnly/ResolveDeviceSymbols/file2_launch.cu
@@ -0,0 +1,18 @@
+
+#include "file2.h"
+
+static __global__ void file2_kernel(result_type_dynamic& r, int x)
+{
+ // call static_func which is a method that is defined in the
+ // static library that is always out of date
+ r = file2_func(x);
+}
+
+static __global__ void file2_kernel(result_type_dynamic& r, int x);
+
+int file2_launch_kernel(int x)
+{
+ result_type_dynamic r;
+ file2_kernel<<<1, 1>>>(r, x);
+ return r.sum;
+}
diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/main.cu b/Tests/CudaOnly/ResolveDeviceSymbols/main.cu
index b4b5b9eac..ea842cc16 100644
--- a/Tests/CudaOnly/ResolveDeviceSymbols/main.cu
+++ b/Tests/CudaOnly/ResolveDeviceSymbols/main.cu
@@ -1,26 +1,10 @@
#include <iostream>
-#include "file1.h"
#include "file2.h"
int file2_launch_kernel(int x);
-result_type_dynamic __device__ file2_func(int x);
-static __global__ void main_kernel(result_type_dynamic& r, int x)
-{
- // call function that was not device linked to us, this will cause
- // a runtime failure of "invalid device function"
- r = file2_func(x);
-}
-
-int main_launch_kernel(int x)
-{
- result_type_dynamic r;
- main_kernel<<<1, 1>>>(r, x);
- return r.sum;
-}
-
int choose_cuda_device()
{
int nDevices = 0;
@@ -62,21 +46,10 @@ int main(int argc, char** argv)
return 0;
}
- cudaError_t err;
- file2_launch_kernel(42);
- err = cudaGetLastError();
+ file2_launch_kernel(1);
+ cudaError_t err = cudaGetLastError();
if (err != cudaSuccess) {
- std::cerr << "file2_launch_kernel: kernel launch failed: "
- << cudaGetErrorString(err) << std::endl;
- return 1;
- }
-
- main_launch_kernel(1);
- err = cudaGetLastError();
- if (err == cudaSuccess) {
- // This kernel launch should fail as the file2_func was device linked
- // into the static library and is not usable by the executable
- std::cerr << "main_launch_kernel: kernel launch should have failed"
+ std::cerr << "file2_launch_kernel: kernel launch should have passed"
<< std::endl;
return 1;
}
diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt
index 3d4a17073..1e574d6cc 100644
--- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt
+++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.7)
-project (CudaOnlySeparateCompilation CUDA)
+project (SeparateCompilation CUDA)
#Goal for this example:
#Build a static library that defines multiple methods and kernels that
@@ -9,11 +9,18 @@ project (CudaOnlySeparateCompilation CUDA)
#and executables.
#We complicate the matter by also testing that multiple static libraries
#all containing cuda separable compilation code links properly
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
+string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=\\\"compute_30,sm_30,sm_35\\\"")
+string(APPEND CMAKE_CUDA_FLAGS " --generate-code=arch=compute_50,code=[compute_50,sm_50,sm_52]")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CUDA_STANDARD 11)
+set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
add_library(CUDASeparateLibA STATIC file1.cu file2.cu file3.cu)
+get_property(sep_comp TARGET CUDASeparateLibA PROPERTY CUDA_SEPARABLE_COMPILATION)
+if(NOT sep_comp)
+ message(FATAL_ERROR "CUDA_SEPARABLE_COMPILATION not initialized")
+endif()
+unset(CMAKE_CUDA_SEPARABLE_COMPILATION)
if(CMAKE_CUDA_SIMULATE_ID STREQUAL "MSVC")
# Test adding a flag that is not in our CUDA flag table for VS.
@@ -48,8 +55,7 @@ if (CMAKE_GENERATOR MATCHES "^Visual Studio")
PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
endif()
-if (APPLE)
- # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
- # the static cuda runtime can find it at runtime.
- target_link_libraries(CudaOnlySeparateCompilation PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
+if(APPLE)
+ # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+ set_property(TARGET CudaOnlySeparateCompilation PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif()
diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt
index e25f141ea..00fd7d24c 100644
--- a/Tests/CudaOnly/WithDefs/CMakeLists.txt
+++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt
@@ -1,10 +1,14 @@
cmake_minimum_required(VERSION 3.7)
-project (CudaOnlyWithDefs CUDA)
+project (WithDefs CUDA)
#verify that we can pass explicit cuda arch flags
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
-set(debug_compile_flags --generate-code arch=compute_20,code=sm_20)
+if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 9)
+ set(debug_compile_flags --generate-code arch=compute_32,code=sm_32)
+else()
+ set(debug_compile_flags --generate-code arch=compute_20,code=sm_20)
+endif()
if(CMAKE_CUDA_SIMULATE_ID STREQUAL "MSVC")
list(APPEND debug_compile_flags -Xcompiler=-WX)
else()
@@ -17,17 +21,13 @@ set(release_compile_defs DEFREL)
#this verifies we can pass things such as '_','(' to nvcc
add_definitions("-DPACKED_DEFINE=__attribute__((packed))")
-if(CMAKE_GENERATOR MATCHES "Visual Studio")
- # CUDA MSBuild rules do not pass '-x cu' to nvcc
- set(main main_for_vs.cu)
-else()
- set(main main.notcu)
- set_source_files_properties(main.notcu PROPERTIES LANGUAGE CUDA)
-endif()
-add_executable(CudaOnlyWithDefs ${main})
+add_executable(CudaOnlyWithDefs main.notcu)
+set_source_files_properties(main.notcu PROPERTIES LANGUAGE CUDA)
target_compile_options(CudaOnlyWithDefs
PRIVATE
+ -DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE>
+ -DFLAG_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
-Xcompiler=-DHOST_DEFINE
$<$<CONFIG:DEBUG>:$<BUILD_INTERFACE:${debug_compile_flags}>>
)
@@ -35,10 +35,18 @@ target_compile_options(CudaOnlyWithDefs
target_compile_definitions(CudaOnlyWithDefs
PRIVATE
$<$<CONFIG:RELEASE>:$<BUILD_INTERFACE:${release_compile_defs}>>
+ -DDEF_COMPILE_LANG_$<COMPILE_LANGUAGE>
+ -DDEF_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
+ -DDEF_CUDA_COMPILER=$<CUDA_COMPILER_ID>
+ -DDEF_CUDA_COMPILER_VERSION=$<CUDA_COMPILER_VERSION>
)
-#we need to add an rpath for the cuda library so that everything
-#loads properly on the mac
-if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
- set_target_properties(CudaOnlyWithDefs PROPERTIES LINK_FLAGS "-Wl,-rpath,${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}")
+target_include_directories(CudaOnlyWithDefs
+ PRIVATE
+ $<$<COMPILE_LANGUAGE:CUDA>:${CMAKE_CURRENT_SOURCE_DIR}/inc_cuda>
+)
+
+if(APPLE)
+ # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+ set_property(TARGET CudaOnlyWithDefs PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif()
diff --git a/Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h b/Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h
new file mode 100644
index 000000000..e228b5867
--- /dev/null
+++ b/Tests/CudaOnly/WithDefs/inc_cuda/inc_cuda.h
@@ -0,0 +1 @@
+#define INC_CUDA
diff --git a/Tests/CudaOnly/WithDefs/main.notcu b/Tests/CudaOnly/WithDefs/main.notcu
index d2eff3f4b..a5f4ed652 100644
--- a/Tests/CudaOnly/WithDefs/main.notcu
+++ b/Tests/CudaOnly/WithDefs/main.notcu
@@ -1,13 +1,50 @@
+#include <iostream>
+
#include <cuda.h>
#include <cuda_runtime.h>
-#include <iostream>
+#include <inc_cuda.h>
+#ifndef INC_CUDA
+# error "INC_CUDA not defined!"
+#endif
#ifndef HOST_DEFINE
-#error "HOST_DEFINE not defined!"
+# error "HOST_DEFINE not defined!"
#endif
#ifndef PACKED_DEFINE
-#error "PACKED_DEFINE not defined!"
+# error "PACKED_DEFINE not defined!"
+#endif
+
+#ifndef FLAG_COMPILE_LANG_CUDA
+# error "FLAG_COMPILE_LANG_CUDA not defined!"
+#endif
+
+#ifndef FLAG_LANG_IS_CUDA
+# error "FLAG_LANG_IS_CUDA not defined!"
+#endif
+
+#if !FLAG_LANG_IS_CUDA
+# error "Expected FLAG_LANG_IS_CUDA"
+#endif
+
+#ifndef DEF_COMPILE_LANG_CUDA
+# error "DEF_COMPILE_LANG_CUDA not defined!"
+#endif
+
+#ifndef DEF_LANG_IS_CUDA
+# error "DEF_LANG_IS_CUDA not defined!"
+#endif
+
+#if !DEF_LANG_IS_CUDA
+# error "Expected DEF_LANG_IS_CUDA"
+#endif
+
+#ifndef DEF_CUDA_COMPILER
+# error "DEF_CUDA_COMPILER not defined!"
+#endif
+
+#ifndef DEF_CUDA_COMPILER_VERSION
+# error "DEF_CUDA_COMPILER_VERSION not defined!"
#endif
static __global__ void DetermineIfValidCudaDevice()
@@ -15,20 +52,20 @@ static __global__ void DetermineIfValidCudaDevice()
}
#ifdef _MSC_VER
-#pragma pack(push, 1)
-#undef PACKED_DEFINE
-#define PACKED_DEFINE
+# pragma pack(push, 1)
+# undef PACKED_DEFINE
+# define PACKED_DEFINE
#endif
struct PACKED_DEFINE result_type
{
bool valid;
int value;
#if defined(NDEBUG) && !defined(DEFREL)
-#error missing DEFREL flag
+# error missing DEFREL flag
#endif
};
#ifdef _MSC_VER
-#pragma pack(pop)
+# pragma pack(pop)
#endif
result_type can_launch_kernel()
diff --git a/Tests/CudaOnly/WithDefs/main_for_vs.cu b/Tests/CudaOnly/WithDefs/main_for_vs.cu
deleted file mode 100644
index 56078e7af..000000000
--- a/Tests/CudaOnly/WithDefs/main_for_vs.cu
+++ /dev/null
@@ -1 +0,0 @@
-#include "main.notcu"
diff --git a/Tests/CustComDepend/bar.h b/Tests/CustComDepend/bar.h
index c072b81a9..b0a690b57 100644
--- a/Tests/CustComDepend/bar.h
+++ b/Tests/CustComDepend/bar.h
@@ -1,9 +1,9 @@
#ifdef _WIN32
-#ifdef bar_EXPORTS
-#define BAR_EXPORT __declspec(dllexport)
+# ifdef bar_EXPORTS
+# define BAR_EXPORT __declspec(dllexport)
+# else
+# define BAR_EXPORT __declspec(dllimport)
+# endif
#else
-#define BAR_EXPORT __declspec(dllimport)
-#endif
-#else
-#define BAR_EXPORT
+# define BAR_EXPORT
#endif
diff --git a/Tests/CustomCommand/wrapper.cxx b/Tests/CustomCommand/wrapper.cxx
index c38093816..33412f8b6 100644
--- a/Tests/CustomCommand/wrapper.cxx
+++ b/Tests/CustomCommand/wrapper.cxx
@@ -17,9 +17,10 @@ int main(int argc, char* argv[])
#ifdef CMAKE_INTDIR
const char* cfg = (argc >= 4) ? argv[3] : "";
if (strcmp(cfg, CMAKE_INTDIR) != 0) {
- fprintf(stderr, "Did not receive expected configuration argument:\n"
- " expected [" CMAKE_INTDIR "]\n"
- " received [%s]\n",
+ fprintf(stderr,
+ "Did not receive expected configuration argument:\n"
+ " expected [" CMAKE_INTDIR "]\n"
+ " received [%s]\n",
cfg);
return 1;
}
diff --git a/Tests/CustomCommandByproducts/CMakeLists.txt b/Tests/CustomCommandByproducts/CMakeLists.txt
index 3289e8f9f..08c897c2d 100644
--- a/Tests/CustomCommandByproducts/CMakeLists.txt
+++ b/Tests/CustomCommandByproducts/CMakeLists.txt
@@ -1,4 +1,5 @@
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.9)
+cmake_policy(SET CMP0058 OLD)
project(CustomCommandByproducts C)
# Generate a byproduct in a rule that runs in the target consuming it.
@@ -13,20 +14,21 @@ add_custom_command(
# Generate a byproduct in a rule that runs in a dependency of the consumer.
add_custom_command(
- OUTPUT timestamp2.txt
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/timestamp2.txt
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/byproduct2.c.in byproduct2.c
- BYPRODUCTS byproduct2.c
+ BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/byproduct2.c
COMMAND ${CMAKE_COMMAND} -E touch timestamp2.txt
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct2.c.in
)
-add_custom_target(Producer2 DEPENDS timestamp2.txt)
+add_custom_target(Producer2 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/timestamp2.txt)
# Generate a byproduct in a custom target.
add_custom_target(Producer3_4
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/byproduct3.c.in byproduct3.c
- BYPRODUCTS byproduct3.c
+ BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/byproduct3.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct3.c.in
)
# Generate a byproduct in a custom target POST_BUILD command.
@@ -34,33 +36,37 @@ add_custom_command(
TARGET Producer3_4 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/byproduct4.c.in byproduct4.c
- BYPRODUCTS byproduct4.c
+ BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/byproduct4.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct4.c.in
)
-add_executable(ProducerExe ProducerExe.c)
+add_executable(ProducerExe5_6_7 ProducerExe.c)
# Generate a byproduct in an executable POST_BUILD command.
add_custom_command(
- TARGET ProducerExe POST_BUILD
+ TARGET ProducerExe5_6_7 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/byproduct5.c.in byproduct5.c
BYPRODUCTS byproduct5.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct5.c.in
)
# Generate a byproduct in an executable PRE_LINK command.
add_custom_command(
- TARGET ProducerExe PRE_LINK
+ TARGET ProducerExe5_6_7 PRE_LINK
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/byproduct6.c.in byproduct6.c
BYPRODUCTS byproduct6.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct6.c.in
)
# Generate a byproduct in an executable PRE_BUILD command.
add_custom_command(
- TARGET ProducerExe PRE_BUILD
+ TARGET ProducerExe5_6_7 PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/byproduct7.c.in byproduct7.c
BYPRODUCTS byproduct7.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct7.c.in
)
# Generate a byproduct in a custom command that consumes other byproducts.
@@ -79,9 +85,29 @@ add_custom_command(OUTPUT timestamp8.txt
${CMAKE_CURRENT_SOURCE_DIR}/byproduct8.c.in
)
+add_executable(ProducerExe9 ProducerExe.c)
+
+# Generate a byproduct in a custom target which depends on a byproduct of a
+# POST_BUILD command (test if dependency of custom target Producer9 to
+# ProducerExe9 is added).
+add_custom_command(
+ TARGET ProducerExe9 POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${CMAKE_CURRENT_SOURCE_DIR}/byproduct9.c.in byproduct9a.c
+ BYPRODUCTS byproduct9a.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct9.c.in
+ )
+add_custom_target(Producer9
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ byproduct9a.c byproduct9.c
+ BYPRODUCTS byproduct9.c
+ DEPENDS byproduct9a.c
+ )
+
# Generate the library file of an imported target as a byproduct
# of an external project.
-if(CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
set(cfg /${CMAKE_CFG_INTDIR})
else()
set(cfg)
@@ -105,7 +131,7 @@ add_dependencies(ExternalLibrary ExternalTarget)
# Generate the library file of an imported target as a byproduct
# of an external project. The byproduct uses <BINARY_DIR> that is substituted
# by the real binary path
-if(CMAKE_CONFIGURATION_TYPES)
+if(_isMultiConfig)
set(cfg /${CMAKE_CFG_INTDIR})
else()
set(cfg)
@@ -134,10 +160,13 @@ add_executable(CustomCommandByproducts
byproduct6.c
byproduct7.c
byproduct8.c timestamp8.txt
+ byproduct9.c
)
+
+# Dependencies to byproducts of custom commands other than build events are not
+# yet traced (see issue #19005).
add_dependencies(CustomCommandByproducts Producer2)
-add_dependencies(CustomCommandByproducts Producer3_4)
-add_dependencies(CustomCommandByproducts ProducerExe)
+
target_link_libraries(CustomCommandByproducts ExternalLibrary)
if(CMAKE_GENERATOR STREQUAL "Ninja")
diff --git a/Tests/CustomCommandByproducts/CustomCommandByproducts.c b/Tests/CustomCommandByproducts/CustomCommandByproducts.c
index 02ad7ea0b..0658d0518 100644
--- a/Tests/CustomCommandByproducts/CustomCommandByproducts.c
+++ b/Tests/CustomCommandByproducts/CustomCommandByproducts.c
@@ -6,10 +6,11 @@ extern int byproduct5(void);
extern int byproduct6(void);
extern int byproduct7(void);
extern int byproduct8(void);
+extern int byproduct9(void);
extern int ExternalLibrary(void);
int main(void)
{
return (byproduct1() + byproduct2() + byproduct3() + byproduct4() +
byproduct5() + byproduct6() + byproduct7() + byproduct8() +
- ExternalLibrary() + 0);
+ byproduct9() + ExternalLibrary() + 0);
}
diff --git a/Tests/CustomCommandByproducts/byproduct9.c.in b/Tests/CustomCommandByproducts/byproduct9.c.in
new file mode 100644
index 000000000..11eed2c4c
--- /dev/null
+++ b/Tests/CustomCommandByproducts/byproduct9.c.in
@@ -0,0 +1 @@
+int byproduct9(void) { return 0; }
diff --git a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt
index 4975feb2d..3bab1fec0 100644
--- a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt
+++ b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt
@@ -9,17 +9,17 @@ add_custom_command(
)
set_source_files_properties(
- "${TestWorkingDir_BINARY_DIR}/customTarget.c"
+ "${TestWorkingDir_BINARY_DIR}/customTarget1.c"
"${TestWorkingDir_BINARY_DIR}/customTarget2.c"
PROPERTIES GENERATED 1)
add_executable(working "${TestWorkingDir_BINARY_DIR}/working.c"
- "${TestWorkingDir_BINARY_DIR}/customTarget.c")
+ "${TestWorkingDir_BINARY_DIR}/customTarget1.c")
add_custom_target(
Custom ALL
- COMMAND "${CMAKE_COMMAND}" -E copy_if_different ./customTarget.c "${TestWorkingDir_BINARY_DIR}/customTarget.c"
- BYPRODUCTS "${TestWorkingDir_BINARY_DIR}/customTarget.c"
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different ./customTarget.c "${TestWorkingDir_BINARY_DIR}/customTarget1.c"
+ BYPRODUCTS "${TestWorkingDir_BINARY_DIR}/customTarget1.c"
WORKING_DIRECTORY "${TestWorkingDir_SOURCE_DIR}"
)
@@ -42,3 +42,23 @@ add_custom_target(
)
add_dependencies(working2 Custom2)
+
+file(MAKE_DIRECTORY ${TestWorkingDir_BINARY_DIR}/genex)
+add_custom_command(
+ OUTPUT "${TestWorkingDir_BINARY_DIR}/genex/working.c"
+ COMMAND "${CMAKE_COMMAND}" -E copy "${TestWorkingDir_SOURCE_DIR}/working.c.in" "${TestWorkingDir_BINARY_DIR}/genex/working.c"
+ WORKING_DIRECTORY "$<0:not_used/>${TestWorkingDir_BINARY_DIR}/$<1:genex>/"
+ COMMENT "custom command"
+)
+
+add_executable(workinggenex "${TestWorkingDir_BINARY_DIR}/genex/working.c"
+ "${TestWorkingDir_BINARY_DIR}/genex/customTarget.c")
+
+add_custom_target(
+ CustomGenex ALL
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${TestWorkingDir_SOURCE_DIR}/customTarget.c" "${TestWorkingDir_BINARY_DIR}/genex/customTarget.c"
+ BYPRODUCTS "${TestWorkingDir_BINARY_DIR}/genex/customTarget.c"
+ WORKING_DIRECTORY "$<0:not_used/>${TestWorkingDir_BINARY_DIR}/$<1:genex>/"
+)
+
+add_dependencies(workinggenex CustomGenex)
diff --git a/Tests/CxxOnly/libcxx2.h b/Tests/CxxOnly/libcxx2.h
index 1d97fa0ac..774e4e897 100644
--- a/Tests/CxxOnly/libcxx2.h
+++ b/Tests/CxxOnly/libcxx2.h
@@ -1,11 +1,11 @@
#ifdef _WIN32
-#ifdef testcxx2_EXPORTS
-#define CM_TEST_LIB_EXPORT __declspec(dllexport)
+# ifdef testcxx2_EXPORTS
+# define CM_TEST_LIB_EXPORT __declspec(dllexport)
+# else
+# define CM_TEST_LIB_EXPORT __declspec(dllimport)
+# endif
#else
-#define CM_TEST_LIB_EXPORT __declspec(dllimport)
-#endif
-#else
-#define CM_TEST_LIB_EXPORT
+# define CM_TEST_LIB_EXPORT
#endif
class CM_TEST_LIB_EXPORT LibCxx2Class
diff --git a/Tests/CxxOnly/testCxxModule.cxx b/Tests/CxxOnly/testCxxModule.cxx
index 039e8bba6..5015d07f8 100644
--- a/Tests/CxxOnly/testCxxModule.cxx
+++ b/Tests/CxxOnly/testCxxModule.cxx
@@ -1,7 +1,7 @@
#ifdef _WIN32
-#define TEST_EXPORT __declspec(dllexport)
+# define TEST_EXPORT __declspec(dllexport)
#else
-#define TEST_EXPORT
+# define TEST_EXPORT
#endif
TEST_EXPORT int testCxxModule(void)
{
diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in
index 8c0817cd6..b7587aa47 100644
--- a/Tests/EnforceConfig.cmake.in
+++ b/Tests/EnforceConfig.cmake.in
@@ -18,9 +18,20 @@ if(NOT CTEST_CONFIGURATION_TYPE)
endif()
endforeach()
if(NOT CTEST_CONFIGURATION_TYPE)
- set(CTEST_CONFIGURATION_TYPE NoConfig)
+ if("@CMAKE_C_COMPILER_ID@;@CMAKE_C_SIMULATE_ID@;@CMAKE_C_COMPILER_FRONTEND_VARIANT@" STREQUAL "Clang;MSVC;GNU")
+ # A valid configuration is required for this compiler in tests that do not set CMP0091 to NEW.
+ set(CTEST_CONFIGURATION_TYPE Debug)
+ else()
+ set(CTEST_CONFIGURATION_TYPE NoConfig)
+ endif()
endif()
message("Guessing configuration ${CTEST_CONFIGURATION_TYPE}")
endif()
+# Isolate tests from user configuration in the environment.
+unset(ENV{CMAKE_GENERATOR})
+unset(ENV{CMAKE_GENERATOR_INSTANCE})
+unset(ENV{CMAKE_GENERATOR_PLATFORM})
+unset(ENV{CMAKE_GENERATOR_TOOLSET})
+
@TEST_HOME_ENV_CODE@
diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt
index eaad3d46c..dc621eb27 100644
--- a/Tests/ExportImport/CMakeLists.txt
+++ b/Tests/ExportImport/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 2.7.20090711)
+cmake_minimum_required (VERSION 3.9)
project(ExportImport C CXX)
if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
@@ -15,7 +15,8 @@ set_property(
PROPERTY SYMBOLIC 1
)
-if(CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}")
else()
if(CMAKE_BUILD_TYPE)
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index eeae3f006..9d8a24852 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -83,11 +83,23 @@ set_property(TARGET testLib7 PROPERTY OUTPUT_NAME testLib7-$<CONFIG>)
add_library(testLib8 OBJECT testLib8A.c testLib8B.c sub/testLib8C.c)
if(NOT CMAKE_GENERATOR STREQUAL "Xcode" OR NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;$]")
- set(maybe_testLib8 testLib8)
+ set(maybe_OBJECTS_DESTINATION OBJECTS DESTINATION $<1:lib>)
else()
- set(maybe_testLib8 "")
+ set(maybe_OBJECTS_DESTINATION "")
endif()
+cmake_policy(PUSH)
+cmake_policy(SET CMP0022 NEW)
+add_library(testLib9ObjPub OBJECT testLib9ObjPub.c)
+target_compile_definitions(testLib9ObjPub INTERFACE testLib9ObjPub_USED)
+add_library(testLib9ObjPriv OBJECT testLib9ObjPriv.c)
+target_compile_definitions(testLib9ObjPriv INTERFACE testLib9ObjPriv_USED)
+add_library(testLib9ObjIface OBJECT testLib9ObjIface.c)
+target_compile_definitions(testLib9ObjIface INTERFACE testLib9ObjIface_USED)
+add_library(testLib9 STATIC testLib9.c)
+target_link_libraries(testLib9 INTERFACE testLib9ObjIface PUBLIC testLib9ObjPub PRIVATE testLib9ObjPriv)
+cmake_policy(POP)
+
# Test using the target_link_libraries command to set the
# LINK_INTERFACE_LIBRARIES* properties. We construct two libraries
# providing the same two symbols. In each library one of the symbols
@@ -143,6 +155,13 @@ add_library(testStaticLibRequiredPrivate testStaticLibRequiredPrivate.c)
target_link_libraries(testLibDepends PRIVATE testStaticLibRequiredPrivate)
cmake_policy(POP)
+cmake_policy(PUSH)
+cmake_policy(SET CMP0079 NEW)
+add_library(TopDirLib STATIC testTopDirLib.c)
+add_subdirectory(SubDirLinkA)
+add_subdirectory(SubDirLinkB)
+cmake_policy(POP)
+
macro(add_include_lib _libName)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c" "/* no content */\n")
add_library(${_libName} "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c")
@@ -294,6 +313,8 @@ install(FILES
)
cmake_policy(POP)
+cmake_policy(PUSH)
+cmake_policy(SET CMP0041 NEW)
add_library(testSharedLibDepends SHARED testSharedLibDepends.cpp)
set_property(TARGET testSharedLibDepends APPEND PROPERTY
INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}"
@@ -310,9 +331,10 @@ install(FILES
DESTINATION include/testSharedLibDepends
)
set_property(TARGET testSharedLibDepends APPEND PROPERTY
- INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/testSharedLibDepends>"
+ INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/$<1:include>/testSharedLibDepends>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}>"
)
+cmake_policy(POP)
# LINK_PRIVATE because the LINK_INTERFACE_LIBRARIES is specified above.
target_link_libraries(testSharedLibDepends LINK_PRIVATE testSharedLibRequired)
@@ -344,6 +366,14 @@ install(FILES
set_property(TARGET testLib2 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS USING_TESTLIB2)
set_property(TARGET testLib3 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS USING_TESTLIB3)
+set_target_properties(testLib3 PROPERTIES
+ EXPORT_PROPERTIES "EXPORTED_PROPERTY1"
+ EXPORTED_PROPERTY1 "EXPORTING_TESTLIB3")
+set_target_properties(testLib4 PROPERTIES
+ EXPORTED_PROPERTY2 "EXPORTING_TESTLIB4_1"
+ EXPORTED_PROPERTY3 "EXPORTING_TESTLIB4_2")
+set_property(TARGET testLib4 PROPERTY
+ EXPORT_PROPERTIES EXPORTED_PROPERTY2 EXPORTED_PROPERTY3)
set_property(TARGET cmp0022NEW APPEND PROPERTY INTERFACE_LINK_LIBRARIES testLib2)
# set_property(TARGET cmp0022NEW APPEND PROPERTY LINK_INTERFACE_LIBRARIES testLibIncludeRequired2) # TODO: Test for error
@@ -483,19 +513,26 @@ install(
TARGETS
testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3 testExe4
testExe2lib testLib4lib testLib4libdbg testLib4libopt
- testLib6 testLib7 ${maybe_testLib8}
+ testLib6 testLib7 testLib8
+ testLib9
testLibCycleA testLibCycleB
testLibNoSONAME
cmp0022NEW cmp0022OLD
+ TopDirLib SubDirLinkA
systemlib
EXPORT exp
- RUNTIME DESTINATION $<1:bin>
- LIBRARY DESTINATION $<1:lib> NAMELINK_SKIP
- ARCHIVE DESTINATION $<1:lib>
- OBJECTS DESTINATION $<1:lib>
+ RUNTIME DESTINATION $<1:bin>$<0:/wrong>
+ LIBRARY DESTINATION $<1:lib>$<0:/wrong> NAMELINK_SKIP
+ ARCHIVE DESTINATION $<1:lib>$<0:/wrong>
+ ${maybe_OBJECTS_DESTINATION}
FRAMEWORK DESTINATION Frameworks
BUNDLE DESTINATION Applications
)
+install(
+ TARGETS
+ testLib9ObjPub testLib9ObjPriv testLib9ObjIface
+ EXPORT exp
+ )
if (APPLE)
file(COPY testLib4.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/testLib4.framework/Headers)
file(COPY testLib4.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Debug/testLib4.framework/Headers)
@@ -540,12 +577,14 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3
testSharedLibRequired testSharedLibRequiredUser testSharedLibRequiredUser2
testSharedLibDepends renamed_on_export
cmp0022NEW cmp0022OLD
+ TopDirLib SubDirLinkA
systemlib
NAMESPACE bld_
FILE ExportBuildTree.cmake
)
export(TARGETS testExe2 testLib4 testLib5 testLib6 testLib7 testExe3 testExe4 testExe2lib
- ${maybe_testLib8}
+ testLib8
+ testLib9 testLib9ObjPub testLib9ObjPriv testLib9ObjIface
testLib4lib testLib4libdbg testLib4libopt
testLibCycleA testLibCycleB
testLibNoSONAME
@@ -570,3 +609,44 @@ install(
)
install(DIRECTORY $<1:include/abs>$<0:/wrong> DESTINATION $<1:include>$<0:/wrong>)
install(EXPORT expAbs NAMESPACE expAbs_ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/expAbs)
+
+
+#------------------------------------------------------------------------------
+# test export of INTERFACE_LINK_OPTIONS
+add_library(testLinkOptions INTERFACE)
+target_link_options(testLinkOptions INTERFACE INTERFACE_FLAG)
+
+install(TARGETS testLinkOptions
+ EXPORT RequiredExp DESTINATION lib)
+export(TARGETS testLinkOptions NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake)
+
+
+#------------------------------------------------------------------------------
+# test export of INTERFACE_LINK_DIRECTORIES
+add_library(testLinkDirectories INTERFACE)
+target_link_directories(testLinkDirectories INTERFACE
+ $<BUILD_INTERFACE:/interface/build>
+ $<INSTALL_INTERFACE:interface/install>)
+
+install(TARGETS testLinkDirectories
+ EXPORT RequiredExp DESTINATION lib)
+export(TARGETS testLinkDirectories NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake)
+
+
+#------------------------------------------------------------------------------
+# test export of INTERFACE_LINK_DEPENDS
+if(CMAKE_GENERATOR MATCHES "Make|Ninja")
+ add_library(testLinkDepends INTERFACE)
+ set_property(TARGET testLinkDepends PROPERTY INTERFACE_LINK_DEPENDS
+ $<BUILD_INTERFACE:BUILD_LINK_DEPENDS>
+ $<INSTALL_INTERFACE:INSTALL_LINK_DEPENDS>)
+
+ install(TARGETS testLinkDepends
+ EXPORT RequiredExp DESTINATION lib)
+ export(TARGETS testLinkDepends NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake)
+endif()
+
+# Test the presence of targets named the same as languages.
+# IMPORTED_LINK_INTERFACE_LANGUAGES entries should not be targets.
+add_library(C INTERFACE)
+add_library(CXX INTERFACE)
diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt
index fd55c423c..43b721778 100644
--- a/Tests/ExportImport/Export/Interface/CMakeLists.txt
+++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt
@@ -6,6 +6,12 @@ set_property(TARGET headeronly PROPERTY INTERFACE_INCLUDE_DIRECTORIES
)
set_property(TARGET headeronly PROPERTY INTERFACE_COMPILE_DEFINITIONS "HEADERONLY_DEFINE")
+add_library(pch_iface INTERFACE)
+target_precompile_headers(pch_iface INTERFACE
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/pch/pch.h>"
+ "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/pch/pch.h>"
+ )
+
include(GenerateExportHeader)
add_library(sharedlib SHARED sharedlib.cpp)
generate_export_header(sharedlib)
@@ -41,9 +47,11 @@ install(FILES
add_library(cmakeonly INTERFACE)
set_property(TARGET cmakeonly PROPERTY INTERFACE_COMPILE_DEFINITIONS [[DEF="\"\$\B"]])
+set_property(TARGET cmakeonly PROPERTY custom_property CustomPropertyValue)
+set_property(TARGET cmakeonly PROPERTY EXPORT_PROPERTIES custom_property)
install(TARGETS headeronly sharediface use_auto_type use_c_restrict source_target
- cmakeonly
+ pch_iface cmakeonly
EXPORT expInterface
)
install(TARGETS sharedlib
@@ -59,6 +67,10 @@ install(FILES
DESTINATION include/headeronly
)
install(FILES
+ pch/pch.h
+ DESTINATION include/pch
+)
+install(FILES
sharedlib/sharedlib.h
"${CMAKE_CURRENT_BINARY_DIR}/sharedlib_export.h"
DESTINATION include/sharedlib
diff --git a/Tests/ExportImport/Export/Interface/pch/pch.h b/Tests/ExportImport/Export/Interface/pch/pch.h
new file mode 100644
index 000000000..bc507270c
--- /dev/null
+++ b/Tests/ExportImport/Export/Interface/pch/pch.h
@@ -0,0 +1 @@
+#define PCH_PCH_H_INCLUDED
diff --git a/Tests/ExportImport/Export/Interface/source_target.cpp b/Tests/ExportImport/Export/Interface/source_target.cpp
index 037191cf6..1eb5b1307 100644
--- a/Tests/ExportImport/Export/Interface/source_target.cpp
+++ b/Tests/ExportImport/Export/Interface/source_target.cpp
@@ -1,10 +1,10 @@
#ifndef USE_FROM_BUILD_DIR
-#error Expected define USE_FROM_BUILD_DIR
+# error Expected define USE_FROM_BUILD_DIR
#endif
#ifdef USE_FROM_INSTALL_DIR
-#error Unexpected define USE_FROM_INSTALL_DIR
+# error Unexpected define USE_FROM_INSTALL_DIR
#endif
int source_symbol()
diff --git a/Tests/ExportImport/Export/Interface/source_target_for_install.cpp b/Tests/ExportImport/Export/Interface/source_target_for_install.cpp
index 64514edb2..2f8819052 100644
--- a/Tests/ExportImport/Export/Interface/source_target_for_install.cpp
+++ b/Tests/ExportImport/Export/Interface/source_target_for_install.cpp
@@ -1,10 +1,10 @@
#ifdef USE_FROM_BUILD_DIR
-#error Unexpected define USE_FROM_BUILD_DIR
+# error Unexpected define USE_FROM_BUILD_DIR
#endif
#ifndef USE_FROM_INSTALL_DIR
-#error Expected define USE_FROM_INSTALL_DIR
+# error Expected define USE_FROM_INSTALL_DIR
#endif
int source_symbol()
diff --git a/Tests/ExportImport/Export/SubDirLinkA/CMakeLists.txt b/Tests/ExportImport/Export/SubDirLinkA/CMakeLists.txt
new file mode 100644
index 000000000..1c3c9dccc
--- /dev/null
+++ b/Tests/ExportImport/Export/SubDirLinkA/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_library(SubDirLinkAImported IMPORTED INTERFACE)
+target_compile_definitions(SubDirLinkAImported INTERFACE DEF_SubDirLinkAImportedForExport)
+
+target_link_libraries(TopDirLib PUBLIC SubDirLinkAImported)
+
+add_library(SubDirLinkA STATIC SubDirLinkA.c)
diff --git a/Tests/ExportImport/Export/SubDirLinkA/SubDirLinkA.c b/Tests/ExportImport/Export/SubDirLinkA/SubDirLinkA.c
new file mode 100644
index 000000000..abf76f556
--- /dev/null
+++ b/Tests/ExportImport/Export/SubDirLinkA/SubDirLinkA.c
@@ -0,0 +1,11 @@
+#ifdef DEF_SubDirLinkAImportedForExport
+# error "DEF_SubDirLinkAImportedForExport is defined but should not be!"
+#endif
+#ifndef DEF_SubDirLinkBImportedForExport
+# error "DEF_SubDirLinkBImportedForExport is not defined but should be!"
+#endif
+
+int testSubDirLinkA(void)
+{
+ return 0;
+}
diff --git a/Tests/ExportImport/Export/SubDirLinkB/CMakeLists.txt b/Tests/ExportImport/Export/SubDirLinkB/CMakeLists.txt
new file mode 100644
index 000000000..22e168ff8
--- /dev/null
+++ b/Tests/ExportImport/Export/SubDirLinkB/CMakeLists.txt
@@ -0,0 +1,4 @@
+add_library(SubDirLinkBImported IMPORTED INTERFACE)
+target_compile_definitions(SubDirLinkBImported INTERFACE DEF_SubDirLinkBImportedForExport)
+
+target_link_libraries(SubDirLinkA PUBLIC SubDirLinkBImported)
diff --git a/Tests/ExportImport/Export/systemlib.h b/Tests/ExportImport/Export/systemlib.h
index 6fd00d503..8ec055bb0 100644
--- a/Tests/ExportImport/Export/systemlib.h
+++ b/Tests/ExportImport/Export/systemlib.h
@@ -3,9 +3,9 @@
#define SYSTEMLIB_H
#if defined(_WIN32) || defined(__CYGWIN__)
-#define systemlib_EXPORT __declspec(dllexport)
+# define systemlib_EXPORT __declspec(dllexport)
#else
-#define systemlib_EXPORT
+# define systemlib_EXPORT
#endif
struct systemlib_EXPORT SystemStruct
diff --git a/Tests/ExportImport/Export/testExe2.c b/Tests/ExportImport/Export/testExe2.c
index f8976c46a..958e4d2bc 100644
--- a/Tests/ExportImport/Export/testExe2.c
+++ b/Tests/ExportImport/Export/testExe2.c
@@ -1,7 +1,7 @@
#if defined(_WIN32) || defined(__CYGWIN__)
-#define testExe2_EXPORT __declspec(dllexport)
+# define testExe2_EXPORT __declspec(dllexport)
#else
-#define testExe2_EXPORT
+# define testExe2_EXPORT
#endif
testExe2_EXPORT int testExe2Func(void)
diff --git a/Tests/ExportImport/Export/testExe2lib.c b/Tests/ExportImport/Export/testExe2lib.c
index 2a5a77bd5..905e6c7f5 100644
--- a/Tests/ExportImport/Export/testExe2lib.c
+++ b/Tests/ExportImport/Export/testExe2lib.c
@@ -1,9 +1,9 @@
#if defined(_WIN32) || defined(__CYGWIN__)
-#define testExe2lib_EXPORT __declspec(dllexport)
-#define testExe2libImp_IMPORT __declspec(dllimport)
+# define testExe2lib_EXPORT __declspec(dllexport)
+# define testExe2libImp_IMPORT __declspec(dllimport)
#else
-#define testExe2lib_EXPORT
-#define testExe2libImp_IMPORT
+# define testExe2lib_EXPORT
+# define testExe2libImp_IMPORT
#endif
testExe2libImp_IMPORT int testExe2libImp(void);
diff --git a/Tests/ExportImport/Export/testExe2libImp.c b/Tests/ExportImport/Export/testExe2libImp.c
index aba914b88..8892c8553 100644
--- a/Tests/ExportImport/Export/testExe2libImp.c
+++ b/Tests/ExportImport/Export/testExe2libImp.c
@@ -1,7 +1,7 @@
#if defined(_WIN32) || defined(__CYGWIN__)
-#define testExe2libImp_EXPORT __declspec(dllexport)
+# define testExe2libImp_EXPORT __declspec(dllexport)
#else
-#define testExe2libImp_EXPORT
+# define testExe2libImp_EXPORT
#endif
testExe2libImp_EXPORT int testExe2libImp(void)
diff --git a/Tests/ExportImport/Export/testLib3.c b/Tests/ExportImport/Export/testLib3.c
index cacac810f..016fae0b1 100644
--- a/Tests/ExportImport/Export/testLib3.c
+++ b/Tests/ExportImport/Export/testLib3.c
@@ -1,9 +1,9 @@
#if defined(_WIN32) || defined(__CYGWIN__)
-#define testLib3_EXPORT __declspec(dllexport)
-#define testLib3Imp_IMPORT __declspec(dllimport)
+# define testLib3_EXPORT __declspec(dllexport)
+# define testLib3Imp_IMPORT __declspec(dllimport)
#else
-#define testLib3_EXPORT
-#define testLib3Imp_IMPORT
+# define testLib3_EXPORT
+# define testLib3Imp_IMPORT
#endif
testLib3Imp_IMPORT int testLib3Imp(void);
diff --git a/Tests/ExportImport/Export/testLib3Imp.c b/Tests/ExportImport/Export/testLib3Imp.c
index 3d836daf1..877d0b6bf 100644
--- a/Tests/ExportImport/Export/testLib3Imp.c
+++ b/Tests/ExportImport/Export/testLib3Imp.c
@@ -1,9 +1,9 @@
#if defined(_WIN32) || defined(__CYGWIN__)
-#define testLib3Imp_EXPORT __declspec(dllexport)
-#define testLib3ImpDep_IMPORT __declspec(dllimport)
+# define testLib3Imp_EXPORT __declspec(dllexport)
+# define testLib3ImpDep_IMPORT __declspec(dllimport)
#else
-#define testLib3Imp_EXPORT
-#define testLib3ImpDep_IMPORT
+# define testLib3Imp_EXPORT
+# define testLib3ImpDep_IMPORT
#endif
testLib3ImpDep_IMPORT int testLib3ImpDep(void);
diff --git a/Tests/ExportImport/Export/testLib3ImpDep.c b/Tests/ExportImport/Export/testLib3ImpDep.c
index b824e03de..4fc97836b 100644
--- a/Tests/ExportImport/Export/testLib3ImpDep.c
+++ b/Tests/ExportImport/Export/testLib3ImpDep.c
@@ -1,7 +1,7 @@
#if defined(_WIN32) || defined(__CYGWIN__)
-#define testLib3ImpDep_EXPORT __declspec(dllexport)
+# define testLib3ImpDep_EXPORT __declspec(dllexport)
#else
-#define testLib3ImpDep_EXPORT
+# define testLib3ImpDep_EXPORT
#endif
testLib3ImpDep_EXPORT int testLib3ImpDep(void)
diff --git a/Tests/ExportImport/Export/testLib4.c b/Tests/ExportImport/Export/testLib4.c
index 0e583b176..2031a4fd7 100644
--- a/Tests/ExportImport/Export/testLib4.c
+++ b/Tests/ExportImport/Export/testLib4.c
@@ -1,7 +1,7 @@
#if defined(_WIN32) || defined(__CYGWIN__)
-#define testLib4_EXPORT __declspec(dllexport)
+# define testLib4_EXPORT __declspec(dllexport)
#else
-#define testLib4_EXPORT
+# define testLib4_EXPORT
#endif
testLib4_EXPORT int testLib4(void)
diff --git a/Tests/ExportImport/Export/testLib5.c b/Tests/ExportImport/Export/testLib5.c
index 7c61fc030..edd02ebd1 100644
--- a/Tests/ExportImport/Export/testLib5.c
+++ b/Tests/ExportImport/Export/testLib5.c
@@ -1,7 +1,7 @@
#if defined(_WIN32) || defined(__CYGWIN__)
-#define testLib5_EXPORT __declspec(dllexport)
+# define testLib5_EXPORT __declspec(dllexport)
#else
-#define testLib5_EXPORT
+# define testLib5_EXPORT
#endif
testLib5_EXPORT int testLib5(void)
diff --git a/Tests/ExportImport/Export/testLib9.c b/Tests/ExportImport/Export/testLib9.c
new file mode 100644
index 000000000..2f6f8ebc7
--- /dev/null
+++ b/Tests/ExportImport/Export/testLib9.c
@@ -0,0 +1,15 @@
+#ifndef testLib9ObjPub_USED
+# error "testLib9ObjPub_USED not defined!"
+#endif
+#ifndef testLib9ObjPriv_USED
+# error "testLib9ObjPriv_USED not defined!"
+#endif
+#ifdef testLib9ObjIface_USED
+# error "testLib9ObjIface_USED defined but should not be!"
+#endif
+int testLib9ObjPub(void);
+int testLib9ObjPriv(void);
+int testLib9(void)
+{
+ return (testLib9ObjPub() + testLib9ObjPriv());
+}
diff --git a/Tests/ExportImport/Export/testLib9ObjIface.c b/Tests/ExportImport/Export/testLib9ObjIface.c
new file mode 100644
index 000000000..e75440a28
--- /dev/null
+++ b/Tests/ExportImport/Export/testLib9ObjIface.c
@@ -0,0 +1,11 @@
+/* Duplicate symbols from other sources to verify that this source
+ is not included when the object library is used. */
+int testLib9ObjMissing(void);
+int testLib9ObjPub(void)
+{
+ return testLib9ObjMissing();
+}
+int testLib9ObjPriv(void)
+{
+ return testLib9ObjMissing();
+}
diff --git a/Tests/ExportImport/Export/testLib9ObjPriv.c b/Tests/ExportImport/Export/testLib9ObjPriv.c
new file mode 100644
index 000000000..6fa63ccde
--- /dev/null
+++ b/Tests/ExportImport/Export/testLib9ObjPriv.c
@@ -0,0 +1,4 @@
+int testLib9ObjPriv(void)
+{
+ return 0;
+}
diff --git a/Tests/ExportImport/Export/testLib9ObjPub.c b/Tests/ExportImport/Export/testLib9ObjPub.c
new file mode 100644
index 000000000..66e2624b0
--- /dev/null
+++ b/Tests/ExportImport/Export/testLib9ObjPub.c
@@ -0,0 +1,4 @@
+int testLib9ObjPub(void)
+{
+ return 0;
+}
diff --git a/Tests/ExportImport/Export/testLibDepends.c b/Tests/ExportImport/Export/testLibDepends.c
index c896c10ef..6100da1dc 100644
--- a/Tests/ExportImport/Export/testLibDepends.c
+++ b/Tests/ExportImport/Export/testLibDepends.c
@@ -4,15 +4,15 @@
#include "testLibIncludeRequired4.h"
#ifndef testLibRequired_IFACE_DEFINE
-#error Expected testLibRequired_IFACE_DEFINE
+# error Expected testLibRequired_IFACE_DEFINE
#endif
#ifndef BuildOnly_DEFINE
-#error Expected BuildOnly_DEFINE
+# error Expected BuildOnly_DEFINE
#endif
#ifdef InstallOnly_DEFINE
-#error Unexpected InstallOnly_DEFINE
+# error Unexpected InstallOnly_DEFINE
#endif
extern int testLibRequired(void);
diff --git a/Tests/ExportImport/Export/testLibNoSONAME.c b/Tests/ExportImport/Export/testLibNoSONAME.c
index 4d98562df..955284852 100644
--- a/Tests/ExportImport/Export/testLibNoSONAME.c
+++ b/Tests/ExportImport/Export/testLibNoSONAME.c
@@ -1,7 +1,7 @@
#if defined(_WIN32) || defined(__CYGWIN__)
-#define testLibNoSONAME_EXPORT __declspec(dllexport)
+# define testLibNoSONAME_EXPORT __declspec(dllexport)
#else
-#define testLibNoSONAME_EXPORT
+# define testLibNoSONAME_EXPORT
#endif
testLibNoSONAME_EXPORT int testLibNoSoName(void)
diff --git a/Tests/ExportImport/Export/testSharedLibDepends.h b/Tests/ExportImport/Export/testSharedLibDepends.h
index e84fb5454..73dafae63 100644
--- a/Tests/ExportImport/Export/testSharedLibDepends.h
+++ b/Tests/ExportImport/Export/testSharedLibDepends.h
@@ -2,10 +2,9 @@
#ifndef TESTSHAREDLIBDEPENDS_H
#define TESTSHAREDLIBDEPENDS_H
-#include "testsharedlibdepends_export.h"
-
#include "renamed.h"
#include "testSharedLibRequired.h"
+#include "testsharedlibdepends_export.h"
struct TESTSHAREDLIBDEPENDS_EXPORT TestSharedLibDepends
{
diff --git a/Tests/ExportImport/Export/testSharedLibRequiredUser2.h b/Tests/ExportImport/Export/testSharedLibRequiredUser2.h
index a13294028..e1c8a05bd 100644
--- a/Tests/ExportImport/Export/testSharedLibRequiredUser2.h
+++ b/Tests/ExportImport/Export/testSharedLibRequiredUser2.h
@@ -2,9 +2,8 @@
#ifndef TESTSHAREDLIBREQUIREDUSER2_H
#define TESTSHAREDLIBREQUIREDUSER2_H
-#include "testsharedlibrequireduser2_export.h"
-
#include "testSharedLibRequired.h"
+#include "testsharedlibrequireduser2_export.h"
struct TESTSHAREDLIBREQUIREDUSER2_EXPORT TestSharedLibRequiredUser2
{
diff --git a/Tests/ExportImport/Export/testTopDirLib.c b/Tests/ExportImport/Export/testTopDirLib.c
new file mode 100644
index 000000000..1ec68de1f
--- /dev/null
+++ b/Tests/ExportImport/Export/testTopDirLib.c
@@ -0,0 +1,11 @@
+#ifndef DEF_SubDirLinkAImportedForExport
+# error "DEF_SubDirLinkAImportedForExport is not defined but should be!"
+#endif
+#ifdef DEF_SubDirLinkBImportedForExport
+# error "DEF_SubDirLinkBImportedForExport is defined but should not be!"
+#endif
+
+int testTopDirLib(void)
+{
+ return 0;
+}
diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt
index 01960ea19..b5df96168 100644
--- a/Tests/ExportImport/Import/A/CMakeLists.txt
+++ b/Tests/ExportImport/Import/A/CMakeLists.txt
@@ -1,3 +1,9 @@
+# Prepare imported targets that the exported project itself imported.
+add_library(SubDirLinkAImported IMPORTED INTERFACE)
+target_compile_definitions(SubDirLinkAImported INTERFACE DEF_SubDirLinkAImportedForImport)
+add_library(SubDirLinkBImported IMPORTED INTERFACE)
+target_compile_definitions(SubDirLinkBImported INTERFACE DEF_SubDirLinkBImportedForImport)
+
# Import targets from the exported build tree.
include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake)
@@ -32,6 +38,20 @@ add_executable(imp_testExe1
${Import_BINARY_DIR}/exp_generated4.c
)
+function(checkForProperty _TARGET _PROP _EXPECTED)
+ get_target_property(EXPORTED_PROPERTY ${_TARGET} "${_PROP}")
+ if (NOT EXPORTED_PROPERTY STREQUAL "${_EXPECTED}")
+ message(SEND_ERROR "${_TARGET} was expected to export \"${_PROP}\" with value \"${_EXPECTED}\" but got \"${EXPORTED_PROPERTY}\"")
+ endif()
+endfunction()
+
+checkForProperty(bld_testLib3 "EXPORTED_PROPERTY1" "EXPORTING_TESTLIB3")
+checkForProperty(exp_testLib3 "EXPORTED_PROPERTY1" "EXPORTING_TESTLIB3")
+checkForProperty(bld_testLib4 "EXPORTED_PROPERTY2" "EXPORTING_TESTLIB4_1")
+checkForProperty(exp_testLib4 "EXPORTED_PROPERTY2" "EXPORTING_TESTLIB4_1")
+checkForProperty(bld_testLib4 "EXPORTED_PROPERTY3" "EXPORTING_TESTLIB4_2")
+checkForProperty(exp_testLib4 "EXPORTED_PROPERTY3" "EXPORTING_TESTLIB4_2")
+
# Try linking to a library imported from the install tree.
target_link_libraries(imp_testExe1
exp_testLib2
@@ -144,6 +164,11 @@ target_link_libraries(cmp0022OLD_exp_test exp_cmp0022OLD)
add_executable(cmp0022NEW_exp_test cmp0022NEW_test_vs6_2.cpp)
target_link_libraries(cmp0022NEW_exp_test exp_cmp0022NEW)
+add_executable(SubDirLink_bld SubDirLink.c)
+target_link_libraries(SubDirLink_bld PRIVATE bld_TopDirLib bld_SubDirLinkA)
+add_executable(SubDirLink_exp SubDirLink.c)
+target_link_libraries(SubDirLink_exp PRIVATE exp_TopDirLib exp_SubDirLinkA)
+
# Try building a plugin to an executable imported from the build tree.
add_library(imp_mod1b MODULE imp_mod1.c)
target_link_libraries(imp_mod1b bld_testExe2)
@@ -229,15 +254,44 @@ add_library(imp_lib1b STATIC imp_lib1.c)
target_link_libraries(imp_lib1b bld_testLib2)
if(NOT CMAKE_GENERATOR STREQUAL "Xcode" OR NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;$]")
- # Create a executable that is using objects imported from the install tree
- add_executable(imp_testLib8 imp_testLib8.c $<TARGET_OBJECTS:exp_testLib8>)
+ set(bld_objlib_type OBJECT_LIBRARY)
+
+ # Create executables using objects imported from the install tree
+ add_executable(imp_testLib8_src imp_testLib8.c $<TARGET_OBJECTS:exp_testLib8>)
+ add_executable(imp_testLib8_link imp_testLib8.c)
+ target_link_libraries(imp_testLib8_link exp_testLib8)
if(NOT CMAKE_GENERATOR STREQUAL "Xcode" OR NOT XCODE_VERSION VERSION_LESS 5)
- # Create a executable that is using objects imported from the build tree
- add_executable(imp_testLib8b imp_testLib8.c $<TARGET_OBJECTS:bld_testLib8>)
+ # Create executables using objects imported from the build tree
+ add_executable(imp_testLib8b_src imp_testLib8.c $<TARGET_OBJECTS:bld_testLib8>)
+ add_executable(imp_testLib8b_link imp_testLib8.c)
+ target_link_libraries(imp_testLib8b_link bld_testLib8)
endif()
+else()
+ set(bld_objlib_type INTERFACE_LIBRARY)
endif()
+# Create an executable that uses a library imported from the install tree
+# that itself was built using an object library. Verify we get the usage
+# requirements.
+add_executable(imp_testLib9 imp_testLib9.c)
+target_link_libraries(imp_testLib9 exp_testLib9)
+# Similarly for importing from the build tree.
+add_executable(imp_testLib9b imp_testLib9.c)
+target_link_libraries(imp_testLib9b bld_testLib9)
+
+# Check that object libraries were transformed on export as expected.
+foreach(vis Pub Priv Iface)
+ get_property(type TARGET exp_testLib9Obj${vis} PROPERTY TYPE)
+ if(NOT type STREQUAL INTERFACE_LIBRARY)
+ message(FATAL_ERROR "exp_testLib9Obj${vis} type is '${type}', not 'INTERFACE_LIBRARY'")
+ endif()
+ get_property(type TARGET bld_testLib9Obj${vis} PROPERTY TYPE)
+ if(NOT type STREQUAL "${bld_objlib_type}")
+ message(FATAL_ERROR "bld_testLib9Obj${vis} type is '${type}', not '${bld_objlib_type}'")
+ endif()
+endforeach()
+
#-----------------------------------------------------------------------------
# Test that handling imported targets, including transitive dependencies,
# works in CheckFunctionExists (...and hopefully all other try_compile() checks
@@ -278,7 +332,6 @@ if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
else()
if (CMAKE_CXX_COMPILER_ID MATCHES "PGI"
OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale"
- OR CMAKE_SYSTEM_NAME MATCHES "IRIX64"
OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set(run_pic_test 0)
else()
@@ -354,7 +407,7 @@ endforeach()
unset(_configs)
if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4)
- OR CMAKE_C_COMPILER_ID STREQUAL Clang)
+ OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC"))
AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja"))
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test)
@@ -429,3 +482,20 @@ if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREA
endif()
endif()
endif()
+
+#---------------------------------------------------------------------------------
+# check that imported libraries have the expected INTERFACE_LINK_OPTIONS property
+checkForProperty(bld_testLinkOptions "INTERFACE_LINK_OPTIONS" "INTERFACE_FLAG")
+checkForProperty(Req::testLinkOptions "INTERFACE_LINK_OPTIONS" "INTERFACE_FLAG")
+
+#---------------------------------------------------------------------------------
+# check that imported libraries have the expected INTERFACE_LINK_DIRECTORIES property
+checkForProperty(bld_testLinkDirectories "INTERFACE_LINK_DIRECTORIES" "/interface/build")
+checkForProperty(Req::testLinkDirectories "INTERFACE_LINK_DIRECTORIES" "${CMAKE_INSTALL_PREFIX}/interface/install")
+
+#---------------------------------------------------------------------------------
+# check that imported libraries have the expected INTERFACE_LINK_DEPENDS property
+if(CMAKE_GENERATOR MATCHES "Make|Ninja")
+ checkForProperty(bld_testLinkDepends "INTERFACE_LINK_DEPENDS" "BUILD_LINK_DEPENDS")
+ checkForProperty(Req::testLinkDepends "INTERFACE_LINK_DEPENDS" "${CMAKE_INSTALL_PREFIX}/INSTALL_LINK_DEPENDS")
+endif()
diff --git a/Tests/ExportImport/Import/A/SubDirLink.c b/Tests/ExportImport/Import/A/SubDirLink.c
new file mode 100644
index 000000000..eb4b8609a
--- /dev/null
+++ b/Tests/ExportImport/Import/A/SubDirLink.c
@@ -0,0 +1,14 @@
+#ifndef DEF_SubDirLinkAImportedForImport
+# error "DEF_SubDirLinkAImportedForImport is not defined but should be!"
+#endif
+#ifndef DEF_SubDirLinkBImportedForImport
+# error "DEF_SubDirLinkBImportedForImport is not defined but should be!"
+#endif
+
+extern int testTopDirLib(void);
+extern int testSubDirLinkA(void);
+
+int main(void)
+{
+ return (testTopDirLib() + testSubDirLinkA() + 0);
+}
diff --git a/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp b/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp
index 587834987..778b8287e 100644
--- a/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp
+++ b/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp
@@ -1,9 +1,9 @@
#ifndef USING_TESTLIB2
-#error Expected USING_TESTLIB2
+# error Expected USING_TESTLIB2
#endif
#ifdef USING_TESTLIB3
-#error Unexpected USING_TESTLIB3
+# error Unexpected USING_TESTLIB3
#endif
int main(void)
diff --git a/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp b/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp
index e50158b76..9eaaee9b4 100644
--- a/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp
+++ b/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp
@@ -1,9 +1,9 @@
#ifdef USING_TESTLIB2
-#error Unexpected USING_TESTLIB2
+# error Unexpected USING_TESTLIB2
#endif
#ifndef USING_TESTLIB3
-#error Expected USING_TESTLIB3
+# error Expected USING_TESTLIB3
#endif
int main(void)
diff --git a/Tests/ExportImport/Import/A/deps_iface.c b/Tests/ExportImport/Import/A/deps_iface.c
index 1539bcb68..afb1af01f 100644
--- a/Tests/ExportImport/Import/A/deps_iface.c
+++ b/Tests/ExportImport/Import/A/deps_iface.c
@@ -1,9 +1,4 @@
-#include "testLibIncludeRequired1.h"
-#include "testLibIncludeRequired2.h"
-#include "testLibIncludeRequired6.h"
-#include "testLibIncludeRequired7.h"
-
#include "installIncludesTest.h"
#include "installIncludesTest2.h"
#include "installIncludesTest3.h"
@@ -12,17 +7,21 @@
#include "installIncludesTest6.h"
#include "installIncludesTest7.h"
#include "installIncludesTest8.h"
+#include "testLibIncludeRequired1.h"
+#include "testLibIncludeRequired2.h"
+#include "testLibIncludeRequired6.h"
+#include "testLibIncludeRequired7.h"
#ifndef testLibRequired_IFACE_DEFINE
-#error Expected testLibRequired_IFACE_DEFINE
+# error Expected testLibRequired_IFACE_DEFINE
#endif
#ifdef BuildOnly_DEFINE
-#error Unexpected BuildOnly_DEFINE
+# error Unexpected BuildOnly_DEFINE
#endif
#ifndef InstallOnly_DEFINE
-#error Expected InstallOnly_DEFINE
+# error Expected InstallOnly_DEFINE
#endif
extern int testLibDepends(void);
diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp
index 3658ab548..d239fb418 100644
--- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp
+++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp
@@ -3,32 +3,32 @@
#include "testSharedLibDepends.h"
#ifdef CHECK_PIC_WORKS
-#if defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__)
-#error Expected by INTERFACE_POSITION_INDEPENDENT_CODE property of dependency
-#endif
+# if defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__)
+# error Expected by INTERFACE_POSITION_INDEPENDENT_CODE property of dependency
+# endif
#endif
#ifndef PIC_PROPERTY_IS_ON
-#error Expected PIC_PROPERTY_IS_ON
+# error Expected PIC_PROPERTY_IS_ON
#endif
#ifndef CUSTOM_PROPERTY_IS_ON
-#error Expected CUSTOM_PROPERTY_IS_ON
+# error Expected CUSTOM_PROPERTY_IS_ON
#endif
#ifndef CUSTOM_STRING_IS_MATCH
-#error Expected CUSTOM_STRING_IS_MATCH
+# error Expected CUSTOM_STRING_IS_MATCH
#endif
#ifdef TEST_SUBDIR_LIB
-#include "renamed.h"
-#include "subdir.h"
+# include "renamed.h"
+# include "subdir.h"
#endif
#ifdef DO_GNU_TESTS
-#ifndef CUSTOM_COMPILE_OPTION
-#error Expected CUSTOM_COMPILE_OPTION
-#endif
+# ifndef CUSTOM_COMPILE_OPTION
+# error Expected CUSTOM_COMPILE_OPTION
+# endif
#endif
int main(int, char**)
diff --git a/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp b/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp
index 357f64f02..ddb8c4b35 100644
--- a/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp
+++ b/Tests/ExportImport/Import/A/framework_interface/framework_test.cpp
@@ -2,5 +2,5 @@
#include <testLib4/testLib4.h>
#ifndef TESTLIB4_H
-#error Expected define TESTLIB4_H
+# error Expected define TESTLIB4_H
#endif
diff --git a/Tests/ExportImport/Import/A/iface_test.cpp b/Tests/ExportImport/Import/A/iface_test.cpp
index fa4474bdb..4428c1c50 100644
--- a/Tests/ExportImport/Import/A/iface_test.cpp
+++ b/Tests/ExportImport/Import/A/iface_test.cpp
@@ -1,6 +1,6 @@
#ifndef USING_TESTSHAREDLIBREQUIRED
-#error Expected USING_TESTSHAREDLIBREQUIRED
+# error Expected USING_TESTSHAREDLIBREQUIRED
#endif
#include "excludedFromAll.h"
diff --git a/Tests/ExportImport/Import/A/imp_mod1.c b/Tests/ExportImport/Import/A/imp_mod1.c
index 89d754595..9385d5519 100644
--- a/Tests/ExportImport/Import/A/imp_mod1.c
+++ b/Tests/ExportImport/Import/A/imp_mod1.c
@@ -1,7 +1,7 @@
#if defined(_WIN32) || defined(__CYGWIN__)
-#define testExe2_IMPORT __declspec(dllimport)
+# define testExe2_IMPORT __declspec(dllimport)
#else
-#define testExe2_IMPORT
+# define testExe2_IMPORT
#endif
testExe2_IMPORT int testExe2Func(void);
diff --git a/Tests/ExportImport/Import/A/imp_testExe1.c b/Tests/ExportImport/Import/A/imp_testExe1.c
index 348843928..8173557cd 100644
--- a/Tests/ExportImport/Import/A/imp_testExe1.c
+++ b/Tests/ExportImport/Import/A/imp_testExe1.c
@@ -14,9 +14,9 @@ extern int testLibPerConfigDest(void);
/* Switch a symbol between debug and optimized builds to make sure the
proper library is found from the testLib4 link interface. */
#ifdef EXE_DBG
-#define testLib4libcfg testLib4libdbg
+# define testLib4libcfg testLib4libdbg
#else
-#define testLib4libcfg testLib4libopt
+# define testLib4libcfg testLib4libopt
#endif
extern testLib4libcfg(void);
diff --git a/Tests/ExportImport/Import/A/imp_testExeAbs1.c b/Tests/ExportImport/Import/A/imp_testExeAbs1.c
index 629b891f1..fd0524206 100644
--- a/Tests/ExportImport/Import/A/imp_testExeAbs1.c
+++ b/Tests/ExportImport/Import/A/imp_testExeAbs1.c
@@ -2,10 +2,10 @@
#include "testLibAbs1a.h"
#include "testLibAbs1b.h"
#ifndef testLibAbs1a
-#error "testLibAbs1a not defined"
+# error "testLibAbs1a not defined"
#endif
#ifndef testLibAbs1b
-#error "testLibAbs1b not defined"
+# error "testLibAbs1b not defined"
#endif
int main()
{
diff --git a/Tests/ExportImport/Import/A/imp_testLib9.c b/Tests/ExportImport/Import/A/imp_testLib9.c
new file mode 100644
index 000000000..e014857ec
--- /dev/null
+++ b/Tests/ExportImport/Import/A/imp_testLib9.c
@@ -0,0 +1,16 @@
+#ifndef testLib9ObjPub_USED
+# error "testLib9ObjPub_USED not defined!"
+#endif
+#ifdef testLib9ObjPriv_USED
+# error "testLib9ObjPriv_USED defined but should not be!"
+#endif
+#ifndef testLib9ObjIface_USED
+# error "testLib9ObjIface_USED not defined!"
+#endif
+
+int testLib9(void);
+
+int main()
+{
+ return testLib9();
+}
diff --git a/Tests/ExportImport/Import/A/imp_testLinkOptions.cpp b/Tests/ExportImport/Import/A/imp_testLinkOptions.cpp
new file mode 100644
index 000000000..2b18b2e09
--- /dev/null
+++ b/Tests/ExportImport/Import/A/imp_testLinkOptions.cpp
@@ -0,0 +1,8 @@
+
+#include "testSharedLibRequired.h"
+
+int foo()
+{
+ TestSharedLibRequired req;
+ return req.foo();
+}
diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt
index c850508e5..ef666b1a7 100644
--- a/Tests/ExportImport/Import/Interface/CMakeLists.txt
+++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt
@@ -98,6 +98,17 @@ set_property(TARGET exp::sharediface APPEND PROPERTY INTERFACE_LINK_LIBRARIES de
add_executable(interfacetest_exp interfacetest.cpp)
target_link_libraries(interfacetest_exp exp::sharediface)
+if(NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;$]" OR CMAKE_GENERATOR STREQUAL "Xcode")
+ add_executable(pch_iface_test_bld pch_iface_test.cpp)
+ target_link_libraries(pch_iface_test_bld bld::pch_iface)
+ add_executable(pch_iface_test_exp pch_iface_test.cpp)
+ target_link_libraries(pch_iface_test_exp exp::pch_iface)
+ if(CMAKE_CXX_COMPILE_OPTIONS_USE_PCH)
+ target_compile_definitions(pch_iface_test_bld PRIVATE EXPECT_PCH)
+ target_compile_definitions(pch_iface_test_exp PRIVATE EXPECT_PCH)
+ endif()
+endif()
+
do_try_compile(exp)
foreach(ns exp bld)
@@ -109,4 +120,12 @@ foreach(ns exp bld)
"not\n"
" " [[DEF="\"\$\B"]] "\n")
endif()
+ get_property(custom TARGET ${ns}::cmakeonly PROPERTY custom_property)
+ if(NOT custom STREQUAL "CustomPropertyValue")
+ message(SEND_ERROR
+ "${ns}::cmakeonly property custom_property is:\n"
+ " ${custom}\n"
+ "not\n"
+ " CustomPropertyValue\n")
+ endif()
endforeach()
diff --git a/Tests/ExportImport/Import/Interface/headeronlytest.cpp b/Tests/ExportImport/Import/Interface/headeronlytest.cpp
index 0e754e9e3..7b63a0496 100644
--- a/Tests/ExportImport/Import/Interface/headeronlytest.cpp
+++ b/Tests/ExportImport/Import/Interface/headeronlytest.cpp
@@ -2,11 +2,11 @@
#include "headeronly.h"
#ifndef HEADERONLY_DEFINE
-#error Expected HEADERONLY_DEFINE
+# error Expected HEADERONLY_DEFINE
#endif
#ifdef SHAREDLIB_DEFINE
-#error Unexpected SHAREDLIB_DEFINE
+# error Unexpected SHAREDLIB_DEFINE
#endif
int main(int, char**)
diff --git a/Tests/ExportImport/Import/Interface/interfacetest.cpp b/Tests/ExportImport/Import/Interface/interfacetest.cpp
index 7be816286..c1e29c246 100644
--- a/Tests/ExportImport/Import/Interface/interfacetest.cpp
+++ b/Tests/ExportImport/Import/Interface/interfacetest.cpp
@@ -2,15 +2,15 @@
#include "sharedlib.h"
#ifndef SHAREDLIB_DEFINE
-#error Expected SHAREDLIB_DEFINE
+# error Expected SHAREDLIB_DEFINE
#endif
#ifdef HEADERONLY_DEFINE
-#error Unexpected HEADERONLY_DEFINE
+# error Unexpected HEADERONLY_DEFINE
#endif
#ifndef DEFINE_IFACE_DEFINE
-#error Expected DEFINE_IFACE_DEFINE
+# error Expected DEFINE_IFACE_DEFINE
#endif
int main(int, char**)
diff --git a/Tests/ExportImport/Import/Interface/pch_iface_test.cpp b/Tests/ExportImport/Import/Interface/pch_iface_test.cpp
new file mode 100644
index 000000000..a18bbde23
--- /dev/null
+++ b/Tests/ExportImport/Import/Interface/pch_iface_test.cpp
@@ -0,0 +1,16 @@
+#ifdef EXPECT_PCH
+// Verify that pch/pch.h was included via '-include ...' or equivalent.
+# ifndef PCH_PCH_H_INCLUDED
+# error "Expected PCH_PCH_H_INCLUDED."
+# endif
+#elif defined(__PGIC__) || defined(__ibmxl__) || defined(_CRAYC)
+// No PCH expected but these compilers define macros below.
+#elif defined(__GNUC__) || defined(__clang__) || defined(_INTEL_COMPILER) || \
+ defined(_MSC_VER)
+# error "Expected EXPECT_PCH for this compiler."
+#endif
+
+int main()
+{
+ return 0;
+}
diff --git a/Tests/ExternalOBJ/CMakeLists.txt b/Tests/ExternalOBJ/CMakeLists.txt
index 458c88bfd..4ff75b8cc 100644
--- a/Tests/ExternalOBJ/CMakeLists.txt
+++ b/Tests/ExternalOBJ/CMakeLists.txt
@@ -55,7 +55,7 @@ message("${EXTERNAL_OBJECT}")
# Build an executable using the external object file.
add_executable(ExternalOBJ executable.cxx ${CUSTOM_OBJECT})
# A bug showed up in VS2010 where an object file that was
-# part of a custom commad output worked, but ones that were
+# part of a custom command output worked, but ones that were
# not didn't work. So, repeat the executable using the object
# directly and not from the output of the copy.
add_executable(ExternalOBJ2 executable.cxx ${EXTERNAL_OBJECT})
diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt
index 6b7356340..093391e3f 100644
--- a/Tests/ExternalProject/CMakeLists.txt
+++ b/Tests/ExternalProject/CMakeLists.txt
@@ -421,7 +421,7 @@ if(do_git_tests)
set(local_git_repo "../../LocalRepositories/GIT-with-submodules")
- set(proj TS1-GIT-no-GIT_SUBMODULES)
+ set(proj TS1-GIT-all-GIT_SUBMODULES)
ExternalProject_Add(${proj}
GIT_REPOSITORY "${local_git_repo}"
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
@@ -435,7 +435,8 @@ if(do_git_tests)
)
set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
- set(proj TS1-GIT-empty-GIT_SUBMODULES)
+ set(proj TS1-GIT-all-GIT_SUBMODULES-via-CMP0097-OLD)
+ cmake_policy(SET CMP0097 OLD)
ExternalProject_Add(${proj}
GIT_REPOSITORY "${local_git_repo}"
GIT_SUBMODULES ""
@@ -450,6 +451,22 @@ if(do_git_tests)
)
set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
+ set(proj TS1-GIT-no-GIT_SUBMODULES)
+ cmake_policy(SET CMP0097 NEW)
+ ExternalProject_Add(${proj}
+ GIT_REPOSITORY "${local_git_repo}"
+ GIT_SUBMODULES ""
+ CMAKE_GENERATOR "${CMAKE_GENERATOR}"
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+ -DWITH_m1:BOOL=OFF
+ -DWITH_m2:BOOL=OFF
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ""
+ DEPENDS "SetupLocalGITRepository"
+ "SetupLocalGITRepositoryWithSubmodules"
+ )
+ set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
+
set(proj TS1-GIT-some-GIT_SUBMODULES)
ExternalProject_Add(${proj}
GIT_REPOSITORY "${local_git_repo}"
@@ -631,3 +648,21 @@ ExternalProject_Add(${proj}
LOG_BUILD 1
LOG_INSTALL 1
)
+
+set(proj ExternalProject-log-dir)
+ExternalProject_Add(${proj}
+ DOWNLOAD_COMMAND "${download_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "download"
+ PATCH_COMMAND "${patch_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "patch"
+ UPDATE_COMMAND "${update_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "update"
+ CONFIGURE_COMMAND "${configure_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "configure"
+ BUILD_COMMAND "${build_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "build"
+ INSTALL_COMMAND "${install_cmd}" COMMAND "${CMAKE_COMMAND}" -E echo "install"
+ LOG_MERGED_STDOUTERR 1
+ LOG_DIR ${CMAKE_CURRENT_BINARY_DIR}/different_log
+ LOG_DOWNLOAD 1
+ LOG_PATCH 1
+ LOG_UPDATE 1
+ LOG_CONFIGURE 1
+ LOG_BUILD 1
+ LOG_INSTALL 1
+ )
diff --git a/Tests/ExternalProjectLocal/CMakeLists.txt b/Tests/ExternalProjectLocal/CMakeLists.txt
index 5b941630a..1075a9d07 100644
--- a/Tests/ExternalProjectLocal/CMakeLists.txt
+++ b/Tests/ExternalProjectLocal/CMakeLists.txt
@@ -20,71 +20,55 @@ set(binary_base "${base}/Build")
set_property(DIRECTORY PROPERTY EP_BASE ${base})
set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test)
-if(NOT DEFINED can_build_tutorial_step5)
- set(can_build_tutorial_step5 1)
-
- # The ExternalProject builds of Tutorial Step5 cannot be built
- # correctly 2nd and later times in an in-source build...
- # (because the CMakeCache.txt from the real in-source build of
- # the Tests/Tutorial/Step5 directory gets copied when we do
- # the "source directory copy" step... but it still refers to
- # its original path which yields a configure error.) So:
- #
- if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
- set(can_build_tutorial_step5 0)
- endif()
-endif()
# Local DIR:
#
-if(can_build_tutorial_step5)
- set(proj TutorialStep5-Local)
- ExternalProject_Add(${proj}
- URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5"
- CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
- CMAKE_ARGS -G ${CMAKE_GENERATOR} <SOURCE_DIR>
- TEST_BEFORE_INSTALL 1
- LOG_INSTALL 1
- )
- set_property(TARGET ${proj} PROPERTY FOLDER "Local")
- ExternalProject_Get_Property(${proj} install_dir)
- set(TutorialStep5_install_dir ${install_dir})
-
- set(proj TutorialStep5-Local-TestAfterInstall)
- ExternalProject_Add(${proj}
- URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5"
- CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
- CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF
- TEST_AFTER_INSTALL 1
- LOG_TEST 1
- )
- set_property(TARGET ${proj} PROPERTY FOLDER "Local")
-
- set(proj TutorialStep5-Local-TestExcludeFromMainBefore)
- ExternalProject_Add(${proj}
- URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5"
- CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
- CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF
- TEST_BEFORE_INSTALL 1
- TEST_EXCLUDE_FROM_MAIN 1
- STEP_TARGETS test
- LOG_TEST 1
- )
- set_property(TARGET ${proj} PROPERTY FOLDER "Local")
-
- set(proj TutorialStep5-Local-TestExcludeFromMainAfter)
- ExternalProject_Add(${proj}
- URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5"
- CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
- CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF
- TEST_AFTER_INSTALL 1
- TEST_EXCLUDE_FROM_MAIN 1
- STEP_TARGETS test
- LOG_TEST 1
- )
- set_property(TARGET ${proj} PROPERTY FOLDER "Local")
+set(proj TutorialStep5-Local)
+ExternalProject_Add(${proj}
+URL "${CMAKE_CURRENT_SOURCE_DIR}/Step5"
+CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+CMAKE_ARGS -G ${CMAKE_GENERATOR} <SOURCE_DIR>
+TEST_BEFORE_INSTALL 1
+LOG_INSTALL 1
+)
+set_property(TARGET ${proj} PROPERTY FOLDER "Local")
+ExternalProject_Get_Property(${proj} install_dir)
+set(TutorialStep5_install_dir ${install_dir})
+
+set(proj TutorialStep5-Local-TestAfterInstall)
+ExternalProject_Add(${proj}
+URL "${CMAKE_CURRENT_SOURCE_DIR}/Step5"
+CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
+CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF
+TEST_AFTER_INSTALL 1
+LOG_TEST 1
+)
+set_property(TARGET ${proj} PROPERTY FOLDER "Local")
+
+set(proj TutorialStep5-Local-TestExcludeFromMainBefore)
+ExternalProject_Add(${proj}
+URL "${CMAKE_CURRENT_SOURCE_DIR}/Step5"
+CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
+CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF
+TEST_BEFORE_INSTALL 1
+TEST_EXCLUDE_FROM_MAIN 1
+STEP_TARGETS test
+LOG_TEST 1
+)
+set_property(TARGET ${proj} PROPERTY FOLDER "Local")
+
+set(proj TutorialStep5-Local-TestExcludeFromMainAfter)
+ExternalProject_Add(${proj}
+URL "${CMAKE_CURRENT_SOURCE_DIR}/Step5"
+CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -G ${CMAKE_GENERATOR} <SOURCE_DIR>
+CMAKE_CACHE_DEFAULT_ARGS -DUSE_MYMATH:BOOL=OFF
+TEST_AFTER_INSTALL 1
+TEST_EXCLUDE_FROM_MAIN 1
+STEP_TARGETS test
+LOG_TEST 1
+)
+set_property(TARGET ${proj} PROPERTY FOLDER "Local")
-endif()
# Local TAR:
@@ -100,6 +84,7 @@ ExternalProject_Add(${proj}
-DTEST_LIST:STRING=A::B::C
INSTALL_COMMAND ""
LOG_CONFIGURE 1
+ LOG_PATCH 1
)
set_property(TARGET ${proj} PROPERTY FOLDER "Local/TAR")
@@ -208,12 +193,10 @@ enable_testing()
#
# BuildTree tests:
#
-if(can_build_tutorial_step5)
- add_test(TutorialStep5-Local-BuildTreeTest
- "${binary_base}/TutorialStep5-Local/Tutorial" 42)
- set_property(TEST TutorialStep5-Local-BuildTreeTest
- APPEND PROPERTY LABELS Step5 BuildTree)
-endif()
+add_test(TutorialStep5-Local-BuildTreeTest
+"${binary_base}/TutorialStep5-Local/Tutorial" 42)
+set_property(TEST TutorialStep5-Local-BuildTreeTest
+APPEND PROPERTY LABELS Step5 BuildTree)
add_test(TutorialStep1-LocalTAR-BuildTreeTest
"${binary_base}/TutorialStep1-LocalTAR/EP-Tutorial" 36)
@@ -233,12 +216,7 @@ add_test(TutorialStep1-LocalNoDirTGZ-BuildTreeTest
# InstallTree tests:
#
-if(can_build_tutorial_step5)
- add_test(TutorialStep5-InstallTreeTest
- "${TutorialStep5_install_dir}/bin/Tutorial" 49)
- set_property(TEST TutorialStep5-InstallTreeTest
- APPEND PROPERTY LABELS Step5 InstallTree)
-endif()
-
-
-message(STATUS "can_build_tutorial_step5='${can_build_tutorial_step5}'")
+add_test(TutorialStep5-InstallTreeTest
+"${TutorialStep5_install_dir}/bin/Tutorial" 49)
+set_property(TEST TutorialStep5-InstallTreeTest
+APPEND PROPERTY LABELS Step5 InstallTree)
diff --git a/Tests/ExternalProjectLocal/Step5/CMakeLists.txt b/Tests/ExternalProjectLocal/Step5/CMakeLists.txt
new file mode 100644
index 000000000..93b3880f0
--- /dev/null
+++ b/Tests/ExternalProjectLocal/Step5/CMakeLists.txt
@@ -0,0 +1,71 @@
+cmake_minimum_required (VERSION 2.6)
+project (Tutorial)
+
+# The version number.
+set (Tutorial_VERSION_MAJOR 1)
+set (Tutorial_VERSION_MINOR 0)
+
+# does this system provide the log and exp functions?
+include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
+check_function_exists (log HAVE_LOG)
+check_function_exists (exp HAVE_EXP)
+
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+
+# configure a header file to pass some of the CMake settings
+# to the source code
+configure_file (
+ "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
+ "${PROJECT_BINARY_DIR}/TutorialConfig.h"
+ )
+
+# add the binary tree to the search path for include files
+# so that we will find TutorialConfig.h
+include_directories ("${PROJECT_BINARY_DIR}")
+
+# add the MathFunctions library?
+if (USE_MYMATH)
+ include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
+ add_subdirectory (MathFunctions)
+ set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
+endif ()
+
+# add the executable
+add_executable (Tutorial tutorial.cxx)
+target_link_libraries (Tutorial ${EXTRA_LIBS})
+
+# add the install targets
+install (TARGETS Tutorial DESTINATION bin)
+install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
+ DESTINATION include)
+
+# enable testing
+enable_testing ()
+
+# does the application run
+add_test (TutorialRuns Tutorial 25)
+
+# does the usage message work?
+add_test (TutorialUsage Tutorial)
+set_tests_properties (TutorialUsage
+ PROPERTIES
+ PASS_REGULAR_EXPRESSION "Usage:.*number"
+ )
+
+#define a macro to simplify adding tests
+macro (do_test arg result)
+ add_test (TutorialComp${arg} Tutorial ${arg})
+ set_tests_properties (TutorialComp${arg}
+ PROPERTIES PASS_REGULAR_EXPRESSION ${result}
+ )
+endmacro ()
+
+# do a bunch of result based tests
+do_test (4 "4 is 2")
+do_test (9 "9 is 3")
+do_test (5 "5 is 2.236")
+do_test (7 "7 is 2.645")
+do_test (25 "25 is 5")
+do_test (-25 "-25 is 0")
+do_test (0.0001 "0.0001 is 0.01")
diff --git a/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt b/Tests/ExternalProjectLocal/Step5/MathFunctions/CMakeLists.txt
index 453a46332..453a46332 100644
--- a/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt
+++ b/Tests/ExternalProjectLocal/Step5/MathFunctions/CMakeLists.txt
diff --git a/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx b/Tests/ExternalProjectLocal/Step5/MathFunctions/MakeTable.cxx
index cebd50fcc..cebd50fcc 100644
--- a/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx
+++ b/Tests/ExternalProjectLocal/Step5/MathFunctions/MakeTable.cxx
diff --git a/Tests/ExternalProjectLocal/Step5/MathFunctions/MathFunctions.h b/Tests/ExternalProjectLocal/Step5/MathFunctions/MathFunctions.h
new file mode 100644
index 000000000..cd36bccff
--- /dev/null
+++ b/Tests/ExternalProjectLocal/Step5/MathFunctions/MathFunctions.h
@@ -0,0 +1 @@
+double mysqrt(double x);
diff --git a/Tests/ExternalProjectLocal/Step5/MathFunctions/mysqrt.cxx b/Tests/ExternalProjectLocal/Step5/MathFunctions/mysqrt.cxx
new file mode 100644
index 000000000..a44aba020
--- /dev/null
+++ b/Tests/ExternalProjectLocal/Step5/MathFunctions/mysqrt.cxx
@@ -0,0 +1,41 @@
+#include <stdio.h>
+
+#include "MathFunctions.h"
+#include "TutorialConfig.h"
+
+// include the generated table
+#include <math.h>
+
+#include "Table.h"
+
+// a hack square root calculation using simple operations
+double mysqrt(double x)
+{
+ if (x <= 0) {
+ return 0;
+ }
+
+ double result;
+
+ // if we have both log and exp then use them
+ double delta;
+
+ // use the table to help find an initial value
+ result = x;
+ if (x >= 1 && x < 10) {
+ result = sqrtTable[static_cast<int>(x)];
+ }
+
+ // do ten iterations
+ int i;
+ for (i = 0; i < 10; ++i) {
+ if (result <= 0) {
+ result = 0.1;
+ }
+ delta = x - (result * result);
+ result = result + 0.5 * delta / result;
+ fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result);
+ }
+
+ return result;
+}
diff --git a/Tests/ExternalProjectLocal/Step5/TutorialConfig.h.in b/Tests/ExternalProjectLocal/Step5/TutorialConfig.h.in
new file mode 100644
index 000000000..e97ce24ea
--- /dev/null
+++ b/Tests/ExternalProjectLocal/Step5/TutorialConfig.h.in
@@ -0,0 +1,8 @@
+// the configured options and settings for Tutorial
+#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
+#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
+#cmakedefine USE_MYMATH
+
+// does the platform provide exp and log functions?
+#cmakedefine HAVE_LOG
+#cmakedefine HAVE_EXP
diff --git a/Tests/ExternalProjectLocal/Step5/tutorial.cxx b/Tests/ExternalProjectLocal/Step5/tutorial.cxx
new file mode 100644
index 000000000..8d077b29c
--- /dev/null
+++ b/Tests/ExternalProjectLocal/Step5/tutorial.cxx
@@ -0,0 +1,34 @@
+// A simple program that computes the square root of a number
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "TutorialConfig.h"
+
+#ifdef USE_MYMATH
+# include "MathFunctions.h"
+#endif
+
+int main(int argc, char* argv[])
+{
+ if (argc < 2) {
+ fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
+ Tutorial_VERSION_MINOR);
+ fprintf(stdout, "Usage: %s number\n", argv[0]);
+ return 1;
+ }
+
+ double inputValue = atof(argv[1]);
+ double outputValue = 0;
+
+ if (inputValue >= 0) {
+#ifdef USE_MYMATH
+ outputValue = mysqrt(inputValue);
+#else
+ outputValue = sqrt(inputValue);
+#endif
+ }
+
+ fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
+ return 0;
+}
diff --git a/Tests/ExternalProjectSourceSubdirNotCMake/CMakeLists.txt b/Tests/ExternalProjectSourceSubdirNotCMake/CMakeLists.txt
new file mode 100644
index 000000000..f64df1a77
--- /dev/null
+++ b/Tests/ExternalProjectSourceSubdirNotCMake/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 3.6)
+project(ExternalProjectSourceSubdirNotCMake NONE)
+include(ExternalProject)
+
+find_program(MAKE_EXECUTABLE
+ NAMES gmake make)
+
+if (NOT MAKE_EXECUTABLE)
+ message("No `make` executable found; skipping")
+ return ()
+endif ()
+
+ExternalProject_Add(Example
+ SOURCE_SUBDIR subdir
+ BUILD_IN_SOURCE 1
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Example
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND "${MAKE_EXECUTABLE}"
+ INSTALL_COMMAND ""
+ )
diff --git a/Tests/ExternalProjectSourceSubdirNotCMake/Example/subdir/Makefile b/Tests/ExternalProjectSourceSubdirNotCMake/Example/subdir/Makefile
new file mode 100644
index 000000000..cab3b8f4b
--- /dev/null
+++ b/Tests/ExternalProjectSourceSubdirNotCMake/Example/subdir/Makefile
@@ -0,0 +1,2 @@
+all:
+ echo "complete"
diff --git a/Tests/FindALSA/CMakeLists.txt b/Tests/FindALSA/CMakeLists.txt
new file mode 100644
index 000000000..891f7a43a
--- /dev/null
+++ b/Tests/FindALSA/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindALSA.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindALSA/Test"
+ "${CMake_BINARY_DIR}/Tests/FindALSA/Test"
+ ${build_generator_args}
+ --build-project TestFindALSA
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindALSA/Test/CMakeLists.txt b/Tests/FindALSA/Test/CMakeLists.txt
new file mode 100644
index 000000000..2829740cf
--- /dev/null
+++ b/Tests/FindALSA/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.10)
+project(TestFindALSA C)
+include(CTest)
+
+find_package(ALSA REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_ALSA_VERSION="${ALSA_VERSION_STRING}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt ALSA::ALSA)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${ALSA_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${ALSA_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindALSA/Test/main.c b/Tests/FindALSA/Test/main.c
new file mode 100644
index 000000000..d3303d076
--- /dev/null
+++ b/Tests/FindALSA/Test/main.c
@@ -0,0 +1,10 @@
+#include <alsa/global.h>
+#include <stdio.h>
+#include <string.h>
+
+int main()
+{
+ printf("Found ALSA version %s, expected version %s\n",
+ snd_asoundlib_version(), CMAKE_EXPECTED_ALSA_VERSION);
+ return strcmp(snd_asoundlib_version(), CMAKE_EXPECTED_ALSA_VERSION);
+}
diff --git a/Tests/FindBoost/CMakeLists.txt b/Tests/FindBoost/CMakeLists.txt
index 0e9527de0..8489d859c 100644
--- a/Tests/FindBoost/CMakeLists.txt
+++ b/Tests/FindBoost/CMakeLists.txt
@@ -9,6 +9,21 @@ add_test(NAME FindBoost.Test COMMAND
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
+add_test(NAME FindBoost.TestFail COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindBoost/TestFail"
+ "${CMake_BINARY_DIR}/Tests/FindBoost/TestFail"
+ ${build_generator_args}
+ --build-project TestFailFindBoost
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+set_tests_properties(FindBoost.TestFail PROPERTIES
+ WILL_FAIL ON
+ PASS_REGULAR_EXPRESSION "Could NOT find Boost (missing: foobar)")
+
add_test(NAME FindBoost.TestHeaders COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -19,3 +34,16 @@ add_test(NAME FindBoost.TestHeaders COMMAND
--build-options ${build_options}
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
+
+if (CMake_TEST_FindBoost_Python)
+ add_test(NAME FindBoost.TestPython COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindBoost/TestPython"
+ "${CMake_BINARY_DIR}/Tests/FindBoost/TestPython"
+ ${build_generator_args}
+ --build-project TestFindBoostPython
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+endif ()
diff --git a/Tests/FindBoost/Test/CMakeLists.txt b/Tests/FindBoost/Test/CMakeLists.txt
index ce50fc775..f60ccfa00 100644
--- a/Tests/FindBoost/Test/CMakeLists.txt
+++ b/Tests/FindBoost/Test/CMakeLists.txt
@@ -2,7 +2,20 @@ cmake_minimum_required(VERSION 3.1)
project(TestFindBoost CXX)
include(CTest)
-find_package(Boost REQUIRED COMPONENTS filesystem thread)
+set(Boost_NO_BOOST_CMAKE ON)
+find_package(Boost REQUIRED COMPONENTS filesystem thread
+ OPTIONAL_COMPONENTS program_options foobar)
+
+if(Boost_FOOBAR_FOUND)
+ message(FATAL_ERROR "Optional inexistent Boost component \"foobar\" found which is unexpected")
+endif(Boost_FOOBAR_FOUND)
+
+if(NOT Boost_PROGRAM_OPTIONS_FOUND)
+ message(FATAL_ERROR "Optional Boost component \"program_options\" not found which is unexpected")
+endif(NOT Boost_PROGRAM_OPTIONS_FOUND)
+
+add_definitions(-DCMAKE_EXPECTED_BOOST_VERSION="${Boost_VERSION}")
+add_definitions(-DCMAKE_EXPECTED_BOOST_VERSION_COMPONENTS="${Boost_VERSION_STRING}")
add_executable(test_boost_tgt main.cxx)
target_link_libraries(test_boost_tgt
diff --git a/Tests/FindBoost/Test/main.cxx b/Tests/FindBoost/Test/main.cxx
index 6e8b5da63..50ddadfba 100644
--- a/Tests/FindBoost/Test/main.cxx
+++ b/Tests/FindBoost/Test/main.cxx
@@ -20,5 +20,20 @@ int main()
boost::thread foo(threadmain);
foo.join();
- return 0;
+ int version = BOOST_VERSION;
+ int major = version / 100000;
+ int minor = version / 100 % 1000;
+ int patch = version % 100;
+ char version_string[100];
+ snprintf(version_string, sizeof(version_string), "%d.%d.%d", major, minor,
+ patch);
+ printf("Found Boost version %s, expected version %s\n", version_string,
+ CMAKE_EXPECTED_BOOST_VERSION_COMPONENTS);
+ int ret = strcmp(version_string, CMAKE_EXPECTED_BOOST_VERSION_COMPONENTS);
+ char raw_version_string[100];
+ snprintf(raw_version_string, sizeof(raw_version_string), "%d",
+ BOOST_VERSION);
+ printf("Found Boost version %s, expected version %s\n", raw_version_string,
+ CMAKE_EXPECTED_BOOST_VERSION);
+ return ret | strcmp(raw_version_string, CMAKE_EXPECTED_BOOST_VERSION);
}
diff --git a/Tests/FindBoost/TestFail/CMakeLists.txt b/Tests/FindBoost/TestFail/CMakeLists.txt
new file mode 100644
index 000000000..7c14a5990
--- /dev/null
+++ b/Tests/FindBoost/TestFail/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.1)
+project(TestFindBoost CXX)
+include(CTest)
+
+find_package(Boost REQUIRED COMPONENTS foobar filesystem thread)
+
+add_executable(test_boost_tgt main.cxx)
+target_link_libraries(test_boost_tgt
+ Boost::dynamic_linking
+ Boost::disable_autolinking
+ Boost::filesystem
+ Boost::thread)
+add_test(NAME test_boost_tgt COMMAND test_boost_tgt)
+
+add_executable(test_boost_var main.cxx)
+target_include_directories(test_boost_var PRIVATE ${Boost_INCLUDE_DIRS})
+target_link_libraries(test_boost_var PRIVATE ${Boost_FILESYSTEM_LIBRARIES} ${Boost_SYSTEM_LIBRARIES} ${Boost_THREAD_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+add_test(NAME test_boost_var COMMAND test_boost_var)
diff --git a/Tests/FindBoost/TestFail/main.cxx b/Tests/FindBoost/TestFail/main.cxx
new file mode 100644
index 000000000..6e8b5da63
--- /dev/null
+++ b/Tests/FindBoost/TestFail/main.cxx
@@ -0,0 +1,24 @@
+#include <boost/filesystem.hpp>
+#include <boost/thread.hpp>
+
+namespace {
+
+boost::mutex m1;
+boost::recursive_mutex m2;
+
+void threadmain()
+{
+ boost::lock_guard<boost::mutex> lock1(m1);
+ boost::lock_guard<boost::recursive_mutex> lock2(m2);
+
+ boost::filesystem::path p(boost::filesystem::current_path());
+}
+}
+
+int main()
+{
+ boost::thread foo(threadmain);
+ foo.join();
+
+ return 0;
+}
diff --git a/Tests/FindBoost/TestPython/CMakeLists.txt b/Tests/FindBoost/TestPython/CMakeLists.txt
new file mode 100644
index 000000000..4d137ca0d
--- /dev/null
+++ b/Tests/FindBoost/TestPython/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.14)
+project(TestFindBoostPython CXX)
+include(CTest)
+
+find_package(Boost OPTIONAL_COMPONENTS python27 python34 python35 python36 python37)
+
+set(FAILTEST TRUE)
+foreach (v IN ITEMS 27 34 35 36 37)
+ if (Boost_PYTHON${v}_FOUND)
+ set(FAILTEST FALSE)
+ break()
+ endif ()
+endforeach ()
+
+if (FAILTEST)
+ message(FATAL_ERROR "No Boost Python module found")
+endif ()
diff --git a/Tests/FindCURL/CMakeLists.txt b/Tests/FindCURL/CMakeLists.txt
new file mode 100644
index 000000000..0cfd629c9
--- /dev/null
+++ b/Tests/FindCURL/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindCURL.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindCURL/Test"
+ "${CMake_BINARY_DIR}/Tests/FindCURL/Test"
+ ${build_generator_args}
+ --build-project TestFindCURL
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindCURL/Test/CMakeLists.txt b/Tests/FindCURL/Test/CMakeLists.txt
new file mode 100644
index 000000000..cbf2866b0
--- /dev/null
+++ b/Tests/FindCURL/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.10)
+project(TestFindCURL C)
+include(CTest)
+
+find_package(CURL REQUIRED COMPONENTS HTTP)
+
+add_definitions(-DCMAKE_EXPECTED_CURL_VERSION="${CURL_VERSION_STRING}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt CURL::libcurl)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${CURL_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${CURL_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindCURL/Test/main.c b/Tests/FindCURL/Test/main.c
new file mode 100644
index 000000000..263775f95
--- /dev/null
+++ b/Tests/FindCURL/Test/main.c
@@ -0,0 +1,17 @@
+#include <curl/curl.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+ struct curl_slist* slist;
+
+ curl_global_init(0);
+
+ slist = curl_slist_append(NULL, "CMake");
+ curl_slist_free_all(slist);
+
+ curl_global_cleanup();
+
+ return 0;
+}
diff --git a/Tests/FindCups/CMakeLists.txt b/Tests/FindCups/CMakeLists.txt
new file mode 100644
index 000000000..5be1ac106
--- /dev/null
+++ b/Tests/FindCups/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindCups.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindCups/Test"
+ "${CMake_BINARY_DIR}/Tests/FindCups/Test"
+ ${build_generator_args}
+ --build-project FindCups
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindCups/Test/CMakeLists.txt b/Tests/FindCups/Test/CMakeLists.txt
new file mode 100644
index 000000000..9e90553fb
--- /dev/null
+++ b/Tests/FindCups/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.10)
+project(TestFindCups C)
+include(CTest)
+
+find_package(Cups REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_CUPS_VERSION="${CUPS_VERSION_STRING}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt Cups::Cups)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${CUPS_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${CUPS_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindCups/Test/main.c b/Tests/FindCups/Test/main.c
new file mode 100644
index 000000000..b69d621f7
--- /dev/null
+++ b/Tests/FindCups/Test/main.c
@@ -0,0 +1,12 @@
+#include <cups/cups.h>
+
+int main()
+{
+ int num_options = 0;
+ cups_option_t* options = NULL;
+
+ num_options = cupsAddOption(CUPS_COPIES, "1", num_options, &options);
+ cupsFreeOptions(num_options, options);
+
+ return 0;
+}
diff --git a/Tests/FindDoxygen/AllTarget/CMakeLists.txt b/Tests/FindDoxygen/AllTarget/CMakeLists.txt
new file mode 100644
index 000000000..69aa518c7
--- /dev/null
+++ b/Tests/FindDoxygen/AllTarget/CMakeLists.txt
@@ -0,0 +1,42 @@
+cmake_minimum_required(VERSION 3.10)
+project(TestFindDoxygen VERSION 1.0 LANGUAGES NONE)
+enable_testing()
+
+find_package(Doxygen REQUIRED)
+
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/main.cpp [[
+/**
+ * \file
+ * \brief One C++ file w/ sample Doxygen comment just to produce any docs...
+ */
+]])
+
+set(DOXYGEN_OUTPUT_DIRECTORY outDirWithout)
+file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/${DOXYGEN_OUTPUT_DIRECTORY})
+doxygen_add_docs(docsNoAll ${CMAKE_CURRENT_BINARY_DIR}/main.cpp)
+
+set(DOXYGEN_OUTPUT_DIRECTORY outDirWith)
+file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/${DOXYGEN_OUTPUT_DIRECTORY})
+doxygen_add_docs(docsWithAll ALL ${CMAKE_CURRENT_BINARY_DIR}/main.cpp)
+
+# Define tests cases that check whether targets were built
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dirExists.cmake [[
+cmake_minimum_required(VERSION 3.11)
+if(NOT EXISTS ${dirName})
+ message(FATAL_ERROR "Directory does not exist: ${dirName}")
+endif()
+]])
+
+add_test(NAME checkWith COMMAND
+ ${CMAKE_COMMAND}
+ -D dirName=${CMAKE_CURRENT_BINARY_DIR}/outDirWith
+ -P dirExists.cmake
+)
+add_test(NAME checkWithout COMMAND
+ ${CMAKE_COMMAND}
+ -D dirName=${CMAKE_CURRENT_BINARY_DIR}/outDirWithout
+ -P dirExists.cmake
+)
+set_tests_properties(checkWithout PROPERTIES
+ WILL_FAIL TRUE
+)
diff --git a/Tests/FindDoxygen/CMakeLists.txt b/Tests/FindDoxygen/CMakeLists.txt
index daceaa3e9..41e6255eb 100644
--- a/Tests/FindDoxygen/CMakeLists.txt
+++ b/Tests/FindDoxygen/CMakeLists.txt
@@ -8,6 +8,36 @@ add_test(NAME FindDoxygen.SimpleTest COMMAND
--build-options ${build_options}
)
+add_test(NAME FindDoxygen.QuotingTest COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindDoxygen/QuotingTest"
+ "${CMake_BINARY_DIR}/Tests/FindDoxygen/QuotingTest"
+ --build-target allDocTargets
+ ${build_generator_args}
+ --build-options ${build_options}
+)
+
+add_test(NAME FindDoxygen.AllTarget COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindDoxygen/AllTarget"
+ "${CMake_BINARY_DIR}/Tests/FindDoxygen/AllTarget"
+ ${build_generator_args}
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+)
+
+add_test(NAME FindDoxygen.StampFile COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindDoxygen/StampFile"
+ "${CMake_BINARY_DIR}/Tests/FindDoxygen/StampFile"
+ --build-target allDocTargets
+ ${build_generator_args}
+ --build-options ${build_options}
+)
+
if(CMake_TEST_FindDoxygen_Dot)
add_test(NAME FindDoxygen.DotComponentTest COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
diff --git a/Tests/FindDoxygen/QuotingTest/CMakeLists.txt b/Tests/FindDoxygen/QuotingTest/CMakeLists.txt
new file mode 100644
index 000000000..26bf090db
--- /dev/null
+++ b/Tests/FindDoxygen/QuotingTest/CMakeLists.txt
@@ -0,0 +1,34 @@
+cmake_minimum_required(VERSION 3.10)
+project(TestFindDoxygen VERSION 1.0 LANGUAGES NONE)
+
+find_package(Doxygen REQUIRED)
+
+set(DOXYGEN_PROJECT_BRIEF "String with spaces")
+set(DOXYGEN_ALIASES
+ [[somealias="@some_command param"]]
+ "anotherAlias=@foobar"
+)
+
+set(DOXYGEN_VERBATIM_VARS DOXYGEN_ALIASES)
+
+doxygen_add_docs(docsQuoting)
+if(NOT EXISTS "${PROJECT_BINARY_DIR}/Doxyfile.docsQuoting")
+ message(FATAL_ERROR "Missing generated file: Doxyfile.docsQuoting")
+endif()
+
+file(STRINGS "${PROJECT_BINARY_DIR}/Doxyfile.docsQuoting" matches
+ REGEX [[^PROJECT_BRIEF *= *"String with spaces"]]
+)
+if(NOT matches)
+ message(FATAL_ERROR "PROJECT_BRIEF does not match expected contents")
+endif()
+
+file(STRINGS "${PROJECT_BINARY_DIR}/Doxyfile.docsQuoting" matches
+ REGEX [[^ALIASES *= *somealias="@some_command param" anotherAlias=@foobar]]
+)
+if(NOT matches)
+ message(FATAL_ERROR "ALIASES does not match expected contents")
+endif()
+
+add_custom_target(allDocTargets)
+add_dependencies(allDocTargets docsQuoting)
diff --git a/Tests/FindDoxygen/StampFile/CMakeLists.txt b/Tests/FindDoxygen/StampFile/CMakeLists.txt
new file mode 100644
index 000000000..2d0654058
--- /dev/null
+++ b/Tests/FindDoxygen/StampFile/CMakeLists.txt
@@ -0,0 +1,24 @@
+cmake_minimum_required(VERSION 3.8)
+project(TestFindDoxygen VERSION 1.0 LANGUAGES NONE)
+
+find_package(Doxygen REQUIRED)
+
+doxygen_add_docs(docsWithoutFilesWithStamp USE_STAMP_FILE)
+if(NOT EXISTS "${PROJECT_BINARY_DIR}/Doxyfile.docsWithoutFilesWithStamp")
+ message(FATAL_ERROR "Missing generated file: Doxyfile.docsWithoutFilesWithStamp")
+endif()
+if(NOT TARGET docsWithoutFilesWithStamp)
+ message(FATAL_ERROR "Target docsWithoutFilesWithStamp not created")
+endif()
+
+doxygen_add_docs(docsWithFilesWithStamp main.cpp main2.cpp USE_STAMP_FILE)
+if(NOT EXISTS "${PROJECT_BINARY_DIR}/Doxyfile.docsWithFilesWithStamp")
+ message(FATAL_ERROR "Missing generated file: Doxyfile.docsWithFilesWithStamp")
+endif()
+if(NOT TARGET docsWithFilesWithStamp)
+ message(FATAL_ERROR "Target docsWithFilesWithStamp not created")
+endif()
+
+
+add_custom_target(allDocTargets)
+add_dependencies(allDocTargets docsWithoutFilesWithStamp docsWithFilesWithStamp)
diff --git a/Tests/FindDoxygen/StampFile/main.cpp b/Tests/FindDoxygen/StampFile/main.cpp
new file mode 100644
index 000000000..925f0afe0
--- /dev/null
+++ b/Tests/FindDoxygen/StampFile/main.cpp
@@ -0,0 +1,4 @@
+/**
+ * \file
+ * \brief One C++ file w/ sample Doxygen comment just to produce any docs...
+ */
diff --git a/Tests/FindDoxygen/StampFile/main2.cpp b/Tests/FindDoxygen/StampFile/main2.cpp
new file mode 100644
index 000000000..925f0afe0
--- /dev/null
+++ b/Tests/FindDoxygen/StampFile/main2.cpp
@@ -0,0 +1,4 @@
+/**
+ * \file
+ * \brief One C++ file w/ sample Doxygen comment just to produce any docs...
+ */
diff --git a/Tests/FindEXPAT/CMakeLists.txt b/Tests/FindEXPAT/CMakeLists.txt
new file mode 100644
index 000000000..a74174a30
--- /dev/null
+++ b/Tests/FindEXPAT/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindEXPAT.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindEXPAT/Test"
+ "${CMake_BINARY_DIR}/Tests/FindEXPAT/Test"
+ ${build_generator_args}
+ --build-project TestFindEXPAT
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindEXPAT/Test/CMakeLists.txt b/Tests/FindEXPAT/Test/CMakeLists.txt
new file mode 100644
index 000000000..5681f7471
--- /dev/null
+++ b/Tests/FindEXPAT/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.9)
+project(TestFindEXPAT C)
+include(CTest)
+
+find_package(EXPAT REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_EXPAT_VERSION="${EXPAT_VERSION_STRING}")
+
+add_executable(testexpat_tgt main.c)
+target_link_libraries(testexpat_tgt EXPAT::EXPAT)
+add_test(NAME testexpat_tgt COMMAND testexpat_tgt)
+
+add_executable(testexpat_var main.c)
+target_include_directories(testexpat_var PRIVATE ${EXPAT_INCLUDE_DIRS})
+target_link_libraries(testexpat_var PRIVATE ${EXPAT_LIBRARIES})
+add_test(NAME testexpat_var COMMAND testexpat_var)
diff --git a/Tests/FindEXPAT/Test/main.c b/Tests/FindEXPAT/Test/main.c
new file mode 100644
index 000000000..94ee3ef24
--- /dev/null
+++ b/Tests/FindEXPAT/Test/main.c
@@ -0,0 +1,21 @@
+#include <expat.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main()
+{
+ XML_Expat_Version expat_version;
+ char expat_version_string[16];
+
+ expat_version = XML_ExpatVersionInfo();
+
+ snprintf(expat_version_string, 16, "%i.%i.%i", expat_version.major,
+ expat_version.minor, expat_version.micro);
+
+ if (strcmp(expat_version_string, CMAKE_EXPECTED_EXPAT_VERSION) != 0) {
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/Tests/FindEnvModules/CMakeLists.txt b/Tests/FindEnvModules/CMakeLists.txt
new file mode 100644
index 000000000..95b7d1ddb
--- /dev/null
+++ b/Tests/FindEnvModules/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_test(FindEnvModules.Test ${CMAKE_CMAKE_COMMAND}
+ -P ${CMAKE_CURRENT_LIST_DIR}/EnvModules.cmake
+)
diff --git a/Tests/FindEnvModules/EnvModules.cmake b/Tests/FindEnvModules/EnvModules.cmake
new file mode 100644
index 000000000..21b0042b4
--- /dev/null
+++ b/Tests/FindEnvModules/EnvModules.cmake
@@ -0,0 +1,33 @@
+find_package(EnvModules REQUIRED)
+message("module purge")
+env_module(COMMAND purge RESULT_VARIABLE ret_var)
+if(NOT ret_var EQUAL 0)
+ message(FATAL_ERROR "module(purge) returned ${ret_var}")
+endif()
+
+message("module avail")
+env_module_avail(avail_mods)
+foreach(mod IN LISTS avail_mods)
+ message(" ${mod}")
+endforeach()
+
+if(avail_mods)
+ list(GET avail_mods 0 mod0)
+ message("module load ${mod0}")
+ env_module(load ${mod0})
+
+ message("module list")
+ env_module_list(loaded_mods)
+ set(mod0_found FALSE)
+ foreach(mod IN LISTS loaded_mods)
+ message(" ${mod}")
+ if(NOT mod0_found AND mod MATCHES "^${mod0}")
+ set(mod0_found ${mod})
+ endif()
+ endforeach()
+
+ if(NOT mod0_found)
+ message(FATAL_ERROR "Requested module ${mod0} not found in loaded modules")
+ endif()
+ message("module ${mod0} found loaded as ${mod0_found}")
+endif()
diff --git a/Tests/FindFontconfig/CMakeLists.txt b/Tests/FindFontconfig/CMakeLists.txt
new file mode 100644
index 000000000..d683d8746
--- /dev/null
+++ b/Tests/FindFontconfig/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindFontconfig.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindFontconfig/Test"
+ "${CMake_BINARY_DIR}/Tests/FindFontconfig/Test"
+ ${build_generator_args}
+ --build-project TestFindFontconfig
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindFontconfig/Test/CMakeLists.txt b/Tests/FindFontconfig/Test/CMakeLists.txt
new file mode 100644
index 000000000..36c76b104
--- /dev/null
+++ b/Tests/FindFontconfig/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.10)
+project(TestFindFontconfig C)
+include(CTest)
+
+find_package(Fontconfig REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_FONTCONFIG_VERSION="${Fontconfig_VERSION}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt Fontconfig::Fontconfig)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${Fontconfig_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${Fontconfig_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindFontconfig/Test/main.c b/Tests/FindFontconfig/Test/main.c
new file mode 100644
index 000000000..c5b596304
--- /dev/null
+++ b/Tests/FindFontconfig/Test/main.c
@@ -0,0 +1,17 @@
+#include <assert.h>
+#include <fontconfig/fontconfig.h>
+#include <stdio.h>
+#include <string.h>
+
+int main()
+{
+ FcInit();
+ printf("Found Fontconfig.\n");
+
+ char fontconfig_version_string[16];
+ snprintf(fontconfig_version_string, 16, "%i.%i.%i", FC_MAJOR, FC_MINOR,
+ FC_REVISION);
+ assert(
+ strcmp(fontconfig_version_string, CMAKE_EXPECTED_FONTCONFIG_VERSION) == 0);
+ return 0;
+}
diff --git a/Tests/FindFreetype/CMakeLists.txt b/Tests/FindFreetype/CMakeLists.txt
new file mode 100644
index 000000000..490c25bd6
--- /dev/null
+++ b/Tests/FindFreetype/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindFreetype.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindFreetype/Test"
+ "${CMake_BINARY_DIR}/Tests/FindFreetype/Test"
+ ${build_generator_args}
+ --build-project TestFindFreetype
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindFreetype/Test/CMakeLists.txt b/Tests/FindFreetype/Test/CMakeLists.txt
new file mode 100644
index 000000000..bc869a13f
--- /dev/null
+++ b/Tests/FindFreetype/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.9)
+project(TestFindFreetype C)
+include(CTest)
+
+find_package(Freetype REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_FREETYPE_VERSION="${FREETYPE_VERSION_STRING}")
+
+add_executable(testfreetype_tgt main.c)
+target_link_libraries(testfreetype_tgt Freetype::Freetype)
+add_test(NAME testfreetype_tgt COMMAND testfreetype_tgt)
+
+add_executable(testfreetype_var main.c)
+target_include_directories(testfreetype_var PRIVATE ${FREETYPE_INCLUDE_DIRS})
+target_link_libraries(testfreetype_var PRIVATE ${FREETYPE_LIBRARIES})
+add_test(NAME testfreetype_var COMMAND testfreetype_var)
diff --git a/Tests/FindFreetype/Test/main.c b/Tests/FindFreetype/Test/main.c
new file mode 100644
index 000000000..bb838a5ce
--- /dev/null
+++ b/Tests/FindFreetype/Test/main.c
@@ -0,0 +1,34 @@
+#include <ft2build.h>
+#include <stdlib.h>
+#include FT_FREETYPE_H
+#include <string.h>
+
+int main()
+{
+ FT_Library library;
+ FT_Error error;
+
+ error = FT_Init_FreeType(&library);
+ if (error) {
+ return EXIT_FAILURE;
+ }
+
+ FT_Int major = 0;
+ FT_Int minor = 0;
+ FT_Int patch = 0;
+ FT_Library_Version(library, &major, &minor, &patch);
+
+ char ft_version_string[16];
+ snprintf(ft_version_string, 16, "%i.%i.%i", major, minor, patch);
+
+ if (strcmp(ft_version_string, CMAKE_EXPECTED_FREETYPE_VERSION) != 0) {
+ return EXIT_FAILURE;
+ }
+
+ error = FT_Done_FreeType(library);
+ if (error) {
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/Tests/FindGDAL/CMakeLists.txt b/Tests/FindGDAL/CMakeLists.txt
new file mode 100644
index 000000000..12f95e11e
--- /dev/null
+++ b/Tests/FindGDAL/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindGDAL.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindGDAL/Test"
+ "${CMake_BINARY_DIR}/Tests/FindGDAL/Test"
+ ${build_generator_args}
+ --build-project TestFindGDAL
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindGDAL/Test/CMakeLists.txt b/Tests/FindGDAL/Test/CMakeLists.txt
new file mode 100644
index 000000000..8bdc57c91
--- /dev/null
+++ b/Tests/FindGDAL/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.10)
+project(TestFindGDAL C)
+include(CTest)
+
+find_package(GDAL REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_GDAL_VERSION="${GDAL_VERSION}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt GDAL::GDAL)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${GDAL_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${GDAL_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindGDAL/Test/main.c b/Tests/FindGDAL/Test/main.c
new file mode 100644
index 000000000..7b31a1362
--- /dev/null
+++ b/Tests/FindGDAL/Test/main.c
@@ -0,0 +1,11 @@
+#include <gdal.h>
+#include <stdio.h>
+#include <string.h>
+
+int main()
+{
+ printf("Found GDAL version %s, expected version %s\n", GDAL_RELEASE_NAME,
+ CMAKE_EXPECTED_GDAL_VERSION);
+ GDALAllRegister();
+ return strcmp(GDAL_RELEASE_NAME, CMAKE_EXPECTED_GDAL_VERSION);
+}
diff --git a/Tests/FindGIF/CMakeLists.txt b/Tests/FindGIF/CMakeLists.txt
new file mode 100644
index 000000000..bac64afd0
--- /dev/null
+++ b/Tests/FindGIF/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindGIF.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindGIF/Test"
+ "${CMake_BINARY_DIR}/Tests/FindGIF/Test"
+ ${build_generator_args}
+ --build-project TestFindGIF
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindGIF/Test/CMakeLists.txt b/Tests/FindGIF/Test/CMakeLists.txt
new file mode 100644
index 000000000..961e636fa
--- /dev/null
+++ b/Tests/FindGIF/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.4)
+project(TestFindGIF C)
+include(CTest)
+
+find_package(GIF REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_GIF_VERSION="${GIF_VERSION}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt GIF::GIF)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${GIF_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${GIF_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindGIF/Test/main.c b/Tests/FindGIF/Test/main.c
new file mode 100644
index 000000000..656a99c04
--- /dev/null
+++ b/Tests/FindGIF/Test/main.c
@@ -0,0 +1,34 @@
+#include <assert.h>
+#include <gif_lib.h>
+#include <stdio.h>
+#include <string.h>
+
+// GIFLIB before version 5 didn't know this macro
+#ifndef GIFLIB_MAJOR
+# define GIFLIB_MAJOR 4
+#endif
+
+int main()
+{
+ // because of the API changes we have to test different functions depending
+ // on the version of GIFLIB
+#if GIFLIB_MAJOR >= 5
+ // test the linker
+ GifErrorString(D_GIF_SUCCEEDED);
+
+ // check the version
+ char gif_version_string[16];
+ snprintf(gif_version_string, 16, "%i.%i.%i", GIFLIB_MAJOR, GIFLIB_MINOR,
+ GIFLIB_RELEASE);
+
+ assert(strcmp(gif_version_string, CMAKE_EXPECTED_GIF_VERSION) == 0);
+#else
+ // test the linker
+ GifLastError();
+
+ // unfortunately there is no way to check the version in older version of
+ // GIFLIB
+#endif
+
+ return 0;
+}
diff --git a/Tests/FindGLEW/CMakeLists.txt b/Tests/FindGLEW/CMakeLists.txt
new file mode 100644
index 000000000..ff42bcec1
--- /dev/null
+++ b/Tests/FindGLEW/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindGLEW.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindGLEW/Test"
+ "${CMake_BINARY_DIR}/Tests/FindGLEW/Test"
+ ${build_generator_args}
+ --build-project TestFindGLEW
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindGLEW/Test/CMakeLists.txt b/Tests/FindGLEW/Test/CMakeLists.txt
new file mode 100644
index 000000000..954ee1092
--- /dev/null
+++ b/Tests/FindGLEW/Test/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.1)
+project(TestFindGLEW LANGUAGES CXX)
+include(CTest)
+
+find_package(GLEW REQUIRED)
+
+add_executable(test_glew_shared_tgt main.cpp)
+target_link_libraries(test_glew_shared_tgt GLEW::GLEW)
+add_test(NAME test_glew_shared_tgt COMMAND test_glew_shared_tgt)
+
+add_executable(test_glew_generic_tgt main.cpp)
+target_link_libraries(test_glew_generic_tgt GLEW::glew)
+add_test(NAME test_glew_generic_tgt COMMAND test_glew_generic_tgt)
+
+add_executable(test_glew_var main.cpp)
+target_include_directories(test_glew_var PRIVATE ${GLEW_INCLUDE_DIRS})
+target_link_libraries(test_glew_var PRIVATE ${GLEW_LIBRARIES})
+add_test(NAME test_glew_var COMMAND test_glew_var)
diff --git a/Tests/FindGLEW/Test/main.cpp b/Tests/FindGLEW/Test/main.cpp
new file mode 100644
index 000000000..4a108ad24
--- /dev/null
+++ b/Tests/FindGLEW/Test/main.cpp
@@ -0,0 +1,8 @@
+#include <GL/glew.h>
+
+int main()
+{
+ GLenum init_return = glewInit();
+
+ return (init_return == GLEW_OK);
+}
diff --git a/Tests/FindGSL/rng/main.cc b/Tests/FindGSL/rng/main.cc
index af131255a..050caacc7 100644
--- a/Tests/FindGSL/rng/main.cc
+++ b/Tests/FindGSL/rng/main.cc
@@ -1,6 +1,7 @@
-#include "gsl/gsl_rng.h"
#include <math.h>
+#include "gsl/gsl_rng.h"
+
int main()
{
// return code
diff --git a/Tests/FindGTK2/cairomm/main.cpp b/Tests/FindGTK2/cairomm/main.cpp
index 1a669c36e..48e5e3930 100644
--- a/Tests/FindGTK2/cairomm/main.cpp
+++ b/Tests/FindGTK2/cairomm/main.cpp
@@ -5,16 +5,16 @@
* et. al.
*/
#if defined(_MSC_VER)
-#define _USE_MATH_DEFINES
+# define _USE_MATH_DEFINES
#endif
-#include <cairomm/context.h>
-#include <cairomm/surface.h>
-#include <cairommconfig.h>
+#include <cmath>
#include <iostream>
#include <string>
-#include <cmath>
+#include <cairomm/context.h>
+#include <cairomm/surface.h>
+#include <cairommconfig.h>
int main()
{
diff --git a/Tests/FindGTK2/gtkmm/helloworld.cpp b/Tests/FindGTK2/gtkmm/helloworld.cpp
index 5f4e0aece..45c942227 100644
--- a/Tests/FindGTK2/gtkmm/helloworld.cpp
+++ b/Tests/FindGTK2/gtkmm/helloworld.cpp
@@ -1,4 +1,5 @@
#include "helloworld.h"
+
#include <iostream>
HelloWorld::HelloWorld()
diff --git a/Tests/FindGTK2/gtkmm/main.cpp b/Tests/FindGTK2/gtkmm/main.cpp
index 1637da28e..29e23fd80 100644
--- a/Tests/FindGTK2/gtkmm/main.cpp
+++ b/Tests/FindGTK2/gtkmm/main.cpp
@@ -1,6 +1,7 @@
-#include "helloworld.h"
#include <gtkmm.h>
+#include "helloworld.h"
+
int main(int argc, char* argv[])
{
Gtk::Main kit(argc, argv);
diff --git a/Tests/FindGTK2/sigc++/main.cpp b/Tests/FindGTK2/sigc++/main.cpp
index e56b91037..4dae4f433 100644
--- a/Tests/FindGTK2/sigc++/main.cpp
+++ b/Tests/FindGTK2/sigc++/main.cpp
@@ -1,6 +1,7 @@
// Taken from https://developer.gnome.org/libsigc++-tutorial/stable/ch02.html
#include <iostream>
+
#include <sigc++/sigc++.h>
class AlienDetector
diff --git a/Tests/FindGTest/Test/main.cxx b/Tests/FindGTest/Test/main.cxx
index 0572a5ddc..19d29675b 100644
--- a/Tests/FindGTest/Test/main.cxx
+++ b/Tests/FindGTest/Test/main.cxx
@@ -2,5 +2,7 @@
TEST(FindCMake, LinksAndRuns)
{
+ using namespace testing;
+ EXPECT_FALSE(GTEST_FLAG(list_tests));
ASSERT_TRUE(true);
}
diff --git a/Tests/FindGit/CMakeLists.txt b/Tests/FindGit/CMakeLists.txt
new file mode 100644
index 000000000..5d061f469
--- /dev/null
+++ b/Tests/FindGit/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindGit.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindGit/Test"
+ "${CMake_BINARY_DIR}/Tests/FindGit/Test"
+ ${build_generator_args}
+ --build-project TestFindGit
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindGit/Test/CMakeLists.txt b/Tests/FindGit/Test/CMakeLists.txt
new file mode 100644
index 000000000..26fb372e6
--- /dev/null
+++ b/Tests/FindGit/Test/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.12)
+project(TestFindGit NONE)
+include(CTest)
+
+find_package(Git REQUIRED)
+
+add_test(NAME test_git
+ COMMAND ${CMAKE_COMMAND}
+ "-DGIT_EXECUTABLE=${GIT_EXECUTABLE}"
+ "-DGIT_EXECUTABLE_TARGET=$<TARGET_FILE:Git::Git>"
+ "-DGIT_VERSION_STRING=${GIT_VERSION_STRING}"
+ -P "${CMAKE_CURRENT_LIST_DIR}/RunGit.cmake"
+ )
diff --git a/Tests/FindGit/Test/RunGit.cmake b/Tests/FindGit/Test/RunGit.cmake
new file mode 100644
index 000000000..f798cd355
--- /dev/null
+++ b/Tests/FindGit/Test/RunGit.cmake
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 3.12)
+
+function(run_git exe exe_display)
+ execute_process(COMMAND ${exe} --version
+ OUTPUT_VARIABLE output
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ RESULT_VARIABLE result
+ )
+
+ if(NOT result EQUAL 0)
+ message(SEND_ERROR "Result of ${exe_display} --version is ${result}, should be 0")
+ endif()
+
+ if(NOT output STREQUAL "git version ${GIT_VERSION_STRING}")
+ message(SEND_ERROR "Output of ${exe_display} --version is \"${output}\", should be \"git version ${GIT_VERSION_STRING}\"")
+ endif()
+endfunction()
+
+run_git("${GIT_EXECUTABLE}" "\${GIT_EXECUTABLE}")
+run_git("${GIT_EXECUTABLE_TARGET}" "Git::Git")
diff --git a/Tests/FindGnuTLS/CMakeLists.txt b/Tests/FindGnuTLS/CMakeLists.txt
new file mode 100644
index 000000000..059ac7b0f
--- /dev/null
+++ b/Tests/FindGnuTLS/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindGnuTLS.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindGnuTLS/Test"
+ "${CMake_BINARY_DIR}/Tests/FindGnuTLS/Test"
+ ${build_generator_args}
+ --build-project TestFindGnuTLS
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindGnuTLS/Test/CMakeLists.txt b/Tests/FindGnuTLS/Test/CMakeLists.txt
new file mode 100644
index 000000000..c5a9819b2
--- /dev/null
+++ b/Tests/FindGnuTLS/Test/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.4)
+project(TestFindGnuTLS C)
+include(CTest)
+
+find_package(GnuTLS REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_GNUTLS_VERSION="${GNUTLS_VERSION}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt GnuTLS::GnuTLS)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${GNUTLS_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${GNUTLS_LIBRARIES})
+target_compile_definitions(test_var PRIVATE ${GNUTLS_DEFINITIONS})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindGnuTLS/Test/main.c b/Tests/FindGnuTLS/Test/main.c
new file mode 100644
index 000000000..110535856
--- /dev/null
+++ b/Tests/FindGnuTLS/Test/main.c
@@ -0,0 +1,21 @@
+#include <assert.h>
+#include <gnutls/gnutls.h>
+#include <stdio.h>
+#include <string.h>
+
+int main()
+{
+ // test the linker
+ gnutls_session_t session;
+ if (gnutls_init(&session, GNUTLS_CLIENT)) {
+ gnutls_deinit(session);
+ }
+
+ // check the version
+ char gnutls_version_string[16];
+ snprintf(gnutls_version_string, 16, "%i.%i.%i", GNUTLS_VERSION_MAJOR,
+ GNUTLS_VERSION_MINOR, GNUTLS_VERSION_PATCH);
+ assert(strcmp(gnutls_version_string, CMAKE_EXPECTED_GNUTLS_VERSION) == 0);
+
+ return 0;
+}
diff --git a/Tests/FindICU/Test/main.cpp b/Tests/FindICU/Test/main.cpp
index 64cc5d375..606e94ef8 100644
--- a/Tests/FindICU/Test/main.cpp
+++ b/Tests/FindICU/Test/main.cpp
@@ -1,10 +1,9 @@
-#include <unicode/uclean.h>
-#include <unicode/ustring.h>
-#include <unicode/utypes.h>
-
#include <unicode/ucal.h>
+#include <unicode/uclean.h>
#include <unicode/ucnv.h>
#include <unicode/udat.h>
+#include <unicode/ustring.h>
+#include <unicode/utypes.h>
int main()
{
diff --git a/Tests/FindIconv/CMakeLists.txt b/Tests/FindIconv/CMakeLists.txt
new file mode 100644
index 000000000..b205b8056
--- /dev/null
+++ b/Tests/FindIconv/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindIconv.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindIconv/Test"
+ "${CMake_BINARY_DIR}/Tests/FindIconv/Test"
+ ${build_generator_args}
+ --build-project TestFindIconv
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindIconv/Test/CMakeLists.txt b/Tests/FindIconv/Test/CMakeLists.txt
new file mode 100644
index 000000000..a6243f53f
--- /dev/null
+++ b/Tests/FindIconv/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.10)
+project(TestFindIconv CXX)
+include(CTest)
+
+find_package(Iconv REQUIRED)
+
+add_executable(test_iconv_tgt main.cxx)
+target_link_libraries(test_iconv_tgt Iconv::Iconv)
+target_compile_features(test_iconv_tgt PRIVATE cxx_std_11)
+add_test(NAME test_iconv_tgt COMMAND test_iconv_tgt)
+
+add_executable(test_iconv_var main.cxx)
+target_include_directories(test_iconv_var PRIVATE ${Iconv_INCLUDE_DIRS})
+target_link_libraries(test_iconv_var PRIVATE ${Iconv_LIBRARIES})
+target_compile_features(test_iconv_var PRIVATE cxx_std_11)
+add_test(NAME test_iconv_var COMMAND test_iconv_var)
diff --git a/Tests/FindIconv/Test/main.cxx b/Tests/FindIconv/Test/main.cxx
new file mode 100644
index 000000000..415ee3768
--- /dev/null
+++ b/Tests/FindIconv/Test/main.cxx
@@ -0,0 +1,52 @@
+extern "C" {
+#include <iconv.h>
+}
+#include <array>
+#include <cstddef>
+#include <cstdlib>
+#include <iostream>
+#include <string>
+#include <system_error>
+
+class iconv_desc
+{
+private:
+ iconv_t iconvd_;
+
+public:
+ iconv_desc(const std::string& tocode, const std::string& fromcode)
+ {
+ iconvd_ = iconv_open(tocode.c_str(), fromcode.c_str());
+ if (iconvd_ == reinterpret_cast<iconv_t>(-1))
+ throw std::system_error(errno, std::system_category());
+ }
+
+ ~iconv_desc() { iconv_close(iconvd_); }
+
+ operator iconv_t() { return this->iconvd_; }
+};
+
+int main()
+{
+ try {
+ auto conv_d = iconv_desc{ "ISO-8859-1", "UTF-8" };
+ auto from_str = std::array<char, 10>{ u8"a\xC3\xA4o\xC3\xB6u\xC3\xBC" };
+ auto to_str = std::array<char, 7>{};
+
+ auto from_str_ptr = from_str.data();
+ auto from_len = from_str.size();
+ auto to_str_ptr = to_str.data();
+ auto to_len = to_str.size();
+ const auto iconv_ret =
+ iconv(conv_d, &from_str_ptr, &from_len, &to_str_ptr, &to_len);
+ if (iconv_ret == static_cast<std::size_t>(-1))
+ throw std::system_error(errno, std::system_category());
+ std::cout << '\'' << from_str.data() << "\' converted to \'"
+ << to_str.data() << '\'' << std::endl;
+ return EXIT_SUCCESS;
+ } catch (const std::system_error& ex) {
+ std::cerr << "ERROR: " << ex.code() << '\n'
+ << ex.code().message() << std::endl;
+ }
+ return EXIT_FAILURE;
+}
diff --git a/Tests/FindJPEG/CMakeLists.txt b/Tests/FindJPEG/CMakeLists.txt
new file mode 100644
index 000000000..c8663c560
--- /dev/null
+++ b/Tests/FindJPEG/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindJPEG.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindJPEG/Test"
+ "${CMake_BINARY_DIR}/Tests/FindJPEG/Test"
+ ${build_generator_args}
+ --build-project TestFindJPEG
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindJPEG/Test/CMakeLists.txt b/Tests/FindJPEG/Test/CMakeLists.txt
new file mode 100644
index 000000000..912c7a19b
--- /dev/null
+++ b/Tests/FindJPEG/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.1)
+project(TestFindJPEG C)
+include(CTest)
+
+find_package(JPEG)
+
+add_definitions(-DCMAKE_EXPECTED_JPEG_VERSION=${JPEG_VERSION})
+
+add_executable(test_jpeg_tgt main.c)
+target_link_libraries(test_jpeg_tgt JPEG::JPEG)
+add_test(NAME test_jpeg_tgt COMMAND test_jpeg_tgt)
+
+add_executable(test_jpeg_var main.c)
+target_include_directories(test_jpeg_var PRIVATE ${JPEG_INCLUDE_DIRS})
+target_link_libraries(test_jpeg_var PRIVATE ${JPEG_LIBRARIES})
+add_test(NAME test_jpeg_var COMMAND test_jpeg_var)
diff --git a/Tests/FindJPEG/Test/main.c b/Tests/FindJPEG/Test/main.c
new file mode 100644
index 000000000..5a67faaee
--- /dev/null
+++ b/Tests/FindJPEG/Test/main.c
@@ -0,0 +1,17 @@
+#include <assert.h>
+// clang-format off
+#include <stdio.h>
+#include <jpeglib.h>
+// clang-format on
+
+int main()
+{
+ /* Without any JPEG file to open, test that the call fails as
+ expected. This tests that linking worked. */
+ struct jpeg_decompress_struct cinfo;
+ struct jpeg_error_mgr jerr;
+ cinfo.err = jpeg_std_error(&jerr);
+ jpeg_create_decompress(&cinfo);
+
+ return (JPEG_LIB_VERSION != CMAKE_EXPECTED_JPEG_VERSION);
+}
diff --git a/Tests/FindLTTngUST/Test/main.c b/Tests/FindLTTngUST/Test/main.c
index 1f313c1a9..01d73cb73 100644
--- a/Tests/FindLTTngUST/Test/main.c
+++ b/Tests/FindLTTngUST/Test/main.c
@@ -4,11 +4,11 @@
#include <string.h>
#ifdef CMAKE_LTTNGUST_HAS_TRACEF
-#include <lttng/tracef.h>
+# include <lttng/tracef.h>
#endif
#ifdef CMAKE_LTTNGUST_HAS_TRACELOG
-#include <lttng/tracelog.h>
+# include <lttng/tracelog.h>
#endif
int main(void)
diff --git a/Tests/FindLibLZMA/CMakeLists.txt b/Tests/FindLibLZMA/CMakeLists.txt
new file mode 100644
index 000000000..6dff0ef22
--- /dev/null
+++ b/Tests/FindLibLZMA/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindLibLZMA.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindLibLZMA/Test"
+ "${CMake_BINARY_DIR}/Tests/FindLibLZMA/Test"
+ ${build_generator_args}
+ --build-project TestFindLibLZMA
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindLibLZMA/Test/CMakeLists.txt b/Tests/FindLibLZMA/Test/CMakeLists.txt
new file mode 100644
index 000000000..c59dcdbdd
--- /dev/null
+++ b/Tests/FindLibLZMA/Test/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.4)
+project(TestFindLZMA C)
+include(CTest)
+
+find_package(LibLZMA REQUIRED)
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt LibLZMA::LibLZMA)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${LIBLZMA_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${LIBLZMA_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindLibLZMA/Test/main.c b/Tests/FindLibLZMA/Test/main.c
new file mode 100644
index 000000000..06e806554
--- /dev/null
+++ b/Tests/FindLibLZMA/Test/main.c
@@ -0,0 +1,15 @@
+#include <assert.h>
+#include <lzma.h>
+#include <string.h>
+
+static const uint8_t test_string[9] = "123456789";
+
+int main()
+{
+ static const uint32_t test_vector = 0xCBF43926;
+
+ uint32_t crc = lzma_crc32(test_string, sizeof(test_string), 0);
+ assert(crc == test_vector);
+
+ return 0;
+}
diff --git a/Tests/FindLibXml2/CMakeLists.txt b/Tests/FindLibXml2/CMakeLists.txt
new file mode 100644
index 000000000..6c2464fd9
--- /dev/null
+++ b/Tests/FindLibXml2/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindLibXml2.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindLibXml2/Test"
+ "${CMake_BINARY_DIR}/Tests/FindLibXml2/Test"
+ ${build_generator_args}
+ --build-project TestFindLibXml2
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindLibXml2/Test/CMakeLists.txt b/Tests/FindLibXml2/Test/CMakeLists.txt
new file mode 100644
index 000000000..df5d8c3d2
--- /dev/null
+++ b/Tests/FindLibXml2/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.4)
+project(TestFindLibXml2 C)
+include(CTest)
+
+find_package(LibXml2 REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_LibXml2_VERSION="${LIBXML2_VERSION_STRING}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt LibXml2::LibXml2)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${LIBXML2_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${LIBXML2_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindLibXml2/Test/main.c b/Tests/FindLibXml2/Test/main.c
new file mode 100644
index 000000000..264f07d03
--- /dev/null
+++ b/Tests/FindLibXml2/Test/main.c
@@ -0,0 +1,19 @@
+#include <assert.h>
+#include <libxml/tree.h>
+#include <string.h>
+
+int main()
+{
+ xmlDoc* doc;
+
+ xmlInitParser();
+
+ doc = xmlNewDoc(BAD_CAST "1.0");
+ xmlFreeDoc(doc);
+
+ assert(strstr(CMAKE_EXPECTED_LibXml2_VERSION, LIBXML_DOTTED_VERSION));
+
+ xmlCleanupParser();
+
+ return 0;
+}
diff --git a/Tests/FindLibinput/CMakeLists.txt b/Tests/FindLibinput/CMakeLists.txt
new file mode 100644
index 000000000..8538a55ed
--- /dev/null
+++ b/Tests/FindLibinput/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindLibinput.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindLibinput/Test"
+ "${CMake_BINARY_DIR}/Tests/FindLibinput/Test"
+ ${build_generator_args}
+ --build-project TestFindLibinput
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindLibinput/Test/CMakeLists.txt b/Tests/FindLibinput/Test/CMakeLists.txt
new file mode 100644
index 000000000..1cc68d48e
--- /dev/null
+++ b/Tests/FindLibinput/Test/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.10)
+project(TestFindLibinput C)
+include(CTest)
+
+find_package(Libinput REQUIRED)
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt Libinput::Libinput)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${Libinput_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${Libinput_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindLibinput/Test/main.c b/Tests/FindLibinput/Test/main.c
new file mode 100644
index 000000000..391996280
--- /dev/null
+++ b/Tests/FindLibinput/Test/main.c
@@ -0,0 +1,13 @@
+#include <libinput.h>
+#include <stdio.h>
+
+int main()
+{
+ struct libinput_interface interface;
+ interface.open_restricted = 0;
+ interface.close_restricted = 0;
+ struct libinput* li;
+ li = libinput_udev_create_context(&interface, NULL, NULL);
+ printf("Found Libinput.\n");
+ return 0;
+}
diff --git a/Tests/FindMPI/Test/CMakeLists.txt b/Tests/FindMPI/Test/CMakeLists.txt
index 3910c254f..efe8c6261 100644
--- a/Tests/FindMPI/Test/CMakeLists.txt
+++ b/Tests/FindMPI/Test/CMakeLists.txt
@@ -20,12 +20,17 @@ foreach(c C CXX Fortran)
endif()
endforeach()
+set(MPI_CXX_SKIP_MPICXX TRUE)
+set(MPI_CXX_VALIDATE_SKIP_MPICXX TRUE)
find_package(MPI REQUIRED)
foreach(c C CXX Fortran)
if(NOT "${MPI_TEST_${c}}")
continue()
endif()
+ if(${c} STREQUAL CXX AND MPI_MPICXX_FOUND)
+ message(FATAL_ERROR "Could not suppress MPI-2 C++ bindings for this MPI.")
+ endif()
source_code_mapper_helper(${c})
add_executable(test_tgt_${c} ${MPITEST_SOURCE_FILE})
target_link_libraries(test_tgt_${c} MPI::MPI_${c})
diff --git a/Tests/FindMatlab/basic_checks/CMakeLists.txt b/Tests/FindMatlab/basic_checks/CMakeLists.txt
index bf5442767..c0c752a0d 100644
--- a/Tests/FindMatlab/basic_checks/CMakeLists.txt
+++ b/Tests/FindMatlab/basic_checks/CMakeLists.txt
@@ -8,8 +8,22 @@ set(MATLAB_FIND_DEBUG TRUE)
# the success of the following command is dependent on the current configuration:
# - on 32bits builds (cmake is building with 32 bits), it looks for 32 bits Matlab
# - on 64bits builds (cmake is building with 64 bits), it looks for 64 bits Matlab
-find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY MAIN_PROGRAM)
+if(IS_MCR)
+ set(RUN_UNIT_TESTS FALSE)
+else()
+ set(RUN_UNIT_TESTS TRUE)
+ set(components MAIN_PROGRAM)
+endif()
+
+if(NOT "${MCR_ROOT}" STREQUAL "")
+ set(Matlab_ROOT_DIR "${MCR_ROOT}")
+ if(NOT EXISTS "${MCR_ROOT}")
+ message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}")
+ endif()
+endif()
+
+find_package(Matlab REQUIRED COMPONENTS ${components})
matlab_add_mex(
@@ -19,39 +33,53 @@ matlab_add_mex(
OUTPUT_NAME cmake_matlab_mex1
SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp
DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt
- )
+ )
+if(RUN_UNIT_TESTS)
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-1
+ TIMEOUT 300
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests1.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+ )
-matlab_add_unit_test(
- NAME ${PROJECT_NAME}_matlabtest-1
- TIMEOUT 90
- UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests1.m
- ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
- )
+ # timeout tests, TIMEOUT set to very short on purpose
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-2
+ TIMEOUT 15
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests_timeout.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+ )
+ set_tests_properties(${PROJECT_NAME}_matlabtest-2 PROPERTIES WILL_FAIL TRUE)
-matlab_add_unit_test(
- NAME ${PROJECT_NAME}_matlabtest-2
- TIMEOUT 15
- UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests_timeout.m
- ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
- )
-set_tests_properties(${PROJECT_NAME}_matlabtest-2 PROPERTIES WILL_FAIL TRUE)
+ # testing the test without the unittest framework of Matlab
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-3
+ TIMEOUT 300
+ NO_UNITTEST_FRAMEWORK
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests2.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+ )
+
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-4
+ TIMEOUT 300
+ NO_UNITTEST_FRAMEWORK
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests3.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+ )
+ set_tests_properties(${PROJECT_NAME}_matlabtest-4 PROPERTIES WILL_FAIL TRUE)
+endif()
-# testing the test without the unittest framework of Matlab
-matlab_add_unit_test(
- NAME ${PROJECT_NAME}_matlabtest-3
- TIMEOUT 30
- NO_UNITTEST_FRAMEWORK
- UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests2.m
- ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
- )
-matlab_add_unit_test(
- NAME ${PROJECT_NAME}_matlabtest-4
- TIMEOUT 30
- NO_UNITTEST_FRAMEWORK
- UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests3.m
- ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+# checking correct flags passed
+# EXCLUDE_FROM_ALL appears after a multiargs (like SRC)
+matlab_add_mex(
+ # target name
+ NAME cmake_matlab_test_exclude_from_all
+ # output name
+ OUTPUT_NAME cmake_matlab_mex_dummy
+ SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper_failure.cpp
+ EXCLUDE_FROM_ALL
)
-set_tests_properties(${PROJECT_NAME}_matlabtest-4 PROPERTIES WILL_FAIL TRUE)
diff --git a/Tests/FindMatlab/cmake_matlab_unit_tests4.m b/Tests/FindMatlab/cmake_matlab_unit_tests4.m
new file mode 100644
index 000000000..6a7b04d14
--- /dev/null
+++ b/Tests/FindMatlab/cmake_matlab_unit_tests4.m
@@ -0,0 +1,28 @@
+
+classdef cmake_matlab_unit_tests4 < matlab.unittest.TestCase
+ % Testing R2017b and R2018a APIs
+ properties
+ end
+
+ methods (Test)
+ function testR2017b(testCase)
+ ret = cmake_matlab_mex2a(5+6i);
+ testCase.verifyEqual(ret, 8);
+ end
+
+ function testR2018a(testCase)
+ ret = cmake_matlab_mex2b(5+6i);
+ v = version;
+ n = find(v=='.');
+ v = str2double(v(1:n(2)-1));
+ disp(v)
+ if v>= 9.4 % R2018a
+ testCase.verifyEqual(ret, 16);
+ disp('TESTING version >= 9.4')
+ else
+ testCase.verifyEqual(ret, 8);
+ end
+ end
+
+ end
+end
diff --git a/Tests/FindMatlab/cmake_matlab_unit_tests5.m b/Tests/FindMatlab/cmake_matlab_unit_tests5.m
new file mode 100644
index 000000000..b1936e354
--- /dev/null
+++ b/Tests/FindMatlab/cmake_matlab_unit_tests5.m
@@ -0,0 +1,20 @@
+
+classdef cmake_matlab_unit_tests5 < matlab.unittest.TestCase
+ % C++ API test
+ properties
+ end
+
+ methods (Test)
+ function testDummyCall(testCase)
+ % very simple call test
+ disp('TESTING C++')
+ ret = cmake_matlab_mex3(162);
+ testCase.verifyEqual(ret, 162);
+ end
+
+ function testFailTest(testCase)
+ testCase.verifyError(@() cmake_matlab_mex3, 'MATLAB:mex:CppMexException');
+ end
+
+ end
+end
diff --git a/Tests/FindMatlab/components_checks/CMakeLists.txt b/Tests/FindMatlab/components_checks/CMakeLists.txt
index 3dec0931c..f5d488060 100644
--- a/Tests/FindMatlab/components_checks/CMakeLists.txt
+++ b/Tests/FindMatlab/components_checks/CMakeLists.txt
@@ -5,10 +5,18 @@ project(component_checks)
set(MATLAB_FIND_DEBUG TRUE)
+if(NOT "${MCR_ROOT}" STREQUAL "")
+ set(Matlab_ROOT_DIR "${MCR_ROOT}")
+ if(NOT EXISTS "${MCR_ROOT}")
+ message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}")
+ endif()
+endif()
+
# the success of the following command is dependent on the current configuration:
# - on 32bits builds (cmake is building with 32 bits), it looks for 32 bits Matlab
# - on 64bits builds (cmake is building with 64 bits), it looks for 64 bits Matlab
-find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY ENG_LIBRARY MAT_LIBRARY MAIN_PROGRAM)
+find_package(Matlab REQUIRED COMPONENTS ENG_LIBRARY MAT_LIBRARY
+ OPTIONAL_COMPONENTS MAIN_PROGRAM)
message(STATUS "FindMatlab libraries: ${Matlab_LIBRARIES}")
@@ -20,4 +28,4 @@ matlab_add_mex(
SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp
DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt
LINK_TO ${Matlab_LIBRARIES}
- )
+ )
diff --git a/Tests/FindMatlab/failure_reports/CMakeLists.txt b/Tests/FindMatlab/failure_reports/CMakeLists.txt
new file mode 100644
index 000000000..4b092cd28
--- /dev/null
+++ b/Tests/FindMatlab/failure_reports/CMakeLists.txt
@@ -0,0 +1,55 @@
+
+cmake_minimum_required (VERSION 2.8.12)
+enable_testing()
+project(failure_reports)
+
+# gather tests about proper failure reports
+
+set(MATLAB_FIND_DEBUG TRUE)
+
+if(IS_MCR)
+ set(RUN_UNIT_TESTS FALSE)
+else()
+ set(RUN_UNIT_TESTS TRUE)
+ set(components MAIN_PROGRAM)
+endif()
+
+if(NOT "${MCR_ROOT}" STREQUAL "")
+ set(Matlab_ROOT_DIR "${MCR_ROOT}")
+ if(NOT EXISTS "${MCR_ROOT}")
+ message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}")
+ endif()
+endif()
+
+find_package(Matlab REQUIRED COMPONENTS ${components})
+
+# main extensions for testing, same as other tests
+matlab_add_mex(
+ # target name
+ NAME cmake_matlab_test_wrapper1
+ # output name
+ OUTPUT_NAME cmake_matlab_mex1
+ SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper1.cpp
+ DOCUMENTATION ${CMAKE_CURRENT_SOURCE_DIR}/../help_text1.m.txt
+ )
+
+if(RUN_UNIT_TESTS)
+ # the unit test file does not exist: the failure should be properly reported
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-1
+ TIMEOUT 300
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../nonexistantfile.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+ )
+ set_tests_properties(${PROJECT_NAME}_matlabtest-1 PROPERTIES WILL_FAIL TRUE)
+
+ # without the unit test framework
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-2
+ TIMEOUT 300
+ NO_UNITTEST_FRAMEWORK
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../nonexistantfile2.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper1>
+ )
+ set_tests_properties(${PROJECT_NAME}_matlabtest-2 PROPERTIES WILL_FAIL TRUE)
+endif()
diff --git a/Tests/FindMatlab/matlab_wrapper2.cpp b/Tests/FindMatlab/matlab_wrapper2.cpp
new file mode 100644
index 000000000..e768fbfbe
--- /dev/null
+++ b/Tests/FindMatlab/matlab_wrapper2.cpp
@@ -0,0 +1,22 @@
+
+// simple workaround to some compiler specific problems
+// see
+// http://stackoverflow.com/questions/22367516/mex-compile-error-unknown-type-name-char16-t/23281916#23281916
+#include <algorithm>
+
+#include "mex.h"
+
+// This test uses the new complex-interleaved C API (R2018a and newer)
+
+// The input should be a complex array (scalar is OK). It returns the number of
+// bytes in a matrix element. For the old (R2017b) API, this is 8. For the new
+// (R2018a) API, this is 16.
+
+void mexFunction(const int nlhs, mxArray* plhs[], const int nrhs,
+ const mxArray* prhs[])
+{
+ if (nrhs != 1 || !mxIsComplex(prhs[0])) {
+ mexErrMsgTxt("Incorrect arguments");
+ }
+ plhs[0] = mxCreateDoubleScalar(mxGetElementSize(prhs[0]));
+}
diff --git a/Tests/FindMatlab/matlab_wrapper3.cpp b/Tests/FindMatlab/matlab_wrapper3.cpp
new file mode 100644
index 000000000..667081542
--- /dev/null
+++ b/Tests/FindMatlab/matlab_wrapper3.cpp
@@ -0,0 +1,29 @@
+#include "mex.hpp"
+#include "mexAdapter.hpp"
+
+// This test uses the new C++ API (R2018a and newer)
+
+// The input should be a scalar double array. The output is a copy of that
+// array.
+
+using namespace matlab::data;
+using matlab::mex::ArgumentList;
+
+class MexFunction : public matlab::mex::Function
+{
+public:
+ void operator()(ArgumentList outputs, ArgumentList inputs)
+ {
+ std::shared_ptr<matlab::engine::MATLABEngine> matlabPtr = getEngine();
+ ArrayFactory factory;
+ if (inputs[0].getType() != ArrayType::DOUBLE ||
+ inputs[0].getType() == ArrayType::COMPLEX_DOUBLE ||
+ inputs[0].getNumberOfElements() != 1) {
+ matlabPtr->feval(
+ u"error", 0,
+ std::vector<Array>({ factory.createScalar("Incorrect arguments") }));
+ }
+ double a = inputs[0][0];
+ outputs[0] = factory.createScalar(a);
+ }
+};
diff --git a/Tests/FindMatlab/matlab_wrapper_failure.cpp b/Tests/FindMatlab/matlab_wrapper_failure.cpp
new file mode 100644
index 000000000..3fe437b90
--- /dev/null
+++ b/Tests/FindMatlab/matlab_wrapper_failure.cpp
@@ -0,0 +1,13 @@
+// This should not link, as the mex function is missing.
+// This is mostly for checking we are passing the right arguments to the
+// add_library
+
+#include <algorithm>
+
+#include "mex.h"
+
+void mexFunctionXX(const int nlhs, mxArray* plhs[], const int nrhs,
+ const mxArray* prhs[])
+{
+ mexErrMsgTxt("Should not be running");
+}
diff --git a/Tests/FindMatlab/r2018a_check/CMakeLists.txt b/Tests/FindMatlab/r2018a_check/CMakeLists.txt
new file mode 100644
index 000000000..c732be151
--- /dev/null
+++ b/Tests/FindMatlab/r2018a_check/CMakeLists.txt
@@ -0,0 +1,84 @@
+
+cmake_minimum_required (VERSION 2.8.12)
+enable_testing()
+project(r2018a_checks)
+
+set(MATLAB_FIND_DEBUG TRUE)
+
+# this test doesn't do much if MATLAB version < R2018a
+
+if(IS_MCR)
+ set(RUN_UNIT_TESTS FALSE)
+else()
+ set(RUN_UNIT_TESTS TRUE)
+ set(components MAIN_PROGRAM)
+endif()
+
+if(NOT "${MCR_ROOT}" STREQUAL "")
+ set(Matlab_ROOT_DIR "${MCR_ROOT}")
+ if(NOT EXISTS "${MCR_ROOT}")
+ message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}")
+ endif()
+endif()
+
+find_package(Matlab REQUIRED COMPONENTS ${components})
+
+set(IS_R2018a 1)
+if(${Matlab_VERSION_STRING} VERSION_LESS "9.4")
+ # This is an older version of MATLAB, tests will fail
+ set(IS_R2018a 0)
+endif()
+
+matlab_add_mex(
+ # target name
+ NAME cmake_matlab_test_wrapper2a
+ # output name
+ OUTPUT_NAME cmake_matlab_mex2a
+ SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper2.cpp
+ R2017b
+ )
+
+matlab_add_mex(
+ # target name
+ NAME cmake_matlab_test_wrapper2b
+ # output name
+ OUTPUT_NAME cmake_matlab_mex2b
+ SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper2.cpp
+ R2018a
+ )
+
+if(IS_R2018a)
+ matlab_add_mex(
+ # target name
+ NAME cmake_matlab_test_wrapper3
+ # output name
+ OUTPUT_NAME cmake_matlab_mex3
+ SRC ${CMAKE_CURRENT_SOURCE_DIR}/../matlab_wrapper3.cpp
+ )
+ set_target_properties(
+ cmake_matlab_test_wrapper3
+ PROPERTIES
+ CXX_STANDARD 11
+ CXX_STANDARD_REQUIRED ON
+ )
+endif()
+
+if(RUN_UNIT_TESTS)
+ # Check that the R2017b and R2018a APIs work.
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-1
+ TIMEOUT 300
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests4.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper2a>
+ )
+
+ # Check that the C++ API works (test run only on R2018a and newer)
+ if(IS_R2018a)
+ matlab_add_unit_test(
+ NAME ${PROJECT_NAME}_matlabtest-3
+ TIMEOUT 300
+ UNITTEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_matlab_unit_tests5.m
+ ADDITIONAL_PATH $<TARGET_FILE_DIR:cmake_matlab_test_wrapper3>
+ )
+ endif()
+endif()
diff --git a/Tests/FindMatlab/versions_checks/CMakeLists.txt b/Tests/FindMatlab/versions_checks/CMakeLists.txt
index 5d20685c2..d015730b0 100644
--- a/Tests/FindMatlab/versions_checks/CMakeLists.txt
+++ b/Tests/FindMatlab/versions_checks/CMakeLists.txt
@@ -7,6 +7,13 @@ set(MATLAB_FIND_DEBUG TRUE)
set(MATLAB_ADDITIONAL_VERSIONS
"dummy=14.9")
+if(NOT "${MCR_ROOT}" STREQUAL "")
+ set(Matlab_ROOT_DIR "${MCR_ROOT}")
+ if(NOT EXISTS "${MCR_ROOT}")
+ message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}")
+ endif()
+endif()
+
# the success of the following command is dependent on the current configuration
# in this case, we are only interested in the version macros
find_package(Matlab)
diff --git a/Tests/FindODBC/CMakeLists.txt b/Tests/FindODBC/CMakeLists.txt
new file mode 100644
index 000000000..6a8109062
--- /dev/null
+++ b/Tests/FindODBC/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindODBC.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindODBC/Test"
+ "${CMake_BINARY_DIR}/Tests/FindODBC/Test"
+ ${build_generator_args}
+ --build-project TestFindODBC
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindODBC/Test/CMakeLists.txt b/Tests/FindODBC/Test/CMakeLists.txt
new file mode 100644
index 000000000..a20c0f707
--- /dev/null
+++ b/Tests/FindODBC/Test/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.1)
+project(TestFindODBC C)
+include(CTest)
+
+find_package(ODBC)
+
+add_executable(test_odbc_tgt main.c)
+target_link_libraries(test_odbc_tgt ODBC::ODBC)
+add_test(NAME test_odbc_tgt COMMAND test_odbc_tgt)
+
+add_executable(test_odbc_var main.c)
+target_include_directories(test_odbc_var PRIVATE ${ODBC_INCLUDE_DIRS})
+target_link_libraries(test_odbc_var PRIVATE ${ODBC_LIBRARIES})
+add_test(NAME test_odbc_var COMMAND test_odbc_var)
diff --git a/Tests/FindODBC/Test/main.c b/Tests/FindODBC/Test/main.c
new file mode 100644
index 000000000..34f279ce1
--- /dev/null
+++ b/Tests/FindODBC/Test/main.c
@@ -0,0 +1,12 @@
+#ifdef WIN32
+# include <windows.h>
+#endif
+#include <sql.h>
+
+int main()
+{
+ SQLHENV env;
+ SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
+ SQLFreeHandle(SQL_HANDLE_ENV, env);
+ return 0;
+}
diff --git a/Tests/FindOpenACC/CMakeLists.txt b/Tests/FindOpenACC/CMakeLists.txt
new file mode 100644
index 000000000..ef7de65a2
--- /dev/null
+++ b/Tests/FindOpenACC/CMakeLists.txt
@@ -0,0 +1,20 @@
+
+set(langs C CXX)
+if(NOT CMAKE_GENERATOR STREQUAL "Ninja")
+ list(APPEND langs Fortran)
+endif()
+
+foreach(lang IN LISTS langs)
+ if(CMAKE_${lang}_COMPILER)
+ add_test(NAME FindOpenACC.Test${lang} COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindOpenACC/${lang}Test"
+ "${CMake_BINARY_DIR}/Tests/FindOpenACC/${lang}Test"
+ ${build_generator_args}
+ --build-project TestFindOpenACC
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ endif()
+endforeach()
diff --git a/Tests/FindOpenACC/CTest/CMakeLists.txt b/Tests/FindOpenACC/CTest/CMakeLists.txt
new file mode 100644
index 000000000..c8d0968a6
--- /dev/null
+++ b/Tests/FindOpenACC/CTest/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.14)
+project(VerifyFindOpenAcc C)
+
+set(CMAKE_C_STANDARD 11)
+
+find_package(OpenACC REQUIRED)
+
+add_executable(UsesOpenACC main.c)
+target_link_libraries(UsesOpenACC PRIVATE OpenACC::OpenACC_C)
+
+add_executable(UsesOpenACCVars main.c)
+target_link_options(UsesOpenACCVars PRIVATE ${OpenACC_C_OPTIONS})
+target_compile_options(UsesOpenACCVars PRIVATE ${OpenACC_C_OPTIONS})
diff --git a/Tests/FindOpenACC/CTest/main.c b/Tests/FindOpenACC/CTest/main.c
new file mode 100644
index 000000000..53b6cae15
--- /dev/null
+++ b/Tests/FindOpenACC/CTest/main.c
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+void vecaddgpu(float* r, float* a, float* b, int n)
+{
+#pragma acc kernels loop present(r, a, b)
+ for (int i = 0; i < n; ++i)
+ r[i] = a[i] + b[i];
+}
+
+int main()
+{
+ int n = 100000; /* vector length */
+ float* a; /* input vector 1 */
+ float* b; /* input vector 2 */
+ float* r; /* output vector */
+ float* e; /* expected output values */
+ int i, errs;
+
+ a = (float*)malloc(n * sizeof(float));
+ b = (float*)malloc(n * sizeof(float));
+ r = (float*)malloc(n * sizeof(float));
+ e = (float*)malloc(n * sizeof(float));
+ for (i = 0; i < n; ++i) {
+ a[i] = (float)(i + 1);
+ b[i] = (float)(1000 * i);
+ }
+/* compute on the GPU */
+#pragma acc data copyin(a [0:n], b [0:n]) copyout(r [0:n])
+ {
+ vecaddgpu(r, a, b, n);
+ }
+ /* compute on the host to compare */
+ for (i = 0; i < n; ++i)
+ e[i] = a[i] + b[i];
+ /* compare results */
+ errs = 0;
+ for (i = 0; i < n; ++i) {
+ if (r[i] != e[i]) {
+ ++errs;
+ }
+ }
+ return errs;
+}
diff --git a/Tests/FindOpenACC/CXXTest/CMakeLists.txt b/Tests/FindOpenACC/CXXTest/CMakeLists.txt
new file mode 100644
index 000000000..a6caf7b35
--- /dev/null
+++ b/Tests/FindOpenACC/CXXTest/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.14)
+project(VerifyFindOpenAcc CXX)
+
+set(CMAKE_CXX_STANDARD 11)
+
+find_package(OpenACC REQUIRED)
+
+add_executable(UsesOpenACC main.cxx)
+target_link_libraries(UsesOpenACC PRIVATE OpenACC::OpenACC_CXX)
+
+add_executable(UsesOpenACCVars main.cxx)
+target_link_options(UsesOpenACCVars PRIVATE ${OpenACC_CXX_OPTIONS})
+target_compile_options(UsesOpenACCVars PRIVATE ${OpenACC_CXX_OPTIONS})
diff --git a/Tests/FindOpenACC/CXXTest/main.cxx b/Tests/FindOpenACC/CXXTest/main.cxx
new file mode 100644
index 000000000..7369045c0
--- /dev/null
+++ b/Tests/FindOpenACC/CXXTest/main.cxx
@@ -0,0 +1,43 @@
+
+#include <vector>
+
+void vecaddgpu(float* r, float* a, float* b, std::size_t n)
+{
+#pragma acc kernels loop present(r, a, b)
+ for (std::size_t i = 0; i < n; ++i)
+ r[i] = a[i] + b[i];
+}
+
+int main(int, char* [])
+{
+ const std::size_t n = 100000; /* vector length */
+ std::vector<float> a(n); /* input vector 1 */
+ std::vector<float> b(n); /* input vector 2 */
+ std::vector<float> r(n); /* output vector */
+ std::vector<float> e(n); /* expected output values */
+
+ for (std::size_t i = 0; i < n; ++i) {
+ a[i] = static_cast<float>(i + 1);
+ b[i] = static_cast<float>(1000 * i);
+ }
+
+ /* compute on the GPU */
+ auto a_ptr = a.data();
+ auto b_ptr = b.data();
+ auto r_ptr = r.data();
+#pragma acc data copyin(a_ptr [0:n], b_ptr [0:n]) copyout(r_ptr [0:n])
+ {
+ vecaddgpu(r_ptr, a_ptr, b_ptr, n);
+ }
+ /* compute on the host to compare */
+ for (std::size_t i = 0; i < n; ++i)
+ e[i] = a[i] + b[i];
+ /* compare results */
+ int errs = 0;
+ for (std::size_t i = 0; i < n; ++i) {
+ if (r[i] != e[i]) {
+ ++errs;
+ }
+ }
+ return errs;
+}
diff --git a/Tests/FindOpenACC/FortranTest/CMakeLists.txt b/Tests/FindOpenACC/FortranTest/CMakeLists.txt
new file mode 100644
index 000000000..12e3503d1
--- /dev/null
+++ b/Tests/FindOpenACC/FortranTest/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.14)
+project(VerifyFindOpenAcc Fortran)
+
+find_package(OpenACC REQUIRED)
+
+add_executable(UsesOpenACC main.f90)
+target_link_libraries(UsesOpenACC PRIVATE OpenACC::OpenACC_Fortran)
+
+add_executable(UsesOpenACCVars main.f90)
+target_link_options(UsesOpenACCVars PRIVATE ${OpenACC_Fortran_OPTIONS})
+target_compile_options(UsesOpenACCVars PRIVATE ${OpenACC_Fortran_OPTIONS})
diff --git a/Tests/FindOpenACC/FortranTest/main.f90 b/Tests/FindOpenACC/FortranTest/main.f90
new file mode 100644
index 000000000..2ff1ba029
--- /dev/null
+++ b/Tests/FindOpenACC/FortranTest/main.f90
@@ -0,0 +1,9 @@
+program t
+integer(4) a(10000)
+a = [ (1+i,i=1,10000) ]
+!$acc kernels
+do i = 1, 10000
+ if (a(i)/3000*3000.eq.a(i)) print *," located ",i,a(i),i.gt.5000,a(i)/5.0
+end do
+!$acc end kernels
+end
diff --git a/Tests/FindOpenCL/Test/main.c b/Tests/FindOpenCL/Test/main.c
index dc7763645..2fe949bd0 100644
--- a/Tests/FindOpenCL/Test/main.c
+++ b/Tests/FindOpenCL/Test/main.c
@@ -1,7 +1,7 @@
#ifdef __APPLE__
-#include <OpenCL/opencl.h>
+# include <OpenCL/opencl.h>
#else
-#include <CL/cl.h>
+# include <CL/cl.h>
#endif
int main()
diff --git a/Tests/FindOpenGL/CMakeLists.txt b/Tests/FindOpenGL/CMakeLists.txt
index 9aa3abafb..97c9e6052 100644
--- a/Tests/FindOpenGL/CMakeLists.txt
+++ b/Tests/FindOpenGL/CMakeLists.txt
@@ -1,3 +1,9 @@
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMake_TEST_FindOpenGL_VND)
+ set(_vnd_testing TRUE)
+else()
+ set(_vnd_testing FALSE)
+endif()
+
add_test(NAME FindOpenGL.Test COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
@@ -6,5 +12,6 @@ add_test(NAME FindOpenGL.Test COMMAND
${build_generator_args}
--build-project TestFindOpenGL
--build-options ${build_options}
+ -DOpenGL_TEST_VND=${_vnd_testing}
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
diff --git a/Tests/FindOpenGL/Test/CMakeLists.txt b/Tests/FindOpenGL/Test/CMakeLists.txt
index cac342488..9004a9860 100644
--- a/Tests/FindOpenGL/Test/CMakeLists.txt
+++ b/Tests/FindOpenGL/Test/CMakeLists.txt
@@ -1,14 +1,71 @@
-cmake_minimum_required(VERSION 3.7)
+cmake_minimum_required(VERSION 3.10)
+cmake_policy(SET CMP0072 NEW)
project(TestFindOpenGL C)
include(CTest)
find_package(OpenGL REQUIRED)
+# import target for GLU
add_executable(test_tgt main.c)
target_link_libraries(test_tgt OpenGL::GLU)
add_test(NAME test_tgt COMMAND test_tgt)
+# OPENGL_LIBRARIES should be whatever libraries are needed to link.
add_executable(test_var main.c)
target_include_directories(test_var PRIVATE ${OPENGL_INGLUDE_DIRS})
target_link_libraries(test_var PRIVATE ${OPENGL_LIBRARIES})
add_test(NAME test_var COMMAND test_var)
+
+# VND support adds an ::OpenGL import target. This can be used for OpenGL-only
+# code (code that does not manipulate contexts, like our 'main.c'). Without
+# VND, ::GL can be used for both context and non-context OpenGL code.
+if(OpenGL_TEST_VND)
+ add_executable(test_comp_none main.c)
+ target_link_libraries(test_comp_none PRIVATE OpenGL::OpenGL)
+ add_test(NAME test_comp_none COMMAND test_comp_none)
+else()
+ add_executable(test_comp_none main.c)
+ target_link_libraries(test_comp_none PRIVATE OpenGL::GL)
+ add_test(NAME test_comp_none COMMAND test_comp_none)
+endif()
+
+# GLX
+if(OpenGL_TEST_VND)
+ find_package(OpenGL REQUIRED COMPONENTS OpenGL GLX)
+ add_executable(test_comp_glx main.c)
+ target_link_libraries(test_comp_glx PRIVATE OpenGL::OpenGL OpenGL::GLX)
+ add_test(NAME test_comp_glx COMMAND test_comp_glx)
+else()
+ # non-VND systems won't have it, but an optional search for GLX should still
+ # be okay.
+ find_package(OpenGL COMPONENTS GLX)
+ add_executable(test_comp_glx_novnd main.c)
+ target_link_libraries(test_comp_glx_novnd PRIVATE OpenGL::GL)
+ add_test(NAME test_comp_glx_novnd COMMAND test_comp_glx_novnd)
+endif()
+
+# EGL is only available on Linux+GLVND at present.
+if(OpenGL_TEST_VND)
+ find_package(OpenGL COMPONENTS OpenGL EGL)
+ if(OpenGL_EGL_FOUND)
+ add_executable(test_comp_egl main.c)
+ target_link_libraries(test_comp_egl PRIVATE OpenGL::OpenGL OpenGL::EGL)
+ add_test(NAME test_comp_egl COMMAND test_comp_egl)
+ # EGL-only code should not link to GLX.
+ execute_process(COMMAND ldd test_comp_egl
+ OUTPUT_VARIABLE LDD_OUT
+ ERROR_VARIABLE LDD_ERR)
+ if("${LDD_OUT}" MATCHES "GLX")
+ message(FATAL_ERROR "EGL-only code links to GLX!")
+ endif()
+ endif()
+
+ # all three COMPONENTS together.
+ find_package(OpenGL COMPONENTS OpenGL EGL GLX)
+ if(OpenGL_EGL_FOUND AND OpenGL_GLX_FOUND)
+ add_executable(test_comp_both main.c)
+ target_link_libraries(test_comp_both PRIVATE OpenGL::OpenGL OpenGL::EGL
+ OpenGL::GLX)
+ add_test(NAME test_comp_both COMMAND test_comp_both)
+ endif()
+endif()
diff --git a/Tests/FindOpenGL/Test/main.c b/Tests/FindOpenGL/Test/main.c
index bca3d7e3f..e1f25c630 100644
--- a/Tests/FindOpenGL/Test/main.c
+++ b/Tests/FindOpenGL/Test/main.c
@@ -1,10 +1,10 @@
#ifdef _WIN32
-#include <windows.h>
+# include <windows.h>
#endif
#ifdef __APPLE__
-#include <OpenGL/gl.h>
+# include <OpenGL/gl.h>
#else
-#include <GL/gl.h>
+# include <GL/gl.h>
#endif
#include <stdio.h>
diff --git a/Tests/FindOpenMP/Test/CMakeLists.txt b/Tests/FindOpenMP/Test/CMakeLists.txt
index 2692947ad..ebdb6b8f9 100644
--- a/Tests/FindOpenMP/Test/CMakeLists.txt
+++ b/Tests/FindOpenMP/Test/CMakeLists.txt
@@ -42,6 +42,7 @@ foreach(c C CXX Fortran)
separate_arguments(_OpenMP_${c}_OPTIONS NATIVE_COMMAND "${OpenMP_${c}_FLAGS}")
target_compile_options(test_var_${c} PRIVATE "${_OpenMP_${c}_OPTIONS}")
target_link_libraries(test_var_${c} PRIVATE "${OpenMP_${c}_FLAGS}")
+ target_include_directories(test_var_${c} PRIVATE ${OpenMP_${c}_INCLUDE_DIRS})
set_property(TARGET test_var_${c} PROPERTY LINKER_LANGUAGE ${c})
add_test(NAME test_var_${c} COMMAND test_var_${c})
diff --git a/Tests/FindOpenMP/Test/scaltest.c b/Tests/FindOpenMP/Test/scaltest.c
index 2ee57f833..4678b87a4 100644
--- a/Tests/FindOpenMP/Test/scaltest.c
+++ b/Tests/FindOpenMP/Test/scaltest.c
@@ -1,8 +1,8 @@
#ifdef __cplusplus
-#include <iostream>
+# include <iostream>
extern "C"
#else
-#include <stdio.h>
+# include <stdio.h>
#endif
int scalprod(int n, double* x, double* y, double* res);
diff --git a/Tests/FindOpenSSL/rand/main.cc b/Tests/FindOpenSSL/rand/main.cc
index d81b31898..147044ba3 100644
--- a/Tests/FindOpenSSL/rand/main.cc
+++ b/Tests/FindOpenSSL/rand/main.cc
@@ -9,7 +9,7 @@ int main()
unsigned char buf[1024];
// random bytes
- int rezval = RAND_bytes(buf, sizeof(buf)); /* 1 succes, 0 otherwise */
+ int rezval = RAND_bytes(buf, sizeof(buf)); /* 1 success, 0 otherwise */
// check result
if (rezval == 1) {
diff --git a/Tests/FindPackageModeMakefileTest/foo.cpp b/Tests/FindPackageModeMakefileTest/foo.cpp
index 6aea22629..7cb9381ed 100644
--- a/Tests/FindPackageModeMakefileTest/foo.cpp
+++ b/Tests/FindPackageModeMakefileTest/foo.cpp
@@ -1,3 +1,5 @@
+#include "foo.h"
+
int foo()
{
return 1477;
diff --git a/Tests/FindPackageModeMakefileTest/foo.h b/Tests/FindPackageModeMakefileTest/foo.h
index 4ec598ad5..7051edac4 100644
--- a/Tests/FindPackageModeMakefileTest/foo.h
+++ b/Tests/FindPackageModeMakefileTest/foo.h
@@ -1,6 +1,14 @@
#ifndef FOO_H
#define FOO_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
int foo();
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
#endif
diff --git a/Tests/FindPackageTest/.gitignore b/Tests/FindPackageTest/.gitignore
new file mode 100644
index 000000000..3aaef13dc
--- /dev/null
+++ b/Tests/FindPackageTest/.gitignore
@@ -0,0 +1 @@
+/symlink
diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt
index 1a6f20429..7217f43b6 100644
--- a/Tests/FindPackageTest/CMakeLists.txt
+++ b/Tests/FindPackageTest/CMakeLists.txt
@@ -188,7 +188,43 @@ find_package(ArchC 3.1 EXACT NAMES zot)
find_package(ArchD 4.0 EXACT NAMES zot)
unset(CMAKE_LIBRARY_ARCHITECTURE)
-# Test <Package>_DIR environment variable.
+# Test find_package() with CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS enabled
+if(UNIX)
+ # Create ./symlink pointing back here.
+ execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
+ . "${CMAKE_CURRENT_SOURCE_DIR}/symlink")
+ # Make find_package search through the symlink
+ set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/symlink")
+
+ # First, test the default behavior where symlinks are preserved.
+ set(SetFoundResolved_DIR "")
+ find_package(SetFoundResolved)
+ # The result must preserve the /symlink/ path.
+ set(SetFoundResolved_EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/symlink/cmake")
+ if(NOT "${SetFoundResolved_DIR}" STREQUAL "${SetFoundResolved_EXPECTED}")
+ message(SEND_ERROR "SetFoundResolved_DIR set by find_package() is set to \"${SetFoundResolved_DIR}\" (expected \"${SetFoundResolved_EXPECTED}\")")
+ endif()
+
+ # This part of the test only works if there are no symlinks in our path.
+ get_filename_component(real_src_dir "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)
+ if(real_src_dir STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ # Resolve symlinks when finding the package.
+ set(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS TRUE)
+ set(SetFoundResolved_DIR "")
+ find_package(SetFoundResolved)
+ # ./symlink points back here so it should be gone when resolved.
+ set(SetFoundResolved_EXPECTED "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+ if(NOT "${SetFoundResolved_DIR}" STREQUAL "${SetFoundResolved_EXPECTED}")
+ message(SEND_ERROR "SetFoundResolved_DIR set by find_package() is set to \"${SetFoundResolved_DIR}\" (expected \"${SetFoundResolved_EXPECTED}\")")
+ endif()
+ endif()
+
+ # Cleanup.
+ unset(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS)
+ file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/symlink")
+endif()
+
+# Test <PackageName>_DIR environment variable.
# We erase the main prefix path to ensure the env var is used.
set(CMAKE_PREFIX_PATH)
set(ENV{EnvA_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/lib/zot-3.1")
@@ -349,21 +385,50 @@ try_compile(EXPORTER_COMPILED
${FindPackageTest_SOURCE_DIR}/Exporter
CMakeTestExportPackage dummy
CMAKE_FLAGS "-UCMAKE_EXPORT_NO_PACKAGE_REGISTRY"
+ "-DCMAKE_POLICY_DEFAULT_CMP0090:STRING=OLD"
-Dversion=${version}
OUTPUT_VARIABLE output)
message(STATUS "Searching for export(PACKAGE) test project")
set(CMakeTestExportPackage_DIR "" CACHE FILEPATH
"Wipe out find results for testing." FORCE)
+
+message(STATUS "Searching for export(PACKAGE) with CMAKE_FIND_USE_PACKAGE_REGISTRY=TRUE")
+set(CMAKE_FIND_USE_PACKAGE_REGISTRY TRUE)
find_package(CMakeTestExportPackage 1.${version} EXACT REQUIRED)
+if(NOT CMakeTestExportPackage_FOUND)
+ message(SEND_ERROR "CMakeTestExportPackage should be FOUND!")
+endif()
+unset(CMAKE_FIND_USE_PACKAGE_REGISTRY)
-message(STATUS "Searching for export(PACKAGE) test project with CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=TRUE")
+message(STATUS "Searching for export(PACKAGE) with CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=FALSE")
+set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY FALSE)
+find_package(CMakeTestExportPackage 1.${version} EXACT REQUIRED)
+if(NOT CMakeTestExportPackage_FOUND)
+ message(SEND_ERROR "CMakeTestExportPackage should be FOUND!")
+endif()
+unset(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY)
+
+message(STATUS "Searching for export(PACKAGE) with CMAKE_FIND_USE_PACKAGE_REGISTRY=TRUE and CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=TRUE")
+set(CMAKE_FIND_USE_PACKAGE_REGISTRY TRUE)
set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY TRUE)
+set(CMakeTestExportPackage_DIR FALSE)
+find_package(CMakeTestExportPackage 1.${version} EXACT REQUIRED)
+if(NOT CMakeTestExportPackage_FOUND)
+ message(SEND_ERROR "CMakeTestExportPackage should be FOUND!")
+endif()
+unset(CMAKE_FIND_USE_PACKAGE_REGISTRY)
+unset(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY)
+
+message(STATUS "Searching for export(PACKAGE) with CMAKE_FIND_USE_PACKAGE_REGISTRY=FALSE and CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=FALSE")
+set(CMAKE_FIND_USE_PACKAGE_REGISTRY FALSE)
+set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY FALSE)
set(CMakeTestExportPackage_DIR "" CACHE FILEPATH
"Wipe out find results for testing." FORCE)
-find_package(CMakeTestExportPackage 1.${version} EXACT QUIET)
+find_package(CMakeTestExportPackage 1.${version} EXACT QUIET)
if(CMakeTestExportPackage_FOUND)
- message(SEND_ERROR "CMakeTestExportPackage should not be FOUND!")
+ message(SEND_ERROR "CMakeTestExportPackage should be not FOUND!")
endif()
+unset(CMAKE_FIND_USE_PACKAGE_REGISTRY)
unset(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY)
message(STATUS "Remove export(PACKAGE) test project")
@@ -386,6 +451,25 @@ if(CMakeTestExportPackage_FOUND)
message(SEND_ERROR "CMakeTestExportPackage should not be FOUND!")
endif()
+message(STATUS "Remove export(PACKAGE) test project")
+file(REMOVE_RECURSE ${FindPackageTest_BINARY_DIR}/Exporter-build)
+
+message(STATUS "Preparing export(PACKAGE) test project with POLICY CMP0090=NEW")
+try_compile(EXPORTER_COMPILED
+ ${FindPackageTest_BINARY_DIR}/Exporter-build
+ ${FindPackageTest_SOURCE_DIR}/Exporter
+ CMakeTestExportPackage dummy
+ CMAKE_FLAGS
+ "-DCMAKE_POLICY_DEFAULT_CMP0090:STRING=NEW"
+ -Dversion=${version}
+ OUTPUT_VARIABLE output)
+message(STATUS "Searching for export(PACKAGE) test project")
+find_package(CMakeTestExportPackage 1.${version} EXACT QUIET)
+if(CMakeTestExportPackage_FOUND)
+ message(SEND_ERROR "CMakeTestExportPackage should not be FOUND!")
+endif()
+
+
#-----------------------------------------------------------------------------
# Test configure_package_config_file().
@@ -461,205 +545,117 @@ if(Relocatable_FOUND)
endif()
+############################################################################
+##Test FIND_PACKAGE using sorting
+set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+SET(CMAKE_FIND_PACKAGE_SORT_ORDER NAME)
+SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION ASC)
-#-----------------------------------------------------------------------------
-# Test write_basic_config_version_file().
-
-# also test that an empty CMAKE_SIZEOF_VOID_P is accepted:
-set(_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
-set(CMAKE_SIZEOF_VOID_P "")
-
-write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake
- VERSION 1.2.3
- COMPATIBILITY AnyNewerVersion)
-
-set(CMAKE_SIZEOF_VOID_P ${_CMAKE_SIZEOF_VOID_P})
-
-set(PACKAGE_FIND_VERSION 2.3.4)
-include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake)
-if(PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Found Foo123 with version 1.2.3, but 2.3.4 was requested !")
-endif()
-
-set(PACKAGE_FIND_VERSION 0.0.1)
-include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake)
-if(NOT PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (0.0.1 was requested) !")
-endif()
-
-if(PACKAGE_VERSION_UNSUITABLE)
- message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !")
+set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE)
+FIND_PACKAGE(SortLib CONFIG)
+IF (NOT "${SortLib_VERSION}" STREQUAL "3.1.1")
+ message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Name Asc! ${SortLib_VERSION}")
endif()
+unset(SortLib_VERSION)
-set(PACKAGE_FIND_VERSION 1.0.0)
-include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake)
-if(NOT PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.0.0 was requested) !")
-endif()
-if(PACKAGE_VERSION_EXACT)
- message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
-endif()
-set(PACKAGE_FIND_VERSION 1.2.3)
-include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake)
-if(NOT PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.2.3 was requested) !")
-endif()
-if(NOT PACKAGE_VERSION_EXACT)
- message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !")
+set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE)
+SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
+SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
+FIND_PACKAGE(SortLib CONFIG)
+IF (NOT "${SortLib_VERSION}" STREQUAL "3.10.1")
+ message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Natural! Dec ${SortLib_VERSION}")
endif()
+set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE)
+unset(SortLib_VERSION)
+unset(CMAKE_FIND_PACKAGE_SORT_ORDER)
+unset(CMAKE_FIND_PACKAGE_SORT_DIRECTION)
+set(CMAKE_PREFIX_PATH )
-#######################
-include(WriteBasicConfigVersionFile)
+############################################################################
+##Test FIND_PACKAGE CMAKE_FIND_PACKAGE_PREFER_CONFIG
-write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake
- VERSION 1.2.3
- COMPATIBILITY SameMajorVersion)
+set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfig)
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfig)
-unset(PACKAGE_VERSION_UNSUITABLE)
-set(PACKAGE_VERSION_EXACT FALSE)
-set(PACKAGE_FIND_VERSION 2.3.4)
-set(PACKAGE_FIND_VERSION_MAJOR 2)
-include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake)
-if(PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Found Boo123 with version 1.2.3, but 2.3.4 was requested !")
-endif()
-if(PACKAGE_VERSION_EXACT)
- message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
-endif()
+# prefer module mode
+set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF)
+unset(ABC_FOUND)
+unset(ABC_CONFIG)
-set(PACKAGE_FIND_VERSION 0.0.1)
-set(PACKAGE_FIND_VERSION_MAJOR 0)
-include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake)
-if(PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Found Boo123 with version 1.2.3, but 0.0.1 was requested !")
+find_package(ABC)
+if(NOT ABC_FOUND)
+ message(SEND_ERROR "Did not find ABC package")
endif()
-if(PACKAGE_VERSION_EXACT)
- message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
+if(ABC_CONFIG)
+ message(SEND_ERROR "Incorrectly found ABC in CONFIG mode, expected to find it with MODULE mode")
endif()
-set(PACKAGE_FIND_VERSION 1.0.0)
-set(PACKAGE_FIND_VERSION_MAJOR 1)
-include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake)
-if(NOT PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.0.0 was requested) !")
-endif()
-if(PACKAGE_VERSION_EXACT)
- message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
-endif()
+# Now prefer config mode
+set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
+unset(ABC_FOUND)
+unset(ABC_CONFIG)
-set(PACKAGE_FIND_VERSION 1.2.3)
-set(PACKAGE_FIND_VERSION_MAJOR 1)
-include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake)
-if(NOT PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.2.3 was requested) !")
+find_package(ABC)
+if(NOT ABC_FOUND)
+ message(SEND_ERROR "Did not find ABC package")
endif()
-if(NOT PACKAGE_VERSION_EXACT)
- message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !")
+if(NOT ABC_CONFIG)
+ message(SEND_ERROR "Incorrectly found ABC in MODULE mode, expected to find it with CONFIG mode")
endif()
-if(PACKAGE_VERSION_UNSUITABLE)
- message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !")
-endif()
+set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF)
+set(CMAKE_PREFIX_PATH)
+set(CMAKE_MODULE_PATH)
-#######################
+############################################################################
+##Test FIND_PACKAGE CMAKE_FIND_PACKAGE_PREFER_CONFIG - Do not recurse
-write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake
- VERSION 1.2.3.17
- COMPATIBILITY ExactVersion)
+# No CMAKE_PREFIX_PATH
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfigRecurse)
-unset(PACKAGE_VERSION_UNSUITABLE)
-set(PACKAGE_VERSION_EXACT FALSE)
-set(PACKAGE_FIND_VERSION 2.3.4)
-include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake)
-if(PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Found Bar123 with version 1.2.3 (2.3.4 was requested) !")
-endif()
-if(PACKAGE_VERSION_EXACT)
- message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
-endif()
+# Now prefer config mode
+set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
+unset(ACME_FOUND)
+unset(ACME_CONFIG)
-set(PACKAGE_FIND_VERSION 1.2)
-include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake)
-if(PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Found Bar123 with version 1.2.3 (1.2 was requested) !")
-endif()
-if(PACKAGE_VERSION_EXACT)
- message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
+find_package(ACME)
+if(ACME_FOUND AND ACME_CONFIG)
+ message(SEND_ERROR "Incorrectly found ACME in CONFIG mode, from the MODULE package")
endif()
-set(PACKAGE_FIND_VERSION 1)
-include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake)
-if(PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Found Bar123 with version 1.2.3 (1 was requested) !")
-endif()
-if(PACKAGE_VERSION_EXACT)
- message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
-endif()
+set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF)
+set(CMAKE_MODULE_PATH)
-set(PACKAGE_FIND_VERSION 1.2.3.4)
-include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake)
-if(NOT PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (1.2.3.4 was requested) !")
-endif()
-if(PACKAGE_VERSION_EXACT)
- message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
-endif()
+############################################################################
+##Test find_package CMAKE_FIND_PACKAGE_PREFER_CONFIG with module fallback
-set(PACKAGE_FIND_VERSION 1.2.3)
-set(PACKAGE_VERSION_EXACT FALSE)
-set(PACKAGE_VERSION_COMPATIBLE FALSE)
-include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake)
-if(NOT PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (1.2.3 was requested) !")
-endif()
-if(PACKAGE_VERSION_EXACT)
- message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
-endif()
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfigOnlyModule)
+set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
-set(PACKAGE_FIND_VERSION 1.2.3.17)
-set(PACKAGE_VERSION_EXACT FALSE)
-set(PACKAGE_VERSION_COMPATIBLE FALSE)
-include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake)
-if(NOT PACKAGE_VERSION_COMPATIBLE)
- message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (1.2.3.17 was requested) !")
-endif()
-if(NOT PACKAGE_VERSION_EXACT)
- message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !")
-endif()
+find_package(ACME REQUIRED)
-if(PACKAGE_VERSION_UNSUITABLE)
- message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !")
+if(NOT ACME_FOUND)
+ message(SEND_ERROR "Did not find ACME package")
endif()
-
############################################################################
-##Test FIND_PACKAGE using sorting
-set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR})
-SET(CMAKE_FIND_PACKAGE_SORT_ORDER NAME)
-SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION ASC)
+##Test find_package CMAKE_FIND_PACKAGE_PREFER_CONFIG with NO_MODULE
-set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE)
-FIND_PACKAGE(SortLib CONFIG)
-IF (NOT "${SortLib_VERSION}" STREQUAL "3.1.1")
- message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Name Asc! ${SortLib_VERSION}")
-endif()
-unset(SortLib_VERSION)
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/PreferConfigOnlyModule)
+set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
-set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE)
-SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
-SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
-FIND_PACKAGE(SortLib CONFIG)
-IF (NOT "${SortLib_VERSION}" STREQUAL "3.10.1")
- message(SEND_ERROR "FIND_PACKAGE_SORT_ORDER Natural! Dec ${SortLib_VERSION}")
+find_package(ACME NO_MODULE)
+
+if(ACME_FOUND)
+ message(SEND_ERROR "Should not find ACME package")
endif()
-set(SortLib_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE)
-unset(SortLib_VERSION)
+############################################################################
+##Test find_package CMAKE_FIND_PACKAGE_PREFER_CONFIG with unknown package
-unset(CMAKE_FIND_PACKAGE_SORT_ORDER)
-unset(CMAKE_FIND_PACKAGE_SORT_DIRECTION)
-set(CMAKE_PREFIX_PATH )
+set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
+find_package(DoesNotExist)
diff --git a/Tests/FindPackageTest/PreferConfig/ABCConfig.cmake b/Tests/FindPackageTest/PreferConfig/ABCConfig.cmake
new file mode 100644
index 000000000..281a5cda9
--- /dev/null
+++ b/Tests/FindPackageTest/PreferConfig/ABCConfig.cmake
@@ -0,0 +1 @@
+set(ABC_FOUND TRUE)
diff --git a/Tests/FindPackageTest/PreferConfig/FindABC.cmake b/Tests/FindPackageTest/PreferConfig/FindABC.cmake
new file mode 100644
index 000000000..281a5cda9
--- /dev/null
+++ b/Tests/FindPackageTest/PreferConfig/FindABC.cmake
@@ -0,0 +1 @@
+set(ABC_FOUND TRUE)
diff --git a/Tests/FindPackageTest/PreferConfigOnlyModule/FindACME.cmake b/Tests/FindPackageTest/PreferConfigOnlyModule/FindACME.cmake
new file mode 100644
index 000000000..7a4e1b3ce
--- /dev/null
+++ b/Tests/FindPackageTest/PreferConfigOnlyModule/FindACME.cmake
@@ -0,0 +1 @@
+set(ACME_FOUND TRUE)
diff --git a/Tests/FindPackageTest/PreferConfigRecurse/ACMEConfig.cmake b/Tests/FindPackageTest/PreferConfigRecurse/ACMEConfig.cmake
new file mode 100644
index 000000000..7a4e1b3ce
--- /dev/null
+++ b/Tests/FindPackageTest/PreferConfigRecurse/ACMEConfig.cmake
@@ -0,0 +1 @@
+set(ACME_FOUND TRUE)
diff --git a/Tests/FindPackageTest/PreferConfigRecurse/FindACME.cmake b/Tests/FindPackageTest/PreferConfigRecurse/FindACME.cmake
new file mode 100644
index 000000000..9bdc7dbc3
--- /dev/null
+++ b/Tests/FindPackageTest/PreferConfigRecurse/FindACME.cmake
@@ -0,0 +1 @@
+find_package(ACME NO_MODULE)
diff --git a/Tests/FindPackageTest/cmake/SetFoundResolvedConfig.cmake b/Tests/FindPackageTest/cmake/SetFoundResolvedConfig.cmake
new file mode 100644
index 000000000..b2cf87ce6
--- /dev/null
+++ b/Tests/FindPackageTest/cmake/SetFoundResolvedConfig.cmake
@@ -0,0 +1 @@
+set(SetFoundResolved_DIR "${CMAKE_CURRENT_LIST_DIR}")
diff --git a/Tests/FindPatch/CMakeLists.txt b/Tests/FindPatch/CMakeLists.txt
new file mode 100644
index 000000000..541f5bd15
--- /dev/null
+++ b/Tests/FindPatch/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_test(NAME FindPatch.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPatch/Test"
+ "${CMake_BINARY_DIR}/Tests/FindPatch/Test"
+ ${build_generator_args}
+ --build-options ${build_options}
+)
diff --git a/Tests/FindPatch/Test/CMakeLists.txt b/Tests/FindPatch/Test/CMakeLists.txt
new file mode 100644
index 000000000..66c672c55
--- /dev/null
+++ b/Tests/FindPatch/Test/CMakeLists.txt
@@ -0,0 +1,77 @@
+cmake_minimum_required(VERSION 3.8)
+project(TestFindPatch VERSION 1.0 LANGUAGES NONE)
+
+macro(_check)
+ if(NOT EXISTS "${Patch_EXECUTABLE}")
+ message(FATAL_ERROR "Failed to lookup Patch_EXECUTABLE [${Patch_EXECUTABLE}]")
+ endif()
+
+ if(NOT DEFINED PATCH_FOUND)
+ message(FATAL_ERROR "Variable PATCH_FOUND is not defined")
+ endif()
+
+ # Is import target available ?
+ if(NOT TARGET Patch::patch)
+ message(FATAL_ERROR "Target Patch::patch is not defined")
+ endif()
+
+ # Check Patch::patch imported location
+ get_property(_imported_location TARGET Patch::patch PROPERTY IMPORTED_LOCATION)
+ if(NOT "${Patch_EXECUTABLE}" STREQUAL "${_imported_location}")
+ message(FATAL_ERROR "\
+Patch_EXECUTABLE is expected to be equal to Patch::patch IMPORTED_LOCATION
+ Patch_EXECUTABLE [${Patch_EXECUTABLE}]
+ Patch::patch IMPORTED_LOCATION [${_imported_location}]
+")
+ endif()
+
+endmacro()
+
+find_package(Patch REQUIRED)
+_check()
+
+# Calling twice should not fail
+find_package(Patch REQUIRED)
+_check()
+
+add_custom_target(TestPatchVersion ALL
+ COMMAND ${Patch_EXECUTABLE} -v
+ )
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/QUOTE.txt.baseline"
+[=[Because it's there.
+- George Mallory, 1923
+]=]
+)
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/QUOTE.txt" "Because it's there.\n")
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/quote-add-author.patch"
+[=[diff --git a/QUOTE.txt b/QUOTE.txt
+index b36681d..68059b3 100644
+--- a/QUOTE.txt
++++ b/QUOTE.txt
+@@ -1 +1,2 @@
+ Because it's there.
++- George Mallory
+]=]
+)
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/quote-add-date.patch"
+[=[diff --git a/QUOTE.txt b/QUOTE.txt
+index 68059b3..c6f30c2 100644
+--- a/QUOTE.txt
++++ b/QUOTE.txt
+@@ -1,2 +1,2 @@
+ Because it's there.
+-- George Mallory
++- George Mallory, 1923
+]=]
+)
+
+add_custom_target(TestPatch ALL
+ COMMAND ${Patch_EXECUTABLE} -p1 -i quote-add-author.patch --binary
+ COMMAND Patch::patch -p1 -i quote-add-date.patch --binary
+ COMMAND ${CMAKE_COMMAND} -E compare_files QUOTE.txt QUOTE.txt.baseline
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ )
diff --git a/Tests/FindPostgreSQL/CMakeLists.txt b/Tests/FindPostgreSQL/CMakeLists.txt
new file mode 100644
index 000000000..50151eec3
--- /dev/null
+++ b/Tests/FindPostgreSQL/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindPostgreSQL.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPostgreSQL/Test"
+ "${CMake_BINARY_DIR}/Tests/FindPostgreSQL/Test"
+ ${build_generator_args}
+ --build-project TestFindPostgreSQL
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindPostgreSQL/Test/CMakeLists.txt b/Tests/FindPostgreSQL/Test/CMakeLists.txt
new file mode 100644
index 000000000..374e1477b
--- /dev/null
+++ b/Tests/FindPostgreSQL/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.10)
+project(TestFindPostgreSQL C)
+include(CTest)
+
+find_package(PostgreSQL REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_POSTGRESQL_VERSION="${PostgreSQL_VERSION_STRING}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt PostgreSQL::PostgreSQL)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${PostgreSQL_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${PostgreSQL_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindPostgreSQL/Test/main.c b/Tests/FindPostgreSQL/Test/main.c
new file mode 100644
index 000000000..a63377a25
--- /dev/null
+++ b/Tests/FindPostgreSQL/Test/main.c
@@ -0,0 +1,24 @@
+#include <libpq-fe.h>
+#include <stdio.h>
+#include <string.h>
+
+int main()
+{
+ int version = PQlibVersion();
+ char version_string[100];
+ // 9.x and older encoding.
+ if (version < 100000) {
+ int major = version / 10000;
+ int minor = version % 10000 / 100;
+ int patch = version % 100;
+ snprintf(version_string, sizeof(version_string), "%d.%d.%d", major, minor,
+ patch);
+ } else {
+ int major = version / 10000;
+ int minor = version % 10000;
+ snprintf(version_string, sizeof(version_string), "%d.%d", major, minor);
+ }
+ printf("Found PostgreSQL version %s, expected version %s\n", version_string,
+ CMAKE_EXPECTED_POSTGRESQL_VERSION);
+ return strcmp(version_string, CMAKE_EXPECTED_POSTGRESQL_VERSION);
+}
diff --git a/Tests/FindProtobuf/Test/CMakeLists.txt b/Tests/FindProtobuf/Test/CMakeLists.txt
index 8b6e38a8e..fc6b37e95 100644
--- a/Tests/FindProtobuf/Test/CMakeLists.txt
+++ b/Tests/FindProtobuf/Test/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.4)
+cmake_minimum_required(VERSION 3.8)
project(TestFindProtobuf CXX)
include(CTest)
@@ -29,4 +29,26 @@ add_test(NAME test_tgt_protoc COMMAND test_tgt_protoc)
add_executable(test_var_protoc main-protoc.cxx)
target_include_directories(test_var_protoc PRIVATE ${Protobuf_INCLUDE_DIRS})
target_link_libraries(test_var_protoc PRIVATE ${Protobuf_PROTOC_LIBRARIES})
+target_compile_features(test_var_protoc PRIVATE cxx_std_11)
add_test(NAME test_var_protoc COMMAND test_var_protoc)
+
+add_test(NAME test_tgt_protoc_version COMMAND protobuf::protoc --version)
+
+set(Protobuf_IMPORT_DIRS ${Protobuf_INCLUDE_DIRS})
+PROTOBUF_GENERATE_CPP(PROTO_SRC PROTO_HEADER msgs/example.proto)
+PROTOBUF_GENERATE_CPP(DESC_PROTO_SRC DESC_PROTO_HEADER DESCRIPTORS DESC_PROTO_DESC msgs/example_desc.proto)
+add_library(msgs ${PROTO_SRC} ${PROTO_HEADER})
+target_compile_features(msgs PRIVATE cxx_std_11)
+
+add_executable(test_generate main-generate.cxx ${PROTO_SRC})
+target_include_directories(test_generate PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+target_link_libraries(test_generate msgs ${Protobuf_LIBRARIES})
+target_compile_features(test_generate PRIVATE cxx_std_11)
+add_test(NAME test_generate COMMAND test_generate)
+
+add_executable(test_desc main-desc.cxx ${DESC_PROTO_SRC})
+target_compile_features(test_desc PRIVATE cxx_std_11)
+target_include_directories(test_desc PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+target_link_libraries(test_desc msgs ${Protobuf_LIBRARIES})
+target_compile_features(test_desc PRIVATE cxx_std_11)
+add_test(NAME test_desc COMMAND test_desc ${DESC_PROTO_DESC})
diff --git a/Tests/FindProtobuf/Test/main-desc.cxx b/Tests/FindProtobuf/Test/main-desc.cxx
new file mode 100644
index 000000000..dc768ab99
--- /dev/null
+++ b/Tests/FindProtobuf/Test/main-desc.cxx
@@ -0,0 +1,58 @@
+#include <fstream>
+#include <google/protobuf/descriptor.pb.h>
+#include <iostream>
+#include <string>
+
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/dynamic_message.h>
+#include <google/protobuf/text_format.h>
+
+int main(int argc, char* argv[])
+{
+ std::ifstream fs;
+ fs.open(argv[1], std::ifstream::in);
+ google::protobuf::FileDescriptorSet file_descriptor_set;
+ file_descriptor_set.ParseFromIstream(&fs);
+
+ const google::protobuf::DescriptorPool* compiled_pool =
+ google::protobuf::DescriptorPool::generated_pool();
+
+ if (compiled_pool == NULL) {
+ std::cerr << "compiled pool is NULL." << std::endl;
+ return 1;
+ }
+
+ google::protobuf::DescriptorPool pool(compiled_pool);
+ google::protobuf::DynamicMessageFactory dynamic_message_factory(&pool);
+
+ for (const google::protobuf::FileDescriptorProto& file_descriptor_proto :
+ file_descriptor_set.file()) {
+ const google::protobuf::FileDescriptor* file_descriptor =
+ pool.BuildFile(file_descriptor_proto);
+ if (file_descriptor == NULL) {
+ continue;
+ }
+
+ const google::protobuf::Descriptor* descriptor =
+ pool.FindMessageTypeByName("example.msgs.ExampleDesc");
+
+ if (descriptor == NULL) {
+ continue;
+ }
+
+ google::protobuf::Message* msg =
+ dynamic_message_factory.GetPrototype(descriptor)->New();
+ std::string data = "data: 1";
+ bool success = google::protobuf::TextFormat::ParseFromString(data, msg);
+
+ if (success) {
+ return 0;
+ } else {
+ std::cerr << "Failed to parse message." << std::endl;
+ return 2;
+ }
+ }
+
+ std::cerr << "No matching message found." << std::endl;
+ return 3;
+}
diff --git a/Tests/FindProtobuf/Test/main-generate.cxx b/Tests/FindProtobuf/Test/main-generate.cxx
new file mode 100644
index 000000000..ca33a6856
--- /dev/null
+++ b/Tests/FindProtobuf/Test/main-generate.cxx
@@ -0,0 +1,8 @@
+#include <example.pb.h>
+
+int main()
+{
+ example::msgs::Example msg;
+
+ return 0;
+}
diff --git a/Tests/FindProtobuf/Test/msgs/example.proto b/Tests/FindProtobuf/Test/msgs/example.proto
new file mode 100644
index 000000000..d27262e1d
--- /dev/null
+++ b/Tests/FindProtobuf/Test/msgs/example.proto
@@ -0,0 +1,6 @@
+syntax = "proto2";
+package example.msgs;
+
+message Example {
+ required int32 data = 1;
+}
diff --git a/Tests/FindProtobuf/Test/msgs/example_desc.proto b/Tests/FindProtobuf/Test/msgs/example_desc.proto
new file mode 100644
index 000000000..44544736d
--- /dev/null
+++ b/Tests/FindProtobuf/Test/msgs/example_desc.proto
@@ -0,0 +1,10 @@
+syntax = "proto2";
+package example.msgs;
+
+import "google/protobuf/descriptor.proto";
+
+message ExampleDesc {
+ required int32 data = 1;
+
+ optional google.protobuf.FileDescriptorSet desc = 2;
+}
diff --git a/Tests/FindPython/CMakeLists.txt b/Tests/FindPython/CMakeLists.txt
new file mode 100644
index 000000000..868cfe0e1
--- /dev/null
+++ b/Tests/FindPython/CMakeLists.txt
@@ -0,0 +1,160 @@
+if(CMake_TEST_FindPython)
+ add_test(NAME FindPython.Python2.LOCATION COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/Python2"
+ "${CMake_BINARY_DIR}/Tests/FindPython/Python2.LOCATION"
+ ${build_generator_args}
+ --build-project TestPython2
+ --build-options ${build_options} -DPython2_FIND_STRATEGY=LOCATION
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ add_test(NAME FindPython.Python2.VERSION COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/Python2"
+ "${CMake_BINARY_DIR}/Tests/FindPython/Python2.VERSION"
+ ${build_generator_args}
+ --build-project TestPython2
+ --build-options ${build_options} -DPython2_FIND_STRATEGY=VERSION
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+ add_test(NAME FindPython.Python2Fail COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/Python2Fail"
+ "${CMake_BINARY_DIR}/Tests/FindPython/Python2Fail"
+ ${build_generator_args}
+ --build-project TestPython2Fail
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ set_tests_properties(FindPython.Python2Fail PROPERTIES
+ PASS_REGULAR_EXPRESSION "Could NOT find Python2 \\(missing: foobar\\)")
+
+ add_test(NAME FindPython.Python3.LOCATION COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/Python3"
+ "${CMake_BINARY_DIR}/Tests/FindPython/Python3.LOCATION"
+ ${build_generator_args}
+ --build-project TestPython3
+ --build-options ${build_options} -DPython3_FIND_STRATEGY=LOCATION
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ add_test(NAME FindPython.Python3.VERSION COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/Python3"
+ "${CMake_BINARY_DIR}/Tests/FindPython/Python3.VERSION"
+ ${build_generator_args}
+ --build-project TestPython3
+ --build-options ${build_options} -DPython3_FIND_STRATEGY=VERSION
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+ add_test(NAME FindPython.Python3Fail COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/Python3Fail"
+ "${CMake_BINARY_DIR}/Tests/FindPython/Python3Fail"
+ ${build_generator_args}
+ --build-project TestPython3Fail
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ set_tests_properties(FindPython.Python3Fail PROPERTIES
+ PASS_REGULAR_EXPRESSION "Could NOT find Python3 \\(missing: foobar\\)")
+
+ add_test(NAME FindPython.Python COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/Python"
+ "${CMake_BINARY_DIR}/Tests/FindPython/Python"
+ ${build_generator_args}
+ --build-project TestPython
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+ add_test(NAME FindPython.MultiplePackages COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/MultiplePackages"
+ "${CMake_BINARY_DIR}/Tests/FindPython/MultiplePackages"
+ ${build_generator_args}
+ --build-project TestMultiplePackages
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+ add_test(NAME FindPython.VirtualEnv COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/VirtualEnv"
+ "${CMake_BINARY_DIR}/Tests/FindPython/VirtualEnv"
+ ${build_generator_args}
+ --build-project TestVirtualEnv
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+ add_test(NAME FindPython.Python2Embedded COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/Python2Embedded"
+ "${CMake_BINARY_DIR}/Tests/FindPython/Python2Embedded"
+ ${build_generator_args}
+ --build-project TestPython2Embedded
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ add_test(NAME FindPython.Python3Embedded COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/Python3Embedded"
+ "${CMake_BINARY_DIR}/Tests/FindPython/Python3Embedded"
+ ${build_generator_args}
+ --build-project TestPython3Embedded
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+ add_test(NAME FindPython.RequiredArtifacts COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts"
+ "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts"
+ ${build_generator_args}
+ --build-project TestRequiredArtifacts
+ --build-options ${build_options} "-Dbuild_generator_args=${build_generator_args}"
+ "-DCMake_SOURCE_DIR=${CMake_SOURCE_DIR}"
+ "-DCMake_BINARY_DIR=${CMake_BINARY_DIR}"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+endif()
+
+if(CMake_TEST_FindPython_NumPy)
+ add_test(NAME FindPython.NumPy COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/NumPy"
+ "${CMake_BINARY_DIR}/Tests/FindPython/NumPy"
+ ${build_generator_args}
+ --build-project TestNumPy
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ add_test(NAME FindPython.NumPyOnly COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/NumPyOnly"
+ "${CMake_BINARY_DIR}/Tests/FindPython/NumPyOnly"
+ ${build_generator_args}
+ --build-project TestNumPyOnly
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ endif()
diff --git a/Tests/FindPython/FindPythonScript.cmake b/Tests/FindPython/FindPythonScript.cmake
new file mode 100644
index 000000000..bc7e0d195
--- /dev/null
+++ b/Tests/FindPython/FindPythonScript.cmake
@@ -0,0 +1,9 @@
+
+if (PYTHON_MUST_NOT_BE_FOUND)
+ find_package(${PYTHON_PACKAGE_NAME} QUIET)
+ if (${PYTHON_PACKAGE_NAME}_FOUND)
+ message(FATAL_ERROR "${PYTHON_PACKAGE_NAME}: unexpectedly founded.")
+ endif()
+else()
+ find_package(${PYTHON_PACKAGE_NAME} REQUIRED QUIET)
+endif()
diff --git a/Tests/FindPython/MultiplePackages/CMakeLists.txt b/Tests/FindPython/MultiplePackages/CMakeLists.txt
new file mode 100644
index 000000000..5c85155bb
--- /dev/null
+++ b/Tests/FindPython/MultiplePackages/CMakeLists.txt
@@ -0,0 +1,33 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestMultiplePackages C)
+
+find_package (Python2 REQUIRED COMPONENTS Interpreter Development)
+find_package (Python3 REQUIRED COMPONENTS Interpreter Development)
+
+# Must find Python 3
+find_package (Python REQUIRED)
+
+if (NOT Python3_EXECUTABLE STREQUAL Python_EXECUTABLE)
+ message (FATAL_ERROR
+ "Python interpreters do not match:\n"
+ " Python_EXECUTABLE='${Python_EXECUTABLE}'\n"
+ " Python3_EXECUTABLE='${Python3_EXECUTABLE}'\n"
+ )
+endif()
+
+
+Python2_add_library (spam2 MODULE ../spam.c)
+target_compile_definitions (spam2 PRIVATE PYTHON2)
+
+Python3_add_library (spam3 MODULE ../spam.c)
+target_compile_definitions (spam3 PRIVATE PYTHON3)
+
+
+add_test (NAME python2_spam2
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
+ "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")")
+
+add_test (NAME python3_spam3
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
+ "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")")
diff --git a/Tests/FindPython/NumPy/CMakeLists.txt b/Tests/FindPython/NumPy/CMakeLists.txt
new file mode 100644
index 000000000..f55702666
--- /dev/null
+++ b/Tests/FindPython/NumPy/CMakeLists.txt
@@ -0,0 +1,22 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestNumPy C)
+
+find_package (Python2 REQUIRED COMPONENTS Interpreter Development NumPy)
+find_package (Python3 REQUIRED COMPONENTS Interpreter Development NumPy)
+
+Python2_add_library (arraytest2 MODULE arraytest.c)
+target_compile_definitions (arraytest2 PRIVATE PYTHON2)
+target_link_libraries (arraytest2 PRIVATE Python2::NumPy)
+
+Python3_add_library (arraytest3 MODULE arraytest.c)
+target_compile_definitions (arraytest3 PRIVATE PYTHON3)
+target_link_libraries (arraytest3 PRIVATE Python3::NumPy)
+
+add_test (NAME python2_arraytest
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest2>"
+ "${Python2_EXECUTABLE}" -c "import numpy; import arraytest2; arraytest2.vecsq(numpy.array([1, 2, 3]));")
+
+add_test (NAME python3_arraytest
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest3>"
+ "${Python3_EXECUTABLE}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));")
diff --git a/Tests/FindPython/NumPy/arraytest.c b/Tests/FindPython/NumPy/arraytest.c
new file mode 100644
index 000000000..51db7bc34
--- /dev/null
+++ b/Tests/FindPython/NumPy/arraytest.c
@@ -0,0 +1,58 @@
+#include "Python.h"
+
+#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
+#include <math.h>
+
+#include "numpy/arrayobject.h"
+
+static PyObject* vecsq(PyObject* self, PyObject* args);
+
+static PyMethodDef arraytestMethods[] = { { "vecsq", vecsq, METH_VARARGS },
+ { NULL, NULL } };
+
+static PyObject* vecsq(PyObject* self, PyObject* args)
+{
+ PyArrayObject *vecin, *vecout;
+ npy_intp dims[2];
+ double *cin, *cout;
+ int i, j, n, m;
+
+ if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &vecin))
+ return NULL;
+
+ n = dims[0] = PyArray_NDIM(vecin);
+ vecout = (PyArrayObject*)PyArray_SimpleNew(1, dims, NPY_DOUBLE);
+
+ cin = (double*)PyArray_DATA(vecin);
+ cout = (double*)PyArray_DATA(vecout);
+
+ for (i = 0; i < n; i++) {
+ cout[i] = cin[i] * cin[i];
+ }
+ return PyArray_Return(vecout);
+}
+
+#if defined(PYTHON2)
+PyMODINIT_FUNC init_C_arraytest(void)
+{
+ (void)Py_InitModule("arraytest2", arraytestMethods);
+ import_array();
+}
+#endif
+
+#if defined(PYTHON3)
+static struct PyModuleDef arraytestmodule = {
+ PyModuleDef_HEAD_INIT, "arraytest3", /* name of module */
+ NULL, /* module documentation, may be NULL */
+ -1, /* size of per-interpreter state of the module,
+ or -1 if the module keeps state in global variables. */
+ arraytestMethods
+};
+
+PyMODINIT_FUNC PyInit_C_arraytest(void)
+{
+ PyObject* po = PyModule_Create(&arraytestmodule);
+ import_array();
+ return po;
+}
+#endif
diff --git a/Tests/FindPython/NumPyOnly/CMakeLists.txt b/Tests/FindPython/NumPyOnly/CMakeLists.txt
new file mode 100644
index 000000000..a5db6037c
--- /dev/null
+++ b/Tests/FindPython/NumPyOnly/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestNumPyOnly C)
+
+find_package(Python2 REQUIRED COMPONENTS NumPy)
+find_package(Python3 REQUIRED COMPONENTS NumPy)
+
+Python2_add_library (arraytest2 MODULE ../NumPy/arraytest.c)
+target_compile_definitions (arraytest2 PRIVATE PYTHON2)
+target_link_libraries (arraytest2 PRIVATE Python2::NumPy)
+
+Python3_add_library (arraytest3 MODULE ../NumPy/arraytest.c)
+target_compile_definitions (arraytest3 PRIVATE PYTHON3)
+target_link_libraries (arraytest3 PRIVATE Python3::NumPy)
diff --git a/Tests/FindPython/Python/CMakeLists.txt b/Tests/FindPython/Python/CMakeLists.txt
new file mode 100644
index 000000000..62c805ec7
--- /dev/null
+++ b/Tests/FindPython/Python/CMakeLists.txt
@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestPython C)
+
+include(CTest)
+
+find_package(Python 3 REQUIRED COMPONENTS Interpreter Development)
+if (NOT Python_FOUND)
+ message (FATAL_ERROR "Fail to found Python 3")
+endif()
+
+if(NOT TARGET Python::Interpreter)
+ message(SEND_ERROR "Python::Interpreter not found")
+endif()
+
+if(NOT TARGET Python::Python)
+ message(SEND_ERROR "Python::Python not found")
+endif()
+if(NOT TARGET Python::Module)
+ message(SEND_ERROR "Python::Module not found")
+endif()
+
+Python_add_library (spam3 MODULE ../spam.c)
+target_compile_definitions (spam3 PRIVATE PYTHON3)
+
+add_test (NAME python_spam3
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
+ "${Python_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")")
+
+add_test(NAME findpython_script
+ COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python
+ -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")
diff --git a/Tests/FindPython/Python2/CMakeLists.txt b/Tests/FindPython/Python2/CMakeLists.txt
new file mode 100644
index 000000000..cf77ca240
--- /dev/null
+++ b/Tests/FindPython/Python2/CMakeLists.txt
@@ -0,0 +1,38 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestPython2 C)
+
+include(CTest)
+
+find_package(Python2 3 QUIET)
+if (Python2_FOUND)
+ message (FATAL_ERROR "Wrong python version found: ${Python2_VERSION}")
+endif()
+
+find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
+if (NOT Python2_FOUND)
+ message (FATAL_ERROR "Fail to found Python 2")
+endif()
+
+if(NOT TARGET Python2::Interpreter)
+ message(SEND_ERROR "Python2::Interpreter not found")
+endif()
+
+if(NOT TARGET Python2::Python)
+ message(SEND_ERROR "Python2::Python not found")
+endif()
+if(NOT TARGET Python2::Module)
+ message(SEND_ERROR "Python2::Module not found")
+endif()
+
+Python2_add_library (spam2 MODULE ../spam.c)
+target_compile_definitions (spam2 PRIVATE PYTHON2)
+
+add_test (NAME python2_spam2
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam2>"
+ "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")")
+
+add_test(NAME findpython2_script
+ COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python2
+ -DPython2_FIND_STRATEGY=${Python2_FIND_STRATEGY}
+ -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")
diff --git a/Tests/FindPython/Python2Embedded/CMakeLists.txt b/Tests/FindPython/Python2Embedded/CMakeLists.txt
new file mode 100644
index 000000000..0115deaa3
--- /dev/null
+++ b/Tests/FindPython/Python2Embedded/CMakeLists.txt
@@ -0,0 +1,29 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestPython2Embedded C)
+
+include(CTest)
+
+find_package(Python2 REQUIRED COMPONENTS Development)
+if (NOT Python2_FOUND)
+ message (FATAL_ERROR "Fail to found Python 2")
+endif()
+
+if(NOT TARGET Python2::Python)
+ message(SEND_ERROR "Python2::Python not found")
+endif()
+
+Python2_add_library (display_time2 SHARED ../display_time.c)
+set_property (TARGET display_time2 PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
+target_compile_definitions (display_time2 PRIVATE PYTHON2)
+
+add_executable (main2 ../main.c)
+target_link_libraries (main2 PRIVATE display_time2)
+
+if (WIN32 OR CYGWIN OR MSYS OR MINGW)
+ list (JOIN Python2_RUNTIME_LIBRARY_DIRS "$<SEMICOLON>" RUNTIME_DIRS)
+ add_test (NAME Python2.Embedded COMMAND "${CMAKE_COMMAND}" -E env "PATH=${RUNTIME_DIRS}" $<TARGET_FILE:main2>)
+else()
+ add_test (NAME Python2.Embedded COMMAND main2)
+endif()
+set_property (TEST Python2.Embedded PROPERTY PASS_REGULAR_EXPRESSION "Today is")
diff --git a/Tests/FindPython/Python2Fail/CMakeLists.txt b/Tests/FindPython/Python2Fail/CMakeLists.txt
new file mode 100644
index 000000000..989688f55
--- /dev/null
+++ b/Tests/FindPython/Python2Fail/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestPython2Fail C)
+
+include(CTest)
+
+find_package(Python2 REQUIRED COMPONENTS Interpreter Development foobar)
+
+Python2_add_library (spam2 MODULE ../spam.c)
+target_compile_definitions (spam2 PRIVATE PYTHON2)
+
+add_test (NAME python2_spam2
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam2>"
+ "${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")")
diff --git a/Tests/FindPython/Python3/CMakeLists.txt b/Tests/FindPython/Python3/CMakeLists.txt
new file mode 100644
index 000000000..6691a48a2
--- /dev/null
+++ b/Tests/FindPython/Python3/CMakeLists.txt
@@ -0,0 +1,90 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestPython3 C)
+
+include(CTest)
+
+find_package(Python3 2 QUIET)
+if (Python3_FOUND)
+ message (FATAL_ERROR "Wrong python version found: ${Python3_VERSION}")
+endif()
+
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
+if (NOT Python3_FOUND)
+ message (FATAL_ERROR "Fail to found Python 3")
+endif()
+
+if(NOT TARGET Python3::Interpreter)
+ message(SEND_ERROR "Python2::Interpreter not found")
+endif()
+
+if(NOT TARGET Python3::Python)
+ message(SEND_ERROR "Python2::Python not found")
+endif()
+if(NOT TARGET Python3::Module)
+ message(SEND_ERROR "Python2::Module not found")
+endif()
+
+Python3_add_library (spam3 MODULE ../spam.c)
+target_compile_definitions (spam3 PRIVATE PYTHON3)
+
+add_test (NAME python3_spam3
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
+ "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")")
+
+add_test(NAME findpython3_script
+ COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python3
+ -DPython3_FIND_STRATEGY=${Python3_FIND_STRATEGY}
+ -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")
+
+
+## Try a new search specifying only expected ABI
+# retrieve ABI of python interpreter
+execute_process (COMMAND "${Python3_EXECUTABLE}" -c
+ "import sys; sys.stdout.write(sys.abiflags)"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE abi
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+if (result)
+ # assume ABI is not supported
+ set (abi "")
+endif()
+
+# define FIND_ABI variable
+if (abi MATCHES "d")
+ set (Python3_VALID_ABI "ON")
+else()
+ set (Python3_VALID_ABI "OFF")
+endif()
+if (abi MATCHES "m")
+ list (APPEND Python3_VALID_ABI "ON")
+else()
+ list (APPEND Python3_VALID_ABI "OFF")
+endif()
+if (abi MATCHES "u")
+ list (APPEND Python3_VALID_ABI "ON")
+else()
+ list (APPEND Python3_VALID_ABI "OFF")
+endif()
+# build an invalid pattern for ABI
+set (Python3_INVALID_ABI)
+foreach (abi IN LISTS Python3_VALID_ABI)
+ if (abi)
+ list (APPEND Python3_INVALID_ABI "OFF")
+ else()
+ list (APPEND Python3_INVALID_ABI "ON")
+ endif()
+endforeach()
+
+add_test(NAME python3_find_valid_abi
+ COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python3
+ -DPython3_FIND_STRATEGY=${Python3_FIND_STRATEGY}
+ "-DPython3_FIND_ABI=${Python3_VALID_ABI}"
+ -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")
+add_test(NAME python3_find_invalid_abi
+ COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python3
+ -DPYTHON_MUST_NOT_BE_FOUND=ON
+ -DPython3_FIND_STRATEGY=${Python3_FIND_STRATEGY}
+ "-DPython3_FIND_ABI=${Python3_INVALID_ABI}"
+ -P "${CMAKE_CURRENT_LIST_DIR}/../FindPythonScript.cmake")
diff --git a/Tests/FindPython/Python3Embedded/CMakeLists.txt b/Tests/FindPython/Python3Embedded/CMakeLists.txt
new file mode 100644
index 000000000..4eb7ebc14
--- /dev/null
+++ b/Tests/FindPython/Python3Embedded/CMakeLists.txt
@@ -0,0 +1,29 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestPython3Embedded C)
+
+include(CTest)
+
+find_package(Python3 REQUIRED COMPONENTS Development)
+if (NOT Python3_FOUND)
+ message (FATAL_ERROR "Fail to found Python 3")
+endif()
+
+if(NOT TARGET Python3::Python)
+ message(SEND_ERROR "Python3::Python not found")
+endif()
+
+Python3_add_library (display_time3 SHARED ../display_time.c)
+set_property (TARGET display_time3 PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
+target_compile_definitions (display_time3 PRIVATE PYTHON3)
+
+add_executable (main3 ../main.c)
+target_link_libraries (main3 PRIVATE display_time3)
+
+if (WIN32 OR CYGWIN OR MSYS OR MINGW)
+ list (JOIN Python3_RUNTIME_LIBRARY_DIRS "$<SEMICOLON>" RUNTIME_DIRS)
+ add_test (NAME Python3.Embedded COMMAND "${CMAKE_COMMAND}" -E env "PATH=${RUNTIME_DIRS}" $<TARGET_FILE:main3>)
+else()
+ add_test (NAME Python3.Embedded COMMAND main3)
+endif()
+set_property (TEST Python3.Embedded PROPERTY PASS_REGULAR_EXPRESSION "Today is")
diff --git a/Tests/FindPython/Python3Fail/CMakeLists.txt b/Tests/FindPython/Python3Fail/CMakeLists.txt
new file mode 100644
index 000000000..cd46c8864
--- /dev/null
+++ b/Tests/FindPython/Python3Fail/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestPython3Fail C)
+
+include(CTest)
+
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development foobar)
+
+Python3_add_library (spam3 MODULE ../spam.c)
+target_compile_definitions (spam3 PRIVATE PYTHON3)
+
+add_test (NAME python3_spam3
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
+ "${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")")
diff --git a/Tests/FindPython/RequiredArtifacts/CMakeLists.txt b/Tests/FindPython/RequiredArtifacts/CMakeLists.txt
new file mode 100644
index 000000000..39e8ea562
--- /dev/null
+++ b/Tests/FindPython/RequiredArtifacts/CMakeLists.txt
@@ -0,0 +1,110 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestRequiredArtifacts LANGUAGES C)
+
+include(CTest)
+
+find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
+if (NOT Python2_FOUND)
+ message (FATAL_ERROR "Fail to found Python 2")
+endif()
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
+if (NOT Python3_FOUND)
+ message (FATAL_ERROR "Fail to found Python 3")
+endif()
+
+
+add_test(NAME FindPython.RequiredArtifacts.Interpreter.VALID COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check"
+ "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Interpreter.VALID"
+ ${build_generator_args}
+ --build-project TestRequiredArtifacts.Check
+ --build-options -DPYTHON_IS_FOUND=TRUE -DCHECK_INTERPRETER=ON
+ "-DPython3_EXECUTABLE=${Python3_EXECUTABLE}"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+add_test(NAME FindPython.RequiredArtifacts.Interpreter.INVALID COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check"
+ "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Interpreter.INVALID"
+ ${build_generator_args}
+ --build-project TestRequiredArtifacts.Check
+ --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_INTERPRETER=ON
+ "-DPython3_EXECUTABLE=${Python3_EXECUTABLE}-bad${CMAKE_EXECUTABLE_SUFFIX}"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+add_test(NAME FindPython.RequiredArtifacts.Library.VALID COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check"
+ "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Library.VALID"
+ ${build_generator_args}
+ --build-project TestRequiredArtifacts.Check
+ --build-options -DPYTHON_IS_FOUND=TRUE -DCHECK_LIBRARY=ON
+ "-DPython3_LIBRARY=${Python3_LIBRARY_RELEASE}"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+add_test(NAME FindPython.RequiredArtifacts.Library.INVALID COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check"
+ "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Library.INVALID"
+ ${build_generator_args}
+ --build-project TestRequiredArtifacts.Check
+ --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_LIBRARY=ON
+ "-DPython3_LIBRARY=${Python2_LIBRARY_RELEASE}"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+add_test(NAME FindPython.RequiredArtifacts.Include.VALID COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check"
+ "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Include.VALID"
+ ${build_generator_args}
+ --build-project TestRequiredArtifacts.Check
+ --build-options -DPYTHON_IS_FOUND=TRUE -DCHECK_INCLUDE=ON
+ "-DPython3_INCLUDE_DIR=${Python3_INCLUDE_DIRS}"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+add_test(NAME FindPython.RequiredArtifacts.Include.INVALID COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check"
+ "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Include.INVALID"
+ ${build_generator_args}
+ --build-project TestRequiredArtifacts.Check
+ --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_INCLUDE=ON
+ "-DPython3_INCLUDE_DIR=${Python2_INCLUDE_DIRS}"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+add_test(NAME FindPython.RequiredArtifacts.Interpreter-Library.INVALID COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check"
+ "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Interpreter-Library.INVALID"
+ ${build_generator_args}
+ --build-project TestRequiredArtifacts.Check
+ --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_INTERPRETER=ON -DCHECK_LIBRARY=ON
+ "-DPython3_EXECUTABLE=${Python3_EXECUTABLE}"
+ "-DPython3_LIBRARY=${Python2_LIBRARY_RELEASE}"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+add_test(NAME FindPython.RequiredArtifacts.Library-Include.INVALID COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindPython/RequiredArtifacts/Check"
+ "${CMake_BINARY_DIR}/Tests/FindPython/RequiredArtifacts/Library-Include.INVALID"
+ ${build_generator_args}
+ --build-project TestRequiredArtifacts.Check
+ --build-options -DPYTHON_IS_FOUND=FALSE -DCHECK_LIBRARY=ON -DCHECK_INCLUDE=ON
+ "-DPython3_LIBRARY=${Python3_LIBRARY_RELEASE}"
+ "-DPython3_INCLUDE_DIR=${Python2_INCLUDE_DIRS}"
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt b/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt
new file mode 100644
index 000000000..b859ac57f
--- /dev/null
+++ b/Tests/FindPython/RequiredArtifacts/Check/CMakeLists.txt
@@ -0,0 +1,41 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestRequiredArtifacts.Check LANGUAGES C)
+
+set (components)
+if (CHECK_INTERPRETER)
+ set (required_interpreter "${Python3_EXECUTABLE}")
+ list (APPEND components Interpreter)
+endif()
+if (CHECK_LIBRARY OR CHECK_INCLUDE)
+ list (APPEND components Development)
+ if (CHECK_LIBRARY)
+ set (required_library "${Python3_LIBRARY}")
+ endif()
+ if (CHECK_INCLUDE)
+ set (required_include "${Python3_INCLUDE_DIR}")
+ endif()
+endif()
+
+find_package (Python3 COMPONENTS ${components})
+
+
+if (PYTHON_IS_FOUND AND NOT Python3_FOUND)
+ message (FATAL_ERROR "Python3 unexpectedly not found")
+endif()
+if (NOT PYTHON_IS_FOUND AND Python3_FOUND)
+ message (FATAL_ERROR "Python3 unexpectedly found")
+endif()
+
+
+if (CHECK_INTERPRETER AND NOT Python3_EXECUTABLE STREQUAL required_interpreter)
+ message (FATAL_ERROR "Fail to use input variable Python3_EXECUTABLE")
+endif()
+
+if (CHECK_LIBRARY AND NOT Python3_LIBRARY_RELEASE STREQUAL required_library)
+ message (FATAL_ERROR "Fail to use input variable Python3_LIBRARY")
+endif()
+
+if (CHECK_INCLUDE AND NOT Python3_INCLUDE_DIRS STREQUAL required_include)
+ message (FATAL_ERROR "Fail to use input variable Python3_INCLUDE_DIR")
+endif()
diff --git a/Tests/FindPython/VirtualEnv/CMakeLists.txt b/Tests/FindPython/VirtualEnv/CMakeLists.txt
new file mode 100644
index 000000000..64ba20186
--- /dev/null
+++ b/Tests/FindPython/VirtualEnv/CMakeLists.txt
@@ -0,0 +1,42 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestVirtualEnv LANGUAGES NONE)
+
+include(CTest)
+
+find_package(Python3 REQUIRED COMPONENTS Interpreter)
+if (NOT Python3_FOUND)
+ message (FATAL_ERROR "Fail to found Python 3")
+endif()
+
+set (Python3_VIRTUAL_ENV "${CMAKE_CURRENT_BINARY_DIR}/py3venv")
+
+execute_process (COMMAND "${Python3_EXECUTABLE}" -m venv "${Python3_VIRTUAL_ENV}"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE outputs
+ ERROR_VARIABLE outputs)
+if (result)
+ message (FATAL_ERROR "Fail to create virtual environment: ${outputs}")
+endif()
+
+add_test(NAME FindPython3.VirtualEnvDefault
+ COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME
+ "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}"
+ "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}"
+ -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvDefault.cmake")
+
+add_test(NAME FindPython3.VirtualEnvOnly
+ COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME
+ "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}"
+ "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}"
+ -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake")
+add_test(NAME FindPython3.UnsetVirtualEnvOnly
+ COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME
+ --unset=VIRTUAL_ENV
+ "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvOnly.cmake")
+
+add_test(NAME FindPython3.VirtualEnvStandard
+ COMMAND "${CMAKE_COMMAND}" -E env --unset=PYTHONHOME
+ "VIRTUAL_ENV=${Python3_VIRTUAL_ENV}"
+ "${CMAKE_COMMAND}" "-DPYTHON3_VIRTUAL_ENV=${Python3_VIRTUAL_ENV}"
+ -P "${CMAKE_CURRENT_LIST_DIR}/VirtualEnvStandard.cmake")
diff --git a/Tests/FindPython/VirtualEnv/VirtualEnvDefault.cmake b/Tests/FindPython/VirtualEnv/VirtualEnvDefault.cmake
new file mode 100644
index 000000000..020ecacd9
--- /dev/null
+++ b/Tests/FindPython/VirtualEnv/VirtualEnvDefault.cmake
@@ -0,0 +1,6 @@
+
+find_package (Python3 REQUIRED)
+
+if (NOT Python3_EXECUTABLE MATCHES "^${PYTHON3_VIRTUAL_ENV}/.+")
+ message (FATAL_ERROR "Fail to use virtual environment")
+endif()
diff --git a/Tests/FindPython/VirtualEnv/VirtualEnvOnly.cmake b/Tests/FindPython/VirtualEnv/VirtualEnvOnly.cmake
new file mode 100644
index 000000000..29a49249c
--- /dev/null
+++ b/Tests/FindPython/VirtualEnv/VirtualEnvOnly.cmake
@@ -0,0 +1,16 @@
+
+#
+# Virtual environment is defined for python3
+# Trying to find a python2 using only virtual environment
+# It is expecting to fail if a virtual environment is active and to success otherwise.
+#
+set (Python2_FIND_VIRTUALENV ONLY)
+find_package (Python2 QUIET)
+
+if (PYTHON3_VIRTUAL_ENV AND Python2_FOUND)
+ message (FATAL_ERROR "Python2 unexpectedly found.")
+endif()
+
+if (NOT PYTHON3_VIRTUAL_ENV AND NOT Python2_FOUND)
+ message (FATAL_ERROR "Fail to find Python2.")
+endif()
diff --git a/Tests/FindPython/VirtualEnv/VirtualEnvStandard.cmake b/Tests/FindPython/VirtualEnv/VirtualEnvStandard.cmake
new file mode 100644
index 000000000..89f27d8da
--- /dev/null
+++ b/Tests/FindPython/VirtualEnv/VirtualEnvStandard.cmake
@@ -0,0 +1,7 @@
+
+set (Python3_FIND_VIRTUALENV STANDARD)
+find_package (Python3 REQUIRED)
+
+if (Python3_EXECUTABLE MATCHES "^${PYTHON3_VIRTUAL_ENV}/.+")
+ message (FATAL_ERROR "Python3 virtual env unexpectedly found.")
+endif()
diff --git a/Tests/FindPython/display_time.c b/Tests/FindPython/display_time.c
new file mode 100644
index 000000000..0e7843422
--- /dev/null
+++ b/Tests/FindPython/display_time.c
@@ -0,0 +1,36 @@
+
+#include <stdio.h>
+
+#define PY_SSIZE_T_CLEAN
+#include <Python.h>
+
+#include "display_time.h"
+
+void display_time()
+{
+#if defined(PYTHON3)
+ wchar_t* program = Py_DecodeLocale("display_time", NULL);
+ if (program == NULL) {
+ fprintf(stderr, "Fatal error: cannot decode argv[0]\n");
+ exit(1);
+ }
+ char* cmd = "from time import time,ctime\n"
+ "print('Today is', ctime(time()))\n";
+#else
+ char* program = "display_time";
+ char* cmd = "from time import time,ctime\n"
+ "print 'Today is', ctime(time())\n";
+#endif
+
+ Py_SetProgramName(program); /* optional but recommended */
+ Py_Initialize();
+ PyRun_SimpleString(cmd);
+#if defined(PYTHON3)
+ if (Py_FinalizeEx() < 0) {
+ exit(120);
+ }
+ PyMem_RawFree(program);
+#else
+ Py_Finalize();
+#endif
+}
diff --git a/Tests/FindPython/display_time.h b/Tests/FindPython/display_time.h
new file mode 100644
index 000000000..d825e0273
--- /dev/null
+++ b/Tests/FindPython/display_time.h
@@ -0,0 +1,2 @@
+
+void display_time();
diff --git a/Tests/FindPython/main.c b/Tests/FindPython/main.c
new file mode 100644
index 000000000..0acba2917
--- /dev/null
+++ b/Tests/FindPython/main.c
@@ -0,0 +1,7 @@
+
+#include "display_time.h"
+
+int main()
+{
+ display_time();
+}
diff --git a/Tests/FindPython/spam.c b/Tests/FindPython/spam.c
new file mode 100644
index 000000000..1c65d5486
--- /dev/null
+++ b/Tests/FindPython/spam.c
@@ -0,0 +1,41 @@
+
+#include <Python.h>
+
+static PyObject* spam_system(PyObject* self, PyObject* args)
+{
+ const char* command;
+ int sts;
+
+ if (!PyArg_ParseTuple(args, "s", &command))
+ return NULL;
+ sts = system(command);
+ /* return PyLong_FromLong(sts); */
+ return Py_BuildValue("i", sts);
+}
+
+static PyMethodDef SpamMethods[] = {
+ { "system", spam_system, METH_VARARGS, "Execute a shell command." },
+ { NULL, NULL, 0, NULL } /* Sentinel */
+};
+
+#if defined(PYTHON2)
+PyMODINIT_FUNC initspam2(void)
+{
+ (void)Py_InitModule("spam2", SpamMethods);
+}
+#endif
+
+#if defined(PYTHON3)
+static struct PyModuleDef spammodule = {
+ PyModuleDef_HEAD_INIT, "spam3", /* name of module */
+ NULL, /* module documentation, may be NULL */
+ -1, /* size of per-interpreter state of the module,
+ or -1 if the module keeps state in global variables. */
+ SpamMethods
+};
+
+PyMODINIT_FUNC PyInit_spam3(void)
+{
+ return PyModule_Create(&spammodule);
+}
+#endif
diff --git a/Tests/FindSQLite3/CMakeLists.txt b/Tests/FindSQLite3/CMakeLists.txt
new file mode 100644
index 000000000..8bf170e35
--- /dev/null
+++ b/Tests/FindSQLite3/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindSQLite3.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindSQLite3/Test"
+ "${CMake_BINARY_DIR}/Tests/FindSQLite3/Test"
+ ${build_generator_args}
+ --build-project TestFindSQLite3
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindSQLite3/Test/CMakeLists.txt b/Tests/FindSQLite3/Test/CMakeLists.txt
new file mode 100644
index 000000000..bcc6ebd20
--- /dev/null
+++ b/Tests/FindSQLite3/Test/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.4)
+project(TestFindSQLite3 C)
+include(CTest)
+
+find_package(SQLite3 REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_SQLite3_VERSION="${SQLite3_VERSION}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt SQLite::SQLite3)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${SQLite3_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${SQLite3_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindSQLite3/Test/main.c b/Tests/FindSQLite3/Test/main.c
new file mode 100644
index 000000000..fb17c672a
--- /dev/null
+++ b/Tests/FindSQLite3/Test/main.c
@@ -0,0 +1,9 @@
+#include <sqlite3.h>
+#include <string.h>
+
+int main()
+{
+ char sqlite3_version[] = SQLITE_VERSION;
+
+ return strcmp(sqlite3_version, CMAKE_EXPECTED_SQLite3_VERSION);
+}
diff --git a/Tests/FindThreads/C-only/CMakeLists.txt b/Tests/FindThreads/C-only/CMakeLists.txt
index ab4ca0ddd..ee2a5f991 100644
--- a/Tests/FindThreads/C-only/CMakeLists.txt
+++ b/Tests/FindThreads/C-only/CMakeLists.txt
@@ -1,7 +1,6 @@
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(FindThreads_C-only C)
-set(CMAKE_THREAD_PREFER_PTHREAD On)
find_package(Threads REQUIRED)
if (NOT WIN32)
diff --git a/Tests/FindThreads/CXX-only/CMakeLists.txt b/Tests/FindThreads/CXX-only/CMakeLists.txt
index 999312322..3c6cc1e55 100644
--- a/Tests/FindThreads/CXX-only/CMakeLists.txt
+++ b/Tests/FindThreads/CXX-only/CMakeLists.txt
@@ -1,7 +1,6 @@
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(FindThreads_CXX-only CXX)
-set(CMAKE_THREAD_PREFER_PTHREAD On)
find_package(Threads REQUIRED)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../../../Modules/CheckForPthreads.c
diff --git a/Tests/FindX11/CMakeLists.txt b/Tests/FindX11/CMakeLists.txt
new file mode 100644
index 000000000..cc931a1b8
--- /dev/null
+++ b/Tests/FindX11/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindX11.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindX11/Test"
+ "${CMake_BINARY_DIR}/Tests/FindX11/Test"
+ ${build_generator_args}
+ --build-project TestFindX11
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindX11/Test/CMakeLists.txt b/Tests/FindX11/Test/CMakeLists.txt
new file mode 100644
index 000000000..769271f4b
--- /dev/null
+++ b/Tests/FindX11/Test/CMakeLists.txt
@@ -0,0 +1,89 @@
+cmake_minimum_required(VERSION 3.10)
+project(TestFindX11 C)
+include(CTest)
+
+find_package(X11 REQUIRED)
+
+function (test_x11_component have_var component)
+ if (NOT X11_${component}_FOUND)
+ message("Skipping ${component} because it was not found.")
+ return ()
+ endif ()
+
+ add_executable(test_tgt_${component} main.c)
+ target_link_libraries(test_tgt_${component} PRIVATE X11::${component})
+ target_compile_definitions(test_tgt_${component} PRIVATE HAVE_X11_${component})
+ add_test(NAME test_tgt_${component} COMMAND test_tgt_${component})
+
+ # Add to the list of components to test for the parent.
+ set(${have_var}
+ ${${have_var}}
+ HAVE_X11_${component}
+ PARENT_SCOPE)
+endfunction ()
+
+set(x11_components)
+test_x11_component(x11_components ICE)
+test_x11_component(x11_components SM)
+# Not a component; hack it up.
+set(X11_X11_FOUND ${X11_FOUND})
+test_x11_component(x11_components X11)
+test_x11_component(x11_components Xau)
+test_x11_component(x11_components Xcomposite)
+test_x11_component(x11_components Xdamage)
+test_x11_component(x11_components Xdmcp)
+test_x11_component(x11_components Xext)
+test_x11_component(x11_components Xxf86misc)
+test_x11_component(x11_components Xxf86vm)
+test_x11_component(x11_components Xfixes)
+# We ignore the Xft component because the variables do not provide the required
+# dependency information (Freetype and Fontconfig).
+test_x11_component(x11_components_ignore Xft)
+test_x11_component(x11_components Xi)
+test_x11_component(x11_components Xinerama)
+test_x11_component(x11_components Xkb)
+test_x11_component(x11_components xkbfile)
+test_x11_component(x11_components Xmu)
+test_x11_component(x11_components Xpm)
+test_x11_component(x11_components Xtst)
+test_x11_component(x11_components Xrandr)
+test_x11_component(x11_components Xrender)
+test_x11_component(x11_components XRes)
+test_x11_component(x11_components Xss)
+test_x11_component(x11_components Xt)
+test_x11_component(x11_components Xutil)
+test_x11_component(x11_components Xv)
+
+# The variables do not include dependency information. Just test "everything".
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${X11_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${X11_LIBRARIES})
+# Not included in X11_LIBRARIES.
+foreach(lib
+ Xau
+ Xcomposite
+ Xdamage
+ Xdmcp
+ Xxf86misc
+ Xxf86vm
+ Xfixes
+ Xi
+ Xinerama
+ Xkb
+ xkbfile
+ Xmu
+ Xpm
+ Xtst
+ Xrandr
+ Xrender
+ XRes
+ Xss
+ Xt
+ Xv
+ )
+ if (X11_${lib}_FOUND)
+ target_link_libraries(test_var PRIVATE ${X11_${lib}_LIB})
+ endif ()
+endforeach()
+target_compile_definitions(test_var PRIVATE ${x11_components})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindX11/Test/main.c b/Tests/FindX11/Test/main.c
new file mode 100644
index 000000000..c8144e09c
--- /dev/null
+++ b/Tests/FindX11/Test/main.c
@@ -0,0 +1,404 @@
+#ifdef HAVE_X11_ICE
+# include <X11/ICE/ICElib.h>
+
+static Status test_ICE(void)
+{
+ return IceInitThreads();
+}
+#endif
+
+#ifdef HAVE_X11_SM
+# include <X11/SM/SMlib.h>
+# include <stdlib.h>
+
+static void test_SM(void)
+{
+ SmcProtocolVersion(NULL);
+}
+#endif
+
+#ifdef HAVE_X11_X11
+# include <X11/Xlib.h>
+
+static Status test_X11(void)
+{
+ return XInitThreads();
+}
+#endif
+
+#ifdef HAVE_X11_Xau
+# include <X11/Xauth.h>
+
+static char* test_Xau(void)
+{
+ return XauFileName();
+}
+#endif
+
+#ifdef HAVE_X11_Xcomposite
+# include <X11/extensions/Xcomposite.h>
+
+static int test_Xcomposite(void)
+{
+ return XCompositeVersion();
+}
+#endif
+
+#ifdef HAVE_X11_Xdamage
+# include <X11/extensions/Xdamage.h>
+
+static Bool test_Xdamage(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ int ev_base;
+ int err_base;
+ Bool ret = XDamageQueryExtension(dpy, &ev_base, &err_base);
+ XCloseDisplay(dpy);
+ return ret;
+}
+#endif
+
+#ifdef HAVE_X11_Xdmcp
+# include <X11/Xdmcp.h>
+
+static int test_Xdmcp(void)
+{
+ BYTE data[1024];
+ XdmcpBuffer buf = { data, sizeof(data), 0, 0 };
+ return XdmcpReadRemaining(&buf);
+}
+#endif
+
+#ifdef HAVE_X11_Xext
+# include <X11/Xlib.h>
+# include <X11/extensions/Xext.h>
+
+static int test_Xext(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ int ret = XMissingExtension(dpy, "cmake");
+ XCloseDisplay(dpy);
+ return ret;
+}
+#endif
+
+#ifdef HAVE_X11_Xxf86misc
+# include <X11/Xlib.h>
+# include <X11/extensions/xf86misc.h>
+
+static Bool test_Xxf86misc(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ Bool ret = XF86MiscSetClientVersion(dpy);
+ XCloseDisplay(dpy);
+ return ret;
+}
+#endif
+
+#ifdef HAVE_X11_Xxf86vm
+# include <X11/Xlib.h>
+# include <X11/extensions/xf86vmode.h>
+
+static Bool test_Xxf86vm(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ Bool ret = XF86VidModeSetClientVersion(dpy);
+ XCloseDisplay(dpy);
+ return ret;
+}
+#endif
+
+#ifdef HAVE_X11_Xfixes
+# include <X11/extensions/Xfixes.h>
+
+static Bool test_Xfixes(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ int ev_base;
+ int err_base;
+ Bool ret = XFixesQueryExtension(dpy, &ev_base, &err_base);
+ XCloseDisplay(dpy);
+ return ret;
+}
+#endif
+
+#ifdef HAVE_X11_Xft
+# include <X11/Xft/Xft.h>
+
+static FcBool test_Xft(void)
+{
+ return XftInitFtLibrary();
+}
+#endif
+
+#ifdef HAVE_X11_Xi
+# include <X11/extensions/XInput.h>
+
+static XExtensionVersion* test_Xi(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ XExtensionVersion* ret = XGetExtensionVersion(dpy, "cmake");
+ XCloseDisplay(dpy);
+ return ret;
+}
+#endif
+
+#ifdef HAVE_X11_Xinerama
+# include <X11/extensions/Xinerama.h>
+
+static Bool test_Xinerama(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ int ev_base;
+ int err_base;
+ Bool ret = XineramaQueryExtension(dpy, &ev_base, &err_base);
+ XCloseDisplay(dpy);
+ return ret;
+}
+#endif
+
+#ifdef HAVE_X11_Xkb
+# include <X11/XKBlib.h>
+
+static Bool test_Xkb(void)
+{
+ return XkbIgnoreExtension(0);
+}
+#endif
+
+#ifdef HAVE_X11_xkbfile
+// clang-format off
+# include <stdio.h>
+# include <X11/XKBlib.h>
+# include <X11/extensions/XKBfile.h>
+# include <stdlib.h>
+// clang-format on
+
+static void test_xkbfile(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ XkbInitAtoms(dpy);
+ XCloseDisplay(dpy);
+}
+#endif
+
+#ifdef HAVE_X11_Xmu
+# include <X11/Xmu/Xmu.h>
+# include <stdlib.h>
+
+static Bool test_Xmu(void)
+{
+ return XmuValidArea(NULL);
+}
+#endif
+
+#ifdef HAVE_X11_Xpm
+# include <X11/xpm.h>
+
+static int test_Xpm(void)
+{
+ return XpmAttributesSize();
+}
+#endif
+
+#ifdef HAVE_X11_Xtst
+# include <X11/extensions/XTest.h>
+
+static Status test_Xtst(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ Status ret = XTestDiscard(dpy);
+ XCloseDisplay(dpy);
+ return ret;
+}
+#endif
+
+#ifdef HAVE_X11_Xrandr
+# include <X11/extensions/Xrandr.h>
+
+static Bool test_Xrandr(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ int ev_base;
+ int err_base;
+ Bool ret = XRRQueryExtension(dpy, &ev_base, &err_base);
+ XCloseDisplay(dpy);
+ return ret;
+}
+#endif
+
+#ifdef HAVE_X11_Xrender
+# include <X11/extensions/Xrender.h>
+
+static Bool test_Xrender(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ int ev_base;
+ int err_base;
+ Bool ret = XRenderQueryExtension(dpy, &ev_base, &err_base);
+ XCloseDisplay(dpy);
+ return ret;
+}
+#endif
+
+#ifdef HAVE_X11_XRes
+# include <X11/Xlib.h>
+# include <X11/extensions/XRes.h>
+
+static Bool test_XRes(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ int ev_base;
+ int err_base;
+ Bool ret = XResQueryExtension(dpy, &ev_base, &err_base);
+ XCloseDisplay(dpy);
+ return ret;
+}
+#endif
+
+#ifdef HAVE_X11_Xss
+# include <X11/extensions/scrnsaver.h>
+
+static Bool test_Xss(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ int ev_base;
+ int err_base;
+ Bool ret = XScreenSaverQueryExtension(dpy, &ev_base, &err_base);
+ XCloseDisplay(dpy);
+ return ret;
+}
+#endif
+
+#ifdef HAVE_X11_Xt
+# include <X11/Intrinsic.h>
+
+static void test_Xt(void)
+{
+ return XtToolkitInitialize();
+}
+#endif
+
+#ifdef HAVE_X11_Xutil
+# include <X11/Xutil.h>
+
+static int test_Xutil(void)
+{
+ Region r = XCreateRegion();
+ return XDestroyRegion(r);
+}
+#endif
+
+#ifdef HAVE_X11_Xv
+# include <X11/Xlib.h>
+# include <X11/extensions/Xvlib.h>
+
+static int test_Xv(void)
+{
+ Display* dpy = XOpenDisplay(NULL);
+ unsigned int version;
+ unsigned int revision;
+ unsigned int req_base;
+ unsigned int ev_base;
+ unsigned int err_base;
+ int ret =
+ XvQueryExtension(dpy, &version, &revision, &req_base, &ev_base, &err_base);
+ XCloseDisplay(dpy);
+ return ret;
+}
+#endif
+
+#include <stddef.h>
+
+int main(int argc, char* argv[])
+{
+ (void)argv;
+ void* fptrs[] = {
+#ifdef HAVE_X11_ICE
+ test_ICE,
+#endif
+#ifdef HAVE_X11_SM
+ test_SM,
+#endif
+#ifdef HAVE_X11_X11
+ test_X11,
+#endif
+#ifdef HAVE_X11_Xau
+ test_Xau,
+#endif
+#ifdef HAVE_X11_Xcomposite
+ test_Xcomposite,
+#endif
+#ifdef HAVE_X11_Xdamage
+ test_Xdamage,
+#endif
+#ifdef HAVE_X11_Xdmcp
+ test_Xdmcp,
+#endif
+#ifdef HAVE_X11_Xext
+ test_Xext,
+#endif
+#ifdef HAVE_X11_Xxf86misc
+ test_Xxf86misc,
+#endif
+#ifdef HAVE_X11_Xxf86vm
+ test_Xxf86vm,
+#endif
+#ifdef HAVE_X11_Xfixes
+ test_Xfixes,
+#endif
+#ifdef HAVE_X11_Xft
+ test_Xft,
+#endif
+#ifdef HAVE_X11_Xi
+ test_Xi,
+#endif
+#ifdef HAVE_X11_Xinerama
+ test_Xinerama,
+#endif
+#ifdef HAVE_X11_Xkb
+ test_Xkb,
+#endif
+#ifdef HAVE_X11_xkbfile
+ test_xkbfile,
+#endif
+#ifdef HAVE_X11_Xmu
+ test_Xmu,
+#endif
+#ifdef HAVE_X11_Xpm
+ test_Xpm,
+#endif
+#ifdef HAVE_X11_Xtst
+ test_Xtst,
+#endif
+#ifdef HAVE_X11_Xrandr
+ test_Xrandr,
+#endif
+#ifdef HAVE_X11_Xrender
+ test_Xrender,
+#endif
+#ifdef HAVE_X11_XRes
+ test_XRes,
+#endif
+#ifdef HAVE_X11_Xss
+ test_Xss,
+#endif
+#ifdef HAVE_X11_Xt
+ test_Xt,
+#endif
+#ifdef HAVE_X11_Xutil
+ test_Xutil,
+#endif
+#ifdef HAVE_X11_Xv
+ test_Xv,
+#endif
+ NULL,
+ };
+
+ // The code here is to convince the compiler to keep the static functions but
+ // without calling them. This ends up always being "0" because `argc` is
+ // 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.
+ return (int)fptrs[(sizeof(fptrs) / sizeof(*fptrs)) - argc];
+}
diff --git a/Tests/ForceInclude/foo.c b/Tests/ForceInclude/foo.c
index 7f550d0f9..2a26c6f33 100644
--- a/Tests/ForceInclude/foo.c
+++ b/Tests/ForceInclude/foo.c
@@ -1,8 +1,8 @@
#ifndef FOO_1
-#error "foo1.h not included by /FI"
+# error "foo1.h not included by /FI"
#endif
#ifndef FOO_2
-#error "foo2.h not included by /FI"
+# error "foo2.h not included by /FI"
#endif
int main(void)
{
diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt
index 740e6f594..929fa4ddf 100644
--- a/Tests/Fortran/CMakeLists.txt
+++ b/Tests/Fortran/CMakeLists.txt
@@ -46,7 +46,7 @@ function(test_fortran_c_interface_module)
FortranCInterface_VERIFY()
FortranCInterface_VERIFY(CXX)
if(CMAKE_Fortran_COMPILER_SUPPORTS_F90)
- if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro|PathScale|Absoft")
+ if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|PathScale|Absoft")
set(module_expected 1)
endif()
if(FortranCInterface_MODULE_FOUND OR module_expected)
@@ -99,6 +99,11 @@ function(test_fortran_c_interface_module)
target_link_libraries(myc myfort)
set_property(TARGET myc PROPERTY COMPILE_DEFINITIONS ${MYC_DEFS})
+ add_library(myfort_obj OBJECT mysub.f)
+ add_library(myc_use_obj myc.c $<TARGET_OBJECTS:myfort_obj>)
+ add_executable(mainc_use_obj mainc.c)
+ target_link_libraries(mainc_use_obj myc_use_obj)
+
add_library(mycxx mycxx.cxx)
target_link_libraries(mycxx myc)
@@ -123,7 +128,7 @@ else()
message("Fortran = ${CMAKE_Fortran_COMPILER_ID}")
message("C = ${CMAKE_C_COMPILER_ID}")
# hack to make g77 work after CL has been enabled
- # as a languge, cmake needs language specific versions
+ # as a language, cmake needs language specific versions
# of these variables....
if(WIN32 AND CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(CMAKE_CREATE_CONSOLE_EXE )
diff --git a/Tests/FortranModules/CMakeLists.txt b/Tests/FortranModules/CMakeLists.txt
index 399660002..d056b4379 100644
--- a/Tests/FortranModules/CMakeLists.txt
+++ b/Tests/FortranModules/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.1)
+cmake_minimum_required (VERSION 3.9)
project(FortranModules Fortran)
if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
@@ -56,7 +56,8 @@ add_executable(test_non_pp_include test_non_pp_include_main.f90)
# Build the external project separately using a custom target.
# Make sure it uses the same build configuration as this test.
-if(CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
set(External_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}")
set(External_BUILD_TYPE)
else()
diff --git a/Tests/FortranModules/Library/a.f90 b/Tests/FortranModules/Library/a.f90
index 3031c0723..c180cc068 100644
--- a/Tests/FortranModules/Library/a.f90
+++ b/Tests/FortranModules/Library/a.f90
@@ -1,3 +1,6 @@
MODULE libraryModuleA
USE libraryModuleB
+CONTAINS
+ SUBROUTINE libA
+ END SUBROUTINE
END MODULE
diff --git a/Tests/FortranModules/Library/b.f90 b/Tests/FortranModules/Library/b.f90
index ae1edcb20..f550996a1 100644
--- a/Tests/FortranModules/Library/b.f90
+++ b/Tests/FortranModules/Library/b.f90
@@ -1,2 +1,5 @@
MODULE libraryModuleB
+CONTAINS
+ SUBROUTINE libB
+ END SUBROUTINE
END MODULE
diff --git a/Tests/FortranModules/Subdir/subdir.f90 b/Tests/FortranModules/Subdir/subdir.f90
index 68955f6b5..5288b065b 100644
--- a/Tests/FortranModules/Subdir/subdir.f90
+++ b/Tests/FortranModules/Subdir/subdir.f90
@@ -1,2 +1,5 @@
MODULE subdirModuleA
+CONTAINS
+ SUBROUTINE subdirLibA
+ END SUBROUTINE
END MODULE
diff --git a/Tests/FortranModules/Submodules/CMakeLists.txt b/Tests/FortranModules/Submodules/CMakeLists.txt
index bf0152f63..ab8e0f9e5 100644
--- a/Tests/FortranModules/Submodules/CMakeLists.txt
+++ b/Tests/FortranModules/Submodules/CMakeLists.txt
@@ -1 +1,23 @@
-add_executable(submod main.f90 provide.f90)
+# The program units in this file consist of a module/submodule
+# tree represented by the following graph:
+#
+# parent
+# |
+# / \
+# / \
+# child sibling
+# |
+# grandchild
+# |
+# GreatGrandChild
+#
+# where the parent node is a module and all other nodes are submodules.
+
+add_executable(submod
+ main.f90
+ parent.f90
+ child.f90
+ grandchild.f90
+ greatgrandchild.f90
+ sibling.f90
+ )
diff --git a/Tests/FortranModules/Submodules/child.f90 b/Tests/FortranModules/Submodules/child.f90
new file mode 100644
index 000000000..c314835ae
--- /dev/null
+++ b/Tests/FortranModules/Submodules/child.f90
@@ -0,0 +1,10 @@
+! Test the notation for a 1st-generation direct
+! descendant of a parent module
+SUBMODULE ( parent ) child
+ implicit none
+CONTAINS
+ module function child_function() result(child_stuff)
+ logical :: child_stuff
+ child_stuff=.true.
+ end function
+END SUBMODULE child
diff --git a/Tests/FortranModules/Submodules/grandchild.f90 b/Tests/FortranModules/Submodules/grandchild.f90
new file mode 100644
index 000000000..1aef63e31
--- /dev/null
+++ b/Tests/FortranModules/Submodules/grandchild.f90
@@ -0,0 +1,8 @@
+! Test the notation for an Nth-generation descendant
+! for N>1, which necessitates the colon.
+submodule ( parent : child ) grandchild
+contains
+ module subroutine grandchild_subroutine()
+ print *,"Test passed."
+ end subroutine
+end submodule grandchild
diff --git a/Tests/FortranModules/Submodules/greatgrandchild.f90 b/Tests/FortranModules/Submodules/greatgrandchild.f90
new file mode 100644
index 000000000..85404eaf5
--- /dev/null
+++ b/Tests/FortranModules/Submodules/greatgrandchild.f90
@@ -0,0 +1,8 @@
+! Test the notation for an Nth-generation descendant
+! for N>1, which necessitates the colon.
+submodule ( parent : grandchild ) GreatGrandChild
+contains
+ module subroutine GreatGrandChild_subroutine()
+ print *,"Test passed."
+ end subroutine
+end submodule GreatGrandChild
diff --git a/Tests/FortranModules/Submodules/main.f90 b/Tests/FortranModules/Submodules/main.f90
index 3c750ce38..3cd29892c 100644
--- a/Tests/FortranModules/Submodules/main.f90
+++ b/Tests/FortranModules/Submodules/main.f90
@@ -1,5 +1,7 @@
program main
use parent, only : child_function,grandchild_subroutine
+ use parent, only : sibling_function,GreatGrandChild_subroutine
implicit none
if (child_function()) call grandchild_subroutine
+ if (sibling_function()) call GreatGrandChild_subroutine
end program
diff --git a/Tests/FortranModules/Submodules/parent.f90 b/Tests/FortranModules/Submodules/parent.f90
new file mode 100644
index 000000000..3180b7043
--- /dev/null
+++ b/Tests/FortranModules/Submodules/parent.f90
@@ -0,0 +1,22 @@
+module parent
+ implicit none
+
+ interface
+
+ ! Test Fortran 2008 "module function" syntax
+ module function child_function() result(child_stuff)
+ logical :: child_stuff
+ end function
+ module function sibling_function() result(sibling_stuff)
+ logical :: sibling_stuff
+ end function
+
+ ! Test Fortran 2008 "module subroutine" syntax
+ module subroutine grandchild_subroutine()
+ end subroutine
+ module subroutine GreatGrandChild_subroutine()
+ end subroutine
+
+ end interface
+
+end module parent
diff --git a/Tests/FortranModules/Submodules/provide.f90 b/Tests/FortranModules/Submodules/provide.f90
deleted file mode 100644
index 0ad216ac5..000000000
--- a/Tests/FortranModules/Submodules/provide.f90
+++ /dev/null
@@ -1,57 +0,0 @@
-! The program units in this file consist of a
-! module/submodule tree represented by the following
-! graph:
-!
-! parent
-! |
-! / \
-! / \
-! child sibling
-! |
-! grandchild
-!
-! where the parent node is a module and all other
-! nodes are submodules.
-
-module parent
- implicit none
-
- interface
-
- ! Test Fortran 2008 "module function" syntax
- module function child_function() result(child_stuff)
- logical :: child_stuff
- end function
-
- ! Test Fortran 2008 "module subroutine" syntax
- module subroutine grandchild_subroutine()
- end subroutine
-
- end interface
-
-end module parent
-
-! Test the notation for a 1st-generation direct
-! descendant of a parent module
-submodule ( parent ) child
- implicit none
-contains
- module function child_function() result(child_stuff)
- logical :: child_stuff
- child_stuff=.true.
- end function
-end submodule child
-
-! Empty submodule for checking disambiguation of
-! nodes at the same vertical level in the tree
-submodule ( parent ) sibling
-end submodule sibling
-
-! Test the notation for an Nth-generation descendant
-! for N>1, which necessitates the colon.
-submodule ( parent : child ) grandchild
-contains
- module subroutine grandchild_subroutine()
- print *,"Test passed."
- end subroutine
-end submodule grandchild
diff --git a/Tests/FortranModules/Submodules/sibling.f90 b/Tests/FortranModules/Submodules/sibling.f90
new file mode 100644
index 000000000..8c0943dec
--- /dev/null
+++ b/Tests/FortranModules/Submodules/sibling.f90
@@ -0,0 +1,9 @@
+! Empty submodule for checking disambiguation of
+! nodes at the same vertical level in the tree
+submodule ( parent ) sibling
+contains
+ module function sibling_function() result(sibling_stuff)
+ logical :: sibling_stuff
+ sibling_stuff=.true.
+ end function
+end submodule sibling
diff --git a/Tests/FortranModules/test_preprocess.F90 b/Tests/FortranModules/test_preprocess.F90
index 3a09976c5..c5a5ec32d 100644
--- a/Tests/FortranModules/test_preprocess.F90
+++ b/Tests/FortranModules/test_preprocess.F90
@@ -1,5 +1,5 @@
MODULE Available
-! no conent
+! no content
END MODULE
PROGRAM PPTEST
diff --git a/Tests/FortranModules/test_preprocess_module.F90 b/Tests/FortranModules/test_preprocess_module.F90
index 5849b62b4..fdbc051e0 100644
--- a/Tests/FortranModules/test_preprocess_module.F90
+++ b/Tests/FortranModules/test_preprocess_module.F90
@@ -1,5 +1,5 @@
#ifdef FOO
MODULE PPAvailable
-! no conent
+! no content
END MODULE
#endif
diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt
index 9bf03033a..de887faa4 100644
--- a/Tests/FortranOnly/CMakeLists.txt
+++ b/Tests/FortranOnly/CMakeLists.txt
@@ -12,6 +12,12 @@ add_executable(FortranOnly1 testf.f)
set_property(TARGET FortranOnly1 PROPERTY OUTPUT_NAME FortranOnly)
target_link_libraries(FortranOnly1 FortranOnlylib)
+# Test that Fortran+RC work together.
+# FIXME: Add .rc in more cases.
+if(CMAKE_GENERATOR MATCHES "Visual Studio")
+ set(test_rc testRC.rc)
+endif()
+
# create a custom command that runs FortranOnly1 and puts
# the output into the file testfhello.txt
add_custom_command(OUTPUT ${FortranOnly_BINARY_DIR}/testfhello.txt
@@ -20,7 +26,7 @@ add_custom_command(OUTPUT ${FortranOnly_BINARY_DIR}/testfhello.txt
# create a second executable FortranOnly2 that has
# testfhello.txt has an source file so that it will
# run the above custom command.
-add_executable(FortranOnly2 testfhello.txt testf.f)
+add_executable(FortranOnly2 testfhello.txt testf.f ${test_rc})
target_link_libraries(FortranOnly2 FortranOnlylib)
# create a custom target to check the content of testfhello.txt
# by running the cmake script checktestf2.cmake
@@ -28,7 +34,7 @@ add_custom_target(checktestf2 ALL
COMMAND ${CMAKE_COMMAND}
-P ${FortranOnly_SOURCE_DIR}/checktestf2.cmake)
-# create a custom target that runs FortranOnly1 exectuable and creates
+# create a custom target that runs FortranOnly1 executable and creates
# a file out.txt that should have hello world in it.
add_custom_target(sayhello ALL
COMMAND FortranOnly1 > out.txt
@@ -38,7 +44,7 @@ add_dependencies(checktestf2 FortranOnly2)
add_dependencies(sayhello FortranOnly1)
add_dependencies(FortranOnly2 FortranOnly1)
-# add a custom target that checkes that out.txt has the correct
+# add a custom target that checks that out.txt has the correct
# content
add_custom_target(checksayhello ALL
COMMAND ${CMAKE_COMMAND} -P ${FortranOnly_SOURCE_DIR}/checksayhello.cmake
@@ -70,8 +76,15 @@ if(NOT CMAKE_Fortran_COMPILER_ID STREQUAL XL)
include(CheckFortranCompilerFlag)
CHECK_Fortran_COMPILER_FLAG(-_this_is_not_a_flag_ Fortran_BOGUS_FLAG)
if (Fortran_BOGUS_FLAG)
- message (SEND_ERROR "CHECK_Fortran_COMPILER_FLAG() succeeded, but should have failed")
- endif ()
+ message(SEND_ERROR "CHECK_Fortran_COMPILER_FLAG() succeeded, but should have failed")
+ endif()
+
+ unset(Fortran_RUN_FLAG CACHE)
+ include(CheckFortranSourceRuns)
+ check_fortran_source_runs("program a; end program" Fortran_RUN_FLAG SRC_EXT F90)
+ if(NOT Fortran_RUN_FLAG)
+ message(SEND_ERROR "CHECK_Fortran_SOURCE_RUNS() failed")
+ endif()
endif()
# Test generation of preprocessed sources.
@@ -99,3 +112,11 @@ if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM)
)
endif()
endif()
+
+# Test that with Intel Fortran we always compile with preprocessor
+# defines even if splitting the preprocessing and compilation steps.
+if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
+ add_executable(IntelIfDef IntelIfDef.f)
+ set_property(TARGET IntelIfDef PROPERTY Fortran_FORMAT FIXED)
+ target_compile_definitions(IntelIfDef PRIVATE SOME_DEF)
+endif()
diff --git a/Tests/FortranOnly/IntelIfDef.f b/Tests/FortranOnly/IntelIfDef.f
new file mode 100644
index 000000000..d7a73d149
--- /dev/null
+++ b/Tests/FortranOnly/IntelIfDef.f
@@ -0,0 +1,3 @@
+ INCLUDE 'IntelIfDef.inc'
+ PROGRAM IntelIfDef
+ END
diff --git a/Tests/FortranOnly/IntelIfDef.inc b/Tests/FortranOnly/IntelIfDef.inc
new file mode 100644
index 000000000..52edafa78
--- /dev/null
+++ b/Tests/FortranOnly/IntelIfDef.inc
@@ -0,0 +1,3 @@
+CDEC$ IF .NOT. DEFINED(SOME_DEF)
+CDEC$ INCLUDE 'SOME_DEF not defined'
+CDEC$ END IF
diff --git a/Tests/FortranOnly/testRC.rc b/Tests/FortranOnly/testRC.rc
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/FortranOnly/testRC.rc
diff --git a/Tests/Framework/foo.cxx b/Tests/Framework/foo.cxx
index c3520c1dd..a4d15f609 100644
--- a/Tests/Framework/foo.cxx
+++ b/Tests/Framework/foo.cxx
@@ -1,8 +1,8 @@
#include <stdio.h>
#if defined(_WIN32) && defined(foo_EXPORTS)
-#define CM_TEST_LIB_EXPORT __declspec(dllexport)
+# define CM_TEST_LIB_EXPORT __declspec(dllexport)
#else
-#define CM_TEST_LIB_EXPORT
+# define CM_TEST_LIB_EXPORT
#endif
CM_TEST_LIB_EXPORT void foo()
{
diff --git a/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp b/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp
index 233eb57e4..2812b0d6f 100644
--- a/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp
+++ b/Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp
@@ -1,24 +1,24 @@
#ifdef Type_Is_
-#if !Result
-#error Result should be 1 in WARN mode
-#endif
+# if !Result
+# error Result should be 1 in WARN mode
+# endif
#endif
#ifdef Type_Is_NEW
-#if Result
-#error Result should be 0 in NEW mode
-#endif
+# if Result
+# error Result should be 0 in NEW mode
+# endif
#endif
#ifdef Type_Is_OLD
-#if !Result
-#error Result should be 1 in OLD mode
-#endif
+# if !Result
+# error Result should be 1 in OLD mode
+# endif
#endif
#if !defined(Type_Is_) && !defined(Type_Is_OLD) && !defined(Type_Is_NEW)
-#error No expected definition present
+# error No expected definition present
#endif
void foo(void)
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index 8ac341912..9d5134203 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -3,11 +3,26 @@ project(GeneratorExpression)
include(CTest)
+# Real projects normally want the MSYS shell path conversion, but for this test
+# we need to verify that the command line is constructed with the proper string.
+set(msys1_prefix "")
+set(msys2_no_conv "")
+if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles")
+ execute_process(COMMAND "uname" OUTPUT_VARIABLE uname)
+ if("${uname}" MATCHES "^MINGW32")
+ # MinGW.org MSYS 1.0 does not support generic path conversion suppression
+ set(msys1_prefix MSYS1_PREFIX)
+ else()
+ # msys2 supports generic path conversion suppression
+ set(msys2_no_conv env MSYS2_ARG_CONV_EXCL=-D)
+ endif()
+endif()
+
# This test is split into multiple parts as needed to avoid NMake command
# length limits.
add_custom_target(check-part1 ALL
- COMMAND ${CMAKE_COMMAND}
+ COMMAND ${msys2_no_conv} ${CMAKE_COMMAND}
-Dtest_0=$<0:nothing>
-Dtest_0_with_comma=$<0:-Wl,--no-undefined>
-Dtest_1=$<1:content>
@@ -57,6 +72,11 @@ add_custom_target(check-part1 ALL
-Dtest_strequal_angle_r_comma=$<STREQUAL:$<ANGLE-R>,$<COMMA>>
-Dtest_strequal_both_empty=$<STREQUAL:,>
-Dtest_strequal_one_empty=$<STREQUAL:something,>
+ -Dtest_inlist_true=$<IN_LIST:a,a$<SEMICOLON>b>
+ -Dtest_inlist_false=$<IN_LIST:c,a$<SEMICOLON>b>
+ -Dtest_inlist_empty_1=$<IN_LIST:a,>
+ -Dtest_inlist_empty_2=$<IN_LIST:,a>
+ -Dtest_inlist_empty_3=$<IN_LIST:,>
-Dtest_angle_r=$<ANGLE-R>
-Dtest_comma=$<COMMA>
-Dtest_semicolon=$<SEMICOLON>
@@ -66,7 +86,7 @@ add_custom_target(check-part1 ALL
-Dtest_colons_4=$<1:C:\\CMake>
-Dtest_colons_5=$<1:C:/CMake>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part1.cmake
- COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 4)"
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 5)"
VERBATIM
)
@@ -92,7 +112,7 @@ add_library(empty5 empty.cpp)
target_include_directories(empty5 PRIVATE /empty5/private1 /empty5/private2)
add_custom_target(check-part2 ALL
- COMMAND ${CMAKE_COMMAND}
+ COMMAND ${msys2_no_conv} ${CMAKE_COMMAND}
-Dtest_incomplete_1=$<
-Dtest_incomplete_2=$<something
-Dtest_incomplete_3=$<something:
@@ -137,7 +157,7 @@ add_custom_target(check-part2 ALL
-Dtest_arbitrary_content_comma_9=$<1:a,,b,,>
-Dtest_arbitrary_content_comma_10=$<1:,,a,,b,,>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part2.cmake
- COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 4)"
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 5)"
VERBATIM
)
@@ -183,7 +203,7 @@ set_property(TARGET importedFallback PROPERTY MAP_IMPORTED_CONFIG_DEBUG "" DEBUG
set_property(TARGET importedFallback PROPERTY MAP_IMPORTED_CONFIG_RELEASE "")
add_custom_target(check-part3 ALL
- COMMAND ${CMAKE_COMMAND}
+ COMMAND ${msys2_no_conv} ${CMAKE_COMMAND}
-Dtest_version_greater_1=$<VERSION_GREATER:1.0,1.1.1>
-Dtest_version_greater_2=$<VERSION_GREATER:1.1.1,1.0>
-Dtest_version_less_1=$<VERSION_LESS:1.1.1,1.0>
@@ -200,6 +220,7 @@ add_custom_target(check-part3 ALL
-Dtest_early_termination_2=$<$<1:>:,
-Dsystem_name=${CMAKE_HOST_SYSTEM_NAME}
-Dtest_platform_id=$<PLATFORM_ID>
+ -Dtest_platform_id_supported=$<PLATFORM_ID:Linux,Windows,Darwin>
-Dtest_platform_id_Linux=$<PLATFORM_ID:Linux>
-Dtest_platform_id_Windows=$<PLATFORM_ID:Windows>
-Dtest_platform_id_Darwin=$<PLATFORM_ID:Darwin>
@@ -230,23 +251,25 @@ add_custom_target(check-part3 ALL
-Dequal22=$<EQUAL:10,-012>
-Dequal23=$<EQUAL:-10,-012>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake
- COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 4)"
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 5)"
VERBATIM
)
if(WIN32)
set(test_shell_path c:/shell/path)
+ set(test_shell_path2 c:/shell/path d:/another/path)
else()
set(test_shell_path /shell/path)
+ set(test_shell_path2 /shell/path /another/path)
endif()
-set(path_prefix BYPASS_FURTHER_CONVERSION)
add_custom_target(check-part4 ALL
- COMMAND ${CMAKE_COMMAND}
+ COMMAND ${msys2_no_conv} ${CMAKE_COMMAND}
# Prefix path to bypass its further conversion when being processed by
# CMake as command-line argument
- -Dtest_shell_path=${path_prefix}$<SHELL_PATH:${test_shell_path}>
- -Dpath_prefix=${path_prefix}
+ -Dmsys1_prefix=${msys1_prefix}
+ -Dtest_shell_path=${msys1_prefix}$<SHELL_PATH:${test_shell_path}>
+ "-Dtest_shell_path2=$<SHELL_PATH:${test_shell_path2}>"
-Dif_1=$<IF:1,a,b>
-Dif_2=$<IF:0,a,b>
-Dif_3=$<IF:$<EQUAL:10,30>,a,b>
@@ -254,15 +277,80 @@ add_custom_target(check-part4 ALL
-DWIN32=${WIN32}
-DCMAKE_GENERATOR=${CMAKE_GENERATOR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part4.cmake
- COMMAND ${CMAKE_COMMAND} -E echo "check done (part 4 of 4)"
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 4 of 5)"
+ VERBATIM
+ )
+
+add_custom_target(check-part5 ALL
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 5 of 5)"
+ DEPENDS check-part5.stamp
+ VERBATIM
+ )
+
+add_custom_command(
+ OUTPUT check-part5.stamp
+ DEPENDS $<FILTER:file.foo.bar,EXCLUDE,\\.foo\\.bar$>
+ COMMAND ${CMAKE_COMMAND} -E sleep 0
+ VERBATIM
+ )
+set_property(SOURCE check-part5.stamp PROPERTY SYMBOLIC 1)
+
+add_custom_command(
+ OUTPUT file.foo.bar
+ COMMAND ${CMAKE_COMMAND} -P check-part5.cmake
VERBATIM
)
#-----------------------------------------------------------------------------
+# Cover source file properties with generator expressions.
+## generate various source files
+foreach (item IN ITEMS flags flags_COMPILE_LANGUAGE
+ options options_COMPILE_LANGUAGE
+ defs defs_COMPILE_LANGUAGE)
+ set(TARGET_NAME srcgenex_${item})
+ configure_file(srcgenex.c.in ${TARGET_NAME}.c @ONLY)
+endforeach()
+add_executable(srcgenex_flags "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags.c")
+set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags.c"
+ PROPERTY COMPILE_FLAGS "-DNAME=$<TARGET_PROPERTY:NAME>")
+add_executable(srcgenex_flags_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags_COMPILE_LANGUAGE.c")
+set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_flags_COMPILE_LANGUAGE.c"
+ PROPERTY COMPILE_FLAGS "$<$<COMPILE_LANGUAGE:C>:-DNAME=$<TARGET_PROPERTY:NAME>>")
+
+add_executable(srcgenex_options "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options.c")
+set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options.c"
+ PROPERTY COMPILE_OPTIONS -DUNUSED -DNAME=$<TARGET_PROPERTY:NAME>)
+add_executable(srcgenex_options_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options_COMPILE_LANGUAGE.c")
+set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_options_COMPILE_LANGUAGE.c"
+ PROPERTY COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:C>:-DNAME=$<TARGET_PROPERTY:NAME>>)
+
+add_executable(srcgenex_defs "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs.c")
+set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs.c"
+ PROPERTY COMPILE_DEFINITIONS UNUSED NAME=$<TARGET_PROPERTY:NAME>)
+add_executable(srcgenex_defs_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs_COMPILE_LANGUAGE.c")
+set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_defs_COMPILE_LANGUAGE.c"
+ PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:C>:NAME=$<TARGET_PROPERTY:NAME>>)
+
+foreach (item IN ITEMS basic COMPILE_LANGUAGE)
+ set(TARGET_NAME srcgenex_includes_${item})
+ configure_file(srcgenex_includes.h.in "sf_includes_${item}/${TARGET_NAME}.h" @ONLY)
+ configure_file(srcgenex_includes.c.in ${TARGET_NAME}.c @ONLY)
+endforeach()
+add_executable(srcgenex_includes_basic "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_basic.c")
+# first include directory is useless but ensure list aspect is tested
+set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_basic.c"
+ PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/sf_includes_basic")
+if (CMAKE_GENERATOR MATCHES "Makefiles|Ninja|Watcom WMake")
+ add_executable(srcgenex_includes_COMPILE_LANGUAGE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_COMPILE_LANGUAGE.c")
+ # first include directory is useless but ensure list aspect is tested
+ set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/srcgenex_includes_COMPILE_LANGUAGE.c"
+ PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" $<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_BINARY_DIR}/sf_includes_COMPILE_LANGUAGE>)
+endif()
+
+#-----------------------------------------------------------------------------
# Cover test properties with generator expressions.
add_executable(echo echo.c)
add_executable(pwd pwd.c)
-set_property(SOURCE echo.c PROPERTY COMPILE_FLAGS $<1:-DSRC_GENEX_WORKS>)
add_test(NAME echo-configuration COMMAND echo $<CONFIGURATION>)
set_property(TEST echo-configuration PROPERTY
@@ -307,4 +395,49 @@ if(NOT CMAKE_GENERATOR STREQUAL Xcode OR NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;
-P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
DEPENDS objlib
)
+
+
+ add_library(sharedlib SHARED objlib1.c objlib2.c)
+ file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/sharedlib_files_$<CONFIGURATION>"
+ CONTENT "$<JOIN:$<TARGET_OBJECTS:sharedlib>,\n>\n"
+ )
+
+ add_custom_target(check_sharedlib_objs ALL
+ COMMAND ${CMAKE_COMMAND}
+ "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/sharedlib_files_$<CONFIGURATION>"
+ -DEXPECTED_NUM_OBJECTFILES=2
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
+ DEPENDS sharedlib
+ )
+
+
+ add_library(staticlib STATIC objlib1.c objlib2.c)
+ file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/staticlib_files_$<CONFIGURATION>"
+ CONTENT "$<JOIN:$<TARGET_OBJECTS:staticlib>,\n>\n"
+ )
+
+ add_custom_target(check_staticlib_objs ALL
+ COMMAND ${CMAKE_COMMAND}
+ "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/staticlib_files_$<CONFIGURATION>"
+ -DEXPECTED_NUM_OBJECTFILES=2
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
+ DEPENDS staticlib
+ )
+
+
+ add_executable(execobjs objlib1.c objlib2.c echo.c)
+ file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/execobjs_files_$<CONFIGURATION>"
+ CONTENT "$<JOIN:$<TARGET_OBJECTS:execobjs>,\n>\n"
+ )
+
+ add_custom_target(check_exec_objs ALL
+ COMMAND ${CMAKE_COMMAND}
+ "-DOBJLIB_LISTFILE=${CMAKE_CURRENT_BINARY_DIR}/execobjs_files_$<CONFIGURATION>"
+ -DEXPECTED_NUM_OBJECTFILES=3
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
+ DEPENDS execobjs
+ )
endif()
diff --git a/Tests/GeneratorExpression/check-part1.cmake b/Tests/GeneratorExpression/check-part1.cmake
index 60b193f58..41bcd6d99 100644
--- a/Tests/GeneratorExpression/check-part1.cmake
+++ b/Tests/GeneratorExpression/check-part1.cmake
@@ -49,6 +49,11 @@ check(test_strequal_semicolon "1")
check(test_strequal_angle_r_comma "0")
check(test_strequal_both_empty "1")
check(test_strequal_one_empty "0")
+check(test_inlist_true "1")
+check(test_inlist_false "0")
+check(test_inlist_empty_1 "0")
+check(test_inlist_empty_2 "0")
+check(test_inlist_empty_3 "0")
check(test_angle_r ">")
check(test_comma ",")
check(test_semicolon ";")
diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake
index 9014406c2..4fb730887 100644
--- a/Tests/GeneratorExpression/check-part3.cmake
+++ b/Tests/GeneratorExpression/check-part3.cmake
@@ -28,11 +28,16 @@ check(test_early_termination_2 "$<:,")
check(test_platform_id "${system_name}")
foreach(system Linux Windows Darwin)
if(system_name STREQUAL system)
+ check(test_platform_id_supported 1)
check(test_platform_id_${system} 1)
+ set(platform_supported 1)
else()
check(test_platform_id_${system} 0)
endif()
endforeach()
+if(NOT platform_supported)
+ check(test_platform_id_supported 0)
+endif()
check(lower_case "mi,xed")
check(upper_case "MIX,ED")
check(make_c_identifier "_4f_oo__bar__")
diff --git a/Tests/GeneratorExpression/check-part4.cmake b/Tests/GeneratorExpression/check-part4.cmake
index f5d14dd45..a7e09445e 100644
--- a/Tests/GeneratorExpression/check-part4.cmake
+++ b/Tests/GeneratorExpression/check-part4.cmake
@@ -1,6 +1,8 @@
include(${CMAKE_CURRENT_LIST_DIR}/check-common.cmake)
-string(REPLACE ${path_prefix} "" test_shell_path ${test_shell_path})
+if(msys1_prefix)
+ string(REPLACE "${msys1_prefix}" "" test_shell_path ${test_shell_path})
+endif()
if(WIN32)
if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles")
@@ -13,6 +15,17 @@ if(WIN32)
else()
check(test_shell_path [[/shell/path]])
endif()
+if(WIN32)
+ if(CMAKE_GENERATOR STREQUAL "MSYS Makefiles" AND NOT msys1_prefix)
+ check(test_shell_path2 [[/c/shell/path:/d/another/path]])
+ elseif(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
+ check(test_shell_path2 [[c:/shell/path;d:/another/path]])
+ else()
+ check(test_shell_path2 [[c:\shell\path;d:\another\path]])
+ endif()
+else()
+ check(test_shell_path2 [[/shell/path:/another/path]])
+endif()
check(if_1 "a")
check(if_2 "b")
diff --git a/Tests/GeneratorExpression/check-part5.cmake b/Tests/GeneratorExpression/check-part5.cmake
new file mode 100644
index 000000000..77d138713
--- /dev/null
+++ b/Tests/GeneratorExpression/check-part5.cmake
@@ -0,0 +1 @@
+message(SEND_ERROR "$<FILTER:file.foo.bar,EXCLUDE,\\.foo\\.bar$> genex in DEPENDS argument of 'add_custom_command()' is not empty")
diff --git a/Tests/GeneratorExpression/echo.c b/Tests/GeneratorExpression/echo.c
index 41596a21d..06b0844b3 100644
--- a/Tests/GeneratorExpression/echo.c
+++ b/Tests/GeneratorExpression/echo.c
@@ -3,9 +3,6 @@
int main(int argc, char* argv[])
{
-#ifndef SRC_GENEX_WORKS
-#error SRC_GENEX_WORKS not defined
-#endif
printf("%s\n", argv[1]);
return EXIT_SUCCESS;
}
diff --git a/Tests/GeneratorExpression/pwd.c b/Tests/GeneratorExpression/pwd.c
index ed2304370..31ebe493a 100644
--- a/Tests/GeneratorExpression/pwd.c
+++ b/Tests/GeneratorExpression/pwd.c
@@ -3,11 +3,11 @@
#include <stdlib.h>
#ifdef _WIN32
-#include <direct.h>
-#define getcurdir _getcwd
+# include <direct.h>
+# define getcurdir _getcwd
#else
-#include <unistd.h>
-#define getcurdir getcwd
+# include <unistd.h>
+# define getcurdir getcwd
#endif
int main(int argc, char* argv[])
diff --git a/Tests/GeneratorExpression/srcgenex.c.in b/Tests/GeneratorExpression/srcgenex.c.in
new file mode 100644
index 000000000..4a43bd19b
--- /dev/null
+++ b/Tests/GeneratorExpression/srcgenex.c.in
@@ -0,0 +1,12 @@
+int @TARGET_NAME@(void)
+{
+ return 0;
+}
+
+int main(int argc, char* argv[])
+{
+#ifndef NAME
+#error NAME not defined
+#endif
+ return NAME();
+}
diff --git a/Tests/GeneratorExpression/srcgenex_includes.c.in b/Tests/GeneratorExpression/srcgenex_includes.c.in
new file mode 100644
index 000000000..b48d7dfc3
--- /dev/null
+++ b/Tests/GeneratorExpression/srcgenex_includes.c.in
@@ -0,0 +1,12 @@
+
+#include "@TARGET_NAME@.h"
+
+int @TARGET_NAME@(void)
+{
+ return 0;
+}
+
+int main(int argc, char* argv[])
+{
+ return @TARGET_NAME@();
+}
diff --git a/Tests/GeneratorExpression/srcgenex_includes.h.in b/Tests/GeneratorExpression/srcgenex_includes.h.in
new file mode 100644
index 000000000..2259ca67f
--- /dev/null
+++ b/Tests/GeneratorExpression/srcgenex_includes.h.in
@@ -0,0 +1,7 @@
+
+#if !defined @TARGET_NAME@_H
+#define @TARGET_NAME@_H
+
+int @TARGET_NAME@(void);
+
+#endif
diff --git a/Tests/GhsMulti/CMakeLists.txt b/Tests/GhsMulti/CMakeLists.txt
deleted file mode 100644
index 6e15ba9a7..000000000
--- a/Tests/GhsMulti/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-cmake_minimum_required(VERSION 3.1)
-project(ReturnNum)
-
-add_subdirectory(ReturnNum)
diff --git a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt
new file mode 100644
index 000000000..4a3f5c238
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt
@@ -0,0 +1,92 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+message("Copy project")
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in
+ ${CMAKE_CURRENT_BINARY_DIR}/src/CMakeLists.txt COPYONLY)
+
+file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test.c
+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/src
+)
+
+message("Building project")
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+try_compile(RESULT
+ ${CMAKE_CURRENT_BINARY_DIR}/build
+ ${CMAKE_CURRENT_BINARY_DIR}/src
+ test
+ CMAKE_FLAGS
+ -DRUN_TEST=${RUN_TEST}
+ -DCMAKE_BUILD_TYPE=${RUN_TEST_BUILD_TYPE}
+ OUTPUT_VARIABLE OUTPUT)
+
+message("Output from build:\n${OUTPUT}")
+if (RUN_TEST STREQUAL "RELEASE_FLAGS")
+ find_file (fileName test_none.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}/build
+ ${CMAKE_CURRENT_BINARY_DIR}/build/test_none
+ )
+ message("Parsing project file: ${fileName}")
+ file(STRINGS ${fileName} fileText)
+ set(opt "-unexpected_release_option")
+ string(FIND "${fileText}" "${opt}" opt_found)
+ if ( NOT opt_found EQUAL -1 )
+ message(SEND_ERROR "Release option found: ${opt}")
+ endif()
+else()
+ unset(fileName CACHE)
+ find_file (fileName K1.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}/build
+ ${CMAKE_CURRENT_BINARY_DIR}/build/K1
+ )
+ message("Parsing project file: ${fileName}")
+ file(STRINGS ${fileName} fileText)
+ set(opt "-required-debug-option")
+ string(FIND "${fileText}" "${opt}" opt_found)
+ if ( opt_found EQUAL -1 )
+ message(SEND_ERROR "Missing debug option: ${opt}")
+ endif()
+
+ unset(fileName CACHE)
+ find_file (fileName K2.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}/build
+ ${CMAKE_CURRENT_BINARY_DIR}/build/K2
+ )
+ message("Parsing project file: ${fileName}")
+ file(STRINGS ${fileName} fileText)
+ set(opt "-required-debug-option")
+ string(FIND "${fileText}" "${opt}" opt_found)
+ if ( opt_found EQUAL -1 )
+ message(SEND_ERROR "Missing debug option: ${opt}")
+ endif()
+
+ unset(fileName CACHE)
+ find_file (fileName K3.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}/build
+ ${CMAKE_CURRENT_BINARY_DIR}/build/K3
+ )
+ message("Parsing project file: ${fileName}")
+ file(STRINGS ${fileName} fileText)
+ set(opt "-required-debug-option")
+ string(FIND "${fileText}" "${opt}" opt_found)
+ if ( opt_found EQUAL -1 )
+ message(SEND_ERROR "Missing debug option: ${opt}")
+ endif()
+
+ unset(fileName CACHE)
+ find_file (fileName K4.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}/build
+ ${CMAKE_CURRENT_BINARY_DIR}/build/K4
+ )
+ message("Parsing project file: ${fileName}")
+ file(STRINGS ${fileName} fileText)
+ set(opt "-required-debug-option")
+ string(FIND "${fileText}" "${opt}" opt_found)
+ if ( opt_found EQUAL -1 )
+ message(SEND_ERROR "Missing debug option: ${opt}")
+ endif()
+endif()
diff --git a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in
new file mode 100644
index 000000000..fc24d907b
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt.in
@@ -0,0 +1,32 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+if(CMAKE_C_COMPILER_ID STREQUAL "GHS")
+ add_link_options("-non_shared")
+endif()
+
+if(RUN_TEST STREQUAL "RELEASE_FLAGS")
+ #RELEASE flags used when CMAKE_BUILD_TYPE is undefined
+ string(APPEND CMAKE_C_FLAGS_RELEASE " -unexpected_release_option")
+ add_executable(test_none test.c)
+endif()
+
+if(RUN_TEST STREQUAL "KERNEL_FLAGS")
+ #DEBUG flag missing when -kernel is added as a compile option
+ string(APPEND CMAKE_C_FLAGS_DEBUG " -required-debug-option")
+
+ add_executable(K1 test.c)
+
+ add_executable(K2 test.c)
+ target_compile_options(K2 PRIVATE -kernel)
+
+ add_executable(K3 test.c)
+ target_compile_options(K3 PRIVATE -kernel=fast)
+
+ add_executable(K4 test.c)
+ target_link_options(K4 PRIVATE -kernel)
+endif()
diff --git a/Tests/GhsMulti/GhsMultiCompilerOptions/test.c b/Tests/GhsMulti/GhsMultiCompilerOptions/test.c
new file mode 100644
index 000000000..95f2e8ec1
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiCompilerOptions/test.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return -1;
+}
diff --git a/Tests/GhsMulti/GhsMultiCopyFile/CMakeLists.txt b/Tests/GhsMulti/GhsMultiCopyFile/CMakeLists.txt
new file mode 100644
index 000000000..d6d007d9c
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiCopyFile/CMakeLists.txt
@@ -0,0 +1,30 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+try_compile(RESULT
+ ${CMAKE_CURRENT_BINARY_DIR}/build
+ ${CMAKE_CURRENT_SOURCE_DIR}/test.c
+ OUTPUT_VARIABLE OUTPUT
+ COPY_FILE "${CMAKE_CURRENT_BINARY_DIR}/test_library"
+)
+
+message(STATUS "Output from build:\n${OUTPUT}")
+
+if(NOT RESULT)
+ message(SEND_ERROR "try_compile() failed")
+endif()
+
+if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/test_library")
+ if (IS_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_library")
+ message(SEND_ERROR "library is folder !")
+ else()
+ message(STATUS "library seems okay")
+ endif()
+else()
+ message(SEND_ERROR "library is not found !")
+endif()
diff --git a/Tests/GhsMulti/GhsMultiCopyFile/test.c b/Tests/GhsMulti/GhsMultiCopyFile/test.c
new file mode 100644
index 000000000..5c657b561
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiCopyFile/test.c
@@ -0,0 +1,4 @@
+int lib(int x)
+{
+ return -x;
+}
diff --git a/Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt b/Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt
new file mode 100644
index 000000000..93d668bb6
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt
@@ -0,0 +1,110 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+# Tests assume no previous builds in the build directory
+file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/build)
+
+macro (test_output)
+ if (BUILD_OUTPUT STREQUAL EXPECTED_LINES )
+ message("Build OK")
+ else()
+ message("BUILD_OUTPUT")
+ foreach(Line IN LISTS BUILD_OUTPUT)
+ message("${Line}")
+ endforeach()
+ message("EXPECTED_LINES")
+ foreach(Line IN LISTS EXPECTED_LINES)
+ message("${Line}")
+ endforeach()
+ message(SEND_ERROR "Build KO")
+ endif()
+endmacro()
+
+message("Copy project")
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in
+ ${CMAKE_CURRENT_BINARY_DIR}/src/CMakeLists.txt COPYONLY)
+
+file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/exe1.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/lib1.c
+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/src
+)
+
+message("Building ALL target")
+try_compile(RESULT
+ ${CMAKE_CURRENT_BINARY_DIR}/build
+ ${CMAKE_CURRENT_BINARY_DIR}/src
+ test
+ CMAKE_FLAGS
+ -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
+ OUTPUT_VARIABLE BUILD_OUTPUT)
+
+message("Output from build:\n${BUILD_OUTPUT}")
+
+#filter outputs
+string(REPLACE "\r" "" BUILD_OUTPUT "${BUILD_OUTPUT}")
+string(REPLACE "\n" ";" BUILD_OUTPUT "${BUILD_OUTPUT}")
+list(FILTER BUILD_OUTPUT INCLUDE REGEX "^.*CT:")
+
+unset(EXPECTED_LINES)
+list(APPEND EXPECTED_LINES "CT: Processing target_empty_prebuild")
+list(APPEND EXPECTED_LINES "CT: Processing target_empty_postbuild")
+list(APPEND EXPECTED_LINES "CT: Processing target_cmd")
+list(APPEND EXPECTED_LINES "CT: Processing target_cmd_prebuild")
+list(APPEND EXPECTED_LINES "CT: Processing target_cmd_postbuild")
+
+test_output()
+
+message("Building target_update_files target")
+try_compile(RESULT
+ ${CMAKE_CURRENT_BINARY_DIR}/build
+ ${CMAKE_CURRENT_BINARY_DIR}/src
+ test target_update_files
+ CMAKE_FLAGS
+ -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
+ OUTPUT_VARIABLE BUILD_OUTPUT)
+
+message("Output from build:\n${BUILD_OUTPUT}")
+
+#filter outputs
+string(REPLACE "\r" "" BUILD_OUTPUT "${BUILD_OUTPUT}")
+string(REPLACE "\n" ";" BUILD_OUTPUT "${BUILD_OUTPUT}")
+list(FILTER BUILD_OUTPUT INCLUDE REGEX "^.*CT:")
+
+unset(EXPECTED_LINES)
+list(APPEND EXPECTED_LINES "CT: Processing target_empty_prebuild")
+list(APPEND EXPECTED_LINES "CT: Processing target_empty_postbuild")
+list(APPEND EXPECTED_LINES "CT: generate C file another_file")
+list(APPEND EXPECTED_LINES "CT: generate text file dependsA")
+list(APPEND EXPECTED_LINES "CT: generate text file out_of_order_dep")
+list(APPEND EXPECTED_LINES "CT: generate text files A, B, and C")
+list(APPEND EXPECTED_LINES "CT: Processing target_update_files")
+
+test_output()
+
+message("Rerun target_update_files target")
+try_compile(RESULT
+ ${CMAKE_CURRENT_BINARY_DIR}/build
+ ${CMAKE_CURRENT_BINARY_DIR}/src
+ test target_update_files
+ CMAKE_FLAGS
+ -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
+ OUTPUT_VARIABLE BUILD_OUTPUT)
+
+message("Output from build:\n${BUILD_OUTPUT}")
+
+#filter outputs
+string(REPLACE "\r" "" BUILD_OUTPUT "${BUILD_OUTPUT}")
+string(REPLACE "\n" ";" BUILD_OUTPUT "${BUILD_OUTPUT}")
+list(FILTER BUILD_OUTPUT INCLUDE REGEX "^.*CT:")
+
+unset(EXPECTED_LINES)
+list(APPEND EXPECTED_LINES "CT: Processing target_empty_prebuild")
+list(APPEND EXPECTED_LINES "CT: Processing target_empty_postbuild")
+list(APPEND EXPECTED_LINES "CT: generate text files A, B, and C")
+list(APPEND EXPECTED_LINES "CT: Processing target_update_files")
+
+test_output()
diff --git a/Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt.in b/Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt.in
new file mode 100644
index 000000000..fed946cc5
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiCustomTarget/CMakeLists.txt.in
@@ -0,0 +1,108 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+if(CMAKE_C_COMPILER_ID STREQUAL "GHS")
+ add_link_options("-non_shared")
+endif()
+
+add_library(lib1 lib1.c)
+
+set(TEST_MISSING_TARGET_SRC 0)
+set(TEST_MISSING_TARGET_DEP 0)
+set(TEST_MISSING_DEP 0)
+set(TEST_DEP_CYCLE 0)
+
+add_executable(exe1 exe1.c)
+target_link_libraries(exe1 lib1)
+
+add_custom_target(target_cmd ALL
+ COMMAND ${CMAKE_COMMAND} -E echo "target_cmd" > target_cmd
+ COMMAND ${CMAKE_COMMAND} -E echo "target_cmd_extra" > target_cmd_extra.txt
+ BYPRODUCTS target_cmd target_cmd_extra.txt
+ COMMENT "CT: Processing target_cmd")
+
+add_custom_command(TARGET target_cmd PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} -E echo "target_cmd_prebuild" > target_cmd_prebuild.txt
+ BYPRODUCTS target_cmd_prebuild.txt
+ COMMENT "CT: Processing target_cmd_prebuild")
+#event does not run for custom targets
+add_custom_command(TARGET target_cmd PRE_LINK
+ COMMAND ${CMAKE_COMMAND} -E echo "executing target_cmd_prelink commands"
+ COMMAND ${CMAKE_COMMAND} -E echo "target_cmd_prelink" > target_cmd_prelink.txt
+ BYPRODUCTS target_cmd_prelink.txt
+ COMMENT "CT: Processing target_cmd_prelink")
+add_custom_command(TARGET target_cmd POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E echo "executing target_cmd_postbuild commands"
+ COMMAND ${CMAKE_COMMAND} -E echo "target_cmd_postbuild" > target_cmd_postbuild.txt
+ BYPRODUCTS target_cmd_postbuild.txt
+ COMMENT "CT: Processing target_cmd_postbuild")
+
+add_custom_target(target_empty ALL
+ COMMENT "CT: Processing target_empty")
+
+add_custom_command(TARGET target_empty PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} -E echo "target_empty_prebuild" > target_empty_prebuild.txt
+ BYPRODUCTS target_empty_prebuild.txt
+ COMMENT "CT: Processing target_empty_prebuild")
+add_custom_command(TARGET target_empty POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E echo "target_empty_postbuild" > target_empty_postbuild.txt
+ BYPRODUCTS target_empty_postbuild.txt
+ COMMENT "CT: Processing target_empty_postbuild")
+
+add_dependencies(target_cmd target_empty)
+
+add_custom_command(
+ OUTPUT out_of_order_dep.txt
+ COMMAND ${CMAKE_COMMAND} -E echo "out_of_order_dep" > out_of_order_dep.txt
+ COMMENT "CT: generate text file out_of_order_dep"
+ DEPENDS dependsA.txt
+)
+
+if(TEST_MISSING_TARGET_SRC)
+ set(SRC_FILE does_not_exist)
+endif()
+if(TEST_MISSING_TARGET_DEP)
+ set(DEP_FILE does_not_exist)
+endif()
+
+add_custom_target(target_update_files
+ DEPENDS genc_do_not_list.txt ${DEP_FILE}
+ SOURCES gena.txt genb.txt another_file.c ${SRC_FILE}
+ BYPRODUCTS junkit.txt
+ COMMAND ${CMAKE_COMMAND} -E copy another_file.c junkit.txt
+ COMMENT "CT: Processing target_update_files")
+
+add_custom_command(
+ OUTPUT force_rebuild gena.txt genb.txt genc_do_not_list.txt
+ COMMAND ${CMAKE_COMMAND} -E copy dependsA.txt gena.txt
+ COMMAND ${CMAKE_COMMAND} -E echo "genb" > genb.txt
+ COMMAND ${CMAKE_COMMAND} -E echo "genc" > genc_do_not_list.txt
+ DEPENDS out_of_order_dep.txt dependsA.txt
+ COMMENT "CT: generate text files A, B, and C"
+)
+
+if(TEST_MISSING_DEP)
+ set(MISSING_DEP MISSING_DEP)
+endif()
+if(TEST_DEP_CYCLE)
+ set(DEP_CYCLE out_of_order_dep.txt)
+endif()
+
+add_custom_command(
+ OUTPUT dependsA.txt
+ COMMAND ${CMAKE_COMMAND} -E echo "dependsA" > dependsA.txt
+ DEPENDS ${MISSING_DEP} ${DEP_CYCLE} another_file.c
+ COMMENT "CT: generate text file dependsA"
+)
+
+add_custom_command(
+ OUTPUT another_file.c
+ COMMAND ${CMAKE_COMMAND} -E echo "//auto-gen file" > another_file.c
+ COMMENT "CT: generate C file another_file"
+)
+
+add_dependencies(target_update_files target_empty)
diff --git a/Tests/GhsMulti/GhsMultiCustomTarget/exe1.c b/Tests/GhsMulti/GhsMultiCustomTarget/exe1.c
new file mode 100644
index 000000000..29ad70a3b
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiCustomTarget/exe1.c
@@ -0,0 +1,5 @@
+extern int func(void);
+int main(void)
+{
+ return func();
+}
diff --git a/Tests/GhsMulti/GhsMultiCustomTarget/lib1.c b/Tests/GhsMulti/GhsMultiCustomTarget/lib1.c
new file mode 100644
index 000000000..b35e9cc5e
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiCustomTarget/lib1.c
@@ -0,0 +1,4 @@
+int func(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiDepOrder/CMakeLists.txt b/Tests/GhsMulti/GhsMultiDepOrder/CMakeLists.txt
new file mode 100644
index 000000000..2e2871b11
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDepOrder/CMakeLists.txt
@@ -0,0 +1,12 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+#set_property( GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1)
+add_subdirectory(exec)
+add_subdirectory(lib)
+add_subdirectory(protolib)
+add_dependencies(lib1 proto)
diff --git a/Tests/GhsMulti/GhsMultiDepOrder/exec/CMakeLists.txt b/Tests/GhsMulti/GhsMultiDepOrder/exec/CMakeLists.txt
new file mode 100644
index 000000000..85ee8056b
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDepOrder/exec/CMakeLists.txt
@@ -0,0 +1,11 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+add_executable(exe1 exe1.c)
+target_link_libraries(exe1 lib1)
+target_include_directories(exe1 PRIVATE "${test_BINARY_DIR}")
+if(CMAKE_C_COMPILER_ID STREQUAL "GHS")
+ target_link_options(exe1 PRIVATE "-non_shared")
+endif()
diff --git a/Tests/GhsMulti/GhsMultiDepOrder/exec/exe1.c b/Tests/GhsMulti/GhsMultiDepOrder/exec/exe1.c
new file mode 100644
index 000000000..fbf4ed43e
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDepOrder/exec/exe1.c
@@ -0,0 +1,8 @@
+#include "lib1.h"
+#include "p.h"
+
+int main(void)
+{
+ return func1() + func2() + func3() + func1p() + func2p() + func3p() +
+ PROTO1 + PROTO2 + PROTO3;
+}
diff --git a/Tests/GhsMulti/GhsMultiDepOrder/lib/CMakeLists.txt b/Tests/GhsMulti/GhsMultiDepOrder/lib/CMakeLists.txt
new file mode 100644
index 000000000..ae30fa2bd
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDepOrder/lib/CMakeLists.txt
@@ -0,0 +1,17 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+add_library(lib1 STATIC
+ func1.c lib1.h
+ "${test_BINARY_DIR}/protolib/proto1.c"
+ "${test_BINARY_DIR}/protolib/proto1.h")
+set_source_files_properties(
+ "${test_BINARY_DIR}/protolib/proto1.c"
+ "${test_BINARY_DIR}/protolib/proto1.h"
+ PROPERTIES GENERATED 1)
+target_include_directories(lib1 PRIVATE "${test_BINARY_DIR}/protolib"
+ PUBLIC .)
+add_custom_command( TARGET lib1 POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy "${test_BINARY_DIR}/protolib/proto1.h" "${test_BINARY_DIR}/p.h"
+ COMMENT "Copy ${test_BINARY_DIR}/protolib/proto1.h ${test_BINARY_DIR}/p.h"
+ BYPRODUCTS "${test_BINARY_DIR}/p.h")
diff --git a/Tests/GhsMulti/GhsMultiDepOrder/lib/func1.c b/Tests/GhsMulti/GhsMultiDepOrder/lib/func1.c
new file mode 100644
index 000000000..53334fe36
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDepOrder/lib/func1.c
@@ -0,0 +1,17 @@
+#include "lib1.h"
+#include "proto1.h"
+
+int func1(void)
+{
+ return 1 + PROTO1;
+}
+
+int func2(void)
+{
+ return 2 + PROTO2;
+}
+
+int func3(void)
+{
+ return 3 + PROTO3;
+}
diff --git a/Tests/GhsMulti/GhsMultiDepOrder/lib/lib1.h b/Tests/GhsMulti/GhsMultiDepOrder/lib/lib1.h
new file mode 100644
index 000000000..5e99f0287
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDepOrder/lib/lib1.h
@@ -0,0 +1,3 @@
+extern int func1(void);
+extern int func2(void);
+extern int func3(void);
diff --git a/Tests/GhsMulti/GhsMultiDepOrder/protolib/CMakeLists.txt b/Tests/GhsMulti/GhsMultiDepOrder/protolib/CMakeLists.txt
new file mode 100644
index 000000000..8cb6869bd
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDepOrder/protolib/CMakeLists.txt
@@ -0,0 +1,28 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+add_custom_target(proto ALL
+ DEPENDS proto1.c
+ proto1.h
+ SOURCES
+ ${test_SOURCE_DIR}/protolib/proto1.c.in
+ ${test_SOURCE_DIR}/protolib/proto1.h.in
+ COMMENT "Creating proto files")
+
+add_custom_command(
+ OUTPUT proto1.c
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${test_SOURCE_DIR}/protolib/proto1.c.in proto1.c
+ DEPENDS ${test_SOURCE_DIR}/protolib/proto1.c.in
+ COMMENT "generate proto C files"
+)
+
+add_custom_command(
+ OUTPUT proto1.h
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${test_SOURCE_DIR}/protolib/proto1.h.in proto1.h
+ DEPENDS ${test_SOURCE_DIR}/protolib/proto1.h.in
+ COMMENT "generate proto H files"
+)
diff --git a/Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.c.in b/Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.c.in
new file mode 100644
index 000000000..0efb1bd8d
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.c.in
@@ -0,0 +1,16 @@
+#include "proto1.h"
+
+int func1p(void)
+{
+ return 1;
+}
+
+int func2p(void)
+{
+ return 2;
+}
+
+int func3p(void)
+{
+ return 3;
+}
diff --git a/Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.h.in b/Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.h.in
new file mode 100644
index 000000000..f2f93afdd
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDepOrder/protolib/proto1.h.in
@@ -0,0 +1,7 @@
+extern int func1p(void);
+extern int func2p(void);
+extern int func3p(void);
+
+#define PROTO1 0x1
+#define PROTO2 0x2
+#define PROTO3 0x3
diff --git a/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/CMakeLists.txt b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/CMakeLists.txt
new file mode 100644
index 000000000..a1f152f29
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.5)
+project(test C)
+
+add_library(libdemo
+ test.c
+ testCase.c
+ subfolder_test.c
+ subfolder_test_0.c
+ "subfolder/test.c"
+ subfolder/testcase.c
+)
+
+add_executable(demo main.c)
+target_link_libraries(demo libdemo)
+if(CMAKE_C_COMPILER_ID STREQUAL "GHS")
+ target_link_options(demo PRIVATE "-non_shared")
+endif()
diff --git a/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/main.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/main.c
new file mode 100644
index 000000000..d4ef7bb0f
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/main.c
@@ -0,0 +1,17 @@
+int test_a(void);
+int test_b(void);
+int test_c(void);
+int test_d(void);
+int test_e(void);
+int test_f(void);
+
+int main(int argc, char* argv[])
+{
+ test_a();
+ test_b();
+ test_c();
+ test_d();
+ test_e();
+ test_f();
+ return 0;
+}
diff --git a/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder/test.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder/test.c
new file mode 100644
index 000000000..5d857dde6
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder/test.c
@@ -0,0 +1,4 @@
+int test_b()
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder/testcase.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder/testcase.c
new file mode 100644
index 000000000..66ee6f380
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder/testcase.c
@@ -0,0 +1,4 @@
+int test_f()
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder_test.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder_test.c
new file mode 100644
index 000000000..83589ba19
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder_test.c
@@ -0,0 +1,4 @@
+int test_c()
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c
new file mode 100644
index 000000000..82f9a52b7
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c
@@ -0,0 +1,4 @@
+int test_d()
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/test.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/test.c
new file mode 100644
index 000000000..feba80efc
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/test.c
@@ -0,0 +1,4 @@
+int test_a()
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/testCase.c b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/testCase.c
new file mode 100644
index 000000000..943c19de6
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiDuplicateSourceFilenames/testCase.c
@@ -0,0 +1,4 @@
+int test_e()
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt b/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt
new file mode 100644
index 000000000..0448cf2d6
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt
@@ -0,0 +1,17 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+if(CMAKE_C_COMPILER_ID STREQUAL "GHS")
+ add_link_options("-non_shared")
+endif()
+
+add_library(lib1 lib1.c)
+set_target_properties( lib1 PROPERTIES EXCLUDE_FROM_ALL yes )
+
+add_library(lib2 EXCLUDE_FROM_ALL lib1.c)
+
+add_executable(exe1 exe1.c)
diff --git a/Tests/GhsMulti/GhsMultiExclude/exe1.c b/Tests/GhsMulti/GhsMultiExclude/exe1.c
new file mode 100644
index 000000000..8488f4e58
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiExclude/exe1.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/GhsMulti/GhsMultiExclude/lib1.c b/Tests/GhsMulti/GhsMultiExclude/lib1.c
new file mode 100644
index 000000000..b35e9cc5e
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiExclude/lib1.c
@@ -0,0 +1,4 @@
+int func(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiExclude/verify.cmake b/Tests/GhsMulti/GhsMultiExclude/verify.cmake
new file mode 100644
index 000000000..0467b5a0d
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiExclude/verify.cmake
@@ -0,0 +1,54 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#test project was generated
+unset(fileName CACHE)
+find_file (fileName lib1.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/lib1
+ )
+
+if (fileName)
+ message("Found target lib1: ${fileName}")
+else()
+ message(SEND_ERROR "Could not find target lib1: ${fileName}")
+endif()
+
+#test project was built
+unset(fileName CACHE)
+find_file (fileName lib1.a
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/lib1
+ )
+
+if (fileName)
+ message(SEND_ERROR "Found target lib1: ${fileName}")
+else()
+ message("Could not find target lib1: ${fileName}")
+endif()
+
+#test project was generated
+unset(fileName CACHE)
+find_file (fileName lib2.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/lib2
+ )
+
+if (fileName)
+ message("Found target lib2 ${fileName}")
+else()
+ message(SEND_ERROR "Could not find target lib2: ${fileName}")
+endif()
+
+#test project was built
+unset(fileName CACHE)
+find_file (fileName lib2.a
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/lib2
+ )
+
+if (fileName)
+ message(SEND_ERROR "Found target lib2: ${fileName}")
+else()
+ message("Could not find target lib2: ${fileName}")
+endif()
diff --git a/Tests/GhsMulti/GhsMultiExternalProject/CMakeLists.txt b/Tests/GhsMulti/GhsMultiExternalProject/CMakeLists.txt
new file mode 100644
index 000000000..24126c8fa
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiExternalProject/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+include(ExternalProject)
+
+ExternalProject_Add(another_project
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/empty
+ BINARY_DIR empty_build
+ INSTALL_COMMAND ""
+ TEST_COMMAND ""
+ )
diff --git a/Tests/GhsMulti/GhsMultiExternalProject/empty/CMakeLists.txt b/Tests/GhsMulti/GhsMultiExternalProject/empty/CMakeLists.txt
new file mode 100644
index 000000000..6846a9853
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiExternalProject/empty/CMakeLists.txt
@@ -0,0 +1,8 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(empty NONE)
+
+message("EMPTY PROJECT")
diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/CMakeLists.txt
new file mode 100644
index 000000000..d4cbf0476
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/CMakeLists.txt
@@ -0,0 +1,19 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+add_link_options("-non_shared")
+
+# create virtual AS
+add_executable(vas exe.c)
+target_link_libraries(vas lib)
+add_library(lib func.c)
+
+# create dynamic download INTEGRITY application
+add_executable(dynamic)
+set_target_properties(dynamic PROPERTIES ghs_integrity_app ON)
+target_compile_options(dynamic PRIVATE -dynamic)
+add_dependencies(dynamic vas)
diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/exe.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/exe.c
new file mode 100644
index 000000000..29ad70a3b
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/exe.c
@@ -0,0 +1,5 @@
+extern int func(void);
+int main(void)
+{
+ return func();
+}
diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/func.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/func.c
new file mode 100644
index 000000000..b35e9cc5e
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDD/func.c
@@ -0,0 +1,4 @@
+int func(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/CMakeLists.txt
new file mode 100644
index 000000000..3837b5a2e
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_executable(App Main.c)
+target_link_libraries(App Lib)
+target_compile_options(App PUBLIC "-non_shared")
diff --git a/Tests/GhsMulti/ReturnNum/App/Main.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/Main.c
index db8d6587d..db8d6587d 100644
--- a/Tests/GhsMulti/ReturnNum/App/Main.c
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/App/Main.c
diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/CMakeLists.txt
new file mode 100644
index 000000000..92254e673
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.1)
+project(test)
+
+add_subdirectory(App)
+add_subdirectory(Int)
+add_subdirectory(Lib)
diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/AppDD.int b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/AppDD.int
new file mode 100644
index 000000000..5035d581a
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/AppDD.int
@@ -0,0 +1,12 @@
+# Input File for the Integrate utility for use with the INTEGRITY real-time
+# operating system by Green Hills Software.
+# Before editing this file, refer to the Integrate Reference Manual.
+
+Kernel
+ Filename DynamicDownload
+EndKernel
+
+AddressSpace App
+ Filename "App/App"
+ Language C
+EndAddressSpace
diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/CMakeLists.txt
new file mode 100644
index 000000000..d173c0151
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Int/CMakeLists.txt
@@ -0,0 +1 @@
+add_executable(AppDD AppDD.int)
diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/CMakeLists.txt
new file mode 100644
index 000000000..bb9849abb
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_library(Lib HelperFun.c HelperFun.h)
+target_include_directories(Lib PUBLIC .)
diff --git a/Tests/GhsMulti/ReturnNum/Lib/HelperFun.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/HelperFun.c
index 61922bb75..61922bb75 100644
--- a/Tests/GhsMulti/ReturnNum/Lib/HelperFun.c
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/HelperFun.c
diff --git a/Tests/GhsMulti/ReturnNum/Lib/HelperFun.h b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/HelperFun.h
index 00971b04f..00971b04f 100644
--- a/Tests/GhsMulti/ReturnNum/Lib/HelperFun.h
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityDDInt/Lib/HelperFun.h
diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt
new file mode 100644
index 000000000..3f2f0eba6
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/CMakeLists.txt
@@ -0,0 +1,21 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+add_link_options("-non_shared")
+
+project(test C)
+
+# create virtual AS
+add_executable(vas exe.c)
+target_link_libraries(vas lib)
+add_library(lib func.c)
+
+# create kernel
+add_executable(kernel kernel.c)
+target_link_options(kernel PRIVATE -kernel)
+
+# create monolith INTEGRITY application
+add_executable(monolith test.int)
+add_dependencies(monolith vas)
diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/exe.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/exe.c
new file mode 100644
index 000000000..29ad70a3b
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/exe.c
@@ -0,0 +1,5 @@
+extern int func(void);
+int main(void)
+{
+ return func();
+}
diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/func.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/func.c
new file mode 100644
index 000000000..c302418f9
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/func.c
@@ -0,0 +1,5 @@
+
+int func(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/kernel.c b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/kernel.c
new file mode 100644
index 000000000..d1bce33c9
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/kernel.c
@@ -0,0 +1,15 @@
+#include "INTEGRITY.h"
+#include "boottable.h"
+
+void main()
+{
+ Exit(0);
+}
+
+/* This global table will be filled in during the Integrate phase with */
+/* information about the AddressSpaces, Tasks, and Objects that are to be */
+/* created. If you do not plan to use Integrate, you may omit this file from
+ */
+/* the kernel, and the boot table code will then not be included. */
+
+GlobalTable TheGlobalTable = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
diff --git a/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/test.int b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/test.int
new file mode 100644
index 000000000..361793a86
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiIntegrity/GhsMultiIntegrityMonolith/test.int
@@ -0,0 +1,8 @@
+Kernel
+ Filename kernel
+EndKernel
+
+AddressSpace App
+ Filename vas
+ Language C
+EndAddressSpace
diff --git a/Tests/GhsMulti/GhsMultiInterface/CMakeLists.txt b/Tests/GhsMulti/GhsMultiInterface/CMakeLists.txt
new file mode 100644
index 000000000..fa0dce027
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiInterface/CMakeLists.txt
@@ -0,0 +1,8 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+add_library(iface INTERFACE)
diff --git a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt
new file mode 100644
index 000000000..da80b510f
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt
@@ -0,0 +1,92 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+message("Copy project")
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in
+ ${CMAKE_CURRENT_BINARY_DIR}/link_src/CMakeLists.txt COPYONLY)
+
+file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/exe1.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/exe1.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/func2.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/func3.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/func4.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/func5.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/func6.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/func7.c
+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/link_src
+)
+
+message("Building project")
+try_compile(RESULT
+ ${CMAKE_CURRENT_BINARY_DIR}/link_build
+ ${CMAKE_CURRENT_BINARY_DIR}/link_src
+ test
+ CMAKE_FLAGS
+ -DRUN_TEST=${RUN_TEST}
+ -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
+ OUTPUT_VARIABLE OUTPUT)
+
+message("Output from build:\n${OUTPUT}")
+if (RUN_TEST STREQUAL "NO_FLAGS")
+ if(NOT RESULT)
+ message(SEND_ERROR "Could not build test project (1)!")
+ endif()
+else()
+ unset(fileName CACHE)
+ find_file(fileName exe1.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}/link_build
+ ${CMAKE_CURRENT_BINARY_DIR}/link_build/exe1
+ )
+ message("Parsing project file: ${fileName}")
+ file(STRINGS ${fileName} fileText)
+ set(expected_flags
+ -add-link-options1 -add-link-options2
+ link_directories_used1 link_directories_used2 "c:/absolute"
+ link_libraries_used1 link_libraries_used2
+ -lcsl1 csl2
+ -clinkexe1 -clinkexe2
+ -special-lib2-public-link)
+ foreach(opt IN LISTS expected_flags)
+ string(FIND "${fileText}" "${opt}" opt_found)
+ if ( opt_found EQUAL -1 )
+ message(SEND_ERROR "Could not find: ${opt}")
+ endif()
+ endforeach()
+
+ unset(fileName CACHE)
+ find_file (fileName lib1.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}/link_build
+ ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib1
+ )
+ message("Parsing project file: ${fileName}")
+ file(STRINGS ${fileName} fileText)
+ set(expected_flags
+ -clinkexeA1 -clinkexeA2
+ -static-lib-flags1 -static-lib-flags2)
+ foreach(opt IN LISTS expected_flags)
+ string(FIND "${fileText}" "${opt}" opt_found)
+ if (opt_found EQUAL -1)
+ message(SEND_ERROR "Could not find: ${opt}")
+ endif()
+ endforeach()
+
+ unset(fileName CACHE)
+ find_file (fileName lib2.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}/link_build
+ ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib2
+ )
+ message("Parsing project file: ${fileName}")
+ file(STRINGS ${fileName} fileText)
+ set(expected_flags
+ -clinkexeA1 -clinkexeA2)
+ foreach(opt IN LISTS expected_flags)
+ string(FIND "${fileText}" "${opt}" opt_found)
+ if ( opt_found EQUAL -1 )
+ message(SEND_ERROR "Could not find: ${opt}")
+ endif()
+ endforeach()
+endif()
diff --git a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in
new file mode 100644
index 000000000..58c211524
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in
@@ -0,0 +1,43 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+if(CMAKE_C_COMPILER_ID STREQUAL "GHS")
+ add_link_options("-non_shared")
+endif()
+
+if(RUN_TEST STREQUAL "CHECK_FLAGS")
+ add_link_options(-add-link-options1 -add-link-options2)
+ link_directories(link_directories_used1 link_directories_used2 "c:/absolute")
+ link_libraries(link_libraries_used1 link_libraries_used2 )
+ set( CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lcsl1 csl2" )
+ set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -clinkexe1 -clinkexe2")
+endif()
+
+add_executable(exe1 exe1.c)
+target_link_libraries(exe1 lib1)
+
+if(RUN_TEST STREQUAL "CHECK_FLAGS")
+ set_property(TARGET exe1 APPEND_STRING PROPERTY LINK_FLAGS "--link-flag-prop1 --link-flag-prop2")
+ set_property(TARGET exe1 APPEND PROPERTY LINK_OPTIONS --link-opt-prop1 --link-opt-prop2)
+endif()
+
+if(RUN_TEST STREQUAL "CHECK_FLAGS")
+ set(CMAKE_STATIC_LINKER_FLAGS ${CMAKE_STATIC_LINKER_FLAGS} "-clinkexeA1 -clinkexeA2")
+endif()
+
+add_library(lib1 STATIC func2.c func3.c func4.c)
+target_link_libraries(lib1 lib2)
+
+if(RUN_TEST STREQUAL "CHECK_FLAGS")
+ set_property(TARGET lib1 APPEND_STRING PROPERTY STATIC_LIBRARY_FLAGS "-static-lib-flags1 -static-lib-flags2")
+endif()
+
+add_library(lib2 STATIC func5.c func6.c func7.c)
+
+if(RUN_TEST STREQUAL "CHECK_FLAGS")
+ target_link_options(lib2 PUBLIC -special-lib2-public-link)
+endif()
diff --git a/Tests/GhsMulti/GhsMultiLinkTest/exe1.c b/Tests/GhsMulti/GhsMultiLinkTest/exe1.c
new file mode 100644
index 000000000..f21c12645
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTest/exe1.c
@@ -0,0 +1,6 @@
+#include "exe1.h"
+
+int main(void)
+{
+ return func2a() + func3a() + func4a() + func5a() + func6a() + func7a();
+}
diff --git a/Tests/GhsMulti/GhsMultiLinkTest/exe1.h b/Tests/GhsMulti/GhsMultiLinkTest/exe1.h
new file mode 100644
index 000000000..e2b172570
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTest/exe1.h
@@ -0,0 +1,6 @@
+extern int func2a(void);
+extern int func3a(void);
+extern int func4a(void);
+extern int func5a(void);
+extern int func6a(void);
+extern int func7a(void);
diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func2.c b/Tests/GhsMulti/GhsMultiLinkTest/func2.c
new file mode 100644
index 000000000..8f66fba25
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTest/func2.c
@@ -0,0 +1,4 @@
+int func2a(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func3.c b/Tests/GhsMulti/GhsMultiLinkTest/func3.c
new file mode 100644
index 000000000..57c7a6ffb
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTest/func3.c
@@ -0,0 +1,4 @@
+int func3a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func4.c b/Tests/GhsMulti/GhsMultiLinkTest/func4.c
new file mode 100644
index 000000000..109fd7b4a
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTest/func4.c
@@ -0,0 +1,4 @@
+int func4a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func5.c b/Tests/GhsMulti/GhsMultiLinkTest/func5.c
new file mode 100644
index 000000000..f28a705d4
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTest/func5.c
@@ -0,0 +1,4 @@
+int func5a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func6.c b/Tests/GhsMulti/GhsMultiLinkTest/func6.c
new file mode 100644
index 000000000..bf7740658
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTest/func6.c
@@ -0,0 +1,4 @@
+int func6a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func7.c b/Tests/GhsMulti/GhsMultiLinkTest/func7.c
new file mode 100644
index 000000000..6a4a9a1f0
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTest/func7.c
@@ -0,0 +1,4 @@
+int func7a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTestSub/CMakeLists.txt
new file mode 100644
index 000000000..145dac0eb
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTestSub/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+add_subdirectory(sub_exe)
+add_subdirectory(sub_lib)
diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/CMakeLists.txt
new file mode 100644
index 000000000..f49e33d6c
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/CMakeLists.txt
@@ -0,0 +1,12 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+add_executable(exe1 exe1.c)
+target_link_libraries(exe1 lib1)
+if(CMAKE_C_COMPILER_ID STREQUAL "GHS")
+ target_link_options(exe1 PRIVATE "-non_shared")
+endif()
diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.c
new file mode 100644
index 000000000..f21c12645
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.c
@@ -0,0 +1,6 @@
+#include "exe1.h"
+
+int main(void)
+{
+ return func2a() + func3a() + func4a() + func5a() + func6a() + func7a();
+}
diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.h b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.h
new file mode 100644
index 000000000..e2b172570
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_exe/exe1.h
@@ -0,0 +1,6 @@
+extern int func2a(void);
+extern int func3a(void);
+extern int func4a(void);
+extern int func5a(void);
+extern int func6a(void);
+extern int func7a(void);
diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/CMakeLists.txt
new file mode 100644
index 000000000..90397304f
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+add_library(lib1 STATIC func2.c func3.c func4.c)
+target_link_libraries(lib1 lib2)
+
+add_library(lib2 STATIC func5.c func6.c func7.c)
diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func2.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func2.c
new file mode 100644
index 000000000..8f66fba25
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func2.c
@@ -0,0 +1,4 @@
+int func2a(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func3.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func3.c
new file mode 100644
index 000000000..57c7a6ffb
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func3.c
@@ -0,0 +1,4 @@
+int func3a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func4.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func4.c
new file mode 100644
index 000000000..109fd7b4a
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func4.c
@@ -0,0 +1,4 @@
+int func4a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func5.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func5.c
new file mode 100644
index 000000000..f28a705d4
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func5.c
@@ -0,0 +1,4 @@
+int func5a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func6.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func6.c
new file mode 100644
index 000000000..bf7740658
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func6.c
@@ -0,0 +1,4 @@
+int func6a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func7.c b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func7.c
new file mode 100644
index 000000000..6a4a9a1f0
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiLinkTestSub/sub_lib/func7.c
@@ -0,0 +1,4 @@
+int func7a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/CMakeLists.txt b/Tests/GhsMulti/GhsMultiMultipleProjects/CMakeLists.txt
new file mode 100644
index 000000000..9e077a9a4
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiMultipleProjects/CMakeLists.txt
@@ -0,0 +1,17 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+if(CMAKE_C_COMPILER_ID STREQUAL "GHS")
+ add_link_options("-non_shared")
+endif()
+
+add_library(lib1 lib1.c)
+add_executable(exe1 exe1.c)
+target_link_libraries(exe1 lib1)
+
+add_subdirectory(sub)
+add_subdirectory(sub2 examples EXCLUDE_FROM_ALL)
diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/exe1.c b/Tests/GhsMulti/GhsMultiMultipleProjects/exe1.c
new file mode 100644
index 000000000..b9cdd61e7
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiMultipleProjects/exe1.c
@@ -0,0 +1,5 @@
+extern int lib1_func(void);
+int main(void)
+{
+ return lib1_func();
+}
diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/lib1.c b/Tests/GhsMulti/GhsMultiMultipleProjects/lib1.c
new file mode 100644
index 000000000..510094589
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiMultipleProjects/lib1.c
@@ -0,0 +1,4 @@
+int lib1_func(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/sub/CMakeLists.txt b/Tests/GhsMulti/GhsMultiMultipleProjects/sub/CMakeLists.txt
new file mode 100644
index 000000000..0d83bc310
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiMultipleProjects/sub/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test2 C)
+
+add_library(lib2 lib2.c)
+add_executable(exe2 exe2.c)
+target_link_libraries(exe2 lib1 lib2)
diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/sub/exe2.c b/Tests/GhsMulti/GhsMultiMultipleProjects/sub/exe2.c
new file mode 100644
index 000000000..9238cf369
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiMultipleProjects/sub/exe2.c
@@ -0,0 +1,6 @@
+extern int func(void);
+extern int lib1_func(void);
+int main(void)
+{
+ return func() + lib1_func();
+}
diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/sub/lib2.c b/Tests/GhsMulti/GhsMultiMultipleProjects/sub/lib2.c
new file mode 100644
index 000000000..b35e9cc5e
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiMultipleProjects/sub/lib2.c
@@ -0,0 +1,4 @@
+int func(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/CMakeLists.txt b/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/CMakeLists.txt
new file mode 100644
index 000000000..e42e7fb2c
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test3 C)
+
+add_library(lib3 lib3.c)
+add_executable(exe3 exe3.c)
+target_link_libraries(exe3 lib1 lib3)
diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/exe3.c b/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/exe3.c
new file mode 100644
index 000000000..9238cf369
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/exe3.c
@@ -0,0 +1,6 @@
+extern int func(void);
+extern int lib1_func(void);
+int main(void)
+{
+ return func() + lib1_func();
+}
diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/lib3.c b/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/lib3.c
new file mode 100644
index 000000000..b35e9cc5e
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiMultipleProjects/sub2/lib3.c
@@ -0,0 +1,4 @@
+int func(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake b/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake
new file mode 100644
index 000000000..3855215af
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake
@@ -0,0 +1,58 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#test project was generated
+unset(fileName CACHE)
+find_file(fileName lib3.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/lib3
+ ${CMAKE_CURRENT_BINARY_DIR}/examples
+ )
+
+if (fileName)
+ message("Found target lib3: ${fileName}")
+else()
+ message(SEND_ERROR "Could not find target lib3: ${fileName}")
+endif()
+
+#test project was generated
+unset(fileName CACHE)
+find_file (fileName exe3.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/exe3
+ ${CMAKE_CURRENT_BINARY_DIR}/examples
+ )
+
+if (fileName)
+ message("Found target exe3: ${fileName}")
+else()
+ message(SEND_ERROR "Could not find target exe3: ${fileName}")
+endif()
+
+#test project was not built
+unset(fileName CACHE)
+find_file (fileName lib3.a
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/lib3
+ ${CMAKE_CURRENT_BINARY_DIR}/examples
+ )
+
+if (fileName)
+ message(SEND_ERROR "Found target lib3: ${fileName}")
+else()
+ message("Could not find target lib3: ${fileName}")
+endif()
+
+unset(fileName CACHE)
+find_file (fileName NAMES exe3.as exe3
+ HINTS
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/exe3
+ ${CMAKE_CURRENT_BINARY_DIR}/examples
+ )
+
+if (fileName)
+ message(SEND_ERROR "Found target exe3: ${fileName}")
+else()
+ message("Could not find target exe3: ${fileName}")
+endif()
diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt b/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt
new file mode 100644
index 000000000..98668e5c9
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiObjectLibrary/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+add_library(obj1 OBJECT testOBJ.c testOBJ.h sub/testOBJ.c testOBJ2.c)
+
+add_executable(exe1 exe.c $<TARGET_OBJECTS:obj1>)
+if(CMAKE_C_COMPILER_ID STREQUAL "GHS")
+ target_link_options(exe1 PRIVATE "-non_shared")
+endif()
diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/exe.c b/Tests/GhsMulti/GhsMultiObjectLibrary/exe.c
new file mode 100644
index 000000000..c2c5a1945
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiObjectLibrary/exe.c
@@ -0,0 +1,8 @@
+extern int funcOBJ(void);
+extern int funcOBJ2(void);
+extern int funcOBJs(void);
+
+int main(void)
+{
+ return funcOBJ() + funcOBJ2() + funcOBJs();
+}
diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/sub/testOBJ.c b/Tests/GhsMulti/GhsMultiObjectLibrary/sub/testOBJ.c
new file mode 100644
index 000000000..5228ef264
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiObjectLibrary/sub/testOBJ.c
@@ -0,0 +1,4 @@
+int funcOBJs(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.c b/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.c
new file mode 100644
index 000000000..ec6f2c331
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.c
@@ -0,0 +1,4 @@
+int funcOBJ(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.h b/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.h
new file mode 100644
index 000000000..9aef4315c
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ.h
@@ -0,0 +1 @@
+extern int funcOBJ(void);
diff --git a/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ2.c b/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ2.c
new file mode 100644
index 000000000..b6a9b93f2
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiObjectLibrary/testOBJ2.c
@@ -0,0 +1,4 @@
+int funcOBJ2(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiPlatform/CMakeLists.txt b/Tests/GhsMulti/GhsMultiPlatform/CMakeLists.txt
new file mode 100644
index 000000000..b177887c9
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiPlatform/CMakeLists.txt
@@ -0,0 +1,34 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test)
+
+message("PLATFORM_ID = ${PLATFORM_ID}")
+
+message("CMAKE_C_COMPILER = ${CMAKE_C_COMPILER}")
+message("CMAKE_C_COMPILER_ID = ${CMAKE_C_COMPILER_ID}")
+message("CMAKE_C_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION}")
+message("CMAKE_C_COMPILER_VERSION_INTERNAL = ${CMAKE_C_COMPILER_VERSION_INTERNAL}")
+message("CMAKE_C_PLATFORM_ID = ${CMAKE_C_PLATFORM_ID}")
+message("CMAKE_C_COMPILER_ARCHITECTURE_ID = ${CMAKE_C_COMPILER_ARCHITECTURE_ID}")
+message("CMAKE_C_COMPILER_ABI = ${CMAKE_C_COMPILER_ABI}")
+message("CMAKE_C_STANDARD_COMPUTED_DEFAULT = ${CMAKE_C_STANDARD_COMPUTED_DEFAULT}")
+
+message("CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}")
+message("CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
+message("CMAKE_CXX_COMPILER_VERSION = ${CMAKE_CXX_COMPILER_VERSION}")
+message("CMAKE_CXX_COMPILER_VERSION_INTERNAL = ${CMAKE_CXX_COMPILER_VERSION_INTERNAL}")
+message("CMAKE_CXX_PLATFORM_ID = ${CMAKE_CXX_PLATFORM_ID}")
+message("CMAKE_CXX_COMPILER_ARCHITECTURE_ID = ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}")
+message("CMAKE_CXX_COMPILER_ABI = ${CMAKE_CXX_COMPILER_ABI}")
+message("CMAKE_CXX_STANDARD_COMPUTED_DEFAULT = ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}")
+
+if(CMAKE_C_COMPILER AND NOT CMAKE_C_COMPILER_ID STREQUAL "GHS")
+ message(FATAL_ERROR "CMAKE_C_COMPILER_ID != GHS")
+endif()
+
+if(CMAKE_CXX_COMPILER AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "GHS")
+ message(FATAL_ERROR "CMAKE_CXX_COMPILER_ID != GHS")
+endif()
diff --git a/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt b/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt
new file mode 100644
index 000000000..b2540d974
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiRenameInstall/CMakeLists.txt
@@ -0,0 +1,42 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+set(targets_to_install "")
+
+if(CMAKE_C_COMPILER_ID STREQUAL "GHS")
+ add_link_options("-non_shared")
+endif()
+
+if(RUN_TEST STREQUAL "SINGLE_EXEC")
+ add_executable(exe1 exe.c)
+ set(targets_to_install exe1)
+endif()
+
+if(RUN_TEST STREQUAL "SINGLE_EXEC_RENAMED")
+ set(name new_name)
+ add_executable(exe1 exe.c)
+ set_property(TARGET exe1 PROPERTY RUNTIME_OUTPUT_DIRECTORY ${name}_bin_$<CONFIG>)
+ set_property(TARGET exe1 PROPERTY OUTPUT_NAME ${name}_$<CONFIG>)
+ set_property(TARGET exe1 PROPERTY SUFFIX .bin)
+ set(targets_to_install exe1)
+endif()
+
+if(RUN_TEST STREQUAL "EXEC_AND_LIB")
+ add_library(lib1 lib1.c)
+ set_property(TARGET lib1 PROPERTY ARCHIVE_OUTPUT_DIRECTORY forced-$<CONFIG>)
+ set_property(TARGET lib1 PROPERTY SUFFIX .LL)
+ set_property(TARGET lib1 PROPERTY OUTPUT_NAME lib1_$<CONFIG>)
+
+ add_executable(exe1 exe1.c)
+ target_link_libraries(exe1 lib1)
+ set(targets_to_install exe1 lib1)
+endif()
+
+install(TARGETS ${targets_to_install}
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib/static)
diff --git a/Tests/GhsMulti/GhsMultiRenameInstall/exe.c b/Tests/GhsMulti/GhsMultiRenameInstall/exe.c
new file mode 100644
index 000000000..8488f4e58
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiRenameInstall/exe.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/GhsMulti/GhsMultiRenameInstall/exe1.c b/Tests/GhsMulti/GhsMultiRenameInstall/exe1.c
new file mode 100644
index 000000000..29ad70a3b
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiRenameInstall/exe1.c
@@ -0,0 +1,5 @@
+extern int func(void);
+int main(void)
+{
+ return func();
+}
diff --git a/Tests/GhsMulti/GhsMultiRenameInstall/lib1.c b/Tests/GhsMulti/GhsMultiRenameInstall/lib1.c
new file mode 100644
index 000000000..b35e9cc5e
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiRenameInstall/lib1.c
@@ -0,0 +1,4 @@
+int func(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/Atest3.c b/Tests/GhsMulti/GhsMultiSrcGroups/Atest3.c
new file mode 100644
index 000000000..9c9c1d91b
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/Atest3.c
@@ -0,0 +1,4 @@
+int funcA3a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/CMakeLists.txt b/Tests/GhsMulti/GhsMultiSrcGroups/CMakeLists.txt
new file mode 100644
index 000000000..93a1afcb6
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/CMakeLists.txt
@@ -0,0 +1,45 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+#set(CMAKE_FOLDER ON)
+add_executable(groups
+ test1.c
+ test1.h
+ test2a.c
+ test4.c
+ test5.c
+ test6.c
+ test7.c
+ standard.h
+ testOBJ.c
+ testOBJ.h
+ sub/testOBJ.c
+ sub/testOBJ.h
+ textfile.txt
+ textfile2.txt
+ test3.c
+ Atest3.c
+# object.o
+ resource.pdf
+ cmake.rule
+ s5.h
+ s2.h
+ s4.h
+ standard.h
+ )
+
+if(TEST_PROP)
+ set_target_properties(groups PROPERTIES GHS_NO_SOURCE_GROUP_FILE ON)
+endif()
+if(CMAKE_C_COMPILER_ID MATCHES "GHS")
+ target_link_options(groups PRIVATE "-non_shared")
+endif()
+source_group( gC FILES sub/testOBJ.h testOBJ.c testOBJ.h sub/testOBJ.c )
+source_group( gA FILES test1.c test1.h)
+source_group( gB test[65].c )
+source_group( gC\\gD FILES test7.c )
+source_group( docs FILES textfile.txt )
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/cmake.rule b/Tests/GhsMulti/GhsMultiSrcGroups/cmake.rule
new file mode 100644
index 000000000..c6cac6926
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/cmake.rule
@@ -0,0 +1 @@
+empty
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/object.o b/Tests/GhsMulti/GhsMultiSrcGroups/object.o
new file mode 100644
index 000000000..c6cac6926
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/object.o
@@ -0,0 +1 @@
+empty
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/resource.pdf b/Tests/GhsMulti/GhsMultiSrcGroups/resource.pdf
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/resource.pdf
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/s2.h b/Tests/GhsMulti/GhsMultiSrcGroups/s2.h
new file mode 100644
index 000000000..e2b172570
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/s2.h
@@ -0,0 +1,6 @@
+extern int func2a(void);
+extern int func3a(void);
+extern int func4a(void);
+extern int func5a(void);
+extern int func6a(void);
+extern int func7a(void);
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/s4.h b/Tests/GhsMulti/GhsMultiSrcGroups/s4.h
new file mode 100644
index 000000000..e2b172570
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/s4.h
@@ -0,0 +1,6 @@
+extern int func2a(void);
+extern int func3a(void);
+extern int func4a(void);
+extern int func5a(void);
+extern int func6a(void);
+extern int func7a(void);
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/s5.h b/Tests/GhsMulti/GhsMultiSrcGroups/s5.h
new file mode 100644
index 000000000..e2b172570
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/s5.h
@@ -0,0 +1,6 @@
+extern int func2a(void);
+extern int func3a(void);
+extern int func4a(void);
+extern int func5a(void);
+extern int func6a(void);
+extern int func7a(void);
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/standard.h b/Tests/GhsMulti/GhsMultiSrcGroups/standard.h
new file mode 100644
index 000000000..2773a5511
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/standard.h
@@ -0,0 +1 @@
+#define somthing
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.c b/Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.c
new file mode 100644
index 000000000..90ea9b991
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.c
@@ -0,0 +1,6 @@
+#include "testOBJ.h"
+
+int funcOBJsub(void)
+{
+ return func2a() + func3a() + func4a() + func5a() + func6a() + func7a();
+}
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.h b/Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.h
new file mode 100644
index 000000000..e2b172570
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/sub/testOBJ.h
@@ -0,0 +1,6 @@
+extern int func2a(void);
+extern int func3a(void);
+extern int func4a(void);
+extern int func5a(void);
+extern int func6a(void);
+extern int func7a(void);
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test1.c b/Tests/GhsMulti/GhsMultiSrcGroups/test1.c
new file mode 100644
index 000000000..94f818a0e
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/test1.c
@@ -0,0 +1,6 @@
+#include "test1.h"
+
+int main(void)
+{
+ return func2a() + func3a() + func4a() + func5a() + func6a() + func7a();
+}
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test1.h b/Tests/GhsMulti/GhsMultiSrcGroups/test1.h
new file mode 100644
index 000000000..e2b172570
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/test1.h
@@ -0,0 +1,6 @@
+extern int func2a(void);
+extern int func3a(void);
+extern int func4a(void);
+extern int func5a(void);
+extern int func6a(void);
+extern int func7a(void);
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test2a.c b/Tests/GhsMulti/GhsMultiSrcGroups/test2a.c
new file mode 100644
index 000000000..8f66fba25
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/test2a.c
@@ -0,0 +1,4 @@
+int func2a(void)
+{
+ return 2;
+}
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test3.c b/Tests/GhsMulti/GhsMultiSrcGroups/test3.c
new file mode 100644
index 000000000..57c7a6ffb
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/test3.c
@@ -0,0 +1,4 @@
+int func3a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test3.h b/Tests/GhsMulti/GhsMultiSrcGroups/test3.h
new file mode 100644
index 000000000..2773a5511
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/test3.h
@@ -0,0 +1 @@
+#define somthing
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test4.c b/Tests/GhsMulti/GhsMultiSrcGroups/test4.c
new file mode 100644
index 000000000..109fd7b4a
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/test4.c
@@ -0,0 +1,4 @@
+int func4a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test5.c b/Tests/GhsMulti/GhsMultiSrcGroups/test5.c
new file mode 100644
index 000000000..f28a705d4
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/test5.c
@@ -0,0 +1,4 @@
+int func5a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test6.c b/Tests/GhsMulti/GhsMultiSrcGroups/test6.c
new file mode 100644
index 000000000..bf7740658
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/test6.c
@@ -0,0 +1,4 @@
+int func6a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/test7.c b/Tests/GhsMulti/GhsMultiSrcGroups/test7.c
new file mode 100644
index 000000000..6a4a9a1f0
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/test7.c
@@ -0,0 +1,4 @@
+int func7a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.c b/Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.c
new file mode 100644
index 000000000..e86e2a451
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.c
@@ -0,0 +1,11 @@
+extern int func2a(void);
+extern int func3a(void);
+extern int func4a(void);
+extern int func5a(void);
+extern int func6a(void);
+extern int func7a(void);
+
+int funcOBJ(void)
+{
+ return func2a() + func3a() + func4a() + func5a() + func6a() + func7a();
+}
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.h b/Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.h
new file mode 100644
index 000000000..e2b172570
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/testOBJ.h
@@ -0,0 +1,6 @@
+extern int func2a(void);
+extern int func3a(void);
+extern int func4a(void);
+extern int func5a(void);
+extern int func6a(void);
+extern int func7a(void);
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/textfile.txt b/Tests/GhsMulti/GhsMultiSrcGroups/textfile.txt
new file mode 100644
index 000000000..48cdce852
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/textfile.txt
@@ -0,0 +1 @@
+placeholder
diff --git a/Tests/GhsMulti/GhsMultiSrcGroups/textfile2.txt b/Tests/GhsMulti/GhsMultiSrcGroups/textfile2.txt
new file mode 100644
index 000000000..48cdce852
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiSrcGroups/textfile2.txt
@@ -0,0 +1 @@
+placeholder
diff --git a/Tests/GhsMulti/GhsMultiUnsupportedTargets/CMakeLists.txt b/Tests/GhsMulti/GhsMultiUnsupportedTargets/CMakeLists.txt
new file mode 100644
index 000000000..f5f3c55fd
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiUnsupportedTargets/CMakeLists.txt
@@ -0,0 +1,10 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
+
+project(test C)
+
+add_library(sharedLib SHARED file.c)
+
+add_library(moduleLib MODULE file.c)
diff --git a/Tests/GhsMulti/GhsMultiUnsupportedTargets/file.c b/Tests/GhsMulti/GhsMultiUnsupportedTargets/file.c
new file mode 100644
index 000000000..6a4a9a1f0
--- /dev/null
+++ b/Tests/GhsMulti/GhsMultiUnsupportedTargets/file.c
@@ -0,0 +1,4 @@
+int func7a(void)
+{
+ return 1;
+}
diff --git a/Tests/GhsMulti/ReturnNum/App/CMakeLists.txt b/Tests/GhsMulti/ReturnNum/App/CMakeLists.txt
deleted file mode 100644
index 2adbd4e3d..000000000
--- a/Tests/GhsMulti/ReturnNum/App/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../Lib)
-add_executable(App Main.c)
-target_link_libraries(App Lib)
-target_compile_options(App PUBLIC "-non_shared")
diff --git a/Tests/GhsMulti/ReturnNum/CMakeLists.txt b/Tests/GhsMulti/ReturnNum/CMakeLists.txt
deleted file mode 100644
index 7bcc5f96a..000000000
--- a/Tests/GhsMulti/ReturnNum/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-add_subdirectory(App)
-add_subdirectory(Int)
-add_subdirectory(Lib)
diff --git a/Tests/GhsMulti/ReturnNum/Int/AppDD.int b/Tests/GhsMulti/ReturnNum/Int/AppDD.int
deleted file mode 100644
index 9e22b5e25..000000000
--- a/Tests/GhsMulti/ReturnNum/Int/AppDD.int
+++ /dev/null
@@ -1,12 +0,0 @@
-# Input File for the Integrate utility for use with the INTEGRITY real-time
-# operating system by Green Hills Software.
-# Before editing this file, refer to the Integrate Reference Manual.
-
-Kernel
- Filename DynamicDownload
-EndKernel
-
-AddressSpace App
- Filename "App/App.as"
- Language C
-EndAddressSpace
diff --git a/Tests/GhsMulti/ReturnNum/Int/CMakeLists.txt b/Tests/GhsMulti/ReturnNum/Int/CMakeLists.txt
deleted file mode 100644
index 44c5de1c5..000000000
--- a/Tests/GhsMulti/ReturnNum/Int/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_executable(AppDD AppDD.int Default.bsp)
diff --git a/Tests/GhsMulti/ReturnNum/Int/Default.bsp b/Tests/GhsMulti/ReturnNum/Int/Default.bsp
deleted file mode 100644
index 224ec2906..000000000
--- a/Tests/GhsMulti/ReturnNum/Int/Default.bsp
+++ /dev/null
@@ -1,35 +0,0 @@
-# Target description File for the Integrate utility for use with the
-# INTEGRITY real-time operating system by Green Hills Software.
-# Before editing this file, refer to your Integrate documentation.
-# default.bsp is appropriate for INTEGRITY applications which are
-# fully linked with the kernel (for RAM or ROM) or dynamically downloaded.
-#
-# MinimumAddress must match the value of .ramend in the linker directives
-# file used for the KernelSpace program - see default.ld for more info.
-# The MaximumAddress used here allows memory mappings to be specified
-# for up to the 16 MB mark in RAM. Intex will not permit programs
-# that require more memory for its mappings. If the board has less
-# memory, this number can be reduced by the user.
-
-Target
- MinimumAddress .ramend
- MaximumAddress .ramlimit
- Clock StandardTick
- EndClock
- Clock HighResTimer
- EndClock
- IODevice "SerialDev0"
- InitialKernelObjects 200
- DefaultStartIt false
- DefaultMaxPriority 255
- DefaultPriority 127
- DefaultWeight 1
- DefaultMaxWeight 255
- DefaultHeapSize 0x10000
- LastVirtualAddress 0x3fffffff
- PageSize 0x1000
- ArchitectedPageSize 0x1000
- ArchitectedPageSize 0x10000
- ArchitectedPageSize 0x100000
- DefaultMemoryRegionSize 0x20000
-EndTarget
diff --git a/Tests/GhsMulti/ReturnNum/Lib/CMakeLists.txt b/Tests/GhsMulti/ReturnNum/Lib/CMakeLists.txt
deleted file mode 100644
index 9c822da56..000000000
--- a/Tests/GhsMulti/ReturnNum/Lib/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_library(Lib HelperFun.c HelperFun.h) \ No newline at end of file
diff --git a/Tests/GhsMultiDuplicateSourceFilenames/CMakeLists.txt b/Tests/GhsMultiDuplicateSourceFilenames/CMakeLists.txt
deleted file mode 100644
index 82a014bb7..000000000
--- a/Tests/GhsMultiDuplicateSourceFilenames/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-cmake_minimum_required(VERSION 3.5)
-project(demo C)
-
-add_library(libdemo
- test.c
- subfolder_test.c
- subfolder_test_0.c
- "subfolder/test.c"
-)
-
-add_executable(demo main.c)
-target_link_libraries(demo libdemo)
-if(GHSMULTI)
- target_compile_options(demo PUBLIC "-non_shared")
-endif()
diff --git a/Tests/GhsMultiDuplicateSourceFilenames/main.c b/Tests/GhsMultiDuplicateSourceFilenames/main.c
deleted file mode 100644
index d5b791409..000000000
--- a/Tests/GhsMultiDuplicateSourceFilenames/main.c
+++ /dev/null
@@ -1,13 +0,0 @@
-int test_a(void);
-int test_b(void);
-int test_c(void);
-int test_d(void);
-
-int main(int argc, char* argv[])
-{
- test_a();
- test_b();
- test_c();
- test_d();
- return 0;
-}
diff --git a/Tests/GhsMultiDuplicateSourceFilenames/subfolder/test.c b/Tests/GhsMultiDuplicateSourceFilenames/subfolder/test.c
deleted file mode 100644
index e1e175921..000000000
--- a/Tests/GhsMultiDuplicateSourceFilenames/subfolder/test.c
+++ /dev/null
@@ -1,5 +0,0 @@
-
-int test_b()
-{
- return 2;
-}
diff --git a/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test.c b/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test.c
deleted file mode 100644
index c552e6a13..000000000
--- a/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test.c
+++ /dev/null
@@ -1,5 +0,0 @@
-
-int test_c()
-{
- return 1;
-}
diff --git a/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c b/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c
deleted file mode 100644
index 170b33d2c..000000000
--- a/Tests/GhsMultiDuplicateSourceFilenames/subfolder_test_0.c
+++ /dev/null
@@ -1,5 +0,0 @@
-
-int test_d()
-{
- return 1;
-}
diff --git a/Tests/GhsMultiDuplicateSourceFilenames/test.c b/Tests/GhsMultiDuplicateSourceFilenames/test.c
deleted file mode 100644
index 5ffcbdf72..000000000
--- a/Tests/GhsMultiDuplicateSourceFilenames/test.c
+++ /dev/null
@@ -1,5 +0,0 @@
-
-int test_a()
-{
- return 1;
-}
diff --git a/Tests/GoogleTest/Test/CMakeLists.txt b/Tests/GoogleTest/Test/CMakeLists.txt
index f798d313c..baf00d53f 100644
--- a/Tests/GoogleTest/Test/CMakeLists.txt
+++ b/Tests/GoogleTest/Test/CMakeLists.txt
@@ -44,12 +44,13 @@ endif()
set_tests_properties(set2.GoogleTest.ConditionalFail.foo PROPERTIES WILL_FAIL YES)
-# Search specific sources to get the test list
-add_executable(test_gtest2 main2.cxx)
+# Search specific sources to get the test list. Include an empty file
+# to ensure they are handled correctly too.
+add_executable(test_gtest2 main2.cxx empty.cxx)
target_link_libraries(test_gtest2 GTest::Main)
gtest_add_tests(TARGET test_gtest2
TEST_LIST testList
- SOURCES main2.h
+ SOURCES main2.h empty.cxx
)
set(expectedTests
GoogleTest.SomethingElse
diff --git a/Tests/GoogleTest/Test/empty.cxx b/Tests/GoogleTest/Test/empty.cxx
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/GoogleTest/Test/empty.cxx
diff --git a/Tests/GoogleTest/Test/main1.cxx b/Tests/GoogleTest/Test/main1.cxx
index 03d604b91..c353d9146 100644
--- a/Tests/GoogleTest/Test/main1.cxx
+++ b/Tests/GoogleTest/Test/main1.cxx
@@ -1,7 +1,7 @@
-#include <gtest/gtest.h>
-
#include <string>
+#include <gtest/gtest.h>
+
namespace {
bool shouldFail = false;
}
diff --git a/Tests/IPO/CMakeLists.txt b/Tests/IPO/CMakeLists.txt
deleted file mode 100644
index 6dabf86bb..000000000
--- a/Tests/IPO/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-cmake_minimum_required (VERSION 2.8)
-project(IPO NONE)
-
-set_property(DIRECTORY PROPERTY INTERPROCEDURAL_OPTIMIZATION 1)
-
-add_subdirectory(../COnly COnly)
-add_subdirectory(../CxxOnly CxxOnly)
diff --git a/Tests/ImportedSameName/A/CMakeLists.txt b/Tests/ImportedSameName/A/CMakeLists.txt
new file mode 100644
index 000000000..0a31b40e2
--- /dev/null
+++ b/Tests/ImportedSameName/A/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_library(a STATIC a.c)
+target_compile_definitions(a INTERFACE DEF_A)
+
+add_library(sameName INTERFACE IMPORTED)
+target_link_libraries(sameName INTERFACE a)
+
+add_library(ifaceA INTERFACE)
+target_link_libraries(ifaceA INTERFACE sameName)
diff --git a/Tests/ImportedSameName/A/a.c b/Tests/ImportedSameName/A/a.c
new file mode 100644
index 000000000..4ef36980e
--- /dev/null
+++ b/Tests/ImportedSameName/A/a.c
@@ -0,0 +1,3 @@
+void a(void)
+{
+}
diff --git a/Tests/ImportedSameName/B/CMakeLists.txt b/Tests/ImportedSameName/B/CMakeLists.txt
new file mode 100644
index 000000000..d93032626
--- /dev/null
+++ b/Tests/ImportedSameName/B/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_library(b STATIC b.c)
+target_compile_definitions(b INTERFACE DEF_B)
+
+add_library(sameName INTERFACE IMPORTED)
+target_link_libraries(sameName INTERFACE b)
+
+add_library(ifaceB INTERFACE)
+target_link_libraries(ifaceB INTERFACE sameName)
diff --git a/Tests/ImportedSameName/B/b.c b/Tests/ImportedSameName/B/b.c
new file mode 100644
index 000000000..c7c7df458
--- /dev/null
+++ b/Tests/ImportedSameName/B/b.c
@@ -0,0 +1,3 @@
+void b(void)
+{
+}
diff --git a/Tests/ImportedSameName/CMakeLists.txt b/Tests/ImportedSameName/CMakeLists.txt
new file mode 100644
index 000000000..4292c123f
--- /dev/null
+++ b/Tests/ImportedSameName/CMakeLists.txt
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.12)
+project(ImportedSameName C)
+
+add_subdirectory(A)
+add_subdirectory(B)
+
+add_executable(ImportedSameName main.c)
+target_link_libraries(ImportedSameName PRIVATE ifaceA ifaceB)
diff --git a/Tests/ImportedSameName/main.c b/Tests/ImportedSameName/main.c
new file mode 100644
index 000000000..a0cb27fee
--- /dev/null
+++ b/Tests/ImportedSameName/main.c
@@ -0,0 +1,16 @@
+#ifndef DEF_A
+# error "DEF_A not defined"
+#endif
+#ifndef DEF_B
+# error "DEF_B not defined"
+#endif
+
+extern void a(void);
+extern void b(void);
+
+int main(void)
+{
+ a();
+ b();
+ return 0;
+}
diff --git a/Tests/IncludeDirectories/CMP0021/main.cpp b/Tests/IncludeDirectories/CMP0021/main.cpp
index f638ed14a..0f87dd997 100644
--- a/Tests/IncludeDirectories/CMP0021/main.cpp
+++ b/Tests/IncludeDirectories/CMP0021/main.cpp
@@ -2,7 +2,7 @@
#include "cmp0021.h"
#ifndef CMP0021_DEFINE
-#error Expected CMP0021_DEFINE
+# error Expected CMP0021_DEFINE
#endif
int main(int, char**)
diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt
index db18462a8..761c405b1 100644
--- a/Tests/IncludeDirectories/CMakeLists.txt
+++ b/Tests/IncludeDirectories/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6)
project(IncludeDirectories)
if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4)
- OR CMAKE_C_COMPILER_ID STREQUAL Clang OR CMAKE_C_COMPILER_ID STREQUAL AppleClang)
+ OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR CMAKE_C_COMPILER_ID STREQUAL AppleClang)
AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles"
OR CMAKE_GENERATOR STREQUAL "Ninja"
OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0)))
@@ -65,6 +65,10 @@ else()
PROPERTIES COMPILE_FLAGS "-ITarProp")
endif()
+add_library(ordertest ordertest.cpp)
+target_include_directories(ordertest SYSTEM PUBLIC SystemIncludeDirectories/systemlib)
+target_include_directories(ordertest PUBLIC SystemIncludeDirectories/userlib)
+
add_subdirectory(StandardIncludeDirectories)
add_subdirectory(TargetIncludeDirectories)
diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt
index 5078f3099..20bd60196 100644
--- a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt
+++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt
@@ -32,7 +32,9 @@ target_link_libraries(consumer upstream config_specific)
target_compile_options(consumer PRIVATE -Werror=unused-variable)
add_library(iface IMPORTED INTERFACE)
-set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/systemlib_header_only")
+set_property(TARGET iface PROPERTY INTERFACE_INCLUDE_DIRECTORIES
+ "$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/systemlib_header_only>"
+ )
add_library(imported_consumer imported_consumer.cpp)
target_link_libraries(imported_consumer iface)
diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp b/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp
index be18ebf52..a13f08fdc 100644
--- a/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp
+++ b/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp
@@ -1,7 +1,6 @@
-#include "upstream.h"
-
#include "config_iface.h"
+#include "upstream.h"
int consumer()
{
diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/ordertest.h b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/ordertest.h
new file mode 100644
index 000000000..28915e6ba
--- /dev/null
+++ b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/ordertest.h
@@ -0,0 +1 @@
+#error ordertest.h includes from systemlib
diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/userlib/ordertest.h b/Tests/IncludeDirectories/SystemIncludeDirectories/userlib/ordertest.h
new file mode 100644
index 000000000..fa882cb5b
--- /dev/null
+++ b/Tests/IncludeDirectories/SystemIncludeDirectories/userlib/ordertest.h
@@ -0,0 +1 @@
+/* empty file */
diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt
index 5b99ea7b3..a9edf9a97 100644
--- a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt
+++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt
@@ -17,7 +17,8 @@ create_header(bing)
create_header(bung)
create_header(arguments)
create_header(list)
-create_header(target)
+create_header(target1)
+create_header(target2)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -69,14 +70,23 @@ set_property(TARGET lib4 APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BI
set_property(TARGET lib4 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/foh;$<TARGET_PROPERTY:lib3,INTERFACE_INCLUDE_DIRECTORIES>")
add_library(somelib::withcolons UNKNOWN IMPORTED)
-set_property(TARGET somelib::withcolons PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/target")
-set_property(TARGET somelib::withcolons PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/target")
+set_property(TARGET somelib::withcolons PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/target1")
+set_property(TARGET somelib::withcolons PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/target1")
set_property(TARGET TargetIncludeDirectories
APPEND PROPERTY INCLUDE_DIRECTORIES
"$<TARGET_PROPERTY:somelib::withcolons,INTERFACE_INCLUDE_DIRECTORIES>"
)
+add_library(somelib_aliased UNKNOWN IMPORTED GLOBAL)
+set_property(TARGET somelib_aliased PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/target2")
+add_library(somelib::withcolons2 ALIAS somelib_aliased)
+
+set_property(TARGET TargetIncludeDirectories
+ APPEND PROPERTY INCLUDE_DIRECTORIES
+ "$<TARGET_PROPERTY:somelib::withcolons2,INTERFACE_INCLUDE_DIRECTORIES>"
+)
+
add_custom_target(test_custom_target
"some_bogus_custom_tool"
$<TARGET_PROPERTY:TargetIncludeDirectories,COMPILE_DEFINITIONS>
diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp
index 2ee05e2ee..541ef92c2 100644
--- a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp
+++ b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp
@@ -10,7 +10,8 @@
#include "foo.h"
#include "list.h"
#include "prefix_foo_bar_bat.h"
-#include "target.h"
+#include "target1.h"
+#include "target2.h"
#include "ting.h"
int main(int, char**)
diff --git a/Tests/IncludeDirectories/ordertest.cpp b/Tests/IncludeDirectories/ordertest.cpp
new file mode 100644
index 000000000..7e24f770f
--- /dev/null
+++ b/Tests/IncludeDirectories/ordertest.cpp
@@ -0,0 +1 @@
+#include "ordertest.h"
diff --git a/Tests/IncludeDirectoriesCPATH/CMakeLists.txt b/Tests/IncludeDirectoriesCPATH/CMakeLists.txt
new file mode 100644
index 000000000..31cbc3680
--- /dev/null
+++ b/Tests/IncludeDirectoriesCPATH/CMakeLists.txt
@@ -0,0 +1,22 @@
+cmake_minimum_required (VERSION 3.14)
+project(IncludeDirectoriesCPATH CXX)
+message(STATUS "ENV{CPATH}: '$ENV{CPATH}'")
+message(STATUS "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES: '${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}'")
+
+include(CheckCXXCompilerFlag)
+check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test)
+if(run_sys_includes_test)
+ # The Bullseye wrapper appears to break the -isystem effect.
+ execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE out ERROR_VARIABLE out)
+ if("x${out}" MATCHES "Bullseye")
+ set(run_sys_includes_test 0)
+ endif()
+endif()
+if (NOT run_sys_includes_test)
+ return()
+endif()
+
+add_library(consumer consumer.cpp)
+add_library(consumer_system consumer.cpp)
+target_compile_options(consumer_system PRIVATE -Werror=unused-variable)
+target_include_directories(consumer_system SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/viacpath")
diff --git a/Tests/IncludeDirectoriesCPATH/consumer.cpp b/Tests/IncludeDirectoriesCPATH/consumer.cpp
new file mode 100644
index 000000000..59608dada
--- /dev/null
+++ b/Tests/IncludeDirectoriesCPATH/consumer.cpp
@@ -0,0 +1,6 @@
+#include "systemlib.h"
+
+int consumer()
+{
+ return systemlib();
+}
diff --git a/Tests/IncludeDirectoriesCPATH/viacpath/systemlib.h b/Tests/IncludeDirectoriesCPATH/viacpath/systemlib.h
new file mode 100644
index 000000000..1aaafa9f4
--- /dev/null
+++ b/Tests/IncludeDirectoriesCPATH/viacpath/systemlib.h
@@ -0,0 +1,15 @@
+#ifndef SYSTEMLIB_H
+#define SYSTEMLIB_H
+
+int systemlib()
+{
+ return 0;
+}
+
+int unusedFunc()
+{
+ int unused;
+ return systemlib();
+}
+
+#endif
diff --git a/Tests/InterfaceLibrary/CMakeLists.txt b/Tests/InterfaceLibrary/CMakeLists.txt
index 33c4b9073..954c02d51 100644
--- a/Tests/InterfaceLibrary/CMakeLists.txt
+++ b/Tests/InterfaceLibrary/CMakeLists.txt
@@ -31,6 +31,7 @@ add_library(item_real STATIC item.cpp)
add_library(item_iface INTERFACE IMPORTED)
set_property(TARGET item_iface PROPERTY IMPORTED_LIBNAME item_real)
add_dependencies(item_iface item_real)
+get_property(item_iface_dependencies TARGET item_iface PROPERTY MANUALLY_ADDED_DEPENDENCIES)
link_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(InterfaceLibrary definetestexe.cpp)
@@ -46,6 +47,7 @@ target_link_libraries(InterfaceLibrary
add_dependencies(InterfaceLibrary item_fake_tgt)
add_subdirectory(libsdir)
+add_subdirectory(excluded EXCLUDE_FROM_ALL)
add_executable(sharedlibtestexe sharedlibtestexe.cpp)
target_link_libraries(sharedlibtestexe shared_iface imported::iface)
@@ -64,7 +66,6 @@ target_link_libraries(iface_whitelist INTERFACE $<$<BOOL:$<TARGET_PROPERTY:CUSTO
add_executable(exec_whitelist dummy.cpp)
target_link_libraries(exec_whitelist iface_whitelist)
-set(CMAKE_NO_SYSTEM_FROM_IMPORTED 1)
add_library(iface_imported INTERFACE IMPORTED)
set_property(TARGET iface_imported PROPERTY
INTERFACE_COMPILE_DEFINITIONS
diff --git a/Tests/InterfaceLibrary/definetestexe.cpp b/Tests/InterfaceLibrary/definetestexe.cpp
index 098502c4c..9156426cd 100644
--- a/Tests/InterfaceLibrary/definetestexe.cpp
+++ b/Tests/InterfaceLibrary/definetestexe.cpp
@@ -1,18 +1,18 @@
#ifndef IFACE_DEFINE
-#error Expected IFACE_DEFINE
+# error Expected IFACE_DEFINE
#endif
#include "iface_header.h"
#ifndef IFACE_HEADER_SRCDIR
-#error Expected IFACE_HEADER_SRCDIR
+# error Expected IFACE_HEADER_SRCDIR
#endif
#include "iface_header_builddir.h"
#ifndef IFACE_HEADER_BUILDDIR
-#error Expected IFACE_HEADER_BUILDDIR
+# error Expected IFACE_HEADER_BUILDDIR
#endif
extern int obj();
diff --git a/Tests/InterfaceLibrary/excluded/CMakeLists.txt b/Tests/InterfaceLibrary/excluded/CMakeLists.txt
new file mode 100644
index 000000000..69a6807c9
--- /dev/null
+++ b/Tests/InterfaceLibrary/excluded/CMakeLists.txt
@@ -0,0 +1 @@
+add_library(excluded_iface INTERFACE)
diff --git a/Tests/InterfaceLibrary/libsdir/sharedlib/sharedlib.h b/Tests/InterfaceLibrary/libsdir/sharedlib/sharedlib.h
index 5b3c7db73..3e1894138 100644
--- a/Tests/InterfaceLibrary/libsdir/sharedlib/sharedlib.h
+++ b/Tests/InterfaceLibrary/libsdir/sharedlib/sharedlib.h
@@ -2,9 +2,8 @@
#ifndef SHAREDLIB_H
#define SHAREDLIB_H
-#include "sharedlib_export.h"
-
#include "shareddependlib.h"
+#include "sharedlib_export.h"
struct SHAREDLIB_EXPORT SharedLibObject
{
diff --git a/Tests/InterfaceLibrary/map_config.cpp b/Tests/InterfaceLibrary/map_config.cpp
index 232a18e88..d0356327d 100644
--- a/Tests/InterfaceLibrary/map_config.cpp
+++ b/Tests/InterfaceLibrary/map_config.cpp
@@ -1,12 +1,12 @@
#ifdef DEBUG_MODE
-#ifndef SPECIAL_MODE
-#error Special configuration should be mapped to debug configuration.
-#endif
+# ifndef SPECIAL_MODE
+# error Special configuration should be mapped to debug configuration.
+# endif
#else
-#ifdef SPECIAL_MODE
-#error Special configuration should not be enabled if not debug configuration
-#endif
+# ifdef SPECIAL_MODE
+# error Special configuration should not be enabled if not debug configuration
+# endif
#endif
int main(int, char**)
diff --git a/Tests/InterfaceLibrary/sharedlibtestexe.cpp b/Tests/InterfaceLibrary/sharedlibtestexe.cpp
index 44f160da8..97b5aa900 100644
--- a/Tests/InterfaceLibrary/sharedlibtestexe.cpp
+++ b/Tests/InterfaceLibrary/sharedlibtestexe.cpp
@@ -1,14 +1,14 @@
#ifndef SHAREDLIB_DEFINE
-#error Expected SHAREDLIB_DEFINE
+# error Expected SHAREDLIB_DEFINE
#endif
#ifndef SHAREDDEPENDLIB_DEFINE
-#error Expected SHAREDDEPENDLIB_DEFINE
+# error Expected SHAREDDEPENDLIB_DEFINE
#endif
-#include "sharedlib.h"
#include "shareddependlib.h"
+#include "sharedlib.h"
int main(int, char**)
{
diff --git a/Tests/InterfaceLinkLibraries/bang.cpp b/Tests/InterfaceLinkLibraries/bang.cpp
index 2e950986b..722af9f18 100644
--- a/Tests/InterfaceLinkLibraries/bang.cpp
+++ b/Tests/InterfaceLinkLibraries/bang.cpp
@@ -1,10 +1,10 @@
#ifdef FOO_LIBRARY
-#error Unexpected FOO_LIBRARY
+# error Unexpected FOO_LIBRARY
#endif
#ifdef BAR_LIBRARY
-#error Unexpected BAR_LIBRARY
+# error Unexpected BAR_LIBRARY
#endif
#include "bang.h"
diff --git a/Tests/InterfaceLinkLibraries/bar.cpp b/Tests/InterfaceLinkLibraries/bar.cpp
index 228ed803a..c1d95ab6e 100644
--- a/Tests/InterfaceLinkLibraries/bar.cpp
+++ b/Tests/InterfaceLinkLibraries/bar.cpp
@@ -1,17 +1,17 @@
#ifdef FOO_LIBRARY
-#error Unexpected FOO_LIBRARY
+# error Unexpected FOO_LIBRARY
#endif
#ifdef BAR_USE_BANG
-#ifndef BANG_LIBRARY
-#error Expected BANG_LIBRARY
-#endif
-#include "bang.h"
+# ifndef BANG_LIBRARY
+# error Expected BANG_LIBRARY
+# endif
+# include "bang.h"
#else
-#ifdef BANG_LIBRARY
-#error Unexpected BANG_LIBRARY
-#endif
+# ifdef BANG_LIBRARY
+# error Unexpected BANG_LIBRARY
+# endif
#endif
#include "bar.h"
diff --git a/Tests/InterfaceLinkLibraries/foo.cpp b/Tests/InterfaceLinkLibraries/foo.cpp
index 5295707b5..c1e93e849 100644
--- a/Tests/InterfaceLinkLibraries/foo.cpp
+++ b/Tests/InterfaceLinkLibraries/foo.cpp
@@ -1,10 +1,10 @@
#ifdef BAR_LIBRARY
-#error Unexpected BAR_LIBRARY
+# error Unexpected BAR_LIBRARY
#endif
#ifdef BANG_LIBRARY
-#error Unexpected BANG_LIBRARY
+# error Unexpected BANG_LIBRARY
#endif
#include "foo.h"
diff --git a/Tests/InterfaceLinkLibraries/main.cpp b/Tests/InterfaceLinkLibraries/main.cpp
index 6e1295a10..e8298d41c 100644
--- a/Tests/InterfaceLinkLibraries/main.cpp
+++ b/Tests/InterfaceLinkLibraries/main.cpp
@@ -1,18 +1,18 @@
#ifndef FOO_LIBRARY
-#error Expected FOO_LIBRARY
+# error Expected FOO_LIBRARY
#endif
#ifndef BAR_LIBRARY
-#error Expected BAR_LIBRARY
+# error Expected BAR_LIBRARY
#endif
#ifdef BANG_LIBRARY
-#error Unexpected BANG_LIBRARY
+# error Unexpected BANG_LIBRARY
#endif
#ifdef ZOT_LIBRARY
-#error Unexpected ZOT_LIBRARY
+# error Unexpected ZOT_LIBRARY
#endif
#include "zot.h"
diff --git a/Tests/Java/CMakeLists.txt b/Tests/Java/CMakeLists.txt
index e1bcf3c20..aea4282e7 100644
--- a/Tests/Java/CMakeLists.txt
+++ b/Tests/Java/CMakeLists.txt
@@ -3,6 +3,8 @@ project(hello Java)
cmake_minimum_required (VERSION 2.6)
set(CMAKE_VERBOSE_MAKEFILE 1)
+include(CTest)
+
find_package(Java COMPONENTS Development)
include (UseJava)
@@ -11,3 +13,13 @@ add_jar(hello A.java HelloWorld.java)
# use listing file to specify sources
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/java_fileslist "A.java\nHelloWorld.java\n")
add_jar(hello2 @${CMAKE_CURRENT_BINARY_DIR}/java_fileslist)
+
+# use listing file to specify sources and specify output directory (issue #17316)
+add_jar(hello3 @${CMAKE_CURRENT_BINARY_DIR}/java_fileslist OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/hello3")
+
+add_test (NAME Java.Jar
+ COMMAND "${Java_JAVA_EXECUTABLE}" -classpath hello.jar HelloWorld)
+add_test (NAME Java.JarSourceList
+ COMMAND "${Java_JAVA_EXECUTABLE}" -classpath hello2.jar HelloWorld)
+add_test (NAME Java.JarSourceListAndOutput
+ COMMAND "${Java_JAVA_EXECUTABLE}" -classpath "${CMAKE_CURRENT_BINARY_DIR}/hello3/hello3.jar" HelloWorld)
diff --git a/Tests/JavaExportImport/CMakeLists.txt b/Tests/JavaExportImport/CMakeLists.txt
index a075301f9..c70704a04 100644
--- a/Tests/JavaExportImport/CMakeLists.txt
+++ b/Tests/JavaExportImport/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.5)
+cmake_minimum_required (VERSION 3.9)
project(JavaExportImport)
if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
@@ -17,7 +17,8 @@ set_property(
PROPERTY SYMBOLIC 1
)
-if(CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}")
else()
if(CMAKE_BUILD_TYPE)
diff --git a/Tests/JavaJavah/B.cpp b/Tests/JavaJavah/B.cpp
index 491107efb..86d8aa869 100644
--- a/Tests/JavaJavah/B.cpp
+++ b/Tests/JavaJavah/B.cpp
@@ -1,9 +1,9 @@
+#include "B.h"
+
#include <jni.h>
#include <stdio.h>
-#include "B.h"
-
JNIEXPORT void JNICALL Java_B_printName(JNIEnv*, jobject)
{
printf("B\n");
diff --git a/Tests/JavaJavah/C.cpp b/Tests/JavaJavah/C.cpp
index 0a3178f95..569eab54a 100644
--- a/Tests/JavaJavah/C.cpp
+++ b/Tests/JavaJavah/C.cpp
@@ -1,9 +1,9 @@
+#include "C.h"
+
#include <jni.h>
#include <stdio.h>
-#include "C.h"
-
JNIEXPORT void JNICALL Java_C_printName(JNIEnv*, jobject)
{
printf("C\n");
diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt
index 071bf20d6..77c292a32 100644
--- a/Tests/JavaJavah/CMakeLists.txt
+++ b/Tests/JavaJavah/CMakeLists.txt
@@ -3,6 +3,8 @@ project(helloJavah Java CXX)
cmake_minimum_required (VERSION 2.6)
set(CMAKE_VERBOSE_MAKEFILE 1)
+include(CTest)
+
find_package(Java COMPONENTS Development)
include (UseJava)
@@ -21,3 +23,6 @@ add_dependencies(B B_javah)
target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
${JAVA_INCLUDE_PATH}
${JAVA_INCLUDE_PATH2})
+
+add_test (NAME Java.Javah
+ COMMAND "${Java_JAVA_EXECUTABLE}" -Djava.library.path=$<TARGET_FILE_DIR:B> -classpath hello3.jar HelloWorld2)
diff --git a/Tests/JavaNativeHeaders/CMakeLists.txt b/Tests/JavaNativeHeaders/CMakeLists.txt
new file mode 100644
index 000000000..2023d25f9
--- /dev/null
+++ b/Tests/JavaNativeHeaders/CMakeLists.txt
@@ -0,0 +1,24 @@
+project(helloJavaNativeHeaders Java CXX)
+
+cmake_minimum_required (VERSION 2.6)
+set(CMAKE_VERBOSE_MAKEFILE 1)
+
+include (CTest)
+
+find_package(Java COMPONENTS Development)
+include (UseJava)
+
+# JNI support
+find_package(JNI)
+
+add_jar(B1 D.java GENERATE_NATIVE_HEADERS D1-native)
+add_jar(E1 E.java GENERATE_NATIVE_HEADERS E1-native)
+
+add_jar(hello4 HelloWorld3.java)
+
+add_library(D SHARED D.cpp E.cpp)
+target_link_libraries (D PRIVATE D1-native E1-native)
+
+
+add_test (NAME Java.NativeHeaders
+ COMMAND "${Java_JAVA_EXECUTABLE}" -Djava.library.path=$<TARGET_FILE_DIR:D> -classpath hello4.jar HelloWorld3)
diff --git a/Tests/JavaNativeHeaders/D.cpp b/Tests/JavaNativeHeaders/D.cpp
new file mode 100644
index 000000000..018386c23
--- /dev/null
+++ b/Tests/JavaNativeHeaders/D.cpp
@@ -0,0 +1,10 @@
+
+#include "D.h"
+
+#include <jni.h>
+#include <stdio.h>
+
+JNIEXPORT void JNICALL Java_D_printName(JNIEnv*, jobject)
+{
+ printf("D\n");
+}
diff --git a/Tests/JavaNativeHeaders/D.java b/Tests/JavaNativeHeaders/D.java
new file mode 100644
index 000000000..449c0df2d
--- /dev/null
+++ b/Tests/JavaNativeHeaders/D.java
@@ -0,0 +1,19 @@
+class D
+{
+ public D()
+ {
+ }
+
+ public native void printName();
+
+ static {
+ try {
+
+ System.loadLibrary("D");
+
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load.\n" + e);
+ System.exit(1);
+ }
+ }
+}
diff --git a/Tests/JavaNativeHeaders/E.cpp b/Tests/JavaNativeHeaders/E.cpp
new file mode 100644
index 000000000..3a8e0acff
--- /dev/null
+++ b/Tests/JavaNativeHeaders/E.cpp
@@ -0,0 +1,10 @@
+
+#include "E.h"
+
+#include <jni.h>
+#include <stdio.h>
+
+JNIEXPORT void JNICALL Java_E_printName(JNIEnv*, jobject)
+{
+ printf("E\n");
+}
diff --git a/Tests/JavaNativeHeaders/E.java b/Tests/JavaNativeHeaders/E.java
new file mode 100644
index 000000000..30fd95aef
--- /dev/null
+++ b/Tests/JavaNativeHeaders/E.java
@@ -0,0 +1,19 @@
+class E
+{
+ public E()
+ {
+ }
+
+ public native void printName();
+
+ static {
+ try {
+
+ System.loadLibrary("D");
+
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load.\n" + e);
+ System.exit(1);
+ }
+ }
+}
diff --git a/Tests/JavaNativeHeaders/HelloWorld3.java b/Tests/JavaNativeHeaders/HelloWorld3.java
new file mode 100644
index 000000000..77f1fedd9
--- /dev/null
+++ b/Tests/JavaNativeHeaders/HelloWorld3.java
@@ -0,0 +1,15 @@
+class HelloWorld3
+{
+ public static void main(String args[])
+ {
+ D d;
+ d = new D();
+ d.printName();
+
+ E e;
+ e = new E();
+ e.printName();
+
+ System.out.println("Hello World!");
+ }
+}
diff --git a/Tests/Jump/Executable/jumpExecutable.cxx b/Tests/Jump/Executable/jumpExecutable.cxx
index 6fa268377..2c5961c5d 100644
--- a/Tests/Jump/Executable/jumpExecutable.cxx
+++ b/Tests/Jump/Executable/jumpExecutable.cxx
@@ -1,7 +1,7 @@
#ifdef _WIN32
-#define JUMP_IMPORT __declspec(dllimport)
+# define JUMP_IMPORT __declspec(dllimport)
#else
-#define JUMP_IMPORT extern
+# define JUMP_IMPORT extern
#endif
extern int jumpStatic();
diff --git a/Tests/Jump/Library/Shared/jumpShared.cxx b/Tests/Jump/Library/Shared/jumpShared.cxx
index 7c4dee9a8..87484b795 100644
--- a/Tests/Jump/Library/Shared/jumpShared.cxx
+++ b/Tests/Jump/Library/Shared/jumpShared.cxx
@@ -1,7 +1,7 @@
#ifdef _WIN32
-#define JUMP_EXPORT __declspec(dllexport)
+# define JUMP_EXPORT __declspec(dllexport)
#else
-#define JUMP_EXPORT
+# define JUMP_EXPORT
#endif
JUMP_EXPORT int jumpShared()
diff --git a/Tests/LinkDirectory/External/CMakeLists.txt b/Tests/LinkDirectory/External/CMakeLists.txt
index f7c840f9a..d2a1f9f77 100644
--- a/Tests/LinkDirectory/External/CMakeLists.txt
+++ b/Tests/LinkDirectory/External/CMakeLists.txt
@@ -1,6 +1,20 @@
cmake_minimum_required(VERSION 2.8)
project(LinkDirectoryExternal C)
+
+add_executable(myexe2 myexe.c)
+set_property(TARGET myexe2 PROPERTY OUTPUT_NAME LinkDirectory2)
+target_link_directories(myexe2 PRIVATE lib "${CMAKE_CURRENT_SOURCE_DIR}/../lib")
+target_link_libraries(myexe2 PRIVATE mylibA mylibB)
+
+add_library (mylibs INTERFACE)
+target_link_directories(mylibs INTERFACE lib "${CMAKE_CURRENT_SOURCE_DIR}/../lib")
+target_link_libraries(mylibs INTERFACE mylibA mylibB)
+add_executable(myexe3 myexe.c)
+set_property(TARGET myexe3 PROPERTY OUTPUT_NAME LinkDirectory3)
+target_link_libraries(myexe3 PRIVATE mylibs)
+
+
# Test CMP0015 OLD behavior: -L../lib
cmake_policy(SET CMP0015 OLD)
link_directories(../lib)
diff --git a/Tests/LinkFlags/LinkFlagsExe.c b/Tests/LinkFlags/LinkFlagsExe.c
index 4d441469f..202d34d26 100644
--- a/Tests/LinkFlags/LinkFlagsExe.c
+++ b/Tests/LinkFlags/LinkFlagsExe.c
@@ -5,5 +5,5 @@ int main(void)
/* Intel compiler does not reject bad flags or objects! */
#if defined(__INTEL_COMPILER)
-#error BADFLAG
+# error BADFLAG
#endif
diff --git a/Tests/LinkFlags/LinkFlagsLib.c b/Tests/LinkFlags/LinkFlagsLib.c
index f35420666..bd288e908 100644
--- a/Tests/LinkFlags/LinkFlagsLib.c
+++ b/Tests/LinkFlags/LinkFlagsLib.c
@@ -5,5 +5,5 @@ int flags_lib(void)
/* Intel compiler does not reject bad flags or objects! */
#if defined(__INTEL_COMPILER)
-#error BADFLAG
+# error BADFLAG
#endif
diff --git a/Tests/LoadCommand/CMakeCommands/cmTestCommand.c b/Tests/LoadCommand/CMakeCommands/cmTestCommand.c
index 3558f894b..99f0de925 100644
--- a/Tests/LoadCommand/CMakeCommands/cmTestCommand.c
+++ b/Tests/LoadCommand/CMakeCommands/cmTestCommand.c
@@ -1,8 +1,9 @@
-#include "cmCPluginAPI.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "cmCPluginAPI.h"
+
typedef struct
{
char* LibraryName;
diff --git a/Tests/LoadCommand/CMakeLists.txt b/Tests/LoadCommand/CMakeLists.txt
index 03a3b4942..cfaebade4 100644
--- a/Tests/LoadCommand/CMakeLists.txt
+++ b/Tests/LoadCommand/CMakeLists.txt
@@ -22,13 +22,6 @@ else()
${LoadCommand_SOURCE_DIR}/CMakeCommands
CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
OUTPUT_VARIABLE OUTPUT )
-# do another TRY_COMPILE to get around make
-# problem on hp
- try_compile(COMPILE_OK
- ${LoadCommand_BINARY_DIR}/CMakeCommands
- ${LoadCommand_SOURCE_DIR}/CMakeCommands
- CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
- OUTPUT_VARIABLE OUTPUT )
endif()
message("Output from try compile: ${OUTPUT}")
diff --git a/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c b/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c
index 3558f894b..99f0de925 100644
--- a/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c
+++ b/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c
@@ -1,8 +1,9 @@
-#include "cmCPluginAPI.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "cmCPluginAPI.h"
+
typedef struct
{
char* LibraryName;
diff --git a/Tests/LoadCommandOneConfig/CMakeLists.txt b/Tests/LoadCommandOneConfig/CMakeLists.txt
index 6affd343f..65de04230 100644
--- a/Tests/LoadCommandOneConfig/CMakeLists.txt
+++ b/Tests/LoadCommandOneConfig/CMakeLists.txt
@@ -28,13 +28,6 @@ else()
${LoadCommand_SOURCE_DIR}/CMakeCommands
CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
OUTPUT_VARIABLE OUTPUT )
-# do another TRY_COMPILE to get around make
-# problem on hp
- try_compile(COMPILE_OK
- ${LoadCommand_BINARY_DIR}/CMakeCommands
- ${LoadCommand_SOURCE_DIR}/CMakeCommands
- CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
- OUTPUT_VARIABLE OUTPUT )
endif()
message("Output from try compile: ${OUTPUT}")
diff --git a/Tests/MFC/CMakeLists.txt.in b/Tests/MFC/CMakeLists.txt.in
index e6bfabd33..bf98e918c 100644
--- a/Tests/MFC/CMakeLists.txt.in
+++ b/Tests/MFC/CMakeLists.txt.in
@@ -45,6 +45,11 @@ set(files
set(CMAKE_MFC_FLAG "@CMAKE_MFC_FLAG_VALUE@")
+FIND_PACKAGE(MFC)
+IF (NOT MFC_FOUND)
+ MESSAGE(FATAL_ERROR "MFC Could not be found during the MFC test")
+ENDIF()
+
if("${CMAKE_MFC_FLAG}" STREQUAL "1")
msvc_link_to_static_crt()
else()
diff --git a/Tests/MFC/mfc1/.gitattributes b/Tests/MFC/mfc1/.gitattributes
deleted file mode 100644
index 59be5dcfb..000000000
--- a/Tests/MFC/mfc1/.gitattributes
+++ /dev/null
@@ -1,6 +0,0 @@
-.gitattributes export-ignore
-
-*.sln -crlf
-*.vcproj -crlf
-
-* -whitespace
diff --git a/Tests/MFC/mfc1/ChildFrm.cpp b/Tests/MFC/mfc1/ChildFrm.cpp
index ddb19c620..0422d2a9c 100644
--- a/Tests/MFC/mfc1/ChildFrm.cpp
+++ b/Tests/MFC/mfc1/ChildFrm.cpp
@@ -1,14 +1,16 @@
// ChildFrm.cpp : implementation of the CChildFrame class
//
+// clang-format off
#include "stdafx.h"
#include "mfc1.h"
#include "ChildFrm.h"
+// clang-format on
#ifdef _DEBUG
-#define new DEBUG_NEW
+# define new DEBUG_NEW
#endif
// CChildFrame
diff --git a/Tests/MFC/mfc1/MainFrm.cpp b/Tests/MFC/mfc1/MainFrm.cpp
index c5510657b..7f82e267f 100644
--- a/Tests/MFC/mfc1/MainFrm.cpp
+++ b/Tests/MFC/mfc1/MainFrm.cpp
@@ -1,14 +1,16 @@
// MainFrm.cpp : implementation of the CMainFrame class
//
+// clang-format off
#include "stdafx.h"
#include "mfc1.h"
#include "MainFrm.h"
+// clang-format on
#ifdef _DEBUG
-#define new DEBUG_NEW
+# define new DEBUG_NEW
#endif
// CMainFrame
@@ -21,7 +23,9 @@ END_MESSAGE_MAP()
static UINT indicators[] = {
ID_SEPARATOR, // status line indicator
- ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL,
+ ID_INDICATOR_CAPS,
+ ID_INDICATOR_NUM,
+ ID_INDICATOR_SCRL,
};
// CMainFrame construction/destruction
@@ -40,9 +44,10 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE |
- CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS |
- CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
+ if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT,
+ WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER |
+ CBRS_TOOLTIPS | CBRS_FLYBY |
+ CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) {
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
diff --git a/Tests/MFC/mfc1/Resource.h b/Tests/MFC/mfc1/Resource.h
index 7184e3064..e3a04f11e 100644
--- a/Tests/MFC/mfc1/Resource.h
+++ b/Tests/MFC/mfc1/Resource.h
@@ -11,10 +11,10 @@
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 130
-#define _APS_NEXT_CONTROL_VALUE 1000
-#define _APS_NEXT_SYMED_VALUE 101
-#define _APS_NEXT_COMMAND_VALUE 32771
-#endif
+# ifndef APSTUDIO_READONLY_SYMBOLS
+# define _APS_NEXT_RESOURCE_VALUE 130
+# define _APS_NEXT_CONTROL_VALUE 1000
+# define _APS_NEXT_SYMED_VALUE 101
+# define _APS_NEXT_COMMAND_VALUE 32771
+# endif
#endif
diff --git a/Tests/MFC/mfc1/mfc1.cpp b/Tests/MFC/mfc1/mfc1.cpp
index 664c6c4ec..87406b641 100644
--- a/Tests/MFC/mfc1/mfc1.cpp
+++ b/Tests/MFC/mfc1/mfc1.cpp
@@ -1,6 +1,7 @@
// mfc1.cpp : Defines the class behaviors for the application.
//
+// clang-format off
#include "stdafx.h"
#include "MainFrm.h"
@@ -9,9 +10,10 @@
#include "ChildFrm.h"
#include "mfc1Doc.h"
#include "mfc1View.h"
+// clang-format on
#ifdef _DEBUG
-#define new DEBUG_NEW
+# define new DEBUG_NEW
#endif
// Cmfc1App
diff --git a/Tests/MFC/mfc1/mfc1.h b/Tests/MFC/mfc1/mfc1.h
index 15e970ba0..f4fcadb45 100644
--- a/Tests/MFC/mfc1/mfc1.h
+++ b/Tests/MFC/mfc1/mfc1.h
@@ -3,7 +3,7 @@
#pragma once
#ifndef __AFXWIN_H__
-#error include 'stdafx.h' before including this file for PCH
+# error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
diff --git a/Tests/MFC/mfc1/mfc1Doc.cpp b/Tests/MFC/mfc1/mfc1Doc.cpp
index 08ab1580a..ef8b6afd2 100644
--- a/Tests/MFC/mfc1/mfc1Doc.cpp
+++ b/Tests/MFC/mfc1/mfc1Doc.cpp
@@ -1,14 +1,16 @@
// mfc1Doc.cpp : implementation of the Cmfc1Doc class
//
+// clang-format off
#include "stdafx.h"
#include "mfc1.h"
#include "mfc1Doc.h"
+// clang-format on
#ifdef _DEBUG
-#define new DEBUG_NEW
+# define new DEBUG_NEW
#endif
// Cmfc1Doc
diff --git a/Tests/MFC/mfc1/mfc1View.cpp b/Tests/MFC/mfc1/mfc1View.cpp
index 6169ce524..55dcb8e42 100644
--- a/Tests/MFC/mfc1/mfc1View.cpp
+++ b/Tests/MFC/mfc1/mfc1View.cpp
@@ -1,15 +1,17 @@
// mfc1View.cpp : implementation of the Cmfc1View class
//
+// clang-format off
#include "stdafx.h"
#include "mfc1.h"
#include "mfc1Doc.h"
#include "mfc1View.h"
+// clang-format on
#ifdef _DEBUG
-#define new DEBUG_NEW
+# define new DEBUG_NEW
#endif
// Cmfc1View
diff --git a/Tests/MFC/mfc1/stdafx.h b/Tests/MFC/mfc1/stdafx.h
index 56f8a6ab4..b36908593 100644
--- a/Tests/MFC/mfc1/stdafx.h
+++ b/Tests/MFC/mfc1/stdafx.h
@@ -5,7 +5,7 @@
#pragma once
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+# define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
// See http://msdn.microsoft.com/en-us/library/6sehtctf.aspx for more info
@@ -17,39 +17,41 @@
// platforms.
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4
// or later.
-#if _MSC_VER < 1600
-#define WINVER \
- 0x0400 // Change this to the appropriate value to target Windows 98 and
- // Windows 2000 or later.
-#else
-#define WINVER 0x0501 // Target Windows XP and later with VS 10 and later
-#endif
+# if _MSC_VER < 1600
+# define WINVER \
+ 0x0400 // Change this to the appropriate value to target Windows 98 and
+ // Windows 2000 or later.
+# else
+# define WINVER 0x0501 // Target Windows XP and later with VS 10 and later
+# endif
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or
// later.
-#if _MSC_VER < 1600
-#define _WIN32_WINNT \
- 0x0400 // Change this to the appropriate value to target Windows 98 and
- // Windows 2000 or later.
-#else
-#define _WIN32_WINNT 0x0501 // Target Windows XP and later with VS 10 and later
-#endif
+# if _MSC_VER < 1600
+# define _WIN32_WINNT \
+ 0x0400 // Change this to the appropriate value to target Windows 98 and
+ // Windows 2000 or later.
+# else
+# define _WIN32_WINNT \
+ 0x0501 // Target Windows XP and later with VS 10 and later
+# endif
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or
// later.
-#if _MSC_VER < 1600
-#define _WIN32_WINDOWS \
- 0x0410 // Change this to the appropriate value to target Windows Me or later.
-#endif
+# if _MSC_VER < 1600
+# define _WIN32_WINDOWS \
+ 0x0410 // Change this to the appropriate value to target Windows Me or
+ // later.
+# endif
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
-#if _MSC_VER < 1600
-#define _WIN32_IE \
- 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
-#endif
+# if _MSC_VER < 1600
+# define _WIN32_IE \
+ 0x0400 // Change this to the appropriate value to target IE 5.0 or later.
+# endif
#endif
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be
@@ -59,11 +61,10 @@
// messages
#define _AFX_ALL_WARNINGS
-#include <afxdisp.h> // MFC Automation classes
-#include <afxext.h> // MFC extensions
-#include <afxwin.h> // MFC core and standard components
-
+#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
+#include <afxext.h> // MFC extensions
+#include <afxwin.h> // MFC core and standard components
#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h> // MFC support for Windows Common Controls
-#endif // _AFX_NO_AFXCMN_SUPPORT
+# include <afxcmn.h> // MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
diff --git a/Tests/MSVCRuntimeLibrary/CMakeLists.txt b/Tests/MSVCRuntimeLibrary/CMakeLists.txt
new file mode 100644
index 000000000..f7d9fec2e
--- /dev/null
+++ b/Tests/MSVCRuntimeLibrary/CMakeLists.txt
@@ -0,0 +1,71 @@
+cmake_minimum_required(VERSION 3.14)
+cmake_policy(SET CMP0091 NEW)
+project(MSVCRuntimeLibrary)
+
+if(CMake_TEST_CUDA)
+ enable_language(CUDA)
+endif()
+
+function(verify_combinations threads lang src)
+ set(verify_tc_config_ Release)
+ set(verify_tc_config_Debug Debug)
+ set(verify_def_MultiThreaded -DVERIFY_MT)
+ set(verify_def_Debug -DVERIFY_DEBUG)
+ set(verify_def_DLL -DVERIFY_DLL)
+ foreach(dbg "" Debug)
+ foreach(dll "" DLL)
+ # Construct the name of this runtime library combination.
+ set(rtl "${threads}${dbg}${dll}")
+
+ # Test that try_compile builds with this RTL.
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "${rtl}")
+ set(CMAKE_TRY_COMPILE_CONFIGURATION "${verify_tc_config_${dbg}}")
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
+ try_compile(${rtl}_COMPILES
+ ${CMAKE_CURRENT_BINARY_DIR}/try_compile/${rtl}
+ ${CMAKE_CURRENT_SOURCE_DIR}/${src}
+ COMPILE_DEFINITIONS ${verify_def_${threads}} ${verify_def_${dbg}} ${verify_def_${dll}}
+ OUTPUT_VARIABLE ${rtl}_OUTPUT
+ )
+ if(${rtl}_COMPILES)
+ message(STATUS "try_compile with ${rtl} worked")
+ else()
+ string(REPLACE "\n" "\n " ${rtl}_OUTPUT " ${${rtl}_OUTPUT}")
+ message(SEND_ERROR "try_compile with ${rtl} failed:\n${${rtl}_OUTPUT}")
+ endif()
+
+ # Test that targets build with this RTL.
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "$<$<BOOL:$<TARGET_PROPERTY:BOOL_TRUE>>:${rtl}>$<$<BOOL:$<TARGET_PROPERTY:BOOL_FALSE>>:BadContent>")
+ add_library(${rtl}-${lang} ${src})
+ set_property(TARGET ${rtl}-${lang} PROPERTY BOOL_TRUE TRUE)
+ target_compile_definitions(${rtl}-${lang} PRIVATE ${verify_def_${threads}} ${verify_def_${dbg}} ${verify_def_${dll}})
+ endforeach()
+ endforeach()
+endfunction()
+
+function(verify lang src)
+ add_library(default-${lang} ${src})
+ target_compile_definitions(default-${lang} PRIVATE VERIFY_MT VERIFY_DLL "$<$<CONFIG:Debug>:VERIFY_DEBUG>")
+
+ verify_combinations(MultiThreaded ${lang} ${src})
+
+ # Test known MSVC default behavior when no flag is given.
+ if(CMAKE_${lang}_COMPILER_ID STREQUAL "MSVC")
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "")
+ add_library(empty-${lang} ${src})
+ if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 14)
+ # VS 2005 and above default to multi-threaded.
+ target_compile_definitions(empty-${lang} PRIVATE VERIFY_MT)
+ endif()
+ if(CMAKE_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])")
+ # VS 2010 and above have a different default runtime library for projects than 'cl'.
+ target_compile_definitions(empty-${lang} PRIVATE VERIFY_DLL)
+ endif()
+ endif()
+endfunction()
+
+verify(C verify.c)
+verify(CXX verify.cxx)
+if(CMake_TEST_CUDA)
+ verify(CUDA verify.cu)
+endif()
diff --git a/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt b/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt
new file mode 100644
index 000000000..27838a40a
--- /dev/null
+++ b/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt
@@ -0,0 +1,58 @@
+cmake_minimum_required(VERSION 3.14)
+cmake_policy(SET CMP0091 NEW)
+project(MSVCRuntimeLibraryFortran Fortran)
+
+foreach(t MultiThreaded SingleThreaded)
+ foreach(dbg "" Debug)
+ foreach(dll "" DLL)
+ set(var "CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_${t}${dbg}${dll}")
+ if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
+ # ifort does not actually define these, so inject them
+ string(REPLACE "-threads" "-threads;-D_MT" "${var}" "${${var}}")
+ string(REPLACE "-dbglibs" "-dbglibs;-D_DEBUG" "${var}" "${${var}}")
+ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Flang")
+ # flang does not actually define these, so inject them
+ string(REPLACE ";--dependent-lib=libcmt;" ";--dependent-lib=libcmt;-D_MT;" "${var}" ";${${var}};")
+ string(REPLACE ";--dependent-lib=msvcrt;" ";--dependent-lib=msvcrt;-D_MT;-D_DLL;" "${var}" ";${${var}};")
+ string(REPLACE ";--dependent-lib=libcmtd;" ";--dependent-lib=libcmtd;-D_MT;-D_DEBUG;" "${var}" ";${${var}};")
+ string(REPLACE ";--dependent-lib=msvcrtd;" ";--dependent-lib=msvcrtd;-D_MT;-D_DEBUG;-D_DLL;" "${var}" ";${${var}};")
+ endif()
+ endforeach()
+ endforeach()
+endforeach()
+string(APPEND CMAKE_Fortran_FLAGS " -w")
+
+function(verify_combinations threads lang src)
+ set(verify_tc_config_ Release)
+ set(verify_tc_config_Debug Debug)
+ set(verify_def_MultiThreaded -DVERIFY_MT)
+ set(verify_def_Debug -DVERIFY_DEBUG)
+ set(verify_def_DLL -DVERIFY_DLL)
+ foreach(dbg "" Debug)
+ foreach(dll "" DLL)
+ # Construct the name of this runtime library combination.
+ set(rtl "${threads}${dbg}${dll}")
+
+ # Test that targets build with this RTL.
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "$<$<BOOL:$<TARGET_PROPERTY:BOOL_TRUE>>:${rtl}>$<$<BOOL:$<TARGET_PROPERTY:BOOL_FALSE>>:BadContent>")
+ add_library(${rtl}-${lang} ${src})
+ set_property(TARGET ${rtl}-${lang} PROPERTY BOOL_TRUE TRUE)
+ target_compile_definitions(${rtl}-${lang} PRIVATE ${verify_def_${threads}} ${verify_def_${dbg}} ${verify_def_${dll}})
+ endforeach()
+ endforeach()
+endfunction()
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+function(verify lang src)
+ add_library(default-${lang} ${src})
+ target_compile_definitions(default-${lang} PRIVATE VERIFY_MT VERIFY_DLL "$<$<CONFIG:Debug>:VERIFY_DEBUG>")
+ verify_combinations(MultiThreaded ${lang} ${src})
+endfunction()
+
+verify(Fortran verify.F90)
+# Intel Fortran for Windows supports single-threaded RTL but it is
+# not implemented by the Visual Studio integration.
+if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
+ verify_combinations(SingleThreaded Fortran verify.F90)
+endif()
diff --git a/Tests/MSVCRuntimeLibrary/Fortran/verify.F90 b/Tests/MSVCRuntimeLibrary/Fortran/verify.F90
new file mode 100644
index 000000000..6fe5e0553
--- /dev/null
+++ b/Tests/MSVCRuntimeLibrary/Fortran/verify.F90
@@ -0,0 +1 @@
+#include "../verify.h"
diff --git a/Tests/MSVCRuntimeLibrary/verify.c b/Tests/MSVCRuntimeLibrary/verify.c
new file mode 100644
index 000000000..741bca6b8
--- /dev/null
+++ b/Tests/MSVCRuntimeLibrary/verify.c
@@ -0,0 +1 @@
+#include "verify.h"
diff --git a/Tests/MSVCRuntimeLibrary/verify.cu b/Tests/MSVCRuntimeLibrary/verify.cu
new file mode 100644
index 000000000..741bca6b8
--- /dev/null
+++ b/Tests/MSVCRuntimeLibrary/verify.cu
@@ -0,0 +1 @@
+#include "verify.h"
diff --git a/Tests/MSVCRuntimeLibrary/verify.cxx b/Tests/MSVCRuntimeLibrary/verify.cxx
new file mode 100644
index 000000000..741bca6b8
--- /dev/null
+++ b/Tests/MSVCRuntimeLibrary/verify.cxx
@@ -0,0 +1 @@
+#include "verify.h"
diff --git a/Tests/MSVCRuntimeLibrary/verify.h b/Tests/MSVCRuntimeLibrary/verify.h
new file mode 100644
index 000000000..58d65fe32
--- /dev/null
+++ b/Tests/MSVCRuntimeLibrary/verify.h
@@ -0,0 +1,29 @@
+#ifdef VERIFY_DEBUG
+# ifndef _DEBUG
+# error "_DEBUG not defined by debug runtime library selection"
+# endif
+#else
+# ifdef _DEBUG
+# error "_DEBUG defined by non-debug runtime library selection"
+# endif
+#endif
+
+#ifdef VERIFY_DLL
+# ifndef _DLL
+# error "_DLL not defined by DLL runtime library selection"
+# endif
+#else
+# ifdef _DLL
+# error "_DLL defined by non-DLL runtime library selection"
+# endif
+#endif
+
+#ifdef VERIFY_MT
+# ifndef _MT
+# error "_MT not defined by multi-threaded runtime library selection"
+# endif
+#else
+# ifdef _MT
+# error "_MT defined by single-threaded runtime library selection"
+# endif
+#endif
diff --git a/Tests/MacRuntimePath/A/framework.cpp b/Tests/MacRuntimePath/A/framework.cpp
index abda195ed..b5a95d89d 100644
--- a/Tests/MacRuntimePath/A/framework.cpp
+++ b/Tests/MacRuntimePath/A/framework.cpp
@@ -1,5 +1,6 @@
#include "framework.h"
+
#include "stdio.h"
void framework()
diff --git a/Tests/MacRuntimePath/A/framework.h b/Tests/MacRuntimePath/A/framework.h
index 343317c59..5a3cfc457 100644
--- a/Tests/MacRuntimePath/A/framework.h
+++ b/Tests/MacRuntimePath/A/framework.h
@@ -3,13 +3,13 @@
#define framework_h
#ifdef WIN32
-#ifdef framework_EXPORTS
-#define FRAMEWORK_EXPORT __declspec(dllexport)
+# ifdef framework_EXPORTS
+# define FRAMEWORK_EXPORT __declspec(dllexport)
+# else
+# define FRAMEWORK_EXPORT __declspec(dllimport)
+# endif
#else
-#define FRAMEWORK_EXPORT __declspec(dllimport)
-#endif
-#else
-#define FRAMEWORK_EXPORT
+# define FRAMEWORK_EXPORT
#endif
void FRAMEWORK_EXPORT framework();
diff --git a/Tests/MacRuntimePath/A/framework2.cpp b/Tests/MacRuntimePath/A/framework2.cpp
index d3c2c458d..0a1beecab 100644
--- a/Tests/MacRuntimePath/A/framework2.cpp
+++ b/Tests/MacRuntimePath/A/framework2.cpp
@@ -1,5 +1,6 @@
#include "framework2.h"
+
#include "stdio.h"
void framework2()
diff --git a/Tests/MacRuntimePath/A/framework2.h b/Tests/MacRuntimePath/A/framework2.h
index 7f45f4d2f..2562396f9 100644
--- a/Tests/MacRuntimePath/A/framework2.h
+++ b/Tests/MacRuntimePath/A/framework2.h
@@ -3,13 +3,13 @@
#define framework2_h
#ifdef WIN32
-#ifdef framework2_EXPORTS
-#define FRAMEWORK2_EXPORT __declspec(dllexport)
+# ifdef framework2_EXPORTS
+# define FRAMEWORK2_EXPORT __declspec(dllexport)
+# else
+# define FRAMEWORK2_EXPORT __declspec(dllimport)
+# endif
#else
-#define FRAMEWORK2_EXPORT __declspec(dllimport)
-#endif
-#else
-#define FRAMEWORK2_EXPORT
+# define FRAMEWORK2_EXPORT
#endif
void FRAMEWORK2_EXPORT framework2();
diff --git a/Tests/MacRuntimePath/A/shared.cpp b/Tests/MacRuntimePath/A/shared.cpp
index e5e7dc5ae..13791c269 100644
--- a/Tests/MacRuntimePath/A/shared.cpp
+++ b/Tests/MacRuntimePath/A/shared.cpp
@@ -1,5 +1,6 @@
#include "shared.h"
+
#include "stdio.h"
void shared()
diff --git a/Tests/MacRuntimePath/A/shared.h b/Tests/MacRuntimePath/A/shared.h
index 28904fd78..5d5b6335c 100644
--- a/Tests/MacRuntimePath/A/shared.h
+++ b/Tests/MacRuntimePath/A/shared.h
@@ -3,13 +3,13 @@
#define shared_h
#ifdef WIN32
-#ifdef shared_EXPORTS
-#define SHARED_EXPORT __declspec(dllexport)
+# ifdef shared_EXPORTS
+# define SHARED_EXPORT __declspec(dllexport)
+# else
+# define SHARED_EXPORT __declspec(dllimport)
+# endif
#else
-#define SHARED_EXPORT __declspec(dllimport)
-#endif
-#else
-#define SHARED_EXPORT
+# define SHARED_EXPORT
#endif
void SHARED_EXPORT shared();
diff --git a/Tests/MacRuntimePath/CMakeLists.txt b/Tests/MacRuntimePath/CMakeLists.txt
index 3e9ab8a55..a3c6fd9a9 100644
--- a/Tests/MacRuntimePath/CMakeLists.txt
+++ b/Tests/MacRuntimePath/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 2.8)
+cmake_minimum_required (VERSION 3.9)
project(MacRuntimePath)
if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
@@ -18,7 +18,8 @@ set_property(
configure_file(${MacRuntimePath_SOURCE_DIR}/InitialCache.cmake.in
${MacRuntimePath_BINARY_DIR}/InitialCache.cmake @ONLY)
-if(CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}")
else()
if(CMAKE_BUILD_TYPE)
diff --git a/Tests/MakeClean/ToClean/CMakeLists.txt b/Tests/MakeClean/ToClean/CMakeLists.txt
index d0e24cefe..a05c38b22 100644
--- a/Tests/MakeClean/ToClean/CMakeLists.txt
+++ b/Tests/MakeClean/ToClean/CMakeLists.txt
@@ -1,42 +1,122 @@
-cmake_minimum_required(VERSION 2.6)
+cmake_minimum_required(VERSION 3.14)
project(ToClean)
-# Build a simple project.
-add_executable(toclean toclean.cxx)
+# Utility variables
+set(CSD ${CMAKE_CURRENT_SOURCE_DIR})
+set(CBD ${CMAKE_CURRENT_BINARY_DIR})
+set(CLEAN_FILE_CONTENT "File registered for cleaning.\n")
+
+# Lists build-time-generated files that should be cleaned away
+set_property(GLOBAL PROPERTY TOCLEAN_FILES "")
+function(addCleanFile FILENAME)
+ set_property(GLOBAL APPEND PROPERTY TOCLEAN_FILES "${FILENAME}")
+endfunction()
+function(writeCleanFile FILENAME)
+ file(WRITE "${FILENAME}" ${CLEAN_FILE_CONTENT})
+endfunction()
-# List some build-time-generated files.
-set(TOCLEAN_FILES ${TOCLEAN_FILES}
- "${ToClean_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}")
+set(DUMMY_CONTENT_FILE ${CSD}/toclean.cxx)
-# Create a file that must be registered for cleaning.
-file(WRITE "${ToClean_BINARY_DIR}/Registered.txt"
- "File registered for cleaning.\n")
-set_directory_properties(PROPERTIES
- ADDITIONAL_MAKE_CLEAN_FILES "${ToClean_BINARY_DIR}/Registered.txt")
-set(TOCLEAN_FILES ${TOCLEAN_FILES} "${ToClean_BINARY_DIR}/Registered.txt")
+# Build a simple project whose compiled objects should be cleaned.
+add_executable(toclean toclean.cxx)
+addCleanFile(
+ "${CBD}${CMAKE_FILES_DIRECTORY}/toclean.dir/toclean.cxx${CMAKE_CXX_OUTPUT_EXTENSION}")
+
+# Create a post build custom command that copies a dummy file
+# to a custom location
+function(addPostBuildFile TARGET FILENAME)
+ add_custom_command(TARGET ${TARGET} POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E copy ${DUMMY_CONTENT_FILE} ${FILENAME})
+endfunction()
# Create a custom command whose output should be cleaned.
-add_custom_command(OUTPUT ${ToClean_BINARY_DIR}/generated.txt
- DEPENDS ${ToClean_SOURCE_DIR}/toclean.cxx
+set(CustomCommandFile "${CBD}/CustomCommandFile.txt")
+add_custom_command(OUTPUT ${CustomCommandFile}
+ DEPENDS ${DUMMY_CONTENT_FILE}
COMMAND ${CMAKE_COMMAND}
- ARGS -E copy ${ToClean_SOURCE_DIR}/toclean.cxx
- ${ToClean_BINARY_DIR}/generated.txt
- )
-add_custom_target(generate ALL DEPENDS ${ToClean_BINARY_DIR}/generated.txt)
-set(TOCLEAN_FILES ${TOCLEAN_FILES} "${ToClean_BINARY_DIR}/generated.txt")
+ ARGS -E copy ${DUMMY_CONTENT_FILE} ${CustomCommandFile})
+add_custom_target(customTarget ALL DEPENDS ${CustomCommandFile})
+addCleanFile(${CustomCommandFile})
+
+
+### Tests ADDITIONAL_MAKE_CLEAN_FILES directory property
+if("${CMAKE_GENERATOR}" MATCHES "Makefile")
+ # Create a file that must be registered for cleaning.
+ set(MakeDirPropFileAbs "${CBD}/MakeDirPropFile.txt")
+ writeCleanFile("${MakeDirPropFileAbs}")
+ set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${MakeDirPropFileAbs}")
+ addCleanFile(${MakeDirPropFileAbs})
+
+ # Create a custom command whose output should be cleaned, but whose name
+ # is not known until generate-time
+ set(MakeDirPropExpFileRel "MakeDirProp_copy${CMAKE_EXECUTABLE_SUFFIX}")
+ set(MakeDirPropExpFileAbs "$<TARGET_FILE_DIR:toclean>/${MakeDirPropExpFileRel}")
+ addPostBuildFile(toclean "${MakeDirPropExpFileAbs}")
+ set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${MakeDirPropExpFileAbs})
+ addCleanFile("${CBD}/${MakeDirPropExpFileRel}")
+endif()
+
+
+### Tests ADDITIONAL_CLEAN_FILES directory property
+
+# Register a file path relative to the build directory
+set(DirPropFileRel "DirPropFileRel.txt")
+writeCleanFile("${CBD}/${DirPropFileRel}")
+set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES ${DirPropFileRel})
+addCleanFile("${CBD}/${DirPropFileRel}")
+
+# Register an absolute file path
+set(DirPropFileAbs "${CBD}/DirPropFileAbs.txt")
+writeCleanFile("${DirPropFileAbs}")
+set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropFileAbs})
+addCleanFile("${DirPropFileAbs}")
# Create a custom command whose output should be cleaned, but whose name
# is not known until generate-time
-set(copied_exe "$<TARGET_FILE_DIR:toclean>/toclean_copy${CMAKE_EXECUTABLE_SUFFIX}")
-add_custom_command(TARGET toclean POST_BUILD
- COMMAND ${CMAKE_COMMAND}
- ARGS -E copy $<TARGET_FILE:toclean>
- ${copied_exe}
- )
-set_property(DIRECTORY APPEND PROPERTY
- ADDITIONAL_MAKE_CLEAN_FILES ${copied_exe})
-list(APPEND TOCLEAN_FILES "${ToClean_BINARY_DIR}/toclean_copy${CMAKE_EXECUTABLE_SUFFIX}")
+set(DirPropExpFileRel "DirProp_copy${CMAKE_EXECUTABLE_SUFFIX}")
+set(DirPropExpFileAbs "$<TARGET_FILE_DIR:toclean>/${DirPropExpFileRel}")
+addPostBuildFile(toclean "${DirPropExpFileAbs}")
+set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropExpFileAbs})
+addCleanFile("${CBD}/${DirPropExpFileRel}")
+
+
+### Tests ADDITIONAL_CLEAN_FILES target property
+
+function(test_target_property TARGET)
+ # Register a file path relative to the build directory
+ set(TgtPropFileRel "${TARGET}_TargetPropFileRel.txt")
+ writeCleanFile("${CBD}/${TgtPropFileRel}")
+ set_target_properties(${TARGET} PROPERTIES ADDITIONAL_CLEAN_FILES ${TgtPropFileRel})
+ addCleanFile("${CBD}/${TgtPropFileRel}")
+
+ # Register an absolute file path
+ set(TgtPropFileAbs "${CBD}/${TARGET}_TargetPropFileAbs.txt")
+ writeCleanFile("${TgtPropFileAbs}")
+ set_property(TARGET ${TARGET} APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropFileAbs})
+ addCleanFile("${TgtPropFileAbs}")
+
+ # Create a custom command whose output should be cleaned, but whose name
+ # is not known until generate-time
+ set(TgtPropExpFileRel "${TARGET}_TargetPropGenExp.txt")
+ set(TgtPropExpFileAbs "$<TARGET_FILE_DIR:toclean>/${TgtPropExpFileRel}")
+ addPostBuildFile(${TARGET} "${TgtPropExpFileAbs}")
+ set_property(TARGET ${TARGET} APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${TgtPropExpFileAbs})
+ addCleanFile("${CBD}/${TgtPropExpFileRel}")
+endfunction()
+
+# Test target property for various target types
+add_executable(acf_exec toclean.cxx)
+test_target_property(acf_exec)
+add_library(acf_lib toclean.cxx)
+test_target_property(acf_lib)
+add_custom_target(acf_custom ALL DEPENDS ${CustomCommandFile})
+test_target_property(acf_custom)
+
+# Process subdirectory without targets
+add_subdirectory(EmptySubDir)
+
# Configure a file listing these build-time-generated files.
-configure_file(${ToClean_SOURCE_DIR}/ToCleanFiles.cmake.in
- ${ToClean_BINARY_DIR}/ToCleanFiles.cmake @ONLY)
+get_property(TOCLEAN_FILES GLOBAL PROPERTY TOCLEAN_FILES)
+configure_file(${CSD}/ToCleanFiles.cmake.in ${CBD}/ToCleanFiles.cmake @ONLY)
diff --git a/Tests/MakeClean/ToClean/EmptySubDir/CMakeLists.txt b/Tests/MakeClean/ToClean/EmptySubDir/CMakeLists.txt
new file mode 100644
index 000000000..55893ae06
--- /dev/null
+++ b/Tests/MakeClean/ToClean/EmptySubDir/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.14)
+
+# Subdirectory CMakeLists.txt without targets
+set(CSD ${CMAKE_CURRENT_SOURCE_DIR})
+set(CBD ${CMAKE_CURRENT_BINARY_DIR})
+
+# Register a file path relative to the build directory
+set(DirPropFileRel "DirPropFileRel.txt")
+writeCleanFile("${CBD}/${DirPropFileRel}")
+set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES ${DirPropFileRel})
+addCleanFile("${CBD}/${DirPropFileRel}")
+
+# Register an absolute file path
+set(DirPropFileAbs "${CBD}/DirPropFileAbs.txt")
+writeCleanFile("${DirPropFileAbs}")
+set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${DirPropFileAbs})
+addCleanFile("${DirPropFileAbs}")
diff --git a/Tests/MakeClean/check_clean.c.in b/Tests/MakeClean/check_clean.c.in
index 5bc4ab880..e5a7945af 100644
--- a/Tests/MakeClean/check_clean.c.in
+++ b/Tests/MakeClean/check_clean.c.in
@@ -18,7 +18,7 @@ int main()
if(pf)
{
fclose(pf);
- fprintf(stderr, "File \"%s\" exists!", *f);
+ fprintf(stderr, "File \"%s\" still exists!\n", *f);
result = 1;
}
}
diff --git a/Tests/MathTest/CMakeLists.txt b/Tests/MathTest/CMakeLists.txt
index f764b3a4f..396f633c6 100644
--- a/Tests/MathTest/CMakeLists.txt
+++ b/Tests/MathTest/CMakeLists.txt
@@ -13,14 +13,37 @@ set(expressions
"-1 + +1"
"+1 - -1"
"+1 - - + + -(-3 + - - +1)"
+ "1000 -12*5"
+ "1000 +12*-5"
+ "1000 -12*-5"
+ "~~1"
+ "1000 & ~0"
)
-set(FILE_EXPRESSIONS "")
-foreach(expression
- ${expressions})
- math(EXPR expr "${expression}")
- string(APPEND FILE_EXPRESSIONS "TEST_EXPRESSION(${expression}, ${expr})\n")
-endforeach()
+set(FILE_EXPRESSIONS "extern void test_expression(int x, int y, const char * text);\n")
+
+
+macro(add_math_test expression)
+ math(EXPR result ${expression} ${ARGV1} ${ARGV2})
+ set(CODE "test_expression(${expression}, ${result}, \"${expression}\");")
+ string(APPEND FILE_EXPRESSIONS "${CODE}\n")
+endmacro()
+
+macro(add_math_tests)
+ foreach (expression ${expressions})
+ add_math_test(${expression} ${ARGV0} ${ARGV1})
+ endforeach ()
+endmacro()
+
+add_math_tests()
+add_math_tests("OUTPUT_FORMAT" "DECIMAL")
+add_math_tests("OUTPUT_FORMAT" "HEXADECIMAL")
+
+# Avoid the test with negative result and hexadecimal formatting
+# therefore more tests with a negative result
+add_math_test("-12*5")
+add_math_test("12*-5")
+
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/MathTestTests.h.in"
diff --git a/Tests/MathTest/MathTestExec.cxx b/Tests/MathTest/MathTestExec.cxx
index 124eba46f..fbcddc4ed 100644
--- a/Tests/MathTest/MathTestExec.cxx
+++ b/Tests/MathTest/MathTestExec.cxx
@@ -1,21 +1,43 @@
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
-#define TEST_EXPRESSION(x, y) \
- if ((x) != (y)) { \
- printf("Problem with EXPR: Expression: \"%s\" in C returns %d while in " \
- "CMake returns: %d\n", \
- #x, (x), (y)); \
- res++; \
+int res = 0;
+bool print = false;
+
+void test_expression(int x, int y, const char* text)
+{
+ bool fail = (x) != (y);
+ if (fail) {
+ res++;
+ printf("Problem with EXPR:");
+ }
+ if (fail || print) {
+ printf("Expression: \"%s\" in CMake returns %d", text, (y));
+ if (fail) {
+ printf(" while in C returns: %d", (x));
+ }
+ printf("\n");
}
+}
int main(int argc, char* argv[])
{
- if (argc > 1) {
- printf("Usage: %s\n", argv[0]);
+ if (argc > 2) {
+ printf("Usage: %s [print]\n", argv[0]);
return 1;
}
- int res = 0;
+
+ if (argc > 1) {
+ if (strcmp(argv[1], "print") != 0) {
+ printf("Usage: %s [print]\n", argv[0]);
+ return 1;
+ }
+ print = true;
+ }
+
#include "MathTestTests.h"
+
if (res != 0) {
printf("%s: %d math tests failed\n", argv[0], res);
return 1;
diff --git a/Tests/MissingInstall/CMakeLists.txt b/Tests/MissingInstall/CMakeLists.txt
index 91624f710..365b31f62 100644
--- a/Tests/MissingInstall/CMakeLists.txt
+++ b/Tests/MissingInstall/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 2.8.12)
+cmake_minimum_required (VERSION 3.9)
project(TestMissingInstall)
set(CMAKE_SKIP_INSTALL_RULES ON)
@@ -8,11 +8,7 @@ set(CMAKE_SKIP_INSTALL_RULES ON)
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1)
set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY 1)
-if(CMAKE_CONFIGURATION_TYPES)
- set(MULTI_CONFIG ON)
-else()
- set(MULTI_CONFIG OFF)
-endif()
+get_property(MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
add_executable(mybin mybin.cpp)
install(TARGETS mybin RUNTIME DESTINATION bin)
diff --git a/Tests/Module/CheckIPOSupported-C/CMakeLists.txt b/Tests/Module/CheckIPOSupported-C/CMakeLists.txt
index 607dcd33a..c5cd03e06 100644
--- a/Tests/Module/CheckIPOSupported-C/CMakeLists.txt
+++ b/Tests/Module/CheckIPOSupported-C/CMakeLists.txt
@@ -4,16 +4,27 @@ project(CheckIPOSupported-C LANGUAGES C)
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
-check_ipo_supported(RESULT ipo_supported)
+check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output)
if(ipo_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
elseif(CMake_TEST_IPO_WORKS_C)
- message(FATAL_ERROR "IPO expected to work")
+ string(REPLACE "\n" "\n " ipo_output "${ipo_output}")
+ message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}")
endif()
add_library(foo foo.c)
+if(NOT CYGWIN AND (NOT WIN32 OR "x${CMAKE_C_COMPILER_ID}" STREQUAL "xClang"))
+ add_library(bar SHARED bar.c)
+ if(WIN32)
+ # Bindexplib for clang supports LTO objects
+ set_target_properties(bar PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
+ endif()
+else()
+ # TODO: bindexplib doesn't support exporting IPO symbols with other compilers on Windows
+ add_library(bar STATIC bar.c)
+endif()
add_executable(CheckIPOSupported-C main.c)
-target_link_libraries(CheckIPOSupported-C PUBLIC foo)
+target_link_libraries(CheckIPOSupported-C PUBLIC foo bar)
enable_testing()
add_test(NAME CheckIPOSupported-C COMMAND CheckIPOSupported-C)
diff --git a/Tests/Module/CheckIPOSupported-C/bar.c b/Tests/Module/CheckIPOSupported-C/bar.c
new file mode 100644
index 000000000..680f21302
--- /dev/null
+++ b/Tests/Module/CheckIPOSupported-C/bar.c
@@ -0,0 +1,4 @@
+int bar()
+{
+ return 0x42;
+}
diff --git a/Tests/Module/CheckIPOSupported-C/main.c b/Tests/Module/CheckIPOSupported-C/main.c
index 99204abce..28ab26f64 100644
--- a/Tests/Module/CheckIPOSupported-C/main.c
+++ b/Tests/Module/CheckIPOSupported-C/main.c
@@ -1,8 +1,9 @@
int foo();
+int bar();
int main()
{
- if (foo() == 0) {
+ if (foo() != bar()) {
return 1;
}
return 0;
diff --git a/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt b/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt
index 2dede930b..237bf1d6d 100644
--- a/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt
+++ b/Tests/Module/CheckIPOSupported-CXX/CMakeLists.txt
@@ -4,16 +4,28 @@ project(CheckIPOSupported-CXX LANGUAGES CXX)
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
-check_ipo_supported(RESULT ipo_supported)
+check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output)
if(ipo_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
elseif(CMake_TEST_IPO_WORKS_CXX)
- message(FATAL_ERROR "IPO expected to work")
+ string(REPLACE "\n" "\n " ipo_output "${ipo_output}")
+ message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}")
endif()
-add_library(foo foo.cpp)
+
+add_library(foo STATIC foo.cpp)
+if(NOT CYGWIN AND (NOT WIN32 OR "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
+ add_library(bar SHARED bar.cpp)
+ if(WIN32)
+ # Bindexplib for clang supports LTO objects
+ set_target_properties(bar PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
+ endif()
+else()
+ # TODO: bindexplib doesn't support exporting IPO symbols with other compilers on Windows
+ add_library(bar STATIC bar.cpp)
+endif()
add_executable(CheckIPOSupported-CXX main.cpp)
-target_link_libraries(CheckIPOSupported-CXX PUBLIC foo)
+target_link_libraries(CheckIPOSupported-CXX PUBLIC foo bar)
enable_testing()
add_test(NAME CheckIPOSupported-CXX COMMAND CheckIPOSupported-CXX)
diff --git a/Tests/Module/CheckIPOSupported-CXX/bar.cpp b/Tests/Module/CheckIPOSupported-CXX/bar.cpp
new file mode 100644
index 000000000..680f21302
--- /dev/null
+++ b/Tests/Module/CheckIPOSupported-CXX/bar.cpp
@@ -0,0 +1,4 @@
+int bar()
+{
+ return 0x42;
+}
diff --git a/Tests/Module/CheckIPOSupported-CXX/main.cpp b/Tests/Module/CheckIPOSupported-CXX/main.cpp
index 99204abce..28ab26f64 100644
--- a/Tests/Module/CheckIPOSupported-CXX/main.cpp
+++ b/Tests/Module/CheckIPOSupported-CXX/main.cpp
@@ -1,8 +1,9 @@
int foo();
+int bar();
int main()
{
- if (foo() == 0) {
+ if (foo() != bar()) {
return 1;
}
return 0;
diff --git a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt
index dee5c25bd..3872b567b 100644
--- a/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt
+++ b/Tests/Module/CheckIPOSupported-Fortran/CMakeLists.txt
@@ -4,11 +4,12 @@ project(CheckIPOSupported-Fortran LANGUAGES Fortran)
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
-check_ipo_supported(RESULT ipo_supported)
+check_ipo_supported(RESULT ipo_supported OUTPUT ipo_output)
if(ipo_supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
elseif(CMake_TEST_IPO_WORKS_Fortran)
- message(FATAL_ERROR "IPO expected to work")
+ string(REPLACE "\n" "\n " ipo_output "${ipo_output}")
+ message(FATAL_ERROR "IPO expected to work, but the check failed:\n ${ipo_output}")
endif()
add_library(foo foo.f)
diff --git a/Tests/Module/CheckTypeSize/CheckTypeSize.c b/Tests/Module/CheckTypeSize/CheckTypeSize.c
index 05c798b05..adfd2fc2a 100644
--- a/Tests/Module/CheckTypeSize/CheckTypeSize.c
+++ b/Tests/Module/CheckTypeSize/CheckTypeSize.c
@@ -2,13 +2,13 @@
#include "somestruct.h"
#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
+# include <sys/types.h>
#endif
#ifdef HAVE_STDINT_H
-#include <stdint.h>
+# include <stdint.h>
#endif
#ifdef HAVE_STDDEF_H
-#include <stddef.h>
+# include <stddef.h>
#endif
#include <stdio.h>
@@ -86,17 +86,17 @@ int main()
/* long long */
#if defined(SIZEOF_LONG_LONG)
CHECK(long long, SIZEOF_LONG_LONG);
-#if !defined(HAVE_SIZEOF_LONG_LONG)
+# if !defined(HAVE_SIZEOF_LONG_LONG)
NODEF(HAVE_SIZEOF_LONG_LONG);
-#endif
+# endif
#endif
/* __int64 */
#if defined(SIZEOF___INT64)
CHECK(__int64, SIZEOF___INT64);
-#if !defined(HAVE_SIZEOF___INT64)
+# if !defined(HAVE_SIZEOF___INT64)
NODEF(HAVE_SIZEOF___INT64);
-#endif
+# endif
#elif defined(HAVE_SIZEOF___INT64)
NODEF(SIZEOF___INT64);
#endif
@@ -114,9 +114,9 @@ int main()
/* ssize_t */
#if defined(SIZEOF_SSIZE_T)
CHECK(ssize_t, SIZEOF_SSIZE_T);
-#if !defined(HAVE_SIZEOF_SSIZE_T)
+# if !defined(HAVE_SIZEOF_SSIZE_T)
NODEF(HAVE_SIZEOF_SSIZE_T);
-#endif
+# endif
#elif defined(HAVE_SIZEOF_SSIZE_T)
NODEF(SIZEOF_SSIZE_T);
#endif
@@ -125,9 +125,9 @@ int main()
#if defined(SIZEOF_STRUCTMEMBER_INT)
CHECK(x.someint, SIZEOF_STRUCTMEMBER_INT);
CHECK(x.someint, SIZEOF_INT);
-#if !defined(HAVE_SIZEOF_STRUCTMEMBER_INT)
+# if !defined(HAVE_SIZEOF_STRUCTMEMBER_INT)
NODEF(HAVE_SIZEOF_STRUCTMEMBER_INT);
-#endif
+# endif
#elif defined(HAVE_SIZEOF_STRUCTMEMBER_INT)
NODEF(SIZEOF_STRUCTMEMBER_INT);
#endif
@@ -136,9 +136,9 @@ int main()
#if defined(SIZEOF_STRUCTMEMBER_PTR)
CHECK(x.someptr, SIZEOF_STRUCTMEMBER_PTR);
CHECK(x.someptr, SIZEOF_DATA_PTR);
-#if !defined(HAVE_SIZEOF_STRUCTMEMBER_PTR)
+# if !defined(HAVE_SIZEOF_STRUCTMEMBER_PTR)
NODEF(HAVE_SIZEOF_STRUCTMEMBER_PTR);
-#endif
+# endif
#elif defined(HAVE_SIZEOF_STRUCTMEMBER_PTR)
NODEF(SIZEOF_STRUCTMEMBER_PTR);
#endif
@@ -147,9 +147,9 @@ int main()
#if defined(SIZEOF_STRUCTMEMBER_CHAR)
CHECK(x.somechar, SIZEOF_STRUCTMEMBER_CHAR);
CHECK(x.somechar, SIZEOF_CHAR);
-#if !defined(HAVE_SIZEOF_STRUCTMEMBER_CHAR)
+# if !defined(HAVE_SIZEOF_STRUCTMEMBER_CHAR)
NODEF(HAVE_SIZEOF_STRUCTMEMBER_CHAR);
-#endif
+# endif
#elif defined(HAVE_SIZEOF_STRUCTMEMBER_CHAR)
NODEF(SIZEOF_STRUCTMEMBER_CHAR);
#endif
diff --git a/Tests/Module/CheckTypeSize/CheckTypeSize.cxx b/Tests/Module/CheckTypeSize/CheckTypeSize.cxx
index 2ae84a32f..15dc890c8 100644
--- a/Tests/Module/CheckTypeSize/CheckTypeSize.cxx
+++ b/Tests/Module/CheckTypeSize/CheckTypeSize.cxx
@@ -3,13 +3,13 @@
#include "someclass.hxx"
#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
+# include <sys/types.h>
#endif
#ifdef HAVE_STDINT_H
-#include <stdint.h>
+# include <stdint.h>
#endif
#ifdef HAVE_STDDEF_H
-#include <stddef.h>
+# include <stddef.h>
#endif
#include <stdio.h>
@@ -87,17 +87,17 @@ int main()
/* long long */
#if defined(SIZEOF_LONG_LONG)
CHECK(long long, SIZEOF_LONG_LONG);
-#if !defined(HAVE_SIZEOF_LONG_LONG)
+# if !defined(HAVE_SIZEOF_LONG_LONG)
NODEF(HAVE_SIZEOF_LONG_LONG);
-#endif
+# endif
#endif
/* __int64 */
#if defined(SIZEOF___INT64)
CHECK(__int64, SIZEOF___INT64);
-#if !defined(HAVE_SIZEOF___INT64)
+# if !defined(HAVE_SIZEOF___INT64)
NODEF(HAVE_SIZEOF___INT64);
-#endif
+# endif
#elif defined(HAVE_SIZEOF___INT64)
NODEF(SIZEOF___INT64);
#endif
@@ -115,9 +115,9 @@ int main()
/* ssize_t */
#if defined(SIZEOF_SSIZE_T)
CHECK(ssize_t, SIZEOF_SSIZE_T);
-#if !defined(HAVE_SIZEOF_SSIZE_T)
+# if !defined(HAVE_SIZEOF_SSIZE_T)
NODEF(HAVE_SIZEOF_SSIZE_T);
-#endif
+# endif
#elif defined(HAVE_SIZEOF_SSIZE_T)
NODEF(SIZEOF_SSIZE_T);
#endif
@@ -126,9 +126,9 @@ int main()
#if defined(SIZEOF_NS_CLASSMEMBER_INT)
CHECK(y.someint, SIZEOF_NS_CLASSMEMBER_INT);
CHECK(y.someint, SIZEOF_INT);
-#if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_INT)
+# if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_INT)
NODEF(HAVE_SIZEOF_STRUCTMEMBER_INT);
-#endif
+# endif
#elif defined(HAVE_SIZEOF_STRUCTMEMBER_INT)
NODEF(SIZEOF_STRUCTMEMBER_INT);
#endif
@@ -137,9 +137,9 @@ int main()
#if defined(SIZEOF_NS_CLASSMEMBER_PTR)
CHECK(y.someptr, SIZEOF_NS_CLASSMEMBER_PTR);
CHECK(y.someptr, SIZEOF_DATA_PTR);
-#if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_PTR)
+# if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_PTR)
NODEF(HAVE_SIZEOF_NS_CLASSMEMBER_PTR);
-#endif
+# endif
#elif defined(HAVE_SIZEOF_NS_CLASSMEMBER_PTR)
NODEF(SIZEOF_NS_CLASSMEMBER_PTR);
#endif
@@ -148,9 +148,9 @@ int main()
#if defined(SIZEOF_NS_CLASSMEMBER_CHAR)
CHECK(y.somechar, SIZEOF_NS_CLASSMEMBER_CHAR);
CHECK(y.somechar, SIZEOF_CHAR);
-#if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_CHAR)
+# if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_CHAR)
NODEF(HAVE_SIZEOF_NS_CLASSMEMBER_CHAR);
-#endif
+# endif
#elif defined(HAVE_SIZEOF_NS_CLASSMEMBER_CHAR)
NODEF(SIZEOF_NS_CLASSMEMBER_CHAR);
#endif
@@ -159,9 +159,9 @@ int main()
#if defined(SIZEOF_NS_CLASSMEMBER_BOOL)
CHECK(y.somechar, SIZEOF_NS_CLASSMEMBER_BOOL);
CHECK(y.somechar, SIZEOF_BOOL);
-#if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_BOOL)
+# if !defined(HAVE_SIZEOF_NS_CLASSMEMBER_BOOL)
NODEF(HAVE_SIZEOF_NS_CLASSMEMBER_BOOL);
-#endif
+# endif
#elif defined(HAVE_SIZEOF_NS_CLASSMEMBER_BOOL)
NODEF(SIZEOF_NS_CLASSMEMBER_BOOL);
#endif
diff --git a/Tests/Module/ExternalData/.gitattributes b/Tests/Module/ExternalData/.gitattributes
new file mode 100644
index 000000000..516129bdb
--- /dev/null
+++ b/Tests/Module/ExternalData/.gitattributes
@@ -0,0 +1,5 @@
+MD5/* -text
+SHA1/* -text
+SHA224/* -text
+SHA256/* -text
+SHA3_256/* -text
diff --git a/Tests/Module/ExternalData/Data5/CMakeLists.txt b/Tests/Module/ExternalData/Data5/CMakeLists.txt
index 13c7fabed..ea67f05af 100644
--- a/Tests/Module/ExternalData/Data5/CMakeLists.txt
+++ b/Tests/Module/ExternalData/Data5/CMakeLists.txt
@@ -2,21 +2,21 @@
ExternalData_Add_Test(Data5.A
NAME Data5Check.A
COMMAND ${CMAKE_COMMAND}
- -D Data5=DATA{../Data.dat}
+ -D Data5=DATA{Data5.dat}
-P ${CMAKE_CURRENT_SOURCE_DIR}/Data5Check.cmake
)
ExternalData_Add_Target(Data5.A)
ExternalData_Add_Test(Data5.B
NAME Data5Check.B
COMMAND ${CMAKE_COMMAND}
- -D Data5=DATA{../Data.dat}
+ -D Data5=DATA{Data5.dat}
-P ${CMAKE_CURRENT_SOURCE_DIR}/Data5Check.cmake
)
ExternalData_Add_Target(Data5.B)
ExternalData_Add_Test(Data5.C
NAME Data5Check.C
COMMAND ${CMAKE_COMMAND}
- -D Data5=DATA{../Data.dat}
+ -D Data5=DATA{Data5.dat}
-P ${CMAKE_CURRENT_SOURCE_DIR}/Data5Check.cmake
)
ExternalData_Add_Target(Data5.C)
diff --git a/Tests/Module/ExternalData/Data5/Data5.dat.md5 b/Tests/Module/ExternalData/Data5/Data5.dat.md5
new file mode 100644
index 000000000..70e39bd5d
--- /dev/null
+++ b/Tests/Module/ExternalData/Data5/Data5.dat.md5
@@ -0,0 +1 @@
+8c018830e3efa5caf3c7415028335a57
diff --git a/Tests/Module/ExternalData/MD5/.gitattributes b/Tests/Module/ExternalData/MD5/.gitattributes
deleted file mode 100644
index 3e51d39db..000000000
--- a/Tests/Module/ExternalData/MD5/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-* -crlf
diff --git a/Tests/Module/ExternalData/SHA1/.gitattributes b/Tests/Module/ExternalData/SHA1/.gitattributes
deleted file mode 100644
index 3e51d39db..000000000
--- a/Tests/Module/ExternalData/SHA1/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-* -crlf
diff --git a/Tests/Module/ExternalData/SHA224/.gitattributes b/Tests/Module/ExternalData/SHA224/.gitattributes
deleted file mode 100644
index 3e51d39db..000000000
--- a/Tests/Module/ExternalData/SHA224/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-* -crlf
diff --git a/Tests/Module/ExternalData/SHA256/.gitattributes b/Tests/Module/ExternalData/SHA256/.gitattributes
deleted file mode 100644
index 3e51d39db..000000000
--- a/Tests/Module/ExternalData/SHA256/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-* -crlf
diff --git a/Tests/Module/ExternalData/SHA3_256/.gitattributes b/Tests/Module/ExternalData/SHA3_256/.gitattributes
deleted file mode 100644
index 3e51d39db..000000000
--- a/Tests/Module/ExternalData/SHA3_256/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-* -crlf
diff --git a/Tests/Module/FindDependency/CMakeLists.txt b/Tests/Module/FindDependency/CMakeLists.txt
index dcb998a4b..06d7dce9a 100644
--- a/Tests/Module/FindDependency/CMakeLists.txt
+++ b/Tests/Module/FindDependency/CMakeLists.txt
@@ -6,6 +6,8 @@ set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/packages")
find_package(Pack1 REQUIRED)
find_package(Pack4 4.3 EXACT REQUIRED)
+find_package(Pack7 REQUIRED)
+find_package(Pack8 REQUIRED)
add_executable(FindDependency main.cpp)
-target_link_libraries(FindDependency Pack1::Lib Pack4::Lib)
+target_link_libraries(FindDependency Pack1::Lib Pack4::Lib Pack8::Lib)
diff --git a/Tests/Module/FindDependency/main.cpp b/Tests/Module/FindDependency/main.cpp
index 50c5958ca..4ee460fbf 100644
--- a/Tests/Module/FindDependency/main.cpp
+++ b/Tests/Module/FindDependency/main.cpp
@@ -1,26 +1,38 @@
#ifndef HAVE_PACK1
-#error Expected HAVE_PACK1
+# error Expected HAVE_PACK1
#endif
#ifndef HAVE_PACK2
-#error Expected HAVE_PACK2
+# error Expected HAVE_PACK2
#endif
#ifndef HAVE_PACK3
-#error Expected HAVE_PACK3
+# error Expected HAVE_PACK3
#endif
#ifndef HAVE_PACK4
-#error Expected HAVE_PACK4
+# error Expected HAVE_PACK4
#endif
#ifndef HAVE_PACK5
-#error Expected HAVE_PACK5
+# error Expected HAVE_PACK5
#endif
#ifndef HAVE_PACK6
-#error Expected HAVE_PACK6
+# error Expected HAVE_PACK6
+#endif
+
+#ifndef HAVE_PACK7
+# error Expected HAVE_PACK7
+#endif
+
+#ifndef HAVE_PACK7_COMP1
+# error Expected HAVE_PACK7_COMP1
+#endif
+
+#ifndef HAVE_PACK8
+# error Expected HAVE_PACK8
#endif
int main(int argc, char** argv)
diff --git a/Tests/Module/FindDependency/packages/Pack7/Pack7Config.cmake b/Tests/Module/FindDependency/packages/Pack7/Pack7Config.cmake
new file mode 100644
index 000000000..9df13457f
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack7/Pack7Config.cmake
@@ -0,0 +1,14 @@
+if(NOT Pack7_FOUND)
+ set(Pack7_FOUND 1)
+ add_library(Pack7::Pack7 INTERFACE IMPORTED)
+ set_property(TARGET Pack7::Pack7 PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK7)
+endif()
+
+foreach(module ${Pack7_FIND_COMPONENTS})
+ if(module STREQUAL "Comp1")
+ add_library(Pack7::Comp1 INTERFACE IMPORTED)
+ set_property(TARGET Pack7::Comp1 PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK7_COMP1)
+ set_property(TARGET Pack7::Comp1 PROPERTY INTERFACE_LINK_LIBRARIES Pack7::Pack7)
+ set(Pack7_Comp1_FOUND 1)
+ endif()
+endforeach()
diff --git a/Tests/Module/FindDependency/packages/Pack8/Pack8Config.cmake b/Tests/Module/FindDependency/packages/Pack8/Pack8Config.cmake
new file mode 100644
index 000000000..d7ca054e7
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack8/Pack8Config.cmake
@@ -0,0 +1,7 @@
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack7 REQUIRED COMPONENTS Comp1)
+
+add_library(Pack8::Lib INTERFACE IMPORTED)
+set_property(TARGET Pack8::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK8)
+set_property(TARGET Pack8::Lib PROPERTY INTERFACE_LINK_LIBRARIES Pack7::Comp1)
diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
index 52d461350..cffef5a0b 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
+++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
@@ -52,8 +52,10 @@ endmacro()
# detailed features tables, not just meta-features
if (CMAKE_C_COMPILE_FEATURES)
- set(C_expected_features ${CMAKE_C_COMPILE_FEATURES})
- list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]")
+ if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$")
+ set(C_expected_features ${CMAKE_C_COMPILE_FEATURES})
+ list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]")
+ endif()
endif()
if (C_expected_features)
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" COMPILER_VERSION_MAJOR "${CMAKE_C_COMPILER_VERSION}")
@@ -61,7 +63,7 @@ if (C_expected_features)
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_C_COMPILER_VERSION}")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
- OR CMAKE_C_COMPILER_ID STREQUAL "Clang"
+ OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang"
OR CMAKE_C_COMPILER_ID STREQUAL "Intel")
add_executable(WriteCompilerDetectionHeader_C11 main.c)
@@ -93,8 +95,10 @@ if (C_expected_features)
endif()
if (CMAKE_CXX_COMPILE_FEATURES)
- set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES})
- list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]")
+ if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$")
+ set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES})
+ list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]")
+ endif()
endif()
if (NOT CXX_expected_features)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp"
@@ -118,7 +122,7 @@ string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" COMPILER_VERSION_MINO
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_CXX_COMPILER_VERSION}")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
- OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
+ OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
OR CMAKE_CXX_COMPILER_ID STREQUAL "SunPro"
OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
@@ -128,7 +132,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
endif()
# for msvc the compiler version determines which c++11 features are available.
-if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC"
+ OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC"))
if(";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_delegating_constructors;")
list(APPEND true_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS)
list(APPEND true_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
@@ -190,7 +195,7 @@ write_compiler_detection_header(
ALLOW_UNKNOWN_COMPILERS
)
-# intentionally abuse the TEST_NULLPR variable: this will only work
+# intentionally abuse the TEST_NULLPTR variable: this will only work
# with the fallback code.
check_cxx_source_compiles("#include \"${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection_allow_unknown.h\"
int main() {\n int i = TEST_NULLPTR;\n return 0; }\n"
@@ -199,3 +204,16 @@ int main() {\n int i = TEST_NULLPTR;\n return 0; }\n"
if (NOT file_include_works_allow_unknown)
message(SEND_ERROR "Inclusion of ${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection_allow_unknown.h was expected to work, but did not.")
endif()
+
+# test for BARE_FEATURES
+
+write_compiler_detection_header(
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection_bare_features.h"
+ PREFIX TEST
+ COMPILERS GNU Clang AppleClang MSVC SunPro Intel
+ VERSION 3.1
+ BARE_FEATURES cxx_nullptr cxx_override cxx_noexcept cxx_final
+)
+
+add_executable(WriteCompilerDetectionHeaderBareFeatures main_bare.cpp)
+set_property(TARGET WriteCompilerDetectionHeaderBareFeatures PROPERTY CXX_STANDARD 11)
diff --git a/Tests/Module/WriteCompilerDetectionHeader/compile_tests.h b/Tests/Module/WriteCompilerDetectionHeader/compile_tests.h
index d3c2a2d39..0da8bab94 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/compile_tests.h
+++ b/Tests/Module/WriteCompilerDetectionHeader/compile_tests.h
@@ -7,21 +7,21 @@
JOIN(EXPECTED_COMPILER_, FEATURE))
#if !CHECK(CXX_DELEGATING_CONSTRUCTORS)
-#error cxx_delegating_constructors expected availability did not match.
+# error cxx_delegating_constructors expected availability did not match.
#endif
#if !CHECK(CXX_VARIADIC_TEMPLATES)
-#error cxx_variadic_templates expected availability did not match.
+# error cxx_variadic_templates expected availability did not match.
#endif
#if !CHECK(VERSION_MAJOR)
-#error Compiler major version did not match.
+# error Compiler major version did not match.
#endif
#if !CHECK(VERSION_MINOR)
-#error Compiler minor version did not match.
+# error Compiler minor version did not match.
#endif
#if !CHECK(VERSION_PATCH)
-#error Compiler patch version did not match.
+# error Compiler patch version did not match.
#endif
diff --git a/Tests/Module/WriteCompilerDetectionHeader/main.c b/Tests/Module/WriteCompilerDetectionHeader/main.c
index ee6abdb92..3420c6750 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/main.c
+++ b/Tests/Module/WriteCompilerDetectionHeader/main.c
@@ -3,25 +3,25 @@
#if !defined(TEST_COMPILER_C_FUNCTION_PROTOTYPES) || \
!TEST_COMPILER_C_FUNCTION_PROTOTYPES
-#error Expected TEST_COMPILER_C_FUNCTION_PROTOTYPES
+# error Expected TEST_COMPILER_C_FUNCTION_PROTOTYPES
#endif
#if !EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES
-#error Expected EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES
+# error Expected EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES
#endif
#if !defined(TEST_COMPILER_C_RESTRICT) || !TEST_COMPILER_C_RESTRICT
-#if EXPECTED_COMPILER_C_RESTRICT
-#error Expected TEST_COMPILER_C_RESTRICT
-#endif
+# if EXPECTED_COMPILER_C_RESTRICT
+# error Expected TEST_COMPILER_C_RESTRICT
+# endif
#else
-#if !EXPECTED_COMPILER_C_RESTRICT
-#error Expect no TEST_COMPILER_C_RESTRICT
-#endif
+# if !EXPECTED_COMPILER_C_RESTRICT
+# error Expect no TEST_COMPILER_C_RESTRICT
+# endif
#endif
#ifdef TEST_COMPILER_CXX_STATIC_ASSERT
-#error Expect no CXX features defined
+# error Expect no CXX features defined
#endif
int main()
diff --git a/Tests/Module/WriteCompilerDetectionHeader/main.cpp b/Tests/Module/WriteCompilerDetectionHeader/main.cpp
index 9979cbae6..97116a5a8 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/main.cpp
+++ b/Tests/Module/WriteCompilerDetectionHeader/main.cpp
@@ -5,7 +5,7 @@
#include "compile_tests.h"
#ifdef TEST_COMPILER_C_STATIC_ASSERT
-#error Expect no C features defined
+# error Expect no C features defined
#endif
TEST_STATIC_ASSERT(true);
diff --git a/Tests/Module/WriteCompilerDetectionHeader/main_bare.cpp b/Tests/Module/WriteCompilerDetectionHeader/main_bare.cpp
new file mode 100644
index 000000000..6954318a2
--- /dev/null
+++ b/Tests/Module/WriteCompilerDetectionHeader/main_bare.cpp
@@ -0,0 +1,23 @@
+#include "test_compiler_detection_bare_features.h"
+
+class base
+{
+public:
+ virtual ~base() {}
+ virtual void baz() = 0;
+};
+
+class foo final
+{
+public:
+ virtual ~foo() {}
+ char* bar;
+ void baz() noexcept override { bar = nullptr; }
+};
+
+int main()
+{
+ foo f;
+
+ return 0;
+}
diff --git a/Tests/Module/WriteCompilerDetectionHeader/main_multi.c b/Tests/Module/WriteCompilerDetectionHeader/main_multi.c
index 6e13fd762..28f9daea2 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/main_multi.c
+++ b/Tests/Module/WriteCompilerDetectionHeader/main_multi.c
@@ -3,25 +3,25 @@
#if !defined(MULTI_COMPILER_C_FUNCTION_PROTOTYPES) || \
!MULTI_COMPILER_C_FUNCTION_PROTOTYPES
-#error Expected MULTI_COMPILER_C_FUNCTION_PROTOTYPES
+# error Expected MULTI_COMPILER_C_FUNCTION_PROTOTYPES
#endif
#if !EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES
-#error Expected EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES
+# error Expected EXPECTED_COMPILER_C_FUNCTION_PROTOTYPES
#endif
#if !defined(MULTI_COMPILER_C_RESTRICT) || !MULTI_COMPILER_C_RESTRICT
-#if EXPECTED_COMPILER_C_RESTRICT
-#error Expected MULTI_COMPILER_C_RESTRICT
-#endif
+# if EXPECTED_COMPILER_C_RESTRICT
+# error Expected MULTI_COMPILER_C_RESTRICT
+# endif
#else
-#if !EXPECTED_COMPILER_C_RESTRICT
-#error Expect no MULTI_COMPILER_C_RESTRICT
-#endif
+# if !EXPECTED_COMPILER_C_RESTRICT
+# error Expect no MULTI_COMPILER_C_RESTRICT
+# endif
#endif
#ifdef MULTI_COMPILER_CXX_STATIC_ASSERT
-#error Expect no CXX features defined
+# error Expect no CXX features defined
#endif
int main()
diff --git a/Tests/Module/WriteCompilerDetectionHeader/multi_files.cpp b/Tests/Module/WriteCompilerDetectionHeader/multi_files.cpp
index d1f178f7c..44f4d17c7 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/multi_files.cpp
+++ b/Tests/Module/WriteCompilerDetectionHeader/multi_files.cpp
@@ -5,7 +5,7 @@
#include "compile_tests.h"
#ifdef MULTI_COMPILER_C_STATIC_ASSERT
-#error Expect no C features defined
+# error Expect no C features defined
#endif
MULTI_STATIC_ASSERT(true);
diff --git a/Tests/ModuleDefinition/example_mod_1.c b/Tests/ModuleDefinition/example_mod_1.c
index 6b355cf6b..8afdb31e7 100644
--- a/Tests/ModuleDefinition/example_mod_1.c
+++ b/Tests/ModuleDefinition/example_mod_1.c
@@ -1,7 +1,7 @@
#ifdef __WATCOMC__
-#define MODULE_CCONV __cdecl
+# define MODULE_CCONV __cdecl
#else
-#define MODULE_CCONV
+# define MODULE_CCONV
#endif
int __declspec(dllimport) example_exe_function(void);
diff --git a/Tests/MumpsCoverage/.gitattributes b/Tests/MumpsCoverage/.gitattributes
index b6806125d..9fc9b0ff2 100644
--- a/Tests/MumpsCoverage/.gitattributes
+++ b/Tests/MumpsCoverage/.gitattributes
@@ -1,2 +1 @@
-*.cmcov -crlf -whitespace
-*.mcov -crlf -whitespace
+*.cmcov eol=crlf
diff --git a/Tests/MumpsCoverage/VistA-FOIA/Packages/Uncategorized/ZZCOVTST.m b/Tests/MumpsCoverage/VistA-FOIA/Packages/Uncategorized/ZZCOVTST.m
index ee7068240..5567c4eef 100644
--- a/Tests/MumpsCoverage/VistA-FOIA/Packages/Uncategorized/ZZCOVTST.m
+++ b/Tests/MumpsCoverage/VistA-FOIA/Packages/Uncategorized/ZZCOVTST.m
@@ -12,6 +12,9 @@ EN ; This entry point shouldn't be found without fixing
; This line not executable
D T6^ZZCOVTST
;
+% ; a line to test for a problem where % was dropped
+ N Do,Re,Mi
+ S Do="A#"
T1 ; This line should always be found
N D
S D=2
diff --git a/Tests/MumpsCoverage/ZZCOVTST.cmcov b/Tests/MumpsCoverage/ZZCOVTST.cmcov
index 7a5df6105..12f2aa6eb 100644
--- a/Tests/MumpsCoverage/ZZCOVTST.cmcov
+++ b/Tests/MumpsCoverage/ZZCOVTST.cmcov
@@ -1,45 +1,48 @@
-Routine,Line,RtnLine,Code
-ZZCOVTST,1,1,"ZZCOVTST;OSEHRA/JPS -- Test routine for Coverage Parsing;4/28/2014"
-,2,0," ; (tab) This is series of comments"
-,3,0," ; (tab) it should all be not executable"
-,4,0," ; (spaces) one of these sets might be a problem"
-,5,0," ; (spaces) we will have to see."
-,6,0,"EN ; This entry point shouldn't be found without fixing"
-,7,1," N D"
-,8,1," S D=1 ;An executable line"
-,9,1," D T1^ZZCOVTST"
-,10,1," I '$$T5 W ""RETURNED FROM t5"",!"
-,11,1," D T6^ZZCOVTST"
-,12,1," Q"
-,13,0," ; This line not executable"
-,14,0," ;"
-,15,0,"T1 ; This line should always be found"
-,16,1," N D"
-,17,1," S D=2"
-,18,1," W !,D,!,""This is the second entry point"",!"
-,19,1," D T2^ZZCOVTST(D)"
-,20,1," Q"
-,21,0," ;"
-,22,0,"T2(EQ) ; This is debatable and only called with ENT^ROU notation"
-,23,1," N D"
-,24,1," S D=3"
-,25,1," W !,D,!,EQ,""This is the third entry point"",!"
-,26,1," D T3^ZZCOVTST"
-,27,1," Q"
-,28,0," ;"
-,29,1,"T3 N D S D=4 W D,!,""Fourth Entry point"",! Q"
-,30,0," ;"
-,31,0,"T4 N D S D=5 W ""Shouldn't be executed"""
-,32,0," W ""Lots to not do"""
-,33,0," Q"
-,34,1,"T5(EQ) ;this entry point is called with a $$ notation"
-,35,1," W ""THIS IS THE $$ NOTATION!"",!"
-,36,1," Q 0"
-,37,0,"T6 ; An entry point to show comments inside of ""DO"" blocks"
-,38,1," D"
-,39,1," . W ""This is executable code"",!"
-,40,0," . ; This is a comment inside the do block, not executable"
-,41,1," . S ZZBLAH=""blah"""
-,42,1," W ""Ending T6"",!"
-,43,0," ;"
-Totals for ZZCOVTST,,25, \ No newline at end of file
+Routine,Line,RtnLine,Code
+ZZCOVTST,1,1,"ZZCOVTST;OSEHRA/JPS -- Test routine for Coverage Parsing;4/28/2014"
+,2,0," ; (tab) This is series of comments"
+,3,0," ; (tab) it should all be not executable"
+,4,0," ; (spaces) one of these sets might be a problem"
+,5,0," ; (spaces) we will have to see."
+,6,0,"EN ; This entry point shouldn't be found without fixing"
+,7,1," N D"
+,8,1," S D=1 ;An executable line"
+,9,1," D T1^ZZCOVTST"
+,10,1," I '$$T5 W ""RETURNED FROM t5"",!"
+,11,1," D T6^ZZCOVTST"
+,12,1," Q"
+,13,0," ; This line not executable"
+,14,0," ;"
+,15,1,"% ; a line to test for a problem where % was dropped"
+,16,1,"N Do,Re,Mi"
+,17,1,"S Do=""A#"""
+,18,0,"T1 ; This line should always be found"
+,19,1," N D"
+,20,1," S D=2"
+,21,1," W !,D,!,""This is the second entry point"",!"
+,22,1," D T2^ZZCOVTST(D)"
+,23,1," Q"
+,24,0," ;"
+,25,0,"T2(EQ) ; This is debatable and only called with ENT^ROU notation"
+,26,1," N D"
+,27,1," S D=3"
+,28,1," W !,D,!,EQ,""This is the third entry point"",!"
+,29,1," D T3^ZZCOVTST"
+,30,1," Q"
+,31,0," ;"
+,32,1,"T3 N D S D=4 W D,!,""Fourth Entry point"",! Q"
+,33,0," ;"
+,34,0,"T4 N D S D=5 W ""Shouldn't be executed"""
+,35,0," W ""Lots to not do"""
+,36,0," Q"
+,37,1,"T5(EQ) ;this entry point is called with a $$ notation"
+,38,1," W ""THIS IS THE $$ NOTATION!"",!"
+,39,1," Q 0"
+,40,0,"T6 ; An entry point to show comments inside of ""DO"" blocks"
+,41,1," D"
+,42,1," . W ""This is executable code"",!"
+,43,0," . ; This is a comment inside the do block, not executable"
+,44,1," . S ZZBLAH=""blah"""
+,45,1," W ""Ending T6"",!"
+,46,0," ;"
+Toals for ZZCOVTST,,28,
diff --git a/Tests/MumpsCoverage/ZZCOVTST.mcov b/Tests/MumpsCoverage/ZZCOVTST.mcov
index b2608d952..e1fa18cad 100644
--- a/Tests/MumpsCoverage/ZZCOVTST.mcov
+++ b/Tests/MumpsCoverage/ZZCOVTST.mcov
@@ -9,6 +9,9 @@ GT.M 15-AUG-2014 10:14:32 ZWR
^ZZCOVERAGE("ZZCOVTST","EN",4)="1:0:0:0:74"
^ZZCOVERAGE("ZZCOVTST","EN",5)="1:0:0:0:66"
^ZZCOVERAGE("ZZCOVTST","EN",6)="1:0:0:0:40"
+^ZZCOVERAGE("ZZCOVTST","%")="2:0:0:0:208"
+^ZZCOVERAGE("ZZCOVTST","%",1)="2:0:0:0:208"
+^ZZCOVERAGE("ZZCOVTST","%",2)="2:0:0:0:208"
^ZZCOVERAGE("ZZCOVTST","T1")="1:0:0:0:208"
^ZZCOVERAGE("ZZCOVTST","T1",1)="1:0:0:0:23"
^ZZCOVERAGE("ZZCOVTST","T1",2)="1:0:0:0:24"
diff --git a/Tests/NewlineArgs/cxxonly.cxx b/Tests/NewlineArgs/cxxonly.cxx
index 9e6f91820..33b26dc29 100644
--- a/Tests/NewlineArgs/cxxonly.cxx
+++ b/Tests/NewlineArgs/cxxonly.cxx
@@ -1,8 +1,8 @@
+#include <stdio.h>
+
#include "libcxx1.h"
#include "libcxx2.h"
-#include <stdio.h>
-
int main()
{
if (LibCxx1Class::Method() != 2.0) {
diff --git a/Tests/NewlineArgs/libcxx1.cxx b/Tests/NewlineArgs/libcxx1.cxx
index 72f171d5c..b3c219247 100644
--- a/Tests/NewlineArgs/libcxx1.cxx
+++ b/Tests/NewlineArgs/libcxx1.cxx
@@ -1,10 +1,10 @@
#include "libcxx1.h"
#ifdef TEST_FLAG_1
-#ifdef TEST_FLAG_2
+# ifdef TEST_FLAG_2
float LibCxx1Class::Method()
{
return 2.0;
}
-#endif
+# endif
#endif
diff --git a/Tests/NewlineArgs/libcxx1.h b/Tests/NewlineArgs/libcxx1.h
index ea094d758..8bb09cdc2 100644
--- a/Tests/NewlineArgs/libcxx1.h
+++ b/Tests/NewlineArgs/libcxx1.h
@@ -2,8 +2,8 @@ class LibCxx1Class
{
public:
#ifdef TEST_FLAG_1
-#ifdef TEST_FLAG_2
+# ifdef TEST_FLAG_2
static float Method();
-#endif
+# endif
#endif
};
diff --git a/Tests/ObjC++/CMakeLists.txt b/Tests/ObjC++/CMakeLists.txt
deleted file mode 100644
index 8b1563ed8..000000000
--- a/Tests/ObjC++/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# a simple objc++ test case that uses Cocoa framework
-project (ObjC++)
-
-add_executable (ObjC++ objc++.mm)
-target_link_libraries(ObjC++ "-framework Cocoa")
-
diff --git a/Tests/ObjC/CMakeLists.txt b/Tests/ObjC/CMakeLists.txt
new file mode 100644
index 000000000..ce3033c03
--- /dev/null
+++ b/Tests/ObjC/CMakeLists.txt
@@ -0,0 +1,4 @@
+ADD_TEST_MACRO(ObjC.simple-build-test simple-build-test)
+ADD_TEST_MACRO(ObjC.c-file-extension-test c-file-extension-test)
+ADD_TEST_MACRO(ObjC.cxx-file-extension-test cxx-file-extension-test)
+ADD_TEST_MACRO(ObjC.objc-file-extension-test objc-file-extension-test)
diff --git a/Tests/ObjC/c-file-extension-test/CMakeLists.txt b/Tests/ObjC/c-file-extension-test/CMakeLists.txt
new file mode 100644
index 000000000..e09144820
--- /dev/null
+++ b/Tests/ObjC/c-file-extension-test/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.15)
+
+project(c-file-extension-test C)
+
+add_executable(c-file-extension-test main.m)
diff --git a/Tests/ObjC/c-file-extension-test/main.m b/Tests/ObjC/c-file-extension-test/main.m
new file mode 100644
index 000000000..1c159a9af
--- /dev/null
+++ b/Tests/ObjC/c-file-extension-test/main.m
@@ -0,0 +1,8 @@
+#ifndef __OBJC__
+# error "Compiler cannot compile Objective-C"
+#endif
+
+int main()
+{
+ return 0;
+}
diff --git a/Tests/ObjC/cxx-file-extension-test/CMakeLists.txt b/Tests/ObjC/cxx-file-extension-test/CMakeLists.txt
new file mode 100644
index 000000000..eb065e46d
--- /dev/null
+++ b/Tests/ObjC/cxx-file-extension-test/CMakeLists.txt
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.15)
+
+project(cxx-file-extension-test)
+
+string(APPEND CMAKE_CXX_FLAGS " -std=c++11")
+set(CMAKE_CXX_STANDARD 14)
+
+add_executable(cxx-file-extension-test main.m)
diff --git a/Tests/ObjC/cxx-file-extension-test/main.m b/Tests/ObjC/cxx-file-extension-test/main.m
new file mode 100644
index 000000000..1c159a9af
--- /dev/null
+++ b/Tests/ObjC/cxx-file-extension-test/main.m
@@ -0,0 +1,8 @@
+#ifndef __OBJC__
+# error "Compiler cannot compile Objective-C"
+#endif
+
+int main()
+{
+ return 0;
+}
diff --git a/Tests/ObjC/objc-file-extension-test/CMakeLists.txt b/Tests/ObjC/objc-file-extension-test/CMakeLists.txt
new file mode 100644
index 000000000..27e88be68
--- /dev/null
+++ b/Tests/ObjC/objc-file-extension-test/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.15)
+
+project(objc-file-extension-test OBJC CXX)
+
+add_executable(objc-file-extension-test main.m)
+target_link_libraries(objc-file-extension-test "-framework Foundation")
diff --git a/Tests/ObjC/objc-file-extension-test/main.m b/Tests/ObjC/objc-file-extension-test/main.m
new file mode 100644
index 000000000..2ec391704
--- /dev/null
+++ b/Tests/ObjC/objc-file-extension-test/main.m
@@ -0,0 +1,12 @@
+#ifndef __OBJC__
+# error "Compiler is not an Objective-C compiler."
+#endif
+
+#import <Foundation/Foundation.h>
+
+int main()
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [pool release];
+ return 0;
+}
diff --git a/Tests/ObjC/simple-build-test/CMakeLists.txt b/Tests/ObjC/simple-build-test/CMakeLists.txt
new file mode 100644
index 000000000..5ab46acd7
--- /dev/null
+++ b/Tests/ObjC/simple-build-test/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.15)
+
+set(CMAKE_MACOSX_RPATH OFF)
+
+project(simple-build-test OBJC)
+
+add_library(foo SHARED foo.m)
+target_link_libraries(foo "-framework Foundation")
+
+add_executable(simple-build-test main.m)
+target_link_libraries(simple-build-test "-framework Foundation" foo)
diff --git a/Tests/ObjC/simple-build-test/foo.h b/Tests/ObjC/simple-build-test/foo.h
new file mode 100644
index 000000000..b3fb084c1
--- /dev/null
+++ b/Tests/ObjC/simple-build-test/foo.h
@@ -0,0 +1,9 @@
+#import <Foundation/Foundation.h>
+
+@interface Foo : NSObject {
+ NSNumber* age;
+}
+
+@property (nonatomic, retain) NSNumber* age;
+
+@end
diff --git a/Tests/ObjC/simple-build-test/foo.m b/Tests/ObjC/simple-build-test/foo.m
new file mode 100644
index 000000000..2d452a8e5
--- /dev/null
+++ b/Tests/ObjC/simple-build-test/foo.m
@@ -0,0 +1,7 @@
+#import "foo.h"
+
+@implementation Foo
+
+@synthesize age;
+
+@end
diff --git a/Tests/ObjC/simple-build-test/main.m b/Tests/ObjC/simple-build-test/main.m
new file mode 100644
index 000000000..970d5548e
--- /dev/null
+++ b/Tests/ObjC/simple-build-test/main.m
@@ -0,0 +1,12 @@
+#import <Foundation/Foundation.h>
+#import "foo.h"
+
+int main(int argc, char **argv)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ Foo *theFoo = [[Foo alloc] init];
+ theFoo.age = [NSNumber numberWithInt:argc];
+ NSLog(@"%d\n",[theFoo.age intValue]);
+ [pool release];
+ return 0;
+}
diff --git a/Tests/ObjCXX/CMakeLists.txt b/Tests/ObjCXX/CMakeLists.txt
new file mode 100644
index 000000000..a2a907a67
--- /dev/null
+++ b/Tests/ObjCXX/CMakeLists.txt
@@ -0,0 +1,4 @@
+ADD_TEST_MACRO(ObjCXX.ObjC++ ObjC++)
+ADD_TEST_MACRO(ObjCXX.simple-build-test simple-build-test)
+ADD_TEST_MACRO(ObjCXX.cxx-file-extension-test cxx-file-extension-test)
+ADD_TEST_MACRO(ObjCXX.objcxx-file-extension-test objcxx-file-extension-test)
diff --git a/Tests/ObjCXX/ObjC++/CMakeLists.txt b/Tests/ObjCXX/ObjC++/CMakeLists.txt
new file mode 100644
index 000000000..5ba5db2ed
--- /dev/null
+++ b/Tests/ObjCXX/ObjC++/CMakeLists.txt
@@ -0,0 +1,5 @@
+# a simple objc++ test case that uses Cocoa framework
+project (ObjC++)
+
+add_executable (ObjC++ objc++.mm)
+target_link_libraries(ObjC++ "-framework Cocoa")
diff --git a/Tests/ObjC++/objc++.mm b/Tests/ObjCXX/ObjC++/objc++.mm
index 258ebaa52..258ebaa52 100644
--- a/Tests/ObjC++/objc++.mm
+++ b/Tests/ObjCXX/ObjC++/objc++.mm
diff --git a/Tests/ObjCXX/cxx-file-extension-test/CMakeLists.txt b/Tests/ObjCXX/cxx-file-extension-test/CMakeLists.txt
new file mode 100644
index 000000000..0b33875d9
--- /dev/null
+++ b/Tests/ObjCXX/cxx-file-extension-test/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.15)
+
+project(cxx-file-extension-test CXX)
+
+add_executable(cxx-file-extension-test main.mm)
diff --git a/Tests/ObjCXX/cxx-file-extension-test/main.mm b/Tests/ObjCXX/cxx-file-extension-test/main.mm
new file mode 100644
index 000000000..1c159a9af
--- /dev/null
+++ b/Tests/ObjCXX/cxx-file-extension-test/main.mm
@@ -0,0 +1,8 @@
+#ifndef __OBJC__
+# error "Compiler cannot compile Objective-C"
+#endif
+
+int main()
+{
+ return 0;
+}
diff --git a/Tests/ObjCXX/objcxx-file-extension-test/CMakeLists.txt b/Tests/ObjCXX/objcxx-file-extension-test/CMakeLists.txt
new file mode 100644
index 000000000..eda7bbaeb
--- /dev/null
+++ b/Tests/ObjCXX/objcxx-file-extension-test/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.15)
+
+project(objcxx-file-extension-test OBJCXX CXX)
+
+add_executable(objcxx-file-extension-test main.mm)
+target_link_libraries(objcxx-file-extension-test "-framework Foundation")
diff --git a/Tests/ObjCXX/objcxx-file-extension-test/main.mm b/Tests/ObjCXX/objcxx-file-extension-test/main.mm
new file mode 100644
index 000000000..d4aa1bba3
--- /dev/null
+++ b/Tests/ObjCXX/objcxx-file-extension-test/main.mm
@@ -0,0 +1,14 @@
+#ifndef __OBJC__
+# error "Compiler is not an Objective-C compiler."
+#endif
+
+#import <Foundation/Foundation.h>
+#include <iostream>
+
+int main()
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ std::cout << "Hello World" << std::endl;
+ [pool release];
+ return 0;
+}
diff --git a/Tests/ObjCXX/simple-build-test/CMakeLists.txt b/Tests/ObjCXX/simple-build-test/CMakeLists.txt
new file mode 100644
index 000000000..cf276834a
--- /dev/null
+++ b/Tests/ObjCXX/simple-build-test/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.15)
+
+set(CMAKE_MACOSX_RPATH OFF)
+
+project(simple-build-test OBJCXX)
+
+add_library(foo SHARED foo.mm)
+target_link_libraries(foo "-framework Foundation")
+
+add_executable(simple-build-test main.mm)
+target_link_libraries(simple-build-test "-framework Foundation" foo)
diff --git a/Tests/ObjCXX/simple-build-test/foo.h b/Tests/ObjCXX/simple-build-test/foo.h
new file mode 100644
index 000000000..b3fb084c1
--- /dev/null
+++ b/Tests/ObjCXX/simple-build-test/foo.h
@@ -0,0 +1,9 @@
+#import <Foundation/Foundation.h>
+
+@interface Foo : NSObject {
+ NSNumber* age;
+}
+
+@property (nonatomic, retain) NSNumber* age;
+
+@end
diff --git a/Tests/ObjCXX/simple-build-test/foo.mm b/Tests/ObjCXX/simple-build-test/foo.mm
new file mode 100644
index 000000000..2d452a8e5
--- /dev/null
+++ b/Tests/ObjCXX/simple-build-test/foo.mm
@@ -0,0 +1,7 @@
+#import "foo.h"
+
+@implementation Foo
+
+@synthesize age;
+
+@end
diff --git a/Tests/ObjCXX/simple-build-test/main.mm b/Tests/ObjCXX/simple-build-test/main.mm
new file mode 100644
index 000000000..7c85551f0
--- /dev/null
+++ b/Tests/ObjCXX/simple-build-test/main.mm
@@ -0,0 +1,14 @@
+#import <Foundation/Foundation.h>
+#import "foo.h"
+#include <iostream>
+
+int main(int argc, char **argv)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ Foo *theFoo = [[Foo alloc] init];
+ theFoo.age = [NSNumber numberWithInt:argc];
+ NSLog(@"%d\n",[theFoo.age intValue]);
+ std::cout << [theFoo.age intValue] << std::endl;
+ [pool release];
+ return 0;
+}
diff --git a/Tests/ObjectLibrary/A/a.h b/Tests/ObjectLibrary/A/a.h
index b1fd42fac..184df3ced 100644
--- a/Tests/ObjectLibrary/A/a.h
+++ b/Tests/ObjectLibrary/A/a.h
@@ -1,6 +1,6 @@
#ifndef A_DEF
-#error "A_DEF not defined"
+# error "A_DEF not defined"
#endif
#ifdef B_DEF
-#error "B_DEF must not be defined"
+# error "B_DEF must not be defined"
#endif
diff --git a/Tests/ObjectLibrary/B/b.h b/Tests/ObjectLibrary/B/b.h
index a7bd35230..de81d69f2 100644
--- a/Tests/ObjectLibrary/B/b.h
+++ b/Tests/ObjectLibrary/B/b.h
@@ -1,18 +1,18 @@
#ifdef A_DEF
-#error "A_DEF must not be defined"
+# error "A_DEF must not be defined"
#endif
#ifndef B_DEF
-#error "B_DEF not defined"
+# error "B_DEF not defined"
#endif
#if defined(_WIN32) && defined(Bexport)
-#define EXPORT_B __declspec(dllexport)
+# define EXPORT_B __declspec(dllexport)
#else
-#define EXPORT_B
+# define EXPORT_B
#endif
#if defined(_WIN32) && defined(SHARED_B)
-#define IMPORT_B __declspec(dllimport)
+# define IMPORT_B __declspec(dllimport)
#else
-#define IMPORT_B
+# define IMPORT_B
#endif
diff --git a/Tests/ObjectLibrary/CMakeLists.txt b/Tests/ObjectLibrary/CMakeLists.txt
index 4bffd1221..7897ab99b 100644
--- a/Tests/ObjectLibrary/CMakeLists.txt
+++ b/Tests/ObjectLibrary/CMakeLists.txt
@@ -62,4 +62,14 @@ add_custom_target(UseABinternalDep COMMAND ${CMAKE_COMMAND} -E touch UseABintern
add_custom_command(TARGET UseABinternal POST_BUILD COMMAND ${CMAKE_COMMAND} -P UseABinternalDep.cmake)
add_dependencies(UseABinternal UseABinternalDep)
+# Test a static library with sources from a different static library
+add_library(UseCstaticObjs STATIC $<TARGET_OBJECTS:Cstatic> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:Bexport>)
+
+# Test a shared library with sources from a different shared library
+add_library(UseCsharedObjs SHARED $<TARGET_OBJECTS:Cshared> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:Bexport>)
+
+# Test a shared executable with sources from a different shared library
+add_executable(UseABstaticObjs $<TARGET_OBJECTS:UseABstatic>)
+target_link_libraries(UseABstaticObjs ABstatic)
+
add_subdirectory(ExportLanguages)
diff --git a/Tests/ObjectLibrary/c.c b/Tests/ObjectLibrary/c.c
index 4c37e38b2..2692899cc 100644
--- a/Tests/ObjectLibrary/c.c
+++ b/Tests/ObjectLibrary/c.c
@@ -1,7 +1,7 @@
#if defined(_WIN32) && defined(Cshared_EXPORTS)
-#define EXPORT_C __declspec(dllexport)
+# define EXPORT_C __declspec(dllexport)
#else
-#define EXPORT_C
+# define EXPORT_C
#endif
extern int a1(void);
diff --git a/Tests/ObjectLibrary/main.c b/Tests/ObjectLibrary/main.c
index b2f1d44bd..cc7568527 100644
--- a/Tests/ObjectLibrary/main.c
+++ b/Tests/ObjectLibrary/main.c
@@ -1,7 +1,7 @@
#if defined(_WIN32) && defined(SHARED_C)
-#define IMPORT_C __declspec(dllimport)
+# define IMPORT_C __declspec(dllimport)
#else
-#define IMPORT_C
+# define IMPORT_C
#endif
extern IMPORT_C int b1(void);
extern IMPORT_C int b2(void);
diff --git a/Tests/OutDir/CMakeLists.txt b/Tests/OutDir/CMakeLists.txt
index 88468c3c0..823ab0864 100644
--- a/Tests/OutDir/CMakeLists.txt
+++ b/Tests/OutDir/CMakeLists.txt
@@ -1,7 +1,8 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.9)
project(OutDir C)
-if(CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
foreach(config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${config}" CONFIG)
list(APPEND configs "${CONFIG}")
diff --git a/Tests/OutName/CMakeLists.txt b/Tests/OutName/CMakeLists.txt
new file mode 100644
index 000000000..f024defc2
--- /dev/null
+++ b/Tests/OutName/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.12)
+project(OutName C)
+
+add_executable(OutName main.c)
+set_property(TARGET OutName PROPERTY PREFIX exe.)
+set_property(TARGET OutName PROPERTY SUFFIX .exe)
diff --git a/Tests/OutName/main.c b/Tests/OutName/main.c
new file mode 100644
index 000000000..8488f4e58
--- /dev/null
+++ b/Tests/OutName/main.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/OutOfSource/CMakeLists.txt b/Tests/OutOfSource/CMakeLists.txt
index de1603a55..4687882aa 100644
--- a/Tests/OutOfSource/CMakeLists.txt
+++ b/Tests/OutOfSource/CMakeLists.txt
@@ -1,4 +1,4 @@
-# a simple test cas
+# a simple test case
cmake_minimum_required (VERSION 2.6)
project (OutOfSource)
diff --git a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt
index 10a2f59d1..76a93d24a 100644
--- a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt
+++ b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt
@@ -16,11 +16,11 @@ if ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}")
# Use a separate variable for computation.
set(MAXPATH "${CMAKE_OBJECT_PATH_MAX}")
- # VS8 adds "OutOfSource/SubDir/OutOfSourceSubdir/../../../" to the
+ # VS adds "OutOfSource/SubDir/OutOfSourceSubdir/../../../" to the
# path of the source file for no good reason. Reduce the length
# limit by 46 characters to account for it. It should still be long
# enough to require special object file name conversion.
- if(${CMAKE_GENERATOR} MATCHES "Visual Studio (8|10)")
+ if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
math(EXPR MAXPATH "${MAXPATH} - 46")
endif()
diff --git a/Tests/OutOfSource/OutOfSourceSubdir/testlib.h b/Tests/OutOfSource/OutOfSourceSubdir/testlib.h
index bacf5a109..3e012d252 100644
--- a/Tests/OutOfSource/OutOfSourceSubdir/testlib.h
+++ b/Tests/OutOfSource/OutOfSourceSubdir/testlib.h
@@ -1,11 +1,11 @@
#ifdef _WIN32
-#ifdef testlib_EXPORTS
-#define CM_TEST_LIB_EXPORT __declspec(dllexport)
+# ifdef testlib_EXPORTS
+# define CM_TEST_LIB_EXPORT __declspec(dllexport)
+# else
+# define CM_TEST_LIB_EXPORT __declspec(dllimport)
+# endif
#else
-#define CM_TEST_LIB_EXPORT __declspec(dllimport)
-#endif
-#else
-#define CM_TEST_LIB_EXPORT
+# define CM_TEST_LIB_EXPORT
#endif
CM_TEST_LIB_EXPORT float TestLib();
diff --git a/Tests/PDBDirectoryAndName/CMakeLists.txt b/Tests/PDBDirectoryAndName/CMakeLists.txt
index 2fb894ed8..44194ca1a 100644
--- a/Tests/PDBDirectoryAndName/CMakeLists.txt
+++ b/Tests/PDBDirectoryAndName/CMakeLists.txt
@@ -3,8 +3,8 @@ cmake_policy(SET CMP0054 NEW)
project(PDBDirectoryAndName C)
# Make sure the proper compiler is in use.
-if(NOT MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
- message(FATAL_ERROR "The PDBDirectoryAndName test works only with MSVC or Intel")
+if(NOT MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "Intel" AND NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ message(FATAL_ERROR "The PDBDirectoryAndName test works only with MSVC, Clang or Intel")
endif()
# Intel 11.1 does not support /Fd but Intel 14.0 does.
@@ -19,7 +19,7 @@ set(my_targets "")
add_library(mylibA SHARED mylibA.c)
set_target_properties(mylibA PROPERTIES
PDB_NAME "mylibA_Special"
- PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibA_PDB"
+ PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibA_PDB/$<CONFIG>"
)
list(APPEND my_targets mylibA)
@@ -87,7 +87,13 @@ foreach(t ${my_targets})
if(NOT pdb_dir)
set(pdb_dir ${CMAKE_CURRENT_BINARY_DIR})
endif()
- list(APPEND pdbs ${pdb_dir}/${CMAKE_CFG_INTDIR}/${pdb_name}.pdb)
+ if (pdb_dir MATCHES "\\$<.*>")
+ # Skip per-configuration subdirectory if the value contained
+ # a generator expression.
+ list(APPEND pdbs ${pdb_dir}/${pdb_name}.pdb)
+ else()
+ list(APPEND pdbs ${pdb_dir}/${CMAKE_CFG_INTDIR}/${pdb_name}.pdb)
+ endif()
endforeach()
add_custom_target(check_pdbs ALL VERBATIM
COMMAND ${CMAKE_COMMAND} -Dconfig=$<CONFIGURATION> "-Dpdbs=${pdbs}"
diff --git a/Tests/PerConfig/pcShared.h b/Tests/PerConfig/pcShared.h
index 031cd7965..2ae66cd42 100644
--- a/Tests/PerConfig/pcShared.h
+++ b/Tests/PerConfig/pcShared.h
@@ -2,13 +2,13 @@
#define pcShared_h
#ifdef _WIN32
-#ifdef pcShared_EXPORTS
-#define PC_EXPORT __declspec(dllexport)
+# ifdef pcShared_EXPORTS
+# define PC_EXPORT __declspec(dllexport)
+# else
+# define PC_EXPORT __declspec(dllimport)
+# endif
#else
-#define PC_EXPORT __declspec(dllimport)
-#endif
-#else
-#define PC_EXPORT
+# define PC_EXPORT
#endif
PC_EXPORT const char* pcShared(void);
diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt
index 9e2b4abd9..729bba347 100644
--- a/Tests/Plugin/CMakeLists.txt
+++ b/Tests/Plugin/CMakeLists.txt
@@ -10,13 +10,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/plugin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/static)
-# We need the dynamic loader support from KWSys to load the plugin in
-# the executable.
-set(KWSYS_NAMESPACE kwsys)
-set(KWSYS_HEADER_ROOT ${Plugin_BINARY_DIR}/include)
-set(KWSYS_USE_DynamicLoader 1)
-add_subdirectory(${Plugin_SOURCE_DIR}/../../Source/kwsys src/kwsys)
-
# Configure the location of plugins.
configure_file(${Plugin_SOURCE_DIR}/src/example_exe.h.in
${Plugin_BINARY_DIR}/include/example_exe.h @ONLY)
@@ -28,13 +21,6 @@ include_directories(
${Plugin_SOURCE_DIR}/include
)
-# Those versions of the HP compiler that need a flag to get proper C++98
-# template support also need a flag to use the newer C++ library.
-if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
- CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98")
- string(APPEND CMAKE_CXX_FLAGS " -AA")
-endif ()
-
# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
@@ -42,14 +28,14 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
endif()
# Create an executable that exports an API for use by plugins.
-add_executable(example_exe src/example_exe.cxx)
+add_executable(example_exe src/example_exe.cxx src/DynamicLoader.cxx)
set_target_properties(example_exe PROPERTIES
ENABLE_EXPORTS 1
OUTPUT_NAME example
# Test placing exe import library in unique directory.
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/exe
)
-target_link_libraries(example_exe kwsys)
+target_link_libraries(example_exe ${CMAKE_DL_LIBS})
# Create a plugin that uses the API provided by the executable.
# This module "links" to the executable to use the symbols.
diff --git a/Tests/Plugin/include/DynamicLoader.hxx b/Tests/Plugin/include/DynamicLoader.hxx
new file mode 100644
index 000000000..20b37de16
--- /dev/null
+++ b/Tests/Plugin/include/DynamicLoader.hxx
@@ -0,0 +1,49 @@
+/* Distributed under the OSI-approved BSD 3-Clause License.
+ See https://cmake.org/licensing#kwsys for details. */
+#ifndef DynamicLoader_hxx
+#define DynamicLoader_hxx
+
+#include <string>
+
+#if defined(__hpux)
+# include <dl.h>
+#elif defined(_WIN32) && !defined(__CYGWIN__)
+# include <windows.h>
+#elif defined(__APPLE__)
+# include <AvailabilityMacros.h>
+# if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
+# include <mach-o/dyld.h>
+# endif
+#elif defined(__BEOS__)
+# include <be/kernel/image.h>
+#endif
+
+class DynamicLoader
+{
+public:
+#if defined(__hpux)
+ typedef shl_t LibraryHandle;
+#elif defined(_WIN32) && !defined(__CYGWIN__)
+ typedef HMODULE LibraryHandle;
+#elif defined(__APPLE__)
+# if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
+ typedef NSModule LibraryHandle;
+# else
+ typedef void* LibraryHandle;
+# endif
+#elif defined(__BEOS__)
+ typedef image_id LibraryHandle;
+#else // POSIX
+ typedef void* LibraryHandle;
+#endif
+
+ typedef void (*SymbolPointer)();
+
+ static LibraryHandle OpenLibrary(const std::string&);
+
+ static int CloseLibrary(LibraryHandle);
+
+ static SymbolPointer GetSymbolAddress(LibraryHandle, const std::string&);
+};
+
+#endif
diff --git a/Tests/Plugin/include/example.h b/Tests/Plugin/include/example.h
index 87d992e57..cbcb3dcc3 100644
--- a/Tests/Plugin/include/example.h
+++ b/Tests/Plugin/include/example.h
@@ -2,13 +2,13 @@
#define example_h
#if defined(_WIN32) || defined(__CYGWIN__)
-#if defined(example_exe_EXPORTS)
-#define EXAMPLE_EXPORT __declspec(dllexport)
+# if defined(example_exe_EXPORTS)
+# define EXAMPLE_EXPORT __declspec(dllexport)
+# else
+# define EXAMPLE_EXPORT __declspec(dllimport)
+# endif
#else
-#define EXAMPLE_EXPORT __declspec(dllimport)
-#endif
-#else
-#define EXAMPLE_EXPORT
+# define EXAMPLE_EXPORT
#endif
#ifdef __cplusplus
diff --git a/Tests/Plugin/src/DynamicLoader.cxx b/Tests/Plugin/src/DynamicLoader.cxx
new file mode 100644
index 000000000..d4a26372b
--- /dev/null
+++ b/Tests/Plugin/src/DynamicLoader.cxx
@@ -0,0 +1,263 @@
+/* Distributed under the OSI-approved BSD 3-Clause License.
+ See https://cmake.org/licensing#kwsys for details. */
+#if defined(_WIN32)
+# define NOMINMAX // hide min,max to not conflict with <limits>
+#endif
+
+#include <DynamicLoader.hxx>
+
+#if defined(__hpux)
+# include <dl.h>
+
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
+ const std::string& libname)
+{
+ return shl_load(libname.c_str(), BIND_DEFERRED | DYNAMIC_PATH, 0L);
+}
+
+int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
+{
+ if (!lib) {
+ return 0;
+ }
+ return !shl_unload(lib);
+}
+
+DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
+ DynamicLoader::LibraryHandle lib, const std::string& sym)
+{
+ void* addr;
+ int status;
+
+ /* TYPE_PROCEDURE Look for a function or procedure. (This used to be default)
+ * TYPE_DATA Look for a symbol in the data segment (for example,
+ * variables).
+ * TYPE_UNDEFINED Look for any symbol.
+ */
+ status = shl_findsym(&lib, sym.c_str(), TYPE_UNDEFINED, &addr);
+ void* result = (status < 0) ? (void*)0 : addr;
+
+ // Hack to cast pointer-to-data to pointer-to-function.
+ return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
+}
+
+#elif defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED < 1030)
+# include <mach-o/dyld.h>
+
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
+ const std::string& libname)
+{
+ NSObjectFileImageReturnCode rc;
+ NSObjectFileImage image = 0;
+
+ rc = NSCreateObjectFileImageFromFile(libname.c_str(), &image);
+ // rc == NSObjectFileImageInappropriateFile when trying to load a dylib file
+ if (rc != NSObjectFileImageSuccess) {
+ return 0;
+ }
+ NSModule handle = NSLinkModule(image, libname.c_str(),
+ NSLINKMODULE_OPTION_BINDNOW |
+ NSLINKMODULE_OPTION_RETURN_ON_ERROR);
+ NSDestroyObjectFileImage(image);
+ return handle;
+}
+
+int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
+{
+ bool success = NSUnLinkModule(lib, NSUNLINKMODULE_OPTION_NONE);
+ return success;
+}
+
+DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
+ DynamicLoader::LibraryHandle lib, const std::string& sym)
+{
+ void* result = 0;
+ // Need to prepend symbols with '_' on Apple-gcc compilers
+ std::string rsym = '_' + sym;
+
+ NSSymbol symbol = NSLookupSymbolInModule(lib, rsym.c_str());
+ if (symbol) {
+ result = NSAddressOfSymbol(symbol);
+ }
+
+ // Hack to cast pointer-to-data to pointer-to-function.
+ return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
+}
+
+#elif defined(_WIN32) && !defined(__CYGWIN__)
+# include <windows.h>
+
+# include <stdio.h>
+
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
+ const std::string& libname)
+{
+ DynamicLoader::LibraryHandle lh;
+ int length = MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, NULL, 0);
+ wchar_t* wchars = new wchar_t[length + 1];
+ wchars[0] = '\0';
+ MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, wchars, length);
+ lh = LoadLibraryW(wchars);
+ delete[] wchars;
+ return lh;
+}
+
+int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
+{
+ return (int)FreeLibrary(lib);
+}
+
+DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
+ DynamicLoader::LibraryHandle lib, const std::string& sym)
+{
+ void* result;
+# if defined(__BORLANDC__) || defined(__WATCOMC__)
+ // Need to prepend symbols with '_'
+ std::string ssym = '_' + sym;
+ const char* rsym = ssym.c_str();
+# else
+ const char* rsym = sym.c_str();
+# endif
+ result = (void*)GetProcAddress(lib, rsym);
+// Hack to cast pointer-to-data to pointer-to-function.
+# ifdef __WATCOMC__
+ return *(DynamicLoader::SymbolPointer*)(&result);
+# else
+ return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
+# endif
+}
+
+#elif defined(__BEOS__)
+# include <be/kernel/image.h>
+# include <be/support/Errors.h>
+
+static image_id last_dynamic_err = B_OK;
+
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
+ const std::string& libname)
+{
+ // image_id's are integers, errors are negative. Add one just in case we
+ // get a valid image_id of zero (is that even possible?).
+ image_id rc = load_add_on(libname.c_str());
+ if (rc < 0) {
+ last_dynamic_err = rc;
+ return 0;
+ }
+
+ return rc + 1;
+}
+
+int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
+{
+ if (!lib) {
+ last_dynamic_err = B_BAD_VALUE;
+ return 0;
+ } else {
+ // The function dlclose() returns 0 on success, and non-zero on error.
+ status_t rc = unload_add_on(lib - 1);
+ if (rc != B_OK) {
+ last_dynamic_err = rc;
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
+ DynamicLoader::LibraryHandle lib, const std::string& sym)
+{
+ // Hack to cast pointer-to-data to pointer-to-function.
+ union
+ {
+ void* pvoid;
+ DynamicLoader::SymbolPointer psym;
+ } result;
+
+ result.psym = NULL;
+
+ if (!lib) {
+ last_dynamic_err = B_BAD_VALUE;
+ } else {
+ // !!! FIXME: BeOS can do function-only lookups...does this ever
+ // !!! FIXME: actually _want_ a data symbol lookup, or was this union
+ // !!! FIXME: a leftover of dlsym()? (s/ANY/TEXT for functions only).
+ status_t rc =
+ get_image_symbol(lib - 1, sym.c_str(), B_SYMBOL_TYPE_ANY, &result.pvoid);
+ if (rc != B_OK) {
+ last_dynamic_err = rc;
+ result.psym = NULL;
+ }
+ }
+ return result.psym;
+}
+
+#elif defined(__MINT__)
+# define _GNU_SOURCE /* for program_invocation_name */
+# include <dld.h>
+# include <errno.h>
+# include <malloc.h>
+
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
+ const std::string& libname)
+{
+ char* name = (char*)calloc(1, libname.size() + 1);
+ dld_init(program_invocation_name);
+ strncpy(name, libname.c_str(), libname.size());
+ dld_link(libname.c_str());
+ return (void*)name;
+}
+
+int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
+{
+ dld_unlink_by_file((char*)lib, 0);
+ free(lib);
+ return 0;
+}
+
+DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
+ DynamicLoader::LibraryHandle lib, const std::string& sym)
+{
+ // Hack to cast pointer-to-data to pointer-to-function.
+ union
+ {
+ void* pvoid;
+ DynamicLoader::SymbolPointer psym;
+ } result;
+ result.pvoid = dld_get_symbol(sym.c_str());
+ return result.psym;
+}
+
+#else
+# include <dlfcn.h>
+
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
+ const std::string& libname)
+{
+ return dlopen(libname.c_str(), RTLD_LAZY);
+}
+
+int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
+{
+ if (lib) {
+ // The function dlclose() returns 0 on success, and non-zero on error.
+ return !dlclose(lib);
+ }
+ // else
+ return 0;
+}
+
+DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
+ DynamicLoader::LibraryHandle lib, const std::string& sym)
+{
+ // Hack to cast pointer-to-data to pointer-to-function.
+ union
+ {
+ void* pvoid;
+ DynamicLoader::SymbolPointer psym;
+ } result;
+ result.pvoid = dlsym(lib, sym.c_str());
+ return result.psym;
+}
+
+#endif
diff --git a/Tests/Plugin/src/example_exe.cxx b/Tests/Plugin/src/example_exe.cxx
index 017fbf607..bc4c727f1 100644
--- a/Tests/Plugin/src/example_exe.cxx
+++ b/Tests/Plugin/src/example_exe.cxx
@@ -1,14 +1,12 @@
-#include <kwsys/DynamicLoader.hxx>
-
-#include <example.h>
-
-#include <example_exe.h>
-
#include <iostream>
#include <string>
+#include <example.h>
+#include <example_exe.h>
#include <stdio.h>
+#include "DynamicLoader.hxx"
+
// Implement the ABI used by plugins.
extern "C" int example_exe_function()
{
@@ -17,27 +15,24 @@ extern "C" int example_exe_function()
}
#ifdef CMAKE_INTDIR
-#define CONFIG_DIR "/" CMAKE_INTDIR
+# define CONFIG_DIR "/" CMAKE_INTDIR
#else
-#define CONFIG_DIR ""
+# define CONFIG_DIR ""
#endif
int main()
{
- std::string libName = EXAMPLE_EXE_PLUGIN_DIR CONFIG_DIR "/";
- libName += kwsys::DynamicLoader::LibPrefix();
- libName += "example_mod_1";
- libName += kwsys::DynamicLoader::LibExtension();
- kwsys::DynamicLoader::LibraryHandle handle =
- kwsys::DynamicLoader::OpenLibrary(libName.c_str());
+ std::string const libName = EXAMPLE_EXE_PLUGIN_DIR CONFIG_DIR
+ "/" EXAMPLE_EXE_MOD_PREFIX "example_mod_1" EXAMPLE_EXE_MOD_SUFFIX;
+ DynamicLoader::LibraryHandle handle = DynamicLoader::OpenLibrary(libName);
if (!handle) {
// Leave the .c_str() on this one. It is needed on OpenWatcom.
std::cerr << "Could not open plugin \"" << libName.c_str() << "\"!"
<< std::endl;
return 1;
}
- kwsys::DynamicLoader::SymbolPointer sym =
- kwsys::DynamicLoader::GetSymbolAddress(handle, "example_mod_1_function");
+ DynamicLoader::SymbolPointer sym =
+ DynamicLoader::GetSymbolAddress(handle, "example_mod_1_function");
if (!sym) {
std::cerr << "Could not get plugin symbol \"example_mod_1_function\"!"
<< std::endl;
@@ -52,6 +47,6 @@ int main()
std::cerr << "Incorrect return value from plugin!" << std::endl;
return 1;
}
- kwsys::DynamicLoader::CloseLibrary(handle);
+ DynamicLoader::CloseLibrary(handle);
return 0;
}
diff --git a/Tests/Plugin/src/example_exe.h.in b/Tests/Plugin/src/example_exe.h.in
index 62f0d9f02..af71021a5 100644
--- a/Tests/Plugin/src/example_exe.h.in
+++ b/Tests/Plugin/src/example_exe.h.in
@@ -2,5 +2,7 @@
#define example_exe_h
#define EXAMPLE_EXE_PLUGIN_DIR "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@"
+#define EXAMPLE_EXE_MOD_PREFIX "@CMAKE_SHARED_MODULE_PREFIX@"
+#define EXAMPLE_EXE_MOD_SUFFIX "@CMAKE_SHARED_MODULE_SUFFIX@"
#endif
diff --git a/Tests/Plugin/src/example_mod_1.c b/Tests/Plugin/src/example_mod_1.c
index a5dd9840d..2b740b8db 100644
--- a/Tests/Plugin/src/example_mod_1.c
+++ b/Tests/Plugin/src/example_mod_1.c
@@ -1,17 +1,16 @@
#include <example.h>
-
#include <stdio.h>
#if defined(_WIN32)
-#define MODULE_EXPORT __declspec(dllexport)
+# define MODULE_EXPORT __declspec(dllexport)
#else
-#define MODULE_EXPORT
+# define MODULE_EXPORT
#endif
#ifdef __WATCOMC__
-#define MODULE_CCONV __cdecl
+# define MODULE_CCONV __cdecl
#else
-#define MODULE_CCONV
+# define MODULE_CCONV
#endif
MODULE_EXPORT int MODULE_CCONV example_mod_1_function(int n)
diff --git a/Tests/PolicyScope/CMakeLists.txt b/Tests/PolicyScope/CMakeLists.txt
index 413195a5c..353842bc4 100644
--- a/Tests/PolicyScope/CMakeLists.txt
+++ b/Tests/PolicyScope/CMakeLists.txt
@@ -52,6 +52,10 @@ if(1)
# CMP0002 should be changed when this function is invoked
cmake_policy(GET CMP0002 cmp)
check(CMP0002 "OLD" "${cmp}")
+
+ # The undocumented PARENT_SCOPE option sees the caller's setting.
+ cmake_policy(GET CMP0002 cmp PARENT_SCOPE)
+ check(CMP0002 "NEW" "${cmp}")
endfunction()
# Unset CMP0002
@@ -61,6 +65,10 @@ if(1)
cmake_policy(GET CMP0002 cmp)
check(CMP0002 "" "${cmp}")
+ # The undocumented PARENT_SCOPE option sees the caller's setting.
+ cmake_policy(GET CMP0002 cmp PARENT_SCOPE)
+ check(CMP0002 "NEW" "${cmp}")
+
# Setting the policy should work here and also in the caller.
cmake_policy(SET CMP0002 OLD)
cmake_policy(GET CMP0002 cmp)
diff --git a/Tests/PositionIndependentTargets/.gitattributes b/Tests/PositionIndependentTargets/.gitattributes
index ed36631f4..61b2751cb 100644
--- a/Tests/PositionIndependentTargets/.gitattributes
+++ b/Tests/PositionIndependentTargets/.gitattributes
@@ -1,2 +1,2 @@
# Do not format a source where we want a long line preserved.
-pic_test.h -format.clang-format
+pic_test.h -format.clang-format-6.0
diff --git a/Tests/PrecompiledHeader/CMakeLists.txt b/Tests/PrecompiledHeader/CMakeLists.txt
index a80453892..58f4863b4 100644
--- a/Tests/PrecompiledHeader/CMakeLists.txt
+++ b/Tests/PrecompiledHeader/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 2.6)
+cmake_minimum_required (VERSION 3.9)
project(PrecompiledHeader C)
# Make sure the proper compiler is in use.
@@ -7,7 +7,8 @@ if(NOT MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
endif()
# Compute a custom name for the precompiled header.
-if(CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
set(PCH_DIR "${CMAKE_CURRENT_BINARY_DIR}/PCH/${CMAKE_CFG_INTDIR}")
foreach(cfg ${CMAKE_CONFIGURATION_TYPES})
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/PCH/${cfg})
diff --git a/Tests/PrecompiledHeader/foo1.c b/Tests/PrecompiledHeader/foo1.c
index 77172bae7..fef258612 100644
--- a/Tests/PrecompiledHeader/foo1.c
+++ b/Tests/PrecompiledHeader/foo1.c
@@ -1,5 +1,5 @@
#ifndef foo_h
-#error "Precompiled header foo_precompiled.h has not been loaded."
+# error "Precompiled header foo_precompiled.h has not been loaded."
#endif
int main()
diff --git a/Tests/PrecompiledHeader/foo2.c b/Tests/PrecompiledHeader/foo2.c
index f192e1615..3ed04ed99 100644
--- a/Tests/PrecompiledHeader/foo2.c
+++ b/Tests/PrecompiledHeader/foo2.c
@@ -1,6 +1,6 @@
#ifndef foo_h
-#include "foo.h"
-#error "Precompiled header foo_precompiled.h has not been loaded."
+# include "foo.h"
+# error "Precompiled header foo_precompiled.h has not been loaded."
#endif
int foo()
diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt
index 8c2cdc9e7..bce1b3f07 100644
--- a/Tests/Preprocess/CMakeLists.txt
+++ b/Tests/Preprocess/CMakeLists.txt
@@ -28,6 +28,14 @@ endif()
if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
set(PP_VS 1)
endif()
+if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND
+ "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
+ set(CLANG_MSVC_WINDOWS 1)
+endif()
+if(CLANG_MSVC_WINDOWS AND
+ "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
+ set(CLANG_GNULIKE_WINDOWS 1)
+endif()
# Some tests below check the PP_* variables set above. They are meant
# to test the case that the build tool is at fault. Other tests below
@@ -53,7 +61,7 @@ endif()
string(APPEND STRING_EXTRA " ")
-if(NOT PP_BORLAND AND NOT PP_WATCOM)
+if(NOT PP_BORLAND AND NOT PP_WATCOM AND NOT CLANG_GNULIKE_WINDOWS)
# Borland, WMake: multiple spaces
# The make tool seems to remove extra whitespace from inside
# quoted strings when passing to the compiler. It does not have
@@ -70,14 +78,14 @@ if(NOT PP_VS)
string(APPEND STRING_EXTRA ",")
endif()
-if(NOT PP_MINGW)
+if(NOT PP_MINGW AND NOT CLANG_GNULIKE_WINDOWS)
# MinGW: &
# When inside -D"FOO=\"a & b\"" MinGW make wants -D"FOO=\"a "&" b\""
# but it does not like quoted ampersand elsewhere.
string(APPEND STRING_EXTRA "&")
endif()
-if(NOT PP_MINGW)
+if(NOT PP_MINGW AND NOT CLANG_GNULIKE_WINDOWS)
# MinGW: |
# When inside -D"FOO=\"a | b\"" MinGW make wants -D"FOO=\"a "|" b\""
# but it does not like quoted pipe elsewhere.
@@ -100,7 +108,8 @@ endif()
set(EXPR_OP1 "/")
if((NOT MSVC OR PP_NMAKE) AND
- NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
+ NOT CMAKE_C_COMPILER_ID STREQUAL "Intel" AND
+ NOT CLANG_MSVC_WINDOWS)
# MSVC cl, Intel icl: %
# When the cl compiler is invoked from the command line then % must
# be written %% (to distinguish from %ENV% syntax). However cl does
diff --git a/Tests/Preprocess/preprocess.c b/Tests/Preprocess/preprocess.c
index 1b038b0c5..958c77ebc 100644
--- a/Tests/Preprocess/preprocess.c
+++ b/Tests/Preprocess/preprocess.c
@@ -10,7 +10,8 @@ int check_defines_C(void)
{
int result = 1;
if (strcmp(FILE_STRING, STRING_VALUE) != 0) {
- fprintf(stderr, "FILE_STRING has wrong value in C [%s]\n", FILE_STRING);
+ fprintf(stderr, "FILE_STRING has wrong value in C [%s] vs [%s]\n",
+ FILE_STRING, STRING_VALUE);
result = 0;
}
if (strcmp(TARGET_STRING, STRING_VALUE) != 0) {
@@ -33,117 +34,117 @@ int check_defines_C(void)
}
}
#ifdef NDEBUG
-#ifdef FILE_DEF_DEBUG
+# ifdef FILE_DEF_DEBUG
{
fprintf(stderr, "FILE_DEF_DEBUG should not be defined in C\n");
result = 0;
}
-#endif
-#ifdef TARGET_DEF_DEBUG
+# endif
+# ifdef TARGET_DEF_DEBUG
{
fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in C\n");
result = 0;
}
-#endif
-#ifdef DIRECTORY_DEF_DEBUG
+# endif
+# ifdef DIRECTORY_DEF_DEBUG
{
fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in C\n");
result = 0;
}
-#endif
-#ifndef FILE_DEF_RELEASE
-#ifndef PREPROCESS_XCODE
+# endif
+# ifndef FILE_DEF_RELEASE
+# ifndef PREPROCESS_XCODE
{
fprintf(stderr, "FILE_DEF_RELEASE should be defined in C\n");
result = 0;
}
-#endif
-#endif
-#ifndef TARGET_DEF_RELEASE
+# endif
+# endif
+# ifndef TARGET_DEF_RELEASE
{
fprintf(stderr, "TARGET_DEF_RELEASE should be defined in C\n");
result = 0;
}
-#endif
-#ifndef DIRECTORY_DEF_RELEASE
+# endif
+# ifndef DIRECTORY_DEF_RELEASE
{
fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in C\n");
result = 0;
}
-#endif
+# endif
#endif
#ifdef PREPROCESS_DEBUG
-#ifndef FILE_DEF_DEBUG
-#ifndef PREPROCESS_XCODE
+# ifndef FILE_DEF_DEBUG
+# ifndef PREPROCESS_XCODE
{
fprintf(stderr, "FILE_DEF_DEBUG should be defined in C\n");
result = 0;
}
-#endif
-#endif
-#ifndef TARGET_DEF_DEBUG
+# endif
+# endif
+# ifndef TARGET_DEF_DEBUG
{
fprintf(stderr, "TARGET_DEF_DEBUG should be defined in C\n");
result = 0;
}
-#endif
-#ifndef DIRECTORY_DEF_DEBUG
+# endif
+# ifndef DIRECTORY_DEF_DEBUG
{
fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in C\n");
result = 0;
}
-#endif
-#ifdef FILE_DEF_RELEASE
+# endif
+# ifdef FILE_DEF_RELEASE
{
fprintf(stderr, "FILE_DEF_RELEASE should not be defined in C\n");
result = 0;
}
-#endif
-#ifdef TARGET_DEF_RELEASE
+# endif
+# ifdef TARGET_DEF_RELEASE
{
fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in C\n");
result = 0;
}
-#endif
-#ifdef DIRECTORY_DEF_RELEASE
+# endif
+# ifdef DIRECTORY_DEF_RELEASE
{
fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in C\n");
result = 0;
}
-#endif
+# endif
#endif
#if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
-#if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG)
-#ifndef PREPROCESS_XCODE
+# if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG)
+# ifndef PREPROCESS_XCODE
{
fprintf(stderr, "FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in C\n");
result = 0;
}
-#endif
-#endif
-#if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
+# endif
+# endif
+# if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
{
fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in C\n");
result = 0;
}
-#endif
+# endif
#endif
#if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
-#if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE)
-#ifndef PREPROCESS_XCODE
+# if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE)
+# ifndef PREPROCESS_XCODE
{
fprintf(stderr,
"FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in C\n");
result = 0;
}
-#endif
-#endif
-#if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
+# endif
+# endif
+# if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
{
fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in C\n");
result = 0;
}
-#endif
+# endif
#endif
#ifndef FILE_PATH_DEF
{
diff --git a/Tests/Preprocess/preprocess.cxx b/Tests/Preprocess/preprocess.cxx
index 0fab78525..34a69c6c6 100644
--- a/Tests/Preprocess/preprocess.cxx
+++ b/Tests/Preprocess/preprocess.cxx
@@ -35,118 +35,118 @@ int check_defines_CXX()
}
}
#ifdef NDEBUG
-#ifdef FILE_DEF_DEBUG
+# ifdef FILE_DEF_DEBUG
{
fprintf(stderr, "FILE_DEF_DEBUG should not be defined in CXX\n");
result = 0;
}
-#endif
-#ifdef TARGET_DEF_DEBUG
+# endif
+# ifdef TARGET_DEF_DEBUG
{
fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in CXX\n");
result = 0;
}
-#endif
-#ifdef DIRECTORY_DEF_DEBUG
+# endif
+# ifdef DIRECTORY_DEF_DEBUG
{
fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in CXX\n");
result = 0;
}
-#endif
-#ifndef FILE_DEF_RELEASE
-#ifndef PREPROCESS_XCODE
+# endif
+# ifndef FILE_DEF_RELEASE
+# ifndef PREPROCESS_XCODE
{
fprintf(stderr, "FILE_DEF_RELEASE should be defined in CXX\n");
result = 0;
}
-#endif
-#endif
-#ifndef TARGET_DEF_RELEASE
+# endif
+# endif
+# ifndef TARGET_DEF_RELEASE
{
fprintf(stderr, "TARGET_DEF_RELEASE should be defined in CXX\n");
result = 0;
}
-#endif
-#ifndef DIRECTORY_DEF_RELEASE
+# endif
+# ifndef DIRECTORY_DEF_RELEASE
{
fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in CXX\n");
result = 0;
}
-#endif
+# endif
#endif
#ifdef PREPROCESS_DEBUG
-#ifndef FILE_DEF_DEBUG
-#ifndef PREPROCESS_XCODE
+# ifndef FILE_DEF_DEBUG
+# ifndef PREPROCESS_XCODE
{
fprintf(stderr, "FILE_DEF_DEBUG should be defined in CXX\n");
result = 0;
}
-#endif
-#endif
-#ifndef TARGET_DEF_DEBUG
+# endif
+# endif
+# ifndef TARGET_DEF_DEBUG
{
fprintf(stderr, "TARGET_DEF_DEBUG should be defined in CXX\n");
result = 0;
}
-#endif
-#ifndef DIRECTORY_DEF_DEBUG
+# endif
+# ifndef DIRECTORY_DEF_DEBUG
{
fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in CXX\n");
result = 0;
}
-#endif
-#ifdef FILE_DEF_RELEASE
+# endif
+# ifdef FILE_DEF_RELEASE
{
fprintf(stderr, "FILE_DEF_RELEASE should not be defined in CXX\n");
result = 0;
}
-#endif
-#ifdef TARGET_DEF_RELEASE
+# endif
+# ifdef TARGET_DEF_RELEASE
{
fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in CXX\n");
result = 0;
}
-#endif
-#ifdef DIRECTORY_DEF_RELEASE
+# endif
+# ifdef DIRECTORY_DEF_RELEASE
{
fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in CXX\n");
result = 0;
}
-#endif
+# endif
#endif
#if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
-#if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG)
-#ifndef PREPROCESS_XCODE
+# if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG)
+# ifndef PREPROCESS_XCODE
{
fprintf(stderr,
"FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in CXX\n");
result = 0;
}
-#endif
-#endif
-#if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
+# endif
+# endif
+# if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
{
fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in CXX\n");
result = 0;
}
-#endif
+# endif
#endif
#if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
-#if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE)
-#ifndef PREPROCESS_XCODE
+# if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE)
+# ifndef PREPROCESS_XCODE
{
fprintf(stderr,
"FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in CXX\n");
result = 0;
}
-#endif
-#endif
-#if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
+# endif
+# endif
+# if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
{
fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in CXX\n");
result = 0;
}
-#endif
+# endif
#endif
#ifndef FILE_PATH_DEF
{
diff --git a/Tests/Properties/CMakeLists.txt b/Tests/Properties/CMakeLists.txt
index 11fca45b0..a26306122 100644
--- a/Tests/Properties/CMakeLists.txt
+++ b/Tests/Properties/CMakeLists.txt
@@ -11,7 +11,7 @@ set_source_files_properties(properties.h PROPERTIES TEST1 1)
get_source_file_property(RESULT1 properties.h TEST1)
# test properties on a headerfile in the source tree
-# accessed without an extenion (also yuck)
+# accessed without an extension (also yuck)
set_source_files_properties(properties2 PROPERTIES TEST2 1)
get_source_file_property(RESULT2 properties2 TEST2)
diff --git a/Tests/Properties/subdirtest.cxx b/Tests/Properties/subdirtest.cxx
index 02d8f3d3f..23f1048ec 100644
--- a/Tests/Properties/subdirtest.cxx
+++ b/Tests/Properties/subdirtest.cxx
@@ -1,6 +1,6 @@
#ifndef SUBDIR_TEST
-#error Expected SUBDIR_TEST
+# error Expected SUBDIR_TEST
#endif
int main(int, char**)
diff --git a/Tests/Qt4Autogen/CMakeLists.txt b/Tests/Qt4Autogen/CMakeLists.txt
new file mode 100644
index 000000000..68b885bab
--- /dev/null
+++ b/Tests/Qt4Autogen/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Set Qt test version and include the Autogen test macros
+set(QT_TEST_VERSION 4)
+include("../QtAutogen/TestMacros.cmake")
+
+# Qt4 only tests
+ADD_AUTOGEN_TEST(DefinesTest)
+
+# Common tests
+include("../QtAutogen/Tests.cmake")
diff --git a/Tests/Qt4Deploy/CMakeLists.txt b/Tests/Qt4Deploy/CMakeLists.txt
index 646ea9f3b..c73a38c0f 100644
--- a/Tests/Qt4Deploy/CMakeLists.txt
+++ b/Tests/Qt4Deploy/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.9)
project(Qt4Deploy)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install)
@@ -10,7 +10,8 @@ add_executable(testdeploy MACOSX_BUNDLE testdeploy.cpp)
target_link_libraries(testdeploy ${QT_LIBRARIES})
set_target_properties(testdeploy PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}")
-if(CMAKE_CONFIGURATION_TYPES AND QT_QTCORE_LIBRARY_RELEASE AND QT_QTCORE_LIBRARY_DEBUG)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig AND QT_QTCORE_LIBRARY_RELEASE AND QT_QTCORE_LIBRARY_DEBUG)
# note: installing debug Qt libraries from a Qt installation configured with
# -debug-and-release not yet supported (very low priority).
install(CODE "
@@ -58,7 +59,7 @@ if(QT_QSQLITE_PLUGIN_DEBUG OR QT_QSQLITE_PLUGIN_RELEASE)
endif()
# custom target to install and test the installation at build time
- if(CMAKE_CONFIGURATION_TYPES)
+ if(_isMultiConfig)
set(install_config "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}")
endif()
diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt
index ae0a02bb6..2ca11e40b 100644
--- a/Tests/Qt4Targets/CMakeLists.txt
+++ b/Tests/Qt4Targets/CMakeLists.txt
@@ -20,6 +20,16 @@ if (WIN32)
endif()
endif()
+# Qt4 moc does not support utf8 paths in _parameter files generated by
+# qt4_wrap_cpp and qt4_generate_moc
+# https://bugreports.qt.io/browse/QTBUG-35480
+# Do a simple check if there is are non ASCII character in the build path
+string(REGEX MATCH "[^ -~]+" NON_ASCII_BDIR ${CMAKE_CURRENT_BINARY_DIR})
+if(NON_ASCII_BDIR)
+ message(WARNING "Build path contains non ASCII characters. Skipping Qt4 test.")
+ return()
+endif()
+
qt4_generate_moc(main_gen_test.cpp
"${CMAKE_CURRENT_BINARY_DIR}/main_gen_test.moc"
TARGET Qt4GenerateMacroTest
diff --git a/Tests/Qt4Targets/activeqtexe.cpp b/Tests/Qt4Targets/activeqtexe.cpp
index f17b0a639..98176f1de 100644
--- a/Tests/Qt4Targets/activeqtexe.cpp
+++ b/Tests/Qt4Targets/activeqtexe.cpp
@@ -2,7 +2,7 @@
#include <QApplication>
#ifndef QT_QAXSERVER_LIB
-#error Expected QT_QAXSERVER_LIB
+# error Expected QT_QAXSERVER_LIB
#endif
#include <QAxFactory>
diff --git a/Tests/Qt4Targets/main.cpp b/Tests/Qt4Targets/main.cpp
index 07443b0c4..fc7f580bd 100644
--- a/Tests/Qt4Targets/main.cpp
+++ b/Tests/Qt4Targets/main.cpp
@@ -1,15 +1,14 @@
#include <QApplication>
-#include <QWidget>
-
#include <QString>
+#include <QWidget>
#ifndef QT_CORE_LIB
-#error Expected QT_CORE_LIB
+# error Expected QT_CORE_LIB
#endif
#ifndef QT_GUI_LIB
-#error Expected QT_GUI_LIB
+# error Expected QT_GUI_LIB
#endif
int main(int argc, char** argv)
diff --git a/Tests/Qt4Targets/main_gen_test.cpp b/Tests/Qt4Targets/main_gen_test.cpp
index 1ea390bcf..6616e844c 100644
--- a/Tests/Qt4Targets/main_gen_test.cpp
+++ b/Tests/Qt4Targets/main_gen_test.cpp
@@ -3,7 +3,9 @@
#include "myinterface.h"
-class MyObject : public QObject, MyInterface
+class MyObject
+ : public QObject
+ , MyInterface
{
Q_OBJECT
Q_INTERFACES(MyInterface)
diff --git a/Tests/Qt4Targets/mywrapobject.h b/Tests/Qt4Targets/mywrapobject.h
index 5d4e52aec..231a1fe8b 100644
--- a/Tests/Qt4Targets/mywrapobject.h
+++ b/Tests/Qt4Targets/mywrapobject.h
@@ -6,7 +6,9 @@
#include "myinterface.h"
-class MyWrapObject : public QObject, MyInterface
+class MyWrapObject
+ : public QObject
+ , MyInterface
{
Q_OBJECT
Q_INTERFACES(MyInterface)
diff --git a/Tests/Qt5Autogen/CMakeLists.txt b/Tests/Qt5Autogen/CMakeLists.txt
new file mode 100644
index 000000000..49d33cc8e
--- /dev/null
+++ b/Tests/Qt5Autogen/CMakeLists.txt
@@ -0,0 +1,6 @@
+# Set Qt test version and include the Autogen test macros
+set(QT_TEST_VERSION 5)
+include("../QtAutogen/TestMacros.cmake")
+
+# Common tests
+include("../QtAutogen/Tests.cmake")
diff --git a/Tests/QtAutoUicInterface/CMakeLists.txt b/Tests/QtAutoUicInterface/CMakeLists.txt
deleted file mode 100644
index 3ea12943a..000000000
--- a/Tests/QtAutoUicInterface/CMakeLists.txt
+++ /dev/null
@@ -1,75 +0,0 @@
-
-cmake_minimum_required(VERSION 3.7)
-
-project(QtAutoUicInterface)
-
-if (QT_TEST_VERSION STREQUAL 4)
- find_package(Qt4 REQUIRED)
-
- include(UseQt4)
-
- set(QT_CORE_TARGET Qt4::QtCore)
- set(QT_GUI_TARGET Qt4::QtGui)
-else()
- if (NOT QT_TEST_VERSION STREQUAL 5)
- message(SEND_ERROR "Invalid Qt version specified.")
- endif()
- find_package(Qt5Widgets REQUIRED)
-
- set(QT_CORE_TARGET Qt5::Core)
- set(QT_GUI_TARGET Qt5::Widgets)
-endif()
-
-set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
-
-# BEGIN Upstream
-
-set(CMAKE_VERBOSE_MAKEFILE ON)
-
-add_library(KI18n klocalizedstring.cpp)
-target_link_libraries(KI18n ${QT_CORE_TARGET})
-
-set(autouic_options
- -tr tr2$<$<NOT:$<BOOL:$<TARGET_PROPERTY:NO_KUIT_SEMANTIC>>>:x>i18n
-)
-if (NOT Qt5Widgets_VERSION VERSION_LESS 5.3.0)
- list(APPEND autouic_options -include klocalizedstring.h)
-endif()
-
-set_property(TARGET KI18n APPEND PROPERTY
- INTERFACE_AUTOUIC_OPTIONS ${autouic_options}
-)
-
-set(domainProp $<TARGET_PROPERTY:TRANSLATION_DOMAIN>)
-set(nameLower $<LOWER_CASE:$<MAKE_C_IDENTIFIER:$<TARGET_PROPERTY:NAME>>>)
-set(domain_logic
- $<$<BOOL:${domainProp}>:${domainProp}>$<$<NOT:$<BOOL:${domainProp}>>:${nameLower}>
-)
-set_property(TARGET KI18n APPEND PROPERTY
- INTERFACE_COMPILE_DEFINITIONS "TRANSLATION_DOMAIN=${domain_logic}"
-)
-
-# END upstream
-
-if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
-set(INC_DIR "include_${CMAKE_BUILD_TYPE}" )
-else()
-set(INC_DIR "include" )
-endif()
-
-add_library(LibWidget libwidget.cpp)
-target_link_libraries(LibWidget KI18n ${QT_GUI_TARGET})
-set_property(TARGET LibWidget PROPERTY NO_KUIT_SEMANTIC ON)
-set_property(TARGET LibWidget PROPERTY TRANSLATION_DOMAIN customdomain)
-
-add_library(MyWidget mywidget.cpp)
-target_link_libraries(MyWidget KI18n ${QT_GUI_TARGET})
-
-add_executable(QtAutoUicInterface main.cpp)
-target_compile_definitions(QtAutoUicInterface
- PRIVATE
- UI_LIBWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/LibWidget_autogen/${INC_DIR}/ui_libwidget.h"
- UI_MYWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/MyWidget_autogen/${INC_DIR}/ui_mywidget.h"
-)
diff --git a/Tests/QtAutoUicInterface/libwidget.h b/Tests/QtAutoUicInterface/libwidget.h
deleted file mode 100644
index b6f3e8252..000000000
--- a/Tests/QtAutoUicInterface/libwidget.h
+++ /dev/null
@@ -1,25 +0,0 @@
-
-#ifndef LIBWIDGET_H
-#define LIBWIDGET_H
-
-#include <QWidget>
-#include <memory>
-
-#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
-#include <klocalizedstring.h>
-#endif
-
-#include "ui_libwidget.h"
-
-class LibWidget : public QWidget
-{
- Q_OBJECT
-public:
- explicit LibWidget(QWidget* parent = 0);
- ~LibWidget();
-
-private:
- Ui::LibWidget* ui;
-};
-
-#endif
diff --git a/Tests/QtAutoUicInterface/mywidget.h b/Tests/QtAutoUicInterface/mywidget.h
deleted file mode 100644
index c23e55de7..000000000
--- a/Tests/QtAutoUicInterface/mywidget.h
+++ /dev/null
@@ -1,25 +0,0 @@
-
-#ifndef MYWIDGET_H
-#define MYWIDGET_H
-
-#include <QWidget>
-#include <memory>
-
-#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
-#include <klocalizedstring.h>
-#endif
-
-#include "ui_mywidget.h"
-
-class MyWidget : public QWidget
-{
- Q_OBJECT
-public:
- explicit MyWidget(QWidget* parent = 0);
- ~MyWidget();
-
-private:
- Ui::MyWidget* ui;
-};
-
-#endif
diff --git a/Tests/QtAutogen/AutogenCoreTest.cmake b/Tests/QtAutogen/AutogenCoreTest.cmake
new file mode 100644
index 000000000..580385928
--- /dev/null
+++ b/Tests/QtAutogen/AutogenCoreTest.cmake
@@ -0,0 +1,55 @@
+
+# Tell find_package(Qt5) where to find Qt.
+if(QT_QMAKE_EXECUTABLE)
+ get_filename_component(Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH)
+ get_filename_component(Qt_PREFIX_DIR "${Qt_BIN_DIR}" PATH)
+ list(APPEND CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR})
+endif()
+
+if (QT_TEST_VERSION EQUAL 4)
+
+ find_package(Qt4 REQUIRED QtCore)
+ include(UseQt4)
+
+ set(QT_QTCORE_TARGET Qt4::QtCore)
+
+ # Qt macros
+ macro(qtx_wrap_cpp)
+ qt4_wrap_cpp(${ARGN})
+ endmacro()
+ macro(qtx_generate_moc)
+ qt4_generate_moc(${ARGN})
+ endmacro()
+
+elseif(QT_TEST_VERSION EQUAL 5)
+
+ find_package(Qt5Core REQUIRED)
+
+ set(QT_QTCORE_TARGET Qt5::Core)
+ set(QT_LIBRARIES Qt5::Core)
+
+ # Include directories
+ include_directories(${Qt5Core_INCLUDE_DIRS})
+
+ # Definitions
+ if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC)
+ add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC})
+ endif()
+
+ # Qt macros
+ macro(qtx_wrap_cpp)
+ qt5_wrap_cpp(${ARGN})
+ endmacro()
+ macro(qtx_generate_moc)
+ qt5_generate_moc(${ARGN})
+ endmacro()
+
+else()
+ message(SEND_ERROR "Invalid Qt version specified: ${QT_TEST_VERSION}")
+endif()
+
+# Get Qt compile features
+get_property(QT_COMPILE_FEATURES
+ TARGET ${QT_QTCORE_TARGET}
+ PROPERTY INTERFACE_COMPILE_FEATURES
+)
diff --git a/Tests/QtAutogen/AutogenGuiTest.cmake b/Tests/QtAutogen/AutogenGuiTest.cmake
new file mode 100644
index 000000000..b76d341a4
--- /dev/null
+++ b/Tests/QtAutogen/AutogenGuiTest.cmake
@@ -0,0 +1,55 @@
+
+# Tell find_package(Qt5) where to find Qt.
+if(QT_QMAKE_EXECUTABLE)
+ get_filename_component(Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH)
+ get_filename_component(Qt_PREFIX_DIR "${Qt_BIN_DIR}" PATH)
+ list(APPEND CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR})
+endif()
+
+if (QT_TEST_VERSION EQUAL 4)
+
+ find_package(Qt4 REQUIRED)
+ include(UseQt4)
+
+ set(QT_QTCORE_TARGET Qt4::QtCore)
+
+ # Qt macros
+ macro(qtx_wrap_cpp)
+ qt4_wrap_cpp(${ARGN})
+ endmacro()
+ macro(qtx_generate_moc)
+ qt4_generate_moc(${ARGN})
+ endmacro()
+
+elseif(QT_TEST_VERSION EQUAL 5)
+
+ find_package(Qt5Widgets REQUIRED)
+
+ set(QT_QTCORE_TARGET Qt5::Core)
+ set(QT_LIBRARIES Qt5::Widgets)
+
+ # Include directories
+ include_directories(${Qt5Widgets_INCLUDE_DIRS})
+
+ # Definitions
+ if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC)
+ add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC})
+ endif()
+
+ # Qt macros
+ macro(qtx_wrap_cpp)
+ qt5_wrap_cpp(${ARGN})
+ endmacro()
+ macro(qtx_generate_moc)
+ qt5_generate_moc(${ARGN})
+ endmacro()
+
+else()
+ message(SEND_ERROR "Invalid Qt version specified: ${QT_TEST_VERSION}")
+endif()
+
+# Get Qt compile features
+get_property(QT_COMPILE_FEATURES
+ TARGET ${QT_QTCORE_TARGET}
+ PROPERTY INTERFACE_COMPILE_FEATURES
+)
diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt b/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt
new file mode 100644
index 000000000..9e6fe8b34
--- /dev/null
+++ b/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt
@@ -0,0 +1,71 @@
+cmake_minimum_required(VERSION 3.11)
+project(AutogenOriginDependsOff)
+include("../AutogenCoreTest.cmake")
+
+set(CSD ${CMAKE_CURRENT_SOURCE_DIR})
+set(CBD ${CMAKE_CURRENT_BINARY_DIR})
+include_directories(${CSD})
+include_directories(${CBD})
+
+# A GENERATED file ensures there will be an _autogen target in VS
+add_custom_command (
+ OUTPUT "${CBD}/config.hpp"
+ COMMAND ${CMAKE_COMMAND} -E copy "${CSD}/config.hpp.in" "${CBD}/config.hpp"
+ )
+
+
+# Library "a_mc" provides a header that holds a string with the content of
+# mocs_compilation.cpp from a_qt. It therefore must depend on a_qt_autogen.
+add_custom_target ( a_mc
+ COMMAND ${CMAKE_COMMAND} -E sleep 2
+ COMMAND ${CMAKE_COMMAND}
+ "-DMCF=${CBD}/a_qt_autogen/mocs_compilation.cpp"
+ "-DCF_IN=${CSD}/a_mc.hpp.in"
+ "-DCF_OUT=${CBD}/a_mc.hpp"
+ -P ${CSD}/configure_content.cmake
+ )
+add_dependencies ( a_mc a_qt_autogen )
+
+# Library "a_qt"
+# - depends on a GENERATED file
+# - AUTOMOC enabled
+# - depends on a target (a_mc) that depends on a_qt_qutogen
+add_library ( a_qt a_qt.cpp "${CBD}/config.hpp" )
+add_dependencies ( a_qt a_mc )
+target_link_libraries ( a_qt ${QT_QTCORE_TARGET})
+set_target_properties ( a_qt PROPERTIES AUTOMOC TRUE)
+# Disable AUTOGEN_ORIGIN_DEPENDS to avoid loop dependencies
+set_target_properties ( a_qt PROPERTIES AUTOGEN_ORIGIN_DEPENDS OFF)
+
+
+# Library "b_mc" provides a header that holds a string function that returns
+# the content of mocs_compilation.cpp from b_qt.
+# It therefore must depend on b_qt_autogen.
+add_custom_command (
+ OUTPUT ${CBD}/b_mc.cpp
+ DEPENDS b_qt_autogen
+ COMMAND ${CMAKE_COMMAND} -E sleep 2
+ COMMAND ${CMAKE_COMMAND}
+ "-DMCF=${CBD}/b_qt_autogen/mocs_compilation.cpp"
+ "-DCF_IN=${CSD}/b_mc.cpp.in"
+ "-DCF_OUT=${CBD}/b_mc.cpp"
+ -P ${CSD}/configure_content.cmake
+ )
+add_library ( b_mc ${CSD}/b_mc.hpp ${CBD}/b_mc.cpp )
+
+# Library "b_qt"
+# - depends on a GENERATED file
+# - AUTOMOC enabled
+# - depends on a library (b_mc) that depends on b_qt_qutogen
+add_library ( b_qt b_qt.cpp "${CBD}/config.hpp" )
+target_link_libraries ( b_qt b_mc )
+target_link_libraries ( b_qt ${QT_QTCORE_TARGET})
+set_target_properties ( b_qt PROPERTIES AUTOMOC TRUE)
+# Disable AUTOGEN_ORIGIN_DEPENDS to avoid loop dependencies
+set_target_properties ( b_qt PROPERTIES AUTOGEN_ORIGIN_DEPENDS OFF)
+
+
+# The main target depends on both libraries which depend on the _autogen
+# target of the main target.
+add_executable ( autogenOriginDependsOff main.cpp )
+target_link_libraries ( autogenOriginDependsOff a_qt b_qt )
diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/a_mc.hpp.in b/Tests/QtAutogen/AutogenOriginDependsOff/a_mc.hpp.in
new file mode 100644
index 000000000..fe71f673d
--- /dev/null
+++ b/Tests/QtAutogen/AutogenOriginDependsOff/a_mc.hpp.in
@@ -0,0 +1,9 @@
+#ifndef A_MC_HPP
+#define A_MC_HPP
+
+namespace a_mc {
+
+char const* mocs_compilation = "@MOCS_COMPILATION@";
+}
+
+#endif
diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.cpp b/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.cpp
new file mode 100644
index 000000000..c7c6863d5
--- /dev/null
+++ b/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.cpp
@@ -0,0 +1,29 @@
+
+#include "a_qt.hpp"
+
+#include <a_mc.hpp>
+
+namespace a_qt {
+
+/// @brief A source local QObject based class
+class Source_QObject : public QObject
+{
+ Q_OBJECT
+public:
+ Source_QObject() {}
+ ~Source_QObject() {}
+
+ std::string str;
+};
+
+std::string mocs_compilation()
+{
+ // Create and destroy QObject based classes
+ Header_QObject header_obj;
+ Source_QObject source_obj;
+
+ return std::string(a_mc::mocs_compilation);
+}
+}
+
+#include "a_qt.moc"
diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.hpp b/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.hpp
new file mode 100644
index 000000000..fafc8a20e
--- /dev/null
+++ b/Tests/QtAutogen/AutogenOriginDependsOff/a_qt.hpp
@@ -0,0 +1,27 @@
+#ifndef A_QT_HPP
+#define A_QT_HPP
+
+#include <string>
+
+#include <config.hpp>
+
+#include <QObject>
+
+namespace a_qt {
+
+/// @brief A header local QObject based class
+class Header_QObject : public QObject
+{
+ Q_OBJECT
+public:
+ Header_QObject() {}
+ ~Header_QObject() {}
+
+ std::string str;
+};
+
+/// @brief Function that returns the content of mocs_compilation.cpp
+extern std::string mocs_compilation();
+}
+
+#endif
diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/b_mc.cpp.in b/Tests/QtAutogen/AutogenOriginDependsOff/b_mc.cpp.in
new file mode 100644
index 000000000..0f5ec308c
--- /dev/null
+++ b/Tests/QtAutogen/AutogenOriginDependsOff/b_mc.cpp.in
@@ -0,0 +1,9 @@
+#include <b_mc.hpp>
+
+namespace b_mc {
+
+char const* mocs_compilation()
+{
+ return "@MOCS_COMPILATION@";
+}
+}
diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/b_mc.hpp b/Tests/QtAutogen/AutogenOriginDependsOff/b_mc.hpp
new file mode 100644
index 000000000..043727359
--- /dev/null
+++ b/Tests/QtAutogen/AutogenOriginDependsOff/b_mc.hpp
@@ -0,0 +1,9 @@
+#ifndef B_MC_HPP
+#define B_MC_HPP
+
+namespace b_mc {
+
+extern char const* mocs_compilation();
+}
+
+#endif
diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.cpp b/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.cpp
new file mode 100644
index 000000000..c5adaebda
--- /dev/null
+++ b/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.cpp
@@ -0,0 +1,29 @@
+
+#include "b_qt.hpp"
+
+#include <b_mc.hpp>
+
+namespace b_qt {
+
+/// @brief A source local QObject based class
+class Source_QObject : public QObject
+{
+ Q_OBJECT
+public:
+ Source_QObject() {}
+ ~Source_QObject() {}
+
+ std::string str;
+};
+
+std::string mocs_compilation()
+{
+ // Create and destroy QObject based classes
+ Header_QObject header_obj;
+ Source_QObject source_obj;
+
+ return std::string(b_mc::mocs_compilation());
+}
+}
+
+#include "b_qt.moc"
diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.hpp b/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.hpp
new file mode 100644
index 000000000..b798e71ca
--- /dev/null
+++ b/Tests/QtAutogen/AutogenOriginDependsOff/b_qt.hpp
@@ -0,0 +1,27 @@
+#ifndef B_QT_HPP
+#define B_QT_HPP
+
+#include <string>
+
+#include <config.hpp>
+
+#include <QObject>
+
+namespace b_qt {
+
+/// @brief A header local QObject based class
+class Header_QObject : public QObject
+{
+ Q_OBJECT
+public:
+ Header_QObject() {}
+ ~Header_QObject() {}
+
+ std::string str;
+};
+
+/// @brief Function that returns the content of mocs_compilation.cpp
+extern std::string mocs_compilation();
+}
+
+#endif
diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/config.hpp.in b/Tests/QtAutogen/AutogenOriginDependsOff/config.hpp.in
new file mode 100644
index 000000000..e415d0855
--- /dev/null
+++ b/Tests/QtAutogen/AutogenOriginDependsOff/config.hpp.in
@@ -0,0 +1,8 @@
+#ifndef CONFIG_HPP
+#define CONFIG_HPP
+
+// Application configuration
+
+enum dummy { NO_OP };
+
+#endif
diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/configure_content.cmake b/Tests/QtAutogen/AutogenOriginDependsOff/configure_content.cmake
new file mode 100644
index 000000000..0fc6e638d
--- /dev/null
+++ b/Tests/QtAutogen/AutogenOriginDependsOff/configure_content.cmake
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.10)
+
+# Read mocs_compilation.cpp file into variable
+file(READ "${MCF}" MOCS_COMPILATION)
+string(REPLACE "\\" "\\\\" MOCS_COMPILATION "${MOCS_COMPILATION}" )
+string(REPLACE "\"" "\\\"" MOCS_COMPILATION "${MOCS_COMPILATION}" )
+string(REPLACE "\n" "\"\n\"" MOCS_COMPILATION "${MOCS_COMPILATION}" )
+
+# Configure file
+configure_file ( "${CF_IN}" "${CF_OUT}" @ONLY )
diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/main.cpp b/Tests/QtAutogen/AutogenOriginDependsOff/main.cpp
new file mode 100644
index 000000000..3fb6c7095
--- /dev/null
+++ b/Tests/QtAutogen/AutogenOriginDependsOff/main.cpp
@@ -0,0 +1,16 @@
+
+#include <string>
+
+#include <a_qt.hpp>
+#include <b_qt.hpp>
+
+int main()
+{
+ if (a_qt::mocs_compilation().empty()) {
+ return -1;
+ }
+ if (b_qt::mocs_compilation().empty()) {
+ return -1;
+ }
+ return 0;
+}
diff --git a/Tests/QtAutogen/AutogenOriginDependsOn/CMakeLists.txt b/Tests/QtAutogen/AutogenOriginDependsOn/CMakeLists.txt
new file mode 100644
index 000000000..5aabe0e68
--- /dev/null
+++ b/Tests/QtAutogen/AutogenOriginDependsOn/CMakeLists.txt
@@ -0,0 +1,91 @@
+cmake_minimum_required(VERSION 3.10)
+project(AutogenOriginDependsOn)
+include("../AutogenCoreTest.cmake")
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+set(CSD ${CMAKE_CURRENT_SOURCE_DIR})
+set(CBD ${CMAKE_CURRENT_BINARY_DIR})
+
+# -- Test dependency on header generated by a custom command
+#
+# The ORIGIN_autogen target must depend on the same *GENERATED* source files as
+# the ORIGIN target. This is a requirement to ensure that all files for the
+# ORIGIN target are generated before the ORIGIN_autogen target is built.
+#
+# This tests the dependency of the mocDepGenFile_autogen target of
+# mocDepGenFile to the source file GenFile.hpp, which is *GENERATED*
+# by a custom command.
+# If mocDepGenFile_autogen gets built *before* or in *parallel* to the
+# custom command, the build will fail. That's because GenFile.hpp,
+# which is required by mocDepGenFile_autogen, is only valid after the
+# custom command has been completed.
+#
+# The sleep seconds artificially increase the build time of the custom command
+# to simulate a slow file generation process that takes longer to run than
+# the build of the mocDepGenFile_autogen target.
+add_custom_command(
+ OUTPUT ${CBD}/GenFile.hpp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/GenFile.hpp
+ COMMAND ${CMAKE_COMMAND} -E sleep 3
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/GenFile.hpp)
+
+add_executable(mocDepGenFile testGenFile.cpp ${CBD}/GenFile.hpp)
+target_link_libraries(mocDepGenFile ${QT_QTCORE_TARGET})
+set_target_properties(mocDepGenFile PROPERTIES AUTOMOC TRUE)
+
+
+# -- Test dependency on header generating custom target
+#
+# The ORIGIN_autogen target must depend on the same user defined targets
+# as the ORIGIN target. This is a requirement to ensure that all files for the
+# ORIGIN target are generated before the ORIGIN_autogen target is built.
+#
+# This tests the dependency of the mocDepTarget_autogen target of
+# mocDepTarget to the utility target mocDepTargetUtil.
+# If mocDepTarget_autogen gets built *before* or in *parallel* to
+# mocDepTargetUtil, the build will fail. That's
+# because GenTarget.hpp, which is required by mocDepTarget_autogen,
+# is only valid after the mocDepTargetUtil build has been completed.
+#
+# The sleep seconds artificially increase the build time of mocDepTargetUtil
+# to simulate a slow utility target build that takes longer to run than
+# the build of the mocDepTarget_autogen target.
+add_custom_target(mocDepTargetUtil
+ BYPRODUCTS ${CBD}/GenTarget.hpp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/GenTarget.hpp
+ COMMAND ${CMAKE_COMMAND} -E sleep 3
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/GenTarget.hpp)
+
+add_executable(mocDepTarget testGenTarget.cpp)
+target_link_libraries(mocDepTarget ${QT_QTCORE_TARGET})
+set_target_properties(mocDepTarget PROPERTIES AUTOMOC TRUE)
+add_dependencies(mocDepTarget mocDepTargetUtil)
+
+
+# -- Test 3: Depend on generated linked library
+# The ORIGIN_autogen target must depend on the same linked libraries
+# as the ORIGIN target. This is a requirement to ensure that all files for the
+# ORIGIN target are generated before the ORIGIN_autogen target is built.
+#
+# This tests the dependency of the mocDepGenLib_autogen target of mocDepGenLib
+# to the user generated library SimpleLib, which mocDepGenLib links to.
+# If mocDepGenLib_autogen gets built *before* or in *parallel* to SimpleLib,
+# the build will fail. That's because simpleLib.hpp, which is required by
+# mocDepGenLib_autogen, is only valid after the SimpleLib build has been
+# completed.
+#
+# The sleep seconds artificially increase the build time of SimpleLib
+# to simulate a slow utility library build that takes longer to run than
+# the build of the mocDepGenLib_autogen target.
+add_custom_command(
+ OUTPUT ${CBD}/simpleLib.hpp ${CBD}/simpleLib.cpp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/simpleLib.hpp
+ COMMAND ${CMAKE_COMMAND} -E sleep 3
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/simpleLib.hpp.in ${CBD}/simpleLib.hpp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/simpleLib.cpp.in ${CBD}/simpleLib.cpp)
+add_library(SimpleLib STATIC ${CBD}/simpleLib.hpp ${CBD}/simpleLib.cpp)
+target_link_libraries(SimpleLib ${QT_QTCORE_TARGET})
+
+add_executable(mocDepGenLib testGenLib.cpp)
+target_link_libraries(mocDepGenLib SimpleLib ${QT_QTCORE_TARGET})
+set_target_properties(mocDepGenLib PROPERTIES AUTOMOC TRUE)
diff --git a/Tests/QtAutogen/mocDepends/object_invalid.hpp.in b/Tests/QtAutogen/AutogenOriginDependsOn/object_invalid.hpp.in
index 854d9a143..854d9a143 100644
--- a/Tests/QtAutogen/mocDepends/object_invalid.hpp.in
+++ b/Tests/QtAutogen/AutogenOriginDependsOn/object_invalid.hpp.in
diff --git a/Tests/QtAutogen/mocDepends/object_valid.hpp.in b/Tests/QtAutogen/AutogenOriginDependsOn/object_valid.hpp.in
index f364f7c97..f364f7c97 100644
--- a/Tests/QtAutogen/mocDepends/object_valid.hpp.in
+++ b/Tests/QtAutogen/AutogenOriginDependsOn/object_valid.hpp.in
diff --git a/Tests/QtAutogen/mocDepends/simpleLib.cpp.in b/Tests/QtAutogen/AutogenOriginDependsOn/simpleLib.cpp.in
index fa33bd375..fa33bd375 100644
--- a/Tests/QtAutogen/mocDepends/simpleLib.cpp.in
+++ b/Tests/QtAutogen/AutogenOriginDependsOn/simpleLib.cpp.in
diff --git a/Tests/QtAutogen/mocDepends/simpleLib.hpp.in b/Tests/QtAutogen/AutogenOriginDependsOn/simpleLib.hpp.in
index b65b0cb4a..b65b0cb4a 100644
--- a/Tests/QtAutogen/mocDepends/simpleLib.hpp.in
+++ b/Tests/QtAutogen/AutogenOriginDependsOn/simpleLib.hpp.in
diff --git a/Tests/QtAutogen/mocDepends/testGenFile.cpp b/Tests/QtAutogen/AutogenOriginDependsOn/testGenFile.cpp
index 7df6e137c..7df6e137c 100644
--- a/Tests/QtAutogen/mocDepends/testGenFile.cpp
+++ b/Tests/QtAutogen/AutogenOriginDependsOn/testGenFile.cpp
diff --git a/Tests/QtAutogen/mocDepends/testGenLib.cpp b/Tests/QtAutogen/AutogenOriginDependsOn/testGenLib.cpp
index c14e15958..c14e15958 100644
--- a/Tests/QtAutogen/mocDepends/testGenLib.cpp
+++ b/Tests/QtAutogen/AutogenOriginDependsOn/testGenLib.cpp
diff --git a/Tests/QtAutogen/AutogenOriginDependsOn/testGenLib.hpp b/Tests/QtAutogen/AutogenOriginDependsOn/testGenLib.hpp
new file mode 100644
index 000000000..55457d212
--- /dev/null
+++ b/Tests/QtAutogen/AutogenOriginDependsOn/testGenLib.hpp
@@ -0,0 +1,17 @@
+#ifndef TEST3_HPP
+#define TEST3_HPP
+
+#include <QObject>
+
+#include "simpleLib.hpp"
+
+// This object triggers the AUTOMOC on this file
+class LObject : public QObject
+{
+ Q_OBJECT
+public:
+ Q_SLOT
+ void aSlot(){};
+};
+
+#endif
diff --git a/Tests/QtAutogen/mocDepends/testGenTarget.cpp b/Tests/QtAutogen/AutogenOriginDependsOn/testGenTarget.cpp
index 911076efd..911076efd 100644
--- a/Tests/QtAutogen/mocDepends/testGenTarget.cpp
+++ b/Tests/QtAutogen/AutogenOriginDependsOn/testGenTarget.cpp
diff --git a/Tests/QtAutogen/AutogenTargetDepends/CMakeLists.txt b/Tests/QtAutogen/AutogenTargetDepends/CMakeLists.txt
new file mode 100644
index 000000000..492b5dbd3
--- /dev/null
+++ b/Tests/QtAutogen/AutogenTargetDepends/CMakeLists.txt
@@ -0,0 +1,54 @@
+cmake_minimum_required(VERSION 3.10)
+project(AutogenTargetDepends)
+include("../AutogenCoreTest.cmake")
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+set(CSD ${CMAKE_CURRENT_SOURCE_DIR})
+set(CBD ${CMAKE_CURRENT_BINARY_DIR})
+
+# -- Test AUTOGEN_TARGET_DEPENDS with GENERATED file dependency
+#
+# This tests the dependency of the mocDepATDFile_autogen target of
+# mocDepATDTarget to the utility target mocDepATDFileUtil.
+# If mocDepATDFile_autogen gets built *before* or in *parallel* to
+# mocDepATDFileUtil, the build will fail. That's
+# because ATDFile.hpp, which is required by mocDepATDFile_autogen,
+# is only valid after the mocDepATDFileUtil build has been completed.
+#
+# The sleep seconds artificially increase the build time of
+# mocDepATDFileUtil to simulate a slow utility target build that takes
+# longer to run than the build of the mocDepATDFile_autogen target.
+add_custom_command(
+ OUTPUT ${CBD}/ATDFile.hpp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/ATDFile.hpp
+ COMMAND ${CMAKE_COMMAND} -E sleep 3
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/ATDFile.hpp)
+
+add_executable(mocDepATDFile testATDFile.cpp)
+target_link_libraries(mocDepATDFile ${QT_QTCORE_TARGET})
+set_target_properties(mocDepATDFile PROPERTIES AUTOMOC TRUE)
+set_target_properties(mocDepATDFile PROPERTIES AUTOGEN_TARGET_DEPENDS ${CBD}/ATDFile.hpp)
+
+
+# -- Test AUTOGEN_TARGET_DEPENDS with target dependency
+#
+# This tests the dependency of the mocDepATDTarget_autogen target of
+# mocDepATDTarget to the utility target mocDepATDTargetUtil.
+# If mocDepATDTarget_autogen gets built *before* or in *parallel* to
+# mocDepATDTargetUtil, the build will fail. That's
+# because ATDTarget.hpp, which is required by mocDepATDTarget_autogen,
+# is only valid after the mocDepATDTargetUtil build has been completed.
+#
+# The sleep seconds artificially increase the build time of
+# mocDepATDTargetUtil to simulate a slow utility target build that takes
+# longer to run than the build of the mocDepATDTarget_autogen target.
+add_custom_target(mocDepATDTargetUtil
+ BYPRODUCTS ${CBD}/ATDTarget.hpp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/ATDTarget.hpp
+ COMMAND ${CMAKE_COMMAND} -E sleep 3
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/ATDTarget.hpp)
+
+add_executable(mocDepATDTarget testATDTarget.cpp)
+target_link_libraries(mocDepATDTarget ${QT_QTCORE_TARGET})
+set_target_properties(mocDepATDTarget PROPERTIES AUTOMOC TRUE)
+set_target_properties(mocDepATDTarget PROPERTIES AUTOGEN_TARGET_DEPENDS mocDepATDTargetUtil)
diff --git a/Tests/QtAutogen/AutogenTargetDepends/object_invalid.hpp.in b/Tests/QtAutogen/AutogenTargetDepends/object_invalid.hpp.in
new file mode 100644
index 000000000..854d9a143
--- /dev/null
+++ b/Tests/QtAutogen/AutogenTargetDepends/object_invalid.hpp.in
@@ -0,0 +1 @@
+#ifndef
diff --git a/Tests/QtAutogen/AutogenTargetDepends/object_valid.hpp.in b/Tests/QtAutogen/AutogenTargetDepends/object_valid.hpp.in
new file mode 100644
index 000000000..f364f7c97
--- /dev/null
+++ b/Tests/QtAutogen/AutogenTargetDepends/object_valid.hpp.in
@@ -0,0 +1,14 @@
+#ifndef OBJECT_HPP
+#define OBJECT_HPP
+
+#include <QObject>
+
+class Object : public QObject
+{
+ Q_OBJECT
+public:
+ Q_SLOT
+ void aSlot(){};
+};
+
+#endif
diff --git a/Tests/QtAutogen/mocDepends/testATDFile.cpp b/Tests/QtAutogen/AutogenTargetDepends/testATDFile.cpp
index 6bddfcd39..6bddfcd39 100644
--- a/Tests/QtAutogen/mocDepends/testATDFile.cpp
+++ b/Tests/QtAutogen/AutogenTargetDepends/testATDFile.cpp
diff --git a/Tests/QtAutogen/mocDepends/testATDTarget.cpp b/Tests/QtAutogen/AutogenTargetDepends/testATDTarget.cpp
index 831fc2691..831fc2691 100644
--- a/Tests/QtAutogen/mocDepends/testATDTarget.cpp
+++ b/Tests/QtAutogen/AutogenTargetDepends/testATDTarget.cpp
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
deleted file mode 100644
index 073c5fdef..000000000
--- a/Tests/QtAutogen/CMakeLists.txt
+++ /dev/null
@@ -1,365 +0,0 @@
-cmake_minimum_required(VERSION 3.7)
-
-project(QtAutogen)
-
-# Tell find_package(Qt5) where to find Qt.
-if(QT_QMAKE_EXECUTABLE)
- get_filename_component(Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH)
- get_filename_component(Qt_PREFIX_DIR "${Qt_BIN_DIR}" PATH)
- set(CMAKE_PREFIX_PATH ${Qt_PREFIX_DIR})
-endif()
-
-if (QT_TEST_VERSION STREQUAL 4)
- find_package(Qt4 REQUIRED)
-
- # Include this directory before using the UseQt4 file.
- add_subdirectory(defines_test)
-
- include(UseQt4)
-
- set(QT_QTCORE_TARGET Qt4::QtCore)
-
- macro(qtx_wrap_cpp)
- qt4_wrap_cpp(${ARGN})
- endmacro()
-
-else()
- if (NOT QT_TEST_VERSION STREQUAL 5)
- message(SEND_ERROR "Invalid Qt version specified.")
- endif()
- find_package(Qt5Widgets REQUIRED)
-
- set(QT_QTCORE_TARGET Qt5::Core)
-
- include_directories(${Qt5Widgets_INCLUDE_DIRS})
- set(QT_LIBRARIES Qt5::Widgets)
-
- if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC)
- add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC})
- endif()
-
- macro(qtx_wrap_cpp)
- qt5_wrap_cpp(${ARGN})
- endmacro()
-
-endif()
-
-get_property(QT_COMPILE_FEATURES TARGET ${QT_QTCORE_TARGET} PROPERTY INTERFACE_COMPILE_FEATURES)
-
-# -- Test
-# RCC only
-add_executable(rccOnly rccOnly.cpp rccOnlyRes.qrc)
-set_property(TARGET rccOnly PROPERTY AUTORCC ON)
-target_link_libraries(rccOnly ${QT_QTCORE_TARGET})
-
-# -- Test
-# RCC empty
-add_executable(rccEmpty rccEmpty.cpp rccEmptyRes.qrc)
-set_property(TARGET rccEmpty PROPERTY AUTORCC ON)
-target_link_libraries(rccEmpty ${QT_QTCORE_TARGET})
-
-# -- Test
-# UIC only
-qtx_wrap_cpp(uicOnlyMoc uicOnlySource/uiconly.h)
-add_executable(uicOnly uicOnlySource/uiconly.cpp ${uicOnlyMoc})
-set_property(TARGET uicOnly PROPERTY AUTOUIC ON)
-target_link_libraries(uicOnly ${QT_LIBRARIES})
-
-# -- Test
-# Add not_generated_file.qrc to the source list to get the file-level
-# dependency, but don't generate a c++ file from it. Disable the AUTORCC
-# feature for this target. This tests that qrc files in the sources don't
-# have an effect on generation if AUTORCC is off.
-add_library(empty STATIC empty.cpp not_generated_file.qrc)
-set_target_properties(empty PROPERTIES AUTORCC OFF)
-set_target_properties(empty PROPERTIES AUTOMOC TRUE)
-target_link_libraries(empty no_link_language)
-add_library(no_link_language STATIC empty.h)
-set_target_properties(no_link_language PROPERTIES AUTOMOC TRUE)
-# Pass Qt compiler features to targets that don't link against Qt
-target_compile_features(no_link_language PRIVATE ${QT_COMPILE_FEATURES})
-target_compile_features(empty PRIVATE ${QT_COMPILE_FEATURES})
-
-# -- Test
-# When a file listed in a .qrc file changes the target must be rebuilt
-set(timeformat "%Y%j%H%M%S")
-set(RCC_DEPENDS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/rccDepends")
-set(RCC_DEPENDS_BIN "${CMAKE_CURRENT_BINARY_DIR}/rccDepends")
-configure_file(${RCC_DEPENDS_SRC}/res1a.qrc.in ${RCC_DEPENDS_BIN}/res1.qrc COPYONLY)
-configure_file(${RCC_DEPENDS_SRC}/res2a.qrc.in ${RCC_DEPENDS_BIN}/res2.qrc.in COPYONLY)
-try_compile(RCC_DEPENDS
- "${RCC_DEPENDS_BIN}"
- "${RCC_DEPENDS_SRC}"
- rccDepends
- CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
- "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
- "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
- OUTPUT_VARIABLE output
-)
-if (NOT RCC_DEPENDS)
- message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}")
-endif()
-# Get name and timestamp of the output binary
-file(STRINGS "${RCC_DEPENDS_BIN}/target.txt" targetList)
-list(GET targetList 0 rccDependsBin)
-file(TIMESTAMP "${rccDependsBin}" timeBegin "${timeformat}")
-# Sleep, touch regular qrc input file, rebuild and compare timestamp
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
-execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res1/input.txt")
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result)
-if (result)
- message(SEND_ERROR "Second build of rccDepends failed.")
-endif()
-file(TIMESTAMP "${rccDependsBin}" timeStep1 "${timeformat}")
-if (NOT timeStep1 GREATER timeBegin)
- message(SEND_ERROR "File (${rccDependsBin}) should have changed in the first step!")
-endif()
-# Sleep, update regular qrc file, rebuild and compare timestamp
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
-configure_file(${RCC_DEPENDS_SRC}/res1b.qrc.in ${RCC_DEPENDS_BIN}/res1.qrc COPYONLY)
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result)
-if (result)
- message(SEND_ERROR "Third build of rccDepends failed.")
-endif()
-file(TIMESTAMP "${rccDependsBin}" timeStep2 "${timeformat}")
-if (NOT timeStep2 GREATER timeStep1)
- message(SEND_ERROR "File (${rccDependsBin}) should have changed in the second step!")
-endif()
-# Sleep, touch regular qrc newly added input file, rebuild and compare timestamp
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
-execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res1/inputAdded.txt")
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result)
-if (result)
- message(SEND_ERROR "Fourth build of rccDepends failed.")
-endif()
-file(TIMESTAMP "${rccDependsBin}" timeStep3 "${timeformat}")
-if (NOT timeStep3 GREATER timeStep2)
- message(SEND_ERROR "File (${rccDependsBin}) should have changed in the third step!")
-endif()
-# Sleep, touch generated qrc input file, rebuild and compare timestamp
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
-execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res2/input.txt")
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result)
-if (result)
- message(SEND_ERROR "Fifth build of rccDepends failed.")
-endif()
-file(TIMESTAMP "${rccDependsBin}" timeStep4 "${timeformat}")
-if (NOT timeStep4 GREATER timeStep3)
- message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fourth step!")
-endif()
-# Sleep, update generated qrc file, rebuild and compare timestamp
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
-configure_file(${RCC_DEPENDS_SRC}/res2b.qrc.in ${RCC_DEPENDS_BIN}/res2.qrc.in COPYONLY)
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result)
-if (result)
- message(SEND_ERROR "Sixth build of rccDepends failed.")
-endif()
-file(TIMESTAMP "${rccDependsBin}" timeStep5 "${timeformat}")
-if (NOT timeStep5 GREATER timeStep4)
- message(SEND_ERROR "File (${rccDependsBin}) should have changed in the fitfh step!")
-endif()
-# Sleep, touch generated qrc newly added input file, rebuild and compare timestamp
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
-execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${RCC_DEPENDS_BIN}/res2/inputAdded.txt")
-execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${RCC_DEPENDS_BIN}" RESULT_VARIABLE result)
-if (result)
- message(SEND_ERROR "Seventh build of rccDepends failed.")
-endif()
-file(TIMESTAMP "${rccDependsBin}" timeStep6 "${timeformat}")
-if (NOT timeStep6 GREATER timeStep5)
- message(SEND_ERROR "File (${rccDependsBin}) should have changed in the sixth step!")
-endif()
-
-
-# -- Test
-# Ensure a repeated build succeeds when a header containing a QObject changes
-set(timeformat "%Y%j%H%M%S")
-configure_file(mocRerun/test1a.h.in mocRerun/test1.h COPYONLY)
-try_compile(MOC_RERUN
- "${CMAKE_CURRENT_BINARY_DIR}/mocRerun"
- "${CMAKE_CURRENT_SOURCE_DIR}/mocRerun"
- mocRerun
- CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
- "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
- "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
- OUTPUT_VARIABLE output
-)
-if (NOT MOC_RERUN)
- message(SEND_ERROR "Initial build of mocRerun failed. Output: ${output}")
-endif()
-# Get name and timestamp of the output binary
-file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/mocRerun/target1.txt" target1List)
-list(GET target1List 0 binFile)
-file(TIMESTAMP "${binFile}" timeBegin "${timeformat}")
-# Change file content and rebuild
-execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
-configure_file(mocRerun/test1b.h.in mocRerun/test1.h COPYONLY)
-execute_process(COMMAND "${CMAKE_COMMAND}" --build .
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mocRerun"
- RESULT_VARIABLE mocRerun_result
- )
-if (mocRerun_result)
- message(SEND_ERROR "Second build of mocRerun failed.")
-endif()
-# Compare timestamps
-file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}")
-if (NOT timeStep1 GREATER timeBegin)
- message(SEND_ERROR "File (${binFile}) should have changed in the first step!")
-endif()
-
-# -- Test
-# Test for SKIP_AUTOMOC and SKIP_AUTOGEN on an AUTOMOC enabled target
-qtx_wrap_cpp(skipMocWrapMoc
- skipSource/qItemA.hpp
- skipSource/qItemB.hpp)
-set(skipMocSources
- skipMoc.cpp
- skipSource/qItemA.cpp
- skipSource/qItemB.cpp
- skipSource/qItemC.cpp)
-set_property(SOURCE skipSource/qItemA.cpp PROPERTY SKIP_AUTOMOC ON)
-set_property(SOURCE skipSource/qItemB.cpp PROPERTY SKIP_AUTOGEN ON)
-# AUTOMOC enabled only
-add_executable(skipMocA ${skipMocSources} ${skipMocWrapMoc})
-set_property(TARGET skipMocA PROPERTY AUTOMOC ON)
-target_link_libraries(skipMocA ${QT_LIBRARIES})
-# AUTOMOC and AUTOUIC enabled
-add_executable(skipMocB ${skipMocSources} ${skipMocWrapMoc})
-set_property(TARGET skipMocB PROPERTY AUTOMOC ON)
-set_property(TARGET skipMocB PROPERTY AUTOUIC ON)
-target_link_libraries(skipMocB ${QT_LIBRARIES})
-
-# -- Test
-# Test for SKIP_AUTOUIC and SKIP_AUTOGEN on an AUTOUIC enabled target
-set(skipUicSources
- skipUic.cpp
- skipSource/skipUicGen.cpp
- skipSource/skipUicNoGen1.cpp
- skipSource/skipUicNoGen2.cpp
-)
-set_property(SOURCE skipSource/skipUicNoGen1.cpp PROPERTY SKIP_AUTOUIC ON)
-set_property(SOURCE skipSource/skipUicNoGen2.cpp PROPERTY SKIP_AUTOGEN ON)
-# AUTOUIC enabled
-add_executable(skipUicA ${skipUicSources})
-set_property(TARGET skipUicA PROPERTY AUTOUIC ON)
-target_link_libraries(skipUicA ${QT_LIBRARIES})
-# AUTOUIC and AUTOMOC enabled
-add_executable(skipUicB ${skipUicSources})
-set_property(TARGET skipUicB PROPERTY AUTOUIC ON)
-set_property(TARGET skipUicB PROPERTY AUTOMOC ON)
-target_link_libraries(skipUicB ${QT_LIBRARIES})
-
-# -- Test
-# Test for SKIP_AUTORCC and SKIP_AUTOGEN on an AUTORCC enabled target
-set(skipRccSources
- skipRcc.cpp
- skipSource/skipRccBad1.qrc
- skipSource/skipRccBad2.qrc
- skipSource/skipRccGood.qrc
-)
-set_property(SOURCE skipSource/skipRccBad1.qrc PROPERTY SKIP_AUTORCC ON)
-set_property(SOURCE skipSource/skipRccBad2.qrc PROPERTY SKIP_AUTOGEN ON)
-# AUTORCC enabled
-add_executable(skipRccA ${skipRccSources})
-set_property(TARGET skipRccA PROPERTY AUTORCC ON)
-target_link_libraries(skipRccA ${QT_LIBRARIES})
-# AUTORCC, AUTOUIC and AUTOMOC enabled
-add_executable(skipRccB ${skipRccSources})
-set_property(TARGET skipRccB PROPERTY AUTORCC ON)
-set_property(TARGET skipRccB PROPERTY AUTOUIC ON)
-set_property(TARGET skipRccB PROPERTY AUTOMOC ON)
-target_link_libraries(skipRccB ${QT_LIBRARIES})
-
-# -- Test
-# Source files with the same basename in different subdirectories
-add_subdirectory(sameName)
-
-# -- Test
-# Tests AUTOMOC with generated sources
-add_subdirectory(mocDepends)
-
-# -- Test
-# Tests various include moc patterns
-add_subdirectory(mocIncludeStrict)
-
-# -- Test
-# Tests various include moc patterns
-add_subdirectory(mocIncludeRelaxed)
-
-# -- Test
-# Tests Q_PLUGIN_METADATA json file change detection
-if (NOT QT_TEST_VERSION STREQUAL 4)
- try_compile(MOC_PLUGIN
- "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin"
- "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin"
- mocPlugin
- CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
- "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
- OUTPUT_VARIABLE output
- )
- if (NOT MOC_PLUGIN)
- message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}")
- endif()
-
- set(timeformat "%Y%j%H%M%S")
- set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/mocPlugin")
- set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/mocPlugin")
- find_library(plAFile "PlugA" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
- find_library(plBFile "PlugB" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
- find_library(plCFile "PlugC" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
- find_library(plDFile "PlugD" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
-
- file(TIMESTAMP "${plAFile}" plABefore "${timeformat}")
- file(TIMESTAMP "${plBFile}" plBBefore "${timeformat}")
- file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}")
- file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}")
-
- # Ensure that the timestamp will change and change the json files
- execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
- configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json")
- configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json")
- execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}")
-
- file(TIMESTAMP "${plAFile}" plAAfter "${timeformat}")
- file(TIMESTAMP "${plBFile}" plBAfter "${timeformat}")
- file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}")
- file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}")
-
- if (plAAfter GREATER plABefore)
- message(SEND_ERROR "file (${plAFile}) should not have changed!")
- endif()
- if (plBAfter GREATER plBBefore)
- message(SEND_ERROR "file (${plBFile}) should not have changed!")
- endif()
- if (NOT plCAfter GREATER plCBefore)
- message(SEND_ERROR "file (${plCFile}) should have changed!")
- endif()
- if (NOT plDAfter GREATER plDBefore)
- message(SEND_ERROR "file (${plDFile}) should have changed!")
- endif()
-
- # Test custom macro
- file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}")
- file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}")
- execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
- configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json")
- configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json")
- execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}")
- file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}")
- file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}")
- if (NOT plCAfter GREATER plCBefore)
- message(SEND_ERROR "file (${plCFile}) should have changed!")
- endif()
- if (NOT plDAfter GREATER plDBefore)
- message(SEND_ERROR "file (${plDFile}) should have changed!")
- endif()
-
-endif()
-
-# -- Test
-# Tests various .ui include directories
-add_subdirectory(uicInclude)
-
-# -- Test
-# Complex test case
-add_subdirectory(complex)
diff --git a/Tests/QtAutogen/complex/Adir/CMakeLists.txt b/Tests/QtAutogen/Complex/Adir/CMakeLists.txt
index a1c36ffce..a1c36ffce 100644
--- a/Tests/QtAutogen/complex/Adir/CMakeLists.txt
+++ b/Tests/QtAutogen/Complex/Adir/CMakeLists.txt
diff --git a/Tests/QtAutogen/complex/Adir/libA.cpp b/Tests/QtAutogen/Complex/Adir/libA.cpp
index f79f24af4..f79f24af4 100644
--- a/Tests/QtAutogen/complex/Adir/libA.cpp
+++ b/Tests/QtAutogen/Complex/Adir/libA.cpp
diff --git a/Tests/QtAutogen/Complex/Adir/libA.h b/Tests/QtAutogen/Complex/Adir/libA.h
new file mode 100644
index 000000000..a8ca20907
--- /dev/null
+++ b/Tests/QtAutogen/Complex/Adir/libA.h
@@ -0,0 +1,18 @@
+
+#ifndef LIBA_H
+#define LIBA_H
+
+#include <QObject>
+
+#include "liba_export.h"
+
+class LIBA_EXPORT LibA : public QObject
+{
+ Q_OBJECT
+public:
+ explicit LibA(QObject* parent = 0);
+
+ int foo();
+};
+
+#endif
diff --git a/Tests/QtAutogen/complex/Bdir/CMakeLists.txt b/Tests/QtAutogen/Complex/Bdir/CMakeLists.txt
index d33876308..d33876308 100644
--- a/Tests/QtAutogen/complex/Bdir/CMakeLists.txt
+++ b/Tests/QtAutogen/Complex/Bdir/CMakeLists.txt
diff --git a/Tests/QtAutogen/complex/Bdir/libB.cpp b/Tests/QtAutogen/Complex/Bdir/libB.cpp
index d3b675333..d3b675333 100644
--- a/Tests/QtAutogen/complex/Bdir/libB.cpp
+++ b/Tests/QtAutogen/Complex/Bdir/libB.cpp
diff --git a/Tests/QtAutogen/Complex/Bdir/libB.h b/Tests/QtAutogen/Complex/Bdir/libB.h
new file mode 100644
index 000000000..38dae87cb
--- /dev/null
+++ b/Tests/QtAutogen/Complex/Bdir/libB.h
@@ -0,0 +1,22 @@
+
+#ifndef LIBB_H
+#define LIBB_H
+
+#include <QObject>
+
+#include "libA.h"
+#include "libb_export.h"
+
+class LIBB_EXPORT LibB : public QObject
+{
+ Q_OBJECT
+public:
+ explicit LibB(QObject* parent = 0);
+
+ int foo();
+
+private:
+ LibA a;
+};
+
+#endif
diff --git a/Tests/QtAutogen/Complex/CMakeLists.txt b/Tests/QtAutogen/Complex/CMakeLists.txt
new file mode 100644
index 000000000..d9fdf5cf4
--- /dev/null
+++ b/Tests/QtAutogen/Complex/CMakeLists.txt
@@ -0,0 +1,85 @@
+cmake_minimum_required(VERSION 3.10)
+project(Complex)
+include("../AutogenGuiTest.cmake")
+
+# -- Test: AUTOMOC AUTORCC AUTOUIC
+add_definitions(-DFOO -DSomeDefine="Barx")
+
+# enable relaxed mode so automoc can handle all the special cases:
+set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTORCC ON)
+
+# create an executable and two library targets, each requiring automoc:
+add_library(codeeditorLib STATIC codeeditor.cpp)
+add_library(privateSlot OBJECT private_slot.cpp)
+# Pass Qt compiler features to targets that don't link against Qt
+target_compile_features(codeeditorLib PRIVATE ${QT_COMPILE_FEATURES})
+target_compile_features(privateSlot PRIVATE ${QT_COMPILE_FEATURES})
+
+configure_file(generated_resource.qrc.in generated_resource.qrc @ONLY)
+add_custom_command(
+ OUTPUT generated.txt
+ COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/generated.txt.in" "${CMAKE_CURRENT_BINARY_DIR}/generated.txt"
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/generated.txt.in"
+)
+
+add_custom_target(generate_moc_input
+ DEPENDS generated.txt
+ COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}"
+ COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h"
+)
+
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h"
+ COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h"
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in"
+)
+
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(NOT _isMultiConfig AND NOT CMAKE_GENERATOR STREQUAL Ninja)
+ set(debug_srcs "$<$<CONFIG:Debug>:debug_class.cpp>" $<$<CONFIG:Debug>:debug_resource.qrc>)
+ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:TEST_DEBUG_CLASS>)
+endif()
+
+# The -no-protection option disables the generation of include guards. Verify
+# that setting the source file property has an effect by using this and
+# issue an error in the preprocessor in calwidget.cpp if the include guard
+# is defined.
+set_source_files_properties(calwidget.ui PROPERTIES AUTOUIC_OPTIONS "-no-protection")
+
+add_executable(QtAutogen main.cpp calwidget.cpp second_widget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
+ multiplewidgets.cpp
+ xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>
+ test.qrc second_resource.qrc resourcetester.cpp generated.cpp ${debug_srcs}
+ ${CMAKE_CURRENT_BINARY_DIR}/generated_resource.qrc
+)
+set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h")
+
+add_executable(targetObjectsTest targetObjectsTest.cpp $<TARGET_OBJECTS:privateSlot>)
+target_link_libraries(targetObjectsTest ${QT_LIBRARIES})
+
+set_target_properties(
+ QtAutogen codeeditorLib privateSlot targetObjectsTest
+ PROPERTIES
+ AUTOMOC TRUE
+)
+
+
+include(GenerateExportHeader)
+# The order is relevant here. B depends on A, and B headers depend on A
+# headers both subdirectories use CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE and we
+# test that CMAKE_AUTOMOC successfully reads the include directories
+# for the build interface from those targets. There has previously been
+# a bug where caching of the include directories happened before
+# extracting the includes to pass to moc.
+add_subdirectory(Bdir)
+add_subdirectory(Adir)
+add_library(libC SHARED libC.cpp)
+set_target_properties(libC PROPERTIES AUTOMOC TRUE)
+generate_export_header(libC)
+target_link_libraries(libC LINK_PUBLIC libB)
+target_include_directories(libC PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+set_property(TARGET libC APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR} )
+
+target_link_libraries(QtAutogen codeeditorLib ${QT_LIBRARIES} libC)
diff --git a/Tests/QtAutogen/Complex/abc.cpp b/Tests/QtAutogen/Complex/abc.cpp
new file mode 100644
index 000000000..4c7dc52cb
--- /dev/null
+++ b/Tests/QtAutogen/Complex/abc.cpp
@@ -0,0 +1,40 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "abc.h"
+
+#include <stdio.h>
+
+#include "abc_p.h"
+
+class PrintAbc : public QObject
+{
+ Q_OBJECT
+public:
+ PrintAbc()
+ : QObject()
+ {
+ }
+public slots:
+ void print() const { printf("abc\n"); }
+};
+
+Abc::Abc()
+ : QObject()
+{
+}
+
+void Abc::doAbc()
+{
+ PrintAbc pa;
+ pa.print();
+ AbcP abcP;
+ abcP.doAbcP();
+}
+
+// check that including the moc file for the cpp file and the header works:
+#include "abc.moc"
+#include "moc_abc.cpp"
+#include "moc_abc_p.cpp"
+
+// check that including a moc file from another header works:
+#include "moc_xyz.cpp"
diff --git a/Tests/QtAutogen/complex/abc.h b/Tests/QtAutogen/Complex/abc.h
index ec5f4115a..ec5f4115a 100644
--- a/Tests/QtAutogen/complex/abc.h
+++ b/Tests/QtAutogen/Complex/abc.h
diff --git a/Tests/QtAutogen/Complex/abc_p.h b/Tests/QtAutogen/Complex/abc_p.h
new file mode 100644
index 000000000..1f6102cd0
--- /dev/null
+++ b/Tests/QtAutogen/Complex/abc_p.h
@@ -0,0 +1,19 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef ABC_P_H
+#define ABC_P_H
+
+#include <stdio.h>
+
+#include <QObject>
+
+class AbcP : public QObject
+{
+ Q_OBJECT
+public:
+ AbcP() {}
+public slots:
+ void doAbcP() { printf("I am private abc !\n"); }
+};
+
+#endif
diff --git a/Tests/QtAutogen/complex/bar.cpp b/Tests/QtAutogen/Complex/bar.cpp
index 734bd7a8e..734bd7a8e 100644
--- a/Tests/QtAutogen/complex/bar.cpp
+++ b/Tests/QtAutogen/Complex/bar.cpp
diff --git a/Tests/QtAutogen/complex/blub.cpp b/Tests/QtAutogen/Complex/blub.cpp
index 1c497e00f..1c497e00f 100644
--- a/Tests/QtAutogen/complex/blub.cpp
+++ b/Tests/QtAutogen/Complex/blub.cpp
diff --git a/Tests/QtAutogen/complex/blub.h b/Tests/QtAutogen/Complex/blub.h
index ff798782b..ff798782b 100644
--- a/Tests/QtAutogen/complex/blub.h
+++ b/Tests/QtAutogen/Complex/blub.h
diff --git a/Tests/QtAutogen/Complex/calwidget.cpp b/Tests/QtAutogen/Complex/calwidget.cpp
new file mode 100644
index 000000000..f58b18247
--- /dev/null
+++ b/Tests/QtAutogen/Complex/calwidget.cpp
@@ -0,0 +1,436 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+ ** All rights reserved.
+ ** Contact: Nokia Corporation (qt-info@nokia.com)
+ **
+ ** This file is part of the examples of the Qt Toolkit.
+ **
+ ** $QT_BEGIN_LICENSE:BSD$
+ ** You may use this file under the terms of the BSD license as follows:
+ **
+ ** "Redistribution and use in source and binary forms, with or without
+ ** modification, are permitted provided that the following conditions are
+ ** met:
+ ** * Redistributions of source code must retain the above copyright
+ ** notice, this list of conditions and the following disclaimer.
+ ** * Redistributions in binary form must reproduce the above copyright
+ ** notice, this list of conditions and the following disclaimer in
+ ** the documentation and/or other materials provided with the
+ ** distribution.
+ ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+ ** the names of its contributors may be used to endorse or promote
+ ** products derived from this software without specific prior written
+ ** permission.
+ **
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+
+#include "calwidget.h"
+
+#include <QCalendarWidget>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QDateEdit>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QLabel>
+#include <QTextCharFormat>
+
+#include "ui_calwidget.h"
+#ifdef UI_CALWIDGET_H
+# error Definition of UI_CALWIDGET_H should be disabled by file option.
+#endif
+
+Window::Window()
+ : ui(new Ui::Window)
+{
+ createPreviewGroupBox();
+ createGeneralOptionsGroupBox();
+ createDatesGroupBox();
+ createTextFormatsGroupBox();
+
+ QGridLayout* layout = new QGridLayout;
+ layout->addWidget(previewGroupBox, 0, 0);
+ layout->addWidget(generalOptionsGroupBox, 0, 1);
+ layout->addWidget(datesGroupBox, 1, 0);
+ layout->addWidget(textFormatsGroupBox, 1, 1);
+ layout->setSizeConstraint(QLayout::SetFixedSize);
+ setLayout(layout);
+
+ previewLayout->setRowMinimumHeight(0, calendar->sizeHint().height());
+ previewLayout->setColumnMinimumWidth(0, calendar->sizeHint().width());
+
+ setWindowTitle(tr("Calendar Widget"));
+}
+
+void Window::localeChanged(int index)
+{
+ calendar->setLocale(localeCombo->itemData(index).toLocale());
+}
+
+void Window::firstDayChanged(int index)
+{
+ calendar->setFirstDayOfWeek(
+ Qt::DayOfWeek(firstDayCombo->itemData(index).toInt()));
+}
+
+void Window::selectionModeChanged(int index)
+{
+ calendar->setSelectionMode(QCalendarWidget::SelectionMode(
+ selectionModeCombo->itemData(index).toInt()));
+}
+
+void Window::horizontalHeaderChanged(int index)
+{
+ calendar->setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat(
+ horizontalHeaderCombo->itemData(index).toInt()));
+}
+
+void Window::verticalHeaderChanged(int index)
+{
+ calendar->setVerticalHeaderFormat(QCalendarWidget::VerticalHeaderFormat(
+ verticalHeaderCombo->itemData(index).toInt()));
+}
+
+void Window::selectedDateChanged()
+{
+ currentDateEdit->setDate(calendar->selectedDate());
+}
+
+void Window::minimumDateChanged(const QDate& date)
+{
+ calendar->setMinimumDate(date);
+ maximumDateEdit->setDate(calendar->maximumDate());
+}
+
+void Window::maximumDateChanged(const QDate& date)
+{
+ calendar->setMaximumDate(date);
+ minimumDateEdit->setDate(calendar->minimumDate());
+}
+
+void Window::weekdayFormatChanged()
+{
+ QTextCharFormat format;
+
+ format.setForeground(qvariant_cast<QColor>(
+ weekdayColorCombo->itemData(weekdayColorCombo->currentIndex())));
+ calendar->setWeekdayTextFormat(Qt::Monday, format);
+ calendar->setWeekdayTextFormat(Qt::Tuesday, format);
+ calendar->setWeekdayTextFormat(Qt::Wednesday, format);
+ calendar->setWeekdayTextFormat(Qt::Thursday, format);
+ calendar->setWeekdayTextFormat(Qt::Friday, format);
+}
+
+void Window::weekendFormatChanged()
+{
+ QTextCharFormat format;
+
+ format.setForeground(qvariant_cast<QColor>(
+ weekendColorCombo->itemData(weekendColorCombo->currentIndex())));
+ calendar->setWeekdayTextFormat(Qt::Saturday, format);
+ calendar->setWeekdayTextFormat(Qt::Sunday, format);
+}
+
+void Window::reformatHeaders()
+{
+ QString text = headerTextFormatCombo->currentText();
+ QTextCharFormat format;
+
+ if (text == tr("Bold")) {
+ format.setFontWeight(QFont::Bold);
+ } else if (text == tr("Italic")) {
+ format.setFontItalic(true);
+ } else if (text == tr("Green")) {
+ format.setForeground(Qt::green);
+ }
+ calendar->setHeaderTextFormat(format);
+}
+
+void Window::reformatCalendarPage()
+{
+ if (firstFridayCheckBox->isChecked()) {
+ QDate firstFriday(calendar->yearShown(), calendar->monthShown(), 1);
+ while (firstFriday.dayOfWeek() != Qt::Friday)
+ firstFriday = firstFriday.addDays(1);
+ QTextCharFormat firstFridayFormat;
+ firstFridayFormat.setForeground(Qt::blue);
+ calendar->setDateTextFormat(firstFriday, firstFridayFormat);
+ }
+
+ // May First in Red takes precedence
+ if (mayFirstCheckBox->isChecked()) {
+ const QDate mayFirst(calendar->yearShown(), 5, 1);
+ QTextCharFormat mayFirstFormat;
+ mayFirstFormat.setForeground(Qt::red);
+ calendar->setDateTextFormat(mayFirst, mayFirstFormat);
+ }
+}
+
+void Window::createPreviewGroupBox()
+{
+ previewGroupBox = new QGroupBox(tr("Preview"));
+
+ calendar = new QCalendarWidget;
+ calendar->setMinimumDate(QDate(1900, 1, 1));
+ calendar->setMaximumDate(QDate(3000, 1, 1));
+ calendar->setGridVisible(true);
+
+ connect(calendar, SIGNAL(currentPageChanged(int, int)), this,
+ SLOT(reformatCalendarPage()));
+
+ previewLayout = new QGridLayout;
+ previewLayout->addWidget(calendar, 0, 0, Qt::AlignCenter);
+ previewGroupBox->setLayout(previewLayout);
+}
+
+void Window::createGeneralOptionsGroupBox()
+{
+ generalOptionsGroupBox = new QGroupBox(tr("General Options"));
+
+ localeCombo = new QComboBox;
+ int curLocaleIndex = -1;
+ int index = 0;
+ for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) {
+ QLocale::Language lang = static_cast<QLocale::Language>(_lang);
+ QList<QLocale::Country> countries = QLocale::countriesForLanguage(lang);
+ for (int i = 0; i < countries.count(); ++i) {
+ QLocale::Country country = countries.at(i);
+ QString label = QLocale::languageToString(lang);
+ label += QLatin1Char('/');
+ label += QLocale::countryToString(country);
+ QLocale locale(lang, country);
+ if (this->locale().language() == lang &&
+ this->locale().country() == country)
+ curLocaleIndex = index;
+ localeCombo->addItem(label, locale);
+ ++index;
+ }
+ }
+ if (curLocaleIndex != -1)
+ localeCombo->setCurrentIndex(curLocaleIndex);
+ localeLabel = new QLabel(tr("&Locale"));
+ localeLabel->setBuddy(localeCombo);
+
+ firstDayCombo = new QComboBox;
+ firstDayCombo->addItem(tr("Sunday"), Qt::Sunday);
+ firstDayCombo->addItem(tr("Monday"), Qt::Monday);
+ firstDayCombo->addItem(tr("Tuesday"), Qt::Tuesday);
+ firstDayCombo->addItem(tr("Wednesday"), Qt::Wednesday);
+ firstDayCombo->addItem(tr("Thursday"), Qt::Thursday);
+ firstDayCombo->addItem(tr("Friday"), Qt::Friday);
+ firstDayCombo->addItem(tr("Saturday"), Qt::Saturday);
+
+ firstDayLabel = new QLabel(tr("Wee&k starts on:"));
+ firstDayLabel->setBuddy(firstDayCombo);
+
+ selectionModeCombo = new QComboBox;
+ selectionModeCombo->addItem(tr("Single selection"),
+ QCalendarWidget::SingleSelection);
+ selectionModeCombo->addItem(tr("None"), QCalendarWidget::NoSelection);
+
+ selectionModeLabel = new QLabel(tr("&Selection mode:"));
+ selectionModeLabel->setBuddy(selectionModeCombo);
+
+ gridCheckBox = new QCheckBox(tr("&Grid"));
+ gridCheckBox->setChecked(calendar->isGridVisible());
+
+ navigationCheckBox = new QCheckBox(tr("&Navigation bar"));
+ navigationCheckBox->setChecked(true);
+
+ horizontalHeaderCombo = new QComboBox;
+ horizontalHeaderCombo->addItem(tr("Single letter day names"),
+ QCalendarWidget::SingleLetterDayNames);
+ horizontalHeaderCombo->addItem(tr("Short day names"),
+ QCalendarWidget::ShortDayNames);
+ horizontalHeaderCombo->addItem(tr("None"),
+ QCalendarWidget::NoHorizontalHeader);
+ horizontalHeaderCombo->setCurrentIndex(1);
+
+ horizontalHeaderLabel = new QLabel(tr("&Horizontal header:"));
+ horizontalHeaderLabel->setBuddy(horizontalHeaderCombo);
+
+ verticalHeaderCombo = new QComboBox;
+ verticalHeaderCombo->addItem(tr("ISO week numbers"),
+ QCalendarWidget::ISOWeekNumbers);
+ verticalHeaderCombo->addItem(tr("None"), QCalendarWidget::NoVerticalHeader);
+
+ verticalHeaderLabel = new QLabel(tr("&Vertical header:"));
+ verticalHeaderLabel->setBuddy(verticalHeaderCombo);
+
+ connect(localeCombo, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(localeChanged(int)));
+ connect(firstDayCombo, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(firstDayChanged(int)));
+ connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(selectionModeChanged(int)));
+ connect(gridCheckBox, SIGNAL(toggled(bool)), calendar,
+ SLOT(setGridVisible(bool)));
+ connect(navigationCheckBox, SIGNAL(toggled(bool)), calendar,
+ SLOT(setNavigationBarVisible(bool)));
+ connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(horizontalHeaderChanged(int)));
+ connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(verticalHeaderChanged(int)));
+
+ QHBoxLayout* checkBoxLayout = new QHBoxLayout;
+ checkBoxLayout->addWidget(gridCheckBox);
+ checkBoxLayout->addStretch();
+ checkBoxLayout->addWidget(navigationCheckBox);
+
+ QGridLayout* outerLayout = new QGridLayout;
+ outerLayout->addWidget(localeLabel, 0, 0);
+ outerLayout->addWidget(localeCombo, 0, 1);
+ outerLayout->addWidget(firstDayLabel, 1, 0);
+ outerLayout->addWidget(firstDayCombo, 1, 1);
+ outerLayout->addWidget(selectionModeLabel, 2, 0);
+ outerLayout->addWidget(selectionModeCombo, 2, 1);
+ outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2);
+ outerLayout->addWidget(horizontalHeaderLabel, 4, 0);
+ outerLayout->addWidget(horizontalHeaderCombo, 4, 1);
+ outerLayout->addWidget(verticalHeaderLabel, 5, 0);
+ outerLayout->addWidget(verticalHeaderCombo, 5, 1);
+ generalOptionsGroupBox->setLayout(outerLayout);
+
+ firstDayChanged(firstDayCombo->currentIndex());
+ selectionModeChanged(selectionModeCombo->currentIndex());
+ horizontalHeaderChanged(horizontalHeaderCombo->currentIndex());
+ verticalHeaderChanged(verticalHeaderCombo->currentIndex());
+}
+
+void Window::createDatesGroupBox()
+{
+ datesGroupBox = new QGroupBox(tr("Dates"));
+
+ minimumDateEdit = new QDateEdit;
+ minimumDateEdit->setDisplayFormat("MMM d yyyy");
+ minimumDateEdit->setDateRange(calendar->minimumDate(),
+ calendar->maximumDate());
+ minimumDateEdit->setDate(calendar->minimumDate());
+
+ minimumDateLabel = new QLabel(tr("&Minimum Date:"));
+ minimumDateLabel->setBuddy(minimumDateEdit);
+
+ currentDateEdit = new QDateEdit;
+ currentDateEdit->setDisplayFormat("MMM d yyyy");
+ currentDateEdit->setDate(calendar->selectedDate());
+ currentDateEdit->setDateRange(calendar->minimumDate(),
+ calendar->maximumDate());
+
+ currentDateLabel = new QLabel(tr("&Current Date:"));
+ currentDateLabel->setBuddy(currentDateEdit);
+
+ maximumDateEdit = new QDateEdit;
+ maximumDateEdit->setDisplayFormat("MMM d yyyy");
+ maximumDateEdit->setDateRange(calendar->minimumDate(),
+ calendar->maximumDate());
+ maximumDateEdit->setDate(calendar->maximumDate());
+
+ maximumDateLabel = new QLabel(tr("Ma&ximum Date:"));
+ maximumDateLabel->setBuddy(maximumDateEdit);
+
+ connect(currentDateEdit, SIGNAL(dateChanged(QDate)), calendar,
+ SLOT(setSelectedDate(QDate)));
+ connect(calendar, SIGNAL(selectionChanged()), this,
+ SLOT(selectedDateChanged()));
+ connect(minimumDateEdit, SIGNAL(dateChanged(QDate)), this,
+ SLOT(minimumDateChanged(QDate)));
+ connect(maximumDateEdit, SIGNAL(dateChanged(QDate)), this,
+ SLOT(maximumDateChanged(QDate)));
+
+ QGridLayout* dateBoxLayout = new QGridLayout;
+ dateBoxLayout->addWidget(currentDateLabel, 1, 0);
+ dateBoxLayout->addWidget(currentDateEdit, 1, 1);
+ dateBoxLayout->addWidget(minimumDateLabel, 0, 0);
+ dateBoxLayout->addWidget(minimumDateEdit, 0, 1);
+ dateBoxLayout->addWidget(maximumDateLabel, 2, 0);
+ dateBoxLayout->addWidget(maximumDateEdit, 2, 1);
+ dateBoxLayout->setRowStretch(3, 1);
+
+ datesGroupBox->setLayout(dateBoxLayout);
+}
+
+void Window::createTextFormatsGroupBox()
+{
+ textFormatsGroupBox = new QGroupBox(tr("Text Formats"));
+
+ weekdayColorCombo = createColorComboBox();
+ weekdayColorCombo->setCurrentIndex(weekdayColorCombo->findText(tr("Black")));
+
+ weekdayColorLabel = new QLabel(tr("&Weekday color:"));
+ weekdayColorLabel->setBuddy(weekdayColorCombo);
+
+ weekendColorCombo = createColorComboBox();
+ weekendColorCombo->setCurrentIndex(weekendColorCombo->findText(tr("Red")));
+
+ weekendColorLabel = new QLabel(tr("Week&end color:"));
+ weekendColorLabel->setBuddy(weekendColorCombo);
+
+ headerTextFormatCombo = new QComboBox;
+ headerTextFormatCombo->addItem(tr("Bold"));
+ headerTextFormatCombo->addItem(tr("Italic"));
+ headerTextFormatCombo->addItem(tr("Plain"));
+
+ headerTextFormatLabel = new QLabel(tr("&Header text:"));
+ headerTextFormatLabel->setBuddy(headerTextFormatCombo);
+
+ firstFridayCheckBox = new QCheckBox(tr("&First Friday in blue"));
+
+ mayFirstCheckBox = new QCheckBox(tr("May &1 in red"));
+
+ connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(weekdayFormatChanged()));
+ connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(weekendFormatChanged()));
+ connect(headerTextFormatCombo, SIGNAL(currentIndexChanged(QString)), this,
+ SLOT(reformatHeaders()));
+ connect(firstFridayCheckBox, SIGNAL(toggled(bool)), this,
+ SLOT(reformatCalendarPage()));
+ connect(mayFirstCheckBox, SIGNAL(toggled(bool)), this,
+ SLOT(reformatCalendarPage()));
+
+ QHBoxLayout* checkBoxLayout = new QHBoxLayout;
+ checkBoxLayout->addWidget(firstFridayCheckBox);
+ checkBoxLayout->addStretch();
+ checkBoxLayout->addWidget(mayFirstCheckBox);
+
+ QGridLayout* outerLayout = new QGridLayout;
+ outerLayout->addWidget(weekdayColorLabel, 0, 0);
+ outerLayout->addWidget(weekdayColorCombo, 0, 1);
+ outerLayout->addWidget(weekendColorLabel, 1, 0);
+ outerLayout->addWidget(weekendColorCombo, 1, 1);
+ outerLayout->addWidget(headerTextFormatLabel, 2, 0);
+ outerLayout->addWidget(headerTextFormatCombo, 2, 1);
+ outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2);
+ textFormatsGroupBox->setLayout(outerLayout);
+
+ weekdayFormatChanged();
+ weekendFormatChanged();
+ reformatHeaders();
+ reformatCalendarPage();
+}
+
+QComboBox* Window::createColorComboBox()
+{
+ QComboBox* comboBox = new QComboBox;
+ comboBox->addItem(tr("Red"), QColor(Qt::red));
+ comboBox->addItem(tr("Blue"), QColor(Qt::blue));
+ comboBox->addItem(tr("Black"), QColor(Qt::black));
+ comboBox->addItem(tr("Magenta"), QColor(Qt::magenta));
+ return comboBox;
+}
+
+//#include "moc_calwidget.cpp"
diff --git a/Tests/QtAutogen/complex/calwidget.h b/Tests/QtAutogen/Complex/calwidget.h
index 084d959bd..084d959bd 100644
--- a/Tests/QtAutogen/complex/calwidget.h
+++ b/Tests/QtAutogen/Complex/calwidget.h
diff --git a/Tests/QtAutogen/complex/calwidget.ui b/Tests/QtAutogen/Complex/calwidget.ui
index 1c245cac9..1c245cac9 100644
--- a/Tests/QtAutogen/complex/calwidget.ui
+++ b/Tests/QtAutogen/Complex/calwidget.ui
diff --git a/Tests/QtAutogen/Complex/codeeditor.cpp b/Tests/QtAutogen/Complex/codeeditor.cpp
new file mode 100644
index 000000000..bb6f405ad
--- /dev/null
+++ b/Tests/QtAutogen/Complex/codeeditor.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+ ** All rights reserved.
+ ** Contact: Nokia Corporation (qt-info@nokia.com)
+ **
+ ** This file is part of the examples of the Qt Toolkit.
+ **
+ ** $QT_BEGIN_LICENSE:BSD$
+ ** You may use this file under the terms of the BSD license as follows:
+ **
+ ** "Redistribution and use in source and binary forms, with or without
+ ** modification, are permitted provided that the following conditions are
+ ** met:
+ ** * Redistributions of source code must retain the above copyright
+ ** notice, this list of conditions and the following disclaimer.
+ ** * Redistributions in binary form must reproduce the above copyright
+ ** notice, this list of conditions and the following disclaimer in
+ ** the documentation and/or other materials provided with the
+ ** distribution.
+ ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+ ** the names of its contributors may be used to endorse or promote
+ ** products derived from this software without specific prior written
+ ** permission.
+ **
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+
+#include "codeeditor.h"
+
+#include <QtGui>
+
+CodeEditor::CodeEditor(QWidget* parent)
+ : QPlainTextEdit(parent)
+{
+ lineNumberArea = new LineNumberArea(this);
+
+ connect(this, SIGNAL(blockCountChanged(int)), this,
+ SLOT(updateLineNumberAreaWidth(int)));
+ connect(this, SIGNAL(updateRequest(QRect, int)), this,
+ SLOT(updateLineNumberArea(QRect, int)));
+ connect(this, SIGNAL(cursorPositionChanged()), this,
+ SLOT(highlightCurrentLine()));
+
+ updateLineNumberAreaWidth(0);
+ highlightCurrentLine();
+}
+
+int CodeEditor::lineNumberAreaWidth()
+{
+ int digits = 1;
+ int max = qMax(1, blockCount());
+ while (max >= 10) {
+ max /= 10;
+ ++digits;
+ }
+
+ int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
+
+ return space;
+}
+
+void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */)
+{
+ setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
+}
+
+void CodeEditor::updateLineNumberArea(const QRect& rect, int dy)
+{
+ if (dy)
+ lineNumberArea->scroll(0, dy);
+ else
+ lineNumberArea->update(0, rect.y(), lineNumberArea->width(),
+ rect.height());
+
+ if (rect.contains(viewport()->rect()))
+ updateLineNumberAreaWidth(0);
+}
+
+void CodeEditor::resizeEvent(QResizeEvent* e)
+{
+ QPlainTextEdit::resizeEvent(e);
+
+ QRect cr = contentsRect();
+ lineNumberArea->setGeometry(
+ QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
+}
+
+void CodeEditor::highlightCurrentLine()
+{
+ QList<QTextEdit::ExtraSelection> extraSelections;
+
+ if (!isReadOnly()) {
+ QTextEdit::ExtraSelection selection;
+
+ QColor lineColor = QColor(Qt::yellow).lighter(160);
+
+ selection.format.setBackground(lineColor);
+ selection.format.setProperty(QTextFormat::FullWidthSelection, true);
+ selection.cursor = textCursor();
+ selection.cursor.clearSelection();
+ extraSelections.append(selection);
+ }
+
+ setExtraSelections(extraSelections);
+}
+
+void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent* event)
+{
+ QPainter painter(lineNumberArea);
+ painter.fillRect(event->rect(), Qt::lightGray);
+
+ QTextBlock block = firstVisibleBlock();
+ int blockNumber = block.blockNumber();
+ int top =
+ (int)blockBoundingGeometry(block).translated(contentOffset()).top();
+ int bottom = top + (int)blockBoundingRect(block).height();
+
+ while (block.isValid() && top <= event->rect().bottom()) {
+ if (block.isVisible() && bottom >= event->rect().top()) {
+ QString number = QString::number(blockNumber + 1);
+ painter.setPen(Qt::black);
+ painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(),
+ Qt::AlignRight, number);
+ }
+
+ block = block.next();
+ top = bottom;
+ bottom = top + (int)blockBoundingRect(block).height();
+ ++blockNumber;
+ }
+}
+
+#include "codeeditor.moc"
diff --git a/Tests/QtAutogen/complex/codeeditor.h b/Tests/QtAutogen/Complex/codeeditor.h
index b410bd4e6..b410bd4e6 100644
--- a/Tests/QtAutogen/complex/codeeditor.h
+++ b/Tests/QtAutogen/Complex/codeeditor.h
diff --git a/Tests/QtAutogen/Complex/debug_class.cpp b/Tests/QtAutogen/Complex/debug_class.cpp
new file mode 100644
index 000000000..3aaf79a08
--- /dev/null
+++ b/Tests/QtAutogen/Complex/debug_class.cpp
@@ -0,0 +1,11 @@
+
+#include "debug_class.h"
+
+#include "ui_debug_class.h"
+
+DebugClass::DebugClass(QWidget* parent)
+ : QWidget(parent)
+ , ui(new Ui::DebugClass)
+{
+ ui->setupUi(this);
+}
diff --git a/Tests/QtAutogen/complex/debug_class.h b/Tests/QtAutogen/Complex/debug_class.h
index c02f0ede6..c02f0ede6 100644
--- a/Tests/QtAutogen/complex/debug_class.h
+++ b/Tests/QtAutogen/Complex/debug_class.h
diff --git a/Tests/QtAutogen/complex/debug_class.ui b/Tests/QtAutogen/Complex/debug_class.ui
index dc2e1ac18..dc2e1ac18 100644
--- a/Tests/QtAutogen/complex/debug_class.ui
+++ b/Tests/QtAutogen/Complex/debug_class.ui
diff --git a/Tests/QtAutogen/complex/debug_resource.qrc b/Tests/QtAutogen/Complex/debug_resource.qrc
index db98b9bc1..db98b9bc1 100644
--- a/Tests/QtAutogen/complex/debug_resource.qrc
+++ b/Tests/QtAutogen/Complex/debug_resource.qrc
diff --git a/Tests/QtAutogen/complex/foo.cpp b/Tests/QtAutogen/Complex/foo.cpp
index f665eee01..f665eee01 100644
--- a/Tests/QtAutogen/complex/foo.cpp
+++ b/Tests/QtAutogen/Complex/foo.cpp
diff --git a/Tests/QtAutogen/complex/foo.h b/Tests/QtAutogen/Complex/foo.h
index 3e03fe6bd..3e03fe6bd 100644
--- a/Tests/QtAutogen/complex/foo.h
+++ b/Tests/QtAutogen/Complex/foo.h
diff --git a/Tests/QtAutogen/complex/gadget.cpp b/Tests/QtAutogen/Complex/gadget.cpp
index 23d95fa4a..23d95fa4a 100644
--- a/Tests/QtAutogen/complex/gadget.cpp
+++ b/Tests/QtAutogen/Complex/gadget.cpp
diff --git a/Tests/QtAutogen/complex/gadget.h b/Tests/QtAutogen/Complex/gadget.h
index 3253e31d9..3253e31d9 100644
--- a/Tests/QtAutogen/complex/gadget.h
+++ b/Tests/QtAutogen/Complex/gadget.h
diff --git a/Tests/QtAutogen/complex/generated.cpp b/Tests/QtAutogen/Complex/generated.cpp
index d514c619c..d514c619c 100644
--- a/Tests/QtAutogen/complex/generated.cpp
+++ b/Tests/QtAutogen/Complex/generated.cpp
diff --git a/Tests/QtAutogen/Complex/generated.h b/Tests/QtAutogen/Complex/generated.h
new file mode 100644
index 000000000..cac14dedb
--- /dev/null
+++ b/Tests/QtAutogen/Complex/generated.h
@@ -0,0 +1,21 @@
+
+#ifndef GENERATED_H
+#define GENERATED_H
+
+#include <QObject>
+
+#include "myinterface.h"
+#include "myotherinterface.h"
+
+class Generated
+ : public QObject
+ , MyInterface
+ , MyOtherInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(MyInterface MyOtherInterface)
+public:
+ explicit Generated(QObject* parent = 0);
+};
+
+#endif
diff --git a/Tests/QtAutogen/complex/generated.txt.in b/Tests/QtAutogen/Complex/generated.txt.in
index 77507bb8e..77507bb8e 100644
--- a/Tests/QtAutogen/complex/generated.txt.in
+++ b/Tests/QtAutogen/Complex/generated.txt.in
diff --git a/Tests/QtAutogen/complex/generated_resource.qrc.in b/Tests/QtAutogen/Complex/generated_resource.qrc.in
index da5fa6289..da5fa6289 100644
--- a/Tests/QtAutogen/complex/generated_resource.qrc.in
+++ b/Tests/QtAutogen/Complex/generated_resource.qrc.in
diff --git a/Tests/QtAutogen/complex/libC.cpp b/Tests/QtAutogen/Complex/libC.cpp
index a3acff161..a3acff161 100644
--- a/Tests/QtAutogen/complex/libC.cpp
+++ b/Tests/QtAutogen/Complex/libC.cpp
diff --git a/Tests/QtAutogen/Complex/libC.h b/Tests/QtAutogen/Complex/libC.h
new file mode 100644
index 000000000..51ea48d9e
--- /dev/null
+++ b/Tests/QtAutogen/Complex/libC.h
@@ -0,0 +1,22 @@
+
+#ifndef LIBC_H
+#define LIBC_H
+
+#include <QObject>
+
+#include "libB.h"
+#include "libc_export.h"
+
+class LIBC_EXPORT LibC : public QObject
+{
+ Q_OBJECT
+public:
+ explicit LibC(QObject* parent = 0);
+
+ int foo();
+
+private:
+ LibB b;
+};
+
+#endif
diff --git a/Tests/QtAutogen/Complex/main.cpp b/Tests/QtAutogen/Complex/main.cpp
new file mode 100644
index 000000000..12f649f03
--- /dev/null
+++ b/Tests/QtAutogen/Complex/main.cpp
@@ -0,0 +1,94 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+ ** All rights reserved.
+ ** Contact: Nokia Corporation (qt-info@nokia.com)
+ **
+ ** This file is part of the examples of the Qt Toolkit.
+ **
+ ** $QT_BEGIN_LICENSE:BSD$
+ ** You may use this file under the terms of the BSD license as follows:
+ **
+ ** "Redistribution and use in source and binary forms, with or without
+ ** modification, are permitted provided that the following conditions are
+ ** met:
+ ** * Redistributions of source code must retain the above copyright
+ ** notice, this list of conditions and the following disclaimer.
+ ** * Redistributions in binary form must reproduce the above copyright
+ ** notice, this list of conditions and the following disclaimer in
+ ** the documentation and/or other materials provided with the
+ ** distribution.
+ ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+ ** the names of its contributors may be used to endorse or promote
+ ** products derived from this software without specific prior written
+ ** permission.
+ **
+ ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+ ** $QT_END_LICENSE$
+ **
+ ****************************************************************************/
+
+#include <QCoreApplication>
+#include <QTimer>
+
+#include "abc.h"
+#include "blub.h"
+#include "calwidget.h"
+#include "codeeditor.h"
+#include "foo.h"
+#include "libC.h"
+#include "resourcetester.h"
+#include "sub/bar.h"
+#include "xyz.h"
+#include "yaf.h"
+#ifdef TEST_DEBUG_CLASS
+# include <iostream>
+
+# include "debug_class.h"
+#endif
+
+int main(int argv, char** args)
+{
+ QCoreApplication app(argv, args);
+
+ Foo foo;
+ foo.doFoo();
+
+ Blub b;
+ b.blubber();
+
+ Bar bar;
+ bar.doBar();
+
+ Abc abc;
+ abc.doAbc();
+
+ Xyz xyz;
+ xyz.doXyz();
+
+ Yaf yaf;
+ yaf.doYaf();
+
+ LibC lc;
+ lc.foo();
+
+ ResourceTester rt;
+
+ QTimer::singleShot(0, &rt, SLOT(doTest()));
+
+#ifdef TEST_DEBUG_CLASS
+ std::cout << DebugClass::staticMetaObject.className() << std::endl;
+#endif
+
+ return app.exec();
+}
diff --git a/Tests/QtAutogen/complex/multiplewidgets.cpp b/Tests/QtAutogen/Complex/multiplewidgets.cpp
index fda36ea92..fda36ea92 100644
--- a/Tests/QtAutogen/complex/multiplewidgets.cpp
+++ b/Tests/QtAutogen/Complex/multiplewidgets.cpp
diff --git a/Tests/QtAutogen/complex/multiplewidgets.h b/Tests/QtAutogen/Complex/multiplewidgets.h
index a4d0a5021..a4d0a5021 100644
--- a/Tests/QtAutogen/complex/multiplewidgets.h
+++ b/Tests/QtAutogen/Complex/multiplewidgets.h
diff --git a/Tests/QtAutogen/complex/myinterface.h.in b/Tests/QtAutogen/Complex/myinterface.h.in
index c6c0ba1b6..c6c0ba1b6 100644
--- a/Tests/QtAutogen/complex/myinterface.h.in
+++ b/Tests/QtAutogen/Complex/myinterface.h.in
diff --git a/Tests/QtAutogen/complex/myotherinterface.h.in b/Tests/QtAutogen/Complex/myotherinterface.h.in
index d21e7af7c..d21e7af7c 100644
--- a/Tests/QtAutogen/complex/myotherinterface.h.in
+++ b/Tests/QtAutogen/Complex/myotherinterface.h.in
diff --git a/Tests/QtAutogen/complex/private_slot.cpp b/Tests/QtAutogen/Complex/private_slot.cpp
index ab1682a25..ab1682a25 100644
--- a/Tests/QtAutogen/complex/private_slot.cpp
+++ b/Tests/QtAutogen/Complex/private_slot.cpp
diff --git a/Tests/QtAutogen/complex/private_slot.h b/Tests/QtAutogen/Complex/private_slot.h
index 8041eb2ae..8041eb2ae 100644
--- a/Tests/QtAutogen/complex/private_slot.h
+++ b/Tests/QtAutogen/Complex/private_slot.h
diff --git a/Tests/QtAutogen/complex/resourcetester.cpp b/Tests/QtAutogen/Complex/resourcetester.cpp
index 4ecb6b482..4ecb6b482 100644
--- a/Tests/QtAutogen/complex/resourcetester.cpp
+++ b/Tests/QtAutogen/Complex/resourcetester.cpp
diff --git a/Tests/QtAutogen/complex/resourcetester.h b/Tests/QtAutogen/Complex/resourcetester.h
index dbdb3ad72..dbdb3ad72 100644
--- a/Tests/QtAutogen/complex/resourcetester.h
+++ b/Tests/QtAutogen/Complex/resourcetester.h
diff --git a/Tests/QtAutogen/complex/second_resource.qrc b/Tests/QtAutogen/Complex/second_resource.qrc
index 27bfb143b..27bfb143b 100644
--- a/Tests/QtAutogen/complex/second_resource.qrc
+++ b/Tests/QtAutogen/Complex/second_resource.qrc
diff --git a/Tests/QtAutogen/Complex/second_widget.cpp b/Tests/QtAutogen/Complex/second_widget.cpp
new file mode 100644
index 000000000..9f51a80cd
--- /dev/null
+++ b/Tests/QtAutogen/Complex/second_widget.cpp
@@ -0,0 +1,16 @@
+
+#include "second_widget.h"
+
+#include "ui_second_widget.h"
+
+SecondWidget::SecondWidget(QWidget* parent)
+ : QWidget(parent)
+ , ui(new Ui::SecondWidget)
+{
+ ui->setupUi(this);
+}
+
+SecondWidget::~SecondWidget()
+{
+ delete ui;
+}
diff --git a/Tests/QtAutogen/complex/second_widget.h b/Tests/QtAutogen/Complex/second_widget.h
index c7929c4b1..c7929c4b1 100644
--- a/Tests/QtAutogen/complex/second_widget.h
+++ b/Tests/QtAutogen/Complex/second_widget.h
diff --git a/Tests/QtAutogen/complex/second_widget.ui b/Tests/QtAutogen/Complex/second_widget.ui
index 4effa589c..4effa589c 100644
--- a/Tests/QtAutogen/complex/second_widget.ui
+++ b/Tests/QtAutogen/Complex/second_widget.ui
diff --git a/Tests/QtAutogen/complex/sub/bar.h b/Tests/QtAutogen/Complex/sub/bar.h
index e4093f61c..e4093f61c 100644
--- a/Tests/QtAutogen/complex/sub/bar.h
+++ b/Tests/QtAutogen/Complex/sub/bar.h
diff --git a/Tests/QtAutogen/complex/targetObjectsTest.cpp b/Tests/QtAutogen/Complex/targetObjectsTest.cpp
index 766b7751b..766b7751b 100644
--- a/Tests/QtAutogen/complex/targetObjectsTest.cpp
+++ b/Tests/QtAutogen/Complex/targetObjectsTest.cpp
diff --git a/Tests/QtAutogen/complex/test.qrc b/Tests/QtAutogen/Complex/test.qrc
index c3d4e3cdb..c3d4e3cdb 100644
--- a/Tests/QtAutogen/complex/test.qrc
+++ b/Tests/QtAutogen/Complex/test.qrc
diff --git a/Tests/QtAutogen/complex/widget1.ui b/Tests/QtAutogen/Complex/widget1.ui
index 8fce81a9a..8fce81a9a 100644
--- a/Tests/QtAutogen/complex/widget1.ui
+++ b/Tests/QtAutogen/Complex/widget1.ui
diff --git a/Tests/QtAutogen/complex/widget2.ui b/Tests/QtAutogen/Complex/widget2.ui
index 1f411b9fb..1f411b9fb 100644
--- a/Tests/QtAutogen/complex/widget2.ui
+++ b/Tests/QtAutogen/Complex/widget2.ui
diff --git a/Tests/QtAutogen/complex/xyz.cpp b/Tests/QtAutogen/Complex/xyz.cpp
index e46c9d3ed..e46c9d3ed 100644
--- a/Tests/QtAutogen/complex/xyz.cpp
+++ b/Tests/QtAutogen/Complex/xyz.cpp
diff --git a/Tests/QtAutogen/complex/xyz.h b/Tests/QtAutogen/Complex/xyz.h
index 8b813fd3a..8b813fd3a 100644
--- a/Tests/QtAutogen/complex/xyz.h
+++ b/Tests/QtAutogen/Complex/xyz.h
diff --git a/Tests/QtAutogen/Complex/yaf.cpp b/Tests/QtAutogen/Complex/yaf.cpp
new file mode 100644
index 000000000..10448c1bc
--- /dev/null
+++ b/Tests/QtAutogen/Complex/yaf.cpp
@@ -0,0 +1,20 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "yaf.h"
+
+#include <stdio.h>
+
+#include "yaf_p.h"
+
+Yaf::Yaf()
+{
+}
+
+void Yaf::doYaf()
+{
+ YafP yafP;
+ yafP.doYafP();
+}
+
+// check that including a moc file from a private header the wrong way works:
+#include "yaf_p.moc"
diff --git a/Tests/QtAutogen/complex/yaf.h b/Tests/QtAutogen/Complex/yaf.h
index f27106199..f27106199 100644
--- a/Tests/QtAutogen/complex/yaf.h
+++ b/Tests/QtAutogen/Complex/yaf.h
diff --git a/Tests/QtAutogen/Complex/yaf_p.h b/Tests/QtAutogen/Complex/yaf_p.h
new file mode 100644
index 000000000..48fdd301c
--- /dev/null
+++ b/Tests/QtAutogen/Complex/yaf_p.h
@@ -0,0 +1,19 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef YAF_P_H
+#define YAF_P_H
+
+#include <stdio.h>
+
+#include <QObject>
+
+class YafP : public QObject
+{
+ Q_OBJECT
+public:
+ YafP() {}
+public slots:
+ void doYafP() { printf("I am yet another file !\n"); }
+};
+
+#endif
diff --git a/Tests/QtAutogen/DefinesTest/CMakeLists.txt b/Tests/QtAutogen/DefinesTest/CMakeLists.txt
new file mode 100644
index 000000000..3761dd842
--- /dev/null
+++ b/Tests/QtAutogen/DefinesTest/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.10)
+project(DefinesTest)
+
+# Qt4 only definitions test
+if(NOT QT_TEST_VERSION EQUAL 4)
+ message(ERROR "Invalid Qt test version. This test is for Qt4 only.")
+endif()
+
+find_package(Qt4 REQUIRED)
+
+add_executable(DefinesTest defines_test.cpp)
+set_target_properties(DefinesTest PROPERTIES AUTOMOC TRUE)
+target_link_libraries(DefinesTest Qt4::QtGui)
diff --git a/Tests/QtAutogen/DefinesTest/defines_test.cpp b/Tests/QtAutogen/DefinesTest/defines_test.cpp
new file mode 100644
index 000000000..a5336221d
--- /dev/null
+++ b/Tests/QtAutogen/DefinesTest/defines_test.cpp
@@ -0,0 +1,38 @@
+
+#include <QObject>
+
+#ifdef QT_GUI_LIB
+# include <QTextDocument>
+
+class SomeDocument : public QTextDocument
+{
+ Q_OBJECT
+
+Q_SIGNALS:
+ void someSig();
+};
+#endif
+
+#ifdef QT_CORE_LIB
+class SomeObject : public QObject
+{
+ Q_OBJECT
+
+Q_SIGNALS:
+ void someSig();
+};
+#endif
+
+int main(int argc, char** argv)
+{
+#ifdef QT_CORE_LIB
+ QMetaObject sosmo = SomeObject::staticMetaObject;
+#endif
+#ifdef QT_GUI_LIB
+ QMetaObject sdsmo = SomeDocument::staticMetaObject;
+#endif
+
+ return 0;
+}
+
+#include "defines_test.moc"
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt
new file mode 100644
index 000000000..81fd8db27
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt
@@ -0,0 +1,126 @@
+cmake_minimum_required(VERSION 3.12)
+project(GlobalAutogenTarget)
+include("../AutogenCoreTest.cmake")
+
+# This tests
+# CMAKE_GLOBAL_AUTOGEN_TARGET,
+# CMAKE_GLOBAL_AUTORCC_TARGET,
+# CMAKE_GLOBAL_AUTOGEN_TARGET_NAME and
+# CMAKE_GLOBAL_AUTORCC_TARGET_NAME
+# for the latter two with different values in different subdirectories.
+
+# Directories
+set(GAT_SDIR "${CMAKE_CURRENT_SOURCE_DIR}/GAT")
+set(GAT_BDIR "${CMAKE_CURRENT_BINARY_DIR}/GAT")
+# Files
+set(MCA "sda/sda_autogen/mocs_compilation.cpp")
+set(MCB "sdb/sdb_autogen/mocs_compilation.cpp")
+set(MCC "sdc/sdc_autogen/mocs_compilation.cpp")
+set(MCG "gat_autogen/mocs_compilation.cpp")
+
+set(DRA "sda/sda_autogen/*qrc_data.cpp")
+set(DRB "sdb/sdb_autogen/*qrc_data.cpp")
+set(DRC "sdc/sdc_autogen/*qrc_data.cpp")
+set(DRG "gat_autogen/*qrc_data.cpp")
+
+# -- Utility macros
+macro(GAT_FIND_FILES VAR NAME)
+ file(GLOB_RECURSE ${VAR} ${GAT_BDIR}/*${NAME})
+endmacro()
+
+macro(GAT_FIND_FILE NAME)
+ GAT_FIND_FILES(LST ${NAME})
+ if(LST)
+ message("Good find ${LST}")
+ else()
+ message(SEND_ERROR "Expected to find ${GAT_BDIR}/${NAME}")
+ endif()
+ unset(LST)
+endmacro()
+
+macro(GAT_FIND_FILE_NOT NAME)
+ GAT_FIND_FILES(LST ${NAME})
+ if(LST)
+ message(SEND_ERROR "Not expected to find ${GAT_BDIR}/${NAME}")
+ else()
+ message("Good not find ${GAT_BDIR}/${NAME}")
+ endif()
+ unset(LST)
+endmacro()
+
+macro(GAT_BUILD_TARGET NAME)
+ message("___ Building GAT ${NAME} target ___")
+ execute_process(
+ COMMAND "${CMAKE_COMMAND}" --build "${GAT_BDIR}" --target ${NAME}
+ WORKING_DIRECTORY "${GAT_BDIR}"
+ RESULT_VARIABLE result)
+ if (result)
+ message(SEND_ERROR "Building of GAT ${NAME} target failed")
+ endif()
+endmacro()
+
+
+# -- Remove and recreate build directory
+file(REMOVE_RECURSE ${GAT_BDIR})
+file(MAKE_DIRECTORY ${GAT_BDIR})
+
+
+# -- Configure project
+message("___ Configuring GAT project ___")
+execute_process(
+ COMMAND "${CMAKE_COMMAND}" "${GAT_SDIR}"
+ -G "${CMAKE_GENERATOR}"
+ -A "${CMAKE_GENERATOR_PLATFORM}"
+ -T "${CMAKE_GENERATOR_TOOLSET}"
+ "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+ "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
+ "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+ WORKING_DIRECTORY "${GAT_BDIR}"
+ OUTPUT_VARIABLE output
+ RESULT_VARIABLE result)
+if (result)
+ message(SEND_ERROR "Configuring of GAT project failed")
+else()
+ message("Configuring of GAT project succeeded")
+ message("${output}")
+endif()
+
+
+# -- Build autogen subtargets
+GAT_BUILD_TARGET("autogen")
+GAT_FIND_FILE("${MCA}")
+GAT_FIND_FILE_NOT("${MCB}")
+GAT_FIND_FILE_NOT("${MCC}")
+GAT_FIND_FILE("${MCG}")
+
+GAT_BUILD_TARGET("global_autogen_sdb")
+GAT_FIND_FILE("${MCA}")
+GAT_FIND_FILE("${MCB}")
+GAT_FIND_FILE_NOT("${MCC}")
+GAT_FIND_FILE("${MCG}")
+
+GAT_BUILD_TARGET("all_autogen")
+GAT_FIND_FILE("${MCA}")
+GAT_FIND_FILE("${MCB}")
+GAT_FIND_FILE("${MCC}")
+GAT_FIND_FILE("${MCG}")
+
+
+# -- Build autorcc subtargets
+GAT_BUILD_TARGET("autorcc")
+GAT_FIND_FILE("${DRA}")
+GAT_FIND_FILE_NOT("${DRB}")
+GAT_FIND_FILE_NOT("${DRC}")
+GAT_FIND_FILE("${DRG}")
+
+GAT_BUILD_TARGET("global_autorcc_sdb")
+GAT_FIND_FILE("${DRA}")
+GAT_FIND_FILE("${DRB}")
+GAT_FIND_FILE_NOT("${DRC}")
+GAT_FIND_FILE("${DRG}")
+
+GAT_BUILD_TARGET("all_autorcc")
+GAT_FIND_FILE("${DRA}")
+GAT_FIND_FILE("${DRB}")
+GAT_FIND_FILE("${DRC}")
+GAT_FIND_FILE("${DRG}")
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/GAT/CMakeLists.txt
new file mode 100644
index 000000000..3925197fe
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/CMakeLists.txt
@@ -0,0 +1,28 @@
+cmake_minimum_required(VERSION 3.12)
+project(GAT)
+include("../../AutogenCoreTest.cmake")
+
+# Include directories
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+# Enable AUTOMOC/UIC/RCC
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTORCC ON)
+# Disable ORIGN_DEPENDS and enable AUTOGEN global targets
+set(CMAKE_AUTOGEN_ORIGIN_DEPENDS OFF)
+set(CMAKE_GLOBAL_AUTOGEN_TARGET ON)
+set(CMAKE_GLOBAL_AUTORCC_TARGET ON)
+
+add_subdirectory(sda)
+add_subdirectory(sdb)
+add_subdirectory(sdc)
+
+# Add custom target that depends on all autogen/autorcc targets
+add_custom_target(all_autogen DEPENDS autogen global_autogen_sdb global_autogen_sdc)
+add_custom_target(all_autorcc DEPENDS autorcc global_autorcc_sdb global_autorcc_sdc)
+
+# Main target
+add_executable(gat data.qrc item.cpp main.cpp)
+target_link_libraries(gat ${QT_LIBRARIES})
+target_link_libraries(gat sda sdb sdc)
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/data.qrc b/Tests/QtAutogen/GlobalAutogenTarget/GAT/data.qrc
new file mode 100644
index 000000000..68d02c9eb
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/data.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/item.cpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/item.cpp
new file mode 100644
index 000000000..3d1fbe7cf
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/item.cpp
@@ -0,0 +1,20 @@
+#include "item.hpp"
+// Include ui_view.h in source and header
+#include <ui_view.h>
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ Ui_View ui;
+ MocLocal obj;
+}
+
+#include "item.moc"
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/item.hpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/item.hpp
new file mode 100644
index 000000000..75e83f483
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/item.hpp
@@ -0,0 +1,15 @@
+#ifndef ITEM_HPP
+#define ITEM_HPP
+
+#include <QObject>
+// Include ui_view.h in source and header
+#include <ui_view.h>
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go();
+};
+
+#endif
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/main.cpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/main.cpp
new file mode 100644
index 000000000..79c00b407
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/main.cpp
@@ -0,0 +1,15 @@
+#include "item.hpp"
+#include "sda/sda.hpp"
+#include "sdb/sdb.hpp"
+#include "sdc/sdc.hpp"
+
+int main(int argv, char** args)
+{
+ // Object instances
+ Item item;
+ // Library calls
+ sda();
+ sdb();
+ sdc();
+ return 0;
+}
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/CMakeLists.txt
new file mode 100644
index 000000000..795e91e97
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_library(sda ../item.cpp ../data.qrc sda.cpp)
+target_link_libraries(sda ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.cpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.cpp
new file mode 100644
index 000000000..ec4dec88a
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.cpp
@@ -0,0 +1,6 @@
+#include <item.hpp>
+
+void sda()
+{
+ Item item;
+}
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.hpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.hpp
new file mode 100644
index 000000000..89ac744b3
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sda/sda.hpp
@@ -0,0 +1,6 @@
+#ifndef SDA_HPP
+#define SDA_HPP
+
+void sda();
+
+#endif
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/CMakeLists.txt
new file mode 100644
index 000000000..5c686fec4
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/CMakeLists.txt
@@ -0,0 +1,5 @@
+set(CMAKE_GLOBAL_AUTOGEN_TARGET_NAME "global_autogen_sdb")
+set(CMAKE_GLOBAL_AUTORCC_TARGET_NAME "global_autorcc_sdb")
+
+add_library(sdb ../item.cpp ../data.qrc sdb.cpp)
+target_link_libraries(sdb ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.cpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.cpp
new file mode 100644
index 000000000..e32c46709
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.cpp
@@ -0,0 +1,6 @@
+#include <item.hpp>
+
+void sdb()
+{
+ Item item;
+}
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.hpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.hpp
new file mode 100644
index 000000000..a5b0f62f9
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdb/sdb.hpp
@@ -0,0 +1,6 @@
+#ifndef SDB_HPP
+#define SDB_HPP
+
+void sdb();
+
+#endif
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/CMakeLists.txt
new file mode 100644
index 000000000..2698bda6b
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/CMakeLists.txt
@@ -0,0 +1,5 @@
+set(CMAKE_GLOBAL_AUTOGEN_TARGET_NAME "global_autogen_sdc")
+set(CMAKE_GLOBAL_AUTORCC_TARGET_NAME "global_autorcc_sdc")
+
+add_library(sdc ../item.cpp ../data.qrc sdc.cpp)
+target_link_libraries(sdc ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.cpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.cpp
new file mode 100644
index 000000000..a97cd4276
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.cpp
@@ -0,0 +1,6 @@
+#include <item.hpp>
+
+void sdc()
+{
+ Item item;
+}
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.hpp b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.hpp
new file mode 100644
index 000000000..7e9217902
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/sdc/sdc.hpp
@@ -0,0 +1,6 @@
+#ifndef SDC_HPP
+#define SDC_HPP
+
+void sdc();
+
+#endif
diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/view.ui b/Tests/QtAutogen/GlobalAutogenTarget/GAT/view.ui
new file mode 100644
index 000000000..2ffe7344c
--- /dev/null
+++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/view.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>View</class>
+ <widget class="QWidget" name="Base">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/LowMinimumVersion/CMakeLists.txt b/Tests/QtAutogen/LowMinimumVersion/CMakeLists.txt
new file mode 100644
index 000000000..e1af3d863
--- /dev/null
+++ b/Tests/QtAutogen/LowMinimumVersion/CMakeLists.txt
@@ -0,0 +1,16 @@
+# Use a low minimum version
+cmake_minimum_required(VERSION 3.0)
+project(LowMinimumVersion)
+include("../AutogenGuiTest.cmake")
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTORCC ON)
+add_executable(lowMinimumVersion
+ main.cpp
+ item.hpp
+ item.cpp
+ view.ui
+ someText.txt
+ example.qrc)
+target_link_libraries(lowMinimumVersion ${QT_QTCORE_TARGET})
diff --git a/Tests/QtAutogen/LowMinimumVersion/example.qrc b/Tests/QtAutogen/LowMinimumVersion/example.qrc
new file mode 100644
index 000000000..551ecc815
--- /dev/null
+++ b/Tests/QtAutogen/LowMinimumVersion/example.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="Example">
+ <file>someText.txt</file>
+ </qresource>
+</RCC>
diff --git a/Tests/QtAutogen/LowMinimumVersion/item.cpp b/Tests/QtAutogen/LowMinimumVersion/item.cpp
new file mode 100644
index 000000000..511a1caa8
--- /dev/null
+++ b/Tests/QtAutogen/LowMinimumVersion/item.cpp
@@ -0,0 +1,20 @@
+#include "item.hpp"
+
+#include <ui_view.h>
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ Ui_View ui;
+ MocLocal obj;
+}
+
+#include "item.moc"
diff --git a/Tests/QtAutogen/LowMinimumVersion/item.hpp b/Tests/QtAutogen/LowMinimumVersion/item.hpp
new file mode 100644
index 000000000..01255d480
--- /dev/null
+++ b/Tests/QtAutogen/LowMinimumVersion/item.hpp
@@ -0,0 +1,15 @@
+#ifndef ITEM_HPP
+#define ITEM_HPP
+
+#include <QObject>
+
+class Item : public QObject
+{
+ Q_OBJECT
+
+public:
+ Q_SLOT
+ void go();
+};
+
+#endif
diff --git a/Tests/QtAutogen/LowMinimumVersion/main.cpp b/Tests/QtAutogen/LowMinimumVersion/main.cpp
new file mode 100644
index 000000000..9f225a4aa
--- /dev/null
+++ b/Tests/QtAutogen/LowMinimumVersion/main.cpp
@@ -0,0 +1,10 @@
+#include "item.hpp"
+
+int main(int argc, char* argv[])
+{
+ Q_INIT_RESOURCE(example);
+ Item item;
+ item.go();
+
+ return 0;
+}
diff --git a/Tests/QtAutogen/LowMinimumVersion/someText.txt b/Tests/QtAutogen/LowMinimumVersion/someText.txt
new file mode 100644
index 000000000..750dae3a1
--- /dev/null
+++ b/Tests/QtAutogen/LowMinimumVersion/someText.txt
@@ -0,0 +1 @@
+Hello world, you're an interesting place.
diff --git a/Tests/QtAutogen/LowMinimumVersion/view.ui b/Tests/QtAutogen/LowMinimumVersion/view.ui
new file mode 100644
index 000000000..2ffe7344c
--- /dev/null
+++ b/Tests/QtAutogen/LowMinimumVersion/view.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>View</class>
+ <widget class="QWidget" name="Base">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/MacOsFW/CMakeLists.txt b/Tests/QtAutogen/MacOsFW/CMakeLists.txt
new file mode 100644
index 000000000..c08efc47a
--- /dev/null
+++ b/Tests/QtAutogen/MacOsFW/CMakeLists.txt
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 3.10)
+project(MacOsFW)
+include("../AutogenGuiTest.cmake")
+
+find_package(Qt5Test REQUIRED)
+
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/bin)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib)
+set(CMAKE_INSTALL_NAME_DIR ${CMAKE_BINARY_DIR}/output/lib)
+
+if(POLICY CMP0042) # in CMake 3.0.0+
+ set (CMAKE_MACOSX_RPATH OFF) # otherwise ON by default
+endif(POLICY CMP0042)
+
+if(POLICY CMP0068) # in CMake 3.9+
+ cmake_policy(SET CMP0068 NEW)
+endif(POLICY CMP0068)
+
+add_subdirectory(src)
+add_subdirectory(test)
diff --git a/Tests/QtAutogen/MacOsFW/src/CMakeLists.txt b/Tests/QtAutogen/MacOsFW/src/CMakeLists.txt
new file mode 100644
index 000000000..a02be00c5
--- /dev/null
+++ b/Tests/QtAutogen/MacOsFW/src/CMakeLists.txt
@@ -0,0 +1,33 @@
+set(MACOS_FW_LIB_VERSION "0.1")
+set(MACOS_FW_LIB_SRCS
+ macos_fw_lib.cpp
+)
+set(MACOS_FW_LIB_HDRS
+ macos_fw_lib.h
+)
+
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${Qt5Core_INCLUDE_DIRS}
+)
+
+add_library(macos_fw_lib SHARED
+ ${MACOS_FW_LIB_SRCS}
+ ${MACOS_FW_LIB_HDRS}
+)
+set_target_properties(macos_fw_lib PROPERTIES AUTOMOC TRUE)
+set_target_properties(macos_fw_lib PROPERTIES
+ CLEAN_DIRECT_OUTPUT 1
+ FRAMEWORK 1
+ FRAMEWORK_VERSION ${MACOS_FW_LIB_VERSION}
+ VERSION ${MACOS_FW_LIB_VERSION}
+ SOVERSION ${MACOS_FW_LIB_VERSION}
+ MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${MACOS_FW_LIB_VERSION}
+ MACOSX_FRAMEWORK_IDENTIFIER org.macos.fw_lib
+ POSITION_INDEPENDENT_CODE ON
+ PUBLIC_HEADER "${MACOS_FW_LIB_HDRS}"
+)
+target_link_libraries(macos_fw_lib
+ Qt5::Core
+)
diff --git a/Tests/QtAutogen/MacOsFW/src/macos_fw_lib.cpp b/Tests/QtAutogen/MacOsFW/src/macos_fw_lib.cpp
new file mode 100644
index 000000000..881a8c9b6
--- /dev/null
+++ b/Tests/QtAutogen/MacOsFW/src/macos_fw_lib.cpp
@@ -0,0 +1,17 @@
+#include "macos_fw_lib.h"
+
+#include <QString>
+#include <QtGlobal>
+
+MacosFWLib::MacosFWLib()
+{
+}
+
+MacosFWLib::~MacosFWLib()
+{
+}
+
+QString MacosFWLib::qtVersionString() const
+{
+ return QString(qVersion());
+}
diff --git a/Tests/QtAutogen/MacOsFW/src/macos_fw_lib.h b/Tests/QtAutogen/MacOsFW/src/macos_fw_lib.h
new file mode 100644
index 000000000..e66e0ea6c
--- /dev/null
+++ b/Tests/QtAutogen/MacOsFW/src/macos_fw_lib.h
@@ -0,0 +1,18 @@
+#ifndef MACOSFWLIB_H
+#define MACOSFWLIB_H
+
+#include <QObject>
+#include <QString>
+
+class __attribute__((visibility("default"))) MacosFWLib : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit MacosFWLib();
+ ~MacosFWLib();
+
+ QString qtVersionString() const;
+};
+
+#endif // MACOSFWLIB_H
diff --git a/Tests/QtAutogen/MacOsFW/test/CMakeLists.txt b/Tests/QtAutogen/MacOsFW/test/CMakeLists.txt
new file mode 100644
index 000000000..521c18450
--- /dev/null
+++ b/Tests/QtAutogen/MacOsFW/test/CMakeLists.txt
@@ -0,0 +1,19 @@
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../src
+)
+include_directories(SYSTEM
+ ${Qt5Core_INCLUDE_DIRS}
+ ${Qt5Widgets_INCLUDE_DIRS}
+)
+
+set(testname AutomocMacosFWLib)
+add_executable(${testname} testMacosFWLib.cpp)
+set_target_properties(${testname} PROPERTIES AUTOMOC TRUE)
+target_link_libraries(${testname}
+ Qt5::Core
+ Qt5::Widgets
+ Qt5::Test
+ macos_fw_lib
+)
diff --git a/Tests/QtAutogen/MacOsFW/test/testMacosFWLib.cpp b/Tests/QtAutogen/MacOsFW/test/testMacosFWLib.cpp
new file mode 100644
index 000000000..edc93764a
--- /dev/null
+++ b/Tests/QtAutogen/MacOsFW/test/testMacosFWLib.cpp
@@ -0,0 +1,43 @@
+#include "testMacosFWLib.h"
+
+#include <QObject>
+#include <QString>
+
+#include "macos_fw_lib.h"
+
+class TestMacosFWLib : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init() {}
+ void cleanup() {}
+
+ void testQtVersion();
+};
+
+void TestMacosFWLib::initTestCase()
+{
+}
+
+void TestMacosFWLib::cleanupTestCase()
+{
+}
+
+void TestMacosFWLib::testQtVersion()
+{
+ MacosFWLib* testLib = new MacosFWLib();
+ QVERIFY(testLib->qtVersionString().contains("5."));
+ testLib->deleteLater();
+}
+
+int main(int argc, char* argv[])
+{
+ QApplication app(argc, argv, false);
+ MacosFWLib testObject;
+ return QTest::qExec(&testObject, argc, argv);
+}
+
+#include "testMacosFWLib.moc"
diff --git a/Tests/QtAutogen/MacOsFW/test/testMacosFWLib.h b/Tests/QtAutogen/MacOsFW/test/testMacosFWLib.h
new file mode 100644
index 000000000..1fe8dae65
--- /dev/null
+++ b/Tests/QtAutogen/MacOsFW/test/testMacosFWLib.h
@@ -0,0 +1,7 @@
+#ifndef TESTMACOSFWLIB_H
+#define TESTMACOSFWLIB_H
+
+#include "qapplication.h"
+#include <QtTest/QtTest>
+
+#endif // TESTMACOSFWLIB_H
diff --git a/Tests/QtAutogen/ManySources/CMakeLists.txt b/Tests/QtAutogen/ManySources/CMakeLists.txt
new file mode 100644
index 000000000..df8a2a662
--- /dev/null
+++ b/Tests/QtAutogen/ManySources/CMakeLists.txt
@@ -0,0 +1,35 @@
+cmake_minimum_required(VERSION 3.10)
+project(ManySources)
+include("../AutogenGuiTest.cmake")
+
+# Test AUTOMOC and AUTOUIC on many source files to stress the concurrent
+# parsing and processing framework.
+
+set(CSD ${CMAKE_CURRENT_SOURCE_DIR})
+set(CBD ${CMAKE_CURRENT_BINARY_DIR})
+
+set(SRCS main.cpp)
+set(MAIN_INCLUDES "\n// Item includes\n")
+set(MAIN_ITEMS "\n// Items\n")
+
+set(NUM 24)
+foreach(III RANGE 1 ${NUM})
+ configure_file(${CSD}/object.h.in ${CBD}/object_${III}.h)
+ configure_file(${CSD}/item.h.in ${CBD}/item_${III}.h)
+ configure_file(${CSD}/item.cpp.in ${CBD}/item_${III}.cpp)
+ configure_file(${CSD}/view.ui.in ${CBD}/view_${III}.ui)
+ configure_file(${CSD}/data.qrc.in ${CBD}/data_${III}.qrc)
+
+ list(APPEND SRCS ${CBD}/item_${III}.cpp)
+ list(APPEND SRCS ${CBD}/data_${III}.qrc)
+
+ string(APPEND MAIN_INCLUDES "#include \"item_${III}.h\"\n")
+ string(APPEND MAIN_ITEMS "Item_${III} item_${III};\n")
+ string(APPEND MAIN_ITEMS "item_${III}.TheSlot();\n")
+endforeach()
+
+configure_file(${CSD}/main.cpp.in ${CBD}/main.cpp)
+
+add_executable(manySources ${SRCS} ${CBD}/main.cpp)
+target_link_libraries(manySources ${QT_LIBRARIES})
+set_target_properties(manySources PROPERTIES AUTOMOC 1 AUTOUIC 1 AUTORCC 1)
diff --git a/Tests/QtAutogen/ManySources/data.qrc.in b/Tests/QtAutogen/ManySources/data.qrc.in
new file mode 100644
index 000000000..870d48631
--- /dev/null
+++ b/Tests/QtAutogen/ManySources/data.qrc.in
@@ -0,0 +1,7 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>object_@III@.h</file>
+ <file>item_@III@.h</file>
+ <file>item_@III@.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/ManySources/item.cpp.in b/Tests/QtAutogen/ManySources/item.cpp.in
new file mode 100644
index 000000000..c34ad16d0
--- /dev/null
+++ b/Tests/QtAutogen/ManySources/item.cpp.in
@@ -0,0 +1,27 @@
+#include "item_@III@.h"
+#include "object_@III@.h"
+// AUTOUIC include
+#include <ui_view_@III@.h>
+
+class LocalObject_@III@ : public QObject
+{
+ Q_OBJECT;
+
+public:
+ LocalObject_@III@() = default;
+ ~LocalObject_@III@() = default;
+};
+
+void Item_@III@ ::TheSlot()
+{
+ LocalObject_@III@ localObject;
+ Object_@III@ obj;
+ obj.ObjectSlot();
+
+ Ui_View_@III@ ui_view;
+}
+
+// AUTOMOC includes
+#include "item_@III@.moc"
+#include "moc_item_@III@.cpp"
+#include "moc_object_@III@.cpp"
diff --git a/Tests/QtAutogen/ManySources/item.h.in b/Tests/QtAutogen/ManySources/item.h.in
new file mode 100644
index 000000000..67ad79435
--- /dev/null
+++ b/Tests/QtAutogen/ManySources/item.h.in
@@ -0,0 +1,15 @@
+#ifndef ITEM_@III@HPP
+#define ITEM_@III@HPP
+
+#include <QObject>
+
+class Item_@III@ : public QObject
+{
+ Q_OBJECT
+
+public:
+ Q_SLOT
+ void TheSlot();
+};
+
+#endif
diff --git a/Tests/QtAutogen/ManySources/main.cpp.in b/Tests/QtAutogen/ManySources/main.cpp.in
new file mode 100644
index 000000000..e1dda40b7
--- /dev/null
+++ b/Tests/QtAutogen/ManySources/main.cpp.in
@@ -0,0 +1,7 @@
+@MAIN_INCLUDES@
+
+int main(int argv, char** args)
+{
+ @MAIN_ITEMS@
+ return 0;
+}
diff --git a/Tests/QtAutogen/ManySources/object.h.in b/Tests/QtAutogen/ManySources/object.h.in
new file mode 100644
index 000000000..a747cbcfa
--- /dev/null
+++ b/Tests/QtAutogen/ManySources/object.h.in
@@ -0,0 +1,15 @@
+#ifndef OBJECT_@III@H
+#define OBJECT_@III@H
+
+#include <QObject>
+
+class Object_@III@ : public QObject
+{
+ Q_OBJECT
+
+public:
+ Q_SLOT
+ void ObjectSlot(){};
+};
+
+#endif
diff --git a/Tests/QtAutogen/ManySources/view.ui.in b/Tests/QtAutogen/ManySources/view.ui.in
new file mode 100644
index 000000000..6901fe3de
--- /dev/null
+++ b/Tests/QtAutogen/ManySources/view.ui.in
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>View_@III@</class>
+ <widget class="QWidget" name="Base">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/MocCMP0071/CMakeLists.txt b/Tests/QtAutogen/MocCMP0071/CMakeLists.txt
new file mode 100644
index 000000000..5c58a8278
--- /dev/null
+++ b/Tests/QtAutogen/MocCMP0071/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.10)
+project(MocCMP0071)
+include("../AutogenCoreTest.cmake")
+
+add_subdirectory(OLD)
+add_subdirectory(NEW)
diff --git a/Tests/QtAutogen/MocCMP0071/NEW/CMakeLists.txt b/Tests/QtAutogen/MocCMP0071/NEW/CMakeLists.txt
new file mode 100644
index 000000000..954fe3dc1
--- /dev/null
+++ b/Tests/QtAutogen/MocCMP0071/NEW/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.10)
+cmake_policy(SET CMP0071 NEW)
+
+# *Generate* files
+set(CSD ${CMAKE_CURRENT_SOURCE_DIR})
+set(CBD ${CMAKE_CURRENT_BINARY_DIR})
+add_custom_command(
+ OUTPUT ${CBD}/Obj_p.h ${CBD}/Obj.hpp ${CBD}/Obj.cpp ${CBD}/main.cpp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj_p.h ${CBD}/Obj_p.h
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj.hpp ${CBD}/Obj.hpp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj.cpp ${CBD}/Obj.cpp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../main.cpp ${CBD}/main.cpp)
+
+add_executable(mocCMP0071New ${CBD}/Obj.cpp ${CBD}/main.cpp)
+target_link_libraries(mocCMP0071New ${QT_LIBRARIES})
+set_target_properties(mocCMP0071New PROPERTIES AUTOMOC ON)
diff --git a/Tests/QtAutogen/MocCMP0071/OLD/CMakeLists.txt b/Tests/QtAutogen/MocCMP0071/OLD/CMakeLists.txt
new file mode 100644
index 000000000..68fa06708
--- /dev/null
+++ b/Tests/QtAutogen/MocCMP0071/OLD/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.10)
+cmake_policy(SET CMP0071 OLD)
+
+# *Generate* files
+set(CSD ${CMAKE_CURRENT_SOURCE_DIR})
+set(CBD ${CMAKE_CURRENT_BINARY_DIR})
+add_custom_command(
+ OUTPUT ${CBD}/Obj_p.h ${CBD}/Obj.hpp ${CBD}/Obj.cpp ${CBD}/main.cpp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj_p.h ${CBD}/Obj_p.h
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj.hpp ${CBD}/Obj.hpp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../Obj.cpp ${CBD}/Obj.cpp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/../main.cpp ${CBD}/main.cpp)
+
+# Generate moc files externally
+qtx_wrap_cpp(mocCMP0071OldMoc ${CBD}/Obj.hpp ${CBD}/Obj_p.h)
+add_executable(mocCMP0071Old ${CBD}/Obj.cpp ${CBD}/main.cpp ${mocCMP0071OldMoc})
+target_link_libraries(mocCMP0071Old ${QT_LIBRARIES})
+set_target_properties(mocCMP0071Old PROPERTIES AUTOMOC ON)
diff --git a/Tests/QtAutogen/MocCMP0071/Obj.cpp b/Tests/QtAutogen/MocCMP0071/Obj.cpp
new file mode 100644
index 000000000..25a291d31
--- /dev/null
+++ b/Tests/QtAutogen/MocCMP0071/Obj.cpp
@@ -0,0 +1,21 @@
+#include "Obj.hpp"
+
+#include "Obj_p.h"
+
+ObjPrivate::ObjPrivate()
+{
+}
+
+ObjPrivate::~ObjPrivate()
+{
+}
+
+Obj::Obj()
+ : d(new ObjPrivate)
+{
+}
+
+Obj::~Obj()
+{
+ delete d;
+}
diff --git a/Tests/QtAutogen/MocCMP0071/Obj.hpp b/Tests/QtAutogen/MocCMP0071/Obj.hpp
new file mode 100644
index 000000000..f064e4793
--- /dev/null
+++ b/Tests/QtAutogen/MocCMP0071/Obj.hpp
@@ -0,0 +1,19 @@
+#ifndef OBJ_HPP
+#define OBJ_HPP
+
+#include <QObject>
+
+// Object source comes without any _moc/.moc includes
+class ObjPrivate;
+class Obj : public QObject
+{
+ Q_OBJECT
+public:
+ Obj();
+ ~Obj();
+
+private:
+ ObjPrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocCMP0071/Obj_p.h b/Tests/QtAutogen/MocCMP0071/Obj_p.h
new file mode 100644
index 000000000..cb1e5df71
--- /dev/null
+++ b/Tests/QtAutogen/MocCMP0071/Obj_p.h
@@ -0,0 +1,14 @@
+#ifndef OBJ_P_HPP
+#define OBJ_P_HPP
+
+#include <QObject>
+
+class ObjPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ ObjPrivate();
+ ~ObjPrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocCMP0071/main.cpp b/Tests/QtAutogen/MocCMP0071/main.cpp
new file mode 100644
index 000000000..3887840ba
--- /dev/null
+++ b/Tests/QtAutogen/MocCMP0071/main.cpp
@@ -0,0 +1,7 @@
+#include "Obj.hpp"
+
+int main(int argv, char** args)
+{
+ Obj obj;
+ return 0;
+}
diff --git a/Tests/QtAutogen/MocInclude/CMakeLists.txt b/Tests/QtAutogen/MocInclude/CMakeLists.txt
new file mode 100644
index 000000000..04c8bafb7
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/CMakeLists.txt
@@ -0,0 +1,112 @@
+cmake_minimum_required(VERSION 3.15)
+project(MocInclude)
+get_filename_component(CS_REAL ${CMAKE_CURRENT_SOURCE_DIR} REALPATH)
+include("${CS_REAL}/../AutogenCoreTest.cmake")
+
+# Test moc include patterns
+
+set(COM_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Common")
+
+macro(addCopyCommand from to)
+ add_custom_command(
+ OUTPUT ${to}
+ COMMAND ${CMAKE_COMMAND} -E copy ${from} ${to}
+ DEPENDS ${from})
+endmacro()
+
+# Create an executable
+function(makeExecutable TARGET_NAME)
+ # Utility variables
+ set(CB_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+
+ # Copy directory
+ file(REMOVE_RECURSE "${CB_DIR}/InIncludes")
+ file(COPY "${COM_DIR}/InIncludes.in" DESTINATION "${CB_DIR}")
+ file(RENAME "${CB_DIR}/InIncludes.in" "${CB_DIR}/InIncludes")
+
+ # Generate .moc file from the header externally and
+ # enabled SKIP_AUTOMOC on the source file
+ qtx_wrap_cpp(ExternDotMOC ${COM_DIR}/ExternDot.hpp OPTIONS "-p" "./")
+ addCopyCommand(${ExternDotMOC}
+ ${CB_DIR}/ExternDot.moc)
+ set_property(
+ SOURCE ${COM_DIR}/ExternDot.cpp
+ PROPERTY SKIP_AUTOMOC ON)
+
+ # Generate .moc file from the GENERATED header externally
+ # and enabled SKIP_AUTOMOC on the source file
+ addCopyCommand(${COM_DIR}/ExternDotGenerated.hpp.in
+ ${CB_DIR}/ExternDotGenerated.hpp)
+ addCopyCommand(${COM_DIR}/ExternDotGenerated.cpp.in
+ ${CB_DIR}/ExternDotGenerated.cpp)
+ qtx_wrap_cpp(ExternDotGeneratedMOC
+ ${CB_DIR}/ExternDotGenerated.hpp
+ OPTIONS "-p" "./")
+ addCopyCommand(${ExternDotGeneratedMOC}
+ ${CB_DIR}/ExternDotGenerated.moc)
+ set_property(
+ SOURCE ${CB_DIR}/ExternDotGenerated.cpp
+ PROPERTY SKIP_AUTOMOC ON)
+
+ # Generate header moc file externally with a custom name
+ # and enabled SKIP_AUTOMOC on the header
+ qtx_wrap_cpp(MixedCustomMOC
+ ${COM_DIR}/MixedCustom.hpp
+ OPTIONS "-p" "./")
+ addCopyCommand(${MixedCustomMOC}
+ ${CB_DIR}/MixedCustom_extMoc.cpp)
+ set_property(
+ SOURCE ${COM_DIR}/MixedCustom.hpp
+ PROPERTY SKIP_AUTOMOC ON)
+ # Custom target to depend on
+ add_custom_target("${TARGET_NAME}_MixedCustom"
+ DEPENDS ${CB_DIR}/MixedCustom_extMoc.cpp
+ BYPRODUCTS ${CB_DIR}/moc_MixedCustom.cpp
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${COM_DIR}/moc_MixedCustom.cpp.in
+ ${CB_DIR}/moc_MixedCustom.cpp)
+
+ add_executable(${TARGET_NAME}
+ # Test own "*.moc" and "moc_*.cpp" includes
+ ${COM_DIR}/None.cpp
+ ${COM_DIR}/OwnDot.cpp
+ ${COM_DIR}/OwnUnderscore.cpp
+ ${COM_DIR}/OwnDotUnderscore.cpp
+
+ # Test "moc_*.cpp" includes of other files
+ ${COM_DIR}/OtherUnderscore.cpp
+ ${COM_DIR}/OtherUnderscoreExtra.cpp
+ ${COM_DIR}/OtherUnderscoreSub.cpp
+ ${COM_DIR}/OtherUnderscoreSubDir/SubExtra.cpp
+
+ # Test relative ../../ path for moc includes
+ ${COM_DIR}/DualSub/Second/Second.cpp
+ ${COM_DIR}/DualSubMocked.cpp
+
+ # Test externally generated moc files
+ ${COM_DIR}/ExternDot.cpp
+ ${CB_DIR}/ExternDot.moc
+
+ # Test externally generated moc files for GENERATED source
+ ${CB_DIR}/ExternDotGenerated.cpp
+ ${CB_DIR}/ExternDotGenerated.moc
+
+ # Test externally generated moc files and SKIP_AUTOMOC enabled header
+ ${COM_DIR}/MixedSkipped.cpp
+ ${COM_DIR}/MixedCustom.hpp
+ ${COM_DIR}/MixedCustom.cpp
+
+ # Test sources in a subdirectory
+ ${CB_DIR}/InIncludes/SubOwnDot.cpp
+ ${COM_DIR}/InIncludesMoc.cpp
+ )
+ add_dependencies(${TARGET_NAME} "${TARGET_NAME}_MixedCustom")
+ target_include_directories(${TARGET_NAME} PRIVATE "${COM_DIR}")
+ target_include_directories(${TARGET_NAME} PRIVATE "${CB_DIR}")
+ target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
+ target_link_libraries(${TARGET_NAME} ${QT_LIBRARIES})
+ set_target_properties(${TARGET_NAME} PROPERTIES AUTOMOC ON)
+endfunction()
+
+add_subdirectory(Strict)
+add_subdirectory(Relaxed)
diff --git a/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp
new file mode 100644
index 000000000..453add117
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp
@@ -0,0 +1,11 @@
+#include "Second.hpp"
+
+Second::Second()
+{
+}
+
+Second::~Second()
+{
+}
+
+#include "../../moc_DualSubMocked.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp
new file mode 100644
index 000000000..e1f3eac16
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp
@@ -0,0 +1,14 @@
+#ifndef Second_HPP
+#define Second_HPP
+
+#include <QObject>
+
+class Second : public QObject
+{
+ Q_OBJECT
+public:
+ Second();
+ ~Second();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp
new file mode 100644
index 000000000..1d4658dcb
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp
@@ -0,0 +1,9 @@
+#include "DualSubMocked.hpp"
+
+DualSubMocked::DualSubMocked()
+{
+}
+
+DualSubMocked::~DualSubMocked()
+{
+}
diff --git a/Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp
new file mode 100644
index 000000000..58cb571dd
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp
@@ -0,0 +1,15 @@
+#ifndef DualSubMocked_HPP
+#define DualSubMocked_HPP
+
+#include <QObject>
+
+// Header moc file is included by DualSub/Second/Second.cpp
+class DualSubMocked : public QObject
+{
+ Q_OBJECT
+public:
+ DualSubMocked();
+ ~DualSubMocked();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDot.cpp b/Tests/QtAutogen/MocInclude/Common/ExternDot.cpp
new file mode 100644
index 000000000..2495aa794
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/ExternDot.cpp
@@ -0,0 +1,11 @@
+#include "ExternDot.hpp"
+
+ExternDot::ExternDot()
+{
+}
+
+ExternDot::~ExternDot()
+{
+}
+
+#include "ExternDot.moc"
diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDot.hpp b/Tests/QtAutogen/MocInclude/Common/ExternDot.hpp
new file mode 100644
index 000000000..7eaab2afb
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/ExternDot.hpp
@@ -0,0 +1,15 @@
+#ifndef ExternDot_HPP
+#define ExternDot_HPP
+
+#include <QObject>
+
+// Object source includes externally generated .moc file
+class ExternDot : public QObject
+{
+ Q_OBJECT
+public:
+ ExternDot();
+ ~ExternDot();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in
new file mode 100644
index 000000000..09ce5cdba
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in
@@ -0,0 +1,11 @@
+#include "ExternDotGenerated.hpp"
+
+ExternDotGenerated::ExternDotGenerated()
+{
+}
+
+ExternDotGenerated::~ExternDotGenerated()
+{
+}
+
+#include "ExternDotGenerated.moc"
diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in
new file mode 100644
index 000000000..21c69be06
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in
@@ -0,0 +1,15 @@
+#ifndef ExternDotGenerated_HPP
+#define ExternDotGenerated_HPP
+
+#include <QObject>
+
+// GENERATED Object source includes externally generated .moc file
+class ExternDotGenerated : public QObject
+{
+ Q_OBJECT
+public:
+ ExternDotGenerated();
+ ~ExternDotGenerated();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp
new file mode 100644
index 000000000..275754dbb
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp
@@ -0,0 +1,44 @@
+#include "SubOwnDot.hpp"
+
+#include "SubOwnDot_p.hpp"
+
+namespace InIncludes {
+
+class SubOwnDotLocal : public QObject
+{
+ Q_OBJECT
+public:
+ SubOwnDotLocal();
+ ~SubOwnDotLocal();
+};
+
+SubOwnDotLocal::SubOwnDotLocal()
+{
+}
+
+SubOwnDotLocal::~SubOwnDotLocal()
+{
+}
+
+SubOwnDotPrivate::SubOwnDotPrivate()
+{
+}
+
+SubOwnDotPrivate::~SubOwnDotPrivate()
+{
+}
+
+SubOwnDot::SubOwnDot()
+{
+ SubOwnDotPrivate privateObj;
+ SubOwnDotLocal localObj;
+}
+
+SubOwnDot::~SubOwnDot()
+{
+}
+
+} // End of namespace
+
+// For the local QObject
+#include "SubOwnDot.moc"
diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp
new file mode 100644
index 000000000..038ddfaa4
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp
@@ -0,0 +1,17 @@
+#ifndef InIncludes_SubOwnDot_HPP
+#define InIncludes_SubOwnDot_HPP
+
+#include <QObject>
+
+namespace InIncludes {
+
+class SubOwnDot : public QObject
+{
+ Q_OBJECT
+public:
+ SubOwnDot();
+ ~SubOwnDot();
+};
+}
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp
new file mode 100644
index 000000000..626a9a86c
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp
@@ -0,0 +1,18 @@
+#ifndef InIncludes_SubOwnDot_P_HPP
+#define InIncludes_SubOwnDot_P_HPP
+
+#include <QObject>
+
+namespace InIncludes {
+
+class SubOwnDotPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ SubOwnDotPrivate();
+ ~SubOwnDotPrivate();
+};
+
+} // End of namespace
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp b/Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp
new file mode 100644
index 000000000..88f53a445
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp
@@ -0,0 +1,4 @@
+
+// Moc a header that is not in the sources but in a directory that
+// is in the list of include directories.
+#include "InIncludes/moc_SubOwnDot.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp b/Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp
new file mode 100644
index 000000000..557cc62e1
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp
@@ -0,0 +1,32 @@
+#include "MixedCustom.hpp"
+
+class MixedCustomLocal : public QObject
+{
+ Q_OBJECT
+
+public:
+ MixedCustomLocal();
+ ~MixedCustomLocal();
+};
+
+MixedCustomLocal::MixedCustomLocal()
+{
+}
+
+MixedCustomLocal::~MixedCustomLocal()
+{
+}
+
+MixedCustom::MixedCustom()
+{
+ MixedCustomLocal local;
+}
+
+MixedCustom::~MixedCustom()
+{
+}
+
+// AUTOMOC generated source moc
+#include "MixedCustom.moc"
+// Externally generated header moc
+#include "MixedCustom_extMoc.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp b/Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp
new file mode 100644
index 000000000..6e8ff8865
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp
@@ -0,0 +1,20 @@
+#ifndef MixedCustom_HPP
+#define MixedCustom_HPP
+
+#include <QObject>
+
+// Object source includes
+// - externally generated header moc file
+// - AUTOMOC generated source .moc file
+class MixedCustom : public QObject
+{
+ Q_OBJECT
+public:
+ MixedCustom();
+ ~MixedCustom();
+};
+
+// Function forward declaration
+void moc_MixedCustom(MixedCustom const& arg);
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp
new file mode 100644
index 000000000..6919ebcf2
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp
@@ -0,0 +1,40 @@
+#include "MixedSkipped.hpp"
+
+#include "MixedCustom.hpp"
+
+class MixedSkippedLocal : public QObject
+{
+ Q_OBJECT
+
+public:
+ MixedSkippedLocal();
+ ~MixedSkippedLocal();
+};
+
+MixedSkippedLocal::MixedSkippedLocal()
+{
+}
+
+MixedSkippedLocal::~MixedSkippedLocal()
+{
+}
+
+MixedSkipped::MixedSkipped()
+{
+ MixedSkippedLocal local;
+ MixedCustom externCutom;
+ // Call moc named function
+ moc_MixedCustom(externCutom);
+}
+
+MixedSkipped::~MixedSkipped()
+{
+}
+
+// Include AUTOMOC generated moc files
+#include "MixedSkipped.moc"
+#include "moc_MixedSkipped.cpp"
+
+// Include externally generated moc_ named file that is not a moc file
+// and for which the relevant header is SKIP_AUTOMOC enabled
+#include "moc_MixedCustom.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp
new file mode 100644
index 000000000..5f6c6644f
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp
@@ -0,0 +1,17 @@
+#ifndef MixedSkipped_HPP
+#define MixedSkipped_HPP
+
+#include <QObject>
+
+// Object source includes
+// - Own moc_ and .moc files.
+// - externally generated moc_ file from a SKIP_AUTOMOC enabled header
+class MixedSkipped : public QObject
+{
+ Q_OBJECT
+public:
+ MixedSkipped();
+ ~MixedSkipped();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/None.cpp b/Tests/QtAutogen/MocInclude/Common/None.cpp
new file mode 100644
index 000000000..286ddb6cc
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/None.cpp
@@ -0,0 +1,21 @@
+#include "None.hpp"
+
+#include "None_p.h"
+
+NonePrivate::NonePrivate()
+{
+}
+
+NonePrivate::~NonePrivate()
+{
+}
+
+None::None()
+ : d(new NonePrivate)
+{
+}
+
+None::~None()
+{
+ delete d;
+}
diff --git a/Tests/QtAutogen/MocInclude/Common/None.hpp b/Tests/QtAutogen/MocInclude/Common/None.hpp
new file mode 100644
index 000000000..ca0713ec4
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/None.hpp
@@ -0,0 +1,19 @@
+#ifndef None_HPP
+#define None_HPP
+
+#include <QObject>
+
+// Object source comes without any _moc/.moc includes
+class NonePrivate;
+class None : public QObject
+{
+ Q_OBJECT
+public:
+ None();
+ ~None();
+
+private:
+ NonePrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/None_p.h b/Tests/QtAutogen/MocInclude/Common/None_p.h
new file mode 100644
index 000000000..e209aebbd
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/None_p.h
@@ -0,0 +1,14 @@
+#ifndef None_P_HPP
+#define None_P_HPP
+
+#include <QObject>
+
+class NonePrivate : public QObject
+{
+ Q_OBJECT
+public:
+ NonePrivate();
+ ~NonePrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp
new file mode 100644
index 000000000..df1c428a1
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp
@@ -0,0 +1,45 @@
+#include "OtherUnderscore.hpp"
+
+#include "OtherUnderscoreExtra.hpp"
+#include "OtherUnderscore_p.hpp"
+
+class OtherUnderscoreLocal : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscoreLocal();
+ ~OtherUnderscoreLocal();
+};
+
+OtherUnderscoreLocal::OtherUnderscoreLocal()
+{
+}
+
+OtherUnderscoreLocal::~OtherUnderscoreLocal()
+{
+}
+
+OtherUnderscorePrivate::OtherUnderscorePrivate()
+{
+ OtherUnderscoreLocal localObj;
+ OtherUnderscoreExtra extraObj;
+}
+
+OtherUnderscorePrivate::~OtherUnderscorePrivate()
+{
+}
+
+OtherUnderscore::OtherUnderscore()
+ : d(new OtherUnderscorePrivate)
+{
+}
+
+OtherUnderscore::~OtherUnderscore()
+{
+ delete d;
+}
+
+// For OtherUnderscoreLocal
+#include "OtherUnderscore.moc"
+// - Not the own header
+#include "moc_OtherUnderscoreExtra.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp
new file mode 100644
index 000000000..a4ff603cf
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp
@@ -0,0 +1,19 @@
+#ifndef OtherUnderscore_HPP
+#define OtherUnderscore_HPP
+
+#include <QObject>
+
+// Sources includes a moc_ includes of an extra object
+class OtherUnderscorePrivate;
+class OtherUnderscore : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscore();
+ ~OtherUnderscore();
+
+private:
+ OtherUnderscorePrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp
new file mode 100644
index 000000000..11ebd8104
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp
@@ -0,0 +1,21 @@
+#include "OtherUnderscoreExtra.hpp"
+
+#include "OtherUnderscoreExtra_p.hpp"
+
+OtherUnderscoreExtraPrivate::OtherUnderscoreExtraPrivate()
+{
+}
+
+OtherUnderscoreExtraPrivate::~OtherUnderscoreExtraPrivate()
+{
+}
+
+OtherUnderscoreExtra::OtherUnderscoreExtra()
+ : d(new OtherUnderscoreExtraPrivate)
+{
+}
+
+OtherUnderscoreExtra::~OtherUnderscoreExtra()
+{
+ delete d;
+}
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp
new file mode 100644
index 000000000..5afe48cf8
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp
@@ -0,0 +1,18 @@
+#ifndef OtherUnderscoreEXTRA_HPP
+#define OtherUnderscoreEXTRA_HPP
+
+#include <QObject>
+
+class OtherUnderscoreExtraPrivate;
+class OtherUnderscoreExtra : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscoreExtra();
+ ~OtherUnderscoreExtra();
+
+private:
+ OtherUnderscoreExtraPrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp
new file mode 100644
index 000000000..2066ac305
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp
@@ -0,0 +1,14 @@
+#ifndef OtherUnderscoreEXTRA_P_HPP
+#define OtherUnderscoreEXTRA_P_HPP
+
+#include <QObject>
+
+class OtherUnderscoreExtraPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscoreExtraPrivate();
+ ~OtherUnderscoreExtraPrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp
new file mode 100644
index 000000000..712c540c3
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp
@@ -0,0 +1,46 @@
+#include "OtherUnderscoreSub.hpp"
+
+#include "OtherUnderscoreSubDir/SubExtra.hpp"
+#include "OtherUnderscoreSub_p.hpp"
+
+class OtherUnderscoreSubLocal : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscoreSubLocal();
+ ~OtherUnderscoreSubLocal();
+};
+
+OtherUnderscoreSubLocal::OtherUnderscoreSubLocal()
+{
+}
+
+OtherUnderscoreSubLocal::~OtherUnderscoreSubLocal()
+{
+}
+
+OtherUnderscoreSubPrivate::OtherUnderscoreSubPrivate()
+{
+ OtherUnderscoreSubLocal localObj;
+ SubExtra extraObj;
+}
+
+OtherUnderscoreSubPrivate::~OtherUnderscoreSubPrivate()
+{
+}
+
+OtherUnderscoreSub::OtherUnderscoreSub()
+ : d(new OtherUnderscoreSubPrivate)
+{
+}
+
+OtherUnderscoreSub::~OtherUnderscoreSub()
+{
+ delete d;
+}
+
+// For OtherUnderscoreSubLocal
+#include "OtherUnderscoreSub.moc"
+// - Not the own header
+// - in a subdirectory
+#include "OtherUnderscoreSubDir/moc_SubExtra.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp
new file mode 100644
index 000000000..7feaa46f1
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp
@@ -0,0 +1,19 @@
+#ifndef OtherUnderscoreSub_HPP
+#define OtherUnderscoreSub_HPP
+
+#include <QObject>
+
+// Sources includes a moc_ includes of an extra object in a subdirectory
+class OtherUnderscoreSubPrivate;
+class OtherUnderscoreSub : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscoreSub();
+ ~OtherUnderscoreSub();
+
+private:
+ OtherUnderscoreSubPrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp
new file mode 100644
index 000000000..22501e44d
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp
@@ -0,0 +1,21 @@
+#include "SubExtra.hpp"
+
+#include "SubExtra_p.hpp"
+
+SubExtraPrivate::SubExtraPrivate()
+{
+}
+
+SubExtraPrivate::~SubExtraPrivate()
+{
+}
+
+SubExtra::SubExtra()
+ : d(new SubExtraPrivate)
+{
+}
+
+SubExtra::~SubExtra()
+{
+ delete d;
+}
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp
new file mode 100644
index 000000000..5700634a0
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp
@@ -0,0 +1,18 @@
+#ifndef SubExtra_HPP
+#define SubExtra_HPP
+
+#include <QObject>
+
+class SubExtraPrivate;
+class SubExtra : public QObject
+{
+ Q_OBJECT
+public:
+ SubExtra();
+ ~SubExtra();
+
+private:
+ SubExtraPrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp
new file mode 100644
index 000000000..5a14a2d38
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp
@@ -0,0 +1,14 @@
+#ifndef SubExtra_P_HPP
+#define SubExtra_P_HPP
+
+#include <QObject>
+
+class SubExtraPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ SubExtraPrivate();
+ ~SubExtraPrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp
new file mode 100644
index 000000000..7d5999ca4
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp
@@ -0,0 +1,14 @@
+#ifndef OtherUnderscoreSub_P_HPP
+#define OtherUnderscoreSub_P_HPP
+
+#include <QObject>
+
+class OtherUnderscoreSubPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscoreSubPrivate();
+ ~OtherUnderscoreSubPrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp
new file mode 100644
index 000000000..96906cfc2
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp
@@ -0,0 +1,14 @@
+#ifndef OtherUnderscore_P_HPP
+#define OtherUnderscore_P_HPP
+
+#include <QObject>
+
+class OtherUnderscorePrivate : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscorePrivate();
+ ~OtherUnderscorePrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDot.cpp b/Tests/QtAutogen/MocInclude/Common/OwnDot.cpp
new file mode 100644
index 000000000..b7b7d854c
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnDot.cpp
@@ -0,0 +1,40 @@
+#include "OwnDot.hpp"
+
+#include "OwnDot_p.h"
+
+class OwnDotLocal : public QObject
+{
+ Q_OBJECT
+public:
+ OwnDotLocal();
+ ~OwnDotLocal();
+};
+
+OwnDotLocal::OwnDotLocal()
+{
+}
+
+OwnDotLocal::~OwnDotLocal()
+{
+}
+
+OwnDotPrivate::OwnDotPrivate()
+{
+ OwnDotLocal localObj;
+}
+
+OwnDotPrivate::~OwnDotPrivate()
+{
+}
+
+OwnDot::OwnDot()
+ : d(new OwnDotPrivate)
+{
+}
+
+OwnDot::~OwnDot()
+{
+ delete d;
+}
+
+#include "OwnDot.moc"
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDot.hpp b/Tests/QtAutogen/MocInclude/Common/OwnDot.hpp
new file mode 100644
index 000000000..6f49f12ba
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnDot.hpp
@@ -0,0 +1,19 @@
+#ifndef OwnDot_HPP
+#define OwnDot_HPP
+
+#include <QObject>
+
+// Object source comes with a .moc include
+class OwnDotPrivate;
+class OwnDot : public QObject
+{
+ Q_OBJECT
+public:
+ OwnDot();
+ ~OwnDot();
+
+private:
+ OwnDotPrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp
new file mode 100644
index 000000000..056c0db84
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp
@@ -0,0 +1,41 @@
+#include "OwnDotUnderscore.hpp"
+
+#include "OwnDotUnderscore_p.h"
+
+class OwnDotUnderscoreLocal : public QObject
+{
+ Q_OBJECT
+public:
+ OwnDotUnderscoreLocal();
+ ~OwnDotUnderscoreLocal();
+};
+
+OwnDotUnderscoreLocal::OwnDotUnderscoreLocal()
+{
+}
+
+OwnDotUnderscoreLocal::~OwnDotUnderscoreLocal()
+{
+}
+
+OwnDotUnderscorePrivate::OwnDotUnderscorePrivate()
+{
+ OwnDotUnderscoreLocal localObj;
+}
+
+OwnDotUnderscorePrivate::~OwnDotUnderscorePrivate()
+{
+}
+
+OwnDotUnderscore::OwnDotUnderscore()
+ : d(new OwnDotUnderscorePrivate)
+{
+}
+
+OwnDotUnderscore::~OwnDotUnderscore()
+{
+ delete d;
+}
+
+#include "OwnDotUnderscore.moc"
+#include "moc_OwnDotUnderscore.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp
new file mode 100644
index 000000000..478955c30
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp
@@ -0,0 +1,19 @@
+#ifndef LOwnDotUnderscore_HPP
+#define LOwnDotUnderscore_HPP
+
+#include <QObject>
+
+// Object source comes with a .moc and a _moc include
+class OwnDotUnderscorePrivate;
+class OwnDotUnderscore : public QObject
+{
+ Q_OBJECT
+public:
+ OwnDotUnderscore();
+ ~OwnDotUnderscore();
+
+private:
+ OwnDotUnderscorePrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h
new file mode 100644
index 000000000..6950b7f13
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h
@@ -0,0 +1,14 @@
+#ifndef OwnDotUnderscore_P_HPP
+#define OwnDotUnderscore_P_HPP
+
+#include <QObject>
+
+class OwnDotUnderscorePrivate : public QObject
+{
+ Q_OBJECT
+public:
+ OwnDotUnderscorePrivate();
+ ~OwnDotUnderscorePrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDot_p.h b/Tests/QtAutogen/MocInclude/Common/OwnDot_p.h
new file mode 100644
index 000000000..f3aff32ff
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnDot_p.h
@@ -0,0 +1,14 @@
+#ifndef OwnDot_P_HPP
+#define OwnDot_P_HPP
+
+#include <QObject>
+
+class OwnDotPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ OwnDotPrivate();
+ ~OwnDotPrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp
new file mode 100644
index 000000000..cb8f12c9b
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp
@@ -0,0 +1,23 @@
+#include "OwnUnderscore.hpp"
+
+#include "OwnUnderscore_p.h"
+
+OwnUnderscorePrivate::OwnUnderscorePrivate()
+{
+}
+
+OwnUnderscorePrivate::~OwnUnderscorePrivate()
+{
+}
+
+OwnUnderscore::OwnUnderscore()
+ : d(new OwnUnderscorePrivate)
+{
+}
+
+OwnUnderscore::~OwnUnderscore()
+{
+ delete d;
+}
+
+#include "moc_OwnUnderscore.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp
new file mode 100644
index 000000000..e6a6a6eb8
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp
@@ -0,0 +1,19 @@
+#ifndef OwnUnderscore_HPP
+#define OwnUnderscore_HPP
+
+#include <QObject>
+
+// Object source comes with a _moc include
+class OwnUnderscorePrivate;
+class OwnUnderscore : public QObject
+{
+ Q_OBJECT
+public:
+ OwnUnderscore();
+ ~OwnUnderscore();
+
+private:
+ OwnUnderscorePrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h
new file mode 100644
index 000000000..a3a6b0062
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h
@@ -0,0 +1,14 @@
+#ifndef OwnUnderscore_P_HPP
+#define OwnUnderscore_P_HPP
+
+#include <QObject>
+
+class OwnUnderscorePrivate : public QObject
+{
+ Q_OBJECT
+public:
+ OwnUnderscorePrivate();
+ ~OwnUnderscorePrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/common.cpp.in b/Tests/QtAutogen/MocInclude/Common/common.cpp.in
new file mode 100644
index 000000000..b53e93dd6
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/common.cpp.in
@@ -0,0 +1,32 @@
+#include "DualSub/Second/Second.hpp"
+#include "DualSubMocked.hpp"
+#include "ExternDot.hpp"
+#include "ExternDotGenerated.hpp"
+#include "None.hpp"
+#include "OtherUnderscore.hpp"
+#include "OtherUnderscoreSub.hpp"
+#include "OwnDot.hpp"
+#include "OwnDotUnderscore.hpp"
+#include "OwnUnderscore.hpp"
+#include "InIncludes/SubOwnDot.hpp"
+
+bool @COMMON_FUNCTION_NAME@()
+{
+ None objNone;
+ OwnUnderscore objOwnUnderscore;
+ OwnDot objOwnDot;
+ OwnDotUnderscore objOwnDotUnderscore;
+
+ OtherUnderscore objOtherUnderscore;
+ OtherUnderscoreSub objOtherUnderscoreSub;
+
+ Second second;
+ DualSubMocked dualSubMocked;
+
+ ExternDot objExternDot;
+ ExternDotGenerated objGeneratedExternDot;
+
+ InIncludes::SubOwnDot subOwnDot;
+
+ return true;
+}
diff --git a/Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in b/Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in
new file mode 100644
index 000000000..6c44793a8
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in
@@ -0,0 +1,5 @@
+
+void moc_MixedCustom(MixedCustom const & arg)
+{
+ (void)arg;
+}
diff --git a/Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt b/Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt
new file mode 100644
index 000000000..048b79cb7
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt
@@ -0,0 +1,17 @@
+# Enable relaxed mode
+set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
+
+# Common test
+set(COMMON_FUNCTION_NAME commonRelaxed)
+configure_file(
+ "${COM_DIR}/common.cpp.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/commonRelaxed.cpp")
+
+makeExecutable(libRelaxed)
+target_sources(libRelaxed PRIVATE
+ "${CMAKE_CURRENT_BINARY_DIR}/commonRelaxed.cpp"
+ RObjA.cpp
+ RObjB.cpp
+ RObjC.cpp
+ relaxed.cpp
+ )
diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjA.cpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.cpp
new file mode 100644
index 000000000..2e2cf6a48
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.cpp
@@ -0,0 +1,12 @@
+#include "RObjA.hpp"
+
+RObjA::RObjA()
+{
+}
+
+RObjA::~RObjA()
+{
+}
+
+// Relaxed include should moc the header instead
+#include "RObjA.moc"
diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjA.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.hpp
new file mode 100644
index 000000000..597418773
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.hpp
@@ -0,0 +1,14 @@
+#ifndef ROBJA_HPP
+#define ROBJA_HPP
+
+#include <QObject>
+
+class RObjA : public QObject
+{
+ Q_OBJECT
+public:
+ RObjA();
+ ~RObjA();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjB.cpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.cpp
new file mode 100644
index 000000000..57d7daf16
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.cpp
@@ -0,0 +1,23 @@
+#include "RObjB.hpp"
+
+#include "RObjBExtra.hpp"
+
+RObjBExtra::RObjBExtra()
+{
+}
+
+RObjBExtra::~RObjBExtra()
+{
+}
+
+RObjB::RObjB()
+{
+ RObjBExtra extraObject;
+}
+
+RObjB::~RObjB()
+{
+}
+
+// Relaxed mode should run moc on RObjBExtra.hpp instead
+#include "RObjBExtra.moc"
diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjB.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.hpp
new file mode 100644
index 000000000..d6d0474ad
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.hpp
@@ -0,0 +1,14 @@
+#ifndef ROBJB_HPP
+#define ROBJB_HPP
+
+#include <QObject>
+
+class RObjB : public QObject
+{
+ Q_OBJECT
+public:
+ RObjB();
+ ~RObjB();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjBExtra.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjBExtra.hpp
new file mode 100644
index 000000000..5d6be752f
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjBExtra.hpp
@@ -0,0 +1,14 @@
+#ifndef ROBJBEXTRA_HPP
+#define ROBJBEXTRA_HPP
+
+#include <QObject>
+
+class RObjBExtra : public QObject
+{
+ Q_OBJECT
+public:
+ RObjBExtra();
+ ~RObjBExtra();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjC.cpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.cpp
new file mode 100644
index 000000000..327521666
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.cpp
@@ -0,0 +1,31 @@
+#include "RObjC.hpp"
+
+#include <QObject>
+
+class RObjCPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ RObjCPrivate();
+ ~RObjCPrivate();
+};
+
+RObjCPrivate::RObjCPrivate()
+{
+}
+
+RObjCPrivate::~RObjCPrivate()
+{
+}
+
+RObjC::RObjC()
+{
+ RObjCPrivate privateObject;
+}
+
+RObjC::~RObjC()
+{
+}
+
+// Relaxed include should moc this source instead of the header
+#include "moc_RObjC.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Relaxed/RObjC.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.hpp
new file mode 100644
index 000000000..5552ede4a
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.hpp
@@ -0,0 +1,14 @@
+#ifndef ROBJC_HPP
+#define ROBJC_HPP
+
+#include <QObject>
+
+class RObjC : public QObject
+{
+ Q_OBJECT
+public:
+ RObjC();
+ ~RObjC();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp b/Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp
new file mode 100644
index 000000000..5a511b673
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp
@@ -0,0 +1,21 @@
+// AUTOMOC relaxed mode objects
+#include "RObjA.hpp"
+#include "RObjB.hpp"
+#include "RObjC.hpp"
+
+// Forward declaration
+bool commonRelaxed();
+
+int main(int argv, char** args)
+{
+ // Common tests
+ if (!commonRelaxed()) {
+ return -1;
+ }
+
+ // Relaxed tests
+ RObjA rObjA;
+ RObjB rObjB;
+ RObjC rObjC;
+ return 0;
+}
diff --git a/Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt b/Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt
new file mode 100644
index 000000000..12c503faf
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Disable relaxed mode
+set(CMAKE_AUTOMOC_RELAXED_MODE FALSE)
+
+# Common test
+set(COMMON_FUNCTION_NAME commonStrict)
+configure_file(
+ "${COM_DIR}/common.cpp.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/commonStrict.cpp")
+
+makeExecutable(libStrict)
+target_sources(libStrict PRIVATE
+ "${CMAKE_CURRENT_BINARY_DIR}/commonStrict.cpp"
+ strict.cpp
+ )
diff --git a/Tests/QtAutogen/MocInclude/Strict/strict.cpp b/Tests/QtAutogen/MocInclude/Strict/strict.cpp
new file mode 100644
index 000000000..dd24bb0d4
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Strict/strict.cpp
@@ -0,0 +1,7 @@
+// Forward declaration
+bool commonStrict();
+
+int main(int argv, char** args)
+{
+ return commonStrict() ? 0 : -1;
+}
diff --git a/Tests/QtAutogen/MocInclude/main.cpp b/Tests/QtAutogen/MocInclude/main.cpp
new file mode 100644
index 000000000..371c5fdad
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/main.cpp
@@ -0,0 +1,9 @@
+
+// Forward declaration
+bool libStrict();
+bool libRelaxed();
+
+int main(int argv, char** args)
+{
+ return (libStrict() && libRelaxed()) ? 0 : -1;
+}
diff --git a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt
new file mode 100644
index 000000000..1627b394f
--- /dev/null
+++ b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt
@@ -0,0 +1,80 @@
+cmake_minimum_required(VERSION 3.15)
+project(MocIncludeSymlink)
+include("../AutogenCoreTest.cmake")
+
+#
+# Tests if MocInclude can be build when
+# - The source directory is a symbolic link
+# - The build directory is a symbolic link
+#
+
+# -- Utility variables
+set(CS_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(CB_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+
+# Absolute MocInclude path
+get_filename_component(MocIncludePath "../MocInclude" ABSOLUTE)
+message("MocIncludePath: ${MocIncludePath}")
+
+# Use nested subdirectories to ensure relatives paths are correct as well
+set(BUILD_DIR_NORMAL "${CB_DIR}/Build/Normal")
+set(BUILD_DIR_LINKED "${CB_DIR}/Build/Linked")
+
+set(SL_SOURCE_DIR "${CB_DIR}/SL_Source")
+set(SL_BUILD_DIR "${CB_DIR}/SL_Build")
+
+# -- Utility macros
+function(makeSymLink origin link)
+ message("Creating symbolic link\n Link: ${link}\n To: ${origin}")
+ file(CREATE_LINK ${origin} ${link} RESULT res SYMBOLIC)
+ if(NOT (${res} STREQUAL "0"))
+ message("Symlink creation failed.\n Link: ${link}\n To: ${origin}\n Result: ${res}")
+ endif()
+endfunction()
+
+# -- Make source directory symlink
+makeSymLink(${MocIncludePath} ${SL_SOURCE_DIR} linkResult)
+if(NOT EXISTS ${SL_SOURCE_DIR})
+ message("Directory symlink can't be created. Skipping test.")
+ return()
+endif()
+
+# -- Make normal build directory
+file(REMOVE_RECURSE ${BUILD_DIR_NORMAL})
+file(MAKE_DIRECTORY ${BUILD_DIR_NORMAL})
+
+# -- Make linked build directory and symlink
+file(REMOVE_RECURSE ${BUILD_DIR_LINKED})
+file(MAKE_DIRECTORY ${BUILD_DIR_LINKED})
+makeSymLink(${BUILD_DIR_LINKED} ${SL_BUILD_DIR} linkResult)
+if(NOT EXISTS ${SL_BUILD_DIR})
+ message("Directory symlink can't be created. Skipping test.")
+ return()
+endif()
+
+
+# -- Building
+macro(buildMocInclude sourceDir binaryDir)
+ message("Building MocInclude\n - source dir: ${sourceDir}\n - binary dir: ${binaryDir}\n")
+ try_compile(result
+ "${binaryDir}"
+ "${sourceDir}"
+ MocInclude
+ CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+ "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
+ "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+ OUTPUT_VARIABLE output
+ )
+ if (result)
+ message(STATUS "--- Build success. ---")
+ else()
+ message(STATUS "\n### Building MocInclude failed. ###\n\n--- Output ---\n${output}")
+ message(FATAL_ERROR "--- Building MocInclude failed. End of output. ---")
+ endif()
+endmacro()
+
+message("\nTry building with\n - symbolic link source dir\n - non symbolic build dir\n")
+buildMocInclude(${SL_SOURCE_DIR} ${BUILD_DIR_NORMAL})
+
+message("\nTry building with\n - symbolic link source dir\n - symbolic link build dir\n")
+buildMocInclude(${SL_SOURCE_DIR} ${SL_BUILD_DIR})
diff --git a/Tests/QtAutogen/MocMacroName/CMakeLists.txt b/Tests/QtAutogen/MocMacroName/CMakeLists.txt
new file mode 100644
index 000000000..bf13d187d
--- /dev/null
+++ b/Tests/QtAutogen/MocMacroName/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.10)
+project(MocMacroName)
+include("../AutogenCoreTest.cmake")
+
+# Test CMAKE_AUTOMOC_MACRO_NAMES and AUTOMOC_MACRO_NAMES
+list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "QO1_ALIAS")
+
+add_executable(mocMacroName
+ main.cpp
+ Gadget.cpp
+ Object.cpp
+ Object1Aliased.cpp
+ Object2Aliased.cpp
+)
+set_property(TARGET mocMacroName PROPERTY AUTOMOC ON)
+set_property(TARGET mocMacroName APPEND PROPERTY AUTOMOC_MACRO_NAMES "QO2_ALIAS")
+target_link_libraries(mocMacroName ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/MocMacroName/CustomMacros.hpp b/Tests/QtAutogen/MocMacroName/CustomMacros.hpp
new file mode 100644
index 000000000..93e5bfdc1
--- /dev/null
+++ b/Tests/QtAutogen/MocMacroName/CustomMacros.hpp
@@ -0,0 +1,8 @@
+#ifndef CUSTOM_MACROS_HPP
+#define CUSTOM_MACROS_HPP
+
+#include <QObject>
+#define QO1_ALIAS Q_OBJECT
+#define QO2_ALIAS Q_OBJECT
+
+#endif
diff --git a/Tests/QtAutogen/MocMacroName/Gadget.cpp b/Tests/QtAutogen/MocMacroName/Gadget.cpp
new file mode 100644
index 000000000..d7cb51590
--- /dev/null
+++ b/Tests/QtAutogen/MocMacroName/Gadget.cpp
@@ -0,0 +1,6 @@
+#include "Gadget.hpp"
+
+Gadget::Gadget()
+ : _test(0)
+{
+}
diff --git a/Tests/QtAutogen/MocMacroName/Gadget.hpp b/Tests/QtAutogen/MocMacroName/Gadget.hpp
new file mode 100644
index 000000000..cab792edc
--- /dev/null
+++ b/Tests/QtAutogen/MocMacroName/Gadget.hpp
@@ -0,0 +1,19 @@
+#ifndef GADGET_HPP
+#define GADGET_HPP
+
+#include <QMetaType>
+
+class Gadget
+{
+ Q_GADGET
+ Q_PROPERTY(int test READ getTest)
+public:
+ Gadget();
+
+ int getTest() { return _test; }
+
+private:
+ int _test;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocMacroName/Object.cpp b/Tests/QtAutogen/MocMacroName/Object.cpp
new file mode 100644
index 000000000..800ebf3da
--- /dev/null
+++ b/Tests/QtAutogen/MocMacroName/Object.cpp
@@ -0,0 +1,10 @@
+#include "Object.hpp"
+
+Object::Object()
+ : _test(0)
+{
+}
+
+void Object::aSlot()
+{
+}
diff --git a/Tests/QtAutogen/MocMacroName/Object.hpp b/Tests/QtAutogen/MocMacroName/Object.hpp
new file mode 100644
index 000000000..aadae1f6d
--- /dev/null
+++ b/Tests/QtAutogen/MocMacroName/Object.hpp
@@ -0,0 +1,22 @@
+#ifndef OBJECT_HPP
+#define OBJECT_HPP
+
+#include <QObject>
+
+class Object : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(int test READ getTest)
+public:
+ Object();
+
+ int getTest() { return _test; }
+
+ Q_SLOT
+ void aSlot();
+
+private:
+ int _test;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocMacroName/Object1Aliased.cpp b/Tests/QtAutogen/MocMacroName/Object1Aliased.cpp
new file mode 100644
index 000000000..b8b4806c6
--- /dev/null
+++ b/Tests/QtAutogen/MocMacroName/Object1Aliased.cpp
@@ -0,0 +1,9 @@
+#include "Object1Aliased.hpp"
+
+Object1Aliased::Object1Aliased()
+{
+}
+
+void Object1Aliased::aSlot()
+{
+}
diff --git a/Tests/QtAutogen/MocMacroName/Object1Aliased.hpp b/Tests/QtAutogen/MocMacroName/Object1Aliased.hpp
new file mode 100644
index 000000000..6c6bb4088
--- /dev/null
+++ b/Tests/QtAutogen/MocMacroName/Object1Aliased.hpp
@@ -0,0 +1,20 @@
+#ifndef OBJECTALIASED_HPP
+#define OBJECTALIASED_HPP
+
+#include "CustomMacros.hpp"
+
+// Test Qt object macro hidden in a macro (AUTOMOC_MACRO_NAMES)
+class Object1Aliased : public QObject
+{
+ QO1_ALIAS
+public:
+ Object1Aliased();
+
+signals:
+ void aSignal();
+
+public slots:
+ void aSlot();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocMacroName/Object2Aliased.cpp b/Tests/QtAutogen/MocMacroName/Object2Aliased.cpp
new file mode 100644
index 000000000..4b09dd1bc
--- /dev/null
+++ b/Tests/QtAutogen/MocMacroName/Object2Aliased.cpp
@@ -0,0 +1,9 @@
+#include "Object2Aliased.hpp"
+
+Object2Aliased::Object2Aliased()
+{
+}
+
+void Object2Aliased::aSlot()
+{
+}
diff --git a/Tests/QtAutogen/MocMacroName/Object2Aliased.hpp b/Tests/QtAutogen/MocMacroName/Object2Aliased.hpp
new file mode 100644
index 000000000..b9bdc126f
--- /dev/null
+++ b/Tests/QtAutogen/MocMacroName/Object2Aliased.hpp
@@ -0,0 +1,20 @@
+#ifndef OBJECT2ALIASED_HPP
+#define OBJECT2ALIASED_HPP
+
+#include "CustomMacros.hpp"
+
+// Test Qt object macro hidden in a macro (AUTOMOC_MACRO_NAMES)
+class Object2Aliased : public QObject
+{
+ QO2_ALIAS
+public:
+ Object2Aliased();
+
+signals:
+ void aSignal();
+
+public slots:
+ void aSlot();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocMacroName/main.cpp b/Tests/QtAutogen/MocMacroName/main.cpp
new file mode 100644
index 000000000..3b45d042d
--- /dev/null
+++ b/Tests/QtAutogen/MocMacroName/main.cpp
@@ -0,0 +1,13 @@
+#include "Gadget.hpp"
+#include "Object.hpp"
+#include "Object1Aliased.hpp"
+#include "Object2Aliased.hpp"
+
+int main(int argv, char** args)
+{
+ Gadget gadget;
+ Object object;
+ Object1Aliased object1Aliased;
+ Object2Aliased object2Aliased;
+ return 0;
+}
diff --git a/Tests/QtAutogen/MocOnly/CMakeLists.txt b/Tests/QtAutogen/MocOnly/CMakeLists.txt
new file mode 100644
index 000000000..e109154aa
--- /dev/null
+++ b/Tests/QtAutogen/MocOnly/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.10)
+project(MocOnly)
+include("../AutogenCoreTest.cmake")
+
+add_executable(mocOnly
+ main.cpp
+ # Test different Q_OBJECT position styles
+ StyleA.cpp
+ StyleB.cpp
+ # Test different moc_/.moc include positions
+ IncA.cpp
+ IncB.cpp
+)
+set_property(TARGET mocOnly PROPERTY AUTOMOC ON)
+target_link_libraries(mocOnly ${QT_LIBRARIES})
+# Add compile definitions with unusual characters
+target_compile_definitions(mocOnly PUBLIC "TOKEN=\"hello\;\"" )
diff --git a/Tests/QtAutogen/MocOnly/IncA.cpp b/Tests/QtAutogen/MocOnly/IncA.cpp
new file mode 100644
index 000000000..94610cd48
--- /dev/null
+++ b/Tests/QtAutogen/MocOnly/IncA.cpp
@@ -0,0 +1,19 @@
+#include "moc_IncA.cpp"
+/// AUTOMOC moc_ include on the first line of the file!
+#include "IncA.hpp"
+
+/// @brief Source local QObject
+///
+class IncAPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ IncAPrivate(){};
+};
+
+IncA::IncA()
+{
+ IncAPrivate priv;
+}
+
+#include "IncA.moc"
diff --git a/Tests/QtAutogen/MocOnly/IncA.hpp b/Tests/QtAutogen/MocOnly/IncA.hpp
new file mode 100644
index 000000000..ecc889f9d
--- /dev/null
+++ b/Tests/QtAutogen/MocOnly/IncA.hpp
@@ -0,0 +1,15 @@
+#ifndef INCA_HPP
+#define INCA_HPP
+
+#include <QObject>
+
+/// @brief Test moc include pattern in the source file
+///
+class IncA : public QObject
+{
+ Q_OBJECT
+public:
+ IncA();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocOnly/IncB.cpp b/Tests/QtAutogen/MocOnly/IncB.cpp
new file mode 100644
index 000000000..bd441a978
--- /dev/null
+++ b/Tests/QtAutogen/MocOnly/IncB.cpp
@@ -0,0 +1,19 @@
+#include "IncB.hpp"
+
+/// @brief Source local QObject
+///
+class IncBPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ IncBPrivate(){};
+};
+
+IncB::IncB()
+{
+ IncBPrivate priv;
+}
+
+/// AUTOMOC moc_ include on the last line of the file!
+#include "IncB.moc"
+#include "moc_IncB.cpp"
diff --git a/Tests/QtAutogen/MocOnly/IncB.hpp b/Tests/QtAutogen/MocOnly/IncB.hpp
new file mode 100644
index 000000000..8331ea2b7
--- /dev/null
+++ b/Tests/QtAutogen/MocOnly/IncB.hpp
@@ -0,0 +1,15 @@
+#ifndef INCB_HPP
+#define INCB_HPP
+
+#include <QObject>
+
+/// @brief Test moc include pattern in the source file
+///
+class IncB : public QObject
+{
+ Q_OBJECT
+public:
+ IncB();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocOnly/StyleA.cpp b/Tests/QtAutogen/MocOnly/StyleA.cpp
new file mode 100644
index 000000000..ced1dd151
--- /dev/null
+++ b/Tests/QtAutogen/MocOnly/StyleA.cpp
@@ -0,0 +1,5 @@
+#include "StyleA.hpp"
+
+StyleA::StyleA()
+{
+}
diff --git a/Tests/QtAutogen/MocOnly/StyleA.hpp b/Tests/QtAutogen/MocOnly/StyleA.hpp
new file mode 100644
index 000000000..5ba0a8768
--- /dev/null
+++ b/Tests/QtAutogen/MocOnly/StyleA.hpp
@@ -0,0 +1,17 @@
+#ifndef STYLEA_HPP
+#define STYLEA_HPP
+
+#include <QObject>
+
+/* clang-format off */
+/// Q_OBJECT on a single new line
+///
+class StyleA : public QObject
+{
+ Q_OBJECT
+public:
+ StyleA();
+};
+/* clang-format on */
+
+#endif
diff --git a/Tests/QtAutogen/MocOnly/StyleB.cpp b/Tests/QtAutogen/MocOnly/StyleB.cpp
new file mode 100644
index 000000000..bec6c1c36
--- /dev/null
+++ b/Tests/QtAutogen/MocOnly/StyleB.cpp
@@ -0,0 +1,5 @@
+#include "StyleB.hpp"
+
+StyleB::StyleB()
+{
+}
diff --git a/Tests/QtAutogen/MocOnly/StyleB.hpp b/Tests/QtAutogen/MocOnly/StyleB.hpp
new file mode 100644
index 000000000..86abaa8c9
--- /dev/null
+++ b/Tests/QtAutogen/MocOnly/StyleB.hpp
@@ -0,0 +1,16 @@
+#ifndef STYLEB_HPP
+#define STYLEB_HPP
+
+#include <QObject>
+
+/* clang-format off */
+/// Q_OBJECT behind a brace on a new line
+///
+class StyleB : public QObject
+{ Q_OBJECT
+public:
+ StyleB();
+};
+/* clang-format on */
+
+#endif
diff --git a/Tests/QtAutogen/MocOnly/main.cpp b/Tests/QtAutogen/MocOnly/main.cpp
new file mode 100644
index 000000000..ec8da214e
--- /dev/null
+++ b/Tests/QtAutogen/MocOnly/main.cpp
@@ -0,0 +1,19 @@
+#include <iostream>
+
+#include "IncA.hpp"
+#include "IncB.hpp"
+#include "StyleA.hpp"
+#include "StyleB.hpp"
+
+int main(int argv, char** args)
+{
+ StyleA styleA;
+ StyleB styleB;
+ IncA incA;
+ IncB incB;
+
+ // Test the TOKEN definition passed on the command line
+ std::string token(TOKEN);
+ std::cout << "std::string(TOKEN): \"" << token << "\"\n";
+ return (token == "hello;") ? 0 : -1;
+}
diff --git a/Tests/QtAutogen/MocOptions/CMakeLists.txt b/Tests/QtAutogen/MocOptions/CMakeLists.txt
new file mode 100644
index 000000000..19ee6587e
--- /dev/null
+++ b/Tests/QtAutogen/MocOptions/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.10)
+project(MocOptions)
+include("../AutogenCoreTest.cmake")
+
+# Test extra options passed to moc via AUTOMOC_MOC_OPTIONS
+add_executable(mocOptions Object.cpp main.cpp)
+set_property(TARGET mocOptions PROPERTY AUTOMOC ON)
+set_property(TARGET mocOptions PROPERTY AUTOMOC_MOC_OPTIONS "-nw")
+target_link_libraries(mocOptions ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/MocOptions/Object.cpp b/Tests/QtAutogen/MocOptions/Object.cpp
new file mode 100644
index 000000000..ad109f14c
--- /dev/null
+++ b/Tests/QtAutogen/MocOptions/Object.cpp
@@ -0,0 +1,5 @@
+#include "Object.hpp"
+
+Object::Object()
+{
+}
diff --git a/Tests/QtAutogen/MocOptions/Object.hpp b/Tests/QtAutogen/MocOptions/Object.hpp
new file mode 100644
index 000000000..e7a614200
--- /dev/null
+++ b/Tests/QtAutogen/MocOptions/Object.hpp
@@ -0,0 +1,13 @@
+#ifndef Object_HPP
+#define Object_HPP
+
+#include <QObject>
+
+class Object : public QObject
+{
+ Q_OBJECT
+public:
+ Object();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocOptions/main.cpp b/Tests/QtAutogen/MocOptions/main.cpp
new file mode 100644
index 000000000..7aeab1a89
--- /dev/null
+++ b/Tests/QtAutogen/MocOptions/main.cpp
@@ -0,0 +1,7 @@
+#include "Object.hpp"
+
+int main(int argv, char** args)
+{
+ Object object;
+ return 0;
+}
diff --git a/Tests/QtAutogen/MocOsMacros/CMakeLists.txt b/Tests/QtAutogen/MocOsMacros/CMakeLists.txt
new file mode 100644
index 000000000..b0125f6c3
--- /dev/null
+++ b/Tests/QtAutogen/MocOsMacros/CMakeLists.txt
@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 3.11)
+project(MocOsMacros)
+include("../AutogenCoreTest.cmake")
+
+# Tests if moc processes Q_OS_XXX macros
+
+message( "Qt5Core_VERSION: ${Qt5Core_VERSION}" )
+message(
+ "CMAKE_CXX_COMPILER_PREDEFINES_COMMAND: "
+ ${CMAKE_CXX_COMPILER_PREDEFINES_COMMAND} )
+
+# On some platforms (e.g. MAC) Q_OS_XXX requires moc to include moc_predefs.h
+# which is supported since Qt 5.8 and requires
+# CMAKE_CXX_COMPILER_PREDEFINES_COMMAND to be defined.
+if( ( ${Qt5Core_VERSION} VERSION_GREATER_EQUAL "5.8" ) AND
+ DEFINED CMAKE_CXX_COMPILER_PREDEFINES_COMMAND
+)
+ message( "Test enabled!" )
+ message(
+ "CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES: "
+ ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} )
+
+ set(CMAKE_AUTOMOC True)
+ add_executable(mocOsMacros
+ main.cpp
+ TestClass.cpp
+ TestClass.hpp
+ )
+ target_link_libraries(mocOsMacros PRIVATE ${QT_QTCORE_TARGET})
+else()
+ message( "Test disabled!" )
+endif()
diff --git a/Tests/QtAutogen/MocOsMacros/TestClass.cpp b/Tests/QtAutogen/MocOsMacros/TestClass.cpp
new file mode 100644
index 000000000..babc08b12
--- /dev/null
+++ b/Tests/QtAutogen/MocOsMacros/TestClass.cpp
@@ -0,0 +1,83 @@
+#include "TestClass.hpp"
+
+#include <iostream>
+
+void TestClass::open()
+{
+ std::cout << "open\n";
+}
+
+// -- Mac
+#ifndef Q_OS_MAC
+void TestClass::MacNotDef()
+{
+ std::cout << "MacNotDef\n";
+}
+#else
+void TestClass::MacNotDefElse()
+{
+ std::cout << "MacNotDefElse\n";
+}
+#endif
+
+#ifdef Q_OS_MAC
+void TestClass::MacDef()
+{
+ std::cout << "MacDef\n";
+}
+#else
+void TestClass::MacDefElse()
+{
+ std::cout << "MacDefElse\n";
+}
+#endif
+
+// -- Unix
+#ifndef Q_OS_UNIX
+void TestClass::UnixNotDef()
+{
+ std::cout << "UnixNotDef\n";
+}
+#else
+void TestClass::UnixNotDefElse()
+{
+ std::cout << "UnixNotDefElse\n";
+}
+#endif
+
+#ifdef Q_OS_UNIX
+void TestClass::UnixDef()
+{
+ std::cout << "UnixDef\n";
+}
+#else
+void TestClass::UnixDefElse()
+{
+ std::cout << "UnixDefElse\n";
+}
+#endif
+
+// -- Windows
+#ifndef Q_OS_WIN
+void TestClass::WindowsNotDef()
+{
+ std::cout << "WindowsNotDef\n";
+}
+#else
+void TestClass::WindowsNotDefElse()
+{
+ std::cout << "WindowsNotDefElse\n";
+}
+#endif
+
+#ifdef Q_OS_WIN
+void TestClass::WindowsDef()
+{
+ std::cout << "WindowsDef\n";
+}
+#else
+void TestClass::WindowsDefElse()
+{
+ std::cout << "WindowsDefElse\n";
+}
+#endif
diff --git a/Tests/QtAutogen/MocOsMacros/TestClass.hpp b/Tests/QtAutogen/MocOsMacros/TestClass.hpp
new file mode 100644
index 000000000..87fd49478
--- /dev/null
+++ b/Tests/QtAutogen/MocOsMacros/TestClass.hpp
@@ -0,0 +1,57 @@
+#ifndef TestClass_hpp
+#define TestClass_hpp
+
+#include <QObject>
+#include <QtGlobal>
+// include qplatformdefs.h for #18669
+#include <qplatformdefs.h>
+
+class TestClass : public QObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+
+ // Method named "open" to test if #18669 is fixed
+ void open();
+
+// -- Mac
+#ifndef Q_OS_MAC
+ void MacNotDef();
+#else
+ void MacNotDefElse();
+#endif
+
+#ifdef Q_OS_MAC
+ void MacDef();
+#else
+ void MacDefElse();
+#endif
+
+// -- Unix
+#ifndef Q_OS_UNIX
+ void UnixNotDef();
+#else
+ void UnixNotDefElse();
+#endif
+
+#ifdef Q_OS_UNIX
+ void UnixDef();
+#else
+ void UnixDefElse();
+#endif
+
+// -- Windows
+#ifndef Q_OS_WIN
+ void WindowsNotDef();
+#else
+ void WindowsNotDefElse();
+#endif
+
+#ifdef Q_OS_WIN
+ void WindowsDef();
+#else
+ void WindowsDefElse();
+#endif
+};
+
+#endif /* TestClass_hpp */
diff --git a/Tests/QtAutogen/MocOsMacros/main.cpp b/Tests/QtAutogen/MocOsMacros/main.cpp
new file mode 100644
index 000000000..c427345be
--- /dev/null
+++ b/Tests/QtAutogen/MocOsMacros/main.cpp
@@ -0,0 +1,33 @@
+#include <QtGlobal>
+
+#include "TestClass.hpp"
+
+int main()
+{
+ TestClass a;
+#ifdef Q_OS_MAC
+ a.MacNotDefElse();
+ a.MacDef();
+#else
+ a.MacNotDef();
+ a.MacDefElse();
+#endif
+
+#ifdef Q_OS_UNIX
+ a.UnixNotDefElse();
+ a.UnixDef();
+#else
+ a.UnixNotDef();
+ a.UnixDefElse();
+#endif
+
+#ifdef Q_OS_WIN
+ a.WindowsNotDefElse();
+ a.WindowsDef();
+#else
+ a.WindowsNotDef();
+ a.WindowsDefElse();
+#endif
+
+ return 0;
+}
diff --git a/Tests/QtAutogen/MocSkipSource/CMakeLists.txt b/Tests/QtAutogen/MocSkipSource/CMakeLists.txt
new file mode 100644
index 000000000..454e896e8
--- /dev/null
+++ b/Tests/QtAutogen/MocSkipSource/CMakeLists.txt
@@ -0,0 +1,36 @@
+cmake_minimum_required(VERSION 3.10)
+project(MocSkipSource)
+include("../AutogenCoreTest.cmake")
+
+# Test for SKIP_AUTOMOC and SKIP_AUTOGEN on an AUTOMOC enabled target
+
+# Generate header mocs manually
+qtx_wrap_cpp(skipMocWrapMoc
+ qItemA.hpp
+ qItemB.hpp
+ qItemC.hpp
+ qItemD.hpp
+)
+set(skipMocSources
+ skipMoc.cpp
+ qItemA.cpp
+ qItemB.cpp
+ qItemC.cpp
+ qItemD.cpp
+)
+# When cpp files are skipped, the hpp won't be processed either,
+# unless they are mentioned in the sources - which they aren't.
+set_property(SOURCE qItemA.cpp PROPERTY SKIP_AUTOMOC ON)
+set_property(SOURCE qItemB.cpp PROPERTY SKIP_AUTOGEN ON)
+# When hpp files are skipped, the cpp still get processed.
+set_property(SOURCE qItemC.hpp PROPERTY SKIP_AUTOMOC ON)
+set_property(SOURCE qItemD.hpp PROPERTY SKIP_AUTOGEN ON)
+# AUTOMOC enabled only
+add_executable(skipMocA ${skipMocSources} ${skipMocWrapMoc})
+set_property(TARGET skipMocA PROPERTY AUTOMOC ON)
+target_link_libraries(skipMocA ${QT_LIBRARIES})
+# AUTOMOC and AUTOUIC enabled
+add_executable(skipMocB ${skipMocSources} ${skipMocWrapMoc})
+set_property(TARGET skipMocB PROPERTY AUTOMOC ON)
+set_property(TARGET skipMocB PROPERTY AUTOUIC ON)
+target_link_libraries(skipMocB ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/skipSource/qItemA.cpp b/Tests/QtAutogen/MocSkipSource/qItemA.cpp
index 522c2c758..522c2c758 100644
--- a/Tests/QtAutogen/skipSource/qItemA.cpp
+++ b/Tests/QtAutogen/MocSkipSource/qItemA.cpp
diff --git a/Tests/QtAutogen/skipSource/qItemA.hpp b/Tests/QtAutogen/MocSkipSource/qItemA.hpp
index d295faf3a..d295faf3a 100644
--- a/Tests/QtAutogen/skipSource/qItemA.hpp
+++ b/Tests/QtAutogen/MocSkipSource/qItemA.hpp
diff --git a/Tests/QtAutogen/skipSource/qItemB.cpp b/Tests/QtAutogen/MocSkipSource/qItemB.cpp
index 636e15dfe..636e15dfe 100644
--- a/Tests/QtAutogen/skipSource/qItemB.cpp
+++ b/Tests/QtAutogen/MocSkipSource/qItemB.cpp
diff --git a/Tests/QtAutogen/skipSource/qItemB.hpp b/Tests/QtAutogen/MocSkipSource/qItemB.hpp
index 177591525..177591525 100644
--- a/Tests/QtAutogen/skipSource/qItemB.hpp
+++ b/Tests/QtAutogen/MocSkipSource/qItemB.hpp
diff --git a/Tests/QtAutogen/MocSkipSource/qItemC.cpp b/Tests/QtAutogen/MocSkipSource/qItemC.cpp
new file mode 100644
index 000000000..622f2829e
--- /dev/null
+++ b/Tests/QtAutogen/MocSkipSource/qItemC.cpp
@@ -0,0 +1,17 @@
+#include "qItemC.hpp"
+
+class QItemC_Local : public QObject
+{
+ Q_OBJECT
+public:
+ QItemC_Local(){};
+ ~QItemC_Local(){};
+};
+
+void QItemC::go()
+{
+ QItemC_Local localObject;
+}
+
+// We need AUTOMOC processing
+#include "qItemC.moc"
diff --git a/Tests/QtAutogen/skipSource/qItemC.hpp b/Tests/QtAutogen/MocSkipSource/qItemC.hpp
index f06bda269..f06bda269 100644
--- a/Tests/QtAutogen/skipSource/qItemC.hpp
+++ b/Tests/QtAutogen/MocSkipSource/qItemC.hpp
diff --git a/Tests/QtAutogen/MocSkipSource/qItemD.cpp b/Tests/QtAutogen/MocSkipSource/qItemD.cpp
new file mode 100644
index 000000000..fe0f4e4da
--- /dev/null
+++ b/Tests/QtAutogen/MocSkipSource/qItemD.cpp
@@ -0,0 +1,17 @@
+#include "qItemD.hpp"
+
+class QItemD_Local : public QObject
+{
+ Q_OBJECT
+public:
+ QItemD_Local(){};
+ ~QItemD_Local(){};
+};
+
+void QItemD::go()
+{
+ QItemD_Local localObject;
+}
+
+// We need AUTOMOC processing
+#include "qItemD.moc"
diff --git a/Tests/QtAutogen/MocSkipSource/qItemD.hpp b/Tests/QtAutogen/MocSkipSource/qItemD.hpp
new file mode 100644
index 000000000..99e0acbed
--- /dev/null
+++ b/Tests/QtAutogen/MocSkipSource/qItemD.hpp
@@ -0,0 +1,13 @@
+#ifndef QITEMD_HPP
+#define QITEMD_HPP
+
+#include <QObject>
+
+class QItemD : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocSkipSource/skipMoc.cpp b/Tests/QtAutogen/MocSkipSource/skipMoc.cpp
new file mode 100644
index 000000000..c91533410
--- /dev/null
+++ b/Tests/QtAutogen/MocSkipSource/skipMoc.cpp
@@ -0,0 +1,16 @@
+
+#include "qItemA.hpp"
+#include "qItemB.hpp"
+#include "qItemC.hpp"
+#include "qItemD.hpp"
+
+int main(int, char**)
+{
+ QItemA itemA;
+ QItemB itemB;
+ QItemC itemC;
+ QItemD itemD;
+
+ // Fails to link if the symbol is not present.
+ return 0;
+}
diff --git a/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt b/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt
new file mode 100644
index 000000000..ec204e775
--- /dev/null
+++ b/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.10)
+project(ObjectLibrary)
+include("../AutogenCoreTest.cmake")
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+set(CMAKE_AUTOMOC ON)
+
+# Object library a defined in a subdirectory
+add_subdirectory(a)
+
+# Object library b defined locally
+include_directories(b)
+add_library(b OBJECT b/classb.cpp)
+target_compile_features(b PRIVATE ${QT_COMPILE_FEATURES})
+
+# Executable with OBJECT library generator expressions
+add_executable(someProgram main.cpp $<TARGET_OBJECTS:a> $<TARGET_OBJECTS:b>)
+target_link_libraries(someProgram ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/ObjectLibrary/a/CMakeLists.txt b/Tests/QtAutogen/ObjectLibrary/a/CMakeLists.txt
new file mode 100644
index 000000000..fe76ac32c
--- /dev/null
+++ b/Tests/QtAutogen/ObjectLibrary/a/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_library(a OBJECT classa.cpp)
+target_compile_features(a PRIVATE ${QT_COMPILE_FEATURES})
diff --git a/Tests/QtAutogen/ObjectLibrary/a/classa.cpp b/Tests/QtAutogen/ObjectLibrary/a/classa.cpp
new file mode 100644
index 000000000..a548652dd
--- /dev/null
+++ b/Tests/QtAutogen/ObjectLibrary/a/classa.cpp
@@ -0,0 +1,8 @@
+#include "classa.h"
+
+#include <QDebug>
+
+void ClassA::slotDoSomething()
+{
+ qDebug() << m_member;
+}
diff --git a/Tests/QtAutogen/ObjectLibrary/a/classa.h b/Tests/QtAutogen/ObjectLibrary/a/classa.h
new file mode 100644
index 000000000..fa5fed941
--- /dev/null
+++ b/Tests/QtAutogen/ObjectLibrary/a/classa.h
@@ -0,0 +1,23 @@
+#ifndef CLASSA_H
+#define CLASSA_H
+
+#include <QObject>
+#include <QString>
+
+class ClassA : public QObject
+{
+ Q_OBJECT
+public:
+ ClassA()
+ : m_member("Hello A")
+ {
+ }
+
+public slots:
+ void slotDoSomething();
+
+private:
+ QString m_member;
+};
+
+#endif
diff --git a/Tests/QtAutogen/ObjectLibrary/b/classb.cpp b/Tests/QtAutogen/ObjectLibrary/b/classb.cpp
new file mode 100644
index 000000000..e5cc2e77e
--- /dev/null
+++ b/Tests/QtAutogen/ObjectLibrary/b/classb.cpp
@@ -0,0 +1,8 @@
+#include "classb.h"
+
+#include <QDebug>
+
+void ClassB::slotDoSomething()
+{
+ qDebug() << m_member;
+}
diff --git a/Tests/QtAutogen/ObjectLibrary/b/classb.h b/Tests/QtAutogen/ObjectLibrary/b/classb.h
new file mode 100644
index 000000000..783bb48ce
--- /dev/null
+++ b/Tests/QtAutogen/ObjectLibrary/b/classb.h
@@ -0,0 +1,23 @@
+#ifndef CLASSB_H
+#define CLASSB_H
+
+#include <QObject>
+#include <QString>
+
+class ClassB : public QObject
+{
+ Q_OBJECT
+public:
+ ClassB()
+ : m_member("Hello B")
+ {
+ }
+
+public slots:
+ void slotDoSomething();
+
+private:
+ QString m_member;
+};
+
+#endif
diff --git a/Tests/QtAutogen/ObjectLibrary/main.cpp b/Tests/QtAutogen/ObjectLibrary/main.cpp
new file mode 100644
index 000000000..cacf0fdae
--- /dev/null
+++ b/Tests/QtAutogen/ObjectLibrary/main.cpp
@@ -0,0 +1,13 @@
+#include "a/classa.h"
+#include "b/classb.h"
+
+int main(int argc, char** argv)
+{
+ ClassA a;
+ a.slotDoSomething();
+
+ ClassB b;
+ b.slotDoSomething();
+
+ return 0;
+}
diff --git a/Tests/QtAutogen/Parallel/CMakeLists.txt b/Tests/QtAutogen/Parallel/CMakeLists.txt
new file mode 100644
index 000000000..299bcbfd7
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.10)
+project(Parallel)
+include("../AutogenGuiTest.cmake")
+
+# Test different values for AUTOGEN_PARALLEL
+include("../Parallel/parallel.cmake")
+
+add_executable(parallel ${PARALLEL_SRC})
+set_target_properties(parallel PROPERTIES AUTOGEN_PARALLEL "")
+target_link_libraries(parallel ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/sameName/aaa/bbb/data.qrc b/Tests/QtAutogen/Parallel/aaa/bbb/data.qrc
index 0ea353756..0ea353756 100644
--- a/Tests/QtAutogen/sameName/aaa/bbb/data.qrc
+++ b/Tests/QtAutogen/Parallel/aaa/bbb/data.qrc
diff --git a/Tests/QtAutogen/Parallel/aaa/bbb/item.cpp b/Tests/QtAutogen/Parallel/aaa/bbb/item.cpp
new file mode 100644
index 000000000..850206f6b
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/aaa/bbb/item.cpp
@@ -0,0 +1,22 @@
+#include "item.hpp"
+
+namespace aaa {
+namespace bbb {
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ MocLocal obj;
+}
+}
+}
+
+#include "aaa/bbb/item.moc"
diff --git a/Tests/QtAutogen/sameName/aaa/bbb/item.hpp b/Tests/QtAutogen/Parallel/aaa/bbb/item.hpp
index 085504385..085504385 100644
--- a/Tests/QtAutogen/sameName/aaa/bbb/item.hpp
+++ b/Tests/QtAutogen/Parallel/aaa/bbb/item.hpp
diff --git a/Tests/QtAutogen/sameName/aaa/data.qrc b/Tests/QtAutogen/Parallel/aaa/data.qrc
index 379af60c8..379af60c8 100644
--- a/Tests/QtAutogen/sameName/aaa/data.qrc
+++ b/Tests/QtAutogen/Parallel/aaa/data.qrc
diff --git a/Tests/QtAutogen/Parallel/aaa/item.cpp b/Tests/QtAutogen/Parallel/aaa/item.cpp
new file mode 100644
index 000000000..e35d3d128
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/aaa/item.cpp
@@ -0,0 +1,22 @@
+#include "item.hpp"
+// Include ui_view.h only in header
+
+namespace aaa {
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ Ui_ViewAAA ui;
+ MocLocal obj;
+}
+}
+
+#include "aaa/item.moc"
diff --git a/Tests/QtAutogen/Parallel/aaa/item.hpp b/Tests/QtAutogen/Parallel/aaa/item.hpp
new file mode 100644
index 000000000..875f72fdb
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/aaa/item.hpp
@@ -0,0 +1,18 @@
+#ifndef AAA_ITEM_HPP
+#define AAA_ITEM_HPP
+
+#include <QObject>
+// Include ui_view.h only in header
+#include <aaa/ui_view.h>
+
+namespace aaa {
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go();
+};
+}
+
+#endif
diff --git a/Tests/QtAutogen/Parallel/aaa/view.ui b/Tests/QtAutogen/Parallel/aaa/view.ui
new file mode 100644
index 000000000..0f0998006
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/aaa/view.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ViewAAA</class>
+ <widget class="QWidget" name="Base">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/sameName/bbb/aaa/data.qrc b/Tests/QtAutogen/Parallel/bbb/aaa/data.qrc
index da980091a..da980091a 100644
--- a/Tests/QtAutogen/sameName/bbb/aaa/data.qrc
+++ b/Tests/QtAutogen/Parallel/bbb/aaa/data.qrc
diff --git a/Tests/QtAutogen/Parallel/bbb/aaa/item.cpp b/Tests/QtAutogen/Parallel/bbb/aaa/item.cpp
new file mode 100644
index 000000000..7ad01c3ef
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/bbb/aaa/item.cpp
@@ -0,0 +1,22 @@
+#include "item.hpp"
+
+namespace bbb {
+namespace aaa {
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ MocLocal obj;
+}
+}
+}
+
+#include "bbb/aaa/item.moc"
diff --git a/Tests/QtAutogen/sameName/bbb/aaa/item.hpp b/Tests/QtAutogen/Parallel/bbb/aaa/item.hpp
index be07ca84c..be07ca84c 100644
--- a/Tests/QtAutogen/sameName/bbb/aaa/item.hpp
+++ b/Tests/QtAutogen/Parallel/bbb/aaa/item.hpp
diff --git a/Tests/QtAutogen/sameName/bbb/data.qrc b/Tests/QtAutogen/Parallel/bbb/data.qrc
index 5b080f5fa..5b080f5fa 100644
--- a/Tests/QtAutogen/sameName/bbb/data.qrc
+++ b/Tests/QtAutogen/Parallel/bbb/data.qrc
diff --git a/Tests/QtAutogen/Parallel/bbb/item.cpp b/Tests/QtAutogen/Parallel/bbb/item.cpp
new file mode 100644
index 000000000..9ef128ed0
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/bbb/item.cpp
@@ -0,0 +1,23 @@
+#include "item.hpp"
+// Include ui_view.h only in source
+#include <bbb/ui_view.h>
+
+namespace bbb {
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ Ui_ViewBBB ui;
+ MocLocal obj;
+}
+}
+
+#include "bbb/item.moc"
diff --git a/Tests/QtAutogen/Parallel/bbb/item.hpp b/Tests/QtAutogen/Parallel/bbb/item.hpp
new file mode 100644
index 000000000..d39a9d711
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/bbb/item.hpp
@@ -0,0 +1,17 @@
+#ifndef BBB_ITEM_HPP
+#define BBB_ITEM_HPP
+
+#include <QObject>
+// Include ui_view.h only in source
+
+namespace bbb {
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go();
+};
+}
+
+#endif
diff --git a/Tests/QtAutogen/Parallel/bbb/view.ui b/Tests/QtAutogen/Parallel/bbb/view.ui
new file mode 100644
index 000000000..a8f506e88
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/bbb/view.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ViewBBB</class>
+ <widget class="QWidget" name="Base">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/sameName/ccc/data.qrc b/Tests/QtAutogen/Parallel/ccc/data.qrc
index f934c39b9..f934c39b9 100644
--- a/Tests/QtAutogen/sameName/ccc/data.qrc
+++ b/Tests/QtAutogen/Parallel/ccc/data.qrc
diff --git a/Tests/QtAutogen/Parallel/ccc/item.cpp b/Tests/QtAutogen/Parallel/ccc/item.cpp
new file mode 100644
index 000000000..ab8a2817b
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/ccc/item.cpp
@@ -0,0 +1,25 @@
+#include "item.hpp"
+// Include ui_view.h in source and header
+#include <ccc/ui_view.h>
+
+namespace ccc {
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ Ui_ViewCCC ui;
+ MocLocal obj;
+}
+}
+
+// Include own moc files
+#include "ccc/item.moc"
+#include "moc_item.cpp"
diff --git a/Tests/QtAutogen/Parallel/ccc/item.hpp b/Tests/QtAutogen/Parallel/ccc/item.hpp
new file mode 100644
index 000000000..20d9dd978
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/ccc/item.hpp
@@ -0,0 +1,18 @@
+#ifndef CCC_ITEM_HPP
+#define CCC_ITEM_HPP
+
+#include <QObject>
+// Include ui_view.h in source and header
+#include <ccc/ui_view.h>
+
+namespace ccc {
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go();
+};
+}
+
+#endif
diff --git a/Tests/QtAutogen/Parallel/ccc/view.ui b/Tests/QtAutogen/Parallel/ccc/view.ui
new file mode 100644
index 000000000..7989c6973
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/ccc/view.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ViewCCC</class>
+ <widget class="QWidget" name="Base">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/sameName/data.qrc b/Tests/QtAutogen/Parallel/data.qrc
index 4ce0b4ec1..4ce0b4ec1 100644
--- a/Tests/QtAutogen/sameName/data.qrc
+++ b/Tests/QtAutogen/Parallel/data.qrc
diff --git a/Tests/QtAutogen/Parallel/item.cpp b/Tests/QtAutogen/Parallel/item.cpp
new file mode 100644
index 000000000..3d1fbe7cf
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/item.cpp
@@ -0,0 +1,20 @@
+#include "item.hpp"
+// Include ui_view.h in source and header
+#include <ui_view.h>
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ Ui_View ui;
+ MocLocal obj;
+}
+
+#include "item.moc"
diff --git a/Tests/QtAutogen/Parallel/item.hpp b/Tests/QtAutogen/Parallel/item.hpp
new file mode 100644
index 000000000..75e83f483
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/item.hpp
@@ -0,0 +1,15 @@
+#ifndef ITEM_HPP
+#define ITEM_HPP
+
+#include <QObject>
+// Include ui_view.h in source and header
+#include <ui_view.h>
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go();
+};
+
+#endif
diff --git a/Tests/QtAutogen/sameName/main.cpp b/Tests/QtAutogen/Parallel/main.cpp
index a4ffcb350..a4ffcb350 100644
--- a/Tests/QtAutogen/sameName/main.cpp
+++ b/Tests/QtAutogen/Parallel/main.cpp
diff --git a/Tests/QtAutogen/Parallel/parallel.cmake b/Tests/QtAutogen/Parallel/parallel.cmake
new file mode 100644
index 000000000..551bcd82b
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/parallel.cmake
@@ -0,0 +1,24 @@
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTORCC ON)
+
+
+set(PBASE ${CMAKE_CURRENT_LIST_DIR})
+set(PARALLEL_SRC
+ ${PBASE}/aaa/bbb/item.cpp
+ ${PBASE}/aaa/bbb/data.qrc
+ ${PBASE}/aaa/item.cpp
+ ${PBASE}/aaa/data.qrc
+
+ ${PBASE}/bbb/aaa/item.cpp
+ ${PBASE}/bbb/aaa/data.qrc
+ ${PBASE}/bbb/item.cpp
+ ${PBASE}/bbb/data.qrc
+
+ ${PBASE}/ccc/item.cpp
+ ${PBASE}/ccc/data.qrc
+
+ ${PBASE}/item.cpp
+ ${PBASE}/data.qrc
+ ${PBASE}/main.cpp
+)
diff --git a/Tests/QtAutogen/Parallel/view.ui b/Tests/QtAutogen/Parallel/view.ui
new file mode 100644
index 000000000..2ffe7344c
--- /dev/null
+++ b/Tests/QtAutogen/Parallel/view.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>View</class>
+ <widget class="QWidget" name="Base">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/Parallel1/CMakeLists.txt b/Tests/QtAutogen/Parallel1/CMakeLists.txt
new file mode 100644
index 000000000..5c7d547df
--- /dev/null
+++ b/Tests/QtAutogen/Parallel1/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.10)
+project(Parallel1)
+include("../AutogenGuiTest.cmake")
+
+# Test different values for AUTOGEN_PARALLEL
+include("../Parallel/parallel.cmake")
+
+add_executable(parallel1 ${PARALLEL_SRC})
+set_target_properties(parallel1 PROPERTIES AUTOGEN_PARALLEL 1)
+target_link_libraries(parallel1 ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/Parallel2/CMakeLists.txt b/Tests/QtAutogen/Parallel2/CMakeLists.txt
new file mode 100644
index 000000000..668aea4bd
--- /dev/null
+++ b/Tests/QtAutogen/Parallel2/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.10)
+project(Parallel2)
+include("../AutogenGuiTest.cmake")
+
+# Test different values for AUTOGEN_PARALLEL
+include("../Parallel/parallel.cmake")
+
+add_executable(parallel2 ${PARALLEL_SRC})
+set_target_properties(parallel2 PROPERTIES AUTOGEN_PARALLEL 2)
+target_link_libraries(parallel2 ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/Parallel3/CMakeLists.txt b/Tests/QtAutogen/Parallel3/CMakeLists.txt
new file mode 100644
index 000000000..5c50f5ee5
--- /dev/null
+++ b/Tests/QtAutogen/Parallel3/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.10)
+project(Parallel3)
+include("../AutogenGuiTest.cmake")
+
+# Test different values for AUTOGEN_PARALLEL
+include("../Parallel/parallel.cmake")
+
+add_executable(parallel3 ${PARALLEL_SRC})
+set_target_properties(parallel3 PROPERTIES AUTOGEN_PARALLEL 3)
+target_link_libraries(parallel3 ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/Parallel4/CMakeLists.txt b/Tests/QtAutogen/Parallel4/CMakeLists.txt
new file mode 100644
index 000000000..2c40c6a67
--- /dev/null
+++ b/Tests/QtAutogen/Parallel4/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.10)
+project(Parallel4)
+include("../AutogenGuiTest.cmake")
+
+# Test different values for AUTOGEN_PARALLEL
+include("../Parallel/parallel.cmake")
+
+add_executable(parallel4 ${PARALLEL_SRC})
+set_target_properties(parallel4 PROPERTIES AUTOGEN_PARALLEL 4)
+target_link_libraries(parallel4 ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/ParallelAUTO/CMakeLists.txt b/Tests/QtAutogen/ParallelAUTO/CMakeLists.txt
new file mode 100644
index 000000000..cddece37a
--- /dev/null
+++ b/Tests/QtAutogen/ParallelAUTO/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.10)
+project(ParallelAUTO)
+include("../AutogenGuiTest.cmake")
+
+# Test different values for AUTOGEN_PARALLEL
+include("../Parallel/parallel.cmake")
+
+add_executable(parallelAUTO ${PARALLEL_SRC})
+set_target_properties(parallelAUTO PROPERTIES AUTOGEN_PARALLEL "AUTO")
+target_link_libraries(parallelAUTO ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/RccEmpty/CMakeLists.txt b/Tests/QtAutogen/RccEmpty/CMakeLists.txt
new file mode 100644
index 000000000..a8e2af1b6
--- /dev/null
+++ b/Tests/QtAutogen/RccEmpty/CMakeLists.txt
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.10)
+project(RccEmpty)
+include("../AutogenCoreTest.cmake")
+
+# Test AUTORCC on a .qrc file with no resource files
+add_executable(rccEmpty rccEmpty.cpp rccEmptyRes.qrc)
+set_property(TARGET rccEmpty PROPERTY AUTORCC ON)
+target_link_libraries(rccEmpty ${QT_QTCORE_TARGET})
diff --git a/Tests/QtAutogen/rccEmpty.cpp b/Tests/QtAutogen/RccEmpty/rccEmpty.cpp
index 7f2c52786..7f2c52786 100644
--- a/Tests/QtAutogen/rccEmpty.cpp
+++ b/Tests/QtAutogen/RccEmpty/rccEmpty.cpp
diff --git a/Tests/QtAutogen/rccEmptyRes.qrc b/Tests/QtAutogen/RccEmpty/rccEmptyRes.qrc
index 4ca9cd583..4ca9cd583 100644
--- a/Tests/QtAutogen/rccEmptyRes.qrc
+++ b/Tests/QtAutogen/RccEmpty/rccEmptyRes.qrc
diff --git a/Tests/QtAutogen/RccOffMocLibrary/CMakeLists.txt b/Tests/QtAutogen/RccOffMocLibrary/CMakeLists.txt
new file mode 100644
index 000000000..61b9601a2
--- /dev/null
+++ b/Tests/QtAutogen/RccOffMocLibrary/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.10)
+project(RccOffMocLibrary)
+include("../AutogenCoreTest.cmake")
+
+# Add not_generated_file.qrc to the source list to get the file-level
+# dependency, but don't generate a c++ file from it. Disable the AUTORCC
+# feature for this target. This tests that qrc files in the sources don't
+# have an effect on generation if AUTORCC is off.
+add_library(empty STATIC empty.cpp not_generated_file.qrc)
+set_target_properties(empty PROPERTIES AUTORCC OFF)
+set_target_properties(empty PROPERTIES AUTOMOC TRUE)
+target_link_libraries(empty no_link_language)
+add_library(no_link_language STATIC empty.h)
+set_target_properties(no_link_language PROPERTIES AUTOMOC TRUE)
+# Pass Qt compiler features to targets that don't link against Qt
+target_compile_features(no_link_language PRIVATE ${QT_COMPILE_FEATURES})
+target_compile_features(empty PRIVATE ${QT_COMPILE_FEATURES})
diff --git a/Tests/QtAutogen/empty.cpp b/Tests/QtAutogen/RccOffMocLibrary/empty.cpp
index ab32cf6c8..ab32cf6c8 100644
--- a/Tests/QtAutogen/empty.cpp
+++ b/Tests/QtAutogen/RccOffMocLibrary/empty.cpp
diff --git a/Tests/QtAutogen/empty.h b/Tests/QtAutogen/RccOffMocLibrary/empty.h
index 6bdd2ac89..6bdd2ac89 100644
--- a/Tests/QtAutogen/empty.h
+++ b/Tests/QtAutogen/RccOffMocLibrary/empty.h
diff --git a/Tests/QtAutogen/not_generated_file.qrc b/Tests/QtAutogen/RccOffMocLibrary/not_generated_file.qrc
index c7698343a..c7698343a 100644
--- a/Tests/QtAutogen/not_generated_file.qrc
+++ b/Tests/QtAutogen/RccOffMocLibrary/not_generated_file.qrc
diff --git a/Tests/QtAutogen/RccOnly/CMakeLists.txt b/Tests/QtAutogen/RccOnly/CMakeLists.txt
new file mode 100644
index 000000000..f3776f575
--- /dev/null
+++ b/Tests/QtAutogen/RccOnly/CMakeLists.txt
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.10)
+project(RccOnly)
+include("../AutogenCoreTest.cmake")
+
+# Test AUTORCC being enabled only
+add_executable(rccOnly rccOnly.cpp rccOnlyRes.qrc)
+set_property(TARGET rccOnly PROPERTY AUTORCC ON)
+target_link_libraries(rccOnly ${QT_QTCORE_TARGET})
diff --git a/Tests/QtAutogen/rccOnly.cpp b/Tests/QtAutogen/RccOnly/rccOnly.cpp
index 61c7bf4ed..61c7bf4ed 100644
--- a/Tests/QtAutogen/rccOnly.cpp
+++ b/Tests/QtAutogen/RccOnly/rccOnly.cpp
diff --git a/Tests/QtAutogen/rccOnlyRes.qrc b/Tests/QtAutogen/RccOnly/rccOnlyRes.qrc
index 555134877..555134877 100644
--- a/Tests/QtAutogen/rccOnlyRes.qrc
+++ b/Tests/QtAutogen/RccOnly/rccOnlyRes.qrc
diff --git a/Tests/QtAutogen/RccSkipSource/CMakeLists.txt b/Tests/QtAutogen/RccSkipSource/CMakeLists.txt
new file mode 100644
index 000000000..42232744f
--- /dev/null
+++ b/Tests/QtAutogen/RccSkipSource/CMakeLists.txt
@@ -0,0 +1,23 @@
+cmake_minimum_required(VERSION 3.10)
+project(RccSkipSource)
+include("../AutogenCoreTest.cmake")
+
+# Test for SKIP_AUTORCC and SKIP_AUTOGEN on an AUTORCC enabled target
+set(skipRccSources
+ skipRcc.cpp
+ skipRccBad1.qrc
+ skipRccBad2.qrc
+ skipRccGood.qrc
+)
+set_property(SOURCE skipRccBad1.qrc PROPERTY SKIP_AUTORCC ON)
+set_property(SOURCE skipRccBad2.qrc PROPERTY SKIP_AUTOGEN ON)
+# AUTORCC enabled
+add_executable(skipRccA ${skipRccSources})
+set_property(TARGET skipRccA PROPERTY AUTORCC ON)
+target_link_libraries(skipRccA ${QT_LIBRARIES})
+# AUTORCC, AUTOUIC and AUTOMOC enabled
+add_executable(skipRccB ${skipRccSources})
+set_property(TARGET skipRccB PROPERTY AUTORCC ON)
+set_property(TARGET skipRccB PROPERTY AUTOUIC ON)
+set_property(TARGET skipRccB PROPERTY AUTOMOC ON)
+target_link_libraries(skipRccB ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/skipRcc.cpp b/Tests/QtAutogen/RccSkipSource/skipRcc.cpp
index ec5711088..ec5711088 100644
--- a/Tests/QtAutogen/skipRcc.cpp
+++ b/Tests/QtAutogen/RccSkipSource/skipRcc.cpp
diff --git a/Tests/QtAutogen/skipSource/skipRccBad1.qrc b/Tests/QtAutogen/RccSkipSource/skipRccBad1.qrc
index 6cbd9ed18..6cbd9ed18 100644
--- a/Tests/QtAutogen/skipSource/skipRccBad1.qrc
+++ b/Tests/QtAutogen/RccSkipSource/skipRccBad1.qrc
diff --git a/Tests/QtAutogen/skipSource/skipRccBad2.qrc b/Tests/QtAutogen/RccSkipSource/skipRccBad2.qrc
index b32c5896c..b32c5896c 100644
--- a/Tests/QtAutogen/skipSource/skipRccBad2.qrc
+++ b/Tests/QtAutogen/RccSkipSource/skipRccBad2.qrc
diff --git a/Tests/QtAutogen/skipSource/skipRccGood.qrc b/Tests/QtAutogen/RccSkipSource/skipRccGood.qrc
index 21a94b0c5..21a94b0c5 100644
--- a/Tests/QtAutogen/skipSource/skipRccGood.qrc
+++ b/Tests/QtAutogen/RccSkipSource/skipRccGood.qrc
diff --git a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt
new file mode 100644
index 000000000..9b32e5951
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt
@@ -0,0 +1,102 @@
+cmake_minimum_required(VERSION 3.10)
+project(RerunMocBasic)
+include("../AutogenCoreTest.cmake")
+
+# Dummy executable to generate a clean target
+add_executable(dummy dummy.cpp)
+
+# Utility variables
+set(timeformat "%Y.%j.%H.%M%S")
+set(mocBasicSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocBasic")
+set(mocBasicBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocBasic")
+
+# Utility macros
+macro(sleep)
+ message(STATUS "Sleeping for a few seconds.")
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+endmacro()
+
+macro(acquire_timestamp When)
+ file(TIMESTAMP "${mocBasicBin}" time${When} "${timeformat}")
+endmacro()
+
+macro(rebuild buildName)
+ message(STATUS "Starting build ${buildName}.")
+ execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result)
+ if (result)
+ message(FATAL_ERROR "Build ${buildName} failed.")
+ else()
+ message(STATUS "Build ${buildName} finished.")
+ endif()
+endmacro()
+
+macro(require_change)
+ if (timeAfter VERSION_GREATER timeBefore)
+ message(STATUS "As expected the file ${mocBasicBin} changed.")
+ else()
+ message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} did not change!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n")
+ endif()
+endmacro()
+
+macro(require_change_not)
+ if (timeAfter VERSION_GREATER timeBefore)
+ message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} changed!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n")
+ else()
+ message(STATUS "As expected the file ${mocBasicBin} did not change.")
+ endif()
+endmacro()
+
+
+# Initial build
+configure_file("${mocBasicSrcDir}/test1a.h.in" "${mocBasicBinDir}/test1.h" COPYONLY)
+try_compile(MOC_RERUN
+ "${mocBasicBinDir}"
+ "${mocBasicSrcDir}"
+ MocBasic
+ CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+ "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
+ "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+ OUTPUT_VARIABLE output
+)
+if (NOT MOC_RERUN)
+ message(FATAL_ERROR "Initial build of mocBasic failed. Output: ${output}")
+endif()
+
+# Get name of the output binary
+file(STRINGS "${mocBasicBinDir}/mocBasic.txt" mocBasicList ENCODING UTF-8)
+list(GET mocBasicList 0 mocBasicBin)
+
+# To avoid a race condition where the binary has the same timestamp
+# as a source file and therefore gets rebuild
+# - sleep to ensure a timestamp change
+# - touch binary to ensure it has a new timestamp
+acquire_timestamp(Before)
+sleep()
+message(STATUS "Touching binary file to ensure a new timestamps")
+file(TOUCH_NOCREATE "${mocBasicBin}")
+acquire_timestamp(After)
+require_change()
+
+
+# - Ensure that the timestamp will change
+# - Change header file content
+# - Rebuild
+acquire_timestamp(Before)
+sleep()
+message(STATUS "Changing the header content for a MOC re-run")
+configure_file("${mocBasicSrcDir}/test1b.h.in" "${mocBasicBinDir}/test1.h" COPYONLY)
+sleep()
+rebuild(2)
+acquire_timestamp(After)
+require_change()
+
+
+# - Ensure that the timestamp would change
+# - Change nothing
+# - Rebuild
+acquire_timestamp(Before)
+sleep()
+message(STATUS "Changing nothing for no MOC re-run")
+rebuild(3)
+acquire_timestamp(After)
+require_change_not()
diff --git a/Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt b/Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt
new file mode 100644
index 000000000..6a9f5507c
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt
@@ -0,0 +1,24 @@
+cmake_minimum_required(VERSION 3.10)
+project(MocBasic)
+include("../../AutogenCoreTest.cmake")
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+
+# Generated source file
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
+ COMMAND ${CMAKE_COMMAND} -E sleep 2
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
+)
+
+add_executable(mocBasic
+ ${CMAKE_CURRENT_BINARY_DIR}/test1.h
+ ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
+ res1.qrc
+)
+target_include_directories(mocBasic PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+target_link_libraries(mocBasic ${QT_QTCORE_TARGET})
+# Write target name to text file
+add_custom_command(TARGET mocBasic POST_BUILD COMMAND
+ ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:mocBasic>" > mocBasic.txt
+)
diff --git a/Tests/QtAutogen/mocRerun/input.txt b/Tests/QtAutogen/RerunMocBasic/MocBasic/input.txt
index da627624b..da627624b 100644
--- a/Tests/QtAutogen/mocRerun/input.txt
+++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/input.txt
diff --git a/Tests/QtAutogen/RerunMocBasic/MocBasic/main.cpp.in b/Tests/QtAutogen/RerunMocBasic/MocBasic/main.cpp.in
new file mode 100644
index 000000000..9d7ea37ae
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/main.cpp.in
@@ -0,0 +1,23 @@
+#include "test1.h"
+
+extern int qInitResources_res1();
+
+class Test2 : public QObject
+{
+ Q_OBJECT
+public slots:
+ void onTst1() {}
+};
+
+int main()
+{
+ // Fails to link if the rcc generated symbol is not present.
+ qInitResources_res1();
+
+ Test1 test1;
+ Test2 test2;
+
+ return 0;
+}
+
+#include "main.moc"
diff --git a/Tests/QtAutogen/mocRerun/res1.qrc b/Tests/QtAutogen/RerunMocBasic/MocBasic/res1.qrc
index fb804b5ec..fb804b5ec 100644
--- a/Tests/QtAutogen/mocRerun/res1.qrc
+++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/res1.qrc
diff --git a/Tests/QtAutogen/mocRerun/test1a.h.in b/Tests/QtAutogen/RerunMocBasic/MocBasic/test1a.h.in
index a335046ba..a335046ba 100644
--- a/Tests/QtAutogen/mocRerun/test1a.h.in
+++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/test1a.h.in
diff --git a/Tests/QtAutogen/mocRerun/test1b.h.in b/Tests/QtAutogen/RerunMocBasic/MocBasic/test1b.h.in
index 6128eeba1..6128eeba1 100644
--- a/Tests/QtAutogen/mocRerun/test1b.h.in
+++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/test1b.h.in
diff --git a/Tests/QtAutogen/RerunMocBasic/dummy.cpp b/Tests/QtAutogen/RerunMocBasic/dummy.cpp
new file mode 100644
index 000000000..4837a76b8
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocBasic/dummy.cpp
@@ -0,0 +1,5 @@
+
+int main(int argv, char** args)
+{
+ return 0;
+}
diff --git a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt
new file mode 100644
index 000000000..e1951f1d0
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt
@@ -0,0 +1,134 @@
+cmake_minimum_required(VERSION 3.10)
+project(RerunMocPlugin)
+include("../AutogenCoreTest.cmake")
+
+# Tests Q_PLUGIN_METADATA and CMAKE_AUTOMOC_DEPEND_FILTERS
+# json file change detection
+
+# Dummy executable to generate a clean target
+add_executable(dummy dummy.cpp)
+
+# Utility variables
+set(timeformat "%Y.%j.%H.%M%S")
+set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocPlugin")
+set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocPlugin")
+
+# Utility macros
+macro(sleep)
+ message(STATUS "Sleeping for a few seconds.")
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+endmacro()
+
+macro(rebuild buildName)
+ message(STATUS "Starting build ${buildName}.")
+ execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}" RESULT_VARIABLE result)
+ if (result)
+ message(FATAL_ERROR "Build ${buildName} failed.")
+ else()
+ message(STATUS "Build ${buildName} finished.")
+ endif()
+endmacro()
+
+macro(require_change PLG)
+ if (pl${PLG}After VERSION_GREATER pl${PLG}Before)
+ message(STATUS "As expected the file ${pl${PLG}File} changed.")
+ else()
+ message(SEND_ERROR
+ "Unexpectedly the file ${pl${PLG}File} did not change!\nTimestamp pre: ${pl${PLG}Before}\nTimestamp aft: ${pl${PLG}After}\n")
+ endif()
+endmacro()
+
+macro(require_change_not PLG)
+ if (pl${PLG}After VERSION_GREATER pl${PLG}Before)
+ message(SEND_ERROR
+ "Unexpectedly the file ${pl${PLG}File} changed!\nTimestamp pre: ${pl${PLG}Before}\nTimestamp aft: ${pl${PLG}After}\n")
+ else()
+ message(STATUS "As expected the file ${pl${PLG}File} did not change.")
+ endif()
+endmacro()
+
+macro(acquire_timestamps When)
+ file(TIMESTAMP "${plAFile}" plA${When} "${timeformat}")
+ file(TIMESTAMP "${plBFile}" plB${When} "${timeformat}")
+ file(TIMESTAMP "${plCFile}" plC${When} "${timeformat}")
+ file(TIMESTAMP "${plDFile}" plD${When} "${timeformat}")
+ file(TIMESTAMP "${plEFile}" plE${When} "${timeformat}")
+endmacro()
+
+
+# Initial build
+try_compile(MOC_PLUGIN
+ "${mocPlugBinDir}"
+ "${mocPlugSrcDir}"
+ MocPlugin
+ CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+ "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
+ "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+ OUTPUT_VARIABLE output
+)
+if (NOT MOC_PLUGIN)
+ message(FATAL_ERROR "Initial build of mocPlugin failed. Output: ${output}")
+endif()
+
+# Get names of the output binaries
+find_library(plAFile "PlugA" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
+find_library(plBFile "PlugB" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
+find_library(plCFile "PlugC" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
+find_library(plDFile "PlugD" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
+find_library(plEFile "PlugE" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH)
+
+# To avoid a race condition where the library has the same timestamp
+# as a source file and therefore gets rebuild
+# - sleep to ensure a timestamp change
+# - rebuild library to ensure it has a new timestamp
+sleep()
+message(STATUS "Rebuilding library files to ensure new timestamps")
+rebuild(1)
+
+
+# - Ensure that the timestamp will change.
+# - Change the json files referenced by Q_PLUGIN_METADATA
+# - Rebuild
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Changing json files.")
+configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json")
+configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json")
+configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/StyleE.json")
+sleep()
+rebuild(2)
+acquire_timestamps(After)
+# Test changes
+require_change_not(A)
+require_change_not(B)
+require_change(C)
+require_change(D)
+# There's a bug in Ninja on Windows:
+# https://gitlab.kitware.com/cmake/cmake/issues/16776
+if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja"))
+ require_change(E)
+endif()
+
+
+# - Ensure that the timestamp will change.
+# - Change the json files referenced by A_CUSTOM_MACRO
+# - Rebuild
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Changing json files")
+configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json")
+configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json")
+configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleE_Custom.json")
+sleep()
+rebuild(3)
+acquire_timestamps(After)
+# Test changes
+require_change_not(A)
+require_change_not(B)
+require_change(C)
+require_change(D)
+# There's a bug in Ninja on Windows
+# https://gitlab.kitware.com/cmake/cmake/issues/16776
+if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja"))
+ require_change(E)
+endif()
diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt
new file mode 100644
index 000000000..506828976
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt
@@ -0,0 +1,31 @@
+cmake_minimum_required(VERSION 3.10)
+project(MocPlugin)
+include("../../AutogenGuiTest.cmake")
+
+if (QT_TEST_VERSION LESS 5)
+ message(SEND_ERROR "Qt 5 or higher required.")
+endif()
+
+set(CMAKE_AUTOMOC_DEPEND_FILTERS
+ "A_CUSTOM_MACRO"
+ "[\n][ \t]*A_CUSTOM_MACRO[ \t\r\n]*\\([^,]+,[ \t\r\n]*\"([^\"]+)\""
+)
+
+configure_file(jsonIn/StyleC.json jsonFiles/StyleC.json)
+configure_file(jsonIn/StyleC.json jsonFiles/StyleC_Custom.json)
+configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD.json)
+configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD_Custom.json)
+configure_file(jsonIn/StyleE.json jsonFiles/StyleE.json)
+configure_file(jsonIn/StyleE.json jsonFiles/StyleE_Custom.json)
+
+# Enable AUTOMOC
+set(CMAKE_AUTOMOC TRUE)
+
+include_directories("${CMAKE_CURRENT_BINARY_DIR}/jsonFiles")
+link_libraries(Qt5::Widgets)
+
+add_library(PlugA STATIC StyleA.cpp)
+add_library(PlugB STATIC StyleB.cpp)
+add_library(PlugC STATIC StyleC.cpp)
+add_library(PlugD STATIC StyleD.cpp)
+add_library(PlugE STATIC StyleE.cpp)
diff --git a/Tests/QtAutogen/mocPlugin/StyleA.cpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.cpp
index b5e87533c..b5e87533c 100644
--- a/Tests/QtAutogen/mocPlugin/StyleA.cpp
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.cpp
diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.hpp
new file mode 100644
index 000000000..e1fdf0bbd
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.hpp
@@ -0,0 +1,18 @@
+#ifndef STYLEA_HPP
+#define STYLEA_HPP
+
+#include <QStylePlugin>
+
+#include "UtilityMacros.hpp"
+
+class StyleA : public QStylePlugin
+{
+ Q_OBJECT
+ // Json file in source local directory
+ Q_PLUGIN_METADATA(IID "org.styles.A" FILE "StyleA.json")
+ A_CUSTOM_MACRO(SomeArg, "StyleA_Custom.json", AnotherArg)
+public:
+ QStyle* create(const QString& key);
+};
+
+#endif
diff --git a/Tests/QtAutogen/mocPlugin/StyleA.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.json
index cc3395369..cc3395369 100644
--- a/Tests/QtAutogen/mocPlugin/StyleA.json
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA.json
diff --git a/Tests/QtAutogen/mocPlugin/StyleA_Custom.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA_Custom.json
index cc3395369..cc3395369 100644
--- a/Tests/QtAutogen/mocPlugin/StyleA_Custom.json
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleA_Custom.json
diff --git a/Tests/QtAutogen/mocPlugin/StyleB.cpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.cpp
index 17d440035..17d440035 100644
--- a/Tests/QtAutogen/mocPlugin/StyleB.cpp
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.cpp
diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.hpp
new file mode 100644
index 000000000..7550d0c3b
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleB.hpp
@@ -0,0 +1,18 @@
+#ifndef STYLEB_HPP
+#define STYLEB_HPP
+
+#include <QStylePlugin>
+
+#include "UtilityMacros.hpp"
+
+class StyleB : public QStylePlugin
+{
+ Q_OBJECT
+ // Json file in source local subdirectory
+ Q_PLUGIN_METADATA(IID "org.styles.B" FILE "jsonIn/StyleB.json")
+ A_CUSTOM_MACRO(SomeArg, "jsonIn/StyleB_Custom.json", AnotherArg)
+public:
+ QStyle* create(const QString& key);
+};
+
+#endif
diff --git a/Tests/QtAutogen/mocPlugin/StyleC.cpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.cpp
index 37e756487..37e756487 100644
--- a/Tests/QtAutogen/mocPlugin/StyleC.cpp
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.cpp
diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.hpp
new file mode 100644
index 000000000..ec71becda
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleC.hpp
@@ -0,0 +1,18 @@
+#ifndef STYLEC_HPP
+#define STYLEC_HPP
+
+#include <QStylePlugin>
+
+#include "UtilityMacros.hpp"
+
+class StyleC : public QStylePlugin
+{
+ Q_OBJECT
+ // Json file in global root directory
+ Q_PLUGIN_METADATA(IID "org.styles.C" FILE "StyleC.json")
+ A_CUSTOM_MACRO(SomeArg, "StyleC_Custom.json", AnotherArg)
+public:
+ QStyle* create(const QString& key);
+};
+
+#endif
diff --git a/Tests/QtAutogen/mocPlugin/StyleD.cpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.cpp
index 7e4b121fc..7e4b121fc 100644
--- a/Tests/QtAutogen/mocPlugin/StyleD.cpp
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.cpp
diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.hpp
new file mode 100644
index 000000000..3c093b914
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleD.hpp
@@ -0,0 +1,18 @@
+#ifndef STYLED_HPP
+#define STYLED_HPP
+
+#include <QStylePlugin>
+
+#include "UtilityMacros.hpp"
+
+class StyleD : public QStylePlugin
+{
+ Q_OBJECT
+ // Json file in global sub director
+ Q_PLUGIN_METADATA(IID "org.styles.D" FILE "sub/StyleD.json")
+ A_CUSTOM_MACRO(SomeArg, "sub/StyleD_Custom.json", AnotherArg)
+public:
+ QStyle* create(const QString& key);
+};
+
+#endif
diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleE.cpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleE.cpp
new file mode 100644
index 000000000..344831969
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleE.cpp
@@ -0,0 +1,9 @@
+#include "StyleE.hpp"
+
+QStyle* StyleE::create(const QString& key)
+{
+ return 0;
+}
+
+// AUTOMOC the StyleEInclude.hpp header
+#include "moc_StyleEInclude.cpp"
diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleE.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleE.hpp
new file mode 100644
index 000000000..a0690343d
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleE.hpp
@@ -0,0 +1,10 @@
+#ifndef STYLEE_HPP
+#define STYLEE_HPP
+
+// The included file is not in the sources list and won't be detected by
+// AUTOMOC source file with the same base name.
+// It is registered to AUTOMOCed via a moc_<NAME>.cpp include in StyleE.cpp
+// though.
+#include "StyleEInclude.hpp"
+
+#endif
diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleEInclude.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleEInclude.hpp
new file mode 100644
index 000000000..5f10fb4a0
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/StyleEInclude.hpp
@@ -0,0 +1,18 @@
+#ifndef STYLEE_INCLUDE_HPP
+#define STYLEE_INCLUDE_HPP
+
+#include <QStylePlugin>
+
+#include "UtilityMacros.hpp"
+
+class StyleE : public QStylePlugin
+{
+ Q_OBJECT
+ // Json files in global root directory
+ Q_PLUGIN_METADATA(IID "org.styles.E" FILE "StyleE.json")
+ A_CUSTOM_MACRO(SomeArg, "StyleE_Custom.json", AnotherArg)
+public:
+ QStyle* create(const QString& key);
+};
+
+#endif
diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/UtilityMacros.hpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/UtilityMacros.hpp
new file mode 100644
index 000000000..53a4284ee
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/UtilityMacros.hpp
@@ -0,0 +1,7 @@
+#ifndef UTILITYMACROS_HPP
+#define UTILITYMACROS_HPP
+
+// Empty test macro definition
+#define A_CUSTOM_MACRO(name, jsonFile, pluginRegistrations)
+
+#endif
diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleB.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleB.json
new file mode 100644
index 000000000..cd155dc0e
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleB.json
@@ -0,0 +1 @@
+{ "Keys": [ "Red", "Green" ] }
diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB_Custom.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleB_Custom.json
index 129cac41f..129cac41f 100644
--- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB_Custom.json
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleB_Custom.json
diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleC.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleC.json
index 119aaa4b7..119aaa4b7 100644
--- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleC.json
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleC.json
diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleD.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleD.json
index 732c547ab..732c547ab 100644
--- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleD.json
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleD.json
diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleE.json b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleE.json
new file mode 100644
index 000000000..5412c94f6
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/jsonIn/StyleE.json
@@ -0,0 +1 @@
+{ "Keys": [ "Floor", "Ceiling" ] }
diff --git a/Tests/QtAutogen/mocPlugin/main.cpp b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/main.cpp
index 3ba2ddc6d..3ba2ddc6d 100644
--- a/Tests/QtAutogen/mocPlugin/main.cpp
+++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/main.cpp
diff --git a/Tests/QtAutogen/RerunMocPlugin/dummy.cpp b/Tests/QtAutogen/RerunMocPlugin/dummy.cpp
new file mode 100644
index 000000000..4837a76b8
--- /dev/null
+++ b/Tests/QtAutogen/RerunMocPlugin/dummy.cpp
@@ -0,0 +1,5 @@
+
+int main(int argv, char** args)
+{
+ return 0;
+}
diff --git a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt
new file mode 100644
index 000000000..33c01acbe
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt
@@ -0,0 +1,47 @@
+cmake_minimum_required(VERSION 3.11.2)
+project(RerunRccConfigChange)
+include("../AutogenCoreTest.cmake")
+
+# Tests rcc rebuilding after a configuration change
+
+# Dummy executable to generate a clean target
+add_executable(dummy dummy.cpp)
+
+# When a .qrc or a file listed in a .qrc file changes,
+# the target must be rebuilt
+set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccConfigChange")
+set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccConfigChange")
+
+# Rebuild macro
+macro(rebuild CFG)
+ message(STATUS "Rebuilding rccConfigChange in ${CFG} configuration.")
+ execute_process(
+ COMMAND "${CMAKE_COMMAND}" --build . --config "${CFG}"
+ WORKING_DIRECTORY "${rccDepBD}"
+ RESULT_VARIABLE result)
+ if (result)
+ message(FATAL_ERROR "${CFG} build of rccConfigChange failed.")
+ else()
+ message(STATUS "${CFG} build of rccConfigChange finished.")
+ endif()
+endmacro()
+
+# Initial build
+try_compile(RCC_DEPENDS
+ "${rccDepBD}"
+ "${rccDepSD}"
+ RccConfigChange
+ CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+ "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
+ "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+ OUTPUT_VARIABLE output
+)
+if (NOT RCC_DEPENDS)
+ message(FATAL_ERROR "Initial build of rccConfigChange failed. Output: ${output}")
+endif()
+
+# Rebuild: Release
+rebuild(Release)
+
+# Rebuild: Debug
+rebuild(Debug)
diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt
new file mode 100644
index 000000000..e2dd0ac38
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt
@@ -0,0 +1,26 @@
+cmake_minimum_required(VERSION 3.11.2)
+project(RccConfigChange)
+include("../../AutogenCoreTest.cmake")
+
+# Enable AUTORCC for all targets
+set(CMAKE_AUTORCC ON)
+
+# Initial resource files setup
+configure_file(resGen/input1.txt.in resGen/input1.txt COPYONLY)
+configure_file(resGen/input2.txt.in resGen/input2.txt COPYONLY)
+configure_file(resGen.qrc.in resGen.qrc COPYONLY)
+
+# Generated qrc file with dependency
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/resGen.qrc.in
+ COMMAND ${CMAKE_COMMAND} -E sleep 2
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resGen.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc
+)
+
+# Target that uses a plain .qrc file
+add_executable(rccConfigChangePlain main.cpp resPlain.qrc)
+target_link_libraries(rccConfigChangePlain ${QT_QTCORE_TARGET})
+
+# Target that uses a GENERATED .qrc file
+add_executable(rccConfigChangeGen main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc )
+target_link_libraries(rccConfigChangeGen ${QT_QTCORE_TARGET})
diff --git a/Tests/QtAutogen/rccDepends/main.cpp b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/main.cpp
index 766b7751b..766b7751b 100644
--- a/Tests/QtAutogen/rccDepends/main.cpp
+++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/main.cpp
diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen.qrc.in b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen.qrc.in
new file mode 100644
index 000000000..967477252
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen.qrc.in
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/TextsGenerated">
+ <file>resGen/input1.txt</file>
+ <file>resGen/input2.txt</file>
+ </qresource>
+</RCC>
diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input1.txt.in b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input1.txt.in
new file mode 100644
index 000000000..4f24589b0
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input1.txt.in
@@ -0,0 +1 @@
+Generated resource input.
diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input2.txt.in b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input2.txt.in
new file mode 100644
index 000000000..4f24589b0
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resGen/input2.txt.in
@@ -0,0 +1 @@
+Generated resource input.
diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain.qrc b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain.qrc
new file mode 100644
index 000000000..e448726a0
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/TextsPlain">
+ <file>resPlain/input1.txt</file>
+ <file>resPlain/input2.txt</file>
+ </qresource>
+</RCC>
diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input1.txt b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input1.txt
new file mode 100644
index 000000000..03969c6a5
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input1.txt
@@ -0,0 +1 @@
+Plain resource input.
diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input2.txt b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input2.txt
new file mode 100644
index 000000000..03969c6a5
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/resPlain/input2.txt
@@ -0,0 +1 @@
+Plain resource input.
diff --git a/Tests/QtAutogen/RerunRccConfigChange/dummy.cpp b/Tests/QtAutogen/RerunRccConfigChange/dummy.cpp
new file mode 100644
index 000000000..4837a76b8
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccConfigChange/dummy.cpp
@@ -0,0 +1,5 @@
+
+int main(int argv, char** args)
+{
+ return 0;
+}
diff --git a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt
new file mode 100644
index 000000000..1301550f2
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt
@@ -0,0 +1,153 @@
+cmake_minimum_required(VERSION 3.10)
+project(RerunRccDepends)
+include("../AutogenCoreTest.cmake")
+
+# Tests rcc rebuilding when a resource file changes
+# When a .qrc or a file listed in a .qrc file changes,
+# the target must be rebuilt
+
+# Dummy executable to generate a clean target
+add_executable(dummy dummy.cpp)
+
+# Utility variables
+set(timeformat "%Y.%j.%H.%M%S")
+set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccDepends")
+set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccDepends")
+
+# Utility macros
+macro(sleep)
+ message(STATUS "Sleeping for a few seconds.")
+ execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
+endmacro()
+
+macro(acquire_timestamps When)
+ file(TIMESTAMP "${rccDepBinPlain}" rdPlain${When} "${timeformat}")
+ file(TIMESTAMP "${rccDepBinGenerated}" rdGenerated${When} "${timeformat}")
+endmacro()
+
+macro(rebuild buildName)
+ message(STATUS "Starting build ${buildName} of rccDepends.")
+ execute_process(
+ COMMAND "${CMAKE_COMMAND}" --build .
+ WORKING_DIRECTORY "${rccDepBD}"
+ RESULT_VARIABLE result)
+ if (result)
+ message(FATAL_ERROR "Build ${buildName} of rccDepends failed.")
+ else()
+ message(STATUS "Build ${buildName} of rccDepends finished.")
+ endif()
+endmacro()
+
+macro(require_change type)
+ if (rd${type}After VERSION_GREATER rd${type}Before)
+ message(STATUS "As expected the ${type} .qrc file ${rccDepBin${type}} changed.")
+ else()
+ message(SEND_ERROR "Unexpectedly the ${type} .qrc file ${rccDepBin${type}} did not change!\nTimestamp pre: ${rd${type}Before}\nTimestamp aft: ${rd${type}After}\n")
+ endif()
+endmacro()
+
+macro(require_change_not type)
+ if (rd${type}After VERSION_GREATER rd${type}Before)
+ message(SEND_ERROR "Unexpectedly the ${type} .qrc file ${rccDepBin${type}} changed!\nTimestamp pre: ${rd${type}Before}\nTimestamp aft: ${rd${type}After}\n")
+ else()
+ message(STATUS "As expected the ${type} .qrc file ${rccDepBin${type}} did not change.")
+ endif()
+endmacro()
+
+
+# Initial configuration
+configure_file(${rccDepSD}/resPlainA.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY)
+configure_file(${rccDepSD}/resGenA.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY)
+
+# Initial build
+try_compile(RCC_DEPENDS
+ "${rccDepBD}"
+ "${rccDepSD}"
+ RccDepends
+ CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+ "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
+ "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+ OUTPUT_VARIABLE output
+)
+if (NOT RCC_DEPENDS)
+ message(FATAL_ERROR "Initial build of rccDepends failed. Output: ${output}")
+endif()
+
+# Get name of the output binaries
+file(STRINGS "${rccDepBD}/targetPlain.txt" targetListPlain ENCODING UTF-8)
+file(STRINGS "${rccDepBD}/targetGen.txt" targetListGen ENCODING UTF-8)
+list(GET targetListPlain 0 rccDepBinPlain)
+list(GET targetListGen 0 rccDepBinGenerated)
+message(STATUS "Target that uses a plain .qrc file is:\n ${rccDepBinPlain}")
+message(STATUS "Target that uses a GENERATED .qrc file is:\n ${rccDepBinGenerated}")
+
+# To avoid a race condition where the binary has the same timestamp
+# as a source file and therefore gets rebuild
+# - sleep to ensure a timestamp change
+# - touch binary to ensure it has a new timestamp
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Touching binary files to ensure new timestamps")
+file(TOUCH_NOCREATE "${rccDepBinPlain}" "${rccDepBinGenerated}")
+acquire_timestamps(After)
+require_change(Plain)
+require_change(Generated)
+
+
+# - Ensure that the timestamp will change
+# - Change a resource files listed in the .qrc file
+# - Rebuild
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Changing a resource file listed in the .qrc file")
+file(TOUCH "${rccDepBD}/resPlain/input.txt" "${rccDepBD}/resGen/input.txt")
+sleep()
+rebuild(2)
+acquire_timestamps(After)
+# - Test if timestamps changed
+require_change(Plain)
+require_change(Generated)
+
+
+# - Ensure that the timestamp will change
+# - Change the .qrc file
+# - Rebuild
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Changing the .qrc file")
+configure_file(${rccDepSD}/resPlainB.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY)
+configure_file(${rccDepSD}/resGenB.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY)
+sleep()
+rebuild(3)
+acquire_timestamps(After)
+# - Test if timestamps changed
+require_change(Plain)
+require_change(Generated)
+
+
+# - Ensure that the timestamp will change
+# - Change a newly added resource files listed in the .qrc file
+# - Rebuild
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Changing a newly added resource file listed in the .qrc file")
+file(TOUCH "${rccDepBD}/resPlain/inputAdded.txt" "${rccDepBD}/resGen/inputAdded.txt")
+sleep()
+rebuild(4)
+acquire_timestamps(After)
+# - Test if timestamps changed
+require_change(Plain)
+require_change(Generated)
+
+
+# - Ensure that the timestamp will change
+# - Change nothing
+# - Rebuild
+acquire_timestamps(Before)
+sleep()
+message(STATUS "Changing nothing in the .qrc file")
+rebuild(5)
+acquire_timestamps(After)
+# - Test if timestamps changed
+require_change_not(Plain)
+require_change_not(Generated)
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt
new file mode 100644
index 000000000..150f849b3
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt
@@ -0,0 +1,33 @@
+cmake_minimum_required(VERSION 3.10)
+project(RccDepends)
+include("../../AutogenCoreTest.cmake")
+
+# Enable AUTORCC for all targets
+set(CMAKE_AUTORCC ON)
+
+# Initial resource files setup
+configure_file(resPlain/input.txt.in resPlain/input.txt COPYONLY)
+configure_file(resPlain/input.txt.in resPlain/inputAdded.txt COPYONLY)
+configure_file(resGen/input.txt.in resGen/input.txt COPYONLY)
+configure_file(resGen/input.txt.in resGen/inputAdded.txt COPYONLY)
+
+# Generated qrc file with dependency
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc.in
+ COMMAND ${CMAKE_COMMAND} -E sleep 2
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc
+)
+
+# Target that uses a plain .qrc file
+add_executable(rccDependsPlain main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resPlain.qrc)
+target_link_libraries(rccDependsPlain ${QT_QTCORE_TARGET})
+add_custom_command(TARGET rccDependsPlain POST_BUILD COMMAND
+ ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDependsPlain>" > targetPlain.txt
+)
+
+# Target that uses a GENERATED .qrc file
+add_executable(rccDependsGen main.cpp ${CMAKE_CURRENT_BINARY_DIR}/resGen.qrc )
+target_link_libraries(rccDependsGen ${QT_QTCORE_TARGET})
+add_custom_command(TARGET rccDependsGen POST_BUILD COMMAND
+ ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDependsGen>" > targetGen.txt
+)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp b/Tests/QtAutogen/RerunRccDepends/RccDepends/main.cpp
index 766b7751b..766b7751b 100644
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/main.cpp
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/main.cpp
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/input.txt.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/input.txt.in
new file mode 100644
index 000000000..4f24589b0
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/input.txt.in
@@ -0,0 +1 @@
+Generated resource input.
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/inputAdded.txt.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/inputAdded.txt.in
new file mode 100644
index 000000000..4f24589b0
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGen/inputAdded.txt.in
@@ -0,0 +1 @@
+Generated resource input.
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenA.qrc.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenA.qrc.in
new file mode 100644
index 000000000..c131a3460
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenA.qrc.in
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/TextsGenerated">
+ <file>resGen/input.txt</file>
+ </qresource>
+</RCC>
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenB.qrc.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenB.qrc.in
new file mode 100644
index 000000000..8c7e64311
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resGenB.qrc.in
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/TextsGenerated">
+ <file>resGen/input.txt</file>
+ <file alias="Added">resGen/inputAdded.txt</file>
+ </qresource>
+</RCC>
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/input.txt.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/input.txt.in
new file mode 100644
index 000000000..a5e407a17
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/input.txt.in
@@ -0,0 +1 @@
+Plaint resource input.
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/inputAdded.txt.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/inputAdded.txt.in
new file mode 100644
index 000000000..a5e407a17
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlain/inputAdded.txt.in
@@ -0,0 +1 @@
+Plaint resource input.
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainA.qrc.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainA.qrc.in
new file mode 100644
index 000000000..c135d85b5
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainA.qrc.in
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/TextsPlain">
+ <file>resPlain/input.txt</file>
+ </qresource>
+</RCC>
diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainB.qrc.in b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainB.qrc.in
new file mode 100644
index 000000000..186b6535a
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/resPlainB.qrc.in
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/TextsPlain">
+ <file>resPlain/input.txt</file>
+ <file alias="Added">resPlain/inputAdded.txt</file>
+ </qresource>
+</RCC>
diff --git a/Tests/QtAutogen/RerunRccDepends/dummy.cpp b/Tests/QtAutogen/RerunRccDepends/dummy.cpp
new file mode 100644
index 000000000..4837a76b8
--- /dev/null
+++ b/Tests/QtAutogen/RerunRccDepends/dummy.cpp
@@ -0,0 +1,5 @@
+
+int main(int argv, char** args)
+{
+ return 0;
+}
diff --git a/Tests/QtAutogen/SameName/CMakeLists.txt b/Tests/QtAutogen/SameName/CMakeLists.txt
new file mode 100644
index 000000000..cd29a2a85
--- /dev/null
+++ b/Tests/QtAutogen/SameName/CMakeLists.txt
@@ -0,0 +1,44 @@
+cmake_minimum_required(VERSION 3.10)
+project(SameName)
+include("../AutogenGuiTest.cmake")
+
+# Test AUTOMOC and AUTORCC on source files with the same name
+# but in different subdirectories
+
+add_executable(sameName
+ aaa/bbb/item.cpp
+ aaa/bbb/data.qrc
+ aaa/item.cpp
+ aaa/data.qrc
+ bbb/aaa/item.cpp
+ bbb/aaa/data.qrc
+ bbb/item.cpp
+ bbb/data.qrc
+ ccc/item.cpp
+ ccc/data.qrc
+ item.cpp
+ object.h
+ object.h++
+ object.hpp
+ object.hxx
+ object_upper_ext.H
+ data.qrc
+ main.cpp
+)
+target_link_libraries(sameName ${QT_LIBRARIES})
+set_target_properties(sameName PROPERTIES
+ AUTOMOC TRUE
+ AUTOUIC TRUE
+ AUTORCC TRUE
+)
+
+# Set different compression levels
+if (QT_TEST_VERSION EQUAL 4)
+ set(rccCompress "-compress")
+else()
+ set(rccCompress "--compress")
+endif()
+set_target_properties(sameName PROPERTIES AUTORCC_OPTIONS "${rccCompress};1" )
+set_source_files_properties(aaa/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};2" )
+set_source_files_properties(bbb/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};3" )
+set_source_files_properties(ccc/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};4" )
diff --git a/Tests/QtAutogen/SameName/aaa/bbb/data.qrc b/Tests/QtAutogen/SameName/aaa/bbb/data.qrc
new file mode 100644
index 000000000..0ea353756
--- /dev/null
+++ b/Tests/QtAutogen/SameName/aaa/bbb/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="aaa/bbb">
+ <file>item.hpp</file>
+ <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/SameName/aaa/bbb/item.cpp b/Tests/QtAutogen/SameName/aaa/bbb/item.cpp
new file mode 100644
index 000000000..850206f6b
--- /dev/null
+++ b/Tests/QtAutogen/SameName/aaa/bbb/item.cpp
@@ -0,0 +1,22 @@
+#include "item.hpp"
+
+namespace aaa {
+namespace bbb {
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ MocLocal obj;
+}
+}
+}
+
+#include "aaa/bbb/item.moc"
diff --git a/Tests/QtAutogen/SameName/aaa/bbb/item.hpp b/Tests/QtAutogen/SameName/aaa/bbb/item.hpp
new file mode 100644
index 000000000..085504385
--- /dev/null
+++ b/Tests/QtAutogen/SameName/aaa/bbb/item.hpp
@@ -0,0 +1,18 @@
+#ifndef AAA_BBB_ITEM_HPP
+#define AAA_BBB_ITEM_HPP
+
+#include <QObject>
+
+namespace aaa {
+namespace bbb {
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go();
+};
+}
+}
+
+#endif
diff --git a/Tests/QtAutogen/SameName/aaa/data.qrc b/Tests/QtAutogen/SameName/aaa/data.qrc
new file mode 100644
index 000000000..379af60c8
--- /dev/null
+++ b/Tests/QtAutogen/SameName/aaa/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="aaa/">
+ <file>item.hpp</file>
+ <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/SameName/aaa/item.cpp b/Tests/QtAutogen/SameName/aaa/item.cpp
new file mode 100644
index 000000000..e35d3d128
--- /dev/null
+++ b/Tests/QtAutogen/SameName/aaa/item.cpp
@@ -0,0 +1,22 @@
+#include "item.hpp"
+// Include ui_view.h only in header
+
+namespace aaa {
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ Ui_ViewAAA ui;
+ MocLocal obj;
+}
+}
+
+#include "aaa/item.moc"
diff --git a/Tests/QtAutogen/SameName/aaa/item.hpp b/Tests/QtAutogen/SameName/aaa/item.hpp
new file mode 100644
index 000000000..875f72fdb
--- /dev/null
+++ b/Tests/QtAutogen/SameName/aaa/item.hpp
@@ -0,0 +1,18 @@
+#ifndef AAA_ITEM_HPP
+#define AAA_ITEM_HPP
+
+#include <QObject>
+// Include ui_view.h only in header
+#include <aaa/ui_view.h>
+
+namespace aaa {
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go();
+};
+}
+
+#endif
diff --git a/Tests/QtAutogen/SameName/aaa/view.ui b/Tests/QtAutogen/SameName/aaa/view.ui
new file mode 100644
index 000000000..0f0998006
--- /dev/null
+++ b/Tests/QtAutogen/SameName/aaa/view.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ViewAAA</class>
+ <widget class="QWidget" name="Base">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/SameName/bbb/aaa/data.qrc b/Tests/QtAutogen/SameName/bbb/aaa/data.qrc
new file mode 100644
index 000000000..da980091a
--- /dev/null
+++ b/Tests/QtAutogen/SameName/bbb/aaa/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="bbb/aaa/">
+ <file>item.hpp</file>
+ <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/SameName/bbb/aaa/item.cpp b/Tests/QtAutogen/SameName/bbb/aaa/item.cpp
new file mode 100644
index 000000000..7ad01c3ef
--- /dev/null
+++ b/Tests/QtAutogen/SameName/bbb/aaa/item.cpp
@@ -0,0 +1,22 @@
+#include "item.hpp"
+
+namespace bbb {
+namespace aaa {
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ MocLocal obj;
+}
+}
+}
+
+#include "bbb/aaa/item.moc"
diff --git a/Tests/QtAutogen/SameName/bbb/aaa/item.hpp b/Tests/QtAutogen/SameName/bbb/aaa/item.hpp
new file mode 100644
index 000000000..be07ca84c
--- /dev/null
+++ b/Tests/QtAutogen/SameName/bbb/aaa/item.hpp
@@ -0,0 +1,18 @@
+#ifndef BBB_AAA_ITEM_HPP
+#define BBB_AAA_ITEM_HPP
+
+#include <QObject>
+
+namespace bbb {
+namespace aaa {
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go();
+};
+}
+}
+
+#endif
diff --git a/Tests/QtAutogen/SameName/bbb/data.qrc b/Tests/QtAutogen/SameName/bbb/data.qrc
new file mode 100644
index 000000000..5b080f5fa
--- /dev/null
+++ b/Tests/QtAutogen/SameName/bbb/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="bbb/">
+ <file>item.hpp</file>
+ <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/SameName/bbb/item.cpp b/Tests/QtAutogen/SameName/bbb/item.cpp
new file mode 100644
index 000000000..9ef128ed0
--- /dev/null
+++ b/Tests/QtAutogen/SameName/bbb/item.cpp
@@ -0,0 +1,23 @@
+#include "item.hpp"
+// Include ui_view.h only in source
+#include <bbb/ui_view.h>
+
+namespace bbb {
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ Ui_ViewBBB ui;
+ MocLocal obj;
+}
+}
+
+#include "bbb/item.moc"
diff --git a/Tests/QtAutogen/SameName/bbb/item.hpp b/Tests/QtAutogen/SameName/bbb/item.hpp
new file mode 100644
index 000000000..d39a9d711
--- /dev/null
+++ b/Tests/QtAutogen/SameName/bbb/item.hpp
@@ -0,0 +1,17 @@
+#ifndef BBB_ITEM_HPP
+#define BBB_ITEM_HPP
+
+#include <QObject>
+// Include ui_view.h only in source
+
+namespace bbb {
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go();
+};
+}
+
+#endif
diff --git a/Tests/QtAutogen/SameName/bbb/view.ui b/Tests/QtAutogen/SameName/bbb/view.ui
new file mode 100644
index 000000000..a8f506e88
--- /dev/null
+++ b/Tests/QtAutogen/SameName/bbb/view.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ViewBBB</class>
+ <widget class="QWidget" name="Base">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/SameName/ccc/data.qrc b/Tests/QtAutogen/SameName/ccc/data.qrc
new file mode 100644
index 000000000..f934c39b9
--- /dev/null
+++ b/Tests/QtAutogen/SameName/ccc/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="ccc/">
+ <file>item.hpp</file>
+ <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/SameName/ccc/item.cpp b/Tests/QtAutogen/SameName/ccc/item.cpp
new file mode 100644
index 000000000..ab8a2817b
--- /dev/null
+++ b/Tests/QtAutogen/SameName/ccc/item.cpp
@@ -0,0 +1,25 @@
+#include "item.hpp"
+// Include ui_view.h in source and header
+#include <ccc/ui_view.h>
+
+namespace ccc {
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ Ui_ViewCCC ui;
+ MocLocal obj;
+}
+}
+
+// Include own moc files
+#include "ccc/item.moc"
+#include "moc_item.cpp"
diff --git a/Tests/QtAutogen/SameName/ccc/item.hpp b/Tests/QtAutogen/SameName/ccc/item.hpp
new file mode 100644
index 000000000..20d9dd978
--- /dev/null
+++ b/Tests/QtAutogen/SameName/ccc/item.hpp
@@ -0,0 +1,18 @@
+#ifndef CCC_ITEM_HPP
+#define CCC_ITEM_HPP
+
+#include <QObject>
+// Include ui_view.h in source and header
+#include <ccc/ui_view.h>
+
+namespace ccc {
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go();
+};
+}
+
+#endif
diff --git a/Tests/QtAutogen/SameName/ccc/view.ui b/Tests/QtAutogen/SameName/ccc/view.ui
new file mode 100644
index 000000000..7989c6973
--- /dev/null
+++ b/Tests/QtAutogen/SameName/ccc/view.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ViewCCC</class>
+ <widget class="QWidget" name="Base">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/SameName/data.qrc b/Tests/QtAutogen/SameName/data.qrc
new file mode 100644
index 000000000..4ce0b4ec1
--- /dev/null
+++ b/Tests/QtAutogen/SameName/data.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>main.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/SameName/item.cpp b/Tests/QtAutogen/SameName/item.cpp
new file mode 100644
index 000000000..3d1fbe7cf
--- /dev/null
+++ b/Tests/QtAutogen/SameName/item.cpp
@@ -0,0 +1,20 @@
+#include "item.hpp"
+// Include ui_view.h in source and header
+#include <ui_view.h>
+
+class MocLocal : public QObject
+{
+ Q_OBJECT;
+
+public:
+ MocLocal() = default;
+ ~MocLocal() = default;
+};
+
+void Item::go()
+{
+ Ui_View ui;
+ MocLocal obj;
+}
+
+#include "item.moc"
diff --git a/Tests/QtAutogen/SameName/item.hpp b/Tests/QtAutogen/SameName/item.hpp
new file mode 100644
index 000000000..75e83f483
--- /dev/null
+++ b/Tests/QtAutogen/SameName/item.hpp
@@ -0,0 +1,15 @@
+#ifndef ITEM_HPP
+#define ITEM_HPP
+
+#include <QObject>
+// Include ui_view.h in source and header
+#include <ui_view.h>
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go();
+};
+
+#endif
diff --git a/Tests/QtAutogen/SameName/main.cpp b/Tests/QtAutogen/SameName/main.cpp
new file mode 100644
index 000000000..19a6f6d1b
--- /dev/null
+++ b/Tests/QtAutogen/SameName/main.cpp
@@ -0,0 +1,29 @@
+#include "aaa/bbb/item.hpp"
+#include "aaa/item.hpp"
+#include "bbb/aaa/item.hpp"
+#include "bbb/item.hpp"
+#include "ccc/item.hpp"
+#include "item.hpp"
+#include "object.h"
+#include "object.h++"
+#include "object.hpp"
+#include "object.hxx"
+#include "object_upper_ext.H"
+
+int main(int argv, char** args)
+{
+ // Item instances
+ ::Item item;
+ ::aaa::Item aaa_item;
+ ::aaa::bbb::Item aaa_bbb_item;
+ ::bbb::Item bbb_item;
+ ::bbb::aaa::Item bbb_aaa_item;
+ ::ccc::Item ccc_item;
+ // Object instances
+ ::Object_h obj_h;
+ ::Object_hplpl obj_hplpl;
+ ::Object_hpp obj_hpp;
+ ::Object_hxx obj_hxx;
+ ::Object_Upper_Ext_H obj_upper_ext_h;
+ return 0;
+}
diff --git a/Tests/QtAutogen/SameName/object.h b/Tests/QtAutogen/SameName/object.h
new file mode 100644
index 000000000..86620941a
--- /dev/null
+++ b/Tests/QtAutogen/SameName/object.h
@@ -0,0 +1,13 @@
+#ifndef OBJECT_H
+#define OBJECT_H
+
+#include <QObject>
+
+class Object_h : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go(){};
+};
+
+#endif
diff --git a/Tests/QtAutogen/SameName/object.h++ b/Tests/QtAutogen/SameName/object.h++
new file mode 100644
index 000000000..64222b7ec
--- /dev/null
+++ b/Tests/QtAutogen/SameName/object.h++
@@ -0,0 +1,13 @@
+#ifndef OBJECT_HPLPL
+#define OBJECT_HPLPL
+
+#include <QObject>
+
+class Object_hplpl : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go(){};
+};
+
+#endif
diff --git a/Tests/QtAutogen/SameName/object.hpp b/Tests/QtAutogen/SameName/object.hpp
new file mode 100644
index 000000000..035050ec7
--- /dev/null
+++ b/Tests/QtAutogen/SameName/object.hpp
@@ -0,0 +1,13 @@
+#ifndef OBJECT_HPP
+#define OBJECT_HPP
+
+#include <QObject>
+
+class Object_hpp : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go(){};
+};
+
+#endif
diff --git a/Tests/QtAutogen/SameName/object.hxx b/Tests/QtAutogen/SameName/object.hxx
new file mode 100644
index 000000000..c3c050f13
--- /dev/null
+++ b/Tests/QtAutogen/SameName/object.hxx
@@ -0,0 +1,13 @@
+#ifndef OBJECT_HXX
+#define OBJECT_HXX
+
+#include <QObject>
+
+class Object_hxx : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go(){};
+};
+
+#endif
diff --git a/Tests/QtAutogen/SameName/object_upper_ext.H b/Tests/QtAutogen/SameName/object_upper_ext.H
new file mode 100644
index 000000000..3266087d4
--- /dev/null
+++ b/Tests/QtAutogen/SameName/object_upper_ext.H
@@ -0,0 +1,13 @@
+#ifndef OBJECT_UPPER_EXT_H
+#define OBJECT_UPPER_EXT_H
+
+#include <QObject>
+
+class Object_Upper_Ext_H : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go(){};
+};
+
+#endif
diff --git a/Tests/QtAutogen/SameName/view.ui b/Tests/QtAutogen/SameName/view.ui
new file mode 100644
index 000000000..2ffe7344c
--- /dev/null
+++ b/Tests/QtAutogen/SameName/view.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>View</class>
+ <widget class="QWidget" name="Base">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/StaticLibraryCycle/CMakeLists.txt b/Tests/QtAutogen/StaticLibraryCycle/CMakeLists.txt
new file mode 100644
index 000000000..f3536ba2c
--- /dev/null
+++ b/Tests/QtAutogen/StaticLibraryCycle/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 3.10)
+project(StaticLibraryCycle)
+include("../AutogenCoreTest.cmake")
+
+# Test AUTOMOC on cyclic static libraries
+
+set(CMAKE_AUTOMOC ON)
+
+# Cyclic static libraries
+add_library(slc_a STATIC a.cpp)
+target_link_libraries(slc_a ${QT_LIBRARIES} slc_b)
+
+add_library(slc_b STATIC b.cpp)
+target_link_libraries(slc_b ${QT_LIBRARIES} slc_c)
+
+add_library(slc_c STATIC c.cpp)
+target_link_libraries(slc_c ${QT_LIBRARIES} slc_a)
+
+add_executable(slc main.cpp)
+target_link_libraries(slc ${QT_LIBRARIES} slc_a)
diff --git a/Tests/QtAutogen/StaticLibraryCycle/a.cpp b/Tests/QtAutogen/StaticLibraryCycle/a.cpp
new file mode 100644
index 000000000..8dd1803f1
--- /dev/null
+++ b/Tests/QtAutogen/StaticLibraryCycle/a.cpp
@@ -0,0 +1,13 @@
+#include "a.h"
+
+#include "b.h"
+
+bool A::recursed = false;
+
+A::A()
+{
+ if (!A::recursed) {
+ A::recursed = true;
+ B b;
+ }
+}
diff --git a/Tests/QtAutogen/StaticLibraryCycle/a.h b/Tests/QtAutogen/StaticLibraryCycle/a.h
new file mode 100644
index 000000000..f24398e5e
--- /dev/null
+++ b/Tests/QtAutogen/StaticLibraryCycle/a.h
@@ -0,0 +1,15 @@
+#ifndef CLASSA_HPP
+#define CLASSA_HPP
+
+#include <QObject>
+
+class A : public QObject
+{
+ Q_OBJECT
+ static bool recursed;
+
+public:
+ A();
+};
+
+#endif
diff --git a/Tests/QtAutogen/StaticLibraryCycle/b.cpp b/Tests/QtAutogen/StaticLibraryCycle/b.cpp
new file mode 100644
index 000000000..dee26177a
--- /dev/null
+++ b/Tests/QtAutogen/StaticLibraryCycle/b.cpp
@@ -0,0 +1,8 @@
+#include "b.h"
+
+#include "c.h"
+
+B::B()
+{
+ C c;
+}
diff --git a/Tests/QtAutogen/StaticLibraryCycle/b.h b/Tests/QtAutogen/StaticLibraryCycle/b.h
new file mode 100644
index 000000000..ededbd803
--- /dev/null
+++ b/Tests/QtAutogen/StaticLibraryCycle/b.h
@@ -0,0 +1,13 @@
+#ifndef CLASSB_HPP
+#define CLASSB_HPP
+
+#include <QObject>
+
+class B : public QObject
+{
+ Q_OBJECT
+public:
+ B();
+};
+
+#endif
diff --git a/Tests/QtAutogen/StaticLibraryCycle/c.cpp b/Tests/QtAutogen/StaticLibraryCycle/c.cpp
new file mode 100644
index 000000000..2871f62f6
--- /dev/null
+++ b/Tests/QtAutogen/StaticLibraryCycle/c.cpp
@@ -0,0 +1,8 @@
+#include "c.h"
+
+#include "a.h"
+
+C::C()
+{
+ A a;
+}
diff --git a/Tests/QtAutogen/StaticLibraryCycle/c.h b/Tests/QtAutogen/StaticLibraryCycle/c.h
new file mode 100644
index 000000000..20f3725e9
--- /dev/null
+++ b/Tests/QtAutogen/StaticLibraryCycle/c.h
@@ -0,0 +1,13 @@
+#ifndef CLASSC_HPP
+#define CLASSC_HPP
+
+#include <QObject>
+
+class C : public QObject
+{
+ Q_OBJECT
+public:
+ C();
+};
+
+#endif
diff --git a/Tests/QtAutogen/StaticLibraryCycle/main.cpp b/Tests/QtAutogen/StaticLibraryCycle/main.cpp
new file mode 100644
index 000000000..f5b7fd227
--- /dev/null
+++ b/Tests/QtAutogen/StaticLibraryCycle/main.cpp
@@ -0,0 +1,8 @@
+#include "a.h"
+
+int main(int argv, char** args)
+{
+ // Object instances
+ A a;
+ return 0;
+}
diff --git a/Tests/QtAutogen/TestMacros.cmake b/Tests/QtAutogen/TestMacros.cmake
new file mode 100644
index 000000000..0e2718807
--- /dev/null
+++ b/Tests/QtAutogen/TestMacros.cmake
@@ -0,0 +1,61 @@
+# Autogen build options
+set(Autogen_BUILD_OPTIONS "-DQT_TEST_VERSION=${QT_TEST_VERSION}")
+if(NOT _isMultiConfig) # Set in Tests/CMakeLists.txt
+ list(APPEND Autogen_BUILD_OPTIONS "-DCMAKE_BUILD_TYPE=$<CONFIGURATION>")
+endif()
+list(APPEND Autogen_BUILD_OPTIONS
+ "-DCMAKE_AUTOGEN_VERBOSE=1"
+ "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+)
+
+# A macro to add a QtAutogen test
+macro(ADD_AUTOGEN_TEST NAME)
+ if(${ARGC} GREATER 1)
+ # On Windows there is no RPATH, so while Qt might be available for building,
+ # the required dlls may not be in the PATH, so we can't run the executables
+ # on that platform.
+ if(WIN32)
+ set(_TestCommand --test-command ${CMAKE_CTEST_COMMAND} -V)
+ else()
+ set(_TestCommand --test-command ${ARGN})
+ endif()
+ endif()
+
+ set(_QtXAutogen "Qt${QT_TEST_VERSION}Autogen")
+ set(_SourceDir "${CMake_SOURCE_DIR}/Tests/QtAutogen/${NAME}")
+ set(_BuildDir "${CMake_BINARY_DIR}/Tests/${_QtXAutogen}/${NAME}")
+ add_test(NAME "${_QtXAutogen}.${NAME}" COMMAND "${CMAKE_CTEST_COMMAND}"
+ --build-and-test
+ "${_SourceDir}"
+ "${_BuildDir}"
+ ${build_generator_args}
+ --build-project ${NAME}
+ --build-exe-dir "${_BuildDir}"
+ --force-new-ctest-process
+ --build-options ${build_options} ${Autogen_BUILD_OPTIONS}
+ ${_TestCommand}
+ )
+ list(APPEND TEST_BUILD_DIRS "${_BuildDir}")
+ unset(_TestCommand)
+ unset(_QtXAutogen)
+ unset(_SourceDir)
+ unset(_BuildDir)
+endmacro()
+
+# Allow using qtx_wrap_cpp and qtx_generate_moc or not
+set(QT_TEST_ALLOW_QT_MACROS TRUE)
+# Do a simple check if there is are non ASCII character in the build path
+string(REGEX MATCH "[^ -~]+" NON_ASCII_BDIR ${CMAKE_CURRENT_BINARY_DIR})
+if(NON_ASCII_BDIR)
+ # Qt4 moc does not support utf8 paths in _parameter files generated by
+ # qtx_wrap_cpp
+ # https://bugreports.qt.io/browse/QTBUG-35480
+ if(QT_TEST_VERSION EQUAL 4)
+ set(QT_TEST_ALLOW_QT_MACROS FALSE)
+ endif()
+ # On windows qtx_wrap_cpp also fails in Qt5 when used on a path that
+ # contains non ASCII characters
+ if(WIN32)
+ set(QT_TEST_ALLOW_QT_MACROS FALSE)
+ endif()
+endif()
diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake
new file mode 100644
index 000000000..2b001d452
--- /dev/null
+++ b/Tests/QtAutogen/Tests.cmake
@@ -0,0 +1,48 @@
+# Qt4 and Qt5 tests
+ADD_AUTOGEN_TEST(AutogenOriginDependsOff autogenOriginDependsOff)
+ADD_AUTOGEN_TEST(AutogenOriginDependsOn)
+ADD_AUTOGEN_TEST(AutogenTargetDepends)
+ADD_AUTOGEN_TEST(Complex QtAutogen)
+ADD_AUTOGEN_TEST(GlobalAutogenTarget)
+ADD_AUTOGEN_TEST(LowMinimumVersion lowMinimumVersion)
+ADD_AUTOGEN_TEST(ManySources manySources)
+ADD_AUTOGEN_TEST(MocOnly mocOnly)
+ADD_AUTOGEN_TEST(MocOptions mocOptions)
+ADD_AUTOGEN_TEST(ObjectLibrary someProgram)
+ADD_AUTOGEN_TEST(Parallel parallel)
+ADD_AUTOGEN_TEST(Parallel1 parallel1)
+ADD_AUTOGEN_TEST(Parallel2 parallel2)
+ADD_AUTOGEN_TEST(Parallel3 parallel3)
+ADD_AUTOGEN_TEST(Parallel4 parallel4)
+ADD_AUTOGEN_TEST(ParallelAUTO parallelAUTO)
+ADD_AUTOGEN_TEST(RccEmpty rccEmpty)
+ADD_AUTOGEN_TEST(RccOffMocLibrary)
+ADD_AUTOGEN_TEST(RccOnly rccOnly)
+ADD_AUTOGEN_TEST(RccSkipSource)
+ADD_AUTOGEN_TEST(RerunMocBasic)
+ADD_AUTOGEN_TEST(RerunRccConfigChange)
+ADD_AUTOGEN_TEST(RerunRccDepends)
+ADD_AUTOGEN_TEST(SameName sameName)
+ADD_AUTOGEN_TEST(StaticLibraryCycle slc)
+ADD_AUTOGEN_TEST(UicInclude uicInclude)
+ADD_AUTOGEN_TEST(UicInterface QtAutoUicInterface)
+ADD_AUTOGEN_TEST(UicNoGui uicNoGui)
+ADD_AUTOGEN_TEST(UicOnly uicOnly)
+ADD_AUTOGEN_TEST(UicSkipSource)
+
+if(QT_TEST_ALLOW_QT_MACROS)
+ ADD_AUTOGEN_TEST(MocCMP0071)
+ ADD_AUTOGEN_TEST(MocInclude)
+ ADD_AUTOGEN_TEST(MocIncludeSymlink)
+ ADD_AUTOGEN_TEST(MocSkipSource)
+endif()
+
+# Qt5 only tests
+if(QT_TEST_VERSION GREATER 4)
+ ADD_AUTOGEN_TEST(MocMacroName mocMacroName)
+ ADD_AUTOGEN_TEST(MocOsMacros)
+ ADD_AUTOGEN_TEST(RerunMocPlugin)
+ if(APPLE)
+ ADD_AUTOGEN_TEST(MacOsFW)
+ endif()
+endif()
diff --git a/Tests/QtAutogen/UicInclude/CMakeLists.txt b/Tests/QtAutogen/UicInclude/CMakeLists.txt
new file mode 100644
index 000000000..929868b52
--- /dev/null
+++ b/Tests/QtAutogen/UicInclude/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.10)
+project(UicInclude)
+include("../AutogenGuiTest.cmake")
+
+# Test uic include patterns
+set(CMAKE_AUTOUIC_SEARCH_PATHS "dirA")
+
+add_executable(uicInclude main.cpp)
+target_link_libraries(uicInclude ${QT_LIBRARIES})
+set_target_properties(uicInclude PROPERTIES AUTOUIC ON)
+set_property(TARGET uicInclude APPEND PROPERTY AUTOUIC_SEARCH_PATHS "dirB")
diff --git a/Tests/QtAutogen/uicInclude/PageC.ui b/Tests/QtAutogen/UicInclude/PageC.ui
index bb2fb5e6a..bb2fb5e6a 100644
--- a/Tests/QtAutogen/uicInclude/PageC.ui
+++ b/Tests/QtAutogen/UicInclude/PageC.ui
diff --git a/Tests/QtAutogen/uicInclude/PageC2.ui b/Tests/QtAutogen/UicInclude/PageC2.ui
index daab86839..daab86839 100644
--- a/Tests/QtAutogen/uicInclude/PageC2.ui
+++ b/Tests/QtAutogen/UicInclude/PageC2.ui
diff --git a/Tests/QtAutogen/uicInclude/dirA/PageA.ui b/Tests/QtAutogen/UicInclude/dirA/PageA.ui
index dd8180292..dd8180292 100644
--- a/Tests/QtAutogen/uicInclude/dirA/PageA.ui
+++ b/Tests/QtAutogen/UicInclude/dirA/PageA.ui
diff --git a/Tests/QtAutogen/uicInclude/dirB/PageB.ui b/Tests/QtAutogen/UicInclude/dirB/PageB.ui
index fa6dfa615..fa6dfa615 100644
--- a/Tests/QtAutogen/uicInclude/dirB/PageB.ui
+++ b/Tests/QtAutogen/UicInclude/dirB/PageB.ui
diff --git a/Tests/QtAutogen/uicInclude/dirB/PageB2.ui b/Tests/QtAutogen/UicInclude/dirB/PageB2.ui
index 2225150b5..2225150b5 100644
--- a/Tests/QtAutogen/uicInclude/dirB/PageB2.ui
+++ b/Tests/QtAutogen/UicInclude/dirB/PageB2.ui
diff --git a/Tests/QtAutogen/uicInclude/dirB/subB/PageBsub.ui b/Tests/QtAutogen/UicInclude/dirB/subB/PageBsub.ui
index 873016ec8..873016ec8 100644
--- a/Tests/QtAutogen/uicInclude/dirB/subB/PageBsub.ui
+++ b/Tests/QtAutogen/UicInclude/dirB/subB/PageBsub.ui
diff --git a/Tests/QtAutogen/uicInclude/main.cpp b/Tests/QtAutogen/UicInclude/main.cpp
index c8e760962..c8e760962 100644
--- a/Tests/QtAutogen/uicInclude/main.cpp
+++ b/Tests/QtAutogen/UicInclude/main.cpp
diff --git a/Tests/QtAutogen/uicInclude/main.hpp b/Tests/QtAutogen/UicInclude/main.hpp
index 58ddc261f..58ddc261f 100644
--- a/Tests/QtAutogen/uicInclude/main.hpp
+++ b/Tests/QtAutogen/UicInclude/main.hpp
diff --git a/Tests/QtAutogen/uicInclude/subC/PageCsub.ui b/Tests/QtAutogen/UicInclude/subC/PageCsub.ui
index 0268326b9..0268326b9 100644
--- a/Tests/QtAutogen/uicInclude/subC/PageCsub.ui
+++ b/Tests/QtAutogen/UicInclude/subC/PageCsub.ui
diff --git a/Tests/QtAutogen/UicInterface/CMakeLists.txt b/Tests/QtAutogen/UicInterface/CMakeLists.txt
new file mode 100644
index 000000000..e0227645b
--- /dev/null
+++ b/Tests/QtAutogen/UicInterface/CMakeLists.txt
@@ -0,0 +1,58 @@
+cmake_minimum_required(VERSION 3.10)
+project(UicInterface)
+include("../AutogenGuiTest.cmake")
+
+set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+
+# BEGIN Upstream
+
+set(CMAKE_VERBOSE_MAKEFILE ON)
+
+add_library(KI18n klocalizedstring.cpp)
+target_link_libraries(KI18n ${QT_QTCORE_TARGET})
+
+set(autouic_options
+ -tr tr2$<$<NOT:$<BOOL:$<TARGET_PROPERTY:NO_KUIT_SEMANTIC>>>:x>i18n
+)
+if (NOT Qt5Widgets_VERSION VERSION_LESS 5.3.0)
+ list(APPEND autouic_options -include klocalizedstring.h)
+endif()
+
+set_property(TARGET KI18n APPEND PROPERTY
+ INTERFACE_AUTOUIC_OPTIONS ${autouic_options}
+)
+
+set(domainProp $<TARGET_PROPERTY:TRANSLATION_DOMAIN>)
+set(nameLower $<LOWER_CASE:$<MAKE_C_IDENTIFIER:$<TARGET_PROPERTY:NAME>>>)
+set(domain_logic
+ $<$<BOOL:${domainProp}>:${domainProp}>$<$<NOT:$<BOOL:${domainProp}>>:${nameLower}>
+)
+set_property(TARGET KI18n APPEND PROPERTY
+ INTERFACE_COMPILE_DEFINITIONS "TRANSLATION_DOMAIN=${domain_logic}"
+)
+
+# END upstream
+
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
+set(INC_DIR "include_$<CONFIG>" )
+else()
+set(INC_DIR "include" )
+endif()
+
+add_library(LibWidget libwidget.cpp)
+target_link_libraries(LibWidget KI18n ${QT_LIBRARIES})
+set_property(TARGET LibWidget PROPERTY NO_KUIT_SEMANTIC ON)
+set_property(TARGET LibWidget PROPERTY TRANSLATION_DOMAIN customdomain)
+
+add_library(MyWidget mywidget.cpp)
+target_link_libraries(MyWidget KI18n ${QT_LIBRARIES})
+
+add_executable(QtAutoUicInterface main.cpp)
+target_compile_definitions(QtAutoUicInterface
+ PRIVATE
+ UI_LIBWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/LibWidget_autogen/${INC_DIR}/ui_libwidget.h"
+ UI_MYWIDGET_H="${CMAKE_CURRENT_BINARY_DIR}/MyWidget_autogen/${INC_DIR}/ui_mywidget.h"
+)
diff --git a/Tests/QtAutoUicInterface/klocalizedstring.cpp b/Tests/QtAutogen/UicInterface/klocalizedstring.cpp
index b629cd176..b629cd176 100644
--- a/Tests/QtAutoUicInterface/klocalizedstring.cpp
+++ b/Tests/QtAutogen/UicInterface/klocalizedstring.cpp
diff --git a/Tests/QtAutoUicInterface/klocalizedstring.h b/Tests/QtAutogen/UicInterface/klocalizedstring.h
index 6129599dc..6129599dc 100644
--- a/Tests/QtAutoUicInterface/klocalizedstring.h
+++ b/Tests/QtAutogen/UicInterface/klocalizedstring.h
diff --git a/Tests/QtAutoUicInterface/libwidget.cpp b/Tests/QtAutogen/UicInterface/libwidget.cpp
index 008c22a96..008c22a96 100644
--- a/Tests/QtAutoUicInterface/libwidget.cpp
+++ b/Tests/QtAutogen/UicInterface/libwidget.cpp
diff --git a/Tests/QtAutogen/UicInterface/libwidget.h b/Tests/QtAutogen/UicInterface/libwidget.h
new file mode 100644
index 000000000..532ff1db1
--- /dev/null
+++ b/Tests/QtAutogen/UicInterface/libwidget.h
@@ -0,0 +1,26 @@
+
+#ifndef LIBWIDGET_H
+#define LIBWIDGET_H
+
+#include <memory>
+
+#include <QWidget>
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
+# include <klocalizedstring.h>
+#endif
+
+#include "ui_libwidget.h"
+
+class LibWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit LibWidget(QWidget* parent = 0);
+ ~LibWidget();
+
+private:
+ Ui::LibWidget* ui;
+};
+
+#endif
diff --git a/Tests/QtAutoUicInterface/libwidget.ui b/Tests/QtAutogen/UicInterface/libwidget.ui
index 897371e4a..897371e4a 100644
--- a/Tests/QtAutoUicInterface/libwidget.ui
+++ b/Tests/QtAutogen/UicInterface/libwidget.ui
diff --git a/Tests/QtAutoUicInterface/main.cpp b/Tests/QtAutogen/UicInterface/main.cpp
index 68bd84363..68bd84363 100644
--- a/Tests/QtAutoUicInterface/main.cpp
+++ b/Tests/QtAutogen/UicInterface/main.cpp
diff --git a/Tests/QtAutoUicInterface/mywidget.cpp b/Tests/QtAutogen/UicInterface/mywidget.cpp
index 7cf1a1318..7cf1a1318 100644
--- a/Tests/QtAutoUicInterface/mywidget.cpp
+++ b/Tests/QtAutogen/UicInterface/mywidget.cpp
diff --git a/Tests/QtAutogen/UicInterface/mywidget.h b/Tests/QtAutogen/UicInterface/mywidget.h
new file mode 100644
index 000000000..320d433ba
--- /dev/null
+++ b/Tests/QtAutogen/UicInterface/mywidget.h
@@ -0,0 +1,26 @@
+
+#ifndef MYWIDGET_H
+#define MYWIDGET_H
+
+#include <memory>
+
+#include <QWidget>
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 3, 0)
+# include <klocalizedstring.h>
+#endif
+
+#include "ui_mywidget.h"
+
+class MyWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit MyWidget(QWidget* parent = 0);
+ ~MyWidget();
+
+private:
+ Ui::MyWidget* ui;
+};
+
+#endif
diff --git a/Tests/QtAutoUicInterface/mywidget.ui b/Tests/QtAutogen/UicInterface/mywidget.ui
index b2b9cc592..b2b9cc592 100644
--- a/Tests/QtAutoUicInterface/mywidget.ui
+++ b/Tests/QtAutogen/UicInterface/mywidget.ui
diff --git a/Tests/QtAutogen/UicNoGui/CMakeLists.txt b/Tests/QtAutogen/UicNoGui/CMakeLists.txt
new file mode 100644
index 000000000..076299db1
--- /dev/null
+++ b/Tests/QtAutogen/UicNoGui/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.13)
+project(UicNoGui)
+include("../AutogenCoreTest.cmake")
+
+# This tests creates a target that has AUTOUIC enabled but does not
+# link against QtXWidgets.
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTORCC ON)
+
+add_subdirectory(MocOnly)
+add_subdirectory(NoQt)
+
+add_executable(uicNoGui main.cpp)
+target_link_libraries(uicNoGui mocOnly noQt)
diff --git a/Tests/QtAutogen/UicNoGui/MocOnly/CMakeLists.txt b/Tests/QtAutogen/UicNoGui/MocOnly/CMakeLists.txt
new file mode 100644
index 000000000..4fcd75fa0
--- /dev/null
+++ b/Tests/QtAutogen/UicNoGui/MocOnly/CMakeLists.txt
@@ -0,0 +1,3 @@
+# Library uses QtCore only (no Widgets)
+add_library(mocOnly main.cpp)
+target_link_libraries(mocOnly ${QT_QTCORE_TARGET})
diff --git a/Tests/QtAutogen/UicNoGui/MocOnly/main.cpp b/Tests/QtAutogen/UicNoGui/MocOnly/main.cpp
new file mode 100644
index 000000000..3091845ef
--- /dev/null
+++ b/Tests/QtAutogen/UicNoGui/MocOnly/main.cpp
@@ -0,0 +1,15 @@
+#include <QObject>
+
+class LocalObject : public QObject
+{
+ Q_OBJECT
+public:
+ LocalObject(){};
+};
+
+void mocOnly()
+{
+ LocalObject obj;
+}
+
+#include "main.moc"
diff --git a/Tests/QtAutogen/UicNoGui/NoQt/CMakeLists.txt b/Tests/QtAutogen/UicNoGui/NoQt/CMakeLists.txt
new file mode 100644
index 000000000..f2bf3eec1
--- /dev/null
+++ b/Tests/QtAutogen/UicNoGui/NoQt/CMakeLists.txt
@@ -0,0 +1,2 @@
+# Library doesn't use or link against Qt at all
+add_library(noQt main.cpp)
diff --git a/Tests/QtAutogen/UicNoGui/NoQt/main.cpp b/Tests/QtAutogen/UicNoGui/NoQt/main.cpp
new file mode 100644
index 000000000..0052cc864
--- /dev/null
+++ b/Tests/QtAutogen/UicNoGui/NoQt/main.cpp
@@ -0,0 +1,4 @@
+
+void noQt()
+{
+}
diff --git a/Tests/QtAutogen/UicNoGui/main.cpp b/Tests/QtAutogen/UicNoGui/main.cpp
new file mode 100644
index 000000000..e90c60aa5
--- /dev/null
+++ b/Tests/QtAutogen/UicNoGui/main.cpp
@@ -0,0 +1,9 @@
+extern void mocOnly();
+extern void noQt();
+
+int main(int argc, char* argv[])
+{
+ mocOnly();
+ noQt();
+ return 0;
+}
diff --git a/Tests/QtAutogen/UicOnly/CMakeLists.txt b/Tests/QtAutogen/UicOnly/CMakeLists.txt
new file mode 100644
index 000000000..b16325438
--- /dev/null
+++ b/Tests/QtAutogen/UicOnly/CMakeLists.txt
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.10)
+project(UicOnly)
+include("../AutogenGuiTest.cmake")
+
+# Test AUTOUIC being enabled only
+add_executable(uicOnly main.cpp UicOnly.cpp)
+set_property(TARGET uicOnly PROPERTY AUTOUIC ON)
+target_link_libraries(uicOnly ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/UicOnly/UicOnly.cpp b/Tests/QtAutogen/UicOnly/UicOnly.cpp
new file mode 100644
index 000000000..8eee6d213
--- /dev/null
+++ b/Tests/QtAutogen/UicOnly/UicOnly.cpp
@@ -0,0 +1,18 @@
+#include "ui_uiC.h"
+#include "ui_uiD.h"
+// AUTOUIC includes on the first two lines of a source file
+#include "UicOnly.hpp"
+
+UicOnly::UicOnly()
+ : uiA(new Ui::UiA)
+ , uiB(new Ui::UiB)
+{
+ Ui::UiC uiC;
+ Ui::UiD uiD;
+}
+
+UicOnly::~UicOnly()
+{
+ delete uiB;
+ delete uiA;
+}
diff --git a/Tests/QtAutogen/UicOnly/UicOnly.hpp b/Tests/QtAutogen/UicOnly/UicOnly.hpp
new file mode 100644
index 000000000..24e1e0b94
--- /dev/null
+++ b/Tests/QtAutogen/UicOnly/UicOnly.hpp
@@ -0,0 +1,15 @@
+#include "ui_uiA.h"
+#include "ui_uiB.h"
+// AUTOUIC includes on the first two lines of a header file
+#include <QObject>
+
+class UicOnly : public QObject
+{
+public:
+ UicOnly();
+ ~UicOnly();
+
+private:
+ Ui::UiA* uiA;
+ Ui::UiB* uiB;
+};
diff --git a/Tests/QtAutogen/UicOnly/main.cpp b/Tests/QtAutogen/UicOnly/main.cpp
new file mode 100644
index 000000000..bdd242ec2
--- /dev/null
+++ b/Tests/QtAutogen/UicOnly/main.cpp
@@ -0,0 +1,7 @@
+#include "UicOnly.hpp"
+
+int main(int argc, char* argv[])
+{
+ UicOnly uicOnly;
+ return 0;
+}
diff --git a/Tests/QtAutogen/UicOnly/uiA.ui b/Tests/QtAutogen/UicOnly/uiA.ui
new file mode 100644
index 000000000..4c5762e82
--- /dev/null
+++ b/Tests/QtAutogen/UicOnly/uiA.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UiA</class>
+ <widget class="QWidget" name="UiA">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/UicOnly/uiB.ui b/Tests/QtAutogen/UicOnly/uiB.ui
new file mode 100644
index 000000000..6ca77dec3
--- /dev/null
+++ b/Tests/QtAutogen/UicOnly/uiB.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UiB</class>
+ <widget class="QWidget" name="UiB">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/UicOnly/uiC.ui b/Tests/QtAutogen/UicOnly/uiC.ui
new file mode 100644
index 000000000..6802550cb
--- /dev/null
+++ b/Tests/QtAutogen/UicOnly/uiC.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UiC</class>
+ <widget class="QWidget" name="UiC">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/UicOnly/uiD.ui b/Tests/QtAutogen/UicOnly/uiD.ui
new file mode 100644
index 000000000..aad79cf7f
--- /dev/null
+++ b/Tests/QtAutogen/UicOnly/uiD.ui
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UiD</class>
+ <widget class="QWidget" name="UiD">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="treeView"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/UicSkipSource/CMakeLists.txt b/Tests/QtAutogen/UicSkipSource/CMakeLists.txt
new file mode 100644
index 000000000..dc3b7d4eb
--- /dev/null
+++ b/Tests/QtAutogen/UicSkipSource/CMakeLists.txt
@@ -0,0 +1,22 @@
+cmake_minimum_required(VERSION 3.10)
+project(UicSkipSource)
+include("../AutogenGuiTest.cmake")
+
+# Test for SKIP_AUTOUIC and SKIP_AUTOGEN on an AUTOUIC enabled target
+set(skipUicSources
+ skipUic.cpp
+ skipUicGen.cpp
+ skipUicNoGen1.cpp
+ skipUicNoGen2.cpp
+)
+set_property(SOURCE skipUicNoGen1.cpp PROPERTY SKIP_AUTOUIC ON)
+set_property(SOURCE skipUicNoGen2.cpp PROPERTY SKIP_AUTOGEN ON)
+# AUTOUIC enabled
+add_executable(skipUicA ${skipUicSources})
+set_property(TARGET skipUicA PROPERTY AUTOUIC ON)
+target_link_libraries(skipUicA ${QT_LIBRARIES})
+# AUTOUIC and AUTOMOC enabled
+add_executable(skipUicB ${skipUicSources})
+set_property(TARGET skipUicB PROPERTY AUTOUIC ON)
+set_property(TARGET skipUicB PROPERTY AUTOMOC ON)
+target_link_libraries(skipUicB ${QT_LIBRARIES})
diff --git a/Tests/QtAutogen/UicSkipSource/skipUic.cpp b/Tests/QtAutogen/UicSkipSource/skipUic.cpp
new file mode 100644
index 000000000..c4a7ce95b
--- /dev/null
+++ b/Tests/QtAutogen/UicSkipSource/skipUic.cpp
@@ -0,0 +1,22 @@
+
+#include "skipUicGen.hpp"
+#include "skipUicNoGen1.hpp"
+#include "skipUicNoGen2.hpp"
+
+int main(int, char**)
+{
+ skipGen();
+ skipNoGen1();
+ skipNoGen2();
+
+ return 0;
+}
+
+// -- Function definitions
+void ui_nogen1()
+{
+}
+
+void ui_nogen2()
+{
+}
diff --git a/Tests/QtAutogen/UicSkipSource/skipUicGen.cpp b/Tests/QtAutogen/UicSkipSource/skipUicGen.cpp
new file mode 100644
index 000000000..ab3c454c7
--- /dev/null
+++ b/Tests/QtAutogen/UicSkipSource/skipUicGen.cpp
@@ -0,0 +1,8 @@
+
+#include "skipUicGen.hpp"
+
+#include "ui_uigen2.h"
+
+void skipGen()
+{
+}
diff --git a/Tests/QtAutogen/skipSource/skipUicGen.hpp b/Tests/QtAutogen/UicSkipSource/skipUicGen.hpp
index 3669f0e5b..3669f0e5b 100644
--- a/Tests/QtAutogen/skipSource/skipUicGen.hpp
+++ b/Tests/QtAutogen/UicSkipSource/skipUicGen.hpp
diff --git a/Tests/QtAutogen/UicSkipSource/skipUicNoGen1.cpp b/Tests/QtAutogen/UicSkipSource/skipUicNoGen1.cpp
new file mode 100644
index 000000000..d648d94e7
--- /dev/null
+++ b/Tests/QtAutogen/UicSkipSource/skipUicNoGen1.cpp
@@ -0,0 +1,8 @@
+
+#include "skipUicNoGen1.hpp"
+
+#include "ui_nogen2.h"
+
+void skipNoGen1()
+{
+}
diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen1.hpp b/Tests/QtAutogen/UicSkipSource/skipUicNoGen1.hpp
index 286469598..286469598 100644
--- a/Tests/QtAutogen/skipSource/skipUicNoGen1.hpp
+++ b/Tests/QtAutogen/UicSkipSource/skipUicNoGen1.hpp
diff --git a/Tests/QtAutogen/UicSkipSource/skipUicNoGen2.cpp b/Tests/QtAutogen/UicSkipSource/skipUicNoGen2.cpp
new file mode 100644
index 000000000..aca58a463
--- /dev/null
+++ b/Tests/QtAutogen/UicSkipSource/skipUicNoGen2.cpp
@@ -0,0 +1,8 @@
+
+#include "skipUicNoGen2.hpp"
+
+#include "ui_nogen2.h"
+
+void skipNoGen2()
+{
+}
diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen2.hpp b/Tests/QtAutogen/UicSkipSource/skipUicNoGen2.hpp
index 7c381938c..7c381938c 100644
--- a/Tests/QtAutogen/skipSource/skipUicNoGen2.hpp
+++ b/Tests/QtAutogen/UicSkipSource/skipUicNoGen2.hpp
diff --git a/Tests/QtAutogen/skipSource/ui_nogen1.h b/Tests/QtAutogen/UicSkipSource/ui_nogen1.h
index a7be52bce..a7be52bce 100644
--- a/Tests/QtAutogen/skipSource/ui_nogen1.h
+++ b/Tests/QtAutogen/UicSkipSource/ui_nogen1.h
diff --git a/Tests/QtAutogen/UicSkipSource/ui_nogen2.h b/Tests/QtAutogen/UicSkipSource/ui_nogen2.h
new file mode 100644
index 000000000..4e500a44d
--- /dev/null
+++ b/Tests/QtAutogen/UicSkipSource/ui_nogen2.h
@@ -0,0 +1,6 @@
+#ifndef UI_NOGEN2_H
+#define UI_NOGEN2_H
+
+void ui_nogen2();
+
+#endif
diff --git a/Tests/QtAutogen/skipSource/uigen1.ui b/Tests/QtAutogen/UicSkipSource/uigen1.ui
index fc7cb8219..fc7cb8219 100644
--- a/Tests/QtAutogen/skipSource/uigen1.ui
+++ b/Tests/QtAutogen/UicSkipSource/uigen1.ui
diff --git a/Tests/QtAutogen/skipSource/uigen2.ui b/Tests/QtAutogen/UicSkipSource/uigen2.ui
index 01f08d2ef..01f08d2ef 100644
--- a/Tests/QtAutogen/skipSource/uigen2.ui
+++ b/Tests/QtAutogen/UicSkipSource/uigen2.ui
diff --git a/Tests/QtAutogen/complex/Adir/libA.h b/Tests/QtAutogen/complex/Adir/libA.h
deleted file mode 100644
index c4eb9f7dc..000000000
--- a/Tests/QtAutogen/complex/Adir/libA.h
+++ /dev/null
@@ -1,18 +0,0 @@
-
-#ifndef LIBA_H
-#define LIBA_H
-
-#include "liba_export.h"
-
-#include <QObject>
-
-class LIBA_EXPORT LibA : public QObject
-{
- Q_OBJECT
-public:
- explicit LibA(QObject* parent = 0);
-
- int foo();
-};
-
-#endif
diff --git a/Tests/QtAutogen/complex/Bdir/libB.h b/Tests/QtAutogen/complex/Bdir/libB.h
deleted file mode 100644
index e4ab788c0..000000000
--- a/Tests/QtAutogen/complex/Bdir/libB.h
+++ /dev/null
@@ -1,22 +0,0 @@
-
-#ifndef LIBB_H
-#define LIBB_H
-
-#include "libb_export.h"
-
-#include "libA.h"
-#include <QObject>
-
-class LIBB_EXPORT LibB : public QObject
-{
- Q_OBJECT
-public:
- explicit LibB(QObject* parent = 0);
-
- int foo();
-
-private:
- LibA a;
-};
-
-#endif
diff --git a/Tests/QtAutogen/complex/CMakeLists.txt b/Tests/QtAutogen/complex/CMakeLists.txt
deleted file mode 100644
index d48f6cc54..000000000
--- a/Tests/QtAutogen/complex/CMakeLists.txt
+++ /dev/null
@@ -1,82 +0,0 @@
-cmake_minimum_required(VERSION 3.7)
-
-# -- Test: AUTOMOC AUTORCC AUTOUIC
-add_definitions(-DFOO -DSomeDefine="Barx")
-
-# enable relaxed mode so automoc can handle all the special cases:
-set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
-set(CMAKE_AUTOUIC ON)
-set(CMAKE_AUTORCC ON)
-
-# create an executable and two library targets, each requiring automoc:
-add_library(codeeditorLib STATIC codeeditor.cpp)
-add_library(privateSlot OBJECT private_slot.cpp)
-# Pass Qt compiler features to targets that don't link against Qt
-target_compile_features(codeeditorLib PRIVATE ${QT_COMPILE_FEATURES})
-target_compile_features(privateSlot PRIVATE ${QT_COMPILE_FEATURES})
-
-configure_file(generated_resource.qrc.in generated_resource.qrc @ONLY)
-add_custom_command(
- OUTPUT generated.txt
- COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/generated.txt.in" "${CMAKE_CURRENT_BINARY_DIR}/generated.txt"
- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/generated.txt.in"
- )
-
-add_custom_target(generate_moc_input
- DEPENDS generated.txt
- COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}"
- COMMAND ${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}/myinterface.h"
-)
-
-add_custom_command(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h"
- COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in" "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h"
- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in"
-)
-
-if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_GENERATOR STREQUAL Ninja)
- set(debug_srcs "$<$<CONFIG:Debug>:debug_class.cpp>" $<$<CONFIG:Debug>:debug_resource.qrc>)
- set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:TEST_DEBUG_CLASS>)
-endif()
-
-# The -no-protection option disables the generation of include guards. Verify
-# that setting the source file property has an effect by using this and
-# issue an error in the preprocessor in calwidget.cpp if the include guard
-# is defined.
-set_source_files_properties(calwidget.ui PROPERTIES AUTOUIC_OPTIONS "-no-protection")
-
-add_executable(QtAutogen main.cpp calwidget.cpp second_widget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
- multiplewidgets.cpp
- xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>
- test.qrc second_resource.qrc resourcetester.cpp generated.cpp ${debug_srcs}
- ${CMAKE_CURRENT_BINARY_DIR}/generated_resource.qrc
-)
-set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h")
-
-add_executable(targetObjectsTest targetObjectsTest.cpp $<TARGET_OBJECTS:privateSlot>)
-target_link_libraries(targetObjectsTest ${QT_LIBRARIES})
-
-set_target_properties(
- QtAutogen codeeditorLib privateSlot targetObjectsTest
- PROPERTIES
- AUTOMOC TRUE
-)
-
-
-include(GenerateExportHeader)
-# The order is relevant here. B depends on A, and B headers depend on A
-# headers both subdirectories use CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE and we
-# test that CMAKE_AUTOMOC successfully reads the include directories
-# for the build interface from those targets. There has previously been
-# a bug where caching of the include directories happened before
-# extracting the includes to pass to moc.
-add_subdirectory(Bdir)
-add_subdirectory(Adir)
-add_library(libC SHARED libC.cpp)
-set_target_properties(libC PROPERTIES AUTOMOC TRUE)
-generate_export_header(libC)
-target_link_libraries(libC LINK_PUBLIC libB)
-target_include_directories(libC PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
-set_property(TARGET libC APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR} )
-
-target_link_libraries(QtAutogen codeeditorLib ${QT_LIBRARIES} libC)
diff --git a/Tests/QtAutogen/complex/abc.cpp b/Tests/QtAutogen/complex/abc.cpp
deleted file mode 100644
index 2929b92ee..000000000
--- a/Tests/QtAutogen/complex/abc.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "abc.h"
-#include "abc_p.h"
-
-#include <stdio.h>
-
-class PrintAbc : public QObject
-{
- Q_OBJECT
-public:
- PrintAbc()
- : QObject()
- {
- }
-public slots:
- void print() const { printf("abc\n"); }
-};
-
-Abc::Abc()
- : QObject()
-{
-}
-
-void Abc::doAbc()
-{
- PrintAbc pa;
- pa.print();
- AbcP abcP;
- abcP.doAbcP();
-}
-
-// check that including the moc file for the cpp file and the header works:
-#include "abc.moc"
-#include "moc_abc.cpp"
-#include "moc_abc_p.cpp"
-
-// check that including a moc file from another header works:
-#include "moc_xyz.cpp"
diff --git a/Tests/QtAutogen/complex/abc_p.h b/Tests/QtAutogen/complex/abc_p.h
deleted file mode 100644
index be984876c..000000000
--- a/Tests/QtAutogen/complex/abc_p.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef ABC_P_H
-#define ABC_P_H
-
-#include <QObject>
-
-#include <stdio.h>
-
-class AbcP : public QObject
-{
- Q_OBJECT
-public:
- AbcP() {}
-public slots:
- void doAbcP() { printf("I am private abc !\n"); }
-};
-
-#endif
diff --git a/Tests/QtAutogen/complex/calwidget.cpp b/Tests/QtAutogen/complex/calwidget.cpp
deleted file mode 100644
index 380e98238..000000000
--- a/Tests/QtAutogen/complex/calwidget.cpp
+++ /dev/null
@@ -1,436 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the examples of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:BSD$
- ** You may use this file under the terms of the BSD license as follows:
- **
- ** "Redistribution and use in source and binary forms, with or without
- ** modification, are permitted provided that the following conditions are
- ** met:
- ** * Redistributions of source code must retain the above copyright
- ** notice, this list of conditions and the following disclaimer.
- ** * Redistributions in binary form must reproduce the above copyright
- ** notice, this list of conditions and the following disclaimer in
- ** the documentation and/or other materials provided with the
- ** distribution.
- ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
- ** the names of its contributors may be used to endorse or promote
- ** products derived from this software without specific prior written
- ** permission.
- **
- ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
-
-#include <QCalendarWidget>
-#include <QCheckBox>
-#include <QComboBox>
-#include <QDateEdit>
-#include <QGridLayout>
-#include <QGroupBox>
-#include <QLabel>
-#include <QTextCharFormat>
-
-#include "calwidget.h"
-
-#include "ui_calwidget.h"
-#ifdef UI_CALWIDGET_H
-#error Definition of UI_CALWIDGET_H should be disabled by file option.
-#endif
-
-Window::Window()
- : ui(new Ui::Window)
-{
- createPreviewGroupBox();
- createGeneralOptionsGroupBox();
- createDatesGroupBox();
- createTextFormatsGroupBox();
-
- QGridLayout* layout = new QGridLayout;
- layout->addWidget(previewGroupBox, 0, 0);
- layout->addWidget(generalOptionsGroupBox, 0, 1);
- layout->addWidget(datesGroupBox, 1, 0);
- layout->addWidget(textFormatsGroupBox, 1, 1);
- layout->setSizeConstraint(QLayout::SetFixedSize);
- setLayout(layout);
-
- previewLayout->setRowMinimumHeight(0, calendar->sizeHint().height());
- previewLayout->setColumnMinimumWidth(0, calendar->sizeHint().width());
-
- setWindowTitle(tr("Calendar Widget"));
-}
-
-void Window::localeChanged(int index)
-{
- calendar->setLocale(localeCombo->itemData(index).toLocale());
-}
-
-void Window::firstDayChanged(int index)
-{
- calendar->setFirstDayOfWeek(
- Qt::DayOfWeek(firstDayCombo->itemData(index).toInt()));
-}
-
-void Window::selectionModeChanged(int index)
-{
- calendar->setSelectionMode(QCalendarWidget::SelectionMode(
- selectionModeCombo->itemData(index).toInt()));
-}
-
-void Window::horizontalHeaderChanged(int index)
-{
- calendar->setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat(
- horizontalHeaderCombo->itemData(index).toInt()));
-}
-
-void Window::verticalHeaderChanged(int index)
-{
- calendar->setVerticalHeaderFormat(QCalendarWidget::VerticalHeaderFormat(
- verticalHeaderCombo->itemData(index).toInt()));
-}
-
-void Window::selectedDateChanged()
-{
- currentDateEdit->setDate(calendar->selectedDate());
-}
-
-void Window::minimumDateChanged(const QDate& date)
-{
- calendar->setMinimumDate(date);
- maximumDateEdit->setDate(calendar->maximumDate());
-}
-
-void Window::maximumDateChanged(const QDate& date)
-{
- calendar->setMaximumDate(date);
- minimumDateEdit->setDate(calendar->minimumDate());
-}
-
-void Window::weekdayFormatChanged()
-{
- QTextCharFormat format;
-
- format.setForeground(qvariant_cast<QColor>(
- weekdayColorCombo->itemData(weekdayColorCombo->currentIndex())));
- calendar->setWeekdayTextFormat(Qt::Monday, format);
- calendar->setWeekdayTextFormat(Qt::Tuesday, format);
- calendar->setWeekdayTextFormat(Qt::Wednesday, format);
- calendar->setWeekdayTextFormat(Qt::Thursday, format);
- calendar->setWeekdayTextFormat(Qt::Friday, format);
-}
-
-void Window::weekendFormatChanged()
-{
- QTextCharFormat format;
-
- format.setForeground(qvariant_cast<QColor>(
- weekendColorCombo->itemData(weekendColorCombo->currentIndex())));
- calendar->setWeekdayTextFormat(Qt::Saturday, format);
- calendar->setWeekdayTextFormat(Qt::Sunday, format);
-}
-
-void Window::reformatHeaders()
-{
- QString text = headerTextFormatCombo->currentText();
- QTextCharFormat format;
-
- if (text == tr("Bold")) {
- format.setFontWeight(QFont::Bold);
- } else if (text == tr("Italic")) {
- format.setFontItalic(true);
- } else if (text == tr("Green")) {
- format.setForeground(Qt::green);
- }
- calendar->setHeaderTextFormat(format);
-}
-
-void Window::reformatCalendarPage()
-{
- if (firstFridayCheckBox->isChecked()) {
- QDate firstFriday(calendar->yearShown(), calendar->monthShown(), 1);
- while (firstFriday.dayOfWeek() != Qt::Friday)
- firstFriday = firstFriday.addDays(1);
- QTextCharFormat firstFridayFormat;
- firstFridayFormat.setForeground(Qt::blue);
- calendar->setDateTextFormat(firstFriday, firstFridayFormat);
- }
-
- // May First in Red takes precedence
- if (mayFirstCheckBox->isChecked()) {
- const QDate mayFirst(calendar->yearShown(), 5, 1);
- QTextCharFormat mayFirstFormat;
- mayFirstFormat.setForeground(Qt::red);
- calendar->setDateTextFormat(mayFirst, mayFirstFormat);
- }
-}
-
-void Window::createPreviewGroupBox()
-{
- previewGroupBox = new QGroupBox(tr("Preview"));
-
- calendar = new QCalendarWidget;
- calendar->setMinimumDate(QDate(1900, 1, 1));
- calendar->setMaximumDate(QDate(3000, 1, 1));
- calendar->setGridVisible(true);
-
- connect(calendar, SIGNAL(currentPageChanged(int, int)), this,
- SLOT(reformatCalendarPage()));
-
- previewLayout = new QGridLayout;
- previewLayout->addWidget(calendar, 0, 0, Qt::AlignCenter);
- previewGroupBox->setLayout(previewLayout);
-}
-
-void Window::createGeneralOptionsGroupBox()
-{
- generalOptionsGroupBox = new QGroupBox(tr("General Options"));
-
- localeCombo = new QComboBox;
- int curLocaleIndex = -1;
- int index = 0;
- for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) {
- QLocale::Language lang = static_cast<QLocale::Language>(_lang);
- QList<QLocale::Country> countries = QLocale::countriesForLanguage(lang);
- for (int i = 0; i < countries.count(); ++i) {
- QLocale::Country country = countries.at(i);
- QString label = QLocale::languageToString(lang);
- label += QLatin1Char('/');
- label += QLocale::countryToString(country);
- QLocale locale(lang, country);
- if (this->locale().language() == lang &&
- this->locale().country() == country)
- curLocaleIndex = index;
- localeCombo->addItem(label, locale);
- ++index;
- }
- }
- if (curLocaleIndex != -1)
- localeCombo->setCurrentIndex(curLocaleIndex);
- localeLabel = new QLabel(tr("&Locale"));
- localeLabel->setBuddy(localeCombo);
-
- firstDayCombo = new QComboBox;
- firstDayCombo->addItem(tr("Sunday"), Qt::Sunday);
- firstDayCombo->addItem(tr("Monday"), Qt::Monday);
- firstDayCombo->addItem(tr("Tuesday"), Qt::Tuesday);
- firstDayCombo->addItem(tr("Wednesday"), Qt::Wednesday);
- firstDayCombo->addItem(tr("Thursday"), Qt::Thursday);
- firstDayCombo->addItem(tr("Friday"), Qt::Friday);
- firstDayCombo->addItem(tr("Saturday"), Qt::Saturday);
-
- firstDayLabel = new QLabel(tr("Wee&k starts on:"));
- firstDayLabel->setBuddy(firstDayCombo);
-
- selectionModeCombo = new QComboBox;
- selectionModeCombo->addItem(tr("Single selection"),
- QCalendarWidget::SingleSelection);
- selectionModeCombo->addItem(tr("None"), QCalendarWidget::NoSelection);
-
- selectionModeLabel = new QLabel(tr("&Selection mode:"));
- selectionModeLabel->setBuddy(selectionModeCombo);
-
- gridCheckBox = new QCheckBox(tr("&Grid"));
- gridCheckBox->setChecked(calendar->isGridVisible());
-
- navigationCheckBox = new QCheckBox(tr("&Navigation bar"));
- navigationCheckBox->setChecked(true);
-
- horizontalHeaderCombo = new QComboBox;
- horizontalHeaderCombo->addItem(tr("Single letter day names"),
- QCalendarWidget::SingleLetterDayNames);
- horizontalHeaderCombo->addItem(tr("Short day names"),
- QCalendarWidget::ShortDayNames);
- horizontalHeaderCombo->addItem(tr("None"),
- QCalendarWidget::NoHorizontalHeader);
- horizontalHeaderCombo->setCurrentIndex(1);
-
- horizontalHeaderLabel = new QLabel(tr("&Horizontal header:"));
- horizontalHeaderLabel->setBuddy(horizontalHeaderCombo);
-
- verticalHeaderCombo = new QComboBox;
- verticalHeaderCombo->addItem(tr("ISO week numbers"),
- QCalendarWidget::ISOWeekNumbers);
- verticalHeaderCombo->addItem(tr("None"), QCalendarWidget::NoVerticalHeader);
-
- verticalHeaderLabel = new QLabel(tr("&Vertical header:"));
- verticalHeaderLabel->setBuddy(verticalHeaderCombo);
-
- connect(localeCombo, SIGNAL(currentIndexChanged(int)), this,
- SLOT(localeChanged(int)));
- connect(firstDayCombo, SIGNAL(currentIndexChanged(int)), this,
- SLOT(firstDayChanged(int)));
- connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)), this,
- SLOT(selectionModeChanged(int)));
- connect(gridCheckBox, SIGNAL(toggled(bool)), calendar,
- SLOT(setGridVisible(bool)));
- connect(navigationCheckBox, SIGNAL(toggled(bool)), calendar,
- SLOT(setNavigationBarVisible(bool)));
- connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)), this,
- SLOT(horizontalHeaderChanged(int)));
- connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)), this,
- SLOT(verticalHeaderChanged(int)));
-
- QHBoxLayout* checkBoxLayout = new QHBoxLayout;
- checkBoxLayout->addWidget(gridCheckBox);
- checkBoxLayout->addStretch();
- checkBoxLayout->addWidget(navigationCheckBox);
-
- QGridLayout* outerLayout = new QGridLayout;
- outerLayout->addWidget(localeLabel, 0, 0);
- outerLayout->addWidget(localeCombo, 0, 1);
- outerLayout->addWidget(firstDayLabel, 1, 0);
- outerLayout->addWidget(firstDayCombo, 1, 1);
- outerLayout->addWidget(selectionModeLabel, 2, 0);
- outerLayout->addWidget(selectionModeCombo, 2, 1);
- outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2);
- outerLayout->addWidget(horizontalHeaderLabel, 4, 0);
- outerLayout->addWidget(horizontalHeaderCombo, 4, 1);
- outerLayout->addWidget(verticalHeaderLabel, 5, 0);
- outerLayout->addWidget(verticalHeaderCombo, 5, 1);
- generalOptionsGroupBox->setLayout(outerLayout);
-
- firstDayChanged(firstDayCombo->currentIndex());
- selectionModeChanged(selectionModeCombo->currentIndex());
- horizontalHeaderChanged(horizontalHeaderCombo->currentIndex());
- verticalHeaderChanged(verticalHeaderCombo->currentIndex());
-}
-
-void Window::createDatesGroupBox()
-{
- datesGroupBox = new QGroupBox(tr("Dates"));
-
- minimumDateEdit = new QDateEdit;
- minimumDateEdit->setDisplayFormat("MMM d yyyy");
- minimumDateEdit->setDateRange(calendar->minimumDate(),
- calendar->maximumDate());
- minimumDateEdit->setDate(calendar->minimumDate());
-
- minimumDateLabel = new QLabel(tr("&Minimum Date:"));
- minimumDateLabel->setBuddy(minimumDateEdit);
-
- currentDateEdit = new QDateEdit;
- currentDateEdit->setDisplayFormat("MMM d yyyy");
- currentDateEdit->setDate(calendar->selectedDate());
- currentDateEdit->setDateRange(calendar->minimumDate(),
- calendar->maximumDate());
-
- currentDateLabel = new QLabel(tr("&Current Date:"));
- currentDateLabel->setBuddy(currentDateEdit);
-
- maximumDateEdit = new QDateEdit;
- maximumDateEdit->setDisplayFormat("MMM d yyyy");
- maximumDateEdit->setDateRange(calendar->minimumDate(),
- calendar->maximumDate());
- maximumDateEdit->setDate(calendar->maximumDate());
-
- maximumDateLabel = new QLabel(tr("Ma&ximum Date:"));
- maximumDateLabel->setBuddy(maximumDateEdit);
-
- connect(currentDateEdit, SIGNAL(dateChanged(QDate)), calendar,
- SLOT(setSelectedDate(QDate)));
- connect(calendar, SIGNAL(selectionChanged()), this,
- SLOT(selectedDateChanged()));
- connect(minimumDateEdit, SIGNAL(dateChanged(QDate)), this,
- SLOT(minimumDateChanged(QDate)));
- connect(maximumDateEdit, SIGNAL(dateChanged(QDate)), this,
- SLOT(maximumDateChanged(QDate)));
-
- QGridLayout* dateBoxLayout = new QGridLayout;
- dateBoxLayout->addWidget(currentDateLabel, 1, 0);
- dateBoxLayout->addWidget(currentDateEdit, 1, 1);
- dateBoxLayout->addWidget(minimumDateLabel, 0, 0);
- dateBoxLayout->addWidget(minimumDateEdit, 0, 1);
- dateBoxLayout->addWidget(maximumDateLabel, 2, 0);
- dateBoxLayout->addWidget(maximumDateEdit, 2, 1);
- dateBoxLayout->setRowStretch(3, 1);
-
- datesGroupBox->setLayout(dateBoxLayout);
-}
-
-void Window::createTextFormatsGroupBox()
-{
- textFormatsGroupBox = new QGroupBox(tr("Text Formats"));
-
- weekdayColorCombo = createColorComboBox();
- weekdayColorCombo->setCurrentIndex(weekdayColorCombo->findText(tr("Black")));
-
- weekdayColorLabel = new QLabel(tr("&Weekday color:"));
- weekdayColorLabel->setBuddy(weekdayColorCombo);
-
- weekendColorCombo = createColorComboBox();
- weekendColorCombo->setCurrentIndex(weekendColorCombo->findText(tr("Red")));
-
- weekendColorLabel = new QLabel(tr("Week&end color:"));
- weekendColorLabel->setBuddy(weekendColorCombo);
-
- headerTextFormatCombo = new QComboBox;
- headerTextFormatCombo->addItem(tr("Bold"));
- headerTextFormatCombo->addItem(tr("Italic"));
- headerTextFormatCombo->addItem(tr("Plain"));
-
- headerTextFormatLabel = new QLabel(tr("&Header text:"));
- headerTextFormatLabel->setBuddy(headerTextFormatCombo);
-
- firstFridayCheckBox = new QCheckBox(tr("&First Friday in blue"));
-
- mayFirstCheckBox = new QCheckBox(tr("May &1 in red"));
-
- connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)), this,
- SLOT(weekdayFormatChanged()));
- connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)), this,
- SLOT(weekendFormatChanged()));
- connect(headerTextFormatCombo, SIGNAL(currentIndexChanged(QString)), this,
- SLOT(reformatHeaders()));
- connect(firstFridayCheckBox, SIGNAL(toggled(bool)), this,
- SLOT(reformatCalendarPage()));
- connect(mayFirstCheckBox, SIGNAL(toggled(bool)), this,
- SLOT(reformatCalendarPage()));
-
- QHBoxLayout* checkBoxLayout = new QHBoxLayout;
- checkBoxLayout->addWidget(firstFridayCheckBox);
- checkBoxLayout->addStretch();
- checkBoxLayout->addWidget(mayFirstCheckBox);
-
- QGridLayout* outerLayout = new QGridLayout;
- outerLayout->addWidget(weekdayColorLabel, 0, 0);
- outerLayout->addWidget(weekdayColorCombo, 0, 1);
- outerLayout->addWidget(weekendColorLabel, 1, 0);
- outerLayout->addWidget(weekendColorCombo, 1, 1);
- outerLayout->addWidget(headerTextFormatLabel, 2, 0);
- outerLayout->addWidget(headerTextFormatCombo, 2, 1);
- outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2);
- textFormatsGroupBox->setLayout(outerLayout);
-
- weekdayFormatChanged();
- weekendFormatChanged();
- reformatHeaders();
- reformatCalendarPage();
-}
-
-QComboBox* Window::createColorComboBox()
-{
- QComboBox* comboBox = new QComboBox;
- comboBox->addItem(tr("Red"), QColor(Qt::red));
- comboBox->addItem(tr("Blue"), QColor(Qt::blue));
- comboBox->addItem(tr("Black"), QColor(Qt::black));
- comboBox->addItem(tr("Magenta"), QColor(Qt::magenta));
- return comboBox;
-}
-
-//#include "moc_calwidget.cpp"
diff --git a/Tests/QtAutogen/complex/codeeditor.cpp b/Tests/QtAutogen/complex/codeeditor.cpp
deleted file mode 100644
index 0caf8a7df..000000000
--- a/Tests/QtAutogen/complex/codeeditor.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the examples of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:BSD$
- ** You may use this file under the terms of the BSD license as follows:
- **
- ** "Redistribution and use in source and binary forms, with or without
- ** modification, are permitted provided that the following conditions are
- ** met:
- ** * Redistributions of source code must retain the above copyright
- ** notice, this list of conditions and the following disclaimer.
- ** * Redistributions in binary form must reproduce the above copyright
- ** notice, this list of conditions and the following disclaimer in
- ** the documentation and/or other materials provided with the
- ** distribution.
- ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
- ** the names of its contributors may be used to endorse or promote
- ** products derived from this software without specific prior written
- ** permission.
- **
- ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
-
-#include <QtGui>
-
-#include "codeeditor.h"
-
-CodeEditor::CodeEditor(QWidget* parent)
- : QPlainTextEdit(parent)
-{
- lineNumberArea = new LineNumberArea(this);
-
- connect(this, SIGNAL(blockCountChanged(int)), this,
- SLOT(updateLineNumberAreaWidth(int)));
- connect(this, SIGNAL(updateRequest(QRect, int)), this,
- SLOT(updateLineNumberArea(QRect, int)));
- connect(this, SIGNAL(cursorPositionChanged()), this,
- SLOT(highlightCurrentLine()));
-
- updateLineNumberAreaWidth(0);
- highlightCurrentLine();
-}
-
-int CodeEditor::lineNumberAreaWidth()
-{
- int digits = 1;
- int max = qMax(1, blockCount());
- while (max >= 10) {
- max /= 10;
- ++digits;
- }
-
- int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
-
- return space;
-}
-
-void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */)
-{
- setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
-}
-
-void CodeEditor::updateLineNumberArea(const QRect& rect, int dy)
-{
- if (dy)
- lineNumberArea->scroll(0, dy);
- else
- lineNumberArea->update(0, rect.y(), lineNumberArea->width(),
- rect.height());
-
- if (rect.contains(viewport()->rect()))
- updateLineNumberAreaWidth(0);
-}
-
-void CodeEditor::resizeEvent(QResizeEvent* e)
-{
- QPlainTextEdit::resizeEvent(e);
-
- QRect cr = contentsRect();
- lineNumberArea->setGeometry(
- QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
-}
-
-void CodeEditor::highlightCurrentLine()
-{
- QList<QTextEdit::ExtraSelection> extraSelections;
-
- if (!isReadOnly()) {
- QTextEdit::ExtraSelection selection;
-
- QColor lineColor = QColor(Qt::yellow).lighter(160);
-
- selection.format.setBackground(lineColor);
- selection.format.setProperty(QTextFormat::FullWidthSelection, true);
- selection.cursor = textCursor();
- selection.cursor.clearSelection();
- extraSelections.append(selection);
- }
-
- setExtraSelections(extraSelections);
-}
-
-void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent* event)
-{
- QPainter painter(lineNumberArea);
- painter.fillRect(event->rect(), Qt::lightGray);
-
- QTextBlock block = firstVisibleBlock();
- int blockNumber = block.blockNumber();
- int top =
- (int)blockBoundingGeometry(block).translated(contentOffset()).top();
- int bottom = top + (int)blockBoundingRect(block).height();
-
- while (block.isValid() && top <= event->rect().bottom()) {
- if (block.isVisible() && bottom >= event->rect().top()) {
- QString number = QString::number(blockNumber + 1);
- painter.setPen(Qt::black);
- painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(),
- Qt::AlignRight, number);
- }
-
- block = block.next();
- top = bottom;
- bottom = top + (int)blockBoundingRect(block).height();
- ++blockNumber;
- }
-}
-
-#include "codeeditor.moc"
diff --git a/Tests/QtAutogen/complex/debug_class.cpp b/Tests/QtAutogen/complex/debug_class.cpp
deleted file mode 100644
index 46b09e705..000000000
--- a/Tests/QtAutogen/complex/debug_class.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-
-#include "debug_class.h"
-#include "ui_debug_class.h"
-
-DebugClass::DebugClass(QWidget* parent)
- : QWidget(parent)
- , ui(new Ui::DebugClass)
-{
- ui->setupUi(this);
-}
diff --git a/Tests/QtAutogen/complex/generated.h b/Tests/QtAutogen/complex/generated.h
deleted file mode 100644
index 62e1607bf..000000000
--- a/Tests/QtAutogen/complex/generated.h
+++ /dev/null
@@ -1,18 +0,0 @@
-
-#ifndef GENERATED_H
-#define GENERATED_H
-
-#include <QObject>
-
-#include "myinterface.h"
-#include "myotherinterface.h"
-
-class Generated : public QObject, MyInterface, MyOtherInterface
-{
- Q_OBJECT
- Q_INTERFACES(MyInterface MyOtherInterface)
-public:
- explicit Generated(QObject* parent = 0);
-};
-
-#endif
diff --git a/Tests/QtAutogen/complex/libC.h b/Tests/QtAutogen/complex/libC.h
deleted file mode 100644
index 3bc2bad54..000000000
--- a/Tests/QtAutogen/complex/libC.h
+++ /dev/null
@@ -1,22 +0,0 @@
-
-#ifndef LIBC_H
-#define LIBC_H
-
-#include "libc_export.h"
-
-#include "libB.h"
-#include <QObject>
-
-class LIBC_EXPORT LibC : public QObject
-{
- Q_OBJECT
-public:
- explicit LibC(QObject* parent = 0);
-
- int foo();
-
-private:
- LibB b;
-};
-
-#endif
diff --git a/Tests/QtAutogen/complex/main.cpp b/Tests/QtAutogen/complex/main.cpp
deleted file mode 100644
index d557c70b3..000000000
--- a/Tests/QtAutogen/complex/main.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
- **
- ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
- ** All rights reserved.
- ** Contact: Nokia Corporation (qt-info@nokia.com)
- **
- ** This file is part of the examples of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:BSD$
- ** You may use this file under the terms of the BSD license as follows:
- **
- ** "Redistribution and use in source and binary forms, with or without
- ** modification, are permitted provided that the following conditions are
- ** met:
- ** * Redistributions of source code must retain the above copyright
- ** notice, this list of conditions and the following disclaimer.
- ** * Redistributions in binary form must reproduce the above copyright
- ** notice, this list of conditions and the following disclaimer in
- ** the documentation and/or other materials provided with the
- ** distribution.
- ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
- ** the names of its contributors may be used to endorse or promote
- ** products derived from this software without specific prior written
- ** permission.
- **
- ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
-
-#include <QCoreApplication>
-#include <QTimer>
-
-#include "abc.h"
-#include "blub.h"
-#include "calwidget.h"
-#include "codeeditor.h"
-#include "foo.h"
-#include "libC.h"
-#include "resourcetester.h"
-#include "sub/bar.h"
-#include "xyz.h"
-#include "yaf.h"
-#ifdef TEST_DEBUG_CLASS
-#include "debug_class.h"
-#include <iostream>
-#endif
-
-int main(int argv, char** args)
-{
- QCoreApplication app(argv, args);
-
- Foo foo;
- foo.doFoo();
-
- Blub b;
- b.blubber();
-
- Bar bar;
- bar.doBar();
-
- Abc abc;
- abc.doAbc();
-
- Xyz xyz;
- xyz.doXyz();
-
- Yaf yaf;
- yaf.doYaf();
-
- LibC lc;
- lc.foo();
-
- ResourceTester rt;
-
- QTimer::singleShot(0, &rt, SLOT(doTest()));
-
-#ifdef TEST_DEBUG_CLASS
- std::cout << DebugClass::staticMetaObject.className() << std::endl;
-#endif
-
- return app.exec();
-}
diff --git a/Tests/QtAutogen/complex/second_widget.cpp b/Tests/QtAutogen/complex/second_widget.cpp
deleted file mode 100644
index c575f1013..000000000
--- a/Tests/QtAutogen/complex/second_widget.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-
-#include "second_widget.h"
-#include "ui_second_widget.h"
-
-SecondWidget::SecondWidget(QWidget* parent)
- : QWidget(parent)
- , ui(new Ui::SecondWidget)
-{
- ui->setupUi(this);
-}
-
-SecondWidget::~SecondWidget()
-{
- delete ui;
-}
diff --git a/Tests/QtAutogen/complex/yaf.cpp b/Tests/QtAutogen/complex/yaf.cpp
deleted file mode 100644
index 70e26aa95..000000000
--- a/Tests/QtAutogen/complex/yaf.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "yaf.h"
-#include "yaf_p.h"
-
-#include <stdio.h>
-
-Yaf::Yaf()
-{
-}
-
-void Yaf::doYaf()
-{
- YafP yafP;
- yafP.doYafP();
-}
-
-// check that including a moc file from a private header the wrong way works:
-#include "yaf_p.moc"
diff --git a/Tests/QtAutogen/complex/yaf_p.h b/Tests/QtAutogen/complex/yaf_p.h
deleted file mode 100644
index ea5eed69c..000000000
--- a/Tests/QtAutogen/complex/yaf_p.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef YAF_P_H
-#define YAF_P_H
-
-#include <QObject>
-
-#include <stdio.h>
-
-class YafP : public QObject
-{
- Q_OBJECT
-public:
- YafP() {}
-public slots:
- void doYafP() { printf("I am yet another file !\n"); }
-};
-
-#endif
diff --git a/Tests/QtAutogen/defines_test/CMakeLists.txt b/Tests/QtAutogen/defines_test/CMakeLists.txt
deleted file mode 100644
index 9ee9a228a..000000000
--- a/Tests/QtAutogen/defines_test/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-
-add_executable(defines_test defines_test.cpp)
-set_target_properties(defines_test PROPERTIES AUTOMOC TRUE)
-target_link_libraries(defines_test Qt4::QtGui)
diff --git a/Tests/QtAutogen/defines_test/defines_test.cpp b/Tests/QtAutogen/defines_test/defines_test.cpp
deleted file mode 100644
index cf4e9cb5b..000000000
--- a/Tests/QtAutogen/defines_test/defines_test.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-
-#include <QObject>
-
-#ifdef QT_GUI_LIB
-#include <QTextDocument>
-
-class SomeDocument : public QTextDocument
-{
- Q_OBJECT
-
-Q_SIGNALS:
- void someSig();
-};
-#endif
-
-#ifdef QT_CORE_LIB
-class SomeObject : public QObject
-{
- Q_OBJECT
-
-Q_SIGNALS:
- void someSig();
-};
-#endif
-
-int main(int argc, char** argv)
-{
-#ifdef QT_CORE_LIB
- QMetaObject sosmo = SomeObject::staticMetaObject;
-#endif
-#ifdef QT_GUI_LIB
- QMetaObject sdsmo = SomeDocument::staticMetaObject;
-#endif
-
- return 0;
-}
-
-#include "defines_test.moc"
diff --git a/Tests/QtAutogen/mocDepends/CMakeLists.txt b/Tests/QtAutogen/mocDepends/CMakeLists.txt
deleted file mode 100644
index 6241ef93d..000000000
--- a/Tests/QtAutogen/mocDepends/CMakeLists.txt
+++ /dev/null
@@ -1,151 +0,0 @@
-cmake_minimum_required(VERSION 3.9)
-project(mocDepends CXX)
-
-if (QT_TEST_VERSION STREQUAL 4)
- find_package(Qt4 REQUIRED)
- set(QT_CORE_TARGET Qt4::QtCore)
-else()
- if (NOT QT_TEST_VERSION STREQUAL 5)
- message(SEND_ERROR "Invalid Qt version specified.")
- endif()
-
- find_package(Qt5Core REQUIRED)
- set(QT_CORE_TARGET Qt5::Core)
-endif()
-
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-set(CSD ${CMAKE_CURRENT_SOURCE_DIR})
-set(CBD ${CMAKE_CURRENT_BINARY_DIR})
-
-# -- Test dependency on header generated by a custom command
-#
-# The ORIGIN_autogen target must depend on the same *GENERATED* source files as
-# the ORIGIN target. This is a requirement to ensure that all files for the
-# ORIGIN target are generated before the ORIGIN_autogen target is built.
-#
-# This tests the dependency of the mocDepGenFile_autogen target of
-# mocDepGenFile to the source file GenFile.hpp, which is *GENERATED*
-# by a custom command.
-# If mocDepGenFile_autogen gets built *before* or in *parallel* to the
-# custom command, the build will fail. That's because GenFile.hpp,
-# which is required by mocDepGenFile_autogen, is only valid after the
-# custom command has been completed.
-#
-# The sleep seconds artificially increase the build time of the custom command
-# to simulate a slow file generation process that takes longer to run than
-# the build of the mocDepGenFile_autogen target.
-add_custom_command(
- OUTPUT ${CBD}/GenFile.hpp
- COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/GenFile.hpp
- COMMAND ${CMAKE_COMMAND} -E sleep 3
- COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/GenFile.hpp)
-
-add_executable(mocDepGenFile testGenFile.cpp ${CBD}/GenFile.hpp)
-target_link_libraries(mocDepGenFile ${QT_CORE_TARGET})
-set_target_properties(mocDepGenFile PROPERTIES AUTOMOC TRUE)
-set_property(TARGET mocDepGenFile PROPERTY __UNDOCUMENTED_AUTOGEN_GENERATED_FILES 1)
-
-
-# -- Test dependency on header generating custom target
-#
-# The ORIGIN_autogen target must depend on the same user defined targets
-# as the ORIGIN target. This is a requirement to ensure that all files for the
-# ORIGIN target are generated before the ORIGIN_autogen target is built.
-#
-# This tests the dependency of the mocDepTarget_autogen target of
-# mocDepTarget to the utility target mocDepTargetUtil.
-# If mocDepTarget_autogen gets built *before* or in *parallel* to
-# mocDepTargetUtil, the build will fail. That's
-# because GenTarget.hpp, which is required by mocDepTarget_autogen,
-# is only valid after the mocDepTargetUtil build has been completed.
-#
-# The sleep seconds artificially increase the build time of mocDepTargetUtil
-# to simulate a slow utility target build that takes longer to run than
-# the build of the mocDepTarget_autogen target.
-add_custom_target(mocDepTargetUtil
- BYPRODUCTS ${CBD}/GenTarget.hpp
- COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/GenTarget.hpp
- COMMAND ${CMAKE_COMMAND} -E sleep 3
- COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/GenTarget.hpp)
-
-add_executable(mocDepTarget testGenTarget.cpp)
-target_link_libraries(mocDepTarget ${QT_CORE_TARGET})
-set_target_properties(mocDepTarget PROPERTIES AUTOMOC TRUE)
-add_dependencies(mocDepTarget mocDepTargetUtil)
-
-
-# -- Test 3: Depend on generated linked library
-# The ORIGIN_autogen target must depend on the same linked libraries
-# as the ORIGIN target. This is a requirement to ensure that all files for the
-# ORIGIN target are generated before the ORIGIN_autogen target is built.
-#
-# This tests the dependency of the mocDepGenLib_autogen target of mocDepGenLib
-# to the user generated library SimpleLib, which mocDepGenLib links to.
-# If mocDepGenLib_autogen gets built *before* or in *parallel* to SimpleLib,
-# the build will fail. That's because simpleLib.hpp, which is required by
-# mocDepGenLib_autogen, is only valid after the SimpleLib build has been
-# completed.
-#
-# The sleep seconds artificially increase the build time of SimpleLib
-# to simulate a slow utility library build that takes longer to run than
-# the build of the mocDepGenLib_autogen target.
-add_custom_command(
- OUTPUT ${CBD}/simpleLib.hpp ${CBD}/simpleLib.cpp
- COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/simpleLib.hpp
- COMMAND ${CMAKE_COMMAND} -E sleep 3
- COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/simpleLib.hpp.in ${CBD}/simpleLib.hpp
- COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/simpleLib.cpp.in ${CBD}/simpleLib.cpp)
-add_library(SimpleLib STATIC ${CBD}/simpleLib.hpp ${CBD}/simpleLib.cpp)
-target_link_libraries(SimpleLib ${QT_CORE_TARGET})
-
-add_executable(mocDepGenLib testGenLib.cpp)
-target_link_libraries(mocDepGenLib SimpleLib ${QT_CORE_TARGET})
-set_target_properties(mocDepGenLib PROPERTIES AUTOMOC TRUE)
-
-
-# -- Test AUTOGEN_TARGET_DEPENDS with GENERATED file dependency
-#
-# This tests the dependency of the mocDepATDFile_autogen target of
-# mocDepATDTarget to the utility target mocDepATDFileUtil.
-# If mocDepATDFile_autogen gets built *before* or in *parallel* to
-# mocDepATDFileUtil, the build will fail. That's
-# because ATDFile.hpp, which is required by mocDepATDFile_autogen,
-# is only valid after the mocDepATDFileUtil build has been completed.
-#
-# The sleep seconds artificially increase the build time of
-# mocDepATDFileUtil to simulate a slow utility target build that takes
-# longer to run than the build of the mocDepATDFile_autogen target.
-add_custom_command(
- OUTPUT ${CBD}/ATDFile.hpp
- COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/ATDFile.hpp
- COMMAND ${CMAKE_COMMAND} -E sleep 3
- COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/ATDFile.hpp)
-
-add_executable(mocDepATDFile testATDFile.cpp)
-target_link_libraries(mocDepATDFile ${QT_CORE_TARGET})
-set_target_properties(mocDepATDFile PROPERTIES AUTOMOC TRUE)
-set_target_properties(mocDepATDFile PROPERTIES AUTOGEN_TARGET_DEPENDS ${CBD}/ATDFile.hpp)
-
-
-# -- Test AUTOGEN_TARGET_DEPENDS with target dependency
-#
-# This tests the dependency of the mocDepATDTarget_autogen target of
-# mocDepATDTarget to the utility target mocDepATDTargetUtil.
-# If mocDepATDTarget_autogen gets built *before* or in *parallel* to
-# mocDepATDTargetUtil, the build will fail. That's
-# because ATDTarget.hpp, which is required by mocDepATDTarget_autogen,
-# is only valid after the mocDepATDTargetUtil build has been completed.
-#
-# The sleep seconds artificially increase the build time of
-# mocDepATDTargetUtil to simulate a slow utility target build that takes
-# longer to run than the build of the mocDepATDTarget_autogen target.
-add_custom_target(mocDepATDTargetUtil
- BYPRODUCTS ${CBD}/ATDTarget.hpp
- COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_invalid.hpp.in ${CBD}/ATDTarget.hpp
- COMMAND ${CMAKE_COMMAND} -E sleep 3
- COMMAND ${CMAKE_COMMAND} -E copy ${CSD}/object_valid.hpp.in ${CBD}/ATDTarget.hpp)
-
-add_executable(mocDepATDTarget testATDTarget.cpp)
-target_link_libraries(mocDepATDTarget ${QT_CORE_TARGET})
-set_target_properties(mocDepATDTarget PROPERTIES AUTOMOC TRUE)
-set_target_properties(mocDepATDTarget PROPERTIES AUTOGEN_TARGET_DEPENDS mocDepATDTargetUtil)
diff --git a/Tests/QtAutogen/mocDepends/testGenLib.hpp b/Tests/QtAutogen/mocDepends/testGenLib.hpp
deleted file mode 100644
index 408335bd2..000000000
--- a/Tests/QtAutogen/mocDepends/testGenLib.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef TEST3_HPP
-#define TEST3_HPP
-
-#include "simpleLib.hpp"
-#include <QObject>
-
-// This object triggers the AUTOMOC on this file
-class LObject : public QObject
-{
- Q_OBJECT
-public:
- Q_SLOT
- void aSlot(){};
-};
-
-#endif
diff --git a/Tests/QtAutogen/mocInclude/ObjA.cpp b/Tests/QtAutogen/mocInclude/ObjA.cpp
deleted file mode 100644
index 1b0311d30..000000000
--- a/Tests/QtAutogen/mocInclude/ObjA.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "ObjA.hpp"
-
-class SubObjA : public QObject
-{
- Q_OBJECT
-
-public:
- SubObjA() {}
- ~SubObjA() {}
-
- Q_SLOT
- void aSlot();
-};
-
-void SubObjA::aSlot()
-{
-}
-
-void ObjA::go()
-{
- SubObjA subObj;
-}
-
-#include "ObjA.moc"
diff --git a/Tests/QtAutogen/mocInclude/ObjA.hpp b/Tests/QtAutogen/mocInclude/ObjA.hpp
deleted file mode 100644
index 281e90d86..000000000
--- a/Tests/QtAutogen/mocInclude/ObjA.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef OBJA_HPP
-#define OBJA_HPP
-
-#include <QObject>
-
-class ObjA : public QObject
-{
- Q_OBJECT
- Q_SLOT
- void go();
-};
-
-#endif
diff --git a/Tests/QtAutogen/mocInclude/ObjB.cpp b/Tests/QtAutogen/mocInclude/ObjB.cpp
deleted file mode 100644
index 5ff315dc7..000000000
--- a/Tests/QtAutogen/mocInclude/ObjB.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "ObjB.hpp"
-
-class SubObjB : public QObject
-{
- Q_OBJECT
-
-public:
- SubObjB() {}
- ~SubObjB() {}
-
- Q_SLOT
- void aSlot();
-};
-
-void SubObjB::aSlot()
-{
-}
-
-void ObjB::go()
-{
- SubObjB subObj;
-}
-
-#include "ObjB.moc"
-#include "moc_ObjB.cpp"
diff --git a/Tests/QtAutogen/mocInclude/ObjB.hpp b/Tests/QtAutogen/mocInclude/ObjB.hpp
deleted file mode 100644
index 94f3d498c..000000000
--- a/Tests/QtAutogen/mocInclude/ObjB.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef OBJB_HPP
-#define OBJB_HPP
-
-#include <QObject>
-
-class ObjB : public QObject
-{
- Q_OBJECT
- Q_SLOT
- void go();
-};
-
-#endif
diff --git a/Tests/QtAutogen/mocInclude/ObjC.cpp b/Tests/QtAutogen/mocInclude/ObjC.cpp
deleted file mode 100644
index 8ca34cbb4..000000000
--- a/Tests/QtAutogen/mocInclude/ObjC.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "ObjC.hpp"
-
-class SubObjC : public QObject
-{
- Q_OBJECT
-
-public:
- SubObjC() {}
- ~SubObjC() {}
-
- Q_SLOT
- void aSlot();
-};
-
-void SubObjC::aSlot()
-{
-}
-
-void ObjC::go()
-{
- SubObjC subObj;
-}
-
-#include "ObjC.moc"
-// Not the own header
-#include "moc_ObjD.cpp"
diff --git a/Tests/QtAutogen/mocInclude/ObjC.hpp b/Tests/QtAutogen/mocInclude/ObjC.hpp
deleted file mode 100644
index a8e98eb1e..000000000
--- a/Tests/QtAutogen/mocInclude/ObjC.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef OBJC_HPP
-#define OBJC_HPP
-
-#include <QObject>
-
-class ObjC : public QObject
-{
- Q_OBJECT
- Q_SLOT
- void go();
-};
-
-#endif
diff --git a/Tests/QtAutogen/mocInclude/ObjD.cpp b/Tests/QtAutogen/mocInclude/ObjD.cpp
deleted file mode 100644
index c18aec152..000000000
--- a/Tests/QtAutogen/mocInclude/ObjD.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "ObjD.hpp"
-
-class SubObjD : public QObject
-{
- Q_OBJECT
-
-public:
- SubObjD() {}
- ~SubObjD() {}
-
- Q_SLOT
- void aSlot();
-};
-
-void SubObjD::aSlot()
-{
-}
-
-void ObjD::go()
-{
- SubObjD subObj;
-}
-
-#include "ObjD.moc"
-// Header in subdirectory
-#include "subA/moc_SubObjA.cpp"
diff --git a/Tests/QtAutogen/mocInclude/ObjD.hpp b/Tests/QtAutogen/mocInclude/ObjD.hpp
deleted file mode 100644
index b6ee09808..000000000
--- a/Tests/QtAutogen/mocInclude/ObjD.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef OBJD_HPP
-#define OBJD_HPP
-
-#include <QObject>
-
-class ObjD : public QObject
-{
- Q_OBJECT
- Q_SLOT
- void go();
-};
-
-#endif
diff --git a/Tests/QtAutogen/mocInclude/subA/SubObjA.cpp b/Tests/QtAutogen/mocInclude/subA/SubObjA.cpp
deleted file mode 100644
index a05f6e37e..000000000
--- a/Tests/QtAutogen/mocInclude/subA/SubObjA.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "SubObjA.hpp"
-
-namespace subA {
-
-class SubObjA : public QObject
-{
- Q_OBJECT
-
-public:
- SubObjA() {}
- ~SubObjA() {}
-
- Q_SLOT
- void aSlot();
-};
-
-void SubObjA::aSlot()
-{
-}
-
-void ObjA::go()
-{
- SubObjA subObj;
-}
-}
-
-#include "SubObjA.moc"
diff --git a/Tests/QtAutogen/mocInclude/subA/SubObjA.hpp b/Tests/QtAutogen/mocInclude/subA/SubObjA.hpp
deleted file mode 100644
index 31a18b618..000000000
--- a/Tests/QtAutogen/mocInclude/subA/SubObjA.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef SUBOBJA_HPP
-#define SUBOBJA_HPP
-
-#include <QObject>
-
-namespace subA {
-
-class ObjA : public QObject
-{
- Q_OBJECT
- Q_SLOT
- void go();
-};
-}
-
-#endif
diff --git a/Tests/QtAutogen/mocInclude/subB/SubObjB.cpp b/Tests/QtAutogen/mocInclude/subB/SubObjB.cpp
deleted file mode 100644
index 1e77639b2..000000000
--- a/Tests/QtAutogen/mocInclude/subB/SubObjB.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "SubObjB.hpp"
-
-namespace subB {
-
-class SubObjB : public QObject
-{
- Q_OBJECT
-
-public:
- SubObjB() {}
- ~SubObjB() {}
-
- Q_SLOT
- void aSlot();
-};
-
-void SubObjB::aSlot()
-{
-}
-
-void ObjB::go()
-{
- SubObjB subObj;
-}
-}
-
-#include "SubObjB.moc"
diff --git a/Tests/QtAutogen/mocInclude/subB/SubObjB.hpp b/Tests/QtAutogen/mocInclude/subB/SubObjB.hpp
deleted file mode 100644
index 3f29fa289..000000000
--- a/Tests/QtAutogen/mocInclude/subB/SubObjB.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef SUBOBJB_HPP
-#define SUBOBJB_HPP
-
-#include <QObject>
-
-namespace subB {
-
-class ObjB : public QObject
-{
- Q_OBJECT
- Q_SLOT
- void go();
-};
-}
-
-#endif
diff --git a/Tests/QtAutogen/mocInclude/subC/SubObjC.cpp b/Tests/QtAutogen/mocInclude/subC/SubObjC.cpp
deleted file mode 100644
index c2d94ef26..000000000
--- a/Tests/QtAutogen/mocInclude/subC/SubObjC.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "SubObjC.hpp"
-
-namespace subC {
-
-class SubObjC : public QObject
-{
- Q_OBJECT
-
-public:
- SubObjC() {}
- ~SubObjC() {}
-
- Q_SLOT
- void aSlot();
-};
-
-void SubObjC::aSlot()
-{
-}
-
-void ObjC::go()
-{
- SubObjC subObj;
-}
-}
-
-#include "SubObjC.moc"
diff --git a/Tests/QtAutogen/mocInclude/subC/SubObjC.hpp b/Tests/QtAutogen/mocInclude/subC/SubObjC.hpp
deleted file mode 100644
index dc251fd61..000000000
--- a/Tests/QtAutogen/mocInclude/subC/SubObjC.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef SUBOBJC_HPP
-#define SUBOBJC_HPP
-
-#include <QObject>
-
-namespace subC {
-
-class ObjC : public QObject
-{
- Q_OBJECT
- Q_SLOT
- void go();
-};
-}
-
-#endif
diff --git a/Tests/QtAutogen/mocIncludeRelaxed/CMakeLists.txt b/Tests/QtAutogen/mocIncludeRelaxed/CMakeLists.txt
deleted file mode 100644
index 6a0829df7..000000000
--- a/Tests/QtAutogen/mocIncludeRelaxed/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-# Test moc include patterns
-
-set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
-
-include_directories("../mocInclude")
-
-add_executable(mocIncludeRelaxed
- ../mocInclude/ObjA.cpp
- ../mocInclude/ObjB.cpp
- ../mocInclude/ObjC.cpp
- ../mocInclude/ObjD.cpp
- ../mocInclude/subA/SubObjA.cpp
- ../mocInclude/subB/SubObjB.cpp
- ../mocInclude/subC/SubObjC.cpp
- main.cpp
-)
-target_link_libraries(mocIncludeRelaxed ${QT_LIBRARIES})
-set_target_properties(mocIncludeRelaxed PROPERTIES AUTOMOC ON)
diff --git a/Tests/QtAutogen/mocIncludeRelaxed/main.cpp b/Tests/QtAutogen/mocIncludeRelaxed/main.cpp
deleted file mode 100644
index 142d59e69..000000000
--- a/Tests/QtAutogen/mocIncludeRelaxed/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "ObjA.hpp"
-#include "ObjB.hpp"
-#include "ObjC.hpp"
-
-int main(int argv, char** args)
-{
- ObjA objA;
- ObjB objB;
- ObjC objC;
- return 0;
-}
-
-// Header in global subdirectory
-#include "subB/moc_SubObjB.cpp"
diff --git a/Tests/QtAutogen/mocIncludeStrict/CMakeLists.txt b/Tests/QtAutogen/mocIncludeStrict/CMakeLists.txt
deleted file mode 100644
index 22e93a8ba..000000000
--- a/Tests/QtAutogen/mocIncludeStrict/CMakeLists.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-# Test moc include patterns
-
-set(CMAKE_AUTOMOC_RELAXED_MODE FALSE)
-
-include_directories("../mocInclude")
-
-add_executable(mocIncludeStrict
- ../mocInclude/ObjA.cpp
- ../mocInclude/ObjB.cpp
- ../mocInclude/ObjC.cpp
- ../mocInclude/ObjD.cpp
- ../mocInclude/subA/SubObjA.cpp
- ../mocInclude/subB/SubObjB.cpp
- ../mocInclude/subC/SubObjC.cpp
- main.cpp
-)
-target_link_libraries(mocIncludeStrict ${QT_LIBRARIES})
-set_target_properties(mocIncludeStrict PROPERTIES AUTOMOC ON)
diff --git a/Tests/QtAutogen/mocIncludeStrict/main.cpp b/Tests/QtAutogen/mocIncludeStrict/main.cpp
deleted file mode 100644
index 142d59e69..000000000
--- a/Tests/QtAutogen/mocIncludeStrict/main.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "ObjA.hpp"
-#include "ObjB.hpp"
-#include "ObjC.hpp"
-
-int main(int argv, char** args)
-{
- ObjA objA;
- ObjB objB;
- ObjC objC;
- return 0;
-}
-
-// Header in global subdirectory
-#include "subB/moc_SubObjB.cpp"
diff --git a/Tests/QtAutogen/mocPlugin/CMakeLists.txt b/Tests/QtAutogen/mocPlugin/CMakeLists.txt
deleted file mode 100644
index f80aa2934..000000000
--- a/Tests/QtAutogen/mocPlugin/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-cmake_minimum_required(VERSION 3.8)
-project(mocPlugin CXX)
-
-set(CMAKE_AUTOMOC_DEPEND_FILTERS
- "A_CUSTOM_MACRO"
- "[\n][ \t]*A_CUSTOM_MACRO[ \t\r\n]*\\([^,]+,[ \t\r\n]*\"([^\"]+)\""
- )
-
-if (NOT QT_TEST_VERSION STREQUAL 5)
- message(SEND_ERROR "Invalid Qt version specified.")
-endif()
-find_package(Qt5Widgets REQUIRED)
-
-if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC)
- add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC})
-endif()
-
-configure_file(jsonIn/StyleC.json jsonFiles/StyleC.json)
-configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD.json)
-configure_file(jsonIn/StyleC.json jsonFiles/StyleC_Custom.json)
-configure_file(jsonIn/StyleD.json jsonFiles/sub/StyleD_Custom.json)
-
-# Enable automoc
-set(CMAKE_AUTOMOC TRUE)
-
-include_directories("${CMAKE_CURRENT_BINARY_DIR}/jsonFiles")
-link_libraries(Qt5::Widgets)
-
-add_library(PlugA STATIC StyleA.cpp)
-add_library(PlugB STATIC StyleB.cpp)
-add_library(PlugC STATIC StyleC.cpp)
-add_library(PlugD STATIC StyleD.cpp)
-add_library(PlugE STATIC StyleE.cpp)
diff --git a/Tests/QtAutogen/mocPlugin/StyleA.hpp b/Tests/QtAutogen/mocPlugin/StyleA.hpp
deleted file mode 100644
index 1b6154d16..000000000
--- a/Tests/QtAutogen/mocPlugin/StyleA.hpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef STYLEA_HPP
-#define STYLEA_HPP
-
-#include "StyleCommon.hpp"
-#include <QStylePlugin>
-
-class StyleA : public QStylePlugin
-{
- Q_OBJECT
- // Json file in local directory
- Q_PLUGIN_METADATA(IID "org.styles.A" FILE "StyleA.json")
- A_CUSTOM_MACRO(SomeArg, "StyleA_Custom.json", AnotherArg)
-public:
- QStyle* create(const QString& key);
-};
-
-#endif
diff --git a/Tests/QtAutogen/mocPlugin/StyleB.hpp b/Tests/QtAutogen/mocPlugin/StyleB.hpp
deleted file mode 100644
index 163c9b20a..000000000
--- a/Tests/QtAutogen/mocPlugin/StyleB.hpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef STYLEB_HPP
-#define STYLEB_HPP
-
-#include "StyleCommon.hpp"
-#include <QStylePlugin>
-
-class StyleB : public QStylePlugin
-{
- Q_OBJECT
- // Json file in local subdirectory
- Q_PLUGIN_METADATA(IID "org.styles.B" FILE "jsonIn/StyleB.json")
- A_CUSTOM_MACRO(SomeArg, "jsonIn/StyleB_Custom.json", AnotherArg)
-public:
- QStyle* create(const QString& key);
-};
-
-#endif
diff --git a/Tests/QtAutogen/mocPlugin/StyleC.hpp b/Tests/QtAutogen/mocPlugin/StyleC.hpp
deleted file mode 100644
index 52a887acf..000000000
--- a/Tests/QtAutogen/mocPlugin/StyleC.hpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef STYLEC_HPP
-#define STYLEC_HPP
-
-#include "StyleCommon.hpp"
-#include <QStylePlugin>
-
-class StyleC : public QStylePlugin
-{
- Q_OBJECT
- // Json file in global root directory
- Q_PLUGIN_METADATA(IID "org.styles.C" FILE "StyleC.json")
- A_CUSTOM_MACRO(SomeArg, "StyleC_Custom.json", AnotherArg)
-public:
- QStyle* create(const QString& key);
-};
-
-#endif
diff --git a/Tests/QtAutogen/mocPlugin/StyleCommon.hpp b/Tests/QtAutogen/mocPlugin/StyleCommon.hpp
deleted file mode 100644
index f1a7ec60d..000000000
--- a/Tests/QtAutogen/mocPlugin/StyleCommon.hpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef STYLECOMMON_HPP
-#define STYLECOMMON_HPP
-
-// Empty test macro definition
-#define A_CUSTOM_MACRO(name, jsonFile, pluginRegistrations)
-
-#endif
diff --git a/Tests/QtAutogen/mocPlugin/StyleD.hpp b/Tests/QtAutogen/mocPlugin/StyleD.hpp
deleted file mode 100644
index df8a4399d..000000000
--- a/Tests/QtAutogen/mocPlugin/StyleD.hpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef STYLED_HPP
-#define STYLED_HPP
-
-#include "StyleCommon.hpp"
-#include <QStylePlugin>
-
-class StyleD : public QStylePlugin
-{
- Q_OBJECT
- // Json file in global sub director
- Q_PLUGIN_METADATA(IID "org.styles.D" FILE "sub/StyleD.json")
- A_CUSTOM_MACRO(SomeArg, "sub/StyleD_Custom.json", AnotherArg)
-public:
- QStyle* create(const QString& key);
-};
-
-#endif
diff --git a/Tests/QtAutogen/mocPlugin/StyleE.cpp b/Tests/QtAutogen/mocPlugin/StyleE.cpp
deleted file mode 100644
index 8fc9a7f68..000000000
--- a/Tests/QtAutogen/mocPlugin/StyleE.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "StyleE.hpp"
-
-QStyle* StyleE::create(const QString& key)
-{
- return 0;
-}
diff --git a/Tests/QtAutogen/mocPlugin/StyleE.hpp b/Tests/QtAutogen/mocPlugin/StyleE.hpp
deleted file mode 100644
index e7915a8e5..000000000
--- a/Tests/QtAutogen/mocPlugin/StyleE.hpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef STYLEE_HPP
-#define STYLEE_HPP
-
-#include "StyleCommon.hpp"
-#include <QStylePlugin>
-
-class StyleE : public QStylePlugin
-{
- Q_OBJECT
- // No Json file
- Q_PLUGIN_METADATA(IID "org.styles.E")
- A_CUSTOM_MACRO(SomeArg, InvalidFileArg, AnotherArg)
-public:
- QStyle* create(const QString& key);
-};
-
-#endif
diff --git a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json b/Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json
deleted file mode 100644
index 129cac41f..000000000
--- a/Tests/QtAutogen/mocPlugin/jsonIn/StyleB.json
+++ /dev/null
@@ -1 +0,0 @@
-{ "Keys": [ "Rocket", "StarbusterB" ] }
diff --git a/Tests/QtAutogen/mocRerun/CMakeLists.txt b/Tests/QtAutogen/mocRerun/CMakeLists.txt
deleted file mode 100644
index 14b077b38..000000000
--- a/Tests/QtAutogen/mocRerun/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-cmake_minimum_required(VERSION 3.7)
-project(mocRerun CXX)
-
-if (QT_TEST_VERSION STREQUAL 4)
- find_package(Qt4 REQUIRED)
- set(QT_CORE_TARGET Qt4::QtCore)
-else()
- if (NOT QT_TEST_VERSION STREQUAL 5)
- message(SEND_ERROR "Invalid Qt version specified.")
- endif()
-
- find_package(Qt5Core REQUIRED)
- set(QT_CORE_TARGET Qt5::Core)
-endif()
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-
-# Generated source file
-add_custom_command(OUTPUT main.cpp
- COMMAND ${CMAKE_COMMAND} -E sleep 2
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
- )
-
-add_executable(mocRerun
- ${CMAKE_CURRENT_BINARY_DIR}/test1.h
- ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
- res1.qrc
- )
-set_property(TARGET mocRerun PROPERTY __UNDOCUMENTED_AUTOGEN_GENERATED_FILES 1)
-target_include_directories(mocRerun PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
-target_link_libraries(mocRerun ${QT_CORE_TARGET})
-# Write target name to text file
-add_custom_command(TARGET mocRerun POST_BUILD COMMAND
- ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:mocRerun>" > target1.txt)
diff --git a/Tests/QtAutogen/mocRerun/main.cpp.in b/Tests/QtAutogen/mocRerun/main.cpp.in
deleted file mode 100644
index b37ff61e2..000000000
--- a/Tests/QtAutogen/mocRerun/main.cpp.in
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "test1.h"
-
-class Test2 : public QObject
-{
- Q_OBJECT
-public slots:
- void onTst1() {}
-};
-
-int main()
-{
- Test1 test1;
- Test2 test2;
-
- return 0;
-}
-
-#include "main.moc"
diff --git a/Tests/QtAutogen/rccDepends/CMakeLists.txt b/Tests/QtAutogen/rccDepends/CMakeLists.txt
deleted file mode 100644
index 878ae5d35..000000000
--- a/Tests/QtAutogen/rccDepends/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-cmake_minimum_required(VERSION 3.7)
-project(rccDepends)
-
-set(CMAKE_AUTORCC ON)
-
-if (QT_TEST_VERSION STREQUAL 4)
- find_package(Qt4 REQUIRED)
- set(QT_CORE_TARGET Qt4::QtCore)
-else()
- if (NOT QT_TEST_VERSION STREQUAL 5)
- message(SEND_ERROR "Invalid Qt version specified.")
- endif()
-
- find_package(Qt5Core REQUIRED)
- set(QT_CORE_TARGET Qt5::Core)
-endif()
-
-configure_file(res/input1.txt.in res1/input.txt COPYONLY)
-configure_file(res/input1.txt.in res1/inputAdded.txt COPYONLY)
-configure_file(res/input2.txt.in res2/input.txt COPYONLY)
-configure_file(res/input2.txt.in res2/inputAdded.txt COPYONLY)
-# Dependency generated qrc file
-add_custom_command(OUTPUT res2.qrc
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in
- COMMAND ${CMAKE_COMMAND} -E sleep 2
- COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc
- )
-
-add_executable(rccDepends
- main.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/res1.qrc
- ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc )
-target_link_libraries(rccDepends ${QT_CORE_TARGET})
-add_custom_command(TARGET rccDepends POST_BUILD COMMAND
- ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:rccDepends>" > target.txt)
diff --git a/Tests/QtAutogen/rccDepends/res/input1.txt.in b/Tests/QtAutogen/rccDepends/res/input1.txt.in
deleted file mode 100644
index da627624b..000000000
--- a/Tests/QtAutogen/rccDepends/res/input1.txt.in
+++ /dev/null
@@ -1 +0,0 @@
-Res1 input.
diff --git a/Tests/QtAutogen/rccDepends/res/input2.txt.in b/Tests/QtAutogen/rccDepends/res/input2.txt.in
deleted file mode 100644
index 08e14b7bd..000000000
--- a/Tests/QtAutogen/rccDepends/res/input2.txt.in
+++ /dev/null
@@ -1 +0,0 @@
-Res2 input.
diff --git a/Tests/QtAutogen/rccDepends/res1a.qrc.in b/Tests/QtAutogen/rccDepends/res1a.qrc.in
deleted file mode 100644
index d111ffbc7..000000000
--- a/Tests/QtAutogen/rccDepends/res1a.qrc.in
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/Texts1">
- <file>res1/input.txt</file>
- </qresource>
-</RCC>
diff --git a/Tests/QtAutogen/rccDepends/res1b.qrc.in b/Tests/QtAutogen/rccDepends/res1b.qrc.in
deleted file mode 100644
index 4cb3f047c..000000000
--- a/Tests/QtAutogen/rccDepends/res1b.qrc.in
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource prefix="/Texts1">
- <file>res1/input.txt</file>
- <file alias="Added">res1/inputAdded.txt</file>
- </qresource>
-</RCC>
diff --git a/Tests/QtAutogen/rccDepends/res2a.qrc.in b/Tests/QtAutogen/rccDepends/res2a.qrc.in
deleted file mode 100644
index 19f34ac90..000000000
--- a/Tests/QtAutogen/rccDepends/res2a.qrc.in
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/Texts2">
- <file>res2/input.txt</file>
- </qresource>
-</RCC>
diff --git a/Tests/QtAutogen/rccDepends/res2b.qrc.in b/Tests/QtAutogen/rccDepends/res2b.qrc.in
deleted file mode 100644
index 19e8ba10c..000000000
--- a/Tests/QtAutogen/rccDepends/res2b.qrc.in
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource prefix="/Texts2">
- <file>res2/input.txt</file>
- <file alias="Added">res2/inputAdded.txt</file>
- </qresource>
-</RCC>
diff --git a/Tests/QtAutogen/sameName/CMakeLists.txt b/Tests/QtAutogen/sameName/CMakeLists.txt
deleted file mode 100644
index 4d2dcd9d2..000000000
--- a/Tests/QtAutogen/sameName/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-# Test AUTOMOC and AUTORCC on source files with the same name
-# but in different subdirectories
-
-add_executable(sameName
- aaa/bbb/item.cpp
- aaa/bbb/data.qrc
- aaa/item.cpp
- aaa/data.qrc
- bbb/aaa/item.cpp
- bbb/aaa/data.qrc
- bbb/item.cpp
- bbb/data.qrc
- ccc/item.cpp
- ccc/data.qrc
- item.cpp
- data.qrc
- main.cpp
-)
-target_link_libraries(sameName ${QT_LIBRARIES})
-set_target_properties(sameName PROPERTIES AUTOMOC TRUE AUTORCC TRUE)
-
-# Set different compression levels
-if (QT_TEST_VERSION STREQUAL 4)
- set(rccCompress "-compress")
-else()
- set(rccCompress "--compress")
-endif()
-set_target_properties(sameName PROPERTIES AUTORCC_OPTIONS "${rccCompress};0" )
-set_source_files_properties(aaa/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};1" )
-set_source_files_properties(bbb/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};2" )
-set_source_files_properties(ccc/data.qrc PROPERTIES AUTORCC_OPTIONS "${rccCompress};3" )
diff --git a/Tests/QtAutogen/sameName/aaa/bbb/item.cpp b/Tests/QtAutogen/sameName/aaa/bbb/item.cpp
deleted file mode 100644
index 20d00445e..000000000
--- a/Tests/QtAutogen/sameName/aaa/bbb/item.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "item.hpp"
-
-namespace aaa {
-namespace bbb {
-
-void Item::go()
-{
-}
-}
-}
diff --git a/Tests/QtAutogen/sameName/aaa/item.cpp b/Tests/QtAutogen/sameName/aaa/item.cpp
deleted file mode 100644
index 95dd3b674..000000000
--- a/Tests/QtAutogen/sameName/aaa/item.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "item.hpp"
-
-namespace aaa {
-
-void Item::go()
-{
-}
-}
diff --git a/Tests/QtAutogen/sameName/aaa/item.hpp b/Tests/QtAutogen/sameName/aaa/item.hpp
deleted file mode 100644
index b63466f6d..000000000
--- a/Tests/QtAutogen/sameName/aaa/item.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef AAA_ITEM_HPP
-#define AAA_ITEM_HPP
-
-#include <QObject>
-
-namespace aaa {
-
-class Item : public QObject
-{
- Q_OBJECT
- Q_SLOT
- void go();
-};
-}
-
-#endif
diff --git a/Tests/QtAutogen/sameName/bbb/aaa/item.cpp b/Tests/QtAutogen/sameName/bbb/aaa/item.cpp
deleted file mode 100644
index ac4b2c27b..000000000
--- a/Tests/QtAutogen/sameName/bbb/aaa/item.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "item.hpp"
-
-namespace bbb {
-namespace aaa {
-
-void Item::go()
-{
-}
-}
-}
diff --git a/Tests/QtAutogen/sameName/bbb/item.cpp b/Tests/QtAutogen/sameName/bbb/item.cpp
deleted file mode 100644
index f97a1431e..000000000
--- a/Tests/QtAutogen/sameName/bbb/item.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "item.hpp"
-
-namespace bbb {
-
-void Item::go()
-{
-}
-}
diff --git a/Tests/QtAutogen/sameName/bbb/item.hpp b/Tests/QtAutogen/sameName/bbb/item.hpp
deleted file mode 100644
index 5b7f9850b..000000000
--- a/Tests/QtAutogen/sameName/bbb/item.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef BBB_ITEM_HPP
-#define BBB_ITEM_HPP
-
-#include <QObject>
-
-namespace bbb {
-
-class Item : public QObject
-{
- Q_OBJECT
- Q_SLOT
- void go();
-};
-}
-
-#endif
diff --git a/Tests/QtAutogen/sameName/ccc/item.cpp b/Tests/QtAutogen/sameName/ccc/item.cpp
deleted file mode 100644
index d90b2b8c7..000000000
--- a/Tests/QtAutogen/sameName/ccc/item.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "item.hpp"
-
-namespace ccc {
-
-void Item::go()
-{
-}
-
-class MocTest : public QObject
-{
- Q_OBJECT;
- Q_SLOT
- void go();
-};
-
-void MocTest::go()
-{
-}
-}
-
-// Include own moc files
-#include "item.moc"
-#include "moc_item.cpp"
diff --git a/Tests/QtAutogen/sameName/ccc/item.hpp b/Tests/QtAutogen/sameName/ccc/item.hpp
deleted file mode 100644
index 96fcc245c..000000000
--- a/Tests/QtAutogen/sameName/ccc/item.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef CCC_ITEM_HPP
-#define CCC_ITEM_HPP
-
-#include <QObject>
-
-namespace ccc {
-
-class Item : public QObject
-{
- Q_OBJECT
- Q_SLOT
- void go();
-};
-}
-
-#endif
diff --git a/Tests/QtAutogen/sameName/item.cpp b/Tests/QtAutogen/sameName/item.cpp
deleted file mode 100644
index e013cf392..000000000
--- a/Tests/QtAutogen/sameName/item.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "item.hpp"
-
-void Item::go()
-{
-}
diff --git a/Tests/QtAutogen/sameName/item.hpp b/Tests/QtAutogen/sameName/item.hpp
deleted file mode 100644
index 91bba3b4d..000000000
--- a/Tests/QtAutogen/sameName/item.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef ITEM_HPP
-#define ITEM_HPP
-
-#include <QObject>
-
-class Item : public QObject
-{
- Q_OBJECT
- Q_SLOT
- void go();
-};
-
-#endif
diff --git a/Tests/QtAutogen/skipMoc.cpp b/Tests/QtAutogen/skipMoc.cpp
deleted file mode 100644
index 85305f590..000000000
--- a/Tests/QtAutogen/skipMoc.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-
-#include "skipSource/qItemA.hpp"
-#include "skipSource/qItemB.hpp"
-#include "skipSource/qItemC.hpp"
-
-int main(int, char**)
-{
- QItemA itemA;
- QItemA itemB;
- QItemA itemC;
-
- // Fails to link if the symbol is not present.
- return 0;
-}
diff --git a/Tests/QtAutogen/skipSource/qItemC.cpp b/Tests/QtAutogen/skipSource/qItemC.cpp
deleted file mode 100644
index 700abd6db..000000000
--- a/Tests/QtAutogen/skipSource/qItemC.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "qItemC.hpp"
-
-void QItemC::go()
-{
-}
diff --git a/Tests/QtAutogen/skipSource/skipUicGen.cpp b/Tests/QtAutogen/skipSource/skipUicGen.cpp
deleted file mode 100644
index d2a55a6f1..000000000
--- a/Tests/QtAutogen/skipSource/skipUicGen.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-
-#include "skipUicGen.hpp"
-#include "ui_uigen2.h"
-
-void skipGen()
-{
-}
diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen1.cpp b/Tests/QtAutogen/skipSource/skipUicNoGen1.cpp
deleted file mode 100644
index f591a42ba..000000000
--- a/Tests/QtAutogen/skipSource/skipUicNoGen1.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-
-#include "skipUicNoGen1.hpp"
-#include "ui_nogen2.h"
-
-void skipNoGen1()
-{
-}
diff --git a/Tests/QtAutogen/skipSource/skipUicNoGen2.cpp b/Tests/QtAutogen/skipSource/skipUicNoGen2.cpp
deleted file mode 100644
index 8c1c3241c..000000000
--- a/Tests/QtAutogen/skipSource/skipUicNoGen2.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-
-#include "skipUicNoGen2.hpp"
-#include "ui_nogen2.h"
-
-void skipNoGen2()
-{
-}
diff --git a/Tests/QtAutogen/skipSource/ui_nogen2.h b/Tests/QtAutogen/skipSource/ui_nogen2.h
deleted file mode 100644
index 5d547d477..000000000
--- a/Tests/QtAutogen/skipSource/ui_nogen2.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef UI_NOGEN2_H
-#define UI_NOGEN2_H
-
-void ui_nogen2();
-
-#endif \ No newline at end of file
diff --git a/Tests/QtAutogen/skipUic.cpp b/Tests/QtAutogen/skipUic.cpp
deleted file mode 100644
index 0adf011a7..000000000
--- a/Tests/QtAutogen/skipUic.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-
-#include "skipSource/skipUicGen.hpp"
-#include "skipSource/skipUicNoGen1.hpp"
-#include "skipSource/skipUicNoGen2.hpp"
-
-int main(int, char**)
-{
- skipGen();
- skipNoGen1();
- skipNoGen2();
-
- return 0;
-}
-
-// -- Function definitions
-void ui_nogen1()
-{
-}
-
-void ui_nogen2()
-{
-}
diff --git a/Tests/QtAutogen/uicInclude/CMakeLists.txt b/Tests/QtAutogen/uicInclude/CMakeLists.txt
deleted file mode 100644
index f62ebb039..000000000
--- a/Tests/QtAutogen/uicInclude/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-# Test moc include patterns
-
-set(CMAKE_AUTOUIC_SEARCH_PATHS "dirA")
-
-add_executable(uicInclude main.cpp)
-target_link_libraries(uicInclude ${QT_LIBRARIES})
-set_target_properties(uicInclude PROPERTIES AUTOUIC ON)
-set_property(TARGET uicInclude APPEND PROPERTY AUTOUIC_SEARCH_PATHS "dirB")
diff --git a/Tests/QtAutogen/uicOnlySource/uiconly.cpp b/Tests/QtAutogen/uicOnlySource/uiconly.cpp
deleted file mode 100644
index 7b91b251f..000000000
--- a/Tests/QtAutogen/uicOnlySource/uiconly.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-
-#include "uiconly.h"
-
-UicOnly::UicOnly(QWidget* parent)
- : QWidget(parent)
- , ui(new Ui::UicOnly)
-{
-}
-
-UicOnly::~UicOnly()
-{
- delete ui;
-}
-
-int main()
-{
- return 0;
-}
diff --git a/Tests/QtAutogen/uicOnlySource/uiconly.h b/Tests/QtAutogen/uicOnlySource/uiconly.h
deleted file mode 100644
index 8f4eebe1e..000000000
--- a/Tests/QtAutogen/uicOnlySource/uiconly.h
+++ /dev/null
@@ -1,20 +0,0 @@
-
-#ifndef UIC_ONLY_H
-#define UIC_ONLY_H
-
-#include <QWidget>
-
-#include "ui_uiconly.h"
-
-class UicOnly : public QWidget
-{
- Q_OBJECT
-public:
- explicit UicOnly(QWidget* parent = 0);
- ~UicOnly();
-
-private:
- Ui::UicOnly* ui;
-};
-
-#endif
diff --git a/Tests/QtAutogen/uicOnlySource/uiconly.ui b/Tests/QtAutogen/uicOnlySource/uiconly.ui
deleted file mode 100644
index 13fb832eb..000000000
--- a/Tests/QtAutogen/uicOnlySource/uiconly.ui
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>UicOnly</class>
- <widget class="QWidget" name="UicOnly">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>300</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QTreeView" name="treeView"/>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/Tests/README b/Tests/README
deleted file mode 100644
index 8b2fda845..000000000
--- a/Tests/README
+++ /dev/null
@@ -1,39 +0,0 @@
-If you think about adding a new testcase then here is a small checklist you
-can run through to find a proper place for it. Go through the list from the
-beginning and stop once you find something that matches your tests needs,
-i.e. if you will test a module and only need the configure mode use the
-instructions from section 2, not 3.
-
-1. Your testcase can run in CMake script mode, i.e. "cmake -P something"
-
-Put your test in Tests/CMakeTests/ directory as a .cmake.in file. It will be
-put into the test binary directory by configure_file(... @ONLY) and run from
-there. Use the AddCMakeTest() macro in Tests/CMakeTests/CMakeLists.txt to add
-your test to the test runs.
-
-2. Your test needs CMake to run in configure mode, but will not build anything
-
-This includes tests that will build something using try_compile() and friends,
-but nothing that expects add_executable(), add_library(), or add_test() to run.
-
-If the test configures the project only once and it must succeed then put it
-into the Tests/CMakeOnly/ directory. Create a subdirectory named like your
-test and write the CMakeLists.txt you need into that subdirectory. Use the
-add_CMakeOnly_test() macro from Tests/CMakeOnly/CMakeLists.txt to add your
-test to the test runs.
-
-If the test configures the project with multiple variations and verifies
-success or failure each time then put it into the Tests/RunCMake/ directory.
-Read the instructions in Tests/RunCMake/CMakeLists.txt to add a test.
-
-3. If you are testing something from the Modules directory
-
-Put your test in the Tests/Modules/ directory. Create a subdirectory there
-named after your test. Use the ADD_TEST_MACRO macro from Tests/CMakeLists.txt
-to add your test to the test run. If you have put your stuff in
-Tests/Modules/Foo then you call it using ADD_TEST_MACRO(Module.Foo Foo).
-
-4. You are doing other stuff.
-
-Find a good place ;) In doubt mail to cmake-developers@cmake.org and ask for
-advise.
diff --git a/Tests/README.rst b/Tests/README.rst
new file mode 100644
index 000000000..3e989382b
--- /dev/null
+++ b/Tests/README.rst
@@ -0,0 +1,31 @@
+CMake Tests Directory
+*********************
+
+This directory contains the CMake test suite.
+See also the `CMake Source Code Guide`_.
+
+.. _`CMake Source Code Guide`: ../Help/dev/source.rst
+
+Many tests exist as immediate subdirectories, but some tests
+are organized as follows.
+
+* ``CMakeLib/``:
+ Source code, used for tests, that links to the ``CMakeLib`` library
+ defined over in ``Source/``.
+
+* ``CMakeOnly/``:
+ Deprecated. Tests that run CMake to generate a project but not build it.
+ Superseded by ``Tests/RunCMake/``.
+
+* ``Find*/``:
+ Tests for specific find modules that can only be run on machines with
+ the corresponding packages installed. They are enabled in
+ ``CMakeLists.txt`` by undocumented options used on CI builds.
+
+* ``Module/``:
+ Tests for specific CMake modules.
+
+* ``RunCMake/``:
+ Tests that run CMake and/or other tools while precisely checking
+ their return code and stdout/stderr content. Useful for testing
+ error cases and diagnostic output.
diff --git a/Tests/RunCMake/Android/RunCMakeTest.cmake b/Tests/RunCMake/Android/RunCMakeTest.cmake
index 86a989623..45798ce59 100644
--- a/Tests/RunCMake/Android/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Android/RunCMakeTest.cmake
@@ -61,8 +61,12 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK)
list(APPEND _abis_${_version} ${_abis})
endif()
endforeach()
- set(_abis_ ${_abis_${_latest_gcc}})
set(_abis_clang ${_abis_${_latest_clang}})
+ if(_latest_gcc)
+ set(_abis_ ${_abis_${_latest_gcc}})
+ else()
+ set(_abis_ ${_abis_clang})
+ endif()
if(_versions MATCHES "clang")
set(_versions "clang" ${_versions})
endif()
@@ -88,12 +92,14 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK)
-DCMAKE_ANDROID_ARM_MODE=0
)
run_cmake(ndk-badarm)
- set(RunCMake_TEST_OPTIONS
- -DCMAKE_SYSTEM_NAME=Android
- -DCMAKE_ANDROID_NDK=${ndk}
- -DCMAKE_ANDROID_ARM_NEON=0
- )
- run_cmake(ndk-badneon)
+ if("armeabi" IN_LIST _abis_)
+ set(RunCMake_TEST_OPTIONS
+ -DCMAKE_SYSTEM_NAME=Android
+ -DCMAKE_ANDROID_NDK=${ndk}
+ -DCMAKE_ANDROID_ARM_NEON=0
+ )
+ run_cmake(ndk-badneon)
+ endif()
set(RunCMake_TEST_OPTIONS
-DCMAKE_SYSTEM_NAME=Android
-DCMAKE_ANDROID_NDK=${ndk}
@@ -130,10 +136,11 @@ foreach(ndk IN LISTS TEST_ANDROID_NDK)
set(stl_types
none
system
- gnustl_static
- gnustl_shared
)
+ if(IS_DIRECTORY "${ndk}/sources/cxx-stl/gnu-libstdc++")
+ list(APPEND stl_types gnustl_static gnustl_shared)
+ endif()
if(IS_DIRECTORY "${ndk}/sources/cxx-stl/gabi++/libs")
list(APPEND stl_types gabi++_static gabi++_shared)
endif()
diff --git a/Tests/RunCMake/Android/android.cxx b/Tests/RunCMake/Android/android.cxx
index 2dee8f9bd..a6d8c551d 100644
--- a/Tests/RunCMake/Android/android.cxx
+++ b/Tests/RunCMake/Android/android.cxx
@@ -1,19 +1,19 @@
#include "android.h"
#ifndef STL_NONE
-#include <cmath>
-#include <cstdio>
-#ifndef STL_SYSTEM
-#include <exception>
-#include <typeinfo>
-#ifndef STL_STLPORT
-#include <cxxabi.h>
-#endif
-#ifndef STL_GABI
-#include <iostream>
-#include <string>
-#endif
-#endif
+# include <cmath>
+# include <cstdio>
+# ifndef STL_SYSTEM
+# include <exception>
+# include <typeinfo>
+# ifndef STL_STLPORT
+# include <cxxabi.h>
+# endif
+# ifndef STL_GABI
+# include <iostream>
+# include <string>
+# endif
+# endif
#endif
int main()
@@ -30,19 +30,19 @@ int main()
try {
delete (new int);
} catch (std::exception const& e) {
-#if defined(STL_GABI)
+# if defined(STL_GABI)
e.what();
typeid(e).name();
-#else
+# else
std::cerr << e.what() << std::endl;
std::cerr << typeid(e).name() << std::endl;
-#endif
+# endif
}
-#if defined(STL_GABI)
+# if defined(STL_GABI)
return 0;
-#else
+# else
std::string s;
return static_cast<int>(s.size());
-#endif
+# endif
#endif
}
diff --git a/Tests/RunCMake/Android/android.h b/Tests/RunCMake/Android/android.h
index a5fd67e58..2c5cd9590 100644
--- a/Tests/RunCMake/Android/android.h
+++ b/Tests/RunCMake/Android/android.h
@@ -1,103 +1,103 @@
#ifndef __ANDROID__
-#error "__ANDROID__ not defined"
+# error "__ANDROID__ not defined"
#endif
#include <android/api-level.h>
#if API_LEVEL != __ANDROID_API__
-#error "API levels do not match"
+# error "API levels do not match"
#endif
#ifdef COMPILER_IS_CLANG
-#ifndef __clang__
-#error "COMPILER_IS_CLANG but __clang__ is not defined"
-#endif
+# ifndef __clang__
+# error "COMPILER_IS_CLANG but __clang__ is not defined"
+# endif
#else
-#ifdef __clang__
-#error "!COMPILER_IS_CLANG but __clang__ is defined"
-#endif
+# ifdef __clang__
+# error "!COMPILER_IS_CLANG but __clang__ is defined"
+# endif
#endif
#ifdef ARM_MODE
-#if ARM_MODE == 1 && defined(__thumb__)
-#error "ARM_MODE==1 but __thumb__ is defined"
-#elif ARM_MODE == 0 && !defined(__thumb__)
-#error "ARM_MODE==0 but __thumb__ is not defined"
-#endif
+# if ARM_MODE == 1 && defined(__thumb__)
+# error "ARM_MODE==1 but __thumb__ is defined"
+# elif ARM_MODE == 0 && !defined(__thumb__)
+# error "ARM_MODE==0 but __thumb__ is not defined"
+# endif
#endif
#ifdef ARM_NEON
-#if ARM_NEON == 0 && defined(__ARM_NEON__)
-#error "ARM_NEON==0 but __ARM_NEON__ is defined"
-#elif ARM_NEON == 1 && !defined(__ARM_NEON__)
-#error "ARM_NEON==1 but __ARM_NEON__ is not defined"
-#endif
+# if ARM_NEON == 0 && defined(__ARM_NEON__)
+# error "ARM_NEON==0 but __ARM_NEON__ is defined"
+# elif ARM_NEON == 1 && !defined(__ARM_NEON__)
+# error "ARM_NEON==1 but __ARM_NEON__ is not defined"
+# endif
#endif
#ifdef ABI_armeabi
-#ifndef __ARM_EABI__
-#error "ABI_armeabi: __ARM_EABI__ not defined"
-#endif
-#if __ARM_ARCH != 5
-#error "ABI_armeabi: __ARM_ARCH is not 5"
-#endif
+# ifndef __ARM_EABI__
+# error "ABI_armeabi: __ARM_EABI__ not defined"
+# endif
+# if __ARM_ARCH != 5
+# error "ABI_armeabi: __ARM_ARCH is not 5"
+# endif
#endif
#ifdef ABI_armeabi_v6
-#ifndef __ARM_EABI__
-#error "ABI_armeabi_v6: __ARM_EABI__ not defined"
-#endif
-#if __ARM_ARCH != 6
-#error "ABI_armeabi_v6: __ARM_ARCH is not 6"
-#endif
+# ifndef __ARM_EABI__
+# error "ABI_armeabi_v6: __ARM_EABI__ not defined"
+# endif
+# if __ARM_ARCH != 6
+# error "ABI_armeabi_v6: __ARM_ARCH is not 6"
+# endif
#endif
#ifdef ABI_armeabi_v7a
-#ifndef __ARM_EABI__
-#error "ABI_armeabi_v7a: __ARM_EABI__ not defined"
-#endif
-#if __ARM_ARCH != 7
-#error "ABI_armeabi_v7a: __ARM_ARCH is not 7"
-#endif
+# ifndef __ARM_EABI__
+# error "ABI_armeabi_v7a: __ARM_EABI__ not defined"
+# endif
+# if __ARM_ARCH != 7
+# error "ABI_armeabi_v7a: __ARM_ARCH is not 7"
+# endif
#endif
#ifdef ABI_arm64_v8a
-#ifdef __ARM_EABI__
-#error "ABI_arm64_v8a: __ARM_EABI__ defined"
-#endif
-#ifndef __aarch64__
-#error "ABI_arm64_v8a: __aarch64__ not defined"
-#endif
+# ifdef __ARM_EABI__
+# error "ABI_arm64_v8a: __ARM_EABI__ defined"
+# endif
+# ifndef __aarch64__
+# error "ABI_arm64_v8a: __aarch64__ not defined"
+# endif
#endif
#ifdef ABI_mips
-#if __mips != 32
-#error "ABI_mips: __mips != 32"
-#endif
-#ifndef _ABIO32
-#error "ABI_mips: _ABIO32 not defined"
-#endif
+# if __mips != 32
+# error "ABI_mips: __mips != 32"
+# endif
+# ifndef _ABIO32
+# error "ABI_mips: _ABIO32 not defined"
+# endif
#endif
#ifdef ABI_mips64
-#if __mips != 64
-#error "ABI_mips64: __mips != 64"
-#endif
-#ifndef _ABI64
-#error "ABI_mips: _ABI64 not defined"
-#endif
+# if __mips != 64
+# error "ABI_mips64: __mips != 64"
+# endif
+# ifndef _ABI64
+# error "ABI_mips: _ABI64 not defined"
+# endif
#endif
#ifdef ABI_x86
-#ifndef __i686__
-#error "ABI_x86: __i686__ not defined"
-#endif
+# ifndef __i686__
+# error "ABI_x86: __i686__ not defined"
+# endif
#endif
#ifdef ABI_x86_64
-#ifndef __x86_64__
-#error "ABI_x86_64: __x86_64__ not defined"
-#endif
+# ifndef __x86_64__
+# error "ABI_x86_64: __x86_64__ not defined"
+# endif
#endif
#include <stddef.h>
diff --git a/Tests/RunCMake/Android/android_lib.cxx b/Tests/RunCMake/Android/android_lib.cxx
new file mode 100644
index 000000000..82f9d27bb
--- /dev/null
+++ b/Tests/RunCMake/Android/android_lib.cxx
@@ -0,0 +1,4 @@
+int android_lib()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/Android/android_sysinc.c b/Tests/RunCMake/Android/android_sysinc.c
index 18d73dbc8..f7cc6f026 100644
--- a/Tests/RunCMake/Android/android_sysinc.c
+++ b/Tests/RunCMake/Android/android_sysinc.c
@@ -1,7 +1,7 @@
#include <dlfcn.h>
#ifndef NOT_SYSTEM_DLFCN_HEADER
-#error "sysroot /usr/include appears too early"
+# error "sysroot /usr/include appears too early"
#endif
#include "android.c"
diff --git a/Tests/RunCMake/Android/android_sysinc.cxx b/Tests/RunCMake/Android/android_sysinc.cxx
index 5c5694b8d..9379f1453 100644
--- a/Tests/RunCMake/Android/android_sysinc.cxx
+++ b/Tests/RunCMake/Android/android_sysinc.cxx
@@ -1,7 +1,7 @@
#include <dlfcn.h>
#ifndef NOT_SYSTEM_DLFCN_HEADER
-#error "sysroot /usr/include appears too early"
+# error "sysroot /usr/include appears too early"
#endif
#include "android.cxx"
diff --git a/Tests/RunCMake/Android/check_binary.cmake b/Tests/RunCMake/Android/check_binary.cmake
new file mode 100644
index 000000000..1d1b01a5d
--- /dev/null
+++ b/Tests/RunCMake/Android/check_binary.cmake
@@ -0,0 +1,8 @@
+if(NOT EXISTS "${file}")
+ message(FATAL_ERROR "Missing file:\n ${file}")
+endif()
+execute_process(COMMAND "${objdump}" -p ${file} OUTPUT_VARIABLE out)
+if(out MATCHES "NEEDED[^\n]*stdc\\+\\+")
+ string(REPLACE "\n" "\n " out " ${out}")
+ message(FATAL_ERROR "File:\n ${file}\ndepends on libstdc++:\n${out}")
+endif()
diff --git a/Tests/RunCMake/Android/common.cmake b/Tests/RunCMake/Android/common.cmake
index 015f2029e..d96ab8648 100644
--- a/Tests/RunCMake/Android/common.cmake
+++ b/Tests/RunCMake/Android/common.cmake
@@ -6,9 +6,6 @@ if(NOT ANDROID)
endif()
foreach(f
- "${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX}"
- "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}g++${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}"
- "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}cpp${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}"
"${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}ar${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}"
"${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}ld${CMAKE_CXX_ANDROID_TOOLCHAIN_SUFFIX}"
)
@@ -52,21 +49,26 @@ elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
endif()
endif()
-execute_process(
- COMMAND "${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX}" -dumpmachine
- OUTPUT_VARIABLE _out OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_VARIABLE _err
- RESULT_VARIABLE _res
- )
-if(NOT _res EQUAL 0)
- message(SEND_ERROR "Failed to run 'gcc -dumpmachine':\n ${_res}")
-endif()
-if(NOT _out STREQUAL "${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}")
- message(SEND_ERROR "'gcc -dumpmachine' produced:\n"
- " ${_out}\n"
- "which is not equal to CMAKE_C_ANDROID_TOOLCHAIN_MACHINE:\n"
- " ${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}"
+set(gcc ${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX})
+if(EXISTS "${gcc}")
+ execute_process(
+ COMMAND "${CMAKE_C_ANDROID_TOOLCHAIN_PREFIX}gcc${CMAKE_C_ANDROID_TOOLCHAIN_SUFFIX}" -dumpmachine
+ OUTPUT_VARIABLE _out OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE _err
+ RESULT_VARIABLE _res
)
+ if(NOT _res EQUAL 0)
+ message(SEND_ERROR "Failed to run 'gcc -dumpmachine':\n ${_res}")
+ endif()
+ string(REPLACE "--" "-" _out_check "${_out}")
+ if(NOT _out_check STREQUAL "${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}"
+ AND NOT (_out STREQUAL "arm--linux-android" AND CMAKE_C_ANDROID_TOOLCHAIN_MACHINE STREQUAL "arm-linux-androideabi"))
+ message(SEND_ERROR "'gcc -dumpmachine' produced:\n"
+ " ${_out}\n"
+ "which does not match CMAKE_C_ANDROID_TOOLCHAIN_MACHINE:\n"
+ " ${CMAKE_C_ANDROID_TOOLCHAIN_MACHINE}"
+ )
+ endif()
endif()
if(CMAKE_ANDROID_STL_TYPE STREQUAL "none")
@@ -92,6 +94,23 @@ if(CMAKE_ANDROID_ARCH_ABI STREQUAL "armeabi-v7a")
endif()
add_executable(android_c android.c)
add_executable(android_cxx android.cxx)
+add_library(android_cxx_lib SHARED android_lib.cxx)
+
+set(objdump "${CMAKE_CXX_ANDROID_TOOLCHAIN_PREFIX}objdump")
+if(NOT EXISTS "${objdump}")
+ message(FATAL_ERROR "Expected tool missing:\n ${objdump}")
+endif()
+
+if(NOT CMAKE_ANDROID_STL_TYPE MATCHES "^(system|stlport_static|stlport_shared)$")
+ foreach(tgt android_cxx android_cxx_lib)
+ add_custom_command(TARGET ${tgt} POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ -Dobjdump=${objdump}
+ -Dfile=$<TARGET_FILE:${tgt}>
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/check_binary.cmake
+ )
+ endforeach()
+endif()
# Test that an explicit /usr/include is ignored in favor of
# appearing as a standard include directory at the end.
diff --git a/Tests/RunCMake/Android/ndk-arm64-v8a-stdout.txt b/Tests/RunCMake/Android/ndk-arm64-v8a-stdout.txt
index 8d0bdc293..a228ccc0a 100644
--- a/Tests/RunCMake/Android/ndk-arm64-v8a-stdout.txt
+++ b/Tests/RunCMake/Android/ndk-arm64-v8a-stdout.txt
@@ -1,2 +1,2 @@
-- Android: Targeting API '[0-9]+' with architecture 'arm64', ABI 'arm64-v8a', and processor 'aarch64'
--- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
+-- Android: Selected (unified Clang toolchain|(Clang toolchain '[^']+' with )?GCC toolchain '[^']+')
diff --git a/Tests/RunCMake/Android/ndk-armeabi-arm-stdout.txt b/Tests/RunCMake/Android/ndk-armeabi-arm-stdout.txt
index 3741da3c4..72ec00ebc 100644
--- a/Tests/RunCMake/Android/ndk-armeabi-arm-stdout.txt
+++ b/Tests/RunCMake/Android/ndk-armeabi-arm-stdout.txt
@@ -1,3 +1,3 @@
-- Android: Targeting API '[0-9]+' with architecture 'arm', ABI 'armeabi', and processor 'armv5te'
--- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
+-- Android: Selected (unified Clang toolchain|(Clang toolchain '[^']+' with )?GCC toolchain '[^']+')
.*-- CMAKE_ANDROID_ARM_MODE=1
diff --git a/Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stdout.txt b/Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stdout.txt
index ac2bfd5a9..8bd87fa27 100644
--- a/Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stdout.txt
+++ b/Tests/RunCMake/Android/ndk-armeabi-v7a-neon-stdout.txt
@@ -1,3 +1,3 @@
-- Android: Targeting API '[0-9]+' with architecture 'arm', ABI 'armeabi-v7a', and processor 'armv7-a'
--- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
+-- Android: Selected (unified Clang toolchain|(Clang toolchain '[^']+' with )?GCC toolchain '[^']+')
.*-- CMAKE_ANDROID_ARM_NEON=1
diff --git a/Tests/RunCMake/Android/ndk-armeabi-v7a-stdout.txt b/Tests/RunCMake/Android/ndk-armeabi-v7a-stdout.txt
index 0edb4f7be..554548ed8 100644
--- a/Tests/RunCMake/Android/ndk-armeabi-v7a-stdout.txt
+++ b/Tests/RunCMake/Android/ndk-armeabi-v7a-stdout.txt
@@ -1,3 +1,3 @@
-- Android: Targeting API '[0-9]+' with architecture 'arm', ABI 'armeabi-v7a', and processor 'armv7-a'
--- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
+-- Android: Selected (unified Clang toolchain|(Clang toolchain '[^']+' with )?GCC toolchain '[^']+')
.*-- CMAKE_ANDROID_ARM_NEON=0
diff --git a/Tests/RunCMake/Android/ndk-badver-stderr.txt b/Tests/RunCMake/Android/ndk-badver-stderr.txt
index df2c5e622..ce6bc4e63 100644
--- a/Tests/RunCMake/Android/ndk-badver-stderr.txt
+++ b/Tests/RunCMake/Android/ndk-badver-stderr.txt
@@ -1,11 +1,12 @@
^CMake Error at .*/Modules/Platform/Android/Determine-Compiler-NDK.cmake:[0-9]+ \(message\):
- Android: The CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION value 'badver' is not one
+ Android: The CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION value 'badver' is not(
+ supported by this NDK. It must be 'clang' or not set at all\.| one
of the allowed forms:
<major>.<minor> = GCC of specified version
clang<major>.<minor> = Clang of specified version
clang = Clang of most recent available version
-
+)
Call Stack \(most recent call first\):
.*
ndk-badver.cmake:1 \(enable_language\)
diff --git a/Tests/RunCMake/Android/ndk-badvernum-stderr.txt b/Tests/RunCMake/Android/ndk-badvernum-stderr.txt
index 25bbaf92c..aec91d95e 100644
--- a/Tests/RunCMake/Android/ndk-badvernum-stderr.txt
+++ b/Tests/RunCMake/Android/ndk-badvernum-stderr.txt
@@ -1,12 +1,14 @@
-^CMake Error at .*/Modules/Platform/Android/Determine-Compiler-NDK.cmake:[0-9]+ \(message\):
- Android: No toolchain for ABI 'armeabi' found in the NDK:
+^CMake Error at .*/Modules/Platform/Android/Determine-Compiler-NDK.cmake:[0-9]+ \(message\):(
+ Android: The CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION value '1.0' is not
+ supported by this NDK. It must be 'clang' or not set at all.|
+ Android: No toolchain for ABI 'armeabi(-v7a)?' found in the NDK:
.*
of the version specified by CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION:
1\.0
-
+)
Call Stack \(most recent call first\):
.*
ndk-badvernum.cmake:1 \(enable_language\)
diff --git a/Tests/RunCMake/Android/ndk-mips-stdout.txt b/Tests/RunCMake/Android/ndk-mips-stdout.txt
index c74468362..8ce544dcc 100644
--- a/Tests/RunCMake/Android/ndk-mips-stdout.txt
+++ b/Tests/RunCMake/Android/ndk-mips-stdout.txt
@@ -1,2 +1,2 @@
-- Android: Targeting API '[0-9]+' with architecture 'mips', ABI 'mips', and processor 'mips'
--- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
+-- Android: Selected (unified Clang toolchain|(Clang toolchain '[^']+' with )?GCC toolchain '[^']+')
diff --git a/Tests/RunCMake/Android/ndk-mips64-stdout.txt b/Tests/RunCMake/Android/ndk-mips64-stdout.txt
index 839ddfd1c..1d7edea60 100644
--- a/Tests/RunCMake/Android/ndk-mips64-stdout.txt
+++ b/Tests/RunCMake/Android/ndk-mips64-stdout.txt
@@ -1,2 +1,2 @@
-- Android: Targeting API '[0-9]+' with architecture 'mips64', ABI 'mips64', and processor 'mips64'
--- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
+-- Android: Selected (unified Clang toolchain|(Clang toolchain '[^']+' with )?GCC toolchain '[^']+')
diff --git a/Tests/RunCMake/Android/ndk-x86-stdout.txt b/Tests/RunCMake/Android/ndk-x86-stdout.txt
index 2dbb2f05e..8d710fe91 100644
--- a/Tests/RunCMake/Android/ndk-x86-stdout.txt
+++ b/Tests/RunCMake/Android/ndk-x86-stdout.txt
@@ -1,2 +1,2 @@
-- Android: Targeting API '[0-9]+' with architecture 'x86', ABI 'x86', and processor 'i686'
--- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
+-- Android: Selected (unified Clang toolchain|(Clang toolchain '[^']+' with )?GCC toolchain '[^']+')
diff --git a/Tests/RunCMake/Android/ndk-x86_64-stdout.txt b/Tests/RunCMake/Android/ndk-x86_64-stdout.txt
index a7ae91d09..695a088bd 100644
--- a/Tests/RunCMake/Android/ndk-x86_64-stdout.txt
+++ b/Tests/RunCMake/Android/ndk-x86_64-stdout.txt
@@ -1,2 +1,2 @@
-- Android: Targeting API '[0-9]+' with architecture 'x86_64', ABI 'x86_64', and processor 'x86_64'
--- Android: Selected (Clang toolchain '[^']+' with )?GCC toolchain '[^']+'
+-- Android: Selected (unified Clang toolchain|(Clang toolchain '[^']+' with )?GCC toolchain '[^']+')
diff --git a/Tests/RunCMake/AndroidMK/AndroidMK.cmake b/Tests/RunCMake/AndroidMK/AndroidMK.cmake
index 2596e8c30..9137f2be6 100644
--- a/Tests/RunCMake/AndroidMK/AndroidMK.cmake
+++ b/Tests/RunCMake/AndroidMK/AndroidMK.cmake
@@ -4,8 +4,10 @@ add_library(foo foo.cxx)
add_library(car foo.cxx)
add_library(bar bar.c)
add_library(dog foo.cxx)
-target_link_libraries(foo car bar dog debug -lm)
-export(TARGETS bar dog car foo ANDROID_MK
+target_link_libraries(foo PRIVATE car bar dog debug -lm)
+add_library(foo2 foo.cxx)
+target_link_options(foo2 INTERFACE -lm)
+export(TARGETS bar dog car foo foo2 ANDROID_MK
${build_BINARY_DIR}/Android.mk)
-install(TARGETS bar dog car foo DESTINATION lib EXPORT myexp)
+install(TARGETS bar dog car foo foo2 DESTINATION lib EXPORT myexp)
install(EXPORT_ANDROID_MK myexp DESTINATION share/ndk-modules)
diff --git a/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt b/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt
index bbf67a51c..a0e5044b1 100644
--- a/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt
+++ b/Tests/RunCMake/AndroidMK/expectedBuildAndroidMK.txt
@@ -24,3 +24,11 @@ LOCAL_STATIC_LIBRARIES.*car bar dog
LOCAL_EXPORT_LDLIBS := -lm
LOCAL_HAS_CPP := true
include.*PREBUILT_STATIC_LIBRARY.*
+.*
+include.*CLEAR_VARS.*
+LOCAL_MODULE.*foo2
+LOCAL_SRC_FILES.*.*foo2.*
+LOCAL_CPP_FEATURES.*rtti exceptions
+LOCAL_EXPORT_LDFLAGS := -lm
+LOCAL_HAS_CPP := true
+include.*PREBUILT_STATIC_LIBRARY.*
diff --git a/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt b/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt
index 3515fb9e9..28b1c210e 100644
--- a/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt
+++ b/Tests/RunCMake/AndroidMK/expectedInstallAndroidMK.txt
@@ -26,3 +26,11 @@ LOCAL_STATIC_LIBRARIES.*car bar dog
LOCAL_EXPORT_LDLIBS := -lm
LOCAL_HAS_CPP := true
include.*PREBUILT_STATIC_LIBRARY.*
+
+include.*CLEAR_VARS.*
+LOCAL_MODULE.*foo2
+LOCAL_SRC_FILES.*_IMPORT_PREFIX\)/lib.*foo2.*
+LOCAL_CPP_FEATURES.*rtti exceptions
+LOCAL_EXPORT_LDFLAGS := -lm
+LOCAL_HAS_CPP := true
+include.*PREBUILT_STATIC_LIBRARY.*
diff --git a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake
index f268de721..6c9be4bb1 100644
--- a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake
+++ b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake
@@ -7,20 +7,51 @@ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
run_cmake(AutoExport)
unset(RunCMake_TEST_OPTIONS)
# don't run this test on Watcom or Borland make as it is not supported
-if("${RunCMake_GENERATOR}" MATCHES "Watcom WMake|Borland Makefiles")
+if(RunCMake_GENERATOR MATCHES "Watcom WMake|Borland Makefiles")
return()
endif()
+if(RunCMake_GENERATOR MATCHES "Ninja|Visual Studio" AND
+ CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+ set(EXPORTS TRUE)
+endif()
# we build debug so the say.exe will be found in Debug/say.exe for
# Visual Studio generators
-if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode")
+if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(INTDIR "Debug/")
endif()
# build AutoExport
run_cmake_command(AutoExportBuild ${CMAKE_COMMAND} --build
${RunCMake_TEST_BINARY_DIR} --config Debug --clean-first)
+# save the current timestamp of exports.def
+if(EXPORTS)
+ set(EXPORTS_DEF "${RunCMake_TEST_BINARY_DIR}/say.dir/${INTDIR}exports.def")
+ if(NOT EXISTS "${EXPORTS_DEF}")
+ set(EXPORTS_DEF
+ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/say.dir/${INTDIR}exports.def")
+ endif()
+ file(TIMESTAMP "${EXPORTS_DEF}" timestamp)
+ if(NOT timestamp)
+ message(SEND_ERROR "Could not get timestamp for \"${EXPORTS_DEF}\"")
+ endif()
+endif()
# run the executable that uses symbols from the dll
if(WIN32)
set(EXE_EXT ".exe")
endif()
run_cmake_command(AutoExportRun
- ${RunCMake_BINARY_DIR}/AutoExport-build/bin/${INTDIR}say${EXE_EXT})
+ ${RunCMake_TEST_BINARY_DIR}/bin/${INTDIR}say${EXE_EXT})
+# build AutoExport again without modification
+run_cmake_command(AutoExportBuildAgain ${CMAKE_COMMAND} --build
+ ${RunCMake_TEST_BINARY_DIR} --config Debug)
+# compare timestamps of exports.def to make sure it has not been updated
+if(EXPORTS)
+ file(TIMESTAMP "${EXPORTS_DEF}" timestamp_after)
+ if(NOT timestamp_after)
+ message(SEND_ERROR "Could not get timestamp for \"${EXPORTS_DEF}\"")
+ endif()
+ if (timestamp_after STREQUAL timestamp)
+ message(STATUS "AutoExportTimeStamp - PASSED")
+ else()
+ message(SEND_ERROR "\"${EXPORTS_DEF}\" has been updated.")
+ endif()
+endif()
diff --git a/Tests/RunCMake/AutoExportDll/foo.c b/Tests/RunCMake/AutoExportDll/foo.c
index 4b1318b9e..d13bc3ede 100644
--- a/Tests/RunCMake/AutoExportDll/foo.c
+++ b/Tests/RunCMake/AutoExportDll/foo.c
@@ -1,7 +1,7 @@
#ifdef _MSC_VER
-#include "windows.h"
+# include "windows.h"
#else
-#define WINAPI
+# define WINAPI
#endif
int WINAPI foo()
diff --git a/Tests/RunCMake/AutoExportDll/hello.cxx b/Tests/RunCMake/AutoExportDll/hello.cxx
index 533fd3e72..74e7a4e94 100644
--- a/Tests/RunCMake/AutoExportDll/hello.cxx
+++ b/Tests/RunCMake/AutoExportDll/hello.cxx
@@ -1,4 +1,5 @@
#include "hello.h"
+
#include <stdio.h>
int Hello::Data = 0;
void Hello::real()
diff --git a/Tests/RunCMake/AutoExportDll/hello.h b/Tests/RunCMake/AutoExportDll/hello.h
index 3749b976f..7192f65af 100644
--- a/Tests/RunCMake/AutoExportDll/hello.h
+++ b/Tests/RunCMake/AutoExportDll/hello.h
@@ -1,11 +1,11 @@
#ifndef _MSC_VER
-#define winexport
+# define winexport
#else
-#ifdef autoexport_EXPORTS
-#define winexport
-#else
-#define winexport __declspec(dllimport)
-#endif
+# ifdef autoexport_EXPORTS
+# define winexport
+# else
+# define winexport __declspec(dllimport)
+# endif
#endif
class Hello
diff --git a/Tests/RunCMake/AutoExportDll/say.cxx b/Tests/RunCMake/AutoExportDll/say.cxx
index 51060e8de..654b5e03d 100644
--- a/Tests/RunCMake/AutoExportDll/say.cxx
+++ b/Tests/RunCMake/AutoExportDll/say.cxx
@@ -1,9 +1,10 @@
-#include "hello.h"
#include <stdio.h>
+
+#include "hello.h"
#ifdef _MSC_VER
-#include "windows.h"
+# include "windows.h"
#else
-#define WINAPI
+# define WINAPI
#endif
extern "C" {
diff --git a/Tests/RunCMake/Autogen/CMakeLists.txt b/Tests/RunCMake/Autogen/CMakeLists.txt
new file mode 100644
index 000000000..9a66cde9b
--- /dev/null
+++ b/Tests/RunCMake/Autogen/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.13)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/Autogen/NoQt-stderr.txt b/Tests/RunCMake/Autogen/NoQt-stderr.txt
new file mode 100644
index 000000000..1c6660a5e
--- /dev/null
+++ b/Tests/RunCMake/Autogen/NoQt-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Warning \(dev\) in CMakeLists.txt:
+ AUTOGEN: No valid Qt version found for target main. AUTOMOC, AUTOUIC and
+ AUTORCC disabled. Consider adding:
+
+ find_package\(Qt<QTVERSION> COMPONENTS Widgets\)
+
+ to your CMakeLists.txt file.
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/Autogen/NoQt.cmake b/Tests/RunCMake/Autogen/NoQt.cmake
new file mode 100644
index 000000000..b2d375ac6
--- /dev/null
+++ b/Tests/RunCMake/Autogen/NoQt.cmake
@@ -0,0 +1,6 @@
+enable_language(CXX)
+
+add_executable(main empty.cpp)
+set_property(TARGET main PROPERTY AUTOMOC 1)
+set_property(TARGET main PROPERTY AUTORCC 1)
+set_property(TARGET main PROPERTY AUTOUIC 1)
diff --git a/Tests/RunCMake/Autogen/QtInFunction.cmake b/Tests/RunCMake/Autogen/QtInFunction.cmake
new file mode 100644
index 000000000..a44bc5ab4
--- /dev/null
+++ b/Tests/RunCMake/Autogen/QtInFunction.cmake
@@ -0,0 +1,13 @@
+enable_language(CXX)
+
+function (use_autogen target)
+ find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
+ set(Qt5Core_VERSION_MAJOR "${Qt5Core_VERSION_MAJOR}" PARENT_SCOPE)
+ set(Qt5Core_VERSION_MINOR "${Qt5Core_VERSION_MINOR}" PARENT_SCOPE)
+ set_property(TARGET "${target}" PROPERTY AUTOMOC 1)
+ set_property(TARGET "${target}" PROPERTY AUTORCC 1)
+ set_property(TARGET "${target}" PROPERTY AUTOUIC 1)
+endfunction ()
+
+add_executable(main empty.cpp)
+use_autogen(main)
diff --git a/Tests/RunCMake/Autogen/QtInFunctionNested-stderr.txt b/Tests/RunCMake/Autogen/QtInFunctionNested-stderr.txt
new file mode 100644
index 000000000..1c6660a5e
--- /dev/null
+++ b/Tests/RunCMake/Autogen/QtInFunctionNested-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Warning \(dev\) in CMakeLists.txt:
+ AUTOGEN: No valid Qt version found for target main. AUTOMOC, AUTOUIC and
+ AUTORCC disabled. Consider adding:
+
+ find_package\(Qt<QTVERSION> COMPONENTS Widgets\)
+
+ to your CMakeLists.txt file.
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/Autogen/QtInFunctionNested.cmake b/Tests/RunCMake/Autogen/QtInFunctionNested.cmake
new file mode 100644
index 000000000..5421ba00d
--- /dev/null
+++ b/Tests/RunCMake/Autogen/QtInFunctionNested.cmake
@@ -0,0 +1,17 @@
+enable_language(CXX)
+
+function (use_autogen target)
+ find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
+ set(Qt5Core_VERSION_MAJOR "${Qt5Core_VERSION_MAJOR}" PARENT_SCOPE)
+ set(Qt5Core_VERSION_MINOR "${Qt5Core_VERSION_MINOR}" PARENT_SCOPE)
+ set_property(TARGET "${target}" PROPERTY AUTOMOC 1)
+ set_property(TARGET "${target}" PROPERTY AUTORCC 1)
+ set_property(TARGET "${target}" PROPERTY AUTOUIC 1)
+endfunction ()
+
+function (wrap_autogen target)
+ use_autogen("${target}")
+endfunction ()
+
+add_executable(main empty.cpp)
+wrap_autogen(main)
diff --git a/Tests/RunCMake/Autogen/QtInFunctionProperty.cmake b/Tests/RunCMake/Autogen/QtInFunctionProperty.cmake
new file mode 100644
index 000000000..35f1cd16c
--- /dev/null
+++ b/Tests/RunCMake/Autogen/QtInFunctionProperty.cmake
@@ -0,0 +1,21 @@
+enable_language(CXX)
+
+function (use_autogen target)
+ find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
+ set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ PROPERTY
+ Qt5Core_VERSION_MAJOR "${Qt5Core_VERSION_MAJOR}")
+ set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ PROPERTY
+ Qt5Core_VERSION_MINOR "${Qt5Core_VERSION_MINOR}")
+ set_property(TARGET "${target}" PROPERTY AUTOMOC 1)
+ set_property(TARGET "${target}" PROPERTY AUTORCC 1)
+ set_property(TARGET "${target}" PROPERTY AUTOUIC 1)
+endfunction ()
+
+function (wrap_autogen target)
+ use_autogen("${target}")
+endfunction ()
+
+add_executable(main empty.cpp)
+wrap_autogen(main)
diff --git a/Tests/RunCMake/Autogen/RunCMakeTest.cmake b/Tests/RunCMake/Autogen/RunCMakeTest.cmake
new file mode 100644
index 000000000..a31b67cd7
--- /dev/null
+++ b/Tests/RunCMake/Autogen/RunCMakeTest.cmake
@@ -0,0 +1,8 @@
+include(RunCMake)
+
+run_cmake(NoQt)
+if (with_qt5)
+ run_cmake(QtInFunction)
+ run_cmake(QtInFunctionNested)
+ run_cmake(QtInFunctionProperty)
+endif ()
diff --git a/Tests/RunCMake/Autogen/empty.cpp b/Tests/RunCMake/Autogen/empty.cpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/Autogen/empty.cpp
diff --git a/Tests/RunCMake/BuildDepends/BuildUnderSource.c b/Tests/RunCMake/BuildDepends/BuildUnderSource.c
new file mode 100644
index 000000000..688a040b7
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/BuildUnderSource.c
@@ -0,0 +1,5 @@
+#include "BuildUnderSource.h"
+int main(void)
+{
+ return BUILD_UNDER_SOURCE;
+}
diff --git a/Tests/RunCMake/BuildDepends/BuildUnderSource.cmake b/Tests/RunCMake/BuildDepends/BuildUnderSource.cmake
new file mode 100644
index 000000000..aa2a44f46
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/BuildUnderSource.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+include_directories(include)
+add_executable(BuildUnderSource BuildUnderSource.c)
+
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
+set(check_pairs
+ \"$<TARGET_FILE:BuildUnderSource>|${CMAKE_CURRENT_SOURCE_DIR}/include/BuildUnderSource.h\"
+ )
+")
diff --git a/Tests/RunCMake/BuildDepends/BuildUnderSource.step1.cmake b/Tests/RunCMake/BuildDepends/BuildUnderSource.step1.cmake
new file mode 100644
index 000000000..2cdd32be9
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/BuildUnderSource.step1.cmake
@@ -0,0 +1,3 @@
+file(WRITE "${RunCMake_TEST_SOURCE_DIR}/include/BuildUnderSource.h" [[
+#define BUILD_UNDER_SOURCE 1
+]])
diff --git a/Tests/RunCMake/BuildDepends/BuildUnderSource.step2.cmake b/Tests/RunCMake/BuildDepends/BuildUnderSource.step2.cmake
new file mode 100644
index 000000000..8e4b858e5
--- /dev/null
+++ b/Tests/RunCMake/BuildDepends/BuildUnderSource.step2.cmake
@@ -0,0 +1,3 @@
+file(WRITE "${RunCMake_TEST_SOURCE_DIR}/include/BuildUnderSource.h" [[
+#define BUILD_UNDER_SOURCE 2
+]])
diff --git a/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake
index ef3301216..87b0de010 100644
--- a/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake
+++ b/Tests/RunCMake/BuildDepends/C-Exe-Manifest.cmake
@@ -11,7 +11,7 @@ endif()
]])
endif()
-file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
set(check_pairs
\"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/test.manifest\"
)
diff --git a/Tests/RunCMake/BuildDepends/C-Exe.cmake b/Tests/RunCMake/BuildDepends/C-Exe.cmake
index 5057ca91d..ad5cd4d47 100644
--- a/Tests/RunCMake/BuildDepends/C-Exe.cmake
+++ b/Tests/RunCMake/BuildDepends/C-Exe.cmake
@@ -2,7 +2,7 @@ enable_language(C)
add_executable(main ${CMAKE_CURRENT_BINARY_DIR}/main.c)
-file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
set(check_pairs
\"$<TARGET_FILE:main>|${CMAKE_CURRENT_BINARY_DIR}/main.c\"
)
diff --git a/Tests/RunCMake/BuildDepends/Custom-Always.cmake b/Tests/RunCMake/BuildDepends/Custom-Always.cmake
index d412708a1..c7e7fb0bc 100644
--- a/Tests/RunCMake/BuildDepends/Custom-Always.cmake
+++ b/Tests/RunCMake/BuildDepends/Custom-Always.cmake
@@ -16,7 +16,7 @@ add_custom_command(
add_custom_target(drive ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/after-always)
-file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
set(check_pairs
\"${CMAKE_CURRENT_BINARY_DIR}/always-updated|${CMAKE_CURRENT_BINARY_DIR}/before-always\"
\"${CMAKE_CURRENT_BINARY_DIR}/after-always|${CMAKE_CURRENT_BINARY_DIR}/always-updated\"
diff --git a/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake b/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake
index 687c8271f..1e1f22ad0 100644
--- a/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake
+++ b/Tests/RunCMake/BuildDepends/Custom-Symbolic-and-Byproduct.cmake
@@ -16,7 +16,7 @@ add_custom_command(
add_custom_target(drive ALL DEPENDS use-byproduct)
add_dependencies(drive produce)
-file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
if (check_step EQUAL 1)
set(check_pairs
\"${CMAKE_CURRENT_BINARY_DIR}/use-byproduct|${CMAKE_CURRENT_BINARY_DIR}/gen-byproduct-stamp\"
diff --git a/Tests/RunCMake/BuildDepends/MakeCustomIncludes.cmake b/Tests/RunCMake/BuildDepends/MakeCustomIncludes.cmake
index 0f92e0edb..8b2ae78cf 100644
--- a/Tests/RunCMake/BuildDepends/MakeCustomIncludes.cmake
+++ b/Tests/RunCMake/BuildDepends/MakeCustomIncludes.cmake
@@ -6,7 +6,7 @@ add_custom_command(
add_custom_target(generate ALL DEPENDS output.cxx)
set_property(TARGET generate PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR})
-file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
set(check_pairs
\"${CMAKE_CURRENT_BINARY_DIR}/output.cxx|${CMAKE_CURRENT_BINARY_DIR}/MakeCustomIncludes.h\"
)
diff --git a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake
index add9aeb69..af6ad86ba 100644
--- a/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake
+++ b/Tests/RunCMake/BuildDepends/MakeInProjectOnly.cmake
@@ -3,7 +3,7 @@ get_filename_component(include_dir "${CMAKE_BINARY_DIR}" PATH)
include_directories("${include_dir}")
add_executable(MakeInProjectOnly MakeInProjectOnly.c)
set(CMAKE_DEPENDS_IN_PROJECT_ONLY 1)
-file(GENERATE OUTPUT check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
if (check_step EQUAL 1)
set(check_pairs
\"$<TARGET_FILE:MakeInProjectOnly>|${include_dir}/MakeInProjectOnly.h\"
diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake
index 9941c70df..14ae2439b 100644
--- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake
+++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake
@@ -9,9 +9,11 @@ endif()
function(run_BuildDepends CASE)
# Use a single build tree for a few tests without cleaning.
- set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build)
+ if(NOT RunCMake_TEST_BINARY_DIR)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build)
+ endif()
set(RunCMake_TEST_NO_CLEAN 1)
- if(RunCMake_GENERATOR MATCHES "Make|Ninja")
+ if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif()
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
@@ -32,7 +34,8 @@ endfunction()
run_BuildDepends(C-Exe)
if(NOT RunCMake_GENERATOR STREQUAL "Xcode")
- if(RunCMake_GENERATOR MATCHES "Visual Studio 10")
+ if(RunCMake_GENERATOR MATCHES "Visual Studio 10" OR
+ RunCMake_GENERATOR_TOOLSET MATCHES "^(v80|v90|v100)$")
# VS 10 forgets to re-link when a manifest changes
set(run_BuildDepends_skip_step_2 1)
endif()
@@ -43,6 +46,18 @@ endif()
run_BuildDepends(Custom-Symbolic-and-Byproduct)
run_BuildDepends(Custom-Always)
+# Test header dependencies with a build tree underneath a source tree.
+set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/BuildUnderSource")
+set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/BuildUnderSource/build")
+file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}")
+file(MAKE_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}/include")
+foreach(f CMakeLists.txt BuildUnderSource.cmake BuildUnderSource.c)
+ configure_file("${RunCMake_SOURCE_DIR}/${f}" "${RunCMake_TEST_SOURCE_DIR}/${f}" COPYONLY)
+endforeach()
+run_BuildDepends(BuildUnderSource)
+unset(RunCMake_TEST_BINARY_DIR)
+unset(RunCMake_TEST_SOURCE_DIR)
+
if(RunCMake_GENERATOR MATCHES "Make")
run_BuildDepends(MakeCustomIncludes)
if(NOT "${RunCMake_BINARY_DIR}" STREQUAL "${RunCMake_SOURCE_DIR}")
diff --git a/Tests/RunCMake/BundleUtilities/CMP0080-COMMAND.cmake b/Tests/RunCMake/BundleUtilities/CMP0080-COMMAND.cmake
new file mode 100644
index 000000000..063a7f3a7
--- /dev/null
+++ b/Tests/RunCMake/BundleUtilities/CMP0080-COMMAND.cmake
@@ -0,0 +1,5 @@
+if(DEFINED CMP0080_VALUE)
+ cmake_policy(SET CMP0080 ${CMP0080_VALUE})
+endif()
+
+include(BundleUtilities)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-result.txt b/Tests/RunCMake/BundleUtilities/CMP0080-NEW-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-result.txt
+++ b/Tests/RunCMake/BundleUtilities/CMP0080-NEW-result.txt
diff --git a/Tests/RunCMake/BundleUtilities/CMP0080-NEW-stderr.txt b/Tests/RunCMake/BundleUtilities/CMP0080-NEW-stderr.txt
new file mode 100644
index 000000000..1454b0c82
--- /dev/null
+++ b/Tests/RunCMake/BundleUtilities/CMP0080-NEW-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error at .*/Modules/BundleUtilities\.cmake:[0-9]+ \(message\):
+ BundleUtilities cannot be included at configure time!
diff --git a/Tests/RunCMake/BundleUtilities/CMP0080-NEW.cmake b/Tests/RunCMake/BundleUtilities/CMP0080-NEW.cmake
new file mode 100644
index 000000000..558c16d16
--- /dev/null
+++ b/Tests/RunCMake/BundleUtilities/CMP0080-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0080 NEW)
+include(BundleUtilities)
diff --git a/Tests/RunCMake/BundleUtilities/CMP0080-OLD.cmake b/Tests/RunCMake/BundleUtilities/CMP0080-OLD.cmake
new file mode 100644
index 000000000..a65d92f11
--- /dev/null
+++ b/Tests/RunCMake/BundleUtilities/CMP0080-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0080 OLD)
+include(BundleUtilities)
diff --git a/Tests/RunCMake/BundleUtilities/CMP0080-WARN-stderr.txt b/Tests/RunCMake/BundleUtilities/CMP0080-WARN-stderr.txt
new file mode 100644
index 000000000..c3d541e47
--- /dev/null
+++ b/Tests/RunCMake/BundleUtilities/CMP0080-WARN-stderr.txt
@@ -0,0 +1,10 @@
+CMake Warning \(dev\) at .*/Modules/BundleUtilities\.cmake:[0-9]+ \(message\):
+ Policy CMP0080 is not set: BundleUtilities cannot be included at configure
+ time\. Run "cmake --help-policy CMP0080" for policy details\. Use the
+ cmake_policy command to set the policy and suppress this warning\.
+
+Call Stack \(most recent call first\):
+ .*/Modules/BundleUtilities\.cmake:[0-9]+ \(_warn_cmp0080\)
+ CMP0080-WARN\.cmake:[0-9]+ \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\. Use -Wno-dev to suppress it\.
diff --git a/Tests/RunCMake/BundleUtilities/CMP0080-WARN.cmake b/Tests/RunCMake/BundleUtilities/CMP0080-WARN.cmake
new file mode 100644
index 000000000..45f6f92b9
--- /dev/null
+++ b/Tests/RunCMake/BundleUtilities/CMP0080-WARN.cmake
@@ -0,0 +1 @@
+include(BundleUtilities)
diff --git a/Tests/RunCMake/BundleUtilities/CMakeLists.txt b/Tests/RunCMake/BundleUtilities/CMakeLists.txt
new file mode 100644
index 000000000..6dd8cdf55
--- /dev/null
+++ b/Tests/RunCMake/BundleUtilities/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.4)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/BundleUtilities/RunCMakeTest.cmake b/Tests/RunCMake/BundleUtilities/RunCMakeTest.cmake
new file mode 100644
index 000000000..14aaff197
--- /dev/null
+++ b/Tests/RunCMake/BundleUtilities/RunCMakeTest.cmake
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.4)
+include(RunCMake)
+
+# TODO Migrate Tests/BundleUtilities here
+
+run_cmake(CMP0080-OLD)
+run_cmake(CMP0080-NEW)
+run_cmake(CMP0080-WARN)
+run_cmake_command(CMP0080-COMMAND-OLD ${CMAKE_COMMAND} -DCMP0080_VALUE:STRING=OLD -P ${RunCMake_SOURCE_DIR}/CMP0080-COMMAND.cmake)
+run_cmake_command(CMP0080-COMMAND-NEW ${CMAKE_COMMAND} -DCMP0080_VALUE:STRING=NEW -P ${RunCMake_SOURCE_DIR}/CMP0080-COMMAND.cmake)
+run_cmake_command(CMP0080-COMMAND-WARN ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/CMP0080-COMMAND.cmake)
diff --git a/Tests/RunCMake/Byproducts/CMakeLists.txt b/Tests/RunCMake/Byproducts/CMakeLists.txt
new file mode 100644
index 000000000..bf2ef1506
--- /dev/null
+++ b/Tests/RunCMake/Byproducts/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.10)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/Byproducts/CleanByproducts.cmake b/Tests/RunCMake/Byproducts/CleanByproducts.cmake
new file mode 100644
index 000000000..85d958295
--- /dev/null
+++ b/Tests/RunCMake/Byproducts/CleanByproducts.cmake
@@ -0,0 +1,93 @@
+cmake_minimum_required(VERSION 3.10)
+project(CleanByproducts)
+
+# Configurable parameters
+set(TEST_CLEAN_NO_CUSTOM FALSE CACHE BOOL "Value for the CLEAN_NO_CUSTOM PROPERTY")
+set(TEST_BUILD_EVENTS TRUE CACHE BOOL "Create byproducts with build events")
+set(TEST_CUSTOM_TARGET TRUE CACHE BOOL "Create a byproduct with a custom target")
+set(TEST_CUSTOM_COMMAND TRUE CACHE BOOL "Create a byproduct with a custom command")
+
+set_property(DIRECTORY PROPERTY CLEAN_NO_CUSTOM ${TEST_CLEAN_NO_CUSTOM})
+
+macro(add_build_event)
+ set(oneValueArgs EVENT)
+
+ cmake_parse_Arguments(ABE "" "${oneValueArgs}" "" ${ARGN})
+
+ # Create two byproducts and only declare one
+ add_custom_command(TARGET foo
+ ${ABE_EVENT}
+ COMMAND ${CMAKE_COMMAND} -E touch foo.${ABE_EVENT}
+ COMMAND ${CMAKE_COMMAND} -E touch foo.${ABE_EVENT}.notdeclared
+ COMMENT "Creating byproducts with ${ABE_EVENT}"
+ BYPRODUCTS foo.${ABE_EVENT}
+ )
+
+ # The nondeclared byproduct should always be present
+ list(APPEND EXPECTED_PRESENT foo.${ABE_EVENT}.notdeclared)
+
+ # If CLEAN_NO_CUSTOM is set, the declared byproduct should be present
+ if(TEST_CLEAN_NO_CUSTOM)
+ list(APPEND EXPECTED_PRESENT foo.${ABE_EVENT})
+ else()
+ list(APPEND EXPECTED_DELETED foo.${ABE_EVENT})
+ endif()
+endmacro()
+
+add_executable(foo foo.cpp)
+
+# Test build events
+if(TEST_BUILD_EVENTS)
+ add_build_event(EVENT "PRE_BUILD" ENABLE ${TEST_PRE_BUILD})
+ add_build_event(EVENT "PRE_LINK" ENABLE ${TEST_PRE_LINK})
+ add_build_event(EVENT "POST_BUILD" ENABLE ${TEST_POST_BUILD})
+endif()
+
+# Custom command that generates byproducts
+if(TEST_CUSTOM_COMMAND)
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bar.cpp.in "void bar() {}\n")
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bar.cpp
+ COMMAND ${CMAKE_COMMAND} -E touch foo.customcommand
+ COMMAND ${CMAKE_COMMAND} -E touch foo.customcommand.notdeclared
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/bar.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/bar.cpp
+ BYPRODUCTS foo.customcommand
+ COMMENT "Creating byproducts with a custom command"
+ )
+
+ # The nondeclared byproduct should always be present
+ list(APPEND EXPECTED_PRESENT "foo.customcommand.notdeclared")
+
+ # If CLEAN_NO_CUSTOM is set, both the output and byproduct should be present
+ if(TEST_CLEAN_NO_CUSTOM)
+ list(APPEND EXPECTED_PRESENT "bar.cpp")
+ list(APPEND EXPECTED_PRESENT "foo.customcommand")
+ else()
+ list(APPEND EXPECTED_DELETED "bar.cpp")
+ list(APPEND EXPECTED_DELETED "foo.customcommand")
+ endif()
+
+ target_sources(foo PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/bar.cpp")
+endif()
+
+# Custom target that generates byproducts
+if(TEST_CUSTOM_TARGET)
+ add_custom_target(foo_file ALL
+ DEPENDS foo
+ COMMAND ${CMAKE_COMMAND} -E touch foo.customtarget
+ COMMAND ${CMAKE_COMMAND} -E touch foo.customtarget.notdeclared
+ BYPRODUCTS foo.customtarget
+ COMMENT "Creating byproducts with a custom target"
+ )
+
+ # The nondeclared byproduct should always be present
+ list(APPEND EXPECTED_PRESENT "foo.customtarget.notdeclared")
+
+ # If CLEAN_NO_CUSTOM is set, the declared byproduct should be present
+ if(TEST_CLEAN_NO_CUSTOM)
+ list(APPEND EXPECTED_PRESENT "foo.customtarget")
+ else()
+ list(APPEND EXPECTED_DELETED "foo.customtarget")
+ endif()
+endif()
+
+configure_file(files.cmake.in files.cmake)
diff --git a/Tests/RunCMake/Byproducts/RunCMakeTest.cmake b/Tests/RunCMake/Byproducts/RunCMakeTest.cmake
new file mode 100644
index 000000000..a7584ee4b
--- /dev/null
+++ b/Tests/RunCMake/Byproducts/RunCMakeTest.cmake
@@ -0,0 +1,58 @@
+include(RunCMake)
+
+function(run_CleanByproducts case)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CleanByproducts-${case}-build)
+ set(RunCMake_TEST_OPTIONS "${ARGN}")
+
+ run_cmake(CleanByproducts)
+ set(RunCMake_TEST_NO_CLEAN 1)
+
+ run_cmake_command(CleanByProducts-build ${CMAKE_COMMAND} --build .)
+ include("${RunCMake_TEST_BINARY_DIR}/files.cmake")
+
+ message("Checking that all expected files are present")
+ check_files(EXPECTED_PRESENT "${RunCMake_TEST_BINARY_DIR}" TRUE)
+ check_files(EXPECTED_DELETED "${RunCMake_TEST_BINARY_DIR}" TRUE)
+
+ run_cmake_command(CleanByProducts-clean ${CMAKE_COMMAND} --build . --target clean)
+
+ message("Checking that only the expected files are present after cleaning")
+ check_files(EXPECTED_PRESENT "${RunCMake_TEST_BINARY_DIR}" TRUE)
+ check_files(EXPECTED_DELETED "${RunCMake_TEST_BINARY_DIR}" FALSE)
+endfunction()
+
+function(check_files list path has_to_exist)
+ foreach(file IN LISTS ${list})
+ message("Checking ${file}")
+ set(file_exists FALSE)
+ if(EXISTS "${path}/${file}")
+ set(file_exists TRUE)
+ endif()
+
+ if(file_exists AND NOT has_to_exist)
+ message(FATAL_ERROR "${file} should have been deleted")
+ elseif(NOT file_exists AND has_to_exist)
+ message(FATAL_ERROR "${file} does not exist")
+ elseif(file_exists AND has_to_exist)
+ message("${file} found as expected")
+ elseif(NOT file_exists AND NOT has_to_exist)
+ message("${file} deleted as expected")
+ endif()
+
+ endforeach()
+endfunction()
+
+
+# Iterate through all possible test values
+set(counter 0)
+foreach(test_clean_no_custom TRUE FALSE)
+ foreach(test_build_events TRUE FALSE)
+ foreach(test_custom_command TRUE FALSE)
+ foreach(test_custom_target TRUE FALSE)
+ math(EXPR counter "${counter} + 1")
+ message("Test ${counter} - CLEAN_NO_CUSTOM: ${test_clean_no_custom}, Build events: ${test_build_events}, Custom command: ${test_custom_command}, Custom target: ${test_custom_target}")
+ run_CleanByproducts("buildevents${counter}" -DCLEAN_NO_CUSTOM=${test_clean_no_custom} -DTEST_BUILD_EVENTS=${test_build_events} -DTEST_CUSTOM_COMMAND=${test_custom_command} -DTEST_CUSTOM_TARGET=${test_custom_target})
+ endforeach()
+ endforeach()
+ endforeach()
+endforeach()
diff --git a/Tests/RunCMake/Byproducts/files.cmake.in b/Tests/RunCMake/Byproducts/files.cmake.in
new file mode 100644
index 000000000..a7d4831fc
--- /dev/null
+++ b/Tests/RunCMake/Byproducts/files.cmake.in
@@ -0,0 +1,2 @@
+set(EXPECTED_PRESENT "@EXPECTED_PRESENT@")
+set(EXPECTED_DELETED "@EXPECTED_DELETED@")
diff --git a/Tests/RunCMake/Byproducts/foo.cpp b/Tests/RunCMake/Byproducts/foo.cpp
new file mode 100644
index 000000000..d47cb91a6
--- /dev/null
+++ b/Tests/RunCMake/Byproducts/foo.cpp
@@ -0,0 +1,14 @@
+int bar(int y)
+{
+ return y * 6;
+}
+
+int foo(int x)
+{
+ return x * bar(x);
+}
+
+int main()
+{
+ return foo(4);
+}
diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-stderr.txt
index 05b021746..6a1f1bde4 100644
--- a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-stderr.txt
+++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-stderr.txt
@@ -4,4 +4,4 @@ CMake Error at CMP0026-CONFIG-LOCATION-NEW.cmake:7 \(get_target_property\):
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-stderr.txt
index edeb33728..84dec3212 100644
--- a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-stderr.txt
+++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-stderr.txt
@@ -7,4 +7,4 @@
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
- CMakeLists.txt:[0-9]+ \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-stderr.txt
index d44dcb48d..d2209fdc8 100644
--- a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-stderr.txt
+++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-stderr.txt
@@ -8,5 +8,5 @@ CMake Warning \(dev\) at CMP0026-CONFIG-LOCATION-WARN.cmake:5 \(get_target_prope
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-stderr.txt
index fec9dfb4d..1490103d5 100644
--- a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-stderr.txt
+++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-stderr.txt
@@ -4,4 +4,4 @@ CMake Error at CMP0026-LOCATION-CONFIG-NEW.cmake:7 \(get_target_property\):
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-stderr.txt
index 32ff698f1..1fb4ef679 100644
--- a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-stderr.txt
+++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-stderr.txt
@@ -7,4 +7,4 @@
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
- CMakeLists.txt:[0-9]+ \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-stderr.txt
index cd6f3d095..8b4faf011 100644
--- a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-stderr.txt
+++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-stderr.txt
@@ -8,5 +8,5 @@ CMake Warning \(dev\) at CMP0026-LOCATION-CONFIG-WARN.cmake:5 \(get_target_prope
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0026/CMP0026-NEW-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-NEW-stderr.txt
index fa025129f..8c47c2ab3 100644
--- a/Tests/RunCMake/CMP0026/CMP0026-NEW-stderr.txt
+++ b/Tests/RunCMake/CMP0026/CMP0026-NEW-stderr.txt
@@ -4,4 +4,4 @@ CMake Error at CMP0026-NEW.cmake:7 \(get_target_property\):
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/CMP0026/CMP0026-OLD-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-OLD-stderr.txt
index b3f79fc4d..b4282f545 100644
--- a/Tests/RunCMake/CMP0026/CMP0026-OLD-stderr.txt
+++ b/Tests/RunCMake/CMP0026/CMP0026-OLD-stderr.txt
@@ -7,4 +7,4 @@
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
- CMakeLists.txt:[0-9]+ \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/CMP0026/CMP0026-WARN-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-WARN-stderr.txt
index d122c4a2e..0d39596b4 100644
--- a/Tests/RunCMake/CMP0026/CMP0026-WARN-stderr.txt
+++ b/Tests/RunCMake/CMP0026/CMP0026-WARN-stderr.txt
@@ -8,7 +8,7 @@ CMake Warning \(dev\) at CMP0026-WARN.cmake:5 \(get_target_property\):
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
+
CMake Warning \(dev\) at CMP0026-WARN.cmake:8 \(get_target_property\):
@@ -21,5 +21,5 @@ CMake Warning \(dev\) at CMP0026-WARN.cmake:8 \(get_target_property\):
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0026/LOCATION-and-TARGET_OBJECTS-stderr.txt b/Tests/RunCMake/CMP0026/LOCATION-and-TARGET_OBJECTS-stderr.txt
index 0996cb6b4..63779219a 100644
--- a/Tests/RunCMake/CMP0026/LOCATION-and-TARGET_OBJECTS-stderr.txt
+++ b/Tests/RunCMake/CMP0026/LOCATION-and-TARGET_OBJECTS-stderr.txt
@@ -8,5 +8,5 @@ CMake Warning \(dev\) at LOCATION-and-TARGET_OBJECTS.cmake:[0-9]+ \(get_target_p
\$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
- CMakeLists.txt:[0-9]+ \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt b/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt
index 87d198d00..360d98765 100644
--- a/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt
+++ b/Tests/RunCMake/CMP0026/ObjlibNotDefined-stderr.txt
@@ -8,5 +8,5 @@ CMake Warning \(dev\) at ObjlibNotDefined.cmake:[0-9]+ \(get_target_property\):
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0026/clear-cached-information-stderr.txt b/Tests/RunCMake/CMP0026/clear-cached-information-stderr.txt
index 157a0468a..3525704bb 100644
--- a/Tests/RunCMake/CMP0026/clear-cached-information-stderr.txt
+++ b/Tests/RunCMake/CMP0026/clear-cached-information-stderr.txt
@@ -7,4 +7,4 @@
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
- CMakeLists.txt:[0-9]+ \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake
index f4c070d7a..fd56e7566 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake
+++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-colon.cmake
@@ -1,4 +1,4 @@
-
+enable_language(CXX)
cmake_policy(SET CMP0037 NEW)
add_library("lib:colon" empty.cpp)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake
index e9f640469..83a711909 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake
+++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-reserved.cmake
@@ -1,4 +1,4 @@
-
+enable_language(CXX)
cmake_policy(SET CMP0037 NEW)
add_library(all empty.cpp)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake
index 9227986e9..2a288cc99 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake
+++ b/Tests/RunCMake/CMP0037/CMP0037-NEW-space.cmake
@@ -1,4 +1,4 @@
-
+enable_language(CXX)
cmake_policy(SET CMP0037 NEW)
add_library("lib with spaces" empty.cpp)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-stderr.txt
new file mode 100644
index 000000000..de093517e
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0037-OLD-reserved.cmake:2 \(cmake_policy\):
+ The OLD behavior for policy CMP0037 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake
index 870a28672..f52e4d2d0 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake
+++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved.cmake
@@ -1,4 +1,4 @@
-
+enable_language(CXX)
cmake_policy(SET CMP0037 OLD)
add_library(all empty.cpp)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-space-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-OLD-space-stderr.txt
new file mode 100644
index 000000000..4d13e59ef
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-space-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0037-OLD-space.cmake:2 \(cmake_policy\):
+ The OLD behavior for policy CMP0037 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake
index 46193a1fa..c9fb6c890 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake
+++ b/Tests/RunCMake/CMP0037/CMP0037-OLD-space.cmake
@@ -1,4 +1,4 @@
-
+enable_language(CXX)
cmake_policy(SET CMP0037 OLD)
add_library("lib with spaces" empty.cpp)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake
index 445e3b23e..1b1a405e8 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake
+++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-colon.cmake
@@ -1,4 +1,4 @@
-
+enable_language(CXX)
add_library("lib:colon" empty.cpp)
add_executable("exe:colon" empty.cpp)
add_custom_target("custom:colon")
diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-reserved-stderr.txt b/Tests/RunCMake/CMP0037/CMP0037-WARN-reserved-stderr.txt
new file mode 100644
index 000000000..2d556a7e8
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-reserved-stderr.txt
@@ -0,0 +1,36 @@
+CMake Warning \(dev\) at CMP0037-WARN-reserved.cmake:2 \(add_library\):
+ Policy CMP0037 is not set: Target names should not be reserved and should
+ match a validity pattern. Run "cmake --help-policy CMP0037" for policy
+ details. Use the cmake_policy command to set the policy and suppress this
+ warning.
+
+ The target name "all" is reserved or not valid for certain CMake features,
+ such as generator expressions, and may result in undefined behavior.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
++
+CMake Warning \(dev\) at CMP0037-WARN-reserved.cmake:3 \(add_executable\):
+ Policy CMP0037 is not set: Target names should not be reserved and should
+ match a validity pattern. Run "cmake --help-policy CMP0037" for policy
+ details. Use the cmake_policy command to set the policy and suppress this
+ warning.
+
+ The target name "clean" is reserved or not valid for certain CMake
+ features, such as generator expressions, and may result in undefined
+ behavior.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
++
+CMake Warning \(dev\) at CMP0037-WARN-reserved.cmake:4 \(add_custom_target\):
+ Policy CMP0037 is not set: Target names should not be reserved and should
+ match a validity pattern. Run "cmake --help-policy CMP0037" for policy
+ details. Use the cmake_policy command to set the policy and suppress this
+ warning.
+
+ The target name "help" is reserved or not valid for certain CMake features,
+ such as generator expressions, and may result in undefined behavior.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-reserved.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-reserved.cmake
new file mode 100644
index 000000000..a5e0f10dd
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-reserved.cmake
@@ -0,0 +1,4 @@
+enable_language(CXX)
+add_library(all empty.cpp)
+add_executable(clean empty.cpp)
+add_custom_target(help)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake
index e50a64dcf..e01b8e5ec 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake
+++ b/Tests/RunCMake/CMP0037/CMP0037-WARN-space.cmake
@@ -1,4 +1,4 @@
-
+enable_language(CXX)
add_library("lib with spaces" empty.cpp)
add_executable("exe with spaces" empty.cpp)
add_custom_target("custom with spaces")
diff --git a/Tests/RunCMake/CMP0037/CMakeLists.txt b/Tests/RunCMake/CMP0037/CMakeLists.txt
index f452db177..12cd3c775 100644
--- a/Tests/RunCMake/CMP0037/CMakeLists.txt
+++ b/Tests/RunCMake/CMP0037/CMakeLists.txt
@@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 2.8.4)
-project(${RunCMake_TEST} CXX)
+project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileOptions-result.txt b/Tests/RunCMake/CMP0037/NEW-cond-package-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileOptions-result.txt
+++ b/Tests/RunCMake/CMP0037/NEW-cond-package-result.txt
diff --git a/Tests/RunCMake/CMP0037/NEW-cond-package-stderr.txt b/Tests/RunCMake/CMP0037/NEW-cond-package-stderr.txt
new file mode 100644
index 000000000..270fa6db2
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/NEW-cond-package-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at NEW-cond-package.cmake:4 \(add_custom_target\):
+ The target name "package" is reserved when CPack packaging is enabled.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0037/NEW-cond-package.cmake b/Tests/RunCMake/CMP0037/NEW-cond-package.cmake
new file mode 100644
index 000000000..ceea90783
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/NEW-cond-package.cmake
@@ -0,0 +1,5 @@
+cmake_policy(SET CMP0037 NEW)
+file(WRITE "${CMAKE_BINARY_DIR}/CPackConfig.cmake" "")
+add_custom_target(test)
+add_custom_target(package)
+add_custom_target(package_source)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-result.txt b/Tests/RunCMake/CMP0037/NEW-cond-package_source-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-result.txt
+++ b/Tests/RunCMake/CMP0037/NEW-cond-package_source-result.txt
diff --git a/Tests/RunCMake/CMP0037/NEW-cond-package_source-stderr.txt b/Tests/RunCMake/CMP0037/NEW-cond-package_source-stderr.txt
new file mode 100644
index 000000000..2d321473b
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/NEW-cond-package_source-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at NEW-cond-package_source.cmake:5 \(add_custom_target\):
+ The target name "package_source" is reserved when CPack source packaging is
+ enabled.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0037/NEW-cond-package_source.cmake b/Tests/RunCMake/CMP0037/NEW-cond-package_source.cmake
new file mode 100644
index 000000000..3f8883b3d
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/NEW-cond-package_source.cmake
@@ -0,0 +1,5 @@
+cmake_policy(SET CMP0037 NEW)
+file(WRITE "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake" "")
+add_custom_target(test)
+add_custom_target(package)
+add_custom_target(package_source)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-result.txt b/Tests/RunCMake/CMP0037/NEW-cond-test-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-result.txt
+++ b/Tests/RunCMake/CMP0037/NEW-cond-test-result.txt
diff --git a/Tests/RunCMake/CMP0037/NEW-cond-test-stderr.txt b/Tests/RunCMake/CMP0037/NEW-cond-test-stderr.txt
new file mode 100644
index 000000000..44b4741ea
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/NEW-cond-test-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at NEW-cond-test.cmake:3 \(add_custom_target\):
+ The target name "test" is reserved when CTest testing is enabled.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0037/NEW-cond-test.cmake b/Tests/RunCMake/CMP0037/NEW-cond-test.cmake
new file mode 100644
index 000000000..7eeaffcc3
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/NEW-cond-test.cmake
@@ -0,0 +1,5 @@
+cmake_policy(SET CMP0037 NEW)
+enable_testing()
+add_custom_target(test)
+add_custom_target(package)
+add_custom_target(package_source)
diff --git a/Tests/RunCMake/CMP0037/NEW-cond.cmake b/Tests/RunCMake/CMP0037/NEW-cond.cmake
new file mode 100644
index 000000000..d0dc77af3
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/NEW-cond.cmake
@@ -0,0 +1,4 @@
+cmake_policy(SET CMP0037 NEW)
+add_custom_target(test)
+add_custom_target(package)
+add_custom_target(package_source)
diff --git a/Tests/RunCMake/CMP0037/OLD-cond-package-stderr.txt b/Tests/RunCMake/CMP0037/OLD-cond-package-stderr.txt
new file mode 100644
index 000000000..5a29a49c3
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/OLD-cond-package-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at OLD-cond-package.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0037 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0037/OLD-cond-package.cmake b/Tests/RunCMake/CMP0037/OLD-cond-package.cmake
new file mode 100644
index 000000000..7a0afbe10
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/OLD-cond-package.cmake
@@ -0,0 +1,5 @@
+cmake_policy(SET CMP0037 OLD)
+file(WRITE "${CMAKE_BINARY_DIR}/CPackConfig.cmake" "")
+add_custom_target(test)
+add_custom_target(package)
+add_custom_target(package_source)
diff --git a/Tests/RunCMake/CMP0037/OLD-cond-package_source-stderr.txt b/Tests/RunCMake/CMP0037/OLD-cond-package_source-stderr.txt
new file mode 100644
index 000000000..5f72e1675
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/OLD-cond-package_source-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at OLD-cond-package_source.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0037 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0037/OLD-cond-package_source.cmake b/Tests/RunCMake/CMP0037/OLD-cond-package_source.cmake
new file mode 100644
index 000000000..95616b685
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/OLD-cond-package_source.cmake
@@ -0,0 +1,5 @@
+cmake_policy(SET CMP0037 OLD)
+file(WRITE "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake" "")
+add_custom_target(test)
+add_custom_target(package)
+add_custom_target(package_source)
diff --git a/Tests/RunCMake/CMP0037/OLD-cond-stderr.txt b/Tests/RunCMake/CMP0037/OLD-cond-stderr.txt
new file mode 100644
index 000000000..94e4575c0
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/OLD-cond-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at OLD-cond.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0037 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0037/OLD-cond-test-stderr.txt b/Tests/RunCMake/CMP0037/OLD-cond-test-stderr.txt
new file mode 100644
index 000000000..81e10ce42
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/OLD-cond-test-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at OLD-cond-test.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0037 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0037/OLD-cond-test.cmake b/Tests/RunCMake/CMP0037/OLD-cond-test.cmake
new file mode 100644
index 000000000..bfa32a954
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/OLD-cond-test.cmake
@@ -0,0 +1,5 @@
+cmake_policy(SET CMP0037 OLD)
+enable_testing()
+add_custom_target(test)
+add_custom_target(package)
+add_custom_target(package_source)
diff --git a/Tests/RunCMake/CMP0037/OLD-cond.cmake b/Tests/RunCMake/CMP0037/OLD-cond.cmake
new file mode 100644
index 000000000..abad68053
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/OLD-cond.cmake
@@ -0,0 +1,5 @@
+cmake_policy(SET CMP0037 OLD)
+
+add_custom_target(test)
+add_custom_target(package)
+add_custom_target(package_source)
diff --git a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake
index b7d8d7bb4..98274f08b 100644
--- a/Tests/RunCMake/CMP0037/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMP0037/RunCMakeTest.cmake
@@ -9,5 +9,22 @@ if(NOT (WIN32 AND "${RunCMake_GENERATOR}" MATCHES "Make"))
run_cmake(CMP0037-WARN-colon)
endif()
+run_cmake(CMP0037-WARN-reserved)
run_cmake(CMP0037-OLD-reserved)
run_cmake(CMP0037-NEW-reserved)
+
+run_cmake(NEW-cond)
+run_cmake(NEW-cond-test)
+run_cmake(NEW-cond-package)
+run_cmake(OLD-cond)
+run_cmake(OLD-cond-test)
+run_cmake(OLD-cond-package)
+run_cmake(WARN-cond)
+run_cmake(WARN-cond-test)
+run_cmake(WARN-cond-package)
+
+if(RunCMake_GENERATOR MATCHES "Make|Ninja")
+ run_cmake(NEW-cond-package_source)
+ run_cmake(OLD-cond-package_source)
+ run_cmake(WARN-cond-package_source)
+endif()
diff --git a/Tests/RunCMake/CMP0037/WARN-cond-package-stderr.txt b/Tests/RunCMake/CMP0037/WARN-cond-package-stderr.txt
new file mode 100644
index 000000000..5960e5149
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/WARN-cond-package-stderr.txt
@@ -0,0 +1,11 @@
+^CMake Warning \(dev\) at WARN-cond-package.cmake:4 \(add_custom_target\):
+ Policy CMP0037 is not set: Target names should not be reserved and should
+ match a validity pattern. Run "cmake --help-policy CMP0037" for policy
+ details. Use the cmake_policy command to set the policy and suppress this
+ warning.
+
+ The target name "package" is reserved when CPack packaging is enabled. It
+ may result in undefined behavior.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/CMP0037/WARN-cond-package.cmake b/Tests/RunCMake/CMP0037/WARN-cond-package.cmake
new file mode 100644
index 000000000..61cdc6834
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/WARN-cond-package.cmake
@@ -0,0 +1,5 @@
+
+file(WRITE "${CMAKE_BINARY_DIR}/CPackConfig.cmake" "")
+add_custom_target(test)
+add_custom_target(package)
+add_custom_target(package_source)
diff --git a/Tests/RunCMake/CMP0037/WARN-cond-package_source-stderr.txt b/Tests/RunCMake/CMP0037/WARN-cond-package_source-stderr.txt
new file mode 100644
index 000000000..ae729092b
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/WARN-cond-package_source-stderr.txt
@@ -0,0 +1,11 @@
+^CMake Warning \(dev\) at WARN-cond-package_source.cmake:5 \(add_custom_target\):
+ Policy CMP0037 is not set: Target names should not be reserved and should
+ match a validity pattern. Run "cmake --help-policy CMP0037" for policy
+ details. Use the cmake_policy command to set the policy and suppress this
+ warning.
+
+ The target name "package_source" is reserved when CPack source packaging is
+ enabled. It may result in undefined behavior.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/CMP0037/WARN-cond-package_source.cmake b/Tests/RunCMake/CMP0037/WARN-cond-package_source.cmake
new file mode 100644
index 000000000..468380c36
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/WARN-cond-package_source.cmake
@@ -0,0 +1,5 @@
+
+file(WRITE "${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake" "")
+add_custom_target(test)
+add_custom_target(package)
+add_custom_target(package_source)
diff --git a/Tests/RunCMake/CMP0037/WARN-cond-test-stderr.txt b/Tests/RunCMake/CMP0037/WARN-cond-test-stderr.txt
new file mode 100644
index 000000000..e7a3ee594
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/WARN-cond-test-stderr.txt
@@ -0,0 +1,11 @@
+^CMake Warning \(dev\) at WARN-cond-test.cmake:3 \(add_custom_target\):
+ Policy CMP0037 is not set: Target names should not be reserved and should
+ match a validity pattern. Run "cmake --help-policy CMP0037" for policy
+ details. Use the cmake_policy command to set the policy and suppress this
+ warning.
+
+ The target name "test" is reserved when CTest testing is enabled. It may
+ result in undefined behavior.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/CMP0037/WARN-cond-test.cmake b/Tests/RunCMake/CMP0037/WARN-cond-test.cmake
new file mode 100644
index 000000000..982af369e
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/WARN-cond-test.cmake
@@ -0,0 +1,5 @@
+
+enable_testing()
+add_custom_target(test)
+add_custom_target(package)
+add_custom_target(package_source)
diff --git a/Tests/RunCMake/CMP0037/WARN-cond.cmake b/Tests/RunCMake/CMP0037/WARN-cond.cmake
new file mode 100644
index 000000000..04a7f9da2
--- /dev/null
+++ b/Tests/RunCMake/CMP0037/WARN-cond.cmake
@@ -0,0 +1,4 @@
+
+add_custom_target(test)
+add_custom_target(package)
+add_custom_target(package_source)
diff --git a/Tests/RunCMake/CMP0038/CMP0038-OLD-stderr.txt b/Tests/RunCMake/CMP0038/CMP0038-OLD-stderr.txt
new file mode 100644
index 000000000..c75412861
--- /dev/null
+++ b/Tests/RunCMake/CMP0038/CMP0038-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0038-OLD.cmake:2 \(cmake_policy\):
+ The OLD behavior for policy CMP0038 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0039/CMP0039-OLD-stderr.txt b/Tests/RunCMake/CMP0039/CMP0039-OLD-stderr.txt
new file mode 100644
index 000000000..d7863fd3c
--- /dev/null
+++ b/Tests/RunCMake/CMP0039/CMP0039-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0039-OLD.cmake:2 \(cmake_policy\):
+ The OLD behavior for policy CMP0039 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target-stderr.txt b/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target-stderr.txt
new file mode 100644
index 000000000..f38c03d06
--- /dev/null
+++ b/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0040-OLD-existing-target.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0040 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target-stderr.txt b/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target-stderr.txt
new file mode 100644
index 000000000..61f4f035d
--- /dev/null
+++ b/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0040-OLD-missing-target.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0040 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt
index e3e3ff468..70ed05ba1 100644
--- a/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt
+++ b/Tests/RunCMake/CMP0040/CMP0040-WARN-missing-target-stderr.txt
@@ -1,8 +1,8 @@
CMake Warning \(dev\) at CMP0040-WARN-missing-target.cmake:2 \(add_custom_command\):
Policy CMP0040 is not set: The target in the TARGET signature of
- add_custom_command\(\) must exist. Run "cmake --help-policy CMP0040" for
- policy details. Use the cmake_policy command to set the policy and
- suppress this warning.
+ add_custom_command\(\) must exist and must be defined in the current
+ directory. Run "cmake --help-policy CMP0040" for policy details. Use the
+ cmake_policy command to set the policy and suppress this warning.
+
No TARGET 'foobar' has been created in this directory.
Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/CMP0041/CMP0041-OLD-stderr.txt b/Tests/RunCMake/CMP0041/CMP0041-OLD-stderr.txt
new file mode 100644
index 000000000..1b736dadc
--- /dev/null
+++ b/Tests/RunCMake/CMP0041/CMP0041-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0041-OLD.cmake:2 \(cmake_policy\):
+ The OLD behavior for policy CMP0041 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0041/CMP0041-tid-OLD-stderr.txt b/Tests/RunCMake/CMP0041/CMP0041-tid-OLD-stderr.txt
new file mode 100644
index 000000000..dbc51674f
--- /dev/null
+++ b/Tests/RunCMake/CMP0041/CMP0041-tid-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0041-tid-OLD.cmake:2 \(cmake_policy\):
+ The OLD behavior for policy CMP0041 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0042/CMP0042-OLD-stderr.txt b/Tests/RunCMake/CMP0042/CMP0042-OLD-stderr.txt
new file mode 100644
index 000000000..9d1488d22
--- /dev/null
+++ b/Tests/RunCMake/CMP0042/CMP0042-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0042-OLD.cmake:2 \(cmake_policy\):
+ The OLD behavior for policy CMP0042 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0043/CMP0043-OLD-stderr.txt b/Tests/RunCMake/CMP0043/CMP0043-OLD-stderr.txt
new file mode 100644
index 000000000..ebbb361ca
--- /dev/null
+++ b/Tests/RunCMake/CMP0043/CMP0043-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0043-OLD.cmake:2 \(cmake_policy\):
+ The OLD behavior for policy CMP0043 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0045/CMP0045-OLD-stderr.txt b/Tests/RunCMake/CMP0045/CMP0045-OLD-stderr.txt
new file mode 100644
index 000000000..0dac20f4f
--- /dev/null
+++ b/Tests/RunCMake/CMP0045/CMP0045-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0045-OLD.cmake:2 \(cmake_policy\):
+ The OLD behavior for policy CMP0045 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0046/CMP0046-OLD-existing-dependency-stderr.txt b/Tests/RunCMake/CMP0046/CMP0046-OLD-existing-dependency-stderr.txt
new file mode 100644
index 000000000..444411895
--- /dev/null
+++ b/Tests/RunCMake/CMP0046/CMP0046-OLD-existing-dependency-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0046-OLD-existing-dependency.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0046 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0046/CMP0046-OLD-missing-dependency-stderr.txt b/Tests/RunCMake/CMP0046/CMP0046-OLD-missing-dependency-stderr.txt
new file mode 100644
index 000000000..525954f63
--- /dev/null
+++ b/Tests/RunCMake/CMP0046/CMP0046-OLD-missing-dependency-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0046-OLD-missing-dependency.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0046 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0049/CMP0049-OLD-result.txt b/Tests/RunCMake/CMP0049/CMP0049-OLD-result.txt
deleted file mode 100644
index 573541ac9..000000000
--- a/Tests/RunCMake/CMP0049/CMP0049-OLD-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/Tests/RunCMake/CMP0049/CMP0049-OLD-stderr.txt b/Tests/RunCMake/CMP0049/CMP0049-OLD-stderr.txt
new file mode 100644
index 000000000..b3739705b
--- /dev/null
+++ b/Tests/RunCMake/CMP0049/CMP0049-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0049-OLD.cmake:2 \(cmake_policy\):
+ The OLD behavior for policy CMP0049 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0050/CMP0050-OLD-result.txt b/Tests/RunCMake/CMP0050/CMP0050-OLD-result.txt
deleted file mode 100644
index 573541ac9..000000000
--- a/Tests/RunCMake/CMP0050/CMP0050-OLD-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/Tests/RunCMake/CMP0050/CMP0050-OLD-stderr.txt b/Tests/RunCMake/CMP0050/CMP0050-OLD-stderr.txt
new file mode 100644
index 000000000..3e7fa979c
--- /dev/null
+++ b/Tests/RunCMake/CMP0050/CMP0050-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0050-OLD.cmake:2 \(cmake_policy\):
+ The OLD behavior for policy CMP0050 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt b/Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt
deleted file mode 100644
index 573541ac9..000000000
--- a/Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt
index cc17f3371..e1c44e507 100644
--- a/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt
+++ b/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt
@@ -1 +1,12 @@
-^Sources: "empty.cpp"$
+^CMake Deprecation Warning at CMP0051-OLD.cmake:2 \(cmake_policy\):
+ The OLD behavior for policy CMP0051 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+Sources: "empty.cpp"$
diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt
index ae2e46848..78c6b6d30 100644
--- a/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt
+++ b/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt
@@ -9,7 +9,7 @@ CMake Warning \(dev\) at CMP0051-WARN.cmake:6 \(get_target_property\):
needs to be adapted to ignore the generator expression using the
string\(GENEX_STRIP\) command.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
Sources: "empty.cpp"
@@ -25,7 +25,7 @@ CMake Warning \(dev\) at CMP0051-WARN.cmake:12 \(get_target_property\):
needs to be adapted to ignore the generator expression using the
string\(GENEX_STRIP\) command.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
Sources: "../empty.cpp"$
diff --git a/Tests/RunCMake/CMP0053/CMP0053-OLD-stderr.txt b/Tests/RunCMake/CMP0053/CMP0053-OLD-stderr.txt
index 836b0ffe9..2a0ddbaaf 100644
--- a/Tests/RunCMake/CMP0053/CMP0053-OLD-stderr.txt
+++ b/Tests/RunCMake/CMP0053/CMP0053-OLD-stderr.txt
@@ -1,2 +1,13 @@
-^called
+^CMake Deprecation Warning at CMP0053-OLD.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0053 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+called
--><--$
diff --git a/Tests/RunCMake/CMP0054/CMP0054-OLD-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-OLD-stderr.txt
index f5a8fbe6e..0500280cd 100644
--- a/Tests/RunCMake/CMP0054/CMP0054-OLD-stderr.txt
+++ b/Tests/RunCMake/CMP0054/CMP0054-OLD-stderr.txt
@@ -1 +1,10 @@
-$^
+^CMake Deprecation Warning at CMP0054-OLD.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0054/CMP0054-keywords-OLD-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-keywords-OLD-stderr.txt
index f5a8fbe6e..60303cd86 100644
--- a/Tests/RunCMake/CMP0054/CMP0054-keywords-OLD-stderr.txt
+++ b/Tests/RunCMake/CMP0054/CMP0054-keywords-OLD-stderr.txt
@@ -1 +1,10 @@
-$^
+^CMake Deprecation Warning at CMP0054-keywords-OLD.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0054/CMP0054-policy-command-scope-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-policy-command-scope-stderr.txt
index f5a8fbe6e..1b354728d 100644
--- a/Tests/RunCMake/CMP0054/CMP0054-policy-command-scope-stderr.txt
+++ b/Tests/RunCMake/CMP0054/CMP0054-policy-command-scope-stderr.txt
@@ -1 +1,10 @@
-$^
+^CMake Deprecation Warning at CMP0054-policy-command-scope.cmake:25 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0054/CMP0054-policy-foreach-scope-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-policy-foreach-scope-stderr.txt
index f5a8fbe6e..4eac90eed 100644
--- a/Tests/RunCMake/CMP0054/CMP0054-policy-foreach-scope-stderr.txt
+++ b/Tests/RunCMake/CMP0054/CMP0054-policy-foreach-scope-stderr.txt
@@ -1 +1,54 @@
-$^
+^CMake Deprecation Warning at CMP0054-policy-foreach-scope.cmake:14 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Deprecation Warning at CMP0054-policy-foreach-scope.cmake:14 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Deprecation Warning at CMP0054-policy-foreach-scope.cmake:27 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Deprecation Warning at CMP0054-policy-foreach-scope.cmake:48 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Deprecation Warning at CMP0054-policy-foreach-scope.cmake:48 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0054/CMP0054-policy-nested-if-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-policy-nested-if-stderr.txt
index f5a8fbe6e..a2dd62e4a 100644
--- a/Tests/RunCMake/CMP0054/CMP0054-policy-nested-if-stderr.txt
+++ b/Tests/RunCMake/CMP0054/CMP0054-policy-nested-if-stderr.txt
@@ -1 +1,10 @@
-$^
+^CMake Deprecation Warning at CMP0054-policy-nested-if.cmake:23 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0054/CMP0054-policy-while-scope-stderr.txt b/Tests/RunCMake/CMP0054/CMP0054-policy-while-scope-stderr.txt
index f5a8fbe6e..718904d39 100644
--- a/Tests/RunCMake/CMP0054/CMP0054-policy-while-scope-stderr.txt
+++ b/Tests/RunCMake/CMP0054/CMP0054-policy-while-scope-stderr.txt
@@ -1 +1,54 @@
-$^
+^CMake Deprecation Warning at CMP0054-policy-while-scope.cmake:16 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Deprecation Warning at CMP0054-policy-while-scope.cmake:16 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Deprecation Warning at CMP0054-policy-while-scope.cmake:37 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Deprecation Warning at CMP0054-policy-while-scope.cmake:58 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Deprecation Warning at CMP0054-policy-while-scope.cmake:58 \(cmake_policy\):
+ The OLD behavior for policy CMP0054 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt
new file mode 100644
index 000000000..d0a156cbc
--- /dev/null
+++ b/Tests/RunCMake/CMP0055/CMP0055-OLD-Out-of-Scope-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0055-OLD-Out-of-Scope.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0055 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt b/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt
new file mode 100644
index 000000000..937b352da
--- /dev/null
+++ b/Tests/RunCMake/CMP0055/CMP0055-OLD-Reject-Arguments-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0055-OLD-Reject-Arguments.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0055 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/CMP0060/CMP0060-Common.cmake b/Tests/RunCMake/CMP0060/CMP0060-Common.cmake
index e0a56e68c..06955eeba 100644
--- a/Tests/RunCMake/CMP0060/CMP0060-Common.cmake
+++ b/Tests/RunCMake/CMP0060/CMP0060-Common.cmake
@@ -1,6 +1,7 @@
# Always build in a predictable configuration. For multi-config
# generators we depend on RunCMakeTest.cmake to do this for us.
-if(NOT CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(NOT _isMultiConfig)
set(CMAKE_BUILD_TYPE Debug)
endif()
diff --git a/Tests/RunCMake/CMP0060/CMP0060-OLD-stderr.txt b/Tests/RunCMake/CMP0060/CMP0060-OLD-stderr.txt
new file mode 100644
index 000000000..465874736
--- /dev/null
+++ b/Tests/RunCMake/CMP0060/CMP0060-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0060-OLD.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0060 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt
index f6cc97854..e2c280ee7 100644
--- a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt
+++ b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt
@@ -12,5 +12,5 @@
will ask the linker to search for these by library name.
Call Stack \(most recent call first\):
CMP0060-WARN-ON.cmake:[0-9]+ \(include\)
- CMakeLists.txt:3 \(include\)
+ CMakeLists.txt:4 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/CMP0060/CMakeLists.txt b/Tests/RunCMake/CMP0060/CMakeLists.txt
index db6b701c0..291d34d43 100644
--- a/Tests/RunCMake/CMP0060/CMakeLists.txt
+++ b/Tests/RunCMake/CMP0060/CMakeLists.txt
@@ -1,3 +1,4 @@
-cmake_minimum_required(VERSION 3.2)
+cmake_minimum_required(VERSION 3.9)
+cmake_policy(VERSION 3.2)
project(${RunCMake_TEST} C)
include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMP0064/CMP0064-OLD-stderr.txt b/Tests/RunCMake/CMP0064/CMP0064-OLD-stderr.txt
new file mode 100644
index 000000000..987a50309
--- /dev/null
+++ b/Tests/RunCMake/CMP0064/CMP0064-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0064-OLD.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0064 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/CMP0065/RunCMakeTest.cmake b/Tests/RunCMake/CMP0065/RunCMakeTest.cmake
index 254a4ec02..e86b50eb1 100644
--- a/Tests/RunCMake/CMP0065/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMP0065/RunCMakeTest.cmake
@@ -1,8 +1,11 @@
include(RunCMake)
run_cmake(OLDBad1)
-run_cmake(OLDBad2)
-run_cmake(NEWBad)
+if(NOT CMAKE_SYSTEM_NAME STREQUAL "AIX")
+ # Tests with ENABLE_EXPORTS ON. For AIX we do not use the flags at all.
+ run_cmake(OLDBad2)
+ run_cmake(NEWBad)
+endif()
run_cmake(NEWGood)
run_cmake(WARN-OFF)
run_cmake(WARN-ON)
diff --git a/Tests/RunCMake/CMP0069/CMP0069-NEW-cmake-stderr.txt b/Tests/RunCMake/CMP0069/CMP0069-NEW-cmake-stderr.txt
index ddb3cae61..87ac88e62 100644
--- a/Tests/RunCMake/CMP0069/CMP0069-NEW-cmake-stderr.txt
+++ b/Tests/RunCMake/CMP0069/CMP0069-NEW-cmake-stderr.txt
@@ -1,4 +1,6 @@
^CMake Error at CMP0069-NEW-cmake\.cmake:[0-9]+ \(add_executable\):
CMake doesn't support IPO for current compiler
Call Stack \(most recent call first\):
- CMakeLists\.txt:[0-9]+ \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/CMP0069/CMP0069-NEW-compiler-stderr.txt b/Tests/RunCMake/CMP0069/CMP0069-NEW-compiler-stderr.txt
index 8decfab3c..cb9d19b47 100644
--- a/Tests/RunCMake/CMP0069/CMP0069-NEW-compiler-stderr.txt
+++ b/Tests/RunCMake/CMP0069/CMP0069-NEW-compiler-stderr.txt
@@ -1,4 +1,6 @@
^CMake Error at CMP0069-NEW-compiler\.cmake:[0-9]+ \(add_executable\):
Compiler doesn't support IPO
Call Stack \(most recent call first\):
- CMakeLists\.txt:[0-9]+ \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/CMP0069/CMP0069-NEW-generator-stderr.txt b/Tests/RunCMake/CMP0069/CMP0069-NEW-generator-stderr.txt
index 0e05ee783..1159ec043 100644
--- a/Tests/RunCMake/CMP0069/CMP0069-NEW-generator-stderr.txt
+++ b/Tests/RunCMake/CMP0069/CMP0069-NEW-generator-stderr.txt
@@ -1,4 +1,6 @@
^CMake Error at CMP0069-NEW-generator\.cmake:[0-9]+ \(add_executable\):
CMake doesn't support IPO for current generator
Call Stack \(most recent call first\):
- CMakeLists\.txt:[0-9]+ \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/CMP0069/RunCMakeTest.cmake b/Tests/RunCMake/CMP0069/RunCMakeTest.cmake
index f44f84002..456e6a656 100644
--- a/Tests/RunCMake/CMP0069/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CMP0069/RunCMakeTest.cmake
@@ -5,6 +5,6 @@ run_cmake(CMP0069-NEW-cmake)
run_cmake(CMP0069-NEW-compiler)
run_cmake(CMP0069-WARN)
-if(RunCMake_GENERATOR MATCHES "^Visual Studio ")
+if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ")
run_cmake(CMP0069-NEW-generator)
endif()
diff --git a/Tests/RunCMake/CMP0081/CMP0081-Common.cmake b/Tests/RunCMake/CMP0081/CMP0081-Common.cmake
new file mode 100644
index 000000000..3ea5277f9
--- /dev/null
+++ b/Tests/RunCMake/CMP0081/CMP0081-Common.cmake
@@ -0,0 +1,5 @@
+
+enable_language(CXX)
+
+add_library(foo SHARED empty.cpp)
+set_target_properties(foo PROPERTIES LINK_DIRECTORIES "../lib")
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-result.txt b/Tests/RunCMake/CMP0081/CMP0081-NEW-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-result.txt
+++ b/Tests/RunCMake/CMP0081/CMP0081-NEW-result.txt
diff --git a/Tests/RunCMake/CMP0081/CMP0081-NEW-stderr.txt b/Tests/RunCMake/CMP0081/CMP0081-NEW-stderr.txt
new file mode 100644
index 000000000..d31c149bd
--- /dev/null
+++ b/Tests/RunCMake/CMP0081/CMP0081-NEW-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error in CMakeLists.txt:
+ Found relative path while evaluating link directories of "foo":
+
+ "../lib"
diff --git a/Tests/RunCMake/CMP0081/CMP0081-NEW.cmake b/Tests/RunCMake/CMP0081/CMP0081-NEW.cmake
new file mode 100644
index 000000000..9b927a2b4
--- /dev/null
+++ b/Tests/RunCMake/CMP0081/CMP0081-NEW.cmake
@@ -0,0 +1,4 @@
+
+cmake_policy(SET CMP0081 NEW)
+
+include (CMP0081-Common.cmake)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-result.txt b/Tests/RunCMake/CMP0081/CMP0081-OLD-result.txt
index 573541ac9..573541ac9 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-OLD-reserved-result.txt
+++ b/Tests/RunCMake/CMP0081/CMP0081-OLD-result.txt
diff --git a/Tests/RunCMake/CMP0081/CMP0081-OLD.cmake b/Tests/RunCMake/CMP0081/CMP0081-OLD.cmake
new file mode 100644
index 000000000..2e91bf6ae
--- /dev/null
+++ b/Tests/RunCMake/CMP0081/CMP0081-OLD.cmake
@@ -0,0 +1,4 @@
+
+cmake_policy(SET CMP0081 OLD)
+
+include (CMP0081-Common.cmake)
diff --git a/Tests/RunCMake/CMP0037/CMP0037-OLD-space-result.txt b/Tests/RunCMake/CMP0081/CMP0081-WARN-result.txt
index 573541ac9..573541ac9 100644
--- a/Tests/RunCMake/CMP0037/CMP0037-OLD-space-result.txt
+++ b/Tests/RunCMake/CMP0081/CMP0081-WARN-result.txt
diff --git a/Tests/RunCMake/CMP0081/CMP0081-WARN-stderr.txt b/Tests/RunCMake/CMP0081/CMP0081-WARN-stderr.txt
new file mode 100644
index 000000000..eac064829
--- /dev/null
+++ b/Tests/RunCMake/CMP0081/CMP0081-WARN-stderr.txt
@@ -0,0 +1,10 @@
+CMake Warning \(dev\) in CMakeLists.txt:
+ Policy CMP0081 is not set: Relative paths not allowed in LINK_DIRECTORIES
+ target property. Run "cmake --help-policy CMP0081" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ Found relative path while evaluating link directories of "foo":
+
+ "../lib"
+
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0081/CMP0081-WARN.cmake b/Tests/RunCMake/CMP0081/CMP0081-WARN.cmake
new file mode 100644
index 000000000..33bb21db1
--- /dev/null
+++ b/Tests/RunCMake/CMP0081/CMP0081-WARN.cmake
@@ -0,0 +1,2 @@
+
+include (CMP0081-Common.cmake)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CMakeLists.txt b/Tests/RunCMake/CMP0081/CMakeLists.txt
index ef2163c29..ef2163c29 100644
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CMakeLists.txt
+++ b/Tests/RunCMake/CMP0081/CMakeLists.txt
diff --git a/Tests/RunCMake/CMP0081/RunCMakeTest.cmake b/Tests/RunCMake/CMP0081/RunCMakeTest.cmake
new file mode 100644
index 000000000..335d8c5ba
--- /dev/null
+++ b/Tests/RunCMake/CMP0081/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(CMP0081-OLD)
+run_cmake(CMP0081-NEW)
+run_cmake(CMP0081-WARN)
diff --git a/Tests/RunCMake/CMP0081/empty.cpp b/Tests/RunCMake/CMP0081/empty.cpp
new file mode 100644
index 000000000..11ec041d1
--- /dev/null
+++ b/Tests/RunCMake/CMP0081/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 79f487d41..581a39e3c 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -1,5 +1,8 @@
# See adjacent README.rst for documentation of this test infrastructure.
+# Note that the _isMultiConfig variable is set in the parent directory's
+# CMakeLists.txt (slightly complex logic to support CMake versions before 3.9)
+
macro(add_RunCMake_test test)
set(TEST_ARGS ${ARGN})
if ("${ARGV1}" STREQUAL "TEST_DIR")
@@ -14,7 +17,9 @@ macro(add_RunCMake_test test)
endif()
add_test(NAME RunCMake.${test} COMMAND ${CMAKE_CMAKE_COMMAND}
-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR}
+ -DRunCMake_GENERATOR_IS_MULTI_CONFIG=${_isMultiConfig}
-DRunCMake_GENERATOR=${CMAKE_GENERATOR}
+ -DRunCMake_GENERATOR_INSTANCE=${CMAKE_GENERATOR_INSTANCE}
-DRunCMake_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DRunCMake_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
-DRunCMake_MAKE_PROGRAM=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
@@ -37,7 +42,12 @@ function(add_RunCMake_test_group test types)
# much system information so it is easier to set programs and environment
# values here
unset(${test}_${type}_FOUND_PREREQUIREMENTS)
- include("${CMAKE_CURRENT_SOURCE_DIR}/${test}/${type}/Prerequirements.cmake")
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${test}/${type}/Prerequirements.cmake")
+ include("${CMAKE_CURRENT_SOURCE_DIR}/${test}/${type}/Prerequirements.cmake")
+ else()
+ string(REGEX MATCH "^[^.]*" main_type "${type}")
+ include("${CMAKE_CURRENT_SOURCE_DIR}/${test}/${main_type}/Prerequirements.cmake")
+ endif()
get_test_prerequirements("${test}_${type}_FOUND_PREREQUIREMENTS"
"${TEST_CONFIG_DIR}/${type}_config.cmake")
@@ -46,7 +56,9 @@ function(add_RunCMake_test_group test types)
add_test(NAME RunCMake.${test}_${type} COMMAND ${CMAKE_CMAKE_COMMAND}
-DTEST_TYPE=${type}
-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR}
+ -DRunCMake_GENERATOR_IS_MULTI_CONFIG=${_isMultiConfig}
-DRunCMake_GENERATOR=${CMAKE_GENERATOR}
+ -DRunCMake_GENERATOR_INSTANCE=${CMAKE_GENERATOR_INSTANCE}
-DRunCMake_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DRunCMake_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
-DRunCMake_MAKE_PROGRAM=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
@@ -59,6 +71,9 @@ function(add_RunCMake_test_group test types)
endforeach()
endfunction()
+# Some tests use python for extra checks.
+find_package(PythonInterp QUIET)
+
if(XCODE_VERSION AND "${XCODE_VERSION}" VERSION_LESS 6.1)
set(Swift_ARGS -DXCODE_BELOW_6_1=1)
endif()
@@ -99,21 +114,25 @@ if(CMAKE_SYSTEM_NAME MATCHES Darwin AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
add_RunCMake_test(CMP0068)
endif()
add_RunCMake_test(CMP0069)
+add_RunCMake_test(CMP0081)
# The test for Policy 65 requires the use of the
# CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode
# generators ignore. The policy will have no effect on those generators.
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio|Xcode")
- add_RunCMake_test(CMP0065)
+ add_RunCMake_test(CMP0065 -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
endif()
if(CMAKE_GENERATOR MATCHES "Make")
- add_RunCMake_test(Make)
+ add_RunCMake_test(Make -DMAKE_IS_GNU=${MAKE_IS_GNU})
endif()
if(CMAKE_GENERATOR STREQUAL "Ninja")
set(Ninja_ARGS
-DCMAKE_C_OUTPUT_EXTENSION=${CMAKE_C_OUTPUT_EXTENSION}
-DCMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX}
-DCMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX})
+ if(CMAKE_Fortran_COMPILER)
+ list(APPEND Ninja_ARGS -DTEST_Fortran=1)
+ endif()
add_RunCMake_test(Ninja)
endif()
add_RunCMake_test(CTest)
@@ -131,31 +150,63 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE)
endif()
add_RunCMake_test(AndroidTestUtilities)
+set(autogen_with_qt5 FALSE)
+if(CMake_TEST_Qt5)
+ find_package(Qt5Widgets QUIET NO_MODULE)
+endif()
+if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND)
+ set(autogen_with_qt5 TRUE)
+endif ()
+add_RunCMake_test(Autogen -Dwith_qt5=${autogen_with_qt5})
add_RunCMake_test(BuildDepends)
if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja")
+ add_RunCMake_test(Byproducts)
+endif()
+add_RunCMake_test(CMakeRoleGlobalProperty)
+if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja")
add_RunCMake_test(CompilerChange)
endif()
add_RunCMake_test(CompilerNotFound)
-add_RunCMake_test(Configure)
+add_RunCMake_test(Configure -DMSVC_IDE=${MSVC_IDE})
add_RunCMake_test(DisallowedCommands)
add_RunCMake_test(ExternalData)
add_RunCMake_test(FeatureSummary)
add_RunCMake_test(FPHSA)
+add_RunCMake_test(FileAPI -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE})
+add_RunCMake_test(FindBoost)
+add_RunCMake_test(FindLua)
+add_RunCMake_test(FindOpenGL)
+if(CMake_TEST_UseSWIG)
+ add_RunCMake_test(UseSWIG -DCMake_TEST_FindPython=${CMake_TEST_FindPython})
+endif()
if(NOT CMAKE_C_COMPILER_ID MATCHES "Watcom")
add_RunCMake_test(GenerateExportHeader)
endif()
add_RunCMake_test(GeneratorExpression)
+add_RunCMake_test(GeneratorInstance)
add_RunCMake_test(GeneratorPlatform)
add_RunCMake_test(GeneratorToolset)
+add_RunCMake_test(GetPrerequisites)
add_RunCMake_test(GNUInstallDirs -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME})
+add_RunCMake_test(GoogleTest) # Note: does not actually depend on Google Test
add_RunCMake_test(TargetPropertyGeneratorExpressions)
add_RunCMake_test(Languages)
add_RunCMake_test(LinkStatic)
+if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$")
+ add_RunCMake_test(MetaCompileFeatures)
+endif()
+if(MSVC)
+ add_RunCMake_test(MSVCRuntimeLibrary)
+ add_RunCMake_test(MSVCWarningFlags)
+endif()
add_RunCMake_test(ObjectLibrary)
+add_RunCMake_test(ParseImplicitIncludeInfo)
+add_RunCMake_test(ParseImplicitLinkInfo)
if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")
add_RunCMake_test(RuntimePath)
endif()
-add_RunCMake_test(Swift)
+add_RunCMake_test(ScriptMode)
+add_RunCMake_test(Swift -DCMAKE_Swift_COMPILER=${CMAKE_Swift_COMPILER})
add_RunCMake_test(TargetObjects)
add_RunCMake_test(TargetSources)
add_RunCMake_test(ToolchainFile)
@@ -163,9 +214,12 @@ add_RunCMake_test(find_dependency)
add_RunCMake_test(CompileDefinitions)
add_RunCMake_test(CompileFeatures)
add_RunCMake_test(PolicyScope)
+add_RunCMake_test(WriteBasicConfigVersionFile)
add_RunCMake_test(WriteCompilerDetectionHeader)
+add_RunCMake_test(SourceProperties)
if(NOT WIN32)
- add_RunCMake_test(PositionIndependentCode)
+ add_RunCMake_test(PositionIndependentCode -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
+ -DCMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID})
endif()
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio")
add_RunCMake_test(VisibilityPreset)
@@ -175,21 +229,28 @@ if (QT4_FOUND)
endif()
add_RunCMake_test(CompatibleInterface)
add_RunCMake_test(Syntax)
+add_RunCMake_test(WorkingDirectory)
+add_RunCMake_test(MaxRecursionDepth)
add_RunCMake_test(add_custom_command)
add_RunCMake_test(add_custom_target)
add_RunCMake_test(add_dependencies)
+add_RunCMake_test(add_executable)
+add_RunCMake_test(add_library)
add_RunCMake_test(add_subdirectory)
add_RunCMake_test(build_command)
+add_executable(exit_code exit_code.c)
+set(execute_process_ARGS -DEXIT_CODE_EXE=$<TARGET_FILE:exit_code>)
if(NOT CMake_TEST_EXTERNAL_CMAKE)
- set(execute_process_ARGS -DTEST_ENCODING_EXE=$<TARGET_FILE:testEncoding>)
+ list(APPEND execute_process_ARGS -DTEST_ENCODING_EXE=$<TARGET_FILE:testEncoding>)
endif()
add_RunCMake_test(execute_process)
add_RunCMake_test(export)
add_RunCMake_test(cmake_minimum_required)
add_RunCMake_test(cmake_parse_arguments)
add_RunCMake_test(continue)
-add_RunCMake_test(ctest_build)
+add_executable(color_warning color_warning.c)
+add_RunCMake_test(ctest_build -DCOLOR_WARNING=$<TARGET_FILE:color_warning>)
add_RunCMake_test(ctest_cmake_error)
add_RunCMake_test(ctest_configure)
if(COVERAGE_COMMAND)
@@ -200,6 +261,7 @@ add_RunCMake_test(ctest_submit)
add_RunCMake_test(ctest_test)
add_RunCMake_test(ctest_disabled_test)
add_RunCMake_test(ctest_skipped_test)
+add_RunCMake_test(ctest_update)
add_RunCMake_test(ctest_upload)
add_RunCMake_test(ctest_fixtures)
add_RunCMake_test(file)
@@ -208,33 +270,62 @@ add_RunCMake_test(find_library)
add_RunCMake_test(find_package)
add_RunCMake_test(find_path)
add_RunCMake_test(find_program -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
+add_RunCMake_test(foreach)
add_RunCMake_test(get_filename_component)
add_RunCMake_test(get_property)
add_RunCMake_test(if)
add_RunCMake_test(include)
add_RunCMake_test(include_directories)
+add_RunCMake_test(include_guard)
add_RunCMake_test(list)
+add_RunCMake_test(math)
add_RunCMake_test(message)
+add_RunCMake_test(option)
add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES})
+add_RunCMake_test(project_injected)
add_RunCMake_test(return)
add_RunCMake_test(separate_arguments)
add_RunCMake_test(set_property)
add_RunCMake_test(string)
-foreach(var
- CMAKE_C_COMPILER_ID
- CMAKE_C_COMPILER_VERSION
- CMAKE_C_STANDARD_DEFAULT
- CMAKE_CXX_COMPILER_ID
- CMAKE_CXX_COMPILER_VERSION
- CMAKE_CXX_STANDARD_DEFAULT
- CMake_TEST_CUDA
- )
- if(DEFINED ${var})
- list(APPEND try_compile_ARGS -D${var}=${${var}})
+add_RunCMake_test(test_include_dirs)
+add_RunCMake_test(BundleUtilities)
+
+function(add_RunCMake_test_try_compile)
+ if(CMAKE_VERSION VERSION_LESS 3.9.20170907 AND "x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
+ # Older CMake versions do not know about MSVC language standards.
+ # Approximate our logic from MSVC-CXX.cmake.
+ if ((NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.24215.1 AND
+ CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10) OR
+ NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10.25017)
+ set(CMAKE_CXX_STANDARD_DEFAULT 14)
+ elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0)
+ set(CMAKE_CXX_STANDARD_DEFAULT "")
+ else()
+ unset(CMAKE_CXX_STANDARD_DEFAULT)
+ endif()
endif()
-endforeach()
-add_RunCMake_test(try_compile)
-add_RunCMake_test(try_run)
+ foreach(var
+ CMAKE_SYSTEM_NAME
+ CMAKE_C_COMPILER_ID
+ CMAKE_C_COMPILER_VERSION
+ CMAKE_C_STANDARD_DEFAULT
+ CMAKE_CXX_COMPILER_ID
+ CMAKE_CXX_COMPILER_VERSION
+ CMAKE_CXX_STANDARD_DEFAULT
+ CMake_TEST_CUDA
+ CMAKE_OBJC_STANDARD_DEFAULT
+ CMAKE_OBJCXX_STANDARD_DEFAULT
+ )
+ if(DEFINED ${var})
+ list(APPEND try_compile_ARGS -D${var}=${${var}})
+ endif()
+ endforeach()
+ add_RunCMake_test(try_compile)
+endfunction()
+add_RunCMake_test_try_compile()
+
+add_RunCMake_test(try_run -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
+ -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
add_RunCMake_test(set)
add_RunCMake_test(variable_watch)
add_RunCMake_test(while)
@@ -246,6 +337,44 @@ add_RunCMake_test(no_install_prefix)
add_RunCMake_test(configure_file)
add_RunCMake_test(CTestTimeoutAfterMatch)
+# ctresalloc links against CMakeLib and CTestLib, which means it can't be built
+# if CMake_TEST_EXTERNAL_CMAKE is activated (the compiler might be different.)
+# So, it has to be provided in the original build tree.
+if(CMake_TEST_EXTERNAL_CMAKE)
+ set(no_package_root_path)
+ if(NOT CMAKE_VERSION VERSION_LESS 3.12)
+ set(no_package_root_path NO_PACKAGE_ROOT_PATH)
+ endif()
+ find_program(ctresalloc ctresalloc PATHS ${CMake_TEST_EXTERNAL_CMAKE}
+ NO_DEFAULT_PATH
+ ${no_package_root_path}
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH
+ NO_CMAKE_FIND_ROOT_PATH
+ )
+ if(ctresalloc)
+ add_executable(ctresalloc IMPORTED)
+ set_property(TARGET ctresalloc PROPERTY IMPORTED_LOCATION ${ctresalloc})
+ endif()
+else()
+ add_executable(ctresalloc CTestResourceAllocation/ctresalloc.cxx)
+ target_link_libraries(ctresalloc CTestLib)
+ target_include_directories(ctresalloc PRIVATE
+ ${CMake_BINARY_DIR}/Source
+ ${CMake_SOURCE_DIR}/Source
+ ${CMake_SOURCE_DIR}/Source/CTest
+ )
+ set_property(TARGET ctresalloc PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMake_BIN_DIR})
+endif()
+
+if(TARGET ctresalloc)
+ add_RunCMake_test(CTestResourceAllocation -DCTRESALLOC_COMMAND=$<TARGET_FILE:ctresalloc>)
+else()
+ message(WARNING "Could not find or build ctresalloc")
+endif()
+
find_package(Qt4 QUIET)
find_package(Qt5Core QUIET)
if (QT4_FOUND AND Qt5Core_FOUND AND NOT Qt5Core_VERSION VERSION_LESS 5.1.0)
@@ -260,25 +389,37 @@ if(PKG_CONFIG_FOUND)
add_RunCMake_test(FindPkgConfig)
endif()
-find_package(GTK2 QUIET)
-if (GTK2_FOUND)
+if(CMake_TEST_FindGTK2)
add_RunCMake_test(FindGTK2)
endif()
if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
- add_RunCMake_test(include_external_msproject)
- if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([89]|10)" AND NOT CMAKE_VS_DEVENV_COMMAND)
+ add_RunCMake_test(include_external_msproject -DVS_PLATFORM_NAME=${CMAKE_VS_PLATFORM_NAME})
+ if("${CMAKE_GENERATOR}" MATCHES "Visual Studio (9|10)" AND NOT CMAKE_VS_DEVENV_COMMAND)
set(NO_USE_FOLDERS 1)
endif()
add_RunCMake_test(VSSolution -DNO_USE_FOLDERS=${NO_USE_FOLDERS})
endif()
-if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^89]|[89][0-9])")
- add_RunCMake_test(VS10Project)
+if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^9]|9[0-9])")
+ add_RunCMake_test(VS10Project
+ -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
+ -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION}
+ )
+ if( vs12 AND wince )
+ add_RunCMake_test( VS10ProjectWinCE "-DRunCMake_GENERATOR_PLATFORM=${wince_sdk}")
+ endif()
endif()
if(XCODE_VERSION)
add_RunCMake_test(XcodeProject -DXCODE_VERSION=${XCODE_VERSION})
+
+ # This test can take a very long time due to lots of combinations.
+ # Use a long default timeout and provide an option to customize it.
+ if(NOT DEFINED CMake_TEST_XcodeProject_TIMEOUT)
+ set(CMake_TEST_XcodeProject_TIMEOUT 2000)
+ endif()
+ set_property(TEST RunCMake.XcodeProject PROPERTY TIMEOUT ${CMake_TEST_XcodeProject_TIMEOUT})
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang"
@@ -288,43 +429,77 @@ endif()
add_RunCMake_test(File_Generate)
add_RunCMake_test(ExportWithoutLanguage)
+add_RunCMake_test(target_link_directories)
add_RunCMake_test(target_link_libraries)
+add_RunCMake_test(add_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
+add_RunCMake_test(target_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
+add_RunCMake_test(target_compile_definitions)
add_RunCMake_test(target_compile_features)
+add_RunCMake_test(target_compile_options)
+add_RunCMake_test(target_include_directories)
+add_RunCMake_test(target_sources)
add_RunCMake_test(CheckModules)
add_RunCMake_test(CheckIPOSupported)
add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME})
add_RunCMake_test(CommandLineTar)
-add_RunCMake_test(install)
+if(CMAKE_PLATFORM_NO_VERSIONED_SONAME OR (NOT CMAKE_SHARED_LIBRARY_SONAME_FLAG AND NOT CMAKE_SHARED_LIBRARY_SONAME_C_FLAG))
+ set(NO_NAMELINK 1)
+else()
+ set(NO_NAMELINK 0)
+endif()
+
+add_RunCMake_test(install -DNO_NAMELINK=${NO_NAMELINK} -DCYGWIN=${CYGWIN} -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
+ -DCMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN=${CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN}
+ -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
+ -DCMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG=${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG}
+ -DCMAKE_EXECUTABLE_FORMAT=${CMAKE_EXECUTABLE_FORMAT})
+
+add_RunCMake_test(CPackCommandLine)
add_RunCMake_test(CPackConfig)
add_RunCMake_test(CPackInstallProperties)
add_RunCMake_test(ExternalProject)
-add_RunCMake_test(CTestCommandLine)
+add_RunCMake_test(FetchContent)
+set(CTestCommandLine_ARGS -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE})
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ list(APPEND CTestCommandLine_ARGS -DTEST_AFFINITY=$<TARGET_FILE:testAffinity>)
+endif()
+add_executable(print_stdin print_stdin.c)
+add_RunCMake_test(CTestCommandLine -DTEST_PRINT_STDIN=$<TARGET_FILE:print_stdin>)
+add_RunCMake_test(CacheNewline)
# Only run this test on unix platforms that support
# symbolic links
if(UNIX)
add_RunCMake_test(CPackSymlinks)
endif()
-set(IfacePaths_INCLUDE_DIRECTORIES_ARGS -DTEST_PROP=INCLUDE_DIRECTORIES)
-add_RunCMake_test(IfacePaths_INCLUDE_DIRECTORIES TEST_DIR IfacePaths)
+set(IfacePaths_INCDIRS_ARGS -DTEST_PROP=INCLUDE_DIRECTORIES)
+add_RunCMake_test(IfacePaths_INCDIRS TEST_DIR IfacePaths)
set(IfacePaths_SOURCES_ARGS -DTEST_PROP=SOURCES)
add_RunCMake_test(IfacePaths_SOURCES TEST_DIR IfacePaths)
-add_RunCMake_test(COMPILE_LANGUAGE-genex)
-
# Matlab module related tests
-if(CMake_TEST_FindMatlab)
- add_RunCMake_test(FindMatlab)
+if(CMake_TEST_FindMatlab OR CMake_TEST_FindMatlab_MCR OR (NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL ""))
+ set(FindMatlab_additional_test_options )
+ if(CMake_TEST_FindMatlab_MCR OR NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL "")
+ set(FindMatlab_additional_test_options -DIS_MCR=TRUE)
+ endif()
+ if(NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL "")
+ set(FindMatlab_additional_test_options ${FindMatlab_additional_test_options} "-DMCR_ROOT:FILEPATH=${CMake_TEST_FindMatlab_MCR_ROOT_DIR}")
+ endif()
+
+ add_RunCMake_test(FindMatlab ${FindMatlab_additional_test_options})
endif()
add_executable(pseudo_emulator pseudo_emulator.c)
add_executable(pseudo_emulator_custom_command pseudo_emulator_custom_command.c)
+add_executable(pseudo_emulator_custom_command_arg pseudo_emulator_custom_command_arg.c)
add_RunCMake_test(CrosscompilingEmulator
-DPSEUDO_EMULATOR=$<TARGET_FILE:pseudo_emulator>
- -DPSEUDO_EMULATOR_CUSTOM_COMMAND=$<TARGET_FILE:pseudo_emulator_custom_command>)
+ -DPSEUDO_EMULATOR_CUSTOM_COMMAND=$<TARGET_FILE:pseudo_emulator_custom_command>
+ -DPSEUDO_EMULATOR_CUSTOM_COMMAND_ARG=$<TARGET_FILE:pseudo_emulator_custom_command_arg>)
if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
if(UNIX AND NOT CYGWIN)
execute_process(COMMAND ldd --help
@@ -338,16 +513,81 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
add_executable(pseudo_tidy pseudo_tidy.c)
add_executable(pseudo_iwyu pseudo_iwyu.c)
add_executable(pseudo_cpplint pseudo_cpplint.c)
+ add_executable(pseudo_cppcheck pseudo_cppcheck.c)
add_RunCMake_test(ClangTidy -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy>)
add_RunCMake_test(IncludeWhatYouUse -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu>)
add_RunCMake_test(Cpplint -DPSEUDO_CPPLINT=$<TARGET_FILE:pseudo_cpplint>)
+ add_RunCMake_test(Cppcheck -DPSEUDO_CPPCHECK=$<TARGET_FILE:pseudo_cppcheck>)
+ add_RunCMake_test(MultiLint
+ -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy>
+ -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu>
+ -DPSEUDO_CPPLINT=$<TARGET_FILE:pseudo_cpplint>
+ -DPSEUDO_CPPCHECK=$<TARGET_FILE:pseudo_cppcheck>
+ )
+ if(DEFINED CMake_TEST_CUDA)
+ list(APPEND CompilerLauncher_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA})
+ endif()
+ if(CMAKE_Fortran_COMPILER)
+ list(APPEND CompilerLauncher_ARGS -DCMake_TEST_Fortran=1)
+ endif()
+ if (APPLE AND CMAKE_C_COMPILER_ID MATCHES "Clang|GNU")
+ list(APPEND CompilerLauncher_ARGS -DCMake_TEST_OBJC=1)
+ endif()
add_RunCMake_test(CompilerLauncher)
+ add_RunCMake_test(ctest_labels_for_subprojects)
endif()
-add_RunCMake_test_group(CPack "DEB;RPM;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ")
+set(cpack_tests
+ DEB.CUSTOM_NAMES
+ DEB.DEBUGINFO
+ DEB.DEFAULT_PERMISSIONS
+ DEB.DEPENDENCIES
+ DEB.EMPTY_DIR
+ DEB.VERSION
+ DEB.EXTRA
+ DEB.GENERATE_SHLIBS
+ DEB.GENERATE_SHLIBS_LDCONFIG
+ DEB.LONG_FILENAMES
+ DEB.MINIMAL
+ DEB.PER_COMPONENT_FIELDS
+ DEB.TIMESTAMPS
+ DEB.MD5SUMS
+ DEB.DEB_PACKAGE_VERSION_BACK_COMPATIBILITY
+ DEB.DEB_DESCRIPTION
+
+ RPM.CUSTOM_BINARY_SPEC_FILE
+ RPM.CUSTOM_NAMES
+ RPM.DEBUGINFO
+ RPM.DEFAULT_PERMISSIONS
+ RPM.DEPENDENCIES
+ RPM.DIST
+ RPM.EMPTY_DIR
+ RPM.VERSION
+ RPM.INSTALL_SCRIPTS
+ RPM.MAIN_COMPONENT
+ RPM.MINIMAL
+ RPM.PARTIALLY_RELOCATABLE_WARNING
+ RPM.PER_COMPONENT_FIELDS
+ RPM.SINGLE_DEBUGINFO
+ RPM.EXTRA_SLASH_IN_PATH
+ RPM.SOURCE_PACKAGE
+ RPM.SUGGESTS
+ RPM.SYMLINKS
+ RPM.USER_FILELIST
+
+ 7Z
+ TBZ2
+ TGZ
+ TXZ
+ TZ
+ ZIP
+ STGZ
+ External
+ )
+add_RunCMake_test_group(CPack "${cpack_tests}")
# add a test to make sure symbols are exported from a shared library
# for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used
-add_RunCMake_test(AutoExportDll)
+add_RunCMake_test(AutoExportDll -DCMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID})
add_RunCMake_test(AndroidMK)
@@ -371,3 +611,13 @@ if(CMake_TEST_ANDROID_NDK OR CMake_TEST_ANDROID_STANDALONE_TOOLCHAIN)
endif()
set_property(TEST RunCMake.Android PROPERTY TIMEOUT ${CMake_TEST_ANDROID_TIMEOUT})
endif()
+
+if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|9[0-9])")
+ add_RunCMake_test(CSharpCustomCommand)
+ add_RunCMake_test(CSharpReferenceImport)
+endif()
+
+add_RunCMake_test("CTestCommandExpandLists")
+
+add_RunCMake_test(PrecompileHeaders)
+add_RunCMake_test("UnityBuild")
diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/BuildAndTest/CMakeLists.txt b/Tests/RunCMake/CMakeRoleGlobalProperty/BuildAndTest/CMakeLists.txt
new file mode 100644
index 000000000..332b0230d
--- /dev/null
+++ b/Tests/RunCMake/CMakeRoleGlobalProperty/BuildAndTest/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.12)
+project(CMakeRoleGlobalPropertyBuildAndTest NONE)
+include(CTest)
+
+get_property(role GLOBAL PROPERTY CMAKE_ROLE)
+if(NOT role STREQUAL "PROJECT")
+ message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"PROJECT\"")
+endif()
+
+add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version)
diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt
new file mode 100644
index 000000000..44025d3bd
--- /dev/null
+++ b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.12)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in
new file mode 100644
index 000000000..bb8f9c140
--- /dev/null
+++ b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 3.12)
+project(CMakeRoleGlobalProperty@CASE_NAME@ NONE)
+include(CTest)
+add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version)
diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/FindDummyPackage.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/FindDummyPackage.cmake
new file mode 100644
index 000000000..8299042f3
--- /dev/null
+++ b/Tests/RunCMake/CMakeRoleGlobalProperty/FindDummyPackage.cmake
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.12)
+
+get_property(role GLOBAL PROPERTY CMAKE_ROLE)
+if(NOT role STREQUAL "FIND_PACKAGE")
+ message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"FIND_PACKAGE\"")
+endif()
+
+set(DummyPackage_FOUND 1)
diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake
new file mode 100644
index 000000000..22cad2bba
--- /dev/null
+++ b/Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake
@@ -0,0 +1,10 @@
+get_property(role GLOBAL PROPERTY CMAKE_ROLE)
+
+file(WRITE "${CMAKE_BINARY_DIR}/test.cmake" "# a")
+include("${CMAKE_BINARY_DIR}/test.cmake")
+
+if(NOT role STREQUAL "PROJECT")
+ message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"PROJECT\"")
+endif()
+
+add_subdirectory(sub)
diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake
new file mode 100644
index 000000000..7b29c28b8
--- /dev/null
+++ b/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake
@@ -0,0 +1,17 @@
+include(RunCMake)
+include(RunCTest)
+
+run_cmake(Project)
+file(WRITE "${RunCMake_BINARY_DIR}/Project-build/test.cmake" "# b")
+run_cmake_command(ProjectBuild "${CMAKE_COMMAND}" --build "${RunCMake_BINARY_DIR}/Project-build")
+
+run_cmake_command(Script "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/Script.cmake")
+run_cmake_command(FindPackage "${CMAKE_COMMAND}" --find-package -DNAME=DummyPackage -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=EXIST "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}")
+run_ctest(CTest)
+run_cmake_command(BuildAndTest "${CMAKE_CTEST_COMMAND}"
+ --build-and-test
+ "${RunCMake_SOURCE_DIR}/BuildAndTest"
+ "${RunCMake_BINARY_DIR}/BuildAndTest-build"
+ --build-project CMakeRoleGlobalPropertyBuildAndTest
+ --build-generator "${RunCMake_GENERATOR}"
+ )
diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/Script.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/Script.cmake
new file mode 100644
index 000000000..371edbc5c
--- /dev/null
+++ b/Tests/RunCMake/CMakeRoleGlobalProperty/Script.cmake
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.12)
+
+get_property(role GLOBAL PROPERTY CMAKE_ROLE)
+if(NOT role STREQUAL "SCRIPT")
+ message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"SCRIPT\"")
+endif()
diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/sub/CMakeLists.txt b/Tests/RunCMake/CMakeRoleGlobalProperty/sub/CMakeLists.txt
new file mode 100644
index 000000000..8ecf671e5
--- /dev/null
+++ b/Tests/RunCMake/CMakeRoleGlobalProperty/sub/CMakeLists.txt
@@ -0,0 +1,4 @@
+get_property(role GLOBAL PROPERTY CMAKE_ROLE)
+if(NOT role STREQUAL "PROJECT")
+ message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"PROJECT\"")
+endif()
diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/test.cmake.in b/Tests/RunCMake/CMakeRoleGlobalProperty/test.cmake.in
new file mode 100644
index 000000000..4e2c0859e
--- /dev/null
+++ b/Tests/RunCMake/CMakeRoleGlobalProperty/test.cmake.in
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 3.12)
+set(CTEST_RUN_CURRENT_SCRIPT 0)
+
+get_property(role GLOBAL PROPERTY CMAKE_ROLE)
+if(NOT role STREQUAL "CTEST")
+ message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"CTEST\"")
+endif()
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-VS.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-VS.txt
deleted file mode 100644
index 73b66acc7..000000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-VS.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at CompileDefinitions.cmake:5 \(target_compile_definitions\):
- Error evaluating generator expression:
-
- \$<COMPILE_LANGUAGE:CXX>
-
- \$<COMPILE_LANGUAGE:...> may not be used with Visual Studio generators.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-Xcode.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-Xcode.txt
deleted file mode 100644
index a1ed63390..000000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-Xcode.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-CMake Error at CompileDefinitions.cmake:5 \(target_compile_definitions\):
- Error evaluating generator expression:
-
- \$<COMPILE_LANGUAGE:CXX>
-
- \$<COMPILE_LANGUAGE:...> may only be used with COMPILE_OPTIONS with the
- Xcode generator.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions.cmake b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions.cmake
deleted file mode 100644
index 7935d881b..000000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-
-enable_language(CXX)
-
-add_executable(main main.cpp)
-target_compile_definitions(main PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-DANYTHING>)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileOptions-stderr-VS.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileOptions-stderr-VS.txt
deleted file mode 100644
index e9e8e9f1e..000000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileOptions-stderr-VS.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at CompileOptions.cmake:5 \(target_compile_options\):
- Error evaluating generator expression:
-
- \$<COMPILE_LANGUAGE:CXX>
-
- \$<COMPILE_LANGUAGE:...> may not be used with Visual Studio generators.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileOptions.cmake b/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileOptions.cmake
deleted file mode 100644
index 6c92abca9..000000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileOptions.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-
-enable_language(CXX)
-
-add_executable(main main.cpp)
-target_compile_options(main PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-DANYTHING>)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt
deleted file mode 100644
index ec15068e9..000000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at IncludeDirectories.cmake:5 \(target_include_directories\):
- Error evaluating generator expression:
-
- \$<COMPILE_LANGUAGE:CXX>
-
- \$<COMPILE_LANGUAGE:...> may not be used with Visual Studio generators.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt
deleted file mode 100644
index fdf92b28f..000000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-CMake Error at IncludeDirectories.cmake:5 \(target_include_directories\):
- Error evaluating generator expression:
-
- \$<COMPILE_LANGUAGE:CXX>
-
- \$<COMPILE_LANGUAGE:...> may only be used with COMPILE_OPTIONS with the
- Xcode generator.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories.cmake b/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories.cmake
deleted file mode 100644
index 31771f64d..000000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-
-enable_language(CXX)
-
-add_executable(main main.cpp)
-target_include_directories(main PRIVATE $<$<COMPILE_LANGUAGE:CXX>:anydir>)
diff --git a/Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake b/Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake
deleted file mode 100644
index 5e0a5f512..000000000
--- a/Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake
+++ /dev/null
@@ -1,20 +0,0 @@
-include(RunCMake)
-
-if (RunCMake_GENERATOR MATCHES "Visual Studio")
- set(RunCMake-stderr-file CompileOptions-stderr-VS.txt)
- run_cmake(CompileOptions)
-endif()
-if (RunCMake_GENERATOR STREQUAL "Xcode")
- set(RunCMake-stderr-file CompileDefinitions-stderr-Xcode.txt)
- run_cmake(CompileDefinitions)
-elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
- set(RunCMake-stderr-file CompileDefinitions-stderr-VS.txt)
- run_cmake(CompileDefinitions)
-endif()
-if (RunCMake_GENERATOR STREQUAL "Xcode")
- set(RunCMake-stderr-file IncludeDirectories-stderr-Xcode.txt)
- run_cmake(IncludeDirectories)
-elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
- set(RunCMake-stderr-file IncludeDirectories-stderr-VS.txt)
- run_cmake(IncludeDirectories)
-endif()
diff --git a/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake b/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake
index 99d3155dd..948c6ab15 100644
--- a/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake
+++ b/Tests/RunCMake/CPack/ArchiveCommon/common_helpers.cmake
@@ -45,13 +45,22 @@ function(toExpectedContentList FILE_NO CONTENT_VAR)
unset(prefix_)
endif()
- if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH)
- set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr")
+ # add install prefix to expected paths
+ if(DEFINED EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX)
+ set(EXPECTED_FILE_PACKAGING_PREFIX
+ "${EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX}")
+ elseif(NOT DEFINED EXPECTED_FILE_PACKAGING_PREFIX)
+ # default CPack Archive packaging install prefix
+ set(EXPECTED_FILE_PACKAGING_PREFIX "/")
endif()
+ set(prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}")
+ foreach(part_ IN LISTS ${CONTENT_VAR})
+ list(APPEND prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}${part_}")
+ endforeach()
unset(filtered_)
- foreach(part_ IN LISTS ${CONTENT_VAR})
- string(REGEX REPLACE "^${TEST_MAIN_INSTALL_PREFIX_PATH}(/|$)" "" part_ "${part_}")
+ foreach(part_ IN LISTS prepared_)
+ string(REGEX REPLACE "^/" "" part_ "${part_}")
if(part_)
list(APPEND filtered_ "${prefix_}${part_}")
diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt
index c361af065..1b3dbb228 100644
--- a/Tests/RunCMake/CPack/CMakeLists.txt
+++ b/Tests/RunCMake/CPack/CMakeLists.txt
@@ -15,3 +15,7 @@ include(tests/${RunCMake_TEST_FILE_PREFIX}/test.cmake)
set(CPACK_GENERATOR "${GENERATOR_TYPE}")
include(CPack)
+
+if(COMMAND run_after_include_cpack)
+ run_after_include_cpack()
+endif()
diff --git a/Tests/RunCMake/CPack/CPackTestHelpers.cmake b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
index f883c69e5..f65cb9df8 100644
--- a/Tests/RunCMake/CPack/CPackTestHelpers.cmake
+++ b/Tests/RunCMake/CPack/CPackTestHelpers.cmake
@@ -1,10 +1,15 @@
cmake_policy(SET CMP0057 NEW)
-function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACKAGING_TYPE)
+function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACKAGING_TYPE package_target)
if(TEST_TYPE IN_LIST types)
+ string(REGEX MATCH "^[^.]*" GENERATOR_TYPE "${TEST_TYPE}")
set(RunCMake_TEST_NO_CLEAN TRUE)
- set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${TEST_NAME}-build")
- set(full_test_name_ "${TEST_NAME}")
+ if(package_target)
+ set(full_test_name_ "${TEST_NAME}-package-target")
+ else()
+ set(full_test_name_ "${TEST_NAME}")
+ endif()
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${full_test_name_}-build")
if(SUBTEST_SUFFIX)
set(RunCMake_TEST_BINARY_DIR "${RunCMake_TEST_BINARY_DIR}-${SUBTEST_SUFFIX}-subtest")
@@ -17,8 +22,8 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACK
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
- if(EXISTS "${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-Prerequirements.cmake")
- include("${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-Prerequirements.cmake")
+ if(EXISTS "${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-Prerequirements.cmake")
+ include("${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-Prerequirements.cmake")
set(FOUND_PREREQUIREMENTS false)
get_test_prerequirements("FOUND_PREREQUIREMENTS" "${config_file}")
@@ -31,28 +36,55 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACK
endif()
# execute cmake
- set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}"
+ set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${GENERATOR_TYPE}"
"-DRunCMake_TEST_FILE_PREFIX=${TEST_NAME}"
"-DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX}"
"-DPACKAGING_TYPE=${PACKAGING_TYPE}")
+
+ foreach(o out err)
+ if(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/configure-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt)
+ set(RunCMake-std${o}-file "tests/${TEST_NAME}/configure-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt")
+ elseif(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/configure-${SUBTEST_SUFFIX}-std${o}.txt)
+ set(RunCMake-std${o}-file "tests/${TEST_NAME}/configure-${SUBTEST_SUFFIX}-std${o}.txt")
+ elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/configure-${PACKAGING_TYPE}-std${o}.txt)
+ set(RunCMake-std${o}-file "tests/${TEST_NAME}/configure-${PACKAGING_TYPE}-std${o}.txt")
+ elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/configure-std${o}.txt)
+ set(RunCMake-std${o}-file "tests/${TEST_NAME}/configure-std${o}.txt")
+ else()
+ unset(RunCMake-std${o}-file)
+ endif()
+ endforeach()
+
run_cmake(${full_test_name_})
# execute optional build step
if(build)
+ unset(RunCMake-stdout-file)
+ unset(RunCMake-stderr-file)
run_cmake_command(${full_test_name_}-Build "${CMAKE_COMMAND}" --build "${RunCMake_TEST_BINARY_DIR}")
endif()
if(source)
- set(pack_params_ -G ${TEST_TYPE} --config ./CPackSourceConfig.cmake)
+ set(pack_params_ -G ${GENERATOR_TYPE} --config ./CPackSourceConfig.cmake)
FILE(APPEND ${RunCMake_TEST_BINARY_DIR}/CPackSourceConfig.cmake
- "\nset(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS \"-DRunCMake_TEST:STRING=${full_test_name_} -DRunCMake_TEST_FILE_PREFIX:STRING=${TEST_NAME} -DGENERATOR_TYPE:STRING=${TEST_TYPE}\")")
+ "\nset(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS \"-DRunCMake_TEST:STRING=${full_test_name_} -DRunCMake_TEST_FILE_PREFIX:STRING=${TEST_NAME} -DGENERATOR_TYPE:STRING=${GENERATOR_TYPE}\")")
else()
unset(pack_params_)
endif()
+ if(package_target)
+ set(cpack_command_ ${CMAKE_COMMAND} --build "${RunCMake_TEST_BINARY_DIR}" --target package)
+ else()
+ set(cpack_command_ ${CMAKE_CPACK_COMMAND} ${pack_params_})
+ endif()
+
# execute cpack
+ set(SETENV)
+ if(ENVIRONMENT)
+ set(SETENV ${CMAKE_COMMAND} -E env "${ENVIRONMENT}")
+ endif()
execute_process(
- COMMAND ${CMAKE_CPACK_COMMAND} ${pack_params_}
+ COMMAND ${SETENV} ${cpack_command_}
WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
RESULT_VARIABLE "result_"
OUTPUT_FILE "${RunCMake_TEST_BINARY_DIR}/test_output.txt"
@@ -60,27 +92,31 @@ function(run_cpack_test_common_ TEST_NAME types build SUBTEST_SUFFIX source PACK
)
foreach(o out err)
- if(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt)
- set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt")
- elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-std${o}.txt)
- set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-${PACKAGING_TYPE}-std${o}.txt")
- elseif(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt)
- set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt")
- elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${TEST_TYPE}-std${o}.txt)
- set(RunCMake-std${o}-file "tests/${TEST_NAME}/${TEST_TYPE}-std${o}.txt")
- elseif(EXISTS ${RunCMake_SOURCE_DIR}/${TEST_TYPE}/default_expected_std${o}.txt)
- set(RunCMake-std${o}-file "${TEST_TYPE}/default_expected_std${o}.txt")
+ if(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt)
+ set(RunCMake-std${o}-file "tests/${TEST_NAME}/${GENERATOR_TYPE}-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt")
+ elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-${PACKAGING_TYPE}-std${o}.txt)
+ set(RunCMake-std${o}-file "tests/${TEST_NAME}/${GENERATOR_TYPE}-${PACKAGING_TYPE}-std${o}.txt")
+ elseif(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt)
+ set(RunCMake-std${o}-file "tests/${TEST_NAME}/${GENERATOR_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt")
+ elseif(EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${GENERATOR_TYPE}-std${o}.txt)
+ set(RunCMake-std${o}-file "tests/${TEST_NAME}/${GENERATOR_TYPE}-std${o}.txt")
+ elseif(SUBTEST_SUFFIX AND EXISTS ${RunCMake_SOURCE_DIR}/tests/${TEST_NAME}/${SUBTEST_SUFFIX}-std${o}.txt)
+ set(RunCMake-std${o}-file "tests/${TEST_NAME}/${SUBTEST_SUFFIX}-std${o}.txt")
+ elseif(EXISTS ${RunCMake_SOURCE_DIR}/${GENERATOR_TYPE}/default_expected_std${o}.txt)
+ set(RunCMake-std${o}-file "${GENERATOR_TYPE}/default_expected_std${o}.txt")
+ else()
+ unset(RunCMake-std${o}-file)
endif()
endforeach()
# verify result
run_cmake_command(
- ${TEST_TYPE}/${full_test_name_}
+ ${GENERATOR_TYPE}/${full_test_name_}
"${CMAKE_COMMAND}"
-DRunCMake_TEST=${full_test_name_}
-DRunCMake_TEST_FILE_PREFIX=${TEST_NAME}
-DRunCMake_SUBTEST_SUFFIX=${SUBTEST_SUFFIX}
- -DGENERATOR_TYPE=${TEST_TYPE}
+ -DGENERATOR_TYPE=${GENERATOR_TYPE}
-DPACKAGING_TYPE=${PACKAGING_TYPE}
"-Dsrc_dir=${RunCMake_SOURCE_DIR}"
"-Dbin_dir=${RunCMake_TEST_BINARY_DIR}"
@@ -92,18 +128,24 @@ endfunction()
function(run_cpack_test TEST_NAME types build PACKAGING_TYPES)
foreach(packaging_type_ IN LISTS PACKAGING_TYPES)
- run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false "${packaging_type_}")
+ run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false "${packaging_type_}" false)
+ endforeach()
+endfunction()
+
+function(run_cpack_test_package_target TEST_NAME types build PACKAGING_TYPES)
+ foreach(packaging_type_ IN LISTS PACKAGING_TYPES)
+ run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "" false "${packaging_type_}" true)
endforeach()
endfunction()
function(run_cpack_test_subtests TEST_NAME SUBTEST_SUFFIXES types build PACKAGING_TYPES)
foreach(suffix_ IN LISTS SUBTEST_SUFFIXES)
foreach(packaging_type_ IN LISTS PACKAGING_TYPES)
- run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "${suffix_}" false "${packaging_type_}")
+ run_cpack_test_common_("${TEST_NAME}" "${types}" "${build}" "${suffix_}" false "${packaging_type_}" false)
endforeach()
endforeach()
endfunction()
function(run_cpack_source_test TEST_NAME types)
- run_cpack_test_common_("${TEST_NAME}" "${types}" false "" true "")
+ run_cpack_test_common_("${TEST_NAME}" "${types}" false "" true "" false)
endfunction()
diff --git a/Tests/RunCMake/CPack/DEB/Helpers.cmake b/Tests/RunCMake/CPack/DEB/Helpers.cmake
index ad1b47bdc..9b98ed41f 100644
--- a/Tests/RunCMake/CPack/DEB/Helpers.cmake
+++ b/Tests/RunCMake/CPack/DEB/Helpers.cmake
@@ -1,7 +1,7 @@
-set(ALL_FILES_GLOB "*.deb")
+set(ALL_FILES_GLOB "*.deb" "*.ddeb")
function(getPackageContent FILE RESULT_VAR)
- execute_process(COMMAND ${DPKG_EXECUTABLE} -c "${FILE}"
+ execute_process(COMMAND ${CMAKE_COMMAND} -E env TZ=Etc/UTC ${DPKG_EXECUTABLE} -c "${FILE}"
OUTPUT_VARIABLE package_content_
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
@@ -23,7 +23,7 @@ function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_V
endif()
if(GENERATOR_SPECIFIC_FORMAT)
- set(${RESULT_VAR} "${NAME}${COMPONENT}_${VERSION}-${REVISION}_*.deb" PARENT_SCOPE)
+ set(${RESULT_VAR} "${NAME}${COMPONENT}_${VERSION}_*.deb" PARENT_SCOPE)
else()
set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.deb" PARENT_SCOPE)
endif()
@@ -47,7 +47,20 @@ function(getPackageContentList FILE RESULT_VAR)
endfunction()
function(toExpectedContentList FILE_NO CONTENT_VAR)
- # no need to do anything
+ # add install prefix to expected paths
+ if(DEFINED EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX)
+ set(EXPECTED_FILE_PACKAGING_PREFIX
+ "${EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX}")
+ elseif(NOT DEFINED EXPECTED_FILE_PACKAGING_PREFIX)
+ # default CPackDeb packaging install prefix
+ set(EXPECTED_FILE_PACKAGING_PREFIX "/usr")
+ endif()
+ set(prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}")
+ foreach(part_ IN LISTS ${CONTENT_VAR})
+ list(APPEND prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}${part_}")
+ endforeach()
+
+ set(${CONTENT_VAR} "${prepared_}" PARENT_SCOPE)
endfunction()
function(getMissingShlibsErrorExtra FILE RESULT_VAR)
diff --git a/Tests/RunCMake/CPack/External/Helpers.cmake b/Tests/RunCMake/CPack/External/Helpers.cmake
new file mode 100644
index 000000000..2c67e0644
--- /dev/null
+++ b/Tests/RunCMake/CPack/External/Helpers.cmake
@@ -0,0 +1,31 @@
+function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_VAR)
+ set(${RESULT_VAR} "${NAME}-${VERSION}-*.json" PARENT_SCOPE)
+endfunction()
+
+function(getPackageContentList FILE RESULT_VAR)
+ set("${RESULT_VAR}" "" PARENT_SCOPE)
+endfunction()
+
+function(toExpectedContentList FILE_NO CONTENT_VAR)
+ set("${CONTENT_VAR}" "" PARENT_SCOPE)
+endfunction()
+
+set(ALL_FILES_GLOB "*.json")
+
+function(check_ext_json EXPECTED_FILE ACTUAL_FILE)
+ file(READ "${EXPECTED_FILE}" _expected_regex)
+ file(READ "${ACTUAL_FILE}" _actual_contents)
+
+ string(REGEX REPLACE "\n+$" "" _expected_regex "${_expected_regex}")
+ string(REGEX REPLACE "\n+$" "" _actual_contents "${_actual_contents}")
+
+ if(NOT "${_actual_contents}" MATCHES "${_expected_regex}")
+ message(FATAL_ERROR
+ "Output JSON does not match expected regex.\n"
+ "Expected regex:\n"
+ "${_expected_regex}\n"
+ "Actual output:\n"
+ "${_actual_contents}\n"
+ )
+ endif()
+endfunction()
diff --git a/Tests/RunCMake/CPack/External/Prerequirements.cmake b/Tests/RunCMake/CPack/External/Prerequirements.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CPack/External/Prerequirements.cmake
diff --git a/Tests/RunCMake/CPack/README.txt b/Tests/RunCMake/CPack/README.txt
index 7c98f6972..216512505 100644
--- a/Tests/RunCMake/CPack/README.txt
+++ b/Tests/RunCMake/CPack/README.txt
@@ -91,6 +91,19 @@ If test will be used for multiple generators but some of them require some
generator specific commands then those commands should be added to 'test.cmake'
script wrapped with 'if(GENERATOR_TYPE STREQUAL <name_of_the_generator>)'.
+NOTE: In some cases (for example when testing CPackComponent.cmake functions)
+the test has to run some functions after CPack.cmake is included. In such cases
+a function run_after_include_cpack can be declared in test.cmake file and that
+function will run after the inclusion of CPack.cmake.
+
+NOTE: During CMake configure stage developer warnings may be expected. In such
+cases an expected output regular expression can be provided by creating
+'<test_name>/configure-stdout.txt' and/or '<test_name>/configure-stderr.txt'
+file. There are also more specialized versions of the file available:
+- configure-${PACKAGING_TYPE}-${SUBTEST_SUFFIX}-std${o}.txt
+- configure-${SUBTEST_SUFFIX}-std${o}.txt
+- configure-${PACKAGING_TYPE}-std${o}.txt
+
build phase (optional and not available for source package tests)
-----------------------------------------------------------------
@@ -144,17 +157,23 @@ this step and must contain
NOTE: This variable should be used only as last resort as it sets generator
specific regular expression.
EXPECTED_FILE_CONTENT_<file_number_starting_with_1>_LIST should be
- prefered as it requires a list of expected files and directories that
+ preferred as it requires a list of expected files and directories that
is later changed automatically depending on the generator so expected
package content can be written only once per test for all generators.
-Optional verification phase is generator specific and is optionaly executed.
+- EXPECTED_FILE_PACKAGING_PREFIX and
+ EXPECTED_FILE_<file_number_starting_with_1>_PACKAGING_PREFIX variables can be
+ set to explicitly specified CPACK_PACKAGING_PREFIX value. By default this
+ variable does not need to be set as it is implicitly set to package generator
+ specific prefix.
+
+Optional verification phase is generator specific and is optionally executed.
This phase is executed if '<test_name>/VerifyResult.cmake' script exists.
VerifyResult.cmake script also automatically prints out standard output and
standard error from CPack execution phase that is compared with
'<test_name>/<generator_name>-stdout.txt' regular expression and
-and '<test_name>/<generator_name>-stderr.txt' regular expresson respectively.
+'<test_name>/<generator_name>-stderr.txt' regular expresson respectively.
NOTE: For subtests generator name can also be suffixed with subtest name and/or
packaging type (MONOLITHIC, COMPONENT, GROUP) and in such cases the
preferences of which file will be used are as follows:
@@ -162,6 +181,7 @@ NOTE: For subtests generator name can also be suffixed with subtest name and/or
- generator name + packaging type
- generator name + subtest name
- generator name
+ - subtest name
- default generator
File name format: '<generator_name>-<packaging_type>-<subtest_name>-std<type>.txt'
where <type> can either be 'out' or 'err'.
@@ -204,7 +224,7 @@ To add a new generator we must
+ FILE that will contain the package file for which the package content
should be returned.
+ RESULT_VAR that will tell the function which variable in parent scope
- should contain the result (list of pacakge content)
+ should contain the result (list of package content)
- toExpectedContentList: This function should convert an expected package
content list into one that is expected for the
generator (e.g. rpm packages have install/relocate
diff --git a/Tests/RunCMake/CPack/RPM/Helpers.cmake b/Tests/RunCMake/CPack/RPM/Helpers.cmake
index d8012b11b..a29c02065 100644
--- a/Tests/RunCMake/CPack/RPM/Helpers.cmake
+++ b/Tests/RunCMake/CPack/RPM/Helpers.cmake
@@ -23,6 +23,9 @@ function(getPackageNameGlobexpr NAME COMPONENT VERSION REVISION FILE_NO RESULT_V
endif()
if(GENERATOR_SPECIFIC_FORMAT)
+ if(NOT REVISION)
+ set(REVISION "1")
+ endif()
set(${RESULT_VAR} "${NAME}${COMPONENT}-${VERSION}-${REVISION}.*.rpm" PARENT_SCOPE)
else()
set(${RESULT_VAR} "${NAME}-${VERSION}-*${COMPONENT}.rpm" PARENT_SCOPE)
@@ -44,14 +47,29 @@ function(getPackageContentList FILE RESULT_VAR)
endfunction()
function(toExpectedContentList FILE_NO CONTENT_VAR)
- if(NOT DEFINED TEST_INSTALL_PREFIX_PATHS)
- set(TEST_INSTALL_PREFIX_PATHS "/usr")
+ # add install prefix to expected paths
+ if(DEFINED EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX)
+ set(EXPECTED_FILE_PACKAGING_PREFIX
+ "${EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX}")
+ elseif(NOT DEFINED EXPECTED_FILE_PACKAGING_PREFIX)
+ # default CPackRPM packaging install prefix
+ set(EXPECTED_FILE_PACKAGING_PREFIX "/usr")
endif()
+ set(prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}")
+ foreach(part_ IN LISTS ${CONTENT_VAR})
+ list(APPEND prepared_ "${EXPECTED_FILE_PACKAGING_PREFIX}${part_}")
+ endforeach()
+ # remove paths that are excluded from auto packaging
+ if(NOT DEFINED CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST)
+ set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST
+ /etc /etc/init.d /usr /usr/bin /usr/include /usr/lib
+ /usr/libx32 /usr/lib64 /usr/share /usr/share/aclocal /usr/share/doc)
+ endif()
unset(filtered_)
- foreach(part_ IN LISTS ${CONTENT_VAR})
+ foreach(part_ IN LISTS prepared_)
unset(dont_add_)
- foreach(for_removal_ IN LISTS TEST_INSTALL_PREFIX_PATHS)
+ foreach(for_removal_ IN LISTS CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST)
if(part_ STREQUAL for_removal_)
set(dont_add_ TRUE)
break()
diff --git a/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt b/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt
index 4a0e4e6d0..6c87ca0c0 100644
--- a/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt
+++ b/Tests/RunCMake/CPack/RPM/default_expected_stderr.txt
@@ -1 +1 @@
-^(CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM/CPack/[^-]*-build((-[^-]*-subtest/)|/)_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec(\n|$))*$
+^(CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM\.[^/]*/CPack/[^-]*(-package-target)?-build((-[^-]*-subtest/)|/)_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec(\n|$))*$
diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake
index faf151a13..c2382b05a 100644
--- a/Tests/RunCMake/CPack/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake
@@ -4,26 +4,42 @@ include(RunCMake)
include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake")
# run_cpack_test args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP "PACKAGING_TYPES"
-run_cpack_test(CUSTOM_BINARY_SPEC_FILE "RPM" false "MONOLITHIC;COMPONENT")
-run_cpack_test(CUSTOM_NAMES "RPM;DEB;TGZ" true "COMPONENT")
-run_cpack_test(DEBUGINFO "RPM" true "COMPONENT")
-run_cpack_test(DEPENDENCIES "RPM;DEB" true "COMPONENT")
-run_cpack_test(DIST "RPM" false "MONOLITHIC")
-run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true "MONOLITHIC;COMPONENT")
-run_cpack_test(EXTRA "DEB" false "COMPONENT")
-run_cpack_test(GENERATE_SHLIBS "DEB" true "COMPONENT")
-run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB" true "COMPONENT")
-run_cpack_test(INSTALL_SCRIPTS "RPM" false "COMPONENT")
-run_cpack_test(LONG_FILENAMES "DEB" false "MONOLITHIC")
-run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM" false "COMPONENT")
-run_cpack_test(MINIMAL "RPM;DEB;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ" false "MONOLITHIC;COMPONENT")
+run_cpack_test(CUSTOM_BINARY_SPEC_FILE "RPM.CUSTOM_BINARY_SPEC_FILE" false "MONOLITHIC;COMPONENT")
+run_cpack_test(CUSTOM_NAMES "RPM.CUSTOM_NAMES;DEB.CUSTOM_NAMES;TGZ" true "COMPONENT")
+run_cpack_test(DEBUGINFO "RPM.DEBUGINFO;DEB.DEBUGINFO" true "COMPONENT")
+run_cpack_test_subtests(DEFAULT_PERMISSIONS "CMAKE_var_set;CPACK_var_set;both_set;invalid_CMAKE_var;invalid_CPACK_var" "RPM.DEFAULT_PERMISSIONS;DEB.DEFAULT_PERMISSIONS" false "MONOLITHIC;COMPONENT")
+run_cpack_test(DEPENDENCIES "RPM.DEPENDENCIES;DEB.DEPENDENCIES" true "COMPONENT")
+run_cpack_test(DIST "RPM.DIST" false "MONOLITHIC")
+run_cpack_test(EMPTY_DIR "RPM.EMPTY_DIR;DEB.EMPTY_DIR;TGZ" true "MONOLITHIC;COMPONENT")
+run_cpack_test(VERSION "RPM.VERSION;DEB.VERSION" false "MONOLITHIC;COMPONENT")
+run_cpack_test(EXTRA "DEB.EXTRA" false "COMPONENT")
+run_cpack_test_subtests(GENERATE_SHLIBS "soversion_not_zero;soversion_zero" "DEB.GENERATE_SHLIBS" true "COMPONENT")
+run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB.GENERATE_SHLIBS_LDCONFIG" true "COMPONENT")
+run_cpack_test(INSTALL_SCRIPTS "RPM.INSTALL_SCRIPTS" false "COMPONENT")
+run_cpack_test(LONG_FILENAMES "DEB.LONG_FILENAMES" false "MONOLITHIC")
+run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM.MAIN_COMPONENT" false "COMPONENT")
+run_cpack_test(MINIMAL "RPM.MINIMAL;DEB.MINIMAL;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;External" false "MONOLITHIC;COMPONENT")
+run_cpack_test_package_target(MINIMAL "RPM.MINIMAL;DEB.MINIMAL;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;External" false "MONOLITHIC;COMPONENT")
run_cpack_test_subtests(PACKAGE_CHECKSUM "invalid;MD5;SHA1;SHA224;SHA256;SHA384;SHA512" "TGZ" false "MONOLITHIC")
-run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false "COMPONENT")
-run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false "COMPONENT")
-run_cpack_test_subtests(SINGLE_DEBUGINFO "no_main_component;one_component;one_component_main;no_debuginfo;one_component_no_debuginfo;no_components;valid" "RPM" true "CUSTOM")
-run_cpack_test(EXTRA_SLASH_IN_PATH "RPM" true "COMPONENT")
-run_cpack_source_test(SOURCE_PACKAGE "RPM")
-run_cpack_test(SUGGESTS "RPM" false "MONOLITHIC")
-run_cpack_test(SYMLINKS "RPM;TGZ" false "MONOLITHIC;COMPONENT")
-run_cpack_test(USER_FILELIST "RPM" false "MONOLITHIC")
-run_cpack_test(MD5SUMS "DEB" false "MONOLITHIC;COMPONENT")
+run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM.PARTIALLY_RELOCATABLE_WARNING" false "COMPONENT")
+run_cpack_test(PER_COMPONENT_FIELDS "RPM.PER_COMPONENT_FIELDS;DEB.PER_COMPONENT_FIELDS" false "COMPONENT")
+run_cpack_test_subtests(SINGLE_DEBUGINFO "no_main_component;one_component;one_component_main;no_debuginfo;one_component_no_debuginfo;no_components;valid" "RPM.SINGLE_DEBUGINFO" true "CUSTOM")
+run_cpack_test(EXTRA_SLASH_IN_PATH "RPM.EXTRA_SLASH_IN_PATH" true "COMPONENT")
+run_cpack_source_test(SOURCE_PACKAGE "RPM.SOURCE_PACKAGE")
+run_cpack_test(SUGGESTS "RPM.SUGGESTS" false "MONOLITHIC")
+run_cpack_test(SYMLINKS "RPM.SYMLINKS;TGZ" false "MONOLITHIC;COMPONENT")
+set(ENVIRONMENT "SOURCE_DATE_EPOCH=123456789")
+run_cpack_test(TIMESTAMPS "DEB.TIMESTAMPS;TGZ" false "COMPONENT")
+unset(ENVIRONMENT)
+run_cpack_test(USER_FILELIST "RPM.USER_FILELIST" false "MONOLITHIC")
+run_cpack_test(MD5SUMS "DEB.MD5SUMS" false "MONOLITHIC;COMPONENT")
+run_cpack_test_subtests(CPACK_INSTALL_SCRIPTS "singular;plural;both" "ZIP" false "MONOLITHIC")
+run_cpack_test(DEB_PACKAGE_VERSION_BACK_COMPATIBILITY "DEB.DEB_PACKAGE_VERSION_BACK_COMPATIBILITY" false "MONOLITHIC;COMPONENT")
+run_cpack_test_subtests(EXTERNAL "none;good;good_multi;bad_major;bad_minor;invalid_good;invalid_bad;stage_and_package" "External" false "MONOLITHIC;COMPONENT")
+run_cpack_test_subtests(
+ DEB_DESCRIPTION
+ "CPACK_DEBIAN_PACKAGE_DESCRIPTION;CPACK_PACKAGE_DESCRIPTION;CPACK_COMPONENT_COMP_DESCRIPTION;CPACK_PACKAGE_DESCRIPTION_FILE;CPACK_NO_PACKAGE_DESCRIPTION"
+ "DEB.DEB_DESCRIPTION"
+ false
+ "MONOLITHIC;COMPONENT"
+)
diff --git a/Tests/RunCMake/CPack/STGZ/Helpers.cmake b/Tests/RunCMake/CPack/STGZ/Helpers.cmake
index 68b1eabd2..175664551 100644
--- a/Tests/RunCMake/CPack/STGZ/Helpers.cmake
+++ b/Tests/RunCMake/CPack/STGZ/Helpers.cmake
@@ -47,18 +47,29 @@ function(toExpectedContentList FILE_NO CONTENT_VAR)
string(SUBSTRING "${prefix_}" 0 ${pos_} prefix_)
endif()
- if(NOT DEFINED TEST_MAIN_INSTALL_PREFIX_PATH)
- set(TEST_MAIN_INSTALL_PREFIX_PATH "/usr")
+ # add install prefix to expected paths
+ if(DEFINED EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX)
+ set(EXPECTED_FILE_PACKAGING_PREFIX
+ "${EXPECTED_FILE_${FILE_NO}_PACKAGING_PREFIX}")
+ elseif(NOT DEFINED EXPECTED_FILE_PACKAGING_PREFIX)
+ # default CPack Archive packaging install prefix
+ set(EXPECTED_FILE_PACKAGING_PREFIX "/")
endif()
- set(filtered_ "${prefix_}")
- foreach(part_ IN LISTS ${CONTENT_VAR})
- string(REGEX REPLACE "^${TEST_MAIN_INSTALL_PREFIX_PATH}(/|$)" "" part_ "${part_}")
+ # remove trailing slash otherwise path concatenation will cause double slashes
+ string(REGEX REPLACE "/$" "" EXPECTED_FILE_PACKAGING_PREFIX
+ "${EXPECTED_FILE_PACKAGING_PREFIX}")
+
+ if(EXPECTED_FILE_PACKAGING_PREFIX)
+ set(prepared_ "${prefix_}")
+ else()
+ unset(prepared_)
+ endif()
- if(part_)
- list(APPEND filtered_ "${prefix_}/${part_}")
- endif()
+ list(APPEND prepared_ "${prefix_}${EXPECTED_FILE_PACKAGING_PREFIX}")
+ foreach(part_ IN LISTS ${CONTENT_VAR})
+ list(APPEND prepared_ "${prefix_}${EXPECTED_FILE_PACKAGING_PREFIX}${part_}")
endforeach()
- set(${CONTENT_VAR} "${filtered_}" PARENT_SCOPE)
+ set(${CONTENT_VAR} "${prepared_}" PARENT_SCOPE)
endfunction()
diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake
index 470ebf7a8..345b37fac 100644
--- a/Tests/RunCMake/CPack/VerifyResult.cmake
+++ b/Tests/RunCMake/CPack/VerifyResult.cmake
@@ -8,9 +8,7 @@ function(findExpectedFile FILE_NO RESULT_VAR GLOBING_EXPR_VAR)
endif()
if(NOT DEFINED EXPECTED_FILE_${FILE_NO}_VERSION)
set(EXPECTED_FILE_${FILE_NO}_VERSION "0.1.1")
- endif()
- if(NOT DEFINED EXPECTED_FILE_${FILE_NO}_REVISION)
- set(EXPECTED_FILE_${FILE_NO}_REVISION "1")
+ set(EXPECTED_FILE_${FILE_NO}_VERSION "0.1.1" PARENT_SCOPE)
endif()
getPackageNameGlobexpr("${EXPECTED_FILE_${FILE_NO}_NAME}"
@@ -58,8 +56,12 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0)
set(EXPECTED_FILE_CONTENT_${file_no_} "${EXPECTED_FILE_CONTENT_${file_no_}_LIST}")
toExpectedContentList("${file_no_}" "EXPECTED_FILE_CONTENT_${file_no_}")
- list(SORT PACKAGE_CONTENT)
- list(SORT EXPECTED_FILE_CONTENT_${file_no_})
+ if(NOT PACKAGE_CONTENT STREQUAL "")
+ list(SORT PACKAGE_CONTENT)
+ endif()
+ if(NOT EXPECTED_FILE_CONTENT_${file_no_} STREQUAL "")
+ list(SORT EXPECTED_FILE_CONTENT_${file_no_})
+ endif()
if(PACKAGE_CONTENT STREQUAL EXPECTED_FILE_CONTENT_${file_no_})
set(expected_content_list TRUE)
@@ -90,7 +92,7 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0)
# check that there were no extra files generated
foreach(all_files_glob_ IN LISTS ALL_FILES_GLOB)
file(GLOB foundAll_ RELATIVE "${bin_dir}" "${all_files_glob_}")
- list(APPEND allFoundFiles_ "${foundAll_}")
+ list(APPEND allFoundFiles_ ${foundAll_})
endforeach()
list(LENGTH foundFiles_ foundFilesCount_)
diff --git a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/ExpectedFiles.cmake
new file mode 100644
index 000000000..02a78215b
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/ExpectedFiles.cmake
@@ -0,0 +1,3 @@
+set(EXPECTED_FILES_COUNT "1")
+
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/abc.txt")
diff --git a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/both-stderr.txt b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/both-stderr.txt
new file mode 100644
index 000000000..666030e29
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/both-stderr.txt
@@ -0,0 +1 @@
+CPack Warning: Both CPACK_INSTALL_SCRIPTS and CPACK_INSTALL_SCRIPT are set, the latter will be ignored.
diff --git a/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/test.cmake b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/test.cmake
new file mode 100644
index 000000000..249d2e6bb
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/CPACK_INSTALL_SCRIPTS/test.cmake
@@ -0,0 +1,26 @@
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/abc.txt" "test content")
+set(user_script_ "${CMAKE_CURRENT_BINARY_DIR}/user-script.cmake")
+file(WRITE "${user_script_}"
+ "file(INSTALL DESTINATION \"\${CMAKE_INSTALL_PREFIX}/foo\"
+ TYPE FILE FILES \"${CMAKE_CURRENT_BINARY_DIR}/abc.txt\")")
+
+if(RunCMake_SUBTEST_SUFFIX STREQUAL "both")
+ set(CPACK_INSTALL_SCRIPT "${user_script_}")
+ set(CPACK_INSTALL_SCRIPTS "${CPACK_INSTALL_SCRIPT}")
+
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "singular")
+ set(CPACK_INSTALL_SCRIPT "${user_script_}")
+
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "plural")
+ set(CPACK_INSTALL_SCRIPTS "${user_script_}")
+
+else()
+ message(FATAL_ERROR "Unexpected subtest name: ${RunCMake_SUBTEST_SUFFIX}")
+
+endif()
+
+function(run_after_include_cpack)
+ file(READ "${CPACK_OUTPUT_CONFIG_FILE}" conf_file_)
+ string(REGEX REPLACE "SET\\(CPACK_INSTALL_CMAKE_PROJECTS [^)]*\\)" "" conf_file_ "${conf_file_}")
+ file(WRITE "${CPACK_OUTPUT_CONFIG_FILE}" "${conf_file_}")
+endfunction()
diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake
index 694dc00ab..6d895ec2f 100644
--- a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/ExpectedFiles.cmake
@@ -1,9 +1,9 @@
set(EXPECTED_FILES_COUNT "1")
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
if(PACKAGING_TYPE STREQUAL "COMPONENT")
set(EXPECTED_FILES_COUNT "2")
set(EXPECTED_FILE_1_COMPONENT "test")
set(EXPECTED_FILE_2_COMPONENT "test2")
- set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt")
+ set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt")
endif()
diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt
index e6d86d0de..b0502628e 100644
--- a/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt
+++ b/Tests/RunCMake/CPack/tests/CUSTOM_BINARY_SPEC_FILE/RPM-COMPONENT-stderr.txt
@@ -1,2 +1,2 @@
^CPackRPM: Will use USER specified spec file: (/[^/]*)*/CUSTOM_BINARY_SPEC_FILE/custom\.spec\.in
-CPackRPM: Will use GENERATED spec file:.*/Tests/RunCMake/RPM/CPack/CUSTOM_BINARY_SPEC_FILE-build/_CPack_Packages/.*/RPM/SPECS/custom_binary_spec_file-test2\.spec$
+CPackRPM: Will use GENERATED spec file:.*/Tests/RunCMake/RPM\.CUSTOM_BINARY_SPEC_FILE/CPack/CUSTOM_BINARY_SPEC_FILE-build/_CPack_Packages/.*/RPM/SPECS/custom_binary_spec_file-test2\.spec$
diff --git a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake
index 5cb280cd6..07226df04 100644
--- a/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/CUSTOM_NAMES/ExpectedFiles.cmake
@@ -1,10 +1,10 @@
set(EXPECTED_FILES_COUNT "3")
set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE)
set(EXPECTED_FILE_1_COMPONENT "pkg_1")
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
set(EXPECTED_FILE_2_NAME "second")
-set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
-set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_2_LIST "/foo;/foo/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_3_LIST "/foo;/foo/CMakeLists.txt")
if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM")
string(TOLOWER "${GENERATOR_TYPE}" file_extension_)
diff --git a/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake
index 3d8de74d4..cf2e8ac6b 100644
--- a/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/ExpectedFiles.cmake
@@ -3,16 +3,39 @@ set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "5")
set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE)
-set(EXPECTED_FILE_1_NAME "Debuginfo")
+if(GENERATOR_TYPE STREQUAL "RPM")
+ set(NAME "Debuginfo")
+ set(DEBUG_SUFFIX "debuginfo")
+ set(PKG "rpm")
+ set(DEBUG_PKG "rpm")
+elseif(GENERATOR_TYPE STREQUAL "DEB")
+ set(NAME "debuginfo")
+ set(DEBUG_SUFFIX "dbgsym")
+ set(PKG "deb")
+ set(DEBUG_PKG "ddeb")
+endif()
+
+set(EXPECTED_FILE_1_NAME "${NAME}")
set(EXPECTED_FILE_1_COMPONENT "applications")
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog")
-set(EXPECTED_FILE_2 "TestDinfo-pkg*-headers.rpm")
-set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt")
-set(EXPECTED_FILE_3 "TestDinfo-pkg*-libs.rpm")
-set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/libtest_lib.so")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog")
+
+set(EXPECTED_FILE_2 "TestDinfo-pkg*-headers.${PKG}")
+set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt")
+
+set(EXPECTED_FILE_3 "TestDinfo-pkg*-libs.${PKG}")
+set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/libtest_lib.so")
+
+set(EXPECTED_FILE_4 "${NAME}-applications-${DEBUG_SUFFIX}*.${DEBUG_PKG}")
+if(GENERATOR_TYPE STREQUAL "RPM")
+ set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*\.debug.*")
+elseif(GENERATOR_TYPE STREQUAL "DEB")
+ set(EXPECTED_FILE_CONTENT_4 ".*/usr/lib/debug/.build-id/.*\.debug.*")
+endif()
-set(EXPECTED_FILE_4_NAME "Debuginfo")
-set(EXPECTED_FILE_4_COMPONENT "applications-debuginfo")
-set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*")
-set(EXPECTED_FILE_5 "libs-DebugInfoPackage.rpm")
-set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*")
+if(GENERATOR_TYPE STREQUAL "RPM")
+ set(EXPECTED_FILE_5 "libs-DebugInfoPackage.rpm")
+ set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*\.debug.*")
+elseif(GENERATOR_TYPE STREQUAL "DEB")
+ set(EXPECTED_FILE_5 "TestDinfo-pkg-libs-dbgsym.ddeb")
+ set(EXPECTED_FILE_CONTENT_5 ".*/usr/lib/debug/.build-id/.*\.debug.*")
+endif()
diff --git a/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake
index f1b6738bd..161a36a85 100644
--- a/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake
+++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/test.cmake
@@ -8,6 +8,10 @@ endif()
set(CMAKE_BUILD_TYPE Debug)
+# for rpm packages execute flag must be set for shared libs if debuginfo
+# packages are generated
+set(CPACK_RPM_INSTALL_WITH_EXEC TRUE)
+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp"
"int test_lib();\n")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp"
@@ -25,12 +29,16 @@ install(TARGETS test_lib DESTINATION bas COMPONENT libs)
set(CPACK_RPM_APPLICATIONS_FILE_NAME "RPM-DEFAULT")
set(CPACK_RPM_APPLICATIONS_DEBUGINFO_PACKAGE ON)
+set(CPACK_DEBIAN_APPLICATIONS_FILE_NAME "DEB-DEFAULT")
+set(CPACK_DEBIAN_APPLICATIONS_DEBUGINFO_PACKAGE ON)
# test that components with debuginfo enabled still honor
# CPACK_PACKAGE_FILE_NAME setting
set(CPACK_RPM_PACKAGE_NAME "Debuginfo")
set(CPACK_PACKAGE_FILE_NAME "TestDinfo-pkg")
set(CPACK_RPM_LIBS_DEBUGINFO_PACKAGE ON)
+set(CPACK_DEBIAN_PACKAGE_NAME "Debuginfo")
+set(CPACK_DEBIAN_LIBS_DEBUGINFO_PACKAGE ON)
# test debuginfo package rename
set(CPACK_RPM_DEBUGINFO_FILE_NAME
diff --git a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/ExpectedFiles.cmake
new file mode 100644
index 000000000..39f18a3d6
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/ExpectedFiles.cmake
@@ -0,0 +1,16 @@
+set(EXPECTED_FILES_COUNT_MONOLITHIC "1")
+set(EXPECTED_FILES_COUNT_COMPONENT "2")
+set(EXPECTED_FILES_COUNT "${EXPECTED_FILES_COUNT_${PACKAGING_TYPE}}")
+
+if(PACKAGING_TYPE STREQUAL "COMPONENT")
+ set(EXPECTED_FILE_1 "deb_description-0.1.1-*-satu.deb")
+ set(EXPECTED_FILE_2 "deb_description-0.1.1-*-dua.deb")
+ set(EXPECTED_FILE_CONTENT_1_LIST "/satu;/satu/CMakeLists.txt")
+ set(EXPECTED_FILE_CONTENT_2_LIST "/dua;/dua/CMakeLists.txt")
+
+elseif(PACKAGING_TYPE STREQUAL "MONOLITHIC")
+ set(EXPECTED_FILE_CONTENT_1_LIST "/dua;/dua/CMakeLists.txt;/satu;/satu/CMakeLists.txt")
+
+endif()
+
+# kate: indent-width 2;
diff --git a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake
new file mode 100644
index 000000000..bfe205944
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake
@@ -0,0 +1,69 @@
+function(checkPackageDescription FILE EXPECTED_DESCRIPTION)
+ getPackageInfo("${FILE}" "_file_info")
+ string(UUID uuid NAMESPACE 00000000-0000-0000-0000-000000000000 TYPE SHA1)
+ string(REPLACE ";" "${uuid}" _file_info "${_file_info}")
+ string(REPLACE ";" "${uuid}" EXPECTED_DESCRIPTION "${EXPECTED_DESCRIPTION}")
+ string(REPLACE "\n" ";" _file_info "${_file_info}")
+
+ set(_actual_description)
+ set(_parse_description FALSE)
+ foreach(_line IN LISTS _file_info)
+ if(_line MATCHES " Description:.*")
+ set(_parse_description TRUE)
+ list(APPEND _actual_description "${_line}")
+ elseif(_parse_description)
+ if(_line MATCHES " [A-Z][A-Za-z\-]+: .*")
+ set(_parse_description FALSE)
+ else()
+ list(APPEND _actual_description "${_line}")
+ endif()
+ endif()
+ endforeach()
+ list(JOIN _actual_description "\n" _actual_description)
+
+ if(NOT _actual_description STREQUAL EXPECTED_DESCRIPTION)
+ set(_error "---[BEGIN Expected description]---\n${EXPECTED_DESCRIPTION}---[END Expected description]---\n")
+ string(APPEND _error "---[BEGIN Actual description]---\n${_actual_description}---[END Actual description]---\n")
+ string(REPLACE "${uuid}" ";" _error "${_error}")
+ message(FATAL_ERROR "${_error}")
+ endif()
+endfunction()
+
+# ALERT The output of `dpkg -I *.deb` indented by one space
+set(_expected_description [[ Description: This is the summary line
+ This is the Debian package multiline description.
+ .
+ It must be formatted properly! Otherwise, the result `*.deb`
+ package become broken and cant be installed!
+ .
+ It may contains `;` characters (even like this `;;;;`). Example:
+ .
+ - one;
+ - two;
+ - three;
+ .
+ ... and they are properly handled by the automatic description formatter!
+ .
+ See also: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description]])
+
+# ATTENTION The code in `cmCPackGenerator.cxx` to read `CPACK_PACKAGE_DESCRIPTION_FILE`
+# has a BUG: it appends the `\n` character to every line of the
+# input, even if there was no EOL (e.g. at the last line of the file).
+# That is WHY for this sub-test the one more pre-formatted "empty"
+# line required!
+# NOTE For component based installers content of the file gonna read by
+# `CPackDeb` module and the `file(READ...)` command so no the mentioned
+# workaround required!
+if(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_PACKAGE_DESCRIPTION_FILE" AND PACKAGING_TYPE STREQUAL "MONOLITHIC")
+ string(APPEND _expected_description "\n ." )
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_NO_PACKAGE_DESCRIPTION")
+ set(_expected_description [[ Description: This is the summary line]])
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_COMPONENT_COMP_DESCRIPTION")
+ set(_expected_description [[ Description: One line description]])
+endif()
+
+foreach(_file_no RANGE 1 ${EXPECTED_FILES_COUNT})
+ checkPackageDescription("${FOUND_FILE_${_file_no}}" "${_expected_description}")
+endforeach()
+
+# kate: indent-width 2;
diff --git a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/test.cmake b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/test.cmake
new file mode 100644
index 000000000..893eb0113
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/test.cmake
@@ -0,0 +1,55 @@
+install(FILES CMakeLists.txt DESTINATION satu COMPONENT satu)
+install(FILES CMakeLists.txt DESTINATION dua COMPONENT dua)
+
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "This is the summary line")
+set(_description [[This is the Debian package multiline description.
+
+It must be formatted properly! Otherwise, the result `*.deb`
+package become broken and cant be installed!
+
+It may contains `;` characters (even like this `;;;;`). Example:
+
+ - one;
+ - two;
+ - three;
+
+... and they are properly handled by the automatic description formatter!
+
+See also: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description]])
+
+if(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_DEBIAN_PACKAGE_DESCRIPTION")
+ if(PACKAGING_TYPE STREQUAL "COMPONENT")
+ set(CPACK_DEBIAN_SATU_DESCRIPTION "${_description}")
+ set(CPACK_DEBIAN_DUA_DESCRIPTION "${_description}")
+ else()
+ set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${_description}")
+ endif()
+
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_PACKAGE_DESCRIPTION")
+ # NOTE Documented fallback variable
+ if(PACKAGING_TYPE STREQUAL "COMPONENT")
+ set(CPACK_COMPONENT_SATU_DESCRIPTION "${_description}")
+ set(CPACK_COMPONENT_DUA_DESCRIPTION "${_description}")
+ else()
+ set(CPACK_PACKAGE_DESCRIPTION "${_description}")
+ endif()
+
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_COMPONENT_COMP_DESCRIPTION")
+ # NOTE Documented fallback variable without CPACK_PACKAGE_DESCRIPTION_SUMMARY
+ if(PACKAGING_TYPE STREQUAL "COMPONENT")
+ set(CPACK_COMPONENT_SATU_DESCRIPTION "One line description")
+ set(CPACK_COMPONENT_DUA_DESCRIPTION "One line description")
+ else()
+ set(CPACK_PACKAGE_DESCRIPTION "One line description")
+ endif()
+ unset(CPACK_PACKAGE_DESCRIPTION_SUMMARY)
+
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_PACKAGE_DESCRIPTION_FILE")
+ # NOTE Getting the description from the file
+ set(_file "${CMAKE_CURRENT_BINARY_DIR}/description.txt")
+ file(WRITE "${_file}" "${_description}")
+ set(CPACK_PACKAGE_DESCRIPTION_FILE "${_file}")
+
+endif()
+
+# kate: indent-width 2;
diff --git a/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/ExpectedFiles.cmake
new file mode 100644
index 000000000..d1a3a5fb2
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/ExpectedFiles.cmake
@@ -0,0 +1,2 @@
+set(EXPECTED_FILES_COUNT "1")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
diff --git a/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/VerifyResult.cmake
new file mode 100644
index 000000000..771cc1048
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/VerifyResult.cmake
@@ -0,0 +1,11 @@
+function(checkPackageInfo_ TYPE FILE REGEX)
+ getPackageInfo("${FILE}" "FILE_INFO_")
+ if(NOT FILE_INFO_ MATCHES "${REGEX}")
+ message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}' ${EXPECTED_FILE_1_VERSION} ${EXPECTED_FILE_1_REVISION}; file info: '${FILE_INFO_}'")
+ endif()
+endfunction()
+
+set(whitespaces_ "[\t\n\r ]*")
+
+checkPackageInfo_("version" "${FOUND_FILE_1}"
+ ".*Version${whitespaces_}:${whitespaces_}5.0.1-71-g884852e")
diff --git a/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/test.cmake b/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/test.cmake
new file mode 100644
index 000000000..403e60dde
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/DEB_PACKAGE_VERSION_BACK_COMPATIBILITY/test.cmake
@@ -0,0 +1,7 @@
+install(FILES CMakeLists.txt DESTINATION foo COMPONENT test)
+
+set(CPACK_DEBIAN_PACKAGE_VERSION "5.0.1-71-g884852e")
+
+if(PACKAGING_TYPE STREQUAL "COMPONENT")
+ set(CPACK_COMPONENTS_ALL test)
+endif()
diff --git a/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/ExpectedFiles.cmake
new file mode 100644
index 000000000..b6fcc175a
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/ExpectedFiles.cmake
@@ -0,0 +1,6 @@
+if(${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid_.*_var")
+ set(EXPECTED_FILES_COUNT "0")
+else()
+ set(EXPECTED_FILES_COUNT "1")
+ set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
+endif()
diff --git a/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/VerifyResult.cmake
new file mode 100644
index 000000000..16ebcdc5e
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/VerifyResult.cmake
@@ -0,0 +1,39 @@
+if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid_.*_var")
+ if(GENERATOR_TYPE STREQUAL "RPM")
+ function(checkContentPermissions_ FILE REGEX)
+ execute_process(COMMAND ${RPM_EXECUTABLE} -qp --dump ${FILE}
+ WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ OUTPUT_VARIABLE PERMISSIONS_
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if(NOT PERMISSIONS_ MATCHES "${REGEX}")
+ message(FATAL_ERROR "Permissions in '${FILE}'. Permissions: '${PERMISSIONS_}'")
+ endif()
+ endfunction()
+
+ if(${RunCMake_SUBTEST_SUFFIX} MATCHES "CMAKE_var_set")
+ checkContentPermissions_("${FOUND_FILE_1}"
+ "/usr/foo .*740 root root.*")
+ else()
+ checkContentPermissions_("${FOUND_FILE_1}"
+ "/usr/foo .*700 root root.*")
+ endif()
+ else() # DEB
+ function(checkContentPermissions_ FILE REGEX)
+ getPackageContent("${FILE}" PERMISSIONS_)
+
+ if(NOT PERMISSIONS_ MATCHES "${REGEX}")
+ message(FATAL_ERROR "Permissions in '${FILE}'. Permissions: '${PERMISSIONS_}'")
+ endif()
+ endfunction()
+
+ if(${RunCMake_SUBTEST_SUFFIX} MATCHES "CMAKE_var_set")
+ checkContentPermissions_("${FOUND_FILE_1}"
+ "drwxr----- root/root .* ./usr/\ndrwxr----- root/root .* ./usr/foo/\n.*")
+ else()
+ checkContentPermissions_("${FOUND_FILE_1}"
+ "drwx------ root/root .* ./usr/\ndrwx------ root/root .* ./usr/foo/\n.*")
+ endif()
+ endif()
+endif()
diff --git a/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CMAKE_var-stderr.txt b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CMAKE_var-stderr.txt
new file mode 100644
index 000000000..541763a29
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CMAKE_var-stderr.txt
@@ -0,0 +1 @@
+.*CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS value is invalid.*
diff --git a/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CPACK_var-stderr.txt b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CPACK_var-stderr.txt
new file mode 100644
index 000000000..541763a29
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/invalid_CPACK_var-stderr.txt
@@ -0,0 +1 @@
+.*CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS value is invalid.*
diff --git a/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/test.cmake b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/test.cmake
new file mode 100644
index 000000000..afe939074
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/DEFAULT_PERMISSIONS/test.cmake
@@ -0,0 +1,34 @@
+if(${RunCMake_SUBTEST_SUFFIX} MATCHES "CMAKE_var_set" OR
+ ${RunCMake_SUBTEST_SUFFIX} MATCHES "both_set")
+
+ set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
+ OWNER_READ
+ OWNER_WRITE
+ OWNER_EXECUTE
+ GROUP_READ
+ )
+endif()
+
+if(${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid_CMAKE_var")
+ list(APPEND CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS "INVALID")
+endif()
+
+if(${RunCMake_SUBTEST_SUFFIX} MATCHES "CPACK_var_set" OR
+ ${RunCMake_SUBTEST_SUFFIX} MATCHES "both_set")
+
+ set(CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
+ OWNER_READ
+ OWNER_WRITE
+ OWNER_EXECUTE
+ )
+endif()
+
+if(${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid_CPACK_var")
+ list(APPEND CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS "INVALID")
+endif()
+
+install(FILES CMakeLists.txt DESTINATION foo COMPONENT test)
+
+if(PACKAGING_TYPE STREQUAL "COMPONENT")
+ set(CPACK_COMPONENTS_ALL test)
+endif()
diff --git a/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake
index 3b280ba73..be7ba07db 100644
--- a/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/DEPENDENCIES/ExpectedFiles.cmake
@@ -1,14 +1,14 @@
set(EXPECTED_FILES_COUNT "5")
set(EXPECTED_FILE_1_COMPONENT "applications")
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog")
set(EXPECTED_FILE_2_COMPONENT "applications_auto")
-set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/foo_auto;/usr/foo_auto/test_prog")
+set(EXPECTED_FILE_CONTENT_2_LIST "/foo_auto;/foo_auto/test_prog")
set(EXPECTED_FILE_3_COMPONENT "headers")
-set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_3_LIST "/bar;/bar/CMakeLists.txt")
set(EXPECTED_FILE_4_COMPONENT "libs")
-set(EXPECTED_FILE_CONTENT_4_LIST "/usr/bas;/usr/bas/libtest_lib.so")
+set(EXPECTED_FILE_CONTENT_4_LIST "/bas;/bas/libtest_lib.so")
set(EXPECTED_FILE_5_COMPONENT "libs_auto")
-set(EXPECTED_FILE_CONTENT_5_LIST "/usr;/usr/bas_auto;/usr/bas_auto/libtest_lib.so")
+set(EXPECTED_FILE_CONTENT_5_LIST "/bas_auto;/bas_auto/libtest_lib.so")
if(GENERATOR_TYPE STREQUAL "DEB")
set(whitespaces_ "[\t\n\r ]*")
diff --git a/Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake
index 6142eb39a..d1a3a5fb2 100644
--- a/Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/DIST/ExpectedFiles.cmake
@@ -1,2 +1,2 @@
set(EXPECTED_FILES_COUNT "1")
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
diff --git a/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake
index 7375ecc21..1b2eb4877 100644
--- a/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake
+++ b/Tests/RunCMake/CPack/tests/DIST/VerifyResult.cmake
@@ -5,6 +5,11 @@ execute_process(COMMAND ${RPMBUILD_EXECUTABLE} -E %{?dist}
set(whitespaces_ "[\t\n\r ]*")
+# since we have no control over dist tag value we should try to escape
+# the content for use as a regular expression
+string(REPLACE "+" "\\+" DIST_TAG "${DIST_TAG}")
+string(REPLACE "." "\\." DIST_TAG "${DIST_TAG}")
+
getPackageInfo("${FOUND_FILE_1}" "FILE_INFO_")
if(NOT FILE_INFO_ MATCHES ".*Release${whitespaces_}:${whitespaces_}1${DIST_TAG}")
message(FATAL_ERROR "Unexpected Release in '${FOUND_FILE_1}'; file info: '${FILE_INFO_}'")
diff --git a/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake
index 650687ce0..8df683115 100644
--- a/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/EMPTY_DIR/ExpectedFiles.cmake
@@ -1,6 +1,6 @@
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE)
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/empty")
+set(EXPECTED_FILE_CONTENT_1_LIST "/empty")
if(PACKAGING_TYPE STREQUAL "COMPONENT")
set(EXPECTED_FILE_1_COMPONENT "test")
diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EXTERNAL/ExpectedFiles.cmake
new file mode 100644
index 000000000..91608c9fe
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/EXTERNAL/ExpectedFiles.cmake
@@ -0,0 +1,7 @@
+if(RunCMake_SUBTEST_SUFFIX MATCHES "^(none|good(_multi)?|invalid_good)$"
+ OR RunCMake_SUBTEST_SUFFIX STREQUAL "stage_and_package")
+ set(EXPECTED_FILES_COUNT "1")
+ set(EXPECTED_FILE_CONTENT_1_LIST "/share;/share/cpack-test;/share/cpack-test/f1.txt;/share/cpack-test/f2.txt;/share/cpack-test/f3.txt;/share/cpack-test/f4.txt")
+else()
+ set(EXPECTED_FILES_COUNT "0")
+endif()
diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/EXTERNAL/VerifyResult.cmake
new file mode 100644
index 000000000..bc19d7efb
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/EXTERNAL/VerifyResult.cmake
@@ -0,0 +1,3 @@
+if(RunCMake_SUBTEST_SUFFIX MATCHES "^(none|good(_multi)?|invalid_good)")
+ check_ext_json("${src_dir}/tests/EXTERNAL/expected-json-1.0.txt" "${FOUND_FILE_1}")
+endif()
diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/bad_major-stderr.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/bad_major-stderr.txt
new file mode 100644
index 000000000..f2e160e20
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/EXTERNAL/bad_major-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*/Modules/Internal/CPack/CPackExternal\.cmake:[0-9]+ \(message\):
+ Could not find a suitable version in CPACK_EXTERNAL_REQUESTED_VERSIONS
+
+
+CPack Error: Error while executing CPackExternal\.cmake
+CPack Error: Cannot initialize the generator External
diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/bad_minor-stderr.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/bad_minor-stderr.txt
new file mode 100644
index 000000000..f2e160e20
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/EXTERNAL/bad_minor-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*/Modules/Internal/CPack/CPackExternal\.cmake:[0-9]+ \(message\):
+ Could not find a suitable version in CPACK_EXTERNAL_REQUESTED_VERSIONS
+
+
+CPack Error: Error while executing CPackExternal\.cmake
+CPack Error: Cannot initialize the generator External
diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake b/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake
new file mode 100644
index 000000000..6f7c4c224
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake
@@ -0,0 +1,31 @@
+message("This script could run an external packaging tool")
+
+get_property(role GLOBAL PROPERTY CMAKE_ROLE)
+if(NOT role STREQUAL "CPACK")
+ message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"CPACK\"")
+endif()
+
+function(expect_variable VAR)
+ if(NOT ${VAR})
+ message(FATAL_ERROR "${VAR} is unexpectedly not set")
+ endif()
+endfunction()
+
+function(expect_file FILE)
+ if(NOT EXISTS "${FILE}")
+ message(FATAL_ERROR "${FILE} is unexpectedly missing")
+ endif()
+endfunction()
+
+expect_variable(CPACK_COMPONENTS_ALL)
+expect_variable(CPACK_TOPLEVEL_DIRECTORY)
+expect_variable(CPACK_TEMPORARY_DIRECTORY)
+expect_variable(CPACK_PACKAGE_DIRECTORY)
+expect_variable(CPACK_PACKAGE_FILE_NAME)
+
+expect_file(${CPACK_TEMPORARY_DIRECTORY}/f1/share/cpack-test/f1.txt)
+expect_file(${CPACK_TEMPORARY_DIRECTORY}/f2/share/cpack-test/f2.txt)
+expect_file(${CPACK_TEMPORARY_DIRECTORY}/f3/share/cpack-test/f3.txt)
+expect_file(${CPACK_TEMPORARY_DIRECTORY}/f4/share/cpack-test/f4.txt)
+
+message(STATUS "This status message is expected to be visible")
diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/expected-json-1.0.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/expected-json-1.0.txt
new file mode 100644
index 000000000..18bf61784
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/EXTERNAL/expected-json-1.0.txt
@@ -0,0 +1,176 @@
+^\{
+ "componentGroups" :[ ]
+ \{
+ "f12" :[ ]
+ \{
+ "components" :[ ]
+ \[
+ "f1",
+ "f2"
+ \],
+ "description" : "Component group for files 1 and 2",
+ "displayName" : "Files 1 and 2",
+ "isBold" : false,
+ "isExpandedByDefault" : false,
+ "name" : "f12",
+ "parentGroup" : "f1234",
+ "subgroups" : \[\]
+ \},
+ "f1234" :[ ]
+ \{
+ "components" : \[\],
+ "description" : "Component group for all files",
+ "displayName" : "Files 1-4",
+ "isBold" : false,
+ "isExpandedByDefault" : false,
+ "name" : "f1234",
+ "subgroups" :[ ]
+ \[
+ "f12",
+ "f34"
+ \]
+ \},
+ "f34" :[ ]
+ \{
+ "components" :[ ]
+ \[
+ "f3",
+ "f4"
+ \],
+ "description" : "Component group for files 3 and 4",
+ "displayName" : "Files 3 and 4",
+ "isBold" : false,
+ "isExpandedByDefault" : false,
+ "name" : "f34",
+ "parentGroup" : "f1234",
+ "subgroups" : \[\]
+ \}
+ \},
+ "components" :[ ]
+ \{
+ "f1" :[ ]
+ \{
+ "archiveFile" : "",
+ "dependencies" : \[\],
+ "description" : "Component for file 1",
+ "displayName" : "File 1",
+ "group" : "f12",
+ "installationTypes" :[ ]
+ \[
+ "full",
+ "f12"
+ \],
+ "isDisabledByDefault" : false,
+ "isDownloaded" : false,
+ "isHidden" : false,
+ "isRequired" : false,
+ "name" : "f1"
+ \},
+ "f2" :[ ]
+ \{
+ "archiveFile" : "",
+ "dependencies" :[ ]
+ \[
+ "f1"
+ \],
+ "description" : "Component for file 2",
+ "displayName" : "File 2",
+ "group" : "f12",
+ "installationTypes" :[ ]
+ \[
+ "full",
+ "f12"
+ \],
+ "isDisabledByDefault" : false,
+ "isDownloaded" : false,
+ "isHidden" : false,
+ "isRequired" : false,
+ "name" : "f2"
+ \},
+ "f3" :[ ]
+ \{
+ "archiveFile" : "",
+ "dependencies" :[ ]
+ \[
+ "f1",
+ "f2"
+ \],
+ "description" : "Component for file 3",
+ "displayName" : "File 3",
+ "group" : "f34",
+ "installationTypes" :[ ]
+ \[
+ "full"
+ \],
+ "isDisabledByDefault" : false,
+ "isDownloaded" : false,
+ "isHidden" : false,
+ "isRequired" : false,
+ "name" : "f3"
+ \},
+ "f4" :[ ]
+ \{
+ "archiveFile" : "",
+ "dependencies" :[ ]
+ \[
+ "f2",
+ "f3",
+ "f1"
+ \],
+ "description" : "Component for file 4",
+ "displayName" : "File 4",
+ "group" : "f34",
+ "installationTypes" :[ ]
+ \[
+ "full"
+ \],
+ "isDisabledByDefault" : false,
+ "isDownloaded" : false,
+ "isHidden" : false,
+ "isRequired" : false,
+ "name" : "f4"
+ \}
+ \},
+ "errorOnAbsoluteInstallDestination" : false,
+ "formatVersionMajor" : 1,
+ "formatVersionMinor" : 0,
+ "installationTypes" :[ ]
+ \{
+ "f12" :[ ]
+ \{
+ "displayName" : "Only files 1 and 2",
+ "index" : 2,
+ "name" : "f12"
+ \},
+ "full" :[ ]
+ \{
+ "displayName" : "Full installation",
+ "index" : 1,
+ "name" : "full"
+ \}
+ \},
+ "packageDescriptionFile" : ".*/Templates/CPack\.GenericDescription\.txt",
+ "packageDescriptionSummary" : "EXTERNAL-(none|good(_multi)?|invalid_good)-subtest-(MONOLITHIC|COMPONENT)-type built using CMake",
+ "packageName" : "external",
+ "packageVersion" : "0\.1\.1",
+ "projects" :[ ]
+ \[
+ \{
+ "component" : "ALL",
+ "components" :[ ]
+ \[
+ "f1",
+ "f2",
+ "f3",
+ "f4"
+ \],
+ "directory" : ".*/Tests/RunCMake/External/CPack/EXTERNAL-build-(none|good(_multi)?|invalid_good)-subtest",
+ "installationTypes" : \[\],
+ "projectName" : "EXTERNAL-(none|good(_multi)?|invalid_good)-subtest-(MONOLITHIC|COMPONENT)-type",
+ "subDirectory" : "/"
+ \}
+ \],
+ "setDestdir" : false,
+ "stripFiles" : false,
+ "warnOnAbsoluteInstallDestination" : false
+\}$
diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/invalid_bad-stderr.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/invalid_bad-stderr.txt
new file mode 100644
index 000000000..f2e160e20
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/EXTERNAL/invalid_bad-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*/Modules/Internal/CPack/CPackExternal\.cmake:[0-9]+ \(message\):
+ Could not find a suitable version in CPACK_EXTERNAL_REQUESTED_VERSIONS
+
+
+CPack Error: Error while executing CPackExternal\.cmake
+CPack Error: Cannot initialize the generator External
diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stderr.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stderr.txt
new file mode 100644
index 000000000..40f2743e2
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stderr.txt
@@ -0,0 +1 @@
+^This script could run an external packaging tool$
diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stdout.txt b/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stdout.txt
new file mode 100644
index 000000000..37d635fa4
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/EXTERNAL/stage_and_package-stdout.txt
@@ -0,0 +1 @@
+-- This status message is expected to be visible
diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/test.cmake b/Tests/RunCMake/CPack/tests/EXTERNAL/test.cmake
new file mode 100644
index 000000000..bc9766b15
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/EXTERNAL/test.cmake
@@ -0,0 +1,86 @@
+include(CPackComponent)
+
+if(RunCMake_SUBTEST_SUFFIX STREQUAL "none")
+ unset(CPACK_EXTERNAL_REQUESTED_VERSIONS)
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "good")
+ set(CPACK_EXTERNAL_REQUESTED_VERSIONS "1.0")
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "good_multi")
+ set(CPACK_EXTERNAL_REQUESTED_VERSIONS "1.0;2.0")
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "bad_major")
+ set(CPACK_EXTERNAL_REQUESTED_VERSIONS "2.0")
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "bad_minor")
+ set(CPACK_EXTERNAL_REQUESTED_VERSIONS "1.1")
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid_good")
+ set(CPACK_EXTERNAL_REQUESTED_VERSIONS "1;1.0")
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "invalid_bad")
+ set(CPACK_EXTERNAL_REQUESTED_VERSIONS "1")
+elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "stage_and_package")
+ set(CPACK_EXTERNAL_ENABLE_STAGING 1)
+ set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/create_package.cmake")
+endif()
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f1.txt" test1)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f2.txt" test2)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f3.txt" test3)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/f4.txt" test4)
+
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f1.txt" DESTINATION share/cpack-test COMPONENT f1)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f2.txt" DESTINATION share/cpack-test COMPONENT f2)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f3.txt" DESTINATION share/cpack-test COMPONENT f3)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/f4.txt" DESTINATION share/cpack-test COMPONENT f4)
+
+cpack_add_component(f1
+ DISPLAY_NAME "File 1"
+ DESCRIPTION "Component for file 1"
+ GROUP f12
+ INSTALL_TYPES full f12
+)
+
+cpack_add_component(f2
+ DISPLAY_NAME "File 2"
+ DESCRIPTION "Component for file 2"
+ GROUP f12
+ DEPENDS f1
+ INSTALL_TYPES full f12
+)
+
+cpack_add_component(f3
+ DISPLAY_NAME "File 3"
+ DESCRIPTION "Component for file 3"
+ GROUP f34
+ DEPENDS f1 f2
+ INSTALL_TYPES full
+)
+
+cpack_add_component(f4
+ DISPLAY_NAME "File 4"
+ DESCRIPTION "Component for file 4"
+ GROUP f34
+ DEPENDS f2 f3 f1
+ INSTALL_TYPES full
+)
+
+cpack_add_component_group(f12
+ DISPLAY_NAME "Files 1 and 2"
+ DESCRIPTION "Component group for files 1 and 2"
+ PARENT_GROUP f1234
+)
+
+cpack_add_component_group(f34
+ DISPLAY_NAME "Files 3 and 4"
+ DESCRIPTION "Component group for files 3 and 4"
+ PARENT_GROUP f1234
+)
+
+cpack_add_component_group(f1234
+ DISPLAY_NAME "Files 1-4"
+ DESCRIPTION "Component group for all files"
+)
+
+cpack_add_install_type(full
+ DISPLAY_NAME "Full installation"
+)
+
+cpack_add_install_type(f12
+ DISPLAY_NAME "Only files 1 and 2"
+)
diff --git a/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake
index ded2923e2..407cbe630 100644
--- a/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/EXTRA/ExpectedFiles.cmake
@@ -1,8 +1,8 @@
set(EXPECTED_FILES_COUNT "3")
set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE)
set(EXPECTED_FILE_1_COMPONENT "foo")
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
set(EXPECTED_FILE_2_COMPONENT "bar")
-set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt")
set(EXPECTED_FILE_3_COMPONENT "bas")
-set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/CMakeLists.txt")
diff --git a/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/ExpectedFiles.cmake
index a45b38ddd..3fb05346c 100644
--- a/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/ExpectedFiles.cmake
@@ -2,6 +2,7 @@ set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "5")
set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE)
+set(EXPECTED_FILE_PACKAGING_PREFIX "")
set(EXPECTED_FILE_1_COMPONENT "applications")
set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog")
@@ -11,6 +12,6 @@ set(EXPECTED_FILE_3 "extra_slash_in_path*-libs.rpm")
set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/libtest_lib.so")
set(EXPECTED_FILE_4_COMPONENT "applications-debuginfo")
-set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*")
+set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*\.debug.*")
set(EXPECTED_FILE_5_COMPONENT "libs-debuginfo")
-set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*")
+set(EXPECTED_FILE_CONTENT_5 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/test_lib.cpp.*\.debug.*")
diff --git a/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/test.cmake b/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/test.cmake
index 4fd1e810a..7cee1888e 100644
--- a/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/test.cmake
+++ b/Tests/RunCMake/CPack/tests/EXTRA_SLASH_IN_PATH/test.cmake
@@ -8,6 +8,10 @@ endif()
set(CMAKE_BUILD_TYPE Debug)
+# for rpm packages execute flag must be set for shared libs if debuginfo
+# packages are generated
+set(CPACK_RPM_INSTALL_WITH_EXEC TRUE)
+
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp"
"int test_lib();\n")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp"
diff --git a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/VerifyResult.cmake
index b1952efd1..8cefeea5f 100644
--- a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/VerifyResult.cmake
+++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/VerifyResult.cmake
@@ -1,4 +1,9 @@
-set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs \\(\\= 0\\.1\\.1\\)\n$")
+if(RunCMake_SUBTEST_SUFFIX STREQUAL "soversion_not_zero")
+ set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs \\(\\= 0\\.1\\.1\\)\n$")
+else() # soversion_zero
+ set(shlibs_shlibs "^libtest_lib 0 generate_shlibs \\(\\= 0\\.1\\.1\\)\n$")
+endif()
+
# optional dot at the end of permissions regex is for SELinux enabled systems
set(shlibs_shlibs_permissions_regex "-rw-r--r--\.? .*")
verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs")
diff --git a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/test.cmake b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/test.cmake
index 90351ba43..e0eb67b84 100644
--- a/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/test.cmake
+++ b/Tests/RunCMake/CPack/tests/GENERATE_SHLIBS/test.cmake
@@ -9,6 +9,11 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp"
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp"
"#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n")
add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp")
-set_target_properties(test_lib PROPERTIES SOVERSION "0.8")
+
+if(RunCMake_SUBTEST_SUFFIX STREQUAL "soversion_not_zero")
+ set_target_properties(test_lib PROPERTIES SOVERSION "0.8")
+else() # soversion_zero
+ set_target_properties(test_lib PROPERTIES SOVERSION "0")
+endif()
install(TARGETS test_lib DESTINATION foo COMPONENT libs)
diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake
index 44346ab8d..de38df9ef 100644
--- a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake
@@ -1,5 +1,5 @@
set(EXPECTED_FILES_COUNT "2")
set(EXPECTED_FILE_1_COMPONENT "foo")
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
set(EXPECTED_FILE_2_COMPONENT "bar")
-set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt")
diff --git a/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake
index 631d95704..4cb8dd0eb 100644
--- a/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/ExpectedFiles.cmake
@@ -1,3 +1,3 @@
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE)
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/llllllllll_oooooooooo_nnnnnnnnnn_gggggggggg_ffffffffff_iiiiiiiiii_llllllllll_eeeeeeeeee_nnnnnnnnnn_aaaaaaaaaa_mmmmmmmmmm_eeeeeeeeee.txt")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/llllllllll_oooooooooo_nnnnnnnnnn_gggggggggg_ffffffffff_iiiiiiiiii_llllllllll_eeeeeeeeee_nnnnnnnnnn_aaaaaaaaaa_mmmmmmmmmm_eeeeeeeeee.txt")
diff --git a/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake
index 6bfb0c19f..629be9ea5 100644
--- a/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/MAIN_COMPONENT/ExpectedFiles.cmake
@@ -3,9 +3,9 @@ set(EXPECTED_FILES_COUNT "0")
if(NOT RunCMake_SUBTEST_SUFFIX STREQUAL "invalid")
set(EXPECTED_FILES_COUNT "3")
set(EXPECTED_FILE_1 "main_component-0.1.1-1.*.rpm")
- set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+ set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
set(EXPECTED_FILE_2_COMPONENT "headers")
- set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt")
+ set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt")
set(EXPECTED_FILE_3_COMPONENT "libs")
- set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/CMakeLists.txt")
+ set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/CMakeLists.txt")
endif()
diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake
index 6142eb39a..d1a3a5fb2 100644
--- a/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake
@@ -1,2 +1,2 @@
set(EXPECTED_FILES_COUNT "1")
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
diff --git a/Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake
index 6142eb39a..d1a3a5fb2 100644
--- a/Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/MINIMAL/ExpectedFiles.cmake
@@ -1,2 +1,2 @@
set(EXPECTED_FILES_COUNT "1")
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
diff --git a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake
index eed5b92b0..c375aca9d 100644
--- a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/ExpectedFiles.cmake
@@ -2,5 +2,5 @@ set(EXPECTED_FILES_COUNT "0")
if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid")
set(EXPECTED_FILES_COUNT "1")
- set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+ set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
endif()
diff --git a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake
index e4f9618d3..2bb4d3ff9 100644
--- a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake
+++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake
@@ -1,8 +1,7 @@
if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid")
- string(TOLOWER ${RunCMake_SUBTEST_SUFFIX} EXTENSION)
+ string(TOLOWER ${RunCMake_SUBTEST_SUFFIX} CHECKSUM_EXTENSION)
file(GLOB PACKAGE RELATIVE ${bin_dir} "*.tar.gz")
- file(GLOB CSUMFILE RELATIVE ${bin_dir} "*.${EXTENSION}")
- file(STRINGS ${CSUMFILE} CHSUM_VALUE)
+ file(STRINGS ${PACKAGE}.${CHECKSUM_EXTENSION} CHSUM_VALUE)
file(${RunCMake_SUBTEST_SUFFIX} ${PACKAGE} expected_value )
set(expected_value "${expected_value} ${PACKAGE}")
diff --git a/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake
index ae58c4b0c..137da470e 100644
--- a/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/PARTIALLY_RELOCATABLE_WARNING/ExpectedFiles.cmake
@@ -1,2 +1,4 @@
set(EXPECTED_FILES_COUNT "1")
+# don't set the prefix here as we have absolute paths that should not be prefixed
+set(EXPECTED_FILE_PACKAGING_PREFIX "")
set(EXPECTED_FILE_CONTENT_1_LIST "/not_relocatable;/not_relocatable/CMakeLists.txt;/opt")
diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake
index 9bdb176dd..26fa1df92 100644
--- a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/ExpectedFiles.cmake
@@ -1,8 +1,8 @@
set(EXPECTED_FILES_COUNT "3")
set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE)
set(EXPECTED_FILE_1_COMPONENT "pkg_1")
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
set(EXPECTED_FILE_2_NAME "second")
-set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_2_LIST "/foo;/foo/CMakeLists.txt")
set(EXPECTED_FILE_3_COMPONENT "pkg_3")
-set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_3_LIST "/foo;/foo/CMakeLists.txt")
diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake
index 18ef63cd8..b4bdb61b6 100644
--- a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake
+++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake
@@ -1,7 +1,7 @@
function(checkPackageInfo_ TYPE FILE REGEX)
getPackageInfo("${FILE}" "FILE_INFO_")
if(NOT FILE_INFO_ MATCHES "${REGEX}")
- message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'")
+ message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'; does not match '${REGEX}'")
endif()
endfunction()
@@ -24,3 +24,15 @@ checkPackageInfo_("name" "${FOUND_FILE_3}" ".*${name_}${whitespaces_}:${whitespa
checkPackageInfo_("group" "${FOUND_FILE_1}" ".*${group_}${whitespaces_}:${whitespaces_}default")
checkPackageInfo_("group" "${FOUND_FILE_2}" ".*${group_}${whitespaces_}:${whitespaces_}second_group")
checkPackageInfo_("group" "${FOUND_FILE_3}" ".*${group_}${whitespaces_}:${whitespaces_}default")
+
+# check package summaries (not available in DEB)
+if(GENERATOR_TYPE STREQUAL "RPM")
+ checkPackageInfo_("summary" "${FOUND_FILE_1}" ".*Summary${whitespaces_}:${whitespaces_}Global summary")
+ checkPackageInfo_("summary" "${FOUND_FILE_2}" ".*Summary${whitespaces_}:${whitespaces_}Summary for pkg_2")
+ checkPackageInfo_("summary" "${FOUND_FILE_3}" ".*Summary${whitespaces_}:${whitespaces_}Global summary")
+endif()
+
+# check package description
+checkPackageInfo_("description" "${FOUND_FILE_1}" ".*Description${whitespaces_}:${whitespaces_}Description for pkg_1")
+checkPackageInfo_("description" "${FOUND_FILE_2}" ".*Description${whitespaces_}:${whitespaces_}Description for pkg_2")
+checkPackageInfo_("description" "${FOUND_FILE_3}" ".*Description${whitespaces_}:${whitespaces_}Description for pkg_3")
diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake
index 8719c0b5e..dc61d0abb 100644
--- a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake
+++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/test.cmake
@@ -11,6 +11,13 @@ if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM")
set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PACKAGE_${group_} "default")
set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_NAME "second")
set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_${group_} "second_group")
+
+ set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PACKAGE_SUMMARY "Global summary") # not used for DEB
+ set(CPACK_${GENERATOR_TYPE}${generator_type_suffix_}_PKG_2_PACKAGE_SUMMARY "Summary for pkg_2") # not used for DEB
+
+ set(CPACK_COMPONENT_PKG_1_DESCRIPTION "Description for pkg_1")
+ set(CPACK_COMPONENT_PKG_2_DESCRIPTION "Description for pkg_2")
+ set(CPACK_COMPONENT_PKG_3_DESCRIPTION "Description for pkg_3")
endif()
install(FILES CMakeLists.txt DESTINATION foo COMPONENT pkg_1)
diff --git a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake
index ca866eaa8..936e4ed80 100644
--- a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake
@@ -5,26 +5,26 @@ set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE)
if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo")
set(EXPECTED_FILES_COUNT "4")
set(EXPECTED_FILE_1 "single_debuginfo-0.1.1-1.*.rpm")
- set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog")
+ set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog")
set(EXPECTED_FILE_2 "single_debuginfo*-headers.rpm")
- set(EXPECTED_FILE_CONTENT_2_LIST "/usr;/usr/bar;/usr/bar/CMakeLists.txt")
+ set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt")
set(EXPECTED_FILE_3 "single_debuginfo*-libs.rpm")
- set(EXPECTED_FILE_CONTENT_3_LIST "/usr;/usr/bas;/usr/bas/libtest_lib.so")
+ set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/libtest_lib.so")
set(EXPECTED_FILE_4_COMPONENT "debuginfo")
- set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp${whitespaces_}/src/src_1/test_lib.cpp.*")
+ set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp${whitespaces_}/src/src_1/test_lib.cpp.*\.debug.*")
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component" OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_no_debuginfo")
set(EXPECTED_FILES_COUNT "2")
set(EXPECTED_FILE_1 "single_debuginfo-0*-applications.rpm")
- set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog")
+ set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog")
set(EXPECTED_FILE_2 "single_debuginfo-applications-debuginfo*.rpm")
- set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*")
+ set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*\.debug.*")
elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_main" OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_components")
set(EXPECTED_FILES_COUNT "2")
set(EXPECTED_FILE_1 "single_debuginfo-0*.rpm")
- set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/test_prog")
+ set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/test_prog")
set(EXPECTED_FILE_2 "single_debuginfo-debuginfo*.rpm")
- set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*")
+ set(EXPECTED_FILE_CONTENT_2 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp.*\.debug.*")
endif()
diff --git a/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake
index 0a3e42635..d78f222a3 100644
--- a/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/ExpectedFiles.cmake
@@ -1,2 +1,3 @@
set(EXPECTED_FILES_COUNT "1")
+set(EXPECTED_FILE_PACKAGING_PREFIX "")
set(EXPECTED_FILE_CONTENT_1_LIST "source_package-0.1.1.tar.gz;source_package.spec")
diff --git a/Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake
index 6142eb39a..d1a3a5fb2 100644
--- a/Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/SUGGESTS/ExpectedFiles.cmake
@@ -1,2 +1,2 @@
set(EXPECTED_FILES_COUNT "1")
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr;/usr/foo;/usr/foo/CMakeLists.txt")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
diff --git a/Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt b/Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt
index feb296cae..53d71d91f 100644
--- a/Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt
+++ b/Tests/RunCMake/CPack/tests/SUGGESTS/RPM-stderr.txt
@@ -1 +1 @@
-^(.*CPackRPM:Warning: SUGGESTS not supported in provided rpmbuild.*)?CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM/CPack/[^-]*-build/_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec$
+^(.*CPackRPM:Warning: SUGGESTS not supported in provided rpmbuild.*)?CPackRPM: Will use GENERATED spec file: (/[^/]*)*/Tests/RunCMake/RPM\.SUGGESTS/CPack/[^-]*-build/_CPack_Packages/.*/RPM/SPECS/[^\.]*\.spec$
diff --git a/Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake
index 32cc6d1af..61ce752fe 100644
--- a/Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake
+++ b/Tests/RunCMake/CPack/tests/SUGGESTS/VerifyResult.cmake
@@ -13,7 +13,7 @@ if(NOT RPMBUILD_CAPS_RESULT)
endif()
# Only verify that suggests tag is present only if that tag is supported.
-# If it is not supported the rpm package was corretly generated by ignoring
+# If it is not supported the rpm package was correctly generated by ignoring
# that tag and that was already checked by expected files test.
if(should_contain_suggests_tag_)
execute_process(COMMAND ${RPM_EXECUTABLE} -q --suggests -p "${FOUND_FILE_1}"
diff --git a/Tests/RunCMake/CPack/tests/SYMLINKS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SYMLINKS/ExpectedFiles.cmake
index 05be748c1..e8281a8d3 100644
--- a/Tests/RunCMake/CPack/tests/SYMLINKS/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/SYMLINKS/ExpectedFiles.cmake
@@ -1,12 +1,11 @@
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_CONTENT_1_LIST
- "/usr"
- "/usr/empty_dir"
- "/usr/non_empty_dir"
- "/usr/non_empty_dir/CMakeLists.txt"
- "/usr/symlink_to_empty_dir"
- "/usr/symlink_to_non_empty_dir")
+ "/empty_dir"
+ "/non_empty_dir"
+ "/non_empty_dir/CMakeLists.txt"
+ "/symlink_to_empty_dir"
+ "/symlink_to_non_empty_dir")
if(PACKAGING_TYPE STREQUAL "COMPONENT")
set(EXPECTED_FILE_1_COMPONENT "links")
diff --git a/Tests/RunCMake/CPack/tests/TIMESTAMPS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/TIMESTAMPS/ExpectedFiles.cmake
new file mode 100644
index 000000000..d1a3a5fb2
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/TIMESTAMPS/ExpectedFiles.cmake
@@ -0,0 +1,2 @@
+set(EXPECTED_FILES_COUNT "1")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
diff --git a/Tests/RunCMake/CPack/tests/TIMESTAMPS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/TIMESTAMPS/VerifyResult.cmake
new file mode 100644
index 000000000..e7e2645aa
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/TIMESTAMPS/VerifyResult.cmake
@@ -0,0 +1,58 @@
+macro(getFileMetadata_ FILE RESULT_VAR)
+ if(GENERATOR_TYPE STREQUAL "TGZ")
+ # getPackageContent defined for archives omit the metadata (non-verbose)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E env TZ=Etc/UTC ${CMAKE_COMMAND} -E tar -xtvf ${FILE}
+ OUTPUT_VARIABLE ${RESULT_VAR}
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ else()
+ getPackageContent("${FILE}" ${RESULT_VAR})
+ endif()
+endmacro()
+
+function(checkContentTimestamp FILE REGEX)
+ getFileMetadata_("${FILE}" METADATA_)
+
+ if(NOT METADATA_ MATCHES "${REGEX}")
+ string(REPLACE "\n" "\n " metadata_indented "${METADATA_}")
+ message(FATAL_ERROR
+ "Wrong timestamps in file:\n"
+ " ${FILE}\n"
+ "Expected timestamps to match:\n"
+ " ${REGEX}\n"
+ "Actual timestamps:\n"
+ " ${metadata_indented}")
+ endif()
+endfunction()
+
+function(checkTimestamp FILE_NAME)
+ file(READ ${FILE_NAME} ACTUAL_TIMESTAMP OFFSET 4 LIMIT 4 HEX)
+
+ if(NOT ACTUAL_TIMESTAMP STREQUAL "00000000")
+ message(FATAL_ERROR "${FILE_NAME} contains a timestamp [0x${ACTUAL_TIMESTAMP}]")
+ endif()
+endfunction()
+
+# Expected timestamp is UNIX time 123456789
+if(GENERATOR_TYPE STREQUAL "TGZ")
+ set(EXPECTED_TIMESTAMP "29 Nov +1973")
+ set(EXPECTED_FILES foo/ foo/CMakeLists.txt)
+else()
+ set(EXPECTED_TIMESTAMP "1973-11-29 21:33")
+ set(EXPECTED_FILES ./usr/ ./usr/foo/ ./usr/foo/CMakeLists.txt)
+endif()
+
+set(EXPECTED_METADATA)
+foreach(FILE ${EXPECTED_FILES})
+ list(APPEND EXPECTED_METADATA ".* ${EXPECTED_TIMESTAMP} ${FILE}")
+endforeach()
+list(JOIN EXPECTED_METADATA ".*" EXPECTED_REGEX)
+checkContentTimestamp("${FOUND_FILE_1}" "${EXPECTED_REGEX}")
+
+if(GENERATOR_TYPE STREQUAL "TGZ")
+ checkTimestamp("${FOUND_FILE_1}")
+else()
+ execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${FOUND_FILE_1}")
+ checkTimestamp("data.tar.gz")
+ checkTimestamp("control.tar.gz")
+endif()
diff --git a/Tests/RunCMake/CPack/tests/TIMESTAMPS/test.cmake b/Tests/RunCMake/CPack/tests/TIMESTAMPS/test.cmake
new file mode 100644
index 000000000..a19385214
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/TIMESTAMPS/test.cmake
@@ -0,0 +1,3 @@
+install(FILES CMakeLists.txt DESTINATION foo COMPONENT test)
+
+set(CPACK_COMPONENTS_ALL test)
diff --git a/Tests/RunCMake/CPack/tests/USER_FILELIST/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/USER_FILELIST/ExpectedFiles.cmake
index aabe53761..8420986f2 100644
--- a/Tests/RunCMake/CPack/tests/USER_FILELIST/ExpectedFiles.cmake
+++ b/Tests/RunCMake/CPack/tests/USER_FILELIST/ExpectedFiles.cmake
@@ -1,2 +1,2 @@
set(EXPECTED_FILES_COUNT "1")
-set(EXPECTED_FILE_CONTENT_1_LIST "/usr/one;/usr/one/foo.txt;/usr/one/two;/usr/one/two/bar.txt;/usr/three;/usr/three/baz.txt;/usr/three/qux.txt")
+set(EXPECTED_FILE_CONTENT_1_LIST "/one;/one/foo.txt;/one/two;/one/two/bar.txt;/three;/three/baz.txt;/three/qux.txt")
diff --git a/Tests/RunCMake/CPack/tests/VERSION/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/VERSION/ExpectedFiles.cmake
new file mode 100644
index 000000000..372f71bad
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/VERSION/ExpectedFiles.cmake
@@ -0,0 +1,3 @@
+set(EXPECTED_FILES_COUNT "1")
+set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt")
+set(EXPECTED_FILE_1_REVISION "1")
diff --git a/Tests/RunCMake/CPack/tests/VERSION/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/VERSION/VerifyResult.cmake
new file mode 100644
index 000000000..eed9696cd
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/VERSION/VerifyResult.cmake
@@ -0,0 +1,17 @@
+function(checkPackageInfo_ TYPE FILE REGEX)
+ getPackageInfo("${FILE}" "FILE_INFO_")
+ if(NOT FILE_INFO_ MATCHES "${REGEX}")
+ message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}' ${EXPECTED_FILE_1_VERSION} ${EXPECTED_FILE_1_REVISION}; file info: '${FILE_INFO_}'")
+ endif()
+endfunction()
+
+set(whitespaces_ "[\t\n\r ]*")
+
+if(GENERATOR_TYPE STREQUAL "RPM")
+ checkPackageInfo_("package version" "${FOUND_FILE_1}" "Version${whitespaces_}:${whitespaces_}${EXPECTED_FILE_1_VERSION}")
+ checkPackageInfo_("package revision" "${FOUND_FILE_1}" "Release${whitespaces_}:${whitespaces_}${EXPECTED_FILE_1_REVISION}")
+ checkPackageInfo_("epoch version" "${FOUND_FILE_1}" "Epoch${whitespaces_}:${whitespaces_}3")
+else() # DEB
+ checkPackageInfo_("version" "${FOUND_FILE_1}"
+ ".*Version${whitespaces_}:${whitespaces_}3:${EXPECTED_FILE_1_VERSION}-${EXPECTED_FILE_1_REVISION}")
+endif()
diff --git a/Tests/RunCMake/CPack/tests/VERSION/test.cmake b/Tests/RunCMake/CPack/tests/VERSION/test.cmake
new file mode 100644
index 000000000..301ab6126
--- /dev/null
+++ b/Tests/RunCMake/CPack/tests/VERSION/test.cmake
@@ -0,0 +1,14 @@
+install(FILES CMakeLists.txt DESTINATION foo COMPONENT test)
+
+if(GENERATOR_TYPE STREQUAL "DEB")
+ set(package_type_ "DEBIAN")
+ set(CPACK_DEBIAN_PACKAGE_RELEASE "1")
+else()
+ set(package_type_ "${GENERATOR_TYPE}")
+endif()
+
+set(CPACK_${package_type_}_PACKAGE_EPOCH "3")
+
+if(PACKAGING_TYPE STREQUAL "COMPONENT")
+ set(CPACK_COMPONENTS_ALL test)
+endif()
diff --git a/Tests/RunCMake/CPackCommandLine/CMakeLists.txt b/Tests/RunCMake/CPackCommandLine/CMakeLists.txt
new file mode 100644
index 000000000..2632ffa91
--- /dev/null
+++ b/Tests/RunCMake/CPackCommandLine/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.16)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CPackCommandLine/MultiConfig-check-stdout.txt b/Tests/RunCMake/CPackCommandLine/MultiConfig-check-stdout.txt
new file mode 100644
index 000000000..f2ae844da
--- /dev/null
+++ b/Tests/RunCMake/CPackCommandLine/MultiConfig-check-stdout.txt
@@ -0,0 +1,4 @@
+MultiConfig-0\.1\.1-[^/
+]*/lib/(lib|)foo_dbg\.(a|lib)
+MultiConfig-0\.1\.1-[^/
+]*/lib/(lib|)foo_rel\.(a|lib)
diff --git a/Tests/RunCMake/CPackCommandLine/MultiConfig-package-stdout.txt b/Tests/RunCMake/CPackCommandLine/MultiConfig-package-stdout.txt
new file mode 100644
index 000000000..4fb8181de
--- /dev/null
+++ b/Tests/RunCMake/CPackCommandLine/MultiConfig-package-stdout.txt
@@ -0,0 +1,8 @@
+^CPack: Create package using ZIP
+CPack: Install projects
+CPack: - Install project: MultiConfig \[Debug\]
+CPack: - Install project: MultiConfig \[Release\]
+CPack: Create package
+CPack: - package: [^
+]*/Tests/RunCMake/CPackCommandLine/MultiConfig-build/MultiConfig-0.1.1-[^
+]*.zip generated.$
diff --git a/Tests/RunCMake/CPackCommandLine/MultiConfig.cmake b/Tests/RunCMake/CPackCommandLine/MultiConfig.cmake
new file mode 100644
index 000000000..71fd189ff
--- /dev/null
+++ b/Tests/RunCMake/CPackCommandLine/MultiConfig.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+include(CPack)
+
+add_library(foo foo.c)
+set_property(TARGET foo PROPERTY DEBUG_POSTFIX _dbg)
+set_property(TARGET foo PROPERTY RELEASE_POSTFIX _rel)
+
+install(TARGETS foo)
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no----result.txt b/Tests/RunCMake/CPackCommandLine/NotAGenerator-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no----result.txt
+++ b/Tests/RunCMake/CPackCommandLine/NotAGenerator-result.txt
diff --git a/Tests/RunCMake/CPackCommandLine/NotAGenerator-stderr.txt b/Tests/RunCMake/CPackCommandLine/NotAGenerator-stderr.txt
new file mode 100644
index 000000000..a553bde5b
--- /dev/null
+++ b/Tests/RunCMake/CPackCommandLine/NotAGenerator-stderr.txt
@@ -0,0 +1 @@
+^CPack Error: Could not create CPack generator: NotAGenerator
diff --git a/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake
new file mode 100644
index 000000000..53f4e4f93
--- /dev/null
+++ b/Tests/RunCMake/CPackCommandLine/RunCMakeTest.cmake
@@ -0,0 +1,33 @@
+include(RunCMake)
+set(RunCMake_TEST_TIMEOUT 60)
+
+file(WRITE "${RunCMake_BINARY_DIR}/NotAGenerator-build/CPackConfig.cmake" [[
+set(CPACK_PACKAGE_NAME "Test")
+set(CPACK_PACKAGE_VERSION "1")
+]])
+set(RunCMake_TEST_NO_CLEAN 1)
+run_cmake_command(NotAGenerator ${CMAKE_CPACK_COMMAND} -G NotAGenerator)
+unset(RunCMake_TEST_NO_CLEAN)
+
+function(run_MultiConfig)
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/MultiConfig-build")
+ run_cmake(MultiConfig)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(MultiConfig-build-dbg ${CMAKE_COMMAND} --build . --config Debug)
+ run_cmake_command(MultiConfig-build-rel ${CMAKE_COMMAND} --build . --config Release)
+ run_cmake_command(MultiConfig-package ${CMAKE_CPACK_COMMAND} -G ZIP -C "Debug\;Release")
+ set(zip_glob "${RunCMake_TEST_BINARY_DIR}/MultiConfig-0.1.1-*.zip")
+ file(GLOB zips "${zip_glob}")
+ set(zip_found 0)
+ foreach(zip IN LISTS zips)
+ set(zip_found 1)
+ run_cmake_command(MultiConfig-check ${CMAKE_COMMAND} -E tar tf "${zip}")
+ endforeach()
+ if(NOT zip_found)
+ message(SEND_ERROR "No package file found at\n ${zip_glob}")
+ endif()
+endfunction()
+
+if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode")
+ run_MultiConfig()
+endif()
diff --git a/Tests/RunCMake/CPackCommandLine/foo.c b/Tests/RunCMake/CPackCommandLine/foo.c
new file mode 100644
index 000000000..c83d85699
--- /dev/null
+++ b/Tests/RunCMake/CPackCommandLine/foo.c
@@ -0,0 +1,4 @@
+int foo(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake
index 16d2cf39f..8f2196d5b 100644
--- a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake
@@ -4,3 +4,6 @@ run_cmake(Simple)
run_cmake(Default)
run_cmake(Special)
run_cmake(Verbatim)
+run_cmake(Version1)
+run_cmake(Version2)
+run_cmake(Version3)
diff --git a/Tests/RunCMake/CPackConfig/Version1-check.cmake b/Tests/RunCMake/CPackConfig/Version1-check.cmake
new file mode 100644
index 000000000..0f5347f78
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/Version1-check.cmake
@@ -0,0 +1,6 @@
+include(${RunCMake_SOURCE_DIR}/check.cmake)
+
+test_variable(CPACK_PACKAGE_VERSION "0")
+test_variable(CPACK_PACKAGE_VERSION_MAJOR "0")
+test_variable(CPACK_PACKAGE_VERSION_MINOR "")
+test_variable(CPACK_PACKAGE_VERSION_PATCH "")
diff --git a/Tests/RunCMake/CPackConfig/Version1.cmake b/Tests/RunCMake/CPackConfig/Version1.cmake
new file mode 100644
index 000000000..703485c98
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/Version1.cmake
@@ -0,0 +1 @@
+project(Version LANGUAGES NONE VERSION 0)
diff --git a/Tests/RunCMake/CPackConfig/Version2-check.cmake b/Tests/RunCMake/CPackConfig/Version2-check.cmake
new file mode 100644
index 000000000..3a2d572df
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/Version2-check.cmake
@@ -0,0 +1,6 @@
+include(${RunCMake_SOURCE_DIR}/check.cmake)
+
+test_variable(CPACK_PACKAGE_VERSION "1.0")
+test_variable(CPACK_PACKAGE_VERSION_MAJOR "1")
+test_variable(CPACK_PACKAGE_VERSION_MINOR "0")
+test_variable(CPACK_PACKAGE_VERSION_PATCH "")
diff --git a/Tests/RunCMake/CPackConfig/Version2.cmake b/Tests/RunCMake/CPackConfig/Version2.cmake
new file mode 100644
index 000000000..c084137b4
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/Version2.cmake
@@ -0,0 +1 @@
+project(Version LANGUAGES NONE VERSION 1.0)
diff --git a/Tests/RunCMake/CPackConfig/Version3-check.cmake b/Tests/RunCMake/CPackConfig/Version3-check.cmake
new file mode 100644
index 000000000..d4a3983dd
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/Version3-check.cmake
@@ -0,0 +1,6 @@
+include(${RunCMake_SOURCE_DIR}/check.cmake)
+
+test_variable(CPACK_PACKAGE_VERSION "1.1.0")
+test_variable(CPACK_PACKAGE_VERSION_MAJOR "1")
+test_variable(CPACK_PACKAGE_VERSION_MINOR "1")
+test_variable(CPACK_PACKAGE_VERSION_PATCH "0")
diff --git a/Tests/RunCMake/CPackConfig/Version3.cmake b/Tests/RunCMake/CPackConfig/Version3.cmake
new file mode 100644
index 000000000..4df28bbe1
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/Version3.cmake
@@ -0,0 +1 @@
+project(Version LANGUAGES NONE VERSION 1.1.0)
diff --git a/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake b/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake
index 1a373b928..8fc1218f2 100644
--- a/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake
+++ b/Tests/RunCMake/CPackInstallProperties/FilenameGenex.cmake
@@ -1,6 +1,6 @@
add_executable(mytest test.cpp)
-file(GENERATE OUTPUT runtest_info.cmake CONTENT [[
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtest_info.cmake CONTENT [[
set(EXPECTED_MYTEST_NAME "$<TARGET_FILE_NAME:mytest>")
]])
diff --git a/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake b/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake
index 77fe8ed5d..b23d3c7df 100644
--- a/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake
+++ b/Tests/RunCMake/CPackInstallProperties/PerConfigValue.cmake
@@ -6,7 +6,7 @@ foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES)
OUTPUT_NAME_${UPPER_CONFIG} bar_${CONFIG})
endforeach()
-file(GENERATE OUTPUT runtest_info_$<CONFIG>.cmake CONTENT [[
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtest_info_$<CONFIG>.cmake CONTENT [[
set(CPACK_BUILD_CONFIG "$<CONFIG>")
set(EXPECTED_MYTEST_NAME "$<TARGET_FILE_NAME:mytest>")
]])
diff --git a/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake b/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake
index 2e1d4656c..2001d9f4c 100644
--- a/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake
+++ b/Tests/RunCMake/CPackInstallProperties/ValueGenex.cmake
@@ -1,6 +1,6 @@
add_executable(mytest test.cpp)
-file(GENERATE OUTPUT runtest_info.cmake CONTENT [[
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/runtest_info.cmake CONTENT [[
set(EXPECTED_MYTEST_NAME "$<TARGET_FILE_NAME:mytest>")
]])
diff --git a/Tests/RunCMake/CSharpCustomCommand/CMakeLists.txt b/Tests/RunCMake/CSharpCustomCommand/CMakeLists.txt
new file mode 100644
index 000000000..74b3ff8de
--- /dev/null
+++ b/Tests/RunCMake/CSharpCustomCommand/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.3)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput-check.cmake b/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput-check.cmake
new file mode 100644
index 000000000..60d77eb60
--- /dev/null
+++ b/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput-check.cmake
@@ -0,0 +1,21 @@
+if(checkLevel EQUAL 0)
+ message("checking generation (${srcName} does not exist)")
+ if(EXISTS "${generatedFileName}")
+ set(RunCMake_TEST_FAILED "file \"${generatedFileName}\" should not exist")
+ endif()
+elseif(checkLevel EQUAL 1)
+ message("checking build 1 (generate ${srcName})")
+ if(NOT "${actual_stdout}" MATCHES "${commandComment}")
+ set(RunCMake_TEST_FAILED "command not executed")
+ endif()
+elseif(checkLevel EQUAL 2)
+ message("checking build 2 (no change in ${srcName}.in)")
+ if("${actual_stdout}" MATCHES "${commandComment}")
+ set(RunCMake_TEST_FAILED "command executed")
+ endif()
+elseif(checkLevel EQUAL 3)
+ message("checking build 3 (update ${srcName})")
+ if(NOT "${actual_stdout}" MATCHES "${commandComment}")
+ set(RunCMake_TEST_FAILED "command not executed")
+ endif()
+endif()
diff --git a/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput.cmake b/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput.cmake
new file mode 100644
index 000000000..68341fa88
--- /dev/null
+++ b/Tests/RunCMake/CSharpCustomCommand/CommandWithOutput.cmake
@@ -0,0 +1,13 @@
+enable_language(CSharp)
+
+add_executable(CSharpCustomCommand dummy.cs)
+
+add_custom_command(OUTPUT ${generatedFileName}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${inputFileName} ${generatedFileName}
+ MAIN_DEPENDENCY ${inputFileName}
+ COMMENT "${commandComment}")
+
+target_sources(CSharpCustomCommand PRIVATE
+ ${inputFileName}
+ ${generatedFileName})
diff --git a/Tests/RunCMake/CSharpCustomCommand/RunCMakeTest.cmake b/Tests/RunCMake/CSharpCustomCommand/RunCMakeTest.cmake
new file mode 100644
index 000000000..ab3e51b59
--- /dev/null
+++ b/Tests/RunCMake/CSharpCustomCommand/RunCMakeTest.cmake
@@ -0,0 +1,42 @@
+include(RunCMake)
+
+function(run_TargetWithCommand)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TargetWithCommand-build)
+ run_cmake(TargetWithCommand)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(TargetWithCommand-build ${CMAKE_COMMAND} --build . --config Debug)
+endfunction()
+run_TargetWithCommand()
+
+# Use a single build tree for a few tests without cleaning.
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CommandWithOutput-build)
+set(RunCMake_TEST_NO_CLEAN 1)
+file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+set(RunCMake-check-file CommandWithOutput-check.cmake)
+
+set(srcName "test.cs")
+set(srcFileName "${CMAKE_CURRENT_LIST_DIR}/${srcName}.in")
+set(inputFileName "${RunCMake_TEST_BINARY_DIR}/${srcName}.in")
+set(generatedFileName "${RunCMake_TEST_BINARY_DIR}/${srcName}")
+set(commandComment "Generating ${srcName}")
+
+# copy the input file to build dir to avoid changing files in cmake
+# source tree.
+file(COPY "${srcFileName}" DESTINATION "${RunCMake_TEST_BINARY_DIR}")
+
+set(RunCMake_TEST_OPTIONS ${RunCMake_TEST_OPTIONS}
+ "-DinputFileName=${inputFileName}"
+ "-DgeneratedFileName=${generatedFileName}"
+ "-DcommandComment=${commandComment}")
+
+set(checkLevel 0)
+run_cmake(CommandWithOutput)
+set(checkLevel 1)
+run_cmake_command(CommandWithOutput-build1 ${CMAKE_COMMAND} --build . --config Debug)
+set(checkLevel 2)
+run_cmake_command(CommandWithOutput-build2 ${CMAKE_COMMAND} --build . --config Debug)
+# change file content to trigger custom command with next build
+file(APPEND ${inputFileName} "\n")
+set(checkLevel 3)
+run_cmake_command(CommandWithOutput-build3 ${CMAKE_COMMAND} --build . --config Debug)
diff --git a/Tests/RunCMake/CSharpCustomCommand/TargetWithCommand-build-stdout.txt b/Tests/RunCMake/CSharpCustomCommand/TargetWithCommand-build-stdout.txt
new file mode 100644
index 000000000..c212a8fe4
--- /dev/null
+++ b/Tests/RunCMake/CSharpCustomCommand/TargetWithCommand-build-stdout.txt
@@ -0,0 +1 @@
+Custom target with CSharp source
diff --git a/Tests/RunCMake/CSharpCustomCommand/TargetWithCommand.cmake b/Tests/RunCMake/CSharpCustomCommand/TargetWithCommand.cmake
new file mode 100644
index 000000000..fdaea5cb2
--- /dev/null
+++ b/Tests/RunCMake/CSharpCustomCommand/TargetWithCommand.cmake
@@ -0,0 +1,4 @@
+enable_language(CSharp)
+
+add_custom_target(drive ALL SOURCES dummy.cs
+ COMMAND ${CMAKE_COMMAND} -E echo "Custom target with CSharp source")
diff --git a/Tests/RunCMake/CSharpCustomCommand/dummy.cs b/Tests/RunCMake/CSharpCustomCommand/dummy.cs
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CSharpCustomCommand/dummy.cs
diff --git a/Tests/RunCMake/CSharpCustomCommand/test.cs.in b/Tests/RunCMake/CSharpCustomCommand/test.cs.in
new file mode 100644
index 000000000..05a7531e0
--- /dev/null
+++ b/Tests/RunCMake/CSharpCustomCommand/test.cs.in
@@ -0,0 +1,8 @@
+class TestCs
+{
+ public static int Main(string[] args)
+ {
+ System.Console.WriteLine("Test C#");
+ return 0;
+ }
+}
diff --git a/Tests/RunCMake/CSharpReferenceImport/CMakeLists.txt b/Tests/RunCMake/CSharpReferenceImport/CMakeLists.txt
new file mode 100644
index 000000000..74b3ff8de
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.3)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CSharpReferenceImport/ImportLib.cmake b/Tests/RunCMake/CSharpReferenceImport/ImportLib.cmake
new file mode 100644
index 000000000..5ad6e76c7
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ImportLib.cmake
@@ -0,0 +1,45 @@
+enable_language(CXX CSharp)
+
+if(NOT DEFINED exportFileName OR
+ NOT DEFINED exportNameSpace OR
+ NOT DEFINED exportTargetName)
+ message(FATAL_ERROR "export information missing")
+endif()
+
+add_library(${exportTargetName}CSharp SHARED
+ ImportLib.cs)
+
+# native c++ dll
+add_library(${exportTargetName}Native SHARED
+ ImportLibNative.h
+ ImportLibNative.cxx)
+
+# mixed c++ dll
+add_library(${exportTargetName}Mixed SHARED
+ ImportLibMixed.cxx
+ ImportLibMixedNative.h
+ ImportLibMixedNative.cxx)
+set_target_properties(${exportTargetName}Mixed PROPERTIES
+ COMMON_LANGUAGE_RUNTIME "")
+
+# pure c++ dll
+add_library(${exportTargetName}Pure SHARED
+ ImportLibPure.cxx)
+set_target_properties(${exportTargetName}Pure PROPERTIES
+ COMMON_LANGUAGE_RUNTIME "pure")
+
+# safe c++ dll
+add_library(${exportTargetName}Safe SHARED
+ ImportLibSafe.cxx)
+set_target_properties(${exportTargetName}Safe PROPERTIES
+ COMMON_LANGUAGE_RUNTIME "safe")
+
+# generate export file
+export(TARGETS
+ ${exportTargetName}CSharp
+ ${exportTargetName}Native
+ ${exportTargetName}Mixed
+ ${exportTargetName}Pure
+ ${exportTargetName}Safe
+ NAMESPACE "${exportNameSpace}:"
+ FILE "${exportFileName}")
diff --git a/Tests/RunCMake/CSharpReferenceImport/ImportLib.cs b/Tests/RunCMake/CSharpReferenceImport/ImportLib.cs
new file mode 100644
index 000000000..4eb28afac
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ImportLib.cs
@@ -0,0 +1,8 @@
+using System;
+
+public
+class ImportLibCSharp
+{
+public
+ static void Message() { Console.WriteLine("ImportLibCSharp"); }
+}
diff --git a/Tests/RunCMake/CSharpReferenceImport/ImportLibMixed.cxx b/Tests/RunCMake/CSharpReferenceImport/ImportLibMixed.cxx
new file mode 100644
index 000000000..d0b810ef8
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ImportLibMixed.cxx
@@ -0,0 +1,8 @@
+using namespace System;
+
+public
+ref class ImportLibMixed
+{
+public:
+ static void Message() { Console::WriteLine("ImportLibMixed"); }
+};
diff --git a/Tests/RunCMake/CSharpReferenceImport/ImportLibMixedNative.cxx b/Tests/RunCMake/CSharpReferenceImport/ImportLibMixedNative.cxx
new file mode 100644
index 000000000..c85a77631
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ImportLibMixedNative.cxx
@@ -0,0 +1,8 @@
+#include "ImportLibMixedNative.h"
+
+#include <iostream>
+
+void ImportLibMixedNative::Message()
+{
+ std::cout << "ImportLibMixedNative" << std::endl;
+}
diff --git a/Tests/RunCMake/CSharpReferenceImport/ImportLibMixedNative.h b/Tests/RunCMake/CSharpReferenceImport/ImportLibMixedNative.h
new file mode 100644
index 000000000..76b97c475
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ImportLibMixedNative.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#ifdef ImportLibMixed_EXPORTS
+# define mixedAPI __declspec(dllexport)
+#else
+# define mixedAPI __declspec(dllimport)
+#endif
+
+class mixedAPI ImportLibMixedNative
+{
+public:
+ static void Message();
+};
diff --git a/Tests/RunCMake/CSharpReferenceImport/ImportLibNative.cxx b/Tests/RunCMake/CSharpReferenceImport/ImportLibNative.cxx
new file mode 100644
index 000000000..8e08b9a0f
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ImportLibNative.cxx
@@ -0,0 +1,8 @@
+#include "ImportLibNative.h"
+
+#include <iostream>
+
+void ImportLibNative::Message()
+{
+ std::cout << "ImportLibNative" << std::endl;
+}
diff --git a/Tests/RunCMake/CSharpReferenceImport/ImportLibNative.h b/Tests/RunCMake/CSharpReferenceImport/ImportLibNative.h
new file mode 100644
index 000000000..77bcb8222
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ImportLibNative.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#ifdef ImportLibNative_EXPORTS
+# define nativeAPI __declspec(dllexport)
+#else
+# define nativeAPI __declspec(dllimport)
+#endif
+
+class nativeAPI ImportLibNative
+{
+public:
+ static void Message();
+};
diff --git a/Tests/RunCMake/CSharpReferenceImport/ImportLibPure.cxx b/Tests/RunCMake/CSharpReferenceImport/ImportLibPure.cxx
new file mode 100644
index 000000000..271e37572
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ImportLibPure.cxx
@@ -0,0 +1,8 @@
+using namespace System;
+
+public
+ref class ImportLibPure
+{
+public:
+ static void Message() { Console::WriteLine("ImportLibPure"); }
+};
diff --git a/Tests/RunCMake/CSharpReferenceImport/ImportLibSafe.cxx b/Tests/RunCMake/CSharpReferenceImport/ImportLibSafe.cxx
new file mode 100644
index 000000000..13b40da26
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ImportLibSafe.cxx
@@ -0,0 +1,8 @@
+using namespace System;
+
+public
+ref class ImportLibSafe
+{
+public:
+ static void Message() { Console::WriteLine("ImportLibSafe"); }
+};
diff --git a/Tests/RunCMake/CSharpReferenceImport/ReferenceImport.cmake b/Tests/RunCMake/CSharpReferenceImport/ReferenceImport.cmake
new file mode 100644
index 000000000..c65f623a0
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ReferenceImport.cmake
@@ -0,0 +1,88 @@
+enable_language(CXX CSharp)
+
+if(NOT DEFINED exportFileName OR
+ NOT DEFINED exportNameSpace OR
+ NOT DEFINED exportTargetName)
+ message(FATAL_ERROR "export information missing")
+endif()
+
+# Include generated export file.
+if(NOT EXISTS "${exportFileName}")
+ message(FATAL_ERROR "exportFileNameCSharp does not exist: ${exportFileName}")
+endif()
+include(${exportFileName})
+
+# Verify expected targets are imported
+set(linkNames linkNameCSharp linkNameNative linkNameMixed
+ linkNamePure linkNameSafe)
+set(linkNameCSharp "${exportNameSpace}:${exportTargetName}CSharp")
+set(linkNameNative "${exportNameSpace}:${exportTargetName}Native")
+set(linkNameMixed "${exportNameSpace}:${exportTargetName}Mixed")
+set(linkNamePure "${exportNameSpace}:${exportTargetName}Pure")
+set(linkNameSafe "${exportNameSpace}:${exportTargetName}Safe")
+foreach(l ${linkNames})
+ if(NOT TARGET ${${l}})
+ message(FATAL_ERROR "imported target not found (${${l}})")
+ endif()
+endforeach()
+
+# Test referencing managed assemblies from C# executable.
+add_executable(ReferenceImportCSharp ReferenceImport.cs)
+target_link_libraries(ReferenceImportCSharp
+ ${linkNameCSharp}
+ ${linkNameNative} # ignored
+ ${linkNameMixed}
+ ${linkNamePure}
+ ${linkNameSafe}
+ )
+
+# native C++ executable.
+add_executable(ReferenceImportNative ReferenceImportNative.cxx)
+target_link_libraries(ReferenceImportNative
+ ${linkNameCSharp} # ignored
+ ${linkNameNative}
+ ${linkNameMixed}
+ ${linkNamePure} # ignored
+ ${linkNameSafe} # ignored
+ )
+add_custom_command(TARGET ReferenceImportNative POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ "$<TARGET_FILE:${linkNameNative}>"
+ "${CMAKE_BINARY_DIR}/$<CONFIG>"
+ )
+
+# mixed C++ executable.
+add_executable(ReferenceImportMixed ReferenceImportMixed.cxx)
+target_link_libraries(ReferenceImportMixed
+ ${linkNameCSharp}
+ ${linkNameNative}
+ ${linkNameMixed}
+ ${linkNamePure}
+ ${linkNameSafe}
+ )
+set_target_properties(ReferenceImportMixed PROPERTIES
+ COMMON_LANGUAGE_RUNTIME "")
+
+# pure C++ executable.
+add_executable(ReferenceImportPure ReferenceImportPure.cxx)
+target_link_libraries(ReferenceImportPure
+ ${linkNameCSharp}
+ ${linkNameNative} # ignored
+ ${linkNameMixed}
+ ${linkNamePure}
+ ${linkNameSafe}
+ )
+set_target_properties(ReferenceImportPure PROPERTIES
+ COMMON_LANGUAGE_RUNTIME "pure")
+
+# native C++ executable.
+add_executable(ReferenceImportSafe ReferenceImportSafe.cxx)
+target_link_libraries(ReferenceImportSafe
+ ${linkNameCSharp}
+ ${linkNameNative} # ignored
+ ${linkNameMixed}
+ ${linkNamePure}
+ ${linkNameSafe}
+ )
+set_target_properties(ReferenceImportSafe PROPERTIES
+ COMMON_LANGUAGE_RUNTIME "safe")
diff --git a/Tests/RunCMake/CSharpReferenceImport/ReferenceImport.cs b/Tests/RunCMake/CSharpReferenceImport/ReferenceImport.cs
new file mode 100644
index 000000000..24175f6d7
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ReferenceImport.cs
@@ -0,0 +1,13 @@
+using System;
+
+public class ReferenceImport
+{
+ public static void Main()
+ {
+ Console.WriteLine("ReferenceImportCSharp");
+ ImportLibMixed.Message();
+ ImportLibPure.Message();
+ ImportLibSafe.Message();
+ ImportLibCSharp.Message();
+ }
+}
diff --git a/Tests/RunCMake/CSharpReferenceImport/ReferenceImportMixed.cxx b/Tests/RunCMake/CSharpReferenceImport/ReferenceImportMixed.cxx
new file mode 100644
index 000000000..53ecd422e
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ReferenceImportMixed.cxx
@@ -0,0 +1,20 @@
+// clang-format off
+
+using namespace System;
+
+#using <ImportLibMixed.dll>
+#using <ImportLibPure.dll>
+#using <ImportLibSafe.dll>
+#using <ImportLibCSharp.dll>
+
+#include "ImportLibNative.h"
+
+int main()
+{
+ Console::WriteLine("ReferenceImportMixed");
+ ImportLibNative::Message();
+ ImportLibMixed::Message();
+ ImportLibPure::Message();
+ ImportLibSafe::Message();
+ ImportLibCSharp::Message();
+};
diff --git a/Tests/RunCMake/CSharpReferenceImport/ReferenceImportNative.cxx b/Tests/RunCMake/CSharpReferenceImport/ReferenceImportNative.cxx
new file mode 100644
index 000000000..831a2c4a1
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ReferenceImportNative.cxx
@@ -0,0 +1,13 @@
+// clang-format off
+
+#include "ImportLibNative.h"
+#include "ImportLibMixedNative.h"
+
+#include <iostream>
+
+int main()
+{
+ std::cout << "ReferenceImportNative" << std::endl;
+ ImportLibNative::Message();
+ ImportLibMixedNative::Message();
+};
diff --git a/Tests/RunCMake/CSharpReferenceImport/ReferenceImportPure.cxx b/Tests/RunCMake/CSharpReferenceImport/ReferenceImportPure.cxx
new file mode 100644
index 000000000..2c5dd66dd
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ReferenceImportPure.cxx
@@ -0,0 +1,17 @@
+// clang-format off
+
+using namespace System;
+
+#using <ImportLibMixed.dll>
+#using <ImportLibPure.dll>
+#using <ImportLibSafe.dll>
+#using <ImportLibCSharp.dll>
+
+int main()
+{
+ Console::WriteLine("ReferenceImportPure");
+ ImportLibMixed::Message();
+ ImportLibPure::Message();
+ ImportLibSafe::Message();
+ ImportLibCSharp::Message();
+};
diff --git a/Tests/RunCMake/CSharpReferenceImport/ReferenceImportSafe.cxx b/Tests/RunCMake/CSharpReferenceImport/ReferenceImportSafe.cxx
new file mode 100644
index 000000000..277c96f20
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/ReferenceImportSafe.cxx
@@ -0,0 +1,17 @@
+// clang-format off
+
+using namespace System;
+
+#using <ImportLibMixed.dll>
+#using <ImportLibPure.dll>
+#using <ImportLibSafe.dll>
+#using <ImportLibCSharp.dll>
+
+int main()
+{
+ Console::WriteLine("ReferenceImportSafe");
+ ImportLibMixed::Message();
+ ImportLibPure::Message();
+ ImportLibSafe::Message();
+ ImportLibCSharp::Message();
+};
diff --git a/Tests/RunCMake/CSharpReferenceImport/RunCMakeTest.cmake b/Tests/RunCMake/CSharpReferenceImport/RunCMakeTest.cmake
new file mode 100644
index 000000000..c44e59e0a
--- /dev/null
+++ b/Tests/RunCMake/CSharpReferenceImport/RunCMakeTest.cmake
@@ -0,0 +1,41 @@
+include(RunCMake)
+
+set(RunCMake_TEST_NO_CLEAN 1)
+
+set(exportFileName "${RunCMake_BINARY_DIR}/module.cmake")
+set(exportNameSpace "ex")
+set(exportTargetName "ImportLib")
+
+set(RunCMake_TEST_OPTIONS_BASE ${RunCMake_TEST_OPTIONS}
+ "-DexportNameSpace:INTERNAL=${exportNameSpace}"
+ "-DexportTargetName:INTERNAL=${exportTargetName}")
+
+file(REMOVE "${exportFileName}")
+
+# generate C# & C++ assemblies for use as imported target
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ImportLib-build)
+file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+set(RunCMake_TEST_OPTIONS ${RunCMake_TEST_OPTIONS_BASE}
+ "-DexportFileName:INTERNAL=${exportFileName}"
+ # make sure we know the RunCMake_TEST if configuring the project again
+ # with cmake-gui for debugging.
+ "-DRunCMake_TEST:INTERNAL=ImportLib")
+
+run_cmake(ImportLib)
+run_cmake_command(ImportLib-build ${CMAKE_COMMAND} --build . --config Debug)
+
+# generate C# & managed C++ programs which reference imported managed assemblies.
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ReferenceImport-build)
+file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+set(RunCMake_TEST_OPTIONS ${RunCMake_TEST_OPTIONS_BASE}
+ "-DexportFileName:INTERNAL=${exportFileName}"
+ # make sure we know the RunCMake_TEST if configuring the project again
+ # with cmake-gui for debugging.
+ "-DRunCMake_TEST:INTERNAL=ReferenceImport")
+
+run_cmake(ReferenceImport)
+run_cmake_command(ReferenceImport-build ${CMAKE_COMMAND} --build . --config Debug)
diff --git a/Tests/RunCMake/CTest/CTestTestfile.cmake.in b/Tests/RunCMake/CTest/CTestTestfile.cmake.in
new file mode 100644
index 000000000..07632445c
--- /dev/null
+++ b/Tests/RunCMake/CTest/CTestTestfile.cmake.in
@@ -0,0 +1 @@
+# Created manually
diff --git a/Tests/RunCMake/CTest/NotOn-check.cmake b/Tests/RunCMake/CTest/NotOn-check.cmake
new file mode 100644
index 000000000..b68218af0
--- /dev/null
+++ b/Tests/RunCMake/CTest/NotOn-check.cmake
@@ -0,0 +1,8 @@
+set(f "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake")
+if(NOT EXISTS "${f}")
+ set(RunCMake_TEST_FAILED "File does not exist:\n ${f}")
+endif()
+file(READ ${f} content)
+if(NOT "${content}" MATCHES "^# Created manually")
+ set(RunCMake_TEST_FAILED "File:\n ${f}\nhas unexpected content:\n ${content}")
+endif()
diff --git a/Tests/RunCMake/CTest/NotOn.cmake b/Tests/RunCMake/CTest/NotOn.cmake
new file mode 100644
index 000000000..7fba019b6
--- /dev/null
+++ b/Tests/RunCMake/CTest/NotOn.cmake
@@ -0,0 +1,3 @@
+set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.")
+include(CTest)
+configure_file(CTestTestfile.cmake.in CTestTestfile.cmake)
diff --git a/Tests/RunCMake/CTest/RunCMakeTest.cmake b/Tests/RunCMake/CTest/RunCMakeTest.cmake
index a6f684224..13922401e 100644
--- a/Tests/RunCMake/CTest/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTest/RunCMakeTest.cmake
@@ -3,3 +3,5 @@ include(RunCMake)
set(RunCMake_TEST_OPTIONS -DNoProject=1)
run_cmake(BeforeProject)
unset(RunCMake_TEST_OPTIONS)
+
+run_cmake(NotOn)
diff --git a/Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt b/Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt
new file mode 100644
index 000000000..3e470a29c
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.14)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt.in b/Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt.in
new file mode 100644
index 000000000..7d56c903b
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt.in
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.14)
+project(@CASE_NAME@ NONE)
+include("@RunCMake_SOURCE_DIR@/@CASE_NAME@.cmake")
diff --git a/Tests/RunCMake/CTestCommandExpandLists/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandExpandLists/RunCMakeTest.cmake
new file mode 100644
index 000000000..7c3779e15
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandExpandLists/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCTest)
+
+run_ctest(expandGeneratorExpressionResult)
+run_ctest(expandEmptyCommand)
+run_cmake(multipleExpandOptions)
diff --git a/Tests/RunCMake/CTestCommandExpandLists/compare_options.cmake b/Tests/RunCMake/CTestCommandExpandLists/compare_options.cmake
new file mode 100644
index 000000000..a32e579e2
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandExpandLists/compare_options.cmake
@@ -0,0 +1,14 @@
+set(range 1 2 3 4 5 6 7 8 9 10)
+set(aargs "")
+set(bargs "")
+foreach(n IN LISTS range)
+ set(aval "${A${n}ARG}")
+ set(bval "${B${n}ARG}")
+ if(aval OR bval)
+ list(APPEND aargs "\"${aval}\"")
+ list(APPEND bargs "\"${bval}\"")
+ endif()
+endforeach()
+if(NOT "${aargs}" STREQUAL "${bargs}")
+ message(FATAL_ERROR "COMPARE_OPTIONS: \n\t${aargs} != \n\t${bargs}")
+endif()
diff --git a/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-result.txt b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_memcheck/DummyAddressLeakSanitizer-result.txt
+++ b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-result.txt
diff --git a/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stderr.txt b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stderr.txt
new file mode 100644
index 000000000..c656b4c7f
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stderr.txt
@@ -0,0 +1 @@
+Unable to find executable:
diff --git a/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stdout.txt b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stdout.txt
new file mode 100644
index 000000000..075258010
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stdout.txt
@@ -0,0 +1,13 @@
+Test project .*/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-build
+.* +Start 1: CommandExpandEmptyList
+Could not find executable +
+Looked in the following places:
+.*
+1/1 Test #1: CommandExpandEmptyList +\.+\*\*\*Not Run +[0-9.]+ sec
++
+0% tests passed, 1 tests failed out of 1
++
+Total Test time \(real\) = +[0-9.]+ sec
++
+The following tests FAILED:
+.* +1 - CommandExpandEmptyList \(Not Run\)$
diff --git a/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand.cmake b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand.cmake
new file mode 100644
index 000000000..b75828e38
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand.cmake
@@ -0,0 +1,10 @@
+include(CTest)
+
+set(argv /bin/true)
+list(POP_BACK argv)
+
+add_test(
+ NAME CommandExpandEmptyList
+ COMMAND "$<JOIN:${argv},;>"
+ COMMAND_EXPAND_LISTS
+)
diff --git a/Tests/RunCMake/CMP0038/CMP0038-OLD-result.txt b/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-result.txt
index 573541ac9..573541ac9 100644
--- a/Tests/RunCMake/CMP0038/CMP0038-OLD-result.txt
+++ b/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-result.txt
diff --git a/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-stdout.txt b/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-stdout.txt
new file mode 100644
index 000000000..2f2159295
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-stdout.txt
@@ -0,0 +1,7 @@
+Test project .*/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-build
+.* +Start 1: CommandExpandList
+1/1 Test #1: CommandExpandList +\.+ +Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 1
++
+Total Test time \(real\) = +[0-9.]+ sec
diff --git a/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult.cmake b/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult.cmake
new file mode 100644
index 000000000..20608ae17
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult.cmake
@@ -0,0 +1,19 @@
+include(CTest)
+
+
+set(cmp_args "1ARG=COMMAND_EXPAND_LISTS" "2ARG=test" "3ARG=outfile"
+ "4ARG=content")
+set(AARGS "")
+foreach(arg IN LISTS cmp_args)
+ list(APPEND AARGS "-DA${arg}")
+endforeach()
+
+
+
+add_test(
+ NAME CommandExpandList
+ COMMAND ${CMAKE_COMMAND} ${AARGS} -V
+ "-DB$<JOIN:${cmp_args},;-DB>"
+ "-P" "${CMAKE_CURRENT_LIST_DIR}/compare_options.cmake"
+ COMMAND_EXPAND_LISTS
+)
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-result.txt b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-result.txt
+++ b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-result.txt
diff --git a/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stderr.txt b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stderr.txt
new file mode 100644
index 000000000..e48513fa7
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error at multipleExpandOptions\.cmake:3 \(add_test\):
+ +add_test may be given at most one COMMAND_EXPAND_LISTS\.
diff --git a/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stdout.txt b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stdout.txt
new file mode 100644
index 000000000..55bb89445
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stdout.txt
@@ -0,0 +1,2 @@
+-- Configuring incomplete, errors occurred!
+See also ".*/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-build/CMakeFiles/CMakeOutput\.log".
diff --git a/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions.cmake b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions.cmake
new file mode 100644
index 000000000..dcf2dc434
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions.cmake
@@ -0,0 +1,8 @@
+include(CTest)
+
+add_test(
+ NAME MultipleExpandOptions
+ COMMAND /bin/true
+ COMMAND_EXPAND_LISTS
+ COMMAND_EXPAND_LISTS
+)
diff --git a/Tests/RunCMake/CTestCommandExpandLists/test.cmake.in b/Tests/RunCMake/CTestCommandExpandLists/test.cmake.in
new file mode 100644
index 000000000..d9a8ccb08
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandExpandLists/test.cmake.in
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.14)
+
+set(CTEST_SITE "test-site")
+set(CTEST_BUILD_NAME "test-build-name")
+set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@")
+set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build")
+set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@")
+set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
+
+ctest_start(Experimental)
+ctest_configure()
+ctest_build()
+ctest_test()
diff --git a/Tests/RunCMake/CTestCommandLine/FailRegexFound-check.cmake b/Tests/RunCMake/CTestCommandLine/FailRegexFound-check.cmake
new file mode 100644
index 000000000..1097788ec
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/FailRegexFound-check.cmake
@@ -0,0 +1,13 @@
+set(last_test_log "${RunCMake_TEST_BINARY_DIR}/Testing/Temporary/LastTest.log")
+if(EXISTS "${last_test_log}")
+ file(READ "${last_test_log}" last_test_log_content)
+ string(REGEX REPLACE "\n+$" "" last_test_log_content "${last_test_log_content}")
+ if(NOT last_test_log_content MATCHES "
+Test Pass Reason:
+Error regular expression found in output. Regex=[[]test1]")
+ string(REPLACE "\n" "\n " last_test_log_content " ${last_test_log_content}")
+ set(RunCMake_TEST_FAILED "LastTest.log does not have expected content:\n${last_test_log_content}")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "LastTest.log missing:\n ${last_test_log}")
+endif()
diff --git a/Tests/RunCMake/CTestCommandLine/LabelCount-stdout.txt b/Tests/RunCMake/CTestCommandLine/LabelCount-stdout.txt
index 7fe04eb6a..9cfe41ca3 100644
--- a/Tests/RunCMake/CTestCommandLine/LabelCount-stdout.txt
+++ b/Tests/RunCMake/CTestCommandLine/LabelCount-stdout.txt
@@ -1,7 +1,7 @@
100% tests passed, 0 tests failed out of 4
+
+Label Time Summary:
-+'bar' = +[0-9.]+ sec \(3 tests\)
-+'foo' = +[0-9.]+ sec \(1 test\)
++'bar' = +[0-9.]+ sec\*proc \(3 tests\)
++'foo' = +[0-9.]+ sec\*proc \(1 test\)
+
Total Test time \(real\) = +[0-9.]+ sec
diff --git a/Tests/RunCMake/CTestCommandLine/RequiredRegexFound-check.cmake b/Tests/RunCMake/CTestCommandLine/RequiredRegexFound-check.cmake
new file mode 100644
index 000000000..bde60d12c
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/RequiredRegexFound-check.cmake
@@ -0,0 +1,13 @@
+set(last_test_log "${RunCMake_TEST_BINARY_DIR}/Testing/Temporary/LastTest.log")
+if(EXISTS "${last_test_log}")
+ file(READ "${last_test_log}" last_test_log_content)
+ string(REGEX REPLACE "\n+$" "" last_test_log_content "${last_test_log_content}")
+ if(NOT last_test_log_content MATCHES "
+Test Pass Reason:
+Required regular expression found. Regex=[[]test1]")
+ string(REPLACE "\n" "\n " last_test_log_content " ${last_test_log_content}")
+ set(RunCMake_TEST_FAILED "LastTest.log does not have expected content:\n${last_test_log_content}")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "LastTest.log missing:\n ${last_test_log}")
+endif()
diff --git a/Tests/RunCMake/CTestCommandLine/RequiredRegexNotFound-check.cmake b/Tests/RunCMake/CTestCommandLine/RequiredRegexNotFound-check.cmake
new file mode 100644
index 000000000..6d420f39d
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/RequiredRegexNotFound-check.cmake
@@ -0,0 +1,16 @@
+set(last_test_log "${RunCMake_TEST_BINARY_DIR}/Testing/Temporary/LastTest.log")
+if(EXISTS "${last_test_log}")
+ file(READ "${last_test_log}" last_test_log_content)
+ string(REGEX REPLACE "\n+$" "" last_test_log_content "${last_test_log_content}")
+ if(NOT last_test_log_content MATCHES "
+Test Pass Reason:
+Required regular expression not found. Regex=[[]foo
+toast1
+bar
+]")
+ string(REPLACE "\n" "\n " last_test_log_content " ${last_test_log_content}")
+ set(RunCMake_TEST_FAILED "LastTest.log does not have expected content:\n${last_test_log_content}")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "LastTest.log missing:\n ${last_test_log}")
+endif()
diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
index e936dab4c..6b23162db 100644
--- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
@@ -78,6 +78,62 @@ endfunction()
run_LabelCount()
+function(run_RequiredRegexFoundTest)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RequiredRegexFound)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
+add_test(test1 \"${CMAKE_COMMAND}\" -E echo \"test1\")
+set_tests_properties(test1 PROPERTIES PASS_REGULAR_EXPRESSION \"foo;test1;bar\")
+")
+
+ run_cmake_command(RequiredRegexFound ${CMAKE_CTEST_COMMAND} -V)
+endfunction()
+run_RequiredRegexFoundTest()
+
+function(run_RequiredRegexNotFoundTest)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RequiredRegexNotFound)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
+add_test(test1 \"${CMAKE_COMMAND}\" -E echo \"test1\")
+set_tests_properties(test1 PROPERTIES PASS_REGULAR_EXPRESSION \"foo;toast1;bar\" WILL_FAIL True)
+")
+
+ run_cmake_command(RequiredRegexNotFound ${CMAKE_CTEST_COMMAND} -V)
+endfunction()
+run_RequiredRegexNotFoundTest()
+
+function(run_FailRegexFoundTest)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/FailRegexFound)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
+add_test(test1 \"${CMAKE_COMMAND}\" -E echo \"test1\")
+set_tests_properties(test1 PROPERTIES FAIL_REGULAR_EXPRESSION \"foo;test1;bar\" WILL_FAIL True)
+")
+
+ run_cmake_command(FailRegexFound ${CMAKE_CTEST_COMMAND} -V)
+endfunction()
+run_FailRegexFoundTest()
+
+function(run_SkipRegexFoundTest)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SkipRegexFound)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
+add_test(test1 \"${CMAKE_COMMAND}\" -E echo \"test1\")
+set_tests_properties(test1 PROPERTIES SKIP_REGULAR_EXPRESSION \"test1\")
+")
+
+ run_cmake_command(SkipRegexFound ${CMAKE_CTEST_COMMAND} -V)
+endfunction()
+run_SkipRegexFoundTest()
+
function(run_SerialFailed)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SerialFailed)
set(RunCMake_TEST_NO_CLEAN 1)
@@ -102,7 +158,7 @@ function(run_TestLoad name load)
add_test(TestLoad1 \"${CMAKE_COMMAND}\" -E echo \"test of --test-load\")
add_test(TestLoad2 \"${CMAKE_COMMAND}\" -E echo \"test of --test-load\")
")
- run_cmake_command(${name} ${CMAKE_CTEST_COMMAND} -j2 --test-load ${load} --test-timeout 5)
+ run_cmake_command(${name} ${CMAKE_CTEST_COMMAND} -j2 --test-load ${load})
endfunction()
# Tests for the --test-load feature of ctest
@@ -111,8 +167,8 @@ endfunction()
set(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING} 5)
# Verify that new tests are not started when the load average exceeds
-# our threshold.
-run_TestLoad(test-load-fail 2)
+# our threshold and that they then run once the load average drops.
+run_TestLoad(test-load-wait 3)
# Verify that warning message is displayed but tests still start when
# an invalid argument is given.
@@ -141,3 +197,75 @@ function(run_TestOutputSize)
)
endfunction()
run_TestOutputSize()
+
+function(run_TestAffinity)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestAffinity)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ # Create a test with affinity enabled. The default PROCESSORS
+ # value is 1, so our expected output checks that this is the
+ # number of processors in the mask.
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
+ add_test(Affinity \"${TEST_AFFINITY}\")
+ set_tests_properties(Affinity PROPERTIES PROCESSOR_AFFINITY ON)
+")
+ # Run ctest with a large parallel level so that the value is
+ # not responsible for capping the number of processors available.
+ run_cmake_command(TestAffinity ${CMAKE_CTEST_COMMAND} -V -j 64)
+endfunction()
+if(TEST_AFFINITY)
+ run_TestAffinity()
+endif()
+
+function(run_TestStdin)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestStdin)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
+ add_test(TestStdin \"${TEST_PRINT_STDIN}\")
+ ")
+ run_cmake_command(TestStdin ${CMAKE_CTEST_COMMAND} -V)
+endfunction()
+run_TestStdin()
+
+function(show_only_json_check_python v)
+ if(RunCMake_TEST_FAILED OR NOT PYTHON_EXECUTABLE)
+ return()
+ endif()
+ set(json_file "${RunCMake_TEST_BINARY_DIR}/ctest.json")
+ file(WRITE "${json_file}" "${actual_stdout}")
+ set(actual_stdout "" PARENT_SCOPE)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/show-only_json-v${v}_check.py" "${json_file}"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE output
+ ERROR_VARIABLE output
+ )
+ if(NOT result EQUAL 0)
+ string(REPLACE "\n" "\n " output " ${output}")
+ set(RunCMake_TEST_FAILED "Unexpected output:\n${output}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(run_ShowOnly)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ShowOnly)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
+ add_test(ShowOnly \"${CMAKE_COMMAND}\" -E echo)
+ set_tests_properties(ShowOnly PROPERTIES
+ WILL_FAIL true
+ RESOURCE_GROUPS \"2,threads:2,gpus:4;gpus:2,threads:4\"
+ REQUIRED_FILES RequiredFileDoesNotExist
+ _BACKTRACE_TRIPLES \"file1;1;add_test;file0;;\"
+ )
+ add_test(ShowOnlyNotAvailable NOT_AVAILABLE)
+")
+ run_cmake_command(show-only_human ${CMAKE_CTEST_COMMAND} --show-only=human)
+ run_cmake_command(show-only_bad ${CMAKE_CTEST_COMMAND} --show-only=bad)
+ run_cmake_command(show-only_json-v1 ${CMAKE_CTEST_COMMAND} --show-only=json-v1)
+endfunction()
+run_ShowOnly()
diff --git a/Tests/RunCMake/CTestCommandLine/SkipRegexFound-check.cmake b/Tests/RunCMake/CTestCommandLine/SkipRegexFound-check.cmake
new file mode 100644
index 000000000..1a2dfa353
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/SkipRegexFound-check.cmake
@@ -0,0 +1,13 @@
+set(last_test_log "${RunCMake_TEST_BINARY_DIR}/Testing/Temporary/LastTest.log")
+if(EXISTS "${last_test_log}")
+ file(READ "${last_test_log}" last_test_log_content)
+ string(REGEX REPLACE "\n+$" "" last_test_log_content "${last_test_log_content}")
+ if(NOT last_test_log_content MATCHES "
+Test Pass Reason:
+Skip regular expression found in output. Regex=[[]test1]")
+ string(REPLACE "\n" "\n " last_test_log_content " ${last_test_log_content}")
+ set(RunCMake_TEST_FAILED "LastTest.log does not have expected content:\n${last_test_log_content}")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "LastTest.log missing:\n ${last_test_log}")
+endif()
diff --git a/Tests/RunCMake/CTestCommandLine/TestAffinity-stdout.txt b/Tests/RunCMake/CTestCommandLine/TestAffinity-stdout.txt
new file mode 100644
index 000000000..e23d30bcf
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestAffinity-stdout.txt
@@ -0,0 +1 @@
+1: CPU affinity (mask count is '1'|not supported on this platform)\.
diff --git a/Tests/RunCMake/CTestCommandLine/TestStdin-stdin.txt b/Tests/RunCMake/CTestCommandLine/TestStdin-stdin.txt
new file mode 100644
index 000000000..d83b50a68
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestStdin-stdin.txt
@@ -0,0 +1 @@
+Content for TestStdin
diff --git a/Tests/RunCMake/CTestCommandLine/TestStdin-stdout.txt b/Tests/RunCMake/CTestCommandLine/TestStdin-stdout.txt
new file mode 100644
index 000000000..d83b50a68
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestStdin-stdout.txt
@@ -0,0 +1 @@
+Content for TestStdin
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-result.txt b/Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-result.txt
+++ b/Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt
diff --git a/Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt b/Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt
new file mode 100644
index 000000000..cc55ab390
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: '--show-only=' given unknown value 'bad'$
diff --git a/Tests/RunCMake/CTestCommandLine/show-only_human-stdout.txt b/Tests/RunCMake/CTestCommandLine/show-only_human-stdout.txt
new file mode 100644
index 000000000..13321496c
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/show-only_human-stdout.txt
@@ -0,0 +1 @@
+Test #1: ShowOnly
diff --git a/Tests/RunCMake/CTestCommandLine/show-only_json-v1-check.cmake b/Tests/RunCMake/CTestCommandLine/show-only_json-v1-check.cmake
new file mode 100644
index 000000000..f9234f8d9
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/show-only_json-v1-check.cmake
@@ -0,0 +1 @@
+show_only_json_check_python(1)
diff --git a/Tests/RunCMake/CTestCommandLine/show-only_json-v1_check.py b/Tests/RunCMake/CTestCommandLine/show-only_json-v1_check.py
new file mode 100644
index 000000000..b81865008
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/show-only_json-v1_check.py
@@ -0,0 +1,173 @@
+from show_only_json_check import *
+
+def check_kind(k):
+ assert is_string(k)
+ assert k == "ctestInfo"
+
+def check_version(v):
+ assert is_dict(v)
+ assert sorted(v.keys()) == ["major", "minor"]
+ assert is_int(v["major"])
+ assert is_int(v["minor"])
+ assert v["major"] == 1
+ assert v["minor"] == 0
+
+def check_backtracegraph(b):
+ assert is_dict(b)
+ assert sorted(b.keys()) == ["commands", "files", "nodes"]
+ check_backtracegraph_commands(b["commands"])
+ check_backtracegraph_files(b["files"])
+ check_backtracegraph_nodes(b["nodes"])
+
+def check_backtracegraph_commands(c):
+ assert is_list(c)
+ assert len(c) == 1
+ assert is_string(c[0])
+ assert c[0] == "add_test"
+
+def check_backtracegraph_files(f):
+ assert is_list(f)
+ assert len(f) == 2
+ assert is_string(f[0])
+ assert is_string(f[1])
+ assert f[0] == "file1"
+ assert f[1] == "file0"
+
+def check_backtracegraph_nodes(n):
+ assert is_list(n)
+ assert len(n) == 2
+ node = n[0]
+ assert is_dict(node)
+ assert sorted(node.keys()) == ["file"]
+ assert is_int(node["file"])
+ assert node["file"] == 1
+ node = n[1]
+ assert is_dict(node)
+ assert sorted(node.keys()) == ["command", "file", "line", "parent"]
+ assert is_int(node["command"])
+ assert is_int(node["file"])
+ assert is_int(node["line"])
+ assert is_int(node["parent"])
+ assert node["command"] == 0
+ assert node["file"] == 0
+ assert node["line"] == 1
+ assert node["parent"] == 0
+
+def check_command(c):
+ assert is_list(c)
+ assert len(c) == 3
+ assert is_string(c[0])
+ check_re(c[0], "/cmake(\.exe)?$")
+ assert is_string(c[1])
+ assert c[1] == "-E"
+ assert is_string(c[2])
+ assert c[2] == "echo"
+
+def check_reqfiles_property(p):
+ assert is_dict(p)
+ assert sorted(p.keys()) == ["name", "value"]
+ assert is_string(p["name"])
+ assert is_list(p["value"])
+ assert p["name"] == "REQUIRED_FILES"
+ assert len(p["value"]) == 1
+ assert p["value"][0] == "RequiredFileDoesNotExist"
+
+def check_willfail_property(p):
+ assert is_dict(p)
+ assert sorted(p.keys()) == ["name", "value"]
+ assert is_string(p["name"])
+ assert is_bool(p["value"])
+ assert p["name"] == "WILL_FAIL"
+ assert p["value"] == True
+
+def check_resource_groups_property(p):
+ assert is_dict(p)
+ assert sorted(p.keys()) == ["name", "value"]
+ assert is_string(p["name"])
+ assert is_list(p["value"])
+ assert p["name"] == "RESOURCE_GROUPS"
+ assert len(p["value"]) == 3
+
+ assert is_dict(p["value"][0])
+ assert sorted(p["value"][0].keys()) == ["requirements"]
+ assert is_list(p["value"][0]["requirements"])
+ assert len(p["value"][0]["requirements"]) == 2
+ assert is_dict(p["value"][0]["requirements"][0])
+ assert sorted(p["value"][0]["requirements"][0].keys()) == \
+ [".type", "slots"]
+ assert is_string(p["value"][0]["requirements"][0][".type"])
+ assert p["value"][0]["requirements"][0][".type"] == "threads"
+ assert is_int(p["value"][0]["requirements"][0]["slots"])
+ assert p["value"][0]["requirements"][0]["slots"] == 2
+ assert is_string(p["value"][0]["requirements"][1][".type"])
+ assert p["value"][0]["requirements"][1][".type"] == "gpus"
+ assert is_int(p["value"][0]["requirements"][1]["slots"])
+ assert p["value"][0]["requirements"][1]["slots"] == 4
+
+ assert is_dict(p["value"][1])
+ assert sorted(p["value"][1].keys()) == ["requirements"]
+ assert is_list(p["value"][1]["requirements"])
+ assert len(p["value"][1]["requirements"]) == 2
+ assert is_dict(p["value"][1]["requirements"][0])
+ assert sorted(p["value"][1]["requirements"][0].keys()) == \
+ [".type", "slots"]
+ assert is_string(p["value"][1]["requirements"][0][".type"])
+ assert p["value"][1]["requirements"][0][".type"] == "threads"
+ assert is_int(p["value"][1]["requirements"][0]["slots"])
+ assert p["value"][1]["requirements"][0]["slots"] == 2
+ assert is_string(p["value"][1]["requirements"][1][".type"])
+ assert p["value"][1]["requirements"][1][".type"] == "gpus"
+ assert is_int(p["value"][1]["requirements"][1]["slots"])
+ assert p["value"][1]["requirements"][1]["slots"] == 4
+
+ assert is_dict(p["value"][2])
+ assert sorted(p["value"][2].keys()) == ["requirements"]
+ assert is_list(p["value"][2]["requirements"])
+ assert len(p["value"][2]["requirements"]) == 2
+ assert is_dict(p["value"][2]["requirements"][0])
+ assert sorted(p["value"][2]["requirements"][0].keys()) == \
+ [".type", "slots"]
+ assert is_string(p["value"][2]["requirements"][0][".type"])
+ assert p["value"][2]["requirements"][0][".type"] == "gpus"
+ assert is_int(p["value"][2]["requirements"][0]["slots"])
+ assert p["value"][2]["requirements"][0]["slots"] == 2
+ assert is_string(p["value"][2]["requirements"][1][".type"])
+ assert p["value"][2]["requirements"][1][".type"] == "threads"
+ assert is_int(p["value"][2]["requirements"][1]["slots"])
+ assert p["value"][2]["requirements"][1]["slots"] == 4
+
+def check_workingdir_property(p):
+ assert is_dict(p)
+ assert sorted(p.keys()) == ["name", "value"]
+ assert is_string(p["name"])
+ assert is_string(p["value"])
+ assert p["name"] == "WORKING_DIRECTORY"
+ assert p["value"].endswith("Tests/RunCMake/CTestCommandLine/ShowOnly")
+
+def check_properties(p):
+ assert is_list(p)
+ assert len(p) == 4
+ check_resource_groups_property(p[0])
+ check_reqfiles_property(p[1])
+ check_willfail_property(p[2])
+ check_workingdir_property(p[3])
+
+def check_tests(t):
+ assert is_list(t)
+ assert len(t) == 1
+ test = t[0]
+ assert is_dict(test)
+ assert sorted(test.keys()) == ["backtrace", "command", "name", "properties"]
+ assert is_int(test["backtrace"])
+ assert test["backtrace"] == 1
+ check_command(test["command"])
+ assert is_string(test["name"])
+ assert test["name"] == "ShowOnly"
+ check_properties(test["properties"])
+
+assert is_dict(ctest_json)
+assert sorted(ctest_json.keys()) == ["backtraceGraph", "kind", "tests", "version"]
+check_backtracegraph(ctest_json["backtraceGraph"])
+check_kind(ctest_json["kind"])
+check_version(ctest_json["version"])
+check_tests(ctest_json["tests"])
diff --git a/Tests/RunCMake/CTestCommandLine/show_only_json_check.py b/Tests/RunCMake/CTestCommandLine/show_only_json_check.py
new file mode 100644
index 000000000..493c9e579
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/show_only_json_check.py
@@ -0,0 +1,24 @@
+import sys
+import json
+import re
+
+def is_bool(x):
+ return isinstance(x, bool)
+
+def is_dict(x):
+ return isinstance(x, dict)
+
+def is_list(x):
+ return isinstance(x, list)
+
+def is_int(x):
+ return isinstance(x, int) or isinstance(x, long)
+
+def is_string(x):
+ return isinstance(x, str) or isinstance(x, unicode)
+
+def check_re(x, regex):
+ assert re.search(regex, x)
+
+with open(sys.argv[1]) as f:
+ ctest_json = json.load(f)
diff --git a/Tests/RunCMake/CTestCommandLine/test-load-fail-stderr.txt b/Tests/RunCMake/CTestCommandLine/test-load-fail-stderr.txt
deleted file mode 100644
index eafba1c69..000000000
--- a/Tests/RunCMake/CTestCommandLine/test-load-fail-stderr.txt
+++ /dev/null
@@ -1 +0,0 @@
-No tests were found!!!
diff --git a/Tests/RunCMake/CTestCommandLine/test-load-fail-stdout.txt b/Tests/RunCMake/CTestCommandLine/test-load-fail-stdout.txt
deleted file mode 100644
index 153da09fb..000000000
--- a/Tests/RunCMake/CTestCommandLine/test-load-fail-stdout.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-^Test project .*/Tests/RunCMake/CTestCommandLine/TestLoad
-\*\*\*\*\* WAITING, System Load: 5, Max Allowed Load: 2, Smallest test TestLoad[1-2] requires 1\*\*\*\*\*
diff --git a/Tests/RunCMake/CTestCommandLine/test-load-wait-stdout.txt b/Tests/RunCMake/CTestCommandLine/test-load-wait-stdout.txt
new file mode 100644
index 000000000..11a768a9c
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/test-load-wait-stdout.txt
@@ -0,0 +1,8 @@
+^Test project .*/Tests/RunCMake/CTestCommandLine/TestLoad
+\*\*\*\*\* WAITING, System Load: 5, Max Allowed Load: 3, Smallest test TestLoad[1-2] requires 1\*\*\*\*\*
+ Start 1: TestLoad1
+ Start 2: TestLoad2
+1/2 Test #[1-2]: TestLoad[1-2] ........................ Passed +[0-9.]+ sec
+2/2 Test #[1-2]: TestLoad[1-2] ........................ Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 2
diff --git a/Tests/RunCMake/CTestResourceAllocation/CMakeLists.txt.in b/Tests/RunCMake/CTestResourceAllocation/CMakeLists.txt.in
new file mode 100644
index 000000000..998442116
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/CMakeLists.txt.in
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.15)
+set(CASE_NAME "@CASE_NAME@")
+if(CASE_NAME MATCHES "^(.*)-ctest-s")
+ set(projname "${CMAKE_MATCH_1}")
+ project(${projname} NONE)
+ include(CTest)
+ include("@RunCMake_SOURCE_DIR@/ResourceCommon.cmake")
+ include("@RunCMake_SOURCE_DIR@/${projname}.cmake")
+endif()
diff --git a/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake b/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake
new file mode 100644
index 000000000..7d632999d
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ResourceCommon.cmake
@@ -0,0 +1,23 @@
+function(setup_resource_tests)
+ if(CTEST_RESOURCE_ALLOC_ENABLED)
+ add_test(NAME ResourceSetup COMMAND "${CMAKE_COMMAND}" -E remove -f "${CMAKE_BINARY_DIR}/ctresalloc.log")
+ endif()
+endfunction()
+
+function(add_resource_test name sleep_time proc)
+ if(CTEST_RESOURCE_ALLOC_ENABLED)
+ add_test(NAME "${name}" COMMAND "${CTRESALLOC_COMMAND}" write "${CMAKE_BINARY_DIR}/ctresalloc.log" "${name}" "${sleep_time}" "${proc}")
+ set_property(TEST "${name}" PROPERTY DEPENDS ResourceSetup)
+ else()
+ add_test(NAME "${name}" COMMAND "${CTRESALLOC_COMMAND}" write "${CMAKE_BINARY_DIR}/ctresalloc.log" "${name}" "${sleep_time}")
+ endif()
+ set_property(TEST "${name}" PROPERTY RESOURCE_GROUPS "${proc}")
+ list(APPEND RESOURCE_TESTS "${name}")
+ set(RESOURCE_TESTS "${RESOURCE_TESTS}" PARENT_SCOPE)
+endfunction()
+
+function(cleanup_resource_tests)
+ if(CTEST_RESOURCE_ALLOC_ENABLED)
+ file(WRITE "${CMAKE_BINARY_DIR}/restests.txt" "${RESOURCE_TESTS}")
+ endif()
+endfunction()
diff --git a/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake b/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake
new file mode 100644
index 000000000..858478647
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/RunCMakeTest.cmake
@@ -0,0 +1,169 @@
+include(RunCMake)
+include(RunCTest)
+
+###############################################################################
+# Test ctresalloc itself - we want to make sure it's not just rubber-stamping
+# the test results
+###############################################################################
+
+function(ctresalloc_verify_log expected_contents)
+ if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/ctresalloc.log")
+ string(APPEND RunCMake_TEST_FAILED "Log file was not written\n")
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+ return()
+ endif()
+ file(READ "${RunCMake_TEST_BINARY_DIR}/ctresalloc.log" actual_contents)
+ if(NOT actual_contents STREQUAL expected_contents)
+ string(APPEND RunCMake_TEST_FAILED "Actual log did not match expected log\n")
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(run_ctresalloc_write_proc name proc)
+ file(REMOVE "${RunCMake_BINARY_DIR}/${name}-build/ctresalloc.log")
+ run_ctresalloc_write_proc_nodel("${name}" "${proc}" "${ARGN}")
+endfunction()
+
+function(run_ctresalloc_write_proc_nodel name proc)
+ string(REPLACE ";" "\\;" proc "${proc}")
+ run_cmake_command(${name} "${CMAKE_COMMAND}" -E env "${ARGN}" "${CTRESALLOC_COMMAND}" write "${RunCMake_BINARY_DIR}/${name}-build/ctresalloc.log" "${name}" 0 "${proc}")
+endfunction()
+
+function(run_ctresalloc_write_noproc name)
+ run_cmake_command(${name} "${CMAKE_COMMAND}" -E env "${ARGN}" "${CTRESALLOC_COMMAND}" write "${RunCMake_BINARY_DIR}/${name}-build/ctresalloc.log" "${name}" 0)
+endfunction()
+
+function(run_ctresalloc_verify name tests)
+ string(REPLACE ";" "\\;" tests "${tests}")
+ run_cmake_command(${name} "${CTRESALLOC_COMMAND}" verify "${RunCMake_SOURCE_DIR}/${name}.log" "${CMAKE_CURRENT_LIST_DIR}/resspec.json" "${tests}")
+endfunction()
+
+unset(ENV{CTEST_RESOURCE_GROUP_COUNT})
+set(RunCMake_TEST_NO_CLEAN 1)
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/ctresalloc-write-proc-good1-build")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/ctresalloc-write-proc-good1-build")
+file(WRITE "${RunCMake_BINARY_DIR}/ctresalloc-write-proc-good1-build/ctresalloc.log"
+[[begin test1
+alloc widgets 0 1
+dealloc widgets 0 1
+end test1
+]])
+run_ctresalloc_write_proc_nodel(ctresalloc-write-proc-good1 "1,widgets:2,transmogrifiers:1;2,widgets:1,widgets:2"
+ CTEST_RESOURCE_GROUP_COUNT=3
+ CTEST_RESOURCE_GROUP_0=widgets,transmogrifiers
+ CTEST_RESOURCE_GROUP_0_WIDGETS=id:0,slots:2
+ CTEST_RESOURCE_GROUP_0_TRANSMOGRIFIERS=id:calvin,slots:1
+ CTEST_RESOURCE_GROUP_1=widgets
+ "CTEST_RESOURCE_GROUP_1_WIDGETS=id:0,slots:1\\;id:2,slots:2"
+ CTEST_RESOURCE_GROUP_2=widgets
+ "CTEST_RESOURCE_GROUP_2_WIDGETS=id:0,slots:1\\;id:2,slots:2"
+ )
+set(RunCMake_TEST_NO_CLEAN 0)
+run_ctresalloc_write_proc(ctresalloc-write-proc-good2 "widgets:8"
+ CTEST_RESOURCE_GROUP_COUNT=1
+ CTEST_RESOURCE_GROUP_0=widgets
+ CTEST_RESOURCE_GROUP_0_WIDGETS=id:3,slots:8
+ )
+run_ctresalloc_write_proc(ctresalloc-write-proc-nocount "widgets:8")
+run_ctresalloc_write_proc(ctresalloc-write-proc-badcount "widgets:8"
+ CTEST_RESOURCE_GROUP_COUNT=2
+ )
+run_ctresalloc_write_proc(ctresalloc-write-proc-nores "widgets:8"
+ CTEST_RESOURCE_GROUP_COUNT=1
+ )
+run_ctresalloc_write_proc(ctresalloc-write-proc-badres "widgets:8"
+ CTEST_RESOURCE_GROUP_COUNT=1
+ CTEST_RESOURCE_GROUP_0=widgets,transmogrifiers
+ )
+run_ctresalloc_write_proc(ctresalloc-write-proc-nowidgets "widgets:8"
+ CTEST_RESOURCE_GROUP_COUNT=1
+ CTEST_RESOURCE_GROUP_0=widgets
+ )
+run_ctresalloc_write_proc(ctresalloc-write-proc-badwidgets1 "widgets:8"
+ CTEST_RESOURCE_GROUP_COUNT=1
+ CTEST_RESOURCE_GROUP_0=widgets
+ CTEST_RESOURCE_GROUP_0_WIDGETS=
+ )
+run_ctresalloc_write_proc(ctresalloc-write-proc-badwidgets2 "widgets:8"
+ CTEST_RESOURCE_GROUP_COUNT=1
+ CTEST_RESOURCE_GROUP_0=widgets
+ "CTEST_RESOURCE_GROUP_0_WIDGETS=id:3,slots:8\\;id:0,slots:1"
+ )
+run_ctresalloc_write_proc(ctresalloc-write-proc-badwidgets3 "widgets:8"
+ CTEST_RESOURCE_GROUP_COUNT=1
+ CTEST_RESOURCE_GROUP_0=widgets
+ CTEST_RESOURCE_GROUP_0_WIDGETS=id:3,slots:7
+ )
+run_ctresalloc_write_proc(ctresalloc-write-proc-badwidgets4 "widgets:8"
+ CTEST_RESOURCE_GROUP_COUNT=1
+ CTEST_RESOURCE_GROUP_0=widgets
+ CTEST_RESOURCE_GROUP_0_WIDGETS=invalid
+ )
+run_ctresalloc_write_proc(ctresalloc-write-proc-badwidgets5 "widgets:2,widgets:2"
+ CTEST_RESOURCE_GROUP_COUNT=1
+ CTEST_RESOURCE_GROUP_0=widgets
+ "CTEST_RESOURCE_GROUP_0_WIDGETS=id:0,slots:2\\;id:0,slots:1"
+ )
+run_ctresalloc_write_proc(ctresalloc-write-proc-badwidgets6 "widgets:2"
+ CTEST_RESOURCE_GROUP_COUNT=1
+ CTEST_RESOURCE_GROUP_0=widgets
+ "CTEST_RESOURCE_GROUP_0_WIDGETS=id:0,slots:2\\;id:0,slots:1"
+ )
+run_ctresalloc_write_proc(ctresalloc-write-proc-badwidgets7 "widgets:2,widgets:2"
+ CTEST_RESOURCE_GROUP_COUNT=1
+ CTEST_RESOURCE_GROUP_0=widgets
+ CTEST_RESOURCE_GROUP_0_WIDGETS=id:0,slots:2
+ )
+
+run_ctresalloc_write_noproc(ctresalloc-write-noproc-good1)
+run_ctresalloc_write_noproc(ctresalloc-write-noproc-count
+ CTEST_RESOURCE_GROUP_COUNT=1
+ )
+
+run_ctresalloc_verify(ctresalloc-verify-good1 "test1;test2")
+run_ctresalloc_verify(ctresalloc-verify-good2 "")
+run_ctresalloc_verify(ctresalloc-verify-nolog "")
+run_ctresalloc_verify(ctresalloc-verify-nores "")
+run_ctresalloc_verify(ctresalloc-verify-noid "")
+run_ctresalloc_verify(ctresalloc-verify-notenough "")
+run_ctresalloc_verify(ctresalloc-verify-baddealloc "")
+run_ctresalloc_verify(ctresalloc-verify-leak "")
+run_ctresalloc_verify(ctresalloc-verify-badtest1 "")
+run_ctresalloc_verify(ctresalloc-verify-badtest2 "test1")
+run_ctresalloc_verify(ctresalloc-verify-badtest3 "test1")
+run_ctresalloc_verify(ctresalloc-verify-badtest4 "test1")
+run_ctresalloc_verify(ctresalloc-verify-badtest5 "test1")
+run_ctresalloc_verify(ctresalloc-verify-nobegin "test1")
+run_ctresalloc_verify(ctresalloc-verify-noend "test1")
+
+###############################################################################
+# Now test the resource allocation feature of CTest
+###############################################################################
+
+function(run_ctest_resource name parallel random)
+ run_ctest("${name}-ctest-s-res" "-DCTEST_RESOURCE_ALLOC_ENABLED=1" "-DCTRESALLOC_COMMAND=${CTRESALLOC_COMMAND}" "-DCTEST_PARALLEL=${parallel}" "-DCTEST_RANDOM=${random}")
+ run_ctest("${name}-ctest-s-nores" "-DCTEST_RESOURCE_ALLOC_ENABLED=0" "-DCTRESALLOC_COMMAND=${CTRESALLOC_COMMAND}" "-DCTEST_PARALLEL=${parallel}" "-DCTEST_RANDOM=${random}")
+endfunction()
+
+function(verify_ctest_resources)
+ file(READ "${RunCMake_TEST_BINARY_DIR}/restests.txt" restests)
+ execute_process(COMMAND "${CTRESALLOC_COMMAND}" verify "${RunCMake_TEST_BINARY_DIR}/ctresalloc.log" "${CMAKE_CURRENT_LIST_DIR}/resspec.json" "${restests}"
+ OUTPUT_VARIABLE output ERROR_QUIET RESULT_VARIABLE result)
+ if(result)
+ string(APPEND RunCMake_TEST_FAILED "${output}")
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+run_ctest_resource(lotsoftests 10 1)
+run_ctest_resource(checkfree1 2 0)
+run_ctest_resource(checkfree2 1 0)
+run_ctest_resource(notenough1 1 0)
+run_ctest_resource(notenough2 1 0)
+run_ctest_resource(notenough3 1 0)
+run_ctest_resource(combine 1 0)
+run_ctest_resource(ensure_parallel 2 0)
+
+set(ENV{CTEST_RESOURCE_GROUP_COUNT} 2)
+run_ctest_resource(process_count 1 0)
+unset(ENV{CTEST_RESOURCE_GROUP_COUNT})
diff --git a/Tests/RunCMake/CTestResourceAllocation/checkfree1-ctest-s-res-check.cmake b/Tests/RunCMake/CTestResourceAllocation/checkfree1-ctest-s-res-check.cmake
new file mode 100644
index 000000000..ceda72ea8
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/checkfree1-ctest-s-res-check.cmake
@@ -0,0 +1 @@
+verify_ctest_resources()
diff --git a/Tests/RunCMake/CTestResourceAllocation/checkfree1.cmake b/Tests/RunCMake/CTestResourceAllocation/checkfree1.cmake
new file mode 100644
index 000000000..45cbf2099
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/checkfree1.cmake
@@ -0,0 +1,7 @@
+setup_resource_tests()
+
+add_resource_test(Test1 1 "widgets:8")
+add_resource_test(Test2 1 "fluxcapacitors:50;fluxcapacitors:50,widgets:8")
+add_resource_test(Test3 1 "fluxcapacitors:121")
+
+cleanup_resource_tests()
diff --git a/Tests/RunCMake/CTestResourceAllocation/checkfree2-ctest-s-res-check.cmake b/Tests/RunCMake/CTestResourceAllocation/checkfree2-ctest-s-res-check.cmake
new file mode 100644
index 000000000..ceda72ea8
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/checkfree2-ctest-s-res-check.cmake
@@ -0,0 +1 @@
+verify_ctest_resources()
diff --git a/Tests/RunCMake/CTestResourceAllocation/checkfree2.cmake b/Tests/RunCMake/CTestResourceAllocation/checkfree2.cmake
new file mode 100644
index 000000000..03b737cea
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/checkfree2.cmake
@@ -0,0 +1,8 @@
+setup_resource_tests()
+
+# This test is an attack on the resource scheduling algorithm. It has been
+# carefully crafted to fool the algorithm into thinking there aren't sufficient
+# resources for it.
+add_resource_test(Test1 1 "widgets:2;4,widgets:4")
+
+cleanup_resource_tests()
diff --git a/Tests/RunCMake/CTestResourceAllocation/combine.cmake b/Tests/RunCMake/CTestResourceAllocation/combine.cmake
new file mode 100644
index 000000000..ed5b25109
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/combine.cmake
@@ -0,0 +1,5 @@
+setup_resource_tests()
+
+add_resource_test(Test1 0 "widgets:8,widgets:4")
+
+cleanup_resource_tests()
diff --git a/Tests/RunCMake/CommandLine/E_make_directory-three-directories-and-file-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-baddealloc-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/CommandLine/E_make_directory-three-directories-and-file-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-baddealloc-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-baddealloc.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-baddealloc.log
new file mode 100644
index 000000000..abd6badc8
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-baddealloc.log
@@ -0,0 +1,2 @@
+alloc widgets 0 1
+dealloc widgets 0 2
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest1-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest1-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest1.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest1.log
new file mode 100644
index 000000000..605104b1a
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest1.log
@@ -0,0 +1 @@
+begin test1
diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource2-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest2-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/ObjectLibrary/BadObjSource2-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest2-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest2.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest2.log
new file mode 100644
index 000000000..1ff1b0d71
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest2.log
@@ -0,0 +1,2 @@
+begin test1
+begin test1
diff --git a/Tests/RunCMake/ObjectLibrary/ExportNotSupported-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest3-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/ObjectLibrary/ExportNotSupported-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest3-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest3.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest3.log
new file mode 100644
index 000000000..1925e6a3d
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest3.log
@@ -0,0 +1,3 @@
+begin test1
+end test1
+begin test1
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHS-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest4-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/ObjectLibrary/LinkObjLHS-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest4-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest4.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest4.log
new file mode 100644
index 000000000..3fe7da169
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest4.log
@@ -0,0 +1,3 @@
+begin test1
+end test1
+end test1
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest5-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest5-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest5.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest5.log
new file mode 100644
index 000000000..3a2e7e3bf
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-badtest5.log
@@ -0,0 +1 @@
+end test1
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-good1.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-good1.log
new file mode 100644
index 000000000..2cca0c39c
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-good1.log
@@ -0,0 +1,14 @@
+begin test1
+alloc widgets 3 4
+alloc widgets 4 1
+alloc transmogrifiers calvin 2
+alloc fluxcapacitors outatime 121
+begin test2
+alloc widgets 3 4
+dealloc widgets 3 4
+dealloc widgets 4 1
+dealloc transmogrifiers calvin 2
+dealloc fluxcapacitors outatime 121
+end test1
+dealloc widgets 3 4
+end test2
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-good2.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-good2.log
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-good2.log
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-leak-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-leak-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-leak.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-leak.log
new file mode 100644
index 000000000..b900d86d1
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-leak.log
@@ -0,0 +1 @@
+alloc widgets 0 1
diff --git a/Tests/RunCMake/ObjectLibrary/ObjWithObj-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nobegin-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/ObjectLibrary/ObjWithObj-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nobegin-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nobegin.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nobegin.log
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nobegin.log
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noend-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noend-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noend.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noend.log
new file mode 100644
index 000000000..605104b1a
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noend.log
@@ -0,0 +1 @@
+begin test1
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noid-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noid-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noid.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noid.log
new file mode 100644
index 000000000..c71897525
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-noid.log
@@ -0,0 +1,2 @@
+alloc fluxcapacitors train 1
+dealloc fluxcapacitors train 1
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nolog-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nolog-result.txt
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nores-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nores-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nores.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nores.log
new file mode 100644
index 000000000..a18202b0a
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-nores.log
@@ -0,0 +1,2 @@
+alloc gpus 0 1
+dealloc gpus 0 1
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-notenough-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-notenough-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-notenough.log b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-notenough.log
new file mode 100644
index 000000000..ac78d5ad3
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-verify-notenough.log
@@ -0,0 +1,2 @@
+alloc widgets 0 8
+dealloc widgets 0 8
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-noproc-count-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-noproc-count-result.txt
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badcount-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badcount-result.txt
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badres-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badres-result.txt
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets1-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets1-result.txt
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets2-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets2-result.txt
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets3-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets3-result.txt
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets4-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets4-result.txt
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets5-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets5-result.txt
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets6-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets6-result.txt
diff --git a/Tests/RunCMake/TargetSources/RelativePathInInterface-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets7-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/TargetSources/RelativePathInInterface-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-badwidgets7-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-good1-check.cmake b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-good1-check.cmake
new file mode 100644
index 000000000..40144c89b
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-good1-check.cmake
@@ -0,0 +1,20 @@
+ctresalloc_verify_log(
+[[begin test1
+alloc widgets 0 1
+dealloc widgets 0 1
+end test1
+begin ctresalloc-write-proc-good1
+alloc transmogrifiers calvin 1
+alloc widgets 0 2
+alloc widgets 0 1
+alloc widgets 2 2
+alloc widgets 0 1
+alloc widgets 2 2
+dealloc transmogrifiers calvin 1
+dealloc widgets 0 2
+dealloc widgets 0 1
+dealloc widgets 2 2
+dealloc widgets 0 1
+dealloc widgets 2 2
+end ctresalloc-write-proc-good1
+]])
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-good2-check.cmake b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-good2-check.cmake
new file mode 100644
index 000000000..4545466fb
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-good2-check.cmake
@@ -0,0 +1,6 @@
+ctresalloc_verify_log(
+[[begin ctresalloc-write-proc-good2
+alloc widgets 3 8
+dealloc widgets 3 8
+end ctresalloc-write-proc-good2
+]])
diff --git a/Tests/RunCMake/list/FILTER-NotList-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-nocount-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/list/FILTER-NotList-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-nocount-result.txt
diff --git a/Tests/RunCMake/list/REMOVE_DUPLICATES-NotList-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-nores-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/list/REMOVE_DUPLICATES-NotList-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-nores-result.txt
diff --git a/Tests/RunCMake/list/REMOVE_ITEM-NotList-result.txt b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-nowidgets-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/list/REMOVE_ITEM-NotList-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc-write-proc-nowidgets-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx b/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx
new file mode 100644
index 000000000..80db05eb6
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx
@@ -0,0 +1,400 @@
+#include <cassert>
+#include <chrono>
+#include <cstddef>
+#include <cstdlib>
+#include <iostream>
+#include <map>
+#include <set>
+#include <string>
+#include <thread>
+#include <utility>
+#include <vector>
+
+#include "cmsys/Encoding.hxx"
+#include "cmsys/FStream.hxx"
+
+#include "cmCTestMultiProcessHandler.h"
+#include "cmCTestResourceAllocator.h"
+#include "cmCTestResourceSpec.h"
+#include "cmCTestTestHandler.h"
+#include "cmFileLock.h"
+#include "cmFileLockResult.h"
+#include "cmStringAlgorithms.h"
+#include "cmSystemTools.h"
+
+/*
+ * This helper program is used to verify that the CTest resource allocation
+ * feature is working correctly. It consists of two stages:
+ *
+ * 1) write - This stage receives the RESOURCE_GROUPS property of the test and
+ * compares it with the values passed in the CTEST_RESOURCE_GROUP_*
+ * environment variables. If it received all of the resources it expected,
+ * then it writes this information to a log file, which will be read in
+ * the verify stage.
+ * 2) verify - This stage compares the log file with the resource spec file to
+ * make sure that no resources were over-subscribed, deallocated without
+ * being allocated, or allocated without being deallocated.
+ */
+
+static int usage(const char* argv0)
+{
+ std::cout << "Usage: " << argv0 << " (write|verify) <args...>" << std::endl;
+ return 1;
+}
+
+static int usageWrite(const char* argv0)
+{
+ std::cout << "Usage: " << argv0
+ << " write <log-file> <test-name> <sleep-time-secs>"
+ " [<resource-groups-property>]"
+ << std::endl;
+ return 1;
+}
+
+static int usageVerify(const char* argv0)
+{
+ std::cout << "Usage: " << argv0
+ << " verify <log-file> <resource-spec-file> [<test-names>]"
+ << std::endl;
+ return 1;
+}
+
+static int doWrite(int argc, char const* const* argv)
+{
+ if (argc < 5 || argc > 6) {
+ return usageWrite(argv[0]);
+ }
+ std::string logFile = argv[2];
+ std::string testName = argv[3];
+ unsigned int sleepTime = std::atoi(argv[4]);
+ std::vector<std::map<
+ std::string, std::vector<cmCTestMultiProcessHandler::ResourceAllocation>>>
+ resources;
+ if (argc == 6) {
+ // Parse RESOURCE_GROUPS property
+ std::string resourceGroupsProperty = argv[5];
+ std::vector<
+ std::vector<cmCTestTestHandler::cmCTestTestResourceRequirement>>
+ resourceGroups;
+ bool result = cmCTestTestHandler::ParseResourceGroupsProperty(
+ resourceGroupsProperty, resourceGroups);
+ (void)result;
+ assert(result);
+
+ // Verify group count
+ const char* resourceGroupCountEnv =
+ cmSystemTools::GetEnv("CTEST_RESOURCE_GROUP_COUNT");
+ if (!resourceGroupCountEnv) {
+ std::cout << "CTEST_RESOURCE_GROUP_COUNT should be defined" << std::endl;
+ return 1;
+ }
+ int resourceGroupCount = std::atoi(resourceGroupCountEnv);
+ if (resourceGroups.size() != std::size_t(resourceGroupCount)) {
+ std::cout
+ << "CTEST_RESOURCE_GROUP_COUNT does not match expected resource groups"
+ << std::endl
+ << "Expected: " << resourceGroups.size() << std::endl
+ << "Actual: " << resourceGroupCount << std::endl;
+ return 1;
+ }
+
+ if (!cmSystemTools::Touch(logFile + ".lock", true)) {
+ std::cout << "Could not create lock file" << std::endl;
+ return 1;
+ }
+ cmFileLock lock;
+ auto lockResult =
+ lock.Lock(logFile + ".lock", static_cast<unsigned long>(-1));
+ if (!lockResult.IsOk()) {
+ std::cout << "Could not lock file" << std::endl;
+ return 1;
+ }
+ std::size_t i = 0;
+ cmsys::ofstream fout(logFile.c_str(), std::ios::app);
+ fout << "begin " << testName << std::endl;
+ for (auto& resourceGroup : resourceGroups) {
+ try {
+ // Build and verify set of expected resources
+ std::set<std::string> expectedResources;
+ for (auto const& it : resourceGroup) {
+ expectedResources.insert(it.ResourceType);
+ }
+
+ std::string prefix = "CTEST_RESOURCE_GROUP_";
+ prefix += std::to_string(i);
+ const char* actualResourcesCStr = cmSystemTools::GetEnv(prefix);
+ if (!actualResourcesCStr) {
+ std::cout << prefix << " should be defined" << std::endl;
+ return 1;
+ }
+
+ auto actualResourcesVec =
+ cmSystemTools::SplitString(actualResourcesCStr, ',');
+ std::set<std::string> actualResources;
+ for (auto const& r : actualResourcesVec) {
+ if (!r.empty()) {
+ actualResources.insert(r);
+ }
+ }
+
+ if (actualResources != expectedResources) {
+ std::cout << prefix << " did not list expected resources"
+ << std::endl;
+ return 1;
+ }
+
+ // Verify that we got what we asked for and write it to the log
+ prefix += '_';
+ std::map<std::string,
+ std::vector<cmCTestMultiProcessHandler::ResourceAllocation>>
+ resEntry;
+ for (auto const& type : actualResources) {
+ auto it = resourceGroup.begin();
+
+ std::string varName = prefix;
+ varName += cmSystemTools::UpperCase(type);
+ const char* varVal = cmSystemTools::GetEnv(varName);
+ if (!varVal) {
+ std::cout << varName << " should be defined" << std::endl;
+ return 1;
+ }
+
+ auto received = cmSystemTools::SplitString(varVal, ';');
+ for (auto const& r : received) {
+ while (it->ResourceType != type || it->UnitsNeeded == 0) {
+ ++it;
+ if (it == resourceGroup.end()) {
+ std::cout << varName << " did not list expected resources"
+ << std::endl;
+ return 1;
+ }
+ }
+ auto split = cmSystemTools::SplitString(r, ',');
+ if (split.size() != 2) {
+ std::cout << varName << " was ill-formed" << std::endl;
+ return 1;
+ }
+ if (!cmHasLiteralPrefix(split[0], "id:")) {
+ std::cout << varName << " was ill-formed" << std::endl;
+ return 1;
+ }
+ auto id = split[0].substr(3);
+ if (!cmHasLiteralPrefix(split[1], "slots:")) {
+ std::cout << varName << " was ill-formed" << std::endl;
+ return 1;
+ }
+ auto slots = split[1].substr(6);
+ unsigned int amount = std::atoi(slots.c_str());
+ if (amount != static_cast<unsigned int>(it->SlotsNeeded)) {
+ std::cout << varName << " did not list expected resources"
+ << std::endl;
+ return 1;
+ }
+ --it->UnitsNeeded;
+
+ fout << "alloc " << type << " " << id << " " << amount
+ << std::endl;
+ resEntry[type].push_back({ id, amount });
+ }
+
+ bool ended = false;
+ while (it->ResourceType != type || it->UnitsNeeded == 0) {
+ ++it;
+ if (it == resourceGroup.end()) {
+ ended = true;
+ break;
+ }
+ }
+
+ if (!ended) {
+ std::cout << varName << " did not list expected resources"
+ << std::endl;
+ return 1;
+ }
+ }
+ resources.push_back(resEntry);
+
+ ++i;
+ } catch (...) {
+ std::cout << "Unknown error while processing resources" << std::endl;
+ return 1;
+ }
+ }
+
+ auto unlockResult = lock.Release();
+ if (!unlockResult.IsOk()) {
+ std::cout << "Could not unlock file" << std::endl;
+ return 1;
+ }
+ } else {
+ if (cmSystemTools::GetEnv("CTEST_RESOURCE_GROUP_COUNT")) {
+ std::cout << "CTEST_RESOURCE_GROUP_COUNT should not be defined"
+ << std::endl;
+ return 1;
+ }
+ }
+
+ std::this_thread::sleep_for(std::chrono::seconds(sleepTime));
+
+ if (argc == 6) {
+ if (!cmSystemTools::Touch(logFile + ".lock", true)) {
+ std::cout << "Could not create lock file" << std::endl;
+ return 1;
+ }
+ cmFileLock lock;
+ auto lockResult =
+ lock.Lock(logFile + ".lock", static_cast<unsigned long>(-1));
+ if (!lockResult.IsOk()) {
+ std::cout << "Could not lock file" << std::endl;
+ return 1;
+ }
+ cmsys::ofstream fout(logFile.c_str(), std::ios::app);
+ for (auto const& group : resources) {
+ for (auto const& it : group) {
+ for (auto const& it2 : it.second) {
+ fout << "dealloc " << it.first << " " << it2.Id << " " << it2.Slots
+ << std::endl;
+ }
+ }
+ }
+
+ fout << "end " << testName << std::endl;
+
+ auto unlockResult = lock.Release();
+ if (!unlockResult.IsOk()) {
+ std::cout << "Could not unlock file" << std::endl;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static int doVerify(int argc, char const* const* argv)
+{
+ if (argc < 4 || argc > 5) {
+ return usageVerify(argv[0]);
+ }
+ std::string logFile = argv[2];
+ std::string resFile = argv[3];
+ std::string testNames;
+ if (argc == 5) {
+ testNames = argv[4];
+ }
+ auto testNameList = cmExpandedList(testNames, false);
+ std::set<std::string> testNameSet(testNameList.begin(), testNameList.end());
+
+ cmCTestResourceSpec spec;
+ if (spec.ReadFromJSONFile(resFile) !=
+ cmCTestResourceSpec::ReadFileResult::READ_OK) {
+ std::cout << "Could not read resource spec " << resFile << std::endl;
+ return 1;
+ }
+
+ cmCTestResourceAllocator allocator;
+ allocator.InitializeFromResourceSpec(spec);
+
+ cmsys::ifstream fin(logFile.c_str(), std::ios::in);
+ if (!fin) {
+ std::cout << "Could not open log file " << logFile << std::endl;
+ return 1;
+ }
+
+ std::string command;
+ std::string resourceName;
+ std::string resourceId;
+ std::string testName;
+ unsigned int amount;
+ std::set<std::string> inProgressTests;
+ std::set<std::string> completedTests;
+ try {
+ while (fin >> command) {
+ if (command == "begin") {
+ if (!(fin >> testName)) {
+ std::cout << "Could not read begin line" << std::endl;
+ return 1;
+ }
+ if (!testNameSet.count(testName) || inProgressTests.count(testName) ||
+ completedTests.count(testName)) {
+ std::cout << "Could not begin test" << std::endl;
+ return 1;
+ }
+ inProgressTests.insert(testName);
+ } else if (command == "alloc") {
+ if (!(fin >> resourceName) || !(fin >> resourceId) ||
+ !(fin >> amount)) {
+ std::cout << "Could not read alloc line" << std::endl;
+ return 1;
+ }
+ if (!allocator.AllocateResource(resourceName, resourceId, amount)) {
+ std::cout << "Could not allocate resources" << std::endl;
+ return 1;
+ }
+ } else if (command == "dealloc") {
+ if (!(fin >> resourceName) || !(fin >> resourceId) ||
+ !(fin >> amount)) {
+ std::cout << "Could not read dealloc line" << std::endl;
+ return 1;
+ }
+ if (!allocator.DeallocateResource(resourceName, resourceId, amount)) {
+ std::cout << "Could not deallocate resources" << std::endl;
+ return 1;
+ }
+ } else if (command == "end") {
+ if (!(fin >> testName)) {
+ std::cout << "Could not read end line" << std::endl;
+ return 1;
+ }
+ if (!inProgressTests.erase(testName)) {
+ std::cout << "Could not end test" << std::endl;
+ return 1;
+ }
+ if (!completedTests.insert(testName).second) {
+ std::cout << "Could not end test" << std::endl;
+ return 1;
+ }
+ }
+ }
+ } catch (...) {
+ std::cout << "Unknown error while reading log file" << std::endl;
+ return 1;
+ }
+
+ auto const& avail = allocator.GetResources();
+ for (auto const& it : avail) {
+ for (auto const& it2 : it.second) {
+ if (it2.second.Locked != 0) {
+ std::cout << "Resource was not unlocked" << std::endl;
+ return 1;
+ }
+ }
+ }
+
+ if (completedTests != testNameSet) {
+ std::cout << "Tests were not ended" << std::endl;
+ return 1;
+ }
+
+ return 0;
+}
+
+int main(int argc, char const* const* argv)
+{
+ cmsys::Encoding::CommandLineArguments args =
+ cmsys::Encoding::CommandLineArguments::Main(argc, argv);
+ argc = args.argc();
+ argv = args.argv();
+
+ if (argc < 2) {
+ return usage(argv[0]);
+ }
+
+ std::string argv1 = argv[1];
+ if (argv1 == "write") {
+ return doWrite(argc, argv);
+ }
+ if (argv1 == "verify") {
+ return doVerify(argc, argv);
+ }
+ return usage(argv[0]);
+}
diff --git a/Tests/RunCMake/CTestResourceAllocation/ensure_parallel-ctest-s-res-check.cmake b/Tests/RunCMake/CTestResourceAllocation/ensure_parallel-ctest-s-res-check.cmake
new file mode 100644
index 000000000..d842a76f4
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ensure_parallel-ctest-s-res-check.cmake
@@ -0,0 +1,16 @@
+verify_ctest_resources()
+
+set(expected_contents [[
+begin Test1
+alloc transmogrifiers calvin 2
+begin Test2
+alloc transmogrifiers hobbes 2
+dealloc transmogrifiers calvin 2
+end Test1
+dealloc transmogrifiers hobbes 2
+end Test2
+]])
+file(READ "${RunCMake_TEST_BINARY_DIR}/ctresalloc.log" actual_contents)
+if(NOT actual_contents STREQUAL expected_contents)
+ string(APPEND RunCMake_TEST_FAILED "ctresalloc.log contents did not match expected\n")
+endif()
diff --git a/Tests/RunCMake/CTestResourceAllocation/ensure_parallel.cmake b/Tests/RunCMake/CTestResourceAllocation/ensure_parallel.cmake
new file mode 100644
index 000000000..562d05acb
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/ensure_parallel.cmake
@@ -0,0 +1,11 @@
+setup_resource_tests()
+
+add_resource_test(Test1 4 "transmogrifiers:2")
+
+# Mitigate possible race conditions to ensure that the events are logged in the
+# exact order we want
+add_test(NAME Test2Sleep COMMAND "${CMAKE_COMMAND}" -E sleep 2)
+add_resource_test(Test2 4 "transmogrifiers:2")
+set_property(TEST Test2 APPEND PROPERTY DEPENDS Test2Sleep)
+
+cleanup_resource_tests()
diff --git a/Tests/RunCMake/CTestResourceAllocation/lotsoftests-ctest-s-res-check.cmake b/Tests/RunCMake/CTestResourceAllocation/lotsoftests-ctest-s-res-check.cmake
new file mode 100644
index 000000000..ceda72ea8
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/lotsoftests-ctest-s-res-check.cmake
@@ -0,0 +1 @@
+verify_ctest_resources()
diff --git a/Tests/RunCMake/CTestResourceAllocation/lotsoftests.cmake b/Tests/RunCMake/CTestResourceAllocation/lotsoftests.cmake
new file mode 100644
index 000000000..4c0a7a554
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/lotsoftests.cmake
@@ -0,0 +1,16 @@
+setup_resource_tests()
+
+add_resource_test(Test1 2 "widgets:8;2,widgets:2")
+add_resource_test(Test2 5 "fluxcapacitors:40")
+add_resource_test(Test3 1 "10,widgets:1,fluxcapacitors:2")
+add_resource_test(Test4 4 "fluxcapacitors:121")
+
+foreach(i RANGE 5 50)
+ add_resource_test(Test${i} 1 "2,widgets:1")
+endforeach()
+
+foreach(i RANGE 51 100)
+ add_resource_test(Test${i} 1 "2,transmogrifiers:2")
+endforeach()
+
+cleanup_resource_tests()
diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-check.cmake b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-check.cmake
new file mode 100644
index 000000000..321e9a2f8
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS "${RunCMake_TEST_BINARY_DIR}/ctresalloc.log")
+ set(RunCMake_TEST_FAILED "ctresalloc.log should not exist")
+endif()
diff --git a/Tests/RunCMake/ctest_memcheck/DummyAddressSanitizer-result.txt b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_memcheck/DummyAddressSanitizer-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-stderr.txt
new file mode 100644
index 000000000..41df5afad
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res-stderr.txt
@@ -0,0 +1,4 @@
+^Insufficient resources
+CMake Error at [^
+]*/Tests/RunCMake/CTestResourceAllocation/notenough1-ctest-s-res/test\.cmake:[0-9]+ \(message\):
+ Tests did not pass$
diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough1.cmake b/Tests/RunCMake/CTestResourceAllocation/notenough1.cmake
new file mode 100644
index 000000000..f820c378c
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/notenough1.cmake
@@ -0,0 +1,5 @@
+setup_resource_tests()
+
+add_resource_test(Test1 0 "fluxcapacitors:200")
+
+cleanup_resource_tests()
diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-check.cmake b/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-check.cmake
new file mode 100644
index 000000000..321e9a2f8
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS "${RunCMake_TEST_BINARY_DIR}/ctresalloc.log")
+ set(RunCMake_TEST_FAILED "ctresalloc.log should not exist")
+endif()
diff --git a/Tests/RunCMake/ctest_memcheck/DummyLeakSanitizer-result.txt b/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_memcheck/DummyLeakSanitizer-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-stderr.txt
new file mode 100644
index 000000000..6c2f554e5
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res-stderr.txt
@@ -0,0 +1,4 @@
+^Insufficient resources
+CMake Error at [^
+]*/Tests/RunCMake/CTestResourceAllocation/notenough2-ctest-s-res/test\.cmake:[0-9]+ \(message\):
+ Tests did not pass$
diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough2.cmake b/Tests/RunCMake/CTestResourceAllocation/notenough2.cmake
new file mode 100644
index 000000000..5b8177636
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/notenough2.cmake
@@ -0,0 +1,5 @@
+setup_resource_tests()
+
+add_resource_test(Test1 0 "terminators:2")
+
+cleanup_resource_tests()
diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-check.cmake b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-check.cmake
new file mode 100644
index 000000000..321e9a2f8
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS "${RunCMake_TEST_BINARY_DIR}/ctresalloc.log")
+ set(RunCMake_TEST_FAILED "ctresalloc.log should not exist")
+endif()
diff --git a/Tests/RunCMake/ctest_memcheck/DummyLeakSanitizerPrintDefects-result.txt b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_memcheck/DummyLeakSanitizerPrintDefects-result.txt
+++ b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-result.txt
diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt
new file mode 100644
index 000000000..82dfdefcf
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res-stderr.txt
@@ -0,0 +1,4 @@
+^Insufficient resources
+CMake Error at [^
+]*/Tests/RunCMake/CTestResourceAllocation/notenough3-ctest-s-res/test\.cmake:[0-9]+ \(message\):
+ Tests did not pass$
diff --git a/Tests/RunCMake/CTestResourceAllocation/notenough3.cmake b/Tests/RunCMake/CTestResourceAllocation/notenough3.cmake
new file mode 100644
index 000000000..ddf3a9cd5
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/notenough3.cmake
@@ -0,0 +1,5 @@
+setup_resource_tests()
+
+add_resource_test(Test1 0 "widgets:12")
+
+cleanup_resource_tests()
diff --git a/Tests/RunCMake/CTestResourceAllocation/process_count-ctest-s-res-check.cmake b/Tests/RunCMake/CTestResourceAllocation/process_count-ctest-s-res-check.cmake
new file mode 100644
index 000000000..ceda72ea8
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/process_count-ctest-s-res-check.cmake
@@ -0,0 +1 @@
+verify_ctest_resources()
diff --git a/Tests/RunCMake/CTestResourceAllocation/process_count.cmake b/Tests/RunCMake/CTestResourceAllocation/process_count.cmake
new file mode 100644
index 000000000..1457f8976
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/process_count.cmake
@@ -0,0 +1,5 @@
+setup_resource_tests()
+
+add_resource_test(Test1 1 "widgets:1")
+
+cleanup_resource_tests()
diff --git a/Tests/RunCMake/CTestResourceAllocation/resspec.json b/Tests/RunCMake/CTestResourceAllocation/resspec.json
new file mode 100644
index 000000000..48321ec77
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/resspec.json
@@ -0,0 +1,59 @@
+{
+ "version": {
+ "major": 1,
+ "minor": 0
+ },
+ "local": [
+ {
+ "widgets": [
+ {
+ "id": "0",
+ "slots": 4
+ },
+ {
+ "id": "1",
+ "slots": 2
+ },
+ {
+ "id": "2",
+ "slots": 4
+ },
+ {
+ "id": "3",
+ "slots": 8
+ },
+ {
+ "id": "4",
+ "slots": 1
+ },
+ {
+ "id": "5",
+ "slots": 1
+ },
+ {
+ "id": "6",
+ "slots": 1
+ },
+ {
+ "id": "7"
+ }
+ ],
+ "transmogrifiers": [
+ {
+ "id": "calvin",
+ "slots": 2
+ },
+ {
+ "id": "hobbes",
+ "slots": 2
+ }
+ ],
+ "fluxcapacitors": [
+ {
+ "id": "outatime",
+ "slots": 121
+ }
+ ]
+ }
+ ]
+}
diff --git a/Tests/RunCMake/CTestResourceAllocation/test.cmake.in b/Tests/RunCMake/CTestResourceAllocation/test.cmake.in
new file mode 100644
index 000000000..4b426f161
--- /dev/null
+++ b/Tests/RunCMake/CTestResourceAllocation/test.cmake.in
@@ -0,0 +1,23 @@
+set(CTEST_SITE "test-site")
+set(CTEST_BUILD_NAME "test-build-name")
+set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@")
+set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build")
+set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@")
+set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
+set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
+
+ctest_start(Experimental QUIET)
+ctest_configure(OPTIONS
+ "-DCTEST_RESOURCE_ALLOC_ENABLED=${CTEST_RESOURCE_ALLOC_ENABLED};-DCTRESALLOC_COMMAND=${CTRESALLOC_COMMAND}"
+ )
+ctest_build()
+
+if(CTEST_RESOURCE_ALLOC_ENABLED)
+ set(resspec RESOURCE_SPEC_FILE "@RunCMake_SOURCE_DIR@/resspec.json")
+endif()
+ctest_test(${resspec} RETURN_VALUE retval PARALLEL_LEVEL ${CTEST_PARALLEL} SCHEDULE_RANDOM ${CTEST_RANDOM})
+if(retval)
+ message(FATAL_ERROR "Tests did not pass")
+endif()
diff --git a/Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in b/Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in
deleted file mode 100644
index 58b11afaf..000000000
--- a/Tests/RunCMake/CTestTimeoutAfterMatch/CTestConfig.cmake.in
+++ /dev/null
@@ -1 +0,0 @@
-set(CTEST_PROJECT_NAME "TimeoutAfterMatch@CASE_NAME@")
diff --git a/Tests/RunCMake/CacheNewline/CMakeLists.txt b/Tests/RunCMake/CacheNewline/CMakeLists.txt
new file mode 100644
index 000000000..93ee9dfd5
--- /dev/null
+++ b/Tests/RunCMake/CacheNewline/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.5)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CacheNewline/CacheNewline-check.cmake b/Tests/RunCMake/CacheNewline/CacheNewline-check.cmake
new file mode 100644
index 000000000..6534f6386
--- /dev/null
+++ b/Tests/RunCMake/CacheNewline/CacheNewline-check.cmake
@@ -0,0 +1,16 @@
+set(CACHE_EXPECTED_FILE "${RunCMake_TEST_SOURCE_DIR}/cache-regex.txt")
+set(CACHE_ACTUAL_FILE "${RunCMake_BINARY_DIR}/CacheNewline-build/CMakeCache.txt")
+
+file(READ ${CACHE_EXPECTED_FILE} CACHE_EXPECTED)
+string(REGEX REPLACE "\r\n" "\n" CACHE_EXPECTED "${CACHE_EXPECTED}")
+string(REGEX REPLACE "\n+$" "" CACHE_EXPECTED "${CACHE_EXPECTED}")
+file(READ ${CACHE_ACTUAL_FILE} CACHE_ACTUAL)
+string(REGEX REPLACE "\r\n" "\n" CACHE_ACTUAL "${CACHE_ACTUAL}")
+string(REGEX REPLACE "\n+$" "" CACHE_ACTUAL "${CACHE_ACTUAL}")
+
+if(NOT "${CACHE_ACTUAL}" MATCHES "${CACHE_EXPECTED}")
+ set(RunCMake_TEST_FAILED "${CACHE_ACTUAL_FILE} does not match ${CACHE_EXPECTED_FILE}:
+
+CMakeCache.txt contents = [\n${CACHE_ACTUAL}\n]
+Expected = [\n${CACHE_EXPECTED}\n]")
+endif()
diff --git a/Tests/RunCMake/CacheNewline/CacheNewline-stderr.txt b/Tests/RunCMake/CacheNewline/CacheNewline-stderr.txt
new file mode 100644
index 000000000..726c65ce0
--- /dev/null
+++ b/Tests/RunCMake/CacheNewline/CacheNewline-stderr.txt
@@ -0,0 +1,2 @@
+CMake Warning:
+ Value of NEWLINE_VARIABLE contained a newline; truncating
diff --git a/Tests/RunCMake/CacheNewline/CacheNewline.cmake b/Tests/RunCMake/CacheNewline/CacheNewline.cmake
new file mode 100644
index 000000000..81851dbe0
--- /dev/null
+++ b/Tests/RunCMake/CacheNewline/CacheNewline.cmake
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.5)
+
+project(CacheNewlineTest NONE)
+
+set(NEWLINE_VARIABLE "a\nb" CACHE STRING "Offending entry")
diff --git a/Tests/RunCMake/CacheNewline/RunCMakeTest.cmake b/Tests/RunCMake/CacheNewline/RunCMakeTest.cmake
new file mode 100644
index 000000000..5e3d2d499
--- /dev/null
+++ b/Tests/RunCMake/CacheNewline/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(CacheNewline)
diff --git a/Tests/RunCMake/CacheNewline/cache-regex.txt b/Tests/RunCMake/CacheNewline/cache-regex.txt
new file mode 100644
index 000000000..b239dbc82
--- /dev/null
+++ b/Tests/RunCMake/CacheNewline/cache-regex.txt
@@ -0,0 +1,6 @@
+//Offending entry
+NEWLINE_VARIABLE:STRING=a
+# WARNING: Value of NEWLINE_VARIABLE contained a newline and was
+# truncated\. Original value:
+# a
+# \\nb
diff --git a/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake b/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake
index e14556944..b7d524ccf 100644
--- a/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake
@@ -8,6 +8,6 @@ run_cmake(not-supported-by-compiler)
run_cmake(save-to-result)
run_cmake(cmp0069-is-old)
-if(RunCMake_GENERATOR MATCHES "^Visual Studio ")
+if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ")
run_cmake(not-supported-by-generator)
endif()
diff --git a/Tests/RunCMake/CheckModules/CMP0075-stderr.txt b/Tests/RunCMake/CheckModules/CMP0075-stderr.txt
new file mode 100644
index 000000000..960fe9444
--- /dev/null
+++ b/Tests/RunCMake/CheckModules/CMP0075-stderr.txt
@@ -0,0 +1,50 @@
+^CMake Warning \(dev\) at [^
+]*/Modules/CheckIncludeFile.cmake:[0-9]+ \(message\):
+ Policy CMP0075 is not set: Include file check macros honor
+ CMAKE_REQUIRED_LIBRARIES. Run "cmake --help-policy CMP0075" for policy
+ details. Use the cmake_policy command to set the policy and suppress this
+ warning.
+
+ CMAKE_REQUIRED_LIBRARIES is set to:
+
+ does_not_exist
+
+ For compatibility with CMake 3.11 and below this check is ignoring it.
+Call Stack \(most recent call first\):
+ CMP0075.cmake:11 \(check_include_file\)
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
++
+CMake Warning \(dev\) at [^
+]*/Modules/CheckIncludeFileCXX.cmake:[0-9]+ \(message\):
+ Policy CMP0075 is not set: Include file check macros honor
+ CMAKE_REQUIRED_LIBRARIES. Run "cmake --help-policy CMP0075" for policy
+ details. Use the cmake_policy command to set the policy and suppress this
+ warning.
+
+ CMAKE_REQUIRED_LIBRARIES is set to:
+
+ does_not_exist
+
+ For compatibility with CMake 3.11 and below this check is ignoring it.
+Call Stack \(most recent call first\):
+ CMP0075.cmake:26 \(check_include_file_cxx\)
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
++
+CMake Warning \(dev\) at [^
+]*/Modules/CheckIncludeFiles.cmake:[0-9]+ \(message\):
+ Policy CMP0075 is not set: Include file check macros honor
+ CMAKE_REQUIRED_LIBRARIES. Run "cmake --help-policy CMP0075" for policy
+ details. Use the cmake_policy command to set the policy and suppress this
+ warning.
+
+ CMAKE_REQUIRED_LIBRARIES is set to:
+
+ does_not_exist
+
+ For compatibility with CMake 3.11 and below this check is ignoring it.
+Call Stack \(most recent call first\):
+ CMP0075.cmake:41 \(check_include_files\)
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/CheckModules/CMP0075.cmake b/Tests/RunCMake/CheckModules/CMP0075.cmake
new file mode 100644
index 000000000..4a3b7204a
--- /dev/null
+++ b/Tests/RunCMake/CheckModules/CMP0075.cmake
@@ -0,0 +1,124 @@
+enable_language(C)
+enable_language(CXX)
+include(CheckIncludeFile)
+include(CheckIncludeFileCXX)
+include(CheckIncludeFiles)
+
+set(CMAKE_REQUIRED_LIBRARIES does_not_exist)
+
+#============================================================================
+
+check_include_file("stddef.h" HAVE_STDDEF_H_1)
+if(NOT HAVE_STDDEF_H_1)
+ message(SEND_ERROR "HAVE_STDDEF_H_1 failed but should have passed.")
+endif()
+if(NOT _CIF_CMP0075_WARNED)
+ message(SEND_ERROR "HAVE_STDDEF_H_1 did not warn but should have")
+endif()
+check_include_file("stddef.h" HAVE_STDDEF_H_2) # second does not warn
+if(NOT HAVE_STDDEF_H_2)
+ message(SEND_ERROR "HAVE_STDDEF_H_2 failed but should have passed.")
+endif()
+unset(_CIF_CMP0075_WARNED)
+
+#----------------------------------------------------------------------------
+
+check_include_file_cxx("stddef.h" HAVE_STDDEF_H_CXX_1)
+if(NOT HAVE_STDDEF_H_CXX_1)
+ message(SEND_ERROR "HAVE_STDDEF_H_CXX_1 failed but should have passed.")
+endif()
+if(NOT _CIF_CMP0075_WARNED)
+ message(SEND_ERROR "HAVE_STDDEF_H_CXX_1 did not warn but should have")
+endif()
+check_include_file_cxx("stddef.h" HAVE_STDDEF_H_CXX_2) # second does not warn
+if(NOT HAVE_STDDEF_H_CXX_2)
+ message(SEND_ERROR "HAVE_STDDEF_H_CXX_2 failed but should have passed.")
+endif()
+unset(_CIF_CMP0075_WARNED)
+
+#----------------------------------------------------------------------------
+
+check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H_1)
+if(NOT HAVE_STDLIB_H_1)
+ message(SEND_ERROR "HAVE_STDLIB_H_1 failed but should have passed.")
+endif()
+if(NOT _CIF_CMP0075_WARNED)
+ message(SEND_ERROR "HAVE_STDLIB_H_1 did not warn but should have")
+endif()
+check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H_2) # second does not warn
+if(NOT HAVE_STDLIB_H_2)
+ message(SEND_ERROR "HAVE_STDLIB_H_2 failed but should have passed.")
+endif()
+unset(_CIF_CMP0075_WARNED)
+
+#============================================================================
+cmake_policy(SET CMP0075 OLD)
+# These should not warn.
+# These should pass the checks due to ignoring 'does_not_exist'.
+
+check_include_file("stddef.h" HAVE_STDDEF_H_3)
+if(NOT HAVE_STDDEF_H_3)
+ message(SEND_ERROR "HAVE_STDDEF_H_3 failed but should have passed.")
+endif()
+if(_CIF_CMP0075_WARNED)
+ message(SEND_ERROR "HAVE_STDDEF_H_3 warned but should not have")
+endif()
+unset(_CIF_CMP0075_WARNED)
+
+#----------------------------------------------------------------------------
+
+check_include_file_cxx("stddef.h" HAVE_STDDEF_H_CXX_3)
+if(NOT HAVE_STDDEF_H_CXX_3)
+ message(SEND_ERROR "HAVE_STDDEF_H_CXX_3 failed but should have passed.")
+endif()
+if(_CIF_CMP0075_WARNED)
+ message(SEND_ERROR "HAVE_STDDEF_H_CXX_3 warned but should not have")
+endif()
+unset(_CIF_CMP0075_WARNED)
+
+#----------------------------------------------------------------------------
+
+check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H_3)
+if(NOT HAVE_STDLIB_H_3)
+ message(SEND_ERROR "HAVE_STDLIB_H_3 failed but should have passed.")
+endif()
+if(_CIF_CMP0075_WARNED)
+ message(SEND_ERROR "HAVE_STDLIB_H_3 warned but should not have")
+endif()
+unset(_CIF_CMP0075_WARNED)
+
+#============================================================================
+cmake_policy(SET CMP0075 NEW)
+# These should not warn.
+# These should fail the checks due to requiring 'does_not_exist'.
+
+check_include_file("stddef.h" HAVE_STDDEF_H_4)
+if(HAVE_STDDEF_H_4)
+ message(SEND_ERROR "HAVE_STDDEF_H_4 passed but should have failed.")
+endif()
+if(_CIF_CMP0075_WARNED)
+ message(SEND_ERROR "HAVE_STDDEF_H_4 warned but should not have")
+endif()
+unset(_CIF_CMP0075_WARNED)
+
+#----------------------------------------------------------------------------
+
+check_include_file_cxx("stddef.h" HAVE_STDDEF_H_CXX_4)
+if(HAVE_STDDEF_H_CXX_4)
+ message(SEND_ERROR "HAVE_STDDEF_H_CXX_4 passed but should have failed.")
+endif()
+if(_CIF_CMP0075_WARNED)
+ message(SEND_ERROR "HAVE_STDDEF_H_CXX_4 warned but should not have")
+endif()
+unset(_CIF_CMP0075_WARNED)
+
+#----------------------------------------------------------------------------
+
+check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H_4)
+if(HAVE_STDLIB_H_4)
+ message(SEND_ERROR "HAVE_STDLIB_H_4 passed but should have failed.")
+endif()
+if(_CIF_CMP0075_WARNED)
+ message(SEND_ERROR "HAVE_STDLIB_H_4 warned but should not have")
+endif()
+unset(_CIF_CMP0075_WARNED)
diff --git a/Tests/RunCMake/list/REVERSE-NotList-result.txt b/Tests/RunCMake/CheckModules/CheckIncludeFilesMissingLanguage-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/list/REVERSE-NotList-result.txt
+++ b/Tests/RunCMake/CheckModules/CheckIncludeFilesMissingLanguage-result.txt
diff --git a/Tests/RunCMake/CheckModules/CheckIncludeFilesMissingLanguage-stderr.txt b/Tests/RunCMake/CheckModules/CheckIncludeFilesMissingLanguage-stderr.txt
new file mode 100644
index 000000000..36c28f9d2
--- /dev/null
+++ b/Tests/RunCMake/CheckModules/CheckIncludeFilesMissingLanguage-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at .*/Modules/CheckIncludeFiles.cmake:[0-9]+. \(message\):
+ No languages listed for LANGUAGE option.
+
+ Supported languages: C, CXX.
+
+Call Stack \(most recent call first\):
+ CheckIncludeFilesMissingLanguage.cmake:[0-9]+ \(check_include_files\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/CheckModules/CheckIncludeFilesMissingLanguage.cmake b/Tests/RunCMake/CheckModules/CheckIncludeFilesMissingLanguage.cmake
new file mode 100644
index 000000000..59accb084
--- /dev/null
+++ b/Tests/RunCMake/CheckModules/CheckIncludeFilesMissingLanguage.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+include(CheckIncludeFiles)
+check_include_files("stddef.h;stdlib.h" HAVE_MISSING_ARGUMENT_H LANGUAGE)
diff --git a/Tests/RunCMake/CheckModules/CheckIncludeFilesOk.cmake b/Tests/RunCMake/CheckModules/CheckIncludeFilesOk.cmake
new file mode 100644
index 000000000..0891ec69a
--- /dev/null
+++ b/Tests/RunCMake/CheckModules/CheckIncludeFilesOk.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+enable_language(CXX)
+include(CheckIncludeFiles)
+check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H)
+check_include_files("stddef.h;stdlib.h" HAVE_STDLIB_H2 LANGUAGE C)
+check_include_files("cstddef;cstdlib" HAVE_CSTDLIB_H LANGUAGE CXX)
diff --git a/Tests/RunCMake/CheckModules/CheckIncludeFilesOkNoC.cmake b/Tests/RunCMake/CheckModules/CheckIncludeFilesOkNoC.cmake
new file mode 100644
index 000000000..a1d2843df
--- /dev/null
+++ b/Tests/RunCMake/CheckModules/CheckIncludeFilesOkNoC.cmake
@@ -0,0 +1,4 @@
+enable_language(CXX)
+include(CheckIncludeFiles)
+check_include_files("cstddef;cstdlib" HAVE_CSTDLIB_H3 LANGUAGE CXX)
+check_include_files("cstddef;cstdlib" HAVE_CSTDLIB_H4)
diff --git a/Tests/RunCMake/list/SORT-NotList-result.txt b/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownArgument-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/list/SORT-NotList-result.txt
+++ b/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownArgument-result.txt
diff --git a/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownArgument-stderr.txt b/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownArgument-stderr.txt
new file mode 100644
index 000000000..098da7913
--- /dev/null
+++ b/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownArgument-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at .*/Modules/CheckIncludeFiles.cmake:[0-9]+. \(message\):
+ Unknown arguments:
+
+ FOOBAR
+
+Call Stack \(most recent call first\):
+ CheckIncludeFilesUnknownArgument.cmake:[0-9]+ \(check_include_files\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownArgument.cmake b/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownArgument.cmake
new file mode 100644
index 000000000..dfc2b932c
--- /dev/null
+++ b/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownArgument.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+include(CheckIncludeFiles)
+check_include_files("stddef.h;stdlib.h" HAVE_UNKNOWN_ARGUMENT_H FOOBAR)
diff --git a/Tests/RunCMake/list/SORT-TooManyArguments-result.txt b/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownLanguage-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/list/SORT-TooManyArguments-result.txt
+++ b/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownLanguage-result.txt
diff --git a/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownLanguage-stderr.txt b/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownLanguage-stderr.txt
new file mode 100644
index 000000000..5d4a9ecb2
--- /dev/null
+++ b/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownLanguage-stderr.txt
@@ -0,0 +1,10 @@
+CMake Error at .*/Modules/CheckIncludeFiles.cmake:[0-9]+. \(message\):
+ Unknown language:
+
+ FOOBAR
+
+ Supported languages: C, CXX.
+
+Call Stack \(most recent call first\):
+ CheckIncludeFilesUnknownLanguage.cmake:[0-9]+ \(check_include_files\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownLanguage.cmake b/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownLanguage.cmake
new file mode 100644
index 000000000..3a77cf93f
--- /dev/null
+++ b/Tests/RunCMake/CheckModules/CheckIncludeFilesUnknownLanguage.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+include(CheckIncludeFiles)
+check_include_files("stddef.h;stdlib.h" HAVE_UNKNOWN_ARGUMENT_H LANGUAGE FOOBAR)
diff --git a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake
index 5b4e57edc..8a046e14c 100644
--- a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake
@@ -1,5 +1,7 @@
include(RunCMake)
+run_cmake(CMP0075)
+
run_cmake(CheckStructHasMemberOk)
run_cmake(CheckStructHasMemberUnknownLanguage)
run_cmake(CheckStructHasMemberMissingLanguage)
@@ -14,3 +16,9 @@ run_cmake(CheckTypeSizeUnknownArgument)
run_cmake(CheckTypeSizeMixedArgs)
run_cmake(CheckTypeSizeOkNoC)
+
+run_cmake(CheckIncludeFilesOk)
+run_cmake(CheckIncludeFilesOkNoC)
+run_cmake(CheckIncludeFilesMissingLanguage)
+run_cmake(CheckIncludeFilesUnknownArgument)
+run_cmake(CheckIncludeFilesUnknownLanguage)
diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget-result.txt b/Tests/RunCMake/CommandLine/B-no-arg-result.txt
index d00491fd7..d00491fd7 100644
--- a/Tests/RunCMake/target_link_libraries/SubDirTarget-result.txt
+++ b/Tests/RunCMake/CommandLine/B-no-arg-result.txt
diff --git a/Tests/RunCMake/CommandLine/B-no-arg-stderr.txt b/Tests/RunCMake/CommandLine/B-no-arg-stderr.txt
new file mode 100644
index 000000000..2309c5edd
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/B-no-arg-stderr.txt
@@ -0,0 +1 @@
+CMake Error: No build directory specified for -B
diff --git a/Tests/RunCMake/CommandLine/B-no-arg2-result.txt b/Tests/RunCMake/CommandLine/B-no-arg2-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/B-no-arg2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/B-no-arg2-stderr.txt b/Tests/RunCMake/CommandLine/B-no-arg2-stderr.txt
new file mode 100644
index 000000000..2309c5edd
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/B-no-arg2-stderr.txt
@@ -0,0 +1 @@
+CMake Error: No build directory specified for -B
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-stderr.txt
new file mode 100644
index 000000000..e73d76020
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-bad-number-stderr.txt
@@ -0,0 +1,3 @@
+^'--parallel' invalid number '12ab' given\.
++
+Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-stderr.txt
new file mode 100644
index 000000000..3c2c808e9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-stderr.txt
@@ -0,0 +1 @@
+(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-trailing--target-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-trailing--target-stderr.txt
new file mode 100644
index 000000000..3c2c808e9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-good-number-trailing--target-stderr.txt
@@ -0,0 +1 @@
+(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-large-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-large-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-large-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-large-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-large-stderr.txt
new file mode 100644
index 000000000..94fc15732
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-large-stderr.txt
@@ -0,0 +1,3 @@
+^The <jobs> value is too large\.
++
+Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-stderr.txt
new file mode 100644
index 000000000..3c2c808e9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-stderr.txt
@@ -0,0 +1 @@
+(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-trailing--target-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-trailing--target-stderr.txt
new file mode 100644
index 000000000..3c2c808e9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-number-trailing--target-stderr.txt
@@ -0,0 +1 @@
+(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-stderr.txt
new file mode 100644
index 000000000..e73d76020
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-bad-number-stderr.txt
@@ -0,0 +1,3 @@
+^'--parallel' invalid number '12ab' given\.
++
+Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-good-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-good-number-stderr.txt
new file mode 100644
index 000000000..3c2c808e9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-good-number-stderr.txt
@@ -0,0 +1 @@
+(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-good-number-trailing--target-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-good-number-trailing--target-stderr.txt
new file mode 100644
index 000000000..3c2c808e9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-no-space-good-number-trailing--target-stderr.txt
@@ -0,0 +1 @@
+(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-zero-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-zero-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-zero-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build--parallel-zero-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-zero-stderr.txt
new file mode 100644
index 000000000..8ed4fee99
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build--parallel-zero-stderr.txt
@@ -0,0 +1,3 @@
+^The <jobs> value requires a positive integer argument\.
++
+Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-stderr.txt
new file mode 100644
index 000000000..c81008786
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-bad-number-stderr.txt
@@ -0,0 +1,3 @@
+^'-j' invalid number '12ab' given\.
++
+Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-stderr.txt
new file mode 100644
index 000000000..3c2c808e9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-stderr.txt
@@ -0,0 +1 @@
+(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-trailing--target-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-trailing--target-stderr.txt
new file mode 100644
index 000000000..3c2c808e9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-good-number-trailing--target-stderr.txt
@@ -0,0 +1 @@
+(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-stderr.txt
new file mode 100644
index 000000000..94fc15732
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-large-stderr.txt
@@ -0,0 +1,3 @@
+^The <jobs> value is too large\.
++
+Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-stderr.txt
new file mode 100644
index 000000000..3c2c808e9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-stderr.txt
@@ -0,0 +1 @@
+(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-trailing--target-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-trailing--target-stderr.txt
new file mode 100644
index 000000000..3c2c808e9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-number-trailing--target-stderr.txt
@@ -0,0 +1 @@
+(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-stderr.txt
new file mode 100644
index 000000000..c81008786
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-bad-number-stderr.txt
@@ -0,0 +1,3 @@
+^'-j' invalid number '12ab' given\.
++
+Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-good-number-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-good-number-stderr.txt
new file mode 100644
index 000000000..3c2c808e9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-good-number-stderr.txt
@@ -0,0 +1 @@
+(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-good-number-trailing--target-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-good-number-trailing--target-stderr.txt
new file mode 100644
index 000000000..3c2c808e9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-no-space-good-number-trailing--target-stderr.txt
@@ -0,0 +1 @@
+(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-stderr.txt
new file mode 100644
index 000000000..8ed4fee99
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-jobs-zero-stderr.txt
@@ -0,0 +1,3 @@
+^The <jobs> value requires a positive integer argument\.
++
+Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-jobs-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-jobs-stderr.txt
new file mode 100644
index 000000000..3c2c808e9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-jobs-stderr.txt
@@ -0,0 +1 @@
+(^$|^Warning: .* does not support parallel builds\. Ignoring parallel build command line option\.)
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-stderr.txt
deleted file mode 100644
index f2cbaa622..000000000
--- a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-stderr.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-^'--target' may not be specified more than once\.
-+
-Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-stderr.txt
new file mode 100644
index 000000000..40d9bec84
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-first-stderr.txt
@@ -0,0 +1,2 @@
+^Error: Building 'clean' and other targets together is not supported\.
+Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-result.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-stderr.txt b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-stderr.txt
new file mode 100644
index 000000000..40d9bec84
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/BuildDir--build-multiple-targets-with-clean-second-stderr.txt
@@ -0,0 +1,2 @@
+^Error: Building 'clean' and other targets together is not supported\.
+Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\]
diff --git a/Tests/RunCMake/CommandLine/C-no-file-stderr.txt b/Tests/RunCMake/CommandLine/C-no-file-stderr.txt
index 5315f5904..b65a3498e 100644
--- a/Tests/RunCMake/CommandLine/C-no-file-stderr.txt
+++ b/Tests/RunCMake/CommandLine/C-no-file-stderr.txt
@@ -1,3 +1,3 @@
-^CMake Error: Error processing file: nosuchcachefile.txt
-CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/C-no-file-build/nosuchcachefile.txt" does not exist.
+^CMake Error: Error processing file: .*/Tests/RunCMake/CommandLine/C-no-file-build/nosuchcachefile.txt
+CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/C-no-file-build" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.$
diff --git a/Tests/RunCMake/CommandLine/C_basic-stderr.txt b/Tests/RunCMake/CommandLine/C_basic-stderr.txt
new file mode 100644
index 000000000..62d0cd5fe
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_basic-stderr.txt
@@ -0,0 +1,4 @@
+initial-cache.txt: CMAKE_SOURCE_DIR: .*/Tests/RunCMake/CommandLine
+initial-cache.txt: CMAKE_BINARY_DIR: .*/Tests/RunCMake/CommandLine/C_basic-build
+CMakeLists.txt: INITIAL_SOURCE_DIR: .*/Tests/RunCMake/CommandLine
+CMakeLists.txt: INITIAL_BINARY_DIR: .*/Tests/RunCMake/CommandLine/C_basic-build
diff --git a/Tests/RunCMake/CommandLine/C_basic-stdout.txt b/Tests/RunCMake/CommandLine/C_basic-stdout.txt
new file mode 100644
index 000000000..74a938e91
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_basic-stdout.txt
@@ -0,0 +1 @@
+loading initial cache file ../C_basic_initial-cache.txt
diff --git a/Tests/RunCMake/CommandLine/C_basic.cmake b/Tests/RunCMake/CommandLine/C_basic.cmake
new file mode 100644
index 000000000..1a565935b
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_basic.cmake
@@ -0,0 +1,2 @@
+message("CMakeLists.txt: INITIAL_SOURCE_DIR: ${INITIAL_SOURCE_DIR}")
+message("CMakeLists.txt: INITIAL_BINARY_DIR: ${INITIAL_BINARY_DIR}")
diff --git a/Tests/RunCMake/CommandLine/C_basic_fullpath-stderr.txt b/Tests/RunCMake/CommandLine/C_basic_fullpath-stderr.txt
new file mode 100644
index 000000000..f382a017b
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_basic_fullpath-stderr.txt
@@ -0,0 +1,4 @@
+initial-cache.txt: CMAKE_SOURCE_DIR: .*/Tests/RunCMake/CommandLine
+initial-cache.txt: CMAKE_BINARY_DIR: .*/Tests/RunCMake/CommandLine/C_basic_fullpath-build
+CMakeLists.txt: INITIAL_SOURCE_DIR: .*/Tests/RunCMake/CommandLine
+CMakeLists.txt: INITIAL_BINARY_DIR: .*/Tests/RunCMake/CommandLine/C_basic_fullpath-build
diff --git a/Tests/RunCMake/CommandLine/C_basic_fullpath-stdout.txt b/Tests/RunCMake/CommandLine/C_basic_fullpath-stdout.txt
new file mode 100644
index 000000000..32724f59f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_basic_fullpath-stdout.txt
@@ -0,0 +1 @@
+loading initial cache file .*/Tests/RunCMake/CommandLine/C_basic_initial-cache.txt
diff --git a/Tests/RunCMake/CommandLine/C_basic_fullpath.cmake b/Tests/RunCMake/CommandLine/C_basic_fullpath.cmake
new file mode 100644
index 000000000..1a565935b
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_basic_fullpath.cmake
@@ -0,0 +1,2 @@
+message("CMakeLists.txt: INITIAL_SOURCE_DIR: ${INITIAL_SOURCE_DIR}")
+message("CMakeLists.txt: INITIAL_BINARY_DIR: ${INITIAL_BINARY_DIR}")
diff --git a/Tests/RunCMake/CommandLine/C_basic_initial-cache.txt b/Tests/RunCMake/CommandLine/C_basic_initial-cache.txt
new file mode 100644
index 000000000..e7a8ac95f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_basic_initial-cache.txt
@@ -0,0 +1,5 @@
+set(INITIAL_SOURCE_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH "defined in initial.cmake")
+set(INITIAL_BINARY_DIR "${CMAKE_BINARY_DIR}" CACHE PATH "defined in initial.cmake")
+
+message("initial-cache.txt: CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
+message("initial-cache.txt: CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
diff --git a/Tests/RunCMake/CommandLine/C_buildsrcdir-stderr.txt b/Tests/RunCMake/CommandLine/C_buildsrcdir-stderr.txt
new file mode 100644
index 000000000..4720a6f68
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_buildsrcdir-stderr.txt
@@ -0,0 +1,8 @@
+initial-cache.txt: CMAKE_SOURCE_DIR: .*/C_buildsrcdir/src
+initial-cache.txt: CMAKE_BINARY_DIR: .*/ExplicitDirs-build/DummyBuildDir
+PreLoad.cmake: CMAKE_SOURCE_DIR: .*/C_buildsrcdir/src
+PreLoad.cmake: CMAKE_BINARY_DIR: .*/ExplicitDirs-build/DummyBuildDir
+CMakeLists.txt: INITIAL_SOURCE_DIR: .*/C_buildsrcdir/src
+CMakeLists.txt: INITIAL_BINARY_DIR: .*/ExplicitDirs-build/DummyBuildDir
+CMakeLists.txt: PRELOAD_SOURCE_DIR: .*/C_buildsrcdir/src
+CMakeLists.txt: PRELOAD_BINARY_DIR: .*/ExplicitDirs-build/DummyBuildDir
diff --git a/Tests/RunCMake/CommandLine/C_buildsrcdir-stdout.txt b/Tests/RunCMake/CommandLine/C_buildsrcdir-stdout.txt
new file mode 100644
index 000000000..862cfeb14
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_buildsrcdir-stdout.txt
@@ -0,0 +1,2 @@
+loading initial cache file .*initial-cache.txt
+.*
diff --git a/Tests/RunCMake/CommandLine/C_buildsrcdir.cmake b/Tests/RunCMake/CommandLine/C_buildsrcdir.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_buildsrcdir.cmake
diff --git a/Tests/RunCMake/CommandLine/C_buildsrcdir/initial-cache.txt b/Tests/RunCMake/CommandLine/C_buildsrcdir/initial-cache.txt
new file mode 100644
index 000000000..adc125ba2
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_buildsrcdir/initial-cache.txt
@@ -0,0 +1,6 @@
+# Used to verify that the values match what is passed via -S and -B, and are retained in cache.
+set(INITIAL_SOURCE_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH "defined in initial.cmake")
+set(INITIAL_BINARY_DIR "${CMAKE_BINARY_DIR}" CACHE PATH "defined in initial.cmake")
+
+message("initial-cache.txt: CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
+message("initial-cache.txt: CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
diff --git a/Tests/RunCMake/CommandLine/C_buildsrcdir/src/CMakeLists.txt b/Tests/RunCMake/CommandLine/C_buildsrcdir/src/CMakeLists.txt
new file mode 100644
index 000000000..4893fe711
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_buildsrcdir/src/CMakeLists.txt
@@ -0,0 +1,6 @@
+project(C_buildsrcdir)
+
+message("CMakeLists.txt: INITIAL_SOURCE_DIR: ${INITIAL_SOURCE_DIR}")
+message("CMakeLists.txt: INITIAL_BINARY_DIR: ${INITIAL_BINARY_DIR}")
+message("CMakeLists.txt: PRELOAD_SOURCE_DIR: ${PRELOAD_SOURCE_DIR}")
+message("CMakeLists.txt: PRELOAD_BINARY_DIR: ${PRELOAD_BINARY_DIR}")
diff --git a/Tests/RunCMake/CommandLine/C_buildsrcdir/src/PreLoad.cmake b/Tests/RunCMake/CommandLine/C_buildsrcdir/src/PreLoad.cmake
new file mode 100644
index 000000000..519921928
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/C_buildsrcdir/src/PreLoad.cmake
@@ -0,0 +1,6 @@
+# Used to verify that the values match what is passed via -S and -B, and are retained in cache.
+message("PreLoad.cmake: CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
+message("PreLoad.cmake: CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
+
+set(PRELOAD_BINARY_DIR "${CMAKE_BINARY_DIR}" CACHE PATH "value of cmake_binary_dir during preload")
+set(PRELOAD_SOURCE_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH "value of cmake_source_dir during preload")
diff --git a/Tests/RunCMake/CommandLine/Cno-file-result.txt b/Tests/RunCMake/CommandLine/Cno-file-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Cno-file-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Cno-file-stderr.txt b/Tests/RunCMake/CommandLine/Cno-file-stderr.txt
new file mode 100644
index 000000000..416686cd5
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Cno-file-stderr.txt
@@ -0,0 +1,3 @@
+^CMake Error: Error processing file: .*/Tests/RunCMake/CommandLine/Cno-file-build/nosuchcachefile.txt
+CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/Cno-file-build" does not appear to contain CMakeLists.txt.
+Specify --help for usage, or press the help button on the CMake GUI.$
diff --git a/Tests/RunCMake/CommandLine/D-no-src-result.txt b/Tests/RunCMake/CommandLine/D-no-src-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/D-no-src-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/D-no-src-stderr.txt b/Tests/RunCMake/CommandLine/D-no-src-stderr.txt
new file mode 100644
index 000000000..b5ac69c3e
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/D-no-src-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/D-no-src-build" does not appear to contain CMakeLists.txt.
+Specify --help for usage, or press the help button on the CMake GUI.$
diff --git a/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-ON-stderr.txt b/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-ON-stderr.txt
deleted file mode 100644
index 2f2cbd3c6..000000000
--- a/Tests/RunCMake/CommandLine/DeprecateVS8-WARN-ON-stderr.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-^CMake Warning:
- The "Visual Studio 8 2005" generator is deprecated and will be removed in a
- future version of CMake.
-
- Add CMAKE_WARN_VS8=OFF to the cache to disable this warning.$
diff --git a/Tests/RunCMake/CommandLine/Dno-src-result.txt b/Tests/RunCMake/CommandLine/Dno-src-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Dno-src-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Dno-src-stderr.txt b/Tests/RunCMake/CommandLine/Dno-src-stderr.txt
new file mode 100644
index 000000000..402c71409
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Dno-src-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/Dno-src-build" does not appear to contain CMakeLists.txt.
+Specify --help for usage, or press the help button on the CMake GUI.$
diff --git a/Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-result.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-stderr.txt
index 338f7c4e6..338f7c4e6 100644
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-bad-iwyu-stderr.txt
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-bad-iwyu-stderr.txt
diff --git a/Tests/RunCMake/CommandLine/E___run_co_compile-no----result.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no----result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no----result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E___run_co_compile-no----stderr.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no----stderr.txt
new file mode 100644
index 000000000..f0597d2cf
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no----stderr.txt
@@ -0,0 +1 @@
+^__run_co_compile given unknown argument: command-does-not-exist$
diff --git a/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-result.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-stderr.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-stderr.txt
new file mode 100644
index 000000000..bba846e41
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no-cc-stderr.txt
@@ -0,0 +1 @@
+^__run_co_compile missing compile command after --$
diff --git a/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-result.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-stderr.txt
new file mode 100644
index 000000000..a7fbad667
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E___run_co_compile-no-iwyu-stderr.txt
@@ -0,0 +1,6 @@
+^__run_co_compile missing command to run. Looking for one or more of the following:
+--cppcheck=
+--cpplint=
+--iwyu=
+--lwyu=
+--tidy=
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt
deleted file mode 100644
index c251adf00..000000000
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no----stderr.txt
+++ /dev/null
@@ -1 +0,0 @@
-^__run_iwyu given unknown argument: command-does-not-exist$
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt
deleted file mode 100644
index 1998abb22..000000000
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-cc-stderr.txt
+++ /dev/null
@@ -1 +0,0 @@
-^__run_iwyu missing compile command after --$
diff --git a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt b/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt
deleted file mode 100644
index 35f50b76b..000000000
--- a/Tests/RunCMake/CommandLine/E___run_iwyu-no-iwyu-stderr.txt
+++ /dev/null
@@ -1 +0,0 @@
-^__run_iwyu missing --cpplint=, --iwyu=, --lwyu=, and/or --tidy=$
diff --git a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt
index 6c5ea44b3..b4b170ef2 100644
--- a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt
+++ b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt
@@ -1 +1 @@
-^{.*}$
+^{"fileApi":{"requests":\[{"kind":"codemodel","version":\[{"major":2,"minor":0}]},{"kind":"cache","version":\[{"major":2,"minor":0}]},{"kind":"cmakeFiles","version":\[{"major":1,"minor":0}]}]},"generators":\[.*\],"serverMode":true,"version":{.*}}$
diff --git a/Tests/RunCMake/CommandLine/E_compare_files-different-eol-result.txt b/Tests/RunCMake/CommandLine/E_compare_files-different-eol-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_compare_files-different-eol-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_compare_files-different-eol-stderr.txt b/Tests/RunCMake/CommandLine/E_compare_files-different-eol-stderr.txt
new file mode 100644
index 000000000..4729ccb8f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_compare_files-different-eol-stderr.txt
@@ -0,0 +1 @@
+^Files ".*/compare_files/lf" to ".*/compare_files/crlf" are different.$
diff --git a/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-result.txt b/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-stderr.txt b/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-stderr.txt
new file mode 100644
index 000000000..8a9ca81f8
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_compare_files-ignore-eol-nonexistent-stderr.txt
@@ -0,0 +1 @@
+^Files "nonexistent_a" to "nonexistent_b" are different.$
diff --git a/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake b/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake
index d7e652de7..5df5f2fb7 100644
--- a/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake
+++ b/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake
@@ -1,6 +1,10 @@
-if(NOT IS_SYMLINK ${RunCMake_TEST_BINARY_DIR}/L)
- set(RunCMake_TEST_FAILED "Symlink 'L' incorrectly not created!")
-endif()
-if(EXISTS ${RunCMake_TEST_BINARY_DIR}/L)
- set(RunCMake_TEST_FAILED "Symlink 'L' not broken!")
+if(${actual_stderr_var} MATCHES "operation not permitted")
+ unset(msg)
+else()
+ if(NOT IS_SYMLINK ${RunCMake_TEST_BINARY_DIR}/L)
+ set(RunCMake_TEST_FAILED "Symlink 'L' incorrectly not created!")
+ endif()
+ if(EXISTS ${RunCMake_TEST_BINARY_DIR}/L)
+ set(RunCMake_TEST_FAILED "Symlink 'L' not broken!")
+ endif()
endif()
diff --git a/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake b/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake
index c078ae8fc..d37df0169 100644
--- a/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake
+++ b/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake
@@ -1,3 +1,7 @@
-if(NOT IS_DIRECTORY ${RunCMake_TEST_BINARY_DIR}/L)
- set(RunCMake_TEST_FAILED "Symlink 'L' not replaced correctly!")
+if(${actual_stderr_var} MATCHES "operation not permitted")
+ unset(msg)
+else()
+ if(NOT IS_DIRECTORY ${RunCMake_TEST_BINARY_DIR}/L)
+ set(RunCMake_TEST_FAILED "Symlink 'L' not replaced correctly!")
+ endif()
endif()
diff --git a/Tests/RunCMake/CommandLine/E_false-extraargs-result.txt b/Tests/RunCMake/CommandLine/E_false-extraargs-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_false-extraargs-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_false-result.txt b/Tests/RunCMake/CommandLine/E_false-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_false-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_make_directory-directory-with-parent-check.cmake b/Tests/RunCMake/CommandLine/E_make_directory-directory-with-parent-check.cmake
new file mode 100644
index 000000000..ea3d161af
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_make_directory-directory-with-parent-check.cmake
@@ -0,0 +1,3 @@
+if(NOT IS_DIRECTORY ${out}/parent/child)
+ set(RunCMake_TEST_FAILED "child directory was not created")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_make_directory-three-directories-check.cmake b/Tests/RunCMake/CommandLine/E_make_directory-three-directories-check.cmake
new file mode 100644
index 000000000..c1e84744a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_make_directory-three-directories-check.cmake
@@ -0,0 +1,6 @@
+if(NOT IS_DIRECTORY ${out}/d1)
+ set(RunCMake_TEST_FAILED "directory d1 was not created")
+endif()
+if(NOT IS_DIRECTORY ${out}/d2)
+ set(RunCMake_TEST_FAILED "directory d2 was not created")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-result.txt b/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_make_directory-three-directories-and-file-stderr.txt b/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-stderr.txt
index 08a9428f4..08a9428f4 100644
--- a/Tests/RunCMake/CommandLine/E_make_directory-three-directories-and-file-stderr.txt
+++ b/Tests/RunCMake/CommandLine/E_make_directory-two-directories-and-file-stderr.txt
diff --git a/Tests/RunCMake/CommandLine/E_md5sum-dir-result.txt b/Tests/RunCMake/CommandLine/E_md5sum-dir-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_md5sum-dir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_md5sum-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_md5sum-dir-stderr.txt
new file mode 100644
index 000000000..061fd64d7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_md5sum-dir-stderr.txt
@@ -0,0 +1 @@
+Error: . is a directory
diff --git a/Tests/RunCMake/CommandLine/E_md5sum-mixed-result.txt b/Tests/RunCMake/CommandLine/E_md5sum-mixed-result.txt
new file mode 100644
index 000000000..0cfbf0888
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_md5sum-mixed-result.txt
@@ -0,0 +1 @@
+2
diff --git a/Tests/RunCMake/CommandLine/E_md5sum-mixed-stderr.txt b/Tests/RunCMake/CommandLine/E_md5sum-mixed-stderr.txt
new file mode 100644
index 000000000..b6b84c39a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_md5sum-mixed-stderr.txt
@@ -0,0 +1,2 @@
+Error: . is a directory
+nonexisting: No such file or directory
diff --git a/Tests/RunCMake/CommandLine/E_md5sum-mixed-stdout.txt b/Tests/RunCMake/CommandLine/E_md5sum-mixed-stdout.txt
new file mode 100644
index 000000000..18e49bef0
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_md5sum-mixed-stdout.txt
@@ -0,0 +1 @@
+275876e34cf609db118f3d84b799a790 ../dummy
diff --git a/Tests/RunCMake/CommandLine/E_md5sum-no-file-result.txt b/Tests/RunCMake/CommandLine/E_md5sum-no-file-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_md5sum-no-file-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_md5sum-no-file-stderr.txt b/Tests/RunCMake/CommandLine/E_md5sum-no-file-stderr.txt
new file mode 100644
index 000000000..732e8c4f6
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_md5sum-no-file-stderr.txt
@@ -0,0 +1 @@
+nonexisting: No such file or directory
diff --git a/Tests/RunCMake/CMP0039/CMP0039-OLD-result.txt b/Tests/RunCMake/CommandLine/E_md5sum-result.txt
index 573541ac9..573541ac9 100644
--- a/Tests/RunCMake/CMP0039/CMP0039-OLD-result.txt
+++ b/Tests/RunCMake/CommandLine/E_md5sum-result.txt
diff --git a/Tests/RunCMake/CommandLine/E_md5sum-stdout.txt b/Tests/RunCMake/CommandLine/E_md5sum-stdout.txt
new file mode 100644
index 000000000..18e49bef0
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_md5sum-stdout.txt
@@ -0,0 +1 @@
+275876e34cf609db118f3d84b799a790 ../dummy
diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-check.cmake b/Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-check.cmake
new file mode 100644
index 000000000..fd6ea111f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-check.cmake
@@ -0,0 +1,3 @@
+if(IS_DIRECTORY ${out}/parent/child)
+ set(RunCMake_TEST_FAILED "child directory was not removed")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-stderr.txt b/Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-stderr.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_remove_directory-directory-with-parent-stderr.txt
diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-symlink-dir-check.cmake b/Tests/RunCMake/CommandLine/E_remove_directory-symlink-dir-check.cmake
new file mode 100644
index 000000000..f70312c46
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_remove_directory-symlink-dir-check.cmake
@@ -0,0 +1,6 @@
+if(EXISTS ${out}/link_dir)
+ set(RunCMake_TEST_FAILED "did not remove ${out}/link_dir")
+endif()
+if(NOT EXISTS ${out}/dir)
+ set(RunCMake_TEST_FAILED "should not have removed ${out}/dir")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-symlink-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_remove_directory-symlink-dir-stderr.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_remove_directory-symlink-dir-stderr.txt
diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-symlink-file-check.cmake b/Tests/RunCMake/CommandLine/E_remove_directory-symlink-file-check.cmake
new file mode 100644
index 000000000..23d7c6d85
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_remove_directory-symlink-file-check.cmake
@@ -0,0 +1,6 @@
+if(NOT EXISTS ${outfile})
+ set(RunCMake_TEST_FAILED "removed non-directory ${outfile}")
+endif()
+if(NOT EXISTS ${out}/link_file_for_test.txt)
+ set(RunCMake_TEST_FAILED "removed non-directory symlink ${out}/link_file_for_test.txt")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-symlink-file-stderr.txt b/Tests/RunCMake/CommandLine/E_remove_directory-symlink-file-stderr.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_remove_directory-symlink-file-stderr.txt
diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-three-directories-check.cmake b/Tests/RunCMake/CommandLine/E_remove_directory-three-directories-check.cmake
new file mode 100644
index 000000000..2b7202ad5
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_remove_directory-three-directories-check.cmake
@@ -0,0 +1,6 @@
+if(IS_DIRECTORY ${out}/d1)
+ set(RunCMake_TEST_FAILED "directory d1 was not removed")
+endif()
+if(IS_DIRECTORY ${out}/d2)
+ set(RunCMake_TEST_FAILED "directory d2 was not removed")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-three-directories-stderr.txt b/Tests/RunCMake/CommandLine/E_remove_directory-three-directories-stderr.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_remove_directory-three-directories-stderr.txt
diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-check.cmake b/Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-check.cmake
new file mode 100644
index 000000000..0aa4a5202
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-check.cmake
@@ -0,0 +1,3 @@
+if(NOT EXISTS ${outfile})
+ set(RunCMake_TEST_FAILED "removed non-directory ${outfile}")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-stderr.txt b/Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-stderr.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_remove_directory-two-directories-and-file-stderr.txt
diff --git a/Tests/RunCMake/CommandLine/E_sha1sum-dir-result.txt b/Tests/RunCMake/CommandLine/E_sha1sum-dir-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha1sum-dir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_sha1sum-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_sha1sum-dir-stderr.txt
new file mode 100644
index 000000000..061fd64d7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha1sum-dir-stderr.txt
@@ -0,0 +1 @@
+Error: . is a directory
diff --git a/Tests/RunCMake/CommandLine/E_sha1sum-no-file-result.txt b/Tests/RunCMake/CommandLine/E_sha1sum-no-file-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha1sum-no-file-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_sha1sum-no-file-stderr.txt b/Tests/RunCMake/CommandLine/E_sha1sum-no-file-stderr.txt
new file mode 100644
index 000000000..732e8c4f6
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha1sum-no-file-stderr.txt
@@ -0,0 +1 @@
+nonexisting: No such file or directory
diff --git a/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target-result.txt b/Tests/RunCMake/CommandLine/E_sha1sum-result.txt
index 573541ac9..573541ac9 100644
--- a/Tests/RunCMake/CMP0040/CMP0040-OLD-existing-target-result.txt
+++ b/Tests/RunCMake/CommandLine/E_sha1sum-result.txt
diff --git a/Tests/RunCMake/CommandLine/E_sha1sum-stdout.txt b/Tests/RunCMake/CommandLine/E_sha1sum-stdout.txt
new file mode 100644
index 000000000..689b85bc3
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha1sum-stdout.txt
@@ -0,0 +1 @@
+829c3804401b0727f70f73d4415e162400cbe57b ../dummy
diff --git a/Tests/RunCMake/CommandLine/E_sha224sum-dir-result.txt b/Tests/RunCMake/CommandLine/E_sha224sum-dir-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha224sum-dir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_sha224sum-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_sha224sum-dir-stderr.txt
new file mode 100644
index 000000000..061fd64d7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha224sum-dir-stderr.txt
@@ -0,0 +1 @@
+Error: . is a directory
diff --git a/Tests/RunCMake/CommandLine/E_sha224sum-no-file-result.txt b/Tests/RunCMake/CommandLine/E_sha224sum-no-file-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha224sum-no-file-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_sha224sum-no-file-stderr.txt b/Tests/RunCMake/CommandLine/E_sha224sum-no-file-stderr.txt
new file mode 100644
index 000000000..732e8c4f6
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha224sum-no-file-stderr.txt
@@ -0,0 +1 @@
+nonexisting: No such file or directory
diff --git a/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target-result.txt b/Tests/RunCMake/CommandLine/E_sha224sum-result.txt
index 573541ac9..573541ac9 100644
--- a/Tests/RunCMake/CMP0040/CMP0040-OLD-missing-target-result.txt
+++ b/Tests/RunCMake/CommandLine/E_sha224sum-result.txt
diff --git a/Tests/RunCMake/CommandLine/E_sha224sum-stdout.txt b/Tests/RunCMake/CommandLine/E_sha224sum-stdout.txt
new file mode 100644
index 000000000..5b3e2178a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha224sum-stdout.txt
@@ -0,0 +1 @@
+37d32c6dbabed711cb1d4620b64090fef0ef63ab16a4a51d668259e6 ../dummy
diff --git a/Tests/RunCMake/CommandLine/E_sha256sum-dir-result.txt b/Tests/RunCMake/CommandLine/E_sha256sum-dir-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha256sum-dir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_sha256sum-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_sha256sum-dir-stderr.txt
new file mode 100644
index 000000000..061fd64d7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha256sum-dir-stderr.txt
@@ -0,0 +1 @@
+Error: . is a directory
diff --git a/Tests/RunCMake/CommandLine/E_sha256sum-no-file-result.txt b/Tests/RunCMake/CommandLine/E_sha256sum-no-file-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha256sum-no-file-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_sha256sum-no-file-stderr.txt b/Tests/RunCMake/CommandLine/E_sha256sum-no-file-stderr.txt
new file mode 100644
index 000000000..732e8c4f6
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha256sum-no-file-stderr.txt
@@ -0,0 +1 @@
+nonexisting: No such file or directory
diff --git a/Tests/RunCMake/CMP0041/CMP0041-OLD-result.txt b/Tests/RunCMake/CommandLine/E_sha256sum-result.txt
index 573541ac9..573541ac9 100644
--- a/Tests/RunCMake/CMP0041/CMP0041-OLD-result.txt
+++ b/Tests/RunCMake/CommandLine/E_sha256sum-result.txt
diff --git a/Tests/RunCMake/CommandLine/E_sha256sum-stdout.txt b/Tests/RunCMake/CommandLine/E_sha256sum-stdout.txt
new file mode 100644
index 000000000..9a1877082
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha256sum-stdout.txt
@@ -0,0 +1 @@
+b5a2c96250612366ea272ffac6d9744aaf4b45aacd96aa7cfcb931ee3b558259 ../dummy
diff --git a/Tests/RunCMake/CommandLine/E_sha384sum-dir-result.txt b/Tests/RunCMake/CommandLine/E_sha384sum-dir-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha384sum-dir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_sha384sum-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_sha384sum-dir-stderr.txt
new file mode 100644
index 000000000..061fd64d7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha384sum-dir-stderr.txt
@@ -0,0 +1 @@
+Error: . is a directory
diff --git a/Tests/RunCMake/CommandLine/E_sha384sum-no-file-result.txt b/Tests/RunCMake/CommandLine/E_sha384sum-no-file-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha384sum-no-file-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_sha384sum-no-file-stderr.txt b/Tests/RunCMake/CommandLine/E_sha384sum-no-file-stderr.txt
new file mode 100644
index 000000000..732e8c4f6
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha384sum-no-file-stderr.txt
@@ -0,0 +1 @@
+nonexisting: No such file or directory
diff --git a/Tests/RunCMake/CMP0041/CMP0041-tid-OLD-result.txt b/Tests/RunCMake/CommandLine/E_sha384sum-result.txt
index 573541ac9..573541ac9 100644
--- a/Tests/RunCMake/CMP0041/CMP0041-tid-OLD-result.txt
+++ b/Tests/RunCMake/CommandLine/E_sha384sum-result.txt
diff --git a/Tests/RunCMake/CommandLine/E_sha384sum-stdout.txt b/Tests/RunCMake/CommandLine/E_sha384sum-stdout.txt
new file mode 100644
index 000000000..b706ac587
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha384sum-stdout.txt
@@ -0,0 +1 @@
+43c1835ceba2e29596f05e3859d4fe2b6d124a181ed670f68e914bd3ed251b02b4be609608a13f23ec3d98da6c4eb8cd ../dummy
diff --git a/Tests/RunCMake/CommandLine/E_sha512sum-dir-result.txt b/Tests/RunCMake/CommandLine/E_sha512sum-dir-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha512sum-dir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_sha512sum-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_sha512sum-dir-stderr.txt
new file mode 100644
index 000000000..061fd64d7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha512sum-dir-stderr.txt
@@ -0,0 +1 @@
+Error: . is a directory
diff --git a/Tests/RunCMake/CommandLine/E_sha512sum-no-file-result.txt b/Tests/RunCMake/CommandLine/E_sha512sum-no-file-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha512sum-no-file-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_sha512sum-no-file-stderr.txt b/Tests/RunCMake/CommandLine/E_sha512sum-no-file-stderr.txt
new file mode 100644
index 000000000..732e8c4f6
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha512sum-no-file-stderr.txt
@@ -0,0 +1 @@
+nonexisting: No such file or directory
diff --git a/Tests/RunCMake/CMP0042/CMP0042-OLD-result.txt b/Tests/RunCMake/CommandLine/E_sha512sum-result.txt
index 573541ac9..573541ac9 100644
--- a/Tests/RunCMake/CMP0042/CMP0042-OLD-result.txt
+++ b/Tests/RunCMake/CommandLine/E_sha512sum-result.txt
diff --git a/Tests/RunCMake/CommandLine/E_sha512sum-stdout.txt b/Tests/RunCMake/CommandLine/E_sha512sum-stdout.txt
new file mode 100644
index 000000000..4305383bb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_sha512sum-stdout.txt
@@ -0,0 +1 @@
+1692526aab84461a8aebcefddcba2b33fb5897ab180c53e8b345ae125484d0aaa35baf60487050be21ed8909a48eace93851bf139087ce1f7a87d97b6120a651 ../dummy
diff --git a/Tests/RunCMake/CommandLine/E_touch-nonexistent-dir-result.txt b/Tests/RunCMake/CommandLine/E_touch-nonexistent-dir-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_touch-nonexistent-dir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_touch-nonexistent-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_touch-nonexistent-dir-stderr.txt
new file mode 100644
index 000000000..470d8115d
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_touch-nonexistent-dir-stderr.txt
@@ -0,0 +1 @@
+^cmake -E touch: failed to update ".+/touch-nonexistent-dir/foo"\.$
diff --git a/Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt b/Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt
new file mode 100644
index 000000000..2b8c65c9b
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvGenerator/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.14)
+project(EnvGenerator C)
+if(CMAKE_GENERATOR MATCHES "Visual Studio")
+ message(STATUS "CMAKE_VS_PLATFORM_NAME='${CMAKE_VS_PLATFORM_NAME}'")
+endif()
+add_custom_command(
+ OUTPUT output.txt
+ COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt
+ )
+add_custom_target(CustomTarget ALL DEPENDS output.txt)
diff --git a/Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt b/Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-A-platform-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt
new file mode 100644
index 000000000..4eae6aa10
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr-vs9.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+ No CMAKE_C_COMPILER could be found.
diff --git a/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt
new file mode 100644
index 000000000..09c2d2ba1
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-A-platform-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+.+Platform='fromcli'.+
diff --git a/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt
new file mode 100644
index 000000000..4dd6be1da
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-G-implicit-platform-stdout.txt
@@ -0,0 +1 @@
+-- CMAKE_VS_PLATFORM_NAME='(x64|Win32)'
diff --git a/Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt b/Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-T-toolset-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt
new file mode 100644
index 000000000..b432c19d1
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-T-toolset-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+.+(Platform Toolset = 'fromcli'|Specified platform toolset \(fromcli\) is not installed or invalid).+
diff --git a/Tests/RunCMake/CommandLine/Envgen-bad-result.txt b/Tests/RunCMake/CommandLine/Envgen-bad-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-bad-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt
new file mode 100644
index 000000000..4a1215eb2
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-bad-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error: No generator specified for -G
+CMake Error: CMAKE_GENERATOR was set but the specified generator doesn't exist. Using CMake default.
+
+Generators.*
+\* (Unix Makefiles|Visual Studio).*
diff --git a/Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt
new file mode 100644
index 000000000..d53daa5a2
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-instance-invalid-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+ could not find specified instance of Visual Studio.+
diff --git a/Tests/RunCMake/CommandLine/Envgen-ninja-result.txt b/Tests/RunCMake/CommandLine/Envgen-ninja-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-ninja-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt
new file mode 100644
index 000000000..0d455db74
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-ninja-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error: No generator specified for -G
+
+Generators.*
+\* Ninja.*
diff --git a/Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt
new file mode 100644
index 000000000..4eae6aa10
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr-vs9.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+ No CMAKE_C_COMPILER could be found.
diff --git a/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt
new file mode 100644
index 000000000..76a8f1cac
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-platform-invalid-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+.+Platform='invalid'.+
diff --git a/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt
new file mode 100644
index 000000000..51fce609d
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-toolset-invalid-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at CMakeLists.+
+.+(Platform Toolset = 'invalid'|Specified platform toolset \(invalid\) is not installed or invalid).+
diff --git a/Tests/RunCMake/CommandLine/Envgen-unset-result.txt b/Tests/RunCMake/CommandLine/Envgen-unset-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-unset-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt
new file mode 100644
index 000000000..ec6ec9253
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-unset-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error: No generator specified for -G
+
+Generators.*
+\* (Unix Makefiles|Visual Studio).*
diff --git a/Tests/RunCMake/CommandLine/Envgen-warnings-result.txt b/Tests/RunCMake/CommandLine/Envgen-warnings-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-warnings-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt b/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt
new file mode 100644
index 000000000..47f9c9e0a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Envgen-warnings-stderr.txt
@@ -0,0 +1,7 @@
+^Warning: Environment variable CMAKE_GENERATOR_INSTANCE will be ignored, because CMAKE_GENERATOR is not set.
+Warning: Environment variable CMAKE_GENERATOR_PLATFORM will be ignored, because CMAKE_GENERATOR is not set.
+Warning: Environment variable CMAKE_GENERATOR_TOOLSET will be ignored, because CMAKE_GENERATOR is not set.
+CMake Error: No generator specified for -G
+
+Generators.*
+\* (Unix Makefiles|Visual Studio).*
diff --git a/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt b/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt
new file mode 100644
index 000000000..fc6291445
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/ExplicitDirs/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.14)
+project(ExplicitDirs NONE)
+add_custom_command(
+ OUTPUT output.txt
+ COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt
+ )
+add_custom_target(CustomTarget ALL DEPENDS output.txt)
+add_custom_target(CustomTarget2 ALL DEPENDS output.txt)
+add_custom_target(CustomTarget3 ALL DEPENDS output.txt)
diff --git a/Tests/RunCMake/CommandLine/NoArgs-stdout.txt b/Tests/RunCMake/CommandLine/NoArgs-stdout.txt
index 1cd34697b..f1dafc886 100644
--- a/Tests/RunCMake/CommandLine/NoArgs-stdout.txt
+++ b/Tests/RunCMake/CommandLine/NoArgs-stdout.txt
@@ -2,6 +2,7 @@
cmake \[options\] <path-to-source>
cmake \[options\] <path-to-existing-build>
+ cmake \[options\] -S <path-to-source> -B <path-to-build>
Specify a source directory to \(re-\)generate a build system for it in the
current working directory. Specify an existing build directory to
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index f94b10ac5..b608d334a 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -3,31 +3,47 @@ cmake_minimum_required(VERSION 3.1)
include(RunCMake)
run_cmake_command(NoArgs ${CMAKE_COMMAND})
-run_cmake_command(C-no-arg ${CMAKE_COMMAND} -C)
-run_cmake_command(C-no-file ${CMAKE_COMMAND} -C nosuchcachefile.txt)
+run_cmake_command(Wizard ${CMAKE_COMMAND} -i)
+run_cmake_command(C-no-arg ${CMAKE_COMMAND} -B DummyBuildDir -C)
+run_cmake_command(C-no-file ${CMAKE_COMMAND} -B DummyBuildDir -C nosuchcachefile.txt)
+run_cmake_command(Cno-file ${CMAKE_COMMAND} -B DummyBuildDir -Cnosuchcachefile.txt)
run_cmake_command(cache-no-file ${CMAKE_COMMAND} nosuchsubdir/CMakeCache.txt)
run_cmake_command(lists-no-file ${CMAKE_COMMAND} nosuchsubdir/CMakeLists.txt)
-run_cmake_command(D-no-arg ${CMAKE_COMMAND} -D)
-run_cmake_command(U-no-arg ${CMAKE_COMMAND} -U)
+run_cmake_command(D-no-arg ${CMAKE_COMMAND} -B DummyBuildDir -D)
+run_cmake_command(D-no-src ${CMAKE_COMMAND} -B DummyBuildDir -D VAR=VALUE)
+run_cmake_command(Dno-src ${CMAKE_COMMAND} -B DummyBuildDir -DVAR=VALUE)
+run_cmake_command(U-no-arg ${CMAKE_COMMAND} -B DummyBuildDir -U)
+run_cmake_command(U-no-src ${CMAKE_COMMAND} -B DummyBuildDir -U VAR)
+run_cmake_command(Uno-src ${CMAKE_COMMAND} -B DummyBuildDir -UVAR)
run_cmake_command(E-no-arg ${CMAKE_COMMAND} -E)
run_cmake_command(E_capabilities ${CMAKE_COMMAND} -E capabilities)
run_cmake_command(E_capabilities-arg ${CMAKE_COMMAND} -E capabilities --extra-arg)
+run_cmake_command(E_compare_files-different-eol ${CMAKE_COMMAND} -E compare_files ${RunCMake_SOURCE_DIR}/compare_files/lf ${RunCMake_SOURCE_DIR}/compare_files/crlf)
+run_cmake_command(E_compare_files-ignore-eol-same ${CMAKE_COMMAND} -E compare_files --ignore-eol ${RunCMake_SOURCE_DIR}/compare_files/lf ${RunCMake_SOURCE_DIR}/compare_files/crlf)
+run_cmake_command(E_compare_files-ignore-eol-empty ${CMAKE_COMMAND} -E compare_files --ignore-eol ${RunCMake_SOURCE_DIR}/compare_files/empty1 ${RunCMake_SOURCE_DIR}/compare_files/empty2)
+run_cmake_command(E_compare_files-ignore-eol-nonexistent ${CMAKE_COMMAND} -E compare_files --ignore-eol nonexistent_a nonexistent_b)
run_cmake_command(E_echo_append ${CMAKE_COMMAND} -E echo_append)
run_cmake_command(E_rename-no-arg ${CMAKE_COMMAND} -E rename)
run_cmake_command(E_server-arg ${CMAKE_COMMAND} -E server --extra-arg)
run_cmake_command(E_server-pipe ${CMAKE_COMMAND} -E server --pipe=)
+run_cmake_command(E_true ${CMAKE_COMMAND} -E true)
+run_cmake_command(E_true-extraargs ${CMAKE_COMMAND} -E true ignored)
+run_cmake_command(E_false ${CMAKE_COMMAND} -E false)
+run_cmake_command(E_false-extraargs ${CMAKE_COMMAND} -E false ignored)
+
run_cmake_command(E_touch_nocreate-no-arg ${CMAKE_COMMAND} -E touch_nocreate)
+run_cmake_command(E_touch-nonexistent-dir ${CMAKE_COMMAND} -E touch "${RunCMake_BINARY_DIR}/touch-nonexistent-dir/foo")
run_cmake_command(E_time ${CMAKE_COMMAND} -E time ${CMAKE_COMMAND} -E echo "hello world")
run_cmake_command(E_time-no-arg ${CMAKE_COMMAND} -E time)
-run_cmake_command(E___run_iwyu-no-iwyu ${CMAKE_COMMAND} -E __run_iwyu -- command-does-not-exist)
-run_cmake_command(E___run_iwyu-bad-iwyu ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist -- command-does-not-exist)
-run_cmake_command(E___run_iwyu-no--- ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist command-does-not-exist)
-run_cmake_command(E___run_iwyu-no-cc ${CMAKE_COMMAND} -E __run_iwyu --iwyu=iwyu-does-not-exist --)
+run_cmake_command(E___run_co_compile-no-iwyu ${CMAKE_COMMAND} -E __run_co_compile -- command-does-not-exist)
+run_cmake_command(E___run_co_compile-bad-iwyu ${CMAKE_COMMAND} -E __run_co_compile --iwyu=iwyu-does-not-exist -- command-does-not-exist)
+run_cmake_command(E___run_co_compile-no--- ${CMAKE_COMMAND} -E __run_co_compile --iwyu=iwyu-does-not-exist command-does-not-exist)
+run_cmake_command(E___run_co_compile-no-cc ${CMAKE_COMMAND} -E __run_co_compile --iwyu=iwyu-does-not-exist --)
-run_cmake_command(G_no-arg ${CMAKE_COMMAND} -G)
-run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -G NoSuchGenerator)
+run_cmake_command(G_no-arg ${CMAKE_COMMAND} -B DummyBuildDir -G)
+run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -B DummyBuildDir -G NoSuchGenerator)
run_cmake_command(P_no-arg ${CMAKE_COMMAND} -P)
run_cmake_command(P_no-file ${CMAKE_COMMAND} -P nosuchscriptfile.cmake)
@@ -42,11 +58,69 @@ run_cmake_command(build-bad-dir
run_cmake_command(build-bad-generator
${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-generator)
+run_cmake_command(install-no-dir
+ ${CMAKE_COMMAND} --install)
+run_cmake_command(install-bad-dir
+ ${CMAKE_COMMAND} --install dir-does-not-exist)
+run_cmake_command(install-options-to-vars
+ ${CMAKE_COMMAND} --install ${RunCMake_SOURCE_DIR}/dir-install-options-to-vars
+ --strip --prefix /var/test --config sample --component pack)
+
run_cmake_command(cache-bad-entry
${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-entry/)
run_cmake_command(cache-empty-entry
${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-empty-entry/)
+function(run_ExplicitDirs)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_NO_SOURCE_DIR 1)
+
+ set(source_dir ${RunCMake_BINARY_DIR}/ExplicitDirsMissing)
+
+ file(REMOVE_RECURSE "${source_dir}")
+ file(MAKE_DIRECTORY "${source_dir}")
+ file(WRITE ${source_dir}/CMakeLists.txt [=[
+cmake_minimum_required(VERSION 3.13)
+project(ExplicitDirsMissing LANGUAGES NONE)
+]=])
+ set(RunCMake_TEST_SOURCE_DIR "${source_dir}")
+ set(RunCMake_TEST_BINARY_DIR "${source_dir}")
+ run_cmake_with_options(no-S-B -DFOO=BAR)
+
+ set(source_dir ${RunCMake_SOURCE_DIR}/ExplicitDirs)
+ set(binary_dir ${RunCMake_BINARY_DIR}/ExplicitDirs-build)
+
+ set(RunCMake_TEST_SOURCE_DIR "${source_dir}")
+ set(RunCMake_TEST_BINARY_DIR "${binary_dir}")
+
+ file(REMOVE_RECURSE "${binary_dir}")
+ run_cmake_with_options(S-arg -S ${source_dir} ${binary_dir})
+ run_cmake_with_options(S-arg-reverse-order ${binary_dir} -S${source_dir} )
+ run_cmake_with_options(S-no-arg -S )
+ run_cmake_with_options(S-no-arg2 -S -T)
+ run_cmake_with_options(S-B -S ${source_dir} -B ${binary_dir})
+
+ # make sure that -B can explicitly construct build directories
+ file(REMOVE_RECURSE "${binary_dir}")
+ run_cmake_with_options(B-arg -B ${binary_dir} ${source_dir})
+ file(REMOVE_RECURSE "${binary_dir}")
+ run_cmake_with_options(B-arg-reverse-order ${source_dir} -B${binary_dir})
+ run_cmake_with_options(B-no-arg -B )
+ run_cmake_with_options(B-no-arg2 -B -T)
+ file(REMOVE_RECURSE "${binary_dir}")
+ run_cmake_with_options(B-S -B${binary_dir} -S${source_dir})
+
+ message("copied to ${RunCMake_TEST_BINARY_DIR}/initial-cache.txt")
+ file(COPY ${RunCMake_SOURCE_DIR}/C_buildsrcdir/initial-cache.txt DESTINATION ${RunCMake_TEST_BINARY_DIR})
+
+ # CMAKE_BINARY_DIR should be determined by -B if specified, and CMAKE_SOURCE_DIR determined by -S if specified.
+ # Path to initial-cache.txt is relative to the $PWD, which is normally set to ${RunCMake_TEST_BINARY_DIR}.
+ run_cmake_with_options(C_buildsrcdir -B DummyBuildDir -S ${RunCMake_SOURCE_DIR}/C_buildsrcdir/src -C initial-cache.txt)
+ # Test that full path works, too.
+ run_cmake_with_options(C_buildsrcdir -B DummyBuildDir -S ${RunCMake_SOURCE_DIR}/C_buildsrcdir/src -C ${RunCMake_TEST_BINARY_DIR}/initial-cache.txt)
+endfunction()
+run_ExplicitDirs()
+
function(run_BuildDir)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BuildDir-build)
@@ -58,10 +132,128 @@ function(run_BuildDir)
run_cmake_command(BuildDir--build ${CMAKE_COMMAND} -E chdir ..
${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget)
run_cmake_command(BuildDir--build-multiple-targets ${CMAKE_COMMAND} -E chdir ..
- ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget2 --target CustomTarget3)
+ ${CMAKE_COMMAND} --build BuildDir-build -t CustomTarget2 --target CustomTarget3)
+ run_cmake_command(BuildDir--build-multiple-targets-jobs ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget CustomTarget2 -j2 --target CustomTarget3)
+ run_cmake_command(BuildDir--build-multiple-targets-with-clean-first ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build --target clean CustomTarget)
+ run_cmake_command(BuildDir--build-multiple-targets-with-clean-second ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget clean)
+ run_cmake_command(BuildDir--build-jobs-bad-number ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build -j 12ab)
+ run_cmake_command(BuildDir--build-jobs-good-number ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build -j 2)
+ run_cmake_command(BuildDir--build-jobs-good-number-trailing--target ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build -j 2 --target CustomTarget)
+ run_cmake_command(BuildDir--build--parallel-bad-number ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build --parallel 12ab)
+ run_cmake_command(BuildDir--build--parallel-good-number ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build --parallel 2)
+ run_cmake_command(BuildDir--build--parallel-good-number-trailing--target ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build --parallel 2 --target CustomTarget)
+ run_cmake_command(BuildDir--build-jobs-no-space-bad-number ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build -j12ab)
+ run_cmake_command(BuildDir--build-jobs-no-space-good-number ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build -j2)
+ run_cmake_command(BuildDir--build-jobs-no-space-good-number-trailing--target ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build -j2 --target CustomTarget)
+ run_cmake_command(BuildDir--build--parallel-no-space-bad-number ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build --parallel12ab)
+ run_cmake_command(BuildDir--build--parallel-no-space-good-number ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build --parallel2)
+ run_cmake_command(BuildDir--build--parallel-no-space-good-number-trailing--target ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build --parallel2 --target CustomTarget)
+ run_cmake_command(BuildDir--build-jobs-zero ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build -j 0)
+ run_cmake_command(BuildDir--build--parallel-zero ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build --parallel 0)
+ run_cmake_command(BuildDir--build-jobs-large ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build -j 4294967293)
+ run_cmake_command(BuildDir--build--parallel-large ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build --parallel 4294967293)
+
+ # No default jobs for Xcode and FreeBSD build command
+ if(NOT RunCMake_GENERATOR MATCHES "Xcode" AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ run_cmake_command(BuildDir--build-jobs-no-number ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build -j)
+ run_cmake_command(BuildDir--build-jobs-no-number-trailing--target ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build -j --target CustomTarget)
+ run_cmake_command(BuildDir--build--parallel-no-number ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build --parallel)
+ run_cmake_command(BuildDir--build--parallel-no-number-trailing--target ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build BuildDir-build --parallel --target CustomTarget)
+ endif()
endfunction()
run_BuildDir()
+function(run_EnvironmentGenerator)
+ set(source_dir ${RunCMake_SOURCE_DIR}/EnvGenerator)
+
+ set(ENV{CMAKE_GENERATOR_INSTANCE} "instance")
+ set(ENV{CMAKE_GENERATOR_PLATFORM} "platform")
+ set(ENV{CMAKE_GENERATOR_TOOLSET} "toolset")
+ run_cmake_command(Envgen-warnings ${CMAKE_COMMAND} -G)
+ unset(ENV{CMAKE_GENERATOR_INSTANCE})
+ unset(ENV{CMAKE_GENERATOR_PLATFORM})
+ unset(ENV{CMAKE_GENERATOR_TOOLSET})
+
+ # Test CMAKE_GENERATOR without actual configuring
+ run_cmake_command(Envgen-unset ${CMAKE_COMMAND} -G)
+ set(ENV{CMAKE_GENERATOR} "Ninja")
+ run_cmake_command(Envgen-ninja ${CMAKE_COMMAND} -G)
+ set(ENV{CMAKE_GENERATOR} "NoSuchGenerator")
+ run_cmake_command(Envgen-bad ${CMAKE_COMMAND} -G)
+ unset(ENV{CMAKE_GENERATOR})
+
+ if(RunCMake_GENERATOR MATCHES "Visual Studio.*")
+ set(ENV{CMAKE_GENERATOR} "${RunCMake_GENERATOR}")
+ run_cmake_command(Envgen ${CMAKE_COMMAND} ${source_dir})
+ # Toolset is available since VS 2010.
+ if(RunCMake_GENERATOR MATCHES "Visual Studio [1-9][0-9]")
+ set(ENV{CMAKE_GENERATOR_TOOLSET} "invalid")
+ # Envvar shouldn't affect existing build tree
+ run_cmake_command(Envgen-toolset-existing ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build Envgen-build)
+ run_cmake_command(Envgen-toolset-invalid ${CMAKE_COMMAND} ${source_dir})
+ # Command line -G implies -T""
+ run_cmake_command(Envgen-G-implicit-toolset ${CMAKE_COMMAND} -G "${RunCMake_GENERATOR}" ${source_dir})
+ run_cmake_command(Envgen-T-toolset ${CMAKE_COMMAND} -T "fromcli" ${source_dir})
+ unset(ENV{CMAKE_GENERATOR_TOOLSET})
+ endif()
+ # Platform can be set only if not in generator name.
+ if(RunCMake_GENERATOR MATCHES "^Visual Studio [0-9]+ [0-9]+$")
+ set(ENV{CMAKE_GENERATOR_PLATFORM} "invalid")
+ # Envvar shouldn't affect existing build tree
+ run_cmake_command(Envgen-platform-existing ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build Envgen-build)
+ if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ")
+ set(RunCMake-stderr-file "Envgen-platform-invalid-stderr-vs9.txt")
+ endif()
+ run_cmake_command(Envgen-platform-invalid ${CMAKE_COMMAND} ${source_dir})
+ unset(RunCMake-stderr-file)
+ # Command line -G implies -A""
+ run_cmake_command(Envgen-G-implicit-platform ${CMAKE_COMMAND} -G "${RunCMake_GENERATOR}" ${source_dir})
+ if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ")
+ set(RunCMake-stderr-file "Envgen-A-platform-stderr-vs9.txt")
+ endif()
+ run_cmake_command(Envgen-A-platform ${CMAKE_COMMAND} -A "fromcli" ${source_dir})
+ unset(RunCMake-stderr-file)
+ unset(ENV{CMAKE_GENERATOR_PLATFORM})
+ endif()
+ # Instance is available since VS 2017.
+ if(RunCMake_GENERATOR MATCHES "Visual Studio (15|16).*")
+ set(ENV{CMAKE_GENERATOR_INSTANCE} "invalid")
+ # Envvar shouldn't affect existing build tree
+ run_cmake_command(Envgen-instance-existing ${CMAKE_COMMAND} -E chdir ..
+ ${CMAKE_COMMAND} --build Envgen-build)
+ run_cmake_command(Envgen-instance-invalid ${CMAKE_COMMAND} ${source_dir})
+ unset(ENV{CMAKE_GENERATOR_INSTANCE})
+ endif()
+ unset(ENV{CMAKE_GENERATOR})
+ endif()
+endfunction()
+run_EnvironmentGenerator()
+
if(RunCMake_GENERATOR STREQUAL "Ninja")
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Build-build)
@@ -78,39 +270,35 @@ if(RunCMake_GENERATOR STREQUAL "Ninja")
unset(RunCMake_TEST_NO_CLEAN)
endif()
-if(RunCMake_GENERATOR MATCHES "^Visual Studio 8 2005")
- set(RunCMake_WARN_VS8 1)
- run_cmake(DeprecateVS8-WARN-ON)
- unset(RunCMake_WARN_VS8)
- run_cmake(DeprecateVS8-WARN-OFF)
-endif()
-
-if(UNIX)
- run_cmake_command(E_create_symlink-no-arg
- ${CMAKE_COMMAND} -E create_symlink
- )
- run_cmake_command(E_create_symlink-missing-dir
- ${CMAKE_COMMAND} -E create_symlink T missing-dir/L
- )
+run_cmake_command(E_create_symlink-no-arg
+ ${CMAKE_COMMAND} -E create_symlink
+ )
+run_cmake_command(E_create_symlink-missing-dir
+ ${CMAKE_COMMAND} -E create_symlink T missing-dir/L
+ )
- # Use a single build tree for a few tests without cleaning.
- set(RunCMake_TEST_BINARY_DIR
- ${RunCMake_BINARY_DIR}/E_create_symlink-broken-build)
- set(RunCMake_TEST_NO_CLEAN 1)
- file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
- run_cmake_command(E_create_symlink-broken-create
- ${CMAKE_COMMAND} -E create_symlink T L
- )
- run_cmake_command(E_create_symlink-broken-replace
- ${CMAKE_COMMAND} -E create_symlink . L
- )
- unset(RunCMake_TEST_BINARY_DIR)
- unset(RunCMake_TEST_NO_CLEAN)
+# Use a single build tree for a few tests without cleaning.
+# These tests are special on Windows since it will only fail if the user
+# running the test does not have the priveldge to create symlinks. If this
+# happens we clear the msg in the -check.cmake and say that the test passes
+set(RunCMake_DEFAULT_stderr "(operation not permitted)?")
+set(RunCMake_TEST_BINARY_DIR
+ ${RunCMake_BINARY_DIR}/E_create_symlink-broken-build)
+set(RunCMake_TEST_NO_CLEAN 1)
+file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+run_cmake_command(E_create_symlink-broken-create
+ ${CMAKE_COMMAND} -E create_symlink T L
+ )
+run_cmake_command(E_create_symlink-broken-replace
+ ${CMAKE_COMMAND} -E create_symlink . L
+ )
+unset(RunCMake_TEST_BINARY_DIR)
+unset(RunCMake_TEST_NO_CLEAN)
+unset(RunCMake_DEFAULT_stderr)
- run_cmake_command(E_create_symlink-no-replace-dir
- ${CMAKE_COMMAND} -E create_symlink T .
- )
-endif()
+run_cmake_command(E_create_symlink-no-replace-dir
+ ${CMAKE_COMMAND} -E create_symlink T .
+ )
set(in ${RunCMake_SOURCE_DIR}/copy_input)
set(out ${RunCMake_BINARY_DIR}/copy_output)
@@ -158,10 +346,27 @@ file(MAKE_DIRECTORY ${out})
file(WRITE ${outfile} "")
run_cmake_command(E_make_directory-three-directories
${CMAKE_COMMAND} -E make_directory ${out}/d1 ${out}/d2 ${out}/d2)
+run_cmake_command(E_remove_directory-three-directories
+ ${CMAKE_COMMAND} -E remove_directory ${out}/d1 ${out}/d2 ${out}/d2)
run_cmake_command(E_make_directory-directory-with-parent
${CMAKE_COMMAND} -E make_directory ${out}/parent/child)
-run_cmake_command(E_make_directory-three-directories-and-file
+run_cmake_command(E_remove_directory-directory-with-parent
+ ${CMAKE_COMMAND} -E remove_directory ${out}/parent)
+run_cmake_command(E_make_directory-two-directories-and-file
${CMAKE_COMMAND} -E make_directory ${out}/d1 ${out}/d2 ${outfile})
+run_cmake_command(E_remove_directory-two-directories-and-file
+ ${CMAKE_COMMAND} -E remove_directory ${out}/d1 ${out}/d2 ${outfile})
+
+if(UNIX)
+ file(MAKE_DIRECTORY ${out}/dir)
+ file(CREATE_LINK ${out}/dir ${out}/link_dir SYMBOLIC)
+ file(CREATE_LINK ${outfile} ${out}/link_file_for_test.txt SYMBOLIC)
+ run_cmake_command(E_remove_directory-symlink-dir
+ ${CMAKE_COMMAND} -E remove_directory ${out}/link_dir)
+ run_cmake_command(E_remove_directory-symlink-file
+ ${CMAKE_COMMAND} -E remove_directory ${out}/link_file_for_test.txt)
+endif()
+
unset(out)
unset(outfile)
@@ -172,6 +377,30 @@ run_cmake_command(E_env-bad-arg1 ${CMAKE_COMMAND} -E env -bad-arg1)
run_cmake_command(E_env-set ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-set.cmake)
run_cmake_command(E_env-unset ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -E env --unset=TEST_ENV ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-unset.cmake)
+run_cmake_command(E_md5sum-dir ${CMAKE_COMMAND} -E md5sum .)
+run_cmake_command(E_sha1sum-dir ${CMAKE_COMMAND} -E sha1sum .)
+run_cmake_command(E_sha224sum-dir ${CMAKE_COMMAND} -E sha224sum .)
+run_cmake_command(E_sha256sum-dir ${CMAKE_COMMAND} -E sha256sum .)
+run_cmake_command(E_sha384sum-dir ${CMAKE_COMMAND} -E sha384sum .)
+run_cmake_command(E_sha512sum-dir ${CMAKE_COMMAND} -E sha512sum .)
+
+run_cmake_command(E_md5sum-no-file ${CMAKE_COMMAND} -E md5sum nonexisting)
+run_cmake_command(E_sha1sum-no-file ${CMAKE_COMMAND} -E sha1sum nonexisting)
+run_cmake_command(E_sha224sum-no-file ${CMAKE_COMMAND} -E sha224sum nonexisting)
+run_cmake_command(E_sha256sum-no-file ${CMAKE_COMMAND} -E sha256sum nonexisting)
+run_cmake_command(E_sha384sum-no-file ${CMAKE_COMMAND} -E sha384sum nonexisting)
+run_cmake_command(E_sha512sum-no-file ${CMAKE_COMMAND} -E sha512sum nonexisting)
+
+file(WRITE "${RunCMake_BINARY_DIR}/dummy" "dummy")
+run_cmake_command(E_md5sum ${CMAKE_COMMAND} -E md5sum ../dummy)
+run_cmake_command(E_md5sum-mixed ${CMAKE_COMMAND} -E md5sum . ../dummy nonexisting)
+run_cmake_command(E_sha1sum ${CMAKE_COMMAND} -E sha1sum ../dummy)
+run_cmake_command(E_sha224sum ${CMAKE_COMMAND} -E sha224sum ../dummy)
+run_cmake_command(E_sha256sum ${CMAKE_COMMAND} -E sha256sum ../dummy)
+run_cmake_command(E_sha384sum ${CMAKE_COMMAND} -E sha384sum ../dummy)
+run_cmake_command(E_sha512sum ${CMAKE_COMMAND} -E sha512sum ../dummy)
+file(REMOVE "${RunCMake_BINARY_DIR}/dummy")
+
set(RunCMake_DEFAULT_stderr ".")
run_cmake_command(E_sleep-no-args ${CMAKE_COMMAND} -E sleep)
unset(RunCMake_DEFAULT_stderr)
@@ -181,6 +410,14 @@ run_cmake_command(E_sleep-one-tenth ${CMAKE_COMMAND} -E sleep 0.1)
run_cmake_command(P_directory ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR})
run_cmake_command(P_working-dir ${CMAKE_COMMAND} -DEXPECTED_WORKING_DIR=${RunCMake_BINARY_DIR}/P_working-dir-build -P ${RunCMake_SOURCE_DIR}/P_working-dir.cmake)
+# Documented to return the same result as above even if -S and -B are set to something else.
+# Tests the values of CMAKE_BINARY_DIR CMAKE_CURRENT_BINARY_DIR CMAKE_SOURCE_DIR CMAKE_CURRENT_SOURCE_DIR.
+run_cmake_command(P_working-dir ${CMAKE_COMMAND} -DEXPECTED_WORKING_DIR=${RunCMake_BINARY_DIR}/P_working-dir-build -P ${RunCMake_SOURCE_DIR}/P_working-dir.cmake -S something_else -B something_else_1)
+
+# Place an initial cache where C_basic will find it when passed the relative path "..".
+file(COPY ${RunCMake_SOURCE_DIR}/C_basic_initial-cache.txt DESTINATION ${RunCMake_BINARY_DIR})
+run_cmake_with_options(C_basic -C ../C_basic_initial-cache.txt)
+run_cmake_with_options(C_basic_fullpath -C ${RunCMake_BINARY_DIR}/C_basic_initial-cache.txt)
set(RunCMake_TEST_OPTIONS
"-DFOO=-DBAR:BOOL=BAZ")
@@ -254,9 +491,9 @@ set(RunCMake_TEST_OPTIONS -Wdev -Wno-dev)
run_cmake(Wno-dev)
unset(RunCMake_TEST_OPTIONS)
-run_cmake_command(W_bad-arg1 ${CMAKE_COMMAND} -W)
-run_cmake_command(W_bad-arg2 ${CMAKE_COMMAND} -Wno-)
-run_cmake_command(W_bad-arg3 ${CMAKE_COMMAND} -Werror=)
+run_cmake_command(W_bad-arg1 ${CMAKE_COMMAND} -B DummyBuildDir -W)
+run_cmake_command(W_bad-arg2 ${CMAKE_COMMAND} -B DummyBuildDir -Wno-)
+run_cmake_command(W_bad-arg3 ${CMAKE_COMMAND} -B DummyBuildDir -Werror=)
set(RunCMake_TEST_OPTIONS --debug-output)
run_cmake(debug-output)
@@ -270,6 +507,22 @@ set(RunCMake_TEST_OPTIONS --trace-expand)
run_cmake(trace-expand)
unset(RunCMake_TEST_OPTIONS)
+set(RunCMake_TEST_OPTIONS --trace-expand --warn-uninitialized)
+run_cmake(trace-expand-warn-uninitialized)
+unset(RunCMake_TEST_OPTIONS)
+
+set(RunCMake_TEST_OPTIONS --trace-redirect=${RunCMake_BINARY_DIR}/redirected.trace)
+run_cmake(trace-redirect)
+unset(RunCMake_TEST_OPTIONS)
+
+set(RunCMake_TEST_OPTIONS --trace-redirect=/no/such/file.txt)
+run_cmake(trace-redirect-nofile)
+unset(RunCMake_TEST_OPTIONS)
+
+set(RunCMake_TEST_OPTIONS -Wno-deprecated --warn-uninitialized)
+run_cmake(warn-uninitialized)
+unset(RunCMake_TEST_OPTIONS)
+
set(RunCMake_TEST_OPTIONS --trace-source=trace-only-this-file.cmake)
run_cmake(trace-source)
unset(RunCMake_TEST_OPTIONS)
@@ -313,4 +566,8 @@ function(reject_fifo)
endfunction()
if(CMAKE_HOST_UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "CYGWIN")
reject_fifo()
+ run_cmake_command(closed_stdin sh -c "\"${CMAKE_COMMAND}\" --version <&-")
+ run_cmake_command(closed_stdout sh -c "\"${CMAKE_COMMAND}\" --version >&-")
+ run_cmake_command(closed_stderr sh -c "\"${CMAKE_COMMAND}\" --version 2>&-")
+ run_cmake_command(closed_stdall sh -c "\"${CMAKE_COMMAND}\" --version <&- >&- 2>&-")
endif()
diff --git a/Tests/RunCMake/CommandLine/S-no-arg-result.txt b/Tests/RunCMake/CommandLine/S-no-arg-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/S-no-arg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/S-no-arg-stderr.txt b/Tests/RunCMake/CommandLine/S-no-arg-stderr.txt
new file mode 100644
index 000000000..d1a2ce34f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/S-no-arg-stderr.txt
@@ -0,0 +1 @@
+CMake Error: No source directory specified for -S
diff --git a/Tests/RunCMake/CommandLine/S-no-arg2-result.txt b/Tests/RunCMake/CommandLine/S-no-arg2-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/S-no-arg2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/S-no-arg2-stderr.txt b/Tests/RunCMake/CommandLine/S-no-arg2-stderr.txt
new file mode 100644
index 000000000..d1a2ce34f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/S-no-arg2-stderr.txt
@@ -0,0 +1 @@
+CMake Error: No source directory specified for -S
diff --git a/Tests/RunCMake/CommandLine/U-no-src-result.txt b/Tests/RunCMake/CommandLine/U-no-src-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/U-no-src-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/U-no-src-stderr.txt b/Tests/RunCMake/CommandLine/U-no-src-stderr.txt
new file mode 100644
index 000000000..a3b4b12cc
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/U-no-src-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/U-no-src-build" does not appear to contain CMakeLists.txt.
+Specify --help for usage, or press the help button on the CMake GUI.$
diff --git a/Tests/RunCMake/CommandLine/Uno-src-result.txt b/Tests/RunCMake/CommandLine/Uno-src-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Uno-src-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Uno-src-stderr.txt b/Tests/RunCMake/CommandLine/Uno-src-stderr.txt
new file mode 100644
index 000000000..baa8d63ef
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Uno-src-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error: The source directory ".*/Tests/RunCMake/CommandLine/Uno-src-build" does not appear to contain CMakeLists.txt.
+Specify --help for usage, or press the help button on the CMake GUI.$
diff --git a/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt b/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt
index e9be1dcb3..30385f88e 100644
--- a/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt
+++ b/Tests/RunCMake/CommandLine/Wdeprecated-stderr.txt
@@ -1,4 +1,4 @@
^CMake Deprecation Warning at Wdeprecated.cmake:1 \(message\):
Some deprecated warning
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/CommandLine/Wdev-stderr.txt b/Tests/RunCMake/CommandLine/Wdev-stderr.txt
index 88cfb3a30..172fb8155 100644
--- a/Tests/RunCMake/CommandLine/Wdev-stderr.txt
+++ b/Tests/RunCMake/CommandLine/Wdev-stderr.txt
@@ -1,11 +1,11 @@
^CMake Warning \(dev\) at Wdev.cmake:1 \(message\):
Some author warning
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning \(dev\) at Wdev.cmake:6 \(include\):
include\(\) given empty file name \(ignored\).
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/CommandLine/Werror_deprecated-stderr.txt b/Tests/RunCMake/CommandLine/Werror_deprecated-stderr.txt
index 6acdc7362..d681836b2 100644
--- a/Tests/RunCMake/CommandLine/Werror_deprecated-stderr.txt
+++ b/Tests/RunCMake/CommandLine/Werror_deprecated-stderr.txt
@@ -1,4 +1,4 @@
^CMake Deprecation Error at Werror_deprecated.cmake:1 \(message\):
Some deprecated warning
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/CommandLine/Werror_dev-stderr.txt b/Tests/RunCMake/CommandLine/Werror_dev-stderr.txt
index 590ec96d3..35890fc99 100644
--- a/Tests/RunCMake/CommandLine/Werror_dev-stderr.txt
+++ b/Tests/RunCMake/CommandLine/Werror_dev-stderr.txt
@@ -1,11 +1,11 @@
^CMake Error \(dev\) at Werror_dev.cmake:4 \(include\):
include\(\) given empty file name \(ignored\).
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This error is for project developers. Use -Wno-error=dev to suppress it.
CMake Error \(dev\) at Werror_dev.cmake:7 \(message\):
Some author warning
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This error is for project developers. Use -Wno-error=dev to suppress it.$
diff --git a/Tests/RunCMake/CommandLine/Wizard-result.txt b/Tests/RunCMake/CommandLine/Wizard-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Wizard-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/Wizard-stderr.txt b/Tests/RunCMake/CommandLine/Wizard-stderr.txt
new file mode 100644
index 000000000..f757aff90
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Wizard-stderr.txt
@@ -0,0 +1 @@
+^The "cmake -i" wizard mode is no longer supported\.
diff --git a/Tests/RunCMake/CommandLine/Wno-error_deprecated-stderr.txt b/Tests/RunCMake/CommandLine/Wno-error_deprecated-stderr.txt
index 0ed169861..45897062d 100644
--- a/Tests/RunCMake/CommandLine/Wno-error_deprecated-stderr.txt
+++ b/Tests/RunCMake/CommandLine/Wno-error_deprecated-stderr.txt
@@ -1,4 +1,4 @@
^CMake Deprecation Warning at Wno-error_deprecated.cmake:2 \(message\):
Some deprecated warning
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/CommandLine/Wno-error_dev-stderr.txt b/Tests/RunCMake/CommandLine/Wno-error_dev-stderr.txt
index dd22d5568..ee28d7f02 100644
--- a/Tests/RunCMake/CommandLine/Wno-error_dev-stderr.txt
+++ b/Tests/RunCMake/CommandLine/Wno-error_dev-stderr.txt
@@ -1,11 +1,11 @@
^CMake Warning \(dev\) at Wno-error_dev.cmake:2 \(message\):
Some author warning
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning \(dev\) at Wno-error_dev.cmake:6 \(include\):
include\(\) given empty file name \(ignored\).
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes b/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes
index 9c22288cd..d9a4db409 100644
--- a/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes
+++ b/Tests/RunCMake/CommandLine/cmake_depends/.gitattributes
@@ -1,2 +1,2 @@
# Do not format a source encoded in UTF-16.
-test_UTF-16LE.h -format.clang-format
+test_UTF-16LE.h -format.clang-format-6.0
diff --git a/Tests/RunCMake/CommandLine/compare_files/.gitattributes b/Tests/RunCMake/CommandLine/compare_files/.gitattributes
new file mode 100644
index 000000000..91d5c104c
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/compare_files/.gitattributes
@@ -0,0 +1,2 @@
+crlf eol=crlf
+lf eol=lf
diff --git a/Tests/RunCMake/CommandLine/compare_files/crlf b/Tests/RunCMake/CommandLine/compare_files/crlf
new file mode 100644
index 000000000..a29bdeb43
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/compare_files/crlf
@@ -0,0 +1 @@
+line1
diff --git a/Tests/RunCMake/CommandLine/compare_files/empty1 b/Tests/RunCMake/CommandLine/compare_files/empty1
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/compare_files/empty1
diff --git a/Tests/RunCMake/CommandLine/compare_files/empty2 b/Tests/RunCMake/CommandLine/compare_files/empty2
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/compare_files/empty2
diff --git a/Tests/RunCMake/CommandLine/compare_files/lf b/Tests/RunCMake/CommandLine/compare_files/lf
new file mode 100644
index 000000000..a29bdeb43
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/compare_files/lf
@@ -0,0 +1 @@
+line1
diff --git a/Tests/RunCMake/CommandLine/dir-install-options-to-vars/cmake_install.cmake b/Tests/RunCMake/CommandLine/dir-install-options-to-vars/cmake_install.cmake
new file mode 100644
index 000000000..fd4e67df1
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/dir-install-options-to-vars/cmake_install.cmake
@@ -0,0 +1,15 @@
+if(CMAKE_INSTALL_PREFIX)
+ message("CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX}")
+endif()
+
+if(CMAKE_INSTALL_COMPONENT)
+ message("CMAKE_INSTALL_COMPONENT is ${CMAKE_INSTALL_COMPONENT}")
+endif()
+
+if(CMAKE_INSTALL_CONFIG_NAME)
+ message("CMAKE_INSTALL_CONFIG_NAME is ${CMAKE_INSTALL_CONFIG_NAME}")
+endif()
+
+if(CMAKE_INSTALL_DO_STRIP)
+ message("CMAKE_INSTALL_DO_STRIP is ${CMAKE_INSTALL_DO_STRIP}")
+endif()
diff --git a/Tests/RunCMake/CommandLine/install-bad-dir-result.txt b/Tests/RunCMake/CommandLine/install-bad-dir-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/install-bad-dir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt b/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt
new file mode 100644
index 000000000..320aecc8f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/install-bad-dir-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: Error processing file:
diff --git a/Tests/RunCMake/CommandLine/install-no-dir-result.txt b/Tests/RunCMake/CommandLine/install-no-dir-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/install-no-dir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/install-no-dir-stderr.txt b/Tests/RunCMake/CommandLine/install-no-dir-stderr.txt
new file mode 100644
index 000000000..d64f6385f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/install-no-dir-stderr.txt
@@ -0,0 +1 @@
+^Usage: cmake --install <dir> \[options\]
diff --git a/Tests/RunCMake/CMP0043/CMP0043-OLD-result.txt b/Tests/RunCMake/CommandLine/install-options-to-vars-result.txt
index 573541ac9..573541ac9 100644
--- a/Tests/RunCMake/CMP0043/CMP0043-OLD-result.txt
+++ b/Tests/RunCMake/CommandLine/install-options-to-vars-result.txt
diff --git a/Tests/RunCMake/CommandLine/install-options-to-vars-stderr.txt b/Tests/RunCMake/CommandLine/install-options-to-vars-stderr.txt
new file mode 100644
index 000000000..f7b1583ad
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/install-options-to-vars-stderr.txt
@@ -0,0 +1,4 @@
+CMAKE_INSTALL_PREFIX is /var/test
+CMAKE_INSTALL_COMPONENT is pack
+CMAKE_INSTALL_CONFIG_NAME is sample
+CMAKE_INSTALL_DO_STRIP is 1
diff --git a/Tests/RunCMake/CommandLine/no-S-B-stderr.txt b/Tests/RunCMake/CommandLine/no-S-B-stderr.txt
new file mode 100644
index 000000000..c166dcf56
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/no-S-B-stderr.txt
@@ -0,0 +1,4 @@
+CMake Warning:
+ No source or binary directory provided. Both will be assumed to be the
+ same as the current working directory, but note that this warning will
+ become a fatal error in future CMake releases.
diff --git a/Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized-stderr.txt b/Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized-stderr.txt
new file mode 100644
index 000000000..74429b643
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized-stderr.txt
@@ -0,0 +1,2 @@
+^.*/Tests/RunCMake/CommandLine/CMakeLists.txt\(1\): cmake_minimum_required\(VERSION 3.0 \)
+.*/Tests/RunCMake/CommandLine/CMakeLists.txt\(2\): project\(trace-expand-warn-uninitialized NONE \)
diff --git a/Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized.cmake b/Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized.cmake
new file mode 100644
index 000000000..ec3e4d46d
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-expand-warn-uninitialized.cmake
@@ -0,0 +1,4 @@
+cmake_policy(SET CMP0053 OLD)
+message(STATUS "'${uninitialized_variable}'")
+cmake_policy(SET CMP0053 NEW)
+message(STATUS "'${uninitialized_variable}'")
diff --git a/Tests/RunCMake/CommandLine/trace-redirect-check.cmake b/Tests/RunCMake/CommandLine/trace-redirect-check.cmake
new file mode 100644
index 000000000..1ee0e0de6
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-redirect-check.cmake
@@ -0,0 +1,13 @@
+file(READ ${RunCMake_SOURCE_DIR}/trace-stderr.txt expected_content)
+string(REGEX REPLACE "\n+$" "" expected_content "${expected_content}")
+
+file(READ ${RunCMake_BINARY_DIR}/redirected.trace actual_content)
+string(REGEX REPLACE "\r\n" "\n" actual_content "${actual_content}")
+string(REGEX REPLACE "\n+$" "" actual_content "${actual_content}")
+if(NOT "${actual_content}" MATCHES "${expected_content}")
+ set(RunCMake_TEST_FAILED
+ "Trace file content does not match that expected."
+ "Expected to match:\n${expected_content}\n"
+ "Actual content:\n${actual_content}\n"
+ )
+endif()
diff --git a/Tests/RunCMake/CommandLine/trace-redirect-nofile-result.txt b/Tests/RunCMake/CommandLine/trace-redirect-nofile-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-redirect-nofile-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/trace-redirect-nofile-stderr.txt b/Tests/RunCMake/CommandLine/trace-redirect-nofile-stderr.txt
new file mode 100644
index 000000000..edb0c8e6f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-redirect-nofile-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: Error opening trace file /no/such/file.txt: .+$
diff --git a/Tests/RunCMake/CommandLine/trace-redirect-nofile.cmake b/Tests/RunCMake/CommandLine/trace-redirect-nofile.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-redirect-nofile.cmake
diff --git a/Tests/RunCMake/CommandLine/trace-redirect-stdout.txt b/Tests/RunCMake/CommandLine/trace-redirect-stdout.txt
new file mode 100644
index 000000000..775f2b5f0
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-redirect-stdout.txt
@@ -0,0 +1 @@
+^.*Trace will be written to .+redirected.trace.*$
diff --git a/Tests/RunCMake/CommandLine/trace-redirect.cmake b/Tests/RunCMake/CommandLine/trace-redirect.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-redirect.cmake
diff --git a/Tests/RunCMake/CommandLine/warn-uninitialized-stderr.txt b/Tests/RunCMake/CommandLine/warn-uninitialized-stderr.txt
new file mode 100644
index 000000000..41ba09898
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/warn-uninitialized-stderr.txt
@@ -0,0 +1,53 @@
+^CMake Warning \(dev\) at warn-uninitialized.cmake:3 \(set\):
+ uninitialized variable 'OLD_WARN_FROM_NORMAL_CMAKE_FILE_INSIDE_BRACES'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:4 \(set\):
+ uninitialized variable 'OLD_WARN_FROM_NORMAL_CMAKE_FILE_IN_ATS'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:5 \(string\):
+ uninitialized variable 'OLD_WARN_FROM_STRING_CONFIGURE_INSIDE_BRACES'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:7 \(configure_file\):
+ uninitialized variable 'OLD_WARN_FROM_CONFIGURE_FILE_INSIDE_AT'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:8 \(string\):
+ uninitialized variable 'OLD_WARN_FROM_STRING_CONFIGURE_INSIDE_AT'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:13 \(set\):
+ uninitialized variable 'NEW_WARN_FROM_NORMAL_CMAKE_FILE_INSIDE_BRACES'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:14 \(string\):
+ uninitialized variable 'NEW_WARN_FROM_STRING_CONFIGURE_INSIDE_BRACES'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:16 \(configure_file\):
+ uninitialized variable 'NEW_WARN_FROM_CONFIGURE_FILE_INSIDE_AT'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at warn-uninitialized.cmake:17 \(string\):
+ uninitialized variable 'NEW_WARN_FROM_STRING_CONFIGURE_INSIDE_AT'
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/CommandLine/warn-uninitialized.cmake b/Tests/RunCMake/CommandLine/warn-uninitialized.cmake
new file mode 100644
index 000000000..ff65c1631
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/warn-uninitialized.cmake
@@ -0,0 +1,18 @@
+cmake_policy(PUSH)
+cmake_policy(SET CMP0053 OLD)
+set(FOO "${OLD_WARN_FROM_NORMAL_CMAKE_FILE_INSIDE_BRACES}")
+set(FOO "@OLD_WARN_FROM_NORMAL_CMAKE_FILE_IN_ATS@")
+string(CONFIGURE "\${OLD_WARN_FROM_STRING_CONFIGURE_INSIDE_BRACES}" OUT1)
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/file1.in "\@OLD_WARN_FROM_CONFIGURE_FILE_INSIDE_AT\@")
+configure_file(${CMAKE_CURRENT_BINARY_DIR}/file1.in file1.out)
+string(CONFIGURE "\@OLD_WARN_FROM_STRING_CONFIGURE_INSIDE_AT\@" OUT2)
+cmake_policy(POP)
+
+cmake_policy(PUSH)
+cmake_policy(SET CMP0053 NEW)
+set(FOO "${NEW_WARN_FROM_NORMAL_CMAKE_FILE_INSIDE_BRACES}")
+string(CONFIGURE "\${NEW_WARN_FROM_STRING_CONFIGURE_INSIDE_BRACES}" OUT3)
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/file2.in "\@NEW_WARN_FROM_CONFIGURE_FILE_INSIDE_AT\@")
+configure_file(${CMAKE_CURRENT_BINARY_DIR}/file2.in file2.out)
+string(CONFIGURE "@NEW_WARN_FROM_STRING_CONFIGURE_INSIDE_AT@" OUT4)
+cmake_policy(POP)
diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
index 12635dbfb..a64af9524 100644
--- a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake
@@ -4,25 +4,33 @@ function(external_command_test NAME)
run_cmake_command(${NAME} ${CMAKE_COMMAND} -E ${ARGN})
endfunction()
-external_command_test(bad-opt1 tar cvf bad.tar --bad)
-external_command_test(bad-mtime1 tar cvf bad.tar --mtime=bad .)
-external_command_test(bad-from1 tar cvf bad.tar --files-from=bad)
-external_command_test(bad-from2 tar cvf bad.tar --files-from=.)
-external_command_test(bad-from3 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from3.txt)
-external_command_test(bad-from4 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from4.txt)
-external_command_test(bad-from5 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from5.txt)
-external_command_test(end-opt1 tar cvf bad.tar -- --bad)
-external_command_test(end-opt2 tar cvf bad.tar --)
-external_command_test(mtime tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC")
-external_command_test(bad-format tar cvf bad.tar "--format=bad-format")
-external_command_test(zip-bz2 tar cvjf bad.tar "--format=zip")
-external_command_test(7zip-gz tar cvzf bad.tar "--format=7zip")
+external_command_test(without-files tar cvf bad.tar)
+external_command_test(bad-opt1 tar cvf bad.tar --bad)
+external_command_test(bad-mtime1 tar cvf bad.tar --mtime=bad .)
+external_command_test(bad-from1 tar cvf bad.tar --files-from=bad)
+external_command_test(bad-from2 tar cvf bad.tar --files-from=.)
+external_command_test(bad-from3 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from3.txt)
+external_command_test(bad-from4 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from4.txt)
+external_command_test(bad-from5 tar cvf bad.tar --files-from=${CMAKE_CURRENT_LIST_DIR}/bad-from5.txt)
+external_command_test(bad-file tar cf bad.tar badfile.txt ${CMAKE_CURRENT_LIST_DIR}/test-file.txt)
+external_command_test(bad-without-action tar f bad.tar ${CMAKE_CURRENT_LIST_DIR}/test-file.txt)
+external_command_test(bad-wrong-flag tar cvfq bad.tar ${CMAKE_CURRENT_LIST_DIR}/test-file.txt)
+external_command_test(end-opt1 tar cvf bad.tar -- --bad)
+external_command_test(end-opt2 tar cvf bad.tar --)
+external_command_test(mtime tar cvf bad.tar "--mtime=1970-01-01 00:00:00 UTC" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt)
+external_command_test(bad-format tar cvf bad.tar "--format=bad-format" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt)
+external_command_test(zip-bz2 tar cvjf bad.tar "--format=zip" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt)
+external_command_test(7zip-gz tar cvzf bad.tar "--format=7zip" ${CMAKE_CURRENT_LIST_DIR}/test-file.txt)
run_cmake(7zip)
run_cmake(gnutar)
run_cmake(gnutar-gz)
run_cmake(pax)
run_cmake(pax-xz)
+run_cmake(pax-zstd)
run_cmake(paxr)
run_cmake(paxr-bz2)
run_cmake(zip)
+
+# Extracting only selected files or directories
+run_cmake(zip-filtered)
diff --git a/Tests/RunCMake/CommandLineTar/bad-file-result.txt b/Tests/RunCMake/CommandLineTar/bad-file-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/bad-file-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLineTar/bad-file-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-file-stderr.txt
new file mode 100644
index 000000000..1f9f748ce
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/bad-file-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error: Unable to read from file 'badfile.txt': .*
+CMake Error: Problem creating tar: bad.tar$
diff --git a/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt
index 1417d4d32..fb0702a1a 100644
--- a/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from4-stderr.txt
@@ -1,2 +1,2 @@
-^CMake Error: archive_read_disk_entry_from_file 'does-not-exist':.*
+^CMake Error: Unable to read from file 'does-not-exist':.*
CMake Error: Problem creating tar: bad.tar$
diff --git a/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt
index 1417d4d32..fb0702a1a 100644
--- a/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/bad-from5-stderr.txt
@@ -1,2 +1,2 @@
-^CMake Error: archive_read_disk_entry_from_file 'does-not-exist':.*
+^CMake Error: Unable to read from file 'does-not-exist':.*
CMake Error: Problem creating tar: bad.tar$
diff --git a/Tests/RunCMake/CommandLineTar/bad-without-action-result.txt b/Tests/RunCMake/CommandLineTar/bad-without-action-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/bad-without-action-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLineTar/bad-without-action-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-without-action-stderr.txt
new file mode 100644
index 000000000..2fec25467
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/bad-without-action-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: tar: No action specified. Please choose: 't' \(list\), 'c' \(create\) or 'x' \(extract\)$
diff --git a/Tests/RunCMake/CommandLineTar/bad-wrong-flag-stderr.txt b/Tests/RunCMake/CommandLineTar/bad-wrong-flag-stderr.txt
new file mode 100644
index 000000000..d5c1e0163
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/bad-wrong-flag-stderr.txt
@@ -0,0 +1 @@
+^tar: Unknown argument: q
diff --git a/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt b/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt
index 1fddf6d2d..1342dc8d0 100644
--- a/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt
+++ b/Tests/RunCMake/CommandLineTar/end-opt1-stderr.txt
@@ -1,2 +1,2 @@
-^CMake Error: archive_read_disk_entry_from_file '--bad':.*
+^CMake Error: Unable to read from file '--bad':.*
CMake Error: Problem creating tar: bad.tar$
diff --git a/Tests/RunCMake/CommandLineTar/end-opt2-stderr.txt b/Tests/RunCMake/CommandLineTar/end-opt2-stderr.txt
new file mode 100644
index 000000000..70166f540
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/end-opt2-stderr.txt
@@ -0,0 +1 @@
+^tar: No files or directories specified
diff --git a/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake b/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake
index 5f2674a8f..53ee96186 100644
--- a/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake
+++ b/Tests/RunCMake/CommandLineTar/gnutar-gz.cmake
@@ -1,9 +1,9 @@
set(OUTPUT_NAME "test.tar.gz")
-set(COMPRESSION_FLAGS cvzf)
+set(COMPRESSION_FLAGS -cvzf)
set(COMPRESSION_OPTIONS --format=gnutar)
-set(DECOMPRESSION_FLAGS xvzf)
+set(DECOMPRESSION_FLAGS -xvzf)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
diff --git a/Tests/RunCMake/CommandLineTar/pax-zstd.cmake b/Tests/RunCMake/CommandLineTar/pax-zstd.cmake
new file mode 100644
index 000000000..c2a304d80
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/pax-zstd.cmake
@@ -0,0 +1,10 @@
+set(OUTPUT_NAME "test.tar.zstd")
+
+set(COMPRESSION_FLAGS cvf)
+set(COMPRESSION_OPTIONS --format=pax --zstd)
+
+set(DECOMPRESSION_FLAGS xvf)
+
+include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
+
+check_magic("28b52ffd0058" LIMIT 6 HEX)
diff --git a/Tests/RunCMake/CommandLineTar/pax.cmake b/Tests/RunCMake/CommandLineTar/pax.cmake
index 60ed2385c..77f74d135 100644
--- a/Tests/RunCMake/CommandLineTar/pax.cmake
+++ b/Tests/RunCMake/CommandLineTar/pax.cmake
@@ -1,9 +1,9 @@
set(OUTPUT_NAME "test.tar")
-set(COMPRESSION_FLAGS cvf)
+set(COMPRESSION_FLAGS -cvf)
set(COMPRESSION_OPTIONS --format=pax)
-set(DECOMPRESSION_FLAGS xvf)
+set(DECOMPRESSION_FLAGS -xvf)
include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
diff --git a/Tests/RunCMake/CommandLineTar/roundtrip.cmake b/Tests/RunCMake/CommandLineTar/roundtrip.cmake
index dc1c88528..fa63d1240 100644
--- a/Tests/RunCMake/CommandLineTar/roundtrip.cmake
+++ b/Tests/RunCMake/CommandLineTar/roundtrip.cmake
@@ -47,7 +47,11 @@ file(REMOVE_RECURSE ${FULL_DECOMPRESS_DIR})
file(MAKE_DIRECTORY ${FULL_DECOMPRESS_DIR})
run_tar(${CMAKE_CURRENT_BINARY_DIR} ${COMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${COMPRESSION_OPTIONS} ${COMPRESS_DIR})
-run_tar(${FULL_DECOMPRESS_DIR} ${DECOMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${DECOMPRESSION_OPTIONS})
+run_tar(${FULL_DECOMPRESS_DIR} ${DECOMPRESSION_FLAGS} ${FULL_OUTPUT_NAME} ${DECOMPRESSION_OPTIONS} -- ${DECOMPRESSION_PATHNAMES})
+
+if(CUSTOM_CHECK_FILES)
+ set(CHECK_FILES ${CUSTOM_CHECK_FILES})
+endif()
foreach(file ${CHECK_FILES})
set(input ${FULL_COMPRESS_DIR}/${file})
@@ -69,6 +73,14 @@ foreach(file ${CHECK_FILES})
endif()
endforeach()
+foreach(file ${NOT_EXISTING_FILES_CHECK})
+ set(output ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file})
+
+ if(EXISTS ${output})
+ message(SEND_ERROR "File ${output} exists but it shouldn't")
+ endif()
+endforeach()
+
function(check_magic EXPECTED)
file(READ ${FULL_OUTPUT_NAME} ACTUAL
${ARGN}
diff --git a/Tests/RunCMake/CommandLineTar/test-file.txt b/Tests/RunCMake/CommandLineTar/test-file.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/test-file.txt
diff --git a/Tests/RunCMake/CommandLineTar/without-files-stderr.txt b/Tests/RunCMake/CommandLineTar/without-files-stderr.txt
new file mode 100644
index 000000000..70166f540
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/without-files-stderr.txt
@@ -0,0 +1 @@
+^tar: No files or directories specified
diff --git a/Tests/RunCMake/CommandLineTar/zip-filtered.cmake b/Tests/RunCMake/CommandLineTar/zip-filtered.cmake
new file mode 100644
index 000000000..c13210ef0
--- /dev/null
+++ b/Tests/RunCMake/CommandLineTar/zip-filtered.cmake
@@ -0,0 +1,28 @@
+set(OUTPUT_NAME "test.zip")
+
+set(COMPRESSION_FLAGS cvf)
+set(COMPRESSION_OPTIONS --format=zip)
+
+set(DECOMPRESSION_FLAGS xvf)
+set(LIST_ARCHIVE TRUE)
+set(DECOMPRESSION_PATHNAMES
+ compress_dir/f1.txt # Decompress only file
+ compress_dir/d1 # and whole directory
+)
+
+set(CUSTOM_CHECK_FILES
+ "f1.txt"
+ "d1/f1.txt"
+)
+
+# This files shouldn't exists
+set(NOT_EXISTING_FILES_CHECK
+ "d 2/f1.txt"
+ "d + 3/f1.txt"
+ "d_4/f1.txt"
+ "d-4/f1.txt"
+)
+
+include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake)
+
+check_magic("504b0304" LIMIT 4 HEX)
diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CUDA-Build-stdout.txt
new file mode 100644
index 000000000..3313e31f6
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/CUDA-Build-stdout.txt
@@ -0,0 +1 @@
+.*-E env USED_LAUNCHER=1.*
diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/CUDA-launch-Build-stdout.txt
new file mode 100644
index 000000000..3313e31f6
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/CUDA-launch-Build-stdout.txt
@@ -0,0 +1 @@
+.*-E env USED_LAUNCHER=1.*
diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-launch.cmake b/Tests/RunCMake/CompilerLauncher/CUDA-launch.cmake
new file mode 100644
index 000000000..6b4b816e9
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/CUDA-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(CUDA.cmake)
diff --git a/Tests/RunCMake/CompilerLauncher/CUDA.cmake b/Tests/RunCMake/CompilerLauncher/CUDA.cmake
new file mode 100644
index 000000000..fe5560bc7
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/CUDA.cmake
@@ -0,0 +1,4 @@
+enable_language(CUDA)
+set(CMAKE_CUDA_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1")
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+add_executable(main main.cu)
diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/Fortran-Build-stdout.txt
new file mode 100644
index 000000000..3313e31f6
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/Fortran-Build-stdout.txt
@@ -0,0 +1 @@
+.*-E env USED_LAUNCHER=1.*
diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/Fortran-launch-Build-stdout.txt
new file mode 100644
index 000000000..3313e31f6
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/Fortran-launch-Build-stdout.txt
@@ -0,0 +1 @@
+.*-E env USED_LAUNCHER=1.*
diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-launch.cmake b/Tests/RunCMake/CompilerLauncher/Fortran-launch.cmake
new file mode 100644
index 000000000..7e9a56479
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/Fortran-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(Fortran.cmake)
diff --git a/Tests/RunCMake/CompilerLauncher/Fortran.cmake b/Tests/RunCMake/CompilerLauncher/Fortran.cmake
new file mode 100644
index 000000000..72cc03ee6
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/Fortran.cmake
@@ -0,0 +1,4 @@
+enable_language(Fortran)
+set(CMAKE_Fortran_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1")
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+add_executable(main main.F)
diff --git a/Tests/RunCMake/CompilerLauncher/OBJC-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/OBJC-Build-stdout.txt
new file mode 100644
index 000000000..3313e31f6
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/OBJC-Build-stdout.txt
@@ -0,0 +1 @@
+.*-E env USED_LAUNCHER=1.*
diff --git a/Tests/RunCMake/CompilerLauncher/OBJC-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/OBJC-launch-Build-stdout.txt
new file mode 100644
index 000000000..3313e31f6
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/OBJC-launch-Build-stdout.txt
@@ -0,0 +1 @@
+.*-E env USED_LAUNCHER=1.*
diff --git a/Tests/RunCMake/CompilerLauncher/OBJC-launch.cmake b/Tests/RunCMake/CompilerLauncher/OBJC-launch.cmake
new file mode 100644
index 000000000..43e852164
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/OBJC-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(OBJC.cmake)
diff --git a/Tests/RunCMake/CompilerLauncher/OBJC.cmake b/Tests/RunCMake/CompilerLauncher/OBJC.cmake
new file mode 100644
index 000000000..55c4493de
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/OBJC.cmake
@@ -0,0 +1,4 @@
+enable_language(OBJC)
+set(CMAKE_OBJC_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1")
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+add_executable(main main.m)
diff --git a/Tests/RunCMake/CompilerLauncher/OBJCXX-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/OBJCXX-Build-stdout.txt
new file mode 100644
index 000000000..3313e31f6
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/OBJCXX-Build-stdout.txt
@@ -0,0 +1 @@
+.*-E env USED_LAUNCHER=1.*
diff --git a/Tests/RunCMake/CompilerLauncher/OBJCXX-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/OBJCXX-launch-Build-stdout.txt
new file mode 100644
index 000000000..3313e31f6
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/OBJCXX-launch-Build-stdout.txt
@@ -0,0 +1 @@
+.*-E env USED_LAUNCHER=1.*
diff --git a/Tests/RunCMake/CompilerLauncher/OBJCXX-launch.cmake b/Tests/RunCMake/CompilerLauncher/OBJCXX-launch.cmake
new file mode 100644
index 000000000..5a54bffeb
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/OBJCXX-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(OBJCXX.cmake)
diff --git a/Tests/RunCMake/CompilerLauncher/OBJCXX.cmake b/Tests/RunCMake/CompilerLauncher/OBJCXX.cmake
new file mode 100644
index 000000000..e62960388
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/OBJCXX.cmake
@@ -0,0 +1,4 @@
+enable_language(OBJCXX)
+set(CMAKE_OBJCXX_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1")
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+add_executable(main main.mm)
diff --git a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake
index 5884d5c4d..44202609f 100644
--- a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake
@@ -15,9 +15,20 @@ function(run_compiler_launcher lang)
run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build . ${verbose_args})
endfunction()
-run_compiler_launcher(C)
-run_compiler_launcher(CXX)
-if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
- run_compiler_launcher(C-launch)
- run_compiler_launcher(CXX-launch)
+set(langs C CXX)
+if(CMake_TEST_CUDA)
+ list(APPEND langs CUDA)
endif()
+if(CMake_TEST_Fortran)
+ list(APPEND langs Fortran)
+endif()
+if(CMake_TEST_OBJC)
+ list(APPEND langs OBJC OBJCXX)
+endif()
+
+foreach(lang ${langs})
+ run_compiler_launcher(${lang})
+ if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
+ run_compiler_launcher(${lang}-launch)
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/CompilerLauncher/main.F b/Tests/RunCMake/CompilerLauncher/main.F
new file mode 100644
index 000000000..53ec0d10b
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/main.F
@@ -0,0 +1,2 @@
+ PROGRAM MAIN
+ END
diff --git a/Tests/RunCMake/CompilerLauncher/main.cu b/Tests/RunCMake/CompilerLauncher/main.cu
new file mode 100644
index 000000000..f8b643afb
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/main.cu
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CompilerLauncher/main.m b/Tests/RunCMake/CompilerLauncher/main.m
new file mode 100644
index 000000000..8488f4e58
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/main.m
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CompilerLauncher/main.mm b/Tests/RunCMake/CompilerLauncher/main.mm
new file mode 100644
index 000000000..f8b643afb
--- /dev/null
+++ b/Tests/RunCMake/CompilerLauncher/main.mm
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/Configure/RerunCMake-build3-result.txt b/Tests/RunCMake/Configure/RerunCMake-build3-result.txt
new file mode 100644
index 000000000..d197c913c
--- /dev/null
+++ b/Tests/RunCMake/Configure/RerunCMake-build3-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/Configure/RerunCMake-build3-stdout.txt b/Tests/RunCMake/Configure/RerunCMake-build3-stdout.txt
new file mode 100644
index 000000000..dde2ea67a
--- /dev/null
+++ b/Tests/RunCMake/Configure/RerunCMake-build3-stdout.txt
@@ -0,0 +1 @@
+Rerun error 3
diff --git a/Tests/RunCMake/Configure/RerunCMake-build4-result.txt b/Tests/RunCMake/Configure/RerunCMake-build4-result.txt
new file mode 100644
index 000000000..d197c913c
--- /dev/null
+++ b/Tests/RunCMake/Configure/RerunCMake-build4-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/Configure/RerunCMake-build4-stdout.txt b/Tests/RunCMake/Configure/RerunCMake-build4-stdout.txt
new file mode 100644
index 000000000..b8727e169
--- /dev/null
+++ b/Tests/RunCMake/Configure/RerunCMake-build4-stdout.txt
@@ -0,0 +1 @@
+Rerun error 4
diff --git a/Tests/RunCMake/Configure/RerunCMake.cmake b/Tests/RunCMake/Configure/RerunCMake.cmake
index 5a561bf45..c0b079819 100644
--- a/Tests/RunCMake/Configure/RerunCMake.cmake
+++ b/Tests/RunCMake/Configure/RerunCMake.cmake
@@ -9,3 +9,9 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${depend})
file(READ ${depend} content)
file(WRITE ${output} "${content}")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS RerunCMake.txt)
+
+set(error ${CMAKE_CURRENT_BINARY_DIR}/CustomCMakeError.txt)
+if(EXISTS ${error})
+ file(READ ${error} content)
+ message(FATAL_ERROR "Rerun error ${content}")
+endif()
diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake b/Tests/RunCMake/Configure/RunCMakeTest.cmake
index 4a135befd..76d843c6e 100644
--- a/Tests/RunCMake/Configure/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake
@@ -14,6 +14,7 @@ set(input "${RunCMake_TEST_BINARY_DIR}/CustomCMakeInput.txt")
set(stamp "${RunCMake_TEST_BINARY_DIR}/CustomCMakeStamp.txt")
set(depend "${RunCMake_TEST_BINARY_DIR}/CustomCMakeDepend.txt")
set(output "${RunCMake_TEST_BINARY_DIR}/CustomCMakeOutput.txt")
+set(error "${RunCMake_TEST_BINARY_DIR}/CustomCMakeError.txt")
file(WRITE "${input}" "1")
file(WRITE "${depend}" "1")
run_cmake(RerunCMake)
@@ -22,6 +23,22 @@ file(WRITE "${input}" "2")
run_cmake_command(RerunCMake-build1 ${CMAKE_COMMAND} --build .)
file(WRITE "${depend}" "2")
run_cmake_command(RerunCMake-build2 ${CMAKE_COMMAND} --build .)
+execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) # handle 1s resolution
+file(WRITE "${depend}" "3")
+file(WRITE "${error}" "3")
+set(RunCMake_TEST_OUTPUT_MERGE 1)
+run_cmake_command(RerunCMake-build3 ${CMAKE_COMMAND} --build .)
+if(MSVC_IDE)
+ # Make sure that for Visual Studio the error occurs from within the build
+ # system.
+ file(REMOVE "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/generate.stamp.list")
+ file(WRITE "${error}" "4")
+ # With Visual Studio the error must be on stdout, otherwise the error was not
+ # emitted by ZERO_CHECK.
+ set(RunCMake_TEST_OUTPUT_MERGE 0)
+ run_cmake_command(RerunCMake-build4 ${CMAKE_COMMAND} --build .)
+endif()
+unset(RunCMake_TEST_OUTPUT_MERGE)
unset(RunCMake_TEST_BINARY_DIR)
unset(RunCMake_TEST_NO_CLEAN)
diff --git a/Tests/RunCMake/Cppcheck/C-Build-stdout.txt b/Tests/RunCMake/Cppcheck/C-Build-stdout.txt
new file mode 100644
index 000000000..26eded30e
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-Build-stdout.txt
@@ -0,0 +1 @@
+.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.*
diff --git a/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt b/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt
new file mode 100644
index 000000000..d197c913c
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/Cppcheck/C-bad-Build-stdout.txt b/Tests/RunCMake/Cppcheck/C-bad-Build-stdout.txt
new file mode 100644
index 000000000..2370ce1c1
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-bad-Build-stdout.txt
@@ -0,0 +1,2 @@
+stdout from bad command line arg '-bad'
+stderr from bad command line arg '-bad'
diff --git a/Tests/RunCMake/Cppcheck/C-bad.cmake b/Tests/RunCMake/Cppcheck/C-bad.cmake
new file mode 100644
index 000000000..920e4b4bc
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-bad.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+set(CMAKE_C_CPPCHECK "${PSEUDO_CPPCHECK}" -bad)
+add_executable(main main.c)
diff --git a/Tests/RunCMake/Cppcheck/C-error-Build-result.txt b/Tests/RunCMake/Cppcheck/C-error-Build-result.txt
new file mode 100644
index 000000000..d197c913c
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-error-Build-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/Cppcheck/C-error-Build-stdout.txt b/Tests/RunCMake/Cppcheck/C-error-Build-stdout.txt
new file mode 100644
index 000000000..4a24c0ccd
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-error-Build-stdout.txt
@@ -0,0 +1 @@
+.*Error: cppcheck reported failure.*error.*warning.*style.*performance.*information.*
diff --git a/Tests/RunCMake/Cppcheck/C-error.cmake b/Tests/RunCMake/Cppcheck/C-error.cmake
new file mode 100644
index 000000000..2254d7511
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-error.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+set(CMAKE_C_CPPCHECK "${PSEUDO_CPPCHECK}" -error)
+add_executable(main main.c)
diff --git a/Tests/RunCMake/Cppcheck/C-launch-Build-stdout.txt b/Tests/RunCMake/Cppcheck/C-launch-Build-stdout.txt
new file mode 100644
index 000000000..26eded30e
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-launch-Build-stdout.txt
@@ -0,0 +1 @@
+.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.*
diff --git a/Tests/RunCMake/Cppcheck/C-launch.cmake b/Tests/RunCMake/Cppcheck/C-launch.cmake
new file mode 100644
index 000000000..e66ca203e
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(C.cmake)
diff --git a/Tests/RunCMake/Cppcheck/C.cmake b/Tests/RunCMake/Cppcheck/C.cmake
new file mode 100644
index 000000000..b1f5bf789
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C.cmake
@@ -0,0 +1,4 @@
+
+enable_language(C)
+set(CMAKE_C_CPPCHECK "${PSEUDO_CPPCHECK}")
+add_executable(main main.c)
diff --git a/Tests/RunCMake/Cppcheck/CMakeLists.txt b/Tests/RunCMake/Cppcheck/CMakeLists.txt
new file mode 100644
index 000000000..a640c569e
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.7)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/Cppcheck/CXX-Build-stdout.txt b/Tests/RunCMake/Cppcheck/CXX-Build-stdout.txt
new file mode 100644
index 000000000..26eded30e
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/CXX-Build-stdout.txt
@@ -0,0 +1 @@
+.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.*
diff --git a/Tests/RunCMake/Cppcheck/CXX-launch-Build-stdout.txt b/Tests/RunCMake/Cppcheck/CXX-launch-Build-stdout.txt
new file mode 100644
index 000000000..26eded30e
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/CXX-launch-Build-stdout.txt
@@ -0,0 +1 @@
+.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.*
diff --git a/Tests/RunCMake/Cppcheck/CXX-launch.cmake b/Tests/RunCMake/Cppcheck/CXX-launch.cmake
new file mode 100644
index 000000000..3002c9d68
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/CXX-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(CXX.cmake)
diff --git a/Tests/RunCMake/Cppcheck/CXX.cmake b/Tests/RunCMake/Cppcheck/CXX.cmake
new file mode 100644
index 000000000..3b7947127
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/CXX.cmake
@@ -0,0 +1,3 @@
+enable_language(CXX)
+set(CMAKE_CXX_CPPCHECK "${PSEUDO_CPPCHECK}")
+add_executable(main main.cxx)
diff --git a/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake b/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake
new file mode 100644
index 000000000..e395f3696
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake
@@ -0,0 +1,24 @@
+include(RunCMake)
+
+set(RunCMake_TEST_OPTIONS "-DPSEUDO_CPPCHECK=${PSEUDO_CPPCHECK}")
+
+function(run_cppcheck lang)
+ # Use a single build tree for tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${lang}-build")
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake(${lang})
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
+ run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build .)
+endfunction()
+
+run_cppcheck(C)
+run_cppcheck(CXX)
+run_cppcheck(C-error)
+run_cppcheck(C-bad)
+
+if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
+ run_cppcheck(C-launch)
+ run_cppcheck(CXX-launch)
+endif()
diff --git a/Tests/RunCMake/Cppcheck/main.c b/Tests/RunCMake/Cppcheck/main.c
new file mode 100644
index 000000000..8488f4e58
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/main.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/Cppcheck/main.cxx b/Tests/RunCMake/Cppcheck/main.cxx
new file mode 100644
index 000000000..f8b643afb
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/main.cxx
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/Cpplint/C-error-Build-result.txt b/Tests/RunCMake/Cpplint/C-error-Build-result.txt
index d197c913c..573541ac9 100644
--- a/Tests/RunCMake/Cpplint/C-error-Build-result.txt
+++ b/Tests/RunCMake/Cpplint/C-error-Build-result.txt
@@ -1 +1 @@
-[^0]
+0
diff --git a/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt b/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt
index d197c913c..573541ac9 100644
--- a/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt
+++ b/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt
@@ -1 +1 @@
-[^0]
+0
diff --git a/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt b/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt
index d197c913c..573541ac9 100644
--- a/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt
+++ b/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt
@@ -1 +1 @@
-[^0]
+0
diff --git a/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt
index d197c913c..573541ac9 100644
--- a/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt
+++ b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt
@@ -1 +1 @@
-[^0]
+0
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake
index c4db11bde..9fcc5bcd7 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommand.cmake
@@ -26,12 +26,14 @@ add_custom_command(OUTPUT output2
# DoesNotUseEmulator: The command will fail if emulator is prepended
add_custom_command(OUTPUT output3
+ COMMAND ${CMAKE_COMMAND} -E echo generated_exe_emulator_unexpected
COMMAND $<TARGET_FILE:generated_exe_emulator_unexpected>
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output3
DEPENDS generated_exe_emulator_unexpected)
# DoesNotUseEmulator: The command will fail if emulator is prepended
add_custom_command(OUTPUT outputImp
+ COMMAND ${CMAKE_COMMAND} -E echo generated_exe_emulator_unexpected_imported
COMMAND generated_exe_emulator_unexpected_imported
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/outputImp
)
@@ -39,6 +41,7 @@ add_custom_command(OUTPUT outputImp
# UsesEmulator: The command only succeeds if the emulator is prepended
# to the command.
add_custom_command(OUTPUT output4
+ COMMAND ${CMAKE_COMMAND} -E echo generated_exe_emulator_expected
COMMAND generated_exe_emulator_expected
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output4
DEPENDS generated_exe_emulator_expected)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg-build-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg-build-check.cmake
new file mode 100644
index 000000000..9ca610660
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg-build-check.cmake
@@ -0,0 +1,3 @@
+if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/output")
+ message(FATAL_ERROR "Failed to create output: ${RunCMake_TEST_BINARY_DIR}/output")
+endif()
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg.cmake
new file mode 100644
index 000000000..d9059ca6e
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomCommandWithArg.cmake
@@ -0,0 +1,14 @@
+set(CMAKE_CROSSCOMPILING 1)
+
+# Executable: Return error code different from 0
+add_executable(generated_exe_emulator_expected simple_src_exiterror.cxx)
+
+add_custom_command(OUTPUT output
+ COMMAND generated_exe_emulator_expected
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output
+ DEPENDS generated_exe_emulator_expected)
+
+add_custom_target(ensure_build ALL
+ SOURCES
+ ${CMAKE_CURRENT_BINARY_DIR}/output
+)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg-build-check.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg-build-check.cmake
new file mode 100644
index 000000000..13c0db96a
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg-build-check.cmake
@@ -0,0 +1 @@
+include(${CMAKE_CURRENT_LIST_DIR}/AddCustomCommandWithArg-build-check.cmake)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg.cmake b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg.cmake
new file mode 100644
index 000000000..dcd80d53a
--- /dev/null
+++ b/Tests/RunCMake/CrosscompilingEmulator/AddCustomTargetWithArg.cmake
@@ -0,0 +1,9 @@
+set(CMAKE_CROSSCOMPILING 1)
+
+# Executable: Return error code different from 0
+add_executable(generated_exe_emulator_expected simple_src_exiterror.cxx)
+
+add_custom_target(generate_output ALL
+ generated_exe_emulator_expected
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/output
+ DEPENDS generated_exe_emulator_expected)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake
index 1aeb510f0..2fdefc4ce 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/CrosscompilingEmulatorProperty.cmake
@@ -26,3 +26,9 @@ get_property(emulator TARGET target_without_emulator
if(NOT "${emulator}" STREQUAL "")
message(SEND_ERROR "Default CROSSCOMPILING_EMULATOR property not set to null")
endif()
+
+add_executable(target_with_empty_emulator simple_src_exiterror.cxx)
+set_property(TARGET target_with_empty_emulator PROPERTY CROSSCOMPILING_EMULATOR "")
+
+enable_testing()
+add_test(NAME test_target_with_empty_emulator COMMAND target_with_empty_emulator)
diff --git a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
index 71aaad19b..97b7b5a31 100644
--- a/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CrosscompilingEmulator/RunCMakeTest.cmake
@@ -11,13 +11,18 @@ function(CustomCommandGenerator_run_and_build case)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
set(RunCMake_TEST_NO_CLEAN 1)
- set(RunCMake_TEST_OPTIONS
- "-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR_CUSTOM_COMMAND}")
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
run_cmake(${case})
run_cmake_command(${case}-build ${CMAKE_COMMAND} --build .)
endfunction()
+set(RunCMake_TEST_OPTIONS
+"-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR_CUSTOM_COMMAND}")
CustomCommandGenerator_run_and_build(AddCustomCommand)
CustomCommandGenerator_run_and_build(AddCustomTarget)
+
+set(RunCMake_TEST_OPTIONS
+"-DCMAKE_CROSSCOMPILING_EMULATOR=${PSEUDO_EMULATOR_CUSTOM_COMMAND_ARG}\;custom_argument")
+CustomCommandGenerator_run_and_build(AddCustomCommandWithArg)
+CustomCommandGenerator_run_and_build(AddCustomTargetWithArg)
diff --git a/Tests/RunCMake/ExternalData/BadAlgoMap1-stderr.txt b/Tests/RunCMake/ExternalData/BadAlgoMap1-stderr.txt
index c3708a9c8..5388c46de 100644
--- a/Tests/RunCMake/ExternalData/BadAlgoMap1-stderr.txt
+++ b/Tests/RunCMake/ExternalData/BadAlgoMap1-stderr.txt
@@ -5,5 +5,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
The transform name must be a valid C identifier.
Call Stack \(most recent call first\):
- BadAlgoMap1.cmake:[0-9]+ \(ExternalData_Add_Target\)
- CMakeLists.txt:3 \(include\)
+ BadAlgoMap1\.cmake:[0-9]+ \(ExternalData_Add_Target\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadAlgoMap2-stderr.txt b/Tests/RunCMake/ExternalData/BadAlgoMap2-stderr.txt
index 1f10644dc..a48e41455 100644
--- a/Tests/RunCMake/ExternalData/BadAlgoMap2-stderr.txt
+++ b/Tests/RunCMake/ExternalData/BadAlgoMap2-stderr.txt
@@ -5,5 +5,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
The transform name must be a valid C identifier.
Call Stack \(most recent call first\):
- BadAlgoMap2.cmake:[0-9]+ \(ExternalData_Add_Target\)
- CMakeLists.txt:3 \(include\)
+ BadAlgoMap2\.cmake:[0-9]+ \(ExternalData_Add_Target\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt b/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt
index f68f0be6b..1f9f6b51b 100644
--- a/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt
+++ b/Tests/RunCMake/ExternalData/BadHashAlgo1-stderr.txt
@@ -4,5 +4,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
BAD
Call Stack \(most recent call first\):
.*
- BadHashAlgo1.cmake:3 \(ExternalData_Expand_Arguments\)
- CMakeLists.txt:3 \(include\)
+ BadHashAlgo1\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadOption1-stderr.txt b/Tests/RunCMake/ExternalData/BadOption1-stderr.txt
index b63d098c0..fece87703 100644
--- a/Tests/RunCMake/ExternalData/BadOption1-stderr.txt
+++ b/Tests/RunCMake/ExternalData/BadOption1-stderr.txt
@@ -5,5 +5,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
Call Stack \(most recent call first\):
.*
- BadOption1.cmake:2 \(ExternalData_Add_Test\)
- CMakeLists.txt:3 \(include\)
+ BadOption1\.cmake:[0-9]+ \(ExternalData_Add_Test\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadOption2-stderr.txt b/Tests/RunCMake/ExternalData/BadOption2-stderr.txt
index d114c8aa9..865552aca 100644
--- a/Tests/RunCMake/ExternalData/BadOption2-stderr.txt
+++ b/Tests/RunCMake/ExternalData/BadOption2-stderr.txt
@@ -5,5 +5,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
Call Stack \(most recent call first\):
.*
- BadOption2.cmake:2 \(ExternalData_Add_Test\)
- CMakeLists.txt:3 \(include\)
+ BadOption2\.cmake:[0-9]+ \(ExternalData_Add_Test\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadRecurse1-stderr.txt b/Tests/RunCMake/ExternalData/BadRecurse1-stderr.txt
index aedc33015..9d04693ca 100644
--- a/Tests/RunCMake/ExternalData/BadRecurse1-stderr.txt
+++ b/Tests/RunCMake/ExternalData/BadRecurse1-stderr.txt
@@ -2,5 +2,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
Recurse option "RECURSE:" allowed only with directories.
Call Stack \(most recent call first\):
.*
- BadRecurse1.cmake:2 \(ExternalData_Expand_Arguments\)
- CMakeLists.txt:3 \(include\)
+ BadRecurse1\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadRecurse2-stderr.txt b/Tests/RunCMake/ExternalData/BadRecurse2-stderr.txt
index 3f809ca69..135b42477 100644
--- a/Tests/RunCMake/ExternalData/BadRecurse2-stderr.txt
+++ b/Tests/RunCMake/ExternalData/BadRecurse2-stderr.txt
@@ -2,5 +2,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
Recurse option "RECURSE:" allowed only with directories.
Call Stack \(most recent call first\):
.*
- BadRecurse2.cmake:2 \(ExternalData_Expand_Arguments\)
- CMakeLists.txt:3 \(include\)
+ BadRecurse2\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadRecurse3-stderr.txt b/Tests/RunCMake/ExternalData/BadRecurse3-stderr.txt
index 37740e0f7..df9bb0e17 100644
--- a/Tests/RunCMake/ExternalData/BadRecurse3-stderr.txt
+++ b/Tests/RunCMake/ExternalData/BadRecurse3-stderr.txt
@@ -5,5 +5,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
Call Stack \(most recent call first\):
.*
- BadRecurse3.cmake:2 \(ExternalData_Expand_Arguments\)
- CMakeLists.txt:3 \(include\)
+ BadRecurse3\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt b/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt
index 3099be579..5b3495985 100644
--- a/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt
+++ b/Tests/RunCMake/ExternalData/BadSeries1-stderr.txt
@@ -15,5 +15,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
Call Stack \(most recent call first\):
.*
- BadSeries1.cmake:3 \(ExternalData_Expand_Arguments\)
- CMakeLists.txt:3 \(include\)
+ BadSeries1\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt b/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt
index 3a02c25e9..82b2311d2 100644
--- a/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt
+++ b/Tests/RunCMake/ExternalData/BadSeries2-stderr.txt
@@ -12,5 +12,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
\(x\)\(y\)\$
Call Stack \(most recent call first\):
.*
- BadSeries2.cmake:3 \(ExternalData_Expand_Arguments\)
- CMakeLists.txt:3 \(include\)
+ BadSeries2\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt b/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt
index 594cb6f6a..13e75c5c5 100644
--- a/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt
+++ b/Tests/RunCMake/ExternalData/BadSeries3-stderr.txt
@@ -2,5 +2,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
Series option ":" not allowed with associated files.
Call Stack \(most recent call first\):
.*
- BadSeries3.cmake:2 \(ExternalData_Expand_Arguments\)
- CMakeLists.txt:3 \(include\)
+ BadSeries3\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/Directory1-stderr.txt b/Tests/RunCMake/ExternalData/Directory1-stderr.txt
index 2bc3c601d..833683285 100644
--- a/Tests/RunCMake/ExternalData/Directory1-stderr.txt
+++ b/Tests/RunCMake/ExternalData/Directory1-stderr.txt
@@ -10,5 +10,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
that is directory instead of a file!
Call Stack \(most recent call first\):
.*
- Directory1.cmake:3 \(ExternalData_Add_Test\)
- CMakeLists.txt:3 \(include\)
+ Directory1\.cmake:[0-9]+ \(ExternalData_Add_Test\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/Directory2-stderr.txt b/Tests/RunCMake/ExternalData/Directory2-stderr.txt
index 92c9a2ff5..ad6d814ec 100644
--- a/Tests/RunCMake/ExternalData/Directory2-stderr.txt
+++ b/Tests/RunCMake/ExternalData/Directory2-stderr.txt
@@ -6,5 +6,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
must list associated files.
Call Stack \(most recent call first\):
.*
- Directory2.cmake:3 \(ExternalData_Add_Test\)
- CMakeLists.txt:3 \(include\)
+ Directory2\.cmake:[0-9]+ \(ExternalData_Add_Test\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/Directory3-stderr.txt b/Tests/RunCMake/ExternalData/Directory3-stderr.txt
index ceed2a04d..5538c38a8 100644
--- a/Tests/RunCMake/ExternalData/Directory3-stderr.txt
+++ b/Tests/RunCMake/ExternalData/Directory3-stderr.txt
@@ -10,6 +10,6 @@ CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
that does not exist as a file \(with or without an extension\)!
Call Stack \(most recent call first\):
.*
- Directory3.cmake:3 \(ExternalData_Add_Test\)
- CMakeLists.txt:3 \(include\)
+ Directory3\.cmake:[0-9]+ \(ExternalData_Add_Test\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/ExternalData/Directory4-stderr.txt b/Tests/RunCMake/ExternalData/Directory4-stderr.txt
index dcb8522f8..ef8847685 100644
--- a/Tests/RunCMake/ExternalData/Directory4-stderr.txt
+++ b/Tests/RunCMake/ExternalData/Directory4-stderr.txt
@@ -2,5 +2,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
Series option ":" not allowed with directories.
Call Stack \(most recent call first\):
.*
- Directory4.cmake:3 \(ExternalData_Add_Test\)
- CMakeLists.txt:3 \(include\)
+ Directory4\.cmake:[0-9]+ \(ExternalData_Add_Test\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/Directory5-stderr.txt b/Tests/RunCMake/ExternalData/Directory5-stderr.txt
index 8e54aecd2..3fcde414d 100644
--- a/Tests/RunCMake/ExternalData/Directory5-stderr.txt
+++ b/Tests/RunCMake/ExternalData/Directory5-stderr.txt
@@ -10,5 +10,5 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
that does not exist as a directory!
Call Stack \(most recent call first\):
.*
- Directory5.cmake:3 \(ExternalData_Add_Test\)
- CMakeLists.txt:3 \(include\)
+ Directory5\.cmake:[0-9]+ \(ExternalData_Add_Test\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/MissingData-stderr.txt b/Tests/RunCMake/ExternalData/MissingData-stderr.txt
index 39ed2f15f..b10997681 100644
--- a/Tests/RunCMake/ExternalData/MissingData-stderr.txt
+++ b/Tests/RunCMake/ExternalData/MissingData-stderr.txt
@@ -10,6 +10,6 @@ CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
that does not exist as a file \(with or without an extension\)!
Call Stack \(most recent call first\):
.*
- MissingData.cmake:4 \(ExternalData_Expand_Arguments\)
- CMakeLists.txt:3 \(include\)
+ MissingData\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt
index 315af5e49..426d86ccd 100644
--- a/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt
+++ b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt
@@ -10,6 +10,6 @@ CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
that does not exist as a file \(with or without an extension\)!
Call Stack \(most recent call first\):
.*
- MissingDataWithAssociated.cmake:4 \(ExternalData_Expand_Arguments\)
- CMakeLists.txt:3 \(include\)
+ MissingDataWithAssociated\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt b/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt
index 496ad8ae4..33cef07b4 100644
--- a/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt
+++ b/Tests/RunCMake/ExternalData/NoLinkInSource-stderr.txt
@@ -2,5 +2,5 @@ CMake Warning at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
ExternalData_LINK_CONTENT cannot be used in-source
Call Stack \(most recent call first\):
.*
- NoLinkInSource.cmake:8 \(ExternalData_Expand_Arguments\)
- CMakeLists.txt:3 \(include\)
+ NoLinkInSource\.cmake:[0-9]+ \(ExternalData_Expand_Arguments\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt b/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt
index ccbaf5af3..45dfb94cb 100644
--- a/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt
+++ b/Tests/RunCMake/ExternalData/NoURLTemplates-stderr.txt
@@ -1,5 +1,5 @@
CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
Neither ExternalData_URL_TEMPLATES nor ExternalData_OBJECT_STORES is set!
Call Stack \(most recent call first\):
- NoURLTemplates.cmake:2 \(ExternalData_Add_Target\)
- CMakeLists.txt:3 \(include\)
+ NoURLTemplates\.cmake:[0-9]+ \(ExternalData_Add_Target\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake
index cb48be7e0..c5018563c 100644
--- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake
+++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS-check.cmake
@@ -24,3 +24,21 @@ if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE)
set(RunCMake_TEST_FAILED "Expected forced TEST_LIST argument")
return()
endif()
+
+if(NOT "${_cache}" MATCHES "set\\(TEST_OPTIONAL \"TEST_OPTIONAL-NOTFOUND\".+\\)")
+ set(RunCMake_TEST_FAILED "Cannot find TEST_OPTIONAL argument in cache")
+ return()
+endif()
+if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE)
+ set(RunCMake_TEST_FAILED "Expected forced TEST_OPTIONAL argument")
+ return()
+endif()
+
+if(NOT "${_cache}" MATCHES "set\\(TEST_OPTIONAL_LAST \"TEST_OPTIONAL_LAST-NOTFOUND\".+\\)")
+ set(RunCMake_TEST_FAILED "Cannot find TEST_OPTIONAL_LAST argument in cache")
+ return()
+endif()
+if(NOT "${CMAKE_MATCH_0}" MATCHES FORCE)
+ set(RunCMake_TEST_FAILED "Expected forced TEST_OPTIONAL_LAST argument")
+ return()
+endif()
diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake
index 1f76fd03e..4f7e02006 100644
--- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake
+++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake
@@ -1,4 +1,5 @@
-if(NOT CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(NOT _isMultiConfig)
set(CMAKE_BUILD_TYPE Debug)
endif()
include(ExternalProject)
@@ -7,4 +8,6 @@ ExternalProject_Add(FOO TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp"
DOWNLOAD_COMMAND ""
CMAKE_CACHE_ARGS
"-DFOO:STRING=$<1:BAR>$<0:BAD>"
- "-DTEST_LIST:STRING=A;B;C")
+ "-DTEST_LIST:STRING=A;B;C"
+ "-DTEST_OPTIONAL:FILEPATH=TEST_OPTIONAL-NOTFOUND"
+ "-DTEST_OPTIONAL_LAST:FILEPATH=TEST_OPTIONAL_LAST-NOTFOUND")
diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake
index c84932d60..059f6d327 100644
--- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake
+++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS-check.cmake
@@ -24,3 +24,21 @@ if("${CMAKE_MATCH_0}" MATCHES FORCE)
set(RunCMake_TEST_FAILED "Expected not forced TEST_LIST argument")
return()
endif()
+
+if(NOT "${_cache}" MATCHES "set\\(TEST_OPTIONAL \"TEST_OPTIONAL-NOTFOUND\".+\\)")
+ set(RunCMake_TEST_FAILED "Cannot find TEST_OPTIONAL argument in cache")
+ return()
+endif()
+if("${CMAKE_MATCH_0}" MATCHES FORCE)
+ set(RunCMake_TEST_FAILED "Expected not forced TEST_OPTIONAL argument")
+ return()
+endif()
+
+if(NOT "${_cache}" MATCHES "set\\(TEST_OPTIONAL_LAST \"TEST_OPTIONAL_LAST-NOTFOUND\".+\\)")
+ set(RunCMake_TEST_FAILED "Cannot find TEST_OPTIONAL_LAST argument in cache")
+ return()
+endif()
+if("${CMAKE_MATCH_0}" MATCHES FORCE)
+ set(RunCMake_TEST_FAILED "Expected not forced TEST_OPTIONAL_LAST argument")
+ return()
+endif()
diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake
index 1b619c8c0..61334183c 100644
--- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake
+++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake
@@ -1,4 +1,5 @@
-if(NOT CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(NOT _isMultiConfig)
set(CMAKE_BUILD_TYPE Debug)
endif()
include(ExternalProject)
@@ -7,4 +8,6 @@ ExternalProject_Add(FOO TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp"
DOWNLOAD_COMMAND ""
CMAKE_CACHE_DEFAULT_ARGS
"-DFOO:STRING=$<1:BAR>$<0:BAD>"
- "-DTEST_LIST:STRING=A;B;C")
+ "-DTEST_LIST:STRING=A;B;C"
+ "-DTEST_OPTIONAL:FILEPATH=TEST_OPTIONAL-NOTFOUND"
+ "-DTEST_OPTIONAL_LAST:FILEPATH=TEST_OPTIONAL_LAST-NOTFOUND")
diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake
index 192776ba7..2fb0705a5 100644
--- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake
+++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake
@@ -1,4 +1,5 @@
-if(NOT CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(NOT _isMultiConfig)
set(CMAKE_BUILD_TYPE Debug)
endif()
include(ExternalProject)
diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add-result.txt b/Tests/RunCMake/ExternalProject/IncludeScope-Add-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add-stderr.txt b/Tests/RunCMake/ExternalProject/IncludeScope-Add-stderr.txt
new file mode 100644
index 000000000..ff3e5c18e
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\):
+ error: ExternalProject module must be explicitly included before using
+ ExternalProject_Add function
+Call Stack \(most recent call first\):
+ .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_parse_arguments\)
+ IncludeScope-Add.cmake:[0-9]+ \(ExternalProject_Add\)
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add.cmake b/Tests/RunCMake/ExternalProject/IncludeScope-Add.cmake
new file mode 100644
index 000000000..1061ffddc
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add.cmake
@@ -0,0 +1,12 @@
+function(IncludeScope_IncludeOnly)
+ include(ExternalProject)
+endfunction()
+
+IncludeScope_IncludeOnly()
+
+ExternalProject_Add(MyProj
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ""
+)
diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-result.txt b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-stderr.txt b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-stderr.txt
new file mode 100644
index 000000000..cbad4be61
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\):
+ error: ExternalProject module must be explicitly included before using
+ ExternalProject_Add_Step function
+Call Stack \(most recent call first\):
+ .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_parse_arguments\)
+ IncludeScope-Add_Step.cmake:[0-9]+ \(ExternalProject_Add_Step\)
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step.cmake b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step.cmake
new file mode 100644
index 000000000..2a820f8f2
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step.cmake
@@ -0,0 +1,13 @@
+function(IncludeScope_DefineProj)
+ include(ExternalProject)
+ ExternalProject_Add(MyProj
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ""
+ )
+endfunction()
+
+IncludeScope_DefineProj()
+
+ExternalProject_Add_Step(MyProj extraStep COMMENT "Foo")
diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-result.txt b/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-result.txt
new file mode 100644
index 000000000..c20fd86c7
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-result.txt
@@ -0,0 +1 @@
+^[^0]
diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stderr.txt b/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stderr.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stderr.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stdout.txt b/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stdout.txt
new file mode 100644
index 000000000..87e5384fa
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailure-build-stdout.txt
@@ -0,0 +1,8 @@
+( )?-- stdout output is:
+( )?This is some dummy output with some long lines to ensure formatting is preserved
+( )? Including lines with leading spaces
+( )?
+( )?And also blank lines[
+ ]+
+( )?-- stderr output is:
+( )?cmake -E env: no command given
diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailure.cmake b/Tests/RunCMake/ExternalProject/LogOutputOnFailure.cmake
new file mode 100644
index 000000000..863bbef9b
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailure.cmake
@@ -0,0 +1,20 @@
+include(ExternalProject)
+
+set(dummyOutput [[
+This is some dummy output with some long lines to ensure formatting is preserved
+ Including lines with leading spaces
+
+And also blank lines
+]])
+
+ExternalProject_Add(FailsWithOutput
+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ${CMAKE_COMMAND} -E echo ${dummyOutput}
+ COMMAND ${CMAKE_COMMAND} -E env # missing command, forces fail
+ TEST_COMMAND ""
+ INSTALL_COMMAND ""
+ LOG_BUILD YES
+ LOG_OUTPUT_ON_FAILURE YES
+ USES_TERMINAL_BUILD YES
+)
diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-result.txt b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-result.txt
new file mode 100644
index 000000000..c20fd86c7
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-result.txt
@@ -0,0 +1 @@
+^[^0]
diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stderr.txt b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stderr.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stderr.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stdout.txt b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stdout.txt
new file mode 100644
index 000000000..11c73176e
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged-build-stdout.txt
@@ -0,0 +1,7 @@
+( )?-- Log output is:
+( )?This is some dummy output with some long lines to ensure formatting is preserved
+( )? Including lines with leading spaces
+( )?
+( )?And also blank lines[
+ ]+
+( )?cmake -E env: no command given
diff --git a/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged.cmake b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged.cmake
new file mode 100644
index 000000000..116448b8f
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/LogOutputOnFailureMerged.cmake
@@ -0,0 +1,21 @@
+include(ExternalProject)
+
+set(dummyOutput [[
+This is some dummy output with some long lines to ensure formatting is preserved
+ Including lines with leading spaces
+
+And also blank lines
+]])
+
+ExternalProject_Add(FailsWithOutput
+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ${CMAKE_COMMAND} -E echo ${dummyOutput}
+ COMMAND ${CMAKE_COMMAND} -E env # missing command, forces fail
+ TEST_COMMAND ""
+ INSTALL_COMMAND ""
+ LOG_BUILD YES
+ LOG_OUTPUT_ON_FAILURE YES
+ LOG_MERGED_STDOUTERR YES
+ USES_TERMINAL_BUILD YES
+)
diff --git a/Tests/RunCMake/ExternalProject/MultiCommand-build-stdout.txt b/Tests/RunCMake/ExternalProject/MultiCommand-build-stdout.txt
new file mode 100644
index 000000000..30ebc7dcc
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/MultiCommand-build-stdout.txt
@@ -0,0 +1,15 @@
+.* *download 1
+.* *download 2
+.* *update 1
+.* *update 2
+.* *patch 1
+.* *patch 2
+.* *configure 1
+.* *configure 2
+.* *build 1
+.* *build 2
+.* *install 1
+.* *install 2
+.* *test 1
+.* *test 2
+.*
diff --git a/Tests/RunCMake/ExternalProject/MultiCommand.cmake b/Tests/RunCMake/ExternalProject/MultiCommand.cmake
new file mode 100644
index 000000000..a8dbfea5d
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/MultiCommand.cmake
@@ -0,0 +1,30 @@
+cmake_minimum_required(VERSION 3.9)
+
+include(ExternalProject)
+
+# Verify COMMAND keyword is recognised after various *_COMMAND options
+ExternalProject_Add(multiCommand
+ DOWNLOAD_COMMAND "${CMAKE_COMMAND}" -E echo "download 1"
+ COMMAND "${CMAKE_COMMAND}" -E echo "download 2"
+ UPDATE_COMMAND "${CMAKE_COMMAND}" -E echo "update 1"
+ COMMAND "${CMAKE_COMMAND}" -E echo "update 2"
+ PATCH_COMMAND "${CMAKE_COMMAND}" -E echo "patch 1"
+ COMMAND "${CMAKE_COMMAND}" -E echo "patch 2"
+ CONFIGURE_COMMAND "${CMAKE_COMMAND}" -E echo "configure 1"
+ COMMAND "${CMAKE_COMMAND}" -E echo "configure 2"
+ BUILD_COMMAND "${CMAKE_COMMAND}" -E echo "build 1"
+ COMMAND "${CMAKE_COMMAND}" -E echo "build 2"
+ TEST_COMMAND "${CMAKE_COMMAND}" -E echo "test 1"
+ COMMAND "${CMAKE_COMMAND}" -E echo "test 2"
+ INSTALL_COMMAND "${CMAKE_COMMAND}" -E echo "install 1"
+ COMMAND "${CMAKE_COMMAND}" -E echo "install 2"
+)
+
+# Workaround for issue 17229 (missing dependency between update and patch steps)
+ExternalProject_Add_StepTargets(multiCommand NO_DEPENDS update)
+ExternalProject_Add_StepDependencies(multiCommand patch multiCommand-update)
+
+# Force all steps to be re-run by removing timestamps from any previous run
+ExternalProject_Get_Property(multiCommand STAMP_DIR)
+file(REMOVE_RECURSE "${STAMP_DIR}")
+file(MAKE_DIRECTORY "${STAMP_DIR}")
diff --git a/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt b/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt
index 12a76c5d4..2fc7d291b 100644
--- a/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt
+++ b/Tests/RunCMake/ExternalProject/NoOptions-stderr.txt
@@ -6,12 +6,12 @@
is not an existing non-empty directory. Please specify one of:
\* SOURCE_DIR with an existing non-empty directory
+ \* DOWNLOAD_COMMAND
\* URL
\* GIT_REPOSITORY
+ \* SVN_REPOSITORY
\* HG_REPOSITORY
\* CVS_REPOSITORY and CVS_MODULE
- \* SVN_REVISION
- \* DOWNLOAD_COMMAND
Call Stack \(most recent call first\):
.*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_download_command\)
NoOptions.cmake:[0-9]+ \(ExternalProject_Add\)
diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
index 47d612969..caaf0d2fd 100644
--- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
@@ -1,5 +1,7 @@
include(RunCMake)
+run_cmake(IncludeScope-Add)
+run_cmake(IncludeScope-Add_Step)
run_cmake(NoOptions)
run_cmake(SourceEmpty)
run_cmake(SourceMissing)
@@ -12,3 +14,41 @@ run_cmake(Add_StepDependencies_iface)
run_cmake(Add_StepDependencies_iface_step)
run_cmake(Add_StepDependencies_no_target)
run_cmake(UsesTerminal)
+
+# Run both cmake and build steps. We always do a clean before the
+# build to ensure that the download step re-runs each time.
+function(__ep_test_with_build testName)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake(${testName})
+ run_cmake_command(${testName}-clean ${CMAKE_COMMAND} --build . --target clean)
+ run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .)
+endfunction()
+
+__ep_test_with_build(MultiCommand)
+
+# Output is not predictable enough to be able to verify it reliably
+# when using the various different Visual Studio generators
+if(NOT RunCMake_GENERATOR MATCHES "Visual Studio")
+ __ep_test_with_build(LogOutputOnFailure)
+ __ep_test_with_build(LogOutputOnFailureMerged)
+endif()
+
+# We can't test the substitution when using the old MSYS due to
+# make/sh mangling the paths (substitution is performed correctly,
+# but the mangling means we can't reliably test the output).
+# There is no such issue when using the newer MSYS though. Therefore,
+# we need to bypass the substitution test if using old MSYS.
+# See merge request 1537 for discussion.
+set(doSubstitutionTest YES)
+if(RunCMake_GENERATOR STREQUAL "MSYS Makefiles")
+ execute_process(COMMAND uname OUTPUT_VARIABLE uname)
+ if(uname MATCHES "^MINGW32_NT")
+ set(doSubstitutionTest NO)
+ endif()
+endif()
+if(doSubstitutionTest)
+ __ep_test_with_build(Substitutions)
+endif()
diff --git a/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt b/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt
index 58a343ccf..07c6e8798 100644
--- a/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt
+++ b/Tests/RunCMake/ExternalProject/SourceEmpty-stderr.txt
@@ -6,12 +6,12 @@
is not an existing non-empty directory. Please specify one of:
\* SOURCE_DIR with an existing non-empty directory
+ \* DOWNLOAD_COMMAND
\* URL
\* GIT_REPOSITORY
+ \* SVN_REPOSITORY
\* HG_REPOSITORY
\* CVS_REPOSITORY and CVS_MODULE
- \* SVN_REVISION
- \* DOWNLOAD_COMMAND
Call Stack \(most recent call first\):
.*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_download_command\)
SourceEmpty.cmake:[0-9]+ \(ExternalProject_Add\)
diff --git a/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt b/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt
index e62f7cf5a..373f6e3aa 100644
--- a/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt
+++ b/Tests/RunCMake/ExternalProject/SourceMissing-stderr.txt
@@ -6,12 +6,12 @@
is not an existing non-empty directory. Please specify one of:
\* SOURCE_DIR with an existing non-empty directory
+ \* DOWNLOAD_COMMAND
\* URL
\* GIT_REPOSITORY
+ \* SVN_REPOSITORY
\* HG_REPOSITORY
\* CVS_REPOSITORY and CVS_MODULE
- \* SVN_REVISION
- \* DOWNLOAD_COMMAND
Call Stack \(most recent call first\):
.*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_add_download_command\)
SourceMissing.cmake:[0-9]+ \(ExternalProject_Add\)
diff --git a/Tests/RunCMake/ExternalProject/Substitutions-build-stdout.txt b/Tests/RunCMake/ExternalProject/Substitutions-build-stdout.txt
new file mode 100644
index 000000000..d6a823add
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/Substitutions-build-stdout.txt
@@ -0,0 +1,7 @@
+.*Download dir = .*/xxxx_dwn
+.*Download file = .*/zzzz_tmp.txt
+.*Source dir = .*/xxxx_src
+.*Source subdir = /yyyy_subdir
+.*Binary dir = .*/xxxx_bin
+.*Install dir = .*/xxxx_install
+.*Tmp dir = .*/xxxx_tmp
diff --git a/Tests/RunCMake/ExternalProject/Substitutions.cmake b/Tests/RunCMake/ExternalProject/Substitutions.cmake
new file mode 100644
index 000000000..db79491ee
--- /dev/null
+++ b/Tests/RunCMake/ExternalProject/Substitutions.cmake
@@ -0,0 +1,25 @@
+include(ExternalProject)
+
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/zzzz_tmp.txt "Dummy file")
+file(MD5 ${CMAKE_CURRENT_BINARY_DIR}/zzzz_tmp.txt md5hash)
+ExternalProject_Add(Subst
+ URL file://${CMAKE_CURRENT_BINARY_DIR}/zzzz_tmp.txt
+ URL_HASH MD5=${md5hash}
+ DOWNLOAD_NO_EXTRACT ON
+ DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/xxxx_dwn
+ SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/xxxx_src
+ SOURCE_SUBDIR yyyy_subdir
+ BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/xxxx_bin
+ INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/xxxx_install
+ TMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/xxxx_tmp
+ CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Download dir = <DOWNLOAD_DIR>"
+ COMMAND ${CMAKE_COMMAND} -E echo "Download file = <DOWNLOADED_FILE>"
+ COMMAND ${CMAKE_COMMAND} -E echo "Source dir = <SOURCE_DIR>"
+ COMMAND ${CMAKE_COMMAND} -E echo "Source subdir = <SOURCE_SUBDIR>"
+ COMMAND ${CMAKE_COMMAND} -E echo "Binary dir = <BINARY_DIR>"
+ COMMAND ${CMAKE_COMMAND} -E echo "Install dir = <INSTALL_DIR>"
+ COMMAND ${CMAKE_COMMAND} -E echo "Tmp dir = <TMP_DIR>"
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ""
+ TEST_COMMAND ""
+)
diff --git a/Tests/RunCMake/ExternalProject/UsesTerminal.cmake b/Tests/RunCMake/ExternalProject/UsesTerminal.cmake
index cd874039d..d3494fd4e 100644
--- a/Tests/RunCMake/ExternalProject/UsesTerminal.cmake
+++ b/Tests/RunCMake/ExternalProject/UsesTerminal.cmake
@@ -1,4 +1,5 @@
-if(NOT CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(NOT _isMultiConfig)
set(CMAKE_BUILD_TYPE Debug)
endif()
include(ExternalProject)
diff --git a/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake b/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake
new file mode 100644
index 000000000..e25db1a0a
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake
@@ -0,0 +1 @@
+# pseudo config module
diff --git a/Tests/RunCMake/FPHSA/CustomMessageConfigVersion.cmake b/Tests/RunCMake/FPHSA/CustomMessageConfigVersion.cmake
new file mode 100644
index 000000000..b7c9e1866
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/CustomMessageConfigVersion.cmake
@@ -0,0 +1,4 @@
+# pseudo find_module
+
+set (PACKAGE_VERSION 2)
+set (PACKAGE_VERSION_UNSUITABLE TRUE)
diff --git a/Tests/RunCMake/FPHSA/FindCustomMessage.cmake b/Tests/RunCMake/FPHSA/FindCustomMessage.cmake
new file mode 100644
index 000000000..4d67db86d
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/FindCustomMessage.cmake
@@ -0,0 +1,17 @@
+# pseudo find_module
+
+if (REASON_FAILURE_MESSAGE)
+ list (PREPEND REASON_FAILURE_MESSAGE "REASON_FAILURE_MESSAGE")
+endif()
+
+include(FindPackageHandleStandardArgs)
+
+if (CONFIG_MODE)
+ find_package (CustomMessage QUIET CONFIG HINTS "${CMAKE_MODULE_PATH}")
+ find_package_handle_standard_args(CustomMessage CONFIG_MODE
+ ${REASON_FAILURE_MESSAGE})
+else()
+ find_package_handle_standard_args(CustomMessage REQUIRED_VARS FOOBAR
+ VERSION_VAR CustomMessage_VERSION
+ ${REASON_FAILURE_MESSAGE})
+endif()
diff --git a/Tests/RunCMake/FPHSA/FindPseudoNoVersionVar.cmake b/Tests/RunCMake/FPHSA/FindPseudoNoVersionVar.cmake
new file mode 100644
index 000000000..d961c6489
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/FindPseudoNoVersionVar.cmake
@@ -0,0 +1,6 @@
+# pseudo find_module without specifying VERSION_VAR
+
+set(FOOBAR TRUE)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(PseudoNoVersionVar REQUIRED_VARS FOOBAR)
diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
index e9b2a7a70..f3e6c3e74 100644
--- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake
@@ -4,7 +4,18 @@ run_cmake(BadFoundVar)
# The pseudo module will "find" a package with the given version. Check if the
# version selection code in FPHSA works correctly.
-set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=1.2.3.4.5")
+
+# Find a package with version 0.
+set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=0")
+run_cmake(any_version_find_0)
+
+# Find a package with more customary version number, without requesting a specific version and in
+# the presence of a cache variable VERSION.
+set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudoNoVersionVar_VERSION=1.2.3.4_SHOULD_BE_IGNORED" "-DVERSION=BAD_VERSION")
+run_cmake(any_version_VERSION_cache_variable)
+
+# Find a package with a more customary version number, without requesting a specific version.
+set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=1.2.3.4")
run_cmake(any_version)
# test EXACT mode with every subcomponent
@@ -28,3 +39,10 @@ unset(RunCMake_DEFAULT_stderr)
# check if searching for a version 0 works
list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=0")
run_cmake(exact_0_matching)
+
+# check custom error message
+set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DCustomMessage_VERSION=1.2.3.4")
+run_cmake(custom_message_1)
+set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DCONFIG_MODE=TRUE")
+run_cmake(custom_message_2)
+run_cmake(custom_message_3)
diff --git a/Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable-stdout.txt b/Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable-stdout.txt
new file mode 100644
index 000000000..f9acece45
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable-stdout.txt
@@ -0,0 +1,2 @@
+Found PseudoNoVersionVar: TRUE *
++
diff --git a/Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable.cmake b/Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable.cmake
new file mode 100644
index 000000000..9f278979b
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/any_version_VERSION_cache_variable.cmake
@@ -0,0 +1 @@
+find_package(PseudoNoVersionVar REQUIRED)
diff --git a/Tests/RunCMake/FPHSA/any_version_find_0-stdout.txt b/Tests/RunCMake/FPHSA/any_version_find_0-stdout.txt
new file mode 100644
index 000000000..861a33987
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/any_version_find_0-stdout.txt
@@ -0,0 +1,2 @@
+Found Pseudo: [^
+]*\(found version "0\"\)
diff --git a/Tests/RunCMake/FPHSA/any_version_find_0.cmake b/Tests/RunCMake/FPHSA/any_version_find_0.cmake
new file mode 100644
index 000000000..b34a540c9
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/any_version_find_0.cmake
@@ -0,0 +1 @@
+find_package(Pseudo REQUIRED)
diff --git a/Tests/RunCMake/FPHSA/custom_message_1-result.txt b/Tests/RunCMake/FPHSA/custom_message_1-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FPHSA/custom_message_1-stderr.txt b/Tests/RunCMake/FPHSA/custom_message_1-stderr.txt
new file mode 100644
index 000000000..992fe39ea
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_1-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at .+/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\):
+ Could NOT find CustomMessage \(missing: FOOBAR\) \(found suitable version
+ "1\.2\.3\.4", minimum required is "1\.2"\)
+
+ Reason given by package: Reason Failure
+
+Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/FPHSA/custom_message_1.cmake b/Tests/RunCMake/FPHSA/custom_message_1.cmake
new file mode 100644
index 000000000..330de501d
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_1.cmake
@@ -0,0 +1,4 @@
+
+set (REASON_FAILURE_MESSAGE "Reason Failure")
+
+find_package(CustomMessage 1.2 REQUIRED)
diff --git a/Tests/RunCMake/FPHSA/custom_message_2-result.txt b/Tests/RunCMake/FPHSA/custom_message_2-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FPHSA/custom_message_2-stderr.txt b/Tests/RunCMake/FPHSA/custom_message_2-stderr.txt
new file mode 100644
index 000000000..494075242
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_2-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Error at .+/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\):
+ Could NOT find CustomMessage \(Required is at least version "1\.2"\), checked
+ the following files:
+
+ .+/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake \(version 2\)
+ Reason given by package: Not Found Message
+
+Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/FPHSA/custom_message_2.cmake b/Tests/RunCMake/FPHSA/custom_message_2.cmake
new file mode 100644
index 000000000..a3f2d969b
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_2.cmake
@@ -0,0 +1,5 @@
+
+unset (REASON_FAILURE_MESSAGE)
+set (CustomMessage_NOT_FOUND_MESSAGE "Not Found Message")
+
+find_package(CustomMessage 1.2 REQUIRED)
diff --git a/Tests/RunCMake/FPHSA/custom_message_3-result.txt b/Tests/RunCMake/FPHSA/custom_message_3-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_3-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FPHSA/custom_message_3-stderr.txt b/Tests/RunCMake/FPHSA/custom_message_3-stderr.txt
new file mode 100644
index 000000000..dc55843ac
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_3-stderr.txt
@@ -0,0 +1,9 @@
+^CMake Error at .+/Modules/FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\):
+ Could NOT find CustomMessage \(Required is at least version "1\.2"\), checked
+ the following files:
+
+ .+/Tests/RunCMake/FPHSA/CustomMessageConfig.cmake \(version 2\)
+ Reason given by package: Not Found Message
+ Reason Failure
+
+Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/FPHSA/custom_message_3.cmake b/Tests/RunCMake/FPHSA/custom_message_3.cmake
new file mode 100644
index 000000000..203e012ca
--- /dev/null
+++ b/Tests/RunCMake/FPHSA/custom_message_3.cmake
@@ -0,0 +1,5 @@
+
+set (REASON_FAILURE_MESSAGE "Reason Failure")
+set (CustomMessage_NOT_FOUND_MESSAGE "Not Found Message")
+
+find_package(CustomMessage 1.2 REQUIRED)
diff --git a/Tests/RunCMake/FetchContent/CMakeLists.txt b/Tests/RunCMake/FetchContent/CMakeLists.txt
new file mode 100644
index 000000000..3cc2e4364
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 3.9)
+project(${RunCMake_TEST} NONE)
+
+# Tests assume no previous downloads in the output directory
+file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/_deps)
+
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/FetchContent/DirOverrides.cmake b/Tests/RunCMake/FetchContent/DirOverrides.cmake
new file mode 100644
index 000000000..50eef161b
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/DirOverrides.cmake
@@ -0,0 +1,46 @@
+include(FetchContent)
+
+# Test using saved details
+FetchContent_Declare(
+ t1
+ SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/savedSrc
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR>
+)
+FetchContent_Populate(t1)
+if(NOT IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/savedSrc)
+ message(FATAL_ERROR "Saved details SOURCE_DIR override failed")
+endif()
+
+# Test direct population
+FetchContent_Populate(
+ t2
+ SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/directSrc
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR>
+)
+if(NOT IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/directSrc)
+ message(FATAL_ERROR "Direct details SOURCE_DIR override failed")
+endif()
+
+# Ensure setting BINARY_DIR to SOURCE_DIR works (a technique to
+# prevent an unwanted separate BINARY_DIR from being created, which
+# ExternalProject_Add() does whether we like it or not)
+FetchContent_Declare(
+ t3
+ SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/savedNoBuildDir
+ BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/savedNoBuildDir
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR>
+)
+FetchContent_Populate(t3)
+if(IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/savedNobuildDir-build)
+ message(FATAL_ERROR "Saved details BINARY_DIR override failed")
+endif()
+
+FetchContent_Populate(
+ t4
+ SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/directNoBuildDir
+ BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/directNoBuildDir
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR>
+)
+if(IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/savedNobuildDir-build)
+ message(FATAL_ERROR "Direct details BINARY_DIR override failed")
+endif()
diff --git a/Tests/RunCMake/FetchContent/DirectIgnoresDetails-stdout.txt b/Tests/RunCMake/FetchContent/DirectIgnoresDetails-stdout.txt
new file mode 100644
index 000000000..6fa5a57ec
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/DirectIgnoresDetails-stdout.txt
@@ -0,0 +1 @@
+Local details used
diff --git a/Tests/RunCMake/FetchContent/DirectIgnoresDetails.cmake b/Tests/RunCMake/FetchContent/DirectIgnoresDetails.cmake
new file mode 100644
index 000000000..0731b4390
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/DirectIgnoresDetails.cmake
@@ -0,0 +1,12 @@
+include(FetchContent)
+
+FetchContent_Declare(
+ t1
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E echo "Saved details used"
+)
+
+# No QUIET option given, so command output will be shown
+FetchContent_Populate(
+ t1
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E echo "Local details used"
+)
diff --git a/Tests/RunCMake/FetchContent/DownloadTwice-result.txt b/Tests/RunCMake/FetchContent/DownloadTwice-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/DownloadTwice-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FetchContent/DownloadTwice-stderr.txt b/Tests/RunCMake/FetchContent/DownloadTwice-stderr.txt
new file mode 100644
index 000000000..96fed483d
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/DownloadTwice-stderr.txt
@@ -0,0 +1 @@
+Content t1 already populated in
diff --git a/Tests/RunCMake/FetchContent/DownloadTwice.cmake b/Tests/RunCMake/FetchContent/DownloadTwice.cmake
new file mode 100644
index 000000000..6863c305f
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/DownloadTwice.cmake
@@ -0,0 +1,9 @@
+include(FetchContent)
+
+FetchContent_Declare(
+ t1
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E echo "Download command executed"
+)
+
+FetchContent_Populate(t1)
+FetchContent_Populate(t1) # Triggers error
diff --git a/Tests/RunCMake/FetchContent/FirstDetailsWin-stdout.txt b/Tests/RunCMake/FetchContent/FirstDetailsWin-stdout.txt
new file mode 100644
index 000000000..7a8bf18b2
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/FirstDetailsWin-stdout.txt
@@ -0,0 +1 @@
+First details used
diff --git a/Tests/RunCMake/FetchContent/FirstDetailsWin.cmake b/Tests/RunCMake/FetchContent/FirstDetailsWin.cmake
new file mode 100644
index 000000000..208b12db0
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/FirstDetailsWin.cmake
@@ -0,0 +1,16 @@
+include(FetchContent)
+
+# Need to see the download command output
+set(FETCHCONTENT_QUIET OFF)
+
+FetchContent_Declare(
+ t1
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E echo "First details used"
+)
+
+FetchContent_Declare(
+ t1
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E echo "Second details used"
+)
+
+FetchContent_Populate(t1)
diff --git a/Tests/RunCMake/FetchContent/GetProperties.cmake b/Tests/RunCMake/FetchContent/GetProperties.cmake
new file mode 100644
index 000000000..61c99fec3
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/GetProperties.cmake
@@ -0,0 +1,67 @@
+include(FetchContent)
+
+# First confirm properties are empty even before declare
+FetchContent_GetProperties(t1)
+if(t1_POPULATED)
+ message(FATAL_ERROR "Property says populated before doing anything")
+endif()
+if(t1_SOURCE_DIR)
+ message(FATAL_ERROR "SOURCE_DIR property not initially empty")
+endif()
+if(t1_BINARY_DIR)
+ message(FATAL_ERROR "BINARY_DIR property not initially empty")
+endif()
+
+# Declare, but no properties should change yet
+FetchContent_Declare(
+ t1
+ SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/savedSrc
+ BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/savedBin
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E echo "Do nothing"
+)
+
+FetchContent_GetProperties(t1)
+if(t1_POPULATED)
+ message(FATAL_ERROR "Property says populated after only declaring details")
+endif()
+if(t1_SOURCE_DIR)
+ message(FATAL_ERROR "SOURCE_DIR property not empty after declare")
+endif()
+if(t1_BINARY_DIR)
+ message(FATAL_ERROR "BINARY_DIR property not empty after declare")
+endif()
+
+# Populate should make all properties non-empty/set
+FetchContent_Populate(t1)
+
+FetchContent_GetProperties(t1)
+if(NOT t1_POPULATED)
+ message(FATAL_ERROR "Population did not set POPULATED property")
+endif()
+if(NOT "${t1_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/savedSrc")
+ message(FATAL_ERROR "SOURCE_DIR property not correct after population: "
+ "${t1_SOURCE_DIR}\n"
+ " Expected: ${CMAKE_CURRENT_BINARY_DIR}/savedSrc")
+endif()
+if(NOT "${t1_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/savedBin")
+ message(FATAL_ERROR "BINARY_DIR property not correct after population: "
+ "${t1_BINARY_DIR}\n"
+ " Expected: ${CMAKE_CURRENT_BINARY_DIR}/savedBin")
+endif()
+
+# Verify we can retrieve properties individually too
+FetchContent_GetProperties(t1 POPULATED varPop)
+FetchContent_GetProperties(t1 SOURCE_DIR varSrc)
+FetchContent_GetProperties(t1 BINARY_DIR varBin)
+
+if(NOT varPop)
+ message(FATAL_ERROR "Failed to retrieve POPULATED property")
+endif()
+if(NOT "${varSrc}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/savedSrc")
+ message(FATAL_ERROR "SOURCE_DIR property not retrieved correctly: ${varSrc}\n"
+ " Expected: ${CMAKE_CURRENT_BINARY_DIR}/savedSrc")
+endif()
+if(NOT "${varBin}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/savedBin")
+ message(FATAL_ERROR "BINARY_DIR property not retrieved correctly: ${varBin}\n"
+ " Expected: ${CMAKE_CURRENT_BINARY_DIR}/savedBin")
+endif()
diff --git a/Tests/RunCMake/FetchContent/MakeAvailable-stdout.txt b/Tests/RunCMake/FetchContent/MakeAvailable-stdout.txt
new file mode 100644
index 000000000..6e6c73062
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/MakeAvailable-stdout.txt
@@ -0,0 +1,2 @@
+Confirmation project has been added
+.*Confirmation script has been called
diff --git a/Tests/RunCMake/FetchContent/MakeAvailable.cmake b/Tests/RunCMake/FetchContent/MakeAvailable.cmake
new file mode 100644
index 000000000..a93f1f70d
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/MakeAvailable.cmake
@@ -0,0 +1,20 @@
+include(FetchContent)
+
+FetchContent_Declare(
+ WithProject
+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithProject
+)
+FetchContent_Declare(
+ WithoutProject
+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithoutProject
+)
+
+# Order is important and will be verified by test output
+FetchContent_MakeAvailable(WithProject WithoutProject)
+
+get_property(addedWith GLOBAL PROPERTY FetchWithProject SET)
+if(NOT addedWith)
+ message(SEND_ERROR "Subdir with CMakeLists.txt not added")
+endif()
+
+include(${withoutproject_SOURCE_DIR}/confirmMessage.cmake)
diff --git a/Tests/RunCMake/FetchContent/MakeAvailableTwice-stdout.txt b/Tests/RunCMake/FetchContent/MakeAvailableTwice-stdout.txt
new file mode 100644
index 000000000..8d3b7c04f
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/MakeAvailableTwice-stdout.txt
@@ -0,0 +1,4 @@
+-- Before first[
+ ]+-- Confirmation project has been added[
+ ]+-- Between both[
+ ]+-- After last
diff --git a/Tests/RunCMake/FetchContent/MakeAvailableTwice.cmake b/Tests/RunCMake/FetchContent/MakeAvailableTwice.cmake
new file mode 100644
index 000000000..a9af02091
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/MakeAvailableTwice.cmake
@@ -0,0 +1,12 @@
+include(FetchContent)
+
+FetchContent_Declare(
+ WithProject
+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithProject
+)
+
+message(STATUS "Before first")
+FetchContent_MakeAvailable(WithProject)
+message(STATUS "Between both")
+FetchContent_MakeAvailable(WithProject)
+message(STATUS "After last")
diff --git a/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-result.txt b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-stderr.txt b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-stderr.txt
new file mode 100644
index 000000000..9715b7889
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared-stderr.txt
@@ -0,0 +1 @@
+No content details recorded for NoDetails
diff --git a/Tests/RunCMake/FetchContent/MakeAvailableUndeclared.cmake b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared.cmake
new file mode 100644
index 000000000..bd57cbe1a
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/MakeAvailableUndeclared.cmake
@@ -0,0 +1,3 @@
+include(FetchContent)
+
+FetchContent_MakeAvailable(NoDetails)
diff --git a/Tests/RunCMake/FetchContent/MissingDetails-result.txt b/Tests/RunCMake/FetchContent/MissingDetails-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/MissingDetails-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FetchContent/MissingDetails-stderr.txt b/Tests/RunCMake/FetchContent/MissingDetails-stderr.txt
new file mode 100644
index 000000000..c4f1daf58
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/MissingDetails-stderr.txt
@@ -0,0 +1 @@
+No content details recorded for t1
diff --git a/Tests/RunCMake/FetchContent/MissingDetails.cmake b/Tests/RunCMake/FetchContent/MissingDetails.cmake
new file mode 100644
index 000000000..ba8d12167
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/MissingDetails.cmake
@@ -0,0 +1,3 @@
+include(FetchContent)
+
+FetchContent_Populate(t1)
diff --git a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake
new file mode 100644
index 000000000..e28ae96dd
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake
@@ -0,0 +1,32 @@
+include(RunCMake)
+
+unset(RunCMake_TEST_NO_CLEAN)
+
+run_cmake(MissingDetails)
+run_cmake(DirectIgnoresDetails)
+run_cmake(FirstDetailsWin)
+run_cmake(DownloadTwice)
+run_cmake(SameGenerator)
+run_cmake(VarDefinitions)
+run_cmake(GetProperties)
+run_cmake(DirOverrides)
+run_cmake(UsesTerminalOverride)
+run_cmake(MakeAvailable)
+run_cmake(MakeAvailableTwice)
+run_cmake(MakeAvailableUndeclared)
+
+# We need to pass through CMAKE_GENERATOR and CMAKE_MAKE_PROGRAM
+# to ensure the test can run on machines where the build tool
+# isn't on the PATH. Some build slaves explicitly test with such
+# an arrangement (e.g. to test with spaces in the path). We also
+# pass through the platform and toolset for completeness, even
+# though we don't build anything, just in case this somehow affects
+# the way the build tool is invoked.
+run_cmake_command(ScriptMode
+ ${CMAKE_COMMAND}
+ -DCMAKE_GENERATOR=${RunCMake_GENERATOR}
+ -DCMAKE_GENERATOR_PLATFORM=${RunCMake_GENERATOR_PLATFORM}
+ -DCMAKE_GENERATOR_TOOLSET=${RunCMake_GENERATOR_TOOLSET}
+ -DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}
+ -P ${CMAKE_CURRENT_LIST_DIR}/ScriptMode.cmake
+)
diff --git a/Tests/RunCMake/FetchContent/SameGenerator.cmake b/Tests/RunCMake/FetchContent/SameGenerator.cmake
new file mode 100644
index 000000000..58204ef04
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/SameGenerator.cmake
@@ -0,0 +1,17 @@
+include(FetchContent)
+
+FetchContent_Declare(
+ t1
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E echo "Download command executed"
+)
+
+FetchContent_Populate(t1)
+
+file(STRINGS "${FETCHCONTENT_BASE_DIR}/t1-subbuild/CMakeCache.txt"
+ matchLine REGEX "^CMAKE_GENERATOR:.*="
+ LIMIT_COUNT 1
+)
+if(NOT matchLine MATCHES "${CMAKE_GENERATOR}")
+ message(FATAL_ERROR "Generator line mismatch: ${matchLine}\n"
+ " Expected type: ${CMAKE_GENERATOR}")
+endif()
diff --git a/Tests/RunCMake/FetchContent/ScriptMode.cmake b/Tests/RunCMake/FetchContent/ScriptMode.cmake
new file mode 100644
index 000000000..0a93d620e
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/ScriptMode.cmake
@@ -0,0 +1,35 @@
+include(FetchContent)
+
+file(WRITE tmpFile.txt "Generated contents, not important")
+
+FetchContent_Populate(
+ t1
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_BINARY_DIR}/tmpFile.txt
+ <SOURCE_DIR>/done1.txt
+)
+if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/t1-src/done1.txt)
+ message(FATAL_ERROR "Default SOURCE_DIR doesn't contain done1.txt")
+endif()
+
+FetchContent_Populate(
+ t2
+ SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/mysrc
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_BINARY_DIR}/tmpFile.txt
+ <SOURCE_DIR>/done2.txt
+)
+if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/mysrc/done2.txt)
+ message(FATAL_ERROR "Specified SOURCE_DIR doesn't contain done2.txt")
+endif()
+
+FetchContent_Populate(
+ t3
+ SOURCE_DIR myrelsrc
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_BINARY_DIR}/tmpFile.txt
+ <SOURCE_DIR>/done3.txt
+)
+if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/myrelsrc/done3.txt)
+ message(FATAL_ERROR "Relative SOURCE_DIR doesn't contain done3.txt")
+endif()
diff --git a/Tests/RunCMake/FetchContent/UsesTerminalOverride-stdout.txt b/Tests/RunCMake/FetchContent/UsesTerminalOverride-stdout.txt
new file mode 100644
index 000000000..3718d6459
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/UsesTerminalOverride-stdout.txt
@@ -0,0 +1,2 @@
+Logged from t1 download step
++.*Logged from t2 download step
diff --git a/Tests/RunCMake/FetchContent/UsesTerminalOverride.cmake b/Tests/RunCMake/FetchContent/UsesTerminalOverride.cmake
new file mode 100644
index 000000000..99d9719e4
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/UsesTerminalOverride.cmake
@@ -0,0 +1,17 @@
+include(FetchContent)
+
+set(FETCHCONTENT_QUIET NO)
+
+FetchContent_Declare(
+ t1
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E echo "Logged from t1 download step"
+ USES_TERMINAL_DOWNLOAD NO
+
+)
+FetchContent_Populate(t1)
+
+FetchContent_Populate(
+ t2
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E echo "Logged from t2 download step"
+ USES_TERMINAL_DOWNLOAD NO
+)
diff --git a/Tests/RunCMake/FetchContent/VarDefinitions.cmake b/Tests/RunCMake/FetchContent/VarDefinitions.cmake
new file mode 100644
index 000000000..4d2a929af
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/VarDefinitions.cmake
@@ -0,0 +1,75 @@
+unset(FETCHCONTENT_FULLY_DISCONNECTED CACHE)
+unset(FETCHCONTENT_UPDATES_DISCONNECTED CACHE)
+unset(FETCHCONTENT_QUIET CACHE)
+unset(FETCHCONTENT_BASE_DIR CACHE)
+
+include(FetchContent)
+
+# Each of the cache entries should be defined and have the
+# expected value. Be careful to check unset separately from a
+# false value, since unset also equates to false.
+if(FETCHCONTENT_FULLY_DISCONNECTED STREQUAL "")
+ message(FATAL_ERROR "FETCHCONTENT_FULLY_DISCONNECTED not defined")
+elseif(FETCHCONTENT_FULLY_DISCONNECTED)
+ message(FATAL_ERROR "FETCHCONTENT_FULLY_DISCONNECTED not defaulted to OFF")
+endif()
+
+if(FETCHCONTENT_UPDATES_DISCONNECTED STREQUAL "")
+ message(FATAL_ERROR "FETCHCONTENT_UPDATES_DISCONNECTED not defined")
+elseif(FETCHCONTENT_UPDATES_DISCONNECTED)
+ message(FATAL_ERROR "FETCHCONTENT_UPDATES_DISCONNECTED not defaulted to OFF")
+endif()
+
+if(FETCHCONTENT_QUIET STREQUAL "")
+ message(FATAL_ERROR "FETCHCONTENT_QUIET not defined")
+elseif(NOT FETCHCONTENT_QUIET)
+ message(FATAL_ERROR "FETCHCONTENT_QUIET not defaulted to ON")
+endif()
+
+if(NOT FETCHCONTENT_BASE_DIR STREQUAL "${CMAKE_BINARY_DIR}/_deps")
+ message(FATAL_ERROR "FETCHCONTENT_BASE_DIR has default value: "
+ "${FETCHCONTENT_BASE_DIR}\n Expected: ${CMAKE_BINARY_DIR}/_deps")
+endif()
+
+file(REMOVE_RECURSE ${FETCHCONTENT_BASE_DIR}/t1-subbuild)
+
+# Use uppercase T1 test name to confirm conversion to lowercase
+# for the t1_... variable names that get set
+FetchContent_Declare(
+ T1
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E echo "Download command executed"
+)
+FetchContent_Populate(T1)
+
+# Be careful to check both regular and cache variables. Since they have
+# the same name, we can only confirm them separately by using get_property().
+get_property(srcRegVarSet VARIABLE PROPERTY t1_SOURCE_DIR SET)
+get_property(bldRegVarSet VARIABLE PROPERTY t1_BINARY_DIR SET)
+
+get_property(srcCacheVarSet CACHE t1_SOURCE_DIR PROPERTY VALUE SET)
+get_property(bldCacheVarSet CACHE t1_BINARY_DIR PROPERTY VALUE SET)
+
+if(NOT srcRegVarSet)
+ message(FATAL_ERROR "t1_SOURCE_DIR regular variable not set")
+endif()
+if(NOT bldRegVarSet)
+ message(FATAL_ERROR "t1_BINARY_DIR regular variable not set")
+endif()
+if(srcCacheVarSet)
+ message(FATAL_ERROR "t1_SOURCE_DIR cache variable unexpectedly set")
+endif()
+if(bldCacheVarSet)
+ message(FATAL_ERROR "t1_BINARY_DIR cache variable unexpectedly set")
+endif()
+
+set(srcRegVar ${t1_SOURCE_DIR})
+set(bldRegVar ${t1_BINARY_DIR})
+
+if(NOT srcRegVar STREQUAL "${CMAKE_BINARY_DIR}/_deps/t1-src")
+ message(FATAL_ERROR "Unexpected t1_SOURCE_DIR value: ${srcRegVar}\n"
+ " Expected: ${CMAKE_BINARY_DIR}/_deps/t1-src")
+endif()
+if(NOT bldRegVar STREQUAL "${CMAKE_BINARY_DIR}/_deps/t1-build")
+ message(FATAL_ERROR "Unexpected t1_BINARY_DIR value: ${bldRegVar}\n"
+ " Expected: ${CMAKE_BINARY_DIR}/_deps/t1-build")
+endif()
diff --git a/Tests/RunCMake/FetchContent/WithProject/CMakeLists.txt b/Tests/RunCMake/FetchContent/WithProject/CMakeLists.txt
new file mode 100644
index 000000000..b6a37508e
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/WithProject/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.13)
+project(WithProject LANGUAGES NONE)
+
+set_property(GLOBAL PROPERTY FetchWithProject YES)
+message(STATUS "Confirmation project has been added")
diff --git a/Tests/RunCMake/FetchContent/WithoutProject/confirmMessage.cmake b/Tests/RunCMake/FetchContent/WithoutProject/confirmMessage.cmake
new file mode 100644
index 000000000..a2f5c61d0
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/WithoutProject/confirmMessage.cmake
@@ -0,0 +1 @@
+message(STATUS "Confirmation script has been called")
diff --git a/Tests/RunCMake/FileAPI/CMakeLists.txt b/Tests/RunCMake/FileAPI/CMakeLists.txt
new file mode 100644
index 000000000..44025d3bd
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.12)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/FileAPI/ClientStateful-check.cmake b/Tests/RunCMake/FileAPI/ClientStateful-check.cmake
new file mode 100644
index 000000000..1e9aab6d1
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/ClientStateful-check.cmake
@@ -0,0 +1,68 @@
+set(expect
+ query
+ query/client-client-member
+ query/client-client-member/query.json
+ query/client-empty-array
+ query/client-empty-array/query.json
+ query/client-empty-object
+ query/client-empty-object/query.json
+ query/client-json-bad-root
+ query/client-json-bad-root/query.json
+ query/client-json-empty
+ query/client-json-empty/query.json
+ query/client-json-extra
+ query/client-json-extra/query.json
+ query/client-not-file
+ query/client-not-file/query.json
+ query/client-request-array-negative-major-version
+ query/client-request-array-negative-major-version/query.json
+ query/client-request-array-negative-minor-version
+ query/client-request-array-negative-minor-version/query.json
+ query/client-request-array-negative-version
+ query/client-request-array-negative-version/query.json
+ query/client-request-array-no-major-version
+ query/client-request-array-no-major-version/query.json
+ query/client-request-array-no-supported-version
+ query/client-request-array-no-supported-version-among
+ query/client-request-array-no-supported-version-among/query.json
+ query/client-request-array-no-supported-version/query.json
+ query/client-request-array-version-1
+ query/client-request-array-version-1-1
+ query/client-request-array-version-1-1/query.json
+ query/client-request-array-version-1/query.json
+ query/client-request-array-version-2
+ query/client-request-array-version-2/query.json
+ query/client-request-negative-major-version
+ query/client-request-negative-major-version/query.json
+ query/client-request-negative-minor-version
+ query/client-request-negative-minor-version/query.json
+ query/client-request-negative-version
+ query/client-request-negative-version/query.json
+ query/client-request-no-major-version
+ query/client-request-no-major-version/query.json
+ query/client-request-no-version
+ query/client-request-no-version/query.json
+ query/client-request-version-1
+ query/client-request-version-1-1
+ query/client-request-version-1-1/query.json
+ query/client-request-version-1/query.json
+ query/client-request-version-2
+ query/client-request-version-2/query.json
+ query/client-requests-bad
+ query/client-requests-bad/query.json
+ query/client-requests-empty
+ query/client-requests-empty/query.json
+ query/client-requests-not-kinded
+ query/client-requests-not-kinded/query.json
+ query/client-requests-not-objects
+ query/client-requests-not-objects/query.json
+ query/client-requests-unknown
+ query/client-requests-unknown/query.json
+ reply
+ reply/__test-v1-[0-9a-f]+.json
+ reply/__test-v2-[0-9a-f]+.json
+ reply/index-[0-9.T-]+.json
+ )
+check_api("^${expect}$")
+
+check_python(ClientStateful)
diff --git a/Tests/RunCMake/FileAPI/ClientStateful-check.py b/Tests/RunCMake/FileAPI/ClientStateful-check.py
new file mode 100644
index 000000000..f3d20d13e
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/ClientStateful-check.py
@@ -0,0 +1,258 @@
+from check_index import *
+
+def check_reply(q):
+ assert is_dict(q)
+ assert sorted(q.keys()) == [
+ "client-client-member",
+ "client-empty-array",
+ "client-empty-object",
+ "client-json-bad-root",
+ "client-json-empty",
+ "client-json-extra",
+ "client-not-file",
+ "client-request-array-negative-major-version",
+ "client-request-array-negative-minor-version",
+ "client-request-array-negative-version",
+ "client-request-array-no-major-version",
+ "client-request-array-no-supported-version",
+ "client-request-array-no-supported-version-among",
+ "client-request-array-version-1",
+ "client-request-array-version-1-1",
+ "client-request-array-version-2",
+ "client-request-negative-major-version",
+ "client-request-negative-minor-version",
+ "client-request-negative-version",
+ "client-request-no-major-version",
+ "client-request-no-version",
+ "client-request-version-1",
+ "client-request-version-1-1",
+ "client-request-version-2",
+ "client-requests-bad",
+ "client-requests-empty",
+ "client-requests-not-kinded",
+ "client-requests-not-objects",
+ "client-requests-unknown",
+ ]
+ expected = [
+ (check_query_client_member, "client-client-member"),
+ (check_query_empty_array, "client-empty-array"),
+ (check_query_empty_object, "client-empty-object"),
+ (check_query_json_bad_root, "client-json-bad-root"),
+ (check_query_json_empty, "client-json-empty"),
+ (check_query_json_extra, "client-json-extra"),
+ (check_query_not_file, "client-not-file"),
+ (check_query_requests_bad, "client-requests-bad"),
+ (check_query_requests_empty, "client-requests-empty"),
+ (check_query_requests_not_kinded, "client-requests-not-kinded"),
+ (check_query_requests_not_objects, "client-requests-not-objects"),
+ (check_query_requests_unknown, "client-requests-unknown"),
+ ]
+ for (f, k) in expected:
+ assert is_dict(q[k])
+ assert sorted(q[k].keys()) == ["query.json"]
+ f(q[k]["query.json"])
+ expected = [
+ (check_query_response_array_negative_major_version, "client-request-array-negative-major-version"),
+ (check_query_response_array_negative_minor_version, "client-request-array-negative-minor-version"),
+ (check_query_response_array_negative_version, "client-request-array-negative-version"),
+ (check_query_response_array_no_major_version, "client-request-array-no-major-version"),
+ (check_query_response_array_no_supported_version, "client-request-array-no-supported-version"),
+ (check_query_response_array_no_supported_version_among, "client-request-array-no-supported-version-among"),
+ (check_query_response_array_version_1, "client-request-array-version-1"),
+ (check_query_response_array_version_1_1, "client-request-array-version-1-1"),
+ (check_query_response_array_version_2, "client-request-array-version-2"),
+ (check_query_response_negative_major_version, "client-request-negative-major-version"),
+ (check_query_response_negative_minor_version, "client-request-negative-minor-version"),
+ (check_query_response_negative_version, "client-request-negative-version"),
+ (check_query_response_no_major_version, "client-request-no-major-version"),
+ (check_query_response_no_version, "client-request-no-version"),
+ (check_query_response_version_1, "client-request-version-1"),
+ (check_query_response_version_1_1, "client-request-version-1-1"),
+ (check_query_response_version_2, "client-request-version-2"),
+ ]
+ for (f, k) in expected:
+ assert is_dict(q[k])
+ assert sorted(q[k].keys()) == ["query.json"]
+ assert is_dict(q[k]["query.json"])
+ assert sorted(q[k]["query.json"].keys()) == ["requests", "responses"]
+ r = q[k]["query.json"]["requests"]
+ assert is_list(r)
+ assert len(r) == 1
+ assert is_dict(r[0])
+ assert r[0]["kind"] == "__test"
+ r = q[k]["query.json"]["responses"]
+ assert is_list(r)
+ assert len(r) == 1
+ assert is_dict(r[0])
+ f(r[0])
+
+def check_query_client_member(q):
+ assert is_dict(q)
+ assert sorted(q.keys()) == ["client", "responses"]
+ assert is_dict(q["client"])
+ assert sorted(q["client"].keys()) == []
+ check_error(q["responses"], "'requests' member missing")
+
+def check_query_empty_array(q):
+ check_error(q, "query root is not an object")
+
+def check_query_empty_object(q):
+ assert is_dict(q)
+ assert sorted(q.keys()) == ["responses"]
+ check_error(q["responses"], "'requests' member missing")
+
+def check_query_json_bad_root(q):
+ check_error_re(q, "A valid JSON document must be either an array or an object value")
+
+def check_query_json_empty(q):
+ check_error_re(q, "value, object or array expected")
+
+def check_query_json_extra(q):
+ check_error_re(q, "Extra non-whitespace after JSON value")
+
+def check_query_not_file(q):
+ check_error_re(q, "failed to read from file")
+
+def check_query_requests_bad(q):
+ assert is_dict(q)
+ assert sorted(q.keys()) == ["requests", "responses"]
+ r = q["requests"]
+ assert is_dict(r)
+ assert sorted(r.keys()) == []
+ check_error(q["responses"], "'requests' member is not an array")
+
+def check_query_requests_empty(q):
+ assert is_dict(q)
+ assert sorted(q.keys()) == ["requests", "responses"]
+ r = q["requests"]
+ assert is_list(r)
+ assert len(r) == 0
+ r = q["responses"]
+ assert is_list(r)
+ assert len(r) == 0
+
+def check_query_requests_not_kinded(q):
+ assert is_dict(q)
+ assert sorted(q.keys()) == ["requests", "responses"]
+ r = q["requests"]
+ assert is_list(r)
+ assert len(r) == 4
+ assert is_dict(r[0])
+ assert sorted(r[0].keys()) == []
+ assert is_dict(r[1])
+ assert sorted(r[1].keys()) == ["kind"]
+ assert is_dict(r[1]["kind"])
+ assert is_dict(r[2])
+ assert sorted(r[2].keys()) == ["kind"]
+ assert is_list(r[2]["kind"])
+ assert is_dict(r[3])
+ assert sorted(r[3].keys()) == ["kind"]
+ assert is_int(r[3]["kind"])
+ r = q["responses"]
+ assert is_list(r)
+ assert len(r) == 4
+ check_error(r[0], "'kind' member missing")
+ check_error(r[1], "'kind' member is not a string")
+ check_error(r[2], "'kind' member is not a string")
+ check_error(r[3], "'kind' member is not a string")
+
+def check_query_requests_not_objects(q):
+ assert is_dict(q)
+ assert sorted(q.keys()) == ["requests", "responses"]
+ r = q["requests"]
+ assert is_list(r)
+ assert len(r) == 3
+ assert is_int(r[0])
+ assert is_string(r[1])
+ assert is_list(r[2])
+ r = q["responses"]
+ assert is_list(r)
+ assert len(r) == 3
+ check_error(r[0], "request is not an object")
+ check_error(r[1], "request is not an object")
+ check_error(r[2], "request is not an object")
+
+def check_query_requests_unknown(q):
+ assert is_dict(q)
+ assert sorted(q.keys()) == ["requests", "responses"]
+ r = q["requests"]
+ assert is_list(r)
+ assert len(r) == 3
+ assert is_dict(r[0])
+ assert sorted(r[0].keys()) == ["kind"]
+ assert r[0]["kind"] == "unknownC"
+ assert is_dict(r[1])
+ assert sorted(r[1].keys()) == ["kind"]
+ assert r[1]["kind"] == "unknownB"
+ assert is_dict(r[2])
+ assert sorted(r[2].keys()) == ["kind"]
+ assert r[2]["kind"] == "unknownA"
+ r = q["responses"]
+ assert is_list(r)
+ assert len(r) == 3
+ check_error(r[0], "unknown request kind 'unknownC'")
+ check_error(r[1], "unknown request kind 'unknownB'")
+ check_error(r[2], "unknown request kind 'unknownA'")
+
+def check_query_response_array_negative_major_version(r):
+ check_error(r, "'version' object 'major' member is not a non-negative integer")
+
+def check_query_response_array_negative_minor_version(r):
+ check_error(r, "'version' object 'minor' member is not a non-negative integer")
+
+def check_query_response_array_negative_version(r):
+ check_error(r, "'version' array entry is not a non-negative integer or object")
+
+def check_query_response_array_no_major_version(r):
+ check_error(r, "'version' object 'major' member missing")
+
+def check_query_response_array_no_supported_version(r):
+ check_error(r, "no supported version specified")
+
+def check_query_response_array_no_supported_version_among(r):
+ check_error(r, "no supported version specified among: 4.0 3.0")
+
+def check_query_response_array_version_1(r):
+ check_index__test(r, 1, 3)
+
+def check_query_response_array_version_1_1(r):
+ check_index__test(r, 1, 3) # always uses latest minor version
+
+def check_query_response_array_version_2(r):
+ check_index__test(r, 2, 0)
+
+def check_query_response_negative_major_version(r):
+ check_error(r, "'version' object 'major' member is not a non-negative integer")
+
+def check_query_response_negative_minor_version(r):
+ check_error(r, "'version' object 'minor' member is not a non-negative integer")
+
+def check_query_response_negative_version(r):
+ check_error(r, "'version' member is not a non-negative integer, object, or array")
+
+def check_query_response_no_major_version(r):
+ check_error(r, "'version' object 'major' member missing")
+
+def check_query_response_no_version(r):
+ check_error(r, "'version' member missing")
+
+def check_query_response_version_1(r):
+ check_index__test(r, 1, 3)
+
+def check_query_response_version_1_1(r):
+ check_index__test(r, 1, 3) # always uses latest minor version
+
+def check_query_response_version_2(r):
+ check_index__test(r, 2, 0)
+
+def check_objects(o):
+ assert is_list(o)
+ assert len(o) == 2
+ check_index__test(o[0], 1, 3)
+ check_index__test(o[1], 2, 0)
+
+assert is_dict(index)
+assert sorted(index.keys()) == ["cmake", "objects", "reply"]
+check_cmake(index["cmake"])
+check_reply(index["reply"])
+check_objects(index["objects"])
diff --git a/Tests/RunCMake/FileAPI/ClientStateful-prep.cmake b/Tests/RunCMake/FileAPI/ClientStateful-prep.cmake
new file mode 100644
index 000000000..5b41d7afb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/ClientStateful-prep.cmake
@@ -0,0 +1,73 @@
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-client-member/query.json" [[{ "client": {} }]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-empty-array/query.json" "[]")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-empty-object/query.json" "{}")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-json-bad-root/query.json" [["invalid root"]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-json-empty/query.json" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-json-extra/query.json" "{}x")
+file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-not-file/query.json")
+
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-requests-bad/query.json" [[{ "requests": {} }]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-requests-empty/query.json" [[{ "requests": [] }]])
+
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-requests-not-objects/query.json" [[
+{ "requests": [ 0, "", [] ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-requests-not-kinded/query.json" [[
+{ "requests": [ {}, { "kind": {} }, { "kind": [] }, { "kind": 0 } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-requests-unknown/query.json" [[
+{ "requests": [ { "kind": "unknownC" }, { "kind": "unknownB" }, { "kind": "unknownA" } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-no-version/query.json" [[
+{ "requests": [ { "kind": "__test" } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-negative-version/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : -1 } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-no-major-version/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : {} } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-negative-major-version/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : { "major": -1 } } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-negative-minor-version/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : { "major": 0, "minor": -1 } } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-array-negative-version/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : [ 1, -1 ] } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-array-no-major-version/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : [ 1, {} ] } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-array-negative-major-version/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : [ 1, { "major": -1 } ] } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-array-negative-minor-version/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : [ 1, { "major": 0, "minor": -1 } ] } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-array-no-supported-version/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : [] } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-array-no-supported-version-among/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : [4, 3] } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-version-1/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : 1 } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-version-1-1/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : { "major": 1, "minor": 1 } } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-version-2/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : { "major": 2 } } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-array-version-1/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : [3, 1] } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-array-version-1-1/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : [3, { "major": 1, "minor": 1 }, 2 ] } ] }
+]])
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-request-array-version-2/query.json" [[
+{ "requests": [ { "kind": "__test", "version" : [3, { "major": 2 } ] } ] }
+]])
+
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/reply/object-to-be-deleted.json" "")
diff --git a/Tests/RunCMake/FileAPI/ClientStateful.cmake b/Tests/RunCMake/FileAPI/ClientStateful.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/ClientStateful.cmake
diff --git a/Tests/RunCMake/FileAPI/ClientStateless-check.cmake b/Tests/RunCMake/FileAPI/ClientStateless-check.cmake
new file mode 100644
index 000000000..955d9bea4
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/ClientStateless-check.cmake
@@ -0,0 +1,15 @@
+set(expect
+ query
+ query/client-foo
+ query/client-foo/__test-v1
+ query/client-foo/__test-v2
+ query/client-foo/__test-v3
+ query/client-foo/unknown
+ reply
+ reply/__test-v1-[0-9a-f]+.json
+ reply/__test-v2-[0-9a-f]+.json
+ reply/index-[0-9.T-]+.json
+ )
+check_api("^${expect}$")
+
+check_python(ClientStateless)
diff --git a/Tests/RunCMake/FileAPI/ClientStateless-check.py b/Tests/RunCMake/FileAPI/ClientStateless-check.py
new file mode 100644
index 000000000..b7da314ce
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/ClientStateless-check.py
@@ -0,0 +1,26 @@
+from check_index import *
+
+def check_reply(r):
+ assert is_dict(r)
+ assert sorted(r.keys()) == ["client-foo"]
+ check_reply_client_foo(r["client-foo"])
+
+def check_reply_client_foo(r):
+ assert is_dict(r)
+ assert sorted(r.keys()) == ["__test-v1", "__test-v2", "__test-v3", "unknown"]
+ check_index__test(r["__test-v1"], 1, 3)
+ check_index__test(r["__test-v2"], 2, 0)
+ check_error(r["__test-v3"], "unknown query file")
+ check_error(r["unknown"], "unknown query file")
+
+def check_objects(o):
+ assert is_list(o)
+ assert len(o) == 2
+ check_index__test(o[0], 1, 3)
+ check_index__test(o[1], 2, 0)
+
+assert is_dict(index)
+assert sorted(index.keys()) == ["cmake", "objects", "reply"]
+check_cmake(index["cmake"])
+check_reply(index["reply"])
+check_objects(index["objects"])
diff --git a/Tests/RunCMake/FileAPI/ClientStateless-prep.cmake b/Tests/RunCMake/FileAPI/ClientStateless-prep.cmake
new file mode 100644
index 000000000..1b8d772fa
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/ClientStateless-prep.cmake
@@ -0,0 +1,5 @@
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/__test-v1" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/__test-v2" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/__test-v3" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/unknown" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/reply/object-to-be-deleted.json" "")
diff --git a/Tests/RunCMake/FileAPI/ClientStateless.cmake b/Tests/RunCMake/FileAPI/ClientStateless.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/ClientStateless.cmake
diff --git a/Tests/RunCMake/FileAPI/DuplicateStateless-check.cmake b/Tests/RunCMake/FileAPI/DuplicateStateless-check.cmake
new file mode 100644
index 000000000..4959c1eaa
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/DuplicateStateless-check.cmake
@@ -0,0 +1,20 @@
+set(expect
+ query
+ query/__test-v1
+ query/__test-v2
+ query/__test-v3
+ query/client-foo
+ query/client-foo/__test-v1
+ query/client-foo/__test-v2
+ query/client-foo/__test-v3
+ query/client-foo/unknown
+ query/query.json
+ query/unknown
+ reply
+ reply/__test-v1-[0-9a-f]+.json
+ reply/__test-v2-[0-9a-f]+.json
+ reply/index-[0-9.T-]+.json
+ )
+check_api("^${expect}$")
+
+check_python(DuplicateStateless)
diff --git a/Tests/RunCMake/FileAPI/DuplicateStateless-check.py b/Tests/RunCMake/FileAPI/DuplicateStateless-check.py
new file mode 100644
index 000000000..33354794c
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/DuplicateStateless-check.py
@@ -0,0 +1,31 @@
+from check_index import *
+
+def check_reply(r):
+ assert is_dict(r)
+ assert sorted(r.keys()) == ["__test-v1", "__test-v2", "__test-v3", "client-foo", "query.json", "unknown"]
+ check_index__test(r["__test-v1"], 1, 3)
+ check_index__test(r["__test-v2"], 2, 0)
+ check_error(r["__test-v3"], "unknown query file")
+ check_reply_client_foo(r["client-foo"])
+ check_error(r["query.json"], "unknown query file")
+ check_error(r["unknown"], "unknown query file")
+
+def check_reply_client_foo(r):
+ assert is_dict(r)
+ assert sorted(r.keys()) == ["__test-v1", "__test-v2", "__test-v3", "unknown"]
+ check_index__test(r["__test-v1"], 1, 3)
+ check_index__test(r["__test-v2"], 2, 0)
+ check_error(r["__test-v3"], "unknown query file")
+ check_error(r["unknown"], "unknown query file")
+
+def check_objects(o):
+ assert is_list(o)
+ assert len(o) == 2
+ check_index__test(o[0], 1, 3)
+ check_index__test(o[1], 2, 0)
+
+assert is_dict(index)
+assert sorted(index.keys()) == ["cmake", "objects", "reply"]
+check_cmake(index["cmake"])
+check_reply(index["reply"])
+check_objects(index["objects"])
diff --git a/Tests/RunCMake/FileAPI/DuplicateStateless-prep.cmake b/Tests/RunCMake/FileAPI/DuplicateStateless-prep.cmake
new file mode 100644
index 000000000..51b985281
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/DuplicateStateless-prep.cmake
@@ -0,0 +1,10 @@
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/__test-v1" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/__test-v2" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/__test-v3" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/query.json" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/unknown" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/__test-v1" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/__test-v2" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/__test-v3" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/unknown" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/reply/object-to-be-deleted.json" "")
diff --git a/Tests/RunCMake/FileAPI/DuplicateStateless.cmake b/Tests/RunCMake/FileAPI/DuplicateStateless.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/DuplicateStateless.cmake
diff --git a/Tests/RunCMake/FileAPI/Empty-check.cmake b/Tests/RunCMake/FileAPI/Empty-check.cmake
new file mode 100644
index 000000000..2764b4297
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/Empty-check.cmake
@@ -0,0 +1,8 @@
+set(expect
+ query
+ reply
+ reply/index-[0-9.T-]+.json
+ )
+check_api("^${expect}$")
+
+check_python(Empty)
diff --git a/Tests/RunCMake/FileAPI/Empty-check.py b/Tests/RunCMake/FileAPI/Empty-check.py
new file mode 100644
index 000000000..75bf096d0
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/Empty-check.py
@@ -0,0 +1,15 @@
+from check_index import *
+
+def check_reply(r):
+ assert is_dict(r)
+ assert sorted(r.keys()) == []
+
+def check_objects(o):
+ assert is_list(o)
+ assert len(o) == 0
+
+assert is_dict(index)
+assert sorted(index.keys()) == ["cmake", "objects", "reply"]
+check_cmake(index["cmake"])
+check_reply(index["reply"])
+check_objects(index["objects"])
diff --git a/Tests/RunCMake/FileAPI/Empty-prep.cmake b/Tests/RunCMake/FileAPI/Empty-prep.cmake
new file mode 100644
index 000000000..1d1f69e23
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/Empty-prep.cmake
@@ -0,0 +1 @@
+file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query")
diff --git a/Tests/RunCMake/FileAPI/Empty.cmake b/Tests/RunCMake/FileAPI/Empty.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/Empty.cmake
diff --git a/Tests/RunCMake/FileAPI/EmptyClient-check.cmake b/Tests/RunCMake/FileAPI/EmptyClient-check.cmake
new file mode 100644
index 000000000..4e5745cdb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/EmptyClient-check.cmake
@@ -0,0 +1,9 @@
+set(expect
+ query
+ query/client-foo
+ reply
+ reply/index-[0-9.T-]+.json
+ )
+check_api("^${expect}$")
+
+check_python(EmptyClient)
diff --git a/Tests/RunCMake/FileAPI/EmptyClient-check.py b/Tests/RunCMake/FileAPI/EmptyClient-check.py
new file mode 100644
index 000000000..f88790818
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/EmptyClient-check.py
@@ -0,0 +1,20 @@
+from check_index import *
+
+def check_reply(r):
+ assert is_dict(r)
+ assert sorted(r.keys()) == ["client-foo"]
+ check_reply_client_foo(r["client-foo"])
+
+def check_reply_client_foo(r):
+ assert is_dict(r)
+ assert sorted(r.keys()) == []
+
+def check_objects(o):
+ assert is_list(o)
+ assert len(o) == 0
+
+assert is_dict(index)
+assert sorted(index.keys()) == ["cmake", "objects", "reply"]
+check_cmake(index["cmake"])
+check_reply(index["reply"])
+check_objects(index["objects"])
diff --git a/Tests/RunCMake/FileAPI/EmptyClient-prep.cmake b/Tests/RunCMake/FileAPI/EmptyClient-prep.cmake
new file mode 100644
index 000000000..31512fd0c
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/EmptyClient-prep.cmake
@@ -0,0 +1,2 @@
+file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/reply/object-to-be-deleted.json" "")
diff --git a/Tests/RunCMake/FileAPI/EmptyClient.cmake b/Tests/RunCMake/FileAPI/EmptyClient.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/EmptyClient.cmake
diff --git a/Tests/RunCMake/FileAPI/MixedStateless-check.cmake b/Tests/RunCMake/FileAPI/MixedStateless-check.cmake
new file mode 100644
index 000000000..57956143e
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/MixedStateless-check.cmake
@@ -0,0 +1,16 @@
+set(expect
+ query
+ query/__test-v1
+ query/__test-v3
+ query/client-foo
+ query/client-foo/__test-v2
+ query/client-foo/unknown
+ query/query.json
+ reply
+ reply/__test-v1-[0-9a-f]+.json
+ reply/__test-v2-[0-9a-f]+.json
+ reply/index-[0-9.T-]+.json
+ )
+check_api("^${expect}$")
+
+check_python(MixedStateless)
diff --git a/Tests/RunCMake/FileAPI/MixedStateless-check.py b/Tests/RunCMake/FileAPI/MixedStateless-check.py
new file mode 100644
index 000000000..be019ab72
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/MixedStateless-check.py
@@ -0,0 +1,27 @@
+from check_index import *
+
+def check_reply(r):
+ assert is_dict(r)
+ assert sorted(r.keys()) == ["__test-v1", "__test-v3", "client-foo", "query.json"]
+ check_index__test(r["__test-v1"], 1, 3)
+ check_error(r["__test-v3"], "unknown query file")
+ check_reply_client_foo(r["client-foo"])
+ check_error(r["query.json"], "unknown query file")
+
+def check_reply_client_foo(r):
+ assert is_dict(r)
+ assert sorted(r.keys()) == ["__test-v2", "unknown"]
+ check_index__test(r["__test-v2"], 2, 0)
+ check_error(r["unknown"], "unknown query file")
+
+def check_objects(o):
+ assert is_list(o)
+ assert len(o) == 2
+ check_index__test(o[0], 1, 3)
+ check_index__test(o[1], 2, 0)
+
+assert is_dict(index)
+assert sorted(index.keys()) == ["cmake", "objects", "reply"]
+check_cmake(index["cmake"])
+check_reply(index["reply"])
+check_objects(index["objects"])
diff --git a/Tests/RunCMake/FileAPI/MixedStateless-prep.cmake b/Tests/RunCMake/FileAPI/MixedStateless-prep.cmake
new file mode 100644
index 000000000..030baac5b
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/MixedStateless-prep.cmake
@@ -0,0 +1,6 @@
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/__test-v1" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/__test-v2" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/__test-v3" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/query.json" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/unknown" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/reply/object-to-be-deleted.json" "")
diff --git a/Tests/RunCMake/FileAPI/MixedStateless.cmake b/Tests/RunCMake/FileAPI/MixedStateless.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/MixedStateless.cmake
diff --git a/Tests/RunCMake/FileAPI/Nothing-check.cmake b/Tests/RunCMake/FileAPI/Nothing-check.cmake
new file mode 100644
index 000000000..cd4f42efc
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/Nothing-check.cmake
@@ -0,0 +1 @@
+check_api("^$")
diff --git a/Tests/RunCMake/FileAPI/Nothing-prep.cmake b/Tests/RunCMake/FileAPI/Nothing-prep.cmake
new file mode 100644
index 000000000..b850d47a8
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/Nothing-prep.cmake
@@ -0,0 +1 @@
+file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1")
diff --git a/Tests/RunCMake/FileAPI/Nothing.cmake b/Tests/RunCMake/FileAPI/Nothing.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/Nothing.cmake
diff --git a/Tests/RunCMake/FileAPI/RunCMakeTest.cmake b/Tests/RunCMake/FileAPI/RunCMakeTest.cmake
new file mode 100644
index 000000000..f8adb644a
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/RunCMakeTest.cmake
@@ -0,0 +1,58 @@
+include(RunCMake)
+
+# Function called in *-check.cmake scripts to check api files.
+function(check_api expect)
+ file(GLOB_RECURSE actual
+ LIST_DIRECTORIES TRUE
+ RELATIVE ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1
+ ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/*
+ )
+ if(NOT "${actual}" MATCHES "${expect}")
+ set(RunCMake_TEST_FAILED "API files:
+ ${actual}
+do not match what we expected:
+ ${expect}
+in directory:
+ ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1" PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(check_python case)
+ if(RunCMake_TEST_FAILED OR NOT PYTHON_EXECUTABLE)
+ return()
+ endif()
+ file(GLOB index ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/reply/index-*.json)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/${case}-check.py" "${index}"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE output
+ ERROR_VARIABLE output
+ )
+ if(NOT result EQUAL 0)
+ string(REPLACE "\n" "\n " output " ${output}")
+ set(RunCMake_TEST_FAILED "Unexpected index:\n${output}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+run_cmake(Nothing)
+run_cmake(Empty)
+run_cmake(EmptyClient)
+run_cmake(Stale)
+run_cmake(SharedStateless)
+run_cmake(ClientStateless)
+run_cmake(MixedStateless)
+run_cmake(DuplicateStateless)
+run_cmake(ClientStateful)
+
+function(run_object object)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${object}-build)
+ run_cmake(${object})
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${object}-SharedStateless ${CMAKE_COMMAND} .)
+ run_cmake_command(${object}-ClientStateless ${CMAKE_COMMAND} .)
+ run_cmake_command(${object}-ClientStateful ${CMAKE_COMMAND} .)
+endfunction()
+
+run_object(codemodel-v2)
+run_object(cache-v2)
+run_object(cmakeFiles-v1)
diff --git a/Tests/RunCMake/FileAPI/SharedStateless-check.cmake b/Tests/RunCMake/FileAPI/SharedStateless-check.cmake
new file mode 100644
index 000000000..7f3bb23dc
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/SharedStateless-check.cmake
@@ -0,0 +1,15 @@
+set(expect
+ query
+ query/__test-v1
+ query/__test-v2
+ query/__test-v3
+ query/query.json
+ query/unknown
+ reply
+ reply/__test-v1-[0-9a-f]+.json
+ reply/__test-v2-[0-9a-f]+.json
+ reply/index-[0-9.T-]+.json
+ )
+check_api("^${expect}$")
+
+check_python(SharedStateless)
diff --git a/Tests/RunCMake/FileAPI/SharedStateless-check.py b/Tests/RunCMake/FileAPI/SharedStateless-check.py
new file mode 100644
index 000000000..79f52d712
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/SharedStateless-check.py
@@ -0,0 +1,22 @@
+from check_index import *
+
+def check_reply(r):
+ assert is_dict(r)
+ assert sorted(r.keys()) == ["__test-v1", "__test-v2", "__test-v3", "query.json", "unknown"]
+ check_index__test(r["__test-v1"], 1, 3)
+ check_index__test(r["__test-v2"], 2, 0)
+ check_error(r["__test-v3"], "unknown query file")
+ check_error(r["query.json"], "unknown query file")
+ check_error(r["unknown"], "unknown query file")
+
+def check_objects(o):
+ assert is_list(o)
+ assert len(o) == 2
+ check_index__test(o[0], 1, 3)
+ check_index__test(o[1], 2, 0)
+
+assert is_dict(index)
+assert sorted(index.keys()) == ["cmake", "objects", "reply"]
+check_cmake(index["cmake"])
+check_reply(index["reply"])
+check_objects(index["objects"])
diff --git a/Tests/RunCMake/FileAPI/SharedStateless-prep.cmake b/Tests/RunCMake/FileAPI/SharedStateless-prep.cmake
new file mode 100644
index 000000000..b2804140e
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/SharedStateless-prep.cmake
@@ -0,0 +1,6 @@
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/__test-v1" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/__test-v2" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/__test-v3" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/query.json" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/unknown" "")
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/reply/object-to-be-deleted.json" "")
diff --git a/Tests/RunCMake/FileAPI/SharedStateless.cmake b/Tests/RunCMake/FileAPI/SharedStateless.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/SharedStateless.cmake
diff --git a/Tests/RunCMake/FileAPI/Stale-check.cmake b/Tests/RunCMake/FileAPI/Stale-check.cmake
new file mode 100644
index 000000000..7ee2c9e7f
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/Stale-check.cmake
@@ -0,0 +1,4 @@
+set(expect
+ reply
+ )
+check_api("^${expect}$")
diff --git a/Tests/RunCMake/FileAPI/Stale-prep.cmake b/Tests/RunCMake/FileAPI/Stale-prep.cmake
new file mode 100644
index 000000000..e920925f0
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/Stale-prep.cmake
@@ -0,0 +1 @@
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/reply/object-to-be-deleted.json" "")
diff --git a/Tests/RunCMake/FileAPI/Stale.cmake b/Tests/RunCMake/FileAPI/Stale.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/Stale.cmake
diff --git a/Tests/RunCMake/FileAPI/alias/CMakeLists.txt b/Tests/RunCMake/FileAPI/alias/CMakeLists.txt
new file mode 100644
index 000000000..549307dfb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/alias/CMakeLists.txt
@@ -0,0 +1,10 @@
+project(Alias)
+enable_language(CXX)
+
+add_library(c_alias_lib ALIAS c_lib)
+add_executable(c_alias_exe ../empty.c)
+target_link_libraries(c_alias_exe PRIVATE c_alias_lib)
+
+add_library(cxx_alias_lib ALIAS cxx_lib)
+add_executable(cxx_alias_exe ../empty.cxx)
+target_link_libraries(cxx_alias_exe PRIVATE cxx_alias_lib)
diff --git a/Tests/RunCMake/FileAPI/cache-v2-ClientStateful-check.cmake b/Tests/RunCMake/FileAPI/cache-v2-ClientStateful-check.cmake
new file mode 100644
index 000000000..0f5ef28a6
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cache-v2-ClientStateful-check.cmake
@@ -0,0 +1,11 @@
+set(expect
+ query
+ query/client-foo
+ query/client-foo/query.json
+ reply
+ reply/cache-v2-[0-9a-f]+.json
+ reply/index-[0-9.T-]+.json
+ )
+check_api("^${expect}$")
+
+check_python(cache-v2)
diff --git a/Tests/RunCMake/FileAPI/cache-v2-ClientStateful-prep.cmake b/Tests/RunCMake/FileAPI/cache-v2-ClientStateful-prep.cmake
new file mode 100644
index 000000000..9329280b1
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cache-v2-ClientStateful-prep.cmake
@@ -0,0 +1,4 @@
+file(REMOVE_RECURSE ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query)
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/query.json" [[
+{ "requests": [ { "kind": "cache", "version" : 2 } ] }
+]])
diff --git a/Tests/RunCMake/FileAPI/cache-v2-ClientStateless-check.cmake b/Tests/RunCMake/FileAPI/cache-v2-ClientStateless-check.cmake
new file mode 100644
index 000000000..c406ec81b
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cache-v2-ClientStateless-check.cmake
@@ -0,0 +1,11 @@
+set(expect
+ query
+ query/client-foo
+ query/client-foo/cache-v2
+ reply
+ reply/cache-v2-[0-9a-f]+.json
+ reply/index-[0-9.T-]+.json
+ )
+check_api("^${expect}$")
+
+check_python(cache-v2)
diff --git a/Tests/RunCMake/FileAPI/cache-v2-ClientStateless-prep.cmake b/Tests/RunCMake/FileAPI/cache-v2-ClientStateless-prep.cmake
new file mode 100644
index 000000000..dccafa545
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cache-v2-ClientStateless-prep.cmake
@@ -0,0 +1,2 @@
+file(REMOVE_RECURSE ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query)
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/cache-v2" "")
diff --git a/Tests/RunCMake/FileAPI/cache-v2-SharedStateless-check.cmake b/Tests/RunCMake/FileAPI/cache-v2-SharedStateless-check.cmake
new file mode 100644
index 000000000..f8337ebf5
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cache-v2-SharedStateless-check.cmake
@@ -0,0 +1,10 @@
+set(expect
+ query
+ query/cache-v2
+ reply
+ reply/cache-v2-[0-9a-f]+.json
+ reply/index-[0-9.T-]+.json
+ )
+check_api("^${expect}$")
+
+check_python(cache-v2)
diff --git a/Tests/RunCMake/FileAPI/cache-v2-SharedStateless-prep.cmake b/Tests/RunCMake/FileAPI/cache-v2-SharedStateless-prep.cmake
new file mode 100644
index 000000000..ee5ac5762
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cache-v2-SharedStateless-prep.cmake
@@ -0,0 +1,2 @@
+file(REMOVE_RECURSE ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query)
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/cache-v2" "")
diff --git a/Tests/RunCMake/FileAPI/cache-v2-check.py b/Tests/RunCMake/FileAPI/cache-v2-check.py
new file mode 100644
index 000000000..756ef8080
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cache-v2-check.py
@@ -0,0 +1,134 @@
+from check_index import *
+
+def check_objects(o):
+ assert is_list(o)
+ assert len(o) == 1
+ check_index_object(o[0], "cache", 2, 0, check_object_cache)
+
+def check_cache_entry(actual, expected):
+ assert is_dict(actual)
+ assert sorted(actual.keys()) == ["name", "properties", "type", "value"]
+
+ assert is_string(actual["type"], expected["type"])
+ assert is_string(actual["value"], expected["value"])
+
+ def check_property(actual, expected):
+ assert is_dict(actual)
+ assert sorted(actual.keys()) == ["name", "value"]
+ assert is_string(actual["value"], expected["value"])
+
+ check_list_match(lambda a, e: is_string(a["name"], e["name"]), actual["properties"], expected["properties"], check=check_property)
+
+def check_object_cache(o):
+ assert sorted(o.keys()) == ["entries", "kind", "version"]
+ # The "kind" and "version" members are handled by check_index_object.
+ check_list_match(lambda a, e: is_string(a["name"], e["name"]), o["entries"], [
+ {
+ "name": "CM_OPTION_BOOL",
+ "type": "BOOL",
+ "value": "OFF",
+ "properties": [
+ {
+ "name": "HELPSTRING",
+ "value": "Testing option()",
+ },
+ ],
+ },
+ {
+ "name": "CM_SET_BOOL",
+ "type": "BOOL",
+ "value": "ON",
+ "properties": [
+ {
+ "name": "HELPSTRING",
+ "value": "Testing set(CACHE BOOL)",
+ },
+ {
+ "name": "ADVANCED",
+ "value": "1",
+ },
+ ],
+ },
+ {
+ "name": "CM_SET_FILEPATH",
+ "type": "FILEPATH",
+ "value": "dir1/dir2/empty.txt",
+ "properties": [
+ {
+ "name": "HELPSTRING",
+ "value": "Testing set(CACHE FILEPATH)",
+ },
+ ],
+ },
+ {
+ "name": "CM_SET_PATH",
+ "type": "PATH",
+ "value": "dir1/dir2",
+ "properties": [
+ {
+ "name": "HELPSTRING",
+ "value": "Testing set(CACHE PATH)",
+ },
+ {
+ "name": "ADVANCED",
+ "value": "ON",
+ },
+ ],
+ },
+ {
+ "name": "CM_SET_STRING",
+ "type": "STRING",
+ "value": "test",
+ "properties": [
+ {
+ "name": "HELPSTRING",
+ "value": "Testing set(CACHE STRING)",
+ },
+ ],
+ },
+ {
+ "name": "CM_SET_STRINGS",
+ "type": "STRING",
+ "value": "1",
+ "properties": [
+ {
+ "name": "HELPSTRING",
+ "value": "Testing set(CACHE STRING) with STRINGS",
+ },
+ {
+ "name": "STRINGS",
+ "value": "1;2;3;4",
+ },
+ ],
+ },
+ {
+ "name": "CM_SET_INTERNAL",
+ "type": "INTERNAL",
+ "value": "int2",
+ "properties": [
+ {
+ "name": "HELPSTRING",
+ "value": "Testing set(CACHE INTERNAL)",
+ },
+ ],
+ },
+ {
+ "name": "CM_SET_TYPE",
+ "type": "STRING",
+ "value": "1",
+ "properties": [
+ {
+ "name": "HELPSTRING",
+ "value": "Testing set(CACHE INTERNAL) with set_property(TYPE)",
+ },
+ {
+ "name": "ADVANCED",
+ "value": "0",
+ },
+ ],
+ },
+ ], check=check_cache_entry, allow_extra=True)
+
+assert is_dict(index)
+assert sorted(index.keys()) == ["cmake", "objects", "reply"]
+check_objects(index["objects"])
diff --git a/Tests/RunCMake/FileAPI/cache-v2.cmake b/Tests/RunCMake/FileAPI/cache-v2.cmake
new file mode 100644
index 000000000..45b402de6
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cache-v2.cmake
@@ -0,0 +1,14 @@
+option(CM_OPTION_BOOL "Testing option()" "OFF")
+set(CM_SET_BOOL "ON" CACHE BOOL "Testing set(CACHE BOOL)")
+mark_as_advanced(CM_SET_BOOL)
+set(CM_SET_FILEPATH "dir1/dir2/empty.txt" CACHE FILEPATH "Testing set(CACHE FILEPATH)")
+set(CM_SET_PATH "dir1/dir2" CACHE PATH "Testing set(CACHE PATH)")
+set_property(CACHE CM_SET_PATH PROPERTY ADVANCED ON)
+set(CM_SET_STRING "test" CACHE STRING "Testing set(CACHE STRING)")
+set(CM_SET_STRINGS "1" CACHE STRING "Testing set(CACHE STRING) with STRINGS")
+set_property(CACHE CM_SET_STRINGS PROPERTY STRINGS "1;2;3;4")
+set(CM_SET_INTERNAL "int" CACHE INTERNAL "Testing set(CACHE INTERNAL)")
+set_property(CACHE CM_SET_INTERNAL PROPERTY VALUE "int2")
+set(CM_SET_TYPE "1" CACHE INTERNAL "Testing set(CACHE INTERNAL) with set_property(TYPE)")
+set_property(CACHE CM_SET_TYPE PROPERTY TYPE "STRING")
+set_property(CACHE CM_SET_TYPE PROPERTY ADVANCED "0")
diff --git a/Tests/RunCMake/FileAPI/check_index.py b/Tests/RunCMake/FileAPI/check_index.py
new file mode 100644
index 000000000..cda72341c
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/check_index.py
@@ -0,0 +1,163 @@
+import sys
+import os
+import json
+import re
+
+if sys.version_info[0] >= 3:
+ unicode = str
+
+def is_bool(x, val=None):
+ return isinstance(x, bool) and (val is None or x == val)
+
+def is_dict(x):
+ return isinstance(x, dict)
+
+def is_list(x):
+ return isinstance(x, list)
+
+def is_int(x, val=None):
+ return (isinstance(x, int) or isinstance(x, long)) and (val is None or x == val)
+
+def is_string(x, val=None):
+ return (isinstance(x, str) or isinstance(x, unicode)) and (val is None or x == val)
+
+def matches(s, pattern):
+ return is_string(s) and bool(re.search(pattern, s))
+
+def check_list_match(match, actual, expected, check=None, check_exception=None, missing_exception=None, extra_exception=None, allow_extra=False):
+ """
+ Handle the common pattern of making sure every actual item "matches" some
+ item in the expected list, and that neither list has extra items after
+ matching is completed.
+
+ @param match: Callback to check if an actual item matches an expected
+ item. Return True if the item matches, return False if the item doesn't
+ match.
+ @param actual: List of actual items to search.
+ @param expected: List of expected items to match.
+ @param check: Optional function to check that the actual item is valid by
+ comparing it to the expected item.
+ @param check_exception: Optional function that returns an argument to
+ append to any exception thrown by the check function.
+ @param missing_exception: Optional function that returns an argument to
+ append to the exception thrown when an item is not found.
+ @param extra_exception: Optional function that returns an argument to
+ append to the exception thrown when an extra item is found.
+ @param allow_extra: Optional parameter allowing there to be extra actual
+ items after all the expected items have been found.
+ """
+ assert is_list(actual)
+ _actual = actual[:]
+ for expected_item in expected:
+ found = False
+ for i, actual_item in enumerate(_actual):
+ if match(actual_item, expected_item):
+ if check:
+ try:
+ check(actual_item, expected_item)
+ except BaseException as e:
+ if check_exception:
+ e.args += (check_exception(actual_item, expected_item),)
+ raise
+ found = True
+ del _actual[i]
+ break
+ if missing_exception:
+ assert found, missing_exception(expected_item)
+ else:
+ assert found
+ if not allow_extra:
+ if extra_exception:
+ assert len(_actual) == 0, [extra_exception(a) for a in _actual]
+ else:
+ assert len(_actual) == 0
+
+def filter_list(f, l):
+ if l is not None:
+ l = list(filter(f, l))
+ if l == []:
+ l = None
+ return l
+
+def check_cmake(cmake):
+ assert is_dict(cmake)
+ assert sorted(cmake.keys()) == ["generator", "paths", "version"]
+ check_cmake_version(cmake["version"])
+ check_cmake_paths(cmake["paths"])
+ check_cmake_generator(cmake["generator"])
+
+def check_cmake_version(v):
+ assert is_dict(v)
+ assert sorted(v.keys()) == ["isDirty", "major", "minor", "patch", "string", "suffix"]
+ assert is_string(v["string"])
+ assert is_int(v["major"])
+ assert is_int(v["minor"])
+ assert is_int(v["patch"])
+ assert is_string(v["suffix"])
+ assert is_bool(v["isDirty"])
+
+def check_cmake_paths(v):
+ assert is_dict(v)
+ assert sorted(v.keys()) == ["cmake", "cpack", "ctest", "root"]
+ assert is_string(v["cmake"])
+ assert is_string(v["cpack"])
+ assert is_string(v["ctest"])
+ assert is_string(v["root"])
+
+def check_cmake_generator(g):
+ assert is_dict(g)
+ name = g.get("name", None)
+ assert is_string(name)
+ if name.startswith("Visual Studio"):
+ assert sorted(g.keys()) == ["name", "platform"]
+ assert is_string(g["platform"])
+ else:
+ assert sorted(g.keys()) == ["name"]
+
+def check_index_object(indexEntry, kind, major, minor, check):
+ assert is_dict(indexEntry)
+ assert sorted(indexEntry.keys()) == ["jsonFile", "kind", "version"]
+ assert is_string(indexEntry["kind"])
+ assert indexEntry["kind"] == kind
+ assert is_dict(indexEntry["version"])
+ assert sorted(indexEntry["version"].keys()) == ["major", "minor"]
+ assert indexEntry["version"]["major"] == major
+ assert indexEntry["version"]["minor"] == minor
+ assert is_string(indexEntry["jsonFile"])
+ filepath = os.path.join(reply_dir, indexEntry["jsonFile"])
+ with open(filepath) as f:
+ object = json.load(f)
+ assert is_dict(object)
+ assert "kind" in object
+ assert is_string(object["kind"])
+ assert object["kind"] == kind
+ assert "version" in object
+ assert is_dict(object["version"])
+ assert sorted(object["version"].keys()) == ["major", "minor"]
+ assert object["version"]["major"] == major
+ assert object["version"]["minor"] == minor
+ if check:
+ check(object)
+
+def check_index__test(indexEntry, major, minor):
+ def check(object):
+ assert sorted(object.keys()) == ["kind", "version"]
+ check_index_object(indexEntry, "__test", major, minor, check)
+
+def check_error(value, error):
+ assert is_dict(value)
+ assert sorted(value.keys()) == ["error"]
+ assert is_string(value["error"])
+ assert value["error"] == error
+
+def check_error_re(value, error):
+ assert is_dict(value)
+ assert sorted(value.keys()) == ["error"]
+ assert is_string(value["error"])
+ assert re.search(error, value["error"])
+
+reply_index = sys.argv[1]
+reply_dir = os.path.dirname(reply_index)
+
+with open(reply_index) as f:
+ index = json.load(f)
diff --git a/Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateful-check.cmake b/Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateful-check.cmake
new file mode 100644
index 000000000..21e931e7b
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateful-check.cmake
@@ -0,0 +1,11 @@
+set(expect
+ query
+ query/client-foo
+ query/client-foo/query.json
+ reply
+ reply/cmakeFiles-v1-[0-9a-f]+.json
+ reply/index-[0-9.T-]+.json
+ )
+check_api("^${expect}$")
+
+check_python(cmakeFiles-v1)
diff --git a/Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateful-prep.cmake b/Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateful-prep.cmake
new file mode 100644
index 000000000..7a726963e
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateful-prep.cmake
@@ -0,0 +1,4 @@
+file(REMOVE_RECURSE ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query)
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/query.json" [[
+{ "requests": [ { "kind": "cmakeFiles", "version" : 1 } ] }
+]])
diff --git a/Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateless-check.cmake b/Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateless-check.cmake
new file mode 100644
index 000000000..2ce2e79e4
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateless-check.cmake
@@ -0,0 +1,11 @@
+set(expect
+ query
+ query/client-foo
+ query/client-foo/cmakeFiles-v1
+ reply
+ reply/cmakeFiles-v1-[0-9a-f]+.json
+ reply/index-[0-9.T-]+.json
+ )
+check_api("^${expect}$")
+
+check_python(cmakeFiles-v1)
diff --git a/Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateless-prep.cmake b/Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateless-prep.cmake
new file mode 100644
index 000000000..eb9649175
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cmakeFiles-v1-ClientStateless-prep.cmake
@@ -0,0 +1,2 @@
+file(REMOVE_RECURSE ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query)
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/cmakeFiles-v1" "")
diff --git a/Tests/RunCMake/FileAPI/cmakeFiles-v1-SharedStateless-check.cmake b/Tests/RunCMake/FileAPI/cmakeFiles-v1-SharedStateless-check.cmake
new file mode 100644
index 000000000..6e3b49a5c
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cmakeFiles-v1-SharedStateless-check.cmake
@@ -0,0 +1,10 @@
+set(expect
+ query
+ query/cmakeFiles-v1
+ reply
+ reply/cmakeFiles-v1-[0-9a-f]+.json
+ reply/index-[0-9.T-]+.json
+ )
+check_api("^${expect}$")
+
+check_python(cmakeFiles-v1)
diff --git a/Tests/RunCMake/FileAPI/cmakeFiles-v1-SharedStateless-prep.cmake b/Tests/RunCMake/FileAPI/cmakeFiles-v1-SharedStateless-prep.cmake
new file mode 100644
index 000000000..8c8bdef1c
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cmakeFiles-v1-SharedStateless-prep.cmake
@@ -0,0 +1,2 @@
+file(REMOVE_RECURSE ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query)
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/cmakeFiles-v1" "")
diff --git a/Tests/RunCMake/FileAPI/cmakeFiles-v1-check.py b/Tests/RunCMake/FileAPI/cmakeFiles-v1-check.py
new file mode 100644
index 000000000..49dfe87ab
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cmakeFiles-v1-check.py
@@ -0,0 +1,94 @@
+from check_index import *
+
+def check_objects(o):
+ assert is_list(o)
+ assert len(o) == 1
+ check_index_object(o[0], "cmakeFiles", 1, 0, check_object_cmakeFiles)
+
+def check_input(actual, expected):
+ assert is_dict(actual)
+ expected_keys = ["path"]
+
+ if expected["isGenerated"] is not None:
+ expected_keys.append("isGenerated")
+ assert is_bool(actual["isGenerated"], expected["isGenerated"])
+
+ if expected["isExternal"] is not None:
+ expected_keys.append("isExternal")
+ assert is_bool(actual["isExternal"], expected["isExternal"])
+
+ if expected["isCMake"] is not None:
+ expected_keys.append("isCMake")
+ assert is_bool(actual["isCMake"], expected["isCMake"])
+
+ assert sorted(actual.keys()) == sorted(expected_keys)
+
+def check_object_cmakeFiles(o):
+ assert sorted(o.keys()) == ["inputs", "kind", "paths", "version"]
+ # The "kind" and "version" members are handled by check_index_object.
+ assert is_dict(o["paths"])
+ assert sorted(o["paths"].keys()) == ["build", "source"]
+ assert matches(o["paths"]["build"], "^.*/Tests/RunCMake/FileAPI/cmakeFiles-v1-build$")
+ assert matches(o["paths"]["source"], "^.*/Tests/RunCMake/FileAPI$")
+
+ expected = [
+ {
+ "path": "^CMakeLists\\.txt$",
+ "isGenerated": None,
+ "isExternal": None,
+ "isCMake": None,
+ },
+ {
+ "path": "^cmakeFiles-v1\\.cmake$",
+ "isGenerated": None,
+ "isExternal": None,
+ "isCMake": None,
+ },
+ {
+ "path": "^dir/CMakeLists\\.txt$",
+ "isGenerated": None,
+ "isExternal": None,
+ "isCMake": None,
+ },
+ {
+ "path": "^dir/dir/CMakeLists\\.txt$",
+ "isGenerated": None,
+ "isExternal": None,
+ "isCMake": None,
+ },
+ {
+ "path": "^dir/dirtest\\.cmake$",
+ "isGenerated": None,
+ "isExternal": None,
+ "isCMake": None,
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPIDummyFile\\.cmake$",
+ "isGenerated": None,
+ "isExternal": True,
+ "isCMake": None,
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/cmakeFiles-v1-build/generated\\.cmake",
+ "isGenerated": True,
+ "isExternal": None,
+ "isCMake": None,
+ },
+ {
+ "path": "^.*/Modules/CMakeParseArguments\\.cmake$",
+ "isGenerated": None,
+ "isExternal": True,
+ "isCMake": True,
+ },
+ ]
+
+ inSource = os.path.dirname(o["paths"]["build"]) == o["paths"]["source"]
+ if inSource:
+ for e in expected:
+ e["path"] = e["path"].replace("^.*/Tests/RunCMake/FileAPI/", "^", 1)
+
+ check_list_match(lambda a, e: matches(a["path"], e["path"]), o["inputs"], expected, check=check_input, allow_extra=True)
+
+assert is_dict(index)
+assert sorted(index.keys()) == ["cmake", "objects", "reply"]
+check_objects(index["objects"])
diff --git a/Tests/RunCMake/FileAPI/cmakeFiles-v1.cmake b/Tests/RunCMake/FileAPI/cmakeFiles-v1.cmake
new file mode 100644
index 000000000..4d4d757c7
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cmakeFiles-v1.cmake
@@ -0,0 +1,8 @@
+include("${CMAKE_CURRENT_LIST_DIR}/dir/dirtest.cmake")
+include(CMakeParseArguments)
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/generated.cmake" "")
+include("${CMAKE_CURRENT_BINARY_DIR}/generated.cmake")
+include("${CMAKE_CURRENT_LIST_DIR}/../FileAPIDummyFile.cmake")
+
+add_subdirectory(dir)
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-check.cmake b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-check.cmake
new file mode 100644
index 000000000..fb78e8789
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-check.cmake
@@ -0,0 +1,12 @@
+set(expect
+ query
+ query/client-foo
+ query/client-foo/query.json
+ reply
+ reply/codemodel-v2-[0-9a-f]+\\.json
+ reply/index-[0-9.T-]+\\.json
+ .*
+ )
+check_api("^${expect}$")
+
+check_python(codemodel-v2)
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-prep.cmake b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-prep.cmake
new file mode 100644
index 000000000..e2b38ff57
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-prep.cmake
@@ -0,0 +1,4 @@
+file(REMOVE_RECURSE ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query)
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/query.json" [[
+{ "requests": [ { "kind": "codemodel", "version" : 2 } ] }
+]])
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-check.cmake b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-check.cmake
new file mode 100644
index 000000000..7c6a35ab5
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-check.cmake
@@ -0,0 +1,12 @@
+set(expect
+ query
+ query/client-foo
+ query/client-foo/codemodel-v2
+ reply
+ reply/codemodel-v2-[0-9a-f]+\\.json
+ reply/index-[0-9.T-]+\\.json
+ .*
+ )
+check_api("^${expect}$")
+
+check_python(codemodel-v2)
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-prep.cmake b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-prep.cmake
new file mode 100644
index 000000000..d1ce2929e
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-prep.cmake
@@ -0,0 +1,2 @@
+file(REMOVE_RECURSE ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query)
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/client-foo/codemodel-v2" "")
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-check.cmake b/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-check.cmake
new file mode 100644
index 000000000..cc2f31b94
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-check.cmake
@@ -0,0 +1,11 @@
+set(expect
+ query
+ query/codemodel-v2
+ reply
+ reply/codemodel-v2-[0-9a-f]+\\.json
+ reply/index-[0-9.T-]+\\.json
+ .*
+ )
+check_api("^${expect}$")
+
+check_python(codemodel-v2)
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-prep.cmake b/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-prep.cmake
new file mode 100644
index 000000000..8a519d5cb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-prep.cmake
@@ -0,0 +1,2 @@
+file(REMOVE_RECURSE ${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query)
+file(WRITE "${RunCMake_TEST_BINARY_DIR}/.cmake/api/v1/query/codemodel-v2" "")
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py
new file mode 100644
index 000000000..66c559d7f
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py
@@ -0,0 +1,5342 @@
+from check_index import *
+
+import sys
+import os
+
+def check_objects(o, g):
+ assert is_list(o)
+ assert len(o) == 1
+ check_index_object(o[0], "codemodel", 2, 0, check_object_codemodel(g))
+
+def check_backtrace(t, b, backtrace):
+ btg = t["backtraceGraph"]
+ for expected in backtrace:
+ assert is_int(b)
+ node = btg["nodes"][b]
+ expected_keys = ["file"]
+ assert matches(btg["files"][node["file"]], expected["file"])
+
+ if expected["line"] is not None:
+ expected_keys.append("line")
+ assert is_int(node["line"], expected["line"])
+
+ if expected["command"] is not None:
+ expected_keys.append("command")
+ assert is_int(node["command"])
+ assert is_string(btg["commands"][node["command"]], expected["command"])
+
+ if expected["hasParent"]:
+ expected_keys.append("parent")
+ assert is_int(node["parent"])
+ b = node["parent"]
+ else:
+ b = None
+
+ assert sorted(node.keys()) == sorted(expected_keys)
+
+ assert b is None
+
+def check_directory(c):
+ def _check(actual, expected):
+ assert is_dict(actual)
+ expected_keys = ["build", "source", "projectIndex"]
+ assert matches(actual["build"], expected["build"])
+
+ assert is_int(actual["projectIndex"])
+ assert is_string(c["projects"][actual["projectIndex"]]["name"], expected["projectName"])
+
+ if expected["parentSource"] is not None:
+ expected_keys.append("parentIndex")
+ assert is_int(actual["parentIndex"])
+ assert matches(c["directories"][actual["parentIndex"]]["source"], expected["parentSource"])
+
+ if expected["childSources"] is not None:
+ expected_keys.append("childIndexes")
+ check_list_match(lambda a, e: matches(c["directories"][a]["source"], e),
+ actual["childIndexes"], expected["childSources"],
+ missing_exception=lambda e: "Child source: %s" % e,
+ extra_exception=lambda a: "Child source: %s" % a["source"])
+
+ if expected["targetIds"] is not None:
+ expected_keys.append("targetIndexes")
+ check_list_match(lambda a, e: matches(c["targets"][a]["id"], e),
+ actual["targetIndexes"], expected["targetIds"],
+ missing_exception=lambda e: "Target ID: %s" % e,
+ extra_exception=lambda a: "Target ID: %s" % c["targets"][a]["id"])
+
+ if expected["minimumCMakeVersion"] is not None:
+ expected_keys.append("minimumCMakeVersion")
+ assert is_dict(actual["minimumCMakeVersion"])
+ assert sorted(actual["minimumCMakeVersion"].keys()) == ["string"]
+ assert is_string(actual["minimumCMakeVersion"]["string"], expected["minimumCMakeVersion"])
+
+ if expected["hasInstallRule"] is not None:
+ expected_keys.append("hasInstallRule")
+ assert is_bool(actual["hasInstallRule"], expected["hasInstallRule"])
+
+ assert sorted(actual.keys()) == sorted(expected_keys)
+
+ return _check
+
+def check_target_backtrace_graph(t):
+ btg = t["backtraceGraph"]
+ assert is_dict(btg)
+ assert sorted(btg.keys()) == ["commands", "files", "nodes"]
+ assert is_list(btg["commands"])
+
+ for c in btg["commands"]:
+ assert is_string(c)
+
+ for f in btg["files"]:
+ assert is_string(f)
+
+ for n in btg["nodes"]:
+ expected_keys = ["file"]
+ assert is_dict(n)
+ assert is_int(n["file"])
+ assert 0 <= n["file"] < len(btg["files"])
+
+ if "line" in n:
+ expected_keys.append("line")
+ assert is_int(n["line"])
+
+ if "command" in n:
+ expected_keys.append("command")
+ assert is_int(n["command"])
+ assert 0 <= n["command"] < len(btg["commands"])
+
+ if "parent" in n:
+ expected_keys.append("parent")
+ assert is_int(n["parent"])
+ assert 0 <= n["parent"] < len(btg["nodes"])
+
+ assert sorted(n.keys()) == sorted(expected_keys)
+
+def check_target(c):
+ def _check(actual, expected):
+ assert is_dict(actual)
+ assert sorted(actual.keys()) == ["directoryIndex", "id", "jsonFile", "name", "projectIndex"]
+ assert is_int(actual["directoryIndex"])
+ assert matches(c["directories"][actual["directoryIndex"]]["source"], expected["directorySource"])
+ assert is_string(actual["name"], expected["name"])
+ assert is_string(actual["jsonFile"])
+ assert is_int(actual["projectIndex"])
+ assert is_string(c["projects"][actual["projectIndex"]]["name"], expected["projectName"])
+
+ filepath = os.path.join(reply_dir, actual["jsonFile"])
+ with open(filepath) as f:
+ obj = json.load(f)
+
+ expected_keys = ["name", "id", "type", "backtraceGraph", "paths", "sources"]
+ assert is_dict(obj)
+ assert is_string(obj["name"], expected["name"])
+ assert matches(obj["id"], expected["id"])
+ assert is_string(obj["type"], expected["type"])
+ check_target_backtrace_graph(obj)
+
+ assert is_dict(obj["paths"])
+ assert sorted(obj["paths"].keys()) == ["build", "source"]
+ assert matches(obj["paths"]["build"], expected["build"])
+ assert matches(obj["paths"]["source"], expected["source"])
+
+ def check_source(actual, expected):
+ assert is_dict(actual)
+ expected_keys = ["path"]
+
+ if expected["compileGroupLanguage"] is not None:
+ expected_keys.append("compileGroupIndex")
+ assert is_string(obj["compileGroups"][actual["compileGroupIndex"]]["language"], expected["compileGroupLanguage"])
+
+ if expected["sourceGroupName"] is not None:
+ expected_keys.append("sourceGroupIndex")
+ assert is_string(obj["sourceGroups"][actual["sourceGroupIndex"]]["name"], expected["sourceGroupName"])
+
+ if expected["isGenerated"] is not None:
+ expected_keys.append("isGenerated")
+ assert is_bool(actual["isGenerated"], expected["isGenerated"])
+
+ if expected["backtrace"] is not None:
+ expected_keys.append("backtrace")
+ check_backtrace(obj, actual["backtrace"], expected["backtrace"])
+
+ assert sorted(actual.keys()) == sorted(expected_keys)
+
+ check_list_match(lambda a, e: matches(a["path"], e["path"]), obj["sources"],
+ expected["sources"], check=check_source,
+ check_exception=lambda a, e: "Source file: %s" % a["path"],
+ missing_exception=lambda e: "Source file: %s" % e["path"],
+ extra_exception=lambda a: "Source file: %s" % a["path"])
+
+ if expected["backtrace"] is not None:
+ expected_keys.append("backtrace")
+ check_backtrace(obj, obj["backtrace"], expected["backtrace"])
+
+ if expected["folder"] is not None:
+ expected_keys.append("folder")
+ assert is_dict(obj["folder"])
+ assert sorted(obj["folder"].keys()) == ["name"]
+ assert is_string(obj["folder"]["name"], expected["folder"])
+
+ if expected["nameOnDisk"] is not None:
+ expected_keys.append("nameOnDisk")
+ assert matches(obj["nameOnDisk"], expected["nameOnDisk"])
+
+ if expected["artifacts"] is not None:
+ expected_keys.append("artifacts")
+
+ def check_artifact(actual, expected):
+ assert is_dict(actual)
+ assert sorted(actual.keys()) == ["path"]
+
+ check_list_match(lambda a, e: matches(a["path"], e["path"]),
+ obj["artifacts"], expected["artifacts"],
+ check=check_artifact,
+ check_exception=lambda a, e: "Artifact: %s" % a["path"],
+ missing_exception=lambda e: "Artifact: %s" % e["path"],
+ extra_exception=lambda a: "Artifact: %s" % a["path"])
+
+ if expected["isGeneratorProvided"] is not None:
+ expected_keys.append("isGeneratorProvided")
+ assert is_bool(obj["isGeneratorProvided"], expected["isGeneratorProvided"])
+
+ if expected["install"] is not None:
+ expected_keys.append("install")
+ assert is_dict(obj["install"])
+ assert sorted(obj["install"].keys()) == ["destinations", "prefix"]
+
+ assert is_dict(obj["install"]["prefix"])
+ assert sorted(obj["install"]["prefix"].keys()) == ["path"]
+ assert matches(obj["install"]["prefix"]["path"], expected["install"]["prefix"])
+
+ def check_install_destination(actual, expected):
+ assert is_dict(actual)
+ expected_keys = ["path"]
+
+ if expected["backtrace"] is not None:
+ expected_keys.append("backtrace")
+ check_backtrace(obj, actual["backtrace"], expected["backtrace"])
+
+ assert sorted(actual.keys()) == sorted(expected_keys)
+
+ check_list_match(lambda a, e: matches(a["path"], e["path"]),
+ obj["install"]["destinations"], expected["install"]["destinations"],
+ check=check_install_destination,
+ check_exception=lambda a, e: "Install path: %s" % a["path"],
+ missing_exception=lambda e: "Install path: %s" % e["path"],
+ extra_exception=lambda a: "Install path: %s" % a["path"])
+
+ if expected["link"] is not None:
+ expected_keys.append("link")
+ assert is_dict(obj["link"])
+ link_keys = ["language"]
+
+ assert is_string(obj["link"]["language"], expected["link"]["language"])
+
+ if "commandFragments" in obj["link"]:
+ link_keys.append("commandFragments")
+ assert is_list(obj["link"]["commandFragments"])
+ for f in obj["link"]["commandFragments"]:
+ assert is_dict(f)
+ assert sorted(f.keys()) == ["fragment", "role"] or sorted(f.keys()) == ["backtrace", "fragment", "role"]
+ assert is_string(f["fragment"])
+ assert is_string(f["role"])
+ assert f["role"] in ("flags", "libraries", "libraryPath", "frameworkPath")
+
+ if expected["link"]["commandFragments"] is not None:
+ def check_link_command_fragments(actual, expected):
+ assert is_dict(actual)
+ expected_keys = ["fragment", "role"]
+
+ if expected["backtrace"] is not None:
+ expected_keys.append("backtrace")
+ assert matches(actual["fragment"], expected["fragment"])
+ assert actual["role"] == expected["role"]
+ check_backtrace(obj, actual["backtrace"], expected["backtrace"])
+
+ assert sorted(actual.keys()) == sorted(expected_keys)
+
+ check_list_match(lambda a, e: matches(a["fragment"], e["fragment"]),
+ obj["link"]["commandFragments"], expected["link"]["commandFragments"],
+ check=check_link_command_fragments,
+ check_exception=lambda a, e: "Link fragment: %s" % a["fragment"],
+ missing_exception=lambda e: "Link fragment: %s" % e["fragment"],
+ extra_exception=lambda a: "Link fragment: %s" % a["fragment"],
+ allow_extra=True)
+
+ if expected["link"]["lto"] is not None:
+ link_keys.append("lto")
+ assert is_bool(obj["link"]["lto"], expected["link"]["lto"])
+
+ # FIXME: Properly test sysroot
+ if "sysroot" in obj["link"]:
+ link_keys.append("sysroot")
+ assert is_string(obj["link"]["sysroot"])
+
+ assert sorted(obj["link"].keys()) == sorted(link_keys)
+
+ if expected["archive"] is not None:
+ expected_keys.append("archive")
+ assert is_dict(obj["archive"])
+ archive_keys = []
+
+ # FIXME: Properly test commandFragments
+ if "commandFragments" in obj["archive"]:
+ archive_keys.append("commandFragments")
+ assert is_list(obj["archive"]["commandFragments"])
+ for f in obj["archive"]["commandFragments"]:
+ assert is_dict(f)
+ assert sorted(f.keys()) == ["fragment", "role"]
+ assert is_string(f["fragment"])
+ assert is_string(f["role"])
+ assert f["role"] in ("flags")
+
+ if expected["archive"]["lto"] is not None:
+ archive_keys.append("lto")
+ assert is_bool(obj["archive"]["lto"], expected["archive"]["lto"])
+
+ assert sorted(obj["archive"].keys()) == sorted(archive_keys)
+
+ if expected["dependencies"] is not None:
+ expected_keys.append("dependencies")
+
+ def check_dependency(actual, expected):
+ assert is_dict(actual)
+ expected_keys = ["id"]
+
+ if expected["backtrace"] is not None:
+ expected_keys.append("backtrace")
+ check_backtrace(obj, actual["backtrace"], expected["backtrace"])
+
+ assert sorted(actual.keys()) == sorted(expected_keys)
+
+ check_list_match(lambda a, e: matches(a["id"], e["id"]),
+ obj["dependencies"], expected["dependencies"],
+ check=check_dependency,
+ check_exception=lambda a, e: "Dependency ID: %s" % a["id"],
+ missing_exception=lambda e: "Dependency ID: %s" % e["id"],
+ extra_exception=lambda a: "Dependency ID: %s" % a["id"])
+
+ if expected["sourceGroups"] is not None:
+ expected_keys.append("sourceGroups")
+
+ def check_source_group(actual, expected):
+ assert is_dict(actual)
+ assert sorted(actual.keys()) == ["name", "sourceIndexes"]
+
+ check_list_match(lambda a, e: matches(obj["sources"][a]["path"], e),
+ actual["sourceIndexes"], expected["sourcePaths"],
+ missing_exception=lambda e: "Source path: %s" % e,
+ extra_exception=lambda a: "Source path: %s" % obj["sources"][a]["path"])
+
+ check_list_match(lambda a, e: is_string(a["name"], e["name"]),
+ obj["sourceGroups"], expected["sourceGroups"],
+ check=check_source_group,
+ check_exception=lambda a, e: "Source group: %s" % a["name"],
+ missing_exception=lambda e: "Source group: %s" % e["name"],
+ extra_exception=lambda a: "Source group: %s" % a["name"])
+
+ if expected["compileGroups"] is not None:
+ expected_keys.append("compileGroups")
+
+ def check_compile_group(actual, expected):
+ assert is_dict(actual)
+ expected_keys = ["sourceIndexes", "language"]
+
+ check_list_match(lambda a, e: matches(obj["sources"][a]["path"], e),
+ actual["sourceIndexes"], expected["sourcePaths"],
+ missing_exception=lambda e: "Source path: %s" % e,
+ extra_exception=lambda a: "Source path: %s" % obj["sources"][a]["path"])
+
+ if "compileCommandFragments" in actual:
+ expected_keys.append("compileCommandFragments")
+ assert is_list(actual["compileCommandFragments"])
+ for f in actual["compileCommandFragments"]:
+ assert is_dict(f)
+ assert is_string(f["fragment"])
+
+ if expected["compileCommandFragments"] is not None:
+ def check_compile_command_fragments(actual, expected):
+ assert is_dict(actual)
+ expected_keys = ["fragment"]
+
+ if expected["backtrace"] is not None:
+ expected_keys.append("backtrace")
+ assert actual["fragment"] == expected["fragment"]
+ check_backtrace(obj, actual["backtrace"], expected["backtrace"])
+
+ assert sorted(actual.keys()) == sorted(expected_keys)
+
+ check_list_match(lambda a, e: is_string(a["fragment"], e["fragment"]),
+ actual["compileCommandFragments"], expected["compileCommandFragments"],
+ check=check_compile_command_fragments,
+ check_exception=lambda a, e: "Compile fragment: %s" % a["fragment"],
+ missing_exception=lambda e: "Compile fragment: %s" % e["fragment"],
+ extra_exception=lambda a: "Compile fragment: %s" % a["fragment"],
+ allow_extra=True)
+
+ if expected["includes"] is not None:
+ expected_keys.append("includes")
+
+ def check_include(actual, expected):
+ assert is_dict(actual)
+ expected_keys = ["path"]
+
+ if expected["isSystem"] is not None:
+ expected_keys.append("isSystem")
+ assert is_bool(actual["isSystem"], expected["isSystem"])
+
+ if expected["backtrace"] is not None:
+ expected_keys.append("backtrace")
+ check_backtrace(obj, actual["backtrace"], expected["backtrace"])
+
+ assert sorted(actual.keys()) == sorted(expected_keys)
+
+ check_list_match(lambda a, e: matches(a["path"], e["path"]),
+ actual["includes"], expected["includes"],
+ check=check_include,
+ check_exception=lambda a, e: "Include path: %s" % a["path"],
+ missing_exception=lambda e: "Include path: %s" % e["path"],
+ extra_exception=lambda a: "Include path: %s" % a["path"])
+
+ if expected["defines"] is not None:
+ expected_keys.append("defines")
+
+ def check_define(actual, expected):
+ assert is_dict(actual)
+ expected_keys = ["define"]
+
+ if expected["backtrace"] is not None:
+ expected_keys.append("backtrace")
+ check_backtrace(obj, actual["backtrace"], expected["backtrace"])
+
+ assert sorted(actual.keys()) == sorted(expected_keys)
+
+ check_list_match(lambda a, e: is_string(a["define"], e["define"]),
+ actual["defines"], expected["defines"],
+ check=check_define,
+ check_exception=lambda a, e: "Define: %s" % a["define"],
+ missing_exception=lambda e: "Define: %s" % e["define"],
+ extra_exception=lambda a: "Define: %s" % a["define"])
+
+ # FIXME: Properly test sysroot
+ if "sysroot" in actual:
+ expected_keys.append("sysroot")
+ assert is_string(actual["sysroot"])
+
+ assert sorted(actual.keys()) == sorted(expected_keys)
+
+ check_list_match(lambda a, e: is_string(a["language"], e["language"]),
+ obj["compileGroups"], expected["compileGroups"],
+ check=check_compile_group,
+ check_exception=lambda a, e: "Compile group: %s" % a["language"],
+ missing_exception=lambda e: "Compile group: %s" % e["language"],
+ extra_exception=lambda a: "Compile group: %s" % a["language"])
+
+ assert sorted(obj.keys()) == sorted(expected_keys)
+
+ return _check
+
+def check_project(c):
+ def _check(actual, expected):
+ assert is_dict(actual)
+ expected_keys = ["name", "directoryIndexes"]
+
+ check_list_match(lambda a, e: matches(c["directories"][a]["source"], e),
+ actual["directoryIndexes"], expected["directorySources"],
+ missing_exception=lambda e: "Directory source: %s" % e,
+ extra_exception=lambda a: "Directory source: %s" % c["directories"][a]["source"])
+
+ if expected["parentName"] is not None:
+ expected_keys.append("parentIndex")
+ assert is_int(actual["parentIndex"])
+ assert is_string(c["projects"][actual["parentIndex"]]["name"], expected["parentName"])
+
+ if expected["childNames"] is not None:
+ expected_keys.append("childIndexes")
+ check_list_match(lambda a, e: is_string(c["projects"][a]["name"], e),
+ actual["childIndexes"], expected["childNames"],
+ missing_exception=lambda e: "Child name: %s" % e,
+ extra_exception=lambda a: "Child name: %s" % c["projects"][a]["name"])
+
+ if expected["targetIds"] is not None:
+ expected_keys.append("targetIndexes")
+ check_list_match(lambda a, e: matches(c["targets"][a]["id"], e),
+ actual["targetIndexes"], expected["targetIds"],
+ missing_exception=lambda e: "Target ID: %s" % e,
+ extra_exception=lambda a: "Target ID: %s" % c["targets"][a]["id"])
+
+ assert sorted(actual.keys()) == sorted(expected_keys)
+
+ return _check
+
+def gen_check_directories(c, g):
+ expected = [
+ {
+ "source": "^\\.$",
+ "build": "^\\.$",
+ "parentSource": None,
+ "childSources": [
+ "^alias$",
+ "^custom$",
+ "^cxx$",
+ "^imported$",
+ "^object$",
+ "^.*/Tests/RunCMake/FileAPIExternalSource$",
+ "^dir$",
+ ],
+ "targetIds": [
+ "^ALL_BUILD::@6890427a1f51a3e7e1df$",
+ "^ZERO_CHECK::@6890427a1f51a3e7e1df$",
+ "^c_exe::@6890427a1f51a3e7e1df$",
+ "^c_lib::@6890427a1f51a3e7e1df$",
+ "^c_shared_exe::@6890427a1f51a3e7e1df$",
+ "^c_shared_lib::@6890427a1f51a3e7e1df$",
+ "^c_static_exe::@6890427a1f51a3e7e1df$",
+ "^c_static_lib::@6890427a1f51a3e7e1df$",
+ "^interface_exe::@6890427a1f51a3e7e1df$",
+ ],
+ "projectName": "codemodel-v2",
+ "minimumCMakeVersion": "3.12",
+ "hasInstallRule": True,
+ },
+ {
+ "source": "^alias$",
+ "build": "^alias$",
+ "parentSource": "^\\.$",
+ "childSources": None,
+ "targetIds": [
+ "^ALL_BUILD::@53632cba2752272bb008$",
+ "^ZERO_CHECK::@53632cba2752272bb008$",
+ "^c_alias_exe::@53632cba2752272bb008$",
+ "^cxx_alias_exe::@53632cba2752272bb008$",
+ ],
+ "projectName": "Alias",
+ "minimumCMakeVersion": "3.12",
+ "hasInstallRule": None,
+ },
+ {
+ "source": "^custom$",
+ "build": "^custom$",
+ "parentSource": "^\\.$",
+ "childSources": None,
+ "targetIds": [
+ "^ALL_BUILD::@c11385ffed57b860da63$",
+ "^ZERO_CHECK::@c11385ffed57b860da63$",
+ "^custom_exe::@c11385ffed57b860da63$",
+ "^custom_tgt::@c11385ffed57b860da63$",
+ ],
+ "projectName": "Custom",
+ "minimumCMakeVersion": "3.12",
+ "hasInstallRule": None,
+ },
+ {
+ "source": "^cxx$",
+ "build": "^cxx$",
+ "parentSource": "^\\.$",
+ "childSources": None,
+ "targetIds": [
+ "^ALL_BUILD::@a56b12a3f5c0529fb296$",
+ "^ZERO_CHECK::@a56b12a3f5c0529fb296$",
+ "^cxx_exe::@a56b12a3f5c0529fb296$",
+ "^cxx_lib::@a56b12a3f5c0529fb296$",
+ "^cxx_shared_exe::@a56b12a3f5c0529fb296$",
+ "^cxx_shared_lib::@a56b12a3f5c0529fb296$",
+ "^cxx_static_exe::@a56b12a3f5c0529fb296$",
+ "^cxx_static_lib::@a56b12a3f5c0529fb296$",
+ ],
+ "projectName": "Cxx",
+ "minimumCMakeVersion": "3.12",
+ "hasInstallRule": None,
+ },
+ {
+ "source": "^imported$",
+ "build": "^imported$",
+ "parentSource": "^\\.$",
+ "childSources": None,
+ "targetIds": [
+ "^ALL_BUILD::@ba7eb709d0b48779c6c8$",
+ "^ZERO_CHECK::@ba7eb709d0b48779c6c8$",
+ "^link_imported_exe::@ba7eb709d0b48779c6c8$",
+ "^link_imported_interface_exe::@ba7eb709d0b48779c6c8$",
+ "^link_imported_object_exe::@ba7eb709d0b48779c6c8$",
+ "^link_imported_shared_exe::@ba7eb709d0b48779c6c8$",
+ "^link_imported_static_exe::@ba7eb709d0b48779c6c8$",
+ ],
+ "projectName": "Imported",
+ "minimumCMakeVersion": "3.12",
+ "hasInstallRule": None,
+ },
+ {
+ "source": "^object$",
+ "build": "^object$",
+ "parentSource": "^\\.$",
+ "childSources": None,
+ "targetIds": [
+ "^ALL_BUILD::@5ed5358f70faf8d8af7a$",
+ "^ZERO_CHECK::@5ed5358f70faf8d8af7a$",
+ "^c_object_exe::@5ed5358f70faf8d8af7a$",
+ "^c_object_lib::@5ed5358f70faf8d8af7a$",
+ "^cxx_object_exe::@5ed5358f70faf8d8af7a$",
+ "^cxx_object_lib::@5ed5358f70faf8d8af7a$",
+ ],
+ "projectName": "Object",
+ "minimumCMakeVersion": "3.13",
+ "hasInstallRule": True,
+ },
+ {
+ "source": "^dir$",
+ "build": "^dir$",
+ "parentSource": "^\\.$",
+ "childSources": [
+ "^dir/dir$",
+ ],
+ "targetIds": None,
+ "projectName": "codemodel-v2",
+ "minimumCMakeVersion": "3.12",
+ "hasInstallRule": None,
+ },
+ {
+ "source": "^dir/dir$",
+ "build": "^dir/dir$",
+ "parentSource": "^dir$",
+ "childSources": None,
+ "targetIds": None,
+ "projectName": "codemodel-v2",
+ "minimumCMakeVersion": "3.12",
+ "hasInstallRule": None,
+ },
+ {
+ "source": "^.*/Tests/RunCMake/FileAPIExternalSource$",
+ "build": "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild$",
+ "parentSource": "^\\.$",
+ "childSources": None,
+ "targetIds": [
+ "^ALL_BUILD::@[0-9a-f]+$",
+ "^ZERO_CHECK::@[0-9a-f]+$",
+ "^generated_exe::@[0-9a-f]+$",
+ ],
+ "projectName": "External",
+ "minimumCMakeVersion": "3.12",
+ "hasInstallRule": None,
+ },
+ ]
+
+ if matches(g, "^Visual Studio "):
+ for e in expected:
+ if e["parentSource"] is not None:
+ e["targetIds"] = filter_list(lambda t: not matches(t, "^\\^ZERO_CHECK"), e["targetIds"])
+
+ elif g == "Xcode":
+ if ';' in os.environ.get("CMAKE_OSX_ARCHITECTURES", ""):
+ for e in expected:
+ e["targetIds"] = filter_list(lambda t: not matches(t, "^\\^(link_imported_object_exe)"), e["targetIds"])
+
+ else:
+ for e in expected:
+ e["targetIds"] = filter_list(lambda t: not matches(t, "^\\^(ALL_BUILD|ZERO_CHECK)"), e["targetIds"])
+
+ return expected
+
+def check_directories(c, g):
+ check_list_match(lambda a, e: matches(a["source"], e["source"]), c["directories"], gen_check_directories(c, g),
+ check=check_directory(c),
+ check_exception=lambda a, e: "Directory source: %s" % a["source"],
+ missing_exception=lambda e: "Directory source: %s" % e["source"],
+ extra_exception=lambda a: "Directory source: %s" % a["source"])
+
+def gen_check_targets(c, g, inSource):
+ expected = [
+ {
+ "name": "ALL_BUILD",
+ "id": "^ALL_BUILD::@6890427a1f51a3e7e1df$",
+ "directorySource": "^\\.$",
+ "projectName": "codemodel-v2",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/CMakeFiles/ALL_BUILD$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/CMakeFiles/ALL_BUILD\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/CMakeFiles/ALL_BUILD$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/CMakeFiles/ALL_BUILD\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^\\.$",
+ "source": "^\\.$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ {
+ "id": "^interface_exe::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ {
+ "id": "^c_lib::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ {
+ "id": "^c_exe::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ {
+ "id": "^c_shared_lib::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ {
+ "id": "^c_shared_exe::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ {
+ "id": "^c_static_lib::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ {
+ "id": "^c_static_exe::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ {
+ "id": "^c_alias_exe::@53632cba2752272bb008$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_alias_exe::@53632cba2752272bb008$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_lib::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_exe::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_shared_lib::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_shared_exe::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_static_lib::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_static_exe::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ {
+ "id": "^c_object_lib::@5ed5358f70faf8d8af7a$",
+ "backtrace": None,
+ },
+ {
+ "id": "^c_object_exe::@5ed5358f70faf8d8af7a$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_object_lib::@5ed5358f70faf8d8af7a$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_object_exe::@5ed5358f70faf8d8af7a$",
+ "backtrace": None,
+ },
+ {
+ "id": "^link_imported_exe::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ {
+ "id": "^link_imported_shared_exe::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ {
+ "id": "^link_imported_static_exe::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ {
+ "id": "^link_imported_object_exe::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ {
+ "id": "^link_imported_interface_exe::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ {
+ "id": "^custom_exe::@c11385ffed57b860da63$",
+ "backtrace": None,
+ },
+ {
+ "id": "^generated_exe::@[0-9a-f]+$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "ZERO_CHECK",
+ "id": "^ZERO_CHECK::@6890427a1f51a3e7e1df$",
+ "directorySource": "^\\.$",
+ "projectName": "codemodel-v2",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/CMakeFiles/ZERO_CHECK$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/CMakeFiles/ZERO_CHECK\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/CMakeFiles/ZERO_CHECK$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/CMakeFiles/ZERO_CHECK\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^\\.$",
+ "source": "^\\.$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": None,
+ },
+ {
+ "name": "interface_exe",
+ "id": "^interface_exe::@6890427a1f51a3e7e1df$",
+ "directorySource": "^\\.$",
+ "projectName": "codemodel-v2",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^include_test\\.cmake$",
+ "line": 3,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^include_test\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": [
+ {
+ "define": "interface_exe_EXPORTS",
+ "backtrace": None,
+ },
+ ],
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^include_test\\.cmake$",
+ "line": 3,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^include_test\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^my_interface_exe\\.myexe$",
+ "artifacts": [
+ {
+ "path": "^bin/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?my_interface_exe\\.myexe$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^lib/my_interface_exe\\.imp$",
+ "_aixExtra": True,
+ "_dllExtra": False,
+ },
+ {
+ "path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?my_interface_exe\\.(dll\\.a|lib)$",
+ "_dllExtra": True,
+ },
+ {
+ "path": "^bin/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?my_interface_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^\\.$",
+ "source": "^\\.$",
+ "install": None,
+ "link": {
+ "language": "C",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "c_lib",
+ "id": "^c_lib::@6890427a1f51a3e7e1df$",
+ "directorySource": "^\\.$",
+ "projectName": "codemodel-v2",
+ "type": "STATIC_LIBRARY",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 5,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 5,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^(lib)?c_lib\\.(a|lib)$",
+ "artifacts": [
+ {
+ "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_lib\\.(a|lib)$",
+ "_dllExtra": False,
+ },
+ ],
+ "build": "^\\.$",
+ "source": "^\\.$",
+ "install": None,
+ "link": None,
+ "archive": {
+ "lto": None,
+ },
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "c_exe",
+ "id": "^c_exe::@6890427a1f51a3e7e1df$",
+ "directorySource": "^\\.$",
+ "projectName": "codemodel-v2",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 6,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 6,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^c_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?c_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?c_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^\\.$",
+ "source": "^\\.$",
+ "install": None,
+ "link": {
+ "language": "C",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^c_lib::@6890427a1f51a3e7e1df$",
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 7,
+ "command": "target_link_libraries",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "id": "^ZERO_CHECK::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "c_shared_lib",
+ "id": "^c_shared_lib::@6890427a1f51a3e7e1df$",
+ "directorySource": "^\\.$",
+ "projectName": "codemodel-v2",
+ "type": "SHARED_LIBRARY",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 9,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": [
+ {
+ "define": "c_shared_lib_EXPORTS",
+ "backtrace": None,
+ },
+ ],
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 9,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^(lib|cyg)?c_shared_lib\\.(so|dylib|dll)$",
+ "artifacts": [
+ {
+ "path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib|cyg)?c_shared_lib\\.(so|dylib|dll)$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_shared_lib\\.(dll\\.a|lib)$",
+ "_dllExtra": True,
+ },
+ {
+ "path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib|cyg)?c_shared_lib\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^\\.$",
+ "source": "^\\.$",
+ "install": None,
+ "link": {
+ "language": "C",
+ "lto": True,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "c_shared_exe",
+ "id": "^c_shared_exe::@6890427a1f51a3e7e1df$",
+ "directorySource": "^\\.$",
+ "projectName": "codemodel-v2",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 10,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 10,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^c_shared_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?c_shared_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?c_shared_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^\\.$",
+ "source": "^\\.$",
+ "install": None,
+ "link": {
+ "language": "C",
+ "lto": True,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^c_shared_lib::@6890427a1f51a3e7e1df$",
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 11,
+ "command": "target_link_libraries",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "id": "^ZERO_CHECK::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "c_static_lib",
+ "id": "^c_static_lib::@6890427a1f51a3e7e1df$",
+ "directorySource": "^\\.$",
+ "projectName": "codemodel-v2",
+ "type": "STATIC_LIBRARY",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 13,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 13,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^(lib)?c_static_lib\\.(a|lib)$",
+ "artifacts": [
+ {
+ "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_static_lib\\.(a|lib)$",
+ "_dllExtra": False,
+ },
+ ],
+ "build": "^\\.$",
+ "source": "^\\.$",
+ "install": None,
+ "link": None,
+ "archive": {
+ "lto": True,
+ },
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "c_static_exe",
+ "id": "^c_static_exe::@6890427a1f51a3e7e1df$",
+ "directorySource": "^\\.$",
+ "projectName": "codemodel-v2",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 14,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 14,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^c_static_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?c_static_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?c_static_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^\\.$",
+ "source": "^\\.$",
+ "install": None,
+ "link": {
+ "language": "C",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^c_static_lib::@6890427a1f51a3e7e1df$",
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 15,
+ "command": "target_link_libraries",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "id": "^ZERO_CHECK::@6890427a1f51a3e7e1df$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "ALL_BUILD",
+ "id": "^ALL_BUILD::@a56b12a3f5c0529fb296$",
+ "directorySource": "^cxx$",
+ "projectName": "Cxx",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/cxx/CMakeFiles/ALL_BUILD$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/cxx/CMakeFiles/ALL_BUILD\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/cxx/CMakeFiles/ALL_BUILD$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/cxx/CMakeFiles/ALL_BUILD\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^cxx$",
+ "source": "^cxx$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_lib::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_exe::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_shared_lib::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_shared_exe::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_static_lib::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_static_exe::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "ZERO_CHECK",
+ "id": "^ZERO_CHECK::@a56b12a3f5c0529fb296$",
+ "directorySource": "^cxx$",
+ "projectName": "Cxx",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/cxx/CMakeFiles/ZERO_CHECK$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/cxx/CMakeFiles/ZERO_CHECK\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/cxx/CMakeFiles/ZERO_CHECK$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/cxx/CMakeFiles/ZERO_CHECK\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^cxx$",
+ "source": "^cxx$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": None,
+ },
+ {
+ "name": "cxx_lib",
+ "id": "^cxx_lib::@a56b12a3f5c0529fb296$",
+ "directorySource": "^cxx$",
+ "projectName": "Cxx",
+ "type": "STATIC_LIBRARY",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.cxx$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "CXX",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 4,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "CXX",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 4,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^(lib)?cxx_lib\\.(a|lib)$",
+ "artifacts": [
+ {
+ "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?cxx_lib\\.(a|lib)$",
+ "_dllExtra": False,
+ },
+ ],
+ "build": "^cxx$",
+ "source": "^cxx$",
+ "install": None,
+ "link": None,
+ "archive": {
+ "lto": None,
+ },
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "cxx_exe",
+ "id": "^cxx_exe::@a56b12a3f5c0529fb296$",
+ "directorySource": "^cxx$",
+ "projectName": "Cxx",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.cxx$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "CXX",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 5,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "CXX",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": [
+ {
+ "fragment" : "TargetCompileOptions",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 17,
+ "command": "target_compile_options",
+ "hasParent": True,
+ },
+ {
+ "file" : "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ }
+ ],
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 5,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": "bin",
+ "nameOnDisk": "^cxx_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^cxx$",
+ "source": "^cxx$",
+ "install": {
+ "prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$",
+ "destinations": [
+ {
+ "path": "bin",
+ "backtrace": [
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": 37,
+ "command": "install",
+ "hasParent": True,
+ },
+ {
+ "file": "^codemodel-v2\\.cmake$",
+ "line": None,
+ "command": None,
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": 3,
+ "command": "include",
+ "hasParent": True,
+ },
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ },
+ "link": {
+ "language": "CXX",
+ "lto": None,
+ "commandFragments": [
+ {
+ "fragment" : "TargetLinkOptions",
+ "role" : "flags",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 18,
+ "command": "target_link_options",
+ "hasParent": True,
+ },
+ {
+ "file" : "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "fragment" : ".*TargetLinkDir\\\"?$",
+ "role" : "libraryPath",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 19,
+ "command": "target_link_directories",
+ "hasParent": True,
+ },
+ {
+ "file" : "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "fragment" : ".*cxx_lib.*",
+ "role" : "libraries",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 6,
+ "command": "target_link_libraries",
+ "hasParent": True,
+ },
+ {
+ "file" : "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^cxx_lib::@a56b12a3f5c0529fb296$",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 6,
+ "command": "target_link_libraries",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "id": "^ZERO_CHECK::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "cxx_shared_lib",
+ "id": "^cxx_shared_lib::@a56b12a3f5c0529fb296$",
+ "directorySource": "^cxx$",
+ "projectName": "Cxx",
+ "type": "SHARED_LIBRARY",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.cxx$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "CXX",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 9,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "CXX",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ "includes": None,
+ "defines": [
+ {
+ "define": "cxx_shared_lib_EXPORTS",
+ "backtrace": None,
+ },
+ ],
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 9,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^(lib|cyg)?cxx_shared_lib\\.(so|dylib|dll)$",
+ "artifacts": [
+ {
+ "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib|cyg)?cxx_shared_lib\\.(so|dylib|dll)$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?cxx_shared_lib\\.(dll\\.a|lib)$",
+ "_dllExtra": True,
+ },
+ {
+ "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib|cyg)?cxx_shared_lib\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^cxx$",
+ "source": "^cxx$",
+ "install": None,
+ "link": {
+ "language": "CXX",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "cxx_shared_exe",
+ "id": "^cxx_shared_exe::@a56b12a3f5c0529fb296$",
+ "directorySource": "^cxx$",
+ "projectName": "Cxx",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.cxx$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "CXX",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 10,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "CXX",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 10,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^cxx_shared_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_shared_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_shared_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^cxx$",
+ "source": "^cxx$",
+ "install": None,
+ "link": {
+ "language": "CXX",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^cxx_shared_lib::@a56b12a3f5c0529fb296$",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 11,
+ "command": "target_link_libraries",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "id": "^ZERO_CHECK::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "cxx_static_lib",
+ "id": "^cxx_static_lib::@a56b12a3f5c0529fb296$",
+ "directorySource": "^cxx$",
+ "projectName": "Cxx",
+ "type": "STATIC_LIBRARY",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.cxx$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "CXX",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 13,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "CXX",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 13,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^(lib)?cxx_static_lib\\.(a|lib)$",
+ "artifacts": [
+ {
+ "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?cxx_static_lib\\.(a|lib)$",
+ "_dllExtra": False,
+ },
+ ],
+ "build": "^cxx$",
+ "source": "^cxx$",
+ "install": None,
+ "link": None,
+ "archive": {
+ "lto": None,
+ },
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "cxx_static_exe",
+ "id": "^cxx_static_exe::@a56b12a3f5c0529fb296$",
+ "directorySource": "^cxx$",
+ "projectName": "Cxx",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.cxx$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "CXX",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 14,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "CXX",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 14,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^cxx_static_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_static_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^cxx/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_static_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^cxx$",
+ "source": "^cxx$",
+ "install": None,
+ "link": {
+ "language": "CXX",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^cxx_static_lib::@a56b12a3f5c0529fb296$",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 15,
+ "command": "target_link_libraries",
+ "hasParent": True,
+ },
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "id": "^ZERO_CHECK::@a56b12a3f5c0529fb296$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "ALL_BUILD",
+ "id": "^ALL_BUILD::@53632cba2752272bb008$",
+ "directorySource": "^alias$",
+ "projectName": "Alias",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/alias/CMakeFiles/ALL_BUILD$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/alias/CMakeFiles/ALL_BUILD\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/alias/CMakeFiles/ALL_BUILD$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/alias/CMakeFiles/ALL_BUILD\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^alias$",
+ "source": "^alias$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@53632cba2752272bb008$",
+ "backtrace": None,
+ },
+ {
+ "id": "^c_alias_exe::@53632cba2752272bb008$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_alias_exe::@53632cba2752272bb008$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "ZERO_CHECK",
+ "id": "^ZERO_CHECK::@53632cba2752272bb008$",
+ "directorySource": "^alias$",
+ "projectName": "Alias",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/alias/CMakeFiles/ZERO_CHECK$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/alias/CMakeFiles/ZERO_CHECK\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/alias/CMakeFiles/ZERO_CHECK$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/alias/CMakeFiles/ZERO_CHECK\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^alias$",
+ "source": "^alias$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": None,
+ },
+ {
+ "name": "c_alias_exe",
+ "id": "^c_alias_exe::@53632cba2752272bb008$",
+ "directorySource": "^alias$",
+ "projectName": "Alias",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": 5,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": 5,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^c_alias_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^alias/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?c_alias_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^alias/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?c_alias_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^alias$",
+ "source": "^alias$",
+ "install": None,
+ "link": {
+ "language": "C",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^c_lib::@6890427a1f51a3e7e1df$",
+ "backtrace": [
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": 6,
+ "command": "target_link_libraries",
+ "hasParent": True,
+ },
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "id": "^ZERO_CHECK::@53632cba2752272bb008$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "cxx_alias_exe",
+ "id": "^cxx_alias_exe::@53632cba2752272bb008$",
+ "directorySource": "^alias$",
+ "projectName": "Alias",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.cxx$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "CXX",
+ "backtrace": [
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": 9,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "CXX",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": 9,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^cxx_alias_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^alias/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_alias_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^alias/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_alias_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^alias$",
+ "source": "^alias$",
+ "install": None,
+ "link": {
+ "language": "CXX",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^cxx_lib::@a56b12a3f5c0529fb296$",
+ "backtrace": [
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": 10,
+ "command": "target_link_libraries",
+ "hasParent": True,
+ },
+ {
+ "file": "^alias/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "id": "^ZERO_CHECK::@53632cba2752272bb008$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "ALL_BUILD",
+ "id": "^ALL_BUILD::@5ed5358f70faf8d8af7a$",
+ "directorySource": "^object$",
+ "projectName": "Object",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/CMakeFiles/ALL_BUILD$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/CMakeFiles/ALL_BUILD\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/CMakeFiles/ALL_BUILD$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/CMakeFiles/ALL_BUILD\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^object$",
+ "source": "^object$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@5ed5358f70faf8d8af7a$",
+ "backtrace": None,
+ },
+ {
+ "id": "^c_object_lib::@5ed5358f70faf8d8af7a$",
+ "backtrace": None,
+ },
+ {
+ "id": "^c_object_exe::@5ed5358f70faf8d8af7a$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_object_lib::@5ed5358f70faf8d8af7a$",
+ "backtrace": None,
+ },
+ {
+ "id": "^cxx_object_exe::@5ed5358f70faf8d8af7a$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "ZERO_CHECK",
+ "id": "^ZERO_CHECK::@5ed5358f70faf8d8af7a$",
+ "directorySource": "^object$",
+ "projectName": "Object",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/CMakeFiles/ZERO_CHECK$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/CMakeFiles/ZERO_CHECK\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/CMakeFiles/ZERO_CHECK$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/CMakeFiles/ZERO_CHECK\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^object$",
+ "source": "^object$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": None,
+ },
+ {
+ "name": "c_object_lib",
+ "id": "^c_object_lib::@5ed5358f70faf8d8af7a$",
+ "directorySource": "^object$",
+ "projectName": "Object",
+ "type": "OBJECT_LIBRARY",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": 5,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": 5,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": [
+ {
+ "path": "^object/.*/empty(\\.c)?\\.o(bj)?$",
+ "_dllExtra": False,
+ },
+ ],
+ "build": "^object$",
+ "source": "^object$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@5ed5358f70faf8d8af7a$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "c_object_exe",
+ "id": "^c_object_exe::@5ed5358f70faf8d8af7a$",
+ "directorySource": "^object$",
+ "projectName": "Object",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": 6,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/.*/empty(\\.c)?\\.o(bj)?$",
+ "isGenerated": True,
+ "sourceGroupName": "Object Libraries",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": 7,
+ "command": "target_link_libraries",
+ "hasParent": True,
+ },
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ {
+ "name": "Object Libraries",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/.*/empty(\\.c)?\\.o(bj)?$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": 6,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^c_object_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^object/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?c_object_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^object/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?c_object_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^object$",
+ "source": "^object$",
+ "install": {
+ "prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$",
+ "destinations": [
+ {
+ "path": "bin",
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": 13,
+ "command": "install",
+ "hasParent": True,
+ },
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ },
+ "link": {
+ "language": "C",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^c_object_lib::@5ed5358f70faf8d8af7a$",
+ # FIXME: Add a backtrace here when it becomes available.
+ # You'll know when it's available, because this test will
+ # fail.
+ "backtrace": None,
+ },
+ {
+ "id": "^ZERO_CHECK::@5ed5358f70faf8d8af7a$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "cxx_object_lib",
+ "id": "^cxx_object_lib::@5ed5358f70faf8d8af7a$",
+ "directorySource": "^object$",
+ "projectName": "Object",
+ "type": "OBJECT_LIBRARY",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.cxx$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "CXX",
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": 9,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "CXX",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": 9,
+ "command": "add_library",
+ "hasParent": True,
+ },
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": [
+ {
+ "path": "^object/.*/empty(\\.cxx)?\\.o(bj)?$",
+ "_dllExtra": False,
+ },
+ ],
+ "build": "^object$",
+ "source": "^object$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@5ed5358f70faf8d8af7a$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "cxx_object_exe",
+ "id": "^cxx_object_exe::@5ed5358f70faf8d8af7a$",
+ "directorySource": "^object$",
+ "projectName": "Object",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.cxx$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "CXX",
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": 10,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/.*/empty(\\.cxx)?\\.o(bj)?$",
+ "isGenerated": True,
+ "sourceGroupName": "Object Libraries",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": 11,
+ "command": "target_link_libraries",
+ "hasParent": True,
+ },
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ },
+ {
+ "name": "Object Libraries",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/.*/empty(\\.cxx)?\\.o(bj)?$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "CXX",
+ "sourcePaths": [
+ "^empty\\.cxx$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": 10,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^cxx_object_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^object/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_object_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^object/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?cxx_object_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^object$",
+ "source": "^object$",
+ "install": {
+ "prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$",
+ "destinations": [
+ {
+ "path": "bin",
+ "backtrace": [
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": 13,
+ "command": "install",
+ "hasParent": True,
+ },
+ {
+ "file": "^object/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ },
+ "link": {
+ "language": "CXX",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^cxx_object_lib::@5ed5358f70faf8d8af7a$",
+ # FIXME: Add a backtrace here when it becomes available.
+ # You'll know when it's available, because this test will
+ # fail.
+ "backtrace": None,
+ },
+ {
+ "id": "^ZERO_CHECK::@5ed5358f70faf8d8af7a$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "ALL_BUILD",
+ "id": "^ALL_BUILD::@ba7eb709d0b48779c6c8$",
+ "directorySource": "^imported$",
+ "projectName": "Imported",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/imported/CMakeFiles/ALL_BUILD$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/imported/CMakeFiles/ALL_BUILD\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/imported/CMakeFiles/ALL_BUILD$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/imported/CMakeFiles/ALL_BUILD\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^imported$",
+ "source": "^imported$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ {
+ "id": "^link_imported_exe::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ {
+ "id": "^link_imported_shared_exe::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ {
+ "id": "^link_imported_static_exe::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ {
+ "id": "^link_imported_object_exe::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ {
+ "id": "^link_imported_interface_exe::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "ZERO_CHECK",
+ "id": "^ZERO_CHECK::@ba7eb709d0b48779c6c8$",
+ "directorySource": "^imported$",
+ "projectName": "Imported",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/imported/CMakeFiles/ZERO_CHECK$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/imported/CMakeFiles/ZERO_CHECK\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/imported/CMakeFiles/ZERO_CHECK$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/imported/CMakeFiles/ZERO_CHECK\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^imported$",
+ "source": "^imported$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": None,
+ },
+ {
+ "name": "link_imported_exe",
+ "id": "^link_imported_exe::@ba7eb709d0b48779c6c8$",
+ "directorySource": "^imported$",
+ "projectName": "Imported",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": 5,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": 5,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^link_imported_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^imported/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_imported_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^imported/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_imported_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^imported$",
+ "source": "^imported$",
+ "install": None,
+ "link": {
+ "language": "C",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "link_imported_shared_exe",
+ "id": "^link_imported_shared_exe::@ba7eb709d0b48779c6c8$",
+ "directorySource": "^imported$",
+ "projectName": "Imported",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": 9,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": 9,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^link_imported_shared_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^imported/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_imported_shared_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^imported/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_imported_shared_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^imported$",
+ "source": "^imported$",
+ "install": None,
+ "link": {
+ "language": "C",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "link_imported_static_exe",
+ "id": "^link_imported_static_exe::@ba7eb709d0b48779c6c8$",
+ "directorySource": "^imported$",
+ "projectName": "Imported",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": 13,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": 13,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^link_imported_static_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^imported/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_imported_static_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^imported/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_imported_static_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^imported$",
+ "source": "^imported$",
+ "install": None,
+ "link": {
+ "language": "C",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "link_imported_object_exe",
+ "id": "^link_imported_object_exe::@ba7eb709d0b48779c6c8$",
+ "directorySource": "^imported$",
+ "projectName": "Imported",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": 18,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": 18,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^link_imported_object_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^imported/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_imported_object_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^imported/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_imported_object_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^imported$",
+ "source": "^imported$",
+ "install": None,
+ "link": {
+ "language": "C",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "link_imported_interface_exe",
+ "id": "^link_imported_interface_exe::@ba7eb709d0b48779c6c8$",
+ "directorySource": "^imported$",
+ "projectName": "Imported",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": 23,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": 23,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^imported/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^link_imported_interface_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^imported/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_imported_interface_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^imported/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?link_imported_interface_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^imported$",
+ "source": "^imported$",
+ "install": None,
+ "link": {
+ "language": "C",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@ba7eb709d0b48779c6c8$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "ALL_BUILD",
+ "id": "^ALL_BUILD::@c11385ffed57b860da63$",
+ "directorySource": "^custom$",
+ "projectName": "Custom",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/custom/CMakeFiles/ALL_BUILD$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/custom/CMakeFiles/ALL_BUILD\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/custom/CMakeFiles/ALL_BUILD$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/custom/CMakeFiles/ALL_BUILD\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^custom$",
+ "source": "^custom$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@c11385ffed57b860da63$",
+ "backtrace": None,
+ },
+ {
+ "id": "^custom_exe::@c11385ffed57b860da63$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "ZERO_CHECK",
+ "id": "^ZERO_CHECK::@c11385ffed57b860da63$",
+ "directorySource": "^custom$",
+ "projectName": "Custom",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/custom/CMakeFiles/ZERO_CHECK$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/custom/CMakeFiles/ZERO_CHECK\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/custom/CMakeFiles/ZERO_CHECK$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/custom/CMakeFiles/ZERO_CHECK\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^custom$",
+ "source": "^custom$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": None,
+ },
+ {
+ "name": "custom_tgt",
+ "id": "^custom_tgt::@c11385ffed57b860da63$",
+ "directorySource": "^custom$",
+ "projectName": "Custom",
+ "type": "UTILITY",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/custom/CMakeFiles/custom_tgt$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": 3,
+ "command": "add_custom_target",
+ "hasParent": True,
+ },
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/(custom/)?CMakeFiles/([0-9a-f]+/)?custom_tgt\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/custom/CMakeFiles/custom_tgt$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/(custom/)?CMakeFiles/([0-9a-f]+/)?custom_tgt\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": 3,
+ "command": "add_custom_target",
+ "hasParent": True,
+ },
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^custom$",
+ "source": "^custom$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@c11385ffed57b860da63$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "custom_exe",
+ "id": "^custom_exe::@c11385ffed57b860da63$",
+ "directorySource": "^custom$",
+ "projectName": "Custom",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": 4,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^empty\\.c$",
+ ],
+ "includes": None,
+ "defines": None,
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": 4,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^custom_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^custom/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?custom_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^custom/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?custom_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^custom$",
+ "source": "^custom$",
+ "install": None,
+ "link": {
+ "language": "C",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^custom_tgt::@c11385ffed57b860da63$",
+ "backtrace": [
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": 5,
+ "command": "add_dependencies",
+ "hasParent": True,
+ },
+ {
+ "file": "^custom/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "id": "^ZERO_CHECK::@c11385ffed57b860da63$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "ALL_BUILD",
+ "id": "^ALL_BUILD::@[0-9a-f]+$",
+ "directorySource": "^.*/Tests/RunCMake/FileAPIExternalSource$",
+ "projectName": "External",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild/CMakeFiles/ALL_BUILD$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild/CMakeFiles/ALL_BUILD\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild/CMakeFiles/ALL_BUILD$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild/CMakeFiles/ALL_BUILD\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild$",
+ "source": "^.*/Tests/RunCMake/FileAPIExternalSource$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@[0-9a-f]+$",
+ "backtrace": None,
+ },
+ {
+ "id": "^generated_exe::@[0-9a-f]+$",
+ "backtrace": None,
+ },
+ ],
+ },
+ {
+ "name": "ZERO_CHECK",
+ "id": "^ZERO_CHECK::@[0-9a-f]+$",
+ "directorySource": "^.*/Tests/RunCMake/FileAPIExternalSource$",
+ "projectName": "External",
+ "type": "UTILITY",
+ "isGeneratorProvided": True,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild/CMakeFiles/ZERO_CHECK$",
+ "isGenerated": True,
+ "sourceGroupName": "",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild/CMakeFiles/ZERO_CHECK\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild/CMakeFiles/ZERO_CHECK$",
+ ],
+ },
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild/CMakeFiles/ZERO_CHECK\\.rule$",
+ ],
+ },
+ ],
+ "compileGroups": None,
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": None,
+ "artifacts": None,
+ "build": "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild$",
+ "source": "^.*/Tests/RunCMake/FileAPIExternalSource$",
+ "install": None,
+ "link": None,
+ "archive": None,
+ "dependencies": None,
+ },
+ {
+ "name": "generated_exe",
+ "id": "^generated_exe::@[0-9a-f]+$",
+ "directorySource": "^.*/Tests/RunCMake/FileAPIExternalSource$",
+ "projectName": "External",
+ "type": "EXECUTABLE",
+ "isGeneratorProvided": None,
+ "sources": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPIExternalSource/empty\\.c$",
+ "isGenerated": None,
+ "sourceGroupName": "Source Files",
+ "compileGroupLanguage": "C",
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": 5,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild/generated\\.cxx$",
+ "isGenerated": True,
+ "sourceGroupName": "Generated Source Files",
+ "compileGroupLanguage": "CXX",
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": 6,
+ "command": "target_sources",
+ "hasParent": True,
+ },
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "sourceGroups": [
+ {
+ "name": "Source Files",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPIExternalSource/empty\\.c$",
+ ],
+ },
+ {
+ "name": "Generated Source Files",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild/generated\\.cxx$",
+ ],
+ },
+ ],
+ "compileGroups": [
+ {
+ "language": "C",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPIExternalSource/empty\\.c$",
+ ],
+ "includes": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild$",
+ "isSystem": None,
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": 10,
+ "command": "set_property",
+ "hasParent": True,
+ },
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPIExternalSource$",
+ "isSystem": True,
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": 11,
+ "command": "target_include_directories",
+ "hasParent": True,
+ },
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "defines": [
+ {
+ "define": "EMPTY_C=1",
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": 9,
+ "command": "set_property",
+ "hasParent": True,
+ },
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "define": "SRC_DUMMY",
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": 9,
+ "command": "set_property",
+ "hasParent": True,
+ },
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "define": "GENERATED_EXE=1",
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": 12,
+ "command": "target_compile_definitions",
+ "hasParent": True,
+ },
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "define": "TGT_DUMMY",
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": 12,
+ "command": "target_compile_definitions",
+ "hasParent": True,
+ },
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "compileCommandFragments": [
+ {
+ "fragment" : "SRC_COMPILE_OPTIONS_DUMMY",
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": 13,
+ "command": "set_source_files_properties",
+ "hasParent": True,
+ },
+ {
+ "file" : "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ }
+ ],
+ },
+ {
+ "language": "CXX",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild/generated\\.cxx$",
+ ],
+ "includes": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPIExternalSource$",
+ "isSystem": True,
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": 11,
+ "command": "target_include_directories",
+ "hasParent": True,
+ },
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "defines": [
+ {
+ "define": "GENERATED_EXE=1",
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": 12,
+ "command": "target_compile_definitions",
+ "hasParent": True,
+ },
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "define": "TGT_DUMMY",
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": 12,
+ "command": "target_compile_definitions",
+ "hasParent": True,
+ },
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
+ "compileCommandFragments": None,
+ },
+ ],
+ "backtrace": [
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": 5,
+ "command": "add_executable",
+ "hasParent": True,
+ },
+ {
+ "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ "folder": None,
+ "nameOnDisk": "^generated_exe(\\.exe)?$",
+ "artifacts": [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?generated_exe(\\.exe)?$",
+ "_dllExtra": False,
+ },
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?generated_exe\\.pdb$",
+ "_dllExtra": True,
+ },
+ ],
+ "build": "^.*/Tests/RunCMake/FileAPI/FileAPIExternalBuild$",
+ "source": "^.*/Tests/RunCMake/FileAPIExternalSource$",
+ "install": None,
+ "link": {
+ "language": "CXX",
+ "lto": None,
+ "commandFragments": None,
+ },
+ "archive": None,
+ "dependencies": [
+ {
+ "id": "^ZERO_CHECK::@[0-9a-f]+$",
+ "backtrace": None,
+ },
+ ],
+ },
+ ]
+
+ if not os.path.exists(os.path.join(reply_dir, "..", "..", "..", "..", "ipo_enabled.txt")):
+ for e in expected:
+ try:
+ e["link"]["lto"] = None
+ except TypeError: # "link" is not a dict, no problem.
+ pass
+ try:
+ e["archive"]["lto"] = None
+ except TypeError: # "archive" is not a dict, no problem.
+ pass
+
+ if inSource:
+ for e in expected:
+ if e["sources"] is not None:
+ for s in e["sources"]:
+ s["path"] = s["path"].replace("^.*/Tests/RunCMake/FileAPI/", "^", 1)
+ if e["sourceGroups"] is not None:
+ for g in e["sourceGroups"]:
+ g["sourcePaths"] = [p.replace("^.*/Tests/RunCMake/FileAPI/", "^", 1) for p in g["sourcePaths"]]
+ if e["compileGroups"] is not None:
+ for g in e["compileGroups"]:
+ g["sourcePaths"] = [p.replace("^.*/Tests/RunCMake/FileAPI/", "^", 1) for p in g["sourcePaths"]]
+
+ if matches(g, "^Visual Studio "):
+ expected = filter_list(lambda e: e["name"] not in ("ZERO_CHECK") or e["id"] == "^ZERO_CHECK::@6890427a1f51a3e7e1df$", expected)
+ for e in expected:
+ if e["type"] == "UTILITY":
+ if e["id"] == "^ZERO_CHECK::@6890427a1f51a3e7e1df$":
+ e["sources"] = [
+ {
+ "path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/CMakeFiles/([0-9a-f]+/)?generate\\.stamp\\.rule$",
+ "isGenerated": True,
+ "sourceGroupName": "CMake Rules",
+ "compileGroupLanguage": None,
+ "backtrace": [
+ {
+ "file": "^CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ]
+ e["sourceGroups"] = [
+ {
+ "name": "CMake Rules",
+ "sourcePaths": [
+ "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/CMakeFiles/([0-9a-f]+/)?generate\\.stamp\\.rule$",
+ ],
+ },
+ ]
+ elif e["name"] in ("ALL_BUILD"):
+ e["sources"] = []
+ e["sourceGroups"] = None
+ if e["dependencies"] is not None:
+ for d in e["dependencies"]:
+ if matches(d["id"], "^\\^ZERO_CHECK::@"):
+ d["id"] = "^ZERO_CHECK::@6890427a1f51a3e7e1df$"
+
+ elif g == "Xcode":
+ if ';' in os.environ.get("CMAKE_OSX_ARCHITECTURES", ""):
+ expected = filter_list(lambda e: e["name"] not in ("link_imported_object_exe"), expected)
+ for e in expected:
+ e["dependencies"] = filter_list(lambda d: not matches(d["id"], "^\\^link_imported_object_exe::@"), e["dependencies"])
+ if e["name"] in ("c_object_lib", "cxx_object_lib"):
+ e["artifacts"] = None
+
+ else:
+ for e in expected:
+ e["dependencies"] = filter_list(lambda d: not matches(d["id"], "^\\^ZERO_CHECK::@"), e["dependencies"])
+
+ expected = filter_list(lambda t: t["name"] not in ("ALL_BUILD", "ZERO_CHECK"), expected)
+
+ if sys.platform not in ("win32", "cygwin", "msys"):
+ for e in expected:
+ e["artifacts"] = filter_list(lambda a: not a["_dllExtra"], e["artifacts"])
+
+ if "aix" not in sys.platform:
+ for e in expected:
+ e["artifacts"] = filter_list(lambda a: not a.get("_aixExtra", False), e["artifacts"])
+
+ return expected
+
+def check_targets(c, g, inSource):
+ check_list_match(lambda a, e: matches(a["id"], e["id"]),
+ c["targets"], gen_check_targets(c, g, inSource),
+ check=check_target(c),
+ check_exception=lambda a, e: "Target ID: %s" % a["id"],
+ missing_exception=lambda e: "Target ID: %s" % e["id"],
+ extra_exception=lambda a: "Target ID: %s" % a["id"])
+
+def gen_check_projects(c, g):
+ expected = [
+ {
+ "name": "codemodel-v2",
+ "parentName": None,
+ "childNames": [
+ "Alias",
+ "Custom",
+ "Cxx",
+ "Imported",
+ "Object",
+ "External",
+ ],
+ "directorySources": [
+ "^\\.$",
+ "^dir$",
+ "^dir/dir$",
+ ],
+ "targetIds": [
+ "^ALL_BUILD::@6890427a1f51a3e7e1df$",
+ "^ZERO_CHECK::@6890427a1f51a3e7e1df$",
+ "^interface_exe::@6890427a1f51a3e7e1df$",
+ "^c_lib::@6890427a1f51a3e7e1df$",
+ "^c_exe::@6890427a1f51a3e7e1df$",
+ "^c_shared_lib::@6890427a1f51a3e7e1df$",
+ "^c_shared_exe::@6890427a1f51a3e7e1df$",
+ "^c_static_lib::@6890427a1f51a3e7e1df$",
+ "^c_static_exe::@6890427a1f51a3e7e1df$",
+ ],
+ },
+ {
+ "name": "Cxx",
+ "parentName": "codemodel-v2",
+ "childNames": None,
+ "directorySources": [
+ "^cxx$",
+ ],
+ "targetIds": [
+ "^ALL_BUILD::@a56b12a3f5c0529fb296$",
+ "^ZERO_CHECK::@a56b12a3f5c0529fb296$",
+ "^cxx_lib::@a56b12a3f5c0529fb296$",
+ "^cxx_exe::@a56b12a3f5c0529fb296$",
+ "^cxx_shared_lib::@a56b12a3f5c0529fb296$",
+ "^cxx_shared_exe::@a56b12a3f5c0529fb296$",
+ "^cxx_static_lib::@a56b12a3f5c0529fb296$",
+ "^cxx_static_exe::@a56b12a3f5c0529fb296$",
+ ],
+ },
+ {
+ "name": "Alias",
+ "parentName": "codemodel-v2",
+ "childNames": None,
+ "directorySources": [
+ "^alias$",
+ ],
+ "targetIds": [
+ "^ALL_BUILD::@53632cba2752272bb008$",
+ "^ZERO_CHECK::@53632cba2752272bb008$",
+ "^c_alias_exe::@53632cba2752272bb008$",
+ "^cxx_alias_exe::@53632cba2752272bb008$",
+ ],
+ },
+ {
+ "name": "Object",
+ "parentName": "codemodel-v2",
+ "childNames": None,
+ "directorySources": [
+ "^object$",
+ ],
+ "targetIds": [
+ "^ALL_BUILD::@5ed5358f70faf8d8af7a$",
+ "^ZERO_CHECK::@5ed5358f70faf8d8af7a$",
+ "^c_object_lib::@5ed5358f70faf8d8af7a$",
+ "^c_object_exe::@5ed5358f70faf8d8af7a$",
+ "^cxx_object_lib::@5ed5358f70faf8d8af7a$",
+ "^cxx_object_exe::@5ed5358f70faf8d8af7a$",
+ ],
+ },
+ {
+ "name": "Imported",
+ "parentName": "codemodel-v2",
+ "childNames": None,
+ "directorySources": [
+ "^imported$",
+ ],
+ "targetIds": [
+ "^ALL_BUILD::@ba7eb709d0b48779c6c8$",
+ "^ZERO_CHECK::@ba7eb709d0b48779c6c8$",
+ "^link_imported_exe::@ba7eb709d0b48779c6c8$",
+ "^link_imported_shared_exe::@ba7eb709d0b48779c6c8$",
+ "^link_imported_static_exe::@ba7eb709d0b48779c6c8$",
+ "^link_imported_object_exe::@ba7eb709d0b48779c6c8$",
+ "^link_imported_interface_exe::@ba7eb709d0b48779c6c8$",
+ ],
+ },
+ {
+ "name": "Custom",
+ "parentName": "codemodel-v2",
+ "childNames": None,
+ "directorySources": [
+ "^custom$",
+ ],
+ "targetIds": [
+ "^ALL_BUILD::@c11385ffed57b860da63$",
+ "^ZERO_CHECK::@c11385ffed57b860da63$",
+ "^custom_tgt::@c11385ffed57b860da63$",
+ "^custom_exe::@c11385ffed57b860da63$",
+ ],
+ },
+ {
+ "name": "External",
+ "parentName": "codemodel-v2",
+ "childNames": None,
+ "directorySources": [
+ "^.*/Tests/RunCMake/FileAPIExternalSource$",
+ ],
+ "targetIds": [
+ "^ALL_BUILD::@[0-9a-f]+$",
+ "^ZERO_CHECK::@[0-9a-f]+$",
+ "^generated_exe::@[0-9a-f]+$",
+ ],
+ },
+ ]
+
+ if matches(g, "^Visual Studio "):
+ for e in expected:
+ if e["parentName"] is not None:
+ e["targetIds"] = filter_list(lambda t: not matches(t, "^\\^ZERO_CHECK"), e["targetIds"])
+
+ elif g == "Xcode":
+ if ';' in os.environ.get("CMAKE_OSX_ARCHITECTURES", ""):
+ for e in expected:
+ e["targetIds"] = filter_list(lambda t: not matches(t, "^\\^(link_imported_object_exe)"), e["targetIds"])
+
+ else:
+ for e in expected:
+ e["targetIds"] = filter_list(lambda t: not matches(t, "^\\^(ALL_BUILD|ZERO_CHECK)"), e["targetIds"])
+
+ return expected
+
+def check_projects(c, g):
+ check_list_match(lambda a, e: is_string(a["name"], e["name"]), c["projects"], gen_check_projects(c, g),
+ check=check_project(c),
+ check_exception=lambda a, e: "Project name: %s" % a["name"],
+ missing_exception=lambda e: "Project name: %s" % e["name"],
+ extra_exception=lambda a: "Project name: %s" % a["name"])
+
+def check_object_codemodel_configuration(c, g, inSource):
+ assert sorted(c.keys()) == ["directories", "name", "projects", "targets"]
+ assert is_string(c["name"])
+ check_directories(c, g)
+ check_targets(c, g, inSource)
+ check_projects(c, g)
+
+def check_object_codemodel(g):
+ def _check(o):
+ assert sorted(o.keys()) == ["configurations", "kind", "paths", "version"]
+ # The "kind" and "version" members are handled by check_index_object.
+ assert is_dict(o["paths"])
+ assert sorted(o["paths"].keys()) == ["build", "source"]
+ assert matches(o["paths"]["build"], "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build$")
+ assert matches(o["paths"]["source"], "^.*/Tests/RunCMake/FileAPI$")
+
+ inSource = os.path.dirname(o["paths"]["build"]) == o["paths"]["source"]
+
+ if matches(g, "^(Visual Studio |Xcode$)"):
+ assert sorted([c["name"] for c in o["configurations"]]) == ["Debug", "MinSizeRel", "RelWithDebInfo", "Release"]
+ else:
+ assert len(o["configurations"]) == 1
+ assert o["configurations"][0]["name"] in ("", "Debug", "Release", "RelWithDebInfo", "MinSizeRel")
+
+ for c in o["configurations"]:
+ check_object_codemodel_configuration(c, g, inSource)
+ return _check
+
+assert is_dict(index)
+assert sorted(index.keys()) == ["cmake", "objects", "reply"]
+check_objects(index["objects"], index["cmake"]["generator"]["name"])
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2.cmake b/Tests/RunCMake/FileAPI/codemodel-v2.cmake
new file mode 100644
index 000000000..c98a84c26
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/codemodel-v2.cmake
@@ -0,0 +1,37 @@
+enable_language(C)
+
+include("${CMAKE_CURRENT_LIST_DIR}/include_test.cmake")
+
+add_library(c_lib empty.c)
+add_executable(c_exe empty.c)
+target_link_libraries(c_exe PRIVATE c_lib)
+
+add_library(c_shared_lib SHARED empty.c)
+add_executable(c_shared_exe empty.c)
+target_link_libraries(c_shared_exe PRIVATE c_shared_lib)
+
+add_library(c_static_lib STATIC empty.c)
+add_executable(c_static_exe empty.c)
+target_link_libraries(c_static_exe PRIVATE c_static_lib)
+
+add_subdirectory(cxx)
+add_subdirectory(alias)
+add_subdirectory(object)
+add_subdirectory(imported)
+add_subdirectory(custom)
+add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../FileAPIExternalSource" "${CMAKE_CURRENT_BINARY_DIR}/../FileAPIExternalBuild")
+add_subdirectory(dir)
+
+set_property(TARGET c_shared_lib PROPERTY LIBRARY_OUTPUT_DIRECTORY lib)
+set_property(TARGET c_shared_lib PROPERTY RUNTIME_OUTPUT_DIRECTORY lib)
+
+include(CheckIPOSupported)
+check_ipo_supported(RESULT _ipo LANGUAGES C)
+if(_ipo)
+ set_property(TARGET c_shared_lib PROPERTY INTERPROCEDURAL_OPTIMIZATION ON)
+ set_property(TARGET c_shared_exe PROPERTY INTERPROCEDURAL_OPTIMIZATION ON)
+ set_property(TARGET c_static_lib PROPERTY INTERPROCEDURAL_OPTIMIZATION ON)
+ file(WRITE "${CMAKE_BINARY_DIR}/ipo_enabled.txt" "")
+endif()
+
+install(TARGETS cxx_exe)
diff --git a/Tests/RunCMake/FileAPI/custom/CMakeLists.txt b/Tests/RunCMake/FileAPI/custom/CMakeLists.txt
new file mode 100644
index 000000000..1cdf5c20a
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/custom/CMakeLists.txt
@@ -0,0 +1,5 @@
+project(Custom)
+
+add_custom_target(custom_tgt COMMAND ${CMAKE_COMMAND} -E echo "Building custom_tgt")
+add_executable(custom_exe ../empty.c)
+add_dependencies(custom_exe custom_tgt)
diff --git a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt
new file mode 100644
index 000000000..b0564f5dd
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt
@@ -0,0 +1,19 @@
+project(Cxx)
+enable_language(CXX)
+
+add_library(cxx_lib ../empty.cxx)
+add_executable(cxx_exe ../empty.cxx)
+target_link_libraries(cxx_exe PRIVATE cxx_lib)
+set_property(TARGET cxx_exe PROPERTY FOLDER bin)
+
+add_library(cxx_shared_lib SHARED ../empty.cxx)
+add_executable(cxx_shared_exe ../empty.cxx)
+target_link_libraries(cxx_shared_exe PRIVATE cxx_shared_lib)
+
+add_library(cxx_static_lib STATIC ../empty.cxx)
+add_executable(cxx_static_exe ../empty.cxx)
+target_link_libraries(cxx_static_exe PRIVATE cxx_static_lib)
+
+target_compile_options(cxx_exe PUBLIC TargetCompileOptions)
+target_link_options(cxx_exe PUBLIC TargetLinkOptions)
+target_link_directories(cxx_exe PUBLIC "${CMAKE_BINARY_DIR}/TargetLinkDir")
diff --git a/Tests/RunCMake/FileAPI/dir/CMakeLists.txt b/Tests/RunCMake/FileAPI/dir/CMakeLists.txt
new file mode 100644
index 000000000..780445d6b
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/dir/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(dir)
diff --git a/Tests/RunCMake/FileAPI/dir/dir/CMakeLists.txt b/Tests/RunCMake/FileAPI/dir/dir/CMakeLists.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/dir/dir/CMakeLists.txt
diff --git a/Tests/RunCMake/FileAPI/dir/dirtest.cmake b/Tests/RunCMake/FileAPI/dir/dirtest.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/dir/dirtest.cmake
diff --git a/Tests/RunCMake/FileAPI/empty.c b/Tests/RunCMake/FileAPI/empty.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/empty.c
diff --git a/Tests/RunCMake/FileAPI/empty.cxx b/Tests/RunCMake/FileAPI/empty.cxx
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/empty.cxx
diff --git a/Tests/RunCMake/FileAPI/imported/CMakeLists.txt b/Tests/RunCMake/FileAPI/imported/CMakeLists.txt
new file mode 100644
index 000000000..d36d88ba8
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/imported/CMakeLists.txt
@@ -0,0 +1,24 @@
+project(Imported)
+
+add_library(imported_lib UNKNOWN IMPORTED)
+add_executable(imported_exe IMPORTED)
+add_executable(link_imported_exe ../empty.c)
+target_link_libraries(link_imported_exe PRIVATE imported_lib)
+
+add_library(imported_shared_lib SHARED IMPORTED)
+add_executable(link_imported_shared_exe ../empty.c)
+target_link_libraries(link_imported_shared_exe PRIVATE imported_shared_lib)
+
+add_library(imported_static_lib STATIC IMPORTED)
+add_executable(link_imported_static_exe ../empty.c)
+target_link_libraries(link_imported_static_exe PRIVATE imported_static_lib)
+
+if(NOT CMAKE_GENERATOR STREQUAL "Xcode" OR NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;$]")
+ add_library(imported_object_lib OBJECT IMPORTED)
+ add_executable(link_imported_object_exe ../empty.c)
+ target_link_libraries(link_imported_object_exe PRIVATE imported_object_lib)
+endif()
+
+add_library(imported_interface_lib INTERFACE IMPORTED)
+add_executable(link_imported_interface_exe ../empty.c)
+target_link_libraries(link_imported_interface_exe PRIVATE imported_interface_lib)
diff --git a/Tests/RunCMake/FileAPI/include_test.cmake b/Tests/RunCMake/FileAPI/include_test.cmake
new file mode 100644
index 000000000..c74d26431
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/include_test.cmake
@@ -0,0 +1,9 @@
+add_library(interface_lib INTERFACE)
+target_compile_definitions(interface_lib INTERFACE COMPILED_WITH_INTERFACE_LIB)
+add_executable(interface_exe empty.c)
+target_link_libraries(interface_exe PRIVATE inteface_lib)
+set_property(TARGET interface_exe PROPERTY ENABLE_EXPORTS ON)
+set_property(TARGET interface_exe PROPERTY RUNTIME_OUTPUT_DIRECTORY bin)
+set_property(TARGET interface_exe PROPERTY ARCHIVE_OUTPUT_DIRECTORY lib)
+set_property(TARGET interface_exe PROPERTY OUTPUT_NAME my_interface_exe)
+set_property(TARGET interface_exe PROPERTY SUFFIX .myexe)
diff --git a/Tests/RunCMake/FileAPI/object/CMakeLists.txt b/Tests/RunCMake/FileAPI/object/CMakeLists.txt
new file mode 100644
index 000000000..9773b8148
--- /dev/null
+++ b/Tests/RunCMake/FileAPI/object/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.13)
+project(Object)
+enable_language(CXX)
+
+add_library(c_object_lib OBJECT ../empty.c)
+add_executable(c_object_exe ../empty.c)
+target_link_libraries(c_object_exe PRIVATE c_object_lib)
+
+add_library(cxx_object_lib OBJECT ../empty.cxx)
+add_executable(cxx_object_exe ../empty.cxx)
+target_link_libraries(cxx_object_exe PRIVATE cxx_object_lib)
+
+install(TARGETS c_object_exe cxx_object_exe DESTINATION bin)
diff --git a/Tests/RunCMake/FileAPIDummyFile.cmake b/Tests/RunCMake/FileAPIDummyFile.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPIDummyFile.cmake
diff --git a/Tests/RunCMake/FileAPIExternalSource/CMakeLists.txt b/Tests/RunCMake/FileAPIExternalSource/CMakeLists.txt
new file mode 100644
index 000000000..b3ca66075
--- /dev/null
+++ b/Tests/RunCMake/FileAPIExternalSource/CMakeLists.txt
@@ -0,0 +1,13 @@
+project(External)
+enable_language(CXX)
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/generated.cxx" "")
+add_executable(generated_exe empty.c)
+target_sources(generated_exe PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated.cxx")
+source_group("Generated Source Files" FILES "${CMAKE_CURRENT_BINARY_DIR}/generated.cxx")
+set_property(SOURCE "${CMAKE_CURRENT_BINARY_DIR}/generated.cxx" PROPERTY GENERATED ON)
+set_property(SOURCE empty.c PROPERTY COMPILE_DEFINITIONS EMPTY_C=1 SRC_DUMMY)
+set_property(SOURCE empty.c PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}")
+target_include_directories(generated_exe SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
+target_compile_definitions(generated_exe PRIVATE GENERATED_EXE=1 -DTGT_DUMMY)
+set_source_files_properties(empty.c PROPERTIES COMPILE_OPTIONS SRC_COMPILE_OPTIONS_DUMMY)
diff --git a/Tests/RunCMake/FileAPIExternalSource/empty.c b/Tests/RunCMake/FileAPIExternalSource/empty.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FileAPIExternalSource/empty.c
diff --git a/Tests/RunCMake/File_Generate/CMP0070-NEW-check.cmake b/Tests/RunCMake/File_Generate/CMP0070-NEW-check.cmake
new file mode 100644
index 000000000..05ec26eed
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/CMP0070-NEW-check.cmake
@@ -0,0 +1,13 @@
+foreach(f
+ "${RunCMake_TEST_SOURCE_DIR}/relative-input-NEW.txt"
+ "${RunCMake_TEST_BINARY_DIR}/relative-output-NEW.txt"
+ )
+ if(EXISTS "${f}")
+ file(READ "${f}" content)
+ if(NOT content MATCHES "^relative-input-NEW[\r\n]*$")
+ string(APPEND RunCMake_TEST_FAILED "File\n ${f}\ndoes not have expected content.\n")
+ endif()
+ else()
+ string(APPEND RunCMake_TEST_FAILED "Missing\n ${f}\n")
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/File_Generate/CMP0070-NEW.cmake b/Tests/RunCMake/File_Generate/CMP0070-NEW.cmake
new file mode 100644
index 000000000..1a0382221
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/CMP0070-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0070 NEW)
+file(GENERATE OUTPUT relative-output-NEW.txt INPUT relative-input-NEW.txt)
diff --git a/Tests/RunCMake/File_Generate/CMP0070-OLD-check.cmake b/Tests/RunCMake/File_Generate/CMP0070-OLD-check.cmake
new file mode 100644
index 000000000..a71d822bb
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/CMP0070-OLD-check.cmake
@@ -0,0 +1,13 @@
+foreach(f
+ "${RunCMake_TEST_BINARY_DIR}/relative-input-OLD.txt"
+ "${RunCMake_TEST_BINARY_DIR}/relative-output-OLD.txt"
+ )
+ if(EXISTS "${f}")
+ file(READ "${f}" content)
+ if(NOT content MATCHES "^relative-input-OLD[\r\n]*$")
+ string(APPEND RunCMake_TEST_FAILED "File\n ${f}\ndoes not have expected content.\n")
+ endif()
+ else()
+ string(APPEND RunCMake_TEST_FAILED "Missing\n ${f}\n")
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/File_Generate/CMP0070-OLD.cmake b/Tests/RunCMake/File_Generate/CMP0070-OLD.cmake
new file mode 100644
index 000000000..0fb47cdfa
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/CMP0070-OLD.cmake
@@ -0,0 +1,3 @@
+cmake_policy(SET CMP0070 OLD)
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/relative-input-OLD.txt "relative-input-OLD\n")
+file(GENERATE OUTPUT relative-output-OLD.txt INPUT relative-input-OLD.txt)
diff --git a/Tests/RunCMake/File_Generate/CMP0070-WARN-check.cmake b/Tests/RunCMake/File_Generate/CMP0070-WARN-check.cmake
new file mode 100644
index 000000000..1488df09d
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/CMP0070-WARN-check.cmake
@@ -0,0 +1,13 @@
+foreach(f
+ "${RunCMake_TEST_BINARY_DIR}/relative-input-WARN.txt"
+ "${RunCMake_TEST_BINARY_DIR}/relative-output-WARN.txt"
+ )
+ if(EXISTS "${f}")
+ file(READ "${f}" content)
+ if(NOT content MATCHES "^relative-input-WARN[\r\n]*$")
+ string(APPEND RunCMake_TEST_FAILED "File\n ${f}\ndoes not have expected content.\n")
+ endif()
+ else()
+ string(APPEND RunCMake_TEST_FAILED "Missing\n ${f}\n")
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt b/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt
new file mode 100644
index 000000000..dbabaa97b
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/CMP0070-WARN-stderr.txt
@@ -0,0 +1,27 @@
+^CMake Warning \(dev\) in CMakeLists.txt:
+ Policy CMP0070 is not set: Define file\(GENERATE\) behavior for relative
+ paths. Run "cmake --help-policy CMP0070" for policy details. Use the
+ cmake_policy command to set the policy and suppress this warning.
+
+ file\(GENERATE\) given relative INPUT path:
+
+ relative-input-WARN.txt
+
+ This is not defined behavior unless CMP0070 is set to NEW. For
+ compatibility with older versions of CMake, the previous undefined behavior
+ will be used.
+This warning is for project developers. Use -Wno-dev to suppress it.(
++
+CMake Warning \(dev\) in CMakeLists.txt:
+ Policy CMP0070 is not set: Define file\(GENERATE\) behavior for relative
+ paths. Run "cmake --help-policy CMP0070" for policy details. Use the
+ cmake_policy command to set the policy and suppress this warning.
+
+ file\(GENERATE\) given relative OUTPUT path:
+
+ relative-output-WARN.txt
+
+ This is not defined behavior unless CMP0070 is set to NEW. For
+ compatibility with older versions of CMake, the previous undefined behavior
+ will be used.
+This warning is for project developers. Use -Wno-dev to suppress it.)+$
diff --git a/Tests/RunCMake/File_Generate/CMP0070-WARN.cmake b/Tests/RunCMake/File_Generate/CMP0070-WARN.cmake
new file mode 100644
index 000000000..ccb045231
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/CMP0070-WARN.cmake
@@ -0,0 +1,2 @@
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/relative-input-WARN.txt "relative-input-WARN\n")
+file(GENERATE OUTPUT relative-output-WARN.txt INPUT relative-input-WARN.txt)
diff --git a/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex-result.txt b/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex-result.txt
deleted file mode 100644
index 573541ac9..000000000
--- a/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex.cmake b/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex.cmake
index e2b081d48..bead2af6f 100644
--- a/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex.cmake
+++ b/Tests/RunCMake/File_Generate/COMPILE_LANGUAGE-genex.cmake
@@ -1,12 +1,6 @@
-
enable_language(CXX C)
-add_library(empty empty.cpp empty.c)
-target_compile_options(empty
- PRIVATE LANG_IS_$<COMPILE_LANGUAGE>
-)
-
file(GENERATE
- OUTPUT opts-$<COMPILE_LANGUAGE>.txt
- CONTENT "$<TARGET_PROPERTY:empty,COMPILE_OPTIONS>\n"
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opts-$<COMPILE_LANGUAGE>.txt
+ CONTENT "LANG_IS_$<COMPILE_LANGUAGE>\n"
)
diff --git a/Tests/RunCMake/File_Generate/CarryPermissions-result.txt b/Tests/RunCMake/File_Generate/CarryPermissions-result.txt
deleted file mode 100644
index 573541ac9..000000000
--- a/Tests/RunCMake/File_Generate/CarryPermissions-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/Tests/RunCMake/File_Generate/GenerateSource-result.txt b/Tests/RunCMake/File_Generate/GenerateSource-result.txt
deleted file mode 100644
index 573541ac9..000000000
--- a/Tests/RunCMake/File_Generate/GenerateSource-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt
index b08ef5a15..4c2e35fcc 100644
--- a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt
+++ b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects-stderr.txt
@@ -3,6 +3,7 @@ CMake Error at OutputNameMatchesObjects.cmake:[0-9]+ \(file\):
\$<TARGET_OBJECTS:foo>
- Objects of target "foo" referenced but is not an OBJECT library.
+ Objects of target "foo" referenced but is not an allowed library types
+ \(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT\).
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake
index daa7c49ca..84825feea 100644
--- a/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake
+++ b/Tests/RunCMake/File_Generate/OutputNameMatchesObjects.cmake
@@ -1,11 +1,8 @@
enable_language(CXX)
file(GENERATE
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<BOOL:$<TARGET_OBJECTS:foo>>somefile.cpp"
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<LOWER_CASE:$<CONFIG>/somefile.cpp"
CONTENT "static const char content[] = \"$<TARGET_OBJECTS:foo>\";\n"
)
-add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/input.txt"
- COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/input.txt" "${CMAKE_CURRENT_BINARY_DIR}")
-
-add_executable(foo empty.cpp "${CMAKE_CURRENT_BINARY_DIR}/1somefile.cpp" "${CMAKE_CURRENT_BINARY_DIR}/input.txt")
+add_library(foo INTERFACE )
diff --git a/Tests/RunCMake/File_Generate/OutputNameMatchesOtherSources-result.txt b/Tests/RunCMake/File_Generate/OutputNameMatchesOtherSources-result.txt
deleted file mode 100644
index 573541ac9..000000000
--- a/Tests/RunCMake/File_Generate/OutputNameMatchesOtherSources-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/Tests/RunCMake/File_Generate/ReRunCMake-result.txt b/Tests/RunCMake/File_Generate/ReRunCMake-result.txt
deleted file mode 100644
index 573541ac9..000000000
--- a/Tests/RunCMake/File_Generate/ReRunCMake-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/Tests/RunCMake/File_Generate/ReRunCMake.cmake b/Tests/RunCMake/File_Generate/ReRunCMake.cmake
index 109d60e6f..541d86df2 100644
--- a/Tests/RunCMake/File_Generate/ReRunCMake.cmake
+++ b/Tests/RunCMake/File_Generate/ReRunCMake.cmake
@@ -1,5 +1,5 @@
file(GENERATE
- OUTPUT output_file.txt
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output_file.txt"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/input_file.txt"
)
diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
index 82e903d82..94aaca84a 100644
--- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
+++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
@@ -1,7 +1,11 @@
include(RunCMake)
+run_cmake(CMP0070-NEW)
+run_cmake(CMP0070-OLD)
+run_cmake(CMP0070-WARN)
+
run_cmake(CommandConflict)
-if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode")
+if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
run_cmake(OutputConflict)
endif()
run_cmake(EmptyCondition1)
@@ -17,15 +21,13 @@ if (NOT file_contents MATCHES "generated.cpp.rule")
message(SEND_ERROR "Rule file not in target sources! ${file_contents}")
endif()
-if (NOT RunCMake_GENERATOR MATCHES "Visual Studio")
- run_cmake(COMPILE_LANGUAGE-genex)
- foreach(l CXX C)
- file(READ "${RunCMake_BINARY_DIR}/COMPILE_LANGUAGE-genex-build/opts-${l}.txt" l_defs)
- if (NOT l_defs STREQUAL "LANG_IS_${l}\n")
- message(FATAL_ERROR "File content does not match: ${l_defs}")
- endif()
- endforeach()
-endif()
+run_cmake(COMPILE_LANGUAGE-genex)
+foreach(l CXX C)
+ file(READ "${RunCMake_BINARY_DIR}/COMPILE_LANGUAGE-genex-build/opts-${l}.txt" l_defs)
+ if (NOT l_defs STREQUAL "LANG_IS_${l}\n")
+ message(FATAL_ERROR "File content does not match: ${l_defs}")
+ endif()
+endforeach()
set(timeformat "%Y%j%H%M%S")
diff --git a/Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt b/Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt
deleted file mode 100644
index 573541ac9..000000000
--- a/Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake b/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake
index d1d832a11..bb36a4c48 100644
--- a/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake
+++ b/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake
@@ -1,5 +1,5 @@
file(GENERATE
- OUTPUT output_file.txt
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/output_file.txt
CONTENT "123"
)
diff --git a/Tests/RunCMake/File_Generate/relative-input-NEW.txt b/Tests/RunCMake/File_Generate/relative-input-NEW.txt
new file mode 100644
index 000000000..7293e904a
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/relative-input-NEW.txt
@@ -0,0 +1 @@
+relative-input-NEW
diff --git a/Tests/RunCMake/FindBoost/CMP0093-NEW-stdout.txt b/Tests/RunCMake/FindBoost/CMP0093-NEW-stdout.txt
new file mode 100644
index 000000000..62a6d39cb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMP0093-NEW-stdout.txt
@@ -0,0 +1 @@
+-- Boost_VERSION=1.70.0
diff --git a/Tests/RunCMake/FindBoost/CMP0093-NEW.cmake b/Tests/RunCMake/FindBoost/CMP0093-NEW.cmake
new file mode 100644
index 000000000..64f44d25b
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMP0093-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0093 NEW)
+include(ModuleMode.cmake)
diff --git a/Tests/RunCMake/FindBoost/CMP0093-OLD-stdout.txt b/Tests/RunCMake/FindBoost/CMP0093-OLD-stdout.txt
new file mode 100644
index 000000000..9e51e35c8
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMP0093-OLD-stdout.txt
@@ -0,0 +1 @@
+-- Boost_VERSION=107000
diff --git a/Tests/RunCMake/FindBoost/CMP0093-OLD.cmake b/Tests/RunCMake/FindBoost/CMP0093-OLD.cmake
new file mode 100644
index 000000000..69a3a9542
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMP0093-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0093 OLD)
+include(ModuleMode.cmake)
diff --git a/Tests/RunCMake/FindBoost/CMP0093-UNSET-stdout.txt b/Tests/RunCMake/FindBoost/CMP0093-UNSET-stdout.txt
new file mode 100644
index 000000000..9e51e35c8
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMP0093-UNSET-stdout.txt
@@ -0,0 +1 @@
+-- Boost_VERSION=107000
diff --git a/Tests/RunCMake/FindBoost/CMP0093-UNSET.cmake b/Tests/RunCMake/FindBoost/CMP0093-UNSET.cmake
new file mode 100644
index 000000000..974094a0e
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMP0093-UNSET.cmake
@@ -0,0 +1 @@
+include(ModuleMode.cmake)
diff --git a/Tests/RunCMake/FindBoost/CMakeLists.txt b/Tests/RunCMake/FindBoost/CMakeLists.txt
new file mode 100644
index 000000000..d3137f614
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.9)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt b/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt
new file mode 100644
index 000000000..ebd723258
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt
@@ -0,0 +1,2 @@
+-- Found Boost: [^
+]* \(found suitable version "1\.12345", minimum required is "1\.12345"\) found components: date_time
diff --git a/Tests/RunCMake/FindBoost/CMakePackage.cmake b/Tests/RunCMake/FindBoost/CMakePackage.cmake
new file mode 100644
index 000000000..06aeccb2d
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage.cmake
@@ -0,0 +1,2 @@
+set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackage)
+find_package(Boost 1.12345 COMPONENTS date_time)
diff --git a/Tests/RunCMake/FindBoost/CMakePackage/BoostConfig.cmake b/Tests/RunCMake/FindBoost/CMakePackage/BoostConfig.cmake
new file mode 100644
index 000000000..36a9abd5c
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage/BoostConfig.cmake
@@ -0,0 +1,4 @@
+set(Boost_DATE_TIME_FOUND 1)
+add_library(Boost::boost INTERFACE IMPORTED)
+add_library(Boost::headers INTERFACE IMPORTED)
+add_library(Boost::date_time UNKNOWN IMPORTED)
diff --git a/Tests/RunCMake/FindBoost/CMakePackage/BoostConfigVersion.cmake b/Tests/RunCMake/FindBoost/CMakePackage/BoostConfigVersion.cmake
new file mode 100644
index 000000000..8176ced19
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage/BoostConfigVersion.cmake
@@ -0,0 +1,7 @@
+set(PACKAGE_VERSION 1.12345)
+if(PACKAGE_FIND_VERSION_MAJOR EQUAL 1)
+ set(PACKAGE_VERSION_COMPATIBLE 1)
+ if(PACKAGE_FIND_VERSION_MINOR EQUAL 12345)
+ set(PACKAGE_VERSION_EXACT 1)
+ endif()
+endif()
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfig.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfig.cmake
new file mode 100644
index 000000000..539267d92
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfig.cmake
@@ -0,0 +1,140 @@
+# Copyright 2019 Peter Dimov
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
+
+# This CMake configuration file, installed as part of the Boost build
+# and installation procedure done by `b2 install`, provides support
+# for find_package(Boost).
+#
+# It's roughly, but not perfectly, compatible with the behavior
+# of find_package(Boost) as provided by FindBoost.cmake.
+#
+# A typical use might be
+#
+# find_package(Boost 1.70 REQUIRED COMPONENTS filesystem regex PATHS C:/Boost)
+#
+# On success, the above invocation would define the targets Boost::headers,
+# Boost::filesystem and Boost::regex. Boost::headers represents all
+# header-only libraries. An alias, Boost::boost, for Boost::headers is
+# provided for compatibility.
+#
+# Since Boost libraries can coexist in many variants - 32/64 bit,
+# static/dynamic runtime, debug/release, the following variables can be used
+# to control which variant is chosen:
+#
+# Boost_USE_DEBUG_LIBS: When OFF, disables debug libraries.
+# Boost_USE_RELEASE_LIBS: When OFF, disables release libraries.
+# Boost_USE_STATIC_LIBS: When ON, uses static Boost libraries; when OFF,
+# uses shared Boost libraries; when not set, the
+# default is to use shared when BUILD_SHARED_LIBS is
+# ON, static otherwise.
+# Boost_USE_STATIC_RUNTIME: When ON, uses Boost libraries linked against the
+# static runtime. The default is shared runtime.
+# Boost_USE_DEBUG_RUNTIME: When ON, uses Boost libraries linked against the
+# debug runtime. When OFF, against the release
+# runtime. The default is to use either.
+# Boost_COMPILER: The compiler that has been used to build Boost,
+# such as vc141, gcc7, clang37. The default is
+# determined from CMAKE_CXX_COMPILER_ID.
+
+message(STATUS "Found Boost ${Boost_VERSION} at ${Boost_DIR}")
+
+# Output requested configuration (f.ex. "REQUIRED COMPONENTS filesystem")
+
+if(Boost_FIND_QUIETLY)
+ set(_BOOST_CONFIG "${_BOOST_CONFIG} QUIET")
+endif()
+
+if(Boost_FIND_REQUIRED)
+ set(_BOOST_CONFIG "${_BOOST_CONFIG} REQUIRED")
+endif()
+
+foreach(__boost_comp IN LISTS Boost_FIND_COMPONENTS)
+ if(${Boost_FIND_REQUIRED_${__boost_comp}})
+ list(APPEND _BOOST_COMPONENTS ${__boost_comp})
+ else()
+ list(APPEND _BOOST_OPTIONAL_COMPONENTS ${__boost_comp})
+ endif()
+endforeach()
+
+if(_BOOST_COMPONENTS)
+ set(_BOOST_CONFIG "${_BOOST_CONFIG} COMPONENTS ${_BOOST_COMPONENTS}")
+endif()
+
+if(_BOOST_OPTIONAL_COMPONENTS)
+ set(_BOOST_CONFIG "${_BOOST_CONFIG} OPTIONAL_COMPONENTS ${_BOOST_OPTIONAL_COMPONENTS}")
+endif()
+
+if(_BOOST_CONFIG)
+ message(STATUS " Requested configuration:${_BOOST_CONFIG}")
+endif()
+
+unset(_BOOST_CONFIG)
+unset(_BOOST_COMPONENTS)
+unset(_BOOST_OPTIONAL_COMPONENTS)
+
+# find_dependency doesn't forward arguments until 3.9, so we have to roll our own
+
+macro(boost_find_dependency dep req)
+
+ set(_BOOST_QUIET)
+ if(Boost_FIND_QUIETLY)
+ set(_BOOST_QUIET QUIET)
+ endif()
+
+ set(_BOOST_REQUIRED)
+ if(${req} AND Boost_FIND_REQUIRED)
+ set(_BOOST_REQUIRED REQUIRED)
+ endif()
+
+ get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE)
+
+ if(Boost_DEBUG)
+ message(STATUS "BoostConfig: find_package(boost_${dep} ${Boost_VERSION} EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR})")
+ endif()
+ find_package(boost_${dep} ${Boost_VERSION} EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR})
+
+ string(TOUPPER ${dep} _BOOST_DEP)
+ set(Boost_${_BOOST_DEP}_FOUND ${boost_${dep}_FOUND})
+
+ unset(_BOOST_REQUIRED)
+ unset(_BOOST_QUIET)
+ unset(_BOOST_CMAKEDIR)
+ unset(_BOOST_DEP)
+
+endmacro()
+
+# Find boost_headers
+
+boost_find_dependency(headers 1)
+
+if(NOT boost_headers_FOUND)
+
+ set(Boost_FOUND 0)
+ set(Boost_NOT_FOUND_MESSAGE "A required dependency, boost_headers, has not been found.")
+
+ return()
+
+endif()
+
+# Find components
+
+foreach(__boost_comp IN LISTS Boost_FIND_COMPONENTS)
+
+ boost_find_dependency(${__boost_comp} ${Boost_FIND_REQUIRED_${__boost_comp}})
+
+endforeach()
+
+# Compatibility targets
+
+if(NOT TARGET Boost::boost)
+
+ add_library(Boost::boost INTERFACE IMPORTED)
+ set_property(TARGET Boost::boost APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::headers)
+
+ # All Boost:: targets already disable autolink
+ add_library(Boost::diagnostic_definitions INTERFACE IMPORTED)
+ add_library(Boost::disable_autolinking INTERFACE IMPORTED)
+ add_library(Boost::dynamic_linking INTERFACE IMPORTED)
+
+endif()
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfigVersion.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfigVersion.cmake
new file mode 100644
index 000000000..114bba078
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/Boost-1.70.0/BoostConfigVersion.cmake
@@ -0,0 +1,12 @@
+# Generated by Boost 1.70.0
+
+set(PACKAGE_VERSION 1.70.0)
+
+if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/BoostDetectToolset-1.70.0.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/BoostDetectToolset-1.70.0.cmake
new file mode 100644
index 000000000..2f1ac0199
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/BoostDetectToolset-1.70.0.cmake
@@ -0,0 +1 @@
+set(BOOST_DETECTED_TOOLSET "gcc7")
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config-version.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config-version.cmake
new file mode 100644
index 000000000..114bba078
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config-version.cmake
@@ -0,0 +1,12 @@
+# Generated by Boost 1.70.0
+
+set(PACKAGE_VERSION 1.70.0)
+
+if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config.cmake
new file mode 100644
index 000000000..5d798b52a
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/boost_chrono-config.cmake
@@ -0,0 +1,98 @@
+# Generated by Boost 1.70.0
+
+if(TARGET Boost::chrono)
+ return()
+endif()
+
+message(STATUS "Found boost_chrono ${boost_chrono_VERSION} at ${boost_chrono_DIR}")
+
+# Compute the include and library directories relative to this file.
+get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE)
+get_filename_component(_BOOST_INCLUDEDIR "${_BOOST_CMAKEDIR}/../../include/" ABSOLUTE)
+get_filename_component(_BOOST_LIBDIR "${_BOOST_CMAKEDIR}/../" ABSOLUTE)
+
+# Create imported target Boost::chrono
+add_library(Boost::chrono UNKNOWN IMPORTED)
+
+set_target_properties(Boost::chrono PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${_BOOST_INCLUDEDIR}"
+ INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB"
+)
+
+include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-1.70.0.cmake)
+
+if(Boost_DEBUG)
+ message(STATUS "Scanning ${CMAKE_CURRENT_LIST_DIR}/libboost_chrono-variant*.cmake")
+endif()
+
+file(GLOB __boost_variants "${CMAKE_CURRENT_LIST_DIR}/libboost_chrono-variant*.cmake")
+
+macro(_BOOST_SKIPPED fname reason)
+ if(Boost_DEBUG)
+ message(STATUS " ... skipped ${fname} (${reason})")
+ endif()
+ list(APPEND __boost_skipped "${fname} (${reason})")
+endmacro()
+
+foreach(f IN LISTS __boost_variants)
+ if(Boost_DEBUG)
+ message(STATUS " Including ${f}")
+ endif()
+ include(${f})
+endforeach()
+
+unset(_BOOST_LIBDIR)
+unset(_BOOST_INCLUDEDIR)
+unset(_BOOST_CMAKEDIR)
+
+get_target_property(__boost_configs Boost::chrono IMPORTED_CONFIGURATIONS)
+
+if(__boost_variants AND NOT __boost_configs)
+ message(STATUS "No suitable boost_chrono variant has been identified!")
+ if(NOT Boost_DEBUG)
+ foreach(s IN LISTS __boost_skipped)
+ message(STATUS " ${s}")
+ endforeach()
+ endif()
+ set(boost_chrono_FOUND 0)
+ set(boost_chrono_NOT_FOUND_MESSAGE "No suitable build variant has been found.")
+ unset(__boost_skipped)
+ unset(__boost_configs)
+ unset(__boost_variants)
+ unset(_BOOST_CHRONO_DEPS)
+ return()
+endif()
+
+unset(__boost_skipped)
+unset(__boost_configs)
+unset(__boost_variants)
+
+if(_BOOST_CHRONO_DEPS)
+ list(REMOVE_DUPLICATES _BOOST_CHRONO_DEPS)
+ message(STATUS "Adding boost_chrono dependencies: ${_BOOST_CHRONO_DEPS}")
+endif()
+
+foreach(dep_boost_chrono IN LISTS _BOOST_CHRONO_DEPS)
+ set(_BOOST_QUIET)
+ if(boost_chrono_FIND_QUIETLY)
+ set(_BOOST_QUIET QUIET)
+ endif()
+ set(_BOOST_REQUIRED)
+ if(boost_chrono_FIND_REQUIRED)
+ set(_BOOST_REQUIRED REQUIRED)
+ endif()
+ get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE)
+ find_package(boost_${dep_boost_chrono} 1.70.0 EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR})
+ set_property(TARGET Boost::chrono APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::${dep_boost_chrono})
+ unset(_BOOST_QUIET)
+ unset(_BOOST_REQUIRED)
+ unset(_BOOST_CMAKEDIR)
+ if(NOT boost_${dep_boost_chrono}_FOUND)
+ set(boost_chrono_FOUND 0)
+ set(boost_chrono_NOT_FOUND_MESSAGE "A required dependency, boost_${dep_boost_chrono}, has not been found.")
+ unset(_BOOST_CHRONO_DEPS)
+ return()
+ endif()
+endforeach()
+
+unset(_BOOST_CHRONO_DEPS)
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-shared.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-shared.cmake
new file mode 100644
index 000000000..7f07aed47
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-shared.cmake
@@ -0,0 +1,62 @@
+# Generated by Boost 1.70.0
+
+# address-model=64
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ _BOOST_SKIPPED("libboost_chrono.so.1.70.0" "64 bit, need 32")
+ return()
+endif()
+
+# layout=system
+
+# toolset=gcc8
+
+# link=shared
+
+if(NOT "${Boost_USE_STATIC_LIBS}" STREQUAL "" AND Boost_USE_STATIC_LIBS)
+ _BOOST_SKIPPED("libboost_chrono.so.1.70.0" "shared, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}")
+ return()
+endif()
+
+if(NOT BUILD_SHARED_LIBS)
+ _BOOST_SKIPPED("libboost_chrono.so.1.70.0" "shared, BUILD_SHARED_LIBS not ON, set Boost_USE_STATIC_LIBS=OFF to override")
+ return()
+endif()
+
+# runtime-link=shared
+
+if(Boost_USE_STATIC_RUNTIME)
+ _BOOST_SKIPPED("libboost_chrono.so.1.70.0" "shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}")
+ return()
+endif()
+
+# runtime-debugging=off
+
+if(Boost_USE_DEBUG_RUNTIME)
+ _BOOST_SKIPPED("libboost_chrono.so.1.70.0" "release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}")
+ return()
+endif()
+
+# threading=multi
+
+# variant=release
+
+if(NOT "${Boost_USE_RELEASE_LIBS}" STREQUAL "" AND NOT Boost_USE_RELEASE_LIBS)
+ _BOOST_SKIPPED("libboost_chrono.so.1.70.0" "release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}")
+ return()
+endif()
+
+message(STATUS " libboost_chrono.so.1.70.0")
+
+# Target file name: libboost_chrono.so.1.70.0
+set_property(TARGET Boost::chrono APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(Boost::chrono PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE CXX
+ IMPORTED_LOCATION_RELEASE "${_BOOST_LIBDIR}/libboost_chrono.so.1.70.0"
+ )
+
+set_target_properties(Boost::chrono PROPERTIES
+ INTERFACE_COMPILE_DEFINITIONS "BOOST_CHRONO_DYN_LINK"
+ )
+
+list(APPEND _BOOST_CHRONO_DEPS headers)
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-static.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-static.cmake
new file mode 100644
index 000000000..d7477b4d7
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_chrono-1.70.0/libboost_chrono-variant-static.cmake
@@ -0,0 +1,58 @@
+# Generated by Boost 1.70.0
+
+# address-model=64
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ _BOOST_SKIPPED("libboost_chrono.a" "64 bit, need 32")
+ return()
+endif()
+
+# layout=system
+
+# toolset=gcc8
+
+# link=static
+
+if(NOT "${Boost_USE_STATIC_LIBS}" STREQUAL "" AND NOT Boost_USE_STATIC_LIBS)
+ _BOOST_SKIPPED("libboost_chrono.a" "static, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}")
+ return()
+endif()
+
+if(BUILD_SHARED_LIBS)
+ _BOOST_SKIPPED("libboost_chrono.a" "static, BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}, set Boost_USE_STATIC_LIBS=ON to override")
+ return()
+endif()
+
+# runtime-link=shared
+
+if(Boost_USE_STATIC_RUNTIME)
+ _BOOST_SKIPPED("libboost_chrono.a" "shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}")
+ return()
+endif()
+
+# runtime-debugging=off
+
+if(Boost_USE_DEBUG_RUNTIME)
+ _BOOST_SKIPPED("libboost_chrono.a" "release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}")
+ return()
+endif()
+
+# threading=multi
+
+# variant=release
+
+if(NOT "${Boost_USE_RELEASE_LIBS}" STREQUAL "" AND NOT Boost_USE_RELEASE_LIBS)
+ _BOOST_SKIPPED("libboost_chrono.a" "release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}")
+ return()
+endif()
+
+message(STATUS " libboost_chrono.a")
+
+# Target file name: libboost_chrono.a
+set_property(TARGET Boost::chrono APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(Boost::chrono PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE CXX
+ IMPORTED_LOCATION_RELEASE "${_BOOST_LIBDIR}/libboost_chrono.a"
+ )
+
+list(APPEND _BOOST_CHRONO_DEPS headers)
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config-version.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config-version.cmake
new file mode 100644
index 000000000..114bba078
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config-version.cmake
@@ -0,0 +1,12 @@
+# Generated by Boost 1.70.0
+
+set(PACKAGE_VERSION 1.70.0)
+
+if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config.cmake
new file mode 100644
index 000000000..0305ecd5c
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_headers-1.70.0/boost_headers-config.cmake
@@ -0,0 +1,20 @@
+# Generated by Boost 1.70.0
+
+if(TARGET Boost::headers)
+ return()
+endif()
+
+message(STATUS "Found boost_headers ${boost_headers_VERSION} at ${boost_headers_DIR}")
+
+# Compute the include and library directories relative to this file.
+get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE)
+get_filename_component(_BOOST_INCLUDEDIR "${_BOOST_CMAKEDIR}/../../include/" ABSOLUTE)
+get_filename_component(_BOOST_LIBDIR "${_BOOST_CMAKEDIR}/../" ABSOLUTE)
+
+# Create imported target Boost::headers
+add_library(Boost::headers INTERFACE IMPORTED)
+
+set_target_properties(Boost::headers PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${_BOOST_INCLUDEDIR}"
+ INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB"
+)
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config-version.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config-version.cmake
new file mode 100644
index 000000000..114bba078
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config-version.cmake
@@ -0,0 +1,12 @@
+# Generated by Boost 1.70.0
+
+set(PACKAGE_VERSION 1.70.0)
+
+if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config.cmake
new file mode 100644
index 000000000..40b10d0c6
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/boost_system-config.cmake
@@ -0,0 +1,98 @@
+# Generated by Boost 1.70.0
+
+if(TARGET Boost::system)
+ return()
+endif()
+
+message(STATUS "Found boost_system ${boost_system_VERSION} at ${boost_system_DIR}")
+
+# Compute the include and library directories relative to this file.
+get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE)
+get_filename_component(_BOOST_INCLUDEDIR "${_BOOST_CMAKEDIR}/../../include/" ABSOLUTE)
+get_filename_component(_BOOST_LIBDIR "${_BOOST_CMAKEDIR}/../" ABSOLUTE)
+
+# Create imported target Boost::system
+add_library(Boost::system UNKNOWN IMPORTED)
+
+set_target_properties(Boost::system PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${_BOOST_INCLUDEDIR}"
+ INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB"
+)
+
+include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-1.70.0.cmake)
+
+if(Boost_DEBUG)
+ message(STATUS "Scanning ${CMAKE_CURRENT_LIST_DIR}/libboost_system-variant*.cmake")
+endif()
+
+file(GLOB __boost_variants "${CMAKE_CURRENT_LIST_DIR}/libboost_system-variant*.cmake")
+
+macro(_BOOST_SKIPPED fname reason)
+ if(Boost_DEBUG)
+ message(STATUS " ... skipped ${fname} (${reason})")
+ endif()
+ list(APPEND __boost_skipped "${fname} (${reason})")
+endmacro()
+
+foreach(f IN LISTS __boost_variants)
+ if(Boost_DEBUG)
+ message(STATUS " Including ${f}")
+ endif()
+ include(${f})
+endforeach()
+
+unset(_BOOST_LIBDIR)
+unset(_BOOST_INCLUDEDIR)
+unset(_BOOST_CMAKEDIR)
+
+get_target_property(__boost_configs Boost::system IMPORTED_CONFIGURATIONS)
+
+if(__boost_variants AND NOT __boost_configs)
+ message(STATUS "No suitable boost_system variant has been identified!")
+ if(NOT Boost_DEBUG)
+ foreach(s IN LISTS __boost_skipped)
+ message(STATUS " ${s}")
+ endforeach()
+ endif()
+ set(boost_system_FOUND 0)
+ set(boost_system_NOT_FOUND_MESSAGE "No suitable build variant has been found.")
+ unset(__boost_skipped)
+ unset(__boost_configs)
+ unset(__boost_variants)
+ unset(_BOOST_SYSTEM_DEPS)
+ return()
+endif()
+
+unset(__boost_skipped)
+unset(__boost_configs)
+unset(__boost_variants)
+
+if(_BOOST_SYSTEM_DEPS)
+ list(REMOVE_DUPLICATES _BOOST_SYSTEM_DEPS)
+ message(STATUS "Adding boost_system dependencies: ${_BOOST_SYSTEM_DEPS}")
+endif()
+
+foreach(dep_boost_system IN LISTS _BOOST_SYSTEM_DEPS)
+ set(_BOOST_QUIET)
+ if(boost_system_FIND_QUIETLY)
+ set(_BOOST_QUIET QUIET)
+ endif()
+ set(_BOOST_REQUIRED)
+ if(boost_system_FIND_REQUIRED)
+ set(_BOOST_REQUIRED REQUIRED)
+ endif()
+ get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE)
+ find_package(boost_${dep_boost_system} 1.70.0 EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR})
+ set_property(TARGET Boost::system APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::${dep_boost_system})
+ unset(_BOOST_QUIET)
+ unset(_BOOST_REQUIRED)
+ unset(_BOOST_CMAKEDIR)
+ if(NOT boost_${dep_boost_system}_FOUND)
+ set(boost_system_FOUND 0)
+ set(boost_system_NOT_FOUND_MESSAGE "A required dependency, boost_${dep_boost_system}, has not been found.")
+ unset(_BOOST_SYSTEM_DEPS)
+ return()
+ endif()
+endforeach()
+
+unset(_BOOST_SYSTEM_DEPS)
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-shared.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-shared.cmake
new file mode 100644
index 000000000..751db32c3
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-shared.cmake
@@ -0,0 +1,62 @@
+# Generated by Boost 1.70.0
+
+# address-model=64
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ _BOOST_SKIPPED("libboost_system.so.1.70.0" "64 bit, need 32")
+ return()
+endif()
+
+# layout=system
+
+# toolset=gcc8
+
+# link=shared
+
+if(NOT "${Boost_USE_STATIC_LIBS}" STREQUAL "" AND Boost_USE_STATIC_LIBS)
+ _BOOST_SKIPPED("libboost_system.so.1.70.0" "shared, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}")
+ return()
+endif()
+
+if(NOT BUILD_SHARED_LIBS)
+ _BOOST_SKIPPED("libboost_system.so.1.70.0" "shared, BUILD_SHARED_LIBS not ON, set Boost_USE_STATIC_LIBS=OFF to override")
+ return()
+endif()
+
+# runtime-link=shared
+
+if(Boost_USE_STATIC_RUNTIME)
+ _BOOST_SKIPPED("libboost_system.so.1.70.0" "shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}")
+ return()
+endif()
+
+# runtime-debugging=off
+
+if(Boost_USE_DEBUG_RUNTIME)
+ _BOOST_SKIPPED("libboost_system.so.1.70.0" "release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}")
+ return()
+endif()
+
+# threading=multi
+
+# variant=release
+
+if(NOT "${Boost_USE_RELEASE_LIBS}" STREQUAL "" AND NOT Boost_USE_RELEASE_LIBS)
+ _BOOST_SKIPPED("libboost_system.so.1.70.0" "release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}")
+ return()
+endif()
+
+message(STATUS " libboost_system.so.1.70.0")
+
+# Target file name: libboost_system.so.1.70.0
+set_property(TARGET Boost::system APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(Boost::system PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE CXX
+ IMPORTED_LOCATION_RELEASE "${_BOOST_LIBDIR}/libboost_system.so.1.70.0"
+ )
+
+set_target_properties(Boost::system PROPERTIES
+ INTERFACE_COMPILE_DEFINITIONS "BOOST_SYSTEM_DYN_LINK"
+ )
+
+list(APPEND _BOOST_SYSTEM_DEPS headers)
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-static.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-static.cmake
new file mode 100644
index 000000000..b10e0b9e3
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_system-1.70.0/libboost_system-variant-static.cmake
@@ -0,0 +1,58 @@
+# Generated by Boost 1.70.0
+
+# address-model=64
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ _BOOST_SKIPPED("libboost_system.a" "64 bit, need 32")
+ return()
+endif()
+
+# layout=system
+
+# toolset=gcc8
+
+# link=static
+
+if(NOT "${Boost_USE_STATIC_LIBS}" STREQUAL "" AND NOT Boost_USE_STATIC_LIBS)
+ _BOOST_SKIPPED("libboost_system.a" "static, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}")
+ return()
+endif()
+
+if(BUILD_SHARED_LIBS)
+ _BOOST_SKIPPED("libboost_system.a" "static, BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}, set Boost_USE_STATIC_LIBS=ON to override")
+ return()
+endif()
+
+# runtime-link=shared
+
+if(Boost_USE_STATIC_RUNTIME)
+ _BOOST_SKIPPED("libboost_system.a" "shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}")
+ return()
+endif()
+
+# runtime-debugging=off
+
+if(Boost_USE_DEBUG_RUNTIME)
+ _BOOST_SKIPPED("libboost_system.a" "release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}")
+ return()
+endif()
+
+# threading=multi
+
+# variant=release
+
+if(NOT "${Boost_USE_RELEASE_LIBS}" STREQUAL "" AND NOT Boost_USE_RELEASE_LIBS)
+ _BOOST_SKIPPED("libboost_system.a" "release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}")
+ return()
+endif()
+
+message(STATUS " libboost_system.a")
+
+# Target file name: libboost_system.a
+set_property(TARGET Boost::system APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(Boost::system PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE CXX
+ IMPORTED_LOCATION_RELEASE "${_BOOST_LIBDIR}/libboost_system.a"
+ )
+
+list(APPEND _BOOST_SYSTEM_DEPS headers)
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config-version.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config-version.cmake
new file mode 100644
index 000000000..114bba078
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config-version.cmake
@@ -0,0 +1,12 @@
+# Generated by Boost 1.70.0
+
+set(PACKAGE_VERSION 1.70.0)
+
+if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config.cmake
new file mode 100644
index 000000000..b0d0e5403
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/boost_timer-config.cmake
@@ -0,0 +1,98 @@
+# Generated by Boost 1.70.0
+
+if(TARGET Boost::timer)
+ return()
+endif()
+
+message(STATUS "Found boost_timer ${boost_timer_VERSION} at ${boost_timer_DIR}")
+
+# Compute the include and library directories relative to this file.
+get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE)
+get_filename_component(_BOOST_INCLUDEDIR "${_BOOST_CMAKEDIR}/../../include/" ABSOLUTE)
+get_filename_component(_BOOST_LIBDIR "${_BOOST_CMAKEDIR}/../" ABSOLUTE)
+
+# Create imported target Boost::timer
+add_library(Boost::timer UNKNOWN IMPORTED)
+
+set_target_properties(Boost::timer PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${_BOOST_INCLUDEDIR}"
+ INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB"
+)
+
+include(${CMAKE_CURRENT_LIST_DIR}/../BoostDetectToolset-1.70.0.cmake)
+
+if(Boost_DEBUG)
+ message(STATUS "Scanning ${CMAKE_CURRENT_LIST_DIR}/libboost_timer-variant*.cmake")
+endif()
+
+file(GLOB __boost_variants "${CMAKE_CURRENT_LIST_DIR}/libboost_timer-variant*.cmake")
+
+macro(_BOOST_SKIPPED fname reason)
+ if(Boost_DEBUG)
+ message(STATUS " ... skipped ${fname} (${reason})")
+ endif()
+ list(APPEND __boost_skipped "${fname} (${reason})")
+endmacro()
+
+foreach(f IN LISTS __boost_variants)
+ if(Boost_DEBUG)
+ message(STATUS " Including ${f}")
+ endif()
+ include(${f})
+endforeach()
+
+unset(_BOOST_LIBDIR)
+unset(_BOOST_INCLUDEDIR)
+unset(_BOOST_CMAKEDIR)
+
+get_target_property(__boost_configs Boost::timer IMPORTED_CONFIGURATIONS)
+
+if(__boost_variants AND NOT __boost_configs)
+ message(STATUS "No suitable boost_timer variant has been identified!")
+ if(NOT Boost_DEBUG)
+ foreach(s IN LISTS __boost_skipped)
+ message(STATUS " ${s}")
+ endforeach()
+ endif()
+ set(boost_timer_FOUND 0)
+ set(boost_timer_NOT_FOUND_MESSAGE "No suitable build variant has been found.")
+ unset(__boost_skipped)
+ unset(__boost_configs)
+ unset(__boost_variants)
+ unset(_BOOST_TIMER_DEPS)
+ return()
+endif()
+
+unset(__boost_skipped)
+unset(__boost_configs)
+unset(__boost_variants)
+
+if(_BOOST_TIMER_DEPS)
+ list(REMOVE_DUPLICATES _BOOST_TIMER_DEPS)
+ message(STATUS "Adding boost_timer dependencies: ${_BOOST_TIMER_DEPS}")
+endif()
+
+foreach(dep_boost_timer IN LISTS _BOOST_TIMER_DEPS)
+ set(_BOOST_QUIET)
+ if(boost_timer_FIND_QUIETLY)
+ set(_BOOST_QUIET QUIET)
+ endif()
+ set(_BOOST_REQUIRED)
+ if(boost_timer_FIND_REQUIRED)
+ set(_BOOST_REQUIRED REQUIRED)
+ endif()
+ get_filename_component(_BOOST_CMAKEDIR "${CMAKE_CURRENT_LIST_DIR}/../" ABSOLUTE)
+ find_package(boost_${dep_boost_timer} 1.70.0 EXACT CONFIG ${_BOOST_REQUIRED} ${_BOOST_QUIET} HINTS ${_BOOST_CMAKEDIR})
+ set_property(TARGET Boost::timer APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::${dep_boost_timer})
+ unset(_BOOST_QUIET)
+ unset(_BOOST_REQUIRED)
+ unset(_BOOST_CMAKEDIR)
+ if(NOT boost_${dep_boost_timer}_FOUND)
+ set(boost_timer_FOUND 0)
+ set(boost_timer_NOT_FOUND_MESSAGE "A required dependency, boost_${dep_boost_timer}, has not been found.")
+ unset(_BOOST_TIMER_DEPS)
+ return()
+ endif()
+endforeach()
+
+unset(_BOOST_TIMER_DEPS)
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-shared.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-shared.cmake
new file mode 100644
index 000000000..b35b59d64
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-shared.cmake
@@ -0,0 +1,62 @@
+# Generated by Boost 1.70.0
+
+# address-model=64
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ _BOOST_SKIPPED("libboost_timer.so.1.70.0" "64 bit, need 32")
+ return()
+endif()
+
+# layout=system
+
+# toolset=gcc8
+
+# link=shared
+
+if(NOT "${Boost_USE_STATIC_LIBS}" STREQUAL "" AND Boost_USE_STATIC_LIBS)
+ _BOOST_SKIPPED("libboost_timer.so.1.70.0" "shared, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}")
+ return()
+endif()
+
+if(NOT BUILD_SHARED_LIBS)
+ _BOOST_SKIPPED("libboost_timer.so.1.70.0" "shared, BUILD_SHARED_LIBS not ON, set Boost_USE_STATIC_LIBS=OFF to override")
+ return()
+endif()
+
+# runtime-link=shared
+
+if(Boost_USE_STATIC_RUNTIME)
+ _BOOST_SKIPPED("libboost_timer.so.1.70.0" "shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}")
+ return()
+endif()
+
+# runtime-debugging=off
+
+if(Boost_USE_DEBUG_RUNTIME)
+ _BOOST_SKIPPED("libboost_timer.so.1.70.0" "release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}")
+ return()
+endif()
+
+# threading=multi
+
+# variant=release
+
+if(NOT "${Boost_USE_RELEASE_LIBS}" STREQUAL "" AND NOT Boost_USE_RELEASE_LIBS)
+ _BOOST_SKIPPED("libboost_timer.so.1.70.0" "release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}")
+ return()
+endif()
+
+message(STATUS " libboost_timer.so.1.70.0")
+
+# Target file name: libboost_timer.so.1.70.0
+set_property(TARGET Boost::timer APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(Boost::timer PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE CXX
+ IMPORTED_LOCATION_RELEASE "${_BOOST_LIBDIR}/libboost_timer.so.1.70.0"
+ )
+
+set_target_properties(Boost::timer PROPERTIES
+ INTERFACE_COMPILE_DEFINITIONS "BOOST_TIMER_DYN_LINK"
+ )
+
+list(APPEND _BOOST_TIMER_DEPS chrono headers)
diff --git a/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-static.cmake b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-static.cmake
new file mode 100644
index 000000000..37fa9c0a5
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackageFixtures/boost_timer-1.70.0/libboost_timer-variant-static.cmake
@@ -0,0 +1,58 @@
+# Generated by Boost 1.70.0
+
+# address-model=64
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ _BOOST_SKIPPED("libboost_timer.a" "64 bit, need 32")
+ return()
+endif()
+
+# layout=system
+
+# toolset=gcc8
+
+# link=static
+
+if(NOT "${Boost_USE_STATIC_LIBS}" STREQUAL "" AND NOT Boost_USE_STATIC_LIBS)
+ _BOOST_SKIPPED("libboost_timer.a" "static, Boost_USE_STATIC_LIBS=${Boost_USE_STATIC_LIBS}")
+ return()
+endif()
+
+if(BUILD_SHARED_LIBS)
+ _BOOST_SKIPPED("libboost_timer.a" "static, BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}, set Boost_USE_STATIC_LIBS=ON to override")
+ return()
+endif()
+
+# runtime-link=shared
+
+if(Boost_USE_STATIC_RUNTIME)
+ _BOOST_SKIPPED("libboost_timer.a" "shared runtime, Boost_USE_STATIC_RUNTIME=${Boost_USE_STATIC_RUNTIME}")
+ return()
+endif()
+
+# runtime-debugging=off
+
+if(Boost_USE_DEBUG_RUNTIME)
+ _BOOST_SKIPPED("libboost_timer.a" "release runtime, Boost_USE_DEBUG_RUNTIME=${Boost_USE_DEBUG_RUNTIME}")
+ return()
+endif()
+
+# threading=multi
+
+# variant=release
+
+if(NOT "${Boost_USE_RELEASE_LIBS}" STREQUAL "" AND NOT Boost_USE_RELEASE_LIBS)
+ _BOOST_SKIPPED("libboost_timer.a" "release, Boost_USE_RELEASE_LIBS=${Boost_USE_RELEASE_LIBS}")
+ return()
+endif()
+
+message(STATUS " libboost_timer.a")
+
+# Target file name: libboost_timer.a
+set_property(TARGET Boost::timer APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(Boost::timer PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE CXX
+ IMPORTED_LOCATION_RELEASE "${_BOOST_LIBDIR}/libboost_timer.a"
+ )
+
+list(APPEND _BOOST_TIMER_DEPS chrono headers)
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfig.cmake b/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfig.cmake
new file mode 100644
index 000000000..cf13b4ac3
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfig.cmake
@@ -0,0 +1,26 @@
+# No boost::boost target and all targets start with lowercase letters
+# Similar to https://github.com/boost-cmake/boost-cmake
+
+add_library(boost::headers INTERFACE IMPORTED)
+target_include_directories(boost::headers INTERFACE "${CMAKE_CURRENT_LIST_DIR}/include")
+
+set(Boost_date_time_FOUND 1)
+add_library(boost::date_time UNKNOWN IMPORTED)
+set_target_properties(boost::date_time PROPERTIES
+ IMPORTED_CONFIGURATIONS RELEASE
+ IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_date_time.a"
+ )
+set(Boost_python37_FOUND 1)
+add_library(boost::python UNKNOWN IMPORTED)
+set_target_properties(boost::python PROPERTIES
+ IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
+ IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_python_release.a"
+ IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_python.a"
+ )
+set(Boost_mpi_python2_FOUND 1)
+add_library(boost::mpi_python UNKNOWN IMPORTED)
+set_target_properties(boost::mpi_python PROPERTIES
+ IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
+ IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_mpi_python.a"
+ IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_mpi_python.a"
+ )
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfigVersion.cmake b/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfigVersion.cmake
new file mode 100644
index 000000000..b4b606000
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/BoostConfigVersion.cmake
@@ -0,0 +1,7 @@
+set(PACKAGE_VERSION 1.70.42)
+if(PACKAGE_FIND_VERSION_MAJOR EQUAL 1)
+ set(PACKAGE_VERSION_COMPATIBLE 1)
+ if(PACKAGE_FIND_VERSION_MINOR EQUAL 70 AND PACKAGE_FIND_VERSION_PATCH EQUAL 42)
+ set(PACKAGE_VERSION_EXACT 1)
+ endif()
+endif()
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/include/boost/version.hpp b/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/include/boost/version.hpp
new file mode 100644
index 000000000..fe8e72c6d
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_LowerCaseTargetPrefix/include/boost/version.hpp
@@ -0,0 +1,34 @@
+// Boost version.hpp configuration header file
+// ------------------------------//
+
+// (C) Copyright John maddock 1999. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/config for documentation
+
+#ifndef BOOST_VERSION_HPP
+#define BOOST_VERSION_HPP
+
+//
+// Caution: this is the only Boost header that is guaranteed
+// to change with every Boost release. Including this header
+// will cause a recompile every time a new Boost version is
+// used.
+//
+// BOOST_VERSION % 100 is the patch level
+// BOOST_VERSION / 100 % 1000 is the minor version
+// BOOST_VERSION / 100000 is the major version
+
+#define BOOST_VERSION 1070042
+
+//
+// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
+// but as a *string* in the form "x_y[_z]" where x is the major version
+// number, y is the minor version number, and z is the patch level if not 0.
+// This is used by <config/auto_link.hpp> to select which library version to
+// link to.
+
+#define BOOST_LIB_VERSION "1_70_42"
+
+#endif
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfig.cmake b/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfig.cmake
new file mode 100644
index 000000000..97d4c797b
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfig.cmake
@@ -0,0 +1,7 @@
+# Don't have targets
+set(Boost_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/include")
+
+set(Boost_DATE_TIME_FOUND 1)
+set(Boost_DATE_TIME_LIBRARY "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_date_time.a")
+
+set(Boost_LIBRARIES ${Boost_DATE_TIME_LIBRARY})
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfigVersion.cmake b/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfigVersion.cmake
new file mode 100644
index 000000000..b4b606000
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/BoostConfigVersion.cmake
@@ -0,0 +1,7 @@
+set(PACKAGE_VERSION 1.70.42)
+if(PACKAGE_FIND_VERSION_MAJOR EQUAL 1)
+ set(PACKAGE_VERSION_COMPATIBLE 1)
+ if(PACKAGE_FIND_VERSION_MINOR EQUAL 70 AND PACKAGE_FIND_VERSION_PATCH EQUAL 42)
+ set(PACKAGE_VERSION_EXACT 1)
+ endif()
+endif()
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/include/boost/version.hpp b/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/include/boost/version.hpp
new file mode 100644
index 000000000..fe8e72c6d
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/include/boost/version.hpp
@@ -0,0 +1,34 @@
+// Boost version.hpp configuration header file
+// ------------------------------//
+
+// (C) Copyright John maddock 1999. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/config for documentation
+
+#ifndef BOOST_VERSION_HPP
+#define BOOST_VERSION_HPP
+
+//
+// Caution: this is the only Boost header that is guaranteed
+// to change with every Boost release. Including this header
+// will cause a recompile every time a new Boost version is
+// used.
+//
+// BOOST_VERSION % 100 is the patch level
+// BOOST_VERSION / 100 % 1000 is the minor version
+// BOOST_VERSION / 100000 is the major version
+
+#define BOOST_VERSION 1070042
+
+//
+// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
+// but as a *string* in the form "x_y[_z]" where x is the major version
+// number, y is the minor version number, and z is the patch level if not 0.
+// This is used by <config/auto_link.hpp> to select which library version to
+// link to.
+
+#define BOOST_LIB_VERSION "1_70_42"
+
+#endif
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfig.cmake b/Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfig.cmake
new file mode 100644
index 000000000..115151476
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfig.cmake
@@ -0,0 +1,29 @@
+add_library(Boost::boost INTERFACE IMPORTED)
+add_library(Boost::headers INTERFACE IMPORTED)
+target_include_directories(Boost::headers INTERFACE "${CMAKE_CURRENT_LIST_DIR}/include")
+
+set(Boost_date_time_FOUND 1)
+add_library(Boost::date_time UNKNOWN IMPORTED)
+set_target_properties(Boost::date_time PROPERTIES
+ IMPORTED_CONFIGURATIONS RELEASE
+ IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_date_time.a"
+ )
+
+set(Boost_python37_FOUND 1)
+add_library(Boost::python UNKNOWN IMPORTED)
+set_target_properties(Boost::python PROPERTIES
+ IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
+ IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_python_release.a"
+ IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_python.a"
+ )
+# Versioned target alias for compatibility (added by upstream BoostConfig).
+add_library(Boost::python37 INTERFACE IMPORTED)
+set_property(TARGET Boost::python37 APPEND PROPERTY INTERFACE_LINK_LIBRARIES Boost::python)
+
+set(Boost_mpi_python2_FOUND 1)
+add_library(Boost::mpi_python UNKNOWN IMPORTED)
+set_target_properties(Boost::mpi_python PROPERTIES
+ IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
+ IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_mpi_python.a"
+ IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_mpi_python.a"
+ )
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfigVersion.cmake b/Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfigVersion.cmake
new file mode 100644
index 000000000..b4b606000
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_New/BoostConfigVersion.cmake
@@ -0,0 +1,7 @@
+set(PACKAGE_VERSION 1.70.42)
+if(PACKAGE_FIND_VERSION_MAJOR EQUAL 1)
+ set(PACKAGE_VERSION_COMPATIBLE 1)
+ if(PACKAGE_FIND_VERSION_MINOR EQUAL 70 AND PACKAGE_FIND_VERSION_PATCH EQUAL 42)
+ set(PACKAGE_VERSION_EXACT 1)
+ endif()
+endif()
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/include/boost/version.hpp b/Tests/RunCMake/FindBoost/CMakePackage_New/include/boost/version.hpp
new file mode 100644
index 000000000..fe8e72c6d
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_New/include/boost/version.hpp
@@ -0,0 +1,34 @@
+// Boost version.hpp configuration header file
+// ------------------------------//
+
+// (C) Copyright John maddock 1999. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/config for documentation
+
+#ifndef BOOST_VERSION_HPP
+#define BOOST_VERSION_HPP
+
+//
+// Caution: this is the only Boost header that is guaranteed
+// to change with every Boost release. Including this header
+// will cause a recompile every time a new Boost version is
+// used.
+//
+// BOOST_VERSION % 100 is the patch level
+// BOOST_VERSION / 100 % 1000 is the minor version
+// BOOST_VERSION / 100000 is the major version
+
+#define BOOST_VERSION 1070042
+
+//
+// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
+// but as a *string* in the form "x_y[_z]" where x is the major version
+// number, y is the minor version number, and z is the patch level if not 0.
+// This is used by <config/auto_link.hpp> to select which library version to
+// link to.
+
+#define BOOST_LIB_VERSION "1_70_42"
+
+#endif
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_date_time.a b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_date_time.a
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_date_time.a
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_mpi_python.a b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_mpi_python.a
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_mpi_python.a
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python.a b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python.a
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python.a
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python_release.a b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python_release.a
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_New/lib/libboost_python_release.a
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfig.cmake b/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfig.cmake
new file mode 100644
index 000000000..ba2269adb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfig.cmake
@@ -0,0 +1,25 @@
+# UPPER_CASE FOUND vars and no header targets
+
+set(Boost_DATE_TIME_FOUND 1)
+add_library(Boost::date_time UNKNOWN IMPORTED)
+set_target_properties(Boost::date_time PROPERTIES
+ IMPORTED_CONFIGURATIONS RELEASE
+ IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_date_time.a"
+ INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/include"
+ )
+set(Boost_PYTHON37_FOUND 1)
+add_library(Boost::python UNKNOWN IMPORTED)
+set_target_properties(Boost::python PROPERTIES
+ IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
+ IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_python_release.a"
+ IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_python.a"
+ INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/include"
+ )
+set(Boost_MPI_PYTHON2_FOUND 1)
+add_library(Boost::mpi_python UNKNOWN IMPORTED)
+set_target_properties(Boost::mpi_python PROPERTIES
+ IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
+ IMPORTED_LOCATION_RELEASE "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_mpi_python.a"
+ IMPORTED_LOCATION_DEBUG "${CMAKE_CURRENT_LIST_DIR}/lib/libboost_mpi_python.a"
+ INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/include"
+ )
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfigVersion.cmake b/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfigVersion.cmake
new file mode 100644
index 000000000..b4b606000
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/BoostConfigVersion.cmake
@@ -0,0 +1,7 @@
+set(PACKAGE_VERSION 1.70.42)
+if(PACKAGE_FIND_VERSION_MAJOR EQUAL 1)
+ set(PACKAGE_VERSION_COMPATIBLE 1)
+ if(PACKAGE_FIND_VERSION_MINOR EQUAL 70 AND PACKAGE_FIND_VERSION_PATCH EQUAL 42)
+ set(PACKAGE_VERSION_EXACT 1)
+ endif()
+endif()
diff --git a/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/include/boost/version.hpp b/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/include/boost/version.hpp
new file mode 100644
index 000000000..fe8e72c6d
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CMakePackage_NoHeaderTarget/include/boost/version.hpp
@@ -0,0 +1,34 @@
+// Boost version.hpp configuration header file
+// ------------------------------//
+
+// (C) Copyright John maddock 1999. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/config for documentation
+
+#ifndef BOOST_VERSION_HPP
+#define BOOST_VERSION_HPP
+
+//
+// Caution: this is the only Boost header that is guaranteed
+// to change with every Boost release. Including this header
+// will cause a recompile every time a new Boost version is
+// used.
+//
+// BOOST_VERSION % 100 is the patch level
+// BOOST_VERSION / 100 % 1000 is the minor version
+// BOOST_VERSION / 100000 is the major version
+
+#define BOOST_VERSION 1070042
+
+//
+// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
+// but as a *string* in the form "x_y[_z]" where x is the major version
+// number, y is the minor version number, and z is the patch level if not 0.
+// This is used by <config/auto_link.hpp> to select which library version to
+// link to.
+
+#define BOOST_LIB_VERSION "1_70_42"
+
+#endif
diff --git a/Tests/RunCMake/FindBoost/CommonNotFound-stderr.txt b/Tests/RunCMake/FindBoost/CommonNotFound-stderr.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CommonNotFound-stderr.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/FindBoost/CommonNotFound-stdout.txt b/Tests/RunCMake/FindBoost/CommonNotFound-stdout.txt
new file mode 100644
index 000000000..644469e5f
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CommonNotFound-stdout.txt
@@ -0,0 +1 @@
+-- Could NOT find Boost
diff --git a/Tests/RunCMake/FindBoost/CommonNotFound.cmake b/Tests/RunCMake/FindBoost/CommonNotFound.cmake
new file mode 100644
index 000000000..864a54913
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CommonNotFound.cmake
@@ -0,0 +1,2 @@
+# Make sure to use the module mode signature here to not bypass FindBoost
+find_package(Boost 1.80 COMPONENTS timer foobar)
diff --git a/Tests/RunCMake/FindBoost/CommonResults-stdout.txt b/Tests/RunCMake/FindBoost/CommonResults-stdout.txt
new file mode 100644
index 000000000..a560843e0
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CommonResults-stdout.txt
@@ -0,0 +1,13 @@
+-- Found Boost: [^
+]* \(found suitable version "1\.70\.0", minimum required is "1\.60"\) found components: .*timer.*
+-- Boost_FOUND
+-- Boost_VERSION=(107000|1\.70\.0)
+-- Boost_VERSION_MAJOR=1
+-- Boost_VERSION_MINOR=70
+-- Boost_VERSION_PATCH=0
+-- Boost_VERSION_COUNT=3
+-- Boost::headers
+-- Boost::boost
+-- Boost::chrono
+-- Boost::timer
+(-- Boost::system)?
diff --git a/Tests/RunCMake/FindBoost/CommonResults.cmake b/Tests/RunCMake/FindBoost/CommonResults.cmake
new file mode 100644
index 000000000..6876800a5
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/CommonResults.cmake
@@ -0,0 +1,25 @@
+# Make sure to use the module mode signature here to not bypass FindBoost
+find_package(Boost 1.60 COMPONENTS timer MODULE)
+if(Boost_FOUND)
+ message(STATUS "Boost_FOUND")
+endif()
+message(STATUS "Boost_VERSION=${Boost_VERSION}")
+message(STATUS "Boost_VERSION_MAJOR=${Boost_VERSION_MAJOR}")
+message(STATUS "Boost_VERSION_MINOR=${Boost_VERSION_MINOR}")
+message(STATUS "Boost_VERSION_PATCH=${Boost_VERSION_PATCH}")
+message(STATUS "Boost_VERSION_COUNT=${Boost_VERSION_COUNT}")
+if(TARGET Boost::headers)
+ message(STATUS "Boost::headers")
+endif()
+if(TARGET Boost::boost)
+ message(STATUS "Boost::boost")
+endif()
+if(TARGET Boost::chrono)
+ message(STATUS "Boost::chrono")
+endif()
+if(TARGET Boost::timer)
+ message(STATUS "Boost::timer")
+endif()
+if(TARGET Boost::system)
+ message(STATUS "Boost::system")
+endif()
diff --git a/Tests/RunCMake/FindBoost/ConfigMode.cmake b/Tests/RunCMake/FindBoost/ConfigMode.cmake
new file mode 100644
index 000000000..5600658a4
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/ConfigMode.cmake
@@ -0,0 +1,2 @@
+set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackageFixtures/Boost-1.70.0)
+include(${CMAKE_CURRENT_SOURCE_DIR}/CommonResults.cmake)
diff --git a/Tests/RunCMake/FindBoost/ConfigModeNotFound.cmake b/Tests/RunCMake/FindBoost/ConfigModeNotFound.cmake
new file mode 100644
index 000000000..7e90a3cfc
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/ConfigModeNotFound.cmake
@@ -0,0 +1,2 @@
+set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackageFixtures/Boost-1.70.0)
+include(${CMAKE_CURRENT_SOURCE_DIR}/CommonNotFound.cmake)
diff --git a/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix-stdout.txt b/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix-stdout.txt
new file mode 100644
index 000000000..11754252e
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix-stdout.txt
@@ -0,0 +1,34 @@
+-- Found Boost: [^
+]* \(found suitable version "1\.70\.42", minimum required is "1\.70"\) found components: date_time python37 mpi_python2 *
+-- Boost_FOUND: TRUE
+-- Boost_INCLUDE_DIRS: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/include
+-- Boost_LIBRARY_DIRS: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib
+-- Boost_LIBRARIES: boost::date_time;boost::python;boost::mpi_python
+-- Boost_DATE_TIME_FOUND: 1
+-- Boost_DATE_TIME_LIBRARY: boost::date_time
+-- Boost_PYTHON37_FOUND: 1
+-- Boost_PYTHON37_LIBRARY: boost::python
+-- Boost_MPI_PYTHON2_FOUND: 1
+-- Boost_MPI_PYTHON2_LIBRARY: boost::mpi_python
+-- Boost_VERSION_MACRO: 1070042
+-- Boost_VERSION_STRING: 1.70.42
+-- Boost_VERSION: 1.70.42
+-- Boost_LIB_VERSION: 1_70_42
+-- Boost_MAJOR_VERSION: 1
+-- Boost_MINOR_VERSION: 70
+-- Boost_SUBMINOR_VERSION: 42
+-- Boost_INCLUDE_DIR: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/include
+-- Boost_DATE_TIME_LIBRARY_DEBUG: *
+-- Boost_DATE_TIME_LIBRARY_RELEASE: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_date_time.a
+-- Boost_PYTHON37_LIBRARY_DEBUG: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_python.a
+-- Boost_PYTHON37_LIBRARY_RELEASE: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_python_release.a
+-- Boost_MPI_PYTHON2_LIBRARY_DEBUG: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_mpi_python.a
+-- Boost_MPI_PYTHON2_LIBRARY_RELEASE: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_mpi_python.a
diff --git a/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix.cmake b/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix.cmake
new file mode 100644
index 000000000..a398c2d8c
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix.cmake
@@ -0,0 +1,6 @@
+# Use a (made up) modern style BoostConfig that defines all targets
+# as boost::<component> with appropriate properties set
+# No legacy variables defined in the BoostConfig
+set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackage_LowerCaseTargetPrefix)
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/LegacyVars.cmake)
diff --git a/Tests/RunCMake/FindBoost/LegacyVars-NoHeaderTarget.cmake b/Tests/RunCMake/FindBoost/LegacyVars-NoHeaderTarget.cmake
new file mode 100644
index 000000000..edb6dda97
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/LegacyVars-NoHeaderTarget.cmake
@@ -0,0 +1,6 @@
+# Use a (made up?) BoostConfig that defines all targets
+# as Boost::<component> with appropriate properties set
+# But no Boost::headers or Boost::boost target is defined
+set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackage_NoHeaderTarget)
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/LegacyVars.cmake)
diff --git a/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined-stdout.txt b/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined-stdout.txt
new file mode 100644
index 000000000..101d60ea7
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined-stdout.txt
@@ -0,0 +1,34 @@
+-- Found Boost: [^
+]* \(found suitable version "1\.70\.42", minimum required is "1\.70"\) found components: date_time python37 mpi_python2 *
+-- Boost_FOUND: TRUE
+-- Boost_INCLUDE_DIRS: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/include
+-- Boost_LIBRARY_DIRS: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib
+-- Boost_LIBRARIES: Boost::date_time;Boost::python;Boost::mpi_python
+-- Boost_DATE_TIME_FOUND: 1
+-- Boost_DATE_TIME_LIBRARY: Boost::date_time
+-- Boost_PYTHON37_FOUND: 1
+-- Boost_PYTHON37_LIBRARY: Boost::python
+-- Boost_MPI_PYTHON2_FOUND: 1
+-- Boost_MPI_PYTHON2_LIBRARY: Boost::mpi_python
+-- Boost_VERSION_MACRO: 1070042
+-- Boost_VERSION_STRING: 1.70.42
+-- Boost_VERSION: 1.70.42
+-- Boost_LIB_VERSION: 1_70_42
+-- Boost_MAJOR_VERSION: 1
+-- Boost_MINOR_VERSION: 70
+-- Boost_SUBMINOR_VERSION: 42
+-- Boost_INCLUDE_DIR: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/include
+-- Boost_DATE_TIME_LIBRARY_DEBUG: *
+-- Boost_DATE_TIME_LIBRARY_RELEASE: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_date_time.a
+-- Boost_PYTHON37_LIBRARY_DEBUG: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_python.a
+-- Boost_PYTHON37_LIBRARY_RELEASE: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_python_release.a
+-- Boost_MPI_PYTHON2_LIBRARY_DEBUG: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_mpi_python.a
+-- Boost_MPI_PYTHON2_LIBRARY_RELEASE: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/lib/libboost_mpi_python.a
diff --git a/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined.cmake b/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined.cmake
new file mode 100644
index 000000000..19ad49f8f
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined.cmake
@@ -0,0 +1,6 @@
+# Use a modern style BoostConfig that defines all targets
+# as Boost::<component> with appropriate properties set
+# No legacy variables defined in the BoostConfig
+set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackage_New)
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/LegacyVars.cmake)
diff --git a/Tests/RunCMake/FindBoost/LegacyVars.cmake b/Tests/RunCMake/FindBoost/LegacyVars.cmake
new file mode 100644
index 000000000..d0d5ee01c
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/LegacyVars.cmake
@@ -0,0 +1,28 @@
+find_package(Boost 1.70 COMPONENTS date_time python37 mpi_python2)
+
+foreach(var Boost_FOUND Boost_INCLUDE_DIRS Boost_LIBRARY_DIRS Boost_LIBRARIES
+ Boost_DATE_TIME_FOUND Boost_DATE_TIME_LIBRARY
+ Boost_PYTHON37_FOUND Boost_PYTHON37_LIBRARY
+ Boost_MPI_PYTHON2_FOUND Boost_MPI_PYTHON2_LIBRARY
+ Boost_VERSION_MACRO Boost_VERSION_STRING Boost_VERSION Boost_LIB_VERSION
+ Boost_MAJOR_VERSION Boost_MINOR_VERSION Boost_SUBMINOR_VERSION
+)
+ message(STATUS "${var}: ${${var}}")
+endforeach()
+
+foreach(cachevar Boost_INCLUDE_DIR
+ Boost_DATE_TIME_LIBRARY_DEBUG Boost_DATE_TIME_LIBRARY_RELEASE
+ Boost_PYTHON37_LIBRARY_DEBUG Boost_PYTHON37_LIBRARY_RELEASE
+ Boost_MPI_PYTHON2_LIBRARY_DEBUG Boost_MPI_PYTHON2_LIBRARY_RELEASE
+)
+ unset(${cachevar})
+ message(STATUS "${cachevar}: ${${cachevar}}")
+endforeach()
+
+foreach(lib Boost::headers Boost::date_time Boost::python Boost::mpi_python
+ Boost::boost Boost::diagnostic_definitions Boost::disable_autolinking Boost::dynamic_linking
+)
+ if(NOT TARGET ${lib})
+ message(FATAL_ERROR "Missing target ${lib}")
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/FindBoost/MissingTarget-stdout.txt b/Tests/RunCMake/FindBoost/MissingTarget-stdout.txt
new file mode 100644
index 000000000..9853c01df
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MissingTarget-stdout.txt
@@ -0,0 +1,22 @@
+-- Found Boost: [^
+]* \(found suitable version "1\.70\.42", minimum required is "1\.70"\) found components: date_time *
+-- Boost_FOUND: TRUE
+-- Boost_INCLUDE_DIRS: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/include
+-- Boost_LIBRARY_DIRS: *
+-- Boost_LIBRARIES: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/lib/libboost_date_time.a
+-- Boost_DATE_TIME_FOUND: 1
+-- Boost_DATE_TIME_LIBRARY: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/lib/libboost_date_time.a
+-- Boost_VERSION_MACRO: 1070042
+-- Boost_VERSION_STRING: 1.70.42
+-- Boost_VERSION: 1.70.42
+-- Boost_LIB_VERSION: 1_70_42
+-- Boost_MAJOR_VERSION: 1
+-- Boost_MINOR_VERSION: 70
+-- Boost_SUBMINOR_VERSION: 42
+-- Boost_INCLUDE_DIR: [^
+]*/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/include
+-- Boost_DATE_TIME_LIBRARY_DEBUG: *
+-- Boost_DATE_TIME_LIBRARY_RELEASE: *
diff --git a/Tests/RunCMake/FindBoost/MissingTarget.cmake b/Tests/RunCMake/FindBoost/MissingTarget.cmake
new file mode 100644
index 000000000..581e0065f
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MissingTarget.cmake
@@ -0,0 +1,25 @@
+set(Boost_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakePackage_MissingTarget)
+find_package(Boost 1.70 COMPONENTS date_time)
+
+foreach(var Boost_FOUND Boost_INCLUDE_DIRS Boost_LIBRARY_DIRS Boost_LIBRARIES
+ Boost_DATE_TIME_FOUND Boost_DATE_TIME_LIBRARY
+ Boost_VERSION_MACRO Boost_VERSION_STRING Boost_VERSION Boost_LIB_VERSION
+ Boost_MAJOR_VERSION Boost_MINOR_VERSION Boost_SUBMINOR_VERSION
+)
+ message(STATUS "${var}: ${${var}}")
+endforeach()
+
+foreach(cachevar Boost_INCLUDE_DIR
+ Boost_DATE_TIME_LIBRARY_DEBUG Boost_DATE_TIME_LIBRARY_RELEASE
+)
+ unset(${cachevar})
+ message(STATUS "${cachevar}: ${${cachevar}}")
+endforeach()
+
+foreach(lib Boost::headers
+ Boost::boost Boost::diagnostic_definitions Boost::disable_autolinking Boost::dynamic_linking
+)
+ if(NOT TARGET ${lib})
+ message(FATAL_ERROR "Missing target ${lib}")
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/chrono.hpp b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/chrono.hpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/chrono.hpp
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/config.hpp b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/config.hpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/config.hpp
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/system/config.hpp b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/system/config.hpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/system/config.hpp
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/timer.hpp b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/timer.hpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/timer.hpp
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/version.hpp b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/version.hpp
new file mode 100644
index 000000000..3ca02b32a
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/include/boost/version.hpp
@@ -0,0 +1,34 @@
+// Boost version.hpp configuration header file
+// ------------------------------//
+
+// (C) Copyright John maddock 1999. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/config for documentation
+
+#ifndef BOOST_VERSION_HPP
+#define BOOST_VERSION_HPP
+
+//
+// Caution: this is the only Boost header that is guaranteed
+// to change with every Boost release. Including this header
+// will cause a recompile every time a new Boost version is
+// used.
+//
+// BOOST_VERSION % 100 is the patch level
+// BOOST_VERSION / 100 % 1000 is the minor version
+// BOOST_VERSION / 100000 is the major version
+
+#define BOOST_VERSION 107000
+
+//
+// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
+// but as a *string* in the form "x_y[_z]" where x is the major version
+// number, y is the minor version number, and z is the patch level if not 0.
+// This is used by <config/auto_link.hpp> to select which library version to
+// link to.
+
+#define BOOST_LIB_VERSION "1_70"
+
+#endif
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_chrono-mt-1_70.lib b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_chrono-mt-1_70.lib
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_chrono-mt-1_70.lib
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_system-mt-1_70.lib b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_system-mt-1_70.lib
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_system-mt-1_70.lib
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_timer-mt-1_70.lib b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_timer-mt-1_70.lib
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/boost_timer-mt-1_70.lib
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono-mt-1_70.lib b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono-mt-1_70.lib
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono-mt-1_70.lib
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.a b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.a
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.a
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.so.1.70.0 b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.so.1.70.0
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_chrono.so.1.70.0
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system-mt-1_70.lib b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system-mt-1_70.lib
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system-mt-1_70.lib
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.a b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.a
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.a
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.so.1.70.0 b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.so.1.70.0
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_system.so.1.70.0
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer-mt-1_70.lib b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer-mt-1_70.lib
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer-mt-1_70.lib
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.a b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.a
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.a
diff --git a/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.so.1.70.0 b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.so.1.70.0
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/MockInstalls/1.70.0/lib/libboost_timer.so.1.70.0
diff --git a/Tests/RunCMake/FindBoost/ModuleMode.cmake b/Tests/RunCMake/FindBoost/ModuleMode.cmake
new file mode 100644
index 000000000..823fc53d4
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/ModuleMode.cmake
@@ -0,0 +1,4 @@
+set(BOOST_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/MockInstalls/1.70.0)
+set(Boost_NO_BOOST_CMAKE ON)
+set(Boost_NO_SYSTEM_PATHS ON)
+include(${CMAKE_CURRENT_SOURCE_DIR}/CommonResults.cmake)
diff --git a/Tests/RunCMake/FindBoost/ModuleModeNotFound.cmake b/Tests/RunCMake/FindBoost/ModuleModeNotFound.cmake
new file mode 100644
index 000000000..aaffbf2a1
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/ModuleModeNotFound.cmake
@@ -0,0 +1,4 @@
+set(BOOST_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/MockInstalls/1.70.0)
+set(Boost_NO_BOOST_CMAKE ON)
+set(Boost_NO_SYSTEM_PATHS ON)
+include(${CMAKE_CURRENT_SOURCE_DIR}/CommonNotFound.cmake)
diff --git a/Tests/RunCMake/FindBoost/NoCXX-stderr.txt b/Tests/RunCMake/FindBoost/NoCXX-stderr.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/NoCXX-stderr.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/FindBoost/NoCXX.cmake b/Tests/RunCMake/FindBoost/NoCXX.cmake
new file mode 100644
index 000000000..04b9cac61
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/NoCXX.cmake
@@ -0,0 +1 @@
+find_package(Boost)
diff --git a/Tests/RunCMake/FindBoost/RunCMakeTest.cmake b/Tests/RunCMake/FindBoost/RunCMakeTest.cmake
new file mode 100644
index 000000000..851a996db
--- /dev/null
+++ b/Tests/RunCMake/FindBoost/RunCMakeTest.cmake
@@ -0,0 +1,28 @@
+include(RunCMake)
+unset(ENV{Boost_ROOT})
+
+run_cmake(CMakePackage)
+run_cmake(NoCXX)
+
+run_cmake(LegacyVars-TargetsDefined) # "Good" BoostConfig
+run_cmake(LegacyVars-LowercaseTargetPrefix)
+set(RunCMake-stdout-file LegacyVars-TargetsDefined-stdout.txt)
+run_cmake(LegacyVars-NoHeaderTarget)
+
+unset(RunCMake-stdout-file)
+run_cmake(MissingTarget)
+
+set(RunCMake-stdout-file CommonResults-stdout.txt)
+run_cmake(ConfigMode)
+run_cmake(ModuleMode)
+unset(RunCMake-stdout-file)
+set(RunCMake-stdout-file CommonNotFound-stdout.txt)
+set(RunCMake-stderr-file CommonNotFound-stderr.txt)
+run_cmake(ConfigModeNotFound)
+run_cmake(ModuleModeNotFound)
+unset(RunCMake-stdout-file)
+unset(RunCMake-stderr-file)
+
+run_cmake(CMP0093-NEW)
+run_cmake(CMP0093-OLD)
+run_cmake(CMP0093-UNSET)
diff --git a/Tests/RunCMake/FindLua/CMakeLists.txt b/Tests/RunCMake/FindLua/CMakeLists.txt
new file mode 100644
index 000000000..a2c4d9812
--- /dev/null
+++ b/Tests/RunCMake/FindLua/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.4)
+project(${RunCMake_TEST} C)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/FindLua/FindLuaTest.cmake b/Tests/RunCMake/FindLua/FindLuaTest.cmake
new file mode 100644
index 000000000..610d544de
--- /dev/null
+++ b/Tests/RunCMake/FindLua/FindLuaTest.cmake
@@ -0,0 +1,87 @@
+unset(VERSION)
+
+# Ignore all default paths for this test to avoid finding system Lua
+set(CMAKE_INCLUDE_PATH )
+set(CMAKE_PREFIX_PATH )
+set(CMAKE_FRAMEWORK_PATH )
+
+set(ENV{CMAKE_INCLUDE_PATH} )
+set(ENV{CMAKE_PREFIX_PATH} )
+set(ENV{CMAKE_FRAMEWORK_PATH} )
+
+set(ENV{PATH} )
+set(ENV{INCLUDE} )
+
+set(CMAKE_SYSTEM_INCLUDE_PATH )
+set(CMAKE_SYSTEM_PREFIX_PATH )
+set(CMAKE_SYSTEM_FRAMEWORK_PATH )
+
+function(require_found path version)
+ find_package(Lua ${VERSION} QUIET)
+ if(NOT "${LUA_INCLUDE_DIR}" STREQUAL "${path}")
+ message(FATAL_ERROR "LUA_INCLUDE_PATH != path: '${LUA_INCLUDE_DIR}' != '${path}'")
+ endif()
+ if(NOT LUA_VERSION_STRING MATCHES "^${version}\.[0-9]$")
+ message(FATAL_ERROR "Wrong versionfound in '${LUA_INCLUDE_DIR}': ${LUA_VERSION_STRING} != ${version}")
+ endif()
+endfunction()
+
+# Use functions for scoping and better error messages
+function(require_find path version)
+ unset(LUA_INCLUDE_DIR CACHE)
+ require_found(${lua_path} ${version})
+endfunction()
+
+function(test_prefix_path path lua_path version)
+ set(CMAKE_PREFIX_PATH ${path})
+ require_find(lua_path ${version})
+endfunction()
+
+function(test_include_path path lua_path version)
+ set(CMAKE_INCLUDE_PATH ${path})
+ require_find(lua_path ${version})
+endfunction()
+
+function(test_env_path path lua_path version)
+ set(ENV{LUA_DIR} ${path})
+ require_find(lua_path ${version})
+ unset(ENV{LUA_DIR})
+endfunction()
+
+function(test_path prefix_path lua_path version)
+ # Shortcut: Make paths relative to current list dir
+ set(prefix_path ${CMAKE_CURRENT_LIST_DIR}/${prefix_path})
+ set(lua_path ${CMAKE_CURRENT_LIST_DIR}/${lua_path})
+
+ test_prefix_path(${prefix_path} ${lua_path} ${version})
+ test_include_path(${prefix_path}/include ${lua_path} ${version})
+ test_env_path(${prefix_path} ${lua_path} ${version})
+endfunction()
+
+# Simple test
+test_path(prefix1 prefix1/include 5.3)
+# Find highest version
+test_path(prefix2 prefix2/include/lua5.3 5.3)
+foreach(ver 5.3 5.2 5.1)
+ # At least X or X.0 -> Highest
+ set(VERSION "${ver}")
+ test_path(prefix2 prefix2/include/lua5.3 5.3)
+ set(VERSION "${ver}.0")
+ test_path(prefix2 prefix2/include/lua5.3 5.3)
+ # Exactly X/X.0
+ set(VERSION "${ver}" EXACT)
+ test_path(prefix2 prefix2/include/lua${ver} ${ver})
+ set(VERSION "${ver}.0" EXACT)
+ test_path(prefix2 prefix2/include/lua${ver} ${ver})
+endforeach()
+
+# Find unknown version
+set(VERSION "5.9")
+test_path(prefix2 prefix2/include/lua5.9 5.9)
+set(VERSION "5.9" EXACT)
+test_path(prefix2 prefix2/include/lua5.9 5.9)
+
+# Set LUA_INCLUDE_DIR (non-cache) to unsuitable version
+set(LUA_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/prefix2/include/lua5.2)
+set(VERSION "5.1" EXACT)
+test_path(prefix2 prefix2/include/lua5.1 5.1)
diff --git a/Tests/RunCMake/FindLua/RunCMakeTest.cmake b/Tests/RunCMake/FindLua/RunCMakeTest.cmake
new file mode 100644
index 000000000..3f180333a
--- /dev/null
+++ b/Tests/RunCMake/FindLua/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(FindLuaTest)
diff --git a/Tests/RunCMake/FindLua/prefix1/include/lua.h b/Tests/RunCMake/FindLua/prefix1/include/lua.h
new file mode 100644
index 000000000..d33434a5e
--- /dev/null
+++ b/Tests/RunCMake/FindLua/prefix1/include/lua.h
@@ -0,0 +1,8 @@
+
+#define LUA_VERSION_MAJOR "5"
+#define LUA_VERSION_MINOR "3"
+#define LUA_VERSION_NUM 503
+#define LUA_VERSION_RELEASE "4"
+
+#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
diff --git a/Tests/RunCMake/FindLua/prefix2/include/lua5.1/lua.h b/Tests/RunCMake/FindLua/prefix2/include/lua5.1/lua.h
new file mode 100644
index 000000000..661e62c73
--- /dev/null
+++ b/Tests/RunCMake/FindLua/prefix2/include/lua5.1/lua.h
@@ -0,0 +1,8 @@
+
+#define LUA_VERSION_MAJOR "5"
+#define LUA_VERSION_MINOR "1"
+#define LUA_VERSION_NUM 501
+#define LUA_VERSION_RELEASE "4"
+
+#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
diff --git a/Tests/RunCMake/FindLua/prefix2/include/lua5.2/lua.h b/Tests/RunCMake/FindLua/prefix2/include/lua5.2/lua.h
new file mode 100644
index 000000000..d53f326cc
--- /dev/null
+++ b/Tests/RunCMake/FindLua/prefix2/include/lua5.2/lua.h
@@ -0,0 +1,8 @@
+
+#define LUA_VERSION_MAJOR "5"
+#define LUA_VERSION_MINOR "2"
+#define LUA_VERSION_NUM 502
+#define LUA_VERSION_RELEASE "4"
+
+#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
diff --git a/Tests/RunCMake/FindLua/prefix2/include/lua5.3/lua.h b/Tests/RunCMake/FindLua/prefix2/include/lua5.3/lua.h
new file mode 100644
index 000000000..d33434a5e
--- /dev/null
+++ b/Tests/RunCMake/FindLua/prefix2/include/lua5.3/lua.h
@@ -0,0 +1,8 @@
+
+#define LUA_VERSION_MAJOR "5"
+#define LUA_VERSION_MINOR "3"
+#define LUA_VERSION_NUM 503
+#define LUA_VERSION_RELEASE "4"
+
+#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
diff --git a/Tests/RunCMake/FindLua/prefix2/include/lua5.9/lua.h b/Tests/RunCMake/FindLua/prefix2/include/lua5.9/lua.h
new file mode 100644
index 000000000..730f7cc21
--- /dev/null
+++ b/Tests/RunCMake/FindLua/prefix2/include/lua5.9/lua.h
@@ -0,0 +1,8 @@
+
+#define LUA_VERSION_MAJOR "5"
+#define LUA_VERSION_MINOR "9"
+#define LUA_VERSION_NUM 509
+#define LUA_VERSION_RELEASE "4"
+
+#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
+#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
diff --git a/Tests/RunCMake/FindMatlab/MatlabTest1.cmake b/Tests/RunCMake/FindMatlab/MatlabTest1.cmake
index 1cbc1c202..b4cc7415b 100644
--- a/Tests/RunCMake/FindMatlab/MatlabTest1.cmake
+++ b/Tests/RunCMake/FindMatlab/MatlabTest1.cmake
@@ -3,6 +3,9 @@ cmake_minimum_required (VERSION 2.8.12)
enable_testing()
project(test_should_fail)
+if(NOT "${matlab_root}" STREQUAL "")
+ set(Matlab_ROOT_DIR ${matlab_root})
+endif()
find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY)
matlab_add_mex(
diff --git a/Tests/RunCMake/FindMatlab/MatlabTest2.cmake b/Tests/RunCMake/FindMatlab/MatlabTest2.cmake
index d5b0e6db1..4295d3c73 100644
--- a/Tests/RunCMake/FindMatlab/MatlabTest2.cmake
+++ b/Tests/RunCMake/FindMatlab/MatlabTest2.cmake
@@ -6,4 +6,8 @@ if(NOT DEFINED matlab_required)
set(matlab_required REQUIRED)
endif()
+if(NOT DEFINED Matlab_ROOT_DIR AND NOT "${matlab_root}" STREQUAL "")
+ set(Matlab_ROOT_DIR ${matlab_root})
+endif()
+
find_package(Matlab ${matlab_required} COMPONENTS MX_LIBRARY)
diff --git a/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake b/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake
index f0eb6b4bb..deebf89d9 100644
--- a/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FindMatlab/RunCMakeTest.cmake
@@ -1,5 +1,13 @@
include(RunCMake)
+
+
+if(NOT "${MCR_ROOT}" STREQUAL "")
+ if(NOT EXISTS "${MCR_ROOT}")
+ message(FATAL_ERROR "MCR does not exist ${MCR_ROOT}")
+ endif()
+ set(RunCMake_TEST_OPTIONS "-Dmatlab_root=${MCR_ROOT}")
+endif()
run_cmake(MatlabTest1)
if(RunCMake_GENERATOR MATCHES "Make" AND UNIX)
@@ -11,6 +19,9 @@ if(RunCMake_GENERATOR MATCHES "Make" AND UNIX)
message(STATUS "RerunFindMatlab: first configuration to extract real Matlab_ROOT_DIR")
set(RunCMake_TEST_OPTIONS "-Dmatlab_required=REQUIRED")
+ if(NOT "${MCR_ROOT}" STREQUAL "")
+ set(RunCMake_TEST_OPTIONS ${RunCMake_TEST_OPTIONS} "-Dmatlab_root=${MCR_ROOT}")
+ endif()
run_cmake(MatlabTest2)
message(STATUS "RerunFindMatlab: flushing the variables")
diff --git a/Tests/RunCMake/FindOpenGL/CMP0072-NEW-stdout.txt b/Tests/RunCMake/FindOpenGL/CMP0072-NEW-stdout.txt
new file mode 100644
index 000000000..f5ee220b2
--- /dev/null
+++ b/Tests/RunCMake/FindOpenGL/CMP0072-NEW-stdout.txt
@@ -0,0 +1,3 @@
+-- OpenGL_GL_PREFERENCE='GLVND'
+-- OPENGL_gl_LIBRARY=''
+-- OPENGL_LIBRARIES='OpenGL;GLX;GLU'
diff --git a/Tests/RunCMake/FindOpenGL/CMP0072-NEW.cmake b/Tests/RunCMake/FindOpenGL/CMP0072-NEW.cmake
new file mode 100644
index 000000000..6cbbeec75
--- /dev/null
+++ b/Tests/RunCMake/FindOpenGL/CMP0072-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0072 NEW)
+include(CMP0072-common.cmake)
diff --git a/Tests/RunCMake/FindOpenGL/CMP0072-OLD-stdout.txt b/Tests/RunCMake/FindOpenGL/CMP0072-OLD-stdout.txt
new file mode 100644
index 000000000..22df1b12d
--- /dev/null
+++ b/Tests/RunCMake/FindOpenGL/CMP0072-OLD-stdout.txt
@@ -0,0 +1,3 @@
+-- OpenGL_GL_PREFERENCE='LEGACY'
+-- OPENGL_gl_LIBRARY='GL'
+-- OPENGL_LIBRARIES='GL;GLU'
diff --git a/Tests/RunCMake/FindOpenGL/CMP0072-OLD.cmake b/Tests/RunCMake/FindOpenGL/CMP0072-OLD.cmake
new file mode 100644
index 000000000..6d570043a
--- /dev/null
+++ b/Tests/RunCMake/FindOpenGL/CMP0072-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0072 OLD)
+include(CMP0072-common.cmake)
diff --git a/Tests/RunCMake/FindOpenGL/CMP0072-WARN-stderr.txt b/Tests/RunCMake/FindOpenGL/CMP0072-WARN-stderr.txt
new file mode 100644
index 000000000..f26f217b0
--- /dev/null
+++ b/Tests/RunCMake/FindOpenGL/CMP0072-WARN-stderr.txt
@@ -0,0 +1,21 @@
+^CMake Warning \(dev\) at .*/Modules/FindOpenGL.cmake:[0-9]+ \(message\):
+ Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
+ available. Run "cmake --help-policy CMP0072" for policy details. Use the
+ cmake_policy command to set the policy and suppress this warning.
+
+ FindOpenGL found both a legacy GL library:
+
+ OPENGL_gl_LIBRARY: GL
+
+ and GLVND libraries for OpenGL and GLX:
+
+ OPENGL_opengl_LIBRARY: OpenGL
+ OPENGL_glx_LIBRARY: GLX
+
+ OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
+ compatibility with CMake 3.10 and below the legacy GL library will be used.
+Call Stack \(most recent call first\):
+ CMP0072-common.cmake:[0-9]+ \(find_package\)
+ CMP0072-WARN.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/FindOpenGL/CMP0072-WARN-stdout.txt b/Tests/RunCMake/FindOpenGL/CMP0072-WARN-stdout.txt
new file mode 100644
index 000000000..22df1b12d
--- /dev/null
+++ b/Tests/RunCMake/FindOpenGL/CMP0072-WARN-stdout.txt
@@ -0,0 +1,3 @@
+-- OpenGL_GL_PREFERENCE='LEGACY'
+-- OPENGL_gl_LIBRARY='GL'
+-- OPENGL_LIBRARIES='GL;GLU'
diff --git a/Tests/RunCMake/FindOpenGL/CMP0072-WARN.cmake b/Tests/RunCMake/FindOpenGL/CMP0072-WARN.cmake
new file mode 100644
index 000000000..459c4583b
--- /dev/null
+++ b/Tests/RunCMake/FindOpenGL/CMP0072-WARN.cmake
@@ -0,0 +1 @@
+include(CMP0072-common.cmake)
diff --git a/Tests/RunCMake/FindOpenGL/CMP0072-common.cmake b/Tests/RunCMake/FindOpenGL/CMP0072-common.cmake
new file mode 100644
index 000000000..3fe80309b
--- /dev/null
+++ b/Tests/RunCMake/FindOpenGL/CMP0072-common.cmake
@@ -0,0 +1,13 @@
+set(CYGWIN 0)
+set(WIN32 0)
+set(APPLE 0)
+set(OPENGL_INCLUDE_DIR GL/include)
+set(OPENGL_GLX_INCLUDE_DIR GLX/include)
+set(OPENGL_gl_LIBRARY GL)
+set(OPENGL_opengl_LIBRARY OpenGL)
+set(OPENGL_glx_LIBRARY GLX)
+set(OPENGL_glu_LIBRARY GLU)
+find_package(OpenGL)
+message(STATUS "OpenGL_GL_PREFERENCE='${OpenGL_GL_PREFERENCE}'")
+message(STATUS "OPENGL_gl_LIBRARY='${OPENGL_gl_LIBRARY}'")
+message(STATUS "OPENGL_LIBRARIES='${OPENGL_LIBRARIES}'")
diff --git a/Tests/RunCMake/FindOpenGL/CMakeLists.txt b/Tests/RunCMake/FindOpenGL/CMakeLists.txt
new file mode 100644
index 000000000..bf2ef1506
--- /dev/null
+++ b/Tests/RunCMake/FindOpenGL/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.10)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/FindOpenGL/RunCMakeTest.cmake b/Tests/RunCMake/FindOpenGL/RunCMakeTest.cmake
new file mode 100644
index 000000000..fcc130f55
--- /dev/null
+++ b/Tests/RunCMake/FindOpenGL/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(CMP0072-WARN)
+run_cmake(CMP0072-OLD)
+run_cmake(CMP0072-NEW)
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_MODULE_NAME.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_MODULE_NAME.cmake
new file mode 100644
index 000000000..fc3a7664b
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_MATCHING_MODULE_NAME.cmake
@@ -0,0 +1,28 @@
+# Prepare environment to reuse bletch.pc
+file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-bletch/lib/pkgconfig" PC_PATH)
+if(UNIX)
+ string(REPLACE "\\ " " " PC_PATH "${PC_PATH}")
+endif()
+set(ENV{PKG_CONFIG_PATH} "${PC_PATH}")
+
+find_package(PkgConfig REQUIRED)
+pkg_search_module(FOO REQUIRED foo bletch bar)
+
+if(NOT FOO_MODULE_NAME STREQUAL "bletch")
+ message(FATAL_ERROR "Wrong value for FOO_MODULE_NAME. Expected: bletch, got: ${FOO_MODULE_NAME}")
+endif()
+
+pkg_get_variable(FOO_JACKPOT ${FOO_MODULE_NAME} jackpot)
+
+if(NOT FOO_JACKPOT STREQUAL "bletch-lives")
+ message(FATAL_ERROR "Wrong value for FOO_JACKPOT. Expected: bletch-lives, got: ${FOO_JACKPOT}")
+endif()
+
+unset(FOO_MODULE_NAME)
+
+# verify variable get's also set on subsequent run
+pkg_search_module(FOO REQUIRED foo bletch bar)
+
+if(NOT FOO_MODULE_NAME STREQUAL "bletch")
+ message(FATAL_ERROR "Wrong value for FOO_MODULE_NAME on second run. Expected: bletch, got: ${FOO_MODULE_NAME}")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH.cmake
new file mode 100644
index 000000000..f5f5c8cea
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH.cmake
@@ -0,0 +1,21 @@
+# Prepare environment and variables
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE)
+if(WIN32)
+ set(ENV{CMAKE_PREFIX_PATH} "C:\\baz")
+ set(ENV{PKG_CONFIG_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bletch\\lib\\pkgconfig;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
+else()
+ set(ENV{CMAKE_PREFIX_PATH} "/baz")
+ set(ENV{PKG_CONFIG_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bletch/lib/pkgconfig:/this/directory/should/not/exist/in/the/filesystem")
+endif()
+
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(BLETCH QUIET bletch)
+
+if (NOT BLETCH_FOUND)
+ message(FATAL_ERROR "Failed to find embedded package bletch via PKG_CONFIG_PATH")
+endif ()
+
+pkg_get_variable(bletchvar bletch jackpot)
+if (NOT bletchvar STREQUAL "bletch-lives")
+ message(FATAL_ERROR "Failed to fetch variable jackpot from embedded package bletch via PKG_CONFIG_PATH")
+endif ()
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PREFIX_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PREFIX_PATH.cmake
new file mode 100644
index 000000000..cfc0760df
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_GET_VARIABLE_PREFIX_PATH.cmake
@@ -0,0 +1,21 @@
+# Prepare environment and variables
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
+if(WIN32)
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bletch;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
+ set(ENV{PKG_CONFIG_PATH} "C:\\baz")
+else()
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bletch:/this/directory/should/not/exist/in/the/filesystem")
+ set(ENV{PKG_CONFIG_PATH} "/baz")
+endif()
+
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(BLETCH QUIET bletch)
+
+if (NOT BLETCH_FOUND)
+ message(FATAL_ERROR "Failed to find embedded package bletch via CMAKE_PREFIX_PATH")
+endif ()
+
+pkg_get_variable(bletchvar bletch jackpot)
+if (NOT bletchvar STREQUAL "bletch-lives")
+ message(FATAL_ERROR "Failed to fetch variable jackpot from embedded package bletch via CMAKE_PREFIX_PATH")
+endif ()
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
index 00cbb7b38..62bb5de77 100644
--- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
@@ -1,10 +1,12 @@
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.12)
project(FindPkgConfig_IMPORTED_TARGET C)
find_package(PkgConfig REQUIRED)
pkg_check_modules(NCURSES IMPORTED_TARGET QUIET ncurses)
+message(STATUS "source: ${CMAKE_CURRENT_SOURCE_DIR} bin ${CMAKE_CURRENT_BINARY_DIR}")
+
if (NCURSES_FOUND)
set(tgt PkgConfig::NCURSES)
if (NOT TARGET ${tgt})
@@ -24,3 +26,90 @@ if (NCURSES_FOUND)
else ()
message(STATUS "skipping test; ncurses not found")
endif ()
+
+
+# Setup for the remaining package tests below
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH)
+set(fakePkgDir ${CMAKE_CURRENT_BINARY_DIR}/pc-fakepackage)
+foreach(i 1 2)
+ set(pname cmakeinternalfakepackage${i})
+ file(WRITE ${fakePkgDir}/lib/lib${pname}.a "")
+ file(WRITE ${fakePkgDir}/lib/${pname}.lib "")
+ file(WRITE ${fakePkgDir}/lib/pkgconfig/${pname}.pc
+"Name: CMakeInternalFakePackage${i}
+Description: Dummy package (${i}) for FindPkgConfig IMPORTED_TARGET test
+Version: 1.2.3
+Libs: -l${pname} -l${pname}-doesnotexist
+")
+endforeach()
+
+# Always find the .pc file in the calls further below so that we can test that
+# the import target find_library() calls handle the NO...PATH options correctly
+set(ENV{PKG_CONFIG_PATH} ${fakePkgDir}/lib/pkgconfig)
+
+# find targets in subdir and check their visibility
+add_subdirectory(target_subdir)
+if (TARGET PkgConfig::FakePackage1_dir)
+ message(FATAL_ERROR "imported target PkgConfig::FakePackage1_dir is visible outside it's directory")
+endif()
+
+if (NOT TARGET PkgConfig::FakePackage1_global)
+ message(FATAL_ERROR "imported target PkgConfig::FakePackage1_global is not visible outside it's directory")
+endif()
+
+# And now do the same for the NO_CMAKE_ENVIRONMENT_PATH - ENV{CMAKE_PREFIX_PATH}
+# combination
+unset(CMAKE_PREFIX_PATH)
+unset(ENV{CMAKE_PREFIX_PATH})
+set(ENV{CMAKE_PREFIX_PATH} ${fakePkgDir})
+
+pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage2)
+if (NOT TARGET PkgConfig::FakePackage2)
+ message(FATAL_ERROR "No import target for fake package 2 with prefix path")
+endif()
+
+# check that 2 library entries exist
+list(LENGTH FakePackage2_LINK_LIBRARIES fp2_nlibs)
+if (NOT fp2_nlibs EQUAL 2)
+ message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has ${fp2_nlibs} entries but should have exactly 2")
+endif()
+
+# check that the full library path is also returned
+list(GET FakePackage2_LINK_LIBRARIES 0 fp2_lib0)
+if (NOT fp2_lib0 STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a")
+ message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on first run: ${FakePackage2_LINK_LIBRARIES}")
+endif()
+
+# check that the library that couldn't be found still shows up
+list(GET FakePackage2_LINK_LIBRARIES 1 fp2_lib1)
+if (NOT fp2_lib1 STREQUAL "cmakeinternalfakepackage2-doesnotexist")
+ message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on first run: ${FakePackage2_LINK_LIBRARIES}")
+endif()
+
+# the information in *_LINK_LIBRARIES is not cached, so ensure is also is present on second run
+unset(FakePackage2_LINK_LIBRARIES)
+pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage2)
+if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a;cmakeinternalfakepackage2-doesnotexist")
+ message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on second run: ${FakePackage2_LINK_LIBRARIES}")
+endif()
+
+set(pname fakelinkoptionspackage)
+file(WRITE ${fakePkgDir}/lib/pkgconfig/${pname}.pc
+"Name: FakeLinkOptionsPackage
+Description: Dummy package for FindPkgConfig IMPORTED_TARGET INTERFACE_LINK_OPTIONS test
+Version: 1.2.3
+Libs: -e dummy_main
+")
+
+set(expected_link_options -e dummy_main)
+pkg_check_modules(FakeLinkOptionsPackage REQUIRED QUIET IMPORTED_TARGET fakelinkoptionspackage)
+if (NOT TARGET PkgConfig::FakeLinkOptionsPackage)
+ message(FATAL_ERROR "No import target for fake link options package")
+endif()
+get_target_property(link_options PkgConfig::FakeLinkOptionsPackage INTERFACE_LINK_OPTIONS)
+if (NOT link_options STREQUAL expected_link_options)
+ message(FATAL_ERROR
+ "Additional link options not present in INTERFACE_LINK_OPTIONS property"
+ "expected: \"${expected_link_options}\", but got \"${link_options}\""
+ )
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake
index 1defde840..d1d538512 100644
--- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake
@@ -29,7 +29,7 @@ if(NOT DEFINED CMAKE_SYSTEM_NAME
set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
endif()
else()
- # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS propertie
+ # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties
get_property(uselibx32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIBX32_PATHS)
get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS)
get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_VERSION_OPERATORS.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_VERSION_OPERATORS.cmake
new file mode 100644
index 000000000..2a505c6a5
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_VERSION_OPERATORS.cmake
@@ -0,0 +1,83 @@
+cmake_minimum_required(VERSION 3.12)
+
+project(FindPkgConfig_IMPORTED_TARGET C)
+
+find_package(PkgConfig REQUIRED)
+
+message(STATUS "source: ${CMAKE_CURRENT_SOURCE_DIR} bin ${CMAKE_CURRENT_BINARY_DIR}")
+
+# Setup for the remaining package tests below
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH)
+set(fakePkgDir ${CMAKE_CURRENT_BINARY_DIR}/pc-fakepackage)
+file(WRITE ${fakePkgDir}/lib/libcmakeinternalfakepackage.a "")
+file(WRITE ${fakePkgDir}/lib/cmakeinternalfakepackage.lib "")
+file(WRITE ${fakePkgDir}/lib/pkgconfig/cmakeinternalfakepackage.pc
+"Name: CMakeInternalFakePackage
+Description: Dummy package for FindPkgConfig VERSION_OPERATORS test
+Version: 8.9
+Libs: -lcmakeinternalfakepackage
+")
+
+# Always find the .pc file in the calls further below so that we can test that
+# the import target find_library() calls handle the NO...PATH options correctly
+set(ENV{PKG_CONFIG_PATH} ${fakePkgDir}/lib/pkgconfig)
+
+pkg_check_modules(FakePackageGE REQUIRED QUIET "cmakeinternalfakepackage >= 8")
+if (NOT FakePackageGE_FOUND)
+ message(FATAL_ERROR "fake package >= 8 not found")
+endif()
+
+pkg_check_modules(FakePackageGE_FAIL QUIET "cmakeinternalfakepackage >= 8.10")
+if (FakePackageGE_FAIL_FOUND)
+ message(FATAL_ERROR "fake package >= 8.10 found")
+endif()
+
+pkg_check_modules(FakePackageLE REQUIRED QUIET "cmakeinternalfakepackage<=9")
+if (NOT FakePackageLE_FOUND)
+ message(FATAL_ERROR "fake package <= 9 not found")
+endif()
+
+pkg_check_modules(FakePackageLE_FAIL QUIET "cmakeinternalfakepackage <= 8.1")
+if (FakePackageLE_FAIL_FOUND)
+ message(FATAL_ERROR "fake package <= 8.1 found")
+endif()
+
+pkg_check_modules(FakePackageGT REQUIRED QUIET "cmakeinternalfakepackage > 8")
+if (NOT FakePackageGT_FOUND)
+ message(FATAL_ERROR "fake package > 8 not found")
+endif()
+
+pkg_check_modules(FakePackageGT_FAIL QUIET "cmakeinternalfakepackage > 8.9")
+if (FakePackageGT_FAIL_FOUND)
+ message(FATAL_ERROR "fake package > 8.9 found")
+endif()
+
+pkg_check_modules(FakePackageLT REQUIRED QUIET "cmakeinternalfakepackage<9")
+if (NOT FakePackageLT_FOUND)
+ message(FATAL_ERROR "fake package < 9 not found")
+endif()
+
+pkg_check_modules(FakePackageLT_FAIL QUIET "cmakeinternalfakepackage < 8.9")
+if (FakePackageLT_FAIL_FOUND)
+ message(FATAL_ERROR "fake package < 8.9 found")
+endif()
+
+pkg_check_modules(FakePackageEQ REQUIRED QUIET "cmakeinternalfakepackage=8.9")
+if (NOT FakePackageEQ_FOUND)
+ message(FATAL_ERROR "fake package = 8.9 not found")
+endif()
+
+pkg_check_modules(FakePackageEQ_FAIL QUIET "cmakeinternalfakepackage = 8.8")
+if (FakePackageEQ_FAIL_FOUND)
+ message(FATAL_ERROR "fake package = 8.8 found")
+endif()
+
+pkg_check_modules(FakePackageEQ_INV QUIET "cmakeinternalfakepackage == 8.9")
+if (FakePackageEQ_FAIL_FOUND)
+ message(FATAL_ERROR "fake package == 8.9 found")
+endif()
+
+pkg_check_modules(FakePackageLLT_INV QUIET "cmakeinternalfakepackage <<= 9")
+if (FakePackageLLT_FAIL_FOUND)
+ message(FATAL_ERROR "fake package <<= 9 found")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
index e12b52fe4..b77bb5432 100644
--- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
@@ -14,6 +14,10 @@ endif()
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
run_cmake(FindPkgConfig_GET_VARIABLE)
+ run_cmake(FindPkgConfig_GET_VARIABLE_PREFIX_PATH)
+ run_cmake(FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH)
run_cmake(FindPkgConfig_cache_variables)
run_cmake(FindPkgConfig_IMPORTED_TARGET)
+ run_cmake(FindPkgConfig_VERSION_OPERATORS)
+ run_cmake(FindPkgConfig_GET_MATCHING_MODULE_NAME)
endif ()
diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat
index b03837030..486977cbb 100755
--- a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat
+++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat
@@ -1,27 +1,27 @@
-@ECHO OFF
-
-:LOOP
-
-IF "%1"=="" (
- EXIT /B 255
-)
-
-IF "%1"=="--version" (
- ECHO 0.0-cmake-dummy
- EXIT /B 0
-)
-
-IF "%1"=="--exists" (
- SHIFT
- ECHO Expected: %*
- ECHO Found: %PKG_CONFIG_PATH%
- IF NOT "%*"=="%PKG_CONFIG_PATH%" (
- EXIT /B 1
- ) ELSE (
- EXIT /B 0
- )
-)
-SHIFT
-IF NOT "%~1"=="" GOTO LOOP
-
-EXIT /B 255
+@ECHO OFF
+
+:LOOP
+
+IF "%1"=="" (
+ EXIT /B 255
+)
+
+IF "%1"=="--version" (
+ ECHO 0.0-cmake-dummy
+ EXIT /B 0
+)
+
+IF "%1"=="--exists" (
+ SHIFT
+ ECHO Expected: %*
+ ECHO Found: %PKG_CONFIG_PATH%
+ IF NOT "%*"=="%PKG_CONFIG_PATH%" (
+ EXIT /B 1
+ ) ELSE (
+ EXIT /B 0
+ )
+)
+SHIFT
+IF NOT "%~1"=="" GOTO LOOP
+
+EXIT /B 255
diff --git a/Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch.pc b/Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch.pc
new file mode 100644
index 000000000..04d2c1b00
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-bletch/lib/pkgconfig/bletch.pc
@@ -0,0 +1,12 @@
+prefix=/opt/bletch
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+jackpot=bletch-lives
+
+Name: Bletch
+Description: Dummy packaget to test variable support
+Version: 1.0
+Libs: -L${libdir} -lbletch
+Cflags: -Dbletch_version=1
diff --git a/Tests/RunCMake/FindPkgConfig/target_subdir/CMakeLists.txt b/Tests/RunCMake/FindPkgConfig/target_subdir/CMakeLists.txt
new file mode 100644
index 000000000..2171ef6d8
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/target_subdir/CMakeLists.txt
@@ -0,0 +1,5 @@
+# a target with visibility only in this directory
+pkg_check_modules(FakePackage1_dir REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage1)
+
+# the same with global visibility
+pkg_check_modules(FakePackage1_global REQUIRED QUIET IMPORTED_TARGET GLOBAL cmakeinternalfakepackage1)
diff --git a/Tests/RunCMake/Framework/FrameworkLayout.cmake b/Tests/RunCMake/Framework/FrameworkLayout.cmake
index 3d62a8af3..84012aa36 100644
--- a/Tests/RunCMake/Framework/FrameworkLayout.cmake
+++ b/Tests/RunCMake/Framework/FrameworkLayout.cmake
@@ -11,8 +11,11 @@ add_library(Framework ${FRAMEWORK_TYPE}
flatresource.txt
deepresource.txt
some.txt)
+if("${CMAKE_FRAMEWORK}" STREQUAL "")
+ set_target_properties(Framework PROPERTIES
+ FRAMEWORK TRUE)
+endif()
set_target_properties(Framework PROPERTIES
- FRAMEWORK TRUE
PUBLIC_HEADER foo.h
RESOURCE "res.txt")
set_source_files_properties(flatresource.txt PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
@@ -22,4 +25,4 @@ set_source_files_properties(some.txt PROPERTIES MACOSX_PACKAGE_LOCATION somedir)
add_custom_command(TARGET Framework POST_BUILD
COMMAND /usr/bin/file $<TARGET_FILE:Framework>)
-file(GENERATE OUTPUT FrameworkName.cmake CONTENT "set(framework-dir \"$<TARGET_BUNDLE_DIR:Framework>\")\n")
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FrameworkName.cmake CONTENT "set(framework-dir \"$<TARGET_BUNDLE_DIR:Framework>\")\n")
diff --git a/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt b/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt
index f664db91f..4a92a455a 100644
--- a/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt
+++ b/Tests/RunCMake/Framework/FrameworkTypeSHARED-build-stdout.txt
@@ -1,3 +1,2 @@
-.*/Framework:( Mach-O universal binary with [^
-]*)? Mach-O[^
+.*/Framework( \(for architecture [^\)]+\))?:[ ]+Mach-O[^
]* dynamically linked shared library.*
diff --git a/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt
index 532cfedcc..dd64717e6 100644
--- a/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt
+++ b/Tests/RunCMake/Framework/FrameworkTypeSTATIC-build-stdout.txt
@@ -1,2 +1 @@
-.*/Framework:( Mach-O universal binary with [^
-]*)? current ar archive random library.*
+/Framework( \(for architecture [^\)]+\))?:[ ]+current ar archive random library
diff --git a/Tests/RunCMake/Framework/InstallBeforeFramework-stderr.txt b/Tests/RunCMake/Framework/InstallBeforeFramework-stderr.txt
new file mode 100644
index 000000000..a3a7c6cbb
--- /dev/null
+++ b/Tests/RunCMake/Framework/InstallBeforeFramework-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Warning \(dev\) at InstallBeforeFramework.cmake:4 \(install\):
+ Target 'foo' was changed to a FRAMEWORK sometime after install\(\). This may
+ result in the wrong install DESTINATION. Set the FRAMEWORK property
+ earlier.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/Framework/InstallBeforeFramework.cmake b/Tests/RunCMake/Framework/InstallBeforeFramework.cmake
new file mode 100644
index 000000000..3791dace7
--- /dev/null
+++ b/Tests/RunCMake/Framework/InstallBeforeFramework.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+
+add_library(foo SHARED foo.c)
+install(TARGETS foo LIBRARY DESTINATION lib)
+set_property(TARGET foo PROPERTY FRAMEWORK TRUE)
diff --git a/Tests/RunCMake/Framework/RunCMakeTest.cmake b/Tests/RunCMake/Framework/RunCMakeTest.cmake
index 4fc83f801..965fbf431 100644
--- a/Tests/RunCMake/Framework/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Framework/RunCMakeTest.cmake
@@ -1,5 +1,7 @@
include(RunCMake)
+run_cmake(InstallBeforeFramework)
+
function(framework_layout_test Name Toolchain Type)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${Toolchain}${Type}FrameworkLayout-build)
set(RunCMake_TEST_NO_CLEAN 1)
@@ -18,11 +20,14 @@ framework_layout_test(iOSFrameworkLayout-build ios STATIC)
framework_layout_test(OSXFrameworkLayout-build osx SHARED)
framework_layout_test(OSXFrameworkLayout-build osx STATIC)
-function(framework_type_test Toolchain Type)
+function(framework_type_test Toolchain Type UseProperty)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${Toolchain}${Type}FrameworkType-build)
set(RunCMake_TEST_NO_CLEAN 1)
set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${Toolchain}.cmake")
list(APPEND RunCMake_TEST_OPTIONS "-DFRAMEWORK_TYPE=${Type}")
+ if(NOT UseProperty)
+ list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_FRAMEWORK=YES")
+ endif()
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
@@ -31,7 +36,12 @@ function(framework_type_test Toolchain Type)
run_cmake_command(FrameworkType${Type}-build ${CMAKE_COMMAND} --build .)
endfunction()
-framework_type_test(ios SHARED)
-framework_type_test(ios STATIC)
-framework_type_test(osx SHARED)
-framework_type_test(osx STATIC)
+framework_type_test(ios SHARED NO)
+framework_type_test(ios STATIC NO)
+framework_type_test(osx SHARED NO)
+framework_type_test(osx STATIC NO)
+
+framework_type_test(ios SHARED YES)
+framework_type_test(ios STATIC YES)
+framework_type_test(osx SHARED YES)
+framework_type_test(osx STATIC YES)
diff --git a/Tests/RunCMake/Framework/ios.cmake b/Tests/RunCMake/Framework/ios.cmake
index 209a50d39..446e9146a 100644
--- a/Tests/RunCMake/Framework/ios.cmake
+++ b/Tests/RunCMake/Framework/ios.cmake
@@ -20,6 +20,16 @@ execute_process(
OUTPUT_VARIABLE IOS_SDK_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(
+ COMMAND ${XCRUN_EXECUTABLE} --sdk iphoneos --show-sdk-version
+ OUTPUT_VARIABLE IOS_SDK_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(IOS_SDK_VERSION VERSION_GREATER_EQUAL 11.0)
+ set(IOS_ARCH arm64)
+else()
+ set(IOS_ARCH armv7)
+endif()
+
set(CMAKE_OSX_SYSROOT ${IOS_SDK_PATH} CACHE PATH "Sysroot used for iOS support")
-set(CMAKE_OSX_ARCHITECTURES "armv7" CACHE STRING "Architectures to build for")
+set(CMAKE_OSX_ARCHITECTURES "${IOS_ARCH}" CACHE STRING "Architectures to build for")
set(CMAKE_FIND_ROOT_PATH ${IOS_SDK_PATH} CACHE PATH "Find search path root")
diff --git a/Tests/RunCMake/GNUInstallDirs/Opt-FreeBSD-stderr.txt b/Tests/RunCMake/GNUInstallDirs/Opt-FreeBSD-stderr.txt
new file mode 100644
index 000000000..feb747b18
--- /dev/null
+++ b/Tests/RunCMake/GNUInstallDirs/Opt-FreeBSD-stderr.txt
@@ -0,0 +1,30 @@
+^CMAKE_INSTALL_BINDIR='bin'
+CMAKE_INSTALL_DATADIR='share'
+CMAKE_INSTALL_DATAROOTDIR='share'
+CMAKE_INSTALL_DOCDIR='share/doc/Opt'
+CMAKE_INSTALL_INCLUDEDIR='include'
+CMAKE_INSTALL_INFODIR='share/info'
+CMAKE_INSTALL_LIBDIR='(lib|lib64)'
+CMAKE_INSTALL_LIBEXECDIR='libexec'
+CMAKE_INSTALL_LOCALEDIR='share/locale'
+CMAKE_INSTALL_LOCALSTATEDIR='var'
+CMAKE_INSTALL_RUNSTATEDIR='var/run'
+CMAKE_INSTALL_MANDIR='man'
+CMAKE_INSTALL_SBINDIR='sbin'
+CMAKE_INSTALL_SHAREDSTATEDIR='com'
+CMAKE_INSTALL_SYSCONFDIR='etc'
+CMAKE_INSTALL_FULL_BINDIR='/opt/Opt/bin'
+CMAKE_INSTALL_FULL_DATADIR='/opt/Opt/share'
+CMAKE_INSTALL_FULL_DATAROOTDIR='/opt/Opt/share'
+CMAKE_INSTALL_FULL_DOCDIR='/opt/Opt/share/doc/Opt'
+CMAKE_INSTALL_FULL_INCLUDEDIR='/opt/Opt/include'
+CMAKE_INSTALL_FULL_INFODIR='/opt/Opt/share/info'
+CMAKE_INSTALL_FULL_LIBDIR='/opt/Opt/(lib|lib64)'
+CMAKE_INSTALL_FULL_LIBEXECDIR='/opt/Opt/libexec'
+CMAKE_INSTALL_FULL_LOCALEDIR='/opt/Opt/share/locale'
+CMAKE_INSTALL_FULL_LOCALSTATEDIR='/var/opt/Opt'
+CMAKE_INSTALL_FULL_RUNSTATEDIR='/var/run/opt/Opt'
+CMAKE_INSTALL_FULL_MANDIR='/opt/Opt/man'
+CMAKE_INSTALL_FULL_SBINDIR='/opt/Opt/sbin'
+CMAKE_INSTALL_FULL_SHAREDSTATEDIR='/opt/Opt/com'
+CMAKE_INSTALL_FULL_SYSCONFDIR='/etc/opt/Opt'$
diff --git a/Tests/RunCMake/GNUInstallDirs/Root-FreeBSD-stderr.txt b/Tests/RunCMake/GNUInstallDirs/Root-FreeBSD-stderr.txt
new file mode 100644
index 000000000..4284a15b1
--- /dev/null
+++ b/Tests/RunCMake/GNUInstallDirs/Root-FreeBSD-stderr.txt
@@ -0,0 +1,30 @@
+^CMAKE_INSTALL_BINDIR='usr/bin'
+CMAKE_INSTALL_DATADIR='usr/share'
+CMAKE_INSTALL_DATAROOTDIR='usr/share'
+CMAKE_INSTALL_DOCDIR='usr/share/doc/Root'
+CMAKE_INSTALL_INCLUDEDIR='usr/include'
+CMAKE_INSTALL_INFODIR='usr/share/info'
+CMAKE_INSTALL_LIBDIR='usr/(lib|lib64)'
+CMAKE_INSTALL_LIBEXECDIR='usr/libexec'
+CMAKE_INSTALL_LOCALEDIR='usr/share/locale'
+CMAKE_INSTALL_LOCALSTATEDIR='var'
+CMAKE_INSTALL_RUNSTATEDIR='var/run'
+CMAKE_INSTALL_MANDIR='usr/man'
+CMAKE_INSTALL_SBINDIR='usr/sbin'
+CMAKE_INSTALL_SHAREDSTATEDIR='usr/com'
+CMAKE_INSTALL_SYSCONFDIR='etc'
+CMAKE_INSTALL_FULL_BINDIR='/usr/bin'
+CMAKE_INSTALL_FULL_DATADIR='/usr/share'
+CMAKE_INSTALL_FULL_DATAROOTDIR='/usr/share'
+CMAKE_INSTALL_FULL_DOCDIR='/usr/share/doc/Root'
+CMAKE_INSTALL_FULL_INCLUDEDIR='/usr/include'
+CMAKE_INSTALL_FULL_INFODIR='/usr/share/info'
+CMAKE_INSTALL_FULL_LIBDIR='/usr/(lib|lib64)'
+CMAKE_INSTALL_FULL_LIBEXECDIR='/usr/libexec'
+CMAKE_INSTALL_FULL_LOCALEDIR='/usr/share/locale'
+CMAKE_INSTALL_FULL_LOCALSTATEDIR='/var'
+CMAKE_INSTALL_FULL_RUNSTATEDIR='/var/run'
+CMAKE_INSTALL_FULL_MANDIR='/usr/man'
+CMAKE_INSTALL_FULL_SBINDIR='/usr/sbin'
+CMAKE_INSTALL_FULL_SHAREDSTATEDIR='/usr/com'
+CMAKE_INSTALL_FULL_SYSCONFDIR='/etc'$
diff --git a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake
index b544ba640..d671ee0ab 100644
--- a/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GNUInstallDirs/RunCMakeTest.cmake
@@ -1,7 +1,11 @@
include(RunCMake)
-if(SYSTEM_NAME MATCHES "^(.*BSD|DragonFly)$")
- set(EXPECT_BSD 1)
+if(SYSTEM_NAME STREQUAL "FreeBSD")
+ set(variant "-FreeBSD")
+elseif(SYSTEM_NAME MATCHES "^(([^k].*)?BSD|DragonFly)$")
+ set(variant "-BSD")
+else()
+ set(variant "")
endif()
foreach(case
@@ -10,8 +14,6 @@ foreach(case
Usr
UsrLocal
)
- if(EXPECT_BSD)
- set(RunCMake-stderr-file ${case}-BSD-stderr.txt)
- endif()
+ set(RunCMake-stderr-file ${case}${variant}-stderr.txt)
run_cmake(${case})
endforeach()
diff --git a/Tests/RunCMake/GNUInstallDirs/Usr-FreeBSD-stderr.txt b/Tests/RunCMake/GNUInstallDirs/Usr-FreeBSD-stderr.txt
new file mode 100644
index 000000000..9efc1103e
--- /dev/null
+++ b/Tests/RunCMake/GNUInstallDirs/Usr-FreeBSD-stderr.txt
@@ -0,0 +1,30 @@
+^CMAKE_INSTALL_BINDIR='bin'
+CMAKE_INSTALL_DATADIR='share'
+CMAKE_INSTALL_DATAROOTDIR='share'
+CMAKE_INSTALL_DOCDIR='share/doc/Usr'
+CMAKE_INSTALL_INCLUDEDIR='include'
+CMAKE_INSTALL_INFODIR='share/info'
+CMAKE_INSTALL_LIBDIR='(lib|lib64|lib/arch)'
+CMAKE_INSTALL_LIBEXECDIR='libexec'
+CMAKE_INSTALL_LOCALEDIR='share/locale'
+CMAKE_INSTALL_LOCALSTATEDIR='var'
+CMAKE_INSTALL_RUNSTATEDIR='var/run'
+CMAKE_INSTALL_MANDIR='man'
+CMAKE_INSTALL_SBINDIR='sbin'
+CMAKE_INSTALL_SHAREDSTATEDIR='com'
+CMAKE_INSTALL_SYSCONFDIR='etc'
+CMAKE_INSTALL_FULL_BINDIR='/usr/bin'
+CMAKE_INSTALL_FULL_DATADIR='/usr/share'
+CMAKE_INSTALL_FULL_DATAROOTDIR='/usr/share'
+CMAKE_INSTALL_FULL_DOCDIR='/usr/share/doc/Usr'
+CMAKE_INSTALL_FULL_INCLUDEDIR='/usr/include'
+CMAKE_INSTALL_FULL_INFODIR='/usr/share/info'
+CMAKE_INSTALL_FULL_LIBDIR='/usr/(lib|lib64|lib/arch)'
+CMAKE_INSTALL_FULL_LIBEXECDIR='/usr/libexec'
+CMAKE_INSTALL_FULL_LOCALEDIR='/usr/share/locale'
+CMAKE_INSTALL_FULL_LOCALSTATEDIR='/var'
+CMAKE_INSTALL_FULL_RUNSTATEDIR='/var/run'
+CMAKE_INSTALL_FULL_MANDIR='/usr/man'
+CMAKE_INSTALL_FULL_SBINDIR='/usr/sbin'
+CMAKE_INSTALL_FULL_SHAREDSTATEDIR='/usr/com'
+CMAKE_INSTALL_FULL_SYSCONFDIR='/etc'$
diff --git a/Tests/RunCMake/GNUInstallDirs/UsrLocal-FreeBSD-stderr.txt b/Tests/RunCMake/GNUInstallDirs/UsrLocal-FreeBSD-stderr.txt
new file mode 100644
index 000000000..505bf08ef
--- /dev/null
+++ b/Tests/RunCMake/GNUInstallDirs/UsrLocal-FreeBSD-stderr.txt
@@ -0,0 +1,30 @@
+^CMAKE_INSTALL_BINDIR='bin'
+CMAKE_INSTALL_DATADIR='share'
+CMAKE_INSTALL_DATAROOTDIR='share'
+CMAKE_INSTALL_DOCDIR='share/doc/UsrLocal'
+CMAKE_INSTALL_INCLUDEDIR='include'
+CMAKE_INSTALL_INFODIR='share/info'
+CMAKE_INSTALL_LIBDIR='(lib|lib64)'
+CMAKE_INSTALL_LIBEXECDIR='libexec'
+CMAKE_INSTALL_LOCALEDIR='share/locale'
+CMAKE_INSTALL_LOCALSTATEDIR='var'
+CMAKE_INSTALL_RUNSTATEDIR='var/run'
+CMAKE_INSTALL_MANDIR='man'
+CMAKE_INSTALL_SBINDIR='sbin'
+CMAKE_INSTALL_SHAREDSTATEDIR='com'
+CMAKE_INSTALL_SYSCONFDIR='etc'
+CMAKE_INSTALL_FULL_BINDIR='/usr/local/bin'
+CMAKE_INSTALL_FULL_DATADIR='/usr/local/share'
+CMAKE_INSTALL_FULL_DATAROOTDIR='/usr/local/share'
+CMAKE_INSTALL_FULL_DOCDIR='/usr/local/share/doc/UsrLocal'
+CMAKE_INSTALL_FULL_INCLUDEDIR='/usr/local/include'
+CMAKE_INSTALL_FULL_INFODIR='/usr/local/share/info'
+CMAKE_INSTALL_FULL_LIBDIR='/usr/local/(lib|lib64)'
+CMAKE_INSTALL_FULL_LIBEXECDIR='/usr/local/libexec'
+CMAKE_INSTALL_FULL_LOCALEDIR='/usr/local/share/locale'
+CMAKE_INSTALL_FULL_LOCALSTATEDIR='/usr/local/var'
+CMAKE_INSTALL_FULL_RUNSTATEDIR='/usr/local/var/run'
+CMAKE_INSTALL_FULL_MANDIR='/usr/local/man'
+CMAKE_INSTALL_FULL_SBINDIR='/usr/local/sbin'
+CMAKE_INSTALL_FULL_SHAREDSTATEDIR='/usr/local/com'
+CMAKE_INSTALL_FULL_SYSCONFDIR='/usr/local/etc'$
diff --git a/Tests/RunCMake/GenerateExportHeader/GEH.cmake b/Tests/RunCMake/GenerateExportHeader/GEH.cmake
index e0677a7a3..ae9a84c43 100644
--- a/Tests/RunCMake/GenerateExportHeader/GEH.cmake
+++ b/Tests/RunCMake/GenerateExportHeader/GEH.cmake
@@ -45,13 +45,6 @@ include(GenerateExportHeader)
set(CMAKE_CXX_STANDARD 98)
-# Those versions of the HP compiler that need a flag to get proper C++98
-# template support also need a flag to use the newer C++ library.
-if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
- CMAKE_CXX98_STANDARD_COMPILE_OPTION STREQUAL "+hpxstd98")
- string(APPEND CMAKE_CXX_FLAGS " -AA")
-endif ()
-
# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
@@ -60,7 +53,16 @@ endif()
add_subdirectory(lib_shared_and_static)
-add_compiler_export_flags()
+if(CMAKE_SYSTEM_NAME MATCHES "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
+ AND CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY)
+ # With GNU 7 on AIX, passing -fvisibility=hidden when driving the
+ # linker for a shared library drops the so init/destruct symbols.
+ # Just use the modern approach instead of testing the macro.
+ set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+ set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
+else()
+ add_compiler_export_flags()
+endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR})
@@ -83,6 +85,7 @@ macro_add_test_library(libshared)
macro_add_test_library(libstatic)
add_subdirectory(nodeprecated)
+add_subdirectory(includeguard)
if(NOT BORLAND)
add_subdirectory(c_identifier)
endif()
diff --git a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake
index 9423ef5dd..18c334080 100644
--- a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake
@@ -4,7 +4,7 @@ function(run_GEH)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GEH-build)
set(RunCMake_TEST_NO_CLEAN 1)
- if(RunCMake_GENERATOR MATCHES "Make|Ninja")
+ if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif()
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
@@ -12,6 +12,8 @@ function(run_GEH)
run_cmake(GEH)
run_cmake_command(GEH-build ${CMAKE_COMMAND} --build . --config Debug)
run_cmake_command(GEH-run ${RunCMake_TEST_BINARY_DIR}/GenerateExportHeader)
+ run_cmake_command(GEH-incguard-macro-run ${RunCMake_TEST_BINARY_DIR}/test_includeguard_macro)
+ run_cmake_command(GEH-incguard-custom-run ${RunCMake_TEST_BINARY_DIR}/test_includeguard_custom)
file(STRINGS "${RunCMake_TEST_BINARY_DIR}/failure_test_targets"
failure_test_targets)
diff --git a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp
index 7e3e0e43f..ba7767986 100644
--- a/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp
+++ b/Tests/RunCMake/GenerateExportHeader/exportheader_test.cpp
@@ -1,13 +1,13 @@
-#include "libshared.h"
-
-#include "libstatic.h"
-
#include <fstream>
#include <iostream>
-#include <stdlib.h>
#include <string>
+#include <stdlib.h>
+
+#include "libshared.h"
+#include "libstatic.h"
+
void compare(const char* refName, const char* testName)
{
std::ifstream ref;
diff --git a/Tests/RunCMake/GenerateExportHeader/includeguard/CMakeLists.txt b/Tests/RunCMake/GenerateExportHeader/includeguard/CMakeLists.txt
new file mode 100644
index 000000000..514d27b67
--- /dev/null
+++ b/Tests/RunCMake/GenerateExportHeader/includeguard/CMakeLists.txt
@@ -0,0 +1,19 @@
+set(libincludeguard_SRC libincludeguard.cpp)
+
+add_library(includeguard_macro ${libincludeguard_SRC})
+generate_export_header(includeguard_macro)
+
+set(EXPORT_HEADER includeguard_macro_export.h)
+set(DEF_SYMBOL INCLUDEGUARD_MACRO_EXPORT_H)
+set(NDEF_SYMBOL CUSTOM_GUARD)
+configure_file(main.cpp.in main_macro.cpp)
+add_executable(test_includeguard_macro ${CMAKE_CURRENT_BINARY_DIR}/main_macro.cpp)
+
+add_library(includeguard_custom ${libincludeguard_SRC})
+generate_export_header(includeguard_custom INCLUDE_GUARD_NAME CUSTOM_GUARD)
+
+set(EXPORT_HEADER includeguard_custom_export.h)
+set(DEF_SYMBOL CUSTOM_GUARD)
+set(NDEF_SYMBOL INCLUDEGUARD_CUSTOM_EXPORT_H)
+configure_file(main.cpp.in main_custom.cpp)
+add_executable(test_includeguard_custom ${CMAKE_CURRENT_BINARY_DIR}/main_custom.cpp)
diff --git a/Tests/RunCMake/GenerateExportHeader/includeguard/libincludeguard.cpp b/Tests/RunCMake/GenerateExportHeader/includeguard/libincludeguard.cpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/GenerateExportHeader/includeguard/libincludeguard.cpp
diff --git a/Tests/RunCMake/GenerateExportHeader/includeguard/main.cpp.in b/Tests/RunCMake/GenerateExportHeader/includeguard/main.cpp.in
new file mode 100644
index 000000000..51bd5d95d
--- /dev/null
+++ b/Tests/RunCMake/GenerateExportHeader/includeguard/main.cpp.in
@@ -0,0 +1,10 @@
+#include "@EXPORT_HEADER@"
+
+int main()
+{
+#if defined(@DEF_SYMBOL@) && !defined(@NDEF_SYMBOL@)
+ return 0;
+#else
+ return 1;
+#endif
+}
diff --git a/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp b/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp
index 9ac838183..752b49e71 100644
--- a/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp
+++ b/Tests/RunCMake/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp
@@ -1,7 +1,7 @@
#include "libshared_and_static.h"
#ifndef MY_CUSTOM_CONTENT_ADDED
-#error "MY_CUSTOM_CONTENT_ADDED not defined!"
+# error "MY_CUSTOM_CONTENT_ADDED not defined!"
#endif
int libshared_and_static::Class::method() const
diff --git a/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt b/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt
index c4a761c74..9516a5aa2 100644
--- a/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt
+++ b/Tests/RunCMake/GenerateExportHeader/libshared/CMakeLists.txt
@@ -1,7 +1,5 @@
include(GenerateExportHeader)
-add_compiler_export_flags()
-
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_library(libshared SHARED libshared.cpp)
diff --git a/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt b/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt
index 0fd136cee..56e833524 100644
--- a/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt
+++ b/Tests/RunCMake/GenerateExportHeader/libstatic/CMakeLists.txt
@@ -2,8 +2,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
include(GenerateExportHeader)
-add_compiler_export_flags()
-
# Show that the export header has no effect on a static library.
add_library(libstatic STATIC libstatic.cpp)
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes b/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes
index 883a7f16d..d9b566e13 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes
+++ b/Tests/RunCMake/GenerateExportHeader/reference/.gitattributes
@@ -1,2 +1,2 @@
# Exclude reference content from formatting.
-* -format.clang-format
+* -format.clang-format-6.0
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h
index e8af0a5c1..0b1dcba5b 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h
index 598bd71be..5e3ac9f3f 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/Empty/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h
index cc20e09b0..dac4fda65 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h
index 4aaa84863..b6e2a4a88 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/MinGW/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h
index 053ad1869..11f8042e3 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h
index 4aaa84863..b6e2a4a88 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h
index 808ff0131..1481acd87 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h
index 4aaa84863..b6e2a4a88 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/UNIX_DeprecatedOnly/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h
index cc20e09b0..dac4fda65 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h
index 4aaa84863..b6e2a4a88 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32-Clang/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h
index 4e675af6c..3ba2d2eac 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h
index 4d5ed4ecd..3c7e093ab 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/Win32/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h
index 84340e305..bf9163ebe 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libshared_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSHARED_EXPORT_H */
diff --git a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h
index 598bd71be..5e3ac9f3f 100644
--- a/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h
+++ b/Tests/RunCMake/GenerateExportHeader/reference/WinEmpty/libstatic_export.h
@@ -39,4 +39,4 @@
# endif
#endif
-#endif
+#endif /* LIBSTATIC_EXPORT_H */
diff --git a/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt
index 0e48ba423..86d3e0472 100644
--- a/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/BadAND-stderr.txt
@@ -50,4 +50,6 @@ CMake Error at BadAND.cmake:1 \(add_custom_target\):
Parameters to \$<AND> must resolve to either '0' or '1'.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists.txt:3 \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt
index 964ea4d4e..42dd0ce50 100644
--- a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt
@@ -32,4 +32,6 @@ CMake Error at BadCONFIG.cmake:1 \(add_custom_target\):
Expression syntax not recognized.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists.txt:3 \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/GeneratorExpression/BadNOT-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadNOT-stderr.txt
index e5e628c30..627327c12 100644
--- a/Tests/RunCMake/GeneratorExpression/BadNOT-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/BadNOT-stderr.txt
@@ -49,4 +49,6 @@ CMake Error at BadNOT.cmake:1 \(add_custom_target\):
\$<NOT> parameter must resolve to exactly one '0' or '1' value.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists.txt:3 \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt
index eb263286e..56e6af00f 100644
--- a/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/BadOR-stderr.txt
@@ -50,4 +50,6 @@ CMake Error at BadOR.cmake:1 \(add_custom_target\):
Parameters to \$<OR> must resolve to either '0' or '1'.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists.txt:3 \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt
index 8d3c4ccd6..a08e7b236 100644
--- a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH-stderr.txt
@@ -15,3 +15,12 @@ CMake Error at BadSHELL_PATH.cmake:[0-9]+ \(add_custom_target\):
"Relative/Path" is not an absolute path.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
++
+CMake Error at BadSHELL_PATH.cmake:[0-9]+ \(add_custom_target\):
+ Error evaluating generator expression:
+
+ \$<SHELL_PATH:;>
+
+ "" is not an absolute path.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake
index 5eff7bccb..0e7c342e4 100644
--- a/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake
+++ b/Tests/RunCMake/GeneratorExpression/BadSHELL_PATH.cmake
@@ -1,4 +1,5 @@
add_custom_target(check ALL COMMAND check
$<SHELL_PATH:>
$<SHELL_PATH:Relative/Path>
+ "$<SHELL_PATH:;>"
VERBATIM)
diff --git a/Tests/RunCMake/GeneratorExpression/BadStrEqual-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadStrEqual-stderr.txt
index dd0d931be..2f04c78f0 100644
--- a/Tests/RunCMake/GeneratorExpression/BadStrEqual-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/BadStrEqual-stderr.txt
@@ -35,4 +35,6 @@ CMake Error at BadStrEqual.cmake:1 \(add_custom_target\):
\$<STREQUAL> expression requires 2 comma separated parameters, but got 3
instead.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists.txt:3 \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/GeneratorExpression/BadTargetName-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadTargetName-stderr.txt
index 969393acc..98eed1f0a 100644
--- a/Tests/RunCMake/GeneratorExpression/BadTargetName-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/BadTargetName-stderr.txt
@@ -5,4 +5,6 @@ CMake Error at BadTargetName.cmake:1 \(add_custom_target\):
\$<TARGET_NAME> expression requires literal input.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists.txt:3 \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt
index 533d38cef..a597d79b6 100644
--- a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\):
+CMake Error at BadTargetTypeObject.cmake:2 \(add_custom_target\):
Error evaluating generator expression:
\$<TARGET_FILE:objlib>
@@ -7,7 +7,7 @@ CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\):
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
-CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\):
+CMake Error at BadTargetTypeObject.cmake:2 \(add_custom_target\):
Error evaluating generator expression:
\$<TARGET_SONAME_FILE:objlib>
@@ -16,7 +16,7 @@ CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\):
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
-CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\):
+CMake Error at BadTargetTypeObject.cmake:2 \(add_custom_target\):
Error evaluating generator expression:
\$<TARGET_LINKER_FILE:objlib>
diff --git a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake
index c47ee2bec..60e2c0dbc 100644
--- a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake
+++ b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake
@@ -1,5 +1,4 @@
-enable_language(C)
-add_library(objlib OBJECT empty.c)
+add_library(objlib OBJECT)
add_custom_target(check ALL COMMAND echo
$<TARGET_FILE:objlib>
$<TARGET_SONAME_FILE:objlib>
diff --git a/Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake
index d5b85c936..dfa23e09e 100644
--- a/Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake
+++ b/Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake
@@ -1,5 +1,5 @@
-project(CMP0044-WARN)
+enable_language(C)
string(TOLOWER ${CMAKE_C_COMPILER_ID} lc_test)
if (lc_test STREQUAL CMAKE_C_COMPILER_ID)
diff --git a/Tests/RunCMake/GeneratorExpression/CMP0085-NEW-check.cmake b/Tests/RunCMake/GeneratorExpression/CMP0085-NEW-check.cmake
new file mode 100644
index 000000000..520bf3dcd
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/CMP0085-NEW-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/CMP0085-NEW-generated.txt" content)
+
+set(expected "101011")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/CMP0085-NEW.cmake b/Tests/RunCMake/GeneratorExpression/CMP0085-NEW.cmake
new file mode 100644
index 000000000..ee85c0d36
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/CMP0085-NEW.cmake
@@ -0,0 +1,4 @@
+cmake_policy(SET CMP0070 NEW)
+file(GENERATE OUTPUT CMP0085-NEW-generated.txt CONTENT
+ "$<IN_LIST:,>$<IN_LIST:,a>$<IN_LIST:,;a>$<IN_LIST:a,>$<IN_LIST:a,a>$<IN_LIST:a,;a>"
+ )
diff --git a/Tests/RunCMake/GeneratorExpression/CMP0085-OLD-check.cmake b/Tests/RunCMake/GeneratorExpression/CMP0085-OLD-check.cmake
new file mode 100644
index 000000000..c387db77c
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/CMP0085-OLD-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/CMP0085-OLD-generated.txt" content)
+
+set(expected "000011")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/CMP0085-OLD.cmake b/Tests/RunCMake/GeneratorExpression/CMP0085-OLD.cmake
new file mode 100644
index 000000000..31b6a51b4
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/CMP0085-OLD.cmake
@@ -0,0 +1,4 @@
+cmake_policy(SET CMP0070 NEW)
+file(GENERATE OUTPUT CMP0085-OLD-generated.txt CONTENT
+ "$<IN_LIST:,>$<IN_LIST:,a>$<IN_LIST:,;a>$<IN_LIST:a,>$<IN_LIST:a,a>$<IN_LIST:a,;a>"
+ )
diff --git a/Tests/RunCMake/GeneratorExpression/CMP0085-WARN-check.cmake b/Tests/RunCMake/GeneratorExpression/CMP0085-WARN-check.cmake
new file mode 100644
index 000000000..f7bcf0ff1
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/CMP0085-WARN-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/CMP0085-WARN-generated.txt" content)
+
+set(expected "000011")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/CMP0085-WARN-stderr.txt b/Tests/RunCMake/GeneratorExpression/CMP0085-WARN-stderr.txt
new file mode 100644
index 000000000..81bd45028
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/CMP0085-WARN-stderr.txt
@@ -0,0 +1,33 @@
+CMake Warning \(dev\) at CMP0085-WARN\.cmake:[0-9]+ \(file\):
+ Policy CMP0085 is not set: \$<IN_LIST:\.\.\.> handles empty list items\. Run
+ "cmake --help-policy CMP0085" for policy details\. Use the cmake_policy
+ command to set the policy and suppress this warning\.
+
+ Search Item:
+
+ ""
+
+ List:
+
+ ""
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\. Use -Wno-dev to suppress it\.
+
+CMake Warning \(dev\) at CMP0085-WARN\.cmake:[0-9]+ \(file\):
+ Policy CMP0085 is not set: \$<IN_LIST:\.\.\.> handles empty list items\. Run
+ "cmake --help-policy CMP0085" for policy details\. Use the cmake_policy
+ command to set the policy and suppress this warning\.
+
+ Search Item:
+
+ ""
+
+ List:
+
+ ";a"
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\. Use -Wno-dev to suppress it\.
diff --git a/Tests/RunCMake/GeneratorExpression/CMP0085-WARN.cmake b/Tests/RunCMake/GeneratorExpression/CMP0085-WARN.cmake
new file mode 100644
index 000000000..59c782653
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/CMP0085-WARN.cmake
@@ -0,0 +1,4 @@
+cmake_policy(SET CMP0070 NEW)
+file(GENERATE OUTPUT CMP0085-WARN-generated.txt CONTENT
+ "$<IN_LIST:,>$<IN_LIST:,a>$<IN_LIST:,;a>$<IN_LIST:a,>$<IN_LIST:a,a>$<IN_LIST:a,;a>"
+ )
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command-stderr.txt
index 789b4d09a..c8f773a0a 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command-stderr.txt
@@ -1,10 +1,10 @@
-CMake Error at COMPILE_LANGUAGE-add_custom_command.cmake:6 \(add_custom_command\):
+CMake Error at COMPILE_LANGUAGE-add_custom_command.cmake:2 \(add_custom_command\):
Error evaluating generator expression:
\$<COMPILE_LANGUAGE>
- \$<COMPILE_LANGUAGE:...> may only be used to specify include directories
- compile definitions, compile options and to evaluate components of the
+ \$<COMPILE_LANGUAGE:...> may only be used to specify include directories,
+ compile definitions, compile options, and to evaluate components of the
file\(GENERATE\) command.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command.cmake
index f4ba26153..c3f051ab4 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command.cmake
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_command.cmake
@@ -1,8 +1,4 @@
-
-enable_language(C)
-
-add_library(empty empty.c)
-
-add_custom_command(TARGET empty PRE_BUILD
+add_custom_target(drive)
+add_custom_command(TARGET drive PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANGUAGE>
)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target-stderr.txt
index 400fbc035..7025838b1 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target-stderr.txt
@@ -1,10 +1,10 @@
-CMake Error at COMPILE_LANGUAGE-add_custom_target.cmake:4 \(add_custom_target\):
+CMake Error at COMPILE_LANGUAGE-add_custom_target.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<COMPILE_LANGUAGE>
- \$<COMPILE_LANGUAGE:...> may only be used to specify include directories
- compile definitions, compile options and to evaluate components of the
+ \$<COMPILE_LANGUAGE:...> may only be used to specify include directories,
+ compile definitions, compile options, and to evaluate components of the
file\(GENERATE\) command.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target.cmake
index 4102623f8..b826772e2 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target.cmake
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_custom_target.cmake
@@ -1,6 +1,3 @@
-
-enable_language(C)
-
-add_custom_target(empty
+add_custom_target(drive
COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANGUAGE>
)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable-stderr.txt
index e45bb020e..8d05e59a0 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable-stderr.txt
@@ -1,10 +1,10 @@
-CMake Error at COMPILE_LANGUAGE-add_executable.cmake:4 \(add_executable\):
+CMake Error at COMPILE_LANGUAGE-add_executable.cmake:1 \(add_executable\):
Error evaluating generator expression:
\$<COMPILE_LANGUAGE>
- \$<COMPILE_LANGUAGE:...> may only be used to specify include directories
- compile definitions, compile options and to evaluate components of the
+ \$<COMPILE_LANGUAGE:...> may only be used to specify include directories,
+ compile definitions, compile options, and to evaluate components of the
file\(GENERATE\) command.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable.cmake
index 5c2ff351c..ff965a9e7 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable.cmake
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_executable.cmake
@@ -1,4 +1 @@
-
-enable_language(C)
-
add_executable(empty empty.$<COMPILE_LANGUAGE>)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library-stderr.txt
index c9ee6fe2a..2ac9b76ac 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library-stderr.txt
@@ -1,10 +1,10 @@
-CMake Error at COMPILE_LANGUAGE-add_library.cmake:4 \(add_library\):
+CMake Error at COMPILE_LANGUAGE-add_library.cmake:1 \(add_library\):
Error evaluating generator expression:
\$<COMPILE_LANGUAGE>
- \$<COMPILE_LANGUAGE:...> may only be used to specify include directories
- compile definitions, compile options and to evaluate components of the
+ \$<COMPILE_LANGUAGE:...> may only be used to specify include directories,
+ compile definitions, compile options, and to evaluate components of the
file\(GENERATE\) command.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library.cmake
index dd9f82403..dd1b5a2d7 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library.cmake
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_library.cmake
@@ -1,4 +1 @@
-
-enable_language(C)
-
add_library(empty empty.$<COMPILE_LANGUAGE>)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_test-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_test-stderr.txt
index 9955f5d91..fd8a731f1 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_test-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-add_test-stderr.txt
@@ -3,8 +3,8 @@ CMake Error at COMPILE_LANGUAGE-add_test.cmake:5 \(add_test\):
\$<COMPILE_LANGUAGE>
- \$<COMPILE_LANGUAGE:...> may only be used to specify include directories
- compile definitions, compile options and to evaluate components of the
+ \$<COMPILE_LANGUAGE:...> may only be used to specify include directories,
+ compile definitions, compile options, and to evaluate components of the
file\(GENERATE\) command.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-install-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-install-stderr.txt
index eca700f4d..bef7f63b9 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-install-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-install-stderr.txt
@@ -3,6 +3,6 @@ CMake Error:
\$<COMPILE_LANGUAGE>
- \$<COMPILE_LANGUAGE:...> may only be used to specify include directories
- compile definitions, compile options and to evaluate components of the
+ \$<COMPILE_LANGUAGE:...> may only be used to specify include directories,
+ compile definitions, compile options, and to evaluate components of the
file\(GENERATE\) command.
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources-stderr.txt
index 2d324e2ac..8e7f88125 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources-stderr.txt
@@ -1,10 +1,10 @@
-CMake Error at COMPILE_LANGUAGE-target_sources.cmake:5 \(target_sources\):
+CMake Error at COMPILE_LANGUAGE-target_sources.cmake:2 \(target_sources\):
Error evaluating generator expression:
\$<COMPILE_LANGUAGE>
- \$<COMPILE_LANGUAGE:...> may only be used to specify include directories
- compile definitions, compile options and to evaluate components of the
+ \$<COMPILE_LANGUAGE:...> may only be used to specify include directories,
+ compile definitions, compile options, and to evaluate components of the
file\(GENERATE\) command.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources.cmake
index 0c78acd74..a4a5abb5e 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources.cmake
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-target_sources.cmake
@@ -1,5 +1,2 @@
-
-enable_language(C)
-
-add_library(empty empty.c)
+add_library(empty)
target_sources(empty PRIVATE empty.$<COMPILE_LANGUAGE>)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-stderr.txt
deleted file mode 100644
index 444da45ef..000000000
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang-stderr.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at COMPILE_LANGUAGE-unknown-lang.cmake:4 \(target_compile_options\):
- Error evaluating generator expression:
-
- \$<COMPILE_LANGUAGE:CXX>
-
- \$<COMPILE_LANGUAGE:...> Unknown language.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake
index cec12a3fb..00dd29070 100644
--- a/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANGUAGE-unknown-lang.cmake
@@ -1,4 +1,4 @@
enable_language(C)
add_executable(empty empty.c)
-target_compile_options(empty PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wall>)
+target_compile_options(empty PRIVATE $<$<COMPILE_LANGUAGE:CXX>:$<TARGET_EXISTS:too,many,parameters>>)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-stderr.txt
new file mode 100644
index 000000000..2ee96ed14
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at COMPILE_LANG_AND_ID-add_custom_command.cmake:2 \(add_custom_command\):
+ Error evaluating generator expression:
+
+ \$<COMPILE_LANG_AND_ID>
+
+ \$<COMPILE_LANG_AND_ID> expression requires at least two parameters.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command.cmake
new file mode 100644
index 000000000..9bd5e8e7e
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_command.cmake
@@ -0,0 +1,4 @@
+add_custom_target(drive)
+add_custom_command(TARGET drive PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANG_AND_ID>
+)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-stderr.txt
new file mode 100644
index 000000000..589e64b4e
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target-stderr.txt
@@ -0,0 +1,11 @@
+CMake Error at COMPILE_LANG_AND_ID-add_custom_target.cmake:2 \(add_custom_target\):
+ Error evaluating generator expression:
+
+ \$<COMPILE_LANG_AND_ID:LANG,ID>
+
+ \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to
+ specify include directories, compile definitions, and compile options. It
+ may not be used with the add_custom_command, add_custom_target, or
+ file\(GENERATE\) commands.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target.cmake
new file mode 100644
index 000000000..398db1978
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_custom_target.cmake
@@ -0,0 +1,4 @@
+
+add_custom_target(drive
+ COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANG_AND_ID:LANG,ID>
+)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-stderr.txt
new file mode 100644
index 000000000..3b3f38d37
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable-stderr.txt
@@ -0,0 +1,11 @@
+CMake Error at COMPILE_LANG_AND_ID-add_executable.cmake:1 \(add_executable\):
+ Error evaluating generator expression:
+
+ \$<COMPILE_LANG_AND_ID:C,MSVC>
+
+ \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to
+ specify include directories, compile definitions, and compile options. It
+ may not be used with the add_custom_command, add_custom_target, or
+ file\(GENERATE\) commands.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable.cmake
new file mode 100644
index 000000000..2245f5046
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_executable.cmake
@@ -0,0 +1,5 @@
+add_executable(empty main.c
+ $<$<COMPILE_LANG_AND_ID:C,MSVC>:empty.c>
+ $<$<COMPILE_LANG_AND_ID:C,GNU>:empty2.c>
+ $<$<COMPILE_LANG_AND_ID:C,Clang>:empty3.c>
+ )
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-stderr.txt
new file mode 100644
index 000000000..4cbf000ea
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library-stderr.txt
@@ -0,0 +1,11 @@
+CMake Error at COMPILE_LANG_AND_ID-add_library.cmake:2 \(add_library\):
+ Error evaluating generator expression:
+
+ \$<COMPILE_LANG_AND_ID:C,MSVC>
+
+ \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to
+ specify include directories, compile definitions, and compile options. It
+ may not be used with the add_custom_command, add_custom_target, or
+ file\(GENERATE\) commands.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library.cmake
new file mode 100644
index 000000000..044962a53
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_library.cmake
@@ -0,0 +1,2 @@
+
+add_library(empty empty.$<COMPILE_LANG_AND_ID:C,MSVC>)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-stderr.txt
new file mode 100644
index 000000000..26a5940f3
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test-stderr.txt
@@ -0,0 +1,11 @@
+CMake Error at COMPILE_LANG_AND_ID-add_test.cmake:5 \(add_test\):
+ Error evaluating generator expression:
+
+ \$<COMPILE_LANG_AND_ID:CXX,GNU>
+
+ \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to
+ specify include directories, compile definitions, and compile options. It
+ may not be used with the add_custom_command, add_custom_target, or
+ file\(GENERATE\) commands.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test.cmake
new file mode 100644
index 000000000..b5b6c2b82
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-add_test.cmake
@@ -0,0 +1,5 @@
+
+include(CTest)
+enable_testing()
+
+add_test(NAME dummy COMMAND ${CMAKE_COMMAND} -E echo $<COMPILE_LANG_AND_ID:CXX,GNU>)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-stderr.txt
new file mode 100644
index 000000000..0c4ecd091
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error:
+ Error evaluating generator expression:
+
+ \$<COMPILE_LANG_AND_ID:C,MSVC>
+
+ \$<COMPILE_LANG_AND_ID:lang,id> may only be used with binary targets to
+ specify include directories, compile definitions, and compile options. It
+ may not be used with the add_custom_command, add_custom_target, or
+ file\(GENERATE\) commands.
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install.cmake
new file mode 100644
index 000000000..c13eda6ec
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-install.cmake
@@ -0,0 +1,5 @@
+
+install(FILES
+ empty.$<COMPILE_LANG_AND_ID:C,MSVC>
+ DESTINATION src
+)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-result.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-stderr.txt b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-stderr.txt
new file mode 100644
index 000000000..3ecbdc360
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at COMPILE_LANG_AND_ID-target_sources.cmake:2 \(target_sources\):
+ Error evaluating generator expression:
+
+ \$<COMPILE_LANG_AND_ID>
+
+ \$<COMPILE_LANG_AND_ID> expression requires at least two parameters.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources.cmake
new file mode 100644
index 000000000..a2c9b03f5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-target_sources.cmake
@@ -0,0 +1,2 @@
+add_library(empty)
+target_sources(empty PRIVATE empty.$<COMPILE_LANG_AND_ID>)
diff --git a/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-unknown-lang.cmake b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-unknown-lang.cmake
new file mode 100644
index 000000000..b9e840b41
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/COMPILE_LANG_AND_ID-unknown-lang.cmake
@@ -0,0 +1,4 @@
+
+enable_language(C)
+add_executable(empty empty.c)
+target_compile_options(empty PRIVATE $<$<COMPILE_LANG_AND_ID:CXX,GNU>:$<TARGET_EXISTS:too,many,parameters>>)
diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-Exclude-check.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-Exclude-check.cmake
new file mode 100644
index 000000000..605ae4d19
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/FILTER-Exclude-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/FILTER-generated.txt" content)
+
+set(expected "DO_NOT_FILTER_THIS;thisisanitem")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-Exclude.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-Exclude.cmake
new file mode 100644
index 000000000..b879be220
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/FILTER-Exclude.cmake
@@ -0,0 +1,4 @@
+cmake_policy(VERSION 3.11)
+
+set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING)
+file(GENERATE OUTPUT "FILTER-generated.txt" CONTENT "$<FILTER:${mylist},EXCLUDE,^FILTER_THIS_.+>")
diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-Include-check.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-Include-check.cmake
new file mode 100644
index 000000000..9d48d982a
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/FILTER-Include-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/FILTER-generated.txt" content)
+
+set(expected "FILTER_THIS_BIT;FILTER_THIS_THING")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-Include.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-Include.cmake
new file mode 100644
index 000000000..5e0260ad7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/FILTER-Include.cmake
@@ -0,0 +1,4 @@
+cmake_policy(VERSION 3.11)
+
+set(mylist FILTER_THIS_BIT DO_NOT_FILTER_THIS thisisanitem FILTER_THIS_THING)
+file(GENERATE OUTPUT "FILTER-generated.txt" CONTENT "$<FILTER:${mylist},INCLUDE,^FILTER_THIS_.+>")
diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-result.txt b/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-stderr.txt b/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-stderr.txt
new file mode 100644
index 000000000..dd1092556
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at FILTER-InvalidOperator.cmake:3 \(file\):
+ Error evaluating generator expression:
+
+ \$<FILTER:,RM,>
+
+ \$<FILTER:...> second parameter must be either INCLUDE or EXCLUDE
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator.cmake
new file mode 100644
index 000000000..26f3917dc
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/FILTER-InvalidOperator.cmake
@@ -0,0 +1,3 @@
+cmake_policy(VERSION 3.11)
+
+file(GENERATE OUTPUT "FILTER-generated.txt" CONTENT "$<FILTER:,RM,>")
diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-empty-check.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-empty-check.cmake
new file mode 100644
index 000000000..2844484c5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/FILTER-empty-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/FILTER-generated.txt" content)
+
+set(expected "")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/FILTER-empty.cmake b/Tests/RunCMake/GeneratorExpression/FILTER-empty.cmake
new file mode 100644
index 000000000..e0fc671d0
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/FILTER-empty.cmake
@@ -0,0 +1,3 @@
+cmake_policy(VERSION 3.11)
+
+file(GENERATE OUTPUT "FILTER-generated.txt" CONTENT "$<FILTER:,INCLUDE,>")
diff --git a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-check.cmake b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-check.cmake
new file mode 100644
index 000000000..df7674051
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/GENEX_EVAL-generated.txt" content)
+
+set(expected "BEFORE_PROPERTY1_AFTER")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion1-result.txt b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion1-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion1-stderr.txt b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion1-stderr.txt
new file mode 100644
index 000000000..012dff658
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion1-stderr.txt
@@ -0,0 +1,26 @@
+^CMake Error at GENEX_EVAL-recursion1.cmake:7 \(add_custom_target\):
+ Error evaluating generator expression:
+
+ \$<GENEX_EVAL:\$<TARGET_PROPERTY:CUSTOM_PROPERTY>>
+
+ Dependency loop found.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at GENEX_EVAL-recursion1.cmake:7 \(add_custom_target\):
+ Loop step 1
+
+ \$<GENEX_EVAL:\$<TARGET_PROPERTY:CUSTOM_PROPERTY>>
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at GENEX_EVAL-recursion1.cmake:7 \(add_custom_target\):
+ Loop step 2
+
+ \$<TARGET_GENEX_EVAL:recursion,\$<TARGET_PROPERTY:recursion,CUSTOM_PROPERTY>>
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion1.cmake b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion1.cmake
new file mode 100644
index 000000000..6596a81ab
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion1.cmake
@@ -0,0 +1,9 @@
+
+enable_language(C)
+
+add_library (recursion SHARED empty.c)
+set_property (TARGET recursion PROPERTY CUSTOM_PROPERTY "$<GENEX_EVAL:$<TARGET_PROPERTY:CUSTOM_PROPERTY>>")
+
+add_custom_target (drive
+ COMMAND echo "$<TARGET_GENEX_EVAL:recursion,$<TARGET_PROPERTY:recursion,CUSTOM_PROPERTY>>"
+ DEPENDS recursion)
diff --git a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-result.txt b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-stderr.txt b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-stderr.txt
new file mode 100644
index 000000000..ed6840057
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-stderr.txt
@@ -0,0 +1,26 @@
+^CMake Error at GENEX_EVAL-recursion2.cmake:8 \(add_custom_target\):
+ Error evaluating generator expression:
+
+ \$<GENEX_EVAL:\$<TARGET_PROPERTY:CUSTOM_PROPERTY2>>
+
+ Dependency loop found.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at GENEX_EVAL-recursion2.cmake:8 \(add_custom_target\):
+ Loop step 1
+
+ \$<GENEX_EVAL:\$<TARGET_PROPERTY:CUSTOM_PROPERTY1>>
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at GENEX_EVAL-recursion2.cmake:8 \(add_custom_target\):
+ Loop step 2
+
+ \$<GENEX_EVAL:\$<TARGET_PROPERTY:CUSTOM_PROPERTY2>>
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2.cmake b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2.cmake
new file mode 100644
index 000000000..773749f2c
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2.cmake
@@ -0,0 +1,10 @@
+
+enable_language(C)
+
+add_library(recursion SHARED empty.c)
+set_property (TARGET recursion PROPERTY CUSTOM_PROPERTY1 "$<GENEX_EVAL:$<TARGET_PROPERTY:CUSTOM_PROPERTY2>>")
+set_property (TARGET recursion PROPERTY CUSTOM_PROPERTY2 "$<GENEX_EVAL:$<TARGET_PROPERTY:CUSTOM_PROPERTY1>>")
+
+add_custom_target (drive
+ COMMAND echo "$<TARGET_GENEX_EVAL:recursion,$<TARGET_PROPERTY:recursion,CUSTOM_PROPERTY1>>"
+ DEPENDS recursion)
diff --git a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL.cmake b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL.cmake
new file mode 100644
index 000000000..153cd176f
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL.cmake
@@ -0,0 +1,12 @@
+
+cmake_policy(VERSION 3.11)
+
+enable_language(C)
+
+add_library (example SHARED empty.c)
+set_property (TARGET example PROPERTY CUSTOM_PROPERTY1 "PROPERTY1")
+set_property (TARGET example PROPERTY CUSTOM_PROPERTY2 "$<TARGET_PROPERTY:CUSTOM_PROPERTY1>")
+set_property (TARGET example PROPERTY CUSTOM_PROPERTY3 "$<GENEX_EVAL:BEFORE_$<TARGET_PROPERTY:CUSTOM_PROPERTY2>_AFTER>")
+set_property (TARGET example PROPERTY CUSTOM_PROPERTY4 "$<GENEX_EVAL:$<TARGET_PROPERTY:CUSTOM_PROPERTY3>>")
+
+file(GENERATE OUTPUT "GENEX_EVAL-generated.txt" CONTENT "$<TARGET_GENEX_EVAL:example,$<TARGET_PROPERTY:example,CUSTOM_PROPERTY4>>")
diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-result.txt b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt
new file mode 100644
index 000000000..3b2a814a7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at ImportedTarget-TARGET_PDB_FILE_BASE_NAME.cmake:2 \(add_custom_target\):
+ Error evaluating generator expression:
+
+ \$<TARGET_PDB_FILE_BASE_NAME:empty>
+
+ TARGET_PDB_FILE_BASE_NAME not allowed for IMPORTED targets.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME.cmake b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME.cmake
new file mode 100644
index 000000000..489d8e620
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/ImportedTarget-TARGET_PDB_FILE_BASE_NAME.cmake
@@ -0,0 +1,2 @@
+add_library(empty UNKNOWN IMPORTED)
+add_custom_target(custom COMMAND echo $<TARGET_PDB_FILE_BASE_NAME:empty>)
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-stderr.txt
new file mode 100644
index 000000000..b061ce3de
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at NonValidCompiler-TARGET_PDB_FILE_BASE_NAME.cmake:6 \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_PDB_FILE_BASE_NAME:empty>
+
+ TARGET_PDB_FILE_BASE_NAME is not supported by the target linker.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME.cmake b/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME.cmake
new file mode 100644
index 000000000..811c3f70f
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidCompiler-TARGET_PDB_FILE_BASE_NAME.cmake
@@ -0,0 +1,9 @@
+
+enable_language(C)
+
+add_library(empty STATIC empty.c)
+
+file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt"
+ CONTENT "[$<TARGET_PDB_FILE_BASE_NAME:empty>]"
+)
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-stderr.txt
index dd7a18304..0c21aa682 100644
--- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at NonValidTarget-CXX_COMPILER_ID.cmake:4 \(add_custom_command\):
+CMake Error at NonValidTarget-CXX_COMPILER_ID.cmake:1 \(add_custom_command\):
Error evaluating generator expression:
\$<CXX_COMPILER_ID>
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID.cmake
index 7dd38da4a..a9fb0925f 100644
--- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID.cmake
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_ID.cmake
@@ -1,8 +1,4 @@
-
-enable_language(CXX)
-
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<CXX_COMPILER_ID>.cpp"
)
-
-add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
+add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-stderr.txt
index d4a064af1..fae1bd225 100644
--- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at NonValidTarget-CXX_COMPILER_VERSION.cmake:4 \(add_custom_command\):
+CMake Error at NonValidTarget-CXX_COMPILER_VERSION.cmake:1 \(add_custom_command\):
Error evaluating generator expression:
\$<CXX_COMPILER_VERSION>
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION.cmake
index 1afb2b56f..41610c422 100644
--- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION.cmake
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-CXX_COMPILER_VERSION.cmake
@@ -1,8 +1,4 @@
-
-enable_language(CXX)
-
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<CXX_COMPILER_VERSION>.cpp"
)
-
-add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
+add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-stderr.txt
index b8e53ed91..337b2996e 100644
--- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at NonValidTarget-C_COMPILER_ID.cmake:4 \(add_custom_command\):
+CMake Error at NonValidTarget-C_COMPILER_ID.cmake:1 \(add_custom_command\):
Error evaluating generator expression:
\$<C_COMPILER_ID>
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID.cmake
index 2d92ee39e..1b02431e1 100644
--- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID.cmake
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_ID.cmake
@@ -1,8 +1,4 @@
-
-enable_language(CXX)
-
-add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp"
- COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<C_COMPILER_ID>.cpp"
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c"
+ COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<C_COMPILER_ID>.c"
)
-
-add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
+add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c")
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-stderr.txt
index 551efe963..d8548b515 100644
--- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at NonValidTarget-C_COMPILER_VERSION.cmake:4 \(add_custom_command\):
+CMake Error at NonValidTarget-C_COMPILER_VERSION.cmake:1 \(add_custom_command\):
Error evaluating generator expression:
\$<C_COMPILER_VERSION>
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION.cmake
index 9b8a53150..bc1ffe059 100644
--- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION.cmake
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-C_COMPILER_VERSION.cmake
@@ -1,8 +1,4 @@
-
-enable_language(CXX)
-
-add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp"
- COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<C_COMPILER_VERSION>.cpp"
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c"
+ COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<C_COMPILER_VERSION>.c"
)
-
-add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
+add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c")
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-stderr.txt
new file mode 100644
index 000000000..fc1324807
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at NonValidTarget-Fortran_COMPILER_ID.cmake:1 \(add_custom_command\):
+ Error evaluating generator expression:
+
+ \$<Fortran_COMPILER_ID>
+
+ \$<Fortran_COMPILER_ID> may only be used with binary targets. It may not be
+ used with add_custom_command or add_custom_target.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID.cmake
new file mode 100644
index 000000000..88a0bfb99
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_ID.cmake
@@ -0,0 +1,4 @@
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c"
+ COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<Fortran_COMPILER_ID>.c"
+)
+add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c")
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-stderr.txt
new file mode 100644
index 000000000..f8a41205c
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at NonValidTarget-Fortran_COMPILER_VERSION.cmake:1 \(add_custom_command\):
+ Error evaluating generator expression:
+
+ \$<Fortran_COMPILER_VERSION>
+
+ \$<Fortran_COMPILER_VERSION> may only be used with binary targets. It may
+ not be used with add_custom_command or add_custom_target.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION.cmake
new file mode 100644
index 000000000..34a4884d4
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-Fortran_COMPILER_VERSION.cmake
@@ -0,0 +1,4 @@
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c"
+ COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<Fortran_COMPILER_VERSION>.c"
+)
+add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c")
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-result.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt
new file mode 100644
index 000000000..c7d245c54
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at NonValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake:6 \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_PDB_FILE_BASE_NAME:empty>
+
+ TARGET_PDB_FILE_BASE_NAME is allowed only for targets with linker created
+ artifacts.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake
new file mode 100644
index 000000000..811c3f70f
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake
@@ -0,0 +1,9 @@
+
+enable_language(C)
+
+add_library(empty STATIC empty.c)
+
+file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt"
+ CONTENT "[$<TARGET_PDB_FILE_BASE_NAME:empty>]"
+)
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-stderr.txt
index 0e87538c6..4babf4375 100644
--- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at NonValidTarget-TARGET_POLICY.cmake:4 \(add_custom_command\):
+CMake Error at NonValidTarget-TARGET_POLICY.cmake:1 \(add_custom_command\):
Error evaluating generator expression:
\$<TARGET_POLICY:CMP0004>
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY.cmake
index 10b37b5a4..55d8a9981 100644
--- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY.cmake
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_POLICY.cmake
@@ -1,8 +1,4 @@
-
-enable_language(CXX)
-
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<TARGET_POLICY:CMP0004>.cpp"
)
-
-add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
+add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-stderr.txt b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-stderr.txt
index 08ad3c2d8..c4149470a 100644
--- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at NonValidTarget-TARGET_PROPERTY.cmake:4 \(add_custom_command\):
+CMake Error at NonValidTarget-TARGET_PROPERTY.cmake:1 \(add_custom_command\):
Error evaluating generator expression:
\$<TARGET_PROPERTY:NotAProperty>
diff --git a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY.cmake b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY.cmake
index 64abc5f90..9e246b278 100644
--- a/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY.cmake
+++ b/Tests/RunCMake/GeneratorExpression/NonValidTarget-TARGET_PROPERTY.cmake
@@ -1,8 +1,4 @@
-
-enable_language(CXX)
-
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp"
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<TARGET_PROPERTY:NotAProperty>.cpp"
)
-
-add_library(empty "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
+add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.cpp")
diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt
index bf592e75c..013c4f25b 100644
--- a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt
+++ b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion-stderr.txt
@@ -1,4 +1,10 @@
CMake Error at OUTPUT_NAME-recursion.cmake:[0-9]+ \(add_executable\):
- Target 'empty1' OUTPUT_NAME depends on itself.
+ Target 'empty2' OUTPUT_NAME depends on itself.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at OUTPUT_NAME-recursion.cmake:[0-9]+ \(add_executable\):
+ Target 'empty2' OUTPUT_NAME depends on itself.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake
index 5cb80509e..006b0daad 100644
--- a/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake
+++ b/Tests/RunCMake/GeneratorExpression/OUTPUT_NAME-recursion.cmake
@@ -1,3 +1,6 @@
enable_language(C)
add_executable(empty1 empty.c)
set_property(TARGET empty1 PROPERTY OUTPUT_NAME $<TARGET_FILE_NAME:empty1>)
+
+add_executable(empty2 empty.c)
+set_property(TARGET empty2 PROPERTY OUTPUT_NAME $<TARGET_FILE_BASE_NAME:empty2>)
diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1-check.cmake
new file mode 100644
index 000000000..e127711eb
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content)
+
+set(expected "1")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1.cmake
new file mode 100644
index 000000000..53934afb0
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1.cmake
@@ -0,0 +1,3 @@
+cmake_policy(VERSION 3.11)
+
+file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:1>")
diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2-check.cmake
new file mode 100644
index 000000000..e127711eb
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content)
+
+set(expected "1")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2.cmake
new file mode 100644
index 000000000..a8aca6e35
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2.cmake
@@ -0,0 +1,3 @@
+cmake_policy(VERSION 3.11)
+
+file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:1$<SEMICOLON>1>")
diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3-check.cmake
new file mode 100644
index 000000000..e3055ce94
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content)
+
+set(expected "2;1")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3.cmake
new file mode 100644
index 000000000..ee2dd3ea5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3.cmake
@@ -0,0 +1,3 @@
+cmake_policy(VERSION 3.11)
+
+file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:2$<SEMICOLON>1>")
diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4-check.cmake
new file mode 100644
index 000000000..e3055ce94
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content)
+
+set(expected "2;1")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4.cmake
new file mode 100644
index 000000000..557bc28c1
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4.cmake
@@ -0,0 +1,3 @@
+cmake_policy(VERSION 3.11)
+
+file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:2$<SEMICOLON>1$<SEMICOLON>2>")
diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty-check.cmake
new file mode 100644
index 000000000..f779d489b
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content)
+
+set(expected "")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty.cmake
new file mode 100644
index 000000000..3b9d674ff
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty.cmake
@@ -0,0 +1,3 @@
+cmake_policy(VERSION 3.11)
+
+file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:>")
diff --git a/Tests/RunCMake/GeneratorExpression/ResultValidator.cmake b/Tests/RunCMake/GeneratorExpression/ResultValidator.cmake
new file mode 100644
index 000000000..722ae0527
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/ResultValidator.cmake
@@ -0,0 +1,6 @@
+
+function (CHECK_VALUE test_msg value expected)
+ if (NOT value STREQUAL expected)
+ string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [[${value}]]\nbut expected:\n [[${expected}]]\n")
+ endif()
+endfunction()
diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
index 2486259da..68a017251 100644
--- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
@@ -15,8 +15,10 @@ run_cmake(BadSHELL_PATH)
run_cmake(CMP0044-WARN)
run_cmake(NonValidTarget-C_COMPILER_ID)
run_cmake(NonValidTarget-CXX_COMPILER_ID)
+run_cmake(NonValidTarget-Fortran_COMPILER_ID)
run_cmake(NonValidTarget-C_COMPILER_VERSION)
run_cmake(NonValidTarget-CXX_COMPILER_VERSION)
+run_cmake(NonValidTarget-Fortran_COMPILER_VERSION)
run_cmake(NonValidTarget-TARGET_BUNDLE_DIR)
run_cmake(NonValidTarget-TARGET_BUNDLE_CONTENT_DIR)
run_cmake(NonValidTarget-TARGET_PROPERTY)
@@ -29,18 +31,79 @@ run_cmake(COMPILE_LANGUAGE-add_executable)
run_cmake(COMPILE_LANGUAGE-add_library)
run_cmake(COMPILE_LANGUAGE-add_test)
run_cmake(COMPILE_LANGUAGE-unknown-lang)
+run_cmake(COMPILE_LANG_AND_ID-add_custom_target)
+run_cmake(COMPILE_LANG_AND_ID-add_custom_command)
+run_cmake(COMPILE_LANG_AND_ID-install)
+run_cmake(COMPILE_LANG_AND_ID-target_sources)
+run_cmake(COMPILE_LANG_AND_ID-add_executable)
+run_cmake(COMPILE_LANG_AND_ID-add_library)
+run_cmake(COMPILE_LANG_AND_ID-add_test)
+run_cmake(COMPILE_LANG_AND_ID-unknown-lang)
run_cmake(TARGET_FILE-recursion)
run_cmake(OUTPUT_NAME-recursion)
+run_cmake(TARGET_FILE_PREFIX)
+run_cmake(TARGET_FILE_PREFIX-imported-target)
+run_cmake(TARGET_FILE_PREFIX-non-valid-target)
+run_cmake(TARGET_LINKER_FILE_PREFIX-non-valid-target)
+run_cmake(TARGET_FILE_SUFFIX)
+run_cmake(TARGET_FILE_SUFFIX-imported-target)
+run_cmake(TARGET_FILE_SUFFIX-non-valid-target)
+run_cmake(TARGET_LINKER_FILE_SUFFIX-non-valid-target)
+run_cmake_with_options(TARGET_FILE_BASE_NAME -DCMAKE_BUILD_TYPE:STRING=Debug)
+run_cmake_with_options(TARGET_FILE_BASE_NAME-imported-target -DCMAKE_BUILD_TYPE:STRING=Debug)
+run_cmake(TARGET_FILE_BASE_NAME-non-valid-target)
+run_cmake(TARGET_LINKER_FILE_BASE_NAME-non-valid-target)
+run_cmake(TARGET_PROPERTY-INCLUDE_DIRECTORIES)
run_cmake(TARGET_PROPERTY-LOCATION)
run_cmake(TARGET_PROPERTY-SOURCES)
run_cmake(LINK_ONLY-not-linking)
+run_cmake(TARGET_EXISTS-no-arg)
+run_cmake(TARGET_EXISTS-empty-arg)
+run_cmake(TARGET_EXISTS)
+run_cmake(TARGET_EXISTS-not-a-target)
+run_cmake(TARGET_NAME_IF_EXISTS-no-arg)
+run_cmake(TARGET_NAME_IF_EXISTS-empty-arg)
+run_cmake(TARGET_NAME_IF_EXISTS)
+run_cmake(TARGET_NAME_IF_EXISTS-not-a-target)
+run_cmake(TARGET_GENEX_EVAL-no-arg)
+run_cmake(TARGET_GENEX_EVAL-no-target)
+run_cmake(TARGET_GENEX_EVAL-non-valid-target)
+run_cmake(TARGET_GENEX_EVAL-recursion1)
+run_cmake(TARGET_GENEX_EVAL-recursion2)
+run_cmake(TARGET_GENEX_EVAL)
+run_cmake(GENEX_EVAL-recursion1)
+run_cmake(GENEX_EVAL-recursion2)
+run_cmake(GENEX_EVAL)
+run_cmake(REMOVE_DUPLICATES-empty)
+run_cmake(REMOVE_DUPLICATES-1)
+run_cmake(REMOVE_DUPLICATES-2)
+run_cmake(REMOVE_DUPLICATES-3)
+run_cmake(REMOVE_DUPLICATES-4)
+run_cmake(FILTER-empty)
+run_cmake(FILTER-InvalidOperator)
+run_cmake(FILTER-Exclude)
+run_cmake(FILTER-Include)
run_cmake(ImportedTarget-TARGET_BUNDLE_DIR)
run_cmake(ImportedTarget-TARGET_BUNDLE_CONTENT_DIR)
run_cmake(ImportedTarget-TARGET_PDB_FILE)
+run_cmake(ImportedTarget-TARGET_PDB_FILE_BASE_NAME)
if(LINKER_SUPPORTS_PDB)
run_cmake(NonValidTarget-TARGET_PDB_FILE)
run_cmake(ValidTarget-TARGET_PDB_FILE)
+ run_cmake(NonValidTarget-TARGET_PDB_FILE_BASE_NAME)
+ run_cmake(ValidTarget-TARGET_PDB_FILE_BASE_NAME)
else()
run_cmake(NonValidCompiler-TARGET_PDB_FILE)
+ run_cmake(NonValidCompiler-TARGET_PDB_FILE_BASE_NAME)
endif()
+
+set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0085:STRING=OLD)
+run_cmake(CMP0085-OLD)
+unset(RunCMake_TEST_OPTIONS)
+
+run_cmake(CMP0085-WARN)
+
+set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0085:STRING=NEW)
+run_cmake(CMP0085-NEW)
+unset(RunCMake_TEST_OPTIONS)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-check.cmake
new file mode 100644
index 000000000..c4c3a513b
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/TARGET_EXISTS-generated.txt" content)
+
+set(expected "1")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg-stderr.txt
new file mode 100644
index 000000000..1df6e28f5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at TARGET_EXISTS-empty-arg.cmake:2 \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_EXISTS:>
+
+ \$<TARGET_EXISTS:tgt> expression requires a non-empty valid target name.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg.cmake
new file mode 100644
index 000000000..e387abccb
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-empty-arg.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0070 NEW)
+file(GENERATE OUTPUT TARGET_EXISTS-generated.txt CONTENT "$<TARGET_EXISTS:${empty}>")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg-stderr.txt
new file mode 100644
index 000000000..69e613052
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at TARGET_EXISTS-no-arg.cmake:2 \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_EXISTS>
+
+ \$<TARGET_EXISTS> expression requires exactly one parameter.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg.cmake
new file mode 100644
index 000000000..0a5ce323f
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-no-arg.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0070 NEW)
+file(GENERATE OUTPUT TARGET_EXISTS-generated.txt CONTENT "$<TARGET_EXISTS>")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target-check.cmake
new file mode 100644
index 000000000..35ba26746
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/TARGET_EXISTS-not-a-target-generated.txt" content)
+
+set(expected "0")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target.cmake
new file mode 100644
index 000000000..d8a8d3e45
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS-not-a-target.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0070 NEW)
+file(GENERATE OUTPUT TARGET_EXISTS-not-a-target-generated.txt CONTENT "$<TARGET_EXISTS:just-random-string>")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS.cmake
new file mode 100644
index 000000000..9a83b34ca
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_EXISTS.cmake
@@ -0,0 +1,3 @@
+cmake_policy(SET CMP0070 NEW)
+add_custom_target(foo)
+file(GENERATE OUTPUT TARGET_EXISTS-generated.txt CONTENT "$<TARGET_EXISTS:foo>")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-check.cmake
new file mode 100644
index 000000000..793edb1de
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-check.cmake
@@ -0,0 +1,2 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/TARGET_FILE_BASE_NAME-generated.cmake")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target-check.cmake
new file mode 100644
index 000000000..793edb1de
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target-check.cmake
@@ -0,0 +1,2 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/TARGET_FILE_BASE_NAME-generated.cmake")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target.cmake
new file mode 100644
index 000000000..40f7c66f2
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-imported-target.cmake
@@ -0,0 +1,106 @@
+
+cmake_minimum_required(VERSION 3.14)
+
+enable_language (C)
+
+set (GENERATE_CONTENT [[
+macro (CHECK_VALUE test_msg value expected)
+ if (NOT "${value}" STREQUAL "${expected}")
+ string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [${value}]\nbut expected:\n [${expected}]\n")
+ endif()
+endmacro()
+]])
+
+add_executable(exec1 IMPORTED)
+add_library (shared1 SHARED IMPORTED)
+add_library (static1 STATIC IMPORTED)
+
+string (APPEND GENERATE_CONTENT [[
+
+check_value ("TARGET_FILE_BASE_NAME executable default" "$<TARGET_FILE_BASE_NAME:exec1>" "exec1")
+check_value ("TARGET_FILE_BASE_NAME shared default" "$<TARGET_FILE_BASE_NAME:shared1>" "shared1")
+check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker default" "$<TARGET_LINKER_FILE_BASE_NAME:shared1>" "shared1")
+check_value ("TARGET_FILE_BASE_NAME static default" "$<TARGET_FILE_BASE_NAME:static1>" "static1")
+check_value ("TARGET_LINKER_FILE_BASE_NAME static linker default" "$<TARGET_LINKER_FILE_BASE_NAME:static1>" "static1")
+]])
+
+
+add_executable (exec2 IMPORTED)
+set_property (TARGET exec2 PROPERTY OUTPUT_NAME exec2_custom)
+add_library (shared2 SHARED IMPORTED)
+set_property (TARGET shared2 PROPERTY OUTPUT_NAME shared2_custom)
+add_library (static2 STATIC IMPORTED)
+set_property (TARGET static2 PROPERTY OUTPUT_NAME static2_custom)
+
+string (APPEND GENERATE_CONTENT [[
+
+check_value ("TARGET_FILE_BASE_NAME executable custom" "$<TARGET_FILE_BASE_NAME:exec2>" "exec2_custom")
+check_value ("TARGET_FILE_BASE_NAME shared custom" "$<TARGET_FILE_BASE_NAME:shared2>" "shared2_custom")
+check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker custom" "$<TARGET_LINKER_FILE_BASE_NAME:shared2>" "shared2_custom")
+check_value ("TARGET_FILE_BASE_NAME static custom" "$<TARGET_FILE_BASE_NAME:static2>" "static2_custom")
+check_value ("TARGET_LINKER_FILE_BASE_NAME static linker custom" "$<TARGET_LINKER_FILE_BASE_NAME:static2>" "static2_custom")
+]])
+
+
+add_executable (exec3 IMPORTED)
+set_property (TARGET exec3 PROPERTY RUNTIME_OUTPUT_NAME exec3_runtime)
+set_property (TARGET exec3 PROPERTY LIBRARY_OUTPUT_NAME exec3_library)
+set_property (TARGET exec3 PROPERTY ARCHIVE_OUTPUT_NAME exec3_archive)
+add_library (shared3 SHARED IMPORTED)
+set_property (TARGET shared3 PROPERTY RUNTIME_OUTPUT_NAME shared3_runtime)
+set_property (TARGET shared3 PROPERTY LIBRARY_OUTPUT_NAME shared3_library)
+set_property (TARGET shared3 PROPERTY ARCHIVE_OUTPUT_NAME shared3_archive)
+add_library (static3 STATIC IMPORTED)
+set_property (TARGET static3 PROPERTY RUNTIME_OUTPUT_NAME static3_runtime)
+set_property (TARGET static3 PROPERTY LIBRARY_OUTPUT_NAME static3_library)
+set_property (TARGET static3 PROPERTY ARCHIVE_OUTPUT_NAME static3_archive)
+
+string (APPEND GENERATE_CONTENT [[
+
+check_value ("TARGET_FILE_BASE_NAME executable all properties" "$<TARGET_FILE_BASE_NAME:exec3>" "exec3_runtime")
+check_value ("TARGET_FILE_BASE_NAME shared all properties" "$<TARGET_FILE_BASE_NAME:shared3>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared3_runtime,shared3_library>")
+check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker all properties" "$<TARGET_LINKER_FILE_BASE_NAME:shared3>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared3_archive,shared3_library>")
+check_value ("TARGET_FILE_BASE_NAME static all properties" "$<TARGET_FILE_BASE_NAME:static3>" "static3_archive")
+check_value ("TARGET_LINKER_FILE_BASE_NAME static linker all properties" "$<TARGET_LINKER_FILE_BASE_NAME:static3>" "static3_archive")
+]])
+
+
+unset(GENERATE_CONDITION)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
+ list(GET CMAKE_CONFIGURATION_TYPES 0 FIRST_CONFIG)
+ set(GENERATE_CONDITION CONDITION $<CONFIG:${FIRST_CONFIG}>)
+else()
+ set (FIRST_CONFIG ${CMAKE_BUILD_TYPE})
+endif()
+string (TOUPPER "${FIRST_CONFIG}" FIRST_CONFIG)
+
+
+add_executable (exec4 IMPORTED)
+set_property (TARGET exec4 PROPERTY RUNTIME_OUTPUT_NAME exec4_runtime)
+set_property (TARGET exec4 PROPERTY LIBRARY_OUTPUT_NAME exec4_library)
+set_property (TARGET exec4 PROPERTY ARCHIVE_OUTPUT_NAME exec4_archive)
+set_property (TARGET exec4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix)
+add_library (shared4 SHARED IMPORTED)
+set_property (TARGET shared4 PROPERTY RUNTIME_OUTPUT_NAME shared4_runtime)
+set_property (TARGET shared4 PROPERTY LIBRARY_OUTPUT_NAME shared4_library)
+set_property (TARGET shared4 PROPERTY ARCHIVE_OUTPUT_NAME shared4_archive)
+set_property (TARGET shared4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix)
+add_library (static4 STATIC IMPORTED)
+set_property (TARGET static4 PROPERTY RUNTIME_OUTPUT_NAME static4_runtime)
+set_property (TARGET static4 PROPERTY LIBRARY_OUTPUT_NAME static4_library)
+set_property (TARGET static4 PROPERTY ARCHIVE_OUTPUT_NAME static4_archive)
+set_property (TARGET static4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix)
+
+string (APPEND GENERATE_CONTENT [[
+
+check_value ("TARGET_FILE_BASE_NAME executable all properties + postfix" "$<TARGET_FILE_BASE_NAME:exec4>" "exec4_runtime_postfix")
+check_value ("TARGET_FILE_BASE_NAME shared all properties + postfix" "$<TARGET_FILE_BASE_NAME:shared4>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared4_runtime,shared4_library>_postfix")
+check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker all properties + postfix" "$<TARGET_LINKER_FILE_BASE_NAME:shared4>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared4_archive,shared4_library>_postfix")
+check_value ("TARGET_FILE_BASE_NAME static all properties + postfix" "$<TARGET_FILE_BASE_NAME:static4>" "static4_archive_postfix")
+check_value ("TARGET_LINKER_FILE_BASE_NAME static linker all properties + postfix" "$<TARGET_LINKER_FILE_BASE_NAME:static4>" "static4_archive_postfix")
+]])
+
+
+file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_BASE_NAME-generated.cmake"
+ CONTENT "${GENERATE_CONTENT}" ${GENERATE_CONDITION})
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-stderr.txt
new file mode 100644
index 000000000..ecb9e5d03
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at TARGET_FILE_BASE_NAME-non-valid-target.cmake:[0-9]+ \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_FILE_BASE_NAME:empty>
+
+ Target "empty" is not an executable or library\.
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target.cmake
new file mode 100644
index 000000000..8622b7dc9
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME-non-valid-target.cmake
@@ -0,0 +1,7 @@
+
+add_custom_target(empty)
+
+file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt"
+ CONTENT "[$<TARGET_FILE_BASE_NAME:empty>]"
+)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME.cmake
new file mode 100644
index 000000000..f88d7109a
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_BASE_NAME.cmake
@@ -0,0 +1,135 @@
+
+cmake_minimum_required(VERSION 3.14)
+
+enable_language (C)
+
+set (GENERATE_CONTENT [[
+macro (CHECK_VALUE test_msg value expected)
+ if (NOT "${value}" STREQUAL "${expected}")
+ string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [${value}]\nbut expected:\n [${expected}]\n")
+ endif()
+endmacro()
+]])
+
+add_executable (exec1 empty.c)
+add_library (shared1 SHARED empty.c)
+add_library (static1 STATIC empty.c)
+
+string (APPEND GENERATE_CONTENT [[
+
+check_value ("TARGET_FILE_BASE_NAME executable default" "$<TARGET_FILE_BASE_NAME:exec1>" "exec1")
+check_value ("TARGET_FILE_BASE_NAME shared default" "$<TARGET_FILE_BASE_NAME:shared1>" "shared1")
+check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker default" "$<TARGET_LINKER_FILE_BASE_NAME:shared1>" "shared1")
+check_value ("TARGET_FILE_BASE_NAME static default" "$<TARGET_FILE_BASE_NAME:static1>" "static1")
+check_value ("TARGET_LINKER_FILE_BASE_NAME static linker default" "$<TARGET_LINKER_FILE_BASE_NAME:static1>" "static1")
+]])
+if (CMAKE_C_LINKER_SUPPORTS_PDB)
+ string(APPEND GENERATE_CONTENT [[
+check_value ("TARGET_PDB_FILE_BASE_NAME executable PDB default" "$<TARGET_PDB_FILE_BASE_NAME:exec1>" "exec1")
+check_value ("TARGET_PDB_FILE_BASE_NAME shared PDB default" "$<TARGET_PDB_FILE_BASE_NAME:shared1>" "shared1")
+]])
+endif()
+
+
+add_executable (exec2 empty.c)
+set_property (TARGET exec2 PROPERTY OUTPUT_NAME exec2_custom)
+add_library (shared2 SHARED empty.c)
+set_property (TARGET shared2 PROPERTY OUTPUT_NAME shared2_custom)
+add_library (static2 STATIC empty.c)
+set_property (TARGET static2 PROPERTY OUTPUT_NAME static2_custom)
+
+string (APPEND GENERATE_CONTENT [[
+
+check_value ("TARGET_FILE_BASE_NAME executable custom" "$<TARGET_FILE_BASE_NAME:exec2>" "exec2_custom")
+check_value ("TARGET_FILE_BASE_NAME shared custom" "$<TARGET_FILE_BASE_NAME:shared2>" "shared2_custom")
+check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker custom" "$<TARGET_LINKER_FILE_BASE_NAME:shared2>" "shared2_custom")
+check_value ("TARGET_FILE_BASE_NAME static custom" "$<TARGET_FILE_BASE_NAME:static2>" "static2_custom")
+check_value ("TARGET_LINKER_FILE_BASE_NAME static linker custom" "$<TARGET_LINKER_FILE_BASE_NAME:static2>" "static2_custom")
+]])
+if (CMAKE_C_LINKER_SUPPORTS_PDB)
+ string (APPEND GENERATE_CONTENT [[
+check_value ("TARGET_PDB_FILE_BASE_NAME executable PDB custom" "$<TARGET_PDB_FILE_BASE_NAME:exec2>" "exec2_custom")
+check_value ("TARGET_PDB_FILE_BASE_NAME shared PDB custom" "$<TARGET_PDB_FILE_BASE_NAME:shared2>" "shared2_custom")
+ ]])
+endif()
+
+add_executable (exec3 empty.c)
+set_property (TARGET exec3 PROPERTY RUNTIME_OUTPUT_NAME exec3_runtime)
+set_property (TARGET exec3 PROPERTY LIBRARY_OUTPUT_NAME exec3_library)
+set_property (TARGET exec3 PROPERTY ARCHIVE_OUTPUT_NAME exec3_archive)
+set_property (TARGET exec3 PROPERTY PDB_NAME exec3_pdb)
+add_library (shared3 SHARED empty.c)
+set_property (TARGET shared3 PROPERTY RUNTIME_OUTPUT_NAME shared3_runtime)
+set_property (TARGET shared3 PROPERTY LIBRARY_OUTPUT_NAME shared3_library)
+set_property (TARGET shared3 PROPERTY ARCHIVE_OUTPUT_NAME shared3_archive)
+set_property (TARGET shared3 PROPERTY PDB_NAME shared3_pdb)
+add_library (static3 STATIC empty.c)
+set_property (TARGET static3 PROPERTY RUNTIME_OUTPUT_NAME static3_runtime)
+set_property (TARGET static3 PROPERTY LIBRARY_OUTPUT_NAME static3_library)
+set_property (TARGET static3 PROPERTY ARCHIVE_OUTPUT_NAME static3_archive)
+set_property (TARGET static3 PROPERTY PDB_NAME static3_pdb)
+
+string (APPEND GENERATE_CONTENT [[
+
+check_value ("TARGET_FILE_BASE_NAME executable all properties" "$<TARGET_FILE_BASE_NAME:exec3>" "exec3_runtime")
+check_value ("TARGET_FILE_BASE_NAME shared all properties" "$<TARGET_FILE_BASE_NAME:shared3>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared3_runtime,shared3_library>")
+check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker all properties" "$<TARGET_LINKER_FILE_BASE_NAME:shared3>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared3_archive,shared3_library>")
+check_value ("TARGET_FILE_BASE_NAME static all properties" "$<TARGET_FILE_BASE_NAME:static3>" "static3_archive")
+check_value ("TARGET_LINKER_FILE_BASE_NAME static linker all properties" "$<TARGET_LINKER_FILE_BASE_NAME:static3>" "static3_archive")
+]])
+if (CMAKE_C_LINKER_SUPPORTS_PDB)
+ string (APPEND GENERATE_CONTENT [[
+check_value ("TARGET_PDB_FILE_BASE_NAME executable PDB all properties" "$<TARGET_PDB_FILE_BASE_NAME:exec3>" "exec3_pdb")
+check_value ("TARGET_PDB_FILE_BASE_NAME shared PDB all properties" "$<TARGET_PDB_FILE_BASE_NAME:shared3>" "shared3_pdb")
+]])
+endif()
+
+
+unset(GENERATE_CONDITION)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
+ list(GET CMAKE_CONFIGURATION_TYPES 0 FIRST_CONFIG)
+ set(GENERATE_CONDITION CONDITION $<CONFIG:${FIRST_CONFIG}>)
+else()
+ set (FIRST_CONFIG ${CMAKE_BUILD_TYPE})
+endif()
+string (TOUPPER "${FIRST_CONFIG}" FIRST_CONFIG)
+
+
+add_executable (exec4 empty.c)
+set_property (TARGET exec4 PROPERTY RUNTIME_OUTPUT_NAME exec4_runtime)
+set_property (TARGET exec4 PROPERTY LIBRARY_OUTPUT_NAME exec4_library)
+set_property (TARGET exec4 PROPERTY ARCHIVE_OUTPUT_NAME exec4_archive)
+set_property (TARGET exec4 PROPERTY PDB_NAME exec4_pdb)
+set_property (TARGET exec4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix)
+add_library (shared4 SHARED empty.c)
+set_property (TARGET shared4 PROPERTY RUNTIME_OUTPUT_NAME shared4_runtime)
+set_property (TARGET shared4 PROPERTY LIBRARY_OUTPUT_NAME shared4_library)
+set_property (TARGET shared4 PROPERTY ARCHIVE_OUTPUT_NAME shared4_archive)
+set_property (TARGET shared4 PROPERTY PDB_NAME shared4_pdb)
+set_property (TARGET shared4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix)
+add_library (static4 STATIC empty.c)
+set_property (TARGET static4 PROPERTY RUNTIME_OUTPUT_NAME static4_runtime)
+set_property (TARGET static4 PROPERTY LIBRARY_OUTPUT_NAME static4_library)
+set_property (TARGET static4 PROPERTY ARCHIVE_OUTPUT_NAME static4_archive)
+set_property (TARGET static4 PROPERTY PDB_NAME static4_pdb)
+set_property (TARGET static4 PROPERTY ${FIRST_CONFIG}_POSTFIX _postfix)
+
+string (APPEND GENERATE_CONTENT [[
+
+check_value ("TARGET_FILE_BASE_NAME executable all properties + postfix" "$<TARGET_FILE_BASE_NAME:exec4>" "exec4_runtime_postfix")
+check_value ("TARGET_FILE_BASE_NAME shared all properties + postfix" "$<TARGET_FILE_BASE_NAME:shared4>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared4_runtime,shared4_library>_postfix")
+check_value ("TARGET_LINKER_FILE_BASE_NAME shared linker all properties + postfix" "$<TARGET_LINKER_FILE_BASE_NAME:shared4>" "$<IF:$<IN_LIST:$<PLATFORM_ID>,Windows$<SEMICOLON>CYGWIN>,shared4_archive,shared4_library>_postfix")
+check_value ("TARGET_FILE_BASE_NAME static all properties + postfix" "$<TARGET_FILE_BASE_NAME:static4>" "static4_archive_postfix")
+check_value ("TARGET_LINKER_FILE_BASE_NAME static linker all properties + postfix" "$<TARGET_LINKER_FILE_BASE_NAME:static4>" "static4_archive_postfix")
+]])
+if (CMAKE_C_LINKER_SUPPORTS_PDB)
+ string (APPEND GENERATE_CONTENT [[
+check_value ("TARGET_PDB_FILE_BASE_NAME executable PDB all properties + postfix" "$<TARGET_PDB_FILE_BASE_NAME:exec4>" "exec4_pdb_postfix")
+check_value ("TARGET_PDB_FILE_BASE_NAME shared PDB all properties + postfix" "$<TARGET_PDB_FILE_BASE_NAME:shared4>" "shared4_pdb_postfix")
+]])
+endif()
+
+
+file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_BASE_NAME-generated.cmake"
+ CONTENT "${GENERATE_CONTENT}" ${GENERATE_CONDITION})
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-check.cmake
new file mode 100644
index 000000000..676ad4bc8
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-check.cmake
@@ -0,0 +1,2 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/TARGET_FILE_PREFIX-generated.cmake")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target-check.cmake
new file mode 100644
index 000000000..676ad4bc8
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target-check.cmake
@@ -0,0 +1,2 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/TARGET_FILE_PREFIX-generated.cmake")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target.cmake
new file mode 100644
index 000000000..f52776e98
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-imported-target.cmake
@@ -0,0 +1,49 @@
+
+cmake_minimum_required(VERSION 3.14)
+
+enable_language (C)
+
+set (win_platforms Windows CYGWIN)
+
+set (GENERATE_CONTENT [[
+macro (CHECK_VALUE test_msg value expected)
+ if (NOT "${value}" STREQUAL "${expected}")
+ string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [${value}]\nbut expected:\n [${expected}]\n")
+ endif()
+endmacro()
+]])
+
+add_executable(exec1 IMPORTED)
+add_library (shared1 SHARED IMPORTED)
+add_library (static1 STATIC IMPORTED)
+
+string (APPEND GENERATE_CONTENT
+"\ncheck_value (\"TARGET_FILE_PREFIX executable default\" \"$<TARGET_FILE_PREFIX:exec1>\" \"\")
+check_value (\"TARGET_FILE_PREFIX shared default\" \"$<TARGET_FILE_PREFIX:shared1>\" \"${CMAKE_SHARED_LIBRARY_PREFIX}\")
+check_value (\"TARGET_LINKER_FILE_PREFIX shared linker default\" \"$<TARGET_LINKER_FILE_PREFIX:shared1>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,${CMAKE_IMPORT_LIBRARY_PREFIX},${CMAKE_SHARED_LIBRARY_PREFIX}>\")
+check_value (\"TARGET_FILE_PREFIX static default\" \"$<TARGET_FILE_PREFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_PREFIX}\")
+check_value (\"TARGET_LINKER_FILE_PREFIX static linker default\" \"$<TARGET_LINKER_FILE_PREFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_PREFIX}\")\n")
+
+
+add_executable (exec2 IMPORTED)
+set_property (TARGET exec2 PROPERTY PREFIX exec2_prefix)
+set_property (TARGET exec2 PROPERTY ENABLE_EXPORTS TRUE)
+set_property (TARGET exec2 PROPERTY IMPORT_PREFIX exec2_import_prefix)
+add_library (shared2 SHARED IMPORTED)
+set_property (TARGET shared2 PROPERTY PREFIX shared2_prefix)
+set_property (TARGET shared2 PROPERTY IMPORT_PREFIX shared2_import_prefix)
+add_library (static2 STATIC IMPORTED)
+set_property (TARGET static2 PROPERTY PREFIX static2_prefix)
+set_property (TARGET static2 PROPERTY IMPORT_PREFIX static2_import_prefix)
+
+string (APPEND GENERATE_CONTENT
+"\ncheck_value (\"TARGET_FILE_PREFIX executable custom\" \"$<TARGET_FILE_PREFIX:exec2>\" \"exec2_prefix\")
+check_value (\"TARGET_LINKER_FILE_PREFIX executable linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms};AIX>,exec2_import_prefix,exec2_prefix>\")
+check_value (\"TARGET_FILE_PREFIX shared custom\" \"$<TARGET_FILE_PREFIX:shared2>\" \"shared2_prefix\")
+check_value (\"TARGET_LINKER_FILE_PREFIX shared linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:shared2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,shared2_import_prefix,shared2_prefix>\")
+check_value (\"TARGET_FILE_PREFIX static custom\" \"$<TARGET_FILE_PREFIX:static2>\" \"static2_prefix\")
+check_value (\"TARGET_LINKER_FILE_PREFIX static linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:static2>\" \"static2_prefix\")\n")
+
+
+file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_PREFIX-generated.cmake"
+ CONTENT "${GENERATE_CONTENT}")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-stderr.txt
new file mode 100644
index 000000000..81362ef04
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at TARGET_FILE_PREFIX-non-valid-target.cmake:[0-9]+ \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_FILE_PREFIX:empty>
+
+ Target "empty" is not an executable or library\.
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target.cmake
new file mode 100644
index 000000000..d1095fa53
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX-non-valid-target.cmake
@@ -0,0 +1,7 @@
+
+add_custom_target(empty)
+
+file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt"
+ CONTENT "[$<TARGET_FILE_PREFIX:empty>]"
+)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX.cmake
new file mode 100644
index 000000000..bef7bbf5c
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_PREFIX.cmake
@@ -0,0 +1,49 @@
+
+cmake_minimum_required(VERSION 3.14)
+
+enable_language (C)
+
+set (win_platforms Windows CYGWIN)
+
+set (GENERATE_CONTENT [[
+macro (CHECK_VALUE test_msg value expected)
+ if (NOT "${value}" STREQUAL "${expected}")
+ string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [${value}]\nbut expected:\n [${expected}]\n")
+ endif()
+endmacro()
+]])
+
+add_executable (exec1 empty.c)
+add_library (shared1 SHARED empty.c)
+add_library (static1 STATIC empty.c)
+
+string (APPEND GENERATE_CONTENT
+"\ncheck_value (\"TARGET_FILE_PREFIX executable default\" \"$<TARGET_FILE_PREFIX:exec1>\" \"\")
+check_value (\"TARGET_FILE_PREFIX shared default\" \"$<TARGET_FILE_PREFIX:shared1>\" \"${CMAKE_SHARED_LIBRARY_PREFIX}\")
+check_value (\"TARGET_LINKER_FILE_PREFIX shared linker default\" \"$<TARGET_LINKER_FILE_PREFIX:shared1>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,${CMAKE_IMPORT_LIBRARY_PREFIX},${CMAKE_SHARED_LIBRARY_PREFIX}>\")
+check_value (\"TARGET_FILE_PREFIX static default\" \"$<TARGET_FILE_PREFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_PREFIX}\")
+check_value (\"TARGET_LINKER_FILE_PREFIX static linker default\" \"$<TARGET_LINKER_FILE_PREFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_PREFIX}\")\n")
+
+
+add_executable (exec2 empty.c)
+set_property (TARGET exec2 PROPERTY PREFIX exec2_prefix)
+set_property (TARGET exec2 PROPERTY ENABLE_EXPORTS TRUE)
+set_property (TARGET exec2 PROPERTY IMPORT_PREFIX exec2_import_prefix)
+add_library (shared2 SHARED empty.c)
+set_property (TARGET shared2 PROPERTY PREFIX shared2_prefix)
+set_property (TARGET shared2 PROPERTY IMPORT_PREFIX shared2_import_prefix)
+add_library (static2 STATIC empty.c)
+set_property (TARGET static2 PROPERTY PREFIX static2_prefix)
+set_property (TARGET static2 PROPERTY IMPORT_PREFIX static2_import_prefix)
+
+string (APPEND GENERATE_CONTENT
+"\ncheck_value (\"TARGET_FILE_PREFIX executable custom\" \"$<TARGET_FILE_PREFIX:exec2>\" \"exec2_prefix\")
+check_value (\"TARGET_LINKER_FILE_PREFIX executable linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms};AIX>,exec2_import_prefix,exec2_prefix>\")
+check_value (\"TARGET_FILE_PREFIX shared custom\" \"$<TARGET_FILE_PREFIX:shared2>\" \"shared2_prefix\")
+check_value (\"TARGET_LINKER_FILE_PREFIX shared linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:shared2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,shared2_import_prefix,shared2_prefix>\")
+check_value (\"TARGET_FILE_PREFIX static custom\" \"$<TARGET_FILE_PREFIX:static2>\" \"static2_prefix\")
+check_value (\"TARGET_LINKER_FILE_PREFIX static linker custom\" \"$<TARGET_LINKER_FILE_PREFIX:static2>\" \"static2_prefix\")\n")
+
+
+file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_PREFIX-generated.cmake"
+ CONTENT "${GENERATE_CONTENT}")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-check.cmake
new file mode 100644
index 000000000..f159370d7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-check.cmake
@@ -0,0 +1,2 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/TARGET_FILE_SUFFIX-generated.cmake")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target-check.cmake
new file mode 100644
index 000000000..f159370d7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target-check.cmake
@@ -0,0 +1,2 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/TARGET_FILE_SUFFIX-generated.cmake")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target.cmake
new file mode 100644
index 000000000..cefeb86f1
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-imported-target.cmake
@@ -0,0 +1,49 @@
+
+cmake_minimum_required(VERSION 3.14)
+
+enable_language (C)
+
+set (win_platforms Windows CYGWIN)
+
+set (GENERATE_CONTENT [[
+macro (CHECK_VALUE test_msg value expected)
+ if (NOT "${value}" STREQUAL "${expected}")
+ string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [${value}]\nbut expected:\n [${expected}]\n")
+ endif()
+endmacro()
+]])
+
+add_executable (exec1 IMPORTED)
+add_library (shared1 SHARED IMPORTED)
+add_library (static1 STATIC IMPORTED)
+
+string (APPEND GENERATE_CONTENT
+"\ncheck_value (\"TARGET_FILE_SUFFIX executable default\" \"$<TARGET_FILE_SUFFIX:exec1>\" \"${CMAKE_EXECUTABLE_SUFFIX}\")
+check_value (\"TARGET_FILE_SUFFIX shared default\" \"$<TARGET_FILE_SUFFIX:shared1>\" \"${CMAKE_SHARED_LIBRARY_SUFFIX}\")
+check_value (\"TARGET_LINKER_FILE_SUFFIX shared linker default\" \"$<TARGET_LINKER_FILE_SUFFIX:shared1>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,${CMAKE_IMPORT_LIBRARY_SUFFIX},${CMAKE_SHARED_LIBRARY_SUFFIX}>\")
+check_value (\"TARGET_FILE_SUFFIX static default\" \"$<TARGET_FILE_SUFFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_SUFFIX}\")
+check_value (\"TARGET_LINKER_FILE_SUFFIX static linker default\" \"$<TARGET_LINKER_FILE_SUFFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_SUFFIX}\")\n")
+
+
+add_executable (exec2 IMPORTED)
+set_property (TARGET exec2 PROPERTY SUFFIX exec2_suffix)
+set_property (TARGET exec2 PROPERTY ENABLE_EXPORTS TRUE)
+set_property (TARGET exec2 PROPERTY IMPORT_SUFFIX exec2_import_suffix)
+add_library (shared2 SHARED IMPORTED)
+set_property (TARGET shared2 PROPERTY SUFFIX shared2_suffix)
+set_property (TARGET shared2 PROPERTY IMPORT_SUFFIX shared2_import_suffix)
+add_library (static2 STATIC IMPORTED)
+set_property (TARGET static2 PROPERTY SUFFIX static2_suffix)
+set_property (TARGET static2 PROPERTY IMPORT_SUFFIX static2_import_suffix)
+
+string (APPEND GENERATE_CONTENT
+"\ncheck_value (\"TARGET_FILE_SUFFIX executable custom\" \"$<TARGET_FILE_SUFFIX:exec2>\" \"exec2_suffix\")
+check_value (\"TARGET_LINKER_FILE_SUFFIX executable linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms};AIX>,exec2_import_suffix,exec2_suffix>\")
+check_value (\"TARGET_FILE_SUFFIX shared custom\" \"$<TARGET_FILE_SUFFIX:shared2>\" \"shared2_suffix\")
+check_value (\"TARGET_LINKER_FILE_SUFFIX shared linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:shared2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,shared2_import_suffix,shared2_suffix>\")
+check_value (\"TARGET_FILE_SUFFIX static custom\" \"$<TARGET_FILE_SUFFIX:static2>\" \"static2_suffix\")
+check_value (\"TARGET_LINKER_FILE_SUFFIX static linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:static2>\" \"static2_suffix\")\n")
+
+
+file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_SUFFIX-generated.cmake"
+ CONTENT "${GENERATE_CONTENT}")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-stderr.txt
new file mode 100644
index 000000000..9ea09d163
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at TARGET_FILE_SUFFIX-non-valid-target.cmake:[0-9]+ \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_FILE_SUFFIX:empty>
+
+ Target "empty" is not an executable or library\.
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target.cmake
new file mode 100644
index 000000000..f7089f947
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX-non-valid-target.cmake
@@ -0,0 +1,7 @@
+
+add_custom_target(empty)
+
+file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt"
+ CONTENT "[$<TARGET_FILE_SUFFIX:empty>]"
+)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX.cmake
new file mode 100644
index 000000000..39e39fd5b
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_FILE_SUFFIX.cmake
@@ -0,0 +1,49 @@
+
+cmake_minimum_required(VERSION 3.14)
+
+enable_language (C)
+
+set (win_platforms Windows CYGWIN)
+
+set (GENERATE_CONTENT [[
+macro (CHECK_VALUE test_msg value expected)
+ if (NOT "${value}" STREQUAL "${expected}")
+ string (APPEND RunCMake_TEST_FAILED "${test_msg}: actual result:\n [${value}]\nbut expected:\n [${expected}]\n")
+ endif()
+endmacro()
+]])
+
+add_executable (exec1 empty.c)
+add_library (shared1 SHARED empty.c)
+add_library (static1 STATIC empty.c)
+
+string (APPEND GENERATE_CONTENT
+"\ncheck_value (\"TARGET_FILE_SUFFIX executable default\" \"$<TARGET_FILE_SUFFIX:exec1>\" \"${CMAKE_EXECUTABLE_SUFFIX}\")
+check_value (\"TARGET_FILE_SUFFIX shared default\" \"$<TARGET_FILE_SUFFIX:shared1>\" \"${CMAKE_SHARED_LIBRARY_SUFFIX}\")
+check_value (\"TARGET_LINKER_FILE_SUFFIX shared linker default\" \"$<TARGET_LINKER_FILE_SUFFIX:shared1>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,${CMAKE_IMPORT_LIBRARY_SUFFIX},${CMAKE_SHARED_LIBRARY_SUFFIX}>\")
+check_value (\"TARGET_FILE_SUFFIX static default\" \"$<TARGET_FILE_SUFFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_SUFFIX}\")
+check_value (\"TARGET_LINKER_FILE_SUFFIX static linker default\" \"$<TARGET_LINKER_FILE_SUFFIX:static1>\" \"${CMAKE_STATIC_LIBRARY_SUFFIX}\")\n")
+
+
+add_executable (exec2 empty.c)
+set_property (TARGET exec2 PROPERTY SUFFIX exec2_suffix)
+set_property (TARGET exec2 PROPERTY ENABLE_EXPORTS TRUE)
+set_property (TARGET exec2 PROPERTY IMPORT_SUFFIX exec2_import_suffix)
+add_library (shared2 SHARED empty.c)
+set_property (TARGET shared2 PROPERTY SUFFIX shared2_suffix)
+set_property (TARGET shared2 PROPERTY IMPORT_SUFFIX shared2_import_suffix)
+add_library (static2 STATIC empty.c)
+set_property (TARGET static2 PROPERTY SUFFIX static2_suffix)
+set_property (TARGET static2 PROPERTY IMPORT_SUFFIX static2_import_suffix)
+
+string (APPEND GENERATE_CONTENT
+"\ncheck_value (\"TARGET_FILE_SUFFIX executable custom\" \"$<TARGET_FILE_SUFFIX:exec2>\" \"exec2_suffix\")
+check_value (\"TARGET_LINKER_FILE_SUFFIX executable linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:exec2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms};AIX>,exec2_import_suffix,exec2_suffix>\")
+check_value (\"TARGET_FILE_SUFFIX shared custom\" \"$<TARGET_FILE_SUFFIX:shared2>\" \"shared2_suffix\")
+check_value (\"TARGET_LINKER_FILE_SUFFIX shared linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:shared2>\" \"$<IF:$<IN_LIST:$<PLATFORM_ID>,${win_platforms}>,shared2_import_suffix,shared2_suffix>\")
+check_value (\"TARGET_FILE_SUFFIX static custom\" \"$<TARGET_FILE_SUFFIX:static2>\" \"static2_suffix\")
+check_value (\"TARGET_LINKER_FILE_SUFFIX static linker custom\" \"$<TARGET_LINKER_FILE_SUFFIX:static2>\" \"static2_suffix\")\n")
+
+
+file (GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TARGET_FILE_SUFFIX-generated.cmake"
+ CONTENT "${GENERATE_CONTENT}")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-check.cmake
new file mode 100644
index 000000000..124a583e2
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/TARGET_GENEX_EVAL-generated.txt" content)
+
+set(expected "BEFORE_PROPERTY1_AFTER")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-arg-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-arg-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-arg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-arg-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-arg-stderr.txt
new file mode 100644
index 000000000..9b0844f9f
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-arg-stderr.txt
@@ -0,0 +1,9 @@
+^CMake Error at TARGET_GENEX_EVAL-no-arg.cmake:4 \(add_custom_command\):
+ Error evaluating generator expression:
+
+ \$<TARGET_GENEX_EVAL:>
+
+ \$<TARGET_GENEX_EVAL> expression requires 2 comma separated parameters, but
+ got 1 instead.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-arg.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-arg.cmake
new file mode 100644
index 000000000..2dc13ea5e
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-arg.cmake
@@ -0,0 +1,7 @@
+
+cmake_policy(VERSION 3.11)
+
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c"
+ COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<TARGET_GENEX_EVAL:>.c"
+)
+add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-target-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-target-stderr.txt
new file mode 100644
index 000000000..647fd85c6
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-target-stderr.txt
@@ -0,0 +1,9 @@
+^CMake Error at TARGET_GENEX_EVAL-no-target.cmake:2 \(add_custom_command\):
+ Error evaluating generator expression:
+
+ \$<TARGET_GENEX_EVAL:,>
+
+ \$<TARGET_GENEX_EVAL:tgt, ...> expression requires a non-empty valid target
+ name.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-target.cmake
new file mode 100644
index 000000000..df4f0eac6
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-no-target.cmake
@@ -0,0 +1,5 @@
+
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c"
+ COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<TARGET_GENEX_EVAL:,>.c"
+)
+add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-non-valid-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-non-valid-target-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-non-valid-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-non-valid-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-non-valid-target-stderr.txt
new file mode 100644
index 000000000..cc44d4b9c
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-non-valid-target-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Error at TARGET_GENEX_EVAL-non-valid-target.cmake:2 \(add_custom_command\):
+ Error evaluating generator expression:
+
+ \$<TARGET_GENEX_EVAL:bad-target,>
+
+ \$<TARGET_GENEX_EVAL:tgt, ...> target "bad-target" not found.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-non-valid-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-non-valid-target.cmake
new file mode 100644
index 000000000..8db737593
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-non-valid-target.cmake
@@ -0,0 +1,5 @@
+
+add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c"
+ COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/empty.c" "${CMAKE_CURRENT_BINARY_DIR}/copied_file$<TARGET_GENEX_EVAL:bad-target,>.c"
+)
+add_custom_target(drive DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/copied_file.c")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion1-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion1-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion1-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion1-stderr.txt
new file mode 100644
index 000000000..bba22340c
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion1-stderr.txt
@@ -0,0 +1,9 @@
+^CMake Error at TARGET_GENEX_EVAL-recursion1.cmake:7 \(add_custom_target\):
+ Error evaluating generator expression:
+
+ \$<TARGET_GENEX_EVAL:recursion,\$<TARGET_PROPERTY:CUSTOM_PROPERTY>>
+
+ Self reference on target "recursion".
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion1.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion1.cmake
new file mode 100644
index 000000000..b75d21175
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion1.cmake
@@ -0,0 +1,9 @@
+
+enable_language(C)
+
+add_library (recursion SHARED empty.c)
+set_property (TARGET recursion PROPERTY CUSTOM_PROPERTY "$<TARGET_GENEX_EVAL:recursion,$<TARGET_PROPERTY:CUSTOM_PROPERTY>>")
+
+add_custom_target (drive
+ COMMAND echo "$<TARGET_GENEX_EVAL:recursion,$<TARGET_PROPERTY:recursion,CUSTOM_PROPERTY>>"
+ DEPENDS recursion)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion2-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion2-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion2-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion2-stderr.txt
new file mode 100644
index 000000000..73f6b77e9
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion2-stderr.txt
@@ -0,0 +1,26 @@
+^CMake Error at TARGET_GENEX_EVAL-recursion2.cmake:10 \(add_custom_target\):
+ Error evaluating generator expression:
+
+ \$<TARGET_GENEX_EVAL:recursion1,\$<TARGET_PROPERTY:recursion1,CUSTOM_PROPERTY1>>
+
+ Dependency loop found.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at TARGET_GENEX_EVAL-recursion2.cmake:10 \(add_custom_target\):
+ Loop step 1
+
+ \$<TARGET_GENEX_EVAL:recursion2,\$<TARGET_PROPERTY:recursion2,CUSTOM_PROPERTY2>>
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at TARGET_GENEX_EVAL-recursion2.cmake:10 \(add_custom_target\):
+ Loop step 2
+
+ \$<TARGET_GENEX_EVAL:recursion1,\$<TARGET_PROPERTY:recursion1,CUSTOM_PROPERTY1>>
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion2.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion2.cmake
new file mode 100644
index 000000000..a28dfc34d
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL-recursion2.cmake
@@ -0,0 +1,12 @@
+
+enable_language(C)
+
+add_library (recursion1 SHARED empty.c)
+set_property (TARGET recursion1 PROPERTY CUSTOM_PROPERTY1 "$<TARGET_GENEX_EVAL:recursion2,$<TARGET_PROPERTY:recursion2,CUSTOM_PROPERTY2>>")
+
+add_library (recursion2 SHARED empty.c)
+set_property (TARGET recursion2 PROPERTY CUSTOM_PROPERTY2 "$<TARGET_GENEX_EVAL:recursion1,$<TARGET_PROPERTY:recursion1,CUSTOM_PROPERTY1>>")
+
+add_custom_target (drive
+ COMMAND echo "$<TARGET_GENEX_EVAL:recursion1,$<TARGET_PROPERTY:recursion1,CUSTOM_PROPERTY1>>"
+ DEPENDS recursion)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL.cmake
new file mode 100644
index 000000000..68b371257
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_GENEX_EVAL.cmake
@@ -0,0 +1,10 @@
+
+cmake_policy(VERSION 3.11)
+
+enable_language(C)
+
+add_library (example SHARED empty.c)
+set_property (TARGET example PROPERTY CUSTOM_PROPERTY1 "PROPERTY1")
+set_property (TARGET example PROPERTY CUSTOM_PROPERTY2 "BEFORE_$<TARGET_PROPERTY:CUSTOM_PROPERTY1>_AFTER")
+
+file(GENERATE OUTPUT "TARGET_GENEX_EVAL-generated.txt" CONTENT "$<TARGET_GENEX_EVAL:example,$<TARGET_PROPERTY:example,CUSTOM_PROPERTY2>>")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-stderr.txt
new file mode 100644
index 000000000..1ae2f2c86
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at TARGET_LINKER_FILE_BASE_NAME-non-valid-target.cmake:[0-9]+ \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_LINKER_FILE_BASE_NAME:empty>
+
+ Target "empty" is not an executable or library\.
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target.cmake
new file mode 100644
index 000000000..776fb4bbb
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_BASE_NAME-non-valid-target.cmake
@@ -0,0 +1,7 @@
+
+add_custom_target(empty)
+
+file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt"
+ CONTENT "[$<TARGET_LINKER_FILE_BASE_NAME:empty>]"
+)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-stderr.txt
new file mode 100644
index 000000000..7a36cefbc
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at TARGET_LINKER_FILE_PREFIX-non-valid-target.cmake:[0-9]+ \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_LINKER_FILE_PREFIX:empty>
+
+ Target "empty" is not an executable or library\.
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target.cmake
new file mode 100644
index 000000000..8dad4dad4
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_PREFIX-non-valid-target.cmake
@@ -0,0 +1,7 @@
+
+add_custom_target(empty)
+
+file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt"
+ CONTENT "[$<TARGET_LINKER_FILE_PREFIX:empty>]"
+)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-stderr.txt
new file mode 100644
index 000000000..cc5217a14
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at TARGET_LINKER_FILE_SUFFIX-non-valid-target.cmake:[0-9]+ \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_LINKER_FILE_SUFFIX:empty>
+
+ Target "empty" is not an executable or library\.
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target.cmake
new file mode 100644
index 000000000..82c2f3a04
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_LINKER_FILE_SUFFIX-non-valid-target.cmake
@@ -0,0 +1,7 @@
+
+add_custom_target(empty)
+
+file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt"
+ CONTENT "[$<TARGET_LINKER_FILE_SUFFIX:empty>]"
+)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-check.cmake
new file mode 100644
index 000000000..2f5743093
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-check.cmake
@@ -0,0 +1,6 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/TARGET_NAME_IF_EXISTS-generated.txt" content)
+
+set(expected "foo")
+if(NOT content STREQUAL expected)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-stderr.txt
new file mode 100644
index 000000000..5ee13b727
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at TARGET_NAME_IF_EXISTS-empty-arg.cmake:2 \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_NAME_IF_EXISTS:>
+
+ \$<TARGET_NAME_IF_EXISTS:tgt> expression requires a non-empty valid target
+ name.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg.cmake
new file mode 100644
index 000000000..f5034f429
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-empty-arg.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0070 NEW)
+file(GENERATE OUTPUT TARGET_NAME_IF_EXISTS-generated.txt CONTENT "$<TARGET_NAME_IF_EXISTS:${empty}>")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-result.txt b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-stderr.txt b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-stderr.txt
new file mode 100644
index 000000000..4122425ab
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at TARGET_NAME_IF_EXISTS-no-arg.cmake:2 \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_NAME_IF_EXISTS>
+
+ \$<TARGET_NAME_IF_EXISTS> expression requires exactly one parameter.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg.cmake
new file mode 100644
index 000000000..32930948a
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-no-arg.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0070 NEW)
+file(GENERATE OUTPUT TARGET_NAME_IF_EXISTS-generated.txt CONTENT "$<TARGET_NAME_IF_EXISTS>")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target-check.cmake
new file mode 100644
index 000000000..2085c167e
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target-check.cmake
@@ -0,0 +1,5 @@
+file(READ "${RunCMake_TEST_BINARY_DIR}/TARGET_NAME_IF_EXISTS-not-a-target-generated.txt" content)
+
+if(content)
+ set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected an empty string")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target.cmake
new file mode 100644
index 000000000..a054e6cc7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS-not-a-target.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0070 NEW)
+file(GENERATE OUTPUT TARGET_NAME_IF_EXISTS-not-a-target-generated.txt CONTENT "$<TARGET_NAME_IF_EXISTS:just-random-string>")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS.cmake
new file mode 100644
index 000000000..0ce3b1d7f
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_NAME_IF_EXISTS.cmake
@@ -0,0 +1,3 @@
+cmake_policy(SET CMP0070 NEW)
+add_custom_target(foo)
+file(GENERATE OUTPUT TARGET_NAME_IF_EXISTS-generated.txt CONTENT "$<TARGET_NAME_IF_EXISTS:foo>")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake
new file mode 100644
index 000000000..cb6f4d867
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-INCLUDE_DIRECTORIES.cmake
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.14)
+enable_language(C)
+
+add_library(foo1 STATIC empty.c)
+target_include_directories(foo1 PUBLIC include)
+target_link_libraries(foo1 PRIVATE foo2 foo3 foo4)
+
+add_library(foo2 STATIC empty.c)
+target_include_directories(foo2 PUBLIC $<TARGET_PROPERTY:foo1,INCLUDE_DIRECTORIES>)
+
+add_library(foo3 STATIC empty.c)
+target_include_directories(foo3 PUBLIC $<TARGET_PROPERTY:foo2,INCLUDE_DIRECTORIES>)
+
+add_library(foo4 STATIC empty.c)
+target_include_directories(foo4 PUBLIC $<TARGET_PROPERTY:foo3,INCLUDE_DIRECTORIES>)
+
+# Evaluate a genex that looks up INCLUDE_DIRECTORIES on multiple targets.
+file(GENERATE OUTPUT out.txt CONTENT "$<TARGET_PROPERTY:foo4,INCLUDE_DIRECTORIES>")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake
index f1452b54d..c1a0f5bc4 100644
--- a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES-check.cmake
@@ -1,8 +1,5 @@
file(READ ${RunCMake_TEST_BINARY_DIR}/foo.txt foo_sources)
-# VS generators inject CMakeLists.txt as a source. Remove it.
-string(REGEX REPLACE ";[^;]*CMakeLists.txt$" "" foo_sources "${foo_sources}")
-
set(foo_expected "empty.c;empty2.c;empty3.c")
if(NOT foo_sources STREQUAL foo_expected)
set(RunCMake_TEST_FAILED "foo SOURCES was:\n [[${foo_sources}]]\nbut expected:\n [[${foo_expected}]]")
diff --git a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake
index 89993ee09..dee7ead54 100644
--- a/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake
+++ b/Tests/RunCMake/GeneratorExpression/TARGET_PROPERTY-SOURCES.cmake
@@ -1,5 +1,5 @@
+cmake_policy(SET CMP0070 NEW)
enable_language(C)
add_library(foo empty.c empty2.c)
target_sources(foo PRIVATE empty3.c)
-file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/foo.txt
- CONTENT "$<TARGET_PROPERTY:foo,SOURCES>")
+file(GENERATE OUTPUT foo.txt CONTENT "$<TARGET_PROPERTY:foo,SOURCES>")
diff --git a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE.cmake b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE.cmake
index 38e47f91f..a66394b42 100644
--- a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE.cmake
+++ b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE.cmake
@@ -3,7 +3,8 @@ enable_language(C)
add_library(empty SHARED empty.c)
-if(CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
list(GET CMAKE_CONFIGURATION_TYPES 0 FIRST_CONFIG)
set(GENERATE_CONDITION CONDITION $<CONFIG:${FIRST_CONFIG}>)
endif()
diff --git a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME-check.cmake b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME-check.cmake
new file mode 100644
index 000000000..996d2d4e6
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME-check.cmake
@@ -0,0 +1,7 @@
+file(STRINGS ${RunCMake_TEST_BINARY_DIR}/test.txt TEST_TXT ENCODING UTF-8)
+
+list(GET TEST_TXT 0 PDB_FILE_BASE_NAME)
+
+if(NOT PDB_FILE_BASE_NAME MATCHES "empty")
+ set(RunCMake_TEST_FAILED "unexpected PDB_FILE_BASE_NAME [${PDB_FILE_BASE_NAME}]")
+endif()
diff --git a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake
new file mode 100644
index 000000000..cc53bdf0a
--- /dev/null
+++ b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE_BASE_NAME.cmake
@@ -0,0 +1,16 @@
+
+enable_language(C)
+
+add_library(empty SHARED empty.c)
+
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
+ list(GET CMAKE_CONFIGURATION_TYPES 0 FIRST_CONFIG)
+ set(GENERATE_CONDITION CONDITION $<CONFIG:${FIRST_CONFIG}>)
+endif()
+
+file(GENERATE
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test.txt"
+ CONTENT "$<TARGET_PDB_FILE_BASE_NAME:empty>"
+ ${GENERATE_CONDITION}
+)
diff --git a/Tests/RunCMake/GeneratorInstance/BadInstance-result.txt b/Tests/RunCMake/GeneratorInstance/BadInstance-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/BadInstance-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorInstance/BadInstance-stderr.txt b/Tests/RunCMake/GeneratorInstance/BadInstance-stderr.txt
new file mode 100644
index 000000000..5d01c4f9a
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/BadInstance-stderr.txt
@@ -0,0 +1,10 @@
+CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+ Generator
+
+ .*
+
+ does not support instance specification, but instance
+
+ Bad Instance
+
+ was specified.$
diff --git a/Tests/RunCMake/GeneratorInstance/BadInstance-toolchain.cmake b/Tests/RunCMake/GeneratorInstance/BadInstance-toolchain.cmake
new file mode 100644
index 000000000..1d99259d5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/BadInstance-toolchain.cmake
@@ -0,0 +1 @@
+set(CMAKE_GENERATOR_INSTANCE "Bad Instance")
diff --git a/Tests/RunCMake/GeneratorInstance/BadInstance.cmake b/Tests/RunCMake/GeneratorInstance/BadInstance.cmake
new file mode 100644
index 000000000..2fc38e5c5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/BadInstance.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")
diff --git a/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-result.txt b/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-stderr.txt b/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-stderr.txt
new file mode 100644
index 000000000..5d01c4f9a
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain-stderr.txt
@@ -0,0 +1,10 @@
+CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+ Generator
+
+ .*
+
+ does not support instance specification, but instance
+
+ Bad Instance
+
+ was specified.$
diff --git a/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain.cmake b/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain.cmake
new file mode 100644
index 000000000..2fc38e5c5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/BadInstanceToolchain.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")
diff --git a/Tests/RunCMake/GeneratorInstance/CMakeLists.txt b/Tests/RunCMake/GeneratorInstance/CMakeLists.txt
new file mode 100644
index 000000000..d3137f614
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.9)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/GeneratorInstance/DefaultInstance.cmake b/Tests/RunCMake/GeneratorInstance/DefaultInstance.cmake
new file mode 100644
index 000000000..7750c2e14
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/DefaultInstance.cmake
@@ -0,0 +1,13 @@
+if("x${CMAKE_GENERATOR_INSTANCE}" STREQUAL "x")
+ message(FATAL_ERROR "CMAKE_GENERATOR_INSTANCE is empty but should have a value.")
+elseif("x${CMAKE_GENERATOR_INSTANCE}" MATCHES [[\\]])
+ message(FATAL_ERROR
+ "CMAKE_GENERATOR_INSTANCE is\n"
+ " ${CMAKE_GENERATOR_INSTANCE}\n"
+ "which contains a backslash.")
+elseif(NOT IS_DIRECTORY "${CMAKE_GENERATOR_INSTANCE}")
+ message(FATAL_ERROR
+ "CMAKE_GENERATOR_INSTANCE is\n"
+ " ${CMAKE_GENERATOR_INSTANCE}\n"
+ "which is not an existing directory.")
+endif()
diff --git a/Tests/RunCMake/GeneratorInstance/MissingInstance-result.txt b/Tests/RunCMake/GeneratorInstance/MissingInstance-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/MissingInstance-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorInstance/MissingInstance-stderr.txt b/Tests/RunCMake/GeneratorInstance/MissingInstance-stderr.txt
new file mode 100644
index 000000000..623bf2ef8
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/MissingInstance-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+ Generator
+
+ .*
+
+ could not find specified instance of .*:
+
+ .*/Tests/RunCMake/GeneratorInstance/instance_does_not_exist$
diff --git a/Tests/RunCMake/GeneratorInstance/MissingInstance-toolchain.cmake b/Tests/RunCMake/GeneratorInstance/MissingInstance-toolchain.cmake
new file mode 100644
index 000000000..f803f14d0
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/MissingInstance-toolchain.cmake
@@ -0,0 +1 @@
+set(CMAKE_GENERATOR_INSTANCE "${CMAKE_CURRENT_LIST_DIR}/instance_does_not_exist")
diff --git a/Tests/RunCMake/GeneratorInstance/MissingInstance.cmake b/Tests/RunCMake/GeneratorInstance/MissingInstance.cmake
new file mode 100644
index 000000000..2fc38e5c5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/MissingInstance.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")
diff --git a/Tests/RunCMake/GeneratorInstance/MissingInstanceToolchain-result.txt b/Tests/RunCMake/GeneratorInstance/MissingInstanceToolchain-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/MissingInstanceToolchain-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorInstance/MissingInstanceToolchain-stderr.txt b/Tests/RunCMake/GeneratorInstance/MissingInstanceToolchain-stderr.txt
new file mode 100644
index 000000000..623bf2ef8
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/MissingInstanceToolchain-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+ Generator
+
+ .*
+
+ could not find specified instance of .*:
+
+ .*/Tests/RunCMake/GeneratorInstance/instance_does_not_exist$
diff --git a/Tests/RunCMake/GeneratorInstance/MissingInstanceToolchain.cmake b/Tests/RunCMake/GeneratorInstance/MissingInstanceToolchain.cmake
new file mode 100644
index 000000000..2fc38e5c5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/MissingInstanceToolchain.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")
diff --git a/Tests/RunCMake/GeneratorInstance/NoInstance-result.txt b/Tests/RunCMake/GeneratorInstance/NoInstance-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/NoInstance-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorInstance/NoInstance-stderr.txt b/Tests/RunCMake/GeneratorInstance/NoInstance-stderr.txt
new file mode 100644
index 000000000..e7b52fd5d
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/NoInstance-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at NoInstance.cmake:2 \(message\):
+ CMAKE_GENERATOR_INSTANCE is empty as expected.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GeneratorInstance/NoInstance.cmake b/Tests/RunCMake/GeneratorInstance/NoInstance.cmake
new file mode 100644
index 000000000..2e6782e38
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/NoInstance.cmake
@@ -0,0 +1,7 @@
+if("x${CMAKE_GENERATOR_INSTANCE}" STREQUAL "x")
+ message(FATAL_ERROR "CMAKE_GENERATOR_INSTANCE is empty as expected.")
+else()
+ message(FATAL_ERROR
+ "CMAKE_GENERATOR_INSTANCE is \"${CMAKE_GENERATOR_INSTANCE}\" "
+ "but should be empty!")
+endif()
diff --git a/Tests/RunCMake/GeneratorInstance/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorInstance/RunCMakeTest.cmake
new file mode 100644
index 000000000..e7f9ccbc4
--- /dev/null
+++ b/Tests/RunCMake/GeneratorInstance/RunCMakeTest.cmake
@@ -0,0 +1,22 @@
+include(RunCMake)
+
+if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio 1[56789]")
+ set(RunCMake_GENERATOR_INSTANCE "")
+ run_cmake(DefaultInstance)
+
+ set(RunCMake_GENERATOR_INSTANCE "${RunCMake_SOURCE_DIR}/instance_does_not_exist")
+ run_cmake(MissingInstance)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/MissingInstance-toolchain.cmake)
+ run_cmake(MissingInstanceToolchain)
+ unset(RunCMake_TEST_OPTIONS)
+else()
+ set(RunCMake_GENERATOR_INSTANCE "")
+ run_cmake(NoInstance)
+
+ set(RunCMake_GENERATOR_INSTANCE "Bad Instance")
+ run_cmake(BadInstance)
+
+ set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/BadInstance-toolchain.cmake)
+ run_cmake(BadInstanceToolchain)
+ unset(RunCMake_TEST_OPTIONS)
+endif()
diff --git a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake
index 27250cba7..27ede066e 100644
--- a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake
@@ -3,7 +3,7 @@ include(RunCMake)
set(RunCMake_GENERATOR_PLATFORM "")
run_cmake(NoPlatform)
-if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[01245])( 20[0-9][0-9])?$")
+if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[012456])( 20[0-9][0-9])?$")
set(RunCMake_GENERATOR_PLATFORM "x64")
run_cmake(x64Platform)
else()
@@ -17,7 +17,7 @@ set(RunCMake_TEST_OPTIONS -A "Extra Platform")
run_cmake(TwoPlatforms)
unset(RunCMake_TEST_OPTIONS)
-if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[01245])( 20[0-9][0-9])?$")
+if("${RunCMake_GENERATOR}" MATCHES "^Visual Studio ([89]|1[012456])( 20[0-9][0-9])?$")
set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/TestPlatform-toolchain.cmake)
run_cmake(TestPlatformToolchain)
unset(RunCMake_TEST_OPTIONS)
diff --git a/Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake b/Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake
index 763478cc5..d8138b8b2 100644
--- a/Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake
+++ b/Tests/RunCMake/GeneratorPlatform/TestPlatform-toolchain.cmake
@@ -1 +1,2 @@
+message("CMAKE_VS_PLATFORM_NAME_DEFAULT is \"${CMAKE_VS_PLATFORM_NAME_DEFAULT}\"")
set(CMAKE_GENERATOR_PLATFORM "Test Platform")
diff --git a/Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt b/Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt
index b9bb3b231..686779013 100644
--- a/Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt
+++ b/Tests/RunCMake/GeneratorPlatform/TestPlatformToolchain-stderr.txt
@@ -1,3 +1,4 @@
+CMAKE_VS_PLATFORM_NAME_DEFAULT is "[^"]+"
CMake Error at TestPlatformToolchain.cmake:[0-9]+ \(message\):
CMAKE_GENERATOR_PLATFORM is "Test Platform" as expected.
Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchTwice-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchTwice-stderr.txt
index 164d3aa79..7067423f4 100644
--- a/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchTwice-stderr.txt
+++ b/Tests/RunCMake/GeneratorToolset/BadToolsetHostArchTwice-stderr.txt
@@ -5,6 +5,6 @@ CMake Error at CMakeLists.txt:[0-9]+ \(project\):
given toolset specification
- Test Toolset,host=x64,host=x64
+ Test Toolset,host=x64,host=x86
that contains duplicate field key 'host'\.$
diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetVersion-result.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetVersion-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/BadToolsetVersion-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetVersion-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetVersion-stderr.txt
new file mode 100644
index 000000000..c976f59ca
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/BadToolsetVersion-stderr.txt
@@ -0,0 +1,10 @@
+CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+ Generator
+
+ .*
+
+ given toolset and version specification
+
+ Test Toolset,version=Bad Toolset Version
+
+ contains an invalid version specification.
diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetVersion.cmake b/Tests/RunCMake/GeneratorToolset/BadToolsetVersion.cmake
new file mode 100644
index 000000000..2fc38e5c5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/BadToolsetVersion.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")
diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetVersionTwice-result.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetVersionTwice-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/BadToolsetVersionTwice-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetVersionTwice-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetVersionTwice-stderr.txt
new file mode 100644
index 000000000..b780dad92
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/BadToolsetVersionTwice-stderr.txt
@@ -0,0 +1,10 @@
+CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+ Generator
+
+ .*
+
+ given toolset specification
+
+ Test Toolset,version=Test Toolset Version,version=Test Toolset Version
+
+ that contains duplicate field key 'version'\.$
diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetVersionTwice.cmake b/Tests/RunCMake/GeneratorToolset/BadToolsetVersionTwice.cmake
new file mode 100644
index 000000000..2fc38e5c5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/BadToolsetVersionTwice.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")
diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
index f89100e84..ae75561b1 100644
--- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake
@@ -3,28 +3,44 @@ include(RunCMake)
set(RunCMake_GENERATOR_TOOLSET "")
run_cmake(NoToolset)
-if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[01245]")
+if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]")
set(RunCMake_GENERATOR_TOOLSET "Test Toolset")
run_cmake(TestToolset)
- set(RunCMake_GENERATOR_TOOLSET "Test Toolset,cuda=Test Cuda")
+ set(RunCMake_GENERATOR_TOOLSET "Test Toolset,cuda=0.0")
run_cmake(TestToolsetCudaBoth)
- set(RunCMake_GENERATOR_TOOLSET ",cuda=Test Cuda")
- run_cmake(TestToolsetCudaOnly)
- set(RunCMake_GENERATOR_TOOLSET "cuda=Test Cuda")
- run_cmake(TestToolsetCudaOnly)
- if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[245]")
+ set(RunCMake_GENERATOR_TOOLSET ",cuda=0.0")
+ run_cmake(TestToolsetCudaVersionOnly)
+ set(RunCMake_GENERATOR_TOOLSET "cuda=0.0")
+ run_cmake(TestToolsetCudaVersionOnly)
+ set(RunCMake_GENERATOR_TOOLSET "cuda=C:\\dummy\\cuda")
+ run_cmake(TestToolsetCudaPathOnly)
+ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[2456]")
set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64")
run_cmake(TestToolsetHostArchBoth)
set(RunCMake_GENERATOR_TOOLSET ",host=x64")
- run_cmake(TestToolsetHostArchOnly)
+ run_cmake(TestToolsetHostArchOnly_x64)
set(RunCMake_GENERATOR_TOOLSET "host=x64")
- run_cmake(TestToolsetHostArchOnly)
+ run_cmake(TestToolsetHostArchOnly_x64)
+ set(RunCMake_GENERATOR_TOOLSET "host=x86")
+ run_cmake(TestToolsetHostArchOnly_x86)
set(RunCMake_GENERATOR_TOOLSET "Test Toolset")
run_cmake(TestToolsetHostArchNone)
set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x65")
run_cmake(BadToolsetHostArch)
- set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64,host=x64")
+ set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64,host=x86")
run_cmake(BadToolsetHostArchTwice)
+ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[56]")
+ set(RunCMake_GENERATOR_TOOLSET "Test Toolset,version=Test Toolset Version")
+ run_cmake(TestToolsetVersionBoth)
+ set(RunCMake_GENERATOR_TOOLSET ",version=Test Toolset Version")
+ run_cmake(TestToolsetVersionOnly)
+ set(RunCMake_GENERATOR_TOOLSET "version=Test Toolset Version")
+ run_cmake(TestToolsetVersionOnly)
+ set(RunCMake_GENERATOR_TOOLSET "Test Toolset,version=Bad Toolset Version")
+ run_cmake(BadToolsetVersion)
+ set(RunCMake_GENERATOR_TOOLSET "Test Toolset,version=Test Toolset Version,version=Test Toolset Version")
+ run_cmake(BadToolsetVersionTwice)
+ endif()
else()
set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64")
run_cmake(BadToolsetHostArch)
@@ -47,7 +63,7 @@ set(RunCMake_TEST_OPTIONS -T "Extra Toolset")
run_cmake(TwoToolsets)
unset(RunCMake_TEST_OPTIONS)
-if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[01245]|Xcode")
+if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]|Xcode")
set(RunCMake_TEST_OPTIONS -DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/TestToolset-toolchain.cmake)
run_cmake(TestToolsetToolchain)
unset(RunCMake_TEST_OPTIONS)
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaBoth-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaBoth-stdout.txt
index 90503e2cc..f12c123a5 100644
--- a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaBoth-stdout.txt
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaBoth-stdout.txt
@@ -1,2 +1,2 @@
-- CMAKE_VS_PLATFORM_TOOLSET='Test Toolset'
--- CMAKE_VS_PLATFORM_TOOLSET_CUDA='Test Cuda'
+-- CMAKE_VS_PLATFORM_TOOLSET_CUDA='0.0'
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaOnly-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaOnly-stdout.txt
deleted file mode 100644
index 94e1e43e4..000000000
--- a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaOnly-stdout.txt
+++ /dev/null
@@ -1,2 +0,0 @@
--- CMAKE_VS_PLATFORM_TOOLSET='(v[0-9]+|Windows7.1SDK)'
--- CMAKE_VS_PLATFORM_TOOLSET_CUDA='Test Cuda'
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-result.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt
new file mode 100644
index 000000000..b17745f9a
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt
@@ -0,0 +1,12 @@
+CMake Error at CMakeLists.txt:[0-9]+ \(project\):
+ Generator
+
+ Visual Studio .*
+
+ given toolset
+
+ cuda=C:\\dummy\\cuda\\
+
+ cannot detect Visual Studio integration files in path
+
+ C:/dummy/cuda/CUDAVisualStudioIntegration/extras/visual_studio_integration/MSBuildExtensions
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly.cmake
new file mode 100644
index 000000000..2fc38e5c5
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This should not be reached!")
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaVersionOnly-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaVersionOnly-stdout.txt
new file mode 100644
index 000000000..1717ff82e
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaVersionOnly-stdout.txt
@@ -0,0 +1,2 @@
+-- CMAKE_VS_PLATFORM_TOOLSET='(v[0-9]+|Windows7.1SDK)'
+-- CMAKE_VS_PLATFORM_TOOLSET_CUDA='0.0'
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaOnly.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaVersionOnly.cmake
index befa0af9d..befa0af9d 100644
--- a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaOnly.cmake
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaVersionOnly.cmake
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt
index 576b40cc0..e5e6c8da9 100644
--- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone-stdout.txt
@@ -1,2 +1,2 @@
-- CMAKE_VS_PLATFORM_TOOLSET='Test Toolset'
--- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE=''
+-- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='.*'
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake
index 26926f9db..085bb6b17 100644
--- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchNone.cmake
@@ -1,2 +1,15 @@
message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'")
message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'")
+
+if(CMAKE_GENERATOR MATCHES "Visual Studio 1[6]")
+ cmake_host_system_information(RESULT is_64_bit QUERY IS_64BIT)
+ if(is_64_bit)
+ if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "x64")
+ message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not 'x64' as expected.")
+ endif()
+ endif()
+else()
+ if(NOT "${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}" STREQUAL "")
+ message(FATAL_ERROR "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE is not empty as expected.")
+ endif()
+endif()
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x64-stdout.txt
index 8271bd487..8271bd487 100644
--- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly-stdout.txt
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x64-stdout.txt
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x64.cmake
index 26926f9db..26926f9db 100644
--- a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly.cmake
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x64.cmake
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86-stdout.txt
new file mode 100644
index 000000000..c7293dc42
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86-stdout.txt
@@ -0,0 +1,2 @@
+-- CMAKE_VS_PLATFORM_TOOLSET='v[0-9]+'
+-- CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='x86'
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86.cmake
new file mode 100644
index 000000000..26926f9db
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetHostArchOnly_x86.cmake
@@ -0,0 +1,2 @@
+message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'")
+message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE='${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}'")
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetVersionBoth-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetVersionBoth-stdout.txt
new file mode 100644
index 000000000..9b91fdec3
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetVersionBoth-stdout.txt
@@ -0,0 +1,2 @@
+-- CMAKE_VS_PLATFORM_TOOLSET='Test Toolset'
+-- CMAKE_VS_PLATFORM_TOOLSET_VERSION='Test Toolset Version'
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetVersionBoth.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetVersionBoth.cmake
new file mode 100644
index 000000000..fbc75bec8
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetVersionBoth.cmake
@@ -0,0 +1,2 @@
+message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'")
+message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_VERSION='${CMAKE_VS_PLATFORM_TOOLSET_VERSION}'")
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetVersionOnly-stdout.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetVersionOnly-stdout.txt
new file mode 100644
index 000000000..25c41635b
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetVersionOnly-stdout.txt
@@ -0,0 +1,2 @@
+-- CMAKE_VS_PLATFORM_TOOLSET='v[0-9]+'
+-- CMAKE_VS_PLATFORM_TOOLSET_VERSION='Test Toolset Version'
diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetVersionOnly.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetVersionOnly.cmake
new file mode 100644
index 000000000..fbc75bec8
--- /dev/null
+++ b/Tests/RunCMake/GeneratorToolset/TestToolsetVersionOnly.cmake
@@ -0,0 +1,2 @@
+message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'")
+message(STATUS "CMAKE_VS_PLATFORM_TOOLSET_VERSION='${CMAKE_VS_PLATFORM_TOOLSET_VERSION}'")
diff --git a/Tests/RunCMake/GetPrerequisites/ExecutableScripts-stdout.txt b/Tests/RunCMake/GetPrerequisites/ExecutableScripts-stdout.txt
new file mode 100644
index 000000000..5a353d8c8
--- /dev/null
+++ b/Tests/RunCMake/GetPrerequisites/ExecutableScripts-stdout.txt
@@ -0,0 +1,3 @@
+-- GetPrequisites\(.*script.sh\) : ignoring script file
+-- GetPrequisites\(.*script.bat\) : ignoring script file
+-- GetPrequisites\(.*script\) : ignoring script file
diff --git a/Tests/RunCMake/GetPrerequisites/ExecutableScripts.cmake b/Tests/RunCMake/GetPrerequisites/ExecutableScripts.cmake
new file mode 100644
index 000000000..d1bc9b1d4
--- /dev/null
+++ b/Tests/RunCMake/GetPrerequisites/ExecutableScripts.cmake
@@ -0,0 +1,19 @@
+include(GetPrerequisites)
+
+function(check_script script)
+ set(prereqs "")
+ get_prerequisites(${script} prereqs 1 1 "" "")
+ if(NOT "${prereqs}" STREQUAL "")
+ message(FATAL_ERROR "Prerequisites for ${script} not empty")
+ endif()
+endfunction()
+
+# Should not throw any errors
+# Regular executable
+get_prerequisites(${CMAKE_COMMAND} cmake_prereqs 1 1 "" "")
+# Shell script
+check_script(${CMAKE_CURRENT_LIST_DIR}/script.sh)
+# Batch script
+check_script(${CMAKE_CURRENT_LIST_DIR}/script.bat)
+# Shell script without extension
+check_script(${CMAKE_CURRENT_LIST_DIR}/script)
diff --git a/Tests/RunCMake/GetPrerequisites/RunCMakeTest.cmake b/Tests/RunCMake/GetPrerequisites/RunCMakeTest.cmake
new file mode 100644
index 000000000..a635e385e
--- /dev/null
+++ b/Tests/RunCMake/GetPrerequisites/RunCMakeTest.cmake
@@ -0,0 +1,4 @@
+include(RunCMake)
+
+run_cmake_command(TargetMissing ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/TargetMissing.cmake)
+run_cmake_command(ExecutableScripts ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/ExecutableScripts.cmake)
diff --git a/Tests/RunCMake/GetPrerequisites/TargetMissing-stderr.txt b/Tests/RunCMake/GetPrerequisites/TargetMissing-stderr.txt
new file mode 100644
index 000000000..cffe5f804
--- /dev/null
+++ b/Tests/RunCMake/GetPrerequisites/TargetMissing-stderr.txt
@@ -0,0 +1,3 @@
+^warning: target 'does_not_exist' is not absolute\.\.\.
+warning: target 'does_not_exist' does not exist\.\.\.
+result_var='value;before;call'$
diff --git a/Tests/RunCMake/GetPrerequisites/TargetMissing.cmake b/Tests/RunCMake/GetPrerequisites/TargetMissing.cmake
new file mode 100644
index 000000000..84fd32ce1
--- /dev/null
+++ b/Tests/RunCMake/GetPrerequisites/TargetMissing.cmake
@@ -0,0 +1,4 @@
+include(GetPrerequisites)
+set(result_var value before call)
+get_prerequisites(does_not_exist result_var 0 0 "" "")
+message("result_var='${result_var}'")
diff --git a/Tests/RunCMake/GetPrerequisites/script b/Tests/RunCMake/GetPrerequisites/script
new file mode 100755
index 000000000..23bf47c06
--- /dev/null
+++ b/Tests/RunCMake/GetPrerequisites/script
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo "Hello World"
diff --git a/Tests/RunCMake/GetPrerequisites/script.bat b/Tests/RunCMake/GetPrerequisites/script.bat
new file mode 100755
index 000000000..338ae039b
--- /dev/null
+++ b/Tests/RunCMake/GetPrerequisites/script.bat
@@ -0,0 +1,3 @@
+@echo off
+
+echo "Hello world"
diff --git a/Tests/RunCMake/GetPrerequisites/script.sh b/Tests/RunCMake/GetPrerequisites/script.sh
new file mode 100755
index 000000000..23bf47c06
--- /dev/null
+++ b/Tests/RunCMake/GetPrerequisites/script.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+echo "Hello World"
diff --git a/Tests/RunCMake/GoogleTest/CMakeLists.txt b/Tests/RunCMake/GoogleTest/CMakeLists.txt
new file mode 100644
index 000000000..dc9248697
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.6)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-result.txt
new file mode 100644
index 000000000..d197c913c
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-stdout.txt
new file mode 100644
index 000000000..3a6572c3e
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-timeout-stdout.txt
@@ -0,0 +1,7 @@
+( *|[0-9]+>)CMake Error at .*GoogleTestAddTests.cmake:[0-9]+ \(message\):
+( *|[0-9]+>) Error running test executable.
+?( *|[0-9]+>)
+( *|[0-9]+>) Path: '.*discovery_timeout_test(\.exe)?'
+( *|[0-9]+>) Result: Process terminated due to timeout
+( *|[0-9]+>) Output:
+( *|[0-9]+>) +
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-result.txt
new file mode 100644
index 000000000..d197c913c
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stderr.txt b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stderr.txt
new file mode 100644
index 000000000..ba4235def
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stderr.txt
@@ -0,0 +1 @@
+Errors while running CTest
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stdout.txt
new file mode 100644
index 000000000..0dda49d7c
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout1-stdout.txt
@@ -0,0 +1,10 @@
+Test project .*GoogleTest-build
+[ \t]*Start [0-9]+: property_timeout.case_no_discovery
+[^\n]+property_timeout.case_no_discovery +\.+\*\*\*Timeout +[0-9.]+ sec
++
+0% tests passed, 1 tests failed out of 1
++
+Total Test time \(real\) = +[0-9.]+ sec
++
+The following tests FAILED:
+[^\n]*property_timeout.case_no_discovery \(Timeout\)
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-result.txt
new file mode 100644
index 000000000..d197c913c
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stderr.txt b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stderr.txt
new file mode 100644
index 000000000..ba4235def
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stderr.txt
@@ -0,0 +1 @@
+Errors while running CTest
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stdout.txt
new file mode 100644
index 000000000..72cea558e
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-property-timeout2-stdout.txt
@@ -0,0 +1,10 @@
+Test project .*GoogleTest-build
+[ \t]*Start [0-9]+: property_timeout.case_with_discovery
+[^\n]+property_timeout.case_with_discovery +\.+\*\*\*Timeout +[0-9.]+ sec
++
+0% tests passed, 1 tests failed out of 1
++
+Total Test time \(real\) = +[0-9.]+ sec
++
+The following tests FAILED:
+[^\n]*property_timeout.case_with_discovery \(Timeout\)
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-result.txt
new file mode 100644
index 000000000..d197c913c
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt
new file mode 100644
index 000000000..a4cc97192
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt
@@ -0,0 +1,2 @@
+Unable to find executable: no_tests_defined_NOT_BUILT
+Errors while running CTest
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt
new file mode 100644
index 000000000..5f7753dba
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-test1-stdout.txt
@@ -0,0 +1,25 @@
+Test project .*
+ Start 1: TEST:basic\.case_foo!1
+1/8 Test #1: TEST:basic\.case_foo!1 \.+ +Passed +[0-9.]+ sec
+ Start 2: TEST:basic\.case_bar!1
+2/8 Test #2: TEST:basic\.case_bar!1 \.+ +Passed +[0-9.]+ sec
+ Start 3: TEST:basic\.disabled_case!1
+3/8 Test #3: TEST:basic\.disabled_case!1 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec
+ Start 4: TEST:disabled\.case!1
+4/8 Test #4: TEST:disabled\.case!1 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec
+ Start 5: TEST:typed/short\.case!1
+5/8 Test #5: TEST:typed/short\.case!1 \.+ +Passed +[0-9.]+ sec
+ Start 6: TEST:typed/float\.case!1
+6/8 Test #6: TEST:typed/float\.case!1 \.+ +Passed +[0-9.]+ sec
+ Start 7: TEST:value/test\.case/1!1
+7/8 Test #7: TEST:value/test\.case/1!1 \.+ +Passed +[0-9.]+ sec
+ Start 8: TEST:value/test\.case/"foo"!1
+8/8 Test #8: TEST:value/test\.case/"foo"!1 \.+ +Passed +[0-9.]+ sec
+
+100% tests passed, 0 tests failed out of 6
+
+Total Test time \(real\) = +[0-9.]+ sec
+
+The following tests did not run:
+.*3 - TEST:basic\.disabled_case!1 \(Disabled\)
+.*4 - TEST:disabled\.case!1 \(Disabled\)
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt
new file mode 100644
index 000000000..960c0b9cf
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-test2-stdout.txt
@@ -0,0 +1,25 @@
+Test project .*
+ Start 9: TEST:basic\.case_foo!2
+1/8 Test #9: TEST:basic\.case_foo!2 \.+ +Passed +[0-9.]+ sec
+ Start 10: TEST:basic\.case_bar!2
+2/8 Test #10: TEST:basic\.case_bar!2 \.+ +Passed +[0-9.]+ sec
+ Start 11: TEST:basic\.disabled_case!2
+3/8 Test #11: TEST:basic\.disabled_case!2 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec
+ Start 12: TEST:disabled\.case!2
+4/8 Test #12: TEST:disabled\.case!2 \.+\*+Not Run \(Disabled\) +[0-9.]+ sec
+ Start 13: TEST:typed/short\.case!2
+5/8 Test #13: TEST:typed/short\.case!2 \.+ +Passed +[0-9.]+ sec
+ Start 14: TEST:typed/float\.case!2
+6/8 Test #14: TEST:typed/float\.case!2 \.+ +Passed +[0-9.]+ sec
+ Start 15: TEST:value/test\.case/1!2
+7/8 Test #15: TEST:value/test\.case/1!2 \.+ +Passed +[0-9.]+ sec
+ Start 16: TEST:value/test\.case/"foo"!2
+8/8 Test #16: TEST:value/test\.case/"foo"!2 \.+ +Passed +[0-9.]+ sec
+
+100% tests passed, 0 tests failed out of 6
+
+Total Test time \(real\) = +[0-9.]+ sec
+
+The following tests did not run:
+.*11 - TEST:basic\.disabled_case!2 \(Disabled\)
+.*12 - TEST:disabled\.case!2 \(Disabled\)
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest.cmake b/Tests/RunCMake/GoogleTest/GoogleTest.cmake
new file mode 100644
index 000000000..31808c670
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest.cmake
@@ -0,0 +1,59 @@
+project(test_include_dirs)
+include(CTest)
+include(GoogleTest)
+
+enable_testing()
+
+add_executable(fake_gtest fake_gtest.cpp)
+
+gtest_discover_tests(
+ fake_gtest
+ TEST_PREFIX TEST:
+ TEST_SUFFIX !1
+ EXTRA_ARGS how now "\"brown\" cow"
+ PROPERTIES LABELS TEST1
+)
+
+gtest_discover_tests(
+ fake_gtest
+ TEST_PREFIX TEST:
+ TEST_SUFFIX !2
+ EXTRA_ARGS how now "\"brown\" cow"
+ PROPERTIES LABELS TEST2
+)
+
+add_executable(no_tests_defined no_tests_defined.cpp)
+
+gtest_discover_tests(
+ no_tests_defined
+)
+
+# Note change in behavior of TIMEOUT keyword in 3.10.3
+# where it was renamed to DISCOVERY_TIMEOUT to prevent it
+# from shadowing the TIMEOUT test property. Verify the
+# 3.10.3 and later behavior, old behavior added in 3.10.1
+# is not supported.
+add_executable(property_timeout_test timeout_test.cpp)
+target_compile_definitions(property_timeout_test PRIVATE sleepSec=10)
+
+gtest_discover_tests(
+ property_timeout_test
+ TEST_PREFIX property_
+ TEST_SUFFIX _no_discovery
+ PROPERTIES TIMEOUT 2
+)
+gtest_discover_tests(
+ property_timeout_test
+ TEST_PREFIX property_
+ TEST_SUFFIX _with_discovery
+ DISCOVERY_TIMEOUT 20
+ PROPERTIES TIMEOUT 2
+)
+
+add_executable(discovery_timeout_test timeout_test.cpp)
+target_compile_definitions(discovery_timeout_test PRIVATE discoverySleepSec=10)
+gtest_discover_tests(
+ discovery_timeout_test
+ TEST_PREFIX discovery_
+ DISCOVERY_TIMEOUT 2
+)
diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
new file mode 100644
index 000000000..0fa4e2aa2
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
@@ -0,0 +1,74 @@
+include(RunCMake)
+
+function(run_GoogleTest)
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+ endif()
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake(GoogleTest)
+
+ run_cmake_command(GoogleTest-build
+ ${CMAKE_COMMAND}
+ --build .
+ --config Debug
+ --target fake_gtest
+ )
+
+ run_cmake_command(GoogleTest-property-timeout-exe
+ ${CMAKE_COMMAND}
+ --build .
+ --config Debug
+ --target property_timeout_test
+ )
+
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
+ run_cmake_command(GoogleTest-discovery-timeout
+ ${CMAKE_COMMAND}
+ --build .
+ --config Debug
+ --target discovery_timeout_test
+ )
+ set(RunCMake_TEST_OUTPUT_MERGE 0)
+
+ run_cmake_command(GoogleTest-test1
+ ${CMAKE_CTEST_COMMAND}
+ -C Debug
+ -L TEST1
+ --no-label-summary
+ )
+
+ run_cmake_command(GoogleTest-test2
+ ${CMAKE_CTEST_COMMAND}
+ -C Debug
+ -L TEST2
+ --no-label-summary
+ )
+
+ run_cmake_command(GoogleTest-test-missing
+ ${CMAKE_CTEST_COMMAND}
+ -C Debug
+ -R no_tests_defined
+ --no-label-summary
+ )
+
+ run_cmake_command(GoogleTest-property-timeout1
+ ${CMAKE_CTEST_COMMAND}
+ -C Debug
+ -R property_timeout\\.case_no_discovery
+ --no-label-summary
+ )
+
+ run_cmake_command(GoogleTest-property-timeout2
+ ${CMAKE_CTEST_COMMAND}
+ -C Debug
+ -R property_timeout\\.case_with_discovery
+ --no-label-summary
+ )
+endfunction()
+
+run_GoogleTest()
diff --git a/Tests/RunCMake/GoogleTest/fake_gtest.cpp b/Tests/RunCMake/GoogleTest/fake_gtest.cpp
new file mode 100644
index 000000000..f1bd7efc8
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/fake_gtest.cpp
@@ -0,0 +1,41 @@
+#include <iostream>
+#include <string>
+
+int main(int argc, char** argv)
+{
+ // Note: GoogleTest.cmake doesn't actually depend on Google Test as such;
+ // it only requires that we produces output in the expected format when
+ // invoked with --gtest_list_tests. Thus, we fake that here. This allows us
+ // to test the module without actually needing Google Test.
+ if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") {
+ std::cout << "basic." << std::endl;
+ std::cout << " case_foo" << std::endl;
+ std::cout << " case_bar" << std::endl;
+ std::cout << " DISABLED_disabled_case" << std::endl;
+ std::cout << "DISABLED_disabled." << std::endl;
+ std::cout << " case" << std::endl;
+ std::cout << "typed/0. # TypeParam = short" << std::endl;
+ std::cout << " case" << std::endl;
+ std::cout << "typed/1. # TypeParam = float" << std::endl;
+ std::cout << " case" << std::endl;
+ std::cout << "value/test." << std::endl;
+ std::cout << " case/0 # GetParam() = 1" << std::endl;
+ std::cout << " case/1 # GetParam() = \"foo\"" << std::endl;
+ return 0;
+ }
+
+ if (argc > 5) {
+ // Simple test of EXTRA_ARGS
+ if (std::string(argv[3]) == "how" && std::string(argv[4]) == "now" &&
+ std::string(argv[5]) == "\"brown\" cow") {
+ return 0;
+ }
+ }
+
+ // Print arguments for debugging, if we didn't get the expected arguments
+ for (int i = 1; i < argc; ++i) {
+ std::cerr << "arg[" << i << "]: '" << argv[i] << "'\n";
+ }
+
+ return 1;
+}
diff --git a/Tests/RunCMake/GoogleTest/no_tests_defined.cpp b/Tests/RunCMake/GoogleTest/no_tests_defined.cpp
new file mode 100644
index 000000000..f8b643afb
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/no_tests_defined.cpp
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/GoogleTest/timeout_test.cpp b/Tests/RunCMake/GoogleTest/timeout_test.cpp
new file mode 100644
index 000000000..b8ad055e8
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/timeout_test.cpp
@@ -0,0 +1,39 @@
+#if defined(_WIN32)
+# include <windows.h>
+#else
+# include <unistd.h>
+#endif
+
+#include <iostream>
+#include <string>
+
+void sleepFor(unsigned seconds)
+{
+#if defined(_WIN32)
+ Sleep(seconds * 1000);
+#else
+ sleep(seconds);
+#endif
+}
+
+int main(int argc, char** argv)
+{
+ // Note: GoogleTest.cmake doesn't actually depend on Google Test as such;
+ // it only requires that we produce output in the expected format when
+ // invoked with --gtest_list_tests. Thus, we fake that here. This allows us
+ // to test the module without actually needing Google Test.
+ if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") {
+ std::cout << "timeout." << std::endl;
+ std::cout << " case" << std::endl;
+#ifdef discoverySleepSec
+ sleepFor(discoverySleepSec);
+#endif
+ return 0;
+ }
+
+#ifdef sleepSec
+ sleepFor(sleepSec);
+#endif
+
+ return 0;
+}
diff --git a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt
index f2d749b68..d5c480d79 100644
--- a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt
+++ b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt
@@ -1,6 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
- ".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix/BinInInstallPrefix-CMP0052-NEW-build/foo"
+ ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix/BinInInstallPrefix-CMP0052-NEW-build/foo"
which is prefixed in the build directory.
diff --git a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt
new file mode 100644
index 000000000..37747a1e4
--- /dev/null
+++ b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-OLD-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\):
+ The OLD behavior for policy CMP0052 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.$
diff --git a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt
index 3d838926c..eb4d56d5e 100644
--- a/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt
+++ b/Tests/RunCMake/IfacePaths/BinInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt
@@ -6,15 +6,15 @@ CMake Warning \(dev\) in CMakeLists.txt:
Directory:
- ".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix/BinInInstallPrefix-CMP0052-WARN-build/foo"
+ ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix/BinInInstallPrefix-CMP0052-WARN-build/foo"
in INTERFACE_INCLUDE_DIRECTORIES of target "testTarget" is a subdirectory
of the install directory:
- ".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix"
+ ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix"
however it is also a subdirectory of the build tree:
- ".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix/BinInInstallPrefix-CMP0052-WARN-build"
+ ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix/BinInInstallPrefix-CMP0052-WARN-build"
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/IfacePaths/BinaryDirectoryInInterface-stderr_INCLUDE_DIRECTORIES.txt b/Tests/RunCMake/IfacePaths/BinaryDirectoryInInterface-stderr_INCLUDE_DIRECTORIES.txt
index ed7cd58e3..8794a8743 100644
--- a/Tests/RunCMake/IfacePaths/BinaryDirectoryInInterface-stderr_INCLUDE_DIRECTORIES.txt
+++ b/Tests/RunCMake/IfacePaths/BinaryDirectoryInInterface-stderr_INCLUDE_DIRECTORIES.txt
@@ -1,6 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
- ".*RunCMake/IfacePaths_INCLUDE_DIRECTORIES/BinaryDirectoryInInterface-build/foo"
+ ".*RunCMake/IfacePaths_INCDIRS/BinaryDirectoryInInterface-build/foo"
which is prefixed in the build directory.
diff --git a/Tests/RunCMake/IfacePaths/InstallInBinDir-stderr_INCLUDE_DIRECTORIES.txt b/Tests/RunCMake/IfacePaths/InstallInBinDir-stderr_INCLUDE_DIRECTORIES.txt
index 3d60831d1..4ba9360fc 100644
--- a/Tests/RunCMake/IfacePaths/InstallInBinDir-stderr_INCLUDE_DIRECTORIES.txt
+++ b/Tests/RunCMake/IfacePaths/InstallInBinDir-stderr_INCLUDE_DIRECTORIES.txt
@@ -1,6 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
- ".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/InstallInBinDir-build/foo"
+ ".*Tests/RunCMake/IfacePaths_INCDIRS/InstallInBinDir-build/foo"
which is prefixed in the build directory.
diff --git a/Tests/RunCMake/IfacePaths/InstallInSrcDir-stderr_INCLUDE_DIRECTORIES.txt b/Tests/RunCMake/IfacePaths/InstallInSrcDir-stderr_INCLUDE_DIRECTORIES.txt
index 11994ddb3..3c126df2f 100644
--- a/Tests/RunCMake/IfacePaths/InstallInSrcDir-stderr_INCLUDE_DIRECTORIES.txt
+++ b/Tests/RunCMake/IfacePaths/InstallInSrcDir-stderr_INCLUDE_DIRECTORIES.txt
@@ -1,6 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
- ".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/copy/foo"
+ ".*Tests/RunCMake/IfacePaths_INCDIRS/copy/foo"
which is prefixed in the source directory.
diff --git a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt
index ed5df34a4..38bfa4e99 100644
--- a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt
+++ b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-NEW-stderr_INCLUDE_DIRECTORIES.txt
@@ -1,6 +1,6 @@
CMake Error in CMakeLists.txt:
Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
- ".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix/src/foo"
+ ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix/src/foo"
which is prefixed in the source directory.
diff --git a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt
new file mode 100644
index 000000000..37747a1e4
--- /dev/null
+++ b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-OLD-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Deprecation Warning at CMakeLists.txt:1 \(cmake_minimum_required\):
+ The OLD behavior for policy CMP0052 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.$
diff --git a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt
index cb5a51ccb..fd6e3726d 100644
--- a/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt
+++ b/Tests/RunCMake/IfacePaths/SrcInInstallPrefix-CMP0052-WARN-stderr_INCLUDE_DIRECTORIES.txt
@@ -6,15 +6,15 @@ CMake Warning \(dev\) in CMakeLists.txt:
Directory:
- ".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix/src/foo"
+ ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix/src/foo"
in INTERFACE_INCLUDE_DIRECTORIES of target "testTarget" is a subdirectory
of the install directory:
- ".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix"
+ ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix"
however it is also a subdirectory of the source tree:
- ".*Tests/RunCMake/IfacePaths_INCLUDE_DIRECTORIES/prefix/src"
+ ".*Tests/RunCMake/IfacePaths_INCDIRS/prefix/src"
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/Languages/ExternalCUDA.cmake b/Tests/RunCMake/Languages/ExternalCUDA.cmake
new file mode 100644
index 000000000..3afa93e55
--- /dev/null
+++ b/Tests/RunCMake/Languages/ExternalCUDA.cmake
@@ -0,0 +1,8 @@
+enable_language(C)
+
+add_library(ext_cuda IMPORTED STATIC)
+set_property(TARGET ext_cuda PROPERTY IMPORTED_LOCATION "/does_not_exist")
+set_property(TARGET ext_cuda PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES "CUDA")
+
+add_executable(main empty.c)
+target_link_libraries(main ext_cuda)
diff --git a/Tests/RunCMake/Languages/RunCMakeTest.cmake b/Tests/RunCMake/Languages/RunCMakeTest.cmake
index 732baae41..2a534b338 100644
--- a/Tests/RunCMake/Languages/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Languages/RunCMakeTest.cmake
@@ -6,3 +6,5 @@ run_cmake(link-libraries-TARGET_FILE-genex)
run_cmake(link-libraries-TARGET_FILE-genex-ok)
run_cmake(DetermineFail)
+
+run_cmake(ExternalCUDA)
diff --git a/Tests/RunCMake/Languages/empty.c b/Tests/RunCMake/Languages/empty.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/Languages/empty.c
diff --git a/Tests/RunCMake/LinkStatic/LinkOptionsLib.c b/Tests/RunCMake/LinkStatic/LinkOptionsLib.c
new file mode 100644
index 000000000..9bbd24cd8
--- /dev/null
+++ b/Tests/RunCMake/LinkStatic/LinkOptionsLib.c
@@ -0,0 +1,7 @@
+#if defined(_WIN32)
+__declspec(dllexport)
+#endif
+ int flags_lib(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/LinkStatic/RunCMakeTest.cmake b/Tests/RunCMake/LinkStatic/RunCMakeTest.cmake
index 0d2949211..d3a8afb21 100644
--- a/Tests/RunCMake/LinkStatic/RunCMakeTest.cmake
+++ b/Tests/RunCMake/LinkStatic/RunCMakeTest.cmake
@@ -1,3 +1,30 @@
include(RunCMake)
run_cmake(LINK_SEARCH_STATIC)
+
+
+macro(run_cmake_target test subtest target)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN})
+
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+endmacro()
+
+if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
+ # Intel compiler does not reject bad flags or objects!
+ set(RunCMake_TEST_OUTPUT_MERGE TRUE)
+ if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release)
+ endif()
+
+ run_cmake(STATIC_LIBRARY_OPTIONS)
+
+ run_cmake_target(STATIC_LIBRARY_OPTIONS basic StaticLinkOptions)
+ run_cmake_target(STATIC_LIBRARY_OPTIONS genex StaticLinkOptions_genex --config Release)
+ run_cmake_target(STATIC_LIBRARY_OPTIONS shared SharedLinkOptions)
+
+ unset(RunCMake_TEST_OPTIONS)
+ unset(RunCMake_TEST_OUTPUT_MERGE)
+endif()
diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-check.cmake b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-check.cmake
new file mode 100644
index 000000000..858ce06f7
--- /dev/null
+++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "BADFLAG")
+ set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG'.")
+endif()
diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-result.txt b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-result.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-basic-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-check.cmake b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-check.cmake
new file mode 100644
index 000000000..a686de945
--- /dev/null
+++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-check.cmake
@@ -0,0 +1,7 @@
+
+if (NOT actual_stdout MATCHES "BADFLAG_RELEASE")
+ set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_RELEASE'.")
+endif()
+if (actual_stdout MATCHES "SHELL:")
+ string (APPEND RunCMake_TEST_FAILED "\nFound unexpected prefix 'SHELL:'.")
+endif()
diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-result.txt b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-result.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-genex-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-check.cmake b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-check.cmake
new file mode 100644
index 000000000..8c1e96e61
--- /dev/null
+++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-check.cmake
@@ -0,0 +1,4 @@
+
+if (actual_stdout MATCHES "BADFLAG")
+ string (APPEND RunCMake_TEST_FAILED "\nFound unexpected flag 'BADFLAG'.")
+endif()
diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-result.txt b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-result.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS-shared-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS.cmake b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS.cmake
new file mode 100644
index 000000000..587af1d96
--- /dev/null
+++ b/Tests/RunCMake/LinkStatic/STATIC_LIBRARY_OPTIONS.cmake
@@ -0,0 +1,21 @@
+
+enable_language(C)
+
+set(obj "${CMAKE_C_OUTPUT_EXTENSION}")
+if(BORLAND)
+ set(pre -)
+endif()
+
+add_library(StaticLinkOptions STATIC LinkOptionsLib.c)
+set_property(TARGET StaticLinkOptions PROPERTY STATIC_LIBRARY_OPTIONS ${pre}BADFLAG${obj})
+
+# static library with generator expression
+add_library(StaticLinkOptions_genex STATIC LinkOptionsLib.c)
+set_property(TARGET StaticLinkOptions_genex PROPERTY STATIC_LIBRARY_OPTIONS
+ $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}>
+ "SHELL:" # produces no options
+ )
+
+# shared library do not use property STATIC_LIBRARY_OPTIONS
+add_library(SharedLinkOptions SHARED LinkOptionsLib.c)
+set_property(TARGET SharedLinkOptions PROPERTY STATIC_LIBRARY_OPTIONS ${pre}BADFLAG${obj})
diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-result.txt b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-stderr.txt b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-stderr.txt
new file mode 100644
index 000000000..9afa461de
--- /dev/null
+++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error in CMakeLists.txt:
+ MSVC_RUNTIME_LIBRARY value 'BogusValue' not known for this C compiler.
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW.cmake
new file mode 100644
index 000000000..c3ea2fddb
--- /dev/null
+++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0091 NEW)
+include(CMP0091-common.cmake)
diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-OLD.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-OLD.cmake
new file mode 100644
index 000000000..734cc9f68
--- /dev/null
+++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0091 OLD)
+include(CMP0091-common.cmake)
diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-WARN.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-WARN.cmake
new file mode 100644
index 000000000..26f86a050
--- /dev/null
+++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-WARN.cmake
@@ -0,0 +1,2 @@
+
+include(CMP0091-common.cmake)
diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-common.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-common.cmake
new file mode 100644
index 000000000..7827d2a6c
--- /dev/null
+++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-common.cmake
@@ -0,0 +1,37 @@
+enable_language(C)
+
+cmake_policy(GET CMP0091 cmp0091)
+if(cmp0091 STREQUAL "NEW")
+ if(NOT CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT)
+ message(SEND_ERROR "CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT not set under NEW behavior")
+ endif()
+else()
+ if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT)
+ message(SEND_ERROR "CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT is set under OLD behavior")
+ endif()
+endif()
+
+if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+ if(CMAKE_C_FLAGS_DEBUG MATCHES "[/-]MDd( |$)")
+ set(have_MDd 1)
+ else()
+ set(have_MDd 0)
+ endif()
+ if(CMAKE_C_FLAGS_RELEASE MATCHES "[/-]MD( |$)")
+ set(have_MD 1)
+ else()
+ set(have_MD 0)
+ endif()
+ if(cmp0091 STREQUAL "NEW")
+ if(have_MDd OR have_MD)
+ message(SEND_ERROR "Have a -MD* flag under NEW behavior.")
+ endif()
+ else()
+ if(NOT (have_MDd AND have_MD))
+ message(SEND_ERROR "Do not have -MD* flags under OLD behavior.")
+ endif()
+ endif()
+endif()
+
+set(CMAKE_MSVC_RUNTIME_LIBRARY BogusValue)
+add_library(foo empty.c)
diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMakeLists.txt b/Tests/RunCMake/MSVCRuntimeLibrary/CMakeLists.txt
new file mode 100644
index 000000000..3e470a29c
--- /dev/null
+++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.14)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/RunCMakeTest.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/RunCMakeTest.cmake
new file mode 100644
index 000000000..fad18dacc
--- /dev/null
+++ b/Tests/RunCMake/MSVCRuntimeLibrary/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(CMP0091-WARN)
+run_cmake(CMP0091-OLD)
+run_cmake(CMP0091-NEW)
diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/empty.c b/Tests/RunCMake/MSVCRuntimeLibrary/empty.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/MSVCRuntimeLibrary/empty.c
diff --git a/Tests/RunCMake/MSVCWarningFlags/CMP0092-NEW.cmake b/Tests/RunCMake/MSVCWarningFlags/CMP0092-NEW.cmake
new file mode 100644
index 000000000..15c52d217
--- /dev/null
+++ b/Tests/RunCMake/MSVCWarningFlags/CMP0092-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0092 NEW)
+include(CMP0092-common.cmake)
diff --git a/Tests/RunCMake/MSVCWarningFlags/CMP0092-OLD.cmake b/Tests/RunCMake/MSVCWarningFlags/CMP0092-OLD.cmake
new file mode 100644
index 000000000..ea7544564
--- /dev/null
+++ b/Tests/RunCMake/MSVCWarningFlags/CMP0092-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0092 OLD)
+include(CMP0092-common.cmake)
diff --git a/Tests/RunCMake/MSVCWarningFlags/CMP0092-WARN.cmake b/Tests/RunCMake/MSVCWarningFlags/CMP0092-WARN.cmake
new file mode 100644
index 000000000..45e183f4a
--- /dev/null
+++ b/Tests/RunCMake/MSVCWarningFlags/CMP0092-WARN.cmake
@@ -0,0 +1,2 @@
+
+include(CMP0092-common.cmake)
diff --git a/Tests/RunCMake/MSVCWarningFlags/CMP0092-common.cmake b/Tests/RunCMake/MSVCWarningFlags/CMP0092-common.cmake
new file mode 100644
index 000000000..87d7f67c6
--- /dev/null
+++ b/Tests/RunCMake/MSVCWarningFlags/CMP0092-common.cmake
@@ -0,0 +1,12 @@
+enable_language(C)
+
+cmake_policy(GET CMP0092 cmp0092)
+if(cmp0092 STREQUAL "NEW")
+ if("${CMAKE_C_FLAGS}" MATCHES "([/-]W[0-9])")
+ message(SEND_ERROR "CMAKE_C_FLAGS has '${CMAKE_MATCH_1}' under NEW behavior")
+ endif()
+else()
+ if(NOT " ${CMAKE_C_FLAGS} " MATCHES " /W3 ")
+ message(SEND_ERROR "CMAKE_C_FLAGS does not have '/W3' under OLD behavior")
+ endif()
+endif()
diff --git a/Tests/RunCMake/MSVCWarningFlags/CMakeLists.txt b/Tests/RunCMake/MSVCWarningFlags/CMakeLists.txt
new file mode 100644
index 000000000..3e470a29c
--- /dev/null
+++ b/Tests/RunCMake/MSVCWarningFlags/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.14)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/MSVCWarningFlags/RunCMakeTest.cmake b/Tests/RunCMake/MSVCWarningFlags/RunCMakeTest.cmake
new file mode 100644
index 000000000..7ce448dff
--- /dev/null
+++ b/Tests/RunCMake/MSVCWarningFlags/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(CMP0092-WARN)
+run_cmake(CMP0092-OLD)
+run_cmake(CMP0092-NEW)
diff --git a/Tests/RunCMake/Make/IncludeRegexSubdir-check.cmake b/Tests/RunCMake/Make/IncludeRegexSubdir-check.cmake
new file mode 100644
index 000000000..dbdf7bea9
--- /dev/null
+++ b/Tests/RunCMake/Make/IncludeRegexSubdir-check.cmake
@@ -0,0 +1,4 @@
+include("${RunCMake_TEST_BINARY_DIR}/IncludeRegexSubdir/CMakeFiles/CMakeDirectoryInformation.cmake" OPTIONAL)
+if(NOT CMAKE_C_INCLUDE_REGEX_SCAN STREQUAL "^custom_include_regex$")
+ set(RunCMake_TEST_FAILED "CMAKE_C_INCLUDE_REGEX_SCAN has unexpected value:\n \"${CMAKE_C_INCLUDE_REGEX_SCAN}\"")
+endif()
diff --git a/Tests/RunCMake/Make/IncludeRegexSubdir.cmake b/Tests/RunCMake/Make/IncludeRegexSubdir.cmake
new file mode 100644
index 000000000..a7a93a090
--- /dev/null
+++ b/Tests/RunCMake/Make/IncludeRegexSubdir.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+include_regular_expression("^custom_include_regex$")
+add_subdirectory(IncludeRegexSubdir)
diff --git a/Tests/RunCMake/Make/IncludeRegexSubdir/CMakeLists.txt b/Tests/RunCMake/Make/IncludeRegexSubdir/CMakeLists.txt
new file mode 100644
index 000000000..e712aea5d
--- /dev/null
+++ b/Tests/RunCMake/Make/IncludeRegexSubdir/CMakeLists.txt
@@ -0,0 +1 @@
+# We only need this directory to be processed. No targets needed.
diff --git a/Tests/RunCMake/Make/RunCMakeTest.cmake b/Tests/RunCMake/Make/RunCMakeTest.cmake
index 869d11e5d..82db6b742 100644
--- a/Tests/RunCMake/Make/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Make/RunCMakeTest.cmake
@@ -16,4 +16,22 @@ run_TargetMessages(OFF)
run_TargetMessages(VAR-ON -DCMAKE_TARGET_MESSAGES=ON)
run_TargetMessages(VAR-OFF -DCMAKE_TARGET_MESSAGES=OFF)
+function(run_VerboseBuild)
+ run_cmake(VerboseBuild)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/VerboseBuild-build)
+ if(RunCMake_GENERATOR STREQUAL "Watcom WMake")
+ # wmake does not actually show the verbose output.
+ set(RunCMake-stdout-file VerboseBuild-build-watcom-stdout.txt)
+ endif()
+ run_cmake_command(VerboseBuild-build ${CMAKE_COMMAND} --build . -v --clean-first)
+ unset(RunCMake-stdout-file)
+ if(MAKE_IS_GNU)
+ set(RunCMake-stdout-file VerboseBuild-nowork-gnu-stdout.txt)
+ endif()
+ run_cmake_command(VerboseBuild-nowork ${CMAKE_COMMAND} --build . --verbose)
+endfunction()
+run_VerboseBuild()
+
run_cmake(CustomCommandDepfile-ERROR)
+run_cmake(IncludeRegexSubdir)
diff --git a/Tests/RunCMake/Make/VerboseBuild-build-stdout.txt b/Tests/RunCMake/Make/VerboseBuild-build-stdout.txt
new file mode 100644
index 000000000..884bf953e
--- /dev/null
+++ b/Tests/RunCMake/Make/VerboseBuild-build-stdout.txt
@@ -0,0 +1 @@
+.*DEFINE_FOR_VERBOSE_DETECTION.*hello.dir.*
diff --git a/Tests/RunCMake/Make/VerboseBuild-build-watcom-stdout.txt b/Tests/RunCMake/Make/VerboseBuild-build-watcom-stdout.txt
new file mode 100644
index 000000000..9c558e357
--- /dev/null
+++ b/Tests/RunCMake/Make/VerboseBuild-build-watcom-stdout.txt
@@ -0,0 +1 @@
+.
diff --git a/Tests/RunCMake/Make/VerboseBuild-nowork-gnu-stdout.txt b/Tests/RunCMake/Make/VerboseBuild-nowork-gnu-stdout.txt
new file mode 100644
index 000000000..3e65cd95f
--- /dev/null
+++ b/Tests/RunCMake/Make/VerboseBuild-nowork-gnu-stdout.txt
@@ -0,0 +1 @@
+.*Nothing to be done for.*hello.*
diff --git a/Tests/RunCMake/Make/VerboseBuild.cmake b/Tests/RunCMake/Make/VerboseBuild.cmake
new file mode 100644
index 000000000..70a971d13
--- /dev/null
+++ b/Tests/RunCMake/Make/VerboseBuild.cmake
@@ -0,0 +1,8 @@
+enable_language(C)
+
+# Make sure compile command is not hidden in a temp file.
+string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}")
+string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}")
+
+add_executable(hello hello.c)
+target_compile_definitions(hello PRIVATE "DEFINE_FOR_VERBOSE_DETECTION")
diff --git a/Tests/RunCMake/Make/hello.c b/Tests/RunCMake/Make/hello.c
new file mode 100644
index 000000000..aac8b4e0f
--- /dev/null
+++ b/Tests/RunCMake/Make/hello.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(void)
+{
+ printf("Hello world!\n");
+ return 0;
+}
diff --git a/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt b/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt
new file mode 100644
index 000000000..d2cd86d13
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.13)
+if(DEFINED CMAKE_GENERATOR)
+ project(${RunCMake_TEST} NONE)
+endif()
+include("${CMAKE_CURRENT_LIST_DIR}/${TEST_NAME}.cmake")
diff --git a/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt.in b/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt.in
new file mode 100644
index 000000000..fee3eda2f
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/CMakeLists.txt.in
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 3.12)
+project(MaxRecursionDepth NONE)
diff --git a/Tests/RunCMake/MaxRecursionDepth/CTestCustom.cmake b/Tests/RunCMake/MaxRecursionDepth/CTestCustom.cmake
new file mode 100644
index 000000000..354bc7a4e
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/CTestCustom.cmake
@@ -0,0 +1,3 @@
+message("${x}")
+math(EXPR x "${x} + 1")
+ctest_read_custom_files("${CMAKE_CURRENT_LIST_DIR}")
diff --git a/Tests/RunCMake/MaxRecursionDepth/FindRecursivePackage.cmake b/Tests/RunCMake/MaxRecursionDepth/FindRecursivePackage.cmake
new file mode 100644
index 000000000..3cbb99e87
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/FindRecursivePackage.cmake
@@ -0,0 +1,3 @@
+message("${x}")
+math(EXPR x "${x} + 1")
+find_package(RecursivePackage)
diff --git a/Tests/RunCMake/MaxRecursionDepth/RunCMakeTest.cmake b/Tests/RunCMake/MaxRecursionDepth/RunCMakeTest.cmake
new file mode 100644
index 000000000..c5a859d87
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/RunCMakeTest.cmake
@@ -0,0 +1,49 @@
+include(RunCMake)
+include(RunCTest)
+
+function(run_cmake_recursive name)
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name})
+ run_cmake(${name}-default)
+ unset(RunCMake_TEST_OPTIONS)
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=10)
+ run_cmake(${name}-var)
+ unset(RunCMake_TEST_OPTIONS)
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=a)
+ run_cmake(${name}-invalid-var)
+ unset(RunCMake_TEST_OPTIONS)
+
+ run_cmake_command(${name}-default-script ${CMAKE_COMMAND} "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -P "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt")
+ run_cmake_command(${name}-var-script ${CMAKE_COMMAND} "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=10 -P "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt")
+ run_cmake_command(${name}-invalid-var-script ${CMAKE_COMMAND} "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=a -P "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt")
+endfunction()
+
+function(run_ctest_recursive name)
+ run_ctest(${name}-default "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name})
+ run_ctest(${name}-var "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=10)
+ run_ctest(${name}-invalid-var "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=${name} -DCMAKE_MAXIMUM_RECURSION_DEPTH=a)
+endfunction()
+
+run_cmake_recursive(function)
+run_cmake_recursive(macro)
+run_cmake_recursive(include)
+run_cmake_recursive(find_package)
+run_cmake_recursive(variable_watch)
+
+# We run these tests separately and only with a small limit because they are
+# taxing and slow. The "implicit" and "invalid" cases are already thoroughly
+# covered by the other tests above.
+set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=add_subdirectory -DCMAKE_MAXIMUM_RECURSION_DEPTH=10)
+run_cmake(add_subdirectory-var)
+unset(RunCMake_TEST_OPTIONS)
+set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=try_compile -DCMAKE_MAXIMUM_RECURSION_DEPTH=10)
+run_cmake(try_compile-var)
+unset(RunCMake_TEST_OPTIONS)
+
+run_ctest_recursive(ctest_read_custom_files)
+
+# We run the ctest_run_script() test separately and only with an explicit limit
+# because ctest_run_script() is taxing and slow, and because the implicit
+# recursion limit is hit by CTestScriptMode.cmake before we can test it
+# properly. The "implicit" and "invalid" cases are already thoroughly covered
+# by the other tests above.
+run_ctest(ctest_run_script-var "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" -DTEST_NAME=ctest_run_script -DCMAKE_MAXIMUM_RECURSION_DEPTH=10)
diff --git a/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-stderr.txt
new file mode 100644
index 000000000..23fb5c65b
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory-var-stderr.txt
@@ -0,0 +1,10 @@
+^3
+4
+5
+6
+7
+8
+9
+10
+CMake Error at add_subdirectory/CMakeLists\.txt:1 \(message\):
+ Maximum recursion depth of 10 exceeded$
diff --git a/Tests/RunCMake/MaxRecursionDepth/add_subdirectory.cmake b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory.cmake
new file mode 100644
index 000000000..36c21f30a
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory.cmake
@@ -0,0 +1,2 @@
+set(x 3)
+add_subdirectory(add_subdirectory)
diff --git a/Tests/RunCMake/MaxRecursionDepth/add_subdirectory/CMakeLists.txt b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory/CMakeLists.txt
new file mode 100644
index 000000000..a8244affe
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/add_subdirectory/CMakeLists.txt
@@ -0,0 +1,3 @@
+message("${x}")
+math(EXPR x "${x} + 1")
+add_subdirectory(. dir)
diff --git a/Tests/RunCMake/ctest_memcheck/DummyMemorySanitizer-result.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_memcheck/DummyMemorySanitizer-result.txt
+++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-result.txt
diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-stderr.txt
new file mode 100644
index 000000000..7dbbb3e72
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-default-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:1 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
diff --git a/Tests/RunCMake/ctest_memcheck/DummyPurifyNoLogFile-result.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_memcheck/DummyPurifyNoLogFile-result.txt
+++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-result.txt
diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-stderr.txt
new file mode 100644
index 000000000..7dbbb3e72
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-invalid-var-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:1 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
diff --git a/Tests/RunCMake/ctest_memcheck/DummyThreadSanitizer-result.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_memcheck/DummyThreadSanitizer-result.txt
+++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-result.txt
diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-stderr.txt
new file mode 100644
index 000000000..bc89703a0
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var-stderr.txt
@@ -0,0 +1,34 @@
+^2
+3
+4
+5
+6
+7
+8
+9
+10
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:1 \(message\):
+ Maximum recursion depth of 10 exceeded
+Call Stack \(most recent call first\):
+ .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
+ .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
+ .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
+ .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
+ .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
+ .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
+ .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
+ .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
+ .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
+ .*/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var/test\.cmake:10 \(ctest_read_custom_files\)
+
+
+Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake
+Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake
+Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake
+Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake
+Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake
+Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake
+Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake
+Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake
+Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake
+Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake$
diff --git a/Tests/RunCMake/ctest_memcheck/DummyUndefinedBehaviorSanitizer-result.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_memcheck/DummyUndefinedBehaviorSanitizer-result.txt
+++ b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-result.txt
diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-stderr.txt
new file mode 100644
index 000000000..b10b26d32
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var-stderr.txt
@@ -0,0 +1,51 @@
+^2
+3
+4
+5
+6
+7
+8
+9
+10
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_11\.cmake:1 \(cmake_minimum_required\):
+ Maximum recursion depth of 10 exceeded
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_10\.cmake:13 \(message\):
+ Nested script failed
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_9\.cmake:13 \(message\):
+ Nested script failed
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_8\.cmake:13 \(message\):
+ Nested script failed
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_7\.cmake:13 \(message\):
+ Nested script failed
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_6\.cmake:13 \(message\):
+ Nested script failed
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_5\.cmake:13 \(message\):
+ Nested script failed
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_4\.cmake:13 \(message\):
+ Nested script failed
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_3\.cmake:13 \(message\):
+ Nested script failed
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_2\.cmake:13 \(message\):
+ Nested script failed
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var/test\.cmake:19 \(message\):
+ Nested script failed$
diff --git a/Tests/RunCMake/MaxRecursionDepth/ctest_run_script.cmake.in b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script.cmake.in
new file mode 100644
index 000000000..d4f28c456
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/ctest_run_script.cmake.in
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.12)
+set(CTEST_RUN_CURRENT_SCRIPT 0)
+
+message("@LEVEL_CURRENT@")
+
+set(CTEST_SOURCE_DIRECTORY "@CTEST_SOURCE_DIRECTORY@")
+set(CTEST_BINARY_DIRECTORY "@CTEST_BINARY_DIRECTORY@")
+set(CTEST_COMMAND "@CTEST_COMMAND@")
+
+ctest_run_script("${CMAKE_CURRENT_LIST_DIR}/ctest_run_script_@LEVEL_NEXT@.cmake" RETURN_VALUE val)
+
+if(NOT val EQUAL 0)
+ message(FATAL_ERROR "Nested script failed")
+endif()
diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-default-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/find_package-default-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-stderr.txt
new file mode 100644
index 000000000..b8557ab64
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/find_package-default-script-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at .*/FindRecursivePackage\.cmake:1 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ .*/FindRecursivePackage\.cmake:3 \(find_package\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-default-stderr.txt
new file mode 100644
index 000000000..5d31e295b
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/find_package-default-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at FindRecursivePackage\.cmake:1 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ FindRecursivePackage\.cmake:3 \(find_package\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-stderr.txt
new file mode 100644
index 000000000..b8557ab64
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-script-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at .*/FindRecursivePackage\.cmake:1 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ .*/FindRecursivePackage\.cmake:3 \(find_package\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-stderr.txt
new file mode 100644
index 000000000..5d31e295b
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/find_package-invalid-var-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at FindRecursivePackage\.cmake:1 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ FindRecursivePackage\.cmake:3 \(find_package\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-var-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/find_package-var-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-stderr.txt
new file mode 100644
index 000000000..53145515a
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/find_package-var-script-stderr.txt
@@ -0,0 +1,21 @@
+^3
+4
+5
+6
+7
+8
+9
+10
+CMake Error at .*/FindRecursivePackage\.cmake:1 \(message\):
+ Maximum recursion depth of 10 exceeded
+Call Stack \(most recent call first\):
+ .*/FindRecursivePackage\.cmake:3 \(find_package\)
+ .*/FindRecursivePackage\.cmake:3 \(find_package\)
+ .*/FindRecursivePackage\.cmake:3 \(find_package\)
+ .*/FindRecursivePackage\.cmake:3 \(find_package\)
+ .*/FindRecursivePackage\.cmake:3 \(find_package\)
+ .*/FindRecursivePackage\.cmake:3 \(find_package\)
+ .*/FindRecursivePackage\.cmake:3 \(find_package\)
+ .*/FindRecursivePackage\.cmake:3 \(find_package\)
+ .*/find_package\.cmake:2 \(find_package\)
+ .*/CMakeLists\.txt:5 \(include\)$
diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/find_package-var-stderr.txt
new file mode 100644
index 000000000..b47a13a17
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/find_package-var-stderr.txt
@@ -0,0 +1,21 @@
+^3
+4
+5
+6
+7
+8
+9
+10
+CMake Error at FindRecursivePackage\.cmake:1 \(message\):
+ Maximum recursion depth of 10 exceeded
+Call Stack \(most recent call first\):
+ FindRecursivePackage\.cmake:3 \(find_package\)
+ FindRecursivePackage\.cmake:3 \(find_package\)
+ FindRecursivePackage\.cmake:3 \(find_package\)
+ FindRecursivePackage\.cmake:3 \(find_package\)
+ FindRecursivePackage\.cmake:3 \(find_package\)
+ FindRecursivePackage\.cmake:3 \(find_package\)
+ FindRecursivePackage\.cmake:3 \(find_package\)
+ FindRecursivePackage\.cmake:3 \(find_package\)
+ find_package\.cmake:2 \(find_package\)
+ CMakeLists\.txt:5 \(include\)$
diff --git a/Tests/RunCMake/MaxRecursionDepth/find_package.cmake b/Tests/RunCMake/MaxRecursionDepth/find_package.cmake
new file mode 100644
index 000000000..a235f7d41
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/find_package.cmake
@@ -0,0 +1,2 @@
+set(x 3)
+find_package(RecursivePackage)
diff --git a/Tests/RunCMake/MaxRecursionDepth/function-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-default-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/function-default-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/function-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-default-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/function-default-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/function-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-default-script-stderr.txt
new file mode 100644
index 000000000..92de1fb3c
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/function-default-script-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at .*/function\.cmake:2 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ .*/function\.cmake:4 \(recursive\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/function-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-default-stderr.txt
new file mode 100644
index 000000000..5c25c4b12
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/function-default-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at function\.cmake:2 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ function\.cmake:4 \(recursive\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-stderr.txt
new file mode 100644
index 000000000..92de1fb3c
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-script-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at .*/function\.cmake:2 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ .*/function\.cmake:4 \(recursive\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-stderr.txt
new file mode 100644
index 000000000..5c25c4b12
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/function-invalid-var-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at function\.cmake:2 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ function\.cmake:4 \(recursive\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/function-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-var-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/function-var-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/function-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/function-var-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/function-var-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/function-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-var-script-stderr.txt
new file mode 100644
index 000000000..61304b13f
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/function-var-script-stderr.txt
@@ -0,0 +1,21 @@
+^3
+4
+5
+6
+7
+8
+9
+10
+CMake Error at .*/function\.cmake:2 \(message\):
+ Maximum recursion depth of 10 exceeded
+Call Stack \(most recent call first\):
+ .*/function\.cmake:4 \(recursive\)
+ .*/function\.cmake:4 \(recursive\)
+ .*/function\.cmake:4 \(recursive\)
+ .*/function\.cmake:4 \(recursive\)
+ .*/function\.cmake:4 \(recursive\)
+ .*/function\.cmake:4 \(recursive\)
+ .*/function\.cmake:4 \(recursive\)
+ .*/function\.cmake:4 \(recursive\)
+ .*/function\.cmake:7 \(recursive\)
+ .*/CMakeLists\.txt:5 \(include\)$
diff --git a/Tests/RunCMake/MaxRecursionDepth/function-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/function-var-stderr.txt
new file mode 100644
index 000000000..54e72aff4
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/function-var-stderr.txt
@@ -0,0 +1,21 @@
+^3
+4
+5
+6
+7
+8
+9
+10
+CMake Error at function\.cmake:2 \(message\):
+ Maximum recursion depth of 10 exceeded
+Call Stack \(most recent call first\):
+ function\.cmake:4 \(recursive\)
+ function\.cmake:4 \(recursive\)
+ function\.cmake:4 \(recursive\)
+ function\.cmake:4 \(recursive\)
+ function\.cmake:4 \(recursive\)
+ function\.cmake:4 \(recursive\)
+ function\.cmake:4 \(recursive\)
+ function\.cmake:4 \(recursive\)
+ function\.cmake:7 \(recursive\)
+ CMakeLists\.txt:5 \(include\)$
diff --git a/Tests/RunCMake/MaxRecursionDepth/function.cmake b/Tests/RunCMake/MaxRecursionDepth/function.cmake
new file mode 100644
index 000000000..581cb8917
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/function.cmake
@@ -0,0 +1,7 @@
+function(recursive x)
+ message("${x}")
+ math(EXPR y "${x} + 1")
+ recursive(${y})
+endfunction()
+
+recursive(3)
diff --git a/Tests/RunCMake/MaxRecursionDepth/include-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-default-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include-default-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/include-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-default-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include-default-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/include-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-default-script-stderr.txt
new file mode 100644
index 000000000..0510e7c37
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include-default-script-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at .*/include_recursive\.cmake:1 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ .*/include_recursive\.cmake:3 \(include\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/include-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-default-stderr.txt
new file mode 100644
index 000000000..b1494a8e1
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include-default-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at include_recursive\.cmake:1 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ include_recursive\.cmake:3 \(include\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-stderr.txt
new file mode 100644
index 000000000..0510e7c37
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-script-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at .*/include_recursive\.cmake:1 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ .*/include_recursive\.cmake:3 \(include\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-stderr.txt
new file mode 100644
index 000000000..b1494a8e1
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include-invalid-var-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at include_recursive\.cmake:1 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ include_recursive\.cmake:3 \(include\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/include-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-var-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include-var-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/include-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/include-var-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include-var-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/include-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-var-script-stderr.txt
new file mode 100644
index 000000000..f55f50536
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include-var-script-stderr.txt
@@ -0,0 +1,21 @@
+^3
+4
+5
+6
+7
+8
+9
+10
+CMake Error at .*/include_recursive\.cmake:1 \(message\):
+ Maximum recursion depth of 10 exceeded
+Call Stack \(most recent call first\):
+ .*/include_recursive\.cmake:3 \(include\)
+ .*/include_recursive\.cmake:3 \(include\)
+ .*/include_recursive\.cmake:3 \(include\)
+ .*/include_recursive\.cmake:3 \(include\)
+ .*/include_recursive\.cmake:3 \(include\)
+ .*/include_recursive\.cmake:3 \(include\)
+ .*/include_recursive\.cmake:3 \(include\)
+ .*/include_recursive\.cmake:3 \(include\)
+ .*/include\.cmake:2 \(include\)
+ .*/CMakeLists\.txt:5 \(include\)$
diff --git a/Tests/RunCMake/MaxRecursionDepth/include-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/include-var-stderr.txt
new file mode 100644
index 000000000..ff3398504
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include-var-stderr.txt
@@ -0,0 +1,21 @@
+^3
+4
+5
+6
+7
+8
+9
+10
+CMake Error at include_recursive\.cmake:1 \(message\):
+ Maximum recursion depth of 10 exceeded
+Call Stack \(most recent call first\):
+ include_recursive\.cmake:3 \(include\)
+ include_recursive\.cmake:3 \(include\)
+ include_recursive\.cmake:3 \(include\)
+ include_recursive\.cmake:3 \(include\)
+ include_recursive\.cmake:3 \(include\)
+ include_recursive\.cmake:3 \(include\)
+ include_recursive\.cmake:3 \(include\)
+ include_recursive\.cmake:3 \(include\)
+ include\.cmake:2 \(include\)
+ CMakeLists\.txt:5 \(include\)$
diff --git a/Tests/RunCMake/MaxRecursionDepth/include.cmake b/Tests/RunCMake/MaxRecursionDepth/include.cmake
new file mode 100644
index 000000000..5e86a40cb
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include.cmake
@@ -0,0 +1,2 @@
+set(x 3)
+include("${CMAKE_CURRENT_LIST_DIR}/include_recursive.cmake")
diff --git a/Tests/RunCMake/MaxRecursionDepth/include_recursive.cmake b/Tests/RunCMake/MaxRecursionDepth/include_recursive.cmake
new file mode 100644
index 000000000..b3f744e38
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/include_recursive.cmake
@@ -0,0 +1,3 @@
+message("${x}")
+math(EXPR x "${x} + 1")
+include("${CMAKE_CURRENT_LIST_FILE}")
diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-default-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/macro-default-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-default-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/macro-default-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-default-script-stderr.txt
new file mode 100644
index 000000000..c67be57d2
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/macro-default-script-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at .*/macro\.cmake:2 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ .*/macro\.cmake:4 \(recursive\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-default-stderr.txt
new file mode 100644
index 000000000..0b271627d
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/macro-default-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at macro\.cmake:2 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ macro\.cmake:4 \(recursive\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-stderr.txt
new file mode 100644
index 000000000..c67be57d2
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-script-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at .*/macro\.cmake:2 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ .*/macro\.cmake:4 \(recursive\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-stderr.txt
new file mode 100644
index 000000000..0b271627d
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/macro-invalid-var-stderr.txt
@@ -0,0 +1,5 @@
+[0-9]+
+CMake Error at macro\.cmake:2 \(message\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ macro\.cmake:4 \(recursive\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-var-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/macro-var-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/macro-var-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/macro-var-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-var-script-stderr.txt
new file mode 100644
index 000000000..142e068a0
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/macro-var-script-stderr.txt
@@ -0,0 +1,21 @@
+^3
+4
+5
+6
+7
+8
+9
+10
+CMake Error at .*/macro\.cmake:2 \(message\):
+ Maximum recursion depth of 10 exceeded
+Call Stack \(most recent call first\):
+ .*/macro\.cmake:4 \(recursive\)
+ .*/macro\.cmake:4 \(recursive\)
+ .*/macro\.cmake:4 \(recursive\)
+ .*/macro\.cmake:4 \(recursive\)
+ .*/macro\.cmake:4 \(recursive\)
+ .*/macro\.cmake:4 \(recursive\)
+ .*/macro\.cmake:4 \(recursive\)
+ .*/macro\.cmake:4 \(recursive\)
+ .*/macro\.cmake:7 \(recursive\)
+ .*/CMakeLists\.txt:5 \(include\)$
diff --git a/Tests/RunCMake/MaxRecursionDepth/macro-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/macro-var-stderr.txt
new file mode 100644
index 000000000..71de55376
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/macro-var-stderr.txt
@@ -0,0 +1,21 @@
+^3
+4
+5
+6
+7
+8
+9
+10
+CMake Error at macro\.cmake:2 \(message\):
+ Maximum recursion depth of 10 exceeded
+Call Stack \(most recent call first\):
+ macro\.cmake:4 \(recursive\)
+ macro\.cmake:4 \(recursive\)
+ macro\.cmake:4 \(recursive\)
+ macro\.cmake:4 \(recursive\)
+ macro\.cmake:4 \(recursive\)
+ macro\.cmake:4 \(recursive\)
+ macro\.cmake:4 \(recursive\)
+ macro\.cmake:4 \(recursive\)
+ macro\.cmake:7 \(recursive\)
+ CMakeLists\.txt:5 \(include\)$
diff --git a/Tests/RunCMake/MaxRecursionDepth/macro.cmake b/Tests/RunCMake/MaxRecursionDepth/macro.cmake
new file mode 100644
index 000000000..a7cbfc2ad
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/macro.cmake
@@ -0,0 +1,7 @@
+macro(recursive x)
+ message("${x}")
+ math(EXPR y "${x} + 1")
+ recursive(${y})
+endmacro()
+
+recursive(3)
diff --git a/Tests/RunCMake/MaxRecursionDepth/test.cmake.in b/Tests/RunCMake/MaxRecursionDepth/test.cmake.in
new file mode 100644
index 000000000..fd1fc10a5
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/test.cmake.in
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 3.12)
+set(CTEST_RUN_CURRENT_SCRIPT 0)
+
+set(CTEST_SOURCE_DIRECTORY "@RunCMake_SOURCE_DIR@")
+set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@")
+set(CTEST_COMMAND "${CMAKE_CTEST_COMMAND}")
+
+if(TEST_NAME STREQUAL "ctest_read_custom_files")
+ set(x 2)
+ ctest_read_custom_files("@RunCMake_SOURCE_DIR@")
+elseif(TEST_NAME STREQUAL "ctest_run_script")
+ foreach(LEVEL_CURRENT RANGE 2 15)
+ math(EXPR LEVEL_NEXT "${LEVEL_CURRENT} + 1")
+ configure_file("@RunCMake_SOURCE_DIR@/ctest_run_script.cmake.in" "@RunCMake_BINARY_DIR@/ctest_run_script_${LEVEL_CURRENT}.cmake" @ONLY)
+ endforeach()
+
+ ctest_run_script("@RunCMake_BINARY_DIR@/ctest_run_script_2.cmake" RETURN_VALUE val)
+ if(NOT val EQUAL 0)
+ message(FATAL_ERROR "Nested script failed")
+ endif()
+endif()
diff --git a/Tests/RunCMake/MaxRecursionDepth/try_compile-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/try_compile-var-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/try_compile-var-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/try_compile-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/try_compile-var-stderr.txt
new file mode 100644
index 000000000..130db346b
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/try_compile-var-stderr.txt
@@ -0,0 +1,48 @@
+^3
+4
+5
+6
+7
+8
+9
+10
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:1 \(cmake_minimum_required\):
+ Maximum recursion depth of 10 exceeded
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\):
+ Failed to configure test project build system\.
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\):
+ Failed to configure test project build system\.
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\):
+ Failed to configure test project build system\.
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\):
+ Failed to configure test project build system\.
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\):
+ Failed to configure test project build system\.
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\):
+ Failed to configure test project build system\.
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\):
+ Failed to configure test project build system\.
+
+
+CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists\.txt:5 \(try_compile\):
+ Failed to configure test project build system\.
+
+
+CMake Error at try_compile\.cmake:1 \(try_compile\):
+ Failed to configure test project build system\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:5 \(include\)$
diff --git a/Tests/RunCMake/MaxRecursionDepth/try_compile.cmake b/Tests/RunCMake/MaxRecursionDepth/try_compile.cmake
new file mode 100644
index 000000000..c40fb0612
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/try_compile.cmake
@@ -0,0 +1,6 @@
+try_compile(result
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${CMAKE_CURRENT_SOURCE_DIR}/try_compile"
+ try_compile
+ CMAKE_FLAGS -Dx:STRING=3
+ )
diff --git a/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists.txt b/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists.txt
new file mode 100644
index 000000000..227109061
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/try_compile/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.12)
+
+message("${x}")
+math(EXPR x "${x} + 1")
+try_compile(result
+ "${CMAKE_CURRENT_BINARY_DIR}/try_compile"
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ try_compile
+ CMAKE_FLAGS -Dx:STRING=${x}
+ )
+
+# We put this last to avoid prematurely triggering the recursion limit
+project(try_compile NONE)
diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt
new file mode 100644
index 000000000..4dddc96c8
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-script-stderr.txt
@@ -0,0 +1,6 @@
+[0-9]+
+CMake Error at .*/variable_watch\.cmake:9999 \(update_x\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ .*/variable_watch\.cmake:5 \(set\)
+ .*/variable_watch\.cmake:9999 \(update_x\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt
new file mode 100644
index 000000000..a8b4756da
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-default-stderr.txt
@@ -0,0 +1,6 @@
+[0-9]+
+CMake Error at variable_watch\.cmake:9999 \(update_x\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ variable_watch\.cmake:5 \(set\)
+ variable_watch\.cmake:9999 \(update_x\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt
new file mode 100644
index 000000000..4dddc96c8
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-script-stderr.txt
@@ -0,0 +1,6 @@
+[0-9]+
+CMake Error at .*/variable_watch\.cmake:9999 \(update_x\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ .*/variable_watch\.cmake:5 \(set\)
+ .*/variable_watch\.cmake:9999 \(update_x\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt
new file mode 100644
index 000000000..a8b4756da
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-invalid-var-stderr.txt
@@ -0,0 +1,6 @@
+[0-9]+
+CMake Error at variable_watch\.cmake:9999 \(update_x\):
+ Maximum recursion depth of [0-9]+ exceeded
+Call Stack \(most recent call first\):
+ variable_watch\.cmake:5 \(set\)
+ variable_watch\.cmake:9999 \(update_x\)
diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-result.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt
new file mode 100644
index 000000000..00b2b3c11
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-script-stderr.txt
@@ -0,0 +1,22 @@
+^4
+6
+8
+10
+CMake Error at .*/variable_watch\.cmake:9999 \(update_x\):
+ Maximum recursion depth of 10 exceeded
+Call Stack \(most recent call first\):
+ .*/variable_watch\.cmake:5 \(set\)
+ .*/variable_watch\.cmake:9999 \(update_x\)
+ .*/variable_watch\.cmake:5 \(set\)
+ .*/variable_watch\.cmake:9999 \(update_x\)
+ .*/variable_watch\.cmake:5 \(set\)
+ .*/variable_watch\.cmake:9999 \(update_x\)
+ .*/variable_watch\.cmake:5 \(set\)
+ .*/variable_watch\.cmake:9999 \(update_x\)
+ .*/variable_watch\.cmake:9 \(set\)
+ .*/CMakeLists\.txt:5 \(include\)
+
+
+CMake Error: Error in cmake code at
+Unknown:0:
+A command failed during the invocation of callback "update_x"\.$
diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt
new file mode 100644
index 000000000..8f27bf1c2
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch-var-stderr.txt
@@ -0,0 +1,22 @@
+^4
+6
+8
+10
+CMake Error at variable_watch\.cmake:9999 \(update_x\):
+ Maximum recursion depth of 10 exceeded
+Call Stack \(most recent call first\):
+ variable_watch\.cmake:5 \(set\)
+ variable_watch\.cmake:9999 \(update_x\)
+ variable_watch\.cmake:5 \(set\)
+ variable_watch\.cmake:9999 \(update_x\)
+ variable_watch\.cmake:5 \(set\)
+ variable_watch\.cmake:9999 \(update_x\)
+ variable_watch\.cmake:5 \(set\)
+ variable_watch\.cmake:9999 \(update_x\)
+ variable_watch\.cmake:9 \(set\)
+ CMakeLists\.txt:5 \(include\)
+
+
+CMake Error: Error in cmake code at
+Unknown:0:
+A command failed during the invocation of callback "update_x"\.$
diff --git a/Tests/RunCMake/MaxRecursionDepth/variable_watch.cmake b/Tests/RunCMake/MaxRecursionDepth/variable_watch.cmake
new file mode 100644
index 000000000..b3c7b8dfe
--- /dev/null
+++ b/Tests/RunCMake/MaxRecursionDepth/variable_watch.cmake
@@ -0,0 +1,9 @@
+function(update_x)
+ message("${x}")
+ math(EXPR y "${x} + 2")
+ variable_watch(x update_x)
+ set(x "${y}")
+endfunction()
+
+variable_watch(x update_x)
+set(x 4)
diff --git a/Tests/RunCMake/MetaCompileFeatures/C.cmake b/Tests/RunCMake/MetaCompileFeatures/C.cmake
new file mode 100644
index 000000000..3bb6181ab
--- /dev/null
+++ b/Tests/RunCMake/MetaCompileFeatures/C.cmake
@@ -0,0 +1,27 @@
+
+enable_language(C)
+
+function(check_language_feature_flags lang level)
+ if(CMAKE_${lang}${level}_STANDARD_COMPILE_OPTION)
+ #this property is an internal implementation detail of CMake
+ get_property(known_features GLOBAL PROPERTY CMAKE_${lang}${level}_KNOWN_FEATURES)
+ list(LENGTH known_features len)
+ if(len LESS 1)
+ message(FATAL_ERROR "unable to find known features of ${lang}${level}")
+ endif()
+
+ string(TOLOWER ${lang} lang_lower)
+ set(known_name ${lang_lower}${level}_known_features)
+ set(meta_name ${lang_lower}${level}_meta_feature)
+
+ add_library(${known_name} STATIC a.c)
+ target_compile_features(${known_name} PUBLIC ${known_features})
+ add_library(${meta_name} STATIC a.c)
+ target_compile_features(${meta_name} PUBLIC ${lang_lower}_std_${level})
+ endif()
+endfunction()
+
+
+check_language_feature_flags(C 90)
+check_language_feature_flags(C 99)
+check_language_feature_flags(C 11)
diff --git a/Tests/RunCMake/MetaCompileFeatures/CMakeLists.txt b/Tests/RunCMake/MetaCompileFeatures/CMakeLists.txt
new file mode 100644
index 000000000..3e470a29c
--- /dev/null
+++ b/Tests/RunCMake/MetaCompileFeatures/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.14)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/MetaCompileFeatures/CXX.cmake b/Tests/RunCMake/MetaCompileFeatures/CXX.cmake
new file mode 100644
index 000000000..ef3b9d4be
--- /dev/null
+++ b/Tests/RunCMake/MetaCompileFeatures/CXX.cmake
@@ -0,0 +1,27 @@
+
+enable_language(CXX)
+
+function(check_language_feature_flags lang level)
+ if(CMAKE_${lang}${level}_STANDARD_COMPILE_OPTION)
+ #this property is an internal implementation detail of CMake
+ get_property(known_features GLOBAL PROPERTY CMAKE_${lang}${level}_KNOWN_FEATURES)
+ list(LENGTH known_features len)
+ if(len LESS 1)
+ message(FATAL_ERROR "unable to find known features of ${lang}${level}")
+ endif()
+
+ string(TOLOWER ${lang} lang_lower)
+ set(known_name ${lang_lower}${level}_known_features)
+ set(meta_name ${lang_lower}${level}_meta_feature)
+
+ add_library(${known_name} STATIC a.cxx)
+ target_compile_features(${known_name} PUBLIC ${known_features})
+ add_library(${meta_name} STATIC a.cxx)
+ target_compile_features(${meta_name} PUBLIC ${lang_lower}_std_${level})
+ endif()
+endfunction()
+
+
+check_language_feature_flags(CXX 98)
+check_language_feature_flags(CXX 11)
+check_language_feature_flags(CXX 14)
diff --git a/Tests/RunCMake/MetaCompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/MetaCompileFeatures/RunCMakeTest.cmake
new file mode 100644
index 000000000..009cde4f1
--- /dev/null
+++ b/Tests/RunCMake/MetaCompileFeatures/RunCMakeTest.cmake
@@ -0,0 +1,4 @@
+include(RunCMake)
+
+run_cmake(C)
+run_cmake(CXX)
diff --git a/Tests/RunCMake/MetaCompileFeatures/a.c b/Tests/RunCMake/MetaCompileFeatures/a.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/MetaCompileFeatures/a.c
diff --git a/Tests/RunCMake/MetaCompileFeatures/a.cxx b/Tests/RunCMake/MetaCompileFeatures/a.cxx
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/MetaCompileFeatures/a.cxx
diff --git a/Tests/RunCMake/MultiLint/C-Build-stdout.txt b/Tests/RunCMake/MultiLint/C-Build-stdout.txt
new file mode 100644
index 000000000..d10427ea6
--- /dev/null
+++ b/Tests/RunCMake/MultiLint/C-Build-stdout.txt
@@ -0,0 +1,8 @@
+Warning: include-what-you-use reported diagnostics:
+should add these lines:
+*
+#include <\.\.\.>
++
+.*Tests[/\]RunCMake[/\]MultiLint[/\]main\.c:0:0: warning: message \[checker\].*
+Total errors found: 0
+.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.*
diff --git a/Tests/RunCMake/MultiLint/C-launch-Build-stdout.txt b/Tests/RunCMake/MultiLint/C-launch-Build-stdout.txt
new file mode 100644
index 000000000..d10427ea6
--- /dev/null
+++ b/Tests/RunCMake/MultiLint/C-launch-Build-stdout.txt
@@ -0,0 +1,8 @@
+Warning: include-what-you-use reported diagnostics:
+should add these lines:
+*
+#include <\.\.\.>
++
+.*Tests[/\]RunCMake[/\]MultiLint[/\]main\.c:0:0: warning: message \[checker\].*
+Total errors found: 0
+.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.*
diff --git a/Tests/RunCMake/MultiLint/C-launch.cmake b/Tests/RunCMake/MultiLint/C-launch.cmake
new file mode 100644
index 000000000..e66ca203e
--- /dev/null
+++ b/Tests/RunCMake/MultiLint/C-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(C.cmake)
diff --git a/Tests/RunCMake/MultiLint/C.cmake b/Tests/RunCMake/MultiLint/C.cmake
new file mode 100644
index 000000000..495d6f042
--- /dev/null
+++ b/Tests/RunCMake/MultiLint/C.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+set(CMAKE_C_INCLUDE_WHAT_YOU_USE "${PSEUDO_IWYU}" -some -args)
+set(CMAKE_C_CLANG_TIDY "${PSEUDO_TIDY}" -some -args)
+set(CMAKE_C_CPPLINT "${PSEUDO_CPPLINT}" --verbose=0 --linelength=80)
+set(CMAKE_C_CPPCHECK "${PSEUDO_CPPCHECK}")
+add_executable(main main.c)
diff --git a/Tests/RunCMake/MultiLint/CMakeLists.txt b/Tests/RunCMake/MultiLint/CMakeLists.txt
new file mode 100644
index 000000000..bf2ef1506
--- /dev/null
+++ b/Tests/RunCMake/MultiLint/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.10)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/MultiLint/CXX-Build-stdout.txt b/Tests/RunCMake/MultiLint/CXX-Build-stdout.txt
new file mode 100644
index 000000000..aaf5fd738
--- /dev/null
+++ b/Tests/RunCMake/MultiLint/CXX-Build-stdout.txt
@@ -0,0 +1,8 @@
+Warning: include-what-you-use reported diagnostics:
+should add these lines:
+*
+#include <\.\.\.>
++
+.*Tests[/\]RunCMake[/\]MultiLint[/\]main\.cxx:0:0: warning: message \[checker\].*
+Total errors found: 0
+.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.*
diff --git a/Tests/RunCMake/MultiLint/CXX-launch-Build-stdout.txt b/Tests/RunCMake/MultiLint/CXX-launch-Build-stdout.txt
new file mode 100644
index 000000000..aaf5fd738
--- /dev/null
+++ b/Tests/RunCMake/MultiLint/CXX-launch-Build-stdout.txt
@@ -0,0 +1,8 @@
+Warning: include-what-you-use reported diagnostics:
+should add these lines:
+*
+#include <\.\.\.>
++
+.*Tests[/\]RunCMake[/\]MultiLint[/\]main\.cxx:0:0: warning: message \[checker\].*
+Total errors found: 0
+.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.*
diff --git a/Tests/RunCMake/MultiLint/CXX-launch.cmake b/Tests/RunCMake/MultiLint/CXX-launch.cmake
new file mode 100644
index 000000000..3002c9d68
--- /dev/null
+++ b/Tests/RunCMake/MultiLint/CXX-launch.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS 1)
+include(CTestUseLaunchers)
+include(CXX.cmake)
diff --git a/Tests/RunCMake/MultiLint/CXX.cmake b/Tests/RunCMake/MultiLint/CXX.cmake
new file mode 100644
index 000000000..dc30146a6
--- /dev/null
+++ b/Tests/RunCMake/MultiLint/CXX.cmake
@@ -0,0 +1,6 @@
+enable_language(CXX)
+set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${PSEUDO_IWYU}" -some -args)
+set(CMAKE_CXX_CLANG_TIDY "${PSEUDO_TIDY}" -some -args)
+set(CMAKE_CXX_CPPLINT "${PSEUDO_CPPLINT}" --verbose=0 --linelength=80)
+set(CMAKE_CXX_CPPCHECK "${PSEUDO_CPPCHECK}")
+add_executable(main main.cxx)
diff --git a/Tests/RunCMake/MultiLint/RunCMakeTest.cmake b/Tests/RunCMake/MultiLint/RunCMakeTest.cmake
new file mode 100644
index 000000000..afd98fd08
--- /dev/null
+++ b/Tests/RunCMake/MultiLint/RunCMakeTest.cmake
@@ -0,0 +1,27 @@
+include(RunCMake)
+
+set(RunCMake_TEST_OPTIONS
+ "-DPSEUDO_CPPCHECK=${PSEUDO_CPPCHECK}"
+ "-DPSEUDO_CPPLINT=${PSEUDO_CPPLINT}"
+ "-DPSEUDO_IWYU=${PSEUDO_IWYU}"
+ "-DPSEUDO_TIDY=${PSEUDO_TIDY}"
+ )
+
+function(run_multilint lang)
+ # Use a single build tree for tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${lang}-build")
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake(${lang})
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
+ run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build .)
+endfunction()
+
+run_multilint(C)
+run_multilint(CXX)
+
+if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
+ run_multilint(C-launch)
+ run_multilint(CXX-launch)
+endif()
diff --git a/Tests/RunCMake/MultiLint/main.c b/Tests/RunCMake/MultiLint/main.c
new file mode 100644
index 000000000..8488f4e58
--- /dev/null
+++ b/Tests/RunCMake/MultiLint/main.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/MultiLint/main.cxx b/Tests/RunCMake/MultiLint/main.cxx
new file mode 100644
index 000000000..f8b643afb
--- /dev/null
+++ b/Tests/RunCMake/MultiLint/main.cxx
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt b/Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt
new file mode 100644
index 000000000..9a606ee60
--- /dev/null
+++ b/Tests/RunCMake/Ninja/CMP0058-OLD-by-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0058-OLD-by.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0058 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt b/Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt
new file mode 100644
index 000000000..ba6e5da4e
--- /dev/null
+++ b/Tests/RunCMake/Ninja/CMP0058-OLD-no-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0058-OLD-no.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0058 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/Ninja/CustomCommandJobPool-check.cmake b/Tests/RunCMake/Ninja/CustomCommandJobPool-check.cmake
new file mode 100644
index 000000000..7f7fa33bf
--- /dev/null
+++ b/Tests/RunCMake/Ninja/CustomCommandJobPool-check.cmake
@@ -0,0 +1,8 @@
+set(log "${RunCMake_BINARY_DIR}/CustomCommandJobPool-build/build.ninja")
+file(READ "${log}" build_file)
+if(NOT "${build_file}" MATCHES "pool = custom_command_pool")
+ set(RunCMake_TEST_FAILED "Log file:\n ${log}\ndoes not have expected line: pool = custom_command_pool")
+endif()
+if(NOT "${build_file}" MATCHES "pool = custom_target_pool")
+ set(RunCMake_TEST_FAILED "Log file:\n ${log}\ndoes not have expected line: pool = custom_target_pool")
+endif()
diff --git a/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake b/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake
new file mode 100644
index 000000000..1e36e65e2
--- /dev/null
+++ b/Tests/RunCMake/Ninja/CustomCommandJobPool.cmake
@@ -0,0 +1,17 @@
+add_custom_command(
+ OUTPUT hello.copy.c
+ COMMAND "${CMAKE_COMMAND}" -E copy
+ "${CMAKE_CURRENT_SOURCE_DIR}/hello.c"
+ hello.copy.c
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+ JOB_POOL "custom_command_pool"
+ )
+add_custom_target(copy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/hello.copy.c")
+
+add_custom_target(
+ hello.echo
+ COMMAND echo
+ JOB_POOL "custom_target_pool"
+)
+
+include(CheckNoPrefixSubDir.cmake)
diff --git a/Tests/RunCMake/Ninja/JobPoolUsesTerminal-result.txt b/Tests/RunCMake/Ninja/JobPoolUsesTerminal-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/Ninja/JobPoolUsesTerminal-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Ninja/JobPoolUsesTerminal-stderr.txt b/Tests/RunCMake/Ninja/JobPoolUsesTerminal-stderr.txt
new file mode 100644
index 000000000..45975caeb
--- /dev/null
+++ b/Tests/RunCMake/Ninja/JobPoolUsesTerminal-stderr.txt
@@ -0,0 +1,9 @@
+^CMake Error at JobPoolUsesTerminal.cmake:1 \(add_custom_command\):
+ add_custom_command JOB_POOL is shadowed by USES_TERMINAL.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Error at JobPoolUsesTerminal.cmake:2 \(add_custom_target\):
+ add_custom_target JOB_POOL is shadowed by USES_TERMINAL.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Ninja/JobPoolUsesTerminal.cmake b/Tests/RunCMake/Ninja/JobPoolUsesTerminal.cmake
new file mode 100644
index 000000000..b7e440c60
--- /dev/null
+++ b/Tests/RunCMake/Ninja/JobPoolUsesTerminal.cmake
@@ -0,0 +1,2 @@
+add_custom_command(OUTPUT x COMMAND y USES_TERMINAL JOB_POOL z)
+add_custom_target(CustomTarget COMMAND y USES_TERMINAL JOB_POOL z)
diff --git a/Tests/RunCMake/Ninja/NoWorkToDo-nowork-stdout.txt b/Tests/RunCMake/Ninja/NoWorkToDo-nowork-stdout.txt
new file mode 100644
index 000000000..60a9228b0
--- /dev/null
+++ b/Tests/RunCMake/Ninja/NoWorkToDo-nowork-stdout.txt
@@ -0,0 +1 @@
+^ninja: no work to do
diff --git a/Tests/RunCMake/Ninja/NoWorkToDo.cmake b/Tests/RunCMake/Ninja/NoWorkToDo.cmake
new file mode 100644
index 000000000..a2fa0cb39
--- /dev/null
+++ b/Tests/RunCMake/Ninja/NoWorkToDo.cmake
@@ -0,0 +1,2 @@
+enable_language(C)
+add_executable(hello hello.c)
diff --git a/Tests/RunCMake/Ninja/PreventConfigureFileDupBuildRule.cmake b/Tests/RunCMake/Ninja/PreventConfigureFileDupBuildRule.cmake
new file mode 100644
index 000000000..505f75094
--- /dev/null
+++ b/Tests/RunCMake/Ninja/PreventConfigureFileDupBuildRule.cmake
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.12)
+project(Test LANGUAGES C)
+
+configure_file(PreventConfigureFileDupBuildRule.cmake PreventTargetAliasesDupBuildRule.cmake @ONLY)
+add_subdirectory(SubDirConfigureFileDup)
diff --git a/Tests/RunCMake/Ninja/PreventTargetAliasesDupBuildRule.cmake b/Tests/RunCMake/Ninja/PreventTargetAliasesDupBuildRule.cmake
new file mode 100644
index 000000000..da6f86a73
--- /dev/null
+++ b/Tests/RunCMake/Ninja/PreventTargetAliasesDupBuildRule.cmake
@@ -0,0 +1,41 @@
+cmake_minimum_required(VERSION 3.12)
+project(Test LANGUAGES C)
+
+# fake launcher executable
+set(input_launcher_executable ${CMAKE_CURRENT_BINARY_DIR}/fake_launcher_executable)
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/fake_launcher_executable "")
+
+# application and executable name
+set(application_target "HelloApp")
+set(application_name "Hello")
+set(executable_name "Hello")
+
+# target built in "<root>/bin"
+add_executable(${application_target} hello.c)
+set_target_properties(${application_target} PROPERTIES
+ OUTPUT_NAME ${executable_name}
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin
+ )
+
+# configured launcher in "<root>"
+set(configured_launcher_executable "${CMAKE_CURRENT_BINARY_DIR}/${application_name}")
+
+# create command to copy the launcher
+add_custom_command(
+ DEPENDS
+ ${input_launcher_executable}
+ OUTPUT
+ ${configured_launcher_executable}
+ COMMAND
+ ${CMAKE_COMMAND} -E copy ${input_launcher_executable} ${configured_launcher_executable}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ COMMENT
+ "Configuring application launcher: ${application_name}"
+ )
+
+add_custom_target(Configure${application_name}Launcher ALL
+ DEPENDS
+ ${application_target}
+ ${input_launcher_executable}
+ ${configured_launcher_executable}
+ )
diff --git a/Tests/RunCMake/Ninja/RspFileC.cmake b/Tests/RunCMake/Ninja/RspFileC.cmake
new file mode 100644
index 000000000..4a4068237
--- /dev/null
+++ b/Tests/RunCMake/Ninja/RspFileC.cmake
@@ -0,0 +1,2 @@
+set(ENV{CMAKE_NINJA_FORCE_RESPONSE_FILE} 1)
+enable_language(C)
diff --git a/Tests/RunCMake/Ninja/RspFileCXX.cmake b/Tests/RunCMake/Ninja/RspFileCXX.cmake
new file mode 100644
index 000000000..9e61ffeff
--- /dev/null
+++ b/Tests/RunCMake/Ninja/RspFileCXX.cmake
@@ -0,0 +1,2 @@
+set(ENV{CMAKE_NINJA_FORCE_RESPONSE_FILE} 1)
+enable_language(CXX)
diff --git a/Tests/RunCMake/Ninja/RspFileFortran.cmake b/Tests/RunCMake/Ninja/RspFileFortran.cmake
new file mode 100644
index 000000000..8c18e3768
--- /dev/null
+++ b/Tests/RunCMake/Ninja/RspFileFortran.cmake
@@ -0,0 +1,2 @@
+set(ENV{CMAKE_NINJA_FORCE_RESPONSE_FILE} 1)
+enable_language(Fortran)
diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
index b3720fb7a..808a872aa 100644
--- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
@@ -21,6 +21,24 @@ function(run_NinjaToolMissing)
endfunction()
run_NinjaToolMissing()
+function(run_NoWorkToDo)
+ run_cmake(NoWorkToDo)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/NoWorkToDo-build)
+ run_cmake_command(NoWorkToDo-build ${CMAKE_COMMAND} --build .)
+ run_cmake_command(NoWorkToDo-nowork ${CMAKE_COMMAND} --build . -- -d explain)
+endfunction()
+run_NoWorkToDo()
+
+function(run_VerboseBuild)
+ run_cmake(VerboseBuild)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/VerboseBuild-build)
+ run_cmake_command(VerboseBuild-build ${CMAKE_COMMAND} --build . -v --clean-first)
+ run_cmake_command(VerboseBuild-nowork ${CMAKE_COMMAND} --build . --verbose)
+endfunction()
+run_VerboseBuild()
+
function(run_CMP0058 case)
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0058-${case}-build)
@@ -39,6 +57,14 @@ run_CMP0058(NEW-no)
run_CMP0058(NEW-by)
run_cmake(CustomCommandDepfile)
+run_cmake(CustomCommandJobPool)
+run_cmake(JobPoolUsesTerminal)
+
+run_cmake(RspFileC)
+run_cmake(RspFileCXX)
+if(TEST_Fortran)
+ run_cmake(RspFileFortran)
+endif()
function(run_CommandConcat)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CommandConcat-build)
@@ -190,15 +216,16 @@ function(run_sub_cmake test ninja_output_path_prefix)
set(cmd_prefix "")
set(cmd_suffix "")
endif()
+ set(fs_delay 3) # We assume the system as 1 sec timestamp resolution.
file(WRITE "${top_build_ninja}" "\
subninja ${escaped_ninja_output_path_prefix}/build.ninja
default ${escaped_ninja_output_path_prefix}/all
-# Sleep for 1 second before to regenerate to make sure the timestamp of
+# Sleep for long enough before regenerating to make sure the timestamp of
# the top build.ninja will be strictly greater than the timestamp of the
-# sub/build.ninja file. We assume the system as 1 sec timestamp resolution.
+# sub/build.ninja file.
rule RERUN
- command = ${cmd_prefix}\"${escaped_CMAKE_COMMAND}\" -E sleep 1 && \"${escaped_CMAKE_COMMAND}\" -E touch \"${escaped_top_build_ninja}\"${cmd_suffix}
+ command = ${cmd_prefix}\"${escaped_CMAKE_COMMAND}\" -E sleep ${fs_delay} && \"${escaped_CMAKE_COMMAND}\" -E touch \"${escaped_top_build_ninja}\"${cmd_suffix}
description = Testing regeneration
generator = 1
@@ -224,7 +251,7 @@ build build.ninja: RERUN ${escaped_build_ninja_dep} || ${escaped_ninja_output_pa
# Test regeneration rules run in order.
set(main_cmakelists "${RunCMake_SOURCE_DIR}/CMakeLists.txt")
- sleep(1) # Assume the system as 1 sec timestamp resolution.
+ sleep(${fs_delay})
touch("${main_cmakelists}")
touch("${build_ninja_dep}")
run_ninja("${top_build_dir}")
@@ -263,3 +290,17 @@ foreach(ninja_output_path_prefix "sub space" "sub")
run_sub_cmake(SubDirPrefix "${ninja_output_path_prefix}")
run_sub_cmake(CustomCommandWorkingDirectory "${ninja_output_path_prefix}")
endforeach(ninja_output_path_prefix)
+
+function (run_PreventTargetAliasesDupBuildRule)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/PreventTargetAliasesDupBuildRule-build)
+ run_cmake(PreventTargetAliasesDupBuildRule)
+ run_ninja("${RunCMake_TEST_BINARY_DIR}" -w dupbuild=err)
+endfunction ()
+run_PreventTargetAliasesDupBuildRule()
+
+function (run_PreventConfigureFileDupBuildRule)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/PreventConfigureFileDupBuildRule-build)
+ run_cmake(PreventConfigureFileDupBuildRule)
+ run_ninja("${RunCMake_TEST_BINARY_DIR}" -w dupbuild=err)
+endfunction()
+run_PreventConfigureFileDupBuildRule()
diff --git a/Tests/RunCMake/Ninja/SubDirConfigureFileDup/CMakeLists.txt b/Tests/RunCMake/Ninja/SubDirConfigureFileDup/CMakeLists.txt
new file mode 100644
index 000000000..433f77bf3
--- /dev/null
+++ b/Tests/RunCMake/Ninja/SubDirConfigureFileDup/CMakeLists.txt
@@ -0,0 +1 @@
+configure_file(../PreventConfigureFileDupBuildRule.cmake PreventTargetAliasesDupBuildRule.cmake @ONLY)
diff --git a/Tests/RunCMake/Ninja/VerboseBuild-build-stdout.txt b/Tests/RunCMake/Ninja/VerboseBuild-build-stdout.txt
new file mode 100644
index 000000000..884bf953e
--- /dev/null
+++ b/Tests/RunCMake/Ninja/VerboseBuild-build-stdout.txt
@@ -0,0 +1 @@
+.*DEFINE_FOR_VERBOSE_DETECTION.*hello.dir.*
diff --git a/Tests/RunCMake/Ninja/VerboseBuild-nowork-stdout.txt b/Tests/RunCMake/Ninja/VerboseBuild-nowork-stdout.txt
new file mode 100644
index 000000000..60a9228b0
--- /dev/null
+++ b/Tests/RunCMake/Ninja/VerboseBuild-nowork-stdout.txt
@@ -0,0 +1 @@
+^ninja: no work to do
diff --git a/Tests/RunCMake/Ninja/VerboseBuild.cmake b/Tests/RunCMake/Ninja/VerboseBuild.cmake
new file mode 100644
index 000000000..424e54eec
--- /dev/null
+++ b/Tests/RunCMake/Ninja/VerboseBuild.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+add_executable(hello hello.c)
+target_compile_definitions(hello PRIVATE "DEFINE_FOR_VERBOSE_DETECTION")
diff --git a/Tests/RunCMake/Ninja/greeting.c b/Tests/RunCMake/Ninja/greeting.c
index ba3e55beb..1124d14c0 100644
--- a/Tests/RunCMake/Ninja/greeting.c
+++ b/Tests/RunCMake/Ninja/greeting.c
@@ -6,4 +6,5 @@ __declspec(dllexport)
void greeting(void)
{
printf("Hello world!\n");
+ fflush(stdout);
}
diff --git a/Tests/RunCMake/Ninja/greeting2.c b/Tests/RunCMake/Ninja/greeting2.c
index c6ed87daa..cc8409c11 100644
--- a/Tests/RunCMake/Ninja/greeting2.c
+++ b/Tests/RunCMake/Ninja/greeting2.c
@@ -3,4 +3,5 @@
void greeting2(void)
{
printf("Hello world 2!\n");
+ fflush(stdout);
}
diff --git a/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt
deleted file mode 100644
index b91ffd068..000000000
--- a/Tests/RunCMake/ObjectLibrary/BadObjSource2-stderr.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-CMake Error at BadObjSource2.cmake:1 \(add_library\):
- OBJECT library "A" contains:
-
- bad.obj
-
- but may contain only sources that compile, header files, and other files
- that would not affect linking of a normal library.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
index 838b3d8c4..4dbd86144 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
@@ -3,6 +3,7 @@ CMake Error at BadSourceExpression3.cmake:2 \(add_library\):
\$<TARGET_OBJECTS:NotObjLib>
- Objects of target "NotObjLib" referenced but is not an OBJECT library.
+ Objects of target "NotObjLib" referenced but is not an allowed library
+ types \(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT\).
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake
index c3d9a622d..4e07ea6fa 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3.cmake
@@ -1,2 +1,2 @@
-add_library(NotObjLib STATIC a.c)
+add_library(NotObjLib INTERFACE)
add_library(A STATIC a.c $<TARGET_OBJECTS:NotObjLib>)
diff --git a/Tests/RunCMake/ObjectLibrary/CMakeLists.txt b/Tests/RunCMake/ObjectLibrary/CMakeLists.txt
index a17c8cd13..d1b0d2c3e 100644
--- a/Tests/RunCMake/ObjectLibrary/CMakeLists.txt
+++ b/Tests/RunCMake/ObjectLibrary/CMakeLists.txt
@@ -1,3 +1,3 @@
-cmake_minimum_required(VERSION 2.8.4)
+cmake_minimum_required(VERSION 3.10)
project(${RunCMake_TEST} C)
include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ObjectLibrary/CheckTargetObjects.cmake b/Tests/RunCMake/ObjectLibrary/CheckTargetObjects.cmake
new file mode 100644
index 000000000..0c85c72b0
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/CheckTargetObjects.cmake
@@ -0,0 +1,32 @@
+add_library(StaticLib STATIC a.c)
+
+add_custom_command(TARGET StaticLib POST_BUILD
+ VERBATIM
+ COMMAND ${CMAKE_COMMAND}
+ "-DTARGET_OBJECTS=$<TARGET_OBJECTS:StaticLib>"
+ -DEXPECTED_NUM_OBJECTFILES=2
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
+ )
+
+add_library(SharedLib SHARED a.c b.c)
+target_compile_definitions(SharedLib PRIVATE REQUIRED)
+
+add_custom_command(TARGET SharedLib POST_BUILD
+ VERBATIM
+ COMMAND ${CMAKE_COMMAND}
+ "-DTARGET_OBJECTS:STRING=$<TARGET_OBJECTS:SharedLib>"
+ -DEXPECTED_NUM_OBJECTFILES=2
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
+ )
+
+add_executable(ExecObjs a.c b.c exe.c)
+target_compile_definitions(ExecObjs PRIVATE REQUIRED)
+
+add_custom_target(check_exec_objs ALL
+ VERBATIM
+ COMMAND ${CMAKE_COMMAND}
+ "-DTARGET_OBJECTS=$<TARGET_OBJECTS:ExecObjs>"
+ -DEXPECTED_NUM_OBJECTFILES=3
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check_object_files.cmake"
+ DEPENDS ExecObjs
+ )
diff --git a/Tests/RunCMake/ObjectLibrary/ExportNotSupported-stderr.txt b/Tests/RunCMake/ObjectLibrary/ExportNotSupported-stderr.txt
deleted file mode 100644
index 542015984..000000000
--- a/Tests/RunCMake/ObjectLibrary/ExportNotSupported-stderr.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-CMake Error at ExportNotSupported.cmake:[0-9]+ \(export\):
- export given OBJECT library "A" which may not be exported under Xcode with
- multiple architectures.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/ExportNotSupported.cmake b/Tests/RunCMake/ObjectLibrary/ExportNotSupported.cmake
deleted file mode 100644
index a3f104e29..000000000
--- a/Tests/RunCMake/ObjectLibrary/ExportNotSupported.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-add_library(A OBJECT a.c)
-export(TARGETS A FILE AExport.cmake)
diff --git a/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1-result.txt b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1-stderr.txt b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1-stderr.txt
new file mode 100644
index 000000000..c6637070e
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1-stderr.txt
@@ -0,0 +1 @@
+CMake Error: install\(EXPORT "exp" ...\) includes target "UseA" which requires target "A" that is not in any export set.
diff --git a/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1.cmake b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1.cmake
new file mode 100644
index 000000000..9e2460987
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj1.cmake
@@ -0,0 +1,6 @@
+add_library(A OBJECT a.c)
+add_library(UseA STATIC)
+target_link_libraries(UseA PUBLIC A)
+
+install(TARGETS UseA EXPORT exp ARCHIVE DESTINATION lib)
+install(EXPORT exp DESTINATION lib/cmake/exp)
diff --git a/Tests/RunCMake/ObjectLibrary/InstallLinkedObj2.cmake b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj2.cmake
new file mode 100644
index 000000000..cdda96239
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/InstallLinkedObj2.cmake
@@ -0,0 +1,6 @@
+add_library(A OBJECT a.c)
+add_library(UseA STATIC)
+target_link_libraries(UseA PUBLIC A)
+
+install(TARGETS UseA A EXPORT exp ARCHIVE DESTINATION lib)
+install(EXPORT exp DESTINATION lib/cmake/exp)
diff --git a/Tests/RunCMake/ObjectLibrary/InstallNotSupported-stderr.txt b/Tests/RunCMake/ObjectLibrary/InstallNotSupported-stderr.txt
index 35a0e4fdf..a7004c14e 100644
--- a/Tests/RunCMake/ObjectLibrary/InstallNotSupported-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/InstallNotSupported-stderr.txt
@@ -1,5 +1,5 @@
CMake Error at InstallNotSupported.cmake:[0-9]+ \(install\):
- install TARGETS given OBJECT library "A" which may not be installed under
- Xcode with multiple architectures.
+ install TARGETS given OBJECT library "A" whose objects may not be installed
+ under Xcode with multiple architectures.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt b/Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt
deleted file mode 100644
index 90e828bdb..000000000
--- a/Tests/RunCMake/ObjectLibrary/LinkObjLHS-stderr.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-CMake Error at LinkObjLHS.cmake:2 \(target_link_libraries\):
- Object library target "AnObjLib" may not link to anything.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake
deleted file mode 100644
index 5d7831a23..000000000
--- a/Tests/RunCMake/ObjectLibrary/LinkObjLHS.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-add_library(AnObjLib OBJECT a.c)
-target_link_libraries(AnObjLib OtherLib)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.c b/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.c
new file mode 100644
index 000000000..088da30b1
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.c
@@ -0,0 +1,17 @@
+#ifndef REQUIRED
+# error "REQUIRED not defined"
+#endif
+
+#if defined(_WIN32)
+# define IMPORT __declspec(dllimport)
+#else
+# define IMPORT
+#endif
+
+IMPORT int a(void);
+extern int required(void);
+
+int main(void)
+{
+ return required() + a();
+}
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake
new file mode 100644
index 000000000..0a76932ec
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/LinkObjLHSShared.cmake
@@ -0,0 +1,15 @@
+project(LinkObjLHSShared C)
+
+# Create a versioned shared library that does not build as part of "all".
+add_library(OtherLib SHARED a.c)
+target_compile_definitions(OtherLib INTERFACE REQUIRED PRIVATE COMPILE_FOR_SHARED_LIB)
+set_target_properties(OtherLib PROPERTIES SOVERSION 0 VERSION 0.0.0 EXCLUDE_FROM_ALL ON)
+
+add_library(AnObjLib OBJECT requires.c)
+target_link_libraries(AnObjLib PUBLIC OtherLib)
+
+add_executable(LinkObjLHSShared LinkObjLHSShared.c)
+target_link_libraries(LinkObjLHSShared AnObjLib)
+
+# Verify that our dependency on OtherLib generated its versioning symlinks.
+add_custom_command(TARGET LinkObjLHSShared POST_BUILD COMMAND LinkObjLHSShared)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjLHSStatic.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjLHSStatic.cmake
new file mode 100644
index 000000000..261bee781
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/LinkObjLHSStatic.cmake
@@ -0,0 +1,7 @@
+project(LinkObjLHSStatic C)
+
+add_library(OtherLib STATIC a.c)
+target_compile_definitions(OtherLib INTERFACE REQUIRED)
+
+add_library(AnObjLib OBJECT requires.c)
+target_link_libraries(AnObjLib OtherLib)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt
deleted file mode 100644
index 8809f8933..000000000
--- a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-CMake Error at LinkObjRHS1.cmake:3 \(target_link_libraries\):
- Target "AnObjLib" of type OBJECT_LIBRARY may not be linked into another
- target. One may link only to STATIC or SHARED libraries, or to executables
- with the ENABLE_EXPORTS property set.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake
deleted file mode 100644
index 113d6a841..000000000
--- a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1.cmake
+++ /dev/null
@@ -1,3 +0,0 @@
-add_library(A STATIC a.c)
-add_library(AnObjLib OBJECT a.c)
-target_link_libraries(A AnObjLib)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt
deleted file mode 100644
index 3295fcac3..000000000
--- a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2-stderr.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-CMake Error at LinkObjRHS2.cmake:1 \(add_library\):
- Target "A" links to OBJECT library "AnObjLib" but this is not allowed. One
- may link only to STATIC or SHARED libraries, or to executables with the
- ENABLE_EXPORTS property set.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake
deleted file mode 100644
index 616372949..000000000
--- a/Tests/RunCMake/ObjectLibrary/LinkObjRHS2.cmake
+++ /dev/null
@@ -1,3 +0,0 @@
-add_library(A SHARED a.c)
-target_link_libraries(A AnObjLib)
-add_library(AnObjLib OBJECT a.c)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-result.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-result.txt
new file mode 100644
index 000000000..e27f06b56
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-result.txt
@@ -0,0 +1 @@
+[1-9][0-9]*
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-stdout.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-stdout.txt
new file mode 100644
index 000000000..4eeb0965c
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject-build-stdout.txt
@@ -0,0 +1 @@
+REQUIRED needs to be defined
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject.cmake
new file mode 100644
index 000000000..db571a3ca
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject.cmake
@@ -0,0 +1,12 @@
+cmake_policy(SET CMP0022 NEW)
+
+enable_language(C)
+
+add_library(AnObjLib OBJECT a.c)
+target_compile_definitions(AnObjLib INTERFACE REQUIRED)
+
+add_library(AnotherObjLib OBJECT b.c)
+target_link_libraries(AnotherObjLib PRIVATE AnObjLib)
+
+add_executable(exe exe.c)
+target_link_libraries(exe AnotherObjLib)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2-build-result.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2-build-result.txt
new file mode 100644
index 000000000..e27f06b56
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2-build-result.txt
@@ -0,0 +1 @@
+[1-9][0-9]*
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2.cmake
new file mode 100644
index 000000000..6bb8d5e7a
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSObject2.cmake
@@ -0,0 +1,12 @@
+cmake_policy(SET CMP0022 NEW)
+
+enable_language(C)
+
+add_library(AnObjLib OBJECT a.c)
+target_compile_definitions(AnObjLib INTERFACE REQUIRED)
+
+add_library(AnotherObjLib OBJECT b.c)
+target_link_libraries(AnotherObjLib PUBLIC AnObjLib)
+
+add_executable(exe exe.c)
+target_link_libraries(exe AnotherObjLib)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSShared.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHSShared.cmake
new file mode 100644
index 000000000..b9030b318
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSShared.cmake
@@ -0,0 +1,13 @@
+enable_language(C)
+
+add_definitions(-DCOMPILE_FOR_SHARED_LIB)
+
+add_library(AnObjLib OBJECT a.c)
+target_compile_definitions(AnObjLib INTERFACE REQUIRED)
+set_target_properties(AnObjLib PROPERTIES POSITION_INDEPENDENT_CODE ON)
+
+add_library(A SHARED b.c $<TARGET_OBJECTS:AnObjLib>)
+target_link_libraries(A PUBLIC AnObjLib)
+
+add_executable(exe exe.c)
+target_link_libraries(exe A)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSShared2.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHSShared2.cmake
new file mode 100644
index 000000000..e2e5fa262
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSShared2.cmake
@@ -0,0 +1,14 @@
+enable_language(C)
+
+add_definitions(-DCOMPILE_FOR_SHARED_LIB)
+
+add_library(AnObjLib OBJECT a.c)
+target_compile_definitions(AnObjLib INTERFACE REQUIRED)
+set_target_properties(AnObjLib PROPERTIES POSITION_INDEPENDENT_CODE ON)
+
+add_library(A SHARED b.c)
+target_link_libraries(A PRIVATE AnObjLib)
+target_compile_definitions(A INTERFACE $<TARGET_PROPERTY:AnObjLib,INTERFACE_COMPILE_DEFINITIONS>)
+
+add_executable(exe exe.c)
+target_link_libraries(exe A)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic.cmake
new file mode 100644
index 000000000..73fad063f
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic.cmake
@@ -0,0 +1,10 @@
+enable_language(C)
+
+add_library(AnObjLib OBJECT a.c)
+target_compile_definitions(AnObjLib INTERFACE REQUIRED)
+
+add_library(A STATIC b.c $<TARGET_OBJECTS:AnObjLib>)
+target_link_libraries(A PUBLIC AnObjLib)
+
+add_executable(exe exe.c)
+target_link_libraries(exe A)
diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic2.cmake b/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic2.cmake
new file mode 100644
index 000000000..9e1ab6d94
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHSStatic2.cmake
@@ -0,0 +1,11 @@
+enable_language(C)
+
+add_library(AnObjLib OBJECT a.c)
+target_compile_definitions(AnObjLib INTERFACE REQUIRED)
+
+add_library(A STATIC b.c)
+target_link_libraries(A PRIVATE AnObjLib)
+target_compile_definitions(A INTERFACE $<TARGET_PROPERTY:AnObjLib,INTERFACE_COMPILE_DEFINITIONS>)
+
+add_executable(exe exe.c)
+target_link_libraries(exe A)
diff --git a/Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt b/Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt
deleted file mode 100644
index d67b4ae32..000000000
--- a/Tests/RunCMake/ObjectLibrary/ObjWithObj-stderr.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-CMake Error at ObjWithObj.cmake:2 \(add_library\):
- Only executables and non-OBJECT libraries may reference target objects.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt b/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt
index 40d650e21..cb1a2e5c8 100644
--- a/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/OwnSources-stderr.txt
@@ -2,4 +2,12 @@
The SOURCES of "A" use a generator expression that depends on the SOURCES
themselves.
Call Stack \(most recent call first\):
- CMakeLists.txt:[0-9]+ \(include\)$
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Error at OwnSources.cmake:[0-9]+ \(add_library\):
+ The SOURCES of "A" use a generator expression that depends on the SOURCES
+ themselves.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake
index b8eed73bb..5ec401873 100644
--- a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake
@@ -6,17 +6,51 @@ run_cmake(BadSourceExpression3)
run_cmake(BadObjSource1)
run_cmake(BadObjSource2)
if(RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")
- run_cmake(ExportNotSupported)
run_cmake(ImportNotSupported)
run_cmake(InstallNotSupported)
else()
- run_cmake(Export)
run_cmake(Import)
run_cmake(Install)
+ run_cmake(InstallLinkedObj1)
+ run_cmake(InstallLinkedObj2)
endif()
-run_cmake(LinkObjLHS)
-run_cmake(LinkObjRHS1)
-run_cmake(LinkObjRHS2)
+run_cmake(Export)
+
+function (run_object_lib_build name)
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake(${name})
+ run_cmake_command(${name}-build ${CMAKE_COMMAND} --build .)
+endfunction ()
+
+function (run_object_lib_build2 name)
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake(${name})
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
+ run_cmake_command(${name}-build ${CMAKE_COMMAND} --build .)
+endfunction ()
+
+if(NOT (RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]"))
+ run_object_lib_build(CheckTargetObjects)
+endif()
+
+run_object_lib_build(LinkObjLHSShared)
+run_object_lib_build(LinkObjLHSStatic)
+run_object_lib_build(LinkObjRHSShared)
+run_object_lib_build(LinkObjRHSStatic)
+run_object_lib_build2(LinkObjRHSObject)
+run_object_lib_build(LinkObjRHSShared2)
+run_object_lib_build(LinkObjRHSStatic2)
+run_object_lib_build2(LinkObjRHSObject2)
+run_object_lib_build(TransitiveDependencies)
+
run_cmake(MissingSource)
run_cmake(ObjWithObj)
run_cmake(OwnSources)
@@ -24,6 +58,7 @@ run_cmake(PostBuild)
run_cmake(PreBuild)
run_cmake(PreLink)
+
function(run_Dependencies)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Dependencies-build)
set(RunCMake_TEST_NO_CLEAN 1)
diff --git a/Tests/RunCMake/ObjectLibrary/TransitiveDependencies.cmake b/Tests/RunCMake/ObjectLibrary/TransitiveDependencies.cmake
new file mode 100644
index 000000000..e41cf2ec9
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/TransitiveDependencies.cmake
@@ -0,0 +1,7 @@
+add_library(lib1 STATIC depends_obj0.c)
+add_library(lib2 OBJECT a.c)
+target_link_libraries(lib2 PRIVATE lib1)
+
+add_executable(test exe2.c)
+
+target_link_libraries(test PUBLIC lib2)
diff --git a/Tests/RunCMake/ObjectLibrary/a.c b/Tests/RunCMake/ObjectLibrary/a.c
index 16363033d..8e490f374 100644
--- a/Tests/RunCMake/ObjectLibrary/a.c
+++ b/Tests/RunCMake/ObjectLibrary/a.c
@@ -1,4 +1,10 @@
-int a(void)
+#if defined(_WIN32) && defined(COMPILE_FOR_SHARED_LIB)
+# define EXPORT __declspec(dllexport)
+#else
+# define EXPORT
+#endif
+
+EXPORT int a(void)
{
return 0;
}
diff --git a/Tests/RunCMake/ObjectLibrary/b.c b/Tests/RunCMake/ObjectLibrary/b.c
index 6751907b6..220ce0302 100644
--- a/Tests/RunCMake/ObjectLibrary/b.c
+++ b/Tests/RunCMake/ObjectLibrary/b.c
@@ -1,4 +1,14 @@
-int b(void)
+#if defined(_WIN32) && defined(COMPILE_FOR_SHARED_LIB)
+# define EXPORT __declspec(dllexport)
+#else
+# define EXPORT
+#endif
+
+extern int a(void);
+EXPORT int b()
{
- return 0;
+ return a();
}
+#ifndef REQUIRED
+# error "REQUIRED needs to be defined"
+#endif
diff --git a/Tests/RunCMake/ObjectLibrary/check_object_files.cmake b/Tests/RunCMake/ObjectLibrary/check_object_files.cmake
new file mode 100644
index 000000000..3c34229ff
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/check_object_files.cmake
@@ -0,0 +1,17 @@
+
+if (NOT TARGET_OBJECTS)
+ message(SEND_ERROR "Object not passed as -DTARGET_OBJECTS")
+endif()
+
+foreach(objlib_file IN LISTS objects)
+ message(STATUS "objlib_file: =${objlib_file}=")
+
+ set(file_exists False)
+ if (EXISTS "${objlib_file}")
+ set(file_exists True)
+ endif()
+
+ if (NOT file_exists)
+ message(SEND_ERROR "File \"${objlib_file}\" does not exist!${tried}")
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/ObjectLibrary/exe.c b/Tests/RunCMake/ObjectLibrary/exe.c
new file mode 100644
index 000000000..2e08700c3
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/exe.c
@@ -0,0 +1,14 @@
+#if defined(_WIN32) && defined(COMPILE_FOR_SHARED_LIB)
+# define IMPORT __declspec(dllimport)
+#else
+# define IMPORT
+#endif
+
+extern IMPORT int b(void);
+int main()
+{
+ return b();
+}
+#ifndef REQUIRED
+# error "REQUIRED needs to be defined"
+#endif
diff --git a/Tests/RunCMake/ObjectLibrary/exe2.c b/Tests/RunCMake/ObjectLibrary/exe2.c
new file mode 100644
index 000000000..66e0caf95
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/exe2.c
@@ -0,0 +1,6 @@
+extern int myobj_foo(void);
+
+int main(void)
+{
+ return myobj_foo();
+}
diff --git a/Tests/RunCMake/ObjectLibrary/requires.c b/Tests/RunCMake/ObjectLibrary/requires.c
new file mode 100644
index 000000000..685632b3d
--- /dev/null
+++ b/Tests/RunCMake/ObjectLibrary/requires.c
@@ -0,0 +1,8 @@
+#ifdef REQUIRED
+int required()
+{
+ return 0;
+}
+#else
+# error "REQUIRED not defined"
+#endif
diff --git a/Tests/RunCMake/ParseImplicitData/CMakeLists.txt b/Tests/RunCMake/ParseImplicitData/CMakeLists.txt
new file mode 100644
index 000000000..7a8570bed
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/CMakeLists.txt
@@ -0,0 +1,91 @@
+#
+# helper CMakeLists.txt file that can be used to generate input files
+# for the Tests/RunCMake/ParseImplicit[Include|Lib]Info tests.
+#
+# usage:
+# [create a temporary build directory and chdir to it]
+# cmake [-D options] $CMAKE_SRC/Tests/RunCMake/ParseImplicitIncludeInfo/data
+#
+# where useful -D options include:
+# -DLANGUAGES="C;CXX" -- list of languages to generate inputs for
+# -DUNAME="Darwin" -- operating system name (def: CMAKE_SYSTEM_NAME)
+#
+
+cmake_minimum_required(VERSION 3.3)
+if(POLICY CMP0089)
+ cmake_policy(SET CMP0089 NEW)
+endif()
+
+set(lngs C CXX)
+set(LANGUAGES "${lngs}" CACHE STRING "List of languages to generate inputs for")
+
+project(gen_implicit_include_data ${LANGUAGES})
+
+set(UNAME "${CMAKE_SYSTEM_NAME}" CACHE STRING "System uname")
+string(TOLOWER "${UNAME}" UNAME)
+message("Generate input for system type: ${UNAME}")
+
+# CMAKE_<LANG>_COMPILER_* variables we save in the resultfile
+set(compvars ABI AR ARCHITECTURE_ID EXTERNAL_TOOLCHAIN ID LAUNCHER LOADED
+ RANLIB TARGET VERSION VERSION_INTERAL)
+
+foreach(lang IN ITEMS ${LANGUAGES})
+
+ if("${lang}" STREQUAL "C")
+ set(file ${CMAKE_ROOT}/Modules/CMakeCCompilerABI.c)
+ elseif("${lang}" STREQUAL "CXX")
+ set(file ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp)
+ elseif("${lang}" STREQUAL "CUDA")
+ set(file ${CMAKE_ROOT}/Modules/CMakeCUDACompilerABI.cu)
+ elseif("${lang}" STREQUAL "Fortran")
+ set(file ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F)
+ else()
+ message(FATAL_ERROR "unknown language ${lang}")
+ endif()
+
+ set(resultfile "${CMAKE_BINARY_DIR}/")
+ string(APPEND resultfile ${UNAME}-${lang}-${CMAKE_${lang}_COMPILER_ID})
+ string(APPEND resultfile -${CMAKE_${lang}_COMPILER_VERSION})
+ string(APPEND resultfile .input)
+ message("Generate input for language ${lang}")
+ message("Input file: ${file}")
+ message("Result file: ${resultfile}")
+
+ # replicate logic from CMakeDetermineCompilerABI
+ set(outfile "${CMAKE_PLATFORM_INFO_DIR}/test${lang}.out")
+ set(CMAKE_FLAGS )
+ set(COMPILE_DEFINITIONS )
+ if(DEFINED CMAKE_${lang}_VERBOSE_FLAG)
+ set(CMAKE_FLAGS "-DEXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}")
+ set(COMPILE_DEFINITIONS "${CMAKE_${lang}_VERBOSE_FLAG}")
+ endif()
+ if(DEFINED CMAKE_${lang}_VERBOSE_COMPILE_FLAG)
+ set(COMPILE_DEFINITIONS "${CMAKE_${lang}_VERBOSE_COMPILE_FLAG}")
+ endif()
+ if(NOT "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC")
+ # Avoid adding our own platform standard libraries for compilers
+ # from which we might detect implicit link libraries.
+ list(APPEND CMAKE_FLAGS "-DCMAKE_${lang}_STANDARD_LIBRARIES=")
+ endif()
+
+ try_compile(rv ${CMAKE_BINARY_DIR} ${file}
+ CMAKE_FLAGS ${CMAKE_FLAGS}
+ COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS}
+ CMAKE_FLAGS ${CMAKE_FLAGS}
+ OUTPUT_VARIABLE output
+ COPY_FILE "${outfile}"
+ COPY_FILE_ERROR copy_error)
+
+ if(NOT rv)
+ message(FATAL_ERROR "${lang} compile failed!!")
+ endif()
+
+ set(result "CMAKE_LANG=${lang}\n")
+ list(APPEND result "CMAKE_LINKER=${CMAKE_LINKER}\n")
+ foreach(var IN ITEMS ${compvars})
+ list(APPEND result
+ "CMAKE_${lang}_COMPILER_${var}=${CMAKE_${lang}_COMPILER_${var}}\n")
+ endforeach()
+
+ file(WRITE ${resultfile} ${result} ${output})
+endforeach()
diff --git a/Tests/RunCMake/ParseImplicitData/README b/Tests/RunCMake/ParseImplicitData/README
new file mode 100644
index 000000000..46802544d
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/README
@@ -0,0 +1,26 @@
+This directory contains sample input files for the implicit include
+directories, and link info parsers for testing. For each configuration
+ there is one ".input" file and matching ".output" files in
+ParseImplicitIncludeInfo/results and ParseImplicitLinkInfo/results.
+
+To generate ".input" files for a system, create a temporary build
+directory and chdir to it. Then run cmake pointing to this directory.
+The CMakeLists.txt file here will generate ".input" files in your
+build directory. The default set of languages is C and CXX. This
+can be changed with -DLANGUAGES=language_list. For example:
+-DLANGUAGES=Fortran will generate Fortran parser input.
+
+The ".output" files should be generated by hand from the input files.
+The test will compare the parser output to the manually generated
+".output" file. The two should match.
+
+For compilers that support "-nostdinc"-like flags, you can generate
+a test for this with a command like:
+cmake -DUNAME=netbsd_nostdinc \
+ -DCMAKE_C_FLAGS=-nostdinc -DCMAKE_CXX_FLAGS=-nostdinc .
+
+Here is an example for testing the XL compiler with both -I and nostdinc:
+
+env CC=xlc CXX=xlC cmake -DUNAME=linux_nostdinc_i \
+ -DCMAKE_C_FLAGS='-qnostdinc -I/tmp/ii/test_c' \
+ -DCMAKE_CXX_FLAGS='-qnostdinc -I/tmp/ii/test_c -I/tmp/ii/test_cxx' .
diff --git a/Tests/RunCMake/ParseImplicitData/aix-C-XL-13.1.3.input b/Tests/RunCMake/ParseImplicitData/aix-C-XL-13.1.3.input
new file mode 100644
index 000000000..14517c5cb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/aix-C-XL-13.1.3.input
@@ -0,0 +1,40 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=XL
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=13.1.3
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_424d1/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_424d1.dir/build.make CMakeFiles/cmTC_424d1.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o
+/opt/IBM/xlc/13.1.3/bin/xlc -qthreaded -qhalt=e -V -o CMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o -c /tmp/CMake/Modules/CMakeCCompilerABI.c
+export XL_CONFIG=/opt/IBM/xlc/13.1.3/etc/xlc.cfg.72:xlc
+export XL_ASMOBJFILES=/tmp/xlcASvf7aid
+export "XL_DIS=/opt/IBM/xlc/13.1.3/exe/dis -o "CMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o" "CMakeCCompilerABI.o""
+/opt/IBM/xlc/13.1.3/exe/xlcentry -qosvar=aix.7.2 -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX50 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_AIX71 -D_AIX72 -D_IBMR2 -D_POWER -qthreaded -qhalt=e -qasm_as=/bin/as -qc_stdinc=/opt/IBM/xlc/13.1.3/include:/opt/IBM/xlmass/8.1.3/include:/usr/include -qvac_include_path=/opt/IBM/xlc/13.1.3/include -oCMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o /tmp/CMake/Modules/CMakeCCompilerABI.c /tmp/xlcW0uR7aia /tmp/xlcW1uV7aib /dev/null /tmp/xlcLvj7aieF.lst /dev/null /tmp/xlcW2vb7aic
+export XL_BACKEND=/opt/IBM/xlc/13.1.3/exe/xlCcode
+export XL_LINKER=/bin/ld
+/opt/IBM/xlc/13.1.3/exe/xlCcode -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qthreaded -qhalt=e /tmp/xlcW0uR7aia /tmp/xlcW1uV7aib CMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o /tmp/xlcLvj7aieB.lst /tmp/xlcW2vb7aic
+rm /tmp/xlcASvf7aid
+rm /tmp/xlcLvj7aie
+rm /tmp/xlcW0uR7aia
+rm /tmp/xlcW1uV7aib
+rm /tmp/xlcW2vb7aic
+Linking C executable cmTC_424d1
+/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_424d1.dir/link.txt --verbose=1
+/opt/IBM/xlc/13.1.3/bin/xlc -qthreaded -qhalt=e -Wl,-bnoipath -Wl,-brtl -V -Wl,-bexpall CMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o -o cmTC_424d1 -Wl,-blibpath:/usr/lib:/lib
+export XL_CONFIG=/opt/IBM/xlc/13.1.3/etc/xlc.cfg.72:xlc
+/bin/ld -b32 /lib/crt0.o -bpT:0x10000000 -bpD:0x20000000 -bnoipath -brtl -bexpall CMakeFiles/cmTC_424d1.dir/CMakeCCompilerABI.c.o -o cmTC_424d1 -blibpath:/usr/lib:/lib -L/opt/IBM/xlmass/8.1.3/lib/aix61 -L/opt/IBM/xlc/13.1.3/lib -lxlopt -lxlipa -lxl -lc
+rm /tmp/xlcW0wn7aia
+rm /tmp/xlcW1wr7aib
+rm /tmp/xlcW2wz7aic
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/aix-C-XLClang-16.1.0.1.input b/Tests/RunCMake/ParseImplicitData/aix-C-XLClang-16.1.0.1.input
new file mode 100644
index 000000000..2f018e624
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/aix-C-XLClang-16.1.0.1.input
@@ -0,0 +1,40 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=XLClang
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=16.1.0.1
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/gmake cmTC_fcf21/fast
+/usr/bin/gmake -f CMakeFiles/cmTC_fcf21.dir/build.make CMakeFiles/cmTC_fcf21.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o
+/opt/IBM/xlC/16.1.0/bin/xlclang -V -o CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o -c /tmp/CMake/Modules/CMakeCCompilerABI.c
+export XL_CONFIG=/opt/IBM/xlc/16.1.0/etc/xlc.cfg.72:xlclang
+export XL_ASMOBJFILES=/tmp/xlcASuz87id
+export "XL_DIS=/opt/IBM/xlc/16.1.0/exe/dis -o "CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o" "CMakeCCompilerABI.o""
+/opt/IBM/xlC/16.1.0/exe/xlC2entry -qosvar=aix.7.2 -qalias=ansi -qthreaded -D_THREAD_SAFE -Wno-parentheses -Wno-unused-value -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX50 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_AIX71 -D_AIX72 -D_IBMR2 -D_POWER -xc -qasm_as=/bin/as -qc_stdinc=/opt/IBM/xlC/16.1.0/include2:/opt/IBM/xlC/16.1.0/include2/aix:/opt/IBM/xlmass/9.1.0/include:/usr/include -qvac_include_path=/opt/IBM/xlc/16.1.0/include -oCMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o /tmp/CMake/Modules/CMakeCCompilerABI.c /tmp/xlcW0tZ87ia /tmp/xlcW1ub87ib /dev/null /tmp/xlcLu487ieF.lst /dev/null /tmp/xlcW2uj87ic
+export XL_BACKEND=/opt/IBM/xlc/16.1.0/exe/xlCcode
+export XL_LINKER=/bin/ld
+/opt/IBM/xlc/16.1.0/exe/xlCcode -qalias=ansi -qthreaded /tmp/xlcW0tZ87ia /tmp/xlcW1ub87ib CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o /tmp/xlcLu487ieB.lst /tmp/xlcW2uj87ic
+rm /tmp/xlcASuz87id
+rm /tmp/xlcLu487ie
+rm /tmp/xlcW0tZ87ia
+rm /tmp/xlcW1ub87ib
+rm /tmp/xlcW2uj87ic
+Linking C executable cmTC_fcf21
+/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_fcf21.dir/link.txt --verbose=1
+/opt/IBM/xlC/16.1.0/bin/xlclang -Wl,-bnoipath -Wl,-brtl -V -Wl,-bexpall CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o -o cmTC_fcf21 -Wl,-blibpath:/usr/lib:/lib
+export XL_CONFIG=/opt/IBM/xlc/16.1.0/etc/xlc.cfg.72:xlclang
+/bin/ld -b32 /lib/crt0.o -bpT:0x10000000 -bpD:0x20000000 -bnoipath -brtl -bexpall CMakeFiles/cmTC_fcf21.dir/CMakeCCompilerABI.c.o -o cmTC_fcf21 -blibpath:/usr/lib:/lib -L/opt/IBM/xlmass/9.1.0/lib/aix61 -L/opt/IBM/xlc/16.1.0/lib -lxlopt -lxlipa -lxl -lc -lpthreads
+rm /tmp/xlcW0vJG7ia
+rm /tmp/xlcW1vNG7ib
+rm /tmp/xlcW2vRG7ic
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/aix-CXX-XL-13.1.3.input b/Tests/RunCMake/ParseImplicitData/aix-CXX-XL-13.1.3.input
new file mode 100644
index 000000000..5aec849e1
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/aix-CXX-XL-13.1.3.input
@@ -0,0 +1,44 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=XL
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=13.1.3
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_e8f3a/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_e8f3a.dir/build.make CMakeFiles/cmTC_e8f3a.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o
+/opt/IBM/xlC/13.1.3/bin/xlC -+ -qthreaded -qhalt=s -V -o CMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o -c /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp
+export XL_CONFIG=/opt/IBM/xlc/13.1.3/etc/xlc.cfg.72:xlC
+export XL_XLCMP_PATH=/opt/IBM/xlc/13.1.3:/opt/IBM/xlC/13.1.3
+export XL_COMPILER=xlc++
+export XL_ASMOBJFILES=/tmp/xlcAS3F7aid
+export "XL_DIS=/opt/IBM/xlc/13.1.3/exe/dis -o "CMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o" "CMakeCXXCompilerABI.o""
+/opt/IBM/xlC/13.1.3/exe/xlCentry -qosvar=aix.7.2 -qalias=ansi -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX50 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_AIX71 -D_AIX72 -D_IBMR2 -D_POWER -qthreaded -qhalt=s -qasm_as=/bin/as -qcpp_stdinc=/opt/IBM/xlC/13.1.3/include:/opt/IBM/xlmass/8.1.3/include:/usr/include -qc_stdinc=/opt/IBM/xlc/13.1.3/include:/opt/IBM/xlmass/8.1.3/include:/usr/include -oCMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp /tmp/xlcW03r7aia /tmp/xlcW1347aib /dev/null /tmp/xlcL3J7aieF.lst /dev/null /tmp/xlcW2387aic
+export XL_BACKEND=/opt/IBM/xlc/13.1.3/exe/xlCcode
+export XL_LINKER=/bin/ld
+/opt/IBM/xlc/13.1.3/exe/xlCcode -qalias=ansi -qthreaded -qhalt=s /tmp/xlcW03r7aia /tmp/xlcW1347aib CMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o /tmp/xlcL3J7aieB.lst /tmp/xlcW2387aic
+rm /tmp/xlcAS3F7aid
+rm /tmp/xlcL3J7aie
+rm /tmp/xlcW03r7aia
+rm /tmp/xlcW1347aib
+rm /tmp/xlcW2387aic
+Linking CXX executable cmTC_e8f3a
+/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e8f3a.dir/link.txt --verbose=1
+/opt/IBM/xlC/13.1.3/bin/xlC -qthreaded -qhalt=s -Wl,-bnoipath -Wl,-brtl -V -Wl,-bexpall CMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_e8f3a -Wl,-blibpath:/usr/lib:/lib
+export XL_CONFIG=/opt/IBM/xlc/13.1.3/etc/xlc.cfg.72:xlC
+/bin/ld -b32 /lib/crt0.o /lib/crti.o -bpT:0x10000000 -bpD:0x20000000 -bnoipath -brtl -bexpall CMakeFiles/cmTC_e8f3a.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_e8f3a -blibpath:/usr/lib:/lib -bcdtors:all:0:s -btmplrename -L/opt/IBM/xlmass/8.1.3/lib/aix61 -L/opt/IBM/xlc/13.1.3/lib -lxlopt -lxlipa -lxl -L/opt/IBM/xlC/13.1.3/lib -lC -lm -lc |
+/opt/IBM/xlC/13.1.3/bin/c++filt -S |
+/bin/sed '/317.*::virtual-fn-table-ptr$/ s/^\(.*: \)*{*\([^}]*\)\(}*.*\)::virtual-fn-table-ptr$/\1Virtual table for class "\2": Some possible causes are: first non-inline virtual function in "\2" is not defined or the class is a template instantiation and an explicit instantiation definition of the class is missing./'
+rm /tmp/xlcW04Jtaea
+rm /tmp/xlcW14Vtaeb
+rm /tmp/xlcW24Vtaec
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/aix-CXX-XLClang-16.1.0.1.input b/Tests/RunCMake/ParseImplicitData/aix-CXX-XLClang-16.1.0.1.input
new file mode 100644
index 000000000..da16db3a0
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/aix-CXX-XLClang-16.1.0.1.input
@@ -0,0 +1,44 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=XLClang
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=16.1.0.1
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/gmake cmTC_b8490/fast
+/usr/bin/gmake -f CMakeFiles/cmTC_b8490.dir/build.make CMakeFiles/cmTC_b8490.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o
+/opt/IBM/xlC/16.1.0/bin/xlclang++ -x c++ -V -o CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o -c /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp
+export XL_CONFIG=/opt/IBM/xlc/16.1.0/etc/xlc.cfg.72:xlclang++
+export XL_XLCMP_PATH=/opt/IBM/xlc/16.1.0:/opt/IBM/xlC/16.1.0
+export XL_COMPILER=xlc++
+export XL_ASMOBJFILES=/tmp/xlcAS3IXqid
+export "XL_DIS=/opt/IBM/xlc/16.1.0/exe/dis -o "CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o" "CMakeCXXCompilerABI.o""
+/opt/IBM/xlC/16.1.0/exe/xlC2entry -qosvar=aix.7.2 -qalias=ansi -qthreaded -D_THREAD_SAFE -Wno-parentheses -Wno-unused-value -D_AIX -D_AIX32 -D_AIX41 -D_AIX43 -D_AIX50 -D_AIX51 -D_AIX52 -D_AIX53 -D_AIX61 -D_AIX71 -D_AIX72 -D_IBMR2 -D_POWER -xc++ -qasm_as=/bin/as -qcpp_stdinc=/opt/IBM/xlC/16.1.0/include2/c++:/opt/IBM/xlC/16.1.0/include2:/opt/IBM/xlC/16.1.0/include2/aix:/opt/IBM/xlmass/9.1.0/include:/usr/include -qc_stdinc=/opt/IBM/xlC/16.1.0/include2:/opt/IBM/xlC/16.1.0/include2/aix:/opt/IBM/xlmass/9.1.0/include:/usr/include -oCMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp /tmp/xlcW03uXqia /tmp/xlcW137Xqib /dev/null /tmp/xlcL3QXqieF.lst /dev/null /tmp/xlcW23AXqic
+export XL_BACKEND=/opt/IBM/xlc/16.1.0/exe/xlCcode
+export XL_LINKER=/bin/ld
+/opt/IBM/xlc/16.1.0/exe/xlCcode -qalias=ansi -qthreaded /tmp/xlcW03uXqia /tmp/xlcW137Xqib CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o /tmp/xlcL3QXqieB.lst /tmp/xlcW23AXqic
+rm /tmp/xlcAS3IXqid
+rm /tmp/xlcL3QXqie
+rm /tmp/xlcW03uXqia
+rm /tmp/xlcW137Xqib
+rm /tmp/xlcW23AXqic
+Linking CXX executable cmTC_b8490
+/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_b8490.dir/link.txt --verbose=1
+/opt/IBM/xlC/16.1.0/bin/xlclang++ -Wl,-bnoipath -Wl,-brtl -V -Wl,-bexpall CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_b8490 -Wl,-blibpath:/usr/lib:/lib
+export XL_CONFIG=/opt/IBM/xlc/16.1.0/etc/xlc.cfg.72:xlclang++
+/bin/ld -b32 /lib/crt0.o /lib/crti.o -bpT:0x10000000 -bpD:0x20000000 -bnoipath -brtl -bexpall CMakeFiles/cmTC_b8490.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_b8490 -blibpath:/usr/lib:/lib -bcdtors:all:0:s -btmplrename -L/opt/IBM/xlmass/9.1.0/lib/aix61 -L/opt/IBM/xlc/16.1.0/lib -lxlopt -lxlipa -lxl -L/opt/IBM/xlC/16.1.0/lib -lc++ -lCcore -lpthreads -lm -lc |
+/opt/IBM/xlC/16.1.0/bin/c++filt -S |
+/bin/sed '/317.*::virtual-fn-table-ptr$/ s/^\(.*: \)*{*\([^}]*\)\(}*.*\)::virtual-fn-table-ptr$/\1Virtual table for class "\2": Some possible causes are: first non-inline virtual function in "\2" is not defined or the class is a template instantiation and an explicit instantiation definition of the class is missing./'
+rm /tmp/xlcW05fS7ia
+rm /tmp/xlcW15rS7ib
+rm /tmp/xlcW25vS7ic
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/craype-C-Cray-8.7.input b/Tests/RunCMake/ParseImplicitData/craype-C-Cray-8.7.input
new file mode 100644
index 000000000..b3218a2f5
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/craype-C-Cray-8.7.input
@@ -0,0 +1,53 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=Cray
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=8.7
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_cb7b8/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_cb7b8.dir/build.make CMakeFiles/cmTC_cb7b8.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_cb7b8.dir/CMakeCCompilerABI.c.o
+/opt/cray/pe/craype/2.5.15/bin/cc -v -o CMakeFiles/cmTC_cb7b8.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake/Modules/CMakeCCompilerABI.c
+rm /tmp/pe_15430/CMakeCCompilerABI_1.s
+
+/opt/cray/pe/cce/8.7.4/cce/x86_64/bin/ccfe -hc -hcpu=haswell -D __CRAYXC -D __CRAY_HASWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -hnetwork=aries -nostdinc -isystem /opt/cray/pe/cce/8.7.4/cce/x86_64/include/craylibs -isystem /opt/cray/pe/cce/8.7.4/cce/x86_64/include/basic -isystem /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include -isystem /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include-fixed -isystem /opt/gcc/6.1.0/snos/include -isystem /usr/include -I /opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include -D__PEDRVR_GCC_BASE_ACTIVE__ -hpl=/tmp/pe_15430//pldir -rx8503 -ru87000 -CZ /tmp/pe_15430/CMakeCCompilerABI.T -Cx -CX /tmp/pe_15430/CMakeCCompilerABI.xml -hdecompile=/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_cb7b8.dir/CMakeCCompilerABI. -S /tmp/pe_15430/CMakeCCompilerABI_1.s -hipa3 -ufile_id=1 /usr/share/cmake/Modules/CMakeCCompilerABI.c
+
+/opt/cray/pe/cce/8.7.4/cce/x86_64/bin/optcg /tmp/pe_15430//pldir 1
+
+/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/bin/as -o CMakeFiles/cmTC_cb7b8.dir/CMakeCCompilerABI.c.o --64 /tmp/pe_15430/CMakeCCompilerABI_1.s
+rm /tmp/pe_15430/CMakeCCompilerABI_1.s
+rm /tmp/pe_15430//CMakeCCompilerABI_1.cif.Ttmp
+rm /tmp/pe_15430//CMakeCCompilerABI.Tfe
+rm /tmp/pe_15430//CMakeCCompilerABI.T
+rm /tmp/pe_15430//CMakeCCompilerABI_1.xml.Ttmp
+rm /tmp/pe_15430//pldir/PL_path
+rm /tmp/pe_15430//pldir/iline_1
+rm /tmp/pe_15430//pldir/PL_module_list
+rm /tmp/pe_15430//pldir/CMakeCCompilerABI_1.inl
+rm /tmp/pe_15430//pldir/gline_1
+rm /tmp/pe_15430//pldir/PL_global_data
+rmdir /tmp/pe_15430//pldir
+rm /tmp/pe_15430//CMakeCCompilerABI.xml
+rmdir /tmp/pe_15430/
+Linking C executable cmTC_cb7b8
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_cb7b8.dir/link.txt --verbose=1
+/opt/cray/pe/craype/2.5.15/bin/cc -v CMakeFiles/cmTC_cb7b8.dir/CMakeCCompilerABI.c.o -o cmTC_cb7b8
+
+/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld /usr/lib64//crt1.o /usr/lib64//crti.o /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtbeginT.o /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtfastmath.o /opt/cray/pe/cce/8.7.4/cce/x86_64/lib/no_mmap.o CMakeFiles/cmTC_cb7b8.dir/CMakeCCompilerABI.c.o -Bstatic -rpath=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib -L /opt/gcc/6.1.0/snos/lib64 -rpath=/opt/cray/pe/gcc-libs -L /opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/lib -L /opt/cray/dmapp/default/lib64 -L /opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib -L /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64 -L /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64 -L /opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/lib64 -L /opt/cray/pe/pmi/5.0.14/lib64 -L /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64 -L /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64 -L /opt/cray/pe/atp/2.1.3/libApp -L /opt/cray/pe/cce/8.7.4/cce/x86_64/lib/pkgconfig/../ -L /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64 --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -L /usr/lib64 -L /lib64 -rpath=/usr/lib64 -rpath=/lib64 -lpthread -lsci_cray_mpi_mp -lm -lf -lsci_cray_mp -lcraymp -lm -lpthread -lf -lhugetlbfs -lmpich_cray -lrt -lpthread -lugni -lpmi -lpgas-dmapp -lfi -lu -lrt --undefined=dmapp_get_flag_nbi -ldmapp -lugni -ludreg -lpthread -lm -lcray-c++-rts -lstdc++ -lxpmem -ldmapp -lpthread -lpmi -lpthread -lalpslli -lpthread -lwlm_detect -lugni -lpthread -lalpsutil -lpthread -lrca -ludreg -lquadmath -lm -lomp -lrt -lcraymp -lpthread -lrt -ldl -lcray-c++-rts -lstdc++ -lm -lmodules -lm -lrt -lfi -lm -lquadmath -lrt -lcraymath -lm -lgfortran -lquadmath -lrt -lf -lm -lpthread -lrt -lu -lrt -ldl -lcray-c++-rts -lstdc++ -lm -lcsup -lrt --as-needed -latomic --no-as-needed -lstdc++ -lpthread --start-group -lc -lcsup -lgcc_eh -lm -lgcc --end-group -T/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/2.23.1.cce.ld -L /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0 -L /opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/..//x86_64-unknown-linux-gnu/lib -EL -o cmTC_cb7b8 --undefined=__pthread_initialize_minimal /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtend.o /usr/lib64//crtn.o
+
+/opt/cray/pe/cce/8.7.4/binutils/x86_64/bin/objcopy --remove-section=.note.ftn_module_data cmTC_cb7b8
+rm /tmp/pe_15450//pldir/PL_path
+rm /tmp/pe_15450//pldir/PL_module_list
+rm /tmp/pe_15450//pldir/PL_global_data
+rmdir /tmp/pe_15450//pldir
+rmdir /tmp/pe_15450/
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/craype-C-Cray-9.0-hlist-ad.input b/Tests/RunCMake/ParseImplicitData/craype-C-Cray-9.0-hlist-ad.input
new file mode 100644
index 000000000..e82bd97c1
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/craype-C-Cray-9.0-hlist-ad.input
@@ -0,0 +1,54 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=Cray
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=9.0
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /home/generic.user/Code/tmp/build/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/gmake cmTC_9ceca/fast && /usr/bin/gmake -f CMakeFiles/cmTC_9ceca.dir/build.make CMakeFiles/cmTC_9ceca.dir/build
+gmake[1]: Entering directory '/home/generic.user/Code/tmp/build/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_9ceca.dir/CMakeCCompilerABI.c.o
+/opt/cray/pe/craype/2.6.0/bin/cc -hlist=ad -v -o CMakeFiles/cmTC_9ceca.dir/CMakeCCompilerABI.c.o -c /home/generic.user/Code/cmake/source/master/Modules/CMakeCCompilerABI.c
+rm /lus/scratch/tmp/pe_14877/CMakeCCompilerABI_1.s
+
+/opt/cray/pe/cce/9.0.0/cce/x86_64/bin/ccfe -hc -hcpu=broadwell -D __CRAYXC -D __CRAY_BROADWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -hnetwork=aries -hdecomp -nostdinc -isystem /opt/cray/pe/cce/9.0.0/cce/x86_64/include/craylibs -isystem /opt/cray/pe/cce/9.0.0/cce/x86_64/include/basic -isystem /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0/include -isystem /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0/include-fixed -isystem /opt/gcc/8.1.0/snos/include -isystem /usr/include -I /opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/include -I /opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/include -I /opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/xpmem/2.2.15-6.0.7.1_5.8__g7549d06.ari/include -I /opt/cray/dmapp/7.1.1-6.0.7.0_34.3__g5a674e0.ari/include -I /opt/cray/gni-headers/5.0.12.0-6.0.7.0_24.1__g3b1768f.ari/include -I /opt/cray/ugni/6.0.14.0-6.0.7.0_23.1__gea11d3d.ari/include -I /opt/cray/udreg/2.3.2-6.0.7.0_33.18__g5196236.ari/include -I /opt/cray/alps/6.6.43-6.0.7.0_26.4__ga796da3.ari/include -I /opt/cray/wlm_detect/1.3.3-6.0.7.0_47.2__g7109084.ari/include -I /opt/cray/krca/2.2.4-6.0.7.1_5.23__g8505b97.ari/include -I /opt/cray-hss-devel/8.0.0/include -D__PEDRVR_GCC_BASE_ACTIVE__ -hpl=/lus/scratch/tmp/pe_14877//pldir -CY "driver.cc -h cpu=broadwell -h dynamic -D __CRAYXC -D __CRAY_BROADWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -h network=aries -h list=ad -v -o CMakeFiles/cmTC_9ceca.dir/CMakeCCompilerABI.c.o -c /home/generic.user/Code/cmake/source/master/Modules/CMakeCCompilerABI.c -isystem /opt/cray/pe/cce/9.0.0/cce/x86_64/include/craylibs -isystem /opt/cray/pe/cce/9.0.0/cce/x86_64/include/basic -isystem /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0/include -isystem /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0/include-fixed -isystem /opt/gcc/8.1.0/snos/include -isystem /usr/include -I /opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/include -I /opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/include -I /opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/xpmem/2.2.15-6.0.7.1_5.8__g7549d06.ari/include -I /opt/cray/dmapp/7.1.1-6.0.7.0_34.3__g5a674e0.ari/include -I /opt/cray/gni-headers/5.0.12.0-6.0.7.0_24.1__g3b1768f.ari/include -I /opt/cray/ugni/6.0.14.0-6.0.7.0_23.1__gea11d3d.ari/include -I /opt/cray/udreg/2.3.2-6.0.7.0_33.18__g5196236.ari/include -I /opt/cray/alps/6.6.43-6.0.7.0_26.4__ga796da3.ari/include -I /opt/cray/wlm_detect/1.3.3-6.0.7.0_47.2__g7109084.ari/include -I /opt/cray/krca/2.2.4-6.0.7.1_5.23__g8505b97.ari/include -I /opt/cray-hss-devel/8.0.0/include" -ru87000 -CZ /lus/scratch/tmp/pe_14877/CMakeCCompilerABI.T -Cx -CX /lus/scratch/tmp/pe_14877/CMakeCCompilerABI.xml -CL -hdecompile=/home/generic.user/Code/tmp/build/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_9ceca.dir/CMakeCCompilerABI. -S /lus/scratch/tmp/pe_14877/CMakeCCompilerABI_1.s -hipa3 -ufile_id=1 /home/generic.user/Code/cmake/source/master/Modules/CMakeCCompilerABI.c
+
+/opt/cray/pe/cce/9.0.0/cce/x86_64/bin/optcg /lus/scratch/tmp/pe_14877//pldir 1
+
+/opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-pc-linux-gnu/bin/as -o CMakeFiles/cmTC_9ceca.dir/CMakeCCompilerABI.c.o --64 /lus/scratch/tmp/pe_14877/CMakeCCompilerABI_1.s
+rm /lus/scratch/tmp/pe_14877/CMakeCCompilerABI_1.s
+
+/opt/cray/pe/cce/9.0.0/cce/x86_64/bin/clx -ra -q -o CMakeFiles/cmTC_9ceca.dir/CMakeCCompilerABI.lst /home/generic.user/Code/cmake/source/master/Modules/CMakeCCompilerABI.c /lus/scratch/tmp/pe_14877/CMakeCCompilerABI.T
+rm /lus/scratch/tmp/pe_14877/CMakeCCompilerABI.T
+rm /lus/scratch/tmp/pe_14877//CMakeCCompilerABI.xml
+rm /lus/scratch/tmp/pe_14877//CMakeCCompilerABI_1.xml.Ttmp
+rm /lus/scratch/tmp/pe_14877//CMakeCCompilerABI.Tfe
+rm /lus/scratch/tmp/pe_14877//CMakeCCompilerABI_1.cif.Ttmp
+rm /lus/scratch/tmp/pe_14877//pldir/gline_1
+rm /lus/scratch/tmp/pe_14877//pldir/PL_path
+rm /lus/scratch/tmp/pe_14877//pldir/CMakeCCompilerABI_1.inl
+rm /lus/scratch/tmp/pe_14877//pldir/PL_global_data
+rm /lus/scratch/tmp/pe_14877//pldir/iline_1
+rm /lus/scratch/tmp/pe_14877//pldir/PL_module_list
+rmdir /lus/scratch/tmp/pe_14877//pldir
+rmdir /lus/scratch/tmp/pe_14877/
+Linking C executable cmTC_9ceca
+/home/generic.user/Code/cmake/build/master/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9ceca.dir/link.txt --verbose=1
+/opt/cray/pe/craype/2.6.0/bin/cc -hlist=ad -v -dynamic CMakeFiles/cmTC_9ceca.dir/CMakeCCompilerABI.c.o -o cmTC_9ceca
+
+/opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld --eh-frame-hdr -m elf_x86_64 --enable-new-dtags --dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib64//crt1.o /usr/lib64//crti.o /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0//crtbegin.o /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0//crtfastmath.o /opt/cray/pe/cce/9.0.0/cce/x86_64/lib/no_mmap.o CMakeFiles/cmTC_9ceca.dir/CMakeCCompilerABI.c.o -Bdynamic -rpath=/opt/cray/pe/cce/9.0.0/cce/x86_64/lib -L /opt/gcc/8.1.0/snos/lib64 -rpath=/opt/cray/pe/gcc-libs -L /opt/cray/dmapp/default/lib64 -L /opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/lib -L /opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/lib -L /opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/lib64 -L /opt/cray/pe/atp/2.1.3/libApp -L /opt/cray/pe/cce/9.0.0/cce/x86_64/lib/pkgconfig/../ --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -L /usr/lib64 -L /lib64 -rpath=/usr/lib64 -rpath=/lib64 -lrca --as-needed -lmpich_cray_90 --no-as-needed --as-needed -lsci_cray_mpi --no-as-needed --as-needed -lsci_cray --no-as-needed --as-needed -lpgas-dmapp --no-as-needed -lquadmath -lmodules -lfi -lcraymath -lf -lu -lcsup --as-needed -latomic --no-as-needed --whole-archive -ltcmalloc_minimal --no-whole-archive -lcray-c++-rts -lstdc++ -lpthread -L /opt/cray/pe/cce/9.0.0/cce-clang/x86_64/lib/clang/9.0.0/lib/linux --start-group -lc -lcsup -lgcc_eh -lm -lclang_rt.craypgo-x86_64 -lgcc --end-group -L /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0 -L /opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-pc-linux-gnu/..//x86_64-unknown-linux-gnu/lib -EL -o cmTC_9ceca /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0//crtend.o /usr/lib64//crtn.o
+
+/opt/cray/pe/cce/9.0.0/binutils/x86_64/bin/objcopy --remove-section=.note.ftn_module_data cmTC_9ceca
+rm /lus/scratch/tmp/pe_14889//pldir/PL_path
+rm /lus/scratch/tmp/pe_14889//pldir/PL_global_data
+rm /lus/scratch/tmp/pe_14889//pldir/PL_module_list
+rmdir /lus/scratch/tmp/pe_14889//pldir
+rmdir /lus/scratch/tmp/pe_14889/
+gmake[1]: Leaving directory '/home/generic.user/Code/tmp/build/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/craype-C-GNU-7.3.0.input b/Tests/RunCMake/ParseImplicitData/craype-C-GNU-7.3.0.input
new file mode 100644
index 000000000..2dc60aff2
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/craype-C-GNU-7.3.0.input
@@ -0,0 +1,79 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=GNU
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=7.3.0
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_61245/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_61245.dir/build.make CMakeFiles/cmTC_61245.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o
+/opt/cray/pe/craype/2.5.15/bin/cc -v -o CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake/Modules/CMakeCCompilerABI.c
+Using built-in specs.
+COLLECT_GCC=/opt/gcc/7.3.0/bin/../snos/bin/gcc
+Target: x86_64-suse-linux
+Configured with: ../cray-gcc-7.3.0-201801270210.d61239fc6000b/configure --prefix=/opt/gcc/7.3.0/snos --disable-nls --libdir=/opt/gcc/7.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.3.0/snos/include/g++ --with-slibdir=/opt/gcc/7.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib
+Thread model: posix
+gcc version 7.3.0 20180125 (Cray Inc.) (GCC)
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o' '-c' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include'
+ /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/cc1 -quiet -v -I /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include -D __CRAYXC -D __CRAY_HASWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -D __TARGET_LINUX__ /usr/share/cmake/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -march=core-avx2 -auxbase-strip CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o -version -o /tmp/ccNvdQ8R.s
+GNU C11 (GCC) version 7.3.0 20180125 (Cray Inc.) (x86_64-suse-linux)
+ compiled by GNU C version 7.3.0 20180125 (Cray Inc.), GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3, isl version isl-0.15-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring nonexistent directory "/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../x86_64-suse-linux/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include
+ /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include
+ /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include
+ /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include
+ /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include
+ /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include
+ /opt/cray/pe/pmi/5.0.14/include
+ /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include
+ /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include
+ /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include
+ /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include
+ /opt/cray-hss-devel/8.0.0/include
+ /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include
+ /usr/local/include
+ /opt/gcc/7.3.0/snos/include
+ /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include-fixed
+ /usr/include
+End of search list.
+GNU C11 (GCC) version 7.3.0 20180125 (Cray Inc.) (x86_64-suse-linux)
+ compiled by GNU C version 7.3.0 20180125 (Cray Inc.), GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3, isl version isl-0.15-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+Compiler executable checksum: 4ecdcb30ed2f7ac4fb078d81fd42f086
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o' '-c' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include'
+ as -v -I /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include --64 -o CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o /tmp/ccNvdQ8R.s
+GNU assembler version 2.31.1 (x86_64-suse-linux) using BFD version (GNU Binutils SUSE Linux Enterprise 12) 2.31.1.20180828-9.26
+COMPILER_PATH=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/
+LIBRARY_PATH=/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o' '-c' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include'
+Linking C executable cmTC_61245
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_61245.dir/link.txt --verbose=1
+/opt/cray/pe/craype/2.5.15/bin/cc -v CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o -o cmTC_61245
+Using built-in specs.
+COLLECT_GCC=/opt/gcc/7.3.0/bin/../snos/bin/gcc
+COLLECT_LTO_WRAPPER=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/lto-wrapper
+Target: x86_64-suse-linux
+Configured with: ../cray-gcc-7.3.0-201801270210.d61239fc6000b/configure --prefix=/opt/gcc/7.3.0/snos --disable-nls --libdir=/opt/gcc/7.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.3.0/snos/include/g++ --with-slibdir=/opt/gcc/7.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib
+Thread model: posix
+gcc version 7.3.0 20180125 (Cray Inc.) (GCC)
+COMPILER_PATH=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/
+LIBRARY_PATH=/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_61245' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64' '-L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64' '-L/opt/cray/pe/pmi/5.0.14/lib64' '-L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64' '-L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64'
+ /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/collect2 -plugin /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/liblto_plugin.so -plugin-opt=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccG3uxpY.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc -m elf_x86_64 -static -o cmTC_61245 -u pthread_mutex_destroy /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/crtbeginT.o -L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64 -L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64 -L/opt/cray/pe/pmi/5.0.14/lib64 -L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64 -L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../.. CMakeFiles/cmTC_61245.dir/CMakeCCompilerABI.c.o -rpath=/opt/cray/pe/gcc-libs --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -lpthread -lsci_gnu_71_mpi -lsci_gnu_71 -lpthread -lhugetlbfs -lmpich_gnu_71 -lrt -lugni -lpthread -lpmi -lpthread -lalpslli -lpthread -lwlm_detect -lalpsutil -lpthread -lrca -lxpmem -lugni -lpthread -ludreg --as-needed -lgfortran -lquadmath --no-as-needed --as-needed -lmvec --no-as-needed --as-needed -lm --no-as-needed --as-needed -lpthread --no-as-needed --start-group -lgcc -lgcc_eh -lc --end-group /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/crtend.o /usr/lib/../lib64/crtn.o
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_61245' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64' '-L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64' '-L/opt/cray/pe/pmi/5.0.14/lib64' '-L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64' '-L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64'
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/craype-C-Intel-18.0.2.20180210.input b/Tests/RunCMake/ParseImplicitData/craype-C-Intel-18.0.2.20180210.input
new file mode 100644
index 000000000..8c68e5bf5
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/craype-C-Intel-18.0.2.20180210.input
@@ -0,0 +1,40 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=Intel
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=18.0.2.20180210
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_96fde/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_96fde.dir/build.make CMakeFiles/cmTC_96fde.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o
+/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/bin/intel64/icc -v -o CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake/Modules/CMakeCCompilerABI.c
+icc version 18.0.2 (gcc version 6.3.0 compatibility)
+/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/mcpcom --target_efi2 --lang=c -_g -mP3OPT_inline_alloca -D__ICC=1800 -D__INTEL_COMPILER=1800 -D__INTEL_COMPILER_UPDATE=2 -D__PTRDIFF_TYPE__=long "-D__SIZE_TYPE__=unsigned long" -D__WCHAR_TYPE__=int "-D__WINT_TYPE__=unsigned int" "-D__INTMAX_TYPE__=long int" "-D__UINTMAX_TYPE__=long unsigned int" -D__LONG_MAX__=9223372036854775807L -D__QMSPP_ -D__OPTIMIZE__ -D__NO_MATH_INLINES -D__NO_STRING_INLINES -D__GNUC_GNU_INLINE__ -D__GNUC__=6 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=0 -D__LP64__ -D_LP64 -D__GXX_ABI_VERSION=1010 "-D__USER_LABEL_PREFIX__= " -D__REGISTER_PREFIX__= -D__INTEL_RTTI__ -D__unix__ -D__unix -D__linux__ -D__linux -D__gnu_linux__ -B -Dunix -Dlinux "-_Asystem(unix)" -D__ELF__ -D__x86_64 -D__x86_64__ -D__amd64 -D__amd64__ "-_Acpu(x86_64)" "-_Amachine(x86_64)" -D__INTEL_COMPILER_BUILD_DATE=20180210 -D__INTEL_OFFLOAD -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE2_MATH__ -D__SSE__ -D__SSE_MATH__ -D__MMX__ -_k -_8 -_l --has_new_stdarg_support -_a -_b --gnu_version=60300 -_W5 --gcc-extern-inline --multibyte_chars -mGLOB_diag_suppress_sys --system_preinclude /usr/include/stdc-predef.h --array_section --simd --simd_func --offload_mode=1 --offload_target_names=gfx,GFX,mic,MIC --offload_unique_string=icc1641499230JViDRp -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=630 "-mGLOB_options_string=-v -o CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -c" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/icc6TGEr2as_.s -mIPOPT_activate -mIPOPT_lite -mGLOB_instruction_tuning=0x0 -mGLOB_uarch_tuning=0x0 -mGLOB_product_id_code=0x22006d92 -mCG_bnl_movbe=T -mGLOB_extended_instructions=0x8 -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icc1641499230JViDRp -mP2OPT_hlo_level=2 -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_lto_object_enabled -mIPOPT_lto_object_value=1 -mIPOPT_obj_output_file_name=CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -mIPOPT_whole_archive_fixup_file_name=/tmp/iccwarchM4gS0h -mGLOB_linker_version=2.31.1.20180828 -mGLOB_driver_tempfile_name=/tmp/icctempfileMGADNU -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_C -mP1OPT_source_file_name=/usr/share/cmake/Modules/CMakeCCompilerABI.c -mP1OPT_full_source_file_name=/usr/share/cmake/Modules/CMakeCCompilerABI.c /usr/share/cmake/Modules/CMakeCCompilerABI.c
+#include "..." search starts here:
+#include <...> search starts here:
+ /opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include
+ /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64
+ /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc
+ /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include
+ /usr/local/include
+ /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include
+ /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed
+ /opt/gcc/6.3.0/snos/include/
+ /usr/include
+End of search list.
+Linking C executable cmTC_96fde
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_96fde.dir/link.txt --verbose=1
+/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/bin/intel64/icc -v CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -o cmTC_96fde -rdynamic
+icc version 18.0.2 (gcc version 6.3.0 compatibility)
+/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/mcpcom -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=630 "-mGLOB_options_string=-v -o cmTC_96fde -rdynamic" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/iccRJ58KYas_.s -mGLOB_dashboard_use_source_name -mIPOPT_activate -mGLOB_product_id_code=0x22006d92 -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mGLOB_opt_report_use_source_name -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icc0762718770pMrhfB -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_link -mIPOPT_ipo_activate -mIPOPT_mo_activate -mIPOPT_source_files_list=/tmp/iccslisYmrmw5 -mIPOPT_mo_global_data -mIPOPT_link_script_file=/tmp/iccscript8Dy5AI "-mIPOPT_cmdline_link="/usr/lib/../lib64/crt1.o" "/usr/lib/../lib64/crti.o" "/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtbegin.o" "-export-dynamic" "--eh-frame-hdr" "--build-id" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-m" "elf_x86_64" "-o" "cmTC_96fde" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64/" "-L/lib/../lib64" "-L/lib/../lib64/" "-L/usr/lib/../lib64" "-L/usr/lib/../lib64/" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64/" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../" "-L/lib64" "-L/lib/" "-L/usr/lib64" "-L/usr/lib" "CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o" "-Bdynamic" "-Bstatic" "-limf" "-lsvml" "-lirng" "-Bdynamic" "-lm" "-Bstatic" "-lipgo" "-ldecimal" "--as-needed" "-Bdynamic" "-lcilkrts" "-lstdc++" "--no-as-needed" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc" "-lsvml" "-Bdynamic" "-lc" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc_s" "-Bdynamic" "-ldl" "-lc" "/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtend.o" "/usr/lib/../lib64/crtn.o"" -mIPOPT_il_in_obj -mIPOPT_ipo_activate_warn=FALSE -mIPOPT_obj_output_file_name=/tmp/ipo_icclnz13i.o -mIPOPT_whole_archive_fixup_file_name=/tmp/iccwarch0d1B2R -mGLOB_linker_version=2.31.1.20180828 -mGLOB_driver_tempfile_name=/tmp/icctempfilelBn98u -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=/tmp/ipo_icclnz13i.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_NONE -mP1OPT_source_file_name=ipo_out.c CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -mIPOPT_object_files=T -mIPOPT_assembly_files=/tmp/iccalisA2xsdz -mIPOPT_generated_tempfiles=/tmp/iccelisbUgbic -mIPOPT_embedded_object_base_name=/tmp/icceobjEt9TmP -mIPOPT_cmdline_link_new_name=/tmp/iccllisYEcDrs
+ld /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtbegin.o -export-dynamic --eh-frame-hdr --build-id -dynamic-linker /lib64/ld-linux-x86-64.so.2 -m elf_x86_64 -o cmTC_96fde -L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64 -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/ -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64 -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64/ -L/lib/../lib64 -L/lib/../lib64/ -L/usr/lib/../lib64 -L/usr/lib/../lib64/ -L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64/ -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../ -L/lib64 -L/lib/ -L/usr/lib64 -L/usr/lib CMakeFiles/cmTC_96fde.dir/CMakeCCompilerABI.c.o -Bdynamic -Bstatic -limf -lsvml -lirng -Bdynamic -lm -Bstatic -lipgo -ldecimal --as-needed -Bdynamic -lcilkrts -lstdc++ --no-as-needed -lgcc -lgcc_s -Bstatic -lirc -lsvml -Bdynamic -lc -lgcc -lgcc_s -Bstatic -lirc_s -Bdynamic -ldl -lc /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtend.o /usr/lib/../lib64/crtn.o
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/craype-CXX-Cray-8.7.input b/Tests/RunCMake/ParseImplicitData/craype-CXX-Cray-8.7.input
new file mode 100644
index 000000000..73c9c8a7f
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/craype-CXX-Cray-8.7.input
@@ -0,0 +1,53 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=Cray
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=8.7
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_f3b1f/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_f3b1f.dir/build.make CMakeFiles/cmTC_f3b1f.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_f3b1f.dir/CMakeCXXCompilerABI.cpp.o
+/opt/cray/pe/craype/2.5.15/bin/CC -v -o CMakeFiles/cmTC_f3b1f.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp
+rm /tmp/pe_15530/CMakeCXXCompilerABI_1.s
+
+/opt/cray/pe/cce/8.7.4/cce/x86_64/bin/ccfe -hcpu=haswell -D __CRAYXC -D __CRAY_HASWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -hnetwork=aries -nostdinc -isystem /opt/cray/pe/cce/8.7.4/cce/x86_64/include/craylibs -isystem /opt/gcc/6.1.0/snos/include/g++ -isystem /opt/gcc/6.1.0/snos/include/g++/x86_64-suse-linux -isystem /opt/gcc/6.1.0/snos/include/g++/backward -isystem /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include -isystem /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include-fixed -isystem /opt/cray/pe/cce/8.7.4/cce/x86_64/include/c++ -isystem /opt/cray/pe/cce/8.7.4/cce/x86_64/include/basic -isystem /opt/gcc/6.1.0/snos/include -isystem /usr/include -I /opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include -D__PEDRVR_GCC_BASE_ACTIVE__ -hpl=/tmp/pe_15530//pldir -rx8503 -ru87000 -hipafrom=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/libcray-c++-rts.a -CZ /tmp/pe_15530/CMakeCXXCompilerABI.T -Cx -CX /tmp/pe_15530/CMakeCXXCompilerABI.xml -hdecompile=/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_f3b1f.dir/CMakeCXXCompilerABI. -S /tmp/pe_15530/CMakeCXXCompilerABI_1.s -hipa4 -ufile_id=1 /usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp
+
+/opt/cray/pe/cce/8.7.4/cce/x86_64/bin/optcg /tmp/pe_15530//pldir 1
+
+/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/bin/as -o CMakeFiles/cmTC_f3b1f.dir/CMakeCXXCompilerABI.cpp.o --64 /tmp/pe_15530/CMakeCXXCompilerABI_1.s
+rm /tmp/pe_15530/CMakeCXXCompilerABI_1.s
+rm /tmp/pe_15530//CMakeCXXCompilerABI.xml
+rm /tmp/pe_15530//CMakeCXXCompilerABI_1.cif.Ttmp
+rm /tmp/pe_15530//CMakeCXXCompilerABI.T
+rm /tmp/pe_15530//pldir/PL_path
+rm /tmp/pe_15530//pldir/CMakeCXXCompilerABI_1.inl
+rm /tmp/pe_15530//pldir/iline_1
+rm /tmp/pe_15530//pldir/PL_module_list
+rm /tmp/pe_15530//pldir/gline_1
+rm /tmp/pe_15530//pldir/PL_global_data
+rmdir /tmp/pe_15530//pldir
+rm /tmp/pe_15530//CMakeCXXCompilerABI.Tfe
+rm /tmp/pe_15530//CMakeCXXCompilerABI_1.xml.Ttmp
+rmdir /tmp/pe_15530/
+Linking CXX executable cmTC_f3b1f
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f3b1f.dir/link.txt --verbose=1
+/opt/cray/pe/craype/2.5.15/bin/CC -v CMakeFiles/cmTC_f3b1f.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_f3b1f
+
+/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld /usr/lib64//crt1.o /usr/lib64//crti.o /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtbeginT.o /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtfastmath.o /opt/cray/pe/cce/8.7.4/cce/x86_64/lib/no_mmap.o CMakeFiles/cmTC_f3b1f.dir/CMakeCXXCompilerABI.cpp.o -Bstatic -rpath=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib -L /opt/gcc/6.1.0/snos/lib64 -rpath=/opt/cray/pe/gcc-libs -L /opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/lib -L /opt/cray/dmapp/default/lib64 -L /opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib -L /opt/cray/dmapp/default/lib64 -L /opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib -L /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64 -L /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64 -L /opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/lib64 -L /opt/cray/pe/pmi/5.0.14/lib64 -L /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64 -L /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64 -L /opt/cray/pe/atp/2.1.3/libApp -L /opt/cray/pe/cce/8.7.4/cce/x86_64/lib/pkgconfig/../ -L /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64 --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -L /usr/lib64 -L /lib64 -rpath=/usr/lib64 -rpath=/lib64 -lpthread -lsci_cray_mpi_mp -lm -lf -lsci_cray_mp -lcraymp -lm -lpthread -lf -lhugetlbfs -lmpichcxx_cray -lrt -lpthread -lugni -lpmi -lmpich_cray -lrt -lpthread -lugni -lpmi -lpgas-dmapp -lfi -lu -lrt --undefined=dmapp_get_flag_nbi -ldmapp -lugni -ludreg -lpthread -lm -lcray-c++-rts -lstdc++ -lxpmem -ldmapp -lpthread -lpmi -lpthread -lalpslli -lpthread -lwlm_detect -lugni -lpthread -lalpsutil -lpthread -lrca -ludreg -lquadmath -lm -lomp -lrt -lcraymp -lpthread -lrt -ldl -lcray-c++-rts -lstdc++ -lm -lmodules -lm -lrt -lfi -lm -lquadmath -lrt -lcraymath -lm -lgfortran -lquadmath -lrt -lf -lm -lpthread -lrt -lu -lrt -ldl -lcray-c++-rts -lstdc++ -lm -lcsup -lrt --as-needed -latomic --no-as-needed -lcray-c++-rts -lstdc++ -lsupc++ -lstdc++ -lpthread --start-group -lc -lcsup -lgcc_eh -lm -lgcc --end-group -T/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/2.23.1.cce.ld -L /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0 -L /opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/..//x86_64-unknown-linux-gnu/lib -EL -o cmTC_f3b1f --undefined=__pthread_initialize_minimal /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtend.o /usr/lib64//crtn.o
+
+/opt/cray/pe/cce/8.7.4/binutils/x86_64/bin/objcopy --remove-section=.note.ftn_module_data cmTC_f3b1f
+rm /tmp/pe_15566//pldir/PL_path
+rm /tmp/pe_15566//pldir/PL_module_list
+rm /tmp/pe_15566//pldir/PL_global_data
+rmdir /tmp/pe_15566//pldir
+rmdir /tmp/pe_15566/
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/craype-CXX-Cray-9.0-hlist-ad.input b/Tests/RunCMake/ParseImplicitData/craype-CXX-Cray-9.0-hlist-ad.input
new file mode 100644
index 000000000..06a4ac929
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/craype-CXX-Cray-9.0-hlist-ad.input
@@ -0,0 +1,54 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=Cray
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=9.0
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /home/generic.user/Code/tmp/build/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/gmake cmTC_aa1be/fast && /usr/bin/gmake -f CMakeFiles/cmTC_aa1be.dir/build.make CMakeFiles/cmTC_aa1be.dir/build
+gmake[1]: Entering directory '/home/generic.user/Code/tmp/build/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_aa1be.dir/CMakeCXXCompilerABI.cpp.o
+/opt/cray/pe/craype/2.6.0/bin/CC -hlist=ad -v -o CMakeFiles/cmTC_aa1be.dir/CMakeCXXCompilerABI.cpp.o -c /home/generic.user/Code/cmake/source/master/Modules/CMakeCXXCompilerABI.cpp
+rm /lus/scratch/tmp/pe_14901/CMakeCXXCompilerABI_1.s
+
+/opt/cray/pe/cce/9.0.0/cce/x86_64/bin/ccfe -hcpu=broadwell -D __CRAYXC -D __CRAY_BROADWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -hnetwork=aries -hdecomp -nostdinc -isystem /opt/cray/pe/cce/9.0.0/cce/x86_64/include/craylibs -isystem /opt/gcc/8.1.0/snos/include/g++ -isystem /opt/gcc/8.1.0/snos/include/g++/x86_64-suse-linux -isystem /opt/gcc/8.1.0/snos/include/g++/backward -isystem /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0/include -isystem /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0/include-fixed -isystem /opt/cray/pe/cce/9.0.0/cce/x86_64/include/c++ -isystem /opt/cray/pe/cce/9.0.0/cce/x86_64/include/basic -isystem /opt/gcc/8.1.0/snos/include -isystem /usr/include -I /opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/include -I /opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/include -I /opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/xpmem/2.2.15-6.0.7.1_5.8__g7549d06.ari/include -I /opt/cray/dmapp/7.1.1-6.0.7.0_34.3__g5a674e0.ari/include -I /opt/cray/gni-headers/5.0.12.0-6.0.7.0_24.1__g3b1768f.ari/include -I /opt/cray/ugni/6.0.14.0-6.0.7.0_23.1__gea11d3d.ari/include -I /opt/cray/udreg/2.3.2-6.0.7.0_33.18__g5196236.ari/include -I /opt/cray/alps/6.6.43-6.0.7.0_26.4__ga796da3.ari/include -I /opt/cray/wlm_detect/1.3.3-6.0.7.0_47.2__g7109084.ari/include -I /opt/cray/krca/2.2.4-6.0.7.1_5.23__g8505b97.ari/include -I /opt/cray-hss-devel/8.0.0/include -D__PEDRVR_GCC_BASE_ACTIVE__ -hpl=/lus/scratch/tmp/pe_14901//pldir -CY "driver.CC -h cpu=broadwell -h dynamic -D __CRAYXC -D __CRAY_BROADWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -h network=aries -h list=ad -v -o CMakeFiles/cmTC_aa1be.dir/CMakeCXXCompilerABI.cpp.o -c /home/generic.user/Code/cmake/source/master/Modules/CMakeCXXCompilerABI.cpp -isystem /opt/cray/pe/cce/9.0.0/cce/x86_64/include/craylibs -isystem /opt/gcc/8.1.0/snos/include/g++ -isystem /opt/gcc/8.1.0/snos/include/g++/x86_64-suse-linux -isystem /opt/gcc/8.1.0/snos/include/g++/backward -isystem /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0/include -isystem /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0/include-fixed -isystem /opt/cray/pe/cce/9.0.0/cce/x86_64/include/c++ -isystem /opt/cray/pe/cce/9.0.0/cce/x86_64/include/basic -isystem /opt/gcc/8.1.0/snos/include -isystem /usr/include -I /opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/include -I /opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/include -I /opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/xpmem/2.2.15-6.0.7.1_5.8__g7549d06.ari/include -I /opt/cray/dmapp/7.1.1-6.0.7.0_34.3__g5a674e0.ari/include -I /opt/cray/gni-headers/5.0.12.0-6.0.7.0_24.1__g3b1768f.ari/include -I /opt/cray/ugni/6.0.14.0-6.0.7.0_23.1__gea11d3d.ari/include -I /opt/cray/udreg/2.3.2-6.0.7.0_33.18__g5196236.ari/include -I /opt/cray/alps/6.6.43-6.0.7.0_26.4__ga796da3.ari/include -I /opt/cray/wlm_detect/1.3.3-6.0.7.0_47.2__g7109084.ari/include -I /opt/cray/krca/2.2.4-6.0.7.1_5.23__g8505b97.ari/include -I /opt/cray-hss-devel/8.0.0/include" -ru87000 -hipafrom=/opt/cray/pe/cce/9.0.0/cce/x86_64/lib/libcray-c++-rts.a -CZ /lus/scratch/tmp/pe_14901/CMakeCXXCompilerABI.T -Cx -CX /lus/scratch/tmp/pe_14901/CMakeCXXCompilerABI.xml -CL -hdecompile=/home/generic.user/Code/tmp/build/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_aa1be.dir/CMakeCXXCompilerABI. -S /lus/scratch/tmp/pe_14901/CMakeCXXCompilerABI_1.s -hipa4 -ufile_id=1 /home/generic.user/Code/cmake/source/master/Modules/CMakeCXXCompilerABI.cpp
+
+/opt/cray/pe/cce/9.0.0/cce/x86_64/bin/optcg /lus/scratch/tmp/pe_14901//pldir 1
+
+/opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-pc-linux-gnu/bin/as -o CMakeFiles/cmTC_aa1be.dir/CMakeCXXCompilerABI.cpp.o --64 /lus/scratch/tmp/pe_14901/CMakeCXXCompilerABI_1.s
+rm /lus/scratch/tmp/pe_14901/CMakeCXXCompilerABI_1.s
+
+/opt/cray/pe/cce/9.0.0/cce/x86_64/bin/clx -ra -q -o CMakeFiles/cmTC_aa1be.dir/CMakeCXXCompilerABI.lst /home/generic.user/Code/cmake/source/master/Modules/CMakeCXXCompilerABI.cpp /lus/scratch/tmp/pe_14901/CMakeCXXCompilerABI.T
+rm /lus/scratch/tmp/pe_14901/CMakeCXXCompilerABI.T
+rm /lus/scratch/tmp/pe_14901//CMakeCXXCompilerABI_1.xml.Ttmp
+rm /lus/scratch/tmp/pe_14901//CMakeCXXCompilerABI_1.cif.Ttmp
+rm /lus/scratch/tmp/pe_14901//CMakeCXXCompilerABI.Tfe
+rm /lus/scratch/tmp/pe_14901//CMakeCXXCompilerABI.xml
+rm /lus/scratch/tmp/pe_14901//pldir/gline_1
+rm /lus/scratch/tmp/pe_14901//pldir/PL_path
+rm /lus/scratch/tmp/pe_14901//pldir/CMakeCXXCompilerABI_1.inl
+rm /lus/scratch/tmp/pe_14901//pldir/PL_global_data
+rm /lus/scratch/tmp/pe_14901//pldir/iline_1
+rm /lus/scratch/tmp/pe_14901//pldir/PL_module_list
+rmdir /lus/scratch/tmp/pe_14901//pldir
+rmdir /lus/scratch/tmp/pe_14901/
+Linking CXX executable cmTC_aa1be
+/home/generic.user/Code/cmake/build/master/bin/cmake -E cmake_link_script CMakeFiles/cmTC_aa1be.dir/link.txt --verbose=1
+/opt/cray/pe/craype/2.6.0/bin/CC -hlist=ad -v -dynamic CMakeFiles/cmTC_aa1be.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_aa1be
+
+/opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld --eh-frame-hdr -m elf_x86_64 --enable-new-dtags --dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib64//crt1.o /usr/lib64//crti.o /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0//crtbegin.o /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0//crtfastmath.o /opt/cray/pe/cce/9.0.0/cce/x86_64/lib/no_mmap.o CMakeFiles/cmTC_aa1be.dir/CMakeCXXCompilerABI.cpp.o -Bdynamic -rpath=/opt/cray/pe/cce/9.0.0/cce/x86_64/lib -L /opt/gcc/8.1.0/snos/lib64 -rpath=/opt/cray/pe/gcc-libs -L /opt/cray/dmapp/default/lib64 -L /opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/lib -L /opt/cray/dmapp/default/lib64 -L /opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/lib -L /opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/lib -L /opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/lib64 -L /opt/cray/pe/atp/2.1.3/libApp -L /opt/cray/pe/cce/9.0.0/cce/x86_64/lib/pkgconfig/../ --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -L /usr/lib64 -L /lib64 -rpath=/usr/lib64 -rpath=/lib64 -lrca --as-needed -lmpich_cray_90 --no-as-needed --as-needed -lmpichcxx_cray_90 --no-as-needed --as-needed -lsci_cray_mpi --no-as-needed --as-needed -lsci_cray --no-as-needed --as-needed -lpgas-dmapp --no-as-needed -lquadmath -lmodules -lfi -lcraymath -lf -lu -lcsup --as-needed -latomic --no-as-needed -lcray-c++-rts -lcray-c++-rts -lstdc++ -lsupc++ --whole-archive -ltcmalloc_minimal --no-whole-archive -lcray-c++-rts -lstdc++ -lpthread -L /opt/cray/pe/cce/9.0.0/cce-clang/x86_64/lib/clang/9.0.0/lib/linux --start-group -lc -lcsup -lgcc_eh -lm -lclang_rt.craypgo-x86_64 -lgcc --end-group -L /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0 -L /opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-pc-linux-gnu/..//x86_64-unknown-linux-gnu/lib -EL -o cmTC_aa1be /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0//crtend.o /usr/lib64//crtn.o
+
+/opt/cray/pe/cce/9.0.0/binutils/x86_64/bin/objcopy --remove-section=.note.ftn_module_data cmTC_aa1be
+rm /lus/scratch/tmp/pe_14913//pldir/PL_path
+rm /lus/scratch/tmp/pe_14913//pldir/PL_global_data
+rm /lus/scratch/tmp/pe_14913//pldir/PL_module_list
+rmdir /lus/scratch/tmp/pe_14913//pldir
+rmdir /lus/scratch/tmp/pe_14913/
+gmake[1]: Leaving directory '/home/generic.user/Code/tmp/build/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/craype-CXX-GNU-7.3.0.input b/Tests/RunCMake/ParseImplicitData/craype-CXX-GNU-7.3.0.input
new file mode 100644
index 000000000..50f2859c7
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/craype-CXX-GNU-7.3.0.input
@@ -0,0 +1,82 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=GNU
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=7.3.0
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_66e70/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_66e70.dir/build.make CMakeFiles/cmTC_66e70.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o
+/opt/cray/pe/craype/2.5.15/bin/CC -v -o CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp
+Using built-in specs.
+COLLECT_GCC=/opt/gcc/7.3.0/bin/../snos/bin/g++
+Target: x86_64-suse-linux
+Configured with: ../cray-gcc-7.3.0-201801270210.d61239fc6000b/configure --prefix=/opt/gcc/7.3.0/snos --disable-nls --libdir=/opt/gcc/7.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.3.0/snos/include/g++ --with-slibdir=/opt/gcc/7.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib
+Thread model: posix
+gcc version 7.3.0 20180125 (Cray Inc.) (GCC)
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include'
+ /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/cc1plus -quiet -v -I /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include -D_GNU_SOURCE -D __CRAYXC -D __CRAY_HASWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -D __TARGET_LINUX__ /usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -march=core-avx2 -auxbase-strip CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o -version -o /tmp/ccH9m9Qh.s
+GNU C++14 (GCC) version 7.3.0 20180125 (Cray Inc.) (x86_64-suse-linux)
+ compiled by GNU C version 7.3.0 20180125 (Cray Inc.), GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3, isl version isl-0.15-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring nonexistent directory "/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../x86_64-suse-linux/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include
+ /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include
+ /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include
+ /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include
+ /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include
+ /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include
+ /opt/cray/pe/pmi/5.0.14/include
+ /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include
+ /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include
+ /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include
+ /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include
+ /opt/cray-hss-devel/8.0.0/include
+ /opt/gcc/7.3.0/snos/include/g++
+ /opt/gcc/7.3.0/snos/include/g++/x86_64-suse-linux
+ /opt/gcc/7.3.0/snos/include/g++/backward
+ /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include
+ /usr/local/include
+ /opt/gcc/7.3.0/snos/include
+ /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include-fixed
+ /usr/include
+End of search list.
+GNU C++14 (GCC) version 7.3.0 20180125 (Cray Inc.) (x86_64-suse-linux)
+ compiled by GNU C version 7.3.0 20180125 (Cray Inc.), GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3, isl version isl-0.15-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+Compiler executable checksum: f544672a0be6a74646c0fce634253d7e
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include'
+ as -v -I /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include --64 -o CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o /tmp/ccH9m9Qh.s
+GNU assembler version 2.31.1 (x86_64-suse-linux) using BFD version (GNU Binutils SUSE Linux Enterprise 12) 2.31.1.20180828-9.26
+COMPILER_PATH=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/
+LIBRARY_PATH=/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include'
+Linking CXX executable cmTC_66e70
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_66e70.dir/link.txt --verbose=1
+/opt/cray/pe/craype/2.5.15/bin/CC -v CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_66e70
+Using built-in specs.
+COLLECT_GCC=/opt/gcc/7.3.0/bin/../snos/bin/g++
+COLLECT_LTO_WRAPPER=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/lto-wrapper
+Target: x86_64-suse-linux
+Configured with: ../cray-gcc-7.3.0-201801270210.d61239fc6000b/configure --prefix=/opt/gcc/7.3.0/snos --disable-nls --libdir=/opt/gcc/7.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.3.0/snos/include/g++ --with-slibdir=/opt/gcc/7.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib
+Thread model: posix
+gcc version 7.3.0 20180125 (Cray Inc.) (GCC)
+COMPILER_PATH=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/
+LIBRARY_PATH=/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_66e70' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64' '-L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64' '-L/opt/cray/pe/pmi/5.0.14/lib64' '-L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64' '-L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64'
+ /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/collect2 -plugin /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/liblto_plugin.so -plugin-opt=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccPBC8Um.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc -m elf_x86_64 -static -o cmTC_66e70 -u pthread_mutex_destroy /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/crtbeginT.o -L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64 -L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64 -L/opt/cray/pe/pmi/5.0.14/lib64 -L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64 -L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../.. CMakeFiles/cmTC_66e70.dir/CMakeCXXCompilerABI.cpp.o -rpath=/opt/cray/pe/gcc-libs --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -lpthread -lsci_gnu_71_mpi -lsci_gnu_71 -lpthread -lhugetlbfs -lmpichcxx_gnu_71 -lrt -lugni -lpthread -lpmi -lmpich_gnu_71 -lrt -lugni -lpthread -lpmi -lpthread -lalpslli -lpthread -lwlm_detect -lalpsutil -lpthread -lrca -lugni -lpthread -lxpmem -ludreg --as-needed -lgfortran -lquadmath --no-as-needed --as-needed -lmvec --no-as-needed --as-needed -lm --no-as-needed --as-needed -lpthread --no-as-needed -lstdc++ -lm --start-group -lgcc -lgcc_eh -lc --end-group /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/crtend.o /usr/lib/../lib64/crtn.o
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-static' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-u' 'pthread_mutex_destroy' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_66e70' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64' '-L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64' '-L/opt/cray/pe/pmi/5.0.14/lib64' '-L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64' '-L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64'
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/craype-CXX-Intel-18.0.2.20180210.input b/Tests/RunCMake/ParseImplicitData/craype-CXX-Intel-18.0.2.20180210.input
new file mode 100644
index 000000000..e25f7cf9d
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/craype-CXX-Intel-18.0.2.20180210.input
@@ -0,0 +1,43 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=Intel
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=18.0.2.20180210
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_7f9a2/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_7f9a2.dir/build.make CMakeFiles/cmTC_7f9a2.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o
+/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/bin/intel64/icpc -v -o CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp
+icpc version 18.0.2 (gcc version 6.3.0 compatibility)
+/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/mcpcom --target_efi2 --lang=c++ -_g -mP3OPT_inline_alloca -D__ICC=1800 -D__INTEL_COMPILER=1800 -D__INTEL_COMPILER_UPDATE=2 -D__PTRDIFF_TYPE__=long "-D__SIZE_TYPE__=unsigned long" -D__WCHAR_TYPE__=int "-D__WINT_TYPE__=unsigned int" "-D__INTMAX_TYPE__=long int" "-D__UINTMAX_TYPE__=long unsigned int" -D__GLIBCXX_TYPE_INT_N_0=__int128 -D__GLIBCXX_BITSIZE_INT_N_0=128 -D__LONG_MAX__=9223372036854775807L -D__QMSPP_ -D__OPTIMIZE__ -D__NO_MATH_INLINES -D__NO_STRING_INLINES -D__GNUC_GNU_INLINE__ -D__GNUG__=6 -D__GNUC__=6 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=0 -D__LP64__ -D_LP64 -D_GNU_SOURCE=1 -D__DEPRECATED=1 -D__GXX_WEAK__=1 -D__GXX_ABI_VERSION=1010 "-D__USER_LABEL_PREFIX__= " -D__REGISTER_PREFIX__= -D__INTEL_RTTI__ -D__EXCEPTIONS=1 -D__unix__ -D__unix -D__linux__ -D__linux -D__gnu_linux__ -B -Dunix -Dlinux "-_Asystem(unix)" -D__ELF__ -D__x86_64 -D__x86_64__ -D__amd64 -D__amd64__ "-_Acpu(x86_64)" "-_Amachine(x86_64)" -D__INTEL_COMPILER_BUILD_DATE=20180210 -D__INTEL_OFFLOAD -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE2_MATH__ -D__SSE__ -D__SSE_MATH__ -D__MMX__ -_k -_8 -_l --has_new_stdarg_support -_a -_b --gnu_version=60300 -_W5 --gcc-extern-inline -p --bool -tused -x --multibyte_chars -mGLOB_diag_suppress_sys --system_preinclude /usr/include/stdc-predef.h --array_section --simd --simd_func --offload_mode=1 --offload_target_names=gfx,GFX,mic,MIC --offload_unique_string=icpc0677339003u7vp5M --bool -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=630 "-mGLOB_options_string=-v -o CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -c" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/icpc9QgBnwas_.s -mIPOPT_activate -mIPOPT_lite -mGLOB_instruction_tuning=0x0 -mGLOB_uarch_tuning=0x0 -mGLOB_product_id_code=0x22006d8f -mCG_bnl_movbe=T -mGLOB_extended_instructions=0x8 -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icpc0677339003u7vp5M -mP2OPT_hlo_level=2 -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_lto_object_enabled -mIPOPT_lto_object_value=1 -mIPOPT_obj_output_file_name=CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -mIPOPT_whole_archive_fixup_file_name=/tmp/icpcwarchdKZxrN -mGLOB_linker_version=2.31.1.20180828 -mGLOB_driver_tempfile_name=/tmp/icpctempfilejCzFYq -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_C_PLUS_PLUS -mP1OPT_source_file_name=/usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp -mP1OPT_full_source_file_name=/usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp -mGLOB_eh_linux /usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp
+#include "..." search starts here:
+#include <...> search starts here:
+ /opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include
+ /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64
+ /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc
+ /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include
+ /opt/gcc/6.3.0/snos/include/g++
+ /opt/gcc/6.3.0/snos/include/g++/x86_64-suse-linux
+ /opt/gcc/6.3.0/snos/include/g++/backward
+ /usr/local/include
+ /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include
+ /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed
+ /opt/gcc/6.3.0/snos/include/
+ /usr/include
+End of search list.
+Linking CXX executable cmTC_7f9a2
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_7f9a2.dir/link.txt --verbose=1
+/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/bin/intel64/icpc -v CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_7f9a2 -rdynamic
+icpc version 18.0.2 (gcc version 6.3.0 compatibility)
+/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/mcpcom -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=630 "-mGLOB_options_string=-v -o cmTC_7f9a2 -rdynamic" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/icpczXhKsFas_.s -mGLOB_dashboard_use_source_name -mIPOPT_activate -mGLOB_product_id_code=0x22006d8f -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mGLOB_opt_report_use_source_name -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icpc0782944392Xjn3gY -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_link -mIPOPT_ipo_activate -mIPOPT_mo_activate -mIPOPT_source_files_list=/tmp/icpcslis0WLMWJ -mIPOPT_mo_global_data -mIPOPT_link_script_file=/tmp/icpcscriptx5xyMn "-mIPOPT_cmdline_link="/usr/lib/../lib64/crt1.o" "/usr/lib/../lib64/crti.o" "/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtbegin.o" "-export-dynamic" "--eh-frame-hdr" "--build-id" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-m" "elf_x86_64" "-o" "cmTC_7f9a2" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64/" "-L/lib/../lib64" "-L/lib/../lib64/" "-L/usr/lib/../lib64" "-L/usr/lib/../lib64/" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64/" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../" "-L/lib64" "-L/lib/" "-L/usr/lib64" "-L/usr/lib" "CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o" "-Bdynamic" "-Bstatic" "-limf" "-lsvml" "-lirng" "-Bdynamic" "-lstdc++" "-lm" "-Bstatic" "-lipgo" "-ldecimal" "--as-needed" "-Bdynamic" "-lcilkrts" "--no-as-needed" "-lstdc++" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc" "-lsvml" "-Bdynamic" "-lc" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc_s" "-Bdynamic" "-ldl" "-lc" "/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtend.o" "/usr/lib/../lib64/crtn.o"" -mIPOPT_il_in_obj -mIPOPT_ipo_activate_warn=FALSE -mIPOPT_obj_output_file_name=/tmp/ipo_icpcP4kcWS.o -mIPOPT_whole_archive_fixup_file_name=/tmp/icpcwarchR2OJ1A -mGLOB_linker_version=2.31.1.20180828 -mGLOB_driver_tempfile_name=/tmp/icpctempfileWiVxTe -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=/tmp/ipo_icpcP4kcWS.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_NONE -mP1OPT_source_file_name=ipo_out.c CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -mIPOPT_object_files=T -mIPOPT_assembly_files=/tmp/icpcalis76IIBa -mIPOPT_generated_tempfiles=/tmp/icpcelisj58trO -mIPOPT_embedded_object_base_name=/tmp/icpceobjgmHfhs -mIPOPT_cmdline_link_new_name=/tmp/icpcllis3p9065
+ld /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtbegin.o -export-dynamic --eh-frame-hdr --build-id -dynamic-linker /lib64/ld-linux-x86-64.so.2 -m elf_x86_64 -o cmTC_7f9a2 -L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64 -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/ -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64 -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64/ -L/lib/../lib64 -L/lib/../lib64/ -L/usr/lib/../lib64 -L/usr/lib/../lib64/ -L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64/ -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../ -L/lib64 -L/lib/ -L/usr/lib64 -L/usr/lib CMakeFiles/cmTC_7f9a2.dir/CMakeCXXCompilerABI.cpp.o -Bdynamic -Bstatic -limf -lsvml -lirng -Bdynamic -lstdc++ -lm -Bstatic -lipgo -ldecimal --as-needed -Bdynamic -lcilkrts --no-as-needed -lstdc++ -lgcc -lgcc_s -Bstatic -lirc -lsvml -Bdynamic -lc -lgcc -lgcc_s -Bstatic -lirc_s -Bdynamic -ldl -lc /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtend.o /usr/lib/../lib64/crtn.o
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/craype-Fortran-Cray-8.7.input b/Tests/RunCMake/ParseImplicitData/craype-Fortran-Cray-8.7.input
new file mode 100644
index 000000000..4c4e2f483
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/craype-Fortran-Cray-8.7.input
@@ -0,0 +1,52 @@
+CMAKE_LANG=Fortran
+CMAKE_Fortran_COMPILER_ABI=ELF
+CMAKE_Fortran_COMPILER_AR=
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=Cray
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=8.7
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_9c3ab/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_9c3ab.dir/build.make CMakeFiles/cmTC_9c3ab.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI.F.o
+/opt/cray/pe/craype/2.5.15/bin/ftn -em -J. -v -c /usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI.F.o
+
+/opt/cray/pe/cce/8.7.4/cce/x86_64/bin/ftnfe -h cpu=haswell -D__CRAYXC -D__CRAY_HASWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -h network=aries -em -J. -I/opt/cray/pe/cce/8.7.4/cce/x86_64/include/craylibs -I/usr/include -I/usr/include -I/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include -I/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include -I/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I/opt/cray-hss-devel/8.0.0/include -hpl=/tmp/pe_32428//pldir -usystem_mod=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/libmodules.a -usystem_mod=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/libomp.a -usystem_mod=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/omp_lib.a -usystem_mod=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/libopenacc.a -usystem_mod=/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include -usystem_mod=/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include -usystem_mod=/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -usystem_mod=/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -usystem_mod=/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -usystem_mod=/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -usystem_mod=/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include -usystem_mod=/opt/cray/pe/pmi/5.0.14/include -usystem_mod=/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -usystem_mod=/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -usystem_mod=/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -usystem_mod=/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -usystem_mod=/opt/cray-hss-devel/8.0.0/include -ux=x8503 -udv=87000 -ffixed -CZ/tmp/pe_32428/CMakeFortranCompilerABI.T -Cx -CX/tmp/pe_32428/CMakeFortranCompilerABI.xml -hdecompile=/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI. -S /tmp/pe_32428/CMakeFortranCompilerABI_1.s -Oipa3 -uo=/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI.F.o -ufile_id=1 /usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F
+
+/opt/cray/pe/cce/8.7.4/cce/x86_64/bin/optcg /tmp/pe_32428//pldir 1
+
+/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/bin/as -o CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI.F.o --64 /tmp/pe_32428/CMakeFortranCompilerABI_1.s
+rm /tmp/pe_32428/CMakeFortranCompilerABI_1.s
+rm /tmp/pe_32428//pldir/PL_path
+rm /tmp/pe_32428//pldir/iline_1
+rm /tmp/pe_32428//pldir/gline_1
+rm /tmp/pe_32428//pldir/PL_global_data
+rm /tmp/pe_32428//pldir/PL_module_list
+rm /tmp/pe_32428//pldir/CMakeFortranCompilerABI_1.inl
+rmdir /tmp/pe_32428//pldir
+rm /tmp/pe_32428//CMakeFortranCompilerABI_1.xml.Ttmp
+rm /tmp/pe_32428//CMakeFortranCompilerABI.T
+rm /tmp/pe_32428//CMakeFortranCompilerABI_1.cif.Ttmp
+rm /tmp/pe_32428//CMakeFortranCompilerABI.Tfe
+rm /tmp/pe_32428//CMakeFortranCompilerABI.xml
+rmdir /tmp/pe_32428/
+Linking Fortran executable cmTC_9c3ab
+/usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9c3ab.dir/link.txt --verbose=1
+/opt/cray/pe/craype/2.5.15/bin/ftn -v -dynamic CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI.F.o -o cmTC_9c3ab
+
+/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld --eh-frame-hdr -m elf_x86_64 --enable-new-dtags --dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib64//crt1.o /usr/lib64//crti.o /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtbegin.o /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtfastmath.o /opt/cray/pe/cce/8.7.4/cce/x86_64/lib/no_mmap.o CMakeFiles/cmTC_9c3ab.dir/CMakeFortranCompilerABI.F.o -Bdynamic -rpath=/opt/cray/pe/cce/8.7.4/cce/x86_64/lib -L/opt/gcc/6.1.0/snos/lib64 -rpath=/opt/cray/pe/gcc-libs -L/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -L/opt/cray/pe/cce/8.7.4/cce/x86_64/lib/pkgconfig/../ --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -L/usr/lib64 -L/lib64 -rpath=/usr/lib64 -rpath=/lib64 -lrca --as-needed -lsci_cray_mpi_mp --no-as-needed --as-needed -lsci_cray_mp --no-as-needed --as-needed -lmpich_cray --no-as-needed --as-needed -lmpichf90_cray --no-as-needed --as-needed -lpgas-dmapp --no-as-needed -lquadmath -lomp -lcraymp -lmodules -lfi -lcraymath -lf -lu -lcsup --as-needed -latomic --no-as-needed --as-needed -lgfortran --no-as-needed --whole-archive -ltcmalloc_minimal --no-whole-archive -lstdc++ -lpthread --start-group -lc -lcsup -lgcc_eh -lm -lgcc --end-group -L /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0 -L /opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-pc-linux-gnu/..//x86_64-unknown-linux-gnu/lib -EL -o cmTC_9c3ab /opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0//crtend.o /usr/lib64//crtn.o
+
+/opt/cray/pe/cce/8.7.4/binutils/x86_64/bin/objcopy --remove-section=.note.ftn_module_data cmTC_9c3ab
+rm /tmp/pe_32450//pldir/PL_path
+rm /tmp/pe_32450//pldir/PL_global_data
+rm /tmp/pe_32450//pldir/PL_module_list
+rmdir /tmp/pe_32450//pldir
+rmdir /tmp/pe_32450/
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/craype-Fortran-Cray-9.0-hlist-ad.input b/Tests/RunCMake/ParseImplicitData/craype-Fortran-Cray-9.0-hlist-ad.input
new file mode 100644
index 000000000..0ba430a4f
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/craype-Fortran-Cray-9.0-hlist-ad.input
@@ -0,0 +1,53 @@
+CMAKE_LANG=Fortran
+CMAKE_Fortran_COMPILER_ABI=ELF
+CMAKE_Fortran_COMPILER_AR=
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=Cray
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=9.0
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: /home/generic.user/Code/tmp/build/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/gmake cmTC_61c1d/fast && /usr/bin/gmake -f CMakeFiles/cmTC_61c1d.dir/build.make CMakeFiles/cmTC_61c1d.dir/build
+gmake[1]: Entering directory '/home/generic.user/Code/tmp/build/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_61c1d.dir/CMakeFortranCompilerABI.F.o
+/opt/cray/pe/craype/2.6.0/bin/ftn -hlist=ad -em -J. -v -c /home/generic.user/Code/cmake/source/master/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_61c1d.dir/CMakeFortranCompilerABI.F.o
+
+/opt/cray/pe/cce/9.0.0/cce/x86_64/bin/ftnfe -h cpu=broadwell -D__CRAYXC -D__CRAY_BROADWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -h network=aries -hdecomp -em -J. -I/opt/cray/pe/cce/9.0.0/cce/x86_64/include/craylibs -I/usr/include -I/usr/include -I/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/include -I/opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/include -I/opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/xpmem/2.2.15-6.0.7.1_5.8__g7549d06.ari/include -I/opt/cray/dmapp/7.1.1-6.0.7.0_34.3__g5a674e0.ari/include -I/opt/cray/gni-headers/5.0.12.0-6.0.7.0_24.1__g3b1768f.ari/include -I/opt/cray/ugni/6.0.14.0-6.0.7.0_23.1__gea11d3d.ari/include -I/opt/cray/udreg/2.3.2-6.0.7.0_33.18__g5196236.ari/include -I/opt/cray/alps/6.6.43-6.0.7.0_26.4__ga796da3.ari/include -I/opt/cray/wlm_detect/1.3.3-6.0.7.0_47.2__g7109084.ari/include -I/opt/cray/krca/2.2.4-6.0.7.1_5.23__g8505b97.ari/include -I/opt/cray-hss-devel/8.0.0/include -hpl=/lus/scratch/tmp/pe_16260//pldir -Ca -CY "ftn_driver.exe -hcpu=broadwell -hdynamic -D__CRAYXC -D__CRAY_BROADWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -hnetwork=aries -hlist=ad -em -J. -v -c /home/generic.user/Code/cmake/source/master/Modules/CMakeFortranCompilerABI.F -oCMakeFiles/cmTC_61c1d.dir/CMakeFortranCompilerABI.F.o -I/opt/cray/pe/cce/9.0.0/cce/x86_64/include/craylibs -I/usr/include -I/usr/include -I/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/include -I/opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/include -I/opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/xpmem/2.2.15-6.0.7.1_5.8__g7549d06.ari/include -I/opt/cray/dmapp/7.1.1-6.0.7.0_34.3__g5a674e0.ari/include -I/opt/cray/gni-headers/5.0.12.0-6.0.7.0_24.1__g3b1768f.ari/include -I/opt/cray/ugni/6.0.14.0-6.0.7.0_23.1__gea11d3d.ari/include -I/opt/cray/udreg/2.3.2-6.0.7.0_33.18__g5196236.ari/include -I/opt/cray/alps/6.6.43-6.0.7.0_26.4__ga796da3.ari/include -I/opt/cray/wlm_detect/1.3.3-6.0.7.0_47.2__g7109084.ari/include -I/opt/cray/krca/2.2.4-6.0.7.1_5.23__g8505b97.ari/include -I/opt/cray-hss-devel/8.0.0/include" -usystem_mod=/opt/cray/pe/cce/9.0.0/cce/x86_64/lib/libmodules.a -usystem_mod=/opt/cray/pe/cce/9.0.0/cce/x86_64/lib/libomp.a -usystem_mod=/opt/cray/pe/cce/9.0.0/cce/x86_64/lib/omp_lib.a -usystem_mod=/opt/cray/pe/cce/9.0.0/cce/x86_64/lib/libopenacc.a -usystem_mod=/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/include -usystem_mod=/opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/include -usystem_mod=/opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/include -usystem_mod=/opt/cray/pe/pmi/5.0.14/include -usystem_mod=/opt/cray/xpmem/2.2.15-6.0.7.1_5.8__g7549d06.ari/include -usystem_mod=/opt/cray/dmapp/7.1.1-6.0.7.0_34.3__g5a674e0.ari/include -usystem_mod=/opt/cray/gni-headers/5.0.12.0-6.0.7.0_24.1__g3b1768f.ari/include -usystem_mod=/opt/cray/ugni/6.0.14.0-6.0.7.0_23.1__gea11d3d.ari/include -usystem_mod=/opt/cray/udreg/2.3.2-6.0.7.0_33.18__g5196236.ari/include -usystem_mod=/opt/cray/alps/6.6.43-6.0.7.0_26.4__ga796da3.ari/include -usystem_mod=/opt/cray/wlm_detect/1.3.3-6.0.7.0_47.2__g7109084.ari/include -usystem_mod=/opt/cray/krca/2.2.4-6.0.7.1_5.23__g8505b97.ari/include -usystem_mod=/opt/cray-hss-devel/8.0.0/include -usystem_mod=/opt/cray/pe/cce/9.0.0/cce/x86_64/lib/libcraymp.a -udv -ffixed -CZ/lus/scratch/tmp/pe_16260/CMakeFortranCompilerABI.T -Cx -CX/lus/scratch/tmp/pe_16260/CMakeFortranCompilerABI.xml -hdecompile=/home/generic.user/Code/tmp/build/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_61c1d.dir/CMakeFortranCompilerABI. -S /lus/scratch/tmp/pe_16260/CMakeFortranCompilerABI_1.s -Oipa3 -uo=/home/generic.user/Code/tmp/build/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_61c1d.dir/CMakeFortranCompilerABI.F.o -ufile_id=1 /home/generic.user/Code/cmake/source/master/Modules/CMakeFortranCompilerABI.F
+
+/opt/cray/pe/cce/9.0.0/cce/x86_64/bin/optcg /lus/scratch/tmp/pe_16260//pldir 1
+
+/opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-pc-linux-gnu/bin/as -o CMakeFiles/cmTC_61c1d.dir/CMakeFortranCompilerABI.F.o --64 /lus/scratch/tmp/pe_16260/CMakeFortranCompilerABI_1.s
+rm /lus/scratch/tmp/pe_16260/CMakeFortranCompilerABI_1.s
+
+/opt/cray/pe/cce/9.0.0/cce/x86_64/bin/ftnlx -ra -q -o CMakeFiles/cmTC_61c1d.dir/CMakeFortranCompilerABI.lst /home/generic.user/Code/cmake/source/master/Modules/CMakeFortranCompilerABI.F /lus/scratch/tmp/pe_16260/CMakeFortranCompilerABI.T
+rm /lus/scratch/tmp/pe_16260/CMakeFortranCompilerABI.T
+rm /lus/scratch/tmp/pe_16260//CMakeFortranCompilerABI.xml
+rm /lus/scratch/tmp/pe_16260//CMakeFortranCompilerABI_1.cif.Ttmp
+rm /lus/scratch/tmp/pe_16260//CMakeFortranCompilerABI_1.xml.Ttmp
+rm /lus/scratch/tmp/pe_16260//pldir/gline_1
+rm /lus/scratch/tmp/pe_16260//pldir/PL_path
+rm /lus/scratch/tmp/pe_16260//pldir/CMakeFortranCompilerABI_1.inl
+rm /lus/scratch/tmp/pe_16260//pldir/PL_global_data
+rm /lus/scratch/tmp/pe_16260//pldir/iline_1
+rm /lus/scratch/tmp/pe_16260//pldir/PL_module_list
+rmdir /lus/scratch/tmp/pe_16260//pldir
+rm /lus/scratch/tmp/pe_16260//CMakeFortranCompilerABI.Tfe
+rmdir /lus/scratch/tmp/pe_16260/
+Linking Fortran executable cmTC_61c1d
+/home/generic.user/Code/cmake/build/master/bin/cmake -E cmake_link_script CMakeFiles/cmTC_61c1d.dir/link.txt --verbose=1
+/opt/cray/pe/craype/2.6.0/bin/ftn -v -hlist=ad CMakeFiles/cmTC_61c1d.dir/CMakeFortranCompilerABI.F.o -o cmTC_61c1d
+
+/opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-pc-linux-gnu/bin/ld --eh-frame-hdr -m elf_x86_64 --enable-new-dtags --dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib64//crt1.o /usr/lib64//crti.o /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0//crtbegin.o /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0//crtfastmath.o /opt/cray/pe/cce/9.0.0/cce/x86_64/lib/no_mmap.o CMakeFiles/cmTC_61c1d.dir/CMakeFortranCompilerABI.F.o -Bdynamic -rpath=/opt/cray/pe/cce/9.0.0/cce/x86_64/lib -L/opt/gcc/8.1.0/snos/lib64 -rpath=/opt/cray/pe/gcc-libs -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/lib -L/opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/lib -L/opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -L/opt/cray/pe/cce/9.0.0/cce/x86_64/lib/pkgconfig/../ --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -L/usr/lib64 -L/lib64 -rpath=/usr/lib64 -rpath=/lib64 -lrca --as-needed -lmpich_cray_90 --no-as-needed --as-needed -lmpichf90_cray_90 --no-as-needed --as-needed -lsci_cray_mpi --no-as-needed --as-needed -lsci_cray --no-as-needed --as-needed -lpgas-dmapp --no-as-needed -lquadmath -lmodules -lfi -lcraymath -lf -lu -lcsup --as-needed -lgfortran --no-as-needed --whole-archive -ltcmalloc_minimal --no-whole-archive -lcray-c++-rts -lstdc++ -lpthread -L/opt/cray/pe/cce/9.0.0/cce-clang/x86_64/lib/clang/9.0.0/lib/linux --start-group -lc -lcsup -lgcc_eh -lm -lclang_rt.craypgo-x86_64 -lgcc --end-group -L /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0 -L /opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-pc-linux-gnu/..//x86_64-unknown-linux-gnu/lib -EL -o cmTC_61c1d /opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0//crtend.o /usr/lib64//crtn.o
+
+/opt/cray/pe/cce/9.0.0/binutils/x86_64/bin/objcopy --remove-section=.note.ftn_module_data cmTC_61c1d
+rm /lus/scratch/tmp/pe_16273//pldir/PL_path
+rm /lus/scratch/tmp/pe_16273//pldir/PL_global_data
+rm /lus/scratch/tmp/pe_16273//pldir/PL_module_list
+rmdir /lus/scratch/tmp/pe_16273//pldir
+rmdir /lus/scratch/tmp/pe_16273/
+gmake[1]: Leaving directory '/home/generic.user/Code/tmp/build/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/craype-Fortran-GNU-7.3.0.input b/Tests/RunCMake/ParseImplicitData/craype-Fortran-GNU-7.3.0.input
new file mode 100644
index 000000000..bee298c37
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/craype-Fortran-GNU-7.3.0.input
@@ -0,0 +1,83 @@
+CMAKE_LANG=Fortran
+CMAKE_Fortran_COMPILER_ABI=
+CMAKE_Fortran_COMPILER_AR=/usr/bin/gcc-ar
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=GNU
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=/usr/bin/gcc-ranlib
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=7.3.0
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_390ef/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_390ef.dir/build.make CMakeFiles/cmTC_390ef.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o
+/opt/cray/pe/craype/2.5.15/bin/ftn -v -c /usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o
+Using built-in specs.
+COLLECT_GCC=/opt/gcc/7.3.0/bin/../snos/bin/gfortran
+Target: x86_64-suse-linux
+Configured with: ../cray-gcc-7.3.0-201801270210.d61239fc6000b/configure --prefix=/opt/gcc/7.3.0/snos --disable-nls --libdir=/opt/gcc/7.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.3.0/snos/include/g++ --with-slibdir=/opt/gcc/7.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib
+Thread model: posix
+gcc version 7.3.0 20180125 (Cray Inc.) (GCC)
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-D' '__TARGET_LINUX__' '-v' '-c' '-o' 'CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include'
+ /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/f951 /usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -ffixed-form -cpp=/tmp/ccxLli6i.f90 -quiet -v -I /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include -D __CRAYXC -D __CRAY_HASWELL -D __CRAYXT_COMPUTE_LINUX_TARGET -D __TARGET_LINUX__ /usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -quiet -dumpbase CMakeFortranCompilerABI.F -march=core-avx2 -auxbase-strip CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o -version -fintrinsic-modules-path /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/finclude -o /tmp/ccqY0cGk.s
+GNU Fortran (GCC) version 7.3.0 20180125 (Cray Inc.) (x86_64-suse-linux)
+ compiled by GNU C version 7.3.0 20180125 (Cray Inc.), GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3, isl version isl-0.15-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring nonexistent directory "/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../x86_64-suse-linux/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include
+ /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include
+ /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include
+ /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include
+ /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include
+ /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include
+ /opt/cray/pe/pmi/5.0.14/include
+ /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include
+ /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include
+ /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include
+ /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include
+ /opt/cray-hss-devel/8.0.0/include
+ /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/finclude
+ /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include
+ /usr/local/include
+ /opt/gcc/7.3.0/snos/include
+ /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include-fixed
+ /usr/include
+End of search list.
+GNU Fortran2008 (GCC) version 7.3.0 20180125 (Cray Inc.) (x86_64-suse-linux)
+ compiled by GNU C version 7.3.0 20180125 (Cray Inc.), GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3, isl version isl-0.15-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-D' '__TARGET_LINUX__' '-v' '-c' '-o' 'CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include'
+ as -v -I /opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I /opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I /opt/cray/pe/pmi/5.0.14/include -I /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I /opt/cray-hss-devel/8.0.0/include --64 -o CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o /tmp/ccqY0cGk.s
+GNU assembler version 2.31.1 (x86_64-suse-linux) using BFD version (GNU Binutils SUSE Linux Enterprise 12) 2.31.1.20180828-9.26
+COMPILER_PATH=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/
+LIBRARY_PATH=/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-D' '__TARGET_LINUX__' '-v' '-c' '-o' 'CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include'
+Linking Fortran executable cmTC_390ef
+/usr/projects/hpcsoft/cle6.0/common/cmake/3.10.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_390ef.dir/link.txt --verbose=1
+/opt/cray/pe/craype/2.5.15/bin/ftn -v -dynamic CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o -o cmTC_390ef
+Driving: /opt/gcc/7.3.0/bin/../snos/bin/gfortran -march=core-avx2 -D__CRAYXC -D__CRAY_HASWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -D__TARGET_LINUX__ -v CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o -o cmTC_390ef -Wl,-rpath=/opt/cray/pe/gcc-libs -Wl,-Bdynamic -I/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include -I/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include -I/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I/opt/cray-hss-devel/8.0.0/include -L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -Wl,--no-as-needed,-lAtpSigHandler,-lAtpSigHCommData -Wl,--undefined=_ATP_Data_Globals -Wl,--undefined=__atpHandlerInstall -lrca -Wl,--as-needed,-lsci_gnu_71_mpi,--no-as-needed -Wl,--as-needed,-lsci_gnu_71,--no-as-needed -Wl,--as-needed,-lmpich_gnu_71,--no-as-needed -Wl,--as-needed,-lmpichf90_gnu_71,--no-as-needed -Wl,--as-needed,-lgfortran,-lquadmath,--no-as-needed -Wl,--as-needed,-lpthread,--no-as-needed -l gfortran -l m -shared-libgcc
+Using built-in specs.
+COLLECT_GCC=/opt/gcc/7.3.0/bin/../snos/bin/gfortran
+COLLECT_LTO_WRAPPER=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/lto-wrapper
+Target: x86_64-suse-linux
+Configured with: ../cray-gcc-7.3.0-201801270210.d61239fc6000b/configure --prefix=/opt/gcc/7.3.0/snos --disable-nls --libdir=/opt/gcc/7.3.0/snos/lib --enable-languages=c,c++,fortran --with-gxx-include-dir=/opt/gcc/7.3.0/snos/include/g++ --with-slibdir=/opt/gcc/7.3.0/snos/lib --with-system-zlib --enable-shared --enable-__cxa_atexit --build=x86_64-suse-linux --with-ppl --with-cloog --disable-multilib
+Thread model: posix
+gcc version 7.3.0 20180125 (Cray Inc.) (GCC)
+Reading specs from /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/libgfortran.spec
+rename spec lib to liborig
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_390ef' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-shared-libgcc'
+COMPILER_PATH=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/
+LIBRARY_PATH=/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_390ef' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-shared-libgcc'
+ /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/collect2 -plugin /opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/liblto_plugin.so -plugin-opt=/opt/gcc/7.3.0/snos/libexec/gcc/x86_64-suse-linux/7.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/cc1AyzSl.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lquadmath -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cmTC_390ef /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/crtbegin.o -L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/../../.. CMakeFiles/cmTC_390ef.dir/CMakeFortranCompilerABI.F.o -rpath=/opt/cray/pe/gcc-libs -Bdynamic --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -lrca --as-needed -lsci_gnu_71_mpi --no-as-needed --as-needed -lsci_gnu_71 --no-as-needed --as-needed -lmpich_gnu_71 --no-as-needed --as-needed -lmpichf90_gnu_71 --no-as-needed --as-needed -lgfortran -lquadmath --no-as-needed --as-needed -lpthread --no-as-needed -lgfortran -lm -lgcc_s -lgcc -lquadmath -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/crtend.o /usr/lib/../lib64/crtn.o
+COLLECT_GCC_OPTIONS='-march=core-avx2' '-D' '__CRAYXC' '-D' '__CRAY_HASWELL' '-D' '__CRAYXT_COMPUTE_LINUX_TARGET' '-D' '__TARGET_LINUX__' '-v' '-o' 'cmTC_390ef' '-I' '/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include' '-I' '/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include' '-I' '/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include' '-I' '/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include' '-I' '/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include' '-I' '/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include' '-I' '/opt/cray/pe/pmi/5.0.14/include' '-I' '/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include' '-I' '/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include' '-I' '/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include' '-I' '/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include' '-I' '/opt/cray-hss-devel/8.0.0/include' '-L/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/dmapp/default/lib64' '-L/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib' '-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64' '-L/opt/cray/pe/atp/2.1.3/libApp' '-shared-libgcc'
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/craype-Fortran-Intel-18.0.2.20180210.input b/Tests/RunCMake/ParseImplicitData/craype-Fortran-Intel-18.0.2.20180210.input
new file mode 100644
index 000000000..4cdff74ec
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/craype-Fortran-Intel-18.0.2.20180210.input
@@ -0,0 +1,80 @@
+CMAKE_LANG=Fortran
+CMAKE_Fortran_COMPILER_ABI=ELF
+CMAKE_Fortran_COMPILER_AR=
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=Intel
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=18.0.2.20180210
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_7523d/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_7523d.dir/build.make CMakeFiles/cmTC_7523d.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o
+/opt/cray/pe/craype/2.5.15/bin/ftn -v -c /usr/share/cmake/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o
+ifort version 18.0.2
+/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/fpp -D__INTEL_COMPILER=1800 -D__INTEL_COMPILER_UPDATE=2 -D__unix__ -D__unix -D__linux__ -D__linux -D__gnu_linux__ -Dunix -Dlinux -D__ELF__ -D__x86_64 -D__x86_64__ -D__amd64 -D__amd64__ -D__INTEL_COMPILER_BUILD_DATE=20180210 -D__INTEL_OFFLOAD -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE2_MATH__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__ -D__SSE__ -D__SSE_MATH__ -D__MMX__ -D__AVX__ -D__AVX_I__ -D__AVX2__ -D__FMA__ -D__CRAYXC -D__CRAY_HASWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -I. -I/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include -I/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include -I/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I/opt/cray-hss-devel/8.0.0/include -I/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include -I/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64 -I/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc -I/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include -I/usr/local/include -I/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include -I/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed -I/opt/gcc/6.3.0/snos/include/ -I/usr/include -fixed -4Ycpp -4Ncvf -f_com=yes -MX /usr/share/cmake/Modules/CMakeFortranCompilerABI.F /tmp/ifortjocHCJ.i
+#include "..." search starts here:
+#include <...> search starts here:
+ .
+ /opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include
+ /opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include
+ /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include
+ /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include
+ /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include
+ /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include
+ /opt/cray/pe/pmi/5.0.14/include
+ /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include
+ /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include
+ /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include
+ /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include
+ /opt/cray-hss-devel/8.0.0/include
+ /opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include
+ /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64
+ /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc
+ /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include
+ /usr/local/include
+ /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include
+ /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed
+ /opt/gcc/6.3.0/snos/include/
+ /usr/include
+End of search list.
+/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/fortcom -D__INTEL_COMPILER=1800 -D__INTEL_COMPILER_UPDATE=2 -D__unix__ -D__unix -D__linux__ -D__linux -D__gnu_linux__ -Dunix -Dlinux -D__ELF__ -D__x86_64 -D__x86_64__ -D__amd64 -D__amd64__ -D__INTEL_COMPILER_BUILD_DATE=20180210 -D__INTEL_OFFLOAD -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE2_MATH__ -D__SSE3__ -D__SSSE3__ -D__SSE4_1__ -D__SSE4_2__ -D__SSE__ -D__SSE_MATH__ -D__MMX__ -D__AVX__ -D__AVX_I__ -D__AVX2__ -D__FMA__ -mGLOB_pack_sort_init_list -I/usr/share/cmake/Modules -I. -I/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include -I/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include -I/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I/opt/cray-hss-devel/8.0.0/include -I/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include -I/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64 -I/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc -I/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include -I/usr/local/include -I/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include -I/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed -I/opt/gcc/6.3.0/snos/include/ -I/usr/include -D__CRAYXC -D__CRAY_HASWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -O2 "-reentrancy none" -simd -offload_host -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mGLOB_source_language=GLOB_SOURCE_LANGUAGE_F90 -mP2OPT_static_promotion -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=630 "-mGLOB_options_string=-I/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include -I/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include -I/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I/opt/cray-hss-devel/8.0.0/include -xCORE-AVX2 -static -D__CRAYXC -D__CRAY_HASWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -v -c -o CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/ifortYH2Bi3as_.s -mIPOPT_activate -mIPOPT_lite -mGLOB_instruction_tuning=0x0 -mGLOB_uarch_tuning=0x0 -mGLOB_product_id_code=0x22006d90 -mCG_bnl_movbe=T -mGLOB_extended_instructions=0x4000 -mGLOB_advanced_optim=TRUE -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=ifort0690104118gDFZUy -mP2OPT_hlo_level=2 -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_lto_object_enabled -mIPOPT_lto_object_value=1 -mIPOPT_obj_output_file_name=CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o -mIPOPT_whole_archive_fixup_file_name=/tmp/ifortwarch8cLx6A -mGLOB_linker_version=2.31.1.20180828 -mGLOB_driver_tempfile_name=/tmp/iforttempfiledtmF0m -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_FORTRAN -mP1OPT_source_file_name=/usr/share/cmake/Modules/CMakeFortranCompilerABI.F -mP1OPT_full_source_file_name=/usr/share/cmake/Modules/CMakeFortranCompilerABI.F -mP2OPT_symtab_type_copy=true /tmp/ifortjocHCJ.i
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/share/cmake/Modules
+ .
+ /opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include
+ /opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include
+ /opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include
+ /opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include
+ /opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include
+ /opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include
+ /opt/cray/pe/pmi/5.0.14/include
+ /opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include
+ /opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include
+ /opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include
+ /opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include
+ /opt/cray-hss-devel/8.0.0/include
+ /opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include
+ /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64
+ /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc
+ /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include
+ /usr/local/include
+ /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include
+ /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed
+ /opt/gcc/6.3.0/snos/include/
+ /usr/include
+End of search list.
+Linking Fortran executable cmTC_7523d
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_7523d.dir/link.txt --verbose=1
+/opt/cray/pe/craype/2.5.15/bin/ftn -v CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o -o cmTC_7523d
+ifort version 18.0.2
+/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/fortcom -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mGLOB_source_language=GLOB_SOURCE_LANGUAGE_F90 -mP2OPT_static_promotion -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=630 "-mGLOB_options_string=-I/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include -I/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include -I/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include -I/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include -I/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include -I/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include -I/opt/cray/pe/pmi/5.0.14/include -I/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include -I/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include -I/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include -I/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include -I/opt/cray-hss-devel/8.0.0/include -xCORE-AVX2 -static -D__CRAYXC -D__CRAY_HASWELL -D__CRAYXT_COMPUTE_LINUX_TARGET -v -o cmTC_7523d -L/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64 -L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64 -L/opt/cray/pe/pmi/5.0.14/lib64 -L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64 -L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64 -Wl,-Ttext-segment=0x20000000,-zmax-page-size=0x20000000 -Wl,--whole-archive,-lhugetlbfs,--no-whole-archive -Wl,--no-as-needed,-lAtpSigHandler,-lAtpSigHCommData -Wl,--undefined=_ATP_Data_Globals -Wl,--undefined=__atpHandlerInstall -lpthread -lmpichf90_intel -lrt -lugni -lpmi -lm -lpthread -ldl -lsci_intel_mpi -lsci_intel -lm -ldl -lmpich_intel -lrt -lugni -lpthread -lpmi -lm -ldl -lpmi -lpthread -lalpslli -lpthread -lwlm_detect -lalpsutil -lpthread -lrca -lxpmem -lugni -lpthread -ludreg -lsci_intel -lm -lpthread -ldl -lhugetlbfs -Wl,--as-needed,-limf,--no-as-needed -Wl,--as-needed,-lm,--no-as-needed -Wl,--as-needed,-lpthread,--no-as-needed" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/ifort3JZMSVas_.s -mGLOB_dashboard_use_source_name -mIPOPT_activate -mGLOB_product_id_code=0x22006d90 -mGLOB_extended_instructions=0x4000 -mGLOB_advanced_optim=TRUE -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mGLOB_opt_report_use_source_name -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=ifort0690373519HAIHNw -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_link -mIPOPT_ipo_activate -mIPOPT_mo_activate -mIPOPT_source_files_list=/tmp/ifortslis6v0DlA -mIPOPT_mo_global_data -mIPOPT_link_script_file=/tmp/ifortscriptsKB8Qm "-mIPOPT_cmdline_link="/usr/lib/../lib64/crt1.o" "/usr/lib/../lib64/crti.o" "/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtbeginT.o" "--build-id" "-static" "-m" "elf_x86_64" "-L/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/lib" "-L/opt/cray/dmapp/default/lib64" "-L/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/lib" "-L/opt/cray/dmapp/default/lib64" "-L/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/lib" "-L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64" "-L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64" "-L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64" "-L/opt/cray/pe/pmi/5.0.14/lib64" "-L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64" "-L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64" "-L/opt/cray/pe/atp/2.1.3/libApp" "-L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64" "-o" "cmTC_7523d" "/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin/for_main.o" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64/" "-L/lib/../lib64" "-L/lib/../lib64/" "-L/usr/lib/../lib64" "-L/usr/lib/../lib64/" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64/" "-L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../" "-L/lib64" "-L/lib/" "-L/usr/lib64" "-L/usr/lib" "CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o" "-Ttext-segment=0x20000000" "-zmax-page-size=0x20000000" "--whole-archive" "-lhugetlbfs" "--no-whole-archive" "--no-as-needed" "-lAtpSigHandler" "-lAtpSigHCommData" "--undefined=_ATP_Data_Globals" "--undefined=__atpHandlerInstall" "-lpthread" "-lmpichf90_intel" "-lrt" "-lugni" "-lpmi" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-limf" "-lm" "-lpthread" "-ldl" "-lsci_intel_mpi" "-lsci_intel" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-limf" "-lm" "-ldl" "-lmpich_intel" "-lrt" "-lugni" "-lpthread" "-lpmi" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-limf" "-lm" "-ldl" "-lpmi" "-lpthread" "-lalpslli" "-lpthread" "-lwlm_detect" "-lalpsutil" "-lpthread" "-lrca" "-lxpmem" "-lugni" "-lpthread" "-ludreg" "-lsci_intel" "-L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin" "-limf" "-lm" "-lpthread" "-ldl" "-lhugetlbfs" "--as-needed" "-limf" "--no-as-needed" "--as-needed" "-lm" "--no-as-needed" "--as-needed" "-lpthread" "--no-as-needed" "-lifport" "-lifcore" "-limf" "-lsvml" "-lm" "-lipgo" "-lirc" "-lsvml" "-lc" "-lgcc" "-lgcc_eh" "-lirc_s" "-ldl" "-lc" "/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtend.o" "/usr/lib/../lib64/crtn.o"" -mIPOPT_il_in_obj -mIPOPT_ipo_activate_warn=FALSE -mIPOPT_obj_output_file_name=/tmp/ipo_ifort5KgIiT.o -mIPOPT_whole_archive_fixup_file_name=/tmp/ifortwarchltBXsh -mGLOB_linker_version=2.31.1.20180828 -mGLOB_driver_tempfile_name=/tmp/iforttempfilesugt03 -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=/tmp/ipo_ifort5KgIiT.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_NONE -mP1OPT_source_file_name=ipo_out.f -mP2OPT_symtab_type_copy=true CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o -mIPOPT_object_files=T -mIPOPT_assembly_files=/tmp/ifortalisCY2Fjs -mIPOPT_generated_tempfiles=/tmp/ifortelisXEqaPe -mIPOPT_embedded_object_base_name=/tmp/iforteobjRoVEk1 -mIPOPT_cmdline_link_new_name=/tmp/ifortllisJHg9PN
+ld /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtbeginT.o --build-id -static -m elf_x86_64 -L/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/lib -L/opt/cray/dmapp/default/lib64 -L/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/lib -L/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64 -L/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64 -L/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64 -L/opt/cray/pe/pmi/5.0.14/lib64 -L/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64 -L/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64 -L/opt/cray/pe/atp/2.1.3/libApp -L/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64 -o cmTC_7523d /opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin/for_main.o -L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64 -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/ -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64 -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../../lib64/ -L/lib/../lib64 -L/lib/../lib64/ -L/usr/lib/../lib64 -L/usr/lib/../lib64/ -L/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64/ -L/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/../../../ -L/lib64 -L/lib/ -L/usr/lib64 -L/usr/lib CMakeFiles/cmTC_7523d.dir/CMakeFortranCompilerABI.F.o -Ttext-segment=0x20000000 -zmax-page-size=0x20000000 --whole-archive -lhugetlbfs --no-whole-archive --no-as-needed -lAtpSigHandler -lAtpSigHCommData --undefined=_ATP_Data_Globals --undefined=__atpHandlerInstall -lpthread -lmpichf90_intel -lrt -lugni -lpmi -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -limf -lm -lpthread -ldl -lsci_intel_mpi -lsci_intel -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -limf -lm -ldl -lmpich_intel -lrt -lugni -lpthread -lpmi -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -limf -lm -ldl -lpmi -lpthread -lalpslli -lpthread -lwlm_detect -lalpsutil -lpthread -lrca -lxpmem -lugni -lpthread -ludreg -lsci_intel -L/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin -limf -lm -lpthread -ldl -lhugetlbfs --as-needed -limf --no-as-needed --as-needed -lm --no-as-needed --as-needed -lpthread --no-as-needed -lifport -lifcore -limf -lsvml -lm -lipgo -lirc -lsvml -lc -lgcc -lgcc_eh -lirc_s -ldl -lc /opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/crtend.o /usr/lib/../lib64/crtn.o
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/darwin-C-AppleClang-8.0.0.8000042.input b/Tests/RunCMake/ParseImplicitData/darwin-C-AppleClang-8.0.0.8000042.input
new file mode 100644
index 000000000..4bc26bcba
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/darwin-C-AppleClang-8.0.0.8000042.input
@@ -0,0 +1,50 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=AppleClang
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=8.0.0.8000042
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_0c33e/fast"
+/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_0c33e.dir/build.make CMakeFiles/cmTC_0c33e.dir/build
+Building C object CMakeFiles/cmTC_0c33e.dir/CMakeCCompilerABI.c.o
+/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -v -Wl,-v -o CMakeFiles/cmTC_0c33e.dir/CMakeCCompilerABI.c.o -c /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCCompilerABI.c
+Apple LLVM version 8.0.0 (clang-800.0.42.1)
+Target: x86_64-apple-darwin15.6.0
+Thread model: posix
+InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
+clang: warning: -Wl,-v: 'linker' input unused
+ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCCompilerABI.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.2 -v -dwarf-column-info -debugger-tuning=lldb -coverage-file /private/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_0c33e.dir/CMakeCCompilerABI.c.o -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0 -fdebug-compilation-dir /private/tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -o CMakeFiles/cmTC_0c33e.dir/CMakeCCompilerABI.c.o -x c /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCCompilerABI.c
+clang -cc1 version 8.0.0 (clang-800.0.42.1) default target x86_64-apple-darwin15.6.0
+ignoring nonexistent directory "/usr/local/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/include
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
+ /usr/include
+ /System/Library/Frameworks (framework directory)
+ /Library/Frameworks (framework directory)
+End of search list.
+Linking C executable cmTC_0c33e
+/usr/local/pkg.1804/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0c33e.dir/link.txt --verbose=1
+/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_0c33e.dir/CMakeCCompilerABI.c.o -o cmTC_0c33e
+Apple LLVM version 8.0.0 (clang-800.0.42.1)
+Target: x86_64-apple-darwin15.6.0
+Thread model: posix
+InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
+ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o cmTC_0c33e -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_0c33e.dir/CMakeCCompilerABI.c.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.osx.a
+@(#)PROGRAM:ld PROJECT:ld64-274.2
+configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
+Library search paths:
+ /usr/lib
+ /usr/local/lib
+Framework search paths:
+ /Library/Frameworks/
+ /System/Library/Frameworks/
diff --git a/Tests/RunCMake/ParseImplicitData/darwin-CXX-AppleClang-8.0.0.8000042.input b/Tests/RunCMake/ParseImplicitData/darwin-CXX-AppleClang-8.0.0.8000042.input
new file mode 100644
index 000000000..907a92e24
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/darwin-CXX-AppleClang-8.0.0.8000042.input
@@ -0,0 +1,52 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=AppleClang
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=8.0.0.8000042
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_b7e96/fast"
+/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_b7e96.dir/build.make CMakeFiles/cmTC_b7e96.dir/build
+Building CXX object CMakeFiles/cmTC_b7e96.dir/CMakeCXXCompilerABI.cpp.o
+/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -v -Wl,-v -o CMakeFiles/cmTC_b7e96.dir/CMakeCXXCompilerABI.cpp.o -c /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp
+Apple LLVM version 8.0.0 (clang-800.0.42.1)
+Target: x86_64-apple-darwin15.6.0
+Thread model: posix
+InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
+clang: warning: -Wl,-v: 'linker' input unused
+ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCXXCompilerABI.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.2 -v -dwarf-column-info -debugger-tuning=lldb -coverage-file /private/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_b7e96.dir/CMakeCXXCompilerABI.cpp.o -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /private/tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -o CMakeFiles/cmTC_b7e96.dir/CMakeCXXCompilerABI.cpp.o -x c++ /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp
+clang -cc1 version 8.0.0 (clang-800.0.42.1) default target x86_64-apple-darwin15.6.0
+ignoring nonexistent directory "/usr/include/c++/v1"
+ignoring nonexistent directory "/usr/local/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/include
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
+ /usr/include
+ /System/Library/Frameworks (framework directory)
+ /Library/Frameworks (framework directory)
+End of search list.
+Linking CXX executable cmTC_b7e96
+/usr/local/pkg.1804/bin/cmake -E cmake_link_script CMakeFiles/cmTC_b7e96.dir/link.txt --verbose=1
+/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_b7e96.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_b7e96
+Apple LLVM version 8.0.0 (clang-800.0.42.1)
+Target: x86_64-apple-darwin15.6.0
+Thread model: posix
+InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
+ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o cmTC_b7e96 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_b7e96.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.osx.a
+@(#)PROGRAM:ld PROJECT:ld64-274.2
+configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
+Library search paths:
+ /usr/lib
+ /usr/local/lib
+Framework search paths:
+ /Library/Frameworks/
+ /System/Library/Frameworks/
diff --git a/Tests/RunCMake/ParseImplicitData/darwin_nostdinc-C-AppleClang-8.0.0.8000042.input b/Tests/RunCMake/ParseImplicitData/darwin_nostdinc-C-AppleClang-8.0.0.8000042.input
new file mode 100644
index 000000000..effaedf55
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/darwin_nostdinc-C-AppleClang-8.0.0.8000042.input
@@ -0,0 +1,44 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=AppleClang
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=8.0.0.8000042
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_ba7aa/fast"
+/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_ba7aa.dir/build.make CMakeFiles/cmTC_ba7aa.dir/build
+Building C object CMakeFiles/cmTC_ba7aa.dir/CMakeCCompilerABI.c.o
+/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -nostdinc -v -Wl,-v -o CMakeFiles/cmTC_ba7aa.dir/CMakeCCompilerABI.c.o -c /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCCompilerABI.c
+Apple LLVM version 8.0.0 (clang-800.0.42.1)
+Target: x86_64-apple-darwin15.6.0
+Thread model: posix
+InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
+clang: warning: -Wl,-v: 'linker' input unused
+ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCCompilerABI.c -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.2 -v -dwarf-column-info -debugger-tuning=lldb -coverage-file /private/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_ba7aa.dir/CMakeCCompilerABI.c.o -nostdsysteminc -nobuiltininc -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0 -fdebug-compilation-dir /private/tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fmax-type-align=16 -fdiagnostics-show-option -o CMakeFiles/cmTC_ba7aa.dir/CMakeCCompilerABI.c.o -x c /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCCompilerABI.c
+clang -cc1 version 8.0.0 (clang-800.0.42.1) default target x86_64-apple-darwin15.6.0
+#include "..." search starts here:
+End of search list.
+Linking C executable cmTC_ba7aa
+/usr/local/pkg.1804/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ba7aa.dir/link.txt --verbose=1
+/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -nostdinc -v -Wl,-v -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_ba7aa.dir/CMakeCCompilerABI.c.o -o cmTC_ba7aa
+Apple LLVM version 8.0.0 (clang-800.0.42.1)
+Target: x86_64-apple-darwin15.6.0
+Thread model: posix
+InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
+clang: warning: argument unused during compilation: '-nostdinc'
+ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o cmTC_ba7aa -v -search_paths_first -headerpad_max_install_names CMakeFiles/cmTC_ba7aa.dir/CMakeCCompilerABI.c.o -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.osx.a
+@(#)PROGRAM:ld PROJECT:ld64-274.2
+configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
+Library search paths:
+ /usr/lib
+ /usr/local/lib
+Framework search paths:
+ /Library/Frameworks/
+ /System/Library/Frameworks/
diff --git a/Tests/RunCMake/ParseImplicitData/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.input b/Tests/RunCMake/ParseImplicitData/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.input
new file mode 100644
index 000000000..5504e9472
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.input
@@ -0,0 +1,44 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=AppleClang
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=8.0.0.8000042
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_638bd/fast"
+/Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_638bd.dir/build.make CMakeFiles/cmTC_638bd.dir/build
+Building CXX object CMakeFiles/cmTC_638bd.dir/CMakeCXXCompilerABI.cpp.o
+/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -nostdinc -v -Wl,-v -o CMakeFiles/cmTC_638bd.dir/CMakeCXXCompilerABI.cpp.o -c /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp
+Apple LLVM version 8.0.0 (clang-800.0.42.1)
+Target: x86_64-apple-darwin15.6.0
+Thread model: posix
+InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
+clang: warning: -Wl,-v: 'linker' input unused
+ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.11.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCXXCompilerABI.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 274.2 -v -dwarf-column-info -debugger-tuning=lldb -coverage-file /private/tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_638bd.dir/CMakeCXXCompilerABI.cpp.o -nostdsysteminc -nobuiltininc -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /private/tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.11.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -o CMakeFiles/cmTC_638bd.dir/CMakeCXXCompilerABI.cpp.o -x c++ /usr/local/pkg.1804/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp
+clang -cc1 version 8.0.0 (clang-800.0.42.1) default target x86_64-apple-darwin15.6.0
+#include "..." search starts here:
+End of search list.
+Linking CXX executable cmTC_638bd
+/usr/local/pkg.1804/bin/cmake -E cmake_link_script CMakeFiles/cmTC_638bd.dir/link.txt --verbose=1
+/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -nostdinc -v -Wl,-v -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_638bd.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_638bd
+Apple LLVM version 8.0.0 (clang-800.0.42.1)
+Target: x86_64-apple-darwin15.6.0
+Thread model: posix
+InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
+clang: warning: argument unused during compilation: '-nostdinc'
+ "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.11.0 -o cmTC_638bd -v -search_paths_first -headerpad_max_install_names CMakeFiles/cmTC_638bd.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/8.0.0/lib/darwin/libclang_rt.osx.a
+@(#)PROGRAM:ld PROJECT:ld64-274.2
+configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
+Library search paths:
+ /usr/lib
+ /usr/local/lib
+Framework search paths:
+ /Library/Frameworks/
+ /System/Library/Frameworks/
diff --git a/Tests/RunCMake/ParseImplicitData/freebsd-C-Clang-3.3.0.input b/Tests/RunCMake/ParseImplicitData/freebsd-C-Clang-3.3.0.input
new file mode 100644
index 000000000..81626f932
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/freebsd-C-Clang-3.3.0.input
@@ -0,0 +1,38 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=Clang
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=3.3.0
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/local/bin/gmake" "cmTC_0c44b/fast"
+/usr/local/bin/gmake -f CMakeFiles/cmTC_0c44b.dir/build.make CMakeFiles/cmTC_0c44b.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_0c44b.dir/CMakeCCompilerABI.c.o
+/usr/bin/cc -v -o CMakeFiles/cmTC_0c44b.dir/CMakeCCompilerABI.c.o -c /usr/local/share/cmake-3.7/Modules/CMakeCCompilerABI.c
+FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610
+Target: x86_64-unknown-freebsd10.0
+Thread model: posix
+ "/usr/bin/cc" -cc1 -triple x86_64-unknown-freebsd10.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name CMakeCCompilerABI.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -coverage-file /tmp/ii/CMakeFiles/cmTC_0c44b.dir/CMakeCCompilerABI.c.o -resource-dir /usr/bin/../lib/clang/3.3 -fdebug-compilation-dir /tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -mstackrealign -fobjc-runtime=gnustep -fobjc-default-synthesize-properties -fdiagnostics-show-option -backend-option -vectorize-loops -o CMakeFiles/cmTC_0c44b.dir/CMakeCCompilerABI.c.o -x c /usr/local/share/cmake-3.7/Modules/CMakeCCompilerABI.c
+clang -cc1 version 3.3 based upon LLVM 3.3 default target x86_64-unknown-freebsd10.0
+ignoring nonexistent directory "/usr/bin/../lib/clang/3.3/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/include/clang/3.3
+ /usr/include
+End of search list.
+Linking C executable cmTC_0c44b
+/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_0c44b.dir/link.txt --verbose=1
+/usr/bin/cc -v CMakeFiles/cmTC_0c44b.dir/CMakeCCompilerABI.c.o -o cmTC_0c44b
+FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610
+Target: x86_64-unknown-freebsd10.0
+Thread model: posix
+ "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o cmTC_0c44b /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib CMakeFiles/cmTC_0c44b.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/freebsd-CXX-Clang-3.3.0.input b/Tests/RunCMake/ParseImplicitData/freebsd-CXX-Clang-3.3.0.input
new file mode 100644
index 000000000..1f7758b17
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/freebsd-CXX-Clang-3.3.0.input
@@ -0,0 +1,45 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=Clang
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=3.3.0
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/local/bin/gmake" "cmTC_c3442/fast"
+/usr/local/bin/gmake -f CMakeFiles/cmTC_c3442.dir/build.make CMakeFiles/cmTC_c3442.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_c3442.dir/CMakeCXXCompilerABI.cpp.o
+/usr/bin/CC -v -o CMakeFiles/cmTC_c3442.dir/CMakeCXXCompilerABI.cpp.o -c /usr/local/share/cmake-3.7/Modules/CMakeCXXCompilerABI.cpp
+FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610
+Target: x86_64-unknown-freebsd10.0
+Thread model: posix
+ "/usr/bin/CC" -cc1 -triple x86_64-unknown-freebsd10.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name CMakeCXXCompilerABI.cpp -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -coverage-file /tmp/ii/CMakeFiles/cmTC_c3442.dir/CMakeCXXCompilerABI.cpp.o -resource-dir /usr/bin/../lib/clang/3.3 -internal-isystem /usr/include/c++/v1 -fdeprecated-macro -fdebug-compilation-dir /tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -mstackrealign -fobjc-runtime=gnustep -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -backend-option -vectorize-loops -o CMakeFiles/cmTC_c3442.dir/CMakeCXXCompilerABI.cpp.o -x c++ /usr/local/share/cmake-3.7/Modules/CMakeCXXCompilerABI.cpp
+clang -cc1 version 3.3 based upon LLVM 3.3 default target x86_64-unknown-freebsd10.0
+ignoring nonexistent directory "/usr/include/c++/4.2/backward/backward"
+ignoring nonexistent directory "/usr/bin/../lib/clang/3.3/include"
+ignoring duplicate directory "/usr/include/c++/4.2"
+ignoring duplicate directory "/usr/include/c++/4.2/backward"
+ignoring duplicate directory "/usr/include/c++/4.2/backward"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/include/c++/v1
+ /usr/include/c++/4.2
+ /usr/include/c++/4.2/backward
+ /usr/include/clang/3.3
+ /usr/include
+End of search list.
+Linking CXX executable cmTC_c3442
+/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_c3442.dir/link.txt --verbose=1
+/usr/bin/CC -v CMakeFiles/cmTC_c3442.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_c3442
+FreeBSD clang version 3.3 (tags/RELEASE_33/final 183502) 20130610
+Target: x86_64-unknown-freebsd10.0
+Thread model: posix
+ "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o cmTC_c3442 /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib CMakeFiles/cmTC_c3442.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/freebsd-Fortran-GNU-4.6.4.input b/Tests/RunCMake/ParseImplicitData/freebsd-Fortran-GNU-4.6.4.input
new file mode 100644
index 000000000..8a5d7411a
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/freebsd-Fortran-GNU-4.6.4.input
@@ -0,0 +1,78 @@
+CMAKE_LANG=Fortran
+CMAKE_Fortran_COMPILER_ABI=
+CMAKE_Fortran_COMPILER_AR=
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=GNU
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=4.6.4
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/local/bin/gmake" "cmTC_9ec75/fast"
+/usr/local/bin/gmake -f CMakeFiles/cmTC_9ec75.dir/build.make CMakeFiles/cmTC_9ec75.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o
+/usr/local/bin/gfortran46 -v -c /usr/local/share/cmake-3.7/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o
+Using built-in specs.
+COLLECT_GCC=/usr/local/bin/gfortran46
+COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/lto-wrapper
+Target: x86_64-portbld-freebsd10.0
+Configured with: ./../gcc-4.6.4/configure --disable-bootstrap --disable-nls --libdir=/usr/local/lib/gcc46 --libexecdir=/usr/local/libexec/gcc46 --program-suffix=46 --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-gxx-include-dir=/usr/local/lib/gcc46/include/c++/ --with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection' --with-system-zlib --disable-libgcj --enable-languages=c,c++,objc,fortran --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/gcc46 --build=x86_64-portbld-freebsd10.0
+Thread model: posix
+gcc version 4.6.4 (FreeBSD Ports Collection)
+COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64'
+ /usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/f951 /usr/local/share/cmake-3.7/Modules/CMakeFortranCompilerABI.F -ffixed-form -cpp=/tmp//ccp5PsLd.f90 -quiet -v /usr/local/share/cmake-3.7/Modules/CMakeFortranCompilerABI.F -quiet -dumpbase CMakeFortranCompilerABI.F -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o -version -fintrinsic-modules-path /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/finclude -o /tmp//ccGWxrQ5.s
+GNU Fortran (FreeBSD Ports Collection) version 4.6.4 (x86_64-portbld-freebsd10.0)
+ compiled by GNU C version 4.2.1 Compatible FreeBSD Clang 3.3 (tags/RELEASE_33/final 183502), GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring nonexistent directory "/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../../../x86_64-portbld-freebsd10.0/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/finclude
+ /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/include
+ /usr/local/include
+ /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/include-fixed
+ /usr/include
+End of search list.
+GNU Fortran (FreeBSD Ports Collection) version 4.6.4 (x86_64-portbld-freebsd10.0)
+ compiled by GNU C version 4.2.1 Compatible FreeBSD Clang 3.3 (tags/RELEASE_33/final 183502), GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64'
+ /usr/local/bin/as -v -o CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o /tmp//ccGWxrQ5.s
+GNU assembler version 2.23.2 (x86_64-portbld-freebsd10.0) using BFD version (GNU Binutils) 2.23.2
+COMPILER_PATH=/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../../../x86_64-portbld-freebsd10.0/bin/
+LIBRARY_PATH=/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../../../x86_64-portbld-freebsd10.0/lib/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64'
+Linking Fortran executable cmTC_9ec75
+/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9ec75.dir/link.txt --verbose=1
+/usr/local/bin/gfortran46 -v CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o -o cmTC_9ec75
+Driving: /usr/local/bin/gfortran46 -v CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o -o cmTC_9ec75 -l gfortran -l m -shared-libgcc
+Using built-in specs.
+COLLECT_GCC=/usr/local/bin/gfortran46
+COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/lto-wrapper
+Target: x86_64-portbld-freebsd10.0
+Configured with: ./../gcc-4.6.4/configure --disable-bootstrap --disable-nls --libdir=/usr/local/lib/gcc46 --libexecdir=/usr/local/libexec/gcc46 --program-suffix=46 --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-gxx-include-dir=/usr/local/lib/gcc46/include/c++/ --with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection' --with-system-zlib --disable-libgcj --enable-languages=c,c++,objc,fortran --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/gcc46 --build=x86_64-portbld-freebsd10.0
+Thread model: posix
+gcc version 4.6.4 (FreeBSD Ports Collection)
+Reading specs from /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../libgfortran.spec
+rename spec lib to liborig
+COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_9ec75' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+COMPILER_PATH=/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../../../x86_64-portbld-freebsd10.0/bin/
+LIBRARY_PATH=/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../../../x86_64-portbld-freebsd10.0/lib/:/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_9ec75' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+ /usr/local/libexec/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/collect2 --eh-frame-hdr -V -dynamic-linker /libexec/ld-elf.so.1 -o cmTC_9ec75 /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/crtbegin.o -L/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4 -L/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../../../x86_64-portbld-freebsd10.0/lib -L/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../.. CMakeFiles/cmTC_9ec75.dir/CMakeFortranCompilerABI.F.o -lgfortran -lm -lgcc_s -lgcc -lquadmath -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/crtend.o /usr/lib/crtn.o
+GNU ld (GNU Binutils) 2.23.2
+ Supported emulations:
+ elf_x86_64_fbsd
+ elf_i386_fbsd
+ elf_x86_64
+ elf_i386
+ elf_l1om
+ elf_l1om_fbsd
+ elf_k1om
+ elf_k1om_fbsd
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/hand-C-empty.input b/Tests/RunCMake/ParseImplicitData/hand-C-empty.input
new file mode 100644
index 000000000..b27eb027d
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/hand-C-empty.input
@@ -0,0 +1,14 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=/usr/bin/gcc-ar-7
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=GNU
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=/usr/bin/gcc-ranlib-7
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=7.3.0
+CMAKE_C_COMPILER_VERSION_INTERAL=
+
+This is a test and there is nothing here to parse.
diff --git a/Tests/RunCMake/ParseImplicitData/hand-C-relative.input b/Tests/RunCMake/ParseImplicitData/hand-C-relative.input
new file mode 100644
index 000000000..52ac9df09
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/hand-C-relative.input
@@ -0,0 +1,23 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=/usr/bin/gcc-ar-7
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=GNU
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=/usr/bin/gcc-ranlib-7
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=7.3.0
+CMAKE_C_COMPILER_VERSION_INTERAL=
+
+This is a hand-written test case.
+
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/local/include
+ ../../../adaptive/relative/include
+ /usr/include
+End of search list.
+
+/usr/bin/ld -L/usr/lib64 -L../../../adaptive/relative/lib
diff --git a/Tests/RunCMake/ParseImplicitData/hand-CXX-empty.input b/Tests/RunCMake/ParseImplicitData/hand-CXX-empty.input
new file mode 100644
index 000000000..b983d6b63
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/hand-CXX-empty.input
@@ -0,0 +1,14 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=/usr/bin/gcc-ar-7
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=GNU
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=/usr/bin/gcc-ranlib-7
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=7.3.0
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+
+This is a test and there is nothing here to parse.
diff --git a/Tests/RunCMake/ParseImplicitData/hand-CXX-relative.input b/Tests/RunCMake/ParseImplicitData/hand-CXX-relative.input
new file mode 100644
index 000000000..0b223a130
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/hand-CXX-relative.input
@@ -0,0 +1,23 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=/usr/bin/gcc-ar-7
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=GNU
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=/usr/bin/gcc-ranlib-7
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=7.3.0
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+
+This is a hand-written test case.
+
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/local/include
+ ../../../adaptive/relative/include
+ /usr/include
+End of search list.
+
+/usr/bin/ld -L/usr/lib64 -L../../../adaptive/relative/lib
diff --git a/Tests/RunCMake/ParseImplicitData/linux-C-GNU-7.3.0.input b/Tests/RunCMake/ParseImplicitData/linux-C-GNU-7.3.0.input
new file mode 100644
index 000000000..ee296a7a1
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-C-GNU-7.3.0.input
@@ -0,0 +1,72 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=/usr/bin/gcc-ar-7
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=GNU
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=/usr/bin/gcc-ranlib-7
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=7.3.0
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_1f304/fast"
+/usr/bin/make -f CMakeFiles/cmTC_1f304.dir/build.make CMakeFiles/cmTC_1f304.dir/build
+make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o
+/usr/bin/cc -v -o CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-3.10/Modules/CMakeCCompilerABI.c
+Using built-in specs.
+COLLECT_GCC=/usr/bin/cc
+OFFLOAD_TARGET_NAMES=nvptx-none
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/7/cc1 -quiet -v -imultiarch x86_64-linux-gnu /usr/share/cmake-3.10/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/cc3JNm0a.s
+GNU C11 (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu)
+ compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/lib/gcc/x86_64-linux-gnu/7/include
+ /usr/local/include
+ /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+GNU C11 (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu)
+ compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+Compiler executable checksum: c8081a99abb72bbfd9129549110a350c
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64'
+ as -v --64 -o CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o /tmp/cc3JNm0a.s
+GNU assembler version 2.30 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.30
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=generic' '-march=x86-64'
+Linking C executable cmTC_1f304
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1f304.dir/link.txt --verbose=1
+/usr/bin/cc -v -rdynamic CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o -o cmTC_1f304
+Using built-in specs.
+COLLECT_GCC=/usr/bin/cc
+COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
+OFFLOAD_TARGET_NAMES=nvptx-none
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_1f304' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/7/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper -plugin-opt=-fresolution=/tmp/ccg3L1R6.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_1f304 /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/7 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/7/../../.. CMakeFiles/cmTC_1f304.dir/CMakeCCompilerABI.c.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o
+COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_1f304' '-mtune=generic' '-march=x86-64'
+make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-C-Intel-18.0.0.20170811.input b/Tests/RunCMake/ParseImplicitData/linux-C-Intel-18.0.0.20170811.input
new file mode 100644
index 000000000..1e6544b90
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-C-Intel-18.0.0.20170811.input
@@ -0,0 +1,43 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=Intel
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=18.0.0.20170811
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_a5f0a/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_a5f0a.dir/build.make CMakeFiles/cmTC_a5f0a.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o
+/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/icc -v -o CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -c /tmp/CMake/Modules/CMakeCCompilerABI.c
+icc version 18.0.0 (gcc version 4.8.5 compatibility)
+/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/mcpcom --target_efi2 --lang=c -_g -mP3OPT_inline_alloca -D__ICC=1800 -D__INTEL_COMPILER=1800 -D__INTEL_COMPILER_UPDATE=0 -D__PTRDIFF_TYPE__=long "-D__SIZE_TYPE__=unsigned long" -D__WCHAR_TYPE__=int "-D__WINT_TYPE__=unsigned int" "-D__INTMAX_TYPE__=long int" "-D__UINTMAX_TYPE__=long unsigned int" -D__LONG_MAX__=9223372036854775807L -D__QMSPP_ -D__OPTIMIZE__ -D__NO_MATH_INLINES -D__NO_STRING_INLINES -D__GNUC_GNU_INLINE__ -D__GNUC__=4 -D__GNUC_MINOR__=8 -D__GNUC_PATCHLEVEL__=5 -D__LP64__ -D_LP64 -D__GXX_ABI_VERSION=1002 "-D__USER_LABEL_PREFIX__= " -D__REGISTER_PREFIX__= -D__INTEL_RTTI__ -D__unix__ -D__unix -D__linux__ -D__linux -D__gnu_linux__ -B -Dunix -Dlinux "-_Asystem(unix)" -D__ELF__ -D__x86_64 -D__x86_64__ -D__amd64 -D__amd64__ "-_Acpu(x86_64)" "-_Amachine(x86_64)" -D__INTEL_COMPILER_BUILD_DATE=20170811 -D__INTEL_OFFLOAD -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE2_MATH__ -D__SSE__ -D__SSE_MATH__ -D__MMX__ -_k -_8 -_l --has_new_stdarg_support -_a -_b --gnu_version=40805 -_W5 --gcc-extern-inline --multibyte_chars -mGLOB_diag_suppress_sys --system_preinclude /usr/include/stdc-predef.h --array_section --simd --simd_func --offload_mode=1 --offload_target_names=gfx,GFX,mic,MIC --offload_unique_string=icc1018727407m03RCD -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=485 "-mGLOB_options_string=-v -o CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -c" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/iccMjPSufas_.s -mIPOPT_activate -mIPOPT_lite -mGLOB_instruction_tuning=0x0 -mGLOB_uarch_tuning=0x0 -mGLOB_product_id_code=0x22006d92 -mCG_bnl_movbe=T -mGLOB_extended_instructions=0x8 -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icc1018727407m03RCD -mP2OPT_hlo_level=2 -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_lto_object_enabled -mIPOPT_lto_object_value=1 -mIPOPT_obj_output_file_name=CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -mIPOPT_whole_archive_fixup_file_name=/tmp/iccwarchDkkYqW -mGLOB_linker_version=2.27 -mGLOB_driver_tempfile_name=/tmp/icctempfileg2vfUM -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_C -mP1OPT_source_file_name=/tmp/CMake/Modules/CMakeCCompilerABI.c -mP1OPT_full_source_file_name=/tmp/CMake/Modules/CMakeCCompilerABI.c /tmp/CMake/Modules/CMakeCCompilerABI.c
+#include "..." search starts here:
+#include <...> search starts here:
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/include
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/include
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/pstl/include
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/intel64
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/icc
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include
+ /usr/local/include
+ /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include
+ /usr/include/
+ /usr/include
+End of search list.
+Linking C executable cmTC_a5f0a
+/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a5f0a.dir/link.txt --verbose=1
+/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/icc -v -rdynamic CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -o cmTC_a5f0a
+icc version 18.0.0 (gcc version 4.8.5 compatibility)
+/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/mcpcom -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=485 "-mGLOB_options_string=-v -rdynamic -o cmTC_a5f0a" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/iccSNrbyQas_.s -mGLOB_dashboard_use_source_name -mIPOPT_activate -mGLOB_product_id_code=0x22006d92 -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mGLOB_opt_report_use_source_name -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icc0131594309ugIRtJ -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_link -mIPOPT_ipo_activate -mIPOPT_mo_activate -mIPOPT_source_files_list=/tmp/iccslis4FFYii -mIPOPT_mo_global_data -mIPOPT_link_script_file=/tmp/iccscriptV37728 "-mIPOPT_cmdline_link="/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o" "-export-dynamic" "--eh-frame-hdr" "--build-id" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-m" "elf_x86_64" "-o" "cmTC_a5f0a" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/" "-L/lib/../lib64" "-L/lib/../lib64/" "-L/usr/lib/../lib64" "-L/usr/lib/../lib64/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7/" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../" "-L/lib64" "-L/lib/" "-L/usr/lib64" "-L/usr/lib" "CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o" "-Bdynamic" "-Bstatic" "-limf" "-lsvml" "-lirng" "-Bdynamic" "-lm" "-Bstatic" "-lipgo" "-ldecimal" "--as-needed" "-Bdynamic" "-lcilkrts" "-lstdc++" "--no-as-needed" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc" "-lsvml" "-Bdynamic" "-lc" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc_s" "-Bdynamic" "-ldl" "-lc" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtend.o" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crtn.o"" -mIPOPT_il_in_obj -mIPOPT_ipo_activate_warn=FALSE -mIPOPT_obj_output_file_name=/tmp/ipo_iccYpsdQb.o -mIPOPT_whole_archive_fixup_file_name=/tmp/iccwarchgEXmQo -mGLOB_linker_version=2.27 -mGLOB_driver_tempfile_name=/tmp/icctempfilemNLlCf -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=/tmp/ipo_iccYpsdQb.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_NONE -mP1OPT_source_file_name=ipo_out.c CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -mIPOPT_object_files=T -mIPOPT_assembly_files=/tmp/iccalisRmwrkT -mIPOPT_generated_tempfiles=/tmp/iccelisUgbz4J -mIPOPT_embedded_object_base_name=/tmp/icceobj0agHOA -mIPOPT_cmdline_link_new_name=/tmp/iccllis0qIPyr
+ld /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o -export-dynamic --eh-frame-hdr --build-id -dynamic-linker /lib64/ld-linux-x86-64.so.2 -m elf_x86_64 -o cmTC_a5f0a -L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64 -L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin -L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin -L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7 -L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7 -L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/ -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/ -L/lib/../lib64 -L/lib/../lib64/ -L/usr/lib/../lib64 -L/usr/lib/../lib64/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7/ -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../ -L/lib64 -L/lib/ -L/usr/lib64 -L/usr/lib CMakeFiles/cmTC_a5f0a.dir/CMakeCCompilerABI.c.o -Bdynamic -Bstatic -limf -lsvml -lirng -Bdynamic -lm -Bstatic -lipgo -ldecimal --as-needed -Bdynamic -lcilkrts -lstdc++ --no-as-needed -lgcc -lgcc_s -Bstatic -lirc -lsvml -Bdynamic -lc -lgcc -lgcc_s -Bstatic -lirc_s -Bdynamic -ldl -lc /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crtn.o
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-C-PGI-18.10.1.input b/Tests/RunCMake/ParseImplicitData/linux-C-PGI-18.10.1.input
new file mode 100644
index 000000000..cfc3e7b1c
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-C-PGI-18.10.1.input
@@ -0,0 +1,36 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=PGI
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=18.10.1
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_81a12/fast"
+/usr/bin/make -f CMakeFiles/cmTC_81a12.dir/build.make CMakeFiles/cmTC_81a12.dir/build
+make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_81a12.dir/CMakeCCompilerABI.c.o
+/mnt/pgi/linux86-64/2018/bin/pgcc -v -o CMakeFiles/cmTC_81a12.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-3.10/Modules/CMakeCCompilerABI.c
+Export PGI_CURR_CUDA_HOME=/mnt/pgi/linux86-64/2018/cuda/9.1
+Export PGI=/mnt/pgi
+
+/mnt/pgi/linux86-64/18.10/bin/pgc /usr/share/cmake-3.10/Modules/CMakeCCompilerABI.c -opt 1 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -quad -x 59 4 -tp k8 -x 120 0x1000 -astype 0 -stdinc /mnt/pgi/linux86-64/18.10/include-gcc70:/mnt/pgi/linux86-64/18.10/include:/usr/lib/gcc/x86_64-linux-gnu/7/include:/usr/local/include:/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed:/usr/include/x86_64-linux-gnu:/usr/include -def unix -def __unix -def __unix__ -def linux -def __linux -def __linux__ -def __NO_MATH_INLINES -def __LP64__ -def __x86_64 -def __x86_64__ -def __LONG_MAX__=9223372036854775807L -def '__SIZE_TYPE__=unsigned long int' -def '__PTRDIFF_TYPE__=long int' -def __extension__= -def __amd_64__amd64__ -def __k8 -def __k8__ -def __SSE__ -def __MMX__ -def __SSE2__ -def __SSE3__ -predicate '#machine(x86_64) #lint(off) #system(posix) #cpu(x86_64)' -cmdline '+pgcc /usr/share/cmake-3.10/Modules/CMakeCCompilerABI.c -v -o CMakeFiles/cmTC_81a12.dir/CMakeCCompilerABI.c.o -c' -outfile CMakeFiles/cmTC_81a12.dir/CMakeCCompilerABI.c.o -x 123 0x80000000 -x 123 4 -x 2 0x400 -preinclude _c_macros.h -x 119 0x20 -def __pgnu_vsn=70300 -x 120 0x200000 -x 70 0x40000000 -x 164 0x800000 -y 163 0xc0000000 -x 189 0x10 -y 189 0x4000000 -asm /tmp/pgccl1BeHkOmG3zk.s
+PGC/x86-64 Linux 18.10-1: compilation successful
+
+/usr/bin/as /tmp/pgccl1BeHkOmG3zk.s -o CMakeFiles/cmTC_81a12.dir/CMakeCCompilerABI.c.o
+Unlinking /tmp/pgccl1BeHkOmG3zk.s
+Unlinking /tmp/pgccJ1BePEjJHZ9x.ll
+Linking C executable cmTC_81a12
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_81a12.dir/link.txt --verbose=1
+/mnt/pgi/linux86-64/2018/bin/pgcc -v CMakeFiles/cmTC_81a12.dir/CMakeCCompilerABI.c.o -o cmTC_81a12
+Export PGI_CURR_CUDA_HOME=/mnt/pgi/linux86-64/2018/cuda/9.1
+Export PGI=/mnt/pgi
+
+/usr/bin/ld /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o /mnt/pgi/linux86-64/18.10/lib/trace_init.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o /mnt/pgi/linux86-64/18.10/lib/initmp.o --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /mnt/pgi/linux86-64/18.10/lib/pgi.ld -L/mnt/pgi/linux86-64/18.10/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-linux-gnu/7 CMakeFiles/cmTC_81a12.dir/CMakeCCompilerABI.c.o -rpath /mnt/pgi/linux86-64/18.10/lib -rpath /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -o cmTC_81a12 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -lpgmp -lnuma -lpthread --start-group -lpgmath -lnspgc -lpgc --end-group -lm -lgcc -lc -lgcc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/7/crtend.o /usr/lib/x86_64-linux-gnu/crtn.o
+make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-C-XL-12.1.0.input b/Tests/RunCMake/ParseImplicitData/linux-C-XL-12.1.0.input
new file mode 100644
index 000000000..a6d9e5a48
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-C-XL-12.1.0.input
@@ -0,0 +1,42 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=XL
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=12.1.0
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_79cdf/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_79cdf.dir/build.make CMakeFiles/cmTC_79cdf.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/bin/xlc -qthreaded -qhalt=e -V -o CMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCCompilerABI.c
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc
+export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447
+export XL_ASMOBJFILES=/tmp/xlcASgBamaX
+export "XL_DIS=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/dis -o "CMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o" "CMakeCCompilerABI.o""
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlcentry -qosvar=rhel.6.9 -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qtls -D_CALL_SYSV -D__null=0 -D__NO_MATH_INLINES -qtls -q64 -qgnu_version=4.4.7 -qthreaded -qhalt=e -qasm_as=/usr/bin/as -qc_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -qgcc_c_stdinc=/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qcomplexgccincl=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qvac_include_path=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -oCMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCCompilerABI.c /tmp/xlcW06RQxFR /tmp/xlcW1Og9D2y /dev/null /tmp/xlcLUravVDF.lst /dev/null /tmp/xlcW2kTjRpg
+export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode
+export XL_LINKER=/usr/bin/ld
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qtls -qtls -qthreaded -qhalt=e /tmp/xlcW06RQxFR /tmp/xlcW1Og9D2y CMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o /tmp/xlcLUravVDB.lst /tmp/xlcW2kTjRpg
+rm /tmp/xlcASgBamaX
+rm /tmp/xlcLUravVD
+rm /tmp/xlcW06RQxFR
+rm /tmp/xlcW1Og9D2y
+rm /tmp/xlcW2kTjRpg
+Linking C executable cmTC_79cdf
+/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_79cdf.dir/link.txt --verbose=1
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/bin/xlc -qthreaded -qhalt=e -V CMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o -o cmTC_79cdf -Wl,-export-dynamic
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc
+export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447
+/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64 -L/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_79cdf.dir/CMakeCCompilerABI.c.o -o cmTC_79cdf -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlopt -lxl -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o
+rm /tmp/xlcW0JVPZO4
+rm /tmp/xlcW1cwDxtZ
+rm /tmp/xlcW2j5Va8T
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-C-XL-16.1.0.0.input b/Tests/RunCMake/ParseImplicitData/linux-C-XL-16.1.0.0.input
new file mode 100644
index 000000000..97fa28be9
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-C-XL-16.1.0.0.input
@@ -0,0 +1,40 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=XL
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=16.1.0.0
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_56ad1/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_56ad1.dir/build.make CMakeFiles/cmTC_56ad1.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o
+/opt/ibm/xlC/16.1.0/bin/xlc -qthreaded -V -o CMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o -c "/tmp/CMake/Modules/CMakeCCompilerABI.c"
+export XL_CONFIG=/opt/ibm/xlC/16.1.0/etc/xlc.cfg.centos.7.gcc.4.8.5:xlc
+export XL_ASMOBJFILES=/tmp/xlcASSb1cI4
+export "XL_DIS=/opt/ibm/xlC/16.1.0/exe/dis -o "CMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o" "CMakeCCompilerABI.o""
+/opt/ibm/xlC/16.1.0/exe/xlCentry -qosvar=centos.7.0 -qlanglvl=extc99 -qalias=ansi -qthreaded -D_REENTRANT -D__VACPP_MULTI__ -qtls -q64 -D_CALL_SYSV -D__NO_MATH_INLINES -D_CALL_ELF=2 -Wno-parentheses -Wno-unused-value -maltivec -qtls -q64 -qgnu_version=4.8.5 -qthreaded -qasm_as=/usr/bin/as -qc_stdinc=/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlmass/9.1.0/include:/opt/ibm/xlC/16.1.0/include -qgcc_c_stdinc=/opt/ibm/xlC/16.1.0/include:/usr/local/include:/opt/ibm/xlC/16.1.0/include:/usr/include -qcomplexgccincl=/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlmass/9.1.0/include:/opt/ibm/xlC/16.1.0/include:/opt/ibm/xlC/16.1.0/include:/usr/local/include:/opt/ibm/xlC/16.1.0/include:/usr/include -qvac_include_path=/opt/ibm/xlC/16.1.0/include -oCMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o "/tmp/CMake/Modules/CMakeCCompilerABI.c" /tmp/xlcW0T1FYwj /tmp/xlcW1fu4lVT /dev/null /tmp/xlcLWBpG6EF.lst /dev/null /tmp/xlcW2TKQJju
+export XL_BACKEND=/opt/ibm/xlC/16.1.0/exe/xlCcode
+export XL_LINKER=/usr/bin/ld
+/opt/ibm/xlC/16.1.0/exe/xlCcode -qlanglvl=extc99 -qalias=ansi -qthreaded -qtls -maltivec -qtls -qthreaded /tmp/xlcW0T1FYwj /tmp/xlcW1fu4lVT CMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o /tmp/xlcLWBpG6EB.lst /tmp/xlcW2TKQJju
+rm /tmp/xlcASSb1cI4
+rm /tmp/xlcLWBpG6E
+rm /tmp/xlcW0T1FYwj
+rm /tmp/xlcW1fu4lVT
+rm /tmp/xlcW2TKQJju
+Linking C executable cmTC_56ad1
+"/tmp/CMake/bin/cmake" -E cmake_link_script CMakeFiles/cmTC_56ad1.dir/link.txt --verbose=1
+/opt/ibm/xlC/16.1.0/bin/xlc -qthreaded -V -Wl,-export-dynamic CMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o -o cmTC_56ad1
+export XL_CONFIG=/opt/ibm/xlC/16.1.0/etc/xlc.cfg.centos.7.gcc.4.8.5:xlc
+/usr/bin/ld --eh-frame-hdr -Qy -melf64lppc -dynamic-linker /lib64/ld64.so.2 --enable-new-dtags /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crt1.o /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crti.o /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/crtbegin.o -L/opt/ibm/xlsmp/5.1.0/lib -L/opt/ibm/xlmass/9.1.0/lib -L/opt/ibm/xlC/16.1.0/lib -R/opt/ibm/lib -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5 -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../.. -export-dynamic CMakeFiles/cmTC_56ad1.dir/CMakeCCompilerABI.c.o -o cmTC_56ad1 -lxlopt -lxl --as-needed -ldl --no-as-needed -lgcc_s --as-needed -lpthread --no-as-needed -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/crtend.o /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crtn.o
+rm /tmp/xlcW0S2fv6n
+rm /tmp/xlcW11wDdxY
+rm /tmp/xlcW2JqnWXy
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-CUDA-NVIDIA-10.1.168-CLANG.input b/Tests/RunCMake/ParseImplicitData/linux-CUDA-NVIDIA-10.1.168-CLANG.input
new file mode 100644
index 000000000..954697dbc
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-CUDA-NVIDIA-10.1.168-CLANG.input
@@ -0,0 +1,242 @@
+CMAKE_LANG=CUDA
+CMAKE_LINKER=/usr/bin/ld
+CMAKE_CUDA_COMPILER_ABI=
+CMAKE_CUDA_COMPILER_AR=
+CMAKE_CUDA_COMPILER_ARCHITECTURE_ID=
+CMAKE_CUDA_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CUDA_COMPILER_ID=NVIDIA
+CMAKE_CUDA_COMPILER_LAUNCHER=
+CMAKE_CUDA_COMPILER_LOADED=1
+CMAKE_CUDA_COMPILER_RANLIB=
+CMAKE_CUDA_COMPILER_TARGET=
+CMAKE_CUDA_COMPILER_VERSION=10.1.168
+CMAKE_CUDA_COMPILER_VERSION_INTERAL=
+Change Dir: /home/robert/Work/cmake/cuda_clang_compiler_info/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/ninja cmTC_e3386 && [1/2] Building CUDA object CMakeFiles/cmTC_e3386.dir/CMakeCUDACompilerABI.cu.o
+clang version 8.0.1-svn369350-1~exp1~20190820121219.79 (branches/release_80)
+Target: x86_64-pc-linux-gnu
+Thread model: posix
+InstalledDir: /usr/bin
+Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/8
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.5.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.5.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
+Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
+Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
+Candidate multilib: .@m64
+Selected multilib: .@m64
+Found CUDA installation: /usr/local/cuda-10.1, version unknown
+ "/usr/lib/llvm-8/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCUDACompilerABI.cu -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/lib/llvm-8/lib/clang/8.0.1 -include cuda_runtime.h -D __CUDA_ARCH__=300 -D CUDA_DOUBLE_MATH_FUNCTIONS -D __CUDACC__ -D __NVCC__ -I /usr/local/cuda/bin/../targets/x86_64-linux/include -D __CUDACC_VER_MAJOR__=10 -D __CUDACC_VER_MINOR__=1 -D __CUDACC_VER_BUILD__=168 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward -internal-isystem /usr/include/clang/8.0.1/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-8/lib/clang/8.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/robert/Work/cmake/cuda_clang_compiler_info/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o - -x c++ /opt/cmake-3.15/share/cmake-3.15/Modules/CMakeCUDACompilerABI.cu -faddrsig
+clang -cc1 version 8.0.1 based upon LLVM 8.0.1 default target x86_64-pc-linux-gnu
+ignoring nonexistent directory "/include"
+ignoring duplicate directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8"
+ignoring duplicate directory "/usr/include/clang/8.0.1/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/local/cuda/bin/../targets/x86_64-linux/include
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward
+ /usr/include/clang/8.0.1/include
+ /usr/local/include
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+clang version 8.0.1-svn369350-1~exp1~20190820121219.79 (branches/release_80)
+Target: x86_64-pc-linux-gnu
+Thread model: posix
+InstalledDir: /usr/bin
+Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/8
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.5.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.5.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
+Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
+Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
+Candidate multilib: .@m64
+Selected multilib: .@m64
+Found CUDA installation: /usr/local/cuda-10.1, version unknown
+ "/usr/lib/llvm-8/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCUDACompilerABI.cu -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/lib/llvm-8/lib/clang/8.0.1 -include cuda_runtime.h -D __CUDACC__ -D __NVCC__ -I /usr/local/cuda/bin/../targets/x86_64-linux/include -D __CUDACC_VER_MAJOR__=10 -D __CUDACC_VER_MINOR__=1 -D __CUDACC_VER_BUILD__=168 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward -internal-isystem /usr/include/clang/8.0.1/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-8/lib/clang/8.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/robert/Work/cmake/cuda_clang_compiler_info/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o - -x c++ /opt/cmake-3.15/share/cmake-3.15/Modules/CMakeCUDACompilerABI.cu -faddrsig
+clang -cc1 version 8.0.1 based upon LLVM 8.0.1 default target x86_64-pc-linux-gnu
+ignoring nonexistent directory "/include"
+ignoring duplicate directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8"
+ignoring duplicate directory "/usr/include/clang/8.0.1/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/local/cuda/bin/../targets/x86_64-linux/include
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward
+ /usr/include/clang/8.0.1/include
+ /usr/local/include
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+clang version 8.0.1-svn369350-1~exp1~20190820121219.79 (branches/release_80)
+Target: x86_64-pc-linux-gnu
+Thread model: posix
+InstalledDir: /usr/bin
+Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/8
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.5.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.5.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
+Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
+Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
+Candidate multilib: .@m64
+Selected multilib: .@m64
+Found CUDA installation: /usr/local/cuda-10.1, version unknown
+ "/usr/lib/llvm-8/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name tmpxft_00005e34_00000000-5_CMakeCUDACompilerABI.cudafe1.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -coverage-notes-file /home/robert/Work/cmake/cuda_clang_compiler_info/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_e3386.dir/CMakeCUDACompilerABI.cu.gcno -resource-dir /usr/lib/llvm-8/lib/clang/8.0.1 -D __CUDA_ARCH__=300 -D CUDA_DOUBLE_MATH_FUNCTIONS -I /usr/local/cuda/bin/../targets/x86_64-linux/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward -internal-isystem /usr/include/clang/8.0.1/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-8/lib/clang/8.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/robert/Work/cmake/cuda_clang_compiler_info/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o CMakeFiles/cmTC_e3386.dir/CMakeCUDACompilerABI.cu.o -x c++ /tmp/tmpxft_00005e34_00000000-5_CMakeCUDACompilerABI.cudafe1.cpp -faddrsig
+clang -cc1 version 8.0.1 based upon LLVM 8.0.1 default target x86_64-pc-linux-gnu
+ignoring nonexistent directory "/include"
+ignoring duplicate directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8"
+ignoring duplicate directory "/usr/include/clang/8.0.1/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/local/cuda/bin/../targets/x86_64-linux/include
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward
+ /usr/include/clang/8.0.1/include
+ /usr/local/include
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+clang version 8.0.1-svn369350-1~exp1~20190820121219.79 (branches/release_80)
+Target: x86_64-pc-linux-gnu
+Thread model: posix
+InstalledDir: /usr/bin
+Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/8
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.5.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.5.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
+Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
+Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
+Candidate multilib: .@m64
+Selected multilib: .@m64
+Found CUDA installation: /usr/local/cuda-10.1, version unknown
+ "/usr/lib/llvm-8/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCUDACompilerABI.cu -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/lib/llvm-8/lib/clang/8.0.1 -include cuda_runtime.h -D __CUDA_ARCH__=300 -D CUDA_DOUBLE_MATH_FUNCTIONS -D __CUDACC__ -D __NVCC__ -I /usr/local/cuda/bin/../targets/x86_64-linux/include -D __CUDACC_VER_MAJOR__=10 -D __CUDACC_VER_MINOR__=1 -D __CUDACC_VER_BUILD__=168 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward -internal-isystem /usr/include/clang/8.0.1/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-8/lib/clang/8.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/robert/Work/cmake/cuda_clang_compiler_info/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o - -x c++ /opt/cmake-3.15/share/cmake-3.15/Modules/CMakeCUDACompilerABI.cu -faddrsig
+clang -cc1 version 8.0.1 based upon LLVM 8.0.1 default target x86_64-pc-linux-gnu
+ignoring nonexistent directory "/include"
+ignoring duplicate directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8"
+ignoring duplicate directory "/usr/include/clang/8.0.1/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/local/cuda/bin/../targets/x86_64-linux/include
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward
+ /usr/include/clang/8.0.1/include
+ /usr/local/include
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+clang version 8.0.1-svn369350-1~exp1~20190820121219.79 (branches/release_80)
+Target: x86_64-pc-linux-gnu
+Thread model: posix
+InstalledDir: /usr/bin
+Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/8
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.5.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.5.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
+Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
+Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
+Candidate multilib: .@m64
+Selected multilib: .@m64
+Found CUDA installation: /usr/local/cuda-10.1, version unknown
+ "/usr/lib/llvm-8/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCUDACompilerABI.cu -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /usr/lib/llvm-8/lib/clang/8.0.1 -include cuda_runtime.h -D __CUDACC__ -D __NVCC__ -I /usr/local/cuda/bin/../targets/x86_64-linux/include -D __CUDACC_VER_MAJOR__=10 -D __CUDACC_VER_MINOR__=1 -D __CUDACC_VER_BUILD__=168 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward -internal-isystem /usr/include/clang/8.0.1/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-8/lib/clang/8.0.1/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /home/robert/Work/cmake/cuda_clang_compiler_info/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -o - -x c++ /opt/cmake-3.15/share/cmake-3.15/Modules/CMakeCUDACompilerABI.cu -faddrsig
+clang -cc1 version 8.0.1 based upon LLVM 8.0.1 default target x86_64-pc-linux-gnu
+ignoring nonexistent directory "/include"
+ignoring duplicate directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8"
+ignoring duplicate directory "/usr/include/clang/8.0.1/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/local/cuda/bin/../targets/x86_64-linux/include
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/x86_64-linux-gnu/c++/8
+ /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/backward
+ /usr/include/clang/8.0.1/include
+ /usr/local/include
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+[2/2] Linking CUDA executable cmTC_e3386
+clang version 8.0.1-svn369350-1~exp1~20190820121219.79 (branches/release_80)
+Target: x86_64-pc-linux-gnu
+Thread model: posix
+InstalledDir: /usr/bin
+Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/8
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.5.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.5.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
+Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
+Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
+Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
+Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
+Candidate multilib: .@m64
+Selected multilib: .@m64
+Found CUDA installation: /usr/local/cuda-10.1, version unknown
+ "/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cmTC_e3386 /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/8/crtbegin.o -L/usr/local/cuda/targets/x86_64-linux/lib/stubs -L/usr/local/cuda/targets/x86_64-linux/lib -L/usr/bin/../lib/gcc/x86_64-linux-gnu/8 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../.. -L/usr/lib/llvm-8/bin/../lib -L/lib -L/usr/lib CMakeFiles/cmTC_e3386.dir/CMakeCUDACompilerABI.cu.o -lcudadevrt -lcudart_static -lrt -lpthread -ldl -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib/gcc/x86_64-linux-gnu/8/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crtn.o
diff --git a/Tests/RunCMake/ParseImplicitData/linux-CUDA-NVIDIA-10.1.168-XLClang-v.input b/Tests/RunCMake/ParseImplicitData/linux-CUDA-NVIDIA-10.1.168-XLClang-v.input
new file mode 100644
index 000000000..7b202884d
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-CUDA-NVIDIA-10.1.168-XLClang-v.input
@@ -0,0 +1,51 @@
+CMAKE_LANG=CUDA
+CMAKE_LINKER=/sw/summit/xalt/1.1.3/bin/ld
+CMAKE_CUDA_COMPILER_ABI=ELF
+CMAKE_CUDA_COMPILER_AR=
+CMAKE_CUDA_COMPILER_ARCHITECTURE_ID=
+CMAKE_CUDA_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CUDA_COMPILER_ID=NVIDIA
+CMAKE_CUDA_COMPILER_LAUNCHER=
+CMAKE_CUDA_COMPILER_LOADED=1
+CMAKE_CUDA_COMPILER_RANLIB=
+CMAKE_CUDA_COMPILER_TARGET=
+CMAKE_CUDA_COMPILER_VERSION=10.1.168
+CMAKE_CUDA_COMPILER_VERSION_INTERAL=
+Change Dir: /ccs/home/rmaynard/cmake/extract_xlc_info/CMakeFiles/CMakeTmp
+
+Run Build Command(s):/usr/bin/gmake cmTC_e9f3e/fast && /usr/bin/gmake -f CMakeFiles/cmTC_e9f3e.dir/build.make CMakeFiles/cmTC_e9f3e.dir/build
+gmake[1]: Entering directory `/autofs/nccs-svm1_home1/rmaynard/cmake/extract_xlc_info/CMakeFiles/CMakeTmp'
+Building CUDA object CMakeFiles/cmTC_e9f3e.dir/CMakeCUDACompilerABI.cu.o
+/sw/summit/cuda/10.1.168/bin/nvcc -ccbin=/sw/summit/xl/16.1.1-3/xlC/16.1.1/bin/xlc++ -v -x cu -c /ccs/home/rmaynard/cmake/src/Modules/CMakeCUDACompilerABI.cu -o CMakeFiles/cmTC_e9f3e.dir/CMakeCUDACompilerABI.cu.o
+#$ _SPACE_=
+#$ _CUDART_=cudart
+#$ _HERE_=/sw/summit/cuda/10.1.168/bin
+#$ _THERE_=/sw/summit/cuda/10.1.168/bin
+#$ _TARGET_SIZE_=
+#$ _TARGET_DIR_=
+#$ _TARGET_DIR_=targets/ppc64le-linux
+#$ TOP=/sw/summit/cuda/10.1.168/bin/..
+#$ NVVMIR_LIBRARY_DIR=/sw/summit/cuda/10.1.168/bin/../nvvm/libdevice
+#$ LD_LIBRARY_PATH=/sw/summit/cuda/10.1.168/bin/../lib:/autofs/nccs-svm1_sw/summit/.swci/1-compute/opt/spack/20180914/linux-rhel7-ppc64le/xl-16.1.1-3/spectrum-mpi-10.3.0.1-20190611-aqjt3jo53mogrrhcrd2iufr435azcaha/lib:/sw/summit/xl/16.1.1-3/xlsmp/5.1.1/lib:/sw/summit/xl/16.1.1-3/xlmass/9.1.1/lib:/sw/summit/xl/16.1.1-3/xlC/16.1.1/lib:/sw/summit/xl/16.1.1-3/xlf/16.1.1/lib:/sw/summit/xl/16.1.1-3/lib:/sw/summit/cuda/10.1.168/lib64:/autofs/nccs-svm1_sw/summit/.swci/1-compute/opt/spack/20180914/linux-rhel7-ppc64le/gcc-4.8.5/darshan-runtime-3.1.7-csygoqyym3m3ysoaperhxlhoiluvpa2u/lib:/opt/ibm/spectrumcomputing/lsf/10.1/linux3.10-glibc2.17-ppc64le-csm/lib
+#$ PATH=/sw/summit/cuda/10.1.168/bin/../nvvm/bin:/sw/summit/cuda/10.1.168/bin:/sw/sources/lsf-tools/2.0/summit/bin:/sw/summit/xalt/1.1.3/bin:/autofs/nccs-svm1_sw/summit/.swci/1-compute/opt/spack/20180914/linux-rhel7-ppc64le/xl-16.1.1-3/spectrum-mpi-10.3.0.1-20190611-aqjt3jo53mogrrhcrd2iufr435azcaha/bin:/sw/summit/xl/16.1.1-3/xlC/16.1.1/bin:/sw/summit/xl/16.1.1-3/xlf/16.1.1/bin:/sw/summit/cuda/10.1.168/bin:/usr/bin:/usr/sbin:/autofs/nccs-svm1_sw/summit/.swci/1-compute/opt/spack/20180914/linux-rhel7-ppc64le/gcc-4.8.5/darshan-runtime-3.1.7-csygoqyym3m3ysoaperhxlhoiluvpa2u/bin:/sw/sources/hpss/bin:/opt/ibm/spectrumcomputing/lsf/10.1/linux3.10-glibc2.17-ppc64le-csm/etc:/opt/ibm/spectrumcomputing/lsf/10.1/linux3.10-glibc2.17-ppc64le-csm/bin:/opt/ibm/csm/bin:/usr/local/bin:/usr/local/sbin:/opt/ibm/flightlog/bin:/opt/ibutils/bin:/opt/ibm/spectrum_mpi/jsm_pmix/bin:/opt/puppetlabs/bin:/usr/lpp/mmfs/bin
+#$ INCLUDES="-I/sw/summit/cuda/10.1.168/bin/../targets/ppc64le-linux/include"
+#$ LIBRARIES= "-L/sw/summit/cuda/10.1.168/bin/../targets/ppc64le-linux/lib/stubs" "-L/sw/summit/cuda/10.1.168/bin/../targets/ppc64le-linux/lib"
+#$ CUDAFE_FLAGS=
+#$ PTXAS_FLAGS=
+#$ "/sw/summit/xl/16.1.1-3/xlC/16.1.1/bin"/xlc++ -D__CUDA_ARCH__=300 -E -x c++ -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDACC__ -D__NVCC__ "-I/sw/summit/cuda/10.1.168/bin/../targets/ppc64le-linux/include" -D__CUDACC_VER_MAJOR__=10 -D__CUDACC_VER_MINOR__=1 -D__CUDACC_VER_BUILD__=168 -include "cuda_runtime.h" "/ccs/home/rmaynard/cmake/src/Modules/CMakeCUDACompilerABI.cu" > "/tmp/tmpxft_0000de61_00000000-6_CMakeCUDACompilerABI.cpp1.ii"
+#$ cicc --clang --clang_version=40000 --allow_managed --unsigned_chars -arch compute_30 -m64 -ftz=0 -prec_div=1 -prec_sqrt=1 -fmad=1 --include_file_name "tmpxft_0000de61_00000000-2_CMakeCUDACompilerABI.fatbin.c" -tused -nvvmir-library "/sw/summit/cuda/10.1.168/bin/../nvvm/libdevice/libdevice.10.bc" --gen_module_id_file --module_id_file_name "/tmp/tmpxft_0000de61_00000000-3_CMakeCUDACompilerABI.module_id" --orig_src_file_name "/ccs/home/rmaynard/cmake/src/Modules/CMakeCUDACompilerABI.cu" --gen_c_file_name "/tmp/tmpxft_0000de61_00000000-5_CMakeCUDACompilerABI.cudafe1.c" --stub_file_name "/tmp/tmpxft_0000de61_00000000-5_CMakeCUDACompilerABI.cudafe1.stub.c" --gen_device_file_name "/tmp/tmpxft_0000de61_00000000-5_CMakeCUDACompilerABI.cudafe1.gpu" "/tmp/tmpxft_0000de61_00000000-6_CMakeCUDACompilerABI.cpp1.ii" -o "/tmp/tmpxft_0000de61_00000000-5_CMakeCUDACompilerABI.ptx"
+#$ ptxas -arch=sm_30 -m64 "/tmp/tmpxft_0000de61_00000000-5_CMakeCUDACompilerABI.ptx" -o "/tmp/tmpxft_0000de61_00000000-7_CMakeCUDACompilerABI.sm_30.cubin"
+#$ fatbinary --create="/tmp/tmpxft_0000de61_00000000-2_CMakeCUDACompilerABI.fatbin" -64 -no-asm "--image=profile=sm_30,file=/tmp/tmpxft_0000de61_00000000-7_CMakeCUDACompilerABI.sm_30.cubin" "--image=profile=compute_30,file=/tmp/tmpxft_0000de61_00000000-5_CMakeCUDACompilerABI.ptx" --embedded-fatbin="/tmp/tmpxft_0000de61_00000000-2_CMakeCUDACompilerABI.fatbin.c"
+#$ rm /tmp/tmpxft_0000de61_00000000-2_CMakeCUDACompilerABI.fatbin
+#$ "/sw/summit/xl/16.1.1-3/xlC/16.1.1/bin"/xlc++ -E -x c++ -D__CUDACC__ -D__NVCC__ "-I/sw/summit/cuda/10.1.168/bin/../targets/ppc64le-linux/include" -D__CUDACC_VER_MAJOR__=10 -D__CUDACC_VER_MINOR__=1 -D__CUDACC_VER_BUILD__=168 -include "cuda_runtime.h" "/ccs/home/rmaynard/cmake/src/Modules/CMakeCUDACompilerABI.cu" > "/tmp/tmpxft_0000de61_00000000-4_CMakeCUDACompilerABI.cpp4.ii"
+#$ cudafe++ --clang --clang_version=40000 --allow_managed --unsigned_chars --m64 --parse_templates --gen_c_file_name "/tmp/tmpxft_0000de61_00000000-5_CMakeCUDACompilerABI.cudafe1.cpp" --stub_file_name "tmpxft_0000de61_00000000-5_CMakeCUDACompilerABI.cudafe1.stub.c" --module_id_file_name "/tmp/tmpxft_0000de61_00000000-3_CMakeCUDACompilerABI.module_id" "/tmp/tmpxft_0000de61_00000000-4_CMakeCUDACompilerABI.cpp4.ii"
+#$ "/sw/summit/xl/16.1.1-3/xlC/16.1.1/bin"/xlc++ -D__CUDA_ARCH__=300 -c -x c++ -DCUDA_DOUBLE_MATH_FUNCTIONS "-I/sw/summit/cuda/10.1.168/bin/../targets/ppc64le-linux/include" -o "CMakeFiles/cmTC_e9f3e.dir/CMakeCUDACompilerABI.cu.o" "/tmp/tmpxft_0000de61_00000000-5_CMakeCUDACompilerABI.cudafe1.cpp"
+Linking CUDA executable cmTC_e9f3e
+/ccs/home/rmaynard/cmake/build/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e9f3e.dir/link.txt --verbose=1
+/sw/summit/xl/16.1.1-3/xlC/16.1.1/bin/xlc++ -v CMakeFiles/cmTC_e9f3e.dir/CMakeCUDACompilerABI.cu.o -o cmTC_e9f3e -L"/sw/summit/cuda/10.1.168/targets/ppc64le-linux/lib/stubs" -L"/sw/summit/cuda/10.1.168/targets/ppc64le-linux/lib" -lcudadevrt -lcudart_static -lrt -lpthread -ldl
+exec: export(export,XL_CONFIG=/sw/summit/xl/16.1.1-3/xlC/16.1.1/etc/xlc.cfg.rhel.7.6.gcc.4.8.5.cuda.10.1:xlc++,NULL)
+exec: /sw/summit/xalt/1.1.3/bin/ld(/sw/summit/xalt/1.1.3/bin/ld,--eh-frame-hdr,-Qy,-melf64lppc,-dynamic-linker,/lib64/ld64.so.2,--enable-new-dtags,-L/sw/summit/cuda/10.1.168/targets/ppc64le-linux/lib/stubs,-L/sw/summit/cuda/10.1.168/targets/ppc64le-linux/lib,-L/autofs/nccs-svm1_sw/summit/.swci/1-compute/opt/spack/20180914/linux-rhel7-ppc64le/xl-16.1.1-3/spectrum-mpi-10.3.0.1-20190611-aqjt3jo53mogrrhcrd2iufr435azcaha/lib,-L/autofs/nccs-svm1_sw/summit/.swci/1-compute/opt/spack/20180914/linux-rhel7-ppc64le/gcc-4.8.5/darshan-runtime-3.1.7-csygoqyym3m3ysoaperhxlhoiluvpa2u/lib,/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crt1.o,/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crti.o,/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/crtbegin.o,-L/autofs/nccs-svm1_sw/summit/xl/16.1.1-3/xlsmp/5.1.1/lib,-L/autofs/nccs-svm1_sw/summit/xl/16.1.1-3/xlmass/9.1.1/lib,-L/autofs/nccs-svm1_sw/summit/xl/16.1.1-3/xlC/16.1.1/lib,-R/autofs/nccs-svm1_sw/summit/xl/16.1.1-3/lib,-L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5,-L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64,-L/lib/../lib64,-L/usr/lib/../lib64,-L/autofs/nccs-svm1_sw/peak/.swci/1-compute/opt/spack/20180914/linux-rhel7-ppc64le/gcc-4.8.5/darshan-runtime-3.1.7-ytwv7xbkub6mqnpvygdthwqa7mhjqbc5/lib,-L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../..,CMakeFiles/cmTC_e9f3e.dir/CMakeCUDACompilerABI.cu.o,-o,cmTC_e9f3e,-lcudadevrt,-lcudart_static,-lrt,-lpthread,-ldl,-lxlopt,-lxl,-libmc++,-lstdc++,-lm,-ldl,-lgcc_s,-lgcc,--as-needed,-lpthread,--no-as-needed,-lm,-lc,-lgcc_s,-lgcc,/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/crtend.o,/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crtn.o,NULL)
+unlink: /tmp/xlcW0by5DKQ
+unlink: /tmp/xlcW1dqSZDp
+unlink: /tmp/xlcW2nyAlxY
+gmake[1]: Leaving directory `/autofs/nccs-svm1_home1/rmaynard/cmake/extract_xlc_info/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-CUDA-NVIDIA-9.2.148-GCC.input b/Tests/RunCMake/ParseImplicitData/linux-CUDA-NVIDIA-9.2.148-GCC.input
new file mode 100644
index 000000000..98aee98f8
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-CUDA-NVIDIA-9.2.148-GCC.input
@@ -0,0 +1,125 @@
+CMAKE_LANG=CUDA
+CMAKE_LINKER=/usr/bin/ld
+CMAKE_CUDA_COMPILER_ABI=ELF
+CMAKE_CUDA_COMPILER_AR=
+CMAKE_CUDA_COMPILER_ARCHITECTURE_ID=
+CMAKE_CUDA_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CUDA_COMPILER_ID=NVIDIA
+CMAKE_CUDA_COMPILER_LAUNCHER=
+CMAKE_CUDA_COMPILER_LOADED=1
+CMAKE_CUDA_COMPILER_RANLIB=
+CMAKE_CUDA_COMPILER_TARGET=
+CMAKE_CUDA_COMPILER_VERSION=9.2.148
+CMAKE_CUDA_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_5996d/fast"
+/usr/bin/make -f CMakeFiles/cmTC_5996d.dir/build.make CMakeFiles/cmTC_5996d.dir/build
+make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building CUDA object CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o
+/usr/bin/nvcc -Xcompiler=-v -x cu -c "/tmp/CMake/Modules/CMakeCUDACompilerABI.cu" -o CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o
+Using built-in specs.
+COLLECT_GCC=gcc-5
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 5.5.0-12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --enable-objc-gc --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 5.5.0 20171010 (Debian 5.5.0-12)
+COLLECT_GCC_OPTIONS='-std=c++14' '-D' '__CUDA_ARCH__=300' '-E' '-D' 'CUDA_DOUBLE_MATH_FUNCTIONS' '-D' '__CUDACC__' '-D' '__NVCC__' '-v' '-D' '__CUDACC_VER_BUILD__=148' '-D' '__CUDACC_VER_MINOR__=2' '-D' '__CUDACC_VER_MAJOR__=9' '-include' 'cuda_runtime.h' '-m64' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE -D __CUDA_ARCH__=300 -D CUDA_DOUBLE_MATH_FUNCTIONS -D __CUDACC__ -D __NVCC__ -D __CUDACC_VER_BUILD__=148 -D __CUDACC_VER_MINOR__=2 -D __CUDACC_VER_MAJOR__=9 -include cuda_runtime.h /tmp/CMake/Modules/CMakeCUDACompilerABI.cu -m64 -mtune=generic -march=x86-64 -std=c++14
+ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/5"
+ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/include/c++/5
+ /usr/include/x86_64-linux-gnu/c++/5
+ /usr/include/c++/5/backward
+ /usr/lib/gcc/x86_64-linux-gnu/5/include
+ /usr/local/include
+ /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-std=c++14' '-D' '__CUDA_ARCH__=300' '-E' '-D' 'CUDA_DOUBLE_MATH_FUNCTIONS' '-D' '__CUDACC__' '-D' '__NVCC__' '-v' '-D' '__CUDACC_VER_BUILD__=148' '-D' '__CUDACC_VER_MINOR__=2' '-D' '__CUDACC_VER_MAJOR__=9' '-include' 'cuda_runtime.h' '-m64' '-mtune=generic' '-march=x86-64'
+Using built-in specs.
+COLLECT_GCC=gcc-5
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 5.5.0-12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --enable-objc-gc --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 5.5.0 20171010 (Debian 5.5.0-12)
+COLLECT_GCC_OPTIONS='-std=c++14' '-E' '-D' '__CUDACC__' '-D' '__NVCC__' '-v' '-D' '__CUDACC_VER_BUILD__=148' '-D' '__CUDACC_VER_MINOR__=2' '-D' '__CUDACC_VER_MAJOR__=9' '-include' 'cuda_runtime.h' '-m64' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE -D __CUDACC__ -D __NVCC__ -D __CUDACC_VER_BUILD__=148 -D __CUDACC_VER_MINOR__=2 -D __CUDACC_VER_MAJOR__=9 -include cuda_runtime.h /tmp/CMake/Modules/CMakeCUDACompilerABI.cu -m64 -mtune=generic -march=x86-64 -std=c++14
+ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/5"
+ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/include/c++/5
+ /usr/include/x86_64-linux-gnu/c++/5
+ /usr/include/c++/5/backward
+ /usr/lib/gcc/x86_64-linux-gnu/5/include
+ /usr/local/include
+ /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-std=c++14' '-E' '-D' '__CUDACC__' '-D' '__NVCC__' '-v' '-D' '__CUDACC_VER_BUILD__=148' '-D' '__CUDACC_VER_MINOR__=2' '-D' '__CUDACC_VER_MAJOR__=9' '-include' 'cuda_runtime.h' '-m64' '-mtune=generic' '-march=x86-64'
+Using built-in specs.
+COLLECT_GCC=gcc-5
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 5.5.0-12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --enable-objc-gc --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 5.5.0 20171010 (Debian 5.5.0-12)
+COLLECT_GCC_OPTIONS='-std=c++14' '-D' '__CUDA_ARCH__=300' '-c' '-D' 'CUDA_DOUBLE_MATH_FUNCTIONS' '-v' '-m64' '-o' 'CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE -D __CUDA_ARCH__=300 -D CUDA_DOUBLE_MATH_FUNCTIONS /tmp/tmpxft_00002df4_00000000-5_CMakeCUDACompilerABI.cudafe1.cpp -quiet -dumpbase tmpxft_00002df4_00000000-5_CMakeCUDACompilerABI.cudafe1.cpp -m64 -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o -std=c++14 -version -o /tmp/ccSDI00n.s
+GNU C++14 (Debian 5.5.0-12) version 5.5.0 20171010 (x86_64-linux-gnu)
+ compiled by GNU C version 5.5.0 20171010, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0
+warning: MPFR header version 4.0.1 differs from library version 4.0.2-rc1.
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/5"
+ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/include/c++/5
+ /usr/include/x86_64-linux-gnu/c++/5
+ /usr/include/c++/5/backward
+ /usr/lib/gcc/x86_64-linux-gnu/5/include
+ /usr/local/include
+ /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+GNU C++14 (Debian 5.5.0-12) version 5.5.0 20171010 (x86_64-linux-gnu)
+ compiled by GNU C version 5.5.0 20171010, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0
+warning: MPFR header version 4.0.1 differs from library version 4.0.2-rc1.
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+Compiler executable checksum: 3caa6244fa07ed8a2b405a77ac6cb692
+COLLECT_GCC_OPTIONS='-std=c++14' '-D' '__CUDA_ARCH__=300' '-c' '-D' 'CUDA_DOUBLE_MATH_FUNCTIONS' '-v' '-m64' '-o' 'CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o' '-mtune=generic' '-march=x86-64'
+ as -v --64 -o CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o /tmp/ccSDI00n.s
+GNU assembler version 2.31.1 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.31.1
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-std=c++14' '-D' '__CUDA_ARCH__=300' '-c' '-D' 'CUDA_DOUBLE_MATH_FUNCTIONS' '-v' '-m64' '-o' 'CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o' '-mtune=generic' '-march=x86-64'
+Linking CUDA device code CMakeFiles/cmTC_5996d.dir/cmake_device_link.o
+"/tmp/CMake/bin/cmake" -E cmake_link_script CMakeFiles/cmTC_5996d.dir/dlink.txt --verbose=1
+/usr/bin/nvcc -Xcompiler=-fPIC -Wno-deprecated-gpu-targets -shared -dlink CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o -o CMakeFiles/cmTC_5996d.dir/cmake_device_link.o -L"/usr/lib/x86_64-linux-gnu"
+Linking CUDA executable cmTC_5996d
+"/tmp/CMake/bin/cmake" -E cmake_link_script CMakeFiles/cmTC_5996d.dir/link.txt --verbose=1
+/usr/lib/nvidia-cuda-toolkit/bin/g++ -v CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o CMakeFiles/cmTC_5996d.dir/cmake_device_link.o -o cmTC_5996d -L"/usr/lib/x86_64-linux-gnu/stubs" -lcudadevrt -lcudart_static -lrt -lpthread -ldl
+Using built-in specs.
+COLLECT_GCC=g++-5
+COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Debian 5.5.0-12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --enable-objc-gc --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 5.5.0 20171010 (Debian 5.5.0-12)
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_5996d' '-L/usr/lib/x86_64-linux-gnu/stubs' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/5/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper -plugin-opt=-fresolution=/tmp/cc85GscA.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o cmTC_5996d /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/5/crtbegin.o -L/usr/lib/x86_64-linux-gnu/stubs -L/usr/lib/gcc/x86_64-linux-gnu/5 -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/5/../../.. CMakeFiles/cmTC_5996d.dir/CMakeCUDACompilerABI.cu.o CMakeFiles/cmTC_5996d.dir/cmake_device_link.o -lcudadevrt -lcudart_static -lrt -lpthread -ldl -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/5/crtend.o /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crtn.o
+make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-CXX-GNU-7.3.0.input b/Tests/RunCMake/ParseImplicitData/linux-CXX-GNU-7.3.0.input
new file mode 100644
index 000000000..633a0efa7
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-CXX-GNU-7.3.0.input
@@ -0,0 +1,76 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=/usr/bin/gcc-ar-7
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=GNU
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=/usr/bin/gcc-ranlib-7
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=7.3.0
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_63146/fast"
+/usr/bin/make -f CMakeFiles/cmTC_63146.dir/build.make CMakeFiles/cmTC_63146.dir/build
+make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o
+/usr/bin/c++ -v -o CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp
+Using built-in specs.
+COLLECT_GCC=/usr/bin/c++
+OFFLOAD_TARGET_NAMES=nvptx-none
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/7/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE /usr/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/ccXqnn3f.s
+GNU C++14 (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu)
+ compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/7"
+ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/include/c++/7
+ /usr/include/x86_64-linux-gnu/c++/7
+ /usr/include/c++/7/backward
+ /usr/lib/gcc/x86_64-linux-gnu/7/include
+ /usr/local/include
+ /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+GNU C++14 (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu)
+ compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+Compiler executable checksum: 1bfae38ae5df64de6196cbd8c3b07d86
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+ as -v --64 -o CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o /tmp/ccXqnn3f.s
+GNU assembler version 2.30 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.30
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+Linking CXX executable cmTC_63146
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_63146.dir/link.txt --verbose=1
+/usr/bin/c++ -v -rdynamic CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_63146
+Using built-in specs.
+COLLECT_GCC=/usr/bin/c++
+COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
+OFFLOAD_TARGET_NAMES=nvptx-none
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_63146' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/7/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper -plugin-opt=-fresolution=/tmp/cca3NVun.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -export-dynamic -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_63146 /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/7 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/7/../../.. CMakeFiles/cmTC_63146.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o
+COLLECT_GCC_OPTIONS='-v' '-rdynamic' '-o' 'cmTC_63146' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-CXX-Intel-18.0.0.20170811.input b/Tests/RunCMake/ParseImplicitData/linux-CXX-Intel-18.0.0.20170811.input
new file mode 100644
index 000000000..22d871598
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-CXX-Intel-18.0.0.20170811.input
@@ -0,0 +1,46 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=Intel
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=18.0.0.20170811
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_d768a/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_d768a.dir/build.make CMakeFiles/cmTC_d768a.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o
+/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/icpc -v -o CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -c /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp
+icpc version 18.0.0 (gcc version 4.8.5 compatibility)
+/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/mcpcom --target_efi2 --lang=c++ -_g -mP3OPT_inline_alloca -D__ICC=1800 -D__INTEL_COMPILER=1800 -D__INTEL_COMPILER_UPDATE=0 -D__PTRDIFF_TYPE__=long "-D__SIZE_TYPE__=unsigned long" -D__WCHAR_TYPE__=int "-D__WINT_TYPE__=unsigned int" "-D__INTMAX_TYPE__=long int" "-D__UINTMAX_TYPE__=long unsigned int" -D__LONG_MAX__=9223372036854775807L -D__QMSPP_ -D__OPTIMIZE__ -D__NO_MATH_INLINES -D__NO_STRING_INLINES -D__GNUC_GNU_INLINE__ -D__GNUG__=4 -D__GNUC__=4 -D__GNUC_MINOR__=8 -D__GNUC_PATCHLEVEL__=5 -D__LP64__ -D_LP64 -D_GNU_SOURCE=1 -D__DEPRECATED=1 -D__GXX_WEAK__=1 -D__GXX_ABI_VERSION=1002 "-D__USER_LABEL_PREFIX__= " -D__REGISTER_PREFIX__= -D__INTEL_RTTI__ -D__EXCEPTIONS=1 -D__unix__ -D__unix -D__linux__ -D__linux -D__gnu_linux__ -B -Dunix -Dlinux "-_Asystem(unix)" -D__ELF__ -D__x86_64 -D__x86_64__ -D__amd64 -D__amd64__ "-_Acpu(x86_64)" "-_Amachine(x86_64)" -D__INTEL_COMPILER_BUILD_DATE=20170811 -D__INTEL_OFFLOAD -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ -D__pentium4 -D__pentium4__ -D__tune_pentium4__ -D__SSE2__ -D__SSE2_MATH__ -D__SSE__ -D__SSE_MATH__ -D__MMX__ -_k -_8 -_l --has_new_stdarg_support -_a -_b --gnu_version=40805 -_W5 --gcc-extern-inline -p --bool -tused -x --multibyte_chars -mGLOB_diag_suppress_sys --system_preinclude /usr/include/stdc-predef.h --array_section --simd --simd_func --offload_mode=1 --offload_target_names=gfx,GFX,mic,MIC --offload_unique_string=icpc1792177319iuY4UR --bool -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=485 "-mGLOB_options_string=-v -o CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -c" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/icpcv8rR8Aas_.s -mIPOPT_activate -mIPOPT_lite -mGLOB_instruction_tuning=0x0 -mGLOB_uarch_tuning=0x0 -mGLOB_product_id_code=0x22006d8f -mCG_bnl_movbe=T -mGLOB_extended_instructions=0x8 -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icpc1792177319iuY4UR -mP2OPT_hlo_level=2 -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_lto_object_enabled -mIPOPT_lto_object_value=1 -mIPOPT_obj_output_file_name=CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -mIPOPT_whole_archive_fixup_file_name=/tmp/icpcwarchqQRwIj -mGLOB_linker_version=2.27 -mGLOB_driver_tempfile_name=/tmp/icpctempfilekXiB0a -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_C_PLUS_PLUS -mP1OPT_source_file_name=/tmp/CMake/Modules/CMakeCXXCompilerABI.cpp -mP1OPT_full_source_file_name=/tmp/CMake/Modules/CMakeCXXCompilerABI.cpp -mGLOB_eh_linux /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp
+#include "..." search starts here:
+#include <...> search starts here:
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/include
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/include
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/pstl/include
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/intel64
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/icc
+ /opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include
+ /usr/include/c++/4.8.5
+ /usr/include/c++/4.8.5/x86_64-redhat-linux
+ /usr/include/c++/4.8.5/backward
+ /usr/local/include
+ /usr/lib/gcc/x86_64-redhat-linux/4.8.5/include
+ /usr/include/
+ /usr/include
+End of search list.
+Linking CXX executable cmTC_d768a
+/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_d768a.dir/link.txt --verbose=1
+/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/icpc -v -rdynamic CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_d768a
+icpc version 18.0.0 (gcc version 4.8.5 compatibility)
+/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/mcpcom -mGLOB_em64t=TRUE -mP1OPT_version=18.0-intel64 -mGLOB_diag_file=CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.diag -mGLOB_long_size_64 -mGLOB_routine_pointer_size_64 -mP1OPT_print_version=FALSE -mCG_use_gas_got_workaround=F -mP2OPT_align_option_used=TRUE -mGLOB_gcc_version=485 "-mGLOB_options_string=-v -rdynamic -o cmTC_d768a" -mGLOB_cxx_limited_range=FALSE -mCG_extend_parms=FALSE -mGLOB_compiler_bin_directory=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64 -mGLOB_as_output_backup_file_name=/tmp/icpczjpPCuas_.s -mGLOB_dashboard_use_source_name -mIPOPT_activate -mGLOB_product_id_code=0x22006d8f -mP3OPT_use_mspp_call_convention -mP2OPT_subs_out_of_bound=FALSE -mP2OPT_disam_type_based_disam=2 -mP2OPT_disam_assume_ansi_c -mP2OPT_checked_disam_ansi_alias=TRUE -mGLOB_ansi_alias -mPGOPTI_value_profile_use=T -mGLOB_opt_report_use_source_name -mP2OPT_il0_array_sections=TRUE -mGLOB_offload_mode=1 -mP2OPT_offload_unique_var_string=icpc1401760296yQqGc2 -mP2OPT_hlo -mP2OPT_hpo_rtt_control=0 -mIPOPT_args_in_regs=0 -mP2OPT_disam_assume_nonstd_intent_in=FALSE -mGLOB_imf_mapping_library=/opt/intel/compilers_and_libraries_2018.0.128/linux/bin/intel64/libiml_attr.so -mPGOPTI_gen_threadsafe_level=0 -mIPOPT_link -mIPOPT_ipo_activate -mIPOPT_mo_activate -mIPOPT_source_files_list=/tmp/icpcslis4PdBUT -mIPOPT_mo_global_data -mIPOPT_link_script_file=/tmp/icpcscript0uzJtL "-mIPOPT_cmdline_link="/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o" "-export-dynamic" "--eh-frame-hdr" "--build-id" "-dynamic-linker" "/lib64/ld-linux-x86-64.so.2" "-m" "elf_x86_64" "-o" "cmTC_d768a" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/" "-L/lib/../lib64" "-L/lib/../lib64/" "-L/usr/lib/../lib64" "-L/usr/lib/../lib64/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin/" "-L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7/" "-L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../" "-L/lib64" "-L/lib/" "-L/usr/lib64" "-L/usr/lib" "CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o" "-Bdynamic" "-Bstatic" "-limf" "-lsvml" "-lirng" "-Bdynamic" "-lstdc++" "-lm" "-Bstatic" "-lipgo" "-ldecimal" "--as-needed" "-Bdynamic" "-lcilkrts" "--no-as-needed" "-lstdc++" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc" "-lsvml" "-Bdynamic" "-lc" "-lgcc" "-lgcc_s" "-Bstatic" "-lirc_s" "-Bdynamic" "-ldl" "-lc" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtend.o" "/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crtn.o"" -mIPOPT_il_in_obj -mIPOPT_ipo_activate_warn=FALSE -mIPOPT_obj_output_file_name=/tmp/ipo_icpcGEmWvI.o -mIPOPT_whole_archive_fixup_file_name=/tmp/icpcwarchvs7jo5 -mGLOB_linker_version=2.27 -mGLOB_driver_tempfile_name=/tmp/icpctempfileQPMrZW -mP3OPT_asm_target=P3OPT_ASM_TARGET_GAS -mGLOB_async_unwind_tables=TRUE -mGLOB_obj_output_file=/tmp/ipo_icpcGEmWvI.o -mGLOB_source_dialect=GLOB_SOURCE_DIALECT_NONE -mP1OPT_source_file_name=ipo_out.c CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -mIPOPT_object_files=T -mIPOPT_assembly_files=/tmp/icpcalisfym8Dr -mIPOPT_generated_tempfiles=/tmp/icpcelisfz0edj -mIPOPT_embedded_object_base_name=/tmp/icpceobjS73lMa -mIPOPT_cmdline_link_new_name=/tmp/icpcllisTgrtl2
+ld /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtbegin.o -export-dynamic --eh-frame-hdr --build-id -dynamic-linker /lib64/ld-linux-x86-64.so.2 -m elf_x86_64 -o cmTC_d768a -L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64 -L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin -L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin -L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7 -L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7 -L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/ -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/ -L/lib/../lib64 -L/lib/../lib64/ -L/usr/lib/../lib64 -L/usr/lib/../lib64/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin/ -L/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7/ -L/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../ -L/lib64 -L/lib/ -L/usr/lib64 -L/usr/lib CMakeFiles/cmTC_d768a.dir/CMakeCXXCompilerABI.cpp.o -Bdynamic -Bstatic -limf -lsvml -lirng -Bdynamic -lstdc++ -lm -Bstatic -lipgo -ldecimal --as-needed -Bdynamic -lcilkrts --no-as-needed -lstdc++ -lgcc -lgcc_s -Bstatic -lirc -lsvml -Bdynamic -lc -lgcc -lgcc_s -Bstatic -lirc_s -Bdynamic -ldl -lc /usr/lib/gcc/x86_64-redhat-linux/4.8.5/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crtn.o
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-CXX-PGI-18.10.1.input b/Tests/RunCMake/ParseImplicitData/linux-CXX-PGI-18.10.1.input
new file mode 100644
index 000000000..f95627ee4
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-CXX-PGI-18.10.1.input
@@ -0,0 +1,40 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=PGI
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=18.10.1
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_9932f/fast"
+/usr/bin/make -f CMakeFiles/cmTC_9932f.dir/build.make CMakeFiles/cmTC_9932f.dir/build
+make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_9932f.dir/CMakeCXXCompilerABI.cpp.o
+/mnt/pgi/linux86-64/2018/bin/pgc++ -v -o CMakeFiles/cmTC_9932f.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp
+Export PGI_CURR_CUDA_HOME=/mnt/pgi/linux86-64/2018/cuda/9.1
+Export PGI=/mnt/pgi
+
+/mnt/pgi/linux86-64/18.10/bin/pggpp1 --llalign -Dunix -D__unix -D__unix__ -Dlinux -D__linux -D__linux__ -D__NO_MATH_INLINES -D__LP64__ -D__x86_64 -D__x86_64__ -D__LONG_MAX__=9223372036854775807L '-D__SIZE_TYPE__=unsigned long int' '-D__PTRDIFF_TYPE__=long int' -D__extension__= -D__amd_64__amd64__ -D__k8 -D__k8__ -D__SSE__ -D__MMX__ -D__SSE2__ -D__SSE3__ -D__PGI -D_GNU_SOURCE -D_PGCG_SOURCE -I- -I/mnt/pgi/linux86-64/18.10/include-gcc70 -I/mnt/pgi/linux86-64/18.10/include -I/usr/include/c++/7 -I/usr/include/x86_64-linux-gnu/c++/7 -I/usr/include/c++/7/backward -I/usr/lib/gcc/x86_64-linux-gnu/7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include --preinclude _cplus_preinclude.h --preinclude_macros _cplus_macros.h --gnu_version=70300 -D__pgnu_vsn=70300 -q -o /tmp/pgc++9bCe3jXUexoO.il /usr/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp
+
+/mnt/pgi/linux86-64/18.10/bin/pggpp2 /usr/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp -opt 1 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -quad -x 59 4 -tp k8 -x 120 0x1000 -astype 0 -fn /usr/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp -il /tmp/pgc++9bCe3jXUexoO.il -x 117 0x600 -x 123 0x80000000 -x 123 4 -x 119 0x20 -def __pgnu_vsn=70300 -x 120 0x200000 -x 70 0x40000000 -x 164 0x800000 -y 163 0xc0000000 -x 189 0x10 -y 189 0x4000000 -gnuvsn 70300 -x 69 0x200 -cmdline '+pgc++ /tmp/pgc++9bCe3jXUexoO.il -v -o CMakeFiles/cmTC_9932f.dir/CMakeCXXCompilerABI.cpp.o -c' -asm /tmp/pgc++LbCeVyAxx_Yt.s
+PGCC/x86 Linux 18.10-1: compilation successful
+
+/usr/bin/as /tmp/pgc++LbCeVyAxx_Yt.s -o CMakeFiles/cmTC_9932f.dir/CMakeCXXCompilerABI.cpp.o
+Action(ReadTIFile(./CMakeCXXCompilerABI.ti))
+Unlinking /tmp/pgc++9bCe3jXUexoO.il
+Unlinking /tmp/pgc++LbCeVyAxx_Yt.s
+Unlinking /tmp/pgc++nbCeNEnzNVv3.ll
+Linking CXX executable cmTC_9932f
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9932f.dir/link.txt --verbose=1
+/mnt/pgi/linux86-64/2018/bin/pgc++ -v CMakeFiles/cmTC_9932f.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_9932f
+Export PGI_CURR_CUDA_HOME=/mnt/pgi/linux86-64/2018/cuda/9.1
+Export PGI=/mnt/pgi
+
+/usr/bin/ld /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o /mnt/pgi/linux86-64/18.10/lib/trace_init.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o /mnt/pgi/linux86-64/18.10/lib/initmp.o --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /mnt/pgi/linux86-64/18.10/lib/pgi.ld -L/mnt/pgi/linux86-64/18.10/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-linux-gnu/7 CMakeFiles/cmTC_9932f.dir/CMakeCXXCompilerABI.cpp.o -rpath /mnt/pgi/linux86-64/18.10/lib -rpath /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -o cmTC_9932f -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -latomic -lpgatm -lstdc++ -lpgmp -lnuma -lpthread --start-group -lpgmath -lnspgc -lpgc --end-group -lm -lgcc -lc -lgcc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/7/crtend.o /usr/lib/x86_64-linux-gnu/crtn.o
+make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-CXX-XL-12.1.0.input b/Tests/RunCMake/ParseImplicitData/linux-CXX-XL-12.1.0.input
new file mode 100644
index 000000000..494b45c14
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-CXX-XL-12.1.0.input
@@ -0,0 +1,42 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=XL
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=12.1.0
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_a9a18/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_a9a18.dir/build.make CMakeFiles/cmTC_a9a18.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o
+/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/bin/xlc++ -+ -qthreaded -qhalt=e -V -o CMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc++
+export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447
+export XL_ASMOBJFILES=/tmp/xlcAS0adOWz
+export "XL_DIS=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/dis -o "CMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o" "CMakeCXXCompilerABI.o""
+/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/exe/xlCentry -qosvar=rhel.6.9 -qalias=ansi -qtls -D_CALL_SYSV -D__null=0 -D__NO_MATH_INLINES -qtls -q64 -qgnu_version=4.4.7 -qthreaded -qhalt=e -qasm_as=/usr/bin/as -qcpp_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/include -qc_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -qgcc_cpp_stdinc=/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7:/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ppc64-redhat-linux:/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qgcc_c_stdinc=/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qcomplexgccincl=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -oCMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp /tmp/xlcW0C4fVNg /tmp/xlcW1gn9wsn /dev/null /tmp/xlcLo7QvMFF.lst /dev/null /tmp/xlcW2svId7t
+export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode
+export XL_LINKER=/usr/bin/ld
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode -qalias=ansi -qtls -qtls -qthreaded -qhalt=e /tmp/xlcW0C4fVNg /tmp/xlcW1gn9wsn CMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o /tmp/xlcLo7QvMFB.lst /tmp/xlcW2svId7t
+rm /tmp/xlcAS0adOWz
+rm /tmp/xlcLo7QvMF
+rm /tmp/xlcW0C4fVNg
+rm /tmp/xlcW1gn9wsn
+rm /tmp/xlcW2svId7t
+Linking CXX executable cmTC_a9a18
+/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a9a18.dir/link.txt --verbose=1
+/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/bin/xlc++ -qthreaded -qhalt=e -V CMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_a9a18 -Wl,-export-dynamic
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc++
+export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447
+/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64 -L/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_a9a18.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_a9a18 -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlopt -lxl -libmc++ -lxlopt -lxl -lstdc++ -lm -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o
+rm /tmp/xlcW0zyCKVs
+rm /tmp/xlcW1UOt3GL
+rm /tmp/xlcW2lKGvs4
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-CXX-XL-16.1.0.0.input b/Tests/RunCMake/ParseImplicitData/linux-CXX-XL-16.1.0.0.input
new file mode 100644
index 000000000..37aa450fb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-CXX-XL-16.1.0.0.input
@@ -0,0 +1,40 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=XL
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=16.1.0.0
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_f0c9c/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_f0c9c.dir/build.make CMakeFiles/cmTC_f0c9c.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o
+/opt/ibm/xlC/16.1.0/bin/xlc++ -+ -qthreaded -V -o CMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o -c "/tmp/CMake/Modules/CMakeCXXCompilerABI.cpp"
+export XL_CONFIG=/opt/ibm/xlC/16.1.0/etc/xlc.cfg.centos.7.gcc.4.8.5:xlc++
+export XL_ASMOBJFILES=/tmp/xlcASfU5Npd
+export "XL_DIS=/opt/ibm/xlC/16.1.0/exe/dis -o "CMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o" "CMakeCXXCompilerABI.o""
+/opt/ibm/xlC/16.1.0/exe/xlCentry -qosvar=centos.7.0 -qalias=ansi -qthreaded -D_REENTRANT -D__VACPP_MULTI__ -qtls -q64 -D_CALL_SYSV -D__NO_MATH_INLINES -D_CALL_ELF=2 -Wno-parentheses -Wno-unused-value -maltivec -qtls -q64 -qgnu_version=4.8.5 -qthreaded -xc++ -qasm_as=/usr/bin/as -qcpp_stdinc=/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlmass/9.1.0/include:/opt/ibm/xlC/16.1.0/include -qc_stdinc=/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlmass/9.1.0/include:/opt/ibm/xlC/16.1.0/include -qgcc_cpp_stdinc=/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5:/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ppc64le-redhat-linux:/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/backward:/opt/ibm/xlC/16.1.0/include:/usr/local/include:/opt/ibm/xlC/16.1.0/include:/usr/include -qgcc_c_stdinc=/opt/ibm/xlC/16.1.0/include:/usr/local/include:/opt/ibm/xlC/16.1.0/include:/usr/include -qcomplexgccincl=/opt/ibm/xlsmp/5.1.0/include:/opt/ibm/xlmass/9.1.0/include:/opt/ibm/xlC/16.1.0/include:/opt/ibm/xlC/16.1.0/include:/usr/local/include:/opt/ibm/xlC/16.1.0/include:/usr/include -oCMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o "/tmp/CMake/Modules/CMakeCXXCompilerABI.cpp" /tmp/xlcW02F8mZr /tmp/xlcW1xG0Ns2 /dev/null /tmp/xlcLI57mTNF.lst /dev/null /tmp/xlcW2qVifWC
+export XL_BACKEND=/opt/ibm/xlC/16.1.0/exe/xlCcode
+export XL_LINKER=/usr/bin/ld
+/opt/ibm/xlC/16.1.0/exe/xlCcode -qalias=ansi -qthreaded -qtls -maltivec -qtls -qthreaded /tmp/xlcW02F8mZr /tmp/xlcW1xG0Ns2 CMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o /tmp/xlcLI57mTNB.lst /tmp/xlcW2qVifWC
+rm /tmp/xlcASfU5Npd
+rm /tmp/xlcLI57mTN
+rm /tmp/xlcW02F8mZr
+rm /tmp/xlcW1xG0Ns2
+rm /tmp/xlcW2qVifWC
+Linking CXX executable cmTC_f0c9c
+"/tmp/CMake/bin/cmake" -E cmake_link_script CMakeFiles/cmTC_f0c9c.dir/link.txt --verbose=1
+/opt/ibm/xlC/16.1.0/bin/xlc++ -qthreaded -V -Wl,-export-dynamic CMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_f0c9c
+export XL_CONFIG=/opt/ibm/xlC/16.1.0/etc/xlc.cfg.centos.7.gcc.4.8.5:xlc++
+/usr/bin/ld --eh-frame-hdr -Qy -melf64lppc -dynamic-linker /lib64/ld64.so.2 --enable-new-dtags /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crt1.o /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crti.o /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/crtbegin.o -L/opt/ibm/xlsmp/5.1.0/lib -L/opt/ibm/xlmass/9.1.0/lib -L/opt/ibm/xlC/16.1.0/lib -R/opt/ibm/lib -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5 -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../.. -export-dynamic CMakeFiles/cmTC_f0c9c.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_f0c9c -lxlopt -lxl -libmc++ -lstdc++ -lm -ldl -lgcc_s -lgcc --as-needed -lpthread --no-as-needed -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/crtend.o /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../lib64/crtn.o
+rm /tmp/xlcW0HSoDlw
+rm /tmp/xlcW1dUcwR6
+rm /tmp/xlcW25pPonH
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-Fortran-GNU-7.3.0.input b/Tests/RunCMake/ParseImplicitData/linux-Fortran-GNU-7.3.0.input
new file mode 100644
index 000000000..4582433de
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-Fortran-GNU-7.3.0.input
@@ -0,0 +1,76 @@
+CMAKE_LANG=Fortran
+CMAKE_Fortran_COMPILER_ABI=
+CMAKE_Fortran_COMPILER_AR=/usr/bin/gcc-ar-7
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=GNU
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=/usr/bin/gcc-ranlib-7
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=7.3.0
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_1cf45/fast"
+/usr/bin/make -f CMakeFiles/cmTC_1cf45.dir/build.make CMakeFiles/cmTC_1cf45.dir/build
+make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o
+/usr/bin/f95 -v -c /proj/TableFS/data/chuck/cmake/f/share/cmake-3.13/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o
+Using built-in specs.
+COLLECT_GCC=/usr/bin/f95
+OFFLOAD_TARGET_NAMES=nvptx-none
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
+COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/7/f951 /proj/TableFS/data/chuck/cmake/f/share/cmake-3.13/Modules/CMakeFortranCompilerABI.F -ffixed-form -cpp=/tmp/cc9yADLU.f90 -quiet -v -imultiarch x86_64-linux-gnu /proj/TableFS/data/chuck/cmake/f/share/cmake-3.13/Modules/CMakeFortranCompilerABI.F -quiet -dumpbase CMakeFortranCompilerABI.F -mtune=generic -march=x86-64 -auxbase-strip CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o -version -fintrinsic-modules-path /usr/lib/gcc/x86_64-linux-gnu/7/finclude -o /tmp/ccH7qQQk.s
+GNU Fortran (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu)
+ compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
+ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/lib/gcc/x86_64-linux-gnu/7/finclude
+ /usr/lib/gcc/x86_64-linux-gnu/7/include
+ /usr/local/include
+ /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
+ /usr/include/x86_64-linux-gnu
+ /usr/include
+End of search list.
+GNU Fortran2008 (Ubuntu 7.3.0-27ubuntu1~18.04) version 7.3.0 (x86_64-linux-gnu)
+ compiled by GNU C version 7.3.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP
+
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64'
+ as -v --64 -o CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o /tmp/ccH7qQQk.s
+GNU assembler version 2.30 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.30
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-c' '-o' 'CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o' '-mtune=generic' '-march=x86-64'
+Linking Fortran executable cmTC_1cf45
+/proj/TableFS/data/chuck/cmake/f/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1cf45.dir/link.txt --verbose=1
+/usr/bin/f95 -v CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o -o cmTC_1cf45
+Driving: /usr/bin/f95 -v CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o -o cmTC_1cf45 -l gfortran -l m -shared-libgcc
+Using built-in specs.
+COLLECT_GCC=/usr/bin/f95
+COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
+OFFLOAD_TARGET_NAMES=nvptx-none
+OFFLOAD_TARGET_DEFAULT=1
+Target: x86_64-linux-gnu
+Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
+Thread model: posix
+gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
+Reading specs from /usr/lib/gcc/x86_64-linux-gnu/7/libgfortran.spec
+rename spec lib to liborig
+COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_1cf45' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/
+LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/7/../../../:/lib/:/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_1cf45' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+ /usr/lib/gcc/x86_64-linux-gnu/7/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/7/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper -plugin-opt=-fresolution=/tmp/ccS0UYIY.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lquadmath -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z now -z relro -o cmTC_1cf45 /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbeginS.o -L/usr/lib/gcc/x86_64-linux-gnu/7 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/7/../../.. CMakeFiles/cmTC_1cf45.dir/CMakeFortranCompilerABI.F.o -lgfortran -lm -lgcc_s -lgcc -lquadmath -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/7/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/crtn.o
+COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_1cf45' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
+make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-Fortran-PGI-18.10.1.input b/Tests/RunCMake/ParseImplicitData/linux-Fortran-PGI-18.10.1.input
new file mode 100644
index 000000000..fe49bcdee
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-Fortran-PGI-18.10.1.input
@@ -0,0 +1,47 @@
+CMAKE_LANG=Fortran
+CMAKE_Fortran_COMPILER_ABI=
+CMAKE_Fortran_COMPILER_AR=
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=PGI
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=18.10.1
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_1e8d2/fast"
+/usr/bin/make -f CMakeFiles/cmTC_1e8d2.dir/build.make CMakeFiles/cmTC_1e8d2.dir/build
+make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_1e8d2.dir/CMakeFortranCompilerABI.F.o
+/mnt/pgi/linux86-64/2018/bin/pgfortran -v -c /usr/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_1e8d2.dir/CMakeFortranCompilerABI.F.o
+Export PGI_CURR_CUDA_HOME=/mnt/pgi/linux86-64/2018/cuda/9.1
+Export PGI=/mnt/pgi
+
+/mnt/pgi/linux86-64/18.10/bin/pgf901 /usr/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -opt 1 -nohpf -nostatic -x 19 0x400000 -quad -x 59 4 -x 15 2 -x 49 0x400004 -x 51 0x20 -x 57 0x4c -x 58 0x10000 -x 124 0x1000 -tp k8 -x 57 0xfb0000 -x 58 0x78031040 -x 47 0x08 -x 48 4608 -x 49 0x100 -x 120 0x200 -stdinc /mnt/pgi/linux86-64/18.10/include-gcc70:/mnt/pgi/linux86-64/18.10/include:/usr/lib/gcc/x86_64-linux-gnu/7/include:/usr/local/include:/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed:/usr/include/x86_64-linux-gnu:/usr/include -cmdline '+pgfortran /usr/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -v -c -o CMakeFiles/cmTC_1e8d2.dir/CMakeFortranCompilerABI.F.o' -def unix -def __unix -def __unix__ -def linux -def __linux -def __linux__ -def __NO_MATH_INLINES -def __LP64__ -def __x86_64 -def __x86_64__ -def __LONG_MAX__=9223372036854775807L -def '__SIZE_TYPE__=unsigned long int' -def '__PTRDIFF_TYPE__=long int' -def __extension__= -def __amd_64__amd64__ -def __k8 -def __k8__ -def __SSE__ -def __MMX__ -def __SSE2__ -def __SSE3__ -preprocess -nofreeform -vect 48 -x 54 1 -x 70 0x40000000 -y 163 0xc0000000 -x 189 0x10 -modexport /tmp/pgfortranSoCeegQjDEd5.cmod -modindex /tmp/pgfortranmoCeK26CaVn7.cmdx -output /tmp/pgfortranSoCeeXSv8E7w.ilm
+ 0 inform, 0 warnings, 0 severes, 0 fatal for cmakefortrancompilerabi
+PGF90/x86-64 Linux 18.10-1: compilation successful
+
+/mnt/pgi/linux86-64/18.10/bin/pgf902 /tmp/pgfortranSoCeeXSv8E7w.ilm -fn /usr/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -opt 1 -x 51 0x20 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -quad -x 59 4 -tp k8 -x 120 0x1000 -x 124 0x1400 -y 15 2 -x 57 0x3b0000 -x 58 0x48000000 -x 49 0x100 -x 120 0x200 -astype 0 -x 68 0x20 -x 70 0x40000000 -x 164 0x800000 -x 124 1 -y 163 0xc0000000 -x 189 0x10 -y 189 0x4000000 -cmdline '+pgfortran /usr/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -v -c -o CMakeFiles/cmTC_1e8d2.dir/CMakeFortranCompilerABI.F.o' -asm /tmp/pgfortranSoCeeRr681iB.s
+ 0 inform, 0 warnings, 0 severes, 0 fatal for cmakefortrancompilerabi
+PGF90/x86-64 Linux 18.10-1: compilation successful
+
+/usr/bin/as /tmp/pgfortranSoCeeRr681iB.s -o CMakeFiles/cmTC_1e8d2.dir/CMakeFortranCompilerABI.F.o
+
+/mnt/pgi/linux86-64/18.10/bin/pgappend -noerror CMakeFiles/cmTC_1e8d2.dir/CMakeFortranCompilerABI.F.o -name .IPDINFO /tmp/pgfortranSoCeegQjDEd5.cmod -name .IPEINFO /tmp/pgfortranmoCeK26CaVn7.cmdx
+Unlinking /tmp/pgfortranSoCeeXSv8E7w.ilm
+Unlinking /tmp/pgfortranmoCeK5sPGGfq.stb
+Unlinking /tmp/pgfortranSoCeegQjDEd5.cmod
+Unlinking /tmp/pgfortranmoCeK26CaVn7.cmdx
+Unlinking /tmp/pgfortranSoCeeRr681iB.s
+Unlinking /tmp/pgfortranmoCeKdFYP9Gu.ll
+Linking Fortran executable cmTC_1e8d2
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1e8d2.dir/link.txt --verbose=1
+/mnt/pgi/linux86-64/2018/bin/pgfortran -v CMakeFiles/cmTC_1e8d2.dir/CMakeFortranCompilerABI.F.o -o cmTC_1e8d2
+Export PGI_CURR_CUDA_HOME=/mnt/pgi/linux86-64/2018/cuda/9.1
+Export PGI=/mnt/pgi
+
+/usr/bin/ld /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o /mnt/pgi/linux86-64/18.10/lib/trace_init.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o /mnt/pgi/linux86-64/18.10/lib/initmp.o /mnt/pgi/linux86-64/18.10/lib/f90main.o --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /mnt/pgi/linux86-64/18.10/lib/pgi.ld -L/mnt/pgi/linux86-64/18.10/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-linux-gnu/7 CMakeFiles/cmTC_1e8d2.dir/CMakeFortranCompilerABI.F.o -rpath /mnt/pgi/linux86-64/18.10/lib -rpath /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -o cmTC_1e8d2 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -lpgf90rtl -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lpgmp -lnuma -lpthread --start-group -lpgmath -lnspgc -lpgc --end-group -lrt -lpthread -lm -lgcc -lc -lgcc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/7/crtend.o /usr/lib/x86_64-linux-gnu/crtn.o
+make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux-Fortran-XL-14.1.0.input b/Tests/RunCMake/ParseImplicitData/linux-Fortran-XL-14.1.0.input
new file mode 100644
index 000000000..d80cedef7
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux-Fortran-XL-14.1.0.input
@@ -0,0 +1,50 @@
+CMAKE_LANG=Fortran
+CMAKE_Fortran_COMPILER_ABI=ELF
+CMAKE_Fortran_COMPILER_AR=
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=XL
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=14.1.0
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_d05a9/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_d05a9.dir/build.make CMakeFiles/cmTC_d05a9.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_d05a9.dir/CMakeFortranCompilerABI.F.o
+/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/bin/xlf -qthreaded -qhalt=e -V -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_d05a9.dir/CMakeFortranCompilerABI.F.o
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/etc/xlf.cfg.rhel6.9.gcc447:xlf
+export XLF_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/etc/V1R2M4.xlf.cfg.rhel6.9.gcc447
+export "XL_DIS=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/dis -o "CMakeFiles/cmTC_d05a9.dir/CMakeFortranCompilerABI.F.o" "CMakeFortranCompilerABI.o""
+/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/cpp /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeFortranCompilerABI.F /tmp/F841970obBXFf -C -I/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include -I/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/include
+/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfentry /tmp/F841970obBXFf /tmp/F841970QXWvB4 /tmp/F841970QXWvB4F.lst xlfsmsg.cat xlfmsg.cat /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeFortranCompilerABI.F "OSVAR(rhel.6.9)" NOZEROSIZE SAVE "ALIAS(intptr)" "POSITION(appendold)" "XLF90(noautodealloc,nosignedzero,oldpad)" "XLF77(intarg,intxor,persistent,noleadzero,gedit77,noblankpad,oldboz,softeof)" "XLF2003(nopolymorphic,nobozlitargs,nostopexcept,novolatile,noautorealloc,oldnaninf)" "XLF2008(nocheckpresence)" 64 "GNU_VERSION(4.4.7)" "SAVEOPTFILE(/tmp/optf.41970mydp8V)" "SAVEVERSIONFILE(/tmp/version.41970sjsfYH)" THREADED "HALT(e)" "WSTREAMS(/tmp/F8419704oFzOth1,/tmp/F8419704oFzOtb1,/tmp/F8419704oFzOts1)" "DEFMSG(/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/msg/en_US)" -I/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include -I/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/include
+COMMAND LINE 1520-061 (W) The XLF77(PERSISTENT) option stores entities in static storage. This may affect the thread safety of your code.
+COMMAND LINE 1520-061 (W) The SAVE option stores entities in static storage. This may affect the thread safety of your code.
+** cmakefortrancompilerabi === End of Compilation 1 ===
+rm /tmp/F841970obBXFf
+export XL_FRONTEND=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfentry
+export XL_ASTI=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfhot
+export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfcode
+export XL_LINKER=/usr/bin/ld
+export XL_BOLT=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/bolt
+/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfhot /tmp/F8419704oFzOth1 /tmp/F8419704oFzOth2 /tmp/F8419704oFzOtb1 /tmp/F8419704oFzOtb2 /tmp/F8419704oFzOts1 /tmp/F8419704oFzOts2 /tmp/F841970QXWvB4 /tmp/F841970QXWvB4A.lst
+export XL_FRONTEND=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfentry
+export XL_ASTI=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfhot
+export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfcode
+export XL_LINKER=/usr/bin/ld
+export XL_BOLT=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/bolt
+/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/exe/xlfcode /tmp/F8419704oFzOth2 /tmp/F8419704oFzOtb2 CMakeFiles/cmTC_d05a9.dir/CMakeFortranCompilerABI.F.o /tmp/F841970QXWvB4B.lst /tmp/F8419704oFzOts2
+1501-510 Compilation successful for file CMakeFortranCompilerABI.F.
+rm /tmp/optf.41970mydp8V
+Linking Fortran executable cmTC_d05a9
+/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_d05a9.dir/link.txt --verbose=1
+/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/bin/xlf -V -qthreaded -qhalt=e CMakeFiles/cmTC_d05a9.dir/CMakeFortranCompilerABI.F.o -o cmTC_d05a9 -Wl,-export-dynamic
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/etc/xlf.cfg.rhel6.9.gcc447:xlf
+export XLF_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/etc/V1R2M4.xlf.cfg.rhel6.9.gcc447
+/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_d05a9.dir/CMakeFortranCompilerABI.F.o -o cmTC_d05a9 -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlf90 -lxlopt -lxlomp_ser -lxl -lxlfmath -lgcc_s -ldl -lrt -lpthread -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o
+rm /tmp/optf.419839KEged
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux_nostdinc-C-PGI-18.10.1.input b/Tests/RunCMake/ParseImplicitData/linux_nostdinc-C-PGI-18.10.1.input
new file mode 100644
index 000000000..5e2e49ab8
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux_nostdinc-C-PGI-18.10.1.input
@@ -0,0 +1,36 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=PGI
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=18.10.1
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_a7f0d/fast"
+/usr/bin/make -f CMakeFiles/cmTC_a7f0d.dir/build.make CMakeFiles/cmTC_a7f0d.dir/build
+make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_a7f0d.dir/CMakeCCompilerABI.c.o
+/mnt/pgi/linux86-64/2018/bin/pgcc -Mnostdinc -v -o CMakeFiles/cmTC_a7f0d.dir/CMakeCCompilerABI.c.o -c /usr/share/cmake-3.10/Modules/CMakeCCompilerABI.c
+Export PGI_CURR_CUDA_HOME=/mnt/pgi/linux86-64/2018/cuda/9.1
+Export PGI=/mnt/pgi
+
+/mnt/pgi/linux86-64/18.10/bin/pgc /usr/share/cmake-3.10/Modules/CMakeCCompilerABI.c -opt 1 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -quad -x 59 4 -tp k8 -x 120 0x1000 -astype 0 -nostdinc -def unix -def __unix -def __unix__ -def linux -def __linux -def __linux__ -def __NO_MATH_INLINES -def __LP64__ -def __x86_64 -def __x86_64__ -def __LONG_MAX__=9223372036854775807L -def '__SIZE_TYPE__=unsigned long int' -def '__PTRDIFF_TYPE__=long int' -def __extension__= -def __amd_64__amd64__ -def __k8 -def __k8__ -def __SSE__ -def __MMX__ -def __SSE2__ -def __SSE3__ -predicate '#machine(x86_64) #lint(off) #system(posix) #cpu(x86_64)' -cmdline '+pgcc /usr/share/cmake-3.10/Modules/CMakeCCompilerABI.c -Mnostdinc -v -o CMakeFiles/cmTC_a7f0d.dir/CMakeCCompilerABI.c.o -c' -outfile CMakeFiles/cmTC_a7f0d.dir/CMakeCCompilerABI.c.o -x 123 0x80000000 -x 123 4 -x 2 0x400 -x 119 0x20 -def __pgnu_vsn=70300 -x 120 0x200000 -x 70 0x40000000 -x 164 0x800000 -y 163 0xc0000000 -x 189 0x10 -y 189 0x4000000 -asm /tmp/pgccjRkfBrHQsITu.s
+PGC/x86-64 Linux 18.10-1: compilation successful
+
+/usr/bin/as /tmp/pgccjRkfBrHQsITu.s -o CMakeFiles/cmTC_a7f0d.dir/CMakeCCompilerABI.c.o
+Unlinking /tmp/pgccjRkfBrHQsITu.s
+Unlinking /tmp/pgccrRkfZClhdaSG.ll
+Linking C executable cmTC_a7f0d
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a7f0d.dir/link.txt --verbose=1
+/mnt/pgi/linux86-64/2018/bin/pgcc -Mnostdinc -v CMakeFiles/cmTC_a7f0d.dir/CMakeCCompilerABI.c.o -o cmTC_a7f0d
+Export PGI_CURR_CUDA_HOME=/mnt/pgi/linux86-64/2018/cuda/9.1
+Export PGI=/mnt/pgi
+
+/usr/bin/ld /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o /mnt/pgi/linux86-64/18.10/lib/trace_init.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o /mnt/pgi/linux86-64/18.10/lib/initmp.o --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /mnt/pgi/linux86-64/18.10/lib/pgi.ld -L/mnt/pgi/linux86-64/18.10/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-linux-gnu/7 CMakeFiles/cmTC_a7f0d.dir/CMakeCCompilerABI.c.o -rpath /mnt/pgi/linux86-64/18.10/lib -rpath /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -o cmTC_a7f0d -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -lpgmp -lnuma -lpthread --start-group -lpgmath -lnspgc -lpgc --end-group -lm -lgcc -lc -lgcc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/7/crtend.o /usr/lib/x86_64-linux-gnu/crtn.o
+make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux_nostdinc-C-XL-12.1.0.input b/Tests/RunCMake/ParseImplicitData/linux_nostdinc-C-XL-12.1.0.input
new file mode 100644
index 000000000..8b1e2860b
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux_nostdinc-C-XL-12.1.0.input
@@ -0,0 +1,42 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=XL
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=12.1.0
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_b8c4a/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_b8c4a.dir/build.make CMakeFiles/cmTC_b8c4a.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/bin/xlc -qnostdinc -V -o CMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCCompilerABI.c
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc
+export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447
+export XL_ASMOBJFILES=/tmp/xlcASEFMkoN
+export "XL_DIS=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/dis -o "CMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o" "CMakeCCompilerABI.o""
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlcentry -qosvar=rhel.6.9 -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qtls -D_CALL_SYSV -D__null=0 -D__NO_MATH_INLINES -qtls -q64 -qgnu_version=4.4.7 -qnostdinc -qasm_as=/usr/bin/as -qc_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -qgcc_c_stdinc=/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qcomplexgccincl=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qvac_include_path=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -oCMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCCompilerABI.c /tmp/xlcW0cUFNRj /tmp/xlcW1YJsgzt /dev/null /tmp/xlcLI4MvwXF.lst /dev/null /tmp/xlcW2sIonhD
+export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode
+export XL_LINKER=/usr/bin/ld
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qtls -qtls -qnostdinc /tmp/xlcW0cUFNRj /tmp/xlcW1YJsgzt CMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o /tmp/xlcLI4MvwXB.lst /tmp/xlcW2sIonhD
+rm /tmp/xlcASEFMkoN
+rm /tmp/xlcLI4MvwX
+rm /tmp/xlcW0cUFNRj
+rm /tmp/xlcW1YJsgzt
+rm /tmp/xlcW2sIonhD
+Linking C executable cmTC_b8c4a
+/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_b8c4a.dir/link.txt --verbose=1
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/bin/xlc -qnostdinc -V CMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o -o cmTC_b8c4a -Wl,-export-dynamic
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc
+export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447
+/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64 -L/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_b8c4a.dir/CMakeCCompilerABI.c.o -o cmTC_b8c4a -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlopt -lxl -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o
+rm /tmp/xlcW03gDCly
+rm /tmp/xlcW1oa6XxW
+rm /tmp/xlcW2fQXnKk
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux_nostdinc-CXX-PGI-18.10.1.input b/Tests/RunCMake/ParseImplicitData/linux_nostdinc-CXX-PGI-18.10.1.input
new file mode 100644
index 000000000..dd2b55d91
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux_nostdinc-CXX-PGI-18.10.1.input
@@ -0,0 +1,40 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=PGI
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=18.10.1
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_90855/fast"
+/usr/bin/make -f CMakeFiles/cmTC_90855.dir/build.make CMakeFiles/cmTC_90855.dir/build
+make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_90855.dir/CMakeCXXCompilerABI.cpp.o
+/mnt/pgi/linux86-64/2018/bin/pgc++ -Mnostdinc -v -o CMakeFiles/cmTC_90855.dir/CMakeCXXCompilerABI.cpp.o -c /usr/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp
+Export PGI_CURR_CUDA_HOME=/mnt/pgi/linux86-64/2018/cuda/9.1
+Export PGI=/mnt/pgi
+
+/mnt/pgi/linux86-64/18.10/bin/pggpp1 --llalign -Dunix -D__unix -D__unix__ -Dlinux -D__linux -D__linux__ -D__NO_MATH_INLINES -D__LP64__ -D__x86_64 -D__x86_64__ -D__LONG_MAX__=9223372036854775807L '-D__SIZE_TYPE__=unsigned long int' '-D__PTRDIFF_TYPE__=long int' -D__extension__= -D__amd_64__amd64__ -D__k8 -D__k8__ -D__SSE__ -D__MMX__ -D__SSE2__ -D__SSE3__ -D__PGI -D_GNU_SOURCE -D_PGCG_SOURCE -I- -I/mnt/pgi/linux86-64/18.10/include-gcc70 -I/mnt/pgi/linux86-64/18.10/include -I/usr/include/c++/7 -I/usr/include/x86_64-linux-gnu/c++/7 -I/usr/include/c++/7/backward -I/usr/lib/gcc/x86_64-linux-gnu/7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include --preinclude _cplus_preinclude.h --preinclude_macros _cplus_macros.h --gnu_version=70300 -D__pgnu_vsn=70300 -q -o /tmp/pgc++X3kftwl3x0Hl.il /usr/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp
+
+/mnt/pgi/linux86-64/18.10/bin/pggpp2 /usr/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp -opt 1 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -quad -x 59 4 -tp k8 -x 120 0x1000 -astype 0 -fn /usr/share/cmake-3.10/Modules/CMakeCXXCompilerABI.cpp -il /tmp/pgc++X3kftwl3x0Hl.il -x 117 0x600 -x 123 0x80000000 -x 123 4 -x 119 0x20 -def __pgnu_vsn=70300 -x 120 0x200000 -x 70 0x40000000 -x 164 0x800000 -y 163 0xc0000000 -x 189 0x10 -y 189 0x4000000 -gnuvsn 70300 -x 69 0x200 -cmdline '+pgc++ /tmp/pgc++X3kftwl3x0Hl.il -Mnostdinc -v -o CMakeFiles/cmTC_90855.dir/CMakeCXXCompilerABI.cpp.o -c' -asm /tmp/pgc++53kfRignAQXZ.s
+PGCC/x86 Linux 18.10-1: compilation successful
+
+/usr/bin/as /tmp/pgc++53kfRignAQXZ.s -o CMakeFiles/cmTC_90855.dir/CMakeCXXCompilerABI.cpp.o
+Action(ReadTIFile(./CMakeCXXCompilerABI.ti))
+Unlinking /tmp/pgc++X3kftwl3x0Hl.il
+Unlinking /tmp/pgc++53kfRignAQXZ.s
+Unlinking /tmp/pgc++b3kfdox2AAgc.ll
+Linking CXX executable cmTC_90855
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_90855.dir/link.txt --verbose=1
+/mnt/pgi/linux86-64/2018/bin/pgc++ -Mnostdinc -v CMakeFiles/cmTC_90855.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_90855
+Export PGI_CURR_CUDA_HOME=/mnt/pgi/linux86-64/2018/cuda/9.1
+Export PGI=/mnt/pgi
+
+/usr/bin/ld /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o /mnt/pgi/linux86-64/18.10/lib/trace_init.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o /mnt/pgi/linux86-64/18.10/lib/initmp.o --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /mnt/pgi/linux86-64/18.10/lib/pgi.ld -L/mnt/pgi/linux86-64/18.10/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-linux-gnu/7 CMakeFiles/cmTC_90855.dir/CMakeCXXCompilerABI.cpp.o -rpath /mnt/pgi/linux86-64/18.10/lib -rpath /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -o cmTC_90855 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -latomic -lpgatm -lstdc++ -lpgmp -lnuma -lpthread --start-group -lpgmath -lnspgc -lpgc --end-group -lm -lgcc -lc -lgcc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/7/crtend.o /usr/lib/x86_64-linux-gnu/crtn.o
+make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux_nostdinc-CXX-XL-12.1.0.input b/Tests/RunCMake/ParseImplicitData/linux_nostdinc-CXX-XL-12.1.0.input
new file mode 100644
index 000000000..f6b5d9111
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux_nostdinc-CXX-XL-12.1.0.input
@@ -0,0 +1,42 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=XL
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=12.1.0
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_98791/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_98791.dir/build.make CMakeFiles/cmTC_98791.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o
+/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/bin/xlC -+ -qnostdinc -V -o CMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlC
+export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447
+export XL_ASMOBJFILES=/tmp/xlcAS82INiZ
+export "XL_DIS=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/dis -o "CMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o" "CMakeCXXCompilerABI.o""
+/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/exe/xlCentry -qosvar=rhel.6.9 -qalias=ansi -qtls -D_CALL_SYSV -D__null=0 -D__NO_MATH_INLINES -qtls -q64 -qgnu_version=4.4.7 -qnostdinc -qasm_as=/usr/bin/as -qcpp_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/include -qc_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -qgcc_cpp_stdinc=/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7:/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ppc64-redhat-linux:/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qgcc_c_stdinc=/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qcomplexgccincl=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -oCMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp /tmp/xlcW0SEqGeR /tmp/xlcW1AfQ1jy /dev/null /tmp/xlcLmUAPcJF.lst /dev/null /tmp/xlcW2OCErpf
+export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode
+export XL_LINKER=/usr/bin/ld
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode -qalias=ansi -qtls -qtls -qnostdinc /tmp/xlcW0SEqGeR /tmp/xlcW1AfQ1jy CMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o /tmp/xlcLmUAPcJB.lst /tmp/xlcW2OCErpf
+rm /tmp/xlcAS82INiZ
+rm /tmp/xlcLmUAPcJ
+rm /tmp/xlcW0SEqGeR
+rm /tmp/xlcW1AfQ1jy
+rm /tmp/xlcW2OCErpf
+Linking CXX executable cmTC_98791
+/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_98791.dir/link.txt --verbose=1
+/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/bin/xlC -qnostdinc -V CMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_98791 -Wl,-export-dynamic
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlC
+export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447
+/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64 -L/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_98791.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_98791 -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlopt -lxl -libmc++ -lxlopt -lxl -lstdc++ -lm -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o
+rm /tmp/xlcW0DcBWi8
+rm /tmp/xlcW14NqGs6
+rm /tmp/xlcW2Z8nuC4
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux_nostdinc-Fortran-PGI-18.10.1.input b/Tests/RunCMake/ParseImplicitData/linux_nostdinc-Fortran-PGI-18.10.1.input
new file mode 100644
index 000000000..12727f048
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux_nostdinc-Fortran-PGI-18.10.1.input
@@ -0,0 +1,47 @@
+CMAKE_LANG=Fortran
+CMAKE_Fortran_COMPILER_ABI=
+CMAKE_Fortran_COMPILER_AR=
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=PGI
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=18.10.1
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_b7462/fast"
+/usr/bin/make -f CMakeFiles/cmTC_b7462.dir/build.make CMakeFiles/cmTC_b7462.dir/build
+make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_b7462.dir/CMakeFortranCompilerABI.F.o
+/mnt/pgi/linux86-64/2018/bin/pgfortran -Mnostdinc -v -c /usr/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_b7462.dir/CMakeFortranCompilerABI.F.o
+Export PGI_CURR_CUDA_HOME=/mnt/pgi/linux86-64/2018/cuda/9.1
+Export PGI=/mnt/pgi
+
+/mnt/pgi/linux86-64/18.10/bin/pgf901 /usr/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -opt 1 -nohpf -nostatic -x 19 0x400000 -quad -x 59 4 -x 15 2 -x 49 0x400004 -x 51 0x20 -x 57 0x4c -x 58 0x10000 -x 124 0x1000 -tp k8 -x 57 0xfb0000 -x 58 0x78031040 -x 47 0x08 -x 48 4608 -x 49 0x100 -x 120 0x200 -nostdinc -cmdline '+pgfortran /usr/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -Mnostdinc -v -c -o CMakeFiles/cmTC_b7462.dir/CMakeFortranCompilerABI.F.o' -def unix -def __unix -def __unix__ -def linux -def __linux -def __linux__ -def __NO_MATH_INLINES -def __LP64__ -def __x86_64 -def __x86_64__ -def __LONG_MAX__=9223372036854775807L -def '__SIZE_TYPE__=unsigned long int' -def '__PTRDIFF_TYPE__=long int' -def __extension__= -def __amd_64__amd64__ -def __k8 -def __k8__ -def __SSE__ -def __MMX__ -def __SSE2__ -def __SSE3__ -preprocess -nofreeform -vect 48 -x 54 1 -x 70 0x40000000 -y 163 0xc0000000 -x 189 0x10 -modexport /tmp/pgfortranoelfQQWHVV3l.cmod -modindex /tmp/pgfortran_elf6-1UcVhp.cmdx -output /tmp/pgfortranUelfk_cqURUw.ilm
+ 0 inform, 0 warnings, 0 severes, 0 fatal for cmakefortrancompilerabi
+PGF90/x86-64 Linux 18.10-1: compilation successful
+
+/mnt/pgi/linux86-64/18.10/bin/pgf902 /tmp/pgfortranUelfk_cqURUw.ilm -fn /usr/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -opt 1 -x 51 0x20 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -quad -x 59 4 -tp k8 -x 120 0x1000 -x 124 0x1400 -y 15 2 -x 57 0x3b0000 -x 58 0x48000000 -x 49 0x100 -x 120 0x200 -astype 0 -x 68 0x20 -x 70 0x40000000 -x 164 0x800000 -x 124 1 -y 163 0xc0000000 -x 189 0x10 -y 189 0x4000000 -cmdline '+pgfortran /usr/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -Mnostdinc -v -c -o CMakeFiles/cmTC_b7462.dir/CMakeFortranCompilerABI.F.o' -asm /tmp/pgfortranUelfk-LC2Ixm.s
+ 0 inform, 0 warnings, 0 severes, 0 fatal for cmakefortrancompilerabi
+PGF90/x86-64 Linux 18.10-1: compilation successful
+
+/usr/bin/as /tmp/pgfortranUelfk-LC2Ixm.s -o CMakeFiles/cmTC_b7462.dir/CMakeFortranCompilerABI.F.o
+
+/mnt/pgi/linux86-64/18.10/bin/pgappend -noerror CMakeFiles/cmTC_b7462.dir/CMakeFortranCompilerABI.F.o -name .IPDINFO /tmp/pgfortranoelfQQWHVV3l.cmod -name .IPEINFO /tmp/pgfortran_elf6-1UcVhp.cmdx
+Unlinking /tmp/pgfortranUelfk_cqURUw.ilm
+Unlinking /tmp/pgfortranEelfAVAFcE2q.stb
+Unlinking /tmp/pgfortranoelfQQWHVV3l.cmod
+Unlinking /tmp/pgfortran_elf6-1UcVhp.cmdx
+Unlinking /tmp/pgfortranUelfk-LC2Ixm.s
+Unlinking /tmp/pgfortranEelfA4vWZ2Nt.ll
+Linking Fortran executable cmTC_b7462
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_b7462.dir/link.txt --verbose=1
+/mnt/pgi/linux86-64/2018/bin/pgfortran -v -Mnostdinc CMakeFiles/cmTC_b7462.dir/CMakeFortranCompilerABI.F.o -o cmTC_b7462
+Export PGI_CURR_CUDA_HOME=/mnt/pgi/linux86-64/2018/cuda/9.1
+Export PGI=/mnt/pgi
+
+/usr/bin/ld /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o /mnt/pgi/linux86-64/18.10/lib/trace_init.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o /mnt/pgi/linux86-64/18.10/lib/initmp.o /mnt/pgi/linux86-64/18.10/lib/f90main.o --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /mnt/pgi/linux86-64/18.10/lib/pgi.ld -L/mnt/pgi/linux86-64/18.10/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-linux-gnu/7 CMakeFiles/cmTC_b7462.dir/CMakeFortranCompilerABI.F.o -rpath /mnt/pgi/linux86-64/18.10/lib -rpath /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -o cmTC_b7462 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -lpgf90rtl -lpgf90 -lpgf90_rpm1 -lpgf902 -lpgf90rtl -lpgftnrtl -lpgmp -lnuma -lpthread --start-group -lpgmath -lnspgc -lpgc --end-group -lrt -lpthread -lm -lgcc -lc -lgcc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/7/crtend.o /usr/lib/x86_64-linux-gnu/crtn.o
+make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux_nostdinc_i-C-XL-12.1.0.input b/Tests/RunCMake/ParseImplicitData/linux_nostdinc_i-C-XL-12.1.0.input
new file mode 100644
index 000000000..a552d7052
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux_nostdinc_i-C-XL-12.1.0.input
@@ -0,0 +1,42 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=XL
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=12.1.0
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_76ec2/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_76ec2.dir/build.make CMakeFiles/cmTC_76ec2.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/bin/xlc -qnostdinc -I/tmp/ii/test_c -V -o CMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCCompilerABI.c
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc
+export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447
+export XL_ASMOBJFILES=/tmp/xlcASknvctJ
+export "XL_DIS=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/dis -o "CMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o" "CMakeCCompilerABI.o""
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlcentry -qosvar=rhel.6.9 -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qtls -D_CALL_SYSV -D__null=0 -D__NO_MATH_INLINES -qtls -q64 -qgnu_version=4.4.7 -qnostdinc -I/tmp/ii/test_c -qasm_as=/usr/bin/as -qc_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -qgcc_c_stdinc=/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qcomplexgccincl=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qvac_include_path=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -oCMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCCompilerABI.c /tmp/xlcW0buijl3 /tmp/xlcW1Cx9kxW /dev/null /tmp/xlcLVbqvUBF.lst /dev/null /tmp/xlcW2hWVoJP
+export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode
+export XL_LINKER=/usr/bin/ld
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode -qlanglvl=extc99 -qcpluscmt -qkeyword=inline -qalias=ansi -qtls -qtls -qnostdinc /tmp/xlcW0buijl3 /tmp/xlcW1Cx9kxW CMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o /tmp/xlcLVbqvUBB.lst /tmp/xlcW2hWVoJP
+rm /tmp/xlcASknvctJ
+rm /tmp/xlcLVbqvUB
+rm /tmp/xlcW0buijl3
+rm /tmp/xlcW1Cx9kxW
+rm /tmp/xlcW2hWVoJP
+Linking C executable cmTC_76ec2
+/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_76ec2.dir/link.txt --verbose=1
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/bin/xlc -qnostdinc -I/tmp/ii/test_c -V CMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o -o cmTC_76ec2 -Wl,-export-dynamic
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlc
+export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447
+/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64 -L/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_76ec2.dir/CMakeCCompilerABI.c.o -o cmTC_76ec2 -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlopt -lxl -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o
+rm /tmp/xlcW0ka8GHg
+rm /tmp/xlcW1k1R1fn
+rm /tmp/xlcW2s4HnOt
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux_nostdinc_i-CXX-XL-12.1.0.input b/Tests/RunCMake/ParseImplicitData/linux_nostdinc_i-CXX-XL-12.1.0.input
new file mode 100644
index 000000000..4b20f2ee4
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux_nostdinc_i-CXX-XL-12.1.0.input
@@ -0,0 +1,42 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=XL
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=12.1.0
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/gmake" "cmTC_026f6/fast"
+/usr/bin/gmake -f CMakeFiles/cmTC_026f6.dir/build.make CMakeFiles/cmTC_026f6.dir/build
+gmake[1]: Entering directory `/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o
+/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/bin/xlC -+ -qnostdinc -I/tmp/ii/test_c -I/tmp/ii/test_cxx -V -o CMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o -c /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlC
+export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447
+export XL_ASMOBJFILES=/tmp/xlcAS6jiX2k
+export "XL_DIS=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/dis -o "CMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o" "CMakeCXXCompilerABI.o""
+/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/exe/xlCentry -qosvar=rhel.6.9 -qalias=ansi -qtls -D_CALL_SYSV -D__null=0 -D__NO_MATH_INLINES -qtls -q64 -qgnu_version=4.4.7 -qnostdinc -I/tmp/ii/test_c -I/tmp/ii/test_cxx -qasm_as=/usr/bin/as -qcpp_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/include -qc_stdinc=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include -qgcc_cpp_stdinc=/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7:/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ppc64-redhat-linux:/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qgcc_c_stdinc=/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -qcomplexgccincl=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include:/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include:/usr/local/include:/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include:/usr/include -oCMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o /soft/buildtools/cmake/3.5.2/share/cmake-3.5/Modules/CMakeCXXCompilerABI.cpp /tmp/xlcW00ICris /tmp/xlcW1eYwBrK /dev/null /tmp/xlcLG2pVwDF.lst /dev/null /tmp/xlcW2YVJhA2
+export XL_BACKEND=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode
+export XL_LINKER=/usr/bin/ld
+/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/exe/xlCcode -qalias=ansi -qtls -qtls -qnostdinc /tmp/xlcW00ICris /tmp/xlcW1eYwBrK CMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o /tmp/xlcLG2pVwDB.lst /tmp/xlcW2YVJhA2
+rm /tmp/xlcAS6jiX2k
+rm /tmp/xlcLG2pVwD
+rm /tmp/xlcW00ICris
+rm /tmp/xlcW1eYwBrK
+rm /tmp/xlcW2YVJhA2
+Linking CXX executable cmTC_026f6
+/soft/buildtools/cmake/3.5.2/bin/cmake -E cmake_link_script CMakeFiles/cmTC_026f6.dir/link.txt --verbose=1
+/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/bin/xlC -qnostdinc -I/tmp/ii/test_c -I/tmp/ii/test_cxx -V CMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_026f6 -Wl,-export-dynamic
+export XL_CONFIG=/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/etc/vac.cfg.rhel6.9.gcc447:xlC
+export XLC_USR_CONFIG=/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/etc/V1R2M4.vac.cfg.rhel6.9.gcc447
+/usr/bin/ld --eh-frame-hdr -Qy -melf64ppc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crt1.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crti.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtbegin.o -L/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64 -L/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64 -L/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64 -L/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64 -R/soft/compilers/ibmcmp-oct2017/lib64/bg -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../.. CMakeFiles/cmTC_026f6.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_026f6 -export-dynamic -dynamic-linker /lib64/ld64.so.1 -lxlopt -lxl -libmc++ -lxlopt -lxl -lstdc++ -lm -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc -ldl -lgcc_s -lgcc -lm -lc -lgcc_s -lgcc /usr/lib/gcc/ppc64-redhat-linux/4.4.7/crtend.o /usr/lib/gcc/ppc64-redhat-linux/4.4.7/../../../../lib64/crtn.o
+rm /tmp/xlcW0rO54CG
+rm /tmp/xlcW1Q6xB5c
+rm /tmp/xlcW2TnvdyJ
+gmake[1]: Leaving directory `/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/linux_pgf77-Fortran-PGI-18.10.1.input b/Tests/RunCMake/ParseImplicitData/linux_pgf77-Fortran-PGI-18.10.1.input
new file mode 100644
index 000000000..01abe8d50
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/linux_pgf77-Fortran-PGI-18.10.1.input
@@ -0,0 +1,35 @@
+CMAKE_LANG=Fortran
+CMAKE_Fortran_COMPILER_ABI=
+CMAKE_Fortran_COMPILER_AR=
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=PGI
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=18.10.1
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_ea063/fast"
+/usr/bin/make -f CMakeFiles/cmTC_ea063.dir/build.make CMakeFiles/cmTC_ea063.dir/build
+make[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_ea063.dir/CMakeFortranCompilerABI.F.o
+/mnt/pgi/linux86-64/2018/bin/pgf77 -v -c /usr/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_ea063.dir/CMakeFortranCompilerABI.F.o
+Export PGI=/mnt/pgi
+
+/mnt/pgi/linux86-64/18.10/bin/pgftnc /usr/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -opt 1 -x 119 0xa10000 -x 122 0x40 -x 123 0x1000 -x 127 4 -x 127 17 -x 19 0x400000 -x 28 0x40000 -x 120 0x10000000 -x 70 0x8000 -x 122 1 -x 125 0x20000 -quad -x 59 4 -tp k8 -x 120 0x1000 -x 51 0x20 -x 124 0x1401 -astype 0 -stdinc /mnt/pgi/linux86-64/18.10/include-gcc70:/mnt/pgi/linux86-64/18.10/include:/usr/lib/gcc/x86_64-linux-gnu/7/include:/usr/local/include:/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed:/usr/include/x86_64-linux-gnu:/usr/include -def unix -def __unix -def __unix__ -def linux -def __linux -def __linux__ -def __NO_MATH_INLINES -def __LP64__ -def __x86_64 -def __x86_64__ -def __LONG_MAX__=9223372036854775807L -def '__SIZE_TYPE__=unsigned long int' -def '__PTRDIFF_TYPE__=long int' -def __extension__= -def __amd_64__amd64__ -def __k8 -def __k8__ -def __SSE__ -def __MMX__ -def __SSE2__ -def __SSE3__ -preprocess -cmdline '+pgf77 /usr/share/cmake-3.10/Modules/CMakeFortranCompilerABI.F -v -c -o CMakeFiles/cmTC_ea063.dir/CMakeFortranCompilerABI.F.o' -x 70 0x40000000 -x 164 0x800000 -x 124 1 -asm /tmp/pgf77RxHebkuzkjES.s
+ 0 inform, 0 warnings, 0 severes, 0 fatal for cmakefortrancompilerabi
+PGFTN/x86-64 Linux 18.10-1: compilation successful
+
+/usr/bin/as /tmp/pgf77RxHebkuzkjES.s -o CMakeFiles/cmTC_ea063.dir/CMakeFortranCompilerABI.F.o
+Unlinking /tmp/pgf77RxHebkuzkjES.s
+Unlinking /tmp/pgf77dxHejAvLAzcs.ll
+Linking Fortran executable cmTC_ea063
+/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ea063.dir/link.txt --verbose=1
+/mnt/pgi/linux86-64/2018/bin/pgf77 -v CMakeFiles/cmTC_ea063.dir/CMakeFortranCompilerABI.F.o -o cmTC_ea063
+Export PGI=/mnt/pgi
+
+/usr/bin/ld /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o /mnt/pgi/linux86-64/18.10/lib/trace_init.o /usr/lib/gcc/x86_64-linux-gnu/7/crtbegin.o /mnt/pgi/linux86-64/18.10/lib/initmp.o /mnt/pgi/linux86-64/18.10/lib/pgfmain.o --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /mnt/pgi/linux86-64/18.10/lib/pgi.ld -L/mnt/pgi/linux86-64/18.10/lib -L/usr/lib64 -L/usr/lib/gcc/x86_64-linux-gnu/7 CMakeFiles/cmTC_ea063.dir/CMakeFortranCompilerABI.F.o -rpath /mnt/pgi/linux86-64/18.10/lib -rpath /usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -o cmTC_ea063 -L/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib64 -lpgftnrtl -lpgmp -lnuma -lpthread --start-group -lpgmath -lnspgc -lpgc --end-group -lrt -lpthread -lm -lgcc -lc -lgcc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/7/crtend.o /usr/lib/x86_64-linux-gnu/crtn.o
+make[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input b/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input
new file mode 100644
index 000000000..81e9ee04b
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/mingw.org-C-GNU-4.9.3.input
@@ -0,0 +1,70 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=
+CMAKE_C_COMPILER_AR=C:/DoesNotExist/MinGW/bin/gcc-ar.exe
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=GNU
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=C:/DoesNotExist/MinGW/bin/gcc-ranlib.exe
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=4.9.3
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: C:/tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"C:/DoesNotExist/MinGW/bin/mingw32-make.exe" "cmTC_ab097/fast"
+C:/DoesNotExist/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_ab097.dir\build.make CMakeFiles/cmTC_ab097.dir/build
+mingw32-make.exe[1]: Entering directory 'C:/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_ab097.dir/CMakeCCompilerABI.c.obj
+C:\DoesNotExist\MinGW\bin\gcc.exe -v -o CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj -c "C:\CMake\Modules\CMakeCCompilerABI.c"
+Using built-in specs.
+COLLECT_GCC=C:\DoesNotExist\MinGW\bin\gcc.exe
+Target: mingw32
+Configured with: ../src/gcc-4.9.3/configure --build=x86_64-pc-linux-gnu --host=mingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libstdcxx-debug --with-tune=generic --enable-nls
+Thread model: win32
+gcc version 4.9.3 (GCC)
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=i586'
+ c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/cc1.exe -quiet -v -iprefix c:\DoesNotExist\mingw\bin\../lib/gcc/mingw32/4.9.3/ C:\CMake\Modules\CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=generic -march=i586 -auxbase-strip CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj -version -o C:\Users\DASHBO~1\AppData\Local\Temp\ccKRBU4I.s
+GNU C (GCC) version 4.9.3 (mingw32)
+ compiled by GNU C version 4.9.3, GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.2
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring nonexistent directory "c:\DoesNotExist\mingw\bin\../lib/gcc/mingw32/4.9.3/../../../../mingw32/include"
+ignoring duplicate directory "c:/DoesNotExist/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include"
+ignoring duplicate directory "/mingw/lib/gcc/mingw32/4.9.3/../../../../include"
+ignoring duplicate directory "c:/DoesNotExist/mingw/lib/gcc/../../include"
+ignoring duplicate directory "c:/DoesNotExist/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include-fixed"
+ignoring nonexistent directory "c:/DoesNotExist/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/../../../../mingw32/include"
+ignoring duplicate directory "/mingw/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ c:\DoesNotExist\mingw\bin\../lib/gcc/mingw32/4.9.3/include
+ c:\DoesNotExist\mingw\bin\../lib/gcc/mingw32/4.9.3/../../../../include
+ c:\DoesNotExist\mingw\bin\../lib/gcc/mingw32/4.9.3/include-fixed
+End of search list.
+GNU C (GCC) version 4.9.3 (mingw32)
+ compiled by GNU C version 4.9.3, GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.2
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+Compiler executable checksum: 32bccaa1a45d39107471fe656e1c3cd5
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=i586'
+ c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/as.exe -v -o CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj C:\Users\DASHBO~1\AppData\Local\Temp\ccKRBU4I.s
+GNU assembler version 2.25.1 (mingw32) using BFD version (GNU Binutils) 2.25.1
+COMPILER_PATH=c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/;c:/DoesNotExist/mingw/bin/../libexec/gcc/;c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/
+LIBRARY_PATH=c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/DoesNotExist/mingw/bin/../lib/gcc/;c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib/;c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_ab097.dir\CMakeCCompilerABI.c.obj' '-c' '-mtune=generic' '-march=i586'
+Linking C executable cmTC_ab097.exe
+"C:\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_ab097.dir\link.txt --verbose=1
+"C:\CMake\bin\cmake.exe" -E remove -f CMakeFiles\cmTC_ab097.dir/objects.a
+C:\DoesNotExist\MinGW\bin\ar.exe cr CMakeFiles\cmTC_ab097.dir/objects.a @CMakeFiles\cmTC_ab097.dir\objects1.rsp
+C:\DoesNotExist\MinGW\bin\gcc.exe -v -Wl,--whole-archive CMakeFiles\cmTC_ab097.dir/objects.a -Wl,--no-whole-archive -o cmTC_ab097.exe -Wl,--out-implib,libcmTC_ab097.dll.a -Wl,--major-image-version,0,--minor-image-version,0
+Using built-in specs.
+COLLECT_GCC=C:\DoesNotExist\MinGW\bin\gcc.exe
+COLLECT_LTO_WRAPPER=c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/lto-wrapper.exe
+Target: mingw32
+Configured with: ../src/gcc-4.9.3/configure --build=x86_64-pc-linux-gnu --host=mingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libstdcxx-debug --with-tune=generic --enable-nls
+Thread model: win32
+gcc version 4.9.3 (GCC)
+COMPILER_PATH=c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/;c:/DoesNotExist/mingw/bin/../libexec/gcc/;c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/
+LIBRARY_PATH=c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/DoesNotExist/mingw/bin/../lib/gcc/;c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib/;c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../
+COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_ab097.exe' '-mtune=generic' '-march=i586'
+ c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/collect2.exe -plugin c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/liblto_plugin-0.dll -plugin-opt=c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\DASHBO~1\AppData\Local\Temp\ccEGcsW8.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -Bdynamic -o cmTC_ab097.exe c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../crt2.o c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/crtbegin.o -Lc:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3 -Lc:/DoesNotExist/mingw/bin/../lib/gcc -Lc:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib -Lc:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../.. --whole-archive CMakeFiles\cmTC_ab097.dir/objects.a --no-whole-archive --out-implib libcmTC_ab097.dll.a --major-image-version 0 --minor-image-version 0 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/crtend.o
+mingw32-make.exe[1]: Leaving directory 'C:/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input b/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input
new file mode 100644
index 000000000..cd773402c
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/mingw.org-CXX-GNU-4.9.3.input
@@ -0,0 +1,76 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=C:/DoesNotExist/MinGW/bin/gcc-ar.exe
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=GNU
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=C:/DoesNotExist/MinGW/bin/gcc-ranlib.exe
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=4.9.3
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: C:/tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"C:/DoesNotExist/MinGW/bin/mingw32-make.exe" "cmTC_2b790/fast"
+C:/DoesNotExist/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_2b790.dir\build.make CMakeFiles/cmTC_2b790.dir/build
+mingw32-make.exe[1]: Entering directory 'C:/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_2b790.dir/CMakeCXXCompilerABI.cpp.obj
+C:\DoesNotExist\MinGW\bin\g++.exe -v -o CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj -c "C:\CMake\Modules\CMakeCXXCompilerABI.cpp"
+Using built-in specs.
+COLLECT_GCC=C:\DoesNotExist\MinGW\bin\g++.exe
+Target: mingw32
+Configured with: ../src/gcc-4.9.3/configure --build=x86_64-pc-linux-gnu --host=mingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libstdcxx-debug --with-tune=generic --enable-nls
+Thread model: win32
+gcc version 4.9.3 (GCC)
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj' '-c' '-shared-libgcc' '-mtune=generic' '-march=i586'
+ c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/cc1plus.exe -quiet -v -iprefix c:\DoesNotExist\mingw\bin\../lib/gcc/mingw32/4.9.3/ C:\CMake\Modules\CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mtune=generic -march=i586 -auxbase-strip CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj -version -o C:\Users\DASHBO~1\AppData\Local\Temp\cceEHFvQ.s
+GNU C++ (GCC) version 4.9.3 (mingw32)
+ compiled by GNU C version 4.9.3, GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.2
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+ignoring nonexistent directory "c:\DoesNotExist\mingw\bin\../lib/gcc/mingw32/4.9.3/../../../../mingw32/include"
+ignoring duplicate directory "c:/DoesNotExist/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include/c++"
+ignoring duplicate directory "c:/DoesNotExist/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include/c++/mingw32"
+ignoring duplicate directory "c:/DoesNotExist/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include/c++/backward"
+ignoring duplicate directory "c:/DoesNotExist/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include"
+ignoring duplicate directory "/mingw/lib/gcc/mingw32/4.9.3/../../../../include"
+ignoring duplicate directory "c:/DoesNotExist/mingw/lib/gcc/../../include"
+ignoring duplicate directory "c:/DoesNotExist/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/include-fixed"
+ignoring nonexistent directory "c:/DoesNotExist/mingw/lib/gcc/../../lib/gcc/mingw32/4.9.3/../../../../mingw32/include"
+ignoring duplicate directory "/mingw/include"
+#include "..." search starts here:
+#include <...> search starts here:
+ c:\DoesNotExist\mingw\bin\../lib/gcc/mingw32/4.9.3/include/c++
+ c:\DoesNotExist\mingw\bin\../lib/gcc/mingw32/4.9.3/include/c++/mingw32
+ c:\DoesNotExist\mingw\bin\../lib/gcc/mingw32/4.9.3/include/c++/backward
+ c:\DoesNotExist\mingw\bin\../lib/gcc/mingw32/4.9.3/include
+ c:\DoesNotExist\mingw\bin\../lib/gcc/mingw32/4.9.3/../../../../include
+ c:\DoesNotExist\mingw\bin\../lib/gcc/mingw32/4.9.3/include-fixed
+End of search list.
+GNU C++ (GCC) version 4.9.3 (mingw32)
+ compiled by GNU C version 4.9.3, GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.2
+GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
+Compiler executable checksum: 5086496b116ea21cdc0e479568243b88
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj' '-c' '-shared-libgcc' '-mtune=generic' '-march=i586'
+ c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/as.exe -v -o CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj C:\Users\DASHBO~1\AppData\Local\Temp\cceEHFvQ.s
+GNU assembler version 2.25.1 (mingw32) using BFD version (GNU Binutils) 2.25.1
+COMPILER_PATH=c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/;c:/DoesNotExist/mingw/bin/../libexec/gcc/;c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/
+LIBRARY_PATH=c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/DoesNotExist/mingw/bin/../lib/gcc/;c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib/;c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles\cmTC_2b790.dir\CMakeCXXCompilerABI.cpp.obj' '-c' '-shared-libgcc' '-mtune=generic' '-march=i586'
+Linking CXX executable cmTC_2b790.exe
+"C:\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_2b790.dir\link.txt --verbose=1
+"C:\CMake\bin\cmake.exe" -E remove -f CMakeFiles\cmTC_2b790.dir/objects.a
+C:\DoesNotExist\MinGW\bin\ar.exe cr CMakeFiles\cmTC_2b790.dir/objects.a @CMakeFiles\cmTC_2b790.dir\objects1.rsp
+C:\DoesNotExist\MinGW\bin\g++.exe -v -Wl,--whole-archive CMakeFiles\cmTC_2b790.dir/objects.a -Wl,--no-whole-archive -o cmTC_2b790.exe -Wl,--out-implib,libcmTC_2b790.dll.a -Wl,--major-image-version,0,--minor-image-version,0
+Using built-in specs.
+COLLECT_GCC=C:\DoesNotExist\MinGW\bin\g++.exe
+COLLECT_LTO_WRAPPER=c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/lto-wrapper.exe
+Target: mingw32
+Configured with: ../src/gcc-4.9.3/configure --build=x86_64-pc-linux-gnu --host=mingw32 --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-libstdcxx-debug --with-tune=generic --enable-nls
+Thread model: win32
+gcc version 4.9.3 (GCC)
+COMPILER_PATH=c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/;c:/DoesNotExist/mingw/bin/../libexec/gcc/;c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/bin/
+LIBRARY_PATH=c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/;c:/DoesNotExist/mingw/bin/../lib/gcc/;c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib/;c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../
+COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_2b790.exe' '-shared-libgcc' '-mtune=generic' '-march=i586'
+ c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/collect2.exe -plugin c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/liblto_plugin-0.dll -plugin-opt=c:/DoesNotExist/mingw/bin/../libexec/gcc/mingw32/4.9.3/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\DASHBO~1\AppData\Local\Temp\ccYpt7zh.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -Bdynamic -u ___register_frame_info -u ___deregister_frame_info -o cmTC_2b790.exe c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../crt2.o c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/crtbegin.o -Lc:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3 -Lc:/DoesNotExist/mingw/bin/../lib/gcc -Lc:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../../../mingw32/lib -Lc:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/../../.. --whole-archive CMakeFiles\cmTC_2b790.dir/objects.a --no-whole-archive --out-implib libcmTC_2b790.dll.a --major-image-version 0 --minor-image-version 0 -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt c:/DoesNotExist/mingw/bin/../lib/gcc/mingw32/4.9.3/crtend.o
+mingw32-make.exe[1]: Leaving directory 'C:/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/netbsd-C-GNU-4.8.5.input b/Tests/RunCMake/ParseImplicitData/netbsd-C-GNU-4.8.5.input
new file mode 100644
index 000000000..b46848433
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/netbsd-C-GNU-4.8.5.input
@@ -0,0 +1,60 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=CMAKE_C_COMPILER_AR-NOTFOUND
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=GNU
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=CMAKE_C_COMPILER_RANLIB-NOTFOUND
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=4.8.5
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/pkg/bin/gmake" "cmTC_9a517/fast"
+/usr/pkg/bin/gmake -f CMakeFiles/cmTC_9a517.dir/build.make CMakeFiles/cmTC_9a517.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o
+/usr/bin/cc -v -o CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o -c /usr/pkg/share/cmake-3.9/Modules/CMakeCCompilerABI.c
+Using built-in specs.
+COLLECT_GCC=/usr/bin/cc
+Target: i486--netbsdelf
+Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386
+Thread model: posix
+gcc version 4.8.5 (nb2 20150115)
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=nocona' '-march=i486'
+ /usr/libexec/cc1 -quiet -v /usr/pkg/share/cmake-3.9/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=nocona -march=i486 -auxbase-strip CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o -version -o /var/tmp//ccXQW9Zo.s
+GNU C (nb2 20150115) version 4.8.5 (i486--netbsdelf)
+ compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
+GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/include/gcc-4.8
+ /usr/include
+End of search list.
+GNU C (nb2 20150115) version 4.8.5 (i486--netbsdelf)
+ compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
+GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803
+Compiler executable checksum: 468b91b49af5cfeb6bb696ad20c66c1c
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=nocona' '-march=i486'
+ as -v -o CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o /var/tmp//ccXQW9Zo.s
+GNU assembler version 2.23.2 (i486--netbsdelf) using BFD version (NetBSD Binutils nb1) 2.23.2
+COMPILER_PATH=/usr/libexec/
+LIBRARY_PATH=/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=nocona' '-march=i486'
+Linking C executable cmTC_9a517
+/usr/pkg/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9a517.dir/link.txt --verbose=1
+/usr/bin/cc -v CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o -o cmTC_9a517
+Using built-in specs.
+COLLECT_GCC=/usr/bin/cc
+COLLECT_LTO_WRAPPER=/usr/libexec/lto-wrapper
+Target: i486--netbsdelf
+Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386
+Thread model: posix
+gcc version 4.8.5 (nb2 20150115)
+COMPILER_PATH=/usr/libexec/
+LIBRARY_PATH=/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_9a517' '-mtune=nocona' '-march=i486'
+ ld --eh-frame-hdr -dc -dp -e __start -dynamic-linker /usr/libexec/ld.elf_so -o cmTC_9a517 /usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o CMakeFiles/cmTC_9a517.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/netbsd-CXX-GNU-4.8.5.input b/Tests/RunCMake/ParseImplicitData/netbsd-CXX-GNU-4.8.5.input
new file mode 100644
index 000000000..e3c5f72e9
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/netbsd-CXX-GNU-4.8.5.input
@@ -0,0 +1,62 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=CMAKE_CXX_COMPILER_AR-NOTFOUND
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=GNU
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=CMAKE_CXX_COMPILER_RANLIB-NOTFOUND
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=4.8.5
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/pkg/bin/gmake" "cmTC_cca06/fast"
+/usr/pkg/bin/gmake -f CMakeFiles/cmTC_cca06.dir/build.make CMakeFiles/cmTC_cca06.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o
+/usr/bin/c++ -v -o CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o -c /usr/pkg/share/cmake-3.9/Modules/CMakeCXXCompilerABI.cpp
+Using built-in specs.
+COLLECT_GCC=/usr/bin/c++
+Target: i486--netbsdelf
+Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386
+Thread model: posix
+gcc version 4.8.5 (nb2 20150115)
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=nocona' '-march=i486'
+ /usr/libexec/cc1plus -quiet -v /usr/pkg/share/cmake-3.9/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mtune=nocona -march=i486 -auxbase-strip CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o -version -o /var/tmp//ccqeRxzZ.s
+GNU C++ (nb2 20150115) version 4.8.5 (i486--netbsdelf)
+ compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
+GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/include/g++
+ /usr/include/g++/backward
+ /usr/include/gcc-4.8
+ /usr/include
+End of search list.
+GNU C++ (nb2 20150115) version 4.8.5 (i486--netbsdelf)
+ compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
+GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803
+Compiler executable checksum: 961550adc452c84b614bf799df00d02b
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=nocona' '-march=i486'
+ as -v -o CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o /var/tmp//ccqeRxzZ.s
+GNU assembler version 2.23.2 (i486--netbsdelf) using BFD version (NetBSD Binutils nb1) 2.23.2
+COMPILER_PATH=/usr/libexec/
+LIBRARY_PATH=/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-o' 'CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=nocona' '-march=i486'
+Linking CXX executable cmTC_cca06
+/usr/pkg/bin/cmake -E cmake_link_script CMakeFiles/cmTC_cca06.dir/link.txt --verbose=1
+/usr/bin/c++ -v CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_cca06
+Using built-in specs.
+COLLECT_GCC=/usr/bin/c++
+COLLECT_LTO_WRAPPER=/usr/libexec/lto-wrapper
+Target: i486--netbsdelf
+Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386
+Thread model: posix
+gcc version 4.8.5 (nb2 20150115)
+COMPILER_PATH=/usr/libexec/
+LIBRARY_PATH=/usr/lib/
+COLLECT_GCC_OPTIONS='-v' '-o' 'cmTC_cca06' '-shared-libgcc' '-mtune=nocona' '-march=i486'
+ ld --eh-frame-hdr -dc -dp -e __start -dynamic-linker /usr/libexec/ld.elf_so -o cmTC_cca06 /usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o CMakeFiles/cmTC_cca06.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm --as-needed -lgcc_s --no-as-needed -lgcc -lc --as-needed -lgcc_s --no-as-needed -lgcc /usr/lib/crtend.o /usr/lib/crtn.o
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/netbsd_nostdinc-C-GNU-4.8.5.input b/Tests/RunCMake/ParseImplicitData/netbsd_nostdinc-C-GNU-4.8.5.input
new file mode 100644
index 000000000..cd5845ae5
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/netbsd_nostdinc-C-GNU-4.8.5.input
@@ -0,0 +1,58 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=CMAKE_C_COMPILER_AR-NOTFOUND
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=GNU
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=CMAKE_C_COMPILER_RANLIB-NOTFOUND
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=4.8.5
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/pkg/bin/gmake" "cmTC_b8d65/fast"
+/usr/pkg/bin/gmake -f CMakeFiles/cmTC_b8d65.dir/build.make CMakeFiles/cmTC_b8d65.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o
+/usr/bin/cc -nostdinc -v -o CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o -c /usr/pkg/share/cmake-3.9/Modules/CMakeCCompilerABI.c
+Using built-in specs.
+COLLECT_GCC=/usr/bin/cc
+Target: i486--netbsdelf
+Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386
+Thread model: posix
+gcc version 4.8.5 (nb2 20150115)
+COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=nocona' '-march=i486'
+ /usr/libexec/cc1 -quiet -nostdinc -v /usr/pkg/share/cmake-3.9/Modules/CMakeCCompilerABI.c -quiet -dumpbase CMakeCCompilerABI.c -mtune=nocona -march=i486 -auxbase-strip CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o -version -o /var/tmp//ccPEfYnQ.s
+GNU C (nb2 20150115) version 4.8.5 (i486--netbsdelf)
+ compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
+GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803
+#include "..." search starts here:
+#include <...> search starts here:
+End of search list.
+GNU C (nb2 20150115) version 4.8.5 (i486--netbsdelf)
+ compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
+GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803
+Compiler executable checksum: 468b91b49af5cfeb6bb696ad20c66c1c
+COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=nocona' '-march=i486'
+ as -v -o CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o /var/tmp//ccPEfYnQ.s
+GNU assembler version 2.23.2 (i486--netbsdelf) using BFD version (NetBSD Binutils nb1) 2.23.2
+COMPILER_PATH=/usr/libexec/
+LIBRARY_PATH=/usr/lib/
+COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o' '-c' '-mtune=nocona' '-march=i486'
+Linking C executable cmTC_b8d65
+/usr/pkg/bin/cmake -E cmake_link_script CMakeFiles/cmTC_b8d65.dir/link.txt --verbose=1
+/usr/bin/cc -nostdinc -v CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o -o cmTC_b8d65
+Using built-in specs.
+COLLECT_GCC=/usr/bin/cc
+COLLECT_LTO_WRAPPER=/usr/libexec/lto-wrapper
+Target: i486--netbsdelf
+Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386
+Thread model: posix
+gcc version 4.8.5 (nb2 20150115)
+COMPILER_PATH=/usr/libexec/
+LIBRARY_PATH=/usr/lib/
+COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'cmTC_b8d65' '-mtune=nocona' '-march=i486'
+ ld --eh-frame-hdr -dc -dp -e __start -dynamic-linker /usr/libexec/ld.elf_so -o cmTC_b8d65 /usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o CMakeFiles/cmTC_b8d65.dir/CMakeCCompilerABI.c.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/netbsd_nostdinc-CXX-GNU-4.8.5.input b/Tests/RunCMake/ParseImplicitData/netbsd_nostdinc-CXX-GNU-4.8.5.input
new file mode 100644
index 000000000..b9a585cc1
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/netbsd_nostdinc-CXX-GNU-4.8.5.input
@@ -0,0 +1,58 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=CMAKE_CXX_COMPILER_AR-NOTFOUND
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=GNU
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=CMAKE_CXX_COMPILER_RANLIB-NOTFOUND
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=4.8.5
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/pkg/bin/gmake" "cmTC_bbb1e/fast"
+/usr/pkg/bin/gmake -f CMakeFiles/cmTC_bbb1e.dir/build.make CMakeFiles/cmTC_bbb1e.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o
+/usr/bin/c++ -nostdinc -v -o CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o -c /usr/pkg/share/cmake-3.9/Modules/CMakeCXXCompilerABI.cpp
+Using built-in specs.
+COLLECT_GCC=/usr/bin/c++
+Target: i486--netbsdelf
+Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386
+Thread model: posix
+gcc version 4.8.5 (nb2 20150115)
+COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=nocona' '-march=i486'
+ /usr/libexec/cc1plus -quiet -nostdinc -v /usr/pkg/share/cmake-3.9/Modules/CMakeCXXCompilerABI.cpp -quiet -dumpbase CMakeCXXCompilerABI.cpp -mtune=nocona -march=i486 -auxbase-strip CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o -version -o /var/tmp//cclVebp0.s
+GNU C++ (nb2 20150115) version 4.8.5 (i486--netbsdelf)
+ compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
+GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803
+#include "..." search starts here:
+#include <...> search starts here:
+End of search list.
+GNU C++ (nb2 20150115) version 4.8.5 (i486--netbsdelf)
+ compiled by GNU C version 4.8.5, GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.1
+GGC heuristics: --param ggc-min-expand=73 --param ggc-min-heapsize=81803
+Compiler executable checksum: 961550adc452c84b614bf799df00d02b
+COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=nocona' '-march=i486'
+ as -v -o CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o /var/tmp//cclVebp0.s
+GNU assembler version 2.23.2 (i486--netbsdelf) using BFD version (NetBSD Binutils nb1) 2.23.2
+COMPILER_PATH=/usr/libexec/
+LIBRARY_PATH=/usr/lib/
+COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o' '-c' '-shared-libgcc' '-mtune=nocona' '-march=i486'
+Linking CXX executable cmTC_bbb1e
+/usr/pkg/bin/cmake -E cmake_link_script CMakeFiles/cmTC_bbb1e.dir/link.txt --verbose=1
+/usr/bin/c++ -nostdinc -v CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_bbb1e
+Using built-in specs.
+COLLECT_GCC=/usr/bin/c++
+COLLECT_LTO_WRAPPER=/usr/libexec/lto-wrapper
+Target: i486--netbsdelf
+Configured with: /usr/7/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=i486--netbsdelf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20150115' --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-threads --with-arch=i486 --with-tune=nocona --enable-libstdcxx-time=rt --enable-lto --with-mpc-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/i386/usr/7/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/7/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/7/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/7/src/external/lgpl3/gmp/lib/libgmp/arch/i386 --enable-tls --disable-multilib --disable-symvers --disable-libstdcxx-pch --build=x86_64-unknown-netbsd6.0. --host=i486--netbsdelf --with-sysroot=/var/obj/mknative/i386/usr/7/src/destdir.i386
+Thread model: posix
+gcc version 4.8.5 (nb2 20150115)
+COMPILER_PATH=/usr/libexec/
+LIBRARY_PATH=/usr/lib/
+COLLECT_GCC_OPTIONS='-nostdinc' '-v' '-o' 'cmTC_bbb1e' '-shared-libgcc' '-mtune=nocona' '-march=i486'
+ ld --eh-frame-hdr -dc -dp -e __start -dynamic-linker /usr/libexec/ld.elf_so -o cmTC_bbb1e /usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o CMakeFiles/cmTC_bbb1e.dir/CMakeCXXCompilerABI.cpp.o -lstdc++ -lm --as-needed -lgcc_s --no-as-needed -lgcc -lc --as-needed -lgcc_s --no-as-needed -lgcc /usr/lib/crtend.o /usr/lib/crtn.o
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/openbsd-C-Clang-5.0.1.input b/Tests/RunCMake/ParseImplicitData/openbsd-C-Clang-5.0.1.input
new file mode 100644
index 000000000..9f34f3d41
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/openbsd-C-Clang-5.0.1.input
@@ -0,0 +1,37 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=ELF
+CMAKE_C_COMPILER_AR=CMAKE_C_COMPILER_AR-NOTFOUND
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=Clang
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=CMAKE_C_COMPILER_RANLIB-NOTFOUND
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=5.0.1
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_f5360/fast"
+/usr/bin/make -f CMakeFiles/cmTC_f5360.dir/build.make CMakeFiles/cmTC_f5360.dir/build
+Building C object CMakeFiles/cmTC_f5360.dir/CMakeCCompilerABI.c.o
+/usr/bin/cc -v -o CMakeFiles/cmTC_f5360.dir/CMakeCCompilerABI.c.o -c /usr/local/share/cmake/Modules/CMakeCCompilerABI.c
+OpenBSD clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1)
+Target: amd64-unknown-openbsd6.3
+Thread model: posix
+InstalledDir: /usr/bin
+ "/usr/bin/cc" -cc1 -triple amd64-unknown-openbsd6.3 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCCompilerABI.c -mrelocation-model pic -pic-level 1 -pic-is-pie -mthread-model posix -mdisable-fp-elim -relaxed-aliasing -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file /tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_f5360.dir/CMakeCCompilerABI.c.gcno -resource-dir /usr/lib/clang/5.0.1 -fdebug-compilation-dir /tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -femulated-tls -fwrapv -stack-protector 2 -fobjc-runtime=gnustep -fdiagnostics-show-option -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -o CMakeFiles/cmTC_f5360.dir/CMakeCCompilerABI.c.o -x c /usr/local/share/cmake/Modules/CMakeCCompilerABI.c
+clang -cc1 version 5.0.1 based upon LLVM 5.0.1 default target amd64-unknown-openbsd6.3
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/lib/clang/5.0.1/include
+ /usr/include
+End of search list.
+Linking C executable cmTC_f5360
+/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f5360.dir/link.txt --verbose=1
+/usr/bin/cc -v CMakeFiles/cmTC_f5360.dir/CMakeCCompilerABI.c.o -o cmTC_f5360 -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib
+OpenBSD clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1)
+Target: amd64-unknown-openbsd6.3
+Thread model: posix
+InstalledDir: /usr/bin
+ "/usr/bin/ld" -e __start --eh-frame-hdr -Bdynamic -dynamic-linker /usr/libexec/ld.so -o cmTC_f5360 /usr/bin/../lib/crt0.o /usr/bin/../lib/crtbegin.o -L/usr/bin/../lib -L/usr/lib CMakeFiles/cmTC_f5360.dir/CMakeCCompilerABI.c.o -rpath-link /usr/X11R6/lib:/usr/local/lib -lcompiler_rt -lc -lcompiler_rt /usr/bin/../lib/crtend.o
diff --git a/Tests/RunCMake/ParseImplicitData/openbsd-CXX-Clang-5.0.1.input b/Tests/RunCMake/ParseImplicitData/openbsd-CXX-Clang-5.0.1.input
new file mode 100644
index 000000000..93f1a9570
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/openbsd-CXX-Clang-5.0.1.input
@@ -0,0 +1,38 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=ELF
+CMAKE_CXX_COMPILER_AR=CMAKE_CXX_COMPILER_AR-NOTFOUND
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=Clang
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=CMAKE_CXX_COMPILER_RANLIB-NOTFOUND
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=5.0.1
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/usr/bin/make" "cmTC_a2bf8/fast"
+/usr/bin/make -f CMakeFiles/cmTC_a2bf8.dir/build.make CMakeFiles/cmTC_a2bf8.dir/build
+Building CXX object CMakeFiles/cmTC_a2bf8.dir/CMakeCXXCompilerABI.cpp.o
+/usr/bin/c++ -v -o CMakeFiles/cmTC_a2bf8.dir/CMakeCXXCompilerABI.cpp.o -c /usr/local/share/cmake/Modules/CMakeCXXCompilerABI.cpp
+OpenBSD clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1)
+Target: amd64-unknown-openbsd6.3
+Thread model: posix
+InstalledDir: /usr/bin
+ "/usr/bin/c++" -cc1 -triple amd64-unknown-openbsd6.3 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name CMakeCXXCompilerABI.cpp -mrelocation-model pic -pic-level 1 -pic-is-pie -mthread-model posix -mdisable-fp-elim -relaxed-aliasing -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file /tmp/ii/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_a2bf8.dir/CMakeCXXCompilerABI.cpp.gcno -resource-dir /usr/lib/clang/5.0.1 -internal-isystem /usr/include/c++/v1 -fdeprecated-macro -fdebug-compilation-dir /tmp/ii/CMakeFiles/CMakeTmp -ferror-limit 19 -fmessage-length 0 -femulated-tls -fwrapv -stack-protector 2 -fobjc-runtime=gnustep -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -o CMakeFiles/cmTC_a2bf8.dir/CMakeCXXCompilerABI.cpp.o -x c++ /usr/local/share/cmake/Modules/CMakeCXXCompilerABI.cpp
+clang -cc1 version 5.0.1 based upon LLVM 5.0.1 default target amd64-unknown-openbsd6.3
+#include "..." search starts here:
+#include <...> search starts here:
+ /usr/include/c++/v1
+ /usr/lib/clang/5.0.1/include
+ /usr/include
+End of search list.
+Linking CXX executable cmTC_a2bf8
+/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a2bf8.dir/link.txt --verbose=1
+/usr/bin/c++ -v CMakeFiles/cmTC_a2bf8.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_a2bf8 -Wl,-rpath-link,/usr/X11R6/lib:/usr/local/lib
+OpenBSD clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1)
+Target: amd64-unknown-openbsd6.3
+Thread model: posix
+InstalledDir: /usr/bin
+ "/usr/bin/ld" -e __start --eh-frame-hdr -Bdynamic -dynamic-linker /usr/libexec/ld.so -o cmTC_a2bf8 /usr/bin/../lib/crt0.o /usr/bin/../lib/crtbegin.o -L/usr/bin/../lib -L/usr/lib CMakeFiles/cmTC_a2bf8.dir/CMakeCXXCompilerABI.cpp.o -rpath-link /usr/X11R6/lib:/usr/local/lib -lc++ -lc++abi -lpthread -lm -lcompiler_rt -lc -lcompiler_rt /usr/bin/../lib/crtend.o
diff --git a/Tests/RunCMake/ParseImplicitData/sunos-C-SunPro-5.13.0.input b/Tests/RunCMake/ParseImplicitData/sunos-C-SunPro-5.13.0.input
new file mode 100644
index 000000000..b0b504acb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/sunos-C-SunPro-5.13.0.input
@@ -0,0 +1,35 @@
+CMAKE_LANG=C
+CMAKE_C_COMPILER_ABI=
+CMAKE_C_COMPILER_AR=
+CMAKE_C_COMPILER_ARCHITECTURE_ID=
+CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_C_COMPILER_ID=SunPro
+CMAKE_C_COMPILER_LAUNCHER=
+CMAKE_C_COMPILER_LOADED=1
+CMAKE_C_COMPILER_RANLIB=
+CMAKE_C_COMPILER_TARGET=
+CMAKE_C_COMPILER_VERSION=5.13.0
+CMAKE_C_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/opt/csw/bin/gmake" "cmTC_55079/fast"
+/opt/csw/bin/gmake -f CMakeFiles/cmTC_55079.dir/build.make CMakeFiles/cmTC_55079.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building C object CMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o
+/opt/solarisstudio12.4/bin/cc -# -o CMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o -c /tmp/CMake/Modules/CMakeCCompilerABI.c
+### cc: Note: NLSPATH = /opt/solarisstudio12.4/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/solarisstudio12.4/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
+### command line files and options (expanded):
+### -# -oCMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o -c /tmp/CMake/Modules/CMakeCCompilerABI.c
+/opt/solarisstudio12.4/lib/compilers/acomp -Qy -std=c11 -i /tmp/CMake/Modules/CMakeCCompilerABI.c -D__SunOS_5_10 -D__SUNPRO_C=0x5130 -D__unix -D__SVR4 -D__sun -D__SunOS -D__sparcv8 -D__sparc -D__BUILTIN_VA_ARG_INCR -D__C11FEATURES__ -D__C99FEATURES__ -D__PRAGMA_REDEFINE_EXTNAME -Dunix -Dsun -Dsparc -D__RESTRICT -D__FLT_EVAL_METHOD__=0 -D__SUN_PREFETCH -D__NOVECTORSIZE__ -I-xbuiltin -I/opt/solarisstudio12.4/lib/compilers/include/cc -xbuiltin=%none -fsimple=0 -m32 -fparam_ir -fparam_ir -xdebuginfo=%none -xF=%none -xdbggen=dwarf+usedonly+incl -xldscope=global -xivdep=loop "-g/opt/solarisstudio12.4/bin/cc -c " -destination_ir=yabe -y-fbe -y/opt/solarisstudio12.4/bin/fbe -y-xmemalign=8i -y-verbose -y-comdat -y-xdebuginfo=%none -y-xarch=generic -y-m32 -y-comdat -y-xthreadvar=no%dynamic -y-xannotate=yes -y-o -yCMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o
+Linking C executable cmTC_55079
+/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_55079.dir/link.txt --verbose=1
+/opt/solarisstudio12.4/bin/cc -# CMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o -o cmTC_55079
+### cc: Note: NLSPATH = /opt/solarisstudio12.4/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/solarisstudio12.4/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
+### command line files and options (expanded):
+### -# CMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o -ocmTC_55079
+### cc: Note: LD_LIBRARY_PATH = (null)
+### cc: Note: LD_RUN_PATH = (null)
+### cc: Note: LD_OPTIONS = (null)
+ln -s /opt/solarisstudio12.4/lib/compilers /tmp/lib_link.1547820951.9061.01
+/usr/ccs/bin/ld -zld32=-S/tmp/lib_link.1547820951.9061.01/libldstab_ws.so -zld64=-S/tmp/lib_link.1547820951.9061.01/sparcv9/libldstab_ws.so -zld32=-S/tmp/lib_link.1547820951.9061.01/libld_annotate.so -zld64=-S/tmp/lib_link.1547820951.9061.01/sparcv9/libld_annotate.so /opt/solarisstudio12.4/lib/compilers/crti.o /opt/solarisstudio12.4/lib/compilers/crt1.o /opt/solarisstudio12.4/lib/compilers/misalign.o /opt/solarisstudio12.4/lib/compilers/values-xa.o CMakeFiles/cmTC_55079.dir/CMakeCCompilerABI.c.o -o cmTC_55079 -Y "P,/opt/solarisstudio12.4/lib/compilers/staticlib:/opt/solarisstudio12.4/lib/compilers/sparc:/opt/solarisstudio12.4/lib/compilers:/usr/ccs/lib:/lib:/usr/lib" -Qy -lc /opt/solarisstudio12.4/lib/compilers/crtn.o
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/sunos-CXX-SunPro-5.13.0.input b/Tests/RunCMake/ParseImplicitData/sunos-CXX-SunPro-5.13.0.input
new file mode 100644
index 000000000..9abd06a28
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/sunos-CXX-SunPro-5.13.0.input
@@ -0,0 +1,38 @@
+CMAKE_LANG=CXX
+CMAKE_CXX_COMPILER_ABI=
+CMAKE_CXX_COMPILER_AR=
+CMAKE_CXX_COMPILER_ARCHITECTURE_ID=
+CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_CXX_COMPILER_ID=SunPro
+CMAKE_CXX_COMPILER_LAUNCHER=
+CMAKE_CXX_COMPILER_LOADED=1
+CMAKE_CXX_COMPILER_RANLIB=
+CMAKE_CXX_COMPILER_TARGET=
+CMAKE_CXX_COMPILER_VERSION=5.13.0
+CMAKE_CXX_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/opt/csw/bin/gmake" "cmTC_cc4b2/fast"
+/opt/csw/bin/gmake -f CMakeFiles/cmTC_cc4b2.dir/build.make CMakeFiles/cmTC_cc4b2.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building CXX object CMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o
+/opt/solarisstudio12.4/bin/CC -v -o CMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o -c /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp
+### CC: Note: NLSPATH = /opt/solarisstudio12.4/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/solarisstudio12.4/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
+### command line files and options (expanded):
+### -v -oCMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o -c /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp
+/opt/solarisstudio12.4/lib/compilers/ccfe -D__SunOS_5_10 -D__SUNPRO_CC=0x5130 -D__unix -D__SVR4 -D__sun -D__SunOS -D__sparcv8 -D__sparc -D__BUILTIN_VA_ARG_INCR -Dunix -Dsun -Dsparc -D__SUN_PREFETCH -D__SUNPRO_CC_COMPAT=5 -D__NOVECTORSIZE__ -I-xbuiltin -I/opt/solarisstudio12.4/lib/compilers/include/CC/Cstd -I/opt/solarisstudio12.4/lib/compilers/include/CC -I/opt/solarisstudio12.4/lib/compilers/include/cc -ptf /tmp/ccfe.1547820952.9069.02.%1.%2 -ptx /opt/solarisstudio12.4/bin/CC -ptk "-v -c " -compat=5 -xdebuginfo=%none -instlib=/opt/solarisstudio12.4/lib/compilers/libCstd.a -xdbggen=dwarf+usedonly+incl -xF=%none -xbuiltin=%none -xldscope=global -xivdep=loop -O0 -xarrayloc /tmp/CMake/Modules/CMakeCXXCompilerABI.cpp -ptb CMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o -y-fbe -y/opt/solarisstudio12.4/bin/fbe -y-xmemalign=8i -y-verbose -y-comdat -y-xdebuginfo=%none -y-xarch=generic -y-m32 -y-comdat -y-xthreadvar=no%dynamic -y-xannotate=yes -y-o -yCMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o 2> /tmp/ccfe.1547820952.9069.01.err
+rm /tmp/ccfe.1547820952.9069.01.err
+Linking CXX executable cmTC_cc4b2
+/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_cc4b2.dir/link.txt --verbose=1
+/opt/solarisstudio12.4/bin/CC -v CMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_cc4b2
+### CC: Note: NLSPATH = /opt/solarisstudio12.4/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/solarisstudio12.4/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
+### command line files and options (expanded):
+### -v CMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o -ocmTC_cc4b2
+### CC: Note: LD_LIBRARY_PATH = (null)
+### CC: Note: LD_RUN_PATH = (null)
+### CC: Note: LD_OPTIONS = (null)
+ln -s /opt/solarisstudio12.4/lib/compilers /tmp/lib_link.1547820952.9076.01
+/usr/ccs/bin/ld -zld32=-S/tmp/lib_link.1547820952.9076.01/libldstab_ws.so -zld64=-S/tmp/lib_link.1547820952.9076.01/sparcv9/libldstab_ws.so -zld32=-S/tmp/lib_link.1547820952.9076.01/libld_annotate.so -zld64=-S/tmp/lib_link.1547820952.9076.01/sparcv9/libld_annotate.so -zld32=-S/tmp/lib_link.1547820952.9076.01/libCCexcept.so.1 -zld64=-S/tmp/lib_link.1547820952.9076.01/sparcv9/libCCexcept.so.1 /opt/solarisstudio12.4/lib/compilers/crti.o -u __1cH__CimplKcplus_init6F_v_ /opt/solarisstudio12.4/lib/compilers/CCrti.o /opt/solarisstudio12.4/lib/compilers/crt1.o /opt/solarisstudio12.4/lib/compilers/misalign.o /opt/solarisstudio12.4/lib/compilers/values-xa.o CMakeFiles/cmTC_cc4b2.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_cc4b2 -Y "P,/opt/solarisstudio12.4/lib/compilers/sparc:/opt/solarisstudio12.4/lib/compilers:/opt/solarisstudio12.4/lib/sparc:/opt/solarisstudio12.4/lib:/usr/ccs/lib:/lib:/usr/lib" -Qy "-R/opt/solarisstudio12.4/lib/sparc:/opt/solarisstudio12.4/lib" -lCstd -lCrun -lm -lc /opt/solarisstudio12.4/lib/compilers/CCrtn.o /opt/solarisstudio12.4/lib/compilers/crtn.o 2> /tmp/ld.1547820952.9076.02.err
+rm /tmp/lib_link.1547820952.9076.01
+rm /tmp/ld.1547820952.9076.02.err
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitData/sunos-Fortran-SunPro-8.8.0.input b/Tests/RunCMake/ParseImplicitData/sunos-Fortran-SunPro-8.8.0.input
new file mode 100644
index 000000000..4a2bedd87
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitData/sunos-Fortran-SunPro-8.8.0.input
@@ -0,0 +1,40 @@
+CMAKE_LANG=Fortran
+CMAKE_Fortran_COMPILER_ABI=
+CMAKE_Fortran_COMPILER_AR=
+CMAKE_Fortran_COMPILER_ARCHITECTURE_ID=
+CMAKE_Fortran_COMPILER_EXTERNAL_TOOLCHAIN=
+CMAKE_Fortran_COMPILER_ID=SunPro
+CMAKE_Fortran_COMPILER_LAUNCHER=
+CMAKE_Fortran_COMPILER_LOADED=1
+CMAKE_Fortran_COMPILER_RANLIB=
+CMAKE_Fortran_COMPILER_TARGET=
+CMAKE_Fortran_COMPILER_VERSION=8.8.0
+CMAKE_Fortran_COMPILER_VERSION_INTERAL=
+Change Dir: /tmp/ii/CMakeFiles/CMakeTmp
+
+Run Build Command:"/opt/csw/bin/gmake" "cmTC_adcec/fast"
+/opt/csw/bin/gmake -f CMakeFiles/cmTC_adcec.dir/build.make CMakeFiles/cmTC_adcec.dir/build
+gmake[1]: Entering directory '/tmp/ii/CMakeFiles/CMakeTmp'
+Building Fortran object CMakeFiles/cmTC_adcec.dir/CMakeFortranCompilerABI.F.o
+/opt/developerstudio12.6/bin/sunf95 -v -c /tmp/CMake/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_adcec.dir/CMakeFortranCompilerABI.F.o
+### f90: Note: NLSPATH = /opt/developerstudio12.6/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/developerstudio12.6/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
+### command line files and options (expanded):
+### -v -c /tmp/CMake/Modules/CMakeFortranCompilerABI.F -o CMakeFiles/cmTC_adcec.dir/CMakeFortranCompilerABI.F.o
+/opt/developerstudio12.6/bin/fpp -undef -vax=bslash -Y/opt/developerstudio12.6/lib/compilers/include/f95 -D__SunOS_5_10 -D__SunOS_RELEASE=0x051000 -D__SUNPRO_F90=0x880 -D__SUNPRO_F95=0x880 -D__unix -D__SVR4__ -D__svr4__ -D__SVR4 -D__sun -D__sun__ -D__SunOS -D__sparcv8 -D__sparcv8plus -D__sparc -D__sparc__ -Dsun -Dunix -Dsparc -D__SUN_PREFETCH -I/opt/developerstudio12.6/lib/compilers/include/f95 /tmp/CMake/Modules/CMakeFortranCompilerABI.F /tmp/fpp.1548681160.26580.01.f
+/opt/developerstudio12.6/lib/compilers/bin/f90comp -E/tmp/CMake/Modules/CMakeFortranCompilerABI.F -m3 -ev -xall -xivdep=loop -H "/opt/developerstudio12.6/bin/f90 -v -c " -I/opt/developerstudio12.6/lib/compilers/include/f95 -p/opt/developerstudio12.6/lib/compilers/modules -m32 -y-m32 -xmemalign=8i -iorounding=processor-defined -xhasc=yes -xdebuginfo=%none -y-xdebuginfo=%none -y-xglobalize=no -xcache=generic -y-xcache=generic -y-xassume_control=optimize -xassume_control=optimize -y-xdbggen=dwarf+incl -keepmod=yes -y-ir -y/tmp/f90comp.1548681160.26580.02.ir /tmp/fpp.1548681160.26580.01.f
+/opt/developerstudio12.6/lib/compilers/bin/cg -Qy -fsimple=0 -xarch=sparcvis2 -m32 -xchip=generic -xcache=generic -comdat -ftrap=division,invalid,overflow -xdebuginfo=%none -xbuiltin=%none -xcode=abs32 -xannotate=yes -xmemalign=8i -xprefetch=auto,explicit -xprefetch_auto_type=no%indirect_array_access -xcheck=stkovf -xcheck=noreturn -xvector=no -oo CMakeFiles/cmTC_adcec.dir/CMakeFortranCompilerABI.F.o -ir /tmp/f90comp.1548681160.26580.02.ir
+rm /tmp/f90comp.1548681160.26580.02.ir
+rm /tmp/fpp.1548681160.26580.01.f
+Linking Fortran executable cmTC_adcec
+/tmp/CMake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_adcec.dir/link.txt --verbose=1
+/opt/developerstudio12.6/bin/sunf95 -v CMakeFiles/cmTC_adcec.dir/CMakeFortranCompilerABI.F.o -o cmTC_adcec
+### f90: Note: NLSPATH = /opt/developerstudio12.6/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/developerstudio12.6/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
+### command line files and options (expanded):
+### -v CMakeFiles/cmTC_adcec.dir/CMakeFortranCompilerABI.F.o -o cmTC_adcec
+### f90: Note: LD_LIBRARY_PATH = (null)
+### f90: Note: LD_RUN_PATH = (null)
+### f90: Note: LD_OPTIONS = (null)
+ln -s /opt/developerstudio12.6/lib/compilers /tmp/lib_link.1548681161.26655.01
+/usr/ccs/bin/ld -zld32=-S/tmp/lib_link.1548681161.26655.01/libldstab_ws.so -zld64=-S/tmp/lib_link.1548681161.26655.01/sparcv9/libldstab_ws.so -zld32=-S/tmp/lib_link.1548681161.26655.01/libld_annotate.so -zld64=-S/tmp/lib_link.1548681161.26655.01/sparcv9/libld_annotate.so /opt/developerstudio12.6/lib/compilers/crti.o /opt/developerstudio12.6/lib/compilers/crt1.o /opt/developerstudio12.6/lib/compilers/misalign.o /opt/developerstudio12.6/lib/compilers/values-xi.o CMakeFiles/cmTC_adcec.dir/CMakeFortranCompilerABI.F.o -o cmTC_adcec -Y "P,/opt/developerstudio12.6/lib/compilers/sparcvis2:/opt/developerstudio12.6/lib/compilers:/opt/developerstudio12.6/lib:/usr/ccs/lib:/lib:/usr/lib" -Qy -R/opt/developerstudio12.6/lib -t -lfsu -lsunmath -lmtsk -lm -lc /opt/developerstudio12.6/lib/compilers/crtn.o
+rm /tmp/lib_link.1548681161.26655.01
+gmake[1]: Leaving directory '/tmp/ii/CMakeFiles/CMakeTmp'
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/CMakeLists.txt b/Tests/RunCMake/ParseImplicitIncludeInfo/CMakeLists.txt
new file mode 100644
index 000000000..289710955
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake b/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake
new file mode 100644
index 000000000..abd0eaa02
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/ParseImplicitIncludeInfo.cmake
@@ -0,0 +1,127 @@
+cmake_minimum_required(VERSION 3.14)
+project(Minimal NONE)
+
+#
+# list of targets to test. to add a target: put its files in the data
+# subdirectory and add it to this list... we run each target's
+# data/*.input file through the parser and check to see if it matches
+# the corresponding data/*.output file. note that the empty-* case
+# has special handling (it should not parse).
+#
+set(targets
+ aix-C-XL-13.1.3 aix-CXX-XL-13.1.3
+ aix-C-XLClang-16.1.0.1 aix-CXX-XLClang-16.1.0.1
+ craype-C-Cray-8.7 craype-CXX-Cray-8.7 craype-Fortran-Cray-8.7
+ craype-C-Cray-9.0-hlist-ad craype-CXX-Cray-9.0-hlist-ad craype-Fortran-Cray-9.0-hlist-ad
+ craype-C-GNU-7.3.0 craype-CXX-GNU-7.3.0 craype-Fortran-GNU-7.3.0
+ craype-C-Intel-18.0.2.20180210 craype-CXX-Intel-18.0.2.20180210
+ craype-Fortran-Intel-18.0.2.20180210
+ darwin-C-AppleClang-8.0.0.8000042 darwin-CXX-AppleClang-8.0.0.8000042
+ darwin_nostdinc-C-AppleClang-8.0.0.8000042
+ darwin_nostdinc-CXX-AppleClang-8.0.0.8000042
+ freebsd-C-Clang-3.3.0 freebsd-CXX-Clang-3.3.0 freebsd-Fortran-GNU-4.6.4
+ hand-C-empty hand-CXX-empty
+ hand-C-relative hand-CXX-relative
+ linux-C-GNU-7.3.0 linux-CXX-GNU-7.3.0 linux-Fortran-GNU-7.3.0
+ linux-C-Intel-18.0.0.20170811 linux-CXX-Intel-18.0.0.20170811
+ linux-C-PGI-18.10.1 linux-CXX-PGI-18.10.1
+ linux-Fortran-PGI-18.10.1 linux_pgf77-Fortran-PGI-18.10.1
+ linux_nostdinc-C-PGI-18.10.1 linux_nostdinc-CXX-PGI-18.10.1
+ linux_nostdinc-Fortran-PGI-18.10.1
+ linux-C-XL-12.1.0 linux-CXX-XL-12.1.0 linux-Fortran-XL-14.1.0
+ linux_nostdinc-C-XL-12.1.0 linux_nostdinc-CXX-XL-12.1.0
+ linux_nostdinc_i-C-XL-12.1.0 linux_nostdinc-CXX-XL-12.1.0
+ linux-C-XL-16.1.0.0 linux-CXX-XL-16.1.0.0
+ linux-CUDA-NVIDIA-10.1.168-CLANG linux-CUDA-NVIDIA-10.1.168-XLClang-v-empty
+ linux-CUDA-NVIDIA-9.2.148-GCC
+ mingw.org-C-GNU-4.9.3 mingw.org-CXX-GNU-4.9.3
+ netbsd-C-GNU-4.8.5 netbsd-CXX-GNU-4.8.5
+ netbsd_nostdinc-C-GNU-4.8.5 netbsd_nostdinc-CXX-GNU-4.8.5
+ openbsd-C-Clang-5.0.1 openbsd-CXX-Clang-5.0.1
+ sunos-C-SunPro-5.13.0 sunos-CXX-SunPro-5.13.0 sunos-Fortran-SunPro-8.8.0
+ )
+
+if(CMAKE_HOST_WIN32)
+ # The KWSys actual-case cache breaks case sensitivity on Windows.
+ list(FILTER targets EXCLUDE REGEX "-XL|-SunPro")
+else()
+ # Windows drive letters are not recognized as absolute on other platforms.
+ list(FILTER targets EXCLUDE REGEX "mingw")
+endif()
+
+include(${CMAKE_ROOT}/Modules/CMakeParseImplicitIncludeInfo.cmake)
+
+#
+# load_compiler_info: read infile, parsing out cmake compiler info
+# variables as we go. returns language, a list of variables we set
+# (so we can clear them later), and the remaining verbose output
+# from the compiler.
+#
+function(load_compiler_info infile lang_var outcmvars_var outstr_var)
+ unset(lang)
+ unset(outcmvars)
+ unset(outstr)
+ file(READ "${infile}" in)
+ string(REGEX REPLACE "\r?\n" ";" in_lines "${in}")
+ foreach(line IN LISTS in_lines)
+ # check for special CMAKE variable lines and parse them if found
+ if("${line}" MATCHES "^CMAKE_([_A-Za-z0-9]+)=(.*)$")
+ if("${CMAKE_MATCH_1}" STREQUAL "LANG") # handle CMAKE_LANG here
+ set(lang "${CMAKE_MATCH_2}")
+ else()
+ set(CMAKE_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" PARENT_SCOPE)
+ list(APPEND outcmvars "CMAKE_${CMAKE_MATCH_1}")
+ endif()
+ else()
+ string(APPEND outstr "${line}\n")
+ endif()
+ endforeach()
+ if(NOT lang)
+ message("load_compiler_info: ${infile} no LANG info; default to C")
+ set(lang C)
+ endif()
+ set(${lang_var} "${lang}" PARENT_SCOPE)
+ set(${outcmvars_var} "${outcmvars}" PARENT_SCOPE)
+ set(${outstr_var} "${outstr}" PARENT_SCOPE)
+endfunction()
+
+#
+# unload_compiler_info: clear out any CMAKE_* vars load previously set
+#
+function(unload_compiler_info cmvars)
+ foreach(var IN LISTS cmvars)
+ unset("${var}" PARENT_SCOPE)
+ endforeach()
+endfunction()
+
+#
+# main test loop
+#
+foreach(t ${targets})
+ set(infile "${CMAKE_SOURCE_DIR}/../ParseImplicitData/${t}.input")
+ set(outfile "${CMAKE_SOURCE_DIR}/results/${t}.output")
+ if (NOT EXISTS ${infile})
+ string(REPLACE "-empty" "" infile "${infile}")
+ if (NOT EXISTS ${infile})
+ message("missing input file for target ${t} in ${CMAKE_SOURCE_DIR}/../ParseImplicitData/")
+ continue()
+ endif()
+ elseif(NOT EXISTS ${outfile})
+ message("missing files for target ${t} in ${CMAKE_SOURCE_DIR}/results/")
+ continue()
+ endif()
+
+ load_compiler_info(${infile} lang cmvars input)
+ file(READ ${outfile} output)
+ string(STRIP "${output}" output)
+ cmake_parse_implicit_include_info("${input}" "${lang}" idirs log state)
+
+ if(t MATCHES "-empty$") # empty isn't supposed to parse
+ if("${state}" STREQUAL "done")
+ message("empty parse failed: ${idirs}, log=${log}")
+ endif()
+ elseif(NOT "${state}" STREQUAL "done" OR NOT "${idirs}" MATCHES "^${output}$")
+ message("${t} parse failed: state=${state}, '${idirs}' does not match '^${output}$', log=${log}")
+ endif()
+ unload_compiler_info("${cmvars}")
+endforeach(t)
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/RunCMakeTest.cmake b/Tests/RunCMake/ParseImplicitIncludeInfo/RunCMakeTest.cmake
new file mode 100644
index 000000000..6266b500d
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(ParseImplicitIncludeInfo)
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-C-XL-13.1.3.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-C-XL-13.1.3.output
new file mode 100644
index 000000000..91b35ad15
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-C-XL-13.1.3.output
@@ -0,0 +1 @@
+/opt/IBM/xlc/13.1.3/include;/opt/IBM/xlmass/8.1.3/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-C-XLClang-16.1.0.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-C-XLClang-16.1.0.1.output
new file mode 100644
index 000000000..85399b75b
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-C-XLClang-16.1.0.1.output
@@ -0,0 +1 @@
+/opt/IBM/xlC/16.1.0/include2;/opt/IBM/xlC/16.1.0/include2/aix;/opt/IBM/xlmass/9.1.0/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-CXX-XL-13.1.3.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-CXX-XL-13.1.3.output
new file mode 100644
index 000000000..264e4fe3b
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-CXX-XL-13.1.3.output
@@ -0,0 +1 @@
+/opt/IBM/xlC/13.1.3/include;/opt/IBM/xlmass/8.1.3/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-CXX-XLClang-16.1.0.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-CXX-XLClang-16.1.0.1.output
new file mode 100644
index 000000000..7666f7e81
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/aix-CXX-XLClang-16.1.0.1.output
@@ -0,0 +1 @@
+/opt/IBM/xlC/16.1.0/include2/c\+\+;/opt/IBM/xlC/16.1.0/include2;/opt/IBM/xlC/16.1.0/include2/aix;/opt/IBM/xlmass/9.1.0/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-Cray-8.7.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-Cray-8.7.output
new file mode 100644
index 000000000..cbd213278
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-Cray-8.7.output
@@ -0,0 +1 @@
+/opt/cray/pe/cce/8.7.4/cce/x86_64/include/craylibs;/opt/cray/pe/cce/8.7.4/cce/x86_64/include/basic;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include-fixed;/opt/gcc/6.1.0/snos/include;/usr/include;/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-Cray-9.0-hlist-ad.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-Cray-9.0-hlist-ad.output
new file mode 100644
index 000000000..42b194acf
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-Cray-9.0-hlist-ad.output
@@ -0,0 +1 @@
+/opt/cray/pe/cce/9.0.0/cce/x86_64/include/craylibs;/opt/cray/pe/cce/9.0.0/cce/x86_64/include/basic;/opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0/include;/opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0/include-fixed;/opt/gcc/8.1.0/snos/include;/usr/include;/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/include;/opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/include;/opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/xpmem/2.2.15-6.0.7.1_5.8__g7549d06.ari/include;/opt/cray/dmapp/7.1.1-6.0.7.0_34.3__g5a674e0.ari/include;/opt/cray/gni-headers/5.0.12.0-6.0.7.0_24.1__g3b1768f.ari/include;/opt/cray/ugni/6.0.14.0-6.0.7.0_23.1__gea11d3d.ari/include;/opt/cray/udreg/2.3.2-6.0.7.0_33.18__g5196236.ari/include;/opt/cray/alps/6.6.43-6.0.7.0_26.4__ga796da3.ari/include;/opt/cray/wlm_detect/1.3.3-6.0.7.0_47.2__g7109084.ari/include;/opt/cray/krca/2.2.4-6.0.7.1_5.23__g8505b97.ari/include;/opt/cray-hss-devel/8.0.0/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-GNU-7.3.0.output
new file mode 100644
index 000000000..64f127ef2
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-GNU-7.3.0.output
@@ -0,0 +1 @@
+/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include;/usr/local/include;/opt/gcc/7.3.0/snos/include;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include-fixed;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-Intel-18.0.2.20180210.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-Intel-18.0.2.20180210.output
new file mode 100644
index 000000000..a26a007ce
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-C-Intel-18.0.2.20180210.output
@@ -0,0 +1 @@
+/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include;/usr/local/include;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed;/opt/gcc/6.3.0/snos/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-Cray-8.7.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-Cray-8.7.output
new file mode 100644
index 000000000..263f8cb25
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-Cray-8.7.output
@@ -0,0 +1 @@
+/opt/cray/pe/cce/8.7.4/cce/x86_64/include/craylibs;/opt/gcc/6.1.0/snos/include/g\+\+;/opt/gcc/6.1.0/snos/include/g\+\+/x86_64-suse-linux;/opt/gcc/6.1.0/snos/include/g\+\+/backward;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0/include-fixed;/opt/cray/pe/cce/8.7.4/cce/x86_64/include/c\+\+;/opt/cray/pe/cce/8.7.4/cce/x86_64/include/basic;/opt/gcc/6.1.0/snos/include;/usr/include;/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-Cray-9.0-hlist-ad.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-Cray-9.0-hlist-ad.output
new file mode 100644
index 000000000..a3b876813
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-Cray-9.0-hlist-ad.output
@@ -0,0 +1 @@
+/opt/cray/pe/cce/9.0.0/cce/x86_64/include/craylibs;/opt/gcc/8.1.0/snos/include/g\+\+;/opt/gcc/8.1.0/snos/include/g\+\+/x86_64-suse-linux;/opt/gcc/8.1.0/snos/include/g\+\+/backward;/opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0/include;/opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0/include-fixed;/opt/cray/pe/cce/9.0.0/cce/x86_64/include/c\+\+;/opt/cray/pe/cce/9.0.0/cce/x86_64/include/basic;/opt/gcc/8.1.0/snos/include;/usr/include;/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/include;/opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/include;/opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/xpmem/2.2.15-6.0.7.1_5.8__g7549d06.ari/include;/opt/cray/dmapp/7.1.1-6.0.7.0_34.3__g5a674e0.ari/include;/opt/cray/gni-headers/5.0.12.0-6.0.7.0_24.1__g3b1768f.ari/include;/opt/cray/ugni/6.0.14.0-6.0.7.0_23.1__gea11d3d.ari/include;/opt/cray/udreg/2.3.2-6.0.7.0_33.18__g5196236.ari/include;/opt/cray/alps/6.6.43-6.0.7.0_26.4__ga796da3.ari/include;/opt/cray/wlm_detect/1.3.3-6.0.7.0_47.2__g7109084.ari/include;/opt/cray/krca/2.2.4-6.0.7.1_5.23__g8505b97.ari/include;/opt/cray-hss-devel/8.0.0/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-GNU-7.3.0.output
new file mode 100644
index 000000000..b76c5dbb9
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-GNU-7.3.0.output
@@ -0,0 +1 @@
+/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include;/opt/gcc/7.3.0/snos/include/g\+\+;/opt/gcc/7.3.0/snos/include/g\+\+/x86_64-suse-linux;/opt/gcc/7.3.0/snos/include/g\+\+/backward;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include;/usr/local/include;/opt/gcc/7.3.0/snos/include;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include-fixed;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-Intel-18.0.2.20180210.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-Intel-18.0.2.20180210.output
new file mode 100644
index 000000000..031c32440
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-CXX-Intel-18.0.2.20180210.output
@@ -0,0 +1 @@
+/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include;/opt/gcc/6.3.0/snos/include/g\+\+;/opt/gcc/6.3.0/snos/include/g\+\+/x86_64-suse-linux;/opt/gcc/6.3.0/snos/include/g\+\+/backward;/usr/local/include;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed;/opt/gcc/6.3.0/snos/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-Cray-8.7.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-Cray-8.7.output
new file mode 100644
index 000000000..daa34e2ea
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-Cray-8.7.output
@@ -0,0 +1 @@
+/opt/cray/pe/cce/8.7.4/cce/x86_64/include/craylibs;/usr/include;/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-Cray-9.0-hlist-ad.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-Cray-9.0-hlist-ad.output
new file mode 100644
index 000000000..234483b4e
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-Cray-9.0-hlist-ad.output
@@ -0,0 +1 @@
+/opt/cray/pe/cce/9.0.0/cce/x86_64/include/craylibs;/usr/include;/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/include;/opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/include;/opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/xpmem/2.2.15-6.0.7.1_5.8__g7549d06.ari/include;/opt/cray/dmapp/7.1.1-6.0.7.0_34.3__g5a674e0.ari/include;/opt/cray/gni-headers/5.0.12.0-6.0.7.0_24.1__g3b1768f.ari/include;/opt/cray/ugni/6.0.14.0-6.0.7.0_23.1__gea11d3d.ari/include;/opt/cray/udreg/2.3.2-6.0.7.0_33.18__g5196236.ari/include;/opt/cray/alps/6.6.43-6.0.7.0_26.4__ga796da3.ari/include;/opt/cray/wlm_detect/1.3.3-6.0.7.0_47.2__g7109084.ari/include;/opt/cray/krca/2.2.4-6.0.7.1_5.23__g8505b97.ari/include;/opt/cray-hss-devel/8.0.0/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-GNU-7.3.0.output
new file mode 100644
index 000000000..5b96c9d08
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-GNU-7.3.0.output
@@ -0,0 +1 @@
+/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/finclude;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include;/usr/local/include;/opt/gcc/7.3.0/snos/include;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0/include-fixed;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-Intel-18.0.2.20180210.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-Intel-18.0.2.20180210.output
new file mode 100644
index 000000000..8e484bca6
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/craype-Fortran-Intel-18.0.2.20180210.output
@@ -0,0 +1 @@
+/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/include;/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/include;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/include;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/include;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/include;/opt/cray/gni-headers/5.0.12-6.0.5.0_2.15__g2ef1ebc.ari/include;/opt/cray/pe/pmi/5.0.14/include;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/include;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/include;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/include;/opt/cray/krca/2.2.2-6.0.5.1_13.47__g4614cf3.ari/include;/opt/cray-hss-devel/8.0.0/include;/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/include;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/intel64;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include/icc;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/include;/usr/local/include;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0/include-fixed;/opt/gcc/6.3.0/snos/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin-C-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin-C-AppleClang-8.0.0.8000042.output
new file mode 100644
index 000000000..20f9b0e94
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin-C-AppleClang-8.0.0.8000042.output
@@ -0,0 +1 @@
+/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.0.0/include;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin-CXX-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin-CXX-AppleClang-8.0.0.8000042.output
new file mode 100644
index 000000000..de0f91f43
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin-CXX-AppleClang-8.0.0.8000042.output
@@ -0,0 +1 @@
+/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c\+\+/v1;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.0.0/include;/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin_nostdinc-C-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin_nostdinc-C-AppleClang-8.0.0.8000042.output
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin_nostdinc-C-AppleClang-8.0.0.8000042.output
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/freebsd-C-Clang-3.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/freebsd-C-Clang-3.3.0.output
new file mode 100644
index 000000000..893ec4972
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/freebsd-C-Clang-3.3.0.output
@@ -0,0 +1 @@
+/usr/include/clang/3.3;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/freebsd-CXX-Clang-3.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/freebsd-CXX-Clang-3.3.0.output
new file mode 100644
index 000000000..97410f20a
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/freebsd-CXX-Clang-3.3.0.output
@@ -0,0 +1 @@
+/usr/include/c\+\+/v1;/usr/include/c\+\+/4.2;/usr/include/c\+\+/4.2/backward;/usr/include/clang/3.3;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/freebsd-Fortran-GNU-4.6.4.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/freebsd-Fortran-GNU-4.6.4.output
new file mode 100644
index 000000000..c0aee1118
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/freebsd-Fortran-GNU-4.6.4.output
@@ -0,0 +1 @@
+/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/finclude;/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/include;/usr/local/include;/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/include-fixed;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-C-empty.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-C-empty.output
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-C-empty.output
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-C-relative.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-C-relative.output
new file mode 100644
index 000000000..e43139b73
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-C-relative.output
@@ -0,0 +1 @@
+ /usr/local/include;[^;]*/Tests/RunCMake/ParseImplicitIncludeInfo/adaptive/relative/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-CXX-empty.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-CXX-empty.output
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-CXX-empty.output
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-CXX-relative.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-CXX-relative.output
new file mode 100644
index 000000000..e43139b73
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/hand-CXX-relative.output
@@ -0,0 +1 @@
+ /usr/local/include;[^;]*/Tests/RunCMake/ParseImplicitIncludeInfo/adaptive/relative/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-GNU-7.3.0.output
new file mode 100644
index 000000000..dcd6565d7
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-GNU-7.3.0.output
@@ -0,0 +1 @@
+/usr/lib/gcc/x86_64-linux-gnu/7/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-Intel-18.0.0.20170811.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-Intel-18.0.0.20170811.output
new file mode 100644
index 000000000..714131c3e
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-Intel-18.0.0.20170811.output
@@ -0,0 +1 @@
+/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/pstl/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/intel64;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/icc;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include;/usr/local/include;/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-PGI-18.10.1.output
new file mode 100644
index 000000000..289c530a6
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-PGI-18.10.1.output
@@ -0,0 +1 @@
+/mnt/pgi/linux86-64/18.10/include-gcc70;/mnt/pgi/linux86-64/18.10/include;/usr/lib/gcc/x86_64-linux-gnu/7/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-XL-12.1.0.output
new file mode 100644
index 000000000..eceacf954
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-XL-12.1.0.output
@@ -0,0 +1 @@
+/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include;/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include;/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/include;/usr/local/include;/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-XL-16.1.0.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-XL-16.1.0.0.output
new file mode 100644
index 000000000..6dac25fb4
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-C-XL-16.1.0.0.output
@@ -0,0 +1 @@
+/opt/ibm/xlsmp/5.1.0/include;/opt/ibm/xlmass/9.1.0/include;/opt/ibm/xlC/16.1.0/include;/usr/local/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CUDA-NVIDIA-10.1.168-CLANG.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CUDA-NVIDIA-10.1.168-CLANG.output
new file mode 100644
index 000000000..84149e6c3
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CUDA-NVIDIA-10.1.168-CLANG.output
@@ -0,0 +1 @@
+/usr/local/cuda/targets/x86_64-linux/include;/usr/include/c\+\+/8;/usr/include/x86_64-linux-gnu/c\+\+/8;/usr/include/c\+\+/8/backward;/usr/include/clang/8.0.1/include;/usr/local/include;/usr/include/x86_64-linux-gnu;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CUDA-NVIDIA-10.1.168-XLClang-v-empty.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CUDA-NVIDIA-10.1.168-XLClang-v-empty.output
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CUDA-NVIDIA-10.1.168-XLClang-v-empty.output
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CUDA-NVIDIA-9.2.148-GCC.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CUDA-NVIDIA-9.2.148-GCC.output
new file mode 100644
index 000000000..497fb887b
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CUDA-NVIDIA-9.2.148-GCC.output
@@ -0,0 +1 @@
+/usr/include/c\+\+/5;/usr/include/x86_64-linux-gnu/c\+\+/5;/usr/include/c\+\+/5/backward;/usr/lib/gcc/x86_64-linux-gnu/5/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-GNU-7.3.0.output
new file mode 100644
index 000000000..af33ba8fe
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-GNU-7.3.0.output
@@ -0,0 +1 @@
+/usr/include/c\+\+/7;/usr/include/x86_64-linux-gnu/c\+\+/7;/usr/include/c\+\+/7/backward;/usr/lib/gcc/x86_64-linux-gnu/7/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-Intel-18.0.0.20170811.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-Intel-18.0.0.20170811.output
new file mode 100644
index 000000000..95bdf991c
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-Intel-18.0.0.20170811.output
@@ -0,0 +1 @@
+/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/pstl/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/include;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/intel64;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include/icc;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/include;/usr/include/c\+\+/4.8.5;/usr/include/c\+\+/4.8.5/x86_64-redhat-linux;/usr/include/c\+\+/4.8.5/backward;/usr/local/include;/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-PGI-18.10.1.output
new file mode 100644
index 000000000..8eb97c84e
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-PGI-18.10.1.output
@@ -0,0 +1 @@
+/mnt/pgi/linux86-64/18.10/include-gcc70;/mnt/pgi/linux86-64/18.10/include;/usr/include/c\+\+/7;/usr/include/x86_64-linux-gnu/c\+\+/7;/usr/include/c\+\+/7/backward;/usr/lib/gcc/x86_64-linux-gnu/7/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-XL-12.1.0.output
new file mode 100644
index 000000000..d6d3e58fd
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-XL-12.1.0.output
@@ -0,0 +1 @@
+/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/include;/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include;/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/include;/usr/include/c\+\+/4.4.7;/usr/include/c\+\+/4.4.7/ppc64-redhat-linux;/usr/include/c\+\+/4.4.7/backward;/usr/local/include;/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/crt/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-XL-16.1.0.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-XL-16.1.0.0.output
new file mode 100644
index 000000000..9e118fc5a
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-CXX-XL-16.1.0.0.output
@@ -0,0 +1 @@
+/opt/ibm/xlsmp/5.1.0/include;/opt/ibm/xlmass/9.1.0/include;/opt/ibm/xlC/16.1.0/include;/usr/include/c\+\+/4.8.5;/usr/include/c\+\+/4.8.5/ppc64le-redhat-linux;/usr/include/c\+\+/4.8.5/backward;/usr/local/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-GNU-7.3.0.output
new file mode 100644
index 000000000..d84842b6f
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-GNU-7.3.0.output
@@ -0,0 +1 @@
+/usr/lib/gcc/x86_64-linux-gnu/7/finclude;/usr/lib/gcc/x86_64-linux-gnu/7/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-PGI-18.10.1.output
new file mode 100644
index 000000000..289c530a6
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-PGI-18.10.1.output
@@ -0,0 +1 @@
+/mnt/pgi/linux86-64/18.10/include-gcc70;/mnt/pgi/linux86-64/18.10/include;/usr/lib/gcc/x86_64-linux-gnu/7/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-XL-14.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-XL-14.1.0.output
new file mode 100644
index 000000000..39a28a46b
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux-Fortran-XL-14.1.0.output
@@ -0,0 +1 @@
+/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/include;/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-C-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-C-PGI-18.10.1.output
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-C-PGI-18.10.1.output
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-C-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-C-XL-12.1.0.output
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-C-XL-12.1.0.output
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-CXX-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-CXX-PGI-18.10.1.output
new file mode 100644
index 000000000..8eb97c84e
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-CXX-PGI-18.10.1.output
@@ -0,0 +1 @@
+/mnt/pgi/linux86-64/18.10/include-gcc70;/mnt/pgi/linux86-64/18.10/include;/usr/include/c\+\+/7;/usr/include/x86_64-linux-gnu/c\+\+/7;/usr/include/c\+\+/7/backward;/usr/lib/gcc/x86_64-linux-gnu/7/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-CXX-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-CXX-XL-12.1.0.output
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-CXX-XL-12.1.0.output
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-Fortran-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-Fortran-PGI-18.10.1.output
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc-Fortran-PGI-18.10.1.output
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc_i-C-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc_i-C-XL-12.1.0.output
new file mode 100644
index 000000000..38f0b3734
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc_i-C-XL-12.1.0.output
@@ -0,0 +1 @@
+/tmp/ii/test_c
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc_i-CXX-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc_i-CXX-XL-12.1.0.output
new file mode 100644
index 000000000..727afdbc0
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_nostdinc_i-CXX-XL-12.1.0.output
@@ -0,0 +1 @@
+/tmp/ii/test_c;/tmp/ii/test_cxx
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_pgf77-Fortran-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_pgf77-Fortran-PGI-18.10.1.output
new file mode 100644
index 000000000..289c530a6
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/linux_pgf77-Fortran-PGI-18.10.1.output
@@ -0,0 +1 @@
+/mnt/pgi/linux86-64/18.10/include-gcc70;/mnt/pgi/linux86-64/18.10/include;/usr/lib/gcc/x86_64-linux-gnu/7/include;/usr/local/include;/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed;/usr/include/x86_64-linux-gnu;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/mingw.org-C-GNU-4.9.3.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/mingw.org-C-GNU-4.9.3.output
new file mode 100644
index 000000000..d23e7fe7c
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/mingw.org-C-GNU-4.9.3.output
@@ -0,0 +1 @@
+C:/DoesNotExist/mingw/lib/gcc/mingw32/4.9.3/include;C:/DoesNotExist/mingw/include;C:/DoesNotExist/mingw/lib/gcc/mingw32/4.9.3/include-fixed
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/mingw.org-CXX-GNU-4.9.3.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/mingw.org-CXX-GNU-4.9.3.output
new file mode 100644
index 000000000..999694050
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/mingw.org-CXX-GNU-4.9.3.output
@@ -0,0 +1 @@
+C:/DoesNotExist/mingw/lib/gcc/mingw32/4.9.3/include/c\+\+;C:/DoesNotExist/mingw/lib/gcc/mingw32/4.9.3/include/c\+\+/mingw32;C:/DoesNotExist/mingw/lib/gcc/mingw32/4.9.3/include/c\+\+/backward;C:/DoesNotExist/mingw/lib/gcc/mingw32/4.9.3/include;C:/DoesNotExist/mingw/include;C:/DoesNotExist/mingw/lib/gcc/mingw32/4.9.3/include-fixed
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd-C-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd-C-GNU-4.8.5.output
new file mode 100644
index 000000000..6b69b2d7c
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd-C-GNU-4.8.5.output
@@ -0,0 +1 @@
+/usr/include/gcc-4.8;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd-CXX-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd-CXX-GNU-4.8.5.output
new file mode 100644
index 000000000..d2289eb81
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd-CXX-GNU-4.8.5.output
@@ -0,0 +1 @@
+/usr/include/g\+\+;/usr/include/g\+\+/backward;/usr/include/gcc-4.8;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd_nostdinc-C-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd_nostdinc-C-GNU-4.8.5.output
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd_nostdinc-C-GNU-4.8.5.output
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd_nostdinc-CXX-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd_nostdinc-CXX-GNU-4.8.5.output
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/netbsd_nostdinc-CXX-GNU-4.8.5.output
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/openbsd-C-Clang-5.0.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/openbsd-C-Clang-5.0.1.output
new file mode 100644
index 000000000..60dbe246a
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/openbsd-C-Clang-5.0.1.output
@@ -0,0 +1 @@
+/usr/lib/clang/5.0.1/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/openbsd-CXX-Clang-5.0.1.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/openbsd-CXX-Clang-5.0.1.output
new file mode 100644
index 000000000..d77687b3c
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/openbsd-CXX-Clang-5.0.1.output
@@ -0,0 +1 @@
+/usr/include/c\+\+/v1;/usr/lib/clang/5.0.1/include;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/sunos-C-SunPro-5.13.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/sunos-C-SunPro-5.13.0.output
new file mode 100644
index 000000000..27c452d26
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/sunos-C-SunPro-5.13.0.output
@@ -0,0 +1 @@
+/opt/solarisstudio12.4/lib/compilers/include/cc;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/sunos-CXX-SunPro-5.13.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/sunos-CXX-SunPro-5.13.0.output
new file mode 100644
index 000000000..be851c2ac
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/sunos-CXX-SunPro-5.13.0.output
@@ -0,0 +1 @@
+/opt/solarisstudio12.4/lib/compilers/include/CC/Cstd;/opt/solarisstudio12.4/lib/compilers/include/CC;/opt/solarisstudio12.4/lib/compilers/include/cc;/usr/include
diff --git a/Tests/RunCMake/ParseImplicitIncludeInfo/results/sunos-Fortran-SunPro-8.8.0.output b/Tests/RunCMake/ParseImplicitIncludeInfo/results/sunos-Fortran-SunPro-8.8.0.output
new file mode 100644
index 000000000..3c31e16c9
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitIncludeInfo/results/sunos-Fortran-SunPro-8.8.0.output
@@ -0,0 +1 @@
+/opt/developerstudio12.6/lib/compilers/include/f95
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/CMakeLists.txt b/Tests/RunCMake/ParseImplicitLinkInfo/CMakeLists.txt
new file mode 100644
index 000000000..289710955
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake
new file mode 100644
index 000000000..bb6beb22b
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake
@@ -0,0 +1,146 @@
+cmake_minimum_required(VERSION 3.14)
+project(Minimal NONE)
+
+#
+# list of targets to test. to add a target: put its files in the data
+# subdirectory and add it to this list... we run each target's
+# data/*.input file through the parser and check to see if it matches
+# the corresponding data/*.output file. note that the empty-* case
+# has special handling (it should not parse).
+#
+set(targets
+ aix-C-XL-13.1.3 aix-CXX-XL-13.1.3
+ aix-C-XLClang-16.1.0.1 aix-CXX-XLClang-16.1.0.1
+ craype-C-Cray-8.7 craype-CXX-Cray-8.7 craype-Fortran-Cray-8.7
+ craype-C-Cray-9.0-hlist-ad craype-CXX-Cray-9.0-hlist-ad craype-Fortran-Cray-9.0-hlist-ad
+ craype-C-GNU-7.3.0 craype-CXX-GNU-7.3.0 craype-Fortran-GNU-7.3.0
+ craype-C-Intel-18.0.2.20180210 craype-CXX-Intel-18.0.2.20180210
+ craype-Fortran-Intel-18.0.2.20180210
+ darwin-C-AppleClang-8.0.0.8000042 darwin-CXX-AppleClang-8.0.0.8000042
+ darwin_nostdinc-C-AppleClang-8.0.0.8000042
+ darwin_nostdinc-CXX-AppleClang-8.0.0.8000042
+ freebsd-C-Clang-3.3.0 freebsd-CXX-Clang-3.3.0 freebsd-Fortran-GNU-4.6.4
+ hand-C-empty hand-CXX-empty
+ hand-C-relative hand-CXX-relative
+ linux-C-GNU-7.3.0 linux-CXX-GNU-7.3.0 linux-Fortran-GNU-7.3.0
+ linux-C-Intel-18.0.0.20170811 linux-CXX-Intel-18.0.0.20170811
+ linux-C-PGI-18.10.1 linux-CXX-PGI-18.10.1
+ linux-Fortran-PGI-18.10.1 linux_pgf77-Fortran-PGI-18.10.1
+ linux_nostdinc-C-PGI-18.10.1 linux_nostdinc-CXX-PGI-18.10.1
+ linux_nostdinc-Fortran-PGI-18.10.1
+ linux-C-XL-12.1.0 linux-CXX-XL-12.1.0 linux-Fortran-XL-14.1.0
+ linux_nostdinc-C-XL-12.1.0 linux_nostdinc-CXX-XL-12.1.0
+ linux_nostdinc_i-C-XL-12.1.0 linux_nostdinc-CXX-XL-12.1.0
+ linux-C-XL-16.1.0.0 linux-CXX-XL-16.1.0.0
+ linux-CUDA-NVIDIA-10.1.168-CLANG linux-CUDA-NVIDIA-10.1.168-XLClang-v
+ linux-CUDA-NVIDIA-9.2.148-GCC
+ mingw.org-C-GNU-4.9.3 mingw.org-CXX-GNU-4.9.3
+ netbsd-C-GNU-4.8.5 netbsd-CXX-GNU-4.8.5
+ netbsd_nostdinc-C-GNU-4.8.5 netbsd_nostdinc-CXX-GNU-4.8.5
+ openbsd-C-Clang-5.0.1 openbsd-CXX-Clang-5.0.1
+ sunos-C-SunPro-5.13.0 sunos-CXX-SunPro-5.13.0 sunos-Fortran-SunPro-8.8.0
+ )
+
+if(CMAKE_HOST_WIN32)
+ # The KWSys actual-case cache breaks case sensitivity on Windows.
+ list(FILTER targets EXCLUDE REGEX "-XL|-SunPro")
+else()
+ # Windows drive letters are not recognized as absolute on other platforms.
+ list(FILTER targets EXCLUDE REGEX "mingw")
+endif()
+
+include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake)
+
+#
+# load_compiler_info: read infile, parsing out cmake compiler info
+# variables as we go. returns language, a list of variables we set
+# (so we can clear them later), and the remaining verbose output
+# from the compiler.
+#
+function(load_compiler_info infile lang_var outcmvars_var outstr_var)
+ unset(lang)
+ unset(outcmvars)
+ unset(outstr)
+ file(READ "${infile}" in)
+ string(REGEX REPLACE "\r?\n" ";" in_lines "${in}")
+ foreach(line IN LISTS in_lines)
+ # check for special CMAKE variable lines and parse them if found
+ if("${line}" MATCHES "^CMAKE_([_A-Za-z0-9]+)=(.*)$")
+ if("${CMAKE_MATCH_1}" STREQUAL "LANG") # handle CMAKE_LANG here
+ set(lang "${CMAKE_MATCH_2}")
+ else()
+ set(CMAKE_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" PARENT_SCOPE)
+ list(APPEND outcmvars "CMAKE_${CMAKE_MATCH_1}")
+ endif()
+ else()
+ string(APPEND outstr "${line}\n")
+ endif()
+ endforeach()
+ if(NOT lang)
+ message("load_compiler_info: ${infile} no LANG info; default to C")
+ set(lang C)
+ endif()
+ set(${lang_var} "${lang}" PARENT_SCOPE)
+ set(${outcmvars_var} "${outcmvars}" PARENT_SCOPE)
+ set(${outstr_var} "${outstr}" PARENT_SCOPE)
+endfunction()
+
+#
+# unload_compiler_info: clear out any CMAKE_* vars load previously set
+#
+function(unload_compiler_info cmvars)
+ foreach(var IN LISTS cmvars)
+ unset("${var}" PARENT_SCOPE)
+ endforeach()
+endfunction()
+
+#
+# main test loop
+#
+foreach(t ${targets})
+ set(infile "${CMAKE_SOURCE_DIR}/../ParseImplicitData/${t}.input")
+ set(outfile "${CMAKE_SOURCE_DIR}/results/${t}.output")
+ if (NOT EXISTS ${infile})
+ string(REPLACE "-empty" "" infile "${infile}")
+ if (NOT EXISTS ${infile})
+ message("missing input file for target ${t} in ${CMAKE_SOURCE_DIR}/../ParseImplicitData/")
+ continue()
+ endif()
+ elseif(NOT EXISTS ${outfile})
+ message("missing files for target ${t} in ${CMAKE_SOURCE_DIR}/results/")
+ continue()
+ endif()
+
+ load_compiler_info(${infile} lang cmvars input)
+
+ # Need to handle files with empty entries for both libs or dirs
+ set(implicit_lib_output "")
+ set(idirs_output "")
+ file(STRINGS ${outfile} outputs)
+ foreach(line IN LISTS outputs)
+ if(line MATCHES "libs=")
+ string(REPLACE "libs=" "" implicit_lib_output "${line}")
+ endif()
+ if(line MATCHES "dirs=")
+ string(REPLACE "dirs=" "" idirs_output "${line}")
+ endif()
+ endforeach()
+
+ cmake_parse_implicit_link_info("${input}" implicit_libs idirs implicit_fwks log
+ "${CMAKE_${lang}_IMPLICIT_OBJECT_REGEX}")
+
+ # File format
+ # file(WRITE ${outfile} "libs=${implicit_libs}\ndirs=${idirs}\n")
+
+ if(t MATCHES "-empty$") # empty isn't supposed to parse
+ if("${state}" STREQUAL "done")
+ message("empty parse failed: ${idirs}, log=${log}")
+ endif()
+ elseif(NOT "${idirs}" STREQUAL "${idirs_output}")
+ message("${t} parse failed: state=${state}, '${idirs}' does not match '${idirs_output}'")
+ elseif(NOT "${implicit_libs}" STREQUAL "${implicit_lib_output}")
+ message("${t} parse failed: state=${state}, '${implicit_libs}' does not match '${implicit_lib_output}'")
+ endif()
+
+ unload_compiler_info("${cmvars}")
+endforeach(t)
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake
new file mode 100644
index 000000000..713e2e76c
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(ParseImplicitLinkInfo)
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-C-XL-13.1.3.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-C-XL-13.1.3.output
new file mode 100644
index 000000000..4e030b3de
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-C-XL-13.1.3.output
@@ -0,0 +1,2 @@
+libs=xlopt;xlipa;xl;c
+dirs=/opt/IBM/xlmass/8.1.3/lib/aix61;/opt/IBM/xlc/13.1.3/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-C-XLClang-16.1.0.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-C-XLClang-16.1.0.1.output
new file mode 100644
index 000000000..6f677a000
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-C-XLClang-16.1.0.1.output
@@ -0,0 +1,2 @@
+libs=xlopt;xlipa;xl;c;pthreads
+dirs=/opt/IBM/xlmass/9.1.0/lib/aix61;/opt/IBM/xlc/16.1.0/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-CXX-XL-13.1.3.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-CXX-XL-13.1.3.output
new file mode 100644
index 000000000..6cbc792c5
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-CXX-XL-13.1.3.output
@@ -0,0 +1,2 @@
+libs=xlopt;xlipa;xl;C;m;c
+dirs=/opt/IBM/xlmass/8.1.3/lib/aix61;/opt/IBM/xlc/13.1.3/lib;/opt/IBM/xlC/13.1.3/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-CXX-XLClang-16.1.0.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-CXX-XLClang-16.1.0.1.output
new file mode 100644
index 000000000..2dc5832b3
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/aix-CXX-XLClang-16.1.0.1.output
@@ -0,0 +1,2 @@
+libs=xlopt;xlipa;xl;c++;Ccore;pthreads;m;c
+dirs=/opt/IBM/xlmass/9.1.0/lib/aix61;/opt/IBM/xlc/16.1.0/lib;/opt/IBM/xlC/16.1.0/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-8.7.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-8.7.output
new file mode 100644
index 000000000..674975cbd
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-8.7.output
@@ -0,0 +1,2 @@
+libs=AtpSigHandler;AtpSigHCommData;pthread;sci_cray_mpi_mp;m;f;sci_cray_mp;craymp;m;pthread;f;hugetlbfs;mpich_cray;rt;pthread;ugni;pmi;pgas-dmapp;fi;u;rt;dmapp;ugni;udreg;pthread;m;cray-c++-rts;stdc++;xpmem;dmapp;pthread;pmi;pthread;alpslli;pthread;wlm_detect;ugni;pthread;alpsutil;pthread;rca;udreg;quadmath;m;omp;rt;craymp;pthread;rt;dl;cray-c++-rts;stdc++;m;modules;m;rt;fi;m;quadmath;rt;craymath;m;gfortran;quadmath;rt;f;m;pthread;rt;u;rt;dl;cray-c++-rts;stdc++;m;csup;rt;atomic;stdc++;pthread;c;csup;m;gcc
+dirs=/opt/gcc/6.1.0/snos/lib64;/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/lib;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64;/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/lib64;/opt/cray/pe/pmi/5.0.14/lib64;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/pe/cce/8.7.4/cce/x86_64/lib;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64;/usr/lib64;/lib64;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0;/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-unknown-linux-gnu/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-9.0-hlist-ad.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-9.0-hlist-ad.output
new file mode 100644
index 000000000..1bf2f6d05
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Cray-9.0-hlist-ad.output
@@ -0,0 +1,2 @@
+libs=AtpSigHandler;AtpSigHCommData;rca;mpich_cray_90;sci_cray_mpi;sci_cray;pgas-dmapp;quadmath;modules;fi;craymath;f;u;csup;atomic;tcmalloc_minimal;cray-c++-rts;stdc++;pthread;c;csup;m;clang_rt.craypgo-x86_64;gcc
+dirs=/opt/gcc/8.1.0/snos/lib64;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/lib;/opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/lib;/opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/pe/cce/9.0.0/cce/x86_64/lib;/usr/lib64;/lib64;/opt/cray/pe/cce/9.0.0/cce-clang/x86_64/lib/clang/9.0.0/lib/linux;/opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0;/opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-unknown-linux-gnu/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-GNU-7.3.0.output
new file mode 100644
index 000000000..267bf58bb
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-GNU-7.3.0.output
@@ -0,0 +1,2 @@
+libs=AtpSigHandler;AtpSigHCommData;pthread;sci_gnu_71_mpi;sci_gnu_71;pthread;hugetlbfs;mpich_gnu_71;rt;ugni;pthread;pmi;pthread;alpslli;pthread;wlm_detect;alpsutil;pthread;rca;xpmem;ugni;pthread;udreg;gfortran;quadmath;mvec;m;pthread;gcc;c
+dirs=/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64;/opt/cray/pe/pmi/5.0.14/lib64;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0;/opt/gcc/7.3.0/snos/lib64;/lib64;/usr/lib64;/opt/gcc/7.3.0/snos/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Intel-18.0.2.20180210.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Intel-18.0.2.20180210.output
new file mode 100644
index 000000000..e9e67396f
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-C-Intel-18.0.2.20180210.output
@@ -0,0 +1,2 @@
+libs=imf;svml;irng;m;ipgo;decimal;cilkrts;stdc++;gcc;gcc_s;irc;svml;c;gcc;gcc_s;irc_s;dl;c
+dirs=/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0;/opt/gcc/6.3.0/snos/lib64;/lib64;/usr/lib64;/opt/gcc/6.3.0/snos/lib;/lib;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-8.7.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-8.7.output
new file mode 100644
index 000000000..7daa29d40
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-8.7.output
@@ -0,0 +1,2 @@
+libs=AtpSigHandler;AtpSigHCommData;pthread;sci_cray_mpi_mp;m;f;sci_cray_mp;craymp;m;pthread;f;hugetlbfs;mpichcxx_cray;rt;pthread;ugni;pmi;mpich_cray;rt;pthread;ugni;pmi;pgas-dmapp;fi;u;rt;dmapp;ugni;udreg;pthread;m;cray-c++-rts;stdc++;xpmem;dmapp;pthread;pmi;pthread;alpslli;pthread;wlm_detect;ugni;pthread;alpsutil;pthread;rca;udreg;quadmath;m;omp;rt;craymp;pthread;rt;dl;cray-c++-rts;stdc++;m;modules;m;rt;fi;m;quadmath;rt;craymath;m;gfortran;quadmath;rt;f;m;pthread;rt;u;rt;dl;cray-c++-rts;stdc++;m;csup;rt;atomic;cray-c++-rts;stdc++;supc++;stdc++;pthread;c;csup;m;gcc
+dirs=/opt/gcc/6.1.0/snos/lib64;/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/lib;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64;/opt/cray/dmapp/7.1.1-6.0.5.0_49.8__g1125556.ari/lib64;/opt/cray/pe/pmi/5.0.14/lib64;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/pe/cce/8.7.4/cce/x86_64/lib;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64;/usr/lib64;/lib64;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0;/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-unknown-linux-gnu/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-9.0-hlist-ad.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-9.0-hlist-ad.output
new file mode 100644
index 000000000..958a6b1cf
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Cray-9.0-hlist-ad.output
@@ -0,0 +1,2 @@
+libs=AtpSigHandler;AtpSigHCommData;rca;mpich_cray_90;mpichcxx_cray_90;sci_cray_mpi;sci_cray;pgas-dmapp;quadmath;modules;fi;craymath;f;u;csup;atomic;cray-c++-rts;cray-c++-rts;stdc++;supc++;tcmalloc_minimal;cray-c++-rts;stdc++;pthread;c;csup;m;clang_rt.craypgo-x86_64;gcc
+dirs=/opt/gcc/8.1.0/snos/lib64;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/lib;/opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/lib;/opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/pe/cce/9.0.0/cce/x86_64/lib;/usr/lib64;/lib64;/opt/cray/pe/cce/9.0.0/cce-clang/x86_64/lib/clang/9.0.0/lib/linux;/opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0;/opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-unknown-linux-gnu/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-GNU-7.3.0.output
new file mode 100644
index 000000000..40d0047c7
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-GNU-7.3.0.output
@@ -0,0 +1,2 @@
+libs=AtpSigHandler;AtpSigHCommData;pthread;sci_gnu_71_mpi;sci_gnu_71;pthread;hugetlbfs;mpichcxx_gnu_71;rt;ugni;pthread;pmi;mpich_gnu_71;rt;ugni;pthread;pmi;pthread;alpslli;pthread;wlm_detect;alpsutil;pthread;rca;ugni;pthread;xpmem;udreg;gfortran;quadmath;mvec;m;pthread;stdc++;m;gcc;c
+dirs=/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64;/opt/cray/pe/pmi/5.0.14/lib64;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0;/opt/gcc/7.3.0/snos/lib64;/lib64;/usr/lib64;/opt/gcc/7.3.0/snos/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Intel-18.0.2.20180210.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Intel-18.0.2.20180210.output
new file mode 100644
index 000000000..621284418
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-CXX-Intel-18.0.2.20180210.output
@@ -0,0 +1,2 @@
+libs=imf;svml;irng;stdc++;m;ipgo;decimal;cilkrts;stdc++;gcc;gcc_s;irc;svml;c;gcc;gcc_s;irc_s;dl;c
+dirs=/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0;/opt/gcc/6.3.0/snos/lib64;/lib64;/usr/lib64;/opt/gcc/6.3.0/snos/lib;/lib;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-8.7.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-8.7.output
new file mode 100644
index 000000000..9828bf3cf
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-8.7.output
@@ -0,0 +1,2 @@
+libs=AtpSigHandler;AtpSigHCommData;rca;sci_cray_mpi_mp;sci_cray_mp;mpich_cray;mpichf90_cray;pgas-dmapp;quadmath;omp;craymp;modules;fi;craymath;f;u;csup;atomic;gfortran;tcmalloc_minimal;stdc++;pthread;c;csup;m;gcc
+dirs=/opt/gcc/6.1.0/snos/lib64;/opt/cray/pe/libsci/18.07.1/CRAY/8.6/x86_64/lib;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.3/gni/mpich-cray/8.6/lib;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/pe/cce/8.7.4/cce/x86_64/lib;/usr/lib64;/lib64;/opt/gcc/6.1.0/snos/lib/gcc/x86_64-suse-linux/6.1.0;/opt/cray/pe/cce/8.7.4/binutils/x86_64/x86_64-unknown-linux-gnu/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-9.0-hlist-ad.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-9.0-hlist-ad.output
new file mode 100644
index 000000000..46754080f
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Cray-9.0-hlist-ad.output
@@ -0,0 +1,2 @@
+libs=AtpSigHandler;AtpSigHCommData;rca;mpich_cray_90;mpichf90_cray_90;sci_cray_mpi;sci_cray;pgas-dmapp;quadmath;modules;fi;craymath;f;u;csup;gfortran;tcmalloc_minimal;cray-c++-rts;stdc++;pthread;c;csup;m;clang_rt.craypgo-x86_64;gcc
+dirs=/opt/gcc/8.1.0/snos/lib64;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.8/gni/mpich-cray/9.0/lib;/opt/cray/pe/libsci/19.06.1/CRAY/9.0/x86_64/lib;/opt/cray/rca/2.2.18-6.0.7.0_33.3__g2aa4f39.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/pe/cce/9.0.0/cce/x86_64/lib;/usr/lib64;/lib64;/opt/cray/pe/cce/9.0.0/cce-clang/x86_64/lib/clang/9.0.0/lib/linux;/opt/gcc/8.1.0/snos/lib/gcc/x86_64-suse-linux/8.1.0;/opt/cray/pe/cce/9.0.0/binutils/x86_64/x86_64-unknown-linux-gnu/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-GNU-7.3.0.output
new file mode 100644
index 000000000..da2e55729
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-GNU-7.3.0.output
@@ -0,0 +1,2 @@
+libs=AtpSigHandler;AtpSigHCommData;rca;sci_gnu_71_mpi;sci_gnu_71;mpich_gnu_71;mpichf90_gnu_71;gfortran;quadmath;pthread;gfortran;m;gcc_s;gcc;quadmath;m;gcc_s;gcc;c;gcc_s;gcc
+dirs=/opt/cray/pe/libsci/18.07.1/GNU/7.1/x86_64/lib;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.3/gni/mpich-gnu/7.1/lib;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/gcc/7.3.0/snos/lib/gcc/x86_64-suse-linux/7.3.0;/opt/gcc/7.3.0/snos/lib64;/lib64;/usr/lib64;/opt/gcc/7.3.0/snos/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Intel-18.0.2.20180210.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Intel-18.0.2.20180210.output
new file mode 100644
index 000000000..e73cbe9fd
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/craype-Fortran-Intel-18.0.2.20180210.output
@@ -0,0 +1,2 @@
+libs=hugetlbfs;AtpSigHandler;AtpSigHCommData;pthread;mpichf90_intel;rt;ugni;pmi;imf;m;pthread;dl;sci_intel_mpi;sci_intel;imf;m;dl;mpich_intel;rt;ugni;pthread;pmi;imf;m;dl;pmi;pthread;alpslli;pthread;wlm_detect;alpsutil;pthread;rca;xpmem;ugni;pthread;udreg;sci_intel;imf;m;pthread;dl;hugetlbfs;imf;m;pthread;ifport;ifcore;imf;svml;m;ipgo;irc;svml;c;gcc;irc_s;dl;c
+dirs=/opt/cray/pe/libsci/18.07.1/INTEL/16.0/x86_64/lib;/opt/cray/dmapp/default/lib64;/opt/cray/pe/mpt/7.7.3/gni/mpich-intel/16.0/lib;/opt/cray/rca/2.2.16-6.0.5.0_15.34__g5e09e6d.ari/lib64;/opt/cray/alps/6.5.28-6.0.5.0_18.6__g13a91b6.ari/lib64;/opt/cray/xpmem/2.2.4-6.0.5.1_8.26__g35d5e73.ari/lib64;/opt/cray/pe/pmi/5.0.14/lib64;/opt/cray/ugni/6.0.14-6.0.5.0_16.9__g19583bb.ari/lib64;/opt/cray/udreg/2.3.2-6.0.5.0_13.12__ga14955a.ari/lib64;/opt/cray/pe/atp/2.1.3/libApp;/opt/cray/wlm_detect/1.3.2-6.0.5.0_3.1__g388ccd5.ari/lib64;/opt/intel/2018.2.199/compilers_and_libraries_2018/linux/mkl/lib/intel64;/opt/intel/2018.2.199/compilers_and_libraries_2018.2.199/linux/compiler/lib/intel64_lin;/opt/gcc/6.3.0/snos/lib/gcc/x86_64-suse-linux/6.3.0;/opt/gcc/6.3.0/snos/lib64;/lib64;/usr/lib64;/opt/gcc/6.3.0/snos/lib;/lib;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin-C-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin-C-AppleClang-8.0.0.8000042.output
new file mode 100644
index 000000000..c041faa4e
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin-C-AppleClang-8.0.0.8000042.output
@@ -0,0 +1,2 @@
+libs=
+dirs=/usr/lib;/usr/local/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin-CXX-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin-CXX-AppleClang-8.0.0.8000042.output
new file mode 100644
index 000000000..f75637c57
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin-CXX-AppleClang-8.0.0.8000042.output
@@ -0,0 +1,2 @@
+libs=c++
+dirs=/usr/lib;/usr/local/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin_nostdinc-C-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin_nostdinc-C-AppleClang-8.0.0.8000042.output
new file mode 100644
index 000000000..c041faa4e
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin_nostdinc-C-AppleClang-8.0.0.8000042.output
@@ -0,0 +1,2 @@
+libs=
+dirs=/usr/lib;/usr/local/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output
new file mode 100644
index 000000000..f75637c57
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/darwin_nostdinc-CXX-AppleClang-8.0.0.8000042.output
@@ -0,0 +1,2 @@
+libs=c++
+dirs=/usr/lib;/usr/local/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-C-Clang-3.3.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-C-Clang-3.3.0.output
new file mode 100644
index 000000000..4ce854adc
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-C-Clang-3.3.0.output
@@ -0,0 +1,2 @@
+libs=gcc;gcc_s;c;gcc;gcc_s
+dirs=/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-CXX-Clang-3.3.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-CXX-Clang-3.3.0.output
new file mode 100644
index 000000000..b0b8e25b5
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-CXX-Clang-3.3.0.output
@@ -0,0 +1,2 @@
+libs=c++;m;gcc;gcc_s;c;gcc;gcc_s
+dirs=/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-Fortran-GNU-4.6.4.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-Fortran-GNU-4.6.4.output
new file mode 100644
index 000000000..12283333a
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/freebsd-Fortran-GNU-4.6.4.output
@@ -0,0 +1,2 @@
+libs=gfortran;m;gcc_s;gcc;quadmath;m;gcc_s;gcc;c;gcc_s;gcc
+dirs=/usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4;/usr/local/x86_64-portbld-freebsd10.0/lib;/usr/local/lib/gcc46
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/hand-C-empty.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/hand-C-empty.output
new file mode 100644
index 000000000..1b14cd558
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/hand-C-empty.output
@@ -0,0 +1,2 @@
+libs=
+dirs=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/hand-C-relative.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/hand-C-relative.output
new file mode 100644
index 000000000..9bb651af5
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/hand-C-relative.output
@@ -0,0 +1,2 @@
+libs=
+dirs=/usr/lib64
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/hand-CXX-empty.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/hand-CXX-empty.output
new file mode 100644
index 000000000..1b14cd558
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/hand-CXX-empty.output
@@ -0,0 +1,2 @@
+libs=
+dirs=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/hand-CXX-relative.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/hand-CXX-relative.output
new file mode 100644
index 000000000..9bb651af5
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/hand-CXX-relative.output
@@ -0,0 +1,2 @@
+libs=
+dirs=/usr/lib64
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-GNU-7.3.0.output
new file mode 100644
index 000000000..63b51a1ec
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-GNU-7.3.0.output
@@ -0,0 +1,2 @@
+libs=gcc;gcc_s;c;gcc;gcc_s
+dirs=/usr/lib/gcc/x86_64-linux-gnu/7;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-Intel-18.0.0.20170811.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-Intel-18.0.0.20170811.output
new file mode 100644
index 000000000..b61e097d2
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-Intel-18.0.0.20170811.output
@@ -0,0 +1,2 @@
+libs=imf;svml;irng;m;ipgo;decimal;cilkrts;stdc++;gcc;gcc_s;irc;svml;c;gcc;gcc_s;irc_s;dl;c
+dirs=/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin;/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin;/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7;/usr/lib/gcc/x86_64-redhat-linux/4.8.5;/usr/lib64;/lib64;/usr/lib;/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-PGI-18.10.1.output
new file mode 100644
index 000000000..7b2091502
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-PGI-18.10.1.output
@@ -0,0 +1,2 @@
+libs=pgmp;numa;pthread;pgmath;nspgc;pgc;m;gcc;c;gcc;gcc_s
+dirs=/mnt/pgi/linux86-64/18.10/lib;/usr/lib64;/usr/lib/gcc/x86_64-linux-gnu/7
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-XL-12.1.0.output
new file mode 100644
index 000000000..de407f2f0
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-XL-12.1.0.output
@@ -0,0 +1,2 @@
+libs=xlopt;xl;dl;gcc_s;gcc;m;c;gcc_s;gcc
+dirs=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64;/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64;/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64;/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64;/usr/lib/gcc/ppc64-redhat-linux/4.4.7;/usr/lib64;/lib64;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-XL-16.1.0.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-XL-16.1.0.0.output
new file mode 100644
index 000000000..de515e790
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-C-XL-16.1.0.0.output
@@ -0,0 +1,2 @@
+libs=xlopt;xl;dl;gcc_s;pthread;gcc;m;c;gcc_s;gcc
+dirs=/opt/ibm/xlsmp/5.1.0/lib;/opt/ibm/xlmass/9.1.0/lib;/opt/ibm/xlC/16.1.0/lib;/usr/lib/gcc/ppc64le-redhat-linux/4.8.5;/usr/lib64;/lib64;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-CLANG.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-CLANG.output
new file mode 100644
index 000000000..a657b8508
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-CLANG.output
@@ -0,0 +1,2 @@
+libs=cudadevrt;cudart_static;rt;pthread;dl;stdc++;m;gcc_s;gcc;c;gcc_s;gcc
+dirs=/usr/local/cuda/targets/x86_64-linux/lib/stubs;/usr/local/cuda/targets/x86_64-linux/lib;/usr/lib/gcc/x86_64-linux-gnu/8;/usr/lib/x86_64-linux-gnu;/lib/x86_64-linux-gnu;/lib64;/usr/lib;/usr/lib/llvm-8/lib;/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-XLClang-v.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-XLClang-v.output
new file mode 100644
index 000000000..58ae64d60
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-10.1.168-XLClang-v.output
@@ -0,0 +1,2 @@
+libs=cudadevrt;cudart_static;rt;pthread;dl;xlopt;xl;ibmc++;stdc++;m;dl;gcc_s;gcc;pthread;m;c;gcc_s;gcc
+dirs=/sw/summit/cuda/10.1.168/targets/ppc64le-linux/lib/stubs;/sw/summit/cuda/10.1.168/targets/ppc64le-linux/lib;/autofs/nccs-svm1_sw/summit/.swci/1-compute/opt/spack/20180914/linux-rhel7-ppc64le/xl-16.1.1-3/spectrum-mpi-10.3.0.1-20190611-aqjt3jo53mogrrhcrd2iufr435azcaha/lib;/autofs/nccs-svm1_sw/summit/.swci/1-compute/opt/spack/20180914/linux-rhel7-ppc64le/gcc-4.8.5/darshan-runtime-3.1.7-csygoqyym3m3ysoaperhxlhoiluvpa2u/lib;/autofs/nccs-svm1_sw/summit/xl/16.1.1-3/xlsmp/5.1.1/lib;/autofs/nccs-svm1_sw/summit/xl/16.1.1-3/xlmass/9.1.1/lib;/autofs/nccs-svm1_sw/summit/xl/16.1.1-3/xlC/16.1.1/lib;/usr/lib/gcc/ppc64le-redhat-linux/4.8.5;/usr/lib64;/lib64;/autofs/nccs-svm1_sw/peak/.swci/1-compute/opt/spack/20180914/linux-rhel7-ppc64le/gcc-4.8.5/darshan-runtime-3.1.7-ytwv7xbkub6mqnpvygdthwqa7mhjqbc5/lib;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-9.2.148-GCC.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-9.2.148-GCC.output
new file mode 100644
index 000000000..7c99bf669
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CUDA-NVIDIA-9.2.148-GCC.output
@@ -0,0 +1,2 @@
+libs=cudadevrt;cudart_static;rt;pthread;dl;stdc++;m;gcc_s;gcc;c;gcc_s;gcc
+dirs=/usr/lib/x86_64-linux-gnu/stubs;/usr/lib/gcc/x86_64-linux-gnu/5;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-GNU-7.3.0.output
new file mode 100644
index 000000000..4fc79373d
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-GNU-7.3.0.output
@@ -0,0 +1,2 @@
+libs=stdc++;m;gcc_s;gcc;c;gcc_s;gcc
+dirs=/usr/lib/gcc/x86_64-linux-gnu/7;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-Intel-18.0.0.20170811.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-Intel-18.0.0.20170811.output
new file mode 100644
index 000000000..5d857892c
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-Intel-18.0.0.20170811.output
@@ -0,0 +1,2 @@
+libs=imf;svml;irng;stdc++;m;ipgo;decimal;cilkrts;stdc++;gcc;gcc_s;irc;svml;c;gcc;gcc_s;irc_s;dl;c
+dirs=/opt/intel/compilers_and_libraries_2018.0.128/linux/ipp/lib/intel64;/opt/intel/compilers_and_libraries_2018.0.128/linux/compiler/lib/intel64_lin;/opt/intel/compilers_and_libraries_2018.0.128/linux/mkl/lib/intel64_lin;/opt/intel/compilers_and_libraries_2018.0.128/linux/tbb/lib/intel64/gcc4.7;/usr/lib/gcc/x86_64-redhat-linux/4.8.5;/usr/lib64;/lib64;/usr/lib;/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-PGI-18.10.1.output
new file mode 100644
index 000000000..db0b29c90
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-PGI-18.10.1.output
@@ -0,0 +1,2 @@
+libs=atomic;pgatm;stdc++;pgmp;numa;pthread;pgmath;nspgc;pgc;m;gcc;c;gcc;gcc_s
+dirs=/mnt/pgi/linux86-64/18.10/lib;/usr/lib64;/usr/lib/gcc/x86_64-linux-gnu/7
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-12.1.0.output
new file mode 100644
index 000000000..4466415b3
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-12.1.0.output
@@ -0,0 +1,2 @@
+libs=xlopt;xl;ibmc++;xlopt;xl;stdc++;m;dl;gcc_s;gcc;m;c;gcc_s;gcc;dl;gcc_s;gcc;m;c;gcc_s;gcc
+dirs=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64;/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64;/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64;/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64;/usr/lib/gcc/ppc64-redhat-linux/4.4.7;/usr/lib64;/lib64;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-16.1.0.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-16.1.0.0.output
new file mode 100644
index 000000000..8124911fa
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-CXX-XL-16.1.0.0.output
@@ -0,0 +1,2 @@
+libs=xlopt;xl;ibmc++;stdc++;m;dl;gcc_s;gcc;pthread;m;c;gcc_s;gcc
+dirs=/opt/ibm/xlsmp/5.1.0/lib;/opt/ibm/xlmass/9.1.0/lib;/opt/ibm/xlC/16.1.0/lib;/usr/lib/gcc/ppc64le-redhat-linux/4.8.5;/usr/lib64;/lib64;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-GNU-7.3.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-GNU-7.3.0.output
new file mode 100644
index 000000000..f985a0330
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-GNU-7.3.0.output
@@ -0,0 +1,2 @@
+libs=gfortran;m;gcc_s;gcc;quadmath;m;gcc_s;gcc;c;gcc_s;gcc
+dirs=/usr/lib/gcc/x86_64-linux-gnu/7;/usr/lib/x86_64-linux-gnu;/usr/lib;/lib/x86_64-linux-gnu;/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-PGI-18.10.1.output
new file mode 100644
index 000000000..d40f81eb9
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-PGI-18.10.1.output
@@ -0,0 +1,2 @@
+libs=pgf90rtl;pgf90;pgf90_rpm1;pgf902;pgf90rtl;pgftnrtl;pgmp;numa;pthread;pgmath;nspgc;pgc;rt;pthread;m;gcc;c;gcc;gcc_s
+dirs=/mnt/pgi/linux86-64/18.10/lib;/usr/lib64;/usr/lib/gcc/x86_64-linux-gnu/7
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-XL-14.1.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-XL-14.1.0.output
new file mode 100644
index 000000000..3c5d23bfc
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux-Fortran-XL-14.1.0.output
@@ -0,0 +1,2 @@
+libs=xlf90;xlopt;xlomp_ser;xl;xlfmath;gcc_s;dl;rt;pthread;gcc;m;c;gcc_s;gcc
+dirs=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64;/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64;/soft/compilers/ibmcmp-oct2017/xlf/bg/14.1/lib64;/usr/lib/gcc/ppc64-redhat-linux/4.4.7;/usr/lib64;/lib64;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-C-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-C-PGI-18.10.1.output
new file mode 100644
index 000000000..7b2091502
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-C-PGI-18.10.1.output
@@ -0,0 +1,2 @@
+libs=pgmp;numa;pthread;pgmath;nspgc;pgc;m;gcc;c;gcc;gcc_s
+dirs=/mnt/pgi/linux86-64/18.10/lib;/usr/lib64;/usr/lib/gcc/x86_64-linux-gnu/7
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-C-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-C-XL-12.1.0.output
new file mode 100644
index 000000000..de407f2f0
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-C-XL-12.1.0.output
@@ -0,0 +1,2 @@
+libs=xlopt;xl;dl;gcc_s;gcc;m;c;gcc_s;gcc
+dirs=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64;/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64;/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64;/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64;/usr/lib/gcc/ppc64-redhat-linux/4.4.7;/usr/lib64;/lib64;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-PGI-18.10.1.output
new file mode 100644
index 000000000..db0b29c90
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-PGI-18.10.1.output
@@ -0,0 +1,2 @@
+libs=atomic;pgatm;stdc++;pgmp;numa;pthread;pgmath;nspgc;pgc;m;gcc;c;gcc;gcc_s
+dirs=/mnt/pgi/linux86-64/18.10/lib;/usr/lib64;/usr/lib/gcc/x86_64-linux-gnu/7
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-XL-12.1.0.output
new file mode 100644
index 000000000..4466415b3
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-CXX-XL-12.1.0.output
@@ -0,0 +1,2 @@
+libs=xlopt;xl;ibmc++;xlopt;xl;stdc++;m;dl;gcc_s;gcc;m;c;gcc_s;gcc;dl;gcc_s;gcc;m;c;gcc_s;gcc
+dirs=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64;/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64;/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64;/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64;/usr/lib/gcc/ppc64-redhat-linux/4.4.7;/usr/lib64;/lib64;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-Fortran-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-Fortran-PGI-18.10.1.output
new file mode 100644
index 000000000..d40f81eb9
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc-Fortran-PGI-18.10.1.output
@@ -0,0 +1,2 @@
+libs=pgf90rtl;pgf90;pgf90_rpm1;pgf902;pgf90rtl;pgftnrtl;pgmp;numa;pthread;pgmath;nspgc;pgc;rt;pthread;m;gcc;c;gcc;gcc_s
+dirs=/mnt/pgi/linux86-64/18.10/lib;/usr/lib64;/usr/lib/gcc/x86_64-linux-gnu/7
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc_i-C-XL-12.1.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc_i-C-XL-12.1.0.output
new file mode 100644
index 000000000..de407f2f0
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_nostdinc_i-C-XL-12.1.0.output
@@ -0,0 +1,2 @@
+libs=xlopt;xl;dl;gcc_s;gcc;m;c;gcc_s;gcc
+dirs=/soft/compilers/ibmcmp-oct2017/xlsmp/bg/3.1/lib64;/soft/compilers/ibmcmp-oct2017/xlmass/bg/7.3/lib64;/soft/compilers/ibmcmp-oct2017/vac/bg/12.1/lib64;/soft/compilers/ibmcmp-oct2017/vacpp/bg/12.1/lib64;/usr/lib/gcc/ppc64-redhat-linux/4.4.7;/usr/lib64;/lib64;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_pgf77-Fortran-PGI-18.10.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_pgf77-Fortran-PGI-18.10.1.output
new file mode 100644
index 000000000..7b523ea9d
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/linux_pgf77-Fortran-PGI-18.10.1.output
@@ -0,0 +1,2 @@
+libs=pgftnrtl;pgmp;numa;pthread;pgmath;nspgc;pgc;rt;pthread;m;gcc;c;gcc;gcc_s
+dirs=/mnt/pgi/linux86-64/18.10/lib;/usr/lib64;/usr/lib/gcc/x86_64-linux-gnu/7
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/mingw.org-C-GNU-4.9.3.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/mingw.org-C-GNU-4.9.3.output
new file mode 100644
index 000000000..8aee7cf44
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/mingw.org-C-GNU-4.9.3.output
@@ -0,0 +1,2 @@
+libs=mingw32;gcc;moldname;mingwex;advapi32;shell32;user32;kernel32;mingw32;gcc;moldname;mingwex
+dirs=C:/DoesNotExist/mingw/lib/gcc/mingw32/4.9.3;C:/DoesNotExist/mingw/lib/gcc;C:/DoesNotExist/mingw/mingw32/lib;C:/DoesNotExist/mingw/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/mingw.org-CXX-GNU-4.9.3.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/mingw.org-CXX-GNU-4.9.3.output
new file mode 100644
index 000000000..5e79cc1ad
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/mingw.org-CXX-GNU-4.9.3.output
@@ -0,0 +1,2 @@
+libs=stdc++;mingw32;gcc_s;gcc;moldname;mingwex;advapi32;shell32;user32;kernel32;mingw32;gcc_s;gcc;moldname;mingwex
+dirs=C:/DoesNotExist/mingw/lib/gcc/mingw32/4.9.3;C:/DoesNotExist/mingw/lib/gcc;C:/DoesNotExist/mingw/mingw32/lib;C:/DoesNotExist/mingw/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd-C-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd-C-GNU-4.8.5.output
new file mode 100644
index 000000000..4a09c5b13
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd-C-GNU-4.8.5.output
@@ -0,0 +1,2 @@
+libs=gcc;gcc_s;c;gcc;gcc_s
+dirs=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd-CXX-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd-CXX-GNU-4.8.5.output
new file mode 100644
index 000000000..d747e5b87
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd-CXX-GNU-4.8.5.output
@@ -0,0 +1,2 @@
+libs=stdc++;m;gcc_s;gcc;c;gcc_s;gcc
+dirs=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd_nostdinc-C-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd_nostdinc-C-GNU-4.8.5.output
new file mode 100644
index 000000000..4a09c5b13
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd_nostdinc-C-GNU-4.8.5.output
@@ -0,0 +1,2 @@
+libs=gcc;gcc_s;c;gcc;gcc_s
+dirs=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd_nostdinc-CXX-GNU-4.8.5.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd_nostdinc-CXX-GNU-4.8.5.output
new file mode 100644
index 000000000..d747e5b87
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/netbsd_nostdinc-CXX-GNU-4.8.5.output
@@ -0,0 +1,2 @@
+libs=stdc++;m;gcc_s;gcc;c;gcc_s;gcc
+dirs=
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/openbsd-C-Clang-5.0.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/openbsd-C-Clang-5.0.1.output
new file mode 100644
index 000000000..5bb5db4d7
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/openbsd-C-Clang-5.0.1.output
@@ -0,0 +1,2 @@
+libs=compiler_rt;c;compiler_rt
+dirs=/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/openbsd-CXX-Clang-5.0.1.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/openbsd-CXX-Clang-5.0.1.output
new file mode 100644
index 000000000..4158973ca
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/openbsd-CXX-Clang-5.0.1.output
@@ -0,0 +1,2 @@
+libs=c++;c++abi;pthread;m;compiler_rt;c;compiler_rt
+dirs=/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/sunos-C-SunPro-5.13.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/sunos-C-SunPro-5.13.0.output
new file mode 100644
index 000000000..0d636e60e
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/sunos-C-SunPro-5.13.0.output
@@ -0,0 +1,2 @@
+libs=c
+dirs=/opt/solarisstudio12.4/lib/compilers/staticlib;/opt/solarisstudio12.4/lib/compilers/sparc;/opt/solarisstudio12.4/lib/compilers;/usr/ccs/lib;/lib;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/sunos-CXX-SunPro-5.13.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/sunos-CXX-SunPro-5.13.0.output
new file mode 100644
index 000000000..f7c821356
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/sunos-CXX-SunPro-5.13.0.output
@@ -0,0 +1,2 @@
+libs=Cstd;Crun;m;c
+dirs=/opt/solarisstudio12.4/lib/compilers/sparc;/opt/solarisstudio12.4/lib/compilers;/opt/solarisstudio12.4/lib/sparc;/opt/solarisstudio12.4/lib;/usr/ccs/lib;/lib;/usr/lib
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/results/sunos-Fortran-SunPro-8.8.0.output b/Tests/RunCMake/ParseImplicitLinkInfo/results/sunos-Fortran-SunPro-8.8.0.output
new file mode 100644
index 000000000..b49557a91
--- /dev/null
+++ b/Tests/RunCMake/ParseImplicitLinkInfo/results/sunos-Fortran-SunPro-8.8.0.output
@@ -0,0 +1,2 @@
+libs=fsu;sunmath;mtsk;m;c
+dirs=/opt/developerstudio12.6/lib/compilers/sparcvis2;/opt/developerstudio12.6/lib/compilers;/opt/developerstudio12.6/lib;/usr/ccs/lib;/lib;/usr/lib
diff --git a/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt b/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt
index 16bcb3689..66ff016f9 100644
--- a/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt
+++ b/Tests/RunCMake/PolicyScope/dir1/CMakeLists.txt
@@ -2,4 +2,4 @@
add_library(foo STATIC foo.cpp)
string(TOLOWER ${CMAKE_CXX_COMPILER_ID} compiler_id)
-target_compile_definitions(foo PRIVATE Foo=$<CXX_COMPILER_ID:${compiler_id}>)
+target_compile_definitions(foo PRIVATE Foo=$<CXX_COMPILER_ID:invalid,${compiler_id}>)
diff --git a/Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_new-check.cmake b/Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_new-check.cmake
new file mode 100644
index 000000000..255e63de4
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_new-check.cmake
@@ -0,0 +1,22 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/${RunCMake_TEST_CONFIG}/CMP0083_config.cmake")
+
+
+# retrieve default type of executable
+check_executable ("${cmp0083_ref}" ref)
+
+if (ref STREQUAL "PIE")
+ # check no_pie executable is really no position independent
+ check_executable ("${cmp0083_new_no_pie}" new_no_pie)
+ if (NOT new_no_pie STREQUAL "NO_PIE")
+ set (RunCMake_TEST_FAILED "CMP0083(NEW) do not produce expected executable.")
+ endif()
+elseif (ref STREQUAL "NO_PIE")
+ # check pie executable is really position independent
+ check_executable ("${cmp0083_new_pie}" new_pie)
+ if (NOT new_pie MATCHES "PIE")
+ set (RunCMake_TEST_FAILED "CMP0083(NEW) do not produce expected executable.")
+ endif()
+else()
+ set (RunCMake_TEST_FAILED "CMP0083(NEW) unexpected result.")
+endif()
diff --git a/Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_old-check.cmake b/Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_old-check.cmake
new file mode 100644
index 000000000..b66b67286
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/CMP0083-cmp0083_old-check.cmake
@@ -0,0 +1,20 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/${RunCMake_TEST_CONFIG}/CMP0083_config.cmake")
+
+
+# retrieve default type of executable
+check_executable ("${cmp0083_ref}" ref)
+
+# POSITION_INDEPENDENT_CODE must not have influence on executable
+# pie and no_pie executable must have same type as reference
+check_executable ("${cmp0083_old_pie}" old_pie)
+if (NOT old_pie STREQUAL ref)
+ set (RunCMake_TEST_FAILED "CMP0083(OLD) do not produce expected executable.")
+ return()
+endif()
+
+check_executable ("${cmp0083_old_no_pie}" old_no_pie)
+if (NOT old_no_pie STREQUAL ref)
+ set (RunCMake_TEST_FAILED "CMP0083(OLD) do not produce expected executable.")
+ return()
+endif()
diff --git a/Tests/RunCMake/PositionIndependentCode/CMP0083.cmake b/Tests/RunCMake/PositionIndependentCode/CMP0083.cmake
new file mode 100644
index 000000000..749ac793e
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/CMP0083.cmake
@@ -0,0 +1,47 @@
+
+# create reference to detect default : PIE or not
+add_executable (cmp0083_ref main.cpp)
+
+
+set (CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+cmake_policy(SET CMP0083 NEW)
+include(CheckPIESupported)
+check_pie_supported()
+add_executable (cmp0083_new_pie main.cpp)
+
+
+cmake_policy(SET CMP0083 OLD)
+add_executable (cmp0083_old_pie main.cpp)
+
+
+set (CMAKE_POSITION_INDEPENDENT_CODE OFF)
+
+cmake_policy(SET CMP0083 NEW)
+add_executable (cmp0083_new_no_pie main.cpp)
+
+
+cmake_policy(SET CMP0083 OLD)
+add_executable (cmp0083_old_no_pie main.cpp)
+
+# high-level targets
+add_custom_target(cmp0083_new)
+add_dependencies(cmp0083_new cmp0083_ref cmp0083_new_pie cmp0083_new_no_pie)
+
+# high-level targets
+add_custom_target(cmp0083_old)
+add_dependencies(cmp0083_old cmp0083_ref cmp0083_old_pie cmp0083_old_no_pie)
+
+
+# generate file holding paths to executables
+file (GENERATE OUTPUT "${CMAKE_BINARY_DIR}/$<CONFIG>/CMP0083_config.cmake"
+ CONTENT
+[==[
+include ("${RunCMake_TEST_SOURCE_DIR}/PIE_validator.cmake")
+
+set (cmp0083_ref "$<TARGET_FILE:cmp0083_ref>")
+set (cmp0083_new_pie "$<TARGET_FILE:cmp0083_new_pie>")
+set (cmp0083_old_pie "$<TARGET_FILE:cmp0083_old_pie>")
+set (cmp0083_new_no_pie "$<TARGET_FILE:cmp0083_new_no_pie>")
+set (cmp0083_old_no_pie "$<TARGET_FILE:cmp0083_old_no_pie>")
+]==])
diff --git a/Tests/RunCMake/PositionIndependentCode/CheckPIESupported.cmake b/Tests/RunCMake/PositionIndependentCode/CheckPIESupported.cmake
new file mode 100644
index 000000000..61e1b6d3e
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/CheckPIESupported.cmake
@@ -0,0 +1,18 @@
+
+cmake_policy(SET CMP0083 NEW)
+
+include (CheckPIESupported)
+
+check_pie_supported()
+
+if (CMAKE_CXX_LINK_PIE_SUPPORTED)
+ file(WRITE "${PIE_SUPPORTED}" "\nset(PIE_SUPPORTED TRUE)\n")
+else()
+ file(WRITE "${PIE_SUPPORTED}" "\nset(PIE_SUPPORTED FALSE)\n")
+endif()
+
+if (CMAKE_CXX_LINK_NO_PIE_SUPPORTED)
+ file(APPEND "${PIE_SUPPORTED}" "\nset(NO_PIE_SUPPORTED TRUE)\n")
+else()
+ file(APPEND "${PIE_SUPPORTED}" "\nset(NO_PIE_SUPPORTED FALSE)\n")
+endif()
diff --git a/Tests/RunCMake/PositionIndependentCode/Genex1-result.txt b/Tests/RunCMake/PositionIndependentCode/Genex1-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/Genex1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/PositionIndependentCode/Genex1-stderr.txt b/Tests/RunCMake/PositionIndependentCode/Genex1-stderr.txt
new file mode 100644
index 000000000..c242a05cb
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/Genex1-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error: Property POSITION_INDEPENDENT_CODE on target "conflict1" does
+not match the INTERFACE_POSITION_INDEPENDENT_CODE property requirement
+of dependency "genex_pic".
diff --git a/Tests/RunCMake/PositionIndependentCode/Genex1.cmake b/Tests/RunCMake/PositionIndependentCode/Genex1.cmake
new file mode 100644
index 000000000..a91be3eec
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/Genex1.cmake
@@ -0,0 +1,9 @@
+
+add_library(genex_pic UNKNOWN IMPORTED)
+# PIC is ON if sibling target is a library, OFF if it is an executable
+set_property(TARGET genex_pic PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE $<NOT:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>>)
+
+
+add_library(conflict1 STATIC main.cpp)
+set_property(TARGET conflict1 PROPERTY POSITION_INDEPENDENT_CODE OFF)
+target_link_libraries(conflict1 PRIVATE genex_pic)
diff --git a/Tests/RunCMake/PositionIndependentCode/Genex2-result.txt b/Tests/RunCMake/PositionIndependentCode/Genex2-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/Genex2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/PositionIndependentCode/Genex2-stderr.txt b/Tests/RunCMake/PositionIndependentCode/Genex2-stderr.txt
new file mode 100644
index 000000000..735a926ed
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/Genex2-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error: Property POSITION_INDEPENDENT_CODE on target "conflict2" does
+not match the INTERFACE_POSITION_INDEPENDENT_CODE property requirement
+of dependency "genex_pic".
diff --git a/Tests/RunCMake/PositionIndependentCode/Genex2.cmake b/Tests/RunCMake/PositionIndependentCode/Genex2.cmake
new file mode 100644
index 000000000..fb0a5dbda
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/Genex2.cmake
@@ -0,0 +1,9 @@
+
+add_library(genex_pic UNKNOWN IMPORTED)
+# PIC is ON if sibling target is a library, OFF if it is an executable
+set_property(TARGET genex_pic PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE $<NOT:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>>)
+
+
+add_executable(conflict2 main.cpp)
+set_property(TARGET conflict2 PROPERTY POSITION_INDEPENDENT_CODE ON)
+target_link_libraries(conflict2 PRIVATE genex_pic)
diff --git a/Tests/RunCMake/PositionIndependentCode/PIE-pie_off-check.cmake b/Tests/RunCMake/PositionIndependentCode/PIE-pie_off-check.cmake
new file mode 100644
index 000000000..096395c08
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/PIE-pie_off-check.cmake
@@ -0,0 +1,7 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/${RunCMake_TEST_CONFIG}/PIE_config.cmake")
+
+check_executable ("${pie_off}" status)
+if (NOT status STREQUAL "NO_PIE")
+ set (RunCMake_TEST_FAILED "Executable is NOT 'no PIE' (${status}).")
+endif()
diff --git a/Tests/RunCMake/PositionIndependentCode/PIE-pie_on-check.cmake b/Tests/RunCMake/PositionIndependentCode/PIE-pie_on-check.cmake
new file mode 100644
index 000000000..bf3d0186d
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/PIE-pie_on-check.cmake
@@ -0,0 +1,7 @@
+
+include ("${RunCMake_TEST_BINARY_DIR}/${RunCMake_TEST_CONFIG}/PIE_config.cmake")
+
+check_executable ("${pie_on}" status)
+if (NOT status STREQUAL "PIE")
+ set (RunCMake_TEST_FAILED "Executable is NOT 'PIE' (${status}).")
+endif()
diff --git a/Tests/RunCMake/PositionIndependentCode/PIE.cmake b/Tests/RunCMake/PositionIndependentCode/PIE.cmake
new file mode 100644
index 000000000..16ed89ce6
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/PIE.cmake
@@ -0,0 +1,22 @@
+
+cmake_policy(SET CMP0083 NEW)
+
+include(CheckPIESupported)
+check_pie_supported()
+
+add_executable (pie_on main.cpp)
+set_property(TARGET pie_on PROPERTY POSITION_INDEPENDENT_CODE ON)
+
+add_executable (pie_off main.cpp)
+set_property(TARGET pie_off PROPERTY POSITION_INDEPENDENT_CODE OFF)
+
+
+# generate file holding paths to executables
+file (GENERATE OUTPUT "${CMAKE_BINARY_DIR}/$<CONFIG>/PIE_config.cmake"
+ CONTENT
+[==[
+include ("${RunCMake_TEST_SOURCE_DIR}/PIE_validator.cmake")
+
+set (pie_on "$<TARGET_FILE:pie_on>")
+set (pie_off "$<TARGET_FILE:pie_off>")
+]==])
diff --git a/Tests/RunCMake/PositionIndependentCode/PIE_validator.cmake b/Tests/RunCMake/PositionIndependentCode/PIE_validator.cmake
new file mode 100644
index 000000000..7be35db6a
--- /dev/null
+++ b/Tests/RunCMake/PositionIndependentCode/PIE_validator.cmake
@@ -0,0 +1,32 @@
+
+include_guard(GLOBAL)
+
+function (CHECK_EXECUTABLE executable result)
+ set (${result} "UNKNOWN" PARENT_SCOPE)
+
+ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ set (tool otool -hv)
+ else()
+ set (tool "${CMAKE_COMMAND}" -E env LANG=C LC_ALL=C readelf -lW)
+ endif()
+
+ execute_process(COMMAND ${tool} "${executable}"
+ OUTPUT_VARIABLE output
+ ERROR_VARIABLE output)
+
+ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ if (output MATCHES "( |\t)PIE( |\n|$)")
+ set (${result} "PIE" PARENT_SCOPE)
+ else()
+ set (${result} "NO_PIE" PARENT_SCOPE)
+ endif()
+ else()
+ if (output MATCHES "Elf file type is DYN")
+ set (${result} "PIE" PARENT_SCOPE)
+ elseif (output MATCHES "Elf file type is EXEC")
+ set (${result} "NO_PIE" PARENT_SCOPE)
+ else()
+ message(SEND_ERROR "Did not find a known file type")
+ endif()
+ endif()
+endfunction()
diff --git a/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake b/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake
index 6a67e3cad..6efa0d402 100644
--- a/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake
+++ b/Tests/RunCMake/PositionIndependentCode/RunCMakeTest.cmake
@@ -7,3 +7,67 @@ run_cmake(Conflict4)
run_cmake(Conflict5)
run_cmake(Conflict6)
run_cmake(Debug)
+run_cmake(Genex1)
+run_cmake(Genex2)
+
+set(RunCMake_TEST_OPTIONS "-DPIE_SUPPORTED=${RunCMake_BINARY_DIR}/PIESupported.cmake")
+run_cmake(CheckPIESupported)
+include ("${RunCMake_BINARY_DIR}/PIESupported.cmake" OPTIONAL)
+
+if (PIE_SUPPORTED OR NO_PIE_SUPPORTED)
+ if (CMAKE_SYSTEM_NAME MATCHES "^(Linux|(Free|Net|Open)BSD)$")
+ # try to locate readelf needed for validation
+ find_program (READELF NAMES readelf)
+ endif()
+ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ # try to locate otool needed for validation
+ find_program (OTOOL NAMES otool)
+ endif()
+
+ if ((READELF OR OTOOL) AND
+ (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
+ OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
+ OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
+ macro(run_cmake_target test subtest)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_CONFIG Release)
+ run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --config Release --target ${subtest} ${ARGN})
+
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+ endmacro()
+
+ set(RunCMake_TEST_SOURCE_DIR "${RunCMake_SOURCE_DIR}")
+ set(RunCMake_TEST_OUTPUT_MERGE TRUE)
+ if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release)
+ endif()
+
+ run_cmake(PIE)
+ if (PIE_SUPPORTED)
+ run_cmake_target(PIE pie_on)
+ endif()
+ if (NO_PIE_SUPPORTED)
+ run_cmake_target(PIE pie_off)
+ endif()
+
+ run_cmake(CMP0083)
+ run_cmake_target(CMP0083 cmp0083_ref)
+
+ # retrieve default mode
+ include("${RunCMake_SOURCE_DIR}/PIE_validator.cmake")
+ include("${RunCMake_BINARY_DIR}/CMP0083-build/Release/CMP0083_config.cmake")
+ check_executable("${cmp0083_ref}" cmp0083_ref_mode)
+
+ if ((cmp0083_ref_mode STREQUAL "PIE" AND NO_PIE_SUPPORTED)
+ OR (cmp0083_ref_mode STREQUAL "NO_PIE" AND PIE_SUPPORTED))
+ run_cmake_target(CMP0083 cmp0083_new)
+ endif()
+ run_cmake_target(CMP0083 cmp0083_old)
+
+ unset(RunCMake_TEST_SOURCE_DIR)
+ unset(RunCMake_TEST_OPTIONS)
+ unset(RunCMake_TEST_OUTPUT_MERGE)
+ endif()
+endif()
diff --git a/Tests/RunCMake/PrecompileHeaders/CMakeLists.txt b/Tests/RunCMake/PrecompileHeaders/CMakeLists.txt
new file mode 100644
index 000000000..7dbf32e86
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.15.0)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake b/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake
new file mode 100644
index 000000000..494bcf726
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/DisabledPch-check.cmake
@@ -0,0 +1,12 @@
+set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/cmake_pch.h")
+set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h")
+
+if (NOT EXISTS ${foo_pch_header})
+ set(RunCMake_TEST_FAILED "Generated foo pch header ${foo_pch_header} does not exist")
+ return()
+endif()
+
+if (EXISTS ${foobar_pch_header})
+ set(RunCMake_TEST_FAILED "Generated foobar pch header ${foobar_pch_header} should not exist")
+ return()
+endif()
diff --git a/Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake b/Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake
new file mode 100644
index 000000000..59ee14b9f
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/DisabledPch.cmake
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.15)
+project(DisabledPch C)
+
+add_library(foo foo.c)
+target_include_directories(foo PUBLIC include)
+target_precompile_headers(foo PUBLIC
+ include/foo.h
+ <stdio.h>
+ \"string.h\"
+)
+
+add_executable(foobar foobar.c)
+target_link_libraries(foobar foo)
+set_target_properties(foobar PROPERTIES DISABLE_PRECOMPILE_HEADERS ON)
diff --git a/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake
new file mode 100644
index 000000000..4e62b81c0
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchInterface-check.cmake
@@ -0,0 +1,26 @@
+set(foo_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foo.dir/cmake_pch.h")
+set(foobar_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h")
+
+if (NOT EXISTS ${foo_pch_header})
+ set(RunCMake_TEST_FAILED "Generated foo pch header ${foo_pch_header} does not exist")
+ return()
+endif()
+
+if (NOT EXISTS ${foobar_pch_header})
+ set(RunCMake_TEST_FAILED "Generated foobar pch header ${foobar_pch_header} does not exist")
+ return()
+endif()
+
+file(STRINGS ${foo_pch_header} foo_pch_header_strings)
+
+if (NOT foo_pch_header_strings MATCHES ";#include \"[^\"]*PrecompileHeaders/include/foo.h\";#include \"foo2.h\";#include <stdio.h>;#include \"string.h\"(;|$)")
+ set(RunCMake_TEST_FAILED "Generated foo pch header\n ${foo_pch_header}\nhas bad content:\n ${foo_pch_header_strings}")
+ return()
+endif()
+
+file(STRINGS ${foobar_pch_header} foobar_pch_header_strings)
+
+if (NOT foobar_pch_header_strings MATCHES ";#include \"[^\"]*PrecompileHeaders/include/foo.h\";#include \"foo2.h\";#include <stdio.h>;#include \"string.h\";#include \"[^\"]*PrecompileHeaders/include/bar.h\"(;|$)")
+ set(RunCMake_TEST_FAILED "Generated foobar pch header\n ${foobar_pch_header}\nhas bad content:\n ${foobar_pch_header_strings}")
+ return()
+endif()
diff --git a/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake b/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake
new file mode 100644
index 000000000..a1e079273
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchInterface.cmake
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 3.15)
+project(PchInterface C)
+
+add_library(foo foo.c)
+target_include_directories(foo PUBLIC include)
+target_precompile_headers(foo PUBLIC
+ include/foo.h
+ \"foo2.h\"
+ <stdio.h>
+ \"string.h\"
+)
+
+add_library(bar INTERFACE)
+target_include_directories(bar INTERFACE include)
+target_precompile_headers(bar INTERFACE include/bar.h)
+
+add_executable(foobar foobar.c)
+target_link_libraries(foobar foo bar)
+
+enable_testing()
+add_test(NAME foobar COMMAND foobar)
diff --git a/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake
new file mode 100644
index 000000000..cc01ecb0d
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage-check.cmake
@@ -0,0 +1,26 @@
+set(foobar_pch_h_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.h")
+set(foobar_pch_hxx_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/foobar.dir/cmake_pch.hxx")
+
+if (NOT EXISTS ${foobar_pch_h_header})
+ set(RunCMake_TEST_FAILED "Generated foobar C pch header ${foobar_pch_h_header} does not exist")
+ return()
+endif()
+
+if (NOT EXISTS ${foobar_pch_hxx_header})
+ set(RunCMake_TEST_FAILED "Generated foobar C++ pch header ${foobar_pch_hxx_header} does not exist")
+ return()
+endif()
+
+file(STRINGS ${foobar_pch_h_header} foobar_pch_h_header_strings)
+
+if (NOT foobar_pch_h_header_strings MATCHES ";#include <stddef.h>(;|$)")
+ set(RunCMake_TEST_FAILED "Generated foo pch header\n ${foobar_pch_h_header}\nhas bad content:\n ${foobar_pch_h_header_strings}")
+ return()
+endif()
+
+file(STRINGS ${foobar_pch_hxx_header} foobar_pch_hxx_header_strings)
+
+if (NOT foobar_pch_hxx_header_strings MATCHES ";#include <cstddef>(;|$)")
+ set(RunCMake_TEST_FAILED "Generated foo pch header\n ${foobar_pch_hxx_header}\nhas bad content:\n ${foobar_pch_hxx_header_strings}")
+ return()
+endif()
diff --git a/Tests/RunCMake/PrecompileHeaders/PchMultilanguage.cmake b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage.cmake
new file mode 100644
index 000000000..cdc42b2a2
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchMultilanguage.cmake
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 3.15)
+project(PchMultilanguage C CXX)
+
+add_executable(foobar
+ foo.c
+ main.cpp
+)
+target_include_directories(foobar PUBLIC include)
+target_precompile_headers(foobar PRIVATE
+ "$<$<COMPILE_LANGUAGE:C>:<stddef.h$<ANGLE-R>>"
+ "$<$<COMPILE_LANGUAGE:CXX>:<cstddef$<ANGLE-R>>"
+ )
diff --git a/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake b/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake
new file mode 100644
index 000000000..9018664b2
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue-check.cmake
@@ -0,0 +1,8 @@
+set(main_pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/main.dir/cmake_pch.hxx")
+
+file(STRINGS ${main_pch_header} main_pch_header_strings)
+string(REGEX MATCH "#pragma warning\\(push, 0\\).*#include.*pch.h.*#pragma warning\\(pop\\)" matched_code ${main_pch_header_strings})
+if(NOT matched_code)
+ set(RunCMake_TEST_FAILED "Generated pch file doesn't include expected prologue and epilogue code")
+ return()
+endif()
diff --git a/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue.cmake b/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue.cmake
new file mode 100644
index 000000000..3e27620f9
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchPrologueEpilogue.cmake
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.15)
+
+project(PchPrologueEpilogue)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_PCH_PROLOGUE "#pragma warning(push, 0)")
+set(CMAKE_PCH_EPILOGUE "#pragma warning(pop)")
+
+add_executable(main main.cpp)
+target_precompile_headers(main PRIVATE pch.h)
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake
new file mode 100644
index 000000000..03a97eda4
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake
@@ -0,0 +1,27 @@
+cmake_minimum_required(VERSION 3.15)
+project(PchReuseFrom C)
+
+if(CMAKE_C_COMPILE_OPTIONS_USE_PCH)
+ add_definitions(-DHAVE_PCH_SUPPORT)
+endif()
+
+add_library(empty empty.c)
+target_precompile_headers(empty PRIVATE
+ <stdio.h>
+ <string.h>
+)
+target_include_directories(empty PUBLIC include)
+
+add_library(foo foo.c)
+target_include_directories(foo PUBLIC include)
+target_precompile_headers(foo REUSE_FROM empty)
+
+# should not cause problems if configured multiple times
+target_precompile_headers(foo REUSE_FROM empty)
+
+add_executable(foobar foobar.c)
+target_link_libraries(foobar foo )
+set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM foo)
+
+enable_testing()
+add_test(NAME foobar COMMAND foobar)
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed-build-stderr.txt b/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed-build-stderr.txt
new file mode 100644
index 000000000..8cdcfd941
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed-build-stderr.txt
@@ -0,0 +1,2 @@
+^(|Warning #670: precompiled header file [^
+]* was not generated in this directory)$
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed.cmake
new file mode 100644
index 000000000..e306d8e9c
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromPrefixed.cmake
@@ -0,0 +1,29 @@
+cmake_minimum_required(VERSION 3.15)
+project(PchReuseFromPrefixed C)
+
+if(CMAKE_C_COMPILE_OPTIONS_USE_PCH)
+ add_definitions(-DHAVE_PCH_SUPPORT)
+endif()
+
+add_library(empty empty.c)
+target_precompile_headers(empty PRIVATE
+ <stdio.h>
+ <string.h>
+)
+target_include_directories(empty PUBLIC include)
+
+add_library(foo foo.c)
+target_include_directories(foo PUBLIC include)
+target_precompile_headers(foo REUSE_FROM empty)
+
+# Visual Studio 2017 and greater
+if (NOT (CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_LESS_EQUAL 19.10))
+ set_target_properties(foo PROPERTIES PREFIX "lib" IMPORT_PREFIX "lib")
+endif()
+
+add_executable(foobar foobar.c)
+target_link_libraries(foobar foo )
+set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM empty)
+
+enable_testing()
+add_test(NAME foobar COMMAND foobar)
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt
new file mode 100644
index 000000000..8cdcfd941
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt
@@ -0,0 +1,2 @@
+^(|Warning #670: precompiled header file [^
+]* was not generated in this directory)$
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake
new file mode 100644
index 000000000..fff74dcd6
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.15)
+project(PchReuseFromSubdir C)
+
+add_library(empty empty.c)
+target_precompile_headers(empty PUBLIC
+ <stdio.h>
+ <string.h>
+)
+target_include_directories(empty PUBLIC include)
+
+add_library(foo foo.c)
+target_include_directories(foo PUBLIC include)
+target_precompile_headers(foo REUSE_FROM empty)
+
+subdirs(subdir)
+
+enable_testing()
+add_test(NAME foobar COMMAND foobar)
diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
new file mode 100644
index 000000000..8d2f4f964
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
@@ -0,0 +1,22 @@
+cmake_policy(SET CMP0057 NEW)
+include(RunCMake)
+
+function(run_test name)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build)
+ run_cmake(${name})
+ # Precompiled headers are not supported with multiple architectures.
+ if(NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${name}-build ${CMAKE_COMMAND} --build . --config Debug)
+ run_cmake_command(${name}-test ${CMAKE_CTEST_COMMAND} -C Debug)
+ endif()
+endfunction()
+
+run_cmake(DisabledPch)
+run_test(PchInterface)
+run_cmake(PchPrologueEpilogue)
+run_test(SkipPrecompileHeaders)
+run_test(PchReuseFrom)
+run_test(PchReuseFromPrefixed)
+run_test(PchReuseFromSubdir)
+run_cmake(PchMultilanguage)
diff --git a/Tests/RunCMake/PrecompileHeaders/SkipPrecompileHeaders.cmake b/Tests/RunCMake/PrecompileHeaders/SkipPrecompileHeaders.cmake
new file mode 100644
index 000000000..49efbfbab
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/SkipPrecompileHeaders.cmake
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.15)
+
+project(SkipPrecompileHeaders)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+add_executable(pch-test main.cpp non-pch.cpp)
+target_precompile_headers(pch-test PRIVATE pch.h)
+
+set_source_files_properties(non-pch.cpp PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
+
+enable_testing()
+add_test(NAME pch-test COMMAND pch-test)
diff --git a/Tests/RunCMake/PrecompileHeaders/empty.c b/Tests/RunCMake/PrecompileHeaders/empty.c
new file mode 100644
index 000000000..30ae1c4ef
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/empty.c
@@ -0,0 +1,3 @@
+void nothing()
+{
+}
diff --git a/Tests/RunCMake/PrecompileHeaders/foo.c b/Tests/RunCMake/PrecompileHeaders/foo.c
new file mode 100644
index 000000000..eb88726f0
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/foo.c
@@ -0,0 +1,13 @@
+#include "foo.h"
+
+#include "foo2.h"
+
+int foo()
+{
+ return 0;
+}
+
+int foo2()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/PrecompileHeaders/foobar.c b/Tests/RunCMake/PrecompileHeaders/foobar.c
new file mode 100644
index 000000000..97d465c01
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/foobar.c
@@ -0,0 +1,14 @@
+#include "bar.h"
+#include "foo.h"
+#include "foo2.h"
+
+int main()
+{
+ int zeroSize = 0;
+
+#ifdef HAVE_PCH_SUPPORT
+ zeroSize = (int)strlen("");
+#endif
+
+ return foo() + foo2() + bar() + zeroSize;
+}
diff --git a/Tests/RunCMake/PrecompileHeaders/include/bar.h b/Tests/RunCMake/PrecompileHeaders/include/bar.h
new file mode 100644
index 000000000..5feb98361
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/include/bar.h
@@ -0,0 +1,9 @@
+#ifndef bar_h
+#define bar_h
+
+static int bar()
+{
+ return 0;
+}
+
+#endif
diff --git a/Tests/RunCMake/PrecompileHeaders/include/foo.h b/Tests/RunCMake/PrecompileHeaders/include/foo.h
new file mode 100644
index 000000000..fc0ae143a
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/include/foo.h
@@ -0,0 +1,6 @@
+#ifndef foo_h
+#define foo_h
+
+int foo(void);
+
+#endif
diff --git a/Tests/RunCMake/PrecompileHeaders/include/foo2.h b/Tests/RunCMake/PrecompileHeaders/include/foo2.h
new file mode 100644
index 000000000..4bf9c8167
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/include/foo2.h
@@ -0,0 +1,6 @@
+#ifndef foo2_h
+#define foo2_h
+
+int foo2(void);
+
+#endif
diff --git a/Tests/RunCMake/PrecompileHeaders/main.cpp b/Tests/RunCMake/PrecompileHeaders/main.cpp
new file mode 100644
index 000000000..f8b643afb
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/main.cpp
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/PrecompileHeaders/non-pch.cpp b/Tests/RunCMake/PrecompileHeaders/non-pch.cpp
new file mode 100644
index 000000000..df5a79f12
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/non-pch.cpp
@@ -0,0 +1,3 @@
+#ifdef PCH_INCLUDED
+# error "PCH must not be included into this file!"
+#endif
diff --git a/Tests/RunCMake/PrecompileHeaders/pch.h b/Tests/RunCMake/PrecompileHeaders/pch.h
new file mode 100644
index 000000000..81b6d9eed
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/pch.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#define PCH_INCLUDED 1
diff --git a/Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt b/Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt
new file mode 100644
index 000000000..fa926c4e4
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_executable(foobar ../foobar.c)
+target_link_libraries(foobar foo )
+set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM foo)
diff --git a/Tests/RunCMake/README.rst b/Tests/RunCMake/README.rst
index 4aae4aed5..ebe40cf48 100644
--- a/Tests/RunCMake/README.rst
+++ b/Tests/RunCMake/README.rst
@@ -47,14 +47,20 @@ but do not actually build anything. To add a test:
containing expected test results:
``<SubTest>-result.txt``
- Process result expected if not "0"
+ Regex matching expected process result, if not ``0``
``<SubTest>-stdout.txt``
Regex matching expected stdout content
``<SubTest>-stderr.txt``
- Regex matching expected stderr content, if not "^$"
+ Regex matching expected stderr content, if not ``^$``
``<SubTest>-check.cmake``
Custom result check.
+ Note that when a specific platform expects differing stdout or stderr that
+ can be done by adding a platform specific output file. These follow the
+ naming convention of:
+ ``<SubTest>-stdout-<platform_lower_case>.txt``
+ ``<SubTest>-stderr-<platform_lower_case>.txt``
+
Note that trailing newlines will be stripped from actual and expected
test output before matching against the stdout and stderr expressions.
The code in ``<SubTest>-check.cmake`` may use variables
@@ -65,3 +71,14 @@ but do not actually build anything. To add a test:
Top of test binary tree
and an failure must store a message in ``RunCMake_TEST_FAILED``.
+
+To speed up local testing, you can choose to run only a subset of
+``run_cmake()`` tests in a ``RunCMakeTest.cmake`` script by using the
+``RunCMake_TEST_FILTER`` environment variable. If this variable is set,
+it is treated as a regular expression, and any tests whose names don't
+match the regular expression are not run. For example::
+
+ $ RunCMake_TEST_FILTER="^example" ctest -R '^RunCMake\.Example$'
+
+This will only run subtests in ``RunCMake.Example`` that start with
+``example``.
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index 26312c45c..da4d1e532 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/Tests/RunCMake/RunCMake.cmake
@@ -9,6 +9,10 @@ foreach(arg
endforeach()
function(run_cmake test)
+ if(DEFINED ENV{RunCMake_TEST_FILTER} AND NOT test MATCHES "$ENV{RunCMake_TEST_FILTER}")
+ return()
+ endif()
+
set(top_src "${RunCMake_SOURCE_DIR}")
set(top_bin "${RunCMake_BINARY_DIR}")
if(EXISTS ${top_src}/${test}-result.txt)
@@ -17,10 +21,20 @@ function(run_cmake test)
else()
set(expect_result 0)
endif()
+
+ string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} platform_name)
+ if(platform_name MATCHES cygwin)
+ #remove all additional bits from cygwin name
+ set(platform_name cygwin)
+ endif()
+
foreach(o out err)
if(RunCMake-std${o}-file AND EXISTS ${top_src}/${RunCMake-std${o}-file})
file(READ ${top_src}/${RunCMake-std${o}-file} expect_std${o})
string(REGEX REPLACE "\n+$" "" expect_std${o} "${expect_std${o}}")
+ elseif(EXISTS ${top_src}/${test}-std${o}-${platform_name}.txt)
+ file(READ ${top_src}/${test}-std${o}-${platform_name}.txt expect_std${o})
+ string(REGEX REPLACE "\n+$" "" expect_std${o} "${expect_std${o}}")
elseif(EXISTS ${top_src}/${test}-std${o}.txt)
file(READ ${top_src}/${test}-std${o}.txt expect_std${o})
string(REGEX REPLACE "\n+$" "" expect_std${o} "${expect_std${o}}")
@@ -45,15 +59,17 @@ function(run_cmake test)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
endif()
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ if(RunCMake-prep-file AND EXISTS ${top_src}/${RunCMake-prep-file})
+ include(${top_src}/${RunCMake-prep-file})
+ else()
+ include(${top_src}/${test}-prep.cmake OPTIONAL)
+ endif()
if(NOT DEFINED RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS "")
endif()
if(APPLE)
list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW)
endif()
- if(RunCMake_GENERATOR MATCHES "^Visual Studio 8 2005" AND NOT RunCMake_WARN_VS8)
- list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_WARN_VS8=OFF)
- endif()
if(RunCMake_MAKE_PROGRAM)
list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}")
endif()
@@ -68,22 +84,45 @@ function(run_cmake test)
else()
set(maybe_timeout "")
endif()
+ if(RunCMake-stdin-file AND EXISTS ${top_src}/${RunCMake-stdin-file})
+ set(maybe_input_file INPUT_FILE ${top_src}/${RunCMake-stdin-file})
+ elseif(EXISTS ${top_src}/${test}-stdin.txt)
+ set(maybe_input_file INPUT_FILE ${top_src}/${test}-stdin.txt)
+ else()
+ set(maybe_input_file "")
+ endif()
if(RunCMake_TEST_COMMAND)
+ if(NOT RunCMake_TEST_COMMAND_WORKING_DIRECTORY)
+ set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ endif()
execute_process(
COMMAND ${RunCMake_TEST_COMMAND}
- WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
+ WORKING_DIRECTORY "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}"
OUTPUT_VARIABLE actual_stdout
ERROR_VARIABLE ${actual_stderr_var}
RESULT_VARIABLE actual_result
ENCODING UTF8
${maybe_timeout}
+ ${maybe_input_file}
)
else()
+ if(RunCMake_GENERATOR_INSTANCE)
+ set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE=${RunCMake_GENERATOR_INSTANCE}")
+ else()
+ set(_D_CMAKE_GENERATOR_INSTANCE "")
+ endif()
+ if(NOT RunCMake_TEST_NO_SOURCE_DIR)
+ set(maybe_source_dir "${RunCMake_TEST_SOURCE_DIR}")
+ else()
+ set(maybe_source_dir "")
+ endif()
execute_process(
- COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}"
+ COMMAND ${CMAKE_COMMAND}
+ ${maybe_source_dir}
-G "${RunCMake_GENERATOR}"
-A "${RunCMake_GENERATOR_PLATFORM}"
-T "${RunCMake_GENERATOR_TOOLSET}"
+ ${_D_CMAKE_GENERATOR_INSTANCE}
-DRunCMake_TEST=${test}
--no-warn-unused-cli
${RunCMake_TEST_OPTIONS}
@@ -93,15 +132,29 @@ function(run_cmake test)
RESULT_VARIABLE actual_result
ENCODING UTF8
${maybe_timeout}
+ ${maybe_input_file}
)
endif()
set(msg "")
if(NOT "${actual_result}" MATCHES "${expect_result}")
string(APPEND msg "Result is [${actual_result}], not [${expect_result}].\n")
endif()
+ string(CONCAT ignore_line_regex
+ "(^|\n)((==[0-9]+=="
+ "|BullseyeCoverage"
+ "|[a-z]+\\([0-9]+\\) malloc:"
+ "|clang[^:]*: warning: the object size sanitizer has no effect at -O0, but is explicitly enabled:"
+ "|Error kstat returned"
+ "|Hit xcodebuild bug"
+ "|[^\n]*xcodebuild[^\n]*warning: file type[^\n]*is based on missing file type"
+ "|[^\n]*is a member of multiple groups"
+ "|[^\n]*from Time Machine by path"
+ "|[^\n]*Bullseye Testing Technology"
+ ")[^\n]*\n)+"
+ )
foreach(o out err)
string(REGEX REPLACE "\r\n" "\n" actual_std${o} "${actual_std${o}}")
- string(REGEX REPLACE "(^|\n)((==[0-9]+==|BullseyeCoverage|[a-z]+\\([0-9]+\\) malloc:|Error kstat returned|Hit xcodebuild bug|[^\n]*is a member of multiple groups|[^\n]*from Time Machine by path|[^\n]*Bullseye Testing Technology)[^\n]*\n)+" "\\1" actual_std${o} "${actual_std${o}}")
+ string(REGEX REPLACE "${ignore_line_regex}" "\\1" actual_std${o} "${actual_std${o}}")
string(REGEX REPLACE "\n+$" "" actual_std${o} "${actual_std${o}}")
set(expect_${o} "")
if(DEFINED expect_std${o})
@@ -146,5 +199,10 @@ function(run_cmake_command test)
run_cmake(${test})
endfunction()
+function(run_cmake_with_options test)
+ set(RunCMake_TEST_OPTIONS "${ARGN}")
+ run_cmake(${test})
+endfunction()
+
# Protect RunCMake tests from calling environment.
unset(ENV{MAKEFLAGS})
diff --git a/Tests/RunCMake/RunCTest.cmake b/Tests/RunCMake/RunCTest.cmake
index 89e16ee69..98fdf20ac 100644
--- a/Tests/RunCMake/RunCTest.cmake
+++ b/Tests/RunCMake/RunCTest.cmake
@@ -3,8 +3,12 @@ include(RunCMake)
function(run_ctest CASE_NAME)
configure_file(${RunCMake_SOURCE_DIR}/test.cmake.in
${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake @ONLY)
- configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in
- ${RunCMake_BINARY_DIR}/${CASE_NAME}/CTestConfig.cmake @ONLY)
+ if(EXISTS "${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in")
+ configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in
+ ${RunCMake_BINARY_DIR}/${CASE_NAME}/CTestConfig.cmake @ONLY)
+ else()
+ file(REMOVE ${RunCMake_BINARY_DIR}/${CASE_NAME}/CTestConfig.cmake)
+ endif()
configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in
${RunCMake_BINARY_DIR}/${CASE_NAME}/CMakeLists.txt @ONLY)
run_cmake_command(${CASE_NAME} ${CMAKE_CTEST_COMMAND}
diff --git a/Tests/RunCMake/RuntimePath/Genex.cmake b/Tests/RunCMake/RuntimePath/Genex.cmake
new file mode 100644
index 000000000..152238a30
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/Genex.cmake
@@ -0,0 +1,29 @@
+enable_language(C)
+
+add_library(A STATIC A.c)
+
+add_executable(buildge main.c)
+target_link_libraries(buildge A)
+set_target_properties(buildge PROPERTIES
+ BUILD_RPATH $<1:/opt/foo/lib>
+ )
+
+add_executable(buildnoge main.c)
+target_link_libraries(buildnoge A)
+set_target_properties(buildnoge PROPERTIES
+ BUILD_RPATH /opt/foo/lib
+ )
+
+add_executable(installge main.c)
+target_link_libraries(installge A)
+set_target_properties(installge PROPERTIES
+ INSTALL_RPATH $<1:/opt/foo/lib>
+ BUILD_WITH_INSTALL_RPATH 1
+ )
+
+add_executable(installnoge main.c)
+target_link_libraries(installnoge A)
+set_target_properties(installnoge PROPERTIES
+ INSTALL_RPATH /opt/foo/lib
+ BUILD_WITH_INSTALL_RPATH 1
+ )
diff --git a/Tests/RunCMake/RuntimePath/GenexCheck.cmake b/Tests/RunCMake/RuntimePath/GenexCheck.cmake
new file mode 100644
index 000000000..07dc4967d
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/GenexCheck.cmake
@@ -0,0 +1,7 @@
+file(GLOB_RECURSE files "${dir}/*")
+
+foreach(file IN LISTS files)
+ if(file MATCHES "/(build|install)(no)?ge$")
+ file(RPATH_CHANGE FILE "${file}" OLD_RPATH "/opt/foo/lib" NEW_RPATH "/opt/bar/lib")
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/RuntimePath/Relative.cmake b/Tests/RunCMake/RuntimePath/Relative.cmake
new file mode 100644
index 000000000..203241ff0
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/Relative.cmake
@@ -0,0 +1,69 @@
+enable_language(C)
+
+if(NOT CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN)
+ if(CMAKE_C_PLATFORM_ID STREQUAL "Linux")
+ # Sanity check for platform that is definitely known to support $ORIGIN.
+ message(FATAL_ERROR "Platform fails to report relative RPATH support")
+ else()
+ message(STATUS "Platform does not support relative RPATHs, skipping")
+ endif()
+ return()
+endif()
+set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
+
+function(CheckRpath target rpath)
+ add_custom_command(
+ TARGET ${target}
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -Dfile=$<TARGET_FILE:${target}> -Drpath=${rpath}
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/RelativeCheck.cmake"
+ VERBATIM
+ )
+endfunction()
+
+if(CMAKE_C_COMPILER_ID STREQUAL "XL" AND CMAKE_BINARY_DIR MATCHES " ")
+ # XL 16.1.0.0 fails building the library if the output path contains a space.
+ set(externDir)
+ message(STATUS "Skipping external library test because of a toolchain bug")
+else()
+ get_filename_component(externDir "${CMAKE_BINARY_DIR}" DIRECTORY)
+ set(externDir "${externDir}/Relative-extern")
+endif()
+
+add_library(utils SHARED A.c)
+add_library(utils-sub SHARED A.c)
+set_property(TARGET utils-sub PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs)
+if(externDir)
+ add_library(utils-extern SHARED A.c)
+ set_property(TARGET utils-extern PROPERTY LIBRARY_OUTPUT_DIRECTORY ${externDir})
+endif()
+
+add_executable(main main.c)
+target_link_libraries(main utils)
+CheckRpath(main "\$ORIGIN")
+
+add_executable(main-norel main.c)
+target_link_libraries(main-norel utils)
+set_property(TARGET main-norel PROPERTY BUILD_RPATH_USE_ORIGIN OFF)
+CheckRpath(main-norel "${CMAKE_CURRENT_BINARY_DIR}")
+
+add_executable(mainsub main.c)
+target_link_libraries(mainsub utils)
+set_property(TARGET mainsub PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
+CheckRpath(mainsub "\$ORIGIN/../")
+
+add_executable(main-sub main.c)
+target_link_libraries(main-sub utils-sub)
+CheckRpath(main-sub "\$ORIGIN/libs")
+
+add_executable(mainsub-sub main.c)
+target_link_libraries(mainsub-sub utils-sub)
+set_property(TARGET mainsub-sub PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
+CheckRpath(mainsub-sub "\$ORIGIN/../libs")
+
+if(externDir)
+ # Binaries linking to libraries outside the build tree should have an absolute RPATH.
+ add_executable(main-extern main.c)
+ target_link_libraries(main-extern utils-extern)
+ CheckRpath(main-extern "${externDir}")
+endif()
diff --git a/Tests/RunCMake/RuntimePath/RelativeCheck.cmake b/Tests/RunCMake/RuntimePath/RelativeCheck.cmake
new file mode 100644
index 000000000..9ee403ff9
--- /dev/null
+++ b/Tests/RunCMake/RuntimePath/RelativeCheck.cmake
@@ -0,0 +1,4 @@
+file(RPATH_CHECK FILE "${file}" RPATH "${rpath}")
+if(NOT EXISTS "${file}")
+ message(FATAL_ERROR "RPATH for ${file} did not contain the expected value")
+endif()
diff --git a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake
index a9a7f05c7..4c9ddcdb9 100644
--- a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake
+++ b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake
@@ -1,18 +1,26 @@
include(RunCMake)
-function(run_SymlinkImplicit)
+function(run_RuntimePath name)
# Use a single build tree for a few tests without cleaning.
- set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SymlinkImplicit-build)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build)
set(RunCMake_TEST_NO_CLEAN 1)
- if(RunCMake_GENERATOR MATCHES "Make|Ninja")
+ if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif()
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
- run_cmake(SymlinkImplicit)
- run_cmake_command(SymlinkImplicit-build ${CMAKE_COMMAND} --build . --config Debug)
- run_cmake_command(SymlinkImplicitCheck
- ${CMAKE_COMMAND} -Ddir=${RunCMake_TEST_BINARY_DIR} -P ${RunCMake_SOURCE_DIR}/SymlinkImplicitCheck.cmake)
+ run_cmake(${name})
+ run_cmake_command(${name}-build ${CMAKE_COMMAND} --build . --config Debug)
endfunction()
-run_SymlinkImplicit()
+
+run_RuntimePath(SymlinkImplicit)
+run_cmake_command(SymlinkImplicitCheck
+ ${CMAKE_COMMAND} -Ddir=${RunCMake_BINARY_DIR}/SymlinkImplicit-build -P ${RunCMake_SOURCE_DIR}/SymlinkImplicitCheck.cmake)
+
+run_RuntimePath(Relative)
+# FIXME: Run RelativeCheck (appears to be broken currently)
+
+run_RuntimePath(Genex)
+run_cmake_command(GenexCheck
+ ${CMAKE_COMMAND} -Ddir=${RunCMake_BINARY_DIR}/Genex-build -P ${RunCMake_SOURCE_DIR}/GenexCheck.cmake)
diff --git a/Tests/RunCMake/RuntimePath/main.c b/Tests/RunCMake/RuntimePath/main.c
index 8488f4e58..181cd0973 100644
--- a/Tests/RunCMake/RuntimePath/main.c
+++ b/Tests/RunCMake/RuntimePath/main.c
@@ -1,4 +1,6 @@
+extern int libA(void);
+
int main(void)
{
- return 0;
+ return libA();
}
diff --git a/Tests/RunCMake/ScriptMode/RunCMakeTest.cmake b/Tests/RunCMake/ScriptMode/RunCMakeTest.cmake
new file mode 100644
index 000000000..4c44ffb09
--- /dev/null
+++ b/Tests/RunCMake/ScriptMode/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake_command(set_directory_properties ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/set_directory_properties.cmake)
diff --git a/Tests/RunCMake/ScriptMode/set_directory_properties.cmake b/Tests/RunCMake/ScriptMode/set_directory_properties.cmake
new file mode 100644
index 000000000..bf793172f
--- /dev/null
+++ b/Tests/RunCMake/ScriptMode/set_directory_properties.cmake
@@ -0,0 +1 @@
+set_directory_properties(PROPERTIES SOME_PROPERTY FALSE)
diff --git a/Tests/RunCMake/SourceProperties/CMakeLists.txt b/Tests/RunCMake/SourceProperties/CMakeLists.txt
new file mode 100644
index 000000000..a17c8cd13
--- /dev/null
+++ b/Tests/RunCMake/SourceProperties/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.4)
+project(${RunCMake_TEST} C)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/SourceProperties/RelativeIncludeDir-result.txt b/Tests/RunCMake/SourceProperties/RelativeIncludeDir-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/SourceProperties/RelativeIncludeDir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/SourceProperties/RelativeIncludeDir-stderr.txt b/Tests/RunCMake/SourceProperties/RelativeIncludeDir-stderr.txt
new file mode 100644
index 000000000..cf146c25d
--- /dev/null
+++ b/Tests/RunCMake/SourceProperties/RelativeIncludeDir-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error in CMakeLists.txt:
+ Found relative path while evaluating include directories of "empty.c":
+
+ "relative"
diff --git a/Tests/RunCMake/SourceProperties/RelativeIncludeDir.cmake b/Tests/RunCMake/SourceProperties/RelativeIncludeDir.cmake
new file mode 100644
index 000000000..08dffa81e
--- /dev/null
+++ b/Tests/RunCMake/SourceProperties/RelativeIncludeDir.cmake
@@ -0,0 +1,4 @@
+
+set_property (SOURCE empty.c PROPERTY INCLUDE_DIRECTORIES "relative")
+
+add_library (somelib empty.c)
diff --git a/Tests/RunCMake/SourceProperties/RunCMakeTest.cmake b/Tests/RunCMake/SourceProperties/RunCMakeTest.cmake
new file mode 100644
index 000000000..098215317
--- /dev/null
+++ b/Tests/RunCMake/SourceProperties/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(RelativeIncludeDir)
diff --git a/Tests/RunCMake/SourceProperties/empty.c b/Tests/RunCMake/SourceProperties/empty.c
new file mode 100644
index 000000000..a9ec1021d
--- /dev/null
+++ b/Tests/RunCMake/SourceProperties/empty.c
@@ -0,0 +1,5 @@
+
+int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/Swift/E.swift b/Tests/RunCMake/Swift/E.swift
new file mode 100644
index 000000000..a41546787
--- /dev/null
+++ b/Tests/RunCMake/Swift/E.swift
@@ -0,0 +1,2 @@
+func f() {
+}
diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake
index 4864295dc..481704554 100644
--- a/Tests/RunCMake/Swift/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake
@@ -4,6 +4,10 @@ if(RunCMake_GENERATOR STREQUAL Xcode)
if(XCODE_BELOW_6_1)
run_cmake(XcodeTooOld)
endif()
+elseif(RunCMake_GENERATOR STREQUAL Ninja)
+ if(CMAKE_Swift_COMPILER)
+ run_cmake(Win32ExecutableDisallowed)
+ endif()
else()
run_cmake(NotSupported)
endif()
diff --git a/Tests/RunCMake/Swift/Win32ExecutableDisallowed-result.txt b/Tests/RunCMake/Swift/Win32ExecutableDisallowed-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/Swift/Win32ExecutableDisallowed-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Swift/Win32ExecutableDisallowed-stderr.txt b/Tests/RunCMake/Swift/Win32ExecutableDisallowed-stderr.txt
new file mode 100644
index 000000000..d78101a91
--- /dev/null
+++ b/Tests/RunCMake/Swift/Win32ExecutableDisallowed-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at Win32ExecutableDisallowed.cmake:[0-9]+ \(add_executable\):
+ WIN32_EXECUTABLE property is not supported on Swift executables
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/Swift/Win32ExecutableDisallowed.cmake b/Tests/RunCMake/Swift/Win32ExecutableDisallowed.cmake
new file mode 100644
index 000000000..02d544749
--- /dev/null
+++ b/Tests/RunCMake/Swift/Win32ExecutableDisallowed.cmake
@@ -0,0 +1,4 @@
+enable_language(Swift)
+add_executable(E E.swift)
+set_target_properties(E PROPERTIES
+ WIN32_EXECUTABLE TRUE)
diff --git a/Tests/RunCMake/Syntax/.gitattributes b/Tests/RunCMake/Syntax/.gitattributes
index 35a9eaf2b..79af28584 100644
--- a/Tests/RunCMake/Syntax/.gitattributes
+++ b/Tests/RunCMake/Syntax/.gitattributes
@@ -1,3 +1,3 @@
CommandTabs.cmake whitespace=-tab-in-indent
-StringCRLF.cmake whitespace=cr-at-eol -crlf
-BracketCRLF.cmake whitespace=cr-at-eol -crlf
+StringCRLF.cmake eol=crlf
+BracketCRLF.cmake eol=crlf
diff --git a/Tests/RunCMake/Syntax/BracketCRLF.cmake b/Tests/RunCMake/Syntax/BracketCRLF.cmake
index bda0e17ef..2ea6df2fd 100644
--- a/Tests/RunCMake/Syntax/BracketCRLF.cmake
+++ b/Tests/RunCMake/Syntax/BracketCRLF.cmake
@@ -1,8 +1,8 @@
-if([[
-]] STREQUAL "" AND
-[[a
-b]] STREQUAL "a\nb")
- message("CRLF->LF worked")
-else()
- message(FATAL_ERROR "CRLF->LF failed")
-endif()
+if([[
+]] STREQUAL "" AND
+[[a
+b]] STREQUAL "a\nb")
+ message("CRLF->LF worked")
+else()
+ message(FATAL_ERROR "CRLF->LF failed")
+endif()
diff --git a/Tests/RunCMake/Syntax/CMP0053-At-OLD-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-At-OLD-stderr.txt
index acfa30a25..0dde1bc5e 100644
--- a/Tests/RunCMake/Syntax/CMP0053-At-OLD-stderr.txt
+++ b/Tests/RunCMake/Syntax/CMP0053-At-OLD-stderr.txt
@@ -1 +1,12 @@
-^-->wrong<--$
+^CMake Deprecation Warning at CMP0053-At-OLD.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0053 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+-->wrong<--$
diff --git a/Tests/RunCMake/Syntax/CMP0053-Dollar-NEW-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-Dollar-NEW-stderr.txt
new file mode 100644
index 000000000..7f248ae17
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-Dollar-NEW-stderr.txt
@@ -0,0 +1,2 @@
+^-->value<--
+-->value<--$
diff --git a/Tests/RunCMake/Syntax/CMP0053-Dollar-NEW.cmake b/Tests/RunCMake/Syntax/CMP0053-Dollar-NEW.cmake
new file mode 100644
index 000000000..b81fd56eb
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-Dollar-NEW.cmake
@@ -0,0 +1,6 @@
+cmake_policy(SET CMP0053 NEW)
+
+set($ value)
+set(dollar $)
+message("-->${${dollar}}<--")
+message("-->${$}<--")
diff --git a/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-result.txt b/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-stderr.txt b/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-stderr.txt
new file mode 100644
index 000000000..aecd4d333
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD-stderr.txt
@@ -0,0 +1,24 @@
+^CMake Deprecation Warning at CMP0053-Dollar-OLD.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0053 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+-->value<--
+CMake Error at CMP0053-Dollar-OLD.cmake:6 \(message\):
+ Syntax error in cmake code at
+
+ .*CMP0053-Dollar-OLD.cmake:6
+
+ when parsing string
+
+ -->\${\$}<--
+
+ syntax error, unexpected \$, expecting } \(7\)
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD.cmake b/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD.cmake
new file mode 100644
index 000000000..647f4648b
--- /dev/null
+++ b/Tests/RunCMake/Syntax/CMP0053-Dollar-OLD.cmake
@@ -0,0 +1,6 @@
+cmake_policy(SET CMP0053 OLD)
+
+set($ value)
+set(dollar $)
+message("-->${${dollar}}<--")
+message("-->${$}<--")
diff --git a/Tests/RunCMake/Syntax/NullAfterBackslash-result.txt b/Tests/RunCMake/Syntax/NullAfterBackslash-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NullAfterBackslash-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Syntax/NullAfterBackslash-stderr.txt b/Tests/RunCMake/Syntax/NullAfterBackslash-stderr.txt
new file mode 100644
index 000000000..e7ba44072
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NullAfterBackslash-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at NullAfterBackslash.cmake:1:
+ Parse error. Function missing ending "\)". Instead found bad character
+ with text "\\".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/NullAfterBackslash.cmake b/Tests/RunCMake/Syntax/NullAfterBackslash.cmake
new file mode 100644
index 000000000..ed96904dc
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NullAfterBackslash.cmake
Binary files differ
diff --git a/Tests/RunCMake/Syntax/NullTerminatedArgument-result.txt b/Tests/RunCMake/Syntax/NullTerminatedArgument-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NullTerminatedArgument-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Syntax/NullTerminatedArgument-stderr.txt b/Tests/RunCMake/Syntax/NullTerminatedArgument-stderr.txt
new file mode 100644
index 000000000..f26754e69
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NullTerminatedArgument-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at NullTerminatedArgument.cmake:1:
+ Parse error. Function missing ending "\)". Instead found bad character
+ with text "".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/NullTerminatedArgument.cmake b/Tests/RunCMake/Syntax/NullTerminatedArgument.cmake
new file mode 100644
index 000000000..c82aceb53
--- /dev/null
+++ b/Tests/RunCMake/Syntax/NullTerminatedArgument.cmake
Binary files differ
diff --git a/Tests/RunCMake/Syntax/QueryCache-stderr.txt b/Tests/RunCMake/Syntax/QueryCache-stderr.txt
new file mode 100644
index 000000000..db6b2b7d6
--- /dev/null
+++ b/Tests/RunCMake/Syntax/QueryCache-stderr.txt
@@ -0,0 +1,2 @@
+-->cache value<--
+-->local value<--
diff --git a/Tests/RunCMake/Syntax/QueryCache.cmake b/Tests/RunCMake/Syntax/QueryCache.cmake
new file mode 100644
index 000000000..20c648e60
--- /dev/null
+++ b/Tests/RunCMake/Syntax/QueryCache.cmake
@@ -0,0 +1,6 @@
+
+set(query_var "cache value" CACHE STRING "")
+set(query_var "local value")
+
+message("-->$CACHE{query_var}<--")
+message("-->${query_var}<--")
diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
index d1fbb16aa..8d74dc163 100644
--- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
@@ -55,6 +55,8 @@ run_cmake(BracketNoSpace5)
run_cmake(Escape1)
run_cmake(Escape2)
run_cmake(EscapeCharsAllowed)
+run_cmake(NullAfterBackslash)
+run_cmake(NullTerminatedArgument)
include("${RunCMake_SOURCE_DIR}/EscapeCharsDisallowed.cmake")
run_cmake(ParenNoSpace0)
run_cmake(ParenNoSpace1)
@@ -109,6 +111,11 @@ run_cmake(CMP0053-NameWithNewlineQuoted)
run_cmake(CMP0053-NameWithCarriageReturnQuoted)
run_cmake(CMP0053-NameWithEscapedSpacesQuoted)
run_cmake(CMP0053-NameWithEscapedTabsQuoted)
+run_cmake(CMP0053-Dollar-OLD)
+run_cmake(CMP0053-Dollar-NEW)
+
+# Variable special types
+run_cmake(QueryCache)
# Function and macro tests.
run_cmake(FunctionUnmatched)
diff --git a/Tests/RunCMake/Syntax/StringCRLF.cmake b/Tests/RunCMake/Syntax/StringCRLF.cmake
index d20cfea7e..14aad31a2 100644
--- a/Tests/RunCMake/Syntax/StringCRLF.cmake
+++ b/Tests/RunCMake/Syntax/StringCRLF.cmake
@@ -1,6 +1,6 @@
-if("a
-b" STREQUAL "a\nb")
- message("CRLF->LF worked")
-else()
- message(FATAL_ERROR "CRLF->LF failed")
-endif()
+if("a
+b" STREQUAL "a\nb")
+ message("CRLF->LF worked")
+else()
+ message(FATAL_ERROR "CRLF->LF failed")
+endif()
diff --git a/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt b/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt
index 3f5224487..f3ee8951b 100644
--- a/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt
+++ b/Tests/RunCMake/Syntax/UnterminatedCall1-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at UnterminatedCall1.cmake:2:
+CMake Error at UnterminatedCall1.cmake:1:
Parse error. Function missing ending "\)". End of file reached.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/UnterminatedCall1.cmake b/Tests/RunCMake/Syntax/UnterminatedCall1.cmake
index 1166109c9..e1d211877 100644
--- a/Tests/RunCMake/Syntax/UnterminatedCall1.cmake
+++ b/Tests/RunCMake/Syntax/UnterminatedCall1.cmake
@@ -1 +1,4 @@
message(
+
+
+message("Additional message")
diff --git a/Tests/RunCMake/Syntax/UnterminatedCall2-stderr.txt b/Tests/RunCMake/Syntax/UnterminatedCall2-stderr.txt
index 18656f713..04216c32f 100644
--- a/Tests/RunCMake/Syntax/UnterminatedCall2-stderr.txt
+++ b/Tests/RunCMake/Syntax/UnterminatedCall2-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at UnterminatedCall2.cmake:4:
+CMake Error at UnterminatedCall2.cmake:3:
Parse error. Function missing ending "\)". End of file reached.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/UnterminatedCall2.cmake b/Tests/RunCMake/Syntax/UnterminatedCall2.cmake
index 26e9e6223..8d4088dcb 100644
--- a/Tests/RunCMake/Syntax/UnterminatedCall2.cmake
+++ b/Tests/RunCMake/Syntax/UnterminatedCall2.cmake
@@ -1,3 +1,6 @@
set(var "\
")
message(
+
+
+message("Additional message")
diff --git a/Tests/RunCMake/TargetObjects/NoTarget.cmake b/Tests/RunCMake/TargetObjects/NoTarget.cmake
index 5d7e33e79..268577d50 100644
--- a/Tests/RunCMake/TargetObjects/NoTarget.cmake
+++ b/Tests/RunCMake/TargetObjects/NoTarget.cmake
@@ -1,7 +1,7 @@
add_library(iface INTERFACE)
target_sources(iface INTERFACE $<TARGET_OBJECTS:NoTarget>)
-file(GENERATE OUTPUT test_output CONTENT $<TARGET_OBJECTS:NoTarget>)
-file(GENERATE OUTPUT test_output2 CONTENT $<TARGET_PROPERTY:iface,INTERFACE_SOURCES>)
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_output CONTENT $<TARGET_OBJECTS:NoTarget>)
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_output2 CONTENT $<TARGET_PROPERTY:iface,INTERFACE_SOURCES>)
install(FILES $<TARGET_OBJECTS:NoTarget> DESTINATION objects)
diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt b/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt
index a66794ce8..77c4afd08 100644
--- a/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt
+++ b/Tests/RunCMake/TargetObjects/NotObjlibTarget-stderr.txt
@@ -1,8 +1,9 @@
-CMake Error at NotObjlibTarget.cmake:3 \(file\):
+CMake Error at NotObjlibTarget.cmake:[0-9]+ \(file\):
Error evaluating generator expression:
- \$<TARGET_OBJECTS:StaticLib>
+ \$<TARGET_OBJECTS:IFaceLib>
- Objects of target "StaticLib" referenced but is not an OBJECT library.
+ Objects of target "IFaceLib" referenced but is not an allowed library types
+ \(EXECUTABLE, STATIC, SHARED, MODULE, OBJECT\).
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake
index 8e5fdd047..9fec369a7 100644
--- a/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake
+++ b/Tests/RunCMake/TargetObjects/NotObjlibTarget.cmake
@@ -1,3 +1,3 @@
-add_library(StaticLib empty.cpp)
+add_library(IFaceLib INTERFACE )
-file(GENERATE OUTPUT test_output CONTENT $<TARGET_OBJECTS:StaticLib>)
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_output CONTENT $<TARGET_OBJECTS:IFaceLib>)
diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
index 5f6be877b..6d72fac8b 100644
--- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
+++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
@@ -12,6 +12,7 @@
\* CMP0021
\* CMP0022
\* CMP0027
+ \* CMP0037
\* CMP0038
\* CMP0041
\* CMP0042
@@ -22,6 +23,11 @@
\* CMP0065
\* CMP0068
\* CMP0069
+ \* CMP0073
+ \* CMP0076
+ \* CMP0081
+ \* CMP0083
+ \* CMP0095
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName-result.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName-stderr.txt
new file mode 100644
index 000000000..6da79b7d5
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName-stderr.txt
@@ -0,0 +1,52 @@
+^(CMake Error at BadInvalidName1/CMakeLists\.txt:[0-9]+ \(include_directories\):
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:Invali/dTarget,INCLUDE_DIRECTORIES>
+
+ Target name not supported.
++)+(CMake Error at BadInvalidName2/CMakeLists\.txt:[0-9]+ \(include_directories\):
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:Invali/dTarget,Invali/dProperty>
+
+ Target name and property name not supported.
++)+(CMake Error at BadInvalidName3/CMakeLists\.txt:[0-9]+ \(include_directories\):
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:Invali/dProperty>
+
+ Property name not supported.
++)+(CMake Error at BadInvalidName4/CMakeLists\.txt:[0-9]+ \(include_directories\):
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:BadInvalidName4,Invali/dProperty>
+
+ Property name not supported.
++)+(CMake Error at BadInvalidName5/CMakeLists\.txt:[0-9]+ \(include_directories\):
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:,>
+
+ \$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty target name and
+ property name.
++)+(CMake Error at BadInvalidName6/CMakeLists\.txt:[0-9]+ \(include_directories\):
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:,ValidProperty>
+
+ \$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty target name.
++)+(CMake Error at BadInvalidName7/CMakeLists\.txt:[0-9]+ \(include_directories\):
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:BadInvalidName7,>
+
+ \$<TARGET_PROPERTY:...> expression requires a non-empty property name.
++)+(CMake Error at BadInvalidName8/CMakeLists\.txt:[0-9]+ \(include_directories\):
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:>
+
+ \$<TARGET_PROPERTY:...> expression requires a non-empty property name.
+*)+
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName.cmake
new file mode 100644
index 000000000..5f083e2a6
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName.cmake
@@ -0,0 +1,8 @@
+add_subdirectory(BadInvalidName1)
+add_subdirectory(BadInvalidName2)
+add_subdirectory(BadInvalidName3)
+add_subdirectory(BadInvalidName4)
+add_subdirectory(BadInvalidName5)
+add_subdirectory(BadInvalidName6)
+add_subdirectory(BadInvalidName7)
+add_subdirectory(BadInvalidName8)
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1-stderr.txt
deleted file mode 100644
index 9c146e057..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1-stderr.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at BadInvalidName1.cmake:7 \(include_directories\):
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:Invali/dTarget,INCLUDE_DIRECTORIES>
-
- Target name not supported.
-Call Stack \(most recent call first\):
- CMakeLists.txt:8 \(include\)
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1.cmake
deleted file mode 100644
index d5f661d60..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-include_directories("$<TARGET_PROPERTY:Invali/dTarget,INCLUDE_DIRECTORIES>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1/CMakeLists.txt
new file mode 100644
index 000000000..13e1de7d6
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName1/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadInvalidName1 ../main.cpp)
+include_directories("$<TARGET_PROPERTY:Invali/dTarget,INCLUDE_DIRECTORIES>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2-stderr.txt
deleted file mode 100644
index 451888cc6..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2-stderr.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at BadInvalidName2.cmake:7 \(include_directories\):
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:Invali/dTarget,Invali/dProperty>
-
- Target name and property name not supported.
-Call Stack \(most recent call first\):
- CMakeLists.txt:8 \(include\)$
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2.cmake
deleted file mode 100644
index 6e4c1d0d3..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-include_directories("$<TARGET_PROPERTY:Invali/dTarget,Invali/dProperty>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2/CMakeLists.txt
new file mode 100644
index 000000000..4b784729e
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName2/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadInvalidName2 ../main.cpp)
+include_directories("$<TARGET_PROPERTY:Invali/dTarget,Invali/dProperty>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3-stderr.txt
deleted file mode 100644
index 39692c4ef..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3-stderr.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at BadInvalidName3.cmake:7 \(include_directories\):
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:Invali/dProperty>
-
- Property name not supported.
-Call Stack \(most recent call first\):
- CMakeLists.txt:8 \(include\)$
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3.cmake
deleted file mode 100644
index 3f75aa382..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-include_directories("$<TARGET_PROPERTY:Invali/dProperty>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3/CMakeLists.txt
new file mode 100644
index 000000000..516a049a8
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName3/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadInvalidName3 ../main.cpp)
+include_directories("$<TARGET_PROPERTY:Invali/dProperty>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4-stderr.txt
deleted file mode 100644
index c3aa1b1a9..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4-stderr.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at BadInvalidName4.cmake:9 \(include_directories\):
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:foo,Invali/dProperty>
-
- Property name not supported.
-Call Stack \(most recent call first\):
- CMakeLists.txt:8 \(include\)$
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4.cmake
deleted file mode 100644
index b616c3106..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(foo "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-include_directories("$<TARGET_PROPERTY:foo,Invali/dProperty>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4/CMakeLists.txt
new file mode 100644
index 000000000..02f2a1a8a
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName4/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadInvalidName4 ../main.cpp)
+include_directories("$<TARGET_PROPERTY:BadInvalidName4,Invali/dProperty>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5-stderr.txt
deleted file mode 100644
index 1c6fad4b0..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5-stderr.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-CMake Error at BadInvalidName5.cmake:7 \(include_directories\):
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:,>
-
- \$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty target name and
- property name.
-Call Stack \(most recent call first\):
- CMakeLists.txt:8 \(include\)$
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5.cmake
deleted file mode 100644
index 11cb6fa52..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-include_directories("$<TARGET_PROPERTY:,>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5/CMakeLists.txt
new file mode 100644
index 000000000..a653583b5
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName5/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadInvalidName5 ../main.cpp)
+include_directories("$<TARGET_PROPERTY:,>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6-stderr.txt
deleted file mode 100644
index 8b147dca6..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6-stderr.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at BadInvalidName6.cmake:7 \(include_directories\):
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:,ValidProperty>
-
- \$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty target name.
-Call Stack \(most recent call first\):
- CMakeLists.txt:8 \(include\)$
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6.cmake
deleted file mode 100644
index bf868a501..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-include_directories("$<TARGET_PROPERTY:,ValidProperty>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6/CMakeLists.txt
new file mode 100644
index 000000000..614458ef2
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName6/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadInvalidName6 ../main.cpp)
+include_directories("$<TARGET_PROPERTY:,ValidProperty>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7-stderr.txt
deleted file mode 100644
index dad6bf86a..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7-stderr.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at BadInvalidName7.cmake:9 \(include_directories\):
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:foo,>
-
- \$<TARGET_PROPERTY:...> expression requires a non-empty property name.
-Call Stack \(most recent call first\):
- CMakeLists.txt:8 \(include\)$
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7.cmake
deleted file mode 100644
index 36d1a7903..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(foo "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-include_directories("$<TARGET_PROPERTY:foo,>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7/CMakeLists.txt
new file mode 100644
index 000000000..8a9fe8018
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName7/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadInvalidName7 ../main.cpp)
+include_directories("$<TARGET_PROPERTY:BadInvalidName7,>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8-stderr.txt
deleted file mode 100644
index 4e8c14c99..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8-stderr.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-CMake Error at BadInvalidName8.cmake:7 \(include_directories\):
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:>
-
- \$<TARGET_PROPERTY:...> expression requires a non-empty property name.
-Call Stack \(most recent call first\):
- CMakeLists.txt:8 \(include\)$
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8.cmake
deleted file mode 100644
index f059288c6..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-include_directories("$<TARGET_PROPERTY:>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8/CMakeLists.txt
new file mode 100644
index 000000000..b228159f0
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadInvalidName8/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadInvalidName8 ../main.cpp)
+include_directories("$<TARGET_PROPERTY:>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt
index 3adf73ea0..d40b16baa 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt
@@ -5,4 +5,6 @@ CMake Error at BadNonTarget.cmake:7 \(include_directories\):
Target "NonExistent" not found.
Call Stack \(most recent call first\):
- CMakeLists.txt:8 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference-result.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference-stderr.txt
new file mode 100644
index 000000000..fa2686193
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference-stderr.txt
@@ -0,0 +1,39 @@
+^(CMake Error:
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>
+
+ Self reference on target "BadSelfReference1".
++)+(CMake Error:
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>
+
+ Self reference on target "BadSelfReference2".
++)+(CMake Error:
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:BadSelfReference3,INCLUDE_DIRECTORIES>
+
+ Self reference on target "BadSelfReference3".
++)+(CMake Error:
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:BadSelfReference4,INCLUDE_DIRECTORIES>
+
+ Self reference on target "BadSelfReference4".
++)+(CMake Error:
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:COMPILE_DEFINITIONS>
+
+ Self reference on target "BadSelfReference5".
++)+(CMake Error:
+ Error evaluating generator expression:
+
+ \$<TARGET_PROPERTY:BadSelfReference6,COMPILE_DEFINITIONS>
+
+ Self reference on target "BadSelfReference6".
+*)+
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference.cmake
new file mode 100644
index 000000000..5a99f7afa
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference.cmake
@@ -0,0 +1,6 @@
+add_subdirectory(BadSelfReference1)
+add_subdirectory(BadSelfReference2)
+add_subdirectory(BadSelfReference3)
+add_subdirectory(BadSelfReference4)
+add_subdirectory(BadSelfReference5)
+add_subdirectory(BadSelfReference6)
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1-stderr.txt
deleted file mode 100644
index 75a729e9c..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1-stderr.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-CMake Error:
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>
-
- Self reference on target "TargetPropertyGeneratorExpressions".
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1.cmake
deleted file mode 100644
index a85731ecf..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-include_directories("$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1/CMakeLists.txt
new file mode 100644
index 000000000..30c27f51b
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference1/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadSelfReference1 ../main.cpp)
+include_directories("$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2-stderr.txt
deleted file mode 100644
index 75a729e9c..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2-stderr.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-CMake Error:
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>
-
- Self reference on target "TargetPropertyGeneratorExpressions".
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2.cmake
deleted file mode 100644
index f1459b8cb..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-set_property(TARGET TargetPropertyGeneratorExpressions PROPERTY
- INCLUDE_DIRECTORIES "$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>"
-)
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2/CMakeLists.txt
new file mode 100644
index 000000000..c2322f43b
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference2/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadSelfReference2 ../main.cpp)
+set_property(TARGET BadSelfReference2 PROPERTY INCLUDE_DIRECTORIES "$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3-stderr.txt
deleted file mode 100644
index f52a27df1..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3-stderr.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-CMake Error:
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,INCLUDE_DIRECTORIES>
-
- Self reference on target "TargetPropertyGeneratorExpressions".
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3.cmake
deleted file mode 100644
index 433b73011..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3.cmake
+++ /dev/null
@@ -1,8 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-include_directories(
- "$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,INCLUDE_DIRECTORIES>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3/CMakeLists.txt
new file mode 100644
index 000000000..3e6c30a74
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference3/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadSelfReference3 ../main.cpp)
+include_directories("$<TARGET_PROPERTY:BadSelfReference3,INCLUDE_DIRECTORIES>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4-stderr.txt
deleted file mode 100644
index f52a27df1..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4-stderr.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-CMake Error:
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,INCLUDE_DIRECTORIES>
-
- Self reference on target "TargetPropertyGeneratorExpressions".
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4.cmake
deleted file mode 100644
index 4b6445916..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-set_property(TARGET TargetPropertyGeneratorExpressions PROPERTY
-INCLUDE_DIRECTORIES
- "$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,INCLUDE_DIRECTORIES>"
-)
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4/CMakeLists.txt
new file mode 100644
index 000000000..f79727a9c
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference4/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadSelfReference4 ../main.cpp)
+set_property(TARGET BadSelfReference4 PROPERTY INCLUDE_DIRECTORIES "$<TARGET_PROPERTY:BadSelfReference4,INCLUDE_DIRECTORIES>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5-stderr.txt
deleted file mode 100644
index d8d12b53d..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5-stderr.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-CMake Error:
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:COMPILE_DEFINITIONS>
-
- Self reference on target "TargetPropertyGeneratorExpressions".
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5.cmake
deleted file mode 100644
index 74fff674d..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-set_property(TARGET TargetPropertyGeneratorExpressions
-PROPERTY
- COMPILE_DEFINITIONS "$<TARGET_PROPERTY:COMPILE_DEFINITIONS>"
-)
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5/CMakeLists.txt
new file mode 100644
index 000000000..c0badbfed
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference5/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadSelfReference5 ../main.cpp)
+set_property(TARGET BadSelfReference5 PROPERTY COMPILE_DEFINITIONS "$<TARGET_PROPERTY:COMPILE_DEFINITIONS>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6-stderr.txt
deleted file mode 100644
index 0b1dd26b3..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6-stderr.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-CMake Error:
- Error evaluating generator expression:
-
- \$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,COMPILE_DEFINITIONS>
-
- Self reference on target "TargetPropertyGeneratorExpressions".
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6.cmake
deleted file mode 100644
index d6650d3a5..000000000
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
-
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
- "int main(int, char **) { return 0; }\n")
-
-add_executable(TargetPropertyGeneratorExpressions
- "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
-set_property(TARGET TargetPropertyGeneratorExpressions PROPERTY
-COMPILE_DEFINITIONS
- "$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,COMPILE_DEFINITIONS>"
-)
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6/CMakeLists.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6/CMakeLists.txt
new file mode 100644
index 000000000..fcb6b3c3e
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadSelfReference6/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_executable(BadSelfReference6 ../main.cpp)
+set_property(TARGET BadSelfReference6 PROPERTY COMPILE_DEFINITIONS "$<TARGET_PROPERTY:BadSelfReference6,COMPILE_DEFINITIONS>")
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle1-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle1-stderr.txt
index 7e002f547..8bff68e08 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle1-stderr.txt
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle1-stderr.txt
@@ -7,4 +7,4 @@ CMake Error at LinkImplementationCycle1.cmake:5 \(target_link_libraries\):
target property which is transitive over the link libraries, creating a
recursion.
Call Stack \(most recent call first\):
- CMakeLists.txt:8 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle2-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle2-stderr.txt
index 2f72de6ec..044b77cc6 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle2-stderr.txt
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle2-stderr.txt
@@ -7,4 +7,4 @@ CMake Error at LinkImplementationCycle2.cmake:5 \(target_link_libraries\):
target property which is transitive over the link libraries, creating a
recursion.
Call Stack \(most recent call first\):
- CMakeLists.txt:8 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake
index 645a57d5f..4294e9fd7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake
@@ -1,20 +1,8 @@
include(RunCMake)
-run_cmake(BadSelfReference1)
-run_cmake(BadSelfReference2)
-run_cmake(BadSelfReference3)
-run_cmake(BadSelfReference4)
-run_cmake(BadSelfReference5)
-run_cmake(BadSelfReference6)
+run_cmake(BadSelfReference)
run_cmake(BadNonTarget)
-run_cmake(BadInvalidName1)
-run_cmake(BadInvalidName2)
-run_cmake(BadInvalidName3)
-run_cmake(BadInvalidName4)
-run_cmake(BadInvalidName5)
-run_cmake(BadInvalidName6)
-run_cmake(BadInvalidName7)
-run_cmake(BadInvalidName8)
+run_cmake(BadInvalidName)
run_cmake(LinkImplementationCycle1)
run_cmake(LinkImplementationCycle2)
run_cmake(LinkImplementationCycle3)
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/main.cpp b/Tests/RunCMake/TargetPropertyGeneratorExpressions/main.cpp
new file mode 100644
index 000000000..f8b643afb
--- /dev/null
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/main.cpp
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/CMP0076-OLD-result.txt b/Tests/RunCMake/TargetSources/CMP0076-OLD-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMP0076-OLD-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/TargetSources/RelativePathInInterface-stderr.txt b/Tests/RunCMake/TargetSources/CMP0076-OLD-stderr.txt
index d47dd4de3..d47dd4de3 100644
--- a/Tests/RunCMake/TargetSources/RelativePathInInterface-stderr.txt
+++ b/Tests/RunCMake/TargetSources/CMP0076-OLD-stderr.txt
diff --git a/Tests/RunCMake/TargetSources/CMP0076-OLD.cmake b/Tests/RunCMake/TargetSources/CMP0076-OLD.cmake
new file mode 100644
index 000000000..4d8c268ef
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMP0076-OLD.cmake
@@ -0,0 +1,10 @@
+cmake_policy(SET CMP0076 OLD)
+
+add_library(iface INTERFACE)
+target_sources(iface INTERFACE empty_1.cpp)
+
+get_property(iface_sources TARGET iface PROPERTY INTERFACE_SOURCES)
+message(STATUS "iface: ${iface_sources}")
+
+add_executable(main main.cpp)
+target_link_libraries(main iface)
diff --git a/Tests/RunCMake/TargetSources/CMP0076-WARN-result.txt b/Tests/RunCMake/TargetSources/CMP0076-WARN-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMP0076-WARN-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/TargetSources/CMP0076-WARN-stderr.txt b/Tests/RunCMake/TargetSources/CMP0076-WARN-stderr.txt
new file mode 100644
index 000000000..bd888eed5
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMP0076-WARN-stderr.txt
@@ -0,0 +1,21 @@
+CMake Warning \(dev\) at CMP0076-WARN/CMakeLists\.txt:[0-9]+ \(target_sources\):
+ Policy CMP0076 is not set: target_sources\(\) command converts relative paths
+ to absolute. Run "cmake --help-policy CMP0076" for policy details. Use
+ the cmake_policy command to set the policy and suppress this warning.
+
+ An interface source of target "publiclib" has a relative path.
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at CMP0076-WARN/CMakeLists\.txt:[0-9]+ \(target_sources\):
+ Policy CMP0076 is not set: target_sources\(\) command converts relative paths
+ to absolute. Run "cmake --help-policy CMP0076" for policy details. Use
+ the cmake_policy command to set the policy and suppress this warning.
+
+ A private source from a directory other than that of target "publiclib" has
+ a relative path.
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Error in CMakeLists.txt:
+ Target "publiclib" contains relative path in its INTERFACE_SOURCES:
+
+ "CMP0076-WARN/subdir_empty_1.cpp"
diff --git a/Tests/RunCMake/TargetSources/CMP0076-WARN.cmake b/Tests/RunCMake/TargetSources/CMP0076-WARN.cmake
new file mode 100644
index 000000000..2e0733112
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMP0076-WARN.cmake
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.12)
+
+add_library(publiclib)
+
+add_subdirectory(CMP0076-WARN)
+
+add_executable(main main.cpp)
+target_link_libraries(main publiclib)
diff --git a/Tests/RunCMake/TargetSources/CMP0076-WARN/CMakeLists.txt b/Tests/RunCMake/TargetSources/CMP0076-WARN/CMakeLists.txt
new file mode 100644
index 000000000..f9c7d6d5e
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMP0076-WARN/CMakeLists.txt
@@ -0,0 +1,3 @@
+
+target_sources(publiclib INTERFACE CMP0076-WARN/subdir_empty_1.cpp
+ PRIVATE empty_1.cpp)
diff --git a/Tests/RunCMake/TargetSources/CMP0076-WARN/subdir_empty_1.cpp b/Tests/RunCMake/TargetSources/CMP0076-WARN/subdir_empty_1.cpp
new file mode 100644
index 000000000..11ec041d1
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMP0076-WARN/subdir_empty_1.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt b/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt
index 1de5dd72e..c6b75fceb 100644
--- a/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt
+++ b/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt
@@ -6,9 +6,7 @@ CMake Error in CMakeLists.txt:
.*/Tests/RunCMake/TargetSources/empty_1.cpp
.*/Tests/RunCMake/TargetSources/empty_2.cpp
- .*/Tests/RunCMake/TargetSources/CMakeLists.txt
Config "Release":
.*/Tests/RunCMake/TargetSources/empty_1.cpp
- .*/Tests/RunCMake/TargetSources/CMakeLists.txt
diff --git a/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt
index 11bc96cf9..a40f46315 100644
--- a/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt
+++ b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt
@@ -4,7 +4,7 @@ CMake Debug Log at OriginDebug.cmake:13 \(add_library\):
\* .*Tests/RunCMake/TargetSources/empty_2.cpp
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
.*
CMake Debug Log at OriginDebug.cmake:16 \(set_property\):
Used sources for target OriginDebug:
@@ -12,7 +12,7 @@ CMake Debug Log at OriginDebug.cmake:16 \(set_property\):
\* .*Tests/RunCMake/TargetSources/empty_3.cpp
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
.*
CMake Debug Log at OriginDebug.cmake:20 \(target_sources\):
Used sources for target OriginDebug:
@@ -20,7 +20,7 @@ CMake Debug Log at OriginDebug.cmake:20 \(target_sources\):
\* .*Tests/RunCMake/TargetSources/empty_4.cpp
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
.*
CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\):
Used sources for target OriginDebug:
@@ -28,4 +28,4 @@ CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\):
\* .*Tests/RunCMake/TargetSources/empty_1.cpp
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt b/Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt
deleted file mode 100644
index 573541ac9..000000000
--- a/Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt
deleted file mode 100644
index 6fdcce73e..000000000
--- a/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-CMake Debug Log at OriginDebug.cmake:13 \(add_library\):
- Used sources for target OriginDebug:
-
- \* .*Tests/RunCMake/TargetSources/empty_2.cpp
-
-Call Stack \(most recent call first\):
- OriginDebugIDE.cmake:4 \(include\)
- CMakeLists.txt:3 \(include\)
-+
-CMake Debug Log at OriginDebug.cmake:16 \(set_property\):
- Used sources for target OriginDebug:
-
- \* .*Tests/RunCMake/TargetSources/empty_3.cpp
-
-Call Stack \(most recent call first\):
- OriginDebugIDE.cmake:4 \(include\)
- CMakeLists.txt:3 \(include\)
-+
-CMake Debug Log at OriginDebug.cmake:20 \(target_sources\):
- Used sources for target OriginDebug:
-
- \* .*Tests/RunCMake/TargetSources/empty_4.cpp
-
-Call Stack \(most recent call first\):
- OriginDebugIDE.cmake:4 \(include\)
- CMakeLists.txt:3 \(include\)
-+
-CMake Debug Log in CMakeLists.txt:
- Used sources for target OriginDebug:
-
- * .*CMakeLists.txt
-+
-CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\):
- Used sources for target OriginDebug:
-
- \* .*Tests/RunCMake/TargetSources/empty_1.cpp
-
-Call Stack \(most recent call first\):
- OriginDebugIDE.cmake:4 \(include\)
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE.cmake b/Tests/RunCMake/TargetSources/OriginDebugIDE.cmake
deleted file mode 100644
index a3cc3a8ed..000000000
--- a/Tests/RunCMake/TargetSources/OriginDebugIDE.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-
-# Separate test for the IDEs, because they show the CMakeLists.txt file
-# as a source file.
-include(${CMAKE_CURRENT_LIST_DIR}/OriginDebug.cmake)
diff --git a/Tests/RunCMake/TargetSources/RelativePathInInterface-stdout.txt b/Tests/RunCMake/TargetSources/RelativePathInInterface-stdout.txt
new file mode 100644
index 000000000..4581d8a88
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInInterface-stdout.txt
@@ -0,0 +1 @@
+-- iface: .*Tests/RunCMake/TargetSources/empty_1.cpp
diff --git a/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake b/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake
index 8bb6149d9..0d3e9a456 100644
--- a/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake
+++ b/Tests/RunCMake/TargetSources/RelativePathInInterface.cmake
@@ -1,6 +1,10 @@
+cmake_policy(SET CMP0076 NEW)
add_library(iface INTERFACE)
target_sources(iface INTERFACE empty_1.cpp)
+get_property(iface_sources TARGET iface PROPERTY INTERFACE_SOURCES)
+message(STATUS "iface: ${iface_sources}")
+
add_executable(main main.cpp)
target_link_libraries(main iface)
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx-stdout.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx-stdout.txt
new file mode 100644
index 000000000..7f480829f
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx-stdout.txt
@@ -0,0 +1 @@
+-- genexlib: \$<1:.*Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/subdir_empty_1.cpp>;\$<1:.*Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/../empty_1.cpp>;\$<1:empty_2.cpp>
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx.cmake b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx.cmake
new file mode 100644
index 000000000..1cdc2a785
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx.cmake
@@ -0,0 +1,10 @@
+cmake_policy(SET CMP0076 NEW)
+
+add_library(genexlib)
+add_subdirectory(RelativePathInSubdirGenEx)
+
+get_property(genexlib_sources TARGET genexlib PROPERTY SOURCES)
+message(STATUS "genexlib: ${genexlib_sources}")
+
+add_executable(genexmain main.cpp)
+target_link_libraries(genexmain genexlib)
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/CMakeLists.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/CMakeLists.txt
new file mode 100644
index 000000000..3bcf454da
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/CMakeLists.txt
@@ -0,0 +1,4 @@
+
+target_sources(genexlib PUBLIC $<1:${CMAKE_CURRENT_LIST_DIR}/subdir_empty_1.cpp>
+ $<1:${CMAKE_CURRENT_LIST_DIR}/../empty_1.cpp>
+ PRIVATE $<1:empty_2.cpp>)
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/subdir_empty_1.cpp b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/subdir_empty_1.cpp
new file mode 100644
index 000000000..11ec041d1
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirGenEx/subdir_empty_1.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude-stdout.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude-stdout.txt
new file mode 100644
index 000000000..aa4851ffa
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude-stdout.txt
@@ -0,0 +1 @@
+-- privatelib: .*Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/subdir_empty_1.cpp;empty_1.cpp
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude.cmake b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude.cmake
new file mode 100644
index 000000000..4acbecacc
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude.cmake
@@ -0,0 +1,8 @@
+cmake_policy(SET CMP0076 NEW)
+
+add_library(privatelib)
+
+include("RelativePathInSubdirInclude/CMakeLists.txt")
+
+get_property(privatelib_sources TARGET privatelib PROPERTY SOURCES)
+message(STATUS "privatelib: ${privatelib_sources}")
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/CMakeLists.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/CMakeLists.txt
new file mode 100644
index 000000000..3dcb13545
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/CMakeLists.txt
@@ -0,0 +1,3 @@
+
+target_sources(privatelib PRIVATE "${CMAKE_CURRENT_LIST_DIR}/subdir_empty_1.cpp"
+ empty_1.cpp)
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/subdir_empty_1.cpp b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/subdir_empty_1.cpp
new file mode 100644
index 000000000..11ec041d1
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInclude/subdir_empty_1.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface-stdout.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface-stdout.txt
new file mode 100644
index 000000000..5990a0599
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface-stdout.txt
@@ -0,0 +1 @@
+-- iface: .*Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_1.cpp;.*Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_2.cpp;.*Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/../empty_1.cpp;.*Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/../empty_2.cpp
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface.cmake b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface.cmake
new file mode 100644
index 000000000..3652b4f64
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface.cmake
@@ -0,0 +1,11 @@
+cmake_policy(SET CMP0076 NEW)
+
+add_library(iface INTERFACE)
+
+add_subdirectory(RelativePathInSubdirInterface)
+
+get_property(iface_sources TARGET iface PROPERTY INTERFACE_SOURCES)
+message(STATUS "iface: ${iface_sources}")
+
+add_executable(main main.cpp)
+target_link_libraries(main iface)
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/CMakeLists.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/CMakeLists.txt
new file mode 100644
index 000000000..02e69669e
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/CMakeLists.txt
@@ -0,0 +1,5 @@
+
+target_sources(iface INTERFACE subdir_empty_1.cpp
+ "${CMAKE_CURRENT_LIST_DIR}/subdir_empty_2.cpp"
+ ../empty_1.cpp
+ "${CMAKE_CURRENT_LIST_DIR}/../empty_2.cpp")
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_1.cpp b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_1.cpp
new file mode 100644
index 000000000..11ec041d1
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_1.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_2.cpp b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_2.cpp
new file mode 100644
index 000000000..11ec041d1
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirInterface/subdir_empty_2.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate-stdout.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate-stdout.txt
new file mode 100644
index 000000000..fa5bcbfee
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate-stdout.txt
@@ -0,0 +1 @@
+-- privatelib: .*Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_1.cpp;.*Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_2.cpp;.*Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/../empty_1.cpp;.*Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/../empty_2.cpp
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate.cmake b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate.cmake
new file mode 100644
index 000000000..d0d3dc441
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate.cmake
@@ -0,0 +1,8 @@
+cmake_policy(SET CMP0076 NEW)
+
+add_library(privatelib)
+
+add_subdirectory(RelativePathInSubdirPrivate)
+
+get_property(privatelib_sources TARGET privatelib PROPERTY SOURCES)
+message(STATUS "privatelib: ${privatelib_sources}")
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/CMakeLists.txt b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/CMakeLists.txt
new file mode 100644
index 000000000..56ee853e1
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/CMakeLists.txt
@@ -0,0 +1,5 @@
+
+target_sources(privatelib PRIVATE subdir_empty_1.cpp
+ "${CMAKE_CURRENT_LIST_DIR}/subdir_empty_2.cpp"
+ ../empty_1.cpp
+ "${CMAKE_CURRENT_LIST_DIR}/../empty_2.cpp")
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_1.cpp b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_1.cpp
new file mode 100644
index 000000000..11ec041d1
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_1.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_2.cpp b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_2.cpp
new file mode 100644
index 000000000..11ec041d1
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RelativePathInSubdirPrivate/subdir_empty_2.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake
index bb55a6ebd..bee8c4e38 100644
--- a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake
+++ b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake
@@ -2,11 +2,15 @@ include(RunCMake)
if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode")
run_cmake(ConfigNotAllowed)
- run_cmake(OriginDebugIDE)
-else()
- run_cmake(OriginDebug)
endif()
+run_cmake(OriginDebug)
run_cmake(CMP0026-LOCATION)
+run_cmake(CMP0076-OLD)
+run_cmake(CMP0076-WARN)
run_cmake(RelativePathInInterface)
+run_cmake(RelativePathInSubdirGenEx)
+run_cmake(RelativePathInSubdirInterface)
+run_cmake(RelativePathInSubdirPrivate)
+run_cmake(RelativePathInSubdirInclude)
run_cmake(ExportBuild)
diff --git a/Tests/RunCMake/ToolchainFile/IncludeDirectories-toolchain.cmake b/Tests/RunCMake/ToolchainFile/IncludeDirectories-toolchain.cmake
new file mode 100644
index 000000000..e77e9fe10
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/IncludeDirectories-toolchain.cmake
@@ -0,0 +1 @@
+include_directories(${CMAKE_CURRENT_LIST_DIR}/IncludeDirectories)
diff --git a/Tests/RunCMake/ToolchainFile/IncludeDirectories.c b/Tests/RunCMake/ToolchainFile/IncludeDirectories.c
new file mode 100644
index 000000000..81b2465a1
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/IncludeDirectories.c
@@ -0,0 +1,5 @@
+#include <IncDir.h>
+
+void IncDir(void)
+{
+}
diff --git a/Tests/RunCMake/ToolchainFile/IncludeDirectories.cmake b/Tests/RunCMake/ToolchainFile/IncludeDirectories.cmake
new file mode 100644
index 000000000..616cff4c3
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/IncludeDirectories.cmake
@@ -0,0 +1,2 @@
+enable_language(C)
+add_library(IncDir STATIC IncludeDirectories.c)
diff --git a/Tests/RunCMake/ToolchainFile/IncludeDirectories/IncDir.h b/Tests/RunCMake/ToolchainFile/IncludeDirectories/IncDir.h
new file mode 100644
index 000000000..bca9c2c6f
--- /dev/null
+++ b/Tests/RunCMake/ToolchainFile/IncludeDirectories/IncDir.h
@@ -0,0 +1 @@
+/* IncDir.h */
diff --git a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake
index 8a202008f..7eb4485d0 100644
--- a/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ToolchainFile/RunCMakeTest.cmake
@@ -9,3 +9,11 @@ run_cmake_toolchain(CallEnableLanguage)
run_cmake_toolchain(CallProject)
run_cmake_toolchain(FlagsInit)
run_cmake_toolchain(LinkFlagsInit)
+
+function(run_IncludeDirectories)
+ run_cmake_toolchain(IncludeDirectories)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/IncludeDirectories-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(IncludeDirectories-build ${CMAKE_COMMAND} --build . --config Debug)
+endfunction()
+run_IncludeDirectories()
diff --git a/Tests/RunCMake/UnityBuild/CMakeLists.txt b/Tests/RunCMake/UnityBuild/CMakeLists.txt
new file mode 100644
index 000000000..77030d63b
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.15)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake b/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake
new file mode 100644
index 000000000..24daa64ff
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/RunCMakeTest.cmake
@@ -0,0 +1,24 @@
+include(RunCMake)
+
+run_cmake(unitybuild_c)
+run_cmake(unitybuild_cxx)
+run_cmake(unitybuild_c_and_cxx)
+run_cmake(unitybuild_batchsize)
+run_cmake(unitybuild_default_batchsize)
+run_cmake(unitybuild_skip)
+run_cmake(unitybuild_code_before_and_after_include)
+run_cmake(unitybuild_c_no_unity_build)
+run_cmake(unitybuild_order)
+
+function(run_test name)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake(${name})
+ run_cmake_command(${name}-build ${CMAKE_COMMAND} --build . --config Debug)
+ run_cmake_command(${name}-test ${CMAKE_CTEST_COMMAND} -C Debug)
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+endfunction()
+
+run_test(unitybuild_runtest)
+run_test(unitybuild_object_library)
diff --git a/Tests/RunCMake/UnityBuild/func.c b/Tests/RunCMake/UnityBuild/func.c
new file mode 100644
index 000000000..b14c90708
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/func.c
@@ -0,0 +1,6 @@
+#include "func.h"
+
+int func(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/UnityBuild/func.h b/Tests/RunCMake/UnityBuild/func.h
new file mode 100644
index 000000000..563a98012
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/func.h
@@ -0,0 +1,6 @@
+#ifndef func_h
+#define func_h
+
+extern int func(void);
+
+#endif
diff --git a/Tests/RunCMake/UnityBuild/main.c b/Tests/RunCMake/UnityBuild/main.c
new file mode 100644
index 000000000..19c18d407
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/main.c
@@ -0,0 +1,6 @@
+#include "func.h"
+
+int main(void)
+{
+ return func();
+}
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_batchsize-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_batchsize-check.cmake
new file mode 100644
index 000000000..72cc2b933
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_batchsize-check.cmake
@@ -0,0 +1,11 @@
+set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c")
+set(unitybuild_c1 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_1_c.c")
+if(NOT EXISTS "${unitybuild_c0}")
+ set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c0} does not exist.")
+ return()
+endif()
+
+if(NOT EXISTS "${unitybuild_c1}")
+ set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c1} does not exist.")
+ return()
+endif()
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_batchsize.cmake b/Tests/RunCMake/UnityBuild/unitybuild_batchsize.cmake
new file mode 100644
index 000000000..7caf25168
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_batchsize.cmake
@@ -0,0 +1,16 @@
+project(unitybuild_batchsize C)
+
+set(srcs "")
+foreach(s RANGE 1 8)
+ set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c")
+ file(WRITE "${src}" "int s${s}(void) { return 0; }\n")
+ list(APPEND srcs "${src}")
+endforeach()
+
+add_library(tgt SHARED ${srcs})
+
+set_target_properties(tgt
+ PROPERTIES
+ UNITY_BUILD ON
+ UNITY_BUILD_BATCH_SIZE 4
+)
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c-check.cmake
new file mode 100644
index 000000000..024286d5a
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_c-check.cmake
@@ -0,0 +1,5 @@
+set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c")
+if(NOT EXISTS "${unitybuild_c}")
+ set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c} does not exist.")
+ return()
+endif()
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c.cmake
new file mode 100644
index 000000000..77a09cb00
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_c.cmake
@@ -0,0 +1,12 @@
+project(unitybuild_c C)
+
+set(srcs "")
+foreach(s RANGE 1 8)
+ set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c")
+ file(WRITE "${src}" "int s${s}(void) { return 0; }\n")
+ list(APPEND srcs "${src}")
+endforeach()
+
+add_library(tgt SHARED ${srcs})
+
+set_target_properties(tgt PROPERTIES UNITY_BUILD ON)
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx-check.cmake
new file mode 100644
index 000000000..269d545ce
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx-check.cmake
@@ -0,0 +1,11 @@
+set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c")
+if(NOT EXISTS "${unitybuild_c}")
+ set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c} does not exist.")
+ return()
+endif()
+
+set(unitybuild_cxx "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_cxx.cxx")
+if(NOT EXISTS "${unitybuild_cxx}")
+ set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_cxx} does not exist.")
+ return()
+endif()
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx.cmake
new file mode 100644
index 000000000..073aff29a
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_c_and_cxx.cmake
@@ -0,0 +1,17 @@
+project(unitybuild_c_and_cxx C CXX)
+
+set(srcs "")
+foreach(s RANGE 1 8)
+ set(src_c "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c")
+ file(WRITE "${src_c}" "int s${s}(void) { return 0; }\n")
+
+ set(src_cxx "${CMAKE_CURRENT_BINARY_DIR}/s${s}.cxx")
+ file(WRITE "${src_cxx}" "int s${s}(void) { return 0; }\n")
+
+ list(APPEND srcs "${src_c}")
+ list(APPEND srcs "${src_cxx}")
+endforeach()
+
+add_library(tgt SHARED ${srcs})
+
+set_target_properties(tgt PROPERTIES UNITY_BUILD ON)
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build-check.cmake
new file mode 100644
index 000000000..22d2fc6c8
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build-check.cmake
@@ -0,0 +1,5 @@
+set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c")
+if(EXISTS "${unitybuild_c}")
+ set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c} should not exist.")
+ return()
+endif()
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build.cmake b/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build.cmake
new file mode 100644
index 000000000..1185e9fcd
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_c_no_unity_build.cmake
@@ -0,0 +1,10 @@
+project(unitybuild_c_no_unity_build C)
+
+set(srcs "")
+foreach(s RANGE 1 8)
+ set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c")
+ file(WRITE "${src}" "int s${s}(void) { return 0; }\n")
+ list(APPEND srcs "${src}")
+endforeach()
+
+add_library(tgt SHARED ${srcs})
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include-check.cmake
new file mode 100644
index 000000000..e0935c70d
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include-check.cmake
@@ -0,0 +1,7 @@
+set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c")
+file(STRINGS ${unitybuild_c} unitybuild_c_strings)
+string(REGEX MATCH "#define NOMINMAX.*#include.*s1.c.*#undef NOMINMAX" matched_code ${unitybuild_c_strings})
+if(NOT matched_code)
+ set(RunCMake_TEST_FAILED "Generated unity file doesn't include expected code before and after include")
+ return()
+endif()
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include.cmake b/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include.cmake
new file mode 100644
index 000000000..cc9cc2843
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_code_before_and_after_include.cmake
@@ -0,0 +1,13 @@
+project(unitybuild_code_before_and_after_include C)
+
+set(src "${CMAKE_CURRENT_BINARY_DIR}/s1.c")
+file(WRITE "${src}" "int s1(void) { return 0; }\n")
+
+add_library(tgt SHARED ${src})
+
+set_target_properties(tgt
+ PROPERTIES
+ UNITY_BUILD ON
+ UNITY_BUILD_CODE_BEFORE_INCLUDE "#define NOMINMAX"
+ UNITY_BUILD_CODE_AFTER_INCLUDE "#undef NOMINMAX"
+)
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_cxx-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_cxx-check.cmake
new file mode 100644
index 000000000..9ef4c2147
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_cxx-check.cmake
@@ -0,0 +1,5 @@
+set(unitybuild_cxx "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_cxx.cxx")
+if(NOT EXISTS "${unitybuild_cxx}")
+ set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_cxx} does not exist.")
+ return()
+endif()
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_cxx.cmake b/Tests/RunCMake/UnityBuild/unitybuild_cxx.cmake
new file mode 100644
index 000000000..be800d7b1
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_cxx.cmake
@@ -0,0 +1,12 @@
+project(unitybuild_cxx CXX)
+
+set(srcs "")
+foreach(s RANGE 1 8)
+ set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.cxx")
+ file(WRITE "${src}" "int s${s}(void) { return 0; }\n")
+ list(APPEND srcs "${src}")
+endforeach()
+
+add_library(tgt SHARED ${srcs})
+
+set_target_properties(tgt PROPERTIES UNITY_BUILD ON)
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize-check.cmake
new file mode 100644
index 000000000..9d39a706d
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize-check.cmake
@@ -0,0 +1,7 @@
+set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c")
+file(STRINGS ${unitybuild_c0} unitybuild_c_strings REGEX "/s[0-9]+.c\"$" )
+list(LENGTH unitybuild_c_strings number_of_includes)
+if(NOT number_of_includes EQUAL 8)
+ set(RunCMake_TEST_FAILED "Generated unity doesn't include the expect number of files")
+ return()
+endif()
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize.cmake b/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize.cmake
new file mode 100644
index 000000000..60b98750d
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_default_batchsize.cmake
@@ -0,0 +1,15 @@
+project(unitybuild_default_batchsize C)
+
+set(srcs "")
+foreach(s RANGE 1 10)
+ set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c")
+ file(WRITE "${src}" "int s${s}(void) { return 0; }\n")
+ list(APPEND srcs "${src}")
+endforeach()
+
+add_library(tgt SHARED ${srcs})
+
+set_target_properties(tgt
+ PROPERTIES
+ UNITY_BUILD ON
+)
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_object_library.cmake b/Tests/RunCMake/UnityBuild/unitybuild_object_library.cmake
new file mode 100644
index 000000000..b4005172d
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_object_library.cmake
@@ -0,0 +1,13 @@
+project(unitybuild_object_library C)
+
+set(CMAKE_UNITY_BUILD ON) # This tests that the variable works in addition to the property
+
+add_library(lib OBJECT func.c)
+
+add_library(other-lib STATIC func.c)
+
+add_executable(main main.c)
+target_link_libraries(main PRIVATE lib)
+
+enable_testing()
+add_test(NAME main COMMAND main)
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake
new file mode 100644
index 000000000..f26ec2ea5
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_order-check.cmake
@@ -0,0 +1,7 @@
+set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c")
+file(STRINGS ${unitybuild_c} unitybuild_c_strings)
+string(REGEX MATCH ".*#include.*s3.c.*#include.*s1.c.*#include.*s2.c.*" matched_code ${unitybuild_c_strings})
+if(NOT matched_code)
+ set(RunCMake_TEST_FAILED "Generated unity file doesn't include expected oder of source files")
+ return()
+endif()
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_order.cmake b/Tests/RunCMake/UnityBuild/unitybuild_order.cmake
new file mode 100644
index 000000000..819603dd3
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_order.cmake
@@ -0,0 +1,12 @@
+project(unitybuild_order C)
+
+set(srcs "")
+foreach(s 3 1 2)
+ set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c")
+ file(WRITE "${src}" "int s${s}(void) { return 0; }\n")
+ list(APPEND srcs "${src}")
+endforeach()
+
+add_library(tgt SHARED ${srcs})
+
+set_target_properties(tgt PROPERTIES UNITY_BUILD ON)
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_runtest.cmake b/Tests/RunCMake/UnityBuild/unitybuild_runtest.cmake
new file mode 100644
index 000000000..3589cc868
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_runtest.cmake
@@ -0,0 +1,9 @@
+project(unitybuild_runtest C)
+
+set(CMAKE_UNITY_BUILD ON) # This tests that the variable works in addition to the property
+
+add_library(lib main.c func.c)
+add_executable(main main.c func.c)
+
+enable_testing()
+add_test(NAME main COMMAND main)
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake b/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake
new file mode 100644
index 000000000..e94ad7211
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_skip-check.cmake
@@ -0,0 +1,14 @@
+set(unitybuild_c "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c")
+file(STRINGS ${unitybuild_c} unitybuild_c_strings)
+
+string(REGEX MATCH "\\/s[1-6].c" matched_files_1_6 ${unitybuild_c_strings})
+if(matched_files_1_6)
+ set(RunCMake_TEST_FAILED "Generated unity contains s1.c -> s6.c which should have been skipped")
+ return()
+endif()
+
+string(REGEX MATCH "\\/s[7-8].c" matched_files_7_8 ${unitybuild_c_strings})
+if(NOT matched_files_7_8)
+ set(RunCMake_TEST_FAILED "Generated unity should have contained s7.c, s8.c!")
+ return()
+endif()
diff --git a/Tests/RunCMake/UnityBuild/unitybuild_skip.cmake b/Tests/RunCMake/UnityBuild/unitybuild_skip.cmake
new file mode 100644
index 000000000..94e5aa327
--- /dev/null
+++ b/Tests/RunCMake/UnityBuild/unitybuild_skip.cmake
@@ -0,0 +1,30 @@
+project(unitybuild_skip C)
+
+set(srcs "")
+foreach(s RANGE 1 8)
+ set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c")
+ file(WRITE "${src}" "int s${s}(void) { return 0; }\n")
+ list(APPEND srcs "${src}")
+endforeach()
+
+add_library(tgt SHARED ${srcs})
+
+set_target_properties(tgt PROPERTIES UNITY_BUILD ON)
+
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s1.c
+ PROPERTIES HEADER_FILE_ONLY ON)
+
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s2.c
+ PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
+
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s3.c
+ PROPERTIES COMPILE_OPTIONS "val")
+
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s4.c
+ PROPERTIES COMPILE_DEFINITIONS "val")
+
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s5.c
+ PROPERTIES COMPILE_FLAGS "val")
+
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/s6.c
+ PROPERTIES INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}")
diff --git a/Tests/RunCMake/UseSWIG/CMP0078-NEW-stdout.txt b/Tests/RunCMake/UseSWIG/CMP0078-NEW-stdout.txt
new file mode 100644
index 000000000..d4fa6e4b8
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0078-NEW-stdout.txt
@@ -0,0 +1,2 @@
+-- PREFIX='_'
+-- TARGET NAME='example'
diff --git a/Tests/RunCMake/UseSWIG/CMP0078-NEW.cmake b/Tests/RunCMake/UseSWIG/CMP0078-NEW.cmake
new file mode 100644
index 000000000..ce77218c8
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0078-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0078 NEW)
+include(CMP0078-common.cmake)
diff --git a/Tests/RunCMake/UseSWIG/CMP0078-OLD-stdout.txt b/Tests/RunCMake/UseSWIG/CMP0078-OLD-stdout.txt
new file mode 100644
index 000000000..62f5371e1
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0078-OLD-stdout.txt
@@ -0,0 +1,2 @@
+-- PREFIX=''
+-- TARGET NAME='_example'
diff --git a/Tests/RunCMake/UseSWIG/CMP0078-OLD.cmake b/Tests/RunCMake/UseSWIG/CMP0078-OLD.cmake
new file mode 100644
index 000000000..2c4d142d5
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0078-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0078 OLD)
+include(CMP0078-common.cmake)
diff --git a/Tests/RunCMake/UseSWIG/CMP0078-WARN-stderr.txt b/Tests/RunCMake/UseSWIG/CMP0078-WARN-stderr.txt
new file mode 100644
index 000000000..d89d1744d
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0078-WARN-stderr.txt
@@ -0,0 +1,10 @@
+CMake Warning \(dev\) at .*/Modules/UseSWIG\.cmake:[0-9]+ \(message\):
+ Policy CMP0078 is not set: UseSWIG generates standard target names\. Run
+ "cmake --help-policy CMP0078" for policy details\. Use the cmake_policy
+ command to set the policy and suppress this warning\.
+
+Call Stack \(most recent call first\):
+ CMP0078-common\.cmake:8 \(swig_add_library\)
+ CMP0078-WARN\.cmake:1 \(include\)
+ CMakeLists\.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/UseSWIG/CMP0078-WARN-stdout.txt b/Tests/RunCMake/UseSWIG/CMP0078-WARN-stdout.txt
new file mode 100644
index 000000000..62f5371e1
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0078-WARN-stdout.txt
@@ -0,0 +1,2 @@
+-- PREFIX=''
+-- TARGET NAME='_example'
diff --git a/Tests/RunCMake/UseSWIG/CMP0078-WARN.cmake b/Tests/RunCMake/UseSWIG/CMP0078-WARN.cmake
new file mode 100644
index 000000000..86b21a585
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0078-WARN.cmake
@@ -0,0 +1 @@
+include(CMP0078-common.cmake)
diff --git a/Tests/RunCMake/UseSWIG/CMP0078-common.cmake b/Tests/RunCMake/UseSWIG/CMP0078-common.cmake
new file mode 100644
index 000000000..b13796b55
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0078-common.cmake
@@ -0,0 +1,12 @@
+
+cmake_policy(SET CMP0086 NEW)
+
+set(SWIG_EXECUTABLE "swig")
+set(SWIG_DIR "/swig")
+include(UseSWIG)
+
+swig_add_library(example LANGUAGE python TYPE MODULE SOURCES example.i)
+
+get_property(prefix TARGET ${SWIG_MODULE_example_REAL_NAME} PROPERTY PREFIX)
+message(STATUS "PREFIX='${prefix}'")
+message(STATUS "TARGET NAME='${SWIG_MODULE_example_REAL_NAME}'")
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-NEW-nuild-check.cmake b/Tests/RunCMake/UseSWIG/CMP0086-NEW-nuild-check.cmake
new file mode 100644
index 000000000..ea8b2cdcb
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-NEW-nuild-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/new_example.py")
+ set (RunCMake_TEST_FAILED "Not found expected file: '${RunCMake_TEST_BINARY_DIR}/new_example.py'.")
+endif()
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-NEW.cmake b/Tests/RunCMake/UseSWIG/CMP0086-NEW.cmake
new file mode 100644
index 000000000..b54338d6a
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0086 NEW)
+include(CMP0086-common.cmake)
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-OLD-build-check.cmake b/Tests/RunCMake/UseSWIG/CMP0086-OLD-build-check.cmake
new file mode 100644
index 000000000..96b5295a3
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-OLD-build-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/example.py")
+ set (RunCMake_TEST_FAILED "Not found expected file: '${RunCMake_TEST_BINARY_DIR}/example.py'.")
+endif()
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-OLD.cmake b/Tests/RunCMake/UseSWIG/CMP0086-OLD.cmake
new file mode 100644
index 000000000..6a63d4cd0
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0086 OLD)
+include(CMP0086-common.cmake)
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-WARN-stderr.txt b/Tests/RunCMake/UseSWIG/CMP0086-WARN-stderr.txt
new file mode 100644
index 000000000..af4102144
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-WARN-stderr.txt
@@ -0,0 +1,11 @@
+CMake Warning \(dev\) at .*/Modules/UseSWIG.cmake:[0-9]+ \(message\):
+ Policy CMP0086 is not set: UseSWIG honors SWIG_MODULE_NAME via -module
+ flag. Run "cmake --help-policy CMP0086" for policy details\. Use the
+ cmake_policy command to set the policy and suppress this warning\.
+
+Call Stack \(most recent call first\):
+ .*/Modules/UseSWIG.cmake:[0-9]+ \(SWIG_ADD_SOURCE_TO_MODULE\)
+ CMP0086-common\.cmake:[0-9]+ \(swig_add_library\)
+ CMP0086-WARN\.cmake:1 \(include\)
+ CMakeLists\.txt:3 \(include\)
+This warning is for project developers\. Use -Wno-dev to suppress it\.$
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-WARN.cmake b/Tests/RunCMake/UseSWIG/CMP0086-WARN.cmake
new file mode 100644
index 000000000..69c2d9db7
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-WARN.cmake
@@ -0,0 +1 @@
+include(CMP0086-common.cmake)
diff --git a/Tests/RunCMake/UseSWIG/CMP0086-common.cmake b/Tests/RunCMake/UseSWIG/CMP0086-common.cmake
new file mode 100644
index 000000000..ef9021813
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMP0086-common.cmake
@@ -0,0 +1,11 @@
+
+cmake_policy(SET CMP0078 NEW)
+
+find_package(Python REQUIRED COMPONENTS Development)
+find_package (SWIG REQUIRED)
+include(UseSWIG)
+
+set_property (SOURCE example.i PROPERTY SWIG_MODULE_NAME "new_example")
+
+swig_add_library(example LANGUAGE python TYPE MODULE SOURCES example.i)
+target_link_libraries(example PRIVATE Python::Module)
diff --git a/Tests/RunCMake/UseSWIG/CMakeLists.txt b/Tests/RunCMake/UseSWIG/CMakeLists.txt
new file mode 100644
index 000000000..d1b0d2c3e
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.10)
+project(${RunCMake_TEST} C)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake b/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake
new file mode 100644
index 000000000..6acf7199c
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake
@@ -0,0 +1,25 @@
+include(RunCMake)
+
+run_cmake(CMP0078-WARN)
+run_cmake(CMP0078-OLD)
+run_cmake(CMP0078-NEW)
+
+run_cmake(CMP0086-WARN)
+
+if (CMake_TEST_FindPython)
+
+ macro(run_cmake_target test subtest target)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN})
+
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+ endmacro()
+
+ run_cmake(CMP0086-OLD)
+ run_cmake_target(CMP0086-OLD build example)
+ run_cmake(CMP0086-NEW)
+ run_cmake_target(CMP0086-NEW build example)
+
+endif()
diff --git a/Tests/RunCMake/UseSWIG/example.i b/Tests/RunCMake/UseSWIG/example.i
new file mode 100644
index 000000000..86625aa3a
--- /dev/null
+++ b/Tests/RunCMake/UseSWIG/example.i
@@ -0,0 +1,2 @@
+/* File : example.i */
+%module example
diff --git a/Tests/RunCMake/VS10Project/Dir/DirNested/foo_nested.cpp b/Tests/RunCMake/VS10Project/Dir/DirNested/foo_nested.cpp
new file mode 100644
index 000000000..3695dc91e
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/Dir/DirNested/foo_nested.cpp
@@ -0,0 +1,3 @@
+void foo()
+{
+}
diff --git a/Tests/RunCMake/VS10Project/Dir/foo.cpp b/Tests/RunCMake/VS10Project/Dir/foo.cpp
new file mode 100644
index 000000000..3695dc91e
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/Dir/foo.cpp
@@ -0,0 +1,3 @@
+void foo()
+{
+}
diff --git a/Tests/RunCMake/VS10Project/ExplicitCMakeLists-check.cmake b/Tests/RunCMake/VS10Project/ExplicitCMakeLists-check.cmake
new file mode 100644
index 000000000..b671e3580
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/ExplicitCMakeLists-check.cmake
@@ -0,0 +1,25 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
+if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+endif()
+
+set(foundCMakeLists 0)
+file(STRINGS "${vcProjectFile}" lines)
+foreach(line IN LISTS lines)
+ if(line MATCHES "<([A-Za-z0-9_]+) +Include=.*CMakeLists.txt")
+ set(rule "${CMAKE_MATCH_1}")
+ if(NOT rule STREQUAL "CustomBuild")
+ set(RunCMake_TEST_FAILED "CMakeLists.txt referenced as ${rule} instead of CustomBuild")
+ return()
+ endif()
+ if(foundCMakeLists)
+ set(RunCMake_TEST_FAILED "CMakeLists.txt referenced multiple times")
+ return()
+ endif()
+ set(foundCMakeLists 1)
+ endif()
+endforeach()
+if(NOT foundCMakeLists)
+ set(RunCMake_TEST_FAILED "CMakeLists.txt not referenced")
+endif()
diff --git a/Tests/RunCMake/VS10Project/ExplicitCMakeLists.cmake b/Tests/RunCMake/VS10Project/ExplicitCMakeLists.cmake
new file mode 100644
index 000000000..c9e44561b
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/ExplicitCMakeLists.cmake
@@ -0,0 +1,3 @@
+set(CMAKE_CONFIGURATION_TYPES Debug)
+enable_language(CXX)
+add_executable(foo foo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt)
diff --git a/Tests/RunCMake/VS10Project/Prefixed/PrefixedNested/bar_nested.cpp b/Tests/RunCMake/VS10Project/Prefixed/PrefixedNested/bar_nested.cpp
new file mode 100644
index 000000000..3695dc91e
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/Prefixed/PrefixedNested/bar_nested.cpp
@@ -0,0 +1,3 @@
+void foo()
+{
+}
diff --git a/Tests/RunCMake/VS10Project/Prefixed/bar.cpp b/Tests/RunCMake/VS10Project/Prefixed/bar.cpp
new file mode 100644
index 000000000..b72a1a516
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/Prefixed/bar.cpp
@@ -0,0 +1,3 @@
+void bar()
+{
+}
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index 3af877f4f..44ccd6b58 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -1,6 +1,46 @@
include(RunCMake)
+cmake_policy(SET CMP0054 NEW)
+
+run_cmake(VsCSharpCompilerOpts)
+run_cmake(ExplicitCMakeLists)
+run_cmake(RuntimeLibrary)
+run_cmake(SourceGroupCMakeLists)
+run_cmake(SourceGroupTreeCMakeLists)
+
run_cmake(VsConfigurationType)
run_cmake(VsTargetsFileReferences)
run_cmake(VsCustomProps)
run_cmake(VsDebuggerWorkingDir)
+run_cmake(VsDebuggerCommand)
+run_cmake(VsDebuggerCommandArguments)
+run_cmake(VsDebuggerEnvironment)
run_cmake(VsCSharpCustomTags)
+run_cmake(VsCSharpReferenceProps)
+run_cmake(VsCSharpWithoutSources)
+run_cmake(VsCSharpDeployFiles)
+run_cmake(VSCSharpDefines)
+run_cmake(VsSdkDirectories)
+run_cmake(VsGlobals)
+run_cmake(VsProjectImport)
+run_cmake(VsPackageReferences)
+run_cmake(VsDpiAware)
+run_cmake(VsDpiAwareBadParam)
+run_cmake(VsPrecompileHeaders)
+run_cmake(VsPrecompileHeadersReuseFromCompilePDBName)
+
+if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05)
+ run_cmake(VsJustMyCode)
+endif()
+
+if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.20)
+ run_cmake(VsSpectreMitigation)
+endif()
+
+# Visual Studio 2017 has toolset version 141
+string(REPLACE "v" "" generator_toolset "${RunCMake_GENERATOR_TOOLSET}")
+if (RunCMake_GENERATOR MATCHES "Visual Studio 1[0-4] 201[0-5]" OR
+ (RunCMake_GENERATOR_TOOLSET AND generator_toolset VERSION_LESS "141"))
+ run_cmake(UnityBuildPre2017)
+else()
+ run_cmake(UnityBuildNative)
+endif()
diff --git a/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake b/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake
new file mode 100644
index 000000000..689b35f4c
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake
@@ -0,0 +1,36 @@
+macro(RuntimeLibrary_check tgt rtl_expect)
+ set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj")
+ if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.")
+ return()
+ endif()
+
+ set(HAVE_Runtimelibrary 0)
+
+ file(STRINGS "${vcProjectFile}" lines)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<RuntimeLibrary>([^<>]+)</RuntimeLibrary>")
+ set(rtl_actual "${CMAKE_MATCH_1}")
+ if(NOT "${rtl_actual}" STREQUAL "${rtl_expect}")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has RuntimeLibrary '${rtl_actual}', not '${rtl_expect}'.")
+ return()
+ endif()
+ set(HAVE_Runtimelibrary 1)
+ break()
+ endif()
+ endforeach()
+
+ if(NOT HAVE_Runtimelibrary AND NOT "${rtl_expect}" STREQUAL "")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a RuntimeLibrary field.")
+ return()
+ endif()
+endmacro()
+
+RuntimeLibrary_check(default-C MultiThreadedDebugDLL)
+RuntimeLibrary_check(default-CXX MultiThreadedDebugDLL)
+RuntimeLibrary_check(empty-C "")
+RuntimeLibrary_check(empty-CXX "")
+RuntimeLibrary_check(MTd-C MultiThreadedDebug)
+RuntimeLibrary_check(MTd-CXX MultiThreadedDebug)
+RuntimeLibrary_check(MT-C MultiThreaded)
+RuntimeLibrary_check(MT-CXX MultiThreaded)
diff --git a/Tests/RunCMake/VS10Project/RuntimeLibrary.cmake b/Tests/RunCMake/VS10Project/RuntimeLibrary.cmake
new file mode 100644
index 000000000..d7787c8f8
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/RuntimeLibrary.cmake
@@ -0,0 +1,20 @@
+set(CMAKE_CONFIGURATION_TYPES Debug)
+cmake_policy(SET CMP0091 NEW)
+enable_language(C)
+enable_language(CXX)
+
+add_library(default-C empty.c)
+add_library(default-CXX empty.cxx)
+
+set(CMAKE_MSVC_RUNTIME_LIBRARY "")
+add_library(empty-C empty.c)
+add_library(empty-CXX empty.cxx)
+
+set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
+add_library(MTd-C empty.c)
+add_library(MTd-CXX empty.cxx)
+
+add_library(MT-C empty.c)
+set_property(TARGET MT-C PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
+add_library(MT-CXX empty.cxx)
+set_property(TARGET MT-CXX PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
diff --git a/Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake b/Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake
new file mode 100644
index 000000000..616f38b07
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake
@@ -0,0 +1,11 @@
+set(vcFiltersFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj.filters")
+if(NOT EXISTS "${vcFiltersFile}")
+ set(RunCMake_TEST_FAILED "Filters file ${vcFiltersFile} does not exist.")
+ return()
+endif()
+
+file(STRINGS "${vcFiltersFile}" lines)
+
+include(${RunCMake_TEST_SOURCE_DIR}/SourceGroupHelpers.cmake)
+
+find_source_group("${lines}" CMakeListsSourceGroup)
diff --git a/Tests/RunCMake/VS10Project/SourceGroupCMakeLists.cmake b/Tests/RunCMake/VS10Project/SourceGroupCMakeLists.cmake
new file mode 100644
index 000000000..4ad87ec8d
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/SourceGroupCMakeLists.cmake
@@ -0,0 +1,3 @@
+set(CMAKE_CONFIGURATION_TYPES Debug)
+add_custom_target(foo)
+source_group("CMakeListsSourceGroup" FILES CMakeLists.txt)
diff --git a/Tests/RunCMake/VS10Project/SourceGroupHelpers.cmake b/Tests/RunCMake/VS10Project/SourceGroupHelpers.cmake
new file mode 100644
index 000000000..c82a66e8c
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/SourceGroupHelpers.cmake
@@ -0,0 +1,35 @@
+function(find_source_group LINES NAME)
+ set(foundFileFilter 0)
+ set(foundFilter 0)
+ foreach(line IN LISTS LINES)
+ if(line MATCHES "<Filter>${NAME}</Filter>")
+ if(foundFileFilter)
+ set(RunCMake_TEST_FAILED "Multiple files listed with filter for ${NAME}." PARENT_SCOPE)
+ set(FILTER_FOUND 0 PARENT_SCOPE)
+ return()
+ endif()
+ set(foundFileFilter 1)
+ endif()
+ if(line MATCHES "<Filter.*Include=\"${NAME}\"")
+ if(foundFilter)
+ set(RunCMake_TEST_FAILED "Multiple copies of ${NAME} filter listed." PARENT_SCOPE)
+ set(FILTER_FOUND 0 PARENT_SCOPE)
+ return()
+ endif()
+ set(foundFilter 1)
+ endif()
+ endforeach()
+
+ if(NOT foundFileFilter)
+ set(RunCMake_TEST_FAILED "File filter for ${NAME} not found." PARENT_SCOPE)
+ set(FILTER_FOUND 0 PARENT_SCOPE)
+ return()
+ endif()
+ if(NOT foundFilter)
+ set(RunCMake_TEST_FAILED "Filter ${NAME} not found." PARENT_SCOPE)
+ set(FILTER_FOUND 0 PARENT_SCOPE)
+ return()
+ endif()
+
+ set(FILTER_FOUND 1 PARENT_SCOPE)
+endfunction()
diff --git a/Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists-check.cmake b/Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists-check.cmake
new file mode 100644
index 000000000..ee0c4120c
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists-check.cmake
@@ -0,0 +1,26 @@
+cmake_policy(SET CMP0011 NEW)
+
+set(vcFiltersFile "${RunCMake_TEST_BINARY_DIR}/SourceGroupTree.vcxproj.filters")
+if(NOT EXISTS "${vcFiltersFile}")
+ set(RunCMake_TEST_FAILED "Filters file ${vcFiltersFile} does not exist.")
+ return()
+endif()
+
+file(STRINGS "${vcFiltersFile}" lines)
+
+include(${RunCMake_TEST_SOURCE_DIR}/SourceGroupHelpers.cmake)
+
+set(SOURCE_GROUPS_TO_FIND
+ "Dir"
+ "Dir\\DirNested"
+ "Generated"
+ "SourcesPrefix"
+ "SourcesPrefix\\PrefixedNested"
+)
+
+foreach(GROUP_NAME IN LISTS ${SOURCE_GROUPS_TO_FIND})
+ find_source_group("${lines}" ${GROUP_NAME})
+ if(NOT ${FILTER_FOUND})
+ return()
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists.cmake b/Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists.cmake
new file mode 100644
index 000000000..7655e6094
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists.cmake
@@ -0,0 +1,45 @@
+set(CMAKE_CONFIGURATION_TYPES Debug)
+
+# Test regular tree grouping.
+set(SRC_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/Dir/foo.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/Dir/DirNested/foo_nested.cpp
+)
+
+source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SRC_FILES})
+
+
+# Test files that are not present at configuration time.
+set(GENERATED_SRC_FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/Generated/generated.cpp
+)
+
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Generated)
+
+if(WIN32)
+ add_custom_command(OUTPUT ${GENERATED_SRC_FILES}
+ COMMAND echo. 2>${CMAKE_CURRENT_BINARY_DIR}\\Generated\\generated.cpp
+ )
+else()
+ add_custom_command(OUTPUT ${GENERATED_SRC_FILES}
+ COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/Generated/generated.cpp
+ )
+endif()
+
+source_group(TREE ${CMAKE_CURRENT_BINARY_DIR} FILES ${GENERATED_SRC_FILES})
+
+
+# Test prefixed tree grouping.
+set(PREFIXED_SRC_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/Prefixed/bar.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/Prefixed/PrefixedNested/bar_nested.cpp
+)
+
+add_custom_target(SourceGroupTree
+ SOURCES
+ ${SRC_FILES}
+ ${GENERATED_SRC_FILES}
+ ${PREFIXED_SRC_FILES}
+)
+
+source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/Prefixed PREFIX SourcesPrefix FILES ${PREFIXED_SRC_FILES})
diff --git a/Tests/RunCMake/VS10Project/UnityBuildNative-check.cmake b/Tests/RunCMake/VS10Project/UnityBuildNative-check.cmake
new file mode 100644
index 000000000..693dcd9f0
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/UnityBuildNative-check.cmake
@@ -0,0 +1,45 @@
+set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c")
+if(NOT EXISTS "${unitybuild_c0}")
+ set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c0} does not exist.")
+ return()
+endif()
+
+set(tgt_project "${RunCMake_TEST_BINARY_DIR}/tgt.vcxproj")
+if (NOT EXISTS "${tgt_project}")
+ set(RunCMake_TEST_FAILED "Generated project file ${tgt_project} doesn't exist.")
+ return()
+endif()
+
+file(STRINGS ${tgt_project} tgt_projects_strings)
+
+foreach(line IN LISTS tgt_projects_strings)
+ if (line MATCHES "<EnableUnitySupport>true</EnableUnitySupport>")
+ set(have_unity_support ON)
+ endif()
+
+ if (line MATCHES "<ClCompile Include=.*IncludeInUnityFile=\"false\" CustomUnityFile=\"true\"")
+ set(unity_source_line ${line})
+ endif()
+
+ if (line MATCHES "<ClCompile Include=.*IncludeInUnityFile=\"true\" CustomUnityFile=\"true\"")
+ list(APPEND sources_list ${line})
+ endif()
+endforeach()
+
+if (NOT have_unity_support)
+ set(RunCMake_TEST_FAILED "Generated project should include the <EnableUnitySupport> block.")
+ return()
+endif()
+
+string(REPLACE "\\" "/" unity_source_line "${unity_source_line}")
+string(FIND "${unity_source_line}" "CMakeFiles/tgt.dir/Unity/unity_0_c.c" unity_source_file_position)
+if (unity_source_file_position EQUAL "-1")
+ set(RunCMake_TEST_FAILED "Generated project should include the generated unity source file.")
+ return()
+endif()
+
+list(LENGTH sources_list number_of_sources)
+if(NOT number_of_sources EQUAL 8)
+ set(RunCMake_TEST_FAILED "Generated project doesn't include the expect number of files.")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/UnityBuildNative.cmake b/Tests/RunCMake/VS10Project/UnityBuildNative.cmake
new file mode 100644
index 000000000..77a09cb00
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/UnityBuildNative.cmake
@@ -0,0 +1,12 @@
+project(unitybuild_c C)
+
+set(srcs "")
+foreach(s RANGE 1 8)
+ set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c")
+ file(WRITE "${src}" "int s${s}(void) { return 0; }\n")
+ list(APPEND srcs "${src}")
+endforeach()
+
+add_library(tgt SHARED ${srcs})
+
+set_target_properties(tgt PROPERTIES UNITY_BUILD ON)
diff --git a/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake b/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake
new file mode 100644
index 000000000..17e7b4668
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/UnityBuildPre2017-check.cmake
@@ -0,0 +1,48 @@
+set(unitybuild_c0 "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/Unity/unity_0_c.c")
+if(NOT EXISTS "${unitybuild_c0}")
+ set(RunCMake_TEST_FAILED "Generated unity source files ${unitybuild_c0} does not exist.")
+ return()
+endif()
+
+set(tgt_project "${RunCMake_TEST_BINARY_DIR}/tgt.vcxproj")
+if (NOT EXISTS "${tgt_project}")
+ set(RunCMake_TEST_FAILED "Generated project file ${tgt_project} doesn't exist.")
+ return()
+endif()
+
+file(STRINGS ${tgt_project} tgt_projects_strings)
+
+foreach(line IN LISTS tgt_projects_strings)
+ if (line MATCHES "<ClCompile Include=.*/>")
+ set(unity_source_line ${line})
+ endif()
+
+ if (line MATCHES "<ClCompile Include=\"[^\"]*\">")
+ string(REGEX MATCH "<ClCompile Include=\"([^\"]*)\">" source_file ${line})
+ list(APPEND sources_list ${source_file})
+ endif()
+
+ if (line MATCHES "<ExcludedFromBuild.*</ExcludedFromBuild>")
+ list(APPEND excluded_sources_list ${source_file})
+ endif()
+endforeach()
+
+string(REPLACE "\\" "/" unity_source_line ${unity_source_line})
+string(FIND "${unity_source_line}" "CMakeFiles/tgt.dir/Unity/unity_0_c.c" unity_source_file_position)
+if (unity_source_file_position EQUAL "-1")
+ set(RunCMake_TEST_FAILED "Generated project should include the generated unity source file.")
+ return()
+endif()
+
+list(LENGTH sources_list number_of_sources)
+if(NOT number_of_sources EQUAL 8)
+ set(RunCMake_TEST_FAILED "Generated project doesn't include the expect number of files.")
+ return()
+endif()
+
+# Exclusions for Debug|Release|MinSizeRel|RelWithDebInfo
+list(LENGTH excluded_sources_list number_of_excluded_sources)
+if(NOT number_of_excluded_sources EQUAL 32)
+ set(RunCMake_TEST_FAILED "Generated project doesn't exclude the source files for all configurations.")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/UnityBuildPre2017.cmake b/Tests/RunCMake/VS10Project/UnityBuildPre2017.cmake
new file mode 100644
index 000000000..77a09cb00
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/UnityBuildPre2017.cmake
@@ -0,0 +1,12 @@
+project(unitybuild_c C)
+
+set(srcs "")
+foreach(s RANGE 1 8)
+ set(src "${CMAKE_CURRENT_BINARY_DIR}/s${s}.c")
+ file(WRITE "${src}" "int s${s}(void) { return 0; }\n")
+ list(APPEND srcs "${src}")
+endforeach()
+
+add_library(tgt SHARED ${srcs})
+
+set_target_properties(tgt PROPERTIES UNITY_BUILD ON)
diff --git a/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake
new file mode 100644
index 000000000..3e418c34b
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts-check.cmake
@@ -0,0 +1,64 @@
+#
+# Check C# VS project for required elements.
+#
+set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj")
+if(NOT EXISTS "${csProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.")
+ return()
+endif()
+
+
+set(inDebug FALSE)
+set(inRelease FALSE)
+set(debugOK FALSE)
+set(releaseOK FALSE)
+
+
+file(STRINGS "${csProjectFile}" lines)
+foreach(line IN LISTS lines)
+ #message(STATUS ${line})
+ if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64).*")
+ set(inDebug TRUE)
+ elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64).*")
+ set(inRelease TRUE)
+ elseif(line MATCHES "^ *</PropertyGroup> *$")
+ set(inRelease FALSE)
+ set(inDebug FALSE)
+ elseif(inDebug AND
+ (line MATCHES "^ *<NoWarn>.*505.*</NoWarn> *$") AND
+ (line MATCHES "^ *<NoWarn>.*707.*</NoWarn> *$") AND
+ (line MATCHES "^ *<NoWarn>.*808.*</NoWarn> *$") AND
+ (line MATCHES "^ *<NoWarn>.*909.*</NoWarn> *$")
+ )
+ set(debugOK TRUE)
+ elseif(inRelease AND
+ (NOT (line MATCHES "^ *<NoWarn>.*505.*</NoWarn> *$")) AND
+ (line MATCHES "^ *<NoWarn>.*707.*</NoWarn> *$") AND
+ (line MATCHES "^ *<NoWarn>.*808.*</NoWarn> *$") AND
+ (line MATCHES "^ *<NoWarn>.*909.*</NoWarn> *$")
+ )
+ set(releaseOK TRUE)
+ endif()
+endforeach()
+
+function(print_csprojfile)
+ file(STRINGS "${csProjectFile}" lines)
+ foreach(line IN LISTS lines)
+ message(STATUS ${line})
+ endforeach()
+endfunction()
+
+
+if(NOT debugOK)
+ message(STATUS "Failed to set Debug configuration warning config correctly.")
+ set(RunCMake_TEST_FAILED "Failed to set Debug configuration defines correctly.")
+ print_csprojfile()
+ return()
+endif()
+
+if(NOT releaseOK)
+ message(STATUS "Failed to set Release configuration warning config correctly.")
+ set(RunCMake_TEST_FAILED "Failed to set Release configuration defines correctly.")
+ print_csprojfile()
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts.cmake b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts.cmake
new file mode 100644
index 000000000..85af38be9
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpCompilerOpts.cmake
@@ -0,0 +1,14 @@
+enable_language(CSharp)
+
+add_library(foo SHARED
+ foo.cs)
+
+set_target_properties(foo PROPERTIES
+ LINKER_LANGUAGE CSharp)
+
+
+# Issue 18878
+target_compile_options(foo PRIVATE "/platform:anycpu" "/nowarn:707,808" "/nowarn:909" )
+
+# Debug only warning disable
+set(CMAKE_CSharp_FLAGS_DEBUG "${CMAKE_CSharp_FLAGS_DEBUG} /nowarn:505")
diff --git a/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake
index 70ea19326..9eb4619f4 100644
--- a/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake
+++ b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-check.cmake
@@ -4,20 +4,31 @@ if(NOT EXISTS "${csProjectFile}")
return()
endif()
-set(tagFound FALSE)
+# test VS_CSHARP_* for the following extensions
+set(fileExtensions
+ "cs"
+ "png"
+ "jpg"
+ "xml"
+ "settings")
+#
set(tagName "MyCustomTag")
set(tagValue "MyCustomValue")
file(STRINGS "${csProjectFile}" lines)
-foreach(line IN LISTS lines)
- if(line MATCHES "^ *<${tagName}>${tagValue}</${tagName}>")
- message(STATUS "foo.csproj has tag ${tagName} with value ${tagValue} defined")
- set(tagFound TRUE)
+
+foreach(e ${fileExtensions})
+ string(TOUPPER ${e} eUC)
+ set(tagFound FALSE)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<${tagName}${eUC}>${tagValue}${eUC}</${tagName}${eUC}>")
+ message(STATUS "foo.csproj has tag ${tagName}${eUC} with value ${tagValue}${eUC} defined")
+ set(tagFound TRUE)
+ endif()
+ endforeach()
+ if(NOT tagFound)
+ set(RunCMake_TEST_FAILED "Source file tag ${tagName}${eUC} with value ${tagValue}${eUC} not found.")
+ return()
endif()
endforeach()
-
-if(NOT tagFound)
- set(RunCMake_TEST_FAILED "Source file tag ${tagName} with value ${tagValue} not found.")
- return()
-endif()
diff --git a/Tests/RunCMake/VS10Project/VsCSharpCustomTags-stderr.txt b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-stderr.txt
new file mode 100644
index 000000000..1ea3b510b
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpCustomTags-stderr.txt
@@ -0,0 +1,3 @@
+^CMake Deprecation Warning in CMakeLists.txt:
+ The C# target "foo" is of type STATIC_LIBRARY. This is discouraged \(and
+ may be disabled in future\). Make it a SHARED library instead.$
diff --git a/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake b/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake
index c51e9c370..96be54b06 100644
--- a/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake
+++ b/Tests/RunCMake/VS10Project/VsCSharpCustomTags.cmake
@@ -1,11 +1,26 @@
enable_language(CSharp)
-add_library(foo foo.cs)
-set(props_file "${CMAKE_CURRENT_SOURCE_DIR}/my.props")
+# test VS_CSHARP_* for the following extensions
+set(fileExtensions
+ "cs"
+ "png"
+ "jpg"
+ "xml"
+ "settings")
+#
set(tagName "MyCustomTag")
set(tagValue "MyCustomValue")
-set_source_files_properties(foo.cs
- PROPERTIES
- VS_CSHARP_${tagName} "${tagValue}")
+set(fileNames)
+foreach(e ${fileExtensions})
+ set(currentFile "${CMAKE_CURRENT_BINARY_DIR}/foo.${e}")
+ list(APPEND fileNames ${currentFile})
+ file(TOUCH "${currentFile}")
+ string(TOUPPER ${e} eUC)
+ set_source_files_properties("${currentFile}"
+ PROPERTIES
+ VS_CSHARP_${tagName}${eUC} "${tagValue}${eUC}")
+endforeach()
+
+add_library(foo ${fileNames})
diff --git a/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake
new file mode 100644
index 000000000..152bf9c93
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpDefines-check.cmake
@@ -0,0 +1,64 @@
+#
+# Check C# VS project for required elements.
+#
+set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj")
+if(NOT EXISTS "${csProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.")
+ return()
+endif()
+
+
+set(inDebug FALSE)
+set(inRelease FALSE)
+set(debugOK FALSE)
+set(releaseOK FALSE)
+
+
+file(STRINGS "${csProjectFile}" lines)
+foreach(line IN LISTS lines)
+ #message(STATUS ${line})
+ if(line MATCHES "^ *<PropertyGroup .*Debug\\|(Win32|x64).*")
+ set(inDebug TRUE)
+ elseif(line MATCHES "^ *<PropertyGroup .*Release\\|(Win32|x64).*")
+ set(inRelease TRUE)
+ elseif(line MATCHES "^ *</PropertyGroup> *$")
+ set(inRelease FALSE)
+ set(inDebug FALSE)
+ elseif(inDebug AND
+ (line MATCHES "^ *<DefineConstants>.*MY_FOO_DEFINE.*</DefineConstants> *$") AND
+ (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_DEBUG.*</DefineConstants> *$") AND
+ (line MATCHES "^ *<DefineConstants>.*MY_BAR_ASSIGNMENT=bar.*</DefineConstants> *$") AND
+ (NOT (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_RELEASE.*</DefineConstants> *$"))
+ )
+ set(debugOK TRUE)
+ elseif(inRelease AND
+ (line MATCHES "^ *<DefineConstants>.*MY_FOO_DEFINE.*</DefineConstants> *$") AND
+ (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_RELEASE.*</DefineConstants> *$") AND
+ (line MATCHES "^ *<DefineConstants>.*MY_BAR_ASSIGNMENT=bar.*</DefineConstants> *$") AND
+ (NOT (line MATCHES "^ *<DefineConstants>.*DEFINE_ONLY_FOR_DEBUG.*</DefineConstants> *$"))
+ )
+ set(releaseOK TRUE)
+ endif()
+endforeach()
+
+function(print_csprojfile)
+ file(STRINGS "${csProjectFile}" lines)
+ foreach(line IN LISTS lines)
+ message(STATUS ${line})
+ endforeach()
+endfunction()
+
+
+if(NOT debugOK)
+ message(STATUS "Failed to set Debug configuration defines correctly.")
+ set(RunCMake_TEST_FAILED "Failed to set Debug configuration defines correctly.")
+ print_csprojfile()
+ return()
+endif()
+
+if(NOT releaseOK)
+ message(STATUS "Failed to set Release configuration defines correctly.")
+ set(RunCMake_TEST_FAILED "Failed to set Release configuration defines correctly.")
+ print_csprojfile()
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsCSharpDefines.cmake b/Tests/RunCMake/VS10Project/VsCSharpDefines.cmake
new file mode 100644
index 000000000..62c19c521
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpDefines.cmake
@@ -0,0 +1,18 @@
+enable_language(CSharp)
+
+add_library(foo SHARED
+ foo.cs)
+
+set_target_properties(foo PROPERTIES
+ LINKER_LANGUAGE CSharp)
+
+
+# Issue 18698
+target_compile_definitions(
+ foo
+ PUBLIC
+ MY_FOO_DEFINE
+ "MY_BAR_ASSIGNMENT=bar"
+ $<$<CONFIG:Debug>:DEFINE_ONLY_FOR_DEBUG>
+ $<$<CONFIG:Release>:DEFINE_ONLY_FOR_RELEASE>
+)
diff --git a/Tests/RunCMake/VS10Project/VsCSharpDeployFiles-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpDeployFiles-check.cmake
new file mode 100644
index 000000000..c29f2ae42
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpDeployFiles-check.cmake
@@ -0,0 +1,67 @@
+set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj")
+if(NOT EXISTS "${csProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.")
+ return()
+endif()
+
+
+set(inNode1 FALSE)
+set(foundNode1 FALSE)
+set(foundCopyDirective1 FALSE)
+
+set(inNode2 FALSE)
+set(foundNode2 FALSE)
+set(foundCopyDirective2 FALSE)
+
+set(foundNode3 FALSE)
+
+file(STRINGS "${csProjectFile}" lines)
+
+foreach(line IN LISTS lines)
+ if( inNode1 )
+ if(line MATCHES " *<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> *$")
+ set(foundCopyDirective1 TRUE)
+ elseif( line MATCHES " *</Content> *$")
+ set(inNode1 FALSE)
+ endif()
+ elseif( inNode2 )
+ if(line MATCHES " *<CopyToOutputDirectory>Always</CopyToOutputDirectory> *$")
+ set(foundCopyDirective2 TRUE)
+ elseif( line MATCHES " *</Content> *$")
+ set(inNode2 FALSE)
+ endif()
+ elseif(line MATCHES "^ *<Content *Include *= *\".*content1\\.txt\"> *")
+ set(foundNode1 TRUE)
+ set(inNode1 TRUE)
+ elseif(line MATCHES "^ *<Content *Include *= *\".*content2\\.txt\"> *")
+ set(foundNode2 TRUE)
+ set(inNode2 TRUE)
+ elseif(line MATCHES "^ *<None *Include *= *\".*content3\\.txt\"> *")
+ set(foundNode3 TRUE)
+ endif()
+endforeach()
+
+if(NOT foundNode1)
+ set(RunCMake_TEST_FAILED "Did not find <Content> item content1.txt.")
+ return()
+endif()
+
+if(NOT foundCopyDirective1)
+ set(RunCMake_TEST_FAILED "Did not find PreserveNewest for <Content> item content1.txt.")
+ return()
+endif()
+
+if(NOT foundNode2)
+ set(RunCMake_TEST_FAILED "Did not find <Content> item content2.txt.")
+ return()
+endif()
+
+if(NOT foundCopyDirective2)
+ set(RunCMake_TEST_FAILED "Did not find Always for <Content> item content2.txt.")
+ return()
+endif()
+
+if(NOT foundNode3)
+ set(RunCMake_TEST_FAILED "Did not find <None> item content3.txt.")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsCSharpDeployFiles.cmake b/Tests/RunCMake/VS10Project/VsCSharpDeployFiles.cmake
new file mode 100644
index 000000000..cb77fa7dd
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpDeployFiles.cmake
@@ -0,0 +1,27 @@
+enable_language(CSharp)
+
+set(fileNames
+ "${CMAKE_CURRENT_BINARY_DIR}/content1.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/content2.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/content3.txt")
+
+foreach(f ${fileNames})
+ message(STATUS "touch ${f}")
+ file(TOUCH ${f})
+endforeach()
+
+set_source_files_properties( "${CMAKE_CURRENT_BINARY_DIR}/content1.txt"
+ PROPERTIES
+ VS_COPY_TO_OUT_DIR PreserveNewest
+)
+
+set_source_files_properties( "${CMAKE_CURRENT_BINARY_DIR}/content2.txt"
+ PROPERTIES
+ VS_COPY_TO_OUT_DIR Always
+)
+
+
+add_library(foo SHARED
+ foo.cs
+ ${fileNames}
+)
diff --git a/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-check.cmake
new file mode 100644
index 000000000..8b9bb6731
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-check.cmake
@@ -0,0 +1,49 @@
+set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj")
+if(NOT EXISTS "${csProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.")
+ return()
+endif()
+
+set(test1Reference "System")
+set(test1Tag "Hello")
+set(test1Value "World")
+
+set(test2Reference "foo2")
+set(test2Tag "Hallo")
+set(test2Value "Welt")
+
+set(tag1Found FALSE)
+set(ref1Found FALSE)
+
+file(STRINGS "${csProjectFile}" lines)
+
+foreach(i 1 2)
+ set(testReference "${test${i}Reference}")
+ set(testTag "${test${i}Tag}")
+ set(testValue "${test${i}Value}")
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<(Project|)Reference .*>$")
+ set(validTag FALSE)
+ if(line MATCHES "^ *<(Project|)Reference .*\".*${testReference}.*\".*>$")
+ set(validTag TRUE)
+ message(STATUS "foo.csproj is using reference ${testReference}")
+ set(ref${i}Found TRUE)
+ endif()
+ endif()
+ if(line MATCHES "^ *<${testTag}>${testValue}</${testTag}>$")
+ if(validTag)
+ message(STATUS "foo.csproj reference ${testReference} has tag ${testTag}")
+ set(tag${i}Found TRUE)
+ else()
+ message(STATUS "tag ${testTag} found in wrong place!")
+ set(tag${i}Found FALSE)
+ endif()
+ endif()
+ endforeach()
+endforeach()
+
+if(NOT tag1Found OR NOT ref1Found OR
+ NOT tag2Found OR NOT ref2Found)
+ set(RunCMake_TEST_FAILED "Custom reference XML tag not found.")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-stderr.txt b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-stderr.txt
new file mode 100644
index 000000000..4402b8f57
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Deprecation Warning in CMakeLists.txt:
+ The C# target "foo2" is of type STATIC_LIBRARY. This is discouraged \(and
+ may be disabled in future\). Make it a SHARED library instead.
+
+
+CMake Deprecation Warning in CMakeLists.txt:
+ The C# target "foo" is of type STATIC_LIBRARY. This is discouraged \(and
+ may be disabled in future\). Make it a SHARED library instead.$
diff --git a/Tests/RunCMake/VS10Project/VsCSharpReferenceProps.cmake b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps.cmake
new file mode 100644
index 000000000..2af17569e
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpReferenceProps.cmake
@@ -0,0 +1,19 @@
+enable_language(CSharp)
+add_library(foo foo.cs)
+add_library(foo2 foo.cs)
+
+set(test1Reference "System")
+set(test1Tag "Hello")
+set(test1Value "World")
+
+set(test2Reference "foo2")
+set(test2Tag "Hallo")
+set(test2Value "Welt")
+
+target_link_libraries(foo foo2)
+
+set_target_properties(foo PROPERTIES
+ VS_DOTNET_REFERENCES "${test1Reference};Blubb"
+ VS_DOTNET_REFERENCEPROP_${test1Reference}_TAG_${test1Tag} ${test1Value}
+ VS_DOTNET_REFERENCEPROP_${test2Reference}_TAG_${test2Tag} ${test2Value}
+ )
diff --git a/Tests/RunCMake/VS10Project/VsCSharpWithoutSources-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpWithoutSources-check.cmake
new file mode 100644
index 000000000..90ae7c3c0
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpWithoutSources-check.cmake
@@ -0,0 +1,5 @@
+set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj")
+if(NOT EXISTS "${csProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsCSharpWithoutSources.cmake b/Tests/RunCMake/VS10Project/VsCSharpWithoutSources.cmake
new file mode 100644
index 000000000..5fdeaa0a2
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCSharpWithoutSources.cmake
@@ -0,0 +1,7 @@
+enable_language(CSharp)
+
+add_library(foo SHARED
+ "${CMAKE_CURRENT_LIST_FILE}")
+
+set_target_properties(foo PROPERTIES
+ LINKER_LANGUAGE CSharp)
diff --git a/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake b/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake
index 4690970a3..bbd34da14 100644
--- a/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake
+++ b/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake
@@ -9,7 +9,7 @@ file(STRINGS "${vcProjectFile}" lines)
foreach(line IN LISTS lines)
if(line MATCHES "^ *<ConfigurationType>(.*)</ConfigurationType>$")
set(propertyFound TRUE)
- set(expectedValue "MyValue")
+ set(expectedValue "MyValue foo")
set(actualValue ${CMAKE_MATCH_1})
if(NOT (${actualValue} STREQUAL ${expectedValue}))
set(RunCMake_TEST_FAILED "ConfigurationType \"${actualValue}\" differs from expected value \"${expectedValue}\".")
diff --git a/Tests/RunCMake/VS10Project/VsConfigurationType.cmake b/Tests/RunCMake/VS10Project/VsConfigurationType.cmake
index a73dfe8c0..a2f544aa9 100644
--- a/Tests/RunCMake/VS10Project/VsConfigurationType.cmake
+++ b/Tests/RunCMake/VS10Project/VsConfigurationType.cmake
@@ -1,3 +1,3 @@
enable_language(CXX)
add_library(foo foo.cpp)
-set_target_properties(foo PROPERTIES VS_CONFIGURATION_TYPE "MyValue")
+set_target_properties(foo PROPERTIES VS_CONFIGURATION_TYPE "MyValue $<TARGET_PROPERTY:foo,NAME>")
diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake
new file mode 100644
index 000000000..00288d483
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDebuggerCommand-check.cmake
@@ -0,0 +1,24 @@
+foreach(target foo bar)
+ set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${target}.vcxproj")
+ if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+ endif()
+
+ set(debuggerCommandSet FALSE)
+
+ file(STRINGS "${vcProjectFile}" lines)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<LocalDebuggerCommand[^>]*>([^<>]+)</LocalDebuggerCommand>$")
+ if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command foo")
+ message(STATUS "${target}.vcxproj has debugger command set")
+ set(debuggerCommandSet TRUE)
+ endif()
+ endif()
+ endforeach()
+
+ if(NOT debuggerCommandSet)
+ set(RunCMake_TEST_FAILED "LocalDebuggerCommand not found or not set correctly.")
+ return()
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake
new file mode 100644
index 000000000..54f91549f
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDebuggerCommand.cmake
@@ -0,0 +1,6 @@
+enable_language(CXX)
+add_library(foo foo.cpp)
+add_custom_target(bar)
+
+set_target_properties(foo bar PROPERTIES
+ VS_DEBUGGER_COMMAND "my-debugger-command $<TARGET_PROPERTY:foo,NAME>")
diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake
new file mode 100644
index 000000000..87555d1f5
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments-check.cmake
@@ -0,0 +1,24 @@
+foreach(target foo bar)
+ set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${target}.vcxproj")
+ if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+ endif()
+
+ set(debuggerCommandArgumentsSet FALSE)
+
+ file(STRINGS "${vcProjectFile}" lines)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<LocalDebuggerCommandArguments[^>]*>([^<>]+)</LocalDebuggerCommandArguments>$")
+ if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-command-arguments foo")
+ message(STATUS "${target}.vcxproj has debugger command arguments set")
+ set(debuggerCommandArgumentsSet TRUE)
+ endif()
+ endif()
+ endforeach()
+
+ if(NOT debuggerCommandArgumentsSet)
+ set(RunCMake_TEST_FAILED "LocalDebuggerCommandArguments not found or not set correctly.")
+ return()
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake
new file mode 100644
index 000000000..1f7d0be49
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDebuggerCommandArguments.cmake
@@ -0,0 +1,6 @@
+enable_language(CXX)
+add_library(foo foo.cpp)
+add_custom_target(bar)
+
+set_target_properties(foo bar PROPERTIES
+ VS_DEBUGGER_COMMAND_ARGUMENTS "my-debugger-command-arguments $<TARGET_PROPERTY:foo,NAME>")
diff --git a/Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake
new file mode 100644
index 000000000..fee121a5e
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment-check.cmake
@@ -0,0 +1,24 @@
+foreach(target foo bar)
+ set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${target}.vcxproj")
+ if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+ endif()
+
+ set(debuggerEnvironmentSet FALSE)
+
+ file(STRINGS "${vcProjectFile}" lines)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<LocalDebuggerEnvironment[^>]*>([^<>]+)</LocalDebuggerEnvironment>$")
+ if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-environment foo")
+ message(STATUS "${target}.vcxproj has debugger environment set")
+ set(debuggerEnvironmentSet TRUE)
+ endif()
+ endif()
+ endforeach()
+
+ if(NOT debuggerEnvironmentSet)
+ set(RunCMake_TEST_FAILED "LocalDebuggerEnvironment not found or not set correctly.")
+ return()
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake
new file mode 100644
index 000000000..c594f3532
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDebuggerEnvironment.cmake
@@ -0,0 +1,6 @@
+enable_language(CXX)
+add_library(foo foo.cpp)
+add_custom_target(bar)
+
+set_target_properties(foo bar PROPERTIES
+ VS_DEBUGGER_ENVIRONMENT "my-debugger-environment $<TARGET_PROPERTY:foo,NAME>")
diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake
index 637c68c60..9d3f2a850 100644
--- a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake
+++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir-check.cmake
@@ -1,22 +1,24 @@
-set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
-if(NOT EXISTS "${vcProjectFile}")
- set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
- return()
-endif()
+foreach(target foo bar)
+ set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${target}.vcxproj")
+ if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+ endif()
-set(debuggerWorkDirSet FALSE)
+ set(debuggerWorkDirSet FALSE)
-file(STRINGS "${vcProjectFile}" lines)
-foreach(line IN LISTS lines)
- if(line MATCHES "^ *<LocalDebuggerWorkingDirectory[^>]*>([^<>]+)</LocalDebuggerWorkingDirectory>$")
- if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory")
- message(STATUS "foo.vcxproj has debugger working dir set")
- set(debuggerWorkDirSet TRUE)
+ file(STRINGS "${vcProjectFile}" lines)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<LocalDebuggerWorkingDirectory[^>]*>([^<>]+)</LocalDebuggerWorkingDirectory>$")
+ if("${CMAKE_MATCH_1}" STREQUAL "my-debugger-directory foo")
+ message(STATUS "${target}.vcxproj has debugger working dir set")
+ set(debuggerWorkDirSet TRUE)
+ endif()
endif()
+ endforeach()
+
+ if(NOT debuggerWorkDirSet)
+ set(RunCMake_TEST_FAILED "LocalDebuggerWorkingDirectory not found or not set correctly.")
+ return()
endif()
endforeach()
-
-if(NOT debuggerWorkDirSet)
- set(RunCMake_TEST_FAILED "LocalDebuggerWorkingDirectory not found or not set correctly.")
- return()
-endif()
diff --git a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake
index a277c6575..69ed85c62 100644
--- a/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake
+++ b/Tests/RunCMake/VS10Project/VsDebuggerWorkingDir.cmake
@@ -1,5 +1,6 @@
enable_language(CXX)
add_library(foo foo.cpp)
+add_custom_target(bar)
-set_target_properties(foo PROPERTIES
- VS_DEBUGGER_WORKING_DIRECTORY "my-debugger-directory")
+set_target_properties(foo bar PROPERTIES
+ VS_DEBUGGER_WORKING_DIRECTORY "my-debugger-directory $<TARGET_PROPERTY:foo,NAME>")
diff --git a/Tests/RunCMake/VS10Project/VsDpiAware-check.cmake b/Tests/RunCMake/VS10Project/VsDpiAware-check.cmake
new file mode 100644
index 000000000..fbb64f0d3
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDpiAware-check.cmake
@@ -0,0 +1,41 @@
+macro(VSDpiAware_check tgt dpiaware_match_expect)
+ set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj")
+ if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.")
+ return()
+ endif()
+
+ set(HAVE_DPIAWARE_MATCH 0)
+ set(IN_MANIFEST_SETTINGS 0)
+
+ file(STRINGS "${vcProjectFile}" lines)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<Manifest>")
+ set(IN_MANIFEST_SETTINGS 1)
+ elseif(line MATCHES "^ *</Manifest>")
+ set(IN_MANIFEST_SETTINGS 0)
+ elseif(IN_MANIFEST_SETTINGS AND (line MATCHES "^ *<EnableDpiAwareness>([^<>]+)</EnableDpiAwareness>"))
+ set(dpiaware_match_actual "${CMAKE_MATCH_1}")
+ if(NOT "${dpiaware_match_actual}" STREQUAL "${dpiaware_match_expect}")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <EnableDpiAwareness> '${dpiaware_match_actual}', not '${dpiaware_match_expect}'.")
+ return()
+ endif()
+ set(HAVE_DPIAWARE_MATCH 1)
+ break()
+ endif()
+ endforeach()
+
+ if(NOT HAVE_DPIAWARE_MATCH AND NOT "${dpiaware_match_expect}" STREQUAL "")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a <EnableDpiAwareness> property group.")
+ return()
+ endif()
+endmacro()
+
+VSDpiAware_check(DPIAWARE-default-C "")
+VSDpiAware_check(DPIAWARE-default-CXX "")
+VSDpiAware_check(DPIAWARE-TGT-PERMONITOR-C "PerMonitorHighDPIAware")
+VSDpiAware_check(DPIAWARE-TGT-PERMONITOR-CXX "PerMonitorHighDPIAware")
+VSDpiAware_check(DPIAWARE-TGT-ON-C "true")
+VSDpiAware_check(DPIAWARE-TGT-ON-CXX "true")
+VSDpiAware_check(DPIAWARE-TGT-OFF-C "false")
+VSDpiAware_check(DPIAWARE-TGT-OFF-CXX "false")
diff --git a/Tests/RunCMake/VS10Project/VsDpiAware.cmake b/Tests/RunCMake/VS10Project/VsDpiAware.cmake
new file mode 100644
index 000000000..74e3d212c
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDpiAware.cmake
@@ -0,0 +1,19 @@
+set(CMAKE_CONFIGURATION_TYPES Debug)
+enable_language(C)
+enable_language(CXX)
+
+add_executable(DPIAWARE-default-C empty.c)
+add_executable(DPIAWARE-default-CXX empty.cxx)
+
+add_executable(DPIAWARE-TGT-PERMONITOR-C empty.c)
+set_property(TARGET DPIAWARE-TGT-PERMONITOR-C PROPERTY VS_DPI_AWARE "PerMonitor")
+add_executable(DPIAWARE-TGT-PERMONITOR-CXX empty.cxx)
+set_property(TARGET DPIAWARE-TGT-PERMONITOR-CXX PROPERTY VS_DPI_AWARE "PerMonitor")
+add_executable(DPIAWARE-TGT-ON-C empty.c)
+set_property(TARGET DPIAWARE-TGT-ON-C PROPERTY VS_DPI_AWARE ON)
+add_executable(DPIAWARE-TGT-ON-CXX empty.cxx)
+set_property(TARGET DPIAWARE-TGT-ON-CXX PROPERTY VS_DPI_AWARE ON)
+add_executable(DPIAWARE-TGT-OFF-C empty.c)
+set_property(TARGET DPIAWARE-TGT-OFF-C PROPERTY VS_DPI_AWARE OFF)
+add_executable(DPIAWARE-TGT-OFF-CXX empty.cxx)
+set_property(TARGET DPIAWARE-TGT-OFF-CXX PROPERTY VS_DPI_AWARE OFF)
diff --git a/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-result.txt b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-stderr.txt b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-stderr.txt
new file mode 100644
index 000000000..95fc5caec
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error: Bad parameter for VS_DPI_AWARE: Bar
+CMake Error: Bad parameter for VS_DPI_AWARE: Foo
+CMake Generate step failed. Build files cannot be regenerated correctly.
diff --git a/Tests/RunCMake/VS10Project/VsDpiAwareBadParam.cmake b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam.cmake
new file mode 100644
index 000000000..e05452bf9
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam.cmake
@@ -0,0 +1,8 @@
+set(CMAKE_CONFIGURATION_TYPES Debug)
+enable_language(C)
+enable_language(CXX)
+
+add_executable(DPIAWARE-TGT-BADPARAM-C empty.c)
+set_property(TARGET DPIAWARE-TGT-BADPARAM-C PROPERTY VS_DPI_AWARE "Foo")
+add_executable(DPIAWARE-TGT-BADPARAM-CXX empty.cxx)
+set_property(TARGET DPIAWARE-TGT-BADPARAM-CXX PROPERTY VS_DPI_AWARE "Bar")
diff --git a/Tests/RunCMake/VS10Project/VsGlobals-check.cmake b/Tests/RunCMake/VS10Project/VsGlobals-check.cmake
new file mode 100644
index 000000000..0e7fd45c1
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsGlobals-check.cmake
@@ -0,0 +1,44 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
+if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+endif()
+
+set(InsideGlobals FALSE)
+set(DefaultLanguageSet FALSE)
+set(MinimumVisualStudioVersionSet FALSE)
+
+file(STRINGS "${vcProjectFile}" lines)
+foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<PropertyGroup Label=\"Globals\"> *$")
+ set(InsideGlobals TRUE)
+ elseif(line MATCHES "^ *<DefaultLanguage>([a-zA-Z\\-]+)</DefaultLanguage> *$")
+ if("${CMAKE_MATCH_1}" STREQUAL "en-US")
+ if(InsideGlobals)
+ message(STATUS "foo.vcxproj has correct DefaultLanguage global property")
+ set(DefaultLanguageSet TRUE)
+ else()
+ message(STATUS "DefaultLanguage is set but not within \"Globals\" property group")
+ endif()
+ endif()
+ elseif(line MATCHES "^ *<MinimumVisualStudioVersion>([0-9\\.]+)</MinimumVisualStudioVersion> *$")
+ if("${CMAKE_MATCH_1}" STREQUAL "14.0")
+ if(InsideGlobals)
+ message(STATUS "foo.vcxproj has correct MinimumVisualStudioVersion global property")
+ set(MinimumVisualStudioVersionSet TRUE)
+ else()
+ message(STATUS "MinimumVisualStudioVersion is set but not within \"Globals\" property group")
+ endif()
+ endif()
+ endif()
+endforeach()
+
+if(NOT DefaultLanguageSet)
+ set(RunCMake_TEST_FAILED "DefaultLanguageSet not found or not set correctly.")
+ return()
+endif()
+
+if(NOT MinimumVisualStudioVersionSet)
+ set(RunCMake_TEST_FAILED "MinimumVisualStudioVersionSet not found or not set correctly.")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsGlobals.cmake b/Tests/RunCMake/VS10Project/VsGlobals.cmake
new file mode 100644
index 000000000..a3ed5afa9
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsGlobals.cmake
@@ -0,0 +1,8 @@
+enable_language(CXX)
+
+set(CMAKE_VS_GLOBALS
+ "DefaultLanguage=en-US"
+ "MinimumVisualStudioVersion=14.0"
+)
+
+add_library(foo foo.cpp)
diff --git a/Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake b/Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake
new file mode 100644
index 000000000..7119976f0
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsJustMyCode-check.cmake
@@ -0,0 +1,38 @@
+macro(VsJustMyCode_check tgt jmc_expect)
+ set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj")
+ if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.")
+ return()
+ endif()
+
+ set(HAVE_JMC 0)
+
+ file(STRINGS "${vcProjectFile}" lines)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<SupportJustMyCode>([^<>]+)</SupportJustMyCode>")
+ set(jmc_actual "${CMAKE_MATCH_1}")
+ if(NOT "${jmc_actual}" STREQUAL "${jmc_expect}")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <SupportJustMyCode> '${jmc_actual}', not '${jmc_expect}'.")
+ return()
+ endif()
+ set(HAVE_JMC 1)
+ break()
+ endif()
+ endforeach()
+
+ if(NOT HAVE_JMC AND NOT "${jmc_expect}" STREQUAL "")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a <SupportJustMyCode> property group.")
+ return()
+ endif()
+endmacro()
+
+VsJustMyCode_check(JMC-default-C "")
+VsJustMyCode_check(JMC-default-CXX "")
+VsJustMyCode_check(JMC-ON-C true)
+VsJustMyCode_check(JMC-ON-CXX true)
+VsJustMyCode_check(JMC-OFF-C "")
+VsJustMyCode_check(JMC-OFF-CXX "")
+VsJustMyCode_check(JMC-TGT-ON-C true)
+VsJustMyCode_check(JMC-TGT-ON-CXX true)
+VsJustMyCode_check(JMC-TGT-OFF-C "")
+VsJustMyCode_check(JMC-TGT-OFF-CXX "")
diff --git a/Tests/RunCMake/VS10Project/VsJustMyCode.cmake b/Tests/RunCMake/VS10Project/VsJustMyCode.cmake
new file mode 100644
index 000000000..b39f30f6c
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsJustMyCode.cmake
@@ -0,0 +1,24 @@
+set(CMAKE_CONFIGURATION_TYPES Debug)
+enable_language(C)
+enable_language(CXX)
+
+add_library(JMC-default-C empty.c)
+add_library(JMC-default-CXX empty.cxx)
+
+set(CMAKE_VS_JUST_MY_CODE_DEBUGGING OFF)
+add_library(JMC-OFF-C empty.c)
+add_library(JMC-OFF-CXX empty.cxx)
+
+set(CMAKE_VS_JUST_MY_CODE_DEBUGGING ON)
+add_library(JMC-ON-C empty.c)
+add_library(JMC-ON-CXX empty.cxx)
+
+set(CMAKE_VS_JUST_MY_CODE_DEBUGGING OFF)
+add_library(JMC-TGT-ON-C empty.c)
+set_property(TARGET JMC-TGT-ON-C PROPERTY VS_JUST_MY_CODE_DEBUGGING ON)
+add_library(JMC-TGT-ON-CXX empty.cxx)
+set_property(TARGET JMC-TGT-ON-CXX PROPERTY VS_JUST_MY_CODE_DEBUGGING ON)
+add_library(JMC-TGT-OFF-C empty.c)
+set_property(TARGET JMC-TGT-OFF-C PROPERTY VS_JUST_MY_CODE_DEBUGGING OFF)
+add_library(JMC-TGT-OFF-CXX empty.cxx)
+set_property(TARGET JMC-TGT-OFF-CXX PROPERTY VS_JUST_MY_CODE_DEBUGGING OFF)
diff --git a/Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake b/Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake
new file mode 100644
index 000000000..512a1c99c
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake
@@ -0,0 +1,39 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
+if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file foo.vcxproj does not exist.")
+ return()
+endif()
+
+
+set(test1Library "boost")
+set(test1Version "1.7.0")
+
+
+set(test2Library "SFML")
+set(test2Version "2.2.0")
+
+set(Library1Found FALSE)
+set(Library2Found FALSE)
+
+file(STRINGS "${vcProjectFile}" lines)
+
+foreach(i 1 2)
+ set(testLibrary "${test${i}Library}")
+ set(testVersion "${test${i}Version}")
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<PackageReference Include=\"${testLibrary}\".*>$")
+ if(line MATCHES "^ *<PackageReference .* Version=\"${testVersion}\".*>$")
+ set(Library${i}Found TRUE)
+ message(STATUS "foo.vcxproj is using package reference ${testLibrary} with version ${testVersion}")
+ else()
+ message(STATUS "foo.vcxproj failed to define reference ${testLibrary} with version ${testVersion}")
+ set(Library${i}Found FALSE)
+ endif()
+ endif()
+ endforeach()
+endforeach()
+
+if(NOT Library1Found OR NOT Library2Found)
+ set(RunCMake_TEST_FAILED "Failed to find package references")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsPackageReferences.cmake b/Tests/RunCMake/VS10Project/VsPackageReferences.cmake
new file mode 100644
index 000000000..224ab18d7
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsPackageReferences.cmake
@@ -0,0 +1,4 @@
+enable_language(CXX)
+add_library(foo foo.cpp)
+
+set_property(TARGET foo PROPERTY VS_PACKAGE_REFERENCES "boost_1.7.0;SFML_2.2.0")
diff --git a/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake b/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake
new file mode 100644
index 000000000..91cea0ef8
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsPrecompileHeaders-check.cmake
@@ -0,0 +1,66 @@
+set(pch_header "CMakeFiles/tgt.dir/cmake_pch.hxx")
+set(pch_source [=[CMakeFiles\\tgt.dir\\cmake_pch.cxx]=])
+
+if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/${pch_header}")
+ set(RunCMake_TEST_FAILED "Generated PCH header ${pch_header} does not exist.")
+ return()
+endif()
+if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/${pch_source}")
+ set(RunCMake_TEST_FAILED "Generated PCH header ${pch_source} does not exist.")
+ return()
+endif()
+
+set(tgt_project "${RunCMake_TEST_BINARY_DIR}/tgt.vcxproj")
+if (NOT EXISTS "${tgt_project}")
+ set(RunCMake_TEST_FAILED "Generated project file ${tgt_project} doesn't exist.")
+ return()
+endif()
+
+file(STRINGS ${tgt_project} tgt_projects_strings)
+
+foreach(line IN LISTS tgt_projects_strings)
+ if (line MATCHES "<PrecompiledHeader.*>Use</PrecompiledHeader>")
+ set(have_pch_use ON)
+ endif()
+
+ if (line MATCHES "<PrecompiledHeader.*>Create</PrecompiledHeader>")
+ set(have_pch_create ON)
+ endif()
+
+ if (line MATCHES "<PrecompiledHeaderFile.*>.*${pch_header}</PrecompiledHeaderFile>")
+ set(have_pch_header ON)
+ endif()
+
+ if (line MATCHES "<ForcedIncludeFiles.*>.*${pch_header}.*</ForcedIncludeFiles>")
+ set(have_force_pch_header ON)
+ endif()
+
+ if (line MATCHES "<ClCompile Include=.*${pch_source}\">")
+ set(have_pch_source_compile ON)
+ endif()
+endforeach()
+
+if (NOT have_pch_use)
+ set(RunCMake_TEST_FAILED "Generated project should have the <PrecompiledHeader>Use</PrecompiledHeader> block.")
+ return()
+endif()
+
+if (NOT have_pch_create)
+ set(RunCMake_TEST_FAILED "Generated project should have the <PrecompiledHeader>Create</PrecompiledHeader> block.")
+ return()
+endif()
+
+if (NOT have_pch_header)
+ set(RunCMake_TEST_FAILED "Generated project should have the <PrecompiledHeaderFile>${pch_header}</PrecompiledHeaderFile> block.")
+ return()
+endif()
+
+if (NOT have_force_pch_header)
+ set(RunCMake_TEST_FAILED "Generated project should have the <ForcedIncludeFiles>${pch_header}</ForcedIncludeFiles> block.")
+ return()
+endif()
+
+if (NOT have_pch_source_compile)
+ set(RunCMake_TEST_FAILED "Generated project should have the <ClCompile Include=\"${pch_source}\"> block.")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsPrecompileHeaders.cmake b/Tests/RunCMake/VS10Project/VsPrecompileHeaders.cmake
new file mode 100644
index 000000000..6d208c988
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsPrecompileHeaders.cmake
@@ -0,0 +1,4 @@
+project(VsPrecompileHeaders CXX)
+
+add_library(tgt SHARED empty.cxx)
+target_precompile_headers(tgt PRIVATE stdafx.h)
diff --git a/Tests/RunCMake/VS10Project/VsPrecompileHeadersReuseFromCompilePDBName-result.txt b/Tests/RunCMake/VS10Project/VsPrecompileHeadersReuseFromCompilePDBName-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsPrecompileHeadersReuseFromCompilePDBName-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/VS10Project/VsPrecompileHeadersReuseFromCompilePDBName-stderr.txt b/Tests/RunCMake/VS10Project/VsPrecompileHeadersReuseFromCompilePDBName-stderr.txt
new file mode 100644
index 000000000..2ff57cda4
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsPrecompileHeadersReuseFromCompilePDBName-stderr.txt
@@ -0,0 +1,7 @@
+CMake Error at VsPrecompileHeadersReuseFromCompilePDBName.cmake:6 \(add_library\):
+ PRECOMPILE_HEADERS_REUSE_FROM property is set on target \("b"\). Reusable
+ precompile headers requires the COMPILE_PDB_NAME property to have the value
+ "a"
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/VS10Project/VsPrecompileHeadersReuseFromCompilePDBName.cmake b/Tests/RunCMake/VS10Project/VsPrecompileHeadersReuseFromCompilePDBName.cmake
new file mode 100644
index 000000000..ec1100805
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsPrecompileHeadersReuseFromCompilePDBName.cmake
@@ -0,0 +1,9 @@
+project(VsPrecompileHeadersReuseFromCompilePDBName CXX)
+
+add_library(a SHARED empty.cxx)
+target_precompile_headers(a PRIVATE <windows.h>)
+
+add_library(b SHARED empty.cxx)
+target_precompile_headers(b REUSE_FROM a)
+
+set_target_properties(b PROPERTIES COMPILE_PDB_NAME b)
diff --git a/Tests/RunCMake/VS10Project/VsProjectImport-check.cmake b/Tests/RunCMake/VS10Project/VsProjectImport-check.cmake
new file mode 100644
index 000000000..e438bf46d
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsProjectImport-check.cmake
@@ -0,0 +1,28 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
+if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+endif()
+
+set(test1Import "path\\\\to\\\\nuget_packages\\\\Foo.1.0.0\\\\build\\\\Foo.props")
+set(test2Import "path\\\\to\\\\nuget_packages\\\\Bar.1.0.0\\\\build\\\\Bar.props")
+
+set(import1Found FALSE)
+set(import2Found FALSE)
+
+file(STRINGS "${vcProjectFile}" lines)
+
+foreach(i 1 2)
+ set(testImport "${test${i}Import}")
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<Import Project=\".*${test1Import}\" />$")
+ message(STATUS "foo.vcxproj is using project import ${testImport}")
+ set(import${i}Found TRUE)
+ endif()
+ endforeach()
+endforeach()
+
+if(NOT import1Found OR NOT import2Found)
+ set(RunCMake_TEST_FAILED "Imported project not found.")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsProjectImport.cmake b/Tests/RunCMake/VS10Project/VsProjectImport.cmake
new file mode 100644
index 000000000..70bddedf8
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsProjectImport.cmake
@@ -0,0 +1,11 @@
+enable_language(CXX)
+add_library(foo foo.cpp)
+
+set(test1Import "path/to/nuget_packages/Foo.1.0.0/build/Foo.props")
+set(test2Import "path/to/nuget_packages/Bar.1.0.0/build/Bar.props")
+
+set_property(TARGET foo PROPERTY
+ VS_PROJECT_IMPORT
+ ${test1Import}
+ ${test2Import}
+ )
diff --git a/Tests/RunCMake/VS10Project/VsSdkDirectories-check.cmake b/Tests/RunCMake/VS10Project/VsSdkDirectories-check.cmake
new file mode 100644
index 000000000..c21afb642
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsSdkDirectories-check.cmake
@@ -0,0 +1,88 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
+if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+endif()
+
+set(ExecutablePathSet FALSE)
+set(IncludePathSet FALSE)
+set(ReferencePathSet FALSE)
+set(LibraryPathSet FALSE)
+set(LibraryWPathSet FALSE)
+set(SourcePathSet FALSE)
+set(ExcludePathSet FALSE)
+
+file(STRINGS "${vcProjectFile}" lines)
+foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<ExecutablePath[^>]*>([^<>]+)</ExecutablePath>$")
+ if("${CMAKE_MATCH_1}" STREQUAL "$(VC_ExecutablePath_x86);C:\\Program Files\\Custom-SDK\\;")
+ message(STATUS "foo.vcxproj has executable path set")
+ set(ExecutablePathSet TRUE)
+ endif()
+ elseif(line MATCHES "^ *<IncludePath[^>]*>([^<>]+)</IncludePath>$")
+ if("${CMAKE_MATCH_1}" STREQUAL "$(VC_IncludePath);C:\\Program Files\\Custom-SDK\\;")
+ message(STATUS "foo.vcxproj has include path set")
+ set(IncludePathSet TRUE)
+ endif()
+ elseif(line MATCHES "^ *<ReferencePath[^>]*>([^<>]+)</ReferencePath>$")
+ if("${CMAKE_MATCH_1}" STREQUAL "$(VC_ReferencesPath_x86);C:\\Program Files\\Custom-SDK\\;")
+ message(STATUS "foo.vcxproj has reference path set")
+ set(ReferencePathSet TRUE)
+ endif()
+ elseif(line MATCHES "^ *<LibraryPath[^>]*>([^<>]+)</LibraryPath>$")
+ if("${CMAKE_MATCH_1}" STREQUAL "$(VC_LibraryPath_x86);C:\\Program Files\\Custom-SDK\\;")
+ message(STATUS "foo.vcxproj has library path set")
+ set(LibraryPathSet TRUE)
+ endif()
+ elseif(line MATCHES "^ *<LibraryWPath[^>]*>([^<>]+)</LibraryWPath>$")
+ if("${CMAKE_MATCH_1}" STREQUAL "$(WindowsSDK_MetadataPath);C:\\Program Files\\Custom-SDK\\;")
+ message(STATUS "foo.vcxproj has library WinRT path set")
+ set(LibraryWPathSet TRUE)
+ endif()
+ elseif(line MATCHES "^ *<SourcePath[^>]*>([^<>]+)</SourcePath>$")
+ if("${CMAKE_MATCH_1}" STREQUAL "$(VC_SourcePath);C:\\Program Files\\Custom-SDK\\;")
+ message(STATUS "foo.vcxproj has source path set")
+ set(SourcePathSet TRUE)
+ endif()
+ elseif(line MATCHES "^ *<ExcludePath[^>]*>([^<>]+)</ExcludePath>$")
+ if("${CMAKE_MATCH_1}" STREQUAL "$(VC_IncludePath);C:\\Program Files\\Custom-SDK\\;")
+ message(STATUS "foo.vcxproj has exclude path set")
+ set(ExcludePathSet TRUE)
+ endif()
+ endif()
+endforeach()
+
+if(NOT ExecutablePathSet)
+ set(RunCMake_TEST_FAILED "ExecutablePath not found or not set correctly.")
+ return()
+endif()
+
+if(NOT IncludePathSet)
+ set(RunCMake_TEST_FAILED "IncludePath not found or not set correctly.")
+ return()
+endif()
+
+if(NOT ReferencePathSet)
+ set(RunCMake_TEST_FAILED "ReferencePath not found or not set correctly.")
+ return()
+endif()
+
+if(NOT LibraryPathSet)
+ set(RunCMake_TEST_FAILED "LibraryPath not found or not set correctly.")
+ return()
+endif()
+
+if(NOT LibraryWPathSet)
+ set(RunCMake_TEST_FAILED "LibraryWPath not found or not set correctly.")
+ return()
+endif()
+
+if(NOT SourcePathSet)
+ set(RunCMake_TEST_FAILED "SourcePath not found or not set correctly.")
+ return()
+endif()
+
+if(NOT ExcludePathSet)
+ set(RunCMake_TEST_FAILED "ExcludePath not found or not set correctly.")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsSdkDirectories.cmake b/Tests/RunCMake/VS10Project/VsSdkDirectories.cmake
new file mode 100644
index 000000000..c8f2a5a27
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsSdkDirectories.cmake
@@ -0,0 +1,11 @@
+enable_language(CXX)
+
+set(CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES "$(VC_ExecutablePath_x86);C:\\Program Files\\Custom-SDK\\;")
+set(CMAKE_VS_SDK_INCLUDE_DIRECTORIES "$(VC_IncludePath);C:\\Program Files\\Custom-SDK\\;")
+set(CMAKE_VS_SDK_REFERENCE_DIRECTORIES "$(VC_ReferencesPath_x86);C:\\Program Files\\Custom-SDK\\;")
+set(CMAKE_VS_SDK_LIBRARY_DIRECTORIES "$(VC_LibraryPath_x86);C:\\Program Files\\Custom-SDK\\;")
+set(CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES "$(WindowsSDK_MetadataPath);C:\\Program Files\\Custom-SDK\\;")
+set(CMAKE_VS_SDK_SOURCE_DIRECTORIES "$(VC_SourcePath);C:\\Program Files\\Custom-SDK\\;")
+set(CMAKE_VS_SDK_EXCLUDE_DIRECTORIES "$(VC_IncludePath);C:\\Program Files\\Custom-SDK\\;")
+
+add_library(foo foo.cpp)
diff --git a/Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake b/Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake
new file mode 100644
index 000000000..611776316
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsSpectreMitigation-check.cmake
@@ -0,0 +1,30 @@
+macro(VsSpectreMitigation_check tgt spectre_expect)
+ set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj")
+ if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.")
+ return()
+ endif()
+
+ set(HAVE_SpectreMitigation 0)
+
+ file(STRINGS "${vcProjectFile}" lines)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<SpectreMitigation>([^<>]+)</SpectreMitigation>")
+ set(spectre_actual "${CMAKE_MATCH_1}")
+ if(NOT "${spectre_actual}" STREQUAL "${spectre_expect}")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <SpectreMitigation> '${spectre_actual}', not '${spectre_expect}'.")
+ return()
+ endif()
+ set(HAVE_SpectreMitigation 1)
+ break()
+ endif()
+ endforeach()
+
+ if(NOT HAVE_SpectreMitigation AND NOT "${spectre_expect}" STREQUAL "")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a <SpectreMitigation> field.")
+ return()
+ endif()
+endmacro()
+
+VsSpectreMitigation_check(SpectreMitigationOn-C "Spectre")
+VsSpectreMitigation_check(SpectreMitigationOff-C "false")
diff --git a/Tests/RunCMake/VS10Project/VsSpectreMitigation.cmake b/Tests/RunCMake/VS10Project/VsSpectreMitigation.cmake
new file mode 100644
index 000000000..b3779d7cc
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsSpectreMitigation.cmake
@@ -0,0 +1,8 @@
+set(CMAKE_CONFIGURATION_TYPES Debug)
+enable_language(C)
+
+add_library(SpectreMitigationOn-C empty.c)
+target_compile_options(SpectreMitigationOn-C PRIVATE -Qspectre)
+
+add_library(SpectreMitigationOff-C empty.c)
+target_compile_options(SpectreMitigationOff-C PRIVATE -Qspectre-)
diff --git a/Tests/RunCMake/VS10Project/empty.c b/Tests/RunCMake/VS10Project/empty.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/empty.c
diff --git a/Tests/RunCMake/VS10Project/empty.cxx b/Tests/RunCMake/VS10Project/empty.cxx
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/empty.cxx
diff --git a/Tests/RunCMake/VS10ProjectWinCE/CMakeLists.txt b/Tests/RunCMake/VS10ProjectWinCE/CMakeLists.txt
new file mode 100644
index 000000000..91baae7eb
--- /dev/null
+++ b/Tests/RunCMake/VS10ProjectWinCE/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.5.0)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/VS10ProjectWinCE/RunCMakeTest.cmake b/Tests/RunCMake/VS10ProjectWinCE/RunCMakeTest.cmake
new file mode 100644
index 000000000..2c9067f75
--- /dev/null
+++ b/Tests/RunCMake/VS10ProjectWinCE/RunCMakeTest.cmake
@@ -0,0 +1,9 @@
+include(RunCMake)
+
+set(RunCMake_GENERATOR "Visual Studio 12 2013")
+set(RunCMake_GENERATOR_TOOLSET CE800)
+set(RunCMake_GENERATOR_INSTANCE "")
+set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=WindowsCE )
+
+run_cmake(VsCEDebuggerDeploy)
+run_cmake(VSCSharpCFProject)
diff --git a/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy-check.cmake b/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy-check.cmake
new file mode 100644
index 000000000..b1deb9907
--- /dev/null
+++ b/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy-check.cmake
@@ -0,0 +1,118 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
+if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+endif()
+
+
+if( NOT ${CMAKE_SYSTEM_NAME} STREQUAL "WindowsCE" )
+ set(RunCMake_TEST_FAILED "Test only valid for WindowsCE")
+ return()
+endif()
+
+
+set(FoundCEAdditionalFiles FALSE)
+set(FoundRemoteDirectory FALSE)
+set(FoundToolsVersion4 FALSE)
+set(FoundEnableRedirectPlatform FALSE)
+set(FoundRedirectPlatformValue FALSE)
+
+
+file(STRINGS "${vcProjectFile}" lines)
+foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<CEAdditionalFiles> *foo\\.dll\\|\\\\foo\\\\src\\\\dir\\\\on\\\\host\\|\\$\\(RemoteDirectory\\)\\|0;bar\\.dll\\|\\\\bar\\\\src\\\\dir\\|\\$\\(RemoteDirectory\\)bardir\\|0.*</CEAdditionalFiles> *$")
+ set(FoundCEAdditionalFiles TRUE)
+ elseif(line MATCHES " *<RemoteDirectory>[A-Za-z0-9\\]+</RemoteDirectory> *$")
+ set(FoundRemoteDirectory TRUE)
+ elseif(line MATCHES " *<Project +.*ToolsVersion=\"4.0\".*> *$")
+ set(FoundToolsVersion4 TRUE)
+ elseif(line MATCHES "^ *<EnableRedirectPlatform>true</EnableRedirectPlatform> *$")
+ set(FoundEnableRedirectPlatform TRUE)
+ elseif(line MATCHES "^ *<RedirectPlatformValue>.+</RedirectPlatformValue> *$")
+ set(FoundRedirectPlatformValue TRUE)
+ endif()
+endforeach()
+
+if(NOT FoundCEAdditionalFiles)
+ set(RunCMake_TEST_FAILED "CEAddionalFiles not found or not set correctly.")
+ return()
+endif()
+
+if(NOT FoundRemoteDirectory)
+ set(RunCMake_TEST_FAILED "RemoteDirectory not found or not set correctly.")
+ return()
+endif()
+
+if(NOT FoundToolsVersion4)
+ set(RunCMake_TEST_FAILED "Failed to find correct ToolsVersion=\"4.0\" .")
+ return()
+endif()
+
+if(NOT FoundEnableRedirectPlatform)
+ set(RunCMake_TEST_FAILED "Failed to find EnableRedirectPlatform true property.")
+ return()
+endif()
+
+if(NOT FoundRedirectPlatformValue)
+ set(RunCMake_TEST_FAILED "Failed to find RedirectPlatformValue property.")
+ return()
+endif()
+
+#
+# Test solution file deployment items.
+#
+
+set(vcSlnFile "${RunCMake_TEST_BINARY_DIR}/VsCEDebuggerDeploy.sln")
+if(NOT EXISTS "${vcSlnFile}")
+ set(RunCMake_TEST_FAILED "Solution file ${vcSlnFile} does not exist.")
+ return()
+endif()
+
+
+if( NOT ${CMAKE_SYSTEM_NAME} STREQUAL "WindowsCE" )
+ set(RunCMake_TEST_FAILED "Test only valid for WindowsCE")
+ return()
+endif()
+
+
+set(FooProjGUID "")
+set(FoundFooProj FALSE)
+set(InFooProj FALSE)
+set(FoundReleaseDeploy FALSE)
+set(DeployConfigs Debug MinSizeRel RelWithDebInfo )
+
+file(STRINGS "${vcSlnFile}" lines)
+foreach(line IN LISTS lines)
+#message(STATUS "${line}")
+ if( (NOT InFooProj ) AND (line MATCHES "^[ \\t]*Project\\(\"{[A-F0-9-]+}\"\\) = \"foo\", \"foo.vcxproj\", \"({[A-F0-9-]+})\"[ \\t]*$"))
+ # First, identify the GUID for the foo project, and record it.
+ set(FoundFooProj TRUE)
+ set(InFooProj TRUE)
+ set(FooProjGUID ${CMAKE_MATCH_1})
+ elseif(InFooProj AND line MATCHES "EndProject")
+ set(InFooProj FALSE)
+ elseif((NOT InFooProj) AND line MATCHES "${FooProjGUID}\\.Release.*\\.Deploy\\.0")
+ # If foo's Release configuration is set to deploy, this is the error.
+ set(FoundReleaseDeploy TRUE)
+ endif()
+ if( line MATCHES "{[A-F0-9-]+}\\.([^\\|]+).*\\.Deploy\\.0" )
+ # Check that the other configurations ARE set to deploy.
+ list( REMOVE_ITEM DeployConfigs ${CMAKE_MATCH_1})
+ endif()
+endforeach()
+
+if(FoundReleaseDeploy)
+ set(RunCMake_TEST_FAILED "Release deployment not inhibited by VS_NO_SOLUTION_DEPLOY_Release.")
+ return()
+endif()
+
+if(NOT FoundFooProj)
+ set(RunCMake_TEST_FAILED "Failed to find foo project in the solution.")
+ return()
+endif()
+
+list(LENGTH DeployConfigs length)
+if( length GREATER 0 )
+ set(RunCMake_TEST_FAILED "Failed to find Deploy lines for non-Release configurations. (${length})")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy.cmake b/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy.cmake
new file mode 100644
index 000000000..611db0adb
--- /dev/null
+++ b/Tests/RunCMake/VS10ProjectWinCE/VsCEDebuggerDeploy.cmake
@@ -0,0 +1,14 @@
+enable_language(CXX)
+
+set(DEPLOY_DIR
+ "temp\\foodir"
+)
+
+add_library(foo SHARED foo.cpp)
+
+set_target_properties(foo
+ PROPERTIES
+ DEPLOYMENT_ADDITIONAL_FILES "foo.dll|\\foo\\src\\dir\\on\\host|$(RemoteDirectory)|0;bar.dll|\\bar\\src\\dir|$(RemoteDirectory)bardir|0"
+ DEPLOYMENT_REMOTE_DIRECTORY ${DEPLOY_DIR}
+ VS_NO_SOLUTION_DEPLOY $<CONFIG:Release>
+)
diff --git a/Tests/RunCMake/VS10ProjectWinCE/VsCSharpCFProject-check.cmake b/Tests/RunCMake/VS10ProjectWinCE/VsCSharpCFProject-check.cmake
new file mode 100644
index 000000000..618896ec0
--- /dev/null
+++ b/Tests/RunCMake/VS10ProjectWinCE/VsCSharpCFProject-check.cmake
@@ -0,0 +1,54 @@
+#
+# Check C# Compact Framework project for required elements.
+#
+set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj")
+if(NOT EXISTS "${csProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.")
+ return()
+endif()
+
+if( NOT ${CMAKE_SYSTEM_NAME} STREQUAL "WindowsCE" )
+ set(RunCMake_TEST_FAILED "Test only valid for WindowsCE")
+ return()
+endif()
+
+set(FoundTargetFrameworkTargetsVersion FALSE)
+set(FoundDotNetFrameworkVersion FALSE)
+set(FoundTargetFrameworkIdentifier FALSE)
+set(FoundCFTargetsImport FALSE)
+
+
+file(STRINGS "${csProjectFile}" lines)
+foreach(line IN LISTS lines)
+ #message(STATUS ${line})
+ if(line MATCHES "^ *<TargetFrameworkIdentifier>WindowsEmbeddedCompact</TargetFrameworkIdentifier> *$")
+ set(FoundTargetFrameworkIdentifier TRUE)
+ elseif(line MATCHES " *<TargetFrameworkVersion>v3.9</TargetFrameworkVersion> *$")
+ set(FoundDotNetFrameworkVersion TRUE)
+ elseif(line MATCHES " *<TargetFrameworkTargetsVersion>v8.0</TargetFrameworkTargetsVersion> *$")
+ set(FoundTargetFrameworkTargetsVersion TRUE)
+ elseif( line MATCHES " *<Import Project=\"\\$\\(MSBuildExtensionsPath\\)\\\\Microsoft\\\\\\$\\(TargetFrameworkIdentifier\\)\\\\\\$\\(TargetFrameworkTargetsVersion\\)\\\\Microsoft\\.\\$\\(TargetFrameworkIdentifier\\)\\.CSharp\\.targets\" */> *" )
+ set(FoundCFTargetsImport TRUE)
+ endif()
+endforeach()
+
+
+if(NOT FoundTargetFrameworkTargetsVersion)
+ set(RunCMake_TEST_FAILED "TargetFrameworkIdentifier not found or not set correctly.")
+ return()
+endif()
+
+if(NOT FoundDotNetFrameworkVersion)
+ set(RunCMake_TEST_FAILED "TargetFrameworkVersion not found or not set correctly.")
+ return()
+endif()
+
+if(NOT FoundTargetFrameworkIdentifier)
+ set(RunCMake_TEST_FAILED "TargetFrameworkTargetsVersion not found or not set correctly.")
+ return()
+endif()
+
+if(NOT FoundCFTargetsImport)
+ set(RunCMake_TEST_FAILED "Import of Compact Framework targets file not found or not set correctly.")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10ProjectWinCE/VsCSharpCFProject.cmake b/Tests/RunCMake/VS10ProjectWinCE/VsCSharpCFProject.cmake
new file mode 100644
index 000000000..fb2acbbe6
--- /dev/null
+++ b/Tests/RunCMake/VS10ProjectWinCE/VsCSharpCFProject.cmake
@@ -0,0 +1,8 @@
+enable_language(CSharp)
+
+add_library(foo SHARED foo.cs )
+
+set_target_properties(foo
+ PROPERTIES
+ DOTNET_TARGET_FRAMEWORK_VERSION "v3.9"
+)
diff --git a/Tests/RunCMake/VS10ProjectWinCE/foo.cpp b/Tests/RunCMake/VS10ProjectWinCE/foo.cpp
new file mode 100644
index 000000000..3695dc91e
--- /dev/null
+++ b/Tests/RunCMake/VS10ProjectWinCE/foo.cpp
@@ -0,0 +1,3 @@
+void foo()
+{
+}
diff --git a/Tests/RunCMake/VS10ProjectWinCE/foo.cs b/Tests/RunCMake/VS10ProjectWinCE/foo.cs
new file mode 100644
index 000000000..3695dc91e
--- /dev/null
+++ b/Tests/RunCMake/VS10ProjectWinCE/foo.cs
@@ -0,0 +1,3 @@
+void foo()
+{
+}
diff --git a/Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt b/Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt
new file mode 100644
index 000000000..34ac57d20
--- /dev/null
+++ b/Tests/RunCMake/VisibilityPreset/CMP0063-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0063-OLD.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0063 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt b/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt
index ca8c33f36..a63591fff 100644
--- a/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt
+++ b/Tests/RunCMake/VisibilityPreset/PropertyTypo-stderr.txt
@@ -1 +1 @@
-CMake Error: Target visibility_preset uses unsupported value \"hiden\" for CXX_VISIBILITY_PRESET
+CMake Error: Target visibility_preset uses unsupported value \"hiden\" for CXX_VISIBILITY_PRESET. The supported values are: default, hidden, protected, and internal.
diff --git a/Tests/RunCMake/WorkingDirectory/CMakeLists.txt.in b/Tests/RunCMake/WorkingDirectory/CMakeLists.txt.in
new file mode 100644
index 000000000..46047b8dd
--- /dev/null
+++ b/Tests/RunCMake/WorkingDirectory/CMakeLists.txt.in
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.11)
+project(@CASE_NAME@ NONE)
+include("@RunCMake_SOURCE_DIR@/@CASE_NAME@.cmake")
diff --git a/Tests/RunCMake/WorkingDirectory/RunCMakeTest.cmake b/Tests/RunCMake/WorkingDirectory/RunCMakeTest.cmake
new file mode 100644
index 000000000..a7685aeed
--- /dev/null
+++ b/Tests/RunCMake/WorkingDirectory/RunCMakeTest.cmake
@@ -0,0 +1,9 @@
+include(RunCTest)
+
+run_ctest(dirNotExist)
+run_ctest(buildAndTestNoBuildDir
+ --build-and-test
+ ${RunCMake_BINARY_DIR}/buildAndTestNoBuildDir
+ ${RunCMake_BINARY_DIR}/buildAndTestNoBuildDir/CMakeLists.txt # Deliberately a file
+ --build-generator "${RunCMake_GENERATOR}"
+)
diff --git a/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-check.cmake b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-check.cmake
new file mode 100644
index 000000000..fcfe4619b
--- /dev/null
+++ b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS ${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt)
+ set(RunCMake_TEST_FAILED "Default build dir ${RunCMake_TEST_BINARY_DIR} was used, should not have been")
+endif()
diff --git a/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-result.txt b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-result.txt
new file mode 100644
index 000000000..0617a38a5
--- /dev/null
+++ b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-result.txt
@@ -0,0 +1 @@
+^[^0][0-9]*$
diff --git a/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-stdout.txt b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-stdout.txt
new file mode 100644
index 000000000..da893176c
--- /dev/null
+++ b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-stdout.txt
@@ -0,0 +1 @@
+Failed to change working directory to .*[/\\]buildAndTestNoBuildDir[/\\]CMakeLists.txt :
diff --git a/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir.cmake b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir.cmake
new file mode 100644
index 000000000..ad795c472
--- /dev/null
+++ b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir.cmake
@@ -0,0 +1,7 @@
+# We want a single test that always passes. We should never actually get to
+# configure with this file, so we use a successful configure-build-test
+# sequence to denote failure of the test case.
+include(CTest)
+add_test(NAME willPass
+ COMMAND ${CMAKE_COMMAND} -E touch someFile.txt
+)
diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindCustomOptions-result.txt b/Tests/RunCMake/WorkingDirectory/dirNotExist-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_memcheck/DummyValgrindCustomOptions-result.txt
+++ b/Tests/RunCMake/WorkingDirectory/dirNotExist-result.txt
diff --git a/Tests/RunCMake/WorkingDirectory/dirNotExist-stderr.txt b/Tests/RunCMake/WorkingDirectory/dirNotExist-stderr.txt
new file mode 100644
index 000000000..3cea8906d
--- /dev/null
+++ b/Tests/RunCMake/WorkingDirectory/dirNotExist-stderr.txt
@@ -0,0 +1 @@
+Failed to change working directory to .*[/\\]dirNotExist-build[/\\]thisDirWillNotExist :
diff --git a/Tests/RunCMake/WorkingDirectory/dirNotExist-stdout.txt b/Tests/RunCMake/WorkingDirectory/dirNotExist-stdout.txt
new file mode 100644
index 000000000..58aa6e4b8
--- /dev/null
+++ b/Tests/RunCMake/WorkingDirectory/dirNotExist-stdout.txt
@@ -0,0 +1,10 @@
+Test project .*/Tests/RunCMake/WorkingDirectory/dirNotExist-build
+.* +Start 1: dirNotExist
+1/1 Test #1: dirNotExist +\.+\*\*\*Not Run +[0-9.]+ sec
++
+0% tests passed, 1 tests failed out of 1
++
+Total Test time \(real\) = +[0-9.]+ sec
++
+The following tests FAILED:
+.* +1 - dirNotExist \(Not Run\)$
diff --git a/Tests/RunCMake/WorkingDirectory/dirNotExist.cmake b/Tests/RunCMake/WorkingDirectory/dirNotExist.cmake
new file mode 100644
index 000000000..642386e85
--- /dev/null
+++ b/Tests/RunCMake/WorkingDirectory/dirNotExist.cmake
@@ -0,0 +1,6 @@
+include(CTest)
+
+add_test(NAME dirNotExist
+ COMMAND ${CMAKE_COMMAND} -E touch someFile.txt
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/thisDirWillNotExist
+)
diff --git a/Tests/RunCMake/WorkingDirectory/test.cmake.in b/Tests/RunCMake/WorkingDirectory/test.cmake.in
new file mode 100644
index 000000000..8eccd799c
--- /dev/null
+++ b/Tests/RunCMake/WorkingDirectory/test.cmake.in
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.11)
+
+set(CTEST_SITE "test-site")
+set(CTEST_BUILD_NAME "test-build-name")
+set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@")
+set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build")
+set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@")
+set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
+
+ctest_start(Experimental)
+ctest_configure()
+ctest_build()
+ctest_test()
diff --git a/Tests/RunCMake/WriteBasicConfigVersionFile/All.cmake b/Tests/RunCMake/WriteBasicConfigVersionFile/All.cmake
new file mode 100644
index 000000000..425365239
--- /dev/null
+++ b/Tests/RunCMake/WriteBasicConfigVersionFile/All.cmake
@@ -0,0 +1,884 @@
+# Hard-code architecture for test without a real compiler.
+set(CMAKE_SIZEOF_VOID_P 4)
+
+include(WriteBasicConfigVersionFile)
+
+set(_compatibilities AnyNewerVersion
+ SameMajorVersion
+ SameMinorVersion
+ ExactVersion)
+
+function(TEST_WRITE_BASIC_CONFIG_VERSION_FILE_PREPARE _version_installed)
+ set(_same_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
+ set(_no_CMAKE_SIZEOF_VOID_P "")
+ math(EXPR _diff_CMAKE_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P} + 1")
+ foreach(_compat ${_compatibilities})
+ set(_pkg ${_compat}${_version_installed})
+ string(REPLACE "." "" _pkg ${_pkg})
+ set(_filename "${CMAKE_CURRENT_BINARY_DIR}/${_pkg}ConfigVersion.cmake")
+ set(_filename_novoid "${CMAKE_CURRENT_BINARY_DIR}/${_pkg}NoVoidConfigVersion.cmake")
+ set(_filename_diffvoid "${CMAKE_CURRENT_BINARY_DIR}/${_pkg}DiffVoidConfigVersion.cmake")
+
+ set(CMAKE_SIZEOF_VOID_P ${_same_CMAKE_SIZEOF_VOID_P})
+ write_basic_config_version_file("${_filename}"
+ VERSION ${_version_installed}
+ COMPATIBILITY ${_compat})
+
+ # Test that an empty CMAKE_SIZEOF_VOID_P is accepted:
+ set(CMAKE_SIZEOF_VOID_P ${_no_CMAKE_SIZEOF_VOID_P})
+ write_basic_config_version_file("${_filename_novoid}"
+ VERSION ${_version_installed}
+ COMPATIBILITY ${_compat})
+
+ # Test that a different CMAKE_SIZEOF_VOID_P results in
+ # PACKAGE_VERSION_UNSUITABLE
+ set(CMAKE_SIZEOF_VOID_P ${_diff_CMAKE_SIZEOF_VOID_P})
+ write_basic_config_version_file("${_filename_diffvoid}"
+ VERSION ${_version_installed}
+ COMPATIBILITY ${_compat})
+ endforeach()
+endfunction()
+
+macro(TEST_WRITE_BASIC_CONFIG_VERSION_FILE_CHECK _filename)
+ include("${_filename}")
+
+ if(_expected_compatible AND NOT PACKAGE_VERSION_COMPATIBLE)
+ message(SEND_ERROR "Did not find package with version ${_version_installed} (${_version_requested} was requested)!")
+ elseif(NOT _expected_compatible AND PACKAGE_VERSION_COMPATIBLE)
+ message(SEND_ERROR "Found package with version ${_version_installed}, but ${_version_requested} was requested!")
+ endif()
+
+ if(${_expected_exact} AND NOT PACKAGE_VERSION_EXACT)
+ message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be!")
+ elseif(NOT ${_expected_exact} AND PACKAGE_VERSION_EXACT)
+ message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be!")
+ endif()
+
+ if(${_expected_unsuitable} AND NOT PACKAGE_VERSION_UNSUITABLE)
+ message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, although it should not be!")
+ elseif(NOT ${_expected_unsuitable} AND PACKAGE_VERSION_UNSUITABLE)
+ message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE not set, although it should be!")
+ endif()
+
+ unset(PACKAGE_VERSION_COMPATIBLE)
+ unset(PACKAGE_VERSION_EXACT)
+ unset(PACKAGE_VERSION_UNSUITABLE)
+endmacro()
+
+function(TEST_WRITE_BASIC_CONFIG_VERSION_FILE _version_installed
+ _version_requested
+ _expected_compatible_AnyNewerVersion
+ _expected_compatible_SameMajorVersion
+ _expected_compatible_SameMinorVersion
+ _expected_compatible_ExactVersion)
+ set(PACKAGE_FIND_VERSION ${_version_requested})
+ if("${PACKAGE_FIND_VERSION}" MATCHES [[(^([0-9]+)(\.([0-9]+)(\.([0-9]+)(\.([0-9]+))?)?)?)?$]])
+ set(PACKAGE_FIND_VERSION_MAJOR "${CMAKE_MATCH_2}")
+ set(PACKAGE_FIND_VERSION_MINOR "${CMAKE_MATCH_4}")
+ set(PACKAGE_FIND_VERSION_PATCH "${CMAKE_MATCH_6}")
+ set(PACKAGE_FIND_VERSION_TWEAK "${CMAKE_MATCH_8}")
+ else()
+ message(FATAL_ERROR "_version_requested (${_version_requested}) should be a version number")
+ endif()
+
+ if ("${_version_installed}" STREQUAL "${_version_requested}")
+ set(_expected_exact 1)
+ else()
+ set(_expected_exact 0)
+ endif()
+
+ unset(PACKAGE_VERSION_COMPATIBLE)
+ unset(PACKAGE_VERSION_EXACT)
+ unset(PACKAGE_VERSION_UNSUITABLE)
+
+ foreach(_compat ${_compatibilities})
+ set(_pkg ${_compat}${_version_installed})
+ string(REPLACE "." "" _pkg ${_pkg})
+ set(_filename "${CMAKE_CURRENT_BINARY_DIR}/${_pkg}ConfigVersion.cmake")
+ set(_filename_novoid "${CMAKE_CURRENT_BINARY_DIR}/${_pkg}NoVoidConfigVersion.cmake")
+ set(_filename_diffvoid "${CMAKE_CURRENT_BINARY_DIR}/${_pkg}DiffVoidConfigVersion.cmake")
+
+ set(_expected_compatible ${_expected_compatible_${_compat}})
+
+ # Test "normal" version
+ set(_expected_unsuitable 0)
+ message(STATUS "TEST write_basic_config_version_file(VERSION ${_version_installed} \
+COMPATIBILITY ${_compat}) vs. ${_version_requested} \
+(expected compatible = ${_expected_compatible}, exact = ${_expected_exact}, unsuitable = ${_expected_unsuitable})")
+ test_write_basic_config_version_file_check("${_filename}")
+
+ # test empty CMAKE_SIZEOF_VOID_P version:
+ set(_expected_unsuitable 0)
+ message(STATUS "TEST write_basic_config_version_file(VERSION ${_version_installed} \
+COMPATIBILITY ${_compat}) vs. ${_version_requested} (no CMAKE_SIZEOF_VOID_P) \
+(expected compatible = ${_expected_compatible}, exact = ${_expected_exact}, unsuitable = ${_expected_unsuitable})")
+ test_write_basic_config_version_file_check("${_filename_novoid}")
+
+ # test different CMAKE_SIZEOF_VOID_P version:
+ set(_expected_unsuitable 1)
+ message(STATUS "TEST write_basic_config_version_file(VERSION ${_version_installed} \
+COMPATIBILITY ${_compat}) vs. ${_version_requested} (different CMAKE_SIZEOF_VOID_P) \
+(expected compatible = ${_expected_compatible}, exact = ${_expected_exact}, unsuitable = ${_expected_unsuitable})")
+ test_write_basic_config_version_file_check("${_filename_diffvoid}")
+
+ endforeach()
+endfunction()
+
+
+test_write_basic_config_version_file_prepare(4)
+test_write_basic_config_version_file_prepare(4.5)
+test_write_basic_config_version_file_prepare(4.5.6)
+test_write_basic_config_version_file_prepare(4.5.6.7)
+
+# AnyNewerVersion
+# | SameMajorVersion
+# | | SameMinorVersion
+# | | | ExactVersion
+# | | | |
+test_write_basic_config_version_file(4 0 1 0 0 0) # Request 0
+test_write_basic_config_version_file(4 2 1 0 0 0) # Request [older major]
+test_write_basic_config_version_file(4 4 1 1 1 1) # Request [same major]
+test_write_basic_config_version_file(4 9 0 0 0 0) # Request [newer major]
+
+test_write_basic_config_version_file(4 0.0 1 0 0 0) # Request 0.0
+test_write_basic_config_version_file(4 0.9 1 0 0 0) # Request 0.[newer minor]
+test_write_basic_config_version_file(4 2.0 1 0 0 0) # Request [older major].0
+test_write_basic_config_version_file(4 2.9 1 0 0 0) # Request [older major].[newer minor]
+test_write_basic_config_version_file(4 4.0 1 1 0 0) # Request [same major].0
+test_write_basic_config_version_file(4 4.9 0 0 0 0) # Request [same major].[newer minor]
+test_write_basic_config_version_file(4 9.0 0 0 0 0) # Request [newer major].0
+test_write_basic_config_version_file(4 9.9 0 0 0 0) # Request [newer major].[newer minor]
+
+test_write_basic_config_version_file(4 0.0.0 1 0 0 0) # Request 0.0.0
+test_write_basic_config_version_file(4 0.0.9 1 0 0 0) # Request 0.0.[newer patch]
+test_write_basic_config_version_file(4 0.9.0 1 0 0 0) # Request 0.[newer minor].0
+test_write_basic_config_version_file(4 0.9.9 1 0 0 0) # Request 0.[newer minor].[newer patch]
+test_write_basic_config_version_file(4 2.0.0 1 0 0 0) # Request [older major].0.0
+test_write_basic_config_version_file(4 2.0.9 1 0 0 0) # Request [older major].0.[newer patch]
+test_write_basic_config_version_file(4 2.9.0 1 0 0 0) # Request [older major].[newer minor].0
+test_write_basic_config_version_file(4 2.9.9 1 0 0 0) # Request [older major].[newer minor].[newer patch]
+test_write_basic_config_version_file(4 4.0.0 1 1 0 0) # Request [same major].0.0
+test_write_basic_config_version_file(4 4.0.9 0 0 0 0) # Request [same major].0.[newer patch]
+test_write_basic_config_version_file(4 4.9.0 0 0 0 0) # Request [same major].[newer minor].0
+test_write_basic_config_version_file(4 4.9.9 0 0 0 0) # Request [same major].[newer minor].[newer patch]
+test_write_basic_config_version_file(4 9.0.0 0 0 0 0) # Request [newer major].0.0
+test_write_basic_config_version_file(4 9.0.9 0 0 0 0) # Request [newer major].0.[newer patch]
+test_write_basic_config_version_file(4 9.9.0 0 0 0 0) # Request [newer major].[newer minor].0
+test_write_basic_config_version_file(4 9.9.9 0 0 0 0) # Request [newer major].[newer minor].[newer patch]
+
+test_write_basic_config_version_file(4 0.0.0.0 1 0 0 0) # Request 0.0.0.0
+test_write_basic_config_version_file(4 0.0.0.9 1 0 0 0) # Request 0.0.0.[newer tweak]
+test_write_basic_config_version_file(4 0.0.9.0 1 0 0 0) # Request 0.0.[newer patch].0
+test_write_basic_config_version_file(4 0.0.9.9 1 0 0 0) # Request 0.0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4 0.9.0.0 1 0 0 0) # Request 0.[newer minor].0.0
+test_write_basic_config_version_file(4 0.9.0.9 1 0 0 0) # Request 0.[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4 0.9.9.0 1 0 0 0) # Request 0.[newer minor].[newer patch].0
+test_write_basic_config_version_file(4 0.9.9.9 1 0 0 0) # Request 0.[newer minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4 2.0.0.0 1 0 0 0) # Request [older major].0.0.0
+test_write_basic_config_version_file(4 2.0.0.9 1 0 0 0) # Request [older major].0.0.[newer tweak]
+test_write_basic_config_version_file(4 2.0.9.0 1 0 0 0) # Request [older major].0.[newer patch].0
+test_write_basic_config_version_file(4 2.0.9.9 1 0 0 0) # Request [older major].0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4 2.9.0.0 1 0 0 0) # Request [older major].[newer minor].0.0
+test_write_basic_config_version_file(4 2.9.0.9 1 0 0 0) # Request [older major].[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4 2.9.9.0 1 0 0 0) # Request [older major].[newer minor].[newer patch].0
+test_write_basic_config_version_file(4 2.9.9.9 1 0 0 0) # Request [older major].[newer minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4 4.0.0.0 1 1 0 0) # Request [same major].0.0.0
+test_write_basic_config_version_file(4 4.0.0.9 0 0 0 0) # Request [same major].0.0.[newer tweak]
+test_write_basic_config_version_file(4 4.0.9.0 0 0 0 0) # Request [same major].0.[newer patch].0
+test_write_basic_config_version_file(4 4.0.9.9 0 0 0 0) # Request [same major].0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4 4.9.0.0 0 0 0 0) # Request [same major].[newer minor].0.0
+test_write_basic_config_version_file(4 4.9.0.9 0 0 0 0) # Request [same major].[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4 4.9.9.0 0 0 0 0) # Request [same major].[newer minor].[newer patch].0
+test_write_basic_config_version_file(4 4.9.9.9 0 0 0 0) # Request [same major].[newer minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4 9.0.0.0 0 0 0 0) # Request [newer major].0.0.0
+test_write_basic_config_version_file(4 9.0.0.9 0 0 0 0) # Request [newer major].0.0.[newer tweak]
+test_write_basic_config_version_file(4 9.0.9.0 0 0 0 0) # Request [newer major].0.[newer patch].0
+test_write_basic_config_version_file(4 9.0.9.9 0 0 0 0) # Request [newer major].0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4 9.9.0.0 0 0 0 0) # Request [newer major].[newer minor].0.0
+test_write_basic_config_version_file(4 9.9.0.9 0 0 0 0) # Request [newer major].[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4 9.9.9.0 0 0 0 0) # Request [newer major].[newer minor].[newer patch].0
+test_write_basic_config_version_file(4 9.9.9.9 0 0 0 0) # Request [newer major].[newer minor].[newer patch].[newer tweak]
+
+
+
+test_write_basic_config_version_file(4.5 0 1 0 0 0) # Request 0
+test_write_basic_config_version_file(4.5 2 1 0 0 0) # Request [older major]
+test_write_basic_config_version_file(4.5 4 1 1 0 0) # Request [same major]
+test_write_basic_config_version_file(4.5 9 0 0 0 0) # Request [newer major]
+
+test_write_basic_config_version_file(4.5 0.0 1 0 0 0) # Request 0.0
+test_write_basic_config_version_file(4.5 0.2 1 0 0 0) # Request 0.[older minor]
+test_write_basic_config_version_file(4.5 0.5 1 0 0 0) # Request 0.[same minor]
+test_write_basic_config_version_file(4.5 0.9 1 0 0 0) # Request 0.[newer minor]
+test_write_basic_config_version_file(4.5 2.0 1 0 0 0) # Request [older major].0
+test_write_basic_config_version_file(4.5 2.2 1 0 0 0) # Request [older major].[older minor]
+test_write_basic_config_version_file(4.5 2.5 1 0 0 0) # Request [older major].[same minor]
+test_write_basic_config_version_file(4.5 2.9 1 0 0 0) # Request [older major].[newer minor]
+test_write_basic_config_version_file(4.5 4.0 1 1 0 0) # Request [same major].0
+test_write_basic_config_version_file(4.5 4.2 1 1 0 0) # Request [same major].[older minor]
+test_write_basic_config_version_file(4.5 4.5 1 1 1 1) # Request [same major].[same minor]
+test_write_basic_config_version_file(4.5 4.9 0 0 0 0) # Request [same major].[newer minor]
+test_write_basic_config_version_file(4.5 9.0 0 0 0 0) # Request [newer major].0
+test_write_basic_config_version_file(4.5 9.1 0 0 0 0) # Request [newer major].[older minor]
+test_write_basic_config_version_file(4.5 9.5 0 0 0 0) # Request [newer major].[same minor]
+test_write_basic_config_version_file(4.5 9.9 0 0 0 0) # Request [newer major].[newer minor]
+
+test_write_basic_config_version_file(4.5 0.0.0 1 0 0 0) # Request 0.0.0
+test_write_basic_config_version_file(4.5 0.0.9 1 0 0 0) # Request 0.0.[newer patch]
+test_write_basic_config_version_file(4.5 0.2.0 1 0 0 0) # Request 0.[older minor].0
+test_write_basic_config_version_file(4.5 0.2.9 1 0 0 0) # Request 0.[older minor].[newer patch]
+test_write_basic_config_version_file(4.5 0.5.0 1 0 0 0) # Request 0.[same minor].0
+test_write_basic_config_version_file(4.5 0.5.9 1 0 0 0) # Request 0.[same minor].[newer patch]
+test_write_basic_config_version_file(4.5 0.9.0 1 0 0 0) # Request 0.[newer minor].0
+test_write_basic_config_version_file(4.5 0.9.9 1 0 0 0) # Request 0.[newer minor].[newer patch]
+test_write_basic_config_version_file(4.5 2.0.0 1 0 0 0) # Request [older major].0.0
+test_write_basic_config_version_file(4.5 2.0.9 1 0 0 0) # Request [older major].0.[newer patch]
+test_write_basic_config_version_file(4.5 2.2.0 1 0 0 0) # Request [older major].[older minor].0
+test_write_basic_config_version_file(4.5 2.2.9 1 0 0 0) # Request [older major].[older minor].[newer patch]
+test_write_basic_config_version_file(4.5 2.5.0 1 0 0 0) # Request [older major].[same minor].0
+test_write_basic_config_version_file(4.5 2.5.9 1 0 0 0) # Request [older major].[same minor].[newer patch]
+test_write_basic_config_version_file(4.5 2.9.0 1 0 0 0) # Request [older major].[newer minor].0
+test_write_basic_config_version_file(4.5 2.9.9 1 0 0 0) # Request [older major].[newer minor].[newer patch]
+test_write_basic_config_version_file(4.5 4.0.0 1 1 0 0) # Request [same major].0.0
+test_write_basic_config_version_file(4.5 4.0.9 1 1 0 0) # Request [same major].0.[newer patch]
+test_write_basic_config_version_file(4.5 4.2.0 1 1 0 0) # Request [same major].[older minor].0
+test_write_basic_config_version_file(4.5 4.2.9 1 1 0 0) # Request [same major].[older minor].[newer patch]
+test_write_basic_config_version_file(4.5 4.5.0 1 1 1 0) # Request [same major].[same minor].0
+test_write_basic_config_version_file(4.5 4.5.9 0 0 0 0) # Request [same major].[same minor].[newer patch]
+test_write_basic_config_version_file(4.5 4.9.0 0 0 0 0) # Request [same major].[newer minor].0
+test_write_basic_config_version_file(4.5 4.9.9 0 0 0 0) # Request [same major].[newer minor].[newer patch]
+test_write_basic_config_version_file(4.5 9.0.0 0 0 0 0) # Request [newer major].0.0
+test_write_basic_config_version_file(4.5 9.0.9 0 0 0 0) # Request [newer major].0.[newer patch]
+test_write_basic_config_version_file(4.5 9.2.0 0 0 0 0) # Request [newer major].[older minor].0
+test_write_basic_config_version_file(4.5 9.2.9 0 0 0 0) # Request [newer major].[older minor].[newer patch]
+test_write_basic_config_version_file(4.5 9.5.0 0 0 0 0) # Request [newer major].[same minor].0
+test_write_basic_config_version_file(4.5 9.5.9 0 0 0 0) # Request [newer major].[same minor].[newer patch]
+test_write_basic_config_version_file(4.5 9.9.0 0 0 0 0) # Request [newer major].[newer minor].0
+test_write_basic_config_version_file(4.5 9.9.9 0 0 0 0) # Request [newer major].[newer minor].[newer patch]
+
+test_write_basic_config_version_file(4.5 0.0.0.0 1 0 0 0) # Request 0.0.0.0
+test_write_basic_config_version_file(4.5 0.0.0.9 1 0 0 0) # Request 0.0.0.[newer tweak]
+test_write_basic_config_version_file(4.5 0.0.9.0 1 0 0 0) # Request 0.0.[newer patch].0
+test_write_basic_config_version_file(4.5 0.0.9.9 1 0 0 0) # Request 0.0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 0.2.0.0 1 0 0 0) # Request 0.[older minor].0.0
+test_write_basic_config_version_file(4.5 0.2.0.9 1 0 0 0) # Request 0.[older minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5 0.2.9.0 1 0 0 0) # Request 0.[older minor].[newer patch].0
+test_write_basic_config_version_file(4.5 0.2.9.9 1 0 0 0) # Request 0.[older minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 0.5.0.0 1 0 0 0) # Request 0.[same minor].0.0
+test_write_basic_config_version_file(4.5 0.5.0.9 1 0 0 0) # Request 0.[same minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5 0.5.9.0 1 0 0 0) # Request 0.[same minor].[newer patch].0
+test_write_basic_config_version_file(4.5 0.5.9.9 1 0 0 0) # Request 0.[same minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 0.9.0.0 1 0 0 0) # Request 0.[newer minor].0.0
+test_write_basic_config_version_file(4.5 0.9.0.9 1 0 0 0) # Request 0.[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5 0.9.9.0 1 0 0 0) # Request 0.[newer minor].[newer patch].0
+test_write_basic_config_version_file(4.5 0.9.9.9 1 0 0 0) # Request 0.[newer minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 2.0.0.0 1 0 0 0) # Request [older major].0.0.0
+test_write_basic_config_version_file(4.5 2.0.0.9 1 0 0 0) # Request [older major].0.0.[newer tweak]
+test_write_basic_config_version_file(4.5 2.0.9.0 1 0 0 0) # Request [older major].0.[newer patch].0
+test_write_basic_config_version_file(4.5 2.0.9.9 1 0 0 0) # Request [older major].0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 2.2.0.0 1 0 0 0) # Request [older major].[older minor].0.0
+test_write_basic_config_version_file(4.5 2.2.0.9 1 0 0 0) # Request [older major].[older minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5 2.2.9.0 1 0 0 0) # Request [older major].[older minor].[newer patch].0
+test_write_basic_config_version_file(4.5 2.2.9.9 1 0 0 0) # Request [older major].[older minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 2.5.0.0 1 0 0 0) # Request [older major].[same minor].0.0
+test_write_basic_config_version_file(4.5 2.5.0.9 1 0 0 0) # Request [older major].[same minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5 2.5.9.0 1 0 0 0) # Request [older major].[same minor].[newer patch].0
+test_write_basic_config_version_file(4.5 2.5.9.9 1 0 0 0) # Request [older major].[same minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 2.9.0.0 1 0 0 0) # Request [older major].[newer minor].0.0
+test_write_basic_config_version_file(4.5 2.9.0.9 1 0 0 0) # Request [older major].[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5 2.9.9.0 1 0 0 0) # Request [older major].[newer minor].[newer patch].0
+test_write_basic_config_version_file(4.5 2.9.9.9 1 0 0 0) # Request [older major].[newer minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 4.0.0.0 1 1 0 0) # Request [same major].0.0.0
+test_write_basic_config_version_file(4.5 4.0.0.9 1 1 0 0) # Request [same major].0.0.[newer tweak]
+test_write_basic_config_version_file(4.5 4.0.9.0 1 1 0 0) # Request [same major].0.[newer patch].0
+test_write_basic_config_version_file(4.5 4.0.9.9 1 1 0 0) # Request [same major].0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 4.2.0.0 1 1 0 0) # Request [same major].[older minor].0.0
+test_write_basic_config_version_file(4.5 4.2.0.9 1 1 0 0) # Request [same major].[older minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5 4.2.9.0 1 1 0 0) # Request [same major].[older minor].[newer patch].0
+test_write_basic_config_version_file(4.5 4.2.9.9 1 1 0 0) # Request [same major].[older minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 4.5.0.0 1 1 1 0) # Request [same major].[same minor].0.0
+test_write_basic_config_version_file(4.5 4.5.0.9 0 0 0 0) # Request [same major].[same minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5 4.5.9.0 0 0 0 0) # Request [same major].[same minor].[newer patch].0
+test_write_basic_config_version_file(4.5 4.5.9.9 0 0 0 0) # Request [same major].[same minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 4.9.0.0 0 0 0 0) # Request [same major].[newer minor].0.0
+test_write_basic_config_version_file(4.5 4.9.0.9 0 0 0 0) # Request [same major].[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5 4.9.9.0 0 0 0 0) # Request [same major].[newer minor].[newer patch].0
+test_write_basic_config_version_file(4.5 4.9.9.9 0 0 0 0) # Request [same major].[newer minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 9.0.0.0 0 0 0 0) # Request [newer major].0.0.0
+test_write_basic_config_version_file(4.5 9.0.0.9 0 0 0 0) # Request [newer major].0.0.[newer tweak]
+test_write_basic_config_version_file(4.5 9.0.9.0 0 0 0 0) # Request [newer major].0.[newer patch].0
+test_write_basic_config_version_file(4.5 9.0.9.9 0 0 0 0) # Request [newer major].0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 9.2.0.0 0 0 0 0) # Request [newer major].[older minor].0.0
+test_write_basic_config_version_file(4.5 9.2.0.9 0 0 0 0) # Request [newer major].[older minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5 9.2.9.0 0 0 0 0) # Request [newer major].[older minor].[newer patch].0
+test_write_basic_config_version_file(4.5 9.2.9.9 0 0 0 0) # Request [newer major].[older minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 9.5.0.0 0 0 0 0) # Request [newer major].[same minor].0.0
+test_write_basic_config_version_file(4.5 9.5.0.9 0 0 0 0) # Request [newer major].[same minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5 9.5.9.0 0 0 0 0) # Request [newer major].[same minor].[newer patch].0
+test_write_basic_config_version_file(4.5 9.5.9.9 0 0 0 0) # Request [newer major].[same minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5 9.9.0.0 0 0 0 0) # Request [newer major].[newer minor].0.0
+test_write_basic_config_version_file(4.5 9.9.0.9 0 0 0 0) # Request [newer major].[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5 9.9.9.0 0 0 0 0) # Request [newer major].[newer minor].[newer patch].0
+test_write_basic_config_version_file(4.5 9.9.9.9 0 0 0 0) # Request [newer major].[newer minor].[newer patch].[newer tweak]
+
+
+test_write_basic_config_version_file(4.5.6 0 1 0 0 0) # Request 0
+test_write_basic_config_version_file(4.5.6 2 1 0 0 0) # Request [older major]
+test_write_basic_config_version_file(4.5.6 4 1 1 0 0) # Request [same major]
+test_write_basic_config_version_file(4.5.6 9 0 0 0 0) # Request [newer major]
+
+test_write_basic_config_version_file(4.5.6 0.0 1 0 0 0) # Request 0.0
+test_write_basic_config_version_file(4.5.6 0.2 1 0 0 0) # Request 0.[older minor]
+test_write_basic_config_version_file(4.5.6 0.5 1 0 0 0) # Request 0.[same minor]
+test_write_basic_config_version_file(4.5.6 0.9 1 0 0 0) # Request 0.[newer minor]
+test_write_basic_config_version_file(4.5.6 2.0 1 0 0 0) # Request [older major].0
+test_write_basic_config_version_file(4.5.6 2.2 1 0 0 0) # Request [older major].[older minor]
+test_write_basic_config_version_file(4.5.6 2.5 1 0 0 0) # Request [older major].[same minor]
+test_write_basic_config_version_file(4.5.6 2.9 1 0 0 0) # Request [older major].[newer minor]
+test_write_basic_config_version_file(4.5.6 4.0 1 1 0 0) # Request [same major].0
+test_write_basic_config_version_file(4.5.6 4.2 1 1 0 0) # Request [same major].[older minor]
+test_write_basic_config_version_file(4.5.6 4.5 1 1 1 0) # Request [same major].[same minor]
+test_write_basic_config_version_file(4.5.6 4.9 0 0 0 0) # Request [same major].[newer minor]
+test_write_basic_config_version_file(4.5.6 9.0 0 0 0 0) # Request [newer major].0
+test_write_basic_config_version_file(4.5.6 9.1 0 0 0 0) # Request [newer major].[older minor]
+test_write_basic_config_version_file(4.5.6 9.5 0 0 0 0) # Request [newer major].[same minor]
+test_write_basic_config_version_file(4.5.6 9.9 0 0 0 0) # Request [newer major].[newer minor]
+
+test_write_basic_config_version_file(4.5.6 0.0.0 1 0 0 0) # Request 0.0.0
+test_write_basic_config_version_file(4.5.6 0.0.2 1 0 0 0) # Request 0.0.[older patch]
+test_write_basic_config_version_file(4.5.6 0.0.6 1 0 0 0) # Request 0.0.[same patch]
+test_write_basic_config_version_file(4.5.6 0.0.9 1 0 0 0) # Request 0.0.[newer patch]
+test_write_basic_config_version_file(4.5.6 0.2.0 1 0 0 0) # Request 0.[older minor].0
+test_write_basic_config_version_file(4.5.6 0.2.2 1 0 0 0) # Request 0.[older minor].[older patch]
+test_write_basic_config_version_file(4.5.6 0.2.6 1 0 0 0) # Request 0.[older minor].[same patch]
+test_write_basic_config_version_file(4.5.6 0.2.9 1 0 0 0) # Request 0.[older minor].[newer patch]
+test_write_basic_config_version_file(4.5.6 0.5.0 1 0 0 0) # Request 0.[same minor].0
+test_write_basic_config_version_file(4.5.6 0.5.2 1 0 0 0) # Request 0.[same minor].[older patch]
+test_write_basic_config_version_file(4.5.6 0.5.6 1 0 0 0) # Request 0.[same minor].[same patch]
+test_write_basic_config_version_file(4.5.6 0.5.9 1 0 0 0) # Request 0.[same minor].[newer patch]
+test_write_basic_config_version_file(4.5.6 0.9.0 1 0 0 0) # Request 0.[newer minor].0
+test_write_basic_config_version_file(4.5.6 0.9.2 1 0 0 0) # Request 0.[newer minor].[older patch]
+test_write_basic_config_version_file(4.5.6 0.9.6 1 0 0 0) # Request 0.[newer minor].[same patch]
+test_write_basic_config_version_file(4.5.6 0.9.9 1 0 0 0) # Request 0.[newer minor].[newer patch]
+test_write_basic_config_version_file(4.5.6 2.0.0 1 0 0 0) # Request [older major].0.0
+test_write_basic_config_version_file(4.5.6 2.0.2 1 0 0 0) # Request [older major].0.[older patch]
+test_write_basic_config_version_file(4.5.6 2.0.6 1 0 0 0) # Request [older major].0.[same patch]
+test_write_basic_config_version_file(4.5.6 2.0.9 1 0 0 0) # Request [older major].0.[newer patch]
+test_write_basic_config_version_file(4.5.6 2.2.0 1 0 0 0) # Request [older major].[older minor].0
+test_write_basic_config_version_file(4.5.6 2.2.2 1 0 0 0) # Request [older major].[older minor].[older patch]
+test_write_basic_config_version_file(4.5.6 2.2.6 1 0 0 0) # Request [older major].[older minor].[same patch]
+test_write_basic_config_version_file(4.5.6 2.2.9 1 0 0 0) # Request [older major].[older minor].[newer patch]
+test_write_basic_config_version_file(4.5.6 2.5.0 1 0 0 0) # Request [older major].[same minor].0
+test_write_basic_config_version_file(4.5.6 2.5.2 1 0 0 0) # Request [older major].[same minor].[older patch]
+test_write_basic_config_version_file(4.5.6 2.5.6 1 0 0 0) # Request [older major].[same minor].[same patch]
+test_write_basic_config_version_file(4.5.6 2.5.9 1 0 0 0) # Request [older major].[same minor].[newer patch]
+test_write_basic_config_version_file(4.5.6 2.9.0 1 0 0 0) # Request [older major].[newer minor].0
+test_write_basic_config_version_file(4.5.6 2.9.2 1 0 0 0) # Request [older major].[newer minor].[older patch]
+test_write_basic_config_version_file(4.5.6 2.9.6 1 0 0 0) # Request [older major].[newer minor].[same patch]
+test_write_basic_config_version_file(4.5.6 2.9.9 1 0 0 0) # Request [older major].[newer minor].[newer patch]
+test_write_basic_config_version_file(4.5.6 4.0.0 1 1 0 0) # Request [same major].0.0
+test_write_basic_config_version_file(4.5.6 4.0.2 1 1 0 0) # Request [same major].0.[older patch]
+test_write_basic_config_version_file(4.5.6 4.0.6 1 1 0 0) # Request [same major].0.[same patch]
+test_write_basic_config_version_file(4.5.6 4.0.9 1 1 0 0) # Request [same major].0.[newer patch]
+test_write_basic_config_version_file(4.5.6 4.2.0 1 1 0 0) # Request [same major].[older minor].0
+test_write_basic_config_version_file(4.5.6 4.2.2 1 1 0 0) # Request [same major].[older minor].[older patch]
+test_write_basic_config_version_file(4.5.6 4.2.6 1 1 0 0) # Request [same major].[older minor].[same patch]
+test_write_basic_config_version_file(4.5.6 4.2.9 1 1 0 0) # Request [same major].[older minor].[newer patch]
+test_write_basic_config_version_file(4.5.6 4.5.0 1 1 1 0) # Request [same major].[same minor].0
+test_write_basic_config_version_file(4.5.6 4.5.2 1 1 1 0) # Request [same major].[same minor].[older patch]
+test_write_basic_config_version_file(4.5.6 4.5.6 1 1 1 1) # Request [same major].[same minor].[same patch]
+test_write_basic_config_version_file(4.5.6 4.5.9 0 0 0 0) # Request [same major].[same minor].[newer patch]
+test_write_basic_config_version_file(4.5.6 4.9.0 0 0 0 0) # Request [same major].[newer minor].0
+test_write_basic_config_version_file(4.5.6 4.9.2 0 0 0 0) # Request [same major].[newer minor].[older patch]
+test_write_basic_config_version_file(4.5.6 4.9.6 0 0 0 0) # Request [same major].[newer minor].[same patch]
+test_write_basic_config_version_file(4.5.6 4.9.9 0 0 0 0) # Request [same major].[newer minor].[newer patch]
+test_write_basic_config_version_file(4.5.6 9.0.0 0 0 0 0) # Request [newer major].0.0
+test_write_basic_config_version_file(4.5.6 9.0.2 0 0 0 0) # Request [newer major].0.[older patch]
+test_write_basic_config_version_file(4.5.6 9.0.6 0 0 0 0) # Request [newer major].0.[same patch]
+test_write_basic_config_version_file(4.5.6 9.0.9 0 0 0 0) # Request [newer major].0.[newer patch]
+test_write_basic_config_version_file(4.5.6 9.2.0 0 0 0 0) # Request [newer major].[older minor].0
+test_write_basic_config_version_file(4.5.6 9.2.2 0 0 0 0) # Request [newer major].[older minor].[older patch]
+test_write_basic_config_version_file(4.5.6 9.2.6 0 0 0 0) # Request [newer major].[older minor].[same patch]
+test_write_basic_config_version_file(4.5.6 9.2.9 0 0 0 0) # Request [newer major].[older minor].[newer patch]
+test_write_basic_config_version_file(4.5.6 9.5.0 0 0 0 0) # Request [newer major].[same minor].0
+test_write_basic_config_version_file(4.5.6 9.5.2 0 0 0 0) # Request [newer major].[same minor].[older patch]
+test_write_basic_config_version_file(4.5.6 9.5.6 0 0 0 0) # Request [newer major].[same minor].[same patch]
+test_write_basic_config_version_file(4.5.6 9.5.9 0 0 0 0) # Request [newer major].[same minor].[newer patch]
+test_write_basic_config_version_file(4.5.6 9.9.0 0 0 0 0) # Request [newer major].[newer minor].0
+test_write_basic_config_version_file(4.5.6 9.9.2 0 0 0 0) # Request [newer major].[newer minor].[older patch]
+test_write_basic_config_version_file(4.5.6 9.9.6 0 0 0 0) # Request [newer major].[newer minor].[same patch]
+test_write_basic_config_version_file(4.5.6 9.9.9 0 0 0 0) # Request [newer major].[newer minor].[newer patch]
+
+test_write_basic_config_version_file(4.5.6 0.0.0.0 1 0 0 0) # Request 0.0.0.0
+test_write_basic_config_version_file(4.5.6 0.0.0.9 1 0 0 0) # Request 0.0.0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.0.2.0 1 0 0 0) # Request 0.0.[older patch].0
+test_write_basic_config_version_file(4.5.6 0.0.2.9 1 0 0 0) # Request 0.0.[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.0.6.0 1 0 0 0) # Request 0.0.[same patch].0
+test_write_basic_config_version_file(4.5.6 0.0.6.9 1 0 0 0) # Request 0.0.[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.0.9.0 1 0 0 0) # Request 0.0.[newer patch].0
+test_write_basic_config_version_file(4.5.6 0.0.9.9 1 0 0 0) # Request 0.0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.2.0.0 1 0 0 0) # Request 0.[older minor].0.0
+test_write_basic_config_version_file(4.5.6 0.2.0.9 1 0 0 0) # Request 0.[older minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.2.2.0 1 0 0 0) # Request 0.[older minor].[older patch].0
+test_write_basic_config_version_file(4.5.6 0.2.2.9 1 0 0 0) # Request 0.[older minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.2.6.0 1 0 0 0) # Request 0.[older minor].[same patch].0
+test_write_basic_config_version_file(4.5.6 0.2.6.9 1 0 0 0) # Request 0.[older minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.2.9.0 1 0 0 0) # Request 0.[older minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6 0.2.9.9 1 0 0 0) # Request 0.[older minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.5.0.0 1 0 0 0) # Request 0.[same minor].0.0
+test_write_basic_config_version_file(4.5.6 0.5.0.9 1 0 0 0) # Request 0.[same minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.5.2.0 1 0 0 0) # Request 0.[same minor].[older patch].0
+test_write_basic_config_version_file(4.5.6 0.5.2.9 1 0 0 0) # Request 0.[same minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.5.6.0 1 0 0 0) # Request 0.[same minor].[same patch].0
+test_write_basic_config_version_file(4.5.6 0.5.6.9 1 0 0 0) # Request 0.[same minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.5.9.0 1 0 0 0) # Request 0.[same minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6 0.5.9.9 1 0 0 0) # Request 0.[same minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.9.0.0 1 0 0 0) # Request 0.[newer minor].0.0
+test_write_basic_config_version_file(4.5.6 0.9.0.9 1 0 0 0) # Request 0.[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.9.2.0 1 0 0 0) # Request 0.[newer minor].[older patch].0
+test_write_basic_config_version_file(4.5.6 0.9.2.9 1 0 0 0) # Request 0.[newer minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.9.6.0 1 0 0 0) # Request 0.[newer minor].[same patch].0
+test_write_basic_config_version_file(4.5.6 0.9.6.9 1 0 0 0) # Request 0.[newer minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 0.9.9.0 1 0 0 0) # Request 0.[newer minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6 0.9.9.9 1 0 0 0) # Request 0.[newer minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.0.0.0 1 0 0 0) # Request [older major].0.0.0
+test_write_basic_config_version_file(4.5.6 2.0.0.9 1 0 0 0) # Request [older major].0.0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.0.2.0 1 0 0 0) # Request [older major].0.[older patch].0
+test_write_basic_config_version_file(4.5.6 2.0.2.9 1 0 0 0) # Request [older major].0.[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.0.6.0 1 0 0 0) # Request [older major].0.[same patch].0
+test_write_basic_config_version_file(4.5.6 2.0.6.9 1 0 0 0) # Request [older major].0.[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.0.9.0 1 0 0 0) # Request [older major].0.[newer patch].0
+test_write_basic_config_version_file(4.5.6 2.0.9.9 1 0 0 0) # Request [older major].0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.2.0.0 1 0 0 0) # Request [older major].[older minor].0.0
+test_write_basic_config_version_file(4.5.6 2.2.0.9 1 0 0 0) # Request [older major].[older minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.2.2.0 1 0 0 0) # Request [older major].[older minor].[older patch].0
+test_write_basic_config_version_file(4.5.6 2.2.2.9 1 0 0 0) # Request [older major].[older minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.2.6.0 1 0 0 0) # Request [older major].[older minor].[same patch].0
+test_write_basic_config_version_file(4.5.6 2.2.6.9 1 0 0 0) # Request [older major].[older minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.2.9.0 1 0 0 0) # Request [older major].[older minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6 2.2.9.9 1 0 0 0) # Request [older major].[older minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.5.0.0 1 0 0 0) # Request [older major].[same minor].0.0
+test_write_basic_config_version_file(4.5.6 2.5.0.9 1 0 0 0) # Request [older major].[same minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.5.2.0 1 0 0 0) # Request [older major].[same minor].[older patch].0
+test_write_basic_config_version_file(4.5.6 2.5.2.9 1 0 0 0) # Request [older major].[same minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.5.6.0 1 0 0 0) # Request [older major].[same minor].[same patch].0
+test_write_basic_config_version_file(4.5.6 2.5.6.9 1 0 0 0) # Request [older major].[same minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.5.9.0 1 0 0 0) # Request [older major].[same minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6 2.5.9.9 1 0 0 0) # Request [older major].[same minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.9.0.0 1 0 0 0) # Request [older major].[newer minor].0.0
+test_write_basic_config_version_file(4.5.6 2.9.0.9 1 0 0 0) # Request [older major].[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.9.2.0 1 0 0 0) # Request [older major].[newer minor].[older patch].0
+test_write_basic_config_version_file(4.5.6 2.9.2.9 1 0 0 0) # Request [older major].[newer minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.9.6.0 1 0 0 0) # Request [older major].[newer minor].[same patch].0
+test_write_basic_config_version_file(4.5.6 2.9.6.9 1 0 0 0) # Request [older major].[newer minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 2.9.9.0 1 0 0 0) # Request [older major].[newer minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6 2.9.9.9 1 0 0 0) # Request [older major].[newer minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.0.0.0 1 1 0 0) # Request [same major].0.0.0
+test_write_basic_config_version_file(4.5.6 4.0.0.9 1 1 0 0) # Request [same major].0.0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.0.2.0 1 1 0 0) # Request [same major].0.[older patch].0
+test_write_basic_config_version_file(4.5.6 4.0.2.9 1 1 0 0) # Request [same major].0.[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.0.6.0 1 1 0 0) # Request [same major].0.[same patch].0
+test_write_basic_config_version_file(4.5.6 4.0.6.9 1 1 0 0) # Request [same major].0.[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.0.9.0 1 1 0 0) # Request [same major].0.[newer patch].0
+test_write_basic_config_version_file(4.5.6 4.0.9.9 1 1 0 0) # Request [same major].0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.2.0.0 1 1 0 0) # Request [same major].[older minor].0.0
+test_write_basic_config_version_file(4.5.6 4.2.0.9 1 1 0 0) # Request [same major].[older minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.2.2.0 1 1 0 0) # Request [same major].[older minor].[older patch].0
+test_write_basic_config_version_file(4.5.6 4.2.2.9 1 1 0 0) # Request [same major].[older minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.2.6.0 1 1 0 0) # Request [same major].[older minor].[same patch].0
+test_write_basic_config_version_file(4.5.6 4.2.6.9 1 1 0 0) # Request [same major].[older minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.2.9.0 1 1 0 0) # Request [same major].[older minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6 4.2.9.9 1 1 0 0) # Request [same major].[older minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.5.0.0 1 1 1 0) # Request [same major].[same minor].0.0
+test_write_basic_config_version_file(4.5.6 4.5.0.9 1 1 1 0) # Request [same major].[same minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.5.2.0 1 1 1 0) # Request [same major].[same minor].[older patch].0
+test_write_basic_config_version_file(4.5.6 4.5.2.9 1 1 1 0) # Request [same major].[same minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.5.6.0 1 1 1 1) # Request [same major].[same minor].[same patch].0
+test_write_basic_config_version_file(4.5.6 4.5.6.9 0 0 0 1) # Request [same major].[same minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.5.9.0 0 0 0 0) # Request [same major].[same minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6 4.5.9.9 0 0 0 0) # Request [same major].[same minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.9.0.0 0 0 0 0) # Request [same major].[newer minor].0.0
+test_write_basic_config_version_file(4.5.6 4.9.0.9 0 0 0 0) # Request [same major].[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.9.2.0 0 0 0 0) # Request [same major].[newer minor].[older patch].0
+test_write_basic_config_version_file(4.5.6 4.9.2.9 0 0 0 0) # Request [same major].[newer minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.9.6.0 0 0 0 0) # Request [same major].[newer minor].[same patch].0
+test_write_basic_config_version_file(4.5.6 4.9.6.9 0 0 0 0) # Request [same major].[newer minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 4.9.9.0 0 0 0 0) # Request [same major].[newer minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6 4.9.9.9 0 0 0 0) # Request [same major].[newer minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.0.0.0 0 0 0 0) # Request [newer major].0.0.0
+test_write_basic_config_version_file(4.5.6 9.0.0.9 0 0 0 0) # Request [newer major].0.0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.0.2.0 0 0 0 0) # Request [newer major].0.[older patch].0
+test_write_basic_config_version_file(4.5.6 9.0.2.9 0 0 0 0) # Request [newer major].0.[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.0.6.0 0 0 0 0) # Request [newer major].0.[same patch].0
+test_write_basic_config_version_file(4.5.6 9.0.6.9 0 0 0 0) # Request [newer major].0.[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.0.9.0 0 0 0 0) # Request [newer major].0.[newer patch].0
+test_write_basic_config_version_file(4.5.6 9.0.9.9 0 0 0 0) # Request [newer major].0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.2.0.0 0 0 0 0) # Request [newer major].[older minor].0.0
+test_write_basic_config_version_file(4.5.6 9.2.0.9 0 0 0 0) # Request [newer major].[older minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.2.2.0 0 0 0 0) # Request [newer major].[older minor].[older patch].0
+test_write_basic_config_version_file(4.5.6 9.2.2.9 0 0 0 0) # Request [newer major].[older minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.2.6.0 0 0 0 0) # Request [newer major].[older minor].[same patch].0
+test_write_basic_config_version_file(4.5.6 9.2.6.9 0 0 0 0) # Request [newer major].[older minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.2.9.0 0 0 0 0) # Request [newer major].[older minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6 9.2.9.9 0 0 0 0) # Request [newer major].[older minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.5.0.0 0 0 0 0) # Request [newer major].[same minor].0.0
+test_write_basic_config_version_file(4.5.6 9.5.0.9 0 0 0 0) # Request [newer major].[same minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.5.2.0 0 0 0 0) # Request [newer major].[same minor].[older patch].0
+test_write_basic_config_version_file(4.5.6 9.5.2.9 0 0 0 0) # Request [newer major].[same minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.5.6.0 0 0 0 0) # Request [newer major].[same minor].[same patch].0
+test_write_basic_config_version_file(4.5.6 9.5.6.9 0 0 0 0) # Request [newer major].[same minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.5.9.0 0 0 0 0) # Request [newer major].[same minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6 9.5.9.9 0 0 0 0) # Request [newer major].[same minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.9.0.0 0 0 0 0) # Request [newer major].[newer minor].0.0
+test_write_basic_config_version_file(4.5.6 9.9.0.9 0 0 0 0) # Request [newer major].[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.9.2.0 0 0 0 0) # Request [newer major].[newer minor].[older patch].0
+test_write_basic_config_version_file(4.5.6 9.9.2.9 0 0 0 0) # Request [newer major].[newer minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.9.6.0 0 0 0 0) # Request [newer major].[newer minor].[same patch].0
+test_write_basic_config_version_file(4.5.6 9.9.6.9 0 0 0 0) # Request [newer major].[newer minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6 9.9.9.0 0 0 0 0) # Request [newer major].[newer minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6 9.9.9.9 0 0 0 0) # Request [newer major].[newer minor].[newer patch].[newer tweak]
+
+
+test_write_basic_config_version_file(4.5.6.7 0 1 0 0 0) # Request 0
+test_write_basic_config_version_file(4.5.6.7 2 1 0 0 0) # Request [older major]
+test_write_basic_config_version_file(4.5.6.7 4 1 1 0 0) # Request [same major]
+test_write_basic_config_version_file(4.5.6.7 9 0 0 0 0) # Request [newer major]
+
+test_write_basic_config_version_file(4.5.6.7 0.0 1 0 0 0) # Request 0.0
+test_write_basic_config_version_file(4.5.6.7 0.2 1 0 0 0) # Request 0.[older minor]
+test_write_basic_config_version_file(4.5.6.7 0.5 1 0 0 0) # Request 0.[same minor]
+test_write_basic_config_version_file(4.5.6.7 0.9 1 0 0 0) # Request 0.[newer minor]
+test_write_basic_config_version_file(4.5.6.7 2.0 1 0 0 0) # Request [older major].0
+test_write_basic_config_version_file(4.5.6.7 2.2 1 0 0 0) # Request [older major].[older minor]
+test_write_basic_config_version_file(4.5.6.7 2.5 1 0 0 0) # Request [older major].[same minor]
+test_write_basic_config_version_file(4.5.6.7 2.9 1 0 0 0) # Request [older major].[newer minor]
+test_write_basic_config_version_file(4.5.6.7 4.0 1 1 0 0) # Request [same major].0
+test_write_basic_config_version_file(4.5.6.7 4.2 1 1 0 0) # Request [same major].[older minor]
+test_write_basic_config_version_file(4.5.6.7 4.5 1 1 1 0) # Request [same major].[same minor]
+test_write_basic_config_version_file(4.5.6.7 4.9 0 0 0 0) # Request [same major].[newer minor]
+test_write_basic_config_version_file(4.5.6.7 9.0 0 0 0 0) # Request [newer major].0
+test_write_basic_config_version_file(4.5.6.7 9.1 0 0 0 0) # Request [newer major].[older minor]
+test_write_basic_config_version_file(4.5.6.7 9.5 0 0 0 0) # Request [newer major].[same minor]
+test_write_basic_config_version_file(4.5.6.7 9.9 0 0 0 0) # Request [newer major].[newer minor]
+
+test_write_basic_config_version_file(4.5.6.7 0.0.0 1 0 0 0) # Request 0.0.0
+test_write_basic_config_version_file(4.5.6.7 0.0.2 1 0 0 0) # Request 0.0.[older patch]
+test_write_basic_config_version_file(4.5.6.7 0.0.6 1 0 0 0) # Request 0.0.[same patch]
+test_write_basic_config_version_file(4.5.6.7 0.0.9 1 0 0 0) # Request 0.0.[newer patch]
+test_write_basic_config_version_file(4.5.6.7 0.2.0 1 0 0 0) # Request 0.[older minor].0
+test_write_basic_config_version_file(4.5.6.7 0.2.2 1 0 0 0) # Request 0.[older minor].[older patch]
+test_write_basic_config_version_file(4.5.6.7 0.2.6 1 0 0 0) # Request 0.[older minor].[same patch]
+test_write_basic_config_version_file(4.5.6.7 0.2.9 1 0 0 0) # Request 0.[older minor].[newer patch]
+test_write_basic_config_version_file(4.5.6.7 0.5.0 1 0 0 0) # Request 0.[same minor].0
+test_write_basic_config_version_file(4.5.6.7 0.5.2 1 0 0 0) # Request 0.[same minor].[older patch]
+test_write_basic_config_version_file(4.5.6.7 0.5.6 1 0 0 0) # Request 0.[same minor].[same patch]
+test_write_basic_config_version_file(4.5.6.7 0.5.9 1 0 0 0) # Request 0.[same minor].[newer patch]
+test_write_basic_config_version_file(4.5.6.7 0.9.0 1 0 0 0) # Request 0.[newer minor].0
+test_write_basic_config_version_file(4.5.6.7 0.9.2 1 0 0 0) # Request 0.[newer minor].[older patch]
+test_write_basic_config_version_file(4.5.6.7 0.9.6 1 0 0 0) # Request 0.[newer minor].[same patch]
+test_write_basic_config_version_file(4.5.6.7 0.9.9 1 0 0 0) # Request 0.[newer minor].[newer patch]
+test_write_basic_config_version_file(4.5.6.7 2.0.0 1 0 0 0) # Request [older major].0.0
+test_write_basic_config_version_file(4.5.6.7 2.0.2 1 0 0 0) # Request [older major].0.[older patch]
+test_write_basic_config_version_file(4.5.6.7 2.0.6 1 0 0 0) # Request [older major].0.[same patch]
+test_write_basic_config_version_file(4.5.6.7 2.0.9 1 0 0 0) # Request [older major].0.[newer patch]
+test_write_basic_config_version_file(4.5.6.7 2.2.0 1 0 0 0) # Request [older major].[older minor].0
+test_write_basic_config_version_file(4.5.6.7 2.2.2 1 0 0 0) # Request [older major].[older minor].[older patch]
+test_write_basic_config_version_file(4.5.6.7 2.2.6 1 0 0 0) # Request [older major].[older minor].[same patch]
+test_write_basic_config_version_file(4.5.6.7 2.2.9 1 0 0 0) # Request [older major].[older minor].[newer patch]
+test_write_basic_config_version_file(4.5.6.7 2.5.0 1 0 0 0) # Request [older major].[same minor].0
+test_write_basic_config_version_file(4.5.6.7 2.5.2 1 0 0 0) # Request [older major].[same minor].[older patch]
+test_write_basic_config_version_file(4.5.6.7 2.5.6 1 0 0 0) # Request [older major].[same minor].[same patch]
+test_write_basic_config_version_file(4.5.6.7 2.5.9 1 0 0 0) # Request [older major].[same minor].[newer patch]
+test_write_basic_config_version_file(4.5.6.7 2.9.0 1 0 0 0) # Request [older major].[newer minor].0
+test_write_basic_config_version_file(4.5.6.7 2.9.2 1 0 0 0) # Request [older major].[newer minor].[older patch]
+test_write_basic_config_version_file(4.5.6.7 2.9.6 1 0 0 0) # Request [older major].[newer minor].[same patch]
+test_write_basic_config_version_file(4.5.6.7 2.9.9 1 0 0 0) # Request [older major].[newer minor].[newer patch]
+test_write_basic_config_version_file(4.5.6.7 4.0.0 1 1 0 0) # Request [same major].0.0
+test_write_basic_config_version_file(4.5.6.7 4.0.2 1 1 0 0) # Request [same major].0.[older patch]
+test_write_basic_config_version_file(4.5.6.7 4.0.6 1 1 0 0) # Request [same major].0.[same patch]
+test_write_basic_config_version_file(4.5.6.7 4.0.9 1 1 0 0) # Request [same major].0.[newer patch]
+test_write_basic_config_version_file(4.5.6.7 4.2.0 1 1 0 0) # Request [same major].[older minor].0
+test_write_basic_config_version_file(4.5.6.7 4.2.2 1 1 0 0) # Request [same major].[older minor].[older patch]
+test_write_basic_config_version_file(4.5.6.7 4.2.6 1 1 0 0) # Request [same major].[older minor].[same patch]
+test_write_basic_config_version_file(4.5.6.7 4.2.9 1 1 0 0) # Request [same major].[older minor].[newer patch]
+test_write_basic_config_version_file(4.5.6.7 4.5.0 1 1 1 0) # Request [same major].[same minor].0
+test_write_basic_config_version_file(4.5.6.7 4.5.2 1 1 1 0) # Request [same major].[same minor].[older patch]
+test_write_basic_config_version_file(4.5.6.7 4.5.6 1 1 1 1) # Request [same major].[same minor].[same patch]
+test_write_basic_config_version_file(4.5.6.7 4.5.9 0 0 0 0) # Request [same major].[same minor].[newer patch]
+test_write_basic_config_version_file(4.5.6.7 4.9.0 0 0 0 0) # Request [same major].[newer minor].0
+test_write_basic_config_version_file(4.5.6.7 4.9.2 0 0 0 0) # Request [same major].[newer minor].[older patch]
+test_write_basic_config_version_file(4.5.6.7 4.9.6 0 0 0 0) # Request [same major].[newer minor].[same patch]
+test_write_basic_config_version_file(4.5.6.7 4.9.9 0 0 0 0) # Request [same major].[newer minor].[newer patch]
+test_write_basic_config_version_file(4.5.6.7 9.0.0 0 0 0 0) # Request [newer major].0.0
+test_write_basic_config_version_file(4.5.6.7 9.0.2 0 0 0 0) # Request [newer major].0.[older patch]
+test_write_basic_config_version_file(4.5.6.7 9.0.6 0 0 0 0) # Request [newer major].0.[same patch]
+test_write_basic_config_version_file(4.5.6.7 9.0.9 0 0 0 0) # Request [newer major].0.[newer patch]
+test_write_basic_config_version_file(4.5.6.7 9.2.0 0 0 0 0) # Request [newer major].[older minor].0
+test_write_basic_config_version_file(4.5.6.7 9.2.2 0 0 0 0) # Request [newer major].[older minor].[older patch]
+test_write_basic_config_version_file(4.5.6.7 9.2.6 0 0 0 0) # Request [newer major].[older minor].[same patch]
+test_write_basic_config_version_file(4.5.6.7 9.2.9 0 0 0 0) # Request [newer major].[older minor].[newer patch]
+test_write_basic_config_version_file(4.5.6.7 9.5.0 0 0 0 0) # Request [newer major].[same minor].0
+test_write_basic_config_version_file(4.5.6.7 9.5.2 0 0 0 0) # Request [newer major].[same minor].[older patch]
+test_write_basic_config_version_file(4.5.6.7 9.5.6 0 0 0 0) # Request [newer major].[same minor].[same patch]
+test_write_basic_config_version_file(4.5.6.7 9.5.9 0 0 0 0) # Request [newer major].[same minor].[newer patch]
+test_write_basic_config_version_file(4.5.6.7 9.9.0 0 0 0 0) # Request [newer major].[newer minor].0
+test_write_basic_config_version_file(4.5.6.7 9.9.2 0 0 0 0) # Request [newer major].[newer minor].[older patch]
+test_write_basic_config_version_file(4.5.6.7 9.9.6 0 0 0 0) # Request [newer major].[newer minor].[same patch]
+test_write_basic_config_version_file(4.5.6.7 9.9.9 0 0 0 0) # Request [newer major].[newer minor].[newer patch]
+
+test_write_basic_config_version_file(4.5.6.7 0.0.0.0 1 0 0 0) # Request 0.0.0.0
+test_write_basic_config_version_file(4.5.6.7 0.0.0.2 1 0 0 0) # Request 0.0.0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.0.0.7 1 0 0 0) # Request 0.0.0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.0.0.9 1 0 0 0) # Request 0.0.0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.0.2.0 1 0 0 0) # Request 0.0.[older patch].0
+test_write_basic_config_version_file(4.5.6.7 0.0.2.2 1 0 0 0) # Request 0.0.[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.0.2.7 1 0 0 0) # Request 0.0.[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.0.2.9 1 0 0 0) # Request 0.0.[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.0.6.0 1 0 0 0) # Request 0.0.[same patch].0
+test_write_basic_config_version_file(4.5.6.7 0.0.6.2 1 0 0 0) # Request 0.0.[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.0.6.7 1 0 0 0) # Request 0.0.[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.0.6.9 1 0 0 0) # Request 0.0.[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.0.9.0 1 0 0 0) # Request 0.0.[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 0.0.9.2 1 0 0 0) # Request 0.0.[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.0.9.7 1 0 0 0) # Request 0.0.[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.0.9.9 1 0 0 0) # Request 0.0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.2.0.0 1 0 0 0) # Request 0.[older minor].0.0
+test_write_basic_config_version_file(4.5.6.7 0.2.0.2 1 0 0 0) # Request 0.[older minor].0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.2.0.7 1 0 0 0) # Request 0.[older minor].0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.2.0.9 1 0 0 0) # Request 0.[older minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.2.2.0 1 0 0 0) # Request 0.[older minor].[older patch].0
+test_write_basic_config_version_file(4.5.6.7 0.2.2.2 1 0 0 0) # Request 0.[older minor].[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.2.2.7 1 0 0 0) # Request 0.[older minor].[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.2.2.9 1 0 0 0) # Request 0.[older minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.2.6.0 1 0 0 0) # Request 0.[older minor].[same patch].0
+test_write_basic_config_version_file(4.5.6.7 0.2.6.2 1 0 0 0) # Request 0.[older minor].[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.2.6.7 1 0 0 0) # Request 0.[older minor].[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.2.6.9 1 0 0 0) # Request 0.[older minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.2.9.0 1 0 0 0) # Request 0.[older minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 0.2.9.2 1 0 0 0) # Request 0.[older minor].[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.2.9.7 1 0 0 0) # Request 0.[older minor].[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.2.9.9 1 0 0 0) # Request 0.[older minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.5.0.0 1 0 0 0) # Request 0.[same minor].0.0
+test_write_basic_config_version_file(4.5.6.7 0.5.0.2 1 0 0 0) # Request 0.[same minor].0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.5.0.7 1 0 0 0) # Request 0.[same minor].0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.5.0.9 1 0 0 0) # Request 0.[same minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.5.2.0 1 0 0 0) # Request 0.[same minor].[older patch].0
+test_write_basic_config_version_file(4.5.6.7 0.5.2.2 1 0 0 0) # Request 0.[same minor].[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.5.2.7 1 0 0 0) # Request 0.[same minor].[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.5.2.9 1 0 0 0) # Request 0.[same minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.5.6.0 1 0 0 0) # Request 0.[same minor].[same patch].0
+test_write_basic_config_version_file(4.5.6.7 0.5.6.2 1 0 0 0) # Request 0.[same minor].[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.5.6.7 1 0 0 0) # Request 0.[same minor].[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.5.6.9 1 0 0 0) # Request 0.[same minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.5.9.0 1 0 0 0) # Request 0.[same minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 0.5.9.2 1 0 0 0) # Request 0.[same minor].[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.5.9.7 1 0 0 0) # Request 0.[same minor].[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.5.9.9 1 0 0 0) # Request 0.[same minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.9.0.0 1 0 0 0) # Request 0.[newer minor].0.0
+test_write_basic_config_version_file(4.5.6.7 0.9.0.2 1 0 0 0) # Request 0.[newer minor].0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.9.0.7 1 0 0 0) # Request 0.[newer minor].0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.9.0.9 1 0 0 0) # Request 0.[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.9.2.0 1 0 0 0) # Request 0.[newer minor].[older patch].0
+test_write_basic_config_version_file(4.5.6.7 0.9.2.2 1 0 0 0) # Request 0.[newer minor].[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.9.2.7 1 0 0 0) # Request 0.[newer minor].[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.9.2.9 1 0 0 0) # Request 0.[newer minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.9.6.0 1 0 0 0) # Request 0.[newer minor].[same patch].0
+test_write_basic_config_version_file(4.5.6.7 0.9.6.2 1 0 0 0) # Request 0.[newer minor].[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.9.6.7 1 0 0 0) # Request 0.[newer minor].[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.9.6.9 1 0 0 0) # Request 0.[newer minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 0.9.9.0 1 0 0 0) # Request 0.[newer minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 0.9.9.2 1 0 0 0) # Request 0.[newer minor].[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 0.9.9.7 1 0 0 0) # Request 0.[newer minor].[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 0.9.9.9 1 0 0 0) # Request 0.[newer minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.0.0.0 1 0 0 0) # Request [older major].0.0.0
+test_write_basic_config_version_file(4.5.6.7 2.0.0.2 1 0 0 0) # Request [older major].0.0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.0.0.7 1 0 0 0) # Request [older major].0.0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.0.0.9 1 0 0 0) # Request [older major].0.0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.0.2.0 1 0 0 0) # Request [older major].0.[older patch].0
+test_write_basic_config_version_file(4.5.6.7 2.0.2.2 1 0 0 0) # Request [older major].0.[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.0.2.7 1 0 0 0) # Request [older major].0.[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.0.2.9 1 0 0 0) # Request [older major].0.[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.0.6.0 1 0 0 0) # Request [older major].0.[same patch].0
+test_write_basic_config_version_file(4.5.6.7 2.0.6.2 1 0 0 0) # Request [older major].0.[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.0.6.7 1 0 0 0) # Request [older major].0.[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.0.6.9 1 0 0 0) # Request [older major].0.[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.0.9.0 1 0 0 0) # Request [older major].0.[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 2.0.9.2 1 0 0 0) # Request [older major].0.[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.0.9.7 1 0 0 0) # Request [older major].0.[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.0.9.9 1 0 0 0) # Request [older major].0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.2.0.0 1 0 0 0) # Request [older major].[older minor].0.0
+test_write_basic_config_version_file(4.5.6.7 2.2.0.2 1 0 0 0) # Request [older major].[older minor].0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.2.0.7 1 0 0 0) # Request [older major].[older minor].0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.2.0.9 1 0 0 0) # Request [older major].[older minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.2.2.0 1 0 0 0) # Request [older major].[older minor].[older patch].0
+test_write_basic_config_version_file(4.5.6.7 2.2.2.2 1 0 0 0) # Request [older major].[older minor].[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.2.2.7 1 0 0 0) # Request [older major].[older minor].[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.2.2.9 1 0 0 0) # Request [older major].[older minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.2.6.0 1 0 0 0) # Request [older major].[older minor].[same patch].0
+test_write_basic_config_version_file(4.5.6.7 2.2.6.2 1 0 0 0) # Request [older major].[older minor].[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.2.6.7 1 0 0 0) # Request [older major].[older minor].[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.2.6.9 1 0 0 0) # Request [older major].[older minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.2.9.0 1 0 0 0) # Request [older major].[older minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 2.2.9.2 1 0 0 0) # Request [older major].[older minor].[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.2.9.7 1 0 0 0) # Request [older major].[older minor].[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.2.9.9 1 0 0 0) # Request [older major].[older minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.5.0.0 1 0 0 0) # Request [older major].[same minor].0.0
+test_write_basic_config_version_file(4.5.6.7 2.5.0.2 1 0 0 0) # Request [older major].[same minor].0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.5.0.7 1 0 0 0) # Request [older major].[same minor].0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.5.0.9 1 0 0 0) # Request [older major].[same minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.5.2.0 1 0 0 0) # Request [older major].[same minor].[older patch].0
+test_write_basic_config_version_file(4.5.6.7 2.5.2.2 1 0 0 0) # Request [older major].[same minor].[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.5.2.7 1 0 0 0) # Request [older major].[same minor].[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.5.2.9 1 0 0 0) # Request [older major].[same minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.5.6.0 1 0 0 0) # Request [older major].[same minor].[same patch].0
+test_write_basic_config_version_file(4.5.6.7 2.5.6.2 1 0 0 0) # Request [older major].[same minor].[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.5.6.7 1 0 0 0) # Request [older major].[same minor].[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.5.6.9 1 0 0 0) # Request [older major].[same minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.5.9.0 1 0 0 0) # Request [older major].[same minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 2.5.9.2 1 0 0 0) # Request [older major].[same minor].[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.5.9.7 1 0 0 0) # Request [older major].[same minor].[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.5.9.9 1 0 0 0) # Request [older major].[same minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.9.0.0 1 0 0 0) # Request [older major].[newer minor].0.0
+test_write_basic_config_version_file(4.5.6.7 2.9.0.2 1 0 0 0) # Request [older major].[newer minor].0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.9.0.7 1 0 0 0) # Request [older major].[newer minor].0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.9.0.9 1 0 0 0) # Request [older major].[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.9.2.0 1 0 0 0) # Request [older major].[newer minor].[older patch].0
+test_write_basic_config_version_file(4.5.6.7 2.9.2.2 1 0 0 0) # Request [older major].[newer minor].[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.9.2.7 1 0 0 0) # Request [older major].[newer minor].[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.9.2.9 1 0 0 0) # Request [older major].[newer minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.9.6.0 1 0 0 0) # Request [older major].[newer minor].[same patch].0
+test_write_basic_config_version_file(4.5.6.7 2.9.6.2 1 0 0 0) # Request [older major].[newer minor].[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.9.6.7 1 0 0 0) # Request [older major].[newer minor].[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.9.6.9 1 0 0 0) # Request [older major].[newer minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 2.9.9.0 1 0 0 0) # Request [older major].[newer minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 2.9.9.2 1 0 0 0) # Request [older major].[newer minor].[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 2.9.9.7 1 0 0 0) # Request [older major].[newer minor].[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 2.9.9.9 1 0 0 0) # Request [older major].[newer minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.0.0.0 1 1 0 0) # Request [same major].0.0.0
+test_write_basic_config_version_file(4.5.6.7 4.0.0.2 1 1 0 0) # Request [same major].0.0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.0.0.7 1 1 0 0) # Request [same major].0.0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.0.0.9 1 1 0 0) # Request [same major].0.0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.0.2.0 1 1 0 0) # Request [same major].0.[older patch].0
+test_write_basic_config_version_file(4.5.6.7 4.0.2.2 1 1 0 0) # Request [same major].0.[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.0.2.7 1 1 0 0) # Request [same major].0.[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.0.2.9 1 1 0 0) # Request [same major].0.[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.0.6.0 1 1 0 0) # Request [same major].0.[same patch].0
+test_write_basic_config_version_file(4.5.6.7 4.0.6.2 1 1 0 0) # Request [same major].0.[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.0.6.7 1 1 0 0) # Request [same major].0.[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.0.6.9 1 1 0 0) # Request [same major].0.[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.0.9.0 1 1 0 0) # Request [same major].0.[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 4.0.9.2 1 1 0 0) # Request [same major].0.[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.0.9.7 1 1 0 0) # Request [same major].0.[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.0.9.9 1 1 0 0) # Request [same major].0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.2.0.0 1 1 0 0) # Request [same major].[older minor].0.0
+test_write_basic_config_version_file(4.5.6.7 4.2.0.2 1 1 0 0) # Request [same major].[older minor].0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.2.0.7 1 1 0 0) # Request [same major].[older minor].0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.2.0.9 1 1 0 0) # Request [same major].[older minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.2.2.0 1 1 0 0) # Request [same major].[older minor].[older patch].0
+test_write_basic_config_version_file(4.5.6.7 4.2.2.2 1 1 0 0) # Request [same major].[older minor].[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.2.2.7 1 1 0 0) # Request [same major].[older minor].[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.2.2.9 1 1 0 0) # Request [same major].[older minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.2.6.0 1 1 0 0) # Request [same major].[older minor].[same patch].0
+test_write_basic_config_version_file(4.5.6.7 4.2.6.2 1 1 0 0) # Request [same major].[older minor].[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.2.6.7 1 1 0 0) # Request [same major].[older minor].[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.2.6.9 1 1 0 0) # Request [same major].[older minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.2.9.0 1 1 0 0) # Request [same major].[older minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 4.2.9.2 1 1 0 0) # Request [same major].[older minor].[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.2.9.7 1 1 0 0) # Request [same major].[older minor].[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.2.9.9 1 1 0 0) # Request [same major].[older minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.5.0.0 1 1 1 0) # Request [same major].[same minor].0.0
+test_write_basic_config_version_file(4.5.6.7 4.5.0.2 1 1 1 0) # Request [same major].[same minor].0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.5.0.7 1 1 1 0) # Request [same major].[same minor].0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.5.0.9 1 1 1 0) # Request [same major].[same minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.5.2.0 1 1 1 0) # Request [same major].[same minor].[older patch].0
+test_write_basic_config_version_file(4.5.6.7 4.5.2.2 1 1 1 0) # Request [same major].[same minor].[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.5.2.7 1 1 1 0) # Request [same major].[same minor].[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.5.2.9 1 1 1 0) # Request [same major].[same minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.5.6.0 1 1 1 1) # Request [same major].[same minor].[same patch].0
+test_write_basic_config_version_file(4.5.6.7 4.5.6.2 1 1 1 1) # Request [same major].[same minor].[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.5.6.7 1 1 1 1) # Request [same major].[same minor].[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.5.6.9 0 0 0 1) # Request [same major].[same minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.5.9.0 0 0 0 0) # Request [same major].[same minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 4.5.9.2 0 0 0 0) # Request [same major].[same minor].[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.5.9.7 0 0 0 0) # Request [same major].[same minor].[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.5.9.9 0 0 0 0) # Request [same major].[same minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.9.0.0 0 0 0 0) # Request [same major].[newer minor].0.0
+test_write_basic_config_version_file(4.5.6.7 4.9.0.2 0 0 0 0) # Request [same major].[newer minor].0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.9.0.7 0 0 0 0) # Request [same major].[newer minor].0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.9.0.9 0 0 0 0) # Request [same major].[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.9.2.0 0 0 0 0) # Request [same major].[newer minor].[older patch].0
+test_write_basic_config_version_file(4.5.6.7 4.9.2.2 0 0 0 0) # Request [same major].[newer minor].[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.9.2.7 0 0 0 0) # Request [same major].[newer minor].[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.9.2.9 0 0 0 0) # Request [same major].[newer minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.9.6.0 0 0 0 0) # Request [same major].[newer minor].[same patch].0
+test_write_basic_config_version_file(4.5.6.7 4.9.6.2 0 0 0 0) # Request [same major].[newer minor].[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.9.6.7 0 0 0 0) # Request [same major].[newer minor].[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.9.6.9 0 0 0 0) # Request [same major].[newer minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 4.9.9.0 0 0 0 0) # Request [same major].[newer minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 4.9.9.2 0 0 0 0) # Request [same major].[newer minor].[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 4.9.9.7 0 0 0 0) # Request [same major].[newer minor].[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 4.9.9.9 0 0 0 0) # Request [same major].[newer minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.0.0.0 0 0 0 0) # Request [newer major].0.0.0
+test_write_basic_config_version_file(4.5.6.7 9.0.0.2 0 0 0 0) # Request [newer major].0.0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.0.0.7 0 0 0 0) # Request [newer major].0.0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.0.0.9 0 0 0 0) # Request [newer major].0.0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.0.2.0 0 0 0 0) # Request [newer major].0.[older patch].0
+test_write_basic_config_version_file(4.5.6.7 9.0.2.2 0 0 0 0) # Request [newer major].0.[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.0.2.7 0 0 0 0) # Request [newer major].0.[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.0.2.9 0 0 0 0) # Request [newer major].0.[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.0.6.0 0 0 0 0) # Request [newer major].0.[same patch].0
+test_write_basic_config_version_file(4.5.6.7 9.0.6.2 0 0 0 0) # Request [newer major].0.[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.0.6.7 0 0 0 0) # Request [newer major].0.[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.0.6.9 0 0 0 0) # Request [newer major].0.[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.0.9.0 0 0 0 0) # Request [newer major].0.[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 9.0.9.2 0 0 0 0) # Request [newer major].0.[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.0.9.7 0 0 0 0) # Request [newer major].0.[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.0.9.9 0 0 0 0) # Request [newer major].0.[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.2.0.0 0 0 0 0) # Request [newer major].[older minor].0.0
+test_write_basic_config_version_file(4.5.6.7 9.2.0.2 0 0 0 0) # Request [newer major].[older minor].0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.2.0.7 0 0 0 0) # Request [newer major].[older minor].0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.2.0.9 0 0 0 0) # Request [newer major].[older minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.2.2.0 0 0 0 0) # Request [newer major].[older minor].[older patch].0
+test_write_basic_config_version_file(4.5.6.7 9.2.2.2 0 0 0 0) # Request [newer major].[older minor].[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.2.2.7 0 0 0 0) # Request [newer major].[older minor].[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.2.2.9 0 0 0 0) # Request [newer major].[older minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.2.6.0 0 0 0 0) # Request [newer major].[older minor].[same patch].0
+test_write_basic_config_version_file(4.5.6.7 9.2.6.2 0 0 0 0) # Request [newer major].[older minor].[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.2.6.7 0 0 0 0) # Request [newer major].[older minor].[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.2.6.9 0 0 0 0) # Request [newer major].[older minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.2.9.0 0 0 0 0) # Request [newer major].[older minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 9.2.9.2 0 0 0 0) # Request [newer major].[older minor].[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.2.9.7 0 0 0 0) # Request [newer major].[older minor].[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.2.9.9 0 0 0 0) # Request [newer major].[older minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.5.0.0 0 0 0 0) # Request [newer major].[same minor].0.0
+test_write_basic_config_version_file(4.5.6.7 9.5.0.2 0 0 0 0) # Request [newer major].[same minor].0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.5.0.7 0 0 0 0) # Request [newer major].[same minor].0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.5.0.9 0 0 0 0) # Request [newer major].[same minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.5.2.0 0 0 0 0) # Request [newer major].[same minor].[older patch].0
+test_write_basic_config_version_file(4.5.6.7 9.5.2.2 0 0 0 0) # Request [newer major].[same minor].[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.5.2.7 0 0 0 0) # Request [newer major].[same minor].[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.5.2.9 0 0 0 0) # Request [newer major].[same minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.5.6.0 0 0 0 0) # Request [newer major].[same minor].[same patch].0
+test_write_basic_config_version_file(4.5.6.7 9.5.6.2 0 0 0 0) # Request [newer major].[same minor].[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.5.6.7 0 0 0 0) # Request [newer major].[same minor].[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.5.6.9 0 0 0 0) # Request [newer major].[same minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.5.9.0 0 0 0 0) # Request [newer major].[same minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 9.5.9.2 0 0 0 0) # Request [newer major].[same minor].[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.5.9.7 0 0 0 0) # Request [newer major].[same minor].[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.5.9.9 0 0 0 0) # Request [newer major].[same minor].[newer patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.9.0.0 0 0 0 0) # Request [newer major].[newer minor].0.0
+test_write_basic_config_version_file(4.5.6.7 9.9.0.2 0 0 0 0) # Request [newer major].[newer minor].0.[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.9.0.7 0 0 0 0) # Request [newer major].[newer minor].0.[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.9.0.9 0 0 0 0) # Request [newer major].[newer minor].0.[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.9.2.0 0 0 0 0) # Request [newer major].[newer minor].[older patch].0
+test_write_basic_config_version_file(4.5.6.7 9.9.2.2 0 0 0 0) # Request [newer major].[newer minor].[older patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.9.2.7 0 0 0 0) # Request [newer major].[newer minor].[older patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.9.2.9 0 0 0 0) # Request [newer major].[newer minor].[older patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.9.6.0 0 0 0 0) # Request [newer major].[newer minor].[same patch].0
+test_write_basic_config_version_file(4.5.6.7 9.9.6.2 0 0 0 0) # Request [newer major].[newer minor].[same patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.9.6.7 0 0 0 0) # Request [newer major].[newer minor].[same patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.9.6.9 0 0 0 0) # Request [newer major].[newer minor].[same patch].[newer tweak]
+test_write_basic_config_version_file(4.5.6.7 9.9.9.0 0 0 0 0) # Request [newer major].[newer minor].[newer patch].0
+test_write_basic_config_version_file(4.5.6.7 9.9.9.2 0 0 0 0) # Request [newer major].[newer minor].[newer patch].[older tweak]
+test_write_basic_config_version_file(4.5.6.7 9.9.9.7 0 0 0 0) # Request [newer major].[newer minor].[newer patch].[same tweak]
+test_write_basic_config_version_file(4.5.6.7 9.9.9.9 0 0 0 0) # Request [newer major].[newer minor].[newer patch].[newer tweak]
diff --git a/Tests/RunCMake/WriteBasicConfigVersionFile/ArchIndependent.cmake b/Tests/RunCMake/WriteBasicConfigVersionFile/ArchIndependent.cmake
new file mode 100644
index 000000000..13ec5d1dd
--- /dev/null
+++ b/Tests/RunCMake/WriteBasicConfigVersionFile/ArchIndependent.cmake
@@ -0,0 +1,63 @@
+# Hard-code architecture for test without a real compiler.
+set(CMAKE_SIZEOF_VOID_P 4)
+
+include(WriteBasicConfigVersionFile)
+
+set(_dummy_version 1.0.0)
+
+set(_compatibilities AnyNewerVersion
+ SameMajorVersion
+ SameMinorVersion
+ ExactVersion)
+
+function(test_write_basic_config_version_file_arch_prepare filename_out compat arch_independent arch)
+ if(arch_independent)
+ set(arch_arg ARCH_INDEPENDENT)
+ else()
+ set(arch_arg )
+ endif()
+
+ set(filename "${CMAKE_CURRENT_BINARY_DIR}/${compat}Arch${arch_arg}ConfigVersion.cmake")
+
+ set(CMAKE_SIZEOF_VOID_P "${arch}")
+
+ write_basic_config_version_file("${filename}"
+ VERSION "${_dummy_version}"
+ COMPATIBILITY "${compat}"
+ ${arch_arg})
+
+ set("${filename_out}" "${filename}" PARENT_SCOPE)
+endfunction()
+
+function(test_write_basic_config_version_file_arch_check unsuitable_out filename arch)
+ set(CMAKE_SIZEOF_VOID_P "${arch}")
+ set(PACKAGE_FIND_VERSION "${_dummy_version}")
+
+ include("${filename}")
+
+ set("${unsuitable_out}" "${PACKAGE_VERSION_UNSUITABLE}" PARENT_SCOPE)
+endfunction()
+
+function(test_write_basic_config_version_file_arch_test expected_unsuitable compat arch_independent source_arch user_arch)
+ test_write_basic_config_version_file_arch_prepare(filename "${compat}" "${arch_independent}" "${source_arch}")
+ test_write_basic_config_version_file_arch_check(unsuitable "${filename}" "${user_arch}")
+ if(unsuitable AND NOT expected_unsuitable)
+ message(SEND_ERROR "Architecture was checked when it shouldn't have been. Compatibility: ${compat} ARCH_INDEPENDENT: ${arch_independent}.")
+ elseif(expected_unsuitable AND NOT unsuitable)
+ message(SEND_ERROR "Requested architecture check not performed. Compatibility: ${compat} ARCH_INDEPENDENT: ${arch_independent}.")
+ endif()
+endfunction()
+
+set(_unsuitable TRUE)
+set(_suitable FALSE)
+
+foreach(compat ${_compatibilities})
+ test_write_basic_config_version_file_arch_test("${_suitable}" "${compat}" TRUE 4 4)
+ test_write_basic_config_version_file_arch_test("${_suitable}" "${compat}" FALSE 4 4)
+ test_write_basic_config_version_file_arch_test("${_suitable}" "${compat}" TRUE 4 8)
+ test_write_basic_config_version_file_arch_test("${_unsuitable}" "${compat}" FALSE 4 8)
+ test_write_basic_config_version_file_arch_test("${_suitable}" "${compat}" TRUE 8 4)
+ test_write_basic_config_version_file_arch_test("${_unsuitable}" "${compat}" FALSE 8 4)
+ test_write_basic_config_version_file_arch_test("${_suitable}" "${compat}" TRUE 8 8)
+ test_write_basic_config_version_file_arch_test("${_suitable}" "${compat}" FALSE 8 8)
+endforeach()
diff --git a/Tests/RunCMake/WriteBasicConfigVersionFile/CMakeLists.txt b/Tests/RunCMake/WriteBasicConfigVersionFile/CMakeLists.txt
new file mode 100644
index 000000000..44025d3bd
--- /dev/null
+++ b/Tests/RunCMake/WriteBasicConfigVersionFile/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.12)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/WriteBasicConfigVersionFile/RunCMakeTest.cmake b/Tests/RunCMake/WriteBasicConfigVersionFile/RunCMakeTest.cmake
new file mode 100644
index 000000000..5db33f7f2
--- /dev/null
+++ b/Tests/RunCMake/WriteBasicConfigVersionFile/RunCMakeTest.cmake
@@ -0,0 +1,4 @@
+include(RunCMake)
+
+run_cmake(All)
+run_cmake(ArchIndependent)
diff --git a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt
index 044574404..f4449929f 100644
--- a/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt
+++ b/Tests/RunCMake/WriteCompilerDetectionHeader/InvalidFeature-stderr.txt
@@ -1,5 +1,6 @@
CMake Error at .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(message\):
Unsupported feature not_a_feature.
Call Stack \(most recent call first\):
+ .*Modules/WriteCompilerDetectionHeader.cmake:[0-9]+ \(_check_feature_lists\)
InvalidFeature.cmake:4 \(write_compiler_detection_header\)
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/XcodeProject/DeploymentTarget.c b/Tests/RunCMake/XcodeProject/DeploymentTarget.c
new file mode 100644
index 000000000..5e0f40fed
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/DeploymentTarget.c
@@ -0,0 +1,26 @@
+#include <Availability.h>
+#include <TargetConditionals.h>
+
+#if TARGET_OS_OSX
+# if __MAC_OS_X_VERSION_MIN_REQUIRED != __MAC_10_11
+# error macOS deployment version mismatch
+# endif
+#elif TARGET_OS_IOS
+# if __IPHONE_OS_VERSION_MIN_REQUIRED != __IPHONE_9_1
+# error iOS deployment version mismatch
+# endif
+#elif TARGET_OS_WATCH
+# if __WATCH_OS_VERSION_MIN_REQUIRED != __WATCHOS_2_0
+# error watchOS deployment version mismatch
+# endif
+#elif TARGET_OS_TV
+# if __TV_OS_VERSION_MIN_REQUIRED != __TVOS_9_0
+# error tvOS deployment version mismatch
+# endif
+#else
+# error unknown OS
+#endif
+
+void foo()
+{
+}
diff --git a/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake b/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake
new file mode 100644
index 000000000..288735e87
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/DeploymentTarget.cmake
@@ -0,0 +1,25 @@
+cmake_minimum_required(VERSION 3.10)
+project(DeploymentTarget C)
+
+# using Xcode 7.1 SDK versions for deployment targets
+
+if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "9.1")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
+ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
+elseif(CMAKE_SYSTEM_NAME STREQUAL "watchOS")
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "2.0")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
+ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
+elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS")
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "9.0")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
+ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
+else()
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11")
+endif()
+
+add_library(myFramework STATIC DeploymentTarget.c)
+set_target_properties(myFramework PROPERTIES FRAMEWORK TRUE)
diff --git a/Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake b/Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake
new file mode 100644
index 000000000..3073e0b87
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake
@@ -0,0 +1,20 @@
+set(xcProjectFile "${RunCMake_TEST_BINARY_DIR}/ExplicitCMakeLists.xcodeproj/project.pbxproj")
+if(NOT EXISTS "${xcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${xcProjectFile} does not exist.")
+ return()
+endif()
+
+set(foundCMakeLists 0)
+file(STRINGS "${xcProjectFile}" lines)
+foreach(line IN LISTS lines)
+ if(line MATCHES "PBXBuildFile.*fileRef.*CMakeLists.txt")
+ if(foundCMakeLists)
+ set(RunCMake_TEST_FAILED "CMakeLists.txt referenced multiple times")
+ return()
+ endif()
+ set(foundCMakeLists 1)
+ endif()
+endforeach()
+if(NOT foundCMakeLists)
+ set(RunCMake_TEST_FAILED "CMakeLists.txt not referenced")
+endif()
diff --git a/Tests/RunCMake/XcodeProject/ExplicitCMakeLists.cmake b/Tests/RunCMake/XcodeProject/ExplicitCMakeLists.cmake
new file mode 100644
index 000000000..678b0ea9d
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/ExplicitCMakeLists.cmake
@@ -0,0 +1,2 @@
+enable_language(CXX)
+add_executable(foo foo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt)
diff --git a/Tests/RunCMake/XcodeProject/ImplicitCMakeLists-check.cmake b/Tests/RunCMake/XcodeProject/ImplicitCMakeLists-check.cmake
new file mode 100644
index 000000000..c6bbc1be1
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/ImplicitCMakeLists-check.cmake
@@ -0,0 +1,20 @@
+set(xcProjectFile "${RunCMake_TEST_BINARY_DIR}/ImplicitCMakeLists.xcodeproj/project.pbxproj")
+if(NOT EXISTS "${xcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${xcProjectFile} does not exist.")
+ return()
+endif()
+
+set(foundCMakeLists 0)
+file(STRINGS "${xcProjectFile}" lines)
+foreach(line IN LISTS lines)
+ if(line MATCHES "PBXFileReference.*CMakeLists.txt")
+ if(foundCMakeLists)
+ set(RunCMake_TEST_FAILED "CMakeLists.txt referenced multiple times")
+ return()
+ endif()
+ set(foundCMakeLists 1)
+ endif()
+endforeach()
+if(NOT foundCMakeLists)
+ set(RunCMake_TEST_FAILED "CMakeLists.txt not referenced")
+endif()
diff --git a/Tests/RunCMake/XcodeProject/ImplicitCMakeLists.cmake b/Tests/RunCMake/XcodeProject/ImplicitCMakeLists.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/ImplicitCMakeLists.cmake
diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-result.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt
new file mode 100644
index 000000000..69c61e698
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Error in CMakeLists.txt:
+ Xcode does not support per-config per-source COMPILE_DEFINITIONS:
+
+ \$<\$<CONFIG:Debug>:MYDEBUG>
+
+ specified for source:
+
+ .*/Tests/RunCMake/XcodeProject/main.c
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions.cmake b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions.cmake
new file mode 100644
index 000000000..f9df55fe9
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+add_executable(main main.c)
+set_property(SOURCE main.c PROPERTY COMPILE_DEFINITIONS "$<$<CONFIG:Debug>:MYDEBUG>")
diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt
index 650064920..c3e9e318a 100644
--- a/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt
+++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceFlags-stderr.txt
@@ -5,4 +5,6 @@
specified for source:
- .*/Tests/RunCMake/XcodeProject/main.c$
+ .*/Tests/RunCMake/XcodeProject/main.c
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-result.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-stderr.txt
new file mode 100644
index 000000000..ff70b95a3
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Error in CMakeLists.txt:
+ Xcode does not support per-config per-source INCLUDE_DIRECTORIES:
+
+ \$<\$<CONFIG:Debug>:MYDEBUG>
+
+ specified for source:
+
+ .*/Tests/RunCMake/XcodeProject/main.c
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs.cmake b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs.cmake
new file mode 100644
index 000000000..4476c39fc
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceIncludeDirs.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+add_executable(main main.c)
+set_property(SOURCE main.c PROPERTY INCLUDE_DIRECTORIES "$<$<CONFIG:Debug>:MYDEBUG>")
diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-result.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-stderr.txt
new file mode 100644
index 000000000..100008a44
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Error in CMakeLists.txt:
+ Xcode does not support per-config per-source COMPILE_OPTIONS:
+
+ \$<\$<CONFIG:Debug>:-DMYDEBUG>
+
+ specified for source:
+
+ .*/Tests/RunCMake/XcodeProject/main.c
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions.cmake b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions.cmake
new file mode 100644
index 000000000..f8e803083
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceOptions.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+add_executable(main main.c)
+set_property(SOURCE main.c PROPERTY COMPILE_OPTIONS $<$<CONFIG:Debug>:-DMYDEBUG>)
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
index 5f4bdc30d..6ecf3f2c8 100644
--- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -1,26 +1,84 @@
include(RunCMake)
+run_cmake(ExplicitCMakeLists)
+run_cmake(ImplicitCMakeLists)
+
run_cmake(XcodeFileType)
run_cmake(XcodeAttributeLocation)
run_cmake(XcodeAttributeGenex)
run_cmake(XcodeAttributeGenexError)
+run_cmake(XcodeGenerateTopLevelProjectOnly)
run_cmake(XcodeObjectNeedsEscape)
run_cmake(XcodeObjectNeedsQuote)
run_cmake(XcodeOptimizationFlags)
run_cmake(XcodePreserveNonOptimizationFlags)
run_cmake(XcodePreserveObjcFlag)
+run_cmake(XcodePrecompileHeaders)
if (NOT XCODE_VERSION VERSION_LESS 6)
run_cmake(XcodePlatformFrameworks)
endif()
run_cmake(PerConfigPerSourceFlags)
+run_cmake(PerConfigPerSourceOptions)
+run_cmake(PerConfigPerSourceDefinitions)
+run_cmake(PerConfigPerSourceIncludeDirs)
+
+function(XcodeSchemaGeneration)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeSchemaGeneration-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_XCODE_GENERATE_SCHEME=ON")
+
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake(XcodeSchemaGeneration)
+ run_cmake_command(XcodeSchemaGeneration-build xcodebuild -scheme foo build)
+endfunction()
+
+if(NOT XCODE_VERSION VERSION_LESS 7)
+ XcodeSchemaGeneration()
+ run_cmake(XcodeSchemaProperty)
+endif()
+
+function(XcodeDependOnZeroCheck)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeDependOnZeroCheck-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake(XcodeDependOnZeroCheck)
+ run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target parentdirlib)
+ run_cmake_command(XcodeDependOnZeroCheck-build ${CMAKE_COMMAND} --build . --target subdirlib)
+endfunction()
+
+XcodeDependOnZeroCheck()
+
+function(XcodeObjcxxFlags testName)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake(${testName})
+ run_cmake_command(${testName}-build ${CMAKE_COMMAND} --build .)
+endfunction()
+
+XcodeObjcxxFlags(XcodeObjcFlags)
+XcodeObjcxxFlags(XcodeObjcxxFlags)
+
+# Isolate device tests from host architecture selection.
+unset(ENV{CMAKE_OSX_ARCHITECTURES})
# Use a single build tree for a few tests without cleaning.
if(NOT XCODE_VERSION VERSION_LESS 5)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeInstallIOS-build)
set(RunCMake_TEST_NO_CLEAN 1)
- set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/ios_install")
+ set(RunCMake_TEST_OPTIONS
+ "-DCMAKE_SYSTEM_NAME=iOS"
+ "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/ios_install")
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
@@ -35,7 +93,7 @@ if(NOT XCODE_VERSION VERSION_LESS 5)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesOSX-build)
set(RunCMake_TEST_NO_CLEAN 1)
set(RunCMake_TEST_OPTIONS
- "-DTEST_IOS=OFF"
+ "-DCMAKE_SYSTEM_NAME=Darwin"
"-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install")
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
@@ -52,7 +110,7 @@ if(NOT XCODE_VERSION VERSION_LESS 5)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesIOS-build)
set(RunCMake_TEST_NO_CLEAN 1)
set(RunCMake_TEST_OPTIONS
- "-DTEST_IOS=ON"
+ "-DCMAKE_SYSTEM_NAME=iOS"
"-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install")
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
@@ -71,7 +129,7 @@ if(NOT XCODE_VERSION VERSION_LESS 7)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesWatchOS-build)
set(RunCMake_TEST_NO_CLEAN 1)
set(RunCMake_TEST_OPTIONS
- "-DTEST_WATCHOS=ON"
+ "-DCMAKE_SYSTEM_NAME=watchOS"
"-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install")
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
@@ -90,7 +148,7 @@ if(NOT XCODE_VERSION VERSION_LESS 7.1)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeBundlesTvOS-build)
set(RunCMake_TEST_NO_CLEAN 1)
set(RunCMake_TEST_OPTIONS
- "-DTEST_TVOS=ON"
+ "-DCMAKE_SYSTEM_NAME=tvOS"
"-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install")
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
@@ -116,8 +174,9 @@ if(NOT XCODE_VERSION VERSION_LESS 6)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombined-build)
set(RunCMake_TEST_NO_CLEAN 1)
set(RunCMake_TEST_OPTIONS
- "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install"
- "-DCMAKE_IOS_INSTALL_COMBINED=YES")
+ "-DCMAKE_SYSTEM_NAME=iOS"
+ "-DCMAKE_IOS_INSTALL_COMBINED=YES"
+ "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install")
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
@@ -134,8 +193,9 @@ if(NOT XCODE_VERSION VERSION_LESS 6)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombinedPrune-build)
set(RunCMake_TEST_NO_CLEAN 1)
set(RunCMake_TEST_OPTIONS
- "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install"
- "-DCMAKE_IOS_INSTALL_COMBINED=YES")
+ "-DCMAKE_SYSTEM_NAME=iOS"
+ "-DCMAKE_IOS_INSTALL_COMBINED=YES"
+ "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install")
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
@@ -152,8 +212,9 @@ if(NOT XCODE_VERSION VERSION_LESS 6)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeIOSInstallCombinedSingleArch-build)
set(RunCMake_TEST_NO_CLEAN 1)
set(RunCMake_TEST_OPTIONS
- "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install"
- "-DCMAKE_IOS_INSTALL_COMBINED=YES")
+ "-DCMAKE_SYSTEM_NAME=iOS"
+ "-DCMAKE_IOS_INSTALL_COMBINED=YES"
+ "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_TEST_BINARY_DIR}/_install")
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
@@ -170,6 +231,7 @@ endif()
if(NOT XCODE_VERSION VERSION_LESS 5)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeMultiplatform-build)
set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_OPTIONS "${IOS_DEPLOYMENT_TARGET}")
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
@@ -188,18 +250,41 @@ if(NOT XCODE_VERSION VERSION_LESS 5)
unset(RunCMake_TEST_OPTIONS)
endif()
-function(XcodeSchemaGeneration)
- set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XcodeSchemaGeneration-build)
- set(RunCMake_TEST_NO_CLEAN 1)
- set(RunCMake_TEST_OPTIONS "-DCMAKE_XCODE_GENERATE_SCHEME=ON")
+if(XCODE_VERSION VERSION_GREATER_EQUAL 8)
+ function(deployment_target_test SystemName SDK)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/DeploymentTarget-${SDK}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=${SystemName}" "-DCMAKE_OSX_SYSROOT=${SDK}")
+
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake(DeploymentTarget)
+ run_cmake_command(DeploymentTarget-${SDK} ${CMAKE_COMMAND} --build .)
+ endfunction()
+
+ deployment_target_test(Darwin macosx)
+ deployment_target_test(iOS iphoneos)
+ deployment_target_test(iOS iphonesimulator)
+ deployment_target_test(tvOS appletvos)
+ deployment_target_test(tvOS appletvsimulator)
+ deployment_target_test(watchOS watchos)
+ deployment_target_test(watchOS watchsimulator)
+endif()
- file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
- file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+if(XCODE_VERSION VERSION_GREATER_EQUAL 8)
+ function(xctest_lookup_test SystemName SDK)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/XCTestLookup-${SDK}-build)
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_SYSTEM_NAME=${SystemName}" "-DCMAKE_OSX_SYSROOT=${SDK}")
- run_cmake(XcodeSchemaGeneration)
- run_cmake_command(XcodeSchemaGeneration-build xcodebuild -scheme foo build)
-endfunction()
+ run_cmake(XCTestLookup)
+ endfunction()
-if(NOT XCODE_VERSION VERSION_LESS 7)
- XcodeSchemaGeneration()
+ xctest_lookup_test(Darwin macosx)
+ xctest_lookup_test(iOS iphoneos)
+ xctest_lookup_test(iOS iphonesimulator)
+ xctest_lookup_test(tvOS appletvos)
+ xctest_lookup_test(tvOS appletvsimulator)
endif()
+
+# Please add macOS-only tests above before the device-specific tests.
diff --git a/Tests/RunCMake/XcodeProject/XCTestLookup.cmake b/Tests/RunCMake/XcodeProject/XCTestLookup.cmake
new file mode 100644
index 000000000..77676e5bd
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XCTestLookup.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+
+find_package(XCTest REQUIRED)
diff --git a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
index 0b854d80a..8c0b470c2 100644
--- a/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeBundles.cmake
@@ -3,24 +3,13 @@
cmake_minimum_required(VERSION 3.3)
enable_language(C)
-if(TEST_IOS)
- set(CMAKE_OSX_SYSROOT iphoneos)
- set(CMAKE_OSX_ARCHITECTURES "armv7")
- set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
- set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
-endif(TEST_IOS)
-
-if(TEST_WATCHOS)
- set(CMAKE_OSX_SYSROOT watchos)
- set(CMAKE_OSX_ARCHITECTURES "armv7k")
+if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
- set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
+ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
endif()
-if(TEST_TVOS)
- set(CMAKE_OSX_SYSROOT appletvos)
- set(CMAKE_OSX_ARCHITECTURES "arm64")
+if(CMAKE_SYSTEM_NAME STREQUAL "tvOS" OR CMAKE_SYSTEM_NAME STREQUAL "watchOS")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
@@ -38,7 +27,7 @@ add_dependencies(AppBundleTest AppBundle)
# with custom extension
-if (NOT TEST_IOS AND NOT TEST_WATCHOS AND NOT TEST_TVOS)
+if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_executable(AppBundleExt MACOSX_BUNDLE main.m)
set_target_properties(AppBundleExt PROPERTIES BUNDLE_EXTENSION "foo")
install(TARGETS AppBundleExt BUNDLE DESTINATION FooExtension)
@@ -52,7 +41,7 @@ endif()
# Shared Framework (not supported for iOS on Xcode < 6)
-if(NOT TEST_IOS OR NOT XCODE_VERSION VERSION_LESS 6)
+if(NOT CMAKE_SYSTEM_NAME STREQUAL "iOS" OR NOT XCODE_VERSION VERSION_LESS 6)
add_library(SharedFramework SHARED main.c)
set_target_properties(SharedFramework PROPERTIES FRAMEWORK TRUE)
diff --git a/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck-build-stdout.txt b/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck-build-stdout.txt
new file mode 100644
index 000000000..92c9a2948
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck-build-stdout.txt
@@ -0,0 +1 @@
+BUILD AGGREGATE TARGET ZERO_CHECK
diff --git a/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck.cmake b/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck.cmake
new file mode 100644
index 000000000..d759a6545
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeDependOnZeroCheck.cmake
@@ -0,0 +1,4 @@
+set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY TRUE)
+project(XcodeDependOnZeroCheck CXX)
+add_subdirectory(zerocheck)
+add_library(parentdirlib foo.cpp)
diff --git a/Tests/RunCMake/XcodeProject/XcodeGenerateTopLevelProjectOnly-check.cmake b/Tests/RunCMake/XcodeProject/XcodeGenerateTopLevelProjectOnly-check.cmake
new file mode 100644
index 000000000..64654af5e
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeGenerateTopLevelProjectOnly-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS "${RunCMake_TEST_BINARY_DIR}/subproject/subproject.xcodeproj")
+ message(SEND_ERROR "Unexpected project file for subproject found.")
+endif()
diff --git a/Tests/RunCMake/XcodeProject/XcodeGenerateTopLevelProjectOnly.cmake b/Tests/RunCMake/XcodeProject/XcodeGenerateTopLevelProjectOnly.cmake
new file mode 100644
index 000000000..7e53c494e
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeGenerateTopLevelProjectOnly.cmake
@@ -0,0 +1,3 @@
+set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY TRUE)
+project(XcodeGenerateTopLevelProjectOnly NONE)
+add_subdirectory(subproject)
diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake
index fc830b19e..c2210332e 100644
--- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombined.cmake
@@ -2,8 +2,16 @@ cmake_minimum_required(VERSION 3.3)
project(IOSInstallCombined CXX)
-set(CMAKE_OSX_SYSROOT iphoneos)
+if(XCODE_VERSION VERSION_GREATER_EQUAL 9)
+ set(CMAKE_OSX_DEPLOYMENT_TARGET 10)
+endif()
+
+if(NOT IOS)
+ message(FATAL_ERROR "IOS variable is not set")
+endif()
+
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
+set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf")
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake
index b47d3a597..172f2e85e 100644
--- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedPrune.cmake
@@ -2,8 +2,12 @@ cmake_minimum_required(VERSION 3.3)
project(XcodeIOSInstallCombinedPrune CXX)
-set(CMAKE_OSX_SYSROOT iphoneos)
+if(XCODE_VERSION VERSION_GREATER_EQUAL 9)
+ set(CMAKE_OSX_DEPLOYMENT_TARGET 10)
+endif()
+
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
+set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf")
add_library(foo SHARED foo.cpp)
diff --git a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake
index 4b5e7ce36..038a89057 100644
--- a/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeIOSInstallCombinedSingleArch.cmake
@@ -2,8 +2,12 @@ cmake_minimum_required(VERSION 3.3)
project(XcodeIOSInstallCombinedSingleArch CXX)
-set(CMAKE_OSX_SYSROOT iphoneos)
+if(XCODE_VERSION VERSION_GREATER_EQUAL 9)
+ set(CMAKE_OSX_DEPLOYMENT_TARGET 10)
+endif()
+
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
+set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf")
add_library(foo SHARED foo.cpp)
diff --git a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake
index a79741069..ab31387cd 100644
--- a/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeInstallIOS.cmake
@@ -2,11 +2,8 @@ cmake_minimum_required(VERSION 2.8.5)
project(XcodeInstallIOS)
-set(CMAKE_OSX_SYSROOT iphoneos)
set(XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
-set(CMAKE_OSX_ARCHITECTURES "armv7;i386")
-
add_library(foo STATIC foo.cpp)
install(TARGETS foo ARCHIVE DESTINATION lib)
diff --git a/Tests/RunCMake/XcodeProject/XcodeObjcFlags.cmake b/Tests/RunCMake/XcodeProject/XcodeObjcFlags.cmake
new file mode 100644
index 000000000..4840276ae
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeObjcFlags.cmake
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 3.15)
+project(objctest LANGUAGES C OBJC)
+
+include(CheckOBJCCompilerFlag)
+check_objc_compiler_flag(-fobjc-arc HAVE_OBJC_ARC)
+
+if(HAVE_OBJC_ARC)
+ add_compile_options(-fobjc-arc)
+ add_compile_definitions(HAVE_OBJC_ARC)
+endif()
+
+add_library(myfuncs STATIC myfuncs.m)
diff --git a/Tests/RunCMake/XcodeProject/XcodeObjcxxFlags.cmake b/Tests/RunCMake/XcodeProject/XcodeObjcxxFlags.cmake
new file mode 100644
index 000000000..0ad942f28
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeObjcxxFlags.cmake
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 3.15)
+project(objcxxtest LANGUAGES CXX OBJCXX)
+
+include(CheckOBJCXXCompilerFlag)
+check_objcxx_compiler_flag(-fobjc-arc HAVE_OBJC_ARC)
+
+if(HAVE_OBJC_ARC)
+ add_compile_options(-fobjc-arc)
+ add_compile_definitions(HAVE_OBJC_ARC)
+endif()
+
+add_library(myfuncs STATIC myfuncs.mm)
diff --git a/Tests/RunCMake/XcodeProject/XcodePrecompileHeaders-check.cmake b/Tests/RunCMake/XcodeProject/XcodePrecompileHeaders-check.cmake
new file mode 100644
index 000000000..aa3eafc26
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodePrecompileHeaders-check.cmake
@@ -0,0 +1,35 @@
+set(pch_header "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/tgt.dir/cmake_pch.hxx")
+
+if(NOT EXISTS "${pch_header}")
+ set(RunCMake_TEST_FAILED "Generated PCH header ${pch_header} does not exist.")
+ return()
+endif()
+
+set(tgt_project "${RunCMake_TEST_BINARY_DIR}/XcodePrecompileHeaders.xcodeproj/project.pbxproj")
+if (NOT EXISTS "${tgt_project}")
+ set(RunCMake_TEST_FAILED "Generated project file ${tgt_project} doesn't exist.")
+ return()
+endif()
+
+file(STRINGS ${tgt_project} tgt_projects_strings)
+
+foreach(line IN LISTS tgt_projects_strings)
+ if (line MATCHES "GCC_PRECOMPILE_PREFIX_HEADER = YES;")
+ set(have_pch_prefix ON)
+ endif()
+
+ string(FIND "${line}" "GCC_PREFIX_HEADER = \"${pch_header}\";" find_pos)
+ if (NOT find_pos EQUAL "-1")
+ set(have_pch_header ON)
+ endif()
+endforeach()
+
+if (NOT have_pch_prefix)
+ set(RunCMake_TEST_FAILED "Generated project should have the GCC_PRECOMPILE_PREFIX_HEADER = YES; line.")
+ return()
+endif()
+
+if (NOT have_pch_header)
+ set(RunCMake_TEST_FAILED "Generated project should have the GCC_PREFIX_HEADER = \"${pch_header}\"; line.")
+ return()
+endif()
diff --git a/Tests/RunCMake/XcodeProject/XcodePrecompileHeaders.cmake b/Tests/RunCMake/XcodeProject/XcodePrecompileHeaders.cmake
new file mode 100644
index 000000000..f86bcf415
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodePrecompileHeaders.cmake
@@ -0,0 +1,4 @@
+project(XcodePrecompileHeaders CXX)
+
+add_library(tgt foo.cpp)
+target_precompile_headers(tgt PRIVATE stdafx.h)
diff --git a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake
new file mode 100644
index 000000000..7d83a7034
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty-check.cmake
@@ -0,0 +1,52 @@
+function(check_property property matcher)
+ set(schema "${RunCMake_TEST_BINARY_DIR}/XcodeSchemaProperty.xcodeproj/xcshareddata/xcschemes/${property}.xcscheme")
+ file(STRINGS ${schema} actual-${property}
+ REGEX "${matcher}" LIMIT_COUNT 1)
+ if(NOT actual-${property})
+ message(SEND_ERROR "Xcode schema property ${property}: Could not find ${matcher} in schema ${schema}")
+ endif()
+endfunction()
+
+function(expect_schema target)
+ set(schema "${RunCMake_TEST_BINARY_DIR}/XcodeSchemaProperty.xcodeproj/xcshareddata/xcschemes/${target}.xcscheme")
+ if(NOT EXISTS ${schema})
+ message(SEND_ERROR "Missing schema for target ${target}")
+ endif()
+endfunction()
+
+function(expect_no_schema target)
+ set(schema "${RunCMake_TEST_BINARY_DIR}/XcodeSchemaProperty.xcodeproj/xcshareddata/xcschemes/${target}.xcscheme")
+ if(EXISTS ${schema})
+ message(SEND_ERROR "Found unexpected schema ${schema}")
+ endif()
+endfunction()
+
+check_property("ADDRESS_SANITIZER" "enableAddressSanitizer")
+check_property("ADDRESS_SANITIZER_USE_AFTER_RETURN" "enableASanStackUseAfterReturn")
+check_property("THREAD_SANITIZER" "enableThreadSanitizer")
+check_property("THREAD_SANITIZER_STOP" "stopOnEveryThreadSanitizerIssue")
+check_property("UNDEFINED_BEHAVIOUR_SANITIZER" "enableUBSanitizer")
+check_property("UNDEFINED_BEHAVIOUR_SANITIZER_STOP" "stopOnEveryUBSanitizerIssue")
+check_property("DISABLE_MAIN_THREAD_CHECKER" "disableMainThreadChecker")
+check_property("MAIN_THREAD_CHECKER_STOP" "stopOnEveryMainThreadCheckerIssue")
+
+check_property("MALLOC_SCRIBBLE" "MallocScribble")
+check_property("MALLOC_GUARD_EDGES" "MallocGuardEdges")
+check_property("GUARD_MALLOC" "DYLD_INSERT_LIBRARIES")
+check_property("ZOMBIE_OBJECTS" "NSZombieEnabled")
+check_property("MALLOC_STACK" "MallocStackLogging")
+check_property("DYNAMIC_LINKER_API_USAGE" "DYLD_PRINT_APIS")
+check_property("DYNAMIC_LIBRARY_LOADS" "DYLD_PRINT_LIBRARIES")
+
+check_property("EXECUTABLE" "myExecutable")
+check_property("ARGUMENTS" [=["--foo"]=])
+check_property("ARGUMENTS" [=["--bar=baz"]=])
+check_property("ENVIRONMENT" [=[key="FOO"]=])
+check_property("ENVIRONMENT" [=[value="foo"]=])
+check_property("ENVIRONMENT" [=[key="BAR"]=])
+check_property("ENVIRONMENT" [=[value="bar"]=])
+
+expect_no_schema("NoSchema")
+
+expect_schema("CustomTarget")
+expect_schema("ALL_BUILD")
diff --git a/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake
new file mode 100644
index 000000000..be219f411
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeSchemaProperty.cmake
@@ -0,0 +1,42 @@
+cmake_minimum_required(VERSION 3.7)
+
+set(CMAKE_XCODE_GENERATE_SCHEME ON)
+
+project(XcodeSchemaProperty CXX)
+
+function(create_scheme_for_variable variable)
+ set(CMAKE_XCODE_SCHEME_${variable} ON)
+ add_executable(${variable} main.cpp)
+endfunction()
+
+create_scheme_for_variable(ADDRESS_SANITIZER)
+create_scheme_for_variable(ADDRESS_SANITIZER_USE_AFTER_RETURN)
+create_scheme_for_variable(THREAD_SANITIZER)
+create_scheme_for_variable(THREAD_SANITIZER_STOP)
+create_scheme_for_variable(UNDEFINED_BEHAVIOUR_SANITIZER)
+create_scheme_for_variable(UNDEFINED_BEHAVIOUR_SANITIZER_STOP)
+create_scheme_for_variable(DISABLE_MAIN_THREAD_CHECKER)
+create_scheme_for_variable(MAIN_THREAD_CHECKER_STOP)
+
+create_scheme_for_variable(MALLOC_SCRIBBLE)
+create_scheme_for_variable(MALLOC_GUARD_EDGES)
+create_scheme_for_variable(GUARD_MALLOC)
+create_scheme_for_variable(ZOMBIE_OBJECTS)
+create_scheme_for_variable(MALLOC_STACK)
+create_scheme_for_variable(DYNAMIC_LINKER_API_USAGE)
+create_scheme_for_variable(DYNAMIC_LIBRARY_LOADS)
+
+function(create_scheme_for_property property value)
+ set(XCODE_SCHEME_${property} ON)
+ add_executable(${property} main.cpp)
+ set_target_properties(${property} PROPERTIES XCODE_SCHEME_${property} "${value}")
+endfunction()
+
+create_scheme_for_property(EXECUTABLE myExecutable)
+create_scheme_for_property(ARGUMENTS "--foo;--bar=baz")
+create_scheme_for_property(ENVIRONMENT "FOO=foo;BAR=bar")
+
+add_executable(NoSchema main.cpp)
+set_target_properties(NoSchema PROPERTIES XCODE_GENERATE_SCHEME OFF)
+
+add_custom_target(CustomTarget)
diff --git a/Tests/RunCMake/XcodeProject/myfuncs.m b/Tests/RunCMake/XcodeProject/myfuncs.m
new file mode 100644
index 000000000..742ba8ecf
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/myfuncs.m
@@ -0,0 +1,3 @@
+#if defined(HAVE_OBJC_ARC) && ! __has_feature(objc_arc)
+#error THIS CODE MUST BE COMPILED WITH ARC ENABLED!
+#endif
diff --git a/Tests/RunCMake/XcodeProject/myfuncs.mm b/Tests/RunCMake/XcodeProject/myfuncs.mm
new file mode 100644
index 000000000..742ba8ecf
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/myfuncs.mm
@@ -0,0 +1,3 @@
+#if defined(HAVE_OBJC_ARC) && ! __has_feature(objc_arc)
+#error THIS CODE MUST BE COMPILED WITH ARC ENABLED!
+#endif
diff --git a/Tests/RunCMake/XcodeProject/subproject/CMakeLists.txt b/Tests/RunCMake/XcodeProject/subproject/CMakeLists.txt
new file mode 100644
index 000000000..20e12b17c
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/subproject/CMakeLists.txt
@@ -0,0 +1 @@
+project(subproject)
diff --git a/Tests/RunCMake/XcodeProject/zerocheck/CMakeLists.txt b/Tests/RunCMake/XcodeProject/zerocheck/CMakeLists.txt
new file mode 100644
index 000000000..4adde99d7
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/zerocheck/CMakeLists.txt
@@ -0,0 +1,2 @@
+project(subproject)
+add_library(subdirlib ../foo.cpp)
diff --git a/Tests/RunCMake/add_custom_command/AppendLiteralQuotes-result.txt b/Tests/RunCMake/add_custom_command/AppendLiteralQuotes-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/AppendLiteralQuotes-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_custom_command/AppendLiteralQuotes-stderr.txt b/Tests/RunCMake/add_custom_command/AppendLiteralQuotes-stderr.txt
new file mode 100644
index 000000000..503385fdc
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/AppendLiteralQuotes-stderr.txt
@@ -0,0 +1,7 @@
+CMake Error at AppendLiteralQuotes.cmake:2 \(add_custom_command\):
+ COMMAND may not contain literal quotes:
+
+ "c"
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/add_custom_command/AppendLiteralQuotes.cmake b/Tests/RunCMake/add_custom_command/AppendLiteralQuotes.cmake
new file mode 100644
index 000000000..038fb3f92
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/AppendLiteralQuotes.cmake
@@ -0,0 +1,2 @@
+add_custom_command(OUTPUT a COMMAND b)
+add_custom_command(OUTPUT a COMMAND "\"c\"" APPEND)
diff --git a/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt b/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt
index cd542d875..b7ee23a55 100644
--- a/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt
+++ b/Tests/RunCMake/add_custom_command/AppendNotOutput-stderr.txt
@@ -1,7 +1,7 @@
CMake Error at AppendNotOutput.cmake:1 \(add_custom_command\):
add_custom_command given APPEND option with output
- .*RunCMake/add_custom_command/AppendNotOutput-build/out.*
+ .*RunCMake/add_custom_command/AppendNotOutput-build/out
which is not already a custom command output.
Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/add_custom_command/AssigningMultipleTargets.cmake b/Tests/RunCMake/add_custom_command/AssigningMultipleTargets.cmake
new file mode 100644
index 000000000..fe1cceb9a
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/AssigningMultipleTargets.cmake
@@ -0,0 +1,13 @@
+enable_language(CXX)
+
+add_custom_command(OUTPUT generated.cpp
+ MAIN_DEPENDENCY a.c
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/generate-once.cmake ${CMAKE_CURRENT_BINARY_DIR}/generated.cpp
+ VERBATIM)
+
+add_executable(exe1 ${CMAKE_CURRENT_BINARY_DIR}/generated.cpp)
+add_executable(exe2 ${CMAKE_CURRENT_BINARY_DIR}/generated.cpp)
+add_executable(exe3 ${CMAKE_CURRENT_BINARY_DIR}/generated.cpp)
+
+add_dependencies(exe1 exe2)
+add_dependencies(exe3 exe1)
diff --git a/Tests/RunCMake/add_custom_command/BadByproduct-result.txt b/Tests/RunCMake/add_custom_command/BadByproduct-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/BadByproduct-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt
new file mode 100644
index 000000000..086e39752
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/BadByproduct-stderr.txt
@@ -0,0 +1,36 @@
+CMake Error at BadByproduct.cmake:2 \(add_custom_command\):
+ add_custom_command called with BYPRODUCTS containing a "#". This character
+ is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:3 \(add_custom_command\):
+ add_custom_command called with BYPRODUCTS containing a "<". This character
+ is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:4 \(add_custom_command\):
+ add_custom_command called with BYPRODUCTS containing a ">". This character
+ is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:5 \(add_custom_command\):
+ add_custom_command called with BYPRODUCTS containing a "<". This character
+ is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:6 \(add_custom_command\):
+ add_custom_command attempted to have a file
+
+ .*RunCMake/add_custom_command/f
+
+ in a source directory as an output of custom command.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/add_custom_command/BadByproduct.cmake b/Tests/RunCMake/add_custom_command/BadByproduct.cmake
new file mode 100644
index 000000000..91bca5220
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/BadByproduct.cmake
@@ -0,0 +1,6 @@
+set(CMAKE_DISABLE_SOURCE_CHANGES ON)
+add_custom_command(OUTPUT a BYPRODUCTS "a#")
+add_custom_command(OUTPUT b BYPRODUCTS "a<")
+add_custom_command(OUTPUT c BYPRODUCTS "a>")
+add_custom_command(OUTPUT d BYPRODUCTS "$<CONFIG>/#")
+add_custom_command(OUTPUT e BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/f)
diff --git a/Tests/RunCMake/add_custom_command/BadOutput-result.txt b/Tests/RunCMake/add_custom_command/BadOutput-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/BadOutput-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt b/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt
new file mode 100644
index 000000000..731e58d03
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/BadOutput-stderr.txt
@@ -0,0 +1,36 @@
+CMake Error at BadOutput.cmake:2 \(add_custom_command\):
+ add_custom_command called with OUTPUT containing a "#". This character is
+ not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadOutput.cmake:3 \(add_custom_command\):
+ add_custom_command called with OUTPUT containing a "<". This character is
+ not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadOutput.cmake:4 \(add_custom_command\):
+ add_custom_command called with OUTPUT containing a ">". This character is
+ not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadOutput.cmake:5 \(add_custom_command\):
+ add_custom_command called with OUTPUT containing a "<". This character is
+ not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadOutput.cmake:6 \(add_custom_command\):
+ add_custom_command attempted to have a file
+
+ .*RunCMake/add_custom_command/e
+
+ in a source directory as an output of custom command.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/add_custom_command/BadOutput.cmake b/Tests/RunCMake/add_custom_command/BadOutput.cmake
new file mode 100644
index 000000000..6875fe966
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/BadOutput.cmake
@@ -0,0 +1,6 @@
+set(CMAKE_DISABLE_SOURCE_CHANGES ON)
+add_custom_command(OUTPUT "a#" COMMAND a)
+add_custom_command(OUTPUT "a<" COMMAND b)
+add_custom_command(OUTPUT "a>" COMMAND c)
+add_custom_command(OUTPUT "$<CONFIG>/#" COMMAND d)
+add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/e COMMAND f)
diff --git a/Tests/RunCMake/add_custom_command/GeneratedProperty.cmake b/Tests/RunCMake/add_custom_command/GeneratedProperty.cmake
new file mode 100644
index 000000000..628134b8b
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/GeneratedProperty.cmake
@@ -0,0 +1,10 @@
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/a"
+ BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/b"
+ COMMAND c
+ )
+get_source_file_property(GENERATED_A "${CMAKE_CURRENT_BINARY_DIR}/a" GENERATED)
+get_source_file_property(GENERATED_B "${CMAKE_CURRENT_BINARY_DIR}/b" GENERATED)
+if(NOT GENERATED_A OR NOT GENERATED_B)
+ message(FATAL_ERROR "failed")
+endif()
diff --git a/Tests/RunCMake/add_custom_command/LiteralQuotes-result.txt b/Tests/RunCMake/add_custom_command/LiteralQuotes-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/LiteralQuotes-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_custom_command/LiteralQuotes-stderr.txt b/Tests/RunCMake/add_custom_command/LiteralQuotes-stderr.txt
new file mode 100644
index 000000000..e7d615555
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/LiteralQuotes-stderr.txt
@@ -0,0 +1,7 @@
+CMake Error at LiteralQuotes.cmake:1 \(add_custom_command\):
+ COMMAND may not contain literal quotes:
+
+ "b"
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/add_custom_command/LiteralQuotes.cmake b/Tests/RunCMake/add_custom_command/LiteralQuotes.cmake
new file mode 100644
index 000000000..046ddd902
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/LiteralQuotes.cmake
@@ -0,0 +1 @@
+add_custom_command(OUTPUT a COMMAND "\"b\"")
diff --git a/Tests/RunCMake/add_custom_command/RemoveEmptyCommands-check.cmake b/Tests/RunCMake/add_custom_command/RemoveEmptyCommands-check.cmake
new file mode 100644
index 000000000..b2970444e
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/RemoveEmptyCommands-check.cmake
@@ -0,0 +1,63 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/exe.vcxproj")
+if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+endif()
+
+set(inGroup FALSE)
+set(inCommand FALSE)
+
+set(expected_Debug
+ "cmd_1 cmd_1_arg"
+ "cmd_1_dbg cmd_1_dbg_arg"
+ "cmd_2_dbg cmd_2_dbg_arg"
+ "cmd_3_dbg cmd_3_dbg_arg")
+
+set(expected_Release
+ "cmd_1 cmd_1_arg"
+ "cmd_3_rel cmd_3_rel_arg")
+
+# extract build events
+file(STRINGS "${vcProjectFile}" lines)
+foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<ItemDefinitionGroup Condition=.*Configuration.*Platform.*>$")
+ set(inGroup TRUE)
+ string(REGEX MATCH "=='(.*)\\|(.*)'" out ${line})
+ set(config ${CMAKE_MATCH_1})
+ elseif(line MATCHES "^ *</ItemDefinitionGroup>$")
+ set(inGroup FALSE)
+ elseif(inGroup)
+ if(line MATCHES "^ *<Command>.*$")
+ set(inCommand TRUE)
+ string(REGEX MATCH "<Command>(.*)" cmd ${line})
+ set(currentCommand ${CMAKE_MATCH_1})
+ elseif(line MATCHES "^(.*)</Command>$")
+ string(REGEX MATCH "(.*)</Command>" cmd ${line})
+ list(APPEND currentCommand ${CMAKE_MATCH_1})
+ set(command_${config} ${currentCommand})
+ set(inCommand FALSE)
+ elseif(inCommand)
+ list(APPEND currentCommand ${line})
+ endif()
+ endif()
+endforeach()
+
+foreach(config "Debug" "Release")
+ set(currentName command_${config})
+ set(expectedName expected_${config})
+ set(strippedCommand "")
+ if(DEFINED ${currentName})
+ foreach(v ${${currentName}})
+ if(${v} MATCHES "cmd_")
+ list(APPEND strippedCommand ${v})
+ endif()
+ endforeach()
+ if(NOT "${strippedCommand}" STREQUAL
+ "${${expectedName}}")
+ message(" - ${strippedCommand}")
+ message(" + ${${expectedName}}")
+ set(RunCMake_TEST_FAILED "build event command does not match")
+ return()
+ endif()
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/add_custom_command/RemoveEmptyCommands.cmake b/Tests/RunCMake/add_custom_command/RemoveEmptyCommands.cmake
new file mode 100644
index 000000000..eb190cc99
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/RemoveEmptyCommands.cmake
@@ -0,0 +1,22 @@
+enable_language(CXX)
+
+# reduce number of configuration types
+set(CMAKE_CONFIGURATION_TYPES "Debug" "Release")
+
+set(main_file "${CMAKE_BINARY_DIR}/main.cpp")
+file(WRITE "${main_file}" "test")
+add_executable(exe "${main_file}")
+
+# add one command for all and one for debug only
+add_custom_command(TARGET exe
+ COMMAND "cmd_1" "cmd_1_arg"
+ COMMAND $<$<CONFIG:Debug>:cmd_1_dbg> $<$<CONFIG:Debug>:cmd_1_dbg_arg>)
+
+# add command for debug only
+add_custom_command(TARGET exe
+ COMMAND $<$<CONFIG:Debug>:cmd_2_dbg> $<$<CONFIG:Debug>:cmd_2_dbg_arg>)
+
+# add separate commands for configurations
+add_custom_command(TARGET exe
+ COMMAND $<$<CONFIG:Debug>:cmd_3_dbg> $<$<CONFIG:Debug>:cmd_3_dbg_arg>
+ COMMAND $<$<CONFIG:Release>:cmd_3_rel> $<$<CONFIG:Release>:cmd_3_rel_arg>)
diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
index 397c63d0a..96642faf1 100644
--- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
+++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
@@ -1,12 +1,29 @@
include(RunCMake)
+run_cmake(AppendLiteralQuotes)
run_cmake(AppendNoOutput)
run_cmake(AppendNotOutput)
run_cmake(BadArgument)
+run_cmake(BadByproduct)
+run_cmake(BadOutput)
+run_cmake(GeneratedProperty)
+run_cmake(LiteralQuotes)
run_cmake(NoArguments)
run_cmake(NoOutputOrTarget)
run_cmake(OutputAndTarget)
run_cmake(SourceByproducts)
run_cmake(SourceUsesTerminal)
run_cmake(TargetImported)
+run_cmake(TargetLiteralQuotes)
run_cmake(TargetNotInDir)
+
+if(${RunCMake_GENERATOR} MATCHES "Visual Studio ([^89]|[89][0-9])")
+ run_cmake(RemoveEmptyCommands)
+endif()
+
+run_cmake(AssigningMultipleTargets)
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AssigningMultipleTargets-build)
+set(RunCMake_TEST_NO_CLEAN 1)
+run_cmake_command(AssigningMultipleTargets-build ${CMAKE_COMMAND} --build .)
+unset(RunCMake_TEST_BINARY_DIR)
+unset(RunCMake_TEST_NO_CLEAN)
diff --git a/Tests/RunCMake/add_custom_command/TargetLiteralQuotes-result.txt b/Tests/RunCMake/add_custom_command/TargetLiteralQuotes-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/TargetLiteralQuotes-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_custom_command/TargetLiteralQuotes-stderr.txt b/Tests/RunCMake/add_custom_command/TargetLiteralQuotes-stderr.txt
new file mode 100644
index 000000000..c4589b4b3
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/TargetLiteralQuotes-stderr.txt
@@ -0,0 +1,7 @@
+CMake Error at TargetLiteralQuotes.cmake:2 \(add_custom_command\):
+ COMMAND may not contain literal quotes:
+
+ "b"
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/add_custom_command/TargetLiteralQuotes.cmake b/Tests/RunCMake/add_custom_command/TargetLiteralQuotes.cmake
new file mode 100644
index 000000000..5f11ed1a4
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/TargetLiteralQuotes.cmake
@@ -0,0 +1,2 @@
+add_library(a)
+add_custom_command(TARGET a POST_BUILD COMMAND "\"b\"")
diff --git a/Tests/RunCMake/add_custom_command/a.c b/Tests/RunCMake/add_custom_command/a.c
new file mode 100644
index 000000000..707c1c380
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/a.c
@@ -0,0 +1,3 @@
+void a()
+{
+}
diff --git a/Tests/RunCMake/add_custom_command/generate-once.cmake b/Tests/RunCMake/add_custom_command/generate-once.cmake
new file mode 100644
index 000000000..2a8e8433e
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/generate-once.cmake
@@ -0,0 +1,8 @@
+if (${CMAKE_ARGC} LESS 4)
+ message(FATAL_ERROR "Too few arguments")
+endif()
+set(output "${CMAKE_ARGV3}")
+if(EXISTS ${output})
+ message(FATAL_ERROR "${output} already exists")
+endif()
+file(WRITE ${output} "int main() { return 0; }\n")
diff --git a/Tests/RunCMake/add_custom_target/BadByproduct-result.txt b/Tests/RunCMake/add_custom_target/BadByproduct-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/BadByproduct-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt b/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt
new file mode 100644
index 000000000..0f58550a3
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/BadByproduct-stderr.txt
@@ -0,0 +1,36 @@
+CMake Error at BadByproduct.cmake:2 \(add_custom_target\):
+ add_custom_target called with BYPRODUCTS containing a "#". This character
+ is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:3 \(add_custom_target\):
+ add_custom_target called with BYPRODUCTS containing a "<". This character
+ is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:4 \(add_custom_target\):
+ add_custom_target called with BYPRODUCTS containing a ">". This character
+ is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:5 \(add_custom_target\):
+ add_custom_target called with BYPRODUCTS containing a "<". This character
+ is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at BadByproduct.cmake:6 \(add_custom_target\):
+ add_custom_target attempted to have a file
+
+ .*RunCMake/add_custom_target/j
+
+ in a source directory as an output of custom command.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/add_custom_target/BadByproduct.cmake b/Tests/RunCMake/add_custom_target/BadByproduct.cmake
new file mode 100644
index 000000000..963d6416b
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/BadByproduct.cmake
@@ -0,0 +1,6 @@
+set(CMAKE_DISABLE_SOURCE_CHANGES ON)
+add_custom_target(a BYPRODUCTS "a#" COMMAND b)
+add_custom_target(c BYPRODUCTS "a<" COMMAND d)
+add_custom_target(e BYPRODUCTS "a>" COMMAND f)
+add_custom_target(g BYPRODUCTS "$<CONFIG>/#" COMMAND h)
+add_custom_target(i BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/j COMMAND k)
diff --git a/Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake b/Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake
new file mode 100644
index 000000000..bc899a4d2
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/CommandExpandsEmpty.cmake
@@ -0,0 +1 @@
+add_custom_target(EmptyCustom COMMAND "" COMMAND_EXPAND_LISTS)
diff --git a/Tests/RunCMake/add_custom_target/GeneratedProperty.cmake b/Tests/RunCMake/add_custom_target/GeneratedProperty.cmake
new file mode 100644
index 000000000..d03453494
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/GeneratedProperty.cmake
@@ -0,0 +1,14 @@
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/a"
+ COMMAND b
+ )
+add_custom_target(CollapseFullPath
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/a"
+ BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/c"
+ COMMAND d
+ )
+get_source_file_property(GENERATED_A "${CMAKE_CURRENT_BINARY_DIR}/a" GENERATED)
+get_source_file_property(GENERATED_C "${CMAKE_CURRENT_BINARY_DIR}/c" GENERATED)
+if(NOT GENERATED_A OR NOT GENERATED_C)
+ message(FATAL_ERROR "failed")
+endif()
diff --git a/Tests/RunCMake/add_custom_target/LiteralQuotes-result.txt b/Tests/RunCMake/add_custom_target/LiteralQuotes-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/LiteralQuotes-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_custom_target/LiteralQuotes-stderr.txt b/Tests/RunCMake/add_custom_target/LiteralQuotes-stderr.txt
new file mode 100644
index 000000000..bc5187adc
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/LiteralQuotes-stderr.txt
@@ -0,0 +1,7 @@
+CMake Error at LiteralQuotes.cmake:1 \(add_custom_target\):
+ COMMAND may not contain literal quotes:
+
+ "b"
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/add_custom_target/LiteralQuotes.cmake b/Tests/RunCMake/add_custom_target/LiteralQuotes.cmake
new file mode 100644
index 000000000..987060852
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/LiteralQuotes.cmake
@@ -0,0 +1 @@
+add_custom_target(a COMMAND "\"b\"")
diff --git a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
index 6c4e91bca..f5d5dd2b5 100644
--- a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
+++ b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
@@ -1,8 +1,12 @@
include(RunCMake)
-run_cmake(NoArguments)
+run_cmake(BadByproduct)
run_cmake(BadTargetName)
run_cmake(ByproductsNoCommand)
+run_cmake(CommandExpandsEmpty)
+run_cmake(GeneratedProperty)
+run_cmake(LiteralQuotes)
+run_cmake(NoArguments)
run_cmake(UsesTerminalNoCommand)
function(run_TargetOrder)
diff --git a/Tests/RunCMake/add_executable/CMakeLists.txt b/Tests/RunCMake/add_executable/CMakeLists.txt
new file mode 100644
index 000000000..ef2163c29
--- /dev/null
+++ b/Tests/RunCMake/add_executable/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.1)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/add_executable/NoSources-result.txt b/Tests/RunCMake/add_executable/NoSources-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_executable/NoSources-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_executable/NoSources-stderr.txt b/Tests/RunCMake/add_executable/NoSources-stderr.txt
new file mode 100644
index 000000000..abefc6d12
--- /dev/null
+++ b/Tests/RunCMake/add_executable/NoSources-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at NoSources.cmake:[0-9]+ \(add_executable\):
+ No SOURCES given to target: TestExeWithoutSources
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/add_executable/NoSources.cmake b/Tests/RunCMake/add_executable/NoSources.cmake
new file mode 100644
index 000000000..563564ad6
--- /dev/null
+++ b/Tests/RunCMake/add_executable/NoSources.cmake
@@ -0,0 +1 @@
+add_executable(TestExeWithoutSources)
diff --git a/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-result.txt b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-stderr.txt
new file mode 100644
index 000000000..80026bfca
--- /dev/null
+++ b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at NoSourcesButLinkObjects.cmake:[0-9]+ \(add_executable\):
+ No SOURCES given to target: TestExeWithoutSources
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/add_executable/NoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects.cmake
new file mode 100644
index 000000000..d0f20934e
--- /dev/null
+++ b/Tests/RunCMake/add_executable/NoSourcesButLinkObjects.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_executable(TestExeWithoutSources)
+target_link_libraries(TestExeWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_executable/OnlyObjectSources.cmake b/Tests/RunCMake/add_executable/OnlyObjectSources.cmake
new file mode 100644
index 000000000..1c90e9adc
--- /dev/null
+++ b/Tests/RunCMake/add_executable/OnlyObjectSources.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_executable(TestExeWithoutSources)
+target_sources(TestExeWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_executable/RunCMakeTest.cmake b/Tests/RunCMake/add_executable/RunCMakeTest.cmake
new file mode 100644
index 000000000..88916b71f
--- /dev/null
+++ b/Tests/RunCMake/add_executable/RunCMakeTest.cmake
@@ -0,0 +1,7 @@
+include(RunCMake)
+
+run_cmake(NoSources)
+run_cmake(OnlyObjectSources)
+if(NOT RunCMake_GENERATOR STREQUAL "Xcode" OR NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")
+ run_cmake(NoSourcesButLinkObjects)
+endif()
diff --git a/Tests/RunCMake/add_executable/test.cpp b/Tests/RunCMake/add_executable/test.cpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/add_executable/test.cpp
diff --git a/Tests/RunCMake/add_library/CMP0073-stdout.txt b/Tests/RunCMake/add_library/CMP0073-stdout.txt
new file mode 100644
index 000000000..84645b8f3
--- /dev/null
+++ b/Tests/RunCMake/add_library/CMP0073-stdout.txt
@@ -0,0 +1,3 @@
+-- warn_LIB_DEPENDS='general;bar;'
+-- old_LIB_DEPENDS='general;bar;'
+-- new_LIB_DEPENDS=''
diff --git a/Tests/RunCMake/add_library/CMP0073.cmake b/Tests/RunCMake/add_library/CMP0073.cmake
new file mode 100644
index 000000000..b34f5dccd
--- /dev/null
+++ b/Tests/RunCMake/add_library/CMP0073.cmake
@@ -0,0 +1,18 @@
+enable_language(C)
+
+add_library(warn empty.c)
+target_link_libraries(warn bar)
+message(STATUS "warn_LIB_DEPENDS='${warn_LIB_DEPENDS}'")
+
+cmake_policy(SET CMP0073 OLD)
+add_library(old empty.c)
+target_link_libraries(old bar)
+message(STATUS "old_LIB_DEPENDS='${old_LIB_DEPENDS}'")
+
+cmake_policy(SET CMP0073 NEW)
+add_library(new empty.c)
+target_link_libraries(new bar)
+message(STATUS "new_LIB_DEPENDS='${new_LIB_DEPENDS}'")
+if(DEFINED new_LIB_DEPENDS)
+ message(FATAL_ERROR "new_LIB_DEPENDS set but should not be")
+endif()
diff --git a/Tests/RunCMake/add_library/CMakeLists.txt b/Tests/RunCMake/add_library/CMakeLists.txt
new file mode 100644
index 000000000..ef2163c29
--- /dev/null
+++ b/Tests/RunCMake/add_library/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.1)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/add_library/INTERFACEwithNoSources.cmake b/Tests/RunCMake/add_library/INTERFACEwithNoSources.cmake
new file mode 100644
index 000000000..79188f387
--- /dev/null
+++ b/Tests/RunCMake/add_library/INTERFACEwithNoSources.cmake
@@ -0,0 +1 @@
+add_library(TestInterfaceLibWithoutSources INTERFACE)
diff --git a/Tests/RunCMake/add_library/INTERFACEwithNoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_library/INTERFACEwithNoSourcesButLinkObjects.cmake
new file mode 100644
index 000000000..53a48f0bd
--- /dev/null
+++ b/Tests/RunCMake/add_library/INTERFACEwithNoSourcesButLinkObjects.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_library(TestInterfaceLibWithoutSources INTERFACE)
+target_link_libraries(TestInterfaceLibWithoutSources INTERFACE $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_library/INTERFACEwithOnlyObjectSources.cmake b/Tests/RunCMake/add_library/INTERFACEwithOnlyObjectSources.cmake
new file mode 100644
index 000000000..86fab1dee
--- /dev/null
+++ b/Tests/RunCMake/add_library/INTERFACEwithOnlyObjectSources.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_library(TestInterfaceLibWithoutSources INTERFACE)
+target_sources(TestInterfaceLibWithoutSources INTERFACE $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_library/MODULEwithNoSources-result.txt b/Tests/RunCMake/add_library/MODULEwithNoSources-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_library/MODULEwithNoSources-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_library/MODULEwithNoSources-stderr.txt b/Tests/RunCMake/add_library/MODULEwithNoSources-stderr.txt
new file mode 100644
index 000000000..72b92ced8
--- /dev/null
+++ b/Tests/RunCMake/add_library/MODULEwithNoSources-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at MODULEwithNoSources.cmake:[0-9]+ \(add_library\):
+ No SOURCES given to target: TestModuleLibWithoutSources
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/add_library/MODULEwithNoSources.cmake b/Tests/RunCMake/add_library/MODULEwithNoSources.cmake
new file mode 100644
index 000000000..5df5033c6
--- /dev/null
+++ b/Tests/RunCMake/add_library/MODULEwithNoSources.cmake
@@ -0,0 +1 @@
+add_library(TestModuleLibWithoutSources MODULE)
diff --git a/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-result.txt b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-stderr.txt
new file mode 100644
index 000000000..1490524e0
--- /dev/null
+++ b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at MODULEwithNoSourcesButLinkObjects.cmake:[0-9]+ \(add_library\):
+ No SOURCES given to target: TestModuleLibWithoutSources
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects.cmake
new file mode 100644
index 000000000..f9d00dea8
--- /dev/null
+++ b/Tests/RunCMake/add_library/MODULEwithNoSourcesButLinkObjects.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_library(TestModuleLibWithoutSources MODULE)
+target_link_libraries(TestModuleLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_library/MODULEwithOnlyObjectSources.cmake b/Tests/RunCMake/add_library/MODULEwithOnlyObjectSources.cmake
new file mode 100644
index 000000000..187481a14
--- /dev/null
+++ b/Tests/RunCMake/add_library/MODULEwithOnlyObjectSources.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_library(TestModuleLibWithoutSources MODULE)
+target_sources(TestModuleLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSources-result.txt b/Tests/RunCMake/add_library/OBJECTwithNoSources-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_library/OBJECTwithNoSources-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSources-stderr.txt b/Tests/RunCMake/add_library/OBJECTwithNoSources-stderr.txt
new file mode 100644
index 000000000..be7634c87
--- /dev/null
+++ b/Tests/RunCMake/add_library/OBJECTwithNoSources-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at OBJECTwithNoSources.cmake:[0-9]+ \(add_library\):
+ No SOURCES given to target: TestObjectLibWithoutSources
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSources.cmake b/Tests/RunCMake/add_library/OBJECTwithNoSources.cmake
new file mode 100644
index 000000000..742e8299a
--- /dev/null
+++ b/Tests/RunCMake/add_library/OBJECTwithNoSources.cmake
@@ -0,0 +1 @@
+add_library(TestObjectLibWithoutSources OBJECT)
diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-result.txt b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt
new file mode 100644
index 000000000..3f8591666
--- /dev/null
+++ b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at OBJECTwithNoSourcesButLinkObjects.cmake:[0-9]+ \(add_library\):
+ No SOURCES given to target: TestObjectLibWithoutSources
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects.cmake
new file mode 100644
index 000000000..6b4b55fda
--- /dev/null
+++ b/Tests/RunCMake/add_library/OBJECTwithNoSourcesButLinkObjects.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_library(TestObjectLibWithoutSources OBJECT)
+target_link_libraries(TestObjectLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources.cmake b/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources.cmake
new file mode 100644
index 000000000..ff75a8cb4
--- /dev/null
+++ b/Tests/RunCMake/add_library/OBJECTwithOnlyObjectSources.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_library(TestObjectLibWithoutSources OBJECT)
+target_sources(TestObjectLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_library/RunCMakeTest.cmake b/Tests/RunCMake/add_library/RunCMakeTest.cmake
new file mode 100644
index 000000000..dfadb8fc1
--- /dev/null
+++ b/Tests/RunCMake/add_library/RunCMakeTest.cmake
@@ -0,0 +1,26 @@
+include(RunCMake)
+
+run_cmake(CMP0073)
+
+run_cmake(INTERFACEwithNoSources)
+run_cmake(OBJECTwithNoSources)
+run_cmake(STATICwithNoSources)
+run_cmake(SHAREDwithNoSources)
+run_cmake(MODULEwithNoSources)
+run_cmake(UNKNOWNwithNoSources)
+
+run_cmake(INTERFACEwithOnlyObjectSources)
+run_cmake(OBJECTwithOnlyObjectSources)
+run_cmake(STATICwithOnlyObjectSources)
+run_cmake(SHAREDwithOnlyObjectSources)
+run_cmake(MODULEwithOnlyObjectSources)
+run_cmake(UNKNOWNwithOnlyObjectSources)
+
+if(NOT RunCMake_GENERATOR STREQUAL "Xcode" OR NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")
+ run_cmake(INTERFACEwithNoSourcesButLinkObjects)
+ run_cmake(OBJECTwithNoSourcesButLinkObjects)
+ run_cmake(STATICwithNoSourcesButLinkObjects)
+ run_cmake(SHAREDwithNoSourcesButLinkObjects)
+ run_cmake(MODULEwithNoSourcesButLinkObjects)
+ run_cmake(UNKNOWNwithNoSourcesButLinkObjects)
+endif()
diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSources-result.txt b/Tests/RunCMake/add_library/SHAREDwithNoSources-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_library/SHAREDwithNoSources-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSources-stderr.txt b/Tests/RunCMake/add_library/SHAREDwithNoSources-stderr.txt
new file mode 100644
index 000000000..471eda12a
--- /dev/null
+++ b/Tests/RunCMake/add_library/SHAREDwithNoSources-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at SHAREDwithNoSources.cmake:[0-9]+ \(add_library\):
+ No SOURCES given to target: TestSharedLibWithoutSources
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSources.cmake b/Tests/RunCMake/add_library/SHAREDwithNoSources.cmake
new file mode 100644
index 000000000..e147b44bc
--- /dev/null
+++ b/Tests/RunCMake/add_library/SHAREDwithNoSources.cmake
@@ -0,0 +1 @@
+add_library(TestSharedLibWithoutSources SHARED)
diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-result.txt b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-stderr.txt
new file mode 100644
index 000000000..4bec7ae89
--- /dev/null
+++ b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at SHAREDwithNoSourcesButLinkObjects.cmake:[0-9]+ \(add_library\):
+ No SOURCES given to target: TestSharedLibWithoutSources
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects.cmake
new file mode 100644
index 000000000..5e3c2709d
--- /dev/null
+++ b/Tests/RunCMake/add_library/SHAREDwithNoSourcesButLinkObjects.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_library(TestSharedLibWithoutSources SHARED)
+target_link_libraries(TestSharedLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_library/SHAREDwithOnlyObjectSources.cmake b/Tests/RunCMake/add_library/SHAREDwithOnlyObjectSources.cmake
new file mode 100644
index 000000000..09281b00d
--- /dev/null
+++ b/Tests/RunCMake/add_library/SHAREDwithOnlyObjectSources.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_library(TestSharedLibWithoutSources SHARED)
+target_sources(TestSharedLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_library/STATICwithNoSources-result.txt b/Tests/RunCMake/add_library/STATICwithNoSources-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_library/STATICwithNoSources-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_library/STATICwithNoSources-stderr.txt b/Tests/RunCMake/add_library/STATICwithNoSources-stderr.txt
new file mode 100644
index 000000000..f65522116
--- /dev/null
+++ b/Tests/RunCMake/add_library/STATICwithNoSources-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at STATICwithNoSources.cmake:[0-9]+ \(add_library\):
+ No SOURCES given to target: TestStaticLibWithoutSources
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/add_library/STATICwithNoSources.cmake b/Tests/RunCMake/add_library/STATICwithNoSources.cmake
new file mode 100644
index 000000000..94a2d9ab0
--- /dev/null
+++ b/Tests/RunCMake/add_library/STATICwithNoSources.cmake
@@ -0,0 +1 @@
+add_library(TestStaticLibWithoutSources STATIC)
diff --git a/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-result.txt b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-stderr.txt b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-stderr.txt
new file mode 100644
index 000000000..185aad801
--- /dev/null
+++ b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at STATICwithNoSourcesButLinkObjects.cmake:[0-9]+ \(add_library\):
+ No SOURCES given to target: TestStaticLibWithoutSources
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Generate step failed\. Build files cannot be regenerated correctly\.$
diff --git a/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects.cmake
new file mode 100644
index 000000000..b6e137f3a
--- /dev/null
+++ b/Tests/RunCMake/add_library/STATICwithNoSourcesButLinkObjects.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_library(TestStaticLibWithoutSources STATIC)
+target_link_libraries(TestStaticLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_library/STATICwithOnlyObjectSources.cmake b/Tests/RunCMake/add_library/STATICwithOnlyObjectSources.cmake
new file mode 100644
index 000000000..74a8947f2
--- /dev/null
+++ b/Tests/RunCMake/add_library/STATICwithOnlyObjectSources.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_library(TestStaticLibWithoutSources STATIC)
+target_sources(TestStaticLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_library/UNKNOWNwithNoSources.cmake b/Tests/RunCMake/add_library/UNKNOWNwithNoSources.cmake
new file mode 100644
index 000000000..dc5d7773b
--- /dev/null
+++ b/Tests/RunCMake/add_library/UNKNOWNwithNoSources.cmake
@@ -0,0 +1 @@
+add_library(TestUnknownLibWithoutSources UNKNOWN IMPORTED)
diff --git a/Tests/RunCMake/add_library/UNKNOWNwithNoSourcesButLinkObjects.cmake b/Tests/RunCMake/add_library/UNKNOWNwithNoSourcesButLinkObjects.cmake
new file mode 100644
index 000000000..a977d42fc
--- /dev/null
+++ b/Tests/RunCMake/add_library/UNKNOWNwithNoSourcesButLinkObjects.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_library(TestUnknownLibWithoutSources UNKNOWN IMPORTED)
+target_link_libraries(TestUnknownLibWithoutSources INTERFACE $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-result.txt b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-stderr.txt b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-stderr.txt
new file mode 100644
index 000000000..838992b05
--- /dev/null
+++ b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at UNKNOWNwithOnlyObjectSources.cmake:[0-9]+ \(target_sources\):
+ target_sources may only set INTERFACE properties on IMPORTED targets
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources.cmake b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources.cmake
new file mode 100644
index 000000000..604e339aa
--- /dev/null
+++ b/Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources.cmake
@@ -0,0 +1,5 @@
+enable_language(CXX)
+add_library(ObjectLibDependency OBJECT test.cpp)
+
+add_library(TestUnknownLibWithoutSources UNKNOWN IMPORTED)
+target_sources(TestUnknownLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
diff --git a/Tests/RunCMake/add_library/empty.c b/Tests/RunCMake/add_library/empty.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/add_library/empty.c
diff --git a/Tests/RunCMake/add_library/test.cpp b/Tests/RunCMake/add_library/test.cpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/add_library/test.cpp
diff --git a/Tests/RunCMake/add_link_options/CMakeLists.txt b/Tests/RunCMake/add_link_options/CMakeLists.txt
new file mode 100644
index 000000000..14ef56e8e
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.11)
+
+project(${RunCMake_TEST} LANGUAGES NONE)
+
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/add_link_options/LINKER_SHELL_expansion-build-check.cmake b/Tests/RunCMake/add_link_options/LINKER_SHELL_expansion-build-check.cmake
new file mode 100644
index 000000000..d0ef8de85
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LINKER_SHELL_expansion-build-check.cmake
@@ -0,0 +1,2 @@
+
+include ("${CMAKE_CURRENT_LIST_DIR}/LINKER_expansion-validation.cmake")
diff --git a/Tests/RunCMake/add_link_options/LINKER_SHELL_expansion.cmake b/Tests/RunCMake/add_link_options/LINKER_SHELL_expansion.cmake
new file mode 100644
index 000000000..7316ef52b
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LINKER_SHELL_expansion.cmake
@@ -0,0 +1,4 @@
+
+set (LINKER_OPTION "LINKER:SHELL:-foo bar")
+
+include ("LINKER_expansion-list.cmake")
diff --git a/Tests/RunCMake/add_link_options/LINKER_expansion-build-check.cmake b/Tests/RunCMake/add_link_options/LINKER_expansion-build-check.cmake
new file mode 100644
index 000000000..d0ef8de85
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LINKER_expansion-build-check.cmake
@@ -0,0 +1,2 @@
+
+include ("${CMAKE_CURRENT_LIST_DIR}/LINKER_expansion-validation.cmake")
diff --git a/Tests/RunCMake/add_link_options/LINKER_expansion-list.cmake b/Tests/RunCMake/add_link_options/LINKER_expansion-list.cmake
new file mode 100644
index 000000000..34dcc6756
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LINKER_expansion-list.cmake
@@ -0,0 +1,36 @@
+
+enable_language(C)
+
+add_executable(dump dump.c)
+
+add_link_options("${LINKER_OPTION}")
+
+# ensure no temp file will be used
+string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}")
+string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}")
+
+add_library(example SHARED LinkOptionsLib.c)
+# use LAUNCH facility to dump linker command
+set_property(TARGET example PROPERTY RULE_LAUNCH_LINK "\"${CMAKE_CURRENT_BINARY_DIR}/dump${CMAKE_EXECUTABLE_SUFFIX}\"")
+
+add_dependencies (example dump)
+
+# generate reference for LINKER flag
+if (CMAKE_C_LINKER_WRAPPER_FLAG)
+ set(linker_flag ${CMAKE_C_LINKER_WRAPPER_FLAG})
+ list(GET linker_flag -1 linker_space)
+ if (linker_space STREQUAL " ")
+ list(REMOVE_AT linker_flag -1)
+ else()
+ set(linker_space)
+ endif()
+ list (JOIN linker_flag " " linker_flag)
+ if (CMAKE_C_LINKER_WRAPPER_FLAG_SEP)
+ string (APPEND linker_flag "${linker_space}" "-foo${CMAKE_C_LINKER_WRAPPER_FLAG_SEP}bar")
+ else()
+ set (linker_flag "${linker_flag}${linker_space}-foo ${linker_flag}${linker_space}bar")
+ endif()
+else()
+ set(linker_flag "-foo bar")
+endif()
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LINKER.txt" "${linker_flag}")
diff --git a/Tests/RunCMake/add_link_options/LINKER_expansion-validation.cmake b/Tests/RunCMake/add_link_options/LINKER_expansion-validation.cmake
new file mode 100644
index 000000000..bebd6c736
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LINKER_expansion-validation.cmake
@@ -0,0 +1,15 @@
+
+if (actual_stdout MATCHES "(LINKER|SHELL):")
+ set (RunCMake_TEST_FAILED "LINKER: prefix was not expanded.")
+ return()
+endif()
+
+if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/LINKER.txt")
+ set (RunCMake_TEST_FAILED "${RunCMake_TEST_BINARY_DIR}/LINKER.txt: Reference file not found.")
+ return()
+endif()
+file(READ "${RunCMake_TEST_BINARY_DIR}/LINKER.txt" linker_flag)
+
+if (NOT actual_stdout MATCHES "${linker_flag}")
+ set (RunCMake_TEST_FAILED "LINKER: was not expanded correctly.")
+endif()
diff --git a/Tests/RunCMake/add_link_options/LINKER_expansion.cmake b/Tests/RunCMake/add_link_options/LINKER_expansion.cmake
new file mode 100644
index 000000000..42b286d2d
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LINKER_expansion.cmake
@@ -0,0 +1,4 @@
+
+set (LINKER_OPTION "LINKER:-foo,bar")
+
+include ("LINKER_expansion-list.cmake")
diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-check.cmake b/Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-check.cmake
new file mode 100644
index 000000000..4a22d7e6d
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-check.cmake
@@ -0,0 +1,7 @@
+
+if (NOT actual_stdout MATCHES "BADFLAG_EXECUTABLE_RELEASE")
+ set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_EXECUTABLE_RELEASE'.")
+endif()
+if (actual_stdout MATCHES "BADFLAG_(SHARED|MODULE)_RELEASE")
+ set (RunCMake_TEST_FAILED "Found unexpected 'BADFLAG_(SHARED|MODULE)_RELEASE'.")
+endif()
diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-result.txt b/Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-result.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS-exe-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-check.cmake b/Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-check.cmake
new file mode 100644
index 000000000..d695761c9
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-check.cmake
@@ -0,0 +1,7 @@
+
+if (NOT actual_stdout MATCHES "BADFLAG_MODULE_RELEASE")
+ set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_MODULE_RELEASE'.")
+endif()
+if (actual_stdout MATCHES "BADFLAG_(SHARED|EXECUTABLE)_RELEASE")
+ set (RunCMake_TEST_FAILED "Found unexpected 'BADFLAG_(SHARED|EXECUTABLE)_RELEASE'.")
+endif()
diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-result.txt b/Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-result.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS-mod-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-check.cmake b/Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-check.cmake
new file mode 100644
index 000000000..eaac8e372
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-check.cmake
@@ -0,0 +1,7 @@
+
+if (NOT actual_stdout MATCHES "BADFLAG_SHARED_RELEASE")
+ set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_SHARED_RELEASE'.")
+endif()
+if (actual_stdout MATCHES "BADFLAG_(MODULE|EXECUTABLE)_RELEASE")
+ set (RunCMake_TEST_FAILED "Found unexpected 'BADFLAG_(MODULE|EXECUTABLE)_RELEASE'.")
+endif()
diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-result.txt b/Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-result.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS-shared-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/add_link_options/LINK_OPTIONS.cmake b/Tests/RunCMake/add_link_options/LINK_OPTIONS.cmake
new file mode 100644
index 000000000..802ff4f42
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LINK_OPTIONS.cmake
@@ -0,0 +1,17 @@
+
+enable_language(C)
+
+set(obj "${CMAKE_C_OUTPUT_EXTENSION}")
+if(BORLAND)
+ set(pre -)
+endif()
+
+add_link_options($<$<AND:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>,$<CONFIG:Release>>:${pre}BADFLAG_SHARED_RELEASE${obj}>)
+add_link_options($<$<AND:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,MODULE_LIBRARY>,$<CONFIG:Release>>:${pre}BADFLAG_MODULE_RELEASE${obj}>)
+add_link_options($<$<AND:$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>,$<CONFIG:Release>>:${pre}BADFLAG_EXECUTABLE_RELEASE${obj}>)
+
+add_library(LinkOptions_shared SHARED LinkOptionsLib.c)
+
+add_library(LinkOptions_mod MODULE LinkOptionsLib.c)
+
+add_executable(LinkOptions_exe LinkOptionsExe.c)
diff --git a/Tests/RunCMake/add_link_options/LinkOptionsExe.c b/Tests/RunCMake/add_link_options/LinkOptionsExe.c
new file mode 100644
index 000000000..8488f4e58
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LinkOptionsExe.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/add_link_options/LinkOptionsLib.c b/Tests/RunCMake/add_link_options/LinkOptionsLib.c
new file mode 100644
index 000000000..9bbd24cd8
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/LinkOptionsLib.c
@@ -0,0 +1,7 @@
+#if defined(_WIN32)
+__declspec(dllexport)
+#endif
+ int flags_lib(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/add_link_options/RunCMakeTest.cmake b/Tests/RunCMake/add_link_options/RunCMakeTest.cmake
new file mode 100644
index 000000000..4f5df724e
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/RunCMakeTest.cmake
@@ -0,0 +1,38 @@
+
+include(RunCMake)
+
+macro(run_cmake_target test subtest target)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN})
+
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+endmacro()
+
+if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
+ # Intel compiler does not reject bad flags or objects!
+ set(RunCMake_TEST_OUTPUT_MERGE TRUE)
+ if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release)
+ endif()
+
+ run_cmake(LINK_OPTIONS)
+
+ run_cmake_target(LINK_OPTIONS shared LinkOptions_shared --config Release)
+ run_cmake_target(LINK_OPTIONS mod LinkOptions_mod --config Release)
+ run_cmake_target(LINK_OPTIONS exe LinkOptions_exe --config Release)
+
+ unset(RunCMake_TEST_OPTIONS)
+ unset(RunCMake_TEST_OUTPUT_MERGE)
+endif()
+
+run_cmake(bad_SHELL_usage)
+
+if(RunCMake_GENERATOR MATCHES "(Ninja|Makefile)")
+ run_cmake(LINKER_expansion)
+ run_cmake_target(LINKER_expansion build all)
+
+ run_cmake(LINKER_SHELL_expansion)
+ run_cmake_target(LINKER_SHELL_expansion build all)
+endif()
diff --git a/Tests/RunCMake/add_link_options/bad_SHELL_usage-result.txt b/Tests/RunCMake/add_link_options/bad_SHELL_usage-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/bad_SHELL_usage-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/add_link_options/bad_SHELL_usage-stderr.txt b/Tests/RunCMake/add_link_options/bad_SHELL_usage-stderr.txt
new file mode 100644
index 000000000..02d09f316
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/bad_SHELL_usage-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at bad_SHELL_usage.cmake:6 \(add_library\):
+ 'SHELL:' prefix is not supported as part of 'LINKER:' arguments.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:5 \(include\)
diff --git a/Tests/RunCMake/add_link_options/bad_SHELL_usage.cmake b/Tests/RunCMake/add_link_options/bad_SHELL_usage.cmake
new file mode 100644
index 000000000..324893ddf
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/bad_SHELL_usage.cmake
@@ -0,0 +1,6 @@
+
+enable_language(C)
+
+add_link_options("LINKER:-foo,SHELL:-bar")
+
+add_library(example SHARED LinkOptionsLib.c)
diff --git a/Tests/RunCMake/add_link_options/dump.c b/Tests/RunCMake/add_link_options/dump.c
new file mode 100644
index 000000000..8baa313fd
--- /dev/null
+++ b/Tests/RunCMake/add_link_options/dump.c
@@ -0,0 +1,13 @@
+
+#include "stdio.h"
+
+int main(int argc, char* argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ printf("%s ", argv[i]);
+ printf("\n");
+
+ return 0;
+}
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-ExcludeFromAll/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/CMP0082-ExcludeFromAll/CMakeLists.txt
new file mode 100644
index 000000000..1bd7f495b
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-ExcludeFromAll/CMakeLists.txt
@@ -0,0 +1 @@
+install(CODE "message(STATUS \"exclude\")")
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-NEW-install-component-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-NEW-install-component-stdout.txt
new file mode 100644
index 000000000..7d76ed959
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-NEW-install-component-stdout.txt
@@ -0,0 +1,4 @@
+^-- Install configuration: "[^\n]*"
+-- Install component: "Unspecified"
+-- sub
+-- top$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-NEW-install-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-NEW-install-stdout.txt
new file mode 100644
index 000000000..35b0bb5e1
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-NEW-install-stdout.txt
@@ -0,0 +1,3 @@
+^-- Install configuration: "[^\n]*"
+-- sub
+-- top$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-NEW.cmake b/Tests/RunCMake/add_subdirectory/CMP0082-NEW.cmake
new file mode 100644
index 000000000..56c1b81f7
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-NEW.cmake
@@ -0,0 +1,3 @@
+add_subdirectory(CMP0082)
+add_subdirectory(CMP0082-ExcludeFromAll EXCLUDE_FROM_ALL)
+install(CODE "message(STATUS \"top\")")
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-Nested/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/CMP0082-Nested/CMakeLists.txt
new file mode 100644
index 000000000..8f26c248e
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-Nested/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(sub)
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-Nested/sub/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/CMP0082-Nested/sub/CMakeLists.txt
new file mode 100644
index 000000000..91a8936dc
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-Nested/sub/CMakeLists.txt
@@ -0,0 +1 @@
+install(CODE "message(STATUS \"sub\")")
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-NestedSub/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/CMP0082-NestedSub/CMakeLists.txt
new file mode 100644
index 000000000..52a066504
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-NestedSub/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory(sub)
+install(CODE "message(STATUS \"top\")")
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-NestedSub/sub/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/CMP0082-NestedSub/sub/CMakeLists.txt
new file mode 100644
index 000000000..91a8936dc
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-NestedSub/sub/CMakeLists.txt
@@ -0,0 +1 @@
+install(CODE "message(STATUS \"sub\")")
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-None/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/CMP0082-None/CMakeLists.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-None/CMakeLists.txt
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-OLD-install-component-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-OLD-install-component-stdout.txt
new file mode 100644
index 000000000..4b39789f7
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-OLD-install-component-stdout.txt
@@ -0,0 +1,4 @@
+^-- Install configuration: "[^\n]*"
+-- Install component: "Unspecified"
+-- top
+-- sub$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-OLD-install-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-OLD-install-stdout.txt
new file mode 100644
index 000000000..8f3a5f71d
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-OLD-install-stdout.txt
@@ -0,0 +1,3 @@
+^-- Install configuration: "[^\n]*"
+-- top
+-- sub$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-OLD.cmake b/Tests/RunCMake/add_subdirectory/CMP0082-OLD.cmake
new file mode 100644
index 000000000..56c1b81f7
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-OLD.cmake
@@ -0,0 +1,3 @@
+add_subdirectory(CMP0082)
+add_subdirectory(CMP0082-ExcludeFromAll EXCLUDE_FROM_ALL)
+install(CODE "message(STATUS \"top\")")
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested-install-component-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested-install-component-stdout.txt
new file mode 100644
index 000000000..4b39789f7
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested-install-component-stdout.txt
@@ -0,0 +1,4 @@
+^-- Install configuration: "[^\n]*"
+-- Install component: "Unspecified"
+-- top
+-- sub$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested-install-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested-install-stdout.txt
new file mode 100644
index 000000000..8f3a5f71d
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested-install-stdout.txt
@@ -0,0 +1,3 @@
+^-- Install configuration: "[^\n]*"
+-- top
+-- sub$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested-stderr.txt b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested-stderr.txt
new file mode 100644
index 000000000..3624c43a4
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested-stderr.txt
@@ -0,0 +1,7 @@
+CMake Warning \(dev\) in CMakeLists\.txt:
+ Policy CMP0082 is not set: Install rules from add_subdirectory\(\) are
+ interleaved with those in caller\. Run "cmake --help-policy CMP0082" for
+ policy details\. Use the cmake_policy command to set the policy and
+ suppress this warning\.
+
+This warning is for project developers\. Use -Wno-dev to suppress it\.
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested.cmake b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested.cmake
new file mode 100644
index 000000000..df5688af3
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-Nested.cmake
@@ -0,0 +1,2 @@
+add_subdirectory(CMP0082-Nested)
+install(CODE "message(STATUS \"top\")")
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub-install-component-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub-install-component-stdout.txt
new file mode 100644
index 000000000..4b39789f7
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub-install-component-stdout.txt
@@ -0,0 +1,4 @@
+^-- Install configuration: "[^\n]*"
+-- Install component: "Unspecified"
+-- top
+-- sub$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub-install-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub-install-stdout.txt
new file mode 100644
index 000000000..8f3a5f71d
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub-install-stdout.txt
@@ -0,0 +1,3 @@
+^-- Install configuration: "[^\n]*"
+-- top
+-- sub$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub-stderr.txt b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub-stderr.txt
new file mode 100644
index 000000000..93629053b
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub-stderr.txt
@@ -0,0 +1,7 @@
+CMake Warning \(dev\) in CMP0082-NestedSub/CMakeLists\.txt:
+ Policy CMP0082 is not set: Install rules from add_subdirectory\(\) are
+ interleaved with those in caller\. Run "cmake --help-policy CMP0082" for
+ policy details\. Use the cmake_policy command to set the policy and
+ suppress this warning\.
+
+This warning is for project developers\. Use -Wno-dev to suppress it\.
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub.cmake b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub.cmake
new file mode 100644
index 000000000..88a0856a6
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NestedSub.cmake
@@ -0,0 +1 @@
+add_subdirectory(CMP0082-NestedSub)
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NoTopInstall-install-component-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NoTopInstall-install-component-stdout.txt
new file mode 100644
index 000000000..f7a331df2
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NoTopInstall-install-component-stdout.txt
@@ -0,0 +1,3 @@
+^-- Install configuration: "[^\n]*"
+-- Install component: "Unspecified"
+-- sub$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NoTopInstall-install-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NoTopInstall-install-stdout.txt
new file mode 100644
index 000000000..6f22ae24d
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NoTopInstall-install-stdout.txt
@@ -0,0 +1,2 @@
+^-- Install configuration: "[^\n]*"
+-- sub$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NoTopInstall.cmake b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NoTopInstall.cmake
new file mode 100644
index 000000000..70bc9edf1
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-NoTopInstall.cmake
@@ -0,0 +1 @@
+add_subdirectory(CMP0082)
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-None-install-component-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-None-install-component-stdout.txt
new file mode 100644
index 000000000..157ab37e2
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-None-install-component-stdout.txt
@@ -0,0 +1,3 @@
+^-- Install configuration: "[^\n]*"
+-- Install component: "Unspecified"
+-- top$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-None-install-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-None-install-stdout.txt
new file mode 100644
index 000000000..9e15872bd
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-None-install-stdout.txt
@@ -0,0 +1,2 @@
+^-- Install configuration: "[^\n]*"
+-- top$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-None.cmake b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-None.cmake
new file mode 100644
index 000000000..670f89b04
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-None.cmake
@@ -0,0 +1,2 @@
+add_subdirectory(CMP0082-None)
+install(CODE "message(STATUS \"top\")")
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-install-component-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-install-component-stdout.txt
new file mode 100644
index 000000000..4b39789f7
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-install-component-stdout.txt
@@ -0,0 +1,4 @@
+^-- Install configuration: "[^\n]*"
+-- Install component: "Unspecified"
+-- top
+-- sub$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-install-stdout.txt b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-install-stdout.txt
new file mode 100644
index 000000000..8f3a5f71d
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-install-stdout.txt
@@ -0,0 +1,3 @@
+^-- Install configuration: "[^\n]*"
+-- top
+-- sub$
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN-stderr.txt b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-stderr.txt
new file mode 100644
index 000000000..3624c43a4
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN-stderr.txt
@@ -0,0 +1,7 @@
+CMake Warning \(dev\) in CMakeLists\.txt:
+ Policy CMP0082 is not set: Install rules from add_subdirectory\(\) are
+ interleaved with those in caller\. Run "cmake --help-policy CMP0082" for
+ policy details\. Use the cmake_policy command to set the policy and
+ suppress this warning\.
+
+This warning is for project developers\. Use -Wno-dev to suppress it\.
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082-WARN.cmake b/Tests/RunCMake/add_subdirectory/CMP0082-WARN.cmake
new file mode 100644
index 000000000..56c1b81f7
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082-WARN.cmake
@@ -0,0 +1,3 @@
+add_subdirectory(CMP0082)
+add_subdirectory(CMP0082-ExcludeFromAll EXCLUDE_FROM_ALL)
+install(CODE "message(STATUS \"top\")")
diff --git a/Tests/RunCMake/add_subdirectory/CMP0082/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/CMP0082/CMakeLists.txt
new file mode 100644
index 000000000..91a8936dc
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/CMP0082/CMakeLists.txt
@@ -0,0 +1 @@
+install(CODE "message(STATUS \"sub\")")
diff --git a/Tests/RunCMake/add_subdirectory/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/CMakeLists.txt
index 18dfd2686..47d249cce 100644
--- a/Tests/RunCMake/add_subdirectory/CMakeLists.txt
+++ b/Tests/RunCMake/add_subdirectory/CMakeLists.txt
@@ -1,3 +1,10 @@
cmake_minimum_required(VERSION 3.2)
+
+# Have to set policy here due to policy scope
+if(DEFINED CMP0082_VALUE)
+ cmake_policy(SET CMP0082 "${CMP0082_VALUE}")
+endif()
+set(CMAKE_POLICY_WARNING_CMP0082 ON)
+
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt b/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt
index 369a956e6..013058111 100644
--- a/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt
+++ b/Tests/RunCMake/add_subdirectory/DoesNotExist-stderr.txt
@@ -2,4 +2,4 @@
add_subdirectory given source "DoesNotExist" which is not an existing
directory.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll-build-sub-stderr.txt b/Tests/RunCMake/add_subdirectory/ExcludeFromAll-build-sub-stderr.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll-build-sub-stderr.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake
index f68600511..57ab93877 100644
--- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake
+++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll.cmake
@@ -4,3 +4,13 @@ add_subdirectory(ExcludeFromAll EXCLUDE_FROM_ALL)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE foo)
+
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
+set(main_exe \"$<TARGET_FILE:main>\")
+set(foo_lib \"$<TARGET_FILE:foo>\")
+set(bar_lib \"$<TARGET_FILE:bar>\")
+set(zot_lib \"$<TARGET_FILE:zot>\")
+set(subinc_lib \"$<TARGET_FILE:subinc>\")
+set(subsub_lib \"$<TARGET_FILE:subsub>\")
+set(subsubinc_lib \"$<TARGET_FILE:subsubinc>\")
+")
diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt
index b1df6b04f..9ed9e5517 100644
--- a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt
+++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/CMakeLists.txt
@@ -1,4 +1,13 @@
-add_library(bar STATIC bar.cpp)
+project(ExcludeFromAllSub NONE)
+
+add_subdirectory(SubSub EXCLUDE_FROM_ALL)
+
+add_library(bar STATIC EXCLUDE_FROM_ALL bar.cpp)
+
+add_library(zot STATIC zot.cpp)
add_library(foo STATIC foo.cpp)
target_include_directories(foo PUBLIC .)
+
+add_library(subinc STATIC subinc.cpp)
+set_target_properties(subinc PROPERTIES EXCLUDE_FROM_ALL OFF)
diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/SubSub/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/SubSub/CMakeLists.txt
new file mode 100644
index 000000000..ec2827542
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/SubSub/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_library(subsub STATIC subsub.cpp)
+add_library(subsubinc STATIC subsub.cpp)
+set_property(TARGET subsubinc PROPERTY EXCLUDE_FROM_ALL OFF)
diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/SubSub/subsub.cpp b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/SubSub/subsub.cpp
new file mode 100644
index 000000000..ca689edaa
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/SubSub/subsub.cpp
@@ -0,0 +1,4 @@
+int subsub()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check-sub.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check-sub.cmake
new file mode 100644
index 000000000..d318c100e
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check-sub.cmake
@@ -0,0 +1,34 @@
+if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake)
+ include(${RunCMake_TEST_BINARY_DIR}/check-debug.cmake)
+ if(RunCMake_TEST_FAILED)
+ return()
+ endif()
+
+ foreach(file
+ "${foo_lib}"
+ "${subinc_lib}"
+ "${zot_lib}"
+ "${subsubinc_lib}"
+ )
+ if(NOT EXISTS "${file}")
+ set(RunCMake_TEST_FAILED
+ "Artifact should exist but is missing:\n ${file}")
+ return()
+ endif()
+ endforeach()
+ foreach(file
+ "${main_exe}"
+ "${bar_lib}"
+ "${subsub_lib}"
+ )
+ if(EXISTS "${file}")
+ set(RunCMake_TEST_FAILED
+ "Artifact should be missing but exists:\n ${file}")
+ return()
+ endif()
+ endforeach()
+else()
+ set(RunCMake_TEST_FAILED "
+ '${RunCMake_TEST_BINARY_DIR}/check-debug.cmake' missing
+")
+endif()
diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake
new file mode 100644
index 000000000..d4bdef23d
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/check.cmake
@@ -0,0 +1,37 @@
+if(EXISTS ${RunCMake_TEST_BINARY_DIR}/check-debug.cmake)
+ include(${RunCMake_TEST_BINARY_DIR}/check-debug.cmake)
+ if(RunCMake_TEST_FAILED)
+ return()
+ endif()
+
+ foreach(file
+ "${foo_lib}"
+ "${subinc_lib}"
+ "${main_exe}"
+ "${subsubinc_lib}"
+ )
+ if(EXISTS "${file}")
+ # Remove for next step of test.
+ file(REMOVE "${file}")
+ else()
+ set(RunCMake_TEST_FAILED
+ "Artifact should exist but is missing:\n ${file}")
+ return()
+ endif()
+ endforeach()
+ foreach(file
+ "${zot_lib}"
+ "${bar_lib}"
+ "${subsub_lib}"
+ )
+ if(EXISTS "${file}")
+ set(RunCMake_TEST_FAILED
+ "Artifact should be missing but exists:\n ${file}")
+ return()
+ endif()
+ endforeach()
+else()
+ set(RunCMake_TEST_FAILED "
+ '${RunCMake_TEST_BINARY_DIR}/check-debug.cmake' missing
+")
+endif()
diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/subinc.cpp b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/subinc.cpp
new file mode 100644
index 000000000..e9faacdba
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/subinc.cpp
@@ -0,0 +1,4 @@
+int subinc()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/add_subdirectory/ExcludeFromAll/zot.cpp b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/zot.cpp
new file mode 100644
index 000000000..ba7e9661c
--- /dev/null
+++ b/Tests/RunCMake/add_subdirectory/ExcludeFromAll/zot.cpp
@@ -0,0 +1,4 @@
+int zot()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/add_subdirectory/Missing-stderr.txt b/Tests/RunCMake/add_subdirectory/Missing-stderr.txt
index aba06755a..dd831406e 100644
--- a/Tests/RunCMake/add_subdirectory/Missing-stderr.txt
+++ b/Tests/RunCMake/add_subdirectory/Missing-stderr.txt
@@ -5,4 +5,4 @@
does not contain a CMakeLists.txt file.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake
index 88b928308..951e03c8f 100644
--- a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake
+++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake
@@ -4,14 +4,57 @@ run_cmake(DoesNotExist)
run_cmake(Missing)
run_cmake(Function)
-set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExcludeFromAll-build)
-set(RunCMake_TEST_NO_CLEAN 1)
+macro(run_cmake_install case)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_TEST_OPTIONS ${ARGN})
-file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
-file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake(${case})
+ run_cmake_command(${case}-install ${CMAKE_COMMAND} -P cmake_install.cmake)
+ run_cmake_command(${case}-install-component ${CMAKE_COMMAND} -DCOMPONENT=Unspecified -P cmake_install.cmake)
-run_cmake(ExcludeFromAll)
-run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build .)
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+ unset(RunCMake_TEST_OPTIONS)
+endmacro()
-unset(RunCMake_TEST_BINARY_DIR)
+run_cmake_install(CMP0082-WARN)
+run_cmake_install(CMP0082-WARN-Nested)
+run_cmake_install(CMP0082-WARN-NestedSub)
+run_cmake_install(CMP0082-WARN-None)
+run_cmake_install(CMP0082-WARN-NoTopInstall)
+run_cmake_install(CMP0082-OLD -DCMP0082_VALUE=OLD)
+run_cmake_install(CMP0082-NEW -DCMP0082_VALUE=NEW)
+
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExcludeFromAll-build)
+if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+endif()
+run_cmake(ExcludeFromAll)
+set(RunCMake_TEST_NO_CLEAN 1)
+set(RunCMake-check-file ExcludeFromAll/check.cmake)
+run_cmake_command(ExcludeFromAll-build ${CMAKE_COMMAND} --build . --config Debug)
+if(RunCMake_GENERATOR STREQUAL "Ninja")
+ if(WIN32)
+ set(slash [[\]])
+ else()
+ set(slash [[/]])
+ endif()
+ set(RunCMake-check-file ExcludeFromAll/check-sub.cmake)
+ run_cmake_command(ExcludeFromAll-build-sub ${CMAKE_COMMAND} --build . --target "ExcludeFromAll${slash}all")
+elseif(RunCMake_GENERATOR MATCHES "Make")
+ set(RunCMake-check-file ExcludeFromAll/check-sub.cmake)
+ set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY ${RunCMake_BINARY_DIR}/ExcludeFromAll-build/ExcludeFromAll)
+ run_cmake_command(ExcludeFromAll-build-sub "${RunCMake_MAKE_PROGRAM}")
+elseif(RunCMake_GENERATOR MATCHES "^Visual Studio [1-9][0-9]")
+ set(RunCMake-check-file ExcludeFromAll/check-sub.cmake)
+ run_cmake_command(ExcludeFromAll-build-sub ${CMAKE_COMMAND} --build ExcludeFromAll --config Debug)
+elseif(RunCMake_GENERATOR STREQUAL "Xcode")
+ set(RunCMake-check-file ExcludeFromAll/check-sub.cmake)
+ set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY ${RunCMake_BINARY_DIR}/ExcludeFromAll-build/ExcludeFromAll)
+ run_cmake_command(ExcludeFromAll-build-sub xcodebuild -configuration Debug)
+endif()
+unset(RunCMake-check-file)
unset(RunCMake_TEST_NO_CLEAN)
+unset(RunCMake_TEST_OPTIONS)
+unset(RunCMake_TEST_BINARY_DIR)
diff --git a/Tests/RunCMake/alias_targets/RunCMakeTest.cmake b/Tests/RunCMake/alias_targets/RunCMakeTest.cmake
index 9a5eaaf1c..dded248ed 100644
--- a/Tests/RunCMake/alias_targets/RunCMakeTest.cmake
+++ b/Tests/RunCMake/alias_targets/RunCMakeTest.cmake
@@ -6,6 +6,7 @@ run_cmake(exclude-from-all)
run_cmake(imported)
run_cmake(invalid-name)
run_cmake(invalid-target)
+run_cmake(imported-global-target)
run_cmake(imported-target)
run_cmake(alias-target)
run_cmake(set_property)
diff --git a/Tests/RunCMake/alias_targets/imported-global-target-stderr.txt b/Tests/RunCMake/alias_targets/imported-global-target-stderr.txt
new file mode 100644
index 000000000..8259c8059
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/imported-global-target-stderr.txt
@@ -0,0 +1,2 @@
+^'alias-test-exe' is an alias for 'test-exe' and its name-property contains 'test-exe'.
+'alias-test-lib' is an alias for 'test-lib' and its name-property contains 'test-lib'.$
diff --git a/Tests/RunCMake/alias_targets/imported-global-target.cmake b/Tests/RunCMake/alias_targets/imported-global-target.cmake
new file mode 100644
index 000000000..12c4e0a61
--- /dev/null
+++ b/Tests/RunCMake/alias_targets/imported-global-target.cmake
@@ -0,0 +1,46 @@
+
+enable_language(CXX)
+
+
+add_executable(test-exe IMPORTED GLOBAL)
+add_executable(alias-test-exe ALIAS test-exe)
+
+if(TARGET alias-test-exe)
+ get_target_property(aliased-target alias-test-exe ALIASED_TARGET)
+ if("${aliased-target}" STREQUAL "test-exe")
+ get_target_property(aliased-name alias-test-exe NAME)
+ if("${aliased-name}" STREQUAL "test-exe")
+ message("'alias-test-exe' is an alias for '${aliased-target}'"
+ " and its name-property contains '${aliased-name}'.")
+ else()
+ message("'alias-test-exe' is an alias for '${aliased-target}'"
+ " but its name-property contains '${aliased-name}'!?")
+ endif()
+ else()
+ message("'alias-test-exe' is something but not a real target!?")
+ endif()
+else()
+ message("'alias-test-exe' does not exist!?")
+endif()
+
+
+add_library(test-lib SHARED IMPORTED GLOBAL)
+add_library(alias-test-lib ALIAS test-lib)
+
+if(TARGET alias-test-lib)
+ get_target_property(aliased-target alias-test-lib ALIASED_TARGET)
+ if("${aliased-target}" STREQUAL "test-lib")
+ get_target_property(aliased-name alias-test-lib NAME)
+ if("${aliased-name}" STREQUAL "test-lib")
+ message("'alias-test-lib' is an alias for '${aliased-target}'"
+ " and its name-property contains '${aliased-name}'.")
+ else()
+ message("'alias-test-lib' is an alias for '${aliased-target}'"
+ " but its name-property contains '${aliased-name}'!?")
+ endif()
+ else()
+ message("'alias-test-lib' is something but not a real target!?")
+ endif()
+else()
+ message("'alias-test-lib' does not exist!?")
+endif()
diff --git a/Tests/RunCMake/alias_targets/imported-target-stderr.txt b/Tests/RunCMake/alias_targets/imported-target-stderr.txt
index bbff29a80..465de0362 100644
--- a/Tests/RunCMake/alias_targets/imported-target-stderr.txt
+++ b/Tests/RunCMake/alias_targets/imported-target-stderr.txt
@@ -1,5 +1,15 @@
-CMake Error at imported-target.cmake:6 \(add_library\):
- add_library cannot create ALIAS target "alias" because target "foo" is
- IMPORTED.
+^CMake Error at imported-target.cmake:[0-9]+ \(add_executable\):
+ add_executable cannot create ALIAS target \"alias-test-exe\" because target
+ \"test-exe\" is imported but not globally visible.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists.txt:[0-9]+ \(include\)
++
+'alias-test-exe' does not exist![?]
+*
+CMake Error at imported-target.cmake:[0-9]+ \(add_library\):
+ add_library cannot create ALIAS target "alias-test-lib" because target
+ "test-lib" is imported but not globally visible.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+'alias-test-lib' does not exist![?]$
diff --git a/Tests/RunCMake/alias_targets/imported-target.cmake b/Tests/RunCMake/alias_targets/imported-target.cmake
index 7259ab091..bb682fecd 100644
--- a/Tests/RunCMake/alias_targets/imported-target.cmake
+++ b/Tests/RunCMake/alias_targets/imported-target.cmake
@@ -1,6 +1,46 @@
enable_language(CXX)
-add_library(foo SHARED IMPORTED)
-add_library(alias ALIAS foo)
+add_executable(test-exe IMPORTED)
+add_executable(alias-test-exe ALIAS test-exe)
+
+if(TARGET alias-test-exe)
+ get_target_property(aliased-target alias-test-exe ALIASED_TARGET)
+ if("${aliased-target}" STREQUAL "test-exe")
+ get_target_property(aliased-name alias-test-exe NAME)
+ if("${aliased-name}" STREQUAL "test-exe")
+ message("'alias-test-exe' is an alias for '${aliased-target}'"
+ " and its name-property contains '${aliased-name}'.")
+ else()
+ message("'alias-test-exe' is an alias for '${aliased-target}'"
+ " but its name-property contains '${aliased-name}'!?")
+ endif()
+ else()
+ message("'alias-test-exe' is something but not a real target!?")
+ endif()
+else()
+ message("'alias-test-exe' does not exist!?")
+endif()
+
+
+add_library(test-lib SHARED IMPORTED)
+add_library(alias-test-lib ALIAS test-lib)
+
+if(TARGET alias-test-lib)
+ get_target_property(aliased-target alias-test-lib ALIASED_TARGET)
+ if("${aliased-target}" STREQUAL "test-lib")
+ get_target_property(aliased-name alias-test-lib NAME)
+ if("${aliased-name}" STREQUAL "test-lib")
+ message("'alias-test-lib' is an alias for '${aliased-target}'"
+ " and its name-property contains '${aliased-name}'.")
+ else()
+ message("'alias-test-lib' is an alias for '${aliased-target}'"
+ " but its name-property contains '${aliased-name}'!?")
+ endif()
+ else()
+ message("'alias-test-lib' is something but not a real target!?")
+ endif()
+else()
+ message("'alias-test-lib' does not exist!?")
+endif()
diff --git a/Tests/RunCMake/build_command/CMP0061-OLD-make-stderr.txt b/Tests/RunCMake/build_command/CMP0061-OLD-make-stderr.txt
index 28e0e7235..1938da37f 100644
--- a/Tests/RunCMake/build_command/CMP0061-OLD-make-stderr.txt
+++ b/Tests/RunCMake/build_command/CMP0061-OLD-make-stderr.txt
@@ -1,4 +1,15 @@
-^[^
+^CMake Deprecation Warning at CMP0061-OLD-make.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0061 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+[^
]+ --build \. --config "Release" -- -i
[^
]+ --build \. --config "Release" --target "MyTarget" -- -i
diff --git a/Tests/RunCMake/build_command/CMP0061-OLD-other-stderr.txt b/Tests/RunCMake/build_command/CMP0061-OLD-other-stderr.txt
index 1dde84379..85bbdf175 100644
--- a/Tests/RunCMake/build_command/CMP0061-OLD-other-stderr.txt
+++ b/Tests/RunCMake/build_command/CMP0061-OLD-other-stderr.txt
@@ -1,4 +1,15 @@
-^[^
+^CMake Deprecation Warning at CMP0061-OLD-other.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0061 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
+[^
]+ --build \. --config "Release"
[^
]+ --build \. --config "Release" --target "MyTarget"
diff --git a/Tests/RunCMake/cmake_minimum_required/Future.cmake b/Tests/RunCMake/cmake_minimum_required/Future.cmake
new file mode 100644
index 000000000..2b5c44517
--- /dev/null
+++ b/Tests/RunCMake/cmake_minimum_required/Future.cmake
@@ -0,0 +1 @@
+cmake_minimum_required(VERSION 3.11...99.0 SOME_FUTURE_OPTION)
diff --git a/Tests/RunCMake/cmake_minimum_required/Range-stderr.txt b/Tests/RunCMake/cmake_minimum_required/Range-stderr.txt
new file mode 100644
index 000000000..7d2bdae3b
--- /dev/null
+++ b/Tests/RunCMake/cmake_minimum_required/Range-stderr.txt
@@ -0,0 +1,4 @@
+^CMAKE_MINIMUM_REQUIRED_VERSION='3\.10'
+CMP0071='NEW'
+CMP0072='NEW'
+CMP0073=''$
diff --git a/Tests/RunCMake/cmake_minimum_required/Range.cmake b/Tests/RunCMake/cmake_minimum_required/Range.cmake
new file mode 100644
index 000000000..008009269
--- /dev/null
+++ b/Tests/RunCMake/cmake_minimum_required/Range.cmake
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.10...3.11)
+message("CMAKE_MINIMUM_REQUIRED_VERSION='${CMAKE_MINIMUM_REQUIRED_VERSION}'")
+foreach(policy CMP0071 CMP0072 CMP0073)
+ cmake_policy(GET ${policy} status)
+ message("${policy}='${status}'")
+endforeach()
diff --git a/Tests/RunCMake/cmake_minimum_required/RangeBad-result.txt b/Tests/RunCMake/cmake_minimum_required/RangeBad-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/cmake_minimum_required/RangeBad-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/cmake_minimum_required/RangeBad-stderr.txt b/Tests/RunCMake/cmake_minimum_required/RangeBad-stderr.txt
new file mode 100644
index 000000000..b2c62fbfc
--- /dev/null
+++ b/Tests/RunCMake/cmake_minimum_required/RangeBad-stderr.txt
@@ -0,0 +1,56 @@
+^CMake Error at RangeBad.cmake:1 \(cmake_minimum_required\):
+ cmake_minimum_required VERSION "3.11..." does not have a version on both
+ sides of "...".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Error at RangeBad.cmake:2 \(cmake_minimum_required\):
+ cmake_minimum_required VERSION "...3.11" does not have a version on both
+ sides of "...".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Error at RangeBad.cmake:3 \(cmake_minimum_required\):
+ cmake_minimum_required VERSION "..." does not have a version on both sides
+ of "...".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Error at RangeBad.cmake:4 \(cmake_minimum_required\):
+ Invalid policy max version value "4". A numeric
+ major.minor\[.patch\[.tweak\]\] must be given.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Error at RangeBad.cmake:5 \(cmake_minimum_required\):
+ Policy VERSION range "3.11...3.10" specifies a larger minimum than maximum.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Error at RangeBad.cmake:6 \(cmake_policy\):
+ cmake_policy VERSION "3.11..." does not have a version on both sides of
+ "...".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Error at RangeBad.cmake:7 \(cmake_policy\):
+ cmake_policy VERSION "...3.11" does not have a version on both sides of
+ "...".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Error at RangeBad.cmake:8 \(cmake_policy\):
+ cmake_policy VERSION "..." does not have a version on both sides of "...".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Error at RangeBad.cmake:9 \(cmake_policy\):
+ Invalid policy max version value "4". A numeric
+ major.minor\[.patch\[.tweak\]\] must be given.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Error at RangeBad.cmake:10 \(cmake_policy\):
+ Policy VERSION range "3.11...3.10" specifies a larger minimum than maximum.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/cmake_minimum_required/RangeBad.cmake b/Tests/RunCMake/cmake_minimum_required/RangeBad.cmake
new file mode 100644
index 000000000..2a2dade2c
--- /dev/null
+++ b/Tests/RunCMake/cmake_minimum_required/RangeBad.cmake
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.11...)
+cmake_minimum_required(VERSION ...3.11)
+cmake_minimum_required(VERSION ...)
+cmake_minimum_required(VERSION 3.11...4)
+cmake_minimum_required(VERSION 3.11...3.10)
+cmake_policy(VERSION 3.11...)
+cmake_policy(VERSION ...3.11)
+cmake_policy(VERSION ...)
+cmake_policy(VERSION 3.11...4)
+cmake_policy(VERSION 3.11...3.10)
diff --git a/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake b/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake
index e4c65e3b6..1030211e7 100644
--- a/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake
+++ b/Tests/RunCMake/cmake_minimum_required/RunCMakeTest.cmake
@@ -2,4 +2,8 @@ include(RunCMake)
run_cmake(Before24)
run_cmake(CompatBefore24)
+run_cmake(Future)
run_cmake(PolicyBefore24)
+run_cmake(Range)
+run_cmake(RangeBad)
+run_cmake(Unknown)
diff --git a/Tests/RunCMake/cmake_minimum_required/Unknown-result.txt b/Tests/RunCMake/cmake_minimum_required/Unknown-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/cmake_minimum_required/Unknown-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/cmake_minimum_required/Unknown-stderr.txt b/Tests/RunCMake/cmake_minimum_required/Unknown-stderr.txt
new file mode 100644
index 000000000..d698642b4
--- /dev/null
+++ b/Tests/RunCMake/cmake_minimum_required/Unknown-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at Unknown.cmake:1 \(cmake_minimum_required\):
+ cmake_minimum_required called with unknown argument "SOME_UNKNOWN_OPTION".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/cmake_minimum_required/Unknown.cmake b/Tests/RunCMake/cmake_minimum_required/Unknown.cmake
new file mode 100644
index 000000000..6c70f917c
--- /dev/null
+++ b/Tests/RunCMake/cmake_minimum_required/Unknown.cmake
@@ -0,0 +1 @@
+cmake_minimum_required(VERSION 3.11 SOME_UNKNOWN_OPTION)
diff --git a/Tests/RunCMake/cmake_parse_arguments/KeyWordsMissingValues.cmake b/Tests/RunCMake/cmake_parse_arguments/KeyWordsMissingValues.cmake
new file mode 100644
index 000000000..561f9c03b
--- /dev/null
+++ b/Tests/RunCMake/cmake_parse_arguments/KeyWordsMissingValues.cmake
@@ -0,0 +1,133 @@
+include(${CMAKE_CURRENT_LIST_DIR}/test_utils.cmake)
+
+# No keywords that miss any values, _KEYWORDS_MISSING_VALUES should not be defined
+cmake_parse_arguments(PREF "" "P1" "P2" P1 p1 P2 p2_a p2_b)
+
+TEST(PREF_KEYWORDS_MISSING_VALUES "UNDEFINED")
+
+# Keyword should even be deleted from the actual scope
+set(PREF_KEYWORDS_MISSING_VALUES "What ever")
+cmake_parse_arguments(PREF "" "" "")
+
+TEST(PREF_KEYWORDS_MISSING_VALUES "UNDEFINED")
+
+# Given missing keywords as only option
+cmake_parse_arguments(PREF "" "P1" "P2" P1)
+
+TEST(PREF_KEYWORDS_MISSING_VALUES "P1")
+TEST(PREF_P1 "UNDEFINED")
+TEST(PREF_UNPARSED_ARGUMENTS "UNDEFINED")
+
+# Mixed with unparsed arguments
+cmake_parse_arguments(UPREF "" "P1" "P2" A B P2 C P1)
+TEST(UPREF_KEYWORDS_MISSING_VALUES "P1")
+TEST(UPREF_UNPARSED_ARGUMENTS A B)
+
+# one_value_keyword followed by option
+cmake_parse_arguments(REF "OP" "P1" "" P1 OP)
+TEST(REF_KEYWORDS_MISSING_VALUES "P1")
+TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED")
+TEST(REF_OP "TRUE")
+
+# Counter Test
+cmake_parse_arguments(REF "OP" "P1" "" P1 p1 OP)
+TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED")
+TEST(REF_P1 "p1")
+TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED")
+TEST(REF_OP "TRUE")
+
+# one_value_keyword followed by a one_value_keyword
+cmake_parse_arguments(REF "" "P1;P2" "" P1 P2 p2)
+TEST(REF_KEYWORDS_MISSING_VALUES "P1")
+TEST(REF_P1 "UNDEFINED")
+TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED")
+TEST(REF_P2 "p2")
+
+# Counter Test
+cmake_parse_arguments(REF "" "P1;P2" "" P1 p1 P2 p2)
+TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED")
+TEST(REF_P1 "p1")
+TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED")
+TEST(REF_P2 "p2")
+
+# one_value_keyword followed by a multi_value_keywords
+cmake_parse_arguments(REF "" "P1" "P2" P1 P2 p1 p2)
+TEST(REF_KEYWORDS_MISSING_VALUES "P1")
+TEST(REF_P1 "UNDEFINED")
+TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED")
+TEST(REF_P2 p1 p2)
+
+# Counter Examples
+cmake_parse_arguments(REF "" "P1" "P2" P1 p1 P2 p1 p2)
+TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED")
+TEST(REF_P1 "p1")
+TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED")
+TEST(REF_P2 p1 p2)
+
+# multi_value_keywords as only option
+cmake_parse_arguments(REF "" "P1" "P2" P2)
+TEST(REF_KEYWORDS_MISSING_VALUES "P2")
+TEST(REF_P1 "UNDEFINED")
+TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED")
+TEST(REF_P2 "UNDEFINED")
+
+# multi_value_keywords followed by option
+cmake_parse_arguments(REF "O1" "" "P1" P1 O1)
+TEST(REF_KEYWORDS_MISSING_VALUES "P1")
+TEST(REF_P1 "UNDEFINED")
+TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED")
+TEST(REF_O1 "TRUE")
+
+# counter test
+cmake_parse_arguments(REF "O1" "" "P1" P1 p1 p2 O1)
+TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED")
+TEST(REF_P1 "p1;p2")
+TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED")
+TEST(REF_O1 "TRUE")
+
+# multi_value_keywords followed by one_value_keyword
+cmake_parse_arguments(REF "" "P1" "P2" P2 P1 p1)
+TEST(REF_KEYWORDS_MISSING_VALUES "P2")
+TEST(REF_P1 "p1")
+TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED")
+TEST(REF_P2 "UNDEFINED")
+
+# counter test
+cmake_parse_arguments(REF "" "P1" "P2" P2 p2 P1 p1)
+TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED")
+TEST(REF_P1 "p1")
+TEST(REF_UNPARSED_ARGUMENTS "UNDEFINED")
+TEST(REF_P2 "p2")
+
+# one_value_keyword as last argument
+cmake_parse_arguments(REF "" "P1" "P2" A P2 p2 P1)
+TEST(REF_KEYWORDS_MISSING_VALUES "P1")
+TEST(REF_P1 "UNDEFINED")
+TEST(REF_UNPARSED_ARGUMENTS "A")
+TEST(REF_P2 "p2")
+
+# multi_value_keywords as last argument
+cmake_parse_arguments(REF "" "P1" "P2" P1 p1 P2)
+TEST(REF_KEYWORDS_MISSING_VALUES "P2")
+TEST(REF_P1 "p1")
+TEST(REF_P2 "UNDEFINED")
+
+# Multiple one_value_keyword and multi_value_keywords at different places
+cmake_parse_arguments(REF "O1;O2" "P1" "P2" P1 O1 P2 O2)
+TEST(REF_KEYWORDS_MISSING_VALUES P1 P2)
+TEST(REF_P1 "UNDEFINED")
+TEST(REF_P2 "UNDEFINED")
+
+# Duplicated missing keywords
+cmake_parse_arguments(REF "O1;O2" "P1" "P2" P1 O1 P2 O2 P1 P2)
+TEST(REF_KEYWORDS_MISSING_VALUES P1 P2)
+TEST(REF_P1 "UNDEFINED")
+TEST(REF_P2 "UNDEFINED")
+
+# make sure keywords that are never used, don't get added to KEYWORDS_MISSING_VALUES
+cmake_parse_arguments(REF "O1;O2" "P1" "P2")
+TEST(REF_KEYWORDS_MISSING_VALUES "UNDEFINED")
+TEST(REF_O1 FALSE)
+TEST(REF_O2 FALSE)
+TEST(REF_P1 UNDEFINED)
+TEST(REF_P2 UNDEFINED)
diff --git a/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake b/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake
index 1e15b3b2c..505840d7a 100644
--- a/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake
+++ b/Tests/RunCMake/cmake_parse_arguments/RunCMakeTest.cmake
@@ -11,3 +11,4 @@ run_cmake(BadArgvN2)
run_cmake(BadArgvN3)
run_cmake(BadArgvN4)
run_cmake(CornerCasesArgvN)
+run_cmake(KeyWordsMissingValues)
diff --git a/Tests/RunCMake/color_warning.c b/Tests/RunCMake/color_warning.c
new file mode 100644
index 000000000..831abd96a
--- /dev/null
+++ b/Tests/RunCMake/color_warning.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+int main(void)
+{
+ printf(
+ "/tmp/hello.c:3:2: \033[35mwarning:\033[0m Hello, World! [-W#warnings]\n");
+ return 0;
+}
diff --git a/Tests/RunCMake/configure_file/DirInput-stderr.txt b/Tests/RunCMake/configure_file/DirInput-stderr.txt
index 2e0cd144c..165ad80eb 100644
--- a/Tests/RunCMake/configure_file/DirInput-stderr.txt
+++ b/Tests/RunCMake/configure_file/DirInput-stderr.txt
@@ -1,7 +1,7 @@
CMake Error at DirInput.cmake:[0-9]+ \(configure_file\):
configure_file input location
- .*/Tests/RunCMake/configure_file/.
+ .*/Tests/RunCMake/configure_file
is a directory but a file was expected.
Call Stack \(most recent call first\):
diff --git a/Tests/RunCMake/ctest_build/BuildQuiet-stdout.txt b/Tests/RunCMake/ctest_build/BuildQuiet-stdout.txt
index 2e59d99ec..cc9085fee 100644
--- a/Tests/RunCMake/ctest_build/BuildQuiet-stdout.txt
+++ b/Tests/RunCMake/ctest_build/BuildQuiet-stdout.txt
@@ -1,7 +1,6 @@
Run dashboard with model Experimental
Source directory: .*/Tests/RunCMake/ctest_build/BuildQuiet
Build directory: .*/Tests/RunCMake/ctest_build/BuildQuiet-build
- Reading ctest configuration file: .*/Tests/RunCMake/ctest_build/BuildQuiet/CTestConfig.cmake
Site: test-site
Build name: test-build-name
Use Experimental tag: [0-9-]+
diff --git a/Tests/RunCMake/ctest_build/CTestConfig.cmake.in b/Tests/RunCMake/ctest_build/CTestConfig.cmake.in
deleted file mode 100644
index 097f82c17..000000000
--- a/Tests/RunCMake/ctest_build/CTestConfig.cmake.in
+++ /dev/null
@@ -1 +0,0 @@
-set(CTEST_PROJECT_NAME "CTestBuild@CASE_NAME@")
diff --git a/Tests/RunCMake/ctest_build/IgnoreColor-stdout.txt b/Tests/RunCMake/ctest_build/IgnoreColor-stdout.txt
new file mode 100644
index 000000000..cd1720f53
--- /dev/null
+++ b/Tests/RunCMake/ctest_build/IgnoreColor-stdout.txt
@@ -0,0 +1,2 @@
+ 0 Compiler errors
+ 1 Compiler warnings
diff --git a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake
index 1092d2ad4..b2e562a93 100644
--- a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake
@@ -1,6 +1,8 @@
include(RunCTest)
set(CASE_CTEST_BUILD_ARGS "")
+set(RunCMake_USE_LAUNCHERS TRUE)
+set(RunCMake_USE_CUSTOM_BUILD_COMMAND FALSE)
function(run_ctest_build CASE_NAME)
set(CASE_CTEST_BUILD_ARGS "${ARGN}")
@@ -45,3 +47,9 @@ function(run_BuildChangeId)
run_ctest(BuildChangeId)
endfunction()
run_BuildChangeId()
+
+set(RunCMake_USE_LAUNCHERS FALSE)
+set(RunCMake_USE_CUSTOM_BUILD_COMMAND TRUE)
+set(RunCMake_BUILD_COMMAND "${COLOR_WARNING}")
+run_ctest(IgnoreColor)
+unset(RunCMake_BUILD_COMMAND)
diff --git a/Tests/RunCMake/ctest_build/test.cmake.in b/Tests/RunCMake/ctest_build/test.cmake.in
index 6f15ec98e..9f7fa13e0 100644
--- a/Tests/RunCMake/ctest_build/test.cmake.in
+++ b/Tests/RunCMake/ctest_build/test.cmake.in
@@ -9,7 +9,10 @@ set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@")
set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@")
set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
-set(CTEST_USE_LAUNCHERS TRUE)
+set(CTEST_USE_LAUNCHERS "@RunCMake_USE_LAUNCHERS@")
+if (@RunCMake_USE_CUSTOM_BUILD_COMMAND@)
+ set(CTEST_BUILD_COMMAND "\"@RunCMake_BUILD_COMMAND@\"")
+endif()
set(ctest_build_args "@CASE_CTEST_BUILD_ARGS@")
ctest_start(Experimental)
diff --git a/Tests/RunCMake/ctest_cmake_error/CTestConfig.cmake.in b/Tests/RunCMake/ctest_cmake_error/CTestConfig.cmake.in
deleted file mode 100644
index 1f679d5d0..000000000
--- a/Tests/RunCMake/ctest_cmake_error/CTestConfig.cmake.in
+++ /dev/null
@@ -1 +0,0 @@
-set(CTEST_PROJECT_NAME "CTestCoverage@CASE_NAME@")
diff --git a/Tests/RunCMake/ctest_configure/CTestConfig.cmake.in b/Tests/RunCMake/ctest_configure/CTestConfig.cmake.in
deleted file mode 100644
index 7e30ab933..000000000
--- a/Tests/RunCMake/ctest_configure/CTestConfig.cmake.in
+++ /dev/null
@@ -1 +0,0 @@
-set(CTEST_PROJECT_NAME "CTestConfigure@CASE_NAME@")
diff --git a/Tests/RunCMake/ctest_configure/ConfigureQuiet-stdout.txt b/Tests/RunCMake/ctest_configure/ConfigureQuiet-stdout.txt
index 015644d81..98f5a4cd4 100644
--- a/Tests/RunCMake/ctest_configure/ConfigureQuiet-stdout.txt
+++ b/Tests/RunCMake/ctest_configure/ConfigureQuiet-stdout.txt
@@ -1,7 +1,6 @@
Run dashboard with model Experimental
Source directory: .*/Tests/RunCMake/ctest_configure/ConfigureQuiet
Build directory: .*/Tests/RunCMake/ctest_configure/ConfigureQuiet-build
- Reading ctest configuration file: .*/Tests/RunCMake/ctest_configure/ConfigureQuiet/CTestConfig.cmake
Site: test-site
Build name: test-build-name
Use Experimental tag: [0-9-]+
diff --git a/Tests/RunCMake/ctest_coverage/CTestConfig.cmake.in b/Tests/RunCMake/ctest_coverage/CTestConfig.cmake.in
deleted file mode 100644
index 1f679d5d0..000000000
--- a/Tests/RunCMake/ctest_coverage/CTestConfig.cmake.in
+++ /dev/null
@@ -1 +0,0 @@
-set(CTEST_PROJECT_NAME "CTestCoverage@CASE_NAME@")
diff --git a/Tests/RunCMake/ctest_disabled_test/CTestConfig.cmake.in b/Tests/RunCMake/ctest_disabled_test/CTestConfig.cmake.in
deleted file mode 100644
index c0d7e425f..000000000
--- a/Tests/RunCMake/ctest_disabled_test/CTestConfig.cmake.in
+++ /dev/null
@@ -1 +0,0 @@
-set(CTEST_PROJECT_NAME "@CASE_NAME@")
diff --git a/Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in b/Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in
index 5cb0b4ef6..6b11cffac 100644
--- a/Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in
+++ b/Tests/RunCMake/ctest_fixtures/CMakeLists.txt.in
@@ -27,7 +27,11 @@ passTest(two) # 6
passTest(cleanupBar) # 7
passTest(three) # 8
failTest(setupFails) # 9
-passTest(wontRun) # 10
+
+# Special case, test executable always missing to verify fixture dependencies
+# are checked before existence of test executable to be run
+add_test(NAME wontRun COMMAND iDoNotExist) # 10
+
passTest(cyclicSetup) # 11
passTest(cyclicCleanup) # 12
passTest(cleanupUnused) # 13
diff --git a/Tests/RunCMake/ctest_fixtures/CTestConfig.cmake.in b/Tests/RunCMake/ctest_fixtures/CTestConfig.cmake.in
deleted file mode 100644
index 982356266..000000000
--- a/Tests/RunCMake/ctest_fixtures/CTestConfig.cmake.in
+++ /dev/null
@@ -1 +0,0 @@
-set(CTEST_PROJECT_NAME "CTestTestFixtures.@CASE_NAME@")
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CMakeLists.txt.in b/Tests/RunCMake/ctest_labels_for_subprojects/CMakeLists.txt.in
new file mode 100644
index 000000000..30dd37e8e
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/CMakeLists.txt.in
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.9)
+@CASE_CMAKELISTS_PREFIX_CODE@
+project(CTestLabelsForSubprojects@CASE_NAME@ NONE)
+include(CTest)
+@CASE_CMAKELISTS_SUFFIX_CODE@
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfig.cmake.in b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfig.cmake.in
new file mode 100644
index 000000000..5d8353068
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfig.cmake.in
@@ -0,0 +1 @@
+@CTEST_EXTRA_CONFIG@
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-check.cmake b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-check.cmake
new file mode 100644
index 000000000..ea0585113
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-check.cmake
@@ -0,0 +1,36 @@
+set(EXPERIMENTAL_FEATURE_REGEX "<Subproject name=\"MyExperimentalFeature\">.*<Label>MyExperimentalFeature</Label>.*</Subproject>")
+set(PRODUCTION_CODE_REGEX "<Subproject name=\"MyProductionCode\">.*<Label>MyProductionCode</Label>.*</Subproject>")
+set(SUBPROJECTS_REGEX "${EXPERIMENTAL_FEATURE_REGEX}.*${PRODUCTION_CODE_REGEX}")
+
+file(GLOB configure_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Configure.xml")
+if(configure_xml_file)
+ file(READ "${configure_xml_file}" configure_xml)
+ if(NOT configure_xml MATCHES "${SUBPROJECTS_REGEX}.*<Configure>")
+ set(RunCMake_TEST_FAILED "Configure.xml does not contain the expected list of subprojects")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "Configure.xml not found")
+endif()
+
+file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml")
+if(build_xml_file)
+ file(READ "${build_xml_file}" build_xml)
+ set(BUILD_WARNING_REGEX "<Failure type=\"Warning\">.*<Labels>.*<Label>MyExperimentalFeature</Label>.*</Labels>")
+ if(NOT build_xml MATCHES "${SUBPROJECTS_REGEX}.*<Build>.*${BUILD_ERROR_REGEX}.*</Build>")
+ set(RunCMake_TEST_FAILED "Build.xml does not contain the expected list of subprojects and labels")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "Build.xml not found")
+endif()
+
+file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml")
+if(test_xml_file)
+ file(READ "${test_xml_file}" test_xml)
+ set(TEST_FAILED_REGEX "<Test Status=\"failed\">.*<Labels>.*<Label>MyExperimentalFeature</Label>.*<Label>NotASubproject</Label>.*</Labels>")
+ set(TEST_PASSED_REGEX "<Test Status=\"passed\">.*<Labels>.*<Label>MyProductionCode</Label>.*</Labels>")
+ if(NOT test_xml MATCHES "${SUBPROJECTS_REGEX}.*<Testing>.*${TEST_FAILED_REGEX}.*${TEST_PASSED_REGEX}.*${TEST_NOTRUN_REGEX}.*</Testing>")
+ set(RunCMake_TEST_FAILED "Test.xml does not contain the expected list of subprojects and labels")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "${CTEST_BINARY_DIRECTORY}/Testing/*/Test.xml not found")
+endif()
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-stdout.txt
new file mode 100644
index 000000000..05b484daa
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestConfigCTestScript-stdout.txt
@@ -0,0 +1,10 @@
+17% tests passed, 5 tests failed out of 6
++
+Subproject Time Summary:
+MyExperimentalFeature += +[0-9.]+ sec\*proc \(5 tests\)
+MyProductionCode += +[0-9.]+ sec\*proc \(1 test\)
++
+Label Time Summary:
+NotASubproject += +[0-9.]+ sec\*proc \(6 tests\)
++
+Total Test time \(real\) = +[0-9.]+ sec
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-check.cmake b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-check.cmake
new file mode 100644
index 000000000..ea0585113
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-check.cmake
@@ -0,0 +1,36 @@
+set(EXPERIMENTAL_FEATURE_REGEX "<Subproject name=\"MyExperimentalFeature\">.*<Label>MyExperimentalFeature</Label>.*</Subproject>")
+set(PRODUCTION_CODE_REGEX "<Subproject name=\"MyProductionCode\">.*<Label>MyProductionCode</Label>.*</Subproject>")
+set(SUBPROJECTS_REGEX "${EXPERIMENTAL_FEATURE_REGEX}.*${PRODUCTION_CODE_REGEX}")
+
+file(GLOB configure_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Configure.xml")
+if(configure_xml_file)
+ file(READ "${configure_xml_file}" configure_xml)
+ if(NOT configure_xml MATCHES "${SUBPROJECTS_REGEX}.*<Configure>")
+ set(RunCMake_TEST_FAILED "Configure.xml does not contain the expected list of subprojects")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "Configure.xml not found")
+endif()
+
+file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml")
+if(build_xml_file)
+ file(READ "${build_xml_file}" build_xml)
+ set(BUILD_WARNING_REGEX "<Failure type=\"Warning\">.*<Labels>.*<Label>MyExperimentalFeature</Label>.*</Labels>")
+ if(NOT build_xml MATCHES "${SUBPROJECTS_REGEX}.*<Build>.*${BUILD_ERROR_REGEX}.*</Build>")
+ set(RunCMake_TEST_FAILED "Build.xml does not contain the expected list of subprojects and labels")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "Build.xml not found")
+endif()
+
+file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml")
+if(test_xml_file)
+ file(READ "${test_xml_file}" test_xml)
+ set(TEST_FAILED_REGEX "<Test Status=\"failed\">.*<Labels>.*<Label>MyExperimentalFeature</Label>.*<Label>NotASubproject</Label>.*</Labels>")
+ set(TEST_PASSED_REGEX "<Test Status=\"passed\">.*<Labels>.*<Label>MyProductionCode</Label>.*</Labels>")
+ if(NOT test_xml MATCHES "${SUBPROJECTS_REGEX}.*<Testing>.*${TEST_FAILED_REGEX}.*${TEST_PASSED_REGEX}.*${TEST_NOTRUN_REGEX}.*</Testing>")
+ set(RunCMake_TEST_FAILED "Test.xml does not contain the expected list of subprojects and labels")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "${CTEST_BINARY_DIRECTORY}/Testing/*/Test.xml not found")
+endif()
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-stdout.txt
new file mode 100644
index 000000000..05b484daa
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariable-stdout.txt
@@ -0,0 +1,10 @@
+17% tests passed, 5 tests failed out of 6
++
+Subproject Time Summary:
+MyExperimentalFeature += +[0-9.]+ sec\*proc \(5 tests\)
+MyProductionCode += +[0-9.]+ sec\*proc \(1 test\)
++
+Label Time Summary:
+NotASubproject += +[0-9.]+ sec\*proc \(6 tests\)
++
+Total Test time \(real\) = +[0-9.]+ sec
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-check.cmake b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-check.cmake
new file mode 100644
index 000000000..7beefba2f
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-check.cmake
@@ -0,0 +1,34 @@
+set(THIRD_PARTY_REGEX "<Subproject name=\"MyThirdPartyDependency\">.*<Label>MyThirdPartyDependency</Label>.*</Subproject>")
+set(SUBPROJECTS_REGEX "${THIRD_PARTY_REGEX}")
+
+file(GLOB configure_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Configure.xml")
+if(configure_xml_file)
+ file(READ "${configure_xml_file}" configure_xml)
+ if(NOT configure_xml MATCHES "${SUBPROJECTS_REGEX}.*<Configure>")
+ set(RunCMake_TEST_FAILED "Configure.xml does not contain the expected list of subprojects")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "Configure.xml not found")
+endif()
+
+file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml")
+if(build_xml_file)
+ file(READ "${build_xml_file}" build_xml)
+ set(BUILD_ERROR_REGEX "<Failure type=\"Error\">.*<Labels>.*<Label>MyThirdPartyDependency</Label>.*<Label>NotASubproject</Label>.*</Labels>")
+ if(NOT build_xml MATCHES "${SUBPROJECTS_REGEX}.*<Build>.*${BUILD_ERROR_REGEX}.*</Build>")
+ set(RunCMake_TEST_FAILED "Build.xml does not contain the expected list of subprojects and labels")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "Build.xml not found")
+endif()
+
+file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml")
+if(test_xml_file)
+ file(READ "${test_xml_file}" test_xml)
+ set(TEST_NOTRUN_REGEX "<Test Status=\"notrun\">.*<Labels>.*<Label>MyThirdPartyDependency</Label>.*<Label>NotASubproject</Label>.*</Labels>")
+ if(NOT test_xml MATCHES "${SUBPROJECTS_REGEX}.*<Testing>.*${TEST_FAILED_REGEX}.*${TEST_PASSED_REGEX}.*${TEST_NOTRUN_REGEX}.*</Testing>")
+ set(RunCMake_TEST_FAILED "Test.xml does not contain the expected list of subprojects and labels")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "${CTEST_BINARY_DIRECTORY}/Testing/*/Test.xml not found")
+endif()
diff --git a/Tests/RunCMake/ctest_memcheck/DummyValgrindNoLogFile-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_memcheck/DummyValgrindNoLogFile-result.txt
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-result.txt
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt
new file mode 100644
index 000000000..38566fb2a
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stderr.txt
@@ -0,0 +1 @@
+Unable to find executable:.*MyThirdPartyDependency/src/thirdparty
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stdout.txt
new file mode 100644
index 000000000..c2c1bc7a0
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/CTestScriptVariableCommandLine-stdout.txt
@@ -0,0 +1,9 @@
+0% tests passed, 1 tests failed out of 1
++
+Subproject Time Summary:
+MyThirdPartyDependency += +[0-9.]+ sec\*proc \(1 test\)
++
+Label Time Summary:
+NotASubproject += +[0-9.]+ sec\*proc \(1 test\)
++
+Total Test time \(real\) = +[0-9.]+ sec
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-result.txt
new file mode 100644
index 000000000..45a4fb75d
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-result.txt
@@ -0,0 +1 @@
+8
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stderr.txt
new file mode 100644
index 000000000..ba4235def
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stderr.txt
@@ -0,0 +1 @@
+Errors while running CTest
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stdout.txt
new file mode 100644
index 000000000..3567a92b8
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCMakeLists-stdout.txt
@@ -0,0 +1,6 @@
+50% tests passed, 1 tests failed out of 2
++
+Subproject Time Summary:
+MySubproject += +[0-9.]+ sec\*proc \(2 tests\)
++
+Total Test time \(real\) = +[0-9.]+ sec
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-result.txt
new file mode 100644
index 000000000..45a4fb75d
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-result.txt
@@ -0,0 +1 @@
+8
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stderr.txt
new file mode 100644
index 000000000..ba4235def
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stderr.txt
@@ -0,0 +1 @@
+Errors while running CTest
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stdout.txt
new file mode 100644
index 000000000..3a7102247
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfig-stdout.txt
@@ -0,0 +1,9 @@
+67% tests passed, 1 tests failed out of 3
++
+Subproject Time Summary:
+MySubproject += +[0-9.]+ sec\*proc \(2 tests\)
++
+Label Time Summary:
+NotASubproject += +[0-9.]+ sec\*proc \(1 test\)
++
+Total Test time \(real\) = +[0-9.]+ sec
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-result.txt
new file mode 100644
index 000000000..45a4fb75d
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-result.txt
@@ -0,0 +1 @@
+8
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stderr.txt
new file mode 100644
index 000000000..ba4235def
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stderr.txt
@@ -0,0 +1 @@
+Errors while running CTest
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stdout.txt
new file mode 100644
index 000000000..1146bfe39
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCTestConfigNoSummary-stdout.txt
@@ -0,0 +1,6 @@
+67% tests passed, 1 tests failed out of 3
++
+Label Time Summary:
+NotASubproject += +[0-9.]+ sec\*proc \(1 test\)
++
+Total Test time \(real\) = +[0-9.]+ sec
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-result.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-result.txt
new file mode 100644
index 000000000..45a4fb75d
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-result.txt
@@ -0,0 +1 @@
+8
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stderr.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stderr.txt
new file mode 100644
index 000000000..ba4235def
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stderr.txt
@@ -0,0 +1 @@
+Errors while running CTest
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stdout.txt b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stdout.txt
new file mode 100644
index 000000000..3567a92b8
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/ModuleVariableCommandLine-stdout.txt
@@ -0,0 +1,6 @@
+50% tests passed, 1 tests failed out of 2
++
+Subproject Time Summary:
+MySubproject += +[0-9.]+ sec\*proc \(2 tests\)
++
+Total Test time \(real\) = +[0-9.]+ sec
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/CMakeLists.txt b/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/CMakeLists.txt
new file mode 100644
index 000000000..cc07a07f7
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/CMakeLists.txt
@@ -0,0 +1,33 @@
+project(MyExperimentalFeature)
+cmake_minimum_required(VERSION 3.8)
+
+include(CTest)
+
+set(CMAKE_DIRECTORY_LABELS "MyExperimentalFeature;NotASubproject")
+
+add_executable(testapp experimental.c)
+
+add_test(experimentalFail1 testapp 5)
+set_tests_properties (experimentalFail1
+ PROPERTIES PASS_REGULAR_EXPRESSION "Test!"
+ )
+
+add_test(experimentalFail2 testapp -5)
+set_tests_properties (experimentalFail2
+ PROPERTIES PASS_REGULAR_EXPRESSION "Test!"
+ )
+
+add_test(experimentalFail3 testapp -5)
+set_tests_properties (experimentalFail3
+ PROPERTIES PASS_REGULAR_EXPRESSION "Test!"
+ )
+
+add_test(experimentalFail4 testapp -5)
+set_tests_properties (experimentalFail4
+ PROPERTIES PASS_REGULAR_EXPRESSION "Test!"
+ )
+
+add_test(experimentalFail5 testapp -5)
+set_tests_properties (experimentalFail5
+ PROPERTIES PASS_REGULAR_EXPRESSION "Test!"
+ )
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/experimental.c b/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/experimental.c
new file mode 100644
index 000000000..7cb11ae50
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyExperimentalFeature/experimental.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+int main(void)
+{
+ int i = 0;
+ if (i > 0) {
+ printf("This doesn't happen.\n");
+ printf("Neither does this.\n");
+ }
+ i = i + 1;
+ if (i > 0) {
+ printf("This does happen.\n");
+ }
+
+ return 0;
+}
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/CMakeLists.txt b/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/CMakeLists.txt
new file mode 100644
index 000000000..c2ee673ab
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/CMakeLists.txt
@@ -0,0 +1,12 @@
+project(MyProductionCode)
+cmake_minimum_required(VERSION 3.8)
+
+include(CTest)
+
+add_executable(production production.c)
+add_test(NAME production COMMAND production)
+
+set_property(TARGET production PROPERTY LABELS MyProductionCode)
+set_property(TEST production PROPERTY LABELS MyProductionCode)
+
+set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY LABELS "NotASubproject")
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/production.c b/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/production.c
new file mode 100644
index 000000000..54dc2bec0
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyProductionCode/production.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+int main(void)
+{
+ int j = 0;
+ if (j > 0) {
+ printf("This doesn't happen.\n");
+ printf("Neither does this.\n");
+ }
+ j = j + 1;
+ if (j > 0) {
+ printf("This does happen.\n");
+ }
+
+ return 0;
+}
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/CMakeLists.txt b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/CMakeLists.txt
new file mode 100644
index 000000000..d5b9c2f22
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/CMakeLists.txt
@@ -0,0 +1,7 @@
+project(MyThirdPartyDependency)
+cmake_minimum_required(VERSION 3.8)
+
+include(CTest)
+
+set_directory_properties(PROPERTIES LABELS "NotASubproject;MyThirdPartyDependency")
+add_subdirectory(src)
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/CMakeLists.txt b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/CMakeLists.txt
new file mode 100644
index 000000000..dc6cb2a57
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/CMakeLists.txt
@@ -0,0 +1,10 @@
+project(MyThirdPartyDependency)
+cmake_minimum_required(VERSION 3.8)
+
+include(CTest)
+
+add_executable(thirdparty thirdparty.c)
+add_test(NAME thirdparty COMMAND thirdparty)
+
+set_property(TARGET thirdparty PROPERTY LABELS NotASubproject)
+set_property(TEST thirdparty PROPERTY LABELS NotASubproject)
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/thirdparty.c b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/thirdparty.c
new file mode 100644
index 000000000..babe82d2d
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/MyThirdPartyDependency/src/thirdparty.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+int main(void)
+{
+ printf(This function has an error!\n");
+ n = 5;
+ return 0;
+}
+
+int notcalled()
+{
+ printf(This function doesn't get called.\n");
+ return 0;
+}
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/RunCMakeTest.cmake b/Tests/RunCMake/ctest_labels_for_subprojects/RunCMakeTest.cmake
new file mode 100644
index 000000000..dbe7bf826
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/RunCMakeTest.cmake
@@ -0,0 +1,185 @@
+include(RunCTest)
+
+
+# 1. Specify subprojects in the CTest script
+function(run_CTestScriptVariable)
+ set(CTEST_EXTRA_CONFIG "set(CTEST_USE_LAUNCHERS 1)")
+ set(CASE_TEST_PREFIX_CODE [[
+file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyProductionCode"
+ DESTINATION ${CTEST_SOURCE_DIRECTORY})
+file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyExperimentalFeature"
+ DESTINATION ${CTEST_SOURCE_DIRECTORY})
+
+set(CTEST_LABELS_FOR_SUBPROJECTS "MyProductionCode;MyExperimentalFeature")
+ ]])
+ set(CASE_CMAKELISTS_SUFFIX_CODE [[
+add_subdirectory(MyExperimentalFeature)
+add_subdirectory(MyProductionCode)
+ ]])
+
+ run_ctest(CTestScriptVariable)
+
+ unset(CTEST_EXTRA_CONFIG)
+ unset(CASE_TEST_PREFIX_CODE)
+ unset(CASE_CMAKELISTS_SUFFIX_CODE)
+endfunction()
+run_CTestScriptVariable()
+
+# 2. Specify subprojects via a CTest script variable on the command line e.g.
+# ctest -S test.cmake -DCTEST_LABELS_FOR_SUBPROJECTS:STRING="MySubproject"
+# Note: This test includes a failing build
+function(run_CTestScriptVariableCommandLine)
+ set(CTEST_EXTRA_CONFIG "set(CTEST_USE_LAUNCHERS 1)")
+ set(CASE_TEST_PREFIX_CODE [[
+file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyThirdPartyDependency"
+ DESTINATION ${CTEST_SOURCE_DIRECTORY})
+ ]])
+ set(CASE_CMAKELISTS_SUFFIX_CODE [[
+add_subdirectory(MyThirdPartyDependency)
+ ]])
+
+ run_ctest(CTestScriptVariableCommandLine "-DCTEST_LABELS_FOR_SUBPROJECTS:STRING=MyThirdPartyDependency")
+
+ unset(CTEST_EXTRA_CONFIG)
+ unset(CASE_TEST_PREFIX_CODE)
+ unset(CASE_CMAKELISTS_SUFFIX_CODE)
+endfunction()
+run_CTestScriptVariableCommandLine()
+
+# 3. Set subprojects via a CTest module variable on the command line
+# (will populate DartConfiguration.tcl)
+function(run_ModuleVariableCommandLine)
+ set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/ModuleVariableCommandLine")
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/ModuleVariableCommandLine-build")
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}")
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ set(CASE_CMAKELISTS_SUFFIX_CODE [[
+set(someFile "${CMAKE_CURRENT_SOURCE_DIR}/test.cmake")
+add_test(NAME SuccessfulTest COMMAND "${CMAKE_COMMAND}" --version)
+set_property(TEST SuccessfulTest PROPERTY LABELS MySubproject)
+add_test(NAME FailingTest
+ COMMAND ${CMAKE_COMMAND} -E compare_files "${someFile}" "${someFile}xxx")
+set_property(TEST FailingTest PROPERTY LABELS MySubproject)
+ ]])
+ configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in
+ ${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt @ONLY)
+
+ set(RunCMake_TEST_OPTIONS "-DCTEST_LABELS_FOR_SUBPROJECTS:STRING=MySubproject")
+ run_cmake(ModuleVariableCommandLine-cmake)
+ unset(RunCMake_TEST_OPTIONS)
+ run_cmake_command(ModuleVariableCommandLine ${CMAKE_CTEST_COMMAND} -C Debug -V)
+
+ unset(RunCMake_TEST_SOURCE_DIR)
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+ unset(CASE_CMAKELISTS_SUFFIX_CODE)
+endfunction()
+run_ModuleVariableCommandLine()
+
+# 4. Set subprojects via a CTest module variable in CMakeLists.txt
+# (will populate DartConfiguration.tcl)
+function(run_ModuleVariableCMakeLists)
+ set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/ModuleVariableCMakeLists")
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/ModuleVariableCMakeLists-build")
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}")
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ set(CASE_CMAKELISTS_PREFIX_CODE [[
+set(CTEST_LABELS_FOR_SUBPROJECTS MySubproject)
+]])
+
+ set(CASE_CMAKELISTS_SUFFIX_CODE [[
+set(someFile "${CMAKE_CURRENT_SOURCE_DIR}/test.cmake")
+add_test(NAME SuccessfulTest COMMAND "${CMAKE_COMMAND}" --version)
+set_property(TEST SuccessfulTest PROPERTY LABELS MySubproject)
+add_test(NAME FailingTest
+ COMMAND ${CMAKE_COMMAND} -E compare_files "${someFile}" "${someFile}xxx")
+set_property(TEST FailingTest PROPERTY LABELS MySubproject)
+ ]])
+ configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in
+ ${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt @ONLY)
+
+ run_cmake(ModuleVariableCMakeLists-cmake)
+ run_cmake_command(ModuleVariableCMakeLists ${CMAKE_CTEST_COMMAND} -C Debug -V)
+
+ unset(RunCMake_TEST_SOURCE_DIR)
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+ unset(CASE_CMAKELISTS_SUFFIX_CODE)
+ unset(CASE_CMAKELISTS_SUFFIX_CODE)
+endfunction()
+run_ModuleVariableCMakeLists()
+
+# The remaining tests set subprojects in CTestConfig.cmake. Settings in this
+# config file are shared by both the CTest module and the ctest command line
+# `Dashboard Client` mode (e.g. ctest -S).
+
+function(run_ModuleVariableCTestConfig CASE_NAME)
+ set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${CASE_NAME}")
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${CASE_NAME}-build")
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}")
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ set(CTEST_EXTRA_CONFIG "set(CTEST_LABELS_FOR_SUBPROJECTS \"MySubproject\")")
+ configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in
+ ${RunCMake_TEST_SOURCE_DIR}/CTestConfig.cmake @ONLY)
+
+ set(CASE_CMAKELISTS_SUFFIX_CODE [[
+set(someFile "${CMAKE_CURRENT_SOURCE_DIR}/test.cmake")
+add_test(NAME SuccessfulTest COMMAND "${CMAKE_COMMAND}" --version)
+set_property(TEST SuccessfulTest PROPERTY LABELS MySubproject)
+add_test(NAME FailingTest
+ COMMAND ${CMAKE_COMMAND} -E compare_files "${someFile}" "${someFile}xxx")
+set_property(TEST FailingTest PROPERTY LABELS MySubproject)
+add_test(NAME AnotherSuccessfulTest COMMAND "${CMAKE_COMMAND}" --version)
+set_property(TEST AnotherSuccessfulTest PROPERTY LABELS NotASubproject)
+ ]])
+ configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in
+ ${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt @ONLY)
+
+ run_cmake(${CASE_NAME}-cmake)
+ run_cmake_command(${CASE_NAME} ${CMAKE_CTEST_COMMAND} -C Debug -V ${ARGN})
+
+ unset(RunCMake_TEST_SOURCE_DIR)
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+ unset(CTEST_EXTRA_CONFIG)
+ unset(CASE_CMAKELISTS_SUFFIX_CODE)
+endfunction()
+
+# 5. Check that the Subproject timing Summary is printed
+run_ModuleVariableCTestConfig(ModuleVariableCTestConfig)
+
+# 6. Use --no-subproject-summary to disable the Subproject timing summary.
+run_ModuleVariableCTestConfig(ModuleVariableCTestConfigNoSummary --no-subproject-summary)
+
+# 7. Verify that subprojects are sent to CDash when running a CTest script
+function(run_CTestConfigCTestScript)
+ set(CTEST_EXTRA_CONFIG [[
+set(CTEST_USE_LAUNCHERS 1)
+set(CTEST_LABELS_FOR_SUBPROJECTS "MyProductionCode;MyExperimentalFeature")
+ ]])
+ set(CASE_TEST_PREFIX_CODE [[
+file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyProductionCode"
+ DESTINATION ${CTEST_SOURCE_DIRECTORY})
+file(COPY "${CTEST_RUNCMAKE_SOURCE_DIRECTORY}/MyExperimentalFeature"
+ DESTINATION ${CTEST_SOURCE_DIRECTORY})
+ ]])
+ set(CASE_CMAKELISTS_SUFFIX_CODE [[
+add_subdirectory(MyExperimentalFeature)
+add_subdirectory(MyProductionCode)
+ ]])
+ run_ctest(CTestConfigCTestScript)
+
+ unset(CTEST_EXTRA_CONFIG)
+ unset(CASE_TEST_PREFIX_CODE)
+ unset(CASE_CMAKELISTS_SUFFIX_CODE)
+endfunction()
+run_CTestConfigCTestScript()
diff --git a/Tests/RunCMake/ctest_labels_for_subprojects/test.cmake.in b/Tests/RunCMake/ctest_labels_for_subprojects/test.cmake.in
new file mode 100644
index 000000000..8cec08d46
--- /dev/null
+++ b/Tests/RunCMake/ctest_labels_for_subprojects/test.cmake.in
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 3.7)
+
+# Settings:
+
+set(CTEST_SITE "test-site")
+set(CTEST_BUILD_NAME "test-build-name")
+set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@")
+set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build")
+set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@")
+set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
+set(CTEST_RUNCMAKE_SOURCE_DIRECTORY "@RunCMake_SOURCE_DIR@")
+
+@CASE_TEST_PREFIX_CODE@
+
+set(ctest_test_args "@CASE_CTEST_TEST_ARGS@")
+ctest_start(Experimental)
+ctest_configure()
+ctest_build()
+ctest_test(${ctest_test_args})
diff --git a/Tests/RunCMake/ctest_memcheck/CTestConfig.cmake.in b/Tests/RunCMake/ctest_memcheck/CTestConfig.cmake.in
index 6d4a718d0..53bdd20c8 100644
--- a/Tests/RunCMake/ctest_memcheck/CTestConfig.cmake.in
+++ b/Tests/RunCMake/ctest_memcheck/CTestConfig.cmake.in
@@ -1,9 +1,6 @@
-set (CTEST_PROJECT_NAME "CTestTestMemcheck@CASE_NAME@")
set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
-set (CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
-set(CTEST_DROP_SITE_CDASH TRUE)
@CTEST_EXTRA_CONFIG@
diff --git a/Tests/RunCMake/ctest_skipped_test/CTestConfig.cmake.in b/Tests/RunCMake/ctest_skipped_test/CTestConfig.cmake.in
deleted file mode 100644
index c0d7e425f..000000000
--- a/Tests/RunCMake/ctest_skipped_test/CTestConfig.cmake.in
+++ /dev/null
@@ -1 +0,0 @@
-set(CTEST_PROJECT_NAME "@CASE_NAME@")
diff --git a/Tests/RunCMake/ctest_skipped_test/skip.bat b/Tests/RunCMake/ctest_skipped_test/skip.bat
index 80e1290df..580f46018 100755
--- a/Tests/RunCMake/ctest_skipped_test/skip.bat
+++ b/Tests/RunCMake/ctest_skipped_test/skip.bat
@@ -1 +1 @@
-EXIT 125
+EXIT 125
diff --git a/Tests/RunCMake/ctest_start/AppendDifferentGroup-stderr.txt b/Tests/RunCMake/ctest_start/AppendDifferentGroup-stderr.txt
new file mode 100644
index 000000000..9e493a6ce
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendDifferentGroup-stderr.txt
@@ -0,0 +1 @@
+^Group given in TAG does not match group given in ctest_start\(\)$
diff --git a/Tests/RunCMake/ctest_start/AppendDifferentGroup-stdout.txt b/Tests/RunCMake/ctest_start/AppendDifferentGroup-stdout.txt
new file mode 100644
index 000000000..5f8365325
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendDifferentGroup-stdout.txt
@@ -0,0 +1,8 @@
+Run dashboard with to-be-determined model
+ Source directory: .*/Tests/RunCMake/ctest_start/AppendDifferentGroup
+ Build directory: .*/Tests/RunCMake/ctest_start/AppendDifferentGroup-build
+ Group: ExperimentalDifferent
+ Site: test-site
+ Build name: test-build-name
+ Use existing tag: 19551112-2204 - ExperimentalDifferent
+ Use ExperimentalDifferent tag: [0-9-]+
diff --git a/Tests/RunCMake/ctest_start/AppendDifferentModel-check.cmake b/Tests/RunCMake/ctest_start/AppendDifferentModel-check.cmake
new file mode 100644
index 000000000..d71b1cf01
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendDifferentModel-check.cmake
@@ -0,0 +1 @@
+check_tag_contents("^19551112-2204\nContinuousTrack\nContinuous\n$")
diff --git a/Tests/RunCMake/ctest_start/AppendDifferentModel-stderr.txt b/Tests/RunCMake/ctest_start/AppendDifferentModel-stderr.txt
new file mode 100644
index 000000000..a523f3ff0
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendDifferentModel-stderr.txt
@@ -0,0 +1 @@
+^Model given in TAG does not match model given in ctest_start\(\)$
diff --git a/Tests/RunCMake/ctest_start/AppendDifferentModel-stdout.txt b/Tests/RunCMake/ctest_start/AppendDifferentModel-stdout.txt
new file mode 100644
index 000000000..78f36a1a5
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendDifferentModel-stdout.txt
@@ -0,0 +1,7 @@
+Run dashboard with model Experimental
+ Source directory: .*/Tests/RunCMake/ctest_start/AppendDifferentModel
+ Build directory: .*/Tests/RunCMake/ctest_start/AppendDifferentModel-build
+ Site: test-site
+ Build name: test-build-name
+ Use existing tag: 19551112-2204 - ContinuousTrack
+ Use ContinuousTrack tag: [0-9-]+
diff --git a/Tests/RunCMake/ctest_start/AppendDifferentTrack-stderr.txt b/Tests/RunCMake/ctest_start/AppendDifferentTrack-stderr.txt
new file mode 100644
index 000000000..9e493a6ce
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendDifferentTrack-stderr.txt
@@ -0,0 +1 @@
+^Group given in TAG does not match group given in ctest_start\(\)$
diff --git a/Tests/RunCMake/ctest_start/AppendDifferentTrack-stdout.txt b/Tests/RunCMake/ctest_start/AppendDifferentTrack-stdout.txt
new file mode 100644
index 000000000..022e2ecaa
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendDifferentTrack-stdout.txt
@@ -0,0 +1,8 @@
+Run dashboard with to-be-determined model
+ Source directory: .*/Tests/RunCMake/ctest_start/AppendDifferentTrack
+ Build directory: .*/Tests/RunCMake/ctest_start/AppendDifferentTrack-build
+ Group: ExperimentalDifferent
+ Site: test-site
+ Build name: test-build-name
+ Use existing tag: 19551112-2204 - ExperimentalDifferent
+ Use ExperimentalDifferent tag: [0-9-]+
diff --git a/Tests/RunCMake/ctest_start/AppendNoMatchingTrack-stdout.txt b/Tests/RunCMake/ctest_start/AppendNoMatchingTrack-stdout.txt
new file mode 100644
index 000000000..578062959
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendNoMatchingTrack-stdout.txt
@@ -0,0 +1,7 @@
+Run dashboard with model Continuous
+ Source directory: .*/Tests/RunCMake/ctest_start/AppendNoMatchingTrack
+ Build directory: .*/Tests/RunCMake/ctest_start/AppendNoMatchingTrack-build
+ Site: test-site
+ Build name: test-build-name
+ Use existing tag: 19551112-2204 - SomeWeirdTrackName
+ Use SomeWeirdTrackName tag: [0-9-]+
diff --git a/Tests/RunCMake/ctest_start/AppendNoModel-check.cmake b/Tests/RunCMake/ctest_start/AppendNoModel-check.cmake
new file mode 100644
index 000000000..d71b1cf01
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendNoModel-check.cmake
@@ -0,0 +1 @@
+check_tag_contents("^19551112-2204\nContinuousTrack\nContinuous\n$")
diff --git a/Tests/RunCMake/ctest_start/AppendNoModel-stdout.txt b/Tests/RunCMake/ctest_start/AppendNoModel-stdout.txt
new file mode 100644
index 000000000..bcd01256b
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendNoModel-stdout.txt
@@ -0,0 +1,7 @@
+Run dashboard with to-be-determined model
+ Source directory: .*/Tests/RunCMake/ctest_start/AppendNoModel
+ Build directory: .*/Tests/RunCMake/ctest_start/AppendNoModel-build
+ Site: test-site
+ Build name: test-build-name
+ Use existing tag: 19551112-2204 - ContinuousTrack
+ Use ContinuousTrack tag: [0-9-]+
diff --git a/Tests/RunCMake/ctest_start/AppendOldContinuous-stdout.txt b/Tests/RunCMake/ctest_start/AppendOldContinuous-stdout.txt
new file mode 100644
index 000000000..e58cd9c66
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendOldContinuous-stdout.txt
@@ -0,0 +1,7 @@
+Run dashboard with model Continuous
+ Source directory: .*/Tests/RunCMake/ctest_start/AppendOldContinuous
+ Build directory: .*/Tests/RunCMake/ctest_start/AppendOldContinuous-build
+ Site: test-site
+ Build name: test-build-name
+ Use existing tag: 19551112-2204 - ContinuousTrack
+ Use ContinuousTrack tag: 19551112-2204
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-cp-result.txt b/Tests/RunCMake/ctest_start/AppendOldNoModel-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_submit/FailDrop-cp-result.txt
+++ b/Tests/RunCMake/ctest_start/AppendOldNoModel-result.txt
diff --git a/Tests/RunCMake/ctest_start/AppendOldNoModel-stderr.txt b/Tests/RunCMake/ctest_start/AppendOldNoModel-stderr.txt
new file mode 100644
index 000000000..c7ca1e7d8
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendOldNoModel-stderr.txt
@@ -0,0 +1,3 @@
+^TAG file does not contain model and no model specified in start command
+CMake Error at .*/Tests/RunCMake/ctest_start/AppendOldNoModel/test.cmake:[0-9]+ \(ctest_start\):
+ ctest_start unknown error.$
diff --git a/Tests/RunCMake/ctest_start/AppendOldNoModel-stdout.txt b/Tests/RunCMake/ctest_start/AppendOldNoModel-stdout.txt
new file mode 100644
index 000000000..47331e637
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendOldNoModel-stdout.txt
@@ -0,0 +1,5 @@
+Run dashboard with to-be-determined model
+ Source directory: .*/Tests/RunCMake/ctest_start/AppendOldNoModel
+ Build directory: .*/Tests/RunCMake/ctest_start/AppendOldNoModel-build
+ Site: test-site
+ Build name: test-build-name
diff --git a/Tests/RunCMake/ctest_start/AppendSameModel-check.cmake b/Tests/RunCMake/ctest_start/AppendSameModel-check.cmake
new file mode 100644
index 000000000..d71b1cf01
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendSameModel-check.cmake
@@ -0,0 +1 @@
+check_tag_contents("^19551112-2204\nContinuousTrack\nContinuous\n$")
diff --git a/Tests/RunCMake/ctest_start/AppendSameModel-stdout.txt b/Tests/RunCMake/ctest_start/AppendSameModel-stdout.txt
new file mode 100644
index 000000000..3abd51e0f
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/AppendSameModel-stdout.txt
@@ -0,0 +1,7 @@
+Run dashboard with model Continuous
+ Source directory: .*/Tests/RunCMake/ctest_start/AppendSameModel
+ Build directory: .*/Tests/RunCMake/ctest_start/AppendSameModel-build
+ Site: test-site
+ Build name: test-build-name
+ Use existing tag: 19551112-2204 - ContinuousTrack
+ Use ContinuousTrack tag: [0-9-]+
diff --git a/Tests/RunCMake/ctest_start/CTestConfig.cmake.in b/Tests/RunCMake/ctest_start/CTestConfig.cmake.in
deleted file mode 100644
index e75d14fc2..000000000
--- a/Tests/RunCMake/ctest_start/CTestConfig.cmake.in
+++ /dev/null
@@ -1 +0,0 @@
-set(CTEST_PROJECT_NAME "CTestStart@CASE_NAME@")
diff --git a/Tests/RunCMake/ctest_start/ConfigInBuild-stdout.txt b/Tests/RunCMake/ctest_start/ConfigInBuild-stdout.txt
index 7e94b8a12..f4a0ba37a 100644
--- a/Tests/RunCMake/ctest_start/ConfigInBuild-stdout.txt
+++ b/Tests/RunCMake/ctest_start/ConfigInBuild-stdout.txt
@@ -1,7 +1,6 @@
Run dashboard with model Experimental
Source directory: .*/Tests/RunCMake/ctest_start/ConfigInBuild
Build directory: .*/Tests/RunCMake/ctest_start/ConfigInBuild-build
- Reading ctest configuration file: .*/Tests/RunCMake/ctest_start/ConfigInBuild-build/CTestConfig.cmake
Site: test-site
Build name: test-build-name
Use Experimental tag: [0-9-]+
diff --git a/Tests/RunCMake/ctest_start/ConfigInSource-stdout.txt b/Tests/RunCMake/ctest_start/ConfigInSource-stdout.txt
index c3903726a..5f98b4e31 100644
--- a/Tests/RunCMake/ctest_start/ConfigInSource-stdout.txt
+++ b/Tests/RunCMake/ctest_start/ConfigInSource-stdout.txt
@@ -1,7 +1,6 @@
Run dashboard with model Experimental
Source directory: .*/Tests/RunCMake/ctest_start/ConfigInSource
Build directory: .*/Tests/RunCMake/ctest_start/ConfigInSource-build
- Reading ctest configuration file: .*/Tests/RunCMake/ctest_start/ConfigInSource/CTestConfig.cmake
Site: test-site
Build name: test-build-name
Use Experimental tag: [0-9-]+
diff --git a/Tests/RunCMake/CTestCommandLine/test-load-pass-stderr.txt b/Tests/RunCMake/ctest_start/FunctionScope-stdout.txt
index 10f32932e..10f32932e 100644
--- a/Tests/RunCMake/CTestCommandLine/test-load-pass-stderr.txt
+++ b/Tests/RunCMake/ctest_start/FunctionScope-stdout.txt
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-ftp-result.txt b/Tests/RunCMake/ctest_start/MissingGroupArg-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_submit/FailDrop-ftp-result.txt
+++ b/Tests/RunCMake/ctest_start/MissingGroupArg-result.txt
diff --git a/Tests/RunCMake/ctest_start/MissingGroupArg-stderr.txt b/Tests/RunCMake/ctest_start/MissingGroupArg-stderr.txt
new file mode 100644
index 000000000..e0480f647
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/MissingGroupArg-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at .*/Tests/RunCMake/ctest_start/MissingGroupArg/test\.cmake:[0-9]+ \(ctest_start\):
+ ctest_start GROUP argument missing group name$
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-scp-result.txt b/Tests/RunCMake/ctest_start/MissingGroupArgAppend-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_submit/FailDrop-scp-result.txt
+++ b/Tests/RunCMake/ctest_start/MissingGroupArgAppend-result.txt
diff --git a/Tests/RunCMake/ctest_start/MissingGroupArgAppend-stderr.txt b/Tests/RunCMake/ctest_start/MissingGroupArgAppend-stderr.txt
new file mode 100644
index 000000000..8ae53ff32
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/MissingGroupArgAppend-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at .*/Tests/RunCMake/ctest_start/MissingGroupArgAppend/test\.cmake:[0-9]+ \(ctest_start\):
+ ctest_start GROUP argument missing group name$
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-xmlrpc-result.txt b/Tests/RunCMake/ctest_start/MissingGroupArgQuiet-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_submit/FailDrop-xmlrpc-result.txt
+++ b/Tests/RunCMake/ctest_start/MissingGroupArgQuiet-result.txt
diff --git a/Tests/RunCMake/ctest_start/MissingGroupArgQuiet-stderr.txt b/Tests/RunCMake/ctest_start/MissingGroupArgQuiet-stderr.txt
new file mode 100644
index 000000000..c4f8900f2
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/MissingGroupArgQuiet-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at .*/Tests/RunCMake/ctest_start/MissingGroupArgQuiet/test\.cmake:[0-9]+ \(ctest_start\):
+ ctest_start GROUP argument missing group name$
diff --git a/Tests/RunCMake/ctest_test/CTestTestLoadFail-result.txt b/Tests/RunCMake/ctest_start/MissingTrackArg-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_test/CTestTestLoadFail-result.txt
+++ b/Tests/RunCMake/ctest_start/MissingTrackArg-result.txt
diff --git a/Tests/RunCMake/ctest_start/MissingTrackArg-stderr.txt b/Tests/RunCMake/ctest_start/MissingTrackArg-stderr.txt
new file mode 100644
index 000000000..2a72a834e
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/MissingTrackArg-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at .*/Tests/RunCMake/ctest_start/MissingTrackArg/test\.cmake:[0-9]+ \(ctest_start\):
+ ctest_start TRACK argument missing group name$
diff --git a/Tests/RunCMake/ctest_test/TestLoadFail-result.txt b/Tests/RunCMake/ctest_start/MissingTrackArgAppend-result.txt
index b57e2deb7..b57e2deb7 100644
--- a/Tests/RunCMake/ctest_test/TestLoadFail-result.txt
+++ b/Tests/RunCMake/ctest_start/MissingTrackArgAppend-result.txt
diff --git a/Tests/RunCMake/ctest_start/MissingTrackArgAppend-stderr.txt b/Tests/RunCMake/ctest_start/MissingTrackArgAppend-stderr.txt
new file mode 100644
index 000000000..7ff82ab32
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/MissingTrackArgAppend-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at .*/Tests/RunCMake/ctest_start/MissingTrackArgAppend/test\.cmake:[0-9]+ \(ctest_start\):
+ ctest_start TRACK argument missing group name$
diff --git a/Tests/RunCMake/ctest_start/MissingTrackArgQuiet-result.txt b/Tests/RunCMake/ctest_start/MissingTrackArgQuiet-result.txt
new file mode 100644
index 000000000..b57e2deb7
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/MissingTrackArgQuiet-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/ctest_start/MissingTrackArgQuiet-stderr.txt b/Tests/RunCMake/ctest_start/MissingTrackArgQuiet-stderr.txt
new file mode 100644
index 000000000..c23b1bfe7
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/MissingTrackArgQuiet-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at .*/Tests/RunCMake/ctest_start/MissingTrackArgQuiet/test\.cmake:[0-9]+ \(ctest_start\):
+ ctest_start TRACK argument missing group name$
diff --git a/Tests/RunCMake/ctest_start/NoAppendDifferentGroup-stdout.txt b/Tests/RunCMake/ctest_start/NoAppendDifferentGroup-stdout.txt
new file mode 100644
index 000000000..13a3883f0
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/NoAppendDifferentGroup-stdout.txt
@@ -0,0 +1,7 @@
+Run dashboard with model Experimental
+ Source directory: .*/Tests/RunCMake/ctest_start/NoAppendDifferentGroup
+ Build directory: .*/Tests/RunCMake/ctest_start/NoAppendDifferentGroup-build
+ Group: ExperimentalDifferent
+ Site: test-site
+ Build name: test-build-name
+ Use ExperimentalDifferent tag: [0-9-]+
diff --git a/Tests/RunCMake/ctest_start/NoAppendDifferentTrack-stdout.txt b/Tests/RunCMake/ctest_start/NoAppendDifferentTrack-stdout.txt
new file mode 100644
index 000000000..c511e0db8
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/NoAppendDifferentTrack-stdout.txt
@@ -0,0 +1,7 @@
+Run dashboard with model Experimental
+ Source directory: .*/Tests/RunCMake/ctest_start/NoAppendDifferentTrack
+ Build directory: .*/Tests/RunCMake/ctest_start/NoAppendDifferentTrack-build
+ Group: ExperimentalDifferent
+ Site: test-site
+ Build name: test-build-name
+ Use ExperimentalDifferent tag: [0-9-]+
diff --git a/Tests/RunCMake/ctest_start/NoModel-result.txt b/Tests/RunCMake/ctest_start/NoModel-result.txt
new file mode 100644
index 000000000..b57e2deb7
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/NoModel-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/ctest_start/NoModel-stderr.txt b/Tests/RunCMake/ctest_start/NoModel-stderr.txt
new file mode 100644
index 000000000..a516cf806
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/NoModel-stderr.txt
@@ -0,0 +1,3 @@
+^CMake Error at .*/Tests/RunCMake/ctest_start/NoModel/test\.cmake:[0-9]+ \(ctest_start\):
+ ctest_start no test model specified and APPEND not specified. Specify
+ either a test model or the APPEND argument$
diff --git a/Tests/RunCMake/ctest_start/RunCMakeTest.cmake b/Tests/RunCMake/ctest_start/RunCMakeTest.cmake
index d630a7904..da85b39ab 100644
--- a/Tests/RunCMake/ctest_start/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ctest_start/RunCMakeTest.cmake
@@ -7,17 +7,53 @@ function(run_ctest_start CASE_NAME)
run_ctest(${CASE_NAME})
endfunction()
-run_ctest_start(StartQuiet Experimental QUIET)
+function(check_tag_contents EXPECTED)
+ set(_tag_file "${RunCMake_BINARY_DIR}/${CASE_NAME}-build/Testing/TAG")
+ if(EXISTS "${_tag_file}")
+ file(READ "${_tag_file}" _tag_contents)
+ if(NOT _tag_contents MATCHES "${EXPECTED}")
+ set(RunCMake_TEST_FAILED "Testing/TAG file does not match expected value.\nActual TAG file:\n${_tag_contents}\nExpected TAG file:\n${EXPECTED}\n" PARENT_SCOPE)
+ endif()
+ else()
+ set(RunCMake_TEST_FAILED "Testing/TAG file does not exist." PARENT_SCOPE)
+ endif()
+endfunction()
+run_ctest_start(StartQuiet Experimental QUIET)
run_ctest_start(ConfigInSource Experimental)
+run_ctest_start(FunctionScope Experimental QUIET)
+run_ctest_start(WriteModelToTagExperimental Experimental QUIET)
+run_ctest_start(WriteModelToTagContinuous Continuous QUIET)
+run_ctest_start(WriteModelToTagNightly Nightly QUIET)
+run_ctest_start(WriteModelToTagNoMatchingTrack Continuous TRACK SomeWeirdTrackName QUIET)
+run_ctest_start(WriteModelToTagNoMatchingGroup Continuous GROUP SomeWeirdTrackName QUIET)
+run_ctest_start(AppendSameModel Continuous APPEND)
+run_ctest_start(AppendDifferentModel Experimental APPEND)
+run_ctest_start(AppendNoModel APPEND)
+run_ctest_start(AppendDifferentTrack TRACK ExperimentalDifferent APPEND)
+run_ctest_start(AppendDifferentGroup GROUP ExperimentalDifferent APPEND)
+run_ctest_start(NoAppendDifferentTrack Experimental TRACK ExperimentalDifferent)
+run_ctest_start(NoAppendDifferentGroup Experimental GROUP ExperimentalDifferent)
+run_ctest_start(AppendNoMatchingTrack Continuous APPEND)
+run_ctest_start(AppendOldContinuous Continuous APPEND)
+run_ctest_start(AppendOldNoModel APPEND)
+run_ctest_start(NoModel QUIET)
+run_ctest_start(MissingTrackArg Experimental TRACK)
+run_ctest_start(MissingGroupArg Experimental GROUP)
+run_ctest_start(MissingTrackArgAppend Experimental TRACK APPEND)
+run_ctest_start(MissingGroupArgAppend Experimental GROUP APPEND)
+run_ctest_start(MissingTrackArgQuiet Experimental TRACK QUIET)
+run_ctest_start(MissingGroupArgQuiet Experimental GROUP QUIET)
+run_ctest_start(TooManyArgs Experimental
+ ${RunCMake_BINARY_DIR}/TooManyArgs-build
+ ${RunCMake_BINARY_DIR}/TooManyArgs-build
+ ${RunCMake_BINARY_DIR}/TooManyArgs-build)
function(run_ConfigInBuild)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ConfigInBuild-build)
set(RunCMake_TEST_NO_CLEAN 1)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
- configure_file(${RunCMake_SOURCE_DIR}/CTestConfig.cmake.in
- ${RunCMake_BINARY_DIR}/ConfigInBuild-build/CTestConfig.cmake @ONLY)
run_ctest_start(ConfigInBuild Experimental)
endfunction()
run_ConfigInBuild()
diff --git a/Tests/RunCMake/ctest_start/TooManyArgs-result.txt b/Tests/RunCMake/ctest_start/TooManyArgs-result.txt
new file mode 100644
index 000000000..b57e2deb7
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/TooManyArgs-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/ctest_start/TooManyArgs-stderr.txt b/Tests/RunCMake/ctest_start/TooManyArgs-stderr.txt
new file mode 100644
index 000000000..c1d5f2207
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/TooManyArgs-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at .*/Tests/RunCMake/ctest_start/TooManyArgs/test\.cmake:[0-9]+ \(ctest_start\):
+ ctest_start Too many arguments$
diff --git a/Tests/RunCMake/ctest_start/WriteModelToTagContinuous-check.cmake b/Tests/RunCMake/ctest_start/WriteModelToTagContinuous-check.cmake
new file mode 100644
index 000000000..4e67bf555
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/WriteModelToTagContinuous-check.cmake
@@ -0,0 +1 @@
+check_tag_contents("^[0-9-]+\nContinuous\nContinuous\n$")
diff --git a/Tests/RunCMake/ctest_start/WriteModelToTagExperimental-check.cmake b/Tests/RunCMake/ctest_start/WriteModelToTagExperimental-check.cmake
new file mode 100644
index 000000000..b5bf2cfa4
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/WriteModelToTagExperimental-check.cmake
@@ -0,0 +1 @@
+check_tag_contents("^[0-9-]+\nExperimental\nExperimental\n$")
diff --git a/Tests/RunCMake/ctest_start/WriteModelToTagNightly-check.cmake b/Tests/RunCMake/ctest_start/WriteModelToTagNightly-check.cmake
new file mode 100644
index 000000000..35d056654
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/WriteModelToTagNightly-check.cmake
@@ -0,0 +1 @@
+check_tag_contents("^[0-9-]+\nNightly\nNightly\n$")
diff --git a/Tests/RunCMake/ctest_start/WriteModelToTagNoMatchingGroup-check.cmake b/Tests/RunCMake/ctest_start/WriteModelToTagNoMatchingGroup-check.cmake
new file mode 100644
index 000000000..bd2862deb
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/WriteModelToTagNoMatchingGroup-check.cmake
@@ -0,0 +1 @@
+check_tag_contents("^[0-9-]+\nSomeWeirdTrackName\nContinuous\n$")
diff --git a/Tests/RunCMake/ctest_start/WriteModelToTagNoMatchingTrack-check.cmake b/Tests/RunCMake/ctest_start/WriteModelToTagNoMatchingTrack-check.cmake
new file mode 100644
index 000000000..bd2862deb
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/WriteModelToTagNoMatchingTrack-check.cmake
@@ -0,0 +1 @@
+check_tag_contents("^[0-9-]+\nSomeWeirdTrackName\nContinuous\n$")
diff --git a/Tests/RunCMake/ctest_start/test.cmake.in b/Tests/RunCMake/ctest_start/test.cmake.in
index 21e3fad2d..8cd3cff5a 100644
--- a/Tests/RunCMake/ctest_start/test.cmake.in
+++ b/Tests/RunCMake/ctest_start/test.cmake.in
@@ -8,6 +8,26 @@ set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@")
set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@")
set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
+set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
+
+function(setup_tests)
+ ctest_start(${ctest_start_args})
+endfunction()
+
+if("@CASE_NAME@" MATCHES "^(No)?Append")
+ if("@CASE_NAME@" MATCHES "^AppendNoMatchingTrack$")
+ file(WRITE "${CTEST_BINARY_DIRECTORY}/Testing/TAG" "19551112-2204\nSomeWeirdTrackName\n")
+ else()
+ file(WRITE "${CTEST_BINARY_DIRECTORY}/Testing/TAG" "19551112-2204\nContinuousTrack\n")
+ endif()
+ if(NOT "@CASE_NAME@" MATCHES "^AppendOld")
+ file(APPEND "${CTEST_BINARY_DIRECTORY}/Testing/TAG" "Continuous\n")
+ endif()
+endif()
set(ctest_start_args "@CASE_CTEST_START_ARGS@")
-ctest_start(${ctest_start_args})
+if("@CASE_NAME@" STREQUAL "FunctionScope")
+ setup_tests()
+else()
+ ctest_start(${ctest_start_args})
+endif()
diff --git a/Tests/RunCMake/ctest_submit/CDashSubmitHeaders-stderr.txt b/Tests/RunCMake/ctest_submit/CDashSubmitHeaders-stderr.txt
index 4825d7a8e..a8f10b558 100644
--- a/Tests/RunCMake/ctest_submit/CDashSubmitHeaders-stderr.txt
+++ b/Tests/RunCMake/ctest_submit/CDashSubmitHeaders-stderr.txt
@@ -1,3 +1 @@
- *Error when uploading file: .*/Configure.xml
*Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?.*|The requested URL returned error:.*)
- *Problems when submitting via HTTP
diff --git a/Tests/RunCMake/ctest_submit/CDashSubmitVerbose-result.txt b/Tests/RunCMake/ctest_submit/CDashSubmitVerbose-result.txt
new file mode 100644
index 000000000..b57e2deb7
--- /dev/null
+++ b/Tests/RunCMake/ctest_submit/CDashSubmitVerbose-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/ctest_submit/CDashSubmitVerbose-stderr.txt b/Tests/RunCMake/ctest_submit/CDashSubmitVerbose-stderr.txt
new file mode 100644
index 000000000..a8f10b558
--- /dev/null
+++ b/Tests/RunCMake/ctest_submit/CDashSubmitVerbose-stderr.txt
@@ -0,0 +1 @@
+ *Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?.*|The requested URL returned error:.*)
diff --git a/Tests/RunCMake/ctest_submit/CDashSubmitVerbose-stdout.txt b/Tests/RunCMake/ctest_submit/CDashSubmitVerbose-stdout.txt
new file mode 100644
index 000000000..11a4edf1a
--- /dev/null
+++ b/Tests/RunCMake/ctest_submit/CDashSubmitVerbose-stdout.txt
@@ -0,0 +1 @@
+Upload file: .* to http:\/\/-no-site-\?FileName=test-site___test-build-name___.*-Experimental___XML___Configure.xml&build=test-build-name&site=test-site&stamp=.*-Experimental&subproject=mysubproj&MD5=.* Size: .*
diff --git a/Tests/RunCMake/ctest_submit/CTestConfig.cmake.in b/Tests/RunCMake/ctest_submit/CTestConfig.cmake.in
index 378a85a0c..140e4be35 100644
--- a/Tests/RunCMake/ctest_submit/CTestConfig.cmake.in
+++ b/Tests/RunCMake/ctest_submit/CTestConfig.cmake.in
@@ -1,4 +1,3 @@
-set(CTEST_PROJECT_NAME "CTestSubmit@CASE_NAME@")
# Intentionally leave out other upload-related CTestConfig.cmake settings
# so that any ctest_submit calls fail with an error message.
diff --git a/Tests/RunCMake/ctest_submit/FILESNoBuildId-result.txt b/Tests/RunCMake/ctest_submit/FILESNoBuildId-result.txt
new file mode 100644
index 000000000..b57e2deb7
--- /dev/null
+++ b/Tests/RunCMake/ctest_submit/FILESNoBuildId-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/ctest_submit/FILESNoBuildId-stderr.txt b/Tests/RunCMake/ctest_submit/FILESNoBuildId-stderr.txt
new file mode 100644
index 000000000..a8f10b558
--- /dev/null
+++ b/Tests/RunCMake/ctest_submit/FILESNoBuildId-stderr.txt
@@ -0,0 +1 @@
+ *Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?.*|The requested URL returned error:.*)
diff --git a/Tests/RunCMake/ctest_submit/FILESNoBuildId-stdout.txt b/Tests/RunCMake/ctest_submit/FILESNoBuildId-stdout.txt
new file mode 100644
index 000000000..929b2549c
--- /dev/null
+++ b/Tests/RunCMake/ctest_submit/FILESNoBuildId-stdout.txt
@@ -0,0 +1 @@
+Upload file: .* to http:\/\/-no-site-\?FileName=test-site___test-build-name___.*-Experimental___XML___RunCMakeTest.cmake&MD5=.* Size: .*
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-cp-stderr.txt b/Tests/RunCMake/ctest_submit/FailDrop-cp-stderr.txt
deleted file mode 100644
index 00a60ac91..000000000
--- a/Tests/RunCMake/ctest_submit/FailDrop-cp-stderr.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Missing arguments for submit via cp:
-.*
- Problems when submitting via CP
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-cp-stdout.txt b/Tests/RunCMake/ctest_submit/FailDrop-cp-stdout.txt
deleted file mode 100644
index fa6e0042c..000000000
--- a/Tests/RunCMake/ctest_submit/FailDrop-cp-stdout.txt
+++ /dev/null
@@ -1 +0,0 @@
-Submit files \(using cp\)
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-ftp-stderr.txt b/Tests/RunCMake/ctest_submit/FailDrop-ftp-stderr.txt
deleted file mode 100644
index b9d9394fb..000000000
--- a/Tests/RunCMake/ctest_submit/FailDrop-ftp-stderr.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?.*|The requested URL returned error:.*)
- Problems when submitting via FTP
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-ftp-stdout.txt b/Tests/RunCMake/ctest_submit/FailDrop-ftp-stdout.txt
deleted file mode 100644
index 345bb62b1..000000000
--- a/Tests/RunCMake/ctest_submit/FailDrop-ftp-stdout.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Submit files \(using ftp\)
- Using FTP submit method
- Drop site: ftp://
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt b/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt
index c7f35c5ff..c9111b0cf 100644
--- a/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt
+++ b/Tests/RunCMake/ctest_submit/FailDrop-http-stdout.txt
@@ -1,3 +1,2 @@
-Submit files \(using http\)
- Using HTTP submit method
- Drop site:http://
+Submit files
+ SubmitURL: http://-no-site-
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-https-stdout.txt b/Tests/RunCMake/ctest_submit/FailDrop-https-stdout.txt
index 19f82347b..2c67eb9db 100644
--- a/Tests/RunCMake/ctest_submit/FailDrop-https-stdout.txt
+++ b/Tests/RunCMake/ctest_submit/FailDrop-https-stdout.txt
@@ -1,3 +1,2 @@
-Submit files \(using https\)
- Using HTTP submit method
- Drop site:https://
+Submit files
+ SubmitURL: https://-no-site-
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-scp-stderr.txt b/Tests/RunCMake/ctest_submit/FailDrop-scp-stderr.txt
deleted file mode 100644
index ef671499e..000000000
--- a/Tests/RunCMake/ctest_submit/FailDrop-scp-stderr.txt
+++ /dev/null
@@ -1 +0,0 @@
- Problems when submitting via SCP
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-scp-stdout.txt b/Tests/RunCMake/ctest_submit/FailDrop-scp-stdout.txt
deleted file mode 100644
index ec2ce92be..000000000
--- a/Tests/RunCMake/ctest_submit/FailDrop-scp-stdout.txt
+++ /dev/null
@@ -1 +0,0 @@
-Submit files \(using scp\)
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-xmlrpc-stderr.txt b/Tests/RunCMake/ctest_submit/FailDrop-xmlrpc-stderr.txt
deleted file mode 100644
index c0f718e76..000000000
--- a/Tests/RunCMake/ctest_submit/FailDrop-xmlrpc-stderr.txt
+++ /dev/null
@@ -1 +0,0 @@
- (Problems when submitting via XML-RPC|Submission method "xmlrpc" not compiled into CTest!)
diff --git a/Tests/RunCMake/ctest_submit/FailDrop-xmlrpc-stdout.txt b/Tests/RunCMake/ctest_submit/FailDrop-xmlrpc-stdout.txt
deleted file mode 100644
index ed2acb53c..000000000
--- a/Tests/RunCMake/ctest_submit/FailDrop-xmlrpc-stdout.txt
+++ /dev/null
@@ -1 +0,0 @@
-Submit files \(using xmlrpc\)
diff --git a/Tests/RunCMake/ctest_submit/PARTSDone-result.txt b/Tests/RunCMake/ctest_submit/PARTSDone-result.txt
new file mode 100644
index 000000000..b57e2deb7
--- /dev/null
+++ b/Tests/RunCMake/ctest_submit/PARTSDone-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/ctest_submit/PARTSDone-stderr.txt b/Tests/RunCMake/ctest_submit/PARTSDone-stderr.txt
new file mode 100644
index 000000000..0020a0fe3
--- /dev/null
+++ b/Tests/RunCMake/ctest_submit/PARTSDone-stderr.txt
@@ -0,0 +1,3 @@
+ *Error when uploading file: .*/Done.xml
+ *Error message was: ([Cc]ould *n.t resolve host:? '?-no-site-'?.*|The requested URL returned error:.*)
+ *Problems when submitting via HTTP
diff --git a/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake b/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake
index b5d90d28c..78856b410 100644
--- a/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ctest_submit/RunCMakeTest.cmake
@@ -5,28 +5,36 @@ set(CASE_DROP_METHOD "http")
set(CASE_DROP_SITE "-no-site-")
set(CASE_CTEST_SUBMIT_ARGS "")
-#-----------------------------------------------------------------------------
-# Test bad argument combinations.
function(run_ctest_submit CASE_NAME)
set(CASE_CTEST_SUBMIT_ARGS "${ARGN}")
run_ctest(${CASE_NAME})
endfunction()
+function(run_ctest_submit_debug CASE_NAME)
+ set(CASE_CTEST_SUBMIT_ARGS "${ARGN}")
+ run_ctest(${CASE_NAME} "--debug")
+endfunction()
+
+#-----------------------------------------------------------------------------
+# Test bad argument combinations.
run_ctest_submit(BadArg bad-arg)
run_ctest_submit(BadPARTS PARTS bad-part)
run_ctest_submit(BadFILES FILES bad-file)
run_ctest_submit(RepeatRETURN_VALUE RETURN_VALUE res RETURN_VALUE res)
run_ctest_submit(PARTSCDashUpload PARTS Configure CDASH_UPLOAD)
run_ctest_submit(PARTSCDashUploadType PARTS Configure CDASH_UPLOAD_TYPE)
+run_ctest_submit(PARTSDone PARTS Done)
run_ctest_submit(CDashUploadPARTS CDASH_UPLOAD bad-upload PARTS)
run_ctest_submit(CDashUploadFILES CDASH_UPLOAD bad-upload FILES)
run_ctest_submit(CDashUploadNone CDASH_UPLOAD)
run_ctest_submit(CDashUploadMissingFile CDASH_UPLOAD bad-upload)
run_ctest_submit(CDashUploadRetry CDASH_UPLOAD ${CMAKE_CURRENT_LIST_FILE} CDASH_UPLOAD_TYPE foo RETRY_COUNT 2 RETRY_DELAY 1 INTERNAL_TEST_CHECKSUM)
run_ctest_submit(CDashSubmitQuiet QUIET)
-run_ctest_submit(CDashSubmitHeaders HTTPHEADER "Authorization: Bearer asdf")
-run_ctest_submit(CDashUploadHeaders CDASH_UPLOAD ${CMAKE_CURRENT_LIST_FILE} CDASH_UPLOAD_TYPE foo HTTPHEADER "Authorization: Bearer asdf")
+run_ctest_submit_debug(CDashSubmitVerbose BUILD_ID my_build_id)
+run_ctest_submit_debug(FILESNoBuildId FILES ${CMAKE_CURRENT_LIST_FILE})
+run_ctest_submit_debug(CDashSubmitHeaders HTTPHEADER "Authorization: Bearer asdf")
+run_ctest_submit_debug(CDashUploadHeaders CDASH_UPLOAD ${CMAKE_CURRENT_LIST_FILE} CDASH_UPLOAD_TYPE foo HTTPHEADER "Authorization: Bearer asdf")
function(run_ctest_CDashUploadFTP)
set(CASE_DROP_METHOD ftp)
@@ -41,9 +49,5 @@ function(run_ctest_submit_FailDrop CASE_DROP_METHOD)
run_ctest(FailDrop-${CASE_DROP_METHOD})
endfunction()
-run_ctest_submit_FailDrop(cp)
-run_ctest_submit_FailDrop(ftp)
run_ctest_submit_FailDrop(http)
run_ctest_submit_FailDrop(https)
-run_ctest_submit_FailDrop(scp)
-run_ctest_submit_FailDrop(xmlrpc)
diff --git a/Tests/RunCMake/ctest_submit/test.cmake.in b/Tests/RunCMake/ctest_submit/test.cmake.in
index ba826f1b3..35cd16a98 100644
--- a/Tests/RunCMake/ctest_submit/test.cmake.in
+++ b/Tests/RunCMake/ctest_submit/test.cmake.in
@@ -9,6 +9,7 @@ set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@")
set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
+set_property(GLOBAL PROPERTY SubProject "mysubproj")
ctest_start(Experimental)
ctest_configure()
diff --git a/Tests/RunCMake/ctest_test/CTestConfig.cmake.in b/Tests/RunCMake/ctest_test/CTestConfig.cmake.in
deleted file mode 100644
index 90044198e..000000000
--- a/Tests/RunCMake/ctest_test/CTestConfig.cmake.in
+++ /dev/null
@@ -1 +0,0 @@
-set(CTEST_PROJECT_NAME "CTestTest@CASE_NAME@")
diff --git a/Tests/RunCMake/ctest_test/CTestTestLoadFail-stderr.txt b/Tests/RunCMake/ctest_test/CTestTestLoadFail-stderr.txt
deleted file mode 100644
index eafba1c69..000000000
--- a/Tests/RunCMake/ctest_test/CTestTestLoadFail-stderr.txt
+++ /dev/null
@@ -1 +0,0 @@
-No tests were found!!!
diff --git a/Tests/RunCMake/ctest_test/CTestTestLoadFail-stdout.txt b/Tests/RunCMake/ctest_test/CTestTestLoadFail-stdout.txt
deleted file mode 100644
index e203c10c1..000000000
--- a/Tests/RunCMake/ctest_test/CTestTestLoadFail-stdout.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Test project .*/Tests/RunCMake/ctest_test/CTestTestLoadFail-build
-\*\*\*\*\* WAITING, System Load: 5, Max Allowed Load: 4, Smallest test RunCMakeVersion requires 1\*\*\*\*\*$
diff --git a/Tests/RunCMake/ctest_test/CTestTestLoadWait-stdout.txt b/Tests/RunCMake/ctest_test/CTestTestLoadWait-stdout.txt
new file mode 100644
index 000000000..2af3838ed
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/CTestTestLoadWait-stdout.txt
@@ -0,0 +1,8 @@
+Test project .*/Tests/RunCMake/ctest_test/CTestTestLoadWait-build
+\*\*\*\*\* WAITING, System Load: 5, Max Allowed Load: 4, Smallest test RunCMakeVersion requires 1\*\*\*\*\*
+ Start 1: RunCMakeVersion
+1/1 Test #1: RunCMakeVersion .................. Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 1
++
+Total Test time \(real\) = +[0-9.]+ sec$
diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
index 1b3172676..6877e6a87 100644
--- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
@@ -21,8 +21,8 @@ set(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING} 5)
run_ctest_test(TestLoadPass TEST_LOAD 6)
# Verify that new tests are not started when the load average exceeds
-# our threshold.
-run_ctest_test(TestLoadFail TEST_LOAD 2)
+# our threshold and that they then run once the load average drops.
+run_ctest_test(TestLoadWait TEST_LOAD 2)
# Verify that when an invalid "TEST_LOAD" value is given, a warning
# message is displayed and the value is ignored.
@@ -34,9 +34,9 @@ set(CASE_CTEST_TEST_LOAD 7)
run_ctest_test(CTestTestLoadPass)
# Verify that new tests are not started when the load average exceeds
-# our threshold.
+# our threshold and that they then run once the load average drops.
set(CASE_CTEST_TEST_LOAD 4)
-run_ctest_test(CTestTestLoadFail)
+run_ctest_test(CTestTestLoadWait)
# Verify that when an invalid "CTEST_TEST_LOAD" value is given,
# a warning message is displayed and the value is ignored.
diff --git a/Tests/RunCMake/ctest_test/TestLoadFail-stderr.txt b/Tests/RunCMake/ctest_test/TestLoadFail-stderr.txt
deleted file mode 100644
index eafba1c69..000000000
--- a/Tests/RunCMake/ctest_test/TestLoadFail-stderr.txt
+++ /dev/null
@@ -1 +0,0 @@
-No tests were found!!!
diff --git a/Tests/RunCMake/ctest_test/TestLoadFail-stdout.txt b/Tests/RunCMake/ctest_test/TestLoadFail-stdout.txt
deleted file mode 100644
index 4d7ce48a4..000000000
--- a/Tests/RunCMake/ctest_test/TestLoadFail-stdout.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Test project .*/Tests/RunCMake/ctest_test/TestLoadFail-build
-\*\*\*\*\* WAITING, System Load: 5, Max Allowed Load: 2, Smallest test RunCMakeVersion requires 1\*\*\*\*\*$
diff --git a/Tests/RunCMake/ctest_test/TestLoadWait-stdout.txt b/Tests/RunCMake/ctest_test/TestLoadWait-stdout.txt
new file mode 100644
index 000000000..07f4ed361
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestLoadWait-stdout.txt
@@ -0,0 +1,8 @@
+Test project .*/Tests/RunCMake/ctest_test/TestLoadWait-build
+\*\*\*\*\* WAITING, System Load: 5, Max Allowed Load: 2, Smallest test RunCMakeVersion requires 1\*\*\*\*\*
+ Start 1: RunCMakeVersion
+1/1 Test #1: RunCMakeVersion .................. Passed +[0-9.]+ sec
++
+100% tests passed, 0 tests failed out of 1
++
+Total Test time \(real\) = +[0-9.]+ sec$
diff --git a/Tests/RunCMake/ctest_update/CMakeLists.txt.in b/Tests/RunCMake/ctest_update/CMakeLists.txt.in
new file mode 100644
index 000000000..ecf0e54ea
--- /dev/null
+++ b/Tests/RunCMake/ctest_update/CMakeLists.txt.in
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 3.1)
+project(CTestTest@CASE_NAME@ NONE)
+include(CTest)
+@CASE_CMAKELISTS_SUFFIX_CODE@
diff --git a/Tests/RunCMake/ctest_update/RunCMakeTest.cmake b/Tests/RunCMake/ctest_update/RunCMakeTest.cmake
new file mode 100644
index 000000000..f8d7665ab
--- /dev/null
+++ b/Tests/RunCMake/ctest_update/RunCMakeTest.cmake
@@ -0,0 +1,25 @@
+include(RunCTest)
+set(CASE_CTEST_UPDATE_ARGS "")
+function(run_ctest_update CASE_NAME)
+ set(CASE_CTEST_UPDATE_ARGS "${ARGN}")
+ run_ctest(${CASE_NAME})
+endfunction()
+
+run_ctest_update(UpdateQuiet QUIET)
+
+function(run_UpdateChangeId)
+ set(CASE_TEST_PREFIX_CODE [[
+ set(CTEST_CHANGE_ID "<>1")
+ ]])
+
+ run_ctest(UpdateChangeId)
+endfunction()
+run_UpdateChangeId()
+
+function(run_UpdateVersionOverride)
+ set(CASE_TEST_PREFIX_CODE [[
+ set(CTEST_UPDATE_VERSION_OVERRIDE "qwertyuiop")
+ ]])
+ run_ctest(UpdateVersionOverride)
+endfunction()
+run_UpdateVersionOverride()
diff --git a/Tests/RunCMake/ctest_update/UpdateActualVersion-check.cmake b/Tests/RunCMake/ctest_update/UpdateActualVersion-check.cmake
new file mode 100644
index 000000000..12bd5a00d
--- /dev/null
+++ b/Tests/RunCMake/ctest_update/UpdateActualVersion-check.cmake
@@ -0,0 +1,12 @@
+file(GLOB update_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Update.xml")
+if(update_xml_file)
+ file(READ "${update_xml_file}" update_xml LIMIT 4096)
+ if(NOT update_xml MATCHES "qwertyuiop")
+ string(REPLACE "\n" "\n " update_xml " ${update_xml}")
+ set(RunCMake_TEST_FAILED
+ "Did not find 'qwertyuiop' in Update.xml:\n${update_xml}"
+ )
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "Update.xml not found")
+endif()
diff --git a/Tests/RunCMake/ctest_update/UpdateChangeId-check.cmake b/Tests/RunCMake/ctest_update/UpdateChangeId-check.cmake
new file mode 100644
index 000000000..382fbec6a
--- /dev/null
+++ b/Tests/RunCMake/ctest_update/UpdateChangeId-check.cmake
@@ -0,0 +1,12 @@
+file(GLOB update_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Update.xml")
+if(update_xml_file)
+ file(READ "${update_xml_file}" update_xml LIMIT 4096)
+ if(NOT update_xml MATCHES [[ChangeId>&lt;&gt;1]])
+ string(REPLACE "\n" "\n " update_xml " ${update_xml}")
+ set(RunCMake_TEST_FAILED
+ "Update.xml does not have expected ChangeId:\n${update_xml}"
+ )
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "Update.xml not found")
+endif()
diff --git a/Tests/RunCMake/ctest_update/test.cmake.in b/Tests/RunCMake/ctest_update/test.cmake.in
new file mode 100644
index 000000000..25b842324
--- /dev/null
+++ b/Tests/RunCMake/ctest_update/test.cmake.in
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.1)
+@CASE_TEST_PREFIX_CODE@
+
+set(CTEST_SITE "test-site")
+set(CTEST_BUILD_NAME "test-build-name")
+set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@")
+set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build")
+set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@")
+set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
+
+# FIXME: update test to do someting meaningful with this.
+set(CTEST_UPDATE_COMMAND "not-actually-used")
+
+set(ctest_test_args "@CASE_CTEST_UPDATE_ARGS@")
+ctest_start(Experimental)
+ctest_update(${ctest_update_args})
diff --git a/Tests/RunCMake/ctest_upload/CTestConfig.cmake.in b/Tests/RunCMake/ctest_upload/CTestConfig.cmake.in
deleted file mode 100644
index 52665a8b8..000000000
--- a/Tests/RunCMake/ctest_upload/CTestConfig.cmake.in
+++ /dev/null
@@ -1 +0,0 @@
-set(CTEST_PROJECT_NAME "CTestUpload@CASE_NAME@")
diff --git a/Tests/RunCMake/execute_process/EchoCommand-result.txt b/Tests/RunCMake/execute_process/EchoCommand-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/execute_process/EchoCommand-stderr.txt b/Tests/RunCMake/execute_process/EchoCommand-stderr.txt
new file mode 100644
index 000000000..f10ece8c4
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand-stderr.txt
@@ -0,0 +1,5 @@
+.*cmake.*-E' 'echo' '-- 2 COMMAND_ECHO STDERR'
+.*cmake.*-E' 'echo' '-- 4 COMMAND_ECHO STDERR'
+.*cmake.*-E' 'echo' '-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR'
+CMake Error at .*EchoCommand.cmake:.* \(execute_process\):
+ CMAKE_EXECUTE_PROCESS_COMMAND_ECHO set to 'BAD' expected STDERR|STDOUT|NONE$
diff --git a/Tests/RunCMake/execute_process/EchoCommand-stdout.txt b/Tests/RunCMake/execute_process/EchoCommand-stdout.txt
new file mode 100644
index 000000000..0954b3b3d
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand-stdout.txt
@@ -0,0 +1,12 @@
+.*cmake.*-E' 'echo' '-- 1 COMMAND_ECHO STDOUT'
+-- 1 COMMAND_ECHO STDOUT
+-- 2 COMMAND_ECHO STDERR
+.*cmake.* '-E' 'echo' '-- 3 COMMAND_ECHO STDOUT'
+-- 3 COMMAND_ECHO STDOUT
+-- 4 COMMAND_ECHO STDERR
+.*cmake.* '-E' 'echo' '-- 5 COMMAND_ECHO STDOUT'
+-- 5 COMMAND_ECHO STDOUT
+-- 6 COMMAND_ECHO NONE
+.*cmake.* '-E' 'echo' '-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT'
+-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT
+-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR$
diff --git a/Tests/RunCMake/execute_process/EchoCommand.cmake b/Tests/RunCMake/execute_process/EchoCommand.cmake
new file mode 100644
index 000000000..9c7d13db6
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand.cmake
@@ -0,0 +1,41 @@
+if(CHECK_ERROR_OUTPUT_LOCATION)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 1 COMMAND_ECHO " COMMAND_ECHO )
+endif()
+# test COMMAND_ECHO STDOUT
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 1 COMMAND_ECHO STDOUT" COMMAND_ECHO STDOUT )
+# test COMMAND_ECHO STDERR
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 2 COMMAND_ECHO STDERR" COMMAND_ECHO STDERR )
+# test CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT
+set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDOUT)
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 3 COMMAND_ECHO STDOUT" )
+# test CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDERR
+set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO STDERR)
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 4 COMMAND_ECHO STDERR" )
+# make sure local will override global settings
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 5 COMMAND_ECHO STDOUT" COMMAND_ECHO STDOUT )
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 6 COMMAND_ECHO NONE" COMMAND_ECHO NONE)
+# test both and make sure override works
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT" COMMAND_ECHO STDERR
+ COMMAND_ECHO STDOUT)
+execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR" COMMAND_ECHO STDOUT
+ COMMAND_ECHO STDERR)
+
+# check for bad arguments to global and local
+if(CHECK_GLOBAL)
+ # make sure a non STDERR or STDOUT value is an error
+ set(CMAKE_EXECUTE_PROCESS_COMMAND_ECHO BAD)
+ execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 9 - 1 CMAKE_EXECUTE_PROCESS_COMMAND_ECHO BAD" )
+else()
+ execute_process(COMMAND ${CMAKE_COMMAND} -E echo
+ "-- 9 - 2 COMMAND_ECHO BAD" COMMAND_ECHO BAD)
+endif()
diff --git a/Tests/RunCMake/execute_process/EchoCommand2-result.txt b/Tests/RunCMake/execute_process/EchoCommand2-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/execute_process/EchoCommand2-stderr.txt b/Tests/RunCMake/execute_process/EchoCommand2-stderr.txt
new file mode 100644
index 000000000..4ae01c4fb
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand2-stderr.txt
@@ -0,0 +1,5 @@
+.*cmake.*-E' 'echo' '-- 2 COMMAND_ECHO STDERR'
+.*cmake.*-E' 'echo' '-- 4 COMMAND_ECHO STDERR'
+.*cmake.*-E' 'echo' '-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR'
+CMake Error at .*EchoCommand.cmake:.* \(execute_process\):
+ called with 'BAD' expected STDERR|STDOUT|NONE for COMMAND_ECHO.$
diff --git a/Tests/RunCMake/execute_process/EchoCommand2-stdout.txt b/Tests/RunCMake/execute_process/EchoCommand2-stdout.txt
new file mode 100644
index 000000000..0954b3b3d
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand2-stdout.txt
@@ -0,0 +1,12 @@
+.*cmake.*-E' 'echo' '-- 1 COMMAND_ECHO STDOUT'
+-- 1 COMMAND_ECHO STDOUT
+-- 2 COMMAND_ECHO STDERR
+.*cmake.* '-E' 'echo' '-- 3 COMMAND_ECHO STDOUT'
+-- 3 COMMAND_ECHO STDOUT
+-- 4 COMMAND_ECHO STDERR
+.*cmake.* '-E' 'echo' '-- 5 COMMAND_ECHO STDOUT'
+-- 5 COMMAND_ECHO STDOUT
+-- 6 COMMAND_ECHO NONE
+.*cmake.* '-E' 'echo' '-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT'
+-- 7 COMMAND_ECHO STDERR COMMAND_ECHO STDOUT
+-- 8 COMMAND_ECHO STDOUT COMMAND_ECHO STDERR$
diff --git a/Tests/RunCMake/execute_process/EchoCommand3-result.txt b/Tests/RunCMake/execute_process/EchoCommand3-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand3-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/execute_process/EchoCommand3-stderr.txt b/Tests/RunCMake/execute_process/EchoCommand3-stderr.txt
new file mode 100644
index 000000000..e27f1e6d2
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EchoCommand3-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error at .*EchoCommand.cmake:.*\(execute_process\):
+ execute_process called with no value for COMMAND_ECHO.
diff --git a/Tests/RunCMake/execute_process/EncodingUTF-8-stderr.txt b/Tests/RunCMake/execute_process/EncodingUTF-8-stderr.txt
new file mode 100644
index 000000000..0ac68de83
--- /dev/null
+++ b/Tests/RunCMake/execute_process/EncodingUTF-8-stderr.txt
@@ -0,0 +1 @@
+यूनिकोड είναι very здорово!
diff --git a/Tests/RunCMake/execute_process/ExitValues-stdout.txt b/Tests/RunCMake/execute_process/ExitValues-stdout.txt
new file mode 100644
index 000000000..3bcaf46cc
--- /dev/null
+++ b/Tests/RunCMake/execute_process/ExitValues-stdout.txt
@@ -0,0 +1,14 @@
+^-- 1 - 1 RESULT_VARIABLE: 0
+-- 1 - 2 RESULT_VARIABLE: [^0].*
+-- 2 - 1 RESULT_VARIABLE: 0
+-- 2 - 1 RESULTS_VARIABLE: 0
+-- 2 - 2 RESULT_VARIABLE: [^0].*
+-- 2 - 2 RESULTS_VARIABLE: [^0].*
+-- 3 - 1 RESULTS_VARIABLE: 0
+-- 3 - 2 RESULTS_VARIABLE: [^0].*
+-- 4 - 1 RESULT_VARIABLE: 0
+-- 4 - 1 RESULTS_VARIABLE: [^0].*;0;[^0].*;0;[^0].*;0
+-- 4 - 1 RESULTS_VARIABLE_LENGTH: 6
+-- 5 - 1 RESULT_VARIABLE: [^0].*
+-- 5 - 1 RESULTS_VARIABLE: 0;0;[^0].*
+-- 5 - 1 RESULTS_VARIABLE_LENGTH: 3$
diff --git a/Tests/RunCMake/execute_process/ExitValues.cmake b/Tests/RunCMake/execute_process/ExitValues.cmake
new file mode 100644
index 000000000..d80a57b2d
--- /dev/null
+++ b/Tests/RunCMake/execute_process/ExitValues.cmake
@@ -0,0 +1,120 @@
+#1st TEST RESULT_VARIABLE ONLY
+execute_process(COMMAND ${EXIT_CODE_EXE} "zero_exit"
+ RESULT_VARIABLE r0
+ )
+message(STATUS " 1 - 1 RESULT_VARIABLE: ${r0}")
+if(NOT r0 EQUAL 0)
+ message(FATAL_ERROR "zero exit code expected")
+endif()
+execute_process(COMMAND ${EXIT_CODE_EXE} "non_zero_exit"
+ RESULT_VARIABLE r01
+ ERROR_QUIET
+ )
+message(STATUS " 1 - 2 RESULT_VARIABLE: ${r01}")
+if(r01 EQUAL 0)
+ message(FATAL_ERROR "non-zero exit code expected")
+endif()
+#2nd TEST RESULT_VARIABLE and RESULTS_VARIABLE
+execute_process(COMMAND ${EXIT_CODE_EXE} "zero_exit"
+ RESULT_VARIABLE r1
+ RESULTS_VARIABLE r1s
+ )
+message(STATUS " 2 - 1 RESULT_VARIABLE: ${r1}")
+message(STATUS " 2 - 1 RESULTS_VARIABLE: ${r1s}")
+if(NOT r1 EQUAL 0 OR NOT r1s EQUAL 0)
+ message(FATAL_ERROR "zero exit code expected")
+endif()
+execute_process(COMMAND ${EXIT_CODE_EXE} "non_zero_exit"
+ RESULT_VARIABLE r11
+ RESULTS_VARIABLE r11s
+ ERROR_QUIET
+ )
+message(STATUS " 2 - 2 RESULT_VARIABLE: ${r11}")
+message(STATUS " 2 - 2 RESULTS_VARIABLE: ${r11s}")
+if(r11 EQUAL 0 OR r11s EQUAL 0)
+ message(FATAL_ERROR "non-zero exit code expected")
+endif()
+#3rd TEST RESULTS_VARIABLE
+execute_process(COMMAND ${EXIT_CODE_EXE} "zero_exit"
+ RESULTS_VARIABLE r2s
+ )
+message(STATUS " 3 - 1 RESULTS_VARIABLE: ${r2s}")
+if(NOT r2s EQUAL 0)
+ message(FATAL_ERROR "zero exit code expected")
+endif()
+execute_process(COMMAND ${EXIT_CODE_EXE} "non_zero_exit"
+ RESULTS_VARIABLE r21s
+ ERROR_QUIET
+ )
+message(STATUS " 3 - 2 RESULTS_VARIABLE: ${r21s}")
+if(r21s EQUAL 0)
+ message(FATAL_ERROR "non-zero exit code expected")
+endif()
+#4th TEST RESULT_VARIABLE and RESULTS_VARIABLE WITH MULTICOMMAND
+execute_process(COMMAND ${EXIT_CODE_EXE} "non_zero_exit"
+ COMMAND ${EXIT_CODE_EXE} "zero_exit"
+ COMMAND ${EXIT_CODE_EXE} "non_zero_exit"
+ COMMAND ${EXIT_CODE_EXE} "zero_exit"
+ COMMAND ${EXIT_CODE_EXE} "non_zero_exit"
+ COMMAND ${EXIT_CODE_EXE} "zero_exit"
+ RESULT_VARIABLE r31
+ RESULTS_VARIABLE r31s
+ OUTPUT_QUIET
+ ERROR_QUIET
+ )
+message(STATUS " 4 - 1 RESULT_VARIABLE: ${r31}")
+message(STATUS " 4 - 1 RESULTS_VARIABLE: ${r31s}")
+if(NOT r31 EQUAL 0)
+ message(FATAL_ERROR "zero exit code expected for last command")
+endif()
+list(LENGTH r31s r31sLen)
+message(STATUS " 4 - 1 RESULTS_VARIABLE_LENGTH: ${r31sLen}")
+if(NOT r31sLen EQUAL 6)
+ message(FATAL_ERROR "length of RESULTS_VARIABLE is not as expected")
+else()
+ foreach(loop_var RANGE 5)
+ list(GET r31s ${loop_var} rsLocal)
+ math(EXPR isOdd "${loop_var} % 2")
+ if(isOdd)
+ if(NOT rsLocal EQUAL 0)
+ message(FATAL_ERROR "zero exit code expected")
+ endif()
+ else()
+ if(rsLocal EQUAL 0)
+ message(FATAL_ERROR "non-zero exit code expected")
+ endif()
+ endif()
+ endforeach()
+endif()
+#5th TEST RESULT_VARIABLE and RESULTS_VARIABLE WITH MULTICOMMAND
+execute_process(COMMAND ${EXIT_CODE_EXE} "zero_exit"
+ COMMAND ${EXIT_CODE_EXE} "zero_exit"
+ COMMAND ${EXIT_CODE_EXE} "non_zero_exit"
+ RESULT_VARIABLE r41
+ RESULTS_VARIABLE r41s
+ OUTPUT_QUIET
+ ERROR_QUIET
+ )
+message(STATUS " 5 - 1 RESULT_VARIABLE: ${r41}")
+message(STATUS " 5 - 1 RESULTS_VARIABLE: ${r41s}")
+if(r41 EQUAL 0)
+ message(FATAL_ERROR "non-zero exit code expected for last command")
+endif()
+list(LENGTH r41s r41sLen)
+message(STATUS " 5 - 1 RESULTS_VARIABLE_LENGTH: ${r41sLen}")
+if(NOT r31sLen EQUAL 6)
+ message(FATAL_ERROR "length of RESULTS_VARIABLE is not as expected")
+else()
+ list(GET r41s 0 rsLocal)
+ if(NOT rsLocal EQUAL 0)
+ message(FATAL_ERROR "zero exit code expected")
+ endif()
+ list(GET r41s 1 rsLocal)
+ if(NOT rsLocal EQUAL 0)
+ message(FATAL_ERROR "zero exit code expected")
+ endif()
+ list(GET r41s 2 rsLocal)
+ if(rsLocal EQUAL 0)
+ message(FATAL_ERROR "non-zero exit code expected")
+ endif()
+endif()
diff --git a/Tests/RunCMake/execute_process/RunCMakeTest.cmake b/Tests/RunCMake/execute_process/RunCMakeTest.cmake
index 62e18c601..b203aabfd 100644
--- a/Tests/RunCMake/execute_process/RunCMakeTest.cmake
+++ b/Tests/RunCMake/execute_process/RunCMakeTest.cmake
@@ -10,4 +10,17 @@ run_cmake_command(MergeOutputVars ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/Mer
run_cmake(EncodingMissing)
if(TEST_ENCODING_EXE)
run_cmake_command(EncodingUTF8 ${CMAKE_COMMAND} -DTEST_ENCODING=UTF8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE} -P ${RunCMake_SOURCE_DIR}/Encoding.cmake)
+ run_cmake_command(EncodingUTF-8 ${CMAKE_COMMAND} -DTEST_ENCODING=UTF-8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE} -P ${RunCMake_SOURCE_DIR}/Encoding.cmake)
endif()
+
+if(EXIT_CODE_EXE)
+ run_cmake_command(ExitValues ${CMAKE_COMMAND} -DEXIT_CODE_EXE=${EXIT_CODE_EXE} -P ${RunCMake_SOURCE_DIR}/ExitValues.cmake)
+endif()
+
+run_cmake_command(EchoCommand ${CMAKE_COMMAND} -DCHECK_GLOBAL=TRUE
+ -P ${RunCMake_SOURCE_DIR}/EchoCommand.cmake)
+run_cmake_command(EchoCommand2 ${CMAKE_COMMAND} -P
+ ${RunCMake_SOURCE_DIR}/EchoCommand.cmake)
+run_cmake_command(EchoCommand3 ${CMAKE_COMMAND}
+ -DCHECK_ERROR_OUTPUT_LOCATION=TRUE -P
+ ${RunCMake_SOURCE_DIR}/EchoCommand.cmake)
diff --git a/Tests/RunCMake/exit_code.c b/Tests/RunCMake/exit_code.c
new file mode 100644
index 000000000..3eba01941
--- /dev/null
+++ b/Tests/RunCMake/exit_code.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+// Usage:
+//
+// /path/to/program arg1 [arg2 [...]]
+//
+// Return EXIT_SUCCESS if 'zero_exit'
+// string was found in <arg1>.
+// Return EXIT_FAILURE if 'non_zero_exit'
+// string was found in <arg1>.
+
+int main(int argc, const char* argv[])
+{
+ const char* substring_failure = "non_zero_exit";
+ const char* substring_success = "zero_exit";
+ const char* str = argv[1];
+ if (argc < 2) {
+ return EXIT_FAILURE;
+ }
+ if (strcmp(str, substring_success) == 0) {
+ return EXIT_SUCCESS;
+ } else if (strcmp(str, substring_failure) == 0) {
+ return EXIT_FAILURE;
+ }
+ fprintf(stderr, "Failed to find string '%s' in '%s'\n", substring_success,
+ str);
+ return EXIT_FAILURE;
+}
diff --git a/Tests/RunCMake/export/AppendExport-stderr.txt b/Tests/RunCMake/export/AppendExport-stderr.txt
index d71620e5f..d12124c9a 100644
--- a/Tests/RunCMake/export/AppendExport-stderr.txt
+++ b/Tests/RunCMake/export/AppendExport-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at AppendExport.cmake:[0-9]+ \(export\):
- export EXPORT signature does not recognise the APPEND option.
+ export Unknown argument: "APPEND".
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/export/DependOnDoubleExport-result.txt b/Tests/RunCMake/export/DependOnDoubleExport-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/export/DependOnDoubleExport-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/export/DependOnDoubleExport-stderr.txt b/Tests/RunCMake/export/DependOnDoubleExport-stderr.txt
new file mode 100644
index 000000000..b78c7e461
--- /dev/null
+++ b/Tests/RunCMake/export/DependOnDoubleExport-stderr.txt
@@ -0,0 +1,13 @@
+CMake Error in CMakeLists.txt:
+ export called with target "exported" which requires target "doubleexported"
+ that is not in this export set, but in multiple other export sets:
+ .*/Tests/RunCMake/export/DependOnDoubleExport-build/exportset.cmake,
+ .*/Tests/RunCMake/export/DependOnDoubleExport-build/manual.cmake.
+
+
+ An exported target cannot depend upon another target which is exported
+ multiple times. Consider consolidating the exports of the "doubleexported"
+ target to a single export.
+
+
+CMake Generate step failed. Build files cannot be regenerated correctly.
diff --git a/Tests/RunCMake/export/DependOnDoubleExport.cmake b/Tests/RunCMake/export/DependOnDoubleExport.cmake
new file mode 100644
index 000000000..8d108d7ef
--- /dev/null
+++ b/Tests/RunCMake/export/DependOnDoubleExport.cmake
@@ -0,0 +1,7 @@
+add_library(doubleexported INTERFACE)
+install(TARGETS doubleexported EXPORT exportset)
+export(TARGETS doubleexported FILE "${CMAKE_CURRENT_BINARY_DIR}/manual.cmake")
+export(EXPORT exportset FILE "${CMAKE_CURRENT_BINARY_DIR}/exportset.cmake")
+add_library(exported INTERFACE)
+target_link_libraries(exported INTERFACE doubleexported)
+export(TARGETS exported FILE "${CMAKE_CURRENT_BINARY_DIR}/exports.cmake")
diff --git a/Tests/RunCMake/export/DependOnNotExport-result.txt b/Tests/RunCMake/export/DependOnNotExport-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/export/DependOnNotExport-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/export/DependOnNotExport-stderr.txt b/Tests/RunCMake/export/DependOnNotExport-stderr.txt
new file mode 100644
index 000000000..80f57584f
--- /dev/null
+++ b/Tests/RunCMake/export/DependOnNotExport-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error in CMakeLists.txt:
+ export called with target "exported" which requires target "notexported"
+ that is not in any export set.
+
+
+CMake Generate step failed. Build files cannot be regenerated correctly.
diff --git a/Tests/RunCMake/export/DependOnNotExport.cmake b/Tests/RunCMake/export/DependOnNotExport.cmake
new file mode 100644
index 000000000..06c1ad951
--- /dev/null
+++ b/Tests/RunCMake/export/DependOnNotExport.cmake
@@ -0,0 +1,4 @@
+add_library(notexported INTERFACE)
+add_library(exported INTERFACE)
+target_link_libraries(exported INTERFACE notexported)
+export(TARGETS exported FILE "${CMAKE_CURRENT_BINARY_DIR}/exports.cmake")
diff --git a/Tests/RunCMake/export/Empty.cmake b/Tests/RunCMake/export/Empty.cmake
new file mode 100644
index 000000000..2198ddf75
--- /dev/null
+++ b/Tests/RunCMake/export/Empty.cmake
@@ -0,0 +1 @@
+export(TARGETS FILE targets.cmake)
diff --git a/Tests/RunCMake/export/ExportPropertiesUndefined.cmake b/Tests/RunCMake/export/ExportPropertiesUndefined.cmake
new file mode 100644
index 000000000..aa529f29a
--- /dev/null
+++ b/Tests/RunCMake/export/ExportPropertiesUndefined.cmake
@@ -0,0 +1,11 @@
+enable_language(CXX)
+add_library(foo empty.cpp)
+set_target_properties(foo PROPERTIES
+ EXPORT_PROPERTIES "NotDefinedProp"
+)
+export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake")
+install(TARGETS foo EXPORT fooExport
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
diff --git a/Tests/RunCMake/export/ForbiddenToExportImportedProperties-result.txt b/Tests/RunCMake/export/ForbiddenToExportImportedProperties-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/export/ForbiddenToExportImportedProperties-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/export/ForbiddenToExportImportedProperties-stderr.txt b/Tests/RunCMake/export/ForbiddenToExportImportedProperties-stderr.txt
new file mode 100644
index 000000000..ab0394316
--- /dev/null
+++ b/Tests/RunCMake/export/ForbiddenToExportImportedProperties-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error in CMakeLists.txt:
+ Target \"foo\" contains property \"IMPORTED_FOOBAR\" in EXPORT_PROPERTIES but
+ IMPORTED_\* and INTERFACE_\* properties are reserved.
diff --git a/Tests/RunCMake/export/ForbiddenToExportImportedProperties.cmake b/Tests/RunCMake/export/ForbiddenToExportImportedProperties.cmake
new file mode 100644
index 000000000..9c8653d8d
--- /dev/null
+++ b/Tests/RunCMake/export/ForbiddenToExportImportedProperties.cmake
@@ -0,0 +1,12 @@
+enable_language(CXX)
+add_library(foo empty.cpp)
+set_target_properties(foo PROPERTIES
+ IMPORTED_FOOBAR "Some other string"
+ EXPORT_PROPERTIES "IMPORTED_FOOBAR"
+)
+export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake")
+install(TARGETS foo EXPORT fooExport
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
diff --git a/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-result.txt b/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-stderr.txt b/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-stderr.txt
new file mode 100644
index 000000000..577602b33
--- /dev/null
+++ b/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error in CMakeLists.txt:
+ Target \"foo\" contains property \"INTERFACE_FOOBAR\" in EXPORT_PROPERTIES but
+ IMPORTED_\* and INTERFACE_\* properties are reserved.
diff --git a/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties.cmake b/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties.cmake
new file mode 100644
index 000000000..bab8de0f3
--- /dev/null
+++ b/Tests/RunCMake/export/ForbiddenToExportInterfaceProperties.cmake
@@ -0,0 +1,12 @@
+enable_language(CXX)
+add_library(foo empty.cpp)
+set_target_properties(foo PROPERTIES
+ INTERFACE_FOOBAR "Some string"
+ EXPORT_PROPERTIES "INTERFACE_FOOBAR"
+)
+export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake")
+install(TARGETS foo EXPORT fooExport
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
diff --git a/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-result.txt b/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-stderr.txt b/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-stderr.txt
new file mode 100644
index 000000000..56488e69e
--- /dev/null
+++ b/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error in CMakeLists.txt:
+ Target \"foo\" contains property \"JUST_A_PROPERTY\" in EXPORT_PROPERTIES but
+ this property contains a generator expression. This is not allowed.
diff --git a/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp.cmake b/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp.cmake
new file mode 100644
index 000000000..065cdbcdb
--- /dev/null
+++ b/Tests/RunCMake/export/ForbiddenToExportPropertyWithGenExp.cmake
@@ -0,0 +1,12 @@
+enable_language(CXX)
+add_library(foo empty.cpp)
+set_target_properties(foo PROPERTIES
+ JUST_A_PROPERTY "$<C_COMPILER_VERSION:0>"
+ EXPORT_PROPERTIES "JUST_A_PROPERTY"
+)
+export(TARGETS foo FILE "${CMAKE_CURRENT_BINARY_DIR}/foo.cmake")
+install(TARGETS foo EXPORT fooExport
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
diff --git a/Tests/RunCMake/export/OldIface-stderr.txt b/Tests/RunCMake/export/OldIface-stderr.txt
index 818c2cb20..3cc10331e 100644
--- a/Tests/RunCMake/export/OldIface-stderr.txt
+++ b/Tests/RunCMake/export/OldIface-stderr.txt
@@ -1,5 +1,4 @@
CMake Error at OldIface.cmake:[0-9]+ \(export\):
- export EXPORT signature does not recognise the
- EXPORT_LINK_INTERFACE_LIBRARIES option.
+ export Unknown argument: "EXPORT_LINK_INTERFACE_LIBRARIES".
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake
index 6d0b7ca7c..4d2f2171e 100644
--- a/Tests/RunCMake/export/RunCMakeTest.cmake
+++ b/Tests/RunCMake/export/RunCMakeTest.cmake
@@ -1,7 +1,14 @@
include(RunCMake)
run_cmake(CustomTarget)
+run_cmake(Empty)
run_cmake(TargetNotFound)
run_cmake(AppendExport)
run_cmake(OldIface)
run_cmake(NoExportSet)
+run_cmake(ForbiddenToExportInterfaceProperties)
+run_cmake(ForbiddenToExportImportedProperties)
+run_cmake(ForbiddenToExportPropertyWithGenExp)
+run_cmake(ExportPropertiesUndefined)
+run_cmake(DependOnNotExport)
+run_cmake(DependOnDoubleExport)
diff --git a/Tests/RunCMake/export/empty.cpp b/Tests/RunCMake/export/empty.cpp
new file mode 100644
index 000000000..11ec041d1
--- /dev/null
+++ b/Tests/RunCMake/export/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/file/CREATE_LINK-COPY_ON_ERROR.cmake b/Tests/RunCMake/file/CREATE_LINK-COPY_ON_ERROR.cmake
new file mode 100644
index 000000000..777ef4e6c
--- /dev/null
+++ b/Tests/RunCMake/file/CREATE_LINK-COPY_ON_ERROR.cmake
@@ -0,0 +1,11 @@
+# Use COPY_ON_ERROR to handle the case where the source and destination
+# directory are on different devices. Cross-device links are not permitted
+# and the following command falls back to copying the file if link fails.
+file(CREATE_LINK
+ ${CMAKE_CURRENT_LIST_FILE} TestCreateLink.cmake
+ RESULT result
+ COPY_ON_ERROR
+ )
+if(NOT result STREQUAL "0")
+ message(SEND_ERROR "COPY_ON_ERROR failed: '${result}'")
+endif()
diff --git a/Tests/RunCMake/file/CREATE_LINK-SYMBOLIC-noexist.cmake b/Tests/RunCMake/file/CREATE_LINK-SYMBOLIC-noexist.cmake
new file mode 100644
index 000000000..61aaf388f
--- /dev/null
+++ b/Tests/RunCMake/file/CREATE_LINK-SYMBOLIC-noexist.cmake
@@ -0,0 +1,4 @@
+file(CREATE_LINK does_not_exist.txt TestSymLink.txt RESULT sym_result SYMBOLIC)
+if(NOT sym_result STREQUAL "0")
+ message("Symlink fail: ${sym_result}")
+endif()
diff --git a/Tests/RunCMake/file/CREATE_LINK-SYMBOLIC.cmake b/Tests/RunCMake/file/CREATE_LINK-SYMBOLIC.cmake
new file mode 100644
index 000000000..77b899cff
--- /dev/null
+++ b/Tests/RunCMake/file/CREATE_LINK-SYMBOLIC.cmake
@@ -0,0 +1,4 @@
+file(CREATE_LINK ${CMAKE_CURRENT_LIST_FILE} TestSymLink.cmake RESULT sym_result SYMBOLIC)
+if(NOT sym_result STREQUAL "0")
+ message(SEND_ERROR "Symlink result='${sym_result}'")
+endif()
diff --git a/Tests/RunCMake/file/CREATE_LINK-noarg-result.txt b/Tests/RunCMake/file/CREATE_LINK-noarg-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/CREATE_LINK-noarg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/CREATE_LINK-noarg-stderr.txt b/Tests/RunCMake/file/CREATE_LINK-noarg-stderr.txt
new file mode 100644
index 000000000..12494f845
--- /dev/null
+++ b/Tests/RunCMake/file/CREATE_LINK-noarg-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at CREATE_LINK-noarg\.cmake:[0-9]+ \(file\):
+ file CREATE_LINK must be called with at least two additional arguments
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/file/CREATE_LINK-noarg.cmake b/Tests/RunCMake/file/CREATE_LINK-noarg.cmake
new file mode 100644
index 000000000..65002fa77
--- /dev/null
+++ b/Tests/RunCMake/file/CREATE_LINK-noarg.cmake
@@ -0,0 +1 @@
+file(CREATE_LINK ${CMAKE_CURRENT_LIST_FILE})
diff --git a/Tests/RunCMake/file/CREATE_LINK-noexist-stderr.txt b/Tests/RunCMake/file/CREATE_LINK-noexist-stderr.txt
new file mode 100644
index 000000000..97eee4fef
--- /dev/null
+++ b/Tests/RunCMake/file/CREATE_LINK-noexist-stderr.txt
@@ -0,0 +1 @@
+Hard link error: Cannot hard link 'does_not_exist.txt' as it does not exist.
diff --git a/Tests/RunCMake/file/CREATE_LINK-noexist.cmake b/Tests/RunCMake/file/CREATE_LINK-noexist.cmake
new file mode 100644
index 000000000..5ee258017
--- /dev/null
+++ b/Tests/RunCMake/file/CREATE_LINK-noexist.cmake
@@ -0,0 +1,4 @@
+file(CREATE_LINK does_not_exist.txt TestLink.txt RESULT result)
+if(NOT result STREQUAL "0")
+ message("Hard link error: ${result}")
+endif()
diff --git a/Tests/RunCMake/file/CREATE_LINK.cmake b/Tests/RunCMake/file/CREATE_LINK.cmake
new file mode 100644
index 000000000..ca616468a
--- /dev/null
+++ b/Tests/RunCMake/file/CREATE_LINK.cmake
@@ -0,0 +1,11 @@
+# start with a file in the same directory to avoid cross-device links
+set(test_file ${CMAKE_CURRENT_BINARY_DIR}/CreateLinkTest.txt)
+file(TOUCH ${test_file})
+
+file(CREATE_LINK
+ ${test_file} ${CMAKE_CURRENT_BINARY_DIR}/TestCreateLink.txt
+ RESULT result
+ )
+if(NOT result STREQUAL "0")
+ message(SEND_ERROR "Hard link result='${result}'")
+endif()
diff --git a/Tests/RunCMake/file/DOWNLOAD-netrc-bad-result.txt b/Tests/RunCMake/file/DOWNLOAD-netrc-bad-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-netrc-bad-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/DOWNLOAD-netrc-bad-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-netrc-bad-stderr.txt
new file mode 100644
index 000000000..96ce62ad0
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-netrc-bad-stderr.txt
@@ -0,0 +1,19 @@
+^CMake Error at DOWNLOAD-netrc-bad\.cmake:[0-9]+ \(file\):
+ file DOWNLOAD missing level value for NETRC\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Error at DOWNLOAD-netrc-bad\.cmake:[0-9]+ \(file\):
+ file DOWNLOAD missing file value for NETRC_FILE\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Error at DOWNLOAD-netrc-bad\.cmake:[0-9]+ \(file\):
+ file NETRC accepts OPTIONAL, IGNORED or REQUIRED but got: INVALID
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Error at DOWNLOAD-netrc-bad\.cmake:[0-9]+ \(file\):
+ file NETRC accepts OPTIONAL, IGNORED or REQUIRED but got: FALSE
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/file/DOWNLOAD-netrc-bad.cmake b/Tests/RunCMake/file/DOWNLOAD-netrc-bad.cmake
new file mode 100644
index 000000000..6a62df94e
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-netrc-bad.cmake
@@ -0,0 +1,15 @@
+if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/")
+ set(slash /)
+endif()
+file(DOWNLOAD "" "" NETRC)
+file(DOWNLOAD "" "" NETRC_FILE)
+set(CMAKE_NETRC FALSE)
+file(DOWNLOAD
+ "file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/DOWNLOAD-netrc-bad.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/netrc-bad.txt"
+ NETRC INVALID
+ )
+file(DOWNLOAD
+ "file://${slash}${CMAKE_CURRENT_SOURCE_DIR}/DOWNLOAD-netrc-bad.txt"
+ "${CMAKE_CURRENT_BINARY_DIR}/netrc-bad.txt"
+ )
diff --git a/Tests/RunCMake/file/DOWNLOAD-netrc-bad.txt b/Tests/RunCMake/file/DOWNLOAD-netrc-bad.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-netrc-bad.txt
diff --git a/Tests/RunCMake/file/FileOpenFailRead-stderr.txt b/Tests/RunCMake/file/FileOpenFailRead-stderr.txt
index 23d4337f4..9f8cee26a 100644
--- a/Tests/RunCMake/file/FileOpenFailRead-stderr.txt
+++ b/Tests/RunCMake/file/FileOpenFailRead-stderr.txt
@@ -3,4 +3,4 @@ CMake Error at FileOpenFailRead.cmake:[0-9]+ \(file\):
.*/Tests/RunCMake/file/does_not_exist/file.txt
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-build-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-build-stdout.txt
new file mode 100644
index 000000000..71ab721d7
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-build-stdout.txt
@@ -0,0 +1 @@
+.*b9fbdd8803c036dbe9f5ea6b74db4b9670c78a72
diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_first-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_first-stdout.txt
new file mode 100644
index 000000000..ff90f9c1d
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_first-stdout.txt
@@ -0,0 +1,2 @@
+.*Running CMake on GLOB-CONFIGURE_DEPENDS-RerunCMake
+.*6bc141b40c0f851d20fa9a1fe5fbdae94acc5de0
diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_second-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_second-stdout.txt
new file mode 100644
index 000000000..cf2a5afe6
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_second-stdout.txt
@@ -0,0 +1,2 @@
+.*Running CMake on GLOB-CONFIGURE_DEPENDS-RerunCMake
+.*0c3ceab9daa7914fde7410c34cae4049e140aa51
diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-stdout.txt b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-stdout.txt
new file mode 100644
index 000000000..66b6c449a
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake-stdout.txt
@@ -0,0 +1 @@
+.*Running CMake on GLOB-CONFIGURE_DEPENDS-RerunCMake
diff --git a/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake.cmake b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake.cmake
new file mode 100644
index 000000000..fe87c7849
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-CONFIGURE_DEPENDS-RerunCMake.cmake
@@ -0,0 +1,10 @@
+message(STATUS "Running CMake on GLOB-CONFIGURE_DEPENDS-RerunCMake")
+file(GLOB_RECURSE
+ CONTENT_LIST
+ CONFIGURE_DEPENDS
+ LIST_DIRECTORIES false
+ RELATIVE "${CMAKE_CURRENT_BINARY_DIR}"
+ "${CMAKE_CURRENT_BINARY_DIR}/test/*"
+ )
+string(SHA1 CONTENT_LIST_HASH "${CONTENT_LIST}")
+add_custom_target(CONTENT_ECHO ALL ${CMAKE_COMMAND} -E echo ${CONTENT_LIST_HASH})
diff --git a/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-result.txt b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-stderr.txt b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-stderr.txt
new file mode 100644
index 000000000..40083c129
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE-stderr.txt
@@ -0,0 +1 @@
+.*CONFIGURE_DEPENDS is invalid for script and find package modes\.
diff --git a/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE.cmake b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE.cmake
new file mode 100644
index 000000000..9dc0f0393
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE.cmake
@@ -0,0 +1 @@
+file(GLOB CONTENT_LIST CONFIGURE_DEPENDS)
diff --git a/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-result.txt b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-stderr.txt b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-stderr.txt
new file mode 100644
index 000000000..d7b36eb67
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error: The glob expression
+.* at GLOB-error-CONFIGURE_DEPENDS-modified\.cmake:[0-9]+ \(file\)
+was already present in the glob cache but the directory
+contents have changed during the configuration run.
+Matching glob expressions:
+ CONTENT_LIST_1 at GLOB-error-CONFIGURE_DEPENDS-modified\.cmake:[0-9]+ \(file\)
+ CONTENT_LIST_2 at GLOB-error-CONFIGURE_DEPENDS-modified\.cmake:[0-9]+ \(file\)$
diff --git a/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified.cmake b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified.cmake
new file mode 100644
index 000000000..8d74deac6
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-CONFIGURE_DEPENDS-modified.cmake
@@ -0,0 +1,21 @@
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/first")
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/second")
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/third")
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/first/one" "one")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/second/two" "two")
+file(GLOB_RECURSE CONTENT_LIST_1
+ CONFIGURE_DEPENDS
+ "${CMAKE_CURRENT_BINARY_DIR}/test/*"
+ )
+
+file(GLOB_RECURSE CONTENT_LIST_2
+ CONFIGURE_DEPENDS
+ "${CMAKE_CURRENT_BINARY_DIR}/test/*"
+ )
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/third/three" "three")
+file(GLOB_RECURSE CONTENT_LIST_3
+ CONFIGURE_DEPENDS
+ "${CMAKE_CURRENT_BINARY_DIR}/test/*"
+ )
diff --git a/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-result.txt b/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-stderr.txt b/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-stderr.txt
new file mode 100644
index 000000000..30cec899b
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at GLOB-error-RELATIVE-no-arg\.cmake:[0-9]+ \(file\):
+ file GLOB requires a directory after the RELATIVE tag\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg.cmake b/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg.cmake
new file mode 100644
index 000000000..a55588126
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-error-RELATIVE-no-arg.cmake
@@ -0,0 +1 @@
+file(GLOB CONTENT_LIST RELATIVE)
diff --git a/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-result.txt b/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-stderr.txt b/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-stderr.txt
new file mode 100644
index 000000000..01d204f2b
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at GLOB-noexp-CONFIGURE_DEPENDS\.cmake:[0-9]+ \(file\):
+ file GLOB requires a glob expression after CONFIGURE_DEPENDS\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS.cmake b/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS.cmake
new file mode 100644
index 000000000..9dc0f0393
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-noexp-CONFIGURE_DEPENDS.cmake
@@ -0,0 +1 @@
+file(GLOB CONTENT_LIST CONFIGURE_DEPENDS)
diff --git a/Tests/RunCMake/file/GLOB-noexp-FOLLOW_SYMLINKS.cmake b/Tests/RunCMake/file/GLOB-noexp-FOLLOW_SYMLINKS.cmake
new file mode 100644
index 000000000..6d467a0c6
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-noexp-FOLLOW_SYMLINKS.cmake
@@ -0,0 +1 @@
+file(GLOB CONTENT_LIST FOLLOW_SYMLINKS)
diff --git a/Tests/RunCMake/file/GLOB-noexp-RELATIVE-result.txt b/Tests/RunCMake/file/GLOB-noexp-RELATIVE-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-noexp-RELATIVE-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/GLOB-noexp-RELATIVE-stderr.txt b/Tests/RunCMake/file/GLOB-noexp-RELATIVE-stderr.txt
new file mode 100644
index 000000000..9c666312d
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-noexp-RELATIVE-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at GLOB-noexp-RELATIVE\.cmake:[0-9]+ \(file\):
+ file GLOB requires a glob expression after the directory\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/file/GLOB-noexp-RELATIVE.cmake b/Tests/RunCMake/file/GLOB-noexp-RELATIVE.cmake
new file mode 100644
index 000000000..7b2d40420
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-noexp-RELATIVE.cmake
@@ -0,0 +1 @@
+file(GLOB CONTENT_LIST RELATIVE "${CMAKE_CURRENT_BINARY_DIR}")
diff --git a/Tests/RunCMake/file/GLOB-sort-dedup-stderr.txt b/Tests/RunCMake/file/GLOB-sort-dedup-stderr.txt
new file mode 100644
index 000000000..d2565e4a9
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-sort-dedup-stderr.txt
@@ -0,0 +1,2 @@
+content: 7[ ]
+1aAb/\.hide;1aAb/1\.log;1aAb/1\.txt;1aAb/xkcd\.txt;a/1\.log;a/1\.txt;a/boot\.ini
diff --git a/Tests/RunCMake/file/GLOB-sort-dedup.cmake b/Tests/RunCMake/file/GLOB-sort-dedup.cmake
new file mode 100644
index 000000000..1e1c5797f
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-sort-dedup.cmake
@@ -0,0 +1,21 @@
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/a")
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/1aAb")
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/a/1.log" "")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/a/1.txt" "")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/a/boot.ini" "")
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/1aAb/.hide" "")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/1aAb/1.txt" "")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/1aAb/1.log" "")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/1aAb/xkcd.txt" "")
+
+file(GLOB CONTENT_LIST
+ LIST_DIRECTORIES false
+ RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/test"
+ "${CMAKE_CURRENT_BINARY_DIR}/test/a/*"
+ "${CMAKE_CURRENT_BINARY_DIR}/test/*/*"
+ )
+list(LENGTH CONTENT_LIST CONTENT_COUNT)
+message("content: ${CONTENT_COUNT} ")
+message("${CONTENT_LIST}")
diff --git a/Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late-stderr.txt b/Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late-stderr.txt
new file mode 100644
index 000000000..af722a4e1
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Warning \(dev\) at GLOB-warn-CONFIGURE_DEPENDS-late\.cmake:[0-9]+ \(file\):
+ CONFIGURE_DEPENDS flag was given after a glob expression was already
+ evaluated\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\. Use -Wno-dev to suppress it\.$
diff --git a/Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late.cmake b/Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late.cmake
new file mode 100644
index 000000000..0b6955291
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB-warn-CONFIGURE_DEPENDS-late.cmake
@@ -0,0 +1,11 @@
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/first")
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/second")
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/first/one" "Hi, Mom!")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/second/two" "Love you!")
+
+file(GLOB CONTENT_LIST
+ "${CMAKE_CURRENT_BINARY_DIR}/test/first/*"
+ CONFIGURE_DEPENDS
+ "${CMAKE_CURRENT_BINARY_DIR}/test/second/*"
+ )
diff --git a/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-result.txt b/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-stderr.txt b/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-stderr.txt
new file mode 100644
index 000000000..d0b2bffa1
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at GLOB_RECURSE-noexp-FOLLOW_SYMLINKS\.cmake:[0-9]+ \(file\):
+ file GLOB_RECURSE requires a glob expression after FOLLOW_SYMLINKS\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS.cmake b/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS.cmake
new file mode 100644
index 000000000..5e5ce9288
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB_RECURSE-noexp-FOLLOW_SYMLINKS.cmake
@@ -0,0 +1 @@
+file(GLOB_RECURSE CONTENT_LIST FOLLOW_SYMLINKS)
diff --git a/Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version-stderr.txt b/Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version-stderr.txt
new file mode 100644
index 000000000..8d2233286
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version-stderr.txt
@@ -0,0 +1,13 @@
+^CMake Warning \(dev\):
+ The detected version of Ninja:
+
+ .*
+
+ is less than the version of Ninja required by CMake for adding restat
+ dependencies to the build\.ninja manifest regeneration target:
+
+ 1\.8
+
+ Any pre-check scripts, such as those generated for file\(GLOB
+ CONFIGURE_DEPENDS\), will not be run by Ninja\.
+This warning is for project developers\. Use -Wno-dev to suppress it\.$
diff --git a/Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version.cmake b/Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version.cmake
new file mode 100644
index 000000000..8e8089516
--- /dev/null
+++ b/Tests/RunCMake/file/GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version.cmake
@@ -0,0 +1,6 @@
+file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test/first")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test/first/one" "one")
+file(GLOB_RECURSE CONTENT_LIST
+ CONFIGURE_DEPENDS
+ "${CMAKE_CURRENT_BINARY_DIR}/test/*"
+ )
diff --git a/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN.cmake b/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN.cmake
new file mode 100644
index 000000000..d8a12ebba
--- /dev/null
+++ b/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN.cmake
@@ -0,0 +1,168 @@
+file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/dest1")
+
+file(TOUCH "${CMAKE_BINARY_DIR}/file1.txt")
+file(CREATE_LINK file1.txt "${CMAKE_BINARY_DIR}/file1.txt.sym" SYMBOLIC)
+file(TOUCH "${CMAKE_BINARY_DIR}/dest1/file1.txt.sym")
+
+file(TOUCH "${CMAKE_BINARY_DIR}/file2.txt")
+file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file2")
+file(CREATE_LINK ../file2.txt "${CMAKE_BINARY_DIR}/file2/file2.txt.sym" SYMBOLIC)
+
+file(TOUCH "${CMAKE_BINARY_DIR}/file3.txt")
+file(CREATE_LINK "${CMAKE_BINARY_DIR}/file3.txt" "${CMAKE_BINARY_DIR}/file3.txt.sym" SYMBOLIC)
+
+file(TOUCH "${CMAKE_BINARY_DIR}/file4.txt")
+file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file4")
+file(CREATE_LINK "${CMAKE_BINARY_DIR}/file4.txt" "${CMAKE_BINARY_DIR}/file4/file4.txt.sym" SYMBOLIC)
+
+file(TOUCH "${CMAKE_BINARY_DIR}/file5.txt")
+
+file(TOUCH "${CMAKE_BINARY_DIR}/file6.txt")
+file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file6/file6")
+file(CREATE_LINK file6.txt "${CMAKE_BINARY_DIR}/file6.txt.sym.1" SYMBOLIC)
+file(CREATE_LINK ../file6.txt.sym.1 "${CMAKE_BINARY_DIR}/file6/file6.txt.sym.2" SYMBOLIC)
+file(CREATE_LINK "${CMAKE_BINARY_DIR}/file6/file6.txt.sym.2" "${CMAKE_BINARY_DIR}/file6/file6/file6.txt.sym.3" SYMBOLIC)
+file(CREATE_LINK file6.txt.sym.3 "${CMAKE_BINARY_DIR}/file6/file6/file6.txt.sym.4" SYMBOLIC)
+
+file(TOUCH "${CMAKE_BINARY_DIR}/file7.txt")
+file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file7")
+
+file(TOUCH "${CMAKE_BINARY_DIR}/file8.txt")
+file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file8")
+file(CREATE_LINK "${CMAKE_BINARY_DIR}/file8/../file8.txt" "${CMAKE_BINARY_DIR}/file8/file8.txt.sym" SYMBOLIC)
+
+file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file9")
+file(TOUCH "${CMAKE_BINARY_DIR}/file9/file9.txt")
+file(CREATE_LINK "${CMAKE_BINARY_DIR}/file9" "${CMAKE_BINARY_DIR}/file9.sym" SYMBOLIC)
+
+file(TOUCH "${CMAKE_BINARY_DIR}/file10.txt")
+file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/file10")
+file(CREATE_LINK "." "${CMAKE_BINARY_DIR}/file10/file10" SYMBOLIC)
+file(CREATE_LINK "${CMAKE_BINARY_DIR}/file10/file10/../file10.txt" "${CMAKE_BINARY_DIR}/file10/file10.txt.sym" SYMBOLIC)
+
+file(INSTALL
+ "${CMAKE_BINARY_DIR}/file1.txt.sym"
+ DESTINATION "${CMAKE_BINARY_DIR}/dest1"
+ FOLLOW_SYMLINK_CHAIN
+ )
+
+file(INSTALL
+ "${CMAKE_BINARY_DIR}/file1.txt.sym"
+ "${CMAKE_BINARY_DIR}/file2/file2.txt.sym"
+ "${CMAKE_BINARY_DIR}/file3.txt.sym"
+ "${CMAKE_BINARY_DIR}/file4/file4.txt.sym"
+ "${CMAKE_BINARY_DIR}/file5.txt"
+ "${CMAKE_BINARY_DIR}/file6/file6/file6.txt.sym.4"
+ "${CMAKE_BINARY_DIR}/file8/file8.txt.sym"
+ "${CMAKE_BINARY_DIR}/file7/../file7.txt"
+ "${CMAKE_BINARY_DIR}/file8.txt"
+ "${CMAKE_BINARY_DIR}/file9.sym/file9.txt"
+ "${CMAKE_BINARY_DIR}/file10/file10/file10.txt.sym"
+ DESTINATION "${CMAKE_BINARY_DIR}/dest2"
+ FOLLOW_SYMLINK_CHAIN
+ )
+
+set(resolved_file1.txt.sym file1.txt)
+set(resolved_file10.txt.sym file10.txt)
+set(resolved_file2.txt.sym file2.txt)
+set(resolved_file3.txt.sym file3.txt)
+set(resolved_file4.txt.sym file4.txt)
+set(resolved_file6.txt.sym.1 file6.txt)
+set(resolved_file6.txt.sym.2 file6.txt.sym.1)
+set(resolved_file6.txt.sym.3 file6.txt.sym.2)
+set(resolved_file6.txt.sym.4 file6.txt.sym.3)
+set(resolved_file8.txt.sym file8.txt)
+set(syms)
+foreach(f
+ file1.txt
+ file1.txt.sym
+ file10.txt
+ file10.txt.sym
+ file2.txt
+ file2.txt.sym
+ file3.txt
+ file3.txt.sym
+ file4.txt
+ file4.txt.sym
+ file5.txt
+ file6.txt
+ file6.txt.sym.1
+ file6.txt.sym.2
+ file6.txt.sym.3
+ file6.txt.sym.4
+ file7.txt
+ file8.txt
+ file8.txt.sym
+ file9.txt
+ )
+ string(REPLACE "." "\\." r "${f}")
+ list(APPEND syms "[^;]*/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/dest2/${r}")
+ set(filename "${CMAKE_BINARY_DIR}/dest2/${f}")
+ if(DEFINED resolved_${f})
+ file(READ_SYMLINK "${filename}" resolved)
+ if(NOT resolved STREQUAL "${resolved_${f}}")
+ message(SEND_ERROR "Expected symlink resolution for ${f}: ${resolved_${f}}\nActual resolution: ${resolved}")
+ endif()
+ elseif(NOT EXISTS "${filename}" OR IS_SYMLINK "${filename}" OR IS_DIRECTORY "${filename}")
+ message(SEND_ERROR "${f} should be a regular file")
+ endif()
+endforeach()
+
+file(GLOB_RECURSE actual_syms LIST_DIRECTORIES true "${CMAKE_BINARY_DIR}/dest2/*")
+if(NOT actual_syms MATCHES "^${syms}$")
+ message(SEND_ERROR "Expected files:\n\n ^${syms}$\n\nActual files:\n\n ${actual_syms}")
+endif()
+
+file(INSTALL
+ "${CMAKE_BINARY_DIR}/file1.txt.sym"
+ "${CMAKE_BINARY_DIR}/file2/file2.txt.sym"
+ "${CMAKE_BINARY_DIR}/file3.txt.sym"
+ "${CMAKE_BINARY_DIR}/file4/file4.txt.sym"
+ "${CMAKE_BINARY_DIR}/file5.txt"
+ "${CMAKE_BINARY_DIR}/file6/file6/file6.txt.sym.4"
+ "${CMAKE_BINARY_DIR}/file8/file8.txt.sym"
+ "${CMAKE_BINARY_DIR}/file7/../file7.txt"
+ "${CMAKE_BINARY_DIR}/file8.txt"
+ "${CMAKE_BINARY_DIR}/file9.sym/file9.txt"
+ "${CMAKE_BINARY_DIR}/file10/file10/file10.txt.sym"
+ DESTINATION "${CMAKE_BINARY_DIR}/dest3"
+ )
+
+set(resolved_file1.txt.sym [[^file1\.txt$]])
+set(resolved_file10.txt.sym [[/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/file10/file10/\.\./file10\.txt$]])
+set(resolved_file2.txt.sym [[^\.\./file2\.txt$]])
+set(resolved_file3.txt.sym [[/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/file3\.txt$]])
+set(resolved_file4.txt.sym [[/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/file4\.txt$]])
+set(resolved_file6.txt.sym.4 [[^file6\.txt\.sym\.3$]])
+set(resolved_file8.txt.sym [[/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/file8/\.\./file8\.txt$]])
+set(syms)
+foreach(f
+ file1.txt.sym
+ file10.txt.sym
+ file2.txt.sym
+ file3.txt.sym
+ file4.txt.sym
+ file5.txt
+ file6.txt.sym.4
+ file7.txt
+ file8.txt
+ file8.txt.sym
+ file9.txt
+ )
+ string(REPLACE "." "\\." r "${f}")
+ list(APPEND syms "[^;]*/Tests/RunCMake/file/INSTALL-FOLLOW_SYMLINK_CHAIN-build/dest3/${r}")
+ set(filename "${CMAKE_BINARY_DIR}/dest3/${f}")
+ if(DEFINED resolved_${f})
+ file(READ_SYMLINK "${filename}" resolved)
+ if(NOT resolved MATCHES "${resolved_${f}}")
+ message(SEND_ERROR "Expected symlink resolution for ${f}: ${resolved_${f}}\nActual resolution: ${resolved}")
+ endif()
+ elseif(NOT EXISTS "${filename}" OR IS_SYMLINK "${filename}" OR IS_DIRECTORY "${filename}")
+ message(SEND_ERROR "${f} should be a regular file")
+ endif()
+endforeach()
+
+file(GLOB_RECURSE actual_syms LIST_DIRECTORIES true "${CMAKE_BINARY_DIR}/dest3/*")
+if(NOT actual_syms MATCHES "^${syms}$")
+ message(SEND_ERROR "Expected files:\n\n ^${syms}$\n\nActual files:\n\n ${actual_syms}")
+endif()
diff --git a/Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt b/Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt
index 557b817bb..bb7e4d2cc 100644
--- a/Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt
+++ b/Tests/RunCMake/file/INSTALL-MESSAGE-bad-stderr.txt
@@ -2,31 +2,31 @@ CMake Error at INSTALL-MESSAGE-bad.cmake:1 \(file\):
file INSTALL options MESSAGE_ALWAYS, MESSAGE_LAZY, and MESSAGE_NEVER are
mutually exclusive.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
+
CMake Error at INSTALL-MESSAGE-bad.cmake:2 \(file\):
file INSTALL options MESSAGE_ALWAYS, MESSAGE_LAZY, and MESSAGE_NEVER are
mutually exclusive.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
+
CMake Error at INSTALL-MESSAGE-bad.cmake:3 \(file\):
file INSTALL options MESSAGE_ALWAYS, MESSAGE_LAZY, and MESSAGE_NEVER are
mutually exclusive.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
+
CMake Error at INSTALL-MESSAGE-bad.cmake:4 \(file\):
file option MESSAGE_ALWAYS may not appear after PATTERN or REGEX.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
+
CMake Error at INSTALL-MESSAGE-bad.cmake:5 \(file\):
file option MESSAGE_LAZY may not appear after PATTERN or REGEX.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
+
CMake Error at INSTALL-MESSAGE-bad.cmake:6 \(file\):
file option MESSAGE_NEVER may not appear after PATTERN or REGEX.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/file/READ_SYMLINK-noexist-result.txt b/Tests/RunCMake/file/READ_SYMLINK-noexist-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/READ_SYMLINK-noexist-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/READ_SYMLINK-noexist-stderr.txt b/Tests/RunCMake/file/READ_SYMLINK-noexist-stderr.txt
new file mode 100644
index 000000000..32b3e8525
--- /dev/null
+++ b/Tests/RunCMake/file/READ_SYMLINK-noexist-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at READ_SYMLINK-noexist\.cmake:[0-9]+ \(file\):
+ file READ_SYMLINK requested of path that is not a symlink:
+
+ .*/Tests/RunCMake/file/READ_SYMLINK-noexist-build/rel\.sym
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/file/READ_SYMLINK-noexist.cmake b/Tests/RunCMake/file/READ_SYMLINK-noexist.cmake
new file mode 100644
index 000000000..9e57e4ba4
--- /dev/null
+++ b/Tests/RunCMake/file/READ_SYMLINK-noexist.cmake
@@ -0,0 +1 @@
+file(READ_SYMLINK "${CMAKE_CURRENT_BINARY_DIR}/rel.sym" result)
diff --git a/Tests/RunCMake/file/READ_SYMLINK-notsymlink-result.txt b/Tests/RunCMake/file/READ_SYMLINK-notsymlink-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/READ_SYMLINK-notsymlink-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/READ_SYMLINK-notsymlink-stderr.txt b/Tests/RunCMake/file/READ_SYMLINK-notsymlink-stderr.txt
new file mode 100644
index 000000000..63e32ed67
--- /dev/null
+++ b/Tests/RunCMake/file/READ_SYMLINK-notsymlink-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at READ_SYMLINK-notsymlink\.cmake:[0-9]+ \(file\):
+ file READ_SYMLINK requested of path that is not a symlink:
+
+ .*/Tests/RunCMake/file/READ_SYMLINK-notsymlink-build/rel\.sym
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/file/READ_SYMLINK-notsymlink.cmake b/Tests/RunCMake/file/READ_SYMLINK-notsymlink.cmake
new file mode 100644
index 000000000..a9798b61e
--- /dev/null
+++ b/Tests/RunCMake/file/READ_SYMLINK-notsymlink.cmake
@@ -0,0 +1,2 @@
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/rel.sym" "")
+file(READ_SYMLINK "${CMAKE_CURRENT_BINARY_DIR}/rel.sym" result)
diff --git a/Tests/RunCMake/file/READ_SYMLINK.cmake b/Tests/RunCMake/file/READ_SYMLINK.cmake
new file mode 100644
index 000000000..865a2e931
--- /dev/null
+++ b/Tests/RunCMake/file/READ_SYMLINK.cmake
@@ -0,0 +1,13 @@
+execute_process(COMMAND
+ ${CMAKE_COMMAND} -E create_symlink "test.txt" "${CMAKE_CURRENT_BINARY_DIR}/rel.sym")
+file(READ_SYMLINK "${CMAKE_CURRENT_BINARY_DIR}/rel.sym" result)
+if(NOT result STREQUAL "test.txt")
+ message(SEND_ERROR "Relative symlink is \"${result}\", should be \"test.txt\"")
+endif()
+
+execute_process(COMMAND
+ ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_BINARY_DIR}/test.txt" "${CMAKE_CURRENT_BINARY_DIR}/abs.sym")
+file(READ_SYMLINK "${CMAKE_CURRENT_BINARY_DIR}/abs.sym" result)
+if(NOT result MATCHES "^.*/Tests/RunCMake/file/READ_SYMLINK-build/test\\.txt$")
+ message(SEND_ERROR "Absolute symlink is \"${result}\", should be \"*/Tests/RunCMake/file/READ_SYMLINK-build/test.txt\"")
+endif()
diff --git a/Tests/RunCMake/file/REMOVE-empty-stderr.txt b/Tests/RunCMake/file/REMOVE-empty-stderr.txt
new file mode 100644
index 000000000..898a6e16e
--- /dev/null
+++ b/Tests/RunCMake/file/REMOVE-empty-stderr.txt
@@ -0,0 +1,11 @@
+^CMake Warning \(dev\) at REMOVE-empty.cmake:1 \(file\):
+ Ignoring empty file name in REMOVE.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9] \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
++
+CMake Warning \(dev\) at REMOVE-empty.cmake:2 \(file\):
+ Ignoring empty file name in REMOVE_RECURSE.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9] \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/file/REMOVE-empty.cmake b/Tests/RunCMake/file/REMOVE-empty.cmake
new file mode 100644
index 000000000..38046fb51
--- /dev/null
+++ b/Tests/RunCMake/file/REMOVE-empty.cmake
@@ -0,0 +1,2 @@
+file(REMOVE "")
+file(REMOVE_RECURSE "")
diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake
index 26051b4d7..5db4b3bce 100644
--- a/Tests/RunCMake/file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/file/RunCMakeTest.cmake
@@ -1,11 +1,20 @@
include(RunCMake)
+run_cmake(CREATE_LINK)
+run_cmake(CREATE_LINK-COPY_ON_ERROR)
+run_cmake(CREATE_LINK-noarg)
+run_cmake(CREATE_LINK-noexist)
run_cmake(DOWNLOAD-hash-mismatch)
run_cmake(DOWNLOAD-unused-argument)
run_cmake(DOWNLOAD-httpheader-not-set)
+run_cmake(DOWNLOAD-netrc-bad)
run_cmake(DOWNLOAD-pass-not-set)
+run_cmake(TOUCH)
+run_cmake(TOUCH-error-in-source-directory)
+run_cmake(TOUCH-error-missing-directory)
run_cmake(UPLOAD-unused-argument)
run_cmake(UPLOAD-httpheader-not-set)
+run_cmake(UPLOAD-netrc-bad)
run_cmake(UPLOAD-pass-not-set)
run_cmake(INSTALL-DIRECTORY)
run_cmake(INSTALL-FILES_FROM_DIR)
@@ -30,13 +39,97 @@ run_cmake(LOCK-lowercase)
run_cmake(READ_ELF)
run_cmake(GLOB)
run_cmake(GLOB_RECURSE)
-# test is valid both for GLOB and GLOB_RECURSE
+run_cmake(GLOB_RECURSE-noexp-FOLLOW_SYMLINKS)
+run_cmake(SIZE)
+run_cmake(SIZE-error-does-not-exist)
+
+run_cmake(REMOVE-empty)
+
+# tests are valid both for GLOB and GLOB_RECURSE
+run_cmake(GLOB-sort-dedup)
run_cmake(GLOB-error-LIST_DIRECTORIES-not-boolean)
-# test is valid both for GLOB and GLOB_RECURSE
run_cmake(GLOB-error-LIST_DIRECTORIES-no-arg)
+run_cmake(GLOB-error-RELATIVE-no-arg)
+run_cmake(GLOB-error-CONFIGURE_DEPENDS-modified)
+run_cmake(GLOB-noexp-CONFIGURE_DEPENDS)
+run_cmake(GLOB-noexp-FOLLOW_SYMLINKS)
run_cmake(GLOB-noexp-LIST_DIRECTORIES)
+run_cmake(GLOB-noexp-RELATIVE)
+run_cmake_command(GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE ${CMAKE_COMMAND} -P
+ ${RunCMake_SOURCE_DIR}/GLOB-error-CONFIGURE_DEPENDS-SCRIPT_MODE.cmake)
if(NOT WIN32 OR CYGWIN)
+ run_cmake(CREATE_LINK-SYMBOLIC)
+ run_cmake(CREATE_LINK-SYMBOLIC-noexist)
run_cmake(GLOB_RECURSE-cyclic-recursion)
run_cmake(INSTALL-SYMLINK)
+ run_cmake(READ_SYMLINK)
+ run_cmake(READ_SYMLINK-noexist)
+ run_cmake(READ_SYMLINK-notsymlink)
+ run_cmake(INSTALL-FOLLOW_SYMLINK_CHAIN)
+endif()
+
+if(RunCMake_GENERATOR STREQUAL "Ninja")
+ # Detect ninja version so we know what tests can be supported.
+ execute_process(
+ COMMAND "${RunCMake_MAKE_PROGRAM}" --version
+ OUTPUT_VARIABLE ninja_out
+ ERROR_VARIABLE ninja_out
+ RESULT_VARIABLE ninja_res
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if(ninja_res EQUAL 0 AND "x${ninja_out}" MATCHES "^x[0-9]+\\.[0-9]+")
+ set(ninja_version "${ninja_out}")
+ message(STATUS "ninja version: ${ninja_version}")
+ else()
+ message(FATAL_ERROR "'ninja --version' reported:\n${ninja_out}")
+ endif()
+
+ if("${ninja_version}" VERSION_LESS 1.8)
+ message(STATUS "Ninja is too old for GLOB CONFIGURE_DEPENDS; expect a warning.")
+ endif()
+endif()
+
+if(RunCMake_GENERATOR STREQUAL "Ninja" AND "${ninja_version}" VERSION_LESS 1.8)
+ run_cmake(GLOB_RECURSE-warn-CONFIGURE_DEPENDS-ninja-version)
+else()
+ run_cmake(GLOB-warn-CONFIGURE_DEPENDS-late)
+
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GLOB-CONFIGURE_DEPENDS-RerunCMake-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(RunCMake_DEFAULT_stderr ".*")
+ if(RunCMake_GENERATOR STREQUAL "Borland Makefiles" OR
+ RunCMake_GENERATOR STREQUAL "Watcom WMake")
+ set(fs_delay 3)
+ else()
+ set(fs_delay 1.125)
+ endif()
+
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/test")
+ set(tf_1 "${RunCMake_TEST_BINARY_DIR}/test/1.txt")
+ file(WRITE "${tf_1}" "1")
+
+ message(STATUS "GLOB-RerunCMake: first configuration...")
+ run_cmake(GLOB-CONFIGURE_DEPENDS-RerunCMake)
+ run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-build ${CMAKE_COMMAND} --build .)
+
+ execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay})
+ message(STATUS "GLOB-CONFIGURE_DEPENDS-RerunCMake: add another file...")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/test/sub")
+ set(tf_2 "${RunCMake_TEST_BINARY_DIR}/test/sub/2.txt")
+ file(WRITE "${tf_2}" "2")
+ run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_first ${CMAKE_COMMAND} --build .)
+ run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-nowork ${CMAKE_COMMAND} --build .)
+
+ execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay})
+ message(STATUS "GLOB-CONFIGURE_DEPENDS-RerunCMake: remove first test file...")
+ file(REMOVE "${RunCMake_TEST_BINARY_DIR}/test/1.txt")
+ run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-rebuild_second ${CMAKE_COMMAND} --build .)
+ run_cmake_command(GLOB-CONFIGURE_DEPENDS-RerunCMake-nowork ${CMAKE_COMMAND} --build .)
+
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+ unset(RunCMake_DEFAULT_stderr)
endif()
diff --git a/Tests/RunCMake/file/SIZE-error-does-not-exist-result.txt b/Tests/RunCMake/file/SIZE-error-does-not-exist-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/SIZE-error-does-not-exist-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/SIZE-error-does-not-exist-stderr.txt b/Tests/RunCMake/file/SIZE-error-does-not-exist-stderr.txt
new file mode 100644
index 000000000..842cf8959
--- /dev/null
+++ b/Tests/RunCMake/file/SIZE-error-does-not-exist-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at SIZE-error-does-not-exist.cmake:[0-9]+ \(file\):
+ file SIZE requested of path that is not readable:
+
+ .*/Tests/RunCMake/file/SIZE-error-does-not-exist-build/does-not-exist
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/file/SIZE-error-does-not-exist.cmake b/Tests/RunCMake/file/SIZE-error-does-not-exist.cmake
new file mode 100644
index 000000000..ebac737dc
--- /dev/null
+++ b/Tests/RunCMake/file/SIZE-error-does-not-exist.cmake
@@ -0,0 +1,3 @@
+set(file "${CMAKE_CURRENT_BINARY_DIR}/does-not-exist")
+
+file(SIZE "${file}" CALCULATED_SIZE)
diff --git a/Tests/RunCMake/file/SIZE.cmake b/Tests/RunCMake/file/SIZE.cmake
new file mode 100644
index 000000000..4d9dbd2c9
--- /dev/null
+++ b/Tests/RunCMake/file/SIZE.cmake
@@ -0,0 +1,9 @@
+set(file "${CMAKE_CURRENT_BINARY_DIR}/a-test-file")
+
+file(WRITE "${file}" "test")
+
+file(SIZE "${file}" CALCULATED_SIZE)
+
+if (NOT CALCULATED_SIZE EQUAL 4)
+ message(FATAL_ERROR "Unexpected file size")
+endif()
diff --git a/Tests/RunCMake/file/TOUCH-error-in-source-directory-result.txt b/Tests/RunCMake/file/TOUCH-error-in-source-directory-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-error-in-source-directory-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/TOUCH-error-in-source-directory-stderr.txt b/Tests/RunCMake/file/TOUCH-error-in-source-directory-stderr.txt
new file mode 100644
index 000000000..f899c759b
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-error-in-source-directory-stderr.txt
@@ -0,0 +1 @@
+.*file attempted to touch a file:
diff --git a/Tests/RunCMake/file/TOUCH-error-in-source-directory.cmake b/Tests/RunCMake/file/TOUCH-error-in-source-directory.cmake
new file mode 100644
index 000000000..9aa7c567e
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-error-in-source-directory.cmake
@@ -0,0 +1,2 @@
+set(CMAKE_DISABLE_SOURCE_CHANGES ON)
+file(TOUCH "${CMAKE_CURRENT_SOURCE_DIR}/touch_test")
diff --git a/Tests/RunCMake/file/TOUCH-error-missing-directory-result.txt b/Tests/RunCMake/file/TOUCH-error-missing-directory-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-error-missing-directory-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/TOUCH-error-missing-directory-stderr.txt b/Tests/RunCMake/file/TOUCH-error-missing-directory-stderr.txt
new file mode 100644
index 000000000..f52e11a9a
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-error-missing-directory-stderr.txt
@@ -0,0 +1 @@
+.*file problem touching file:
diff --git a/Tests/RunCMake/file/TOUCH-error-missing-directory.cmake b/Tests/RunCMake/file/TOUCH-error-missing-directory.cmake
new file mode 100644
index 000000000..0cfb8d9a9
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-error-missing-directory.cmake
@@ -0,0 +1 @@
+file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/missing/directory/file.to-touch")
diff --git a/Tests/RunCMake/file/TOUCH-result.txt b/Tests/RunCMake/file/TOUCH-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/TOUCH-stderr.txt b/Tests/RunCMake/file/TOUCH-stderr.txt
new file mode 100644
index 000000000..9f31676db
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH-stderr.txt
@@ -0,0 +1,9 @@
+^CMake Error at TOUCH\.cmake:[0-9]+ \(file\):
+ file must be called with at least two arguments\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Error at TOUCH\.cmake:[0-9]+ \(file\):
+ file must be called with at least two arguments\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/file/TOUCH.cmake b/Tests/RunCMake/file/TOUCH.cmake
new file mode 100644
index 000000000..8931eb53a
--- /dev/null
+++ b/Tests/RunCMake/file/TOUCH.cmake
@@ -0,0 +1,16 @@
+set(file "${CMAKE_CURRENT_BINARY_DIR}/file-to-touch")
+
+file(REMOVE "${file}")
+file(TOUCH_NOCREATE "${file}")
+if(EXISTS "${file}")
+ message(FATAL_ERROR "error: TOUCH_NOCREATE created a file!")
+endif()
+
+file(TOUCH "${file}")
+if(NOT EXISTS "${file}")
+ message(FATAL_ERROR "error: TOUCH did not create a file!")
+endif()
+file(REMOVE "${file}")
+
+file(TOUCH)
+file(TOUCH_NOCREATE)
diff --git a/Tests/RunCMake/file/UPLOAD-netrc-bad-result.txt b/Tests/RunCMake/file/UPLOAD-netrc-bad-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/file/UPLOAD-netrc-bad-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/UPLOAD-netrc-bad-stderr.txt b/Tests/RunCMake/file/UPLOAD-netrc-bad-stderr.txt
new file mode 100644
index 000000000..d5752eaf9
--- /dev/null
+++ b/Tests/RunCMake/file/UPLOAD-netrc-bad-stderr.txt
@@ -0,0 +1,19 @@
+^CMake Error at UPLOAD-netrc-bad\.cmake:[0-9]+ \(file\):
+ file UPLOAD missing level value for NETRC\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Error at UPLOAD-netrc-bad\.cmake:[0-9]+ \(file\):
+ file UPLOAD missing file value for NETRC_FILE\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Error at UPLOAD-netrc-bad\.cmake:[0-9]+ \(file\):
+ file NETRC accepts OPTIONAL, IGNORED or REQUIRED but got: INVALID
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Error at UPLOAD-netrc-bad\.cmake:[0-9]+ \(file\):
+ file NETRC accepts OPTIONAL, IGNORED or REQUIRED but got: FALSE
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/file/UPLOAD-netrc-bad.cmake b/Tests/RunCMake/file/UPLOAD-netrc-bad.cmake
new file mode 100644
index 000000000..e59a2c498
--- /dev/null
+++ b/Tests/RunCMake/file/UPLOAD-netrc-bad.cmake
@@ -0,0 +1,15 @@
+if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" MATCHES "^/")
+ set(slash /)
+endif()
+file(UPLOAD "" "" NETRC)
+file(UPLOAD "" "" NETRC_FILE)
+set(CMAKE_NETRC FALSE)
+file(UPLOAD
+ "${CMAKE_CURRENT_SOURCE_DIR}/UPLOAD-netrc-bad.txt"
+ "file://${slash}${CMAKE_CURRENT_BINARY_DIR}/netrc-bad.txt"
+ NETRC INVALID
+ )
+file(UPLOAD
+ "${CMAKE_CURRENT_SOURCE_DIR}/UPLOAD-netrc-bad.txt"
+ "file://${slash}${CMAKE_CURRENT_BINARY_DIR}/netrc-bad.txt"
+ )
diff --git a/Tests/RunCMake/file/UPLOAD-netrc-bad.txt b/Tests/RunCMake/file/UPLOAD-netrc-bad.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/file/UPLOAD-netrc-bad.txt
diff --git a/Tests/RunCMake/find_file/FromPATHEnv-stdout-cygwin.txt b/Tests/RunCMake/find_file/FromPATHEnv-stdout-cygwin.txt
new file mode 100644
index 000000000..6912bdfac
--- /dev/null
+++ b/Tests/RunCMake/find_file/FromPATHEnv-stdout-cygwin.txt
@@ -0,0 +1,9 @@
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
diff --git a/Tests/RunCMake/find_file/FromPATHEnv-stdout-windows.txt b/Tests/RunCMake/find_file/FromPATHEnv-stdout-windows.txt
new file mode 100644
index 000000000..6912bdfac
--- /dev/null
+++ b/Tests/RunCMake/find_file/FromPATHEnv-stdout-windows.txt
@@ -0,0 +1,9 @@
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
diff --git a/Tests/RunCMake/find_file/FromPATHEnv-stdout.txt b/Tests/RunCMake/find_file/FromPATHEnv-stdout.txt
new file mode 100644
index 000000000..27a83ad22
--- /dev/null
+++ b/Tests/RunCMake/find_file/FromPATHEnv-stdout.txt
@@ -0,0 +1,9 @@
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
diff --git a/Tests/RunCMake/find_file/FromPATHEnv.cmake b/Tests/RunCMake/find_file/FromPATHEnv.cmake
new file mode 100644
index 000000000..9f058dd70
--- /dev/null
+++ b/Tests/RunCMake/find_file/FromPATHEnv.cmake
@@ -0,0 +1,24 @@
+set(ENV_PATH "$ENV{PATH}")
+foreach(path "/does_not_exist" "/include" "")
+ unset(PrefixInPATH_File CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_file(PrefixInPATH_File NAMES PrefixInPATH.h)
+ message(STATUS "PrefixInPATH_File='${PrefixInPATH_File}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+foreach(path "/does_not_exist" "/include" "")
+ unset(PrefixInPATH_File CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_file(PrefixInPATH_File NAMES PrefixInPATH.h)
+ message(STATUS "PrefixInPATH_File='${PrefixInPATH_File}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
+foreach(path "/does_not_exist" "/include" "")
+ unset(PrefixInPATH_File CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_file(PrefixInPATH_File NAMES PrefixInPATH.h NO_SYSTEM_ENVIRONMENT_PATH)
+ message(STATUS "PrefixInPATH_File='${PrefixInPATH_File}'")
+endforeach()
+set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_file/FromPrefixPath-stdout.txt b/Tests/RunCMake/find_file/FromPrefixPath-stdout.txt
new file mode 100644
index 000000000..4bd24aa5c
--- /dev/null
+++ b/Tests/RunCMake/find_file/FromPrefixPath-stdout.txt
@@ -0,0 +1,6 @@
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
diff --git a/Tests/RunCMake/find_file/FromPrefixPath.cmake b/Tests/RunCMake/find_file/FromPrefixPath.cmake
new file mode 100644
index 000000000..63c6a0791
--- /dev/null
+++ b/Tests/RunCMake/find_file/FromPrefixPath.cmake
@@ -0,0 +1,19 @@
+set(ENV_PATH "$ENV{PATH}")
+set(ENV{PATH} "")
+foreach(path "/does_not_exist" "/include" "")
+ unset(PrefixInPATH_File CACHE)
+ set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_file(PrefixInPATH_File NAMES PrefixInPATH.h)
+ message(STATUS "PrefixInPATH_File='${PrefixInPATH_File}'")
+endforeach()
+
+set(CMAKE_FIND_USE_CMAKE_PATH OFF)
+set(CMAKE_PREFIX_PATH )
+foreach(path "/does_not_exist" "/include" "")
+ unset(PrefixInPATH_File CACHE)
+ set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_file(PrefixInPATH_File NAMES PrefixInPATH.h)
+ message(STATUS "PrefixInPATH_File='${PrefixInPATH_File}'")
+endforeach()
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
+set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_file/PrefixInPATH-stdout-cygwin.txt b/Tests/RunCMake/find_file/PrefixInPATH-stdout-cygwin.txt
new file mode 100644
index 000000000..d73bc1dfd
--- /dev/null
+++ b/Tests/RunCMake/find_file/PrefixInPATH-stdout-cygwin.txt
@@ -0,0 +1,4 @@
+-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
diff --git a/Tests/RunCMake/find_file/PrefixInPATH-stdout-windows.txt b/Tests/RunCMake/find_file/PrefixInPATH-stdout-windows.txt
new file mode 100644
index 000000000..d73bc1dfd
--- /dev/null
+++ b/Tests/RunCMake/find_file/PrefixInPATH-stdout-windows.txt
@@ -0,0 +1,4 @@
+-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
diff --git a/Tests/RunCMake/find_file/PrefixInPATH-stdout.txt b/Tests/RunCMake/find_file/PrefixInPATH-stdout.txt
index d73bc1dfd..947a9003f 100644
--- a/Tests/RunCMake/find_file/PrefixInPATH-stdout.txt
+++ b/Tests/RunCMake/find_file/PrefixInPATH-stdout.txt
@@ -1,4 +1,4 @@
-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
--- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
--- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
--- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
+-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
+-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
diff --git a/Tests/RunCMake/find_file/RunCMakeTest.cmake b/Tests/RunCMake/find_file/RunCMakeTest.cmake
index 5ce96e0e8..9f56a570f 100644
--- a/Tests/RunCMake/find_file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_file/RunCMakeTest.cmake
@@ -1,5 +1,5 @@
include(RunCMake)
-if(WIN32 OR CYGWIN)
- run_cmake(PrefixInPATH)
-endif()
+run_cmake(FromPATHEnv)
+run_cmake(FromPrefixPath)
+run_cmake(PrefixInPATH)
diff --git a/Tests/RunCMake/find_library/FromPATHEnv-stdout-cygwin.txt b/Tests/RunCMake/find_library/FromPATHEnv-stdout-cygwin.txt
new file mode 100644
index 000000000..01e272050
--- /dev/null
+++ b/Tests/RunCMake/find_library/FromPATHEnv-stdout-cygwin.txt
@@ -0,0 +1,6 @@
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnv-build/lib/libcreated.a'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnv-build/lib/libcreated.a'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
diff --git a/Tests/RunCMake/find_library/FromPATHEnv-stdout-windows.txt b/Tests/RunCMake/find_library/FromPATHEnv-stdout-windows.txt
new file mode 100644
index 000000000..01e272050
--- /dev/null
+++ b/Tests/RunCMake/find_library/FromPATHEnv-stdout-windows.txt
@@ -0,0 +1,6 @@
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnv-build/lib/libcreated.a'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnv-build/lib/libcreated.a'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
diff --git a/Tests/RunCMake/find_library/FromPATHEnv-stdout.txt b/Tests/RunCMake/find_library/FromPATHEnv-stdout.txt
new file mode 100644
index 000000000..4e570a6de
--- /dev/null
+++ b/Tests/RunCMake/find_library/FromPATHEnv-stdout.txt
@@ -0,0 +1,6 @@
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnv-build/lib/libcreated.a'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
diff --git a/Tests/RunCMake/find_library/FromPATHEnv.cmake b/Tests/RunCMake/find_library/FromPATHEnv.cmake
new file mode 100644
index 000000000..fec041d3e
--- /dev/null
+++ b/Tests/RunCMake/find_library/FromPATHEnv.cmake
@@ -0,0 +1,22 @@
+list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib)
+list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a)
+set(ENV_PATH "$ENV{PATH}")
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib/libcreated.a" "created")
+
+foreach(path "/does_not_exist" "/lib" "")
+ unset(CREATED_LIBRARY CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}${path}")
+ find_library(CREATED_LIBRARY NAMES created)
+ message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+foreach(path "/does_not_exist" "/lib" "")
+ unset(CREATED_LIBRARY CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}${path}")
+ find_library(CREATED_LIBRARY NAMES created)
+ message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")
+endforeach()
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
+set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_library/FromPrefixPath-stdout.txt b/Tests/RunCMake/find_library/FromPrefixPath-stdout.txt
new file mode 100644
index 000000000..de3df1a22
--- /dev/null
+++ b/Tests/RunCMake/find_library/FromPrefixPath-stdout.txt
@@ -0,0 +1,6 @@
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPrefixPath-build/lib/libcreated.a'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPrefixPath-build/lib/libcreated.a'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
diff --git a/Tests/RunCMake/find_library/FromPrefixPath.cmake b/Tests/RunCMake/find_library/FromPrefixPath.cmake
new file mode 100644
index 000000000..04763a942
--- /dev/null
+++ b/Tests/RunCMake/find_library/FromPrefixPath.cmake
@@ -0,0 +1,24 @@
+list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib)
+list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a)
+set(ENV_PATH "$ENV{PATH}")
+set(ENV{PATH} "")
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib/libcreated.a" "created")
+
+foreach(path "/does_not_exist" "/lib" "")
+ unset(CREATED_LIBRARY CACHE)
+ set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_BINARY_DIR}${path}")
+ find_library(CREATED_LIBRARY NAMES created)
+ message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")
+endforeach()
+
+set(CMAKE_FIND_USE_CMAKE_PATH OFF)
+set(CMAKE_PREFIX_PATH )
+foreach(path "/does_not_exist" "/lib" "")
+ unset(CREATED_LIBRARY CACHE)
+ set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_BINARY_DIR}${path}")
+ find_library(CREATED_LIBRARY NAMES created)
+ message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")
+endforeach()
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
+set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_library/PrefixInPATH-stdout-cygwin.txt b/Tests/RunCMake/find_library/PrefixInPATH-stdout-cygwin.txt
new file mode 100644
index 000000000..1ab884cb7
--- /dev/null
+++ b/Tests/RunCMake/find_library/PrefixInPATH-stdout-cygwin.txt
@@ -0,0 +1,4 @@
+-- PrefixInPATH_LIBRARY='PrefixInPATH_LIBRARY-NOTFOUND'
+-- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a'
+-- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a'
+-- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a'
diff --git a/Tests/RunCMake/find_library/PrefixInPATH-stdout-windows.txt b/Tests/RunCMake/find_library/PrefixInPATH-stdout-windows.txt
new file mode 100644
index 000000000..1ab884cb7
--- /dev/null
+++ b/Tests/RunCMake/find_library/PrefixInPATH-stdout-windows.txt
@@ -0,0 +1,4 @@
+-- PrefixInPATH_LIBRARY='PrefixInPATH_LIBRARY-NOTFOUND'
+-- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a'
+-- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a'
+-- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a'
diff --git a/Tests/RunCMake/find_library/PrefixInPATH-stdout.txt b/Tests/RunCMake/find_library/PrefixInPATH-stdout.txt
index 1ab884cb7..c6ff51374 100644
--- a/Tests/RunCMake/find_library/PrefixInPATH-stdout.txt
+++ b/Tests/RunCMake/find_library/PrefixInPATH-stdout.txt
@@ -1,4 +1,4 @@
-- PrefixInPATH_LIBRARY='PrefixInPATH_LIBRARY-NOTFOUND'
--- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a'
--- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a'
--- PrefixInPATH_LIBRARY='.*/Tests/RunCMake/find_library/lib/libPrefixInPATH.a'
+-- PrefixInPATH_LIBRARY='PrefixInPATH_LIBRARY-NOTFOUND'
+-- PrefixInPATH_LIBRARY='PrefixInPATH_LIBRARY-NOTFOUND'
+-- PrefixInPATH_LIBRARY='PrefixInPATH_LIBRARY-NOTFOUND'
diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake
index e7e8db39a..643a5b9b4 100644
--- a/Tests/RunCMake/find_library/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake
@@ -1,9 +1,9 @@
include(RunCMake)
run_cmake(Created)
+run_cmake(FromPrefixPath)
+run_cmake(FromPATHEnv)
if(CMAKE_HOST_UNIX)
run_cmake(LibArchLink)
endif()
-if(WIN32 OR CYGWIN)
- run_cmake(PrefixInPATH)
-endif()
+run_cmake(PrefixInPATH)
diff --git a/Tests/RunCMake/find_package/CMP0074-OLD-stderr.txt b/Tests/RunCMake/find_package/CMP0074-OLD-stderr.txt
new file mode 100644
index 000000000..4c2e5171d
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0074-OLD-stderr.txt
@@ -0,0 +1,12 @@
+----------
+Foo_ROOT :<base>/foo/cmake_root
+ENV{Foo_ROOT} :<base>/foo/env_root
+
+find_package\(Foo\)
+FOO_TEST_FILE_FOO :FOO_TEST_FILE_FOO-NOTFOUND
+FOO_TEST_FILE_ZOT :FOO_TEST_FILE_ZOT-NOTFOUND
+FOO_TEST_PATH_FOO :FOO_TEST_PATH_FOO-NOTFOUND
+FOO_TEST_PATH_ZOT :FOO_TEST_PATH_ZOT-NOTFOUND
+FOO_TEST_PROG_FOO :FOO_TEST_PROG_FOO-NOTFOUND
+
+----------
diff --git a/Tests/RunCMake/find_package/CMP0074-OLD.cmake b/Tests/RunCMake/find_package/CMP0074-OLD.cmake
new file mode 100644
index 000000000..435831702
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0074-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0074 OLD)
+include(CMP0074-common.cmake)
diff --git a/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt b/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt
new file mode 100644
index 000000000..fc08163cd
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0074-WARN-stderr.txt
@@ -0,0 +1,32 @@
+----------
+Foo_ROOT :<base>/foo/cmake_root
+ENV{Foo_ROOT} :<base>/foo/env_root
++
+CMake Warning \(dev\) at CMP0074-common.cmake:[0-9]+ \(find_package\):
+ Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
+ Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy
+ command to set the policy and suppress this warning.
+
+ CMake variable Foo_ROOT is set to:
+
+ .*/Tests/RunCMake/find_package/PackageRoot/foo/cmake_root
+
+ Environment variable Foo_ROOT is set to:
+
+ .*/Tests/RunCMake/find_package/PackageRoot/foo/env_root
+
+ For compatibility, CMake is ignoring the variable.
+Call Stack \(most recent call first\):
+ CMP0074-common.cmake:[0-9]+ \(RunPackageRootTest\)
+ CMP0074-WARN.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
++
+find_package\(Foo\)
+FOO_TEST_FILE_FOO :FOO_TEST_FILE_FOO-NOTFOUND
+FOO_TEST_FILE_ZOT :FOO_TEST_FILE_ZOT-NOTFOUND
+FOO_TEST_PATH_FOO :FOO_TEST_PATH_FOO-NOTFOUND
+FOO_TEST_PATH_ZOT :FOO_TEST_PATH_ZOT-NOTFOUND
+FOO_TEST_PROG_FOO :FOO_TEST_PROG_FOO-NOTFOUND
+
+----------
diff --git a/Tests/RunCMake/find_package/CMP0074-WARN.cmake b/Tests/RunCMake/find_package/CMP0074-WARN.cmake
new file mode 100644
index 000000000..0d4ada78c
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0074-WARN.cmake
@@ -0,0 +1,2 @@
+# (do not set CMP0074)
+include(CMP0074-common.cmake)
diff --git a/Tests/RunCMake/find_package/CMP0074-common.cmake b/Tests/RunCMake/find_package/CMP0074-common.cmake
new file mode 100644
index 000000000..bfacd82c4
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0074-common.cmake
@@ -0,0 +1,46 @@
+# (includer selects CMP0074)
+cmake_policy(SET CMP0057 NEW)
+list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot)
+set(PackageRoot_BASE ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot)
+
+function(PrintPath label path)
+ string(REPLACE "${PackageRoot_BASE}" "<base>" out "${path}")
+ message("${label}${out}")
+endfunction()
+
+macro(CleanUpPackageRootTest)
+ unset(Foo_ROOT)
+ unset(ENV{Foo_ROOT})
+ unset(FOO_TEST_FILE_FOO)
+ unset(FOO_TEST_FILE_ZOT)
+ unset(FOO_TEST_PATH_FOO)
+ unset(FOO_TEST_PATH_ZOT)
+ unset(FOO_TEST_PROG_FOO)
+ unset(FOO_TEST_FILE_FOO CACHE)
+ unset(FOO_TEST_FILE_ZOT CACHE)
+ unset(FOO_TEST_PATH_FOO CACHE)
+ unset(FOO_TEST_PATH_ZOT CACHE)
+ unset(FOO_TEST_PROG_FOO CACHE)
+endmacro()
+
+macro(RunPackageRootTest)
+ message("----------")
+ PrintPath("Foo_ROOT :" "${Foo_ROOT}")
+ PrintPath("ENV{Foo_ROOT} :" "$ENV{Foo_ROOT}")
+ message("")
+
+ find_package(Foo)
+ message("find_package(Foo)")
+ PrintPath("FOO_TEST_FILE_FOO :" "${FOO_TEST_FILE_FOO}")
+ PrintPath("FOO_TEST_FILE_ZOT :" "${FOO_TEST_FILE_ZOT}")
+ PrintPath("FOO_TEST_PATH_FOO :" "${FOO_TEST_PATH_FOO}")
+ PrintPath("FOO_TEST_PATH_ZOT :" "${FOO_TEST_PATH_ZOT}")
+ PrintPath("FOO_TEST_PROG_FOO :" "${FOO_TEST_PROG_FOO}")
+ CleanUpPackageRootTest()
+ message("")
+endmacro()
+
+set(Foo_ROOT ${PackageRoot_BASE}/foo/cmake_root)
+set(ENV{Foo_ROOT} ${PackageRoot_BASE}/foo/env_root)
+RunPackageRootTest()
+message("----------")
diff --git a/Tests/RunCMake/find_package/CMP0084-NEW-stderr.txt b/Tests/RunCMake/find_package/CMP0084-NEW-stderr.txt
new file mode 100644
index 000000000..280ff8c30
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0084-NEW-stderr.txt
@@ -0,0 +1,20 @@
+^CMake Warning at CMP0084-NEW\.cmake:[0-9]+ \(find_package\):
+ No "FindQt\.cmake" found in CMAKE_MODULE_PATH\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:3 \(include\)
++
+CMake Warning \(dev\) at CMP0084-NEW\.cmake:[0-9]+ \(find_package\):
+ FindQt\.cmake must either be part of this project itself, in this case
+ adjust CMAKE_MODULE_PATH so that it points to the correct location inside
+ its source tree\.
+
+ Or it must be installed by a package which has already been found via
+ find_package\(\)\. In this case make sure that package has indeed been found
+ and adjust CMAKE_MODULE_PATH to contain the location where that package has
+ installed FindQt\.cmake\. This must be a location provided by that package\.
+ This error in general means that the buildsystem of this project is relying
+ on a Find-module without ensuring that it is actually available\.
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\. Use -Wno-dev to suppress it\.$
diff --git a/Tests/RunCMake/find_package/CMP0084-NEW.cmake b/Tests/RunCMake/find_package/CMP0084-NEW.cmake
new file mode 100644
index 000000000..68fd6cff6
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0084-NEW.cmake
@@ -0,0 +1,7 @@
+cmake_policy(SET CMP0084 NEW)
+set(_findqt_testing TRUE)
+find_package(Qt MODULE)
+
+if(_findqt_included)
+ message(FATAL_ERROR "FindQt.cmake erroneously included")
+endif()
diff --git a/Tests/RunCMake/find_package/CMP0084-OLD.cmake b/Tests/RunCMake/find_package/CMP0084-OLD.cmake
new file mode 100644
index 000000000..7bd472653
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0084-OLD.cmake
@@ -0,0 +1,7 @@
+cmake_policy(SET CMP0084 OLD)
+set(_findqt_testing TRUE)
+find_package(Qt MODULE)
+
+if(NOT _findqt_included)
+ message(FATAL_ERROR "FindQt.cmake not included")
+endif()
diff --git a/Tests/RunCMake/find_package/CMP0084-WARN-stderr.txt b/Tests/RunCMake/find_package/CMP0084-WARN-stderr.txt
new file mode 100644
index 000000000..9ecebd3c7
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0084-WARN-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Warning \(dev\) at CMP0084-WARN\.cmake:[0-9]+ \(find_package\):
+ Policy CMP0084 is not set: The FindQt module does not exist for
+ find_package\(\)\. Run "cmake --help-policy CMP0084" for policy details\. Use
+ the cmake_policy command to set the policy and suppress this warning\.
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\. Use -Wno-dev to suppress it\.$
diff --git a/Tests/RunCMake/find_package/CMP0084-WARN.cmake b/Tests/RunCMake/find_package/CMP0084-WARN.cmake
new file mode 100644
index 000000000..4ea22cb5c
--- /dev/null
+++ b/Tests/RunCMake/find_package/CMP0084-WARN.cmake
@@ -0,0 +1,6 @@
+set(_findqt_testing TRUE)
+find_package(Qt MODULE)
+
+if(NOT _findqt_included)
+ message(FATAL_ERROR "FindQt.cmake not included")
+endif()
diff --git a/Tests/RunCMake/find_package/FromPATHEnv-stdout.txt b/Tests/RunCMake/find_package/FromPATHEnv-stdout.txt
new file mode 100644
index 000000000..2ead34911
--- /dev/null
+++ b/Tests/RunCMake/find_package/FromPATHEnv-stdout.txt
@@ -0,0 +1,9 @@
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='1'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
diff --git a/Tests/RunCMake/find_package/FromPATHEnv.cmake b/Tests/RunCMake/find_package/FromPATHEnv.cmake
new file mode 100644
index 000000000..4822b133d
--- /dev/null
+++ b/Tests/RunCMake/find_package/FromPATHEnv.cmake
@@ -0,0 +1,27 @@
+set(ENV_PATH "$ENV{PATH}")
+foreach(path "/does_not_exist" "/PackageRoot" "")
+ unset(Resolved_FOUND CACHE)
+ set(Resolved_DIR "")
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_package(Resolved QUIET)
+ message(STATUS "Resolved_FOUND='${Resolved_FOUND}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+foreach(path "/does_not_exist" "/PackageRoot" "")
+ unset(Resolved_FOUND CACHE)
+ set(Resolved_DIR "")
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_package(Resolved QUIET)
+ message(STATUS "Resolved_FOUND='${Resolved_FOUND}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
+foreach(path "/does_not_exist" "/PackageRoot" "")
+ unset(Resolved_FOUND CACHE)
+ set(Resolved_DIR "")
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_package(Resolved NO_SYSTEM_ENVIRONMENT_PATH QUIET)
+ message(STATUS "Resolved_FOUND='${Resolved_FOUND}'")
+endforeach()
+set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_package/FromPrefixPath-stdout.txt b/Tests/RunCMake/find_package/FromPrefixPath-stdout.txt
new file mode 100644
index 000000000..2ead34911
--- /dev/null
+++ b/Tests/RunCMake/find_package/FromPrefixPath-stdout.txt
@@ -0,0 +1,9 @@
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='1'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
diff --git a/Tests/RunCMake/find_package/FromPrefixPath.cmake b/Tests/RunCMake/find_package/FromPrefixPath.cmake
new file mode 100644
index 000000000..be853c118
--- /dev/null
+++ b/Tests/RunCMake/find_package/FromPrefixPath.cmake
@@ -0,0 +1,29 @@
+set(ENV_PATH "$ENV{PATH}")
+set(ENV{PATH} "")
+foreach(path "/does_not_exist" "/PackageRoot" "")
+ unset(Resolved_FOUND CACHE)
+ set(Resolved_DIR "")
+ set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_package(Resolved QUIET)
+ message(STATUS "Resolved_FOUND='${Resolved_FOUND}'")
+endforeach()
+
+set(CMAKE_FIND_USE_CMAKE_PATH OFF)
+set(CMAKE_PREFIX_PATH )
+foreach(path "/does_not_exist" "/PackageRoot" "")
+ unset(Resolved_FOUND CACHE)
+ set(Resolved_DIR "")
+ set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_package(Resolved QUIET)
+ message(STATUS "Resolved_FOUND='${Resolved_FOUND}'")
+endforeach()
+
+set(CMAKE_FIND_USE_CMAKE_PATH ON)
+foreach(path "/does_not_exist" "/PackageRoot" "")
+ unset(Resolved_FOUND CACHE)
+ set(Resolved_DIR "")
+ set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_package(Resolved NO_CMAKE_PATH QUIET)
+ message(STATUS "Resolved_FOUND='${Resolved_FOUND}'")
+endforeach()
+set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_package/PackageRoot.cmake b/Tests/RunCMake/find_package/PackageRoot.cmake
index 4c4f4c233..aa12e9b5f 100644
--- a/Tests/RunCMake/find_package/PackageRoot.cmake
+++ b/Tests/RunCMake/find_package/PackageRoot.cmake
@@ -1,5 +1,5 @@
-set(__UNDOCUMENTED_CMAKE_FIND_PACKAGE_ROOT 1)
cmake_policy(SET CMP0057 NEW)
+cmake_policy(SET CMP0074 NEW)
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot)
set(PackageRoot_BASE ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot)
diff --git a/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake
new file mode 100644
index 000000000..4496a051c
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake
@@ -0,0 +1 @@
+set(Resolved_DIR "${CMAKE_CURRENT_LIST_DIR}")
diff --git a/Tests/RunCMake/find_package/PackageRootNestedConfig.cmake b/Tests/RunCMake/find_package/PackageRootNestedConfig.cmake
index ba06c09ce..1ef32cbba 100644
--- a/Tests/RunCMake/find_package/PackageRootNestedConfig.cmake
+++ b/Tests/RunCMake/find_package/PackageRootNestedConfig.cmake
@@ -1,5 +1,5 @@
-set(__UNDOCUMENTED_CMAKE_FIND_PACKAGE_ROOT 1)
cmake_policy(SET CMP0057 NEW)
+cmake_policy(SET CMP0074 NEW)
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot)
set(PackageRoot_BASE ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot)
diff --git a/Tests/RunCMake/find_package/PackageRootNestedModule.cmake b/Tests/RunCMake/find_package/PackageRootNestedModule.cmake
index 2795cd48f..017834cd3 100644
--- a/Tests/RunCMake/find_package/PackageRootNestedModule.cmake
+++ b/Tests/RunCMake/find_package/PackageRootNestedModule.cmake
@@ -1,5 +1,5 @@
-set(__UNDOCUMENTED_CMAKE_FIND_PACKAGE_ROOT 1)
cmake_policy(SET CMP0057 NEW)
+cmake_policy(SET CMP0074 NEW)
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot)
set(PackageRoot_BASE ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot)
diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake
index d548da027..208f83c91 100644
--- a/Tests/RunCMake/find_package/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake
@@ -1,6 +1,10 @@
include(RunCMake)
+run_cmake(CMP0074-WARN)
+run_cmake(CMP0074-OLD)
run_cmake(ComponentRequiredAndOptional)
+run_cmake(FromPATHEnv)
+run_cmake(FromPrefixPath)
run_cmake(MissingNormal)
run_cmake(MissingNormalRequired)
run_cmake(MissingNormalVersion)
@@ -21,3 +25,9 @@ run_cmake(PolicyPop)
run_cmake(SetFoundFALSE)
run_cmake(WrongVersion)
run_cmake(WrongVersionConfig)
+run_cmake(CMP0084-OLD)
+run_cmake(CMP0084-WARN)
+run_cmake(CMP0084-NEW)
+if(UNIX)
+ run_cmake(SetFoundResolved)
+endif()
diff --git a/Tests/RunCMake/find_package/SetFoundResolved-stderr.txt b/Tests/RunCMake/find_package/SetFoundResolved-stderr.txt
new file mode 100644
index 000000000..ea94be5a9
--- /dev/null
+++ b/Tests/RunCMake/find_package/SetFoundResolved-stderr.txt
@@ -0,0 +1,10 @@
+CMake Warning at SetFoundResolved.cmake:10 \(message\):
+ .*/Tests/RunCMake/find_package/symlink
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Warning at SetFoundResolved.cmake:15 \(message\):
+ .*/Tests/RunCMake/find_package/PackageRoot
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/find_package/SetFoundResolved.cmake b/Tests/RunCMake/find_package/SetFoundResolved.cmake
new file mode 100644
index 000000000..8d5651357
--- /dev/null
+++ b/Tests/RunCMake/find_package/SetFoundResolved.cmake
@@ -0,0 +1,17 @@
+# Create ./symlink pointing back here.
+execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
+ PackageRoot "${CMAKE_CURRENT_SOURCE_DIR}/symlink")
+
+# Make find_package search through the symlink.
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/symlink")
+
+# Test preservation of symlinks.
+find_package(Resolved)
+message(WARNING "${Resolved_DIR}")
+
+# Test resolving symlinks.
+set(CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS ON)
+find_package(Resolved)
+message(WARNING "${Resolved_DIR}")
+
+file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/symlink")
diff --git a/Tests/RunCMake/find_path/EmptyOldStyle-stdout.txt b/Tests/RunCMake/find_path/EmptyOldStyle-stdout.txt
new file mode 100644
index 000000000..8f21eb85c
--- /dev/null
+++ b/Tests/RunCMake/find_path/EmptyOldStyle-stdout.txt
@@ -0,0 +1 @@
+-- VAR-NOTFOUND
diff --git a/Tests/RunCMake/find_path/EmptyOldStyle.cmake b/Tests/RunCMake/find_path/EmptyOldStyle.cmake
new file mode 100644
index 000000000..d78bb65e0
--- /dev/null
+++ b/Tests/RunCMake/find_path/EmptyOldStyle.cmake
@@ -0,0 +1,2 @@
+find_path(VAR ONLY_CMAKE_FIND_ROOT_PATH)
+message(STATUS "${VAR}")
diff --git a/Tests/RunCMake/find_path/FromPATHEnv-stdout-cygwin.txt b/Tests/RunCMake/find_path/FromPATHEnv-stdout-cygwin.txt
new file mode 100644
index 000000000..8f3e7ca5f
--- /dev/null
+++ b/Tests/RunCMake/find_path/FromPATHEnv-stdout-cygwin.txt
@@ -0,0 +1,9 @@
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include'
+-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
diff --git a/Tests/RunCMake/find_path/FromPATHEnv-stdout-windows.txt b/Tests/RunCMake/find_path/FromPATHEnv-stdout-windows.txt
new file mode 100644
index 000000000..8f3e7ca5f
--- /dev/null
+++ b/Tests/RunCMake/find_path/FromPATHEnv-stdout-windows.txt
@@ -0,0 +1,9 @@
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include'
+-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
diff --git a/Tests/RunCMake/find_path/FromPATHEnv-stdout.txt b/Tests/RunCMake/find_path/FromPATHEnv-stdout.txt
new file mode 100644
index 000000000..fd41bf415
--- /dev/null
+++ b/Tests/RunCMake/find_path/FromPATHEnv-stdout.txt
@@ -0,0 +1,9 @@
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH-NOTFOUND'
diff --git a/Tests/RunCMake/find_path/FromPATHEnv.cmake b/Tests/RunCMake/find_path/FromPATHEnv.cmake
new file mode 100644
index 000000000..af13d09fa
--- /dev/null
+++ b/Tests/RunCMake/find_path/FromPATHEnv.cmake
@@ -0,0 +1,25 @@
+set(ENV_PATH "$ENV{PATH}")
+foreach(path "/does_not_exist" "/include" "")
+ unset(PATH_IN_ENV_PATH CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h)
+ message(STATUS "PATH_IN_ENV_PATH='${PATH_IN_ENV_PATH}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+foreach(path "/does_not_exist" "/include" "")
+ unset(PATH_IN_ENV_PATH CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h)
+ message(STATUS "PATH_IN_ENV_PATH='${PATH_IN_ENV_PATH}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
+foreach(path "/does_not_exist" "/include" "")
+ unset(PATH_IN_ENV_PATH CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h NO_SYSTEM_ENVIRONMENT_PATH)
+ message(STATUS "PATH_IN_ENV_PATH='${PATH_IN_ENV_PATH}'")
+endforeach()
+
+set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_path/PrefixInPATH-stdout-cygwin.txt b/Tests/RunCMake/find_path/PrefixInPATH-stdout-cygwin.txt
new file mode 100644
index 000000000..bb2ceb725
--- /dev/null
+++ b/Tests/RunCMake/find_path/PrefixInPATH-stdout-cygwin.txt
@@ -0,0 +1,4 @@
+-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include'
diff --git a/Tests/RunCMake/find_path/PrefixInPATH-stdout-windows.txt b/Tests/RunCMake/find_path/PrefixInPATH-stdout-windows.txt
new file mode 100644
index 000000000..bb2ceb725
--- /dev/null
+++ b/Tests/RunCMake/find_path/PrefixInPATH-stdout-windows.txt
@@ -0,0 +1,4 @@
+-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include'
+-- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include'
diff --git a/Tests/RunCMake/find_path/PrefixInPATH-stdout.txt b/Tests/RunCMake/find_path/PrefixInPATH-stdout.txt
index bb2ceb725..947a9003f 100644
--- a/Tests/RunCMake/find_path/PrefixInPATH-stdout.txt
+++ b/Tests/RunCMake/find_path/PrefixInPATH-stdout.txt
@@ -1,4 +1,4 @@
-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
--- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include'
--- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include'
--- PrefixInPATH_INCLUDE_DIR='.*/Tests/RunCMake/find_path/include'
+-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
+-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
+-- PrefixInPATH_INCLUDE_DIR='PrefixInPATH_INCLUDE_DIR-NOTFOUND'
diff --git a/Tests/RunCMake/find_path/RunCMakeTest.cmake b/Tests/RunCMake/find_path/RunCMakeTest.cmake
index bf0fa8951..ed55f5107 100644
--- a/Tests/RunCMake/find_path/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_path/RunCMakeTest.cmake
@@ -1,8 +1,8 @@
include(RunCMake)
-if(WIN32 OR CYGWIN)
- run_cmake(PrefixInPATH)
-endif()
+run_cmake(EmptyOldStyle)
+run_cmake(FromPATHEnv)
+run_cmake(PrefixInPATH)
if(APPLE)
run_cmake(FrameworksWithSubdirs)
diff --git a/Tests/RunCMake/find_program/EnvAndHints-stdout.txt b/Tests/RunCMake/find_program/EnvAndHints-stdout.txt
index 39329b22e..0051636d3 100644
--- a/Tests/RunCMake/find_program/EnvAndHints-stdout.txt
+++ b/Tests/RunCMake/find_program/EnvAndHints-stdout.txt
@@ -1 +1,4 @@
-- PROG='[^']*/Tests/RunCMake/find_program/A/testAandB'
+-- PROG='PROG-NOTFOUND'
+-- PROG='[^']*/Tests/RunCMake/find_program/B/testAandB'
+-- PROG='[^']*/Tests/RunCMake/find_program/A/testAandB'
diff --git a/Tests/RunCMake/find_program/EnvAndHints.cmake b/Tests/RunCMake/find_program/EnvAndHints.cmake
index 14ebd6e2f..0f12effc0 100644
--- a/Tests/RunCMake/find_program/EnvAndHints.cmake
+++ b/Tests/RunCMake/find_program/EnvAndHints.cmake
@@ -1,8 +1,31 @@
+
set(ENV_PATH "$ENV{PATH}")
set(ENV{PATH} ${CMAKE_CURRENT_SOURCE_DIR}/A)
find_program(PROG
NAMES testAandB
+ )
+message(STATUS "PROG='${PROG}'")
+unset(PROG CACHE)
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+find_program(PROG
+ NAMES testAandB
+ )
+message(STATUS "PROG='${PROG}'")
+unset(PROG CACHE)
+
+find_program(PROG
+ NAMES testAandB
+ HINTS ${CMAKE_CURRENT_SOURCE_DIR}/B ${CMAKE_CURRENT_SOURCE_DIR}/A
+ )
+message(STATUS "PROG='${PROG}'")
+unset(PROG CACHE)
+set(ENV{PATH} "${ENV_PATH}")
+
+find_program(PROG
+ NAMES testAandB
HINTS ${CMAKE_CURRENT_SOURCE_DIR}/A ${CMAKE_CURRENT_SOURCE_DIR}/B
)
message(STATUS "PROG='${PROG}'")
+unset(PROG CACHE)
set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_program/RelAndAbsPath-stdout.txt b/Tests/RunCMake/find_program/RelAndAbsPath-stdout.txt
new file mode 100644
index 000000000..d2312e7af
--- /dev/null
+++ b/Tests/RunCMake/find_program/RelAndAbsPath-stdout.txt
@@ -0,0 +1,8 @@
+-- PROG_ABS='PROG_ABS-NOTFOUND'
+-- PROG_ABS_NPD='PROG_ABS_NPD-NOTFOUND'
+-- PROG_CWD='PROG_CWD-NOTFOUND'
+-- PROG_CWD='PROG_CWD-NOTFOUND'
+-- PROG_CWD='[^']*/Tests/RunCMake/find_program/testCWD'
+-- PROG_CWD_NPD='PROG_CWD_NPD-NOTFOUND'
+-- PROG_CWD_DOT='[^']*/Tests/RunCMake/find_program/testCWD'
+-- PROG_CWD_DOT_NPD='[^']*/Tests/RunCMake/find_program/testCWD'
diff --git a/Tests/RunCMake/find_program/RelAndAbsPath.cmake b/Tests/RunCMake/find_program/RelAndAbsPath.cmake
new file mode 100644
index 000000000..6b61980f3
--- /dev/null
+++ b/Tests/RunCMake/find_program/RelAndAbsPath.cmake
@@ -0,0 +1,84 @@
+# testNoSuchFile should only be found if the file absolute path is
+# incorrectly prepended with the search path.
+
+function(strip_windows_path_prefix p outvar)
+ if(CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
+ string(REGEX REPLACE "^.:" "" p "${p}")
+ endif()
+ set(${outvar} "${p}" PARENT_SCOPE)
+endfunction()
+
+strip_windows_path_prefix("${CMAKE_CURRENT_SOURCE_DIR}" srcdir)
+
+configure_file(testCWD "tmp${srcdir}/testNoSuchFile" COPYONLY)
+
+find_program(PROG_ABS
+ NAMES "${srcdir}/testNoSuchFile"
+ PATHS "${CMAKE_CURRENT_BINARY_DIR}/tmp"
+ NO_DEFAULT_PATH
+ )
+message(STATUS "PROG_ABS='${PROG_ABS}'")
+
+find_program(PROG_ABS_NPD
+ NAMES "${srcdir}/testNoSuchFile"
+ PATHS "${CMAKE_CURRENT_BINARY_DIR}/tmp"
+ NAMES_PER_DIR
+ NO_DEFAULT_PATH
+ )
+message(STATUS "PROG_ABS_NPD='${PROG_ABS_NPD}'")
+
+# ./testCWD should not be found without '.' being in the path list.
+
+configure_file(testCWD testCWD COPYONLY)
+
+find_program(PROG_CWD
+ NAMES testCWD
+ NO_DEFAULT_PATH
+ )
+message(STATUS "PROG_CWD='${PROG_CWD}'")
+
+
+set(CMAKE_PREFIX_PATH ".")
+# On some platforms / dashboards the current working
+# directory can be in PATH or other search locations
+# so disable all searching to make sure this fails
+set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH OFF)
+set(CMAKE_FIND_USE_CMAKE_PATH OFF)
+set(CMAKE_FIND_USE_CMAKE_SYSTEM_PATH OFF)
+set(CMAKE_FIND_USE_PACKAGE_ROOT_PATH OFF)
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+find_program(PROG_CWD
+ NAMES testCWD
+ )
+message(STATUS "PROG_CWD='${PROG_CWD}'")
+
+set(CMAKE_PREFIX_PATH ".")
+set(CMAKE_FIND_USE_CMAKE_PATH ON)
+find_program(PROG_CWD
+ NAMES testCWD
+ )
+message(STATUS "PROG_CWD='${PROG_CWD}'")
+
+find_program(PROG_CWD_NPD
+ NAMES testCWD
+ NAMES_PER_DIR
+ NO_DEFAULT_PATH
+ )
+message(STATUS "PROG_CWD_NPD='${PROG_CWD_NPD}'")
+
+# Confirm that adding '.' to path does locate ./testCWD.
+
+find_program(PROG_CWD_DOT
+ NAMES testCWD
+ PATHS .
+ NO_DEFAULT_PATH
+ )
+message(STATUS "PROG_CWD_DOT='${PROG_CWD_DOT}'")
+
+find_program(PROG_CWD_DOT_NPD
+ NAMES testCWD
+ PATHS .
+ NAMES_PER_DIR
+ NO_DEFAULT_PATH
+ )
+message(STATUS "PROG_CWD_DOT_NPD='${PROG_CWD_DOT_NPD}'")
diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake
index 89307c1ae..6903f057b 100644
--- a/Tests/RunCMake/find_program/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake
@@ -3,6 +3,7 @@ include(RunCMake)
run_cmake(EnvAndHints)
run_cmake(DirsPerName)
run_cmake(NamesPerDir)
+run_cmake(RelAndAbsPath)
if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN)$")
run_cmake(WindowsCom)
diff --git a/Tests/RunCMake/find_program/testCWD b/Tests/RunCMake/find_program/testCWD
new file mode 100755
index 000000000..1a2485251
--- /dev/null
+++ b/Tests/RunCMake/find_program/testCWD
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/Tests/RunCMake/foreach/BadRangeInFunction-result.txt b/Tests/RunCMake/foreach/BadRangeInFunction-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/foreach/BadRangeInFunction-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/foreach/BadRangeInFunction-stderr.txt b/Tests/RunCMake/foreach/BadRangeInFunction-stderr.txt
new file mode 100644
index 000000000..e16a0f15b
--- /dev/null
+++ b/Tests/RunCMake/foreach/BadRangeInFunction-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at BadRangeInFunction.cmake:2 \(foreach\):
+ foreach called with incorrect range specification: start 2, stop 1, step 1
+Call Stack \(most recent call first\):
+ BadRangeInFunction.cmake:5 \(func\)
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/foreach/BadRangeInFunction.cmake b/Tests/RunCMake/foreach/BadRangeInFunction.cmake
new file mode 100644
index 000000000..f51cbbf11
--- /dev/null
+++ b/Tests/RunCMake/foreach/BadRangeInFunction.cmake
@@ -0,0 +1,5 @@
+function(func)
+ foreach(bad_range RANGE 2 1 1)
+ endforeach()
+endfunction()
+func()
diff --git a/Tests/RunCMake/foreach/CMakeLists.txt b/Tests/RunCMake/foreach/CMakeLists.txt
new file mode 100644
index 000000000..bf2ef1506
--- /dev/null
+++ b/Tests/RunCMake/foreach/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.10)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/foreach/RunCMakeTest.cmake b/Tests/RunCMake/foreach/RunCMakeTest.cmake
new file mode 100644
index 000000000..4b74cfe49
--- /dev/null
+++ b/Tests/RunCMake/foreach/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(BadRangeInFunction)
diff --git a/Tests/RunCMake/get_filename_component/KnownComponents.cmake b/Tests/RunCMake/get_filename_component/KnownComponents.cmake
index 7dfb55d79..54b858f92 100644
--- a/Tests/RunCMake/get_filename_component/KnownComponents.cmake
+++ b/Tests/RunCMake/get_filename_component/KnownComponents.cmake
@@ -11,8 +11,10 @@ set(expect_DIRECTORY "/path/to")
set(expect_NAME "filename.ext.in")
set(expect_EXT ".ext.in")
set(expect_NAME_WE "filename")
+set(expect_LAST_EXT ".in")
+set(expect_NAME_WLE "filename.ext")
set(expect_PATH "/path/to")
-foreach(c DIRECTORY NAME EXT NAME_WE PATH)
+foreach(c DIRECTORY NAME EXT NAME_WE LAST_EXT NAME_WLE PATH)
get_filename_component(actual_${c} "${filename}" ${c})
check("${c}" "${actual_${c}}" "${expect_${c}}")
list(APPEND non_cache_vars actual_${c})
@@ -80,6 +82,17 @@ get_filename_component(test_program_name "/ arg1 arg2" PROGRAM
check("PROGRAM with args output: name" "${test_program_name}" "/")
check("PROGRAM with args output: args" "${test_program_args}" " arg1 arg2")
+get_filename_component(test_program_name " " PROGRAM)
+check("PROGRAM with just a space" "${test_program_name}" "")
+
+get_filename_component(test_program_name "${CMAKE_CURRENT_LIST_FILE}" PROGRAM)
+check("PROGRAM specified explicitly without quoting" "${test_program_name}" "${CMAKE_CURRENT_LIST_FILE}")
+
+get_filename_component(test_program_name "\"${CMAKE_CURRENT_LIST_FILE}\" arg1 arg2" PROGRAM
+ PROGRAM_ARGS test_program_args)
+check("PROGRAM specified explicitly with arguments: name" "${test_program_name}" "${CMAKE_CURRENT_LIST_FILE}")
+check("PROGRAM specified explicitly with arguments: args" "${test_program_args}" " arg1 arg2")
+
list(APPEND non_cache_vars test_program_name)
list(APPEND non_cache_vars test_program_args)
diff --git a/Tests/RunCMake/get_property/BadArgument-stderr.txt b/Tests/RunCMake/get_property/BadArgument-stderr.txt
index 37c44775c..ce5a20923 100644
--- a/Tests/RunCMake/get_property/BadArgument-stderr.txt
+++ b/Tests/RunCMake/get_property/BadArgument-stderr.txt
@@ -1,4 +1,4 @@
^CMake Error at BadArgument.cmake:1 \(get_property\):
get_property given invalid argument "FOO".
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/get_property/BadDirectory-stderr.txt b/Tests/RunCMake/get_property/BadDirectory-stderr.txt
index 98464f8dc..6afec038a 100644
--- a/Tests/RunCMake/get_property/BadDirectory-stderr.txt
+++ b/Tests/RunCMake/get_property/BadDirectory-stderr.txt
@@ -3,4 +3,4 @@
found. This could be because the directory argument was invalid or, it is
valid but has not been processed yet.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/get_property/BadScope-stderr.txt b/Tests/RunCMake/get_property/BadScope-stderr.txt
index 4cc32c87b..3084bb7fd 100644
--- a/Tests/RunCMake/get_property/BadScope-stderr.txt
+++ b/Tests/RunCMake/get_property/BadScope-stderr.txt
@@ -2,4 +2,4 @@
get_property given invalid scope FOO. Valid scopes are GLOBAL, DIRECTORY,
TARGET, SOURCE, TEST, VARIABLE, CACHE, INSTALL.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/get_property/BadTarget-stderr.txt b/Tests/RunCMake/get_property/BadTarget-stderr.txt
index 45a0df6c9..e85711721 100644
--- a/Tests/RunCMake/get_property/BadTarget-stderr.txt
+++ b/Tests/RunCMake/get_property/BadTarget-stderr.txt
@@ -2,4 +2,4 @@
get_property could not find TARGET FOO. Perhaps it has not yet been
created.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/get_property/BadTest-stderr.txt b/Tests/RunCMake/get_property/BadTest-stderr.txt
index 819c0704a..aec9e9e9c 100644
--- a/Tests/RunCMake/get_property/BadTest-stderr.txt
+++ b/Tests/RunCMake/get_property/BadTest-stderr.txt
@@ -1,4 +1,4 @@
^CMake Error at BadTest.cmake:1 \(get_property\):
get_property given TEST name that does not exist: FOO
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/get_property/GlobalName-stderr.txt b/Tests/RunCMake/get_property/GlobalName-stderr.txt
index a7d4971c2..4ddceb257 100644
--- a/Tests/RunCMake/get_property/GlobalName-stderr.txt
+++ b/Tests/RunCMake/get_property/GlobalName-stderr.txt
@@ -1,4 +1,4 @@
^CMake Error at GlobalName.cmake:1 \(get_property\):
get_property given name for GLOBAL scope.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/get_property/MissingArgument-stderr.txt b/Tests/RunCMake/get_property/MissingArgument-stderr.txt
index 87227127a..00d3311af 100644
--- a/Tests/RunCMake/get_property/MissingArgument-stderr.txt
+++ b/Tests/RunCMake/get_property/MissingArgument-stderr.txt
@@ -1,4 +1,4 @@
^CMake Error at MissingArgument.cmake:1 \(get_property\):
get_property called with incorrect number of arguments
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/get_property/NoCache-stderr.txt b/Tests/RunCMake/get_property/NoCache-stderr.txt
index defafb62d..7348cffdb 100644
--- a/Tests/RunCMake/get_property/NoCache-stderr.txt
+++ b/Tests/RunCMake/get_property/NoCache-stderr.txt
@@ -1,4 +1,4 @@
^CMake Error at NoCache.cmake:1 \(get_property\):
get_property not given name for CACHE scope.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/get_property/NoProperty-stderr.txt b/Tests/RunCMake/get_property/NoProperty-stderr.txt
index 0ef147fdb..79b8c8702 100644
--- a/Tests/RunCMake/get_property/NoProperty-stderr.txt
+++ b/Tests/RunCMake/get_property/NoProperty-stderr.txt
@@ -1,4 +1,4 @@
^CMake Error at NoProperty.cmake:1 \(get_property\):
get_property not given a PROPERTY <name> argument.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/get_property/NoSource-stderr.txt b/Tests/RunCMake/get_property/NoSource-stderr.txt
index 59fd0add7..cefff4167 100644
--- a/Tests/RunCMake/get_property/NoSource-stderr.txt
+++ b/Tests/RunCMake/get_property/NoSource-stderr.txt
@@ -1,4 +1,4 @@
^CMake Error at NoSource.cmake:1 \(get_property\):
get_property not given name for SOURCE scope.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/get_property/NoTarget-stderr.txt b/Tests/RunCMake/get_property/NoTarget-stderr.txt
index a0e1a9440..fb1c8f4e8 100644
--- a/Tests/RunCMake/get_property/NoTarget-stderr.txt
+++ b/Tests/RunCMake/get_property/NoTarget-stderr.txt
@@ -1,4 +1,4 @@
^CMake Error at NoTarget.cmake:1 \(get_property\):
get_property not given name for TARGET scope.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/get_property/NoTest-stderr.txt b/Tests/RunCMake/get_property/NoTest-stderr.txt
index c90a0ffc2..93c3e9821 100644
--- a/Tests/RunCMake/get_property/NoTest-stderr.txt
+++ b/Tests/RunCMake/get_property/NoTest-stderr.txt
@@ -1,4 +1,4 @@
^CMake Error at NoTest.cmake:1 \(get_property\):
get_property not given name for TEST scope.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/get_property/RunCMakeTest.cmake b/Tests/RunCMake/get_property/RunCMakeTest.cmake
index 017990fa9..06a0c673c 100644
--- a/Tests/RunCMake/get_property/RunCMakeTest.cmake
+++ b/Tests/RunCMake/get_property/RunCMakeTest.cmake
@@ -23,6 +23,10 @@ run_cmake(NoSource)
run_cmake(NoProperty)
run_cmake(NoCache)
+# Since we are testing the GENERATOR_IS_MULTI_CONFIG property itself,
+# don't rely on RunCMake_GENERATOR_IS_MULTI_CONFIG being set correctly
+# and instead explicitly check for a match against those generators we
+# expect to be multi-config
if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode")
run_cmake(IsMultiConfig)
else()
diff --git a/Tests/RunCMake/get_property/VariableName-stderr.txt b/Tests/RunCMake/get_property/VariableName-stderr.txt
index e9f382759..250d920b4 100644
--- a/Tests/RunCMake/get_property/VariableName-stderr.txt
+++ b/Tests/RunCMake/get_property/VariableName-stderr.txt
@@ -1,4 +1,4 @@
^CMake Error at VariableName.cmake:1 \(get_property\):
get_property given name for VARIABLE scope.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/get_property/directory_properties-stderr.txt b/Tests/RunCMake/get_property/directory_properties-stderr.txt
index 6d5bcdb0d..89f5618ee 100644
--- a/Tests/RunCMake/get_property/directory_properties-stderr.txt
+++ b/Tests/RunCMake/get_property/directory_properties-stderr.txt
@@ -19,4 +19,12 @@ get_property: -->[^<;]*/Tests/RunCMake/get_property<--
get_directory_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build/directory_properties<--
get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties-build/directory_properties<--
get_directory_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties<--
-get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties<--$
+get_property: -->[^<;]*/Tests/RunCMake/get_property/directory_properties<--
+get_directory_property: --><--
+get_property: --><--
+get_directory_property: -->test1;test2<--
+get_property: -->test1;test2<--
+get_directory_property: -->test1;test2;test3<--
+get_property: -->test1;test2;test3<--
+get_directory_property: -->Sub/test1;Sub/test2<--
+get_property: -->Sub/test1;Sub/test2<--$
diff --git a/Tests/RunCMake/get_property/directory_properties.cmake b/Tests/RunCMake/get_property/directory_properties.cmake
index 4e68738d8..9b978fd50 100644
--- a/Tests/RunCMake/get_property/directory_properties.cmake
+++ b/Tests/RunCMake/get_property/directory_properties.cmake
@@ -28,3 +28,12 @@ check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" BINARY_DIR)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" SOURCE_DIR)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" BINARY_DIR)
check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" SOURCE_DIR)
+
+check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" TESTS)
+add_test(NAME test1 COMMAND "${CMAKE_COMMAND}" -E echo "test1")
+add_test(NAME test2 COMMAND "${CMAKE_COMMAND}" -E echo "test2")
+check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" TESTS)
+add_test(NAME test3 COMMAND "${CMAKE_COMMAND}" -E echo "test3")
+check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}" TESTS)
+
+check_directory_property("${CMAKE_CURRENT_SOURCE_DIR}/directory_properties" TESTS)
diff --git a/Tests/RunCMake/get_property/directory_properties/CMakeLists.txt b/Tests/RunCMake/get_property/directory_properties/CMakeLists.txt
index 7318b9777..95106adca 100644
--- a/Tests/RunCMake/get_property/directory_properties/CMakeLists.txt
+++ b/Tests/RunCMake/get_property/directory_properties/CMakeLists.txt
@@ -4,3 +4,6 @@ subdirs(sub2)
add_custom_target(CustomSub)
add_library(InterfaceSub INTERFACE)
add_library(my::InterfaceSub ALIAS InterfaceSub)
+
+add_test(Sub/test1 COMMAND "${CMAKE_COMMAND}" -E echo "Sub/test1")
+add_test(Sub/test2 COMMAND "${CMAKE_COMMAND}" -E echo "Sub/test2")
diff --git a/Tests/RunCMake/get_property/source_properties-stderr.txt b/Tests/RunCMake/get_property/source_properties-stderr.txt
index 0a46f96a0..00a9b8287 100644
--- a/Tests/RunCMake/get_property/source_properties-stderr.txt
+++ b/Tests/RunCMake/get_property/source_properties-stderr.txt
@@ -3,4 +3,10 @@ get_property: --><--
get_source_file_property: -->value<--
get_property: -->value<--
get_source_file_property: -->NOTFOUND<--
-get_property: --><--$
+get_property: --><--
+get_source_file_property: -->value<--
+get_property: -->value<--
+get_source_file_property: -->NOTFOUND<--
+get_property: --><--
+get_source_file_property: -->value<--
+get_property: -->value<--$
diff --git a/Tests/RunCMake/get_property/source_properties.cmake b/Tests/RunCMake/get_property/source_properties.cmake
index 263ffe123..12d2d0797 100644
--- a/Tests/RunCMake/get_property/source_properties.cmake
+++ b/Tests/RunCMake/get_property/source_properties.cmake
@@ -13,3 +13,13 @@ set_source_files_properties(file.c PROPERTIES empty "" custom value)
check_source_file_property(file.c empty)
check_source_file_property(file.c custom)
check_source_file_property(file.c noexist)
+
+# Test strange legacy behavior in which the order in which source files are
+# first accessed affects how properties are applied without an extension.
+# See also issue #15208.
+get_property(lang SOURCE ${CMAKE_CURRENT_BINARY_DIR}/file2.c PROPERTY LANGUAGE)
+get_property(lang SOURCE ${CMAKE_CURRENT_BINARY_DIR}/file2.h PROPERTY LANGUAGE)
+set_property(SOURCE file2 PROPERTY custom value) # set property without extension
+check_source_file_property(file2 custom) # should have property
+check_source_file_property(file2.h custom) # should not have property
+check_source_file_property(file2.c custom) # should have property
diff --git a/Tests/RunCMake/get_property/target_properties-stderr.txt b/Tests/RunCMake/get_property/target_properties-stderr.txt
index 6b3c6ca1b..df7a2f12c 100644
--- a/Tests/RunCMake/get_property/target_properties-stderr.txt
+++ b/Tests/RunCMake/get_property/target_properties-stderr.txt
@@ -7,4 +7,10 @@ get_property: --><--
get_target_property: -->(.*)/Tests/RunCMake/get_property<--
get_property: -->(.*)/Tests/RunCMake/get_property<--
get_target_property: -->(.*)/Tests/RunCMake/get_property/target_properties-build<--
-get_property: -->(.*)/Tests/RunCMake/get_property/target_properties-build<--$
+get_property: -->(.*)/Tests/RunCMake/get_property/target_properties-build<--
+get_target_property: -->FALSE<--
+get_property: -->FALSE<--
+get_target_property: -->FALSE<--
+get_property: -->FALSE<--
+get_target_property: -->TRUE<--
+get_property: -->TRUE<--$
diff --git a/Tests/RunCMake/get_property/target_properties.cmake b/Tests/RunCMake/get_property/target_properties.cmake
index 9ff833a67..321d5b5b8 100644
--- a/Tests/RunCMake/get_property/target_properties.cmake
+++ b/Tests/RunCMake/get_property/target_properties.cmake
@@ -16,3 +16,10 @@ check_target_property(tgt custom)
check_target_property(tgt noexist)
check_target_property(tgt SOURCE_DIR)
check_target_property(tgt BINARY_DIR)
+
+add_library(imported_local_tgt SHARED IMPORTED)
+add_library(imported_global_tgt SHARED IMPORTED GLOBAL)
+
+check_target_property(tgt IMPORTED_GLOBAL)
+check_target_property(imported_local_tgt IMPORTED_GLOBAL)
+check_target_property(imported_global_tgt IMPORTED_GLOBAL)
diff --git a/Tests/RunCMake/include_external_msproject/check_utils.cmake b/Tests/RunCMake/include_external_msproject/check_utils.cmake
index e9e9cac72..0a2ba63f5 100644
--- a/Tests/RunCMake/include_external_msproject/check_utils.cmake
+++ b/Tests/RunCMake/include_external_msproject/check_utils.cmake
@@ -100,6 +100,8 @@ function(check_project test name guid type platform imported_release_config_name
set(platform "${RunCMake_GENERATOR_PLATFORM}")
elseif("${RunCMake_GENERATOR}" MATCHES "Win64")
set(platform "x64")
+ elseif(VS_PLATFORM_NAME)
+ set(platform "${VS_PLATFORM_NAME}")
else()
set(platform "Win32")
endif()
diff --git a/Tests/RunCMake/include_guard/CMakeLists.txt b/Tests/RunCMake/include_guard/CMakeLists.txt
new file mode 100644
index 000000000..d3137f614
--- /dev/null
+++ b/Tests/RunCMake/include_guard/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.9)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/include_guard/DirectoryScope.cmake b/Tests/RunCMake/include_guard/DirectoryScope.cmake
new file mode 100644
index 000000000..d6c5a3ce2
--- /dev/null
+++ b/Tests/RunCMake/include_guard/DirectoryScope.cmake
@@ -0,0 +1,19 @@
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Scripts")
+
+# Test include_guard with DIRECTORY scope
+
+# Add subdirectory which includes DirScript three times:
+# 1. Include at inner function scope
+# 2. At directory scope
+# 3. At another subdirectory to check that the guard is checked
+# against parent directories
+add_subdirectory(sub_dir_script1)
+# Add another directory which includes DirScript
+add_subdirectory(sub_dir_script2)
+
+# check inclusions count
+get_property(dir_count GLOBAL PROPERTY DIR_SCRIPT_COUNT)
+if(NOT dir_count EQUAL 2)
+ message(FATAL_ERROR
+ "Wrong DIR_SCRIPT_COUNT value: ${dir_count}, expected: 2")
+endif()
diff --git a/Tests/RunCMake/include_guard/GlobalScope.cmake b/Tests/RunCMake/include_guard/GlobalScope.cmake
new file mode 100644
index 000000000..02137fa77
--- /dev/null
+++ b/Tests/RunCMake/include_guard/GlobalScope.cmake
@@ -0,0 +1,11 @@
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Scripts")
+
+# Test GLOBAL include guard
+add_subdirectory(global_script_dir)
+include(GlobScript)
+
+get_property(glob_count GLOBAL PROPERTY GLOB_SCRIPT_COUNT)
+if(NOT glob_count EQUAL 1)
+ message(FATAL_ERROR
+ "Wrong GLOB_SCRIPT_COUNT value: ${glob_count}, expected: 1")
+endif()
diff --git a/Tests/RunCMake/include_guard/InvalidArgumentsNumber-result.txt b/Tests/RunCMake/include_guard/InvalidArgumentsNumber-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/include_guard/InvalidArgumentsNumber-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/include_guard/InvalidArgumentsNumber-stderr.txt b/Tests/RunCMake/include_guard/InvalidArgumentsNumber-stderr.txt
new file mode 100644
index 000000000..698e89ab0
--- /dev/null
+++ b/Tests/RunCMake/include_guard/InvalidArgumentsNumber-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at InvalidArgumentsNumber.cmake:1 \(include_guard\):
+ include_guard given an invalid number of arguments. The command takes at
+ most 1 argument.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/include_guard/InvalidArgumentsNumber.cmake b/Tests/RunCMake/include_guard/InvalidArgumentsNumber.cmake
new file mode 100644
index 000000000..a63a395c0
--- /dev/null
+++ b/Tests/RunCMake/include_guard/InvalidArgumentsNumber.cmake
@@ -0,0 +1 @@
+include_guard(ARG1 ARG2)
diff --git a/Tests/RunCMake/include_guard/InvalidScope-result.txt b/Tests/RunCMake/include_guard/InvalidScope-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/include_guard/InvalidScope-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/include_guard/InvalidScope-stderr.txt b/Tests/RunCMake/include_guard/InvalidScope-stderr.txt
new file mode 100644
index 000000000..58f62a362
--- /dev/null
+++ b/Tests/RunCMake/include_guard/InvalidScope-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at InvalidScope.cmake:1 \(include_guard\):
+ include_guard given an invalid scope: INVALID
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/include_guard/InvalidScope.cmake b/Tests/RunCMake/include_guard/InvalidScope.cmake
new file mode 100644
index 000000000..f69f9fd64
--- /dev/null
+++ b/Tests/RunCMake/include_guard/InvalidScope.cmake
@@ -0,0 +1 @@
+include_guard(INVALID)
diff --git a/Tests/RunCMake/include_guard/RunCMakeTest.cmake b/Tests/RunCMake/include_guard/RunCMakeTest.cmake
new file mode 100644
index 000000000..e87bddd87
--- /dev/null
+++ b/Tests/RunCMake/include_guard/RunCMakeTest.cmake
@@ -0,0 +1,7 @@
+include(RunCMake)
+
+run_cmake(VariableScope)
+run_cmake(DirectoryScope)
+run_cmake(GlobalScope)
+run_cmake(InvalidScope)
+run_cmake(InvalidArgumentsNumber)
diff --git a/Tests/RunCMake/include_guard/Scripts/DirScript.cmake b/Tests/RunCMake/include_guard/Scripts/DirScript.cmake
new file mode 100644
index 000000000..e61d18051
--- /dev/null
+++ b/Tests/RunCMake/include_guard/Scripts/DirScript.cmake
@@ -0,0 +1,12 @@
+include_guard(DIRECTORY)
+
+set(prop_name DIR_SCRIPT_COUNT)
+get_property(count_is_set GLOBAL PROPERTY ${prop_name} SET)
+
+if(NOT count_is_set)
+ set_property(GLOBAL PROPERTY ${prop_name} 1)
+else()
+ get_property(count GLOBAL PROPERTY ${prop_name})
+ math(EXPR count "${count} + 1")
+ set_property(GLOBAL PROPERTY ${prop_name} ${count})
+endif()
diff --git a/Tests/RunCMake/include_guard/Scripts/GlobScript.cmake b/Tests/RunCMake/include_guard/Scripts/GlobScript.cmake
new file mode 100644
index 000000000..c26bf40e8
--- /dev/null
+++ b/Tests/RunCMake/include_guard/Scripts/GlobScript.cmake
@@ -0,0 +1,12 @@
+include_guard(GLOBAL)
+
+set(prop_name GLOB_SCRIPT_COUNT)
+get_property(count_is_set GLOBAL PROPERTY ${prop_name} SET)
+
+if(NOT count_is_set)
+ set_property(GLOBAL PROPERTY ${prop_name} 1)
+else()
+ get_property(count GLOBAL PROPERTY ${prop_name})
+ math(EXPR count "${count} + 1")
+ set_property(GLOBAL PROPERTY ${prop_name} ${count})
+endif()
diff --git a/Tests/RunCMake/include_guard/Scripts/VarScript.cmake b/Tests/RunCMake/include_guard/Scripts/VarScript.cmake
new file mode 100644
index 000000000..3080377cb
--- /dev/null
+++ b/Tests/RunCMake/include_guard/Scripts/VarScript.cmake
@@ -0,0 +1,12 @@
+include_guard()
+
+set(prop_name VAR_SCRIPT_COUNT)
+get_property(count_is_set GLOBAL PROPERTY ${prop_name} SET)
+
+if(NOT count_is_set)
+ set_property(GLOBAL PROPERTY ${prop_name} 1)
+else()
+ get_property(count GLOBAL PROPERTY ${prop_name})
+ math(EXPR count "${count} + 1")
+ set_property(GLOBAL PROPERTY ${prop_name} ${count})
+endif()
diff --git a/Tests/RunCMake/include_guard/VariableScope.cmake b/Tests/RunCMake/include_guard/VariableScope.cmake
new file mode 100644
index 000000000..7f8477db3
--- /dev/null
+++ b/Tests/RunCMake/include_guard/VariableScope.cmake
@@ -0,0 +1,24 @@
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Scripts")
+
+# Test include_guard with VARIABLE scope
+function(var_include_func)
+ # Include twice in the same scope
+ include(VarScript)
+ include(VarScript)
+ get_property(var_count GLOBAL PROPERTY VAR_SCRIPT_COUNT)
+ if(NOT var_count EQUAL 1)
+ message(FATAL_ERROR
+ "Wrong VAR_SCRIPT_COUNT value: ${var_count}, expected: 1")
+ endif()
+endfunction()
+
+var_include_func()
+
+# Check again that include_guard has been reset
+include(VarScript)
+
+get_property(var_count GLOBAL PROPERTY VAR_SCRIPT_COUNT)
+if(NOT var_count EQUAL 2)
+ message(FATAL_ERROR
+ "Wrong VAR_SCRIPT_COUNT value: ${var_count}, expected: 2")
+endif()
diff --git a/Tests/RunCMake/include_guard/global_script_dir/CMakeLists.txt b/Tests/RunCMake/include_guard/global_script_dir/CMakeLists.txt
new file mode 100644
index 000000000..ee7ea2ecc
--- /dev/null
+++ b/Tests/RunCMake/include_guard/global_script_dir/CMakeLists.txt
@@ -0,0 +1 @@
+include(GlobScript)
diff --git a/Tests/RunCMake/include_guard/sub_dir_script1/CMakeLists.txt b/Tests/RunCMake/include_guard/sub_dir_script1/CMakeLists.txt
new file mode 100644
index 000000000..d3626e5fa
--- /dev/null
+++ b/Tests/RunCMake/include_guard/sub_dir_script1/CMakeLists.txt
@@ -0,0 +1,9 @@
+function(dir_check)
+ include(DirScript)
+endfunction()
+
+dir_check()
+
+include(DirScript)
+
+add_subdirectory(sub_dir_script3)
diff --git a/Tests/RunCMake/include_guard/sub_dir_script1/sub_dir_script3/CMakeLists.txt b/Tests/RunCMake/include_guard/sub_dir_script1/sub_dir_script3/CMakeLists.txt
new file mode 100644
index 000000000..1c3b1b245
--- /dev/null
+++ b/Tests/RunCMake/include_guard/sub_dir_script1/sub_dir_script3/CMakeLists.txt
@@ -0,0 +1 @@
+include(DirScript)
diff --git a/Tests/RunCMake/include_guard/sub_dir_script2/CMakeLists.txt b/Tests/RunCMake/include_guard/sub_dir_script2/CMakeLists.txt
new file mode 100644
index 000000000..1c3b1b245
--- /dev/null
+++ b/Tests/RunCMake/include_guard/sub_dir_script2/CMakeLists.txt
@@ -0,0 +1 @@
+include(DirScript)
diff --git a/Tests/RunCMake/install/CMP0062-OLD-stderr.txt b/Tests/RunCMake/install/CMP0062-OLD-stderr.txt
new file mode 100644
index 000000000..de0b70ffc
--- /dev/null
+++ b/Tests/RunCMake/install/CMP0062-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0062-OLD.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0062 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/install/CMP0087-NEW-check.cmake b/Tests/RunCMake/install/CMP0087-NEW-check.cmake
new file mode 100644
index 000000000..422c53202
--- /dev/null
+++ b/Tests/RunCMake/install/CMP0087-NEW-check.cmake
@@ -0,0 +1,7 @@
+execute_process(COMMAND ${CMAKE_COMMAND} -P ${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake
+ OUTPUT_VARIABLE out ERROR_VARIABLE err)
+if(NOT out MATCHES "-- Install configuration: .*-- codegenexlib")
+ string(REGEX REPLACE "\n" "\n " out " ${out}")
+ string(APPEND RunCMake_TEST_FAILED
+ "\"-- codegenexlib\" was not found:\n${out}")
+endif()
diff --git a/Tests/RunCMake/install/CMP0087-NEW.cmake b/Tests/RunCMake/install/CMP0087-NEW.cmake
new file mode 100644
index 000000000..01779609c
--- /dev/null
+++ b/Tests/RunCMake/install/CMP0087-NEW.cmake
@@ -0,0 +1,3 @@
+# Need a new directory scope, not just a new policy scope
+# to test this correctly
+add_subdirectory(CMP0087-NEW)
diff --git a/Tests/RunCMake/install/CMP0087-NEW/CMakeLists.txt b/Tests/RunCMake/install/CMP0087-NEW/CMakeLists.txt
new file mode 100644
index 000000000..07b4589cf
--- /dev/null
+++ b/Tests/RunCMake/install/CMP0087-NEW/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Note that it is the policy settings at the end of the directory
+# scope that will be used when deciding whether or not generator
+# expressions should be evaluated in the installed code.
+cmake_policy(VERSION 3.13)
+cmake_policy(SET CMP0087 NEW)
+add_library( codegenexlib INTERFACE )
+install(CODE "message( STATUS \"$<TARGET_PROPERTY:codegenexlib,NAME>\")")
diff --git a/Tests/RunCMake/install/CMP0087-OLD-check.cmake b/Tests/RunCMake/install/CMP0087-OLD-check.cmake
new file mode 100644
index 000000000..c5984bca7
--- /dev/null
+++ b/Tests/RunCMake/install/CMP0087-OLD-check.cmake
@@ -0,0 +1,8 @@
+execute_process(COMMAND ${CMAKE_COMMAND} -P ${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake
+ OUTPUT_VARIABLE out ERROR_VARIABLE err)
+
+if(NOT out MATCHES "-- Install configuration: .*-- \\$<TARGET_PROPERTY:codegenexlib,NAME>")
+ string(REGEX REPLACE "\n" "\n " out " ${out}")
+ string(APPEND RunCMake_TEST_FAILED
+ "\"-- $<TARGET_PROPERTY:codegenexlib,NAME>\" was not found:\n${out}")
+endif()
diff --git a/Tests/RunCMake/install/CMP0087-OLD.cmake b/Tests/RunCMake/install/CMP0087-OLD.cmake
new file mode 100644
index 000000000..e7ed4ee98
--- /dev/null
+++ b/Tests/RunCMake/install/CMP0087-OLD.cmake
@@ -0,0 +1,3 @@
+# Need a new directory scope, not just a new policy scope
+# to test this correctly
+add_subdirectory(CMP0087-OLD)
diff --git a/Tests/RunCMake/install/CMP0087-OLD/CMakeLists.txt b/Tests/RunCMake/install/CMP0087-OLD/CMakeLists.txt
new file mode 100644
index 000000000..b1d4e2e7d
--- /dev/null
+++ b/Tests/RunCMake/install/CMP0087-OLD/CMakeLists.txt
@@ -0,0 +1,6 @@
+# Note that it is the policy settings at the end of the directory
+# scope that will be used when deciding whether or not generator
+# expressions should be evaluated in the installed code.
+cmake_policy(VERSION 3.13)
+cmake_policy(SET CMP0087 OLD)
+install(CODE "message( STATUS \"$<TARGET_PROPERTY:codegenexlib,NAME>\")")
diff --git a/Tests/RunCMake/install/CMP0087-WARN-stderr.txt b/Tests/RunCMake/install/CMP0087-WARN-stderr.txt
new file mode 100644
index 000000000..75fbf2c0c
--- /dev/null
+++ b/Tests/RunCMake/install/CMP0087-WARN-stderr.txt
@@ -0,0 +1,5 @@
+CMake Warning (dev) in CMakeLists.txt:
+ Policy CMP0087 is not set: Install CODE|SCRIPT allow the use of generator
+ expressions. Run "cmake --help-policy CMP0087" for policy details. Use
+ the cmake_policy command to set the policy and suppress this warning.
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/install/CMP0087-WARN.cmake b/Tests/RunCMake/install/CMP0087-WARN.cmake
new file mode 100644
index 000000000..3b8513d64
--- /dev/null
+++ b/Tests/RunCMake/install/CMP0087-WARN.cmake
@@ -0,0 +1,2 @@
+add_library( codegenexlib INTERFACE )
+install(CODE "message( STATUS \"$<TARGET_PROPERTY:codegenexlib,NAME>\")")
diff --git a/Tests/RunCMake/install/CMakeLists.txt b/Tests/RunCMake/install/CMakeLists.txt
index 6dd8cdf55..c7e99ada4 100644
--- a/Tests/RunCMake/install/CMakeLists.txt
+++ b/Tests/RunCMake/install/CMakeLists.txt
@@ -1,3 +1,6 @@
cmake_minimum_required(VERSION 3.4)
+if(RunCMake_TEST MATCHES "^file-GET_RUNTIME_DEPENDENCIES")
+ cmake_policy(SET CMP0087 NEW)
+endif()
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/install/DIRECTORY-DESTINATION-TYPE-result.txt b/Tests/RunCMake/install/DIRECTORY-DESTINATION-TYPE-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-DESTINATION-TYPE-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/DIRECTORY-DESTINATION-TYPE-stderr.txt b/Tests/RunCMake/install/DIRECTORY-DESTINATION-TYPE-stderr.txt
new file mode 100644
index 000000000..c847c430f
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-DESTINATION-TYPE-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at DIRECTORY-DESTINATION-TYPE\.cmake:[0-9]+ \(install\):
+ install DIRECTORY given both TYPE and DESTINATION arguments\. You may only
+ specify one\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/install/DIRECTORY-DESTINATION-TYPE.cmake b/Tests/RunCMake/install/DIRECTORY-DESTINATION-TYPE.cmake
new file mode 100644
index 000000000..4404d6b76
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-DESTINATION-TYPE.cmake
@@ -0,0 +1 @@
+install(DIRECTORY dir TYPE BIN DESTINATION mybin)
diff --git a/Tests/RunCMake/install/DIRECTORY-OPTIONAL-all-check.cmake b/Tests/RunCMake/install/DIRECTORY-OPTIONAL-all-check.cmake
new file mode 100644
index 000000000..c14998ecf
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-OPTIONAL-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^dir;dir/empty.txt$]])
diff --git a/Tests/RunCMake/install/DIRECTORY-OPTIONAL.cmake b/Tests/RunCMake/install/DIRECTORY-OPTIONAL.cmake
new file mode 100644
index 000000000..e57aab005
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-OPTIONAL.cmake
@@ -0,0 +1 @@
+install(DIRECTORY dir/ noexist/ DESTINATION dir OPTIONAL)
diff --git a/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt b/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt
index 166ba6f04..c8074e96f 100644
--- a/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt
+++ b/Tests/RunCMake/install/DIRECTORY-PATTERN-MESSAGE_NEVER-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at DIRECTORY-PATTERN-MESSAGE_NEVER.cmake:[0-9]+ \(install\):
install DIRECTORY does not allow "MESSAGE_NEVER" after PATTERN or REGEX.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/install/DIRECTORY-PATTERN-all-check.cmake b/Tests/RunCMake/install/DIRECTORY-PATTERN-all-check.cmake
new file mode 100644
index 000000000..7a20edc36
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-PATTERN-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^dir1;dir1/empty\.c;dir1/empty\.h;dir2;dir2/pattern;dir2/pattern/empty\.txt;dir3;dir3/empty\.c;dir3/empty\.h;dir3/empty\.txt;dir4;dir4/empty\.c;dir4/empty\.h;dir4/empty\.txt;empty$]])
diff --git a/Tests/RunCMake/install/DIRECTORY-PATTERN.cmake b/Tests/RunCMake/install/DIRECTORY-PATTERN.cmake
new file mode 100644
index 000000000..74d804351
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-PATTERN.cmake
@@ -0,0 +1,36 @@
+install(
+ DIRECTORY pattern/
+ DESTINATION dir1
+ FILES_MATCHING
+ PATTERN "*.h"
+ REGEX "\\.c$"
+ )
+
+# FIXME: If/when CMake gains a good way to read file permissions, we should
+# check that these permissions were set correctly.
+install(
+ DIRECTORY pattern
+ DESTINATION dir2
+ FILE_PERMISSIONS OWNER_READ OWNER_WRITE
+ DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ PATTERN "*.h" EXCLUDE
+ REGEX "\\.c$" EXCLUDE
+ )
+
+install(
+ DIRECTORY pattern/
+ DESTINATION dir3
+ PATTERN "*.h"
+ PERMISSIONS OWNER_READ OWNER_WRITE
+ )
+
+install(
+ DIRECTORY pattern/
+ DESTINATION dir4
+ USE_SOURCE_PERMISSIONS
+ )
+
+install(
+ DIRECTORY
+ DESTINATION empty
+ )
diff --git a/Tests/RunCMake/install/DIRECTORY-TYPE-Cache-all-check.cmake b/Tests/RunCMake/install/DIRECTORY-TYPE-Cache-all-check.cmake
new file mode 100644
index 000000000..fb393e396
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-TYPE-Cache-all-check.cmake
@@ -0,0 +1,42 @@
+set(_check_files
+ [[mybin]]
+ [[mybin/dir]]
+ [[mybin/dir/empty\.txt]]
+ [[mycom]]
+ [[mycom/dir]]
+ [[mycom/dir/empty\.txt]]
+ [[mydoc]]
+ [[mydoc/dir]]
+ [[mydoc/dir/empty\.txt]]
+ [[myetc]]
+ [[myetc/dir]]
+ [[myetc/dir/empty\.txt]]
+ [[myinclude]]
+ [[myinclude/dir]]
+ [[myinclude/dir/empty\.txt]]
+ [[myinfo]]
+ [[myinfo/dir]]
+ [[myinfo/dir/empty\.txt]]
+ [[mylib]]
+ [[mylib/dir]]
+ [[mylib/dir/empty\.txt]]
+ [[mylocale]]
+ [[mylocale/dir]]
+ [[mylocale/dir/empty\.txt]]
+ [[myman]]
+ [[myman/dir]]
+ [[myman/dir/empty\.txt]]
+ [[myrun]]
+ [[myrun/dir]]
+ [[myrun/dir/empty\.txt]]
+ [[mysbin]]
+ [[mysbin/dir]]
+ [[mysbin/dir/empty\.txt]]
+ [[myshare]]
+ [[myshare/dir]]
+ [[myshare/dir/empty\.txt]]
+ [[myvar]]
+ [[myvar/dir]]
+ [[myvar/dir/empty\.txt]]
+ )
+check_installed("^${_check_files}$")
diff --git a/Tests/RunCMake/install/DIRECTORY-TYPE-Cache.cmake b/Tests/RunCMake/install/DIRECTORY-TYPE-Cache.cmake
new file mode 100644
index 000000000..53e95f8ee
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-TYPE-Cache.cmake
@@ -0,0 +1,13 @@
+install(DIRECTORY dir TYPE BIN)
+install(DIRECTORY dir TYPE SBIN)
+install(DIRECTORY dir TYPE LIB)
+install(DIRECTORY dir TYPE INCLUDE)
+install(DIRECTORY dir TYPE SYSCONF)
+install(DIRECTORY dir TYPE SHAREDSTATE)
+install(DIRECTORY dir TYPE LOCALSTATE)
+install(DIRECTORY dir TYPE RUNSTATE)
+install(DIRECTORY dir TYPE DATA)
+install(DIRECTORY dir TYPE INFO)
+install(DIRECTORY dir TYPE LOCALE)
+install(DIRECTORY dir TYPE MAN)
+install(DIRECTORY dir TYPE DOC)
diff --git a/Tests/RunCMake/install/DIRECTORY-TYPE-CacheDependent-all-check.cmake b/Tests/RunCMake/install/DIRECTORY-TYPE-CacheDependent-all-check.cmake
new file mode 100644
index 000000000..03f7bd657
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-TYPE-CacheDependent-all-check.cmake
@@ -0,0 +1,24 @@
+set(_check_files
+ [[myshare]]
+ [[myshare/dir]]
+ [[myshare/dir/empty\.txt]]
+ [[myshare/doc]]
+ [[myshare/doc/dir]]
+ [[myshare/doc/dir/empty\.txt]]
+ [[myshare/info]]
+ [[myshare/info/dir]]
+ [[myshare/info/dir/empty\.txt]]
+ [[myshare/locale]]
+ [[myshare/locale/dir]]
+ [[myshare/locale/dir/empty\.txt]]
+ [[myshare/man]]
+ [[myshare/man/dir]]
+ [[myshare/man/dir/empty.txt]]
+ [[myvar]]
+ [[myvar/dir]]
+ [[myvar/dir/empty\.txt]]
+ [[myvar/run]]
+ [[myvar/run/dir]]
+ [[myvar/run/dir/empty\.txt]]
+ )
+check_installed("^${_check_files}$")
diff --git a/Tests/RunCMake/install/DIRECTORY-TYPE-CacheDependent.cmake b/Tests/RunCMake/install/DIRECTORY-TYPE-CacheDependent.cmake
new file mode 100644
index 000000000..e797abb91
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-TYPE-CacheDependent.cmake
@@ -0,0 +1,7 @@
+install(DIRECTORY dir TYPE LOCALSTATE)
+install(DIRECTORY dir TYPE RUNSTATE)
+install(DIRECTORY dir TYPE DATA)
+install(DIRECTORY dir TYPE INFO)
+install(DIRECTORY dir TYPE LOCALE)
+install(DIRECTORY dir TYPE MAN)
+install(DIRECTORY dir TYPE DOC)
diff --git a/Tests/RunCMake/install/DIRECTORY-TYPE-all-check.cmake b/Tests/RunCMake/install/DIRECTORY-TYPE-all-check.cmake
new file mode 100644
index 000000000..03fa3c832
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-TYPE-all-check.cmake
@@ -0,0 +1,42 @@
+set(_check_files
+ [[bin]]
+ [[bin/dir]]
+ [[bin/dir/empty\.txt]]
+ [[com]]
+ [[com/dir]]
+ [[com/dir/empty\.txt]]
+ [[etc]]
+ [[etc/dir]]
+ [[etc/dir/empty\.txt]]
+ [[include]]
+ [[include/dir]]
+ [[include/dir/empty\.txt]]
+ [[lib]]
+ [[lib/dir]]
+ [[lib/dir/empty\.txt]]
+ [[sbin]]
+ [[sbin/dir]]
+ [[sbin/dir/empty\.txt]]
+ [[share]]
+ [[share/dir]]
+ [[share/dir/empty\.txt]]
+ [[share/doc]]
+ [[share/doc/dir]]
+ [[share/doc/dir/empty\.txt]]
+ [[share/info]]
+ [[share/info/dir]]
+ [[share/info/dir/empty\.txt]]
+ [[share/locale]]
+ [[share/locale/dir]]
+ [[share/locale/dir/empty\.txt]]
+ [[share/man]]
+ [[share/man/dir]]
+ [[share/man/dir/empty\.txt]]
+ [[var]]
+ [[var/dir]]
+ [[var/dir/empty\.txt]]
+ [[var/run]]
+ [[var/run/dir]]
+ [[var/run/dir/empty\.txt]]
+ )
+check_installed("^${_check_files}$")
diff --git a/Tests/RunCMake/install/DIRECTORY-TYPE.cmake b/Tests/RunCMake/install/DIRECTORY-TYPE.cmake
new file mode 100644
index 000000000..53e95f8ee
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-TYPE.cmake
@@ -0,0 +1,13 @@
+install(DIRECTORY dir TYPE BIN)
+install(DIRECTORY dir TYPE SBIN)
+install(DIRECTORY dir TYPE LIB)
+install(DIRECTORY dir TYPE INCLUDE)
+install(DIRECTORY dir TYPE SYSCONF)
+install(DIRECTORY dir TYPE SHAREDSTATE)
+install(DIRECTORY dir TYPE LOCALSTATE)
+install(DIRECTORY dir TYPE RUNSTATE)
+install(DIRECTORY dir TYPE DATA)
+install(DIRECTORY dir TYPE INFO)
+install(DIRECTORY dir TYPE LOCALE)
+install(DIRECTORY dir TYPE MAN)
+install(DIRECTORY dir TYPE DOC)
diff --git a/Tests/RunCMake/install/Deprecated-all-check.cmake b/Tests/RunCMake/install/Deprecated-all-check.cmake
new file mode 100644
index 000000000..9ea33a6b4
--- /dev/null
+++ b/Tests/RunCMake/install/Deprecated-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^bin;bin/myexe(\.exe)?;scripts1;scripts1/script;scripts1/script\.bat;scripts2;scripts2/script;scripts2/script\.bat;scripts3;scripts3/script;scripts3/script\.bat;src;src/empty\.c;src/obj1\.c;src/obj\2.c$]])
diff --git a/Tests/RunCMake/install/Deprecated.cmake b/Tests/RunCMake/install/Deprecated.cmake
new file mode 100644
index 000000000..c435cb507
--- /dev/null
+++ b/Tests/RunCMake/install/Deprecated.cmake
@@ -0,0 +1,13 @@
+enable_language(C)
+
+add_executable(myexe main.c)
+
+install_files(/src FILES empty.c)
+install_files(/src .c obj1)
+install_files(/src "^obj2.c$")
+
+install_targets(/bin myexe)
+
+install_programs(/scripts1 FILES script script.bat)
+install_programs(/scripts2 script script.bat)
+install_programs(/scripts3 "^script(\.bat)?$")
diff --git a/Tests/RunCMake/install/FILES-DESTINATION-TYPE-result.txt b/Tests/RunCMake/install/FILES-DESTINATION-TYPE-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-DESTINATION-TYPE-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/FILES-DESTINATION-TYPE-stderr.txt b/Tests/RunCMake/install/FILES-DESTINATION-TYPE-stderr.txt
new file mode 100644
index 000000000..ce8fc2386
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-DESTINATION-TYPE-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at FILES-DESTINATION-TYPE\.cmake:[0-9]+ \(install\):
+ install FILES given both TYPE and DESTINATION arguments\. You may only
+ specify one\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/install/FILES-DESTINATION-TYPE.cmake b/Tests/RunCMake/install/FILES-DESTINATION-TYPE.cmake
new file mode 100644
index 000000000..576c98f36
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-DESTINATION-TYPE.cmake
@@ -0,0 +1 @@
+install(FILES main.c TYPE BIN DESTINATION mybin)
diff --git a/Tests/RunCMake/install/FILES-OPTIONAL-all-check.cmake b/Tests/RunCMake/install/FILES-OPTIONAL-all-check.cmake
new file mode 100644
index 000000000..2997a8d4e
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-OPTIONAL-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^src;src/main.c$]])
diff --git a/Tests/RunCMake/install/FILES-OPTIONAL.cmake b/Tests/RunCMake/install/FILES-OPTIONAL.cmake
new file mode 100644
index 000000000..812bf4f02
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-OPTIONAL.cmake
@@ -0,0 +1 @@
+install(FILES main.c noexist.c DESTINATION src OPTIONAL)
diff --git a/Tests/RunCMake/install/FILES-PERMISSIONS-all-check.cmake b/Tests/RunCMake/install/FILES-PERMISSIONS-all-check.cmake
new file mode 100644
index 000000000..b8ba6d0d5
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-PERMISSIONS-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^src;src/empty.c]])
diff --git a/Tests/RunCMake/install/FILES-PERMISSIONS.cmake b/Tests/RunCMake/install/FILES-PERMISSIONS.cmake
new file mode 100644
index 000000000..999c271f9
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-PERMISSIONS.cmake
@@ -0,0 +1,5 @@
+install(
+ FILES empty.c
+ DESTINATION src
+ PERMISSIONS OWNER_READ OWNER_WRITE
+ )
diff --git a/Tests/RunCMake/install/FILES-TYPE-Cache-all-check.cmake b/Tests/RunCMake/install/FILES-TYPE-Cache-all-check.cmake
new file mode 100644
index 000000000..dfb90cf02
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-TYPE-Cache-all-check.cmake
@@ -0,0 +1,29 @@
+set(_check_files
+ [[mybin]]
+ [[mybin/main\.c]]
+ [[mycom]]
+ [[mycom/main\.c]]
+ [[mydoc]]
+ [[mydoc/main\.c]]
+ [[myetc]]
+ [[myetc/main\.c]]
+ [[myinclude]]
+ [[myinclude/main\.c]]
+ [[myinfo]]
+ [[myinfo/main\.c]]
+ [[mylib]]
+ [[mylib/main\.c]]
+ [[mylocale]]
+ [[mylocale/main\.c]]
+ [[myman]]
+ [[myman/main\.c]]
+ [[myrun]]
+ [[myrun/main\.c]]
+ [[mysbin]]
+ [[mysbin/main\.c]]
+ [[myshare]]
+ [[myshare/main\.c]]
+ [[myvar]]
+ [[myvar/main\.c]]
+ )
+check_installed("^${_check_files}$")
diff --git a/Tests/RunCMake/install/FILES-TYPE-Cache.cmake b/Tests/RunCMake/install/FILES-TYPE-Cache.cmake
new file mode 100644
index 000000000..2e2bfc7fa
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-TYPE-Cache.cmake
@@ -0,0 +1,13 @@
+install(FILES main.c TYPE BIN)
+install(FILES main.c TYPE SBIN)
+install(FILES main.c TYPE LIB)
+install(FILES main.c TYPE INCLUDE)
+install(FILES main.c TYPE SYSCONF)
+install(FILES main.c TYPE SHAREDSTATE)
+install(FILES main.c TYPE LOCALSTATE)
+install(FILES main.c TYPE RUNSTATE)
+install(FILES main.c TYPE DATA)
+install(FILES main.c TYPE INFO)
+install(FILES main.c TYPE LOCALE)
+install(FILES main.c TYPE MAN)
+install(FILES main.c TYPE DOC)
diff --git a/Tests/RunCMake/install/FILES-TYPE-CacheDependent-all-check.cmake b/Tests/RunCMake/install/FILES-TYPE-CacheDependent-all-check.cmake
new file mode 100644
index 000000000..e58c80ad3
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-TYPE-CacheDependent-all-check.cmake
@@ -0,0 +1,17 @@
+set(_check_files
+ [[myshare]]
+ [[myshare/doc]]
+ [[myshare/doc/main\.c]]
+ [[myshare/info]]
+ [[myshare/info/main\.c]]
+ [[myshare/locale]]
+ [[myshare/locale/main\.c]]
+ [[myshare/main\.c]]
+ [[myshare/man]]
+ [[myshare/man/main\.c]]
+ [[myvar]]
+ [[myvar/main\.c]]
+ [[myvar/run]]
+ [[myvar/run/main\.c]]
+ )
+check_installed("^${_check_files}$")
diff --git a/Tests/RunCMake/install/FILES-TYPE-CacheDependent.cmake b/Tests/RunCMake/install/FILES-TYPE-CacheDependent.cmake
new file mode 100644
index 000000000..d7d5aaa11
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-TYPE-CacheDependent.cmake
@@ -0,0 +1,7 @@
+install(FILES main.c TYPE LOCALSTATE)
+install(FILES main.c TYPE RUNSTATE)
+install(FILES main.c TYPE DATA)
+install(FILES main.c TYPE INFO)
+install(FILES main.c TYPE LOCALE)
+install(FILES main.c TYPE MAN)
+install(FILES main.c TYPE DOC)
diff --git a/Tests/RunCMake/install/FILES-TYPE-all-check.cmake b/Tests/RunCMake/install/FILES-TYPE-all-check.cmake
new file mode 100644
index 000000000..c4ec66149
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-TYPE-all-check.cmake
@@ -0,0 +1,29 @@
+set(_check_files
+ [[bin]]
+ [[bin/main\.c]]
+ [[com]]
+ [[com/main\.c]]
+ [[etc]]
+ [[etc/main\.c]]
+ [[include]]
+ [[include/main\.c]]
+ [[lib]]
+ [[lib/main\.c]]
+ [[sbin]]
+ [[sbin/main\.c]]
+ [[share]]
+ [[share/doc]]
+ [[share/doc/main\.c]]
+ [[share/info]]
+ [[share/info/main\.c]]
+ [[share/locale]]
+ [[share/locale/main\.c]]
+ [[share/main\.c]]
+ [[share/man]]
+ [[share/man/main\.c]]
+ [[var]]
+ [[var/main\.c]]
+ [[var/run]]
+ [[var/run/main\.c]]
+ )
+check_installed("^${_check_files}$")
diff --git a/Tests/RunCMake/install/FILES-TYPE.cmake b/Tests/RunCMake/install/FILES-TYPE.cmake
new file mode 100644
index 000000000..2e2bfc7fa
--- /dev/null
+++ b/Tests/RunCMake/install/FILES-TYPE.cmake
@@ -0,0 +1,13 @@
+install(FILES main.c TYPE BIN)
+install(FILES main.c TYPE SBIN)
+install(FILES main.c TYPE LIB)
+install(FILES main.c TYPE INCLUDE)
+install(FILES main.c TYPE SYSCONF)
+install(FILES main.c TYPE SHAREDSTATE)
+install(FILES main.c TYPE LOCALSTATE)
+install(FILES main.c TYPE RUNSTATE)
+install(FILES main.c TYPE DATA)
+install(FILES main.c TYPE INFO)
+install(FILES main.c TYPE LOCALE)
+install(FILES main.c TYPE MAN)
+install(FILES main.c TYPE DOC)
diff --git a/Tests/RunCMake/install/InstallRequiredSystemLibraries-stderr.txt b/Tests/RunCMake/install/InstallRequiredSystemLibraries-stderr.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/install/InstallRequiredSystemLibraries-stderr.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/install/InstallRequiredSystemLibraries.cmake b/Tests/RunCMake/install/InstallRequiredSystemLibraries.cmake
new file mode 100644
index 000000000..27ff68387
--- /dev/null
+++ b/Tests/RunCMake/install/InstallRequiredSystemLibraries.cmake
@@ -0,0 +1,10 @@
+enable_language(C)
+set(CMAKE_INSTALL_MFC_LIBRARIES 1)
+set(CMAKE_INSTALL_DEBUG_LIBRARIES 1)
+set(CMAKE_INSTALL_UCRT_LIBRARIES 1)
+set(CMAKE_INSTALL_OPENMP_LIBRARIES 1)
+include(InstallRequiredSystemLibraries)
+
+# FIXME: This test emits warnings because InstallRequiredSystemLibraries
+# doesn't currently work properly. The warnings have been suppressed in
+# InstallRequiredSystemLibraries-stderr.txt. This needs to be fixed.
diff --git a/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT-all-check.cmake b/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT-all-check.cmake
new file mode 100644
index 000000000..16ff1e1c1
--- /dev/null
+++ b/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^bin;bin/myexe(\.exe)?;postinstall;preinstall]])
diff --git a/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT.cmake b/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT.cmake
new file mode 100644
index 000000000..357c68872
--- /dev/null
+++ b/Tests/RunCMake/install/PRE_POST_INSTALL_SCRIPT.cmake
@@ -0,0 +1,7 @@
+enable_language(C)
+
+add_executable(myexe main.c)
+set_property(TARGET myexe PROPERTY PRE_INSTALL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/preinstall.cmake")
+set_property(TARGET myexe PROPERTY POST_INSTALL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/postinstall.cmake")
+
+install(TARGETS myexe DESTINATION bin)
diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake
index 1a60f0c27..21c320b04 100644
--- a/Tests/RunCMake/install/RunCMakeTest.cmake
+++ b/Tests/RunCMake/install/RunCMakeTest.cmake
@@ -21,6 +21,10 @@ function(run_install_test case)
# Check explicit component.
set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-exc)
run_cmake_command(${case}-exc ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -DCOMPONENT=exc -P cmake_install.cmake)
+ set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-lib)
+ run_cmake_command(${case}-lib ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -DCOMPONENT=lib -P cmake_install.cmake)
+ set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-dev)
+ run_cmake_command(${case}-dev ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -DCOMPONENT=dev -P cmake_install.cmake)
endif()
endfunction()
@@ -44,6 +48,22 @@ in directory:
endif()
endfunction()
+# Wrapper for run_cmake() that skips platforms that are non-ELF or have no RPATH support
+function(run_cmake_ELFRPATH_only case)
+ if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")
+ run_cmake(${case})
+ else()
+ # Sanity check against a platform known to be ELF-based
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ message(FATAL_ERROR "Expected platform Linux to advertize itself as ELF-based, but it did not.")
+ else()
+ message(STATUS "${case} - SKIPPED (No ELF-based platform found)")
+ endif()
+ endif()
+endfunction()
+
+run_cmake(TARGETS-FILE_RPATH_CHANGE-old_rpath)
+run_cmake_ELFRPATH_only(TARGETS-FILE_RPATH_CHANGE-new_rpath)
run_cmake(DIRECTORY-MESSAGE_NEVER)
run_cmake(DIRECTORY-PATTERN-MESSAGE_NEVER)
run_cmake(DIRECTORY-message)
@@ -59,11 +79,114 @@ run_cmake(EXPORT-OldIFace)
run_cmake(CMP0062-OLD)
run_cmake(CMP0062-NEW)
run_cmake(CMP0062-WARN)
+run_cmake(CMP0087-OLD)
+run_cmake(CMP0087-NEW)
+run_cmake(CMP0087-WARN)
+run_cmake(TARGETS-ImportedGlobal)
+run_cmake(TARGETS-NAMELINK_COMPONENT-bad-all)
+run_cmake(TARGETS-NAMELINK_COMPONENT-bad-exc)
+run_cmake(FILES-DESTINATION-TYPE)
+run_cmake(DIRECTORY-DESTINATION-TYPE)
+
+if(APPLE)
+ run_cmake(TARGETS-Apple-Defaults)
+endif()
if(NOT RunCMake_GENERATOR STREQUAL "Xcode" OR NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")
run_install_test(FILES-TARGET_OBJECTS)
endif()
+run_install_test(TARGETS-InstallFromSubDir)
+run_install_test(TARGETS-OPTIONAL)
+run_install_test(FILES-OPTIONAL)
+run_install_test(DIRECTORY-OPTIONAL)
+run_install_test(TARGETS-Defaults)
+
+set(RunCMake_TEST_OPTIONS
+ "-DCMAKE_INSTALL_BINDIR:PATH=mybin"
+ "-DCMAKE_INSTALL_LIBDIR:PATH=mylib"
+ "-DCMAKE_INSTALL_INCLUDEDIR:PATH=myinclude"
+ )
+run_install_test(TARGETS-Defaults-Cache)
+unset(RunCMake_TEST_OPTIONS)
+
+run_install_test(FILES-TYPE)
+run_install_test(DIRECTORY-TYPE)
+
+set(RunCMake_TEST_OPTIONS
+ "-DCMAKE_INSTALL_BINDIR:PATH=mybin"
+ "-DCMAKE_INSTALL_SBINDIR:PATH=mysbin"
+ "-DCMAKE_INSTALL_LIBEXECDIR:PATH=mylibexec"
+ "-DCMAKE_INSTALL_LIBDIR:PATH=mylib"
+ "-DCMAKE_INSTALL_INCLUDEDIR:PATH=myinclude"
+ "-DCMAKE_INSTALL_SYSCONFDIR:PATH=myetc"
+ "-DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=mycom"
+ "-DCMAKE_INSTALL_LOCALSTATEDIR:PATH=myvar"
+ "-DCMAKE_INSTALL_RUNSTATEDIR:PATH=myrun"
+ "-DCMAKE_INSTALL_DATADIR:PATH=myshare"
+ "-DCMAKE_INSTALL_INFODIR:PATH=myinfo"
+ "-DCMAKE_INSTALL_LOCALEDIR:PATH=mylocale"
+ "-DCMAKE_INSTALL_MANDIR:PATH=myman"
+ "-DCMAKE_INSTALL_DOCDIR:PATH=mydoc"
+ )
+run_install_test(FILES-TYPE-Cache)
+run_install_test(DIRECTORY-TYPE-Cache)
+unset(RunCMake_TEST_OPTIONS)
+
+set(RunCMake_TEST_OPTIONS
+ "-DCMAKE_INSTALL_LOCALSTATEDIR:PATH=myvar"
+ "-DCMAKE_INSTALL_DATAROOTDIR:PATH=myshare"
+ )
+run_install_test(FILES-TYPE-CacheDependent)
+run_install_test(DIRECTORY-TYPE-CacheDependent)
+unset(RunCMake_TEST_OPTIONS)
+
+set(RunCMake_TEST_OPTIONS "-DCMAKE_BUILD_TYPE:STRING=Debug")
+run_install_test(TARGETS-OUTPUT_NAME)
+unset(RunCMake_TEST_OPTIONS)
+
+run_install_test(Deprecated)
+run_install_test(PRE_POST_INSTALL_SCRIPT)
+run_install_test(SCRIPT)
+run_install_test(TARGETS-CONFIGURATIONS)
+run_install_test(DIRECTORY-PATTERN)
+run_install_test(TARGETS-Parts)
+run_install_test(FILES-PERMISSIONS)
+run_install_test(TARGETS-RPATH)
+run_install_test(InstallRequiredSystemLibraries)
+
+if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
+ run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos)
+ run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos-unresolved)
+ run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos-conflict)
+ run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos-notfile)
+ run_cmake(file-GET_RUNTIME_DEPENDENCIES-project)
+ run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs1)
+ run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs2)
+elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
+ run_install_test(file-GET_RUNTIME_DEPENDENCIES-windows)
+ run_install_test(file-GET_RUNTIME_DEPENDENCIES-windows-unresolved)
+ run_install_test(file-GET_RUNTIME_DEPENDENCIES-windows-conflict)
+ run_install_test(file-GET_RUNTIME_DEPENDENCIES-windows-notfile)
+ run_cmake(file-GET_RUNTIME_DEPENDENCIES-project)
+ run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs1)
+ run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs2)
+elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
+ if(NOT CMAKE_C_COMPILER_ID MATCHES "^XL")
+ run_install_test(file-GET_RUNTIME_DEPENDENCIES-linux)
+ endif()
+ run_install_test(file-GET_RUNTIME_DEPENDENCIES-linux-unresolved)
+ run_install_test(file-GET_RUNTIME_DEPENDENCIES-linux-conflict)
+ run_install_test(file-GET_RUNTIME_DEPENDENCIES-linux-notfile)
+ run_cmake(file-GET_RUNTIME_DEPENDENCIES-project)
+ run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs1)
+ run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs2)
+else()
+ run_cmake(file-GET_RUNTIME_DEPENDENCIES-unsupported)
+endif()
+
set(run_install_test_components 1)
run_install_test(FILES-EXCLUDE_FROM_ALL)
run_install_test(TARGETS-EXCLUDE_FROM_ALL)
+run_install_test(TARGETS-NAMELINK_COMPONENT)
+run_install_test(SCRIPT-COMPONENT)
diff --git a/Tests/RunCMake/install/SCRIPT-COMPONENT-all-check.cmake b/Tests/RunCMake/install/SCRIPT-COMPONENT-all-check.cmake
new file mode 100644
index 000000000..48d8e1aec
--- /dev/null
+++ b/Tests/RunCMake/install/SCRIPT-COMPONENT-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^empty1.txt;empty2.txt$]])
diff --git a/Tests/RunCMake/install/SCRIPT-COMPONENT-dev-check.cmake b/Tests/RunCMake/install/SCRIPT-COMPONENT-dev-check.cmake
new file mode 100644
index 000000000..48d8e1aec
--- /dev/null
+++ b/Tests/RunCMake/install/SCRIPT-COMPONENT-dev-check.cmake
@@ -0,0 +1 @@
+check_installed([[^empty1.txt;empty2.txt$]])
diff --git a/Tests/RunCMake/install/SCRIPT-COMPONENT-uns-check.cmake b/Tests/RunCMake/install/SCRIPT-COMPONENT-uns-check.cmake
new file mode 100644
index 000000000..e09a102af
--- /dev/null
+++ b/Tests/RunCMake/install/SCRIPT-COMPONENT-uns-check.cmake
@@ -0,0 +1 @@
+check_installed([[^$]])
diff --git a/Tests/RunCMake/install/SCRIPT-COMPONENT.cmake b/Tests/RunCMake/install/SCRIPT-COMPONENT.cmake
new file mode 100644
index 000000000..aaa9bd45a
--- /dev/null
+++ b/Tests/RunCMake/install/SCRIPT-COMPONENT.cmake
@@ -0,0 +1,5 @@
+install(
+ SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/install_script.cmake"
+ CODE "write_empty_file(empty2.txt)"
+ COMPONENT dev
+ )
diff --git a/Tests/RunCMake/install/SCRIPT-all-check.cmake b/Tests/RunCMake/install/SCRIPT-all-check.cmake
new file mode 100644
index 000000000..48d8e1aec
--- /dev/null
+++ b/Tests/RunCMake/install/SCRIPT-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^empty1.txt;empty2.txt$]])
diff --git a/Tests/RunCMake/install/SCRIPT.cmake b/Tests/RunCMake/install/SCRIPT.cmake
new file mode 100644
index 000000000..f857b5437
--- /dev/null
+++ b/Tests/RunCMake/install/SCRIPT.cmake
@@ -0,0 +1,4 @@
+install(
+ SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/install_script.cmake"
+ CODE "write_empty_file(empty2.txt)"
+ )
diff --git a/Tests/RunCMake/install/TARGETS-Apple-Defaults-result.txt b/Tests/RunCMake/install/TARGETS-Apple-Defaults-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-Apple-Defaults-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/TARGETS-Apple-Defaults-stderr.txt b/Tests/RunCMake/install/TARGETS-Apple-Defaults-stderr.txt
new file mode 100644
index 000000000..645882f52
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-Apple-Defaults-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at TARGETS-Apple-Defaults\.cmake:[0-9]+ \(install\):
+ install TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE executable
+ target "exe"\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+
+
+CMake Error at TARGETS-Apple-Defaults\.cmake:[0-9]+ \(install\):
+ install TARGETS given no FRAMEWORK DESTINATION for shared library FRAMEWORK
+ target "lib1"\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/install/TARGETS-Apple-Defaults.cmake b/Tests/RunCMake/install/TARGETS-Apple-Defaults.cmake
new file mode 100644
index 000000000..b60c31894
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-Apple-Defaults.cmake
@@ -0,0 +1,8 @@
+enable_language(C)
+
+add_executable(exe MACOSX_BUNDLE main.c)
+add_library(lib1 SHARED obj1.c)
+set_property(TARGET lib1 PROPERTY FRAMEWORK ON)
+
+install(TARGETS exe)
+install(TARGETS lib1)
diff --git a/Tests/RunCMake/install/TARGETS-CONFIGURATIONS-all-check.cmake b/Tests/RunCMake/install/TARGETS-CONFIGURATIONS-all-check.cmake
new file mode 100644
index 000000000..2866e7fb9
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-CONFIGURATIONS-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^src;src/main-d.c$]])
diff --git a/Tests/RunCMake/install/TARGETS-CONFIGURATIONS.cmake b/Tests/RunCMake/install/TARGETS-CONFIGURATIONS.cmake
new file mode 100644
index 000000000..5531cd2ff
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-CONFIGURATIONS.cmake
@@ -0,0 +1,2 @@
+install(FILES main.c DESTINATION src CONFIGURATIONS Debug RENAME main-d.c)
+install(FILES main.c DESTINATION src CONFIGURATIONS Release RENAME main-r.c)
diff --git a/Tests/RunCMake/install/TARGETS-Defaults-Cache-all-check.cmake b/Tests/RunCMake/install/TARGETS-Defaults-Cache-all-check.cmake
new file mode 100644
index 000000000..57ad6e140
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-Defaults-Cache-all-check.cmake
@@ -0,0 +1,49 @@
+if(WIN32)
+ set(_check_files
+ [[lib3]]
+ [[lib3/(lib)?lib3\.(dll\.a|lib)]]
+ [[lib4]]
+ [[lib4/(lib)?lib4\.dll]]
+ [[mybin]]
+ [[mybin/exe\.exe]]
+ [[mybin/(lib)?lib1\.dll]]
+ [[myinclude]]
+ [[myinclude/obj4\.h]]
+ [[myinclude/obj5\.h]]
+ [[mylib]]
+ [[mylib/(lib)?lib1\.(dll\.a|lib)]]
+ [[mylib/(lib)?lib2\.(a|lib)]]
+ )
+elseif(CYGWIN)
+ set(_check_files
+ [[lib3]]
+ [[lib3/liblib3\.dll\.a]]
+ [[lib4]]
+ [[lib4/cyglib4\.dll]]
+ [[mybin]]
+ [[mybin/cyglib1\.dll]]
+ [[mybin/exe\.exe]]
+ [[myinclude]]
+ [[myinclude/obj4\.h]]
+ [[myinclude/obj5\.h]]
+ [[mylib]]
+ [[mylib/liblib1\.dll\.a]]
+ [[mylib/liblib2\.a]]
+ )
+else()
+ set(_check_files
+ [[lib3]]
+ [[lib3/liblib3\.(dylib|so)]]
+ [[lib4]]
+ [[lib4/liblib4\.(dylib|so)]]
+ [[mybin]]
+ [[mybin/exe]]
+ [[myinclude]]
+ [[myinclude/obj4\.h]]
+ [[myinclude/obj5\.h]]
+ [[mylib]]
+ [[mylib/liblib1\.(dylib|so)]]
+ [[mylib/liblib2\.a]]
+ )
+endif()
+check_installed("^${_check_files}$")
diff --git a/Tests/RunCMake/install/TARGETS-Defaults-Cache.cmake b/Tests/RunCMake/install/TARGETS-Defaults-Cache.cmake
new file mode 100644
index 000000000..bfd8c2c61
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-Defaults-Cache.cmake
@@ -0,0 +1,19 @@
+enable_language(C)
+
+add_executable(exe main.c)
+add_library(lib1 SHARED obj1.c)
+add_library(lib2 STATIC obj3.c)
+add_library(lib3 SHARED obj4.c)
+set_property(TARGET lib3 PROPERTY PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj4.h)
+add_library(lib4 SHARED obj5.c)
+set_property(TARGET lib4 PROPERTY PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj5.h)
+
+install(TARGETS exe lib1 lib2)
+install(TARGETS lib3
+ LIBRARY DESTINATION lib3
+ ARCHIVE DESTINATION lib3
+ )
+install(TARGETS lib4
+ LIBRARY DESTINATION lib4
+ RUNTIME DESTINATION lib4
+ )
diff --git a/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake b/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake
new file mode 100644
index 000000000..15335b2a9
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake
@@ -0,0 +1,55 @@
+if(WIN32)
+ set(_check_files
+ [[bin]]
+ [[bin/exe\.exe]]
+ [[bin/(lib)?lib1\.dll]]
+ [[include]]
+ [[include/obj1\.h]]
+ [[include/obj2\.h]]
+ [[include/obj4\.h]]
+ [[include/obj5\.h]]
+ [[lib]]
+ [[lib/(lib)?lib1\.(dll\.a|lib)]]
+ [[lib/(lib)?lib2\.(a|lib)]]
+ [[lib3]]
+ [[lib3/(lib)?lib3\.(dll\.a|lib)]]
+ [[lib4]]
+ [[lib4/(lib)?lib4\.dll]]
+ )
+elseif(CYGWIN)
+ set(_check_files
+ [[bin]]
+ [[bin/cyglib1\.dll]]
+ [[bin/exe\.exe]]
+ [[include]]
+ [[include/obj1\.h]]
+ [[include/obj2\.h]]
+ [[include/obj4\.h]]
+ [[include/obj5\.h]]
+ [[lib]]
+ [[lib/liblib1\.dll\.a]]
+ [[lib/liblib2\.a]]
+ [[lib3]]
+ [[lib3/liblib3\.dll\.a]]
+ [[lib4]]
+ [[lib4/cyglib4\.dll]]
+ )
+else()
+ set(_check_files
+ [[bin]]
+ [[bin/exe]]
+ [[include]]
+ [[include/obj1\.h]]
+ [[include/obj2\.h]]
+ [[include/obj4\.h]]
+ [[include/obj5\.h]]
+ [[lib]]
+ [[lib/liblib1\.(dylib|so)]]
+ [[lib/liblib2\.a]]
+ [[lib3]]
+ [[lib3/liblib3\.(dylib|so)]]
+ [[lib4]]
+ [[lib4/liblib4\.(dylib|so)]]
+ )
+endif()
+check_installed("^${_check_files}$")
diff --git a/Tests/RunCMake/install/TARGETS-Defaults.cmake b/Tests/RunCMake/install/TARGETS-Defaults.cmake
new file mode 100644
index 000000000..324aa111f
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-Defaults.cmake
@@ -0,0 +1,27 @@
+enable_language(C)
+
+add_executable(exe main.c)
+add_library(lib1 SHARED obj1.c)
+add_library(lib2 STATIC obj3.c)
+add_library(lib3 SHARED obj4.c)
+set_property(TARGET lib3 PROPERTY PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj4.h)
+add_library(lib4 SHARED obj5.c)
+set_property(TARGET lib4 PROPERTY PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj5.h)
+
+add_library(iface INTERFACE)
+set_target_properties(iface PROPERTIES
+ PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj1.h
+ PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj2.h)
+
+install(TARGETS exe lib1 lib2)
+install(TARGETS lib3
+ LIBRARY DESTINATION lib3
+ ARCHIVE DESTINATION lib3
+ )
+install(TARGETS lib4
+ LIBRARY DESTINATION lib4
+ RUNTIME DESTINATION lib4
+ )
+install(TARGETS iface
+ PUBLIC_HEADER DESTINATION include
+ PRIVATE_HEADER DESTINATION include)
diff --git a/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-check-common.cmake b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-check-common.cmake
new file mode 100644
index 000000000..673fdde19
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-check-common.cmake
@@ -0,0 +1,30 @@
+file(READ ${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake install_script)
+#message(STATUS ${install_script})
+
+set(wsnl " *[\n\r]+ *") # whitespace + single newline + whitespace
+set(wssl " *[\n\r]+[^\n\r]*[\n\r]+ *") # ws nl skipline nl ws
+string(CONCAT prefix [[file\(RPATH_CHANGE]])
+set(_msg "cmake_install.cmake does not match ")
+
+macro(check)
+ if(NOT install_script MATCHES "${regex}")
+ message(STATUS "${test} - check \"${target}\" - FAILED:")
+ string(CONCAT RunCMake_TEST_FAILED "${_msg}" ">>>${regex}<<<")
+ return()
+ else()
+ message(STATUS "${test} - check \"${target}\" - PASSED")
+ endif()
+endmacro()
+
+macro(skip_without_rpath_change_rule)
+# Not all platforms generate a file(RPATH_CHANGE) rule
+ if(NOT install_script MATCHES [[file\(RPATH_CHANGE]])
+ # Sanity check against a platform known to generate a file(RPATH_CHANGE) rule
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ message(FATAL_ERROR "Expected generated file(RPATH_CHANGE) rule on platform Linux.")
+ else()
+ message(STATUS "${test} - All checks skipped. No file(RPATH_CHANGE) rule found on this platform.")
+ return()
+ endif()
+ endif()
+endmacro()
diff --git a/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-check.cmake b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-check.cmake
new file mode 100644
index 000000000..930ef7044
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-check.cmake
@@ -0,0 +1,63 @@
+include(${RunCMake_SOURCE_DIR}/TARGETS-FILE_RPATH_CHANGE-check-common.cmake)
+skip_without_rpath_change_rule()
+string(APPEND prefix "${wsnl}" [[FILE "[^"]*/]])
+
+set(target "exe1_cmp0095_old")
+string(CONCAT regex "${prefix}${target}\"${wssl}"
+ [[NEW_RPATH "/foo/bar]])
+check()
+
+set(target "exe1_cmp0095_warn")
+string(CONCAT regex "${prefix}${target}\"${wssl}"
+ [[NEW_RPATH "/foo/bar]])
+check()
+
+set(target "exe1_cmp0095_new")
+string(CONCAT regex "${prefix}${target}\"${wssl}"
+ [[NEW_RPATH "/foo/bar]])
+check()
+
+set(target "exe2_cmp0095_old")
+string(CONCAT regex "${prefix}${target}\"${wssl}"
+ [[NEW_RPATH "\$ORIGIN/../lib]])
+check()
+
+set(target "exe2_cmp0095_warn")
+string(CONCAT regex "${prefix}${target}\"${wssl}"
+ [[NEW_RPATH "\$ORIGIN/../lib]])
+check()
+
+set(target "exe2_cmp0095_new")
+string(CONCAT regex "${prefix}${target}\"${wssl}"
+ [[NEW_RPATH "\\\$ORIGIN/../lib]])
+check()
+
+set(target "exe3_cmp0095_old")
+string(CONCAT regex "${prefix}${target}\"${wssl}"
+ [[NEW_RPATH "\${ORIGIN}/../lib]])
+check()
+
+set(target "exe3_cmp0095_warn")
+string(CONCAT regex "${prefix}${target}\"${wssl}"
+ [[NEW_RPATH "\${ORIGIN}/../lib]])
+check()
+
+set(target "exe3_cmp0095_new")
+string(CONCAT regex "${prefix}${target}\"${wssl}"
+ [[NEW_RPATH "\\\${ORIGIN}/../lib]])
+check()
+
+set(target "exe4_cmp0095_old")
+string(CONCAT regex "${prefix}${target}\"${wssl}"
+ [[NEW_RPATH "/foo/bar/\${PLATFORM}]])
+check()
+
+set(target "exe4_cmp0095_warn")
+string(CONCAT regex "${prefix}${target}\"${wssl}"
+ [[NEW_RPATH "/foo/bar/\${PLATFORM}]])
+check()
+
+set(target "exe4_cmp0095_new")
+string(CONCAT regex "${prefix}${target}\"${wssl}"
+ [[NEW_RPATH "/foo/bar/\\\${PLATFORM}]])
+check()
diff --git a/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt
new file mode 100644
index 000000000..1e123f6e5
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt
@@ -0,0 +1,23 @@
+^CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(install\):
+ Policy CMP0095 is not set: RPATH entries are properly escaped in the
+ intermediary CMake install script\. Run "cmake --help-policy CMP0095" for
+ policy details\. Use the cmake_policy command to set the policy and
+ suppress this warning\.
+
+ RPATH entries for target 'exe3_cmp0095_warn' will not be escaped in the
+ intermediary cmake_install\.cmake script\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\. Use -Wno-dev to suppress it\.
+
+CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(install\):
+ Policy CMP0095 is not set: RPATH entries are properly escaped in the
+ intermediary CMake install script\. Run "cmake --help-policy CMP0095" for
+ policy details\. Use the cmake_policy command to set the policy and
+ suppress this warning\.
+
+ RPATH entries for target 'exe4_cmp0095_warn' will not be escaped in the
+ intermediary cmake_install\.cmake script\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\. Use -Wno-dev to suppress it\.$
diff --git a/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath.cmake b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath.cmake
new file mode 100644
index 000000000..cba04b266
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath.cmake
@@ -0,0 +1,72 @@
+cmake_minimum_required(VERSION 3.14)
+enable_language(C)
+
+# test matrix
+#
+# A :=
+# | no cmake syntax | cmake syntax |
+# -----------------------+-----------------+--------------+
+# absolute install RPATH | exe1 | exe4 |
+# relative install RPATH | exe2 | exe3 |
+#
+# all := A * CMP005_OLD + A * CMP0095_WARN + A * CMP0095_NEW
+
+add_library(utils SHARED obj1.c)
+set(targets utils)
+
+set(exe1_install_rpath "/foo/bar")
+set(exe2_install_rpath "\$ORIGIN/../lib")
+set(exe3_install_rpath "\${ORIGIN}/../lib")
+set(exe4_install_rpath "/foo/bar/\${PLATFORM}")
+
+macro(A_CMP0095 policy_value)
+ cmake_policy(PUSH)
+ if(NOT "x${policy_value}x" STREQUAL "xWARNx")
+ cmake_policy(SET CMP0095 ${policy_value})
+ endif()
+ string(TOLOWER "${policy_value}" p)
+
+ # exe1: absolute install RPATH, no cmake syntax
+ set(case "exe1")
+ set(target "${case}_cmp0095_${p}")
+ list(APPEND targets ${target})
+ add_executable(${target} main.c)
+ target_link_libraries(${target} PRIVATE utils)
+ set_target_properties(${target} PROPERTIES
+ INSTALL_RPATH "${${case}_install_rpath}")
+
+ # exe2: relative install RPATH, no cmake syntax
+ set(case "exe2")
+ set(target "${case}_cmp0095_${p}")
+ list(APPEND targets ${target})
+ add_executable(${target} main.c)
+ target_link_libraries(${target} PRIVATE utils)
+ set_target_properties(${target} PROPERTIES
+ INSTALL_RPATH "${${case}_install_rpath}")
+
+ # exe3: relative install RPATH, cmake syntax
+ set(case "exe3")
+ set(target "${case}_cmp0095_${p}")
+ list(APPEND targets ${target})
+ add_executable(${target} main.c)
+ target_link_libraries(${target} PRIVATE utils)
+ set_target_properties(${target} PROPERTIES
+ INSTALL_RPATH "${${case}_install_rpath}")
+
+ # exe4: absolute install RPATH, cmake syntax
+ set(case "exe4")
+ set(target "${case}_cmp0095_${p}")
+ list(APPEND targets ${target})
+ add_executable(${target} main.c)
+ target_link_libraries(${target} PRIVATE utils)
+ set_target_properties(${target} PROPERTIES
+ INSTALL_RPATH "${${case}_install_rpath}")
+
+ cmake_policy(POP)
+endmacro()
+
+A_CMP0095("OLD")
+A_CMP0095("WARN") # exe3 and exe4 are expected to issue an author warning
+A_CMP0095("NEW")
+
+install(TARGETS ${targets})
diff --git a/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-old_rpath-check.cmake b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-old_rpath-check.cmake
new file mode 100644
index 000000000..814f405a9
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-old_rpath-check.cmake
@@ -0,0 +1,15 @@
+include(${RunCMake_SOURCE_DIR}/TARGETS-FILE_RPATH_CHANGE-check-common.cmake)
+skip_without_rpath_change_rule()
+string(APPEND prefix "${wsnl}" [[FILE "[^"]*/]])
+
+set(target "exe1")
+string(CONCAT regex "${prefix}${target}\"${wsnl}"
+ [[OLD_RPATH "]] "${RunCMake_BINARY_DIR}")
+check()
+
+if("x${CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN}" STREQUAL "x\$ORIGIN")
+ set(target "exe2")
+ string(CONCAT regex "${prefix}${target}\"${wsnl}"
+ [[OLD_RPATH "\\\$ORIGIN]])
+ check()
+endif()
diff --git a/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-old_rpath.cmake b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-old_rpath.cmake
new file mode 100644
index 000000000..43ae78708
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-old_rpath.cmake
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.14)
+enable_language(C)
+
+add_library(utils SHARED obj1.c)
+
+# exe1: absolute build RPATH, no cmake syntax
+set(CMAKE_BUILD_RPATH_USE_ORIGIN OFF)
+set(CMAKE_INSTALL_RPATH "/foo/bar")
+add_executable(exe1 main.c)
+target_link_libraries(exe1 PRIVATE utils)
+
+# exe2: relative build RPATH, no cmake syntax
+set(CMAKE_BUILD_RPATH_USE_ORIGIN ON)
+set(CMAKE_INSTALL_RPATH "/foo/bar")
+add_executable(exe2 main.c)
+target_link_libraries(exe2 PRIVATE utils)
+
+install(TARGETS utils exe1 exe2)
diff --git a/Tests/RunCMake/install/TARGETS-ImportedGlobal-result.txt b/Tests/RunCMake/install/TARGETS-ImportedGlobal-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-ImportedGlobal-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/TARGETS-ImportedGlobal-stderr.txt b/Tests/RunCMake/install/TARGETS-ImportedGlobal-stderr.txt
new file mode 100644
index 000000000..d67802bb5
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-ImportedGlobal-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TARGETS-ImportedGlobal.cmake:[0-9]+ \(install\):
+ install TARGETS given target "imported_global" which does not exist.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/install/TARGETS-ImportedGlobal.cmake b/Tests/RunCMake/install/TARGETS-ImportedGlobal.cmake
new file mode 100644
index 000000000..08c20bd4e
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-ImportedGlobal.cmake
@@ -0,0 +1,3 @@
+add_library(imported_global STATIC IMPORTED GLOBAL)
+set_property(TARGET imported_global PROPERTY IMPORTED_LOCATION /does_not_exist)
+install(TARGETS imported_global DESTINATION bin)
diff --git a/Tests/RunCMake/install/TARGETS-InstallFromSubDir-all-check.cmake b/Tests/RunCMake/install/TARGETS-InstallFromSubDir-all-check.cmake
new file mode 100644
index 000000000..1d747c301
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-InstallFromSubDir-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^bin;bin/myexe(\.exe)?;bin/subexe(\.exe)?$]])
diff --git a/Tests/RunCMake/install/TARGETS-InstallFromSubDir.cmake b/Tests/RunCMake/install/TARGETS-InstallFromSubDir.cmake
new file mode 100644
index 000000000..8615d6ecb
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-InstallFromSubDir.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+add_executable(myexe main.c)
+add_subdirectory(TARGETS-InstallFromSubDir)
+install(TARGETS myexe subexe DESTINATION bin)
diff --git a/Tests/RunCMake/install/TARGETS-InstallFromSubDir/CMakeLists.txt b/Tests/RunCMake/install/TARGETS-InstallFromSubDir/CMakeLists.txt
new file mode 100644
index 000000000..477d9381f
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-InstallFromSubDir/CMakeLists.txt
@@ -0,0 +1 @@
+add_executable(subexe ../main.c)
diff --git a/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-all-check.cmake b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-all-check.cmake
new file mode 100644
index 000000000..bc9ebd192
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-all-check.cmake
@@ -0,0 +1,73 @@
+if(WIN32)
+ set(_check_files
+ [[lib]]
+ [[lib/(lib)?namelink-none\.dll]]
+ [[lib/(lib)?namelink-same\.dll]]
+ [[lib/(lib)?namelink-sep\.dll]]
+ [[lib/(lib)?namelink-skip\.dll]]
+ [[lib/(lib)?namelink-uns-dev\.dll]]
+ [[lib/(lib)?namelink-uns\.dll]]
+ )
+elseif(CYGWIN)
+ set(_check_files
+ [[lib]]
+ [[lib/cygnamelink-none\.dll]]
+ [[lib/cygnamelink-same-1\.dll]]
+ [[lib/cygnamelink-sep-1\.dll]]
+ [[lib/cygnamelink-skip-1\.dll]]
+ [[lib/cygnamelink-uns-1\.dll]]
+ [[lib/cygnamelink-uns-dev-1\.dll]]
+ )
+elseif(APPLE)
+ set(_check_files
+ [[lib]]
+ [[lib/libnamelink-none\.dylib]]
+ [[lib/libnamelink-only\.dylib]]
+ [[lib/libnamelink-same\.1\.0\.dylib]]
+ [[lib/libnamelink-same\.1\.dylib]]
+ [[lib/libnamelink-same\.dylib]]
+ [[lib/libnamelink-sep\.1\.0\.dylib]]
+ [[lib/libnamelink-sep\.1\.dylib]]
+ [[lib/libnamelink-sep\.dylib]]
+ [[lib/libnamelink-skip\.1\.0\.dylib]]
+ [[lib/libnamelink-skip\.1\.dylib]]
+ [[lib/libnamelink-uns-dev\.1\.0\.dylib]]
+ [[lib/libnamelink-uns-dev\.1\.dylib]]
+ [[lib/libnamelink-uns-dev\.dylib]]
+ [[lib/libnamelink-uns\.1\.0\.dylib]]
+ [[lib/libnamelink-uns\.1\.dylib]]
+ [[lib/libnamelink-uns\.dylib]]
+ )
+elseif(NO_NAMELINK)
+ set(_check_files
+ [[lib]]
+ [[lib/libnamelink-none\.so]]
+ [[lib/libnamelink-same\.so]]
+ [[lib/libnamelink-sep\.so]]
+ [[lib/libnamelink-skip\.so]]
+ [[lib/libnamelink-uns-dev\.so]]
+ [[lib/libnamelink-uns\.so]]
+ )
+else()
+ set(_check_files
+ [[lib]]
+ [[lib/libnamelink-none\.so]]
+ [[lib/libnamelink-only\.so]]
+ [[lib/libnamelink-same\.so]]
+ [[lib/libnamelink-same\.so\.1]]
+ [[lib/libnamelink-same\.so\.1\.0]]
+ [[lib/libnamelink-sep\.so]]
+ [[lib/libnamelink-sep\.so\.1]]
+ [[lib/libnamelink-sep\.so\.1\.0]]
+ [[lib/libnamelink-skip\.so\.1]]
+ [[lib/libnamelink-skip\.so\.1\.0]]
+ [[lib/libnamelink-uns-dev\.so]]
+ [[lib/libnamelink-uns-dev\.so\.1]]
+ [[lib/libnamelink-uns-dev\.so\.1\.0]]
+ [[lib/libnamelink-uns\.so]]
+ [[lib/libnamelink-uns\.so\.1]]
+ [[lib/libnamelink-uns\.so\.1\.0]]
+ )
+endif()
+
+check_installed("^${_check_files}$")
diff --git a/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-all-result.txt b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-all-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-all-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-all-stderr.txt b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-all-stderr.txt
new file mode 100644
index 000000000..fe65fd300
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-all-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at TARGETS-NAMELINK_COMPONENT-bad-all\.cmake:5 \(install\):
+ install TARGETS given NAMELINK_COMPONENT option not in LIBRARY group\. The
+ NAMELINK_COMPONENT option may be specified only following LIBRARY\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-all.cmake b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-all.cmake
new file mode 100644
index 000000000..701d0931c
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-all.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+add_library(namelink-lib empty.c)
+
+install(TARGETS namelink-lib
+ DESTINATION lib
+ COMPONENT lib
+ NAMELINK_COMPONENT dev
+)
diff --git a/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-exc-result.txt b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-exc-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-exc-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-exc-stderr.txt b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-exc-stderr.txt
new file mode 100644
index 000000000..60f52c488
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-exc-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at TARGETS-NAMELINK_COMPONENT-bad-exc\.cmake:5 \(install\):
+ install TARGETS given NAMELINK_COMPONENT option not in LIBRARY group\. The
+ NAMELINK_COMPONENT option may be specified only following LIBRARY\.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-exc.cmake b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-exc.cmake
new file mode 100644
index 000000000..19c12d4bc
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-bad-exc.cmake
@@ -0,0 +1,10 @@
+enable_language(C)
+
+add_executable(namelink-exc main.c)
+
+install(TARGETS namelink-exc
+ RUNTIME
+ DESTINATION bin
+ COMPONENT exc
+ NAMELINK_COMPONENT dev
+)
diff --git a/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-dev-check.cmake b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-dev-check.cmake
new file mode 100644
index 000000000..5396cdbf3
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-dev-check.cmake
@@ -0,0 +1,11 @@
+if(WIN32 OR CYGWIN OR NO_NAMELINK)
+ set(_check_files)
+else()
+ set(_check_files
+ [[lib]]
+ [[lib/libnamelink-only\.(so|dylib)]]
+ [[lib/libnamelink-sep\.(so|dylib)]]
+ [[lib/libnamelink-uns-dev\.(so|dylib)]]
+ )
+endif()
+check_installed("^${_check_files}$")
diff --git a/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-lib-check.cmake b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-lib-check.cmake
new file mode 100644
index 000000000..3f6be686c
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-lib-check.cmake
@@ -0,0 +1,50 @@
+if(WIN32)
+ set(_check_files
+ [[lib]]
+ [[lib/(lib)?namelink-none\.dll]]
+ [[lib/(lib)?namelink-same\.dll]]
+ [[lib/(lib)?namelink-sep\.dll]]
+ [[lib/(lib)?namelink-skip\.dll]]
+ )
+elseif(CYGWIN)
+ set(_check_files
+ [[lib]]
+ [[lib/cygnamelink-none\.dll]]
+ [[lib/cygnamelink-same-1\.dll]]
+ [[lib/cygnamelink-sep-1\.dll]]
+ [[lib/cygnamelink-skip-1\.dll]]
+ )
+elseif(APPLE)
+ set(_check_files
+ [[lib]]
+ [[lib/libnamelink-none\.dylib]]
+ [[lib/libnamelink-same\.1\.0\.dylib]]
+ [[lib/libnamelink-same\.1\.dylib]]
+ [[lib/libnamelink-same\.dylib]]
+ [[lib/libnamelink-sep\.1\.0\.dylib]]
+ [[lib/libnamelink-sep\.1\.dylib]]
+ [[lib/libnamelink-skip\.1\.0\.dylib]]
+ [[lib/libnamelink-skip\.1\.dylib]]
+ )
+elseif(NO_NAMELINK)
+ set(_check_files
+ [[lib]]
+ [[lib/libnamelink-none\.so]]
+ [[lib/libnamelink-same\.so]]
+ [[lib/libnamelink-sep\.so]]
+ [[lib/libnamelink-skip\.so]]
+ )
+else()
+ set(_check_files
+ [[lib]]
+ [[lib/libnamelink-none\.so]]
+ [[lib/libnamelink-same\.so]]
+ [[lib/libnamelink-same\.so\.1]]
+ [[lib/libnamelink-same\.so\.1\.0]]
+ [[lib/libnamelink-sep\.so\.1]]
+ [[lib/libnamelink-sep\.so\.1\.0]]
+ [[lib/libnamelink-skip\.so\.1]]
+ [[lib/libnamelink-skip\.so\.1\.0]]
+ )
+endif()
+check_installed("^${_check_files}$")
diff --git a/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-uns-check.cmake b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-uns-check.cmake
new file mode 100644
index 000000000..0033c88e4
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT-uns-check.cmake
@@ -0,0 +1,38 @@
+if(WIN32)
+ set(_check_files
+ [[lib]]
+ [[lib/(lib)?namelink-uns-dev\.dll]]
+ [[lib/(lib)?namelink-uns\.dll]]
+ )
+elseif(CYGWIN)
+ set(_check_files
+ [[lib]]
+ [[lib/cygnamelink-uns-1\.dll]]
+ [[lib/cygnamelink-uns-dev-1\.dll]]
+ )
+elseif(APPLE)
+ set(_check_files
+ [[lib]]
+ [[lib/libnamelink-uns-dev\.1\.0\.dylib]]
+ [[lib/libnamelink-uns-dev\.1\.dylib]]
+ [[lib/libnamelink-uns\.1\.0\.dylib]]
+ [[lib/libnamelink-uns\.1\.dylib]]
+ [[lib/libnamelink-uns\.dylib]]
+ )
+elseif(NO_NAMELINK)
+ set(_check_files
+ [[lib]]
+ [[lib/libnamelink-uns-dev\.so]]
+ [[lib/libnamelink-uns\.so]]
+ )
+else()
+ set(_check_files
+ [[lib]]
+ [[lib/libnamelink-uns-dev\.so\.1]]
+ [[lib/libnamelink-uns-dev\.so\.1\.0]]
+ [[lib/libnamelink-uns\.so]]
+ [[lib/libnamelink-uns\.so\.1]]
+ [[lib/libnamelink-uns\.so\.1\.0]]
+ )
+endif()
+check_installed("^${_check_files}$")
diff --git a/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT.cmake b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT.cmake
new file mode 100644
index 000000000..0e684e184
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-NAMELINK_COMPONENT.cmake
@@ -0,0 +1,68 @@
+enable_language(C)
+
+macro(add_versioned_library NAME)
+ add_library(${NAME} SHARED obj1.c)
+ set_target_properties(${NAME} PROPERTIES
+ VERSION 1.0
+ SOVERSION 1
+ )
+endmacro()
+
+add_versioned_library(namelink-sep)
+add_versioned_library(namelink-same)
+add_versioned_library(namelink-uns)
+add_versioned_library(namelink-uns-dev)
+add_versioned_library(namelink-only)
+add_versioned_library(namelink-skip)
+add_library(namelink-none SHARED obj1.c)
+
+install(TARGETS namelink-sep namelink-none
+ RUNTIME
+ DESTINATION lib
+ COMPONENT lib
+ LIBRARY
+ DESTINATION lib
+ COMPONENT lib
+ NAMELINK_COMPONENT dev
+)
+install(TARGETS namelink-same
+ RUNTIME
+ DESTINATION lib
+ COMPONENT lib
+ LIBRARY
+ DESTINATION lib
+ COMPONENT lib
+)
+install(TARGETS namelink-uns
+ RUNTIME
+ DESTINATION lib
+ LIBRARY
+ DESTINATION lib
+)
+install(TARGETS namelink-uns-dev
+ RUNTIME
+ DESTINATION lib
+ LIBRARY
+ DESTINATION lib
+ NAMELINK_COMPONENT dev
+)
+install(TARGETS namelink-only
+ RUNTIME
+ DESTINATION lib
+ COMPONENT lib
+ LIBRARY
+ DESTINATION lib
+ COMPONENT lib
+ NAMELINK_COMPONENT dev
+ NAMELINK_ONLY
+)
+install(TARGETS namelink-skip
+ RUNTIME
+ DESTINATION lib
+ COMPONENT lib
+ LIBRARY
+ DESTINATION lib
+ COMPONENT lib
+ NAMELINK_COMPONENT dev
+ NAMELINK_SKIP
+)
diff --git a/Tests/RunCMake/install/TARGETS-OPTIONAL-all-check.cmake b/Tests/RunCMake/install/TARGETS-OPTIONAL-all-check.cmake
new file mode 100644
index 000000000..bcf71ddfe
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-OPTIONAL-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^bin;bin/myexe(\.exe)?$]])
diff --git a/Tests/RunCMake/install/TARGETS-OPTIONAL.cmake b/Tests/RunCMake/install/TARGETS-OPTIONAL.cmake
new file mode 100644
index 000000000..d3c5cdae2
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-OPTIONAL.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+add_executable(myexe main.c)
+add_executable(notall EXCLUDE_FROM_ALL main.c)
+install(TARGETS myexe notall DESTINATION bin OPTIONAL)
diff --git a/Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake
new file mode 100644
index 000000000..5daecc815
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME-all-check.cmake
@@ -0,0 +1,13 @@
+if(WIN32)
+ set(test123 [[bin/test1out\.exe;bin/test2deb\.exe;bin/test3exc\.exe]])
+ set(libtest45 [[bin/libtest4\.dll;bin/libtest4\.dll\.a;bin/libtest5ar\.a]])
+ set(test45 [[bin/test4\.dll;bin/test4\.lib;bin/test5ar\.lib]])
+
+ check_installed("^bin;(${libtest45};${test123})|(${test123};${test45})\$")
+elseif(CYGWIN)
+ check_installed([[^bin;bin/cygtest4\.dll;bin/libtest4\.dll\.a;bin/libtest5ar\.a;bin/test1out\.exe;bin/test2deb\.exe;bin/test3exc\.exe$]])
+elseif(APPLE)
+ check_installed([[^bin;bin/libtest4lib\.dylib;bin/libtest5ar\.a;bin/test1out;bin/test2deb;bin/test3exc$]])
+else()
+ check_installed([[^bin;bin/libtest4lib\.so;bin/libtest5ar\.a;bin/test1out;bin/test2deb;bin/test3exc$]])
+endif()
diff --git a/Tests/RunCMake/install/TARGETS-OUTPUT_NAME.cmake b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME.cmake
new file mode 100644
index 000000000..67e706941
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-OUTPUT_NAME.cmake
@@ -0,0 +1,27 @@
+enable_language(C)
+
+add_executable(test1 main.c)
+set_property(TARGET test1 PROPERTY OUTPUT_NAME test1out)
+set_property(TARGET test1 PROPERTY RELEASE_OUTPUT_NAME test1rel)
+
+add_executable(test2 main.c)
+set_property(TARGET test2 PROPERTY OUTPUT_NAME test2out)
+set_property(TARGET test2 PROPERTY DEBUG_OUTPUT_NAME test2deb)
+
+add_executable(test3 main.c)
+set_property(TARGET test3 PROPERTY RUNTIME_OUTPUT_NAME test3exc)
+
+add_library(test4 SHARED obj1.c)
+set_property(TARGET test4 PROPERTY LIBRARY_OUTPUT_NAME test4lib)
+
+add_library(test5 STATIC obj1.c)
+set_property(TARGET test5 PROPERTY ARCHIVE_OUTPUT_NAME test5ar)
+
+install(TARGETS
+ test1
+ test2
+ test3
+ test4
+ test5
+ DESTINATION bin
+ )
diff --git a/Tests/RunCMake/install/TARGETS-Parts-all-check.cmake b/Tests/RunCMake/install/TARGETS-Parts-all-check.cmake
new file mode 100644
index 000000000..6245839fc
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-Parts-all-check.cmake
@@ -0,0 +1 @@
+check_installed([[^include;include/obj1\.h;lib;lib/(mylib\.lib|(lib|cyg)mylib\.a)$]])
diff --git a/Tests/RunCMake/install/TARGETS-Parts.cmake b/Tests/RunCMake/install/TARGETS-Parts.cmake
new file mode 100644
index 000000000..2a46ab9a9
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-Parts.cmake
@@ -0,0 +1,7 @@
+enable_language(C)
+add_library(mylib STATIC obj1.c)
+set_property(TARGET mylib PROPERTY PUBLIC_HEADER obj1.h)
+install(TARGETS mylib
+ ARCHIVE DESTINATION lib
+ PUBLIC_HEADER DESTINATION include
+ )
diff --git a/Tests/RunCMake/install/TARGETS-RPATH-all-check.cmake b/Tests/RunCMake/install/TARGETS-RPATH-all-check.cmake
new file mode 100644
index 000000000..fa52d65cf
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-RPATH-all-check.cmake
@@ -0,0 +1,14 @@
+execute_process(
+ COMMAND "${CMAKE_INSTALL_PREFIX}/bin/myexe"
+ RESULT_VARIABLE MYEXE_RESULT
+ OUTPUT_VARIABLE MYEXE_OUTPUT
+ ERROR_VARIABLE MYEXE_ERROR
+ )
+
+if(NOT MYEXE_RESULT EQUAL "0")
+ set(RunCMake_TEST_FAILED "myexe returned [${MYEXE_RESULT}], was expecting [0]")
+elseif(NOT MYEXE_OUTPUT STREQUAL "")
+ set(RunCMake_TEST_FAILED "myexe printed nonempty output:\n${MYEXE_OUTPUT}")
+elseif(NOT MYEXE_ERROR STREQUAL "")
+ set(RunCMake_TEST_FAILED "myexe printed nonempty error:\n${MYEXE_ERROR}")
+endif()
diff --git a/Tests/RunCMake/install/TARGETS-RPATH.cmake b/Tests/RunCMake/install/TARGETS-RPATH.cmake
new file mode 100644
index 000000000..b75deffff
--- /dev/null
+++ b/Tests/RunCMake/install/TARGETS-RPATH.cmake
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.9)
+
+enable_language(C)
+
+set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
+add_library(mylib SHARED obj1.c)
+add_executable(myexe testobj1.c)
+target_link_libraries(myexe mylib)
+set_property(TARGET myexe PROPERTY INSTALL_RPATH "${CMAKE_CURRENT_BINARY_DIR}/root-all/bin")
+set_target_properties(mylib PROPERTIES VERSION 1.0 SOVERSION 1)
+
+install(TARGETS mylib myexe
+ DESTINATION bin
+ )
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs1-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs1-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs1-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs1-stderr.txt
new file mode 100644
index 000000000..b66d1fe5b
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs1-stderr.txt
@@ -0,0 +1,18 @@
+^CMake Warning \(dev\) at file-GET_RUNTIME_DEPENDENCIES-badargs1\.cmake:[0-9]+ \(file\):
+ You have used file\(GET_RUNTIME_DEPENDENCIES\) in project mode\. This is
+ probably not what you intended to do\. Instead, please consider using it in
+ an install\(CODE\) or install\(SCRIPT\) command\. For example:
+
+ install\(CODE \[\[
+ file\(GET_RUNTIME_DEPENDENCIES
+ # \.\.\.
+ \)
+ ]]\)
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\. Use -Wno-dev to suppress it\.
+
+CMake Error at file-GET_RUNTIME_DEPENDENCIES-badargs1\.cmake:[0-9]+ \(file\):
+ file Unrecognized argument: "invalid"
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs1.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs1.cmake
new file mode 100644
index 000000000..f3b8ce472
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs1.cmake
@@ -0,0 +1,2 @@
+file(GET_RUNTIME_DEPENDENCIES invalid)
+message(FATAL_ERROR "This message should not be displayed")
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs2-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs2-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs2-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs2-stderr.txt
new file mode 100644
index 000000000..50fa81fa1
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs2-stderr.txt
@@ -0,0 +1,23 @@
+^CMake Warning \(dev\) at file-GET_RUNTIME_DEPENDENCIES-badargs2\.cmake:[0-9]+ \(file\):
+ You have used file\(GET_RUNTIME_DEPENDENCIES\) in project mode\. This is
+ probably not what you intended to do\. Instead, please consider using it in
+ an install\(CODE\) or install\(SCRIPT\) command\. For example:
+
+ install\(CODE \[\[
+ file\(GET_RUNTIME_DEPENDENCIES
+ # \.\.\.
+ \)
+ ]]\)
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\. Use -Wno-dev to suppress it\.
+
+CMake Error at file-GET_RUNTIME_DEPENDENCIES-badargs2\.cmake:[0-9]+ \(file\):
+ file Keywords missing values:
+
+ RESOLVED_DEPENDENCIES_VAR
+ UNRESOLVED_DEPENDENCIES_VAR
+ CONFLICTING_DEPENDENCIES_PREFIX
+ BUNDLE_EXECUTABLE
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs2.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs2.cmake
new file mode 100644
index 000000000..ac6af8576
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-badargs2.cmake
@@ -0,0 +1,15 @@
+file(GET_RUNTIME_DEPENDENCIES
+ RESOLVED_DEPENDENCIES_VAR
+ UNRESOLVED_DEPENDENCIES_VAR
+ CONFLICTING_DEPENDENCIES_PREFIX
+ BUNDLE_EXECUTABLE
+ EXECUTABLES
+ LIBRARIES
+ MODULES
+ DIRECTORIES
+ PRE_INCLUDE_REGEXES
+ PRE_EXCLUDE_REGEXES
+ POST_INCLUDE_REGEXES
+ POST_EXCLUDE_REGEXES
+ )
+message(FATAL_ERROR "This message should not be displayed")
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-all-check.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-all-check.cmake
new file mode 100644
index 000000000..ab630f0ac
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-all-check.cmake
@@ -0,0 +1,44 @@
+function(check_contents filename contents_regex)
+ if(EXISTS "${CMAKE_INSTALL_PREFIX}/${filename}")
+ file(READ "${CMAKE_INSTALL_PREFIX}/${filename}" contents)
+ if(NOT contents MATCHES "${contents_regex}")
+ string(APPEND RunCMake_TEST_FAILED "File contents:
+ ${contents}
+do not match what we expected:
+ ${contents_regex}
+in file:
+ ${CMAKE_INSTALL_PREFIX}/${filename}\n")
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+ endif()
+ else()
+ string(APPEND RunCMake_TEST_FAILED "File ${CMAKE_INSTALL_PREFIX}/${filename} does not exist")
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+set(_check
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/libtest_rpath\.so]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/libtest_runpath\.so]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath/librpath\.so]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_parent/librpath_parent\.so]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search/librpath_search\.so]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath/librunpath\.so]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search/librunpath_search\.so]]
+ )
+check_contents(deps/deps1.txt "^${_check}$")
+check_contents(deps/deps2.txt "^${_check}$")
+check_contents(deps/deps3.txt "^${_check}$")
+set(_check
+ [[librpath_unresolved\.so]]
+ [[librunpath_parent_unresolved\.so]]
+ [[librunpath_unresolved\.so]]
+ )
+check_contents(deps/udeps1.txt "^${_check}$")
+check_contents(deps/udeps2.txt "^${_check}$")
+check_contents(deps/udeps3.txt "^${_check}$")
+set(_check
+ "^libconflict\\.so:[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/conflict/libconflict\\.so;[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/conflict2/libconflict\\.so\n$"
+ )
+check_contents(deps/cdeps1.txt "${_check}")
+check_contents(deps/cdeps2.txt "${_check}")
+check_contents(deps/cdeps3.txt "${_check}")
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-all-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-all-stderr.txt
new file mode 100644
index 000000000..123ae48ab
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-all-stderr.txt
@@ -0,0 +1,119 @@
+^CMake Warning at cmake_install\.cmake:[0-9]+ \(file\):
+ Dependency librpath_search_postexcluded\.so found in search directory:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search_postexcluded
+
+ See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\.
+Call Stack \(most recent call first\):
+ cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\)
+
+*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\):
+ Dependency librpath_search\.so found in search directory:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search
+
+ See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\.
+Call Stack \(most recent call first\):
+ cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\)
+
+*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\):
+ Dependency librunpath_search_postexcluded\.so found in search directory:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search_postexcluded
+
+ See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\.
+Call Stack \(most recent call first\):
+ cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\)
+
+*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\):
+ Dependency librunpath_search\.so found in search directory:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search
+
+ See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\.
+Call Stack \(most recent call first\):
+ cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\)
+
+*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\):
+ Dependency librpath_search_postexcluded\.so found in search directory:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search_postexcluded
+
+ See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\.
+Call Stack \(most recent call first\):
+ cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\)
+
+*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\):
+ Dependency librpath_search\.so found in search directory:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search
+
+ See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\.
+Call Stack \(most recent call first\):
+ cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\)
+
+*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\):
+ Dependency librunpath_search_postexcluded\.so found in search directory:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search_postexcluded
+
+ See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\.
+Call Stack \(most recent call first\):
+ cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\)
+
+*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\):
+ Dependency librunpath_search\.so found in search directory:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search
+
+ See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\.
+Call Stack \(most recent call first\):
+ cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\)
+
+*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\):
+ Dependency librpath_search_postexcluded\.so found in search directory:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search_postexcluded
+
+ See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\.
+Call Stack \(most recent call first\):
+ cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\)
+
+*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\):
+ Dependency librpath_search\.so found in search directory:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search
+
+ See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\.
+Call Stack \(most recent call first\):
+ cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\)
+
+*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\):
+ Dependency librunpath_search_postexcluded\.so found in search directory:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search_postexcluded
+
+ See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\.
+Call Stack \(most recent call first\):
+ cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\)
+
+*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\):
+ Dependency librunpath_search\.so found in search directory:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search
+
+ See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\.
+Call Stack \(most recent call first\):
+ cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\)$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-stderr.txt
new file mode 100644
index 000000000..1692348f4
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at cmake_install\.cmake:[0-9]+ \(file\):
+ file Multiple conflicting paths found for librpath\.so:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-build/root-all/lib/rpath1/librpath\.so
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-build/root-all/lib/rpath2/librpath\.so$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict.cmake
new file mode 100644
index 000000000..f7194995d
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-conflict.cmake
@@ -0,0 +1,54 @@
+enable_language(C)
+
+set(test1_names rpath)
+set(test2_names rpath)
+
+file(WRITE "${CMAKE_BINARY_DIR}/rpath.c" "void rpath(void) {}\n")
+add_library(rpath SHARED "${CMAKE_BINARY_DIR}/rpath.c")
+install(TARGETS rpath DESTINATION lib/rpath1)
+install(TARGETS rpath DESTINATION lib/rpath2)
+
+file(REMOVE "${CMAKE_BINARY_DIR}/test1.c")
+add_library(test1 SHARED "${CMAKE_BINARY_DIR}/test1.c")
+foreach(name ${test1_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "extern void ${name}(void);\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "void test1(void)\n{\n")
+foreach(name ${test1_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/test1.c" " ${name}();\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "}\n")
+
+target_link_libraries(test1 PRIVATE ${test1_names})
+set_property(TARGET test1 PROPERTY INSTALL_RPATH
+ "${CMAKE_BINARY_DIR}/root-all/lib/rpath1"
+ )
+
+file(REMOVE "${CMAKE_BINARY_DIR}/test2.c")
+add_library(test2 SHARED "${CMAKE_BINARY_DIR}/test2.c")
+foreach(name ${test2_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "extern void ${name}(void);\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "void test2(void)\n{\n")
+foreach(name ${test2_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/test2.c" " ${name}();\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "}\n")
+
+target_link_libraries(test2 PRIVATE ${test2_names})
+set_property(TARGET test2 PROPERTY INSTALL_RPATH
+ "${CMAKE_BINARY_DIR}/root-all/lib/rpath2"
+ )
+
+install(TARGETS test1 test2 DESTINATION lib)
+
+install(CODE [[
+ file(GET_RUNTIME_DEPENDENCIES
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:test1>"
+ "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:test2>"
+ PRE_INCLUDE_REGEXES "^librpath\\.so$"
+ PRE_EXCLUDE_REGEXES ".*"
+ )
+ message(FATAL_ERROR "This message should not be displayed")
+ ]])
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-stderr.txt
new file mode 100644
index 000000000..83a87c9c5
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at cmake_install\.cmake:[0-9]+ \(file\):
+ file Failed to run objdump on:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-build/root-all/bin/\.\./lib/libtest\.so$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-notfile.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-notfile.cmake
new file mode 100644
index 000000000..6567438a2
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-notfile.cmake
@@ -0,0 +1,30 @@
+enable_language(C)
+cmake_policy(SET CMP0095 NEW)
+
+file(WRITE "${CMAKE_BINARY_DIR}/test.c" "void test(void) {}\n")
+file(WRITE "${CMAKE_BINARY_DIR}/main.c" [[extern void test(void);
+
+int main(void)
+{
+ test();
+ return 0;
+}
+]])
+
+add_library(test SHARED "${CMAKE_BINARY_DIR}/test.c")
+add_executable(exe "${CMAKE_BINARY_DIR}/main.c")
+target_link_libraries(exe PRIVATE test)
+set_property(TARGET exe PROPERTY INSTALL_RPATH "\${ORIGIN}/../lib")
+
+install(TARGETS exe DESTINATION bin)
+
+install(CODE [[
+ file(MAKE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:test>")
+ file(GET_RUNTIME_DEPENDENCIES
+ EXECUTABLES
+ "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:exe>"
+ PRE_INCLUDE_REGEXES "^libtest\\.so$"
+ PRE_EXCLUDE_REGEXES ".*"
+ )
+ message(FATAL_ERROR "This message should not be displayed")
+ ]])
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-stderr.txt
new file mode 100644
index 000000000..eaca5121b
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at cmake_install\.cmake:[0-9]+ \(file\):
+ file Could not resolve file libunresolved\.so$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved.cmake
new file mode 100644
index 000000000..3efa305be
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved.cmake
@@ -0,0 +1,18 @@
+enable_language(C)
+
+file(WRITE "${CMAKE_BINARY_DIR}/testlib.c" "extern void unresolved(void);\nvoid testlib(void)\n{\n unresolved();\n}\n")
+add_library(testlib SHARED "${CMAKE_BINARY_DIR}/testlib.c")
+file(WRITE "${CMAKE_BINARY_DIR}/unresolved.c" "void unresolved(void) {}\n")
+add_library(unresolved SHARED "${CMAKE_BINARY_DIR}/unresolved.c")
+target_link_libraries(testlib PRIVATE unresolved)
+install(TARGETS testlib DESTINATION lib)
+
+install(CODE [[
+ file(GET_RUNTIME_DEPENDENCIES
+ PRE_INCLUDE_REGEXES "^libunresolved\\.so$"
+ PRE_EXCLUDE_REGEXES ".*"
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:testlib>"
+ )
+ message(FATAL_ERROR "This message should not be displayed")
+ ]])
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux.cmake
new file mode 100644
index 000000000..bd0f9f169
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux.cmake
@@ -0,0 +1,169 @@
+enable_language(C)
+cmake_policy(SET CMP0095 NEW)
+
+set(test_rpath_names
+ preexcluded
+ rpath_postexcluded
+ rpath
+ rpath_parent_postexcluded
+ rpath_parent
+ rpath_origin_postexcluded
+ rpath_origin
+ rpath_search_postexcluded
+ rpath_search
+ rpath_unresolved
+ conflict
+ )
+set(test_runpath_names
+ runpath_postexcluded
+ runpath
+ runpath_origin_postexcluded
+ runpath_origin
+ runpath_parent_unresolved
+ runpath_search_postexcluded
+ runpath_search
+ runpath_unresolved
+ )
+
+file(REMOVE "${CMAKE_BINARY_DIR}/test_rpath.c")
+add_library(test_rpath SHARED "${CMAKE_BINARY_DIR}/test_rpath.c")
+foreach(name ${test_rpath_names})
+ file(WRITE "${CMAKE_BINARY_DIR}/${name}.c" "void ${name}(void) {}\n")
+ add_library(${name} SHARED "${CMAKE_BINARY_DIR}/${name}.c")
+
+ file(APPEND "${CMAKE_BINARY_DIR}/test_rpath.c" "extern void ${name}(void);\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test_rpath.c" "void test_rpath(void)\n{\n")
+foreach(name ${test_rpath_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/test_rpath.c" " ${name}();\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test_rpath.c" "}\n")
+
+install(TARGETS rpath_postexcluded DESTINATION lib/rpath_postexcluded)
+install(TARGETS rpath DESTINATION lib/rpath)
+install(TARGETS rpath_origin_postexcluded DESTINATION lib/rpath_origin_postexcluded)
+install(TARGETS rpath_origin DESTINATION lib/rpath_origin)
+install(TARGETS rpath_parent_postexcluded DESTINATION lib/rpath_parent_postexcluded)
+install(TARGETS rpath rpath_origin rpath_parent DESTINATION lib/rpath_parent)
+install(TARGETS rpath_search_postexcluded DESTINATION lib/rpath_search_postexcluded)
+install(TARGETS rpath rpath_origin rpath_parent rpath_search DESTINATION lib/rpath_search)
+install(TARGETS conflict DESTINATION lib/conflict)
+
+target_link_libraries(test_rpath PRIVATE ${test_rpath_names})
+set_property(TARGET test_rpath PROPERTY INSTALL_RPATH
+ "${CMAKE_BINARY_DIR}/root-all/lib/rpath_postexcluded"
+ "${CMAKE_BINARY_DIR}/root-all/lib/rpath"
+ "\$ORIGIN/rpath_origin_postexcluded"
+ "\${ORIGIN}/rpath_origin"
+ "${CMAKE_BINARY_DIR}/root-all/lib/conflict"
+ )
+target_link_options(test_rpath PRIVATE -Wl,--disable-new-dtags)
+
+file(REMOVE "${CMAKE_BINARY_DIR}/test_runpath.c")
+add_library(test_runpath SHARED "${CMAKE_BINARY_DIR}/test_runpath.c")
+foreach(name ${test_runpath_names} rpath conflict)
+ file(WRITE "${CMAKE_BINARY_DIR}/${name}.c" "void ${name}(void) {}\n")
+ if(NOT name MATCHES "^(rpath|conflict)$")
+ add_library(${name} SHARED "${CMAKE_BINARY_DIR}/${name}.c")
+ endif()
+
+ file(APPEND "${CMAKE_BINARY_DIR}/test_runpath.c" "extern void ${name}(void);\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test_runpath.c" "void test_runpath(void)\n{\n")
+foreach(name ${test_runpath_names} rpath conflict)
+ file(APPEND "${CMAKE_BINARY_DIR}/test_runpath.c" " ${name}();\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test_runpath.c" "}\n")
+
+install(TARGETS runpath_postexcluded DESTINATION lib/runpath_postexcluded)
+install(TARGETS runpath DESTINATION lib/runpath)
+install(TARGETS runpath_origin_postexcluded DESTINATION lib/runpath_origin_postexcluded)
+install(TARGETS runpath_origin DESTINATION lib/runpath_origin)
+install(TARGETS runpath_parent_unresolved DESTINATION lib/runpath_parent_unresolved)
+install(TARGETS runpath_search_postexcluded DESTINATION lib/runpath_search_postexcluded)
+install(TARGETS runpath runpath_origin runpath_search DESTINATION lib/runpath_search)
+install(TARGETS conflict DESTINATION lib/conflict2)
+
+target_link_libraries(test_runpath PRIVATE ${test_runpath_names} rpath conflict)
+set_property(TARGET test_runpath PROPERTY INSTALL_RPATH
+ "${CMAKE_BINARY_DIR}/root-all/lib/runpath/../rpath" # Ensure that files that don't conflict are treated correctly
+ "${CMAKE_BINARY_DIR}/root-all/lib/runpath_postexcluded"
+ "${CMAKE_BINARY_DIR}/root-all/lib/runpath"
+ "\${ORIGIN}/runpath_origin_postexcluded"
+ "\$ORIGIN/runpath_origin"
+ "${CMAKE_BINARY_DIR}/root-all/lib/conflict2"
+ )
+target_link_options(test_runpath PRIVATE -Wl,--enable-new-dtags)
+
+set_property(TARGET test_rpath ${test_rpath_names} test_runpath ${test_runpath_names} PROPERTY LIBRARY_OUTPUT_DIRECTORY lib)
+install(TARGETS test_rpath test_runpath DESTINATION lib)
+
+add_executable(topexe file-GET_RUNTIME_DEPENDENCIES-linux/topexe.c)
+add_library(toplib SHARED file-GET_RUNTIME_DEPENDENCIES-linux/toplib.c)
+add_library(topmod MODULE file-GET_RUNTIME_DEPENDENCIES-linux/toplib.c)
+target_link_libraries(topexe PRIVATE test_rpath test_runpath)
+target_link_libraries(toplib PRIVATE test_rpath test_runpath)
+target_link_libraries(topmod PRIVATE test_rpath test_runpath)
+set_property(TARGET topexe toplib topmod PROPERTY INSTALL_RPATH
+ "${CMAKE_BINARY_DIR}/root-all/lib"
+ "${CMAKE_BINARY_DIR}/root-all/lib/rpath_parent_postexcluded"
+ "${CMAKE_BINARY_DIR}/root-all/lib/rpath_parent"
+ "${CMAKE_BINARY_DIR}/root-all/lib/runpath_parent_unresolved"
+ )
+target_link_options(topexe PRIVATE -Wl,--disable-new-dtags)
+target_link_options(toplib PRIVATE -Wl,--disable-new-dtags)
+target_link_options(topmod PRIVATE -Wl,--disable-new-dtags)
+
+install(TARGETS topexe toplib RUNTIME DESTINATION bin LIBRARY DESTINATION lib)
+install(TARGETS topmod LIBRARY DESTINATION lib/modules)
+
+install(CODE [[
+ function(exec_get_runtime_dependencies depsfile udepsfile cdepsfile)
+ file(GET_RUNTIME_DEPENDENCIES
+ RESOLVED_DEPENDENCIES_VAR deps
+ UNRESOLVED_DEPENDENCIES_VAR udeps
+ CONFLICTING_DEPENDENCIES_PREFIX cdeps
+ PRE_INCLUDE_REGEXES
+ "^lib(test_rpath|rpath_postexcluded|rpath|rpath_parent_postexcluded|rpath_parent|rpath_origin_postexcluded|rpath_origin|rpath_search_postexcluded|rpath_search|rpath_unresolved|test_runpath|runpath_postexcluded|runpath|runpath_origin_postexcluded|runpath_origin|runpath_parent_unresolved|runpath_search_postexcluded|runpath_search|runpath_unresolved|conflict)\\.so$"
+ "^libc\\.so"
+ PRE_EXCLUDE_REGEXES ".*"
+ POST_INCLUDE_REGEXES "^.*/(libtest_rpath|rpath/librpath|rpath_parent/librpath_parent|rpath_search/librpath_search|libtest_runpath|runpath/librunpath|runpath_origin_postexcluded|runpath_origin|runpath_search/librunpath_search|conflict2?/libconflict)\\.so$"
+ POST_EXCLUDE_REGEXES ".*"
+ DIRECTORIES
+ "${CMAKE_INSTALL_PREFIX}/lib/rpath_search_postexcluded"
+ "${CMAKE_INSTALL_PREFIX}/lib/rpath_search"
+ "${CMAKE_INSTALL_PREFIX}/lib/runpath_search_postexcluded"
+ "${CMAKE_INSTALL_PREFIX}/lib/runpath_search"
+ ${ARGN}
+ )
+ list(SORT deps)
+ list(SORT udeps)
+ list(SORT cdeps_FILENAMES)
+ file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${depsfile}" "${deps}")
+ file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${udepsfile}" "${udeps}")
+ file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "")
+ foreach(cdep IN LISTS cdeps_FILENAMES)
+ set(cdep_values ${cdeps_${cdep}})
+ list(SORT cdep_values)
+ file(APPEND "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "${cdep}:${cdep_values}\n")
+ endforeach()
+ endfunction()
+
+ exec_get_runtime_dependencies(
+ deps1.txt udeps1.txt cdeps1.txt
+ EXECUTABLES
+ "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:topexe>"
+ )
+
+ exec_get_runtime_dependencies(
+ deps2.txt udeps2.txt cdeps2.txt
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:toplib>"
+ )
+
+ exec_get_runtime_dependencies(
+ deps3.txt udeps3.txt cdeps3.txt
+ MODULES
+ "${CMAKE_INSTALL_PREFIX}/lib/modules/$<TARGET_FILE_NAME:topmod>"
+ )
+ ]])
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux/topexe.c b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux/topexe.c
new file mode 100644
index 000000000..d196afe0d
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux/topexe.c
@@ -0,0 +1,9 @@
+extern void test_rpath(void);
+extern void test_runpath(void);
+
+int main(void)
+{
+ test_rpath();
+ test_runpath();
+ return 0;
+}
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux/toplib.c b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux/toplib.c
new file mode 100644
index 000000000..040e59191
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-linux/toplib.c
@@ -0,0 +1,8 @@
+extern void test_rpath(void);
+extern void test_runpath(void);
+
+void toplib(void)
+{
+ test_rpath();
+ test_runpath();
+}
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-all-check.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-all-check.cmake
new file mode 100644
index 000000000..4d6dde12d
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-all-check.cmake
@@ -0,0 +1,157 @@
+function(check_contents filename contents_regex)
+ if(EXISTS "${CMAKE_INSTALL_PREFIX}/${filename}")
+ file(READ "${CMAKE_INSTALL_PREFIX}/${filename}" contents)
+ if(NOT contents MATCHES "${contents_regex}")
+ string(APPEND RunCMake_TEST_FAILED "File contents:
+ ${contents}
+do not match what we expected:
+ ${contents_regex}
+in file:
+ ${CMAKE_INSTALL_PREFIX}/${filename}\n")
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+ endif()
+ else()
+ string(APPEND RunCMake_TEST_FAILED "File ${CMAKE_INSTALL_PREFIX}/${filename} does not exist")
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+set(_check
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/bin/../lib/executable_path/libexecutable_path\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/bin/../lib/rpath_executable_path/librpath_executable_path\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/libtestlib\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/loader_path/libloader_path\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/../rpath/librpath\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/libnormal\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/rpath_loader_path/librpath_loader_path\.dylib]]
+ [[/usr/lib/libSystem\.B\.dylib]]
+ )
+check_contents(deps/deps1.txt "^${_check}$")
+
+set(_check
+ [[@executable_path/../lib/executable_path_bundle/libexecutable_path_bundle\.dylib]]
+ [[@loader_path/loader_path_unresolved/libloader_path_unresolved\.dylib]]
+ [[@rpath/librpath_executable_path_bundle\.dylib]]
+ [[@rpath/librpath_loader_path_unresolved\.dylib]]
+ [[@rpath/librpath_unresolved\.dylib]]
+ )
+check_contents(deps/udeps1.txt "^${_check}$")
+
+set(_check
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/libtestlib\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/loader_path/libloader_path\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/../rpath/librpath\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/libnormal\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/rpath_loader_path/librpath_loader_path\.dylib]]
+ [[/usr/lib/libSystem\.B\.dylib]]
+ )
+check_contents(deps/deps2.txt "^${_check}$")
+
+set(_check
+ [[@executable_path/../lib/executable_path/libexecutable_path\.dylib]]
+ [[@executable_path/../lib/executable_path_bundle/libexecutable_path_bundle\.dylib]]
+ [[@executable_path/../lib/executable_path_postexcluded/libexecutable_path_postexcluded\.dylib]]
+ [[@loader_path/loader_path_unresolved/libloader_path_unresolved\.dylib]]
+ [[@rpath/librpath_executable_path\.dylib]]
+ [[@rpath/librpath_executable_path_bundle\.dylib]]
+ [[@rpath/librpath_executable_path_postexcluded\.dylib]]
+ [[@rpath/librpath_loader_path_unresolved\.dylib]]
+ [[@rpath/librpath_unresolved\.dylib]]
+ )
+check_contents(deps/udeps2.txt "^${_check}$")
+
+set(_check
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/libtestlib\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/loader_path/libloader_path\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/../rpath/librpath\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/libnormal\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/rpath_loader_path/librpath_loader_path\.dylib]]
+ [[/usr/lib/libSystem\.B\.dylib]]
+ )
+check_contents(deps/deps3.txt "^${_check}$")
+
+set(_check
+ [[@executable_path/../lib/executable_path/libexecutable_path\.dylib]]
+ [[@executable_path/../lib/executable_path_bundle/libexecutable_path_bundle\.dylib]]
+ [[@executable_path/../lib/executable_path_postexcluded/libexecutable_path_postexcluded\.dylib]]
+ [[@loader_path/loader_path_unresolved/libloader_path_unresolved\.dylib]]
+ [[@rpath/librpath_executable_path\.dylib]]
+ [[@rpath/librpath_executable_path_bundle\.dylib]]
+ [[@rpath/librpath_executable_path_postexcluded\.dylib]]
+ [[@rpath/librpath_loader_path_unresolved\.dylib]]
+ [[@rpath/librpath_unresolved\.dylib]]
+ )
+check_contents(deps/udeps3.txt "^${_check}$")
+
+set(_check
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/bin/../lib/executable_path/libexecutable_path\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/bin/../lib/rpath_executable_path/librpath_executable_path\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/libtestlib\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/loader_path/libloader_path\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/../rpath/librpath\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/libnormal\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/rpath_loader_path/librpath_loader_path\.dylib]]
+ [[/usr/lib/libSystem\.B\.dylib]]
+ )
+check_contents(deps/deps4.txt "^${_check}$")
+
+set(_check
+ [[@executable_path/../lib/executable_path_bundle/libexecutable_path_bundle\.dylib]]
+ [[@loader_path/loader_path_unresolved/libloader_path_unresolved\.dylib]]
+ [[@rpath/librpath_executable_path_bundle\.dylib]]
+ [[@rpath/librpath_loader_path_unresolved\.dylib]]
+ [[@rpath/librpath_unresolved\.dylib]]
+ )
+check_contents(deps/udeps4.txt "^${_check}$")
+
+set(_check
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/bundle_executable/bin/../lib/executable_path_bundle/libexecutable_path_bundle\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/libtestlib\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/loader_path/libloader_path\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/../rpath/librpath\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/libnormal\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/rpath_loader_path/librpath_loader_path\.dylib]]
+ [[/usr/lib/libSystem\.B\.dylib]]
+ )
+check_contents(deps/deps5.txt "^${_check}$")
+
+set(_check
+ [[@executable_path/../lib/executable_path/libexecutable_path\.dylib]]
+ [[@loader_path/loader_path_unresolved/libloader_path_unresolved\.dylib]]
+ [[@rpath/librpath_executable_path\.dylib]]
+ [[@rpath/librpath_executable_path_bundle\.dylib]]
+ [[@rpath/librpath_loader_path_unresolved\.dylib]]
+ [[@rpath/librpath_unresolved\.dylib]]
+ )
+check_contents(deps/udeps5.txt "^${_check}$")
+
+set(_check
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/bundle_executable/bin/../lib/executable_path_bundle/libexecutable_path_bundle\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/libtestlib\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/loader_path/libloader_path\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/../rpath/librpath\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/libnormal\.dylib]]
+ [[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/rpath_loader_path/librpath_loader_path\.dylib]]
+ [[/usr/lib/libSystem\.B\.dylib]]
+ )
+check_contents(deps/deps6.txt "^${_check}$")
+
+set(_check
+ [[@executable_path/../lib/executable_path/libexecutable_path\.dylib]]
+ [[@loader_path/loader_path_unresolved/libloader_path_unresolved\.dylib]]
+ [[@rpath/librpath_executable_path\.dylib]]
+ [[@rpath/librpath_executable_path_bundle\.dylib]]
+ [[@rpath/librpath_loader_path_unresolved\.dylib]]
+ [[@rpath/librpath_unresolved\.dylib]]
+ )
+check_contents(deps/udeps6.txt "^${_check}$")
+
+set(_check
+ "^libconflict\\.dylib:[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/conflict/libconflict\\.dylib;[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/conflict2/libconflict\\.dylib\n$"
+ )
+check_contents(deps/cdeps1.txt "${_check}")
+check_contents(deps/cdeps2.txt "${_check}")
+check_contents(deps/cdeps3.txt "${_check}")
+check_contents(deps/cdeps4.txt "${_check}")
+check_contents(deps/cdeps5.txt "${_check}")
+check_contents(deps/cdeps6.txt "${_check}")
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-stderr.txt
new file mode 100644
index 000000000..bc9e97a82
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at cmake_install\.cmake:[0-9]+ \(file\):
+ file Multiple conflicting paths found for librpath\.dylib:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-build/root-all/lib/rpath1/librpath\.dylib
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-build/root-all/lib/rpath2/librpath\.dylib$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict.cmake
new file mode 100644
index 000000000..a8446fe2d
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-conflict.cmake
@@ -0,0 +1,55 @@
+enable_language(C)
+
+set(test1_names rpath)
+set(test2_names rpath)
+
+file(WRITE "${CMAKE_BINARY_DIR}/rpath.c" "void rpath(void) {}\n")
+add_library(rpath SHARED "${CMAKE_BINARY_DIR}/rpath.c")
+set_property(TARGET rpath PROPERTY INSTALL_NAME_DIR @rpath)
+install(TARGETS rpath DESTINATION lib/rpath1)
+install(TARGETS rpath DESTINATION lib/rpath2)
+
+file(REMOVE "${CMAKE_BINARY_DIR}/test1.c")
+add_library(test1 SHARED "${CMAKE_BINARY_DIR}/test1.c")
+foreach(name ${test1_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "extern void ${name}(void);\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "void test1(void)\n{\n")
+foreach(name ${test1_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/test1.c" " ${name}();\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "}\n")
+
+target_link_libraries(test1 PRIVATE ${test1_names})
+set_property(TARGET test1 PROPERTY INSTALL_RPATH
+ "${CMAKE_BINARY_DIR}/root-all/lib/rpath1"
+ )
+
+file(REMOVE "${CMAKE_BINARY_DIR}/test2.c")
+add_library(test2 SHARED "${CMAKE_BINARY_DIR}/test2.c")
+foreach(name ${test2_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "extern void ${name}(void);\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "void test2(void)\n{\n")
+foreach(name ${test2_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/test2.c" " ${name}();\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "}\n")
+
+target_link_libraries(test2 PRIVATE ${test2_names})
+set_property(TARGET test2 PROPERTY INSTALL_RPATH
+ "${CMAKE_BINARY_DIR}/root-all/lib/rpath2"
+ )
+
+install(TARGETS test1 test2 DESTINATION lib)
+
+install(CODE [[
+ file(GET_RUNTIME_DEPENDENCIES
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:test1>"
+ "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:test2>"
+ PRE_INCLUDE_REGEXES "^@rpath/librpath\\.dylib$"
+ PRE_EXCLUDE_REGEXES ".*"
+ )
+ message(FATAL_ERROR "This message should not be displayed")
+ ]])
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-stderr.txt
new file mode 100644
index 000000000..73ab9f1c5
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at cmake_install\.cmake:[0-9]+ \(file\):
+ file Failed to run otool on:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-build/root-all/bin/\.\./lib/libtest\.dylib$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-notfile.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-notfile.cmake
new file mode 100644
index 000000000..3e4c43423
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-notfile.cmake
@@ -0,0 +1,30 @@
+enable_language(C)
+
+file(WRITE "${CMAKE_BINARY_DIR}/test.c" "void test(void) {}\n")
+file(WRITE "${CMAKE_BINARY_DIR}/main.c" [[extern void test(void);
+
+int main(void)
+{
+ test();
+ return 0;
+}
+]])
+
+add_library(test SHARED "${CMAKE_BINARY_DIR}/test.c")
+set_property(TARGET test PROPERTY INSTALL_NAME_DIR @rpath)
+add_executable(exe "${CMAKE_BINARY_DIR}/main.c")
+target_link_libraries(exe PRIVATE test)
+set_property(TARGET exe PROPERTY INSTALL_RPATH "@loader_path/../lib")
+
+install(TARGETS exe DESTINATION bin)
+
+install(CODE [[
+ file(MAKE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:test>")
+ file(GET_RUNTIME_DEPENDENCIES
+ EXECUTABLES
+ "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:exe>"
+ PRE_INCLUDE_REGEXES "^@rpath/libtest\\.dylib$"
+ PRE_EXCLUDE_REGEXES ".*"
+ )
+ message(FATAL_ERROR "This message should not be displayed")
+ ]])
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-stderr.txt
new file mode 100644
index 000000000..01762b45f
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at cmake_install\.cmake:[0-9]+ \(file\):
+ file Could not resolve file @rpath/libunresolved\.dylib$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved.cmake
new file mode 100644
index 000000000..c9b6c9559
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved.cmake
@@ -0,0 +1,18 @@
+enable_language(C)
+
+file(WRITE "${CMAKE_BINARY_DIR}/testlib.c" "extern void unresolved(void);\nvoid testlib(void)\n{\n unresolved();\n}\n")
+add_library(testlib SHARED "${CMAKE_BINARY_DIR}/testlib.c")
+file(WRITE "${CMAKE_BINARY_DIR}/unresolved.c" "void unresolved(void) {}\n")
+add_library(unresolved SHARED "${CMAKE_BINARY_DIR}/unresolved.c")
+target_link_libraries(testlib PRIVATE unresolved)
+install(TARGETS testlib DESTINATION lib)
+
+install(CODE [[
+ file(GET_RUNTIME_DEPENDENCIES
+ PRE_INCLUDE_REGEXES "^@rpath/libunresolved\\.dylib$"
+ PRE_EXCLUDE_REGEXES ".*"
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:testlib>"
+ )
+ message(FATAL_ERROR "This message should not be displayed")
+ ]])
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos.cmake
new file mode 100644
index 000000000..6db05b3ff
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos.cmake
@@ -0,0 +1,216 @@
+enable_language(C)
+
+set(testlib_names
+ preexcluded
+ executable_path
+ executable_path_bundle
+ executable_path_postexcluded
+ loader_path
+ loader_path_unresolved
+ loader_path_postexcluded
+ rpath
+ rpath_unresolved
+ rpath_postexcluded
+ rpath_executable_path
+ rpath_executable_path_bundle
+ rpath_executable_path_postexcluded
+ rpath_loader_path
+ rpath_loader_path_unresolved
+ rpath_loader_path_postexcluded
+ normal
+ normal_unresolved
+ normal_postexcluded
+ conflict
+ )
+
+file(REMOVE "${CMAKE_BINARY_DIR}/testlib.c")
+add_library(testlib SHARED "${CMAKE_BINARY_DIR}/testlib.c")
+foreach(name ${testlib_names})
+ if(name STREQUAL "normal")
+ file(WRITE "${CMAKE_BINARY_DIR}/normal.c" "extern void rpath(void);\nvoid normal(void)\n{\n rpath();\n}\n")
+ else()
+ file(WRITE "${CMAKE_BINARY_DIR}/${name}.c" "void ${name}(void) {}\n")
+ endif()
+ add_library(${name} SHARED "${CMAKE_BINARY_DIR}/${name}.c")
+
+ file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "extern void ${name}(void);\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "void testlib(void)\n{\n")
+foreach(name ${testlib_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" " ${name}();\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "}\n")
+set_property(TARGET ${testlib_names} PROPERTY BUILD_WITH_INSTALL_NAME_DIR 1)
+target_link_libraries(normal PRIVATE rpath)
+set_property(TARGET normal PROPERTY INSTALL_RPATH
+ "${CMAKE_BINARY_DIR}/root-all/executable/lib/normal/../rpath"
+ )
+
+file(WRITE "${CMAKE_BINARY_DIR}/testlib_conflict.c" "extern void conflict(void);\nvoid testlib_conflict(void)\n{\n conflict();\n}\n")
+add_library(testlib_conflict SHARED "${CMAKE_BINARY_DIR}/testlib_conflict.c")
+target_link_libraries(testlib_conflict PRIVATE conflict)
+
+set_property(TARGET testlib PROPERTY INSTALL_RPATH
+ "${CMAKE_BINARY_DIR}/root-all/executable/lib/rpath"
+ "${CMAKE_BINARY_DIR}/root-all/executable/lib/rpath_unresolved"
+ "${CMAKE_BINARY_DIR}/root-all/executable/lib/rpath_postexcluded"
+ "${CMAKE_BINARY_DIR}/root-all/executable/lib/conflict"
+ @executable_path/../lib/rpath_executable_path
+ @executable_path/../lib/rpath_executable_path_unresolved
+ @executable_path/../lib/rpath_executable_path_postexcluded
+ @loader_path/rpath_loader_path
+ @loader_path/rpath_loader_path_unresolved
+ @loader_path/rpath_loader_path_postexcluded
+ )
+set_property(TARGET testlib_conflict PROPERTY INSTALL_RPATH
+ "${CMAKE_BINARY_DIR}/root-all/executable/lib/conflict2"
+ )
+
+foreach(t
+ executable_path
+ executable_path_postexcluded
+ loader_path
+ loader_path_postexcluded
+ rpath
+ rpath_postexcluded
+ rpath_executable_path
+ rpath_executable_path_postexcluded
+ rpath_loader_path
+ rpath_loader_path_postexcluded
+ conflict
+ )
+ install(TARGETS ${t} DESTINATION executable/lib/${t})
+endforeach()
+install(TARGETS conflict DESTINATION executable/lib/conflict2)
+
+foreach(t
+ executable_path_bundle
+ executable_path_postexcluded
+ loader_path_postexcluded
+ rpath_postexcluded
+ rpath_executable_path_bundle
+ rpath_executable_path_postexcluded
+ rpath_loader_path_postexcluded
+ )
+ install(TARGETS ${t} DESTINATION bundle_executable/lib/${t})
+endforeach()
+
+foreach(t executable_path executable_path_bundle executable_path_postexcluded)
+ set_property(TARGET ${t} PROPERTY INSTALL_NAME_DIR @executable_path/../lib/${t})
+endforeach()
+
+foreach(t loader_path loader_path_unresolved loader_path_postexcluded)
+ set_property(TARGET ${t} PROPERTY INSTALL_NAME_DIR @loader_path/${t})
+endforeach()
+
+foreach(t
+ rpath
+ rpath_unresolved
+ rpath_postexcluded
+ rpath_executable_path
+ rpath_executable_path_bundle
+ rpath_executable_path_postexcluded
+ rpath_loader_path
+ rpath_loader_path_unresolved
+ rpath_loader_path_postexcluded
+ conflict
+ )
+ set_property(TARGET ${t} PROPERTY INSTALL_NAME_DIR @rpath)
+endforeach()
+
+foreach(t normal normal_unresolved normal_postexcluded)
+ set_property(TARGET ${t} PROPERTY INSTALL_NAME_DIR "${CMAKE_BINARY_DIR}/root-all/executable/lib/${t}")
+ if(NOT t STREQUAL "normal_unresolved")
+ install(TARGETS ${t} DESTINATION executable/lib/${t})
+ endif()
+endforeach()
+
+target_link_libraries(testlib PRIVATE ${testlib_names})
+
+add_executable(topexe file-GET_RUNTIME_DEPENDENCIES-macos/topexe.c)
+add_library(toplib SHARED file-GET_RUNTIME_DEPENDENCIES-macos/toplib.c)
+add_library(topmod MODULE file-GET_RUNTIME_DEPENDENCIES-macos/toplib.c)
+target_link_libraries(topexe PRIVATE testlib)
+target_link_libraries(toplib PRIVATE testlib)
+target_link_libraries(topmod PRIVATE testlib)
+
+set_property(TARGET topexe toplib topmod PROPERTY INSTALL_RPATH "${CMAKE_BINARY_DIR}/root-all/executable/lib")
+
+install(TARGETS topexe toplib topmod testlib testlib_conflict RUNTIME DESTINATION executable/bin LIBRARY DESTINATION executable/lib)
+install(TARGETS topexe toplib topmod testlib testlib_conflict RUNTIME DESTINATION bundle_executable/bin LIBRARY DESTINATION bundle_executable/lib)
+
+install(CODE [[
+ function(exec_get_runtime_dependencies depsfile udepsfile cdepsfile)
+ file(GET_RUNTIME_DEPENDENCIES
+ RESOLVED_DEPENDENCIES_VAR deps
+ UNRESOLVED_DEPENDENCIES_VAR udeps
+ CONFLICTING_DEPENDENCIES_PREFIX cdeps
+ PRE_INCLUDE_REGEXES "^.*/lib(testlib|executable_path|executable_path_bundle|executable_path_postexcluded|loader_path|loader_path_unresolved|loader_path_postexcluded|rpath|rpath_unresolved|rpath_postexcluded|rpath_executable_path|rpath_executable_path_bundle|rpath_executable_path_postexcluded|rpath_loader_path|rpath_loader_path_unresolved|rpath_loader_path_postexcluded|normal|normal_unresolved|normal_postexcluded|conflict|System\\.B)\\.dylib$"
+ PRE_EXCLUDE_REGEXES ".*"
+ POST_INCLUDE_REGEXES "^.*/lib(testlib|executable_path|executable_path_bundle|loader_path|rpath|rpath_executable_path|rpath_executable_path_bundle|rpath_loader_path|normal|conflict|System\\.B)\\.dylib$"
+ POST_EXCLUDE_REGEXES ".*"
+ ${ARGN}
+ )
+ list(SORT deps)
+ list(SORT udeps)
+ list(SORT cdeps_FILENAMES)
+ file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${depsfile}" "${deps}")
+ file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${udepsfile}" "${udeps}")
+ file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "")
+ foreach(cdep IN LISTS cdeps_FILENAMES)
+ set(cdep_values ${cdeps_${cdep}})
+ list(SORT cdep_values)
+ file(APPEND "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "${cdep}:${cdep_values}\n")
+ endforeach()
+ endfunction()
+
+ exec_get_runtime_dependencies(
+ deps1.txt udeps1.txt cdeps1.txt
+ EXECUTABLES
+ "${CMAKE_INSTALL_PREFIX}/executable/bin/$<TARGET_FILE_NAME:topexe>"
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>"
+ )
+
+ exec_get_runtime_dependencies(
+ deps2.txt udeps2.txt cdeps2.txt
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:toplib>"
+ "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>"
+ )
+
+ exec_get_runtime_dependencies(
+ deps3.txt udeps3.txt cdeps3.txt
+ MODULES
+ "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:topmod>"
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>"
+ )
+
+ exec_get_runtime_dependencies(
+ deps4.txt udeps4.txt cdeps4.txt
+ EXECUTABLES
+ "${CMAKE_INSTALL_PREFIX}/executable/bin/$<TARGET_FILE_NAME:topexe>"
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>"
+ BUNDLE_EXECUTABLE
+ "${CMAKE_INSTALL_PREFIX}/bundle_executable/bin/$<TARGET_FILE_NAME:topexe>"
+ )
+
+ exec_get_runtime_dependencies(
+ deps5.txt udeps5.txt cdeps5.txt
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:toplib>"
+ "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>"
+ BUNDLE_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/bundle_executable/bin/$<TARGET_FILE_NAME:topexe>"
+ )
+
+ exec_get_runtime_dependencies(
+ deps6.txt udeps6.txt cdeps6.txt
+ MODULES
+ "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:topmod>"
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>"
+ BUNDLE_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/bundle_executable/bin/$<TARGET_FILE_NAME:topexe>"
+ )
+ ]])
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos/topexe.c b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos/topexe.c
new file mode 100644
index 000000000..20c608731
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos/topexe.c
@@ -0,0 +1,7 @@
+extern void testlib(void);
+
+int main(void)
+{
+ testlib();
+ return 0;
+}
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos/toplib.c b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos/toplib.c
new file mode 100644
index 000000000..cff1bff3f
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-macos/toplib.c
@@ -0,0 +1,6 @@
+extern void testlib(void);
+
+void toplib(void)
+{
+ testlib();
+}
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-project-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-project-stderr.txt
new file mode 100644
index 000000000..d506645a0
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-project-stderr.txt
@@ -0,0 +1,13 @@
+^CMake Warning \(dev\) at file-GET_RUNTIME_DEPENDENCIES-project\.cmake:[0-9]+ \(file\):
+ You have used file\(GET_RUNTIME_DEPENDENCIES\) in project mode\. This is
+ probably not what you intended to do\. Instead, please consider using it in
+ an install\(CODE\) or install\(SCRIPT\) command\. For example:
+
+ install\(CODE \[\[
+ file\(GET_RUNTIME_DEPENDENCIES
+ # \.\.\.
+ \)
+ ]]\)
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+This warning is for project developers\. Use -Wno-dev to suppress it\.$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-project.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-project.cmake
new file mode 100644
index 000000000..842d7abd7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-project.cmake
@@ -0,0 +1 @@
+file(GET_RUNTIME_DEPENDENCIES RESOLVED_DEPENDENCIES_VAR deps)
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-unsupported-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-unsupported-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-unsupported-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-unsupported-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-unsupported-stderr.txt
new file mode 100644
index 000000000..3db835c08
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-unsupported-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at file-GET_RUNTIME_DEPENDENCIES-unsupported\.cmake:[0-9]+ \(file\):
+ file GET_RUNTIME_DEPENDENCIES is not supported on system "[^
+ ]+"
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-unsupported.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-unsupported.cmake
new file mode 100644
index 000000000..b91eefef3
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-unsupported.cmake
@@ -0,0 +1,2 @@
+file(GET_RUNTIME_DEPENDENCIES RESOLVED_DEPENDENCIES_VAR deps)
+message(FATAL_ERROR "This message should not be displayed")
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-all-check.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-all-check.cmake
new file mode 100644
index 000000000..c120ce461
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-all-check.cmake
@@ -0,0 +1,38 @@
+function(check_contents filename contents_regex)
+ if(EXISTS "${CMAKE_INSTALL_PREFIX}/${filename}")
+ file(READ "${CMAKE_INSTALL_PREFIX}/${filename}" contents)
+ if(NOT contents MATCHES "${contents_regex}")
+ string(APPEND RunCMake_TEST_FAILED "File contents:
+ ${contents}
+do not match what we expected:
+ ${contents_regex}
+in file:
+ ${CMAKE_INSTALL_PREFIX}/${filename}\n")
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+ endif()
+ else()
+ string(APPEND RunCMake_TEST_FAILED "File ${CMAKE_INSTALL_PREFIX}/${filename} does not exist")
+ set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+set(_check
+ [=[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-build/root-all/bin/\.conflict/\.\./(lib)?libdir\.dll]=]
+ [=[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-build/root-all/bin/\.search/(lib)?search\.dll]=]
+ [=[[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-build/root-all/bin/(lib)?testlib\.dll]=]
+ )
+check_contents(deps/deps1.txt "^${_check}$")
+check_contents(deps/deps2.txt "^${_check}$")
+check_contents(deps/deps3.txt "^${_check}$")
+set(_check
+ [=[(lib)?unresolved\.dll]=]
+ )
+check_contents(deps/udeps1.txt "^${_check}$")
+check_contents(deps/udeps2.txt "^${_check}$")
+check_contents(deps/udeps3.txt "^${_check}$")
+set(_check
+ "^(lib)?conflict\\.dll:[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-build/root-all/bin/\\.conflict/(lib)?conflict\\.dll;[^;]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-build/root-all/bin/(lib)?conflict\\.dll\n$"
+ )
+check_contents(deps/cdeps1.txt "${_check}")
+check_contents(deps/cdeps2.txt "${_check}")
+check_contents(deps/cdeps3.txt "${_check}")
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-stderr.txt
new file mode 100644
index 000000000..66ecb932c
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at cmake_install\.cmake:[0-9]+ \(file\):
+ file Multiple conflicting paths found for (lib)?path\.dll:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-build/root-all/lib/test1/(lib)?path\.dll
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-build/root-all/lib/test2/(lib)?path\.dll$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict.cmake
new file mode 100644
index 000000000..d41344375
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-conflict.cmake
@@ -0,0 +1,47 @@
+enable_language(C)
+
+set(test1_names path)
+set(test2_names path)
+
+file(WRITE "${CMAKE_BINARY_DIR}/path.c" "__declspec(dllexport) void path(void) {}\n")
+add_library(path SHARED "${CMAKE_BINARY_DIR}/path.c")
+
+file(REMOVE "${CMAKE_BINARY_DIR}/test1.c")
+add_library(test1 SHARED "${CMAKE_BINARY_DIR}/test1.c")
+foreach(name ${test1_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "__declspec(dllimport) extern void ${name}(void);\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "__declspec(dllexport) void test1(void)\n{\n")
+foreach(name ${test1_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/test1.c" " ${name}();\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "}\n")
+
+target_link_libraries(test1 PRIVATE ${test1_names})
+
+file(REMOVE "${CMAKE_BINARY_DIR}/test2.c")
+add_library(test2 SHARED "${CMAKE_BINARY_DIR}/test2.c")
+foreach(name ${test2_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "__declspec(dllimport) extern void ${name}(void);\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "__declspec(dllexport) void test2(void)\n{\n")
+foreach(name ${test2_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/test2.c" " ${name}();\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "}\n")
+
+target_link_libraries(test2 PRIVATE ${test2_names})
+
+install(TARGETS test1 path DESTINATION lib/test1)
+install(TARGETS test2 path DESTINATION lib/test2)
+
+install(CODE [[
+ file(GET_RUNTIME_DEPENDENCIES
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/lib/test1/$<TARGET_FILE_NAME:test1>"
+ "${CMAKE_INSTALL_PREFIX}/lib/test2/$<TARGET_FILE_NAME:test2>"
+ PRE_INCLUDE_REGEXES "^(lib)?path\\.dll$"
+ PRE_EXCLUDE_REGEXES ".*"
+ )
+ message(FATAL_ERROR "This message should not be displayed")
+ ]])
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-stderr.txt
new file mode 100644
index 000000000..f921409f9
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at cmake_install\.cmake:[0-9]+ \(file\):
+ file Failed to run (dumpbin|objdump) on:
+
+ [^
+]*/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-build/root-all/bin/(lib)?test\.dll$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-notfile.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-notfile.cmake
new file mode 100644
index 000000000..6665a3b3e
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-notfile.cmake
@@ -0,0 +1,28 @@
+enable_language(C)
+
+file(WRITE "${CMAKE_BINARY_DIR}/test.c" "__declspec(dllexport) void test(void) {}\n")
+file(WRITE "${CMAKE_BINARY_DIR}/main.c" [[__declspec(dllimport) extern void test(void);
+
+int main(void)
+{
+ test();
+ return 0;
+}
+]])
+
+add_library(test SHARED "${CMAKE_BINARY_DIR}/test.c")
+add_executable(exe "${CMAKE_BINARY_DIR}/main.c")
+target_link_libraries(exe PRIVATE test)
+
+install(TARGETS exe DESTINATION bin)
+
+install(CODE [[
+ file(MAKE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:test>")
+ file(GET_RUNTIME_DEPENDENCIES
+ EXECUTABLES
+ "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:exe>"
+ PRE_INCLUDE_REGEXES "^(lib)?test\\.dll$"
+ PRE_EXCLUDE_REGEXES ".*"
+ )
+ message(FATAL_ERROR "This message should not be displayed")
+ ]])
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-result.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-stderr.txt b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-stderr.txt
new file mode 100644
index 000000000..a20654c5a
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-stderr.txt
@@ -0,0 +1,2 @@
+^CMake Error at cmake_install\.cmake:[0-9]+ \(file\):
+ file Could not resolve file (lib)?unresolved\.dll$
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved.cmake
new file mode 100644
index 000000000..4cc74c70d
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved.cmake
@@ -0,0 +1,18 @@
+enable_language(C)
+
+file(WRITE "${CMAKE_BINARY_DIR}/testlib.c" "__declspec(dllimport) extern void unresolved(void);\n__declspec(dllexport) void testlib(void)\n{\n unresolved();\n}\n")
+add_library(testlib SHARED "${CMAKE_BINARY_DIR}/testlib.c")
+file(WRITE "${CMAKE_BINARY_DIR}/unresolved.c" "__declspec(dllexport) void unresolved(void) {}\n")
+add_library(unresolved SHARED "${CMAKE_BINARY_DIR}/unresolved.c")
+target_link_libraries(testlib PRIVATE unresolved)
+install(TARGETS testlib DESTINATION lib)
+
+install(CODE [[
+ file(GET_RUNTIME_DEPENDENCIES
+ PRE_INCLUDE_REGEXES "^(lib)?unresolved\\.dll$"
+ PRE_EXCLUDE_REGEXES ".*"
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:testlib>"
+ )
+ message(FATAL_ERROR "This message should not be displayed")
+ ]])
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows.cmake b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows.cmake
new file mode 100644
index 000000000..19288d853
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows.cmake
@@ -0,0 +1,114 @@
+enable_language(C)
+
+set(testlib_names
+ preexcluded
+ libdir_postexcluded
+ libdir
+ search_postexcluded
+ search
+ unresolved
+ conflict
+ )
+
+file(REMOVE "${CMAKE_BINARY_DIR}/testlib.c")
+add_library(testlib SHARED "${CMAKE_BINARY_DIR}/testlib.c")
+foreach(name ${testlib_names})
+ file(WRITE "${CMAKE_BINARY_DIR}/${name}.c" "__declspec(dllexport) void ${name}(void) {}\n")
+ add_library(${name} SHARED "${CMAKE_BINARY_DIR}/${name}.c")
+
+ file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "__declspec(dllimport) extern void ${name}(void);\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "__declspec(dllexport) void testlib(void)\n{\n")
+foreach(name ${testlib_names})
+ file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" " ${name}();\n")
+endforeach()
+file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "}\n")
+
+target_link_libraries(testlib PRIVATE ${testlib_names})
+
+file(WRITE "${CMAKE_BINARY_DIR}/testlib_conflict.c" "__declspec(dllimport) extern void conflict(void);\n__declspec(dllexport) void testlib_conflict(void)\n{\n conflict();\n}\n")
+add_library(testlib_conflict SHARED "${CMAKE_BINARY_DIR}/testlib_conflict.c")
+target_link_libraries(testlib_conflict PRIVATE conflict)
+
+file(WRITE "${CMAKE_BINARY_DIR}/testlib_noconflict.c" "__declspec(dllimport) extern void libdir(void);\n__declspec(dllexport) void testlib_noconflict(void)\n{\n libdir();\n}\n")
+add_library(testlib_noconflict SHARED "${CMAKE_BINARY_DIR}/testlib_noconflict.c")
+target_link_libraries(testlib_noconflict PRIVATE libdir)
+
+install(TARGETS testlib libdir_postexcluded libdir conflict testlib_noconflict DESTINATION bin)
+install(TARGETS libdir search_postexcluded search DESTINATION bin/.search) # Prefixing with "." ensures it is the first item after list(SORT)
+install(TARGETS testlib_conflict conflict DESTINATION bin/.conflict)
+
+add_executable(topexe file-GET_RUNTIME_DEPENDENCIES-windows/topexe.c)
+add_library(toplib SHARED file-GET_RUNTIME_DEPENDENCIES-windows/toplib.c)
+add_library(topmod MODULE file-GET_RUNTIME_DEPENDENCIES-windows/toplib.c)
+target_link_libraries(topexe PRIVATE testlib)
+target_link_libraries(toplib PRIVATE testlib)
+target_link_libraries(topmod PRIVATE testlib)
+
+install(TARGETS topexe toplib topmod DESTINATION bin)
+
+install(CODE [[
+ function(exec_get_runtime_dependencies depsfile udepsfile cdepsfile)
+ file(GET_RUNTIME_DEPENDENCIES
+ RESOLVED_DEPENDENCIES_VAR deps
+ UNRESOLVED_DEPENDENCIES_VAR udeps
+ CONFLICTING_DEPENDENCIES_PREFIX cdeps
+ PRE_INCLUDE_REGEXES
+ "^(lib)?testlib\\.dll$"
+ "^(lib)?libdir_postexcluded\\.dll$"
+ "^(lib)?libdir\\.dll$"
+ "^(lib)?search_postexcluded\\.dll$"
+ "^(lib)?search\\.dll$"
+ "^(lib)?unresolved\\.dll$"
+ "^(lib)?conflict\\.dll$"
+ "^kernel32\\.dll$"
+ PRE_EXCLUDE_REGEXES ".*"
+ POST_INCLUDE_REGEXES
+ "^.*/(lib)?testlib\\.dll$"
+ "^.*/(lib)?libdir\\.dll$"
+ "^.*/(lib)?search\\.dll$"
+ "^.*/(lib)?conflict\\.dll$"
+ POST_EXCLUDE_REGEXES ".*"
+ DIRECTORIES
+ "${CMAKE_INSTALL_PREFIX}/bin/.search"
+ ${ARGN}
+ )
+ list(SORT deps)
+ list(SORT udeps)
+ list(SORT cdeps_FILENAMES)
+ file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${depsfile}" "${deps}")
+ file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${udepsfile}" "${udeps}")
+ file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "")
+ foreach(cdep IN LISTS cdeps_FILENAMES)
+ set(cdep_values ${cdeps_${cdep}})
+ list(SORT cdep_values)
+ file(APPEND "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "${cdep}:${cdep_values}\n")
+ endforeach()
+ endfunction()
+
+ exec_get_runtime_dependencies(
+ deps1.txt udeps1.txt cdeps1.txt
+ EXECUTABLES
+ "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:topexe>"
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/bin/.conflict/$<TARGET_FILE_NAME:testlib_conflict>"
+ "${CMAKE_INSTALL_PREFIX}/bin/.conflict/../$<TARGET_FILE_NAME:testlib_noconflict>"
+ )
+
+ exec_get_runtime_dependencies(
+ deps2.txt udeps2.txt cdeps2.txt
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:toplib>"
+ "${CMAKE_INSTALL_PREFIX}/bin/.conflict/$<TARGET_FILE_NAME:testlib_conflict>"
+ "${CMAKE_INSTALL_PREFIX}/bin/.conflict/../$<TARGET_FILE_NAME:testlib_noconflict>"
+ )
+
+ exec_get_runtime_dependencies(
+ deps3.txt udeps3.txt cdeps3.txt
+ MODULES
+ "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:topmod>"
+ LIBRARIES
+ "${CMAKE_INSTALL_PREFIX}/bin/.conflict/$<TARGET_FILE_NAME:testlib_conflict>"
+ "${CMAKE_INSTALL_PREFIX}/bin/.conflict/../$<TARGET_FILE_NAME:testlib_noconflict>"
+ )
+ ]])
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows/topexe.c b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows/topexe.c
new file mode 100644
index 000000000..713b8eb41
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows/topexe.c
@@ -0,0 +1,7 @@
+__declspec(dllimport) extern void testlib(void);
+
+int main(void)
+{
+ testlib();
+ return 0;
+}
diff --git a/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows/toplib.c b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows/toplib.c
new file mode 100644
index 000000000..69971759e
--- /dev/null
+++ b/Tests/RunCMake/install/file-GET_RUNTIME_DEPENDENCIES-windows/toplib.c
@@ -0,0 +1,6 @@
+__declspec(dllimport) extern void testlib(void);
+
+__declspec(dllexport) void toplib(void)
+{
+ testlib();
+}
diff --git a/Tests/RunCMake/install/install_script.cmake b/Tests/RunCMake/install/install_script.cmake
new file mode 100644
index 000000000..1f8522c70
--- /dev/null
+++ b/Tests/RunCMake/install/install_script.cmake
@@ -0,0 +1,5 @@
+function(write_empty_file FILENAME)
+ file(WRITE "${CMAKE_INSTALL_PREFIX}/${FILENAME}" "")
+endfunction()
+
+write_empty_file(empty1.txt)
diff --git a/Tests/RunCMake/install/obj1.c b/Tests/RunCMake/install/obj1.c
index 2411aab79..70007df8a 100644
--- a/Tests/RunCMake/install/obj1.c
+++ b/Tests/RunCMake/install/obj1.c
@@ -1,4 +1,7 @@
-int obj1(void)
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int obj1(void)
{
return 0;
}
diff --git a/Tests/RunCMake/install/obj1.h b/Tests/RunCMake/install/obj1.h
new file mode 100644
index 000000000..d88d5d2b9
--- /dev/null
+++ b/Tests/RunCMake/install/obj1.h
@@ -0,0 +1,6 @@
+#ifndef OBJ1_H
+#define OBJ1_H
+
+int obj1(void);
+
+#endif /* OBJ1_H */
diff --git a/Tests/RunCMake/install/obj2.h b/Tests/RunCMake/install/obj2.h
new file mode 100644
index 000000000..90bcd3444
--- /dev/null
+++ b/Tests/RunCMake/install/obj2.h
@@ -0,0 +1,6 @@
+#ifndef OBJ2_H
+#define OBJ2_H
+
+int obj2(void);
+
+#endif /* OBJ2_H */
diff --git a/Tests/RunCMake/install/obj3.c b/Tests/RunCMake/install/obj3.c
new file mode 100644
index 000000000..991fed369
--- /dev/null
+++ b/Tests/RunCMake/install/obj3.c
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int obj3(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/install/obj3.h b/Tests/RunCMake/install/obj3.h
new file mode 100644
index 000000000..9e8bb760a
--- /dev/null
+++ b/Tests/RunCMake/install/obj3.h
@@ -0,0 +1,6 @@
+#ifndef OBJ3_H
+#define OBJ3_H
+
+int obj3(void);
+
+#endif /* OBJ3_H */
diff --git a/Tests/RunCMake/install/obj4.c b/Tests/RunCMake/install/obj4.c
new file mode 100644
index 000000000..edd61725d
--- /dev/null
+++ b/Tests/RunCMake/install/obj4.c
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int obj4(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/install/obj4.h b/Tests/RunCMake/install/obj4.h
new file mode 100644
index 000000000..6195aa77e
--- /dev/null
+++ b/Tests/RunCMake/install/obj4.h
@@ -0,0 +1,6 @@
+#ifndef OBJ4_H
+#define OBJ4_H
+
+int obj4(void);
+
+#endif /* OBJ4_H */
diff --git a/Tests/RunCMake/install/obj5.c b/Tests/RunCMake/install/obj5.c
new file mode 100644
index 000000000..df3e9973e
--- /dev/null
+++ b/Tests/RunCMake/install/obj5.c
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+ int obj5(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/install/obj5.h b/Tests/RunCMake/install/obj5.h
new file mode 100644
index 000000000..a16a1b0c4
--- /dev/null
+++ b/Tests/RunCMake/install/obj5.h
@@ -0,0 +1,6 @@
+#ifndef OBJ5_H
+#define OBJ5_H
+
+int obj5(void);
+
+#endif /* OBJ5_H */
diff --git a/Tests/RunCMake/install/pattern/empty.c b/Tests/RunCMake/install/pattern/empty.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/install/pattern/empty.c
diff --git a/Tests/RunCMake/install/pattern/empty.h b/Tests/RunCMake/install/pattern/empty.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/install/pattern/empty.h
diff --git a/Tests/RunCMake/install/pattern/empty.txt b/Tests/RunCMake/install/pattern/empty.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/install/pattern/empty.txt
diff --git a/Tests/RunCMake/install/postinstall.cmake b/Tests/RunCMake/install/postinstall.cmake
new file mode 100644
index 000000000..7607f40e1
--- /dev/null
+++ b/Tests/RunCMake/install/postinstall.cmake
@@ -0,0 +1 @@
+file(WRITE "${CMAKE_INSTALL_PREFIX}/postinstall" "postinstall")
diff --git a/Tests/RunCMake/install/preinstall.cmake b/Tests/RunCMake/install/preinstall.cmake
new file mode 100644
index 000000000..4b28d1626
--- /dev/null
+++ b/Tests/RunCMake/install/preinstall.cmake
@@ -0,0 +1 @@
+file(WRITE "${CMAKE_INSTALL_PREFIX}/preinstall" "preinstall")
diff --git a/Tests/SimpleInstall/scripts/sample_script b/Tests/RunCMake/install/script
index 81f9f5315..81f9f5315 100755
--- a/Tests/SimpleInstall/scripts/sample_script
+++ b/Tests/RunCMake/install/script
diff --git a/Tests/SimpleInstall/scripts/sample_script.bat b/Tests/RunCMake/install/script.bat
index 64a77b5b0..64a77b5b0 100755
--- a/Tests/SimpleInstall/scripts/sample_script.bat
+++ b/Tests/RunCMake/install/script.bat
diff --git a/Tests/RunCMake/install/testobj1.c b/Tests/RunCMake/install/testobj1.c
new file mode 100644
index 000000000..081ef2027
--- /dev/null
+++ b/Tests/RunCMake/install/testobj1.c
@@ -0,0 +1,9 @@
+#ifdef _WIN32
+__declspec(dllimport)
+#endif
+ int obj1(void);
+
+int main(void)
+{
+ return obj1();
+}
diff --git a/Tests/RunCMake/interface_library/global-interface-stderr.txt b/Tests/RunCMake/interface_library/global-interface-stderr.txt
index 24edd0f89..23b45d926 100644
--- a/Tests/RunCMake/interface_library/global-interface-stderr.txt
+++ b/Tests/RunCMake/interface_library/global-interface-stderr.txt
@@ -3,7 +3,7 @@ CMake Error at global-interface.cmake:2 \(add_library\):
GLOBAL
- Tried extensions \.c \.C \.c\+\+ \.cc \.cpp \.cxx \.m \.M \.mm \.h \.hh \.h\+\+ \.hm \.hpp
- \.hxx \.in \.txx
+ Tried extensions( \.[A-Za-z+]+|
+ )*
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/interface_library/target_commands-stderr.txt b/Tests/RunCMake/interface_library/target_commands-stderr.txt
index be11b7754..9362a752d 100644
--- a/Tests/RunCMake/interface_library/target_commands-stderr.txt
+++ b/Tests/RunCMake/interface_library/target_commands-stderr.txt
@@ -23,25 +23,25 @@ Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at target_commands.cmake:9 \(target_include_directories\):
- target_include_directories may only be set INTERFACE properties on
- INTERFACE targets
+ target_include_directories may only set INTERFACE properties on INTERFACE
+ targets
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at target_commands.cmake:10 \(target_include_directories\):
- target_include_directories may only be set INTERFACE properties on
- INTERFACE targets
+ target_include_directories may only set INTERFACE properties on INTERFACE
+ targets
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at target_commands.cmake:12 \(target_compile_definitions\):
- target_compile_definitions may only be set INTERFACE properties on
- INTERFACE targets
+ target_compile_definitions may only set INTERFACE properties on INTERFACE
+ targets
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
CMake Error at target_commands.cmake:13 \(target_compile_definitions\):
- target_compile_definitions may only be set INTERFACE properties on
- INTERFACE targets
+ target_compile_definitions may only set INTERFACE properties on INTERFACE
+ targets
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/interface_library/whitelist.cmake b/Tests/RunCMake/interface_library/whitelist.cmake
index 98ef05c0f..0db637531 100644
--- a/Tests/RunCMake/interface_library/whitelist.cmake
+++ b/Tests/RunCMake/interface_library/whitelist.cmake
@@ -4,3 +4,22 @@ add_library(iface INTERFACE)
set_property(TARGET iface PROPERTY OUTPUT_NAME output)
set_property(TARGET iface APPEND PROPERTY OUTPUT_NAME append)
get_target_property(outname iface OUTPUT_NAME)
+
+# Properties starting with `_` are allowed.
+set_property(TARGET iface PROPERTY "_custom_property" output)
+set_property(TARGET iface APPEND PROPERTY "_custom_property" append)
+get_target_property(outname iface "_custom_property")
+
+# Properties starting with a lowercase letter are allowed.
+set_property(TARGET iface PROPERTY "custom_property" output)
+set_property(TARGET iface APPEND PROPERTY "custom_property" append)
+get_target_property(outname iface "custom_property")
+
+# PUBLIC_HEADER / PRIVATE_HEADER properties are allowed
+set_property(TARGET iface PROPERTY PUBLIC_HEADER foo.h)
+set_property(TARGET iface APPEND PROPERTY PUBLIC_HEADER bar.h)
+get_target_property(outname iface PUBLIC_HEADER)
+
+set_property(TARGET iface PROPERTY PRIVATE_HEADER foo.h)
+set_property(TARGET iface APPEND PROPERTY PRIVATE_HEADER bar.h)
+get_target_property(outname iface PRIVATE_HEADER)
diff --git a/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt b/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt
index b24a0ed0b..9368e880b 100644
--- a/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt
+++ b/Tests/RunCMake/list/EmptyRemoveAt0-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at EmptyRemoveAt0.cmake:2 \(list\):
- list REMOVE_AT given empty list
+ list index: mylist, 0 out of range \(0, 0\)
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/FILTER-NotList-stderr.txt b/Tests/RunCMake/list/FILTER-NotList-stderr.txt
deleted file mode 100644
index 159c28dd4..000000000
--- a/Tests/RunCMake/list/FILTER-NotList-stderr.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-^CMake Error at FILTER-NotList.cmake:2 \(list\):
- list sub-command FILTER requires list to be present.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/FILTER-NotList.cmake b/Tests/RunCMake/list/FILTER-NotList.cmake
index 1e15635b9..bf09ec74f 100644
--- a/Tests/RunCMake/list/FILTER-NotList.cmake
+++ b/Tests/RunCMake/list/FILTER-NotList.cmake
@@ -1,2 +1,6 @@
unset(nosuchlist)
list(FILTER nosuchlist EXCLUDE REGEX "^FILTER_THIS_.+")
+if (DEFINED nosuchlist)
+ message(FATAL_ERROR
+ "list(FILTER) created our list")
+endif ()
diff --git a/Tests/RunCMake/list/INSERT-InvalidIndex-stderr.txt b/Tests/RunCMake/list/INSERT-InvalidIndex-stderr.txt
index 6e15c0b43..9b9c5e0af 100644
--- a/Tests/RunCMake/list/INSERT-InvalidIndex-stderr.txt
+++ b/Tests/RunCMake/list/INSERT-InvalidIndex-stderr.txt
@@ -1,4 +1,4 @@
^CMake Error at INSERT-InvalidIndex.cmake:2 \(list\):
- list index: 3 out of range \(-3, 2\)
+ list index: 4 out of range \(-3, 3\)
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/INSERT-InvalidIndex.cmake b/Tests/RunCMake/list/INSERT-InvalidIndex.cmake
index 4103d974b..12ac114cb 100644
--- a/Tests/RunCMake/list/INSERT-InvalidIndex.cmake
+++ b/Tests/RunCMake/list/INSERT-InvalidIndex.cmake
@@ -1,2 +1,2 @@
set(mylist alpha bravo charlie)
-list(INSERT mylist 3 delta)
+list(INSERT mylist 4 delta)
diff --git a/Tests/RunCMake/list/JOIN-NoArguments-result.txt b/Tests/RunCMake/list/JOIN-NoArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/JOIN-NoArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/JOIN-NoArguments-stderr.txt b/Tests/RunCMake/list/JOIN-NoArguments-stderr.txt
new file mode 100644
index 000000000..5e1b98f35
--- /dev/null
+++ b/Tests/RunCMake/list/JOIN-NoArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at JOIN-NoArguments.cmake:1 \(list\):
+ list sub-command JOIN requires three arguments \(1 found\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/JOIN-NoArguments.cmake b/Tests/RunCMake/list/JOIN-NoArguments.cmake
new file mode 100644
index 000000000..2ab449a97
--- /dev/null
+++ b/Tests/RunCMake/list/JOIN-NoArguments.cmake
@@ -0,0 +1 @@
+list(JOIN mylist)
diff --git a/Tests/RunCMake/list/JOIN-NoVariable-result.txt b/Tests/RunCMake/list/JOIN-NoVariable-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/JOIN-NoVariable-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/JOIN-NoVariable-stderr.txt b/Tests/RunCMake/list/JOIN-NoVariable-stderr.txt
new file mode 100644
index 000000000..db1d77307
--- /dev/null
+++ b/Tests/RunCMake/list/JOIN-NoVariable-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at JOIN-NoVariable.cmake:1 \(list\):
+ list sub-command JOIN requires three arguments \(2 found\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/JOIN-NoVariable.cmake b/Tests/RunCMake/list/JOIN-NoVariable.cmake
new file mode 100644
index 000000000..b60d8f14f
--- /dev/null
+++ b/Tests/RunCMake/list/JOIN-NoVariable.cmake
@@ -0,0 +1 @@
+list(JOIN mylist "glue")
diff --git a/Tests/RunCMake/list/JOIN-TooManyArguments-result.txt b/Tests/RunCMake/list/JOIN-TooManyArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/JOIN-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/JOIN-TooManyArguments-stderr.txt b/Tests/RunCMake/list/JOIN-TooManyArguments-stderr.txt
new file mode 100644
index 000000000..2b09e22a2
--- /dev/null
+++ b/Tests/RunCMake/list/JOIN-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at JOIN-TooManyArguments.cmake:1 \(list\):
+ list sub-command JOIN requires three arguments \(4 found\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/JOIN-TooManyArguments.cmake b/Tests/RunCMake/list/JOIN-TooManyArguments.cmake
new file mode 100644
index 000000000..dc651f6c1
--- /dev/null
+++ b/Tests/RunCMake/list/JOIN-TooManyArguments.cmake
@@ -0,0 +1 @@
+list(JOIN mylist "glue" out one_too_many)
diff --git a/Tests/RunCMake/list/JOIN.cmake b/Tests/RunCMake/list/JOIN.cmake
new file mode 100644
index 000000000..24a623e66
--- /dev/null
+++ b/Tests/RunCMake/list/JOIN.cmake
@@ -0,0 +1,18 @@
+list(JOIN undefList % out)
+if(NOT out STREQUAL "")
+ message(FATAL_ERROR "\"list(JOIN undefList % out)\" set out to \"${out}\"")
+endif()
+set(myList a)
+list(JOIN myList % out)
+if(NOT out STREQUAL "a")
+ message(FATAL_ERROR "\"list(JOIN \"a\" % out)\" set out to \"${out}\"")
+endif()
+set(myList a b)
+list(JOIN myList % out)
+if(NOT out STREQUAL "a%b")
+ message(FATAL_ERROR "\"list(JOIN \"a;b\" % out)\" set out to \"${out}\"")
+endif()
+list(JOIN myList "" out)
+if(NOT out STREQUAL "ab")
+ message(FATAL_ERROR "\"list(JOIN \"a;b\" \"\" out a)\" set out to \"${out}\"")
+endif()
diff --git a/Tests/RunCMake/list/POP_BACK-NoArgs-result.txt b/Tests/RunCMake/list/POP_BACK-NoArgs-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/POP_BACK-NoArgs-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/POP_BACK-NoArgs-stderr.txt b/Tests/RunCMake/list/POP_BACK-NoArgs-stderr.txt
new file mode 100644
index 000000000..83060b44c
--- /dev/null
+++ b/Tests/RunCMake/list/POP_BACK-NoArgs-stderr.txt
@@ -0,0 +1 @@
+list must be called with at least two arguments
diff --git a/Tests/RunCMake/list/POP_BACK-NoArgs.cmake b/Tests/RunCMake/list/POP_BACK-NoArgs.cmake
new file mode 100644
index 000000000..518924d71
--- /dev/null
+++ b/Tests/RunCMake/list/POP_BACK-NoArgs.cmake
@@ -0,0 +1 @@
+list(POP_FRONT)
diff --git a/Tests/RunCMake/list/POP_BACK.cmake b/Tests/RunCMake/list/POP_BACK.cmake
new file mode 100644
index 000000000..479479632
--- /dev/null
+++ b/Tests/RunCMake/list/POP_BACK.cmake
@@ -0,0 +1,79 @@
+cmake_policy(SET CMP0054 NEW)
+
+function(assert_expected_list_len list_var expected_size)
+ list(LENGTH ${list_var} _size)
+ if(NOT _size EQUAL ${expected_size})
+ message(FATAL_ERROR "list size expected to be `${expected_size}`, got `${_size}` instead")
+ endif()
+endfunction()
+
+# Pop from undefined list
+list(POP_BACK test)
+if(DEFINED test)
+ message(FATAL_ERROR "`test` expected to be undefined")
+endif()
+
+# Pop from empty list
+set(test)
+list(POP_BACK test)
+if(DEFINED test)
+ message(FATAL_ERROR "`test` expected to be undefined")
+endif()
+
+# Default pop from 1-item list
+list(APPEND test one)
+list(POP_BACK test)
+assert_expected_list_len(test 0)
+
+# Pop from 1-item list to var
+list(APPEND test one)
+list(POP_BACK test one)
+assert_expected_list_len(test 0)
+if(NOT DEFINED one)
+ message(FATAL_ERROR "`one` expected to be defined")
+endif()
+if(NOT one STREQUAL "one")
+ message(FATAL_ERROR "`one` has unexpected value `${one}`")
+endif()
+
+unset(one)
+unset(two)
+
+# Pop from 1-item list to vars
+list(APPEND test one)
+list(POP_BACK test one two)
+assert_expected_list_len(test 0)
+if(NOT DEFINED one)
+ message(FATAL_ERROR "`one` expected to be defined")
+endif()
+if(NOT one STREQUAL "one")
+ message(FATAL_ERROR "`one` has unexpected value `${one}`")
+endif()
+if(DEFINED two)
+ message(FATAL_ERROR "`two` expected to be undefined")
+endif()
+
+unset(one)
+unset(two)
+
+# Default pop from 2-item list
+list(APPEND test one two)
+list(POP_BACK test)
+assert_expected_list_len(test 1)
+if(NOT test STREQUAL "one")
+ message(FATAL_ERROR "`test` has unexpected value `${test}`")
+endif()
+
+# Pop from 2-item list
+list(APPEND test two)
+list(POP_BACK test two)
+assert_expected_list_len(test 1)
+if(NOT DEFINED two)
+ message(FATAL_ERROR "`two` expected to be defined")
+endif()
+if(NOT two STREQUAL "two")
+ message(FATAL_ERROR "`two` has unexpected value `${two}`")
+endif()
+if(NOT test STREQUAL "one")
+ message(FATAL_ERROR "`test` has unexpected value `${test}`")
+endif()
diff --git a/Tests/RunCMake/list/POP_FRONT-NoArgs-result.txt b/Tests/RunCMake/list/POP_FRONT-NoArgs-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/POP_FRONT-NoArgs-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/POP_FRONT-NoArgs-stderr.txt b/Tests/RunCMake/list/POP_FRONT-NoArgs-stderr.txt
new file mode 100644
index 000000000..83060b44c
--- /dev/null
+++ b/Tests/RunCMake/list/POP_FRONT-NoArgs-stderr.txt
@@ -0,0 +1 @@
+list must be called with at least two arguments
diff --git a/Tests/RunCMake/list/POP_FRONT-NoArgs.cmake b/Tests/RunCMake/list/POP_FRONT-NoArgs.cmake
new file mode 100644
index 000000000..c5cf83739
--- /dev/null
+++ b/Tests/RunCMake/list/POP_FRONT-NoArgs.cmake
@@ -0,0 +1 @@
+list(POP_BACK)
diff --git a/Tests/RunCMake/list/POP_FRONT.cmake b/Tests/RunCMake/list/POP_FRONT.cmake
new file mode 100644
index 000000000..70f757a27
--- /dev/null
+++ b/Tests/RunCMake/list/POP_FRONT.cmake
@@ -0,0 +1,92 @@
+cmake_policy(SET CMP0054 NEW)
+
+function(assert_expected_list_len list_var expected_size)
+ list(LENGTH ${list_var} _size)
+ if(NOT _size EQUAL ${expected_size})
+ message(FATAL_ERROR "list size expected to be `${expected_size}`, got `${_size}` instead")
+ endif()
+endfunction()
+
+# Pop from undefined list
+list(POP_FRONT test)
+if(DEFINED test)
+ message(FATAL_ERROR "`test` expected to be undefined")
+endif()
+
+# Pop from empty list
+set(test)
+list(POP_FRONT test)
+if(DEFINED test)
+ message(FATAL_ERROR "`test` expected to be undefined")
+endif()
+
+# Default pop from 1-item list
+list(APPEND test one)
+list(POP_FRONT test)
+assert_expected_list_len(test 0)
+
+# Pop from 1-item list to var
+list(APPEND test one)
+list(POP_FRONT test one)
+assert_expected_list_len(test 0)
+if(NOT DEFINED one)
+ message(FATAL_ERROR "`one` expected to be defined")
+endif()
+if(NOT one STREQUAL "one")
+ message(FATAL_ERROR "`one` has unexpected value `${one}`")
+endif()
+
+unset(one)
+unset(two)
+
+# Pop from 1-item list to vars
+list(APPEND test one)
+list(POP_FRONT test one two)
+assert_expected_list_len(test 0)
+if(NOT DEFINED one)
+ message(FATAL_ERROR "`one` expected to be defined")
+endif()
+if(NOT one STREQUAL "one")
+ message(FATAL_ERROR "`one` has unexpected value `${one}`")
+endif()
+if(DEFINED two)
+ message(FATAL_ERROR "`two` expected to be undefined")
+endif()
+
+unset(one)
+unset(two)
+
+# Default pop from 2-item list
+list(APPEND test one two)
+list(POP_FRONT test)
+assert_expected_list_len(test 1)
+if(NOT test STREQUAL "two")
+ message(FATAL_ERROR "`test` has unexpected value `${test}`")
+endif()
+
+# Pop from 2-item list
+list(PREPEND test one)
+list(POP_FRONT test one)
+assert_expected_list_len(test 1)
+if(NOT DEFINED one)
+ message(FATAL_ERROR "`one` expected to be defined")
+endif()
+if(NOT one STREQUAL "one")
+ message(FATAL_ERROR "`one` has unexpected value `${one}`")
+endif()
+if(NOT test STREQUAL "two")
+ message(FATAL_ERROR "`test` has unexpected value `${test}`")
+endif()
+
+# BUG 19436
+set(myList a b c)
+list(POP_FRONT myList first second)
+if(NOT first STREQUAL "a")
+ message(FATAL_ERROR "BUG#19436: `first` has unexpected value `${first}`")
+endif()
+if(NOT second STREQUAL "b")
+ message(FATAL_ERROR "BUG#19436: `second` has unexpected value `${second}`")
+endif()
+if(NOT myList STREQUAL "c")
+ message(FATAL_ERROR "BUG#19436: `myList` has unexpected value `${myList}`")
+endif()
diff --git a/Tests/RunCMake/list/PREPEND-NoArgs-result.txt b/Tests/RunCMake/list/PREPEND-NoArgs-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/PREPEND-NoArgs-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/PREPEND-NoArgs-stderr.txt b/Tests/RunCMake/list/PREPEND-NoArgs-stderr.txt
new file mode 100644
index 000000000..83060b44c
--- /dev/null
+++ b/Tests/RunCMake/list/PREPEND-NoArgs-stderr.txt
@@ -0,0 +1 @@
+list must be called with at least two arguments
diff --git a/Tests/RunCMake/list/PREPEND-NoArgs.cmake b/Tests/RunCMake/list/PREPEND-NoArgs.cmake
new file mode 100644
index 000000000..8935fa9c5
--- /dev/null
+++ b/Tests/RunCMake/list/PREPEND-NoArgs.cmake
@@ -0,0 +1 @@
+list(PREPEND)
diff --git a/Tests/RunCMake/list/PREPEND.cmake b/Tests/RunCMake/list/PREPEND.cmake
new file mode 100644
index 000000000..17b292126
--- /dev/null
+++ b/Tests/RunCMake/list/PREPEND.cmake
@@ -0,0 +1,33 @@
+list(PREPEND test)
+if(test)
+ message(FATAL_ERROR "failed")
+endif()
+
+list(PREPEND test satu)
+if(NOT test STREQUAL "satu")
+ message(FATAL_ERROR "failed")
+endif()
+
+list(PREPEND test dua)
+if(NOT test STREQUAL "dua;satu")
+ message(FATAL_ERROR "failed")
+endif()
+
+list(PREPEND test tiga)
+if(NOT test STREQUAL "tiga;dua;satu")
+ message(FATAL_ERROR "failed")
+endif()
+
+# Scope test
+function(foo)
+ list(PREPEND test empat)
+ if(NOT test STREQUAL "empat;tiga;dua;satu")
+ message(FATAL_ERROR "failed")
+ endif()
+endfunction()
+
+foo()
+
+if(NOT test STREQUAL "tiga;dua;satu")
+ message(FATAL_ERROR "failed")
+endif()
diff --git a/Tests/RunCMake/list/REMOVE_AT-EmptyList-result.txt b/Tests/RunCMake/list/REMOVE_AT-EmptyList-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/REMOVE_AT-EmptyList-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/REMOVE_AT-EmptyList-stderr.txt b/Tests/RunCMake/list/REMOVE_AT-EmptyList-stderr.txt
new file mode 100644
index 000000000..582b74b04
--- /dev/null
+++ b/Tests/RunCMake/list/REMOVE_AT-EmptyList-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at REMOVE_AT-EmptyList.cmake:2 \(list\):
+ list index: nosuchlist, 0 out of range \(0, 0\)
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/REMOVE_AT-EmptyList.cmake b/Tests/RunCMake/list/REMOVE_AT-EmptyList.cmake
new file mode 100644
index 000000000..ff0dde84f
--- /dev/null
+++ b/Tests/RunCMake/list/REMOVE_AT-EmptyList.cmake
@@ -0,0 +1,6 @@
+set(nosuchlist "")
+list(REMOVE_AT nosuchlist 0)
+if (NOT DEFINED nosuchlist OR NOT nosuchlist STREQUAL "")
+ message(FATAL_ERROR
+ "list(REMOVE_AT) modified our list")
+endif ()
diff --git a/Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt b/Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt
index d6e8d85f5..563d865ea 100644
--- a/Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt
+++ b/Tests/RunCMake/list/REMOVE_AT-NotList-stderr.txt
@@ -1,4 +1,4 @@
^CMake Error at REMOVE_AT-NotList.cmake:2 \(list\):
- list sub-command REMOVE_AT requires list to be present.
+ list index: nosuchlist, 0 out of range \(0, 0\)
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/REMOVE_AT-NotList.cmake b/Tests/RunCMake/list/REMOVE_AT-NotList.cmake
index 5266c7fe9..090df4933 100644
--- a/Tests/RunCMake/list/REMOVE_AT-NotList.cmake
+++ b/Tests/RunCMake/list/REMOVE_AT-NotList.cmake
@@ -1,2 +1,6 @@
unset(nosuchlist)
list(REMOVE_AT nosuchlist 0)
+if (DEFINED nosuchlist)
+ message(FATAL_ERROR
+ "list(REMOVE_AT) created our list")
+endif ()
diff --git a/Tests/RunCMake/list/REMOVE_DUPLICATES-NotList-stderr.txt b/Tests/RunCMake/list/REMOVE_DUPLICATES-NotList-stderr.txt
deleted file mode 100644
index 96f3446ff..000000000
--- a/Tests/RunCMake/list/REMOVE_DUPLICATES-NotList-stderr.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-^CMake Error at REMOVE_DUPLICATES-NotList.cmake:2 \(list\):
- list sub-command REMOVE_DUPLICATES requires list to be present.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/REMOVE_DUPLICATES-NotList.cmake b/Tests/RunCMake/list/REMOVE_DUPLICATES-NotList.cmake
index 218f2272c..b9f399943 100644
--- a/Tests/RunCMake/list/REMOVE_DUPLICATES-NotList.cmake
+++ b/Tests/RunCMake/list/REMOVE_DUPLICATES-NotList.cmake
@@ -1,2 +1,6 @@
unset(nosuchlist)
list(REMOVE_DUPLICATES nosuchlist)
+if (DEFINED nosuchlist)
+ message(FATAL_ERROR
+ "list(REMOVE_DUPLICATES) created our list")
+endif ()
diff --git a/Tests/RunCMake/list/REMOVE_DUPLICATES-PreserveOrder.cmake b/Tests/RunCMake/list/REMOVE_DUPLICATES-PreserveOrder.cmake
new file mode 100644
index 000000000..91abbd61a
--- /dev/null
+++ b/Tests/RunCMake/list/REMOVE_DUPLICATES-PreserveOrder.cmake
@@ -0,0 +1,5 @@
+set(mylist "b;c;b;a;a;c;b;a;c;b")
+list(REMOVE_DUPLICATES mylist)
+if(NOT mylist STREQUAL "b;c;a")
+ message(SEND_ERROR "Expected b;c;a, got ${mylist}")
+endif()
diff --git a/Tests/RunCMake/list/REMOVE_ITEM-NotList-stderr.txt b/Tests/RunCMake/list/REMOVE_ITEM-NotList-stderr.txt
deleted file mode 100644
index c32a4c055..000000000
--- a/Tests/RunCMake/list/REMOVE_ITEM-NotList-stderr.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-^CMake Error at REMOVE_ITEM-NotList.cmake:2 \(list\):
- list sub-command REMOVE_ITEM requires list to be present.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/REMOVE_ITEM-NotList.cmake b/Tests/RunCMake/list/REMOVE_ITEM-NotList.cmake
index 079e7fbce..0c66837c5 100644
--- a/Tests/RunCMake/list/REMOVE_ITEM-NotList.cmake
+++ b/Tests/RunCMake/list/REMOVE_ITEM-NotList.cmake
@@ -1,2 +1,6 @@
unset(nosuchlist)
list(REMOVE_ITEM nosuchlist alpha)
+if (DEFINED nosuchlist)
+ message(FATAL_ERROR
+ "list(REMOVE_ITEM) created our list")
+endif ()
diff --git a/Tests/RunCMake/list/REVERSE-NotList-stderr.txt b/Tests/RunCMake/list/REVERSE-NotList-stderr.txt
deleted file mode 100644
index e9dcc06b3..000000000
--- a/Tests/RunCMake/list/REVERSE-NotList-stderr.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-^CMake Error at REVERSE-NotList.cmake:2 \(list\):
- list sub-command REVERSE requires list to be present.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/REVERSE-NotList.cmake b/Tests/RunCMake/list/REVERSE-NotList.cmake
index 977e2ccac..71383294c 100644
--- a/Tests/RunCMake/list/REVERSE-NotList.cmake
+++ b/Tests/RunCMake/list/REVERSE-NotList.cmake
@@ -1,2 +1,6 @@
unset(nosuchlist)
list(REVERSE nosuchlist)
+if (DEFINED nosuchlist)
+ message(FATAL_ERROR
+ "list(REVERSE) created our list")
+endif ()
diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake
index b002ab388..b4a91bc62 100644
--- a/Tests/RunCMake/list/RunCMakeTest.cmake
+++ b/Tests/RunCMake/list/RunCMakeTest.cmake
@@ -13,12 +13,18 @@ run_cmake(FILTER-REGEX-InvalidRegex)
run_cmake(GET-InvalidIndex)
run_cmake(INSERT-InvalidIndex)
run_cmake(REMOVE_AT-InvalidIndex)
+run_cmake(SUBLIST-InvalidIndex)
run_cmake(FILTER-REGEX-TooManyArguments)
+run_cmake(JOIN-TooManyArguments)
run_cmake(LENGTH-TooManyArguments)
run_cmake(REMOVE_DUPLICATES-TooManyArguments)
run_cmake(REVERSE-TooManyArguments)
-run_cmake(SORT-TooManyArguments)
+run_cmake(SUBLIST-TooManyArguments)
+
+run_cmake(REMOVE_AT-EmptyList)
+
+run_cmake(REMOVE_DUPLICATES-PreserveOrder)
run_cmake(FILTER-NotList)
run_cmake(REMOVE_AT-NotList)
@@ -31,3 +37,78 @@ run_cmake(FILTER-REGEX-InvalidMode)
run_cmake(FILTER-REGEX-InvalidOperator)
run_cmake(FILTER-REGEX-Valid0)
run_cmake(FILTER-REGEX-Valid1)
+
+run_cmake(JOIN-NoArguments)
+run_cmake(JOIN-NoVariable)
+run_cmake(JOIN)
+
+run_cmake(SUBLIST-NoArguments)
+run_cmake(SUBLIST-NoVariable)
+run_cmake(SUBLIST-InvalidLength)
+run_cmake(SUBLIST)
+
+run_cmake(TRANSFORM-NoAction)
+run_cmake(TRANSFORM-InvalidAction)
+# 'action' oriented tests
+run_cmake(TRANSFORM-TOUPPER-TooManyArguments)
+run_cmake(TRANSFORM-TOLOWER-TooManyArguments)
+run_cmake(TRANSFORM-STRIP-TooManyArguments)
+run_cmake(TRANSFORM-GENEX_STRIP-TooManyArguments)
+run_cmake(TRANSFORM-APPEND-NoArguments)
+run_cmake(TRANSFORM-APPEND-TooManyArguments)
+run_cmake(TRANSFORM-PREPEND-NoArguments)
+run_cmake(TRANSFORM-PREPEND-TooManyArguments)
+run_cmake(TRANSFORM-REPLACE-NoArguments)
+run_cmake(TRANSFORM-REPLACE-NoEnoughArguments)
+run_cmake(TRANSFORM-REPLACE-TooManyArguments)
+run_cmake(TRANSFORM-REPLACE-InvalidRegex)
+run_cmake(TRANSFORM-REPLACE-InvalidReplace1)
+run_cmake(TRANSFORM-REPLACE-InvalidReplace2)
+# 'selector' oriented tests
+run_cmake(TRANSFORM-Selector-REGEX-NoArguments)
+run_cmake(TRANSFORM-Selector-REGEX-TooManyArguments)
+run_cmake(TRANSFORM-Selector-REGEX-InvalidRegex)
+run_cmake(TRANSFORM-Selector-AT-NoArguments)
+run_cmake(TRANSFORM-Selector-AT-BadArgument)
+run_cmake(TRANSFORM-Selector-AT-InvalidIndex)
+run_cmake(TRANSFORM-Selector-FOR-NoArguments)
+run_cmake(TRANSFORM-Selector-FOR-NoEnoughArguments)
+run_cmake(TRANSFORM-Selector-FOR-TooManyArguments)
+run_cmake(TRANSFORM-Selector-FOR-BadArgument)
+run_cmake(TRANSFORM-Selector-FOR-InvalidIndex)
+# 'output' oriented tests
+run_cmake(TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments)
+run_cmake(TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments)
+# Successful tests
+run_cmake(TRANSFORM-TOUPPER)
+run_cmake(TRANSFORM-TOLOWER)
+run_cmake(TRANSFORM-STRIP)
+run_cmake(TRANSFORM-GENEX_STRIP)
+run_cmake(TRANSFORM-APPEND)
+run_cmake(TRANSFORM-PREPEND)
+run_cmake(TRANSFORM-REPLACE)
+
+# argument tests
+run_cmake(SORT-WrongOption)
+run_cmake(SORT-BadCaseOption)
+run_cmake(SORT-BadCompareOption)
+run_cmake(SORT-BadOrderOption)
+run_cmake(SORT-DuplicateOrderOption)
+run_cmake(SORT-DuplicateCompareOption)
+run_cmake(SORT-DuplicateCaseOption)
+run_cmake(SORT-NoCaseOption)
+
+# Successful tests
+run_cmake(SORT)
+
+# argument tests
+run_cmake(PREPEND-NoArgs)
+# Successful tests
+run_cmake(PREPEND)
+
+# argument tests
+run_cmake(POP_BACK-NoArgs)
+run_cmake(POP_FRONT-NoArgs)
+# Successful tests
+run_cmake(POP_BACK)
+run_cmake(POP_FRONT)
diff --git a/Tests/RunCMake/list/SORT-BadCaseOption-result.txt b/Tests/RunCMake/list/SORT-BadCaseOption-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-BadCaseOption-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/SORT-BadCaseOption-stderr.txt b/Tests/RunCMake/list/SORT-BadCaseOption-stderr.txt
new file mode 100644
index 000000000..87dd50283
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-BadCaseOption-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at SORT-BadCaseOption.cmake:1 \(list\):
+ list sub-command SORT value "BAD_CASE_OPTION" for option "CASE" is invalid.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SORT-BadCaseOption.cmake b/Tests/RunCMake/list/SORT-BadCaseOption.cmake
new file mode 100644
index 000000000..ac5c102b6
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-BadCaseOption.cmake
@@ -0,0 +1 @@
+list(SORT mylist CASE BAD_CASE_OPTION)
diff --git a/Tests/RunCMake/list/SORT-BadCompareOption-result.txt b/Tests/RunCMake/list/SORT-BadCompareOption-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-BadCompareOption-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/SORT-BadCompareOption-stderr.txt b/Tests/RunCMake/list/SORT-BadCompareOption-stderr.txt
new file mode 100644
index 000000000..51b4de291
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-BadCompareOption-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at SORT-BadCompareOption.cmake:1 \(list\):
+ list sub-command SORT value "BAD_COMPARE_OPTION" for option "COMPARE" is
+ invalid.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SORT-BadCompareOption.cmake b/Tests/RunCMake/list/SORT-BadCompareOption.cmake
new file mode 100644
index 000000000..d5c632e39
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-BadCompareOption.cmake
@@ -0,0 +1 @@
+list(SORT mylist COMPARE BAD_COMPARE_OPTION)
diff --git a/Tests/RunCMake/list/SORT-BadOrderOption-result.txt b/Tests/RunCMake/list/SORT-BadOrderOption-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-BadOrderOption-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/SORT-BadOrderOption-stderr.txt b/Tests/RunCMake/list/SORT-BadOrderOption-stderr.txt
new file mode 100644
index 000000000..7984e5c92
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-BadOrderOption-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at SORT-BadOrderOption.cmake:1 \(list\):
+ list sub-command SORT value "BAD_ODER_OPTION" for option "ORDER" is
+ invalid.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SORT-BadOrderOption.cmake b/Tests/RunCMake/list/SORT-BadOrderOption.cmake
new file mode 100644
index 000000000..e23219772
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-BadOrderOption.cmake
@@ -0,0 +1 @@
+list(SORT mylist ORDER BAD_ODER_OPTION)
diff --git a/Tests/RunCMake/list/SORT-DuplicateCaseOption-result.txt b/Tests/RunCMake/list/SORT-DuplicateCaseOption-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-DuplicateCaseOption-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/SORT-DuplicateCaseOption-stderr.txt b/Tests/RunCMake/list/SORT-DuplicateCaseOption-stderr.txt
new file mode 100644
index 000000000..b893f50eb
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-DuplicateCaseOption-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at SORT-DuplicateCaseOption.cmake:2 \(list\):
+ list sub-command SORT option "CASE" has been specified multiple times.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SORT-DuplicateCaseOption.cmake b/Tests/RunCMake/list/SORT-DuplicateCaseOption.cmake
new file mode 100644
index 000000000..ba52b2410
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-DuplicateCaseOption.cmake
@@ -0,0 +1,2 @@
+set (mylist a b c)
+list(SORT mylist CASE INSENSITIVE CASE INSENSITIVE )
diff --git a/Tests/RunCMake/list/SORT-DuplicateCompareOption-result.txt b/Tests/RunCMake/list/SORT-DuplicateCompareOption-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-DuplicateCompareOption-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/SORT-DuplicateCompareOption-stderr.txt b/Tests/RunCMake/list/SORT-DuplicateCompareOption-stderr.txt
new file mode 100644
index 000000000..83624be42
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-DuplicateCompareOption-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at SORT-DuplicateCompareOption.cmake:2 \(list\):
+ list sub-command SORT option "COMPARE" has been specified multiple times.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SORT-DuplicateCompareOption.cmake b/Tests/RunCMake/list/SORT-DuplicateCompareOption.cmake
new file mode 100644
index 000000000..fd2e31d1e
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-DuplicateCompareOption.cmake
@@ -0,0 +1,2 @@
+set (mylist a b c)
+list(SORT mylist COMPARE STRING COMPARE STRING)
diff --git a/Tests/RunCMake/list/SORT-DuplicateOrderOption-result.txt b/Tests/RunCMake/list/SORT-DuplicateOrderOption-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-DuplicateOrderOption-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/SORT-DuplicateOrderOption-stderr.txt b/Tests/RunCMake/list/SORT-DuplicateOrderOption-stderr.txt
new file mode 100644
index 000000000..9e95178a2
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-DuplicateOrderOption-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at SORT-DuplicateOrderOption.cmake:2 \(list\):
+ list sub-command SORT option "ORDER" has been specified multiple times.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SORT-DuplicateOrderOption.cmake b/Tests/RunCMake/list/SORT-DuplicateOrderOption.cmake
new file mode 100644
index 000000000..26d9c7d8a
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-DuplicateOrderOption.cmake
@@ -0,0 +1,2 @@
+set (mylist a b c)
+list(SORT mylist ORDER ASCENDING ORDER ASCENDING)
diff --git a/Tests/RunCMake/list/SORT-NoCaseOption-result.txt b/Tests/RunCMake/list/SORT-NoCaseOption-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-NoCaseOption-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/SORT-NoCaseOption-stderr.txt b/Tests/RunCMake/list/SORT-NoCaseOption-stderr.txt
new file mode 100644
index 000000000..5c63e77a3
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-NoCaseOption-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at SORT-NoCaseOption.cmake:1 \(list\):
+ list sub-command SORT missing argument for option "CASE".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SORT-NoCaseOption.cmake b/Tests/RunCMake/list/SORT-NoCaseOption.cmake
new file mode 100644
index 000000000..57cc4292c
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-NoCaseOption.cmake
@@ -0,0 +1 @@
+list(SORT mylist CASE)
diff --git a/Tests/RunCMake/list/SORT-NotList-stderr.txt b/Tests/RunCMake/list/SORT-NotList-stderr.txt
deleted file mode 100644
index 396c5b57d..000000000
--- a/Tests/RunCMake/list/SORT-NotList-stderr.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-^CMake Error at SORT-NotList.cmake:2 \(list\):
- list sub-command SORT requires list to be present.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SORT-NotList.cmake b/Tests/RunCMake/list/SORT-NotList.cmake
index 8f48e1043..6314f1493 100644
--- a/Tests/RunCMake/list/SORT-NotList.cmake
+++ b/Tests/RunCMake/list/SORT-NotList.cmake
@@ -1,2 +1,6 @@
unset(nosuchlist)
list(SORT nosuchlist)
+if (DEFINED nosuchlist)
+ message(FATAL_ERROR
+ "list(SORT) created our list")
+endif ()
diff --git a/Tests/RunCMake/list/SORT-TooManyArguments-stderr.txt b/Tests/RunCMake/list/SORT-TooManyArguments-stderr.txt
deleted file mode 100644
index d3fad6068..000000000
--- a/Tests/RunCMake/list/SORT-TooManyArguments-stderr.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-^CMake Error at SORT-TooManyArguments.cmake:1 \(list\):
- list sub-command SORT only takes one argument.
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SORT-WrongOption-result.txt b/Tests/RunCMake/list/SORT-WrongOption-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-WrongOption-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/SORT-WrongOption-stderr.txt b/Tests/RunCMake/list/SORT-WrongOption-stderr.txt
new file mode 100644
index 000000000..597cb298d
--- /dev/null
+++ b/Tests/RunCMake/list/SORT-WrongOption-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at SORT-WrongOption.cmake:1 \(list\):
+ list sub-command SORT option "one_too_many" is unknown.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SORT-TooManyArguments.cmake b/Tests/RunCMake/list/SORT-WrongOption.cmake
index 81b195d67..81b195d67 100644
--- a/Tests/RunCMake/list/SORT-TooManyArguments.cmake
+++ b/Tests/RunCMake/list/SORT-WrongOption.cmake
diff --git a/Tests/RunCMake/list/SORT.cmake b/Tests/RunCMake/list/SORT.cmake
new file mode 100644
index 000000000..4a9e064dd
--- /dev/null
+++ b/Tests/RunCMake/list/SORT.cmake
@@ -0,0 +1,114 @@
+set(source_unsorted
+ c/B.h
+ a/c.h
+ B/a.h
+ )
+
+## Test with default options
+set(expected
+ B/a.h
+ a/c.h
+ c/B.h
+ )
+set(list ${source_unsorted})
+list(SORT list)
+if (NOT expected STREQUAL list)
+ message(FATAL_ERROR "wrong sort result with command list(SORT list CASE SENSITIVE ORDER ASCENDING COMPARE STRING)")
+endif ()
+
+
+## Test CASE INSENSITIVE ORDER ASCENDING COMPARE STRING
+set(expected
+ a/c.h
+ B/a.h
+ c/B.h
+ )
+set(list ${source_unsorted})
+list(SORT list CASE INSENSITIVE ORDER ASCENDING COMPARE STRING)
+if (NOT expected STREQUAL list)
+ message(FATAL_ERROR "wrong sort result with command list(SORT list CASE INSENSITIVE ORDER ASCENDING COMPARE STRING)")
+endif ()
+
+## Test CASE INSENSITIVE ORDER DESCENDING COMPARE STRING
+set(expected
+ c/B.h
+ B/a.h
+ a/c.h
+ )
+set(list ${source_unsorted})
+list(SORT list CASE INSENSITIVE ORDER DESCENDING COMPARE STRING)
+if (NOT expected STREQUAL list)
+ message(FATAL_ERROR "wrong sort result with command list(SORT list CASE INSENSITIVE ORDER DESCENDING COMPARE STRING)")
+endif ()
+
+## Test CASE SENSITIVE ORDER ASCENDING COMPARE STRING
+set(expected
+ B/a.h
+ a/c.h
+ c/B.h
+ )
+set(list ${source_unsorted})
+list(SORT list CASE SENSITIVE ORDER ASCENDING COMPARE STRING)
+if (NOT expected STREQUAL list)
+ message(FATAL_ERROR "wrong sort result with command list(SORT list CASE SENSITIVE ORDER ASCENDING COMPARE STRING)")
+endif ()
+
+## Test CASE SENSITIVE ORDER DESCENDING COMPARE STRING
+set(expected
+ c/B.h
+ a/c.h
+ B/a.h
+ )
+set(list ${source_unsorted})
+list(SORT list CASE SENSITIVE ORDER DESCENDING COMPARE STRING)
+if (NOT expected STREQUAL list)
+ message(FATAL_ERROR "wrong sort result with command list(SORT list CASE SENSITIVE ORDER DESCENDING COMPARE STRING)")
+endif ()
+
+## Test CASE INSENSITIVE ORDER ASCENDING COMPARE FILE_BASENAME
+set(expected
+ B/a.h
+ c/B.h
+ a/c.h
+ )
+set(list ${source_unsorted})
+list(SORT list CASE INSENSITIVE ORDER ASCENDING COMPARE FILE_BASENAME)
+if (NOT expected STREQUAL list)
+ message(FATAL_ERROR "wrong sort result with command list(SORT list CASE INSENSITIVE ORDER ASCENDING COMPARE FILE_BASENAME)")
+endif ()
+
+## Test CASE INSENSITIVE ORDER DESCENDING COMPARE FILE_BASENAME
+set(expected
+ a/c.h
+ c/B.h
+ B/a.h
+ )
+set(list ${source_unsorted})
+list(SORT list CASE INSENSITIVE ORDER DESCENDING COMPARE FILE_BASENAME)
+if (NOT expected STREQUAL list)
+ message(FATAL_ERROR "wrong sort result with command list(SORT list CASE INSENSITIVE ORDER DESCENDING COMPARE FILE_BASENAME)")
+endif ()
+
+## Test CASE SENSITIVE ORDER ASCENDING COMPARE FILE_BASENAME
+set(expected
+ c/B.h
+ B/a.h
+ a/c.h
+ )
+set(list ${source_unsorted})
+list(SORT list CASE SENSITIVE ORDER ASCENDING COMPARE FILE_BASENAME)
+if (NOT expected STREQUAL list)
+ message(FATAL_ERROR "wrong sort result with command list(SORT list CASE SENSITIVE ORDER ASCENDING COMPARE FILE_BASENAME)")
+endif ()
+
+## Test CASE SENSITIVE ORDER DESCENDING COMPARE FILE_BASENAME
+set(expected
+ a/c.h
+ B/a.h
+ c/B.h
+ )
+set(list ${source_unsorted})
+list(SORT list CASE SENSITIVE ORDER DESCENDING COMPARE FILE_BASENAME)
+if (NOT expected STREQUAL list)
+ message(FATAL_ERROR "wrong sort result with command list(SORT list CASE SENSITIVE ORDER DESCENDING COMPARE FILE_BASENAME)")
+endif ()
diff --git a/Tests/RunCMake/list/SUBLIST-InvalidIndex-result.txt b/Tests/RunCMake/list/SUBLIST-InvalidIndex-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-InvalidIndex-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/SUBLIST-InvalidIndex-stderr.txt b/Tests/RunCMake/list/SUBLIST-InvalidIndex-stderr.txt
new file mode 100644
index 000000000..5e67b271d
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-InvalidIndex-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at SUBLIST-InvalidIndex.cmake:2 \(list\):
+ list begin index: 3 is out of range 0 - 2
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SUBLIST-InvalidIndex.cmake b/Tests/RunCMake/list/SUBLIST-InvalidIndex.cmake
new file mode 100644
index 000000000..565b9dc39
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-InvalidIndex.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(SUBLIST mylist 3 -1 result)
diff --git a/Tests/RunCMake/list/SUBLIST-InvalidLength-result.txt b/Tests/RunCMake/list/SUBLIST-InvalidLength-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-InvalidLength-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/SUBLIST-InvalidLength-stderr.txt b/Tests/RunCMake/list/SUBLIST-InvalidLength-stderr.txt
new file mode 100644
index 000000000..16c6ecb34
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-InvalidLength-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at SUBLIST-InvalidLength.cmake:2 \(list\):
+ list length: -2 should be -1 or greater
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SUBLIST-InvalidLength.cmake b/Tests/RunCMake/list/SUBLIST-InvalidLength.cmake
new file mode 100644
index 000000000..1dab83f22
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-InvalidLength.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(SUBLIST mylist 0 -2 result)
diff --git a/Tests/RunCMake/list/SUBLIST-NoArguments-result.txt b/Tests/RunCMake/list/SUBLIST-NoArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-NoArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/SUBLIST-NoArguments-stderr.txt b/Tests/RunCMake/list/SUBLIST-NoArguments-stderr.txt
new file mode 100644
index 000000000..073173cde
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-NoArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at SUBLIST-NoArguments.cmake:1 \(list\):
+ list sub-command SUBLIST requires four arguments \(1 found\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SUBLIST-NoArguments.cmake b/Tests/RunCMake/list/SUBLIST-NoArguments.cmake
new file mode 100644
index 000000000..df38b8780
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-NoArguments.cmake
@@ -0,0 +1 @@
+list(SUBLIST mylist)
diff --git a/Tests/RunCMake/list/SUBLIST-NoVariable-result.txt b/Tests/RunCMake/list/SUBLIST-NoVariable-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-NoVariable-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/SUBLIST-NoVariable-stderr.txt b/Tests/RunCMake/list/SUBLIST-NoVariable-stderr.txt
new file mode 100644
index 000000000..6f80c1a98
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-NoVariable-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at SUBLIST-NoVariable.cmake:2 \(list\):
+ list sub-command SUBLIST requires four arguments \(3 found\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SUBLIST-NoVariable.cmake b/Tests/RunCMake/list/SUBLIST-NoVariable.cmake
new file mode 100644
index 000000000..83edae9f3
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-NoVariable.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(SUBLIST mylist 0 -1)
diff --git a/Tests/RunCMake/list/SUBLIST-TooManyArguments-result.txt b/Tests/RunCMake/list/SUBLIST-TooManyArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/SUBLIST-TooManyArguments-stderr.txt b/Tests/RunCMake/list/SUBLIST-TooManyArguments-stderr.txt
new file mode 100644
index 000000000..eb468449b
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at SUBLIST-TooManyArguments.cmake:1 \(list\):
+ list sub-command SUBLIST requires four arguments \(5 found\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/SUBLIST-TooManyArguments.cmake b/Tests/RunCMake/list/SUBLIST-TooManyArguments.cmake
new file mode 100644
index 000000000..28f20c120
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST-TooManyArguments.cmake
@@ -0,0 +1 @@
+list(SUBLIST mylist 0 -1 result one_too_many)
diff --git a/Tests/RunCMake/list/SUBLIST.cmake b/Tests/RunCMake/list/SUBLIST.cmake
new file mode 100644
index 000000000..fd15c2844
--- /dev/null
+++ b/Tests/RunCMake/list/SUBLIST.cmake
@@ -0,0 +1,46 @@
+set(mylist alpha bravo charlie delta)
+list(SUBLIST mylist 1 2 result)
+
+if (NOT result STREQUAL "bravo;charlie")
+ message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"bravo;charlie\"")
+endif()
+
+
+unset(result)
+list(SUBLIST mylist 0 2 result)
+
+if (NOT result STREQUAL "alpha;bravo")
+ message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"alpha;bravo\"")
+endif()
+
+
+unset(result)
+list(SUBLIST mylist 3 2 result)
+
+if (NOT result STREQUAL "delta")
+ message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"delta\"")
+endif()
+
+
+unset(result)
+list(SUBLIST mylist 2 0 result)
+list(LENGTH result length)
+if (NOT length EQUAL 0)
+ message (FATAL_ERROR "SUBLIST is \"${result}\", expected is an empty list")
+endif()
+
+
+unset(result)
+list(SUBLIST mylist 1 5 result)
+
+if (NOT result STREQUAL "bravo;charlie;delta")
+ message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"bravo;charlie;delta\"")
+endif()
+
+
+unset(result)
+list(SUBLIST mylist 1 -1 result)
+
+if (NOT result STREQUAL "bravo;charlie;delta")
+ message (FATAL_ERROR "SUBLIST is \"${result}\", expected is \"bravo;charlie;delta\"")
+endif()
diff --git a/Tests/RunCMake/list/TRANSFORM-APPEND-NoArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-APPEND-NoArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-APPEND-NoArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-APPEND-NoArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-APPEND-NoArguments-stderr.txt
new file mode 100644
index 000000000..028f8d589
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-APPEND-NoArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-APPEND-NoArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, action APPEND expects 1 argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-APPEND-NoArguments.cmake b/Tests/RunCMake/list/TRANSFORM-APPEND-NoArguments.cmake
new file mode 100644
index 000000000..f1611870d
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-APPEND-NoArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist APPEND)
diff --git a/Tests/RunCMake/list/TRANSFORM-APPEND-TooManyArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-APPEND-TooManyArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-APPEND-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-APPEND-TooManyArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-APPEND-TooManyArguments-stderr.txt
new file mode 100644
index 000000000..aeb646daf
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-APPEND-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-APPEND-TooManyArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, 'one_too_many': unexpected argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-APPEND-TooManyArguments.cmake b/Tests/RunCMake/list/TRANSFORM-APPEND-TooManyArguments.cmake
new file mode 100644
index 000000000..8430a4c8c
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-APPEND-TooManyArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist APPEND delta one_too_many)
diff --git a/Tests/RunCMake/list/TRANSFORM-APPEND.cmake b/Tests/RunCMake/list/TRANSFORM-APPEND.cmake
new file mode 100644
index 000000000..96390882f
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-APPEND.cmake
@@ -0,0 +1,48 @@
+set(mylist alpha bravo charlie delta)
+
+list(TRANSFORM mylist APPEND "_A" OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha_A;bravo_A;charlie_A;delta_A")
+ message (FATAL_ERROR "TRANSFORM(APPEND) is \"${output}\", expected is \"alpha_A;bravo_A;charlie_A;delta_A\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist APPEND "_A" AT 1 3 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;bravo_A;charlie;delta_A")
+ message (FATAL_ERROR "TRANSFORM(APPEND) is \"${output}\", expected is \"alpha;bravo_A;charlie;delta_A\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist APPEND "_A" AT 1 -2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;bravo_A;charlie_A;delta")
+ message (FATAL_ERROR "TRANSFORM(APPEND) is \"${output}\", expected is \"alpha;bravo_A;charlie_A;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist APPEND "_A" FOR 1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;bravo_A;charlie_A;delta")
+ message (FATAL_ERROR "TRANSFORM(APPEND) is \"${output}\", expected is \"alpha;bravo_A;charlie_A;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist APPEND "_A" FOR 1 -1 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;bravo_A;charlie_A;delta_A")
+ message (FATAL_ERROR "TRANSFORM(APPEND) is \"${output}\", expected is \"alpha;bravo_A;charlie_A;delta_A\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist APPEND "_A" FOR 0 -1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha_A;bravo;charlie_A;delta")
+ message (FATAL_ERROR "TRANSFORM(APPEND) is \"${output}\", expected is \"alpha_A;bravo;charlie_A;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist APPEND "_A" REGEX "(r|t)a" OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;bravo_A;charlie;delta_A")
+ message (FATAL_ERROR "TRANSFORM(APPEND) is \"${output}\", expected is \"alpha;bravo_A;charlie;delta_A\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist APPEND "_A" REGEX "(r|t)a")
+if (NOT mylist STREQUAL "alpha;bravo_A;charlie;delta_A")
+ message (FATAL_ERROR "TRANSFORM(APPEND) is \"${mylist}\", expected is \"alpha;bravo_A;charlie;delta_A\"")
+endif()
diff --git a/Tests/RunCMake/list/TRANSFORM-GENEX_STRIP-TooManyArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-GENEX_STRIP-TooManyArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-GENEX_STRIP-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-GENEX_STRIP-TooManyArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-GENEX_STRIP-TooManyArguments-stderr.txt
new file mode 100644
index 000000000..6071a0079
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-GENEX_STRIP-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-GENEX_STRIP-TooManyArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, 'one_too_many': unexpected argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-GENEX_STRIP-TooManyArguments.cmake b/Tests/RunCMake/list/TRANSFORM-GENEX_STRIP-TooManyArguments.cmake
new file mode 100644
index 000000000..257d7fe8a
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-GENEX_STRIP-TooManyArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist GENEX_STRIP one_too_many)
diff --git a/Tests/RunCMake/list/TRANSFORM-GENEX_STRIP.cmake b/Tests/RunCMake/list/TRANSFORM-GENEX_STRIP.cmake
new file mode 100644
index 000000000..8045eef6d
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-GENEX_STRIP.cmake
@@ -0,0 +1,49 @@
+set(mylist one "$<1:two\;three>" four "$<TARGET_OBJECTS:some_target>")
+
+list(TRANSFORM mylist GENEX_STRIP OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "one;;four;")
+ message (FATAL_ERROR "TRANSFORM(GENEX_STRIP) is \"${output}\", expected is \"one;;four;\"")
+endif()
+
+set(mylist "one $<CONFIG>" "$<1:two\;three>-$<PLATFORM_ID>" "$<ANGLE-R>four" "$<TARGET_OBJECTS:some_target>")
+unset(output)
+list(TRANSFORM mylist GENEX_STRIP AT 1 3 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "one $<CONFIG>;-;$<ANGLE-R>four;")
+ message (FATAL_ERROR "TRANSFORM(GENEX_STRIP) is \"${output}\", expected is \"one $<CONFIG>;-;$<ANGLE-R>four;\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist GENEX_STRIP AT 1 -2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "one $<CONFIG>;-;four;$<TARGET_OBJECTS:some_target>")
+ message (FATAL_ERROR "TRANSFORM(GENEX_STRIP) is \"${output}\", expected is \"one $<CONFIG>;-;four;$<TARGET_OBJECTS:some_target>\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist GENEX_STRIP FOR 1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "one $<CONFIG>;-;four;$<TARGET_OBJECTS:some_target>")
+ message (FATAL_ERROR "TRANSFORM(GENEX_STRIP) is \"${output}\", expected is \"one $<CONFIG>;-;four;$<TARGET_OBJECTS:some_target>\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist GENEX_STRIP FOR 1 -1 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "one $<CONFIG>;-;four;")
+ message (FATAL_ERROR "TRANSFORM(GENEX_STRIP) is \"${output}\", expected is \"one $<CONFIG>;-;four;\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist GENEX_STRIP FOR 0 -1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "one ;$<1:two;three>-$<PLATFORM_ID>;four;$<TARGET_OBJECTS:some_target>")
+ message (FATAL_ERROR "TRANSFORM(GENEX_STRIP) is \"${output}\", expected is \"one ;$<1:two;three>-$<PLATFORM_ID>;four;$<TARGET_OBJECTS:some_target>\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist GENEX_STRIP REGEX "(D|G)>" OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "one ;-;$<ANGLE-R>four;$<TARGET_OBJECTS:some_target>")
+ message (FATAL_ERROR "TRANSFORM(GENEX_STRIP) is \"${output}\", expected is \"one ;-;$<ANGLE-R>four;$<TARGET_OBJECTS:some_target>\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist GENEX_STRIP REGEX "(D|G)>")
+if (NOT mylist STREQUAL "one ;-;$<ANGLE-R>four;$<TARGET_OBJECTS:some_target>")
+ message (FATAL_ERROR "TRANSFORM(GENEX_STRIP) is \"${mylist}\", expected is \"one ;-;$<ANGLE-R>four;$<TARGET_OBJECTS:some_target>\"")
+endif()
diff --git a/Tests/RunCMake/list/TRANSFORM-InvalidAction-result.txt b/Tests/RunCMake/list/TRANSFORM-InvalidAction-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-InvalidAction-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-InvalidAction-stderr.txt b/Tests/RunCMake/list/TRANSFORM-InvalidAction-stderr.txt
new file mode 100644
index 000000000..0fa45c927
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-InvalidAction-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-InvalidAction.cmake:2 \(list\):
+ list sub-command TRANSFORM, BAD_ACTION invalid action.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-InvalidAction.cmake b/Tests/RunCMake/list/TRANSFORM-InvalidAction.cmake
new file mode 100644
index 000000000..fb2cc30d9
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-InvalidAction.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist BAD_ACTION)
diff --git a/Tests/RunCMake/list/TRANSFORM-NoAction-result.txt b/Tests/RunCMake/list/TRANSFORM-NoAction-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-NoAction-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-NoAction-stderr.txt b/Tests/RunCMake/list/TRANSFORM-NoAction-stderr.txt
new file mode 100644
index 000000000..68e9e9db2
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-NoAction-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-NoAction.cmake:2 \(list\):
+ list sub-command TRANSFORM requires an action to be specified.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-NoAction.cmake b/Tests/RunCMake/list/TRANSFORM-NoAction.cmake
new file mode 100644
index 000000000..3690f1436
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-NoAction.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist)
diff --git a/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments-stderr.txt
new file mode 100644
index 000000000..b4f4e0614
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, OUTPUT_VARIABLE expects variable name argument.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments.cmake b/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments.cmake
new file mode 100644
index 000000000..acc409484
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-NoArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER OUTPUT_VARIABLE)
diff --git a/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments-stderr.txt
new file mode 100644
index 000000000..9a5834622
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, 'one_too_many': unexpected argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments.cmake b/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments.cmake
new file mode 100644
index 000000000..c4da86416
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Output-OUTPUT_VARIABLE-TooManyArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER OUTPUT_VARIABLE output one_too_many)
diff --git a/Tests/RunCMake/list/TRANSFORM-PREPEND-NoArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-PREPEND-NoArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-PREPEND-NoArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-PREPEND-NoArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-PREPEND-NoArguments-stderr.txt
new file mode 100644
index 000000000..413ce3021
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-PREPEND-NoArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-PREPEND-NoArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, action PREPEND expects 1 argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-PREPEND-NoArguments.cmake b/Tests/RunCMake/list/TRANSFORM-PREPEND-NoArguments.cmake
new file mode 100644
index 000000000..a8e453058
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-PREPEND-NoArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist PREPEND)
diff --git a/Tests/RunCMake/list/TRANSFORM-PREPEND-TooManyArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-PREPEND-TooManyArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-PREPEND-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-PREPEND-TooManyArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-PREPEND-TooManyArguments-stderr.txt
new file mode 100644
index 000000000..6ff1b89ad
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-PREPEND-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-PREPEND-TooManyArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, 'one_too_many': unexpected argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-PREPEND-TooManyArguments.cmake b/Tests/RunCMake/list/TRANSFORM-PREPEND-TooManyArguments.cmake
new file mode 100644
index 000000000..1f904ad66
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-PREPEND-TooManyArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist PREPEND delta one_too_many)
diff --git a/Tests/RunCMake/list/TRANSFORM-PREPEND.cmake b/Tests/RunCMake/list/TRANSFORM-PREPEND.cmake
new file mode 100644
index 000000000..55b8867d5
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-PREPEND.cmake
@@ -0,0 +1,48 @@
+set(mylist alpha bravo charlie delta)
+
+list(TRANSFORM mylist PREPEND "P_" OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "P_alpha;P_bravo;P_charlie;P_delta")
+ message (FATAL_ERROR "TRANSFORM(PREPEND) is \"${output}\", expected is \"P_alpha;P_bravo;P_charlie;P_delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist PREPEND "P_" AT 1 3 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;P_bravo;charlie;P_delta")
+ message (FATAL_ERROR "TRANSFORM(PREPEND) is \"${output}\", expected is \"alpha;P_bravo;charlie;P_delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist PREPEND "P_" AT 1 -2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;P_bravo;P_charlie;delta")
+ message (FATAL_ERROR "TRANSFORM(PREPEND) is \"${output}\", expected is \"alpha;P_bravo;P_charlie;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist PREPEND "P_" FOR 1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;P_bravo;P_charlie;delta")
+ message (FATAL_ERROR "TRANSFORM(PREPEND) is \"${output}\", expected is \"alpha;P_bravo;P_charlie;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist PREPEND "P_" FOR 1 -1 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;P_bravo;P_charlie;P_delta")
+ message (FATAL_ERROR "TRANSFORM(PREPEND) is \"${output}\", expected is \"alpha;P_bravo;P_charlie;P_delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist PREPEND "P_" FOR 0 -1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "P_alpha;bravo;P_charlie;delta")
+ message (FATAL_ERROR "TRANSFORM(PREPEND) is \"${output}\", expected is \"P_alpha;bravo;P_charlie;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist PREPEND "P_" REGEX "(r|t)a" OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;P_bravo;charlie;P_delta")
+ message (FATAL_ERROR "TRANSFORM(PREPEND) is \"${output}\", expected is \"alpha;P_bravo;charlie;P_delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist PREPEND "P_" REGEX "(r|t)a")
+if (NOT mylist STREQUAL "alpha;P_bravo;charlie;P_delta")
+ message (FATAL_ERROR "TRANSFORM(PREPEND) is \"${mylist}\", expected is \"alpha;P_bravo;charlie;P_delta\"")
+endif()
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidRegex-result.txt b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidRegex-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidRegex-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidRegex-stderr.txt b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidRegex-stderr.txt
new file mode 100644
index 000000000..334c96ecc
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidRegex-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at TRANSFORM-REPLACE-InvalidRegex.cmake:2 \(list\):
+ list sub-command TRANSFORM, action REPLACE: Failed to compile regex
+ "\^\(alpha\$".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidRegex.cmake b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidRegex.cmake
new file mode 100644
index 000000000..f440c3563
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidRegex.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist REPLACE "^(alpha$" "zulu")
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace-result.txt b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace1-result.txt b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace1-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace1-stderr.txt b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace1-stderr.txt
new file mode 100644
index 000000000..7671c8322
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace1-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at TRANSFORM-REPLACE-InvalidReplace1.cmake:2 \(list\):
+ list sub-command TRANSFORM, action REPLACE: replace-expression ends in a
+ backslash.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace1.cmake b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace1.cmake
new file mode 100644
index 000000000..35387f000
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace1.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist REPLACE "^alpha$" "zulu\\")
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace2-result.txt b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace2-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace2-stderr.txt b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace2-stderr.txt
new file mode 100644
index 000000000..e0aabd7c7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace2-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at TRANSFORM-REPLACE-InvalidReplace2.cmake:2 \(list\):
+ list sub-command TRANSFORM, action REPLACE: Unknown escape "\\z" in
+ replace-expression.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace2.cmake b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace2.cmake
new file mode 100644
index 000000000..2f1f2c7e1
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-InvalidReplace2.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist REPLACE "^alpha$" "\\zulu")
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-NoArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-REPLACE-NoArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-NoArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-NoArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-REPLACE-NoArguments-stderr.txt
new file mode 100644
index 000000000..3d39e7283
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-NoArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-REPLACE-NoArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, action REPLACE expects 2 argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-NoArguments.cmake b/Tests/RunCMake/list/TRANSFORM-REPLACE-NoArguments.cmake
new file mode 100644
index 000000000..b7b1e9dd1
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-NoArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist REPLACE)
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-NoEnoughArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-REPLACE-NoEnoughArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-NoEnoughArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-NoEnoughArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-REPLACE-NoEnoughArguments-stderr.txt
new file mode 100644
index 000000000..dc80f33a8
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-NoEnoughArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-REPLACE-NoEnoughArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, action REPLACE expects 2 argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-NoEnoughArguments.cmake b/Tests/RunCMake/list/TRANSFORM-REPLACE-NoEnoughArguments.cmake
new file mode 100644
index 000000000..1d418c00e
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-NoEnoughArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist REPLACE "^alpha$")
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-TooManyArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-REPLACE-TooManyArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-TooManyArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-REPLACE-TooManyArguments-stderr.txt
new file mode 100644
index 000000000..3d4e15a0e
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-REPLACE-TooManyArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, 'one_too_many': unexpected argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE-TooManyArguments.cmake b/Tests/RunCMake/list/TRANSFORM-REPLACE-TooManyArguments.cmake
new file mode 100644
index 000000000..baed0af27
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE-TooManyArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist REPLACE "^alpha$" "zulu" "one_too_many")
diff --git a/Tests/RunCMake/list/TRANSFORM-REPLACE.cmake b/Tests/RunCMake/list/TRANSFORM-REPLACE.cmake
new file mode 100644
index 000000000..256b1b8c6
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-REPLACE.cmake
@@ -0,0 +1,48 @@
+set(mylist alpha bravo charlie delta)
+
+list(TRANSFORM mylist REPLACE "(.+a)$" "\\1_\\1" OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha_alpha;bravo;charlie;delta_delta")
+ message (FATAL_ERROR "TRANSFORM(REPLACE) is \"${output}\", expected is \"alpha_alpha;bravo;charlie;delta_delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist REPLACE "(.+a)$" "\\1_\\1" AT 1 3 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;bravo;charlie;delta_delta")
+ message (FATAL_ERROR "TRANSFORM(REPLACE) is \"${output}\", expected is \"alpha;bravo;charlie;delta_delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist REPLACE "(.+e)$" "\\1_\\1" AT 1 -2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;bravo;charlie_charlie;delta")
+ message (FATAL_ERROR "TRANSFORM(REPLACE) is \"${output}\", expected is \"alpha;bravo;charlie_charlie;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist REPLACE "(.+e)$" "\\1_\\1" FOR 1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;bravo;charlie_charlie;delta")
+ message (FATAL_ERROR "TRANSFORM(REPLACE) is \"${output}\", expected is \"alpha;bravo;charlie_charlie;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist REPLACE "(.+a)$" "\\1_\\1" FOR 1 -1 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;bravo;charlie;delta_delta")
+ message (FATAL_ERROR "TRANSFORM(REPLACE) is \"${output}\", expected is \"alpha;bravo;charlie_A;delta_delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist REPLACE "(.+a)$" "\\1_\\1" FOR 0 -1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha_alpha;bravo;charlie;delta")
+ message (FATAL_ERROR "TRANSFORM(REPLACE) is \"${output}\", expected is \"alpha_alpha;bravo;charlie;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist REPLACE "(.+a)$" "\\1_\\1" REGEX "(r|t)a" OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;bravo;charlie;delta_delta")
+ message (FATAL_ERROR "TRANSFORM(REPLACE) is \"${output}\", expected is \"alpha;bravo;charlie;delta_delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist REPLACE "(.+a)$" "\\1_\\1" REGEX "(r|t)a")
+if (NOT mylist STREQUAL "alpha;bravo;charlie;delta_delta")
+ message (FATAL_ERROR "TRANSFORM(REPLACE) is \"${mylist}\", expected is \"alpha;bravo;charlie;delta_delta\"")
+endif()
diff --git a/Tests/RunCMake/list/TRANSFORM-STRIP-TooManyArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-STRIP-TooManyArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-STRIP-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-STRIP-TooManyArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-STRIP-TooManyArguments-stderr.txt
new file mode 100644
index 000000000..534f940a5
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-STRIP-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-STRIP-TooManyArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, 'one_too_many': unexpected argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-STRIP-TooManyArguments.cmake b/Tests/RunCMake/list/TRANSFORM-STRIP-TooManyArguments.cmake
new file mode 100644
index 000000000..c6a821314
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-STRIP-TooManyArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist STRIP one_too_many)
diff --git a/Tests/RunCMake/list/TRANSFORM-STRIP.cmake b/Tests/RunCMake/list/TRANSFORM-STRIP.cmake
new file mode 100644
index 000000000..366c63a83
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-STRIP.cmake
@@ -0,0 +1,49 @@
+set(mylist " alpha" "bravo " " charlie " delta)
+
+list(TRANSFORM mylist STRIP OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;bravo;charlie;delta")
+ message (FATAL_ERROR "TRANSFORM(STRIP) is \"${output}\", expected is \"alpha;bravo;charlie;delta\"")
+endif()
+
+set(mylist " alpha" "bravo " " charlie " "delta ")
+unset(output)
+list(TRANSFORM mylist STRIP AT 1 3 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL " alpha;bravo; charlie ;delta")
+ message (FATAL_ERROR "TRANSFORM(STRIP) is \"${output}\", expected is \" alpha;bravo; charlie ;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist STRIP AT 1 -2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL " alpha;bravo;charlie;delta ")
+ message (FATAL_ERROR "TRANSFORM(STRIP) is \"${output}\", expected is \" alpha;bravo;charlie;delta \"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist STRIP FOR 1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL " alpha;bravo;charlie;delta ")
+ message (FATAL_ERROR "TRANSFORM(STRIP) is \"${output}\", expected is \" alpha;bravo;charlie;delta \"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist STRIP FOR 1 -1 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL " alpha;bravo;charlie;delta")
+ message (FATAL_ERROR "TRANSFORM(STRIP) is \"${output}\", expected is \" alpha;bravo;charlie;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist STRIP FOR 0 -1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;bravo ;charlie;delta ")
+ message (FATAL_ERROR "TRANSFORM(STRIP) is \"${output}\", expected is \"alpha;bravo ;charlie;delta \"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist STRIP REGEX "(r|t)a" OUTPUT_VARIABLE output)
+if (NOT output STREQUAL " alpha;bravo; charlie ;delta")
+ message (FATAL_ERROR "TRANSFORM(STRIP) is \"${output}\", expected is \" alpha;bravo; charlie ;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist STRIP REGEX "(r|t)a")
+if (NOT mylist STREQUAL " alpha;bravo; charlie ;delta")
+ message (FATAL_ERROR "TRANSFORM(STRIP) is \"${mylist}\", expected is \" alpha;bravo; charlie ;delta\"")
+endif()
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-AT-BadArgument-result.txt b/Tests/RunCMake/list/TRANSFORM-Selector-AT-BadArgument-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-AT-BadArgument-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-AT-BadArgument-stderr.txt b/Tests/RunCMake/list/TRANSFORM-Selector-AT-BadArgument-stderr.txt
new file mode 100644
index 000000000..cec520f2e
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-AT-BadArgument-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-Selector-AT-BadArgument.cmake:2 \(list\):
+ list sub-command TRANSFORM, '1x 2': unexpected argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-AT-BadArgument.cmake b/Tests/RunCMake/list/TRANSFORM-Selector-AT-BadArgument.cmake
new file mode 100644
index 000000000..f61b86bc2
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-AT-BadArgument.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER AT 0 1x 2)
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-AT-InvalidIndex-result.txt b/Tests/RunCMake/list/TRANSFORM-Selector-AT-InvalidIndex-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-AT-InvalidIndex-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-AT-InvalidIndex-stderr.txt b/Tests/RunCMake/list/TRANSFORM-Selector-AT-InvalidIndex-stderr.txt
new file mode 100644
index 000000000..7e2898b3a
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-AT-InvalidIndex-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-Selector-AT-InvalidIndex.cmake:2 \(list\):
+ list sub-command TRANSFORM, selector AT, index: 3 out of range \(-3, 2\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-AT-InvalidIndex.cmake b/Tests/RunCMake/list/TRANSFORM-Selector-AT-InvalidIndex.cmake
new file mode 100644
index 000000000..d33586c36
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-AT-InvalidIndex.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER AT 0 3 2)
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-AT-NoArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-Selector-AT-NoArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-AT-NoArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-AT-NoArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-Selector-AT-NoArguments-stderr.txt
new file mode 100644
index 000000000..eaf5281db
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-AT-NoArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-Selector-AT-NoArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, selector AT expects at least one numeric value.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-AT-NoArguments.cmake b/Tests/RunCMake/list/TRANSFORM-Selector-AT-NoArguments.cmake
new file mode 100644
index 000000000..052b79bbe
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-AT-NoArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER AT)
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-BadArgument-result.txt b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-BadArgument-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-BadArgument-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-BadArgument-stderr.txt b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-BadArgument-stderr.txt
new file mode 100644
index 000000000..a0f701f01
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-BadArgument-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at TRANSFORM-Selector-FOR-BadArgument.cmake:2 \(list\):
+ list sub-command TRANSFORM, selector FOR expects, at least, two numeric
+ values.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-BadArgument.cmake b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-BadArgument.cmake
new file mode 100644
index 000000000..55527be21
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-BadArgument.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER FOR 0 1x 2)
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-InvalidIndex-result.txt b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-InvalidIndex-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-InvalidIndex-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-InvalidIndex-stderr.txt b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-InvalidIndex-stderr.txt
new file mode 100644
index 000000000..c50cc0a61
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-InvalidIndex-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-Selector-FOR-InvalidIndex.cmake:2 \(list\):
+ list sub-command TRANSFORM, selector FOR, index: 6 out of range \(-3, 2\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-InvalidIndex.cmake b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-InvalidIndex.cmake
new file mode 100644
index 000000000..6e2374e31
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-InvalidIndex.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER FOR 0 6 2)
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoArguments-stderr.txt
new file mode 100644
index 000000000..5881b67b4
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-Selector-FOR-NoArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, selector FOR expects, at least, two arguments.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoArguments.cmake b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoArguments.cmake
new file mode 100644
index 000000000..4902cc9a7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER FOR)
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoEnoughArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoEnoughArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoEnoughArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoEnoughArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoEnoughArguments-stderr.txt
new file mode 100644
index 000000000..b1081d98d
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoEnoughArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-Selector-FOR-NoEnoughArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, selector FOR expects, at least, two arguments.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoEnoughArguments.cmake b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoEnoughArguments.cmake
new file mode 100644
index 000000000..81417de57
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-NoEnoughArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER FOR 1)
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-TooManyArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-TooManyArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-TooManyArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-TooManyArguments-stderr.txt
new file mode 100644
index 000000000..2221cb3cd
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-Selector-FOR-TooManyArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, '3': unexpected argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-FOR-TooManyArguments.cmake b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-TooManyArguments.cmake
new file mode 100644
index 000000000..80917d65a
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-FOR-TooManyArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER FOR 0 1 2 3)
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-InvalidRegex-result.txt b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-InvalidRegex-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-InvalidRegex-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-InvalidRegex-stderr.txt b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-InvalidRegex-stderr.txt
new file mode 100644
index 000000000..31ba93986
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-InvalidRegex-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at TRANSFORM-Selector-REGEX-InvalidRegex.cmake:2 \(list\):
+ list sub-command TRANSFORM, selector REGEX failed to compile regex
+ "\^\(alpha\$".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-InvalidRegex.cmake b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-InvalidRegex.cmake
new file mode 100644
index 000000000..56e202bb4
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-InvalidRegex.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER REGEX "^(alpha$")
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-NoArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-NoArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-NoArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-NoArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-NoArguments-stderr.txt
new file mode 100644
index 000000000..278478555
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-NoArguments-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at TRANSFORM-Selector-REGEX-NoArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, selector REGEX expects 'regular expression'
+ argument.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-NoArguments.cmake b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-NoArguments.cmake
new file mode 100644
index 000000000..f199d0e12
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-NoArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER REGEX)
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-TooManyArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-TooManyArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-TooManyArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-TooManyArguments-stderr.txt
new file mode 100644
index 000000000..db5b1ffb5
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-Selector-REGEX-TooManyArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, 'one_too_many': unexpected argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-TooManyArguments.cmake b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-TooManyArguments.cmake
new file mode 100644
index 000000000..4aa1619d7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-Selector-REGEX-TooManyArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER REGEX "^alpha$" "one_too_many")
diff --git a/Tests/RunCMake/list/TRANSFORM-TOLOWER-TooManyArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-TOLOWER-TooManyArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-TOLOWER-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-TOLOWER-TooManyArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-TOLOWER-TooManyArguments-stderr.txt
new file mode 100644
index 000000000..90248aec3
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-TOLOWER-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-TOLOWER-TooManyArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, 'one_too_many': unexpected argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-TOLOWER-TooManyArguments.cmake b/Tests/RunCMake/list/TRANSFORM-TOLOWER-TooManyArguments.cmake
new file mode 100644
index 000000000..1758e19e4
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-TOLOWER-TooManyArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOLOWER one_too_many)
diff --git a/Tests/RunCMake/list/TRANSFORM-TOLOWER.cmake b/Tests/RunCMake/list/TRANSFORM-TOLOWER.cmake
new file mode 100644
index 000000000..a2d73480c
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-TOLOWER.cmake
@@ -0,0 +1,48 @@
+set(mylist ALPHA BRAVO CHARLIE DELTA)
+
+list(TRANSFORM mylist TOLOWER OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;bravo;charlie;delta")
+ message (FATAL_ERROR "TRANSFORM(TOLOWER) is \"${output}\", expected is \"alpha;bravo;charlie;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOLOWER AT 1 3 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "ALPHA;bravo;CHARLIE;delta")
+ message (FATAL_ERROR "TRANSFORM(TOLOWER) is \"${output}\", expected is \"ALPHA;bravo;CHARLIE;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOLOWER AT 1 -2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "ALPHA;bravo;charlie;DELTA")
+ message (FATAL_ERROR "TRANSFORM(TOLOWER) is \"${output}\", expected is \"ALPHA;bravo;charlie;DELTA\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOLOWER FOR 1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "ALPHA;bravo;charlie;DELTA")
+ message (FATAL_ERROR "TRANSFORM(TOLOWER) is \"${output}\", expected is \"ALPHA;bravo;charlie;DELTA\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOLOWER FOR 1 -1 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "ALPHA;bravo;charlie;delta")
+ message (FATAL_ERROR "TRANSFORM(TOLOWER) is \"${output}\", expected is \"ALPHA;bravo;charlie;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOLOWER FOR 0 -1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;BRAVO;charlie;DELTA")
+ message (FATAL_ERROR "TRANSFORM(TOLOWER) is \"${output}\", expected is \"alpha;BRAVO;charlie;DELTA\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOLOWER REGEX "(R|T)A" OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "ALPHA;bravo;CHARLIE;delta")
+ message (FATAL_ERROR "TRANSFORM(TOLOWER) is \"${output}\", expected is \"ALPHA;bravo;CHARLIE;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOLOWER REGEX "(R|T)A")
+if (NOT mylist STREQUAL "ALPHA;bravo;CHARLIE;delta")
+ message (FATAL_ERROR "TRANSFORM(TOLOWER) is \"${mylist}\", expected is \"ALPHA;bravo;CHARLIE;delta\"")
+endif()
diff --git a/Tests/RunCMake/list/TRANSFORM-TOUPPER-TooManyArguments-result.txt b/Tests/RunCMake/list/TRANSFORM-TOUPPER-TooManyArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-TOUPPER-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/list/TRANSFORM-TOUPPER-TooManyArguments-stderr.txt b/Tests/RunCMake/list/TRANSFORM-TOUPPER-TooManyArguments-stderr.txt
new file mode 100644
index 000000000..9da241ba8
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-TOUPPER-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at TRANSFORM-TOUPPER-TooManyArguments.cmake:2 \(list\):
+ list sub-command TRANSFORM, 'one_too_many': unexpected argument\(s\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/list/TRANSFORM-TOUPPER-TooManyArguments.cmake b/Tests/RunCMake/list/TRANSFORM-TOUPPER-TooManyArguments.cmake
new file mode 100644
index 000000000..58d6a8cd7
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-TOUPPER-TooManyArguments.cmake
@@ -0,0 +1,2 @@
+set(mylist alpha bravo charlie)
+list(TRANSFORM mylist TOUPPER one_too_many)
diff --git a/Tests/RunCMake/list/TRANSFORM-TOUPPER.cmake b/Tests/RunCMake/list/TRANSFORM-TOUPPER.cmake
new file mode 100644
index 000000000..5b1fcb66e
--- /dev/null
+++ b/Tests/RunCMake/list/TRANSFORM-TOUPPER.cmake
@@ -0,0 +1,48 @@
+set(mylist alpha bravo charlie delta)
+
+list(TRANSFORM mylist TOUPPER OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "ALPHA;BRAVO;CHARLIE;DELTA")
+ message (FATAL_ERROR "TRANSFORM(TOUPPER) is \"${output}\", expected is \"ALPHA;BRAVO;CHARLIE;DELTA\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOUPPER AT 1 3 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;BRAVO;charlie;DELTA")
+ message (FATAL_ERROR "TRANSFORM(TOUPPER) is \"${output}\", expected is \"alpha;BRAVO;charlie;DELTA\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOUPPER AT 1 -2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;BRAVO;CHARLIE;delta")
+ message (FATAL_ERROR "TRANSFORM(TOUPPER) is \"${output}\", expected is \"alpha;BRAVO;CHARLIE;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOUPPER FOR 1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;BRAVO;CHARLIE;delta")
+ message (FATAL_ERROR "TRANSFORM(TOUPPER) is \"${output}\", expected is \"alpha;BRAVO;CHARLIE;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOUPPER FOR 1 -1 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;BRAVO;CHARLIE;DELTA")
+ message (FATAL_ERROR "TRANSFORM(TOUPPER) is \"${output}\", expected is \"alpha;BRAVO;CHARLIE;DELTA\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOUPPER FOR 0 -1 2 OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "ALPHA;bravo;CHARLIE;delta")
+ message (FATAL_ERROR "TRANSFORM(TOUPPER) is \"${output}\", expected is \"ALPHA;bravo;CHARLIE;delta\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOUPPER REGEX "(r|t)a" OUTPUT_VARIABLE output)
+if (NOT output STREQUAL "alpha;BRAVO;charlie;DELTA")
+ message (FATAL_ERROR "TRANSFORM(TOUPPER) is \"${output}\", expected is \"alpha;BRAVO;charlie;DELTA\"")
+endif()
+
+unset(output)
+list(TRANSFORM mylist TOUPPER REGEX "(r|t)a")
+if (NOT mylist STREQUAL "alpha;BRAVO;charlie;DELTA")
+ message (FATAL_ERROR "TRANSFORM(TOUPPER) is \"${mylist}\", expected is \"alpha;BRAVO;charlie;DELTA\"")
+endif()
diff --git a/Tests/RunCMake/math/CMakeLists.txt b/Tests/RunCMake/math/CMakeLists.txt
new file mode 100644
index 000000000..12cd3c775
--- /dev/null
+++ b/Tests/RunCMake/math/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.4)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/math/MATH-DivideByZero-result.txt b/Tests/RunCMake/math/MATH-DivideByZero-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-DivideByZero-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/math/MATH-DivideByZero-stderr.txt b/Tests/RunCMake/math/MATH-DivideByZero-stderr.txt
new file mode 100644
index 000000000..66ad6332f
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-DivideByZero-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at MATH-DivideByZero.cmake:1 \(math\):
+ math cannot evaluate the expression: "100/0": divide by zero.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/math/MATH-DivideByZero.cmake b/Tests/RunCMake/math/MATH-DivideByZero.cmake
new file mode 100644
index 000000000..3ac161e11
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-DivideByZero.cmake
@@ -0,0 +1 @@
+math(EXPR var "100/0")
diff --git a/Tests/RunCMake/math/MATH-DoubleOption-result.txt b/Tests/RunCMake/math/MATH-DoubleOption-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-DoubleOption-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/math/MATH-DoubleOption-stderr.txt b/Tests/RunCMake/math/MATH-DoubleOption-stderr.txt
new file mode 100644
index 000000000..767a060fc
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-DoubleOption-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at MATH-DoubleOption.cmake:1 \(math\):
+ math EXPR called with incorrect arguments.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/math/MATH-DoubleOption.cmake b/Tests/RunCMake/math/MATH-DoubleOption.cmake
new file mode 100644
index 000000000..7bcb78ec2
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-DoubleOption.cmake
@@ -0,0 +1 @@
+math(EXPR var "10*10" OUTPUT_FORMAT DECIMAL OUTPUT_FORMAT HEXADECIMAL)
diff --git a/Tests/RunCMake/math/MATH-InvalidExpression-result.txt b/Tests/RunCMake/math/MATH-InvalidExpression-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-InvalidExpression-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/math/MATH-InvalidExpression-stderr.txt b/Tests/RunCMake/math/MATH-InvalidExpression-stderr.txt
new file mode 100644
index 000000000..22226f2ae
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-InvalidExpression-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at MATH-InvalidExpression.cmake:1 \(math\):
+ math cannot parse the expression: "INVALID": syntax error, unexpected \$end
+ \(7\).
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/math/MATH-InvalidExpression.cmake b/Tests/RunCMake/math/MATH-InvalidExpression.cmake
new file mode 100644
index 000000000..6e37128d7
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-InvalidExpression.cmake
@@ -0,0 +1 @@
+math(EXPR var "INVALID")
diff --git a/Tests/RunCMake/math/MATH-ToleratedExpression-stderr.txt b/Tests/RunCMake/math/MATH-ToleratedExpression-stderr.txt
new file mode 100644
index 000000000..732ce6f16
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-ToleratedExpression-stderr.txt
@@ -0,0 +1,8 @@
+^CMake Warning \(dev\) at MATH-ToleratedExpression.cmake:1 \(math\):
+ Unexpected character in expression at position 1: '
+
+ Unexpected character in expression at position 7: '
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/math/MATH-ToleratedExpression.cmake b/Tests/RunCMake/math/MATH-ToleratedExpression.cmake
new file mode 100644
index 000000000..d1be218c8
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-ToleratedExpression.cmake
@@ -0,0 +1,4 @@
+math(EXPR var "'2*1-1'")
+if(NOT var EQUAL 1)
+ message(FATAL_ERROR "Expression did not evaluate to 1")
+endif()
diff --git a/Tests/RunCMake/math/MATH-TooManyArguments-result.txt b/Tests/RunCMake/math/MATH-TooManyArguments-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-TooManyArguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/math/MATH-TooManyArguments-stderr.txt b/Tests/RunCMake/math/MATH-TooManyArguments-stderr.txt
new file mode 100644
index 000000000..fdcfecf7f
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-TooManyArguments-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at MATH-TooManyArguments.cmake:1 \(math\):
+ math EXPR called with incorrect arguments.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/math/MATH-TooManyArguments.cmake b/Tests/RunCMake/math/MATH-TooManyArguments.cmake
new file mode 100644
index 000000000..969dc80f0
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-TooManyArguments.cmake
@@ -0,0 +1 @@
+math(EXPR var "10*10" OUTPUT_FORMAT DECIMAL OUTPUT_FORMAT )
diff --git a/Tests/RunCMake/math/MATH-WrongArgument-result.txt b/Tests/RunCMake/math/MATH-WrongArgument-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-WrongArgument-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/math/MATH-WrongArgument-stderr.txt b/Tests/RunCMake/math/MATH-WrongArgument-stderr.txt
new file mode 100644
index 000000000..bbe54bf1f
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-WrongArgument-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at MATH-WrongArgument.cmake:1 \(math\):
+ math sub-command EXPR option "OUT" is unknown.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/math/MATH-WrongArgument.cmake b/Tests/RunCMake/math/MATH-WrongArgument.cmake
new file mode 100644
index 000000000..fb6d2e725
--- /dev/null
+++ b/Tests/RunCMake/math/MATH-WrongArgument.cmake
@@ -0,0 +1 @@
+math(EXPR var "10*10" OUT HEX )
diff --git a/Tests/RunCMake/math/MATH.cmake b/Tests/RunCMake/math/MATH.cmake
new file mode 100644
index 000000000..a5f50cd90
--- /dev/null
+++ b/Tests/RunCMake/math/MATH.cmake
@@ -0,0 +1,12 @@
+macro(math_test expression expected)
+ math(EXPR evaluated ${expression} ${ARGN})
+ if (NOT evaluated STREQUAL ${expected})
+ message(FATAL_ERROR "wrong math result: ${evaluated} != ${expected}")
+ endif ()
+endmacro()
+
+
+math_test("100 * 10" 1000)
+math_test("100 * 10" 1000 OUTPUT_FORMAT DECIMAL)
+math_test("100 * 0xA" 1000 OUTPUT_FORMAT DECIMAL)
+math_test("100 * 0xA" 0x3e8 OUTPUT_FORMAT HEXADECIMAL)
diff --git a/Tests/RunCMake/math/RunCMakeTest.cmake b/Tests/RunCMake/math/RunCMakeTest.cmake
new file mode 100644
index 000000000..a4d5c31df
--- /dev/null
+++ b/Tests/RunCMake/math/RunCMakeTest.cmake
@@ -0,0 +1,9 @@
+include(RunCMake)
+
+run_cmake(MATH)
+run_cmake(MATH-WrongArgument)
+run_cmake(MATH-DoubleOption)
+run_cmake(MATH-TooManyArguments)
+run_cmake(MATH-InvalidExpression)
+run_cmake(MATH-ToleratedExpression)
+run_cmake(MATH-DivideByZero)
diff --git a/Tests/RunCMake/message/RunCMakeTest.cmake b/Tests/RunCMake/message/RunCMakeTest.cmake
index 2346c8675..681839d84 100644
--- a/Tests/RunCMake/message/RunCMakeTest.cmake
+++ b/Tests/RunCMake/message/RunCMakeTest.cmake
@@ -5,8 +5,70 @@ run_cmake(nomessage)
run_cmake(message-internal-warning)
run_cmake(nomessage-internal-warning)
run_cmake(warnmessage)
+
+# Have to explicitly give the command for the working dir to be honoured
+set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY /)
+run_cmake_command(
+ warnmessage-rootdir
+ ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/warnmessage-rootdir.cmake
+ )
+unset(RunCMake_TEST_COMMAND_WORKING_DIRECTORY)
+
# message command sets fatal occurred flag, so check each type of error
-# seperately
+# separately
run_cmake(errormessage_deprecated)
run_cmake(errormessage_dev)
+
+foreach(opt IN ITEMS loglevel log-level)
+ run_cmake_command(
+ message-${opt}-invalid
+ ${CMAKE_COMMAND} --${opt}=blah -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+
+ # Checking various combinations of `message(...)` and log levels `WARNING` to `TRACE`
+ # - no CLI option -> `WARNING` to `STATUS` output
+ run_cmake_command(
+ message-${opt}-default
+ ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+ # - Only `WARNING` output
+ run_cmake_command(
+ message-${opt}-warning
+ ${CMAKE_COMMAND} --${opt}=warning -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+ # - Only `WARNING` and `NOTICE` output
+ run_cmake_command(
+ message-${opt}-notice
+ ${CMAKE_COMMAND} --${opt}=notice -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+ # - `WARNING` to `STATUS` output
+ run_cmake_command(
+ message-${opt}-status
+ ${CMAKE_COMMAND} --${opt}=status -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+ # - `WARNING` to `VERBOSE` output
+ run_cmake_command(
+ message-${opt}-verbose
+ ${CMAKE_COMMAND} --${opt}=verbose -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+ # - `WARNING` to `DEBUG` output
+ run_cmake_command(
+ message-${opt}-debug
+ ${CMAKE_COMMAND} --${opt}=debug -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+ # - `WARNING` to `TRACE` output
+ run_cmake_command(
+ message-${opt}-trace
+ ${CMAKE_COMMAND} --${opt}=trace -P ${RunCMake_SOURCE_DIR}/message-all-loglevels.cmake
+ )
+endforeach()
+
+run_cmake_command(
+ message-indent
+ ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/message-indent.cmake
+ )
+run_cmake_command(
+ message-indent-multiline
+ ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/message-indent-multiline.cmake
+ )
diff --git a/Tests/RunCMake/message/message-all-loglevels.cmake b/Tests/RunCMake/message/message-all-loglevels.cmake
new file mode 100644
index 000000000..f8d884154
--- /dev/null
+++ b/Tests/RunCMake/message/message-all-loglevels.cmake
@@ -0,0 +1,10 @@
+# Produce a message for everything except FATAL_ERROR and SEND_ERROR
+message(DEPRECATION "Deprecation warning")
+message(AUTHOR_WARNING "Author warning message")
+message(WARNING "Warning message")
+message("Default NOTICE message")
+message(NOTICE "NOTICE message")
+message(STATUS "STATUS message")
+message(VERBOSE "VERBOSE message")
+message(DEBUG "DEBUG message")
+message(TRACE "TRACE message")
diff --git a/Tests/RunCMake/message/message-indent-multiline-stderr.txt b/Tests/RunCMake/message/message-indent-multiline-stderr.txt
new file mode 100644
index 000000000..5853a31d3
--- /dev/null
+++ b/Tests/RunCMake/message/message-indent-multiline-stderr.txt
@@ -0,0 +1,3 @@
+ >This is
+ >the multiline
+ >message
diff --git a/Tests/RunCMake/message/message-indent-multiline-stdout.txt b/Tests/RunCMake/message/message-indent-multiline-stdout.txt
new file mode 100644
index 000000000..ae0c72e79
--- /dev/null
+++ b/Tests/RunCMake/message/message-indent-multiline-stdout.txt
@@ -0,0 +1,8 @@
+-- >This is
+ >the multiline
+ >message
+ >
+ >
+-- >This is
+ >the multiline
+ >message
diff --git a/Tests/RunCMake/message/message-indent-multiline.cmake b/Tests/RunCMake/message/message-indent-multiline.cmake
new file mode 100644
index 000000000..0f789bfce
--- /dev/null
+++ b/Tests/RunCMake/message/message-indent-multiline.cmake
@@ -0,0 +1,13 @@
+# NOTE Use non-space indent string, to check indentation
+# of line endings and "empty" lines.
+# ALERT Do not put any space characters after the non-space!
+list(APPEND CMAKE_MESSAGE_INDENT " >")
+set(msg [[This is
+the multiline
+message]]) # No `\n` at the end!
+# NOTE Two empty lines after the text
+message(STATUS "${msg}\n\n")
+message(STATUS "${msg}")
+# This is just to make sure NOTICE messages are also get indented:
+# https://gitlab.kitware.com/cmake/cmake/issues/19418#note_588011
+message(NOTICE "${msg}")
diff --git a/Tests/RunCMake/message/message-indent-stdout.txt b/Tests/RunCMake/message/message-indent-stdout.txt
new file mode 100644
index 000000000..b2c3c60d1
--- /dev/null
+++ b/Tests/RunCMake/message/message-indent-stdout.txt
@@ -0,0 +1,13 @@
+-- COUNTING:
+-- COUNTING_ENGLISH:
+-- one
+-- two
+-- three
+-- four
+-- five
+-- COUNTING_BAHASA:
+-- satu
+-- dua
+-- tiga
+-- empat
+-- lima
diff --git a/Tests/RunCMake/message/message-indent.cmake b/Tests/RunCMake/message/message-indent.cmake
new file mode 100644
index 000000000..c07ff45eb
--- /dev/null
+++ b/Tests/RunCMake/message/message-indent.cmake
@@ -0,0 +1,19 @@
+function(debug_list LIST_VAR)
+ message(STATUS "${LIST_VAR}:")
+ list(APPEND CMAKE_MESSAGE_INDENT " ")
+ foreach(_item IN LISTS ${LIST_VAR})
+ list(LENGTH ${_item} _item_len)
+ if(_item_len GREATER 1)
+ debug_list(${_item})
+ else()
+ message(STATUS "${_item}")
+ endif()
+ endforeach()
+endfunction()
+
+list(APPEND COUNTING_ENGLISH one two three four five)
+list(APPEND COUNTING_BAHASA satu dua tiga empat lima)
+
+list(APPEND COUNTING COUNTING_ENGLISH COUNTING_BAHASA)
+
+debug_list(COUNTING)
diff --git a/Tests/RunCMake/message/message-log-level-debug-stderr.txt b/Tests/RunCMake/message/message-log-level-debug-stderr.txt
new file mode 100644
index 000000000..efec736fe
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-debug-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-log-level-debug-stdout.txt b/Tests/RunCMake/message/message-log-level-debug-stdout.txt
new file mode 100644
index 000000000..145213703
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-debug-stdout.txt
@@ -0,0 +1,3 @@
+-- STATUS message
+-- VERBOSE message
+-- DEBUG message
diff --git a/Tests/RunCMake/message/message-log-level-default-stderr.txt b/Tests/RunCMake/message/message-log-level-default-stderr.txt
new file mode 100644
index 000000000..efec736fe
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-default-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-log-level-default-stdout.txt b/Tests/RunCMake/message/message-log-level-default-stdout.txt
new file mode 100644
index 000000000..809f4cc4a
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-default-stdout.txt
@@ -0,0 +1 @@
+-- STATUS message
diff --git a/Tests/RunCMake/message/message-log-level-invalid-result.txt b/Tests/RunCMake/message/message-log-level-invalid-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-invalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/message/message-log-level-invalid-stderr.txt b/Tests/RunCMake/message/message-log-level-invalid-stderr.txt
new file mode 100644
index 000000000..a166bbcca
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-invalid-stderr.txt
@@ -0,0 +1 @@
+CMake Error: Invalid level specified for --log-level
diff --git a/Tests/RunCMake/message/message-log-level-notice-stderr.txt b/Tests/RunCMake/message/message-log-level-notice-stderr.txt
new file mode 100644
index 000000000..efec736fe
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-notice-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-log-level-status-stderr.txt b/Tests/RunCMake/message/message-log-level-status-stderr.txt
new file mode 100644
index 000000000..efec736fe
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-status-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-log-level-status-stdout.txt b/Tests/RunCMake/message/message-log-level-status-stdout.txt
new file mode 100644
index 000000000..809f4cc4a
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-status-stdout.txt
@@ -0,0 +1 @@
+-- STATUS message
diff --git a/Tests/RunCMake/message/message-log-level-trace-stderr.txt b/Tests/RunCMake/message/message-log-level-trace-stderr.txt
new file mode 100644
index 000000000..efec736fe
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-trace-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-log-level-trace-stdout.txt b/Tests/RunCMake/message/message-log-level-trace-stdout.txt
new file mode 100644
index 000000000..1cfce6f11
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-trace-stdout.txt
@@ -0,0 +1,4 @@
+-- STATUS message
+-- VERBOSE message
+-- DEBUG message
+-- TRACE message
diff --git a/Tests/RunCMake/message/message-log-level-verbose-stderr.txt b/Tests/RunCMake/message/message-log-level-verbose-stderr.txt
new file mode 100644
index 000000000..efec736fe
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-verbose-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-log-level-verbose-stdout.txt b/Tests/RunCMake/message/message-log-level-verbose-stdout.txt
new file mode 100644
index 000000000..c15d43fc4
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-verbose-stdout.txt
@@ -0,0 +1,2 @@
+-- STATUS message
+-- VERBOSE message
diff --git a/Tests/RunCMake/message/message-log-level-warning-stderr.txt b/Tests/RunCMake/message/message-log-level-warning-stderr.txt
new file mode 100644
index 000000000..c721b063c
--- /dev/null
+++ b/Tests/RunCMake/message/message-log-level-warning-stderr.txt
@@ -0,0 +1,9 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message$
diff --git a/Tests/RunCMake/message/message-loglevel-debug-stderr.txt b/Tests/RunCMake/message/message-loglevel-debug-stderr.txt
new file mode 100644
index 000000000..efec736fe
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-debug-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-loglevel-debug-stdout.txt b/Tests/RunCMake/message/message-loglevel-debug-stdout.txt
new file mode 100644
index 000000000..145213703
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-debug-stdout.txt
@@ -0,0 +1,3 @@
+-- STATUS message
+-- VERBOSE message
+-- DEBUG message
diff --git a/Tests/RunCMake/message/message-loglevel-default-stderr.txt b/Tests/RunCMake/message/message-loglevel-default-stderr.txt
new file mode 100644
index 000000000..efec736fe
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-default-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-loglevel-default-stdout.txt b/Tests/RunCMake/message/message-loglevel-default-stdout.txt
new file mode 100644
index 000000000..809f4cc4a
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-default-stdout.txt
@@ -0,0 +1 @@
+-- STATUS message
diff --git a/Tests/RunCMake/message/message-loglevel-invalid-result.txt b/Tests/RunCMake/message/message-loglevel-invalid-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-invalid-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/message/message-loglevel-invalid-stderr.txt b/Tests/RunCMake/message/message-loglevel-invalid-stderr.txt
new file mode 100644
index 000000000..f54d0f844
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-invalid-stderr.txt
@@ -0,0 +1 @@
+CMake Error: Invalid level specified for --loglevel
diff --git a/Tests/RunCMake/message/message-loglevel-notice-stderr.txt b/Tests/RunCMake/message/message-loglevel-notice-stderr.txt
new file mode 100644
index 000000000..efec736fe
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-notice-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-loglevel-status-stderr.txt b/Tests/RunCMake/message/message-loglevel-status-stderr.txt
new file mode 100644
index 000000000..efec736fe
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-status-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-loglevel-status-stdout.txt b/Tests/RunCMake/message/message-loglevel-status-stdout.txt
new file mode 100644
index 000000000..809f4cc4a
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-status-stdout.txt
@@ -0,0 +1 @@
+-- STATUS message
diff --git a/Tests/RunCMake/message/message-loglevel-trace-stderr.txt b/Tests/RunCMake/message/message-loglevel-trace-stderr.txt
new file mode 100644
index 000000000..efec736fe
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-trace-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-loglevel-trace-stdout.txt b/Tests/RunCMake/message/message-loglevel-trace-stdout.txt
new file mode 100644
index 000000000..1cfce6f11
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-trace-stdout.txt
@@ -0,0 +1,4 @@
+-- STATUS message
+-- VERBOSE message
+-- DEBUG message
+-- TRACE message
diff --git a/Tests/RunCMake/message/message-loglevel-verbose-stderr.txt b/Tests/RunCMake/message/message-loglevel-verbose-stderr.txt
new file mode 100644
index 000000000..efec736fe
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-verbose-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message
++
+Default NOTICE message
+NOTICE message$
diff --git a/Tests/RunCMake/message/message-loglevel-verbose-stdout.txt b/Tests/RunCMake/message/message-loglevel-verbose-stdout.txt
new file mode 100644
index 000000000..c15d43fc4
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-verbose-stdout.txt
@@ -0,0 +1,2 @@
+-- STATUS message
+-- VERBOSE message
diff --git a/Tests/RunCMake/message/message-loglevel-warning-stderr.txt b/Tests/RunCMake/message/message-loglevel-warning-stderr.txt
new file mode 100644
index 000000000..c721b063c
--- /dev/null
+++ b/Tests/RunCMake/message/message-loglevel-warning-stderr.txt
@@ -0,0 +1,9 @@
+^CMake Deprecation Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:2 \(message\):
+ Deprecation warning
++
+CMake Warning \(dev\) at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:3 \(message\):
+ Author warning message
+This warning is for project developers\. Use -Wno-dev to suppress it\.
++
+CMake Warning at.*/Tests/RunCMake/message/message-all-loglevels\.cmake:4 \(message\):
+ Warning message$
diff --git a/Tests/RunCMake/message/warnmessage-rootdir-stderr.txt b/Tests/RunCMake/message/warnmessage-rootdir-stderr.txt
new file mode 100644
index 000000000..19d93989a
--- /dev/null
+++ b/Tests/RunCMake/message/warnmessage-rootdir-stderr.txt
@@ -0,0 +1 @@
+We expect to see this warning message
diff --git a/Tests/RunCMake/message/warnmessage-rootdir.cmake b/Tests/RunCMake/message/warnmessage-rootdir.cmake
new file mode 100644
index 000000000..f82efb909
--- /dev/null
+++ b/Tests/RunCMake/message/warnmessage-rootdir.cmake
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.15)
+
+# Generating the backtrace for this warning message used to trigger a
+# spurious assertion when the current directory is the root directory
+message(WARNING "We expect to see this warning message")
diff --git a/Tests/RunCMake/option/CMP0077-NEW.cmake b/Tests/RunCMake/option/CMP0077-NEW.cmake
new file mode 100644
index 000000000..d4c518b1e
--- /dev/null
+++ b/Tests/RunCMake/option/CMP0077-NEW.cmake
@@ -0,0 +1,14 @@
+
+#Verify that option DOESN'T overwrite existing normal variable when the policy
+#is set to NEW
+cmake_policy(SET CMP0077 NEW)
+set(OPT_LOCAL_VAR FALSE)
+option(OPT_LOCAL_VAR "TEST_VAR" ON)
+if(OPT_LOCAL_VAR)
+ message(FATAL_ERROR "option failed to overwrite existing normal variable")
+endif()
+
+get_property(_exists_in_cache CACHE OPT_LOCAL_VAR PROPERTY VALUE SET)
+if(_exists_in_cache)
+ message(FATAL_ERROR "value should not exist in cache as it was already a local variable")
+endif()
diff --git a/Tests/RunCMake/option/CMP0077-OLD.cmake b/Tests/RunCMake/option/CMP0077-OLD.cmake
new file mode 100644
index 000000000..4c52d4b92
--- /dev/null
+++ b/Tests/RunCMake/option/CMP0077-OLD.cmake
@@ -0,0 +1,9 @@
+
+#Verify that option overwrites existing normal variable when the policy
+#is set to OLD
+cmake_policy(SET CMP0077 OLD)
+set(OPT_LOCAL_VAR FALSE)
+option(OPT_LOCAL_VAR "TEST_VAR" ON)
+if(NOT OPT_LOCAL_VAR)
+ message(FATAL_ERROR "option failed to overwrite existing normal variable")
+endif()
diff --git a/Tests/RunCMake/option/CMP0077-SECOND-PASS.cmake b/Tests/RunCMake/option/CMP0077-SECOND-PASS.cmake
new file mode 100644
index 000000000..f62a85370
--- /dev/null
+++ b/Tests/RunCMake/option/CMP0077-SECOND-PASS.cmake
@@ -0,0 +1,14 @@
+
+#Verify that when both a cache and local version of a value exist that CMake
+#doesn't produce a CMP0077 warning and that we get the expected values.
+option(OPT_LOCAL_VAR "TEST_VAR" ON)
+set(OPT_LOCAL_VAR FALSE)
+option(OPT_LOCAL_VAR "TEST_VAR" ON)
+if(OPT_LOCAL_VAR)
+ message(FATAL_ERROR "option improperly set a cache variable that already exists")
+endif()
+
+get_property(_exists_in_cache CACHE OPT_LOCAL_VAR PROPERTY VALUE SET)
+if(NOT _exists_in_cache)
+ message(FATAL_ERROR "value should exist in cache")
+endif()
diff --git a/Tests/RunCMake/option/CMP0077-WARN-stderr.txt b/Tests/RunCMake/option/CMP0077-WARN-stderr.txt
new file mode 100644
index 000000000..0d02ffbf7
--- /dev/null
+++ b/Tests/RunCMake/option/CMP0077-WARN-stderr.txt
@@ -0,0 +1,7 @@
+CMake Warning \(dev\) at CMP0077-WARN.cmake:5 \(option\):
+ Policy CMP0077 is not set: option\(\) honors normal variables. Run "cmake
+ --help-policy CMP0077" for policy details. Use the cmake_policy command to
+ set the policy and suppress this warning.
+
+ For compatibility with older versions of CMake, option is clearing the
+ normal variable 'OPT_LOCAL_VAR'.
diff --git a/Tests/RunCMake/option/CMP0077-WARN.cmake b/Tests/RunCMake/option/CMP0077-WARN.cmake
new file mode 100644
index 000000000..7f994569f
--- /dev/null
+++ b/Tests/RunCMake/option/CMP0077-WARN.cmake
@@ -0,0 +1,5 @@
+
+#Verify that option overwrites existing normal variable when the policy
+#is set to OLD
+set(OPT_LOCAL_VAR FALSE)
+option(OPT_LOCAL_VAR "TEST_VAR" ON)
diff --git a/Tests/RunCMake/option/CMakeLists.txt b/Tests/RunCMake/option/CMakeLists.txt
new file mode 100644
index 000000000..11dc49a05
--- /dev/null
+++ b/Tests/RunCMake/option/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.12)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/option/RunCMakeTest.cmake b/Tests/RunCMake/option/RunCMakeTest.cmake
new file mode 100644
index 000000000..979afa1ce
--- /dev/null
+++ b/Tests/RunCMake/option/RunCMakeTest.cmake
@@ -0,0 +1,6 @@
+include(RunCMake)
+
+run_cmake(CMP0077-OLD)
+run_cmake(CMP0077-NEW)
+run_cmake(CMP0077-WARN)
+run_cmake(CMP0077-SECOND-PASS)
diff --git a/Tests/RunCMake/print_stdin.c b/Tests/RunCMake/print_stdin.c
new file mode 100644
index 000000000..e083e6297
--- /dev/null
+++ b/Tests/RunCMake/print_stdin.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+
+int main()
+{
+ char buf[1024];
+ size_t nIn = sizeof(buf);
+ while (nIn == sizeof(buf)) {
+ nIn = fread(buf, 1, sizeof(buf), stdin);
+ if (nIn > 0) {
+ size_t nOut;
+ nOut = fwrite(buf, 1, nIn, stdout);
+ if (nOut != nIn) {
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/Tests/RunCMake/project/CMP0048-NEW.cmake b/Tests/RunCMake/project/CMP0048-NEW.cmake
index 7e16b7081..b6e80aca9 100644
--- a/Tests/RunCMake/project/CMP0048-NEW.cmake
+++ b/Tests/RunCMake/project/CMP0048-NEW.cmake
@@ -1,9 +1,4 @@
-macro(print_versions name)
- foreach(v "" _MAJOR _MINOR _PATCH _TWEAK)
- message(STATUS "PROJECT_VERSION${v}='${PROJECT_VERSION${v}}'")
- message(STATUS "${name}_VERSION${v}='${${name}_VERSION${v}}'")
- endforeach()
-endmacro()
+include(PrintVersions.cmake)
cmake_policy(SET CMP0048 NEW)
diff --git a/Tests/RunCMake/project/CMP0048-OLD-stderr.txt b/Tests/RunCMake/project/CMP0048-OLD-stderr.txt
new file mode 100644
index 000000000..1fa70f88b
--- /dev/null
+++ b/Tests/RunCMake/project/CMP0048-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0048-OLD.cmake:1 \(cmake_policy\):
+ The OLD behavior for policy CMP0048 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/project/CMP0096-NEW-stdout.txt b/Tests/RunCMake/project/CMP0096-NEW-stdout.txt
new file mode 100644
index 000000000..f6b999a43
--- /dev/null
+++ b/Tests/RunCMake/project/CMP0096-NEW-stdout.txt
@@ -0,0 +1,30 @@
+-- PROJECT_VERSION='2019.07.06'
+-- DateVersion_VERSION='2019.07.06'
+-- PROJECT_VERSION_MAJOR='2019'
+-- DateVersion_VERSION_MAJOR='2019'
+-- PROJECT_VERSION_MINOR='07'
+-- DateVersion_VERSION_MINOR='07'
+-- PROJECT_VERSION_PATCH='06'
+-- DateVersion_VERSION_PATCH='06'
+-- PROJECT_VERSION_TWEAK=''
+-- DateVersion_VERSION_TWEAK=''
+-- PROJECT_VERSION='4294967297'
+-- LongVersion_VERSION='4294967297'
+-- PROJECT_VERSION_MAJOR='4294967297'
+-- LongVersion_VERSION_MAJOR='4294967297'
+-- PROJECT_VERSION_MINOR=''
+-- LongVersion_VERSION_MINOR=''
+-- PROJECT_VERSION_PATCH=''
+-- LongVersion_VERSION_PATCH=''
+-- PROJECT_VERSION_TWEAK=''
+-- LongVersion_VERSION_TWEAK=''
+-- PROJECT_VERSION='0009999999999.0009999999999.0009999999999.0009999999999'
+-- VeryLongVersion_VERSION='0009999999999.0009999999999.0009999999999.0009999999999'
+-- PROJECT_VERSION_MAJOR='0009999999999'
+-- VeryLongVersion_VERSION_MAJOR='0009999999999'
+-- PROJECT_VERSION_MINOR='0009999999999'
+-- VeryLongVersion_VERSION_MINOR='0009999999999'
+-- PROJECT_VERSION_PATCH='0009999999999'
+-- VeryLongVersion_VERSION_PATCH='0009999999999'
+-- PROJECT_VERSION_TWEAK='0009999999999'
+-- VeryLongVersion_VERSION_TWEAK='0009999999999'
diff --git a/Tests/RunCMake/project/CMP0096-NEW.cmake b/Tests/RunCMake/project/CMP0096-NEW.cmake
new file mode 100644
index 000000000..e2cdd2001
--- /dev/null
+++ b/Tests/RunCMake/project/CMP0096-NEW.cmake
@@ -0,0 +1,6 @@
+cmake_policy(SET CMP0048 NEW)
+cmake_policy(SET CMP0096 NEW)
+include(CMP0096-common.cmake)
+
+project(VeryLongVersion VERSION 0009999999999.0009999999999.0009999999999.0009999999999 LANGUAGES NONE)
+print_versions(VeryLongVersion)
diff --git a/Tests/RunCMake/project/CMP0096-OLD-stdout.txt b/Tests/RunCMake/project/CMP0096-OLD-stdout.txt
new file mode 100644
index 000000000..6a945ceda
--- /dev/null
+++ b/Tests/RunCMake/project/CMP0096-OLD-stdout.txt
@@ -0,0 +1,20 @@
+-- PROJECT_VERSION='2019.7.6'
+-- DateVersion_VERSION='2019.7.6'
+-- PROJECT_VERSION_MAJOR='2019'
+-- DateVersion_VERSION_MAJOR='2019'
+-- PROJECT_VERSION_MINOR='7'
+-- DateVersion_VERSION_MINOR='7'
+-- PROJECT_VERSION_PATCH='6'
+-- DateVersion_VERSION_PATCH='6'
+-- PROJECT_VERSION_TWEAK=''
+-- DateVersion_VERSION_TWEAK=''
+-- PROJECT_VERSION='(1|4294967295)'
+-- LongVersion_VERSION='(1|4294967295)'
+-- PROJECT_VERSION_MAJOR='(1|4294967295)'
+-- LongVersion_VERSION_MAJOR='(1|4294967295)'
+-- PROJECT_VERSION_MINOR=''
+-- LongVersion_VERSION_MINOR=''
+-- PROJECT_VERSION_PATCH=''
+-- LongVersion_VERSION_PATCH=''
+-- PROJECT_VERSION_TWEAK=''
+-- LongVersion_VERSION_TWEAK=''
diff --git a/Tests/RunCMake/project/CMP0096-OLD.cmake b/Tests/RunCMake/project/CMP0096-OLD.cmake
new file mode 100644
index 000000000..25a3b19f9
--- /dev/null
+++ b/Tests/RunCMake/project/CMP0096-OLD.cmake
@@ -0,0 +1,3 @@
+cmake_policy(SET CMP0048 NEW)
+cmake_policy(SET CMP0096 OLD)
+include(CMP0096-common.cmake)
diff --git a/Tests/RunCMake/project/CMP0096-WARN-stdout.txt b/Tests/RunCMake/project/CMP0096-WARN-stdout.txt
new file mode 100644
index 000000000..6a945ceda
--- /dev/null
+++ b/Tests/RunCMake/project/CMP0096-WARN-stdout.txt
@@ -0,0 +1,20 @@
+-- PROJECT_VERSION='2019.7.6'
+-- DateVersion_VERSION='2019.7.6'
+-- PROJECT_VERSION_MAJOR='2019'
+-- DateVersion_VERSION_MAJOR='2019'
+-- PROJECT_VERSION_MINOR='7'
+-- DateVersion_VERSION_MINOR='7'
+-- PROJECT_VERSION_PATCH='6'
+-- DateVersion_VERSION_PATCH='6'
+-- PROJECT_VERSION_TWEAK=''
+-- DateVersion_VERSION_TWEAK=''
+-- PROJECT_VERSION='(1|4294967295)'
+-- LongVersion_VERSION='(1|4294967295)'
+-- PROJECT_VERSION_MAJOR='(1|4294967295)'
+-- LongVersion_VERSION_MAJOR='(1|4294967295)'
+-- PROJECT_VERSION_MINOR=''
+-- LongVersion_VERSION_MINOR=''
+-- PROJECT_VERSION_PATCH=''
+-- LongVersion_VERSION_PATCH=''
+-- PROJECT_VERSION_TWEAK=''
+-- LongVersion_VERSION_TWEAK=''
diff --git a/Tests/RunCMake/project/CMP0096-WARN.cmake b/Tests/RunCMake/project/CMP0096-WARN.cmake
new file mode 100644
index 000000000..7fe086179
--- /dev/null
+++ b/Tests/RunCMake/project/CMP0096-WARN.cmake
@@ -0,0 +1,3 @@
+cmake_policy(SET CMP0048 NEW)
+
+include(CMP0096-common.cmake)
diff --git a/Tests/RunCMake/project/CMP0096-common.cmake b/Tests/RunCMake/project/CMP0096-common.cmake
new file mode 100644
index 000000000..8d26d3060
--- /dev/null
+++ b/Tests/RunCMake/project/CMP0096-common.cmake
@@ -0,0 +1,9 @@
+include(PrintVersions.cmake)
+
+# Test leading zeros motivating this policy.
+project(DateVersion VERSION 2019.07.06 LANGUAGES NONE)
+print_versions(DateVersion)
+
+# Overflow version component in OLD behavior.
+project(LongVersion VERSION 4294967297 #[[ uint32_max + 2 ]] LANGUAGES NONE)
+print_versions(LongVersion)
diff --git a/Tests/RunCMake/project/LanguagesUnordered-stderr.txt b/Tests/RunCMake/project/LanguagesUnordered-stderr.txt
new file mode 100644
index 000000000..51086700c
--- /dev/null
+++ b/Tests/RunCMake/project/LanguagesUnordered-stderr.txt
@@ -0,0 +1 @@
+ the following parameters must be specified after LANGUAGES keyword: C.
diff --git a/Tests/RunCMake/project/LanguagesUnordered.cmake b/Tests/RunCMake/project/LanguagesUnordered.cmake
new file mode 100644
index 000000000..cd3ba2872
--- /dev/null
+++ b/Tests/RunCMake/project/LanguagesUnordered.cmake
@@ -0,0 +1 @@
+project(ProjectA C LANGUAGES CXX)
diff --git a/Tests/RunCMake/project/PrintVersions.cmake b/Tests/RunCMake/project/PrintVersions.cmake
new file mode 100644
index 000000000..ce1b25d66
--- /dev/null
+++ b/Tests/RunCMake/project/PrintVersions.cmake
@@ -0,0 +1,6 @@
+macro(print_versions name)
+ foreach(v "" _MAJOR _MINOR _PATCH _TWEAK)
+ message(STATUS "PROJECT_VERSION${v}='${PROJECT_VERSION${v}}'")
+ message(STATUS "${name}_VERSION${v}='${${name}_VERSION${v}}'")
+ endforeach()
+endmacro()
diff --git a/Tests/RunCMake/project/ProjectDescription2-stderr.txt b/Tests/RunCMake/project/ProjectDescription2-stderr.txt
index 558e2dfbb..c65a99731 100644
--- a/Tests/RunCMake/project/ProjectDescription2-stderr.txt
+++ b/Tests/RunCMake/project/ProjectDescription2-stderr.txt
@@ -1 +1 @@
- DESCRITPION may be specified at most once.
+ DESCRIPTION may be specified at most once.
diff --git a/Tests/RunCMake/project/ProjectDescriptionNoArg-stderr.txt b/Tests/RunCMake/project/ProjectDescriptionNoArg-stderr.txt
new file mode 100644
index 000000000..910106f40
--- /dev/null
+++ b/Tests/RunCMake/project/ProjectDescriptionNoArg-stderr.txt
@@ -0,0 +1,2 @@
+ DESCRIPTION keyword not followed by a value or was followed by a value that
+ expanded to nothing.
diff --git a/Tests/RunCMake/project/ProjectDescriptionNoArg.cmake b/Tests/RunCMake/project/ProjectDescriptionNoArg.cmake
new file mode 100644
index 000000000..25acff840
--- /dev/null
+++ b/Tests/RunCMake/project/ProjectDescriptionNoArg.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0048 NEW)
+project(ProjectDescriptionTest VERSION 1.0.0 LANGUAGES NONE DESCRIPTION)
diff --git a/Tests/RunCMake/project/ProjectDescriptionNoArg2-stderr.txt b/Tests/RunCMake/project/ProjectDescriptionNoArg2-stderr.txt
new file mode 100644
index 000000000..910106f40
--- /dev/null
+++ b/Tests/RunCMake/project/ProjectDescriptionNoArg2-stderr.txt
@@ -0,0 +1,2 @@
+ DESCRIPTION keyword not followed by a value or was followed by a value that
+ expanded to nothing.
diff --git a/Tests/RunCMake/project/ProjectDescriptionNoArg2.cmake b/Tests/RunCMake/project/ProjectDescriptionNoArg2.cmake
new file mode 100644
index 000000000..f50a2f688
--- /dev/null
+++ b/Tests/RunCMake/project/ProjectDescriptionNoArg2.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0048 NEW)
+project(ProjectDescriptionTest VERSION 1.0.0 DESCRIPTION LANGUAGES NONE)
diff --git a/Tests/RunCMake/project/ProjectHomepage-stdout.txt b/Tests/RunCMake/project/ProjectHomepage-stdout.txt
new file mode 100644
index 000000000..253990f3d
--- /dev/null
+++ b/Tests/RunCMake/project/ProjectHomepage-stdout.txt
@@ -0,0 +1,3 @@
+-- PROJECT_HOMEPAGE_URL=http://example.com
+-- CMAKE_PROJECT_HOMEPAGE_URL=http://example.com
+-- ProjectHomepageTest_HOMEPAGE_URL=http://example.com
diff --git a/Tests/RunCMake/project/ProjectHomepage.cmake b/Tests/RunCMake/project/ProjectHomepage.cmake
new file mode 100644
index 000000000..3307f1fc9
--- /dev/null
+++ b/Tests/RunCMake/project/ProjectHomepage.cmake
@@ -0,0 +1,14 @@
+cmake_policy(SET CMP0048 NEW)
+project(ProjectHomepageTest VERSION 1.0.0 HOMEPAGE_URL "http://example.com" LANGUAGES)
+if(NOT PROJECT_HOMEPAGE_URL)
+ message(FATAL_ERROR "PROJECT_HOMEPAGE_URL expected to be set")
+endif()
+if(NOT CMAKE_PROJECT_HOMEPAGE_URL)
+ message(FATAL_ERROR "CMAKE_PROJECT_HOMEPAGE_URL expected to be set")
+endif()
+if(NOT ProjectHomepageTest_HOMEPAGE_URL)
+ message(FATAL_ERROR "ProjectHomepageTest_HOMEPAGE_URL expected to be set")
+endif()
+message(STATUS "PROJECT_HOMEPAGE_URL=${PROJECT_HOMEPAGE_URL}")
+message(STATUS "CMAKE_PROJECT_HOMEPAGE_URL=${CMAKE_PROJECT_HOMEPAGE_URL}")
+message(STATUS "ProjectHomepageTest_HOMEPAGE_URL=${ProjectHomepageTest_HOMEPAGE_URL}")
diff --git a/Tests/RunCMake/project/ProjectHomepage2-result.txt b/Tests/RunCMake/project/ProjectHomepage2-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/project/ProjectHomepage2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/project/ProjectHomepage2-stderr.txt b/Tests/RunCMake/project/ProjectHomepage2-stderr.txt
new file mode 100644
index 000000000..4a0adc2d3
--- /dev/null
+++ b/Tests/RunCMake/project/ProjectHomepage2-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at ProjectHomepage2.cmake:2 \(project\):
+ HOMEPAGE_URL may be specified at most once.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/project/ProjectHomepage2.cmake b/Tests/RunCMake/project/ProjectHomepage2.cmake
new file mode 100644
index 000000000..184c392c4
--- /dev/null
+++ b/Tests/RunCMake/project/ProjectHomepage2.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0048 NEW)
+project(ProjectDescriptionTest VERSION 1.0.0 HOMEPAGE_URL "http://example.com" HOMEPAGE_URL "http://example.com" LANGUAGES)
diff --git a/Tests/RunCMake/project/ProjectHomepageNoArg-stderr.txt b/Tests/RunCMake/project/ProjectHomepageNoArg-stderr.txt
new file mode 100644
index 000000000..c9503b74b
--- /dev/null
+++ b/Tests/RunCMake/project/ProjectHomepageNoArg-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Warning at ProjectHomepageNoArg.cmake:2 \(project\):
+ HOMEPAGE_URL keyword not followed by a value or was followed by a value
+ that expanded to nothing.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/project/ProjectHomepageNoArg.cmake b/Tests/RunCMake/project/ProjectHomepageNoArg.cmake
new file mode 100644
index 000000000..460554194
--- /dev/null
+++ b/Tests/RunCMake/project/ProjectHomepageNoArg.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0048 NEW)
+project(ProjectDescriptionTest VERSION 1.0.0 LANGUAGES NONE HOMEPAGE_URL)
diff --git a/Tests/RunCMake/project/ProjectTwice.cmake b/Tests/RunCMake/project/ProjectTwice.cmake
new file mode 100644
index 000000000..d053834dc
--- /dev/null
+++ b/Tests/RunCMake/project/ProjectTwice.cmake
@@ -0,0 +1,26 @@
+cmake_policy(SET CMP0048 NEW)
+project(ProjectTwiceTestFirst
+ VERSION 1.2.3.4
+ DESCRIPTION "Test Project"
+ HOMEPAGE_URL "http://example.com"
+ LANGUAGES NONE
+)
+
+project(ProjectTwiceTestSecond LANGUAGES NONE)
+
+foreach(var
+ PROJECT_VERSION
+ PROJECT_VERSION_MAJOR
+ PROJECT_VERSION_MINOR
+ PROJECT_VERSION_PATCH
+ PROJECT_VERSION_TWEAK
+ PROJECT_DESCRIPTION
+ PROJECT_HOMEPAGE_URL
+)
+ if(${var})
+ message(SEND_ERROR "${var} set but should be empty")
+ endif()
+ if(CMAKE_${var})
+ message(SEND_ERROR "CMAKE_${var} set but should be empty")
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake
index 3d13e2ef4..69146993b 100644
--- a/Tests/RunCMake/project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/project/RunCMakeTest.cmake
@@ -7,16 +7,28 @@ run_cmake(LanguagesImplicit)
run_cmake(LanguagesEmpty)
run_cmake(LanguagesNONE)
run_cmake(LanguagesTwice)
+run_cmake(LanguagesUnordered)
run_cmake(ProjectDescription)
run_cmake(ProjectDescription2)
+run_cmake(ProjectDescriptionNoArg)
+run_cmake(ProjectDescriptionNoArg2)
+run_cmake(ProjectHomepage)
+run_cmake(ProjectHomepage2)
+run_cmake(ProjectHomepageNoArg)
+run_cmake(ProjectTwice)
run_cmake(VersionAndLanguagesEmpty)
run_cmake(VersionEmpty)
run_cmake(VersionInvalid)
run_cmake(VersionMissingLanguages)
run_cmake(VersionMissingValueOkay)
run_cmake(VersionTwice)
+run_cmake(VersionMax)
run_cmake(CMP0048-OLD)
run_cmake(CMP0048-OLD-VERSION)
run_cmake(CMP0048-WARN)
run_cmake(CMP0048-NEW)
+
+run_cmake(CMP0096-WARN)
+run_cmake(CMP0096-OLD)
+run_cmake(CMP0096-NEW)
diff --git a/Tests/RunCMake/project/VersionMax.cmake b/Tests/RunCMake/project/VersionMax.cmake
new file mode 100644
index 000000000..e95536438
--- /dev/null
+++ b/Tests/RunCMake/project/VersionMax.cmake
@@ -0,0 +1,32 @@
+cmake_policy(SET CMP0048 NEW)
+cmake_policy(SET CMP0096 OLD)
+
+enable_language(C)
+include(CheckTypeSize)
+check_type_size(unsigned __sizeOfUnsigned BUILTIN_TYPES_ONLY LANGUAGE C)
+
+# We can't use math() to compute this because it only supports up to
+# 64-bit signed integers, so hard-code the types we expect to encounter
+if(__sizeOfUnsigned EQUAL 0)
+ message(STATUS "Multi-architecture build, skipping project version check")
+ return()
+elseif(__sizeOfUnsigned EQUAL 4)
+ set(maxVal 4294967295)
+elseif(__sizeOfUnsigned EQUAL 8)
+ set(maxVal 18446744073709551615)
+else()
+ message(FATAL_ERROR
+ "Test needs to be updated for unsigned integer size ${__sizeOfUnsigned}")
+endif()
+
+# The real value of this test is when an address sanitizer is enabled.
+# It catches situations where the size of the buffer used to compute or
+# hold the version components as strings is too small.
+project(ProjectA VERSION ${maxVal}.${maxVal}.${maxVal}.${maxVal} LANGUAGES NONE)
+
+if(NOT ${PROJECT_VERSION_MAJOR} EQUAL ${maxVal})
+ message(FATAL_ERROR "Project version number parsing failed round trip.\n"
+ "Expected: ${maxVal}\n"
+ "Computed: ${PROJECT_VERSION_MAJOR}"
+ )
+endif()
diff --git a/Tests/RunCMake/project/VersionMissingLanguages-stderr.txt b/Tests/RunCMake/project/VersionMissingLanguages-stderr.txt
index 52433bcc0..576ac6934 100644
--- a/Tests/RunCMake/project/VersionMissingLanguages-stderr.txt
+++ b/Tests/RunCMake/project/VersionMissingLanguages-stderr.txt
@@ -1,4 +1,5 @@
CMake Error at VersionMissingLanguages.cmake:2 \(project\):
- project with VERSION must use LANGUAGES before language names.
+ project with VERSION, DESCRIPTION or HOMEPAGE_URL must use LANGUAGES before
+ language names.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/project/VersionMissingValueOkay-stderr.txt b/Tests/RunCMake/project/VersionMissingValueOkay-stderr.txt
new file mode 100644
index 000000000..3228df7eb
--- /dev/null
+++ b/Tests/RunCMake/project/VersionMissingValueOkay-stderr.txt
@@ -0,0 +1,2 @@
+ VERSION keyword not followed by a value or was followed by a value that
+ expanded to nothing.
diff --git a/Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt b/Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt
new file mode 100644
index 000000000..fc1a02b43
--- /dev/null
+++ b/Tests/RunCMake/project_injected/CMP0048-WARN-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Warning \(dev\) in CMakeLists.txt:
+ No project\(\) command is present. The top-level CMakeLists.txt file must
+ contain a literal, direct call to the project\(\) command. Add a line of
+ code such as
+
+ project\(ProjectName\)
+
+ near the top of the file, but after cmake_minimum_required\(\).
+
+ CMake is pretending there is a "project\(Project\)" command on the first
+ line.
+This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/project_injected/CMP0048-WARN.cmake b/Tests/RunCMake/project_injected/CMP0048-WARN.cmake
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/project_injected/CMP0048-WARN.cmake
diff --git a/Tests/RunCMake/project_injected/CMakeLists.txt b/Tests/RunCMake/project_injected/CMakeLists.txt
new file mode 100644
index 000000000..1b4931b8f
--- /dev/null
+++ b/Tests/RunCMake/project_injected/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.12.2) # old enough to not set CMP0048
+# no project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/project_injected/RunCMakeTest.cmake b/Tests/RunCMake/project_injected/RunCMakeTest.cmake
new file mode 100644
index 000000000..ba1a00377
--- /dev/null
+++ b/Tests/RunCMake/project_injected/RunCMakeTest.cmake
@@ -0,0 +1,12 @@
+include(RunCMake)
+
+set(RunCMake_TEST_OPTIONS
+ # Simulate a previous CMake run that used `project(... VERSION ...)`
+ # in a non-injected call site.
+ -DCMAKE_PROJECT_VERSION:STATIC=1.2.3
+ -DCMAKE_PROJECT_VERSION_MAJOR:STATIC=1
+ -DCMAKE_PROJECT_VERSION_MINOR:STATIC=2
+ -DCMAKE_PROJECT_VERSION_PATCH:STATIC=3
+ )
+run_cmake(CMP0048-WARN)
+unset(RunCMake_TEST_OPTIONS)
diff --git a/Tests/RunCMake/pseudo_cppcheck.c b/Tests/RunCMake/pseudo_cppcheck.c
new file mode 100644
index 000000000..5b1531bb4
--- /dev/null
+++ b/Tests/RunCMake/pseudo_cppcheck.c
@@ -0,0 +1,39 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main(int argc, char* argv[])
+{
+ int i;
+ int result = 0;
+ for (i = 1; i < argc; ++i) {
+ if (strcmp(argv[i], "-bad") == 0) {
+ fprintf(stdout, "stdout from bad command line arg '-bad'\n");
+ fprintf(stderr, "stderr from bad command line arg '-bad'\n");
+ return 1;
+ } else if (strcmp(argv[i], "-error") == 0) {
+ // The real cppcheck allows to set the exitcode with --error-exitcode
+ result = 5;
+ }
+ }
+ fprintf(stderr,
+ "[/foo/bar.c:2]: (error) Array 'abc[10]' accessed at index 12,"
+ " which is out of bounds.\n");
+ fprintf(stderr,
+ "[/foo/bar.c:2]: (warning) Member variable 'foo::bar' is "
+ "not initialized in the constructor.\n");
+ fprintf(stderr, "[/foo/bar.c:2]: (style) C-style pointer casting.\n");
+ fprintf(stderr,
+ "[/foo/bar.c:2]: (performance) Variable 'm_message' is "
+ "assigned in constructor body. Consider performing "
+ "initialization in initialization list.\n");
+ fprintf(stderr,
+ "[/foo/bar.c:2]: (portability) scanf without field width "
+ "limits can crash with huge input data on some versions of "
+ "libc\n");
+ fprintf(stderr,
+ "[/foo/bar.c:2]: (information) cannot find all the include "
+ "files (use --check-config for details)\n");
+
+ return result;
+}
diff --git a/Tests/RunCMake/pseudo_emulator_custom_command_arg.c b/Tests/RunCMake/pseudo_emulator_custom_command_arg.c
new file mode 100644
index 000000000..d00deda53
--- /dev/null
+++ b/Tests/RunCMake/pseudo_emulator_custom_command_arg.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+// Usage:
+//
+// /path/to/program arg1 [arg2 [...]]
+//
+// Return EXIT_SUCCESS if 'custom_argument' string was found
+// in <arg1> and 'generated_exe_emulator_expected'
+// string was found in <arg2>
+// Return EXIT_FAILURE if 'custom_argument' string was not
+// found in <arg1> or 'generated_exe_emulator_expected'
+// string was not found in <arg2>.
+
+int main(int argc, const char* argv[])
+{
+ // Require a slash to make sure it is a path and not a target name.
+ const char* substring_success = "/generated_exe_emulator_expected";
+ const char* substring_custom_argument = "custom_argument";
+
+ if (argc < 2) {
+ return EXIT_FAILURE;
+ }
+ if (strstr(argv[1], substring_custom_argument) != 0 &&
+ strstr(argv[2], substring_success) != 0) {
+ return EXIT_SUCCESS;
+ }
+ return EXIT_FAILURE;
+}
diff --git a/Tests/RunCMake/set/ExtraEnvValue-stderr.txt b/Tests/RunCMake/set/ExtraEnvValue-stderr.txt
new file mode 100644
index 000000000..f61f9d287
--- /dev/null
+++ b/Tests/RunCMake/set/ExtraEnvValue-stderr.txt
@@ -0,0 +1,6 @@
+CMake Warning \(dev\) at ExtraEnvValue.cmake:1 \(set\):
+ Only the first value argument is used when setting an environment variable.
+ Argument 'value_2' and later are unused.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/set/ExtraEnvValue.cmake b/Tests/RunCMake/set/ExtraEnvValue.cmake
new file mode 100644
index 000000000..768a6eac2
--- /dev/null
+++ b/Tests/RunCMake/set/ExtraEnvValue.cmake
@@ -0,0 +1 @@
+set (ENV{sample_key} value_1 value_2)
diff --git a/Tests/RunCMake/set/RunCMakeTest.cmake b/Tests/RunCMake/set/RunCMakeTest.cmake
index b8e8cf1f9..b3bd0a480 100644
--- a/Tests/RunCMake/set/RunCMakeTest.cmake
+++ b/Tests/RunCMake/set/RunCMakeTest.cmake
@@ -3,3 +3,5 @@ include(RunCMake)
run_cmake(ParentScope)
run_cmake(ParentPulling)
run_cmake(ParentPullingRecursive)
+run_cmake(UnknownCacheType)
+run_cmake(ExtraEnvValue)
diff --git a/Tests/RunCMake/set/UnknownCacheType-stderr.txt b/Tests/RunCMake/set/UnknownCacheType-stderr.txt
new file mode 100644
index 000000000..6e1c8114a
--- /dev/null
+++ b/Tests/RunCMake/set/UnknownCacheType-stderr.txt
@@ -0,0 +1,5 @@
+CMake Warning \(dev\) at UnknownCacheType.cmake:1 \(set\):
+ implicitly converting 'unknown_type_sample' to 'STRING' type.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/set/UnknownCacheType.cmake b/Tests/RunCMake/set/UnknownCacheType.cmake
new file mode 100644
index 000000000..f2b5d051d
--- /dev/null
+++ b/Tests/RunCMake/set/UnknownCacheType.cmake
@@ -0,0 +1 @@
+set (sample_key sample_value CACHE unknown_type_sample "sample doc")
diff --git a/Tests/RunCMake/set_property/IMPORTED_GLOBAL-result.txt b/Tests/RunCMake/set_property/IMPORTED_GLOBAL-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/set_property/IMPORTED_GLOBAL-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/set_property/IMPORTED_GLOBAL-stderr.txt b/Tests/RunCMake/set_property/IMPORTED_GLOBAL-stderr.txt
new file mode 100644
index 000000000..e45fc64b1
--- /dev/null
+++ b/Tests/RunCMake/set_property/IMPORTED_GLOBAL-stderr.txt
@@ -0,0 +1,61 @@
+^CMake Error at IMPORTED_GLOBAL.cmake:9 \(set_property\):
+ IMPORTED_GLOBAL property can't be set to FALSE on targets
+ \(\"ImportedGlobalTarget\"\)
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+
+
+CMake Error at IMPORTED_GLOBAL.cmake:16 \(set_property\):
+ IMPORTED_GLOBAL property can't be appended, only set on imported targets
+ \(\"ImportedGlobalTarget\"\)
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+
+
+CMake Error at IMPORTED_GLOBAL.cmake:26 \(set_property\):
+ IMPORTED_GLOBAL property can't be set to FALSE on targets
+ \(\"ImportedLocalTarget\"\)
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+
+
+CMake Error at IMPORTED_GLOBAL.cmake:32 \(set_property\):
+ IMPORTED_GLOBAL property can't be set on non-imported targets
+ \(\"NonImportedTarget\"\)
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+
+
+CMake Error at IMPORTED_GLOBAL/CMakeLists\.txt:[0-9]+ \(set_property\):
+ Attempt to promote imported target \"ImportedLocalTarget2\" to global scope
+ \(by setting IMPORTED_GLOBAL\) which is not built in this directory.
+
+
+CMake Error in IMPORTED_GLOBAL/CMakeLists.txt:
+ IMPORTED_GLOBAL property can't be set to FALSE on targets
+ \(\"ImportedSubdirTarget1\"\)
+
+
+
+CMake Error at IMPORTED_GLOBAL.cmake:50 \(set_property\):
+ Attempt to promote imported target \"ImportedSubdirTarget1\" to global scope
+ \(by setting IMPORTED_GLOBAL\) which is not built in this directory.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
+
+
+CMake Error in IMPORTED_GLOBAL/CMakeLists.txt:
+ IMPORTED_GLOBAL property can't be set to FALSE on targets
+ \(\"ImportedSubdirTarget2\"\)
+
+
+
+CMake Error at IMPORTED_GLOBAL.cmake:52 \(set_property\):
+ Attempt to promote imported target \"ImportedSubdirTarget2\" to global scope
+ \(by setting IMPORTED_GLOBAL\) which is not built in this directory.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/set_property/IMPORTED_GLOBAL-stdout.txt b/Tests/RunCMake/set_property/IMPORTED_GLOBAL-stdout.txt
new file mode 100644
index 000000000..c5f1d1128
--- /dev/null
+++ b/Tests/RunCMake/set_property/IMPORTED_GLOBAL-stdout.txt
@@ -0,0 +1,17 @@
+-- ImportedGlobalTarget: Target IMPORTED_GLOBAL is 'TRUE'
+-- ImportedGlobalTarget: Target IMPORTED_GLOBAL is 'TRUE'
+-- ImportedGlobalTarget: Target IMPORTED_GLOBAL is 'TRUE'
+-- ImportedGlobalTarget: Target IMPORTED_GLOBAL is 'TRUE'
+-- ImportedGlobalTarget: Target IMPORTED_GLOBAL is 'TRUE'
+-- ImportedLocalTarget: Target IMPORTED_GLOBAL is 'FALSE'
+-- ImportedLocalTarget: Target IMPORTED_GLOBAL is 'TRUE'
+-- ImportedLocalTarget: Target IMPORTED_GLOBAL is 'TRUE'
+-- ImportedLocalTarget: Target IMPORTED_GLOBAL is 'TRUE'
+-- NonImportedTarget: Target IMPORTED_GLOBAL is 'FALSE'
+-- NonImportedTarget: Target IMPORTED_GLOBAL is 'FALSE'
+-- ImportedLocalTarget2: Target IMPORTED_GLOBAL is 'FALSE'
+-- ImportedLocalTarget2: Target IMPORTED_GLOBAL is 'TRUE'
+-- ImportedSubdirTarget1: Target IMPORTED_GLOBAL is 'TRUE'
+-- ImportedSubdirTarget2: Target IMPORTED_GLOBAL is 'TRUE'
+-- ImportedSubdirTarget1: Target IMPORTED_GLOBAL is 'TRUE'
+-- ImportedSubdirTarget2: Target IMPORTED_GLOBAL is 'TRUE'
diff --git a/Tests/RunCMake/set_property/IMPORTED_GLOBAL.cmake b/Tests/RunCMake/set_property/IMPORTED_GLOBAL.cmake
new file mode 100644
index 000000000..08308ebae
--- /dev/null
+++ b/Tests/RunCMake/set_property/IMPORTED_GLOBAL.cmake
@@ -0,0 +1,53 @@
+macro(print_property TARGET PROP)
+ get_property(val TARGET ${TARGET} PROPERTY ${PROP})
+ message(STATUS "${TARGET}: Target ${PROP} is '${val}'")
+endmacro()
+
+# Changing property on IMPORTED target created with `GLOBAL` option.
+add_library(ImportedGlobalTarget SHARED IMPORTED GLOBAL)
+print_property(ImportedGlobalTarget IMPORTED_GLOBAL)
+set_property(TARGET ImportedGlobalTarget PROPERTY IMPORTED_GLOBAL FALSE)
+print_property(ImportedGlobalTarget IMPORTED_GLOBAL)
+set_property(TARGET ImportedGlobalTarget PROPERTY IMPORTED_GLOBAL TRUE)
+print_property(ImportedGlobalTarget IMPORTED_GLOBAL)
+set_property(TARGET ImportedGlobalTarget PROPERTY IMPORTED_GLOBAL TRUE)
+print_property(ImportedGlobalTarget IMPORTED_GLOBAL)
+# Appending property is never allowed!
+set_property(TARGET ImportedGlobalTarget APPEND PROPERTY IMPORTED_GLOBAL TRUE)
+print_property(ImportedGlobalTarget IMPORTED_GLOBAL)
+
+# Changing property on IMPORTED target created without `GLOBAL` option.
+add_library(ImportedLocalTarget SHARED IMPORTED)
+print_property(ImportedLocalTarget IMPORTED_GLOBAL)
+set_property(TARGET ImportedLocalTarget PROPERTY IMPORTED_GLOBAL TRUE)
+print_property(ImportedLocalTarget IMPORTED_GLOBAL)
+set_property(TARGET ImportedLocalTarget PROPERTY IMPORTED_GLOBAL TRUE)
+print_property(ImportedLocalTarget IMPORTED_GLOBAL)
+set_property(TARGET ImportedLocalTarget PROPERTY IMPORTED_GLOBAL FALSE)
+print_property(ImportedLocalTarget IMPORTED_GLOBAL)
+
+# Setting property on non-IMPORTED target is never allowed!
+add_library(NonImportedTarget SHARED test.cpp)
+print_property(NonImportedTarget IMPORTED_GLOBAL)
+set_property(TARGET NonImportedTarget PROPERTY IMPORTED_GLOBAL TRUE)
+print_property(NonImportedTarget IMPORTED_GLOBAL)
+
+# Local IMPORTED targets can only be promoted from same directory!
+add_library(ImportedLocalTarget2 SHARED IMPORTED)
+print_property(ImportedLocalTarget2 IMPORTED_GLOBAL)
+add_subdirectory(IMPORTED_GLOBAL)
+# Note: The value should not have changed. However, it does change because the
+# check for the same directory comes after it was changed! (At least, that is
+# not really bad because the generation will fail due to this error.)
+print_property(ImportedLocalTarget2 IMPORTED_GLOBAL)
+
+# Global IMPORTED targets from subdir are always visible
+# no matter how they became global.
+print_property(ImportedSubdirTarget1 IMPORTED_GLOBAL)
+print_property(ImportedSubdirTarget2 IMPORTED_GLOBAL)
+
+# Changing property on IMPORTED target from subdir is never possible.
+set_property(TARGET ImportedSubdirTarget1 PROPERTY IMPORTED_GLOBAL FALSE)
+print_property(ImportedSubdirTarget1 IMPORTED_GLOBAL)
+set_property(TARGET ImportedSubdirTarget2 PROPERTY IMPORTED_GLOBAL FALSE)
+print_property(ImportedSubdirTarget2 IMPORTED_GLOBAL)
diff --git a/Tests/RunCMake/set_property/IMPORTED_GLOBAL/CMakeLists.txt b/Tests/RunCMake/set_property/IMPORTED_GLOBAL/CMakeLists.txt
new file mode 100644
index 000000000..468bf781c
--- /dev/null
+++ b/Tests/RunCMake/set_property/IMPORTED_GLOBAL/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_library(ImportedSubdirTarget1 SHARED IMPORTED GLOBAL)
+add_library(ImportedSubdirTarget2 SHARED IMPORTED)
+
+# Extend visibility of ImportedSubdirTarget2 to global scope.
+set_property(TARGET ImportedSubdirTarget2 PROPERTY IMPORTED_GLOBAL TRUE)
+
+# Only targets from the same directory can be promoted.
+set_property(TARGET ImportedLocalTarget2 PROPERTY IMPORTED_GLOBAL TRUE)
diff --git a/Tests/RunCMake/set_property/LINK_DIRECTORIES-stdout.txt b/Tests/RunCMake/set_property/LINK_DIRECTORIES-stdout.txt
new file mode 100644
index 000000000..580c3734f
--- /dev/null
+++ b/Tests/RunCMake/set_property/LINK_DIRECTORIES-stdout.txt
@@ -0,0 +1,2 @@
+-- Target LINK_DIRECTORIES is 'a;b;c;d;;e'
+-- Directory LINK_DIRECTORIES is 'a;b;c;d;;e'
diff --git a/Tests/RunCMake/set_property/LINK_DIRECTORIES.cmake b/Tests/RunCMake/set_property/LINK_DIRECTORIES.cmake
new file mode 100644
index 000000000..8529ef5b2
--- /dev/null
+++ b/Tests/RunCMake/set_property/LINK_DIRECTORIES.cmake
@@ -0,0 +1,3 @@
+include(Common.cmake)
+test_target_property(LINK_DIRECTORIES)
+test_directory_property(LINK_DIRECTORIES)
diff --git a/Tests/RunCMake/set_property/LINK_OPTIONS-stdout.txt b/Tests/RunCMake/set_property/LINK_OPTIONS-stdout.txt
new file mode 100644
index 000000000..033792a47
--- /dev/null
+++ b/Tests/RunCMake/set_property/LINK_OPTIONS-stdout.txt
@@ -0,0 +1,2 @@
+-- Target LINK_OPTIONS is 'a;b;c;d;;e'
+-- Directory LINK_OPTIONS is 'a;b;c;d;;e'
diff --git a/Tests/RunCMake/set_property/LINK_OPTIONS.cmake b/Tests/RunCMake/set_property/LINK_OPTIONS.cmake
new file mode 100644
index 000000000..6daf41b49
--- /dev/null
+++ b/Tests/RunCMake/set_property/LINK_OPTIONS.cmake
@@ -0,0 +1,3 @@
+include(Common.cmake)
+test_target_property(LINK_OPTIONS)
+test_directory_property(LINK_OPTIONS)
diff --git a/Tests/RunCMake/set_property/RunCMakeTest.cmake b/Tests/RunCMake/set_property/RunCMakeTest.cmake
index 1ddaceeab..8d4614c5d 100644
--- a/Tests/RunCMake/set_property/RunCMakeTest.cmake
+++ b/Tests/RunCMake/set_property/RunCMakeTest.cmake
@@ -3,8 +3,12 @@ include(RunCMake)
run_cmake(COMPILE_DEFINITIONS)
run_cmake(COMPILE_FEATURES)
run_cmake(COMPILE_OPTIONS)
+run_cmake(IMPORTED_GLOBAL)
run_cmake(INCLUDE_DIRECTORIES)
+run_cmake(LINK_OPTIONS)
+run_cmake(LINK_DIRECTORIES)
run_cmake(LINK_LIBRARIES)
run_cmake(SOURCES)
run_cmake(TYPE)
run_cmake(USER_PROP)
+run_cmake(USER_PROP_INHERITED)
diff --git a/Tests/RunCMake/set_property/USER_PROP_INHERITED-stdout.txt b/Tests/RunCMake/set_property/USER_PROP_INHERITED-stdout.txt
new file mode 100644
index 000000000..dcb0f875c
--- /dev/null
+++ b/Tests/RunCMake/set_property/USER_PROP_INHERITED-stdout.txt
@@ -0,0 +1,29 @@
+-- TopDir-to-nothing chaining: ''
+-- TopDir-to-global chaining: 'vGlobal'
+-- TopDir no chaining required: 'vTopDir'
+-- TopDir unset append chaining: 'aTopDir'
+-- TopDir preset append chaining: 'vTopDir;aTopDir'
+-- Subdir-to-parent chaining: 'vTopDir'
+-- Subdir-to-global chaining: 'vGlobal'
+-- Subdir no chaining required: 'vSubdir'
+-- Subdir preset append chaining: 'vSubdir;aSubdir'
+-- Subdir unset append chaining: 'aSubdir'
+-- Subdir undefined append chaining: 'aSubdir'
+-- Target-to-directory chaining: 'vTopDir'
+-- Target unset append chaining: 'aTarget'
+-- Target no chaining required: 'vTarget'
+-- Target preset append chaining: 'vTarget;aTarget'
+-- Target undefined get chaining: ''
+-- Target undefined append chaining: 'aTarget'
+-- Source-to-directory chaining: 'vTopDir'
+-- Source unset append chaining: 'aSource'
+-- Source no chaining required: 'vSource'
+-- Source preset append chaining: 'vSource;aSource'
+-- Source undefined get chaining: ''
+-- Source undefined append chaining: 'aSource'
+-- Test-to-directory chaining: 'vTopDir'
+-- Test unset append chaining: 'aTest'
+-- Test no chaining required: 'vTest'
+-- Test preset append chaining: 'vTest;aTest'
+-- Test undefined get chaining: ''
+-- Test undefined append chaining: 'aTest'
diff --git a/Tests/RunCMake/set_property/USER_PROP_INHERITED.cmake b/Tests/RunCMake/set_property/USER_PROP_INHERITED.cmake
new file mode 100644
index 000000000..2429866ed
--- /dev/null
+++ b/Tests/RunCMake/set_property/USER_PROP_INHERITED.cmake
@@ -0,0 +1,83 @@
+# Needed for source property tests
+enable_language(C)
+
+#=================================================
+# Directory property chaining
+#=================================================
+
+foreach(i RANGE 1 5)
+ foreach(propType DIRECTORY TARGET SOURCE TEST)
+ define_property(${propType} PROPERTY USER_PROP${i} INHERITED
+ BRIEF_DOCS "Brief" FULL_DOCS "Full"
+ )
+ endforeach()
+endforeach()
+
+get_property(val DIRECTORY PROPERTY USER_PROP1)
+message(STATUS "TopDir-to-nothing chaining: '${val}'")
+
+set_property(GLOBAL PROPERTY USER_PROP1 vGlobal)
+set_property(GLOBAL PROPERTY USER_PROP2 vGlobal)
+set_property(DIRECTORY PROPERTY USER_PROP2 vTopDir)
+set_property(GLOBAL PROPERTY USER_PROP3 vGlobal)
+set_property(DIRECTORY PROPERTY USER_PROP4 vTopDir)
+
+get_property(val DIRECTORY PROPERTY USER_PROP1)
+message(STATUS "TopDir-to-global chaining: '${val}'")
+
+get_property(val DIRECTORY PROPERTY USER_PROP2)
+message(STATUS "TopDir no chaining required: '${val}'")
+
+set_property(DIRECTORY APPEND PROPERTY USER_PROP3 aTopDir)
+get_property(val DIRECTORY PROPERTY USER_PROP3)
+message(STATUS "TopDir unset append chaining: '${val}'")
+
+set_property(DIRECTORY APPEND PROPERTY USER_PROP4 aTopDir)
+get_property(val DIRECTORY PROPERTY USER_PROP4)
+message(STATUS "TopDir preset append chaining: '${val}'")
+
+add_subdirectory(USER_PROP_INHERITED)
+
+#=================================================
+# The other property types all chain the same way
+#=================================================
+macro(__chainToDirTests propType)
+ string(TOUPPER ${propType} propTypeUpper)
+
+ get_property(val ${propTypeUpper} ${propType}1 PROPERTY USER_PROP2)
+ message(STATUS "${propType}-to-directory chaining: '${val}'")
+
+ set_property(${propTypeUpper} ${propType}1 APPEND PROPERTY USER_PROP2 a${propType})
+ get_property(val ${propTypeUpper} ${propType}1 PROPERTY USER_PROP2)
+ message(STATUS "${propType} unset append chaining: '${val}'")
+
+ set_property(${propTypeUpper} ${propType}1 PROPERTY USER_PROP1 v${propType})
+ get_property(val ${propTypeUpper} ${propType}1 PROPERTY USER_PROP1)
+ message(STATUS "${propType} no chaining required: '${val}'")
+
+ set_property(${propTypeUpper} ${propType}1 APPEND PROPERTY USER_PROP1 a${propType})
+ get_property(val ${propTypeUpper} ${propType}1 PROPERTY USER_PROP1)
+ message(STATUS "${propType} preset append chaining: '${val}'")
+
+ get_property(val ${propTypeUpper} ${propType}2 PROPERTY USER_PROP5)
+ message(STATUS "${propType} undefined get chaining: '${val}'")
+
+ set_property(${propTypeUpper} ${propType}2 APPEND PROPERTY USER_PROP5 a${propType})
+ get_property(val ${propTypeUpper} ${propType}2 PROPERTY USER_PROP5)
+ message(STATUS "${propType} undefined append chaining: '${val}'")
+endmacro()
+
+add_custom_target(Target1)
+add_custom_target(Target2)
+__chainToDirTests(Target)
+
+foreach(i RANGE 1 2)
+ set(Source${i} "${CMAKE_CURRENT_BINARY_DIR}/src${i}.c")
+ file(WRITE ${Source${i}} "int foo${i}() { return ${i}; }")
+endforeach()
+add_library(srcProps OBJECT ${Source1} ${Source2})
+__chainToDirTests(Source)
+
+add_test(NAME Test1 COMMAND ${CMAKE_COMMAND} -E touch_nocreate iDoNotExist)
+add_test(NAME Test2 COMMAND ${CMAKE_COMMAND} -E touch_nocreate iDoNotExist)
+__chainToDirTests(Test)
diff --git a/Tests/RunCMake/set_property/USER_PROP_INHERITED/CMakeLists.txt b/Tests/RunCMake/set_property/USER_PROP_INHERITED/CMakeLists.txt
new file mode 100644
index 000000000..234f4ee5d
--- /dev/null
+++ b/Tests/RunCMake/set_property/USER_PROP_INHERITED/CMakeLists.txt
@@ -0,0 +1,21 @@
+get_property(val DIRECTORY PROPERTY USER_PROP2)
+message(STATUS "Subdir-to-parent chaining: '${val}'")
+
+get_property(val DIRECTORY PROPERTY USER_PROP1)
+message(STATUS "Subdir-to-global chaining: '${val}'")
+
+set_property(DIRECTORY PROPERTY USER_PROP1 vSubdir)
+get_property(val DIRECTORY PROPERTY USER_PROP1)
+message(STATUS "Subdir no chaining required: '${val}'")
+
+set_property(DIRECTORY APPEND PROPERTY USER_PROP1 aSubdir)
+get_property(val DIRECTORY PROPERTY USER_PROP1)
+message(STATUS "Subdir preset append chaining: '${val}'")
+
+set_property(DIRECTORY APPEND PROPERTY USER_PROP2 aSubdir)
+get_property(val DIRECTORY PROPERTY USER_PROP2)
+message(STATUS "Subdir unset append chaining: '${val}'")
+
+set_property(DIRECTORY APPEND PROPERTY USER_PROP5 aSubdir)
+get_property(val DIRECTORY PROPERTY USER_PROP5)
+message(STATUS "Subdir undefined append chaining: '${val}'")
diff --git a/Tests/RunCMake/set_property/test.cpp b/Tests/RunCMake/set_property/test.cpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/Tests/RunCMake/set_property/test.cpp
diff --git a/Tests/RunCMake/string/AppendNoArgs-stderr.txt b/Tests/RunCMake/string/AppendNoArgs-stderr.txt
index 75ad427fd..9b7e9facd 100644
--- a/Tests/RunCMake/string/AppendNoArgs-stderr.txt
+++ b/Tests/RunCMake/string/AppendNoArgs-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at AppendNoArgs.cmake:1 \(string\):
string sub-command APPEND requires at least one argument.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/string/ConcatNoArgs-stderr.txt b/Tests/RunCMake/string/ConcatNoArgs-stderr.txt
index efea5f1d8..22b608dd7 100644
--- a/Tests/RunCMake/string/ConcatNoArgs-stderr.txt
+++ b/Tests/RunCMake/string/ConcatNoArgs-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at ConcatNoArgs.cmake:1 \(string\):
string sub-command CONCAT requires at least one argument.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/string/Join.cmake b/Tests/RunCMake/string/Join.cmake
new file mode 100644
index 000000000..081f1e4fc
--- /dev/null
+++ b/Tests/RunCMake/string/Join.cmake
@@ -0,0 +1,16 @@
+string(JOIN % out)
+if(NOT out STREQUAL "")
+ message(FATAL_ERROR "\"string(JOIN % out)\" set out to \"${out}\"")
+endif()
+string(JOIN % out a)
+if(NOT out STREQUAL "a")
+ message(FATAL_ERROR "\"string(JOIN % out a)\" set out to \"${out}\"")
+endif()
+string(JOIN % out a "b")
+if(NOT out STREQUAL "a%b")
+ message(FATAL_ERROR "\"string(JOIN % out a \"b\")\" set out to \"${out}\"")
+endif()
+string(JOIN :: out a "b")
+if(NOT out STREQUAL "a::b")
+ message(FATAL_ERROR "\"string(JOIN :: out a \"b\")\" set out to \"${out}\"")
+endif()
diff --git a/Tests/RunCMake/string/JoinNoArgs-result.txt b/Tests/RunCMake/string/JoinNoArgs-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/string/JoinNoArgs-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/string/JoinNoArgs-stderr.txt b/Tests/RunCMake/string/JoinNoArgs-stderr.txt
new file mode 100644
index 000000000..7fcd3524d
--- /dev/null
+++ b/Tests/RunCMake/string/JoinNoArgs-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at JoinNoArgs.cmake:1 \(string\):
+ string sub-command JOIN requires at least two arguments.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/string/JoinNoArgs.cmake b/Tests/RunCMake/string/JoinNoArgs.cmake
new file mode 100644
index 000000000..35ba4d9dd
--- /dev/null
+++ b/Tests/RunCMake/string/JoinNoArgs.cmake
@@ -0,0 +1 @@
+string(JOIN)
diff --git a/Tests/RunCMake/string/JoinNoVar-result.txt b/Tests/RunCMake/string/JoinNoVar-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/string/JoinNoVar-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/string/JoinNoVar-stderr.txt b/Tests/RunCMake/string/JoinNoVar-stderr.txt
new file mode 100644
index 000000000..b4a09c31c
--- /dev/null
+++ b/Tests/RunCMake/string/JoinNoVar-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at JoinNoVar.cmake:1 \(string\):
+ string sub-command JOIN requires at least two arguments.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/string/JoinNoVar.cmake b/Tests/RunCMake/string/JoinNoVar.cmake
new file mode 100644
index 000000000..35f7b9272
--- /dev/null
+++ b/Tests/RunCMake/string/JoinNoVar.cmake
@@ -0,0 +1 @@
+string(JOIN ";")
diff --git a/Tests/RunCMake/string/Prepend.cmake b/Tests/RunCMake/string/Prepend.cmake
new file mode 100644
index 000000000..8eaeebb46
--- /dev/null
+++ b/Tests/RunCMake/string/Prepend.cmake
@@ -0,0 +1,58 @@
+set(out)
+string(PREPEND out)
+if(DEFINED out)
+ message(FATAL_ERROR "\"string(PREPEND out)\" set out to \"${out}\"")
+endif()
+
+set(out "")
+string(PREPEND out)
+if(NOT out STREQUAL "")
+ message(FATAL_ERROR "\"string(PREPEND out)\" set out to \"${out}\"")
+endif()
+
+set(out x)
+string(PREPEND out)
+if(NOT out STREQUAL "x")
+ message(FATAL_ERROR "\"string(PREPEND out)\" set out to \"${out}\"")
+endif()
+
+
+set(out)
+string(PREPEND out a)
+if(NOT out STREQUAL "a")
+ message(FATAL_ERROR "\"string(PREPEND out a)\" set out to \"${out}\"")
+endif()
+
+set(out "")
+string(PREPEND out a)
+if(NOT out STREQUAL "a")
+ message(FATAL_ERROR "\"string(PREPEND out a)\" set out to \"${out}\"")
+endif()
+
+set(out x)
+string(PREPEND out a)
+if(NOT out STREQUAL "ax")
+ message(FATAL_ERROR "\"string(PREPEND out a)\" set out to \"${out}\"")
+endif()
+
+
+set(out x)
+string(PREPEND out a "b")
+if(NOT out STREQUAL "abx")
+ message(FATAL_ERROR "\"string(PREPEND out a \"b\")\" set out to \"${out}\"")
+endif()
+
+set(b)
+set(out x)
+string(PREPEND out ${b})
+if(NOT out STREQUAL "x")
+ message(FATAL_ERROR "\"string(PREPEND out \${b})\" set out to \"${out}\"")
+endif()
+
+set(b b)
+set(out x)
+string(PREPEND out a "${b}" [[
+${c}]])
+if(NOT out STREQUAL "ab\${c}x")
+ message(FATAL_ERROR "\"string(PREPEND out a \"\${b}\" [[\${c}]])\" set out to \"${out}\"")
+endif()
diff --git a/Tests/RunCMake/string/PrependNoArgs-result.txt b/Tests/RunCMake/string/PrependNoArgs-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/string/PrependNoArgs-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/string/PrependNoArgs-stderr.txt b/Tests/RunCMake/string/PrependNoArgs-stderr.txt
new file mode 100644
index 000000000..c8acba8f0
--- /dev/null
+++ b/Tests/RunCMake/string/PrependNoArgs-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at PrependNoArgs.cmake:1 \(string\):
+ string sub-command PREPEND requires at least one argument.
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/string/PrependNoArgs.cmake b/Tests/RunCMake/string/PrependNoArgs.cmake
new file mode 100644
index 000000000..f324f2854
--- /dev/null
+++ b/Tests/RunCMake/string/PrependNoArgs.cmake
@@ -0,0 +1 @@
+string(PREPEND)
diff --git a/Tests/RunCMake/string/RegexMultiMatchClear-stderr.txt b/Tests/RunCMake/string/RegexMultiMatchClear-stderr.txt
new file mode 100644
index 000000000..4360d79c1
--- /dev/null
+++ b/Tests/RunCMake/string/RegexMultiMatchClear-stderr.txt
@@ -0,0 +1,12 @@
+^matches: Some::;Scope
+results from: string\(REGEX MATCHALL\)
+CMAKE_MATCH_0: -->Scope<--
+CMAKE_MATCH_1: -->Scope<--
+CMAKE_MATCH_2: --><--
+CMAKE_MATCH_COUNT: -->1<--
+replace: \[Some\]\[Scope\]
+results from: string\(REGEX REPLACE\)
+CMAKE_MATCH_0: -->Scope<--
+CMAKE_MATCH_1: -->Scope<--
+CMAKE_MATCH_2: --><--
+CMAKE_MATCH_COUNT: -->1<--$
diff --git a/Tests/RunCMake/string/RegexMultiMatchClear.cmake b/Tests/RunCMake/string/RegexMultiMatchClear.cmake
new file mode 100644
index 000000000..80b6b3c7b
--- /dev/null
+++ b/Tests/RunCMake/string/RegexMultiMatchClear.cmake
@@ -0,0 +1,20 @@
+cmake_minimum_required (VERSION 3.0)
+project (RegexClear NONE)
+
+function (output_results msg)
+ message("results from: ${msg}")
+ message("CMAKE_MATCH_0: -->${CMAKE_MATCH_0}<--")
+ message("CMAKE_MATCH_1: -->${CMAKE_MATCH_1}<--")
+ message("CMAKE_MATCH_2: -->${CMAKE_MATCH_2}<--")
+ message("CMAKE_MATCH_COUNT: -->${CMAKE_MATCH_COUNT}<--")
+endfunction ()
+
+set(haystack "Some::Scope")
+
+string(REGEX MATCHALL "^([^:]+)(::)?" matches "${haystack}")
+message("matches: ${matches}")
+output_results("string(REGEX MATCHALL)")
+
+string(REGEX REPLACE "^([^:]+)(::)?" "[\\1]" replace "${haystack}")
+message("replace: ${replace}")
+output_results("string(REGEX REPLACE)")
diff --git a/Tests/RunCMake/string/Repeat.cmake b/Tests/RunCMake/string/Repeat.cmake
new file mode 100644
index 000000000..fc390aa62
--- /dev/null
+++ b/Tests/RunCMake/string/Repeat.cmake
@@ -0,0 +1,45 @@
+string(REPEAT "q" 4 q_out)
+
+if(NOT DEFINED q_out)
+ message(FATAL_ERROR "q_out is not defined")
+endif()
+
+if(NOT q_out STREQUAL "qqqq")
+ message(FATAL_ERROR "unexpected result")
+endif()
+
+string(REPEAT "1234" 0 zero_out)
+
+if(NOT DEFINED zero_out)
+ message(FATAL_ERROR "zero_out is not defined")
+endif()
+
+if(NOT zero_out STREQUAL "")
+ message(FATAL_ERROR "unexpected result")
+endif()
+
+unset(zero_out)
+
+string(REPEAT "" 100 zero_out)
+
+if(NOT DEFINED zero_out)
+ message(FATAL_ERROR "zero_out is not defined")
+endif()
+
+if(NOT zero_out STREQUAL "")
+ message(FATAL_ERROR "unexpected result")
+endif()
+
+string(REPEAT "1" 1 one_out)
+
+if(NOT one_out STREQUAL "1")
+ message(FATAL_ERROR "unexpected result")
+endif()
+
+unset(one_out)
+
+string(REPEAT "one" 1 one_out)
+
+if(NOT one_out STREQUAL "one")
+ message(FATAL_ERROR "unexpected result")
+endif()
diff --git a/Tests/RunCMake/string/RepeatNegativeCount-result.txt b/Tests/RunCMake/string/RepeatNegativeCount-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/string/RepeatNegativeCount-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/string/RepeatNegativeCount-stderr.txt b/Tests/RunCMake/string/RepeatNegativeCount-stderr.txt
new file mode 100644
index 000000000..bbd498eee
--- /dev/null
+++ b/Tests/RunCMake/string/RepeatNegativeCount-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at RepeatNegativeCount.cmake:[0-9]+ \(string\):
+ repeat count is not a positive number.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/string/RepeatNegativeCount.cmake b/Tests/RunCMake/string/RepeatNegativeCount.cmake
new file mode 100644
index 000000000..769e7c0a1
--- /dev/null
+++ b/Tests/RunCMake/string/RepeatNegativeCount.cmake
@@ -0,0 +1 @@
+string(REPEAT "blah" -1 out)
diff --git a/Tests/RunCMake/string/RepeatNoArgs-result.txt b/Tests/RunCMake/string/RepeatNoArgs-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/string/RepeatNoArgs-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/string/RepeatNoArgs-stderr.txt b/Tests/RunCMake/string/RepeatNoArgs-stderr.txt
new file mode 100644
index 000000000..5abcb3be7
--- /dev/null
+++ b/Tests/RunCMake/string/RepeatNoArgs-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at RepeatNoArgs.cmake:[0-9]+ \(string\):
+ sub-command REPEAT requires three arguments.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/string/RepeatNoArgs.cmake b/Tests/RunCMake/string/RepeatNoArgs.cmake
new file mode 100644
index 000000000..e327e998e
--- /dev/null
+++ b/Tests/RunCMake/string/RepeatNoArgs.cmake
@@ -0,0 +1 @@
+string(REPEAT)
diff --git a/Tests/RunCMake/string/RunCMakeTest.cmake b/Tests/RunCMake/string/RunCMakeTest.cmake
index 38a77b0d1..c432b4ed5 100644
--- a/Tests/RunCMake/string/RunCMakeTest.cmake
+++ b/Tests/RunCMake/string/RunCMakeTest.cmake
@@ -3,9 +3,16 @@ include(RunCMake)
run_cmake(Append)
run_cmake(AppendNoArgs)
+run_cmake(Prepend)
+run_cmake(PrependNoArgs)
+
run_cmake(Concat)
run_cmake(ConcatNoArgs)
+run_cmake(Join)
+run_cmake(JoinNoArgs)
+run_cmake(JoinNoVar)
+
run_cmake(Timestamp)
run_cmake(TimestampEmpty)
run_cmake(TimestampInvalid)
@@ -20,8 +27,13 @@ run_cmake(UuidMissingTypeValue)
run_cmake(UuidBadType)
run_cmake(RegexClear)
+run_cmake(RegexMultiMatchClear)
run_cmake(UTF-16BE)
run_cmake(UTF-16LE)
run_cmake(UTF-32BE)
run_cmake(UTF-32LE)
+
+run_cmake(Repeat)
+run_cmake(RepeatNoArgs)
+run_cmake(RepeatNegativeCount)
diff --git a/Tests/RunCMake/string/Timestamp-stderr.txt b/Tests/RunCMake/string/Timestamp-stderr.txt
index 653974c62..cd4dcb37e 100644
--- a/Tests/RunCMake/string/Timestamp-stderr.txt
+++ b/Tests/RunCMake/string/Timestamp-stderr.txt
@@ -1 +1 @@
-RESULT=2005-08-07 23:19:49 Sun Aug 05 day=219 wd=0 week=32 %I=11 epoch=1123456789
+RESULT=2005-08-07 23:19:49 Sunday=Sun August=Aug 05 day=219 wd=0 week=32 %I=11 epoch=1123456789
diff --git a/Tests/RunCMake/string/Timestamp.cmake b/Tests/RunCMake/string/Timestamp.cmake
index d24203942..cba258d12 100644
--- a/Tests/RunCMake/string/Timestamp.cmake
+++ b/Tests/RunCMake/string/Timestamp.cmake
@@ -1,3 +1,3 @@
set(ENV{SOURCE_DATE_EPOCH} "1123456789")
-string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S %a %b %y day=%j wd=%w week=%U %%I=%I epoch=%s" UTC)
+string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S %A=%a %B=%b %y day=%j wd=%w week=%U %%I=%I epoch=%s" UTC)
message("RESULT=${RESULT}")
diff --git a/Tests/RunCMake/string/UuidBadNamespace-stderr.txt b/Tests/RunCMake/string/UuidBadNamespace-stderr.txt
index cb12903e1..340189b9f 100644
--- a/Tests/RunCMake/string/UuidBadNamespace-stderr.txt
+++ b/Tests/RunCMake/string/UuidBadNamespace-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at UuidBadNamespace.cmake:3 \(string\):
string UUID sub-command, malformed NAMESPACE UUID.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/string/UuidBadType-stderr.txt b/Tests/RunCMake/string/UuidBadType-stderr.txt
index 1993c044a..2734d86a6 100644
--- a/Tests/RunCMake/string/UuidBadType-stderr.txt
+++ b/Tests/RunCMake/string/UuidBadType-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at UuidBadType.cmake:3 \(string\):
string UUID sub-command, unknown TYPE 'FOO'.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/string/UuidMissingNameValue-stderr.txt b/Tests/RunCMake/string/UuidMissingNameValue-stderr.txt
index 0b7cde463..79819a97d 100644
--- a/Tests/RunCMake/string/UuidMissingNameValue-stderr.txt
+++ b/Tests/RunCMake/string/UuidMissingNameValue-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at UuidMissingNameValue.cmake:3 \(string\):
string UUID sub-command, NAME requires a value.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/string/UuidMissingNamespace-stderr.txt b/Tests/RunCMake/string/UuidMissingNamespace-stderr.txt
index dfcfe42b2..1ffc53fe0 100644
--- a/Tests/RunCMake/string/UuidMissingNamespace-stderr.txt
+++ b/Tests/RunCMake/string/UuidMissingNamespace-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at UuidMissingNamespace.cmake:3 \(string\):
string UUID sub-command, malformed NAMESPACE UUID.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/string/UuidMissingNamespaceValue-stderr.txt b/Tests/RunCMake/string/UuidMissingNamespaceValue-stderr.txt
index 86585ad40..2a73d3f0c 100644
--- a/Tests/RunCMake/string/UuidMissingNamespaceValue-stderr.txt
+++ b/Tests/RunCMake/string/UuidMissingNamespaceValue-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at UuidMissingNamespaceValue.cmake:3 \(string\):
string UUID sub-command, NAMESPACE requires a value.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/string/UuidMissingTypeValue-stderr.txt b/Tests/RunCMake/string/UuidMissingTypeValue-stderr.txt
index 70252f8cd..44bd479cd 100644
--- a/Tests/RunCMake/string/UuidMissingTypeValue-stderr.txt
+++ b/Tests/RunCMake/string/UuidMissingTypeValue-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at UuidMissingTypeValue.cmake:3 \(string\):
string UUID sub-command, TYPE requires a value.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_compile_definitions/CMakeLists.txt b/Tests/RunCMake/target_compile_definitions/CMakeLists.txt
new file mode 100644
index 000000000..14ef56e8e
--- /dev/null
+++ b/Tests/RunCMake/target_compile_definitions/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.11)
+
+project(${RunCMake_TEST} LANGUAGES NONE)
+
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/target_compile_definitions/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_definitions/RunCMakeTest.cmake
new file mode 100644
index 000000000..a419cc972
--- /dev/null
+++ b/Tests/RunCMake/target_compile_definitions/RunCMakeTest.cmake
@@ -0,0 +1,4 @@
+include(RunCMake)
+
+run_cmake(empty_keyword_args)
+run_cmake(unknown_imported_target)
diff --git a/Tests/RunCMake/target_compile_definitions/empty_keyword_args.cmake b/Tests/RunCMake/target_compile_definitions/empty_keyword_args.cmake
new file mode 100644
index 000000000..cb94e87be
--- /dev/null
+++ b/Tests/RunCMake/target_compile_definitions/empty_keyword_args.cmake
@@ -0,0 +1,5 @@
+add_library(iface INTERFACE)
+target_compile_definitions(iface PUBLIC PRIVATE INTERFACE)
+# Cannot be called with non-compilable targets.
+#add_library(imported UNKNOWN IMPORTED)
+#target_compile_definitions(imported PUBLIC PRIVATE INTERFACE)
diff --git a/Tests/RunCMake/target_compile_definitions/unknown_imported_target.cmake b/Tests/RunCMake/target_compile_definitions/unknown_imported_target.cmake
new file mode 100644
index 000000000..4ae1c0dd7
--- /dev/null
+++ b/Tests/RunCMake/target_compile_definitions/unknown_imported_target.cmake
@@ -0,0 +1,11 @@
+# Test that target_compile_definitions works on UNKNOWN IMPORTED target
+add_library(imported UNKNOWN IMPORTED)
+target_compile_definitions(imported INTERFACE FOO)
+
+get_target_property(IMPORTED_INTERFACE_CDS imported INTERFACE_COMPILE_DEFINITIONS)
+
+if (NOT FOO IN_LIST IMPORTED_INTERFACE_CDS)
+ message(
+ FATAL_ERROR "FOO should be in INTERFACE_COMPILE_DEFINITIONS.\n"
+ "Actual INTERFACE_COMPILE_DEFINITIONS: " ${IMPORTED_INTERFACE_CDS})
+endif()
diff --git a/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake
index 1f67f11a0..f8b08094b 100644
--- a/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake
@@ -12,3 +12,4 @@ run_cmake(no_matching_cxx_feature)
run_cmake(not_a_c_feature)
run_cmake(no_matching_c_feature)
run_cmake(cxx_not_enabled)
+run_cmake(empty_keyword_args)
diff --git a/Tests/RunCMake/target_compile_features/alias_target-stderr.txt b/Tests/RunCMake/target_compile_features/alias_target-stderr.txt
index 5ebe170c3..1658f58df 100644
--- a/Tests/RunCMake/target_compile_features/alias_target-stderr.txt
+++ b/Tests/RunCMake/target_compile_features/alias_target-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at alias_target.cmake:[0-9]+ \(target_compile_features\):
target_compile_features can not be used on an ALIAS target.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt b/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt
index 4f707c7b9..5b4761c60 100644
--- a/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt
+++ b/Tests/RunCMake/target_compile_features/cxx_not_enabled-stderr.txt
@@ -1,4 +1,4 @@
^CMake Error at cxx_not_enabled.cmake:[0-9]+ \(target_compile_features\):
target_compile_features cannot use features from non-enabled language CXX
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)$
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/target_compile_features/empty_keyword_args.cmake b/Tests/RunCMake/target_compile_features/empty_keyword_args.cmake
new file mode 100644
index 000000000..8d57c1cac
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/empty_keyword_args.cmake
@@ -0,0 +1,5 @@
+add_library(iface INTERFACE)
+target_compile_features(iface PUBLIC PRIVATE INTERFACE)
+# Cannot be called with non-compilable targets.
+#add_library(imported UNKNOWN IMPORTED)
+#target_compile_features(imported PUBLIC PRIVATE INTERFACE)
diff --git a/Tests/RunCMake/target_compile_features/imported_target-stderr.txt b/Tests/RunCMake/target_compile_features/imported_target-stderr.txt
index 7a07427a0..f2a1aba9c 100644
--- a/Tests/RunCMake/target_compile_features/imported_target-stderr.txt
+++ b/Tests/RunCMake/target_compile_features/imported_target-stderr.txt
@@ -1,4 +1,5 @@
-CMake Error at imported_target.cmake:[0-9]+ \(target_compile_features\):
- Cannot specify compile features for imported target "main".
+^CMake Error at imported_target.cmake:[0-9]+ \(target_compile_features\):
+ target_compile_features may only set INTERFACE properties on INTERFACE
+ targets
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/target_compile_features/imported_target.cmake b/Tests/RunCMake/target_compile_features/imported_target.cmake
index e886ce922..e410ace2a 100644
--- a/Tests/RunCMake/target_compile_features/imported_target.cmake
+++ b/Tests/RunCMake/target_compile_features/imported_target.cmake
@@ -1,4 +1,10 @@
enable_language(CXX)
-add_library(main INTERFACE IMPORTED)
-target_compile_features(main INTERFACE cxx_delegating_constructors)
+add_library(lib1-interface INTERFACE IMPORTED)
+target_compile_features(lib1-interface INTERFACE cxx_delegating_constructors)
+
+add_library(lib2-interface INTERFACE IMPORTED)
+target_compile_features(lib2-interface PUBLIC cxx_delegating_constructors)
+
+add_library(lib-shared SHARED IMPORTED)
+target_compile_features(lib-shared INTERFACE cxx_delegating_constructors)
diff --git a/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt b/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt
index 9917be77a..ee57b5484 100644
--- a/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt
+++ b/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at invalid_args.cmake:[0-9]+ \(target_compile_features\):
target_compile_features called with invalid arguments
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt
index 37089983a..d6564f4c0 100644
--- a/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt
+++ b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt
@@ -1,5 +1,5 @@
CMake Error at invalid_args_on_interface.cmake:[0-9]+ \(target_compile_features\):
- target_compile_features may only be set INTERFACE properties on INTERFACE
+ target_compile_features may only set INTERFACE properties on INTERFACE
targets
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt b/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt
index 1875d1209..07ddd6a55 100644
--- a/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt
+++ b/Tests/RunCMake/target_compile_features/no_matching_c_feature-stderr.txt
@@ -5,4 +5,4 @@ CMake Error at no_matching_c_feature.cmake:[0-9]+ \((target_compile_features|mes
version 4.8.1.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt
index 90d41c957..9392f4b25 100644
--- a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt
+++ b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt
@@ -5,4 +5,4 @@ CMake Error at no_matching_cxx_feature.cmake:[0-9]+ \((target_compile_features|m
version *[.0-9]+\.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_compile_features/no_target-stderr.txt b/Tests/RunCMake/target_compile_features/no_target-stderr.txt
index 65974b4d6..7b62c947e 100644
--- a/Tests/RunCMake/target_compile_features/no_target-stderr.txt
+++ b/Tests/RunCMake/target_compile_features/no_target-stderr.txt
@@ -2,4 +2,4 @@ CMake Error at no_target.cmake:[0-9]+ \(target_compile_features\):
Cannot specify compile features for target "main" which is not built by
this project.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt b/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt
index 493c5826c..8a4055d07 100644
--- a/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt
+++ b/Tests/RunCMake/target_compile_features/not_a_c_feature-stderr.txt
@@ -2,4 +2,4 @@ CMake Error at not_a_c_feature.cmake:[0-9]+ \(target_compile_features\):
target_compile_features specified unknown feature "c_not_a_feature" for
target "main".
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt
index 3dbf0e654..bd7f2c6b4 100644
--- a/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt
+++ b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt
@@ -2,4 +2,4 @@ CMake Error at not_a_cxx_feature.cmake:[0-9]+ \(target_compile_features\):
target_compile_features specified unknown feature "cxx_not_a_feature" for
target "main".
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt b/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt
index c0c2efac4..34f1ce222 100644
--- a/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt
+++ b/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at not_enough_args.cmake:[0-9]+ \(target_compile_features\):
target_compile_features called with incorrect number of arguments
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_compile_features/utility_target-stderr.txt b/Tests/RunCMake/target_compile_features/utility_target-stderr.txt
index ff03310d1..0c01377fa 100644
--- a/Tests/RunCMake/target_compile_features/utility_target-stderr.txt
+++ b/Tests/RunCMake/target_compile_features/utility_target-stderr.txt
@@ -1,4 +1,4 @@
CMake Error at utility_target.cmake:[0-9]+ \(target_compile_features\):
target_compile_features called with non-compilable target type
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_compile_options/CMakeLists.txt b/Tests/RunCMake/target_compile_options/CMakeLists.txt
new file mode 100644
index 000000000..14ef56e8e
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.11)
+
+project(${RunCMake_TEST} LANGUAGES NONE)
+
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake
new file mode 100644
index 000000000..b67c5983e
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(empty_keyword_args)
diff --git a/Tests/RunCMake/target_compile_options/empty_keyword_args.cmake b/Tests/RunCMake/target_compile_options/empty_keyword_args.cmake
new file mode 100644
index 000000000..8b92fcf16
--- /dev/null
+++ b/Tests/RunCMake/target_compile_options/empty_keyword_args.cmake
@@ -0,0 +1,5 @@
+add_library(iface INTERFACE)
+target_compile_options(iface PUBLIC PRIVATE INTERFACE)
+# Cannot be called with non-compilable targets.
+#add_library(imported UNKNOWN IMPORTED)
+#target_compile_options(imported PUBLIC PRIVATE INTERFACE)
diff --git a/Tests/RunCMake/target_include_directories/CMakeLists.txt b/Tests/RunCMake/target_include_directories/CMakeLists.txt
new file mode 100644
index 000000000..14ef56e8e
--- /dev/null
+++ b/Tests/RunCMake/target_include_directories/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.11)
+
+project(${RunCMake_TEST} LANGUAGES NONE)
+
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/target_include_directories/RunCMakeTest.cmake b/Tests/RunCMake/target_include_directories/RunCMakeTest.cmake
new file mode 100644
index 000000000..b67c5983e
--- /dev/null
+++ b/Tests/RunCMake/target_include_directories/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(empty_keyword_args)
diff --git a/Tests/RunCMake/target_include_directories/empty_keyword_args.cmake b/Tests/RunCMake/target_include_directories/empty_keyword_args.cmake
new file mode 100644
index 000000000..08eaf9157
--- /dev/null
+++ b/Tests/RunCMake/target_include_directories/empty_keyword_args.cmake
@@ -0,0 +1,5 @@
+add_library(iface INTERFACE)
+target_include_directories(iface PUBLIC PRIVATE INTERFACE)
+# Cannot be called with non-compilable targets.
+#add_library(imported UNKNOWN IMPORTED)
+#target_include_directories(imported PUBLIC PRIVATE INTERFACE)
diff --git a/Tests/RunCMake/target_link_directories/CMakeLists.txt b/Tests/RunCMake/target_link_directories/CMakeLists.txt
new file mode 100644
index 000000000..14ef56e8e
--- /dev/null
+++ b/Tests/RunCMake/target_link_directories/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.11)
+
+project(${RunCMake_TEST} LANGUAGES NONE)
+
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/target_link_directories/RunCMakeTest.cmake b/Tests/RunCMake/target_link_directories/RunCMakeTest.cmake
new file mode 100644
index 000000000..b67c5983e
--- /dev/null
+++ b/Tests/RunCMake/target_link_directories/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(empty_keyword_args)
diff --git a/Tests/RunCMake/target_link_directories/empty_keyword_args.cmake b/Tests/RunCMake/target_link_directories/empty_keyword_args.cmake
new file mode 100644
index 000000000..aadf80a04
--- /dev/null
+++ b/Tests/RunCMake/target_link_directories/empty_keyword_args.cmake
@@ -0,0 +1,5 @@
+add_library(iface INTERFACE)
+target_link_directories(iface PUBLIC PRIVATE INTERFACE)
+# Cannot be called with non-compilable targets.
+#add_library(imported UNKNOWN IMPORTED)
+#target_link_directories(imported PUBLIC PRIVATE INTERFACE)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt
index 8e3f3153b..12c00fb01 100644
--- a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-2-stderr.txt
@@ -8,4 +8,4 @@ CMake Error at CMP0023-NEW-2.cmake:11 \(target_link_libraries\):
\* CMP0023-NEW-2.cmake:10 \(target_link_libraries\)
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt
index 2ef229034..117c80614 100644
--- a/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-NEW-stderr.txt
@@ -8,4 +8,4 @@ CMake Error at CMP0023-NEW.cmake:11 \(target_link_libraries\):
\* CMP0023-NEW.cmake:10 \(target_link_libraries\)
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt
index 514786154..7e49d525e 100644
--- a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-2-stderr.txt
@@ -13,4 +13,4 @@ CMake Warning \(dev\) at CMP0023-WARN-2.cmake:9 \(target_link_libraries\):
\* CMP0023-WARN-2.cmake:8 \(target_link_libraries\)
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt
index a7474fac9..df1288e35 100644
--- a/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt
+++ b/Tests/RunCMake/target_link_libraries/CMP0023-WARN-stderr.txt
@@ -13,4 +13,4 @@ CMake Warning \(dev\) at CMP0023-WARN.cmake:9 \(target_link_libraries\):
\* CMP0023-WARN.cmake:8 \(target_link_libraries\)
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface-NEW-stdout.txt b/Tests/RunCMake/target_link_libraries/CMP0079-iface-NEW-stdout.txt
new file mode 100644
index 000000000..89cd80633
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface-NEW-stdout.txt
@@ -0,0 +1 @@
+-- INTERFACE_LINK_LIBRARIES='foo::@<[Xx0-9A-Fa-f]+>'
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface-NEW.cmake b/Tests/RunCMake/target_link_libraries/CMP0079-iface-NEW.cmake
new file mode 100644
index 000000000..82486c42c
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0079 NEW)
+include(CMP0079-iface-common.cmake)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface-OLD-stdout.txt b/Tests/RunCMake/target_link_libraries/CMP0079-iface-OLD-stdout.txt
new file mode 100644
index 000000000..e575e1675
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface-OLD-stdout.txt
@@ -0,0 +1 @@
+-- INTERFACE_LINK_LIBRARIES='foo'
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface-OLD.cmake b/Tests/RunCMake/target_link_libraries/CMP0079-iface-OLD.cmake
new file mode 100644
index 000000000..e04a2bb53
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0079 OLD)
+include(CMP0079-iface-common.cmake)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stderr.txt
new file mode 100644
index 000000000..6dd7d3069
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stderr.txt
@@ -0,0 +1,17 @@
+^CMake Warning \(dev\) at CMP0079-iface/CMakeLists.txt:[0-9]+ \(target_link_libraries\):
+ Policy CMP0079 is not set: target_link_libraries allows use with targets in
+ other directories. Run "cmake --help-policy CMP0079" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ Target
+
+ top
+
+ is not created in this directory. For compatibility with older versions of
+ CMake, link library
+
+ foo
+
+ will be looked up in the directory in which the target was created rather
+ than in this calling directory.
+This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stdout.txt b/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stdout.txt
new file mode 100644
index 000000000..e575e1675
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN-stdout.txt
@@ -0,0 +1 @@
+-- INTERFACE_LINK_LIBRARIES='foo'
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN.cmake b/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN.cmake
new file mode 100644
index 000000000..2041893c8
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface-WARN.cmake
@@ -0,0 +1 @@
+include(CMP0079-iface-common.cmake)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface-common.cmake b/Tests/RunCMake/target_link_libraries/CMP0079-iface-common.cmake
new file mode 100644
index 000000000..3982ff264
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface-common.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+
+add_executable(top empty.c)
+add_subdirectory(CMP0079-iface)
+get_property(libs TARGET top PROPERTY INTERFACE_LINK_LIBRARIES)
+message(STATUS "INTERFACE_LINK_LIBRARIES='${libs}'")
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-iface/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/CMP0079-iface/CMakeLists.txt
new file mode 100644
index 000000000..4b15b329b
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-iface/CMakeLists.txt
@@ -0,0 +1 @@
+target_link_libraries(top INTERFACE foo)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-result.txt b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt
new file mode 100644
index 000000000..8ef35c1dc
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt
@@ -0,0 +1,6 @@
+^CMake Error at CMP0079-link-NEW-bogus.cmake:[0-9]+ \(add_executable\):
+ Target "top" links to target "foo::@<0xdeadbeef>" but the target was not
+ found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
+ an ALIAS target is missing\?
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus.cmake b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus.cmake
new file mode 100644
index 000000000..8622f14e7
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus.cmake
@@ -0,0 +1,6 @@
+cmake_policy(SET CMP0028 NEW)
+cmake_policy(SET CMP0079 NEW)
+enable_language(C)
+
+add_executable(top empty.c)
+set_property(TARGET top APPEND PROPERTY LINK_LIBRARIES "foo::@<0xdeadbeef>")
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-stdout.txt b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-stdout.txt
new file mode 100644
index 000000000..84b30bd0a
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-stdout.txt
@@ -0,0 +1 @@
+-- LINK_LIBRARIES='foo::@<[Xx0-9A-Fa-f]+>'
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW.cmake b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW.cmake
new file mode 100644
index 000000000..72e457494
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0079 NEW)
+include(CMP0079-link-common.cmake)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-OLD-result.txt b/Tests/RunCMake/target_link_libraries/CMP0079-link-OLD-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-OLD-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-OLD-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0079-link-OLD-stderr.txt
new file mode 100644
index 000000000..0b4c4c683
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-OLD-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at CMP0079-link/CMakeLists.txt:[0-9]+ \(target_link_libraries\):
+ Attempt to add link library "foo" to target "top" which is not built in
+ this directory.
+
+ This is allowed only when policy CMP0079 is set to NEW.$
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-OLD.cmake b/Tests/RunCMake/target_link_libraries/CMP0079-link-OLD.cmake
new file mode 100644
index 000000000..caa7231b7
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0079 OLD)
+include(CMP0079-link-common.cmake)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-WARN-result.txt b/Tests/RunCMake/target_link_libraries/CMP0079-link-WARN-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-WARN-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-WARN-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0079-link-WARN-stderr.txt
new file mode 100644
index 000000000..0b4c4c683
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-WARN-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at CMP0079-link/CMakeLists.txt:[0-9]+ \(target_link_libraries\):
+ Attempt to add link library "foo" to target "top" which is not built in
+ this directory.
+
+ This is allowed only when policy CMP0079 is set to NEW.$
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-WARN.cmake b/Tests/RunCMake/target_link_libraries/CMP0079-link-WARN.cmake
new file mode 100644
index 000000000..e83818a9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-WARN.cmake
@@ -0,0 +1 @@
+include(CMP0079-link-common.cmake)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-common.cmake b/Tests/RunCMake/target_link_libraries/CMP0079-link-common.cmake
new file mode 100644
index 000000000..4f9454f0a
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-common.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+
+add_executable(top empty.c)
+add_subdirectory(CMP0079-link)
+get_property(libs TARGET top PROPERTY LINK_LIBRARIES)
+message(STATUS "LINK_LIBRARIES='${libs}'")
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/CMP0079-link/CMakeLists.txt
new file mode 100644
index 000000000..8b2b3c94f
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link/CMakeLists.txt
@@ -0,0 +1 @@
+target_link_libraries(top PUBLIC foo)
diff --git a/Tests/RunCMake/target_link_libraries/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/CMakeLists.txt
index 12cd3c775..8f85fbf54 100644
--- a/Tests/RunCMake/target_link_libraries/CMakeLists.txt
+++ b/Tests/RunCMake/target_link_libraries/CMakeLists.txt
@@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 2.8.4)
project(${RunCMake_TEST} NONE)
-include(${RunCMake_TEST}.cmake)
+include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)
diff --git a/Tests/RunCMake/target_link_libraries/ImportedTarget.cmake b/Tests/RunCMake/target_link_libraries/ImportedTarget.cmake
new file mode 100644
index 000000000..e5ec3f6b6
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/ImportedTarget.cmake
@@ -0,0 +1,2 @@
+add_library(UnknownImportedGlobal UNKNOWN IMPORTED GLOBAL)
+target_link_libraries(UnknownImportedGlobal INTERFACE z)
diff --git a/Tests/RunCMake/target_link_libraries/ImportedTargetFailure-result.txt b/Tests/RunCMake/target_link_libraries/ImportedTargetFailure-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/ImportedTargetFailure-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_link_libraries/ImportedTargetFailure-stderr.txt b/Tests/RunCMake/target_link_libraries/ImportedTargetFailure-stderr.txt
new file mode 100644
index 000000000..1cafa5b5e
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/ImportedTargetFailure-stderr.txt
@@ -0,0 +1,5 @@
+^CMake Error at ImportedTargetFailure.cmake:[0-9]+ \(target_link_libraries\):
+ IMPORTED library can only be used with the INTERFACE keyword of
+ target_link_libraries
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/target_link_libraries/ImportedTargetFailure.cmake b/Tests/RunCMake/target_link_libraries/ImportedTargetFailure.cmake
new file mode 100644
index 000000000..3ac0aa981
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/ImportedTargetFailure.cmake
@@ -0,0 +1,2 @@
+add_library(UnknownImportedGlobal UNKNOWN IMPORTED GLOBAL)
+target_link_libraries(UnknownImportedGlobal PRIVATE z)
diff --git a/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt b/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt
index a0c66dbe2..5b0caf757 100644
--- a/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt
+++ b/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt
@@ -1,5 +1,5 @@
CMake Error at MixedSignature.cmake:6 \(target_link_libraries\):
- The PUBLIC or PRIVATE option must appear as the second argument, just after
- the target name.
+ The INTERFACE, PUBLIC or PRIVATE option must appear as the second argument,
+ just after the target name.
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
index 1466fbf61..0152d4c67 100644
--- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake
@@ -4,9 +4,19 @@ run_cmake(CMP0023-WARN)
run_cmake(CMP0023-NEW)
run_cmake(CMP0023-WARN-2)
run_cmake(CMP0023-NEW-2)
+run_cmake(CMP0079-iface-WARN)
+run_cmake(CMP0079-iface-OLD)
+run_cmake(CMP0079-iface-NEW)
+run_cmake(CMP0079-link-WARN)
+run_cmake(CMP0079-link-OLD)
+run_cmake(CMP0079-link-NEW)
+run_cmake(CMP0079-link-NEW-bogus)
+run_cmake(ImportedTarget)
+run_cmake(ImportedTargetFailure)
run_cmake(MixedSignature)
run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses)
-run_cmake(SubDirTarget)
run_cmake(SharedDepNotTarget)
run_cmake(StaticPrivateDepNotExported)
run_cmake(StaticPrivateDepNotTarget)
+run_cmake(UNKNOWN-IMPORTED-GLOBAL)
+run_cmake(empty_keyword_args)
diff --git a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-stderr.txt b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-stderr.txt
index 6bb44ab4b..32042254d 100644
--- a/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-stderr.txt
+++ b/Tests/RunCMake/target_link_libraries/StaticPrivateDepNotExported-stderr.txt
@@ -1 +1 @@
-CMake Error: install\(EXPORT "Exp" ...\) includes target "foo" which requires target "not_exported" that is not in the export set.
+CMake Error: install\(EXPORT "Exp" ...\) includes target "foo" which requires target "not_exported" that is not in any export set.
diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget-stderr.txt b/Tests/RunCMake/target_link_libraries/SubDirTarget-stderr.txt
deleted file mode 100644
index 5cd1f23d7..000000000
--- a/Tests/RunCMake/target_link_libraries/SubDirTarget-stderr.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-^CMake Error at SubDirTarget.cmake:[0-9]+ \(target_link_libraries\):
- Attempt to add link library "m" to target "subexe" which is not built in
- this directory.
-Call Stack \(most recent call first\):
- CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget.cmake b/Tests/RunCMake/target_link_libraries/SubDirTarget.cmake
deleted file mode 100644
index 32431cecc..000000000
--- a/Tests/RunCMake/target_link_libraries/SubDirTarget.cmake
+++ /dev/null
@@ -1,3 +0,0 @@
-enable_language(C)
-add_subdirectory(SubDirTarget)
-target_link_libraries(subexe m)
diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/SubDirTarget/CMakeLists.txt
deleted file mode 100644
index b0b23809a..000000000
--- a/Tests/RunCMake/target_link_libraries/SubDirTarget/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_executable(subexe ../empty.c)
diff --git a/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake b/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake
new file mode 100644
index 000000000..f52fa30bc
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/UNKNOWN-IMPORTED-GLOBAL.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+add_library(UnknownImportedGlobal UNKNOWN IMPORTED GLOBAL)
+add_library(mylib empty.c)
+target_link_libraries(mylib UnknownImportedGlobal)
diff --git a/Tests/RunCMake/target_link_libraries/empty_keyword_args.cmake b/Tests/RunCMake/target_link_libraries/empty_keyword_args.cmake
new file mode 100644
index 000000000..440fa06b8
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries/empty_keyword_args.cmake
@@ -0,0 +1,4 @@
+add_library(iface INTERFACE)
+target_link_libraries(iface PUBLIC PRIVATE INTERFACE)
+add_library(imported UNKNOWN IMPORTED)
+target_link_libraries(imported PUBLIC PRIVATE INTERFACE)
diff --git a/Tests/RunCMake/target_link_options/CMakeLists.txt b/Tests/RunCMake/target_link_options/CMakeLists.txt
new file mode 100644
index 000000000..14ef56e8e
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.11)
+
+project(${RunCMake_TEST} LANGUAGES NONE)
+
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/target_link_options/LINKER_expansion-LINKER-check.cmake b/Tests/RunCMake/target_link_options/LINKER_expansion-LINKER-check.cmake
new file mode 100644
index 000000000..d0ef8de85
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINKER_expansion-LINKER-check.cmake
@@ -0,0 +1,2 @@
+
+include ("${CMAKE_CURRENT_LIST_DIR}/LINKER_expansion-validation.cmake")
diff --git a/Tests/RunCMake/target_link_options/LINKER_expansion-LINKER_SHELL-check.cmake b/Tests/RunCMake/target_link_options/LINKER_expansion-LINKER_SHELL-check.cmake
new file mode 100644
index 000000000..d0ef8de85
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINKER_expansion-LINKER_SHELL-check.cmake
@@ -0,0 +1,2 @@
+
+include ("${CMAKE_CURRENT_LIST_DIR}/LINKER_expansion-validation.cmake")
diff --git a/Tests/RunCMake/target_link_options/LINKER_expansion-validation.cmake b/Tests/RunCMake/target_link_options/LINKER_expansion-validation.cmake
new file mode 100644
index 000000000..1af8f13a3
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINKER_expansion-validation.cmake
@@ -0,0 +1,15 @@
+
+if (actual_stdout MATCHES "LINKER:")
+ set (RunCMake_TEST_FAILED "LINKER: prefix was not expanded.")
+ return()
+endif()
+
+if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/LINKER.txt")
+ set (RunCMake_TEST_FAILED "${RunCMake_TEST_BINARY_DIR}/LINKER.txt: Reference file not found.")
+ return()
+endif()
+file(READ "${RunCMake_TEST_BINARY_DIR}/LINKER.txt" linker_flag)
+
+if (NOT actual_stdout MATCHES "${linker_flag}")
+ set (RunCMake_TEST_FAILED "LINKER: was not expanded correctly.")
+endif()
diff --git a/Tests/RunCMake/target_link_options/LINKER_expansion.cmake b/Tests/RunCMake/target_link_options/LINKER_expansion.cmake
new file mode 100644
index 000000000..b3448679d
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINKER_expansion.cmake
@@ -0,0 +1,49 @@
+
+enable_language(C)
+
+add_executable(dump dump.c)
+
+# ensure no temp file will be used
+string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}")
+string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}")
+
+
+# Use LINKER alone
+add_library(linker SHARED LinkOptionsLib.c)
+target_link_options(linker PRIVATE "LINKER:-foo,bar")
+
+# use LAUNCH facility to dump linker command
+set_property(TARGET linker PROPERTY RULE_LAUNCH_LINK "\"${CMAKE_CURRENT_BINARY_DIR}/dump${CMAKE_EXECUTABLE_SUFFIX}\"")
+
+add_dependencies (linker dump)
+
+
+# Use LINKER with SHELL
+add_library(linker_shell SHARED LinkOptionsLib.c)
+target_link_options(linker_shell PRIVATE "LINKER:SHELL:-foo bar")
+
+# use LAUNCH facility to dump linker command
+set_property(TARGET linker_shell PROPERTY RULE_LAUNCH_LINK "\"${CMAKE_CURRENT_BINARY_DIR}/dump${CMAKE_EXECUTABLE_SUFFIX}\"")
+
+add_dependencies (linker_shell dump)
+
+
+# generate reference for LINKER flag
+if (CMAKE_C_LINKER_WRAPPER_FLAG)
+ set(linker_flag ${CMAKE_C_LINKER_WRAPPER_FLAG})
+ list(GET linker_flag -1 linker_space)
+ if (linker_space STREQUAL " ")
+ list(REMOVE_AT linker_flag -1)
+ else()
+ set(linker_space)
+ endif()
+ list (JOIN linker_flag " " linker_flag)
+ if (CMAKE_C_LINKER_WRAPPER_FLAG_SEP)
+ string (APPEND linker_flag "${linker_space}" "-foo${CMAKE_C_LINKER_WRAPPER_FLAG_SEP}bar")
+ else()
+ set (linker_flag "${linker_flag}${linker_space}-foo ${linker_flag}${linker_space}bar")
+ endif()
+else()
+ set(linker_flag "-foo bar")
+endif()
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/LINKER.txt" "${linker_flag}")
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-check.cmake
new file mode 100644
index 000000000..779950610
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-check.cmake
@@ -0,0 +1,7 @@
+
+if (NOT actual_stdout MATCHES "BADFLAG_PRIVATE")
+ set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_PRIVATE'.")
+endif()
+if (actual_stdout MATCHES "BADFLAG_INTERFACE")
+ string (APPEND RunCMake_TEST_FAILED "\nFound unexpected 'BADFLAG_INTERFACE'.")
+endif()
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-result.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-basic-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-check.cmake
new file mode 100644
index 000000000..a686de945
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-check.cmake
@@ -0,0 +1,7 @@
+
+if (NOT actual_stdout MATCHES "BADFLAG_RELEASE")
+ set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_RELEASE'.")
+endif()
+if (actual_stdout MATCHES "SHELL:")
+ string (APPEND RunCMake_TEST_FAILED "\nFound unexpected prefix 'SHELL:'.")
+endif()
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-result.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-exe-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-check.cmake
new file mode 100644
index 000000000..6c5ffdb36
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "BADFLAG_INTERFACE")
+ set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_INTERFACE'.")
+endif()
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-result.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-static-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-static-check.cmake
new file mode 100644
index 000000000..6c5ffdb36
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-static-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "BADFLAG_INTERFACE")
+ set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_INTERFACE'.")
+endif()
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-static-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-static-result.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-interface-static-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-check.cmake
new file mode 100644
index 000000000..a686de945
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-check.cmake
@@ -0,0 +1,7 @@
+
+if (NOT actual_stdout MATCHES "BADFLAG_RELEASE")
+ set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_RELEASE'.")
+endif()
+if (actual_stdout MATCHES "SHELL:")
+ string (APPEND RunCMake_TEST_FAILED "\nFound unexpected prefix 'SHELL:'.")
+endif()
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-result.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-mod-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-check.cmake
new file mode 100644
index 000000000..a686de945
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-check.cmake
@@ -0,0 +1,7 @@
+
+if (NOT actual_stdout MATCHES "BADFLAG_RELEASE")
+ set (RunCMake_TEST_FAILED "Not found expected 'BADFLAG_RELEASE'.")
+endif()
+if (actual_stdout MATCHES "SHELL:")
+ string (APPEND RunCMake_TEST_FAILED "\nFound unexpected prefix 'SHELL:'.")
+endif()
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-result.txt
new file mode 100644
index 000000000..8d98f9deb
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-shared-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS-static-check.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS-static-check.cmake
new file mode 100644
index 000000000..b68e45175
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-static-check.cmake
@@ -0,0 +1,7 @@
+
+if (actual_stdout MATCHES "BADFLAG_RELEASE")
+ set (RunCMake_TEST_FAILED "Found 'BADFLAG_RELEASE' which was not expected.")
+endif()
+if (actual_stdout MATCHES "SHELL:")
+ string (APPEND RunCMake_TEST_FAILED "\nFound unexpected prefix 'SHELL:'.")
+endif()
diff --git a/Tests/RunCMake/CMP0045/CMP0045-OLD-result.txt b/Tests/RunCMake/target_link_options/LINK_OPTIONS-static-result.txt
index 573541ac9..573541ac9 100644
--- a/Tests/RunCMake/CMP0045/CMP0045-OLD-result.txt
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS-static-result.txt
diff --git a/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake b/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake
new file mode 100644
index 000000000..bb048412e
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LINK_OPTIONS.cmake
@@ -0,0 +1,55 @@
+
+enable_language(C)
+
+set(obj "${CMAKE_C_OUTPUT_EXTENSION}")
+if(BORLAND)
+ set(pre -)
+endif()
+
+# basic configuration
+add_library(LinkOptions SHARED LinkOptionsLib.c)
+target_link_options(LinkOptions
+ PRIVATE ${pre}BADFLAG_PRIVATE${obj}
+ INTERFACE ${pre}BADFLAG_INTERFACE${obj})
+
+
+# INTERFACE_LINK_OPTIONS
+add_library(LinkOptions_producer SHARED LinkOptionsLib.c)
+target_link_options(LinkOptions_producer
+ INTERFACE ${pre}BADFLAG_INTERFACE${obj})
+
+add_executable(LinkOptions_consumer LinkOptionsExe.c)
+target_link_libraries(LinkOptions_consumer PRIVATE LinkOptions_producer)
+
+
+# static library with INTERFACE_LINK_OPTIONS
+add_library(LinkOptions_producer_static STATIC LinkOptionsLib.c)
+target_link_options(LinkOptions_producer_static
+ INTERFACE ${pre}BADFLAG_INTERFACE${obj})
+
+add_executable(LinkOptions_consumer_static LinkOptionsExe.c)
+target_link_libraries(LinkOptions_consumer_static PRIVATE LinkOptions_producer_static)
+
+
+# static library with generator expression
+add_library(LinkOptions_static STATIC LinkOptionsLib.c)
+target_link_options(LinkOptions_static PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}>
+ "SHELL:" # produces no options
+ )
+
+
+# shared library with generator expression
+add_library(LinkOptions_shared SHARED LinkOptionsLib.c)
+target_link_options(LinkOptions_shared PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}>
+ "SHELL:" # produces no options
+ )
+
+
+# module library with generator expression
+add_library(LinkOptions_mod MODULE LinkOptionsLib.c)
+target_link_options(LinkOptions_mod PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}>)
+
+
+# executable with generator expression
+add_executable(LinkOptions_exe LinkOptionsExe.c)
+target_link_options(LinkOptions_exe PRIVATE $<$<CONFIG:Release>:${pre}BADFLAG_RELEASE${obj}>)
diff --git a/Tests/RunCMake/target_link_options/LinkOptionsExe.c b/Tests/RunCMake/target_link_options/LinkOptionsExe.c
new file mode 100644
index 000000000..8488f4e58
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LinkOptionsExe.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/target_link_options/LinkOptionsLib.c b/Tests/RunCMake/target_link_options/LinkOptionsLib.c
new file mode 100644
index 000000000..9bbd24cd8
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/LinkOptionsLib.c
@@ -0,0 +1,7 @@
+#if defined(_WIN32)
+__declspec(dllexport)
+#endif
+ int flags_lib(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
new file mode 100644
index 000000000..1d9ef8b4f
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
@@ -0,0 +1,43 @@
+
+include(RunCMake)
+
+macro(run_cmake_target test subtest target)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN})
+
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+endmacro()
+
+if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
+ # Intel compiler does not reject bad flags or objects!
+ set(RunCMake_TEST_OUTPUT_MERGE TRUE)
+ if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release)
+ endif()
+
+ run_cmake(LINK_OPTIONS)
+
+ run_cmake_target(LINK_OPTIONS basic LinkOptions)
+ run_cmake_target(LINK_OPTIONS interface LinkOptions_consumer)
+ run_cmake_target(LINK_OPTIONS interface-static LinkOptions_consumer_static)
+ run_cmake_target(LINK_OPTIONS static LinkOptions_static --config Release)
+ run_cmake_target(LINK_OPTIONS shared LinkOptions_shared --config Release)
+ run_cmake_target(LINK_OPTIONS mod LinkOptions_mod --config Release)
+ run_cmake_target(LINK_OPTIONS exe LinkOptions_exe --config Release)
+
+ unset(RunCMake_TEST_OPTIONS)
+ unset(RunCMake_TEST_OUTPUT_MERGE)
+endif()
+
+run_cmake(bad_SHELL_usage)
+
+if(RunCMake_GENERATOR MATCHES "(Ninja|Makefile)")
+ run_cmake(LINKER_expansion)
+
+ run_cmake_target(LINKER_expansion LINKER linker)
+ run_cmake_target(LINKER_expansion LINKER_SHELL linker_shell)
+endif()
+
+run_cmake(empty_keyword_args)
diff --git a/Tests/RunCMake/target_link_options/bad_SHELL_usage-result.txt b/Tests/RunCMake/target_link_options/bad_SHELL_usage-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/bad_SHELL_usage-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_link_options/bad_SHELL_usage-stderr.txt b/Tests/RunCMake/target_link_options/bad_SHELL_usage-stderr.txt
new file mode 100644
index 000000000..bffd80a00
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/bad_SHELL_usage-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at bad_SHELL_usage.cmake:4 \(add_library\):
+ 'SHELL:' prefix is not supported as part of 'LINKER:' arguments.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:5 \(include\)
diff --git a/Tests/RunCMake/target_link_options/bad_SHELL_usage.cmake b/Tests/RunCMake/target_link_options/bad_SHELL_usage.cmake
new file mode 100644
index 000000000..b0adf1936
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/bad_SHELL_usage.cmake
@@ -0,0 +1,5 @@
+
+enable_language(C)
+
+add_library(example SHARED LinkOptionsLib.c)
+target_link_options(example PRIVATE "LINKER:-foo,SHELL:-bar")
diff --git a/Tests/RunCMake/target_link_options/dump.c b/Tests/RunCMake/target_link_options/dump.c
new file mode 100644
index 000000000..8baa313fd
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/dump.c
@@ -0,0 +1,13 @@
+
+#include "stdio.h"
+
+int main(int argc, char* argv[])
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ printf("%s ", argv[i]);
+ printf("\n");
+
+ return 0;
+}
diff --git a/Tests/RunCMake/target_link_options/empty_keyword_args.cmake b/Tests/RunCMake/target_link_options/empty_keyword_args.cmake
new file mode 100644
index 000000000..a1a297ef4
--- /dev/null
+++ b/Tests/RunCMake/target_link_options/empty_keyword_args.cmake
@@ -0,0 +1,5 @@
+add_library(iface INTERFACE)
+target_link_options(iface PUBLIC PRIVATE INTERFACE)
+# Cannot be called with non-compilable targets.
+#add_library(imported UNKNOWN IMPORTED)
+#target_link_options(imported PUBLIC PRIVATE INTERFACE)
diff --git a/Tests/RunCMake/target_sources/CMakeLists.txt b/Tests/RunCMake/target_sources/CMakeLists.txt
new file mode 100644
index 000000000..14ef56e8e
--- /dev/null
+++ b/Tests/RunCMake/target_sources/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.11)
+
+project(${RunCMake_TEST} LANGUAGES NONE)
+
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/target_sources/RunCMakeTest.cmake b/Tests/RunCMake/target_sources/RunCMakeTest.cmake
new file mode 100644
index 000000000..b67c5983e
--- /dev/null
+++ b/Tests/RunCMake/target_sources/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(empty_keyword_args)
diff --git a/Tests/RunCMake/target_sources/empty_keyword_args.cmake b/Tests/RunCMake/target_sources/empty_keyword_args.cmake
new file mode 100644
index 000000000..5cee451fd
--- /dev/null
+++ b/Tests/RunCMake/target_sources/empty_keyword_args.cmake
@@ -0,0 +1,5 @@
+add_library(iface INTERFACE)
+target_sources(iface PUBLIC PRIVATE INTERFACE)
+# Cannot be called with non-compilable targets.
+#add_library(imported UNKNOWN IMPORTED)
+#target_sources(imported PUBLIC PRIVATE INTERFACE)
diff --git a/Tests/RunCMake/test_include_dirs/CMakeLists.txt b/Tests/RunCMake/test_include_dirs/CMakeLists.txt
new file mode 100644
index 000000000..dc9248697
--- /dev/null
+++ b/Tests/RunCMake/test_include_dirs/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.6)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake b/Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake
new file mode 100644
index 000000000..72056aee3
--- /dev/null
+++ b/Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake
@@ -0,0 +1,17 @@
+include(RunCMake)
+
+function(run_TID)
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TID-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+ endif()
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake(TID)
+ run_cmake_command(TID-build ${CMAKE_COMMAND} --build . --config Debug)
+ run_cmake_command(TID-test ${CMAKE_CTEST_COMMAND} -C Debug)
+endfunction()
+
+run_TID()
diff --git a/Tests/RunCMake/test_include_dirs/TID-test-stdout.txt b/Tests/RunCMake/test_include_dirs/TID-test-stdout.txt
new file mode 100644
index 000000000..19bf051fa
--- /dev/null
+++ b/Tests/RunCMake/test_include_dirs/TID-test-stdout.txt
@@ -0,0 +1,17 @@
+Test project .*
+ Start 1: house\.dog
+1/6 Test #1: house\.dog \.+ +Passed +[0-9.]+ sec
+ Start 2: house\.cat
+2/6 Test #2: house\.cat \.+ +Passed +[0-9.]+ sec
+ Start 3: farm\.cow
+3/6 Test #3: farm\.cow \.+ +Passed +[0-9.]+ sec
+ Start 4: farm\.pig
+4/6 Test #4: farm\.pig \.+ +Passed +[0-9.]+ sec
+ Start 5: zoo\.fox
+5/6 Test #5: zoo\.fox \.+ +Passed +[0-9.]+ sec
+ Start 6: zoo\.emu
+6/6 Test #6: zoo\.emu \.+ +Passed +[0-9.]+ sec
+
+100% tests passed, 0 tests failed out of 6
+
+Total Test time \(real\) = +[0-9.]+ sec
diff --git a/Tests/RunCMake/test_include_dirs/TID.cmake b/Tests/RunCMake/test_include_dirs/TID.cmake
new file mode 100644
index 000000000..1e74f90fe
--- /dev/null
+++ b/Tests/RunCMake/test_include_dirs/TID.cmake
@@ -0,0 +1,29 @@
+project(test_include_dirs)
+include(CTest)
+
+enable_testing()
+
+add_executable(dummy dummy.cpp)
+
+function(generate_tests NAME)
+ set(ctest_file "${CMAKE_CURRENT_BINARY_DIR}/${NAME}_tests.cmake")
+ add_custom_command(
+ OUTPUT "${ctest_file}"
+ COMMAND "${CMAKE_COMMAND}"
+ -D "TEST_EXECUTABLE=$<TARGET_FILE:dummy>"
+ -D "TEST_SUITE=${NAME}"
+ -D "TEST_NAMES=${ARGN}"
+ -D "CTEST_FILE=${ctest_file}"
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/add-tests.cmake"
+ VERBATIM
+ )
+ add_custom_target(${NAME}_tests ALL DEPENDS "${ctest_file}")
+endfunction()
+
+generate_tests(house dog cat)
+generate_tests(farm cow pig)
+generate_tests(zoo fox emu)
+
+set_property(DIRECTORY PROPERTY TEST_INCLUDE_FILE "house_tests.cmake")
+set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "farm_tests.cmake")
+set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "zoo_tests.cmake")
diff --git a/Tests/RunCMake/test_include_dirs/add-tests.cmake b/Tests/RunCMake/test_include_dirs/add-tests.cmake
new file mode 100644
index 000000000..e74665acc
--- /dev/null
+++ b/Tests/RunCMake/test_include_dirs/add-tests.cmake
@@ -0,0 +1,8 @@
+set(script)
+
+foreach(TEST_NAME ${TEST_NAMES})
+ set(script "${script}add_test(\"${TEST_SUITE}.${TEST_NAME}\"")
+ set(script "${script} \"${TEST_EXECUTABLE}\")\n")
+endforeach()
+
+file(WRITE "${CTEST_FILE}" "${script}")
diff --git a/Tests/RunCMake/test_include_dirs/dummy.cpp b/Tests/RunCMake/test_include_dirs/dummy.cpp
new file mode 100644
index 000000000..f8b643afb
--- /dev/null
+++ b/Tests/RunCMake/test_include_dirs/dummy.cpp
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/try_compile/CMP0056-stderr.txt b/Tests/RunCMake/try_compile/CMP0056-stderr.txt
index 5c1f0e4cf..de442059d 100644
--- a/Tests/RunCMake/try_compile/CMP0056-stderr.txt
+++ b/Tests/RunCMake/try_compile/CMP0056-stderr.txt
@@ -10,4 +10,15 @@ CMake Warning \(dev\) at CMP0056.cmake:[0-9]+ \(try_compile\):
caller link flags \(e.g. CMAKE_EXE_LINKER_FLAGS\) in the test project.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
-This warning is for project developers. Use -Wno-dev to suppress it.$
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Deprecation Warning at CMP0056.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0056 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/try_compile/CMP0066-stderr.txt b/Tests/RunCMake/try_compile/CMP0066-stderr.txt
index b14e2900e..0b92dcfc7 100644
--- a/Tests/RunCMake/try_compile/CMP0066-stderr.txt
+++ b/Tests/RunCMake/try_compile/CMP0066-stderr.txt
@@ -12,4 +12,15 @@ CMake Warning \(dev\) at CMP0066.cmake:[0-9]+ \(try_compile\):
test project.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)
-This warning is for project developers. Use -Wno-dev to suppress it.$
+This warning is for project developers. Use -Wno-dev to suppress it.
+*
+CMake Deprecation Warning at CMP0066.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0066 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/try_compile/CMP0067-stderr.txt b/Tests/RunCMake/try_compile/CMP0067-stderr.txt
index e2677ed7f..d955dda2c 100644
--- a/Tests/RunCMake/try_compile/CMP0067-stderr.txt
+++ b/Tests/RunCMake/try_compile/CMP0067-stderr.txt
@@ -19,6 +19,17 @@ Call Stack \(most recent call first\):
This warning is for project developers. Use -Wno-dev to suppress it.
after try_compile with CMP0067 WARN-enabled
+CMake Deprecation Warning at CMP0067.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0067 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
++
before try_compile with CMP0067 OLD
after try_compile with CMP0067 OLD
before try_compile with CMP0067 NEW
diff --git a/Tests/RunCMake/try_compile/CStandardGNU.c b/Tests/RunCMake/try_compile/CStandardGNU.c
index ac26c15e9..f7ddff4d3 100644
--- a/Tests/RunCMake/try_compile/CStandardGNU.c
+++ b/Tests/RunCMake/try_compile/CStandardGNU.c
@@ -1,8 +1,8 @@
#if __STDC_VERSION__ != 199901L
-#error "Not GNU C 99 mode!"
+# error "Not GNU C 99 mode!"
#endif
#ifndef __STRICT_ANSI__
-#error "Not GNU C strict ANSI!"
+# error "Not GNU C strict ANSI!"
#endif
int main(void)
{
diff --git a/Tests/RunCMake/try_compile/CxxStandardGNU.cxx b/Tests/RunCMake/try_compile/CxxStandardGNU.cxx
index 7990a78dd..ef65e2656 100644
--- a/Tests/RunCMake/try_compile/CxxStandardGNU.cxx
+++ b/Tests/RunCMake/try_compile/CxxStandardGNU.cxx
@@ -1,9 +1,9 @@
#if __cplusplus != 201103L && \
!(__cplusplus < 201103L && defined(__GXX_EXPERIMENTAL_CXX0X__))
-#error "Not GNU C++ 11 mode!"
+# error "Not GNU C++ 11 mode!"
#endif
#ifndef __STRICT_ANSI__
-#error "Not GNU C++ strict ANSI!"
+# error "Not GNU C++ strict ANSI!"
#endif
int main()
{
diff --git a/Tests/RunCMake/try_compile/LinkOptions.cmake b/Tests/RunCMake/try_compile/LinkOptions.cmake
new file mode 100644
index 000000000..7fae35ca9
--- /dev/null
+++ b/Tests/RunCMake/try_compile/LinkOptions.cmake
@@ -0,0 +1,40 @@
+
+enable_language(C)
+
+cmake_policy(SET CMP0054 NEW)
+
+set (lib_name "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}lib${CMAKE_STATIC_LIBRARY_SUFFIX}")
+if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ if (RunCMake_C_COMPILER_ID STREQUAL "MSVC"
+ OR ("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" AND
+ NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC"))
+ if (CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set (undef_flag /INCLUDE:_func)
+ else()
+ set (undef_flag /INCLUDE:func)
+ endif()
+ else()
+ if (CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set (undef_flag -u _func)
+ else()
+ set (undef_flag -u func)
+ endif()
+ endif()
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ set (undef_flag -u _func)
+else()
+ set (undef_flag -u func)
+endif()
+
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib.c
+ COPY_FILE "${lib_name}")
+
+set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/main.c
+ OUTPUT_VARIABLE out
+ LINK_OPTIONS ${undef_flag} "${lib_name}")
+
+if(NOT result)
+ message(FATAL_ERROR "try_compile(... LINK_OPTIONS ...) failed:\n${out}")
+endif()
diff --git a/Tests/RunCMake/try_compile/ObjCStandard-result.txt b/Tests/RunCMake/try_compile/ObjCStandard-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/try_compile/ObjCStandard-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/ObjCStandard-stderr.txt b/Tests/RunCMake/try_compile/ObjCStandard-stderr.txt
new file mode 100644
index 000000000..f1b4df9e0
--- /dev/null
+++ b/Tests/RunCMake/try_compile/ObjCStandard-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at .*/Tests/RunCMake/try_compile/ObjCStandard-build/CMakeFiles/CMakeTmp/CMakeLists.txt:[0-9]+ \(add_executable\):
+ OBJC_STANDARD is set to invalid value '3'
++
+CMake Error at ObjCStandard.cmake:[0-9]+ \(try_compile\):
+ Failed to generate test project build system.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/try_compile/ObjCStandard.cmake b/Tests/RunCMake/try_compile/ObjCStandard.cmake
new file mode 100644
index 000000000..b2066f957
--- /dev/null
+++ b/Tests/RunCMake/try_compile/ObjCStandard.cmake
@@ -0,0 +1,7 @@
+enable_language(OBJC)
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR}
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.m
+ OBJC_STANDARD 3
+ OUTPUT_VARIABLE out
+ )
+message("try_compile output:\n${out}")
diff --git a/Tests/RunCMake/try_compile/ObjCxxStandard-result.txt b/Tests/RunCMake/try_compile/ObjCxxStandard-result.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/Tests/RunCMake/try_compile/ObjCxxStandard-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/ObjCxxStandard-stderr.txt b/Tests/RunCMake/try_compile/ObjCxxStandard-stderr.txt
new file mode 100644
index 000000000..a2f91b48f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/ObjCxxStandard-stderr.txt
@@ -0,0 +1,7 @@
+^CMake Error at .*/Tests/RunCMake/try_compile/ObjCxxStandard-build/CMakeFiles/CMakeTmp/CMakeLists.txt:[0-9]+ \(add_executable\):
+ OBJCXX_STANDARD is set to invalid value '3'
++
+CMake Error at ObjCxxStandard.cmake:[0-9]+ \(try_compile\):
+ Failed to generate test project build system.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/try_compile/ObjCxxStandard.cmake b/Tests/RunCMake/try_compile/ObjCxxStandard.cmake
new file mode 100644
index 000000000..1221805c0
--- /dev/null
+++ b/Tests/RunCMake/try_compile/ObjCxxStandard.cmake
@@ -0,0 +1,7 @@
+enable_language(OBJCXX)
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR}
+ SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.mm
+ OBJCXX_STANDARD 3
+ OUTPUT_VARIABLE out
+ )
+message("try_compile output:\n${out}")
diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
index 6a1bc64c0..91f014e4d 100644
--- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake
+++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
@@ -25,16 +25,29 @@ run_cmake(TargetTypeExe)
run_cmake(TargetTypeInvalid)
run_cmake(TargetTypeStatic)
+if (CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin|Windows)$" AND
+ CMAKE_C_COMPILER_ID MATCHES "^(MSVC|GNU|Clang|AppleClang)$")
+ set (RunCMake_TEST_OPTIONS -DRunCMake_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
+ run_cmake(LinkOptions)
+ unset (RunCMake_TEST_OPTIONS)
+endif()
+
if(CMAKE_C_STANDARD_DEFAULT)
run_cmake(CStandard)
elseif(DEFINED CMAKE_C_STANDARD_DEFAULT)
run_cmake(CStandardNoDefault)
endif()
+if(CMAKE_OBJC_STANDARD_DEFAULT)
+ run_cmake(ObjCStandard)
+endif()
if(CMAKE_CXX_STANDARD_DEFAULT)
run_cmake(CxxStandard)
elseif(DEFINED CMAKE_CXX_STANDARD_DEFAULT)
run_cmake(CxxStandardNoDefault)
endif()
+if(CMAKE_OBJCXX_STANDARD_DEFAULT)
+ run_cmake(ObjCxxStandard)
+endif()
if(CMake_TEST_CUDA)
if(CMAKE_HOST_WIN32)
run_cmake(CudaStandardNoDefault)
diff --git a/Tests/RunCMake/try_compile/lib.c b/Tests/RunCMake/try_compile/lib.c
new file mode 100644
index 000000000..b00c576c7
--- /dev/null
+++ b/Tests/RunCMake/try_compile/lib.c
@@ -0,0 +1,4 @@
+
+void func()
+{
+}
diff --git a/Tests/RunCMake/try_compile/main.c b/Tests/RunCMake/try_compile/main.c
new file mode 100644
index 000000000..2128ead9d
--- /dev/null
+++ b/Tests/RunCMake/try_compile/main.c
@@ -0,0 +1,8 @@
+extern void func();
+
+int main(void)
+{
+ func();
+
+ return 0;
+}
diff --git a/Tests/RunCMake/try_compile/src.c b/Tests/RunCMake/try_compile/src.c
index 5e513825c..beed9b14d 100644
--- a/Tests/RunCMake/try_compile/src.c
+++ b/Tests/RunCMake/try_compile/src.c
@@ -3,5 +3,5 @@ int main(void)
return 0;
}
#ifdef PP_ERROR
-#error PP_ERROR is defined
+# error PP_ERROR is defined
#endif
diff --git a/Tests/RunCMake/try_compile/src.m b/Tests/RunCMake/try_compile/src.m
new file mode 100644
index 000000000..f8b643afb
--- /dev/null
+++ b/Tests/RunCMake/try_compile/src.m
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/try_compile/src.mm b/Tests/RunCMake/try_compile/src.mm
new file mode 100644
index 000000000..f8b643afb
--- /dev/null
+++ b/Tests/RunCMake/try_compile/src.mm
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/try_run/LinkOptions.cmake b/Tests/RunCMake/try_run/LinkOptions.cmake
new file mode 100644
index 000000000..b9a87f3ca
--- /dev/null
+++ b/Tests/RunCMake/try_run/LinkOptions.cmake
@@ -0,0 +1,44 @@
+
+enable_language(C)
+
+cmake_policy(SET CMP0054 NEW)
+
+set (lib_name "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}lib${CMAKE_STATIC_LIBRARY_SUFFIX}")
+if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ if (RunCMake_C_COMPILER_ID STREQUAL "MSVC"
+ OR ("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" AND
+ NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC"))
+ if (CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set (undef_flag /INCLUDE:_func)
+ else()
+ set (undef_flag /INCLUDE:func)
+ endif()
+ else()
+ if (CMAKE_SIZEOF_VOID_P EQUAL 4)
+ set (undef_flag -u _func)
+ else()
+ set (undef_flag -u func)
+ endif()
+ endif()
+elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ set (undef_flag -u _func)
+else()
+ set (undef_flag -u func)
+endif()
+
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+try_compile(result ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib.c
+ COPY_FILE "${lib_name}")
+
+set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
+try_run(run_result compile_result ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/main.c
+ COMPILE_OUTPUT_VARIABLE compile_out
+ RUN_OUTPUT_VARIABLE run_out
+ LINK_OPTIONS ${undef_flag} "${lib_name}")
+
+if(NOT compile_result)
+ message(FATAL_ERROR "try_run(... LINK_OPTIONS ...) compilation failed:\n${compile_out}")
+endif()
+if(run_result STREQUAL "FAILED_TO_RUN")
+ message(FATAL_ERROR "try_run(... LINK_OPTIONS ...) execution failed:\n${run_out}")
+endif()
diff --git a/Tests/RunCMake/try_run/RunCMakeTest.cmake b/Tests/RunCMake/try_run/RunCMakeTest.cmake
index 1ec9a55aa..368956295 100644
--- a/Tests/RunCMake/try_run/RunCMakeTest.cmake
+++ b/Tests/RunCMake/try_run/RunCMakeTest.cmake
@@ -1,3 +1,10 @@
include(RunCMake)
run_cmake(BadLinkLibraries)
+
+if (CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin|Windows)$" AND
+ CMAKE_C_COMPILER_ID MATCHES "^(MSVC|GNU|Clang|AppleClang)$")
+ set (RunCMake_TEST_OPTIONS -DRunCMake_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
+ run_cmake(LinkOptions)
+ unset (RunCMake_TEST_OPTIONS)
+endif()
diff --git a/Tests/RunCMake/try_run/lib.c b/Tests/RunCMake/try_run/lib.c
new file mode 100644
index 000000000..b00c576c7
--- /dev/null
+++ b/Tests/RunCMake/try_run/lib.c
@@ -0,0 +1,4 @@
+
+void func()
+{
+}
diff --git a/Tests/RunCMake/try_run/main.c b/Tests/RunCMake/try_run/main.c
new file mode 100644
index 000000000..2128ead9d
--- /dev/null
+++ b/Tests/RunCMake/try_run/main.c
@@ -0,0 +1,8 @@
+extern void func();
+
+int main(void)
+{
+ func();
+
+ return 0;
+}
diff --git a/Tests/RunCMake/variable_watch/ModifyWatchInCallback.cmake b/Tests/RunCMake/variable_watch/ModifyWatchInCallback.cmake
new file mode 100644
index 000000000..1dee8375a
--- /dev/null
+++ b/Tests/RunCMake/variable_watch/ModifyWatchInCallback.cmake
@@ -0,0 +1,17 @@
+function (watch2)
+
+endfunction ()
+
+function (watch1)
+ variable_watch(watched watch2)
+ variable_watch(watched watch2)
+ variable_watch(watched watch2)
+ variable_watch(watched watch2)
+ variable_watch(watched watch2)
+ variable_watch(watched watch2)
+endfunction ()
+
+variable_watch(watched watch1)
+variable_watch(watched watch2)
+
+set(access "${watched}")
diff --git a/Tests/RunCMake/variable_watch/RaiseInParentScope-stderr.txt b/Tests/RunCMake/variable_watch/RaiseInParentScope-stderr.txt
new file mode 100644
index 000000000..51db19cc3
--- /dev/null
+++ b/Tests/RunCMake/variable_watch/RaiseInParentScope-stderr.txt
@@ -0,0 +1,2 @@
+var MODIFIED_ACCESS a
+var MODIFIED_ACCESS b
diff --git a/Tests/RunCMake/variable_watch/RaiseInParentScope.cmake b/Tests/RunCMake/variable_watch/RaiseInParentScope.cmake
new file mode 100644
index 000000000..207798e4b
--- /dev/null
+++ b/Tests/RunCMake/variable_watch/RaiseInParentScope.cmake
@@ -0,0 +1,15 @@
+
+function(watch variable access value)
+ message("${variable} ${access} ${value}")
+endfunction ()
+
+# --------------
+
+variable_watch(var watch)
+set(var "a")
+
+function(f)
+ set(var "b" PARENT_SCOPE)
+endfunction(f)
+
+f()
diff --git a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake
index 9becb4cd7..3883999c6 100644
--- a/Tests/RunCMake/variable_watch/RunCMakeTest.cmake
+++ b/Tests/RunCMake/variable_watch/RunCMakeTest.cmake
@@ -3,3 +3,5 @@ include(RunCMake)
run_cmake(ModifiedAccess)
run_cmake(NoWatcher)
run_cmake(WatchTwice)
+run_cmake(ModifyWatchInCallback)
+run_cmake(RaiseInParentScope)
diff --git a/Tests/RuntimePath/CMakeLists.txt b/Tests/RuntimePath/CMakeLists.txt
index 6583a8712..bb874404a 100644
--- a/Tests/RuntimePath/CMakeLists.txt
+++ b/Tests/RuntimePath/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 2.6)
+cmake_minimum_required (VERSION 3.15)
project(RuntimePath C)
# Add a simple chain of shared libraries that must be found.
@@ -31,3 +31,14 @@ if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG)
set_property(TARGET bar2 PROPERTY LIBRARY_OUTPUT_DIRECTORY A)
target_link_libraries(bar2 foo2)
endif()
+
+# Add a library that is missing the rpath for its dependency.
+add_library(bar1_no_rpath SHARED bar1.c)
+set_property(TARGET bar1_no_rpath PROPERTY LIBRARY_OUTPUT_DIRECTORY B)
+set_property(TARGET bar1_no_rpath PROPERTY SKIP_BUILD_RPATH 1)
+target_link_libraries(bar1_no_rpath PRIVATE foo1)
+
+# Add an executable linking to the library with a missing dependency rpath.
+# CMake should generate the proper rpath-link flag to find it at build time.
+add_executable(main_with_bar1_no_rpath main.c)
+target_link_libraries(main_with_bar1_no_rpath bar1_no_rpath)
diff --git a/Tests/SameName/CMakeLists.txt b/Tests/SameName/CMakeLists.txt
deleted file mode 100644
index d78879dd9..000000000
--- a/Tests/SameName/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-project(SameName C)
-
-add_subdirectory(Lib1)
-
-include_directories(${PROJECT_SOURCE_DIR}/Lib1)
-add_subdirectory(Exe1)
diff --git a/Tests/SameName/Exe1/CMakeLists.txt b/Tests/SameName/Exe1/CMakeLists.txt
deleted file mode 100644
index b9182f209..000000000
--- a/Tests/SameName/Exe1/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-# a target with the same name as a target in a different dir
-add_executable(mytest_exe conly.c)
-set_target_properties(mytest_exe PROPERTIES OUTPUT_NAME mytest)
-target_link_libraries(mytest_exe mytest)
-
-# and two targets in the same dir with the same name
-add_library(mytest2 ../Lib1/libc1.c)
-
-add_executable(mytest2_exe conly.c)
-set_target_properties(mytest2_exe PROPERTIES OUTPUT_NAME mytest2)
-target_link_libraries(mytest2_exe mytest2)
diff --git a/Tests/SameName/Exe1/conly.c b/Tests/SameName/Exe1/conly.c
deleted file mode 100644
index 8f2ce05f7..000000000
--- a/Tests/SameName/Exe1/conly.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "libc1.h"
-#include <stdio.h>
-
-int main()
-{
- if (LibC1Func() != 2.0) {
- printf("Problem with libc1\n");
- return 1;
- }
- return 0;
-}
diff --git a/Tests/SameName/Lib1/CMakeLists.txt b/Tests/SameName/Lib1/CMakeLists.txt
deleted file mode 100644
index 40fa15422..000000000
--- a/Tests/SameName/Lib1/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_library(mytest libc1.c)
diff --git a/Tests/SameName/Lib1/libc1.c b/Tests/SameName/Lib1/libc1.c
deleted file mode 100644
index b01e1e1b5..000000000
--- a/Tests/SameName/Lib1/libc1.c
+++ /dev/null
@@ -1,4 +0,0 @@
-float LibC1Func()
-{
- return 2.0;
-}
diff --git a/Tests/SameName/Lib1/libc1.h b/Tests/SameName/Lib1/libc1.h
deleted file mode 100644
index 84c94a9cb..000000000
--- a/Tests/SameName/Lib1/libc1.h
+++ /dev/null
@@ -1 +0,0 @@
-extern float LibC1Func();
diff --git a/Tests/Server/CMakeLists.txt b/Tests/Server/CMakeLists.txt
index e7eaa8d72..8321edb1d 100644
--- a/Tests/Server/CMakeLists.txt
+++ b/Tests/Server/CMakeLists.txt
@@ -1,12 +1,12 @@
cmake_minimum_required(VERSION 3.4)
project(Server CXX)
-find_package(PythonInterp REQUIRED)
+find_package(Python REQUIRED)
-macro(do_test bsname file)
- execute_process(COMMAND ${PYTHON_EXECUTABLE}
+macro(do_test bsname file type)
+ execute_process(COMMAND ${Python_EXECUTABLE}
-B # no .pyc files
- "${CMAKE_SOURCE_DIR}/server-test.py"
+ "${CMAKE_SOURCE_DIR}/${type}-test.py"
"${CMAKE_COMMAND}"
"${CMAKE_SOURCE_DIR}/${file}"
"${CMAKE_SOURCE_DIR}"
@@ -16,12 +16,13 @@ macro(do_test bsname file)
)
if (NOT test_result EQUAL 0)
- message(SEND_ERROR "TEST FAILED")
+ message(SEND_ERROR "TEST FAILED: ${test_result}")
endif()
endmacro()
-do_test("test_handshake" "tc_handshake.json")
-do_test("test_globalSettings" "tc_globalSettings.json")
-do_test("test_buildsystem1" "tc_buildsystem1.json")
+do_test("test_cache" "tc_cache.json" "server")
+do_test("test_handshake" "tc_handshake.json" "server")
+do_test("test_globalSettings" "tc_globalSettings.json" "server")
+do_test("test_buildsystem1" "tc_buildsystem1.json" "server")
add_executable(Server empty.cpp)
diff --git a/Tests/Server/cmakelib.py b/Tests/Server/cmakelib.py
index 78450d5bf..546ae4cc5 100644
--- a/Tests/Server/cmakelib.py
+++ b/Tests/Server/cmakelib.py
@@ -1,5 +1,5 @@
from __future__ import print_function
-import sys, subprocess, json
+import sys, subprocess, json, os, select, shutil, time, socket
termwidth = 150
@@ -38,11 +38,50 @@ def col_print(title, array):
for index in range(numRows):
print(indent + pad.join(item.ljust(maxitemwidth) for item in array[index::numRows]))
+filterPacket = lambda x: x
+
+STDIN = 0
+PIPE = 1
+
+communicationMethods = [STDIN]
+
+if hasattr(socket, 'AF_UNIX'):
+ communicationMethods.append(PIPE)
+
+def defaultExitWithError(proc):
+ data = ""
+ try:
+ while select.select([proc.outPipe], [], [], 3.)[0]:
+ data = data + proc.outPipe.read(1)
+ if len(data):
+ print("Rest of raw buffer from server:")
+ printServer(data)
+ except:
+ pass
+ proc.outPipe.close()
+ proc.inPipe.close()
+ proc.kill()
+ sys.exit(1)
+
+exitWithError = lambda proc: defaultExitWithError(proc)
+
+serverTag = "SERVER"
+
+def printServer(*args):
+ print(serverTag + ">", *args)
+ print()
+ sys.stdout.flush()
+
+def printClient(*args):
+ print("CLIENT>", *args)
+ print()
+ sys.stdout.flush()
+
def waitForRawMessage(cmakeCommand):
stdoutdata = ""
payload = ""
while not cmakeCommand.poll():
- stdoutdataLine = cmakeCommand.stdout.readline()
+ stdoutdataLine = cmakeCommand.outPipe.readline()
if stdoutdataLine:
stdoutdata += stdoutdataLine.decode('utf-8')
else:
@@ -50,12 +89,24 @@ def waitForRawMessage(cmakeCommand):
begin = stdoutdata.find('[== "CMake Server" ==[\n')
end = stdoutdata.find(']== "CMake Server" ==]')
- if (begin != -1 and end != -1):
+ if begin != -1 and end != -1:
begin += len('[== "CMake Server" ==[\n')
payload = stdoutdata[begin:end]
- if print_communication:
- print("\nSERVER>", json.loads(payload), "\n")
- return json.loads(payload)
+ jsonPayload = json.loads(payload)
+ filteredPayload = filterPacket(jsonPayload)
+ if print_communication and filteredPayload:
+ printServer(filteredPayload)
+ if filteredPayload is not None or jsonPayload is None:
+ return jsonPayload
+ stdoutdata = stdoutdata[(end+len(']== "CMake Server" ==]')):]
+
+# Python2 has no problem writing the output of encodes directly,
+# but Python3 returns only 'int's for encode and so must be turned
+# into bytes. We use the existence of 'to_bytes' on an int to
+# determine which behavior is appropriate. It might be more clear
+# to do this in the code which uses the flag, but introducing
+# this lookup cost at every byte sent isn't ideal.
+has_to_bytes = "to_bytes" in dir(10)
def writeRawData(cmakeCommand, content):
writeRawData.counter += 1
@@ -71,36 +122,96 @@ def writeRawData(cmakeCommand, content):
payload = payload.replace('\n', '\r\n')
if print_communication:
- print("\nCLIENT>", content, "(Use \\r\\n:", rn, ")\n")
- cmakeCommand.stdin.write(payload.encode('utf-8'))
- cmakeCommand.stdin.flush()
+ printClient(content, "(Use \\r\\n:", rn, ")")
+
+ # To stress test how cmake deals with fragmentation in the
+ # communication channel, we send only one byte at a time.
+ # Certain communication methods / platforms might still buffer
+ # it all into one message since its so close together, but in
+ # general this will catch places where we assume full buffers
+ # come in all at once.
+ encoded_payload = payload.encode('utf-8')
+
+ # Python version 3+ can't write ints directly; but 'to_bytes'
+ # for int was only added in python 3.2. If this is a 3+ version
+ # of python without that conversion function; just write the whole
+ # thing out at once.
+ if sys.version_info[0] > 2 and not has_to_bytes:
+ cmakeCommand.write(encoded_payload)
+ else:
+ for c in encoded_payload:
+ if has_to_bytes:
+ c = c.to_bytes(1, byteorder='big')
+ cmakeCommand.write(c)
+
writeRawData.counter = 0
def writePayload(cmakeCommand, obj):
writeRawData(cmakeCommand, json.dumps(obj))
-def initProc(cmakeCommand):
- cmakeCommand = subprocess.Popen([cmakeCommand, "-E", "server", "--experimental", "--debug"],
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE)
+def getPipeName():
+ return "/tmp/server-test-socket"
+
+def attachPipe(cmakeCommand, pipeName):
+ time.sleep(1)
+ sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ sock.connect(pipeName)
+ global serverTag
+ serverTag = "SERVER(PIPE)"
+ cmakeCommand.outPipe = sock.makefile()
+ cmakeCommand.inPipe = sock
+ cmakeCommand.write = cmakeCommand.inPipe.sendall
+
+def writeAndFlush(pipe, val):
+ pipe.write(val)
+ pipe.flush()
+
+def initServerProc(cmakeCommand, comm):
+ if comm == PIPE:
+ pipeName = getPipeName()
+ cmakeCommand = subprocess.Popen([cmakeCommand, "-E", "server", "--experimental", "--pipe=" + pipeName])
+ attachPipe(cmakeCommand, pipeName)
+ else:
+ cmakeCommand = subprocess.Popen([cmakeCommand, "-E", "server", "--experimental", "--debug"],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE)
+ cmakeCommand.outPipe = cmakeCommand.stdout
+ cmakeCommand.inPipe = cmakeCommand.stdin
+ cmakeCommand.write = lambda val: writeAndFlush(cmakeCommand.inPipe, val)
packet = waitForRawMessage(cmakeCommand)
if packet == None:
print("Not in server mode")
- sys.exit(1)
+ sys.exit(2)
if packet['type'] != 'hello':
print("No hello message")
- sys.exit(1)
+ sys.exit(3)
return cmakeCommand
+def exitProc(cmakeCommand):
+ # Tell the server to exit.
+ cmakeCommand.stdin.close()
+ cmakeCommand.stdout.close()
+
+ # Wait for the server to exit.
+ # If this version of python supports it, terminate the server after a timeout.
+ try:
+ cmakeCommand.wait(timeout=5)
+ except TypeError:
+ cmakeCommand.wait()
+ except:
+ cmakeCommand.terminate()
+ raise
+
def waitForMessage(cmakeCommand, expected):
data = ordered(expected)
packet = ordered(waitForRawMessage(cmakeCommand))
if packet != data:
- sys.exit(-1)
+ print ("Received unexpected message; test failed")
+ exitWithError(cmakeCommand)
return packet
def waitForReply(cmakeCommand, originalType, cookie, skipProgress):
@@ -109,25 +220,27 @@ def waitForReply(cmakeCommand, originalType, cookie, skipProgress):
packet = waitForRawMessage(cmakeCommand)
t = packet['type']
if packet['cookie'] != cookie or packet['inReplyTo'] != originalType:
- sys.exit(1)
+ print("cookie or inReplyTo mismatch")
+ sys.exit(4)
if t == 'message' or t == 'progress':
if skipProgress:
continue
if t == 'reply':
break
- sys.exit(1)
+ print("Unrecognized message", packet)
+ sys.exit(5)
return packet
def waitForError(cmakeCommand, originalType, cookie, message):
packet = waitForRawMessage(cmakeCommand)
if packet['cookie'] != cookie or packet['type'] != 'error' or packet['inReplyTo'] != originalType or packet['errorMessage'] != message:
- sys.exit(1)
+ sys.exit(6)
def waitForProgress(cmakeCommand, originalType, cookie, current, message):
packet = waitForRawMessage(cmakeCommand)
if packet['cookie'] != cookie or packet['type'] != 'progress' or packet['inReplyTo'] != originalType or packet['progressCurrent'] != current or packet['progressMessage'] != message:
- sys.exit(1)
+ sys.exit(7)
def handshake(cmakeCommand, major, minor, source, build, generator, extraGenerator):
version = { 'major': major }
@@ -152,9 +265,9 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data):
versionString = version['string']
vs = str(version['major']) + '.' + str(version['minor']) + '.' + str(version['patch'])
if (versionString != vs and not versionString.startswith(vs + '-')):
- sys.exit(1)
+ sys.exit(8)
if (versionString != cmakeVersion):
- sys.exit(1)
+ sys.exit(9)
# validate generators:
generatorObjects = capabilities['generators']
@@ -163,6 +276,10 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data):
index = cmakeoutput.index('\nGenerators\n\n')
cmakeGenerators = []
for line in cmakeoutput[index + 12:].splitlines():
+ if not line:
+ continue
+ if line[0] == '*': # default generator marker
+ line = ' ' + line[1:]
if not line.startswith(' '):
continue
if line.startswith(' '):
@@ -175,7 +292,7 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data):
tmp = line.strip()
if tmp.endswith(" [arch]"):
tmp = tmp[0:len(tmp) - 7]
- if (len(tmp) > 0) and (" - " not in tmp) and (tmp != 'KDevelop3'):
+ if (len(tmp) > 0) and (" - " not in tmp):
cmakeGenerators.append(tmp)
generators = []
@@ -187,13 +304,77 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data):
for gen in cmakeGenerators:
if (not gen in generators):
- sys.exit(1)
+ sys.exit(10)
gen = packet['generator']
if (gen != '' and not (gen in generators)):
- sys.exit(1)
+ sys.exit(11)
for i in data:
print("Validating", i)
if (packet[i] != data[i]):
+ sys.exit(12)
+
+def validateCache(cmakeCommand, data):
+ packet = waitForReply(cmakeCommand, 'cache', '', False)
+
+ cache = packet['cache']
+
+ if (data['isEmpty']):
+ if (cache != []):
+ print('Expected empty cache, but got data.\n')
sys.exit(1)
+ return;
+
+ if (cache == []):
+ print('Expected cache contents, but got none.\n')
+ sys.exit(1)
+
+ hadHomeDir = False
+ for value in cache:
+ if (value['key'] == 'CMAKE_HOME_DIRECTORY'):
+ hadHomeDir = True
+
+ if (not hadHomeDir):
+ print('No CMAKE_HOME_DIRECTORY found in cache.')
+ sys.exit(1)
+
+def handleBasicMessage(proc, obj, debug):
+ if 'sendRaw' in obj:
+ data = obj['sendRaw']
+ if debug: print("Sending raw:", data)
+ writeRawData(proc, data)
+ return True
+ elif 'send' in obj:
+ data = obj['send']
+ if debug: print("Sending:", json.dumps(data))
+ writePayload(proc, data)
+ return True
+ elif 'recv' in obj:
+ data = obj['recv']
+ if debug: print("Waiting for:", json.dumps(data))
+ waitForMessage(proc, data)
+ return True
+ elif 'message' in obj:
+ print("MESSAGE:", obj["message"])
+ sys.stdout.flush()
+ return True
+ return False
+
+def shutdownProc(proc):
+ # Tell the server to exit.
+ proc.inPipe.close()
+ proc.outPipe.close()
+
+ # Wait for the server to exit.
+ # If this version of python supports it, terminate the server after a timeout.
+ try:
+ proc.wait(timeout=5)
+ except TypeError:
+ proc.wait()
+ except:
+ proc.terminate()
+ raise
+
+ print('cmake-server exited: %d' % proc.returncode)
+ sys.exit(proc.returncode)
diff --git a/Tests/Server/server-test.py b/Tests/Server/server-test.py
index 62d9008b2..701c6e945 100644
--- a/Tests/Server/server-test.py
+++ b/Tests/Server/server-test.py
@@ -9,7 +9,7 @@ sourceDir = sys.argv[3]
buildDir = sys.argv[4] + "/" + os.path.splitext(os.path.basename(testFile))[0]
cmakeGenerator = sys.argv[5]
-print("Test:", testFile,
+print("Server Test:", testFile,
"\n-- SourceDir:", sourceDir,
"\n-- BuildDir:", buildDir,
"\n-- Generator:", cmakeGenerator)
@@ -17,104 +17,89 @@ print("Test:", testFile,
if os.path.exists(buildDir):
shutil.rmtree(buildDir)
-proc = cmakelib.initProc(cmakeCommand)
+cmakelib.filterBase = sourceDir
with open(testFile) as f:
testData = json.loads(f.read())
-for obj in testData:
- if 'sendRaw' in obj:
- data = obj['sendRaw']
- if debug: print("Sending raw:", data)
- cmakelib.writeRawData(proc, data)
- elif 'send' in obj:
- data = obj['send']
- if debug: print("Sending:", json.dumps(data))
- cmakelib.writePayload(proc, data)
- elif 'recv' in obj:
- data = obj['recv']
- if debug: print("Waiting for:", json.dumps(data))
- cmakelib.waitForMessage(proc, data)
- elif 'reply' in obj:
- data = obj['reply']
- if debug: print("Waiting for reply:", json.dumps(data))
- originalType = ""
- cookie = ""
- skipProgress = False;
- if 'cookie' in data: cookie = data['cookie']
- if 'type' in data: originalType = data['type']
- if 'skipProgress' in data: skipProgress = data['skipProgress']
- cmakelib.waitForReply(proc, originalType, cookie, skipProgress)
- elif 'error' in obj:
- data = obj['error']
- if debug: print("Waiting for error:", json.dumps(data))
- originalType = ""
- cookie = ""
- message = ""
- if 'cookie' in data: cookie = data['cookie']
- if 'type' in data: originalType = data['type']
- if 'message' in data: message = data['message']
- cmakelib.waitForError(proc, originalType, cookie, message)
- elif 'progress' in obj:
- data = obj['progress']
- if debug: print("Waiting for progress:", json.dumps(data))
- originalType = ''
- cookie = ""
- current = 0
- message = ""
- if 'cookie' in data: cookie = data['cookie']
- if 'type' in data: originalType = data['type']
- if 'current' in data: current = data['current']
- if 'message' in data: message = data['message']
- cmakelib.waitForProgress(proc, originalType, cookie, current, message)
- elif 'handshake' in obj:
- data = obj['handshake']
- if debug: print("Doing handshake:", json.dumps(data))
- major = -1
- minor = -1
- generator = cmakeGenerator
- extraGenerator = ''
- sourceDirectory = sourceDir
- buildDirectory = buildDir
- if 'major' in data: major = data['major']
- if 'minor' in data: minor = data['minor']
- if 'buildDirectory' in data: buildDirectory = data['buildDirectory']
- if 'sourceDirectory' in data: sourceDirectory = data['sourceDirectory']
- if 'generator' in data: generator = data['generator']
- if 'extraGenerator' in data: extraGenerator = data['extraGenerator']
- if not os.path.isabs(buildDirectory):
- buildDirectory = buildDir + "/" + buildDirectory
- if not os.path.isabs(sourceDirectory):
- sourceDirectory = sourceDir + "/" + sourceDirectory
- cmakelib.handshake(proc, major, minor, sourceDirectory, buildDirectory,
- generator, extraGenerator)
- elif 'validateGlobalSettings' in obj:
- data = obj['validateGlobalSettings']
- if not 'buildDirectory' in data: data['buildDirectory'] = buildDir
- if not 'sourceDirectory' in data: data['sourceDirectory'] = sourceDir
- if not 'generator' in data: data['generator'] = cmakeGenerator
- if not 'extraGenerator' in data: data['extraGenerator'] = ''
- cmakelib.validateGlobalSettings(proc, cmakeCommand, data)
- elif 'message' in obj:
- print("MESSAGE:", obj["message"])
- else:
- print("Unknown command:", json.dumps(obj))
- sys.exit(2)
+for communicationMethod in cmakelib.communicationMethods:
+ proc = cmakelib.initServerProc(cmakeCommand, communicationMethod)
+ if proc is None:
+ continue
- print("Completed")
-
-# Tell the server to exit.
-proc.stdin.close()
-proc.stdout.close()
+ for obj in testData:
+ if cmakelib.handleBasicMessage(proc, obj, debug):
+ pass
+ elif 'reply' in obj:
+ data = obj['reply']
+ if debug: print("Waiting for reply:", json.dumps(data))
+ originalType = ""
+ cookie = ""
+ skipProgress = False;
+ if 'cookie' in data: cookie = data['cookie']
+ if 'type' in data: originalType = data['type']
+ if 'skipProgress' in data: skipProgress = data['skipProgress']
+ cmakelib.waitForReply(proc, originalType, cookie, skipProgress)
+ elif 'error' in obj:
+ data = obj['error']
+ if debug: print("Waiting for error:", json.dumps(data))
+ originalType = ""
+ cookie = ""
+ message = ""
+ if 'cookie' in data: cookie = data['cookie']
+ if 'type' in data: originalType = data['type']
+ if 'message' in data: message = data['message']
+ cmakelib.waitForError(proc, originalType, cookie, message)
+ elif 'progress' in obj:
+ data = obj['progress']
+ if debug: print("Waiting for progress:", json.dumps(data))
+ originalType = ''
+ cookie = ""
+ current = 0
+ message = ""
+ if 'cookie' in data: cookie = data['cookie']
+ if 'type' in data: originalType = data['type']
+ if 'current' in data: current = data['current']
+ if 'message' in data: message = data['message']
+ cmakelib.waitForProgress(proc, originalType, cookie, current, message)
+ elif 'handshake' in obj:
+ data = obj['handshake']
+ if debug: print("Doing handshake:", json.dumps(data))
+ major = -1
+ minor = -1
+ generator = cmakeGenerator
+ extraGenerator = ''
+ sourceDirectory = sourceDir
+ buildDirectory = buildDir
+ if 'major' in data: major = data['major']
+ if 'minor' in data: minor = data['minor']
+ if 'buildDirectory' in data: buildDirectory = data['buildDirectory']
+ if 'sourceDirectory' in data: sourceDirectory = data['sourceDirectory']
+ if 'generator' in data: generator = data['generator']
+ if 'extraGenerator' in data: extraGenerator = data['extraGenerator']
-# Wait for the server to exit.
-# If this version of python supports it, terminate the server after a timeout.
-try:
- proc.wait(timeout=5)
-except TypeError:
- proc.wait()
-except:
- proc.terminate()
- raise
-
-sys.exit(0)
+ if not os.path.isabs(buildDirectory):
+ buildDirectory = buildDir + "/" + buildDirectory
+ if sourceDirectory != '' and not os.path.isabs(sourceDirectory):
+ sourceDirectory = sourceDir + "/" + sourceDirectory
+ cmakelib.handshake(proc, major, minor, sourceDirectory, buildDirectory,
+ generator, extraGenerator)
+ elif 'validateGlobalSettings' in obj:
+ data = obj['validateGlobalSettings']
+ if not 'buildDirectory' in data: data['buildDirectory'] = buildDir
+ if not 'sourceDirectory' in data: data['sourceDirectory'] = sourceDir
+ if not 'generator' in data: data['generator'] = cmakeGenerator
+ if not 'extraGenerator' in data: data['extraGenerator'] = ''
+ cmakelib.validateGlobalSettings(proc, cmakeCommand, data)
+ elif 'validateCache' in obj:
+ data = obj['validateCache']
+ if not 'isEmpty' in data: data['isEmpty'] = false
+ cmakelib.validateCache(proc, data)
+ elif 'reconnect' in obj:
+ cmakelib.exitProc(proc)
+ proc = cmakelib.initServerProc(cmakeCommand, communicationMethod)
+ else:
+ print("Unknown command:", json.dumps(obj))
+ sys.exit(2)
+ cmakelib.shutdownProc(proc)
+ print("Completed")
diff --git a/Tests/Server/tc_cache.json b/Tests/Server/tc_cache.json
new file mode 100644
index 000000000..74af6d93c
--- /dev/null
+++ b/Tests/Server/tc_cache.json
@@ -0,0 +1,24 @@
+[
+{ "message": "Testing cache" },
+
+{ "message": "Cache after first handshake is empty:" },
+{ "handshake": {"major": 1, "sourceDirectory": "buildsystem1", "buildDirectory": "buildsystem1"} },
+{ "send": { "type": "cache" } },
+{ "validateCache": { "isEmpty": true } },
+
+{ "message": "Cache after configure is populated:" },
+{ "send": { "type": "configure" } },
+{ "reply": { "type": "configure", "skipProgress":true } },
+{ "send": { "type": "cache" } },
+{ "validateCache": { "isEmpty": false } },
+
+{ "message": "Handshake for existing cache requires buildDirectory only:" },
+{ "reconnect": {} },
+{ "handshake": {"major": 1, "sourceDirectory": "", "buildDirectory": "buildsystem1"} },
+
+{ "message": "Cache after reconnect is again populated:" },
+{ "send": { "type": "cache" } },
+{ "validateCache": { "isEmpty": false } },
+
+{ "message": "Everything ok." }
+]
diff --git a/Tests/Server/tc_handshake.json b/Tests/Server/tc_handshake.json
index 975bb3d32..4bb7fa7ac 100644
--- a/Tests/Server/tc_handshake.json
+++ b/Tests/Server/tc_handshake.json
@@ -11,6 +11,10 @@
{ "send": {"test": "sometext","cookie":"monster"} },
{ "recv": {"cookie":"monster","errorMessage":"No type given in request.","inReplyTo":"","type":"error"} },
+{ "message": "Testing commands before handshake" },
+{ "send": {"type": "cache","cookie":"monster"} },
+{ "recv": {"cookie":"monster","errorMessage":"Waiting for type \"handshake\".","inReplyTo":"cache","type":"error"} },
+
{ "message": "Testing handshake" },
{ "send": {"type": "sometype","cookie":"monster2"} },
{ "recv": {"cookie":"monster2","errorMessage":"Waiting for type \"handshake\".","inReplyTo":"sometype","type":"error"} },
diff --git a/Tests/SimpleExclude/CMakeLists.txt b/Tests/SimpleExclude/CMakeLists.txt
deleted file mode 100644
index baca23e39..000000000
--- a/Tests/SimpleExclude/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-project(SimpleExclude C)
-
-set(EXECUTABLE_OUTPUT_PATH "${SimpleExclude_BINARY_DIR}" CACHE INTERNAL "" FORCE)
-set(LIBRARY_OUTPUT_PATH "${SimpleExclude_BINARY_DIR}" CACHE INTERNAL "" FORCE)
-
-add_subdirectory(dirC EXCLUDE_FROM_ALL)
-add_subdirectory(dirD)
-
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/run.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/run.cmake" @ONLY)
diff --git a/Tests/SimpleExclude/dirC/CMakeLists.txt b/Tests/SimpleExclude/dirC/CMakeLists.txt
deleted file mode 100644
index 9b59fdaff..000000000
--- a/Tests/SimpleExclude/dirC/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-add_subdirectory(dirA EXCLUDE_FROM_ALL)
-add_subdirectory(dirB)
-
diff --git a/Tests/SimpleExclude/dirC/dirA/CMakeLists.txt b/Tests/SimpleExclude/dirC/dirA/CMakeLists.txt
deleted file mode 100644
index 52fac8183..000000000
--- a/Tests/SimpleExclude/dirC/dirA/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-add_library(t1 STATIC t1.c)
-
-add_library(t2 STATIC t2.c)
-
-add_executable(t3 t3.c)
-
-add_executable(t4 t4.c)
-
-add_executable(t5 t5.c)
-target_link_libraries(t5 t1)
diff --git a/Tests/SimpleExclude/dirC/dirA/t1.c b/Tests/SimpleExclude/dirC/dirA/t1.c
deleted file mode 100644
index 67fe06fee..000000000
--- a/Tests/SimpleExclude/dirC/dirA/t1.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <stdio.h>
-
-int tlib1func()
-{
- Should not be build unless target directory A, B, or C are build;
- printf("This is T1\n");
- return 5;
-}
diff --git a/Tests/SimpleExclude/dirC/dirA/t2.c b/Tests/SimpleExclude/dirC/dirA/t2.c
deleted file mode 100644
index 6aaf40675..000000000
--- a/Tests/SimpleExclude/dirC/dirA/t2.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <stdio.h>
-
-int tlib2func()
-{
- printf("This is T2\n");
- return 2;
-}
diff --git a/Tests/SimpleExclude/dirC/dirA/t3.c b/Tests/SimpleExclude/dirC/dirA/t3.c
deleted file mode 100644
index 1366dc0a6..000000000
--- a/Tests/SimpleExclude/dirC/dirA/t3.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <stdio.h>
-
-int main(int argc, char* argv[])
-{
- Should not be build unless target directory A, B, or C are build;
- return 0;
-}
diff --git a/Tests/SimpleExclude/dirC/dirA/t4.c b/Tests/SimpleExclude/dirC/dirA/t4.c
deleted file mode 100644
index b0e400014..000000000
--- a/Tests/SimpleExclude/dirC/dirA/t4.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <stdio.h>
-
-#ifdef __CLASSIC_C__
-int main()
-{
- int ac;
- char* av[];
-#else
-int main(int ac, char* av[])
-{
-#endif
- if (ac > 1000) {
- return *av[0];
- }
- printf("This is T4. This one should work.\n");
- return 0;
-}
diff --git a/Tests/SimpleExclude/dirC/dirA/t5.c b/Tests/SimpleExclude/dirC/dirA/t5.c
deleted file mode 100644
index 1fba2127c..000000000
--- a/Tests/SimpleExclude/dirC/dirA/t5.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <stdio.h>
-
-int main(int argc, char* argv[])
-{
- Should not be build unless target directory A, B, or C are build;
- return 5;
-}
diff --git a/Tests/SimpleExclude/dirC/dirB/CMakeLists.txt b/Tests/SimpleExclude/dirC/dirB/CMakeLists.txt
deleted file mode 100644
index ea4650c4a..000000000
--- a/Tests/SimpleExclude/dirC/dirB/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-add_library(t6 STATIC t6.c)
-
-add_library(t7 STATIC t7.c)
-target_link_libraries(t7 t2)
-
diff --git a/Tests/SimpleExclude/dirC/dirB/t6.c b/Tests/SimpleExclude/dirC/dirB/t6.c
deleted file mode 100644
index e8877df60..000000000
--- a/Tests/SimpleExclude/dirC/dirB/t6.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <stdio.h>
-
-int tlib6func()
-{
- Should not be build unless target directory B, or C are build;
- printf("This is T6\n");
- return 6;
-}
diff --git a/Tests/SimpleExclude/dirC/dirB/t7.c b/Tests/SimpleExclude/dirC/dirB/t7.c
deleted file mode 100644
index b613e9175..000000000
--- a/Tests/SimpleExclude/dirC/dirB/t7.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <stdio.h>
-
-extern int tlib2func();
-
-int tlib7func()
-{
- printf("This is T7\n");
-
- if (tlib2func() != 2) {
- fprintf(stderr, "Something wrong with T2\n");
- return 1;
- }
-
- return 7;
-}
diff --git a/Tests/SimpleExclude/dirD/CMakeLists.txt b/Tests/SimpleExclude/dirD/CMakeLists.txt
deleted file mode 100644
index 44b8c27b6..000000000
--- a/Tests/SimpleExclude/dirD/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-add_library(t8 STATIC t8.c)
-
-add_executable(t9 t9.c)
-target_link_libraries(t9 t7)
-
-add_custom_target(t4_custom ALL)
-add_dependencies(t4_custom t4)
diff --git a/Tests/SimpleExclude/dirD/t8.c b/Tests/SimpleExclude/dirD/t8.c
deleted file mode 100644
index bddec6f7e..000000000
--- a/Tests/SimpleExclude/dirD/t8.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <stdio.h>
-
-int tlib8func()
-{
- printf("This is T8\n");
- return 8;
-}
diff --git a/Tests/SimpleExclude/dirD/t9.c b/Tests/SimpleExclude/dirD/t9.c
deleted file mode 100644
index 9954ea567..000000000
--- a/Tests/SimpleExclude/dirD/t9.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <stdio.h>
-
-extern int tlib7func();
-
-#ifdef __CLASSIC_C__
-int main()
-{
- int ac;
- char* av[];
-#else
-int main(int ac, char* av[])
-{
-#endif
- if (ac > 1000) {
- return *av[0];
- }
- printf("This is T9. This one should work.\n");
-
- if (tlib7func() != 7) {
- fprintf(stderr, "Something wrong with T7\n");
- return 1;
- }
- return 0;
-}
diff --git a/Tests/SimpleExclude/run.cmake.in b/Tests/SimpleExclude/run.cmake.in
deleted file mode 100644
index d31d2e51b..000000000
--- a/Tests/SimpleExclude/run.cmake.in
+++ /dev/null
@@ -1,13 +0,0 @@
-set(t4_name "\"@CMAKE_CURRENT_BINARY_DIR@${CFG_DIR}/t4\"")
-exec_program("${t4_name}" RETURN_VALUE "t4_var")
-message("T4 ${t4_name} resulted ${t4_var}")
-
-set(t9_name "\"@CMAKE_CURRENT_BINARY_DIR@${CFG_DIR}/t9\"")
-exec_program("${t9_name}" RETURN_VALUE "t9_var")
-message("T9 ${t9_name} resulted ${t9_var}")
-
-if ( "${t4_var}" EQUAL "0" AND "${t9_var}" EQUAL "0" )
- message("Everything is good, Yoshimi won...")
-else ()
- message(FATAL_ERROR "Yoshimi lost... The evil pink robots will take over the world")
-endif ()
diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt
deleted file mode 100644
index f8068b143..000000000
--- a/Tests/SimpleInstall/CMakeLists.txt
+++ /dev/null
@@ -1,397 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-project (TestSimpleInstall)
-set(CMAKE_VERBOSE_MAKEFILE 1)
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
- "${TestSimpleInstall_BINARY_DIR}/bin")
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
- "${TestSimpleInstall_BINARY_DIR}/lib/static")
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
- "${TestSimpleInstall_BINARY_DIR}/lib")
-
-# Skip generating the rpath pointing at the build tree to make sure
-# the executable is installed with the proper rpath in the install
-# tree.
-set(CMAKE_SKIP_BUILD_RPATH 1)
-
-# Make sure the executable can run from the install tree.
-set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
-
-# Skip the dependency that causes a build when installing. This
-# avoids infinite loops when the post-build rule below installs.
-set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1)
-set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY 1)
-
-set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix")
-
-set(EXTRA_INSTALL_FLAGS)
-message("Extra install: ${EXTRA_INSTALL_FLAGS}")
-
-if(STAGE2)
- set(LIBPATHS
- ${CMAKE_INSTALL_PREFIX}/MyTest/lib/static
- ${CMAKE_INSTALL_PREFIX}/MyTest/lib
- )
- set(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX} test1rel)
- set(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX})
- set(t4NAMES test4out test4out${CMAKE_DEBUG_POSTFIX})
-
- # Make sure the install script ran.
- set(CMAKE_INSTALL_SCRIPT_DID_RUN 0)
- include(${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake OPTIONAL)
- if(CMAKE_INSTALL_SCRIPT_DID_RUN)
- message(STATUS "Stage 1 did run install script 2.")
- else()
- message(SEND_ERROR "Stage 1 did not run install script 2.")
- endif()
-
- if(CYGWIN OR MINGW)
- set(LIBPATHS ${LIBPATHS} "${CMAKE_INSTALL_PREFIX}/MyTest/bin")
- endif()
- message("Search for library in: ${LIBPATHS}")
-
- set(TEST1_LIBRARY "TEST1_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE)
- set(TEST2_LIBRARY "TEST2_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE)
- set(TEST4_LIBRARY "TEST4_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE)
-
- find_library(TEST1_LIBRARY
- NAMES ${t1NAMES}
- PATHS ${LIBPATHS}
- DOC "First library")
- find_library(TEST2_LIBRARY
- NAMES ${t2NAMES}
- PATHS ${LIBPATHS}
- DOC "Second library")
- find_library(TEST4_LIBRARY
- NAMES ${t4NAMES}
- PATHS ${LIBPATHS}
- DOC "Fourth library")
-
- # Test importing a library found on disk.
- add_library(lib_test4 UNKNOWN IMPORTED)
- set_property(TARGET lib_test4 PROPERTY IMPORTED_LOCATION ${TEST4_LIBRARY})
-
- include_directories(${CMAKE_INSTALL_PREFIX}/MyTest/include)
- add_executable (SimpleInstExeS2 inst2.cxx foo.c foo.h)
- target_link_libraries(SimpleInstExeS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} lib_test4)
- set(install_target SimpleInstExeS2)
-
- if("${TEST1_LIBRARY}" MATCHES "static")
- message(STATUS "test1 correctly found in lib/static")
- else()
- message(SEND_ERROR "test1 not found in lib/static!")
- endif()
-
- # Check for failure of configuration-specific installation.
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Release/lib1debug.h")
- message(FATAL_ERROR "Debug-configuration file installed for Release!")
- endif()
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h")
- message(FATAL_ERROR "Release-configuration file installed for Debug!")
- endif()
-
- # Check for failure of directory installation.
- if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/TSD.h")
- message(FATAL_ERROR "Directory installation did not install TSD.h")
- endif()
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS")
- message(FATAL_ERROR "Directory installation installed CVS directory.")
- endif()
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS")
- message(FATAL_ERROR "Directory installation installed CVS directory.")
- endif()
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CMakeLists.txt")
- message(FATAL_ERROR "Directory installation installed CMakeLists.txt.")
- endif()
- if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.h")
- message(FATAL_ERROR "Directory installation did not install alternate TSD.h")
- endif()
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.cxx")
- message(FATAL_ERROR "Directory installation installed alternate TSD.cxx")
- endif()
-
- # Check that scripts properly installed.
- if(WIN32 AND NOT CYGWIN)
- set(BAT .bat)
- else()
- set(BAT)
- endif()
- foreach(loc share share/old1 share/old2 share/old3 share/alt)
- set(CUR_SCRIPT "${CMAKE_INSTALL_PREFIX}/MyTest/${loc}/sample_script${BAT}")
- execute_process(
- COMMAND ${CUR_SCRIPT}
- RESULT_VARIABLE SAMPLE_SCRIPT_RESULT
- OUTPUT_VARIABLE SAMPLE_SCRIPT_OUTPUT
- )
- if(NOT "${SAMPLE_SCRIPT_RESULT}" STREQUAL "0")
- message(FATAL_ERROR
- "Sample script [${CUR_SCRIPT}] failed: [${SAMPLE_SCRIPT_RESULT}]")
- endif()
- if(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output")
- message(FATAL_ERROR
- "Bad sample script [${CUR_SCRIPT}] output: [${SAMPLE_SCRIPT_OUTPUT}]")
- endif()
- endforeach()
-
- # Check for failure of empty directory installation.
- if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty")
- message(FATAL_ERROR "Empty directory installation did not install.")
- endif()
- file(GLOB EMPTY_FILES "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty/*")
- if(EMPTY_FILES)
- message(FATAL_ERROR "Empty directory installed [${EMPTY_FILES}].")
- endif()
-
- # Make sure the test executable can run from the install tree.
- set_target_properties(SimpleInstExeS2 PROPERTIES
- INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
-
- install_targets(/MyTest/bin SimpleInstExeS2)
-
-# try to import the exported targets again
- set(SimpleInstallS1_DIR ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
- find_package(SimpleInstallS1 REQUIRED)
- get_target_property(simpleInstallImported S1_SimpleInstall IMPORTED)
- if(NOT simpleInstallImported)
- message(FATAL_ERROR "Target S1_SimpleInstall could not be imported")
- endif()
-
-else()
- # Wipe out the install directory to do a fresh test.
- file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/MyTest)
-
- # this is stage 1, so create libraries and modules and install everything
- add_library(test1 STATIC lib1.cxx)
- add_library(test2 SHARED lib2.cxx)
- add_library(test3 MODULE lib3.cxx)
- add_library(test4 SHARED lib4.cxx)
-
- # Test <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME properties.
- set_property(TARGET test4 PROPERTY ARCHIVE_OUTPUT_NAME test4out)
- set_property(TARGET test4 PROPERTY LIBRARY_OUTPUT_NAME test4out)
-
- add_executable (SimpleInstall inst.cxx foo.c foo.h)
- target_link_libraries(SimpleInstall test1 test2 test4)
- set(install_target SimpleInstall)
-
- set_target_properties(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe)
- # Disable VERSION test until it is implemented in the Xcode generator.
- if(NOT XCODE)
- set_target_properties(SimpleInstall PROPERTIES VERSION 1.2)
- endif()
-
- # Make sure the test executable can run from the install tree.
- set_target_properties(SimpleInstall PROPERTIES
- INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
-
- # Test per-configuration output name.
- set_target_properties(test1 PROPERTIES RELEASE_OUTPUT_NAME test1rel)
- set_target_properties(test2 PROPERTIES PUBLIC_HEADER foo.h)
-
- if(CMAKE_GENERATOR MATCHES "Makefiles")
- add_subdirectory(TestSubDir)
- add_dependencies(SimpleInstall TSD)
- endif()
-
- add_dependencies(SimpleInstall test3)
- add_dependencies(test2 test3)
- add_dependencies(test4 test2)
-
- install(TARGETS SimpleInstall test1 test2 test3 EXPORT SimpleInstallS1
- RUNTIME DESTINATION MyTest/bin COMPONENT Runtime # .exe, .dll
- LIBRARY DESTINATION MyTest/lib COMPONENT Runtime # .so, mod.dll
- ARCHIVE DESTINATION MyTest/lib/static COMPONENT Development # .a, .lib
- PUBLIC_HEADER DESTINATION MyTest/include COMPONENT Development
- )
-
- install(TARGETS test4 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
- RUNTIME DESTINATION MyTest/bin
- LIBRARY DESTINATION MyTest/lib
- ARCHIVE DESTINATION MyTest/lib/static
- OPTIONAL # for coverage...target should always exist
- )
- install(FILES lib1.h DESTINATION MyTest/include/$<1:foo>$<0:/wrong>)
- install(FILES lib2.h
- DESTINATION $<1:MyTest/include/foo>$<0:/wrong>
- COMPONENT Development
- PERMISSIONS OWNER_READ OWNER_WRITE
- RENAME lib2renamed.h
- )
-
- # Test old-style install commands.
- install_files(/MyTest/include FILES lib3.h)
- install_files(/MyTest/include/old .h lib3)
- install_files(/MyTest/include/old "^lib2.h$")
- install_programs(/MyTest/share/old1 FILES
- scripts/sample_script scripts/sample_script.bat)
- install_programs(/MyTest/share/old2
- scripts/sample_script scripts/sample_script.bat)
-
-# "export" the targets collected in "SimpleInstallS1"
- install(EXPORT SimpleInstallS1 FILE SimpleInstallS1Config.cmake
- DESTINATION MyTest/lib
- NAMESPACE S1_ )
-
- export(TARGETS SimpleInstall test1 test2 test3
- FILE "${CMAKE_CURRENT_BINARY_DIR}/SimpleInstallS1Config.cmake"
- NAMESPACE S2_ )
-
- add_subdirectory(scripts)
-
- # Test optional installation.
- install(FILES does_not_exist.h DESTINATION MyTest/include/foo OPTIONAL)
-
- # Test configuration-specific installation.
- install(FILES lib1.h RENAME lib1release.h CONFIGURATIONS Release
- DESTINATION MyTest/include/Release
- )
- install(FILES lib1.h RENAME lib1debug.h CONFIGURATIONS Debug
- DESTINATION MyTest/include/Debug
- )
-
- # Test directory installation.
- file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS")
- file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS")
- install(
- DIRECTORY TestSubDir $<1:scripts/>$<0:/wrong> DESTINATION $<1:MyTest/share>$<0:/wrong>
- FILE_PERMISSIONS OWNER_READ OWNER_WRITE
- DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
- GROUP_READ GROUP_EXECUTE
- PATTERN "CVS" EXCLUDE
- REGEX "\\.txt$" EXCLUDE
- PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
- )
-
- # Alternate directory installation for coverage.
- install(
- DIRECTORY $<1:scripts/>$<0:/wrong> DESTINATION $<1:MyTest/share/alt>$<0:/wrong>
- COMPONENT Development
- USE_SOURCE_PERMISSIONS
- PATTERN "CVS" EXCLUDE
- REGEX "\\.txt$" EXCLUDE
- )
- install(
- DIRECTORY TestSubDir DESTINATION $<1:MyTest/share/alt>$<0:/wrong>
- FILE_PERMISSIONS OWNER_READ OWNER_WRITE
- DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
- GROUP_READ GROUP_EXECUTE
- FILES_MATCHING PATTERN "*.h"
- )
-
- # Test empty directory installation.
- install(DIRECTORY DESTINATION MyTest/share/empty)
-
- # Test optional directory installation.
- install(DIRECTORY does-not-exist DESTINATION MyTest/share OPTIONAL)
-
- # Test user-specified install scripts, with and without COMPONENT.
- install(
- SCRIPT InstallScript1.cmake
- CODE "set(INSTALL_CODE_DID_RUN 1)"
- SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript2.cmake
- )
- install(
- SCRIPT InstallScript3.cmake
- CODE "set(INSTALL_CODE_WITH_COMPONENT_DID_RUN 1)"
- SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript4.cmake
- COMPONENT Development
- )
- set_directory_properties(PROPERTIES
- ADDITIONAL_MAKE_CLEAN_FILES
- "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake")
-
- set_target_properties(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT
- ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake)
- set_target_properties(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT
- ${CMAKE_CURRENT_SOURCE_DIR}/PostInstall.cmake)
- set_target_properties(test4 PROPERTIES VERSION 1.2 SOVERSION 3
- INSTALL_NAME_DIR @executable_path/../lib)
-endif()
-
-if(CMAKE_CONFIGURATION_TYPES)
- set(SI_CONFIG --config $<CONFIGURATION>)
-else()
- set(SI_CONFIG)
-endif()
-
-# Dummy test of CPack
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Test of packaging with cpack")
-set(CPACK_PACKAGE_VENDOR "Kitware")
-set(CPACK_INSTALL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/PackageScript.cmake")
-
-if(WIN32 AND NOT UNIX)
- find_program(NSIS_MAKENSIS NAMES makensis
- PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS]
- DOC "Where is makensis.exe located"
- )
- if(NOT NSIS_MAKENSIS)
- set(CPACK_GENERATOR TGZ)
- endif()
-endif()
-if(UNIX AND NOT APPLE)
- set(CPACK_GENERATOR "TGZ;STGZ;TZ")
- # find_program(found_compress
- # NAMES compress)
- # if(found_compress)
- # find_program(file_command NAMES file)
- # if(NOT file_command)
- # set(file_command file)
- # endif()
- # execute_process(COMMAND ${file_command} ${found_compress}
- # OUTPUT_VARIABLE output)
- # set(SKIP_TZ FALSE)
- # if("${output}" MATCHES "script")
- # set(SKIP_TZ TRUE)
- # endif()
- # if("${output}" MATCHES "dummy.sh")
- # set(SKIP_TZ TRUE)
- # endif()
- # if(NOT SKIP_TZ)
- # message("compress found and it was not a script")
- # message("output from file command: [${output}]")
- # list(APPEND CPACK_GENERATOR "TZ")
- # else()
- # message("compress found, but it was a script so dont use it")
- # message("output from file command: [${output}]")
- # endif()
- # endif()
- find_program(found_bz2
- NAMES bzip2)
- if(found_bz2)
- list(APPEND CPACK_GENERATOR "TBZ2")
- endif()
-endif()
-
-set(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install")
-set(CMAKE_INSTALL_MFC_LIBRARIES 1)
-set(CMAKE_INSTALL_DEBUG_LIBRARIES 1)
-set(CMAKE_INSTALL_UCRT_LIBRARIES 1)
-set(CMAKE_INSTALL_OPENMP_LIBRARIES 1)
-include(InstallRequiredSystemLibraries)
-
-if(CTEST_TEST_CPACK)
- set(package_command COMMAND
- ${CMAKE_COMMAND} --build . --target package ${SI_CONFIG}
- )
-
- # Avoid settings that require the .zip file command line tools...
- # (just build an NSIS installer without component support)
- #
- set(CPACK_BINARY_ZIP OFF)
- set(CPACK_MONOLITHIC_INSTALL ON)
-else()
- set(package_command)
-endif()
-
-include(CPack)
-
-set(install_command COMMAND
- ${CMAKE_COMMAND} --build . --target install ${SI_CONFIG}
- )
-
-add_custom_command(
- TARGET ${install_target}
- POST_BUILD
- ${install_command}
- ${package_command}
- COMMENT "Install Project"
- )
diff --git a/Tests/SimpleInstall/InstallScript1.cmake b/Tests/SimpleInstall/InstallScript1.cmake
deleted file mode 100644
index ef9da5761..000000000
--- a/Tests/SimpleInstall/InstallScript1.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-message("This is install script 1.")
-set(INSTALL_SCRIPT_1_DID_RUN 1)
-if(INSTALL_CODE_DID_RUN)
- message(FATAL_ERROR "Install script 1 did not run before install code.")
-endif()
diff --git a/Tests/SimpleInstall/InstallScript2.cmake b/Tests/SimpleInstall/InstallScript2.cmake
deleted file mode 100644
index c1d20a3a6..000000000
--- a/Tests/SimpleInstall/InstallScript2.cmake
+++ /dev/null
@@ -1,14 +0,0 @@
-message("This is install script 2.")
-if(INSTALL_SCRIPT_1_DID_RUN)
- message("Install script ordering works.")
-else()
- message(FATAL_ERROR "Install script 1 did not run before install script 2.")
-endif()
-if(INSTALL_CODE_DID_RUN)
- message("Install code ordering works.")
-else()
- message(FATAL_ERROR "Install script 2 did not run after install code.")
-endif()
-file(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake"
- "set(CMAKE_INSTALL_SCRIPT_DID_RUN 1)\n"
- )
diff --git a/Tests/SimpleInstall/InstallScript3.cmake b/Tests/SimpleInstall/InstallScript3.cmake
deleted file mode 100644
index 64851564d..000000000
--- a/Tests/SimpleInstall/InstallScript3.cmake
+++ /dev/null
@@ -1,12 +0,0 @@
-message("This is install script 3.")
-set(INSTALL_SCRIPT_3_DID_RUN 1)
-if(INSTALL_CODE_WITH_COMPONENT_DID_RUN)
- message(FATAL_ERROR "Install script 3 did not run before install code with component.")
-endif()
-
-if(CMAKE_INSTALL_COMPONENT)
-if(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development")
- message("CMAKE_INSTALL_COMPONENT=\"${CMAKE_INSTALL_COMPONENT}\"")
- message(FATAL_ERROR "Install script 3 should only run for \"Development\" INSTALL COMPONENT.")
-endif()
-endif()
diff --git a/Tests/SimpleInstall/InstallScript4.cmake b/Tests/SimpleInstall/InstallScript4.cmake
deleted file mode 100644
index 34d0a73bb..000000000
--- a/Tests/SimpleInstall/InstallScript4.cmake
+++ /dev/null
@@ -1,22 +0,0 @@
-message("This is install script 4.")
-if(INSTALL_SCRIPT_3_DID_RUN)
- message("Install script ordering works.")
-else()
- message(FATAL_ERROR "Install script 3 did not run before install script 4.")
-endif()
-if(INSTALL_CODE_WITH_COMPONENT_DID_RUN)
- message("Install code ordering works.")
-else()
- message(FATAL_ERROR "Install script 4 did not run after install with component code.")
-endif()
-
-if(CMAKE_INSTALL_COMPONENT)
-if(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development")
- message("CMAKE_INSTALL_COMPONENT=\"${CMAKE_INSTALL_COMPONENT}\"")
- message(FATAL_ERROR "Install script 4 should only run for \"Development\" INSTALL COMPONENT.")
-endif()
-endif()
-
-file(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScript4Out.cmake"
- "set(CMAKE_INSTALL_SCRIPT_4_DID_RUN 1)\n"
- )
diff --git a/Tests/SimpleInstall/PackageScript.cmake b/Tests/SimpleInstall/PackageScript.cmake
deleted file mode 100644
index 53b790932..000000000
--- a/Tests/SimpleInstall/PackageScript.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
-message("This is packaging script")
-message("It writes a file with all variables available in ${CMAKE_INSTALL_PREFIX}/AllVariables.txt")
-
-file(WRITE ${CMAKE_INSTALL_PREFIX}/AllVariables.txt "")
-get_cmake_property(res VARIABLES)
-foreach(var ${res})
- file(APPEND ${CMAKE_INSTALL_PREFIX}/AllVariables.txt
- "${var} \"${${var}}\"\n")
-endforeach()
-
diff --git a/Tests/SimpleInstall/PostInstall.cmake b/Tests/SimpleInstall/PostInstall.cmake
deleted file mode 100644
index d616221ef..000000000
--- a/Tests/SimpleInstall/PostInstall.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-message("In post install")
-if(PRE_INSTALL_DID_RUN)
- message("Pre and post install work fine")
-else()
- message(FATAL_ERROR "Pre install did not run before post install")
-endif()
diff --git a/Tests/SimpleInstall/PreInstall.cmake b/Tests/SimpleInstall/PreInstall.cmake
deleted file mode 100644
index 7a9851e1d..000000000
--- a/Tests/SimpleInstall/PreInstall.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-message("This is in pre install")
-set(PRE_INSTALL_DID_RUN 1)
diff --git a/Tests/SimpleInstall/TestSubDir/CMakeLists.txt b/Tests/SimpleInstall/TestSubDir/CMakeLists.txt
deleted file mode 100644
index 860e10425..000000000
--- a/Tests/SimpleInstall/TestSubDir/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-add_executable(TSD TSD.cxx TSD_utils.cxx)
-install_files(/MyTest/include FILES TSD.h)
-install_targets(/MyTest/bin TSD)
diff --git a/Tests/SimpleInstall/TestSubDir/TSD.cxx b/Tests/SimpleInstall/TestSubDir/TSD.cxx
deleted file mode 100644
index 8fc38787a..000000000
--- a/Tests/SimpleInstall/TestSubDir/TSD.cxx
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <stdio.h>
-
-#include "TSD.h"
-
-int main()
-{
- int res = TSD("TEST");
- printf("Hello from TSD\n");
- return res;
-}
diff --git a/Tests/SimpleInstall/TestSubDir/TSD.h b/Tests/SimpleInstall/TestSubDir/TSD.h
deleted file mode 100644
index 6a3c1affa..000000000
--- a/Tests/SimpleInstall/TestSubDir/TSD.h
+++ /dev/null
@@ -1 +0,0 @@
-int TSD(const char*);
diff --git a/Tests/SimpleInstall/TestSubDir/TSD_utils.cxx b/Tests/SimpleInstall/TestSubDir/TSD_utils.cxx
deleted file mode 100644
index 0f32894fe..000000000
--- a/Tests/SimpleInstall/TestSubDir/TSD_utils.cxx
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <string.h>
-
-int TSD(const char* foo)
-{
- if (strcmp(foo, "TEST") == 0) {
- return 0;
- }
- return 1;
-}
diff --git a/Tests/SimpleInstall/foo.c b/Tests/SimpleInstall/foo.c
deleted file mode 100644
index 45d5b2bf2..000000000
--- a/Tests/SimpleInstall/foo.c
+++ /dev/null
@@ -1,6 +0,0 @@
-char* foo = "Foo";
-
-int SomeFunctionInFoo()
-{
- return 5;
-}
diff --git a/Tests/SimpleInstall/foo.h b/Tests/SimpleInstall/foo.h
deleted file mode 100644
index 216cdf67b..000000000
--- a/Tests/SimpleInstall/foo.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern char* foo;
-extern int SomeFunctionInFoo();
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Tests/SimpleInstall/inst.cxx b/Tests/SimpleInstall/inst.cxx
deleted file mode 100644
index ecf061c80..000000000
--- a/Tests/SimpleInstall/inst.cxx
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "foo.h"
-
-#ifdef STAGE_2
-#include <foo/lib1.h>
-#include <foo/lib2renamed.h>
-#include <lib3.h>
-#include <old/lib2.h>
-#include <old/lib3.h>
-#else
-#include "lib1.h"
-#include "lib2.h"
-#endif
-
-#include "lib4.h"
-
-#include <stdio.h>
-
-int main()
-{
- if (Lib1Func() != 2.0) {
- printf("Problem with lib1\n");
- return 1;
- }
- if (Lib2Func() != 1.0) {
- printf("Problem with lib2\n");
- return 1;
- }
- if (Lib4Func() != 4.0) {
- printf("Problem with lib4\n");
- return 1;
- }
- printf("The value of Foo: %s\n", foo);
- return SomeFunctionInFoo() - 5;
-}
diff --git a/Tests/SimpleInstall/inst2.cxx b/Tests/SimpleInstall/inst2.cxx
deleted file mode 100644
index c70b93af1..000000000
--- a/Tests/SimpleInstall/inst2.cxx
+++ /dev/null
@@ -1,2 +0,0 @@
-#define STAGE_2
-#include "inst.cxx"
diff --git a/Tests/SimpleInstall/lib1.cxx b/Tests/SimpleInstall/lib1.cxx
deleted file mode 100644
index 7aa905205..000000000
--- a/Tests/SimpleInstall/lib1.cxx
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "lib1.h"
-
-float Lib1Func()
-{
- return 2.0;
-}
diff --git a/Tests/SimpleInstall/lib1.h b/Tests/SimpleInstall/lib1.h
deleted file mode 100644
index 0d64e76bc..000000000
--- a/Tests/SimpleInstall/lib1.h
+++ /dev/null
@@ -1 +0,0 @@
-extern float Lib1Func();
diff --git a/Tests/SimpleInstall/lib2.cxx b/Tests/SimpleInstall/lib2.cxx
deleted file mode 100644
index dccc48b78..000000000
--- a/Tests/SimpleInstall/lib2.cxx
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "lib2.h"
-
-float Lib2Func()
-{
- return 1.0;
-}
diff --git a/Tests/SimpleInstall/lib2.h b/Tests/SimpleInstall/lib2.h
deleted file mode 100644
index a3ed758fc..000000000
--- a/Tests/SimpleInstall/lib2.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifdef _WIN32
-#ifdef test2_EXPORTS
-#define CM_TEST_LIB_EXPORT __declspec(dllexport)
-#else
-#define CM_TEST_LIB_EXPORT __declspec(dllimport)
-#endif
-#else
-#define CM_TEST_LIB_EXPORT
-#endif
-
-CM_TEST_LIB_EXPORT float Lib2Func();
diff --git a/Tests/SimpleInstall/lib3.cxx b/Tests/SimpleInstall/lib3.cxx
deleted file mode 100644
index da8dbf942..000000000
--- a/Tests/SimpleInstall/lib3.cxx
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "lib3.h"
-
-float Lib3Func()
-{
- return 2.0;
-}
diff --git a/Tests/SimpleInstall/lib3.h b/Tests/SimpleInstall/lib3.h
deleted file mode 100644
index df11327c7..000000000
--- a/Tests/SimpleInstall/lib3.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifdef _WIN32
-#ifdef test3_EXPORTS
-#define CM_TEST_LIB_EXPORT __declspec(dllexport)
-#else
-#define CM_TEST_LIB_EXPORT __declspec(dllimport)
-#endif
-#else
-#define CM_TEST_LIB_EXPORT
-#endif
-
-CM_TEST_LIB_EXPORT float Lib3Func();
diff --git a/Tests/SimpleInstall/lib4.cxx b/Tests/SimpleInstall/lib4.cxx
deleted file mode 100644
index fbede5ce5..000000000
--- a/Tests/SimpleInstall/lib4.cxx
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "lib4.h"
-
-float Lib4Func()
-{
- return 4.0;
-}
diff --git a/Tests/SimpleInstall/lib4.h b/Tests/SimpleInstall/lib4.h
deleted file mode 100644
index 71425a5c8..000000000
--- a/Tests/SimpleInstall/lib4.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifdef _WIN32
-#ifdef test4_EXPORTS
-#define CM_TEST_LIB_EXPORT __declspec(dllexport)
-#else
-#define CM_TEST_LIB_EXPORT __declspec(dllimport)
-#endif
-#else
-#define CM_TEST_LIB_EXPORT
-#endif
-
-CM_TEST_LIB_EXPORT float Lib4Func();
diff --git a/Tests/SimpleInstall/scripts/.gitattributes b/Tests/SimpleInstall/scripts/.gitattributes
deleted file mode 100644
index 5e3db2fb3..000000000
--- a/Tests/SimpleInstall/scripts/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-sample_script crlf=input
diff --git a/Tests/SimpleInstall/scripts/CMakeLists.txt b/Tests/SimpleInstall/scripts/CMakeLists.txt
deleted file mode 100644
index ec34e8c50..000000000
--- a/Tests/SimpleInstall/scripts/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-install_programs(/MyTest/share/old3 "^sample_script(\\.bat)?$")
diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt
deleted file mode 100644
index 4cf73559b..000000000
--- a/Tests/SimpleInstallS2/CMakeLists.txt
+++ /dev/null
@@ -1,396 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-project (TestSimpleInstall)
-set(CMAKE_VERBOSE_MAKEFILE 1)
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
- "${TestSimpleInstall_BINARY_DIR}/bin")
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
- "${TestSimpleInstall_BINARY_DIR}/lib/static")
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
- "${TestSimpleInstall_BINARY_DIR}/lib")
-
-# Skip generating the rpath pointing at the build tree to make sure
-# the executable is installed with the proper rpath in the install
-# tree.
-set(CMAKE_SKIP_BUILD_RPATH 1)
-
-# Make sure the executable can run from the install tree.
-set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
-
-# Skip the dependency that causes a build when installing. This
-# avoids infinite loops when the post-build rule below installs.
-set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1)
-set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY 1)
-
-set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix")
-
-set(EXTRA_INSTALL_FLAGS)
-message("Extra install: ${EXTRA_INSTALL_FLAGS}")
-
-if(STAGE2)
- set(LIBPATHS
- ${CMAKE_INSTALL_PREFIX}/MyTest/lib/static
- ${CMAKE_INSTALL_PREFIX}/MyTest/lib
- )
- set(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX} test1rel)
- set(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX})
- set(t4NAMES test4out test4out${CMAKE_DEBUG_POSTFIX})
-
- # Make sure the install script ran.
- set(CMAKE_INSTALL_SCRIPT_DID_RUN 0)
- include(${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake OPTIONAL)
- if(CMAKE_INSTALL_SCRIPT_DID_RUN)
- message(STATUS "Stage 1 did run install script 2.")
- else()
- message(SEND_ERROR "Stage 1 did not run install script 2.")
- endif()
-
- if(CYGWIN OR MINGW)
- set(LIBPATHS ${LIBPATHS} "${CMAKE_INSTALL_PREFIX}/MyTest/bin")
- endif()
- message("Search for library in: ${LIBPATHS}")
-
- set(TEST1_LIBRARY "TEST1_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE)
- set(TEST2_LIBRARY "TEST2_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE)
- set(TEST4_LIBRARY "TEST4_LIBRARY-NOTFOUND" CACHE FILEPATH "Force find." FORCE)
-
- find_library(TEST1_LIBRARY
- NAMES ${t1NAMES}
- PATHS ${LIBPATHS}
- DOC "First library")
- find_library(TEST2_LIBRARY
- NAMES ${t2NAMES}
- PATHS ${LIBPATHS}
- DOC "Second library")
- find_library(TEST4_LIBRARY
- NAMES ${t4NAMES}
- PATHS ${LIBPATHS}
- DOC "Fourth library")
-
- # Test importing a library found on disk.
- add_library(lib_test4 UNKNOWN IMPORTED)
- set_property(TARGET lib_test4 PROPERTY IMPORTED_LOCATION ${TEST4_LIBRARY})
-
- include_directories(${CMAKE_INSTALL_PREFIX}/MyTest/include)
- add_executable (SimpleInstExeS2 inst2.cxx foo.c foo.h)
- target_link_libraries(SimpleInstExeS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} lib_test4)
- set(install_target SimpleInstExeS2)
-
- if("${TEST1_LIBRARY}" MATCHES "static")
- message(STATUS "test1 correctly found in lib/static")
- else()
- message(SEND_ERROR "test1 not found in lib/static!")
- endif()
-
- # Check for failure of configuration-specific installation.
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Release/lib1debug.h")
- message(FATAL_ERROR "Debug-configuration file installed for Release!")
- endif()
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/include/Debug/lib1release.h")
- message(FATAL_ERROR "Release-configuration file installed for Debug!")
- endif()
-
- # Check for failure of directory installation.
- if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/TSD.h")
- message(FATAL_ERROR "Directory installation did not install TSD.h")
- endif()
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS")
- message(FATAL_ERROR "Directory installation installed CVS directory.")
- endif()
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS")
- message(FATAL_ERROR "Directory installation installed CVS directory.")
- endif()
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/CMakeLists.txt")
- message(FATAL_ERROR "Directory installation installed CMakeLists.txt.")
- endif()
- if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.h")
- message(FATAL_ERROR "Directory installation did not install alternate TSD.h")
- endif()
- if(EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/alt/TestSubDir/TSD.cxx")
- message(FATAL_ERROR "Directory installation installed alternate TSD.cxx")
- endif()
-
- # Check that scripts properly installed.
- if(WIN32 AND NOT CYGWIN)
- set(BAT .bat)
- else()
- set(BAT)
- endif()
- foreach(loc share share/old1 share/old2 share/old3 share/alt)
- set(CUR_SCRIPT "${CMAKE_INSTALL_PREFIX}/MyTest/${loc}/sample_script${BAT}")
- execute_process(
- COMMAND ${CUR_SCRIPT}
- RESULT_VARIABLE SAMPLE_SCRIPT_RESULT
- OUTPUT_VARIABLE SAMPLE_SCRIPT_OUTPUT
- )
- if(NOT "${SAMPLE_SCRIPT_RESULT}" STREQUAL "0")
- message(FATAL_ERROR
- "Sample script [${CUR_SCRIPT}] failed: [${SAMPLE_SCRIPT_RESULT}]")
- endif()
- if(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output")
- message(FATAL_ERROR
- "Bad sample script [${CUR_SCRIPT}] output: [${SAMPLE_SCRIPT_OUTPUT}]")
- endif()
- endforeach()
-
- # Check for failure of empty directory installation.
- if(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty")
- message(FATAL_ERROR "Empty directory installation did not install.")
- endif()
- file(GLOB EMPTY_FILES "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty/*")
- if(EMPTY_FILES)
- message(FATAL_ERROR "Empty directory installed [${EMPTY_FILES}].")
- endif()
-
- # Make sure the test executable can run from the install tree.
- set_target_properties(SimpleInstExeS2 PROPERTIES
- INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
-
- install_targets(/MyTest/bin SimpleInstExeS2)
-
-# try to import the exported targets again
- set(SimpleInstallS1_DIR ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
- find_package(SimpleInstallS1 REQUIRED)
- get_target_property(simpleInstallImported S1_SimpleInstall IMPORTED)
- if(NOT simpleInstallImported)
- message(FATAL_ERROR "Target S1_SimpleInstall could not be imported")
- endif()
-
-else()
- # Wipe out the install directory to do a fresh test.
- file(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/MyTest)
-
- # this is stage 1, so create libraries and modules and install everything
- add_library(test1 STATIC lib1.cxx)
- add_library(test2 SHARED lib2.cxx)
- add_library(test3 MODULE lib3.cxx)
- add_library(test4 SHARED lib4.cxx)
-
- # Test <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME properties.
- set_property(TARGET test4 PROPERTY ARCHIVE_OUTPUT_NAME test4out)
- set_property(TARGET test4 PROPERTY LIBRARY_OUTPUT_NAME test4out)
-
- add_executable (SimpleInstall inst.cxx foo.c foo.h)
- target_link_libraries(SimpleInstall test1 test2 test4)
- set(install_target SimpleInstall)
-
- set_target_properties(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe)
- # Disable VERSION test until it is implemented in the Xcode generator.
- if(NOT XCODE)
- set_target_properties(SimpleInstall PROPERTIES VERSION 1.2)
- endif()
-
- # Make sure the test executable can run from the install tree.
- set_target_properties(SimpleInstall PROPERTIES
- INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
-
- # Test per-configuration output name.
- set_target_properties(test1 PROPERTIES RELEASE_OUTPUT_NAME test1rel)
- set_target_properties(test2 PROPERTIES PUBLIC_HEADER foo.h)
-
- if(CMAKE_GENERATOR MATCHES "Makefiles")
- add_subdirectory(TestSubDir)
- add_dependencies(SimpleInstall TSD)
- endif()
-
- add_dependencies(SimpleInstall test3)
- add_dependencies(test2 test3)
- add_dependencies(test4 test2)
-
- install(TARGETS SimpleInstall test1 test2 test3 EXPORT SimpleInstallS1
- RUNTIME DESTINATION MyTest/bin COMPONENT Runtime # .exe, .dll
- LIBRARY DESTINATION MyTest/lib COMPONENT Runtime # .so, mod.dll
- ARCHIVE DESTINATION MyTest/lib/static COMPONENT Development # .a, .lib
- PUBLIC_HEADER DESTINATION MyTest/include COMPONENT Development
- )
-
- install(TARGETS test4 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
- RUNTIME DESTINATION MyTest/bin
- LIBRARY DESTINATION MyTest/lib
- ARCHIVE DESTINATION MyTest/lib/static
- OPTIONAL # for coverage...target should always exist
- )
- install(FILES lib1.h DESTINATION MyTest/include/$<1:foo>$<0:/wrong>)
- install(FILES lib2.h
- DESTINATION $<1:MyTest/include/foo>$<0:/wrong>
- COMPONENT Development
- PERMISSIONS OWNER_READ OWNER_WRITE
- RENAME lib2renamed.h
- )
-
- # Test old-style install commands.
- install_files(/MyTest/include FILES lib3.h)
- install_files(/MyTest/include/old .h lib3)
- install_files(/MyTest/include/old "^lib2.h$")
- install_programs(/MyTest/share/old1 FILES
- scripts/sample_script scripts/sample_script.bat)
- install_programs(/MyTest/share/old2
- scripts/sample_script scripts/sample_script.bat)
-
-# "export" the targets collected in "SimpleInstallS1"
- install(EXPORT SimpleInstallS1 FILE SimpleInstallS1Config.cmake
- DESTINATION MyTest/lib
- NAMESPACE S1_ )
-
- export(TARGETS SimpleInstall test1 test2 test3
- FILE "${CMAKE_CURRENT_BINARY_DIR}/SimpleInstallS1Config.cmake"
- NAMESPACE S2_ )
-
- add_subdirectory(scripts)
-
- # Test optional installation.
- install(FILES does_not_exist.h DESTINATION MyTest/include/foo OPTIONAL)
-
- # Test configuration-specific installation.
- install(FILES lib1.h RENAME lib1release.h CONFIGURATIONS Release
- DESTINATION MyTest/include/Release
- )
- install(FILES lib1.h RENAME lib1debug.h CONFIGURATIONS Debug
- DESTINATION MyTest/include/Debug
- )
-
- # Test directory installation.
- file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/CVS")
- file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}/MyTest/share/TestSubDir/CVS")
- install(
- DIRECTORY TestSubDir $<1:scripts/>$<0:/wrong> DESTINATION $<1:MyTest/share>$<0:/wrong>
- FILE_PERMISSIONS OWNER_READ OWNER_WRITE
- DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
- GROUP_READ GROUP_EXECUTE
- PATTERN "CVS" EXCLUDE
- REGEX "\\.txt$" EXCLUDE
- PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
- )
-
- # Alternate directory installation for coverage.
- install(
- DIRECTORY $<1:scripts/>$<0:/wrong> DESTINATION $<1:MyTest/share/alt>$<0:/wrong>
- COMPONENT Development
- USE_SOURCE_PERMISSIONS
- PATTERN "CVS" EXCLUDE
- REGEX "\\.txt$" EXCLUDE
- )
- install(
- DIRECTORY TestSubDir DESTINATION $<1:MyTest/share/alt>$<0:/wrong>
- FILE_PERMISSIONS OWNER_READ OWNER_WRITE
- DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
- GROUP_READ GROUP_EXECUTE
- FILES_MATCHING PATTERN "*.h"
- )
-
- # Test empty directory installation.
- install(DIRECTORY DESTINATION MyTest/share/empty)
-
- # Test optional directory installation.
- install(DIRECTORY does-not-exist DESTINATION MyTest/share OPTIONAL)
-
- # Test user-specified install scripts, with and without COMPONENT.
- install(
- SCRIPT InstallScript1.cmake
- CODE "set(INSTALL_CODE_DID_RUN 1)"
- SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript2.cmake
- )
- install(
- SCRIPT InstallScript3.cmake
- CODE "set(INSTALL_CODE_WITH_COMPONENT_DID_RUN 1)"
- SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/InstallScript4.cmake
- COMPONENT Development
- )
- set_directory_properties(PROPERTIES
- ADDITIONAL_MAKE_CLEAN_FILES
- "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake")
-
- set_target_properties(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT
- ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake)
- set_target_properties(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT
- ${CMAKE_CURRENT_SOURCE_DIR}/PostInstall.cmake)
- set_target_properties(test4 PROPERTIES VERSION 1.2 SOVERSION 3
- INSTALL_NAME_DIR @executable_path/../lib)
-endif()
-
-if(CMAKE_CONFIGURATION_TYPES)
- set(SI_CONFIG --config $<CONFIGURATION>)
-else()
- set(SI_CONFIG)
-endif()
-
-# Dummy test of CPack
-set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Test of packaging with cpack")
-set(CPACK_PACKAGE_VENDOR "Kitware")
-set(CPACK_INSTALL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/PackageScript.cmake")
-
-if(WIN32 AND NOT UNIX)
- find_program(NSIS_MAKENSIS NAMES makensis
- PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS]
- DOC "Where is makensis.exe located"
- )
- if(NOT NSIS_MAKENSIS)
- set(CPACK_GENERATOR TGZ)
- endif()
-endif()
-if(UNIX AND NOT APPLE)
- set(CPACK_GENERATOR "TGZ;STGZ;TZ")
- # find_program(found_compress
- # NAMES compress)
- # if(found_compress)
- # find_program(file_command NAMES file)
- # if(NOT file_command)
- # set(file_command file)
- # endif()
- # execute_process(COMMAND ${file_command} ${found_compress}
- # OUTPUT_VARIABLE output)
- # set(SKIP_TZ FALSE)
- # if("${output}" MATCHES "script")
- # set(SKIP_TZ TRUE)
- # endif()
- # if("${output}" MATCHES "dummy.sh")
- # set(SKIP_TZ TRUE)
- # endif()
- # if(NOT SKIP_TZ)
- # message("compress found and it was not a script")
- # message("output from file command: [${output}]")
- # list(APPEND CPACK_GENERATOR "TZ")
- # else()
- # message("compress found, but it was a script so dont use it")
- # message("output from file command: [${output}]")
- # endif()
- # endif()
- find_program(found_bz2
- NAMES bzip2)
- if(found_bz2)
- list(APPEND CPACK_GENERATOR "TBZ2")
- endif()
-endif()
-
-set(CPACK_PACKAGE_EXECUTABLES "SimpleInstall" "Simple Install")
-set(CMAKE_INSTALL_MFC_LIBRARIES 1)
-set(CMAKE_INSTALL_DEBUG_LIBRARIES 1)
-set(CMAKE_INSTALL_UCRT_LIBRARIES 1)
-include(InstallRequiredSystemLibraries)
-
-if(CTEST_TEST_CPACK)
- set(package_command COMMAND
- ${CMAKE_COMMAND} --build . --target package ${SI_CONFIG}
- )
-
- # Avoid settings that require the .zip file command line tools...
- # (just build an NSIS installer without component support)
- #
- set(CPACK_BINARY_ZIP OFF)
- set(CPACK_MONOLITHIC_INSTALL ON)
-else()
- set(package_command)
-endif()
-
-include(CPack)
-
-set(install_command COMMAND
- ${CMAKE_COMMAND} --build . --target install ${SI_CONFIG}
- )
-
-add_custom_command(
- TARGET ${install_target}
- POST_BUILD
- ${install_command}
- ${package_command}
- COMMENT "Install Project"
- )
diff --git a/Tests/SimpleInstallS2/InstallScript1.cmake b/Tests/SimpleInstallS2/InstallScript1.cmake
deleted file mode 100644
index ef9da5761..000000000
--- a/Tests/SimpleInstallS2/InstallScript1.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-message("This is install script 1.")
-set(INSTALL_SCRIPT_1_DID_RUN 1)
-if(INSTALL_CODE_DID_RUN)
- message(FATAL_ERROR "Install script 1 did not run before install code.")
-endif()
diff --git a/Tests/SimpleInstallS2/InstallScript2.cmake b/Tests/SimpleInstallS2/InstallScript2.cmake
deleted file mode 100644
index c1d20a3a6..000000000
--- a/Tests/SimpleInstallS2/InstallScript2.cmake
+++ /dev/null
@@ -1,14 +0,0 @@
-message("This is install script 2.")
-if(INSTALL_SCRIPT_1_DID_RUN)
- message("Install script ordering works.")
-else()
- message(FATAL_ERROR "Install script 1 did not run before install script 2.")
-endif()
-if(INSTALL_CODE_DID_RUN)
- message("Install code ordering works.")
-else()
- message(FATAL_ERROR "Install script 2 did not run after install code.")
-endif()
-file(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScriptOut.cmake"
- "set(CMAKE_INSTALL_SCRIPT_DID_RUN 1)\n"
- )
diff --git a/Tests/SimpleInstallS2/InstallScript3.cmake b/Tests/SimpleInstallS2/InstallScript3.cmake
deleted file mode 100644
index 64851564d..000000000
--- a/Tests/SimpleInstallS2/InstallScript3.cmake
+++ /dev/null
@@ -1,12 +0,0 @@
-message("This is install script 3.")
-set(INSTALL_SCRIPT_3_DID_RUN 1)
-if(INSTALL_CODE_WITH_COMPONENT_DID_RUN)
- message(FATAL_ERROR "Install script 3 did not run before install code with component.")
-endif()
-
-if(CMAKE_INSTALL_COMPONENT)
-if(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development")
- message("CMAKE_INSTALL_COMPONENT=\"${CMAKE_INSTALL_COMPONENT}\"")
- message(FATAL_ERROR "Install script 3 should only run for \"Development\" INSTALL COMPONENT.")
-endif()
-endif()
diff --git a/Tests/SimpleInstallS2/InstallScript4.cmake b/Tests/SimpleInstallS2/InstallScript4.cmake
deleted file mode 100644
index 34d0a73bb..000000000
--- a/Tests/SimpleInstallS2/InstallScript4.cmake
+++ /dev/null
@@ -1,22 +0,0 @@
-message("This is install script 4.")
-if(INSTALL_SCRIPT_3_DID_RUN)
- message("Install script ordering works.")
-else()
- message(FATAL_ERROR "Install script 3 did not run before install script 4.")
-endif()
-if(INSTALL_CODE_WITH_COMPONENT_DID_RUN)
- message("Install code ordering works.")
-else()
- message(FATAL_ERROR "Install script 4 did not run after install with component code.")
-endif()
-
-if(CMAKE_INSTALL_COMPONENT)
-if(NOT "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Development")
- message("CMAKE_INSTALL_COMPONENT=\"${CMAKE_INSTALL_COMPONENT}\"")
- message(FATAL_ERROR "Install script 4 should only run for \"Development\" INSTALL COMPONENT.")
-endif()
-endif()
-
-file(WRITE "${CMAKE_INSTALL_PREFIX}/MyTest/InstallScript4Out.cmake"
- "set(CMAKE_INSTALL_SCRIPT_4_DID_RUN 1)\n"
- )
diff --git a/Tests/SimpleInstallS2/PackageScript.cmake b/Tests/SimpleInstallS2/PackageScript.cmake
deleted file mode 100644
index 53b790932..000000000
--- a/Tests/SimpleInstallS2/PackageScript.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
-message("This is packaging script")
-message("It writes a file with all variables available in ${CMAKE_INSTALL_PREFIX}/AllVariables.txt")
-
-file(WRITE ${CMAKE_INSTALL_PREFIX}/AllVariables.txt "")
-get_cmake_property(res VARIABLES)
-foreach(var ${res})
- file(APPEND ${CMAKE_INSTALL_PREFIX}/AllVariables.txt
- "${var} \"${${var}}\"\n")
-endforeach()
-
diff --git a/Tests/SimpleInstallS2/PostInstall.cmake b/Tests/SimpleInstallS2/PostInstall.cmake
deleted file mode 100644
index d616221ef..000000000
--- a/Tests/SimpleInstallS2/PostInstall.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-message("In post install")
-if(PRE_INSTALL_DID_RUN)
- message("Pre and post install work fine")
-else()
- message(FATAL_ERROR "Pre install did not run before post install")
-endif()
diff --git a/Tests/SimpleInstallS2/PreInstall.cmake b/Tests/SimpleInstallS2/PreInstall.cmake
deleted file mode 100644
index 7a9851e1d..000000000
--- a/Tests/SimpleInstallS2/PreInstall.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-message("This is in pre install")
-set(PRE_INSTALL_DID_RUN 1)
diff --git a/Tests/SimpleInstallS2/TestSubDir/CMakeLists.txt b/Tests/SimpleInstallS2/TestSubDir/CMakeLists.txt
deleted file mode 100644
index 860e10425..000000000
--- a/Tests/SimpleInstallS2/TestSubDir/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-add_executable(TSD TSD.cxx TSD_utils.cxx)
-install_files(/MyTest/include FILES TSD.h)
-install_targets(/MyTest/bin TSD)
diff --git a/Tests/SimpleInstallS2/TestSubDir/TSD.cxx b/Tests/SimpleInstallS2/TestSubDir/TSD.cxx
deleted file mode 100644
index 8fc38787a..000000000
--- a/Tests/SimpleInstallS2/TestSubDir/TSD.cxx
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <stdio.h>
-
-#include "TSD.h"
-
-int main()
-{
- int res = TSD("TEST");
- printf("Hello from TSD\n");
- return res;
-}
diff --git a/Tests/SimpleInstallS2/TestSubDir/TSD.h b/Tests/SimpleInstallS2/TestSubDir/TSD.h
deleted file mode 100644
index 6a3c1affa..000000000
--- a/Tests/SimpleInstallS2/TestSubDir/TSD.h
+++ /dev/null
@@ -1 +0,0 @@
-int TSD(const char*);
diff --git a/Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx b/Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx
deleted file mode 100644
index 0f32894fe..000000000
--- a/Tests/SimpleInstallS2/TestSubDir/TSD_utils.cxx
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <string.h>
-
-int TSD(const char* foo)
-{
- if (strcmp(foo, "TEST") == 0) {
- return 0;
- }
- return 1;
-}
diff --git a/Tests/SimpleInstallS2/foo.c b/Tests/SimpleInstallS2/foo.c
deleted file mode 100644
index 45d5b2bf2..000000000
--- a/Tests/SimpleInstallS2/foo.c
+++ /dev/null
@@ -1,6 +0,0 @@
-char* foo = "Foo";
-
-int SomeFunctionInFoo()
-{
- return 5;
-}
diff --git a/Tests/SimpleInstallS2/foo.h b/Tests/SimpleInstallS2/foo.h
deleted file mode 100644
index 216cdf67b..000000000
--- a/Tests/SimpleInstallS2/foo.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern char* foo;
-extern int SomeFunctionInFoo();
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/Tests/SimpleInstallS2/inst.cxx b/Tests/SimpleInstallS2/inst.cxx
deleted file mode 100644
index ecf061c80..000000000
--- a/Tests/SimpleInstallS2/inst.cxx
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "foo.h"
-
-#ifdef STAGE_2
-#include <foo/lib1.h>
-#include <foo/lib2renamed.h>
-#include <lib3.h>
-#include <old/lib2.h>
-#include <old/lib3.h>
-#else
-#include "lib1.h"
-#include "lib2.h"
-#endif
-
-#include "lib4.h"
-
-#include <stdio.h>
-
-int main()
-{
- if (Lib1Func() != 2.0) {
- printf("Problem with lib1\n");
- return 1;
- }
- if (Lib2Func() != 1.0) {
- printf("Problem with lib2\n");
- return 1;
- }
- if (Lib4Func() != 4.0) {
- printf("Problem with lib4\n");
- return 1;
- }
- printf("The value of Foo: %s\n", foo);
- return SomeFunctionInFoo() - 5;
-}
diff --git a/Tests/SimpleInstallS2/inst2.cxx b/Tests/SimpleInstallS2/inst2.cxx
deleted file mode 100644
index c70b93af1..000000000
--- a/Tests/SimpleInstallS2/inst2.cxx
+++ /dev/null
@@ -1,2 +0,0 @@
-#define STAGE_2
-#include "inst.cxx"
diff --git a/Tests/SimpleInstallS2/lib1.cxx b/Tests/SimpleInstallS2/lib1.cxx
deleted file mode 100644
index 7aa905205..000000000
--- a/Tests/SimpleInstallS2/lib1.cxx
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "lib1.h"
-
-float Lib1Func()
-{
- return 2.0;
-}
diff --git a/Tests/SimpleInstallS2/lib1.h b/Tests/SimpleInstallS2/lib1.h
deleted file mode 100644
index 0d64e76bc..000000000
--- a/Tests/SimpleInstallS2/lib1.h
+++ /dev/null
@@ -1 +0,0 @@
-extern float Lib1Func();
diff --git a/Tests/SimpleInstallS2/lib2.cxx b/Tests/SimpleInstallS2/lib2.cxx
deleted file mode 100644
index dccc48b78..000000000
--- a/Tests/SimpleInstallS2/lib2.cxx
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "lib2.h"
-
-float Lib2Func()
-{
- return 1.0;
-}
diff --git a/Tests/SimpleInstallS2/lib2.h b/Tests/SimpleInstallS2/lib2.h
deleted file mode 100644
index a3ed758fc..000000000
--- a/Tests/SimpleInstallS2/lib2.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifdef _WIN32
-#ifdef test2_EXPORTS
-#define CM_TEST_LIB_EXPORT __declspec(dllexport)
-#else
-#define CM_TEST_LIB_EXPORT __declspec(dllimport)
-#endif
-#else
-#define CM_TEST_LIB_EXPORT
-#endif
-
-CM_TEST_LIB_EXPORT float Lib2Func();
diff --git a/Tests/SimpleInstallS2/lib3.cxx b/Tests/SimpleInstallS2/lib3.cxx
deleted file mode 100644
index da8dbf942..000000000
--- a/Tests/SimpleInstallS2/lib3.cxx
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "lib3.h"
-
-float Lib3Func()
-{
- return 2.0;
-}
diff --git a/Tests/SimpleInstallS2/lib3.h b/Tests/SimpleInstallS2/lib3.h
deleted file mode 100644
index df11327c7..000000000
--- a/Tests/SimpleInstallS2/lib3.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifdef _WIN32
-#ifdef test3_EXPORTS
-#define CM_TEST_LIB_EXPORT __declspec(dllexport)
-#else
-#define CM_TEST_LIB_EXPORT __declspec(dllimport)
-#endif
-#else
-#define CM_TEST_LIB_EXPORT
-#endif
-
-CM_TEST_LIB_EXPORT float Lib3Func();
diff --git a/Tests/SimpleInstallS2/lib4.cxx b/Tests/SimpleInstallS2/lib4.cxx
deleted file mode 100644
index fbede5ce5..000000000
--- a/Tests/SimpleInstallS2/lib4.cxx
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "lib4.h"
-
-float Lib4Func()
-{
- return 4.0;
-}
diff --git a/Tests/SimpleInstallS2/lib4.h b/Tests/SimpleInstallS2/lib4.h
deleted file mode 100644
index 71425a5c8..000000000
--- a/Tests/SimpleInstallS2/lib4.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifdef _WIN32
-#ifdef test4_EXPORTS
-#define CM_TEST_LIB_EXPORT __declspec(dllexport)
-#else
-#define CM_TEST_LIB_EXPORT __declspec(dllimport)
-#endif
-#else
-#define CM_TEST_LIB_EXPORT
-#endif
-
-CM_TEST_LIB_EXPORT float Lib4Func();
diff --git a/Tests/SimpleInstallS2/scripts/.gitattributes b/Tests/SimpleInstallS2/scripts/.gitattributes
deleted file mode 100644
index 5e3db2fb3..000000000
--- a/Tests/SimpleInstallS2/scripts/.gitattributes
+++ /dev/null
@@ -1 +0,0 @@
-sample_script crlf=input
diff --git a/Tests/SimpleInstallS2/scripts/CMakeLists.txt b/Tests/SimpleInstallS2/scripts/CMakeLists.txt
deleted file mode 100644
index ec34e8c50..000000000
--- a/Tests/SimpleInstallS2/scripts/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-install_programs(/MyTest/share/old3 "^sample_script(\\.bat)?$")
diff --git a/Tests/SimpleInstallS2/scripts/sample_script b/Tests/SimpleInstallS2/scripts/sample_script
deleted file mode 100755
index 81f9f5315..000000000
--- a/Tests/SimpleInstallS2/scripts/sample_script
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-echo "Sample Script Output"
diff --git a/Tests/SimpleInstallS2/scripts/sample_script.bat b/Tests/SimpleInstallS2/scripts/sample_script.bat
deleted file mode 100755
index 64a77b5b0..000000000
--- a/Tests/SimpleInstallS2/scripts/sample_script.bat
+++ /dev/null
@@ -1 +0,0 @@
-@echo Sample Script Output
diff --git a/Tests/SourceFileIncludeDirProperty/CMakeLists.txt b/Tests/SourceFileIncludeDirProperty/CMakeLists.txt
new file mode 100644
index 000000000..786d5b683
--- /dev/null
+++ b/Tests/SourceFileIncludeDirProperty/CMakeLists.txt
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.0)
+
+project(SourceFileIncludeDirProperty C)
+
+#
+# Check that source level include directory take
+# precedence over target one
+
+add_executable(SourceFileIncludeDirProperty main.c)
+
+set_property (TARGET SourceFileIncludeDirProperty
+ PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/target")
+
+set_property (SOURCE main.c
+ PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/source")
diff --git a/Tests/SourceFileIncludeDirProperty/main.c b/Tests/SourceFileIncludeDirProperty/main.c
new file mode 100644
index 000000000..36144ca06
--- /dev/null
+++ b/Tests/SourceFileIncludeDirProperty/main.c
@@ -0,0 +1,7 @@
+
+#include "header.h"
+
+int main()
+{
+ return 0;
+}
diff --git a/Tests/SourceFileIncludeDirProperty/source/header.h b/Tests/SourceFileIncludeDirProperty/source/header.h
new file mode 100644
index 000000000..0c6f24128
--- /dev/null
+++ b/Tests/SourceFileIncludeDirProperty/source/header.h
@@ -0,0 +1,2 @@
+
+/* used header file */
diff --git a/Tests/SourceFileIncludeDirProperty/target/header.h b/Tests/SourceFileIncludeDirProperty/target/header.h
new file mode 100644
index 000000000..71c1521d5
--- /dev/null
+++ b/Tests/SourceFileIncludeDirProperty/target/header.h
@@ -0,0 +1,2 @@
+
+#error "wrong header file"
diff --git a/Tests/SourceFileProperty/CMakeLists.txt b/Tests/SourceFileProperty/CMakeLists.txt
index 1b6506da5..5e55f7b3d 100644
--- a/Tests/SourceFileProperty/CMakeLists.txt
+++ b/Tests/SourceFileProperty/CMakeLists.txt
@@ -1,19 +1,27 @@
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.1)
project(SourceFileProperty C)
-set(sources)
-
if (EXISTS icasetest.c)
# If a file exists by this name, use it.
set_source_files_properties(icasetest.c
PROPERTIES
- COMPILE_FLAGS -DNEEDED_TO_WORK)
+ COMPILE_DEFINITIONS NEEDED_TO_WORK)
else ()
# Work on case-sensitive file systems as well.
set_source_files_properties(main.c
PROPERTIES
- COMPILE_FLAGS -DNO_NEED_TO_CALL)
+ COMPILE_DEFINITIONS NO_NEED_TO_CALL)
endif ()
-list(APPEND sources ICaseTest.c)
-add_executable(SourceFileProperty main.c ${sources})
+add_executable(SourceFileProperty main.c)
+target_sources(SourceFileProperty PRIVATE ICaseTest.c)
+
+get_source_file_property(LANG_MAIN main.c LANGUAGE)
+if(NOT "${LANG_MAIN}" STREQUAL "C")
+ message(FATAL_ERROR "Bad language for file main.c")
+endif()
+
+get_property(LANG_TEST SOURCE ICaseTest.c PROPERTY LANGUAGE)
+if (NOT "${LANG_TEST}" STREQUAL "C")
+ message(FATAL_ERROR "Bad language for file ICaseTest.c")
+endif ()
diff --git a/Tests/SourceGroups/CMakeLists.txt b/Tests/SourceGroups/CMakeLists.txt
index 4e4a030ce..a5740bba9 100644
--- a/Tests/SourceGroups/CMakeLists.txt
+++ b/Tests/SourceGroups/CMakeLists.txt
@@ -39,9 +39,23 @@ set(tree_files_without_prefix ${root}/sub1/tree_bar.c
set(tree_files_with_prefix ${root}/tree_prefix_foo.c
tree_prefix_bar.c)
+set(tree_files_with_empty_prefix ${root}/tree_empty_prefix_foo.c
+ tree_empty_prefix_bar.c)
+
+set(tree_files_which_are_actually_directories ${root}
+ ${root}/
+ ${root}/sub1
+ ${root}/sub1/)
+
source_group(TREE ${root} FILES ${tree_files_without_prefix})
-source_group(TREE ${root} PREFIX tree_root/subgroup FILES ${tree_files_with_prefix})
+# Should not crash and not add any files - just silently ignore the directories
+source_group(TREE ${root} FILES ${tree_files_which_are_actually_directories})
+
+source_group(FILES ${tree_files_with_prefix} PREFIX tree_root/subgroup TREE ${root})
+
+source_group(PREFIX "" FILES ${tree_files_with_empty_prefix} TREE ${root})
add_executable(SourceGroups main.c bar.c foo.c sub1/foo.c sub1/foobar.c baz.c
- ${tree_files_with_prefix} ${tree_files_without_prefix} README.txt)
+ ${tree_files_with_prefix} ${tree_files_without_prefix}
+ ${tree_files_with_empty_prefix} README.txt)
diff --git a/Tests/SourceGroups/main.c b/Tests/SourceGroups/main.c
index 4d84cf20e..87225f546 100644
--- a/Tests/SourceGroups/main.c
+++ b/Tests/SourceGroups/main.c
@@ -7,6 +7,8 @@ extern int barbar(void);
extern int baz(void);
extern int tree_prefix_foo(void);
extern int tree_prefix_bar(void);
+extern int tree_empty_prefix_foo(void);
+extern int tree_empty_prefix_bar(void);
extern int tree_bar(void);
extern int tree_foobar(void);
extern int tree_baz(void);
@@ -17,8 +19,9 @@ int main()
foobar(), barbar(), baz());
printf("tree_prefix_foo: %d tree_prefix_bar: %d tree_bar: %d tree_foobar: "
- "%d tree_baz: %d\n",
+ "%d tree_baz: %d tree_empty_prefix_foo: %d "
+ "tree_empty_prefix_bar: %d\n",
tree_prefix_foo(), tree_prefix_bar(), tree_bar(), tree_foobar(),
- tree_baz());
+ tree_baz(), tree_empty_prefix_foo(), tree_empty_prefix_bar());
return 0;
}
diff --git a/Tests/SourceGroups/tree_empty_prefix_bar.c b/Tests/SourceGroups/tree_empty_prefix_bar.c
new file mode 100644
index 000000000..d974c6e8c
--- /dev/null
+++ b/Tests/SourceGroups/tree_empty_prefix_bar.c
@@ -0,0 +1,4 @@
+int tree_empty_prefix_bar(void)
+{
+ return 66;
+}
diff --git a/Tests/SourceGroups/tree_empty_prefix_foo.c b/Tests/SourceGroups/tree_empty_prefix_foo.c
new file mode 100644
index 000000000..277cbd4db
--- /dev/null
+++ b/Tests/SourceGroups/tree_empty_prefix_foo.c
@@ -0,0 +1,4 @@
+int tree_empty_prefix_foo(void)
+{
+ return 6;
+}
diff --git a/Tests/StagingPrefix/CMakeLists.txt b/Tests/StagingPrefix/CMakeLists.txt
index 49ff7fee7..8d2519ea3 100644
--- a/Tests/StagingPrefix/CMakeLists.txt
+++ b/Tests/StagingPrefix/CMakeLists.txt
@@ -1,15 +1,16 @@
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.9)
project(StagingPrefix)
# Wipe out the install tree
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/CleanupProject
- COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ConsumerBuild
- COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ProducerBuild
- COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/stage
- COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/prefix
- COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_BINARY_DIR}/ignored
+ COMMAND ${CMAKE_COMMAND} -E remove_directory
+ ${CMAKE_BINARY_DIR}/ConsumerBuild
+ ${CMAKE_BINARY_DIR}/ProducerBuild
+ ${CMAKE_BINARY_DIR}/stage
+ ${CMAKE_BINARY_DIR}/prefix
+ ${CMAKE_BINARY_DIR}/ignored
)
add_custom_target(CleanupTarget ALL DEPENDS ${CMAKE_BINARY_DIR}/CleanupProject)
set_property(
@@ -17,7 +18,8 @@ set_property(
PROPERTY SYMBOLIC 1
)
-if(CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}")
else()
if(CMAKE_BUILD_TYPE)
diff --git a/Tests/SubDir/Executable/test.cxx b/Tests/SubDir/Executable/test.cxx
index 06aed018b..01d928085 100644
--- a/Tests/SubDir/Executable/test.cxx
+++ b/Tests/SubDir/Executable/test.cxx
@@ -1,19 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
-#include <io.h>
+# include <io.h>
#else
-#include <unistd.h>
+# include <unistd.h>
#endif
// return true if the file exists
int FileExists(const char* filename)
{
#ifdef _MSC_VER
-#define access _access
+# define access _access
#endif
#ifndef F_OK
-#define F_OK 0
+# define F_OK 0
#endif
if (access(filename, F_OK) != 0) {
return false;
diff --git a/Tests/SubDirSpaces/CMakeLists.txt b/Tests/SubDirSpaces/CMakeLists.txt
index 40c265e5f..0d45db85c 100644
--- a/Tests/SubDirSpaces/CMakeLists.txt
+++ b/Tests/SubDirSpaces/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6)
project(SUBDIR)
# Some systems do not seem to support rpath with spaces.
-if(CMAKE_SYSTEM_NAME MATCHES "IRIX|QNX")
+if(CMAKE_SYSTEM_NAME MATCHES "QNX")
set(CMAKE_SKIP_BUILD_RPATH 1)
endif()
diff --git a/Tests/SubDirSpaces/Executable Sources/test.cxx b/Tests/SubDirSpaces/Executable Sources/test.cxx
index 06aed018b..01d928085 100644
--- a/Tests/SubDirSpaces/Executable Sources/test.cxx
+++ b/Tests/SubDirSpaces/Executable Sources/test.cxx
@@ -1,19 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
-#include <io.h>
+# include <io.h>
#else
-#include <unistd.h>
+# include <unistd.h>
#endif
// return true if the file exists
int FileExists(const char* filename)
{
#ifdef _MSC_VER
-#define access _access
+# define access _access
#endif
#ifndef F_OK
-#define F_OK 0
+# define F_OK 0
#endif
if (access(filename, F_OK) != 0) {
return false;
diff --git a/Tests/SubDirSpaces/Executable/test.cxx b/Tests/SubDirSpaces/Executable/test.cxx
index 06aed018b..01d928085 100644
--- a/Tests/SubDirSpaces/Executable/test.cxx
+++ b/Tests/SubDirSpaces/Executable/test.cxx
@@ -1,19 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef _WIN32
-#include <io.h>
+# include <io.h>
#else
-#include <unistd.h>
+# include <unistd.h>
#endif
// return true if the file exists
int FileExists(const char* filename)
{
#ifdef _MSC_VER
-#define access _access
+# define access _access
#endif
#ifndef F_OK
-#define F_OK 0
+# define F_OK 0
#endif
if (access(filename, F_OK) != 0) {
return false;
diff --git a/Tests/SwiftMix/CMain.c b/Tests/SwiftMix/CMain.c
index 8877da430..519058efe 100644
--- a/Tests/SwiftMix/CMain.c
+++ b/Tests/SwiftMix/CMain.c
@@ -1,5 +1,5 @@
-extern int ObjCMain(int argc, char const* const argv[]);
-int main(int argc, char* argv[])
+extern int ObjCMain(void);
+int main(void)
{
- return ObjCMain(argc, argv);
+ return ObjCMain();
}
diff --git a/Tests/SwiftMix/CMakeLists.txt b/Tests/SwiftMix/CMakeLists.txt
index 5e50470f6..6d8e48bd0 100644
--- a/Tests/SwiftMix/CMakeLists.txt
+++ b/Tests/SwiftMix/CMakeLists.txt
@@ -3,3 +3,4 @@ project(SwiftMix C Swift)
add_executable(SwiftMix CMain.c ObjCMain.m SwiftMain.swift ObjC-Swift.h)
set_property(TARGET SwiftMix PROPERTY XCODE_ATTRIBUTE_SWIFT_OBJC_BRIDGING_HEADER "ObjC-Swift.h")
+target_compile_options(SwiftMix PRIVATE "$<$<COMPILE_LANGUAGE:C>:-Werror=objc-method-access>")
diff --git a/Tests/SwiftMix/ObjCMain.m b/Tests/SwiftMix/ObjCMain.m
index 20f0bf1ee..afc924380 100644
--- a/Tests/SwiftMix/ObjCMain.m
+++ b/Tests/SwiftMix/ObjCMain.m
@@ -1,4 +1,4 @@
#import "SwiftMix-Swift.h"
-int ObjCMain(int argc, char const* const argv[]) {
+int ObjCMain(void) {
return [SwiftMainClass SwiftMain];
}
diff --git a/Tests/SwiftMix/SwiftMain.swift b/Tests/SwiftMix/SwiftMain.swift
index a4a0a62b4..d9c8cd756 100644
--- a/Tests/SwiftMix/SwiftMain.swift
+++ b/Tests/SwiftMix/SwiftMain.swift
@@ -1,7 +1,7 @@
import Foundation
@objc class SwiftMainClass : NSObject {
- class func SwiftMain() -> Int32 {
+ @objc class func SwiftMain() -> Int32 {
dump("Hello World!");
return 0;
}
diff --git a/Tests/SwiftOnly/CMakeLists.txt b/Tests/SwiftOnly/CMakeLists.txt
index cf4463ccf..f4cbac212 100644
--- a/Tests/SwiftOnly/CMakeLists.txt
+++ b/Tests/SwiftOnly/CMakeLists.txt
@@ -1,8 +1,13 @@
cmake_minimum_required(VERSION 3.3)
project(SwiftOnly Swift)
-if(NOT XCODE_VERSION VERSION_LESS 8.0)
+if(NOT XCODE_VERSION VERSION_LESS 10.2)
+ set(CMAKE_Swift_LANGUAGE_VERSION 5.0)
+elseif(NOT XCODE_VERSION VERSION_LESS 8.0)
set(CMAKE_Swift_LANGUAGE_VERSION 3.0)
endif()
add_executable(SwiftOnly main.swift)
+
+# Dummy to make sure generation works with such targets.
+add_library(SwiftIface INTERFACE)
diff --git a/Tests/SwigTest/CMakeLists.txt b/Tests/SwigTest/CMakeLists.txt
deleted file mode 100644
index 65f5c93e2..000000000
--- a/Tests/SwigTest/CMakeLists.txt
+++ /dev/null
@@ -1,59 +0,0 @@
-set(language "python")
-
-cmake_minimum_required (VERSION 2.6)
-
-project(example_${language}_class)
-
-find_package(SWIG REQUIRED)
-include(${SWIG_USE_FILE})
-
-unset(SWIG_LANG_TYPE)
-if(${language} MATCHES python)
- find_package(PythonLibs)
- include_directories(${PYTHON_INCLUDE_PATH})
- set(SWIG_LANG_LIBRARIES ${PYTHON_LIBRARIES})
-endif()
-if(${language} MATCHES perl)
- find_package(PerlLibs)
- include_directories(${PERL_INCLUDE_PATH})
- add_definitions(${PERL_EXTRA_C_FLAGS})
- set(SWIG_LANG_LIBRARIES ${PERL_LIBRARY})
-endif()
-if(${language} MATCHES tcl)
- find_package(TCL)
- include_directories(${TCL_INCLUDE_PATH})
- set(SWIG_LANG_LIBRARIES ${TCL_LIBRARY})
-endif()
-if(${language} MATCHES ruby)
- find_package(Ruby)
- include_directories(${RUBY_INCLUDE_PATH})
- set(SWIG_LANG_LIBRARIES ${RUBY_LIBRARY})
-endif()
-if(${language} MATCHES php4)
- find_package(PHP4)
- include_directories(${PHP4_INCLUDE_PATH})
- set(SWIG_LANG_LIBRARIES ${PHP4_LIBRARY})
-endif()
-if(${language} MATCHES pike)
- find_package(Pike)
- include_directories(${PIKE_INCLUDE_PATH})
- set(SWIG_LANG_LIBRARIES ${PIKE_LIBRARY})
-endif()
-if(${language} MATCHES lua)
- find_package(Lua)
- include_directories(${LUA_INCLUDE_DIR})
- set(SWIG_LANG_TYPE TYPE SHARED)
- set(SWIG_LANG_LIBRARIES ${LUA_LIBRARIES})
-endif()
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-
-set(CMAKE_SWIG_FLAGS "")
-
-set_source_files_properties(example.i PROPERTIES CPLUSPLUS ON)
-set_source_files_properties(example.i PROPERTIES SWIG_FLAGS "-includeall")
-SWIG_ADD_LIBRARY(example
- LANGUAGE "${language}"
- ${SWIG_LANG_TYPE}
- SOURCES example.i example.cxx)
-SWIG_LINK_LIBRARIES(example ${SWIG_LANG_LIBRARIES})
diff --git a/Tests/SwigTest/example.i b/Tests/SwigTest/example.i
deleted file mode 100644
index 75700b305..000000000
--- a/Tests/SwigTest/example.i
+++ /dev/null
@@ -1,10 +0,0 @@
-/* File : example.i */
-%module example
-
-%{
-#include "example.h"
-%}
-
-/* Let's just grab the original header file here */
-%include "example.h"
-
diff --git a/Tests/SwigTest/runme.pl b/Tests/SwigTest/runme.pl
deleted file mode 100644
index 5bfb3d83a..000000000
--- a/Tests/SwigTest/runme.pl
+++ /dev/null
@@ -1,57 +0,0 @@
-# file: runme.pl
-
-# This file illustrates the low-level C++ interface
-# created by SWIG. In this case, all of our C++ classes
-# get converted into function calls.
-
-use example;
-
-# ----- Object creation -----
-
-print "Creating some objects:\n";
-$c = examplec::new_Circle(10);
-print " Created circle $c\n";
-$s = examplec::new_Square(10);
-print " Created square $s\n";
-
-# ----- Access a static member -----
-
-print "\nA total of $examplec::Shape_nshapes shapes were created\n";
-
-# ----- Member data access -----
-
-# Set the location of the object.
-# Note: methods in the base class Shape are used since
-# x and y are defined there.
-
-examplec::Shape_x_set($c, 20);
-examplec::Shape_y_set($c, 30);
-examplec::Shape_x_set($s,-10);
-examplec::Shape_y_set($s,5);
-
-print "\nHere is their current position:\n";
-print " Circle = (",examplec::Shape_x_get($c),",", examplec::Shape_y_get($c),")\n";
-print " Square = (",examplec::Shape_x_get($s),",", examplec::Shape_y_get($s),")\n";
-
-# ----- Call some methods -----
-
-print "\nHere are some properties of the shapes:\n";
-foreach $o ($c,$s) {
- print " $o\n";
- print " area = ", examplec::Shape_area($o), "\n";
- print " perimeter = ", examplec::Shape_perimeter($o), "\n";
- }
-# Notice how the Shape_area() and Shape_perimeter() functions really
-# invoke the appropriate virtual method on each object.
-
-# ----- Delete everything -----
-
-print "\nGuess I'll clean up now\n";
-
-# Note: this invokes the virtual destructor
-examplec::delete_Shape($c);
-examplec::delete_Shape($s);
-
-print $examplec::Shape_nshapes," shapes remain\n";
-print "Goodbye\n";
-
diff --git a/Tests/SwigTest/runme.py b/Tests/SwigTest/runme.py
deleted file mode 100644
index ed3909e30..000000000
--- a/Tests/SwigTest/runme.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# file: runme.py
-
-# This file illustrates the shadow-class C++ interface generated
-# by SWIG.
-
-import example
-
-# ----- Object creation -----
-
-print "Creating some objects:"
-c = example.Circle(10)
-print " Created circle", c
-s = example.Square(10)
-print " Created square", s
-
-# ----- Access a static member -----
-
-print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
-
-# ----- Member data access -----
-
-# Set the location of the object
-
-c.x = 20
-c.y = 30
-
-s.x = -10
-s.y = 5
-
-print "\nHere is their current position:"
-print " Circle = (%f, %f)" % (c.x,c.y)
-print " Square = (%f, %f)" % (s.x,s.y)
-
-# ----- Call some methods -----
-
-print "\nHere are some properties of the shapes:"
-for o in [c,s]:
- print " ", o
- print " area = ", o.area()
- print " perimeter = ", o.perimeter()
-
-print "\nGuess I'll clean up now"
-
-# Note: this invokes the virtual destructor
-del c
-del s
-
-s = 3
-print example.cvar.Shape_nshapes,"shapes remain"
-print "Goodbye"
-
diff --git a/Tests/SwigTest/runme.tcl b/Tests/SwigTest/runme.tcl
deleted file mode 100644
index c7f472560..000000000
--- a/Tests/SwigTest/runme.tcl
+++ /dev/null
@@ -1,50 +0,0 @@
-# file: runme.tcl
-
-# This file illustrates the high level C++ interface.
-# In this case C++ classes work kind of like Tk widgets
-
-catch { load ./example[info sharedlibextension] example}
-
-# ----- Object creation -----
-
-puts "Creating some objects:"
-Circle c 10
-puts " Created circle [c cget -this]"
-Square s 10
-puts " Created square [s cget -this]"
-
-# ----- Access a static member -----
-
-puts "\nA total of $Shape_nshapes shapes were created"
-
-# ----- Member data access -----
-
-# Set the location of the object
-
-c configure -x 20 -y 30
-s configure -x -10 -y 5
-
-puts "\nHere is their current position:"
-puts " Circle = ([c cget -x], [c cget -y])"
-puts " Square = ([s cget -x], [s cget -y])"
-
-# ----- Call some methods -----
-
-puts "\nHere are some properties of the shapes:"
-foreach o "c s" {
- puts " [$o cget -this]"
- puts " area = [$o area]"
- puts " perimeter = [$o perimeter]"
-}
-
-# ----- Delete everything -----
-
-puts "\nGuess I'll clean up now"
-
-# Note: this invokes the virtual destructor
-rename c ""
-rename s ""
-
-puts "$Shape_nshapes shapes remain"
-puts "Goodbye"
-
diff --git a/Tests/SwigTest/runme2.tcl b/Tests/SwigTest/runme2.tcl
deleted file mode 100644
index 88ec2f678..000000000
--- a/Tests/SwigTest/runme2.tcl
+++ /dev/null
@@ -1,70 +0,0 @@
-# file: runme2.tcl
-
-# This file illustrates the low-level C++ interface
-# created by SWIG. In this case, all of our C++ classes
-# get converted into function calls.
-
-catch { load ./example[info sharedlibextension] example}
-
-# ----- Object creation -----
-
-puts "Creating some objects:"
-set c [new_Circle 10]
-puts " Created circle $c"
-set s [new_Square 10]
-puts " Created square $s"
-
-# ----- Access a static member -----
-
-puts "\nA total of $Shape_nshapes shapes were created"
-
-# ----- Member data access -----
-
-# Set the location of the object
-# Note: the base class must be used since that's where x and y
-# were declared.
-
-Shape_x_set $c 20
-Shape_y_set $c 30
-Shape_x_set $s -10
-Shape_y_set $s 5
-
-puts "\nHere is their current position:"
-puts " Circle = ([Shape_x_get $c], [Shape_y_get $c])"
-puts " Square = ([Shape_x_get $s], [Shape_y_get $s])"
-
-# ----- Call some methods -----
-
-puts "\nHere are some properties of the shapes:"
-foreach o "$c $s" {
- puts " $o"
- puts " area = [Shape_area $o]"
- puts " perimeter = [Shape_perimeter $o]"
-}
-# Notice how the Shape_area() and Shape_perimeter() functions really
-# invoke the appropriate virtual method on each object.
-
-# ----- Try to cause a type error -----
-
-puts "\nI'm going to try and break the type system"
-
-if { [catch {
- # Bad script!
- Square_area $c # Try to invoke Square method on a Circle
- puts " Bad bad SWIG!"
-
-}]} {
- puts " Well, it didn't work. Good SWIG."
-}
-
-# ----- Delete everything -----
-
-puts "\nGuess I'll clean up now"
-
-# Note: this invokes the virtual destructor
-delete_Shape $c
-delete_Shape $s
-
-puts "$Shape_nshapes shapes remain"
-puts "Goodbye"
-
diff --git a/Tests/SystemInformation/DumpInformation.cxx b/Tests/SystemInformation/DumpInformation.cxx
index e0cc0ce6d..43286753b 100644
--- a/Tests/SystemInformation/DumpInformation.cxx
+++ b/Tests/SystemInformation/DumpInformation.cxx
@@ -1,5 +1,7 @@
#include "DumpInformation.h"
+
#include <stdio.h>
+
#include <sys/stat.h>
void cmDumpInformationPrintFile(const char* name, FILE* fout)
diff --git a/Tests/TestsWorkingDirectory/main.c b/Tests/TestsWorkingDirectory/main.c
index 11dd4ff7c..ca72f2102 100644
--- a/Tests/TestsWorkingDirectory/main.c
+++ b/Tests/TestsWorkingDirectory/main.c
@@ -3,16 +3,17 @@
#include <stdlib.h>
#include <string.h>
-#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || \
- defined(__BORLANDC__) || defined(__MINGW32__))
+#if defined(_WIN32) && \
+ (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || \
+ defined(__MINGW32__))
-#include <direct.h>
-#include <io.h>
+# include <direct.h>
+# include <io.h>
-#if defined(__WATCOMC__)
-#include <direct.h>
-#define _getcwd getcwd
-#endif
+# if defined(__WATCOMC__)
+# include <direct.h>
+# define _getcwd getcwd
+# endif
static const char* Getcwd(char* buf, unsigned int len)
{
@@ -35,9 +36,10 @@ static const char* Getcwd(char* buf, unsigned int len)
}
#else
-#include <fcntl.h>
-#include <sys/types.h>
-#include <unistd.h>
+# include <fcntl.h>
+# include <unistd.h>
+
+# include <sys/types.h>
static const char* Getcwd(char* buf, unsigned int len)
{
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt
index 2f8e4fb3c..9ec9b70fd 100644
--- a/Tests/TryCompile/CMakeLists.txt
+++ b/Tests/TryCompile/CMakeLists.txt
@@ -165,6 +165,35 @@ try_compile(TEST_INNER
OUTPUT_VARIABLE output)
TEST_ASSERT(TEST_INNER "try_compile project mode failed:\n${output}")
+try_compile(COMPILE_DEFINITIONS_LIST_EXPANDED
+ ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_SOURCE_DIR}/check_a_b.c
+ OUTPUT_VARIABLE output
+ COMPILE_DEFINITIONS "-DDEF_A;-DDEF_B"
+ )
+if(COMPILE_DEFINITIONS_LIST_EXPANDED)
+ message(STATUS "COMPILE_DEFINITIONS list expanded correctly")
+else()
+ string(REPLACE "\n" "\n " output " ${output}")
+ message(SEND_ERROR "COMPILE_DEFINITIONS list did not expand correctly\n${output}")
+endif()
+
+try_compile(SHOULD_FAIL_DUE_TO_BAD_SOURCE
+ ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_SOURCE_DIR}/pass.c
+ OUTPUT_VARIABLE output
+ COMPILE_DEFINITIONS "bad#source.c"
+ )
+if(SHOULD_FAIL_DUE_TO_BAD_SOURCE AND NOT CMAKE_GENERATOR MATCHES "Watcom WMake|NMake Makefiles")
+ string(REPLACE "\n" "\n " output " ${output}")
+ message(SEND_ERROR "try_compile with bad#source.c did not fail:\n${output}")
+elseif(NOT output MATCHES [[(bad#source\.c|bad\\)]])
+ string(REPLACE "\n" "\n " output " ${output}")
+ message(SEND_ERROR "try_compile with bad#source.c failed without mentioning bad source:\n${output}")
+else()
+ message(STATUS "try_compile with bad#source.c correctly failed")
+endif()
+
add_executable(TryCompile pass.c)
######################################
@@ -242,7 +271,7 @@ include(CheckCXXSourceCompiles)
include(CheckCSourceRuns)
include(CheckCXXSourceRuns)
-CHECK_C_SOURCE_COMPILES("I dont build" C_BUILD_SHOULD_FAIL)
+CHECK_C_SOURCE_COMPILES("I don't build" C_BUILD_SHOULD_FAIL)
CHECK_C_SOURCE_COMPILES("int main() {return 0;}" C_BUILD_SHOULD_WORK)
CHECK_C_SOURCE_RUNS("int main() {return 1;}" C_RUN_SHOULD_FAIL)
CHECK_C_SOURCE_RUNS("int main() {return 0;}" C_RUN_SHOULD_WORK)
@@ -252,7 +281,7 @@ TEST_ASSERT(C_BUILD_SHOULD_WORK "CHECK_C_SOURCE_COMPILES() failed")
TEST_FAIL(C_RUN_SHOULD_FAIL "CHECK_C_SOURCE_RUNS() succeeded, but should have failed")
TEST_ASSERT(C_RUN_SHOULD_WORK "CHECK_C_SOURCE_RUNS() failed")
-CHECK_CXX_SOURCE_COMPILES("I dont build" CXX_BUILD_SHOULD_FAIL)
+CHECK_CXX_SOURCE_COMPILES("I don't build" CXX_BUILD_SHOULD_FAIL)
CHECK_CXX_SOURCE_COMPILES("int main() {return 0;}" CXX_BUILD_SHOULD_WORK)
CHECK_CXX_SOURCE_RUNS("int main() {return 2;}" CXX_RUN_SHOULD_FAIL)
CHECK_CXX_SOURCE_RUNS("int main() {return 0;}" CXX_RUN_SHOULD_WORK)
@@ -284,6 +313,79 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
TEST_ASSERT(C_STRICT_PROTOTYPES "CHECK_C_COMPILER_FLAG failed -Werror -Wstrict-prototypes")
endif()
+#########################################################################
+#
+# Test that the CHECK_OBJCC_SOURCE_COMPILES, CHECK_OBJCXX_SOURCE_COMPILES
+# CHECK_OBJC_SOURCE_RUNS and CHECK_OBJCXX_SOURCE_RUNS macros work
+
+if (APPLE)
+ enable_language(OBJC)
+ enable_language(OBJCXX)
+
+ include(CheckOBJCSourceCompiles)
+ include(CheckOBJCXXSourceCompiles)
+ include(CheckOBJCSourceRuns)
+ include(CheckOBJCXXSourceRuns)
+
+ CHECK_OBJC_SOURCE_COMPILES("I don't build in Objective-C" OBJC_BUILD_SHOULD_FAIL)
+ CHECK_OBJC_SOURCE_COMPILES("int main() { return 0; }" SIMPLE_OBJC_BUILD_SHOULD_WORK)
+
+ TEST_FAIL(OBJC_BUILD_SHOULD_FAIL "CHECK_OBJC_SOURCE_COMPILES() succeeded, but should have failed")
+ TEST_ASSERT(SIMPLE_OBJC_BUILD_SHOULD_WORK "CHECK_OBJC_SOURCE_COMPILES() failed, but should have succeeded")
+
+ set(CMAKE_REQUIRED_LIBRARIES "-framework Foundation")
+
+ CHECK_OBJC_SOURCE_COMPILES("#import <Foundation/Foundation.h>\nint main()\n{\nNSObject *foo;\nreturn 0;\n}\n" OBJC_BUILD_SHOULD_WORK)
+ CHECK_OBJC_SOURCE_RUNS("int main() { return 2; }" SIMPLE_OBJC_RUN_SHOULD_FAIL)
+ CHECK_OBJC_SOURCE_RUNS("int main() { return 0; }" SIMPLE_OBJC_RUN_SHOULD_WORK)
+ CHECK_OBJC_SOURCE_RUNS("#import <Foundation/Foundation.h>\nint main()\n{\nNSObject *foo;\nreturn 2;\n}\n" OBJC_RUN_SHOULD_FAIL)
+ CHECK_OBJC_SOURCE_RUNS("#import <Foundation/Foundation.h>\nint main()\n{\nNSObject *foo;\nreturn 0;\n}\n" OBJC_RUN_SHOULD_WORK)
+
+ TEST_ASSERT(OBJC_BUILD_SHOULD_WORK "CHECK_OBJC_SOURCE_COMPILES() failed, but should have succeeded")
+ TEST_FAIL(SIMPLE_OBJC_RUN_SHOULD_FAIL "CHECK_OBJC_SOURC_RUNS() succeeds, but should have failed")
+ TEST_ASSERT(SIMPLE_OBJC_RUN_SHOULD_WORK "CHECK_OBJC_SOURCE_RUNS() failed, but should have succeeded")
+ TEST_FAIL(OBJC_RUN_SHOULD_FAIL "CHECK_OBJC_SOURCE_RUNS() succeeds, but should have failed")
+ TEST_ASSERT(OBJC_RUN_SHOULD_WORK "CHECK_OBJC_SOURCE_RUNS() failed, but should have succeeded")
+
+
+ CHECK_OBJCXX_SOURCE_COMPILES("I don't build in Objective-C++" OBJCXX_BUILD_SHOULD_FAIL)
+ CHECK_OBJCXX_SOURCE_COMPILES("int main() { return 0; }" SIMPLE_OBJCXX_BUILD_SHOULD_WORK)
+
+ TEST_FAIL(OBJCXX_BUILD_SHOULD_FAIL "CHECK_OBJCXX_SOURCE_COMPILES() succeeded, but should have failed")
+ TEST_ASSERT(SIMPLE_OBJCXX_BUILD_SHOULD_WORK "CHECK_OBJCXX_SOURCE_COMPILES() failed, but should have succeeded")
+
+ CHECK_OBJCXX_SOURCE_COMPILES("#import <Foundation/Foundation.h>\n#include <iostream>\nint main()\n{\nNSObject *foo;\nstd::cout << \"Hello\" << std::endl;\nreturn 0;\n}\n" OBJCXX_BUILD_SHOULD_WORK)
+ CHECK_OBJCXX_SOURCE_RUNS("int main() { return 2; }" SIMPLE_OBJCXX_RUN_SHOULD_FAIL)
+ CHECK_OBJCXX_SOURCE_RUNS("int main() { return 0; }" SIMPLE_OBJCXX_RUN_SHOULD_WORK)
+ CHECK_OBJCXX_SOURCE_RUNS("#import <Foundation/Foundation.h>\n#include <vector>\nint main()\n{\nNSObject *foo;\nstd::vector<int> bar;\nreturn 2;\n}\n" OBJCXX_RUN_SHOULD_FAIL)
+ CHECK_OBJCXX_SOURCE_RUNS("#import <Foundation/Foundation.h>\n#include <vector>\nint main()\n{\nNSObject *foo;\nstd::vector<int> bar;\nreturn 0;\n}\n" OBJCXX_RUN_SHOULD_WORK)
+
+ TEST_ASSERT(OBJCXX_BUILD_SHOULD_WORK "CHECK_OBJCXX_SOURCE_COMPILES() failed, but should have succeeded")
+ TEST_FAIL(SIMPLE_OBJCXX_RUN_SHOULD_FAIL "CHECK_OBJCXX_SOURC_RUNS() succeeds, but should have failed")
+ TEST_ASSERT(SIMPLE_OBJCXX_RUN_SHOULD_WORK "CHECK_OBJCXX_SOURCE_RUNS() failed, but should have succeeded")
+ TEST_FAIL(OBJCXX_RUN_SHOULD_FAIL "CHECK_OBJCXX_SOURCE_RUNS() succeeds, but should have failed")
+ TEST_ASSERT(OBJCXX_RUN_SHOULD_WORK "CHECK_OBJCXX_SOURCE_RUNS() failed, but should have succeeded")
+
+ # try to compile a file that should compile
+ try_compile(SHOULD_PASS
+ ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_SOURCE_DIR}/pass.m
+ OUTPUT_VARIABLE TRY_OUT)
+ if(NOT SHOULD_PASS)
+ message(SEND_ERROR "should pass failed ${TRY_OUT}")
+ endif()
+
+ # try to compile a file that should not compile
+ try_compile(SHOULD_FAIL
+ ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_SOURCE_DIR}/fail.m
+ OUTPUT_VARIABLE TRY_OUT)
+ if(SHOULD_FAIL)
+ message(SEND_ERROR "Should fail passed ${TRY_OUT}")
+ endif()
+
+endif()
+
#######################################################################
#
# also test that the check_prototype_definition macro works
diff --git a/Tests/TryCompile/check_a_b.c b/Tests/TryCompile/check_a_b.c
new file mode 100644
index 000000000..05fba0f82
--- /dev/null
+++ b/Tests/TryCompile/check_a_b.c
@@ -0,0 +1,10 @@
+#ifndef DEF_A
+# error DEF_A not defined
+#endif
+#ifndef DEF_B
+# error DEF_B not defined
+#endif
+int main()
+{
+ return 0;
+}
diff --git a/Tests/TryCompile/fail.m b/Tests/TryCompile/fail.m
new file mode 100644
index 000000000..b915ebe4c
--- /dev/null
+++ b/Tests/TryCompile/fail.m
@@ -0,0 +1 @@
+asdflkjasdlj
diff --git a/Tests/TryCompile/pass.m b/Tests/TryCompile/pass.m
new file mode 100644
index 000000000..f8b643afb
--- /dev/null
+++ b/Tests/TryCompile/pass.m
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/Tests/TryCompile/testdef.c b/Tests/TryCompile/testdef.c
index b05f070d0..72301dd4e 100644
--- a/Tests/TryCompile/testdef.c
+++ b/Tests/TryCompile/testdef.c
@@ -1,5 +1,5 @@
#ifndef TESTDEF
-#error "TESTDEF should be defined!"
+# error "TESTDEF should be defined!"
#endif
int main(void)
{
diff --git a/Tests/Tutorial/Step1/CMakeLists.txt b/Tests/Tutorial/Step1/CMakeLists.txt
deleted file mode 100644
index e461d3c8b..000000000
--- a/Tests/Tutorial/Step1/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-project (Tutorial)
-
-# The version number.
-set (Tutorial_VERSION_MAJOR 1)
-set (Tutorial_VERSION_MINOR 0)
-
-# configure a header file to pass some of the CMake settings
-# to the source code
-configure_file (
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
-
-# add the binary tree to the search path for include files
-# so that we will find TutorialConfig.h
-include_directories("${PROJECT_BINARY_DIR}")
-
-# add the executable
-add_executable(Tutorial tutorial.cxx)
diff --git a/Tests/Tutorial/Step1/TutorialConfig.h.in b/Tests/Tutorial/Step1/TutorialConfig.h.in
deleted file mode 100644
index 5395a0671..000000000
--- a/Tests/Tutorial/Step1/TutorialConfig.h.in
+++ /dev/null
@@ -1,4 +0,0 @@
-// the configured options and settings for Tutorial
-#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
-#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
-
diff --git a/Tests/Tutorial/Step1/tutorial.cxx b/Tests/Tutorial/Step1/tutorial.cxx
deleted file mode 100644
index 7a13376cb..000000000
--- a/Tests/Tutorial/Step1/tutorial.cxx
+++ /dev/null
@@ -1,19 +0,0 @@
-// A simple program that computes the square root of a number
-#include "TutorialConfig.h"
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int main(int argc, char* argv[])
-{
- if (argc < 2) {
- fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
- Tutorial_VERSION_MINOR);
- fprintf(stdout, "Usage: %s number\n", argv[0]);
- return 1;
- }
- double inputValue = atof(argv[1]);
- double outputValue = sqrt(inputValue);
- fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
- return 0;
-}
diff --git a/Tests/Tutorial/Step2/CMakeLists.txt b/Tests/Tutorial/Step2/CMakeLists.txt
deleted file mode 100644
index cf1d30ee2..000000000
--- a/Tests/Tutorial/Step2/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-project (Tutorial)
-
-# The version number.
-set (Tutorial_VERSION_MAJOR 1)
-set (Tutorial_VERSION_MINOR 0)
-
-# should we use our own math functions
-option(USE_MYMATH "Use tutorial provided math implementation" ON)
-
-# configure a header file to pass some of the CMake settings
-# to the source code
-configure_file (
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
-
-# add the binary tree to the search path for include files
-# so that we will find TutorialConfig.h
-include_directories ("${PROJECT_BINARY_DIR}")
-
-# add the MathFunctions library?
-if (USE_MYMATH)
- include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
- add_subdirectory (MathFunctions)
- set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
-endif ()
-
-# add the executable
-add_executable (Tutorial tutorial.cxx)
-target_link_libraries (Tutorial ${EXTRA_LIBS})
diff --git a/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx
deleted file mode 100644
index 2710f9220..000000000
--- a/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "MathFunctions.h"
-#include <stdio.h>
-
-// a hack square root calculation using simple operations
-double mysqrt(double x)
-{
- if (x <= 0) {
- return 0;
- }
-
- double result;
- double delta;
- result = x;
-
- // do ten iterations
- int i;
- for (i = 0; i < 10; ++i) {
- if (result <= 0) {
- result = 0.1;
- }
- delta = x - (result * result);
- result = result + 0.5 * delta / result;
- fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result);
- }
- return result;
-}
diff --git a/Tests/Tutorial/Step2/TutorialConfig.h.in b/Tests/Tutorial/Step2/TutorialConfig.h.in
deleted file mode 100644
index 25a06020a..000000000
--- a/Tests/Tutorial/Step2/TutorialConfig.h.in
+++ /dev/null
@@ -1,5 +0,0 @@
-// the configured options and settings for Tutorial
-#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
-#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
-#cmakedefine USE_MYMATH
-
diff --git a/Tests/Tutorial/Step2/tutorial.cxx b/Tests/Tutorial/Step2/tutorial.cxx
deleted file mode 100644
index 2fae364d4..000000000
--- a/Tests/Tutorial/Step2/tutorial.cxx
+++ /dev/null
@@ -1,33 +0,0 @@
-// A simple program that computes the square root of a number
-#include "TutorialConfig.h"
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef USE_MYMATH
-#include "MathFunctions.h"
-#endif
-
-int main(int argc, char* argv[])
-{
- if (argc < 2) {
- fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
- Tutorial_VERSION_MINOR);
- fprintf(stdout, "Usage: %s number\n", argv[0]);
- return 1;
- }
-
- double inputValue = atof(argv[1]);
- double outputValue = 0;
-
- if (inputValue >= 0) {
-#ifdef USE_MYMATH
- outputValue = mysqrt(inputValue);
-#else
- outputValue = sqrt(inputValue);
-#endif
- }
-
- fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
- return 0;
-}
diff --git a/Tests/Tutorial/Step3/CMakeLists.txt b/Tests/Tutorial/Step3/CMakeLists.txt
deleted file mode 100644
index 762302bc5..000000000
--- a/Tests/Tutorial/Step3/CMakeLists.txt
+++ /dev/null
@@ -1,68 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-project (Tutorial)
-
-# The version number.
-set (Tutorial_VERSION_MAJOR 1)
-set (Tutorial_VERSION_MINOR 0)
-
-# should we use our own math functions
-option(USE_MYMATH "Use tutorial provided math implementation" ON)
-
-# configure a header file to pass some of the CMake settings
-# to the source code
-configure_file (
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
-
-# add the binary tree to the search path for include files
-# so that we will find TutorialConfig.h
-include_directories ("${PROJECT_BINARY_DIR}")
-
-# add the MathFunctions library?
-if (USE_MYMATH)
- include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
- add_subdirectory (MathFunctions)
- set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
-endif ()
-
-# add the executable
-add_executable (Tutorial tutorial.cxx)
-target_link_libraries (Tutorial ${EXTRA_LIBS})
-
-# add the install targets
-install (TARGETS Tutorial DESTINATION bin)
-install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- DESTINATION include)
-
-
-# enable testing
-enable_testing ()
-
-# does the application run
-add_test (TutorialRuns Tutorial 25)
-
-# does it sqrt of 25
-add_test (TutorialComp25 Tutorial 25)
-set_tests_properties (TutorialComp25
- PROPERTIES PASS_REGULAR_EXPRESSION "25 is 5"
- )
-
-# does it handle negative numbers
-add_test (TutorialNegative Tutorial -25)
-set_tests_properties (TutorialNegative
- PROPERTIES PASS_REGULAR_EXPRESSION "-25 is 0"
- )
-
-# does it handle small numbers
-add_test (TutorialSmall Tutorial 0.0001)
-set_tests_properties (TutorialSmall
- PROPERTIES PASS_REGULAR_EXPRESSION "0.0001 is 0.01"
- )
-
-# does the usage message work?
-add_test (TutorialUsage Tutorial)
-set_tests_properties (TutorialUsage
- PROPERTIES
- PASS_REGULAR_EXPRESSION "Usage:.*number"
- )
diff --git a/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt
deleted file mode 100644
index f386036c3..000000000
--- a/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-add_library(MathFunctions mysqrt.cxx)
-
-install (TARGETS MathFunctions DESTINATION bin)
-install (FILES MathFunctions.h DESTINATION include)
diff --git a/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx
deleted file mode 100644
index 2710f9220..000000000
--- a/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "MathFunctions.h"
-#include <stdio.h>
-
-// a hack square root calculation using simple operations
-double mysqrt(double x)
-{
- if (x <= 0) {
- return 0;
- }
-
- double result;
- double delta;
- result = x;
-
- // do ten iterations
- int i;
- for (i = 0; i < 10; ++i) {
- if (result <= 0) {
- result = 0.1;
- }
- delta = x - (result * result);
- result = result + 0.5 * delta / result;
- fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result);
- }
- return result;
-}
diff --git a/Tests/Tutorial/Step3/TutorialConfig.h.in b/Tests/Tutorial/Step3/TutorialConfig.h.in
deleted file mode 100644
index 25a06020a..000000000
--- a/Tests/Tutorial/Step3/TutorialConfig.h.in
+++ /dev/null
@@ -1,5 +0,0 @@
-// the configured options and settings for Tutorial
-#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
-#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
-#cmakedefine USE_MYMATH
-
diff --git a/Tests/Tutorial/Step3/tutorial.cxx b/Tests/Tutorial/Step3/tutorial.cxx
deleted file mode 100644
index 2fae364d4..000000000
--- a/Tests/Tutorial/Step3/tutorial.cxx
+++ /dev/null
@@ -1,33 +0,0 @@
-// A simple program that computes the square root of a number
-#include "TutorialConfig.h"
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef USE_MYMATH
-#include "MathFunctions.h"
-#endif
-
-int main(int argc, char* argv[])
-{
- if (argc < 2) {
- fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
- Tutorial_VERSION_MINOR);
- fprintf(stdout, "Usage: %s number\n", argv[0]);
- return 1;
- }
-
- double inputValue = atof(argv[1]);
- double outputValue = 0;
-
- if (inputValue >= 0) {
-#ifdef USE_MYMATH
- outputValue = mysqrt(inputValue);
-#else
- outputValue = sqrt(inputValue);
-#endif
- }
-
- fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
- return 0;
-}
diff --git a/Tests/Tutorial/Step4/CMakeLists.txt b/Tests/Tutorial/Step4/CMakeLists.txt
deleted file mode 100644
index 6994aa1ce..000000000
--- a/Tests/Tutorial/Step4/CMakeLists.txt
+++ /dev/null
@@ -1,68 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-project (Tutorial)
-
-# The version number.
-set (Tutorial_VERSION_MAJOR 1)
-set (Tutorial_VERSION_MINOR 0)
-
-# does this system provide the log and exp functions?
-include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
-check_function_exists (log HAVE_LOG)
-check_function_exists (exp HAVE_EXP)
-
-# should we use our own math functions
-option(USE_MYMATH "Use tutorial provided math implementation" ON)
-
-# configure a header file to pass some of the CMake settings
-# to the source code
-configure_file (
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
-
-# add the binary tree to the search path for include files
-# so that we will find TutorialConfig.h
-include_directories ("${PROJECT_BINARY_DIR}")
-
-# add the MathFunctions library?
-if (USE_MYMATH)
- include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
- add_subdirectory (MathFunctions)
- set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
-endif ()
-
-# add the executable
-add_executable (Tutorial tutorial.cxx)
-target_link_libraries (Tutorial ${EXTRA_LIBS})
-
-# add the install targets
-install (TARGETS Tutorial DESTINATION bin)
-install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- DESTINATION include)
-
-# enable testing
-enable_testing ()
-
-# does the application run
-add_test (TutorialRuns Tutorial 25)
-
-# does the usage message work?
-add_test (TutorialUsage Tutorial)
-set_tests_properties (TutorialUsage
- PROPERTIES
- PASS_REGULAR_EXPRESSION "Usage:.*number"
- )
-
-#define a macro to simplify adding tests
-macro (do_test arg result)
- add_test (TutorialComp${arg} Tutorial ${arg})
- set_tests_properties (TutorialComp${arg}
- PROPERTIES PASS_REGULAR_EXPRESSION ${result}
- )
-endmacro ()
-
-# do a bunch of result based tests
-do_test (25 "25 is 5")
-do_test (-25 "-25 is 0")
-do_test (0.0001 "0.0001 is 0.01")
-
diff --git a/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt
deleted file mode 100644
index f386036c3..000000000
--- a/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-add_library(MathFunctions mysqrt.cxx)
-
-install (TARGETS MathFunctions DESTINATION bin)
-install (FILES MathFunctions.h DESTINATION include)
diff --git a/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx
deleted file mode 100644
index 6ca264f76..000000000
--- a/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "MathFunctions.h"
-#include "TutorialConfig.h"
-#include <stdio.h>
-
-#include <math.h>
-
-// a hack square root calculation using simple operations
-double mysqrt(double x)
-{
- if (x <= 0) {
- return 0;
- }
-
- double result;
-
-// if we have both log and exp then use them
-#if defined(HAVE_LOG) && defined(HAVE_EXP)
- result = exp(log(x) * 0.5);
- fprintf(stdout, "Computing sqrt of %g to be %g using log\n", x, result);
-#else
- double delta;
- result = x;
-
- // do ten iterations
- int i;
- for (i = 0; i < 10; ++i) {
- if (result <= 0) {
- result = 0.1;
- }
- delta = x - (result * result);
- result = result + 0.5 * delta / result;
- fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result);
- }
-#endif
- return result;
-}
diff --git a/Tests/Tutorial/Step4/TutorialConfig.h.in b/Tests/Tutorial/Step4/TutorialConfig.h.in
deleted file mode 100644
index a0912656a..000000000
--- a/Tests/Tutorial/Step4/TutorialConfig.h.in
+++ /dev/null
@@ -1,9 +0,0 @@
-// the configured options and settings for Tutorial
-#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
-#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
-#cmakedefine USE_MYMATH
-
-// does the platform provide exp and log functions?
-#cmakedefine HAVE_LOG
-#cmakedefine HAVE_EXP
-
diff --git a/Tests/Tutorial/Step4/tutorial.cxx b/Tests/Tutorial/Step4/tutorial.cxx
deleted file mode 100644
index 2fae364d4..000000000
--- a/Tests/Tutorial/Step4/tutorial.cxx
+++ /dev/null
@@ -1,33 +0,0 @@
-// A simple program that computes the square root of a number
-#include "TutorialConfig.h"
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef USE_MYMATH
-#include "MathFunctions.h"
-#endif
-
-int main(int argc, char* argv[])
-{
- if (argc < 2) {
- fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
- Tutorial_VERSION_MINOR);
- fprintf(stdout, "Usage: %s number\n", argv[0]);
- return 1;
- }
-
- double inputValue = atof(argv[1]);
- double outputValue = 0;
-
- if (inputValue >= 0) {
-#ifdef USE_MYMATH
- outputValue = mysqrt(inputValue);
-#else
- outputValue = sqrt(inputValue);
-#endif
- }
-
- fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
- return 0;
-}
diff --git a/Tests/Tutorial/Step5/CMakeLists.txt b/Tests/Tutorial/Step5/CMakeLists.txt
deleted file mode 100644
index e40b676b4..000000000
--- a/Tests/Tutorial/Step5/CMakeLists.txt
+++ /dev/null
@@ -1,72 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-project (Tutorial)
-
-# The version number.
-set (Tutorial_VERSION_MAJOR 1)
-set (Tutorial_VERSION_MINOR 0)
-
-# does this system provide the log and exp functions?
-include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
-check_function_exists (log HAVE_LOG)
-check_function_exists (exp HAVE_EXP)
-
-# should we use our own math functions
-option(USE_MYMATH "Use tutorial provided math implementation" ON)
-
-# configure a header file to pass some of the CMake settings
-# to the source code
-configure_file (
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
-
-# add the binary tree to the search path for include files
-# so that we will find TutorialConfig.h
-include_directories ("${PROJECT_BINARY_DIR}")
-
-# add the MathFunctions library?
-if (USE_MYMATH)
- include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
- add_subdirectory (MathFunctions)
- set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
-endif ()
-
-# add the executable
-add_executable (Tutorial tutorial.cxx)
-target_link_libraries (Tutorial ${EXTRA_LIBS})
-
-# add the install targets
-install (TARGETS Tutorial DESTINATION bin)
-install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- DESTINATION include)
-
-# enable testing
-enable_testing ()
-
-# does the application run
-add_test (TutorialRuns Tutorial 25)
-
-# does the usage message work?
-add_test (TutorialUsage Tutorial)
-set_tests_properties (TutorialUsage
- PROPERTIES
- PASS_REGULAR_EXPRESSION "Usage:.*number"
- )
-
-#define a macro to simplify adding tests
-macro (do_test arg result)
- add_test (TutorialComp${arg} Tutorial ${arg})
- set_tests_properties (TutorialComp${arg}
- PROPERTIES PASS_REGULAR_EXPRESSION ${result}
- )
-endmacro ()
-
-# do a bunch of result based tests
-do_test (4 "4 is 2")
-do_test (9 "9 is 3")
-do_test (5 "5 is 2.236")
-do_test (7 "7 is 2.645")
-do_test (25 "25 is 5")
-do_test (-25 "-25 is 0")
-do_test (0.0001 "0.0001 is 0.01")
-
diff --git a/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx
deleted file mode 100644
index 458ed63a1..000000000
--- a/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "MathFunctions.h"
-#include "TutorialConfig.h"
-#include <stdio.h>
-
-// include the generated table
-#include "Table.h"
-
-#include <math.h>
-
-// a hack square root calculation using simple operations
-double mysqrt(double x)
-{
- if (x <= 0) {
- return 0;
- }
-
- double result;
-
- // if we have both log and exp then use them
- double delta;
-
- // use the table to help find an initial value
- result = x;
- if (x >= 1 && x < 10) {
- result = sqrtTable[static_cast<int>(x)];
- }
-
- // do ten iterations
- int i;
- for (i = 0; i < 10; ++i) {
- if (result <= 0) {
- result = 0.1;
- }
- delta = x - (result * result);
- result = result + 0.5 * delta / result;
- fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result);
- }
-
- return result;
-}
diff --git a/Tests/Tutorial/Step5/TutorialConfig.h.in b/Tests/Tutorial/Step5/TutorialConfig.h.in
deleted file mode 100644
index a0912656a..000000000
--- a/Tests/Tutorial/Step5/TutorialConfig.h.in
+++ /dev/null
@@ -1,9 +0,0 @@
-// the configured options and settings for Tutorial
-#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
-#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
-#cmakedefine USE_MYMATH
-
-// does the platform provide exp and log functions?
-#cmakedefine HAVE_LOG
-#cmakedefine HAVE_EXP
-
diff --git a/Tests/Tutorial/Step5/tutorial.cxx b/Tests/Tutorial/Step5/tutorial.cxx
deleted file mode 100644
index 2fae364d4..000000000
--- a/Tests/Tutorial/Step5/tutorial.cxx
+++ /dev/null
@@ -1,33 +0,0 @@
-// A simple program that computes the square root of a number
-#include "TutorialConfig.h"
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef USE_MYMATH
-#include "MathFunctions.h"
-#endif
-
-int main(int argc, char* argv[])
-{
- if (argc < 2) {
- fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
- Tutorial_VERSION_MINOR);
- fprintf(stdout, "Usage: %s number\n", argv[0]);
- return 1;
- }
-
- double inputValue = atof(argv[1]);
- double outputValue = 0;
-
- if (inputValue >= 0) {
-#ifdef USE_MYMATH
- outputValue = mysqrt(inputValue);
-#else
- outputValue = sqrt(inputValue);
-#endif
- }
-
- fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
- return 0;
-}
diff --git a/Tests/Tutorial/Step6/CMakeLists.txt b/Tests/Tutorial/Step6/CMakeLists.txt
deleted file mode 100644
index 0fb7cac5f..000000000
--- a/Tests/Tutorial/Step6/CMakeLists.txt
+++ /dev/null
@@ -1,78 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-project (Tutorial)
-
-# The version number.
-set (Tutorial_VERSION_MAJOR 1)
-set (Tutorial_VERSION_MINOR 0)
-
-# does this system provide the log and exp functions?
-include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
-check_function_exists (log HAVE_LOG)
-check_function_exists (exp HAVE_EXP)
-
-# should we use our own math functions
-option(USE_MYMATH "Use tutorial provided math implementation" ON)
-
-# configure a header file to pass some of the CMake settings
-# to the source code
-configure_file (
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
-
-# add the binary tree to the search path for include files
-# so that we will find TutorialConfig.h
-include_directories ("${PROJECT_BINARY_DIR}")
-
-# add the MathFunctions library?
-if (USE_MYMATH)
- include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
- add_subdirectory (MathFunctions)
- set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
-endif ()
-
-# add the executable
-add_executable (Tutorial tutorial.cxx)
-target_link_libraries (Tutorial ${EXTRA_LIBS})
-
-# add the install targets
-install (TARGETS Tutorial DESTINATION bin)
-install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- DESTINATION include)
-
-# enable testing
-enable_testing ()
-
-# does the application run
-add_test (TutorialRuns Tutorial 25)
-
-# does the usage message work?
-add_test (TutorialUsage Tutorial)
-set_tests_properties (TutorialUsage
- PROPERTIES
- PASS_REGULAR_EXPRESSION "Usage:.*number"
- )
-
-#define a macro to simplify adding tests
-macro (do_test arg result)
- add_test (TutorialComp${arg} Tutorial ${arg})
- set_tests_properties (TutorialComp${arg}
- PROPERTIES PASS_REGULAR_EXPRESSION ${result}
- )
-endmacro ()
-
-# do a bunch of result based tests
-do_test (4 "4 is 2")
-do_test (9 "9 is 3")
-do_test (5 "5 is 2.236")
-do_test (7 "7 is 2.645")
-do_test (25 "25 is 5")
-do_test (-25 "-25 is 0")
-do_test (0.0001 "0.0001 is 0.01")
-
-# build a CPack driven installer package
-include (InstallRequiredSystemLibraries)
-set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
-set (CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}")
-set (CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}")
-include (CPack)
diff --git a/Tests/Tutorial/Step6/License.txt b/Tests/Tutorial/Step6/License.txt
deleted file mode 100644
index 673d72453..000000000
--- a/Tests/Tutorial/Step6/License.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-This is the open source License.txt file introduced in
-CMake/Tests/Tutorial/Step6...
diff --git a/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt
deleted file mode 100644
index 70a35f662..000000000
--- a/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-# first we add the executable that generates the table
-add_executable(MakeTable MakeTable.cxx)
-
-# add the command to generate the source code
-add_custom_command (
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
- DEPENDS MakeTable
- COMMAND MakeTable
- ARGS ${CMAKE_CURRENT_BINARY_DIR}/Table.h
- )
-
-set_source_files_properties (
- mysqrt.cxx PROPERTIES
- OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Table.h
- )
-
-# add the binary tree directory to the search path for include files
-include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
-
-# add the main library
-add_library(MathFunctions mysqrt.cxx)
-
-install (TARGETS MathFunctions DESTINATION bin)
-install (FILES MathFunctions.h DESTINATION include)
diff --git a/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx
deleted file mode 100644
index cebd50fcc..000000000
--- a/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx
+++ /dev/null
@@ -1,32 +0,0 @@
-// A simple program that builds a sqrt table
-#include <math.h>
-#include <stdio.h>
-
-int main(int argc, char* argv[])
-{
- int i;
- double result;
-
- // make sure we have enough arguments
- if (argc < 2) {
- return 1;
- }
-
- // open the output file
- FILE* fout = fopen(argv[1], "w");
- if (!fout) {
- return 1;
- }
-
- // create a source file with a table of square roots
- fprintf(fout, "double sqrtTable[] = {\n");
- for (i = 0; i < 10; ++i) {
- result = sqrt(static_cast<double>(i));
- fprintf(fout, "%g,\n", result);
- }
-
- // close the table with a zero
- fprintf(fout, "0};\n");
- fclose(fout);
- return 0;
-}
diff --git a/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx
deleted file mode 100644
index 458ed63a1..000000000
--- a/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "MathFunctions.h"
-#include "TutorialConfig.h"
-#include <stdio.h>
-
-// include the generated table
-#include "Table.h"
-
-#include <math.h>
-
-// a hack square root calculation using simple operations
-double mysqrt(double x)
-{
- if (x <= 0) {
- return 0;
- }
-
- double result;
-
- // if we have both log and exp then use them
- double delta;
-
- // use the table to help find an initial value
- result = x;
- if (x >= 1 && x < 10) {
- result = sqrtTable[static_cast<int>(x)];
- }
-
- // do ten iterations
- int i;
- for (i = 0; i < 10; ++i) {
- if (result <= 0) {
- result = 0.1;
- }
- delta = x - (result * result);
- result = result + 0.5 * delta / result;
- fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result);
- }
-
- return result;
-}
diff --git a/Tests/Tutorial/Step6/TutorialConfig.h.in b/Tests/Tutorial/Step6/TutorialConfig.h.in
deleted file mode 100644
index a0912656a..000000000
--- a/Tests/Tutorial/Step6/TutorialConfig.h.in
+++ /dev/null
@@ -1,9 +0,0 @@
-// the configured options and settings for Tutorial
-#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
-#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
-#cmakedefine USE_MYMATH
-
-// does the platform provide exp and log functions?
-#cmakedefine HAVE_LOG
-#cmakedefine HAVE_EXP
-
diff --git a/Tests/Tutorial/Step6/tutorial.cxx b/Tests/Tutorial/Step6/tutorial.cxx
deleted file mode 100644
index 2fae364d4..000000000
--- a/Tests/Tutorial/Step6/tutorial.cxx
+++ /dev/null
@@ -1,33 +0,0 @@
-// A simple program that computes the square root of a number
-#include "TutorialConfig.h"
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef USE_MYMATH
-#include "MathFunctions.h"
-#endif
-
-int main(int argc, char* argv[])
-{
- if (argc < 2) {
- fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
- Tutorial_VERSION_MINOR);
- fprintf(stdout, "Usage: %s number\n", argv[0]);
- return 1;
- }
-
- double inputValue = atof(argv[1]);
- double outputValue = 0;
-
- if (inputValue >= 0) {
-#ifdef USE_MYMATH
- outputValue = mysqrt(inputValue);
-#else
- outputValue = sqrt(inputValue);
-#endif
- }
-
- fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
- return 0;
-}
diff --git a/Tests/Tutorial/Step7/CMakeLists.txt b/Tests/Tutorial/Step7/CMakeLists.txt
deleted file mode 100644
index d9a92fbef..000000000
--- a/Tests/Tutorial/Step7/CMakeLists.txt
+++ /dev/null
@@ -1,82 +0,0 @@
-cmake_minimum_required (VERSION 2.6)
-project (Tutorial)
-
-# The version number.
-set (Tutorial_VERSION_MAJOR 1)
-set (Tutorial_VERSION_MINOR 0)
-
-# does this system provide the log and exp functions?
-include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
-check_function_exists (log HAVE_LOG)
-check_function_exists (exp HAVE_EXP)
-
-# should we use our own math functions
-option(USE_MYMATH "Use tutorial provided math implementation" ON)
-
-# configure a header file to pass some of the CMake settings
-# to the source code
-configure_file (
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
-
-# add the binary tree to the search path for include files
-# so that we will find TutorialConfig.h
-include_directories ("${PROJECT_BINARY_DIR}")
-
-# add the MathFunctions library?
-if (USE_MYMATH)
- include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
- add_subdirectory (MathFunctions)
- set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
-endif ()
-
-# add the executable
-add_executable (Tutorial tutorial.cxx)
-target_link_libraries (Tutorial ${EXTRA_LIBS})
-
-# add the install targets
-install (TARGETS Tutorial DESTINATION bin)
-install (FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- DESTINATION include)
-
-# enable testing
-enable_testing ()
-
-# does the application run
-add_test (TutorialRuns Tutorial 25)
-
-# does the usage message work?
-add_test (TutorialUsage Tutorial)
-set_tests_properties (TutorialUsage
- PROPERTIES
- PASS_REGULAR_EXPRESSION "Usage:.*number"
- )
-
-#define a macro to simplify adding tests
-macro (do_test arg result)
- add_test (TutorialComp${arg} Tutorial ${arg})
- set_tests_properties (TutorialComp${arg}
- PROPERTIES PASS_REGULAR_EXPRESSION ${result}
- )
-endmacro ()
-
-# do a bunch of result based tests
-do_test (4 "4 is 2")
-do_test (9 "9 is 3")
-do_test (5 "5 is 2.236")
-do_test (7 "7 is 2.645")
-do_test (25 "25 is 5")
-do_test (-25 "-25 is 0")
-do_test (0.0001 "0.0001 is 0.01")
-
-# build a CPack driven installer package
-include (InstallRequiredSystemLibraries)
-set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
-set (CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}")
-set (CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}")
-set (CPACK_PACKAGE_CONTACT "foo@bar.org")
-include (CPack)
-
-# enable dashboard scripting
-include (CTest)
diff --git a/Tests/Tutorial/Step7/CTestConfig.cmake b/Tests/Tutorial/Step7/CTestConfig.cmake
deleted file mode 100644
index d8f5c4491..000000000
--- a/Tests/Tutorial/Step7/CTestConfig.cmake
+++ /dev/null
@@ -1 +0,0 @@
-set (CTEST_PROJECT_NAME "Tutorial")
diff --git a/Tests/Tutorial/Step7/License.txt b/Tests/Tutorial/Step7/License.txt
deleted file mode 100644
index 673d72453..000000000
--- a/Tests/Tutorial/Step7/License.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-This is the open source License.txt file introduced in
-CMake/Tests/Tutorial/Step6...
diff --git a/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt b/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt
deleted file mode 100644
index 70a35f662..000000000
--- a/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-# first we add the executable that generates the table
-add_executable(MakeTable MakeTable.cxx)
-
-# add the command to generate the source code
-add_custom_command (
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
- DEPENDS MakeTable
- COMMAND MakeTable
- ARGS ${CMAKE_CURRENT_BINARY_DIR}/Table.h
- )
-
-set_source_files_properties (
- mysqrt.cxx PROPERTIES
- OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Table.h
- )
-
-# add the binary tree directory to the search path for include files
-include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
-
-# add the main library
-add_library(MathFunctions mysqrt.cxx)
-
-install (TARGETS MathFunctions DESTINATION bin)
-install (FILES MathFunctions.h DESTINATION include)
diff --git a/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx b/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx
deleted file mode 100644
index cebd50fcc..000000000
--- a/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx
+++ /dev/null
@@ -1,32 +0,0 @@
-// A simple program that builds a sqrt table
-#include <math.h>
-#include <stdio.h>
-
-int main(int argc, char* argv[])
-{
- int i;
- double result;
-
- // make sure we have enough arguments
- if (argc < 2) {
- return 1;
- }
-
- // open the output file
- FILE* fout = fopen(argv[1], "w");
- if (!fout) {
- return 1;
- }
-
- // create a source file with a table of square roots
- fprintf(fout, "double sqrtTable[] = {\n");
- for (i = 0; i < 10; ++i) {
- result = sqrt(static_cast<double>(i));
- fprintf(fout, "%g,\n", result);
- }
-
- // close the table with a zero
- fprintf(fout, "0};\n");
- fclose(fout);
- return 0;
-}
diff --git a/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx b/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx
deleted file mode 100644
index 458ed63a1..000000000
--- a/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "MathFunctions.h"
-#include "TutorialConfig.h"
-#include <stdio.h>
-
-// include the generated table
-#include "Table.h"
-
-#include <math.h>
-
-// a hack square root calculation using simple operations
-double mysqrt(double x)
-{
- if (x <= 0) {
- return 0;
- }
-
- double result;
-
- // if we have both log and exp then use them
- double delta;
-
- // use the table to help find an initial value
- result = x;
- if (x >= 1 && x < 10) {
- result = sqrtTable[static_cast<int>(x)];
- }
-
- // do ten iterations
- int i;
- for (i = 0; i < 10; ++i) {
- if (result <= 0) {
- result = 0.1;
- }
- delta = x - (result * result);
- result = result + 0.5 * delta / result;
- fprintf(stdout, "Computing sqrt of %g to be %g\n", x, result);
- }
-
- return result;
-}
diff --git a/Tests/Tutorial/Step7/TutorialConfig.h.in b/Tests/Tutorial/Step7/TutorialConfig.h.in
deleted file mode 100644
index a0912656a..000000000
--- a/Tests/Tutorial/Step7/TutorialConfig.h.in
+++ /dev/null
@@ -1,9 +0,0 @@
-// the configured options and settings for Tutorial
-#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
-#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
-#cmakedefine USE_MYMATH
-
-// does the platform provide exp and log functions?
-#cmakedefine HAVE_LOG
-#cmakedefine HAVE_EXP
-
diff --git a/Tests/Tutorial/Step7/build1.cmake b/Tests/Tutorial/Step7/build1.cmake
deleted file mode 100644
index baa475f28..000000000
--- a/Tests/Tutorial/Step7/build1.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-set(CTEST_SOURCE_DIRECTORY "$ENV{HOME}/Dashboards/My Tests/CMake/Tests/Tutorial/Step7")
-set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}-build1")
-
-set(CTEST_CMAKE_COMMAND "cmake")
-set(CTEST_COMMAND "ctest -D Experimental")
diff --git a/Tests/Tutorial/Step7/build2.cmake b/Tests/Tutorial/Step7/build2.cmake
deleted file mode 100644
index c2f2e2e10..000000000
--- a/Tests/Tutorial/Step7/build2.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-set(CTEST_SOURCE_DIRECTORY "$ENV{HOME}/Dashboards/My Tests/CMake/Tests/Tutorial/Step7")
-set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}-build2")
-set(CTEST_CMAKE_GENERATOR "Visual Studio 8 2005")
-
-CTEST_START("Experimental")
-CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}")
-CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}")
-CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}")
-CTEST_SUBMIT()
diff --git a/Tests/Tutorial/Step7/tutorial.cxx b/Tests/Tutorial/Step7/tutorial.cxx
deleted file mode 100644
index 2fae364d4..000000000
--- a/Tests/Tutorial/Step7/tutorial.cxx
+++ /dev/null
@@ -1,33 +0,0 @@
-// A simple program that computes the square root of a number
-#include "TutorialConfig.h"
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef USE_MYMATH
-#include "MathFunctions.h"
-#endif
-
-int main(int argc, char* argv[])
-{
- if (argc < 2) {
- fprintf(stdout, "%s Version %d.%d\n", argv[0], Tutorial_VERSION_MAJOR,
- Tutorial_VERSION_MINOR);
- fprintf(stdout, "Usage: %s number\n", argv[0]);
- return 1;
- }
-
- double inputValue = atof(argv[1]);
- double outputValue = 0;
-
- if (inputValue >= 0) {
-#ifdef USE_MYMATH
- outputValue = mysqrt(inputValue);
-#else
- outputValue = sqrt(inputValue);
-#endif
- }
-
- fprintf(stdout, "The square root of %g is %g\n", inputValue, outputValue);
- return 0;
-}
diff --git a/Tests/Unset/CMakeLists.txt b/Tests/Unset/CMakeLists.txt
index 07aa68e7a..a40367bbe 100644
--- a/Tests/Unset/CMakeLists.txt
+++ b/Tests/Unset/CMakeLists.txt
@@ -21,17 +21,26 @@ set(x 43)
if(NOT x EQUAL 43)
message(FATAL_ERROR "x!=43")
endif()
+if(DEFINED CACHE{x})
+ message(FATAL_ERROR "x shouldn't be found in the cache")
+endif()
+
set(x)
if(DEFINED x)
message(FATAL_ERROR "x should be undefined now!")
endif()
+
# Cache variable
set(BAR "test" CACHE STRING "documentation")
if(NOT DEFINED BAR)
message(FATAL_ERROR "BAR not defined")
endif()
+if(NOT DEFINED CACHE{BAR})
+ message(FATAL_ERROR "BAR could not be found by CACHE{BAR}")
+endif()
+
# Test interaction of cache entries with variables.
set(BAR "test-var")
if(NOT "$CACHE{BAR}" STREQUAL "test")
diff --git a/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt b/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt
new file mode 100644
index 000000000..a2c239cbd
--- /dev/null
+++ b/Tests/UseSWIG/AlternateLibraryName/CMakeLists.txt
@@ -0,0 +1,35 @@
+cmake_minimum_required(VERSION 3.14...3.15)
+
+project(TestAlternateLibraryName CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
+
+# Path separator
+if (WIN32)
+ set (PS "$<SEMICOLON>")
+else()
+ set (PS ":")
+endif()
+
+unset(CMAKE_SWIG_FLAGS)
+
+set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/../example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/../example.i" PROPERTY COMPILE_OPTIONS -includeall)
+
+swig_add_library(example_python
+ LANGUAGE python
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example_python PROPERTIES
+ INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.."
+ SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)
+target_link_libraries(example_python PRIVATE Python2::Python)
+
+
+add_test (NAME AlternateLibraryName.example1
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}${PS}$<TARGET_FILE_DIR:example_python>"
+ "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
diff --git a/Tests/UseSWIG/BasicConfiguration.cmake b/Tests/UseSWIG/BasicConfiguration.cmake
new file mode 100644
index 000000000..fd3ac4031
--- /dev/null
+++ b/Tests/UseSWIG/BasicConfiguration.cmake
@@ -0,0 +1,83 @@
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+# Path separator
+if (WIN32)
+ set (PS "$<SEMICOLON>")
+else()
+ set (PS ":")
+endif()
+
+unset(SWIG_LANG_TYPE)
+unset(SWIG_LANG_INCLUDE_DIRECTORIES)
+unset(SWIG_LANG_DEFINITIONS)
+unset(SWIG_LANG_OPTIONS)
+unset(SWIG_LANG_LIBRARIES)
+
+if(${language} MATCHES csharp)
+ set(SWIG_LANG_TYPE TYPE SHARED)
+endif()
+if(${language} MATCHES python)
+ find_package(Python REQUIRED COMPONENTS Interpreter Development)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${Python_INCLUDE_DIRS})
+ set(SWIG_LANG_LIBRARIES ${Python_LIBRARIES})
+endif()
+if(${language} MATCHES perl)
+ find_package(Perl REQUIRED)
+ find_package(PerlLibs REQUIRED)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${PERL_INCLUDE_PATH})
+ separate_arguments(c_flags UNIX_COMMAND "${PERL_EXTRA_C_FLAGS}")
+ set(SWIG_LANG_OPTIONS ${c_flags})
+ set(SWIG_LANG_LIBRARIES ${PERL_LIBRARY})
+endif()
+if(${language} MATCHES tcl)
+ find_package(TCL REQUIRED)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${TCL_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${TCL_LIBRARY})
+endif()
+if(${language} MATCHES ruby)
+ find_package(Ruby REQUIRED)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${RUBY_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${RUBY_LIBRARY})
+endif()
+if(${language} MATCHES php4)
+ find_package(PHP4 REQUIRED)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${PHP4_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${PHP4_LIBRARY})
+endif()
+if(${language} MATCHES pike)
+ find_package(Pike REQUIRED)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${PIKE_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${PIKE_LIBRARY})
+endif()
+if(${language} MATCHES lua)
+ find_package(Lua REQUIRED)
+ set(SWIG_LANG_INCLUDE_DIRECTORIES ${LUA_INCLUDE_DIR})
+ set(SWIG_LANG_TYPE TYPE SHARED)
+ set(SWIG_LANG_LIBRARIES ${LUA_LIBRARIES})
+endif()
+
+unset(CMAKE_SWIG_FLAGS)
+
+set (CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTY COMPILE_OPTIONS -includeall)
+
+set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i"
+ PROPERTY GENERATED_INCLUDE_DIRECTORIES ${SWIG_LANG_INCLUDE_DIRECTORIES}
+ "${CMAKE_CURRENT_LIST_DIR}")
+set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i"
+ PROPERTY GENERATED_COMPILE_DEFINITIONS ${SWIG_LANG_DEFINITIONS})
+set_property(SOURCE "${CMAKE_CURRENT_LIST_DIR}/example.i"
+ PROPERTY GENERATED_COMPILE_OPTIONS ${SWIG_LANG_OPTIONS})
+
+
+SWIG_ADD_LIBRARY(example
+ LANGUAGE "${language}"
+ ${SWIG_LANG_TYPE}
+ SOURCES "${CMAKE_CURRENT_LIST_DIR}/example.i"
+ "${CMAKE_CURRENT_LIST_DIR}/example.cxx")
+TARGET_INCLUDE_DIRECTORIES(example PUBLIC ${CMAKE_CURRENT_LIST_DIR})
+TARGET_LINK_LIBRARIES(example PRIVATE ${SWIG_LANG_LIBRARIES})
diff --git a/Tests/UseSWIG/BasicCsharp/CMakeLists.txt b/Tests/UseSWIG/BasicCsharp/CMakeLists.txt
new file mode 100644
index 000000000..1a6c763b5
--- /dev/null
+++ b/Tests/UseSWIG/BasicCsharp/CMakeLists.txt
@@ -0,0 +1,21 @@
+cmake_minimum_required(VERSION 3.12...3.13)
+
+project(TestBasicCsharp CXX CSharp)
+
+include(CTest)
+
+set(language "csharp")
+
+include (../BasicConfiguration.cmake)
+
+set_source_files_properties(Square.cs Circle.cs Shape.cs PROPERTIES GENERATED 1)
+add_library(example_cs SHARED $<TARGET_PROPERTY:example,SWIG_SUPPORT_FILES> Square.cs Circle.cs Shape.cs)
+set_target_properties(example_cs PROPERTIES LINKER_LANGUAGE CSharp)
+target_link_libraries(example_cs example)
+
+add_executable(runme ${CMAKE_CURRENT_SOURCE_DIR}/../runme.cs)
+target_link_libraries(runme example_cs)
+set_target_properties(runme PROPERTIES LINKER_LANGUAGE CSharp)
+
+add_test (NAME BasicCsharp
+ COMMAND $<TARGET_FILE:runme>)
diff --git a/Tests/UseSWIG/BasicPerl/CMakeLists.txt b/Tests/UseSWIG/BasicPerl/CMakeLists.txt
new file mode 100644
index 000000000..cf02de7de
--- /dev/null
+++ b/Tests/UseSWIG/BasicPerl/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.1...3.13)
+
+project(TestBasicPerl CXX)
+
+include(CTest)
+
+set(language "perl")
+
+include (../BasicConfiguration.cmake)
+
+add_test (NAME BasicPerl
+ COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}"
+ "-I$<TARGET_FILE_DIR:example>"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl")
diff --git a/Tests/UseSWIG/BasicPython/CMakeLists.txt b/Tests/UseSWIG/BasicPython/CMakeLists.txt
new file mode 100644
index 000000000..8bbd1cbe8
--- /dev/null
+++ b/Tests/UseSWIG/BasicPython/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.1...3.13)
+
+project(TestBasicPython CXX)
+
+include(CTest)
+
+set(language "python")
+
+include (../BasicConfiguration.cmake)
+
+add_test (NAME BasicPython
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}${PS}$<TARGET_FILE_DIR:example>"
+ "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt
new file mode 100644
index 000000000..3cc910fec
--- /dev/null
+++ b/Tests/UseSWIG/CMakeLists.txt
@@ -0,0 +1,137 @@
+add_test(NAME UseSWIG.LegacyPython COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/LegacyPython"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/LegacyPython"
+ ${build_generator_args}
+ --build-project TestLegacyPython
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+add_test(NAME UseSWIG.LegacyPerl COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/LegacyPerl"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/LegacyPerl"
+ ${build_generator_args}
+ --build-project TestLegacyPerl
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+include(CheckLanguage)
+check_language(CSharp)
+if (CMAKE_CSharp_COMPILER)
+ add_test(NAME UseSWIG.BasicCsharp COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/BasicCsharp"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/BasicCsharp"
+ ${build_generator_args}
+ --build-project TestBasicCsharp
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+endif()
+
+add_test(NAME UseSWIG.BasicPython COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/BasicPython"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/BasicPython"
+ ${build_generator_args}
+ --build-project TestBasicPython
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+add_test(NAME UseSWIG.BasicPerl COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/BasicPerl"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/BasicPerl"
+ ${build_generator_args}
+ --build-project TestBasicPerl
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+
+add_test(NAME UseSWIG.MultipleModules COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/MultipleModules"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/MultipleModules"
+ ${build_generator_args}
+ --build-project TestMultipleModules
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+add_test(NAME UseSWIG.MultiplePython COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/MultiplePython"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/MultiplePython"
+ ${build_generator_args}
+ --build-project TestMultiplePython
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+
+add_test(NAME UseSWIG.ModuleVersion2 COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/ModuleVersion2"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/ModuleVersion2"
+ ${build_generator_args}
+ --build-project TestModuleVersion2
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+
+add_test(NAME UseSWIG.UseTargetINCLUDE_DIRECTORIES COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES"
+ ${build_generator_args}
+ --build-project TestUseTargetINCLUDE_DIRECTORIES
+ --build-options ${build_options}
+ )
+
+
+add_test(NAME UseSWIG.ModuleName COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/ModuleName"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/ModuleName"
+ ${build_generator_args}
+ --build-project TestModuleName
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+
+add_test(NAME UseSWIG.SwigSrcFileExtension COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/SwigSrcFileExtension"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/SwigSrcFileExtension"
+ ${build_generator_args}
+ --build-project SwigSrcFileExtension
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+
+add_test(NAME UseSWIG.AlternateLibraryName COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/UseSWIG/AlternateLibraryName"
+ "${CMake_BINARY_DIR}/Tests/UseSWIG/AlternateLibraryName"
+ ${build_generator_args}
+ --build-project TestAlternateLibraryName
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/UseSWIG/LegacyConfiguration.cmake b/Tests/UseSWIG/LegacyConfiguration.cmake
new file mode 100644
index 000000000..1acc05a4d
--- /dev/null
+++ b/Tests/UseSWIG/LegacyConfiguration.cmake
@@ -0,0 +1,68 @@
+
+# Prevent deprecated warnings from new UseSWIG module
+set (CMAKE_WARN_DEPRECATED FALSE)
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+# Path separator
+if (WIN32)
+ set (PS "$<SEMICOLON>")
+else()
+ set (PS ":")
+endif()
+
+unset(SWIG_LANG_TYPE)
+if(${language} MATCHES python)
+ find_package(PythonInterp REQUIRED)
+ find_package(PythonLibs REQUIRED)
+ include_directories(${PYTHON_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${PYTHON_LIBRARIES})
+endif()
+if(${language} MATCHES perl)
+ find_package(Perl REQUIRED)
+ find_package(PerlLibs REQUIRED)
+ include_directories(${PERL_INCLUDE_PATH})
+ separate_arguments(c_flags UNIX_COMMAND "${PERL_EXTRA_C_FLAGS}")
+ add_compile_options(${c_flags})
+ set(SWIG_LANG_LIBRARIES ${PERL_LIBRARY})
+endif()
+if(${language} MATCHES tcl)
+ find_package(TCL REQUIRED)
+ include_directories(${TCL_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${TCL_LIBRARY})
+endif()
+if(${language} MATCHES ruby)
+ find_package(Ruby REQUIRED)
+ include_directories(${RUBY_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${RUBY_LIBRARY})
+endif()
+if(${language} MATCHES php4)
+ find_package(PHP4 REQUIRED)
+ include_directories(${PHP4_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${PHP4_LIBRARY})
+endif()
+if(${language} MATCHES pike)
+ find_package(Pike REQUIRED)
+ include_directories(${PIKE_INCLUDE_PATH})
+ set(SWIG_LANG_LIBRARIES ${PIKE_LIBRARY})
+endif()
+if(${language} MATCHES lua)
+ find_package(Lua REQUIRED)
+ include_directories(${LUA_INCLUDE_DIR})
+ set(SWIG_LANG_TYPE TYPE SHARED)
+ set(SWIG_LANG_LIBRARIES ${LUA_LIBRARIES})
+endif()
+
+unset(CMAKE_SWIG_FLAGS)
+
+include_directories(${CMAKE_CURRENT_LIST_DIR})
+
+set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTIES CPLUSPLUS ON)
+set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/example.i" PROPERTIES SWIG_FLAGS "-includeall")
+SWIG_ADD_LIBRARY(example
+ LANGUAGE "${language}"
+ ${SWIG_LANG_TYPE}
+ SOURCES "${CMAKE_CURRENT_LIST_DIR}/example.i"
+ "${CMAKE_CURRENT_LIST_DIR}/example.cxx")
+SWIG_LINK_LIBRARIES(example ${SWIG_LANG_LIBRARIES})
diff --git a/Tests/UseSWIG/LegacyPerl/CMakeLists.txt b/Tests/UseSWIG/LegacyPerl/CMakeLists.txt
new file mode 100644
index 000000000..90d92f4eb
--- /dev/null
+++ b/Tests/UseSWIG/LegacyPerl/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestLegacyPerl CXX)
+
+include(CTest)
+
+set(language "perl")
+
+include (../LegacyConfiguration.cmake)
+
+add_test (NAME LegacyPerl
+ COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}"
+ "-I$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl")
diff --git a/Tests/UseSWIG/LegacyPython/CMakeLists.txt b/Tests/UseSWIG/LegacyPython/CMakeLists.txt
new file mode 100644
index 000000000..03facb19a
--- /dev/null
+++ b/Tests/UseSWIG/LegacyPython/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(TestLegacyPython CXX)
+
+include(CTest)
+
+set(language "python")
+
+include (../LegacyConfiguration.cmake)
+
+add_test (NAME LegacyPython
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}${PS}$<TARGET_FILE_DIR:${SWIG_MODULE_example_REAL_NAME}>"
+ "${PYTHON_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
diff --git a/Tests/UseSWIG/ModuleName/CMakeLists.txt b/Tests/UseSWIG/ModuleName/CMakeLists.txt
new file mode 100644
index 000000000..435b441a4
--- /dev/null
+++ b/Tests/UseSWIG/ModuleName/CMakeLists.txt
@@ -0,0 +1,42 @@
+cmake_minimum_required(VERSION 3.1...3.14)
+
+project(TestModuleName CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+cmake_policy(SET CMP0086 NEW)
+include(${SWIG_USE_FILE})
+
+find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
+
+# Path separator
+if (WIN32)
+ set (PS "$<SEMICOLON>")
+else()
+ set (PS ":")
+endif()
+
+unset(CMAKE_SWIG_FLAGS)
+
+set_property(SOURCE "example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "example.i" PROPERTY COMPILE_OPTIONS -includeall)
+set_property(SOURCE "example.i" PROPERTY SWIG_MODULE_NAME new_example)
+
+swig_add_library(example1
+ LANGUAGE python
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/example1"
+ SOURCES example.i ../example.cxx)
+set_target_properties (example1 PROPERTIES
+ INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.."
+ SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE
+ OUTPUT_NAME new_example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1")
+target_link_libraries(example1 PRIVATE Python2::Module)
+
+
+add_test (NAME ModuleName.example1
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python2${PS}$<TARGET_FILE_DIR:example1>"
+ "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runme.py")
diff --git a/Tests/UseSWIG/ModuleName/example.i b/Tests/UseSWIG/ModuleName/example.i
new file mode 100644
index 000000000..fbdf7249f
--- /dev/null
+++ b/Tests/UseSWIG/ModuleName/example.i
@@ -0,0 +1,9 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/Tests/UseSWIG/ModuleName/runme.py b/Tests/UseSWIG/ModuleName/runme.py
new file mode 100644
index 000000000..c37e4a736
--- /dev/null
+++ b/Tests/UseSWIG/ModuleName/runme.py
@@ -0,0 +1,52 @@
+# file: runme.py
+
+# This file illustrates the shadow-class C++ interface generated
+# by SWIG.
+
+from __future__ import print_function
+
+import new_example
+
+# ----- Object creation -----
+
+print ("Creating some objects:")
+c = new_example.Circle(10)
+print (" Created circle", c)
+s = new_example.Square(10)
+print (" Created square", s)
+
+# ----- Access a static member -----
+
+print ("\nA total of", new_example.cvar.Shape_nshapes,"shapes were created")
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+
+s.x = -10
+s.y = 5
+
+print ("\nHere is their current position:")
+print (" Circle = (%f, %f)" % (c.x,c.y))
+print (" Square = (%f, %f)" % (s.x,s.y))
+
+# ----- Call some methods -----
+
+print ("\nHere are some properties of the shapes:")
+for o in [c,s]:
+ print (" ", o)
+ print (" area = ", o.area())
+ print (" perimeter = ", o.perimeter())
+
+print ("\nGuess I'll clean up now")
+
+# Note: this invokes the virtual destructor
+del c
+del s
+
+s = 3
+print (new_example.cvar.Shape_nshapes,"shapes remain")
+print ("Goodbye")
diff --git a/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt
new file mode 100644
index 000000000..093e8582c
--- /dev/null
+++ b/Tests/UseSWIG/ModuleVersion2/CMakeLists.txt
@@ -0,0 +1,56 @@
+cmake_minimum_required(VERSION 3.1...3.13)
+
+project(TestModuleVersion2 CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
+
+if (WIN32)
+ set (PS $<SEMICOLON>)
+else()
+ set (PS ":")
+endif()
+
+set (UseSWIG_MODULE_VERSION 2)
+unset(CMAKE_SWIG_FLAGS)
+
+set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "../example.i" PROPERTY COMPILE_OPTIONS -includeall)
+
+set_property(SOURCE "../example.i"
+ PROPERTY GENERATED_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/..")
+
+swig_add_library(example1
+ LANGUAGE python
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example1 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2")
+target_link_libraries(example1 PRIVATE Python2::Module)
+
+# re-use sample interface file for another plugin
+swig_add_library(example2
+ LANGUAGE python
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example2 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3")
+target_link_libraries(example2 PRIVATE Python3::Module)
+
+
+add_test (NAME ModuleVersion2.example1
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example1,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example1>"
+ "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
+
+add_test (NAME ModuleVersion2.example2
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_PROPERTY:example2,SWIG_SUPPORT_FILES_DIRECTORY>${PS}$<TARGET_FILE_DIR:example2>"
+ "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
diff --git a/Tests/UseSWIG/MultipleModules/CMakeLists.txt b/Tests/UseSWIG/MultipleModules/CMakeLists.txt
new file mode 100644
index 000000000..4380080f5
--- /dev/null
+++ b/Tests/UseSWIG/MultipleModules/CMakeLists.txt
@@ -0,0 +1,68 @@
+cmake_minimum_required(VERSION 3.1...3.13)
+
+project(TestMultipleModules CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+find_package(Python REQUIRED COMPONENTS Interpreter Development)
+
+find_package(Perl REQUIRED)
+find_package(PerlLibs REQUIRED)
+
+# Path separator
+if (WIN32)
+ set (PS "$<SEMICOLON>")
+else()
+ set (PS ":")
+endif()
+
+unset(CMAKE_SWIG_FLAGS)
+
+set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "../example.i" PROPERTY COMPILE_OPTIONS -includeall)
+
+set_property(SOURCE "../example.i"
+ PROPERTY GENERATED_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/..")
+
+swig_add_library(example1
+ LANGUAGE python
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Python"
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example1 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python")
+target_link_libraries(example1 PRIVATE Python::Module)
+
+# re-use sample interface file for another plugin
+set_property(SOURCE "../example.i" APPEND PROPERTY
+ GENERATED_INCLUDE_DIRECTORIES ${PERL_INCLUDE_PATH})
+separate_arguments(c_flags UNIX_COMMAND "${PERL_EXTRA_C_FLAGS}")
+set_property(SOURCE "../example.i" PROPERTY GENERATED_COMPILE_OPTIONS ${c_flags})
+
+swig_add_library(example2
+ LANGUAGE perl
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Perl"
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example2 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Perl"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Perl"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Perl")
+target_link_libraries(example2 PRIVATE ${PERL_LIBRARY})
+
+
+
+add_test (NAME MultipleModules.Python
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python${PS}$<TARGET_FILE_DIR:example1>"
+ "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
+
+
+add_test (NAME MultipleModules.Perl
+ COMMAND "${PERL_EXECUTABLE}" "-I${CMAKE_CURRENT_BINARY_DIR}/Perl"
+ "-I$<TARGET_FILE_DIR:example2>"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../runme.pl")
diff --git a/Tests/UseSWIG/MultiplePython/CMakeLists.txt b/Tests/UseSWIG/MultiplePython/CMakeLists.txt
new file mode 100644
index 000000000..cf6c80e28
--- /dev/null
+++ b/Tests/UseSWIG/MultiplePython/CMakeLists.txt
@@ -0,0 +1,59 @@
+cmake_minimum_required(VERSION 3.1...3.13)
+
+project(TestMultiplePython CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
+
+# Path separator
+if (WIN32)
+ set (PS "$<SEMICOLON>")
+else()
+ set (PS ":")
+endif()
+
+unset(CMAKE_SWIG_FLAGS)
+
+set_property(SOURCE "../example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "../example.i" PROPERTY COMPILE_OPTIONS -includeall)
+
+set_property(SOURCE "../example.i"
+ PROPERTY GENERATED_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/..")
+
+swig_add_library(example1
+ LANGUAGE python
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Python2"
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example1 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python2")
+target_link_libraries(example1 PRIVATE Python2::Module)
+
+# re-use sample interface file for another plugin
+swig_add_library(example2
+ LANGUAGE python
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/Python3"
+ SOURCES ../example.i ../example.cxx)
+set_target_properties (example2 PROPERTIES
+ OUTPUT_NAME example
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Python3")
+target_link_libraries(example2 PRIVATE Python3::Module)
+
+
+
+add_test (NAME MultiplePython.example1
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python2${PS}$<TARGET_FILE_DIR:example1>"
+ "${Python2_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
+
+add_test (NAME MultiplePython.example2
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Python3${PS}$<TARGET_FILE_DIR:example2>"
+ "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../runme.py")
diff --git a/Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt b/Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt
new file mode 100644
index 000000000..f70ce491d
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcFileExtension/CMakeLists.txt
@@ -0,0 +1,28 @@
+cmake_minimum_required(VERSION 3.1...3.14)
+
+project(SwigSrcFileExtension C)
+
+include(CTest)
+find_package(SWIG REQUIRED)
+find_package(Python COMPONENTS Interpreter Development REQUIRED)
+
+include(${SWIG_USE_FILE})
+
+# Use the newer target name preference
+set(UseSWIG_TARGET_NAME_PREFERENCE "STANDARD")
+
+# Set the custom source file extension to both .i and .swg
+set(SWIG_SOURCE_FILE_EXTENSIONS ".i" ".swg")
+
+# Generate a Python module out of `.i`
+swig_add_library(my_add LANGUAGE python SOURCES my_add.i)
+target_link_libraries(my_add Python::Module)
+
+# Generate a Python module out of `.swg`
+swig_add_library(my_sub LANGUAGE python SOURCES my_sub.swg)
+target_link_libraries(my_sub Python::Module)
+
+# Add a test
+add_test(NAME SwigSrcFileExtension
+ COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}"
+ "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/runme.py")
diff --git a/Tests/UseSWIG/SwigSrcFileExtension/my_add.i b/Tests/UseSWIG/SwigSrcFileExtension/my_add.i
new file mode 100644
index 000000000..d087ab5e2
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcFileExtension/my_add.i
@@ -0,0 +1,9 @@
+%module my_add
+
+%{
+int add(int a, int b) {
+ return a + b;
+}
+%}
+
+int add(int a, int b);
diff --git a/Tests/UseSWIG/SwigSrcFileExtension/my_sub.swg b/Tests/UseSWIG/SwigSrcFileExtension/my_sub.swg
new file mode 100644
index 000000000..df34b441a
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcFileExtension/my_sub.swg
@@ -0,0 +1,9 @@
+%module my_sub
+
+%{
+int sub(int a, int b) {
+ return a - b;
+}
+%}
+
+int sub(int a, int b);
diff --git a/Tests/UseSWIG/SwigSrcFileExtension/runme.py b/Tests/UseSWIG/SwigSrcFileExtension/runme.py
new file mode 100755
index 000000000..290175b08
--- /dev/null
+++ b/Tests/UseSWIG/SwigSrcFileExtension/runme.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+import random
+
+import my_add
+import my_sub
+
+
+# These can be changed, but make sure not to overflow `int`
+a = random.randint(1, 1024)
+b = random.randint(1, 1024)
+
+if my_add.add(a, b) == a + b:
+ print ("Test 1 Passed for SWIG custom source file extension")
+else:
+ print ("Test 1 FAILED for SWIG custom source file extension")
+ exit(1)
+
+if my_sub.sub(a, b) == a - b:
+ print ("Test 2 Passed for SWIG custom source file extension")
+else:
+ print ("Test 2 FAILED for SWIG custom source file extension")
+ exit(1)
diff --git a/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt
new file mode 100644
index 000000000..80a2e1650
--- /dev/null
+++ b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.1...3.13)
+
+project(TestUseTargetINCLUDE_DIRECTORIES CXX)
+
+include(CTest)
+
+find_package(SWIG REQUIRED)
+include(${SWIG_USE_FILE})
+
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
+
+unset(CMAKE_SWIG_FLAGS)
+
+set_property(SOURCE "example.i" PROPERTY CPLUSPLUS ON)
+set_property(SOURCE "example.i" PROPERTY COMPILE_OPTIONS -includeall)
+
+swig_add_library(example1
+ LANGUAGE python
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/example1"
+ SOURCES example.i ../example.cxx)
+set_target_properties (example1 PROPERTIES
+ INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.."
+ SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE
+ OUTPUT_NAME example1
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example1")
+target_link_libraries(example1 PRIVATE Python3::Module)
+
+
+# Check that source property override target property
+set_property(SOURCE "example.i" PROPERTY USE_TARGET_INCLUDE_DIRECTORIES TRUE)
+
+swig_add_library(example2
+ LANGUAGE python
+ OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/example2"
+ SOURCES example.i ../example.cxx)
+set_target_properties (example2 PROPERTIES
+ INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/.."
+ SWIG_USE_TARGET_INCLUDE_DIRECTORIES FALSE
+ OUTPUT_NAME example2
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/example2")
+target_link_libraries(example2 PRIVATE Python3::Module)
diff --git a/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i
new file mode 100644
index 000000000..fbdf7249f
--- /dev/null
+++ b/Tests/UseSWIG/UseTargetINCLUDE_DIRECTORIES/example.i
@@ -0,0 +1,9 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/Tests/SwigTest/example.cxx b/Tests/UseSWIG/example.cxx
index 961d6dd9a..961d6dd9a 100644
--- a/Tests/SwigTest/example.cxx
+++ b/Tests/UseSWIG/example.cxx
diff --git a/Tests/SwigTest/example.h b/Tests/UseSWIG/example.h
index 366deb044..366deb044 100644
--- a/Tests/SwigTest/example.h
+++ b/Tests/UseSWIG/example.h
diff --git a/Tests/UseSWIG/example.i b/Tests/UseSWIG/example.i
new file mode 100644
index 000000000..fbdf7249f
--- /dev/null
+++ b/Tests/UseSWIG/example.i
@@ -0,0 +1,9 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/Tests/UseSWIG/runme.cs b/Tests/UseSWIG/runme.cs
new file mode 100644
index 000000000..f0c1bd220
--- /dev/null
+++ b/Tests/UseSWIG/runme.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+
+public class runme
+{
+ static void Main()
+ {
+ // ----- Object creation -----
+
+ Console.WriteLine("Creating some objects:");
+ Circle c = new Circle(10);
+ Console.WriteLine(" Created " + c);
+ Square s = new Square(10);
+ Console.WriteLine(" Created " + s);
+
+ // ----- Access a static member -----
+
+ Console.WriteLine("\nA total of " + Shape.nshapes + " shapes were created");
+
+ // ----- Member data access -----
+
+ // Set the location of the object
+
+ c.x = 20;
+ c.y = 30;
+
+ s.x = -10;
+ s.y = 5;
+
+ Console.WriteLine("\nHere is their current position:");
+ Console.WriteLine(" Circle = ({0}, {1})", c.x,c.y);
+ Console.WriteLine(" Square = ({0}, {1})", s.x,s.y);
+
+ // ----- Call some methods -----
+
+ Console.WriteLine("\nHere are some properties of the shapes:");
+ List <Shape> shapeList = new List <Shape> { c,s };
+ foreach(var o in shapeList){
+ Console.WriteLine(" " + o);
+ Console.WriteLine(" area = " + o.area());
+ Console.WriteLine(" perimeter = " + o.perimeter());
+ }
+
+ Console.WriteLine("\nGuess I'll clean up now");
+
+ // Note: this invokes the virtual destructor
+ c.Dispose();
+ s.Dispose();
+
+ s = new Square(10);;
+ Console.WriteLine(Shape.nshapes + " shapes remain");
+ Console.WriteLine("Goodbye");
+ }
+}
diff --git a/Tests/SwigTest/runme.php4 b/Tests/UseSWIG/runme.php4
index 653ced256..653ced256 100644
--- a/Tests/SwigTest/runme.php4
+++ b/Tests/UseSWIG/runme.php4
diff --git a/Tests/SwigTest/runme.pike b/Tests/UseSWIG/runme.pike
index ec28dd70e..ec28dd70e 100755..100644
--- a/Tests/SwigTest/runme.pike
+++ b/Tests/UseSWIG/runme.pike
diff --git a/Tests/UseSWIG/runme.pl b/Tests/UseSWIG/runme.pl
new file mode 100644
index 000000000..965e06382
--- /dev/null
+++ b/Tests/UseSWIG/runme.pl
@@ -0,0 +1,56 @@
+# file: runme.pl
+
+# This file illustrates the low-level C++ interface
+# created by SWIG. In this case, all of our C++ classes
+# get converted into function calls.
+
+use example;
+
+# ----- Object creation -----
+
+print "Creating some objects:\n";
+$c = examplec::new_Circle(10);
+print " Created circle $c\n";
+$s = examplec::new_Square(10);
+print " Created square $s\n";
+
+# ----- Access a static member -----
+
+print "\nA total of $examplec::Shape_nshapes shapes were created\n";
+
+# ----- Member data access -----
+
+# Set the location of the object.
+# Note: methods in the base class Shape are used since
+# x and y are defined there.
+
+examplec::Shape_x_set($c, 20);
+examplec::Shape_y_set($c, 30);
+examplec::Shape_x_set($s,-10);
+examplec::Shape_y_set($s,5);
+
+print "\nHere is their current position:\n";
+print " Circle = (",examplec::Shape_x_get($c),",", examplec::Shape_y_get($c),")\n";
+print " Square = (",examplec::Shape_x_get($s),",", examplec::Shape_y_get($s),")\n";
+
+# ----- Call some methods -----
+
+print "\nHere are some properties of the shapes:\n";
+foreach $o ($c,$s) {
+ print " $o\n";
+ print " area = ", examplec::Shape_area($o), "\n";
+ print " perimeter = ", examplec::Shape_perimeter($o), "\n";
+ }
+# Notice how the Shape_area() and Shape_perimeter() functions really
+# invoke the appropriate virtual method on each object.
+
+# ----- Delete everything -----
+
+print "\nGuess I'll clean up now\n";
+
+# Note: this invokes the virtual destructor
+examplec::delete_Shape($c);
+examplec::delete_Shape($s);
+
+print $examplec::Shape_nshapes," shapes remain\n";
+print "Goodbye\n";
diff --git a/Tests/UseSWIG/runme.py b/Tests/UseSWIG/runme.py
new file mode 100644
index 000000000..af5e07dc2
--- /dev/null
+++ b/Tests/UseSWIG/runme.py
@@ -0,0 +1,52 @@
+# file: runme.py
+
+# This file illustrates the shadow-class C++ interface generated
+# by SWIG.
+
+from __future__ import print_function
+
+import example
+
+# ----- Object creation -----
+
+print ("Creating some objects:")
+c = example.Circle(10)
+print (" Created circle", c)
+s = example.Square(10)
+print (" Created square", s)
+
+# ----- Access a static member -----
+
+print ("\nA total of", example.cvar.Shape_nshapes,"shapes were created")
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c.x = 20
+c.y = 30
+
+s.x = -10
+s.y = 5
+
+print ("\nHere is their current position:")
+print (" Circle = (%f, %f)" % (c.x,c.y))
+print (" Square = (%f, %f)" % (s.x,s.y))
+
+# ----- Call some methods -----
+
+print ("\nHere are some properties of the shapes:")
+for o in [c,s]:
+ print (" ", o)
+ print (" area = ", o.area())
+ print (" perimeter = ", o.perimeter())
+
+print ("\nGuess I'll clean up now")
+
+# Note: this invokes the virtual destructor
+del c
+del s
+
+s = 3
+print (example.cvar.Shape_nshapes,"shapes remain")
+print ("Goodbye")
diff --git a/Tests/SwigTest/runme.rb b/Tests/UseSWIG/runme.rb
index de73bcd46..de73bcd46 100644
--- a/Tests/SwigTest/runme.rb
+++ b/Tests/UseSWIG/runme.rb
diff --git a/Tests/UseSWIG/runme.tcl b/Tests/UseSWIG/runme.tcl
new file mode 100644
index 000000000..6055cf619
--- /dev/null
+++ b/Tests/UseSWIG/runme.tcl
@@ -0,0 +1,49 @@
+# file: runme.tcl
+
+# This file illustrates the high level C++ interface.
+# In this case C++ classes work kind of like Tk widgets
+
+catch { load ./example[info sharedlibextension] example}
+
+# ----- Object creation -----
+
+puts "Creating some objects:"
+Circle c 10
+puts " Created circle [c cget -this]"
+Square s 10
+puts " Created square [s cget -this]"
+
+# ----- Access a static member -----
+
+puts "\nA total of $Shape_nshapes shapes were created"
+
+# ----- Member data access -----
+
+# Set the location of the object
+
+c configure -x 20 -y 30
+s configure -x -10 -y 5
+
+puts "\nHere is their current position:"
+puts " Circle = ([c cget -x], [c cget -y])"
+puts " Square = ([s cget -x], [s cget -y])"
+
+# ----- Call some methods -----
+
+puts "\nHere are some properties of the shapes:"
+foreach o "c s" {
+ puts " [$o cget -this]"
+ puts " area = [$o area]"
+ puts " perimeter = [$o perimeter]"
+}
+
+# ----- Delete everything -----
+
+puts "\nGuess I'll clean up now"
+
+# Note: this invokes the virtual destructor
+rename c ""
+rename s ""
+
+puts "$Shape_nshapes shapes remain"
+puts "Goodbye"
diff --git a/Tests/UseSWIG/runme2.tcl b/Tests/UseSWIG/runme2.tcl
new file mode 100644
index 000000000..d0b5c219e
--- /dev/null
+++ b/Tests/UseSWIG/runme2.tcl
@@ -0,0 +1,69 @@
+# file: runme2.tcl
+
+# This file illustrates the low-level C++ interface
+# created by SWIG. In this case, all of our C++ classes
+# get converted into function calls.
+
+catch { load ./example[info sharedlibextension] example}
+
+# ----- Object creation -----
+
+puts "Creating some objects:"
+set c [new_Circle 10]
+puts " Created circle $c"
+set s [new_Square 10]
+puts " Created square $s"
+
+# ----- Access a static member -----
+
+puts "\nA total of $Shape_nshapes shapes were created"
+
+# ----- Member data access -----
+
+# Set the location of the object
+# Note: the base class must be used since that's where x and y
+# were declared.
+
+Shape_x_set $c 20
+Shape_y_set $c 30
+Shape_x_set $s -10
+Shape_y_set $s 5
+
+puts "\nHere is their current position:"
+puts " Circle = ([Shape_x_get $c], [Shape_y_get $c])"
+puts " Square = ([Shape_x_get $s], [Shape_y_get $s])"
+
+# ----- Call some methods -----
+
+puts "\nHere are some properties of the shapes:"
+foreach o "$c $s" {
+ puts " $o"
+ puts " area = [Shape_area $o]"
+ puts " perimeter = [Shape_perimeter $o]"
+}
+# Notice how the Shape_area() and Shape_perimeter() functions really
+# invoke the appropriate virtual method on each object.
+
+# ----- Try to cause a type error -----
+
+puts "\nI'm going to try and break the type system"
+
+if { [catch {
+ # Bad script!
+ Square_area $c # Try to invoke Square method on a Circle
+ puts " Bad bad SWIG!"
+
+}]} {
+ puts " Well, it didn't work. Good SWIG."
+}
+
+# ----- Delete everything -----
+
+puts "\nGuess I'll clean up now"
+
+# Note: this invokes the virtual destructor
+delete_Shape $c
+delete_Shape $s
+
+puts "$Shape_nshapes shapes remain"
+puts "Goodbye"
diff --git a/Tests/VSExternalInclude/CMakeLists.txt b/Tests/VSExternalInclude/CMakeLists.txt
index 7465243bd..8ca725249 100644
--- a/Tests/VSExternalInclude/CMakeLists.txt
+++ b/Tests/VSExternalInclude/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.6)
project(VSExternalInclude)
-if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[01245]")
+if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[012456]")
set(PROJECT_EXT vcxproj)
else()
set(PROJECT_EXT vcproj)
@@ -55,7 +55,7 @@ add_dependencies(VSExternalInclude lib2)
# and the sln file can no longer be the only source
# of that depend. So, for VS 10 make the executable
# depend on lib1 and lib2
-if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[01245]")
+if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[012456]")
add_dependencies(VSExternalInclude lib1)
endif()
diff --git a/Tests/VSExternalInclude/Lib2/lib2.cpp b/Tests/VSExternalInclude/Lib2/lib2.cpp
index adc2d29af..37180172b 100644
--- a/Tests/VSExternalInclude/Lib2/lib2.cpp
+++ b/Tests/VSExternalInclude/Lib2/lib2.cpp
@@ -1,5 +1,6 @@
#include "lib2.h"
+
#include "lib1.h"
int add1_and_mult2(int num)
diff --git a/Tests/VSGNUFortran/CMakeLists.txt b/Tests/VSGNUFortran/CMakeLists.txt
index 229c3156c..993d0d65f 100644
--- a/Tests/VSGNUFortran/CMakeLists.txt
+++ b/Tests/VSGNUFortran/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.9)
project(VSGNUFortran)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
@@ -9,7 +9,8 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
# because gmake build of fortran will not be in a config
# directory, and for easier testing we want the exe and .dll
# to be in the same directory.
-if(CMAKE_CONFIGURATION_TYPES)
+get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+if(_isMultiConfig)
foreach(config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${config}" config)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${config}
diff --git a/Tests/VSGNUFortran/runtest.cmake.in b/Tests/VSGNUFortran/runtest.cmake.in
index 987207bc4..fc05715d3 100644
--- a/Tests/VSGNUFortran/runtest.cmake.in
+++ b/Tests/VSGNUFortran/runtest.cmake.in
@@ -14,7 +14,7 @@ file(TO_NATIVE_PATH "${MINGW_PATH}" MINGW_PATH)
string(REPLACE "\\" "\\\\" MINGW_PATH "${MINGW_PATH}")
message("${MINGW_PATH}")
set(test_exe "@VSGNUFortran_BINARY_DIR@/bin/c_using_fortran.exe")
-set(ENV{PATH} "${MINGW_PATH}";$ENV{PATH})
+set(ENV{PATH} "${MINGW_PATH};$ENV{PATH}")
message("run ${test_exe}")
execute_process(COMMAND "${test_exe}"
RESULT_VARIABLE res)
diff --git a/Tests/VSMidl/src/main.cpp b/Tests/VSMidl/src/main.cpp
index 68089adc4..ae114fe09 100644
--- a/Tests/VSMidl/src/main.cpp
+++ b/Tests/VSMidl/src/main.cpp
@@ -1,6 +1,7 @@
+#include <test_i.c>
+
#include <stdio.h>
#include <test.h>
-#include <test_i.c>
int main(int argc, char** argv)
{
diff --git a/Tests/VSNASM/CMakeLists.txt b/Tests/VSNASM/CMakeLists.txt
index c2e29df25..821d0227e 100644
--- a/Tests/VSNASM/CMakeLists.txt
+++ b/Tests/VSNASM/CMakeLists.txt
@@ -1,10 +1,20 @@
cmake_minimum_required(VERSION 2.8.12)
project(VSNASM C ASM_NASM)
+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions(-DTESTx64)
string(APPEND CMAKE_ASM_NASM_FLAGS " -DTEST2x64")
else()
add_definitions(-DTESTi386)
endif()
+
+# Test quoting for definitions with spaces.
+add_definitions("-DEAX_COMMA_SPACE_ZERO=eax, 0")
+
+# Test quoting for file names with spaces. The file is generated because CMake
+# itself cannot have files with spaces.
+file(READ bar.asm BAR_ASM_CONTENTS)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/bar baz.asm" "${BAR_ASM_CONTENTS}")
+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
-add_executable(VSNASM main.c foo.asm)
+add_executable(VSNASM main.c foo.asm "${CMAKE_CURRENT_BINARY_DIR}/bar baz.asm")
diff --git a/Tests/VSNASM/bar.asm b/Tests/VSNASM/bar.asm
new file mode 100644
index 000000000..b486d82ae
--- /dev/null
+++ b/Tests/VSNASM/bar.asm
@@ -0,0 +1,13 @@
+section .text
+%ifdef TEST2x64
+global bar
+%else
+global _bar
+%endif
+%ifdef TESTx64
+bar:
+%else
+_bar:
+%endif
+ mov EAX_COMMA_SPACE_ZERO
+ ret
diff --git a/Tests/VSNASM/include/foo-proc.asm b/Tests/VSNASM/include/foo-proc.asm
index 450a7919b..eb5bb2b06 100644
--- a/Tests/VSNASM/include/foo-proc.asm
+++ b/Tests/VSNASM/include/foo-proc.asm
@@ -3,5 +3,5 @@ foo:
%else
_foo:
%endif
- mov eax, 0
+ mov EAX_COMMA_SPACE_ZERO
ret
diff --git a/Tests/VSNASM/main.c b/Tests/VSNASM/main.c
index 18ddb7826..b1401b698 100644
--- a/Tests/VSNASM/main.c
+++ b/Tests/VSNASM/main.c
@@ -1,5 +1,6 @@
extern int foo(void);
+extern int bar(void);
int main(void)
{
- return foo();
+ return foo() + bar();
}
diff --git a/Tests/VSNsightTegra/jni/second.c b/Tests/VSNsightTegra/jni/second.c
index 12fcdb6a9..30bdc17b0 100644
--- a/Tests/VSNsightTegra/jni/second.c
+++ b/Tests/VSNsightTegra/jni/second.c
@@ -14,9 +14,10 @@
* limitations under the License.
*
*/
-#include "first.h"
#include <jni.h>
+#include "first.h"
+
jint Java_com_example_twolibs_TwoLibs_add(JNIEnv* env, jobject this, jint x,
jint y)
{
diff --git a/Tests/VSResource/CMakeLists.txt b/Tests/VSResource/CMakeLists.txt
index 718e62441..fb47c7e13 100644
--- a/Tests/VSResource/CMakeLists.txt
+++ b/Tests/VSResource/CMakeLists.txt
@@ -56,3 +56,10 @@ endif()
set_property(TARGET VSResource
PROPERTY VS_GLOBAL_CMakeTestVsGlobalVariable "test val")
+
+if(CMAKE_GENERATOR MATCHES "Ninja|Visual Studio")
+ cmake_policy(PUSH)
+ cmake_policy(SET CMP0037 OLD)
+ add_library("My ResourceLib" lib.cpp lib.rc)
+ cmake_policy(POP)
+endif()
diff --git a/Tests/VSResource/main.cpp b/Tests/VSResource/main.cpp
index b2b5ac99c..6de7adc6e 100644
--- a/Tests/VSResource/main.cpp
+++ b/Tests/VSResource/main.cpp
@@ -1,6 +1,7 @@
-#include <stdio.h>
#include <windows.h>
+#include <stdio.h>
+
extern int lib();
struct x
diff --git a/Tests/VSWinStorePhone/CMakeLists.txt b/Tests/VSWinStorePhone/CMakeLists.txt
index 2b0c47806..b8e157dae 100644
--- a/Tests/VSWinStorePhone/CMakeLists.txt
+++ b/Tests/VSWinStorePhone/CMakeLists.txt
@@ -8,6 +8,9 @@ elseif(MSVC_VERSION GREATER 1600)
set(COMPILER_VERSION "11")
endif()
+add_subdirectory(WinRT)
+add_subdirectory(CxxDLL)
+
set (APP_MANIFEST_NAME Package.appxmanifest)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsPhone")
set(PLATFORM WP)
@@ -116,12 +119,14 @@ set_property(SOURCE ${RELEASE_CONTENT_FILES} PROPERTY
set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel)
set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainPS)
set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3)
-set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED /Fh \"$(OutDir)%(Filename).h\"")
+set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED")
+set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)%(Filename).h")
set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_TYPE Vertex)
set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainVS)
set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_MODEL 4.0_level_9_3)
-set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED /Fh \"$(OutDir)%(Filename).h\"")
+set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_FLAGS "/DFLAGS_ADDED")
+set_property(SOURCE ${VERTEXSHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)%(Filename).h")
source_group("Source Files" FILES ${SOURCE_FILES})
@@ -137,11 +142,14 @@ if("${SHORT_VERSION}" STREQUAL "10.0")
message(STATUS "Targeting Windows 10. Setting Extensions to version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
set_property(TARGET ${EXE_NAME} PROPERTY VS_DESKTOP_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
set_property(TARGET ${EXE_NAME} PROPERTY VS_MOBILE_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
- set_property(TARGET ${EXE_NAME} PROPERTY VS_IOT_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
+
+ # The last IOT reference is on 10.0.17134.0, so only add it if supported
+ if("${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}" VERSION_LESS "10.0.17135.0")
+ set_property(TARGET ${EXE_NAME} PROPERTY VS_IOT_EXTENSIONS_VERSION "${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
+ endif()
# Add a reference to an SDK
set_property(TARGET ${EXE_NAME} PROPERTY VS_SDK_REFERENCES "Microsoft.UniversalCRT.Debug, Version=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
endif()
-
-target_link_libraries(${EXE_NAME} d3d11)
+target_link_libraries(${EXE_NAME} d3d11 JusticeLeagueWinRT CxxDll)
diff --git a/Tests/VSWinStorePhone/CxxDLL/CMakeLists.txt b/Tests/VSWinStorePhone/CxxDLL/CMakeLists.txt
new file mode 100644
index 000000000..6bd32a20d
--- /dev/null
+++ b/Tests/VSWinStorePhone/CxxDLL/CMakeLists.txt
@@ -0,0 +1,3 @@
+project(CxxDll CXX)
+
+add_library(CxxDll SHARED cxxdll.cpp)
diff --git a/Tests/VSWinStorePhone/CxxDLL/cxxdll.cpp b/Tests/VSWinStorePhone/CxxDLL/cxxdll.cpp
new file mode 100644
index 000000000..1438e8a88
--- /dev/null
+++ b/Tests/VSWinStorePhone/CxxDLL/cxxdll.cpp
@@ -0,0 +1,8 @@
+#include "cxxdll.h"
+
+#include <iostream>
+
+void CxxDllClass::SomeMethod()
+{
+ std::cout << "CxxDllClass::SomeMethod\n";
+}
diff --git a/Tests/VSWinStorePhone/CxxDLL/cxxdll.h b/Tests/VSWinStorePhone/CxxDLL/cxxdll.h
new file mode 100644
index 000000000..86edceb63
--- /dev/null
+++ b/Tests/VSWinStorePhone/CxxDLL/cxxdll.h
@@ -0,0 +1,5 @@
+class __declspec(dllexport) CxxDllClass
+{
+public:
+ static void SomeMethod();
+};
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes b/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes
new file mode 100644
index 000000000..78a54694d
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/.gitattributes
@@ -0,0 +1 @@
+Direct3DApp1.cpp -format.clang-format-6.0
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png
index 7d95d4e08..c715e1bc7 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/ApplicationIcon.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png
index e26771cb3..65f91ac0f 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Logo.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png
index 1eb0d9d52..460c0222d 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png
index 28810b7c0..c2374581a 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SmallLogo44x44.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png
index c951e031b..834256580 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/SplashScreen.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png
index dcb672712..508c8a809 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/StoreLogo.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png
index e0c59ac01..fcdbaf4ac 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileLarge.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png
index e93b89d60..06425c4b1 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileMedium.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png
index 550b1b5e8..4cef0eb30 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/FlipCycleTileSmall.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png
index 686e6b53f..253503f04 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileMediumLarge.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png
index d4b5ede1b..2ef050fb3 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Assets/Tiles/IconicTileSmall.png
Binary files differ
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp
index 1c969cd2f..595f55392 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp
+++ b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp
@@ -1,16 +1,22 @@
+// clang-format off
#include "pch.h"
#include "CubeRenderer.h"
+// clang-format on
using namespace DirectX;
using namespace Microsoft::WRL;
using namespace Windows::Foundation;
using namespace Windows::UI::Core;
+using namespace JusticeLeagueWinRT;
CubeRenderer::CubeRenderer()
: m_loadingComplete(false)
, m_indexCount(0)
{
+ // Create a new WinRT object to validate that we can link properly
+ Batman ^ hero = ref new Batman();
+ hero->savePeople();
}
void CubeRenderer::CreateDeviceResources()
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h
index c3499c708..79b907006 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DApp1.h
@@ -1,8 +1,10 @@
#pragma once
+// clang-format off
#include "pch.h"
#include "CubeRenderer.h"
+// clang-format on
ref class Direct3DApp1 sealed
: public Windows::ApplicationModel::Core::IFrameworkView
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp
index 8f3452c06..f24ce28f1 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Direct3DBase.cpp
@@ -1,6 +1,8 @@
+// clang-format off
#include "pch.h"
#include "Direct3DBase.h"
+// clang-format on
using namespace DirectX;
using namespace Microsoft::WRL;
@@ -101,12 +103,12 @@ void Direct3DBase::CreateWindowSizeDependentResources()
#if WINVER > 0x0602
m_orientation = DisplayInformation::GetForCurrentView()->CurrentOrientation;
#else
-#if PHONE
+# if PHONE
// WP8 doesn't support rotations so always make it landscape
m_orientation = DisplayOrientations::Landscape;
-#else
+# else
m_orientation = DisplayProperties::CurrentOrientation;
-#endif
+# endif
#endif
bool swapDimensions = m_orientation == DisplayOrientations::Portrait ||
m_orientation == DisplayOrientations::PortraitFlipped;
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/pch.h b/Tests/VSWinStorePhone/Direct3DApp1/pch.h
index 78ebea347..d80cdb75a 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/pch.h
+++ b/Tests/VSWinStorePhone/Direct3DApp1/pch.h
@@ -1,7 +1,8 @@
#pragma once
+#include <memory>
+
#include <DirectXMath.h>
#include <agile.h>
#include <d3d11_1.h>
-#include <memory>
#include <wrl/client.h>
diff --git a/Tests/VSWinStorePhone/VerifyAppPackage.cmake b/Tests/VSWinStorePhone/VerifyAppPackage.cmake
new file mode 100644
index 000000000..f9440d75e
--- /dev/null
+++ b/Tests/VSWinStorePhone/VerifyAppPackage.cmake
@@ -0,0 +1,34 @@
+set(APP_PKG_NAME Direct3DApp1)
+
+# List of files that are expected to be present in the generated app package
+set(EXPECTED_APP_PKG_CONTENT
+ ${APP_PKG_NAME}.exe
+ CxxDll.dll
+ JusticeLeagueWinRT.winmd
+ JusticeLeagueWinRT.dll
+)
+
+# Windows app package formats can be either msix, appx or xap
+file(GLOB_RECURSE ALL_APP_PKG_FILES ${APP_PACKAGE_DIR} ${APP_PKG_NAME}*.msix ${APP_PKG_NAME}*.appx ${APP_PKG_NAME}*.xap)
+
+# There can be only one generated app package
+list(LENGTH ALL_APP_PKG_FILES APP_PKG_COUNT)
+if(NOT APP_PKG_COUNT EQUAL 1)
+ message(FATAL_ERROR "Expected 1 generated app package, but detected ${APP_PKG_COUNT}: ${ALL_APP_PKG_FILES}")
+endif()
+
+execute_process(COMMAND ${CMAKE_COMMAND} -E tar tf ${ALL_APP_PKG_FILES}
+ OUTPUT_VARIABLE APP_PKG_CONTENT_OUTPUT
+ ERROR_VARIABLE error
+ RESULT_VARIABLE result)
+
+if(NOT result EQUAL 0)
+ message(FATAL_ERROR "Listing app package content failed with: ${error}")
+endif()
+
+foreach(app_pkg_item ${EXPECTED_APP_PKG_CONTENT})
+ string(FIND ${APP_PKG_CONTENT_OUTPUT} ${app_pkg_item} _found)
+ if(_found EQUAL -1)
+ message(FATAL_ERROR "Generated app package is missing an expected item: ${app_pkg_item}")
+ endif()
+endforeach()
diff --git a/Tests/VSWinStorePhone/WinRT/Batman.cpp b/Tests/VSWinStorePhone/WinRT/Batman.cpp
new file mode 100644
index 000000000..e09225898
--- /dev/null
+++ b/Tests/VSWinStorePhone/WinRT/Batman.cpp
@@ -0,0 +1,14 @@
+#include "Batman.h"
+
+using namespace JusticeLeagueWinRT;
+using namespace Platform;
+
+Batman::Batman()
+{
+}
+
+void Batman::savePeople()
+{
+ int i = 0;
+ i++;
+}
diff --git a/Tests/VSWinStorePhone/WinRT/Batman.h b/Tests/VSWinStorePhone/WinRT/Batman.h
new file mode 100644
index 000000000..e2dcabc46
--- /dev/null
+++ b/Tests/VSWinStorePhone/WinRT/Batman.h
@@ -0,0 +1,12 @@
+#pragma once
+
+namespace JusticeLeagueWinRT {
+public
+ref class Batman sealed
+{
+public:
+ Batman();
+
+ void savePeople();
+};
+}
diff --git a/Tests/VSWinStorePhone/WinRT/CMakeLists.txt b/Tests/VSWinStorePhone/WinRT/CMakeLists.txt
new file mode 100644
index 000000000..bb9333360
--- /dev/null
+++ b/Tests/VSWinStorePhone/WinRT/CMakeLists.txt
@@ -0,0 +1,13 @@
+project(JusticeLeagueWinRT CXX)
+
+# create project
+add_library(JusticeLeagueWinRT SHARED
+ "${CMAKE_CURRENT_SOURCE_DIR}/Batman.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/Batman.h"
+)
+
+set_target_properties(JusticeLeagueWinRT PROPERTIES
+ VS_WINRT_COMPONENT TRUE
+ VS_GLOBAL_ROOTNAMESPACE "JusticeLeagueWinRT"
+ OUTPUT_NAME "JusticeLeagueWinRT"
+)
diff --git a/Tests/VSXaml/App.xaml.cpp b/Tests/VSXaml/App.xaml.cpp
index 549b7ef28..f9ae27e60 100644
--- a/Tests/VSXaml/App.xaml.cpp
+++ b/Tests/VSXaml/App.xaml.cpp
@@ -3,9 +3,8 @@
// Implementation of the App class.
//
-#include "pch.h"
-
#include "MainPage.xaml.h"
+#include "pch.h"
using namespace VSXaml;
diff --git a/Tests/VSXaml/Assets/Logo.scale-100.png b/Tests/VSXaml/Assets/Logo.scale-100.png
index e26771cb3..65f91ac0f 100644
--- a/Tests/VSXaml/Assets/Logo.scale-100.png
+++ b/Tests/VSXaml/Assets/Logo.scale-100.png
Binary files differ
diff --git a/Tests/VSXaml/Assets/SmallLogo.scale-100.png b/Tests/VSXaml/Assets/SmallLogo.scale-100.png
index 1eb0d9d52..460c0222d 100644
--- a/Tests/VSXaml/Assets/SmallLogo.scale-100.png
+++ b/Tests/VSXaml/Assets/SmallLogo.scale-100.png
Binary files differ
diff --git a/Tests/VSXaml/Assets/SplashScreen.scale-100.png b/Tests/VSXaml/Assets/SplashScreen.scale-100.png
index c951e031b..834256580 100644
--- a/Tests/VSXaml/Assets/SplashScreen.scale-100.png
+++ b/Tests/VSXaml/Assets/SplashScreen.scale-100.png
Binary files differ
diff --git a/Tests/VSXaml/Assets/StoreLogo.scale-100.png b/Tests/VSXaml/Assets/StoreLogo.scale-100.png
index dcb672712..508c8a809 100644
--- a/Tests/VSXaml/Assets/StoreLogo.scale-100.png
+++ b/Tests/VSXaml/Assets/StoreLogo.scale-100.png
Binary files differ
diff --git a/Tests/VSXaml/MainPage.xaml.cpp b/Tests/VSXaml/MainPage.xaml.cpp
index 51da23770..f372772d4 100644
--- a/Tests/VSXaml/MainPage.xaml.cpp
+++ b/Tests/VSXaml/MainPage.xaml.cpp
@@ -3,10 +3,10 @@
// Implementation of the MainPage class.
//
-#include "pch.h"
-
#include "MainPage.xaml.h"
+#include "pch.h"
+
using namespace VSXaml;
using namespace Platform;
diff --git a/Tests/WarnUnusedCliUnused/CMakeLists.txt b/Tests/WarnUnusedCliUnused/CMakeLists.txt
index 7ed69bf3c..a149f043f 100644
--- a/Tests/WarnUnusedCliUnused/CMakeLists.txt
+++ b/Tests/WarnUnusedCliUnused/CMakeLists.txt
@@ -1,9 +1,9 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.14)
project(WarnUnusedCliUnused)
-set_directory_properties(PROPERTIES
- ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_BINARY_DIR}/CMakeCache.txt"
-)
+# Remove UNUSED_CLI_VARIABLE from the cache to trigger the
+# CMake warning message on re-builds as well.
+unset(UNUSED_CLI_VARIABLE CACHE)
add_library(dummy empty.cpp)
diff --git a/Tests/Wrapping/fakefluid.cxx b/Tests/Wrapping/fakefluid.cxx
index a118bbd43..f5fb3fb25 100644
--- a/Tests/Wrapping/fakefluid.cxx
+++ b/Tests/Wrapping/fakefluid.cxx
@@ -6,9 +6,10 @@ int main(int ac, char** av)
if (strcmp(av[i], "-o") == 0 || strcmp(av[i], "-h") == 0) {
fprintf(stdout, "fakefluid is creating file \"%s\"\n", av[i + 1]);
FILE* file = fopen(av[i + 1], "w");
- fprintf(file, "// Solaris needs non-empty content so ensure\n"
- "// we have at least one symbol\n"
- "int Solaris_requires_a_symbol_here = 0;\n");
+ fprintf(file,
+ "// Solaris needs non-empty content so ensure\n"
+ "// we have at least one symbol\n"
+ "int Solaris_requires_a_symbol_here = 0;\n");
fclose(file);
}
}
diff --git a/Tests/Wrapping/qtwrappingmain.cxx b/Tests/Wrapping/qtwrappingmain.cxx
index 37234d900..d4951eef2 100644
--- a/Tests/Wrapping/qtwrappingmain.cxx
+++ b/Tests/Wrapping/qtwrappingmain.cxx
@@ -2,8 +2,8 @@
#include <qapplication.h>
#ifndef _WIN32
-#include <stdio.h>
-#include <stdlib.h>
+# include <stdio.h>
+# include <stdlib.h>
#endif
int main(int argc, char* argv[])
diff --git a/Tests/X11/HelloWorldX11.cxx b/Tests/X11/HelloWorldX11.cxx
index 0863f7bb7..f18f8c84e 100644
--- a/Tests/X11/HelloWorldX11.cxx
+++ b/Tests/X11/HelloWorldX11.cxx
@@ -11,15 +11,16 @@
*/
#ifndef MAIN_H
-#define MAIN_H 1
+# define MAIN_H 1
-#include <iostream>
-#include <stdlib.h>
+# include <iostream>
+
+# include <stdlib.h>
/* include the X library headers */
-#include <X11/Xlib.h>
-#include <X11/Xos.h>
-#include <X11/Xutil.h>
+# include <X11/Xlib.h>
+# include <X11/Xos.h>
+# include <X11/Xutil.h>
class Main
{
diff --git a/Tests/X11/X11.c b/Tests/X11/X11.c
index b802ed8b9..3a6f9f0b3 100644
--- a/Tests/X11/X11.c
+++ b/Tests/X11/X11.c
@@ -1,8 +1,8 @@
#include "stdio.h"
#ifdef CMAKE_HAS_X
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
+# include <X11/Xlib.h>
+# include <X11/Xutil.h>
int main()
{
diff --git a/Tests/XCTest/CMakeLists.txt b/Tests/XCTest/CMakeLists.txt
index d40c40e2a..d0b07ea1c 100644
--- a/Tests/XCTest/CMakeLists.txt
+++ b/Tests/XCTest/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.1)
-project(XCTest)
+project(XCTest C)
enable_testing()
find_package(XCTest REQUIRED)
diff --git a/Tests/bootstrap.bat.in b/Tests/bootstrap.bat.in
index aeb24b1ca..85e79ef00 100644
--- a/Tests/bootstrap.bat.in
+++ b/Tests/bootstrap.bat.in
@@ -1,2 +1,2 @@
-@echo off
-sh "@CMake_SOURCE_DIR@/bootstrap" %*
+@echo off
+sh "@CMake_SOURCE_DIR@/bootstrap" %*
diff --git a/Utilities/.gitattributes b/Utilities/.gitattributes
index bd978021b..81bbf2679 100644
--- a/Utilities/.gitattributes
+++ b/Utilities/.gitattributes
@@ -3,5 +3,6 @@
SetupForDevelopment.sh export-ignore
# Do not format third-party sources.
-/KWIML/** -format.clang-format
-/cm*/** -format.clang-format
+/KWIML/** -format.clang-format-6.0
+/cm*/** -format.clang-format-6.0
+/cmcurl/curltest.c format.clang-format-6.0
diff --git a/Utilities/Doxygen/CMakeLists.txt b/Utilities/Doxygen/CMakeLists.txt
index f1e8f95e7..5bf13f3c9 100644
--- a/Utilities/Doxygen/CMakeLists.txt
+++ b/Utilities/Doxygen/CMakeLists.txt
@@ -3,11 +3,11 @@
if(NOT CMake_SOURCE_DIR)
set(CMakeDeveloperReference_STANDALONE 1)
- cmake_minimum_required(VERSION 2.8.12.2 FATAL_ERROR)
+ cmake_minimum_required(VERSION 3.1...3.15 FATAL_ERROR)
get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH)
get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH)
include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake)
- include(${CMake_SOURCE_DIR}/Source/CMakeVersionCompute.cmake)
+ include(${CMake_SOURCE_DIR}/Source/CMakeVersion.cmake)
include(${CMake_SOURCE_DIR}/Source/CMakeInstallDestinations.cmake)
unset(CMAKE_DATA_DIR)
unset(CMAKE_DATA_DIR CACHE)
diff --git a/Utilities/GitSetup/config.sample b/Utilities/GitSetup/config.sample
deleted file mode 100644
index eeb468ba1..000000000
--- a/Utilities/GitSetup/config.sample
+++ /dev/null
@@ -1,32 +0,0 @@
-# Kitware Local Git Setup Scripts - Sample Project Configuration
-#
-# Copy to "config" and edit as necessary.
-
-[hooks]
- url = http://public.kitware.com/GitSetup.git
- #branch = hooks
-
-[ssh]
- host = public.kitware.com
- key = id_git_public
- request-url = https://www.kitware.com/Admin/SendPassword.cgi
-
-[stage]
- #url = git://public.kitware.com/stage/Project.git
- #pushurl = git@public.kitware.com:stage/Project.git
-
-[gerrit]
- #project = Project
- site = http://review.source.kitware.com
- # pushurl placeholder "$username" is literal
- pushurl = $username@review.source.kitware.com:Project
-
-[upstream]
- url = git://public.kitware.com/Project.git
-
-[gitlab]
- host = gitlab.kitware.com
- group-path = group
- group-name = Group
- project-path = project
- project-name = Project
diff --git a/Utilities/GitSetup/git-gerrit-push b/Utilities/GitSetup/git-gerrit-push
deleted file mode 100755
index b46f753eb..000000000
--- a/Utilities/GitSetup/git-gerrit-push
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env bash
-#=============================================================================
-# Copyright 2010-2015 Kitware, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#=============================================================================
-
-USAGE="[<remote>] [--no-topic] [--dry-run] [--]"
-OPTIONS_SPEC=
-SUBDIRECTORY_OK=Yes
-. "$(git --exec-path)/git-sh-setup"
-
-#-----------------------------------------------------------------------------
-
-remote=''
-refspecs=''
-no_topic=''
-dry_run=''
-
-# Parse the command line options.
-while test $# != 0; do
- case "$1" in
- --no-topic) no_topic=1 ;;
- --dry-run) dry_run=--dry-run ;;
- --) shift; break ;;
- -*) usage ;;
- *) test -z "$remote" || usage ; remote="$1" ;;
- esac
- shift
-done
-test $# = 0 || usage
-
-# Default remote.
-test -n "$remote" || remote="gerrit"
-
-if test -z "$no_topic"; then
- # Identify and validate the topic branch name.
- head="$(git symbolic-ref HEAD)" && topic="${head#refs/heads/}" || topic=''
- if test -z "$topic" -o "$topic" = "master"; then
- die 'Please name your topic:
- git checkout -b descriptive-name'
- fi
- # The topic branch will be pushed by name.
- refspecs="HEAD:refs/for/master/$topic $refspecs"
-fi
-
-# Fetch the current upstream master branch head.
-# This helps computation of a minimal pack to push.
-echo "Fetching $remote master"
-fetch_out=$(git fetch "$remote" master 2>&1) || die "$fetch_out"
-
-# Exit early if we have nothing to push.
-if test -z "$refspecs"; then
- echo 'Nothing to push!'
- exit 0
-fi
-
-# Push. Save output and exit code.
-echo "Pushing to $remote"
-push_stdout=$(git push --porcelain $dry_run "$remote" $refspecs); push_exit=$?
-echo "$push_stdout"
-
-# Reproduce the push exit code.
-exit $push_exit
diff --git a/Utilities/GitSetup/git-gitlab-push b/Utilities/GitSetup/git-gitlab-push
deleted file mode 100755
index 768f8534e..000000000
--- a/Utilities/GitSetup/git-gitlab-push
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/usr/bin/env bash
-#=============================================================================
-# Copyright 2010-2015 Kitware, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#=============================================================================
-
-USAGE='[<remote>] [<options>...] [--]
-
-OPTIONS
-
---dry-run
- Show what would be pushed without actually updating the destination
-
--f,--force
- Force-push the topic HEAD to rewrite the destination branch
-
---no-default
- Do not push the default branch (e.g. master)
-
---no-topic
- Do not push the topic HEAD.
-'
-OPTIONS_SPEC=
-SUBDIRECTORY_OK=Yes
-. "$(git --exec-path)/git-sh-setup"
-
-egrep-q() {
- egrep "$@" >/dev/null 2>/dev/null
-}
-
-# Load the project configuration.
-gitlab_upstream='' &&
-gitlab_configured='' &&
-config="${BASH_SOURCE%/*}/config" &&
-protocol=$(git config -f "$config" --get gitlab.protocol ||
- echo "https") &&
-host=$(git config -f "$config" --get gitlab.host) &&
-site=$(git config -f "$config" --get gitlab.site ||
- echo "$protocol://$host") &&
-group_path=$(git config -f "$config" --get gitlab.group-path) &&
-project_path=$(git config -f "$config" --get gitlab.project-path) &&
-gitlab_upstream="$site/$group_path/$project_path.git" &&
-gitlab_pushurl=$(git config --get remote.gitlab.pushurl ||
- git config --get remote.gitlab.url) &&
-gitlab_configured=1
-
-#-----------------------------------------------------------------------------
-
-remote=''
-refspecs=''
-force=''
-lease=false
-lease_flag=''
-no_topic=''
-no_default=''
-dry_run=''
-
-# Parse the command line options.
-while test $# != 0; do
- case "$1" in
- -f|--force) force='+'; lease=true ;;
- --no-topic) no_topic=1 ;;
- --dry-run) dry_run=--dry-run ;;
- --no-default) no_default=1 ;;
- --) shift; break ;;
- -*) usage ;;
- *) test -z "$remote" || usage ; remote="$1" ;;
- esac
- shift
-done
-test $# = 0 || usage
-
-# Default remote.
-test -n "$remote" || remote="gitlab"
-
-if test -z "$no_topic"; then
- # Identify and validate the topic branch name.
- head="$(git symbolic-ref HEAD)" && topic="${head#refs/heads/}" || topic=''
- if test -z "$topic" -o "$topic" = "master"; then
- die 'Please name your topic:
- git checkout -b descriptive-name'
- fi
-
- if $lease; then
- have_ref=false
- remoteref="refs/remotes/$remote/$topic"
- if git rev-parse --verify -q "$remoteref"; then
- have_ref=true
- else
- die "It seems that a local ref for the branch is
-missing; forcing a push is dangerous and may overwrite
-previous work. Fetch from the $remote remote first or
-push without '-f' or '--force'."
- fi
-
- have_lease_flag=false
- if git push -h | egrep-q -e '--force-with-lease'; then
- have_lease_flag=true
- fi
-
- if $have_lease_flag && $have_ref; then
- # Set the lease flag.
- lease_flag="--force-with-lease=$topic:$remoteref"
- # Clear the force string.
- force=''
- fi
- fi
-
- # The topic branch will be pushed by name.
- refspecs="${force}HEAD:refs/heads/$topic $refspecs"
-fi
-
-# Fetch the current remote master branch head.
-# This helps computation of a minimal pack to push.
-echo "Fetching $remote master"
-fetch_out=$(git fetch "$remote" master 2>&1) || die "$fetch_out"
-gitlab_head=$(git rev-parse FETCH_HEAD) || exit
-
-# Fetch the current upstream master branch head.
-if origin_fetchurl=$(git config --get remote.origin.url) &&
- test "$origin_fetchurl" = "$gitlab_upstream"; then
- upstream_remote='origin'
-else
- upstream_remote="$gitlab_upstream"
-fi
-echo "Fetching $upstream_remote master"
-fetch_out=$(git fetch "$upstream_remote" master 2>&1) || die "$fetch_out"
-upstream_head=$(git rev-parse FETCH_HEAD) || exit
-
-# Add a refspec to keep the remote master up to date if possible.
-if test -z "$no_default" &&
- base=$(git merge-base "$gitlab_head" "$upstream_head") &&
- test "$base" = "$gitlab_head"; then
- refspecs="$upstream_head:refs/heads/master $refspecs"
-fi
-
-# Exit early if we have nothing to push.
-if test -z "$refspecs"; then
- echo 'Nothing to push!'
- exit 0
-fi
-
-# Push. Save output and exit code.
-echo "Pushing to $remote"
-push_config='-c advice.pushUpdateRejected=false'
-push_stdout=$(git $push_config push $lease_flag --porcelain $dry_run "$remote" $refspecs); push_exit=$?
-echo "$push_stdout"
-
-if test "$push_exit" -ne 0 && test -z "$force"; then
- # Advise the user to fetch if needed.
- if echo "$push_stdout" | egrep-q 'stale info'; then
- echo "
-You have pushed to your branch from another machine; you may be overwriting
-commits unintentionally. Fetch from the $remote remote and check that you are
-not pushing an outdated branch."
- fi
-
- # Advise the user to force-push if needed.
- if echo "$push_stdout" | egrep-q 'non-fast-forward'; then
- echo '
-Add "-f" or "--force" to push a rewritten topic.'
- fi
-fi
-
-# Reproduce the push exit code.
-exit $push_exit
diff --git a/Utilities/GitSetup/setup-gerrit b/Utilities/GitSetup/setup-gerrit
deleted file mode 100755
index 6d46e3ccf..000000000
--- a/Utilities/GitSetup/setup-gerrit
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/usr/bin/env bash
-#=============================================================================
-# Copyright 2010-2012 Kitware, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#=============================================================================
-
-# Run this script to set up the local Git repository to push to
-# a Gerrit Code Review instance for this project.
-
-# Project configuration instructions:
-#
-# - Run a Gerrit Code Review server
-#
-# - Populate adjacent "config" file with:
-# gerrit.site = Top Gerrit URL (not project-specific)
-# gerrit.project = Name of project in Gerrit
-# gerrit.pushurl = Review site push URL with "$username" placeholder
-# gerrit.remote = Gerrit remote name, if not "gerrit"
-# gerrit.url = Gerrit project URL, if not "$site/p/$project"
-# optionally with "$username" placeholder
-
-die() {
- echo 1>&2 "$@" ; exit 1
-}
-
-# Make sure we are inside the repository.
-cd "${BASH_SOURCE%/*}" &&
-
-# Load the project configuration.
-site=$(git config -f config --get gerrit.site) &&
-project=$(git config -f config --get gerrit.project) &&
-remote=$(git config -f config --get gerrit.remote ||
- echo "gerrit") &&
-fetchurl_=$(git config -f config --get gerrit.url ||
- echo "$site/p/$project") &&
-pushurl_=$(git config -f config --get gerrit.pushurl ||
- git config -f config --get gerrit.url) ||
-die 'This project is not configured to use Gerrit.'
-
-# Get current gerrit push URL.
-pushurl=$(git config --get remote."$remote".pushurl ||
- git config --get remote."$remote".url || echo '') &&
-
-# Tell user about current configuration.
-if test -n "$pushurl"; then
- echo 'Remote "'"$remote"'" is currently configured to push to
-
- '"$pushurl"'
-' &&
- read -ep 'Reconfigure Gerrit? [y/N]: ' ans &&
- if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then
- setup=1
- else
- setup=''
- fi
-else
- echo 'Remote "'"$remote"'" is not yet configured.
-
-'"$project"' changes must be pushed to our Gerrit Code Review site:
-
- '"$site/p/$project"'
-
-Register a Gerrit account and select a username (used below).
-You will need an OpenID:
-
- http://openid.net/get-an-openid/
-' &&
- read -ep 'Configure Gerrit? [Y/n]: ' ans &&
- if [ "$ans" == "n" ] || [ "$ans" == "N" ]; then
- exit 0
- else
- setup=1
- fi
-fi &&
-
-# Perform setup if necessary.
-if test -n "$setup"; then
- echo 'Sign-in to Gerrit to get/set your username at
-
- '"$site"'/#/settings
-
-Add your SSH public keys at
-
- '"$site"'/#/settings/ssh-keys
-' &&
- read -ep "Gerrit username? [$USER]: " gu &&
- if test -z "$gu"; then
- gu="$USER"
- fi &&
- fetchurl="${fetchurl_/\$username/$gu}" &&
- if test -z "$pushurl"; then
- git remote add "$remote" "$fetchurl"
- else
- git config remote."$remote".url "$fetchurl"
- fi &&
- pushurl="${pushurl_/\$username/$gu}" &&
- if test "$pushurl" != "$fetchurl"; then
- git config remote."$remote".pushurl "$pushurl"
- fi &&
- echo 'Remote "'"$remote"'" is now configured to push to
-
- '"$pushurl"'
-'
-fi &&
-
-# Optionally test Gerrit access.
-if test -n "$pushurl"; then
- read -ep 'Test access to Gerrit (SSH)? [y/N]: ' ans &&
- if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then
- echo -n 'Testing Gerrit access by SSH...'
- if git ls-remote --heads "$pushurl" >/dev/null; then
- echo 'passed.'
- else
- echo 'failed.' &&
- die 'Could not access Gerrit. Add your SSH public keys at
-
- '"$site"'/#/settings/ssh-keys
-'
- fi
- fi
-fi &&
-
-# Set up GerritId hook.
-hook=$(git config --get hooks.GerritId || echo '') &&
-if test -z "$hook"; then
- echo '
-Enabling GerritId hook to add a "Change-Id" footer to commit
-messages for interaction with Gerrit. Run
-
- git config hooks.GerritId false
-
-to disable this feature (but you will be on your own).' &&
- git config hooks.GerritId true
-else
- echo 'GerritId hook already configured to "'"$hook"'".'
-fi
diff --git a/Utilities/GitSetup/setup-gitlab b/Utilities/GitSetup/setup-gitlab
deleted file mode 100755
index 9c7574d1e..000000000
--- a/Utilities/GitSetup/setup-gitlab
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/usr/bin/env bash
-#=============================================================================
-# Copyright 2010-2015 Kitware, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#=============================================================================
-
-# Run this script to set up the local Git repository to push to
-# a personal fork for this project in GitLab.
-
-# Project configuration instructions:
-#
-# - Run a GitLab server
-#
-# - Populate adjacent "config" file with:
-# gitlab.protocol = Top GitLab protocol, if not 'https'
-# gitlab.host = Top GitLab fully qualified host name
-# gitlab.site = Top GitLab URL, if not "<protocol>://<host>"
-# gitlab.group-name = Name of group containing project in GitLab
-# gitlab.group-path = Path of group containing project in GitLab
-# gitlab.project-name = Name of project within GitLab group
-# gitlab.project-path = Path of project within GitLab group
-# gitlab.url = GitLab push URL with "$username" placeholder,
-# if not "<site>/$username/<project-path>.git"
-# gitlab.pushurl = GitLab push URL with "$username" placeholder,
-# if not "git@<host>:$username/<project-path>.git"
-# gitlab.remote = GitLab remote name, if not "gitlab"
-
-die() {
- echo 1>&2 "$@" ; exit 1
-}
-
-# Make sure we are inside the repository.
-cd "${BASH_SOURCE%/*}" &&
-
-# Load the project configuration.
-protocol=$(git config -f config --get gitlab.protocol ||
- echo "https") &&
-host=$(git config -f config --get gitlab.host) &&
-site=$(git config -f config --get gitlab.site ||
- echo "$protocol://$host") &&
-group_path=$(git config -f config --get gitlab.group-path) &&
-group_name=$(git config -f config --get gitlab.group-name) &&
-project_name=$(git config -f config --get gitlab.project-name) &&
-project_path=$(git config -f config --get gitlab.project-path) &&
-pushurl_=$(git config -f config --get gitlab.pushurl ||
- echo "git@$host:\$username/$project_path.git") &&
-remote=$(git config -f config --get gitlab.remote ||
- echo "gitlab") &&
-fetchurl_=$(git config -f config --get gitlab.url ||
- echo "$site/\$username/$project_path.git") ||
-die 'This project is not configured to use GitLab.'
-
-# Get current gitlab push URL.
-pushurl=$(git config --get remote."$remote".pushurl ||
- git config --get remote."$remote".url || echo '') &&
-
-# Tell user about current configuration.
-if test -n "$pushurl"; then
- echo 'Remote "'"$remote"'" is currently configured to push to
-
- '"$pushurl"'
-' &&
- read -ep 'Reconfigure GitLab? [y/N]: ' ans &&
- if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then
- setup=1
- else
- setup=''
- fi
-else
- echo 'Remote "'"$remote"'" is not yet configured.
-' &&
- read -ep 'Configure GitLab to contribute to '"$project_name"'? [Y/n]: ' ans &&
- if [ "$ans" == "n" ] || [ "$ans" == "N" ]; then
- exit 0
- else
- setup=1
- fi
-fi &&
-
-setup_instructions='Add your SSH public keys at
-
- '"$site"'/profile/keys
-
-Then visit the main repository at:
-
- '"$site/$group_path/$project_path"'
-
-and use the Fork button in the upper right.
-'
-
-# Perform setup if necessary.
-if test -n "$setup"; then
- echo 'Sign-in to GitLab to get/set your username at
-
- '"$site/profile/account"'
-
-'"$setup_instructions" &&
- read -ep "GitLab username? [$USER]: " gu &&
- if test -z "$gu"; then
- gu="$USER"
- fi &&
- fetchurl="${fetchurl_/\$username/$gu}" &&
- if test -z "$pushurl"; then
- git remote add "$remote" "$fetchurl"
- else
- git config remote."$remote".url "$fetchurl"
- fi &&
- pushurl="${pushurl_/\$username/$gu}" &&
- git config remote."$remote".pushurl "$pushurl" &&
- echo 'Remote "'"$remote"'" is now configured to push to
-
- '"$pushurl"'
-'
-fi &&
-
-# Optionally test GitLab access.
-if test -n "$pushurl"; then
- read -ep 'Test access to GitLab (SSH)? [y/N]: ' ans &&
- if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then
- echo -n 'Testing GitLab access by SSH...'
- if git ls-remote --heads "$pushurl" >/dev/null; then
- echo 'passed.'
- else
- echo 'failed.' &&
- die 'Could not access your GitLab fork of this project.
-'"$setup_instructions"
- fi
- fi
-fi
diff --git a/Utilities/GitSetup/setup-hooks b/Utilities/GitSetup/setup-hooks
index ca07712d5..6a17b10e2 100755
--- a/Utilities/GitSetup/setup-hooks
+++ b/Utilities/GitSetup/setup-hooks
@@ -26,7 +26,7 @@
# hooks.url = Repository URL publishing "hooks" branch
# hooks.branch = Repository branch instead of "hooks"
-egrep-q() {
+egrep_q() {
egrep "$@" >/dev/null 2>/dev/null
}
@@ -42,7 +42,7 @@ if url=$(git config --get hooks.url); then
# Fetch hooks from locally configured repository.
branch=$(git config hooks.branch || echo hooks)
elif git for-each-ref refs/remotes/origin/hooks 2>/dev/null |
- egrep-q 'refs/remotes/origin/hooks$'; then
+ egrep_q 'refs/remotes/origin/hooks$'; then
# Use hooks cloned from origin.
url=.. && branch=remotes/origin/hooks
elif url=$(git config -f config --get hooks.url); then
diff --git a/Utilities/GitSetup/setup-ssh b/Utilities/GitSetup/setup-ssh
deleted file mode 100755
index 8920a5bd3..000000000
--- a/Utilities/GitSetup/setup-ssh
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/usr/bin/env bash
-#=============================================================================
-# Copyright 2010-2012 Kitware, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#=============================================================================
-
-# Run this script to set up ssh push access to the repository host.
-
-# Project configuration instructions:
-#
-# - Populate adjacent "config" file with:
-# ssh.host = Repository host name
-# ssh.user = Username on host, if not "git"
-# ssh.key = Local ssh key name
-# ssh.request-url = Web page URL to request ssh access
-
-egrep-q() {
- egrep "$@" >/dev/null 2>/dev/null
-}
-
-die() {
- echo 1>&2 "$@" ; exit 1
-}
-
-# Make sure we are inside the repository.
-cd "${BASH_SOURCE%/*}" &&
-
-# Load the project configuration.
-host=$(git config -f config --get ssh.host) &&
-user=$(git config -f config --get ssh.user || echo git) &&
-key=$(git config -f config --get ssh.key) &&
-request_url=$(git config -f config --get ssh.request-url) ||
-die 'This project is not configured for ssh push access.'
-
-# Check for existing configuration.
-if test -r ~/.ssh/config &&
- egrep-q 'Host[= ]'"${host//\./\\.}" ~/.ssh/config; then
- echo 'Host "'"$host"'" is already in ~/.ssh/config' &&
- setup= &&
- question='Test'
-else
- echo 'Host "'"$host"'" not found in ~/.ssh/config' &&
- setup=1 &&
- question='Setup and test'
-fi &&
-
-# Ask the user whether to make changes.
-echo '' &&
-read -ep "${question} push access by ssh to $user@$host? [y/N]: " access &&
-if test "$access" != "y" -a "$access" != "Y"; then
- exit 0
-fi &&
-
-# Setup host configuration if necessary.
-if test -n "$setup"; then
- if ! test -d ~/.ssh; then
- mkdir -p ~/.ssh &&
- chmod 700 ~/.ssh
- fi &&
- if ! test -f ~/.ssh/config; then
- touch ~/.ssh/config &&
- chmod 600 ~/.ssh/config
- fi &&
- ssh_config='Host='"$host"'
- IdentityFile ~/.ssh/'"$key" &&
- echo "Adding to ~/.ssh/config:
-
-$ssh_config
-" &&
- echo "$ssh_config" >> ~/.ssh/config &&
- if ! test -e ~/.ssh/"$key"; then
- if test -f ~/.ssh/id_rsa; then
- # Take care of the common case.
- ln -s id_rsa ~/.ssh/"$key"
- echo '
-Assuming ~/.ssh/id_rsa is the private key corresponding to the public key for
-
- '"$user@$host"'
-
-If this is incorrect place private key at "~/.ssh/'"$key"'".'
- else
- echo '
-Place the private key corresponding to the public key registered for
-
- '"$user@$host"'
-
-at "~/.ssh/'"$key"'".'
- fi
- read -e -n 1 -p 'Press any key to continue...'
- fi
-fi || exit 1
-
-# Test access configuration.
-echo 'Testing ssh push access to "'"$user@$host"'"...' &&
-if ! ssh "$user@$host" info; then
- die 'No ssh push access to "'"$user@$host"'". You may need to request access at
-
- '"$request_url"'
-'
-fi
diff --git a/Utilities/GitSetup/setup-stage b/Utilities/GitSetup/setup-stage
deleted file mode 100755
index ce6ec4574..000000000
--- a/Utilities/GitSetup/setup-stage
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env bash
-#=============================================================================
-# Copyright 2010-2012 Kitware, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#=============================================================================
-
-# Run this script to set up the topic stage for pushing changes.
-
-# Project configuration instructions:
-#
-# - Run a Topic Stage repository next to the main project repository.
-#
-# - Populate adjacent "config" file with:
-# stage.url = Topic Stage repository URL
-# stage.pushurl = Topic Stage push URL if not "$url"
-
-egrep-q() {
- egrep "$@" >/dev/null 2>/dev/null
-}
-
-die() {
- echo 1>&2 "$@" ; exit 1
-}
-
-# Make sure we are inside the repository.
-cd "${BASH_SOURCE%/*}" &&
-
-# Load the project configuration.
-fetchurl_=$(git config -f config --get stage.url) &&
-pushurl_=$(git config -f config --get stage.pushurl || echo "$fetchurl_") &&
-remote=$(git config -f config --get stage.remote || echo 'stage') ||
-die 'This project is not configured to use a topic stage.'
-
-# Get current stage push URL.
-pushurl=$(git config --get remote."$remote".pushurl ||
- git config --get remote."$remote".url || echo '') &&
-
-# Tell user about current configuration.
-if test -n "$pushurl"; then
- echo 'Remote "'"$remote"'" is currently configured to push to
-
- '"$pushurl"'
-' &&
- read -ep 'Reconfigure Topic Stage? [y/N]: ' ans &&
- if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then
- setup=1
- else
- setup=''
- fi
-else
- setup=1
-fi
-
-# Perform setup if necessary.
-if test -n "$setup"; then
- echo 'Setting up the topic stage...' &&
- fetchurl="${fetchurl_}" &&
- if test -z "$pushurl"; then
- git remote add "$remote" "$fetchurl"
- else
- git config remote."$remote".url "$fetchurl"
- fi &&
- pushurl="${pushurl_}" &&
- if test "$pushurl" != "$fetchurl"; then
- git config remote."$remote".pushurl "$pushurl"
- fi &&
- echo 'Remote "'"$remote"'" is now configured to push to
-
- '"$pushurl"'
-'
-fi || die 'Could not configure the topic stage remote.'
diff --git a/Utilities/GitSetup/setup-upstream b/Utilities/GitSetup/setup-upstream
deleted file mode 100755
index 92ce1dae5..000000000
--- a/Utilities/GitSetup/setup-upstream
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/env bash
-#=============================================================================
-# Copyright 2010-2015 Kitware, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#=============================================================================
-
-# Run this script to set up the local Git repository to use the
-# preferred upstream repository URLs.
-
-# Project configuration instructions:
-#
-# - Populate adjacent "config" file with:
-# upstream.url = Preferred fetch url for upstream remote
-# upstream.remote = Preferred name for upstream remote, if not "origin"
-
-die() {
- echo 1>&2 "$@" ; exit 1
-}
-
-# Make sure we are inside the repository.
-cd "${BASH_SOURCE%/*}" &&
-
-# Load the project configuration.
-url=$(git config -f config --get upstream.url) &&
-remote=$(git config -f config --get upstream.remote ||
- echo 'origin') ||
-die 'This project is not configured to use a preferred upstream repository.'
-
-# Get current upstream URLs.
-fetchurl=$(git config --get remote."$remote".url || echo '') &&
-pushurl=$(git config --get remote."$remote".pushurl || echo '') &&
-
-if test "$fetchurl" = "$url"; then
- echo 'Remote "'"$remote"'" already uses recommended upstream repository.'
- exit 0
-fi
-
-upstream_recommend='
-We recommended configuring the "'"$remote"'" remote to fetch from upstream at
-
- '"$url"'
-'
-
-# Tell user about current configuration.
-if test -n "$fetchurl"; then
- echo 'Remote "'"$remote"'" is currently configured to fetch from
-
- '"$fetchurl"'
-' &&
- if test -n "$pushurl"; then
- echo 'and push to
-
- '"$pushurl"
- fi &&
- echo "$upstream_recommend" &&
- if test -n "$pushurl"; then
- echo 'and to never push to it directly.
-'
- fi &&
-
- read -ep 'Reconfigure "'"$remote"'" remote as recommended? [y/N]: ' ans &&
- if [ "$ans" == "y" ] || [ "$ans" == "Y" ]; then
- setup=1
- else
- setup=''
- fi
-else
- echo 'Remote "'"$remote"'" is not yet configured.' &&
- echo "$upstream_recommend" &&
- read -ep 'Configure "'"$remote"'" remote as recommended? [Y/n]: ' ans &&
- if [ "$ans" == "n" ] || [ "$ans" == "N" ]; then
- exit 0
- else
- setup=1
- fi
-fi &&
-
-# Perform setup if necessary.
-if test -n "$setup"; then
- if test -z "$fetchurl"; then
- git remote add "$remote" "$url"
- else
- git config remote."$remote".url "$url" &&
- if old=$(git config --get remote."$remote".pushurl); then
- git config --unset remote."$remote".pushurl ||
- echo 'Warning: failed to unset remote.'"$remote"'.pushurl'
- fi
- fi &&
- echo 'Remote "'"$remote"'" is now configured to fetch from
-
- '"$url"'
-'
-fi
diff --git a/Utilities/GitSetup/tips b/Utilities/GitSetup/tips
index 784e1ed89..f47d84cf5 100755
--- a/Utilities/GitSetup/tips
+++ b/Utilities/GitSetup/tips
@@ -19,7 +19,7 @@
# Project configuration instructions: NONE
-egrep-q() {
+egrep_q() {
egrep "$@" >/dev/null 2>/dev/null
}
@@ -33,7 +33,7 @@ One may enable color output from Git commands with
fi
# Suggest bash completion.
-if ! bash -i -c 'echo $PS1' | egrep-q '__git_ps1'; then
+if ! bash -i -c 'echo $PS1' | egrep_q '__git_ps1'; then
echo '
A dynamic, informative Git shell prompt can be obtained by sourcing
the git bash-completion script in your "~/.bashrc". Set the PS1
diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp
index fe0f7df71..ef31e8bef 100644
--- a/Utilities/IWYU/mapping.imp
+++ b/Utilities/IWYU/mapping.imp
@@ -21,9 +21,14 @@
{ include: [ "<wctype.h>", public, "<cwctype>", public ] },
# HACK: check whether this can be removed with next iwyu release.
+ { include: [ "<bits/shared_ptr.h>", private, "<memory>", public ] },
{ include: [ "<bits/std_function.h>", private, "<functional>", public ] },
+ { include: [ "<bits/refwrap.h>", private, "<functional>", public ] },
+ { include: [ "<bits/stdint-intn.h>", private, "<stdint.h>", public ] },
+ { include: [ "<bits/stdint-uintn.h>", private, "<stdint.h>", public ] },
{ include: [ "<bits/time.h>", private, "<time.h>", public ] },
{ include: [ "<bits/types/clock_t.h>", private, "<time.h>", public ] },
+ { include: [ "<bits/types/mbstate_t.h>", private, "<wchar.h>", public ] },
{ include: [ "<bits/types/struct_timespec.h>", private, "<time.h>", public ] },
{ include: [ "<bits/types/struct_timeval.h>", private, "<time.h>", public ] },
{ include: [ "<bits/types/struct_tm.h>", private, "<time.h>", public ] },
@@ -38,63 +43,60 @@
{ symbol: [ "std::istringstream", private, "<sstream>", public ] },
{ symbol: [ "std::ostringstream", private, "<sstream>", public ] },
- # HACK: iwyu suggests those two files each time vector[] is used.
+ # HACK: iwyu suggests <ext/alloc_traits.h> and <memory> each time vector[] is used.
# https://github.com/include-what-you-use/include-what-you-use/issues/166
{ include: [ "<ext/alloc_traits.h>", private, "<vector>", public ] },
- { include: [ "<memory>", public, "<vector>", public ] },
+ { symbol: [ "std::allocator_traits<std::allocator<cmComputeComponentGraph::TarjanEntry> >::value_type", private, "<vector>", public ] },
+ { symbol: [ "std::allocator_traits<std::allocator<cmFortranFile> >::value_type", private, "<vector>", public ] },
+ { symbol: [ "std::allocator_traits<std::allocator<cmGraphEdgeList> >::value_type", private, "<vector>", public ] },
+ { symbol: [ "std::allocator_traits<std::allocator<cmOrderDirectories::ConflictList> >::value_type", private, "<vector>", public ] },
+ { symbol: [ "std::allocator_traits<std::allocator<cmStateSnapshot> >::value_type", private, "<vector>", public ] },
+ { symbol: [ "std::allocator_traits<std::allocator<std::basic_string<char> > >::value_type", private, "<vector>", public ] },
+ { symbol: [ "std::allocator_traits<std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::value_type", private, "<vector>", public ] },
+ { symbol: [ "std::allocator_traits<std::allocator<std::vector<std::basic_string<char>, std::allocator<std::basic_string<char> > > > >::value_type", private, "<vector>", public ] },
+ { symbol: [ "std::allocator_traits<std::allocator<std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > >::value_type", private, "<vector>", public ] },
+ { symbol: [ "std::allocator_traits<std::allocator<uv_stdio_container_s> >::value_type", private, "<vector>", public ] },
# TODO: enable this block and remove some <utility> includes?
#{ symbol: [ "std::pair", private, "<utility>", public ] },
#{ symbol: [ "std::pair", private, "<map>", public ] },
#{ symbol: [ "std::pair", private, "<set>", public ] },
- # IWYU wrongly suggests to include "cm_auto_ptr.hxx" in some places. This
- # might be a misinterpretation of a template specialization in <utility>.
- # As a workaround, map the symbol auto_ptr to "cmConfigure.h".
- # This will still correctly require "cm_auto_ptr.hxx" for CM_AUTO_PTR.
- { symbol: [ "cm::auto_ptr", private, "\"cmConfigure.h\"", public ] },
+ # HACK: iwyu wrongly thinks that <system_error> is needed for std::hash
+ { symbol: [ "std::hash", private, "<functional>", public ] },
+
+ # HACK: iwyu thinks we use a libstdc++ private type
+ { symbol: [ "__gnu_cxx::size_t", private, "<cstddef>", public ] },
# __decay_and_strip is used internally in the C++11 standard library.
# IWYU does not classify it as internal and suggests to add <type_traits>.
# To ignore it, we simply map it to a file that is included anyway.
+ # Use '-Xiwyu -v7' to see the fully qualified names that need this.
# TODO: Can this be simplified with an @-expression?
#{ symbol: [ "@std::__decay_and_strip<.*>::__type", private, "\"cmConfigure.h\"", public ] },
+ { symbol: [ "std::__decay_and_strip<char const (&)[1]>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__decay_and_strip<cmCommand *&>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__decay_and_strip<cmGeneratorTarget *&>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__decay_and_strip<cmFindCommon::PathLabel &>::__type", private, "\"cmConfigure.h\"", public ] },
+ { symbol: [ "std::__decay_and_strip<cmSearchPath>::__type", private, "\"cmConfigure.h\"", public ] },
+ { symbol: [ "std::__decay_and_strip<cm::string_view>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__decay_and_strip<std::basic_string<char> &>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__decay_and_strip<const std::basic_string<char> &>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__decay_and_strip<cmFindPackageCommand::PathLabel &>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__decay_and_strip<__gnu_cxx::__normal_iterator<const cmCTestTestHandler::cmCTestTestProperties *, std::vector<cmCTestTestHandler::cmCTestTestProperties, std::allocator<cmCTestTestHandler::cmCTestTestProperties> > > &>::__type", private, "\"cmConfigure.h\"", public ] },
-
- # Wrappers for headers added in TR1 / C++11
- # { include: [ "<array>", public, "\"cm_array.hxx\"", public ] },
- # { include: [ "<functional>", public, "\"cm_functional.hxx\"", public ] },
- # { include: [ "<memory>", public, "\"cm_memory.hxx\"", public ] },
- { include: [ "<unordered_map>", public, "\"cm_unordered_map.hxx\"", public ] },
- { include: [ "<unordered_set>", public, "\"cm_unordered_set.hxx\"", public ] },
- # { include: [ "<tr1/array>", public, "\"cm_array.hxx\"", public ] },
- # { include: [ "<tr1/functional>", public, "\"cm_functional.hxx\"", public ] },
- # { include: [ "<tr1/memory>", public, "\"cm_memory.hxx\"", public ] },
- { include: [ "<tr1/unordered_map>", public, "\"cm_unordered_map.hxx\"", public ] },
- { include: [ "<tr1/unordered_set>", public, "\"cm_unordered_set.hxx\"", public ] },
+ { symbol: [ "std::__success_type<std::chrono::duration<double, std::ratio<1, 1> > >::type", private, "\"cmConfigure.h\"", public ] },
+ { symbol: [ "std::__success_type<std::chrono::duration<long, std::ratio<1, 1000000000> > >::type", private, "\"cmConfigure.h\"", public ] },
+ { symbol: [ "std::enable_if<true, std::chrono::duration<long, std::ratio<1, 1> > >::type", private, "\"cmConfigure.h\"", public ] },
+ { symbol: [ "std::enable_if<true, std::chrono::duration<long, std::ratio<60, 1> > >::type", private, "\"cmConfigure.h\"", public ] },
+ { symbol: [ "std::enable_if<true, std::chrono::duration<long, std::ratio<1, 1000> > >::type", private, "\"cmConfigure.h\"", public ] },
# KWIML
{ include: [ "<stdint.h>", public, "\"cm_kwiml.h\"", public ] },
{ include: [ "<inttypes.h>", public, "\"cm_kwiml.h\"", public ] },
# Self-sufficient wrapper for <sys/stat.h>
- { include: [ "<sys/stat.h>", public, "\"cm_sys_stat.h\"", public ] },
{ symbol: [ "mode_t", private, "\"cm_sys_stat.h\"", public ] },
- # TODO: remove once TR1 / C++11 is required.
- { include: [ "\"cmsys/hash_fun.hxx\"", private, "\"cm_unordered_map.hxx\"", public ] },
- { include: [ "\"cmsys/hash_fun.hxx\"", private, "\"cm_unordered_set.hxx\"", public ] },
- { include: [ "\"cmsys/hash_map.hxx\"", private, "\"cm_unordered_map.hxx\"", public ] },
- { include: [ "\"cmsys/hash_set.hxx\"", private, "\"cm_unordered_set.hxx\"", public ] },
- { include: [ "\"cmsys/hashtable.hxx\"", private, "\"cm_unordered_map.hxx\"", public ] },
- { include: [ "\"cmsys/hashtable.hxx\"", private, "\"cm_unordered_set.hxx\"", public ] },
-
# Wrappers for 3rd-party libraries used from the system.
{ include: [ "<archive.h>", private, "\"cm_libarchive.h\"", public ] },
{ include: [ "<archive_entry.h>", private, "\"cm_libarchive.h\"", public ] },
@@ -106,12 +108,9 @@
{ include: [ "<json/writer.h>", private, "\"cm_jsoncpp_writer.h\"", public ] },
{ include: [ "<rhash.h>", private, "\"cm_rhash.h\"", public ] },
{ include: [ "<uv.h>", private, "\"cm_uv.h\"", public ] },
- { include: [ "@<uv-.+\\.h>", private, "\"cm_uv.h\"", public ] },
+ { include: [ "@<uv[/-].+\\.h>", private, "\"cm_uv.h\"", public ] },
{ include: [ "<kwiml/abi.h>", private, "\"cm_kwiml.h\"", public ] },
{ include: [ "<kwiml/int.h>", private, "\"cm_kwiml.h\"", public ] },
- { include: [ "<xmlrpc.h>", private, "\"cm_xmlrpc.h\"", public ] },
- { include: [ "<xmlrpc_client.h>", private, "\"cm_xmlrpc.h\"", public ] },
- { include: [ "@<xmlrpc-c/.+\\.h>", private, "\"cm_xmlrpc.h\"", public ] },
{ include: [ "<zconf.h>", private, "\"cm_zlib.h\"", public ] },
{ include: [ "<zlib.h>", private, "\"cm_zlib.h\"", public ] },
@@ -126,7 +125,7 @@
{ include: [ "\"cmjsoncpp/include/json/writer.h\"", private, "\"cm_jsoncpp_writer.h\"", public ] },
{ include: [ "\"cmlibrhash/librhash/rhash.h\"", private, "\"cm_rhash.h\"", public ] },
{ include: [ "\"cmlibuv/include/uv.h\"", private, "\"cm_uv.h\"", public ] },
- { include: [ "@\"cmlibuv/include/uv-.+\\.h\"", private, "\"cm_uv.h\"", public ] },
+ { include: [ "@\"cmlibuv/include/uv/.+\\.h\"", private, "\"cm_uv.h\"", public ] },
{ include: [ "\"KWIML/include/kwiml/abi.h\"", private, "\"cm_kwiml.h\"", public ] },
{ include: [ "\"KWIML/include/kwiml/int.h\"", private, "\"cm_kwiml.h\"", public ] },
{ include: [ "\"cmzlib/cm_zlib_mangle.h\"", private, "\"cm_zlib.h\"", public ] },
@@ -138,6 +137,8 @@
{ symbol: [ "SIGINT", private, "\"cm_uv.h\"", public ] },
{ symbol: [ "ssize_t", private, "\"cm_uv.h\"", public ] },
+ { symbol: [ "Json::ArrayIndex", private, "\"cm_jsoncpp_value.h\"", public ] },
+
{ symbol: [ "std::ifstream", private, "\"cmsys/FStream.hxx\"", public ] },
{ symbol: [ "std::ofstream", private, "\"cmsys/FStream.hxx\"", public ] },
{ symbol: [ "cmsys::ifstream", private, "\"cmsys/FStream.hxx\"", public ] },
diff --git a/Utilities/KWIML/Copyright.txt b/Utilities/KWIML/Copyright.txt
index 515c4ebc4..fffd6d13e 100644
--- a/Utilities/KWIML/Copyright.txt
+++ b/Utilities/KWIML/Copyright.txt
@@ -1,5 +1,5 @@
Kitware Information Macro Library
-Copyright 2010-2016 Kitware, Inc.
+Copyright 2010-2018 Kitware, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/Utilities/KWIML/include/kwiml/abi.h b/Utilities/KWIML/include/kwiml/abi.h
index 5ffd542cf..da525fdcb 100644
--- a/Utilities/KWIML/include/kwiml/abi.h
+++ b/Utilities/KWIML/include/kwiml/abi.h
@@ -1,6 +1,6 @@
/*============================================================================
Kitware Information Macro Library
- Copyright 2010-2016 Kitware, Inc.
+ Copyright 2010-2018 Kitware, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -468,7 +468,7 @@ suppression macro KWIML_ABI_NO_VERIFY was defined.
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
/* RISC-V */
-#elif defined(__riscv__)
+#elif defined(__riscv) || defined(__riscv__)
# define KWIML_ABI_ENDIAN_ID KWIML_ABI_ENDIAN_ID_LITTLE
/* Unknown CPU */
@@ -484,9 +484,16 @@ suppression macro KWIML_ABI_NO_VERIFY was defined.
#if defined(_MSC_VER)
# pragma warning (push)
+# pragma warning (disable:4309) /* static_cast trunction of constant value */
# pragma warning (disable:4310) /* cast truncates constant value */
#endif
+#if defined(__cplusplus) && !defined(__BORLANDC__)
+#define KWIML_ABI_private_STATIC_CAST(t,v) static_cast<t>(v)
+#else
+#define KWIML_ABI_private_STATIC_CAST(t,v) (t)(v)
+#endif
+
#define KWIML_ABI_private_VERIFY(n, x, y) KWIML_ABI_private_VERIFY_0(KWIML_ABI_private_VERSION, n, x, y)
#define KWIML_ABI_private_VERIFY_0(V, n, x, y) KWIML_ABI_private_VERIFY_1(V, n, x, y)
#define KWIML_ABI_private_VERIFY_1(V, n, x, y) extern int (*n##_v##V)[x]; extern int (*n##_v##V)[y]
@@ -535,9 +542,11 @@ KWIML_ABI_private_VERIFY_DIFF(KWIML_ABI___INT64_NOT_LONG_LONG, __int64, long lon
#endif
#if defined(KWIML_ABI_CHAR_IS_UNSIGNED)
-KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_UNSIGNED, (char)0x80 > 0);
+KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_UNSIGNED,
+ KWIML_ABI_private_STATIC_CAST(char, 0x80) > 0);
#elif defined(KWIML_ABI_CHAR_IS_SIGNED)
-KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_SIGNED, (char)0x80 < 0);
+KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_SIGNED,
+ KWIML_ABI_private_STATIC_CAST(char, 0x80) < 0);
#endif
#undef KWIML_ABI_private_VERIFY_DIFF
@@ -557,6 +566,8 @@ KWIML_ABI_private_VERIFY_BOOL(KWIML_ABI_CHAR_IS_SIGNED, (char)0x80 < 0);
#undef KWIML_ABI_private_VERIFY_0
#undef KWIML_ABI_private_VERIFY
+#undef KWIML_ABI_private_STATIC_CAST
+
#if defined(_MSC_VER)
# pragma warning (pop)
#endif
diff --git a/Utilities/KWIML/include/kwiml/int.h b/Utilities/KWIML/include/kwiml/int.h
index 489c60325..b2e14d5f2 100644
--- a/Utilities/KWIML/include/kwiml/int.h
+++ b/Utilities/KWIML/include/kwiml/int.h
@@ -1,6 +1,6 @@
/*============================================================================
Kitware Information Macro Library
- Copyright 2010-2016 Kitware, Inc.
+ Copyright 2010-2018 Kitware, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -1003,16 +1003,25 @@ An includer may test the following macros after inclusion:
#if defined(_MSC_VER)
# pragma warning (push)
+# pragma warning (disable:4309) /* static_cast trunction of constant value */
# pragma warning (disable:4310) /* cast truncates constant value */
#endif
+#if defined(__cplusplus) && !defined(__BORLANDC__)
+#define KWIML_INT_private_STATIC_CAST(t,v) static_cast<t>(v)
+#else
+#define KWIML_INT_private_STATIC_CAST(t,v) (t)(v)
+#endif
+
#define KWIML_INT_private_VERIFY(n, x, y) KWIML_INT_private_VERIFY_0(KWIML_INT_private_VERSION, n, x, y)
#define KWIML_INT_private_VERIFY_0(V, n, x, y) KWIML_INT_private_VERIFY_1(V, n, x, y)
#define KWIML_INT_private_VERIFY_1(V, n, x, y) extern int (*n##_v##V)[x]; extern int (*n##_v##V)[y]
#define KWIML_INT_private_VERIFY_BOOL(m, b) KWIML_INT_private_VERIFY(KWIML_INT_detail_VERIFY_##m, 2, (b)?2:3)
#define KWIML_INT_private_VERIFY_TYPE(t, s) KWIML_INT_private_VERIFY(KWIML_INT_detail_VERIFY_##t, s, sizeof(t))
-#define KWIML_INT_private_VERIFY_SIGN(t, u, o) KWIML_INT_private_VERIFY_BOOL(SIGN_##t, (t)((u)1 << ((sizeof(t)<<3)-1)) o 0)
+#define KWIML_INT_private_VERIFY_SIGN(t, u, o) \
+ KWIML_INT_private_VERIFY_BOOL(SIGN_##t, KWIML_INT_private_STATIC_CAST( \
+ t, KWIML_INT_private_STATIC_CAST(u, 1) << ((sizeof(t)<<3)-1)) o 0)
KWIML_INT_private_VERIFY_TYPE(KWIML_INT_int8_t, 1);
KWIML_INT_private_VERIFY_TYPE(KWIML_INT_uint8_t, 1);
@@ -1060,6 +1069,8 @@ KWIML_INT_private_VERIFY_SIGN(KWIML_INT_uintptr_t, KWIML_INT_uintptr_t, >);
#undef KWIML_INT_private_VERIFY_0
#undef KWIML_INT_private_VERIFY
+#undef KWIML_INT_private_STATIC_CAST
+
#if defined(_MSC_VER)
# pragma warning (pop)
#endif
diff --git a/Utilities/KWIML/src/version.h.in b/Utilities/KWIML/src/version.h.in
index 0ac8854f2..5c566bb2e 100644
--- a/Utilities/KWIML/src/version.h.in
+++ b/Utilities/KWIML/src/version.h.in
@@ -1,6 +1,6 @@
/*============================================================================
Kitware Information Macro Library
- Copyright 2010-2016 Kitware, Inc.
+ Copyright 2010-2018 Kitware, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/Utilities/KWIML/test/test_int_format.h b/Utilities/KWIML/test/test_int_format.h
index 24dcdfba6..2e0310ce4 100644
--- a/Utilities/KWIML/test/test_int_format.h
+++ b/Utilities/KWIML/test/test_int_format.h
@@ -8,6 +8,7 @@
#if defined(_MSC_VER)
# pragma warning (push)
+# pragma warning (disable:4309) /* static_cast trunction of constant value */
# pragma warning (disable:4310) /* cast truncates constant value */
#endif
@@ -17,7 +18,13 @@
# define LANG "C "
#endif
-#define VALUE(T, U) (T)((U)0xab << ((sizeof(T)-1)<<3))
+#if defined(__cplusplus) && !defined(__BORLANDC__)
+# define STATIC_CAST(t,v) static_cast<t>(v)
+#else
+# define STATIC_CAST(t,v) (t)(v)
+#endif
+
+#define VALUE(T, U) STATIC_CAST(T, STATIC_CAST(U, 0xab) << ((sizeof(T)-1)<<3))
#define TEST_C_(C, V, PRI, T, U) \
{ \
diff --git a/Utilities/Release/CMakeLogo.ico b/Utilities/Release/CMakeLogo.ico
index e13bb156f..c1006122b 100644
--- a/Utilities/Release/CMakeLogo.ico
+++ b/Utilities/Release/CMakeLogo.ico
Binary files differ
diff --git a/Utilities/Release/README b/Utilities/Release/README
deleted file mode 100644
index 11de1c325..000000000
--- a/Utilities/Release/README
+++ /dev/null
@@ -1,18 +0,0 @@
-To create a cmake release, make sure the "release" tag is pointing to the
-expected git commit:
-
-https://cmake.org/gitweb?p=cmake.git;a=shortlog;h=refs/heads/release
-
-Then as kitware@hythloth, using an up-to-date CMake:
-
- cd ~/CMakeReleases/cmake/Utilities/Release
- mkdir 283rc1
- cd 283rc1
- ~/CMakeReleases/build/bin/cmake -DCMAKE_CREATE_VERSION=release -P ../create-cmake-release.cmake
- ./create-release.sh
-
-
-create-cmake-release.cmake: script to run to create release sh scripts
-Add or remove machines in create-cmake-release.cmake.
-
-machine_release.cmake : config files for each machine
diff --git a/Utilities/Release/README.rst b/Utilities/Release/README.rst
new file mode 100644
index 000000000..de294d1c1
--- /dev/null
+++ b/Utilities/Release/README.rst
@@ -0,0 +1,84 @@
+CMake Release Utilities
+***********************
+
+This directory contains scripts used to package CMake itself for distribution
+on ``cmake.org``. See also the `CMake Source Code Guide`_.
+
+.. _`CMake Source Code Guide`: ../../Help/dev/source.rst
+
+Docker
+------
+
+The ``linux/<arch>/`` directories contain Docker specifications that anyone
+may use to produce Linux binaries for CMake:
+
+* ``linux/<arch>/base/Dockerfile``:
+ Produces a base image with a build environment for portable CMake binaries.
+ This image is published in the `kitware/cmake Docker Hub Repository`_
+ with tag ``build-linux-<arch>-base-<date>``.
+
+* ``linux/<arch>/deps/Dockerfile``:
+ Produces an image with custom-built dependencies for portable CMake binaries.
+ This image is published in the `kitware/cmake Docker Hub Repository`_
+ with tag ``build-linux-<arch>-deps-<date>``.
+
+* ``linux/<arch>/Dockerfile``:
+ Produce an image containing a portable CMake binary package for Linux.
+ Build this image using the CMake source directory as the build context.
+ The resulting image will have an ``/out`` directory containing the package.
+ For example:
+
+ .. code-block:: console
+
+ $ docker build --tag=cmake:build --network none \
+ -f cmake-src/Utilities/Release/linux/$arch/Dockerfile cmake-src
+ $ docker container create --name cmake-build cmake:build
+ $ docker cp cmake-build:/out .
+ $ ls out/cmake-*-Linux-$arch.*
+
+* ``linux/<arch>/test/Dockerfile``:
+ Produces a base image with a test environment for packaged CMake binaries.
+ For example, build the test base image:
+
+ .. code-block:: console
+
+ $ docker build --tag=cmake:test-base \
+ cmake-src/Utilities/Release/linux/$arch/test
+
+ Then create a local ``test/Dockerfile`` to prepare an image with both the
+ CMake source tree and the above-built package::
+
+ FROM cmake:test-base
+ COPY cmake-src /opt/cmake/src/cmake
+ ADD out/cmake-<ver>-Linux-<arch>.tar.gz /opt/
+ ENV PATH=/opt/cmake-<ver>-Linux-<arch>/bin:$PATH
+
+ Build the test image and run it to drive testing:
+
+ .. code-block:: console
+
+ $ docker build --tag cmake:test --network none -f test/Dockerfile .
+ $ docker run --network none cmake:test bash test-make.bash
+ $ docker run --network none cmake:test bash test-ninja.bash
+
+.. _`kitware/cmake Docker Hub Repository`: https://hub.docker.com/r/kitware/cmake
+
+Scripts for Kitware
+-------------------
+
+Kitware uses the following scripts to produce binaries for ``cmake.org``.
+They work only on specific machines Kitware uses for such builds.
+
+* ``create-cmake-release.cmake``:
+ Run ``cmake -DCMAKE_CREATE_VERSION=$ver -P ../create-cmake-release.cmake``
+ to generate ``create-$ver-*.sh`` release scripts. It also displays
+ instructions to run them.
+
+* ``*_release.cmake``:
+ Platform-specific settings used in corresponding scripts generated above.
+
+* ``release_cmake.cmake``:
+ Code shared by all ``*_release.cmake`` scripts.
+
+* ``release_cmake.sh.in``:
+ Template for script that runs on the actual build machines.
diff --git a/Utilities/Release/WiX/CustomAction/CMakeLists.txt b/Utilities/Release/WiX/CustomAction/CMakeLists.txt
index 7efd01e00..9d89dd89a 100644
--- a/Utilities/Release/WiX/CustomAction/CMakeLists.txt
+++ b/Utilities/Release/WiX/CustomAction/CMakeLists.txt
@@ -1,9 +1,15 @@
-foreach(CONFIG DEBUG MINSIZEREL RELEASE RELWITHDEBINFO)
- string(REPLACE "/MD" "/MT"
- "CMAKE_CXX_FLAGS_${CONFIG}"
- "${CMAKE_CXX_FLAGS_${CONFIG}}"
- )
-endforeach()
+if(MSVC)
+ if(NOT CMAKE_VERSION VERSION_LESS 3.15)
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+ else()
+ foreach(CONFIG DEBUG MINSIZEREL RELEASE RELWITHDEBINFO)
+ string(REPLACE "/MD" "/MT"
+ "CMAKE_CXX_FLAGS_${CONFIG}"
+ "${CMAKE_CXX_FLAGS_${CONFIG}}"
+ )
+ endforeach()
+ endif()
+endif()
add_library(CMakeWiXCustomActions MODULE
detect_nsis_overwrite.cpp
diff --git a/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp b/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp
index 4b178759d..4ced98738 100644
--- a/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp
+++ b/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp
@@ -1,16 +1,17 @@
+#include <string>
+#include <vector>
+
#include <windows.h>
#include <msi.h>
#include <msiquery.h>
-#include <string>
-#include <vector>
-
std::wstring get_property(MSIHANDLE msi_handle, std::wstring const& name)
{
DWORD size = 0;
- UINT status = MsiGetPropertyW(msi_handle, name.c_str(), L"", &size);
+ WCHAR value_buffer[] = L"";
+ UINT status = MsiGetPropertyW(msi_handle, name.c_str(), value_buffer, &size);
if (status == ERROR_MORE_DATA) {
std::vector<wchar_t> buffer(size + 1);
diff --git a/Utilities/Release/WiX/WIX.template.in b/Utilities/Release/WiX/WIX.template.in
index fe176ca90..8abf9d8f2 100644
--- a/Utilities/Release/WiX/WIX.template.in
+++ b/Utilities/Release/WiX/WIX.template.in
@@ -20,6 +20,8 @@
Schedule="afterInstallInitialize"
AllowDowngrades="yes"/>
+ <Property Id="REINSTALLMODE" Value="amus"/>
+
<WixVariable Id="WixUILicenseRtf" Value="$(var.CPACK_WIX_LICENSE_RTF)"/>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALL_ROOT"/>
diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake
index 3af1b035f..17a215176 100644
--- a/Utilities/Release/create-cmake-release.cmake
+++ b/Utilities/Release/create-cmake-release.cmake
@@ -5,30 +5,10 @@ endif()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/logs)
-set(RELEASE_SCRIPTS_BATCH_1
- win32_release.cmake # Windows x86
- osx_release.cmake # OS X x86_64
- linux64_release.cmake # Linux x86_64
-)
-
-set(RELEASE_SCRIPTS_BATCH_2
- win64_release.cmake # Windows x64
-)
-
-function(write_batch_shell_script filename)
- set(scripts ${ARGN})
- set(i 0)
- file(WRITE ${filename} "#!/bin/bash")
- foreach(f ${scripts})
- math(EXPR x "420*(${i}/4)")
- math(EXPR y "160*(${i}%4)")
- file(APPEND ${filename}
- "
-\"${CMAKE_COMMAND}\" -DCMAKE_CREATE_VERSION=${CMAKE_CREATE_VERSION} -DCMAKE_DOC_TARBALL=\"${CMAKE_DOC_TARBALL}\" -P \"${CMAKE_ROOT}/Utilities/Release/${f}\" < /dev/null >& \"${CMAKE_CURRENT_SOURCE_DIR}/logs/${f}-${CMAKE_CREATE_VERSION}.log\" &
-xterm -geometry 64x6+${x}+${y} -sb -sl 2000 -T ${f}-${CMAKE_CREATE_VERSION}.log -e tail -f \"${CMAKE_CURRENT_SOURCE_DIR}/logs/${f}-${CMAKE_CREATE_VERSION}.log\" &
+function(write_rel_shell_script filename script)
+ file(WRITE ${filename} "#!/usr/bin/env bash
+\"${CMAKE_COMMAND}\" -DCMAKE_CREATE_VERSION=${CMAKE_CREATE_VERSION} -DCMAKE_DOC_TARBALL=\"${CMAKE_DOC_TARBALL}\" -P \"${CMAKE_CURRENT_LIST_DIR}/${script}.cmake\" < /dev/null 2>&1 | tee \"${CMAKE_CURRENT_SOURCE_DIR}/logs/${script}-${CMAKE_CREATE_VERSION}.log\"
")
- math(EXPR i "${i}+1")
- endforeach()
execute_process(COMMAND chmod a+x ${filename})
endfunction()
@@ -54,7 +34,7 @@ cd \${name}-build &&
-DCMAKE_INSTALL_PREFIX=\"\$inst/\" \\
-DCMAKE_DOC_DIR=doc/cmake \\
-DSPHINX_EXECUTABLE=\"${SPHINX_EXECUTABLE}\" \\
- -DSPHINX_HTML=ON -DSPHINX_MAN=ON &&
+ -DSPHINX_HTML=ON -DSPHINX_MAN=ON -DSPHINX_QTHELP=ON &&
make install &&
cd .. &&
tar czf \${name}.tar.gz \${name} ||
@@ -65,12 +45,14 @@ echo 'Failed to create \${name}.tar.gz'
endfunction()
write_docs_shell_script("create-${CMAKE_CREATE_VERSION}-docs.sh")
-write_batch_shell_script("create-${CMAKE_CREATE_VERSION}-batch1.sh" ${RELEASE_SCRIPTS_BATCH_1})
-write_batch_shell_script("create-${CMAKE_CREATE_VERSION}-batch2.sh" ${RELEASE_SCRIPTS_BATCH_2})
-
-message("Run one at a time:
- ./create-${CMAKE_CREATE_VERSION}-docs.sh &&
- ./create-${CMAKE_CREATE_VERSION}-batch1.sh &&
- ./create-${CMAKE_CREATE_VERSION}-batch2.sh &&
+write_rel_shell_script("create-${CMAKE_CREATE_VERSION}-macos.sh" osx_release ) # macOS x86_64
+write_rel_shell_script("create-${CMAKE_CREATE_VERSION}-win64.sh" win64_release ) # Windows x64
+write_rel_shell_script("create-${CMAKE_CREATE_VERSION}-win32.sh" win32_release ) # Windows x86
+
+message("Build docs first and then build for each platform:
+ ./create-${CMAKE_CREATE_VERSION}-docs.sh &&
+ ./create-${CMAKE_CREATE_VERSION}-macos.sh &&
+ ./create-${CMAKE_CREATE_VERSION}-win64.sh &&
+ ./create-${CMAKE_CREATE_VERSION}-win32.sh &&
echo done
")
diff --git a/Utilities/Release/linux/x86_64/Dockerfile b/Utilities/Release/linux/x86_64/Dockerfile
new file mode 100644
index 000000000..1ba753c76
--- /dev/null
+++ b/Utilities/Release/linux/x86_64/Dockerfile
@@ -0,0 +1,36 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# Produce an image containing a portable CMake binary package for Linux/x86_64.
+# Build using the CMake source directory as the build context.
+# The resulting image will have an '/out' directory containing the package.
+
+ARG FROM_IMAGE_NAME=kitware/cmake:build-linux-x86_64-deps-2019-08-09
+ARG FROM_IMAGE_DIGEST=@sha256:630c320b26a67fc584e0bc98314f1fb0cb0abc764348bb2613ef07437f7101f9
+ARG FROM_IMAGE=$FROM_IMAGE_NAME$FROM_IMAGE_DIGEST
+FROM $FROM_IMAGE
+
+COPY . /opt/cmake/src/cmake
+
+ARG TEST=true
+
+RUN : \
+ && mkdir -p /opt/cmake/src/cmake-build \
+ && cd /opt/cmake/src/cmake-build \
+ && cp ../cmake/Utilities/Release/linux/x86_64/cache.txt CMakeCache.txt \
+ && source /opt/rh/devtoolset-6/enable \
+ && source /opt/rh/rh-python36/enable \
+ && export LANG=en_US.UTF-8 \
+ && set -x \
+ && ../cmake/bootstrap --parallel=$(nproc) --docdir=doc/cmake \
+ && nice make -j $(nproc) \
+ && if $TEST; then \
+ # Run tests that require the full build tree.
+ bin/ctest --output-on-failure -j 8 -R '^(CMake\.|CMakeLib\.|CMakeServerLib\.|RunCMake\.ctest_memcheck)'; \
+ fi \
+ && bin/cpack -G TGZ \
+ && bin/cpack -G STGZ \
+ && set +x \
+ && mkdir /out \
+ && mv cmake-*-Linux-x86_64.* /out \
+ && :
diff --git a/Utilities/Release/linux/x86_64/base/Dockerfile b/Utilities/Release/linux/x86_64/base/Dockerfile
new file mode 100644
index 000000000..dfc7df802
--- /dev/null
+++ b/Utilities/Release/linux/x86_64/base/Dockerfile
@@ -0,0 +1,30 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# Produce a base image with a build environment for portable CMake binaries.
+# Build using the directory containing this file as its own build context.
+
+ARG FROM_IMAGE_NAME=centos:6
+ARG FROM_IMAGE_DIGEST=@sha256:dec8f471302de43f4cfcf82f56d99a5227b5ea1aa6d02fa56344986e1f4610e7
+ARG FROM_IMAGE=$FROM_IMAGE_NAME$FROM_IMAGE_DIGEST
+FROM $FROM_IMAGE
+
+RUN : \
+ && yum install -y centos-release-scl \
+ && yum install -y \
+ ca-certificates \
+ curl \
+ devtoolset-6-gcc \
+ devtoolset-6-gcc-c++ \
+ fontconfig-devel \
+ freetype-devel \
+ git \
+ libX11-devel \
+ libxcb-devel \
+ make \
+ patch \
+ perl \
+ rh-python36-python-pip \
+ xz \
+ && yum clean all \
+ && :
diff --git a/Utilities/Release/linux/x86_64/cache.txt b/Utilities/Release/linux/x86_64/cache.txt
new file mode 100644
index 000000000..a2864e98b
--- /dev/null
+++ b/Utilities/Release/linux/x86_64/cache.txt
@@ -0,0 +1,44 @@
+CMAKE_BUILD_TYPE:STRING=Release
+
+CMAKE_C_STANDARD:STRING=11
+CMAKE_CXX_STANDARD:STRING=14
+
+# Require only older APIs where possible.
+CMAKE_C_FLAGS:STRING=-D_POSIX_C_SOURCE=199506L -D_POSIX_SOURCE=1 -D_SVID_SOURCE=1 -D_BSD_SOURCE=1
+
+# Link C++ library statically.
+CMAKE_EXE_LINKER_FLAGS:STRING=-static-libstdc++ -static-libgcc
+
+# Enable ssl support in curl
+CMAKE_USE_OPENSSL:BOOL=ON
+OPENSSL_CRYPTO_LIBRARY:STRING=/opt/openssl/lib/libcrypto.a;-pthread
+OPENSSL_INCLUDE_DIR:PATH=/opt/openssl/include
+OPENSSL_SSL_LIBRARY:FILEPATH=/opt/openssl/lib/libssl.a
+
+# Enable ccmake
+BUILD_CursesDialog:BOOL=ON
+CURSES_FORM_LIBRARY:FILEPATH=/opt/ncurses/lib/libform.a
+CURSES_INCLUDE_PATH:PATH=/opt/ncurses/include
+CURSES_NCURSES_LIBRARY:FILEPATH=/opt/ncurses/lib/libncurses.a
+
+# Enable cmake-gui with static qt plugins
+BUILD_QtDialog:BOOL=TRUE
+CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:STRING=3
+CMAKE_PREFIX_PATH:STRING=/opt/qt
+CMake_QT_STATIC_QXcbIntegrationPlugin_LIBRARIES:STRING=/opt/qt/plugins/platforms/libqxcb.a;/opt/qt/lib/libQt5XcbQpa.a;/opt/qt/lib/libQt5ServiceSupport.a;/opt/qt/lib/libQt5EdidSupport.a;/opt/qt/lib/libQt5EventDispatcherSupport.a;/opt/qt/lib/libQt5FontDatabaseSupport.a;/opt/qt/lib/libQt5ThemeSupport.a;/opt/qt/lib/libxcb-static.a;-lxcb;-lfontconfig;-lfreetype
+
+# Build documentation.
+SPHINX_EXECUTABLE:FILEPATH=/opt/rh/rh-python36/root/usr/bin/sphinx-build
+SPHINX_HTML:BOOL=ON
+SPHINX_MAN:BOOL=ON
+SPHINX_QTHELP:BOOL=ON
+QCOLLECTIONGENERATOR_EXECUTABLE:PATH=/opt/qt/bin/qhelpgenerator
+
+# We bootstrap as part of the build so skip its test.
+CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
+
+# Skip Qt5 tests because our Qt is static.
+CMake_TEST_Qt5:BOOL=FALSE
+
+# CPack package file name component for this platform.
+CPACK_SYSTEM_NAME:STRING=Linux-x86_64
diff --git a/Utilities/Release/linux/x86_64/deps/Dockerfile b/Utilities/Release/linux/x86_64/deps/Dockerfile
new file mode 100644
index 000000000..db5551c61
--- /dev/null
+++ b/Utilities/Release/linux/x86_64/deps/Dockerfile
@@ -0,0 +1,142 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# Produce an image with custom-built dependencies for portable CMake binaries.
+# Build using the directory containing this file as its own build context.
+
+ARG FROM_IMAGE_NAME=kitware/cmake:build-linux-x86_64-base-2019-08-09
+ARG FROM_IMAGE_DIGEST=@sha256:d2c13617f01181a3143a069e4496d6b78eafffa19d181c42be196d5dfd588151
+ARG FROM_IMAGE=$FROM_IMAGE_NAME$FROM_IMAGE_DIGEST
+FROM $FROM_IMAGE
+
+# Sphinx
+RUN : \
+ && source /opt/rh/rh-python36/enable \
+ && pip install sphinx==2.1.2 \
+ && :
+
+# Qt
+# Version 5.12.0 was the last to bundle xkbcommon.
+COPY qt-install.patch /opt/qt/src/
+RUN : \
+ && mkdir -p /opt/qt/src/qt-build \
+ && cd /opt/qt/src \
+ && curl -OL https://download.qt.io/archive/qt/5.12/5.12.0/single/qt-everywhere-src-5.12.0.tar.xz \
+ && sha512sum qt-everywhere-src-5.12.0.tar.xz | grep -q 0dd03d2645fb6dac5b58c8caf92b4a0a6900131f1ccfb02443a0df4702b5da0458f4c45e758d1b929ec709b0f4b36900df2fd60a058af9cc8c1a0748b6d57aae \
+ && tar xJf qt-everywhere-src-5.12.0.tar.xz \
+ && cd qt-build \
+ && source /opt/rh/devtoolset-6/enable \
+ && ../qt-everywhere-src-5.12.0/configure \
+ -prefix /opt/qt \
+ -static \
+ -release \
+ -c++std c++11 \
+ -opensource -confirm-license \
+ -gui \
+ -widgets \
+ -xcb \
+ -fontconfig \
+ -sql-sqlite \
+ -qt-doubleconversion \
+ -qt-libjpeg \
+ -qt-libpng \
+ -qt-pcre \
+ -qt-sqlite \
+ -qt-xcb \
+ -qt-xkbcommon \
+ -qt-zlib \
+ -system-freetype \
+ -no-accessibility \
+ -no-compile-examples \
+ -no-cups \
+ -no-dbus \
+ -no-directfb \
+ -no-egl \
+ -no-eglfs \
+ -no-evdev \
+ -no-gbm \
+ -no-gif \
+ -no-glib \
+ -no-gtk \
+ -no-harfbuzz \
+ -no-iconv \
+ -no-icu \
+ -no-journald \
+ -no-kms \
+ -no-libinput \
+ -no-libproxy \
+ -no-linuxfb \
+ -no-ltcg \
+ -no-mirclient \
+ -no-mtdev \
+ -no-opengl \
+ -no-openssl \
+ -no-pch \
+ -no-sql-mysql \
+ -no-sql-psql \
+ -no-sql-sqlite2 \
+ -no-syslog \
+ -no-system-proxies \
+ -no-tslib \
+ -no-use-gold-linker \
+ -skip declarative \
+ -skip multimedia \
+ -skip qtcanvas3d \
+ -skip qtconnectivity \
+ -skip qtdeclarative \
+ -skip qtlocation \
+ -skip qtmultimedia \
+ -skip qtsensors \
+ -skip qtserialport \
+ -skip qtsvg \
+ -skip qtwayland \
+ -skip qtwebchannel \
+ -skip qtwebengine \
+ -skip qtwebsockets \
+ -skip qtwinextras \
+ -skip qtxmlpatterns \
+ -nomake examples \
+ -nomake tests \
+ && make install -j $(nproc) \
+ && cd /opt/qt \
+ && patch -p1 -i src/qt-install.patch \
+ && cd /opt \
+ && rm -rf /opt/qt/src \
+ && :
+
+# Curses
+RUN : \
+ && mkdir -p /opt/ncurses/src/ncurses-build \
+ && cd /opt/ncurses/src \
+ && curl -O https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz \
+ && sha512sum ncurses-6.1.tar.gz | grep -q e308af43f8b7e01e98a55f4f6c4ee4d1c39ce09d95399fa555b3f0cdf5fd0db0f4c4d820b4af78a63f6cf6d8627587114a40af48cfc066134b600520808a77ee \
+ && tar xzf ncurses-6.1.tar.gz \
+ && cd ncurses-build \
+ && source /opt/rh/devtoolset-6/enable \
+ && ../ncurses-6.1/configure \
+ --prefix=/opt/ncurses \
+ --with-terminfo-dirs=/etc/terminfo:/lib/terminfo:/usr/share/terminfo \
+ --with-default-terminfo-dir=/usr/share/terminfo \
+ --without-shared \
+ && make -j $(nproc) \
+ && make install.libs install.includes \
+ && cd /opt \
+ && rm -rf /opt/ncurses/src \
+ && :
+
+# OpenSSL
+COPY openssl-source.patch /opt/openssl/src/
+RUN : \
+ && mkdir -p /opt/openssl/src \
+ && cd /opt/openssl/src \
+ && curl -O https://www.openssl.org/source/openssl-1.1.1c.tar.gz \
+ && sha512sum openssl-1.1.1c.tar.gz | grep -q 8e2c5cc11c120efbb7d7850980cb6eaa782d29b4996b3f3378d37613c1679f852d7cc08a90d62e78fcec3439f06bdbee70064579a8c2adaffd91532a97f646ff \
+ && tar xzf openssl-1.1.1c.tar.gz \
+ && cd openssl-1.1.1c \
+ && patch -p1 -i ../openssl-source.patch \
+ && source /opt/rh/devtoolset-6/enable \
+ && ./Configure --prefix=/opt/openssl linux-elf no-asm no-shared -D_POSIX_C_SOURCE=199506L -D_POSIX_SOURCE=1 -D_SVID_SOURCE=1 -D_BSD_SOURCE=1 \
+ && make install_dev -j $(nproc) \
+ && cd /opt \
+ && rm -rf /opt/openssl/src \
+ && :
diff --git a/Utilities/Release/linux/x86_64/deps/openssl-source.patch b/Utilities/Release/linux/x86_64/deps/openssl-source.patch
new file mode 100644
index 000000000..c81fe2f88
--- /dev/null
+++ b/Utilities/Release/linux/x86_64/deps/openssl-source.patch
@@ -0,0 +1,12 @@
+# enable pthread APIs disabled by our _POSIX_SOURCE definitions
+--- openssl-source/crypto/threads_pthread.c.orig
++++ openssl-source/crypto/threads_pthread.c
+@@ -6,6 +6,8 @@
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
++#undef _POSIX_C_SOURCE
++#undef _POSIX_SOURCE
+
+ #include <openssl/crypto.h>
+ #include "internal/cryptlib.h"
diff --git a/Utilities/Release/linux/x86_64/deps/qt-install.patch b/Utilities/Release/linux/x86_64/deps/qt-install.patch
new file mode 100644
index 000000000..792aefd39
--- /dev/null
+++ b/Utilities/Release/linux/x86_64/deps/qt-install.patch
@@ -0,0 +1,24 @@
+# Add Qt Core dependencies missing from static Qt build.
+--- qt-install/lib/cmake/Qt5Core/Qt5CoreConfig.cmake.orig
++++ qt-install/lib/cmake/Qt5Core/Qt5CoreConfig.cmake
+@@ -111,7 +111,7 @@
+ list(REMOVE_DUPLICATES Qt5Core_COMPILE_DEFINITIONS)
+ list(REMOVE_DUPLICATES Qt5Core_EXECUTABLE_COMPILE_FLAGS)
+
+- set(_Qt5Core_LIB_DEPENDENCIES "")
++ set(_Qt5Core_LIB_DEPENDENCIES "${_qt5Core_install_prefix}/lib/libqtpcre2.a")
+
+
+ add_library(Qt5::Core STATIC IMPORTED)
+# Add Qt Gui dependencies missing from static Qt build.
+--- qt-install/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake.orig
++++ qt-install/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake
+@@ -111,7 +111,7 @@
+ list(REMOVE_DUPLICATES Qt5Gui_COMPILE_DEFINITIONS)
+ list(REMOVE_DUPLICATES Qt5Gui_EXECUTABLE_COMPILE_FLAGS)
+
+- set(_Qt5Gui_LIB_DEPENDENCIES "Qt5::Core")
++ set(_Qt5Gui_LIB_DEPENDENCIES "Qt5::Core;${_qt5Gui_install_prefix}/lib/libqtlibpng.a")
+
+
+ add_library(Qt5::Gui STATIC IMPORTED)
diff --git a/Utilities/Release/linux/x86_64/test/Dockerfile b/Utilities/Release/linux/x86_64/test/Dockerfile
new file mode 100644
index 000000000..662915655
--- /dev/null
+++ b/Utilities/Release/linux/x86_64/test/Dockerfile
@@ -0,0 +1,26 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+# Produce a base image with a test environment for packaged CMake binaries.
+# Build using the directory containing this file as its own build context.
+
+ARG FROM_IMAGE_NAME=debian:9
+ARG FROM_IMAGE_DIGEST=@sha256:397b2157a9ea8d7f16c613aded70284292106e8b813fb1ed5de8a8785310a26a
+ARG FROM_IMAGE=$FROM_IMAGE_NAME$FROM_IMAGE_DIGEST
+FROM $FROM_IMAGE
+
+RUN : \
+ && apt-get update \
+ && apt-get install -y \
+ dpkg \
+ file \
+ gcc \
+ g++ \
+ gfortran \
+ qt5-default \
+ make \
+ ninja-build \
+ && apt-get clean \
+ && :
+
+COPY test-make.bash test-ninja.bash /
diff --git a/Utilities/Release/linux/x86_64/test/cache-ninja.txt b/Utilities/Release/linux/x86_64/test/cache-ninja.txt
new file mode 100644
index 000000000..b00370e27
--- /dev/null
+++ b/Utilities/Release/linux/x86_64/test/cache-ninja.txt
@@ -0,0 +1,4 @@
+CMAKE_Fortran_COMPILER:STRING=
+CMake_TEST_IPO_WORKS_C:BOOL=ON
+CMake_TEST_IPO_WORKS_CXX:BOOL=ON
+CMake_TEST_Qt5:BOOL=ON
diff --git a/Utilities/Release/linux/x86_64/test/test-make.bash b/Utilities/Release/linux/x86_64/test/test-make.bash
new file mode 100644
index 000000000..10d30c38a
--- /dev/null
+++ b/Utilities/Release/linux/x86_64/test/test-make.bash
@@ -0,0 +1,17 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+set -e
+set -x
+mkdir -p /opt/cmake/src/cmake-make
+cd /opt/cmake/src/cmake-make
+echo >CMakeCache.txt '
+CMake_TEST_IPO_WORKS_C:BOOL=ON
+CMake_TEST_IPO_WORKS_CXX:BOOL=ON
+CMake_TEST_IPO_WORKS_Fortran:BOOL=ON
+CMake_TEST_NO_NETWORK:BOOL=ON
+CMake_TEST_Qt5:BOOL=ON
+'
+cmake ../cmake -DCMake_TEST_HOST_CMAKE=1 -G "Unix Makefiles"
+make -j $(nproc)
+ctest --output-on-failure -j $(nproc)
diff --git a/Utilities/Release/linux/x86_64/test/test-ninja.bash b/Utilities/Release/linux/x86_64/test/test-ninja.bash
new file mode 100644
index 000000000..fe39e2e63
--- /dev/null
+++ b/Utilities/Release/linux/x86_64/test/test-ninja.bash
@@ -0,0 +1,17 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+set -e
+set -x
+mkdir -p /opt/cmake/src/cmake-ninja
+cd /opt/cmake/src/cmake-ninja
+echo >CMakeCache.txt '
+CMAKE_Fortran_COMPILER:STRING=
+CMake_TEST_IPO_WORKS_C:BOOL=ON
+CMake_TEST_IPO_WORKS_CXX:BOOL=ON
+CMake_TEST_NO_NETWORK:BOOL=ON
+CMake_TEST_Qt5:BOOL=ON
+'
+cmake ../cmake -DCMake_TEST_HOST_CMAKE=1 -G "Ninja"
+ninja
+ctest --output-on-failure -j $(nproc)
diff --git a/Utilities/Release/linux64_release.cmake b/Utilities/Release/linux64_release.cmake
deleted file mode 100644
index 3d8ddba3c..000000000
--- a/Utilities/Release/linux64_release.cmake
+++ /dev/null
@@ -1,50 +0,0 @@
-set(PROCESSORS 4)
-set(BOOTSTRAP_ARGS "--docdir=doc/cmake")
-set(HOST linux64)
-set(MAKE_PROGRAM "make")
-set(CPACK_BINARY_GENERATORS "STGZ TGZ")
-set(CC /opt/gcc-6.1.0/bin/gcc)
-set(CXX /opt/gcc-6.1.0/bin/g++)
-set(CFLAGS "")
-set(CXXFLAGS "")
-set(qt_prefix "/home/kitware/qt-5.7.0")
-set(qt_xcb_libs
- ${qt_prefix}/plugins/platforms/libqxcb.a
- ${qt_prefix}/lib/libQt5XcbQpa.a
- ${qt_prefix}/lib/libQt5PlatformSupport.a
- ${qt_prefix}/lib/libxcb-static.a
- -lX11-xcb
- -lX11
- -lxcb
- -lfontconfig
- -lfreetype
- )
-set(INITIAL_CACHE "
-CMAKE_BUILD_TYPE:STRING=Release
-CMAKE_C_STANDARD:STRING=11
-CMAKE_CXX_STANDARD:STRING=14
-CMAKE_C_FLAGS:STRING=-D_POSIX_C_SOURCE=199506L -D_POSIX_SOURCE=1 -D_SVID_SOURCE=1 -D_BSD_SOURCE=1
-CMAKE_EXE_LINKER_FLAGS:STRING=-static-libstdc++ -static-libgcc
-CURSES_LIBRARY:FILEPATH=/home/kitware/ncurses-5.9/lib/libncurses.a
-CURSES_INCLUDE_PATH:PATH=/home/kitware/ncurses-5.9/include
-FORM_LIBRARY:FILEPATH=/home/kitware/ncurses-5.9/lib/libform.a
-CMAKE_USE_OPENSSL:BOOL=ON
-OPENSSL_CRYPTO_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2j/lib/libcrypto.a
-OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.2j/include
-OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.2j/lib/libssl.a
-PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3
-CPACK_SYSTEM_NAME:STRING=Linux-x86_64
-BUILD_QtDialog:BOOL:=TRUE
-CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
-CMake_ENABLE_SERVER_MODE:BOOL=TRUE
-CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:STRING=3
-CMake_INSTALL_DEPENDENCIES:BOOL=ON
-CMAKE_PREFIX_PATH:STRING=${qt_prefix}
-CMake_QT_STATIC_QXcbIntegrationPlugin_LIBRARIES:STRING=${qt_xcb_libs}
-")
-
-# Exclude Qt5 tests because our Qt5 is static.
-set(EXTRA_CTEST_ARGS "-E Qt5")
-
-get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
-include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/osx_release.cmake b/Utilities/Release/osx_release.cmake
index 36498a7ce..5ef30039a 100644
--- a/Utilities/Release/osx_release.cmake
+++ b/Utilities/Release/osx_release.cmake
@@ -5,7 +5,7 @@ set(HOST dragnipur)
set(MAKE_PROGRAM "make")
set(MAKE "${MAKE_PROGRAM} -j5")
set(CPACK_BINARY_GENERATORS "DragNDrop TGZ")
-set(CPACK_SOURCE_GENERATORS "TGZ TZ")
+set(CPACK_SOURCE_GENERATORS "")
set(CPACK_DMG_FORMAT "UDBZ") #build using bzip2 for smaller package size
set(CC clang)
set(CXX clang++)
@@ -19,8 +19,8 @@ CMAKE_OSX_ARCHITECTURES:STRING=x86_64
CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.7
CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
CPACK_SYSTEM_NAME:STRING=Darwin-x86_64
+BUILD_CursesDialog:BOOL=ON
BUILD_QtDialog:BOOL=TRUE
-CMake_ENABLE_SERVER_MODE:BOOL=TRUE
CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:STRING=3
CMake_INSTALL_DEPENDENCIES:BOOL=ON
CMAKE_SKIP_RPATH:BOOL=TRUE
@@ -29,5 +29,6 @@ CMake_TEST_NO_FindPackageModeMakefileTest:BOOL=TRUE
set(ENV [[
export CMAKE_PREFIX_PATH='/Users/kitware/SDKs/qt-5.6.2-clang-x64'
]])
+set(SIGN "")
get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/push.bash b/Utilities/Release/push.bash
new file mode 100755
index 000000000..1c8efe900
--- /dev/null
+++ b/Utilities/Release/push.bash
@@ -0,0 +1,70 @@
+#!/usr/bin/env bash
+
+usage='usage: push.bash [<options>] [--] <dest>
+
+Options:
+
+ --dir <dir> Specify subdirectory under destination.
+ Defaults to "v<version>".
+ --version <ver> CMake <major>.<minor> version number to push.
+ Defaults to version of source tree.
+'
+
+die() {
+ echo "$@" 1>&2; exit 1
+}
+
+cmake_source_dir="${BASH_SOURCE%/*}/../.."
+
+cmake_version_component()
+{
+ sed -n "
+/^set(CMake_VERSION_${1}/ {s/set(CMake_VERSION_${1} *\([0-9]*\))/\1/;p;}
+" "${cmake_source_dir}/Source/CMakeVersion.cmake"
+}
+
+
+version=''
+dir=''
+while test "$#" != 0; do
+ case "$1" in
+ --dir) shift; dir="$1" ;;
+ --version) shift; version="$1" ;;
+ --) shift ; break ;;
+ -*) die "$usage" ;;
+ *) break ;;
+ esac
+ shift
+done
+test "$#" = 1 || die "$usage"
+readonly dest="$1"
+
+if test -z "$version"; then
+ cmake_version_major="$(cmake_version_component MAJOR)"
+ cmake_version_minor="$(cmake_version_component MINOR)"
+ version="${cmake_version_major}.${cmake_version_minor}"
+fi
+readonly version
+
+if test -z "$dir"; then
+ dir="v${version}"
+fi
+readonly dir
+
+for f in cmake-${version}*; do
+ if ! test -f "${f}"; then
+ continue
+ fi
+
+ echo "pushing '${f}'"
+
+ # Make a copy with a new timestamp and atomically rename into place.
+ tf="${dest}/${dir}/.tmp.${f}"
+ df="${dest}/${dir}/${f}"
+ cp "${f}" "${tf}"
+ mv "${tf}" "${df}"
+
+ # Pause to give each file a distinct time stamp even with 1s resolution
+ # so that sorting by time also sorts alphabetically.
+ sleep 1.1
+done
diff --git a/Utilities/Release/release_cmake.sh.in b/Utilities/Release/release_cmake.sh.in
index f363b3d8a..696a3f445 100755
--- a/Utilities/Release/release_cmake.sh.in
+++ b/Utilities/Release/release_cmake.sh.in
@@ -150,7 +150,7 @@ for GEN in $generators; do
check_exit_value $? "Create $GEN package" || exit 1
done
-
+@SIGN@
echo "End release"
date
diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake
deleted file mode 100644
index 5b2cc5732..000000000
--- a/Utilities/Release/upload_release.cmake
+++ /dev/null
@@ -1,39 +0,0 @@
-set(CTEST_RUN_CURRENT_SCRIPT 0)
-if(NOT VERSION)
- set(VERSION 3.9)
-endif()
-if(NOT DEFINED PROJECT_PREFIX)
- set(PROJECT_PREFIX cmake-${VERSION})
-endif()
-if(NOT DEFINED DIR)
- set(DIR "v${VERSION}")
-endif()
-file(GLOB FILES ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_PREFIX}*")
-list(SORT FILES)
-list(REVERSE FILES)
-message("${FILES}")
-set(UPLOAD_LOC
- "kitware@www.cmake.org:/projects/FTP/pub/cmake/${DIR}")
-set(count 0)
-foreach(file ${FILES})
- if(NOT IS_DIRECTORY ${file})
- message("upload ${file} ${UPLOAD_LOC}")
- execute_process(COMMAND
- scp ${file} ${UPLOAD_LOC}
- RESULT_VARIABLE result)
- if("${result}" GREATER 0)
- message(FATAL_ERROR "failed to upload file to ${UPLOAD_LOC}")
- endif()
-
- # Pause to give each upload a distinct (to the nearest second)
- # time stamp
- if(COMMAND ctest_sleep)
- ctest_sleep(2)
- endif()
-
- math(EXPR count "${count} + 1")
- endif()
-endforeach()
-if(${count} EQUAL 0)
- message(FATAL_ERROR "Error no files uploaded.")
-endif()
diff --git a/Utilities/Release/win32_release.cmake b/Utilities/Release/win32_release.cmake
index df9fe275b..14e5cba7f 100644
--- a/Utilities/Release/win32_release.cmake
+++ b/Utilities/Release/win32_release.cmake
@@ -1,33 +1,52 @@
-set(CMAKE_RELEASE_DIRECTORY "c:/msys64/home/dashboard/CMakeReleaseDirectory")
+set(CMAKE_RELEASE_DIRECTORY "c:/msys64/home/dashboard/CMakeReleaseDirectory32")
set(CONFIGURE_WITH_CMAKE TRUE)
set(CMAKE_CONFIGURE_PATH "c:/Program\\ Files/CMake/bin/cmake.exe")
-set(PROCESSORS 8)
-set(HOST dash3win7)
+set(PROCESSORS 16)
+set(HOST win32)
set(RUN_LAUNCHER ~/rel/run)
set(CPACK_BINARY_GENERATORS "WIX ZIP")
-set(CPACK_SOURCE_GENERATORS "ZIP")
+set(CPACK_SOURCE_GENERATORS "")
set(MAKE_PROGRAM "ninja")
-set(MAKE "${MAKE_PROGRAM} -j8")
+set(MAKE "${MAKE_PROGRAM} -j16")
+set(qt_prefix "c:/Qt/5.12.1/msvc2017-32-w7-mt")
+set(qt_win_libs
+ ${qt_prefix}/plugins/platforms/qwindows.lib
+ ${qt_prefix}/plugins/styles/qwindowsvistastyle.lib
+ ${qt_prefix}/lib/Qt5EventDispatcherSupport.lib
+ ${qt_prefix}/lib/Qt5FontDatabaseSupport.lib
+ ${qt_prefix}/lib/Qt5ThemeSupport.lib
+ ${qt_prefix}/lib/qtfreetype.lib
+ ${qt_prefix}/lib/qtlibpng.lib
+ imm32.lib
+ wtsapi32.lib
+ )
set(INITIAL_CACHE "CMAKE_BUILD_TYPE:STRING=Release
CMAKE_DOC_DIR:STRING=doc/cmake
CMAKE_USE_OPENSSL:BOOL=OFF
CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
CMAKE_Fortran_COMPILER:FILEPATH=FALSE
CMAKE_GENERATOR:INTERNAL=Ninja
-BUILD_QtDialog:BOOL:=TRUE
-CMake_ENABLE_SERVER_MODE:BOOL=TRUE
+BUILD_QtDialog:BOOL=TRUE
CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:STRING=3
-CMake_INSTALL_DEPENDENCIES:BOOL=ON
-CMAKE_EXE_LINKER_FLAGS:STRING=-machine:x86 -subsystem:console,5.01
+CMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreaded$<$<CONFIG:Debug>:Debug>
+CMAKE_EXE_LINKER_FLAGS:STRING=-machine:x86 -subsystem:console,6.01
+CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES:STRING=${qt_win_libs}
+CMAKE_PREFIX_PATH:STRING=${qt_prefix}
+CMake_TEST_Qt4:BOOL=OFF
+CMake_TEST_Qt5:BOOL=OFF
")
-set(ppflags "-D_WIN32_WINNT=0x501 -DNTDDI_VERSION=0x05010000 -D_USING_V110_SDK71_")
+set(ppflags "-D_WIN32_WINNT=0x601 -DNTDDI_VERSION=0x06010000")
set(CFLAGS "${ppflags}")
set(CXXFLAGS "${ppflags}")
-set(ENV ". ~/rel/env")
+set(ENV ". ~/rel/env32")
get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(GIT_EXTRA "git config core.autocrlf true")
if(CMAKE_CREATE_VERSION STREQUAL "nightly")
# Some tests fail spuriously too often.
- set(EXTRA_CTEST_ARGS "-E 'Qt5Autogen|ConsoleBuf'")
+ set(EXTRA_CTEST_ARGS "-E 'ConsoleBuf|Module.ExternalData'")
+ set(SIGN "")
+else()
+ string(APPEND INITIAL_CACHE "CMake_INSTALL_SIGNTOOL:STRING=signtool\n")
+ set(SIGN [[signtool sign -v -a -tr http://timestamp.digicert.com -fd sha256 -td sha256 -d "CMake Windows Installer" cmake-*.msi]])
endif()
include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/win64_release.cmake b/Utilities/Release/win64_release.cmake
index ab52d794d..149d37899 100644
--- a/Utilities/Release/win64_release.cmake
+++ b/Utilities/Release/win64_release.cmake
@@ -1,27 +1,41 @@
set(CMAKE_RELEASE_DIRECTORY "c:/msys64/home/dashboard/CMakeReleaseDirectory64")
set(CONFIGURE_WITH_CMAKE TRUE)
set(CMAKE_CONFIGURE_PATH "c:/Program\\ Files/CMake/bin/cmake.exe")
-set(PROCESSORS 8)
-set(HOST dash3win7)
-set(SCRIPT_NAME dash3win7x64)
+set(PROCESSORS 16)
+set(HOST win64)
set(RUN_LAUNCHER ~/rel/run)
set(CPACK_BINARY_GENERATORS "WIX ZIP")
set(CPACK_SOURCE_GENERATORS "")
set(MAKE_PROGRAM "ninja")
-set(MAKE "${MAKE_PROGRAM} -j8")
+set(MAKE "${MAKE_PROGRAM} -j16")
+set(qt_prefix "c:/Qt/5.12.1/msvc2017-64-w7-mt")
+set(qt_win_libs
+ ${qt_prefix}/plugins/platforms/qwindows.lib
+ ${qt_prefix}/plugins/styles/qwindowsvistastyle.lib
+ ${qt_prefix}/lib/Qt5EventDispatcherSupport.lib
+ ${qt_prefix}/lib/Qt5FontDatabaseSupport.lib
+ ${qt_prefix}/lib/Qt5ThemeSupport.lib
+ ${qt_prefix}/lib/qtfreetype.lib
+ ${qt_prefix}/lib/qtlibpng.lib
+ imm32.lib
+ wtsapi32.lib
+ )
set(INITIAL_CACHE "CMAKE_BUILD_TYPE:STRING=Release
CMAKE_DOC_DIR:STRING=doc/cmake
CMAKE_USE_OPENSSL:BOOL=OFF
CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
CMAKE_Fortran_COMPILER:FILEPATH=FALSE
CMAKE_GENERATOR:INTERNAL=Ninja
-BUILD_QtDialog:BOOL:=TRUE
-CMake_ENABLE_SERVER_MODE:BOOL=TRUE
+BUILD_QtDialog:BOOL=TRUE
CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:STRING=3
-CMake_INSTALL_DEPENDENCIES:BOOL=ON
-CMAKE_EXE_LINKER_FLAGS:STRING=-machine:x64 -subsystem:console,5.02
+CMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreaded$<$<CONFIG:Debug>:Debug>
+CMAKE_EXE_LINKER_FLAGS:STRING=-machine:x64 -subsystem:console,6.01
+CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES:STRING=${qt_win_libs}
+CMAKE_PREFIX_PATH:STRING=${qt_prefix}
+CMake_TEST_Qt4:BOOL=OFF
+CMake_TEST_Qt5:BOOL=OFF
")
-set(ppflags "-D_WIN32_WINNT=0x502 -DNTDDI_VERSION=0x05020000 -D_USING_V110_SDK71_")
+set(ppflags "-D_WIN32_WINNT=0x601 -DNTDDI_VERSION=0x06010000")
set(CFLAGS "${ppflags}")
set(CXXFLAGS "${ppflags}")
set(ENV ". ~/rel/env64")
@@ -29,6 +43,10 @@ get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(GIT_EXTRA "git config core.autocrlf true")
if(CMAKE_CREATE_VERSION STREQUAL "nightly")
# Some tests fail spuriously too often.
- set(EXTRA_CTEST_ARGS "-E 'Qt5Autogen|ConsoleBuf'")
+ set(EXTRA_CTEST_ARGS "-E 'ConsoleBuf|Module.ExternalData'")
+ set(SIGN "")
+else()
+ string(APPEND INITIAL_CACHE "CMake_INSTALL_SIGNTOOL:STRING=signtool\n")
+ set(SIGN [[signtool sign -v -a -tr http://timestamp.digicert.com -fd sha256 -td sha256 -d "CMake Windows Installer" cmake-*.msi]])
endif()
include(${path}/release_cmake.cmake)
diff --git a/Utilities/Scripts/BoostScanDeps.cmake b/Utilities/Scripts/BoostScanDeps.cmake
index 2fd8f8633..28a94ce89 100644
--- a/Utilities/Scripts/BoostScanDeps.cmake
+++ b/Utilities/Scripts/BoostScanDeps.cmake
@@ -39,29 +39,40 @@ function(_Boost_FIND_COMPONENT_DEPENDENCIES component includedir _ret_libs)
# Start by finding all headers for the component; header
# dependencies via #include will be solved by future passes
+ file(GLOB_RECURSE _boost_mpi_python_headers
+ RELATIVE "${includedir}"
+ "${includedir}/boost/mpi/python/*")
+ list(INSERT _boost_mpi_python_headers 0 "boost/mpi/python.hpp")
+
+ file(GLOB_RECURSE _boost_python_numpy_headers
+ RELATIVE "${includedir}"
+ "${includedir}/boost/python/numpy/*")
+ list(INSERT _boost_python_numpy_headers 0 "boost/python/numpy.hpp")
# Special-case since it is part of mpi; look only in boost/mpi/python*
if(component STREQUAL "mpi_python")
- set(_boost_DEPS "python")
+ set(_boost_DEPS "python\${component_python_version}")
set(library_component TRUE)
- file(GLOB_RECURSE _boost_unprocessed_headers
- RELATIVE "${includedir}"
- "${includedir}/boost/mpi/python/*")
- list(INSERT _boost_unprocessed_headers 0 "${includedir}/boost/mpi/python.hpp")
+ set(_boost_unprocessed_headers ${_boost_mpi_python_headers})
+ # Special-case since it is part of python; look only in boost/python/numpy*
+ elseif(component STREQUAL "numpy")
+ set(_boost_DEPS "python\${component_python_version}")
+ set(library_component TRUE)
+ set(_boost_unprocessed_headers ${_boost_python_numpy_headers})
# Special-case since it is a serialization variant; look in boost/serialization
elseif(component STREQUAL "wserialization")
set(library_component TRUE)
file(GLOB_RECURSE _boost_unprocessed_headers
RELATIVE "${includedir}"
"${includedir}/boost/serialization/*")
- list(INSERT _boost_unprocessed_headers 0 "${includedir}/boost/serialization.hpp")
+ list(INSERT _boost_unprocessed_headers 0 "boost/serialization.hpp")
# Not really a library in its own right, but treat it as one
elseif(component STREQUAL "math")
set(library_component TRUE)
file(GLOB_RECURSE _boost_unprocessed_headers
RELATIVE "${includedir}"
"${includedir}/boost/math/*")
- list(INSERT _boost_unprocessed_headers 0 "${includedir}/boost/math.hpp")
+ list(INSERT _boost_unprocessed_headers 0 "boost/math.hpp")
# Single test header
elseif(component STREQUAL "unit_test_framework")
set(library_component TRUE)
@@ -79,7 +90,8 @@ function(_Boost_FIND_COMPONENT_DEPENDENCIES component includedir _ret_libs)
file(GLOB_RECURSE _boost_unprocessed_headers
RELATIVE "${includedir}"
"${includedir}/boost/${component}/*")
- list(INSERT _boost_unprocessed_headers 0 "${includedir}/boost/${component}.hpp")
+ list(INSERT _boost_unprocessed_headers 0 "boost/${component}.hpp")
+ list(REMOVE_ITEM _boost_unprocessed_headers ${_boost_mpi_python_headers} ${_boost_python_numpy_headers})
endif()
while(_boost_unprocessed_headers)
@@ -102,6 +114,8 @@ function(_Boost_FIND_COMPONENT_DEPENDENCIES component includedir _ret_libs)
foreach(line ${_boost_header_deps})
string(REGEX REPLACE "^[ \t]*#[ \t]*define[ \t][ \t]*BOOST_LIB_NAME[ \t][ \t]*boost_([^ \t][^ \t]*).*" "\\1" _boost_component_match "${line}")
+ string(REPLACE "python3" "python" _boost_component_match "${_boost_component_match}")
+ string(REPLACE "numpy3" "numpy" _boost_component_match "${_boost_component_match}")
list(FIND _boost_DEPS "${_boost_component_match}" _boost_dep_found)
if(_boost_component_match STREQUAL "bzip2" OR
_boost_component_match STREQUAL "zlib")
@@ -119,6 +133,12 @@ function(_Boost_FIND_COMPONENT_DEPENDENCIES component includedir _ret_libs)
# hard dependency (handle as special-case for mpi_python).
continue()
endif()
+ if(component STREQUAL "python" AND
+ boost_component_match STREQUAL "numpy")
+ # Optional python dependency; skip to avoid making it a
+ # hard dependency (handle as special-case for numpy).
+ continue()
+ endif()
if (_boost_dep_found EQUAL -1 AND
NOT "${_boost_component_match}" STREQUAL "${component}")
list(APPEND _boost_DEPS "${_boost_component_match}")
@@ -168,6 +188,11 @@ if(IS_DIRECTORY "${BOOST_DIR}/boost/mpi" AND
IS_DIRECTORY "${BOOST_DIR}/boost/python")
list(APPEND boost_components "mpi_python")
endif()
+# Special-case numpy, since it's a part of python
+if(IS_DIRECTORY "${BOOST_DIR}/boost/python" AND
+ IS_DIRECTORY "${BOOST_DIR}/boost/python/numpy")
+ list(APPEND boost_components "numpy")
+endif()
# Special-case wserialization, which is a variant of serialization
if(IS_DIRECTORY "${BOOST_DIR}/boost/serialization")
list(APPEND boost_components "wserialization")
diff --git a/Utilities/Scripts/clang-format.bash b/Utilities/Scripts/clang-format.bash
index edcda77b9..7ca4433a8 100755
--- a/Utilities/Scripts/clang-format.bash
+++ b/Utilities/Scripts/clang-format.bash
@@ -78,8 +78,8 @@ test "$#" = 0 || die "$usage"
# Find a default tool.
tools='
+ clang-format-6.0
clang-format
- clang-format-3.8
'
if test "x$clang_format" = "x"; then
for tool in $tools; do
@@ -92,7 +92,12 @@ fi
# Verify that we have a tool.
if ! type -p "$clang_format" >/dev/null; then
- echo "Unable to locate '$clang_format'"
+ echo "Unable to locate a 'clang-format' tool."
+ exit 1
+fi
+
+if ! "$clang_format" --version | grep 'clang-format version 6\.0' >/dev/null 2>/dev/null; then
+ echo "clang-format version 6.0 is required (exactly)"
exit 1
fi
@@ -110,8 +115,10 @@ esac
$git_ls |
# Select sources with our attribute.
- git check-attr --stdin format.clang-format |
- sed -n '/: format\.clang-format: set$/ {s/:[^:]*:[^:]*$//p}' |
+ git check-attr --stdin format.clang-format-6.0 |
+ grep -e ': format\.clang-format-6\.0: set$' |
+ sed -n 's/:[^:]*:[^:]*$//p' |
# Update sources in-place.
- xargs -d '\n' "$clang_format" -i
+ tr '\n' '\0' |
+ xargs -0 "$clang_format" -i
diff --git a/Utilities/Scripts/regenerate-lexers.bash b/Utilities/Scripts/regenerate-lexers.bash
new file mode 100755
index 000000000..1b61b705e
--- /dev/null
+++ b/Utilities/Scripts/regenerate-lexers.bash
@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+
+set -e
+
+forced=1
+if [[ "${1}" = "make" ]]; then
+ forced=0
+fi
+
+pushd "${BASH_SOURCE%/*}/../../Source/LexerParser" > /dev/null
+
+for lexer in \
+ CommandArgument \
+ CTestResourceGroups \
+ DependsJava \
+ Expr \
+ Fortran
+do
+ cxx_file=cm${lexer}Lexer.cxx
+ h_file=cm${lexer}Lexer.h
+ in_file=cm${lexer}Lexer.in.l
+
+ if [[ (${in_file} -nt ${cxx_file}) || (${in_file} -nt ${h_file}) || (${forced} -gt 0) ]]; then
+ echo "Generating Lexer ${lexer}"
+ flex --nounistd -DFLEXINT_H --noline --header-file=${h_file} -o${cxx_file} ${in_file}
+ sed -i 's/\s*$//' ${h_file} ${cxx_file} # remove trailing whitespaces
+ sed -i '${/^$/d;}' ${h_file} ${cxx_file} # remove blank line at the end
+ sed -i '1i#include "cmStandardLexer.h"' ${cxx_file} # add cmStandardLexer.h include
+ else
+ echo "Skipped generating Lexer ${lexer}"
+ fi
+done
+
+
+# these lexers (at the moment only the ListFileLexer) are compiled as C and do not generate a header
+for lexer in ListFile
+do
+ c_file=cm${lexer}Lexer.c
+ in_file=cm${lexer}Lexer.in.l
+
+ if [[ (${in_file} -nt ${c_file}) || (${forced} -gt 0) ]]; then
+ echo "Generating Lexer ${lexer}"
+ flex --nounistd -DFLEXINT_H --noline -o${c_file} ${in_file}
+ sed -i 's/\s*$//' ${c_file} # remove trailing whitespaces
+ sed -i '${/^$/d;}' ${c_file} # remove blank line at the end
+ sed -i '1i#include "cmStandardLexer.h"' ${c_file} # add cmStandardLexer.h include
+ else
+ echo "Skipped generating Lexer ${lexer}"
+ fi
+
+done
+
+popd > /dev/null
diff --git a/Utilities/Scripts/regenerate-parsers.bash b/Utilities/Scripts/regenerate-parsers.bash
new file mode 100755
index 000000000..6fb35c028
--- /dev/null
+++ b/Utilities/Scripts/regenerate-parsers.bash
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+set -e
+
+forced=1
+if [[ "${1}" = "make" ]]; then
+ forced=0
+fi
+
+pushd "${BASH_SOURCE%/*}/../../Source/LexerParser" > /dev/null
+
+for parser in \
+ CommandArgument \
+ DependsJava \
+ Expr \
+ Fortran
+do
+ in_file=cm${parser}Parser.y
+ cxx_file=cm${parser}Parser.cxx
+ h_file=cm${parser}ParserTokens.h
+ prefix=cm${parser}_yy
+
+ if [[ (${in_file} -nt ${cxx_file}) || (${in_file} -nt ${h_file}) || (${forced} -gt 0) ]]; then
+ echo "Generating Parser ${parser}"
+ bison --yacc --name-prefix=${prefix} --defines=${h_file} -o${cxx_file} ${in_file}
+ sed -i '/\/\* Else will try to reuse/ i\
+#if 0
+/^yyerrlab1:/ a\
+#endif
+' ${cxx_file}
+ else
+ echo "Skipped generating Parser ${parser}"
+ fi
+done
+
+
+popd > /dev/null
diff --git a/Utilities/Scripts/update-curl.bash b/Utilities/Scripts/update-curl.bash
index 465841a02..5c2a331c0 100755
--- a/Utilities/Scripts/update-curl.bash
+++ b/Utilities/Scripts/update-curl.bash
@@ -8,14 +8,13 @@ readonly name="curl"
readonly ownership="Curl Upstream <curl-library@cool.haxx.se>"
readonly subtree="Utilities/cmcurl"
readonly repo="https://github.com/curl/curl.git"
-readonly tag="curl-7_54_1"
+readonly tag="curl-7_65_0"
readonly shortlog=false
readonly paths="
CMake/*
CMakeLists.txt
COPYING
include/curl/*.h
- include/curl/curlbuild.h.cmake
lib/*.c
lib/*.h
lib/CMakeLists.txt
@@ -32,6 +31,15 @@ extract_source () {
git_archive
pushd "${extractdir}/${name}-reduced"
rm lib/config-*.h
+ chmod a-x lib/connect.c
+ for f in \
+ lib/cookie.c \
+ lib/krb5.c \
+ lib/security.c \
+ ; do
+ iconv -f LATIN1 -t UTF8 $f -o $f.utf-8
+ mv $f.utf-8 $f
+ done
echo "* -whitespace" > .gitattributes
popd
}
diff --git a/Utilities/Scripts/update-expat.bash b/Utilities/Scripts/update-expat.bash
index 4ac5ef32c..95c5a0f6e 100755
--- a/Utilities/Scripts/update-expat.bash
+++ b/Utilities/Scripts/update-expat.bash
@@ -8,7 +8,7 @@ readonly name="expat"
readonly ownership="Expat Upstream <kwrobot@kitware.com>"
readonly subtree="Utilities/cmexpat"
readonly repo="https://github.com/libexpat/libexpat.git"
-readonly tag="R_2_2_3"
+readonly tag="R_2_2_9"
readonly shortlog=false
readonly paths="
expat/lib/asciitab.h
@@ -18,7 +18,6 @@ readonly paths="
expat/lib/xmlrole.h
expat/lib/iasciitab.h
expat/lib/latin1tab.h
- expat/lib/loadlibrary.c
expat/lib/xmlrole.c
expat/lib/utf8tab.h
expat/lib/nametab.h
diff --git a/Utilities/Scripts/update-gitsetup.bash b/Utilities/Scripts/update-gitsetup.bash
index 8f0da7682..70fb16511 100755
--- a/Utilities/Scripts/update-gitsetup.bash
+++ b/Utilities/Scripts/update-gitsetup.bash
@@ -11,6 +11,13 @@ readonly repo="https://gitlab.kitware.com/utils/gitsetup.git"
readonly tag="setup"
readonly shortlog=false
readonly paths="
+ .gitattributes
+ LICENSE
+ NOTICE
+ README
+ setup-hooks
+ setup-user
+ tips
"
extract_source () {
diff --git a/Utilities/Scripts/update-jsoncpp.bash b/Utilities/Scripts/update-jsoncpp.bash
new file mode 100755
index 000000000..f8fe54462
--- /dev/null
+++ b/Utilities/Scripts/update-jsoncpp.bash
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+set -e
+set -x
+shopt -s dotglob
+
+readonly name="jsoncpp"
+readonly ownership="JsonCpp Upstream <kwrobot@kitware.com>"
+readonly subtree="Utilities/cmjsoncpp"
+readonly repo="https://github.com/open-source-parsers/jsoncpp.git"
+readonly tag="1.8.2"
+readonly shortlog=false
+readonly paths="
+ LICENSE
+ include/json
+ src/lib_json
+"
+readonly remove="
+ include/json/autolink.h
+ src/lib_json/CMakeLists.txt
+ src/lib_json/sconscript
+ src/lib_json/version.h.in
+"
+
+extract_source () {
+ git_archive
+ pushd "${extractdir}/${name}-reduced"
+ rm $remove
+ echo "* -whitespace" > .gitattributes
+ popd
+}
+
+. "${BASH_SOURCE%/*}/update-third-party.bash"
diff --git a/Utilities/Scripts/update-libarchive.bash b/Utilities/Scripts/update-libarchive.bash
index 41c6a66d6..31886584f 100755
--- a/Utilities/Scripts/update-libarchive.bash
+++ b/Utilities/Scripts/update-libarchive.bash
@@ -8,7 +8,7 @@ readonly name="LibArchive"
readonly ownership="LibArchive Upstream <libarchive-discuss@googlegroups.com>"
readonly subtree="Utilities/cmlibarchive"
readonly repo="https://github.com/libarchive/libarchive.git"
-readonly tag="v3.3.1"
+readonly tag="v3.3.3"
readonly shortlog=false
readonly paths="
CMakeLists.txt
diff --git a/Utilities/Scripts/update-liblzma.bash b/Utilities/Scripts/update-liblzma.bash
index 088eb91e0..fdf66b3ec 100755
--- a/Utilities/Scripts/update-liblzma.bash
+++ b/Utilities/Scripts/update-liblzma.bash
@@ -7,8 +7,8 @@ shopt -s dotglob
readonly name="liblzma"
readonly ownership="liblzma upstream <xz-devel@tukaani.org>"
readonly subtree="Utilities/cmliblzma"
-readonly repo="http://git.tukaani.org/xz.git"
-readonly tag="v5.0.8"
+readonly repo="https://git.tukaani.org/xz.git"
+readonly tag="v5.2.4"
readonly shortlog=false
readonly paths="
COPYING
@@ -24,6 +24,10 @@ extract_source () {
mv src/common .
mv src/liblzma .
rmdir src
+ rm liblzma/Makefile.*
+ rm liblzma/*/Makefile.*
+ rm liblzma/liblzma.map
+ rm liblzma/validate_map.sh
popd
}
diff --git a/Utilities/Scripts/update-libuv.bash b/Utilities/Scripts/update-libuv.bash
index d7a7d1f28..6d423a764 100755
--- a/Utilities/Scripts/update-libuv.bash
+++ b/Utilities/Scripts/update-libuv.bash
@@ -20,6 +20,8 @@ extract_source () {
git_archive
pushd "${extractdir}/${name}-reduced"
echo "* -whitespace" > .gitattributes
+ echo >> src/unix/aix-common.c
+ echo >> src/unix/ibmi.c
popd
}
diff --git a/Utilities/Scripts/update-third-party.bash b/Utilities/Scripts/update-third-party.bash
index 670946ef4..fcab871bd 100644
--- a/Utilities/Scripts/update-third-party.bash
+++ b/Utilities/Scripts/update-third-party.bash
@@ -71,8 +71,6 @@ warn () {
readonly regex_date='20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
readonly basehash_regex="$name $regex_date ([0-9a-f]*)"
-readonly basehash="$( git rev-list --author="$ownership" --grep="$basehash_regex" -n 1 HEAD )"
-readonly upstream_old_short="$( git cat-file commit "$basehash" | sed -n '/'"$basehash_regex"'/ {s/.*(//;s/)//;p}' | egrep '^[0-9a-f]+$' )"
########################################################################
# Sanity checking
@@ -87,6 +85,18 @@ readonly upstream_old_short="$( git cat-file commit "$basehash" | sed -n '/'"$ba
die "'repo' is empty"
[ -n "$tag" ] || \
die "'tag' is empty"
+
+# Check for an empty destination directory on disk. By checking on disk and
+# not in the repo it allows a library to be freshly re-inialized in a single
+# commit rather than first deleting the old copy in one commit and adding the
+# new copy in a seperate commit.
+if [ ! -d "$(git rev-parse --show-toplevel)/$subtree" ]; then
+ readonly basehash=""
+else
+ readonly basehash="$( git rev-list --author="$ownership" --grep="$basehash_regex" -n 1 HEAD )"
+fi
+readonly upstream_old_short="$( git cat-file commit "$basehash" | sed -n '/'"$basehash_regex"'/ {s/.*(//;s/)//;p}' | egrep '^[0-9a-f]+$' )"
+
[ -n "$basehash" ] || \
warn "'basehash' is empty; performing initial import"
readonly do_shortlog="${shortlog-false}"
@@ -104,6 +114,8 @@ trap "rm -rf '$workdir'" EXIT
git clone "$repo" "$upstreamdir"
if [ -n "$basehash" ]; then
+ # Remove old worktrees
+ git worktree prune
# Use the existing package's history
git worktree add "$extractdir" "$basehash"
# Clear out the working tree
@@ -163,13 +175,17 @@ popd
if [ -n "$basehash" ]; then
git merge --log -s recursive "-Xsubtree=$subtree/" --no-commit "upstream-$name"
else
+ # Note: on Windows 'git merge --help' will open a browser, and the check
+ # will fail, so use the flag by default.
unrelated_histories_flag=""
- if git merge --help | grep -q -e allow-unrelated-histories; then
+ if git --version | grep -q windows; then
+ unrelated_histories_flag="--allow-unrelated-histories "
+ elif git merge --help | grep -q -e allow-unrelated-histories; then
unrelated_histories_flag="--allow-unrelated-histories "
fi
readonly unrelated_histories_flag
- git fetch "$extractdir" "upstream-$name:upstream-$name"
+ git fetch "$extractdir" "+upstream-$name:upstream-$name"
git merge --log -s ours --no-commit $unrelated_histories_flag "upstream-$name"
git read-tree -u --prefix="$subtree/" "upstream-$name"
fi
diff --git a/Utilities/Scripts/update-zstd.bash b/Utilities/Scripts/update-zstd.bash
new file mode 100755
index 000000000..ce2c66b64
--- /dev/null
+++ b/Utilities/Scripts/update-zstd.bash
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+set -e
+set -x
+shopt -s dotglob
+
+readonly name="zstd"
+readonly ownership="zstd upstream <kwrobot@kitware.com>"
+readonly subtree="Utilities/cmzstd"
+readonly repo="https://github.com/facebook/zstd.git"
+readonly tag="v1.3.8"
+readonly shortlog=false
+readonly paths="
+ LICENSE
+ README.md
+ lib/common/*.c
+ lib/common/*.h
+ lib/compress/*.c
+ lib/compress/*.h
+ lib/decompress/*.c
+ lib/decompress/*.h
+ lib/deprecated/*.c
+ lib/deprecated/*.h
+ lib/dictBuilder/*.c
+ lib/dictBuilder/*.h
+ lib/zstd.h
+"
+
+extract_source () {
+ git_archive
+ pushd "${extractdir}/${name}-reduced"
+ echo "* -whitespace" > .gitattributes
+ popd
+}
+
+. "${BASH_SOURCE%/*}/update-third-party.bash"
diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt
index a29380c95..17c5018b2 100644
--- a/Utilities/Sphinx/CMakeLists.txt
+++ b/Utilities/Sphinx/CMakeLists.txt
@@ -3,11 +3,11 @@
if(NOT CMake_SOURCE_DIR)
set(CMakeHelp_STANDALONE 1)
- cmake_minimum_required(VERSION 2.8.12.2 FATAL_ERROR)
+ cmake_minimum_required(VERSION 3.1...3.15 FATAL_ERROR)
get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH)
get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH)
include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake)
- include(${CMake_SOURCE_DIR}/Source/CMakeVersionCompute.cmake)
+ include(${CMake_SOURCE_DIR}/Source/CMakeVersion.cmake)
include(${CMake_SOURCE_DIR}/Source/CMakeInstallDestinations.cmake)
unset(CMAKE_DATA_DIR)
unset(CMAKE_DATA_DIR CACHE)
@@ -17,6 +17,7 @@ if(NOT CMake_SOURCE_DIR)
endif()
project(CMakeHelp NONE)
+option(SPHINX_INFO "Build Info manual with Sphinx" OFF)
option(SPHINX_MAN "Build man pages with Sphinx" OFF)
option(SPHINX_HTML "Build html help with Sphinx" OFF)
option(SPHINX_SINGLEHTML "Build html single page help with Sphinx" OFF)
@@ -32,7 +33,7 @@ separate_arguments(sphinx_flags UNIX_COMMAND "${SPHINX_FLAGS}")
mark_as_advanced(SPHINX_TEXT)
mark_as_advanced(SPHINX_FLAGS)
-if(NOT SPHINX_MAN AND NOT SPHINX_HTML AND NOT SPHINX_SINGLEHTML AND NOT SPHINX_QTHELP AND NOT SPHINX_TEXT)
+if(NOT SPHINX_INFO AND NOT SPHINX_MAN AND NOT SPHINX_HTML AND NOT SPHINX_SINGLEHTML AND NOT SPHINX_QTHELP AND NOT SPHINX_TEXT)
return()
elseif(NOT SPHINX_EXECUTABLE)
message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!")
@@ -66,6 +67,24 @@ endif()
if(SPHINX_TEXT)
list(APPEND doc_formats text)
endif()
+if(SPHINX_INFO)
+ find_program(MAKEINFO_EXECUTABLE
+ NAMES makeinfo
+ DOC "makeinfo tool"
+ )
+ if (NOT MAKEINFO_EXECUTABLE)
+ message(FATAL_ERROR "MAKEINFO_EXECUTABLE (makeinfo) not found!")
+ endif()
+ list(APPEND doc_formats texinfo)
+
+ # Sphinx texinfo builder supports .info, .txt, .html and .pdf output.
+ # SPHINX_INFO controls the .info output.
+ set(texinfo_extra_commands
+ COMMAND ${MAKEINFO_EXECUTABLE} --no-split -o
+ ${CMAKE_CURRENT_BINARY_DIR}/texinfo/cmake.info
+ ${CMAKE_CURRENT_BINARY_DIR}/texinfo/cmake.texi
+ )
+endif()
if(SPHINX_QTHELP)
find_package(PythonInterp REQUIRED)
@@ -86,7 +105,6 @@ if(SPHINX_QTHELP)
# Workaround sphinx configurability:
# https://bitbucket.org/birkenfeld/sphinx/issue/1448/make-qthelp-more-configurable
COMMAND ${CMAKE_COMMAND} "-DQTHELP_DIR=${CMAKE_CURRENT_BINARY_DIR}/qthelp/"
- "-DCMake_VERSION=${CMake_VERSION_MAJOR}${CMake_VERSION_MINOR}${CMake_VERSION_PATCH}"
-P "${CMAKE_CURRENT_SOURCE_DIR}/fixup_qthelp_names.cmake"
# Create proper identifiers. Workaround for
@@ -143,6 +161,14 @@ if(CMake_SPHINX_DEPEND_ON_EXECUTABLES)
endforeach()
endif()
+if(SPHINX_INFO)
+ CMake_OPTIONAL_COMPONENT(sphinx-info)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/texinfo/cmake.info
+ DESTINATION ${CMAKE_INFO_DIR}
+ ${COMPONENT}
+ )
+endif()
+
if(SPHINX_MAN)
file(GLOB man_rst RELATIVE ${CMake_SOURCE_DIR}/Help/manual
${CMake_SOURCE_DIR}/Help/manual/*.[1-9].rst)
@@ -189,7 +215,7 @@ endif()
if(SPHINX_QTHELP)
CMake_OPTIONAL_COMPONENT(sphinx-qthelp)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake-${CMake_VERSION_MAJOR}${CMake_VERSION_MINOR}${CMake_VERSION_PATCH}.qch
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake.qch
DESTINATION ${CMAKE_DOC_DIR} ${COMPONENT}
)
endif()
diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py
index cfda2d479..d903dbe39 100644
--- a/Utilities/Sphinx/cmake.py
+++ b/Utilities/Sphinx/cmake.py
@@ -4,14 +4,58 @@
import os
import re
-# Monkey patch for pygments reporting an error when generator expressions are
-# used.
-# https://bitbucket.org/birkenfeld/pygments-main/issue/942/cmake-generator-expressions-not-handled
+# Override much of pygments' CMakeLexer.
+# We need to parse CMake syntax definitions, not CMake code.
+
+# For hard test cases that use much of the syntax below, see
+# - module/FindPkgConfig.html (with "glib-2.0>=2.10 gtk+-2.0" and similar)
+# - module/ExternalProject.html (with http:// https:// git@; also has command options -E --build)
+# - manual/cmake-buildsystem.7.html (with nested $<..>; relative and absolute paths, "::")
+
from pygments.lexers import CMakeLexer
-from pygments.token import Name, Operator
+from pygments.token import Name, Operator, Punctuation, String, Text, Comment, Generic, Whitespace, Number
from pygments.lexer import bygroups
-CMakeLexer.tokens["args"].append(('(\\$<)(.+?)(>)',
- bygroups(Operator, Name.Variable, Operator)))
+
+# Notes on regular expressions below:
+# - [\.\+-] are needed for string constants like gtk+-2.0
+# - Unix paths are recognized by '/'; support for Windows paths may be added if needed
+# - (\\.) allows for \-escapes (used in manual/cmake-language.7)
+# - $<..$<..$>..> nested occurence in cmake-buildsystem
+# - Nested variable evaluations are only supported in a limited capacity. Only
+# one level of nesting is supported and at most one nested variable can be present.
+
+CMakeLexer.tokens["root"] = [
+ (r'\b(\w+)([ \t]*)(\()', bygroups(Name.Function, Text, Name.Function), '#push'), # fctn(
+ (r'\(', Name.Function, '#push'),
+ (r'\)', Name.Function, '#pop'),
+ (r'\[', Punctuation, '#push'),
+ (r'\]', Punctuation, '#pop'),
+ (r'[|;,.=*\-]', Punctuation),
+ (r'\\\\', Punctuation), # used in commands/source_group
+ (r'[:]', Operator),
+ (r'[<>]=', Punctuation), # used in FindPkgConfig.cmake
+ (r'\$<', Operator, '#push'), # $<...>
+ (r'<[^<|]+?>(\w*\.\.\.)?', Name.Variable), # <expr>
+ (r'(\$\w*\{)([^\}\$]*)?(?:(\$\w*\{)([^\}]+?)(\}))?([^\}]*?)(\})', # ${..} $ENV{..}, possibly nested
+ bygroups(Operator, Name.Tag, Operator, Name.Tag, Operator, Name.Tag, Operator)),
+ (r'([A-Z]+\{)(.+?)(\})', bygroups(Operator, Name.Tag, Operator)), # DATA{ ...}
+ (r'[a-z]+(@|(://))((\\.)|[\w.+-:/\\])+', Name.Attribute), # URL, git@, ...
+ (r'/\w[\w\.\+-/\\]*', Name.Attribute), # absolute path
+ (r'/', Name.Attribute),
+ (r'\w[\w\.\+-]*/[\w.+-/\\]*', Name.Attribute), # relative path
+ (r'[A-Z]((\\.)|[\w.+-])*[a-z]((\\.)|[\w.+-])*', Name.Builtin), # initial A-Z, contains a-z
+ (r'@?[A-Z][A-Z0-9_]*', Name.Constant),
+ (r'[a-z_]((\\;)|(\\ )|[\w.+-])*', Name.Builtin),
+ (r'[0-9][0-9\.]*', Number),
+ (r'(?s)"(\\"|[^"])*"', String), # "string"
+ (r'\.\.\.', Name.Variable),
+ (r'<', Operator, '#push'), # <..|..> is different from <expr>
+ (r'>', Operator, '#pop'),
+ (r'\n', Whitespace),
+ (r'[ \t]+', Whitespace),
+ (r'#.*\n', Comment),
+ # (r'[^<>\])\}\|$"# \t\n]+', Name.Exception), # fallback, for debugging only
+]
# Monkey patch for sphinx generating invalid content for qcollectiongenerator
# https://bitbucket.org/birkenfeld/sphinx/issue/1435/qthelp-builder-should-htmlescape-keywords
@@ -144,6 +188,8 @@ class _cmake_index_entry:
_cmake_index_objs = {
'command': _cmake_index_entry('command'),
+ 'cpack_gen': _cmake_index_entry('cpack generator'),
+ 'envvar': _cmake_index_entry('envvar'),
'generator': _cmake_index_entry('generator'),
'manual': _cmake_index_entry('manual'),
'module': _cmake_index_entry('module'),
@@ -278,7 +324,7 @@ class CMakeXRefRole(XRefRole):
# We cannot insert index nodes using the result_nodes method
# because CMakeXRefRole is processed before substitution_reference
# nodes are evaluated so target nodes (with 'ids' fields) would be
- # duplicated in each evaluted substitution replacement. The
+ # duplicated in each evaluated substitution replacement. The
# docutils substitution transform does not allow this. Instead we
# use our own CMakeXRefTransform below to add index entries after
# substitutions are completed.
@@ -324,6 +370,8 @@ class CMakeDomain(Domain):
label = 'CMake'
object_types = {
'command': ObjType('command', 'command'),
+ 'cpack_gen': ObjType('cpack_gen', 'cpack_gen'),
+ 'envvar': ObjType('envvar', 'envvar'),
'generator': ObjType('generator', 'generator'),
'variable': ObjType('variable', 'variable'),
'module': ObjType('module', 'module'),
@@ -339,6 +387,7 @@ class CMakeDomain(Domain):
}
directives = {
'command': CMakeObject,
+ 'envvar': CMakeObject,
'variable': CMakeObject,
# Other object types cannot be created except by the CMakeTransform
# 'generator': CMakeObject,
@@ -355,6 +404,8 @@ class CMakeDomain(Domain):
}
roles = {
'command': CMakeXRefRole(fix_parens = True, lowercase = True),
+ 'cpack_gen': CMakeXRefRole(),
+ 'envvar': CMakeXRefRole(),
'generator': CMakeXRefRole(),
'variable': CMakeXRefRole(),
'module': CMakeXRefRole(),
diff --git a/Utilities/Sphinx/colors.py b/Utilities/Sphinx/colors.py
new file mode 100644
index 000000000..dae00634e
--- /dev/null
+++ b/Utilities/Sphinx/colors.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+
+from pygments.style import Style
+from pygments.token import Name, Comment, String, Number, Operator, Whitespace
+
+class CMakeTemplateStyle(Style):
+ """
+ for more token names, see pygments/styles.default
+ """
+
+ background_color = "#f8f8f8"
+ default_style = ""
+
+ styles = {
+ Whitespace: "#bbbbbb",
+ Comment: "italic #408080",
+ Operator: "#555555",
+ String: "#217A21",
+ Number: "#105030",
+ Name.Builtin: "#333333", # anything lowercase
+ Name.Function: "#007020", # function
+ Name.Variable: "#1080B0", # <..>
+ Name.Tag: "#bb60d5", # ${..}
+ Name.Constant: "#4070a0", # uppercase only
+ Name.Entity: "italic #70A020", # @..@
+ Name.Attribute: "#906060", # paths, URLs
+ Name.Label: "#A0A000", # anything left over
+ Name.Exception: "bold #FF0000", # for debugging only
+ }
diff --git a/Utilities/Sphinx/conf.py.in b/Utilities/Sphinx/conf.py.in
index 7878ad20a..e50c4f99b 100644
--- a/Utilities/Sphinx/conf.py.in
+++ b/Utilities/Sphinx/conf.py.in
@@ -15,8 +15,10 @@ project = 'CMake'
copyright = '@conf_copyright@'
version = '@conf_version@' # feature version
release = '@conf_release@' # full version string
+pygments_style = 'colors.CMakeTemplateStyle'
primary_domain = 'cmake'
+highlight_language = 'none'
exclude_patterns = [
'dev', # ignore developer-only documentation
@@ -80,4 +82,4 @@ html_favicon = '@conf_path@/static/cmake-favicon.ico'
# Not supported yet by sphinx:
# https://bitbucket.org/birkenfeld/sphinx/issue/1448/make-qthelp-more-configurable
# qthelp_namespace = "org.cmake"
-# qthelp_qch_name = "CMake-300.qch"
+# qthelp_qch_name = "CMake.qch"
diff --git a/Utilities/Sphinx/create_identifiers.py b/Utilities/Sphinx/create_identifiers.py
index 3fe3fcbe5..6716b480d 100755
--- a/Utilities/Sphinx/create_identifiers.py
+++ b/Utilities/Sphinx/create_identifiers.py
@@ -21,7 +21,10 @@ newlines = []
for line in lines:
mapping = (("command", "command"),
+ ("cpack generator", "cpack_gen"),
+ ("envvar", "envvar"),
("variable", "variable"),
+ ("generator", "generator"),
("target property", "prop_tgt"),
("test property", "prop_test"),
("source file property", "prop_sf"),
diff --git a/Utilities/Sphinx/fixup_qthelp_names.cmake b/Utilities/Sphinx/fixup_qthelp_names.cmake
index e35ef25be..179e84680 100644
--- a/Utilities/Sphinx/fixup_qthelp_names.cmake
+++ b/Utilities/Sphinx/fixup_qthelp_names.cmake
@@ -10,15 +10,6 @@ string(REPLACE
QHCP_CONTENT "${QHCP_CONTENT}"
)
-string(REPLACE
- "<output>CMake.qch" "<output>CMake-${CMake_VERSION}.qch"
- QHCP_CONTENT "${QHCP_CONTENT}"
-)
-string(REPLACE
- "<file>CMake.qch" "<file>CMake-${CMake_VERSION}.qch"
- QHCP_CONTENT "${QHCP_CONTENT}"
-)
-
file(WRITE "${QTHELP_DIR}/CMake.qhcp" "${QHCP_CONTENT}")
diff --git a/Utilities/Sphinx/static/cmake-favicon.ico b/Utilities/Sphinx/static/cmake-favicon.ico
index fce8f922f..ae529f54e 100644
--- a/Utilities/Sphinx/static/cmake-favicon.ico
+++ b/Utilities/Sphinx/static/cmake-favicon.ico
Binary files differ
diff --git a/Utilities/Sphinx/static/cmake-logo-16.png b/Utilities/Sphinx/static/cmake-logo-16.png
index 2039c25b0..db9458dc1 100644
--- a/Utilities/Sphinx/static/cmake-logo-16.png
+++ b/Utilities/Sphinx/static/cmake-logo-16.png
Binary files differ
diff --git a/Utilities/Sphinx/static/cmake.css b/Utilities/Sphinx/static/cmake.css
index 2a326d47d..b082edec8 100644
--- a/Utilities/Sphinx/static/cmake.css
+++ b/Utilities/Sphinx/static/cmake.css
@@ -6,3 +6,13 @@
div.sphinxsidebarwrapper {
word-wrap: break-word;
}
+
+/* Make links inside parsed-literal blocks more obvious
+ by using a background color and increased line spacing
+ to make them look boxed. */
+.literal-block {
+ line-height: 1.4;
+}
+.literal-block a.reference.internal {
+ background-color: #dfdfdf;
+}
diff --git a/Utilities/cmThirdParty.h.in b/Utilities/cmThirdParty.h.in
index a547f0da7..1456e34c7 100644
--- a/Utilities/cmThirdParty.h.in
+++ b/Utilities/cmThirdParty.h.in
@@ -15,6 +15,6 @@
#cmakedefine CMAKE_USE_SYSTEM_JSONCPP
#cmakedefine CMAKE_USE_SYSTEM_LIBRHASH
#cmakedefine CMAKE_USE_SYSTEM_LIBUV
-#cmakedefine CTEST_USE_XMLRPC
+#cmakedefine CMAKE_USE_SYSTEM_ZSTD
#endif
diff --git a/Utilities/cm_bzlib.h b/Utilities/cm_bzlib.h
index e7f6d8990..8669e9e6e 100644
--- a/Utilities/cm_bzlib.h
+++ b/Utilities/cm_bzlib.h
@@ -6,9 +6,9 @@
/* Use the bzip2 library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_BZIP2
-#include <bzlib.h>
+# include <bzlib.h>
#else
-#include <cmbzip2/bzlib.h>
+# include <cmbzip2/bzlib.h>
#endif
#endif
diff --git a/Utilities/cm_curl.h b/Utilities/cm_curl.h
index fc2b8ab8a..673f8ad95 100644
--- a/Utilities/cm_curl.h
+++ b/Utilities/cm_curl.h
@@ -6,9 +6,9 @@
/* Use the curl library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_CURL
-#include <curl/curl.h>
+# include <curl/curl.h>
#else
-#include <cmcurl/include/curl/curl.h>
+# include <cmcurl/include/curl/curl.h>
#endif
#endif
diff --git a/Utilities/cm_expat.h b/Utilities/cm_expat.h
index d87933715..fc5b39aba 100644
--- a/Utilities/cm_expat.h
+++ b/Utilities/cm_expat.h
@@ -6,9 +6,9 @@
/* Use the expat library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_EXPAT
-#include <expat.h>
+# include <expat.h>
#else
-#include <cmexpat/lib/expat.h>
+# include <cmexpat/lib/expat.h>
#endif
#endif
diff --git a/Utilities/cm_jsoncpp_reader.h b/Utilities/cm_jsoncpp_reader.h
index e78ec1e0c..23af65c61 100644
--- a/Utilities/cm_jsoncpp_reader.h
+++ b/Utilities/cm_jsoncpp_reader.h
@@ -6,9 +6,9 @@
/* Use the jsoncpp library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_JSONCPP
-#include <json/reader.h>
+# include <json/reader.h>
#else
-#include <cmjsoncpp/include/json/reader.h>
+# include <cmjsoncpp/include/json/reader.h>
#endif
#endif
diff --git a/Utilities/cm_jsoncpp_value.h b/Utilities/cm_jsoncpp_value.h
index cf3775859..742d99a01 100644
--- a/Utilities/cm_jsoncpp_value.h
+++ b/Utilities/cm_jsoncpp_value.h
@@ -6,9 +6,9 @@
/* Use the jsoncpp library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_JSONCPP
-#include <json/value.h>
+# include <json/value.h>
#else
-#include <cmjsoncpp/include/json/value.h>
+# include <cmjsoncpp/include/json/value.h>
#endif
#endif
diff --git a/Utilities/cm_jsoncpp_writer.h b/Utilities/cm_jsoncpp_writer.h
index 33b246847..d9e5d8217 100644
--- a/Utilities/cm_jsoncpp_writer.h
+++ b/Utilities/cm_jsoncpp_writer.h
@@ -6,9 +6,9 @@
/* Use the jsoncpp library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_JSONCPP
-#include <json/writer.h>
+# include <json/writer.h>
#else
-#include <cmjsoncpp/include/json/writer.h>
+# include <cmjsoncpp/include/json/writer.h>
#endif
#endif
diff --git a/Utilities/cm_kwiml.h b/Utilities/cm_kwiml.h
index 65cb35f96..566f67e43 100644
--- a/Utilities/cm_kwiml.h
+++ b/Utilities/cm_kwiml.h
@@ -6,11 +6,11 @@
/* Use the KWIML library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_KWIML
-#include <kwiml/abi.h>
-#include <kwiml/int.h>
+# include <kwiml/abi.h>
+# include <kwiml/int.h>
#else
-#include "KWIML/include/kwiml/abi.h"
-#include "KWIML/include/kwiml/int.h"
+# include "KWIML/include/kwiml/abi.h"
+# include "KWIML/include/kwiml/int.h"
#endif
#endif
diff --git a/Utilities/cm_libarchive.h b/Utilities/cm_libarchive.h
index 226952601..ea8e9db62 100644
--- a/Utilities/cm_libarchive.h
+++ b/Utilities/cm_libarchive.h
@@ -6,11 +6,11 @@
/* Use the libarchive configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_LIBARCHIVE
-#include <archive.h>
-#include <archive_entry.h>
+# include <archive.h>
+# include <archive_entry.h>
#else
-#include <cmlibarchive/libarchive/archive.h>
-#include <cmlibarchive/libarchive/archive_entry.h>
+# include <cmlibarchive/libarchive/archive.h>
+# include <cmlibarchive/libarchive/archive_entry.h>
#endif
#endif
diff --git a/Utilities/cm_lzma.h b/Utilities/cm_lzma.h
index 013c724b9..0526036c6 100644
--- a/Utilities/cm_lzma.h
+++ b/Utilities/cm_lzma.h
@@ -6,9 +6,9 @@
/* Use the liblzma configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_LIBLZMA
-#include <lzma.h>
+# include <lzma.h>
#else
-#include <cmliblzma/liblzma/api/lzma.h>
+# include <cmliblzma/liblzma/api/lzma.h>
#endif
#endif
diff --git a/Utilities/cm_rhash.h b/Utilities/cm_rhash.h
index c79362775..03d9871f7 100644
--- a/Utilities/cm_rhash.h
+++ b/Utilities/cm_rhash.h
@@ -6,9 +6,9 @@
/* Use the LibRHash library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_LIBRHASH
-#include <rhash.h>
+# include <rhash.h>
#else
-#include <cmlibrhash/librhash/rhash.h>
+# include <cmlibrhash/librhash/rhash.h>
#endif
#endif
diff --git a/Utilities/cm_uv.h b/Utilities/cm_uv.h
index 6d4813de1..448f30d8d 100644
--- a/Utilities/cm_uv.h
+++ b/Utilities/cm_uv.h
@@ -6,9 +6,9 @@
/* Use the libuv library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_LIBUV
-#include <uv.h>
+# include <uv.h>
#else
-#include <cmlibuv/include/uv.h>
+# include <cmlibuv/include/uv.h>
#endif
#endif
diff --git a/Utilities/cm_xmlrpc.h b/Utilities/cm_xmlrpc.h
deleted file mode 100644
index 08db89f60..000000000
--- a/Utilities/cm_xmlrpc.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cm_xmlrpc_h
-#define cm_xmlrpc_h
-
-/* Use the xmlrpc library configured for CMake. */
-#include "cmThirdParty.h"
-#ifdef CTEST_USE_XMLRPC
-#include <xmlrpc.h>
-#include <xmlrpc_client.h>
-#endif
-
-#endif
diff --git a/Utilities/cm_zlib.h b/Utilities/cm_zlib.h
index 2aee9f194..2314183b1 100644
--- a/Utilities/cm_zlib.h
+++ b/Utilities/cm_zlib.h
@@ -6,9 +6,9 @@
/* Use the zlib library configured for CMake. */
#include "cmThirdParty.h"
#ifdef CMAKE_USE_SYSTEM_ZLIB
-#include <zlib.h>
+# include <zlib.h>
#else
-#include <cmzlib/zlib.h>
+# include <cmzlib/zlib.h>
#endif
#endif
diff --git a/Utilities/cm_zstd.h b/Utilities/cm_zstd.h
new file mode 100644
index 000000000..4bda996aa
--- /dev/null
+++ b/Utilities/cm_zstd.h
@@ -0,0 +1,14 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cm_zstd_h
+#define cm_zstd_h
+
+/* Use the libzstd configured for CMake. */
+#include "cmThirdParty.h"
+#ifdef CMAKE_USE_SYSTEM_ZSTD
+# include <zstd.h>
+#else
+# include <cmzstd/lib/zstd.h>
+#endif
+
+#endif
diff --git a/Utilities/cmbzip2/dlltest.dsp b/Utilities/cmbzip2/dlltest.dsp
deleted file mode 100644
index 4b1615edc..000000000
--- a/Utilities/cmbzip2/dlltest.dsp
+++ /dev/null
@@ -1,93 +0,0 @@
-# Microsoft Developer Studio Project File - Name="dlltest" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** •ÒW‚µ‚È‚¢‚Å‚­‚¾‚³‚¢ **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=dlltest - Win32 Debug
-!MESSAGE ‚±‚ê‚Í—LŒø‚ÈÒ²¸Ì§²Ù‚Å‚Í‚ ‚è‚Ü‚¹‚ñB ‚±‚ÌÌßÛ¼Þª¸Ä‚ðËÞÙÄÞ‚·‚邽‚ß‚É‚Í NMAKE ‚ðŽg—p‚µ‚Ä‚­‚¾‚³‚¢B
-!MESSAGE [Ò²¸Ì§²Ù‚Ì´¸½Îß°Ä] ºÏÝÄÞ‚ðŽg—p‚µ‚ÄŽÀs‚µ‚Ä‚­‚¾‚³‚¢
-!MESSAGE
-!MESSAGE NMAKE /f "dlltest.mak".
-!MESSAGE
-!MESSAGE NMAKE ‚ÌŽÀsŽž‚É\¬‚ðŽw’è‚Å‚«‚Ü‚·
-!MESSAGE ºÏÝÄÞ ×²Ýã‚ÅϸۂÌÝ’è‚ð’è‹`‚µ‚Ü‚·B—á:
-!MESSAGE
-!MESSAGE NMAKE /f "dlltest.mak" CFG="dlltest - Win32 Debug"
-!MESSAGE
-!MESSAGE ‘I‘ð‰Â”\‚ÈËÞÙÄÞ Ó°ÄÞ:
-!MESSAGE
-!MESSAGE "dlltest - Win32 Release" ("Win32 (x86) Console Application" —p)
-!MESSAGE "dlltest - Win32 Debug" ("Win32 (x86) Console Application" —p)
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "dlltest - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x411 /d "NDEBUG"
-# ADD RSC /l 0x411 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"minibz2.exe"
-
-!ELSEIF "$(CFG)" == "dlltest - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "dlltest_"
-# PROP BASE Intermediate_Dir "dlltest_"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "dlltest_"
-# PROP Intermediate_Dir "dlltest_"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x411 /d "_DEBUG"
-# ADD RSC /l 0x411 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"minibz2.exe" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "dlltest - Win32 Release"
-# Name "dlltest - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\bzlib.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\dlltest.c
-# End Source File
-# End Target
-# End Project
diff --git a/Utilities/cmbzip2/libbz2.dsp b/Utilities/cmbzip2/libbz2.dsp
deleted file mode 100644
index a21a20f75..000000000
--- a/Utilities/cmbzip2/libbz2.dsp
+++ /dev/null
@@ -1,130 +0,0 @@
-# Microsoft Developer Studio Project File - Name="libbz2" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** •ÒW‚µ‚È‚¢‚Å‚­‚¾‚³‚¢ **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=libbz2 - Win32 Debug
-!MESSAGE ‚±‚ê‚Í—LŒø‚ÈÒ²¸Ì§²Ù‚Å‚Í‚ ‚è‚Ü‚¹‚ñB ‚±‚ÌÌßÛ¼Þª¸Ä‚ðËÞÙÄÞ‚·‚邽‚ß‚É‚Í NMAKE ‚ðŽg—p‚µ‚Ä‚­‚¾‚³‚¢B
-!MESSAGE [Ò²¸Ì§²Ù‚Ì´¸½Îß°Ä] ºÏÝÄÞ‚ðŽg—p‚µ‚ÄŽÀs‚µ‚Ä‚­‚¾‚³‚¢
-!MESSAGE
-!MESSAGE NMAKE /f "libbz2.mak".
-!MESSAGE
-!MESSAGE NMAKE ‚ÌŽÀsŽž‚É\¬‚ðŽw’è‚Å‚«‚Ü‚·
-!MESSAGE ºÏÝÄÞ ×²Ýã‚ÅϸۂÌÝ’è‚ð’è‹`‚µ‚Ü‚·B—á:
-!MESSAGE
-!MESSAGE NMAKE /f "libbz2.mak" CFG="libbz2 - Win32 Debug"
-!MESSAGE
-!MESSAGE ‘I‘ð‰Â”\‚ÈËÞÙÄÞ Ó°ÄÞ:
-!MESSAGE
-!MESSAGE "libbz2 - Win32 Release" ("Win32 (x86) Dynamic-Link Library" —p)
-!MESSAGE "libbz2 - Win32 Debug" ("Win32 (x86) Dynamic-Link Library" —p)
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "libbz2 - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
-# ADD BASE RSC /l 0x411 /d "NDEBUG"
-# ADD RSC /l 0x411 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"libbz2.dll"
-
-!ELSEIF "$(CFG)" == "libbz2 - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
-# ADD BASE RSC /l 0x411 /d "_DEBUG"
-# ADD RSC /l 0x411 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"libbz2.dll" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "libbz2 - Win32 Release"
-# Name "libbz2 - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\blocksort.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\bzlib.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\bzlib.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\bzlib_private.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\compress.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\crctable.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\decompress.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\huffman.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\libbz2.def
-# End Source File
-# Begin Source File
-
-SOURCE=.\randtable.c
-# End Source File
-# End Target
-# End Project
diff --git a/Utilities/cmcompress/CMakeLists.txt b/Utilities/cmcompress/CMakeLists.txt
deleted file mode 100644
index 806357327..000000000
--- a/Utilities/cmcompress/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-PROJECT(CMCompress)
-
-ADD_LIBRARY(cmcompress cmcompress.c)
-
-INSTALL(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR}/cmcompress)
diff --git a/Utilities/cmcompress/Copyright.txt b/Utilities/cmcompress/Copyright.txt
deleted file mode 100644
index 162332f69..000000000
--- a/Utilities/cmcompress/Copyright.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-Copyright (c) 1985, 1986 The Regents of the University of California.
-All rights reserved.
-
-This code is derived from software contributed to Berkeley by
-James A. Woods, derived from original work by Spencer Thomas
-and Joseph Orost.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-3. All advertising materials mentioning features or use of this software
- must display the following acknowledgement:
- This product includes software developed by the University of
- California, Berkeley and its contributors.
-4. Neither the name of the University nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGE.
diff --git a/Utilities/cmcompress/cmcompress.c b/Utilities/cmcompress/cmcompress.c
deleted file mode 100644
index ea845ed5f..000000000
--- a/Utilities/cmcompress/cmcompress.c
+++ /dev/null
@@ -1,551 +0,0 @@
-/*
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * James A. Woods, derived from original work by Spencer Thomas
- * and Joseph Orost.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "cmcompress.h"
-
-#include <errno.h>
-#include <string.h>
-
-static const char_type magic_header[] = { "\037\235" }; /* 1F 9D */
-
-/* Defines for third byte of header */
-#define BIT_MASK 0x1f
-#define BLOCK_MASK 0x80
-#define CHECK_GAP 10000 /* ratio check interval */
-/* Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is
- a fourth header byte (for expansion).
- */
-#define INIT_BITS 9 /* initial number of bits/code */
-
-#ifdef COMPATIBLE /* But wrong! */
-# define MAXCODE(n_bits) (1 << (n_bits) - 1)
-#else
-# define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
-#endif /* COMPATIBLE */
-
-#define htabof(i) cdata->htab[i]
-#define codetabof(i) cdata->codetab[i]
-
-/*
- * the next two codes should not be changed lightly, as they must not
- * lie within the contiguous general code space.
- */
-#define FIRST 257 /* first free entry */
-#define CLEAR 256 /* table clear output code */
-
-#ifdef DEBUG
-static void prratio( FILE *stream, long int num, long int den);
-#endif
-
-int cmcompress_compress_initialize(struct cmcompress_stream* cdata)
-{
- cdata->maxbits = BITS; /* user settable max # bits/code */
- cdata->maxmaxcode = 1 << BITS; /* should NEVER generate this code */
- cdata->hsize = HSIZE; /* for dynamic table sizing */
- cdata->free_ent = 0; /* first unused entry */
- cdata->nomagic = 0; /* Use a 3-byte magic number header, unless old file */
- cdata->block_compress = BLOCK_MASK;
- cdata->clear_flg = 0;
- cdata->ratio = 0;
- cdata->checkpoint = CHECK_GAP;
-
- cdata->input_stream = 0;
- cdata->output_stream = 0;
- cdata->client_data = 0;
- return 1;
-}
-
-static void cl_hash(struct cmcompress_stream* cdata, count_int hsize) /* reset code table */
-{
- register count_int *htab_p = cdata->htab+hsize;
- register long i;
- register long m1 = -1;
-
- i = hsize - 16;
- do
- { /* might use Sys V memset(3) here */
- *(htab_p-16) = m1;
- *(htab_p-15) = m1;
- *(htab_p-14) = m1;
- *(htab_p-13) = m1;
- *(htab_p-12) = m1;
- *(htab_p-11) = m1;
- *(htab_p-10) = m1;
- *(htab_p-9) = m1;
- *(htab_p-8) = m1;
- *(htab_p-7) = m1;
- *(htab_p-6) = m1;
- *(htab_p-5) = m1;
- *(htab_p-4) = m1;
- *(htab_p-3) = m1;
- *(htab_p-2) = m1;
- *(htab_p-1) = m1;
- htab_p -= 16;
- }
- while ((i -= 16) >= 0);
- for ( i += 16; i > 0; i-- )
- {
- *--htab_p = m1;
- }
-}
-
-/*-
- * Output the given code.
- * Inputs:
- * code: A n_bits-bit integer. If == -1, then EOF. This assumes
- * that n_bits =< (long)wordsize - 1.
- * Outputs:
- * Outputs code to the file.
- * Assumptions:
- * Chars are 8 bits long.
- * Algorithm:
- * Maintain a BITS character long buffer (so that 8 codes will
- * fit in it exactly). Use the VAX insv instruction to insert each
- * code in turn. When the buffer fills up empty it and start over.
- */
-
-static char buf[BITS];
-
-#ifndef vax
-char_type lmask[9] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00};
-char_type rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
-#endif /* vax */
-
-static int output(struct cmcompress_stream* cdata, code_int code)
-{
-#ifdef DEBUG
- static int col = 0;
-#endif /* DEBUG */
-
- /*
- * On the VAX, it is important to have the register declarations
- * in exactly the order given, or the asm will break.
- */
- register int r_off = cdata->offset, bits= cdata->n_bits;
- register char * bp = buf;
-
-#ifdef DEBUG
- if ( verbose )
- {
- fprintf( stderr, "%5d%c", code,
- (col+=6) >= 74 ? (col = 0, '\n') : ' ' );
- }
-#endif /* DEBUG */
- if ( code >= 0 )
- {
-#if defined(vax) && !defined(__GNUC__)
- /*
- * VAX and PCC DEPENDENT!! Implementation on other machines is
- * below.
- *
- * Translation: Insert BITS bits from the argument starting at
- * cdata->offset bits from the beginning of buf.
- */
- 0; /* Work around for pcc -O bug with asm and if stmt */
- asm( "insv 4(ap),r11,r10,(r9)" );
-#else
- /*
- * byte/bit numbering on the VAX is simulated by the following code
- */
- /*
- * Get to the first byte.
- */
- bp += (r_off >> 3);
- r_off &= 7;
- /*
- * Since code is always >= 8 bits, only need to mask the first
- * hunk on the left.
- */
- *bp = (char)((*bp & rmask[r_off]) | ((code << r_off) & lmask[r_off]));
- bp++;
- bits -= (8 - r_off);
- code >>= 8 - r_off;
- /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
- if ( bits >= 8 )
- {
- *bp++ = (char)(code);
- code >>= 8;
- bits -= 8;
- }
- /* Last bits. */
- if(bits)
- {
- *bp = (char)(code);
- }
-#endif /* vax */
- cdata->offset += cdata->n_bits;
- if ( cdata->offset == (cdata->n_bits << 3) )
- {
- bp = buf;
- bits = cdata->n_bits;
- cdata->bytes_out += bits;
- do
- {
- if ( cdata->output_stream(cdata, bp, 1) != 1 )
- {
- return 0;
- }
- bp++;
- }
- while(--bits);
- cdata->offset = 0;
- }
-
- /*
- * If the next entry is going to be too big for the code size,
- * then increase it, if possible.
- */
- if ( cdata->free_ent > cdata->maxcode || (cdata->clear_flg > 0))
- {
- /*
- * Write the whole buffer, because the input side won't
- * discover the size increase until after it has read it.
- */
- if ( cdata->offset > 0 )
- {
- if ( cdata->output_stream(cdata, buf, cdata->n_bits) != cdata->n_bits )
- {
- return 0;
- }
- cdata->bytes_out += cdata->n_bits;
- }
- cdata->offset = 0;
-
- if ( cdata->clear_flg )
- {
- cdata->maxcode = MAXCODE (cdata->n_bits = INIT_BITS);
- cdata->clear_flg = 0;
- }
- else
- {
- cdata->n_bits++;
- if ( cdata->n_bits == cdata->maxbits )
- {
- cdata->maxcode = cdata->maxmaxcode;
- }
- else
- {
- cdata->maxcode = MAXCODE(cdata->n_bits);
- }
- }
-#ifdef DEBUG
- if ( debug )
- {
- fprintf( stderr, "\nChange to %d bits\n", cdata->n_bits );
- col = 0;
- }
-#endif /* DEBUG */
- }
- }
- else
- {
- /*
- * At EOF, write the rest of the buffer.
- */
- if ( cdata->offset > 0 )
- {
- cdata->offset = (cdata->offset + 7) / 8;
- if ( cdata->output_stream(cdata, buf, cdata->offset ) != cdata->offset )
- {
- return 0;
- }
- cdata->bytes_out += cdata->offset;
- }
- cdata->offset = 0;
- (void)fflush( stdout );
- if( ferror( stdout ) )
- {
- return 0;
- }
-#ifdef DEBUG
- if ( verbose )
- {
- fprintf( stderr, "\n" );
- }
-#endif
- }
- return 1;
-}
-
-/*
- * compress stdin to stdout
- *
- * Algorithm: use open addressing double hashing (no chaining) on the
- * prefix code / next character combination. We do a variant of Knuth's
- * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
- * secondary probe. Here, the modular division first probe is gives way
- * to a faster exclusive-or manipulation. Also do block compression with
- * an adaptive reset, whereby the code table is cleared when the compression
- * ratio decreases, but after the table fills. The variable-length output
- * codes are re-sized at this point, and a special CLEAR code is generated
- * for the decompressor. Late addition: construct the table according to
- * file size for noticeable speed improvement on small files. Please direct
- * questions about this implementation to ames!jaw.
- */
-
-int cmcompress_compress_start(struct cmcompress_stream* cdata)
-{
-#ifndef COMPATIBLE
- if (cdata->nomagic == 0)
- {
- char headLast = (char)(cdata->maxbits | cdata->block_compress);
- cdata->output_stream(cdata, (const char*)magic_header, 2);
- cdata->output_stream(cdata, &headLast, 1);
- if(ferror(stdout))
- {
- printf("Error...\n");
- }
- }
-#endif /* COMPATIBLE */
-
- cdata->offset = 0;
- cdata->bytes_out = 3; /* includes 3-byte header mojo */
- cdata->out_count = 0;
- cdata->clear_flg = 0;
- cdata->ratio = 0;
- cdata->in_count = 1;
- cdata->checkpoint = CHECK_GAP;
- cdata->maxcode = MAXCODE(cdata->n_bits = INIT_BITS);
- cdata->free_ent = ((cdata->block_compress) ? FIRST : 256 );
-
- cdata->first_pass = 1;
-
- cdata->hshift = 0;
- for ( cdata->fcode = (long) cdata->hsize; cdata->fcode < 65536L; cdata->fcode *= 2L )
- {
- cdata->hshift++;
- }
- cdata->hshift = 8 - cdata->hshift; /* set hash code range bound */
-
- cdata->hsize_reg = cdata->hsize;
- cl_hash(cdata, (count_int) cdata->hsize_reg); /* clear hash table */
-
- return 1;
-}
-
-static int cl_block (struct cmcompress_stream* cdata) /* table clear for block compress */
-{
- register long int rat;
-
- cdata->checkpoint = cdata->in_count + CHECK_GAP;
-#ifdef DEBUG
- if ( cdata->debug )
- {
- fprintf ( stderr, "count: %ld, ratio: ", cdata->in_count );
- prratio ( stderr, cdata->in_count, cdata->bytes_out );
- fprintf ( stderr, "\n");
- }
-#endif /* DEBUG */
-
- if(cdata->in_count > 0x007fffff)
- { /* shift will overflow */
- rat = cdata->bytes_out >> 8;
- if(rat == 0)
- { /* Don't divide by zero */
- rat = 0x7fffffff;
- }
- else
- {
- rat = cdata->in_count / rat;
- }
- }
- else
- {
- rat = (cdata->in_count << 8) / cdata->bytes_out; /* 8 fractional bits */
- }
- if ( rat > cdata->ratio )
- {
- cdata->ratio = rat;
- }
- else
- {
- cdata->ratio = 0;
-#ifdef DEBUG
- if(cdata->verbose)
- {
- dump_tab(); /* dump string table */
- }
-#endif
- cl_hash (cdata, (count_int) cdata->hsize );
- cdata->free_ent = FIRST;
- cdata->clear_flg = 1;
- if ( !output (cdata, (code_int) CLEAR ) )
- {
- return 0;
- }
-#ifdef DEBUG
- if(cdata->debug)
- {
- fprintf ( stderr, "clear\n" );
- }
-#endif /* DEBUG */
- }
- return 1;
-}
-
-
-int cmcompress_compress(struct cmcompress_stream* cdata, void* buff, size_t n)
-{
- register code_int i;
- register int c;
- register int disp;
-
- unsigned char* input_buffer = (unsigned char*)buff;
-
- size_t cc;
-
- /*printf("cmcompress_compress(%p, %p, %d)\n", cdata, buff, n);*/
-
- if ( cdata->first_pass )
- {
- cdata->ent = input_buffer[0];
- ++ input_buffer;
- -- n;
- cdata->first_pass = 0;
- }
-
- for ( cc = 0; cc < n; ++ cc )
- {
- c = input_buffer[cc];
- cdata->in_count++;
- cdata->fcode = (long) (((long) c << cdata->maxbits) + cdata->ent);
- i = ((c << cdata->hshift) ^ cdata->ent); /* xor hashing */
-
- if ( htabof (i) == cdata->fcode )
- {
- cdata->ent = codetabof (i);
- continue;
- }
- else if ( (long)htabof (i) < 0 ) /* empty slot */
- {
- goto nomatch;
- }
- disp = (int)(cdata->hsize_reg - i); /* secondary hash (after G. Knott) */
- if ( i == 0 )
- {
- disp = 1;
- }
-probe:
- if ( (i -= disp) < 0 )
- {
- i += cdata->hsize_reg;
- }
-
- if ( htabof (i) == cdata->fcode )
- {
- cdata->ent = codetabof (i);
- continue;
- }
- if ( (long)htabof (i) > 0 )
- {
- goto probe;
- }
-nomatch:
- if ( !output(cdata, (code_int) cdata->ent ) )
- {
- return 0;
- }
- cdata->out_count++;
- cdata->ent = c;
- if (
-#ifdef SIGNED_COMPARE_SLOW
- (unsigned) cdata->free_ent < (unsigned) cdata->maxmaxcode
-#else
- cdata->free_ent < cdata->maxmaxcode
-#endif
- )
- {
- codetabof (i) = (unsigned short)(cdata->free_ent++); /* code -> hashtable */
- htabof (i) = cdata->fcode;
- }
- else if ( (count_int)cdata->in_count >= cdata->checkpoint && cdata->block_compress )
- {
- if ( !cl_block (cdata) )
- {
- return 0;
- }
- }
- }
-
- return 1;
-}
-
-int cmcompress_compress_finalize(struct cmcompress_stream* cdata)
-{
- /*
- * Put out the final code.
- */
- if ( !output(cdata, (code_int)cdata->ent ) )
- {
- return 0;
- }
- cdata->out_count++;
- if ( !output(cdata, (code_int)-1 ) )
- {
- return 0;
- }
-
- if(cdata->bytes_out > cdata->in_count) /* exit(2) if no savings */
- {
- return 0;
- }
- return 1;
-}
-
-
-#if defined(DEBUG)
-static void prratio(FILE *stream, long int num, long int den)
-{
- register int q; /* Doesn't need to be long */
-
- if(num > 214748L)
- { /* 2147483647/10000 */
- q = num / (den / 10000L);
- }
- else
- {
- q = 10000L * num / den; /* Long calculations, though */
- }
- if (q < 0)
- {
- putc('-', stream);
- q = -q;
- }
- fprintf(stream, "%d.%02d%%", q / 100, q % 100);
-}
-#endif
-
diff --git a/Utilities/cmcompress/cmcompress.h b/Utilities/cmcompress/cmcompress.h
deleted file mode 100644
index 4cd3a1c3e..000000000
--- a/Utilities/cmcompress/cmcompress.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * James A. Woods, derived from original work by Spencer Thomas
- * and Joseph Orost.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef cmcompress__h_
-#define cmcompress__h_
-
-#include <stdio.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*
- * Set USERMEM to the maximum amount of physical user memory available
- * in bytes. USERMEM is used to determine the maximum BITS that can be used
- * for compression.
- *
- * SACREDMEM is the amount of physical memory saved for others; compress
- * will hog the rest.
- */
-#ifndef SACREDMEM
-#define SACREDMEM 0
-#endif
-
-#ifndef USERMEM
-# define USERMEM 450000 /* default user memory */
-#endif
-
-#ifdef pdp11
-# define BITS 12 /* max bits/code for 16-bit machine */
-# define NO_UCHAR /* also if "unsigned char" functions as signed char */
-# undef USERMEM
-#endif /* pdp11 */ /* don't forget to compile with -i */
-
-#ifdef USERMEM
-# if USERMEM >= (433484+SACREDMEM)
-# define PBITS 16
-# else
-# if USERMEM >= (229600+SACREDMEM)
-# define PBITS 15
-# else
-# if USERMEM >= (127536+SACREDMEM)
-# define PBITS 14
-# else
-# if USERMEM >= (73464+SACREDMEM)
-# define PBITS 13
-# else
-# define PBITS 12
-# endif
-# endif
-# endif
-# endif
-# undef USERMEM
-#endif /* USERMEM */
-
-#ifdef PBITS /* Preferred BITS for this memory size */
-# ifndef BITS
-# define BITS PBITS
-# endif /* BITS */
-#endif /* PBITS */
-
-#if BITS == 16
-# define HSIZE 69001 /* 95% occupancy */
-#endif
-#if BITS == 15
-# define HSIZE 35023 /* 94% occupancy */
-#endif
-#if BITS == 14
-# define HSIZE 18013 /* 91% occupancy */
-#endif
-#if BITS == 13
-# define HSIZE 9001 /* 91% occupancy */
-#endif
-#if BITS <= 12
-# define HSIZE 5003 /* 80% occupancy */
-#endif
-
- /*
- * a code_int must be able to hold 2**BITS values of type int, and also -1
- */
-#if BITS > 15
- typedef long int code_int;
-#else
- typedef int code_int;
-#endif
-
-#ifdef SIGNED_COMPARE_SLOW
- typedef unsigned long int count_int;
- typedef unsigned short int count_short;
-#else
- typedef long int count_int;
-#endif
-
-#ifdef NO_UCHAR
- typedef char char_type;
-#else
- typedef unsigned char char_type;
-#endif /* UCHAR */
-
-
-
- struct cmcompress_stream
- {
- int n_bits; /* number of bits/code */
- int maxbits; /* user settable max # bits/code */
- code_int maxcode; /* maximum code, given n_bits */
- code_int maxmaxcode; /* should NEVER generate this code */
-
- count_int htab [HSIZE];
- unsigned short codetab [HSIZE];
-
- code_int hsize; /* for dynamic table sizing */
- code_int free_ent; /* first unused entry */
- int nomagic; /* Use a 3-byte magic number header, unless old file */
-
- /*
- * block compression parameters -- after all codes are used up,
- * and compression rate changes, start over.
- */
- int block_compress;
- int clear_flg;
- long int ratio;
- count_int checkpoint;
-
-#ifdef DEBUG
- int debug;
- int verbose;
-#endif
-
- /* compress internals */
- int offset;
- long int in_count; /* length of input */
- long int bytes_out; /* length of compressed output */
- long int out_count; /* # of codes output (for debugging) */
-
- /* internals */
- code_int ent;
- code_int hsize_reg;
- int hshift;
-
- long fcode;
- int first_pass;
-
- /* For input and output */
- int (*input_stream)(void*);
- int (*output_stream)(void*, const char*,int);
- void* client_data;
- };
-
- int cmcompress_compress_initialize(struct cmcompress_stream* cdata);
- int cmcompress_compress_start(struct cmcompress_stream* cdata);
- int cmcompress_compress(struct cmcompress_stream* cdata, void* buff, size_t n);
- int cmcompress_compress_finalize(struct cmcompress_stream* cdata);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* cmcompress__h_ */
diff --git a/Utilities/cmcompress/compress.c.original b/Utilities/cmcompress/compress.c.original
deleted file mode 100644
index 5062bda98..000000000
--- a/Utilities/cmcompress/compress.c.original
+++ /dev/null
@@ -1,1308 +0,0 @@
-/*
- * Copyright (c) 1985, 1986 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * James A. Woods, derived from original work by Spencer Thomas
- * and Joseph Orost.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1985, 1986 The Regents of the University of California.\n\
- All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static char sccsid[] = "@(#)compress.c 5.19 (Berkeley) 3/18/91";
-#endif /* not lint */
-
-/*
- * compress.c - File compression ala IEEE Computer, June 1984.
- *
- * Authors: Spencer W. Thomas (decvax!utah-cs!thomas)
- * Jim McKie (decvax!mcvax!jim)
- * Steve Davies (decvax!vax135!petsd!peora!srd)
- * Ken Turkowski (decvax!decwrl!turtlevax!ken)
- * James A. Woods (decvax!ihnp4!ames!jaw)
- * Joe Orost (decvax!vax135!petsd!joe)
- */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <signal.h>
-#include <utime.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-
-/*
- * Set USERMEM to the maximum amount of physical user memory available
- * in bytes. USERMEM is used to determine the maximum BITS that can be used
- * for compression.
- *
- * SACREDMEM is the amount of physical memory saved for others; compress
- * will hog the rest.
- */
-#ifndef SACREDMEM
-#define SACREDMEM 0
-#endif
-
-#ifndef USERMEM
-# define USERMEM 450000 /* default user memory */
-#endif
-
-#ifdef pdp11
-# define BITS 12 /* max bits/code for 16-bit machine */
-# define NO_UCHAR /* also if "unsigned char" functions as signed char */
-# undef USERMEM
-#endif /* pdp11 */ /* don't forget to compile with -i */
-
-#ifdef USERMEM
-# if USERMEM >= (433484+SACREDMEM)
-# define PBITS 16
-# else
-# if USERMEM >= (229600+SACREDMEM)
-# define PBITS 15
-# else
-# if USERMEM >= (127536+SACREDMEM)
-# define PBITS 14
-# else
-# if USERMEM >= (73464+SACREDMEM)
-# define PBITS 13
-# else
-# define PBITS 12
-# endif
-# endif
-# endif
-# endif
-# undef USERMEM
-#endif /* USERMEM */
-
-#ifdef PBITS /* Preferred BITS for this memory size */
-# ifndef BITS
-# define BITS PBITS
-# endif BITS
-#endif /* PBITS */
-
-#if BITS == 16
-# define HSIZE 69001 /* 95% occupancy */
-#endif
-#if BITS == 15
-# define HSIZE 35023 /* 94% occupancy */
-#endif
-#if BITS == 14
-# define HSIZE 18013 /* 91% occupancy */
-#endif
-#if BITS == 13
-# define HSIZE 9001 /* 91% occupancy */
-#endif
-#if BITS <= 12
-# define HSIZE 5003 /* 80% occupancy */
-#endif
-
-/*
- * a code_int must be able to hold 2**BITS values of type int, and also -1
- */
-#if BITS > 15
-typedef long int code_int;
-#else
-typedef int code_int;
-#endif
-
-#ifdef SIGNED_COMPARE_SLOW
-typedef unsigned long int count_int;
-typedef unsigned short int count_short;
-#else
-typedef long int count_int;
-#endif
-
-#ifdef NO_UCHAR
- typedef char char_type;
-#else
- typedef unsigned char char_type;
-#endif /* UCHAR */
-char_type magic_header[] = { "\037\235" }; /* 1F 9D */
-
-/* Defines for third byte of header */
-#define BIT_MASK 0x1f
-#define BLOCK_MASK 0x80
-/* Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is
- a fourth header byte (for expansion).
-*/
-#define INIT_BITS 9 /* initial number of bits/code */
-
-int n_bits; /* number of bits/code */
-int maxbits = BITS; /* user settable max # bits/code */
-code_int maxcode; /* maximum code, given n_bits */
-code_int maxmaxcode = 1 << BITS; /* should NEVER generate this code */
-#ifdef COMPATIBLE /* But wrong! */
-# define MAXCODE(n_bits) (1 << (n_bits) - 1)
-#else
-# define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
-#endif /* COMPATIBLE */
-
-count_int htab [HSIZE];
-unsigned short codetab [HSIZE];
-
-#define htabof(i) htab[i]
-#define codetabof(i) codetab[i]
-code_int hsize = HSIZE; /* for dynamic table sizing */
-count_int fsize;
-
-/*
- * To save much memory, we overlay the table used by compress() with those
- * used by decompress(). The tab_prefix table is the same size and type
- * as the codetab. The tab_suffix table needs 2**BITS characters. We
- * get this from the beginning of htab. The output stack uses the rest
- * of htab, and contains characters. There is plenty of room for any
- * possible stack (stack used to be 8000 characters).
- */
-
-#define tab_prefixof(i) codetabof(i)
-# define tab_suffixof(i) ((char_type *)(htab))[i]
-# define de_stack ((char_type *)&tab_suffixof(1<<BITS))
-
-code_int free_ent = 0; /* first unused entry */
-int exit_stat = 0; /* per-file status */
-int perm_stat = 0; /* permanent status */
-
-code_int getcode();
-
-int nomagic = 0; /* Use a 3-byte magic number header, unless old file */
-int zcat_flg = 0; /* Write output on stdout, suppress messages */
-int precious = 1; /* Don't unlink output file on interrupt */
-int quiet = 1; /* don't tell me about compression */
-
-/*
- * block compression parameters -- after all codes are used up,
- * and compression rate changes, start over.
- */
-int block_compress = BLOCK_MASK;
-int clear_flg = 0;
-long int ratio = 0;
-#define CHECK_GAP 10000 /* ratio check interval */
-count_int checkpoint = CHECK_GAP;
-/*
- * the next two codes should not be changed lightly, as they must not
- * lie within the contiguous general code space.
- */
-#define FIRST 257 /* first free entry */
-#define CLEAR 256 /* table clear output code */
-
-int force = 0;
-char ofname [100];
-#ifdef DEBUG
-int debug, verbose;
-#endif
-sig_t oldint;
-int bgnd_flag;
-
-int do_decomp = 0;
-
-/*-
- * Algorithm from "A Technique for High Performance Data Compression",
- * Terry A. Welch, IEEE Computer Vol 17, No 6 (June 1984), pp 8-19.
- *
- * Usage: compress [-dfvc] [-b bits] [file ...]
- * Inputs:
- * -d: If given, decompression is done instead.
- *
- * -c: Write output on stdout, don't remove original.
- *
- * -b: Parameter limits the max number of bits/code.
- *
- * -f: Forces output file to be generated, even if one already
- * exists, and even if no space is saved by compressing.
- * If -f is not used, the user will be prompted if stdin is
- * a tty, otherwise, the output file will not be overwritten.
- *
- * -v: Write compression statistics
- *
- * file ...: Files to be compressed. If none specified, stdin
- * is used.
- * Outputs:
- * file.Z: Compressed form of file with same mode, owner, and utimes
- * or stdout (if stdin used as input)
- *
- * Assumptions:
- * When filenames are given, replaces with the compressed version
- * (.Z suffix) only if the file decreases in size.
- * Algorithm:
- * Modified Lempel-Ziv method (LZW). Basically finds common
- * substrings and replaces them with a variable size code. This is
- * deterministic, and can be done on the fly. Thus, the decompression
- * procedure needs no input table, but tracks the way the table was built.
- */
-
-main(argc, argv)
- int argc;
- char **argv;
-{
- extern int optind;
- extern char *optarg;
- struct stat statbuf;
- int ch, overwrite;
- char **filelist, **fileptr, *cp, tempname[MAXPATHLEN];
- void onintr(), oops();
-
- /* This bg check only works for sh. */
- if ((oldint = signal(SIGINT, SIG_IGN)) != SIG_IGN) {
- (void)signal(SIGINT, onintr);
- (void)signal(SIGSEGV, oops); /* XXX */
- }
- bgnd_flag = oldint != SIG_DFL;
-
-#ifdef COMPATIBLE
- nomagic = 1; /* Original didn't have a magic number */
-#endif
-
- if (cp = rindex(argv[0], '/'))
- ++cp;
- else
- cp = argv[0];
- if (strcmp(cp, "uncompress") == 0)
- do_decomp = 1;
- else if(strcmp(cp, "zcat") == 0) {
- do_decomp = 1;
- zcat_flg = 1;
- }
-
- /*
- * -b maxbits => maxbits.
- * -C => generate output compatible with compress 2.0.
- * -c => cat all output to stdout
- * -D => debug
- * -d => do_decomp
- * -f => force overwrite of output file
- * -n => no header: useful to uncompress old files
- * -V => print Version; debug verbose
- * -v => unquiet
- */
-
- overwrite = 0;
-#ifdef DEBUG
- while ((ch = getopt(argc, argv, "b:CcDdfnVv")) != EOF)
-#else
- while ((ch = getopt(argc, argv, "b:Ccdfnv")) != EOF)
-#endif
- switch(ch) {
- case 'b':
- maxbits = atoi(optarg);
- break;
- case 'C':
- block_compress = 0;
- break;
- case 'c':
- zcat_flg = 1;
- break;
-#ifdef DEBUG
- case 'D':
- debug = 1;
- break;
-#endif
- case 'd':
- do_decomp = 1;
- break;
- case 'f':
- overwrite = 1;
- force = 1;
- break;
- case 'n':
- nomagic = 1;
- break;
- case 'q':
- quiet = 1;
- break;
-#ifdef DEBUG
- case 'V':
- verbose = 1;
- break;
-#endif
- case 'v':
- quiet = 0;
- break;
- case '?':
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
-
- if (maxbits < INIT_BITS)
- maxbits = INIT_BITS;
- if (maxbits > BITS)
- maxbits = BITS;
- maxmaxcode = 1 << maxbits;
-
- /* Build useless input file list. */
- filelist = fileptr = (char **)(malloc(argc * sizeof(*argv)));
- while (*argv)
- *fileptr++ = *argv++;
- *fileptr = NULL;
-
- if (*filelist != NULL) {
- for (fileptr = filelist; *fileptr; fileptr++) {
- exit_stat = 0;
- if (do_decomp) { /* DECOMPRESSION */
- /* Check for .Z suffix */
- if (strcmp(*fileptr + strlen(*fileptr) - 2, ".Z") != 0) {
- /* No .Z: tack one on */
- strcpy(tempname, *fileptr);
- strcat(tempname, ".Z");
- *fileptr = tempname;
- }
- /* Open input file */
- if ((freopen(*fileptr, "r", stdin)) == NULL) {
- perror(*fileptr);
- perm_stat = 1;
- continue;
- }
- /* Check the magic number */
- if (nomagic == 0) {
- if ((getchar() != (magic_header[0] & 0xFF))
- || (getchar() != (magic_header[1] & 0xFF))) {
- fprintf(stderr, "%s: not in compressed format\n",
- *fileptr);
- continue;
- }
- maxbits = getchar(); /* set -b from file */
- block_compress = maxbits & BLOCK_MASK;
- maxbits &= BIT_MASK;
- maxmaxcode = 1 << maxbits;
- if(maxbits > BITS) {
- fprintf(stderr,
- "%s: compressed with %d bits, can only handle %d bits\n",
- *fileptr, maxbits, BITS);
- continue;
- }
- }
- /* Generate output filename */
- strcpy(ofname, *fileptr);
- ofname[strlen(*fileptr) - 2] = '\0'; /* Strip off .Z */
- } else { /* COMPRESSION */
- if (strcmp(*fileptr + strlen(*fileptr) - 2, ".Z") == 0) {
- fprintf(stderr, "%s: already has .Z suffix -- no change\n",
- *fileptr);
- continue;
- }
- /* Open input file */
- if ((freopen(*fileptr, "r", stdin)) == NULL) {
- perror(*fileptr);
- perm_stat = 1;
- continue;
- }
- stat ( *fileptr, &statbuf );
- fsize = (long) statbuf.st_size;
- /*
- * tune hash table size for small files -- ad hoc,
- * but the sizes match earlier #defines, which
- * serve as upper bounds on the number of output codes.
- */
- hsize = HSIZE;
- if ( fsize < (1 << 12) )
- hsize = MIN ( 5003, HSIZE );
- else if ( fsize < (1 << 13) )
- hsize = MIN ( 9001, HSIZE );
- else if ( fsize < (1 << 14) )
- hsize = MIN ( 18013, HSIZE );
- else if ( fsize < (1 << 15) )
- hsize = MIN ( 35023, HSIZE );
- else if ( fsize < 47000 )
- hsize = MIN ( 50021, HSIZE );
-
- /* Generate output filename */
- strcpy(ofname, *fileptr);
- strcat(ofname, ".Z");
- }
- /* Check for overwrite of existing file */
- if (overwrite == 0 && zcat_flg == 0) {
- if (stat(ofname, &statbuf) == 0) {
- char response[2];
- response[0] = 'n';
- fprintf(stderr, "%s already exists;", ofname);
- if (bgnd_flag == 0 && isatty(2)) {
- fprintf(stderr, " do you wish to overwrite %s (y or n)? ",
- ofname);
- fflush(stderr);
- read(2, response, 2);
- while (response[1] != '\n') {
- if (read(2, response+1, 1) < 0) { /* Ack! */
- perror("stderr"); break;
- }
- }
- }
- if (response[0] != 'y') {
- fprintf(stderr, "\tnot overwritten\n");
- continue;
- }
- }
- }
- if(zcat_flg == 0) { /* Open output file */
- if (freopen(ofname, "w", stdout) == NULL) {
- perror(ofname);
- perm_stat = 1;
- continue;
- }
- precious = 0;
- if(!quiet)
- fprintf(stderr, "%s: ", *fileptr);
- }
-
- /* Actually do the compression/decompression */
- if (do_decomp == 0) compress();
-#ifndef DEBUG
- else decompress();
-#else
- else if (debug == 0) decompress();
- else printcodes();
- if (verbose) dump_tab();
-#endif /* DEBUG */
- if(zcat_flg == 0) {
- copystat(*fileptr, ofname); /* Copy stats */
- precious = 1;
- if((exit_stat == 1) || (!quiet))
- putc('\n', stderr);
- }
- }
- } else { /* Standard input */
- if (do_decomp == 0) {
- compress();
-#ifdef DEBUG
- if(verbose) dump_tab();
-#endif /* DEBUG */
- if(!quiet)
- putc('\n', stderr);
- } else {
- /* Check the magic number */
- if (nomagic == 0) {
- if ((getchar()!=(magic_header[0] & 0xFF))
- || (getchar()!=(magic_header[1] & 0xFF))) {
- fprintf(stderr, "stdin: not in compressed format\n");
- exit(1);
- }
- maxbits = getchar(); /* set -b from file */
- block_compress = maxbits & BLOCK_MASK;
- maxbits &= BIT_MASK;
- maxmaxcode = 1 << maxbits;
- fsize = 100000; /* assume stdin large for USERMEM */
- if(maxbits > BITS) {
- fprintf(stderr,
- "stdin: compressed with %d bits, can only handle %d bits\n",
- maxbits, BITS);
- exit(1);
- }
- }
-#ifndef DEBUG
- decompress();
-#else
- if (debug == 0) decompress();
- else printcodes();
- if (verbose) dump_tab();
-#endif /* DEBUG */
- }
- }
- exit(perm_stat ? perm_stat : exit_stat);
-}
-
-static int offset;
-long int in_count = 1; /* length of input */
-long int bytes_out; /* length of compressed output */
-long int out_count = 0; /* # of codes output (for debugging) */
-
-/*
- * compress stdin to stdout
- *
- * Algorithm: use open addressing double hashing (no chaining) on the
- * prefix code / next character combination. We do a variant of Knuth's
- * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
- * secondary probe. Here, the modular division first probe is gives way
- * to a faster exclusive-or manipulation. Also do block compression with
- * an adaptive reset, whereby the code table is cleared when the compression
- * ratio decreases, but after the table fills. The variable-length output
- * codes are re-sized at this point, and a special CLEAR code is generated
- * for the decompressor. Late addition: construct the table according to
- * file size for noticeable speed improvement on small files. Please direct
- * questions about this implementation to ames!jaw.
- */
-
-compress()
-{
- register long fcode;
- register code_int i = 0;
- register int c;
- register code_int ent;
- register int disp;
- register code_int hsize_reg;
- register int hshift;
-
-#ifndef COMPATIBLE
- if (nomagic == 0) {
- putchar(magic_header[0]);
- putchar(magic_header[1]);
- putchar((char)(maxbits | block_compress));
- if(ferror(stdout))
- writeerr();
- }
-#endif /* COMPATIBLE */
-
- offset = 0;
- bytes_out = 3; /* includes 3-byte header mojo */
- out_count = 0;
- clear_flg = 0;
- ratio = 0;
- in_count = 1;
- checkpoint = CHECK_GAP;
- maxcode = MAXCODE(n_bits = INIT_BITS);
- free_ent = ((block_compress) ? FIRST : 256 );
-
- ent = getchar ();
-
- hshift = 0;
- for ( fcode = (long) hsize; fcode < 65536L; fcode *= 2L )
- hshift++;
- hshift = 8 - hshift; /* set hash code range bound */
-
- hsize_reg = hsize;
- cl_hash( (count_int) hsize_reg); /* clear hash table */
-
-#ifdef SIGNED_COMPARE_SLOW
- while ( (c = getchar()) != (unsigned) EOF ) {
-#else
- while ( (c = getchar()) != EOF ) {
-#endif
- in_count++;
- fcode = (long) (((long) c << maxbits) + ent);
- i = ((c << hshift) ^ ent); /* xor hashing */
-
- if ( htabof (i) == fcode ) {
- ent = codetabof (i);
- continue;
- } else if ( (long)htabof (i) < 0 ) /* empty slot */
- goto nomatch;
- disp = hsize_reg - i; /* secondary hash (after G. Knott) */
- if ( i == 0 )
- disp = 1;
-probe:
- if ( (i -= disp) < 0 )
- i += hsize_reg;
-
- if ( htabof (i) == fcode ) {
- ent = codetabof (i);
- continue;
- }
- if ( (long)htabof (i) > 0 )
- goto probe;
-nomatch:
- output ( (code_int) ent );
- out_count++;
- ent = c;
-#ifdef SIGNED_COMPARE_SLOW
- if ( (unsigned) free_ent < (unsigned) maxmaxcode) {
-#else
- if ( free_ent < maxmaxcode ) {
-#endif
- codetabof (i) = free_ent++; /* code -> hashtable */
- htabof (i) = fcode;
- }
- else if ( (count_int)in_count >= checkpoint && block_compress )
- cl_block ();
- }
- /*
- * Put out the final code.
- */
- output( (code_int)ent );
- out_count++;
- output( (code_int)-1 );
-
- /*
- * Print out stats on stderr
- */
- if(zcat_flg == 0 && !quiet) {
-#ifdef DEBUG
- fprintf( stderr,
- "%ld chars in, %ld codes (%ld bytes) out, compression factor: ",
- in_count, out_count, bytes_out );
- prratio( stderr, in_count, bytes_out );
- fprintf( stderr, "\n");
- fprintf( stderr, "\tCompression as in compact: " );
- prratio( stderr, in_count-bytes_out, in_count );
- fprintf( stderr, "\n");
- fprintf( stderr, "\tLargest code (of last block) was %d (%d bits)\n",
- free_ent - 1, n_bits );
-#else /* !DEBUG */
- fprintf( stderr, "Compression: " );
- prratio( stderr, in_count-bytes_out, in_count );
-#endif /* DEBUG */
- }
- if(bytes_out > in_count) /* exit(2) if no savings */
- exit_stat = 2;
- return;
-}
-
-/*-
- * Output the given code.
- * Inputs:
- * code: A n_bits-bit integer. If == -1, then EOF. This assumes
- * that n_bits =< (long)wordsize - 1.
- * Outputs:
- * Outputs code to the file.
- * Assumptions:
- * Chars are 8 bits long.
- * Algorithm:
- * Maintain a BITS character long buffer (so that 8 codes will
- * fit in it exactly). Use the VAX insv instruction to insert each
- * code in turn. When the buffer fills up empty it and start over.
- */
-
-static char buf[BITS];
-
-#ifndef vax
-char_type lmask[9] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00};
-char_type rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
-#endif /* vax */
-
-output( code )
-code_int code;
-{
-#ifdef DEBUG
- static int col = 0;
-#endif /* DEBUG */
-
- /*
- * On the VAX, it is important to have the register declarations
- * in exactly the order given, or the asm will break.
- */
- register int r_off = offset, bits= n_bits;
- register char * bp = buf;
-
-#ifdef DEBUG
- if ( verbose )
- fprintf( stderr, "%5d%c", code,
- (col+=6) >= 74 ? (col = 0, '\n') : ' ' );
-#endif /* DEBUG */
- if ( code >= 0 ) {
-#if defined(vax) && !defined(__GNUC__)
- /*
- * VAX and PCC DEPENDENT!! Implementation on other machines is
- * below.
- *
- * Translation: Insert BITS bits from the argument starting at
- * offset bits from the beginning of buf.
- */
- 0; /* Work around for pcc -O bug with asm and if stmt */
- asm( "insv 4(ap),r11,r10,(r9)" );
-#else
-/*
- * byte/bit numbering on the VAX is simulated by the following code
- */
- /*
- * Get to the first byte.
- */
- bp += (r_off >> 3);
- r_off &= 7;
- /*
- * Since code is always >= 8 bits, only need to mask the first
- * hunk on the left.
- */
- *bp = (*bp & rmask[r_off]) | (code << r_off) & lmask[r_off];
- bp++;
- bits -= (8 - r_off);
- code >>= 8 - r_off;
- /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
- if ( bits >= 8 ) {
- *bp++ = code;
- code >>= 8;
- bits -= 8;
- }
- /* Last bits. */
- if(bits)
- *bp = code;
-#endif /* vax */
- offset += n_bits;
- if ( offset == (n_bits << 3) ) {
- bp = buf;
- bits = n_bits;
- bytes_out += bits;
- do {
- putchar(*bp++);
- if (ferror(stdout))
- writeerr();
- } while(--bits);
- offset = 0;
- }
-
- /*
- * If the next entry is going to be too big for the code size,
- * then increase it, if possible.
- */
- if ( free_ent > maxcode || (clear_flg > 0))
- {
- /*
- * Write the whole buffer, because the input side won't
- * discover the size increase until after it has read it.
- */
- if ( offset > 0 ) {
- if( fwrite( buf, 1, n_bits, stdout ) != n_bits)
- writeerr();
- bytes_out += n_bits;
- }
- offset = 0;
-
- if ( clear_flg ) {
- maxcode = MAXCODE (n_bits = INIT_BITS);
- clear_flg = 0;
- }
- else {
- n_bits++;
- if ( n_bits == maxbits )
- maxcode = maxmaxcode;
- else
- maxcode = MAXCODE(n_bits);
- }
-#ifdef DEBUG
- if ( debug ) {
- fprintf( stderr, "\nChange to %d bits\n", n_bits );
- col = 0;
- }
-#endif /* DEBUG */
- }
- } else {
- /*
- * At EOF, write the rest of the buffer.
- */
- if ( offset > 0 ) {
- offset = (offset + 7) / 8;
- if( fwrite( buf, 1, offset, stdout ) != offset )
- writeerr();
- bytes_out += offset;
- }
- offset = 0;
- (void)fflush( stdout );
- if( ferror( stdout ) )
- writeerr();
-#ifdef DEBUG
- if ( verbose )
- fprintf( stderr, "\n" );
-#endif
- }
-}
-
-/*
- * Decompress stdin to stdout. This routine adapts to the codes in the
- * file building the "string" table on-the-fly; requiring no table to
- * be stored in the compressed file. The tables used herein are shared
- * with those of the compress() routine. See the definitions above.
- */
-
-decompress() {
- register char_type *stackp;
- register int finchar;
- register code_int code, oldcode, incode;
- int n, nwritten, offset; /* Variables for buffered write */
- char buff[BUFSIZ]; /* Buffer for buffered write */
-
-
- /*
- * As above, initialize the first 256 entries in the table.
- */
- maxcode = MAXCODE(n_bits = INIT_BITS);
- for ( code = 255; code >= 0; code-- ) {
- tab_prefixof(code) = 0;
- tab_suffixof(code) = (char_type)code;
- }
- free_ent = ((block_compress) ? FIRST : 256 );
-
- finchar = oldcode = getcode();
- if(oldcode == -1) /* EOF already? */
- return; /* Get out of here */
-
- /* first code must be 8 bits = char */
- n=0;
- buff[n++] = (char)finchar;
-
- stackp = de_stack;
-
- while ( (code = getcode()) > -1 ) {
-
- if ( (code == CLEAR) && block_compress ) {
- for ( code = 255; code >= 0; code-- )
- tab_prefixof(code) = 0;
- clear_flg = 1;
- free_ent = FIRST - 1;
- if ( (code = getcode ()) == -1 ) /* O, untimely death! */
- break;
- }
- incode = code;
- /*
- * Special case for KwKwK string.
- */
- if ( code >= free_ent ) {
- *stackp++ = finchar;
- code = oldcode;
- }
-
- /*
- * Generate output characters in reverse order
- */
-#ifdef SIGNED_COMPARE_SLOW
- while ( ((unsigned long)code) >= ((unsigned long)256) ) {
-#else
- while ( code >= 256 ) {
-#endif
- *stackp++ = tab_suffixof(code);
- code = tab_prefixof(code);
- }
- *stackp++ = finchar = tab_suffixof(code);
-
- /*
- * And put them out in forward order
- */
- do {
- /*
- * About 60% of the time is spent in the putchar() call
- * that appeared here. It was originally
- * putchar ( *--stackp );
- * If we buffer the writes ourselves, we can go faster (about
- * 30%).
- *
- * At this point, the next line is the next *big* time
- * sink in the code. It takes up about 10% of the time.
- */
- buff[n++] = *--stackp;
- if (n == BUFSIZ) {
- offset = 0;
- do {
- nwritten = write(fileno(stdout), &buff[offset], n);
- if (nwritten < 0)
- writeerr();
- offset += nwritten;
- } while ((n -= nwritten) > 0);
- }
- } while ( stackp > de_stack );
-
- /*
- * Generate the new entry.
- */
- if ( (code=free_ent) < maxmaxcode ) {
- tab_prefixof(code) = (unsigned short)oldcode;
- tab_suffixof(code) = finchar;
- free_ent = code+1;
- }
- /*
- * Remember previous code.
- */
- oldcode = incode;
- }
- /*
- * Flush the stuff remaining in our buffer...
- */
- offset = 0;
- while (n > 0) {
- nwritten = write(fileno(stdout), &buff[offset], n);
- if (nwritten < 0)
- writeerr();
- offset += nwritten;
- n -= nwritten;
- }
-}
-
-/*-
- * Read one code from the standard input. If EOF, return -1.
- * Inputs:
- * stdin
- * Outputs:
- * code or -1 is returned.
- */
-code_int
-getcode() {
- /*
- * On the VAX, it is important to have the register declarations
- * in exactly the order given, or the asm will break.
- */
- register code_int code;
- static int offset = 0, size = 0;
- static char_type buf[BITS];
- register int r_off, bits;
- register char_type *bp = buf;
-
- if ( clear_flg > 0 || offset >= size || free_ent > maxcode ) {
- /*
- * If the next entry will be too big for the current code
- * size, then we must increase the size. This implies reading
- * a new buffer full, too.
- */
- if ( free_ent > maxcode ) {
- n_bits++;
- if ( n_bits == maxbits )
- maxcode = maxmaxcode; /* won't get any bigger now */
- else
- maxcode = MAXCODE(n_bits);
- }
- if ( clear_flg > 0) {
- maxcode = MAXCODE (n_bits = INIT_BITS);
- clear_flg = 0;
- }
- size = fread( buf, 1, n_bits, stdin );
- if ( size <= 0 )
- return -1; /* end of file */
- offset = 0;
- /* Round size down to integral number of codes */
- size = (size << 3) - (n_bits - 1);
- }
- r_off = offset;
- bits = n_bits;
-#ifdef vax
- asm( "extzv r10,r9,(r8),r11" );
-#else /* not a vax */
- /*
- * Get to the first byte.
- */
- bp += (r_off >> 3);
- r_off &= 7;
- /* Get first part (low order bits) */
-#ifdef NO_UCHAR
- code = ((*bp++ >> r_off) & rmask[8 - r_off]) & 0xff;
-#else
- code = (*bp++ >> r_off);
-#endif /* NO_UCHAR */
- bits -= (8 - r_off);
- r_off = 8 - r_off; /* now, offset into code word */
- /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
- if ( bits >= 8 ) {
-#ifdef NO_UCHAR
- code |= (*bp++ & 0xff) << r_off;
-#else
- code |= *bp++ << r_off;
-#endif /* NO_UCHAR */
- r_off += 8;
- bits -= 8;
- }
- /* high order bits. */
- code |= (*bp & rmask[bits]) << r_off;
-#endif /* vax */
- offset += n_bits;
-
- return code;
-}
-
-#ifdef DEBUG
-printcodes()
-{
- /*
- * Just print out codes from input file. For debugging.
- */
- code_int code;
- int col = 0, bits;
-
- bits = n_bits = INIT_BITS;
- maxcode = MAXCODE(n_bits);
- free_ent = ((block_compress) ? FIRST : 256 );
- while ( ( code = getcode() ) >= 0 ) {
- if ( (code == CLEAR) && block_compress ) {
- free_ent = FIRST - 1;
- clear_flg = 1;
- }
- else if ( free_ent < maxmaxcode )
- free_ent++;
- if ( bits != n_bits ) {
- fprintf(stderr, "\nChange to %d bits\n", n_bits );
- bits = n_bits;
- col = 0;
- }
- fprintf(stderr, "%5d%c", code, (col+=6) >= 74 ? (col = 0, '\n') : ' ' );
- }
- putc( '\n', stderr );
- exit( 0 );
-}
-
-code_int sorttab[1<<BITS]; /* sorted pointers into htab */
-
-dump_tab() /* dump string table */
-{
- register int i, first;
- register ent;
-#define STACK_SIZE 15000
- int stack_top = STACK_SIZE;
- register c;
-
- if(do_decomp == 0) { /* compressing */
- register int flag = 1;
-
- for(i=0; i<hsize; i++) { /* build sort pointers */
- if((long)htabof(i) >= 0) {
- sorttab[codetabof(i)] = i;
- }
- }
- first = block_compress ? FIRST : 256;
- for(i = first; i < free_ent; i++) {
- fprintf(stderr, "%5d: \"", i);
- de_stack[--stack_top] = '\n';
- de_stack[--stack_top] = '"';
- stack_top = in_stack((htabof(sorttab[i])>>maxbits)&0xff,
- stack_top);
- for(ent=htabof(sorttab[i]) & ((1<<maxbits)-1);
- ent > 256;
- ent=htabof(sorttab[ent]) & ((1<<maxbits)-1)) {
- stack_top = in_stack(htabof(sorttab[ent]) >> maxbits,
- stack_top);
- }
- stack_top = in_stack(ent, stack_top);
- fwrite( &de_stack[stack_top], 1, STACK_SIZE-stack_top, stderr);
- stack_top = STACK_SIZE;
- }
- } else if(!debug) { /* decompressing */
-
- for ( i = 0; i < free_ent; i++ ) {
- ent = i;
- c = tab_suffixof(ent);
- if ( isascii(c) && isprint(c) )
- fprintf( stderr, "%5d: %5d/'%c' \"",
- ent, tab_prefixof(ent), c );
- else
- fprintf( stderr, "%5d: %5d/\\%03o \"",
- ent, tab_prefixof(ent), c );
- de_stack[--stack_top] = '\n';
- de_stack[--stack_top] = '"';
- for ( ; ent != NULL;
- ent = (ent >= FIRST ? tab_prefixof(ent) : NULL) ) {
- stack_top = in_stack(tab_suffixof(ent), stack_top);
- }
- fwrite( &de_stack[stack_top], 1, STACK_SIZE - stack_top, stderr );
- stack_top = STACK_SIZE;
- }
- }
-}
-
-int
-in_stack(c, stack_top)
- register c, stack_top;
-{
- if ( (isascii(c) && isprint(c) && c != '\\') || c == ' ' ) {
- de_stack[--stack_top] = c;
- } else {
- switch( c ) {
- case '\n': de_stack[--stack_top] = 'n'; break;
- case '\t': de_stack[--stack_top] = 't'; break;
- case '\b': de_stack[--stack_top] = 'b'; break;
- case '\f': de_stack[--stack_top] = 'f'; break;
- case '\r': de_stack[--stack_top] = 'r'; break;
- case '\\': de_stack[--stack_top] = '\\'; break;
- default:
- de_stack[--stack_top] = '0' + c % 8;
- de_stack[--stack_top] = '0' + (c / 8) % 8;
- de_stack[--stack_top] = '0' + c / 64;
- break;
- }
- de_stack[--stack_top] = '\\';
- }
- return stack_top;
-}
-#endif /* DEBUG */
-
-writeerr()
-{
- (void)fprintf(stderr, "compress: %s: %s\n",
- ofname[0] ? ofname : "stdout", strerror(errno));
- (void)unlink(ofname);
- exit(1);
-}
-
-copystat(ifname, ofname)
-char *ifname, *ofname;
-{
- struct stat statbuf;
- int mode;
- struct utimbuf tp;
-
- fclose(stdout);
- if (stat(ifname, &statbuf)) { /* Get stat on input file */
- perror(ifname);
- return;
- }
- if ((statbuf.st_mode & S_IFMT/*0170000*/) != S_IFREG/*0100000*/) {
- if(quiet)
- fprintf(stderr, "%s: ", ifname);
- fprintf(stderr, " -- not a regular file: unchanged");
- exit_stat = 1;
- perm_stat = 1;
- } else if (statbuf.st_nlink > 1) {
- if(quiet)
- fprintf(stderr, "%s: ", ifname);
- fprintf(stderr, " -- has %d other links: unchanged",
- statbuf.st_nlink - 1);
- exit_stat = 1;
- perm_stat = 1;
- } else if (exit_stat == 2 && (!force)) { /* No compression: remove file.Z */
- if(!quiet)
- fprintf(stderr, " -- file unchanged");
- } else { /* ***** Successful Compression ***** */
- exit_stat = 0;
- mode = statbuf.st_mode & 07777;
- if (chmod(ofname, mode)) /* Copy modes */
- perror(ofname);
- chown(ofname, statbuf.st_uid, statbuf.st_gid); /* Copy ownership */
- tp.actime = statbuf.st_atime;
- tp.modtime = statbuf.st_mtime;
- utime(ofname, &tp); /* Update last accessed and modified times */
- if (unlink(ifname)) /* Remove input file */
- perror(ifname);
- if(!quiet)
- fprintf(stderr, " -- replaced with %s", ofname);
- return; /* Successful return */
- }
-
- /* Unsuccessful return -- one of the tests failed */
- if (unlink(ofname))
- perror(ofname);
-}
-
-void
-onintr ( )
-{
- if (!precious)
- unlink ( ofname );
- exit ( 1 );
-}
-
-void
-oops ( ) /* wild pointer -- assume bad input */
-{
- if ( do_decomp )
- fprintf ( stderr, "uncompress: corrupt input\n" );
- unlink ( ofname );
- exit ( 1 );
-}
-
-cl_block () /* table clear for block compress */
-{
- register long int rat;
-
- checkpoint = in_count + CHECK_GAP;
-#ifdef DEBUG
- if ( debug ) {
- fprintf ( stderr, "count: %ld, ratio: ", in_count );
- prratio ( stderr, in_count, bytes_out );
- fprintf ( stderr, "\n");
- }
-#endif /* DEBUG */
-
- if(in_count > 0x007fffff) { /* shift will overflow */
- rat = bytes_out >> 8;
- if(rat == 0) { /* Don't divide by zero */
- rat = 0x7fffffff;
- } else {
- rat = in_count / rat;
- }
- } else {
- rat = (in_count << 8) / bytes_out; /* 8 fractional bits */
- }
- if ( rat > ratio ) {
- ratio = rat;
- } else {
- ratio = 0;
-#ifdef DEBUG
- if(verbose)
- dump_tab(); /* dump string table */
-#endif
- cl_hash ( (count_int) hsize );
- free_ent = FIRST;
- clear_flg = 1;
- output ( (code_int) CLEAR );
-#ifdef DEBUG
- if(debug)
- fprintf ( stderr, "clear\n" );
-#endif /* DEBUG */
- }
-}
-
-cl_hash(hsize) /* reset code table */
- register count_int hsize;
-{
- register count_int *htab_p = htab+hsize;
- register long i;
- register long m1 = -1;
-
- i = hsize - 16;
- do { /* might use Sys V memset(3) here */
- *(htab_p-16) = m1;
- *(htab_p-15) = m1;
- *(htab_p-14) = m1;
- *(htab_p-13) = m1;
- *(htab_p-12) = m1;
- *(htab_p-11) = m1;
- *(htab_p-10) = m1;
- *(htab_p-9) = m1;
- *(htab_p-8) = m1;
- *(htab_p-7) = m1;
- *(htab_p-6) = m1;
- *(htab_p-5) = m1;
- *(htab_p-4) = m1;
- *(htab_p-3) = m1;
- *(htab_p-2) = m1;
- *(htab_p-1) = m1;
- htab_p -= 16;
- } while ((i -= 16) >= 0);
- for ( i += 16; i > 0; i-- )
- *--htab_p = m1;
-}
-
-prratio(stream, num, den)
-FILE *stream;
-long int num, den;
-{
- register int q; /* Doesn't need to be long */
-
- if(num > 214748L) { /* 2147483647/10000 */
- q = num / (den / 10000L);
- } else {
- q = 10000L * num / den; /* Long calculations, though */
- }
- if (q < 0) {
- putc('-', stream);
- q = -q;
- }
- fprintf(stream, "%d.%02d%%", q / 100, q % 100);
-}
-
-usage()
-{
- (void)fprintf(stderr,
-#ifdef DEBUG
- "compress [-CDVcdfnv] [-b maxbits] [file ...]\n");
-#else
- "compress [-Ccdfnv] [-b maxbits] [file ...]\n");
-#endif
- exit(1);
-}
diff --git a/Utilities/cmcurl/CMake/CMakeConfigurableFile.in b/Utilities/cmcurl/CMake/CMakeConfigurableFile.in
index 4cf74a12b..df2c382e9 100644
--- a/Utilities/cmcurl/CMake/CMakeConfigurableFile.in
+++ b/Utilities/cmcurl/CMake/CMakeConfigurableFile.in
@@ -1,2 +1 @@
@CMAKE_CONFIGURABLE_FILE_CONTENT@
-
diff --git a/Utilities/cmcurl/CMake/CurlSymbolHiding.cmake b/Utilities/cmcurl/CMake/CurlSymbolHiding.cmake
index 9f7d29633..60ee8e682 100644
--- a/Utilities/cmcurl/CMake/CurlSymbolHiding.cmake
+++ b/Utilities/cmcurl/CMake/CurlSymbolHiding.cmake
@@ -4,57 +4,57 @@ option(CURL_HIDDEN_SYMBOLS "Set to ON to hide libcurl internal symbols (=hide al
mark_as_advanced(CURL_HIDDEN_SYMBOLS)
if(CURL_HIDDEN_SYMBOLS)
- set(SUPPORTS_SYMBOL_HIDING FALSE)
+ set(SUPPORTS_SYMBOL_HIDING FALSE)
- if(CMAKE_C_COMPILER_ID MATCHES "Clang")
- set(SUPPORTS_SYMBOL_HIDING TRUE)
- set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))")
- set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden")
- elseif(CMAKE_COMPILER_IS_GNUCC)
- if(NOT CMAKE_VERSION VERSION_LESS 2.8.10)
- set(GCC_VERSION ${CMAKE_C_COMPILER_VERSION})
- else()
- execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
- OUTPUT_VARIABLE GCC_VERSION)
- endif()
- if(NOT GCC_VERSION VERSION_LESS 3.4)
- # note: this is considered buggy prior to 4.0 but the autotools don't care, so let's ignore that fact
- set(SUPPORTS_SYMBOL_HIDING TRUE)
- set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))")
- set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden")
- endif()
- elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0)
- set(SUPPORTS_SYMBOL_HIDING TRUE)
- set(_SYMBOL_EXTERN "__global")
- set(_CFLAG_SYMBOLS_HIDE "-xldscope=hidden")
- elseif(CMAKE_C_COMPILER_ID MATCHES "Intel" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0)
- # note: this should probably just check for version 9.1.045 but I'm not 100% sure
- # so let's to it the same way autotools do.
- set(SUPPORTS_SYMBOL_HIDING TRUE)
- set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))")
- set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden")
- check_c_source_compiles("#include <stdio.h>
- int main (void) { printf(\"icc fvisibility bug test\"); return 0; }" _no_bug)
- if(NOT _no_bug)
- set(SUPPORTS_SYMBOL_HIDING FALSE)
- set(_SYMBOL_EXTERN "")
- set(_CFLAG_SYMBOLS_HIDE "")
- endif()
- elseif(MSVC)
- set(SUPPORTS_SYMBOL_HIDING TRUE)
+ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+ set(SUPPORTS_SYMBOL_HIDING TRUE)
+ set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))")
+ set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden")
+ elseif(CMAKE_COMPILER_IS_GNUCC)
+ if(NOT CMAKE_VERSION VERSION_LESS 2.8.10)
+ set(GCC_VERSION ${CMAKE_C_COMPILER_VERSION})
+ else()
+ execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
+ OUTPUT_VARIABLE GCC_VERSION)
+ endif()
+ if(NOT GCC_VERSION VERSION_LESS 3.4)
+ # note: this is considered buggy prior to 4.0 but the autotools don't care, so let's ignore that fact
+ set(SUPPORTS_SYMBOL_HIDING TRUE)
+ set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))")
+ set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden")
+ endif()
+ elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0)
+ set(SUPPORTS_SYMBOL_HIDING TRUE)
+ set(_SYMBOL_EXTERN "__global")
+ set(_CFLAG_SYMBOLS_HIDE "-xldscope=hidden")
+ elseif(CMAKE_C_COMPILER_ID MATCHES "Intel" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0)
+ # note: this should probably just check for version 9.1.045 but I'm not 100% sure
+ # so let's to it the same way autotools do.
+ set(SUPPORTS_SYMBOL_HIDING TRUE)
+ set(_SYMBOL_EXTERN "__attribute__ ((__visibility__ (\"default\")))")
+ set(_CFLAG_SYMBOLS_HIDE "-fvisibility=hidden")
+ check_c_source_compiles("#include <stdio.h>
+ int main (void) { printf(\"icc fvisibility bug test\"); return 0; }" _no_bug)
+ if(NOT _no_bug)
+ set(SUPPORTS_SYMBOL_HIDING FALSE)
+ set(_SYMBOL_EXTERN "")
+ set(_CFLAG_SYMBOLS_HIDE "")
endif()
+ elseif(MSVC)
+ set(SUPPORTS_SYMBOL_HIDING TRUE)
+ endif()
- set(HIDES_CURL_PRIVATE_SYMBOLS ${SUPPORTS_SYMBOL_HIDING})
+ set(HIDES_CURL_PRIVATE_SYMBOLS ${SUPPORTS_SYMBOL_HIDING})
elseif(MSVC)
- if(NOT CMAKE_VERSION VERSION_LESS 3.7)
- set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) #present since 3.4.3 but broken
- set(HIDES_CURL_PRIVATE_SYMBOLS FALSE)
- else()
- message(WARNING "Hiding private symbols regardless CURL_HIDDEN_SYMBOLS being disabled.")
- set(HIDES_CURL_PRIVATE_SYMBOLS TRUE)
- endif()
-elseif()
+ if(NOT CMAKE_VERSION VERSION_LESS 3.7)
+ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) #present since 3.4.3 but broken
set(HIDES_CURL_PRIVATE_SYMBOLS FALSE)
+ else()
+ message(WARNING "Hiding private symbols regardless CURL_HIDDEN_SYMBOLS being disabled.")
+ set(HIDES_CURL_PRIVATE_SYMBOLS TRUE)
+ endif()
+else()
+ set(HIDES_CURL_PRIVATE_SYMBOLS FALSE)
endif()
set(CURL_CFLAG_SYMBOLS_HIDE ${_CFLAG_SYMBOLS_HIDE})
diff --git a/Utilities/cmcurl/CMake/CurlTests.c b/Utilities/cmcurl/CMake/CurlTests.c
index bc36c8ef7..07b516b4d 100644
--- a/Utilities/cmcurl/CMake/CurlTests.c
+++ b/Utilities/cmcurl/CMake/CurlTests.c
@@ -240,6 +240,7 @@ int main()
#ifndef inet_ntoa_r
func_type func;
func = (func_type)inet_ntoa_r;
+ (void)func;
#endif
return 0;
}
@@ -255,6 +256,7 @@ int main()
#ifndef inet_ntoa_r
func_type func;
func = (func_type)&inet_ntoa_r;
+ (void)func;
#endif
return 0;
}
@@ -507,30 +509,30 @@ main ()
#ifdef HAVE_GLIBC_STRERROR_R
#include <string.h>
#include <errno.h>
+
+void check(char c) {}
+
int
main () {
- char buffer[1024]; /* big enough to play with */
- char *string =
- strerror_r(EACCES, buffer, sizeof(buffer));
- /* this should've returned a string */
- if(!string || !string[0])
- return 99;
- return 0;
+ char buffer[1024];
+ /* This will not compile if strerror_r does not return a char* */
+ check(strerror_r(EACCES, buffer, sizeof(buffer))[0]);
+ return 0;
}
#endif
#ifdef HAVE_POSIX_STRERROR_R
#include <string.h>
#include <errno.h>
+
+/* float, because a pointer can't be implicitly cast to float */
+void check(float f) {}
+
int
main () {
- char buffer[1024]; /* big enough to play with */
- int error =
- strerror_r(EACCES, buffer, sizeof(buffer));
- /* This should've returned zero, and written an error string in the
- buffer.*/
- if(!buffer[0] || error)
- return 99;
- return 0;
+ char buffer[1024];
+ /* This will not compile if strerror_r does not return an int */
+ check(strerror_r(EACCES, buffer, sizeof(buffer)));
+ return 0;
}
#endif
#ifdef HAVE_FSETXATTR_6
@@ -549,3 +551,65 @@ main() {
return 0;
}
#endif
+#ifdef HAVE_CLOCK_GETTIME_MONOTONIC
+#include <time.h>
+int
+main() {
+ struct timespec ts = {0, 0};
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return 0;
+}
+#endif
+#ifdef HAVE_BUILTIN_AVAILABLE
+int
+main() {
+ if(__builtin_available(macOS 10.12, *)) {}
+ return 0;
+}
+#endif
+#ifdef HAVE_VARIADIC_MACROS_C99
+#define c99_vmacro3(first, ...) fun3(first, __VA_ARGS__)
+#define c99_vmacro2(first, ...) fun2(first, __VA_ARGS__)
+
+int fun3(int arg1, int arg2, int arg3);
+int fun2(int arg1, int arg2);
+
+int fun3(int arg1, int arg2, int arg3) {
+ return arg1 + arg2 + arg3;
+}
+int fun2(int arg1, int arg2) {
+ return arg1 + arg2;
+}
+
+int
+main() {
+ int res3 = c99_vmacro3(1, 2, 3);
+ int res2 = c99_vmacro2(1, 2);
+ (void)res3;
+ (void)res2;
+ return 0;
+}
+#endif
+#ifdef HAVE_VARIADIC_MACROS_GCC
+#define gcc_vmacro3(first, args...) fun3(first, args)
+#define gcc_vmacro2(first, args...) fun2(first, args)
+
+int fun3(int arg1, int arg2, int arg3);
+int fun2(int arg1, int arg2);
+
+int fun3(int arg1, int arg2, int arg3) {
+ return arg1 + arg2 + arg3;
+}
+int fun2(int arg1, int arg2) {
+ return arg1 + arg2;
+}
+
+int
+main() {
+ int res3 = gcc_vmacro3(1, 2, 3);
+ int res2 = gcc_vmacro2(1, 2);
+ (void)res3;
+ (void)res2;
+ return 0;
+}
+#endif
diff --git a/Utilities/cmcurl/CMake/FindBrotli.cmake b/Utilities/cmcurl/CMake/FindBrotli.cmake
new file mode 100644
index 000000000..351b8f757
--- /dev/null
+++ b/Utilities/cmcurl/CMake/FindBrotli.cmake
@@ -0,0 +1,20 @@
+include(FindPackageHandleStandardArgs)
+
+find_path(BROTLI_INCLUDE_DIR "brotli/decode.h")
+
+find_library(BROTLICOMMON_LIBRARY NAMES brotlicommon)
+find_library(BROTLIDEC_LIBRARY NAMES brotlidec)
+
+find_package_handle_standard_args(BROTLI
+ FOUND_VAR
+ BROTLI_FOUND
+ REQUIRED_VARS
+ BROTLIDEC_LIBRARY
+ BROTLICOMMON_LIBRARY
+ BROTLI_INCLUDE_DIR
+ FAIL_MESSAGE
+ "Could NOT find BROTLI"
+)
+
+set(BROTLI_INCLUDE_DIRS ${BROTLI_INCLUDE_DIR})
+set(BROTLI_LIBRARIES ${BROTLICOMMON_LIBRARY} ${BROTLIDEC_LIBRARY})
diff --git a/Utilities/cmcurl/CMake/FindCARES.cmake b/Utilities/cmcurl/CMake/FindCARES.cmake
index c4ab5f132..723044a64 100644
--- a/Utilities/cmcurl/CMake/FindCARES.cmake
+++ b/Utilities/cmcurl/CMake/FindCARES.cmake
@@ -7,36 +7,36 @@
# also defined, but not for general use are
# CARES_LIBRARY, where to find the c-ares library.
-FIND_PATH(CARES_INCLUDE_DIR ares.h
+find_path(CARES_INCLUDE_DIR ares.h
/usr/local/include
/usr/include
)
-SET(CARES_NAMES ${CARES_NAMES} cares)
-FIND_LIBRARY(CARES_LIBRARY
+set(CARES_NAMES ${CARES_NAMES} cares)
+find_library(CARES_LIBRARY
NAMES ${CARES_NAMES}
PATHS /usr/lib /usr/local/lib
)
-IF (CARES_LIBRARY AND CARES_INCLUDE_DIR)
- SET(CARES_LIBRARIES ${CARES_LIBRARY})
- SET(CARES_FOUND "YES")
-ELSE (CARES_LIBRARY AND CARES_INCLUDE_DIR)
- SET(CARES_FOUND "NO")
-ENDIF (CARES_LIBRARY AND CARES_INCLUDE_DIR)
+if(CARES_LIBRARY AND CARES_INCLUDE_DIR)
+ set(CARES_LIBRARIES ${CARES_LIBRARY})
+ set(CARES_FOUND "YES")
+else()
+ set(CARES_FOUND "NO")
+endif()
-IF (CARES_FOUND)
- IF (NOT CARES_FIND_QUIETLY)
- MESSAGE(STATUS "Found c-ares: ${CARES_LIBRARIES}")
- ENDIF (NOT CARES_FIND_QUIETLY)
-ELSE (CARES_FOUND)
- IF (CARES_FIND_REQUIRED)
- MESSAGE(FATAL_ERROR "Could not find c-ares library")
- ENDIF (CARES_FIND_REQUIRED)
-ENDIF (CARES_FOUND)
+if(CARES_FOUND)
+ if(NOT CARES_FIND_QUIETLY)
+ message(STATUS "Found c-ares: ${CARES_LIBRARIES}")
+ endif()
+else()
+ if(CARES_FIND_REQUIRED)
+ message(FATAL_ERROR "Could not find c-ares library")
+ endif()
+endif()
-MARK_AS_ADVANCED(
+mark_as_advanced(
CARES_LIBRARY
CARES_INCLUDE_DIR
)
diff --git a/Utilities/cmcurl/CMake/FindGSS.cmake b/Utilities/cmcurl/CMake/FindGSS.cmake
index 60dcb73c9..8a28f2fb6 100644
--- a/Utilities/cmcurl/CMake/FindGSS.cmake
+++ b/Utilities/cmcurl/CMake/FindGSS.cmake
@@ -28,211 +28,209 @@ set(_GSS_ROOT_HINTS
# try to find library using system pkg-config if user didn't specify root dir
if(NOT GSS_ROOT_DIR AND NOT "$ENV{GSS_ROOT_DIR}")
- if(UNIX)
- find_package(PkgConfig QUIET)
- pkg_search_module(_GSS_PKG ${_MIT_MODNAME} ${_HEIMDAL_MODNAME})
- list(APPEND _GSS_ROOT_HINTS "${_GSS_PKG_PREFIX}")
- elseif(WIN32)
- list(APPEND _GSS_ROOT_HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos;InstallDir]")
- endif()
+ if(UNIX)
+ find_package(PkgConfig QUIET)
+ pkg_search_module(_GSS_PKG ${_MIT_MODNAME} ${_HEIMDAL_MODNAME})
+ list(APPEND _GSS_ROOT_HINTS "${_GSS_PKG_PREFIX}")
+ elseif(WIN32)
+ list(APPEND _GSS_ROOT_HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos;InstallDir]")
+ endif()
endif()
if(NOT _GSS_FOUND) #not found by pkg-config. Let's take more traditional approach.
- find_file(_GSS_CONFIGURE_SCRIPT
- NAMES
- "krb5-config"
- HINTS
- ${_GSS_ROOT_HINTS}
- PATH_SUFFIXES
- bin
- NO_CMAKE_PATH
- NO_CMAKE_ENVIRONMENT_PATH
+ find_file(_GSS_CONFIGURE_SCRIPT
+ NAMES
+ "krb5-config"
+ HINTS
+ ${_GSS_ROOT_HINTS}
+ PATH_SUFFIXES
+ bin
+ NO_CMAKE_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ )
+
+ # if not found in user-supplied directories, maybe system knows better
+ find_file(_GSS_CONFIGURE_SCRIPT
+ NAMES
+ "krb5-config"
+ PATH_SUFFIXES
+ bin
+ )
+
+ if(_GSS_CONFIGURE_SCRIPT)
+ execute_process(
+ COMMAND ${_GSS_CONFIGURE_SCRIPT} "--cflags" "gssapi"
+ OUTPUT_VARIABLE _GSS_CFLAGS
+ RESULT_VARIABLE _GSS_CONFIGURE_FAILED
+ )
+ message(STATUS "CFLAGS: ${_GSS_CFLAGS}")
+ if(NOT _GSS_CONFIGURE_FAILED) # 0 means success
+ # should also work in an odd case when multiple directories are given
+ string(STRIP "${_GSS_CFLAGS}" _GSS_CFLAGS)
+ string(REGEX REPLACE " +-I" ";" _GSS_CFLAGS "${_GSS_CFLAGS}")
+ string(REGEX REPLACE " +-([^I][^ \\t;]*)" ";-\\1" _GSS_CFLAGS "${_GSS_CFLAGS}")
+
+ foreach(_flag ${_GSS_CFLAGS})
+ if(_flag MATCHES "^-I.*")
+ string(REGEX REPLACE "^-I" "" _val "${_flag}")
+ list(APPEND _GSS_INCLUDE_DIR "${_val}")
+ else()
+ list(APPEND _GSS_COMPILER_FLAGS "${_flag}")
+ endif()
+ endforeach()
+ endif()
+
+ execute_process(
+ COMMAND ${_GSS_CONFIGURE_SCRIPT} "--libs" "gssapi"
+ OUTPUT_VARIABLE _GSS_LIB_FLAGS
+ RESULT_VARIABLE _GSS_CONFIGURE_FAILED
)
+ message(STATUS "LDFLAGS: ${_GSS_LIB_FLAGS}")
+
+ if(NOT _GSS_CONFIGURE_FAILED) # 0 means success
+ # this script gives us libraries and link directories. Blah. We have to deal with it.
+ string(STRIP "${_GSS_LIB_FLAGS}" _GSS_LIB_FLAGS)
+ string(REGEX REPLACE " +-(L|l)" ";-\\1" _GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}")
+ string(REGEX REPLACE " +-([^Ll][^ \\t;]*)" ";-\\1" _GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}")
+
+ foreach(_flag ${_GSS_LIB_FLAGS})
+ if(_flag MATCHES "^-l.*")
+ string(REGEX REPLACE "^-l" "" _val "${_flag}")
+ list(APPEND _GSS_LIBRARIES "${_val}")
+ elseif(_flag MATCHES "^-L.*")
+ string(REGEX REPLACE "^-L" "" _val "${_flag}")
+ list(APPEND _GSS_LINK_DIRECTORIES "${_val}")
+ else()
+ list(APPEND _GSS_LINKER_FLAGS "${_flag}")
+ endif()
+ endforeach()
+ endif()
- # if not found in user-supplied directories, maybe system knows better
- find_file(_GSS_CONFIGURE_SCRIPT
- NAMES
- "krb5-config"
- PATH_SUFFIXES
- bin
+ execute_process(
+ COMMAND ${_GSS_CONFIGURE_SCRIPT} "--version"
+ OUTPUT_VARIABLE _GSS_VERSION
+ RESULT_VARIABLE _GSS_CONFIGURE_FAILED
)
- if(_GSS_CONFIGURE_SCRIPT)
- execute_process(
- COMMAND ${_GSS_CONFIGURE_SCRIPT} "--cflags" "gssapi"
- OUTPUT_VARIABLE _GSS_CFLAGS
- RESULT_VARIABLE _GSS_CONFIGURE_FAILED
- )
-message(STATUS "CFLAGS: ${_GSS_CFLAGS}")
- if(NOT _GSS_CONFIGURE_FAILED) # 0 means success
- # should also work in an odd case when multiple directories are given
- string(STRIP "${_GSS_CFLAGS}" _GSS_CFLAGS)
- string(REGEX REPLACE " +-I" ";" _GSS_CFLAGS "${_GSS_CFLAGS}")
- string(REGEX REPLACE " +-([^I][^ \\t;]*)" ";-\\1"_GSS_CFLAGS "${_GSS_CFLAGS}")
-
- foreach(_flag ${_GSS_CFLAGS})
- if(_flag MATCHES "^-I.*")
- string(REGEX REPLACE "^-I" "" _val "${_flag}")
- list(APPEND _GSS_INCLUDE_DIR "${_val}")
- else()
- list(APPEND _GSS_COMPILER_FLAGS "${_flag}")
- endif()
- endforeach()
- endif()
+ # older versions may not have the "--version" parameter. In this case we just don't care.
+ if(_GSS_CONFIGURE_FAILED)
+ set(_GSS_VERSION 0)
+ endif()
- execute_process(
- COMMAND ${_GSS_CONFIGURE_SCRIPT} "--libs" "gssapi"
- OUTPUT_VARIABLE _GSS_LIB_FLAGS
- RESULT_VARIABLE _GSS_CONFIGURE_FAILED
- )
-message(STATUS "LDFLAGS: ${_GSS_LIB_FLAGS}")
- if(NOT _GSS_CONFIGURE_FAILED) # 0 means success
- # this script gives us libraries and link directories. Blah. We have to deal with it.
- string(STRIP "${_GSS_LIB_FLAGS}" _GSS_LIB_FLAGS)
- string(REGEX REPLACE " +-(L|l)" ";-\\1" _GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}")
- string(REGEX REPLACE " +-([^Ll][^ \\t;]*)" ";-\\1"_GSS_LIB_FLAGS "${_GSS_LIB_FLAGS}")
-
- foreach(_flag ${_GSS_LIB_FLAGS})
- if(_flag MATCHES "^-l.*")
- string(REGEX REPLACE "^-l" "" _val "${_flag}")
- list(APPEND _GSS_LIBRARIES "${_val}")
- elseif(_flag MATCHES "^-L.*")
- string(REGEX REPLACE "^-L" "" _val "${_flag}")
- list(APPEND _GSS_LINK_DIRECTORIES "${_val}")
- else()
- list(APPEND _GSS_LINKER_FLAGS "${_flag}")
- endif()
- endforeach()
- endif()
+ execute_process(
+ COMMAND ${_GSS_CONFIGURE_SCRIPT} "--vendor"
+ OUTPUT_VARIABLE _GSS_VENDOR
+ RESULT_VARIABLE _GSS_CONFIGURE_FAILED
+ )
+ # older versions may not have the "--vendor" parameter. In this case we just don't care.
+ if(_GSS_CONFIGURE_FAILED)
+ set(GSS_FLAVOUR "Heimdal") # most probably, shouldn't really matter
+ else()
+ if(_GSS_VENDOR MATCHES ".*H|heimdal.*")
+ set(GSS_FLAVOUR "Heimdal")
+ else()
+ set(GSS_FLAVOUR "MIT")
+ endif()
+ endif()
- execute_process(
- COMMAND ${_GSS_CONFIGURE_SCRIPT} "--version"
- OUTPUT_VARIABLE _GSS_VERSION
- RESULT_VARIABLE _GSS_CONFIGURE_FAILED
- )
+ else() # either there is no config script or we are on platform that doesn't provide one (Windows?)
- # older versions may not have the "--version" parameter. In this case we just don't care.
- if(_GSS_CONFIGURE_FAILED)
- set(_GSS_VERSION 0)
- endif()
+ find_path(_GSS_INCLUDE_DIR
+ NAMES
+ "gssapi/gssapi.h"
+ HINTS
+ ${_GSS_ROOT_HINTS}
+ PATH_SUFFIXES
+ include
+ inc
+ )
+ if(_GSS_INCLUDE_DIR) #jay, we've found something
+ set(CMAKE_REQUIRED_INCLUDES "${_GSS_INCLUDE_DIR}")
+ check_include_files( "gssapi/gssapi_generic.h;gssapi/gssapi_krb5.h" _GSS_HAVE_MIT_HEADERS)
- execute_process(
- COMMAND ${_GSS_CONFIGURE_SCRIPT} "--vendor"
- OUTPUT_VARIABLE _GSS_VENDOR
- RESULT_VARIABLE _GSS_CONFIGURE_FAILED
- )
+ if(_GSS_HAVE_MIT_HEADERS)
+ set(GSS_FLAVOUR "MIT")
+ else()
+ # prevent compiling the header - just check if we can include it
+ set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D__ROKEN_H__")
+ check_include_file( "roken.h" _GSS_HAVE_ROKEN_H)
+
+ check_include_file( "heimdal/roken.h" _GSS_HAVE_HEIMDAL_ROKEN_H)
+ if(_GSS_HAVE_ROKEN_H OR _GSS_HAVE_HEIMDAL_ROKEN_H)
+ set(GSS_FLAVOUR "Heimdal")
+ endif()
+ set(CMAKE_REQUIRED_DEFINITIONS "")
+ endif()
+ else()
+ # I'm not convienced if this is the right way but this is what autotools do at the moment
+ find_path(_GSS_INCLUDE_DIR
+ NAMES
+ "gssapi.h"
+ HINTS
+ ${_GSS_ROOT_HINTS}
+ PATH_SUFFIXES
+ include
+ inc
+ )
+
+ if(_GSS_INCLUDE_DIR)
+ set(GSS_FLAVOUR "Heimdal")
+ endif()
+ endif()
+
+ # if we have headers, check if we can link libraries
+ if(GSS_FLAVOUR)
+ set(_GSS_LIBDIR_SUFFIXES "")
+ set(_GSS_LIBDIR_HINTS ${_GSS_ROOT_HINTS})
+ get_filename_component(_GSS_CALCULATED_POTENTIAL_ROOT "${_GSS_INCLUDE_DIR}" PATH)
+ list(APPEND _GSS_LIBDIR_HINTS ${_GSS_CALCULATED_POTENTIAL_ROOT})
- # older versions may not have the "--vendor" parameter. In this case we just don't care.
- if(_GSS_CONFIGURE_FAILED)
- set(GSS_FLAVOUR "Heimdal") # most probably, shouldn't really matter
+ if(WIN32)
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ list(APPEND _GSS_LIBDIR_SUFFIXES "lib/AMD64")
+ if(GSS_FLAVOUR STREQUAL "MIT")
+ set(_GSS_LIBNAME "gssapi64")
+ else()
+ set(_GSS_LIBNAME "libgssapi")
+ endif()
else()
- if(_GSS_VENDOR MATCHES ".*H|heimdal.*")
- set(GSS_FLAVOUR "Heimdal")
- else()
- set(GSS_FLAVOUR "MIT")
- endif()
+ list(APPEND _GSS_LIBDIR_SUFFIXES "lib/i386")
+ if(GSS_FLAVOUR STREQUAL "MIT")
+ set(_GSS_LIBNAME "gssapi32")
+ else()
+ set(_GSS_LIBNAME "libgssapi")
+ endif()
endif()
-
- else() # either there is no config script or we are on platform that doesn't provide one (Windows?)
-
- find_path(_GSS_INCLUDE_DIR
- NAMES
- "gssapi/gssapi.h"
- HINTS
- ${_GSS_ROOT_HINTS}
- PATH_SUFFIXES
- include
- inc
- )
-
- if(_GSS_INCLUDE_DIR) #jay, we've found something
- set(CMAKE_REQUIRED_INCLUDES "${_GSS_INCLUDE_DIR}")
- check_include_files( "gssapi/gssapi_generic.h;gssapi/gssapi_krb5.h" _GSS_HAVE_MIT_HEADERS)
-
- if(_GSS_HAVE_MIT_HEADERS)
- set(GSS_FLAVOUR "MIT")
- else()
- # prevent compiling the header - just check if we can include it
- set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D__ROKEN_H__")
- check_include_file( "roken.h" _GSS_HAVE_ROKEN_H)
-
- check_include_file( "heimdal/roken.h" _GSS_HAVE_HEIMDAL_ROKEN_H)
- if(_GSS_HAVE_ROKEN_H OR _GSS_HAVE_HEIMDAL_ROKEN_H)
- set(GSS_FLAVOUR "Heimdal")
- endif()
- set(CMAKE_REQUIRED_DEFINITIONS "")
- endif()
+ else()
+ list(APPEND _GSS_LIBDIR_SUFFIXES "lib;lib64") # those suffixes are not checked for HINTS
+ if(GSS_FLAVOUR STREQUAL "MIT")
+ set(_GSS_LIBNAME "gssapi_krb5")
else()
- # I'm not convienced if this is the right way but this is what autotools do at the moment
- find_path(_GSS_INCLUDE_DIR
- NAMES
- "gssapi.h"
- HINTS
- ${_GSS_ROOT_HINTS}
- PATH_SUFFIXES
- include
- inc
- )
-
- if(_GSS_INCLUDE_DIR)
- set(GSS_FLAVOUR "Heimdal")
- endif()
+ set(_GSS_LIBNAME "gssapi")
endif()
+ endif()
- # if we have headers, check if we can link libraries
- if(GSS_FLAVOUR)
- set(_GSS_LIBDIR_SUFFIXES "")
- set(_GSS_LIBDIR_HINTS ${_GSS_ROOT_HINTS})
- get_filename_component(_GSS_CALCULATED_POTENTIAL_ROOT "${_GSS_INCLUDE_DIR}" PATH)
- list(APPEND _GSS_LIBDIR_HINTS ${_GSS_CALCULATED_POTENTIAL_ROOT})
-
- if(WIN32)
- if(CMAKE_SIZEOF_VOID_P EQUAL 8)
- list(APPEND _GSS_LIBDIR_SUFFIXES "lib/AMD64")
- if(GSS_FLAVOUR STREQUAL "MIT")
- set(_GSS_LIBNAME "gssapi64")
- else()
- set(_GSS_LIBNAME "libgssapi")
- endif()
- else()
- list(APPEND _GSS_LIBDIR_SUFFIXES "lib/i386")
- if(GSS_FLAVOUR STREQUAL "MIT")
- set(_GSS_LIBNAME "gssapi32")
- else()
- set(_GSS_LIBNAME "libgssapi")
- endif()
- endif()
- else()
- list(APPEND _GSS_LIBDIR_SUFFIXES "lib;lib64") # those suffixes are not checked for HINTS
- if(GSS_FLAVOUR STREQUAL "MIT")
- set(_GSS_LIBNAME "gssapi_krb5")
- else()
- set(_GSS_LIBNAME "gssapi")
- endif()
- endif()
-
- find_library(_GSS_LIBRARIES
- NAMES
- ${_GSS_LIBNAME}
- HINTS
- ${_GSS_LIBDIR_HINTS}
- PATH_SUFFIXES
- ${_GSS_LIBDIR_SUFFIXES}
- )
-
- endif()
+ find_library(_GSS_LIBRARIES
+ NAMES
+ ${_GSS_LIBNAME}
+ HINTS
+ ${_GSS_LIBDIR_HINTS}
+ PATH_SUFFIXES
+ ${_GSS_LIBDIR_SUFFIXES}
+ )
endif()
+ endif()
else()
- if(_GSS_PKG_${_MIT_MODNAME}_VERSION)
- set(GSS_FLAVOUR "MIT")
- set(_GSS_VERSION _GSS_PKG_${_MIT_MODNAME}_VERSION)
- else()
- set(GSS_FLAVOUR "Heimdal")
- set(_GSS_VERSION _GSS_PKG_${_MIT_HEIMDAL}_VERSION)
- endif()
+ if(_GSS_PKG_${_MIT_MODNAME}_VERSION)
+ set(GSS_FLAVOUR "MIT")
+ set(_GSS_VERSION _GSS_PKG_${_MIT_MODNAME}_VERSION)
+ else()
+ set(GSS_FLAVOUR "Heimdal")
+ set(_GSS_VERSION _GSS_PKG_${_MIT_HEIMDAL}_VERSION)
+ endif()
endif()
set(GSS_INCLUDE_DIR ${_GSS_INCLUDE_DIR})
@@ -243,36 +241,34 @@ set(GSS_COMPILER_FLAGS ${_GSS_COMPILER_FLAGS})
set(GSS_VERSION ${_GSS_VERSION})
if(GSS_FLAVOUR)
+ if(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "Heimdal")
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.amd64.manifest")
+ else()
+ set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.x86.manifest")
+ endif()
- if(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "Heimdal")
- if(CMAKE_SIZEOF_VOID_P EQUAL 8)
- set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.amd64.manifest")
- else()
- set(HEIMDAL_MANIFEST_FILE "Heimdal.Application.x86.manifest")
- endif()
-
- if(EXISTS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}")
- file(STRINGS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}" heimdal_version_str
- REGEX "^.*version=\"[0-9]\\.[^\"]+\".*$")
+ if(EXISTS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}")
+ file(STRINGS "${GSS_INCLUDE_DIR}/${HEIMDAL_MANIFEST_FILE}" heimdal_version_str
+ REGEX "^.*version=\"[0-9]\\.[^\"]+\".*$")
- string(REGEX MATCH "[0-9]\\.[^\"]+"
- GSS_VERSION "${heimdal_version_str}")
- endif()
+ string(REGEX MATCH "[0-9]\\.[^\"]+"
+ GSS_VERSION "${heimdal_version_str}")
+ endif()
- if(NOT GSS_VERSION)
- set(GSS_VERSION "Heimdal Unknown")
- endif()
- elseif(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "MIT")
- get_filename_component(_MIT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos\\SDK\\CurrentVersion;VersionString]" NAME CACHE)
- if(WIN32 AND _MIT_VERSION)
- set(GSS_VERSION "${_MIT_VERSION}")
- else()
- set(GSS_VERSION "MIT Unknown")
- endif()
+ if(NOT GSS_VERSION)
+ set(GSS_VERSION "Heimdal Unknown")
endif()
+ elseif(NOT GSS_VERSION AND GSS_FLAVOUR STREQUAL "MIT")
+ get_filename_component(_MIT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MIT\\Kerberos\\SDK\\CurrentVersion;VersionString]" NAME CACHE)
+ if(WIN32 AND _MIT_VERSION)
+ set(GSS_VERSION "${_MIT_VERSION}")
+ else()
+ set(GSS_VERSION "MIT Unknown")
+ endif()
+ endif()
endif()
-
include(FindPackageHandleStandardArgs)
set(_GSS_REQUIRED_VARS GSS_LIBRARIES GSS_FLAVOUR)
diff --git a/Utilities/cmcurl/CMake/FindLibSSH2.cmake b/Utilities/cmcurl/CMake/FindLibSSH2.cmake
index 12a7c612b..84822dba7 100644
--- a/Utilities/cmcurl/CMake/FindLibSSH2.cmake
+++ b/Utilities/cmcurl/CMake/FindLibSSH2.cmake
@@ -5,14 +5,14 @@
# LIBSSH2_INCLUDE_DIR - the libssh2 include directory
# LIBSSH2_LIBRARY - the libssh2 library name
-if (LIBSSH2_INCLUDE_DIR AND LIBSSH2_LIBRARY)
+if(LIBSSH2_INCLUDE_DIR AND LIBSSH2_LIBRARY)
set(LibSSH2_FIND_QUIETLY TRUE)
-endif (LIBSSH2_INCLUDE_DIR AND LIBSSH2_LIBRARY)
+endif()
-FIND_PATH(LIBSSH2_INCLUDE_DIR libssh2.h
+find_path(LIBSSH2_INCLUDE_DIR libssh2.h
)
-FIND_LIBRARY(LIBSSH2_LIBRARY NAMES ssh2
+find_library(LIBSSH2_LIBRARY NAMES ssh2
)
if(LIBSSH2_INCLUDE_DIR)
@@ -27,9 +27,9 @@ if(LIBSSH2_INCLUDE_DIR)
string(REGEX REPLACE "^0(.+)" "\\1" LIBSSH2_VERSION_PATCH "${LIBSSH2_VERSION_PATCH}")
set(LIBSSH2_VERSION "${LIBSSH2_VERSION_MAJOR}.${LIBSSH2_VERSION_MINOR}.${LIBSSH2_VERSION_PATCH}")
-endif(LIBSSH2_INCLUDE_DIR)
+endif()
include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibSSH2 DEFAULT_MSG LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY )
+find_package_handle_standard_args(LibSSH2 DEFAULT_MSG LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY )
-MARK_AS_ADVANCED(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY LIBSSH2_VERSION_MAJOR LIBSSH2_VERSION_MINOR LIBSSH2_VERSION_PATCH LIBSSH2_VERSION)
+mark_as_advanced(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY LIBSSH2_VERSION_MAJOR LIBSSH2_VERSION_MINOR LIBSSH2_VERSION_PATCH LIBSSH2_VERSION)
diff --git a/Utilities/cmcurl/CMake/FindNGHTTP2.cmake b/Utilities/cmcurl/CMake/FindNGHTTP2.cmake
index 4e566cf02..348b9612d 100644
--- a/Utilities/cmcurl/CMake/FindNGHTTP2.cmake
+++ b/Utilities/cmcurl/CMake/FindNGHTTP2.cmake
@@ -14,5 +14,5 @@ find_package_handle_standard_args(NGHTTP2
"Could NOT find NGHTTP2"
)
-set(NGHTTP2_INCLUDE_DIRS ${NGHTTP2_INCLUDE_DIR} )
+set(NGHTTP2_INCLUDE_DIRS ${NGHTTP2_INCLUDE_DIR})
set(NGHTTP2_LIBRARIES ${NGHTTP2_LIBRARY})
diff --git a/Utilities/cmcurl/CMake/Macros.cmake b/Utilities/cmcurl/CMake/Macros.cmake
index dab005f73..7f7134515 100644
--- a/Utilities/cmcurl/CMake/Macros.cmake
+++ b/Utilities/cmcurl/CMake/Macros.cmake
@@ -5,35 +5,35 @@
# multiple times with a sequence of possibly dependent libraries in
# order of least-to-most-dependent. Some libraries depend on others
# to link correctly.
-macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE)
+macro(check_library_exists_concat LIBRARY SYMBOL VARIABLE)
check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "${CMAKE_LIBRARY_PATH}"
${VARIABLE})
if(${VARIABLE})
set(CURL_LIBS ${LIBRARY} ${CURL_LIBS})
- endif(${VARIABLE})
-endmacro(CHECK_LIBRARY_EXISTS_CONCAT)
+ endif()
+endmacro()
# Check if header file exists and add it to the list.
# This macro is intended to be called multiple times with a sequence of
# possibly dependent header files. Some headers depend on others to be
# compiled correctly.
-macro(CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE)
+macro(check_include_file_concat FILE VARIABLE)
check_include_files("${CURL_INCLUDES};${FILE}" ${VARIABLE})
if(${VARIABLE})
set(CURL_INCLUDES ${CURL_INCLUDES} ${FILE})
set(CURL_TEST_DEFINES "${CURL_TEST_DEFINES} -D${VARIABLE}")
- endif(${VARIABLE})
-endmacro(CHECK_INCLUDE_FILE_CONCAT)
+ endif()
+endmacro()
# For other curl specific tests, use this macro.
-macro(CURL_INTERNAL_TEST CURL_TEST)
+macro(curl_internal_test CURL_TEST)
if(NOT DEFINED "${CURL_TEST}")
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${CURL_TEST} ${CURL_TEST_DEFINES} ${CMAKE_REQUIRED_FLAGS}")
if(CMAKE_REQUIRED_LIBRARIES)
set(CURL_TEST_ADD_LIBRARIES
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
- endif(CMAKE_REQUIRED_LIBRARIES)
+ endif()
message(STATUS "Performing Curl Test ${CURL_TEST}")
try_compile(${CURL_TEST}
@@ -48,48 +48,41 @@ macro(CURL_INTERNAL_TEST CURL_TEST)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Performing Curl Test ${CURL_TEST} passed with the following output:\n"
"${OUTPUT}\n")
- else(${CURL_TEST})
+ else()
message(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing Curl Test ${CURL_TEST} failed with the following output:\n"
"${OUTPUT}\n")
- endif(${CURL_TEST})
+ endif()
endif()
-endmacro(CURL_INTERNAL_TEST)
+endmacro()
-macro(CURL_INTERNAL_TEST_RUN CURL_TEST)
- if(NOT DEFINED "${CURL_TEST}_COMPILE")
- set(MACRO_CHECK_FUNCTION_DEFINITIONS
- "-D${CURL_TEST} ${CMAKE_REQUIRED_FLAGS}")
- if(CMAKE_REQUIRED_LIBRARIES)
- set(CURL_TEST_ADD_LIBRARIES
- "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
- endif(CMAKE_REQUIRED_LIBRARIES)
-
- message(STATUS "Performing Curl Test ${CURL_TEST}")
- try_run(${CURL_TEST} ${CURL_TEST}_COMPILE
- ${CMAKE_BINARY_DIR}
- ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CurlTests.c
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
- "${CURL_TEST_ADD_LIBRARIES}"
- OUTPUT_VARIABLE OUTPUT)
- if(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
- set(${CURL_TEST} 1 CACHE INTERNAL "Curl test ${FUNCTION}")
- message(STATUS "Performing Curl Test ${CURL_TEST} - Success")
- else(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
- message(STATUS "Performing Curl Test ${CURL_TEST} - Failed")
- set(${CURL_TEST} "" CACHE INTERNAL "Curl test ${FUNCTION}")
- file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
- "Performing Curl Test ${CURL_TEST} failed with the following output:\n"
- "${OUTPUT}")
- if(${CURL_TEST}_COMPILE)
- file(APPEND
- "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
- "There was a problem running this test\n")
- endif(${CURL_TEST}_COMPILE)
- file(APPEND "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
- "\n\n")
- endif(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
+macro(curl_nroff_check)
+ find_program(NROFF NAMES gnroff nroff)
+ if(NROFF)
+ # Need a way to write to stdin, this will do
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt" "test")
+ # Tests for a valid nroff option to generate a manpage
+ foreach(_MANOPT "-man" "-mandoc")
+ execute_process(COMMAND "${NROFF}" ${_MANOPT}
+ OUTPUT_VARIABLE NROFF_MANOPT_OUTPUT
+ INPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt"
+ ERROR_QUIET)
+ # Save the option if it was valid
+ if(NROFF_MANOPT_OUTPUT)
+ message("Found *nroff option: -- ${_MANOPT}")
+ set(NROFF_MANOPT ${_MANOPT})
+ set(NROFF_USEFUL ON)
+ break()
+ endif()
+ endforeach()
+ # No need for the temporary file
+ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt")
+ if(NOT NROFF_USEFUL)
+ message(WARNING "Found no *nroff option to get plaintext from man pages")
+ endif()
+ else()
+ message(WARNING "Found no *nroff program")
endif()
-endmacro(CURL_INTERNAL_TEST_RUN)
+endmacro()
diff --git a/Utilities/cmcurl/CMake/OtherTests.cmake b/Utilities/cmcurl/CMake/OtherTests.cmake
index 3b203c538..c1c9aa32a 100644
--- a/Utilities/cmcurl/CMake/OtherTests.cmake
+++ b/Utilities/cmcurl/CMake/OtherTests.cmake
@@ -5,8 +5,8 @@ set(_source_epilogue "#undef inline")
macro(add_header_include check header)
if(${check})
set(_source_epilogue "${_source_epilogue}\n#include <${header}>")
- endif(${check})
-endmacro(add_header_include)
+ endif()
+endmacro()
set(signature_call_conv)
if(HAVE_WINDOWS_H)
@@ -19,10 +19,12 @@ if(HAVE_WINDOWS_H)
if(HAVE_LIBWS2_32)
set(CMAKE_REQUIRED_LIBRARIES ws2_32)
endif()
-else(HAVE_WINDOWS_H)
+else()
add_header_include(HAVE_SYS_TYPES_H "sys/types.h")
add_header_include(HAVE_SYS_SOCKET_H "sys/socket.h")
-endif(HAVE_WINDOWS_H)
+endif()
+
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
check_c_source_compiles("${_source_epilogue}
int main(void) {
@@ -32,9 +34,9 @@ int main(void) {
if(curl_cv_recv)
if(NOT DEFINED curl_cv_func_recv_args OR "${curl_cv_func_recv_args}" STREQUAL "unknown")
foreach(recv_retv "int" "ssize_t" )
- foreach(recv_arg1 "int" "ssize_t" "SOCKET")
- foreach(recv_arg2 "void *" "char *")
- foreach(recv_arg3 "size_t" "int" "socklen_t" "unsigned int")
+ foreach(recv_arg1 "SOCKET" "int" )
+ foreach(recv_arg2 "char *" "void *" )
+ foreach(recv_arg3 "int" "size_t" "socklen_t" "unsigned int")
foreach(recv_arg4 "int" "unsigned int")
if(NOT curl_cv_func_recv_done)
unset(curl_cv_func_recv_test CACHE)
@@ -64,13 +66,13 @@ if(curl_cv_recv)
set(RECV_TYPE_RETV "${recv_retv}")
set(HAVE_RECV 1)
set(curl_cv_func_recv_done 1)
- endif(curl_cv_func_recv_test)
- endif(NOT curl_cv_func_recv_done)
- endforeach(recv_arg4)
- endforeach(recv_arg3)
- endforeach(recv_arg2)
- endforeach(recv_arg1)
- endforeach(recv_retv)
+ endif()
+ endif()
+ endforeach()
+ endforeach()
+ endforeach()
+ endforeach()
+ endforeach()
else()
string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG1 "${curl_cv_func_recv_args}")
string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG2 "${curl_cv_func_recv_args}")
@@ -81,10 +83,10 @@ if(curl_cv_recv)
if("${curl_cv_func_recv_args}" STREQUAL "unknown")
message(FATAL_ERROR "Cannot find proper types to use for recv args")
- endif("${curl_cv_func_recv_args}" STREQUAL "unknown")
-else(curl_cv_recv)
+ endif()
+else()
message(FATAL_ERROR "Unable to link function recv")
-endif(curl_cv_recv)
+endif()
set(curl_cv_func_recv_args "${curl_cv_func_recv_args}" CACHE INTERNAL "Arguments for recv")
set(HAVE_RECV 1)
@@ -96,9 +98,9 @@ int main(void) {
if(curl_cv_send)
if(NOT DEFINED curl_cv_func_send_args OR "${curl_cv_func_send_args}" STREQUAL "unknown")
foreach(send_retv "int" "ssize_t" )
- foreach(send_arg1 "int" "ssize_t" "SOCKET")
- foreach(send_arg2 "const void *" "void *" "char *" "const char *")
- foreach(send_arg3 "size_t" "int" "socklen_t" "unsigned int")
+ foreach(send_arg1 "SOCKET" "int" "ssize_t" )
+ foreach(send_arg2 "const char *" "const void *" "void *" "char *")
+ foreach(send_arg3 "int" "size_t" "socklen_t" "unsigned int")
foreach(send_arg4 "int" "unsigned int")
if(NOT curl_cv_func_send_done)
unset(curl_cv_func_send_test CACHE)
@@ -130,13 +132,13 @@ if(curl_cv_send)
set(SEND_TYPE_RETV "${send_retv}")
set(HAVE_SEND 1)
set(curl_cv_func_send_done 1)
- endif(curl_cv_func_send_test)
- endif(NOT curl_cv_func_send_done)
- endforeach(send_arg4)
- endforeach(send_arg3)
- endforeach(send_arg2)
- endforeach(send_arg1)
- endforeach(send_retv)
+ endif()
+ endif()
+ endforeach()
+ endforeach()
+ endforeach()
+ endforeach()
+ endforeach()
else()
string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG1 "${curl_cv_func_send_args}")
string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG2 "${curl_cv_func_send_args}")
@@ -148,11 +150,11 @@ if(curl_cv_send)
if("${curl_cv_func_send_args}" STREQUAL "unknown")
message(FATAL_ERROR "Cannot find proper types to use for send args")
- endif("${curl_cv_func_send_args}" STREQUAL "unknown")
+ endif()
set(SEND_QUAL_ARG2 "const")
-else(curl_cv_send)
+else()
message(FATAL_ERROR "Unable to link function send")
-endif(curl_cv_send)
+endif()
set(curl_cv_func_send_args "${curl_cv_func_send_args}" CACHE INTERNAL "Arguments for send")
set(HAVE_SEND 1)
@@ -177,29 +179,12 @@ int main(void) {
return 0;
}" HAVE_STRUCT_TIMEVAL)
-
-include(CheckCSourceRuns)
-# See HAVE_POLL in CMakeLists.txt for why poll is disabled on macOS
-if(NOT APPLE)
- set(CMAKE_REQUIRED_FLAGS)
- if(HAVE_SYS_POLL_H)
- set(CMAKE_REQUIRED_FLAGS "-DHAVE_SYS_POLL_H")
- endif(HAVE_SYS_POLL_H)
- check_c_source_runs("
- #ifdef HAVE_SYS_POLL_H
- # include <sys/poll.h>
- #endif
- int main(void) {
- return poll((void *)0, 0, 10 /*ms*/);
- }" HAVE_POLL_FINE)
-endif()
-
set(HAVE_SIG_ATOMIC_T 1)
set(CMAKE_REQUIRED_FLAGS)
if(HAVE_SIGNAL_H)
set(CMAKE_REQUIRED_FLAGS "-DHAVE_SIGNAL_H")
set(CMAKE_EXTRA_INCLUDE_FILES "signal.h")
-endif(HAVE_SIGNAL_H)
+endif()
check_type_size("sig_atomic_t" SIZEOF_SIG_ATOMIC_T)
if(HAVE_SIZEOF_SIG_ATOMIC_T)
check_c_source_compiles("
@@ -213,8 +198,8 @@ if(HAVE_SIZEOF_SIG_ATOMIC_T)
}" HAVE_SIG_ATOMIC_T_NOT_VOLATILE)
if(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE)
set(HAVE_SIG_ATOMIC_T_VOLATILE 1)
- endif(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE)
-endif(HAVE_SIZEOF_SIG_ATOMIC_T)
+ endif()
+endif()
if(HAVE_WINDOWS_H)
set(CMAKE_EXTRA_INCLUDE_FILES winsock2.h)
@@ -222,11 +207,58 @@ else()
set(CMAKE_EXTRA_INCLUDE_FILES)
if(HAVE_SYS_SOCKET_H)
set(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
- endif(HAVE_SYS_SOCKET_H)
+ endif()
endif()
check_type_size("struct sockaddr_storage" SIZEOF_STRUCT_SOCKADDR_STORAGE)
if(HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE)
set(HAVE_STRUCT_SOCKADDR_STORAGE 1)
-endif(HAVE_SIZEOF_STRUCT_SOCKADDR_STORAGE)
+endif()
+
+unset(CMAKE_TRY_COMPILE_TARGET_TYPE)
+
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
+ # if not cross-compilation...
+ include(CheckCSourceRuns)
+ set(CMAKE_REQUIRED_FLAGS "")
+ if(HAVE_SYS_POLL_H)
+ set(CMAKE_REQUIRED_FLAGS "-DHAVE_SYS_POLL_H")
+ elseif(HAVE_POLL_H)
+ set(CMAKE_REQUIRED_FLAGS "-DHAVE_POLL_H")
+ endif()
+ check_c_source_runs("
+ #include <stdlib.h>
+ #include <sys/time.h>
+
+ #ifdef HAVE_SYS_POLL_H
+ # include <sys/poll.h>
+ #elif HAVE_POLL_H
+ # include <poll.h>
+ #endif
+
+ int main(void)
+ {
+ if(0 != poll(0, 0, 10)) {
+ return 1; /* fail */
+ }
+ else {
+ /* detect the 10.12 poll() breakage */
+ struct timeval before, after;
+ int rc;
+ size_t us;
+
+ gettimeofday(&before, NULL);
+ rc = poll(NULL, 0, 500);
+ gettimeofday(&after, NULL);
+
+ us = (after.tv_sec - before.tv_sec) * 1000000 +
+ (after.tv_usec - before.tv_usec);
+
+ if(us < 400000) {
+ return 1;
+ }
+ }
+ return 0;
+ }" HAVE_POLL_FINE)
+endif()
diff --git a/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake b/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake
index 53d0a5e88..2dbe1bbbd 100644
--- a/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake
+++ b/Utilities/cmcurl/CMake/Platforms/WindowsCache.cmake
@@ -115,8 +115,7 @@ if(NOT UNIX)
set(HAVE_SIGACTION 0)
set(HAVE_MACRO_SIGSETJMP 0)
- else(WIN32)
+ else()
message("This file should be included on Windows platform only")
- endif(WIN32)
-endif(NOT UNIX)
-
+ endif()
+endif()
diff --git a/Utilities/cmcurl/CMake/Utilities.cmake b/Utilities/cmcurl/CMake/Utilities.cmake
index 8b6276df6..5cb1d4497 100644
--- a/Utilities/cmcurl/CMake/Utilities.cmake
+++ b/Utilities/cmcurl/CMake/Utilities.cmake
@@ -1,44 +1,13 @@
# File containing various utilities
-# Converts a CMake list to a string containing elements separated by spaces
-function(TO_LIST_SPACES _LIST_NAME OUTPUT_VAR)
- set(NEW_LIST_SPACE)
- foreach(ITEM ${${_LIST_NAME}})
- set(NEW_LIST_SPACE "${NEW_LIST_SPACE} ${ITEM}")
- endforeach()
- string(STRIP ${NEW_LIST_SPACE} NEW_LIST_SPACE)
- set(${OUTPUT_VAR} "${NEW_LIST_SPACE}" PARENT_SCOPE)
-endfunction()
-
-# Appends a lis of item to a string which is a space-separated list, if they don't already exist.
-function(LIST_SPACES_APPEND_ONCE LIST_NAME)
- string(REPLACE " " ";" _LIST ${${LIST_NAME}})
- list(APPEND _LIST ${ARGN})
- list(REMOVE_DUPLICATES _LIST)
- to_list_spaces(_LIST NEW_LIST_SPACE)
- set(${LIST_NAME} "${NEW_LIST_SPACE}" PARENT_SCOPE)
-endfunction()
-
-# Convinience function that does the same as LIST(FIND ...) but with a TRUE/FALSE return value.
-# Ex: IN_STR_LIST(MY_LIST "Searched item" WAS_FOUND)
-function(IN_STR_LIST LIST_NAME ITEM_SEARCHED RETVAL)
- list(FIND ${LIST_NAME} ${ITEM_SEARCHED} FIND_POS)
- if(${FIND_POS} EQUAL -1)
- set(${RETVAL} FALSE PARENT_SCOPE)
- else()
- set(${RETVAL} TRUE PARENT_SCOPE)
- endif()
-endfunction()
-
# Returns a list of arguments that evaluate to true
-function(collect_true output_var output_count_var)
- set(${output_var})
+function(count_true output_count_var)
+ set(lst)
foreach(option_var IN LISTS ARGN)
if(${option_var})
- list(APPEND ${output_var} ${option_var})
+ list(APPEND lst ${option_var})
endif()
endforeach()
- set(${output_var} ${${output_var}} PARENT_SCOPE)
- list(LENGTH ${output_var} ${output_count_var})
- set(${output_count_var} ${${output_count_var}} PARENT_SCOPE)
+ list(LENGTH lst lst_len)
+ set(${output_count_var} ${lst_len} PARENT_SCOPE)
endfunction()
diff --git a/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in b/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in
new file mode 100644
index 000000000..db8e5367d
--- /dev/null
+++ b/Utilities/cmcurl/CMake/cmake_uninstall.cmake.in
@@ -0,0 +1,26 @@
+if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+endif()
+
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+ set(CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
+endif()
+message(${CMAKE_INSTALL_PREFIX})
+
+file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+ message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
+ if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ exec_program(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ if(NOT "${rm_retval}" STREQUAL 0)
+ message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
+ endif()
+ else()
+ message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+ endif()
+endforeach()
diff --git a/Utilities/cmcurl/CMake/curl-config.cmake.in b/Utilities/cmcurl/CMake/curl-config.cmake.in
new file mode 100644
index 000000000..1294e173a
--- /dev/null
+++ b/Utilities/cmcurl/CMake/curl-config.cmake.in
@@ -0,0 +1,12 @@
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+if(@USE_OPENSSL@)
+ find_dependency(OpenSSL @OPENSSL_VERSION_MAJOR@)
+endif()
+if(@USE_ZLIB@)
+ find_dependency(ZLIB @ZLIB_VERSION_MAJOR@)
+endif()
+
+include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
+check_required_components("@PROJECT_NAME@")
diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt
index d85f366c0..bc8a7dc37 100644
--- a/Utilities/cmcurl/CMakeLists.txt
+++ b/Utilities/cmcurl/CMakeLists.txt
@@ -2,6 +2,7 @@
set(BUILD_CURL_EXE OFF CACHE INTERNAL "No curl exe")
set(BUILD_DASHBOARD_REPORTS OFF CACHE INTERNAL "No curl dashboard reports")
set(BUILD_RELEASE_DEBUG_DIRS OFF CACHE INTERNAL "No curl release/debug dirs")
+set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Build shared libraries")
set(CMAKE_USE_GSSAPI OFF CACHE INTERNAL "Disable curl gssapi")
set(CMAKE_USE_LIBSSH2 OFF CACHE INTERNAL "Disable curl libssh2")
set(CMAKE_USE_OPENLDAP OFF CACHE INTERNAL "No curl OpenLDAP")
@@ -23,16 +24,17 @@ set(CURL_DISABLE_TELNET ON CACHE INTERNAL "Disable curl telnet protocol?")
set(CURL_DISABLE_TFTP ON CACHE INTERNAL "Disable curl tftp protocol?")
set(CURL_DISABLE_VERBOSE_STRINGS OFF CACHE INTERNAL "Do not disable curl verbosity")
set(CURL_HIDDEN_SYMBOLS OFF CACHE INTERNAL "No curl hidden symbols")
-set(CURL_STATICLIB ON CACHE INTERNAL "Static curl")
+set(CURL_WERROR OFF CACHE INTERNAL "Turn compiler warnings into errors")
set(DISABLED_THREADSAFE OFF CACHE INTERNAL "Curl can use thread-safe functions")
set(ENABLE_ARES OFF CACHE INTERNAL "No curl c-ares support")
set(ENABLE_CURLDEBUG OFF CACHE INTERNAL "No curl TrackMemory features")
set(ENABLE_DEBUG OFF CACHE INTERNAL "No curl debug features")
-set(ENABLE_IPV6 OFF CACHE INTERNAL "No curl IPv6 support")
+set(ENABLE_IPV6 ON CACHE INTERNAL "Enable curl IPv6 support detection")
set(ENABLE_MANUAL OFF CACHE INTERNAL "No curl built-in manual")
set(ENABLE_THREADED_RESOLVER OFF CACHE INTERNAL "No curl POSIX threaded DNS lookup")
set(ENABLE_UNIX_SOCKETS OFF CACHE INTERNAL "No curl Unix domain sockets support")
set(HTTP_ONLY OFF CACHE INTERNAL "Curl is not http-only")
+set(PICKY_COMPILER OFF CACHE INTERNAL "Enable picky compiler options")
set(USE_WIN32_LDAP OFF CACHE INTERNAL "No curl Windows LDAP")
if(CMAKE_USE_OPENSSL)
elseif(WIN32)
@@ -51,10 +53,11 @@ elseif(APPLE)
endif()
if(NOT OSX_VERSION VERSION_LESS 10.6 AND
CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
- set(CMAKE_USE_DARWINSSL ON CACHE INTERNAL "enable Apple OS native SSL/TLS")
+ set(CMAKE_USE_SECTRANSP ON CACHE INTERNAL "enable Apple OS native SSL/TLS")
else()
- set(CMAKE_USE_DARWINSSL OFF CACHE INTERNAL "enable Apple OS native SSL/TLS")
+ set(CMAKE_USE_SECTRANSP OFF CACHE INTERNAL "enable Apple OS native SSL/TLS")
endif()
+ unset(CMAKE_USE_DARWINSSL CACHE)
endif()
set(CMAKE_USE_MBEDTLS OFF CACHE INTERNAL "Enable mbedTLS for SSL/TLS")
@@ -75,7 +78,7 @@ endif(APPLE)
# Disable warnings to avoid changing 3rd party code.
if(CMAKE_C_COMPILER_ID MATCHES
- "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
+ "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel)$")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
@@ -88,7 +91,7 @@ endif()
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@@ -121,27 +124,26 @@ endif()
# To check:
# (From Daniel Stenberg) The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not.
# (From Daniel Stenberg) The gcc command line use neither -g nor any -O options. As a developer, I also treasure our configure scripts's --enable-debug option that sets a long range of "picky" compiler options.
-cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
include(Utilities)
include(Macros)
include(CMakeDependentOption)
+include(CheckCCompilerFlag)
-project( CURL C )
+project(CURL C)
if(0) # This code not needed for building within CMake.
message(WARNING "the curl cmake build system is poorly maintained. Be aware")
endif()
-file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS)
-string (REGEX MATCH "#define LIBCURL_VERSION \"[^\"]*"
+file(READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS)
+string(REGEX MATCH "#define LIBCURL_VERSION \"[^\"]*"
CURL_VERSION ${CURL_VERSION_H_CONTENTS})
-string (REGEX REPLACE "[^\"]+\"" "" CURL_VERSION ${CURL_VERSION})
-string (REGEX MATCH "#define LIBCURL_VERSION_NUM 0x[0-9a-fA-F]+"
+string(REGEX REPLACE "[^\"]+\"" "" CURL_VERSION ${CURL_VERSION})
+string(REGEX MATCH "#define LIBCURL_VERSION_NUM 0x[0-9a-fA-F]+"
CURL_VERSION_NUM ${CURL_VERSION_H_CONTENTS})
-string (REGEX REPLACE "[^0]+0x" "" CURL_VERSION_NUM ${CURL_VERSION_NUM})
+string(REGEX REPLACE "[^0]+0x" "" CURL_VERSION_NUM ${CURL_VERSION_NUM})
-include_regular_expression("^.*$") # Sukender: Is it necessary?
# Setup package meta-data
# SET(PACKAGE "curl")
@@ -156,56 +158,67 @@ endif()
set(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}")
set(OS "\"${CMAKE_SYSTEM_NAME}\"")
-include_directories(${PROJECT_BINARY_DIR}/include/curl)
-include_directories( ${CURL_SOURCE_DIR}/include )
+include_directories(${CURL_SOURCE_DIR}/include)
+option(CURL_WERROR "Turn compiler warnings into errors" OFF)
+option(PICKY_COMPILER "Enable picky compiler options" ON)
option(BUILD_CURL_EXE "Set to ON to build curl executable." ON)
-option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF)
+option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(ENABLE_ARES "Set to ON to enable c-ares support" OFF)
if(WIN32)
- CMAKE_DEPENDENT_OPTION(ENABLE_THREADED_RESOLVER
- "Set to ON to enable threaded DNS lookup"
- ON "NOT ENABLE_ARES"
- OFF)
-else()
- option(ENABLE_THREADED_RESOLVER "Set to ON to enable POSIX threaded DNS lookup" OFF)
+ option(CURL_STATIC_CRT "Set to ON to build libcurl with static CRT on Windows (/MT)." OFF)
+ option(ENABLE_INET_PTON "Set to OFF to prevent usage of inet_pton when building against modern SDKs while still requiring compatibility with older Windows versions, such as Windows XP, Windows Server 2003 etc." ON)
endif()
+
+if(0) # This code not needed for building within CMake.
+cmake_dependent_option(ENABLE_THREADED_RESOLVER "Set to ON to enable threaded DNS lookup"
+ ON "NOT ENABLE_ARES"
+ OFF)
+endif()
+
option(ENABLE_DEBUG "Set to ON to enable curl debug features" OFF)
option(ENABLE_CURLDEBUG "Set to ON to build with TrackMemory feature enabled" OFF)
-if (ENABLE_DEBUG)
- # DEBUGBUILD will be defined only for Debug builds
- if(NOT CMAKE_VERSION VERSION_LESS 3.0)
- set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUGBUILD>)
- else()
- set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUGBUILD)
+if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
+ if(PICKY_COMPILER)
+ foreach(_CCOPT -pedantic -Wall -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wundef -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wno-sign-conversion -Wvla -Wdouble-promotion -Wno-system-headers -Wno-pedantic-ms-format)
+ # surprisingly, CHECK_C_COMPILER_FLAG needs a new variable to store each new
+ # test result in.
+ check_c_compiler_flag(${_CCOPT} OPT${_CCOPT})
+ if(OPT${_CCOPT})
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT}")
+ endif()
+ endforeach()
endif()
+endif()
+
+if(ENABLE_DEBUG)
+ # DEBUGBUILD will be defined only for Debug builds
+ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUGBUILD>)
set(ENABLE_CURLDEBUG ON)
endif()
-if (ENABLE_CURLDEBUG)
+if(ENABLE_CURLDEBUG)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS CURLDEBUG)
endif()
+if(0) # This code not needed for building within CMake.
+# For debug libs and exes, add "-d" postfix
+if(NOT DEFINED CMAKE_DEBUG_POSTFIX)
+ set(CMAKE_DEBUG_POSTFIX "-d")
+endif()
+endif()
+
# initialize CURL_LIBS
set(CURL_LIBS "")
-if(ENABLE_THREADED_RESOLVER AND ENABLE_ARES)
- message(FATAL_ERROR "Options ENABLE_THREADED_RESOLVER and ENABLE_ARES are mutually exclusive")
-endif()
-
if(ENABLE_ARES)
set(USE_ARES 1)
find_package(CARES REQUIRED)
- list(APPEND CURL_LIBS ${CARES_LIBRARY} )
+ list(APPEND CURL_LIBS ${CARES_LIBRARY})
set(CURL_LIBS ${CURL_LIBS} ${CARES_LIBRARY})
endif()
-if(MSVC)
- option(BUILD_RELEASE_DEBUG_DIRS "Set OFF to build each configuration to a separate directory" OFF)
- mark_as_advanced(BUILD_RELEASE_DEBUG_DIRS)
-endif()
-
if(0) # This code not needed for building within CMake.
include(CurlSymbolHiding)
endif()
@@ -265,8 +278,6 @@ option(CURL_DISABLE_CRYPTO_AUTH "to disable cryptographic authentication" OFF)
mark_as_advanced(CURL_DISABLE_CRYPTO_AUTH)
option(CURL_DISABLE_VERBOSE_STRINGS "to disable verbose strings" OFF)
mark_as_advanced(CURL_DISABLE_VERBOSE_STRINGS)
-option(DISABLED_THREADSAFE "Set to explicitly specify we don't want to use thread-safe functions" OFF)
-mark_as_advanced(DISABLED_THREADSAFE)
option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON)
mark_as_advanced(ENABLE_IPV6)
if(ENABLE_IPV6 AND NOT WIN32)
@@ -283,85 +294,67 @@ if(ENABLE_IPV6 AND NOT WIN32)
endif()
endif()
-option(ENABLE_MANUAL "to provide the built-in manual" ON)
-unset(USE_MANUAL CACHE) # TODO: cache NROFF/NROFF_MANOPT/USE_MANUAL vars?
-if(ENABLE_MANUAL)
- find_program(NROFF NAMES gnroff nroff)
- if(NROFF)
- # Need a way to write to stdin, this will do
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt" "test")
- # Tests for a valid nroff option to generate a manpage
- foreach(_MANOPT "-man" "-mandoc")
- execute_process(COMMAND "${NROFF}" ${_MANOPT}
- OUTPUT_VARIABLE NROFF_MANOPT_OUTPUT
- INPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt"
- ERROR_QUIET)
- # Save the option if it was valid
- if(NROFF_MANOPT_OUTPUT)
- message("Found *nroff option: -- ${_MANOPT}")
- set(NROFF_MANOPT ${_MANOPT})
- set(USE_MANUAL 1)
- break()
- endif()
- endforeach()
- # No need for the temporary file
- file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt")
- if(NOT USE_MANUAL)
- message(WARNING "Found no *nroff option to get plaintext from man pages")
- endif()
- else()
- message(WARNING "Found no *nroff program")
- endif()
-endif()
-
if(0) # This code not needed for building within CMake.
# Required for building manual, docs, tests
-find_package(Perl REQUIRED)
+curl_nroff_check()
+find_package(Perl)
+
+cmake_dependent_option(ENABLE_MANUAL "to provide the built-in manual"
+ ON "NROFF_USEFUL;PERL_FOUND"
+ OFF)
+
+if(NOT PERL_FOUND)
+ message(STATUS "Perl not found, testing disabled.")
+ set(BUILD_TESTING OFF)
+endif()
+if(ENABLE_MANUAL)
+ set(USE_MANUAL ON)
+endif()
endif()
# We need ansi c-flags, especially on HP
set(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
set(CMAKE_REQUIRED_FLAGS ${CMAKE_ANSI_CFLAGS})
+if(CURL_STATIC_CRT)
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
+endif()
+
# Disable warnings on Borland to avoid changing 3rd party code.
if(BORLAND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")
-endif(BORLAND)
+endif()
# If we are on AIX, do the _ALL_SOURCE magic
if(${CMAKE_SYSTEM_NAME} MATCHES AIX)
set(_ALL_SOURCE 1)
-endif(${CMAKE_SYSTEM_NAME} MATCHES AIX)
+endif()
# Include all the necessary files for macros
-include (CheckFunctionExists)
-include (CheckIncludeFile)
-include (CheckIncludeFiles)
-include (CheckLibraryExists)
-include (CheckSymbolExists)
-include (CheckTypeSize)
-include (CheckCSourceCompiles)
+include(CheckFunctionExists)
+include(CheckIncludeFile)
+include(CheckIncludeFiles)
+include(CheckLibraryExists)
+include(CheckSymbolExists)
+include(CheckTypeSize)
+include(CheckCSourceCompiles)
# On windows preload settings
if(WIN32)
set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} -D_WINSOCKAPI_=")
include(${CMAKE_CURRENT_SOURCE_DIR}/CMake/Platforms/WindowsCache.cmake)
-endif(WIN32)
+endif()
if(ENABLE_THREADED_RESOLVER)
+ find_package(Threads REQUIRED)
if(WIN32)
set(USE_THREADS_WIN32 ON)
else()
- check_include_file_concat("pthread.h" HAVE_PTHREAD_H)
- if(HAVE_PTHREAD_H)
- set(CMAKE_THREAD_PREFER_PTHREAD 1)
- find_package(Threads)
- if(CMAKE_USE_PTHREADS_INIT)
- set(CURL_LIBS ${CURL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
- set(USE_THREADS_POSIX 1)
- endif()
- endif()
+ set(USE_THREADS_POSIX ${CMAKE_USE_PTHREADS_INIT})
+ set(HAVE_PTHREAD_H ${CMAKE_USE_PTHREADS_INIT})
endif()
+ set(CURL_LIBS ${CURL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
endif()
# Check for all needed libraries
@@ -380,26 +373,27 @@ if(BEOS)
set(NOT_NEED_LIBNSL 1)
check_library_exists_concat("bind" gethostbyname HAVE_LIBBIND)
check_library_exists_concat("bnetapi" closesocket HAVE_LIBBNETAPI)
-endif(BEOS)
+endif()
check_library_exists_concat("network" recv HAVE_LIBNETWORK)
if(NOT NOT_NEED_LIBNSL)
check_library_exists_concat("nsl" gethostbyname HAVE_LIBNSL)
-endif(NOT NOT_NEED_LIBNSL)
+endif()
check_function_exists(gethostname HAVE_GETHOSTNAME)
if(WIN32)
check_library_exists_concat("ws2_32" getch HAVE_LIBWS2_32)
check_library_exists_concat("winmm" getch HAVE_LIBWINMM)
+ list(APPEND CURL_LIBS "advapi32")
endif()
# check SSL libraries
-# TODO support GNUTLS, NSS, POLARSSL, AXTLS, CYASSL
+# TODO support GNUTLS, NSS, POLARSSL, CYASSL
if(APPLE)
- option(CMAKE_USE_DARWINSSL "enable Apple OS native SSL/TLS" OFF)
+ option(CMAKE_USE_SECTRANSP "enable Apple OS native SSL/TLS" OFF)
endif()
if(WIN32)
option(CMAKE_USE_WINSSL "enable Windows native SSL/TLS" OFF)
@@ -409,18 +403,18 @@ endif()
option(CMAKE_USE_MBEDTLS "Enable mbedTLS for SSL/TLS" OFF)
set(openssl_default ON)
-if(WIN32 OR CMAKE_USE_DARWINSSL OR CMAKE_USE_WINSSL OR CMAKE_USE_MBEDTLS)
+if(WIN32 OR CMAKE_USE_SECTRANSP OR CMAKE_USE_WINSSL OR CMAKE_USE_MBEDTLS)
set(openssl_default OFF)
endif()
-collect_true(enabled_ssl_options enabled_ssl_options_count
+count_true(enabled_ssl_options_count
CMAKE_USE_WINSSL
- CMAKE_USE_DARWINSSL
+ CMAKE_USE_SECTRANSP
CMAKE_USE_OPENSSL
CMAKE_USE_MBEDTLS
)
-if(enabled_ssl_options_count GREATER 1)
- message(FATAL_ERROR "Multiple SSL options specified: ${enabled_ssl_options}. Please pick at most one and disable the rest.")
+if(enabled_ssl_options_count GREATER "1")
+ set(CURL_WITH_MULTI_SSL ON)
endif()
if(CMAKE_USE_WINSSL)
@@ -435,6 +429,10 @@ if(CURL_WINDOWS_SSPI)
endif()
if(CMAKE_USE_DARWINSSL)
+ message(FATAL_ERROR "The cmake option CMAKE_USE_DARWINSSL was renamed to CMAKE_USE_SECTRANSP.")
+endif()
+
+if(CMAKE_USE_SECTRANSP)
find_library(COREFOUNDATION_FRAMEWORK "CoreFoundation")
if(NOT COREFOUNDATION_FRAMEWORK)
message(FATAL_ERROR "CoreFoundation framework not found")
@@ -446,24 +444,28 @@ if(CMAKE_USE_DARWINSSL)
endif()
set(SSL_ENABLED ON)
- set(USE_DARWINSSL ON)
+ set(USE_SECTRANSP ON)
list(APPEND CURL_LIBS "${COREFOUNDATION_FRAMEWORK}" "${SECURITY_FRAMEWORK}")
endif()
if(CMAKE_USE_OPENSSL)
- find_package(OpenSSL REQUIRED)
+ find_package(OpenSSL)
+ if(NOT OpenSSL_FOUND)
+ message(FATAL_ERROR
+ "Could not find OpenSSL. Install an OpenSSL development package or "
+ "configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.")
+ endif()
set(SSL_ENABLED ON)
set(USE_OPENSSL ON)
set(HAVE_LIBCRYPTO ON)
set(HAVE_LIBSSL ON)
list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})
include_directories(${OPENSSL_INCLUDE_DIR})
+
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
check_include_file("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H)
- check_include_file("openssl/engine.h" HAVE_OPENSSL_ENGINE_H)
check_include_file("openssl/err.h" HAVE_OPENSSL_ERR_H)
check_include_file("openssl/pem.h" HAVE_OPENSSL_PEM_H)
- check_include_file("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H)
check_include_file("openssl/rsa.h" HAVE_OPENSSL_RSA_H)
check_include_file("openssl/ssl.h" HAVE_OPENSSL_SSL_H)
check_include_file("openssl/x509.h" HAVE_OPENSSL_X509_H)
@@ -582,6 +584,7 @@ if(NOT CURL_DISABLE_LDAP)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CMAKE_LBER_LIB})
endif()
check_c_source_compiles("${_SRC_STRING}" NOT_NEED_LBER_H)
+ unset(CMAKE_REQUIRED_LIBRARIES)
if(NOT_NEED_LBER_H)
set(NEED_LBER_H OFF)
@@ -590,7 +593,6 @@ if(NOT CURL_DISABLE_LDAP)
endif()
endif()
endif()
-
endif()
# No ldap, no ldaps.
@@ -616,15 +618,23 @@ if(0) # This code not needed for building within CMake.
option(CURL_ZLIB "Set to ON to enable building curl with zlib support." ON)
set(HAVE_LIBZ OFF)
set(HAVE_ZLIB_H OFF)
-set(HAVE_ZLIB OFF)
+set(USE_ZLIB OFF)
if(CURL_ZLIB)
find_package(ZLIB QUIET)
if(ZLIB_FOUND)
set(HAVE_ZLIB_H ON)
- set(HAVE_ZLIB ON)
set(HAVE_LIBZ ON)
- list(APPEND CURL_LIBS ${ZLIB_LIBRARIES})
- include_directories(${ZLIB_INCLUDE_DIRS})
+ set(USE_ZLIB ON)
+
+ # Depend on ZLIB via imported targets if supported by the running
+ # version of CMake. This allows our dependents to get our dependencies
+ # transitively.
+ if(NOT CMAKE_VERSION VERSION_LESS 3.4)
+ list(APPEND CURL_LIBS ZLIB::ZLIB)
+ else()
+ list(APPEND CURL_LIBS ${ZLIB_LIBRARIES})
+ include_directories(${ZLIB_INCLUDE_DIRS})
+ endif()
list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
endif()
endif()
@@ -640,6 +650,18 @@ if(CURL_SPECIAL_LIBZ)
set(HAVE_ZLIB_H 0)
endif()
+option(CURL_BROTLI "Set to ON to enable building curl with brotli support." OFF)
+set(HAVE_BROTLI OFF)
+if(CURL_BROTLI)
+ find_package(BROTLI QUIET)
+ if(BROTLI_FOUND)
+ set(HAVE_BROTLI ON)
+ list(APPEND CURL_LIBS ${BROTLI_LIBRARIES})
+ include_directories(${BROTLI_INCLUDE_DIRS})
+ list(APPEND CMAKE_REQUIRED_INCLUDES ${BROTLI_INCLUDE_DIRS})
+ endif()
+endif()
+
#libSSH2
option(CMAKE_USE_LIBSSH2 "Use libSSH2" ON)
mark_as_advanced(CMAKE_USE_LIBSSH2)
@@ -670,9 +692,9 @@ if(CMAKE_USE_LIBSSH2)
check_function_exists(libssh2_scp_send64 HAVE_LIBSSH2_SCP_SEND64)
check_function_exists(libssh2_session_handshake HAVE_LIBSSH2_SESSION_HANDSHAKE)
set(CMAKE_EXTRA_INCLUDE_FILES "")
-
- endif(LIBSSH2_FOUND)
-endif(CMAKE_USE_LIBSSH2)
+ unset(CMAKE_REQUIRED_LIBRARIES)
+ endif()
+endif()
option(CMAKE_USE_GSSAPI "Use GSSAPI implementation (right now only Heimdal is supported with CMake build)" OFF)
mark_as_advanced(CMAKE_USE_GSSAPI)
@@ -685,7 +707,7 @@ if(CMAKE_USE_GSSAPI)
message(STATUS "Found ${GSS_FLAVOUR} GSSAPI version: \"${GSS_VERSION}\"")
- list(APPEND CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIRECTORIES})
+ list(APPEND CMAKE_REQUIRED_INCLUDES ${GSS_INCLUDE_DIR})
check_include_file_concat("gssapi/gssapi.h" HAVE_GSSAPI_GSSAPI_H)
check_include_file_concat("gssapi/gssapi_generic.h" HAVE_GSSAPI_GSSAPI_GENERIC_H)
check_include_file_concat("gssapi/gssapi_krb5.h" HAVE_GSSAPI_GSSAPI_KRB5_H)
@@ -718,10 +740,11 @@ if(CMAKE_USE_GSSAPI)
if(NOT HAVE_GSS_C_NT_HOSTBASED_SERVICE)
set(HAVE_OLD_GSSMIT ON)
endif()
+ unset(CMAKE_REQUIRED_LIBRARIES)
endif()
- include_directories(${GSS_INCLUDE_DIRECTORIES})
+ include_directories(${GSS_INCLUDE_DIR})
link_directories(${GSS_LINK_DIRECTORIES})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GSS_COMPILER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GSS_LINKER_FLAGS}")
@@ -754,68 +777,67 @@ set(CURL_CA_PATH "auto" CACHE STRING
"Location of default CA path. Set 'none' to disable or 'auto' for auto-detection. Defaults to 'auto'.")
if("${CURL_CA_BUNDLE}" STREQUAL "")
- message(FATAL_ERROR "Invalid value of CURL_CA_BUNDLE. Use 'none', 'auto' or file path.")
+ message(FATAL_ERROR "Invalid value of CURL_CA_BUNDLE. Use 'none', 'auto' or file path.")
elseif("${CURL_CA_BUNDLE}" STREQUAL "none")
- unset(CURL_CA_BUNDLE CACHE)
+ unset(CURL_CA_BUNDLE CACHE)
elseif("${CURL_CA_BUNDLE}" STREQUAL "auto")
- unset(CURL_CA_BUNDLE CACHE)
- set(CURL_CA_BUNDLE_AUTODETECT TRUE)
+ unset(CURL_CA_BUNDLE CACHE)
+ set(CURL_CA_BUNDLE_AUTODETECT TRUE)
else()
- set(CURL_CA_BUNDLE_SET TRUE)
+ set(CURL_CA_BUNDLE_SET TRUE)
endif()
if("${CURL_CA_PATH}" STREQUAL "")
- message(FATAL_ERROR "Invalid value of CURL_CA_PATH. Use 'none', 'auto' or directory path.")
+ message(FATAL_ERROR "Invalid value of CURL_CA_PATH. Use 'none', 'auto' or directory path.")
elseif("${CURL_CA_PATH}" STREQUAL "none")
- unset(CURL_CA_PATH CACHE)
+ unset(CURL_CA_PATH CACHE)
elseif("${CURL_CA_PATH}" STREQUAL "auto")
- unset(CURL_CA_PATH CACHE)
- set(CURL_CA_PATH_AUTODETECT TRUE)
+ unset(CURL_CA_PATH CACHE)
+ set(CURL_CA_PATH_AUTODETECT TRUE)
else()
- set(CURL_CA_PATH_SET TRUE)
+ set(CURL_CA_PATH_SET TRUE)
endif()
if(CURL_CA_BUNDLE_SET AND CURL_CA_PATH_AUTODETECT)
- # Skip autodetection of unset CA path because CA bundle is set explicitly
+ # Skip autodetection of unset CA path because CA bundle is set explicitly
elseif(CURL_CA_PATH_SET AND CURL_CA_BUNDLE_AUTODETECT)
- # Skip autodetection of unset CA bundle because CA path is set explicitly
+ # Skip autodetection of unset CA bundle because CA path is set explicitly
elseif(CURL_CA_PATH_AUTODETECT OR CURL_CA_BUNDLE_AUTODETECT)
- # first try autodetecting a CA bundle, then a CA path
-
- if(CURL_CA_BUNDLE_AUTODETECT)
- set(SEARCH_CA_BUNDLE_PATHS
- /etc/ssl/certs/ca-certificates.crt
- /etc/pki/tls/certs/ca-bundle.crt
- /usr/share/ssl/certs/ca-bundle.crt
- /usr/local/share/certs/ca-root-nss.crt
- /etc/ssl/cert.pem)
-
- foreach(SEARCH_CA_BUNDLE_PATH ${SEARCH_CA_BUNDLE_PATHS})
- if(EXISTS "${SEARCH_CA_BUNDLE_PATH}")
- message(STATUS "Found CA bundle: ${SEARCH_CA_BUNDLE_PATH}")
- set(CURL_CA_BUNDLE "${SEARCH_CA_BUNDLE_PATH}")
- set(CURL_CA_BUNDLE_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
- break()
- endif()
- endforeach()
- endif()
+ # first try autodetecting a CA bundle, then a CA path
+
+ if(CURL_CA_BUNDLE_AUTODETECT)
+ set(SEARCH_CA_BUNDLE_PATHS
+ /etc/ssl/certs/ca-certificates.crt
+ /etc/pki/tls/certs/ca-bundle.crt
+ /usr/share/ssl/certs/ca-bundle.crt
+ /usr/local/share/certs/ca-root-nss.crt
+ /etc/ssl/cert.pem)
+
+ foreach(SEARCH_CA_BUNDLE_PATH ${SEARCH_CA_BUNDLE_PATHS})
+ if(EXISTS "${SEARCH_CA_BUNDLE_PATH}")
+ message(STATUS "Found CA bundle: ${SEARCH_CA_BUNDLE_PATH}")
+ set(CURL_CA_BUNDLE "${SEARCH_CA_BUNDLE_PATH}")
+ set(CURL_CA_BUNDLE_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
+ break()
+ endif()
+ endforeach()
+ endif()
- if(CURL_CA_PATH_AUTODETECT AND (NOT CURL_CA_PATH_SET))
- if(EXISTS "/etc/ssl/certs")
- set(CURL_CA_PATH "/etc/ssl/certs")
- set(CURL_CA_PATH_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
- endif()
+ if(CURL_CA_PATH_AUTODETECT AND (NOT CURL_CA_PATH_SET))
+ if(EXISTS "/etc/ssl/certs")
+ set(CURL_CA_PATH "/etc/ssl/certs")
+ set(CURL_CA_PATH_SET TRUE CACHE BOOL "Path to the CA bundle has been set")
endif()
+ endif()
endif()
if(CURL_CA_PATH_SET AND NOT USE_OPENSSL AND NOT USE_MBEDTLS)
- message(FATAL_ERROR
- "CA path only supported by OpenSSL, GnuTLS or mbed TLS. "
- "Set CURL_CA_PATH=none or enable one of those TLS backends.")
+ message(FATAL_ERROR
+ "CA path only supported by OpenSSL, GnuTLS or mbed TLS. "
+ "Set CURL_CA_PATH=none or enable one of those TLS backends.")
endif()
endif()
-
# Check for header files
if(NOT UNIX)
check_include_file_concat("windows.h" HAVE_WINDOWS_H)
@@ -863,7 +885,6 @@ check_include_file_concat("ifaddrs.h" HAVE_IFADDRS_H)
check_include_file_concat("io.h" HAVE_IO_H)
check_include_file_concat("krb.h" HAVE_KRB_H)
check_include_file_concat("libgen.h" HAVE_LIBGEN_H)
-check_include_file_concat("limits.h" HAVE_LIMITS_H)
check_include_file_concat("locale.h" HAVE_LOCALE_H)
check_include_file_concat("net/if.h" HAVE_NET_IF_H)
check_include_file_concat("netdb.h" HAVE_NETDB_H)
@@ -911,15 +932,10 @@ check_type_size("int" SIZEOF_INT)
check_type_size("__int64" SIZEOF___INT64)
check_type_size("time_t" SIZEOF_TIME_T)
-# Make public versions of some type sizes for curlbuild.h.
-foreach(t INT LONG LONG_LONG SSIZE_T)
- string(REPLACE "SIZEOF_" "CURL_SIZEOF_" CURL_SIZEOF_${t}_CODE "${SIZEOF_${t}_CODE}")
-endforeach()
-
if(HAVE_SIZEOF_LONG_LONG)
set(HAVE_LONGLONG 1)
set(HAVE_LL 1)
-endif(HAVE_SIZEOF_LONG_LONG)
+endif()
find_file(RANDOM_FILE urandom /dev)
mark_as_advanced(RANDOM_FILE)
@@ -935,12 +951,8 @@ endif()
check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME)
check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET)
-# poll on macOS is unreliable, it first did not exist, then was broken until
-# fixed in 10.9 only to break again in 10.12.
-if(NOT APPLE)
- check_symbol_exists(poll "${CURL_INCLUDES}" HAVE_POLL)
-endif()
check_symbol_exists(select "${CURL_INCLUDES}" HAVE_SELECT)
+check_symbol_exists(poll "${CURL_INCLUDES}" HAVE_POLL)
check_symbol_exists(strdup "${CURL_INCLUDES}" HAVE_STRDUP)
check_symbol_exists(strstr "${CURL_INCLUDES}" HAVE_STRSTR)
check_symbol_exists(strtok_r "${CURL_INCLUDES}" HAVE_STRTOK_R)
@@ -953,7 +965,7 @@ check_symbol_exists(strncmpi "${CURL_INCLUDES}" HAVE_STRNCMPI)
check_symbol_exists(alarm "${CURL_INCLUDES}" HAVE_ALARM)
if(NOT HAVE_STRNCMPI)
set(HAVE_STRCMPI)
-endif(NOT HAVE_STRNCMPI)
+endif()
check_symbol_exists(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR)
check_symbol_exists(gethostbyaddr_r "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR_R)
check_symbol_exists(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY)
@@ -969,6 +981,7 @@ check_symbol_exists(sigsetjmp "${CURL_INCLUDES}" HAVE_SIGSETJMP)
check_symbol_exists(getpass_r "${CURL_INCLUDES}" HAVE_GETPASS_R)
check_symbol_exists(strlcat "${CURL_INCLUDES}" HAVE_STRLCAT)
check_symbol_exists(getpwuid "${CURL_INCLUDES}" HAVE_GETPWUID)
+check_symbol_exists(getpwuid_r "${CURL_INCLUDES}" HAVE_GETPWUID_R)
check_symbol_exists(geteuid "${CURL_INCLUDES}" HAVE_GETEUID)
check_symbol_exists(utime "${CURL_INCLUDES}" HAVE_UTIME)
check_symbol_exists(gmtime_r "${CURL_INCLUDES}" HAVE_GMTIME_R)
@@ -981,7 +994,7 @@ check_symbol_exists(signal "${CURL_INCLUDES}" HAVE_SIGNAL_FUNC)
check_symbol_exists(SIGALRM "${CURL_INCLUDES}" HAVE_SIGNAL_MACRO)
if(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
set(HAVE_SIGNAL 1)
-endif(HAVE_SIGNAL_FUNC AND HAVE_SIGNAL_MACRO)
+endif()
check_symbol_exists(uname "${CURL_INCLUDES}" HAVE_UNAME)
check_symbol_exists(strtoll "${CURL_INCLUDES}" HAVE_STRTOLL)
check_symbol_exists(_strtoi64 "${CURL_INCLUDES}" HAVE__STRTOI64)
@@ -995,42 +1008,57 @@ check_symbol_exists(freeifaddrs "${CURL_INCLUDES}" HAVE_FREEIFADDRS)
check_symbol_exists(pipe "${CURL_INCLUDES}" HAVE_PIPE)
check_symbol_exists(ftruncate "${CURL_INCLUDES}" HAVE_FTRUNCATE)
check_symbol_exists(getprotobyname "${CURL_INCLUDES}" HAVE_GETPROTOBYNAME)
+check_symbol_exists(getpeername "${CURL_INCLUDES}" HAVE_GETPEERNAME)
+check_symbol_exists(getsockname "${CURL_INCLUDES}" HAVE_GETSOCKNAME)
check_symbol_exists(getrlimit "${CURL_INCLUDES}" HAVE_GETRLIMIT)
check_symbol_exists(setlocale "${CURL_INCLUDES}" HAVE_SETLOCALE)
+check_symbol_exists(setmode "${CURL_INCLUDES}" HAVE_SETMODE)
check_symbol_exists(setrlimit "${CURL_INCLUDES}" HAVE_SETRLIMIT)
check_symbol_exists(fcntl "${CURL_INCLUDES}" HAVE_FCNTL)
check_symbol_exists(ioctl "${CURL_INCLUDES}" HAVE_IOCTL)
check_symbol_exists(setsockopt "${CURL_INCLUDES}" HAVE_SETSOCKOPT)
+check_function_exists(mach_absolute_time HAVE_MACH_ABSOLUTE_TIME)
# symbol exists in win32, but function does not.
-check_function_exists(inet_pton HAVE_INET_PTON)
+if(WIN32)
+ if(ENABLE_INET_PTON)
+ check_function_exists(inet_pton HAVE_INET_PTON)
+ # _WIN32_WINNT_VISTA (0x0600)
+ add_definitions(-D_WIN32_WINNT=0x0600)
+ else()
+ # _WIN32_WINNT_WINXP (0x0501)
+ add_definitions(-D_WIN32_WINNT=0x0501)
+ endif()
+else()
+ check_function_exists(inet_pton HAVE_INET_PTON)
+endif()
check_symbol_exists(fsetxattr "${CURL_INCLUDES}" HAVE_FSETXATTR)
if(HAVE_FSETXATTR)
foreach(CURL_TEST HAVE_FSETXATTR_5 HAVE_FSETXATTR_6)
- curl_internal_test_run(${CURL_TEST})
- endforeach(CURL_TEST)
-endif(HAVE_FSETXATTR)
+ curl_internal_test(${CURL_TEST})
+ endforeach()
+endif()
# sigaction and sigsetjmp are special. Use special mechanism for
# detecting those, but only if previous attempt failed.
if(HAVE_SIGNAL_H)
check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
-endif(HAVE_SIGNAL_H)
+endif()
if(NOT HAVE_SIGSETJMP)
if(HAVE_SETJMP_H)
check_symbol_exists(sigsetjmp "setjmp.h" HAVE_MACRO_SIGSETJMP)
if(HAVE_MACRO_SIGSETJMP)
set(HAVE_SIGSETJMP 1)
- endif(HAVE_MACRO_SIGSETJMP)
- endif(HAVE_SETJMP_H)
-endif(NOT HAVE_SIGSETJMP)
+ endif()
+ endif()
+endif()
# If there is no stricmp(), do not allow LDAP to parse URLs
if(NOT HAVE_STRICMP)
set(HAVE_LDAP_URL_PARSE 1)
-endif(NOT HAVE_STRICMP)
+endif()
# Do curl specific tests
foreach(CURL_TEST
@@ -1057,7 +1085,6 @@ foreach(CURL_TEST
HAVE_GETHOSTBYNAME_R_3_REENTRANT
HAVE_GETHOSTBYNAME_R_5_REENTRANT
HAVE_GETHOSTBYNAME_R_6_REENTRANT
- HAVE_SOCKLEN_T
HAVE_IN_ADDR_T
HAVE_BOOL_T
STDC_HEADERS
@@ -1066,23 +1093,32 @@ foreach(CURL_TEST
HAVE_INET_NTOA_R_DECL_REENTRANT
HAVE_GETADDRINFO
HAVE_FILE_OFFSET_BITS
+ HAVE_VARIADIC_MACROS_C99
+ HAVE_VARIADIC_MACROS_GCC
)
curl_internal_test(${CURL_TEST})
-endforeach(CURL_TEST)
+endforeach()
if(HAVE_FILE_OFFSET_BITS)
set(_FILE_OFFSET_BITS 64)
set(CMAKE_REQUIRED_FLAGS "-D_FILE_OFFSET_BITS=64")
-endif(HAVE_FILE_OFFSET_BITS)
+endif()
check_type_size("off_t" SIZEOF_OFF_T)
+
+# include this header to get the type
+set(CMAKE_REQUIRED_INCLUDES "${CURL_SOURCE_DIR}/include")
+set(CMAKE_EXTRA_INCLUDE_FILES "curl/system.h")
+check_type_size("curl_off_t" SIZEOF_CURL_OFF_T)
+set(CMAKE_EXTRA_INCLUDE_FILES "")
+
set(CMAKE_REQUIRED_FLAGS)
foreach(CURL_TEST
HAVE_GLIBC_STRERROR_R
HAVE_POSIX_STRERROR_R
)
- curl_internal_test_run(${CURL_TEST})
-endforeach(CURL_TEST)
+ curl_internal_test(${CURL_TEST})
+endforeach()
# Check for reentrant
foreach(CURL_TEST
@@ -1096,9 +1132,9 @@ foreach(CURL_TEST
if(NOT ${CURL_TEST})
if(${CURL_TEST}_REENTRANT)
set(NEED_REENTRANT 1)
- endif(${CURL_TEST}_REENTRANT)
- endif(NOT ${CURL_TEST})
-endforeach(CURL_TEST)
+ endif()
+ endif()
+endforeach()
if(NEED_REENTRANT)
foreach(CURL_TEST
@@ -1111,32 +1147,38 @@ if(NEED_REENTRANT)
set(${CURL_TEST} 0)
if(${CURL_TEST}_REENTRANT)
set(${CURL_TEST} 1)
- endif(${CURL_TEST}_REENTRANT)
- endforeach(CURL_TEST)
-endif(NEED_REENTRANT)
+ endif()
+ endforeach()
+endif()
if(HAVE_INET_NTOA_R_DECL_REENTRANT)
set(HAVE_INET_NTOA_R_DECL 1)
set(NEED_REENTRANT 1)
-endif(HAVE_INET_NTOA_R_DECL_REENTRANT)
+endif()
+
+# Check clock_gettime(CLOCK_MONOTONIC, x) support
+curl_internal_test(HAVE_CLOCK_GETTIME_MONOTONIC)
+
+# Check compiler support of __builtin_available()
+curl_internal_test(HAVE_BUILTIN_AVAILABLE)
# Some other minor tests
if(NOT HAVE_IN_ADDR_T)
set(in_addr_t "unsigned long")
-endif(NOT HAVE_IN_ADDR_T)
+endif()
# Fix libz / zlib.h
if(NOT CURL_SPECIAL_LIBZ)
if(NOT HAVE_LIBZ)
set(HAVE_ZLIB_H 0)
- endif(NOT HAVE_LIBZ)
+ endif()
if(NOT HAVE_ZLIB_H)
set(HAVE_LIBZ 0)
- endif(NOT HAVE_ZLIB_H)
-endif(NOT CURL_SPECIAL_LIBZ)
+ endif()
+endif()
# Check for nonblocking
set(HAVE_DISABLED_NONBLOCKING 1)
@@ -1145,16 +1187,13 @@ if(HAVE_FIONBIO OR
HAVE_IOCTLSOCKET_CASE OR
HAVE_O_NONBLOCK)
set(HAVE_DISABLED_NONBLOCKING)
-endif(HAVE_FIONBIO OR
- HAVE_IOCTLSOCKET OR
- HAVE_IOCTLSOCKET_CASE OR
- HAVE_O_NONBLOCK)
+endif()
if(RETSIGTYPE_TEST)
set(RETSIGTYPE void)
-else(RETSIGTYPE_TEST)
+else()
set(RETSIGTYPE int)
-endif(RETSIGTYPE_TEST)
+endif()
if(CMAKE_COMPILER_IS_GNUCC AND APPLE)
include(CheckCCompilerFlag)
@@ -1164,33 +1203,15 @@ if(CMAKE_COMPILER_IS_GNUCC AND APPLE)
get_source_file_property(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS)
if(MPRINTF_COMPILE_FLAGS)
set(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double")
- else(MPRINTF_COMPILE_FLAGS)
+ else()
set(MPRINTF_COMPILE_FLAGS "-Wno-long-double")
- endif(MPRINTF_COMPILE_FLAGS)
+ endif()
set_source_files_properties(mprintf.c PROPERTIES
COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS})
- endif(HAVE_C_FLAG_Wno_long_double)
-endif(CMAKE_COMPILER_IS_GNUCC AND APPLE)
-
-if(HAVE_SOCKLEN_T)
- set(CURL_HAVE_SOCKLEN_T 1)
- set(CURL_TYPEOF_CURL_SOCKLEN_T "socklen_t")
- if(WIN32)
- set(CMAKE_EXTRA_INCLUDE_FILES "winsock2.h;ws2tcpip.h")
- elseif(HAVE_SYS_SOCKET_H)
- set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h")
- endif()
- check_type_size("socklen_t" CURL_SIZEOF_CURL_SOCKLEN_T)
- set(CMAKE_EXTRA_INCLUDE_FILES)
- if(NOT HAVE_CURL_SIZEOF_CURL_SOCKLEN_T)
- message(FATAL_ERROR
- "Check for sizeof socklen_t failed, see CMakeFiles/CMakerror.log")
endif()
-else()
- set(CURL_HAVE_SOCKLEN_T 0)
endif()
-# TODO test which of these headers are required for the typedefs used in curlbuild.h
+# TODO test which of these headers are required
if(WIN32)
set(CURL_PULL_WS2TCPIP_H ${HAVE_WS2TCPIP_H})
else()
@@ -1205,22 +1226,37 @@ include(CMake/OtherTests.cmake)
add_definitions(-DHAVE_CONFIG_H)
-# For windows, do not allow the compiler to use default target (Vista).
-if(WIN32)
- add_definitions(-D_WIN32_WINNT=0x0501)
-endif(WIN32)
-
-# For windows, all compilers used by cmake should support large files
+# For Windows, all compilers used by CMake should support large files
if(WIN32)
set(USE_WIN32_LARGE_FILES ON)
-endif(WIN32)
+
+ # Use the manifest embedded in the Windows Resource
+ set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -DCURL_EMBED_MANIFEST")
+endif()
if(MSVC)
+ # Disable default manifest added by CMake
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
+
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
-endif(MSVC)
+ if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
+ string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+ else()
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
+ endif()
+endif()
+
+if(CURL_WERROR)
+ if(MSVC_VERSION)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
+ else()
+ # this assumes clang or gcc style options
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
+ endif()
+endif()
# Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it).
-function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE)
+function(transform_makefile_inc INPUT_FILE OUTPUT_FILE)
file(READ ${INPUT_FILE} MAKEFILE_INC_TEXT)
string(REPLACE "$(top_srcdir)" "\${CURL_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
string(REPLACE "$(top_builddir)" "\${CURL_BINARY_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
@@ -1236,20 +1272,32 @@ function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE)
endfunction()
if(0) # This code not needed for building within CMake.
-add_subdirectory(docs)
+include(GNUInstallDirs)
+
+set(CURL_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
+set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
+set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
+set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
+set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
endif()
+
+if(USE_MANUAL)
+ add_subdirectory(docs)
+endif()
+
add_subdirectory(lib)
+
if(BUILD_CURL_EXE)
add_subdirectory(src)
endif()
#-----------------------------------------------------------------------------
# CMake-specific curl code.
-add_executable(LIBCURL curltest.c)
-target_link_libraries(LIBCURL cmcurl)
+add_executable(curltest curltest.c)
+target_link_libraries(curltest cmcurl)
-if(CMAKE_CURL_TEST_URL)
- add_test(curl LIBCURL ${CMAKE_CURL_TEST_URL})
+if(BUILD_TESTING AND CMAKE_CURL_TEST_URL)
+ add_test(curl curltest ${CMAKE_CURL_TEST_URL})
endif()
install(FILES COPYING DESTINATION ${CMAKE_DOC_DIR}/cmcurl)
@@ -1272,10 +1320,7 @@ endfunction()
# Clear list and try to detect available features
set(_items)
-_add_if("WinSSL" SSL_ENABLED AND USE_WINDOWS_SSPI)
-_add_if("OpenSSL" SSL_ENABLED AND USE_OPENSSL)
-_add_if("DarwinSSL" SSL_ENABLED AND USE_DARWINSSL)
-_add_if("mbedTLS" SSL_ENABLED AND USE_MBEDTLS)
+_add_if("SSL" SSL_ENABLED)
_add_if("IPv6" ENABLE_IPV6)
_add_if("unix-sockets" USE_UNIX_SOCKETS)
_add_if("libz" HAVE_LIBZ)
@@ -1293,7 +1338,7 @@ _add_if("Kerberos" NOT CURL_DISABLE_CRYPTO_AUTH AND
(HAVE_GSSAPI OR USE_WINDOWS_SSPI))
# NTLM support requires crypto function adaptions from various SSL libs
# TODO alternative SSL libs tests for SSP1, GNUTLS, NSS
-if(NOT CURL_DISABLE_CRYPTO_AUTH AND (USE_OPENSSL OR USE_WINDOWS_SSPI OR USE_DARWINSSL OR USE_MBEDTLS))
+if(NOT CURL_DISABLE_CRYPTO_AUTH AND (USE_OPENSSL OR USE_WINDOWS_SSPI OR USE_SECTRANSP OR USE_MBEDTLS))
_add_if("NTLM" 1)
# TODO missing option (autoconf: --enable-ntlm-wb)
_add_if("NTLM_WB" NOT CURL_DISABLE_HTTP AND NTLM_WB_ENABLED)
@@ -1332,10 +1377,24 @@ _add_if("SCP" USE_LIBSSH2)
_add_if("SFTP" USE_LIBSSH2)
_add_if("RTSP" NOT CURL_DISABLE_RTSP)
_add_if("RTMP" USE_LIBRTMP)
-list(SORT _items)
+if(_items)
+ list(SORT _items)
+endif()
string(REPLACE ";" " " SUPPORT_PROTOCOLS "${_items}")
message(STATUS "Enabled protocols: ${SUPPORT_PROTOCOLS}")
+# Clear list and collect SSL backends
+set(_items)
+_add_if("WinSSL" SSL_ENABLED AND USE_WINDOWS_SSPI)
+_add_if("OpenSSL" SSL_ENABLED AND USE_OPENSSL)
+_add_if("Secure Transport" SSL_ENABLED AND USE_SECTRANSP)
+_add_if("mbedTLS" SSL_ENABLED AND USE_MBEDTLS)
+if(_items)
+ list(SORT _items)
+endif()
+string(REPLACE ";" " " SSL_BACKENDS "${_items}")
+message(STATUS "Enabled SSL backends: ${SSL_BACKENDS}")
+
# curl-config needs the following options to be set.
set(CC "${CMAKE_C_COMPILER}")
# TODO probably put a -D... options here?
@@ -1343,11 +1402,12 @@ set(CONFIGURE_OPTIONS "")
# TODO when to set "-DCURL_STATICLIB" for CPPFLAG_CURL_STATICLIB?
set(CPPFLAG_CURL_STATICLIB "")
set(CURLVERSION "${CURL_VERSION}")
-set(ENABLE_SHARED "yes")
-if(CURL_STATICLIB)
- set(ENABLE_STATIC "yes")
-else()
+if(BUILD_SHARED_LIBS)
+ set(ENABLE_SHARED "yes")
set(ENABLE_STATIC "no")
+else()
+ set(ENABLE_SHARED "no")
+ set(ENABLE_STATIC "yes")
endif()
set(exec_prefix "\${prefix}")
set(includedir "\${prefix}/include")
@@ -1355,7 +1415,7 @@ set(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(LIBCURL_LIBS "")
set(libdir "${CMAKE_INSTALL_PREFIX}/lib")
foreach(_lib ${CMAKE_C_IMPLICIT_LINK_LIBRARIES} ${CURL_LIBS})
- if(_lib MATCHES ".*/.*")
+ if(_lib MATCHES ".*/.*" OR _lib MATCHES "^-")
set(LIBCURL_LIBS "${LIBCURL_LIBS} ${_lib}")
else()
set(LIBCURL_LIBS "${LIBCURL_LIBS} -l${_lib}")
@@ -1371,10 +1431,13 @@ set(REQUIRE_LIB_DEPS "no")
set(VERSIONNUM "${CURL_VERSION_NUM}")
# Finally generate a "curl-config" matching this config
+# Use:
+# * ENABLE_SHARED
+# * ENABLE_STATIC
configure_file("${CURL_SOURCE_DIR}/curl-config.in"
"${CURL_BINARY_DIR}/curl-config" @ONLY)
install(FILES "${CURL_BINARY_DIR}/curl-config"
- DESTINATION bin
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
@@ -1384,23 +1447,38 @@ install(FILES "${CURL_BINARY_DIR}/curl-config"
configure_file("${CURL_SOURCE_DIR}/libcurl.pc.in"
"${CURL_BINARY_DIR}/libcurl.pc" @ONLY)
install(FILES "${CURL_BINARY_DIR}/libcurl.pc"
- DESTINATION lib/pkgconfig)
-
-# This needs to be run very last so other parts of the scripts can take advantage of this.
-if(NOT CURL_CONFIG_HAS_BEEN_RUN_BEFORE)
- set(CURL_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before")
-endif()
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
-# Installation.
-# First, install generated curlbuild.h
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/curl/curlbuild.h"
- DESTINATION include/curl )
-# Next, install other headers excluding curlbuild.h
+# install headers
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/curl"
- DESTINATION include
- FILES_MATCHING PATTERN "*.h"
- PATTERN "curlbuild.h" EXCLUDE)
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ FILES_MATCHING PATTERN "*.h")
+
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(
+ "${version_config}"
+ VERSION ${CURL_VERSION}
+ COMPATIBILITY SameMajorVersion
+)
+# Use:
+# * TARGETS_EXPORT_NAME
+# * PROJECT_NAME
+configure_package_config_file(CMake/curl-config.cmake.in
+ "${project_config}"
+ INSTALL_DESTINATION ${CURL_INSTALL_CMAKE_DIR}
+)
+
+install(
+ EXPORT "${TARGETS_EXPORT_NAME}"
+ NAMESPACE "${PROJECT_NAME}::"
+ DESTINATION ${CURL_INSTALL_CMAKE_DIR}
+)
+
+install(
+ FILES ${version_config} ${project_config}
+ DESTINATION ${CURL_INSTALL_CMAKE_DIR}
+)
# Workaround for MSVS10 to avoid the Dialog Hell
# FIXME: This could be removed with future version of CMake.
@@ -1410,4 +1488,15 @@ if(MSVC_VERSION EQUAL 1600)
file(APPEND "${CURL_SLN_FILENAME}" "\n# This should be regenerated!\n")
endif()
endif()
+
+if(NOT TARGET uninstall)
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/CMake/cmake_uninstall.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/CMake/cmake_uninstall.cmake
+ IMMEDIATE @ONLY)
+
+ add_custom_target(uninstall
+ COMMAND ${CMAKE_COMMAND} -P
+ ${CMAKE_CURRENT_BINARY_DIR}/CMake/cmake_uninstall.cmake)
+endif()
endif()
diff --git a/Utilities/cmcurl/COPYING b/Utilities/cmcurl/COPYING
index 1e45a5e2c..3528bd756 100644
--- a/Utilities/cmcurl/COPYING
+++ b/Utilities/cmcurl/COPYING
@@ -1,6 +1,6 @@
COPYRIGHT AND PERMISSION NOTICE
-Copyright (c) 1996 - 2017, Daniel Stenberg, <daniel@haxx.se>, and many
+Copyright (c) 1996 - 2019, Daniel Stenberg, <daniel@haxx.se>, and many
contributors, see the THANKS file.
All rights reserved.
diff --git a/Utilities/cmcurl/curltest.c b/Utilities/cmcurl/curltest.c
index 210868e36..f80e758a0 100644
--- a/Utilities/cmcurl/curltest.c
+++ b/Utilities/cmcurl/curltest.c
@@ -1,159 +1,81 @@
-/* Prevent warnings on Visual Studio */
-struct _RPC_ASYNC_STATE;
-
#include "curl/curl.h"
+
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-int GetFtpFile(void)
+int test_curl(const char* url)
{
- int retVal = 0;
- CURL *curl;
- CURLcode res;
- curl = curl_easy_init();
- if(curl)
- {
- /* Get curl 7.9.2 from sunet.se's FTP site: */
- curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
- curl_easy_setopt(curl, CURLOPT_HEADER, 1);
- curl_easy_setopt(curl, CURLOPT_URL,
- "ftp://public.kitware.com/pub/cmake/cygwin/setup.hint");
- res = curl_easy_perform(curl);
- if ( res != 0 )
- {
- printf("Error fetching: ftp://public.kitware.com/pub/cmake/cygwin/setup.hint\n");
- retVal = 1;
- }
-
- /* always cleanup */
- curl_easy_cleanup(curl);
- }
- else
- {
- printf("Cannot create curl object\n");
- retVal = 1;
- }
- return retVal;
-}
-
-int GetWebFiles(char *url1, char *url2)
-{
- int retVal = 0;
- CURL *curl;
- CURLcode res;
-
+ CURL* curl;
+ CURLcode r;
char proxy[1024];
int proxy_type = 0;
- if ( getenv("HTTP_PROXY") )
- {
+ if (getenv("HTTP_PROXY")) {
proxy_type = 1;
- if (getenv("HTTP_PROXY_PORT") )
- {
+ if (getenv("HTTP_PROXY_PORT")) {
sprintf(proxy, "%s:%s", getenv("HTTP_PROXY"), getenv("HTTP_PROXY_PORT"));
- }
- else
- {
+ } else {
sprintf(proxy, "%s", getenv("HTTP_PROXY"));
- }
- if ( getenv("HTTP_PROXY_TYPE") )
- {
+ }
+ if (getenv("HTTP_PROXY_TYPE")) {
/* HTTP/SOCKS4/SOCKS5 */
- if ( strcmp(getenv("HTTP_PROXY_TYPE"), "HTTP") == 0 )
- {
+ if (strcmp(getenv("HTTP_PROXY_TYPE"), "HTTP") == 0) {
proxy_type = 1;
- }
- else if ( strcmp(getenv("HTTP_PROXY_TYPE"), "SOCKS4") == 0 )
- {
+ } else if (strcmp(getenv("HTTP_PROXY_TYPE"), "SOCKS4") == 0) {
proxy_type = 2;
- }
- else if ( strcmp(getenv("HTTP_PROXY_TYPE"), "SOCKS5") == 0 )
- {
+ } else if (strcmp(getenv("HTTP_PROXY_TYPE"), "SOCKS5") == 0) {
proxy_type = 3;
- }
}
}
+ }
curl = curl_easy_init();
- if(curl)
- {
- curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
- curl_easy_setopt(curl, CURLOPT_HEADER, 1);
-
- /* Using proxy */
- if ( proxy_type > 0 )
- {
- curl_easy_setopt(curl, CURLOPT_PROXY, proxy);
- switch (proxy_type)
- {
- case 2:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
- break;
- case 3:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
- break;
- default:
- curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
- }
- }
-
- /* get the first document */
- curl_easy_setopt(curl, CURLOPT_URL, url1);
- res = curl_easy_perform(curl);
- if ( res != 0 )
- {
- printf("Error fetching: %s\n", url1);
- retVal = 1;
- }
+ if (!curl) {
+ fprintf(stderr, "curl_easy_init failed\n");
+ return 1;
+ }
+
+ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+ curl_easy_setopt(curl, CURLOPT_HEADER, 1);
+
+ if (proxy_type > 0) {
+ curl_easy_setopt(curl, CURLOPT_PROXY, proxy);
+ switch (proxy_type) {
+ case 2:
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
+ break;
+ case 3:
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
+ break;
+ default:
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+ }
+ }
- /* get another document from the same server using the same
- connection */
- /* avoid warnings about url2 since below block is commented out: */
- (void) url2;
- /*
- curl_easy_setopt(curl, CURLOPT_URL, url2);
- res = curl_easy_perform(curl);
- if ( res != 0 )
- {
- printf("Error fetching: %s\n", url2);
- retVal = 1;
- }
- */
+ curl_easy_setopt(curl, CURLOPT_URL, url);
+ r = curl_easy_perform(curl);
+ curl_easy_cleanup(curl);
- /* always cleanup */
- curl_easy_cleanup(curl);
- }
- else
- {
- printf("Cannot create curl object\n");
- retVal = 1;
- }
+ if (r != CURLE_OK) {
+ fprintf(stderr, "error: fetching '%s' failed: %s\n", url,
+ curl_easy_strerror(r));
+ return 1;
+ }
- return retVal;
+ return 0;
}
-
-int main(int argc, char **argv)
+int main(int argc, const char* argv[])
{
- int retVal = 0;
-
+ int r;
curl_global_init(CURL_GLOBAL_DEFAULT);
-
- if(argc>1)
- {
- retVal += GetWebFiles(argv[1], 0);
- }
- else
- {
- printf("error: first argument should be a url to download\n");
- retVal = 1;
- }
-
- /* Do not check the output of FTP socks5 cannot handle FTP yet */
- /* GetFtpFile(); */
- /* do not test ftp right now because we don't enable that port */
-
+ if (argc == 2) {
+ r = test_curl(argv[1]);
+ } else {
+ fprintf(stderr, "error: no URL given as first argument\n");
+ r = 1;
+ }
curl_global_cleanup();
-
- return retVal;
+ return r;
}
diff --git a/Utilities/cmcurl/include/curl/curl.h b/Utilities/cmcurl/include/curl/curl.h
index 395521202..089c427db 100644
--- a/Utilities/cmcurl/include/curl/curl.h
+++ b/Utilities/cmcurl/include/curl/curl.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -36,8 +36,6 @@
#include "curlver.h" /* libcurl version defines */
#include "system.h" /* determine things run-time */
-#include "cmcurl/include/curl/curlbuild.h" /* libcurl build definitions */
-#include "curlrules.h" /* libcurl rules enforcement */
/*
* Define WIN32 when build target is Win32 API
@@ -76,6 +74,7 @@
#if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \
defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \
defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \
+ defined(__CYGWIN__) || \
(defined(__FreeBSD_version) && (__FreeBSD_version < 800000))
#include <sys/select.h>
#endif
@@ -92,6 +91,11 @@
#include <support/SupportDefs.h>
#endif
+/* Compatibility for non-Clang compilers */
+#ifndef __has_declspec_attribute
+# define __has_declspec_attribute(x) 0
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -110,7 +114,9 @@ typedef void CURLSH;
#ifdef CURL_STATICLIB
# define CURL_EXTERN
-#elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)
+#elif defined(WIN32) || defined(__SYMBIAN32__) || \
+ (__has_declspec_attribute(dllexport) && \
+ __has_declspec_attribute(dllimport))
# if defined(BUILDING_LIBCURL)
# define CURL_EXTERN __declspec(dllexport)
# else
@@ -134,6 +140,31 @@ typedef int curl_socket_t;
#define curl_socket_typedef
#endif /* curl_socket_typedef */
+/* enum for the different supported SSL backends */
+typedef enum {
+ CURLSSLBACKEND_NONE = 0,
+ CURLSSLBACKEND_OPENSSL = 1,
+ CURLSSLBACKEND_GNUTLS = 2,
+ CURLSSLBACKEND_NSS = 3,
+ CURLSSLBACKEND_OBSOLETE4 = 4, /* Was QSOSSL. */
+ CURLSSLBACKEND_GSKIT = 5,
+ CURLSSLBACKEND_POLARSSL = 6,
+ CURLSSLBACKEND_WOLFSSL = 7,
+ CURLSSLBACKEND_SCHANNEL = 8,
+ CURLSSLBACKEND_SECURETRANSPORT = 9,
+ CURLSSLBACKEND_AXTLS = 10, /* never used since 7.63.0 */
+ CURLSSLBACKEND_MBEDTLS = 11,
+ CURLSSLBACKEND_MESALINK = 12
+} curl_sslbackend;
+
+/* aliases for library clones and renames */
+#define CURLSSLBACKEND_LIBRESSL CURLSSLBACKEND_OPENSSL
+#define CURLSSLBACKEND_BORINGSSL CURLSSLBACKEND_OPENSSL
+
+/* deprecated names: */
+#define CURLSSLBACKEND_CYASSL CURLSSLBACKEND_WOLFSSL
+#define CURLSSLBACKEND_DARWINSSL CURLSSLBACKEND_SECURETRANSPORT
+
struct curl_httppost {
struct curl_httppost *next; /* next entry in the list */
char *name; /* pointer to allocated name */
@@ -225,7 +256,9 @@ typedef size_t (*curl_write_callback)(char *buffer,
size_t nitems,
void *outstream);
-
+/* This callback will be called when a new resolver request is made */
+typedef int (*curl_resolver_start_callback)(void *resolver_state,
+ void *reserved, void *userdata);
/* enumeration of file types */
typedef enum {
@@ -257,7 +290,7 @@ typedef enum {
struct curl_fileinfo {
char *filename;
curlfiletype filetype;
- time_t time;
+ time_t time; /* always zero! */
unsigned int perm;
int uid;
int gid;
@@ -332,12 +365,22 @@ typedef int (*curl_seek_callback)(void *instream,
signal libcurl to pause sending data on the current transfer. */
#define CURL_READFUNC_PAUSE 0x10000001
+/* Return code for when the trailing headers' callback has terminated
+ without any errors*/
+#define CURL_TRAILERFUNC_OK 0
+/* Return code for when was an error in the trailing header's list and we
+ want to abort the request */
+#define CURL_TRAILERFUNC_ABORT 1
+
typedef size_t (*curl_read_callback)(char *buffer,
size_t size,
size_t nitems,
void *instream);
-typedef enum {
+typedef int (*curl_trailer_callback)(struct curl_slist **list,
+ void *userdata);
+
+typedef enum {
CURLSOCKTYPE_IPCXN, /* socket created for a specific IP connection */
CURLSOCKTYPE_ACCEPT, /* socket created by accept() call */
CURLSOCKTYPE_LAST /* never use */
@@ -379,7 +422,7 @@ typedef enum {
CURLIOE_LAST /* never use */
} curlioerr;
-typedef enum {
+typedef enum {
CURLIOCMD_NOP, /* no operation */
CURLIOCMD_RESTARTREAD, /* restart the read stream from start */
CURLIOCMD_LAST /* never use */
@@ -495,8 +538,7 @@ typedef enum {
CURLE_UNKNOWN_OPTION, /* 48 - User specified an unknown option */
CURLE_TELNET_OPTION_SYNTAX, /* 49 - Malformed telnet option */
CURLE_OBSOLETE50, /* 50 - NOT USED */
- CURLE_PEER_FAILED_VERIFICATION, /* 51 - peer's certificate or fingerprint
- wasn't verified fine */
+ CURLE_OBSOLETE51, /* 51 - NOT USED */
CURLE_GOT_NOTHING, /* 52 - when this is a specific error */
CURLE_SSL_ENGINE_NOTFOUND, /* 53 - SSL crypto engine not found */
CURLE_SSL_ENGINE_SETFAILED, /* 54 - can not set SSL crypto engine as
@@ -506,7 +548,8 @@ typedef enum {
CURLE_OBSOLETE57, /* 57 - NOT IN USE */
CURLE_SSL_CERTPROBLEM, /* 58 - problem with the local certificate */
CURLE_SSL_CIPHER, /* 59 - couldn't use specified cipher */
- CURLE_SSL_CACERT, /* 60 - problem with the CA cert (path?) */
+ CURLE_PEER_FAILED_VERIFICATION, /* 60 - peer's certificate or fingerprint
+ wasn't verified fine */
CURLE_BAD_CONTENT_ENCODING, /* 61 - Unrecognized/bad encoding */
CURLE_LDAP_INVALID_URL, /* 62 - Invalid LDAP URL */
CURLE_FILESIZE_EXCEEDED, /* 63 - Maximum file size exceeded */
@@ -557,6 +600,8 @@ typedef enum {
CURLE_SSL_INVALIDCERTSTATUS, /* 91 - invalid certificate status */
CURLE_HTTP2_STREAM, /* 92 - stream error in HTTP/2 framing layer
*/
+ CURLE_RECURSIVE_API_CALL, /* 93 - an api function was called from
+ inside a callback */
CURL_LAST /* never use! */
} CURLcode;
@@ -574,6 +619,9 @@ typedef enum {
#define CURLOPT_ENCODING CURLOPT_ACCEPT_ENCODING
#define CURLE_FTP_WEIRD_SERVER_REPLY CURLE_WEIRD_SERVER_REPLY
+/* The following were added in 7.62.0 */
+#define CURLE_SSL_CACERT CURLE_PEER_FAILED_VERIFICATION
+
/* The following were added in 7.21.5, April 2011 */
#define CURLE_UNKNOWN_TELNET_OPTION CURLE_UNKNOWN_OPTION
@@ -667,6 +715,7 @@ typedef enum {
* CURLAUTH_NTLM - HTTP NTLM authentication
* CURLAUTH_DIGEST_IE - HTTP Digest authentication with IE flavour
* CURLAUTH_NTLM_WB - HTTP NTLM authentication delegated to winbind helper
+ * CURLAUTH_BEARER - HTTP Bearer token authentication
* CURLAUTH_ONLY - Use together with a single other type to force no
* authentication or just that single type
* CURLAUTH_ANY - All fine types set
@@ -679,9 +728,12 @@ typedef enum {
#define CURLAUTH_NEGOTIATE (((unsigned long)1)<<2)
/* Deprecated since the advent of CURLAUTH_NEGOTIATE */
#define CURLAUTH_GSSNEGOTIATE CURLAUTH_NEGOTIATE
+/* Used for CURLOPT_SOCKS5_AUTH to stay terminologically correct */
+#define CURLAUTH_GSSAPI CURLAUTH_NEGOTIATE
#define CURLAUTH_NTLM (((unsigned long)1)<<3)
#define CURLAUTH_DIGEST_IE (((unsigned long)1)<<4)
#define CURLAUTH_NTLM_WB (((unsigned long)1)<<5)
+#define CURLAUTH_BEARER (((unsigned long)1)<<6)
#define CURLAUTH_ONLY (((unsigned long)1)<<31)
#define CURLAUTH_ANY (~CURLAUTH_DIGEST_IE)
#define CURLAUTH_ANYSAFE (~(CURLAUTH_BASIC|CURLAUTH_DIGEST_IE))
@@ -693,6 +745,7 @@ typedef enum {
#define CURLSSH_AUTH_HOST (1<<2) /* host key files */
#define CURLSSH_AUTH_KEYBOARD (1<<3) /* keyboard interactive */
#define CURLSSH_AUTH_AGENT (1<<4) /* agent (ssh-agent, pageant...) */
+#define CURLSSH_AUTH_GSSAPI (1<<5) /* gssapi (kerberos, ...) */
#define CURLSSH_AUTH_DEFAULT CURLSSH_AUTH_ANY
#define CURLGSSAPI_DELEGATION_NONE 0 /* no delegation (default) */
@@ -705,7 +758,9 @@ enum curl_khtype {
CURLKHTYPE_UNKNOWN,
CURLKHTYPE_RSA1,
CURLKHTYPE_RSA,
- CURLKHTYPE_DSS
+ CURLKHTYPE_DSS,
+ CURLKHTYPE_ECDSA,
+ CURLKHTYPE_ED25519
};
struct curl_khkey {
@@ -764,6 +819,14 @@ typedef enum {
SSL backends where such behavior is present. */
#define CURLSSLOPT_NO_REVOKE (1<<1)
+/* The default connection attempt delay in milliseconds for happy eyeballs.
+ CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS.3 and happy-eyeballs-timeout-ms.d document
+ this value, keep them in sync. */
+#define CURL_HET_DEFAULT 200L
+
+/* The default connection upkeep interval in milliseconds. */
+#define CURL_UPKEEP_INTERVAL_DEFAULT 60000L
+
#ifndef CURL_NO_OLDIES /* define this to test if your app builds with all
the obsolete stuff removed! */
@@ -818,6 +881,14 @@ typedef enum {
#define CURLHEADER_UNIFIED 0
#define CURLHEADER_SEPARATE (1<<0)
+/* CURLALTSVC_* are bits for the CURLOPT_ALTSVC_CTRL option */
+#define CURLALTSVC_IMMEDIATELY (1<<0)
+#define CURLALTSVC_ALTUSED (1<<1)
+#define CURLALTSVC_READONLYFILE (1<<2)
+#define CURLALTSVC_H1 (1<<3)
+#define CURLALTSVC_H2 (1<<4)
+#define CURLALTSVC_H3 (1<<5)
+
/* CURLPROTO_ defines are for the CURLOPT_*PROTOCOLS options */
#define CURLPROTO_HTTP (1<<0)
#define CURLPROTO_HTTPS (1<<1)
@@ -913,7 +984,7 @@ typedef enum {
CINIT(READDATA, OBJECTPOINT, 9),
/* Buffer to receive error messages in, must be at least CURL_ERROR_SIZE
- * bytes big. If this is not used, error messages go to stderr instead: */
+ * bytes big. */
CINIT(ERRORBUFFER, OBJECTPOINT, 10),
/* Function that will be called to store the output (instead of fwrite). The
@@ -1637,7 +1708,7 @@ typedef enum {
* Only supported by the c-ares DNS backend */
CINIT(DNS_LOCAL_IP4, STRINGPOINT, 222),
- /* Set the local IPv4 address to use for outgoing DNS requests.
+ /* Set the local IPv6 address to use for outgoing DNS requests.
* Only supported by the c-ares DNS backend */
CINIT(DNS_LOCAL_IP6, STRINGPOINT, 223),
@@ -1782,6 +1853,74 @@ typedef enum {
/* Suppress proxy CONNECT response headers from user callbacks */
CINIT(SUPPRESS_CONNECT_HEADERS, LONG, 265),
+ /* The request target, instead of extracted from the URL */
+ CINIT(REQUEST_TARGET, STRINGPOINT, 266),
+
+ /* bitmask of allowed auth methods for connections to SOCKS5 proxies */
+ CINIT(SOCKS5_AUTH, LONG, 267),
+
+ /* Enable/disable SSH compression */
+ CINIT(SSH_COMPRESSION, LONG, 268),
+
+ /* Post MIME data. */
+ CINIT(MIMEPOST, OBJECTPOINT, 269),
+
+ /* Time to use with the CURLOPT_TIMECONDITION. Specified in number of
+ seconds since 1 Jan 1970. */
+ CINIT(TIMEVALUE_LARGE, OFF_T, 270),
+
+ /* Head start in milliseconds to give happy eyeballs. */
+ CINIT(HAPPY_EYEBALLS_TIMEOUT_MS, LONG, 271),
+
+ /* Function that will be called before a resolver request is made */
+ CINIT(RESOLVER_START_FUNCTION, FUNCTIONPOINT, 272),
+
+ /* User data to pass to the resolver start callback. */
+ CINIT(RESOLVER_START_DATA, OBJECTPOINT, 273),
+
+ /* send HAProxy PROXY protocol header? */
+ CINIT(HAPROXYPROTOCOL, LONG, 274),
+
+ /* shuffle addresses before use when DNS returns multiple */
+ CINIT(DNS_SHUFFLE_ADDRESSES, LONG, 275),
+
+ /* Specify which TLS 1.3 ciphers suites to use */
+ CINIT(TLS13_CIPHERS, STRINGPOINT, 276),
+ CINIT(PROXY_TLS13_CIPHERS, STRINGPOINT, 277),
+
+ /* Disallow specifying username/login in URL. */
+ CINIT(DISALLOW_USERNAME_IN_URL, LONG, 278),
+
+ /* DNS-over-HTTPS URL */
+ CINIT(DOH_URL, STRINGPOINT, 279),
+
+ /* Preferred buffer size to use for uploads */
+ CINIT(UPLOAD_BUFFERSIZE, LONG, 280),
+
+ /* Time in ms between connection upkeep calls for long-lived connections. */
+ CINIT(UPKEEP_INTERVAL_MS, LONG, 281),
+
+ /* Specify URL using CURL URL API. */
+ CINIT(CURLU, OBJECTPOINT, 282),
+
+ /* add trailing data just after no more data is available */
+ CINIT(TRAILERFUNCTION, FUNCTIONPOINT, 283),
+
+ /* pointer to be passed to HTTP_TRAILER_FUNCTION */
+ CINIT(TRAILERDATA, OBJECTPOINT, 284),
+
+ /* set this to 1L to allow HTTP/0.9 responses or 0L to disallow */
+ CINIT(HTTP09_ALLOWED, LONG, 285),
+
+ /* alt-svc control bitmask */
+ CINIT(ALTSVC_CTRL, LONG, 286),
+
+ /* alt-svc cache file name to possibly read from/write to */
+ CINIT(ALTSVC, STRINGPOINT, 287),
+
+ /* maximum age of a connection to consider it for reuse (in seconds) */
+ CINIT(MAXAGE_CONN, LONG, 288),
+
CURLOPT_LASTENTRY /* the last unused */
} CURLoption;
@@ -1928,15 +2067,140 @@ typedef enum {
CURL_TIMECOND_LAST
} curl_TimeCond;
+/* Special size_t value signaling a zero-terminated string. */
+#define CURL_ZERO_TERMINATED ((size_t) -1)
/* curl_strequal() and curl_strnequal() are subject for removal in a future
- libcurl, see lib/README.curlx for details
+ release */
+CURL_EXTERN int curl_strequal(const char *s1, const char *s2);
+CURL_EXTERN int curl_strnequal(const char *s1, const char *s2, size_t n);
+
+/* Mime/form handling support. */
+typedef struct curl_mime_s curl_mime; /* Mime context. */
+typedef struct curl_mimepart_s curl_mimepart; /* Mime part context. */
+
+/*
+ * NAME curl_mime_init()
+ *
+ * DESCRIPTION
+ *
+ * Create a mime context and return its handle. The easy parameter is the
+ * target handle.
+ */
+CURL_EXTERN curl_mime *curl_mime_init(CURL *easy);
- !checksrc! disable SPACEBEFOREPAREN 2
-*/
-CURL_EXTERN int (curl_strequal)(const char *s1, const char *s2);
-CURL_EXTERN int (curl_strnequal)(const char *s1, const char *s2, size_t n);
+/*
+ * NAME curl_mime_free()
+ *
+ * DESCRIPTION
+ *
+ * release a mime handle and its substructures.
+ */
+CURL_EXTERN void curl_mime_free(curl_mime *mime);
+/*
+ * NAME curl_mime_addpart()
+ *
+ * DESCRIPTION
+ *
+ * Append a new empty part to the given mime context and return a handle to
+ * the created part.
+ */
+CURL_EXTERN curl_mimepart *curl_mime_addpart(curl_mime *mime);
+
+/*
+ * NAME curl_mime_name()
+ *
+ * DESCRIPTION
+ *
+ * Set mime/form part name.
+ */
+CURL_EXTERN CURLcode curl_mime_name(curl_mimepart *part, const char *name);
+
+/*
+ * NAME curl_mime_filename()
+ *
+ * DESCRIPTION
+ *
+ * Set mime part remote file name.
+ */
+CURL_EXTERN CURLcode curl_mime_filename(curl_mimepart *part,
+ const char *filename);
+
+/*
+ * NAME curl_mime_type()
+ *
+ * DESCRIPTION
+ *
+ * Set mime part type.
+ */
+CURL_EXTERN CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype);
+
+/*
+ * NAME curl_mime_encoder()
+ *
+ * DESCRIPTION
+ *
+ * Set mime data transfer encoder.
+ */
+CURL_EXTERN CURLcode curl_mime_encoder(curl_mimepart *part,
+ const char *encoding);
+
+/*
+ * NAME curl_mime_data()
+ *
+ * DESCRIPTION
+ *
+ * Set mime part data source from memory data,
+ */
+CURL_EXTERN CURLcode curl_mime_data(curl_mimepart *part,
+ const char *data, size_t datasize);
+
+/*
+ * NAME curl_mime_filedata()
+ *
+ * DESCRIPTION
+ *
+ * Set mime part data source from named file.
+ */
+CURL_EXTERN CURLcode curl_mime_filedata(curl_mimepart *part,
+ const char *filename);
+
+/*
+ * NAME curl_mime_data_cb()
+ *
+ * DESCRIPTION
+ *
+ * Set mime part data source from callback function.
+ */
+CURL_EXTERN CURLcode curl_mime_data_cb(curl_mimepart *part,
+ curl_off_t datasize,
+ curl_read_callback readfunc,
+ curl_seek_callback seekfunc,
+ curl_free_callback freefunc,
+ void *arg);
+
+/*
+ * NAME curl_mime_subparts()
+ *
+ * DESCRIPTION
+ *
+ * Set mime part data source from subparts.
+ */
+CURL_EXTERN CURLcode curl_mime_subparts(curl_mimepart *part,
+ curl_mime *subparts);
+/*
+ * NAME curl_mime_headers()
+ *
+ * DESCRIPTION
+ *
+ * Set mime part headers.
+ */
+CURL_EXTERN CURLcode curl_mime_headers(curl_mimepart *part,
+ struct curl_slist *headers,
+ int take_ownership);
+
+/* Old form API. */
/* name is uppercase CURLFORM_<name> */
#ifdef CFINIT
#undef CFINIT
@@ -2179,6 +2443,47 @@ struct curl_slist {
};
/*
+ * NAME curl_global_sslset()
+ *
+ * DESCRIPTION
+ *
+ * When built with multiple SSL backends, curl_global_sslset() allows to
+ * choose one. This function can only be called once, and it must be called
+ * *before* curl_global_init().
+ *
+ * The backend can be identified by the id (e.g. CURLSSLBACKEND_OPENSSL). The
+ * backend can also be specified via the name parameter (passing -1 as id).
+ * If both id and name are specified, the name will be ignored. If neither id
+ * nor name are specified, the function will fail with
+ * CURLSSLSET_UNKNOWN_BACKEND and set the "avail" pointer to the
+ * NULL-terminated list of available backends.
+ *
+ * Upon success, the function returns CURLSSLSET_OK.
+ *
+ * If the specified SSL backend is not available, the function returns
+ * CURLSSLSET_UNKNOWN_BACKEND and sets the "avail" pointer to a NULL-terminated
+ * list of available SSL backends.
+ *
+ * The SSL backend can be set only once. If it has already been set, a
+ * subsequent attempt to change it will result in a CURLSSLSET_TOO_LATE.
+ */
+
+typedef struct {
+ curl_sslbackend id;
+ const char *name;
+} curl_ssl_backend;
+
+typedef enum {
+ CURLSSLSET_OK = 0,
+ CURLSSLSET_UNKNOWN_BACKEND,
+ CURLSSLSET_TOO_LATE,
+ CURLSSLSET_NO_BACKENDS /* libcurl was built without any SSL support */
+} CURLsslset;
+
+CURL_EXTERN CURLsslset curl_global_sslset(curl_sslbackend id, const char *name,
+ const curl_ssl_backend ***avail);
+
+/*
* NAME curl_slist_append()
*
* DESCRIPTION
@@ -2218,27 +2523,6 @@ struct curl_certinfo {
format "name: value" */
};
-/* enum for the different supported SSL backends */
-typedef enum {
- CURLSSLBACKEND_NONE = 0,
- CURLSSLBACKEND_OPENSSL = 1,
- CURLSSLBACKEND_GNUTLS = 2,
- CURLSSLBACKEND_NSS = 3,
- CURLSSLBACKEND_OBSOLETE4 = 4, /* Was QSOSSL. */
- CURLSSLBACKEND_GSKIT = 5,
- CURLSSLBACKEND_POLARSSL = 6,
- CURLSSLBACKEND_CYASSL = 7,
- CURLSSLBACKEND_SCHANNEL = 8,
- CURLSSLBACKEND_DARWINSSL = 9,
- CURLSSLBACKEND_AXTLS = 10,
- CURLSSLBACKEND_MBEDTLS = 11
-} curl_sslbackend;
-
-/* aliases for library clones and renames */
-#define CURLSSLBACKEND_LIBRESSL 1
-#define CURLSSLBACKEND_BORINGSSL 1
-#define CURLSSLBACKEND_WOLFSSL 6
-
/* Information about the SSL library used and the respective internal SSL
handle, which can be used to obtain further information regarding the
connection. Asked for with CURLINFO_TLS_SSL_PTR or CURLINFO_TLS_SESSION. */
@@ -2253,6 +2537,7 @@ struct curl_tlssessioninfo {
#define CURLINFO_SLIST 0x400000
#define CURLINFO_PTR 0x400000 /* same as SLIST */
#define CURLINFO_SOCKET 0x500000
+#define CURLINFO_OFF_T 0x600000
#define CURLINFO_MASK 0x0fffff
#define CURLINFO_TYPEMASK 0xf00000
@@ -2265,15 +2550,22 @@ typedef enum {
CURLINFO_CONNECT_TIME = CURLINFO_DOUBLE + 5,
CURLINFO_PRETRANSFER_TIME = CURLINFO_DOUBLE + 6,
CURLINFO_SIZE_UPLOAD = CURLINFO_DOUBLE + 7,
+ CURLINFO_SIZE_UPLOAD_T = CURLINFO_OFF_T + 7,
CURLINFO_SIZE_DOWNLOAD = CURLINFO_DOUBLE + 8,
+ CURLINFO_SIZE_DOWNLOAD_T = CURLINFO_OFF_T + 8,
CURLINFO_SPEED_DOWNLOAD = CURLINFO_DOUBLE + 9,
+ CURLINFO_SPEED_DOWNLOAD_T = CURLINFO_OFF_T + 9,
CURLINFO_SPEED_UPLOAD = CURLINFO_DOUBLE + 10,
+ CURLINFO_SPEED_UPLOAD_T = CURLINFO_OFF_T + 10,
CURLINFO_HEADER_SIZE = CURLINFO_LONG + 11,
CURLINFO_REQUEST_SIZE = CURLINFO_LONG + 12,
CURLINFO_SSL_VERIFYRESULT = CURLINFO_LONG + 13,
CURLINFO_FILETIME = CURLINFO_LONG + 14,
+ CURLINFO_FILETIME_T = CURLINFO_OFF_T + 14,
CURLINFO_CONTENT_LENGTH_DOWNLOAD = CURLINFO_DOUBLE + 15,
+ CURLINFO_CONTENT_LENGTH_DOWNLOAD_T = CURLINFO_OFF_T + 15,
CURLINFO_CONTENT_LENGTH_UPLOAD = CURLINFO_DOUBLE + 16,
+ CURLINFO_CONTENT_LENGTH_UPLOAD_T = CURLINFO_OFF_T + 16,
CURLINFO_STARTTRANSFER_TIME = CURLINFO_DOUBLE + 17,
CURLINFO_CONTENT_TYPE = CURLINFO_STRING + 18,
CURLINFO_REDIRECT_TIME = CURLINFO_DOUBLE + 19,
@@ -2309,7 +2601,17 @@ typedef enum {
CURLINFO_SCHEME = CURLINFO_STRING + 49,
/* Fill in new entries below here! */
- CURLINFO_LASTONE = 49
+ /* Preferably these would be defined conditionally based on the
+ sizeof curl_off_t being 64-bits */
+ CURLINFO_TOTAL_TIME_T = CURLINFO_OFF_T + 50,
+ CURLINFO_NAMELOOKUP_TIME_T = CURLINFO_OFF_T + 51,
+ CURLINFO_CONNECT_TIME_T = CURLINFO_OFF_T + 52,
+ CURLINFO_PRETRANSFER_TIME_T = CURLINFO_OFF_T + 53,
+ CURLINFO_STARTTRANSFER_TIME_T = CURLINFO_OFF_T + 54,
+ CURLINFO_REDIRECT_TIME_T = CURLINFO_OFF_T + 55,
+ CURLINFO_APPCONNECT_TIME_T = CURLINFO_OFF_T + 56,
+
+ CURLINFO_LASTONE = 56
} CURLINFO;
/* CURLINFO_RESPONSE_CODE is the new name for the option previously known as
@@ -2328,7 +2630,7 @@ typedef enum {
CURLCLOSEPOLICY_LAST /* last, never use this */
} curl_closepolicy;
-#define CURL_GLOBAL_SSL (1<<0)
+#define CURL_GLOBAL_SSL (1<<0) /* no purpose since since 7.57.0 */
#define CURL_GLOBAL_WIN32 (1<<1)
#define CURL_GLOBAL_ALL (CURL_GLOBAL_SSL|CURL_GLOBAL_WIN32)
#define CURL_GLOBAL_NOTHING 0
@@ -2352,6 +2654,7 @@ typedef enum {
CURL_LOCK_DATA_DNS,
CURL_LOCK_DATA_SSL_SESSION,
CURL_LOCK_DATA_CONNECT,
+ CURL_LOCK_DATA_PSL,
CURL_LOCK_DATA_LAST
} curl_lock_data;
@@ -2406,6 +2709,7 @@ typedef enum {
CURLVERSION_SECOND,
CURLVERSION_THIRD,
CURLVERSION_FOURTH,
+ CURLVERSION_FIFTH,
CURLVERSION_LAST /* never actually use this */
} CURLversion;
@@ -2414,7 +2718,7 @@ typedef enum {
meant to be a built-in version number for what kind of struct the caller
expects. If the struct ever changes, we redefine the NOW to another enum
from above. */
-#define CURLVERSION_NOW CURLVERSION_FOURTH
+#define CURLVERSION_NOW CURLVERSION_FIFTH
typedef struct {
CURLversion age; /* age of the returned struct */
@@ -2442,6 +2746,12 @@ typedef struct {
const char *libssh_version; /* human readable string */
+ /* These fields were added in CURLVERSION_FIFTH */
+
+ unsigned int brotli_ver_num; /* Numeric Brotli version
+ (MAJOR << 24) | (MINOR << 12) | PATCH */
+ const char *brotli_version; /* human readable string. */
+
} curl_version_info_data;
#define CURL_VERSION_IPV6 (1<<0) /* IPv6-enabled */
@@ -2471,6 +2781,9 @@ typedef struct {
#define CURL_VERSION_PSL (1<<20) /* Mozilla's Public Suffix List, used
for cookie domain verification */
#define CURL_VERSION_HTTPS_PROXY (1<<21) /* HTTPS-proxy support built-in */
+#define CURL_VERSION_MULTI_SSL (1<<22) /* Multiple SSL backends available */
+#define CURL_VERSION_BROTLI (1<<23) /* Brotli features are present. */
+#define CURL_VERSION_ALTSVC (1<<24) /* Alt-Svc handling built-in */
/*
* NAME curl_version_info()
@@ -2532,6 +2845,7 @@ CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask);
stuff before they can be included! */
#include "easy.h" /* nothing in curl is fun without the easy stuff */
#include "multi.h"
+#include "urlapi.h"
/* the typechecker doesn't work in C++ (yet) */
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && \
diff --git a/Utilities/cmcurl/include/curl/curlbuild.h.cmake b/Utilities/cmcurl/include/curl/curlbuild.h.cmake
deleted file mode 100644
index c8b4f5270..000000000
--- a/Utilities/cmcurl/include/curl/curlbuild.h.cmake
+++ /dev/null
@@ -1,218 +0,0 @@
-#ifndef __CURL_CURLBUILD_H
-#define __CURL_CURLBUILD_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.haxx.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-/* ================================================================ */
-/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */
-/* ================================================================ */
-
-/*
- * NOTE 1:
- * -------
- *
- * Nothing in this file is intended to be modified or adjusted by the
- * curl library user nor by the curl library builder.
- *
- * If you think that something actually needs to be changed, adjusted
- * or fixed in this file, then, report it on the libcurl development
- * mailing list: https://cool.haxx.se/mailman/listinfo/curl-library/
- *
- * This header file shall only export symbols which are 'curl' or 'CURL'
- * prefixed, otherwise public name space would be polluted.
- *
- * NOTE 2:
- * -------
- *
- * Right now you might be staring at file include/curl/curlbuild.h.in or
- * at file include/curl/curlbuild.h, this is due to the following reason:
- *
- * On systems capable of running the configure script, the configure process
- * will overwrite the distributed include/curl/curlbuild.h file with one that
- * is suitable and specific to the library being configured and built, which
- * is generated from the include/curl/curlbuild.h.in template file.
- *
- */
-
-/* ================================================================ */
-/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */
-/* ================================================================ */
-
-#ifdef CURL_SIZEOF_LONG
-#error "CURL_SIZEOF_LONG shall not be defined except in curlbuild.h"
- Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined
-#endif
-
-#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
-#error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h"
- Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined
-#endif
-
-#ifdef CURL_SIZEOF_CURL_SOCKLEN_T
-#error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h"
- Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined
-#endif
-
-#ifdef CURL_TYPEOF_CURL_OFF_T
-#error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h"
- Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined
-#endif
-
-#ifdef CURL_FORMAT_CURL_OFF_T
-#error "CURL_FORMAT_CURL_OFF_T shall not be defined except in curlbuild.h"
- Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_already_defined
-#endif
-
-#ifdef CURL_FORMAT_CURL_OFF_TU
-#error "CURL_FORMAT_CURL_OFF_TU shall not be defined except in curlbuild.h"
- Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_already_defined
-#endif
-
-#ifdef CURL_FORMAT_OFF_T
-#error "CURL_FORMAT_OFF_T shall not be defined except in curlbuild.h"
- Error Compilation_aborted_CURL_FORMAT_OFF_T_already_defined
-#endif
-
-#ifdef CURL_SIZEOF_CURL_OFF_T
-#error "CURL_SIZEOF_CURL_OFF_T shall not be defined except in curlbuild.h"
- Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_already_defined
-#endif
-
-#ifdef CURL_SUFFIX_CURL_OFF_T
-#error "CURL_SUFFIX_CURL_OFF_T shall not be defined except in curlbuild.h"
- Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_already_defined
-#endif
-
-#ifdef CURL_SUFFIX_CURL_OFF_TU
-#error "CURL_SUFFIX_CURL_OFF_TU shall not be defined except in curlbuild.h"
- Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_already_defined
-#endif
-
-/* ================================================================ */
-/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */
-/* ================================================================ */
-
-/* Configure process defines this to 1 when it finds out that system */
-/* header file ws2tcpip.h must be included by the external interface. */
-#cmakedefine CURL_PULL_WS2TCPIP_H
-#ifdef CURL_PULL_WS2TCPIP_H
-# ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-# endif
-# include <windows.h>
-# include <winsock2.h>
-# include <ws2tcpip.h>
-#endif
-
-/* Configure process defines this to 1 when it finds out that system */
-/* header file sys/types.h must be included by the external interface. */
-#cmakedefine CURL_PULL_SYS_TYPES_H
-#ifdef CURL_PULL_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-/* Configure process defines this to 1 when it finds out that system */
-/* header file stdint.h must be included by the external interface. */
-#cmakedefine CURL_PULL_STDINT_H
-#ifdef CURL_PULL_STDINT_H
-# include <stdint.h>
-#endif
-
-/* Configure process defines this to 1 when it finds out that system */
-/* header file inttypes.h must be included by the external interface. */
-#cmakedefine CURL_PULL_INTTYPES_H
-#ifdef CURL_PULL_INTTYPES_H
-# include <inttypes.h>
-#endif
-
-/* Configure process defines this to 1 when it finds out that system */
-/* header file sys/socket.h must be included by the external interface. */
-#cmakedefine CURL_PULL_SYS_SOCKET_H
-#ifdef CURL_PULL_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-
-/* Configure process defines this to 1 when it finds out that system */
-/* header file sys/poll.h must be included by the external interface. */
-#cmakedefine CURL_PULL_SYS_POLL_H
-#ifdef CURL_PULL_SYS_POLL_H
-# include <sys/poll.h>
-#endif
-
-/* The size of `int', as computed by sizeof. */
-@CURL_SIZEOF_INT_CODE@
-
-/* The size of `long', as computed by sizeof. */
-@CURL_SIZEOF_LONG_CODE@
-
-/* The size of `long long', as computed by sizeof. */
-@CURL_SIZEOF_LONG_LONG_CODE@
-
-/* The size of `ssize_t', as computed by sizeof. */
-@CURL_SIZEOF_SSIZE_T_CODE@
-
-#define CURL_HAVE_SOCKLEN_T @CURL_HAVE_SOCKLEN_T@
-#if CURL_HAVE_SOCKLEN_T
-/* Integral data type used for curl_socklen_t. */
-#define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
-
-/* The size of `curl_socklen_t', as computed by sizeof. */
-@CURL_SIZEOF_CURL_SOCKLEN_T_CODE@
-#else
-# define CURL_TYPEOF_CURL_SOCKLEN_T int
-# define CURL_SIZEOF_CURL_SOCKLEN_T CURL_SIZEOF_INT
-#endif
-
-/* Data type definition of curl_socklen_t. */
-typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
-
-#if CURL_SIZEOF_LONG == 8
-# define CURL_TYPEOF_CURL_OFF_T long
-# define CURL_SIZEOF_CURL_OFF_T 8
-# define CURL_FORMAT_CURL_OFF_T "ld"
-# define CURL_FORMAT_CURL_OFF_TU "lu"
-# define CURL_FORMAT_OFF_T "%ld"
-# define CURL_SUFFIX_CURL_OFF_T L
-# define CURL_SUFFIX_CURL_OFF_TU UL
-#elif CURL_SIZEOF_LONG_LONG == 8
-# define CURL_TYPEOF_CURL_OFF_T long long
-# define CURL_SIZEOF_CURL_OFF_T 8
-# define CURL_FORMAT_CURL_OFF_T "lld"
-# define CURL_FORMAT_CURL_OFF_TU "llu"
-# define CURL_FORMAT_OFF_T "%lld"
-# define CURL_SUFFIX_CURL_OFF_T LL
-# define CURL_SUFFIX_CURL_OFF_TU ULL
-#else
-# define CURL_TYPEOF_CURL_OFF_T ssize_t
-# define CURL_SIZEOF_CURL_OFF_T CURL_SIZEOF_SSIZE_T
-/* TODO: need adjustment here. */
-# define CURL_FORMAT_CURL_OFF_T "ld"
-# define CURL_FORMAT_CURL_OFF_TU "lu"
-# define CURL_FORMAT_OFF_T "%ld"
-# define CURL_SUFFIX_CURL_OFF_T L
-# define CURL_SUFFIX_CURL_OFF_TU UL
-#endif
-
-/* Data type definition of curl_off_t. */
-typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
-
-#endif /* __CURL_CURLBUILD_H */
diff --git a/Utilities/cmcurl/include/curl/curlrules.h b/Utilities/cmcurl/include/curl/curlrules.h
deleted file mode 100644
index 0abd9f71d..000000000
--- a/Utilities/cmcurl/include/curl/curlrules.h
+++ /dev/null
@@ -1,239 +0,0 @@
-#ifndef __CURL_CURLRULES_H
-#define __CURL_CURLRULES_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.haxx.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-/* ================================================================ */
-/* COMPILE TIME SANITY CHECKS */
-/* ================================================================ */
-
-/*
- * NOTE 1:
- * -------
- *
- * All checks done in this file are intentionally placed in a public
- * header file which is pulled by curl/curl.h when an application is
- * being built using an already built libcurl library. Additionally
- * this file is also included and used when building the library.
- *
- * If compilation fails on this file it is certainly sure that the
- * problem is elsewhere. It could be a problem in the curlbuild.h
- * header file, or simply that you are using different compilation
- * settings than those used to build the library.
- *
- * Nothing in this file is intended to be modified or adjusted by the
- * curl library user nor by the curl library builder.
- *
- * Do not deactivate any check, these are done to make sure that the
- * library is properly built and used.
- *
- * You can find further help on the libcurl development mailing list:
- * https://cool.haxx.se/mailman/listinfo/curl-library/
- *
- * NOTE 2
- * ------
- *
- * Some of the following compile time checks are based on the fact
- * that the dimension of a constant array can not be a negative one.
- * In this way if the compile time verification fails, the compilation
- * will fail issuing an error. The error description wording is compiler
- * dependent but it will be quite similar to one of the following:
- *
- * "negative subscript or subscript is too large"
- * "array must have at least one element"
- * "-1 is an illegal array size"
- * "size of array is negative"
- *
- * If you are building an application which tries to use an already
- * built libcurl library and you are getting this kind of errors on
- * this file, it is a clear indication that there is a mismatch between
- * how the library was built and how you are trying to use it for your
- * application. Your already compiled or binary library provider is the
- * only one who can give you the details you need to properly use it.
- */
-
-/*
- * Verify that some macros are actually defined.
- */
-
-#ifndef CURL_SIZEOF_LONG
-# error "CURL_SIZEOF_LONG definition is missing!"
- Error Compilation_aborted_CURL_SIZEOF_LONG_is_missing
-#endif
-
-#ifndef CURL_TYPEOF_CURL_SOCKLEN_T
-# error "CURL_TYPEOF_CURL_SOCKLEN_T definition is missing!"
- Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_is_missing
-#endif
-
-#ifndef CURL_SIZEOF_CURL_SOCKLEN_T
-# error "CURL_SIZEOF_CURL_SOCKLEN_T definition is missing!"
- Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_is_missing
-#endif
-
-#ifndef CURL_TYPEOF_CURL_OFF_T
-# error "CURL_TYPEOF_CURL_OFF_T definition is missing!"
- Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_is_missing
-#endif
-
-#ifndef CURL_FORMAT_CURL_OFF_T
-# error "CURL_FORMAT_CURL_OFF_T definition is missing!"
- Error Compilation_aborted_CURL_FORMAT_CURL_OFF_T_is_missing
-#endif
-
-#ifndef CURL_FORMAT_CURL_OFF_TU
-# error "CURL_FORMAT_CURL_OFF_TU definition is missing!"
- Error Compilation_aborted_CURL_FORMAT_CURL_OFF_TU_is_missing
-#endif
-
-#ifndef CURL_SIZEOF_CURL_OFF_T
-# error "CURL_SIZEOF_CURL_OFF_T definition is missing!"
- Error Compilation_aborted_CURL_SIZEOF_CURL_OFF_T_is_missing
-#endif
-
-#ifndef CURL_SUFFIX_CURL_OFF_T
-# error "CURL_SUFFIX_CURL_OFF_T definition is missing!"
- Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_T_is_missing
-#endif
-
-#ifndef CURL_SUFFIX_CURL_OFF_TU
-# error "CURL_SUFFIX_CURL_OFF_TU definition is missing!"
- Error Compilation_aborted_CURL_SUFFIX_CURL_OFF_TU_is_missing
-#endif
-
-/*
- * Macros private to this header file.
- */
-
-#define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1
-
-#define CurlchkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1
-
-/*
- * Verify that the size previously defined and expected for long
- * is the same as the one reported by sizeof() at compile time.
- */
-
-typedef char
- __curl_rule_01__
- [CurlchkszEQ(long, CURL_SIZEOF_LONG)];
-
-/*
- * Verify that the size previously defined and expected for
- * curl_off_t is actually the the same as the one reported
- * by sizeof() at compile time.
- */
-
-typedef char
- __curl_rule_02__
- [CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)];
-
-/*
- * Verify at compile time that the size of curl_off_t as reported
- * by sizeof() is greater or equal than the one reported for long
- * for the current compilation.
- */
-
-typedef char
- __curl_rule_03__
- [CurlchkszGE(curl_off_t, long)];
-
-/*
- * Verify that the size previously defined and expected for
- * curl_socklen_t is actually the the same as the one reported
- * by sizeof() at compile time.
- */
-
-typedef char
- __curl_rule_04__
- [CurlchkszEQ(curl_socklen_t, CURL_SIZEOF_CURL_SOCKLEN_T)];
-
-/*
- * Verify at compile time that the size of curl_socklen_t as reported
- * by sizeof() is greater or equal than the one reported for int for
- * the current compilation.
- */
-
-typedef char
- __curl_rule_05__
- [CurlchkszGE(curl_socklen_t, int)];
-
-/* ================================================================ */
-/* EXTERNALLY AND INTERNALLY VISIBLE DEFINITIONS */
-/* ================================================================ */
-
-/*
- * CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
- * these to be visible and exported by the external libcurl interface API,
- * while also making them visible to the library internals, simply including
- * curl_setup.h, without actually needing to include curl.h internally.
- * If some day this section would grow big enough, all this should be moved
- * to its own header file.
- */
-
-/*
- * Figure out if we can use the ## preprocessor operator, which is supported
- * by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
- * or __cplusplus so we need to carefully check for them too.
- */
-
-#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
- defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
- defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
- defined(__ILEC400__)
- /* This compiler is believed to have an ISO compatible preprocessor */
-#define CURL_ISOCPP
-#else
- /* This compiler is believed NOT to have an ISO compatible preprocessor */
-#undef CURL_ISOCPP
-#endif
-
-/*
- * Macros for minimum-width signed and unsigned curl_off_t integer constants.
- */
-
-#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
-# define __CURL_OFF_T_C_HLPR2(x) x
-# define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x)
-# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
- __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
-# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
- __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
-#else
-# ifdef CURL_ISOCPP
-# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
-# else
-# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
-# endif
-# define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix)
-# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
-# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
-#endif
-
-/*
- * Get rid of macros private to this header file.
- */
-
-#undef CurlchkszEQ
-#undef CurlchkszGE
-
-#endif /* __CURL_CURLRULES_H */
diff --git a/Utilities/cmcurl/include/curl/curlver.h b/Utilities/cmcurl/include/curl/curlver.h
index 667b7eb13..04efb93ae 100644
--- a/Utilities/cmcurl/include/curl/curlver.h
+++ b/Utilities/cmcurl/include/curl/curlver.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -26,17 +26,17 @@
a script at release-time. This was made its own header file in 7.11.2 */
/* This is the global package copyright */
-#define LIBCURL_COPYRIGHT "1996 - 2017 Daniel Stenberg, <daniel@haxx.se>."
+#define LIBCURL_COPYRIGHT "1996 - 2019 Daniel Stenberg, <daniel@haxx.se>."
/* This is the version number of the libcurl package from which this header
file origins: */
-#define LIBCURL_VERSION "7.54.1"
+#define LIBCURL_VERSION "7.65.0"
/* The numeric version number is also available "in parts" by using these
defines: */
#define LIBCURL_VERSION_MAJOR 7
-#define LIBCURL_VERSION_MINOR 54
-#define LIBCURL_VERSION_PATCH 1
+#define LIBCURL_VERSION_MINOR 65
+#define LIBCURL_VERSION_PATCH 0
/* This is the numeric version of the libcurl version number, meant for easier
parsing and comparions by programs. The LIBCURL_VERSION_NUM define will
@@ -57,7 +57,7 @@
CURL_VERSION_BITS() macro since curl's own configure script greps for it
and needs it to contain the full number.
*/
-#define LIBCURL_VERSION_NUM 0x073601
+#define LIBCURL_VERSION_NUM 0x074100
/*
* This is the date and time when the full source package was created. The
@@ -70,7 +70,7 @@
*/
#define LIBCURL_TIMESTAMP "[unreleased]"
-#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|z)
+#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z))
#define CURL_AT_LEAST_VERSION(x,y,z) \
(LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
diff --git a/Utilities/cmcurl/include/curl/easy.h b/Utilities/cmcurl/include/curl/easy.h
index 752c5049f..f42a8a969 100644
--- a/Utilities/cmcurl/include/curl/easy.h
+++ b/Utilities/cmcurl/include/curl/easy.h
@@ -95,6 +95,16 @@ CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
size_t buflen, size_t *n);
+
+/*
+ * NAME curl_easy_upkeep()
+ *
+ * DESCRIPTION
+ *
+ * Performs connection upkeep for the given session handle.
+ */
+CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl);
+
#ifdef __cplusplus
}
#endif
diff --git a/Utilities/cmcurl/include/curl/multi.h b/Utilities/cmcurl/include/curl/multi.h
index f93e511be..b19dbaf79 100644
--- a/Utilities/cmcurl/include/curl/multi.h
+++ b/Utilities/cmcurl/include/curl/multi.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -70,6 +70,8 @@ typedef enum {
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
attempted to get added - again */
+ CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
+ callback */
CURLM_LAST
} CURLMcode;
@@ -184,8 +186,8 @@ CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
*
* Returns: CURLMcode type, general multi error code. *NOTE* that this only
* returns errors etc regarding the whole multi stack. There might
- * still have occurred problems on invidual transfers even when this
- * returns OK.
+ * still have occurred problems on individual transfers even when
+ * this returns OK.
*/
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
int *running_handles);
diff --git a/Utilities/cmcurl/include/curl/system.h b/Utilities/cmcurl/include/curl/system.h
index ed3a55c95..1e555ec19 100644
--- a/Utilities/cmcurl/include/curl/system.h
+++ b/Utilities/cmcurl/include/curl/system.h
@@ -23,14 +23,6 @@
***************************************************************************/
/*
- * This header is supposed to eventually replace curlbuild.h. This little one
- * is still learning. During the experimental phase, this header files
- * defines symbols using the prefixes CURLSYS_ or curlsys_. When we feel
- * confident enough, we replace curlbuild.h with this file and rename all
- * prefixes to CURL_ and curl_.
- */
-
-/*
* Try to keep one section per platform, compiler and architecture, otherwise,
* if an existing section is reused for a different one and later on the
* original is adjusted, probably the piggybacking one can be adversely
@@ -60,323 +52,291 @@
#if defined(__DJGPP__) || defined(__GO32__)
# if defined(__DJGPP__) && (__DJGPP__ > 1)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long long
-# define CURLSYS_FORMAT_CURL_OFF_T "lld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "llu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T LL
-# define CURLSYS_SUFFIX_CURL_OFF_TU ULL
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
# else
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 4
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__SALFORDC__)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 4
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__BORLANDC__)
# if (__BORLANDC__ < 0x520)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 4
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
# else
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T __int64
-# define CURLSYS_FORMAT_CURL_OFF_T "I64d"
-# define CURLSYS_FORMAT_CURL_OFF_TU "I64u"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T i64
-# define CURLSYS_SUFFIX_CURL_OFF_TU ui64
+# define CURL_TYPEOF_CURL_OFF_T __int64
+# define CURL_FORMAT_CURL_OFF_T "I64d"
+# define CURL_FORMAT_CURL_OFF_TU "I64u"
+# define CURL_SUFFIX_CURL_OFF_T i64
+# define CURL_SUFFIX_CURL_OFF_TU ui64
# endif
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__TURBOC__)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 4
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__WATCOMC__)
# if defined(__386__)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T __int64
-# define CURLSYS_FORMAT_CURL_OFF_T "I64d"
-# define CURLSYS_FORMAT_CURL_OFF_TU "I64u"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T i64
-# define CURLSYS_SUFFIX_CURL_OFF_TU ui64
+# define CURL_TYPEOF_CURL_OFF_T __int64
+# define CURL_FORMAT_CURL_OFF_T "I64d"
+# define CURL_FORMAT_CURL_OFF_TU "I64u"
+# define CURL_SUFFIX_CURL_OFF_T i64
+# define CURL_SUFFIX_CURL_OFF_TU ui64
# else
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 4
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__POCC__)
# if (__POCC__ < 280)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 4
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
# elif defined(_MSC_VER)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T __int64
-# define CURLSYS_FORMAT_CURL_OFF_T "I64d"
-# define CURLSYS_FORMAT_CURL_OFF_TU "I64u"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T i64
-# define CURLSYS_SUFFIX_CURL_OFF_TU ui64
+# define CURL_TYPEOF_CURL_OFF_T __int64
+# define CURL_FORMAT_CURL_OFF_T "I64d"
+# define CURL_FORMAT_CURL_OFF_TU "I64u"
+# define CURL_SUFFIX_CURL_OFF_T i64
+# define CURL_SUFFIX_CURL_OFF_TU ui64
# else
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long long
-# define CURLSYS_FORMAT_CURL_OFF_T "lld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "llu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T LL
-# define CURLSYS_SUFFIX_CURL_OFF_TU ULL
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
# endif
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__LCC__)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 4
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__SYMBIAN32__)
# if defined(__EABI__) /* Treat all ARM compilers equally */
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long long
-# define CURLSYS_FORMAT_CURL_OFF_T "lld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "llu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T LL
-# define CURLSYS_SUFFIX_CURL_OFF_TU ULL
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__CW32__)
# pragma longlong on
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long long
-# define CURLSYS_FORMAT_CURL_OFF_T "lld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "llu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T LL
-# define CURLSYS_SUFFIX_CURL_OFF_TU ULL
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__VC32__)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T __int64
-# define CURLSYS_FORMAT_CURL_OFF_T "lld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "llu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T LL
-# define CURLSYS_SUFFIX_CURL_OFF_TU ULL
+# define CURL_TYPEOF_CURL_OFF_T __int64
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
# endif
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T unsigned int
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
+# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
#elif defined(__MWERKS__)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long long
-# define CURLSYS_FORMAT_CURL_OFF_T "lld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "llu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T LL
-# define CURLSYS_SUFFIX_CURL_OFF_TU ULL
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(_WIN32_WCE)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T __int64
-# define CURLSYS_FORMAT_CURL_OFF_T "I64d"
-# define CURLSYS_FORMAT_CURL_OFF_TU "I64u"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T i64
-# define CURLSYS_SUFFIX_CURL_OFF_TU ui64
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
+# define CURL_TYPEOF_CURL_OFF_T __int64
+# define CURL_FORMAT_CURL_OFF_T "I64d"
+# define CURL_FORMAT_CURL_OFF_TU "I64u"
+# define CURL_SUFFIX_CURL_OFF_T i64
+# define CURL_SUFFIX_CURL_OFF_TU ui64
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__MINGW32__)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long long
-# define CURLSYS_FORMAT_CURL_OFF_T "I64d"
-# define CURLSYS_FORMAT_CURL_OFF_TU "I64u"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T LL
-# define CURLSYS_SUFFIX_CURL_OFF_TU ULL
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T socklen_t
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
-# define CURLSYS_PULL_SYS_TYPES_H 1
-# define CURLSYS_PULL_WS2TCPIP_H 1
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "I64d"
+# define CURL_FORMAT_CURL_OFF_TU "I64u"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
+# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
+# define CURL_PULL_SYS_TYPES_H 1
+# define CURL_PULL_WS2TCPIP_H 1
#elif defined(__VMS)
# if defined(__VAX)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 4
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
# else
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long long
-# define CURLSYS_FORMAT_CURL_OFF_T "lld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "llu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T LL
-# define CURLSYS_SUFFIX_CURL_OFF_TU ULL
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
# endif
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T unsigned int
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
+# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
#elif defined(__OS400__)
# if defined(__ILEC400__)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long long
-# define CURLSYS_FORMAT_CURL_OFF_T "lld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "llu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T LL
-# define CURLSYS_SUFFIX_CURL_OFF_TU ULL
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T socklen_t
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
-# define CURLSYS_PULL_SYS_TYPES_H 1
-# define CURLSYS_PULL_SYS_SOCKET_H 1
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
+# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
+# define CURL_PULL_SYS_TYPES_H 1
+# define CURL_PULL_SYS_SOCKET_H 1
# endif
#elif defined(__MVS__)
# if defined(__IBMC__) || defined(__IBMCPP__)
# if defined(_ILP32)
-# define CURLSYS_SIZEOF_LONG 4
# elif defined(_LP64)
-# define CURLSYS_SIZEOF_LONG 8
# endif
# if defined(_LONG_LONG)
-# define CURLSYS_TYPEOF_CURL_OFF_T long long
-# define CURLSYS_FORMAT_CURL_OFF_T "lld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "llu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T LL
-# define CURLSYS_SUFFIX_CURL_OFF_TU ULL
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(_LP64)
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
# else
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 4
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T socklen_t
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
-# define CURLSYS_PULL_SYS_TYPES_H 1
-# define CURLSYS_PULL_SYS_SOCKET_H 1
+# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
+# define CURL_PULL_SYS_TYPES_H 1
+# define CURL_PULL_SYS_SOCKET_H 1
# endif
#elif defined(__370__)
# if defined(__IBMC__) || defined(__IBMCPP__)
# if defined(_ILP32)
-# define CURLSYS_SIZEOF_LONG 4
# elif defined(_LP64)
-# define CURLSYS_SIZEOF_LONG 8
# endif
# if defined(_LONG_LONG)
-# define CURLSYS_TYPEOF_CURL_OFF_T long long
-# define CURLSYS_FORMAT_CURL_OFF_T "lld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "llu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T LL
-# define CURLSYS_SUFFIX_CURL_OFF_TU ULL
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(_LP64)
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
# else
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 4
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T socklen_t
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
-# define CURLSYS_PULL_SYS_TYPES_H 1
-# define CURLSYS_PULL_SYS_SOCKET_H 1
+# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
+# define CURL_PULL_SYS_TYPES_H 1
+# define CURL_PULL_SYS_SOCKET_H 1
# endif
#elif defined(TPF)
-# define CURLSYS_SIZEOF_LONG 8
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
#elif defined(__TINYC__) /* also known as tcc */
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long long
-# define CURLSYS_FORMAT_CURL_OFF_T "lld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "llu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T LL
-# define CURLSYS_SUFFIX_CURL_OFF_TU ULL
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T socklen_t
-# define CURLSYS_PULL_SYS_TYPES_H 1
-# define CURLSYS_PULL_SYS_SOCKET_H 1
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
+# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
+# define CURL_PULL_SYS_TYPES_H 1
+# define CURL_PULL_SYS_SOCKET_H 1
+
+#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */
+# if !defined(__LP64) && (defined(__ILP32) || \
+ defined(__i386) || \
+ defined(__sparcv8) || \
+ defined(__sparcv8plus))
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
+# elif defined(__LP64) || \
+ defined(__amd64) || defined(__sparcv9)
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
+# endif
+# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
+# define CURL_PULL_SYS_TYPES_H 1
+# define CURL_PULL_SYS_SOCKET_H 1
+
+#elif defined(__xlc__) /* IBM xlc compiler */
+# if !defined(_LP64)
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
+# else
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
+# endif
+# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
+# define CURL_PULL_SYS_TYPES_H 1
+# define CURL_PULL_SYS_SOCKET_H 1
/* ===================================== */
/* KEEP MSVC THE PENULTIMATE ENTRY */
@@ -384,101 +344,150 @@
#elif defined(_MSC_VER)
# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T __int64
-# define CURLSYS_FORMAT_CURL_OFF_T "I64d"
-# define CURLSYS_FORMAT_CURL_OFF_TU "I64u"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T i64
-# define CURLSYS_SUFFIX_CURL_OFF_TU ui64
+# define CURL_TYPEOF_CURL_OFF_T __int64
+# define CURL_FORMAT_CURL_OFF_T "I64d"
+# define CURL_FORMAT_CURL_OFF_TU "I64u"
+# define CURL_SUFFIX_CURL_OFF_T i64
+# define CURL_SUFFIX_CURL_OFF_TU ui64
# else
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 4
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
/* ===================================== */
/* KEEP GENERIC GCC THE LAST ENTRY */
/* ===================================== */
-#elif defined(__GNUC__)
-# if !defined(__LP64__) && (defined(__ILP32__) || \
- defined(__i386__) || defined(__ppc__) || defined(__arm__) || \
- defined(__sparc__) || defined(__mips__) || defined(__sh__))
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long long
-# define CURLSYS_FORMAT_CURL_OFF_T "lld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "llu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T LL
-# define CURLSYS_SUFFIX_CURL_OFF_TU ULL
+#elif defined(__GNUC__) && !defined(_SCO_DS)
+# if !defined(__LP64__) && \
+ (defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \
+ defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \
+ defined(__sparc__) || defined(__mips__) || defined(__sh__) || \
+ defined(__XTENSA__) || \
+ (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
+ (defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L))
+# define CURL_TYPEOF_CURL_OFF_T long long
+# define CURL_FORMAT_CURL_OFF_T "lld"
+# define CURL_FORMAT_CURL_OFF_TU "llu"
+# define CURL_SUFFIX_CURL_OFF_T LL
+# define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__LP64__) || \
- defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__)
-# define CURLSYS_SIZEOF_LONG 8
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SIZEOF_CURL_OFF_T 8
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
+ defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
+ (defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \
+ (defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L)
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
# endif
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T socklen_t
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
-# define CURLSYS_PULL_SYS_TYPES_H 1
-# define CURLSYS_PULL_SYS_SOCKET_H 1
+# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
+# define CURL_PULL_SYS_TYPES_H 1
+# define CURL_PULL_SYS_SOCKET_H 1
#else
/* generic "safe guess" on old 32 bit style */
-# define CURLSYS_SIZEOF_LONG 4
-# define CURLSYS_SIZEOF_CURL_SOCKLEN_T 4
-# define CURLSYS_SIZEOF_CURL_OFF_T 4
-# define CURLSYS_TYPEOF_CURL_OFF_T long
-# define CURLSYS_FORMAT_CURL_OFF_T "ld"
-# define CURLSYS_FORMAT_CURL_OFF_TU "lu"
-# define CURLSYS_SUFFIX_CURL_OFF_T L
-# define CURLSYS_SUFFIX_CURL_OFF_TU UL
-# define CURLSYS_TYPEOF_CURL_SOCKLEN_T int
+# define CURL_TYPEOF_CURL_OFF_T long
+# define CURL_FORMAT_CURL_OFF_T "ld"
+# define CURL_FORMAT_CURL_OFF_TU "lu"
+# define CURL_SUFFIX_CURL_OFF_T L
+# define CURL_SUFFIX_CURL_OFF_TU UL
+# define CURL_TYPEOF_CURL_SOCKLEN_T int
+#endif
+
+#ifdef _AIX
+/* AIX needs <sys/poll.h> */
+#define CURL_PULL_SYS_POLL_H
#endif
-/* CURLSYS_PULL_WS2TCPIP_H is defined above when inclusion of header file */
+
+/* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */
/* ws2tcpip.h is required here to properly make type definitions below. */
-#ifdef CURLSYS_PULL_WS2TCPIP_H
-# ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-# endif
-# include <windows.h>
+#ifdef CURL_PULL_WS2TCPIP_H
# include <winsock2.h>
+# include <windows.h>
# include <ws2tcpip.h>
#endif
-/* CURLSYS_PULL_SYS_TYPES_H is defined above when inclusion of header file */
+/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
/* sys/types.h is required here to properly make type definitions below. */
-#ifdef CURLSYS_PULL_SYS_TYPES_H
+#ifdef CURL_PULL_SYS_TYPES_H
# include <sys/types.h>
#endif
-/* CURLSYS_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
+/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
/* sys/socket.h is required here to properly make type definitions below. */
-#ifdef CURLSYS_PULL_SYS_SOCKET_H
+#ifdef CURL_PULL_SYS_SOCKET_H
# include <sys/socket.h>
#endif
+/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */
+/* sys/poll.h is required here to properly make type definitions below. */
+#ifdef CURL_PULL_SYS_POLL_H
+# include <sys/poll.h>
+#endif
+
/* Data type definition of curl_socklen_t. */
-#ifdef CURLSYS_TYPEOF_CURL_SOCKLEN_T
- typedef CURLSYS_TYPEOF_CURL_SOCKLEN_T curlsys_socklen_t;
+#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
+ typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
#endif
/* Data type definition of curl_off_t. */
-#ifdef CURLSYS_TYPEOF_CURL_OFF_T
- typedef CURLSYS_TYPEOF_CURL_OFF_T curlsys_off_t;
+#ifdef CURL_TYPEOF_CURL_OFF_T
+ typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
#endif
-#endif /* __CURL_SYSTEM_H */
+/*
+ * CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
+ * these to be visible and exported by the external libcurl interface API,
+ * while also making them visible to the library internals, simply including
+ * curl_setup.h, without actually needing to include curl.h internally.
+ * If some day this section would grow big enough, all this should be moved
+ * to its own header file.
+ */
+
+/*
+ * Figure out if we can use the ## preprocessor operator, which is supported
+ * by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
+ * or __cplusplus so we need to carefully check for them too.
+ */
+
+#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
+ defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
+ defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
+ defined(__ILEC400__)
+ /* This compiler is believed to have an ISO compatible preprocessor */
+#define CURL_ISOCPP
+#else
+ /* This compiler is believed NOT to have an ISO compatible preprocessor */
+#undef CURL_ISOCPP
+#endif
+
+/*
+ * Macros for minimum-width signed and unsigned curl_off_t integer constants.
+ */
+
+#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
+# define __CURL_OFF_T_C_HLPR2(x) x
+# define __CURL_OFF_T_C_HLPR1(x) __CURL_OFF_T_C_HLPR2(x)
+# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
+ __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
+# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val) ## \
+ __CURL_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
+#else
+# ifdef CURL_ISOCPP
+# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
+# else
+# define __CURL_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
+# endif
+# define __CURL_OFF_T_C_HLPR1(Val,Suffix) __CURL_OFF_T_C_HLPR2(Val,Suffix)
+# define CURL_OFF_T_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
+# define CURL_OFF_TU_C(Val) __CURL_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
+#endif
+#endif /* __CURL_SYSTEM_H */
diff --git a/Utilities/cmcurl/include/curl/typecheck-gcc.h b/Utilities/cmcurl/include/curl/typecheck-gcc.h
index 10b5de2ab..2d1de4d43 100644
--- a/Utilities/cmcurl/include/curl/typecheck-gcc.h
+++ b/Utilities/cmcurl/include/curl/typecheck-gcc.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -54,6 +54,9 @@ __extension__ ({ \
if(_curl_is_write_cb_option(_curl_opt)) \
if(!_curl_is_write_cb(value)) \
_curl_easy_setopt_err_write_callback(); \
+ if((_curl_opt) == CURLOPT_RESOLVER_START_FUNCTION) \
+ if(!_curl_is_resolver_start_callback(value)) \
+ _curl_easy_setopt_err_resolver_start_callback(); \
if((_curl_opt) == CURLOPT_READFUNCTION) \
if(!_curl_is_read_cb(value)) \
_curl_easy_setopt_err_read_cb(); \
@@ -96,6 +99,9 @@ __extension__ ({ \
if((_curl_opt) == CURLOPT_HTTPPOST) \
if(!_curl_is_arr((value), struct curl_httppost)) \
_curl_easy_setopt_err_curl_httpost(); \
+ if((_curl_opt) == CURLOPT_MIMEPOST) \
+ if(!_curl_is_ptr((value), curl_mime)) \
+ _curl_easy_setopt_err_curl_mimepost(); \
if(_curl_is_slist_option(_curl_opt)) \
if(!_curl_is_arr((value), struct curl_slist)) \
_curl_easy_setopt_err_curl_slist(); \
@@ -107,10 +113,9 @@ __extension__ ({ \
})
/* wraps curl_easy_getinfo() with typechecking */
-/* FIXME: don't allow const pointers */
#define curl_easy_getinfo(handle, info, arg) \
__extension__ ({ \
- __typeof__(info) _curl_info = info; \
+ __typeof__(info) _curl_info = info; \
if(__builtin_constant_p(_curl_info)) { \
if(_curl_is_string_info(_curl_info)) \
if(!_curl_is_arr((arg), char *)) \
@@ -130,16 +135,18 @@ __extension__ ({ \
if(_curl_is_certinfo_info(_curl_info)) \
if(!_curl_is_arr((arg), struct curl_certinfo *)) \
_curl_easy_getinfo_err_curl_certinfo(); \
- if(_curl_is_socket_info(_curl_info)) \
+ if(_curl_is_socket_info(_curl_info)) \
if(!_curl_is_arr((arg), curl_socket_t)) \
_curl_easy_getinfo_err_curl_socket(); \
+ if(_curl_is_off_t_info(_curl_info)) \
+ if(!_curl_is_arr((arg), curl_off_t)) \
+ _curl_easy_getinfo_err_curl_off_t(); \
} \
curl_easy_getinfo(handle, _curl_info, arg); \
})
-/* TODO: typechecking for curl_share_setopt() and curl_multi_setopt(),
- * for now just make sure that the functions are called with three
- * arguments
+/*
+ * For now, just make sure that the functions are called with three arguments
*/
#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
@@ -164,6 +171,10 @@ _CURL_WARNING(_curl_easy_setopt_err_string,
)
_CURL_WARNING(_curl_easy_setopt_err_write_callback,
"curl_easy_setopt expects a curl_write_callback argument for this option")
+_CURL_WARNING(_curl_easy_setopt_err_resolver_start_callback,
+ "curl_easy_setopt expects a "
+ "curl_resolver_start_callback argument for this option"
+ )
_CURL_WARNING(_curl_easy_setopt_err_read_cb,
"curl_easy_setopt expects a curl_read_callback argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_ioctl_cb,
@@ -197,6 +208,9 @@ _CURL_WARNING(_curl_easy_setopt_err_postfields,
_CURL_WARNING(_curl_easy_setopt_err_curl_httpost,
"curl_easy_setopt expects a 'struct curl_httppost *' "
"argument for this option")
+_CURL_WARNING(_curl_easy_setopt_err_curl_mimepost,
+ "curl_easy_setopt expects a 'curl_mime *' "
+ "argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_curl_slist,
"curl_easy_setopt expects a 'struct curl_slist *' argument for this option")
_CURL_WARNING(_curl_easy_setopt_err_CURLSH,
@@ -218,6 +232,8 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_certinfo,
"'struct curl_certinfo *' for this info")
_CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
"curl_easy_getinfo expects a pointer to curl_socket_t for this info")
+_CURL_WARNING(_curl_easy_getinfo_err_curl_off_t,
+ "curl_easy_getinfo expects a pointer to curl_off_t for this info")
/* groups of curl_easy_setops options that take the same type of argument */
@@ -238,6 +254,7 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
#define _curl_is_string_option(option) \
((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \
(option) == CURLOPT_ACCEPT_ENCODING || \
+ (option) == CURLOPT_ALTSVC || \
(option) == CURLOPT_CAINFO || \
(option) == CURLOPT_CAPATH || \
(option) == CURLOPT_COOKIE || \
@@ -251,6 +268,7 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
(option) == CURLOPT_DNS_LOCAL_IP4 || \
(option) == CURLOPT_DNS_LOCAL_IP6 || \
(option) == CURLOPT_DNS_SERVERS || \
+ (option) == CURLOPT_DOH_URL || \
(option) == CURLOPT_EGDSOCKET || \
(option) == CURLOPT_FTPPORT || \
(option) == CURLOPT_FTP_ACCOUNT || \
@@ -343,6 +361,8 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
(option) == CURLOPT_SSH_KEYDATA || \
(option) == CURLOPT_SSL_CTX_DATA || \
(option) == CURLOPT_WRITEDATA || \
+ (option) == CURLOPT_RESOLVER_START_DATA || \
+ (option) == CURLOPT_CURLU || \
0)
/* evaluates to true if option takes a POST data argument (void* or char*) */
@@ -391,7 +411,11 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
/* true if info expects a pointer to struct curl_socket_t argument */
#define _curl_is_socket_info(info) \
- (CURLINFO_SOCKET < (info))
+ (CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T)
+
+/* true if info expects a pointer to curl_off_t argument */
+#define _curl_is_off_t_info(info) \
+ (CURLINFO_OFF_T < (info))
/* typecheck helpers -- check whether given expression has requested type*/
@@ -405,7 +429,7 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
* == or whatsoever.
*/
-/* XXX: should evaluate to true iff expr is a pointer */
+/* XXX: should evaluate to true if expr is a pointer */
#define _curl_is_any_ptr(expr) \
(sizeof(expr) == sizeof(void *))
@@ -477,18 +501,20 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
/* evaluates to true if expr can be passed as POST data (void* or char*) */
#define _curl_is_postfields(expr) \
(_curl_is_ptr((expr), void) || \
- _curl_is_arr((expr), char))
+ _curl_is_arr((expr), char) || \
+ _curl_is_arr((expr), unsigned char))
-/* FIXME: the whole callback checking is messy...
- * The idea is to tolerate char vs. void and const vs. not const
- * pointers in arguments at least
- */
/* helper: __builtin_types_compatible_p distinguishes between functions and
* function pointers, hide it */
#define _curl_callback_compatible(func, type) \
(__builtin_types_compatible_p(__typeof__(func), type) || \
__builtin_types_compatible_p(__typeof__(func) *, type))
+/* evaluates to true if expr is of type curl_resolver_start_callback */
+#define _curl_is_resolver_start_callback(expr) \
+ (_curl_is_NULL(expr) || \
+ _curl_callback_compatible((expr), curl_resolver_start_callback))
+
/* evaluates to true if expr is of type curl_read_callback or "similar" */
#define _curl_is_read_cb(expr) \
(_curl_is_NULL(expr) || \
diff --git a/Utilities/cmcurl/include/curl/urlapi.h b/Utilities/cmcurl/include/curl/urlapi.h
new file mode 100644
index 000000000..58e89d85c
--- /dev/null
+++ b/Utilities/cmcurl/include/curl/urlapi.h
@@ -0,0 +1,123 @@
+#ifndef __CURL_URLAPI_H
+#define __CURL_URLAPI_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2018 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* the error codes for the URL API */
+typedef enum {
+ CURLUE_OK,
+ CURLUE_BAD_HANDLE, /* 1 */
+ CURLUE_BAD_PARTPOINTER, /* 2 */
+ CURLUE_MALFORMED_INPUT, /* 3 */
+ CURLUE_BAD_PORT_NUMBER, /* 4 */
+ CURLUE_UNSUPPORTED_SCHEME, /* 5 */
+ CURLUE_URLDECODE, /* 6 */
+ CURLUE_OUT_OF_MEMORY, /* 7 */
+ CURLUE_USER_NOT_ALLOWED, /* 8 */
+ CURLUE_UNKNOWN_PART, /* 9 */
+ CURLUE_NO_SCHEME, /* 10 */
+ CURLUE_NO_USER, /* 11 */
+ CURLUE_NO_PASSWORD, /* 12 */
+ CURLUE_NO_OPTIONS, /* 13 */
+ CURLUE_NO_HOST, /* 14 */
+ CURLUE_NO_PORT, /* 15 */
+ CURLUE_NO_QUERY, /* 16 */
+ CURLUE_NO_FRAGMENT /* 17 */
+} CURLUcode;
+
+typedef enum {
+ CURLUPART_URL,
+ CURLUPART_SCHEME,
+ CURLUPART_USER,
+ CURLUPART_PASSWORD,
+ CURLUPART_OPTIONS,
+ CURLUPART_HOST,
+ CURLUPART_PORT,
+ CURLUPART_PATH,
+ CURLUPART_QUERY,
+ CURLUPART_FRAGMENT,
+ CURLUPART_ZONEID /* added in 7.65.0 */
+} CURLUPart;
+
+#define CURLU_DEFAULT_PORT (1<<0) /* return default port number */
+#define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set,
+ if the port number matches the
+ default for the scheme */
+#define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if
+ missing */
+#define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */
+#define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */
+#define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */
+#define CURLU_URLDECODE (1<<6) /* URL decode on get */
+#define CURLU_URLENCODE (1<<7) /* URL encode on set */
+#define CURLU_APPENDQUERY (1<<8) /* append a form style part */
+#define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */
+
+typedef struct Curl_URL CURLU;
+
+/*
+ * curl_url() creates a new CURLU handle and returns a pointer to it.
+ * Must be freed with curl_url_cleanup().
+ */
+CURL_EXTERN CURLU *curl_url(void);
+
+/*
+ * curl_url_cleanup() frees the CURLU handle and related resources used for
+ * the URL parsing. It will not free strings previously returned with the URL
+ * API.
+ */
+CURL_EXTERN void curl_url_cleanup(CURLU *handle);
+
+/*
+ * curl_url_dup() duplicates a CURLU handle and returns a new copy. The new
+ * handle must also be freed with curl_url_cleanup().
+ */
+CURL_EXTERN CURLU *curl_url_dup(CURLU *in);
+
+/*
+ * curl_url_get() extracts a specific part of the URL from a CURLU
+ * handle. Returns error code. The returned pointer MUST be freed with
+ * curl_free() afterwards.
+ */
+CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what,
+ char **part, unsigned int flags);
+
+/*
+ * curl_url_set() sets a specific part of the URL in a CURLU handle. Returns
+ * error code. The passed in string will be copied. Passing a NULL instead of
+ * a part string, clears that part.
+ */
+CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
+ const char *part, unsigned int flags);
+
+
+#ifdef __cplusplus
+} /* end of extern "C" */
+#endif
+
+#endif
diff --git a/Utilities/cmcurl/lib/CMakeLists.txt b/Utilities/cmcurl/lib/CMakeLists.txt
index 76dd6c63c..2a6279c29 100644
--- a/Utilities/cmcurl/lib/CMakeLists.txt
+++ b/Utilities/cmcurl/lib/CMakeLists.txt
@@ -1,7 +1,13 @@
set(LIB_NAME cmcurl)
-configure_file(${CURL_SOURCE_DIR}/include/curl/curlbuild.h.cmake
- ${CURL_BINARY_DIR}/include/curl/curlbuild.h)
+if(BUILD_SHARED_LIBS)
+ set(CURL_STATICLIB NO)
+else()
+ set(CURL_STATICLIB YES)
+endif()
+
+# Use:
+# * CURL_STATICLIB
configure_file(curl_config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/curl_config.h)
@@ -10,11 +16,11 @@ include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
list(APPEND HHEADERS
${CMAKE_CURRENT_BINARY_DIR}/curl_config.h
- ${CURL_BINARY_DIR}/include/curl/curlbuild.h
)
if(MSVC AND NOT CURL_STATICLIB)
list(APPEND CSOURCES libcurl.rc)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127")
endif()
# SET(CSOURCES
@@ -61,14 +67,6 @@ if(USE_ARES)
include_directories(${CARES_INCLUDE_DIR})
endif()
-if(CURL_STATICLIB)
- # Static lib
- set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC STATIC)
-else()
- # DLL / so dynamic lib
- set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC SHARED)
-endif()
-
# For windows we want to install OPENSSL_LIBRARIES dlls
# and also copy them into the build tree so that testing
# can find them.
@@ -95,16 +93,19 @@ endif()
add_library(
${LIB_NAME}
- ${CURL_USER_DEFINED_DYNAMIC_OR_STATIC}
${HHEADERS} ${CSOURCES}
${CMAKE_CURL_SSL_DLLS}
)
+if(NOT BUILD_SHARED_LIBS)
+ set_target_properties(${LIB_NAME} PROPERTIES INTERFACE_COMPILE_DEFINITIONS CURL_STATICLIB)
+endif()
+
target_link_libraries(${LIB_NAME} ${CURL_LIBS})
if(0) # This code not needed for building within CMake.
if(WIN32)
- add_definitions( -D_USRDLL )
+ add_definitions(-D_USRDLL)
endif()
endif()
@@ -121,14 +122,26 @@ set_target_properties(${LIB_NAME} PROPERTIES PREFIX "")
set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "")
if(WIN32)
- if(NOT CURL_STATICLIB)
+ if(BUILD_SHARED_LIBS)
# Add "_imp" as a suffix before the extension to avoid conflicting with the statically linked "libcurl.lib"
set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib")
endif()
endif()
+target_include_directories(${LIB_NAME} INTERFACE
+ $<INSTALL_INTERFACE:include>
+ $<BUILD_INTERFACE:${CURL_SOURCE_DIR}/include>)
+
install(TARGETS ${LIB_NAME}
- ARCHIVE DESTINATION lib
- LIBRARY DESTINATION lib
- RUNTIME DESTINATION bin)
+ EXPORT ${TARGETS_EXPORT_NAME}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
+
+export(TARGETS ${LIB_NAME}
+ APPEND FILE ${PROJECT_BINARY_DIR}/libcurl-target.cmake
+ NAMESPACE CURL::
+)
+
endif()
diff --git a/Utilities/cmcurl/lib/Makefile.inc b/Utilities/cmcurl/lib/Makefile.inc
index 19f58000a..235b82b0e 100644
--- a/Utilities/cmcurl/lib/Makefile.inc
+++ b/Utilities/cmcurl/lib/Makefile.inc
@@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
-# Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
@@ -28,14 +28,14 @@ LIB_VAUTH_CFILES = vauth/vauth.c vauth/cleartext.c vauth/cram.c \
LIB_VAUTH_HFILES = vauth/vauth.h vauth/digest.h vauth/ntlm.h
LIB_VTLS_CFILES = vtls/openssl.c vtls/gtls.c vtls/vtls.c vtls/nss.c \
- vtls/polarssl.c vtls/polarssl_threadlock.c vtls/axtls.c \
- vtls/cyassl.c vtls/schannel.c vtls/darwinssl.c vtls/gskit.c \
- vtls/mbedtls.c
+ vtls/polarssl.c vtls/polarssl_threadlock.c \
+ vtls/cyassl.c vtls/schannel.c vtls/schannel_verify.c \
+ vtls/sectransp.c vtls/gskit.c vtls/mbedtls.c vtls/mesalink.c
LIB_VTLS_HFILES = vtls/openssl.h vtls/vtls.h vtls/gtls.h \
- vtls/nssg.h vtls/polarssl.h vtls/polarssl_threadlock.h vtls/axtls.h \
- vtls/cyassl.h vtls/schannel.h vtls/darwinssl.h vtls/gskit.h \
- vtls/mbedtls.h
+ vtls/nssg.h vtls/polarssl.h vtls/polarssl_threadlock.h \
+ vtls/cyassl.h vtls/schannel.h vtls/sectransp.h vtls/gskit.h \
+ vtls/mbedtls.h vtls/mesalink.h
LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \
cookie.c http.c sendf.c ftp.c url.c dict.c if2ip.c speedcheck.c \
@@ -46,14 +46,16 @@ LIB_CFILES = file.c timeval.c base64.c hostip.c progress.c formdata.c \
http_digest.c md4.c md5.c http_negotiate.c inet_pton.c strtoofft.c \
strerror.c amigaos.c hostasyn.c hostip4.c hostip6.c hostsyn.c \
inet_ntop.c parsedate.c select.c tftp.c splay.c strdup.c socks.c \
- ssh.c curl_addrinfo.c socks_gssapi.c socks_sspi.c \
+ ssh.c ssh-libssh.c curl_addrinfo.c socks_gssapi.c socks_sspi.c \
curl_sspi.c slist.c nonblock.c curl_memrchr.c imap.c pop3.c smtp.c \
pingpong.c rtsp.c curl_threads.c warnless.c hmac.c curl_rtmp.c \
openldap.c curl_gethostname.c gopher.c idn_win32.c \
http_proxy.c non-ascii.c asyn-ares.c asyn-thread.c curl_gssapi.c \
http_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_sasl.c rand.c \
- curl_multibyte.c hostcheck.c conncache.c pipeline.c dotdot.c \
- x509asn1.c http2.c smb.c curl_endian.c curl_des.c system_win32.c
+ curl_multibyte.c hostcheck.c conncache.c dotdot.c \
+ x509asn1.c http2.c smb.c curl_endian.c curl_des.c system_win32.c \
+ mime.c sha256.c setopt.c curl_path.c curl_ctype.c curl_range.c psl.c \
+ doh.c urlapi.c curl_get_line.c altsvc.c
LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \
formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h if2ip.h \
@@ -70,9 +72,11 @@ LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \
curl_gethostname.h gopher.h http_proxy.h non-ascii.h asyn.h \
http_ntlm.h curl_gssapi.h curl_ntlm_wb.h curl_ntlm_core.h \
curl_sasl.h curl_multibyte.h hostcheck.h conncache.h \
- curl_setup_once.h multihandle.h setup-vms.h pipeline.h dotdot.h \
+ curl_setup_once.h multihandle.h setup-vms.h dotdot.h \
x509asn1.h http2.h sigpipe.h smb.h curl_endian.h curl_des.h \
- curl_printf.h system_win32.h rand.h
+ curl_printf.h system_win32.h rand.h mime.h curl_sha256.h setopt.h \
+ curl_path.h curl_ctype.h curl_range.h psl.h doh.h urlapi-int.h \
+ curl_get_line.h altsvc.h
LIB_RCFILES = libcurl.rc
diff --git a/Utilities/cmcurl/lib/altsvc.c b/Utilities/cmcurl/lib/altsvc.c
new file mode 100644
index 000000000..85a4e01b5
--- /dev/null
+++ b/Utilities/cmcurl/lib/altsvc.c
@@ -0,0 +1,569 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+/*
+ * The Alt-Svc: header is defined in RFC 7838:
+ * https://tools.ietf.org/html/rfc7838
+ */
+#include "curl_setup.h"
+
+#if !defined(CURL_DISABLE_HTTP) && defined(USE_ALTSVC)
+#include <curl/curl.h>
+#include "urldata.h"
+#include "altsvc.h"
+#include "curl_get_line.h"
+#include "strcase.h"
+#include "parsedate.h"
+#include "sendf.h"
+#include "warnless.h"
+
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "memdebug.h"
+
+#define MAX_ALTSVC_LINE 4095
+#define MAX_ALTSVC_DATELENSTR "64"
+#define MAX_ALTSVC_DATELEN 64
+#define MAX_ALTSVC_HOSTLENSTR "512"
+#define MAX_ALTSVC_HOSTLEN 512
+#define MAX_ALTSVC_ALPNLENSTR "10"
+#define MAX_ALTSVC_ALPNLEN 10
+
+static enum alpnid alpn2alpnid(char *name)
+{
+ if(strcasecompare(name, "h1"))
+ return ALPN_h1;
+ if(strcasecompare(name, "h2"))
+ return ALPN_h2;
+ if(strcasecompare(name, "h2c"))
+ return ALPN_h2c;
+ if(strcasecompare(name, "h3"))
+ return ALPN_h3;
+ return ALPN_none; /* unknown, probably rubbish input */
+}
+
+/* Given the ALPN ID, return the name */
+const char *Curl_alpnid2str(enum alpnid id)
+{
+ switch(id) {
+ case ALPN_h1:
+ return "h1";
+ case ALPN_h2:
+ return "h2";
+ case ALPN_h2c:
+ return "h2c";
+ case ALPN_h3:
+ return "h3";
+ default:
+ return ""; /* bad */
+ }
+}
+
+
+static void altsvc_free(struct altsvc *as)
+{
+ free(as->srchost);
+ free(as->dsthost);
+ free(as);
+}
+
+static struct altsvc *altsvc_createid(const char *srchost,
+ const char *dsthost,
+ enum alpnid srcalpnid,
+ enum alpnid dstalpnid,
+ unsigned int srcport,
+ unsigned int dstport)
+{
+ struct altsvc *as = calloc(sizeof(struct altsvc), 1);
+ if(!as)
+ return NULL;
+
+ as->srchost = strdup(srchost);
+ if(!as->srchost)
+ goto error;
+ as->dsthost = strdup(dsthost);
+ if(!as->dsthost)
+ goto error;
+
+ as->srcalpnid = srcalpnid;
+ as->dstalpnid = dstalpnid;
+ as->srcport = curlx_ultous(srcport);
+ as->dstport = curlx_ultous(dstport);
+
+ return as;
+ error:
+ altsvc_free(as);
+ return NULL;
+}
+
+static struct altsvc *altsvc_create(char *srchost,
+ char *dsthost,
+ char *srcalpn,
+ char *dstalpn,
+ unsigned int srcport,
+ unsigned int dstport)
+{
+ enum alpnid dstalpnid = alpn2alpnid(dstalpn);
+ enum alpnid srcalpnid = alpn2alpnid(srcalpn);
+ if(!srcalpnid || !dstalpnid)
+ return NULL;
+ return altsvc_createid(srchost, dsthost, srcalpnid, dstalpnid,
+ srcport, dstport);
+}
+
+/* only returns SERIOUS errors */
+static CURLcode altsvc_add(struct altsvcinfo *asi, char *line)
+{
+ /* Example line:
+ h2 example.com 443 h3 shiny.example.com 8443 "20191231 10:00:00" 1
+ */
+ char srchost[MAX_ALTSVC_HOSTLEN + 1];
+ char dsthost[MAX_ALTSVC_HOSTLEN + 1];
+ char srcalpn[MAX_ALTSVC_ALPNLEN + 1];
+ char dstalpn[MAX_ALTSVC_ALPNLEN + 1];
+ char date[MAX_ALTSVC_DATELEN + 1];
+ unsigned int srcport;
+ unsigned int dstport;
+ unsigned int prio;
+ unsigned int persist;
+ int rc;
+
+ rc = sscanf(line,
+ "%" MAX_ALTSVC_ALPNLENSTR "s %" MAX_ALTSVC_HOSTLENSTR "s %u "
+ "%" MAX_ALTSVC_ALPNLENSTR "s %" MAX_ALTSVC_HOSTLENSTR "s %u "
+ "\"%" MAX_ALTSVC_DATELENSTR "[^\"]\" %u %u",
+ srcalpn, srchost, &srcport,
+ dstalpn, dsthost, &dstport,
+ date, &persist, &prio);
+ if(9 == rc) {
+ struct altsvc *as;
+ time_t expires = curl_getdate(date, NULL);
+ as = altsvc_create(srchost, dsthost, srcalpn, dstalpn, srcport, dstport);
+ if(as) {
+ as->expires = expires;
+ as->prio = prio;
+ as->persist = persist ? 1 : 0;
+ Curl_llist_insert_next(&asi->list, asi->list.tail, as, &as->node);
+ asi->num++; /* one more entry */
+ }
+ }
+
+ return CURLE_OK;
+}
+
+/*
+ * Load alt-svc entries from the given file. The text based line-oriented file
+ * format is documented here:
+ * https://github.com/curl/curl/wiki/QUIC-implementation
+ *
+ * This function only returns error on major problems that prevents alt-svc
+ * handling to work completely. It will ignore individual syntactical errors
+ * etc.
+ */
+static CURLcode altsvc_load(struct altsvcinfo *asi, const char *file)
+{
+ CURLcode result = CURLE_OK;
+ char *line = NULL;
+ FILE *fp = fopen(file, FOPEN_READTEXT);
+ if(fp) {
+ line = malloc(MAX_ALTSVC_LINE);
+ if(!line)
+ goto fail;
+ while(Curl_get_line(line, MAX_ALTSVC_LINE, fp)) {
+ char *lineptr = line;
+ while(*lineptr && ISBLANK(*lineptr))
+ lineptr++;
+ if(*lineptr == '#')
+ /* skip commented lines */
+ continue;
+
+ altsvc_add(asi, lineptr);
+ }
+ free(line); /* free the line buffer */
+ fclose(fp);
+ }
+ return result;
+
+ fail:
+ free(line);
+ fclose(fp);
+ return CURLE_OUT_OF_MEMORY;
+}
+
+/*
+ * Write this single altsvc entry to a single output line
+ */
+
+static CURLcode altsvc_out(struct altsvc *as, FILE *fp)
+{
+ struct tm stamp;
+ CURLcode result = Curl_gmtime(as->expires, &stamp);
+ if(result)
+ return result;
+
+ fprintf(fp,
+ "%s %s %u "
+ "%s %s %u "
+ "\"%d%02d%02d "
+ "%02d:%02d:%02d\" "
+ "%u %d\n",
+ Curl_alpnid2str(as->srcalpnid), as->srchost, as->srcport,
+ Curl_alpnid2str(as->dstalpnid), as->dsthost, as->dstport,
+ stamp.tm_year + 1900, stamp.tm_mon + 1, stamp.tm_mday,
+ stamp.tm_hour, stamp.tm_min, stamp.tm_sec,
+ as->persist, as->prio);
+ return CURLE_OK;
+}
+
+/* ---- library-wide functions below ---- */
+
+/*
+ * Curl_altsvc_init() creates a new altsvc cache.
+ * It returns the new instance or NULL if something goes wrong.
+ */
+struct altsvcinfo *Curl_altsvc_init(void)
+{
+ struct altsvcinfo *asi = calloc(sizeof(struct altsvcinfo), 1);
+ if(!asi)
+ return NULL;
+ Curl_llist_init(&asi->list, NULL);
+
+ /* set default behavior */
+ asi->flags = CURLALTSVC_H1
+#ifdef USE_NGHTTP2
+ | CURLALTSVC_H2
+#endif
+#ifdef USE_HTTP3
+ | CURLALTSVC_H3
+#endif
+ ;
+ return asi;
+}
+
+/*
+ * Curl_altsvc_load() loads alt-svc from file.
+ */
+CURLcode Curl_altsvc_load(struct altsvcinfo *asi, const char *file)
+{
+ CURLcode result;
+ DEBUGASSERT(asi);
+ result = altsvc_load(asi, file);
+ return result;
+}
+
+/*
+ * Curl_altsvc_ctrl() passes on the external bitmask.
+ */
+CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl)
+{
+ DEBUGASSERT(asi);
+ if(!ctrl)
+ /* unexpected */
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ asi->flags = ctrl;
+ return CURLE_OK;
+}
+
+/*
+ * Curl_altsvc_cleanup() frees an altsvc cache instance and all associated
+ * resources.
+ */
+void Curl_altsvc_cleanup(struct altsvcinfo *altsvc)
+{
+ struct curl_llist_element *e;
+ struct curl_llist_element *n;
+ if(altsvc) {
+ for(e = altsvc->list.head; e; e = n) {
+ struct altsvc *as = e->ptr;
+ n = e->next;
+ altsvc_free(as);
+ }
+ free(altsvc);
+ }
+}
+
+/*
+ * Curl_altsvc_save() writes the altsvc cache to a file.
+ */
+CURLcode Curl_altsvc_save(struct altsvcinfo *altsvc, const char *file)
+{
+ struct curl_llist_element *e;
+ struct curl_llist_element *n;
+ CURLcode result = CURLE_OK;
+ FILE *out;
+
+ if(!altsvc)
+ /* no cache activated */
+ return CURLE_OK;
+
+ if((altsvc->flags & CURLALTSVC_READONLYFILE) || !file[0])
+ /* marked as read-only or zero length file name */
+ return CURLE_OK;
+ out = fopen(file, FOPEN_WRITETEXT);
+ if(!out)
+ return CURLE_WRITE_ERROR;
+ fputs("# Your alt-svc cache. https://curl.haxx.se/docs/alt-svc.html\n"
+ "# This file was generated by libcurl! Edit at your own risk.\n",
+ out);
+ for(e = altsvc->list.head; e; e = n) {
+ struct altsvc *as = e->ptr;
+ n = e->next;
+ result = altsvc_out(as, out);
+ if(result)
+ break;
+ }
+ fclose(out);
+ return result;
+}
+
+static CURLcode getalnum(const char **ptr, char *alpnbuf, size_t buflen)
+{
+ size_t len;
+ const char *protop;
+ const char *p = *ptr;
+ while(*p && ISBLANK(*p))
+ p++;
+ protop = p;
+ while(*p && ISALNUM(*p))
+ p++;
+ len = p - protop;
+
+ if(!len || (len >= buflen))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ memcpy(alpnbuf, protop, len);
+ alpnbuf[len] = 0;
+ *ptr = p;
+ return CURLE_OK;
+}
+
+/* altsvc_flush() removes all alternatives for this source origin from the
+ list */
+static void altsvc_flush(struct altsvcinfo *asi, enum alpnid srcalpnid,
+ const char *srchost, unsigned short srcport)
+{
+ struct curl_llist_element *e;
+ struct curl_llist_element *n;
+ for(e = asi->list.head; e; e = n) {
+ struct altsvc *as = e->ptr;
+ n = e->next;
+ if((srcalpnid == as->srcalpnid) &&
+ (srcport == as->srcport) &&
+ strcasecompare(srchost, as->srchost)) {
+ Curl_llist_remove(&asi->list, e, NULL);
+ altsvc_free(as);
+ asi->num--;
+ }
+ }
+}
+
+#ifdef DEBUGBUILD
+/* to play well with debug builds, we can *set* a fixed time this will
+ return */
+static time_t debugtime(void *unused)
+{
+ char *timestr = getenv("CURL_TIME");
+ (void)unused;
+ if(timestr) {
+ unsigned long val = strtol(timestr, NULL, 10);
+ return (time_t)val;
+ }
+ return time(NULL);
+}
+#define time(x) debugtime(x)
+#endif
+
+/*
+ * Curl_altsvc_parse() takes an incoming alt-svc response header and stores
+ * the data correctly in the cache.
+ *
+ * 'value' points to the header *value*. That's contents to the right of the
+ * header name.
+ */
+CURLcode Curl_altsvc_parse(struct Curl_easy *data,
+ struct altsvcinfo *asi, const char *value,
+ enum alpnid srcalpnid, const char *srchost,
+ unsigned short srcport)
+{
+ const char *p = value;
+ size_t len;
+ enum alpnid dstalpnid = srcalpnid; /* the same by default */
+ char namebuf[MAX_ALTSVC_HOSTLEN] = "";
+ char alpnbuf[MAX_ALTSVC_ALPNLEN] = "";
+ struct altsvc *as;
+ unsigned short dstport = srcport; /* the same by default */
+ const char *semip;
+ time_t maxage = 24 * 3600; /* default is 24 hours */
+ bool persist = FALSE;
+ CURLcode result = getalnum(&p, alpnbuf, sizeof(alpnbuf));
+ if(result)
+ return result;
+
+ DEBUGASSERT(asi);
+
+ /* Flush all cached alternatives for this source origin, if any */
+ altsvc_flush(asi, srcalpnid, srchost, srcport);
+
+ /* "clear" is a magic keyword */
+ if(strcasecompare(alpnbuf, "clear")) {
+ return CURLE_OK;
+ }
+
+ /* The 'ma' and 'persist' flags are annoyingly meant for all alternatives
+ but are set after the list on the line. Scan for the semicolons and get
+ those fields first! */
+ semip = p;
+ do {
+ semip = strchr(semip, ';');
+ if(semip) {
+ char option[32];
+ unsigned long num;
+ char *end_ptr;
+ semip++; /* pass the semicolon */
+ result = getalnum(&semip, option, sizeof(option));
+ if(result)
+ break;
+ while(*semip && ISBLANK(*semip))
+ semip++;
+ if(*semip != '=')
+ continue;
+ semip++;
+ num = strtoul(semip, &end_ptr, 10);
+ if(num < ULONG_MAX) {
+ if(strcasecompare("ma", option))
+ maxage = num;
+ else if(strcasecompare("persist", option) && (num == 1))
+ persist = TRUE;
+ }
+ semip = end_ptr;
+ }
+ } while(semip);
+
+ do {
+ if(*p == '=') {
+ /* [protocol]="[host][:port]" */
+ dstalpnid = alpn2alpnid(alpnbuf);
+ if(!dstalpnid) {
+ infof(data, "Unknown alt-svc protocol \"%s\", ignoring...\n", alpnbuf);
+ return CURLE_OK;
+ }
+ p++;
+ if(*p == '\"') {
+ const char *dsthost;
+ p++;
+ if(*p != ':') {
+ /* host name starts here */
+ const char *hostp = p;
+ while(*p && (ISALNUM(*p) || (*p == '.') || (*p == '-')))
+ p++;
+ len = p - hostp;
+ if(!len || (len >= MAX_ALTSVC_HOSTLEN))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ memcpy(namebuf, hostp, len);
+ namebuf[len] = 0;
+ dsthost = namebuf;
+ }
+ else {
+ /* no destination name, use source host */
+ dsthost = srchost;
+ }
+ if(*p == ':') {
+ /* a port number */
+ char *end_ptr;
+ unsigned long port = strtoul(++p, &end_ptr, 10);
+ if(port > USHRT_MAX || end_ptr == p || *end_ptr != '\"') {
+ infof(data, "Unknown alt-svc port number, ignoring...\n");
+ return CURLE_OK;
+ }
+ p = end_ptr;
+ dstport = curlx_ultous(port);
+ }
+ if(*p++ != '\"')
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ as = altsvc_createid(srchost, dsthost,
+ srcalpnid, dstalpnid,
+ srcport, dstport);
+ if(as) {
+ /* The expires time also needs to take the Age: value (if any) into
+ account. [See RFC 7838 section 3.1] */
+ as->expires = maxage + time(NULL);
+ as->persist = persist;
+ Curl_llist_insert_next(&asi->list, asi->list.tail, as, &as->node);
+ asi->num++; /* one more entry */
+ infof(data, "Added alt-svc: %s:%d over %s\n", dsthost, dstport,
+ Curl_alpnid2str(dstalpnid));
+ }
+ }
+ /* after the double quote there can be a comma if there's another
+ string or a semicolon if no more */
+ if(*p == ',') {
+ /* comma means another alternative is presented */
+ p++;
+ result = getalnum(&p, alpnbuf, sizeof(alpnbuf));
+ if(result)
+ /* failed to parse, but since we already did at least one host we
+ return OK */
+ return CURLE_OK;
+ }
+ }
+ } while(*p && (*p != ';') && (*p != '\n') && (*p != '\r'));
+
+ return CURLE_OK;
+}
+
+/*
+ * Return TRUE on a match
+ */
+bool Curl_altsvc_lookup(struct altsvcinfo *asi,
+ enum alpnid srcalpnid, const char *srchost,
+ int srcport,
+ enum alpnid *dstalpnid, const char **dsthost,
+ int *dstport)
+{
+ struct curl_llist_element *e;
+ struct curl_llist_element *n;
+ time_t now = time(NULL);
+ DEBUGASSERT(asi);
+ DEBUGASSERT(srchost);
+ DEBUGASSERT(dsthost);
+
+ for(e = asi->list.head; e; e = n) {
+ struct altsvc *as = e->ptr;
+ n = e->next;
+ if(as->expires < now) {
+ /* an expired entry, remove */
+ altsvc_free(as);
+ continue;
+ }
+ if((as->srcalpnid == srcalpnid) &&
+ strcasecompare(as->srchost, srchost) &&
+ as->srcport == srcport) {
+ /* match */
+ *dstalpnid = as->dstalpnid;
+ *dsthost = as->dsthost;
+ *dstport = as->dstport;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+#endif /* CURL_DISABLE_HTTP || USE_ALTSVC */
diff --git a/Utilities/cmcurl/lib/altsvc.h b/Utilities/cmcurl/lib/altsvc.h
new file mode 100644
index 000000000..eefb45bf6
--- /dev/null
+++ b/Utilities/cmcurl/lib/altsvc.h
@@ -0,0 +1,77 @@
+#ifndef HEADER_CURL_ALTSVC_H
+#define HEADER_CURL_ALTSVC_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "curl_setup.h"
+
+#if !defined(CURL_DISABLE_HTTP) && defined(USE_ALTSVC)
+#include <curl/curl.h>
+#include "llist.h"
+
+enum alpnid {
+ ALPN_none,
+ ALPN_h1,
+ ALPN_h2,
+ ALPN_h2c,
+ ALPN_h3
+};
+
+struct altsvc {
+ char *srchost;
+ char *dsthost;
+ unsigned short srcport;
+ unsigned short dstport;
+ enum alpnid srcalpnid;
+ enum alpnid dstalpnid;
+ time_t expires;
+ bool persist;
+ int prio;
+ struct curl_llist_element node;
+};
+
+struct altsvcinfo {
+ char *filename;
+ struct curl_llist list; /* list of entries */
+ size_t num; /* number of alt-svc entries */
+ long flags; /* the publicly set bitmask */
+};
+
+const char *Curl_alpnid2str(enum alpnid id);
+struct altsvcinfo *Curl_altsvc_init(void);
+CURLcode Curl_altsvc_load(struct altsvcinfo *asi, const char *file);
+CURLcode Curl_altsvc_save(struct altsvcinfo *asi, const char *file);
+CURLcode Curl_altsvc_ctrl(struct altsvcinfo *asi, const long ctrl);
+void Curl_altsvc_cleanup(struct altsvcinfo *altsvc);
+CURLcode Curl_altsvc_parse(struct Curl_easy *data,
+ struct altsvcinfo *altsvc, const char *value,
+ enum alpnid srcalpn, const char *srchost,
+ unsigned short srcport);
+bool Curl_altsvc_lookup(struct altsvcinfo *asi,
+ enum alpnid srcalpnid, const char *srchost,
+ int srcport,
+ enum alpnid *dstalpnid, const char **dsthost,
+ int *dstport);
+#else
+/* disabled */
+#define Curl_altsvc_save(a,b)
+#endif /* CURL_DISABLE_HTTP || USE_ALTSVC */
+#endif /* HEADER_CURL_ALTSVC_H */
diff --git a/Utilities/cmcurl/lib/amigaos.c b/Utilities/cmcurl/lib/amigaos.c
index 4f55b30e7..cf44bdc8d 100644
--- a/Utilities/cmcurl/lib/amigaos.c
+++ b/Utilities/cmcurl/lib/amigaos.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,17 +22,26 @@
#include "curl_setup.h"
-#if defined(__AMIGA__) && !defined(__ixemul__)
-
-#include <amitcp/socketbasetags.h>
+#ifdef __AMIGA__
+# include "amigaos.h"
+# if defined(HAVE_PROTO_BSDSOCKET_H) && !defined(USE_AMISSL)
+# include <amitcp/socketbasetags.h>
+# endif
+# ifdef __libnix__
+# include <stabs.h>
+# endif
+#endif
-#include "amigaos.h"
+/* The last #include files should be: */
+#include "curl_memory.h"
+#include "memdebug.h"
+#ifdef __AMIGA__
+#if defined(HAVE_PROTO_BSDSOCKET_H) && !defined(USE_AMISSL)
struct Library *SocketBase = NULL;
extern int errno, h_errno;
#ifdef __libnix__
-#include <stabs.h>
void __request(const char *msg);
#else
# define __request(msg) Printf(msg "\n\a")
@@ -74,4 +83,13 @@ bool Curl_amiga_init()
ADD2EXIT(Curl_amiga_cleanup, -50);
#endif
-#endif /* __AMIGA__ && ! __ixemul__ */
+#endif /* HAVE_PROTO_BSDSOCKET_H */
+
+#ifdef USE_AMISSL
+void Curl_amiga_X509_free(X509 *a)
+{
+ X509_free(a);
+}
+#endif /* USE_AMISSL */
+#endif /* __AMIGA__ */
+
diff --git a/Utilities/cmcurl/lib/amigaos.h b/Utilities/cmcurl/lib/amigaos.h
index 02bee1610..c776c9c9b 100644
--- a/Utilities/cmcurl/lib/amigaos.h
+++ b/Utilities/cmcurl/lib/amigaos.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -23,7 +23,7 @@
***************************************************************************/
#include "curl_setup.h"
-#if defined(__AMIGA__) && !defined(__ixemul__)
+#if defined(__AMIGA__) && defined(HAVE_BSDSOCKET_H) && !defined(USE_AMISSL)
bool Curl_amiga_init();
void Curl_amiga_cleanup();
@@ -35,5 +35,10 @@ void Curl_amiga_cleanup();
#endif
+#ifdef USE_AMISSL
+#include <openssl/x509v3.h>
+void Curl_amiga_X509_free(X509 *a);
+#endif /* USE_AMISSL */
+
#endif /* HEADER_CURL_AMIGAOS_H */
diff --git a/Utilities/cmcurl/lib/arpa_telnet.h b/Utilities/cmcurl/lib/arpa_telnet.h
index ec238729d..232680e7d 100644
--- a/Utilities/cmcurl/lib/arpa_telnet.h
+++ b/Utilities/cmcurl/lib/arpa_telnet.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -37,6 +37,7 @@
#define CURL_NEW_ENV_VAR 0
#define CURL_NEW_ENV_VALUE 1
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
/*
* The telnet options represented as strings
*/
@@ -53,6 +54,7 @@ static const char * const telnetoptions[]=
"TERM SPEED", "LFLOW", "LINEMODE", "XDISPLOC",
"OLD-ENVIRON", "AUTHENTICATION", "ENCRYPT", "NEW-ENVIRON"
};
+#endif
#define CURL_TELOPT_MAXIMUM CURL_TELOPT_NEW_ENVIRON
@@ -76,6 +78,7 @@ static const char * const telnetoptions[]=
#define CURL_DONT 254 /* DON'T use this option! */
#define CURL_IAC 255 /* Interpret As Command */
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
/*
* Then those numbers represented as strings:
*/
@@ -86,6 +89,7 @@ static const char * const telnetcmds[]=
"AYT", "EC", "EL", "GA", "SB",
"WILL", "WONT", "DO", "DONT", "IAC"
};
+#endif
#define CURL_TELCMD_MINIMUM CURL_xEOF /* the first one */
#define CURL_TELCMD_MAXIMUM CURL_IAC /* surprise, 255 is the last one! ;-) */
diff --git a/Utilities/cmcurl/lib/asyn-ares.c b/Utilities/cmcurl/lib/asyn-ares.c
index 11a914f82..8561a4724 100644
--- a/Utilities/cmcurl/lib/asyn-ares.c
+++ b/Utilities/cmcurl/lib/asyn-ares.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,9 +22,15 @@
#include "curl_setup.h"
-#ifdef HAVE_LIMITS_H
+/***********************************************************************
+ * Only for ares-enabled builds
+ * And only for functions that fulfill the asynch resolver backend API
+ * as defined in asyn.h, nothing else belongs in this file!
+ **********************************************************************/
+
+#ifdef CURLRES_ARES
+
#include <limits.h>
-#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
@@ -48,14 +54,6 @@
#define in_addr_t unsigned long
#endif
-/***********************************************************************
- * Only for ares-enabled builds
- * And only for functions that fulfill the asynch resolver backend API
- * as defined in asyn.h, nothing else belongs in this file!
- **********************************************************************/
-
-#ifdef CURLRES_ARES
-
#include "urldata.h"
#include "sendf.h"
#include "hostip.h"
@@ -70,7 +68,7 @@
#include "progress.h"
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
- (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
+ (defined(WIN32) || defined(__SYMBIAN32__))
# define CARES_STATICLIB
# endif
# include <ares.h>
@@ -91,8 +89,20 @@ struct ResolverResults {
int num_pending; /* number of ares_gethostbyname() requests */
Curl_addrinfo *temp_ai; /* intermediary result while fetching c-ares parts */
int last_status;
+ struct curltime happy_eyeballs_dns_time; /* when this timer started, or 0 */
};
+/* How long we are willing to wait for additional parallel responses after
+ obtaining a "definitive" one.
+
+ This is intended to equal the c-ares default timeout. cURL always uses that
+ default value. Unfortunately, c-ares doesn't expose its default timeout in
+ its API, but it is officially documented as 5 seconds.
+
+ See query_completed_cb() for an explanation of how this is used.
+ */
+#define HAPPY_EYEBALLS_DNS_TIMEOUT 5000
+
/*
* Curl_resolver_global_init() - the generic low-level asynchronous name
* resolve API. Called from curl_global_init() to initialize global resolver
@@ -121,6 +131,17 @@ void Curl_resolver_global_cleanup(void)
#endif
}
+
+static void Curl_ares_sock_state_cb(void *data, ares_socket_t socket_fd,
+ int readable, int writable)
+{
+ struct Curl_easy *easy = data;
+ if(!readable && !writable) {
+ DEBUGASSERT(easy);
+ Curl_multi_closed(easy, socket_fd);
+ }
+}
+
/*
* Curl_resolver_init()
*
@@ -128,9 +149,14 @@ void Curl_resolver_global_cleanup(void)
* URL-state specific environment ('resolver' member of the UrlState
* structure). Fills the passed pointer by the initialized ares_channel.
*/
-CURLcode Curl_resolver_init(void **resolver)
+CURLcode Curl_resolver_init(struct Curl_easy *easy, void **resolver)
{
- int status = ares_init((ares_channel*)resolver);
+ int status;
+ struct ares_options options;
+ int optmask = ARES_OPT_SOCK_STATE_CB;
+ options.sock_state_cb = Curl_ares_sock_state_cb;
+ options.sock_state_cb_data = easy;
+ status = ares_init_options((ares_channel*)resolver, &options, optmask);
if(status != ARES_SUCCESS) {
if(status == ARES_ENOMEM)
return CURLE_OUT_OF_MEMORY;
@@ -161,12 +187,15 @@ void Curl_resolver_cleanup(void *resolver)
* environment ('resolver' member of the UrlState structure). Duplicates the
* 'from' ares channel and passes the resulting channel to the 'to' pointer.
*/
-int Curl_resolver_duphandle(void **to, void *from)
+CURLcode Curl_resolver_duphandle(struct Curl_easy *easy, void **to, void *from)
{
- /* Clone the ares channel for the new handle */
- if(ARES_SUCCESS != ares_dup((ares_channel*)to, (ares_channel)from))
- return CURLE_FAILED_INIT;
- return CURLE_OK;
+ (void)from;
+ /*
+ * it would be better to call ares_dup instead, but right now
+ * it is not possible to set 'sock_state_cb_data' outside of
+ * ares_init_options
+ */
+ return Curl_resolver_init(easy, to);
}
static void destroy_async_data(struct Curl_async *async);
@@ -182,6 +211,17 @@ void Curl_resolver_cancel(struct connectdata *conn)
}
/*
+ * We're equivalent to Curl_resolver_cancel() for the c-ares resolver. We
+ * never block.
+ */
+void Curl_resolver_kill(struct connectdata *conn)
+{
+ /* We don't need to check the resolver state because we can be called safely
+ at any time and we always do the same thing. */
+ Curl_resolver_cancel(conn);
+}
+
+/*
* destroy_async_data() cleans up async resolver data.
*/
static void destroy_async_data(struct Curl_async *async)
@@ -260,7 +300,7 @@ static int waitperform(struct connectdata *conn, int timeout_ms)
bitmask = ares_getsock((ares_channel)data->state.resolver, socks,
ARES_GETSOCK_MAXNUM);
- for(i=0; i < ARES_GETSOCK_MAXNUM; i++) {
+ for(i = 0; i < ARES_GETSOCK_MAXNUM; i++) {
pfd[i].events = 0;
pfd[i].revents = 0;
if(ARES_GETSOCK_READABLE(bitmask, i)) {
@@ -289,11 +329,11 @@ static int waitperform(struct connectdata *conn, int timeout_ms)
ARES_SOCKET_BAD);
else {
/* move through the descriptors and ask for processing on them */
- for(i=0; i < num; i++)
+ for(i = 0; i < num; i++)
ares_process_fd((ares_channel)data->state.resolver,
- pfd[i].revents & (POLLRDNORM|POLLIN)?
+ (pfd[i].revents & (POLLRDNORM|POLLIN))?
pfd[i].fd:ARES_SOCKET_BAD,
- pfd[i].revents & (POLLWRNORM|POLLOUT)?
+ (pfd[i].revents & (POLLWRNORM|POLLOUT))?
pfd[i].fd:ARES_SOCKET_BAD);
}
return nfds;
@@ -314,22 +354,48 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
conn->async.os_specific;
CURLcode result = CURLE_OK;
- *dns = NULL;
+ if(dns)
+ *dns = NULL;
waitperform(conn, 0);
+ /* Now that we've checked for any last minute results above, see if there are
+ any responses still pending when the EXPIRE_HAPPY_EYEBALLS_DNS timer
+ expires. */
+ if(res
+ && res->num_pending
+ /* This is only set to non-zero if the timer was started. */
+ && (res->happy_eyeballs_dns_time.tv_sec
+ || res->happy_eyeballs_dns_time.tv_usec)
+ && (Curl_timediff(Curl_now(), res->happy_eyeballs_dns_time)
+ >= HAPPY_EYEBALLS_DNS_TIMEOUT)) {
+ /* Remember that the EXPIRE_HAPPY_EYEBALLS_DNS timer is no longer
+ running. */
+ memset(
+ &res->happy_eyeballs_dns_time, 0, sizeof(res->happy_eyeballs_dns_time));
+
+ /* Cancel the raw c-ares request, which will fire query_completed_cb() with
+ ARES_ECANCELLED synchronously for all pending responses. This will
+ leave us with res->num_pending == 0, which is perfect for the next
+ block. */
+ ares_cancel((ares_channel)data->state.resolver);
+ DEBUGASSERT(res->num_pending == 0);
+ }
+
if(res && !res->num_pending) {
- (void)Curl_addrinfo_callback(conn, res->last_status, res->temp_ai);
- /* temp_ai ownership is moved to the connection, so we need not free-up
- them */
- res->temp_ai = NULL;
+ if(dns) {
+ (void)Curl_addrinfo_callback(conn, res->last_status, res->temp_ai);
+ /* temp_ai ownership is moved to the connection, so we need not free-up
+ them */
+ res->temp_ai = NULL;
+ }
if(!conn->async.dns) {
failf(data, "Could not resolve: %s (%s)",
conn->async.hostname, ares_strerror(conn->async.status));
result = conn->bits.proxy?CURLE_COULDNT_RESOLVE_PROXY:
CURLE_COULDNT_RESOLVE_HOST;
}
- else
+ else if(dns)
*dns = conn->async.dns;
destroy_async_data(&conn->async);
@@ -341,21 +407,21 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
/*
* Curl_resolver_wait_resolv()
*
- * waits for a resolve to finish. This function should be avoided since using
+ * Waits for a resolve to finish. This function should be avoided since using
* this risk getting the multi interface to "hang".
*
* If 'entry' is non-NULL, make it point to the resolved dns entry
*
- * Returns CURLE_COULDNT_RESOLVE_HOST if the host was not resolved, and
- * CURLE_OPERATION_TIMEDOUT if a time-out occurred.
+ * Returns CURLE_COULDNT_RESOLVE_HOST if the host was not resolved,
+ * CURLE_OPERATION_TIMEDOUT if a time-out occurred, or other errors.
*/
CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
struct Curl_dns_entry **entry)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- long timeout;
- struct timeval now = Curl_tvnow();
+ timediff_t timeout;
+ struct curltime now = Curl_now();
struct Curl_dns_entry *temp_entry;
if(entry)
@@ -392,7 +458,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
timeout_ms = 1000;
waitperform(conn, timeout_ms);
- result = Curl_resolver_is_resolved(conn, &temp_entry);
+ result = Curl_resolver_is_resolved(conn, entry?&temp_entry:NULL);
if(result || conn->async.done)
break;
@@ -400,8 +466,8 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
else {
- struct timeval now2 = Curl_tvnow();
- time_t timediff = Curl_tvdiff(now2, now); /* spent time */
+ struct curltime now2 = Curl_now();
+ timediff_t timediff = Curl_timediff(now2, now); /* spent time */
if(timediff <= 0)
timeout -= 1; /* always deduct at least 1 */
else if(timediff > timeout)
@@ -424,9 +490,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
if(result)
/* close the connection, since we can't return failure here without
- cleaning up this connection properly.
- TODO: remove this action from here, it is not a name resolver decision.
- */
+ cleaning up this connection properly. */
connclose(conn, "c-ares resolve failed");
return result;
@@ -474,17 +538,79 @@ static void query_completed_cb(void *arg, /* (struct connectdata *) */
return;
res = (struct ResolverResults *)conn->async.os_specific;
- res->num_pending--;
+ if(res) {
+ res->num_pending--;
- if(CURL_ASYNC_SUCCESS == status) {
- Curl_addrinfo *ai = Curl_he2ai(hostent, conn->async.port);
- if(ai) {
- compound_results(res, ai);
+ if(CURL_ASYNC_SUCCESS == status) {
+ Curl_addrinfo *ai = Curl_he2ai(hostent, conn->async.port);
+ if(ai) {
+ compound_results(res, ai);
+ }
+ }
+ /* A successful result overwrites any previous error */
+ if(res->last_status != ARES_SUCCESS)
+ res->last_status = status;
+
+ /* If there are responses still pending, we presume they must be the
+ complementary IPv4 or IPv6 lookups that we started in parallel in
+ Curl_resolver_getaddrinfo() (for Happy Eyeballs). If we've got a
+ "definitive" response from one of a set of parallel queries, we need to
+ think about how long we're willing to wait for more responses. */
+ if(res->num_pending
+ /* Only these c-ares status values count as "definitive" for these
+ purposes. For example, ARES_ENODATA is what we expect when there is
+ no IPv6 entry for a domain name, and that's not a reason to get more
+ aggressive in our timeouts for the other response. Other errors are
+ either a result of bad input (which should affect all parallel
+ requests), local or network conditions, non-definitive server
+ responses, or us cancelling the request. */
+ && (status == ARES_SUCCESS || status == ARES_ENOTFOUND)) {
+ /* Right now, there can only be up to two parallel queries, so don't
+ bother handling any other cases. */
+ DEBUGASSERT(res->num_pending == 1);
+
+ /* It's possible that one of these parallel queries could succeed
+ quickly, but the other could always fail or timeout (when we're
+ talking to a pool of DNS servers that can only successfully resolve
+ IPv4 address, for example).
+
+ It's also possible that the other request could always just take
+ longer because it needs more time or only the second DNS server can
+ fulfill it successfully. But, to align with the philosophy of Happy
+ Eyeballs, we don't want to wait _too_ long or users will think
+ requests are slow when IPv6 lookups don't actually work (but IPv4 ones
+ do).
+
+ So, now that we have a usable answer (some IPv4 addresses, some IPv6
+ addresses, or "no such domain"), we start a timeout for the remaining
+ pending responses. Even though it is typical that this resolved
+ request came back quickly, that needn't be the case. It might be that
+ this completing request didn't get a result from the first DNS server
+ or even the first round of the whole DNS server pool. So it could
+ already be quite some time after we issued the DNS queries in the
+ first place. Without modifying c-ares, we can't know exactly where in
+ its retry cycle we are. We could guess based on how much time has
+ gone by, but it doesn't really matter. Happy Eyeballs tells us that,
+ given usable information in hand, we simply don't want to wait "too
+ much longer" after we get a result.
+
+ We simply wait an additional amount of time equal to the default
+ c-ares query timeout. That is enough time for a typical parallel
+ response to arrive without being "too long". Even on a network
+ where one of the two types of queries is failing or timing out
+ constantly, this will usually mean we wait a total of the default
+ c-ares timeout (5 seconds) plus the round trip time for the successful
+ request, which seems bearable. The downside is that c-ares might race
+ with us to issue one more retry just before we give up, but it seems
+ better to "waste" that request instead of trying to guess the perfect
+ timeout to prevent it. After all, we don't even know where in the
+ c-ares retry cycle each request is.
+ */
+ res->happy_eyeballs_dns_time = Curl_now();
+ Curl_expire(
+ conn->data, HAPPY_EYEBALLS_DNS_TIMEOUT, EXPIRE_HAPPY_EYEBALLS_DNS);
}
}
- /* A successful result overwrites any previous error */
- if(res->last_status != ARES_SUCCESS)
- res->last_status = status;
}
/*
diff --git a/Utilities/cmcurl/lib/asyn-thread.c b/Utilities/cmcurl/lib/asyn-thread.c
index 65fa6c5be..55e0811c5 100644
--- a/Utilities/cmcurl/lib/asyn-thread.c
+++ b/Utilities/cmcurl/lib/asyn-thread.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -79,6 +79,10 @@
#include "curl_memory.h"
#include "memdebug.h"
+struct resdata {
+ struct curltime start;
+};
+
/*
* Curl_resolver_global_init()
* Called from curl_global_init() to initialize global resolver environment.
@@ -102,11 +106,14 @@ void Curl_resolver_global_cleanup(void)
* Curl_resolver_init()
* Called from curl_easy_init() -> Curl_open() to initialize resolver
* URL-state specific environment ('resolver' member of the UrlState
- * structure). Does nothing here.
+ * structure).
*/
-CURLcode Curl_resolver_init(void **resolver)
+CURLcode Curl_resolver_init(struct Curl_easy *easy, void **resolver)
{
- (void)resolver;
+ (void)easy;
+ *resolver = calloc(1, sizeof(struct resdata));
+ if(!*resolver)
+ return CURLE_OUT_OF_MEMORY;
return CURLE_OK;
}
@@ -114,24 +121,22 @@ CURLcode Curl_resolver_init(void **resolver)
* Curl_resolver_cleanup()
* Called from curl_easy_cleanup() -> Curl_close() to cleanup resolver
* URL-state specific environment ('resolver' member of the UrlState
- * structure). Does nothing here.
+ * structure).
*/
void Curl_resolver_cleanup(void *resolver)
{
- (void)resolver;
+ free(resolver);
}
/*
* Curl_resolver_duphandle()
* Called from curl_easy_duphandle() to duplicate resolver URL state-specific
- * environment ('resolver' member of the UrlState structure). Does nothing
- * here.
+ * environment ('resolver' member of the UrlState structure).
*/
-int Curl_resolver_duphandle(void **to, void *from)
+CURLcode Curl_resolver_duphandle(struct Curl_easy *easy, void **to, void *from)
{
- (void)to;
(void)from;
- return CURLE_OK;
+ return Curl_resolver_init(easy, to);
}
static void destroy_async_data(struct Curl_async *);
@@ -178,8 +183,6 @@ static struct thread_sync_data *conn_thread_sync_data(struct connectdata *conn)
return &(((struct thread_data *)conn->async.os_specific)->tsd);
}
-#define CONN_THREAD_SYNC_DATA(conn) &(((conn)->async.os_specific)->tsd);
-
/* Destroy resolver thread synchronization data */
static
void destroy_thread_sync_data(struct thread_sync_data * tsd)
@@ -210,6 +213,10 @@ int init_thread_sync_data(struct thread_data * td,
tsd->td = td;
tsd->port = port;
+ /* Treat the request as done until the thread actually starts so any early
+ * cleanup gets done properly.
+ */
+ tsd->done = 1;
#ifdef HAVE_GETADDRINFO
DEBUGASSERT(hints);
tsd->hints = *hints;
@@ -270,7 +277,7 @@ static unsigned int CURL_STDCALL getaddrinfo_thread(void *arg)
char service[12];
int rc;
- snprintf(service, sizeof(service), "%d", tsd->port);
+ msnprintf(service, sizeof(service), "%d", tsd->port);
rc = Curl_getaddrinfo_ex(tsd->hostname, service, &tsd->hints, &tsd->res);
@@ -380,11 +387,11 @@ static bool init_resolve_thread(struct connectdata *conn,
const struct addrinfo *hints)
{
struct thread_data *td = calloc(1, sizeof(struct thread_data));
- int err = RESOLVER_ENOMEM;
+ int err = ENOMEM;
conn->async.os_specific = (void *)td;
if(!td)
- goto err_exit;
+ goto errno_exit;
conn->async.port = port;
conn->async.done = FALSE;
@@ -392,14 +399,20 @@ static bool init_resolve_thread(struct connectdata *conn,
conn->async.dns = NULL;
td->thread_hnd = curl_thread_t_null;
- if(!init_thread_sync_data(td, hostname, port, hints))
- goto err_exit;
+ if(!init_thread_sync_data(td, hostname, port, hints)) {
+ conn->async.os_specific = NULL;
+ free(td);
+ goto errno_exit;
+ }
free(conn->async.hostname);
conn->async.hostname = strdup(hostname);
if(!conn->async.hostname)
goto err_exit;
+ /* The thread will set this to 1 when complete. */
+ td->tsd.done = 0;
+
#ifdef HAVE_GETADDRINFO
td->thread_hnd = Curl_thread_create(getaddrinfo_thread, &td->tsd);
#else
@@ -407,9 +420,9 @@ static bool init_resolve_thread(struct connectdata *conn,
#endif
if(!td->thread_hnd) {
-#ifndef _WIN32_WCE
+ /* The thread never started, so mark it as done here for proper cleanup. */
+ td->tsd.done = 1;
err = errno;
-#endif
goto err_exit;
}
@@ -418,8 +431,8 @@ static bool init_resolve_thread(struct connectdata *conn,
err_exit:
destroy_async_data(&conn->async);
- SET_ERRNO(err);
-
+ errno_exit:
+ errno = err;
return FALSE;
}
@@ -448,27 +461,21 @@ static CURLcode resolver_error(struct connectdata *conn)
return result;
}
-/*
- * Curl_resolver_wait_resolv()
- *
- * waits for a resolve to finish. This function should be avoided since using
- * this risk getting the multi interface to "hang".
- *
- * If 'entry' is non-NULL, make it point to the resolved dns entry
- *
- * This is the version for resolves-in-a-thread.
- */
-CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
- struct Curl_dns_entry **entry)
+static CURLcode thread_wait_resolv(struct connectdata *conn,
+ struct Curl_dns_entry **entry,
+ bool report)
{
struct thread_data *td = (struct thread_data*) conn->async.os_specific;
CURLcode result = CURLE_OK;
DEBUGASSERT(conn && td);
+ DEBUGASSERT(td->thread_hnd != curl_thread_t_null);
/* wait for the thread to resolve the name */
- if(Curl_thread_join(&td->thread_hnd))
- result = getaddrinfo_complete(conn);
+ if(Curl_thread_join(&td->thread_hnd)) {
+ if(entry)
+ result = getaddrinfo_complete(conn);
+ }
else
DEBUGASSERT(0);
@@ -477,18 +484,55 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
if(entry)
*entry = conn->async.dns;
- if(!conn->async.dns)
+ if(!conn->async.dns && report)
/* a name was not resolved, report error */
result = resolver_error(conn);
destroy_async_data(&conn->async);
- if(!conn->async.dns)
+ if(!conn->async.dns && report)
connclose(conn, "asynch resolve failed");
return result;
}
+
+/*
+ * Until we gain a way to signal the resolver threads to stop early, we must
+ * simply wait for them and ignore their results.
+ */
+void Curl_resolver_kill(struct connectdata *conn)
+{
+ struct thread_data *td = (struct thread_data*) conn->async.os_specific;
+
+ /* If we're still resolving, we must wait for the threads to fully clean up,
+ unfortunately. Otherwise, we can simply cancel to clean up any resolver
+ data. */
+ if(td && td->thread_hnd != curl_thread_t_null)
+ (void)thread_wait_resolv(conn, NULL, FALSE);
+ else
+ Curl_resolver_cancel(conn);
+}
+
+/*
+ * Curl_resolver_wait_resolv()
+ *
+ * Waits for a resolve to finish. This function should be avoided since using
+ * this risk getting the multi interface to "hang".
+ *
+ * If 'entry' is non-NULL, make it point to the resolved dns entry
+ *
+ * Returns CURLE_COULDNT_RESOLVE_HOST if the host was not resolved,
+ * CURLE_OPERATION_TIMEDOUT if a time-out occurred, or other errors.
+ *
+ * This is the version for resolves-in-a-thread.
+ */
+CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
+ struct Curl_dns_entry **entry)
+{
+ return thread_wait_resolv(conn, entry, TRUE);
+}
+
/*
* Curl_resolver_is_resolved() is called repeatedly to check if a previous
* name resolve request has completed. It should also make sure to time-out if
@@ -525,7 +569,8 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
}
else {
/* poll for name lookup done with exponential backoff up to 250ms */
- time_t elapsed = Curl_tvdiff(Curl_tvnow(), data->progress.t_startsingle);
+ timediff_t elapsed = Curl_timediff(Curl_now(),
+ data->progress.t_startsingle);
if(elapsed < 0)
elapsed = 0;
@@ -550,9 +595,22 @@ int Curl_resolver_getsock(struct connectdata *conn,
curl_socket_t *socks,
int numsocks)
{
- (void)conn;
+ time_t milli;
+ timediff_t ms;
+ struct Curl_easy *data = conn->data;
+ struct resdata *reslv = (struct resdata *)data->state.resolver;
(void)socks;
(void)numsocks;
+ ms = Curl_timediff(Curl_now(), reslv->start);
+ if(ms < 3)
+ milli = 0;
+ else if(ms <= 50)
+ milli = ms/3;
+ else if(ms <= 250)
+ milli = 50;
+ else
+ milli = 200;
+ Curl_expire(data, milli, EXPIRE_ASYNC_NAME);
return 0;
}
@@ -566,6 +624,8 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
int *waitp)
{
struct in_addr in;
+ struct Curl_easy *data = conn->data;
+ struct resdata *reslv = (struct resdata *)data->state.resolver;
*waitp = 0; /* default to synchronous response */
@@ -573,14 +633,17 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
/* This is a dotted IP address 123.123.123.123-style */
return Curl_ip2addr(AF_INET, &in, hostname, port);
+ reslv->start = Curl_now();
+
/* fire up a new resolver thread! */
if(init_resolve_thread(conn, hostname, port, NULL)) {
*waitp = 1; /* expect asynchronous response */
return NULL;
}
- /* fall-back to blocking version */
- return Curl_ipv4_resolve_r(hostname, port);
+ failf(conn->data, "getaddrinfo() thread failed\n");
+
+ return NULL;
}
#else /* !HAVE_GETADDRINFO */
@@ -594,28 +657,29 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
int *waitp)
{
struct addrinfo hints;
- struct in_addr in;
- Curl_addrinfo *res;
- int error;
char sbuf[12];
int pf = PF_INET;
-#ifdef CURLRES_IPV6
- struct in6_addr in6;
-#endif /* CURLRES_IPV6 */
+ struct Curl_easy *data = conn->data;
+ struct resdata *reslv = (struct resdata *)data->state.resolver;
*waitp = 0; /* default to synchronous response */
#ifndef USE_RESOLVE_ON_IPS
- /* First check if this is an IPv4 address string */
- if(Curl_inet_pton(AF_INET, hostname, &in) > 0)
- /* This is a dotted IP address 123.123.123.123-style */
- return Curl_ip2addr(AF_INET, &in, hostname, port);
-
+ {
+ struct in_addr in;
+ /* First check if this is an IPv4 address string */
+ if(Curl_inet_pton(AF_INET, hostname, &in) > 0)
+ /* This is a dotted IP address 123.123.123.123-style */
+ return Curl_ip2addr(AF_INET, &in, hostname, port);
+ }
#ifdef CURLRES_IPV6
- /* check if this is an IPv6 address string */
- if(Curl_inet_pton(AF_INET6, hostname, &in6) > 0)
- /* This is an IPv6 address literal */
- return Curl_ip2addr(AF_INET6, &in6, hostname, port);
+ {
+ struct in6_addr in6;
+ /* check if this is an IPv6 address string */
+ if(Curl_inet_pton(AF_INET6, hostname, &in6) > 0)
+ /* This is an IPv6 address literal */
+ return Curl_ip2addr(AF_INET6, &in6, hostname, port);
+ }
#endif /* CURLRES_IPV6 */
#endif /* !USE_RESOLVE_ON_IPS */
@@ -644,29 +708,18 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
hints.ai_family = pf;
hints.ai_socktype = conn->socktype;
- snprintf(sbuf, sizeof(sbuf), "%d", port);
+ msnprintf(sbuf, sizeof(sbuf), "%d", port);
+ reslv->start = Curl_now();
/* fire up a new resolver thread! */
if(init_resolve_thread(conn, hostname, port, &hints)) {
*waitp = 1; /* expect asynchronous response */
return NULL;
}
- /* fall-back to blocking version */
- infof(conn->data, "init_resolve_thread() failed for %s; %s\n",
- hostname, Curl_strerror(conn, ERRNO));
-
- error = Curl_getaddrinfo_ex(hostname, sbuf, &hints, &res);
- if(error) {
- infof(conn->data, "getaddrinfo() failed for %s:%d; %s\n",
- hostname, port, Curl_strerror(conn, SOCKERRNO));
- return NULL;
- }
- else {
- Curl_addrinfo_set_port(res, port);
- }
+ failf(data, "getaddrinfo() thread failed to start\n");
+ return NULL;
- return res;
}
#endif /* !HAVE_GETADDRINFO */
diff --git a/Utilities/cmcurl/lib/asyn.h b/Utilities/cmcurl/lib/asyn.h
index 3adc3664a..ccd4b1f7e 100644
--- a/Utilities/cmcurl/lib/asyn.h
+++ b/Utilities/cmcurl/lib/asyn.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -60,7 +60,7 @@ void Curl_resolver_global_cleanup(void);
* Returning anything else than CURLE_OK fails curl_easy_init() with the
* correspondent code.
*/
-CURLcode Curl_resolver_init(void **resolver);
+CURLcode Curl_resolver_init(struct Curl_easy *easy, void **resolver);
/*
* Curl_resolver_cleanup()
@@ -79,17 +79,33 @@ void Curl_resolver_cleanup(void *resolver);
* pointer. Returning anything else than CURLE_OK causes failed
* curl_easy_duphandle() call.
*/
-int Curl_resolver_duphandle(void **to, void *from);
+CURLcode Curl_resolver_duphandle(struct Curl_easy *easy, void **to,
+ void *from);
/*
* Curl_resolver_cancel().
*
* It is called from inside other functions to cancel currently performing
* resolver request. Should also free any temporary resources allocated to
- * perform a request.
+ * perform a request. This never waits for resolver threads to complete.
+ *
+ * It is safe to call this when conn is in any state.
*/
void Curl_resolver_cancel(struct connectdata *conn);
+/*
+ * Curl_resolver_kill().
+ *
+ * This acts like Curl_resolver_cancel() except it will block until any threads
+ * associated with the resolver are complete. This never blocks for resolvers
+ * that do not use threads. This is intended to be the "last chance" function
+ * that cleans up an in-progress resolver completely (before its owner is about
+ * to die).
+ *
+ * It is safe to call this when conn is in any state.
+ */
+void Curl_resolver_kill(struct connectdata *conn);
+
/* Curl_resolver_getsock()
*
* This function is called from the multi_getsock() function. 'sock' is a
@@ -116,14 +132,13 @@ CURLcode Curl_resolver_is_resolved(struct connectdata *conn,
/*
* Curl_resolver_wait_resolv()
*
- * waits for a resolve to finish. This function should be avoided since using
+ * Waits for a resolve to finish. This function should be avoided since using
* this risk getting the multi interface to "hang".
*
* If 'entry' is non-NULL, make it point to the resolved dns entry
*
- * Returns CURLE_COULDNT_RESOLVE_HOST if the host was not resolved, and
- * CURLE_OPERATION_TIMEDOUT if a time-out occurred.
-
+ * Returns CURLE_COULDNT_RESOLVE_HOST if the host was not resolved,
+ * CURLE_OPERATION_TIMEDOUT if a time-out occurred, or other errors.
*/
CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
struct Curl_dns_entry **dnsentry);
@@ -147,11 +162,12 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
#ifndef CURLRES_ASYNCH
/* convert these functions if an asynch resolver isn't used */
#define Curl_resolver_cancel(x) Curl_nop_stmt
+#define Curl_resolver_kill(x) Curl_nop_stmt
#define Curl_resolver_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST
#define Curl_resolver_wait_resolv(x,y) CURLE_COULDNT_RESOLVE_HOST
#define Curl_resolver_getsock(x,y,z) 0
-#define Curl_resolver_duphandle(x,y) CURLE_OK
-#define Curl_resolver_init(x) CURLE_OK
+#define Curl_resolver_duphandle(x,y,z) CURLE_OK
+#define Curl_resolver_init(x,y) CURLE_OK
#define Curl_resolver_global_init() CURLE_OK
#define Curl_resolver_global_cleanup() Curl_nop_stmt
#define Curl_resolver_cleanup(x) Curl_nop_stmt
diff --git a/Utilities/cmcurl/lib/base64.c b/Utilities/cmcurl/lib/base64.c
index 204a2273d..fb081a6bb 100644
--- a/Utilities/cmcurl/lib/base64.c
+++ b/Utilities/cmcurl/lib/base64.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -23,6 +23,11 @@
/* Base64 encoding/decoding */
#include "curl_setup.h"
+
+#if !defined(CURL_DISABLE_HTTP_AUTH) || defined(USE_LIBSSH2) || \
+ defined(USE_LIBSSH) || !defined(CURL_DISABLE_LDAP) || \
+ !defined(CURL_DISABLE_DOH) || defined(USE_SSL)
+
#include "urldata.h" /* for the Curl_easy definition */
#include "warnless.h"
#include "curl_base64.h"
@@ -49,13 +54,12 @@ static size_t decodeQuantum(unsigned char *dest, const char *src)
unsigned long i, x = 0;
for(i = 0, s = src; i < 4; i++, s++) {
- unsigned long v = 0;
-
if(*s == '=') {
x = (x << 6);
padding++;
}
else {
+ unsigned long v = 0;
p = base64;
while(*p && (*p != *s)) {
@@ -234,24 +238,24 @@ static CURLcode base64_encode(const char *table64,
switch(inputparts) {
case 1: /* only one byte read */
- snprintf(output, 5, "%c%c==",
- table64[obuf[0]],
- table64[obuf[1]]);
+ msnprintf(output, 5, "%c%c==",
+ table64[obuf[0]],
+ table64[obuf[1]]);
break;
case 2: /* two bytes read */
- snprintf(output, 5, "%c%c%c=",
- table64[obuf[0]],
- table64[obuf[1]],
- table64[obuf[2]]);
+ msnprintf(output, 5, "%c%c%c=",
+ table64[obuf[0]],
+ table64[obuf[1]],
+ table64[obuf[2]]);
break;
default:
- snprintf(output, 5, "%c%c%c%c",
- table64[obuf[0]],
- table64[obuf[1]],
- table64[obuf[2]],
- table64[obuf[3]]);
+ msnprintf(output, 5, "%c%c%c%c",
+ table64[obuf[0]],
+ table64[obuf[1]],
+ table64[obuf[2]],
+ table64[obuf[3]]);
break;
}
output += 4;
@@ -318,3 +322,5 @@ CURLcode Curl_base64url_encode(struct Curl_easy *data,
{
return base64_encode(base64url, data, inputbuff, insize, outptr, outlen);
}
+
+#endif /* no users so disabled */
diff --git a/Utilities/cmcurl/lib/conncache.c b/Utilities/cmcurl/lib/conncache.c
index c79d22764..535091996 100644
--- a/Utilities/cmcurl/lib/conncache.c
+++ b/Utilities/cmcurl/lib/conncache.c
@@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012 - 2016, Linus Nielsen Feltzing, <linus@haxx.se>
- * Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -31,17 +31,41 @@
#include "multiif.h"
#include "sendf.h"
#include "conncache.h"
+#include "share.h"
+#include "sigpipe.h"
+#include "connect.h"
+
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"
+#ifdef CURLDEBUG
+/* the debug versions of these macros make extra certain that the lock is
+ never doubly locked or unlocked */
+#define CONN_LOCK(x) if((x)->share) { \
+ Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, CURL_LOCK_ACCESS_SINGLE); \
+ DEBUGASSERT(!(x)->state.conncache_lock); \
+ (x)->state.conncache_lock = TRUE; \
+ }
+
+#define CONN_UNLOCK(x) if((x)->share) { \
+ DEBUGASSERT((x)->state.conncache_lock); \
+ (x)->state.conncache_lock = FALSE; \
+ Curl_share_unlock((x), CURL_LOCK_DATA_CONNECT); \
+ }
+#else
+#define CONN_LOCK(x) if((x)->share) \
+ Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, CURL_LOCK_ACCESS_SINGLE)
+#define CONN_UNLOCK(x) if((x)->share) \
+ Curl_share_unlock((x), CURL_LOCK_DATA_CONNECT)
+#endif
+
static void conn_llist_dtor(void *user, void *element)
{
- struct connectdata *data = element;
+ struct connectdata *conn = element;
(void)user;
-
- data->bundle = NULL;
+ conn->bundle = NULL;
}
static CURLcode bundle_create(struct Curl_easy *data,
@@ -71,14 +95,13 @@ static void bundle_destroy(struct connectbundle *cb_ptr)
}
/* Add a connection to a bundle */
-static CURLcode bundle_add_conn(struct connectbundle *cb_ptr,
- struct connectdata *conn)
+static void bundle_add_conn(struct connectbundle *cb_ptr,
+ struct connectdata *conn)
{
Curl_llist_insert_next(&cb_ptr->conn_list, cb_ptr->conn_list.tail, conn,
&conn->bundle_node);
conn->bundle = cb_ptr;
cb_ptr->num_connections++;
- return CURLE_OK;
}
/* Remove a connection from a bundle */
@@ -109,8 +132,23 @@ static void free_bundle_hash_entry(void *freethis)
int Curl_conncache_init(struct conncache *connc, int size)
{
- return Curl_hash_init(&connc->hash, size, Curl_hash_str,
- Curl_str_key_compare, free_bundle_hash_entry);
+ int rc;
+
+ /* allocate a new easy handle to use when closing cached connections */
+ connc->closure_handle = curl_easy_init();
+ if(!connc->closure_handle)
+ return 1; /* bad */
+
+ rc = Curl_hash_init(&connc->hash, size, Curl_hash_str,
+ Curl_str_key_compare, free_bundle_hash_entry);
+ if(rc) {
+ Curl_close(connc->closure_handle);
+ connc->closure_handle = NULL;
+ }
+ else
+ connc->closure_handle->state.conn_cache = connc;
+
+ return rc;
}
void Curl_conncache_destroy(struct conncache *connc)
@@ -137,15 +175,47 @@ static void hashkey(struct connectdata *conn, char *buf,
DEBUGASSERT(len > 32);
/* put the number first so that the hostname gets cut off if too long */
- snprintf(buf, len, "%ld%s", conn->port, hostname);
+ msnprintf(buf, len, "%ld%s", conn->port, hostname);
+}
+
+void Curl_conncache_unlock(struct Curl_easy *data)
+{
+ CONN_UNLOCK(data);
+}
+
+/* Returns number of connections currently held in the connection cache.
+ Locks/unlocks the cache itself!
+*/
+size_t Curl_conncache_size(struct Curl_easy *data)
+{
+ size_t num;
+ CONN_LOCK(data);
+ num = data->state.conn_cache->num_conn;
+ CONN_UNLOCK(data);
+ return num;
+}
+
+/* Returns number of connections currently held in the connections's bundle
+ Locks/unlocks the cache itself!
+*/
+size_t Curl_conncache_bundle_size(struct connectdata *conn)
+{
+ size_t num;
+ CONN_LOCK(conn->data);
+ num = conn->bundle->num_connections;
+ CONN_UNLOCK(conn->data);
+ return num;
}
/* Look up the bundle with all the connections to the same host this
- connectdata struct is setup to use. */
+ connectdata struct is setup to use.
+
+ **NOTE**: When it returns, it holds the connection cache lock! */
struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
struct conncache *connc)
{
struct connectbundle *bundle = NULL;
+ CONN_LOCK(conn->data);
if(connc) {
char key[128];
hashkey(conn, key, sizeof(key));
@@ -191,77 +261,94 @@ static void conncache_remove_bundle(struct conncache *connc,
CURLcode Curl_conncache_add_conn(struct conncache *connc,
struct connectdata *conn)
{
- CURLcode result;
+ CURLcode result = CURLE_OK;
struct connectbundle *bundle;
struct connectbundle *new_bundle = NULL;
struct Curl_easy *data = conn->data;
+ /* *find_bundle() locks the connection cache */
bundle = Curl_conncache_find_bundle(conn, data->state.conn_cache);
if(!bundle) {
int rc;
char key[128];
result = bundle_create(data, &new_bundle);
- if(result)
- return result;
+ if(result) {
+ goto unlock;
+ }
hashkey(conn, key, sizeof(key));
rc = conncache_add_bundle(data->state.conn_cache, key, new_bundle);
if(!rc) {
bundle_destroy(new_bundle);
- return CURLE_OUT_OF_MEMORY;
+ result = CURLE_OUT_OF_MEMORY;
+ goto unlock;
}
bundle = new_bundle;
}
- result = bundle_add_conn(bundle, conn);
- if(result) {
- if(new_bundle)
- conncache_remove_bundle(data->state.conn_cache, new_bundle);
- return result;
- }
-
+ bundle_add_conn(bundle, conn);
conn->connection_id = connc->next_connection_id++;
- connc->num_connections++;
+ connc->num_conn++;
DEBUGF(infof(conn->data, "Added connection %ld. "
- "The cache now contains %" CURL_FORMAT_CURL_OFF_TU " members\n",
- conn->connection_id, (curl_off_t) connc->num_connections));
+ "The cache now contains %zu members\n",
+ conn->connection_id, connc->num_conn));
- return CURLE_OK;
+ unlock:
+ CONN_UNLOCK(data);
+
+ return result;
}
-void Curl_conncache_remove_conn(struct conncache *connc,
- struct connectdata *conn)
+/*
+ * Removes the connectdata object from the connection cache *and* clears the
+ * ->data pointer association. Pass TRUE/FALSE in the 'lock' argument
+ * depending on if the parent function already holds the lock or not.
+ */
+void Curl_conncache_remove_conn(struct Curl_easy *data,
+ struct connectdata *conn, bool lock)
{
struct connectbundle *bundle = conn->bundle;
+ struct conncache *connc = data->state.conn_cache;
/* The bundle pointer can be NULL, since this function can be called
due to a failed connection attempt, before being added to a bundle */
if(bundle) {
+ if(lock) {
+ CONN_LOCK(data);
+ }
bundle_remove_conn(bundle, conn);
- if(bundle->num_connections == 0) {
+ if(bundle->num_connections == 0)
conncache_remove_bundle(connc, bundle);
- }
-
+ conn->bundle = NULL; /* removed from it */
if(connc) {
- connc->num_connections--;
-
- DEBUGF(infof(conn->data, "The cache now contains %"
- CURL_FORMAT_CURL_OFF_TU " members\n",
- (curl_off_t) connc->num_connections));
+ connc->num_conn--;
+ DEBUGF(infof(data, "The cache now contains %zu members\n",
+ connc->num_conn));
+ }
+ conn->data = NULL; /* clear the association */
+ if(lock) {
+ CONN_UNLOCK(data);
}
}
}
-/* This function iterates the entire connection cache and calls the
- function func() with the connection pointer as the first argument
- and the supplied 'param' argument as the other,
+/* This function iterates the entire connection cache and calls the function
+ func() with the connection pointer as the first argument and the supplied
+ 'param' argument as the other.
+
+ The conncache lock is still held when the callback is called. It needs it,
+ so that it can safely continue traversing the lists once the callback
+ returns.
+
+ Returns 1 if the loop was aborted due to the callback's return code.
Return 0 from func() to continue the loop, return 1 to abort it.
*/
-void Curl_conncache_foreach(struct conncache *connc,
+bool Curl_conncache_foreach(struct Curl_easy *data,
+ struct conncache *connc,
void *param,
int (*func)(struct connectdata *conn, void *param))
{
@@ -270,8 +357,9 @@ void Curl_conncache_foreach(struct conncache *connc,
struct curl_hash_element *he;
if(!connc)
- return;
+ return FALSE;
+ CONN_LOCK(data);
Curl_hash_start_iterate(&connc->hash, &iter);
he = Curl_hash_next_element(&iter);
@@ -288,16 +376,24 @@ void Curl_conncache_foreach(struct conncache *connc,
struct connectdata *conn = curr->ptr;
curr = curr->next;
- if(1 == func(conn, param))
- return;
+ if(1 == func(conn, param)) {
+ CONN_UNLOCK(data);
+ return TRUE;
+ }
}
}
+ CONN_UNLOCK(data);
+ return FALSE;
}
/* Return the first connection found in the cache. Used when closing all
- connections */
-struct connectdata *
-Curl_conncache_find_first_connection(struct conncache *connc)
+ connections.
+
+ NOTE: no locking is done here as this is presumably only done when cleaning
+ up a cache!
+*/
+static struct connectdata *
+conncache_find_first_connection(struct conncache *connc)
{
struct curl_hash_iterator iter;
struct curl_hash_element *he;
@@ -321,6 +417,181 @@ Curl_conncache_find_first_connection(struct conncache *connc)
return NULL;
}
+/*
+ * Give ownership of a connection back to the connection cache. Might
+ * disconnect the oldest existing in there to make space.
+ *
+ * Return TRUE if stored, FALSE if closed.
+ */
+bool Curl_conncache_return_conn(struct connectdata *conn)
+{
+ struct Curl_easy *data = conn->data;
+
+ /* data->multi->maxconnects can be negative, deal with it. */
+ size_t maxconnects =
+ (data->multi->maxconnects < 0) ? data->multi->num_easy * 4:
+ data->multi->maxconnects;
+ struct connectdata *conn_candidate = NULL;
+
+ conn->data = NULL; /* no owner anymore */
+ conn->lastused = Curl_now(); /* it was used up until now */
+ if(maxconnects > 0 &&
+ Curl_conncache_size(data) > maxconnects) {
+ infof(data, "Connection cache is full, closing the oldest one.\n");
+
+ conn_candidate = Curl_conncache_extract_oldest(data);
+ if(conn_candidate) {
+ /* the winner gets the honour of being disconnected */
+ (void)Curl_disconnect(data, conn_candidate, /* dead_connection */ FALSE);
+ }
+ }
+
+ return (conn_candidate == conn) ? FALSE : TRUE;
+
+}
+
+/*
+ * This function finds the connection in the connection bundle that has been
+ * unused for the longest time.
+ *
+ * Does not lock the connection cache!
+ *
+ * Returns the pointer to the oldest idle connection, or NULL if none was
+ * found.
+ */
+struct connectdata *
+Curl_conncache_extract_bundle(struct Curl_easy *data,
+ struct connectbundle *bundle)
+{
+ struct curl_llist_element *curr;
+ timediff_t highscore = -1;
+ timediff_t score;
+ struct curltime now;
+ struct connectdata *conn_candidate = NULL;
+ struct connectdata *conn;
+
+ (void)data;
+
+ now = Curl_now();
+
+ curr = bundle->conn_list.head;
+ while(curr) {
+ conn = curr->ptr;
+
+ if(!CONN_INUSE(conn) && !conn->data) {
+ /* Set higher score for the age passed since the connection was used */
+ score = Curl_timediff(now, conn->lastused);
+
+ if(score > highscore) {
+ highscore = score;
+ conn_candidate = conn;
+ }
+ }
+ curr = curr->next;
+ }
+ if(conn_candidate) {
+ /* remove it to prevent another thread from nicking it */
+ bundle_remove_conn(bundle, conn_candidate);
+ data->state.conn_cache->num_conn--;
+ DEBUGF(infof(data, "The cache now contains %zu members\n",
+ data->state.conn_cache->num_conn));
+ conn_candidate->data = data; /* associate! */
+ }
+
+ return conn_candidate;
+}
+
+/*
+ * This function finds the connection in the connection cache that has been
+ * unused for the longest time and extracts that from the bundle.
+ *
+ * Returns the pointer to the connection, or NULL if none was found.
+ */
+struct connectdata *
+Curl_conncache_extract_oldest(struct Curl_easy *data)
+{
+ struct conncache *connc = data->state.conn_cache;
+ struct curl_hash_iterator iter;
+ struct curl_llist_element *curr;
+ struct curl_hash_element *he;
+ timediff_t highscore =- 1;
+ timediff_t score;
+ struct curltime now;
+ struct connectdata *conn_candidate = NULL;
+ struct connectbundle *bundle;
+ struct connectbundle *bundle_candidate = NULL;
+
+ now = Curl_now();
+
+ CONN_LOCK(data);
+ Curl_hash_start_iterate(&connc->hash, &iter);
+
+ he = Curl_hash_next_element(&iter);
+ while(he) {
+ struct connectdata *conn;
+
+ bundle = he->ptr;
+
+ curr = bundle->conn_list.head;
+ while(curr) {
+ conn = curr->ptr;
+
+ if(!CONN_INUSE(conn) && !conn->data) {
+ /* Set higher score for the age passed since the connection was used */
+ score = Curl_timediff(now, conn->lastused);
+
+ if(score > highscore) {
+ highscore = score;
+ conn_candidate = conn;
+ bundle_candidate = bundle;
+ }
+ }
+ curr = curr->next;
+ }
+
+ he = Curl_hash_next_element(&iter);
+ }
+ if(conn_candidate) {
+ /* remove it to prevent another thread from nicking it */
+ bundle_remove_conn(bundle_candidate, conn_candidate);
+ connc->num_conn--;
+ DEBUGF(infof(data, "The cache now contains %zu members\n",
+ connc->num_conn));
+ conn_candidate->data = data; /* associate! */
+ }
+ CONN_UNLOCK(data);
+
+ return conn_candidate;
+}
+
+void Curl_conncache_close_all_connections(struct conncache *connc)
+{
+ struct connectdata *conn;
+
+ conn = conncache_find_first_connection(connc);
+ while(conn) {
+ SIGPIPE_VARIABLE(pipe_st);
+ conn->data = connc->closure_handle;
+
+ sigpipe_ignore(conn->data, &pipe_st);
+ /* This will remove the connection from the cache */
+ connclose(conn, "kill all");
+ (void)Curl_disconnect(connc->closure_handle, conn, FALSE);
+ sigpipe_restore(&pipe_st);
+
+ conn = conncache_find_first_connection(connc);
+ }
+
+ if(connc->closure_handle) {
+ SIGPIPE_VARIABLE(pipe_st);
+ sigpipe_ignore(connc->closure_handle, &pipe_st);
+
+ Curl_hostcache_clean(connc->closure_handle,
+ connc->closure_handle->dns.hostcache);
+ Curl_close(connc->closure_handle);
+ sigpipe_restore(&pipe_st);
+ }
+}
#if 0
/* Useful for debugging the connection cache */
diff --git a/Utilities/cmcurl/lib/conncache.h b/Utilities/cmcurl/lib/conncache.h
index f976cfdb4..35be9e0aa 100644
--- a/Utilities/cmcurl/lib/conncache.h
+++ b/Utilities/cmcurl/lib/conncache.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2015 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2015 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2012 - 2014, Linus Nielsen Feltzing, <linus@haxx.se>
*
* This software is licensed as described in the file COPYING, which
@@ -23,16 +23,23 @@
*
***************************************************************************/
+/*
+ * All accesses to struct fields and changing of data in the connection cache
+ * and connectbundles must be done with the conncache LOCKED. The cache might
+ * be shared.
+ */
+
struct conncache {
struct curl_hash hash;
- size_t num_connections;
+ size_t num_conn;
long next_connection_id;
- struct timeval last_cleanup;
+ struct curltime last_cleanup;
+ /* handle used for closing cached connections */
+ struct Curl_easy *closure_handle;
};
#define BUNDLE_NO_MULTIUSE -1
#define BUNDLE_UNKNOWN 0 /* initial value */
-#define BUNDLE_PIPELINING 1
#define BUNDLE_MULTIPLEX 2
struct connectbundle {
@@ -41,21 +48,26 @@ struct connectbundle {
struct curl_llist conn_list; /* The connectdata members of the bundle */
};
+/* returns 1 on error, 0 is fine */
int Curl_conncache_init(struct conncache *, int size);
-
void Curl_conncache_destroy(struct conncache *connc);
/* return the correct bundle, to a host or a proxy */
struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn,
struct conncache *connc);
+void Curl_conncache_unlock(struct Curl_easy *data);
+/* returns number of connections currently held in the connection cache */
+size_t Curl_conncache_size(struct Curl_easy *data);
+size_t Curl_conncache_bundle_size(struct connectdata *conn);
+bool Curl_conncache_return_conn(struct connectdata *conn);
CURLcode Curl_conncache_add_conn(struct conncache *connc,
- struct connectdata *conn);
-
-void Curl_conncache_remove_conn(struct conncache *connc,
- struct connectdata *conn);
-
-void Curl_conncache_foreach(struct conncache *connc,
+ struct connectdata *conn) WARN_UNUSED_RESULT;
+void Curl_conncache_remove_conn(struct Curl_easy *data,
+ struct connectdata *conn,
+ bool lock);
+bool Curl_conncache_foreach(struct Curl_easy *data,
+ struct conncache *connc,
void *param,
int (*func)(struct connectdata *conn,
void *param));
@@ -63,6 +75,12 @@ void Curl_conncache_foreach(struct conncache *connc,
struct connectdata *
Curl_conncache_find_first_connection(struct conncache *connc);
+struct connectdata *
+Curl_conncache_extract_bundle(struct Curl_easy *data,
+ struct connectbundle *bundle);
+struct connectdata *
+Curl_conncache_extract_oldest(struct Curl_easy *data);
+void Curl_conncache_close_all_connections(struct conncache *connc);
void Curl_conncache_print(struct conncache *connc);
#endif /* HEADER_CURL_CONNCACHE_H */
diff --git a/Utilities/cmcurl/lib/connect.c b/Utilities/cmcurl/lib/connect.c
index d4fd52b99..002535b42 100644
--- a/Utilities/cmcurl/lib/connect.c
+++ b/Utilities/cmcurl/lib/connect.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -28,8 +28,10 @@
#ifdef HAVE_SYS_UN_H
#include <sys/un.h> /* for sockaddr_un */
#endif
-#ifdef HAVE_NETINET_TCP_H
-#include <netinet/tcp.h> /* for TCP_NODELAY */
+#ifdef HAVE_LINUX_TCP_H
+#include <linux/tcp.h>
+#elif defined(HAVE_NETINET_TCP_H)
+#include <netinet/tcp.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
@@ -179,13 +181,13 @@ singleipconnect(struct connectdata *conn,
*
* @unittest: 1303
*/
-time_t Curl_timeleft(struct Curl_easy *data,
- struct timeval *nowp,
- bool duringconnect)
+timediff_t Curl_timeleft(struct Curl_easy *data,
+ struct curltime *nowp,
+ bool duringconnect)
{
int timeout_set = 0;
- time_t timeout_ms = duringconnect?DEFAULT_CONNECT_TIMEOUT:0;
- struct timeval now;
+ timediff_t timeout_ms = duringconnect?DEFAULT_CONNECT_TIMEOUT:0;
+ struct curltime now;
/* if a timeout is set, use the most restrictive one */
@@ -218,17 +220,17 @@ time_t Curl_timeleft(struct Curl_easy *data,
}
if(!nowp) {
- now = Curl_tvnow();
+ now = Curl_now();
nowp = &now;
}
/* subtract elapsed time */
if(duringconnect)
/* since this most recent connect started */
- timeout_ms -= Curl_tvdiff(*nowp, data->progress.t_startsingle);
+ timeout_ms -= Curl_timediff(*nowp, data->progress.t_startsingle);
else
/* since the entire operation started */
- timeout_ms -= Curl_tvdiff(*nowp, data->progress.t_startop);
+ timeout_ms -= Curl_timediff(*nowp, data->progress.t_startop);
if(!timeout_ms)
/* avoid returning 0 as that means no timeout! */
return -1;
@@ -249,7 +251,7 @@ static CURLcode bindlocal(struct connectdata *conn,
struct sockaddr_in6 *si6 = (struct sockaddr_in6 *)&sa;
#endif
- struct Curl_dns_entry *h=NULL;
+ struct Curl_dns_entry *h = NULL;
unsigned short port = data->set.localport; /* use this port number, 0 for
"random" */
/* how many port numbers to try to bind to, increasing one at a time */
@@ -285,6 +287,34 @@ static CURLcode bindlocal(struct connectdata *conn,
/* interface */
if(!is_host) {
+#ifdef SO_BINDTODEVICE
+ /* I am not sure any other OSs than Linux that provide this feature,
+ * and at the least I cannot test. --Ben
+ *
+ * This feature allows one to tightly bind the local socket to a
+ * particular interface. This will force even requests to other
+ * local interfaces to go out the external interface.
+ *
+ *
+ * Only bind to the interface when specified as interface, not just
+ * as a hostname or ip address.
+ *
+ * interface might be a VRF, eg: vrf-blue, which means it cannot be
+ * converted to an IP address and would fail Curl_if2ip. Simply try
+ * to use it straight away.
+ */
+ if(setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
+ dev, (curl_socklen_t)strlen(dev) + 1) == 0) {
+ /* This is typically "errno 1, error: Operation not permitted" if
+ * you're not running as root or another suitable privileged
+ * user.
+ * If it succeeds it means the parameter was a valid interface and
+ * not an IP address. Return immediately.
+ */
+ return CURLE_OK;
+ }
+#endif
+
switch(Curl_if2ip(af, scope, conn->scope_id, dev,
myhost, sizeof(myhost))) {
case IF2IP_NOT_FOUND:
@@ -305,30 +335,6 @@ static CURLcode bindlocal(struct connectdata *conn,
infof(data, "Local Interface %s is ip %s using address family %i\n",
dev, myhost, af);
done = 1;
-
-#ifdef SO_BINDTODEVICE
- /* I am not sure any other OSs than Linux that provide this feature,
- * and at the least I cannot test. --Ben
- *
- * This feature allows one to tightly bind the local socket to a
- * particular interface. This will force even requests to other
- * local interfaces to go out the external interface.
- *
- *
- * Only bind to the interface when specified as interface, not just
- * as a hostname or ip address.
- */
- if(setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
- dev, (curl_socklen_t)strlen(dev)+1) != 0) {
- error = SOCKERRNO;
- infof(data, "SO_BINDTODEVICE %s failed with errno %d: %s;"
- " will do regular bind\n",
- dev, error, Curl_strerror(conn, error));
- /* This is typically "errno 1, error: Operation not permitted" if
- you're not running as root or another suitable privileged
- user */
- }
-#endif
break;
}
}
@@ -351,7 +357,7 @@ static CURLcode bindlocal(struct connectdata *conn,
conn->ip_version = CURL_IPRESOLVE_V6;
#endif
- rc = Curl_resolv(conn, dev, 0, &h);
+ rc = Curl_resolv(conn, dev, 0, FALSE, &h);
if(rc == CURLRESOLV_PENDING)
(void)Curl_resolver_wait_resolv(conn, &h);
conn->ip_version = ipver;
@@ -408,6 +414,10 @@ static CURLcode bindlocal(struct connectdata *conn,
}
if(done < 1) {
+ /* errorbuf is set false so failf will overwrite any message already in
+ the error buffer, so the user receives this error message instead of a
+ generic resolve error. */
+ data->state.errorbuf = FALSE;
failf(data, "Couldn't bind to '%s'", dev);
return CURLE_INTERFACE_FAILED;
}
@@ -436,9 +446,10 @@ static CURLcode bindlocal(struct connectdata *conn,
curl_socklen_t size = sizeof(add);
memset(&add, 0, sizeof(struct Curl_sockaddr_storage));
if(getsockname(sockfd, (struct sockaddr *) &add, &size) < 0) {
+ char buffer[STRERROR_LEN];
data->state.os_errno = error = SOCKERRNO;
failf(data, "getsockname() failed with errno %d: %s",
- error, Curl_strerror(conn, error));
+ error, Curl_strerror(error, buffer, sizeof(buffer)));
return CURLE_INTERFACE_FAILED;
}
infof(data, "Local port: %hu\n", port);
@@ -460,10 +471,12 @@ static CURLcode bindlocal(struct connectdata *conn,
else
break;
}
-
- data->state.os_errno = error = SOCKERRNO;
- failf(data, "bind failed with errno %d: %s",
- error, Curl_strerror(conn, error));
+ {
+ char buffer[STRERROR_LEN];
+ data->state.os_errno = error = SOCKERRNO;
+ failf(data, "bind failed with errno %d: %s",
+ error, Curl_strerror(error, buffer, sizeof(buffer)));
+ }
return CURLE_INTERFACE_FAILED;
}
@@ -512,7 +525,7 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
err = 0;
}
#endif
-#ifdef __minix
+#if defined(EBADIOCTL) && defined(__minix)
/* Minix 3.1.x doesn't support getsockopt on UDP sockets */
if(EBADIOCTL == err) {
SET_SOCKERRNO(0);
@@ -607,11 +620,14 @@ void Curl_persistconninfo(struct connectdata *conn)
conn->data->info.conn_local_port = conn->local_port;
}
-/* retrieves ip address and port from a sockaddr structure */
-static bool getaddressinfo(struct sockaddr *sa, char *addr,
- long *port)
+UNITTEST bool getaddressinfo(struct sockaddr *sa, char *addr,
+ long *port);
+
+/* retrieves ip address and port from a sockaddr structure.
+ note it calls Curl_inet_ntop which sets errno on fail, not SOCKERRNO. */
+UNITTEST bool getaddressinfo(struct sockaddr *sa, char *addr,
+ long *port)
{
- unsigned short us_port;
struct sockaddr_in *si = NULL;
#ifdef ENABLE_IPV6
struct sockaddr_in6 *si6 = NULL;
@@ -625,7 +641,7 @@ static bool getaddressinfo(struct sockaddr *sa, char *addr,
si = (struct sockaddr_in *)(void *) sa;
if(Curl_inet_ntop(sa->sa_family, &si->sin_addr,
addr, MAX_IPADR_LEN)) {
- us_port = ntohs(si->sin_port);
+ unsigned short us_port = ntohs(si->sin_port);
*port = us_port;
return TRUE;
}
@@ -635,7 +651,7 @@ static bool getaddressinfo(struct sockaddr *sa, char *addr,
si6 = (struct sockaddr_in6 *)(void *) sa;
if(Curl_inet_ntop(sa->sa_family, &si6->sin6_addr,
addr, MAX_IPADR_LEN)) {
- us_port = ntohs(si6->sin6_port);
+ unsigned short us_port = ntohs(si6->sin6_port);
*port = us_port;
return TRUE;
}
@@ -644,7 +660,7 @@ static bool getaddressinfo(struct sockaddr *sa, char *addr,
#if defined(HAVE_SYS_UN_H) && defined(AF_UNIX)
case AF_UNIX:
su = (struct sockaddr_un*)sa;
- snprintf(addr, MAX_IPADR_LEN, "%s", su->sun_path);
+ msnprintf(addr, MAX_IPADR_LEN, "%s", su->sun_path);
*port = 0;
return TRUE;
#endif
@@ -654,7 +670,7 @@ static bool getaddressinfo(struct sockaddr *sa, char *addr,
addr[0] = '\0';
*port = 0;
-
+ errno = EAFNOSUPPORT;
return FALSE;
}
@@ -662,53 +678,57 @@ static bool getaddressinfo(struct sockaddr *sa, char *addr,
connection */
void Curl_updateconninfo(struct connectdata *conn, curl_socket_t sockfd)
{
- curl_socklen_t len;
- struct Curl_sockaddr_storage ssrem;
- struct Curl_sockaddr_storage ssloc;
- struct Curl_easy *data = conn->data;
-
if(conn->socktype == SOCK_DGRAM)
/* there's no connection! */
return;
+#if defined(HAVE_GETPEERNAME) || defined(HAVE_GETSOCKNAME)
if(!conn->bits.reuse && !conn->bits.tcp_fastopen) {
- int error;
-
+ struct Curl_easy *data = conn->data;
+ char buffer[STRERROR_LEN];
+ struct Curl_sockaddr_storage ssrem;
+ struct Curl_sockaddr_storage ssloc;
+ curl_socklen_t len;
+#ifdef HAVE_GETPEERNAME
len = sizeof(struct Curl_sockaddr_storage);
if(getpeername(sockfd, (struct sockaddr*) &ssrem, &len)) {
- error = SOCKERRNO;
+ int error = SOCKERRNO;
failf(data, "getpeername() failed with errno %d: %s",
- error, Curl_strerror(conn, error));
+ error, Curl_strerror(error, buffer, sizeof(buffer)));
return;
}
-
+#endif
+#ifdef HAVE_GETSOCKNAME
len = sizeof(struct Curl_sockaddr_storage);
memset(&ssloc, 0, sizeof(ssloc));
if(getsockname(sockfd, (struct sockaddr*) &ssloc, &len)) {
- error = SOCKERRNO;
+ int error = SOCKERRNO;
failf(data, "getsockname() failed with errno %d: %s",
- error, Curl_strerror(conn, error));
+ error, Curl_strerror(error, buffer, sizeof(buffer)));
return;
}
-
+#endif
+#ifdef HAVE_GETPEERNAME
if(!getaddressinfo((struct sockaddr*)&ssrem,
- conn->primary_ip, &conn->primary_port)) {
- error = ERRNO;
+ conn->primary_ip, &conn->primary_port)) {
failf(data, "ssrem inet_ntop() failed with errno %d: %s",
- error, Curl_strerror(conn, error));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
return;
}
memcpy(conn->ip_addr_str, conn->primary_ip, MAX_IPADR_LEN);
-
+#endif
+#ifdef HAVE_GETSOCKNAME
if(!getaddressinfo((struct sockaddr*)&ssloc,
conn->local_ip, &conn->local_port)) {
- error = ERRNO;
failf(data, "ssloc inet_ntop() failed with errno %d: %s",
- error, Curl_strerror(conn, error));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
return;
}
-
+#endif
}
+#else /* !HAVE_GETSOCKNAME && !HAVE_GETPEERNAME */
+ (void)sockfd; /* unused */
+#endif
/* persist connection info in session handle */
Curl_persistconninfo(conn);
@@ -724,9 +744,9 @@ CURLcode Curl_is_connected(struct connectdata *conn,
{
struct Curl_easy *data = conn->data;
CURLcode result = CURLE_OK;
- time_t allow;
+ timediff_t allow;
int error = 0;
- struct timeval now;
+ struct curltime now;
int rc;
int i;
@@ -740,7 +760,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
return CURLE_OK;
}
- now = Curl_tvnow();
+ now = Curl_now();
/* figure out how long time we have left to connect */
allow = Curl_timeleft(data, &now, TRUE);
@@ -751,7 +771,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
return CURLE_OPERATION_TIMEDOUT;
}
- for(i=0; i<2; i++) {
+ for(i = 0; i<2; i++) {
const int other = i ^ 1;
if(conn->tempsock[i] == CURL_SOCKET_BAD)
continue;
@@ -768,7 +788,7 @@ CURLcode Curl_is_connected(struct connectdata *conn,
if(rc == 0) { /* no connection yet */
error = 0;
- if(curlx_tvdiff(now, conn->connecttime) >= conn->timeoutms_per_addr) {
+ if(Curl_timediff(now, conn->connecttime) >= conn->timeoutms_per_addr) {
infof(data, "After %ldms connect time, move on!\n",
conn->timeoutms_per_addr);
error = ETIMEDOUT;
@@ -776,7 +796,8 @@ CURLcode Curl_is_connected(struct connectdata *conn,
/* should we try another protocol family? */
if(i == 0 && conn->tempaddr[1] == NULL &&
- curlx_tvdiff(now, conn->connecttime) >= HAPPY_EYEBALLS_TIMEOUT) {
+ (Curl_timediff(now, conn->connecttime) >=
+ data->set.happy_eyeballs_timeout)) {
trynextip(conn, sockindex, 1);
}
}
@@ -788,6 +809,9 @@ CURLcode Curl_is_connected(struct connectdata *conn,
conn->sock[sockindex] = conn->tempsock[i];
conn->ip_addr = conn->tempaddr[i];
conn->tempsock[i] = CURL_SOCKET_BAD;
+#ifdef ENABLE_IPV6
+ conn->bits.ipv6 = (conn->ip_addr->ai_family == AF_INET6)?TRUE:FALSE;
+#endif
/* close the other socket, if open */
if(conn->tempsock[other] != CURL_SOCKET_BAD) {
@@ -825,9 +849,11 @@ CURLcode Curl_is_connected(struct connectdata *conn,
if(conn->tempaddr[i]) {
CURLcode status;
char ipaddress[MAX_IPADR_LEN];
+ char buffer[STRERROR_LEN];
Curl_printable_address(conn->tempaddr[i], ipaddress, MAX_IPADR_LEN);
infof(data, "connect to %s port %ld failed: %s\n",
- ipaddress, conn->port, Curl_strerror(conn, error));
+ ipaddress, conn->port,
+ Curl_strerror(error, buffer, sizeof(buffer)));
conn->timeoutms_per_addr = conn->tempaddr[i]->ai_next == NULL ?
allow : allow / 2;
@@ -843,8 +869,8 @@ CURLcode Curl_is_connected(struct connectdata *conn,
if(result) {
/* no more addresses to try */
-
const char *hostname;
+ char buffer[STRERROR_LEN];
/* if the first address family runs out of addresses to try before
the happy eyeball timeout, go ahead and try the next family now */
@@ -864,13 +890,14 @@ CURLcode Curl_is_connected(struct connectdata *conn,
hostname = conn->host.name;
failf(data, "Failed to connect to %s port %ld: %s",
- hostname, conn->port, Curl_strerror(conn, error));
+ hostname, conn->port,
+ Curl_strerror(error, buffer, sizeof(buffer)));
}
return result;
}
-void Curl_tcpnodelay(struct connectdata *conn, curl_socket_t sockfd)
+static void tcpnodelay(struct connectdata *conn, curl_socket_t sockfd)
{
#if defined(TCP_NODELAY)
#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
@@ -878,19 +905,7 @@ void Curl_tcpnodelay(struct connectdata *conn, curl_socket_t sockfd)
#endif
curl_socklen_t onoff = (curl_socklen_t) 1;
int level = IPPROTO_TCP;
-
-#if 0
- /* The use of getprotobyname() is disabled since it isn't thread-safe on
- numerous systems. On these getprotobyname_r() should be used instead, but
- that exists in at least one 4 arg version and one 5 arg version, and
- since the proto number rarely changes anyway we now just use the hard
- coded number. The "proper" fix would need a configure check for the
- correct function much in the same style the gethostbyname_r versions are
- detected. */
- struct protoent *pe = getprotobyname("tcp");
- if(pe)
- level = pe->p_proto;
-#endif
+ char buffer[STRERROR_LEN];
#if defined(CURL_DISABLE_VERBOSE_STRINGS)
(void) conn;
@@ -899,7 +914,7 @@ void Curl_tcpnodelay(struct connectdata *conn, curl_socket_t sockfd)
if(setsockopt(sockfd, level, TCP_NODELAY, (void *)&onoff,
sizeof(onoff)) < 0)
infof(data, "Could not set TCP_NODELAY: %s\n",
- Curl_strerror(conn, SOCKERRNO));
+ Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
else
infof(data, "TCP_NODELAY set\n");
#else
@@ -916,12 +931,14 @@ void Curl_tcpnodelay(struct connectdata *conn, curl_socket_t sockfd)
static void nosigpipe(struct connectdata *conn,
curl_socket_t sockfd)
{
- struct Curl_easy *data= conn->data;
+ struct Curl_easy *data = conn->data;
int onoff = 1;
if(setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&onoff,
- sizeof(onoff)) < 0)
+ sizeof(onoff)) < 0) {
+ char buffer[STRERROR_LEN];
infof(data, "Could not set SO_NOSIGPIPE: %s\n",
- Curl_strerror(conn, SOCKERRNO));
+ Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
+ }
}
#else
#define nosigpipe(x,y) Curl_nop_stmt
@@ -994,6 +1011,10 @@ static CURLcode singleipconnect(struct connectdata *conn,
char ipaddress[MAX_IPADR_LEN];
long port;
bool is_tcp;
+#ifdef TCP_FASTOPEN_CONNECT
+ int optval = 1;
+#endif
+ char buffer[STRERROR_LEN];
*sockp = CURL_SOCKET_BAD;
@@ -1008,13 +1029,12 @@ static CURLcode singleipconnect(struct connectdata *conn,
if(!getaddressinfo((struct sockaddr*)&addr.sa_addr,
ipaddress, &port)) {
/* malformed address or bug in inet_ntop, try next address */
- error = ERRNO;
failf(data, "sa_addr inet_ntop() failed with errno %d: %s",
- error, Curl_strerror(conn, error));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
Curl_closesocket(conn, sockfd);
return CURLE_OK;
}
- infof(data, " Trying %s...\n", ipaddress);
+ infof(data, " Trying %s:%ld...\n", ipaddress, port);
#ifdef ENABLE_IPV6
is_tcp = (addr.family == AF_INET || addr.family == AF_INET6) &&
@@ -1023,7 +1043,7 @@ static CURLcode singleipconnect(struct connectdata *conn,
is_tcp = (addr.family == AF_INET) && addr.socktype == SOCK_STREAM;
#endif
if(is_tcp && data->set.tcp_nodelay)
- Curl_tcpnodelay(conn, sockfd);
+ tcpnodelay(conn, sockfd);
nosigpipe(conn, sockfd);
@@ -1034,9 +1054,11 @@ static CURLcode singleipconnect(struct connectdata *conn,
if(data->set.fsockopt) {
/* activate callback for setting socket options */
+ Curl_set_in_callback(data, true);
error = data->set.fsockopt(data->set.sockopt_client,
sockfd,
CURLSOCKTYPE_IPCXN);
+ Curl_set_in_callback(data, false);
if(error == CURL_SOCKOPT_ALREADY_CONNECTED)
isconnected = TRUE;
@@ -1068,25 +1090,45 @@ static CURLcode singleipconnect(struct connectdata *conn,
/* set socket non-blocking */
(void)curlx_nonblock(sockfd, TRUE);
- conn->connecttime = Curl_tvnow();
+ conn->connecttime = Curl_now();
if(conn->num_addr > 1)
Curl_expire(data, conn->timeoutms_per_addr, EXPIRE_DNS_PER_NAME);
/* Connect TCP sockets, bind UDP */
if(!isconnected && (conn->socktype == SOCK_STREAM)) {
if(conn->bits.tcp_fastopen) {
-#if defined(CONNECT_DATA_IDEMPOTENT) /* OS X */
- sa_endpoints_t endpoints;
- endpoints.sae_srcif = 0;
- endpoints.sae_srcaddr = NULL;
- endpoints.sae_srcaddrlen = 0;
- endpoints.sae_dstaddr = &addr.sa_addr;
- endpoints.sae_dstaddrlen = addr.addrlen;
-
- rc = connectx(sockfd, &endpoints, SAE_ASSOCID_ANY,
- CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT,
- NULL, 0, NULL, NULL);
-#elif defined(MSG_FASTOPEN) /* Linux */
+#if defined(CONNECT_DATA_IDEMPOTENT) /* Darwin */
+# if defined(HAVE_BUILTIN_AVAILABLE)
+ /* while connectx function is available since macOS 10.11 / iOS 9,
+ it did not have the interface declared correctly until
+ Xcode 9 / macOS SDK 10.13 */
+ if(__builtin_available(macOS 10.11, iOS 9.0, tvOS 9.0, watchOS 2.0, *)) {
+ sa_endpoints_t endpoints;
+ endpoints.sae_srcif = 0;
+ endpoints.sae_srcaddr = NULL;
+ endpoints.sae_srcaddrlen = 0;
+ endpoints.sae_dstaddr = &addr.sa_addr;
+ endpoints.sae_dstaddrlen = addr.addrlen;
+
+ rc = connectx(sockfd, &endpoints, SAE_ASSOCID_ANY,
+ CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT,
+ NULL, 0, NULL, NULL);
+ }
+ else {
+ rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
+ }
+# else
+ rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
+# endif /* HAVE_BUILTIN_AVAILABLE */
+#elif defined(TCP_FASTOPEN_CONNECT) /* Linux >= 4.11 */
+ if(setsockopt(sockfd, IPPROTO_TCP, TCP_FASTOPEN_CONNECT,
+ (void *)&optval, sizeof(optval)) < 0)
+ infof(data, "Failed to enable TCP Fast Open on fd %d\n", sockfd);
+ else
+ infof(data, "TCP_FASTOPEN_CONNECT set\n");
+
+ rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
+#elif defined(MSG_FASTOPEN) /* old Linux */
if(conn->given->flags & PROTOPT_SSL)
rc = connect(sockfd, &addr.sa_addr, addr.addrlen);
else
@@ -1105,10 +1147,6 @@ static CURLcode singleipconnect(struct connectdata *conn,
return CURLE_OK;
}
-#ifdef ENABLE_IPV6
- conn->bits.ipv6 = (addr.family == AF_INET6)?TRUE:FALSE;
-#endif
-
if(-1 == rc) {
switch(error) {
case EINPROGRESS:
@@ -1128,7 +1166,7 @@ static CURLcode singleipconnect(struct connectdata *conn,
default:
/* unknown error, fallthrough and try another address! */
infof(data, "Immediate connect fail for %s: %s\n",
- ipaddress, Curl_strerror(conn, error));
+ ipaddress, Curl_strerror(error, buffer, sizeof(buffer)));
data->state.os_errno = error;
/* connect failed */
@@ -1153,10 +1191,10 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
const struct Curl_dns_entry *remotehost)
{
struct Curl_easy *data = conn->data;
- struct timeval before = Curl_tvnow();
+ struct curltime before = Curl_now();
CURLcode result = CURLE_COULDNT_CONNECT;
- time_t timeout_ms = Curl_timeleft(data, &before, TRUE);
+ timediff_t timeout_ms = Curl_timeleft(data, &before, TRUE);
if(timeout_ms < 0) {
/* a precaution, no need to continue if time already is up */
@@ -1169,7 +1207,6 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
conn->tempaddr[1] = NULL;
conn->tempsock[0] = CURL_SOCKET_BAD;
conn->tempsock[1] = CURL_SOCKET_BAD;
- Curl_expire(conn->data, HAPPY_EYEBALLS_TIMEOUT, EXPIRE_HAPPY_EYEBALLS);
/* Max time for the next connection attempt */
conn->timeoutms_per_addr =
@@ -1190,6 +1227,8 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
}
data->info.numconnects++; /* to track the number of connections made */
+ Curl_expire(conn->data, data->set.happy_eyeballs_timeout,
+ EXPIRE_HAPPY_EYEBALLS);
return CURLE_OK;
}
@@ -1218,8 +1257,6 @@ static int conn_is_conn(struct connectdata *conn, void *param)
curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
struct connectdata **connp)
{
- curl_socket_t sockfd;
-
DEBUGASSERT(data);
/* this works for an easy handle:
@@ -1233,7 +1270,7 @@ curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
find.tofind = data->state.lastconnect;
find.found = FALSE;
- Curl_conncache_foreach(data->multi_easy?
+ Curl_conncache_foreach(data, data->multi_easy?
&data->multi_easy->conn_cache:
&data->multi->conn_cache, &find, conn_is_conn);
@@ -1242,15 +1279,15 @@ curl_socket_t Curl_getconnectinfo(struct Curl_easy *data,
return CURL_SOCKET_BAD;
}
- if(connp)
+ if(connp) {
/* only store this if the caller cares for it */
*connp = c;
- sockfd = c->sock[FIRSTSOCKET];
+ c->data = data;
+ }
+ return c->sock[FIRSTSOCKET];
}
else
return CURL_SOCKET_BAD;
-
- return sockfd;
}
/*
@@ -1296,14 +1333,18 @@ int Curl_closesocket(struct connectdata *conn,
status */
conn->sock_accepted[SECONDARYSOCKET] = FALSE;
else {
- Curl_multi_closed(conn, sock);
- return conn->fclosesocket(conn->closesocket_client, sock);
+ int rc;
+ Curl_multi_closed(conn->data, sock);
+ Curl_set_in_callback(conn->data, true);
+ rc = conn->fclosesocket(conn->closesocket_client, sock);
+ Curl_set_in_callback(conn->data, false);
+ return rc;
}
}
if(conn)
/* tell the multi-socket code about this */
- Curl_multi_closed(conn, sock);
+ Curl_multi_closed(conn->data, sock);
sclose(sock);
@@ -1341,14 +1382,14 @@ CURLcode Curl_socket(struct connectdata *conn,
addr->family = ai->ai_family;
addr->socktype = conn->socktype;
- addr->protocol = conn->socktype==SOCK_DGRAM?IPPROTO_UDP:ai->ai_protocol;
+ addr->protocol = conn->socktype == SOCK_DGRAM?IPPROTO_UDP:ai->ai_protocol;
addr->addrlen = ai->ai_addrlen;
if(addr->addrlen > sizeof(struct Curl_sockaddr_storage))
addr->addrlen = sizeof(struct Curl_sockaddr_storage);
memcpy(&addr->sa_addr, ai->ai_addr, addr->addrlen);
- if(data->set.fopensocket)
+ if(data->set.fopensocket) {
/*
* If the opensocket callback is set, all the destination address
* information is passed to the callback. Depending on this information the
@@ -1358,9 +1399,12 @@ CURLcode Curl_socket(struct connectdata *conn,
* might have been changed and this 'new' address will actually be used
* here to connect.
*/
+ Curl_set_in_callback(data, true);
*sockfd = data->set.fopensocket(data->set.opensocket_client,
CURLSOCKTYPE_IPCXN,
(struct curl_sockaddr *)addr);
+ Curl_set_in_callback(data, false);
+ }
else
/* opensocket callback not set, so simply create the socket now */
*sockfd = socket(addr->family, addr->socktype, addr->protocol);
@@ -1396,7 +1440,7 @@ void Curl_conncontrol(struct connectdata *conn,
if((ctrl == CONNCTRL_STREAM) &&
(conn->handler->flags & PROTOPT_STREAM))
DEBUGF(infof(conn->data, "Kill stream: %s\n", reason));
- else if(closeit != conn->bits.close) {
+ else if((bit)closeit != conn->bits.close) {
DEBUGF(infof(conn->data, "Marked for [%s]: %s\n",
closeit?"closure":"keep alive", reason));
conn->bits.close = closeit; /* the only place in the source code that
diff --git a/Utilities/cmcurl/lib/connect.h b/Utilities/cmcurl/lib/connect.h
index 44bdb1051..6a5c755cc 100644
--- a/Utilities/cmcurl/lib/connect.h
+++ b/Utilities/cmcurl/lib/connect.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -25,6 +25,7 @@
#include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */
#include "sockaddr.h"
+#include "timeval.h"
CURLcode Curl_is_connected(struct connectdata *conn,
int sockindex,
@@ -35,13 +36,11 @@ CURLcode Curl_connecthost(struct connectdata *conn,
/* generic function that returns how much time there's left to run, according
to the timeouts set */
-time_t Curl_timeleft(struct Curl_easy *data,
- struct timeval *nowp,
- bool duringconnect);
+timediff_t Curl_timeleft(struct Curl_easy *data,
+ struct curltime *nowp,
+ bool duringconnect);
#define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */
-#define HAPPY_EYEBALLS_TIMEOUT 200 /* milliseconds to wait between
- IPv4/IPv6 connection attempts */
/*
* Used to extract socket and connectdata struct for the most recent
@@ -107,8 +106,6 @@ CURLcode Curl_socket(struct connectdata *conn,
struct Curl_sockaddr_ex *addr,
curl_socket_t *sockfd);
-void Curl_tcpnodelay(struct connectdata *conn, curl_socket_t sockfd);
-
/*
* Curl_conncontrol() marks the end of a connection/stream. The 'closeit'
* argument specifies if it is the end of a connection or a stream.
diff --git a/Utilities/cmcurl/lib/content_encoding.c b/Utilities/cmcurl/lib/content_encoding.c
index 652ed9764..6d4753788 100644
--- a/Utilities/cmcurl/lib/content_encoding.c
+++ b/Utilities/cmcurl/lib/content_encoding.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,22 +22,43 @@
#include "curl_setup.h"
-#ifdef HAVE_LIBZ
-
#include "urldata.h"
#include <curl/curl.h>
+#include <stddef.h>
+
+#ifdef HAVE_ZLIB_H
+#include <zlib.h>
+#ifdef __SYMBIAN32__
+/* zlib pollutes the namespace with this definition */
+#undef WIN32
+#endif
+#endif
+
+#ifdef HAVE_BROTLI
+#include <brotli/decode.h>
+#endif
+
#include "sendf.h"
+#include "http.h"
#include "content_encoding.h"
#include "strdup.h"
+#include "strcase.h"
#include "curl_memory.h"
#include "memdebug.h"
+#define CONTENT_ENCODING_DEFAULT "identity"
+
+#ifndef CURL_DISABLE_HTTP
+
+#define DSIZ CURL_MAX_WRITE_SIZE /* buffer size for decompressed data */
+
+
+#ifdef HAVE_LIBZ
+
/* Comment this out if zlib is always going to be at least ver. 1.2.0.4
(doing so will reduce code size slightly). */
#define OLD_ZLIB_SUPPORT 1
-#define DSIZ CURL_MAX_WRITE_SIZE /* buffer size for decompressed data */
-
#define GZIP_MAGIC_0 0x1f
#define GZIP_MAGIC_1 0x8b
@@ -49,6 +70,24 @@
#define COMMENT 0x10 /* bit 4 set: file comment present */
#define RESERVED 0xE0 /* bits 5..7: reserved */
+typedef enum {
+ ZLIB_UNINIT, /* uninitialized */
+ ZLIB_INIT, /* initialized */
+ ZLIB_INFLATING, /* inflating started. */
+ ZLIB_EXTERNAL_TRAILER, /* reading external trailer */
+ ZLIB_GZIP_HEADER, /* reading gzip header */
+ ZLIB_GZIP_INFLATING, /* inflating gzip stream */
+ ZLIB_INIT_GZIP /* initialized in transparent gzip mode */
+} zlibInitState;
+
+/* Writer parameters. */
+typedef struct {
+ zlibInitState zlib_init; /* zlib init state */
+ uInt trailerlen; /* Remaining trailer byte count. */
+ z_stream z; /* State structure for zlib. */
+} zlib_params;
+
+
static voidpf
zalloc_cb(voidpf opaque, unsigned int items, unsigned int size)
{
@@ -79,114 +118,233 @@ process_zlib_error(struct connectdata *conn, z_stream *z)
}
static CURLcode
-exit_zlib(z_stream *z, zlibInitState *zlib_init, CURLcode result)
+exit_zlib(struct connectdata *conn,
+ z_stream *z, zlibInitState *zlib_init, CURLcode result)
{
- inflateEnd(z);
- *zlib_init = ZLIB_UNINIT;
+ if(*zlib_init == ZLIB_GZIP_HEADER)
+ Curl_safefree(z->next_in);
+
+ if(*zlib_init != ZLIB_UNINIT) {
+ if(inflateEnd(z) != Z_OK && result == CURLE_OK)
+ result = process_zlib_error(conn, z);
+ *zlib_init = ZLIB_UNINIT;
+ }
+
return result;
}
-static CURLcode
-inflate_stream(struct connectdata *conn,
- struct SingleRequest *k)
+static CURLcode process_trailer(struct connectdata *conn, zlib_params *zp)
{
- int allow_restart = 1;
- z_stream *z = &k->z; /* zlib state structure */
+ z_stream *z = &zp->z;
+ CURLcode result = CURLE_OK;
+ uInt len = z->avail_in < zp->trailerlen? z->avail_in: zp->trailerlen;
+
+ /* Consume expected trailer bytes. Terminate stream if exhausted.
+ Issue an error if unexpected bytes follow. */
+
+ zp->trailerlen -= len;
+ z->avail_in -= len;
+ z->next_in += len;
+ if(z->avail_in)
+ result = CURLE_WRITE_ERROR;
+ if(result || !zp->trailerlen)
+ result = exit_zlib(conn, z, &zp->zlib_init, result);
+ else {
+ /* Only occurs for gzip with zlib < 1.2.0.4 or raw deflate. */
+ zp->zlib_init = ZLIB_EXTERNAL_TRAILER;
+ }
+ return result;
+}
+
+static CURLcode inflate_stream(struct connectdata *conn,
+ contenc_writer *writer, zlibInitState started)
+{
+ zlib_params *zp = (zlib_params *) &writer->params;
+ z_stream *z = &zp->z; /* zlib state structure */
uInt nread = z->avail_in;
Bytef *orig_in = z->next_in;
- int status; /* zlib status */
+ bool done = FALSE;
CURLcode result = CURLE_OK; /* Curl_client_write status */
char *decomp; /* Put the decompressed data here. */
+ /* Check state. */
+ if(zp->zlib_init != ZLIB_INIT &&
+ zp->zlib_init != ZLIB_INFLATING &&
+ zp->zlib_init != ZLIB_INIT_GZIP &&
+ zp->zlib_init != ZLIB_GZIP_INFLATING)
+ return exit_zlib(conn, z, &zp->zlib_init, CURLE_WRITE_ERROR);
+
/* Dynamically allocate a buffer for decompression because it's uncommonly
large to hold on the stack */
decomp = malloc(DSIZ);
- if(decomp == NULL) {
- return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
- }
+ if(decomp == NULL)
+ return exit_zlib(conn, z, &zp->zlib_init, CURLE_OUT_OF_MEMORY);
/* because the buffer size is fixed, iteratively decompress and transfer to
- the client via client_write. */
- for(;;) {
+ the client via downstream_write function. */
+ while(!done) {
+ int status; /* zlib status */
+ done = TRUE;
+
/* (re)set buffer for decompressed output for every iteration */
- z->next_out = (Bytef *)decomp;
+ z->next_out = (Bytef *) decomp;
z->avail_out = DSIZ;
+#ifdef Z_BLOCK
+ /* Z_BLOCK is only available in zlib ver. >= 1.2.0.5 */
+ status = inflate(z, Z_BLOCK);
+#else
+ /* fallback for zlib ver. < 1.2.0.5 */
status = inflate(z, Z_SYNC_FLUSH);
- if(status == Z_OK || status == Z_STREAM_END) {
- allow_restart = 0;
- if((DSIZ - z->avail_out) && (!k->ignorebody)) {
- result = Curl_client_write(conn, CLIENTWRITE_BODY, decomp,
- DSIZ - z->avail_out);
- /* if !CURLE_OK, clean up, return */
+#endif
+
+ /* Flush output data if some. */
+ if(z->avail_out != DSIZ) {
+ if(status == Z_OK || status == Z_STREAM_END) {
+ zp->zlib_init = started; /* Data started. */
+ result = Curl_unencode_write(conn, writer->downstream, decomp,
+ DSIZ - z->avail_out);
if(result) {
- free(decomp);
- return exit_zlib(z, &k->zlib_init, result);
+ exit_zlib(conn, z, &zp->zlib_init, result);
+ break;
}
}
-
- /* Done? clean up, return */
- if(status == Z_STREAM_END) {
- free(decomp);
- if(inflateEnd(z) == Z_OK)
- return exit_zlib(z, &k->zlib_init, result);
- return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));
- }
-
- /* Done with these bytes, exit */
-
- /* status is always Z_OK at this point! */
- if(z->avail_in == 0) {
- free(decomp);
- return result;
- }
}
- else if(allow_restart && status == Z_DATA_ERROR) {
+
+ /* Dispatch by inflate() status. */
+ switch(status) {
+ case Z_OK:
+ /* Always loop: there may be unflushed latched data in zlib state. */
+ done = FALSE;
+ break;
+ case Z_BUF_ERROR:
+ /* No more data to flush: just exit loop. */
+ break;
+ case Z_STREAM_END:
+ result = process_trailer(conn, zp);
+ break;
+ case Z_DATA_ERROR:
/* some servers seem to not generate zlib headers, so this is an attempt
to fix and continue anyway */
-
- (void) inflateEnd(z); /* don't care about the return code */
- if(inflateInit2(z, -MAX_WBITS) != Z_OK) {
- free(decomp);
- return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));
+ if(zp->zlib_init == ZLIB_INIT) {
+ /* Do not use inflateReset2(): only available since zlib 1.2.3.4. */
+ (void) inflateEnd(z); /* don't care about the return code */
+ if(inflateInit2(z, -MAX_WBITS) == Z_OK) {
+ z->next_in = orig_in;
+ z->avail_in = nread;
+ zp->zlib_init = ZLIB_INFLATING;
+ zp->trailerlen = 4; /* Tolerate up to 4 unknown trailer bytes. */
+ done = FALSE;
+ break;
+ }
+ zp->zlib_init = ZLIB_UNINIT; /* inflateEnd() already called. */
}
- z->next_in = orig_in;
- z->avail_in = nread;
- allow_restart = 0;
- continue;
- }
- else { /* Error; exit loop, handle below */
- free(decomp);
- return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));
+ /* FALLTHROUGH */
+ default:
+ result = exit_zlib(conn, z, &zp->zlib_init, process_zlib_error(conn, z));
+ break;
}
}
- /* Will never get here */
+ free(decomp);
+
+ /* We're about to leave this call so the `nread' data bytes won't be seen
+ again. If we are in a state that would wrongly allow restart in raw mode
+ at the next call, assume output has already started. */
+ if(nread && zp->zlib_init == ZLIB_INIT)
+ zp->zlib_init = started; /* Cannot restart anymore. */
+
+ return result;
}
-CURLcode
-Curl_unencode_deflate_write(struct connectdata *conn,
- struct SingleRequest *k,
- ssize_t nread)
+
+/* Deflate handler. */
+static CURLcode deflate_init_writer(struct connectdata *conn,
+ contenc_writer *writer)
{
- z_stream *z = &k->z; /* zlib state structure */
+ zlib_params *zp = (zlib_params *) &writer->params;
+ z_stream *z = &zp->z; /* zlib state structure */
- /* Initialize zlib? */
- if(k->zlib_init == ZLIB_UNINIT) {
- memset(z, 0, sizeof(z_stream));
- z->zalloc = (alloc_func)zalloc_cb;
- z->zfree = (free_func)zfree_cb;
+ if(!writer->downstream)
+ return CURLE_WRITE_ERROR;
- if(inflateInit(z) != Z_OK)
- return process_zlib_error(conn, z);
- k->zlib_init = ZLIB_INIT;
- }
+ /* Initialize zlib */
+ z->zalloc = (alloc_func) zalloc_cb;
+ z->zfree = (free_func) zfree_cb;
+
+ if(inflateInit(z) != Z_OK)
+ return process_zlib_error(conn, z);
+ zp->zlib_init = ZLIB_INIT;
+ return CURLE_OK;
+}
+
+static CURLcode deflate_unencode_write(struct connectdata *conn,
+ contenc_writer *writer,
+ const char *buf, size_t nbytes)
+{
+ zlib_params *zp = (zlib_params *) &writer->params;
+ z_stream *z = &zp->z; /* zlib state structure */
/* Set the compressed input when this function is called */
- z->next_in = (Bytef *)k->str;
- z->avail_in = (uInt)nread;
+ z->next_in = (Bytef *) buf;
+ z->avail_in = (uInt) nbytes;
+
+ if(zp->zlib_init == ZLIB_EXTERNAL_TRAILER)
+ return process_trailer(conn, zp);
/* Now uncompress the data */
- return inflate_stream(conn, k);
+ return inflate_stream(conn, writer, ZLIB_INFLATING);
+}
+
+static void deflate_close_writer(struct connectdata *conn,
+ contenc_writer *writer)
+{
+ zlib_params *zp = (zlib_params *) &writer->params;
+ z_stream *z = &zp->z; /* zlib state structure */
+
+ exit_zlib(conn, z, &zp->zlib_init, CURLE_OK);
+}
+
+static const content_encoding deflate_encoding = {
+ "deflate",
+ NULL,
+ deflate_init_writer,
+ deflate_unencode_write,
+ deflate_close_writer,
+ sizeof(zlib_params)
+};
+
+
+/* Gzip handler. */
+static CURLcode gzip_init_writer(struct connectdata *conn,
+ contenc_writer *writer)
+{
+ zlib_params *zp = (zlib_params *) &writer->params;
+ z_stream *z = &zp->z; /* zlib state structure */
+
+ if(!writer->downstream)
+ return CURLE_WRITE_ERROR;
+
+ /* Initialize zlib */
+ z->zalloc = (alloc_func) zalloc_cb;
+ z->zfree = (free_func) zfree_cb;
+
+ if(strcmp(zlibVersion(), "1.2.0.4") >= 0) {
+ /* zlib ver. >= 1.2.0.4 supports transparent gzip decompressing */
+ if(inflateInit2(z, MAX_WBITS + 32) != Z_OK) {
+ return process_zlib_error(conn, z);
+ }
+ zp->zlib_init = ZLIB_INIT_GZIP; /* Transparent gzip decompress state */
+ }
+ else {
+ /* we must parse the gzip header and trailer ourselves */
+ if(inflateInit2(z, -MAX_WBITS) != Z_OK) {
+ return process_zlib_error(conn, z);
+ }
+ zp->trailerlen = 8; /* A CRC-32 and a 32-bit input size (RFC 1952, 2.2) */
+ zp->zlib_init = ZLIB_INIT; /* Initial call state */
+ }
+
+ return CURLE_OK;
}
#ifdef OLD_ZLIB_SUPPORT
@@ -227,7 +385,7 @@ static enum {
extra_len = (data[1] << 8) | data[0];
- if(len < (extra_len+2))
+ if(len < (extra_len + 2))
return GZIP_UNDERFLOW;
len -= (extra_len + 2);
@@ -273,47 +431,25 @@ static enum {
}
#endif
-CURLcode
-Curl_unencode_gzip_write(struct connectdata *conn,
- struct SingleRequest *k,
- ssize_t nread)
+static CURLcode gzip_unencode_write(struct connectdata *conn,
+ contenc_writer *writer,
+ const char *buf, size_t nbytes)
{
- z_stream *z = &k->z; /* zlib state structure */
-
- /* Initialize zlib? */
- if(k->zlib_init == ZLIB_UNINIT) {
- memset(z, 0, sizeof(z_stream));
- z->zalloc = (alloc_func)zalloc_cb;
- z->zfree = (free_func)zfree_cb;
+ zlib_params *zp = (zlib_params *) &writer->params;
+ z_stream *z = &zp->z; /* zlib state structure */
- if(strcmp(zlibVersion(), "1.2.0.4") >= 0) {
- /* zlib ver. >= 1.2.0.4 supports transparent gzip decompressing */
- if(inflateInit2(z, MAX_WBITS+32) != Z_OK) {
- return process_zlib_error(conn, z);
- }
- k->zlib_init = ZLIB_INIT_GZIP; /* Transparent gzip decompress state */
- }
- else {
- /* we must parse the gzip header ourselves */
- if(inflateInit2(z, -MAX_WBITS) != Z_OK) {
- return process_zlib_error(conn, z);
- }
- k->zlib_init = ZLIB_INIT; /* Initial call state */
- }
- }
-
- if(k->zlib_init == ZLIB_INIT_GZIP) {
+ if(zp->zlib_init == ZLIB_INIT_GZIP) {
/* Let zlib handle the gzip decompression entirely */
- z->next_in = (Bytef *)k->str;
- z->avail_in = (uInt)nread;
+ z->next_in = (Bytef *) buf;
+ z->avail_in = (uInt) nbytes;
/* Now uncompress the data */
- return inflate_stream(conn, k);
+ return inflate_stream(conn, writer, ZLIB_INIT_GZIP);
}
#ifndef OLD_ZLIB_SUPPORT
/* Support for old zlib versions is compiled away and we are running with
an old version, so return an error. */
- return exit_zlib(z, &k->zlib_init, CURLE_WRITE_ERROR);
+ return exit_zlib(conn, z, &zp->zlib_init, CURLE_WRITE_ERROR);
#else
/* This next mess is to get around the potential case where there isn't
@@ -326,18 +462,18 @@ Curl_unencode_gzip_write(struct connectdata *conn,
* can handle the gzip header themselves.
*/
- switch(k->zlib_init) {
+ switch(zp->zlib_init) {
/* Skip over gzip header? */
case ZLIB_INIT:
{
/* Initial call state */
ssize_t hlen;
- switch(check_gzip_header((unsigned char *)k->str, nread, &hlen)) {
+ switch(check_gzip_header((unsigned char *) buf, nbytes, &hlen)) {
case GZIP_OK:
- z->next_in = (Bytef *)k->str + hlen;
- z->avail_in = (uInt)(nread - hlen);
- k->zlib_init = ZLIB_GZIP_INFLATING; /* Inflating stream state */
+ z->next_in = (Bytef *) buf + hlen;
+ z->avail_in = (uInt) (nbytes - hlen);
+ zp->zlib_init = ZLIB_GZIP_INFLATING; /* Inflating stream state */
break;
case GZIP_UNDERFLOW:
@@ -348,19 +484,19 @@ Curl_unencode_gzip_write(struct connectdata *conn,
* the first place, and it's even more unlikely for a transfer to fail
* immediately afterwards, it should seldom be a problem.
*/
- z->avail_in = (uInt)nread;
+ z->avail_in = (uInt) nbytes;
z->next_in = malloc(z->avail_in);
if(z->next_in == NULL) {
- return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
+ return exit_zlib(conn, z, &zp->zlib_init, CURLE_OUT_OF_MEMORY);
}
- memcpy(z->next_in, k->str, z->avail_in);
- k->zlib_init = ZLIB_GZIP_HEADER; /* Need more gzip header data state */
+ memcpy(z->next_in, buf, z->avail_in);
+ zp->zlib_init = ZLIB_GZIP_HEADER; /* Need more gzip header data state */
/* We don't have any data to inflate yet */
return CURLE_OK;
case GZIP_BAD:
default:
- return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));
+ return exit_zlib(conn, z, &zp->zlib_init, process_zlib_error(conn, z));
}
}
@@ -370,22 +506,22 @@ Curl_unencode_gzip_write(struct connectdata *conn,
{
/* Need more gzip header data state */
ssize_t hlen;
- z->avail_in += (uInt)nread;
+ z->avail_in += (uInt) nbytes;
z->next_in = Curl_saferealloc(z->next_in, z->avail_in);
if(z->next_in == NULL) {
- return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY);
+ return exit_zlib(conn, z, &zp->zlib_init, CURLE_OUT_OF_MEMORY);
}
/* Append the new block of data to the previous one */
- memcpy(z->next_in + z->avail_in - nread, k->str, nread);
+ memcpy(z->next_in + z->avail_in - nbytes, buf, nbytes);
switch(check_gzip_header(z->next_in, z->avail_in, &hlen)) {
case GZIP_OK:
/* This is the zlib stream data */
free(z->next_in);
/* Don't point into the malloced block since we just freed it */
- z->next_in = (Bytef *)k->str + hlen + nread - z->avail_in;
- z->avail_in = (uInt)(z->avail_in - hlen);
- k->zlib_init = ZLIB_GZIP_INFLATING; /* Inflating stream state */
+ z->next_in = (Bytef *) buf + hlen + nbytes - z->avail_in;
+ z->avail_in = (uInt) (z->avail_in - hlen);
+ zp->zlib_init = ZLIB_GZIP_INFLATING; /* Inflating stream state */
break;
case GZIP_UNDERFLOW:
@@ -394,18 +530,22 @@ Curl_unencode_gzip_write(struct connectdata *conn,
case GZIP_BAD:
default:
- free(z->next_in);
- return exit_zlib(z, &k->zlib_init, process_zlib_error(conn, z));
+ return exit_zlib(conn, z, &zp->zlib_init, process_zlib_error(conn, z));
}
}
break;
+ case ZLIB_EXTERNAL_TRAILER:
+ z->next_in = (Bytef *) buf;
+ z->avail_in = (uInt) nbytes;
+ return process_trailer(conn, zp);
+
case ZLIB_GZIP_INFLATING:
default:
/* Inflating stream state */
- z->next_in = (Bytef *)k->str;
- z->avail_in = (uInt)nread;
+ z->next_in = (Bytef *) buf;
+ z->avail_in = (uInt) nbytes;
break;
}
@@ -415,17 +555,466 @@ Curl_unencode_gzip_write(struct connectdata *conn,
}
/* We've parsed the header, now uncompress the data */
- return inflate_stream(conn, k);
+ return inflate_stream(conn, writer, ZLIB_GZIP_INFLATING);
+#endif
+}
+
+static void gzip_close_writer(struct connectdata *conn,
+ contenc_writer *writer)
+{
+ zlib_params *zp = (zlib_params *) &writer->params;
+ z_stream *z = &zp->z; /* zlib state structure */
+
+ exit_zlib(conn, z, &zp->zlib_init, CURLE_OK);
+}
+
+static const content_encoding gzip_encoding = {
+ "gzip",
+ "x-gzip",
+ gzip_init_writer,
+ gzip_unencode_write,
+ gzip_close_writer,
+ sizeof(zlib_params)
+};
+
+#endif /* HAVE_LIBZ */
+
+
+#ifdef HAVE_BROTLI
+
+/* Writer parameters. */
+typedef struct {
+ BrotliDecoderState *br; /* State structure for brotli. */
+} brotli_params;
+
+
+static CURLcode brotli_map_error(BrotliDecoderErrorCode be)
+{
+ switch(be) {
+ case BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:
+ case BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:
+ case BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:
+ case BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:
+ case BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:
+ case BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:
+ case BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:
+ case BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:
+ case BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:
+ case BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:
+ case BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:
+ case BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:
+ case BROTLI_DECODER_ERROR_FORMAT_PADDING_1:
+ case BROTLI_DECODER_ERROR_FORMAT_PADDING_2:
+#ifdef BROTLI_DECODER_ERROR_COMPOUND_DICTIONARY
+ case BROTLI_DECODER_ERROR_COMPOUND_DICTIONARY:
#endif
+#ifdef BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET
+ case BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:
+#endif
+ case BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:
+ return CURLE_BAD_CONTENT_ENCODING;
+ case BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:
+ case BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:
+ case BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:
+ case BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:
+ case BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:
+ case BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:
+ return CURLE_OUT_OF_MEMORY;
+ default:
+ break;
+ }
+ return CURLE_WRITE_ERROR;
+}
+
+static CURLcode brotli_init_writer(struct connectdata *conn,
+ contenc_writer *writer)
+{
+ brotli_params *bp = (brotli_params *) &writer->params;
+
+ (void) conn;
+
+ if(!writer->downstream)
+ return CURLE_WRITE_ERROR;
+
+ bp->br = BrotliDecoderCreateInstance(NULL, NULL, NULL);
+ return bp->br? CURLE_OK: CURLE_OUT_OF_MEMORY;
}
+static CURLcode brotli_unencode_write(struct connectdata *conn,
+ contenc_writer *writer,
+ const char *buf, size_t nbytes)
+{
+ brotli_params *bp = (brotli_params *) &writer->params;
+ const uint8_t *src = (const uint8_t *) buf;
+ char *decomp;
+ uint8_t *dst;
+ size_t dstleft;
+ CURLcode result = CURLE_OK;
+ BrotliDecoderResult r = BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT;
+
+ if(!bp->br)
+ return CURLE_WRITE_ERROR; /* Stream already ended. */
+
+ decomp = malloc(DSIZ);
+ if(!decomp)
+ return CURLE_OUT_OF_MEMORY;
+
+ while((nbytes || r == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) &&
+ result == CURLE_OK) {
+ dst = (uint8_t *) decomp;
+ dstleft = DSIZ;
+ r = BrotliDecoderDecompressStream(bp->br,
+ &nbytes, &src, &dstleft, &dst, NULL);
+ result = Curl_unencode_write(conn, writer->downstream,
+ decomp, DSIZ - dstleft);
+ if(result)
+ break;
+ switch(r) {
+ case BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:
+ case BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:
+ break;
+ case BROTLI_DECODER_RESULT_SUCCESS:
+ BrotliDecoderDestroyInstance(bp->br);
+ bp->br = NULL;
+ if(nbytes)
+ result = CURLE_WRITE_ERROR;
+ break;
+ default:
+ result = brotli_map_error(BrotliDecoderGetErrorCode(bp->br));
+ break;
+ }
+ }
+ free(decomp);
+ return result;
+}
+
+static void brotli_close_writer(struct connectdata *conn,
+ contenc_writer *writer)
+{
+ brotli_params *bp = (brotli_params *) &writer->params;
+
+ (void) conn;
+
+ if(bp->br) {
+ BrotliDecoderDestroyInstance(bp->br);
+ bp->br = NULL;
+ }
+}
+
+static const content_encoding brotli_encoding = {
+ "br",
+ NULL,
+ brotli_init_writer,
+ brotli_unencode_write,
+ brotli_close_writer,
+ sizeof(brotli_params)
+};
+#endif
+
+
+/* Identity handler. */
+static CURLcode identity_init_writer(struct connectdata *conn,
+ contenc_writer *writer)
+{
+ (void) conn;
+ return writer->downstream? CURLE_OK: CURLE_WRITE_ERROR;
+}
+
+static CURLcode identity_unencode_write(struct connectdata *conn,
+ contenc_writer *writer,
+ const char *buf, size_t nbytes)
+{
+ return Curl_unencode_write(conn, writer->downstream, buf, nbytes);
+}
+
+static void identity_close_writer(struct connectdata *conn,
+ contenc_writer *writer)
+{
+ (void) conn;
+ (void) writer;
+}
+
+static const content_encoding identity_encoding = {
+ "identity",
+ "none",
+ identity_init_writer,
+ identity_unencode_write,
+ identity_close_writer,
+ 0
+};
+
+
+/* supported content encodings table. */
+static const content_encoding * const encodings[] = {
+ &identity_encoding,
+#ifdef HAVE_LIBZ
+ &deflate_encoding,
+ &gzip_encoding,
+#endif
+#ifdef HAVE_BROTLI
+ &brotli_encoding,
+#endif
+ NULL
+};
+
+
+/* Return a list of comma-separated names of supported encodings. */
+char *Curl_all_content_encodings(void)
+{
+ size_t len = 0;
+ const content_encoding * const *cep;
+ const content_encoding *ce;
+ char *ace;
+
+ for(cep = encodings; *cep; cep++) {
+ ce = *cep;
+ if(!strcasecompare(ce->name, CONTENT_ENCODING_DEFAULT))
+ len += strlen(ce->name) + 2;
+ }
+
+ if(!len)
+ return strdup(CONTENT_ENCODING_DEFAULT);
+
+ ace = malloc(len);
+ if(ace) {
+ char *p = ace;
+ for(cep = encodings; *cep; cep++) {
+ ce = *cep;
+ if(!strcasecompare(ce->name, CONTENT_ENCODING_DEFAULT)) {
+ strcpy(p, ce->name);
+ p += strlen(p);
+ *p++ = ',';
+ *p++ = ' ';
+ }
+ }
+ p[-2] = '\0';
+ }
+
+ return ace;
+}
+
+
+/* Real client writer: no downstream. */
+static CURLcode client_init_writer(struct connectdata *conn,
+ contenc_writer *writer)
+{
+ (void) conn;
+ return writer->downstream? CURLE_WRITE_ERROR: CURLE_OK;
+}
+
+static CURLcode client_unencode_write(struct connectdata *conn,
+ contenc_writer *writer,
+ const char *buf, size_t nbytes)
+{
+ struct Curl_easy *data = conn->data;
+ struct SingleRequest *k = &data->req;
+
+ (void) writer;
+
+ if(!nbytes || k->ignorebody)
+ return CURLE_OK;
+
+ return Curl_client_write(conn, CLIENTWRITE_BODY, (char *) buf, nbytes);
+}
+
+static void client_close_writer(struct connectdata *conn,
+ contenc_writer *writer)
+{
+ (void) conn;
+ (void) writer;
+}
+
+static const content_encoding client_encoding = {
+ NULL,
+ NULL,
+ client_init_writer,
+ client_unencode_write,
+ client_close_writer,
+ 0
+};
+
+
+/* Deferred error dummy writer. */
+static CURLcode error_init_writer(struct connectdata *conn,
+ contenc_writer *writer)
+{
+ (void) conn;
+ return writer->downstream? CURLE_OK: CURLE_WRITE_ERROR;
+}
+
+static CURLcode error_unencode_write(struct connectdata *conn,
+ contenc_writer *writer,
+ const char *buf, size_t nbytes)
+{
+ char *all = Curl_all_content_encodings();
+
+ (void) writer;
+ (void) buf;
+ (void) nbytes;
+
+ if(!all)
+ return CURLE_OUT_OF_MEMORY;
+ failf(conn->data, "Unrecognized content encoding type. "
+ "libcurl understands %s content encodings.", all);
+ free(all);
+ return CURLE_BAD_CONTENT_ENCODING;
+}
+
+static void error_close_writer(struct connectdata *conn,
+ contenc_writer *writer)
+{
+ (void) conn;
+ (void) writer;
+}
+
+static const content_encoding error_encoding = {
+ NULL,
+ NULL,
+ error_init_writer,
+ error_unencode_write,
+ error_close_writer,
+ 0
+};
+
+/* Create an unencoding writer stage using the given handler. */
+static contenc_writer *new_unencoding_writer(struct connectdata *conn,
+ const content_encoding *handler,
+ contenc_writer *downstream)
+{
+ size_t sz = offsetof(contenc_writer, params) + handler->paramsize;
+ contenc_writer *writer = (contenc_writer *) calloc(1, sz);
+
+ if(writer) {
+ writer->handler = handler;
+ writer->downstream = downstream;
+ if(handler->init_writer(conn, writer)) {
+ free(writer);
+ writer = NULL;
+ }
+ }
+
+ return writer;
+}
+
+/* Write data using an unencoding writer stack. */
+CURLcode Curl_unencode_write(struct connectdata *conn, contenc_writer *writer,
+ const char *buf, size_t nbytes)
+{
+ if(!nbytes)
+ return CURLE_OK;
+ return writer->handler->unencode_write(conn, writer, buf, nbytes);
+}
+
+/* Close and clean-up the connection's writer stack. */
void Curl_unencode_cleanup(struct connectdata *conn)
{
struct Curl_easy *data = conn->data;
struct SingleRequest *k = &data->req;
- z_stream *z = &k->z;
- if(k->zlib_init != ZLIB_UNINIT)
- (void) exit_zlib(z, &k->zlib_init, CURLE_OK);
+ contenc_writer *writer = k->writer_stack;
+
+ while(writer) {
+ k->writer_stack = writer->downstream;
+ writer->handler->close_writer(conn, writer);
+ free(writer);
+ writer = k->writer_stack;
+ }
}
-#endif /* HAVE_LIBZ */
+/* Find the content encoding by name. */
+static const content_encoding *find_encoding(const char *name, size_t len)
+{
+ const content_encoding * const *cep;
+
+ for(cep = encodings; *cep; cep++) {
+ const content_encoding *ce = *cep;
+ if((strncasecompare(name, ce->name, len) && !ce->name[len]) ||
+ (ce->alias && strncasecompare(name, ce->alias, len) && !ce->alias[len]))
+ return ce;
+ }
+ return NULL;
+}
+
+/* Set-up the unencoding stack from the Content-Encoding header value.
+ * See RFC 7231 section 3.1.2.2. */
+CURLcode Curl_build_unencoding_stack(struct connectdata *conn,
+ const char *enclist, int maybechunked)
+{
+ struct Curl_easy *data = conn->data;
+ struct SingleRequest *k = &data->req;
+
+ do {
+ const char *name;
+ size_t namelen;
+
+ /* Parse a single encoding name. */
+ while(ISSPACE(*enclist) || *enclist == ',')
+ enclist++;
+
+ name = enclist;
+
+ for(namelen = 0; *enclist && *enclist != ','; enclist++)
+ if(!ISSPACE(*enclist))
+ namelen = enclist - name + 1;
+
+ /* Special case: chunked encoding is handled at the reader level. */
+ if(maybechunked && namelen == 7 && strncasecompare(name, "chunked", 7)) {
+ k->chunk = TRUE; /* chunks coming our way. */
+ Curl_httpchunk_init(conn); /* init our chunky engine. */
+ }
+ else if(namelen) {
+ const content_encoding *encoding = find_encoding(name, namelen);
+ contenc_writer *writer;
+
+ if(!k->writer_stack) {
+ k->writer_stack = new_unencoding_writer(conn, &client_encoding, NULL);
+
+ if(!k->writer_stack)
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ if(!encoding)
+ encoding = &error_encoding; /* Defer error at stack use. */
+
+ /* Stack the unencoding stage. */
+ writer = new_unencoding_writer(conn, encoding, k->writer_stack);
+ if(!writer)
+ return CURLE_OUT_OF_MEMORY;
+ k->writer_stack = writer;
+ }
+ } while(*enclist);
+
+ return CURLE_OK;
+}
+
+#else
+/* Stubs for builds without HTTP. */
+CURLcode Curl_build_unencoding_stack(struct connectdata *conn,
+ const char *enclist, int maybechunked)
+{
+ (void) conn;
+ (void) enclist;
+ (void) maybechunked;
+ return CURLE_NOT_BUILT_IN;
+}
+
+CURLcode Curl_unencode_write(struct connectdata *conn, contenc_writer *writer,
+ const char *buf, size_t nbytes)
+{
+ (void) conn;
+ (void) writer;
+ (void) buf;
+ (void) nbytes;
+ return CURLE_NOT_BUILT_IN;
+}
+
+void Curl_unencode_cleanup(struct connectdata *conn)
+{
+ (void) conn;
+}
+
+char *Curl_all_content_encodings(void)
+{
+ return strdup(CONTENT_ENCODING_DEFAULT); /* Satisfy caller. */
+}
+
+#endif /* CURL_DISABLE_HTTP */
diff --git a/Utilities/cmcurl/lib/content_encoding.h b/Utilities/cmcurl/lib/content_encoding.h
index 3fadd2899..4cd52be62 100644
--- a/Utilities/cmcurl/lib/content_encoding.h
+++ b/Utilities/cmcurl/lib/content_encoding.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -23,26 +23,33 @@
***************************************************************************/
#include "curl_setup.h"
-/*
- * Comma-separated list all supported Content-Encodings ('identity' is implied)
- */
-#ifdef HAVE_LIBZ
-#define ALL_CONTENT_ENCODINGS "deflate, gzip"
-/* force a cleanup */
-void Curl_unencode_cleanup(struct connectdata *conn);
-#else
-#define ALL_CONTENT_ENCODINGS "identity"
-#define Curl_unencode_cleanup(x) Curl_nop_stmt
-#endif
+/* Decoding writer. */
+typedef struct contenc_writer_s contenc_writer;
+typedef struct content_encoding_s content_encoding;
+
+struct contenc_writer_s {
+ const content_encoding *handler; /* Encoding handler. */
+ contenc_writer *downstream; /* Downstream writer. */
+ void *params; /* Encoding-specific storage (variable length). */
+};
-CURLcode Curl_unencode_deflate_write(struct connectdata *conn,
- struct SingleRequest *req,
- ssize_t nread);
+/* Content encoding writer. */
+struct content_encoding_s {
+ const char *name; /* Encoding name. */
+ const char *alias; /* Encoding name alias. */
+ CURLcode (*init_writer)(struct connectdata *conn, contenc_writer *writer);
+ CURLcode (*unencode_write)(struct connectdata *conn, contenc_writer *writer,
+ const char *buf, size_t nbytes);
+ void (*close_writer)(struct connectdata *conn, contenc_writer *writer);
+ size_t paramsize;
+};
-CURLcode
-Curl_unencode_gzip_write(struct connectdata *conn,
- struct SingleRequest *k,
- ssize_t nread);
+CURLcode Curl_build_unencoding_stack(struct connectdata *conn,
+ const char *enclist, int maybechunked);
+CURLcode Curl_unencode_write(struct connectdata *conn, contenc_writer *writer,
+ const char *buf, size_t nbytes);
+void Curl_unencode_cleanup(struct connectdata *conn);
+char *Curl_all_content_encodings(void);
#endif /* HEADER_CURL_CONTENT_ENCODING_H */
diff --git a/Utilities/cmcurl/lib/cookie.c b/Utilities/cmcurl/lib/cookie.c
index 6b678aeb8..9a9e14d01 100644
--- a/Utilities/cmcurl/lib/cookie.c
+++ b/Utilities/cmcurl/lib/cookie.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -40,7 +40,7 @@ struct Cookie *Curl_cookie_add(struct Curl_easy *data,
received from a server.
The function need to replace previously stored lines that this new
- line superceeds.
+ line supersedes.
It may remove lines that are expired.
@@ -84,18 +84,16 @@ Example set of cookies:
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
-#ifdef USE_LIBPSL
-# include <libpsl.h>
-#endif
-
#include "urldata.h"
#include "cookie.h"
+#include "psl.h"
#include "strtok.h"
#include "sendf.h"
#include "slist.h"
#include "share.h"
#include "strtoofft.h"
#include "strcase.h"
+#include "curl_get_line.h"
#include "curl_memrchr.h"
#include "inet_pton.h"
@@ -125,7 +123,7 @@ static bool tailmatch(const char *cooke_domain, const char *hostname)
if(hostname_len < cookie_domain_len)
return FALSE;
- if(!strcasecompare(cooke_domain, hostname+hostname_len-cookie_domain_len))
+ if(!strcasecompare(cooke_domain, hostname + hostname_len-cookie_domain_len))
return FALSE;
/* A lead char of cookie_domain is not '.'.
@@ -143,6 +141,28 @@ static bool tailmatch(const char *cooke_domain, const char *hostname)
}
/*
+ * Return true if the given string is an IP(v4|v6) address.
+ */
+static bool isip(const char *domain)
+{
+ struct in_addr addr;
+#ifdef ENABLE_IPV6
+ struct in6_addr addr6;
+#endif
+
+ if(Curl_inet_pton(AF_INET, domain, &addr)
+#ifdef ENABLE_IPV6
+ || Curl_inet_pton(AF_INET6, domain, &addr6)
+#endif
+ ) {
+ /* domain name given as IP address */
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*
* matching cookie path and url path
* RFC6265 5.1.4 Paths and Path-Match
*/
@@ -204,7 +224,7 @@ static bool pathmatch(const char *cookie_path, const char *request_uri)
goto pathmatched;
}
- /* here, cookie_path_len < url_path_len */
+ /* here, cookie_path_len < uri_path_len */
if(uri_path[cookie_path_len] == '/') {
ret = TRUE;
goto pathmatched;
@@ -218,6 +238,62 @@ pathmatched:
}
/*
+ * Return the top-level domain, for optimal hashing.
+ */
+static const char *get_top_domain(const char * const domain, size_t *outlen)
+{
+ size_t len;
+ const char *first = NULL, *last;
+
+ if(!domain)
+ return NULL;
+
+ len = strlen(domain);
+ last = memrchr(domain, '.', len);
+ if(last) {
+ first = memrchr(domain, '.', (last - domain));
+ if(first)
+ len -= (++first - domain);
+ }
+
+ if(outlen)
+ *outlen = len;
+
+ return first? first: domain;
+}
+
+/*
+ * A case-insensitive hash for the cookie domains.
+ */
+static size_t cookie_hash_domain(const char *domain, const size_t len)
+{
+ const char *end = domain + len;
+ size_t h = 5381;
+
+ while(domain < end) {
+ h += h << 5;
+ h ^= Curl_raw_toupper(*domain++);
+ }
+
+ return (h % COOKIE_HASH_SIZE);
+}
+
+/*
+ * Hash this domain.
+ */
+static size_t cookiehash(const char * const domain)
+{
+ const char *top;
+ size_t len;
+
+ if(!domain || isip(domain))
+ return 0;
+
+ top = get_top_domain(domain, &len);
+ return cookie_hash_domain(top, len);
+}
+
+/*
* cookie path sanitize
*/
static char *sanitize_cookie_path(const char *cookie_path)
@@ -301,50 +377,37 @@ static void strstore(char **str, const char *newstr)
*/
static void remove_expired(struct CookieInfo *cookies)
{
- struct Cookie *co, *nx, *pv;
+ struct Cookie *co, *nx;
curl_off_t now = (curl_off_t)time(NULL);
-
- co = cookies->cookies;
- pv = NULL;
- while(co) {
- nx = co->next;
- if(co->expires && co->expires < now) {
- if(co == cookies->cookies) {
- cookies->cookies = co->next;
+ unsigned int i;
+
+ for(i = 0; i < COOKIE_HASH_SIZE; i++) {
+ struct Cookie *pv = NULL;
+ co = cookies->cookies[i];
+ while(co) {
+ nx = co->next;
+ if(co->expires && co->expires < now) {
+ if(!pv) {
+ cookies->cookies[i] = co->next;
+ }
+ else {
+ pv->next = co->next;
+ }
+ cookies->numcookies--;
+ freecookie(co);
}
else {
- pv->next = co->next;
+ pv = co;
}
- cookies->numcookies--;
- freecookie(co);
- }
- else {
- pv = co;
+ co = nx;
}
- co = nx;
}
}
-/*
- * Return true if the given string is an IP(v4|v6) address.
- */
-static bool isip(const char *domain)
+/* Make sure domain contains a dot or is localhost. */
+static bool bad_domain(const char *domain)
{
- struct in_addr addr;
-#ifdef ENABLE_IPV6
- struct in6_addr addr6;
-#endif
-
- if(Curl_inet_pton(AF_INET, domain, &addr)
-#ifdef ENABLE_IPV6
- || Curl_inet_pton(AF_INET6, domain, &addr6)
-#endif
- ) {
- /* domain name given as IP address */
- return TRUE;
- }
-
- return FALSE;
+ return !strchr(domain, '.') && !strcasecompare(domain, "localhost");
}
/****************************************************************************
@@ -368,23 +431,21 @@ Curl_cookie_add(struct Curl_easy *data,
struct CookieInfo *c,
bool httpheader, /* TRUE if HTTP header-style line */
+ bool noexpire, /* if TRUE, skip remove_expired() */
char *lineptr, /* first character of the line */
const char *domain, /* default domain */
- const char *path) /* full path used when this cookie is set,
+ const char *path, /* full path used when this cookie is set,
used to get default path for the cookie
unless set */
+ bool secure) /* TRUE if connection is over secure origin */
{
struct Cookie *clist;
- char name[MAX_NAME];
struct Cookie *co;
- struct Cookie *lastc=NULL;
+ struct Cookie *lastc = NULL;
time_t now = time(NULL);
bool replace_old = FALSE;
bool badcookie = FALSE; /* cookies are good by default. mmmmm yummy */
-
-#ifdef USE_LIBPSL
- const psl_ctx_t *psl;
-#endif
+ size_t myhash;
#ifdef CURL_DISABLE_VERBOSE_STRINGS
(void)data;
@@ -397,17 +458,19 @@ Curl_cookie_add(struct Curl_easy *data,
if(httpheader) {
/* This line was read off a HTTP-header */
+ char name[MAX_NAME];
+ char what[MAX_NAME];
const char *ptr;
const char *semiptr;
- char *what;
- what = malloc(MAX_COOKIE_LINE);
- if(!what) {
+ size_t linelength = strlen(lineptr);
+ if(linelength > MAX_COOKIE_LINE) {
+ /* discard overly long lines at once */
free(co);
return NULL;
}
- semiptr=strchr(lineptr, ';'); /* first, find a semicolon */
+ semiptr = strchr(lineptr, ';'); /* first, find a semicolon */
while(*lineptr && ISBLANK(*lineptr))
lineptr++;
@@ -415,9 +478,9 @@ Curl_cookie_add(struct Curl_easy *data,
ptr = lineptr;
do {
/* we have a <what>=<this> pair or a stand-alone word here */
- name[0]=what[0]=0; /* init the buffers */
+ name[0] = what[0] = 0; /* init the buffers */
if(1 <= sscanf(ptr, "%" MAX_NAME_TXT "[^;\r\n=] =%"
- MAX_COOKIE_LINE_TXT "[^;\r\n]",
+ MAX_NAME_TXT "[^;\r\n]",
name, what)) {
/* Use strstore() below to properly deal with received cookie
headers that have the same string property set more than once,
@@ -425,10 +488,21 @@ Curl_cookie_add(struct Curl_easy *data,
const char *whatptr;
bool done = FALSE;
bool sep;
- size_t len=strlen(what);
+ size_t len = strlen(what);
size_t nlen = strlen(name);
const char *endofn = &ptr[ nlen ];
+ if(nlen >= (MAX_NAME-1) || len >= (MAX_NAME-1) ||
+ ((nlen + len) > MAX_NAME)) {
+ /* too long individual name or contents, or too long combination of
+ name + contents. Chrome and Firefox support 4095 or 4096 bytes
+ combo. */
+ freecookie(co);
+ infof(data, "oversized cookie dropped, name/val %zu + %zu bytes\n",
+ nlen, len);
+ return NULL;
+ }
+
/* name ends with a '=' ? */
sep = (*endofn == '=')?TRUE:FALSE;
@@ -440,25 +514,44 @@ Curl_cookie_add(struct Curl_easy *data,
endofn--;
nlen--;
}
- name[nlen]=0; /* new end of name */
+ name[nlen] = 0; /* new end of name */
}
}
/* Strip off trailing whitespace from the 'what' */
while(len && ISBLANK(what[len-1])) {
- what[len-1]=0;
+ what[len-1] = 0;
len--;
}
/* Skip leading whitespace from the 'what' */
- whatptr=what;
+ whatptr = what;
while(*whatptr && ISBLANK(*whatptr))
whatptr++;
- if(!co->name && sep) {
+ /*
+ * Check if we have a reserved prefix set before anything else, as we
+ * otherwise have to test for the prefix in both the cookie name and
+ * "the rest". Prefixes must start with '__' and end with a '-', so
+ * only test for names where that can possibly be true.
+ */
+ if(nlen > 3 && name[0] == '_' && name[1] == '_') {
+ if(strncasecompare("__Secure-", name, 9))
+ co->prefix |= COOKIE_PREFIX__SECURE;
+ else if(strncasecompare("__Host-", name, 7))
+ co->prefix |= COOKIE_PREFIX__HOST;
+ }
+
+ if(!co->name) {
/* The very first name/value pair is the actual cookie name */
+ if(!sep) {
+ /* Bad name/value pair. */
+ badcookie = TRUE;
+ break;
+ }
co->name = strdup(name);
co->value = strdup(whatptr);
+ done = TRUE;
if(!co->name || !co->value) {
badcookie = TRUE;
break;
@@ -468,8 +561,20 @@ Curl_cookie_add(struct Curl_easy *data,
/* this was a "<name>=" with no content, and we must allow
'secure' and 'httponly' specified this weirdly */
done = TRUE;
- if(strcasecompare("secure", name))
- co->secure = TRUE;
+ /*
+ * secure cookies are only allowed to be set when the connection is
+ * using a secure protocol, or when the cookie is being set by
+ * reading from file
+ */
+ if(strcasecompare("secure", name)) {
+ if(secure || !c->running) {
+ co->secure = TRUE;
+ }
+ else {
+ badcookie = TRUE;
+ break;
+ }
+ }
else if(strcasecompare("httponly", name))
co->httponly = TRUE;
else if(sep)
@@ -484,6 +589,7 @@ Curl_cookie_add(struct Curl_easy *data,
badcookie = TRUE; /* out of memory bad */
break;
}
+ free(co->spath); /* if this is set again */
co->spath = sanitize_cookie_path(co->path);
if(!co->spath) {
badcookie = TRUE; /* out of memory bad */
@@ -505,13 +611,8 @@ Curl_cookie_add(struct Curl_easy *data,
* TLD or otherwise "protected" suffix. To reduce risk, we require a
* dot OR the exact host name being "localhost".
*/
- {
- const char *dotp;
- /* check for more dots */
- dotp = strchr(whatptr, '.');
- if(!dotp && !strcasecompare("localhost", whatptr))
- domain=":";
- }
+ if(bad_domain(whatptr))
+ domain = ":";
#endif
is_ip = isip(domain ? domain : whatptr);
@@ -525,14 +626,14 @@ Curl_cookie_add(struct Curl_easy *data,
break;
}
if(!is_ip)
- co->tailmatch=TRUE; /* we always do that if the domain name was
- given */
+ co->tailmatch = TRUE; /* we always do that if the domain name was
+ given */
}
else {
/* we did not get a tailmatch and then the attempted set domain
is not a domain to which the current host belongs. Mark as
bad. */
- badcookie=TRUE;
+ badcookie = TRUE;
infof(data, "skipped cookie with bad tailmatch domain: %s\n",
whatptr);
}
@@ -581,26 +682,35 @@ Curl_cookie_add(struct Curl_easy *data,
continue;
}
- ptr=semiptr+1;
+ ptr = semiptr + 1;
while(*ptr && ISBLANK(*ptr))
ptr++;
- semiptr=strchr(ptr, ';'); /* now, find the next semicolon */
+ semiptr = strchr(ptr, ';'); /* now, find the next semicolon */
if(!semiptr && *ptr)
/* There are no more semicolons, but there's a final name=value pair
coming up */
- semiptr=strchr(ptr, '\0');
+ semiptr = strchr(ptr, '\0');
} while(semiptr);
if(co->maxage) {
- co->expires =
- curlx_strtoofft((*co->maxage=='\"')?
- &co->maxage[1]:&co->maxage[0], NULL, 10);
- if(CURL_OFF_T_MAX - now < co->expires)
- /* avoid overflow */
+ CURLofft offt;
+ offt = curlx_strtoofft((*co->maxage == '\"')?
+ &co->maxage[1]:&co->maxage[0], NULL, 10,
+ &co->expires);
+ if(offt == CURL_OFFT_FLOW)
+ /* overflow, used max value */
co->expires = CURL_OFF_T_MAX;
- else
- co->expires += now;
+ else if(!offt) {
+ if(!co->expires)
+ /* already expired */
+ co->expires = 1;
+ else if(CURL_OFF_T_MAX - now < co->expires)
+ /* would overflow */
+ co->expires = CURL_OFF_T_MAX;
+ else
+ co->expires += now;
+ }
}
else if(co->expirestr) {
/* Note that if the date couldn't get parsed for whatever reason,
@@ -619,7 +729,7 @@ Curl_cookie_add(struct Curl_easy *data,
if(!badcookie && !co->domain) {
if(domain) {
/* no domain was given in the header line, set the default */
- co->domain=strdup(domain);
+ co->domain = strdup(domain);
if(!co->domain)
badcookie = TRUE;
}
@@ -637,13 +747,13 @@ Curl_cookie_add(struct Curl_easy *data,
if(!queryp)
endslash = strrchr(path, '/');
else
- endslash = memrchr(path, '/', (size_t)(queryp - path));
+ endslash = memrchr(path, '/', (queryp - path));
if(endslash) {
- size_t pathlen = (size_t)(endslash-path+1); /* include ending slash */
- co->path=malloc(pathlen+1); /* one extra for the zero byte */
+ size_t pathlen = (endslash-path + 1); /* include end slash */
+ co->path = malloc(pathlen + 1); /* one extra for the zero byte */
if(co->path) {
memcpy(co->path, path, pathlen);
- co->path[pathlen]=0; /* zero terminate */
+ co->path[pathlen] = 0; /* zero terminate */
co->spath = sanitize_cookie_path(co->path);
if(!co->spath)
badcookie = TRUE; /* out of memory bad */
@@ -653,8 +763,6 @@ Curl_cookie_add(struct Curl_easy *data,
}
}
- free(what);
-
if(badcookie || !co->name) {
/* we didn't get a cookie name or a bad one,
this is an illegal line, bail out */
@@ -668,7 +776,7 @@ Curl_cookie_add(struct Curl_easy *data,
reading the odd netscape cookies-file format here */
char *ptr;
char *firstptr;
- char *tok_buf=NULL;
+ char *tok_buf = NULL;
int fields;
/* IE introduced HTTP-only cookies to prevent XSS attacks. Cookies
@@ -689,19 +797,19 @@ Curl_cookie_add(struct Curl_easy *data,
return NULL;
}
/* strip off the possible end-of-line characters */
- ptr=strchr(lineptr, '\r');
+ ptr = strchr(lineptr, '\r');
if(ptr)
- *ptr=0; /* clear it */
- ptr=strchr(lineptr, '\n');
+ *ptr = 0; /* clear it */
+ ptr = strchr(lineptr, '\n');
if(ptr)
- *ptr=0; /* clear it */
+ *ptr = 0; /* clear it */
- firstptr=strtok_r(lineptr, "\t", &tok_buf); /* tokenize it on the TAB */
+ firstptr = strtok_r(lineptr, "\t", &tok_buf); /* tokenize it on the TAB */
/* Now loop through the fields and init the struct we already have
allocated */
- for(ptr=firstptr, fields=0; ptr && !badcookie;
- ptr=strtok_r(NULL, "\t", &tok_buf), fields++) {
+ for(ptr = firstptr, fields = 0; ptr && !badcookie;
+ ptr = strtok_r(NULL, "\t", &tok_buf), fields++) {
switch(fields) {
case 0:
if(ptr[0]=='.') /* skip preceding dots */
@@ -712,7 +820,7 @@ Curl_cookie_add(struct Curl_easy *data,
break;
case 1:
/* This field got its explanation on the 23rd of May 2001 by
- Andrés García:
+ Andrés García:
flag: A TRUE/FALSE value indicating if all machines within a given
domain can access the variable. This value is set automatically by
@@ -726,7 +834,7 @@ Curl_cookie_add(struct Curl_easy *data,
case 2:
/* It turns out, that sometimes the file format allows the path
field to remain not filled in, we try to detect this and work
- around it! Andrés García made us aware of this... */
+ around it! Andrés García made us aware of this... */
if(strcmp("TRUE", ptr) && strcmp("FALSE", ptr)) {
/* only if the path doesn't look like a boolean option! */
co->path = strdup(ptr);
@@ -750,15 +858,29 @@ Curl_cookie_add(struct Curl_easy *data,
fields++; /* add a field and fall down to secure */
/* FALLTHROUGH */
case 3:
- co->secure = strcasecompare(ptr, "TRUE")?TRUE:FALSE;
+ co->secure = FALSE;
+ if(strcasecompare(ptr, "TRUE")) {
+ if(secure || c->running)
+ co->secure = TRUE;
+ else
+ badcookie = TRUE;
+ }
break;
case 4:
- co->expires = curlx_strtoofft(ptr, NULL, 10);
+ if(curlx_strtoofft(ptr, NULL, 10, &co->expires))
+ badcookie = TRUE;
break;
case 5:
co->name = strdup(ptr);
if(!co->name)
badcookie = TRUE;
+ else {
+ /* For Netscape file format cookies we check prefix on the name */
+ if(strncasecompare("__Secure-", co->name, 9))
+ co->prefix |= COOKIE_PREFIX__SECURE;
+ else if(strncasecompare("__Host-", co->name, 7))
+ co->prefix |= COOKIE_PREFIX__HOST;
+ }
break;
case 6:
co->value = strdup(ptr);
@@ -787,6 +909,26 @@ Curl_cookie_add(struct Curl_easy *data,
}
+ if(co->prefix & COOKIE_PREFIX__SECURE) {
+ /* The __Secure- prefix only requires that the cookie be set secure */
+ if(!co->secure) {
+ freecookie(co);
+ return NULL;
+ }
+ }
+ if(co->prefix & COOKIE_PREFIX__HOST) {
+ /*
+ * The __Host- prefix requires the cookie to be secure, have a "/" path
+ * and not have a domain set.
+ */
+ if(co->secure && co->path && strcmp(co->path, "/") == 0 && !co->tailmatch)
+ ;
+ else {
+ freecookie(co);
+ return NULL;
+ }
+ }
+
if(!c->running && /* read from a file */
c->newsession && /* clean session cookies */
!co->expires) { /* this is a session cookie since it doesn't expire! */
@@ -795,30 +937,40 @@ Curl_cookie_add(struct Curl_easy *data,
}
co->livecookie = c->running;
+ co->creationtime = ++c->lastct;
/* now, we have parsed the incoming line, we must now check if this
- superceeds an already existing cookie, which it may if the previous have
+ supersedes an already existing cookie, which it may if the previous have
the same domain and path as this */
/* at first, remove expired cookies */
- remove_expired(c);
+ if(!noexpire)
+ remove_expired(c);
#ifdef USE_LIBPSL
- /* Check if the domain is a Public Suffix and if yes, ignore the cookie.
- This needs a libpsl compiled with builtin data. */
+ /* Check if the domain is a Public Suffix and if yes, ignore the cookie. */
if(domain && co->domain && !isip(co->domain)) {
- psl = psl_builtin();
- if(psl && !psl_is_cookie_domain_acceptable(psl, domain, co->domain)) {
- infof(data,
- "cookie '%s' dropped, domain '%s' must not set cookies for '%s'\n",
- co->name, domain, co->domain);
+ const psl_ctx_t *psl = Curl_psl_use(data);
+ int acceptable;
+
+ if(psl) {
+ acceptable = psl_is_cookie_domain_acceptable(psl, domain, co->domain);
+ Curl_psl_release(data);
+ }
+ else
+ acceptable = !bad_domain(domain);
+
+ if(!acceptable) {
+ infof(data, "cookie '%s' dropped, domain '%s' must not "
+ "set cookies for '%s'\n", co->name, domain, co->domain);
freecookie(co);
return NULL;
}
}
#endif
- clist = c->cookies;
+ myhash = cookiehash(co->domain);
+ clist = c->cookies[myhash];
replace_old = FALSE;
while(clist) {
if(strcasecompare(clist->name, co->name)) {
@@ -828,7 +980,7 @@ Curl_cookie_add(struct Curl_easy *data,
if(strcasecompare(clist->domain, co->domain) &&
(clist->tailmatch == co->tailmatch))
/* The domains are identical */
- replace_old=TRUE;
+ replace_old = TRUE;
}
else if(!clist->domain && !co->domain)
replace_old = TRUE;
@@ -837,9 +989,31 @@ Curl_cookie_add(struct Curl_easy *data,
/* the domains were identical */
if(clist->spath && co->spath) {
- if(strcasecompare(clist->spath, co->spath)) {
- replace_old = TRUE;
+ if(clist->secure && !co->secure && !secure) {
+ size_t cllen;
+ const char *sep;
+
+ /*
+ * A non-secure cookie may not overlay an existing secure cookie.
+ * For an existing cookie "a" with path "/login", refuse a new
+ * cookie "a" with for example path "/login/en", while the path
+ * "/loginhelper" is ok.
+ */
+
+ sep = strchr(clist->spath + 1, '/');
+
+ if(sep)
+ cllen = sep - clist->spath;
+ else
+ cllen = strlen(clist->spath);
+
+ if(strncasecompare(clist->spath, co->spath, cllen)) {
+ freecookie(co);
+ return NULL;
+ }
}
+ else if(strcasecompare(clist->spath, co->spath))
+ replace_old = TRUE;
else
replace_old = FALSE;
}
@@ -864,6 +1038,9 @@ Curl_cookie_add(struct Curl_easy *data,
if(replace_old) {
co->next = clist->next; /* get the next-pointer first */
+ /* when replacing, creationtime is kept from old */
+ co->creationtime = clist->creationtime;
+
/* then free all the old pointers */
free(clist->name);
free(clist->value);
@@ -904,40 +1081,13 @@ Curl_cookie_add(struct Curl_easy *data,
if(lastc)
lastc->next = co;
else
- c->cookies = co;
+ c->cookies[myhash] = co;
c->numcookies++; /* one more cookie in the jar */
}
return co;
}
-/*
- * get_line() makes sure to only return complete whole lines that fit in 'len'
- * bytes and end with a newline.
- */
-static char *get_line(char *buf, int len, FILE *input)
-{
- bool partial = FALSE;
- while(1) {
- char *b = fgets(buf, len, input);
- if(b) {
- size_t rlen = strlen(b);
- if(rlen && (b[rlen-1] == '\n')) {
- if(partial) {
- partial = FALSE;
- continue;
- }
- return b;
- }
- /* read a partial, discard the next piece that ends with newline */
- partial = TRUE;
- }
- else
- break;
- }
- return NULL;
-}
-
/*****************************************************************************
*
@@ -957,7 +1107,7 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
{
struct CookieInfo *c;
FILE *fp = NULL;
- bool fromfile=TRUE;
+ bool fromfile = TRUE;
char *line = NULL;
if(NULL == inc) {
@@ -977,7 +1127,7 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
if(file && !strcmp(file, "-")) {
fp = stdin;
- fromfile=FALSE;
+ fromfile = FALSE;
}
else if(file && !*file) {
/* points to a "" string */
@@ -995,22 +1145,23 @@ struct CookieInfo *Curl_cookie_init(struct Curl_easy *data,
line = malloc(MAX_COOKIE_LINE);
if(!line)
goto fail;
- while(get_line(line, MAX_COOKIE_LINE, fp)) {
+ while(Curl_get_line(line, MAX_COOKIE_LINE, fp)) {
if(checkprefix("Set-Cookie:", line)) {
/* This is a cookie line, get it! */
- lineptr=&line[11];
- headerline=TRUE;
+ lineptr = &line[11];
+ headerline = TRUE;
}
else {
- lineptr=line;
- headerline=FALSE;
+ lineptr = line;
+ headerline = FALSE;
}
while(*lineptr && ISBLANK(*lineptr))
lineptr++;
- Curl_cookie_add(data, c, headerline, lineptr, NULL, NULL);
+ Curl_cookie_add(data, c, headerline, TRUE, lineptr, NULL, NULL, TRUE);
}
free(line); /* free the line buffer */
+ remove_expired(c); /* run this once, not on every cookie */
if(fromfile)
fclose(fp);
@@ -1052,12 +1203,24 @@ static int cookie_sort(const void *p1, const void *p2)
if(l1 != l2)
return (l2 > l1) ? 1 : -1 ; /* avoid size_t <=> int conversions */
- /* 3 - compare cookie names */
- if(c1->name && c2->name)
- return strcmp(c1->name, c2->name);
+ /* 3 - compare cookie name lengths */
+ l1 = c1->name ? strlen(c1->name) : 0;
+ l2 = c2->name ? strlen(c2->name) : 0;
- /* sorry, can't be more deterministic */
- return 0;
+ if(l1 != l2)
+ return (l2 > l1) ? 1 : -1;
+
+ /* 4 - compare cookie creation time */
+ return (c2->creationtime > c1->creationtime) ? 1 : -1;
+}
+
+/* sort cookies only according to creation time */
+static int cookie_sort_ct(const void *p1, const void *p2)
+{
+ struct Cookie *c1 = *(struct Cookie **)p1;
+ struct Cookie *c2 = *(struct Cookie **)p2;
+
+ return (c2->creationtime > c1->creationtime) ? 1 : -1;
}
#define CLONE(field) \
@@ -1086,6 +1249,7 @@ static struct Cookie *dup_cookie(struct Cookie *src)
d->secure = src->secure;
d->livecookie = src->livecookie;
d->httponly = src->httponly;
+ d->creationtime = src->creationtime;
}
return d;
@@ -1112,12 +1276,12 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
{
struct Cookie *newco;
struct Cookie *co;
- time_t now = time(NULL);
- struct Cookie *mainco=NULL;
+ struct Cookie *mainco = NULL;
size_t matches = 0;
bool is_ip;
+ const size_t myhash = cookiehash(host);
- if(!c || !c->cookies)
+ if(!c || !c->cookies[myhash])
return NULL; /* no cookie struct or no cookies in the struct */
/* at first, remove expired cookies */
@@ -1126,14 +1290,11 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
/* check if host is an IP(v4|v6) address */
is_ip = isip(host);
- co = c->cookies;
+ co = c->cookies[myhash];
while(co) {
- /* only process this cookie if it is not expired or had no expire
- date AND that if the cookie requires we're secure we must only
- continue if we are! */
- if((!co->expires || (co->expires > now)) &&
- (co->secure?secure:TRUE)) {
+ /* if the cookie requires we're secure we must only continue if we are! */
+ if(co->secure?secure:TRUE) {
/* now check if the domain is correct */
if(!co->domain ||
@@ -1159,12 +1320,8 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
matches++;
}
- else {
- fail:
- /* failure, clear up the allocated chain and return NULL */
- Curl_cookie_freelist(mainco);
- return NULL;
- }
+ else
+ goto fail;
}
}
}
@@ -1185,7 +1342,7 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
co = mainco;
- for(i=0; co; co = co->next)
+ for(i = 0; co; co = co->next)
array[i++] = co;
/* now sort the cookie pointers in path length order */
@@ -1194,14 +1351,19 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
/* remake the linked list order according to the new order */
mainco = array[0]; /* start here */
- for(i=0; i<matches-1; i++)
- array[i]->next = array[i+1];
+ for(i = 0; i<matches-1; i++)
+ array[i]->next = array[i + 1];
array[matches-1]->next = NULL; /* terminate the list */
free(array); /* remove the temporary data again */
}
return mainco; /* return the new list */
+
+fail:
+ /* failure, clear up the allocated chain and return NULL */
+ Curl_cookie_freelist(mainco);
+ return NULL;
}
/*****************************************************************************
@@ -1214,8 +1376,11 @@ struct Cookie *Curl_cookie_getlist(struct CookieInfo *c,
void Curl_cookie_clearall(struct CookieInfo *cookies)
{
if(cookies) {
- Curl_cookie_freelist(cookies->cookies);
- cookies->cookies = NULL;
+ unsigned int i;
+ for(i = 0; i < COOKIE_HASH_SIZE; i++) {
+ Curl_cookie_freelist(cookies->cookies[i]);
+ cookies->cookies[i] = NULL;
+ }
cookies->numcookies = 0;
}
}
@@ -1249,31 +1414,37 @@ void Curl_cookie_freelist(struct Cookie *co)
void Curl_cookie_clearsess(struct CookieInfo *cookies)
{
struct Cookie *first, *curr, *next, *prev = NULL;
+ unsigned int i;
- if(!cookies || !cookies->cookies)
+ if(!cookies)
return;
- first = curr = prev = cookies->cookies;
+ for(i = 0; i < COOKIE_HASH_SIZE; i++) {
+ if(!cookies->cookies[i])
+ continue;
- for(; curr; curr = next) {
- next = curr->next;
- if(!curr->expires) {
- if(first == curr)
- first = next;
+ first = curr = prev = cookies->cookies[i];
- if(prev == curr)
- prev = next;
- else
- prev->next = next;
+ for(; curr; curr = next) {
+ next = curr->next;
+ if(!curr->expires) {
+ if(first == curr)
+ first = next;
- freecookie(curr);
- cookies->numcookies--;
+ if(prev == curr)
+ prev = next;
+ else
+ prev->next = next;
+
+ freecookie(curr);
+ cookies->numcookies--;
+ }
+ else
+ prev = curr;
}
- else
- prev = curr;
- }
- cookies->cookies = first;
+ cookies->cookies[i] = first;
+ }
}
@@ -1287,8 +1458,10 @@ void Curl_cookie_clearsess(struct CookieInfo *cookies)
void Curl_cookie_cleanup(struct CookieInfo *c)
{
if(c) {
+ unsigned int i;
free(c->filename);
- Curl_cookie_freelist(c->cookies);
+ for(i = 0; i < COOKIE_HASH_SIZE; i++)
+ Curl_cookie_freelist(c->cookies[i]);
free(c); /* free the base struct as well */
}
}
@@ -1335,12 +1508,10 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
{
struct Cookie *co;
FILE *out;
- bool use_stdout=FALSE;
- char *format_ptr;
+ bool use_stdout = FALSE;
- if((NULL == c) || (0 == c->numcookies))
- /* If there are no known cookies, we don't write or even create any
- destination file */
+ if(!c)
+ /* no cookie engine alive */
return 0;
/* at first, remove expired cookies */
@@ -1349,12 +1520,13 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
if(!strcmp("-", dumphere)) {
/* use stdout */
out = stdout;
- use_stdout=TRUE;
+ use_stdout = TRUE;
}
else {
out = fopen(dumphere, FOPEN_WRITETEXT);
- if(!out)
+ if(!out) {
return 1; /* failure */
+ }
}
fputs("# Netscape HTTP Cookie File\n"
@@ -1362,57 +1534,93 @@ static int cookie_output(struct CookieInfo *c, const char *dumphere)
"# This file was generated by libcurl! Edit at your own risk.\n\n",
out);
- for(co = c->cookies; co; co = co->next) {
- if(!co->domain)
- continue;
- format_ptr = get_netscape_format(co);
- if(format_ptr == NULL) {
- fprintf(out, "#\n# Fatal libcurl error\n");
+ if(c->numcookies) {
+ unsigned int i;
+ unsigned int j;
+ struct Cookie **array;
+
+ array = malloc(sizeof(struct Cookie *) * c->numcookies);
+ if(!array) {
if(!use_stdout)
fclose(out);
return 1;
}
- fprintf(out, "%s\n", format_ptr);
- free(format_ptr);
- }
+ j = 0;
+ for(i = 0; i < COOKIE_HASH_SIZE; i++) {
+ for(co = c->cookies[i]; co; co = co->next) {
+ if(!co->domain)
+ continue;
+ array[j++] = co;
+ }
+ }
+
+ qsort(array, c->numcookies, sizeof(struct Cookie *), cookie_sort_ct);
+
+ for(i = 0; i < j; i++) {
+ char *format_ptr = get_netscape_format(array[i]);
+ if(format_ptr == NULL) {
+ fprintf(out, "#\n# Fatal libcurl error\n");
+ free(array);
+ if(!use_stdout)
+ fclose(out);
+ return 1;
+ }
+ fprintf(out, "%s\n", format_ptr);
+ free(format_ptr);
+ }
+
+ free(array);
+ }
if(!use_stdout)
fclose(out);
return 0;
}
-struct curl_slist *Curl_cookie_list(struct Curl_easy *data)
+static struct curl_slist *cookie_list(struct Curl_easy *data)
{
struct curl_slist *list = NULL;
struct curl_slist *beg;
struct Cookie *c;
char *line;
+ unsigned int i;
if((data->cookies == NULL) ||
(data->cookies->numcookies == 0))
return NULL;
- for(c = data->cookies->cookies; c; c = c->next) {
- if(!c->domain)
- continue;
- line = get_netscape_format(c);
- if(!line) {
- curl_slist_free_all(list);
- return NULL;
- }
- beg = Curl_slist_append_nodup(list, line);
- if(!beg) {
- free(line);
- curl_slist_free_all(list);
- return NULL;
+ for(i = 0; i < COOKIE_HASH_SIZE; i++) {
+ for(c = data->cookies->cookies[i]; c; c = c->next) {
+ if(!c->domain)
+ continue;
+ line = get_netscape_format(c);
+ if(!line) {
+ curl_slist_free_all(list);
+ return NULL;
+ }
+ beg = Curl_slist_append_nodup(list, line);
+ if(!beg) {
+ free(line);
+ curl_slist_free_all(list);
+ return NULL;
+ }
+ list = beg;
}
- list = beg;
}
return list;
}
+struct curl_slist *Curl_cookie_list(struct Curl_easy *data)
+{
+ struct curl_slist *list;
+ Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
+ list = cookie_list(data);
+ Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
+ return list;
+}
+
void Curl_flush_cookies(struct Curl_easy *data, int cleanup)
{
if(data->set.str[STRING_COOKIEJAR]) {
diff --git a/Utilities/cmcurl/lib/cookie.h b/Utilities/cmcurl/lib/cookie.h
index a9a45785c..b2730cfb9 100644
--- a/Utilities/cmcurl/lib/cookie.h
+++ b/Utilities/cmcurl/lib/cookie.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -34,7 +34,7 @@ struct Cookie {
char *domain; /* domain = <this> */
curl_off_t expires; /* expires = <this> */
char *expirestr; /* the plain text version */
- bool tailmatch; /* weather we do tail-matchning of the domain name */
+ bool tailmatch; /* whether we do tail-matching of the domain name */
/* RFC 2109 keywords. Version=1 means 2109-compliant cookie sending */
char *version; /* Version = <value> */
@@ -43,16 +43,28 @@ struct Cookie {
bool secure; /* whether the 'secure' keyword was used */
bool livecookie; /* updated from a server, not a stored file */
bool httponly; /* true if the httponly directive is present */
+ int creationtime; /* time when the cookie was written */
+ unsigned char prefix; /* bitmap fields indicating which prefix are set */
};
+/*
+ * Available cookie prefixes, as defined in
+ * draft-ietf-httpbis-rfc6265bis-02
+ */
+#define COOKIE_PREFIX__SECURE (1<<0)
+#define COOKIE_PREFIX__HOST (1<<1)
+
+#define COOKIE_HASH_SIZE 256
+
struct CookieInfo {
/* linked list of cookies we know of */
- struct Cookie *cookies;
+ struct Cookie *cookies[COOKIE_HASH_SIZE];
char *filename; /* file we read from/write to */
bool running; /* state info, for cookie adding information */
long numcookies; /* number of cookies in the "jar" */
bool newsession; /* new session, discard session cookies on load */
+ int lastct; /* last creation-time used in the jar */
};
/* This is the maximum line length we accept for a cookie line. RFC 2109
@@ -62,13 +74,15 @@ struct CookieInfo {
that comprise the cookie non-terminal in the syntax description of the
Set-Cookie header)"
+ We allow max 5000 bytes cookie header. Max 4095 bytes length per cookie
+ name and value. Name + value may not exceed 4096 bytes.
+
*/
#define MAX_COOKIE_LINE 5000
-#define MAX_COOKIE_LINE_TXT "4999"
-/* This is the maximum length of a cookie name we deal with: */
-#define MAX_NAME 1024
-#define MAX_NAME_TXT "1023"
+/* This is the maximum length of a cookie name or content we deal with: */
+#define MAX_NAME 4096
+#define MAX_NAME_TXT "4095"
struct Curl_easy;
/*
@@ -77,8 +91,10 @@ struct Curl_easy;
*/
struct Cookie *Curl_cookie_add(struct Curl_easy *data,
- struct CookieInfo *, bool header, char *lineptr,
- const char *domain, const char *path);
+ struct CookieInfo *, bool header, bool noexpiry,
+ char *lineptr,
+ const char *domain, const char *path,
+ bool secure);
struct Cookie *Curl_cookie_getlist(struct CookieInfo *, const char *,
const char *, bool);
diff --git a/Utilities/cmcurl/lib/curl_addrinfo.c b/Utilities/cmcurl/lib/curl_addrinfo.c
index 1adf3198a..16c4779c1 100644
--- a/Utilities/cmcurl/lib/curl_addrinfo.c
+++ b/Utilities/cmcurl/lib/curl_addrinfo.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -27,6 +27,9 @@
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
+#ifdef HAVE_NETINET_IN6_H
+# include <netinet/in6.h>
+#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
@@ -47,6 +50,10 @@
# define in_addr_t unsigned long
#endif
+#if defined(WIN32) && defined(USE_UNIX_SOCKETS)
+#include <afunix.h>
+#endif
+
#include <stddef.h>
#include "curl_addrinfo.h"
@@ -286,7 +293,7 @@ Curl_he2ai(const struct hostent *he, int port)
DEBUGASSERT((he->h_name != NULL) && (he->h_addr_list != NULL));
- for(i=0; (curr = he->h_addr_list[i]) != NULL; i++) {
+ for(i = 0; (curr = he->h_addr_list[i]) != NULL; i++) {
size_t ss_size;
#ifdef ENABLE_IPV6
@@ -338,7 +345,7 @@ Curl_he2ai(const struct hostent *he, int port)
addr = (void *)ai->ai_addr; /* storage area for this info */
memcpy(&addr->sin_addr, curr, sizeof(struct in_addr));
- addr->sin_family = (unsigned short)(he->h_addrtype);
+ addr->sin_family = (CURL_SA_FAMILY_T)(he->h_addrtype);
addr->sin_port = htons((unsigned short)port);
break;
@@ -347,7 +354,7 @@ Curl_he2ai(const struct hostent *he, int port)
addr6 = (void *)ai->ai_addr; /* storage area for this info */
memcpy(&addr6->sin6_addr, curr, sizeof(struct in6_addr));
- addr6->sin6_family = (unsigned short)(he->h_addrtype);
+ addr6->sin6_family = (CURL_SA_FAMILY_T)(he->h_addrtype);
addr6->sin6_port = htons((unsigned short)port);
break;
#endif
@@ -529,9 +536,10 @@ Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, bool abstract)
}
#endif
-#if defined(CURLDEBUG) && defined(HAVE_FREEADDRINFO)
+#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \
+ defined(HAVE_FREEADDRINFO)
/*
- * curl_dofreeaddrinfo()
+ * curl_dbg_freeaddrinfo()
*
* This is strictly for memory tracing and are using the same style as the
* family otherwise present in memdebug.c. I put these ones here since they
@@ -539,23 +547,23 @@ Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, bool abstract)
*/
void
-curl_dofreeaddrinfo(struct addrinfo *freethis,
- int line, const char *source)
+curl_dbg_freeaddrinfo(struct addrinfo *freethis,
+ int line, const char *source)
{
+ curl_dbg_log("ADDR %s:%d freeaddrinfo(%p)\n",
+ source, line, (void *)freethis);
#ifdef USE_LWIPSOCK
lwip_freeaddrinfo(freethis);
#else
(freeaddrinfo)(freethis);
#endif
- curl_memlog("ADDR %s:%d freeaddrinfo(%p)\n",
- source, line, (void *)freethis);
}
#endif /* defined(CURLDEBUG) && defined(HAVE_FREEADDRINFO) */
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO)
/*
- * curl_dogetaddrinfo()
+ * curl_dbg_getaddrinfo()
*
* This is strictly for memory tracing and are using the same style as the
* family otherwise present in memdebug.c. I put these ones here since they
@@ -563,24 +571,24 @@ curl_dofreeaddrinfo(struct addrinfo *freethis,
*/
int
-curl_dogetaddrinfo(const char *hostname,
- const char *service,
- const struct addrinfo *hints,
- struct addrinfo **result,
- int line, const char *source)
+curl_dbg_getaddrinfo(const char *hostname,
+ const char *service,
+ const struct addrinfo *hints,
+ struct addrinfo **result,
+ int line, const char *source)
{
#ifdef USE_LWIPSOCK
- int res=lwip_getaddrinfo(hostname, service, hints, result);
+ int res = lwip_getaddrinfo(hostname, service, hints, result);
#else
- int res=(getaddrinfo)(hostname, service, hints, result);
+ int res = (getaddrinfo)(hostname, service, hints, result);
#endif
if(0 == res)
/* success */
- curl_memlog("ADDR %s:%d getaddrinfo() = %p\n",
- source, line, (void *)*result);
+ curl_dbg_log("ADDR %s:%d getaddrinfo() = %p\n",
+ source, line, (void *)*result);
else
- curl_memlog("ADDR %s:%d getaddrinfo() failed\n",
- source, line);
+ curl_dbg_log("ADDR %s:%d getaddrinfo() failed\n",
+ source, line);
return res;
}
#endif /* defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) */
diff --git a/Utilities/cmcurl/lib/curl_addrinfo.h b/Utilities/cmcurl/lib/curl_addrinfo.h
index 8f6f3d106..205e121ea 100644
--- a/Utilities/cmcurl/lib/curl_addrinfo.h
+++ b/Utilities/cmcurl/lib/curl_addrinfo.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -86,17 +86,14 @@ Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, bool abstract);
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \
defined(HAVE_FREEADDRINFO)
void
-curl_dofreeaddrinfo(struct addrinfo *freethis,
- int line, const char *source);
+curl_dbg_freeaddrinfo(struct addrinfo *freethis, int line, const char *source);
#endif
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO)
int
-curl_dogetaddrinfo(const char *hostname,
- const char *service,
- const struct addrinfo *hints,
- struct addrinfo **result,
- int line, const char *source);
+curl_dbg_getaddrinfo(const char *hostname, const char *service,
+ const struct addrinfo *hints, struct addrinfo **result,
+ int line, const char *source);
#endif
#ifdef HAVE_GETADDRINFO
diff --git a/Utilities/cmcurl/lib/curl_config.h.cmake b/Utilities/cmcurl/lib/curl_config.h.cmake
index f9d54b4bd..b285c3fdd 100644
--- a/Utilities/cmcurl/lib/curl_config.h.cmake
+++ b/Utilities/cmcurl/lib/curl_config.h.cmake
@@ -42,9 +42,6 @@
/* to disable RTSP */
#cmakedefine CURL_DISABLE_RTSP 1
-/* to disable RTMP */
-#cmakedefine CURL_DISABLE_RTMP 1
-
/* to disable SMB */
#cmakedefine CURL_DISABLE_SMB 1
@@ -73,9 +70,6 @@
/* when not building a shared library */
#cmakedefine CURL_STATICLIB 1
-/* Set to explicitly specify we don't want to use thread-safe functions */
-#cmakedefine DISABLED_THREADSAFE 1
-
/* your Entropy Gathering Daemon socket pathname */
#cmakedefine EGD_SOCKET ${EGD_SOCKET}
@@ -124,6 +118,9 @@
/* Define to 1 if bool is an available type. */
#cmakedefine HAVE_BOOL_T 1
+/* Define to 1 if you have the __builtin_available function. */
+#cmakedefine HAVE_BUILTIN_AVAILABLE 1
+
/* Define to 1 if you have the clock_gettime function and monotonic timer. */
#cmakedefine HAVE_CLOCK_GETTIME_MONOTONIC 1
@@ -229,9 +226,18 @@
/* Define to 1 if you have the `getprotobyname' function. */
#cmakedefine HAVE_GETPROTOBYNAME 1
+/* Define to 1 if you have the `getpeername' function. */
+#cmakedefine HAVE_GETPEERNAME 1
+
+/* Define to 1 if you have the `getsockname' function. */
+#cmakedefine HAVE_GETSOCKNAME 1
+
/* Define to 1 if you have the `getpwuid' function. */
#cmakedefine HAVE_GETPWUID 1
+/* Define to 1 if you have the `getpwuid_r' function. */
+#cmakedefine HAVE_GETPWUID_R 1
+
/* Define to 1 if you have the `getrlimit' function. */
#cmakedefine HAVE_GETRLIMIT 1
@@ -395,8 +401,8 @@
/* if zlib is available */
#cmakedefine HAVE_LIBZ 1
-/* Define to 1 if you have the <limits.h> header file. */
-#cmakedefine HAVE_LIMITS_H 1
+/* if brotli is available */
+#cmakedefine HAVE_BROTLI 1
/* if your compiler supports LL */
#cmakedefine HAVE_LL 1
@@ -882,9 +888,18 @@
/* The size of `long', as computed by sizeof. */
@SIZEOF_LONG_CODE@
+/* The size of `long long', as computed by sizeof. */
+@SIZEOF_LONG_LONG_CODE@
+
+/* The size of `__int64', as computed by sizeof. */
+@SIZEOF___INT64_CODE@
+
/* The size of `off_t', as computed by sizeof. */
@SIZEOF_OFF_T_CODE@
+/* The size of `curl_off_t', as computed by sizeof. */
+@SIZEOF_CURL_OFF_T_CODE@
+
/* The size of `size_t', as computed by sizeof. */
@SIZEOF_SIZE_T_CODE@
@@ -921,8 +936,8 @@
/* if PolarSSL is enabled */
#cmakedefine USE_POLARSSL 1
-/* if DarwinSSL is enabled */
-#cmakedefine USE_DARWINSSL 1
+/* if Secure Transport is enabled */
+#cmakedefine USE_SECTRANSP 1
/* if mbedTLS is enabled */
#cmakedefine USE_MBEDTLS 1
@@ -954,15 +969,15 @@
/* to enable Windows SSL */
#cmakedefine USE_SCHANNEL 1
+/* enable multiple SSL backends */
+#cmakedefine CURL_WITH_MULTI_SSL 1
+
/* Define to 1 if using yaSSL in OpenSSL compatibility mode. */
#cmakedefine USE_YASSLEMUL 1
/* Version number of package */
#cmakedefine VERSION ${VERSION}
-/* Define to avoid automatic inclusion of winsock.h */
-#cmakedefine WIN32_LEAN_AND_MEAN 1
-
/* Define to 1 if OS is AIX. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
@@ -1004,3 +1019,6 @@
typedef int ssize_t;
# endif
#endif
+
+/* Define to 1 if you have the mach_absolute_time function. */
+#cmakedefine HAVE_MACH_ABSOLUTE_TIME 1
diff --git a/Utilities/cmcurl/lib/curl_ctype.c b/Utilities/cmcurl/lib/curl_ctype.c
new file mode 100644
index 000000000..1a47fb5e6
--- /dev/null
+++ b/Utilities/cmcurl/lib/curl_ctype.c
@@ -0,0 +1,133 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#ifndef CURL_DOES_CONVERSIONS
+
+#undef _U
+#define _U (1<<0) /* upper case */
+#undef _L
+#define _L (1<<1) /* lower case */
+#undef _N
+#define _N (1<<2) /* decimal numerical digit */
+#undef _S
+#define _S (1<<3) /* space */
+#undef _P
+#define _P (1<<4) /* punctuation */
+#undef _C
+#define _C (1<<5) /* control */
+#undef _X
+#define _X (1<<6) /* hexadecimal letter */
+#undef _B
+#define _B (1<<7) /* blank */
+
+static const unsigned char ascii[128] = {
+ _C, _C, _C, _C, _C, _C, _C, _C,
+ _C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C,
+ _C, _C, _C, _C, _C, _C, _C, _C,
+ _C, _C, _C, _C, _C, _C, _C, _C,
+ _S|_B, _P, _P, _P, _P, _P, _P, _P,
+ _P, _P, _P, _P, _P, _P, _P, _P,
+ _N, _N, _N, _N, _N, _N, _N, _N,
+ _N, _N, _P, _P, _P, _P, _P, _P,
+ _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U,
+ _U, _U, _U, _U, _U, _U, _U, _U,
+ _U, _U, _U, _U, _U, _U, _U, _U,
+ _U, _U, _U, _P, _P, _P, _P, _P,
+ _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L,
+ _L, _L, _L, _L, _L, _L, _L, _L,
+ _L, _L, _L, _L, _L, _L, _L, _L,
+ _L, _L, _L, _P, _P, _P, _P, _C
+};
+
+int Curl_isspace(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & _S);
+}
+
+int Curl_isdigit(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & _N);
+}
+
+int Curl_isalnum(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & (_N|_U|_L));
+}
+
+int Curl_isxdigit(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & (_N|_X));
+}
+
+int Curl_isgraph(int c)
+{
+ if((c < 0) || (c >= 0x80) || (c == ' '))
+ return FALSE;
+ return (ascii[c] & (_N|_X|_U|_L|_P|_S));
+}
+
+int Curl_isprint(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & (_N|_X|_U|_L|_P|_S));
+}
+
+int Curl_isalpha(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & (_U|_L));
+}
+
+int Curl_isupper(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & (_U));
+}
+
+int Curl_islower(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & (_L));
+}
+
+int Curl_iscntrl(int c)
+{
+ if((c < 0) || (c >= 0x80))
+ return FALSE;
+ return (ascii[c] & (_C));
+}
+
+#endif /* !CURL_DOES_CONVERSIONS */
diff --git a/Utilities/cmcurl/lib/curl_ctype.h b/Utilities/cmcurl/lib/curl_ctype.h
new file mode 100644
index 000000000..6e94bb1b4
--- /dev/null
+++ b/Utilities/cmcurl/lib/curl_ctype.h
@@ -0,0 +1,81 @@
+#ifndef HEADER_CURL_CTYPE_H
+#define HEADER_CURL_CTYPE_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#ifdef CURL_DOES_CONVERSIONS
+
+/*
+ * Uppercase macro versions of ANSI/ISO is*() functions/macros which
+ * avoid negative number inputs with argument byte codes > 127.
+ *
+ * For non-ASCII platforms the C library character classification routines
+ * are used despite being locale-dependent, because this is better than
+ * not to work at all.
+ */
+#include <ctype.h>
+
+#define ISSPACE(x) (isspace((int) ((unsigned char)x)))
+#define ISDIGIT(x) (isdigit((int) ((unsigned char)x)))
+#define ISALNUM(x) (isalnum((int) ((unsigned char)x)))
+#define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x)))
+#define ISGRAPH(x) (isgraph((int) ((unsigned char)x)))
+#define ISALPHA(x) (isalpha((int) ((unsigned char)x)))
+#define ISPRINT(x) (isprint((int) ((unsigned char)x)))
+#define ISUPPER(x) (isupper((int) ((unsigned char)x)))
+#define ISLOWER(x) (islower((int) ((unsigned char)x)))
+#define ISCNTRL(x) (iscntrl((int) ((unsigned char)x)))
+#define ISASCII(x) (isascii((int) ((unsigned char)x)))
+
+#else
+
+int Curl_isspace(int c);
+int Curl_isdigit(int c);
+int Curl_isalnum(int c);
+int Curl_isxdigit(int c);
+int Curl_isgraph(int c);
+int Curl_isprint(int c);
+int Curl_isalpha(int c);
+int Curl_isupper(int c);
+int Curl_islower(int c);
+int Curl_iscntrl(int c);
+
+#define ISSPACE(x) (Curl_isspace((int) ((unsigned char)x)))
+#define ISDIGIT(x) (Curl_isdigit((int) ((unsigned char)x)))
+#define ISALNUM(x) (Curl_isalnum((int) ((unsigned char)x)))
+#define ISXDIGIT(x) (Curl_isxdigit((int) ((unsigned char)x)))
+#define ISGRAPH(x) (Curl_isgraph((int) ((unsigned char)x)))
+#define ISALPHA(x) (Curl_isalpha((int) ((unsigned char)x)))
+#define ISPRINT(x) (Curl_isprint((int) ((unsigned char)x)))
+#define ISUPPER(x) (Curl_isupper((int) ((unsigned char)x)))
+#define ISLOWER(x) (Curl_islower((int) ((unsigned char)x)))
+#define ISCNTRL(x) (Curl_iscntrl((int) ((unsigned char)x)))
+#define ISASCII(x) (((x) >= 0) && ((x) <= 0x80))
+
+#endif
+
+#define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \
+ (((unsigned char)x) == '\t'))
+
+#endif /* HEADER_CURL_CTYPE_H */
diff --git a/Utilities/cmcurl/lib/curl_endian.c b/Utilities/cmcurl/lib/curl_endian.c
index c25db4956..b7563b3de 100644
--- a/Utilities/cmcurl/lib/curl_endian.c
+++ b/Utilities/cmcurl/lib/curl_endian.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -82,7 +82,7 @@ unsigned short Curl_read16_be(const unsigned char *buf)
}
/*
- * Curl_write32_le()
+ * write32_le()
*
* This function converts a 32-bit integer from the native endian format,
* to little endian format ready for sending down the wire.
@@ -92,7 +92,7 @@ unsigned short Curl_read16_be(const unsigned char *buf)
* value [in] - The 32-bit integer value.
* buffer [in] - A pointer to the output buffer.
*/
-void Curl_write32_le(const int value, unsigned char *buffer)
+static void write32_le(const int value, unsigned char *buffer)
{
buffer[0] = (char)(value & 0x000000FF);
buffer[1] = (char)((value & 0x0000FF00) >> 8);
@@ -118,7 +118,7 @@ void Curl_write64_le(const long long value, unsigned char *buffer)
void Curl_write64_le(const __int64 value, unsigned char *buffer)
#endif
{
- Curl_write32_le((int)value, buffer);
- Curl_write32_le((int)(value >> 32), buffer + 4);
+ write32_le((int)value, buffer);
+ write32_le((int)(value >> 32), buffer + 4);
}
#endif /* CURL_SIZEOF_CURL_OFF_T > 4 */
diff --git a/Utilities/cmcurl/lib/curl_fnmatch.c b/Utilities/cmcurl/lib/curl_fnmatch.c
index 46d3ada1e..ab3e7428d 100644
--- a/Utilities/cmcurl/lib/curl_fnmatch.c
+++ b/Utilities/cmcurl/lib/curl_fnmatch.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -21,7 +21,7 @@
***************************************************************************/
#include "curl_setup.h"
-
+#ifndef CURL_DISABLE_FTP
#include <curl/curl.h>
#include "curl_fnmatch.h"
@@ -30,6 +30,8 @@
/* The last #include file should be: */
#include "memdebug.h"
+#ifndef HAVE_FNMATCH
+
#define CURLFNM_CHARSET_LEN (sizeof(char) * 256)
#define CURLFNM_CHSET_SIZE (CURLFNM_CHARSET_LEN + 15)
@@ -47,14 +49,7 @@
#define CURLFNM_UPPER (CURLFNM_CHARSET_LEN + 10)
typedef enum {
- CURLFNM_LOOP_DEFAULT = 0,
- CURLFNM_LOOP_BACKSLASH
-} loop_state;
-
-typedef enum {
CURLFNM_SCHS_DEFAULT = 0,
- CURLFNM_SCHS_MAYRANGE,
- CURLFNM_SCHS_MAYRANGE2,
CURLFNM_SCHS_RIGHTBR,
CURLFNM_SCHS_RIGHTBRLEFTBR
} setcharset_state;
@@ -64,6 +59,13 @@ typedef enum {
CURLFNM_PKW_DDOT
} parsekey_state;
+typedef enum {
+ CCLASS_OTHER = 0,
+ CCLASS_DIGIT,
+ CCLASS_UPPER,
+ CCLASS_LOWER
+} char_class;
+
#define SETCHARSET_OK 1
#define SETCHARSET_FAIL 0
@@ -81,12 +83,12 @@ static int parsekeyword(unsigned char **pattern, unsigned char *charset)
return SETCHARSET_FAIL;
switch(state) {
case CURLFNM_PKW_INIT:
- if(ISALPHA(c) && ISLOWER(c))
+ if(ISLOWER(c))
keyword[i] = c;
else if(c == ':')
state = CURLFNM_PKW_DDOT;
else
- return 0;
+ return SETCHARSET_FAIL;
break;
case CURLFNM_PKW_DDOT:
if(c == ']')
@@ -123,26 +125,56 @@ static int parsekeyword(unsigned char **pattern, unsigned char *charset)
return SETCHARSET_OK;
}
+/* Return the character class. */
+static char_class charclass(unsigned char c)
+{
+ if(ISUPPER(c))
+ return CCLASS_UPPER;
+ if(ISLOWER(c))
+ return CCLASS_LOWER;
+ if(ISDIGIT(c))
+ return CCLASS_DIGIT;
+ return CCLASS_OTHER;
+}
+
+/* Include a character or a range in set. */
+static void setcharorrange(unsigned char **pp, unsigned char *charset)
+{
+ unsigned char *p = (*pp)++;
+ unsigned char c = *p++;
+
+ charset[c] = 1;
+ if(ISALNUM(c) && *p++ == '-') {
+ char_class cc = charclass(c);
+ unsigned char endrange = *p++;
+
+ if(endrange == '\\')
+ endrange = *p++;
+ if(endrange >= c && charclass(endrange) == cc) {
+ while(c++ != endrange)
+ if(charclass(c) == cc) /* Chars in class may be not consecutive. */
+ charset[c] = 1;
+ *pp = p;
+ }
+ }
+}
+
/* returns 1 (true) if pattern is OK, 0 if is bad ("p" is pattern pointer) */
static int setcharset(unsigned char **p, unsigned char *charset)
{
setcharset_state state = CURLFNM_SCHS_DEFAULT;
- unsigned char rangestart = 0;
- unsigned char lastchar = 0;
bool something_found = FALSE;
unsigned char c;
+
+ memset(charset, 0, CURLFNM_CHSET_SIZE);
for(;;) {
c = **p;
+ if(!c)
+ return SETCHARSET_FAIL;
+
switch(state) {
case CURLFNM_SCHS_DEFAULT:
- if(ISALNUM(c)) { /* ASCII value */
- rangestart = c;
- charset[c] = 1;
- (*p)++;
- state = CURLFNM_SCHS_MAYRANGE;
- something_found = TRUE;
- }
- else if(c == ']') {
+ if(c == ']') {
if(something_found)
return SETCHARSET_OK;
something_found = TRUE;
@@ -151,26 +183,16 @@ static int setcharset(unsigned char **p, unsigned char *charset)
(*p)++;
}
else if(c == '[') {
- char c2 = *((*p)+1);
- if(c2 == ':') { /* there has to be a keyword */
- (*p) += 2;
- if(parsekeyword(p, charset)) {
- state = CURLFNM_SCHS_DEFAULT;
- }
- else
- return SETCHARSET_FAIL;
- }
+ unsigned char *pp = *p + 1;
+
+ if(*pp++ == ':' && parsekeyword(&pp, charset))
+ *p = pp;
else {
charset[c] = 1;
(*p)++;
}
something_found = TRUE;
}
- else if(c == '?' || c == '*') {
- something_found = TRUE;
- charset[c] = 1;
- (*p)++;
- }
else if(c == '^' || c == '!') {
if(!something_found) {
if(charset[CURLFNM_NEGATE]) {
@@ -186,88 +208,17 @@ static int setcharset(unsigned char **p, unsigned char *charset)
}
else if(c == '\\') {
c = *(++(*p));
- if(ISPRINT((c))) {
- something_found = TRUE;
- state = CURLFNM_SCHS_MAYRANGE;
- charset[c] = 1;
- rangestart = c;
- (*p)++;
- }
+ if(c)
+ setcharorrange(p, charset);
else
- return SETCHARSET_FAIL;
- }
- else if(c == '\0') {
- return SETCHARSET_FAIL;
+ charset['\\'] = 1;
+ something_found = TRUE;
}
else {
- charset[c] = 1;
- (*p)++;
+ setcharorrange(p, charset);
something_found = TRUE;
}
break;
- case CURLFNM_SCHS_MAYRANGE:
- if(c == '-') {
- charset[c] = 1;
- (*p)++;
- lastchar = '-';
- state = CURLFNM_SCHS_MAYRANGE2;
- }
- else if(c == '[') {
- state = CURLFNM_SCHS_DEFAULT;
- }
- else if(ISALNUM(c)) {
- charset[c] = 1;
- (*p)++;
- }
- else if(c == '\\') {
- c = *(++(*p));
- if(ISPRINT(c)) {
- charset[c] = 1;
- (*p)++;
- }
- else
- return SETCHARSET_FAIL;
- }
- else if(c == ']') {
- return SETCHARSET_OK;
- }
- else
- return SETCHARSET_FAIL;
- break;
- case CURLFNM_SCHS_MAYRANGE2:
- if(c == '\\') {
- c = *(++(*p));
- if(!ISPRINT(c))
- return SETCHARSET_FAIL;
- }
- if(c == ']') {
- return SETCHARSET_OK;
- }
- if(c == '\\') {
- c = *(++(*p));
- if(ISPRINT(c)) {
- charset[c] = 1;
- state = CURLFNM_SCHS_DEFAULT;
- (*p)++;
- }
- else
- return SETCHARSET_FAIL;
- }
- if(c >= rangestart) {
- if((ISLOWER(c) && ISLOWER(rangestart)) ||
- (ISDIGIT(c) && ISDIGIT(rangestart)) ||
- (ISUPPER(c) && ISUPPER(rangestart))) {
- charset[lastchar] = 0;
- rangestart++;
- while(rangestart++ <= c)
- charset[rangestart-1] = 1;
- (*p)++;
- state = CURLFNM_SCHS_DEFAULT;
- }
- else
- return SETCHARSET_FAIL;
- }
- break;
case CURLFNM_SCHS_RIGHTBR:
if(c == '[') {
state = CURLFNM_SCHS_RIGHTBRLEFTBR;
@@ -277,9 +228,6 @@ static int setcharset(unsigned char **p, unsigned char *charset)
else if(c == ']') {
return SETCHARSET_OK;
}
- else if(c == '\0') {
- return SETCHARSET_FAIL;
- }
else if(ISPRINT(c)) {
charset[c] = 1;
(*p)++;
@@ -292,14 +240,11 @@ static int setcharset(unsigned char **p, unsigned char *charset)
goto fail;
break;
case CURLFNM_SCHS_RIGHTBRLEFTBR:
- if(c == ']') {
+ if(c == ']')
return SETCHARSET_OK;
- }
- else {
- state = CURLFNM_SCHS_DEFAULT;
- charset[c] = 1;
- (*p)++;
- }
+ state = CURLFNM_SCHS_DEFAULT;
+ charset[c] = 1;
+ (*p)++;
break;
}
}
@@ -307,104 +252,96 @@ fail:
return SETCHARSET_FAIL;
}
-static int loop(const unsigned char *pattern, const unsigned char *string)
+static int loop(const unsigned char *pattern, const unsigned char *string,
+ int maxstars)
{
- loop_state state = CURLFNM_LOOP_DEFAULT;
unsigned char *p = (unsigned char *)pattern;
unsigned char *s = (unsigned char *)string;
unsigned char charset[CURLFNM_CHSET_SIZE] = { 0 };
- int rc = 0;
for(;;) {
- switch(state) {
- case CURLFNM_LOOP_DEFAULT:
- if(*p == '*') {
- while(*(p+1) == '*') /* eliminate multiple stars */
- p++;
- if(*s == '\0' && *(p+1) == '\0')
- return CURL_FNMATCH_MATCH;
- rc = loop(p + 1, s); /* *.txt matches .txt <=> .txt matches .txt */
- if(rc == CURL_FNMATCH_MATCH)
+ unsigned char *pp;
+
+ switch(*p) {
+ case '*':
+ if(!maxstars)
+ return CURL_FNMATCH_NOMATCH;
+ /* Regroup consecutive stars and question marks. This can be done because
+ '*?*?*' can be expressed as '??*'. */
+ for(;;) {
+ if(*++p == '\0')
return CURL_FNMATCH_MATCH;
- if(*s) /* let the star eat up one character */
- s++;
- else
- return CURL_FNMATCH_NOMATCH;
- }
- else if(*p == '?') {
- if(ISPRINT(*s)) {
- s++;
- p++;
+ if(*p == '?') {
+ if(!*s++)
+ return CURL_FNMATCH_NOMATCH;
}
- else if(*s == '\0')
- return CURL_FNMATCH_NOMATCH;
- else
- return CURL_FNMATCH_FAIL; /* cannot deal with other character */
+ else if(*p != '*')
+ break;
}
- else if(*p == '\0') {
- if(*s == '\0')
+ /* Skip string characters until we find a match with pattern suffix. */
+ for(maxstars--; *s; s++) {
+ if(loop(p, s, maxstars) == CURL_FNMATCH_MATCH)
return CURL_FNMATCH_MATCH;
- return CURL_FNMATCH_NOMATCH;
}
- else if(*p == '\\') {
- state = CURLFNM_LOOP_BACKSLASH;
+ return CURL_FNMATCH_NOMATCH;
+ case '?':
+ if(!*s)
+ return CURL_FNMATCH_NOMATCH;
+ s++;
+ p++;
+ break;
+ case '\0':
+ return *s? CURL_FNMATCH_NOMATCH: CURL_FNMATCH_MATCH;
+ case '\\':
+ if(p[1])
p++;
- }
- else if(*p == '[') {
- unsigned char *pp = p+1; /* cannot handle with pointer to register */
- if(setcharset(&pp, charset)) {
- int found = FALSE;
- if(charset[(unsigned int)*s])
- found = TRUE;
- else if(charset[CURLFNM_ALNUM])
- found = ISALNUM(*s);
- else if(charset[CURLFNM_ALPHA])
- found = ISALPHA(*s);
- else if(charset[CURLFNM_DIGIT])
- found = ISDIGIT(*s);
- else if(charset[CURLFNM_XDIGIT])
- found = ISXDIGIT(*s);
- else if(charset[CURLFNM_PRINT])
- found = ISPRINT(*s);
- else if(charset[CURLFNM_SPACE])
- found = ISSPACE(*s);
- else if(charset[CURLFNM_UPPER])
- found = ISUPPER(*s);
- else if(charset[CURLFNM_LOWER])
- found = ISLOWER(*s);
- else if(charset[CURLFNM_BLANK])
- found = ISBLANK(*s);
- else if(charset[CURLFNM_GRAPH])
- found = ISGRAPH(*s);
+ if(*s++ != *p++)
+ return CURL_FNMATCH_NOMATCH;
+ break;
+ case '[':
+ pp = p + 1; /* Copy in case of syntax error in set. */
+ if(setcharset(&pp, charset)) {
+ int found = FALSE;
+ if(!*s)
+ return CURL_FNMATCH_NOMATCH;
+ if(charset[(unsigned int)*s])
+ found = TRUE;
+ else if(charset[CURLFNM_ALNUM])
+ found = ISALNUM(*s);
+ else if(charset[CURLFNM_ALPHA])
+ found = ISALPHA(*s);
+ else if(charset[CURLFNM_DIGIT])
+ found = ISDIGIT(*s);
+ else if(charset[CURLFNM_XDIGIT])
+ found = ISXDIGIT(*s);
+ else if(charset[CURLFNM_PRINT])
+ found = ISPRINT(*s);
+ else if(charset[CURLFNM_SPACE])
+ found = ISSPACE(*s);
+ else if(charset[CURLFNM_UPPER])
+ found = ISUPPER(*s);
+ else if(charset[CURLFNM_LOWER])
+ found = ISLOWER(*s);
+ else if(charset[CURLFNM_BLANK])
+ found = ISBLANK(*s);
+ else if(charset[CURLFNM_GRAPH])
+ found = ISGRAPH(*s);
- if(charset[CURLFNM_NEGATE])
- found = !found;
+ if(charset[CURLFNM_NEGATE])
+ found = !found;
- if(found) {
- p = pp+1;
- s++;
- memset(charset, 0, CURLFNM_CHSET_SIZE);
- }
- else
- return CURL_FNMATCH_NOMATCH;
- }
- else
- return CURL_FNMATCH_FAIL;
- }
- else {
- if(*p++ != *s++)
- return CURL_FNMATCH_NOMATCH;
- }
- break;
- case CURLFNM_LOOP_BACKSLASH:
- if(ISPRINT(*p)) {
- if(*p++ == *s++)
- state = CURLFNM_LOOP_DEFAULT;
- else
+ if(!found)
return CURL_FNMATCH_NOMATCH;
+ p = pp + 1;
+ s++;
+ break;
}
- else
- return CURL_FNMATCH_FAIL;
+ /* Syntax error in set; mismatch! */
+ return CURL_FNMATCH_NOMATCH;
+
+ default:
+ if(*p++ != *s++)
+ return CURL_FNMATCH_NOMATCH;
break;
}
}
@@ -420,5 +357,33 @@ int Curl_fnmatch(void *ptr, const char *pattern, const char *string)
if(!pattern || !string) {
return CURL_FNMATCH_FAIL;
}
- return loop((unsigned char *)pattern, (unsigned char *)string);
+ return loop((unsigned char *)pattern, (unsigned char *)string, 2);
}
+#else
+#include <fnmatch.h>
+/*
+ * @unittest: 1307
+ */
+int Curl_fnmatch(void *ptr, const char *pattern, const char *string)
+{
+ int rc;
+ (void)ptr; /* the argument is specified by the curl_fnmatch_callback
+ prototype, but not used by Curl_fnmatch() */
+ if(!pattern || !string) {
+ return CURL_FNMATCH_FAIL;
+ }
+ rc = fnmatch(pattern, string, 0);
+ switch(rc) {
+ case 0:
+ return CURL_FNMATCH_MATCH;
+ case FNM_NOMATCH:
+ return CURL_FNMATCH_NOMATCH;
+ default:
+ return CURL_FNMATCH_FAIL;
+ }
+ /* not reached */
+}
+
+#endif
+
+#endif /* if FTP is disabled */
diff --git a/Utilities/cmcurl/lib/curl_get_line.c b/Utilities/cmcurl/lib/curl_get_line.c
new file mode 100644
index 000000000..c4194851a
--- /dev/null
+++ b/Utilities/cmcurl/lib/curl_get_line.c
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#include "curl_get_line.h"
+#include "curl_memory.h"
+/* The last #include file should be: */
+#include "memdebug.h"
+
+/*
+ * get_line() makes sure to only return complete whole lines that fit in 'len'
+ * bytes and end with a newline.
+ */
+char *Curl_get_line(char *buf, int len, FILE *input)
+{
+ bool partial = FALSE;
+ while(1) {
+ char *b = fgets(buf, len, input);
+ if(b) {
+ size_t rlen = strlen(b);
+ if(rlen && (b[rlen-1] == '\n')) {
+ if(partial) {
+ partial = FALSE;
+ continue;
+ }
+ return b;
+ }
+ /* read a partial, discard the next piece that ends with newline */
+ partial = TRUE;
+ }
+ else
+ break;
+ }
+ return NULL;
+}
diff --git a/Utilities/cmcurl/lib/curl_get_line.h b/Utilities/cmcurl/lib/curl_get_line.h
new file mode 100644
index 000000000..532ab080a
--- /dev/null
+++ b/Utilities/cmcurl/lib/curl_get_line.h
@@ -0,0 +1,29 @@
+#ifndef HEADER_CURL_GET_LINE_H
+#define HEADER_CURL_GET_LINE_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+/* get_line() makes sure to only return complete whole lines that fit in 'len'
+ * bytes and end with a newline. */
+char *Curl_get_line(char *buf, int len, FILE *input);
+
+#endif /* HEADER_CURL_GET_LINE_H */
diff --git a/Utilities/cmcurl/lib/curl_gssapi.c b/Utilities/cmcurl/lib/curl_gssapi.c
index 83f3fa0c4..d854ab0c7 100644
--- a/Utilities/cmcurl/lib/curl_gssapi.c
+++ b/Utilities/cmcurl/lib/curl_gssapi.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2011 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2011 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -27,6 +27,11 @@
#include "curl_gssapi.h"
#include "sendf.h"
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "memdebug.h"
+
static char spnego_oid_bytes[] = "\x2b\x06\x01\x05\x05\x02";
gss_OID_desc Curl_spnego_mech_oid = { 6, &spnego_oid_bytes };
static char krb5_oid_bytes[] = "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02";
@@ -92,9 +97,9 @@ static size_t display_gss_error(OM_uint32 status, int type,
&msg_ctx,
&status_string);
if(GSS_LOG_BUFFER_LEN > len + status_string.length + 3) {
- len += snprintf(buf + len, GSS_LOG_BUFFER_LEN - len,
- "%.*s. ", (int)status_string.length,
- (char *)status_string.value);
+ len += msnprintf(buf + len, GSS_LOG_BUFFER_LEN - len,
+ "%.*s. ", (int)status_string.length,
+ (char *)status_string.value);
}
gss_release_buffer(&min_stat, &status_string);
} while(!GSS_ERROR(maj_stat) && msg_ctx != 0);
diff --git a/Utilities/cmcurl/lib/curl_gssapi.h b/Utilities/cmcurl/lib/curl_gssapi.h
index 9700a2817..88f68dbbb 100644
--- a/Utilities/cmcurl/lib/curl_gssapi.h
+++ b/Utilities/cmcurl/lib/curl_gssapi.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2011 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2011 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -26,19 +26,6 @@
#include "urldata.h"
#ifdef HAVE_GSSAPI
-
-#ifdef HAVE_GSSGNU
-# include <gss.h>
-#elif defined HAVE_GSSMIT
- /* MIT style */
-# include <gssapi/gssapi.h>
-# include <gssapi/gssapi_generic.h>
-# include <gssapi/gssapi_krb5.h>
-#else
- /* Heimdal-style */
-# include <gssapi.h>
-#endif
-
extern gss_OID_desc Curl_spnego_mech_oid;
extern gss_OID_desc Curl_krb5_mech_oid;
@@ -71,5 +58,4 @@ void Curl_gss_log_error(struct Curl_easy *data, const char *prefix,
#define GSSAUTH_P_PRIVACY 4
#endif /* HAVE_GSSAPI */
-
#endif /* HEADER_CURL_GSSAPI_H */
diff --git a/Utilities/cmcurl/lib/curl_ldap.h b/Utilities/cmcurl/lib/curl_ldap.h
index 27d03810f..94c002948 100644
--- a/Utilities/cmcurl/lib/curl_ldap.h
+++ b/Utilities/cmcurl/lib/curl_ldap.h
@@ -32,4 +32,3 @@ extern const struct Curl_handler Curl_handler_ldaps;
#endif
#endif /* HEADER_CURL_LDAP_H */
-
diff --git a/Utilities/cmcurl/lib/curl_md4.h b/Utilities/cmcurl/lib/curl_md4.h
index e0690416d..392203f9e 100644
--- a/Utilities/cmcurl/lib/curl_md4.h
+++ b/Utilities/cmcurl/lib/curl_md4.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -25,11 +25,13 @@
#include "curl_setup.h"
#if defined(USE_NSS) || defined(USE_OS400CRYPTO) || \
+ (defined(USE_OPENSSL) && defined(OPENSSL_NO_MD4)) || \
(defined(USE_MBEDTLS) && !defined(MBEDTLS_MD4_C))
void Curl_md4it(unsigned char *output, const unsigned char *input, size_t len);
#endif /* defined(USE_NSS) || defined(USE_OS400CRYPTO) ||
+ (defined(USE_OPENSSL) && defined(OPENSSL_NO_MD4)) ||
(defined(USE_MBEDTLS) && !defined(MBEDTLS_MD4_C)) */
#endif /* HEADER_CURL_MD4_H */
diff --git a/Utilities/cmcurl/lib/curl_md5.h b/Utilities/cmcurl/lib/curl_md5.h
index 5f70c9634..aaf25f61b 100644
--- a/Utilities/cmcurl/lib/curl_md5.h
+++ b/Utilities/cmcurl/lib/curl_md5.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -53,10 +53,10 @@ void Curl_md5it(unsigned char *output,
const unsigned char *input);
MD5_context * Curl_MD5_init(const MD5_params *md5params);
-int Curl_MD5_update(MD5_context *context,
- const unsigned char *data,
- unsigned int len);
-int Curl_MD5_final(MD5_context *context, unsigned char *result);
+CURLcode Curl_MD5_update(MD5_context *context,
+ const unsigned char *data,
+ unsigned int len);
+CURLcode Curl_MD5_final(MD5_context *context, unsigned char *result);
#endif
diff --git a/Utilities/cmcurl/lib/curl_memory.h b/Utilities/cmcurl/lib/curl_memory.h
index fccf46879..ce38a08cd 100644
--- a/Utilities/cmcurl/lib/curl_memory.h
+++ b/Utilities/cmcurl/lib/curl_memory.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -39,7 +39,7 @@
*
* File lib/strdup.c is an exception, given that it provides a strdup
* clone implementation while using malloc. Extra care needed inside
- * this one. TODO: revisit this paragraph and related code.
+ * this one.
*
* The need for curl_memory.h inclusion is due to libcurl's feature
* of allowing library user to provide memory replacement functions,
diff --git a/Utilities/cmcurl/lib/curl_memrchr.c b/Utilities/cmcurl/lib/curl_memrchr.c
index c521497b2..eeb3044a9 100644
--- a/Utilities/cmcurl/lib/curl_memrchr.c
+++ b/Utilities/cmcurl/lib/curl_memrchr.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -44,17 +44,18 @@
void *
Curl_memrchr(const void *s, int c, size_t n)
{
- const unsigned char *p = s;
- const unsigned char *q = s;
+ if(n > 0) {
+ const unsigned char *p = s;
+ const unsigned char *q = s;
- p += n - 1;
+ p += n - 1;
- while(p >= q) {
- if(*p == (unsigned char)c)
- return (void *)p;
- p--;
+ while(p >= q) {
+ if(*p == (unsigned char)c)
+ return (void *)p;
+ p--;
+ }
}
-
return NULL;
}
diff --git a/Utilities/cmcurl/lib/curl_multibyte.c b/Utilities/cmcurl/lib/curl_multibyte.c
index e78bb5002..e48334faf 100644
--- a/Utilities/cmcurl/lib/curl_multibyte.c
+++ b/Utilities/cmcurl/lib/curl_multibyte.c
@@ -64,13 +64,13 @@ char *Curl_convert_wchar_to_UTF8(const wchar_t *str_w)
char *str_utf8 = NULL;
if(str_w) {
- int str_utf8_len = WideCharToMultiByte(CP_UTF8, 0, str_w, -1, NULL,
- 0, NULL, NULL);
- if(str_utf8_len > 0) {
- str_utf8 = malloc(str_utf8_len * sizeof(wchar_t));
+ int bytes = WideCharToMultiByte(CP_UTF8, 0, str_w, -1,
+ NULL, 0, NULL, NULL);
+ if(bytes > 0) {
+ str_utf8 = malloc(bytes);
if(str_utf8) {
- if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, str_utf8_len,
- NULL, FALSE) == 0) {
+ if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, bytes,
+ NULL, NULL) == 0) {
free(str_utf8);
return NULL;
}
diff --git a/Utilities/cmcurl/lib/curl_ntlm_core.c b/Utilities/cmcurl/lib/curl_ntlm_core.c
index aea545295..b6df38f71 100644
--- a/Utilities/cmcurl/lib/curl_ntlm_core.c
+++ b/Utilities/cmcurl/lib/curl_ntlm_core.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -31,27 +31,38 @@
* https://www.innovation.ch/java/ntlm.html
*/
+/* Please keep the SSL backend-specific #if branches in this order:
+
+ 1. USE_OPENSSL
+ 2. USE_GNUTLS_NETTLE
+ 3. USE_GNUTLS
+ 4. USE_NSS
+ 5. USE_MBEDTLS
+ 6. USE_SECTRANSP
+ 7. USE_OS400CRYPTO
+ 8. USE_WIN32_CRYPTO
+
+ This ensures that:
+ - the same SSL branch gets activated throughout this source
+ file even if multiple backends are enabled at the same time.
+ - OpenSSL and NSS have higher priority than Windows Crypt, due
+ to issues with the latter supporting NTLM2Session responses
+ in NTLM type-3 messages.
+ */
+
#if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)
#ifdef USE_OPENSSL
-# ifdef USE_OPENSSL
-# include <openssl/des.h>
-# ifndef OPENSSL_NO_MD4
-# include <openssl/md4.h>
-# endif
-# include <openssl/md5.h>
-# include <openssl/ssl.h>
-# include <openssl/rand.h>
+# include <openssl/des.h>
+# ifndef OPENSSL_NO_MD4
+# include <openssl/md4.h>
# else
-# include <des.h>
-# ifndef OPENSSL_NO_MD4
-# include <md4.h>
-# endif
-# include <md5.h>
-# include <ssl.h>
-# include <rand.h>
+# include "curl_md4.h"
# endif
+# include <openssl/md5.h>
+# include <openssl/ssl.h>
+# include <openssl/rand.h>
# if (OPENSSL_VERSION_NUMBER < 0x00907001L)
# define DES_key_schedule des_key_schedule
# define DES_cblock des_cblock
@@ -76,14 +87,6 @@
# define MD5_DIGEST_LENGTH 16
# define MD4_DIGEST_LENGTH 16
-#elif defined(USE_MBEDTLS)
-
-# include <mbedtls/des.h>
-# include <mbedtls/md4.h>
-# if !defined(MBEDTLS_MD4_C)
-# include "curl_md4.h"
-# endif
-
#elif defined(USE_NSS)
# include <nss.h>
@@ -92,7 +95,15 @@
# include "curl_md4.h"
# define MD5_DIGEST_LENGTH MD5_LENGTH
-#elif defined(USE_DARWINSSL)
+#elif defined(USE_MBEDTLS)
+
+# include <mbedtls/des.h>
+# include <mbedtls/md4.h>
+# if !defined(MBEDTLS_MD4_C)
+# include "curl_md4.h"
+# endif
+
+#elif defined(USE_SECTRANSP)
# include <CommonCrypto/CommonCryptor.h>
# include <CommonCrypto/CommonDigest.h>
@@ -196,26 +207,6 @@ static void setup_des_key(const unsigned char *key_56,
gcry_cipher_setkey(*des, key, sizeof(key));
}
-#elif defined(USE_MBEDTLS)
-
-static bool encrypt_des(const unsigned char *in, unsigned char *out,
- const unsigned char *key_56)
-{
- mbedtls_des_context ctx;
- char key[8];
-
- /* Expand the 56-bit key to 64-bits */
- extend_key_56_to_64(key_56, key);
-
- /* Set the key parity to odd */
- mbedtls_des_key_set_parity((unsigned char *) key);
-
- /* Perform the encryption */
- mbedtls_des_init(&ctx);
- mbedtls_des_setkey_enc(&ctx, (unsigned char *) key);
- return mbedtls_des_crypt_ecb(&ctx, in, out) == 0;
-}
-
#elif defined(USE_NSS)
/*
@@ -281,7 +272,27 @@ fail:
return rv;
}
-#elif defined(USE_DARWINSSL)
+#elif defined(USE_MBEDTLS)
+
+static bool encrypt_des(const unsigned char *in, unsigned char *out,
+ const unsigned char *key_56)
+{
+ mbedtls_des_context ctx;
+ char key[8];
+
+ /* Expand the 56-bit key to 64-bits */
+ extend_key_56_to_64(key_56, key);
+
+ /* Set the key parity to odd */
+ mbedtls_des_key_set_parity((unsigned char *) key);
+
+ /* Perform the encryption */
+ mbedtls_des_init(&ctx);
+ mbedtls_des_setkey_enc(&ctx, (unsigned char *) key);
+ return mbedtls_des_crypt_ecb(&ctx, in, out) == 0;
+}
+
+#elif defined(USE_SECTRANSP)
static bool encrypt_des(const unsigned char *in, unsigned char *out,
const unsigned char *key_56)
@@ -428,7 +439,7 @@ void Curl_ntlm_core_lm_resp(const unsigned char *keys,
setup_des_key(keys + 14, &des);
gcry_cipher_encrypt(des, results + 16, 8, plaintext, 8);
gcry_cipher_close(des);
-#elif defined(USE_MBEDTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) \
+#elif defined(USE_NSS) || defined(USE_MBEDTLS) || defined(USE_SECTRANSP) \
|| defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO)
encrypt_des(plaintext, results, keys);
encrypt_des(plaintext, results + 8, keys + 7);
@@ -492,7 +503,7 @@ CURLcode Curl_ntlm_core_mk_lm_hash(struct Curl_easy *data,
setup_des_key(pw + 7, &des);
gcry_cipher_encrypt(des, lmbuffer + 8, 8, magic, 8);
gcry_cipher_close(des);
-#elif defined(USE_MBEDTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) \
+#elif defined(USE_NSS) || defined(USE_MBEDTLS) || defined(USE_SECTRANSP) \
|| defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO)
encrypt_des(magic, lmbuffer, pw);
encrypt_des(magic, lmbuffer + 8, pw + 7);
@@ -538,8 +549,11 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
unsigned char *ntbuffer /* 21 bytes */)
{
size_t len = strlen(password);
- unsigned char *pw = malloc(len * 2);
+ unsigned char *pw;
CURLcode result;
+ if(len > SIZE_T_MAX/2) /* avoid integer overflow */
+ return CURLE_OUT_OF_MEMORY;
+ pw = len ? malloc(len * 2) : strdup("");
if(!pw)
return CURLE_OUT_OF_MEMORY;
@@ -556,10 +570,14 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
{
/* Create NT hashed password. */
#ifdef USE_OPENSSL
+#if !defined(OPENSSL_NO_MD4)
MD4_CTX MD4pw;
MD4_Init(&MD4pw);
MD4_Update(&MD4pw, pw, 2 * len);
MD4_Final(ntbuffer, &MD4pw);
+#else
+ Curl_md4it(ntbuffer, pw, 2 * len);
+#endif
#elif defined(USE_GNUTLS_NETTLE)
struct md4_ctx MD4pw;
md4_init(&MD4pw);
@@ -571,13 +589,18 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
gcry_md_write(MD4pw, pw, 2 * len);
memcpy(ntbuffer, gcry_md_read(MD4pw, 0), MD4_DIGEST_LENGTH);
gcry_md_close(MD4pw);
-#elif defined(USE_NSS) || defined(USE_OS400CRYPTO) || \
- (defined(USE_MBEDTLS) && !defined(MBEDTLS_MD4_C))
+#elif defined(USE_NSS)
Curl_md4it(ntbuffer, pw, 2 * len);
#elif defined(USE_MBEDTLS)
+#if defined(MBEDTLS_MD4_C)
mbedtls_md4(pw, 2 * len, ntbuffer);
-#elif defined(USE_DARWINSSL)
+#else
+ Curl_md4it(ntbuffer, pw, 2 * len);
+#endif
+#elif defined(USE_SECTRANSP)
(void)CC_MD4(pw, (CC_LONG)(2 * len), ntbuffer);
+#elif defined(USE_OS400CRYPTO)
+ Curl_md4it(ntbuffer, pw, 2 * len);
#elif defined(USE_WIN32_CRYPTO)
HCRYPTPROV hprov;
if(CryptAcquireContext(&hprov, NULL, NULL, PROV_RSA_FULL,
@@ -604,9 +627,9 @@ CURLcode Curl_ntlm_core_mk_nt_hash(struct Curl_easy *data,
#if defined(USE_NTLM_V2) && !defined(USE_WINDOWS_SSPI)
/* This returns the HMAC MD5 digest */
-CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen,
- const unsigned char *data, unsigned int datalen,
- unsigned char *output)
+static CURLcode hmac_md5(const unsigned char *key, unsigned int keylen,
+ const unsigned char *data, unsigned int datalen,
+ unsigned char *output)
{
HMAC_context *ctxt = Curl_HMAC_init(Curl_HMAC_MD5, key, keylen);
@@ -631,19 +654,28 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_hash(const char *user, size_t userlen,
unsigned char *ntlmv2hash)
{
/* Unicode representation */
- size_t identity_len = (userlen + domlen) * 2;
- unsigned char *identity = malloc(identity_len);
+ size_t identity_len;
+ unsigned char *identity;
CURLcode result = CURLE_OK;
+ /* we do the length checks below separately to avoid integer overflow risk
+ on extreme data lengths */
+ if((userlen > SIZE_T_MAX/2) ||
+ (domlen > SIZE_T_MAX/2) ||
+ ((userlen + domlen) > SIZE_T_MAX/2))
+ return CURLE_OUT_OF_MEMORY;
+
+ identity_len = (userlen + domlen) * 2;
+ identity = malloc(identity_len);
+
if(!identity)
return CURLE_OUT_OF_MEMORY;
ascii_uppercase_to_unicode_le(identity, user, userlen);
ascii_to_unicode_le(identity + (userlen << 1), domain, domlen);
- result = Curl_hmac_md5(ntlmhash, 16, identity, curlx_uztoui(identity_len),
- ntlmv2hash);
-
+ result = hmac_md5(ntlmhash, 16, identity, curlx_uztoui(identity_len),
+ ntlmv2hash);
free(identity);
return result;
@@ -711,19 +743,17 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
len = NTLM_HMAC_MD5_LEN + NTLMv2_BLOB_LEN;
/* Allocate the response */
- ptr = malloc(len);
+ ptr = calloc(1, len);
if(!ptr)
return CURLE_OUT_OF_MEMORY;
- memset(ptr, 0, len);
-
/* Create the BLOB structure */
- snprintf((char *)ptr + NTLM_HMAC_MD5_LEN, NTLMv2_BLOB_LEN,
- "%c%c%c%c" /* NTLMv2_BLOB_SIGNATURE */
- "%c%c%c%c", /* Reserved = 0 */
- NTLMv2_BLOB_SIGNATURE[0], NTLMv2_BLOB_SIGNATURE[1],
- NTLMv2_BLOB_SIGNATURE[2], NTLMv2_BLOB_SIGNATURE[3],
- 0, 0, 0, 0);
+ msnprintf((char *)ptr + NTLM_HMAC_MD5_LEN, NTLMv2_BLOB_LEN,
+ "%c%c%c%c" /* NTLMv2_BLOB_SIGNATURE */
+ "%c%c%c%c", /* Reserved = 0 */
+ NTLMv2_BLOB_SIGNATURE[0], NTLMv2_BLOB_SIGNATURE[1],
+ NTLMv2_BLOB_SIGNATURE[2], NTLMv2_BLOB_SIGNATURE[3],
+ 0, 0, 0, 0);
Curl_write64_le(tw, ptr + 24);
memcpy(ptr + 32, challenge_client, 8);
@@ -731,8 +761,8 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
/* Concatenate the Type 2 challenge with the BLOB and do HMAC MD5 */
memcpy(ptr + 8, &ntlm->nonce[0], 8);
- result = Curl_hmac_md5(ntlmv2hash, NTLM_HMAC_MD5_LEN, ptr + 8,
- NTLMv2_BLOB_LEN + 8, hmac_output);
+ result = hmac_md5(ntlmv2hash, NTLM_HMAC_MD5_LEN, ptr + 8,
+ NTLMv2_BLOB_LEN + 8, hmac_output);
if(result) {
free(ptr);
return result;
@@ -774,13 +804,13 @@ CURLcode Curl_ntlm_core_mk_lmv2_resp(unsigned char *ntlmv2hash,
memcpy(&data[0], challenge_server, 8);
memcpy(&data[8], challenge_client, 8);
- result = Curl_hmac_md5(ntlmv2hash, 16, &data[0], 16, hmac_output);
+ result = hmac_md5(ntlmv2hash, 16, &data[0], 16, hmac_output);
if(result)
return result;
/* Concatenate the HMAC MD5 output with the client nonce */
memcpy(lmresp, hmac_output, 16);
- memcpy(lmresp+16, challenge_client, 8);
+ memcpy(lmresp + 16, challenge_client, 8);
return result;
}
diff --git a/Utilities/cmcurl/lib/curl_ntlm_core.h b/Utilities/cmcurl/lib/curl_ntlm_core.h
index 4a83d40bc..3b4b8053c 100644
--- a/Utilities/cmcurl/lib/curl_ntlm_core.h
+++ b/Utilities/cmcurl/lib/curl_ntlm_core.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -26,20 +26,24 @@
#if defined(USE_NTLM)
+/* If NSS is the first available SSL backend (see order in curl_ntlm_core.c)
+ then it must be initialized to be used by NTLM. */
+#if !defined(USE_OPENSSL) && \
+ !defined(USE_GNUTLS_NETTLE) && \
+ !defined(USE_GNUTLS) && \
+ defined(USE_NSS)
+#define NTLM_NEEDS_NSS_INIT
+#endif
+
#if !defined(USE_WINDOWS_SSPI) || defined(USE_WIN32_CRYPTO)
#ifdef USE_OPENSSL
-# if !defined(OPENSSL_VERSION_NUMBER) && \
- !defined(HEADER_SSL_H) && !defined(HEADER_MD5_H)
-# error "curl_ntlm_core.h shall not be included before OpenSSL headers."
-# endif
+# include <openssl/ssl.h>
#endif
/* Define USE_NTRESPONSES in order to make the type-3 message include
* the NT response message. */
-#if !defined(USE_OPENSSL) || !defined(OPENSSL_NO_MD4)
#define USE_NTRESPONSES
-#endif
/* Define USE_NTLM2SESSION in order to make the type-3 message include the
NTLM2Session response message, requires USE_NTRESPONSES defined to 1 and a
diff --git a/Utilities/cmcurl/lib/curl_ntlm_wb.c b/Utilities/cmcurl/lib/curl_ntlm_wb.c
index 9f5b87bc3..80266e2a4 100644
--- a/Utilities/cmcurl/lib/curl_ntlm_wb.c
+++ b/Utilities/cmcurl/lib/curl_ntlm_wb.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -48,10 +48,13 @@
#include "sendf.h"
#include "select.h"
#include "vauth/ntlm.h"
+#include "curl_ntlm_core.h"
#include "curl_ntlm_wb.h"
#include "url.h"
#include "strerror.h"
#include "strdup.h"
+#include "strcase.h"
+
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
@@ -73,7 +76,7 @@
# define sclose_nolog(x) close((x))
#endif
-void Curl_ntlm_wb_cleanup(struct connectdata *conn)
+void Curl_http_auth_cleanup_ntlm_wb(struct connectdata *conn)
{
if(conn->ntlm_auth_hlpr_socket != CURL_SOCKET_BAD) {
sclose(conn->ntlm_auth_hlpr_socket);
@@ -123,7 +126,7 @@ static CURLcode ntlm_wb_init(struct connectdata *conn, const char *userp)
struct passwd pw, *pw_res;
char pwbuf[1024];
#endif
- int error;
+ char buffer[STRERROR_LEN];
/* Return if communication with ntlm_auth already set up */
if(conn->ntlm_auth_hlpr_socket != CURL_SOCKET_BAD ||
@@ -178,26 +181,23 @@ static CURLcode ntlm_wb_init(struct connectdata *conn, const char *userp)
ntlm_auth = NTLM_WB_FILE;
if(access(ntlm_auth, X_OK) != 0) {
- error = ERRNO;
failf(conn->data, "Could not access ntlm_auth: %s errno %d: %s",
- ntlm_auth, error, Curl_strerror(conn, error));
+ ntlm_auth, errno, Curl_strerror(errno, buffer, sizeof(buffer)));
goto done;
}
if(socketpair(AF_UNIX, SOCK_STREAM, 0, sockfds)) {
- error = ERRNO;
failf(conn->data, "Could not open socket pair. errno %d: %s",
- error, Curl_strerror(conn, error));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
goto done;
}
child_pid = fork();
if(child_pid == -1) {
- error = ERRNO;
sclose(sockfds[0]);
sclose(sockfds[1]);
failf(conn->data, "Could not fork. errno %d: %s",
- error, Curl_strerror(conn, error));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
goto done;
}
else if(!child_pid) {
@@ -208,16 +208,14 @@ static CURLcode ntlm_wb_init(struct connectdata *conn, const char *userp)
/* Don't use sclose in the child since it fools the socket leak detector */
sclose_nolog(sockfds[0]);
if(dup2(sockfds[1], STDIN_FILENO) == -1) {
- error = ERRNO;
failf(conn->data, "Could not redirect child stdin. errno %d: %s",
- error, Curl_strerror(conn, error));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
exit(1);
}
if(dup2(sockfds[1], STDOUT_FILENO) == -1) {
- error = ERRNO;
failf(conn->data, "Could not redirect child stdout. errno %d: %s",
- error, Curl_strerror(conn, error));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
exit(1);
}
@@ -235,10 +233,9 @@ static CURLcode ntlm_wb_init(struct connectdata *conn, const char *userp)
"--username", username,
NULL);
- error = ERRNO;
sclose_nolog(sockfds[1]);
failf(conn->data, "Could not execl(). errno %d: %s",
- error, Curl_strerror(conn, error));
+ errno, Curl_strerror(errno, buffer, sizeof(buffer)));
exit(1);
}
@@ -255,6 +252,9 @@ done:
return CURLE_REMOTE_ACCESS_DENIED;
}
+/* if larger than this, something is seriously wrong */
+#define MAX_NTLM_WB_RESPONSE 100000
+
static CURLcode ntlm_wb_response(struct connectdata *conn,
const char *input, curlntlm state)
{
@@ -295,6 +295,13 @@ static CURLcode ntlm_wb_response(struct connectdata *conn,
buf[len_out - 1] = '\0';
break;
}
+
+ if(len_out > MAX_NTLM_WB_RESPONSE) {
+ failf(conn->data, "too large ntlm_wb response!");
+ free(buf);
+ return CURLE_OUT_OF_MEMORY;
+ }
+
newbuf = Curl_saferealloc(buf, len_out + NTLM_BUFSIZE);
if(!newbuf)
return CURLE_OUT_OF_MEMORY;
@@ -320,12 +327,56 @@ static CURLcode ntlm_wb_response(struct connectdata *conn,
conn->response_header = aprintf("NTLM %.*s", len_out - 4, buf + 3);
free(buf);
+ if(!conn->response_header)
+ return CURLE_OUT_OF_MEMORY;
return CURLE_OK;
done:
free(buf);
return CURLE_REMOTE_ACCESS_DENIED;
}
+CURLcode Curl_input_ntlm_wb(struct connectdata *conn,
+ bool proxy,
+ const char *header)
+{
+ curlntlm *state = proxy ? &conn->proxy_ntlm_state : &conn->http_ntlm_state;
+
+ if(!checkprefix("NTLM", header))
+ return CURLE_BAD_CONTENT_ENCODING;
+
+ header += strlen("NTLM");
+ while(*header && ISSPACE(*header))
+ header++;
+
+ if(*header) {
+ conn->challenge_header = strdup(header);
+ if(!conn->challenge_header)
+ return CURLE_OUT_OF_MEMORY;
+
+ *state = NTLMSTATE_TYPE2; /* We got a type-2 message */
+ }
+ else {
+ if(*state == NTLMSTATE_LAST) {
+ infof(conn->data, "NTLM auth restarted\n");
+ Curl_http_auth_cleanup_ntlm_wb(conn);
+ }
+ else if(*state == NTLMSTATE_TYPE3) {
+ infof(conn->data, "NTLM handshake rejected\n");
+ Curl_http_auth_cleanup_ntlm_wb(conn);
+ *state = NTLMSTATE_NONE;
+ return CURLE_REMOTE_ACCESS_DENIED;
+ }
+ else if(*state >= NTLMSTATE_TYPE1) {
+ infof(conn->data, "NTLM handshake failure (internal error)\n");
+ return CURLE_REMOTE_ACCESS_DENIED;
+ }
+
+ *state = NTLMSTATE_TYPE1; /* We should send away a type-1 */
+ }
+
+ return CURLE_OK;
+}
+
/*
* This is for creating ntlm header output by delegating challenge/response
* to Samba's winbind daemon helper ntlm_auth.
@@ -338,8 +389,7 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn,
char **allocuserpwd;
/* point to the name and password for this */
const char *userp;
- /* point to the correct struct with this */
- struct ntlmdata *ntlm;
+ curlntlm *state;
struct auth *authp;
CURLcode res = CURLE_OK;
@@ -351,26 +401,26 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn,
if(proxy) {
allocuserpwd = &conn->allocptr.proxyuserpwd;
userp = conn->http_proxy.user;
- ntlm = &conn->proxyntlm;
+ state = &conn->proxy_ntlm_state;
authp = &conn->data->state.authproxy;
}
else {
allocuserpwd = &conn->allocptr.userpwd;
userp = conn->user;
- ntlm = &conn->ntlm;
+ state = &conn->http_ntlm_state;
authp = &conn->data->state.authhost;
}
authp->done = FALSE;
/* not set means empty */
if(!userp)
- userp="";
+ userp = "";
- switch(ntlm->state) {
+ switch(*state) {
case NTLMSTATE_TYPE1:
default:
/* Use Samba's 'winbind' daemon to support NTLM authentication,
- * by delegating the NTLM challenge/response protocal to a helper
+ * by delegating the NTLM challenge/response protocol to a helper
* in ntlm_auth.
* http://devel.squid-cache.org/ntlm/squid_helper_protocol.html
* https://www.samba.org/samba/docs/man/manpages-3/winbindd.8.html
@@ -385,7 +435,7 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn,
res = ntlm_wb_init(conn, userp);
if(res)
return res;
- res = ntlm_wb_response(conn, "YR\n", ntlm->state);
+ res = ntlm_wb_response(conn, "YR\n", *state);
if(res)
return res;
@@ -395,13 +445,16 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn,
conn->response_header);
DEBUG_OUT(fprintf(stderr, "**** Header %s\n ", *allocuserpwd));
free(conn->response_header);
+ if(!*allocuserpwd)
+ return CURLE_OUT_OF_MEMORY;
conn->response_header = NULL;
break;
+
case NTLMSTATE_TYPE2:
input = aprintf("TT %s\n", conn->challenge_header);
if(!input)
return CURLE_OUT_OF_MEMORY;
- res = ntlm_wb_response(conn, input, ntlm->state);
+ res = ntlm_wb_response(conn, input, *state);
free(input);
input = NULL;
if(res)
@@ -412,15 +465,20 @@ CURLcode Curl_output_ntlm_wb(struct connectdata *conn,
proxy ? "Proxy-" : "",
conn->response_header);
DEBUG_OUT(fprintf(stderr, "**** %s\n ", *allocuserpwd));
- ntlm->state = NTLMSTATE_TYPE3; /* we sent a type-3 */
+ *state = NTLMSTATE_TYPE3; /* we sent a type-3 */
authp->done = TRUE;
- Curl_ntlm_wb_cleanup(conn);
+ Curl_http_auth_cleanup_ntlm_wb(conn);
+ if(!*allocuserpwd)
+ return CURLE_OUT_OF_MEMORY;
break;
+
case NTLMSTATE_TYPE3:
/* connection is already authenticated,
* don't send a header in future requests */
- free(*allocuserpwd);
- *allocuserpwd=NULL;
+ *state = NTLMSTATE_LAST;
+ /* FALLTHROUGH */
+ case NTLMSTATE_LAST:
+ Curl_safefree(*allocuserpwd);
authp->done = TRUE;
break;
}
diff --git a/Utilities/cmcurl/lib/curl_ntlm_wb.h b/Utilities/cmcurl/lib/curl_ntlm_wb.h
index aba3d469c..3cf841cf2 100644
--- a/Utilities/cmcurl/lib/curl_ntlm_wb.h
+++ b/Utilities/cmcurl/lib/curl_ntlm_wb.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -27,11 +27,14 @@
#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
defined(NTLM_WB_ENABLED)
-/* this is for creating ntlm header output by delegating challenge/response
- to Samba's winbind daemon helper ntlm_auth */
+/* this is for ntlm header input */
+CURLcode Curl_input_ntlm_wb(struct connectdata *conn, bool proxy,
+ const char *header);
+
+/* this is for creating ntlm header output */
CURLcode Curl_output_ntlm_wb(struct connectdata *conn, bool proxy);
-void Curl_ntlm_wb_cleanup(struct connectdata *conn);
+void Curl_http_auth_cleanup_ntlm_wb(struct connectdata *conn);
#endif /* !CURL_DISABLE_HTTP && USE_NTLM && NTLM_WB_ENABLED */
diff --git a/Utilities/cmcurl/lib/curl_path.c b/Utilities/cmcurl/lib/curl_path.c
new file mode 100644
index 000000000..85dddcef1
--- /dev/null
+++ b/Utilities/cmcurl/lib/curl_path.c
@@ -0,0 +1,199 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#if defined(USE_SSH)
+
+#include <curl/curl.h>
+#include "curl_memory.h"
+#include "curl_path.h"
+#include "escape.h"
+#include "memdebug.h"
+
+/* figure out the path to work with in this particular request */
+CURLcode Curl_getworkingpath(struct connectdata *conn,
+ char *homedir, /* when SFTP is used */
+ char **path) /* returns the allocated
+ real path to work with */
+{
+ struct Curl_easy *data = conn->data;
+ char *real_path = NULL;
+ char *working_path;
+ size_t working_path_len;
+ CURLcode result =
+ Curl_urldecode(data, data->state.up.path, 0, &working_path,
+ &working_path_len, FALSE);
+ if(result)
+ return result;
+
+ /* Check for /~/, indicating relative to the user's home directory */
+ if(conn->handler->protocol & CURLPROTO_SCP) {
+ real_path = malloc(working_path_len + 1);
+ if(real_path == NULL) {
+ free(working_path);
+ return CURLE_OUT_OF_MEMORY;
+ }
+ if((working_path_len > 3) && (!memcmp(working_path, "/~/", 3)))
+ /* It is referenced to the home directory, so strip the leading '/~/' */
+ memcpy(real_path, working_path + 3, 4 + working_path_len-3);
+ else
+ memcpy(real_path, working_path, 1 + working_path_len);
+ }
+ else if(conn->handler->protocol & CURLPROTO_SFTP) {
+ if((working_path_len > 1) && (working_path[1] == '~')) {
+ size_t homelen = strlen(homedir);
+ real_path = malloc(homelen + working_path_len + 1);
+ if(real_path == NULL) {
+ free(working_path);
+ return CURLE_OUT_OF_MEMORY;
+ }
+ /* It is referenced to the home directory, so strip the
+ leading '/' */
+ memcpy(real_path, homedir, homelen);
+ real_path[homelen] = '/';
+ real_path[homelen + 1] = '\0';
+ if(working_path_len > 3) {
+ memcpy(real_path + homelen + 1, working_path + 3,
+ 1 + working_path_len -3);
+ }
+ }
+ else {
+ real_path = malloc(working_path_len + 1);
+ if(real_path == NULL) {
+ free(working_path);
+ return CURLE_OUT_OF_MEMORY;
+ }
+ memcpy(real_path, working_path, 1 + working_path_len);
+ }
+ }
+
+ free(working_path);
+
+ /* store the pointer for the caller to receive */
+ *path = real_path;
+
+ return CURLE_OK;
+}
+
+/* The get_pathname() function is being borrowed from OpenSSH sftp.c
+ version 4.6p1. */
+/*
+ * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+CURLcode Curl_get_pathname(const char **cpp, char **path, char *homedir)
+{
+ const char *cp = *cpp, *end;
+ char quot;
+ unsigned int i, j;
+ size_t fullPathLength, pathLength;
+ bool relativePath = false;
+ static const char WHITESPACE[] = " \t\r\n";
+
+ if(!*cp) {
+ *cpp = NULL;
+ *path = NULL;
+ return CURLE_QUOTE_ERROR;
+ }
+ /* Ignore leading whitespace */
+ cp += strspn(cp, WHITESPACE);
+ /* Allocate enough space for home directory and filename + separator */
+ fullPathLength = strlen(cp) + strlen(homedir) + 2;
+ *path = malloc(fullPathLength);
+ if(*path == NULL)
+ return CURLE_OUT_OF_MEMORY;
+
+ /* Check for quoted filenames */
+ if(*cp == '\"' || *cp == '\'') {
+ quot = *cp++;
+
+ /* Search for terminating quote, unescape some chars */
+ for(i = j = 0; i <= strlen(cp); i++) {
+ if(cp[i] == quot) { /* Found quote */
+ i++;
+ (*path)[j] = '\0';
+ break;
+ }
+ if(cp[i] == '\0') { /* End of string */
+ /*error("Unterminated quote");*/
+ goto fail;
+ }
+ if(cp[i] == '\\') { /* Escaped characters */
+ i++;
+ if(cp[i] != '\'' && cp[i] != '\"' &&
+ cp[i] != '\\') {
+ /*error("Bad escaped character '\\%c'",
+ cp[i]);*/
+ goto fail;
+ }
+ }
+ (*path)[j++] = cp[i];
+ }
+
+ if(j == 0) {
+ /*error("Empty quotes");*/
+ goto fail;
+ }
+ *cpp = cp + i + strspn(cp + i, WHITESPACE);
+ }
+ else {
+ /* Read to end of filename - either to white space or terminator */
+ end = strpbrk(cp, WHITESPACE);
+ if(end == NULL)
+ end = strchr(cp, '\0');
+ /* return pointer to second parameter if it exists */
+ *cpp = end + strspn(end, WHITESPACE);
+ pathLength = 0;
+ relativePath = (cp[0] == '/' && cp[1] == '~' && cp[2] == '/');
+ /* Handling for relative path - prepend home directory */
+ if(relativePath) {
+ strcpy(*path, homedir);
+ pathLength = strlen(homedir);
+ (*path)[pathLength++] = '/';
+ (*path)[pathLength] = '\0';
+ cp += 3;
+ }
+ /* Copy path name up until first "white space" */
+ memcpy(&(*path)[pathLength], cp, (int)(end - cp));
+ pathLength += (int)(end - cp);
+ (*path)[pathLength] = '\0';
+ }
+ return CURLE_OK;
+
+ fail:
+ Curl_safefree(*path);
+ return CURLE_QUOTE_ERROR;
+}
+
+#endif /* if SSH is used */
diff --git a/Utilities/cmcurl/lib/curl_path.h b/Utilities/cmcurl/lib/curl_path.h
new file mode 100644
index 000000000..636c37f20
--- /dev/null
+++ b/Utilities/cmcurl/lib/curl_path.h
@@ -0,0 +1,47 @@
+#ifndef HEADER_CURL_PATH_H
+#define HEADER_CURL_PATH_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+#include <curl/curl.h>
+#include "urldata.h"
+
+#ifdef WIN32
+# undef PATH_MAX
+# define PATH_MAX MAX_PATH
+# ifndef R_OK
+# define R_OK 4
+# endif
+#endif
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024 /* just an extra precaution since there are systems that
+ have their definition hidden well */
+#endif
+
+CURLcode Curl_getworkingpath(struct connectdata *conn,
+ char *homedir,
+ char **path);
+
+CURLcode Curl_get_pathname(const char **cpp, char **path, char *homedir);
+#endif /* HEADER_CURL_PATH_H */
diff --git a/Utilities/cmcurl/lib/curl_printf.h b/Utilities/cmcurl/lib/curl_printf.h
index 49857cdb0..0d37b8e57 100644
--- a/Utilities/cmcurl/lib/curl_printf.h
+++ b/Utilities/cmcurl/lib/curl_printf.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -31,7 +31,7 @@
# undef printf
# undef fprintf
-# undef snprintf
+# undef msnprintf
# undef vprintf
# undef vfprintf
# undef vsnprintf
@@ -39,18 +39,10 @@
# undef vaprintf
# define printf curl_mprintf
# define fprintf curl_mfprintf
-# define snprintf curl_msnprintf
+# define msnprintf curl_msnprintf
# define vprintf curl_mvprintf
# define vfprintf curl_mvfprintf
-# define vsnprintf curl_mvsnprintf
+# define mvsnprintf curl_mvsnprintf
# define aprintf curl_maprintf
# define vaprintf curl_mvaprintf
-
-/* We define away the sprintf functions unconditonally since we don't want
- internal code to be using them, intentionally or by mistake!*/
-# undef sprintf
-# undef vsprintf
-# define sprintf sprintf_was_used
-# define vsprintf vsprintf_was_used
-
#endif /* HEADER_CURL_PRINTF_H */
diff --git a/Utilities/cmcurl/lib/curl_range.c b/Utilities/cmcurl/lib/curl_range.c
new file mode 100644
index 000000000..aa3c49332
--- /dev/null
+++ b/Utilities/cmcurl/lib/curl_range.c
@@ -0,0 +1,95 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+#include <curl/curl.h>
+#include "curl_range.h"
+#include "sendf.h"
+#include "strtoofft.h"
+
+/* Only include this function if one or more of FTP, FILE are enabled. */
+#if !defined(CURL_DISABLE_FTP) || !defined(CURL_DISABLE_FILE)
+
+ /*
+ Check if this is a range download, and if so, set the internal variables
+ properly.
+ */
+CURLcode Curl_range(struct connectdata *conn)
+{
+ curl_off_t from, to;
+ char *ptr;
+ char *ptr2;
+ struct Curl_easy *data = conn->data;
+
+ if(data->state.use_range && data->state.range) {
+ CURLofft from_t;
+ CURLofft to_t;
+ from_t = curlx_strtoofft(data->state.range, &ptr, 0, &from);
+ if(from_t == CURL_OFFT_FLOW)
+ return CURLE_RANGE_ERROR;
+ while(*ptr && (ISSPACE(*ptr) || (*ptr == '-')))
+ ptr++;
+ to_t = curlx_strtoofft(ptr, &ptr2, 0, &to);
+ if(to_t == CURL_OFFT_FLOW)
+ return CURLE_RANGE_ERROR;
+ if((to_t == CURL_OFFT_INVAL) && !from_t) {
+ /* X - */
+ data->state.resume_from = from;
+ DEBUGF(infof(data, "RANGE %" CURL_FORMAT_CURL_OFF_T " to end of file\n",
+ from));
+ }
+ else if((from_t == CURL_OFFT_INVAL) && !to_t) {
+ /* -Y */
+ data->req.maxdownload = to;
+ data->state.resume_from = -to;
+ DEBUGF(infof(data, "RANGE the last %" CURL_FORMAT_CURL_OFF_T " bytes\n",
+ to));
+ }
+ else {
+ /* X-Y */
+ curl_off_t totalsize;
+
+ /* Ensure the range is sensible - to should follow from. */
+ if(from > to)
+ return CURLE_RANGE_ERROR;
+
+ totalsize = to - from;
+ if(totalsize == CURL_OFF_T_MAX)
+ return CURLE_RANGE_ERROR;
+
+ data->req.maxdownload = totalsize + 1; /* include last byte */
+ data->state.resume_from = from;
+ DEBUGF(infof(data, "RANGE from %" CURL_FORMAT_CURL_OFF_T
+ " getting %" CURL_FORMAT_CURL_OFF_T " bytes\n",
+ from, data->req.maxdownload));
+ }
+ DEBUGF(infof(data, "range-download from %" CURL_FORMAT_CURL_OFF_T
+ " to %" CURL_FORMAT_CURL_OFF_T ", totally %"
+ CURL_FORMAT_CURL_OFF_T " bytes\n",
+ from, to, data->req.maxdownload));
+ }
+ else
+ data->req.maxdownload = -1;
+ return CURLE_OK;
+}
+
+#endif
diff --git a/Utilities/cmcurl/lib/curl_range.h b/Utilities/cmcurl/lib/curl_range.h
new file mode 100644
index 000000000..2350df992
--- /dev/null
+++ b/Utilities/cmcurl/lib/curl_range.h
@@ -0,0 +1,30 @@
+#ifndef HEADER_CURL_RANGE_H
+#define HEADER_CURL_RANGE_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+#include "urldata.h"
+
+CURLcode Curl_range(struct connectdata *conn);
+
+#endif /* HEADER_CURL_RANGE_H */
diff --git a/Utilities/cmcurl/lib/curl_rtmp.c b/Utilities/cmcurl/lib/curl_rtmp.c
index 87a6caf9e..16b1de1ae 100644
--- a/Utilities/cmcurl/lib/curl_rtmp.c
+++ b/Utilities/cmcurl/lib/curl_rtmp.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2012 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2010, Howard Chu, <hyc@highlandsun.com>
*
* This software is licensed as described in the file COPYING, which
@@ -37,9 +37,11 @@
/* The last #include file should be: */
#include "memdebug.h"
-#ifdef _WIN32
+#if defined(WIN32) && !defined(USE_LWIPSOCK)
#define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
#define SET_RCVTIMEO(tv,s) int tv = s*1000
+#elif defined(LWIP_SO_SNDRCVTIMEO_NONSTANDARD)
+#define SET_RCVTIMEO(tv,s) int tv = s*1000
#else
#define SET_RCVTIMEO(tv,s) struct timeval tv = {s,0}
#endif
@@ -74,6 +76,7 @@ const struct Curl_handler Curl_handler_rtmp = {
ZERO_NULL, /* perform_getsock */
rtmp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_RTMP, /* defport */
CURLPROTO_RTMP, /* protocol */
PROTOPT_NONE /* flags*/
@@ -94,6 +97,7 @@ const struct Curl_handler Curl_handler_rtmpt = {
ZERO_NULL, /* perform_getsock */
rtmp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_RTMPT, /* defport */
CURLPROTO_RTMPT, /* protocol */
PROTOPT_NONE /* flags*/
@@ -114,6 +118,7 @@ const struct Curl_handler Curl_handler_rtmpe = {
ZERO_NULL, /* perform_getsock */
rtmp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_RTMP, /* defport */
CURLPROTO_RTMPE, /* protocol */
PROTOPT_NONE /* flags*/
@@ -134,6 +139,7 @@ const struct Curl_handler Curl_handler_rtmpte = {
ZERO_NULL, /* perform_getsock */
rtmp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_RTMPT, /* defport */
CURLPROTO_RTMPTE, /* protocol */
PROTOPT_NONE /* flags*/
@@ -154,6 +160,7 @@ const struct Curl_handler Curl_handler_rtmps = {
ZERO_NULL, /* perform_getsock */
rtmp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_RTMPS, /* defport */
CURLPROTO_RTMPS, /* protocol */
PROTOPT_NONE /* flags*/
@@ -174,6 +181,7 @@ const struct Curl_handler Curl_handler_rtmpts = {
ZERO_NULL, /* perform_getsock */
rtmp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_RTMPS, /* defport */
CURLPROTO_RTMPTS, /* protocol */
PROTOPT_NONE /* flags*/
@@ -200,7 +208,7 @@ static CURLcode rtmp_connect(struct connectdata *conn, bool *done)
RTMP *r = conn->proto.generic;
SET_RCVTIMEO(tv, 10);
- r->m_sb.sb_socket = conn->sock[FIRSTSOCKET];
+ r->m_sb.sb_socket = (int)conn->sock[FIRSTSOCKET];
/* We have to know if it's a write before we send the
* connect request packet
@@ -231,17 +239,18 @@ static CURLcode rtmp_connect(struct connectdata *conn, bool *done)
static CURLcode rtmp_do(struct connectdata *conn, bool *done)
{
+ struct Curl_easy *data = conn->data;
RTMP *r = conn->proto.generic;
if(!RTMP_ConnectStream(r, 0))
return CURLE_FAILED_INIT;
if(conn->data->set.upload) {
- Curl_pgrsSetUploadSize(conn->data, conn->data->state.infilesize);
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, FIRSTSOCKET, NULL);
+ Curl_pgrsSetUploadSize(data, data->state.infilesize);
+ Curl_setup_transfer(data, -1, -1, FALSE, FIRSTSOCKET);
}
else
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, FALSE, -1);
*done = TRUE;
return CURLE_OK;
}
diff --git a/Utilities/cmcurl/lib/curl_sasl.c b/Utilities/cmcurl/lib/curl_sasl.c
index bd574b5e2..018e4228b 100644
--- a/Utilities/cmcurl/lib/curl_sasl.c
+++ b/Utilities/cmcurl/lib/curl_sasl.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -31,6 +31,9 @@
#include "curl_setup.h"
+#if !defined(CURL_DISABLE_IMAP) || !defined(CURL_DISABLE_SMTP) || \
+ !defined(CURL_DISABLE_POP3)
+
#include <curl/curl.h>
#include "urldata.h"
@@ -83,14 +86,14 @@ void Curl_sasl_cleanup(struct connectdata *conn, unsigned int authused)
#if defined(USE_KERBEROS5)
/* Cleanup the gssapi structure */
if(authused == SASL_MECH_GSSAPI) {
- Curl_auth_gssapi_cleanup(&conn->krb5);
+ Curl_auth_cleanup_gssapi(&conn->krb5);
}
#endif
#if defined(USE_NTLM)
/* Cleanup the NTLM structure */
if(authused == SASL_MECH_NTLM) {
- Curl_auth_ntlm_cleanup(&conn->ntlm);
+ Curl_auth_cleanup_ntlm(&conn->ntlm);
}
#endif
@@ -146,7 +149,6 @@ CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl,
const char *value, size_t len)
{
CURLcode result = CURLE_OK;
- unsigned int mechbit;
size_t mechlen;
if(!len)
@@ -160,7 +162,7 @@ CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl,
if(!strncmp(value, "*", len))
sasl->prefmech = SASL_AUTH_DEFAULT;
else {
- mechbit = Curl_sasl_decode_mech(value, len, &mechlen);
+ unsigned int mechbit = Curl_sasl_decode_mech(value, len, &mechlen);
if(mechbit && mechlen == len)
sasl->prefmech |= mechbit;
else
@@ -265,7 +267,7 @@ CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn,
const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port;
-#if defined(USE_KERBEROS5)
+#if defined(USE_KERBEROS5) || defined(USE_NTLM)
const char *service = data->set.str[STRING_SERVICE_NAME] ?
data->set.str[STRING_SERVICE_NAME] :
sasl->params->service;
@@ -291,7 +293,7 @@ CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn,
#if defined(USE_KERBEROS5)
if((enabledmechs & SASL_MECH_GSSAPI) && Curl_auth_is_gssapi_supported() &&
Curl_auth_user_contains_domain(conn->user)) {
- sasl->mutual_auth = FALSE; /* TODO: Calculate mutual authentication */
+ sasl->mutual_auth = FALSE;
mech = SASL_MECH_STRING_GSSAPI;
state1 = SASL_GSSAPI;
state2 = SASL_GSSAPI_TOKEN;
@@ -301,8 +303,7 @@ CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn,
result = Curl_auth_create_gssapi_user_message(data, conn->user,
conn->passwd,
service,
- data->easy_conn->
- host.name,
+ data->conn->host.name,
sasl->mutual_auth,
NULL, &conn->krb5,
&resp, &len);
@@ -331,8 +332,12 @@ CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn,
sasl->authused = SASL_MECH_NTLM;
if(force_ir || data->set.sasl_ir)
- result = Curl_auth_create_ntlm_type1_message(conn->user, conn->passwd,
- &conn->ntlm, &resp, &len);
+ result = Curl_auth_create_ntlm_type1_message(data,
+ conn->user, conn->passwd,
+ service,
+ hostname,
+ &conn->ntlm, &resp,
+ &len);
}
else
#endif
@@ -355,10 +360,18 @@ CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn,
sasl->authused = SASL_MECH_XOAUTH2;
if(force_ir || data->set.sasl_ir)
- result = Curl_auth_create_oauth_bearer_message(data, conn->user,
- NULL, 0,
- conn->oauth_bearer,
- &resp, &len);
+ result = Curl_auth_create_xoauth_bearer_message(data, conn->user,
+ conn->oauth_bearer,
+ &resp, &len);
+ }
+ else if(enabledmechs & SASL_MECH_PLAIN) {
+ mech = SASL_MECH_STRING_PLAIN;
+ state1 = SASL_PLAIN;
+ sasl->authused = SASL_MECH_PLAIN;
+
+ if(force_ir || data->set.sasl_ir)
+ result = Curl_auth_create_plain_message(data, NULL, conn->user,
+ conn->passwd, &resp, &len);
}
else if(enabledmechs & SASL_MECH_LOGIN) {
mech = SASL_MECH_STRING_LOGIN;
@@ -369,15 +382,6 @@ CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn,
if(force_ir || data->set.sasl_ir)
result = Curl_auth_create_login_message(data, conn->user, &resp, &len);
}
- else if(enabledmechs & SASL_MECH_PLAIN) {
- mech = SASL_MECH_STRING_PLAIN;
- state1 = SASL_PLAIN;
- sasl->authused = SASL_MECH_PLAIN;
-
- if(force_ir || data->set.sasl_ir)
- result = Curl_auth_create_plain_message(data, conn->user, conn->passwd,
- &resp, &len);
- }
}
if(!result && mech) {
@@ -418,13 +422,11 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
char *chlg = NULL;
size_t chlglen = 0;
#endif
-#if !defined(CURL_DISABLE_CRYPTO_AUTH) || defined(USE_KERBEROS5)
+#if !defined(CURL_DISABLE_CRYPTO_AUTH) || defined(USE_KERBEROS5) || \
+ defined(USE_NTLM)
const char *service = data->set.str[STRING_SERVICE_NAME] ?
data->set.str[STRING_SERVICE_NAME] :
sasl->params->service;
-#endif
-#if !defined(CURL_DISABLE_CRYPTO_AUTH) || defined(USE_KERBEROS5) || \
- defined(USE_NTLM)
char *serverdata;
#endif
size_t len = 0;
@@ -451,9 +453,8 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
*progress = SASL_DONE;
return result;
case SASL_PLAIN:
- result = Curl_auth_create_plain_message(data, conn->user, conn->passwd,
- &resp,
- &len);
+ result = Curl_auth_create_plain_message(data, NULL, conn->user,
+ conn->passwd, &resp, &len);
break;
case SASL_LOGIN:
result = Curl_auth_create_login_message(data, conn->user, &resp, &len);
@@ -493,7 +494,9 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
#ifdef USE_NTLM
case SASL_NTLM:
/* Create the type-1 message */
- result = Curl_auth_create_ntlm_type1_message(conn->user, conn->passwd,
+ result = Curl_auth_create_ntlm_type1_message(data,
+ conn->user, conn->passwd,
+ service, hostname,
&conn->ntlm, &resp, &len);
newstate = SASL_NTLM_TYPE2MSG;
break;
@@ -514,7 +517,7 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
result = Curl_auth_create_gssapi_user_message(data, conn->user,
conn->passwd,
service,
- data->easy_conn->host.name,
+ data->conn->host.name,
sasl->mutual_auth, NULL,
&conn->krb5,
&resp, &len);
@@ -560,10 +563,9 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
newstate = SASL_OAUTH2_RESP;
}
else
- result = Curl_auth_create_oauth_bearer_message(data, conn->user,
- NULL, 0,
- conn->oauth_bearer,
- &resp, &len);
+ result = Curl_auth_create_xoauth_bearer_message(data, conn->user,
+ conn->oauth_bearer,
+ &resp, &len);
break;
case SASL_OAUTH2_RESP:
@@ -624,3 +626,4 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
return result;
}
+#endif /* protocols are enabled that use SASL */
diff --git a/Utilities/cmcurl/lib/curl_setup.h b/Utilities/cmcurl/lib/curl_setup.h
index a6268adf2..efba5ddec 100644
--- a/Utilities/cmcurl/lib/curl_setup.h
+++ b/Utilities/cmcurl/lib/curl_setup.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,6 +22,10 @@
*
***************************************************************************/
+#if defined(BUILDING_LIBCURL) && !defined(CURL_NO_OLDIES)
+#define CURL_NO_OLDIES
+#endif
+
/*
* Define WIN32 when build target is Win32 API
*/
@@ -31,6 +35,20 @@
#define WIN32
#endif
+#ifdef WIN32
+/*
+ * Don't include unneeded stuff in Windows headers to avoid compiler
+ * warnings and macro clashes.
+ * Make sure to define this macro before including any Windows headers.
+ */
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+# ifndef NOGDI
+# define NOGDI
+# endif
+#endif
+
/*
* Include configuration script results or hand-crafted
* configuration file for platforms which lack config tool.
@@ -130,14 +148,7 @@
#include <curl/curl.h>
-/*
- * Ensure that no one is using the old SIZEOF_CURL_OFF_T macro
- */
-
-#ifdef SIZEOF_CURL_OFF_T
-# error "SIZEOF_CURL_OFF_T shall not be defined!"
- Error Compilation_aborted_SIZEOF_CURL_OFF_T_shall_not_be_defined
-#endif
+#define CURL_SIZEOF_CURL_OFF_T SIZEOF_CURL_OFF_T
/*
* Disable other protocols when http is the only one desired.
@@ -174,9 +185,6 @@
# ifndef CURL_DISABLE_SMTP
# define CURL_DISABLE_SMTP
# endif
-# ifndef CURL_DISABLE_RTMP
-# define CURL_DISABLE_RTMP
-# endif
# ifndef CURL_DISABLE_GOPHER
# define CURL_DISABLE_GOPHER
# endif
@@ -195,7 +203,7 @@
/* ================================================================ */
/* No system header file shall be included in this file before this */
-/* point. The only allowed ones are those included from curlbuild.h */
+/* point. The only allowed ones are those included from curl/system.h */
/* ================================================================ */
/*
@@ -216,7 +224,7 @@
/*
* Use getaddrinfo to resolve the IPv4 address literal. If the current network
- * interface doesn’t support IPv4, but supports IPv6, NAT64, and DNS64,
+ * interface doesn't support IPv4, but supports IPv6, NAT64, and DNS64,
* performing this task will result in a synthesized IPv6 address.
*/
#ifdef __APPLE__
@@ -241,9 +249,7 @@
# if defined(_UNICODE) && !defined(UNICODE)
# define UNICODE
# endif
-# ifndef WIN32_LEAN_AND_MEAN
-# define WIN32_LEAN_AND_MEAN
-# endif
+# include <winerror.h>
# include <windows.h>
# ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -308,11 +314,12 @@
#endif
#ifdef __AMIGA__
-# ifndef __ixemul__
-# include <exec/types.h>
-# include <exec/execbase.h>
-# include <proto/exec.h>
-# include <proto/dos.h>
+# include <exec/types.h>
+# include <exec/execbase.h>
+# include <proto/exec.h>
+# include <proto/dos.h>
+# ifdef HAVE_PROTO_BSDSOCKET_H
+# include <proto/bsdsocket.h> /* ensure bsdsocket.library use */
# define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
# endif
#endif
@@ -402,6 +409,11 @@
# define LSEEK_ERROR (off_t)-1
#endif
+#ifndef SIZEOF_TIME_T
+/* assume default size of time_t to be 32 bit */
+#define SIZEOF_TIME_T 4
+#endif
+
/*
* Default sizeof(off_t) in case it hasn't been defined in config file.
*/
@@ -429,6 +441,41 @@
# endif
#endif
+#if (SIZEOF_CURL_OFF_T == 4)
+# define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFF)
+#else
+ /* assume CURL_SIZEOF_CURL_OFF_T == 8 */
+# define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF)
+#endif
+#define CURL_OFF_T_MIN (-CURL_OFF_T_MAX - CURL_OFF_T_C(1))
+
+#if (SIZEOF_TIME_T == 4)
+# ifdef HAVE_TIME_T_UNSIGNED
+# define TIME_T_MAX UINT_MAX
+# define TIME_T_MIN 0
+# else
+# define TIME_T_MAX INT_MAX
+# define TIME_T_MIN INT_MIN
+# endif
+#else
+# ifdef HAVE_TIME_T_UNSIGNED
+# define TIME_T_MAX 0xFFFFFFFFFFFFFFFF
+# define TIME_T_MIN 0
+# else
+# define TIME_T_MAX 0x7FFFFFFFFFFFFFFF
+# define TIME_T_MIN (-TIME_T_MAX - 1)
+# endif
+#endif
+
+#ifndef SIZE_T_MAX
+/* some limits.h headers have this defined, some don't */
+#if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
+#define SIZE_T_MAX 18446744073709551615U
+#else
+#define SIZE_T_MAX 4294967295U
+#endif
+#endif
+
/*
* Arg 2 type for gethostname in case it hasn't been defined in config file.
*/
@@ -612,17 +659,12 @@ int netware_init(void);
#error "Both libidn2 and WinIDN are enabled, choose one."
#endif
-#ifndef SIZEOF_TIME_T
-/* assume default size of time_t to be 32 bit */
-#define SIZEOF_TIME_T 4
-#endif
-
#define LIBIDN_REQUIRED_VERSION "0.4.1"
#if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_NSS) || \
- defined(USE_POLARSSL) || defined(USE_AXTLS) || defined(USE_MBEDTLS) || \
+ defined(USE_POLARSSL) || defined(USE_MBEDTLS) || \
defined(USE_CYASSL) || defined(USE_SCHANNEL) || \
- defined(USE_DARWINSSL) || defined(USE_GSKIT)
+ defined(USE_SECTRANSP) || defined(USE_GSKIT) || defined(USE_MESALINK)
#define USE_SSL /* SSL support has been enabled */
#endif
@@ -641,7 +683,7 @@ int netware_init(void);
/* Single point where USE_NTLM definition might be defined */
#if !defined(CURL_DISABLE_NTLM) && !defined(CURL_DISABLE_CRYPTO_AUTH)
#if defined(USE_OPENSSL) || defined(USE_WINDOWS_SSPI) || \
- defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) || \
+ defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_SECTRANSP) || \
defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \
defined(USE_MBEDTLS)
@@ -655,9 +697,12 @@ int netware_init(void);
#endif
#endif
-/* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */
-#if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE)
-#define CURL_CA_BUNDLE getenv("CURL_CA_BUNDLE")
+#ifdef CURL_WANTS_CA_BUNDLE_ENV
+#error "No longer supported. Set CURLOPT_CAINFO at runtime instead."
+#endif
+
+#if defined(USE_LIBSSH2) || defined(USE_LIBSSH) || defined(USE_WOLFSSH)
+#define USE_SSH
#endif
/*
@@ -731,6 +776,7 @@ Therefore we specify it explicitly. https://github.com/curl/curl/pull/258
#if defined(WIN32) || defined(MSDOS)
#define FOPEN_READTEXT "rt"
#define FOPEN_WRITETEXT "wt"
+#define FOPEN_APPENDTEXT "at"
#elif defined(__CYGWIN__)
/* Cygwin has specific behavior we need to address when WIN32 is not defined.
https://cygwin.com/cygwin-ug-net/using-textbinary.html
@@ -740,9 +786,11 @@ endings either CRLF or LF so 't' is appropriate.
*/
#define FOPEN_READTEXT "rt"
#define FOPEN_WRITETEXT "w"
+#define FOPEN_APPENDTEXT "a"
#else
#define FOPEN_READTEXT "r"
#define FOPEN_WRITETEXT "w"
+#define FOPEN_APPENDTEXT "a"
#endif
/* WinSock destroys recv() buffer when send() failed.
@@ -754,20 +802,44 @@ endings either CRLF or LF so 't' is appropriate.
# if defined(WIN32) || defined(__CYGWIN__)
# define USE_RECV_BEFORE_SEND_WORKAROUND
# endif
-#else /* DONT_USE_RECV_BEFORE_SEND_WORKAROUNDS */
+#else /* DONT_USE_RECV_BEFORE_SEND_WORKAROUND */
# ifdef USE_RECV_BEFORE_SEND_WORKAROUND
# undef USE_RECV_BEFORE_SEND_WORKAROUND
# endif
-#endif /* DONT_USE_RECV_BEFORE_SEND_WORKAROUNDS */
+#endif /* DONT_USE_RECV_BEFORE_SEND_WORKAROUND */
/* Detect Windows App environment which has a restricted access
* to the Win32 APIs. */
-# if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)
+# if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \
+ defined(WINAPI_FAMILY)
# include <winapifamily.h>
-# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
+# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
# define CURL_WINDOWS_APP
# endif
# endif
+/* for systems that don't detect this in configure, use a sensible default */
+#ifndef CURL_SA_FAMILY_T
+#define CURL_SA_FAMILY_T unsigned short
+#endif
+
+/* Some convenience macros to get the larger/smaller value out of two given.
+ We prefix with CURL to prevent name collisions. */
+#define CURLMAX(x,y) ((x)>(y)?(x):(y))
+#define CURLMIN(x,y) ((x)<(y)?(x):(y))
+
+/* Some versions of the Android SDK is missing the declaration */
+#if defined(HAVE_GETPWUID_R) && defined(HAVE_DECL_GETPWUID_R_MISSING)
+struct passwd;
+int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
+ size_t buflen, struct passwd **result);
+#endif
+
+#ifdef DEBUGBUILD
+#define UNITTEST
+#else
+#define UNITTEST static
+#endif
+
#endif /* HEADER_CURL_SETUP_H */
diff --git a/Utilities/cmcurl/lib/curl_setup_once.h b/Utilities/cmcurl/lib/curl_setup_once.h
index 684187cae..413ccea91 100644
--- a/Utilities/cmcurl/lib/curl_setup_once.h
+++ b/Utilities/cmcurl/lib/curl_setup_once.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -101,7 +101,6 @@
# endif
#endif
-
/*
* Definition of timeval struct for platforms that don't have it.
*/
@@ -274,25 +273,6 @@ struct timeval {
# define sfcntl fcntl
#endif
-/*
- * Uppercase macro versions of ANSI/ISO is*() functions/macros which
- * avoid negative number inputs with argument byte codes > 127.
- */
-
-#define ISSPACE(x) (isspace((int) ((unsigned char)x)))
-#define ISDIGIT(x) (isdigit((int) ((unsigned char)x)))
-#define ISALNUM(x) (isalnum((int) ((unsigned char)x)))
-#define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x)))
-#define ISGRAPH(x) (isgraph((int) ((unsigned char)x)))
-#define ISALPHA(x) (isalpha((int) ((unsigned char)x)))
-#define ISPRINT(x) (isprint((int) ((unsigned char)x)))
-#define ISUPPER(x) (isupper((int) ((unsigned char)x)))
-#define ISLOWER(x) (islower((int) ((unsigned char)x)))
-#define ISASCII(x) (isascii((int) ((unsigned char)x)))
-
-#define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \
- (((unsigned char)x) == '\t'))
-
#define TOLOWER(x) (tolower((int) ((unsigned char)x)))
@@ -347,6 +327,7 @@ struct timeval {
#define FALSE false
#endif
+#include "curl_ctype.h"
/*
* Macro WHILE_FALSE may be used to build single-iteration do-while loops,
@@ -436,20 +417,6 @@ typedef int sig_atomic_t;
/*
- * Macro ERRNO / SET_ERRNO() returns / sets the NOT *socket-related* errno
- * (or equivalent) on this platform to hide platform details to code using it.
- */
-
-#if defined(WIN32) && !defined(USE_LWIPSOCK)
-#define ERRNO ((int)GetLastError())
-#define SET_ERRNO(x) (SetLastError((DWORD)(x)))
-#else
-#define ERRNO (errno)
-#define SET_ERRNO(x) (errno = (x))
-#endif
-
-
-/*
* Portable error number symbolic names defined to Winsock error codes.
*/
@@ -548,4 +515,3 @@ typedef int sig_atomic_t;
#endif /* HEADER_CURL_SETUP_ONCE_H */
-
diff --git a/Utilities/cmcurl/lib/curl_sha256.h b/Utilities/cmcurl/lib/curl_sha256.h
new file mode 100644
index 000000000..6db4b04db
--- /dev/null
+++ b/Utilities/cmcurl/lib/curl_sha256.h
@@ -0,0 +1,32 @@
+#ifndef HEADER_CURL_SHA256_H
+#define HEADER_CURL_SHA256_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2010, Florin Petriuc, <petriuc.florin@gmail.com>
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#ifndef CURL_DISABLE_CRYPTO_AUTH
+
+void Curl_sha256it(unsigned char *outbuffer,
+ const unsigned char *input);
+
+#endif
+
+#endif /* HEADER_CURL_SHA256_H */
diff --git a/Utilities/cmcurl/lib/curl_sspi.c b/Utilities/cmcurl/lib/curl_sspi.c
index 11a7120a9..1d0de4ed3 100644
--- a/Utilities/cmcurl/lib/curl_sspi.c
+++ b/Utilities/cmcurl/lib/curl_sspi.c
@@ -90,8 +90,9 @@ CURLcode Curl_sspi_global_init(void)
return CURLE_FAILED_INIT;
/* Get address of the InitSecurityInterfaceA function from the SSPI dll */
- pInitSecurityInterface = (INITSECURITYINTERFACE_FN)
- GetProcAddress(s_hSecDll, SECURITYENTRYPOINT);
+ pInitSecurityInterface =
+ CURLX_FUNCTION_CAST(INITSECURITYINTERFACE_FN,
+ (GetProcAddress(s_hSecDll, SECURITYENTRYPOINT)));
if(!pInitSecurityInterface)
return CURLE_FAILED_INIT;
@@ -131,7 +132,7 @@ void Curl_sspi_global_cleanup(void)
* Parameters:
*
* userp [in] - The user name in the format User or Domain\User.
- * passdwp [in] - The user's password.
+ * passwdp [in] - The user's password.
* identity [in/out] - The identity structure.
*
* Returns CURLE_OK on success.
diff --git a/Utilities/cmcurl/lib/curl_threads.c b/Utilities/cmcurl/lib/curl_threads.c
index a78eff5c2..8e5937aa0 100644
--- a/Utilities/cmcurl/lib/curl_threads.c
+++ b/Utilities/cmcurl/lib/curl_threads.c
@@ -105,14 +105,30 @@ curl_thread_t Curl_thread_create(unsigned int (CURL_STDCALL *func) (void *),
void *arg)
{
#ifdef _WIN32_WCE
- return CreateThread(NULL, 0, func, arg, 0, NULL);
+ typedef HANDLE curl_win_thread_handle_t;
+#elif defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
+ typedef unsigned long curl_win_thread_handle_t;
#else
+ typedef uintptr_t curl_win_thread_handle_t;
+#endif
curl_thread_t t;
- t = (curl_thread_t)_beginthreadex(NULL, 0, func, arg, 0, NULL);
- if((t == 0) || (t == (curl_thread_t)-1L))
+ curl_win_thread_handle_t thread_handle;
+#ifdef _WIN32_WCE
+ thread_handle = CreateThread(NULL, 0, func, arg, 0, NULL);
+#else
+ thread_handle = _beginthreadex(NULL, 0, func, arg, 0, NULL);
+#endif
+ t = (curl_thread_t)thread_handle;
+ if((t == 0) || (t == LongToHandle(-1L))) {
+#ifdef _WIN32_WCE
+ DWORD gle = GetLastError();
+ errno = ((gle == ERROR_ACCESS_DENIED ||
+ gle == ERROR_NOT_ENOUGH_MEMORY) ?
+ EACCES : EINVAL);
+#endif
return curl_thread_t_null;
+ }
return t;
-#endif
}
void Curl_thread_destroy(curl_thread_t hnd)
diff --git a/Utilities/cmcurl/lib/curl_threads.h b/Utilities/cmcurl/lib/curl_threads.h
index 9e0d14a30..2a93644c5 100644
--- a/Utilities/cmcurl/lib/curl_threads.h
+++ b/Utilities/cmcurl/lib/curl_threads.h
@@ -38,7 +38,8 @@
# define curl_thread_t HANDLE
# define curl_thread_t_null (HANDLE)0
# if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || \
- (_WIN32_WINNT < _WIN32_WINNT_VISTA)
+ (_WIN32_WINNT < _WIN32_WINNT_VISTA) || \
+ (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
# define Curl_mutex_init(m) InitializeCriticalSection(m)
# else
# define Curl_mutex_init(m) InitializeCriticalSectionEx(m, 0, 1)
diff --git a/Utilities/cmcurl/lib/curlx.h b/Utilities/cmcurl/lib/curlx.h
index 6168dc119..3e9b516f8 100644
--- a/Utilities/cmcurl/lib/curlx.h
+++ b/Utilities/cmcurl/lib/curlx.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -42,16 +42,6 @@
curl_off_t number from a given string.
*/
-#include "timeval.h"
-/*
- "timeval.h" sets up a 'struct timeval' even for platforms that otherwise
- don't have one and has protos for these functions:
-
- curlx_tvnow()
- curlx_tvdiff()
- curlx_tvdiff_secs()
-*/
-
#include "nonblock.h"
/* "nonblock.h" provides curlx_nonblock() */
@@ -91,25 +81,23 @@
# undef printf
# undef fprintf
# undef sprintf
-# undef snprintf
+# undef msnprintf
# undef vprintf
# undef vfprintf
# undef vsprintf
-# undef vsnprintf
+# undef mvsnprintf
# undef aprintf
# undef vaprintf
# define printf curlx_mprintf
# define fprintf curlx_mfprintf
# define sprintf curlx_msprintf
-# define snprintf curlx_msnprintf
+# define msnprintf curlx_msnprintf
# define vprintf curlx_mvprintf
# define vfprintf curlx_mvfprintf
-# define vsprintf curlx_mvsprintf
-# define vsnprintf curlx_mvsnprintf
+# define mvsnprintf curlx_mvsnprintf
# define aprintf curlx_maprintf
# define vaprintf curlx_mvaprintf
#endif /* ENABLE_CURLX_PRINTF */
#endif /* HEADER_CURL_CURLX_H */
-
diff --git a/Utilities/cmcurl/lib/dict.c b/Utilities/cmcurl/lib/dict.c
index 451ec389a..208a2336f 100644
--- a/Utilities/cmcurl/lib/dict.c
+++ b/Utilities/cmcurl/lib/dict.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -85,6 +85,7 @@ const struct Curl_handler Curl_handler_dict = {
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_DICT, /* defport */
CURLPROTO_DICT, /* protocol */
PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */
@@ -94,17 +95,17 @@ static char *unescape_word(struct Curl_easy *data, const char *inputbuff)
{
char *newp = NULL;
char *dictp;
- char *ptr;
size_t len;
- char ch;
- int olen=0;
CURLcode result = Curl_urldecode(data, inputbuff, 0, &newp, &len, FALSE);
if(!newp || result)
return NULL;
- dictp = malloc(((size_t)len)*2 + 1); /* add one for terminating zero */
+ dictp = malloc(len*2 + 1); /* add one for terminating zero */
if(dictp) {
+ char *ptr;
+ char ch;
+ int olen = 0;
/* According to RFC2229 section 2.2, these letters need to be escaped with
\[letter] */
for(ptr = newp;
@@ -116,7 +117,7 @@ static char *unescape_word(struct Curl_easy *data, const char *inputbuff)
}
dictp[olen++] = ch;
}
- dictp[olen]=0;
+ dictp[olen] = 0;
}
free(newp);
return dictp;
@@ -131,12 +132,11 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
char *strategy = NULL;
char *nthdef = NULL; /* This is not part of the protocol, but required
by RFC 2229 */
- CURLcode result=CURLE_OK;
- struct Curl_easy *data=conn->data;
+ CURLcode result = CURLE_OK;
+ struct Curl_easy *data = conn->data;
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
- char *path = data->state.path;
- curl_off_t *bytecount = &data->req.bytecount;
+ char *path = data->state.up.path;
*done = TRUE; /* unconditionally */
@@ -167,7 +167,7 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
if((word == NULL) || (*word == (char)0)) {
infof(data, "lookup word is missing\n");
- word=(char *)"default";
+ word = (char *)"default";
}
if((database == NULL) || (*database == (char)0)) {
database = (char *)"!";
@@ -199,8 +199,7 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
failf(data, "Failed sending DICT request");
return result;
}
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount,
- -1, NULL); /* no upload */
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, FALSE, -1); /* no upload */
}
else if(strncasecompare(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
strncasecompare(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) ||
@@ -221,7 +220,7 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
if((word == NULL) || (*word == (char)0)) {
infof(data, "lookup word is missing\n");
- word=(char *)"default";
+ word = (char *)"default";
}
if((database == NULL) || (*database == (char)0)) {
database = (char *)"!";
@@ -246,8 +245,7 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
failf(data, "Failed sending DICT request");
return result;
}
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount,
- -1, NULL); /* no upload */
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, FALSE, -1);
}
else {
@@ -269,7 +267,7 @@ static CURLcode dict_do(struct connectdata *conn, bool *done)
return result;
}
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount, -1, NULL);
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, FALSE, -1);
}
}
diff --git a/Utilities/cmcurl/lib/doh.c b/Utilities/cmcurl/lib/doh.c
new file mode 100644
index 000000000..6d1f3303b
--- /dev/null
+++ b/Utilities/cmcurl/lib/doh.c
@@ -0,0 +1,967 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2018 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#ifndef CURL_DISABLE_DOH
+
+#include "urldata.h"
+#include "curl_addrinfo.h"
+#include "doh.h"
+
+#include "sendf.h"
+#include "multiif.h"
+#include "url.h"
+#include "share.h"
+#include "curl_base64.h"
+#include "connect.h"
+#include "strdup.h"
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "memdebug.h"
+
+#define DNS_CLASS_IN 0x01
+#define DOH_MAX_RESPONSE_SIZE 3000 /* bytes */
+
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
+static const char * const errors[]={
+ "",
+ "Bad label",
+ "Out of range",
+ "Label loop",
+ "Too small",
+ "Out of memory",
+ "RDATA length",
+ "Malformat",
+ "Bad RCODE",
+ "Unexpected TYPE",
+ "Unexpected CLASS",
+ "No content",
+ "Bad ID"
+};
+
+static const char *doh_strerror(DOHcode code)
+{
+ if((code >= DOH_OK) && (code <= DOH_DNS_BAD_ID))
+ return errors[code];
+ return "bad error code";
+}
+#endif
+
+#ifdef DEBUGBUILD
+#define UNITTEST
+#else
+#define UNITTEST static
+#endif
+
+UNITTEST DOHcode doh_encode(const char *host,
+ DNStype dnstype,
+ unsigned char *dnsp, /* buffer */
+ size_t len, /* buffer size */
+ size_t *olen) /* output length */
+{
+ size_t hostlen = strlen(host);
+ unsigned char *orig = dnsp;
+ const char *hostp = host;
+
+ if(len < (12 + hostlen + 4))
+ return DOH_TOO_SMALL_BUFFER;
+
+ *dnsp++ = 0; /* 16 bit id */
+ *dnsp++ = 0;
+ *dnsp++ = 0x01; /* |QR| Opcode |AA|TC|RD| Set the RD bit */
+ *dnsp++ = '\0'; /* |RA| Z | RCODE | */
+ *dnsp++ = '\0';
+ *dnsp++ = 1; /* QDCOUNT (number of entries in the question section) */
+ *dnsp++ = '\0';
+ *dnsp++ = '\0'; /* ANCOUNT */
+ *dnsp++ = '\0';
+ *dnsp++ = '\0'; /* NSCOUNT */
+ *dnsp++ = '\0';
+ *dnsp++ = '\0'; /* ARCOUNT */
+
+ /* store a QNAME */
+ do {
+ char *dot = strchr(hostp, '.');
+ size_t labellen;
+ bool found = false;
+ if(dot) {
+ found = true;
+ labellen = dot - hostp;
+ }
+ else
+ labellen = strlen(hostp);
+ if(labellen > 63) {
+ /* too long label, error out */
+ *olen = 0;
+ return DOH_DNS_BAD_LABEL;
+ }
+ *dnsp++ = (unsigned char)labellen;
+ memcpy(dnsp, hostp, labellen);
+ dnsp += labellen;
+ hostp += labellen + 1;
+ if(!found) {
+ *dnsp++ = 0; /* terminating zero */
+ break;
+ }
+ } while(1);
+
+ *dnsp++ = '\0'; /* upper 8 bit TYPE */
+ *dnsp++ = (unsigned char)dnstype;
+ *dnsp++ = '\0'; /* upper 8 bit CLASS */
+ *dnsp++ = DNS_CLASS_IN; /* IN - "the Internet" */
+
+ *olen = dnsp - orig;
+ return DOH_OK;
+}
+
+static size_t
+doh_write_cb(void *contents, size_t size, size_t nmemb, void *userp)
+{
+ size_t realsize = size * nmemb;
+ struct dohresponse *mem = (struct dohresponse *)userp;
+
+ if((mem->size + realsize) > DOH_MAX_RESPONSE_SIZE)
+ /* suspiciously much for us */
+ return 0;
+
+ mem->memory = Curl_saferealloc(mem->memory, mem->size + realsize);
+ if(!mem->memory)
+ /* out of memory! */
+ return 0;
+
+ memcpy(&(mem->memory[mem->size]), contents, realsize);
+ mem->size += realsize;
+
+ return realsize;
+}
+
+/* called from multi.c when this DOH transfer is complete */
+static int Curl_doh_done(struct Curl_easy *doh, CURLcode result)
+{
+ struct Curl_easy *data = doh->set.dohfor;
+ /* so one of the DOH request done for the 'data' transfer is now complete! */
+ data->req.doh.pending--;
+ infof(data, "a DOH request is completed, %u to go\n", data->req.doh.pending);
+ if(result)
+ infof(data, "DOH request %s\n", curl_easy_strerror(result));
+
+ if(!data->req.doh.pending) {
+ /* DOH completed */
+ curl_slist_free_all(data->req.doh.headers);
+ data->req.doh.headers = NULL;
+ Curl_expire(data, 0, EXPIRE_RUN_NOW);
+ }
+ return 0;
+}
+
+#define ERROR_CHECK_SETOPT(x,y) \
+do { \
+ result = curl_easy_setopt(doh, x, y); \
+ if(result) \
+ goto error; \
+} WHILE_FALSE
+
+static CURLcode dohprobe(struct Curl_easy *data,
+ struct dnsprobe *p, DNStype dnstype,
+ const char *host,
+ const char *url, CURLM *multi,
+ struct curl_slist *headers)
+{
+ struct Curl_easy *doh = NULL;
+ char *nurl = NULL;
+ CURLcode result = CURLE_OK;
+ timediff_t timeout_ms;
+ DOHcode d = doh_encode(host, dnstype, p->dohbuffer, sizeof(p->dohbuffer),
+ &p->dohlen);
+ if(d) {
+ failf(data, "Failed to encode DOH packet [%d]\n", d);
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ p->dnstype = dnstype;
+ p->serverdoh.memory = NULL;
+ /* the memory will be grown as needed by realloc in the doh_write_cb
+ function */
+ p->serverdoh.size = 0;
+
+ /* Note: this is code for sending the DoH request with GET but there's still
+ no logic that actually enables this. We should either add that ability or
+ yank out the GET code. Discuss! */
+ if(data->set.doh_get) {
+ char *b64;
+ size_t b64len;
+ result = Curl_base64url_encode(data, (char *)p->dohbuffer, p->dohlen,
+ &b64, &b64len);
+ if(result)
+ goto error;
+ nurl = aprintf("%s?dns=%s", url, b64);
+ free(b64);
+ if(!nurl) {
+ result = CURLE_OUT_OF_MEMORY;
+ goto error;
+ }
+ url = nurl;
+ }
+
+ timeout_ms = Curl_timeleft(data, NULL, TRUE);
+
+ /* Curl_open() is the internal version of curl_easy_init() */
+ result = Curl_open(&doh);
+ if(!result) {
+ /* pass in the struct pointer via a local variable to please coverity and
+ the gcc typecheck helpers */
+ struct dohresponse *resp = &p->serverdoh;
+ ERROR_CHECK_SETOPT(CURLOPT_URL, url);
+ ERROR_CHECK_SETOPT(CURLOPT_WRITEFUNCTION, doh_write_cb);
+ ERROR_CHECK_SETOPT(CURLOPT_WRITEDATA, resp);
+ if(!data->set.doh_get) {
+ ERROR_CHECK_SETOPT(CURLOPT_POSTFIELDS, p->dohbuffer);
+ ERROR_CHECK_SETOPT(CURLOPT_POSTFIELDSIZE, (long)p->dohlen);
+ }
+ ERROR_CHECK_SETOPT(CURLOPT_HTTPHEADER, headers);
+#ifdef USE_NGHTTP2
+ ERROR_CHECK_SETOPT(CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
+#endif
+#ifndef CURLDEBUG
+ /* enforce HTTPS if not debug */
+ ERROR_CHECK_SETOPT(CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
+#endif
+ ERROR_CHECK_SETOPT(CURLOPT_TIMEOUT_MS, (long)timeout_ms);
+ if(data->set.verbose)
+ ERROR_CHECK_SETOPT(CURLOPT_VERBOSE, 1L);
+ if(data->set.no_signal)
+ ERROR_CHECK_SETOPT(CURLOPT_NOSIGNAL, 1L);
+
+ /* Inherit *some* SSL options from the user's transfer. This is a
+ best-guess as to which options are needed for compatibility. #3661 */
+ if(data->set.ssl.falsestart)
+ ERROR_CHECK_SETOPT(CURLOPT_SSL_FALSESTART, 1L);
+ if(data->set.ssl.primary.verifyhost)
+ ERROR_CHECK_SETOPT(CURLOPT_SSL_VERIFYHOST, 2L);
+ if(data->set.proxy_ssl.primary.verifyhost)
+ ERROR_CHECK_SETOPT(CURLOPT_PROXY_SSL_VERIFYHOST, 2L);
+ if(data->set.ssl.primary.verifypeer)
+ ERROR_CHECK_SETOPT(CURLOPT_SSL_VERIFYPEER, 1L);
+ if(data->set.proxy_ssl.primary.verifypeer)
+ ERROR_CHECK_SETOPT(CURLOPT_PROXY_SSL_VERIFYPEER, 1L);
+ if(data->set.ssl.primary.verifystatus)
+ ERROR_CHECK_SETOPT(CURLOPT_SSL_VERIFYSTATUS, 1L);
+ if(data->set.str[STRING_SSL_CAFILE_ORIG]) {
+ ERROR_CHECK_SETOPT(CURLOPT_CAINFO,
+ data->set.str[STRING_SSL_CAFILE_ORIG]);
+ }
+ if(data->set.str[STRING_SSL_CAFILE_PROXY]) {
+ ERROR_CHECK_SETOPT(CURLOPT_PROXY_CAINFO,
+ data->set.str[STRING_SSL_CAFILE_PROXY]);
+ }
+ if(data->set.str[STRING_SSL_CAPATH_ORIG]) {
+ ERROR_CHECK_SETOPT(CURLOPT_CAPATH,
+ data->set.str[STRING_SSL_CAPATH_ORIG]);
+ }
+ if(data->set.str[STRING_SSL_CAPATH_PROXY]) {
+ ERROR_CHECK_SETOPT(CURLOPT_PROXY_CAPATH,
+ data->set.str[STRING_SSL_CAPATH_PROXY]);
+ }
+ if(data->set.str[STRING_SSL_CRLFILE_ORIG]) {
+ ERROR_CHECK_SETOPT(CURLOPT_CRLFILE,
+ data->set.str[STRING_SSL_CRLFILE_ORIG]);
+ }
+ if(data->set.str[STRING_SSL_CRLFILE_PROXY]) {
+ ERROR_CHECK_SETOPT(CURLOPT_PROXY_CRLFILE,
+ data->set.str[STRING_SSL_CRLFILE_PROXY]);
+ }
+ if(data->set.ssl.certinfo)
+ ERROR_CHECK_SETOPT(CURLOPT_CERTINFO, 1L);
+ if(data->set.str[STRING_SSL_RANDOM_FILE]) {
+ ERROR_CHECK_SETOPT(CURLOPT_RANDOM_FILE,
+ data->set.str[STRING_SSL_RANDOM_FILE]);
+ }
+ if(data->set.str[STRING_SSL_EGDSOCKET]) {
+ ERROR_CHECK_SETOPT(CURLOPT_EGDSOCKET,
+ data->set.str[STRING_SSL_EGDSOCKET]);
+ }
+ if(data->set.ssl.no_revoke)
+ ERROR_CHECK_SETOPT(CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);
+ if(data->set.proxy_ssl.no_revoke)
+ ERROR_CHECK_SETOPT(CURLOPT_PROXY_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);
+ if(data->set.ssl.fsslctx)
+ ERROR_CHECK_SETOPT(CURLOPT_SSL_CTX_FUNCTION, data->set.ssl.fsslctx);
+ if(data->set.ssl.fsslctxp)
+ ERROR_CHECK_SETOPT(CURLOPT_SSL_CTX_DATA, data->set.ssl.fsslctxp);
+
+ doh->set.fmultidone = Curl_doh_done;
+ doh->set.dohfor = data; /* identify for which transfer this is done */
+ p->easy = doh;
+
+ /* add this transfer to the multi handle */
+ if(curl_multi_add_handle(multi, doh))
+ goto error;
+ }
+ else
+ goto error;
+ free(nurl);
+ return CURLE_OK;
+
+ error:
+ free(nurl);
+ Curl_close(doh);
+ return result;
+}
+
+/*
+ * Curl_doh() resolves a name using DOH. It resolves a name and returns a
+ * 'Curl_addrinfo *' with the address information.
+ */
+
+Curl_addrinfo *Curl_doh(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ int *waitp)
+{
+ struct Curl_easy *data = conn->data;
+ CURLcode result = CURLE_OK;
+ *waitp = TRUE; /* this never returns synchronously */
+ (void)conn;
+ (void)hostname;
+ (void)port;
+
+ /* start clean, consider allocating this struct on demand */
+ memset(&data->req.doh, 0, sizeof(struct dohdata));
+
+ data->req.doh.host = hostname;
+ data->req.doh.port = port;
+ data->req.doh.headers =
+ curl_slist_append(NULL,
+ "Content-Type: application/dns-message");
+ if(!data->req.doh.headers)
+ goto error;
+
+ if(conn->ip_version != CURL_IPRESOLVE_V6) {
+ /* create IPv4 DOH request */
+ result = dohprobe(data, &data->req.doh.probe[0], DNS_TYPE_A,
+ hostname, data->set.str[STRING_DOH],
+ data->multi, data->req.doh.headers);
+ if(result)
+ goto error;
+ data->req.doh.pending++;
+ }
+
+ if(conn->ip_version != CURL_IPRESOLVE_V4) {
+ /* create IPv6 DOH request */
+ result = dohprobe(data, &data->req.doh.probe[1], DNS_TYPE_AAAA,
+ hostname, data->set.str[STRING_DOH],
+ data->multi, data->req.doh.headers);
+ if(result)
+ goto error;
+ data->req.doh.pending++;
+ }
+ return NULL;
+
+ error:
+ curl_slist_free_all(data->req.doh.headers);
+ data->req.doh.headers = NULL;
+ curl_easy_cleanup(data->req.doh.probe[0].easy);
+ data->req.doh.probe[0].easy = NULL;
+ curl_easy_cleanup(data->req.doh.probe[1].easy);
+ data->req.doh.probe[1].easy = NULL;
+ return NULL;
+}
+
+static DOHcode skipqname(unsigned char *doh, size_t dohlen,
+ unsigned int *indexp)
+{
+ unsigned char length;
+ do {
+ if(dohlen < (*indexp + 1))
+ return DOH_DNS_OUT_OF_RANGE;
+ length = doh[*indexp];
+ if((length & 0xc0) == 0xc0) {
+ /* name pointer, advance over it and be done */
+ if(dohlen < (*indexp + 2))
+ return DOH_DNS_OUT_OF_RANGE;
+ *indexp += 2;
+ break;
+ }
+ if(length & 0xc0)
+ return DOH_DNS_BAD_LABEL;
+ if(dohlen < (*indexp + 1 + length))
+ return DOH_DNS_OUT_OF_RANGE;
+ *indexp += 1 + length;
+ } while(length);
+ return DOH_OK;
+}
+
+static unsigned short get16bit(unsigned char *doh, int index)
+{
+ return (unsigned short)((doh[index] << 8) | doh[index + 1]);
+}
+
+static unsigned int get32bit(unsigned char *doh, int index)
+{
+ return (doh[index] << 24) | (doh[index + 1] << 16) |
+ (doh[index + 2] << 8) | doh[index + 3];
+}
+
+static DOHcode store_a(unsigned char *doh, int index, struct dohentry *d)
+{
+ /* silently ignore addresses over the limit */
+ if(d->numaddr < DOH_MAX_ADDR) {
+ struct dohaddr *a = &d->addr[d->numaddr];
+ a->type = DNS_TYPE_A;
+ memcpy(&a->ip.v4, &doh[index], 4);
+ d->numaddr++;
+ }
+ return DOH_OK;
+}
+
+static DOHcode store_aaaa(unsigned char *doh, int index, struct dohentry *d)
+{
+ /* silently ignore addresses over the limit */
+ if(d->numaddr < DOH_MAX_ADDR) {
+ struct dohaddr *a = &d->addr[d->numaddr];
+ a->type = DNS_TYPE_AAAA;
+ memcpy(&a->ip.v6, &doh[index], 16);
+ d->numaddr++;
+ }
+ return DOH_OK;
+}
+
+static DOHcode cnameappend(struct cnamestore *c,
+ unsigned char *src,
+ size_t len)
+{
+ if(!c->alloc) {
+ c->allocsize = len + 1;
+ c->alloc = malloc(c->allocsize);
+ if(!c->alloc)
+ return DOH_OUT_OF_MEM;
+ }
+ else if(c->allocsize < (c->allocsize + len + 1)) {
+ char *ptr;
+ c->allocsize += len + 1;
+ ptr = realloc(c->alloc, c->allocsize);
+ if(!ptr) {
+ free(c->alloc);
+ return DOH_OUT_OF_MEM;
+ }
+ c->alloc = ptr;
+ }
+ memcpy(&c->alloc[c->len], src, len);
+ c->len += len;
+ c->alloc[c->len] = 0; /* keep it zero terminated */
+ return DOH_OK;
+}
+
+static DOHcode store_cname(unsigned char *doh,
+ size_t dohlen,
+ unsigned int index,
+ struct dohentry *d)
+{
+ struct cnamestore *c;
+ unsigned int loop = 128; /* a valid DNS name can never loop this much */
+ unsigned char length;
+
+ if(d->numcname == DOH_MAX_CNAME)
+ return DOH_OK; /* skip! */
+
+ c = &d->cname[d->numcname++];
+ do {
+ if(index >= dohlen)
+ return DOH_DNS_OUT_OF_RANGE;
+ length = doh[index];
+ if((length & 0xc0) == 0xc0) {
+ int newpos;
+ /* name pointer, get the new offset (14 bits) */
+ if((index + 1) >= dohlen)
+ return DOH_DNS_OUT_OF_RANGE;
+
+ /* move to the the new index */
+ newpos = (length & 0x3f) << 8 | doh[index + 1];
+ index = newpos;
+ continue;
+ }
+ else if(length & 0xc0)
+ return DOH_DNS_BAD_LABEL; /* bad input */
+ else
+ index++;
+
+ if(length) {
+ DOHcode rc;
+ if(c->len) {
+ rc = cnameappend(c, (unsigned char *)".", 1);
+ if(rc)
+ return rc;
+ }
+ if((index + length) > dohlen)
+ return DOH_DNS_BAD_LABEL;
+
+ rc = cnameappend(c, &doh[index], length);
+ if(rc)
+ return rc;
+ index += length;
+ }
+ } while(length && --loop);
+
+ if(!loop)
+ return DOH_DNS_LABEL_LOOP;
+ return DOH_OK;
+}
+
+static DOHcode rdata(unsigned char *doh,
+ size_t dohlen,
+ unsigned short rdlength,
+ unsigned short type,
+ int index,
+ struct dohentry *d)
+{
+ /* RDATA
+ - A (TYPE 1): 4 bytes
+ - AAAA (TYPE 28): 16 bytes
+ - NS (TYPE 2): N bytes */
+ DOHcode rc;
+
+ switch(type) {
+ case DNS_TYPE_A:
+ if(rdlength != 4)
+ return DOH_DNS_RDATA_LEN;
+ rc = store_a(doh, index, d);
+ if(rc)
+ return rc;
+ break;
+ case DNS_TYPE_AAAA:
+ if(rdlength != 16)
+ return DOH_DNS_RDATA_LEN;
+ rc = store_aaaa(doh, index, d);
+ if(rc)
+ return rc;
+ break;
+ case DNS_TYPE_CNAME:
+ rc = store_cname(doh, dohlen, index, d);
+ if(rc)
+ return rc;
+ break;
+ default:
+ /* unsupported type, just skip it */
+ break;
+ }
+ return DOH_OK;
+}
+
+static void init_dohentry(struct dohentry *de)
+{
+ memset(de, 0, sizeof(*de));
+ de->ttl = INT_MAX;
+}
+
+
+UNITTEST DOHcode doh_decode(unsigned char *doh,
+ size_t dohlen,
+ DNStype dnstype,
+ struct dohentry *d)
+{
+ unsigned char rcode;
+ unsigned short qdcount;
+ unsigned short ancount;
+ unsigned short type = 0;
+ unsigned short rdlength;
+ unsigned short nscount;
+ unsigned short arcount;
+ unsigned int index = 12;
+ DOHcode rc;
+
+ if(dohlen < 12)
+ return DOH_TOO_SMALL_BUFFER; /* too small */
+ if(!doh || doh[0] || doh[1])
+ return DOH_DNS_BAD_ID; /* bad ID */
+ rcode = doh[3] & 0x0f;
+ if(rcode)
+ return DOH_DNS_BAD_RCODE; /* bad rcode */
+
+ qdcount = get16bit(doh, 4);
+ while(qdcount) {
+ rc = skipqname(doh, dohlen, &index);
+ if(rc)
+ return rc; /* bad qname */
+ if(dohlen < (index + 4))
+ return DOH_DNS_OUT_OF_RANGE;
+ index += 4; /* skip question's type and class */
+ qdcount--;
+ }
+
+ ancount = get16bit(doh, 6);
+ while(ancount) {
+ unsigned short class;
+ unsigned int ttl;
+
+ rc = skipqname(doh, dohlen, &index);
+ if(rc)
+ return rc; /* bad qname */
+
+ if(dohlen < (index + 2))
+ return DOH_DNS_OUT_OF_RANGE;
+
+ type = get16bit(doh, index);
+ if((type != DNS_TYPE_CNAME) && (type != dnstype))
+ /* Not the same type as was asked for nor CNAME */
+ return DOH_DNS_UNEXPECTED_TYPE;
+ index += 2;
+
+ if(dohlen < (index + 2))
+ return DOH_DNS_OUT_OF_RANGE;
+ class = get16bit(doh, index);
+ if(DNS_CLASS_IN != class)
+ return DOH_DNS_UNEXPECTED_CLASS; /* unsupported */
+ index += 2;
+
+ if(dohlen < (index + 4))
+ return DOH_DNS_OUT_OF_RANGE;
+
+ ttl = get32bit(doh, index);
+ if(ttl < d->ttl)
+ d->ttl = ttl;
+ index += 4;
+
+ if(dohlen < (index + 2))
+ return DOH_DNS_OUT_OF_RANGE;
+
+ rdlength = get16bit(doh, index);
+ index += 2;
+ if(dohlen < (index + rdlength))
+ return DOH_DNS_OUT_OF_RANGE;
+
+ rc = rdata(doh, dohlen, rdlength, type, index, d);
+ if(rc)
+ return rc; /* bad rdata */
+ index += rdlength;
+ ancount--;
+ }
+
+ nscount = get16bit(doh, 8);
+ while(nscount) {
+ rc = skipqname(doh, dohlen, &index);
+ if(rc)
+ return rc; /* bad qname */
+
+ if(dohlen < (index + 8))
+ return DOH_DNS_OUT_OF_RANGE;
+
+ index += 2 + 2 + 4; /* type, class and ttl */
+
+ if(dohlen < (index + 2))
+ return DOH_DNS_OUT_OF_RANGE;
+
+ rdlength = get16bit(doh, index);
+ index += 2;
+ if(dohlen < (index + rdlength))
+ return DOH_DNS_OUT_OF_RANGE;
+ index += rdlength;
+ nscount--;
+ }
+
+ arcount = get16bit(doh, 10);
+ while(arcount) {
+ rc = skipqname(doh, dohlen, &index);
+ if(rc)
+ return rc; /* bad qname */
+
+ if(dohlen < (index + 8))
+ return DOH_DNS_OUT_OF_RANGE;
+
+ index += 2 + 2 + 4; /* type, class and ttl */
+
+ if(dohlen < (index + 2))
+ return DOH_DNS_OUT_OF_RANGE;
+
+ rdlength = get16bit(doh, index);
+ index += 2;
+ if(dohlen < (index + rdlength))
+ return DOH_DNS_OUT_OF_RANGE;
+ index += rdlength;
+ arcount--;
+ }
+
+ if(index != dohlen)
+ return DOH_DNS_MALFORMAT; /* something is wrong */
+
+ if((type != DNS_TYPE_NS) && !d->numcname && !d->numaddr)
+ /* nothing stored! */
+ return DOH_NO_CONTENT;
+
+ return DOH_OK; /* ok */
+}
+
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
+static void showdoh(struct Curl_easy *data,
+ struct dohentry *d)
+{
+ int i;
+ infof(data, "TTL: %u seconds\n", d->ttl);
+ for(i = 0; i < d->numaddr; i++) {
+ struct dohaddr *a = &d->addr[i];
+ if(a->type == DNS_TYPE_A) {
+ infof(data, "DOH A: %u.%u.%u.%u\n",
+ a->ip.v4[0], a->ip.v4[1],
+ a->ip.v4[2], a->ip.v4[3]);
+ }
+ else if(a->type == DNS_TYPE_AAAA) {
+ int j;
+ char buffer[128];
+ char *ptr;
+ size_t len;
+ msnprintf(buffer, 128, "DOH AAAA: ");
+ ptr = &buffer[10];
+ len = 118;
+ for(j = 0; j < 16; j += 2) {
+ size_t l;
+ msnprintf(ptr, len, "%s%02x%02x", j?":":"", d->addr[i].ip.v6[j],
+ d->addr[i].ip.v6[j + 1]);
+ l = strlen(ptr);
+ len -= l;
+ ptr += l;
+ }
+ infof(data, "%s\n", buffer);
+ }
+ }
+ for(i = 0; i < d->numcname; i++) {
+ infof(data, "CNAME: %s\n", d->cname[i].alloc);
+ }
+}
+#else
+#define showdoh(x,y)
+#endif
+
+/*
+ * doh2ai()
+ *
+ * This function returns a pointer to the first element of a newly allocated
+ * Curl_addrinfo struct linked list filled with the data from a set of DOH
+ * lookups. Curl_addrinfo is meant to work like the addrinfo struct does for
+ * a IPv6 stack, but usable also for IPv4, all hosts and environments.
+ *
+ * The memory allocated by this function *MUST* be free'd later on calling
+ * Curl_freeaddrinfo(). For each successful call to this function there
+ * must be an associated call later to Curl_freeaddrinfo().
+ */
+
+static Curl_addrinfo *
+doh2ai(const struct dohentry *de, const char *hostname, int port)
+{
+ Curl_addrinfo *ai;
+ Curl_addrinfo *prevai = NULL;
+ Curl_addrinfo *firstai = NULL;
+ struct sockaddr_in *addr;
+#ifdef ENABLE_IPV6
+ struct sockaddr_in6 *addr6;
+#endif
+ CURLcode result = CURLE_OK;
+ int i;
+
+ if(!de)
+ /* no input == no output! */
+ return NULL;
+
+ for(i = 0; i < de->numaddr; i++) {
+ size_t ss_size;
+ CURL_SA_FAMILY_T addrtype;
+ if(de->addr[i].type == DNS_TYPE_AAAA) {
+#ifndef ENABLE_IPV6
+ /* we can't handle IPv6 addresses */
+ continue;
+#else
+ ss_size = sizeof(struct sockaddr_in6);
+ addrtype = AF_INET6;
+#endif
+ }
+ else {
+ ss_size = sizeof(struct sockaddr_in);
+ addrtype = AF_INET;
+ }
+
+ ai = calloc(1, sizeof(Curl_addrinfo));
+ if(!ai) {
+ result = CURLE_OUT_OF_MEMORY;
+ break;
+ }
+ ai->ai_canonname = strdup(hostname);
+ if(!ai->ai_canonname) {
+ result = CURLE_OUT_OF_MEMORY;
+ free(ai);
+ break;
+ }
+ ai->ai_addr = calloc(1, ss_size);
+ if(!ai->ai_addr) {
+ result = CURLE_OUT_OF_MEMORY;
+ free(ai->ai_canonname);
+ free(ai);
+ break;
+ }
+
+ if(!firstai)
+ /* store the pointer we want to return from this function */
+ firstai = ai;
+
+ if(prevai)
+ /* make the previous entry point to this */
+ prevai->ai_next = ai;
+
+ ai->ai_family = addrtype;
+
+ /* we return all names as STREAM, so when using this address for TFTP
+ the type must be ignored and conn->socktype be used instead! */
+ ai->ai_socktype = SOCK_STREAM;
+
+ ai->ai_addrlen = (curl_socklen_t)ss_size;
+
+ /* leave the rest of the struct filled with zero */
+
+ switch(ai->ai_family) {
+ case AF_INET:
+ addr = (void *)ai->ai_addr; /* storage area for this info */
+ DEBUGASSERT(sizeof(struct in_addr) == sizeof(de->addr[i].ip.v4));
+ memcpy(&addr->sin_addr, &de->addr[i].ip.v4, sizeof(struct in_addr));
+ addr->sin_family = (CURL_SA_FAMILY_T)addrtype;
+ addr->sin_port = htons((unsigned short)port);
+ break;
+
+#ifdef ENABLE_IPV6
+ case AF_INET6:
+ addr6 = (void *)ai->ai_addr; /* storage area for this info */
+ DEBUGASSERT(sizeof(struct in6_addr) == sizeof(de->addr[i].ip.v6));
+ memcpy(&addr6->sin6_addr, &de->addr[i].ip.v6, sizeof(struct in6_addr));
+ addr6->sin6_family = (CURL_SA_FAMILY_T)addrtype;
+ addr6->sin6_port = htons((unsigned short)port);
+ break;
+#endif
+ }
+
+ prevai = ai;
+ }
+
+ if(result) {
+ Curl_freeaddrinfo(firstai);
+ firstai = NULL;
+ }
+
+ return firstai;
+}
+
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
+static const char *type2name(DNStype dnstype)
+{
+ return (dnstype == DNS_TYPE_A)?"A":"AAAA";
+}
+#endif
+
+UNITTEST void de_cleanup(struct dohentry *d)
+{
+ int i = 0;
+ for(i = 0; i < d->numcname; i++) {
+ free(d->cname[i].alloc);
+ }
+}
+
+CURLcode Curl_doh_is_resolved(struct connectdata *conn,
+ struct Curl_dns_entry **dnsp)
+{
+ struct Curl_easy *data = conn->data;
+ *dnsp = NULL; /* defaults to no response */
+
+ if(!data->req.doh.probe[0].easy && !data->req.doh.probe[1].easy) {
+ failf(data, "Could not DOH-resolve: %s", conn->async.hostname);
+ return conn->bits.proxy?CURLE_COULDNT_RESOLVE_PROXY:
+ CURLE_COULDNT_RESOLVE_HOST;
+ }
+ else if(!data->req.doh.pending) {
+ DOHcode rc;
+ DOHcode rc2;
+ struct dohentry de;
+ /* remove DOH handles from multi handle and close them */
+ curl_multi_remove_handle(data->multi, data->req.doh.probe[0].easy);
+ Curl_close(data->req.doh.probe[0].easy);
+ curl_multi_remove_handle(data->multi, data->req.doh.probe[1].easy);
+ Curl_close(data->req.doh.probe[1].easy);
+
+ /* parse the responses, create the struct and return it! */
+ init_dohentry(&de);
+ rc = doh_decode(data->req.doh.probe[0].serverdoh.memory,
+ data->req.doh.probe[0].serverdoh.size,
+ data->req.doh.probe[0].dnstype,
+ &de);
+ free(data->req.doh.probe[0].serverdoh.memory);
+ if(rc) {
+ infof(data, "DOH: %s type %s for %s\n", doh_strerror(rc),
+ type2name(data->req.doh.probe[0].dnstype),
+ data->req.doh.host);
+ }
+ rc2 = doh_decode(data->req.doh.probe[1].serverdoh.memory,
+ data->req.doh.probe[1].serverdoh.size,
+ data->req.doh.probe[1].dnstype,
+ &de);
+ free(data->req.doh.probe[1].serverdoh.memory);
+ if(rc2) {
+ infof(data, "DOH: %s type %s for %s\n", doh_strerror(rc2),
+ type2name(data->req.doh.probe[1].dnstype),
+ data->req.doh.host);
+ }
+ if(!rc || !rc2) {
+ struct Curl_dns_entry *dns;
+ struct Curl_addrinfo *ai;
+
+ infof(data, "DOH Host name: %s\n", data->req.doh.host);
+ showdoh(data, &de);
+
+ ai = doh2ai(&de, data->req.doh.host, data->req.doh.port);
+ if(!ai) {
+ de_cleanup(&de);
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ if(data->share)
+ Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
+
+ /* we got a response, store it in the cache */
+ dns = Curl_cache_addr(data, ai, data->req.doh.host, data->req.doh.port);
+
+ if(data->share)
+ Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
+
+ de_cleanup(&de);
+ if(!dns)
+ /* returned failure, bail out nicely */
+ Curl_freeaddrinfo(ai);
+ else {
+ conn->async.dns = dns;
+ *dnsp = dns;
+ return CURLE_OK;
+ }
+ }
+ de_cleanup(&de);
+
+ return CURLE_COULDNT_RESOLVE_HOST;
+ }
+
+ return CURLE_OK;
+}
+
+#endif /* CURL_DISABLE_DOH */
diff --git a/Utilities/cmcurl/lib/doh.h b/Utilities/cmcurl/lib/doh.h
new file mode 100644
index 000000000..34bfa6f2b
--- /dev/null
+++ b/Utilities/cmcurl/lib/doh.h
@@ -0,0 +1,113 @@
+#ifndef HEADER_CURL_DOH_H
+#define HEADER_CURL_DOH_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2018 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "urldata.h"
+#include "curl_addrinfo.h"
+
+#ifndef CURL_DISABLE_DOH
+
+/*
+ * Curl_doh() resolve a name using DoH (DNS-over-HTTPS). It resolves a name
+ * and returns a 'Curl_addrinfo *' with the address information.
+ */
+
+Curl_addrinfo *Curl_doh(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ int *waitp);
+
+CURLcode Curl_doh_is_resolved(struct connectdata *conn,
+ struct Curl_dns_entry **dns);
+
+int Curl_doh_getsock(struct connectdata *conn, curl_socket_t *socks,
+ int numsocks);
+
+typedef enum {
+ DOH_OK,
+ DOH_DNS_BAD_LABEL, /* 1 */
+ DOH_DNS_OUT_OF_RANGE, /* 2 */
+ DOH_DNS_LABEL_LOOP, /* 3 */
+ DOH_TOO_SMALL_BUFFER, /* 4 */
+ DOH_OUT_OF_MEM, /* 5 */
+ DOH_DNS_RDATA_LEN, /* 6 */
+ DOH_DNS_MALFORMAT, /* 7 */
+ DOH_DNS_BAD_RCODE, /* 8 - no such name */
+ DOH_DNS_UNEXPECTED_TYPE, /* 9 */
+ DOH_DNS_UNEXPECTED_CLASS, /* 10 */
+ DOH_NO_CONTENT, /* 11 */
+ DOH_DNS_BAD_ID /* 12 */
+} DOHcode;
+
+typedef enum {
+ DNS_TYPE_A = 1,
+ DNS_TYPE_NS = 2,
+ DNS_TYPE_CNAME = 5,
+ DNS_TYPE_AAAA = 28
+} DNStype;
+
+#define DOH_MAX_ADDR 24
+#define DOH_MAX_CNAME 4
+
+struct cnamestore {
+ size_t len; /* length of cname */
+ char *alloc; /* allocated pointer */
+ size_t allocsize; /* allocated size */
+};
+
+struct dohaddr {
+ int type;
+ union {
+ unsigned char v4[4]; /* network byte order */
+ unsigned char v6[16];
+ } ip;
+};
+
+struct dohentry {
+ unsigned int ttl;
+ int numaddr;
+ struct dohaddr addr[DOH_MAX_ADDR];
+ int numcname;
+ struct cnamestore cname[DOH_MAX_CNAME];
+};
+
+
+#ifdef DEBUGBUILD
+DOHcode doh_encode(const char *host,
+ DNStype dnstype,
+ unsigned char *dnsp, /* buffer */
+ size_t len, /* buffer size */
+ size_t *olen); /* output length */
+DOHcode doh_decode(unsigned char *doh,
+ size_t dohlen,
+ DNStype dnstype,
+ struct dohentry *d);
+void de_cleanup(struct dohentry *d);
+#endif
+
+#else /* if DOH is disabled */
+#define Curl_doh(a,b,c,d) NULL
+#define Curl_doh_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST
+#endif
+
+#endif /* HEADER_CURL_DOH_H */
diff --git a/Utilities/cmcurl/lib/dotdot.c b/Utilities/cmcurl/lib/dotdot.c
index 20603bcab..2c6177aea 100644
--- a/Utilities/cmcurl/lib/dotdot.c
+++ b/Utilities/cmcurl/lib/dotdot.c
@@ -55,13 +55,15 @@ char *Curl_dedotdotify(const char *input)
size_t inlen = strlen(input);
char *clone;
size_t clen = inlen; /* the length of the cloned input */
- char *out = malloc(inlen+1);
+ char *out = malloc(inlen + 1);
char *outptr;
char *orgclone;
char *queryp;
if(!out)
return NULL; /* out of memory */
+ *out = 0; /* zero terminates, for inputs like "./" */
+
/* get a cloned copy of the input */
clone = strdup(input);
if(!clone) {
@@ -92,25 +94,25 @@ char *Curl_dedotdotify(const char *input)
remove that prefix from the input buffer; otherwise, */
if(!strncmp("./", clone, 2)) {
- clone+=2;
- clen-=2;
+ clone += 2;
+ clen -= 2;
}
else if(!strncmp("../", clone, 3)) {
- clone+=3;
- clen-=3;
+ clone += 3;
+ clen -= 3;
}
/* B. if the input buffer begins with a prefix of "/./" or "/.", where
"." is a complete path segment, then replace that prefix with "/" in
the input buffer; otherwise, */
else if(!strncmp("/./", clone, 3)) {
- clone+=2;
- clen-=2;
+ clone += 2;
+ clen -= 2;
}
else if(!strcmp("/.", clone)) {
clone[1]='/';
clone++;
- clen-=1;
+ clen -= 1;
}
/* C. if the input buffer begins with a prefix of "/../" or "/..", where
@@ -119,8 +121,8 @@ char *Curl_dedotdotify(const char *input)
any) from the output buffer; otherwise, */
else if(!strncmp("/../", clone, 4)) {
- clone+=3;
- clen-=3;
+ clone += 3;
+ clen -= 3;
/* remove the last segment from the output buffer */
while(outptr > out) {
outptr--;
@@ -131,8 +133,8 @@ char *Curl_dedotdotify(const char *input)
}
else if(!strcmp("/..", clone)) {
clone[2]='/';
- clone+=2;
- clen-=2;
+ clone += 2;
+ clen -= 2;
/* remove the last segment from the output buffer */
while(outptr > out) {
outptr--;
@@ -146,8 +148,8 @@ char *Curl_dedotdotify(const char *input)
that from the input buffer; otherwise, */
else if(!strcmp(".", clone) || !strcmp("..", clone)) {
- *clone=0;
- *out=0;
+ *clone = 0;
+ *out = 0;
}
else {
@@ -172,7 +174,7 @@ char *Curl_dedotdotify(const char *input)
from the correct index. */
size_t oindex = queryp - orgclone;
qlen = strlen(&input[oindex]);
- memcpy(outptr, &input[oindex], qlen+1); /* include the ending zero byte */
+ memcpy(outptr, &input[oindex], qlen + 1); /* include the end zero byte */
}
free(orgclone);
diff --git a/Utilities/cmcurl/lib/dotdot.h b/Utilities/cmcurl/lib/dotdot.h
index fac8e6f2a..125af4367 100644
--- a/Utilities/cmcurl/lib/dotdot.h
+++ b/Utilities/cmcurl/lib/dotdot.h
@@ -22,4 +22,4 @@
*
***************************************************************************/
char *Curl_dedotdotify(const char *input);
-#endif
+#endif /* HEADER_CURL_DOTDOT_H */
diff --git a/Utilities/cmcurl/lib/easy.c b/Utilities/cmcurl/lib/easy.c
index 2b1ce9e8a..4a6f96567 100644
--- a/Utilities/cmcurl/lib/easy.c
+++ b/Utilities/cmcurl/lib/easy.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -61,17 +61,22 @@
#include "strdup.h"
#include "progress.h"
#include "easyif.h"
+#include "multiif.h"
#include "select.h"
#include "sendf.h" /* for failf function prototype */
#include "connect.h" /* for Curl_getconnectinfo */
#include "slist.h"
+#include "mime.h"
#include "amigaos.h"
#include "non-ascii.h"
#include "warnless.h"
-#include "conncache.h"
#include "multiif.h"
#include "sigpipe.h"
#include "ssh.h"
+#include "setopt.h"
+#include "http_digest.h"
+#include "system_win32.h"
+
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
@@ -79,70 +84,6 @@
void Curl_version_init(void);
-/* win32_cleanup() is for win32 socket cleanup functionality, the opposite
- of win32_init() */
-static void win32_cleanup(void)
-{
-#ifdef USE_WINSOCK
- WSACleanup();
-#endif
-#ifdef USE_WINDOWS_SSPI
- Curl_sspi_global_cleanup();
-#endif
-}
-
-/* win32_init() performs win32 socket initialization to properly setup the
- stack to allow networking */
-static CURLcode win32_init(void)
-{
-#ifdef USE_WINSOCK
- WORD wVersionRequested;
- WSADATA wsaData;
- int res;
-
-#if defined(ENABLE_IPV6) && (USE_WINSOCK < 2)
- Error IPV6_requires_winsock2
-#endif
-
- wVersionRequested = MAKEWORD(USE_WINSOCK, USE_WINSOCK);
-
- res = WSAStartup(wVersionRequested, &wsaData);
-
- if(res != 0)
- /* Tell the user that we couldn't find a useable */
- /* winsock.dll. */
- return CURLE_FAILED_INIT;
-
- /* Confirm that the Windows Sockets DLL supports what we need.*/
- /* Note that if the DLL supports versions greater */
- /* than wVersionRequested, it will still return */
- /* wVersionRequested in wVersion. wHighVersion contains the */
- /* highest supported version. */
-
- if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) ||
- HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested) ) {
- /* Tell the user that we couldn't find a useable */
-
- /* winsock.dll. */
- WSACleanup();
- return CURLE_FAILED_INIT;
- }
- /* The Windows Sockets DLL is acceptable. Proceed. */
-#elif defined(USE_LWIPSOCK)
- lwip_init();
-#endif
-
-#ifdef USE_WINDOWS_SSPI
- {
- CURLcode result = Curl_sspi_global_init();
- if(result)
- return result;
- }
-#endif
-
- return CURLE_OK;
-}
-
/* true globals -- for curl_global_init() and curl_global_cleanup() */
static unsigned int initialized;
static long init_flags;
@@ -214,17 +155,17 @@ static CURLcode global_init(long flags, bool memoryfuncs)
#endif
}
- if(flags & CURL_GLOBAL_SSL)
- if(!Curl_ssl_init()) {
- DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n"));
- return CURLE_FAILED_INIT;
- }
+ if(!Curl_ssl_init()) {
+ DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n"));
+ return CURLE_FAILED_INIT;
+ }
- if(flags & CURL_GLOBAL_WIN32)
- if(win32_init()) {
- DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
- return CURLE_FAILED_INIT;
- }
+#ifdef WIN32
+ if(Curl_win32_init(flags)) {
+ DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
+ return CURLE_FAILED_INIT;
+ }
+#endif
#ifdef __AMIGA__
if(!Curl_amiga_init()) {
@@ -253,6 +194,13 @@ static CURLcode global_init(long flags, bool memoryfuncs)
}
#endif
+#if defined(USE_LIBSSH)
+ if(ssh_init()) {
+ DEBUGF(fprintf(stderr, "Error: libssh_init failed\n"));
+ return CURLE_FAILED_INIT;
+ }
+#endif
+
if(flags & CURL_GLOBAL_ACK_EINTR)
Curl_ack_eintr = 1;
@@ -317,15 +265,12 @@ void curl_global_cleanup(void)
if(--initialized)
return;
- Curl_global_host_cache_dtor();
-
- if(init_flags & CURL_GLOBAL_SSL)
- Curl_ssl_cleanup();
-
+ Curl_ssl_cleanup();
Curl_resolver_global_cleanup();
- if(init_flags & CURL_GLOBAL_WIN32)
- win32_cleanup();
+#ifdef WIN32
+ Curl_win32_cleanup(init_flags);
+#endif
Curl_amiga_cleanup();
@@ -333,6 +278,10 @@ void curl_global_cleanup(void)
(void)libssh2_exit();
#endif
+#if defined(USE_LIBSSH)
+ (void)ssh_finalize();
+#endif
+
init_flags = 0;
}
@@ -365,28 +314,6 @@ struct Curl_easy *curl_easy_init(void)
return data;
}
-/*
- * curl_easy_setopt() is the external interface for setting options on an
- * easy handle.
- */
-
-#undef curl_easy_setopt
-CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...)
-{
- va_list arg;
- CURLcode result;
-
- if(!data)
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- va_start(arg, tag);
-
- result = Curl_setopt(data, tag, arg);
-
- va_end(arg);
- return result;
-}
-
#ifdef CURLDEBUG
struct socketmonitor {
@@ -433,7 +360,7 @@ static int events_timer(struct Curl_multi *multi, /* multi handle */
*/
static int poll2cselect(int pollmask)
{
- int omask=0;
+ int omask = 0;
if(pollmask & POLLIN)
omask |= CURL_CSELECT_IN;
if(pollmask & POLLOUT)
@@ -450,7 +377,7 @@ static int poll2cselect(int pollmask)
*/
static short socketcb2poll(int pollmask)
{
- short omask=0;
+ short omask = 0;
if(pollmask & CURL_POLL_IN)
omask |= POLLIN;
if(pollmask & CURL_POLL_OUT)
@@ -473,7 +400,7 @@ static int events_socket(struct Curl_easy *easy, /* easy handle */
{
struct events *ev = userp;
struct socketmonitor *m;
- struct socketmonitor *prev=NULL;
+ struct socketmonitor *prev = NULL;
#if defined(CURL_DISABLE_VERBOSE_STRINGS)
(void) easy;
@@ -500,8 +427,8 @@ static int events_socket(struct Curl_easy *easy, /* easy handle */
mask. Convert from libcurl bitmask to the poll one. */
m->socket.events = socketcb2poll(what);
infof(easy, "socket cb: socket %d UPDATED as %s%s\n", s,
- what&CURL_POLL_IN?"IN":"",
- what&CURL_POLL_OUT?"OUT":"");
+ (what&CURL_POLL_IN)?"IN":"",
+ (what&CURL_POLL_OUT)?"OUT":"");
}
break;
}
@@ -524,8 +451,8 @@ static int events_socket(struct Curl_easy *easy, /* easy handle */
m->socket.revents = 0;
ev->list = m;
infof(easy, "socket cb: socket %d ADDED as %s%s\n", s,
- what&CURL_POLL_IN?"IN":"",
- what&CURL_POLL_OUT?"OUT":"");
+ (what&CURL_POLL_IN)?"IN":"",
+ (what&CURL_POLL_OUT)?"OUT":"");
}
else
return CURLE_OUT_OF_MEMORY;
@@ -569,14 +496,14 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
struct socketmonitor *m;
struct pollfd *f;
struct pollfd fds[4];
- int numfds=0;
+ int numfds = 0;
int pollrc;
int i;
- struct timeval before;
- struct timeval after;
+ struct curltime before;
+ struct curltime after;
/* populate the fds[] array */
- for(m = ev->list, f=&fds[0]; m; m = m->next) {
+ for(m = ev->list, f = &fds[0]; m; m = m->next) {
f->fd = m->socket.fd;
f->events = m->socket.events;
f->revents = 0;
@@ -586,12 +513,12 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
}
/* get the time stamp to use to figure out how long poll takes */
- before = curlx_tvnow();
+ before = Curl_now();
/* wait for activity or timeout */
pollrc = Curl_poll(fds, numfds, (int)ev->ms);
- after = curlx_tvnow();
+ after = Curl_now();
ev->msbump = FALSE; /* reset here */
@@ -619,7 +546,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
/* If nothing updated the timeout, we decrease it by the spent time.
* If it was updated, it has the new timeout time stored already.
*/
- time_t timediff = curlx_tvdiff(after, before);
+ timediff_t timediff = Curl_timediff(after, before);
if(timediff > 0) {
if(timediff > ev->ms)
ev->ms = 0;
@@ -632,7 +559,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
return CURLE_RECV_ERROR;
if(mcode)
- return CURLE_URL_MALFORMAT; /* TODO: return a proper error! */
+ return CURLE_URL_MALFORMAT;
/* we don't really care about the "msgs_in_queue" value returned in the
second argument */
@@ -653,7 +580,9 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
*/
static CURLcode easy_events(struct Curl_multi *multi)
{
- struct events evs= {2, FALSE, 0, NULL, 0};
+ /* this struct is made static to allow it to be used after this function
+ returns and curl_multi_remove_handle() is called */
+ static struct events evs = {2, FALSE, 0, NULL, 0};
/* if running event-based, do some further multi inits */
events_setup(multi, &evs);
@@ -670,44 +599,34 @@ static CURLcode easy_transfer(struct Curl_multi *multi)
bool done = FALSE;
CURLMcode mcode = CURLM_OK;
CURLcode result = CURLE_OK;
- struct timeval before;
- int without_fds = 0; /* count number of consecutive returns from
- curl_multi_wait() without any filedescriptors */
while(!done && !mcode) {
int still_running = 0;
- int rc;
+ bool gotsocket = FALSE;
- before = curlx_tvnow();
- mcode = curl_multi_wait(multi, NULL, 0, 1000, &rc);
+ mcode = Curl_multi_wait(multi, NULL, 0, 1000, NULL, &gotsocket);
if(!mcode) {
- if(!rc) {
- struct timeval after = curlx_tvnow();
+ if(!gotsocket) {
+ long sleep_ms;
/* If it returns without any filedescriptor instantly, we need to
avoid busy-looping during periods where it has nothing particular
to wait for */
- if(curlx_tvdiff(after, before) <= 10) {
- without_fds++;
- if(without_fds > 2) {
- int sleep_ms = without_fds < 10 ? (1 << (without_fds - 1)) : 1000;
- Curl_wait_ms(sleep_ms);
- }
+ curl_multi_timeout(multi, &sleep_ms);
+ if(sleep_ms) {
+ if(sleep_ms > 1000)
+ sleep_ms = 1000;
+ Curl_wait_ms((int)sleep_ms);
}
- else
- /* it wasn't "instant", restart counter */
- without_fds = 0;
}
- else
- /* got file descriptor, restart counter */
- without_fds = 0;
mcode = curl_multi_perform(multi, &still_running);
}
/* only read 'still_running' if curl_multi_perform() return OK */
if(!mcode && !still_running) {
+ int rc;
CURLMsg *msg = curl_multi_info_read(multi, &rc);
if(msg) {
result = msg->data.result;
@@ -755,6 +674,10 @@ static CURLcode easy_perform(struct Curl_easy *data, bool events)
if(!data)
return CURLE_BAD_FUNCTION_ARGUMENT;
+ if(data->set.errorbuffer)
+ /* clear this as early as possible */
+ data->set.errorbuffer[0] = 0;
+
if(data->multi) {
failf(data, "easy handle already used in multi handle");
return CURLE_FAILED_INIT;
@@ -771,6 +694,9 @@ static CURLcode easy_perform(struct Curl_easy *data, bool events)
data->multi_easy = multi;
}
+ if(multi->in_callback)
+ return CURLE_RECURSIVE_API_CALL;
+
/* Copy the MAXCONNECTS option to the multi handle */
curl_multi_setopt(multi, CURLMOPT_MAXCONNECTS, data->set.maxconnects);
@@ -859,6 +785,47 @@ CURLcode curl_easy_getinfo(struct Curl_easy *data, CURLINFO info, ...)
return result;
}
+static CURLcode dupset(struct Curl_easy *dst, struct Curl_easy *src)
+{
+ CURLcode result = CURLE_OK;
+ enum dupstring i;
+
+ /* Copy src->set into dst->set first, then deal with the strings
+ afterwards */
+ dst->set = src->set;
+ Curl_mime_initpart(&dst->set.mimepost, dst);
+
+ /* clear all string pointers first */
+ memset(dst->set.str, 0, STRING_LAST * sizeof(char *));
+
+ /* duplicate all strings */
+ for(i = (enum dupstring)0; i< STRING_LASTZEROTERMINATED; i++) {
+ result = Curl_setstropt(&dst->set.str[i], src->set.str[i]);
+ if(result)
+ return result;
+ }
+
+ /* duplicate memory areas pointed to */
+ i = STRING_COPYPOSTFIELDS;
+ if(src->set.postfieldsize && src->set.str[i]) {
+ /* postfieldsize is curl_off_t, Curl_memdup() takes a size_t ... */
+ dst->set.str[i] = Curl_memdup(src->set.str[i],
+ curlx_sotouz(src->set.postfieldsize));
+ if(!dst->set.str[i])
+ return CURLE_OUT_OF_MEMORY;
+ /* point to the new copy */
+ dst->set.postfields = dst->set.str[i];
+ }
+
+ /* Duplicate mime data. */
+ result = Curl_mime_duppart(&dst->set.mimepost, &src->set.mimepost);
+
+ if(src->set.resolve)
+ dst->change.resolve = dst->set.resolve;
+
+ return result;
+}
+
/*
* curl_easy_duphandle() is an external interface to allow duplication of a
* given input easy handle. The returned handle will be a new working handle
@@ -886,7 +853,7 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
outcurl->state.headersize = HEADERSIZE;
/* copy all userdefined values */
- if(Curl_dupset(outcurl, data))
+ if(dupset(outcurl, data))
goto fail;
/* the connection cache is setup on demand */
@@ -930,8 +897,16 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
outcurl->change.referer_alloc = TRUE;
}
+ /* Reinitialize an SSL engine for the new handle
+ * note: the engine name has already been copied by dupset */
+ if(outcurl->set.str[STRING_SSL_ENGINE]) {
+ if(Curl_ssl_set_engine(outcurl, outcurl->set.str[STRING_SSL_ENGINE]))
+ goto fail;
+ }
+
/* Clone the resolver handle, if present, for the new handle */
- if(Curl_resolver_duphandle(&outcurl->state.resolver,
+ if(Curl_resolver_duphandle(outcurl,
+ &outcurl->state.resolver,
data->state.resolver))
goto fail;
@@ -967,16 +942,12 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
*/
void curl_easy_reset(struct Curl_easy *data)
{
- Curl_safefree(data->state.pathbuffer);
-
- data->state.path = NULL;
-
Curl_free_request_state(data);
/* zero out UserDefined data: */
Curl_freeset(data);
memset(&data->set, 0, sizeof(struct UserDefined));
- (void)Curl_init_userdefined(&data->set);
+ (void)Curl_init_userdefined(data);
/* zero out Progress data: */
memset(&data->progress, 0, sizeof(struct Progress));
@@ -990,6 +961,10 @@ void curl_easy_reset(struct Curl_easy *data)
/* zero out authentication data: */
memset(&data->state.authhost, 0, sizeof(struct auth));
memset(&data->state.authproxy, 0, sizeof(struct auth));
+
+#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_CRYPTO_AUTH)
+ Curl_http_auth_cleanup_digest(data);
+#endif
}
/*
@@ -1001,6 +976,9 @@ void curl_easy_reset(struct Curl_easy *data)
* the pausing, you may get your write callback called at this point.
*
* Action is a bitmask consisting of CURLPAUSE_* bits in curl/curl.h
+ *
+ * NOTE: This is one of few API functions that are allowed to be called from
+ * within a callback.
*/
CURLcode curl_easy_pause(struct Curl_easy *data, int action)
{
@@ -1023,24 +1001,35 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action)
unsigned int i;
unsigned int count = data->state.tempcount;
struct tempbuf writebuf[3]; /* there can only be three */
+ struct connectdata *conn = data->conn;
+ struct Curl_easy *saved_data = NULL;
/* copy the structs to allow for immediate re-pausing */
- for(i=0; i < data->state.tempcount; i++) {
+ for(i = 0; i < data->state.tempcount; i++) {
writebuf[i] = data->state.tempwrite[i];
data->state.tempwrite[i].buf = NULL;
}
data->state.tempcount = 0;
- for(i=0; i < count; i++) {
+ /* set the connection's current owner */
+ if(conn->data != data) {
+ saved_data = conn->data;
+ conn->data = data;
+ }
+
+ for(i = 0; i < count; i++) {
/* even if one function returns error, this loops through and frees all
buffers */
if(!result)
- result = Curl_client_chop_write(data->easy_conn,
- writebuf[i].type,
- writebuf[i].buf,
- writebuf[i].len);
+ result = Curl_client_write(conn, writebuf[i].type, writebuf[i].buf,
+ writebuf[i].len);
free(writebuf[i].buf);
}
+
+ /* recover previous owner of the connection */
+ if(saved_data)
+ conn->data = saved_data;
+
if(result)
return result;
}
@@ -1052,6 +1041,10 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int action)
(KEEP_RECV_PAUSE|KEEP_SEND_PAUSE)) )
Curl_expire(data, 0, EXPIRE_RUN_NOW); /* get this handle going again */
+ /* This transfer may have been moved in or out of the bundle, update
+ the corresponding socket callback, if used */
+ Curl_updatesocket(data);
+
return result;
}
@@ -1092,6 +1085,9 @@ CURLcode curl_easy_recv(struct Curl_easy *data, void *buffer, size_t buflen,
ssize_t n1;
struct connectdata *c;
+ if(Curl_is_in_callback(data))
+ return CURLE_RECURSIVE_API_CALL;
+
result = easy_connection(data, &sfd, &c);
if(result)
return result;
@@ -1119,6 +1115,9 @@ CURLcode curl_easy_send(struct Curl_easy *data, const void *buffer,
ssize_t n1;
struct connectdata *c = NULL;
+ if(Curl_is_in_callback(data))
+ return CURLE_RECURSIVE_API_CALL;
+
result = easy_connection(data, &sfd, &c);
if(result)
return result;
@@ -1137,3 +1136,22 @@ CURLcode curl_easy_send(struct Curl_easy *data, const void *buffer,
return result;
}
+
+/*
+ * Performs connection upkeep for the given session handle.
+ */
+CURLcode curl_easy_upkeep(struct Curl_easy *data)
+{
+ /* Verify that we got an easy handle we can work with. */
+ if(!GOOD_EASY_HANDLE(data))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ if(data->multi_easy) {
+ /* Use the common function to keep connections alive. */
+ return Curl_upkeep(&data->multi_easy->conn_cache, data);
+ }
+ else {
+ /* No connections, so just return success */
+ return CURLE_OK;
+ }
+}
diff --git a/Utilities/cmcurl/lib/easyif.h b/Utilities/cmcurl/lib/easyif.h
index f6132cc70..6ba7e549d 100644
--- a/Utilities/cmcurl/lib/easyif.h
+++ b/Utilities/cmcurl/lib/easyif.h
@@ -30,4 +30,3 @@ CURL_EXTERN CURLcode curl_easy_perform_ev(struct Curl_easy *easy);
#endif
#endif /* HEADER_CURL_EASYIF_H */
-
diff --git a/Utilities/cmcurl/lib/escape.c b/Utilities/cmcurl/lib/escape.c
index 973aeb6ea..7121db31c 100644
--- a/Utilities/cmcurl/lib/escape.c
+++ b/Utilities/cmcurl/lib/escape.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -41,7 +41,7 @@
its behavior is altered by the current locale.
See https://tools.ietf.org/html/rfc3986#section-2.3
*/
-static bool Curl_isunreserved(unsigned char in)
+bool Curl_isunreserved(unsigned char in)
{
switch(in) {
case '0': case '1': case '2': case '3': case '4':
@@ -82,16 +82,15 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
size_t alloc;
char *ns;
char *testing_ptr = NULL;
- unsigned char in; /* we need to treat the characters unsigned */
size_t newlen;
- size_t strindex=0;
+ size_t strindex = 0;
size_t length;
CURLcode result;
if(inlength < 0)
return NULL;
- alloc = (inlength?(size_t)inlength:strlen(string))+1;
+ alloc = (inlength?(size_t)inlength:strlen(string)) + 1;
newlen = alloc;
ns = malloc(alloc);
@@ -100,11 +99,11 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
length = alloc-1;
while(length--) {
- in = *string;
+ unsigned char in = *string; /* we need to treat the characters unsigned */
if(Curl_isunreserved(in))
/* just copy this */
- ns[strindex++]=in;
+ ns[strindex++] = in;
else {
/* encode it */
newlen += 2; /* the size grows with two, since this'll become a %XX */
@@ -116,20 +115,20 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
ns = testing_ptr;
}
- result = Curl_convert_to_network(data, &in, 1);
+ result = Curl_convert_to_network(data, (char *)&in, 1);
if(result) {
/* Curl_convert_to_network calls failf if unsuccessful */
free(ns);
return NULL;
}
- snprintf(&ns[strindex], 4, "%%%02X", in);
+ msnprintf(&ns[strindex], 4, "%%%02X", in);
- strindex+=3;
+ strindex += 3;
}
string++;
}
- ns[strindex]=0; /* terminate it */
+ ns[strindex] = 0; /* terminate it */
return ns;
}
@@ -142,24 +141,25 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string,
* Returns a pointer to a malloced string in *ostring with length given in
* *olen. If length == 0, the length is assumed to be strlen(string).
*
+ * 'data' can be set to NULL but then this function can't convert network
+ * data to host for non-ascii.
*/
CURLcode Curl_urldecode(struct Curl_easy *data,
const char *string, size_t length,
char **ostring, size_t *olen,
bool reject_ctrl)
{
- size_t alloc = (length?length:strlen(string))+1;
+ size_t alloc = (length?length:strlen(string)) + 1;
char *ns = malloc(alloc);
- unsigned char in;
- size_t strindex=0;
+ size_t strindex = 0;
unsigned long hex;
- CURLcode result;
+ CURLcode result = CURLE_OK;
if(!ns)
return CURLE_OUT_OF_MEMORY;
while(--alloc > 0) {
- in = *string;
+ unsigned char in = *string;
if(('%' == in) && (alloc > 2) &&
ISXDIGIT(string[1]) && ISXDIGIT(string[2])) {
/* this is two hexadecimal digits following a '%' */
@@ -173,15 +173,17 @@ CURLcode Curl_urldecode(struct Curl_easy *data,
in = curlx_ultouc(hex); /* this long is never bigger than 255 anyway */
- result = Curl_convert_from_network(data, &in, 1);
- if(result) {
- /* Curl_convert_from_network calls failf if unsuccessful */
- free(ns);
- return result;
+ if(data) {
+ result = Curl_convert_from_network(data, (char *)&in, 1);
+ if(result) {
+ /* Curl_convert_from_network calls failf if unsuccessful */
+ free(ns);
+ return result;
+ }
}
- string+=2;
- alloc-=2;
+ string += 2;
+ alloc -= 2;
}
if(reject_ctrl && (in < 0x20)) {
@@ -192,7 +194,7 @@ CURLcode Curl_urldecode(struct Curl_easy *data,
ns[strindex++] = in;
string++;
}
- ns[strindex]=0; /* terminate it */
+ ns[strindex] = 0; /* terminate it */
if(olen)
/* store output size */
diff --git a/Utilities/cmcurl/lib/escape.h b/Utilities/cmcurl/lib/escape.h
index 638666f03..d8bbe5cb0 100644
--- a/Utilities/cmcurl/lib/escape.h
+++ b/Utilities/cmcurl/lib/escape.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -24,10 +24,10 @@
/* Escape and unescape URL encoding in strings. The functions return a new
* allocated string or NULL if an error occurred. */
+bool Curl_isunreserved(unsigned char in);
CURLcode Curl_urldecode(struct Curl_easy *data,
const char *string, size_t length,
char **ostring, size_t *olen,
bool reject_crlf);
#endif /* HEADER_CURL_ESCAPE_H */
-
diff --git a/Utilities/cmcurl/lib/file.c b/Utilities/cmcurl/lib/file.c
index c804d75e1..d349cd924 100644
--- a/Utilities/cmcurl/lib/file.c
+++ b/Utilities/cmcurl/lib/file.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -61,6 +61,7 @@
#include "url.h"
#include "parsedate.h" /* for the week day and month names */
#include "warnless.h"
+#include "curl_range.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
@@ -108,6 +109,7 @@ const struct Curl_handler Curl_handler_file = {
ZERO_NULL, /* perform_getsock */
file_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
0, /* defport */
CURLPROTO_FILE, /* protocol */
PROTOPT_NONETWORK | PROTOPT_NOURLQUERY /* flags */
@@ -124,60 +126,6 @@ static CURLcode file_setup_connection(struct connectdata *conn)
return CURLE_OK;
}
- /*
- Check if this is a range download, and if so, set the internal variables
- properly. This code is copied from the FTP implementation and might as
- well be factored out.
- */
-static CURLcode file_range(struct connectdata *conn)
-{
- curl_off_t from, to;
- curl_off_t totalsize=-1;
- char *ptr;
- char *ptr2;
- struct Curl_easy *data = conn->data;
-
- if(data->state.use_range && data->state.range) {
- from=curlx_strtoofft(data->state.range, &ptr, 0);
- while(*ptr && (ISSPACE(*ptr) || (*ptr=='-')))
- ptr++;
- to=curlx_strtoofft(ptr, &ptr2, 0);
- if(ptr == ptr2) {
- /* we didn't get any digit */
- to=-1;
- }
- if((-1 == to) && (from>=0)) {
- /* X - */
- data->state.resume_from = from;
- DEBUGF(infof(data, "RANGE %" CURL_FORMAT_CURL_OFF_T " to end of file\n",
- from));
- }
- else if(from < 0) {
- /* -Y */
- data->req.maxdownload = -from;
- data->state.resume_from = from;
- DEBUGF(infof(data, "RANGE the last %" CURL_FORMAT_CURL_OFF_T " bytes\n",
- -from));
- }
- else {
- /* X-Y */
- totalsize = to-from;
- data->req.maxdownload = totalsize+1; /* include last byte */
- data->state.resume_from = from;
- DEBUGF(infof(data, "RANGE from %" CURL_FORMAT_CURL_OFF_T
- " getting %" CURL_FORMAT_CURL_OFF_T " bytes\n",
- from, data->req.maxdownload));
- }
- DEBUGF(infof(data, "range-download from %" CURL_FORMAT_CURL_OFF_T
- " to %" CURL_FORMAT_CURL_OFF_T ", totally %"
- CURL_FORMAT_CURL_OFF_T " bytes\n",
- from, to, data->req.maxdownload));
- }
- else
- data->req.maxdownload = -1;
- return CURLE_OK;
-}
-
/*
* file_connect() gets called from Curl_protocol_connect() to allow us to
* do protocol-specific actions at connect-time. We emulate a
@@ -195,7 +143,7 @@ static CURLcode file_connect(struct connectdata *conn, bool *done)
#endif
size_t real_path_len;
- CURLcode result = Curl_urldecode(data, data->state.path, 0, &real_path,
+ CURLcode result = Curl_urldecode(data, data->state.up.path, 0, &real_path,
&real_path_len, FALSE);
if(result)
return result;
@@ -225,7 +173,7 @@ static CURLcode file_connect(struct connectdata *conn, bool *done)
}
/* change path separators from '/' to '\\' for DOS, Windows and OS/2 */
- for(i=0; i < real_path_len; ++i)
+ for(i = 0; i < real_path_len; ++i)
if(actual_path[i] == '/')
actual_path[i] = '\\';
else if(!actual_path[i]) { /* binary zero */
@@ -249,7 +197,7 @@ static CURLcode file_connect(struct connectdata *conn, bool *done)
file->fd = fd;
if(!data->set.upload && (fd == -1)) {
- failf(data, "Couldn't open file %s", data->state.path);
+ failf(data, "Couldn't open file %s", data->state.up.path);
file_done(conn, CURLE_FILE_COULDNT_READ_FILE, FALSE);
return CURLE_FILE_COULDNT_READ_FILE;
}
@@ -308,8 +256,6 @@ static CURLcode file_upload(struct connectdata *conn)
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
char *buf = data->state.buffer;
- size_t nread;
- size_t nwrite;
curl_off_t bytecount = 0;
struct_stat file_stat;
const char *buf2;
@@ -358,15 +304,17 @@ static CURLcode file_upload(struct connectdata *conn)
}
while(!result) {
- int readcount;
- result = Curl_fillreadbuffer(conn, (int)data->set.buffer_size, &readcount);
+ size_t nread;
+ size_t nwrite;
+ size_t readcount;
+ result = Curl_fillreadbuffer(conn, data->set.buffer_size, &readcount);
if(result)
break;
- if(readcount <= 0) /* fix questionable compare error. curlvms */
+ if(!readcount)
break;
- nread = (size_t)readcount;
+ nread = readcount;
/*skip bytes before resume point*/
if(data->state.resume_from) {
@@ -398,7 +346,7 @@ static CURLcode file_upload(struct connectdata *conn)
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
else
- result = Curl_speedcheck(data, Curl_tvnow());
+ result = Curl_speedcheck(data, Curl_now());
}
if(!result && Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
@@ -427,10 +375,9 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
struct_stat statbuf; /* struct_stat instead of struct stat just to allow the
Windows version to have a different struct without
having to redefine the simple word 'stat' */
- curl_off_t expected_size=0;
+ curl_off_t expected_size = 0;
bool size_known;
- bool fstated=FALSE;
- ssize_t nread;
+ bool fstated = FALSE;
struct Curl_easy *data = conn->data;
char *buf = data->state.buffer;
curl_off_t bytecount = 0;
@@ -439,7 +386,6 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
*done = TRUE; /* unconditionally */
- Curl_initinfo(data);
Curl_pgrsStartNow(data);
if(data->set.upload)
@@ -455,32 +401,30 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
/* we could stat it, then read out the size */
expected_size = statbuf.st_size;
/* and store the modification time */
- data->info.filetime = (long)statbuf.st_mtime;
+ data->info.filetime = statbuf.st_mtime;
fstated = TRUE;
}
if(fstated && !data->state.range && data->set.timecondition) {
- if(!Curl_meets_timecondition(data, (time_t)data->info.filetime)) {
+ if(!Curl_meets_timecondition(data, data->info.filetime)) {
*done = TRUE;
return CURLE_OK;
}
}
- /* If we have selected NOBODY and HEADER, it means that we only want file
- information. Which for FILE can't be much more than the file size and
- date. */
- if(data->set.opt_no_body && data->set.include_header && fstated) {
+ if(fstated) {
time_t filetime;
struct tm buffer;
const struct tm *tm = &buffer;
char header[80];
- snprintf(header, sizeof(header),
- "Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", expected_size);
- result = Curl_client_write(conn, CLIENTWRITE_BOTH, header, 0);
+ msnprintf(header, sizeof(header),
+ "Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n",
+ expected_size);
+ result = Curl_client_write(conn, CLIENTWRITE_HEADER, header, 0);
if(result)
return result;
- result = Curl_client_write(conn, CLIENTWRITE_BOTH,
+ result = Curl_client_write(conn, CLIENTWRITE_HEADER,
(char *)"Accept-ranges: bytes\r\n", 0);
if(result)
return result;
@@ -491,27 +435,32 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
return result;
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
- snprintf(header, sizeof(header),
- "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
- Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
- tm->tm_mday,
- Curl_month[tm->tm_mon],
- tm->tm_year + 1900,
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec);
- result = Curl_client_write(conn, CLIENTWRITE_BOTH, buf, 0);
- if(!result)
- /* set the file size to make it available post transfer */
- Curl_pgrsSetDownloadSize(data, expected_size);
- return result;
+ msnprintf(header, sizeof(header),
+ "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n%s",
+ Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
+ tm->tm_mday,
+ Curl_month[tm->tm_mon],
+ tm->tm_year + 1900,
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec,
+ data->set.opt_no_body ? "": "\r\n");
+ result = Curl_client_write(conn, CLIENTWRITE_HEADER, header, 0);
+ if(result)
+ return result;
+ /* set the file size to make it available post transfer */
+ Curl_pgrsSetDownloadSize(data, expected_size);
+ if(data->set.opt_no_body)
+ return result;
}
/* Check whether file range has been specified */
- file_range(conn);
+ result = Curl_range(conn);
+ if(result)
+ return result;
/* Adjust the start offset in case we want to get the N last bytes
- * of the stream iff the filesize could be determined */
+ * of the stream if the filesize could be determined */
if(data->state.resume_from < 0) {
if(!fstated) {
failf(data, "Can't get the size of file.");
@@ -552,6 +501,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
while(!result) {
+ ssize_t nread;
/* Don't fill a whole buffer if we want less than all data */
size_t bytestoread;
@@ -583,7 +533,7 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
else
- result = Curl_speedcheck(data, Curl_tvnow());
+ result = Curl_speedcheck(data, Curl_now());
}
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
diff --git a/Utilities/cmcurl/lib/file.h b/Utilities/cmcurl/lib/file.h
index c12ae0e09..20828ad4a 100644
--- a/Utilities/cmcurl/lib/file.h
+++ b/Utilities/cmcurl/lib/file.h
@@ -38,4 +38,3 @@ extern const struct Curl_handler Curl_handler_file;
#endif
#endif /* HEADER_CURL_FILE_H */
-
diff --git a/Utilities/cmcurl/lib/fileinfo.c b/Utilities/cmcurl/lib/fileinfo.c
index 387298847..2630c9e46 100644
--- a/Utilities/cmcurl/lib/fileinfo.c
+++ b/Utilities/cmcurl/lib/fileinfo.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2010 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2010 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -21,7 +21,7 @@
***************************************************************************/
#include "curl_setup.h"
-
+#ifndef CURL_DISABLE_FTP
#include "strdup.h"
#include "fileinfo.h"
#include "curl_memory.h"
@@ -33,14 +33,12 @@ struct fileinfo *Curl_fileinfo_alloc(void)
return calloc(1, sizeof(struct fileinfo));
}
-void Curl_fileinfo_dtor(void *user, void *element)
+void Curl_fileinfo_cleanup(struct fileinfo *finfo)
{
- struct fileinfo *finfo = element;
- (void) user;
if(!finfo)
return;
Curl_safefree(finfo->info.b_data);
-
free(finfo);
}
+#endif
diff --git a/Utilities/cmcurl/lib/fileinfo.h b/Utilities/cmcurl/lib/fileinfo.h
index c5d0ee5b6..f4d8f3b90 100644
--- a/Utilities/cmcurl/lib/fileinfo.h
+++ b/Utilities/cmcurl/lib/fileinfo.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2010, 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2010 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -31,7 +31,6 @@ struct fileinfo {
};
struct fileinfo *Curl_fileinfo_alloc(void);
-
-void Curl_fileinfo_dtor(void *, void *);
+void Curl_fileinfo_cleanup(struct fileinfo *finfo);
#endif /* HEADER_CURL_FILEINFO_H */
diff --git a/Utilities/cmcurl/lib/formdata.c b/Utilities/cmcurl/lib/formdata.c
index e48a6276c..429d479da 100644
--- a/Utilities/cmcurl/lib/formdata.c
+++ b/Utilities/cmcurl/lib/formdata.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -24,35 +24,27 @@
#include <curl/curl.h>
-#ifndef CURL_DISABLE_HTTP
+#include "formdata.h"
+#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_MIME)
#if defined(HAVE_LIBGEN_H) && defined(HAVE_BASENAME)
#include <libgen.h>
#endif
#include "urldata.h" /* for struct Curl_easy */
-#include "formdata.h"
+#include "mime.h"
+#include "non-ascii.h"
#include "vtls/vtls.h"
#include "strcase.h"
#include "sendf.h"
#include "strdup.h"
#include "rand.h"
+#include "warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"
-#ifndef HAVE_BASENAME
-static char *Curl_basename(char *path);
-#define basename(x) Curl_basename((x))
-#endif
-
-static size_t readfromfile(struct Form *form, char *buffer, size_t size);
-static CURLcode formboundary(struct Curl_easy *data, char *buffer, size_t len);
-
-/* What kind of Content-Type to use on un-specified files with unrecognized
- extensions. */
-#define HTTPPOST_CONTENTTYPE_DEFAULT "application/octet-stream"
#define HTTPPOST_PTRNAME CURL_HTTPPOST_PTRNAME
#define HTTPPOST_FILENAME CURL_HTTPPOST_FILENAME
@@ -160,60 +152,6 @@ static FormInfo * AddFormInfo(char *value,
/***************************************************************************
*
- * ContentTypeForFilename()
- *
- * Provides content type for filename if one of the known types (else
- * (either the prevtype or the default is returned).
- *
- * Returns some valid contenttype for filename.
- *
- ***************************************************************************/
-static const char *ContentTypeForFilename(const char *filename,
- const char *prevtype)
-{
- const char *contenttype = NULL;
- unsigned int i;
- /*
- * No type was specified, we scan through a few well-known
- * extensions and pick the first we match!
- */
- struct ContentType {
- const char *extension;
- const char *type;
- };
- static const struct ContentType ctts[]={
- {".gif", "image/gif"},
- {".jpg", "image/jpeg"},
- {".jpeg", "image/jpeg"},
- {".txt", "text/plain"},
- {".html", "text/html"},
- {".xml", "application/xml"}
- };
-
- if(prevtype)
- /* default to the previously set/used! */
- contenttype = prevtype;
- else
- contenttype = HTTPPOST_CONTENTTYPE_DEFAULT;
-
- if(filename) { /* in case a NULL was passed in */
- for(i=0; i<sizeof(ctts)/sizeof(ctts[0]); i++) {
- if(strlen(filename) >= strlen(ctts[i].extension)) {
- if(strcasecompare(filename +
- strlen(filename) - strlen(ctts[i].extension),
- ctts[i].extension)) {
- contenttype = ctts[i].type;
- break;
- }
- }
- }
- }
- /* we have a contenttype by now */
- return contenttype;
-}
-
-/***************************************************************************
- *
* FormAdd()
*
* Stores a formpost parameter and builds the appropriate linked list.
@@ -272,7 +210,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
struct curl_httppost *post = NULL;
CURLformoption option;
struct curl_forms *forms = NULL;
- char *array_value=NULL; /* value read from an array */
+ char *array_value = NULL; /* value read from an array */
/* This is a state variable, that if TRUE means that we're parsing an
array that we got passed to us. If FALSE we're parsing the input
@@ -364,7 +302,8 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
* Set the contents property.
*/
case CURLFORM_PTRCONTENTS:
- current_form->flags |= HTTPPOST_PTRCONTENTS; /* fall through */
+ current_form->flags |= HTTPPOST_PTRCONTENTS;
+ /* FALLTHROUGH */
case CURLFORM_COPYCONTENTS:
if(current_form->value)
return_value = CURL_FORMADD_OPTION_TWICE;
@@ -630,26 +569,43 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
if(((form->flags & HTTPPOST_FILENAME) ||
(form->flags & HTTPPOST_BUFFER)) &&
!form->contenttype) {
- char *f = form->flags & HTTPPOST_BUFFER?
+ char *f = (form->flags & HTTPPOST_BUFFER)?
form->showfilename : form->value;
+ char const *type;
+ type = Curl_mime_contenttype(f);
+ if(!type)
+ type = prevtype;
+ if(!type)
+ type = FILE_CONTENTTYPE_DEFAULT;
/* our contenttype is missing */
- form->contenttype = strdup(ContentTypeForFilename(f, prevtype));
+ form->contenttype = strdup(type);
if(!form->contenttype) {
return_value = CURL_FORMADD_MEMORY;
break;
}
form->contenttype_alloc = TRUE;
}
+ if(form->name && form->namelength) {
+ /* Name should not contain nul bytes. */
+ size_t i;
+ for(i = 0; i < form->namelength; i++)
+ if(!form->name[i]) {
+ return_value = CURL_FORMADD_NULL;
+ break;
+ }
+ if(return_value != CURL_FORMADD_OK)
+ break;
+ }
if(!(form->flags & HTTPPOST_PTRNAME) &&
(form == first_form) ) {
/* Note that there's small risk that form->name is NULL here if the
app passed in a bad combo, so we better check for that first. */
if(form->name) {
- /* copy name (without strdup; possibly contains null characters) */
+ /* copy name (without strdup; possibly not nul-terminated) */
form->name = Curl_memdup(form->name, form->namelength?
form->namelength:
- strlen(form->name)+1);
+ strlen(form->name) + 1);
}
if(!form->name) {
return_value = CURL_FORMADD_MEMORY;
@@ -663,7 +619,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
/* copy value (without strdup; possibly contains null characters) */
size_t clen = (size_t) form->contentslength;
if(!clen)
- clen = strlen(form->value)+1;
+ clen = strlen(form->value) + 1;
form->value = Curl_memdup(form->value, clen);
@@ -746,211 +702,6 @@ CURLFORMcode curl_formadd(struct curl_httppost **httppost,
return result;
}
-#ifdef __VMS
-#include <fabdef.h>
-/*
- * get_vms_file_size does what it takes to get the real size of the file
- *
- * For fixed files, find out the size of the EOF block and adjust.
- *
- * For all others, have to read the entire file in, discarding the contents.
- * Most posted text files will be small, and binary files like zlib archives
- * and CD/DVD images should be either a STREAM_LF format or a fixed format.
- *
- */
-curl_off_t VmsRealFileSize(const char *name,
- const struct_stat *stat_buf)
-{
- char buffer[8192];
- curl_off_t count;
- int ret_stat;
- FILE * file;
-
- file = fopen(name, FOPEN_READTEXT); /* VMS */
- if(file == NULL)
- return 0;
-
- count = 0;
- ret_stat = 1;
- while(ret_stat > 0) {
- ret_stat = fread(buffer, 1, sizeof(buffer), file);
- if(ret_stat != 0)
- count += ret_stat;
- }
- fclose(file);
-
- return count;
-}
-
-/*
- *
- * VmsSpecialSize checks to see if the stat st_size can be trusted and
- * if not to call a routine to get the correct size.
- *
- */
-static curl_off_t VmsSpecialSize(const char *name,
- const struct_stat *stat_buf)
-{
- switch(stat_buf->st_fab_rfm) {
- case FAB$C_VAR:
- case FAB$C_VFC:
- return VmsRealFileSize(name, stat_buf);
- break;
- default:
- return stat_buf->st_size;
- }
-}
-
-#endif
-
-#ifndef __VMS
-#define filesize(name, stat_data) (stat_data.st_size)
-#else
- /* Getting the expected file size needs help on VMS */
-#define filesize(name, stat_data) VmsSpecialSize(name, &stat_data)
-#endif
-
-/*
- * AddFormData() adds a chunk of data to the FormData linked list.
- *
- * size is incremented by the chunk length, unless it is NULL
- */
-static CURLcode AddFormData(struct FormData **formp,
- enum formtype type,
- const void *line,
- curl_off_t length,
- curl_off_t *size)
-{
- struct FormData *newform;
- char *alloc2 = NULL;
- CURLcode result = CURLE_OK;
- if(length < 0 || (size && *size < 0))
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- newform = malloc(sizeof(struct FormData));
- if(!newform)
- return CURLE_OUT_OF_MEMORY;
- newform->next = NULL;
-
- if(type <= FORM_CONTENT) {
- /* we make it easier for plain strings: */
- if(!length)
- length = strlen((char *)line);
-#if (SIZEOF_SIZE_T < CURL_SIZEOF_CURL_OFF_T)
- else if(length >= (curl_off_t)(size_t)-1) {
- result = CURLE_BAD_FUNCTION_ARGUMENT;
- goto error;
- }
-#endif
- if(type != FORM_DATAMEM) {
- newform->line = malloc((size_t)length+1);
- if(!newform->line) {
- result = CURLE_OUT_OF_MEMORY;
- goto error;
- }
- alloc2 = newform->line;
- memcpy(newform->line, line, (size_t)length);
-
- /* zero terminate for easier debugging */
- newform->line[(size_t)length]=0;
- }
- else {
- newform->line = (char *)line;
- type = FORM_DATA; /* in all other aspects this is just FORM_DATA */
- }
- newform->length = (size_t)length;
- }
- else
- /* For callbacks and files we don't have any actual data so we just keep a
- pointer to whatever this points to */
- newform->line = (char *)line;
-
- newform->type = type;
-
- if(size) {
- if(type != FORM_FILE)
- /* for static content as well as callback data we add the size given
- as input argument */
- *size += length;
- else {
- /* Since this is a file to be uploaded here, add the size of the actual
- file */
- if(strcmp("-", newform->line)) {
- struct_stat file;
- if(!stat(newform->line, &file) && !S_ISDIR(file.st_mode))
- *size += filesize(newform->line, file);
- else {
- result = CURLE_BAD_FUNCTION_ARGUMENT;
- goto error;
- }
- }
- }
- }
-
- if(*formp) {
- (*formp)->next = newform;
- *formp = newform;
- }
- else
- *formp = newform;
-
- return CURLE_OK;
- error:
- if(newform)
- free(newform);
- if(alloc2)
- free(alloc2);
- return result;
-}
-
-/*
- * AddFormDataf() adds printf()-style formatted data to the formdata chain.
- */
-
-static CURLcode AddFormDataf(struct FormData **formp,
- curl_off_t *size,
- const char *fmt, ...)
-{
- char *s;
- CURLcode result;
- va_list ap;
- va_start(ap, fmt);
- s = curl_mvaprintf(fmt, ap);
- va_end(ap);
-
- if(!s)
- return CURLE_OUT_OF_MEMORY;
-
- result = AddFormData(formp, FORM_DATAMEM, s, 0, size);
- if(result)
- free(s);
-
- return result;
-}
-
-/*
- * Curl_formclean() is used from http.c, this cleans a built FormData linked
- * list
- */
-void Curl_formclean(struct FormData **form_ptr)
-{
- struct FormData *next, *form;
-
- form = *form_ptr;
- if(!form)
- return;
-
- do {
- next=form->next; /* the following form line */
- if(form->type <= FORM_CONTENT)
- free(form->line); /* free the line */
- free(form); /* free the struct */
- form = next;
- } while(form); /* continue */
-
- *form_ptr = NULL;
-}
-
/*
* curl_formget()
* Serialize a curl_httppost struct.
@@ -962,42 +713,34 @@ int curl_formget(struct curl_httppost *form, void *arg,
curl_formget_callback append)
{
CURLcode result;
- curl_off_t size;
- struct FormData *data, *ptr;
+ curl_mimepart toppart;
- result = Curl_getformdata(NULL, &data, form, NULL, &size);
- if(result)
- return (int)result;
-
- for(ptr = data; ptr; ptr = ptr->next) {
- if((ptr->type == FORM_FILE) || (ptr->type == FORM_CALLBACK)) {
- char buffer[8192];
- size_t nread;
- struct Form temp;
-
- Curl_FormInit(&temp, ptr);
-
- do {
- nread = readfromfile(&temp, buffer, sizeof(buffer));
- if((nread == (size_t) -1) ||
- (nread > sizeof(buffer)) ||
- (nread != append(arg, buffer, nread))) {
- if(temp.fp)
- fclose(temp.fp);
- Curl_formclean(&data);
- return -1;
- }
- } while(nread);
- }
- else {
- if(ptr->length != append(arg, ptr->line, ptr->length)) {
- Curl_formclean(&data);
- return -1;
- }
+ Curl_mime_initpart(&toppart, NULL); /* default form is empty */
+ result = Curl_getformdata(NULL, &toppart, form, NULL);
+ if(!result)
+ result = Curl_mime_prepare_headers(&toppart, "multipart/form-data",
+ NULL, MIMESTRATEGY_FORM);
+
+ while(!result) {
+ char buffer[8192];
+ size_t nread = Curl_mime_read(buffer, 1, sizeof(buffer), &toppart);
+
+ if(!nread)
+ break;
+
+ switch(nread) {
+ default:
+ if(append(arg, buffer, nread) != nread)
+ result = CURLE_READ_ERROR;
+ break;
+ case CURL_READFUNC_ABORT:
+ case CURL_READFUNC_PAUSE:
+ break;
}
}
- Curl_formclean(&data);
- return 0;
+
+ Curl_mime_cleanpart(&toppart);
+ return (int) result;
}
/*
@@ -1013,7 +756,7 @@ void curl_formfree(struct curl_httppost *form)
return;
do {
- next=form->next; /* the following form line */
+ next = form->next; /* the following form line */
/* recurse to sub-contents */
curl_formfree(form->more);
@@ -1031,118 +774,29 @@ void curl_formfree(struct curl_httppost *form)
} while(form); /* continue */
}
-#ifndef HAVE_BASENAME
-/*
- (Quote from The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004
- Edition)
-
- The basename() function shall take the pathname pointed to by path and
- return a pointer to the final component of the pathname, deleting any
- trailing '/' characters.
-
- If the string pointed to by path consists entirely of the '/' character,
- basename() shall return a pointer to the string "/". If the string pointed
- to by path is exactly "//", it is implementation-defined whether '/' or "//"
- is returned.
-
- If path is a null pointer or points to an empty string, basename() shall
- return a pointer to the string ".".
-
- The basename() function may modify the string pointed to by path, and may
- return a pointer to static storage that may then be overwritten by a
- subsequent call to basename().
-
- The basename() function need not be reentrant. A function that is not
- required to be reentrant is not required to be thread-safe.
-
-*/
-static char *Curl_basename(char *path)
-{
- /* Ignore all the details above for now and make a quick and simple
- implementaion here */
- char *s1;
- char *s2;
-
- s1=strrchr(path, '/');
- s2=strrchr(path, '\\');
-
- if(s1 && s2) {
- path = (s1 > s2? s1 : s2)+1;
- }
- else if(s1)
- path = s1 + 1;
- else if(s2)
- path = s2 + 1;
-
- return path;
-}
-#endif
-
-static char *strippath(const char *fullfile)
-{
- char *filename;
- char *base;
- filename = strdup(fullfile); /* duplicate since basename() may ruin the
- buffer it works on */
- if(!filename)
- return NULL;
- base = strdup(basename(filename));
-
- free(filename); /* free temporary buffer */
-
- return base; /* returns an allocated string or NULL ! */
-}
-static CURLcode formdata_add_filename(const struct curl_httppost *file,
- struct FormData **form,
- curl_off_t *size)
+/* Set mime part name, taking care of non nul-terminated name string. */
+static CURLcode setname(curl_mimepart *part, const char *name, size_t len)
{
- CURLcode result = CURLE_OK;
- char *filename = file->showfilename;
- char *filebasename = NULL;
- char *filename_escaped = NULL;
-
- if(!filename) {
- filebasename = strippath(file->contents);
- if(!filebasename)
- return CURLE_OUT_OF_MEMORY;
- filename = filebasename;
- }
+ char *zname;
+ CURLcode res;
- if(strchr(filename, '\\') || strchr(filename, '"')) {
- char *p0, *p1;
-
- /* filename need be escaped */
- filename_escaped = malloc(strlen(filename)*2+1);
- if(!filename_escaped) {
- free(filebasename);
- return CURLE_OUT_OF_MEMORY;
- }
- p0 = filename_escaped;
- p1 = filename;
- while(*p1) {
- if(*p1 == '\\' || *p1 == '"')
- *p0++ = '\\';
- *p0++ = *p1++;
- }
- *p0 = '\0';
- filename = filename_escaped;
- }
- result = AddFormDataf(form, size,
- "; filename=\"%s\"",
- filename);
- free(filename_escaped);
- free(filebasename);
- return result;
+ if(!name || !len)
+ return curl_mime_name(part, name);
+ zname = malloc(len + 1);
+ if(!zname)
+ return CURLE_OUT_OF_MEMORY;
+ memcpy(zname, name, len);
+ zname[len] = '\0';
+ res = curl_mime_name(part, zname);
+ free(zname);
+ return res;
}
/*
- * Curl_getformdata() converts a linked list of "meta data" into a complete
- * (possibly huge) multipart formdata. The input list is in 'post', while the
- * output resulting linked lists gets stored in '*finalform'. *sizep will get
- * the total size of the whole POST.
- * A multipart/form_data content-type is built, unless a custom content-type
- * is passed in 'custom_content_type'.
+ * Curl_getformdata() converts a linked list of "meta data" into a mime
+ * structure. The input list is in 'post', while the output is stored in
+ * mime part at '*finalform'.
*
* This function will not do a failf() for the potential memory failures but
* should for all other errors it spots. Just note that this function MAY get
@@ -1150,423 +804,125 @@ static CURLcode formdata_add_filename(const struct curl_httppost *file,
*/
CURLcode Curl_getformdata(struct Curl_easy *data,
- struct FormData **finalform,
+ curl_mimepart *finalform,
struct curl_httppost *post,
- const char *custom_content_type,
- curl_off_t *sizep)
+ curl_read_callback fread_func)
{
- struct FormData *form = NULL;
- struct FormData *firstform;
- struct curl_httppost *file;
CURLcode result = CURLE_OK;
- curl_off_t size = 0; /* support potentially ENORMOUS formposts */
- char fileboundary[42];
- struct curl_slist *curList;
- char boundary[42];
+ curl_mime *form = NULL;
+ curl_mimepart *part;
+ struct curl_httppost *file;
- *finalform = NULL; /* default form is empty */
+ Curl_mime_cleanpart(finalform); /* default form is empty */
if(!post)
return result; /* no input => no output! */
- result = formboundary(data, boundary, sizeof(boundary));
- if(result)
- return result;
-
- /* Make the first line of the output */
- result = AddFormDataf(&form, NULL,
- "%s; boundary=%s\r\n",
- custom_content_type?custom_content_type:
- "Content-Type: multipart/form-data",
- boundary);
-
- if(result) {
- return result;
- }
- /* we DO NOT include that line in the total size of the POST, since it'll be
- part of the header! */
-
- firstform = form;
-
- do {
-
- if(size) {
- result = AddFormDataf(&form, &size, "\r\n");
- if(result)
- break;
- }
-
- /* boundary */
- result = AddFormDataf(&form, &size, "--%s\r\n", boundary);
- if(result)
- break;
-
- /* Maybe later this should be disabled when a custom_content_type is
- passed, since Content-Disposition is not meaningful for all multipart
- types.
- */
- result = AddFormDataf(&form, &size,
- "Content-Disposition: form-data; name=\"");
- if(result)
- break;
-
- result = AddFormData(&form, FORM_DATA, post->name, post->namelength,
- &size);
- if(result)
- break;
+ form = curl_mime_init(data);
+ if(!form)
+ result = CURLE_OUT_OF_MEMORY;
- result = AddFormDataf(&form, &size, "\"");
- if(result)
- break;
+ if(!result)
+ result = curl_mime_subparts(finalform, form);
+ /* Process each top part. */
+ for(; !result && post; post = post->next) {
+ /* If we have more than a file here, create a mime subpart and fill it. */
+ curl_mime *multipart = form;
if(post->more) {
- /* If used, this is a link to more file names, we must then do
- the magic to include several files with the same field name */
-
- result = formboundary(data, fileboundary, sizeof(fileboundary));
- if(result) {
- break;
+ part = curl_mime_addpart(form);
+ if(!part)
+ result = CURLE_OUT_OF_MEMORY;
+ if(!result)
+ result = setname(part, post->name, post->namelength);
+ if(!result) {
+ multipart = curl_mime_init(data);
+ if(!multipart)
+ result = CURLE_OUT_OF_MEMORY;
}
-
- result = AddFormDataf(&form, &size,
- "\r\nContent-Type: multipart/mixed;"
- " boundary=%s\r\n",
- fileboundary);
- if(result)
- break;
+ if(!result)
+ result = curl_mime_subparts(part, multipart);
}
- file = post;
-
- do {
-
- /* If 'showfilename' is set, that is a faked name passed on to us
- to use to in the formpost. If that is not set, the actually used
- local file name should be added. */
-
- if(post->more) {
- /* if multiple-file */
- result = AddFormDataf(&form, &size,
- "\r\n--%s\r\nContent-Disposition: "
- "attachment",
- fileboundary);
- if(result)
- break;
- result = formdata_add_filename(file, &form, &size);
- if(result)
- break;
- }
- else if(post->flags & (HTTPPOST_FILENAME|HTTPPOST_BUFFER|
- HTTPPOST_CALLBACK)) {
- /* it should be noted that for the HTTPPOST_FILENAME and
- HTTPPOST_CALLBACK cases the ->showfilename struct member is always
- assigned at this point */
- if(post->showfilename || (post->flags & HTTPPOST_FILENAME)) {
- result = formdata_add_filename(post, &form, &size);
- }
+ /* Generate all the part contents. */
+ for(file = post; !result && file; file = file->more) {
+ /* Create the part. */
+ part = curl_mime_addpart(multipart);
+ if(!part)
+ result = CURLE_OUT_OF_MEMORY;
- if(result)
- break;
- }
+ /* Set the headers. */
+ if(!result)
+ result = curl_mime_headers(part, file->contentheader, 0);
- if(file->contenttype) {
- /* we have a specified type */
- result = AddFormDataf(&form, &size,
- "\r\nContent-Type: %s",
- file->contenttype);
- if(result)
- break;
- }
+ /* Set the content type. */
+ if(!result && file->contenttype)
+ result = curl_mime_type(part, file->contenttype);
- curList = file->contentheader;
- while(curList) {
- /* Process the additional headers specified for this form */
- result = AddFormDataf(&form, &size, "\r\n%s", curList->data);
- if(result)
- break;
- curList = curList->next;
- }
- if(result)
- break;
+ /* Set field name. */
+ if(!result && !post->more)
+ result = setname(part, post->name, post->namelength);
- result = AddFormDataf(&form, &size, "\r\n\r\n");
- if(result)
- break;
+ /* Process contents. */
+ if(!result) {
+ curl_off_t clen = post->contentslength;
- if((post->flags & HTTPPOST_FILENAME) ||
- (post->flags & HTTPPOST_READFILE)) {
- /* we should include the contents from the specified file */
- FILE *fileread;
-
- fileread = !strcmp("-", file->contents)?
- stdin:fopen(file->contents, "rb"); /* binary read for win32 */
-
- /*
- * VMS: This only allows for stream files on VMS. Stream files are
- * OK, as are FIXED & VAR files WITHOUT implied CC For implied CC,
- * every record needs to have a \n appended & 1 added to SIZE
- */
-
- if(fileread) {
- if(fileread != stdin) {
- /* close the file */
- fclose(fileread);
- /* add the file name only - for later reading from this */
- result = AddFormData(&form, FORM_FILE, file->contents, 0, &size);
- }
- else {
- /* When uploading from stdin, we can't know the size of the file,
- * thus must read the full file as before. We *could* use chunked
- * transfer-encoding, but that only works for HTTP 1.1 and we
- * can't be sure we work with such a server.
- */
- size_t nread;
- char buffer[512];
- while((nread = fread(buffer, 1, sizeof(buffer), fileread)) != 0) {
- result = AddFormData(&form, FORM_CONTENT, buffer, nread, &size);
- if(result || feof(fileread) || ferror(fileread))
- break;
- }
+ if(post->flags & CURL_HTTPPOST_LARGE)
+ clen = post->contentlen;
+ if(!clen)
+ clen = -1;
+
+ if(post->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE)) {
+ if(!strcmp(file->contents, "-")) {
+ /* There are a few cases where the code below won't work; in
+ particular, freopen(stdin) by the caller is not guaranteed
+ to result as expected. This feature has been kept for backward
+ compatibility: use of "-" pseudo file name should be avoided. */
+ result = curl_mime_data_cb(part, (curl_off_t) -1,
+ (curl_read_callback) fread,
+ CURLX_FUNCTION_CAST(curl_seek_callback,
+ fseek),
+ NULL, (void *) stdin);
}
+ else
+ result = curl_mime_filedata(part, file->contents);
+ if(!result && (post->flags & HTTPPOST_READFILE))
+ result = curl_mime_filename(part, NULL);
}
+ else if(post->flags & HTTPPOST_BUFFER)
+ result = curl_mime_data(part, post->buffer,
+ post->bufferlength? post->bufferlength: -1);
+ else if(post->flags & HTTPPOST_CALLBACK)
+ /* the contents should be read with the callback and the size is set
+ with the contentslength */
+ result = curl_mime_data_cb(part, clen,
+ fread_func, NULL, NULL, post->userp);
else {
- if(data)
- failf(data, "couldn't open file \"%s\"", file->contents);
- *finalform = NULL;
- result = CURLE_READ_ERROR;
+ result = curl_mime_data(part, post->contents, (ssize_t) clen);
+#ifdef CURL_DOES_CONVERSIONS
+ /* Convert textual contents now. */
+ if(!result && data && part->datasize)
+ result = Curl_convert_to_network(data, part->data, part->datasize);
+#endif
}
}
- else if(post->flags & HTTPPOST_BUFFER)
- /* include contents of buffer */
- result = AddFormData(&form, FORM_CONTENT, post->buffer,
- post->bufferlength, &size);
- else if(post->flags & HTTPPOST_CALLBACK)
- /* the contents should be read with the callback and the size is set
- with the contentslength */
- result = AddFormData(&form, FORM_CALLBACK, post->userp,
- post->flags&CURL_HTTPPOST_LARGE?
- post->contentlen:post->contentslength, &size);
- else
- /* include the contents we got */
- result = AddFormData(&form, FORM_CONTENT, post->contents,
- post->flags&CURL_HTTPPOST_LARGE?
- post->contentlen:post->contentslength, &size);
- file = file->more;
- } while(file && !result); /* for each specified file for this field */
-
- if(result)
- break;
- if(post->more) {
- /* this was a multiple-file inclusion, make a termination file
- boundary: */
- result = AddFormDataf(&form, &size,
- "\r\n--%s--",
- fileboundary);
- if(result)
- break;
+ /* Set fake file name. */
+ if(!result && post->showfilename)
+ if(post->more || (post->flags & (HTTPPOST_FILENAME | HTTPPOST_BUFFER |
+ HTTPPOST_CALLBACK)))
+ result = curl_mime_filename(part, post->showfilename);
}
- post = post->next;
- } while(post); /* for each field */
-
- /* end-boundary for everything */
- if(!result)
- result = AddFormDataf(&form, &size, "\r\n--%s--\r\n", boundary);
-
- if(result) {
- Curl_formclean(&firstform);
- return result;
}
- *sizep = size;
- *finalform = firstform;
+ if(result)
+ Curl_mime_cleanpart(finalform);
return result;
}
-/*
- * Curl_FormInit() inits the struct 'form' points to with the 'formdata'
- * and resets the 'sent' counter.
- */
-int Curl_FormInit(struct Form *form, struct FormData *formdata)
-{
- if(!formdata)
- return 1; /* error */
-
- form->data = formdata;
- form->sent = 0;
- form->fp = NULL;
- form->fread_func = ZERO_NULL;
-
- return 0;
-}
-
-#ifndef __VMS
-# define fopen_read fopen
#else
- /*
- * vmsfopenread
- *
- * For upload to work as expected on VMS, different optional
- * parameters must be added to the fopen command based on
- * record format of the file.
- *
- */
-# define fopen_read vmsfopenread
-static FILE * vmsfopenread(const char *file, const char *mode)
-{
- struct_stat statbuf;
- int result;
-
- result = stat(file, &statbuf);
-
- switch(statbuf.st_fab_rfm) {
- case FAB$C_VAR:
- case FAB$C_VFC:
- case FAB$C_STMCR:
- return fopen(file, FOPEN_READTEXT); /* VMS */
- break;
- default:
- return fopen(file, FOPEN_READTEXT, "rfm=stmlf", "ctx=stm");
- }
-}
-#endif
-
-/*
- * readfromfile()
- *
- * The read callback that this function may use can return a value larger than
- * 'size' (which then this function returns) that indicates a problem and it
- * must be properly dealt with
- */
-static size_t readfromfile(struct Form *form, char *buffer,
- size_t size)
-{
- size_t nread;
- bool callback = (form->data->type == FORM_CALLBACK)?TRUE:FALSE;
-
- if(callback) {
- if(form->fread_func == ZERO_NULL)
- return 0;
- nread = form->fread_func(buffer, 1, size, form->data->line);
- }
- else {
- if(!form->fp) {
- /* this file hasn't yet been opened */
- form->fp = fopen_read(form->data->line, "rb"); /* b is for binary */
- if(!form->fp)
- return (size_t)-1; /* failure */
- }
- nread = fread(buffer, 1, size, form->fp);
- }
- if(!nread) {
- /* this is the last chunk from the file, move on */
- if(form->fp) {
- fclose(form->fp);
- form->fp = NULL;
- }
- form->data = form->data->next;
- }
-
- return nread;
-}
-
-/*
- * Curl_FormReader() is the fread() emulation function that will be used to
- * deliver the formdata to the transfer loop and then sent away to the peer.
- */
-size_t Curl_FormReader(char *buffer,
- size_t size,
- size_t nitems,
- FILE *mydata)
-{
- struct Form *form;
- size_t wantedsize;
- size_t gotsize = 0;
-
- form=(struct Form *)mydata;
-
- wantedsize = size * nitems;
-
- if(!form->data)
- return 0; /* nothing, error, empty */
-
- if((form->data->type == FORM_FILE) ||
- (form->data->type == FORM_CALLBACK)) {
- gotsize = readfromfile(form, buffer, wantedsize);
-
- if(gotsize)
- /* If positive or -1, return. If zero, continue! */
- return gotsize;
- }
- do {
-
- if((form->data->length - form->sent) > wantedsize - gotsize) {
-
- memcpy(buffer + gotsize, form->data->line + form->sent,
- wantedsize - gotsize);
-
- form->sent += wantedsize-gotsize;
-
- return wantedsize;
- }
-
- memcpy(buffer+gotsize,
- form->data->line + form->sent,
- (form->data->length - form->sent) );
- gotsize += form->data->length - form->sent;
-
- form->sent = 0;
-
- form->data = form->data->next; /* advance */
-
- } while(form->data && (form->data->type < FORM_CALLBACK));
- /* If we got an empty line and we have more data, we proceed to the next
- line immediately to avoid returning zero before we've reached the end. */
-
- return gotsize;
-}
-
-/*
- * Curl_formpostheader() returns the first line of the formpost, the
- * request-header part (which is not part of the request-body like the rest of
- * the post).
- */
-char *Curl_formpostheader(void *formp, size_t *len)
-{
- char *header;
- struct Form *form=(struct Form *)formp;
-
- if(!form->data)
- return NULL; /* nothing, ERROR! */
-
- header = form->data->line;
- *len = form->data->length;
-
- form->data = form->data->next; /* advance */
-
- return header;
-}
-
-/*
- * formboundary() creates a suitable boundary string and returns an allocated
- * one.
- */
-static CURLcode formboundary(struct Curl_easy *data,
- char *buffer, size_t buflen)
-{
- /* 24 dashes and 16 hexadecimal digits makes 64 bit (18446744073709551615)
- combinations */
- if(buflen < 41)
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- memset(buffer, '-', 24);
- Curl_rand_hex(data, (unsigned char *)&buffer[24], 17);
-
- return CURLE_OK;
-}
-
-#else /* CURL_DISABLE_HTTP */
+/* if disabled */
CURLFORMcode curl_formadd(struct curl_httppost **httppost,
struct curl_httppost **last_post,
...)
@@ -1591,5 +947,4 @@ void curl_formfree(struct curl_httppost *form)
/* does nothing HTTP is disabled */
}
-
-#endif /* !defined(CURL_DISABLE_HTTP) */
+#endif /* if disabled */
diff --git a/Utilities/cmcurl/lib/formdata.h b/Utilities/cmcurl/lib/formdata.h
index 69629f628..cb20805f5 100644
--- a/Utilities/cmcurl/lib/formdata.h
+++ b/Utilities/cmcurl/lib/formdata.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,31 +22,9 @@
*
***************************************************************************/
-enum formtype {
- FORM_DATAMEM, /* already allocated FORM_DATA memory */
- FORM_DATA, /* form metadata (convert to network encoding if necessary) */
- FORM_CONTENT, /* form content (never convert) */
- FORM_CALLBACK, /* 'line' points to the custom pointer we pass to the callback
- */
- FORM_FILE /* 'line' points to a file name we should read from
- to create the form data (never convert) */
-};
+#include "curl_setup.h"
-/* plain and simple linked list with lines to send */
-struct FormData {
- struct FormData *next;
- enum formtype type;
- char *line;
- size_t length;
-};
-
-struct Form {
- struct FormData *data; /* current form line to send */
- size_t sent; /* number of bytes of the current line that has
- already been sent in a previous invoke */
- FILE *fp; /* file to read from */
- curl_read_callback fread_func; /* fread callback pointer */
-};
+#ifndef CURL_DISABLE_MIME
/* used by FormAdd for temporary storage */
typedef struct FormInfo {
@@ -69,31 +47,14 @@ typedef struct FormInfo {
struct FormInfo *more;
} FormInfo;
-int Curl_FormInit(struct Form *form, struct FormData *formdata);
-
CURLcode Curl_getformdata(struct Curl_easy *data,
- struct FormData **,
+ curl_mimepart *,
struct curl_httppost *post,
- const char *custom_contenttype,
- curl_off_t *size);
-
-/* fread() emulation */
-size_t Curl_FormReader(char *buffer,
- size_t size,
- size_t nitems,
- FILE *mydata);
-
-/*
- * Curl_formpostheader() returns the first line of the formpost, the
- * request-header part (which is not part of the request-body like the rest of
- * the post).
- */
-char *Curl_formpostheader(void *formp, size_t *len);
-
-char *Curl_FormBoundary(void);
-
-void Curl_formclean(struct FormData **);
+ curl_read_callback fread_func);
+#else
+/* disabled */
+#define Curl_getformdata(a,b,c,d) CURLE_NOT_BUILT_IN
+#endif
-CURLcode Curl_formconvert(struct Curl_easy *, struct FormData *);
#endif /* HEADER_CURL_FORMDATA_H */
diff --git a/Utilities/cmcurl/lib/ftp.c b/Utilities/cmcurl/lib/ftp.c
index 783dbe124..53510f821 100644
--- a/Utilities/cmcurl/lib/ftp.c
+++ b/Utilities/cmcurl/lib/ftp.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -59,6 +59,7 @@
#include "ftp.h"
#include "fileinfo.h"
#include "ftplistparser.h"
+#include "curl_range.h"
#include "curl_sec.h"
#include "strtoofft.h"
#include "strcase.h"
@@ -178,10 +179,12 @@ const struct Curl_handler Curl_handler_ftp = {
ZERO_NULL, /* perform_getsock */
ftp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_FTP, /* defport */
CURLPROTO_FTP, /* protocol */
- PROTOPT_DUAL | PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD
- | PROTOPT_NOURLQUERY /* flags */
+ PROTOPT_DUAL | PROTOPT_CLOSEACTION | PROTOPT_NEEDSPWD |
+ PROTOPT_NOURLQUERY | PROTOPT_PROXY_AS_HTTP |
+ PROTOPT_WILDCARD /* flags */
};
@@ -205,66 +208,14 @@ const struct Curl_handler Curl_handler_ftps = {
ZERO_NULL, /* perform_getsock */
ftp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_FTPS, /* defport */
CURLPROTO_FTPS, /* protocol */
PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION |
- PROTOPT_NEEDSPWD | PROTOPT_NOURLQUERY /* flags */
+ PROTOPT_NEEDSPWD | PROTOPT_NOURLQUERY | PROTOPT_WILDCARD /* flags */
};
#endif
-#ifndef CURL_DISABLE_HTTP
-/*
- * HTTP-proxyed FTP protocol handler.
- */
-
-static const struct Curl_handler Curl_handler_ftp_proxy = {
- "FTP", /* scheme */
- Curl_http_setup_conn, /* setup_connection */
- Curl_http, /* do_it */
- Curl_http_done, /* done */
- ZERO_NULL, /* do_more */
- ZERO_NULL, /* connect_it */
- ZERO_NULL, /* connecting */
- ZERO_NULL, /* doing */
- ZERO_NULL, /* proto_getsock */
- ZERO_NULL, /* doing_getsock */
- ZERO_NULL, /* domore_getsock */
- ZERO_NULL, /* perform_getsock */
- ZERO_NULL, /* disconnect */
- ZERO_NULL, /* readwrite */
- PORT_FTP, /* defport */
- CURLPROTO_HTTP, /* protocol */
- PROTOPT_NONE /* flags */
-};
-
-
-#ifdef USE_SSL
-/*
- * HTTP-proxyed FTPS protocol handler.
- */
-
-static const struct Curl_handler Curl_handler_ftps_proxy = {
- "FTPS", /* scheme */
- Curl_http_setup_conn, /* setup_connection */
- Curl_http, /* do_it */
- Curl_http_done, /* done */
- ZERO_NULL, /* do_more */
- ZERO_NULL, /* connect_it */
- ZERO_NULL, /* connecting */
- ZERO_NULL, /* doing */
- ZERO_NULL, /* proto_getsock */
- ZERO_NULL, /* doing_getsock */
- ZERO_NULL, /* domore_getsock */
- ZERO_NULL, /* perform_getsock */
- ZERO_NULL, /* disconnect */
- ZERO_NULL, /* readwrite */
- PORT_FTPS, /* defport */
- CURLPROTO_HTTP, /* protocol */
- PROTOPT_NONE /* flags */
-};
-#endif
-#endif
-
static void close_secondarysocket(struct connectdata *conn)
{
if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) {
@@ -272,7 +223,6 @@ static void close_secondarysocket(struct connectdata *conn)
conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
}
conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE;
- conn->tunnel_state[SECONDARYSOCKET] = TUNNEL_INIT;
}
/*
@@ -289,11 +239,11 @@ static void close_secondarysocket(struct connectdata *conn)
static void freedirs(struct ftp_conn *ftpc)
{
- int i;
if(ftpc->dirs) {
- for(i=0; i < ftpc->dirdepth; i++) {
+ int i;
+ for(i = 0; i < ftpc->dirdepth; i++) {
free(ftpc->dirs[i]);
- ftpc->dirs[i]=NULL;
+ ftpc->dirs[i] = NULL;
}
free(ftpc->dirs);
ftpc->dirs = NULL;
@@ -340,7 +290,7 @@ static CURLcode AcceptServerConnect(struct connectdata *conn)
if(0 == getsockname(sock, (struct sockaddr *) &add, &size)) {
size = sizeof(add);
- s=accept(sock, (struct sockaddr *) &add, &size);
+ s = accept(sock, (struct sockaddr *) &add, &size);
}
Curl_closesocket(conn, sock); /* close the first socket */
@@ -361,9 +311,11 @@ static CURLcode AcceptServerConnect(struct connectdata *conn)
int error = 0;
/* activate callback for setting socket options */
+ Curl_set_in_callback(data, true);
error = data->set.fsockopt(data->set.sockopt_client,
s,
CURLSOCKTYPE_ACCEPT);
+ Curl_set_in_callback(data, false);
if(error) {
close_secondarysocket(conn);
@@ -384,16 +336,16 @@ static CURLcode AcceptServerConnect(struct connectdata *conn)
* Curl_pgrsTime(..., TIMER_STARTACCEPT);
*
*/
-static time_t ftp_timeleft_accept(struct Curl_easy *data)
+static timediff_t ftp_timeleft_accept(struct Curl_easy *data)
{
- time_t timeout_ms = DEFAULT_ACCEPT_TIMEOUT;
- time_t other;
- struct timeval now;
+ timediff_t timeout_ms = DEFAULT_ACCEPT_TIMEOUT;
+ timediff_t other;
+ struct curltime now;
if(data->set.accepttimeout > 0)
timeout_ms = data->set.accepttimeout;
- now = Curl_tvnow();
+ now = Curl_now();
/* check if the generic timeout possibly is set shorter */
other = Curl_timeleft(data, &now, FALSE);
@@ -403,7 +355,7 @@ static time_t ftp_timeleft_accept(struct Curl_easy *data)
timeout_ms = other;
else {
/* subtract elapsed time */
- timeout_ms -= Curl_tvdiff(now, data->progress.t_acceptdata);
+ timeout_ms -= Curl_timediff(now, data->progress.t_acceptdata);
if(!timeout_ms)
/* avoid returning 0 as that means no timeout! */
return -1;
@@ -496,7 +448,6 @@ static CURLcode ReceivedServerConnect(struct connectdata *conn, bool *received)
static CURLcode InitiateTransfer(struct connectdata *conn)
{
struct Curl_easy *data = conn->data;
- struct FTP *ftp = data->req.protop;
CURLcode result = CURLE_OK;
if(conn->bits.ftp_use_data_ssl) {
@@ -509,24 +460,19 @@ static CURLcode InitiateTransfer(struct connectdata *conn)
}
if(conn->proto.ftpc.state_saved == FTP_STOR) {
- *(ftp->bytecountp)=0;
-
/* When we know we're uploading a specified file, we can get the file
size prior to the actual upload. */
-
Curl_pgrsSetUploadSize(data, data->state.infilesize);
/* set the SO_SNDBUF for the secondary socket for those who need it */
Curl_sndbufset(conn->sock[SECONDARYSOCKET]);
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, /* no download */
- SECONDARYSOCKET, ftp->bytecountp);
+ Curl_setup_transfer(data, -1, -1, FALSE, SECONDARYSOCKET);
}
else {
/* FTP download: */
- Curl_setup_transfer(conn, SECONDARYSOCKET,
- conn->proto.ftpc.retr_size_saved, FALSE,
- ftp->bytecountp, -1, NULL); /* no upload here */
+ Curl_setup_transfer(data, SECONDARYSOCKET,
+ conn->proto.ftpc.retr_size_saved, FALSE, -1);
}
conn->proto.ftpc.pp.pending_resp = TRUE; /* expect server response */
@@ -626,7 +572,6 @@ static CURLcode ftp_readresp(curl_socket_t sockfd,
#if defined(HAVE_GSSAPI)
/* handle the security-oriented responses 6xx ***/
- /* FIXME: some errorchecking perhaps... ***/
switch(code) {
case 631:
code = Curl_sec_read_msg(conn, buf, PROT_SAFE);
@@ -644,7 +589,7 @@ static CURLcode ftp_readresp(curl_socket_t sockfd,
#endif
/* store the latest code for later retrieval */
- data->info.httpcode=code;
+ data->info.httpcode = code;
if(ftpcode)
*ftpcode = code;
@@ -685,15 +630,13 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
* line in a response or continue reading. */
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
- time_t timeout; /* timeout in milliseconds */
- time_t interval_ms;
struct Curl_easy *data = conn->data;
CURLcode result = CURLE_OK;
struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp;
size_t nread;
- int cache_skip=0;
- int value_to_be_ignored=0;
+ int cache_skip = 0;
+ int value_to_be_ignored = 0;
if(ftpcode)
*ftpcode = 0; /* 0 for errors */
@@ -701,13 +644,14 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
/* make the pointer point to something for the rest of this function */
ftpcode = &value_to_be_ignored;
- *nreadp=0;
+ *nreadp = 0;
while(!*ftpcode && !result) {
/* check and reset timeout value every lap */
- timeout = Curl_pp_state_timeout(pp);
+ time_t timeout = Curl_pp_state_timeout(pp, FALSE);
+ time_t interval_ms;
- if(timeout <=0) {
+ if(timeout <= 0) {
failf(data, "FTP response timeout");
return CURLE_OPERATION_TIMEDOUT; /* already too little time */
}
@@ -765,7 +709,7 @@ CURLcode Curl_GetFTPResponse(ssize_t *nreadp, /* return number of bytes read */
else
/* when we got data or there is no cache left, we reset the cache skip
counter */
- cache_skip=0;
+ cache_skip = 0;
*nreadp += nread;
@@ -900,7 +844,7 @@ static int ftp_domore_getsock(struct connectdata *conn, curl_socket_t *socks,
int i;
/* PORT is used to tell the server to connect to us, and during that we
don't do happy eyeballs, but we do if we connect to the server */
- for(s=1, i=0; i<2; i++) {
+ for(s = 1, i = 0; i<2; i++) {
if(conn->tempsock[i] != CURL_SOCKET_BAD) {
socks[s] = conn->tempsock[i];
bits |= GETSOCK_WRITESOCK(s++);
@@ -937,23 +881,26 @@ static CURLcode ftp_state_cwd(struct connectdata *conn)
/* count3 is set to allow a MKD to fail once. In the case when first CWD
fails and then MKD fails (due to another session raced it to create the
dir) this then allows for a second try to CWD to it */
- ftpc->count3 = (conn->data->set.ftp_create_missing_dirs==2)?1:0;
+ ftpc->count3 = (conn->data->set.ftp_create_missing_dirs == 2)?1:0;
- if(conn->bits.reuse && ftpc->entrypath) {
+ if((conn->data->set.ftp_filemethod == FTPFILE_NOCWD) && !ftpc->cwdcount)
+ /* No CWD necessary */
+ result = ftp_state_mdtm(conn);
+ else if(conn->bits.reuse && ftpc->entrypath) {
/* This is a re-used connection. Since we change directory to where the
transfer is taking place, we must first get back to the original dir
where we ended up after login: */
- ftpc->count1 = 0; /* we count this as the first path, then we add one
- for all upcoming ones in the ftp->dirs[] array */
+ ftpc->cwdcount = 0; /* we count this as the first path, then we add one
+ for all upcoming ones in the ftp->dirs[] array */
PPSENDF(&conn->proto.ftpc.pp, "CWD %s", ftpc->entrypath);
state(conn, FTP_CWD);
}
else {
if(ftpc->dirdepth) {
- ftpc->count1 = 1;
+ ftpc->cwdcount = 1;
/* issue the first CWD, the rest is sent when the CWD responses are
received... */
- PPSENDF(&conn->proto.ftpc.pp, "CWD %s", ftpc->dirs[ftpc->count1 -1]);
+ PPSENDF(&conn->proto.ftpc.pp, "CWD %s", ftpc->dirs[ftpc->cwdcount -1]);
state(conn, FTP_CWD);
}
else {
@@ -977,15 +924,15 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
{
CURLcode result = CURLE_OK;
struct ftp_conn *ftpc = &conn->proto.ftpc;
- struct Curl_easy *data=conn->data;
- curl_socket_t portsock= CURL_SOCKET_BAD;
+ struct Curl_easy *data = conn->data;
+ curl_socket_t portsock = CURL_SOCKET_BAD;
char myhost[256] = "";
struct Curl_sockaddr_storage ss;
Curl_addrinfo *res, *ai;
curl_socklen_t sslen;
char hbuf[NI_MAXHOST];
- struct sockaddr *sa=(struct sockaddr *)&ss;
+ struct sockaddr *sa = (struct sockaddr *)&ss;
struct sockaddr_in * const sa4 = (void *)sa;
#ifdef ENABLE_IPV6
struct sockaddr_in6 * const sa6 = (void *)sa;
@@ -996,12 +943,12 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
int error;
char *host = NULL;
char *string_ftpport = data->set.str[STRING_FTPPORT];
- struct Curl_dns_entry *h=NULL;
+ struct Curl_dns_entry *h = NULL;
unsigned short port_min = 0;
unsigned short port_max = 0;
unsigned short port;
bool possibly_non_local = TRUE;
-
+ char buffer[STRERROR_LEN];
char *addr = NULL;
/* Step 1, figure out what is requested,
@@ -1024,7 +971,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
char *port_start = NULL;
char *port_sep = NULL;
- addr = calloc(addrlen+1, 1);
+ addr = calloc(addrlen + 1, 1);
if(!addr)
return CURLE_OUT_OF_MEMORY;
@@ -1067,7 +1014,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
if(ip_end != NULL) {
port_start = strchr(ip_end, ':');
if(port_start) {
- port_min = curlx_ultous(strtoul(port_start+1, NULL, 10));
+ port_min = curlx_ultous(strtoul(port_start + 1, NULL, 10));
port_sep = strchr(port_start, '-');
if(port_sep) {
port_max = curlx_ultous(strtoul(port_sep + 1, NULL, 10));
@@ -1110,11 +1057,10 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
if(!host) {
/* not an interface and not a host name, get default by extracting
the IP from the control connection */
-
sslen = sizeof(ss);
if(getsockname(conn->sock[FIRSTSOCKET], sa, &sslen)) {
failf(data, "getsockname() failed: %s",
- Curl_strerror(conn, SOCKERRNO) );
+ Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
free(addr);
return CURLE_FTP_PORT_FAILED;
}
@@ -1133,7 +1079,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
}
/* resolv ip/host to ip */
- rc = Curl_resolv(conn, host, 0, &h);
+ rc = Curl_resolv(conn, host, 0, FALSE, &h);
if(rc == CURLRESOLV_PENDING)
(void)Curl_resolver_wait_resolv(conn, &h);
if(h) {
@@ -1167,7 +1113,8 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
break;
}
if(!ai) {
- failf(data, "socket failure: %s", Curl_strerror(conn, error));
+ failf(data, "socket failure: %s",
+ Curl_strerror(error, buffer, sizeof(buffer)));
return CURLE_FTP_PORT_FAILED;
}
@@ -1191,14 +1138,13 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
/* The requested bind address is not local. Use the address used for
* the control connection instead and restart the port loop
*/
-
infof(data, "bind(port=%hu) on non-local address failed: %s\n", port,
- Curl_strerror(conn, error) );
+ Curl_strerror(error, buffer, sizeof(buffer)));
sslen = sizeof(ss);
if(getsockname(conn->sock[FIRSTSOCKET], sa, &sslen)) {
failf(data, "getsockname() failed: %s",
- Curl_strerror(conn, SOCKERRNO) );
+ Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
Curl_closesocket(conn, portsock);
return CURLE_FTP_PORT_FAILED;
}
@@ -1208,7 +1154,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
}
if(error != EADDRINUSE && error != EACCES) {
failf(data, "bind(port=%hu) failed: %s", port,
- Curl_strerror(conn, error) );
+ Curl_strerror(error, buffer, sizeof(buffer)));
Curl_closesocket(conn, portsock);
return CURLE_FTP_PORT_FAILED;
}
@@ -1231,7 +1177,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
sslen = sizeof(ss);
if(getsockname(portsock, (struct sockaddr *)sa, &sslen)) {
failf(data, "getsockname() failed: %s",
- Curl_strerror(conn, SOCKERRNO) );
+ Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
Curl_closesocket(conn, portsock);
return CURLE_FTP_PORT_FAILED;
}
@@ -1239,7 +1185,8 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
/* step 4, listen on the socket */
if(listen(portsock, 1)) {
- failf(data, "socket failure: %s", Curl_strerror(conn, SOCKERRNO));
+ failf(data, "socket failure: %s",
+ Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
Curl_closesocket(conn, portsock);
return CURLE_FTP_PORT_FAILED;
}
@@ -1311,14 +1258,14 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
/* translate x.x.x.x to x,x,x,x */
while(source && *source) {
if(*source == '.')
- *dest=',';
+ *dest = ',';
else
*dest = *source;
dest++;
source++;
}
*dest = 0;
- snprintf(dest, 20, ",%d,%d", (int)(port>>8), (int)(port&0xff));
+ msnprintf(dest, 20, ",%d,%d", (int)(port>>8), (int)(port&0xff));
result = Curl_pp_sendf(&ftpc->pp, "%s %s", mode[fcmd], tmp);
if(result) {
@@ -1490,6 +1437,7 @@ static CURLcode ftp_state_list(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
+ struct FTP *ftp = data->req.protop;
/* If this output is to be machine-parsed, the NLST command might be better
to use, since the LIST command output is not specified or standard in any
@@ -1506,25 +1454,22 @@ static CURLcode ftp_state_list(struct connectdata *conn)
then just do LIST (in that case: nothing to do here)
*/
char *cmd, *lstArg, *slashPos;
+ const char *inpath = ftp->path;
lstArg = NULL;
if((data->set.ftp_filemethod == FTPFILE_NOCWD) &&
- data->state.path &&
- data->state.path[0] &&
- strchr(data->state.path, '/')) {
-
- lstArg = strdup(data->state.path);
- if(!lstArg)
- return CURLE_OUT_OF_MEMORY;
+ inpath && inpath[0] && strchr(inpath, '/')) {
+ size_t n = strlen(inpath);
/* Check if path does not end with /, as then we cut off the file part */
- if(lstArg[strlen(lstArg) - 1] != '/') {
-
+ if(inpath[n - 1] != '/') {
/* chop off the file part if format is dir/dir/file */
- slashPos = strrchr(lstArg, '/');
- if(slashPos)
- *(slashPos+1) = '\0';
+ slashPos = strrchr(inpath, '/');
+ n = slashPos - inpath;
}
+ result = Curl_urldecode(data, inpath, n, &lstArg, NULL, TRUE);
+ if(result)
+ return result;
}
cmd = aprintf("%s%s%s",
@@ -1586,7 +1531,7 @@ static CURLcode ftp_state_type(struct connectdata *conn)
date. */
if(data->set.opt_no_body && ftpc->file &&
ftp_need_type(conn, data->set.prefer_ascii)) {
- /* The SIZE command is _not_ RFC 959 specified, and therefor many servers
+ /* The SIZE command is _not_ RFC 959 specified, and therefore many servers
may not support it! It is however the only way we have to get a file's
size! */
@@ -1637,7 +1582,6 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
struct FTP *ftp = conn->data->req.protop;
struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
- int seekerr = CURL_SEEKFUNC_OK;
if((data->state.resume_from && !sizechecked) ||
((data->state.resume_from > 0) && sizechecked)) {
@@ -1653,6 +1597,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
/* 3. pass file-size number of bytes in the source file */
/* 4. lower the infilesize counter */
/* => transfer as usual */
+ int seekerr = CURL_SEEKFUNC_OK;
if(data->state.resume_from < 0) {
/* Got no given size to start from, figure it out */
@@ -1666,12 +1611,14 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
/* Let's read off the proper amount of bytes from the input. */
if(conn->seek_func) {
+ Curl_set_in_callback(data, true);
seekerr = conn->seek_func(conn->seek_client, data->state.resume_from,
SEEK_SET);
+ Curl_set_in_callback(data, false);
}
if(seekerr != CURL_SEEKFUNC_OK) {
- curl_off_t passed=0;
+ curl_off_t passed = 0;
if(seekerr != CURL_SEEKFUNC_CANTSEEK) {
failf(data, "Could not seek stream");
return CURLE_FTP_COULDNT_USE_REST;
@@ -1704,7 +1651,7 @@ static CURLcode ftp_state_ul_setup(struct connectdata *conn,
infof(data, "File already completely uploaded\n");
/* no data to transfer */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
/* Set ->transfer so that we won't get any error in
* ftp_done() because we didn't transfer anything! */
@@ -1733,7 +1680,7 @@ static CURLcode ftp_state_quote(struct connectdata *conn,
struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
- bool quote=FALSE;
+ bool quote = FALSE;
struct curl_slist *item;
switch(instate) {
@@ -1834,7 +1781,7 @@ static CURLcode ftp_epsv_disable(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- if(conn->bits.ipv6) {
+ if(conn->bits.ipv6 && !(conn->bits.tunnel_proxy || conn->bits.socksproxy)) {
/* We can't disable EPSV when doing IPv6, so this is instead a fail */
failf(conn->data, "Failed EPSV attempt, exiting\n");
return CURLE_WEIRD_SERVER_REPLY;
@@ -1870,11 +1817,11 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
{
struct ftp_conn *ftpc = &conn->proto.ftpc;
CURLcode result;
- struct Curl_easy *data=conn->data;
- struct Curl_dns_entry *addr=NULL;
+ struct Curl_easy *data = conn->data;
+ struct Curl_dns_entry *addr = NULL;
int rc;
unsigned short connectport; /* the local port connect() should use! */
- char *str=&data->state.buffer[4]; /* start on the first letter */
+ char *str = &data->state.buffer[4]; /* start on the first letter */
/* if we come here again, make sure the former name is cleared */
Curl_safefree(ftpc->newhost);
@@ -1898,9 +1845,9 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
/* The four separators should be identical, or else this is an oddly
formatted reply and we bail out immediately. */
- for(i=1; i<4; i++) {
+ for(i = 1; i<4; i++) {
if(separator[i] != sep1) {
- ptr=NULL; /* set to NULL to signal error */
+ ptr = NULL; /* set to NULL to signal error */
break;
}
}
@@ -1916,7 +1863,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
}
}
else
- ptr=NULL;
+ ptr = NULL;
}
if(!ptr) {
failf(data, "Weirdly formatted EPSV reply");
@@ -1926,8 +1873,8 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
else if((ftpc->count1 == 1) &&
(ftpcode == 227)) {
/* positive PASV response */
- int ip[4];
- int port[2];
+ unsigned int ip[4];
+ unsigned int port[2];
/*
* Scan for a sequence of six comma-separated numbers and use them as
@@ -1939,14 +1886,15 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
* "227 Entering passive mode. 127,0,0,1,4,51"
*/
while(*str) {
- if(6 == sscanf(str, "%d,%d,%d,%d,%d,%d",
+ if(6 == sscanf(str, "%u,%u,%u,%u,%u,%u",
&ip[0], &ip[1], &ip[2], &ip[3],
&port[0], &port[1]))
break;
str++;
}
- if(!*str) {
+ if(!*str || (ip[0] > 255) || (ip[1] > 255) || (ip[2] > 255) ||
+ (ip[3] > 255) || (port[0] > 255) || (port[1] > 255) ) {
failf(data, "Couldn't interpret the 227-response");
return CURLE_FTP_WEIRD_227_FORMAT;
}
@@ -1955,13 +1903,13 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
if(data->set.ftp_skip_ip) {
/* told to ignore the remotely given IP but instead use the host we used
for the control connection */
- infof(data, "Skip %d.%d.%d.%d for data connection, re-use %s instead\n",
+ infof(data, "Skip %u.%u.%u.%u for data connection, re-use %s instead\n",
ip[0], ip[1], ip[2], ip[3],
conn->host.name);
ftpc->newhost = strdup(control_address(conn));
}
else
- ftpc->newhost = aprintf("%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
+ ftpc->newhost = aprintf("%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
if(!ftpc->newhost)
return CURLE_OUT_OF_MEMORY;
@@ -1985,7 +1933,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
*/
const char * const host_name = conn->bits.socksproxy ?
conn->socks_proxy.host.name : conn->http_proxy.host.name;
- rc = Curl_resolv(conn, host_name, (int)conn->port, &addr);
+ rc = Curl_resolv(conn, host_name, (int)conn->port, FALSE, &addr);
if(rc == CURLRESOLV_PENDING)
/* BLOCKING, ignores the return code but 'addr' will be NULL in
case of failure */
@@ -2001,7 +1949,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
}
else {
/* normal, direct, ftp connection */
- rc = Curl_resolv(conn, ftpc->newhost, ftpc->newport, &addr);
+ rc = Curl_resolv(conn, ftpc->newhost, ftpc->newport, FALSE, &addr);
if(rc == CURLRESOLV_PENDING)
/* BLOCKING */
(void)Curl_resolver_wait_resolv(conn, &addr);
@@ -2090,7 +2038,7 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
int ftpcode)
{
CURLcode result = CURLE_OK;
- struct Curl_easy *data=conn->data;
+ struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
@@ -2104,13 +2052,13 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
&year, &month, &day, &hour, &minute, &second)) {
/* we have a time, reformat it */
char timebuf[24];
- time_t secs=time(NULL);
+ time_t secs = time(NULL);
- snprintf(timebuf, sizeof(timebuf),
- "%04d%02d%02d %02d:%02d:%02d GMT",
- year, month, day, hour, minute, second);
+ msnprintf(timebuf, sizeof(timebuf),
+ "%04d%02d%02d %02d:%02d:%02d GMT",
+ year, month, day, hour, minute, second);
/* now, convert this into a time() value: */
- data->info.filetime = (long)curl_getdate(timebuf, &secs);
+ data->info.filetime = curl_getdate(timebuf, &secs);
}
#ifdef CURL_FTP_HTTPSTYLE_HEAD
@@ -2120,9 +2068,9 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
if(data->set.opt_no_body &&
ftpc->file &&
data->set.get_filetime &&
- (data->info.filetime>=0) ) {
+ (data->info.filetime >= 0) ) {
char headerbuf[128];
- time_t filetime = (time_t)data->info.filetime;
+ time_t filetime = data->info.filetime;
struct tm buffer;
const struct tm *tm = &buffer;
@@ -2131,15 +2079,15 @@ static CURLcode ftp_state_mdtm_resp(struct connectdata *conn,
return result;
/* format: "Tue, 15 Nov 1994 12:45:26" */
- snprintf(headerbuf, sizeof(headerbuf),
- "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
- Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
- tm->tm_mday,
- Curl_month[tm->tm_mon],
- tm->tm_year + 1900,
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec);
+ msnprintf(headerbuf, sizeof(headerbuf),
+ "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
+ Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
+ tm->tm_mday,
+ Curl_month[tm->tm_mon],
+ tm->tm_year + 1900,
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec);
result = Curl_client_write(conn, CLIENTWRITE_BOTH, headerbuf, 0);
if(result)
return result;
@@ -2196,7 +2144,7 @@ static CURLcode ftp_state_type_resp(struct connectdata *conn,
ftpstate instate)
{
CURLcode result = CURLE_OK;
- struct Curl_easy *data=conn->data;
+ struct Curl_easy *data = conn->data;
if(ftpcode/100 != 2) {
/* "sasserftpd" and "(u)r(x)bot ftpd" both responds with 226 after a
@@ -2225,7 +2173,7 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
curl_off_t filesize)
{
CURLcode result = CURLE_OK;
- struct Curl_easy *data=conn->data;
+ struct Curl_easy *data = conn->data;
struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
@@ -2275,7 +2223,7 @@ static CURLcode ftp_state_retr(struct connectdata *conn,
if(ftp->downloadsize == 0) {
/* no data to transfer */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
infof(data, "File already completely downloaded\n");
/* Set ->transfer so that we won't get any error in ftp_done()
@@ -2308,19 +2256,21 @@ static CURLcode ftp_state_size_resp(struct connectdata *conn,
ftpstate instate)
{
CURLcode result = CURLE_OK;
- struct Curl_easy *data=conn->data;
- curl_off_t filesize;
+ struct Curl_easy *data = conn->data;
+ curl_off_t filesize = -1;
char *buf = data->state.buffer;
/* get the size from the ascii string: */
- filesize = (ftpcode == 213)?curlx_strtoofft(buf+4, NULL, 0):-1;
+ if(ftpcode == 213)
+ /* ignores parsing errors, which will make the size remain unknown */
+ (void)curlx_strtoofft(buf + 4, NULL, 0, &filesize);
if(instate == FTP_SIZE) {
#ifdef CURL_FTP_HTTPSTYLE_HEAD
if(-1 != filesize) {
char clbuf[128];
- snprintf(clbuf, sizeof(clbuf),
- "Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", filesize);
+ msnprintf(clbuf, sizeof(clbuf),
+ "Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", filesize);
result = Curl_client_write(conn, CLIENTWRITE_BOTH, clbuf, 0);
if(result)
return result;
@@ -2383,7 +2333,7 @@ static CURLcode ftp_state_stor_resp(struct connectdata *conn,
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- if(ftpcode>=400) {
+ if(ftpcode >= 400) {
failf(data, "Failed FTP upload: %0d", ftpcode);
state(conn, FTP_STOP);
/* oops, we never close the sockets! */
@@ -2441,7 +2391,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
E:
125 Data connection already open; Transfer starting. */
- curl_off_t size=-1; /* default unknown size */
+ curl_off_t size = -1; /* default unknown size */
/*
@@ -2465,9 +2415,9 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
* Example D above makes this parsing a little tricky */
char *bytes;
char *buf = data->state.buffer;
- bytes=strstr(buf, " bytes");
- if(bytes--) {
- long in=(long)(bytes-buf);
+ bytes = strstr(buf, " bytes");
+ if(bytes) {
+ long in = (long)(--bytes-buf);
/* this is a hint there is size information in there! ;-) */
while(--in) {
/* scan for the left parenthesis and break there */
@@ -2475,7 +2425,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
break;
/* skip only digits */
if(!ISDIGIT(*bytes)) {
- bytes=NULL;
+ bytes = NULL;
break;
}
/* one more estep backwards */
@@ -2484,7 +2434,7 @@ static CURLcode ftp_state_get_resp(struct connectdata *conn,
/* if we have nothing but digits: */
if(bytes++) {
/* get the number! */
- size = curlx_strtoofft(bytes, NULL, 0);
+ (void)curlx_strtoofft(bytes, NULL, 0, &size);
}
}
}
@@ -2647,7 +2597,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
{
CURLcode result;
curl_socket_t sock = conn->sock[FIRSTSOCKET];
- struct Curl_easy *data=conn->data;
+ struct Curl_easy *data = conn->data;
int ftpcode;
struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp;
@@ -2699,7 +2649,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
/* We don't have a SSL/TLS connection yet, but FTPS is
requested. Try a FTPS connection now */
- ftpc->count3=0;
+ ftpc->count3 = 0;
switch(data->set.ftpsslauth) {
case CURLFTPAUTH_DEFAULT:
case CURLFTPAUTH_SSL:
@@ -2822,10 +2772,10 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
case FTP_PWD:
if(ftpcode == 257) {
- char *ptr=&data->state.buffer[4]; /* start on the first letter */
+ char *ptr = &data->state.buffer[4]; /* start on the first letter */
const size_t buf_size = data->set.buffer_size;
char *dir;
- char *store;
+ bool entry_extracted = FALSE;
dir = malloc(nread + 1);
if(!dir)
@@ -2847,6 +2797,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
if('\"' == *ptr) {
/* it started good */
+ char *store;
ptr++;
for(store = dir; *ptr;) {
if('\"' == *ptr) {
@@ -2857,7 +2808,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
}
else {
/* end of path */
- *store = '\0'; /* zero terminate */
+ entry_extracted = TRUE;
break; /* get out of this loop */
}
}
@@ -2866,7 +2817,9 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
store++;
ptr++;
}
-
+ *store = '\0'; /* zero terminate */
+ }
+ if(entry_extracted) {
/* If the path name does not look like an absolute path (i.e.: it
does not start with a '/'), we probably need some server-dependent
adjustments. For example, this is the case when connecting to
@@ -2913,7 +2866,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
case FTP_SYST:
if(ftpcode == 215) {
- char *ptr=&data->state.buffer[4]; /* start on the first letter */
+ char *ptr = &data->state.buffer[4]; /* start on the first letter */
char *os;
char *store;
@@ -2988,10 +2941,10 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
if(ftpcode/100 != 2) {
/* failure to CWD there */
if(conn->data->set.ftp_create_missing_dirs &&
- ftpc->count1 && !ftpc->count2) {
+ ftpc->cwdcount && !ftpc->count2) {
/* try making it */
ftpc->count2++; /* counter to prevent CWD-MKD loops */
- PPSENDF(&ftpc->pp, "MKD %s", ftpc->dirs[ftpc->count1 - 1]);
+ PPSENDF(&ftpc->pp, "MKD %s", ftpc->dirs[ftpc->cwdcount - 1]);
state(conn, FTP_MKD);
}
else {
@@ -3004,10 +2957,10 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
}
else {
/* success */
- ftpc->count2=0;
- if(++ftpc->count1 <= ftpc->dirdepth) {
+ ftpc->count2 = 0;
+ if(++ftpc->cwdcount <= ftpc->dirdepth) {
/* send next CWD */
- PPSENDF(&ftpc->pp, "CWD %s", ftpc->dirs[ftpc->count1 - 1]);
+ PPSENDF(&ftpc->pp, "CWD %s", ftpc->dirs[ftpc->cwdcount - 1]);
}
else {
result = ftp_state_mdtm(conn);
@@ -3025,7 +2978,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
}
state(conn, FTP_CWD);
/* send CWD */
- PPSENDF(&ftpc->pp, "CWD %s", ftpc->dirs[ftpc->count1 - 1]);
+ PPSENDF(&ftpc->pp, "CWD %s", ftpc->dirs[ftpc->cwdcount - 1]);
break;
case FTP_MDTM:
@@ -3094,7 +3047,7 @@ static CURLcode ftp_multi_statemach(struct connectdata *conn,
bool *done)
{
struct ftp_conn *ftpc = &conn->proto.ftpc;
- CURLcode result = Curl_pp_statemach(&ftpc->pp, FALSE);
+ CURLcode result = Curl_pp_statemach(&ftpc->pp, FALSE, FALSE);
/* Check for the state outside of the Curl_socket_check() return code checks
since at times we are in fact already in this state when this function
@@ -3111,7 +3064,7 @@ static CURLcode ftp_block_statemach(struct connectdata *conn)
CURLcode result = CURLE_OK;
while(ftpc->state != FTP_STOP) {
- result = Curl_pp_statemach(pp, TRUE);
+ result = Curl_pp_statemach(pp, TRUE, TRUE /* disconnecting */);
if(result)
break;
}
@@ -3182,7 +3135,6 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
int ftpcode;
CURLcode result = CURLE_OK;
char *path = NULL;
- const char *path_to_use = data->state.path;
if(!ftp)
return CURLE_OK;
@@ -3223,16 +3175,18 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
/* now store a copy of the directory we are in */
free(ftpc->prevpath);
- if(data->set.wildcardmatch) {
+ if(data->state.wildcardmatch) {
if(data->set.chunk_end && ftpc->file) {
+ Curl_set_in_callback(data, true);
data->set.chunk_end(data->wildcard.customptr);
+ Curl_set_in_callback(data, false);
}
ftpc->known_filesize = -1;
}
if(!result)
/* get the "raw" path */
- result = Curl_urldecode(data, path_to_use, 0, &path, NULL, FALSE);
+ result = Curl_urldecode(data, ftp->path, 0, &path, NULL, TRUE);
if(result) {
/* We can limp along anyway (and should try to since we may already be in
* the error path) */
@@ -3244,16 +3198,19 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
size_t flen = ftpc->file?strlen(ftpc->file):0; /* file is "raw" already */
size_t dlen = strlen(path)-flen;
if(!ftpc->cwdfail) {
+ ftpc->prevmethod = data->set.ftp_filemethod;
if(dlen && (data->set.ftp_filemethod != FTPFILE_NOCWD)) {
ftpc->prevpath = path;
if(flen)
/* if 'path' is not the whole string */
- ftpc->prevpath[dlen]=0; /* terminate */
+ ftpc->prevpath[dlen] = 0; /* terminate */
}
else {
- /* we never changed dir */
- ftpc->prevpath=strdup("");
free(path);
+ /* we never changed dir */
+ ftpc->prevpath = strdup("");
+ if(!ftpc->prevpath)
+ return CURLE_OUT_OF_MEMORY;
}
if(ftpc->prevpath)
infof(data, "Remembering we are in dir \"%s\"\n", ftpc->prevpath);
@@ -3306,7 +3263,7 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
long old_time = pp->response_time;
pp->response_time = 60*1000; /* give it only a minute for now */
- pp->response = Curl_tvnow(); /* timeout relative now */
+ pp->response = Curl_now(); /* timeout relative now */
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
@@ -3344,33 +3301,33 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
;
else if(data->set.upload) {
if((-1 != data->state.infilesize) &&
- (data->state.infilesize != *ftp->bytecountp) &&
+ (data->state.infilesize != data->req.writebytecount) &&
!data->set.crlf &&
(ftp->transfer == FTPTRANSFER_BODY)) {
failf(data, "Uploaded unaligned file size (%" CURL_FORMAT_CURL_OFF_T
" out of %" CURL_FORMAT_CURL_OFF_T " bytes)",
- *ftp->bytecountp, data->state.infilesize);
+ data->req.bytecount, data->state.infilesize);
result = CURLE_PARTIAL_FILE;
}
}
else {
if((-1 != data->req.size) &&
- (data->req.size != *ftp->bytecountp) &&
+ (data->req.size != data->req.bytecount) &&
#ifdef CURL_DO_LINEEND_CONV
/* Most FTP servers don't adjust their file SIZE response for CRLFs, so
* we'll check to see if the discrepancy can be explained by the number
* of CRLFs we've changed to LFs.
*/
((data->req.size + data->state.crlf_conversions) !=
- *ftp->bytecountp) &&
+ data->req.bytecount) &&
#endif /* CURL_DO_LINEEND_CONV */
- (data->req.maxdownload != *ftp->bytecountp)) {
+ (data->req.maxdownload != data->req.bytecount)) {
failf(data, "Received only partial file: %" CURL_FORMAT_CURL_OFF_T
- " bytes", *ftp->bytecountp);
+ " bytes", data->req.bytecount);
result = CURLE_PARTIAL_FILE;
}
else if(!ftpc->dont_check &&
- !*ftp->bytecountp &&
+ !data->req.bytecount &&
(data->req.size>0)) {
failf(data, "No data was received!");
result = CURLE_FTP_COULDNT_RETR_FILE;
@@ -3384,7 +3341,7 @@ static CURLcode ftp_done(struct connectdata *conn, CURLcode status,
/* Send any post-transfer QUOTE strings? */
if(!status && !result && !premature && data->set.postquote)
result = ftp_sendquote(conn, data->set.postquote);
-
+ Curl_safefree(ftp->pathalloc);
return result;
}
@@ -3426,7 +3383,7 @@ CURLcode ftp_sendquote(struct connectdata *conn, struct curl_slist *quote)
PPSENDF(&conn->proto.ftpc.pp, "%s", cmd);
- pp->response = Curl_tvnow(); /* timeout relative now */
+ pp->response = Curl_now(); /* timeout relative now */
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
if(result)
@@ -3507,61 +3464,6 @@ ftp_pasv_verbose(struct connectdata *conn,
#endif
/*
- Check if this is a range download, and if so, set the internal variables
- properly.
- */
-
-static CURLcode ftp_range(struct connectdata *conn)
-{
- curl_off_t from, to;
- char *ptr;
- char *ptr2;
- struct Curl_easy *data = conn->data;
- struct ftp_conn *ftpc = &conn->proto.ftpc;
-
- if(data->state.use_range && data->state.range) {
- from=curlx_strtoofft(data->state.range, &ptr, 0);
- while(*ptr && (ISSPACE(*ptr) || (*ptr=='-')))
- ptr++;
- to=curlx_strtoofft(ptr, &ptr2, 0);
- if(ptr == ptr2) {
- /* we didn't get any digit */
- to=-1;
- }
- if((-1 == to) && (from>=0)) {
- /* X - */
- data->state.resume_from = from;
- DEBUGF(infof(conn->data, "FTP RANGE %" CURL_FORMAT_CURL_OFF_T
- " to end of file\n", from));
- }
- else if(from < 0) {
- /* -Y */
- data->req.maxdownload = -from;
- data->state.resume_from = from;
- DEBUGF(infof(conn->data, "FTP RANGE the last %" CURL_FORMAT_CURL_OFF_T
- " bytes\n", -from));
- }
- else {
- /* X-Y */
- data->req.maxdownload = (to-from)+1; /* include last byte */
- data->state.resume_from = from;
- DEBUGF(infof(conn->data, "FTP RANGE from %" CURL_FORMAT_CURL_OFF_T
- " getting %" CURL_FORMAT_CURL_OFF_T " bytes\n",
- from, data->req.maxdownload));
- }
- DEBUGF(infof(conn->data, "range-download from %" CURL_FORMAT_CURL_OFF_T
- " to %" CURL_FORMAT_CURL_OFF_T ", totally %"
- CURL_FORMAT_CURL_OFF_T " bytes\n",
- from, to, data->req.maxdownload));
- ftpc->dont_check = TRUE; /* don't check for successful transfer */
- }
- else
- data->req.maxdownload = -1;
- return CURLE_OK;
-}
-
-
-/*
* ftp_do_more()
*
* This function shall be called when the second FTP (data) connection is
@@ -3574,7 +3476,7 @@ static CURLcode ftp_range(struct connectdata *conn)
static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
{
- struct Curl_easy *data=conn->data;
+ struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
CURLcode result = CURLE_OK;
bool connected = FALSE;
@@ -3585,9 +3487,9 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
/* if the second connection isn't done yet, wait for it */
if(!conn->bits.tcpconnect[SECONDARYSOCKET]) {
- if(conn->tunnel_state[SECONDARYSOCKET] == TUNNEL_CONNECT) {
+ if(Curl_connect_ongoing(conn)) {
/* As we're in TUNNEL_CONNECT state now, we know the proxy name and port
- aren't used so we blank their arguments. TODO: make this nicer */
+ aren't used so we blank their arguments. */
result = Curl_proxyCONNECT(conn, SECONDARYSOCKET, NULL, 0);
return result;
@@ -3617,7 +3519,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
return result;
if(conn->bits.tunnel_proxy && conn->bits.httpproxy &&
- conn->tunnel_state[SECONDARYSOCKET] != TUNNEL_COMPLETE)
+ Curl_connect_ongoing(conn))
return result;
@@ -3683,7 +3585,13 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
/* download */
ftp->downloadsize = -1; /* unknown as of yet */
- result = ftp_range(conn);
+ result = Curl_range(conn);
+
+ if(result == CURLE_OK && data->req.maxdownload >= 0) {
+ /* Don't check for successful transfer */
+ ftpc->dont_check = TRUE;
+ }
+
if(result)
;
else if(data->set.ftp_list_only || !ftpc->file) {
@@ -3714,7 +3622,7 @@ static CURLcode ftp_do_more(struct connectdata *conn, int *completep)
if(!result && (ftp->transfer != FTPTRANSFER_BODY))
/* no data to transfer. FIX: it feels like a kludge to have this here
too! */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
if(!ftpc->wait_data_conn) {
/* no waiting for the data connection so this is now complete */
@@ -3741,7 +3649,7 @@ CURLcode ftp_perform(struct connectdata *conn,
bool *dophase_done)
{
/* this is FTP and no proxy */
- CURLcode result=CURLE_OK;
+ CURLcode result = CURLE_OK;
DEBUGF(infof(conn->data, "DO phase starts\n"));
@@ -3774,21 +3682,22 @@ CURLcode ftp_perform(struct connectdata *conn,
static void wc_data_dtor(void *ptr)
{
- struct ftp_wc_tmpdata *tmp = ptr;
- if(tmp)
- Curl_ftp_parselist_data_free(&tmp->parser);
- free(tmp);
+ struct ftp_wc *ftpwc = ptr;
+ if(ftpwc && ftpwc->parser)
+ Curl_ftp_parselist_data_free(&ftpwc->parser);
+ free(ftpwc);
}
static CURLcode init_wc_data(struct connectdata *conn)
{
char *last_slash;
- char *path = conn->data->state.path;
+ struct FTP *ftp = conn->data->req.protop;
+ char *path = ftp->path;
struct WildcardData *wildcard = &(conn->data->wildcard);
CURLcode result = CURLE_OK;
- struct ftp_wc_tmpdata *ftp_tmp;
+ struct ftp_wc *ftpwc = NULL;
- last_slash = strrchr(conn->data->state.path, '/');
+ last_slash = strrchr(ftp->path, '/');
if(last_slash) {
last_slash++;
if(last_slash[0] == '\0') {
@@ -3818,23 +3727,22 @@ static CURLcode init_wc_data(struct connectdata *conn)
/* program continues only if URL is not ending with slash, allocate needed
resources for wildcard transfer */
- /* allocate ftp protocol specific temporary wildcard data */
- ftp_tmp = calloc(1, sizeof(struct ftp_wc_tmpdata));
- if(!ftp_tmp) {
- Curl_safefree(wildcard->pattern);
- return CURLE_OUT_OF_MEMORY;
+ /* allocate ftp protocol specific wildcard data */
+ ftpwc = calloc(1, sizeof(struct ftp_wc));
+ if(!ftpwc) {
+ result = CURLE_OUT_OF_MEMORY;
+ goto fail;
}
/* INITIALIZE parselist structure */
- ftp_tmp->parser = Curl_ftp_parselist_data_alloc();
- if(!ftp_tmp->parser) {
- Curl_safefree(wildcard->pattern);
- free(ftp_tmp);
- return CURLE_OUT_OF_MEMORY;
+ ftpwc->parser = Curl_ftp_parselist_data_alloc();
+ if(!ftpwc->parser) {
+ result = CURLE_OUT_OF_MEMORY;
+ goto fail;
}
- wildcard->tmp = ftp_tmp; /* put it to the WildcardData tmp pointer */
- wildcard->tmp_dtor = wc_data_dtor;
+ wildcard->protdata = ftpwc; /* put it to the WildcardData tmp pointer */
+ wildcard->dtor = wc_data_dtor;
/* wildcard does not support NOCWD option (assert it?) */
if(conn->data->set.ftp_filemethod == FTPFILE_NOCWD)
@@ -3843,33 +3751,36 @@ static CURLcode init_wc_data(struct connectdata *conn)
/* try to parse ftp url */
result = ftp_parse_url_path(conn);
if(result) {
- Curl_safefree(wildcard->pattern);
- wildcard->tmp_dtor(wildcard->tmp);
- wildcard->tmp_dtor = ZERO_NULL;
- wildcard->tmp = NULL;
- return result;
+ goto fail;
}
- wildcard->path = strdup(conn->data->state.path);
+ wildcard->path = strdup(ftp->path);
if(!wildcard->path) {
- Curl_safefree(wildcard->pattern);
- wildcard->tmp_dtor(wildcard->tmp);
- wildcard->tmp_dtor = ZERO_NULL;
- wildcard->tmp = NULL;
- return CURLE_OUT_OF_MEMORY;
+ result = CURLE_OUT_OF_MEMORY;
+ goto fail;
}
/* backup old write_function */
- ftp_tmp->backup.write_function = conn->data->set.fwrite_func;
+ ftpwc->backup.write_function = conn->data->set.fwrite_func;
/* parsing write function */
conn->data->set.fwrite_func = Curl_ftp_parselist;
/* backup old file descriptor */
- ftp_tmp->backup.file_descriptor = conn->data->set.out;
+ ftpwc->backup.file_descriptor = conn->data->set.out;
/* let the writefunc callback know what curl pointer is working with */
conn->data->set.out = conn;
infof(conn->data, "Wildcard - Parsing started\n");
return CURLE_OK;
+
+ fail:
+ if(ftpwc) {
+ Curl_ftp_parselist_data_free(&ftpwc->parser);
+ free(ftpwc);
+ }
+ Curl_safefree(wildcard->pattern);
+ wildcard->dtor = ZERO_NULL;
+ wildcard->protdata = NULL;
+ return result;
}
/* This is called recursively */
@@ -3890,14 +3801,14 @@ static CURLcode wc_statemach(struct connectdata *conn)
case CURLWC_MATCHING: {
/* In this state is LIST response successfully parsed, so lets restore
previous WRITEFUNCTION callback and WRITEDATA pointer */
- struct ftp_wc_tmpdata *ftp_tmp = wildcard->tmp;
- conn->data->set.fwrite_func = ftp_tmp->backup.write_function;
- conn->data->set.out = ftp_tmp->backup.file_descriptor;
- ftp_tmp->backup.write_function = ZERO_NULL;
- ftp_tmp->backup.file_descriptor = NULL;
+ struct ftp_wc *ftpwc = wildcard->protdata;
+ conn->data->set.fwrite_func = ftpwc->backup.write_function;
+ conn->data->set.out = ftpwc->backup.file_descriptor;
+ ftpwc->backup.write_function = ZERO_NULL;
+ ftpwc->backup.file_descriptor = NULL;
wildcard->state = CURLWC_DOWNLOADING;
- if(Curl_ftp_parselist_geterror(ftp_tmp->parser)) {
+ if(Curl_ftp_parselist_geterror(ftpwc->parser)) {
/* error found in LIST parsing */
wildcard->state = CURLWC_CLEAN;
return wc_statemach(conn);
@@ -3914,21 +3825,23 @@ static CURLcode wc_statemach(struct connectdata *conn)
/* filelist has at least one file, lets get first one */
struct ftp_conn *ftpc = &conn->proto.ftpc;
struct curl_fileinfo *finfo = wildcard->filelist.head->ptr;
+ struct FTP *ftp = conn->data->req.protop;
char *tmp_path = aprintf("%s%s", wildcard->path, finfo->filename);
if(!tmp_path)
return CURLE_OUT_OF_MEMORY;
- /* switch default "state.pathbuffer" and tmp_path, good to see
- ftp_parse_url_path function to understand this trick */
- Curl_safefree(conn->data->state.pathbuffer);
- conn->data->state.pathbuffer = tmp_path;
- conn->data->state.path = tmp_path;
+ /* switch default ftp->path and tmp_path */
+ free(ftp->pathalloc);
+ ftp->pathalloc = ftp->path = tmp_path;
infof(conn->data, "Wildcard - START of \"%s\"\n", finfo->filename);
if(conn->data->set.chunk_bgn) {
- long userresponse = conn->data->set.chunk_bgn(
+ long userresponse;
+ Curl_set_in_callback(conn->data, true);
+ userresponse = conn->data->set.chunk_bgn(
finfo, wildcard->customptr, (int)wildcard->filelist.size);
+ Curl_set_in_callback(conn->data, false);
switch(userresponse) {
case CURL_CHUNK_BGN_FUNC_SKIP:
infof(conn->data, "Wildcard - \"%s\" skipped by user\n",
@@ -3964,8 +3877,11 @@ static CURLcode wc_statemach(struct connectdata *conn)
} break;
case CURLWC_SKIP: {
- if(conn->data->set.chunk_end)
+ if(conn->data->set.chunk_end) {
+ Curl_set_in_callback(conn->data, true);
conn->data->set.chunk_end(conn->data->wildcard.customptr);
+ Curl_set_in_callback(conn->data, false);
+ }
Curl_llist_remove(&wildcard->filelist, wildcard->filelist.head, NULL);
wildcard->state = (wildcard->filelist.size == 0) ?
CURLWC_CLEAN : CURLWC_DOWNLOADING;
@@ -3973,10 +3889,10 @@ static CURLcode wc_statemach(struct connectdata *conn)
}
case CURLWC_CLEAN: {
- struct ftp_wc_tmpdata *ftp_tmp = wildcard->tmp;
+ struct ftp_wc *ftpwc = wildcard->protdata;
result = CURLE_OK;
- if(ftp_tmp)
- result = Curl_ftp_parselist_geterror(ftp_tmp->parser);
+ if(ftpwc)
+ result = Curl_ftp_parselist_geterror(ftpwc->parser);
wildcard->state = result ? CURLWC_ERROR : CURLWC_DONE;
} break;
@@ -3984,6 +3900,8 @@ static CURLcode wc_statemach(struct connectdata *conn)
case CURLWC_DONE:
case CURLWC_ERROR:
case CURLWC_CLEAR:
+ if(wildcard->dtor)
+ wildcard->dtor(wildcard->protdata);
break;
}
@@ -4007,7 +3925,7 @@ static CURLcode ftp_do(struct connectdata *conn, bool *done)
*done = FALSE; /* default to false */
ftpc->wait_data_conn = FALSE; /* default to no such wait */
- if(conn->data->set.wildcardmatch) {
+ if(conn->data->state.wildcardmatch) {
result = wc_statemach(conn);
if(conn->data->wildcard.state == CURLWC_SKIP ||
conn->data->wildcard.state == CURLWC_DONE) {
@@ -4035,20 +3953,23 @@ CURLcode Curl_ftpsend(struct connectdata *conn, const char *cmd)
#define SBUF_SIZE 1024
char s[SBUF_SIZE];
size_t write_len;
- char *sptr=s;
+ char *sptr = s;
CURLcode result = CURLE_OK;
#ifdef HAVE_GSSAPI
enum protection_level data_sec = conn->data_prot;
#endif
+ if(!cmd)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
write_len = strlen(cmd);
- if(write_len > (sizeof(s) -3))
+ if(!write_len || write_len > (sizeof(s) -3))
return CURLE_BAD_FUNCTION_ARGUMENT;
+ memcpy(&s, cmd, write_len);
strcpy(&s[write_len], "\r\n"); /* append a trailing CRLF */
- write_len +=2;
-
- bytes_written=0;
+ write_len += 2;
+ bytes_written = 0;
result = Curl_convert_to_network(conn->data, s, write_len);
/* Curl_convert_to_network calls failf if unsuccessful */
@@ -4070,8 +3991,7 @@ CURLcode Curl_ftpsend(struct connectdata *conn, const char *cmd)
break;
if(conn->data->set.verbose)
- Curl_debug(conn->data, CURLINFO_HEADER_OUT,
- sptr, (size_t)bytes_written, conn);
+ Curl_debug(conn->data, CURLINFO_HEADER_OUT, sptr, (size_t)bytes_written);
if(bytes_written != (ssize_t)write_len) {
write_len -= bytes_written;
@@ -4126,7 +4046,7 @@ static CURLcode ftp_quit(struct connectdata *conn)
*/
static CURLcode ftp_disconnect(struct connectdata *conn, bool dead_connection)
{
- struct ftp_conn *ftpc= &conn->proto.ftpc;
+ struct ftp_conn *ftpc = &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp;
/* We cannot send quit unconditionally. If this connection is stale or
@@ -4181,7 +4101,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
struct FTP *ftp = data->req.protop;
struct ftp_conn *ftpc = &conn->proto.ftpc;
const char *slash_pos; /* position of the first '/' char in curpos */
- const char *path_to_use = data->state.path;
+ const char *path_to_use = ftp->path;
const char *cur_pos;
const char *filename = NULL;
@@ -4222,7 +4142,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
ftpc->dirdepth = 0;
break;
}
- slash_pos=strrchr(cur_pos, '/');
+ slash_pos = strrchr(cur_pos, '/');
if(slash_pos || !*cur_pos) {
size_t dirlen = slash_pos-cur_pos;
CURLcode result;
@@ -4237,13 +4157,13 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
result = Curl_urldecode(conn->data, slash_pos ? cur_pos : "/",
slash_pos ? dirlen : 1,
&ftpc->dirs[0], NULL,
- FALSE);
+ TRUE);
if(result) {
freedirs(ftpc);
return result;
}
ftpc->dirdepth = 1; /* we consider it to be a single dir */
- filename = slash_pos ? slash_pos+1 : cur_pos; /* rest is file name */
+ filename = slash_pos ? slash_pos + 1 : cur_pos; /* rest is file name */
}
else
filename = cur_pos; /* this is a file name only */
@@ -4267,7 +4187,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
/* parse the URL path into separate path components */
while((slash_pos = strchr(cur_pos, '/')) != NULL) {
/* 1 or 0 pointer offset to indicate absolute directory */
- ssize_t absolute_dir = ((cur_pos - data->state.path > 0) &&
+ ssize_t absolute_dir = ((cur_pos - ftp->path > 0) &&
(ftpc->dirdepth == 0))?1:0;
/* seek out the next path component */
@@ -4327,8 +4247,8 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
}
}
else
- ftpc->file=NULL; /* instead of point to a zero byte, we make it a NULL
- pointer */
+ ftpc->file = NULL; /* instead of point to a zero byte, we make it a NULL
+ pointer */
if(data->set.upload && !ftpc->file && (ftp->transfer == FTPTRANSFER_BODY)) {
/* We need a file name when uploading. Return error! */
@@ -4344,7 +4264,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
size_t dlen;
char *path;
CURLcode result =
- Curl_urldecode(conn->data, data->state.path, 0, &path, &dlen, FALSE);
+ Curl_urldecode(conn->data, ftp->path, 0, &path, &dlen, TRUE);
if(result) {
freedirs(ftpc);
return result;
@@ -4352,7 +4272,8 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
dlen -= ftpc->file?strlen(ftpc->file):0;
if((dlen == strlen(ftpc->prevpath)) &&
- !strncmp(path, ftpc->prevpath, dlen)) {
+ !strncmp(path, ftpc->prevpath, dlen) &&
+ (ftpc->prevmethod == data->set.ftp_filemethod)) {
infof(data, "Request has same path as previous transfer\n");
ftpc->cwddone = TRUE;
}
@@ -4381,7 +4302,7 @@ static CURLcode ftp_dophase_done(struct connectdata *conn,
if(ftp->transfer != FTPTRANSFER_BODY)
/* no data to transfer */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(conn->data, -1, -1, FALSE, -1);
else if(!connected)
/* since we didn't connect now, we want do_more to get called */
conn->bits.do_more = TRUE;
@@ -4423,8 +4344,8 @@ static
CURLcode ftp_regular_transfer(struct connectdata *conn,
bool *dophase_done)
{
- CURLcode result=CURLE_OK;
- bool connected=FALSE;
+ CURLcode result = CURLE_OK;
+ bool connected = FALSE;
struct Curl_easy *data = conn->data;
struct ftp_conn *ftpc = &conn->proto.ftpc;
data->req.size = -1; /* make sure this is unknown at this point */
@@ -4461,46 +4382,23 @@ static CURLcode ftp_setup_connection(struct connectdata *conn)
{
struct Curl_easy *data = conn->data;
char *type;
- char command;
struct FTP *ftp;
- if(conn->bits.httpproxy && !data->set.tunnel_thru_httpproxy) {
- /* Unless we have asked to tunnel ftp operations through the proxy, we
- switch and use HTTP operations only */
-#ifndef CURL_DISABLE_HTTP
- if(conn->handler == &Curl_handler_ftp)
- conn->handler = &Curl_handler_ftp_proxy;
- else {
-#ifdef USE_SSL
- conn->handler = &Curl_handler_ftps_proxy;
-#else
- failf(data, "FTPS not supported!");
- return CURLE_UNSUPPORTED_PROTOCOL;
-#endif
- }
- /* set it up as a HTTP connection instead */
- return conn->handler->setup_connection(conn);
-#else
- failf(data, "FTP over http proxy requires HTTP support built-in!");
- return CURLE_UNSUPPORTED_PROTOCOL;
-#endif
- }
-
- conn->data->req.protop = ftp = malloc(sizeof(struct FTP));
+ conn->data->req.protop = ftp = calloc(sizeof(struct FTP), 1);
if(NULL == ftp)
return CURLE_OUT_OF_MEMORY;
- data->state.path++; /* don't include the initial slash */
- data->state.slash_removed = TRUE; /* we've skipped the slash */
+ ftp->path = &data->state.up.path[1]; /* don't include the initial slash */
/* FTP URLs support an extension like ";type=<typecode>" that
* we'll try to get now! */
- type = strstr(data->state.path, ";type=");
+ type = strstr(ftp->path, ";type=");
if(!type)
type = strstr(conn->host.rawalloc, ";type=");
if(type) {
+ char command;
*type = 0; /* it was in the middle of the hostname */
command = Curl_raw_toupper(type[6]);
conn->bits.type_set = TRUE;
@@ -4523,7 +4421,6 @@ static CURLcode ftp_setup_connection(struct connectdata *conn)
}
/* get some initial data into the ftp struct */
- ftp->bytecountp = &conn->data->req.bytecount;
ftp->transfer = FTPTRANSFER_BODY;
ftp->downloadsize = 0;
diff --git a/Utilities/cmcurl/lib/ftp.h b/Utilities/cmcurl/lib/ftp.h
index 3bbf26206..828d69a21 100644
--- a/Utilities/cmcurl/lib/ftp.h
+++ b/Utilities/cmcurl/lib/ftp.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -81,7 +81,7 @@ typedef enum {
struct ftp_parselist_data; /* defined later in ftplistparser.c */
-struct ftp_wc_tmpdata {
+struct ftp_wc {
struct ftp_parselist_data *parser;
struct {
@@ -102,9 +102,10 @@ typedef enum {
perhaps the Curl_easy is changed between the times the connection is
used. */
struct FTP {
- curl_off_t *bytecountp;
char *user; /* user name string */
char *passwd; /* password string */
+ char *path; /* points to the urlpieces struct field */
+ char *pathalloc; /* if non-NULL a pointer to an allocated path */
/* transfer a file/body or not, done as a typedefed enum just to make
debuggers display the full symbol and not just the numerical value */
@@ -130,10 +131,12 @@ struct ftp_conn {
should be FALSE when it gets to Curl_ftp_quit() */
bool cwddone; /* if it has been determined that the proper CWD combo
already has been done */
+ int cwdcount; /* number of CWD commands issued */
bool cwdfail; /* set TRUE if a CWD command fails, as then we must prevent
caching the current directory */
bool wait_data_conn; /* this is set TRUE if data connection is waited */
char *prevpath; /* conn->path from the previous transfer */
+ curl_ftpfile prevmethod; /* ftp method in previous transfer */
char transfertype; /* set by ftp_transfertype for use by Curl_client_write()a
and others (A/I or zero) */
int count1; /* general purpose counter for the state machine */
diff --git a/Utilities/cmcurl/lib/ftplistparser.c b/Utilities/cmcurl/lib/ftplistparser.c
index 2acce31d8..c4eb43732 100644
--- a/Utilities/cmcurl/lib/ftplistparser.c
+++ b/Utilities/cmcurl/lib/ftplistparser.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -49,6 +49,7 @@
#include "ftplistparser.h"
#include "curl_fnmatch.h"
#include "curl_memory.h"
+#include "multiif.h"
/* The last #include file should be: */
#include "memdebug.h"
@@ -184,10 +185,13 @@ struct ftp_parselist_data *Curl_ftp_parselist_data_alloc(void)
}
-void Curl_ftp_parselist_data_free(struct ftp_parselist_data **pl_data)
+void Curl_ftp_parselist_data_free(struct ftp_parselist_data **parserp)
{
- free(*pl_data);
- *pl_data = NULL;
+ struct ftp_parselist_data *parser = *parserp;
+ if(parser)
+ Curl_fileinfo_cleanup(parser->file_data);
+ free(parser);
+ *parserp = NULL;
}
@@ -264,24 +268,14 @@ static int ftp_pl_get_permission(const char *str)
return permissions;
}
-static void PL_ERROR(struct connectdata *conn, CURLcode err)
-{
- struct ftp_wc_tmpdata *tmpdata = conn->data->wildcard.tmp;
- struct ftp_parselist_data *parser = tmpdata->parser;
- if(parser->file_data)
- Curl_fileinfo_dtor(NULL, parser->file_data);
- parser->file_data = NULL;
- parser->error = err;
-}
-
static CURLcode ftp_pl_insert_finfo(struct connectdata *conn,
struct fileinfo *infop)
{
curl_fnmatch_callback compare;
struct WildcardData *wc = &conn->data->wildcard;
- struct ftp_wc_tmpdata *tmpdata = wc->tmp;
+ struct ftp_wc *ftpwc = wc->protdata;
struct curl_llist *llist = &wc->filelist;
- struct ftp_parselist_data *parser = tmpdata->parser;
+ struct ftp_parselist_data *parser = ftpwc->parser;
bool add = TRUE;
struct curl_fileinfo *finfo = &infop->info;
@@ -304,6 +298,7 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn,
compare = Curl_fnmatch;
/* filter pattern-corresponding filenames */
+ Curl_set_in_callback(conn->data, true);
if(compare(conn->data->set.fnmatch_data, wc->pattern,
finfo->filename) == 0) {
/* discard symlink which is containing multiple " -> " */
@@ -315,15 +310,16 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn,
else {
add = FALSE;
}
+ Curl_set_in_callback(conn->data, false);
if(add) {
Curl_llist_insert_next(llist, llist->tail, finfo, &infop->list);
}
else {
- Curl_fileinfo_dtor(NULL, finfo);
+ Curl_fileinfo_cleanup(infop);
}
- tmpdata->parser->file_data = NULL;
+ ftpwc->parser->file_data = NULL;
return CURLE_OK;
}
@@ -332,12 +328,13 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
{
size_t bufflen = size*nmemb;
struct connectdata *conn = (struct connectdata *)connptr;
- struct ftp_wc_tmpdata *tmpdata = conn->data->wildcard.tmp;
- struct ftp_parselist_data *parser = tmpdata->parser;
+ struct ftp_wc *ftpwc = conn->data->wildcard.protdata;
+ struct ftp_parselist_data *parser = ftpwc->parser;
struct fileinfo *infop;
struct curl_fileinfo *finfo;
unsigned long i = 0;
CURLcode result;
+ size_t retsize = bufflen;
if(parser->error) { /* error in previous call */
/* scenario:
@@ -346,7 +343,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
* 3. (last) call => is skipped RIGHT HERE and the error is hadled later
* in wc_statemach()
*/
- return bufflen;
+ goto fail;
}
if(parser->os_type == OS_TYPE_UNKNOWN && bufflen > 0) {
@@ -362,12 +359,12 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->file_data = Curl_fileinfo_alloc();
if(!parser->file_data) {
parser->error = CURLE_OUT_OF_MEMORY;
- return bufflen;
+ goto fail;
}
parser->file_data->info.b_data = malloc(FTP_BUFFER_ALLOCSIZE);
if(!parser->file_data->info.b_data) {
- PL_ERROR(conn, CURLE_OUT_OF_MEMORY);
- return bufflen;
+ parser->error = CURLE_OUT_OF_MEMORY;
+ goto fail;
}
parser->file_data->info.b_size = FTP_BUFFER_ALLOCSIZE;
parser->item_offset = 0;
@@ -387,11 +384,10 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
finfo->b_data = tmp;
}
else {
- Curl_fileinfo_dtor(NULL, parser->file_data);
+ Curl_fileinfo_cleanup(parser->file_data);
parser->file_data = NULL;
parser->error = CURLE_OUT_OF_MEMORY;
- PL_ERROR(conn, CURLE_OUT_OF_MEMORY);
- return bufflen;
+ goto fail;
}
}
@@ -409,7 +405,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.main = PL_UNIX_FILETYPE;
/* start FSM again not considering size of directory */
finfo->b_used = 0;
- i--;
+ continue;
}
break;
case PL_UNIX_TOTALSIZE_READING:
@@ -421,7 +417,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
else if(c == '\n') {
finfo->b_data[parser->item_length - 1] = 0;
if(strncmp("total ", finfo->b_data, 6) == 0) {
- char *endptr = finfo->b_data+6;
+ char *endptr = finfo->b_data + 6;
/* here we can deal with directory size, pass the leading white
spaces and then the digits */
while(ISSPACE(*endptr))
@@ -429,15 +425,15 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
while(ISDIGIT(*endptr))
endptr++;
if(*endptr != 0) {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
parser->state.UNIX.main = PL_UNIX_FILETYPE;
finfo->b_used = 0;
}
else {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
}
break;
@@ -470,8 +466,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
finfo->filetype = CURLFILETYPE_DOOR;
break;
default:
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
parser->state.UNIX.main = PL_UNIX_PERMISSION;
parser->item_length = 0;
@@ -481,21 +477,21 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->item_length++;
if(parser->item_length <= 9) {
if(!strchr("rwx-tTsS", c)) {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
}
else if(parser->item_length == 10) {
unsigned int perm;
if(c != ' ') {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
finfo->b_data[10] = 0; /* terminate permissions */
perm = ftp_pl_get_permission(finfo->b_data + parser->item_offset);
if(perm & FTP_LP_MALFORMATED_PERM) {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
parser->file_data->info.flags |= CURLFINFOFLAG_KNOWN_PERM;
parser->file_data->info.perm = perm;
@@ -516,8 +512,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.sub.hlinks = PL_UNIX_HLINKS_NUMBER;
}
else {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
}
break;
@@ -538,8 +534,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.sub.user = PL_UNIX_USER_PRESPACE;
}
else if(c < '0' || c > '9') {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
break;
}
@@ -598,8 +594,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.sub.size = PL_UNIX_SIZE_NUMBER;
}
else {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
}
break;
@@ -609,20 +605,22 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
char *p;
curl_off_t fsize;
finfo->b_data[parser->item_offset + parser->item_length - 1] = 0;
- fsize = curlx_strtoofft(finfo->b_data+parser->item_offset, &p, 10);
- if(p[0] == '\0' && fsize != CURL_OFF_T_MAX &&
- fsize != CURL_OFF_T_MIN) {
- parser->file_data->info.flags |= CURLFINFOFLAG_KNOWN_SIZE;
- parser->file_data->info.size = fsize;
+ if(!curlx_strtoofft(finfo->b_data + parser->item_offset,
+ &p, 10, &fsize)) {
+ if(p[0] == '\0' && fsize != CURL_OFF_T_MAX &&
+ fsize != CURL_OFF_T_MIN) {
+ parser->file_data->info.flags |= CURLFINFOFLAG_KNOWN_SIZE;
+ parser->file_data->info.size = fsize;
+ }
+ parser->item_length = 0;
+ parser->item_offset = 0;
+ parser->state.UNIX.main = PL_UNIX_TIME;
+ parser->state.UNIX.sub.time = PL_UNIX_TIME_PREPART1;
}
- parser->item_length = 0;
- parser->item_offset = 0;
- parser->state.UNIX.main = PL_UNIX_TIME;
- parser->state.UNIX.sub.time = PL_UNIX_TIME_PREPART1;
}
else if(!ISDIGIT(c)) {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
break;
}
@@ -637,8 +635,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.sub.time = PL_UNIX_TIME_PART1;
}
else {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
}
break;
@@ -648,8 +646,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.sub.time = PL_UNIX_TIME_PREPART2;
}
else if(!ISALNUM(c) && c != '.') {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
break;
case PL_UNIX_TIME_PREPART2:
@@ -659,8 +657,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.sub.time = PL_UNIX_TIME_PART2;
}
else {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
}
break;
@@ -670,8 +668,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.sub.time = PL_UNIX_TIME_PREPART3;
}
else if(!ISALNUM(c) && c != '.') {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
break;
case PL_UNIX_TIME_PREPART3:
@@ -681,8 +679,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.sub.time = PL_UNIX_TIME_PART3;
}
else {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
}
break;
@@ -706,8 +704,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
}
}
else if(!ISALNUM(c) && c != '.' && c != ':') {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
break;
}
@@ -732,8 +730,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.main = PL_UNIX_FILETYPE;
result = ftp_pl_insert_finfo(conn, infop);
if(result) {
- PL_ERROR(conn, result);
- return bufflen;
+ parser->error = result;
+ goto fail;
}
}
break;
@@ -744,13 +742,13 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.main = PL_UNIX_FILETYPE;
result = ftp_pl_insert_finfo(conn, infop);
if(result) {
- PL_ERROR(conn, result);
- return bufflen;
+ parser->error = result;
+ goto fail;
}
}
else {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
break;
}
@@ -770,8 +768,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.sub.symlink = PL_UNIX_SYMLINK_PRETARGET1;
}
else if(c == '\r' || c == '\n') {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
break;
case PL_UNIX_SYMLINK_PRETARGET1:
@@ -780,8 +778,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.sub.symlink = PL_UNIX_SYMLINK_PRETARGET2;
}
else if(c == '\r' || c == '\n') {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
else {
parser->state.UNIX.sub.symlink = PL_UNIX_SYMLINK_NAME;
@@ -793,8 +791,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.UNIX.sub.symlink = PL_UNIX_SYMLINK_PRETARGET3;
}
else if(c == '\r' || c == '\n') {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
else {
parser->state.UNIX.sub.symlink = PL_UNIX_SYMLINK_NAME;
@@ -811,8 +809,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->item_offset = 0;
}
else if(c == '\r' || c == '\n') {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
else {
parser->state.UNIX.sub.symlink = PL_UNIX_SYMLINK_NAME;
@@ -825,8 +823,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->item_length = 1;
}
else {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
break;
case PL_UNIX_SYMLINK_TARGET:
@@ -839,8 +837,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->offsets.symlink_target = parser->item_offset;
result = ftp_pl_insert_finfo(conn, infop);
if(result) {
- PL_ERROR(conn, result);
- return bufflen;
+ parser->error = result;
+ goto fail;
}
parser->state.UNIX.main = PL_UNIX_FILETYPE;
}
@@ -851,14 +849,14 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->offsets.symlink_target = parser->item_offset;
result = ftp_pl_insert_finfo(conn, infop);
if(result) {
- PL_ERROR(conn, result);
- return bufflen;
+ parser->error = result;
+ goto fail;
}
parser->state.UNIX.main = PL_UNIX_FILETYPE;
}
else {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
break;
}
@@ -871,8 +869,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->item_length++;
if(parser->item_length < 9) {
if(!strchr("0123456789-", c)) { /* only simple control */
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
}
else if(parser->item_length == 9) {
@@ -881,13 +879,13 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->state.NT.sub.time = PL_WINNT_TIME_PRESPACE;
}
else {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
}
else {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
break;
case PL_WINNT_TIME:
@@ -907,8 +905,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->item_length = 0;
}
else if(!strchr("APM0123456789:", c)) {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
break;
}
@@ -916,10 +914,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
case PL_WINNT_DIRORSIZE:
switch(parser->state.NT.sub.dirorsize) {
case PL_WINNT_DIRORSIZE_PRESPACE:
- if(c == ' ') {
-
- }
- else {
+ if(c != ' ') {
parser->item_offset = finfo->b_used - 1;
parser->item_length = 1;
parser->state.NT.sub.dirorsize = PL_WINNT_DIRORSIZE_CONTENT;
@@ -935,21 +930,11 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
}
else {
char *endptr;
- finfo->size = curlx_strtoofft(finfo->b_data +
- parser->item_offset,
- &endptr, 10);
- if(!*endptr) {
- if(finfo->size == CURL_OFF_T_MAX ||
- finfo->size == CURL_OFF_T_MIN) {
- if(errno == ERANGE) {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
- }
- }
- }
- else {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ if(curlx_strtoofft(finfo->b_data +
+ parser->item_offset,
+ &endptr, 10, &finfo->size)) {
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
/* correct file type */
parser->file_data->info.filetype = CURLFILETYPE_FILE;
@@ -984,8 +969,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->offsets.filename = parser->item_offset;
result = ftp_pl_insert_finfo(conn, infop);
if(result) {
- PL_ERROR(conn, result);
- return bufflen;
+ parser->error = result;
+ goto fail;
}
parser->state.NT.main = PL_WINNT_DATE;
parser->state.NT.sub.filename = PL_WINNT_FILENAME_PRESPACE;
@@ -996,15 +981,15 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
parser->offsets.filename = parser->item_offset;
result = ftp_pl_insert_finfo(conn, infop);
if(result) {
- PL_ERROR(conn, result);
- return bufflen;
+ parser->error = result;
+ goto fail;
}
parser->state.NT.main = PL_WINNT_DATE;
parser->state.NT.sub.filename = PL_WINNT_FILENAME_PRESPACE;
}
else {
- PL_ERROR(conn, CURLE_FTP_BAD_FILE_LIST);
- return bufflen;
+ parser->error = CURLE_FTP_BAD_FILE_LIST;
+ goto fail;
}
break;
}
@@ -1012,13 +997,23 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb,
}
break;
default:
- return bufflen + 1;
+ retsize = bufflen + 1;
+ goto fail;
}
i++;
}
+ return retsize;
+
+fail:
+
+ /* Clean up any allocated memory. */
+ if(parser->file_data) {
+ Curl_fileinfo_cleanup(parser->file_data);
+ parser->file_data = NULL;
+ }
- return bufflen;
+ return retsize;
}
#endif /* CURL_DISABLE_FTP */
diff --git a/Utilities/cmcurl/lib/getinfo.c b/Utilities/cmcurl/lib/getinfo.c
index a1ce5058e..e118da80d 100644
--- a/Utilities/cmcurl/lib/getinfo.c
+++ b/Utilities/cmcurl/lib/getinfo.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -54,6 +54,7 @@ CURLcode Curl_initinfo(struct Curl_easy *data)
pro->t_starttransfer = 0;
pro->timespent = 0;
pro->t_redirect = 0;
+ pro->is_t_startransfer_set = false;
info->httpcode = 0;
info->httpproxycode = 0;
@@ -84,7 +85,6 @@ CURLcode Curl_initinfo(struct Curl_easy *data)
#ifdef USE_SSL
Curl_ssl_free_certinfo(data);
#endif
-
return CURLE_OK;
}
@@ -155,13 +155,18 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
*param_longp = data->info.httpproxycode;
break;
case CURLINFO_FILETIME:
- *param_longp = data->info.filetime;
+ if(data->info.filetime > LONG_MAX)
+ *param_longp = LONG_MAX;
+ else if(data->info.filetime < LONG_MIN)
+ *param_longp = LONG_MIN;
+ else
+ *param_longp = (long)data->info.filetime;
break;
case CURLINFO_HEADER_SIZE:
- *param_longp = data->info.header_size;
+ *param_longp = (long)data->info.header_size;
break;
case CURLINFO_REQUEST_SIZE:
- *param_longp = data->info.request_size;
+ *param_longp = (long)data->info.request_size;
break;
case CURLINFO_SSL_VERIFYRESULT:
*param_longp = data->set.ssl.certverifyresult;
@@ -246,27 +251,85 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
return CURLE_OK;
}
+#define DOUBLE_SECS(x) (double)(x)/1000000
+
+static CURLcode getinfo_offt(struct Curl_easy *data, CURLINFO info,
+ curl_off_t *param_offt)
+{
+ switch(info) {
+ case CURLINFO_FILETIME_T:
+ *param_offt = (curl_off_t)data->info.filetime;
+ break;
+ case CURLINFO_SIZE_UPLOAD_T:
+ *param_offt = data->progress.uploaded;
+ break;
+ case CURLINFO_SIZE_DOWNLOAD_T:
+ *param_offt = data->progress.downloaded;
+ break;
+ case CURLINFO_SPEED_DOWNLOAD_T:
+ *param_offt = data->progress.dlspeed;
+ break;
+ case CURLINFO_SPEED_UPLOAD_T:
+ *param_offt = data->progress.ulspeed;
+ break;
+ case CURLINFO_CONTENT_LENGTH_DOWNLOAD_T:
+ *param_offt = (data->progress.flags & PGRS_DL_SIZE_KNOWN)?
+ data->progress.size_dl:-1;
+ break;
+ case CURLINFO_CONTENT_LENGTH_UPLOAD_T:
+ *param_offt = (data->progress.flags & PGRS_UL_SIZE_KNOWN)?
+ data->progress.size_ul:-1;
+ break;
+ case CURLINFO_TOTAL_TIME_T:
+ *param_offt = data->progress.timespent;
+ break;
+ case CURLINFO_NAMELOOKUP_TIME_T:
+ *param_offt = data->progress.t_nslookup;
+ break;
+ case CURLINFO_CONNECT_TIME_T:
+ *param_offt = data->progress.t_connect;
+ break;
+ case CURLINFO_APPCONNECT_TIME_T:
+ *param_offt = data->progress.t_appconnect;
+ break;
+ case CURLINFO_PRETRANSFER_TIME_T:
+ *param_offt = data->progress.t_pretransfer;
+ break;
+ case CURLINFO_STARTTRANSFER_TIME_T:
+ *param_offt = data->progress.t_starttransfer;
+ break;
+ case CURLINFO_REDIRECT_TIME_T:
+ *param_offt = data->progress.t_redirect;
+ break;
+
+ default:
+ return CURLE_UNKNOWN_OPTION;
+ }
+
+ return CURLE_OK;
+}
+
static CURLcode getinfo_double(struct Curl_easy *data, CURLINFO info,
double *param_doublep)
{
switch(info) {
case CURLINFO_TOTAL_TIME:
- *param_doublep = data->progress.timespent;
+ *param_doublep = DOUBLE_SECS(data->progress.timespent);
break;
case CURLINFO_NAMELOOKUP_TIME:
- *param_doublep = data->progress.t_nslookup;
+ *param_doublep = DOUBLE_SECS(data->progress.t_nslookup);
break;
case CURLINFO_CONNECT_TIME:
- *param_doublep = data->progress.t_connect;
+ *param_doublep = DOUBLE_SECS(data->progress.t_connect);
break;
case CURLINFO_APPCONNECT_TIME:
- *param_doublep = data->progress.t_appconnect;
+ *param_doublep = DOUBLE_SECS(data->progress.t_appconnect);
break;
case CURLINFO_PRETRANSFER_TIME:
- *param_doublep = data->progress.t_pretransfer;
+ *param_doublep = DOUBLE_SECS(data->progress.t_pretransfer);
break;
case CURLINFO_STARTTRANSFER_TIME:
- *param_doublep = data->progress.t_starttransfer;
+ *param_doublep = DOUBLE_SECS(data->progress.t_starttransfer);
break;
case CURLINFO_SIZE_UPLOAD:
*param_doublep = (double)data->progress.uploaded;
@@ -289,7 +352,7 @@ static CURLcode getinfo_double(struct Curl_easy *data, CURLINFO info,
(double)data->progress.size_ul:-1;
break;
case CURLINFO_REDIRECT_TIME:
- *param_doublep = data->progress.t_redirect;
+ *param_doublep = DOUBLE_SECS(data->progress.t_redirect);
break;
default:
@@ -326,46 +389,25 @@ static CURLcode getinfo_slist(struct Curl_easy *data, CURLINFO info,
struct curl_tlssessioninfo **tsip = (struct curl_tlssessioninfo **)
param_slistp;
struct curl_tlssessioninfo *tsi = &data->tsi;
- struct connectdata *conn = data->easy_conn;
+#ifdef USE_SSL
+ struct connectdata *conn = data->conn;
+#endif
*tsip = tsi;
tsi->backend = Curl_ssl_backend();
tsi->internals = NULL;
+#ifdef USE_SSL
if(conn && tsi->backend != CURLSSLBACKEND_NONE) {
unsigned int i;
for(i = 0; i < (sizeof(conn->ssl) / sizeof(conn->ssl[0])); ++i) {
if(conn->ssl[i].use) {
-#if defined(USE_AXTLS)
- tsi->internals = (void *)conn->ssl[i].ssl;
-#elif defined(USE_CYASSL)
- tsi->internals = (void *)conn->ssl[i].handle;
-#elif defined(USE_DARWINSSL)
- tsi->internals = (void *)conn->ssl[i].ssl_ctx;
-#elif defined(USE_GNUTLS)
- tsi->internals = (void *)conn->ssl[i].session;
-#elif defined(USE_GSKIT)
- tsi->internals = (void *)conn->ssl[i].handle;
-#elif defined(USE_MBEDTLS)
- tsi->internals = (void *)&conn->ssl[i].ssl;
-#elif defined(USE_NSS)
- tsi->internals = (void *)conn->ssl[i].handle;
-#elif defined(USE_OPENSSL)
- /* Legacy: CURLINFO_TLS_SESSION must return an SSL_CTX pointer. */
- tsi->internals = ((info == CURLINFO_TLS_SESSION) ?
- (void *)conn->ssl[i].ctx :
- (void *)conn->ssl[i].handle);
-#elif defined(USE_POLARSSL)
- tsi->internals = (void *)&conn->ssl[i].ssl;
-#elif defined(USE_SCHANNEL)
- tsi->internals = (void *)&conn->ssl[i].ctxt->ctxt_handle;
-#elif defined(USE_SSL)
-#error "SSL backend specific information missing for CURLINFO_TLS_SSL_PTR"
-#endif
+ tsi->internals = Curl_ssl->get_internals(&conn->ssl[i], info);
break;
}
}
}
+#endif
}
break;
default:
@@ -394,6 +436,7 @@ CURLcode Curl_getinfo(struct Curl_easy *data, CURLINFO info, ...)
va_list arg;
long *param_longp = NULL;
double *param_doublep = NULL;
+ curl_off_t *param_offt = NULL;
const char **param_charp = NULL;
struct curl_slist **param_slistp = NULL;
curl_socket_t *param_socketp = NULL;
@@ -422,6 +465,11 @@ CURLcode Curl_getinfo(struct Curl_easy *data, CURLINFO info, ...)
if(param_doublep)
result = getinfo_double(data, info, param_doublep);
break;
+ case CURLINFO_OFF_T:
+ param_offt = va_arg(arg, curl_off_t *);
+ if(param_offt)
+ result = getinfo_offt(data, info, param_offt);
+ break;
case CURLINFO_SLIST:
param_slistp = va_arg(arg, struct curl_slist **);
if(param_slistp)
diff --git a/Utilities/cmcurl/lib/gopher.c b/Utilities/cmcurl/lib/gopher.c
index e6d274648..b296c62d1 100644
--- a/Utilities/cmcurl/lib/gopher.c
+++ b/Utilities/cmcurl/lib/gopher.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -31,9 +31,11 @@
#include "progress.h"
#include "gopher.h"
#include "select.h"
+#include "strdup.h"
#include "url.h"
#include "escape.h"
#include "warnless.h"
+#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
@@ -65,6 +67,7 @@ const struct Curl_handler Curl_handler_gopher = {
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_GOPHER, /* defport */
CURLPROTO_GOPHER, /* protocol */
PROTOPT_NONE /* flags */
@@ -72,12 +75,12 @@ const struct Curl_handler Curl_handler_gopher = {
static CURLcode gopher_do(struct connectdata *conn, bool *done)
{
- CURLcode result=CURLE_OK;
- struct Curl_easy *data=conn->data;
+ CURLcode result = CURLE_OK;
+ struct Curl_easy *data = conn->data;
curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
-
- curl_off_t *bytecount = &data->req.bytecount;
- char *path = data->state.path;
+ char *gopherpath;
+ char *path = data->state.up.path;
+ char *query = data->state.up.query;
char *sel = NULL;
char *sel_org = NULL;
ssize_t amount, k;
@@ -85,27 +88,33 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
*done = TRUE; /* unconditionally */
+ /* path is guaranteed non-NULL */
+ DEBUGASSERT(path);
+
+ if(query)
+ gopherpath = aprintf("%s?%s", path, query);
+ else
+ gopherpath = strdup(path);
+
+ if(!gopherpath)
+ return CURLE_OUT_OF_MEMORY;
+
/* Create selector. Degenerate cases: / and /1 => convert to "" */
- if(strlen(path) <= 2) {
+ if(strlen(gopherpath) <= 2) {
sel = (char *)"";
- len = (int)strlen(sel);
+ len = strlen(sel);
+ free(gopherpath);
}
else {
char *newp;
- size_t j, i;
/* Otherwise, drop / and the first character (i.e., item type) ... */
- newp = path;
- newp+=2;
-
- /* ... then turn ? into TAB for search servers, Veronica, etc. ... */
- j = strlen(newp);
- for(i=0; i<j; i++)
- if(newp[i] == '?')
- newp[i] = '\x09';
+ newp = gopherpath;
+ newp += 2;
/* ... and finally unescape */
result = Curl_urldecode(data, newp, 0, &sel, &len, FALSE);
+ free(gopherpath);
if(result)
return result;
sel_org = sel;
@@ -159,8 +168,7 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
if(result)
return result;
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, bytecount,
- -1, NULL); /* no upload */
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, FALSE, -1);
return CURLE_OK;
}
#endif /*CURL_DISABLE_GOPHER*/
diff --git a/Utilities/cmcurl/lib/hash.c b/Utilities/cmcurl/lib/hash.c
index 6afeaa12c..421d68f76 100644
--- a/Utilities/cmcurl/lib/hash.c
+++ b/Utilities/cmcurl/lib/hash.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -60,8 +60,6 @@ Curl_hash_init(struct curl_hash *h,
comp_function comparator,
curl_hash_dtor dtor)
{
- int i;
-
if(!slots || !hfunc || !comparator ||!dtor) {
return 1; /* failure */
}
@@ -74,6 +72,7 @@ Curl_hash_init(struct curl_hash *h,
h->table = malloc(slots * sizeof(struct curl_llist));
if(h->table) {
+ int i;
for(i = 0; i < slots; ++i)
Curl_llist_init(&h->table[i], (curl_llist_dtor) hash_element_dtor);
return 0; /* fine */
@@ -140,11 +139,10 @@ Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p)
int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len)
{
struct curl_llist_element *le;
- struct curl_hash_element *he;
struct curl_llist *l = FETCH_LIST(h, key, key_len);
for(le = l->head; le; le = le->next) {
- he = le->ptr;
+ struct curl_hash_element *he = le->ptr;
if(h->comp_func(he->key, he->key_len, key, key_len)) {
Curl_llist_remove(l, le, (void *) h);
--h->size;
@@ -162,13 +160,12 @@ void *
Curl_hash_pick(struct curl_hash *h, void *key, size_t key_len)
{
struct curl_llist_element *le;
- struct curl_hash_element *he;
struct curl_llist *l;
if(h) {
l = FETCH_LIST(h, key, key_len);
for(le = l->head; le; le = le->next) {
- he = le->ptr;
+ struct curl_hash_element *he = le->ptr;
if(h->comp_func(he->key, he->key_len, key, key_len)) {
return he->ptr;
}
@@ -261,11 +258,11 @@ size_t Curl_hash_str(void *key, size_t key_length, size_t slots_num)
{
const char *key_str = (const char *) key;
const char *end = key_str + key_length;
- unsigned long h = 5381;
+ size_t h = 5381;
while(key_str < end) {
h += h << 5;
- h ^= (unsigned long) *key_str++;
+ h ^= *key_str++;
}
return (h % slots_num);
@@ -291,7 +288,6 @@ void Curl_hash_start_iterate(struct curl_hash *hash,
struct curl_hash_element *
Curl_hash_next_element(struct curl_hash_iterator *iter)
{
- int i;
struct curl_hash *h = iter->hash;
/* Get the next element in the current list, if any */
@@ -300,10 +296,11 @@ Curl_hash_next_element(struct curl_hash_iterator *iter)
/* If we have reached the end of the list, find the next one */
if(!iter->current_element) {
- for(i = iter->slot_index;i < h->slots;i++) {
+ int i;
+ for(i = iter->slot_index; i < h->slots; i++) {
if(h->table[i].head) {
iter->current_element = h->table[i].head;
- iter->slot_index = i+1;
+ iter->slot_index = i + 1;
break;
}
}
diff --git a/Utilities/cmcurl/lib/hmac.c b/Utilities/cmcurl/lib/hmac.c
index dae95054b..bf49ebec5 100644
--- a/Utilities/cmcurl/lib/hmac.c
+++ b/Utilities/cmcurl/lib/hmac.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -58,7 +58,7 @@ Curl_HMAC_init(const HMAC_params * hashparams,
unsigned char b;
/* Create HMAC context. */
- i = sizeof *ctxt + 2 * hashparams->hmac_ctxtsize +
+ i = sizeof(*ctxt) + 2 * hashparams->hmac_ctxtsize +
hashparams->hmac_resultlen;
ctxt = malloc(i);
diff --git a/Utilities/cmcurl/lib/hostasyn.c b/Utilities/cmcurl/lib/hostasyn.c
index 28bdf7a48..99d872b35 100644
--- a/Utilities/cmcurl/lib/hostasyn.c
+++ b/Utilities/cmcurl/lib/hostasyn.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,6 +22,11 @@
#include "curl_setup.h"
+/***********************************************************************
+ * Only for builds using asynchronous name resolves
+ **********************************************************************/
+#ifdef CURLRES_ASYNCH
+
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
@@ -51,11 +56,6 @@
/* The last #include file should be: */
#include "memdebug.h"
-/***********************************************************************
- * Only for builds using asynchronous name resolves
- **********************************************************************/
-#ifdef CURLRES_ASYNCH
-
/*
* Curl_addrinfo_callback() gets called by ares, gethostbyname_thread()
* or getaddrinfo_thread() when we got the name resolved (or not!).
@@ -85,14 +85,14 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn,
dns = Curl_cache_addr(data, ai,
conn->async.hostname,
conn->async.port);
+ if(data->share)
+ Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
+
if(!dns) {
/* failed to store, cleanup and return error */
Curl_freeaddrinfo(ai);
result = CURLE_OUT_OF_MEMORY;
}
-
- if(data->share)
- Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
}
else {
result = CURLE_OUT_OF_MEMORY;
@@ -111,31 +111,6 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn,
return result;
}
-/* Call this function after Curl_connect() has returned async=TRUE and
- then a successful name resolve has been received.
-
- Note: this function disconnects and frees the conn data in case of
- resolve failure */
-CURLcode Curl_async_resolved(struct connectdata *conn,
- bool *protocol_done)
-{
- CURLcode result;
-
- if(conn->async.dns) {
- conn->dns_entry = conn->async.dns;
- conn->async.dns = NULL;
- }
-
- result = Curl_setup_conn(conn, protocol_done);
-
- if(result)
- /* We're not allowed to return failure with memory left allocated
- in the connectdata struct, free those here */
- Curl_disconnect(conn, FALSE); /* close the connection */
-
- return result;
-}
-
/*
* Curl_getaddrinfo() is the generic low-level name resolve API within this
* source file. There are several versions of this function - for different
diff --git a/Utilities/cmcurl/lib/hostcheck.c b/Utilities/cmcurl/lib/hostcheck.c
index 156091ca8..115d24b2e 100644
--- a/Utilities/cmcurl/lib/hostcheck.c
+++ b/Utilities/cmcurl/lib/hostcheck.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -23,14 +23,16 @@
#include "curl_setup.h"
#if defined(USE_OPENSSL) \
- || defined(USE_AXTLS) \
|| defined(USE_GSKIT) \
- || (defined(USE_SCHANNEL) && defined(_WIN32_WCE))
+ || defined(USE_SCHANNEL)
/* these backends use functions from this file */
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
+#ifdef HAVE_NETINET_IN6_H
+#include <netinet/in6.h>
+#endif
#include "hostcheck.h"
#include "strcase.h"
@@ -73,10 +75,10 @@ static int hostmatch(char *hostname, char *pattern)
/* normalize pattern and hostname by stripping off trailing dots */
size_t len = strlen(hostname);
if(hostname[len-1]=='.')
- hostname[len-1]=0;
+ hostname[len-1] = 0;
len = strlen(pattern);
if(pattern[len-1]=='.')
- pattern[len-1]=0;
+ pattern[len-1] = 0;
pattern_wildcard = strchr(pattern, '*');
if(pattern_wildcard == NULL)
@@ -95,7 +97,7 @@ static int hostmatch(char *hostname, char *pattern)
match. */
wildcard_enabled = 1;
pattern_label_end = strchr(pattern, '.');
- if(pattern_label_end == NULL || strchr(pattern_label_end+1, '.') == NULL ||
+ if(pattern_label_end == NULL || strchr(pattern_label_end + 1, '.') == NULL ||
pattern_wildcard > pattern_label_end ||
strncasecompare(pattern, "xn--", 4)) {
wildcard_enabled = 0;
@@ -116,28 +118,26 @@ static int hostmatch(char *hostname, char *pattern)
return CURL_HOST_NOMATCH;
prefixlen = pattern_wildcard - pattern;
- suffixlen = pattern_label_end - (pattern_wildcard+1);
+ suffixlen = pattern_label_end - (pattern_wildcard + 1);
return strncasecompare(pattern, hostname, prefixlen) &&
- strncasecompare(pattern_wildcard+1, hostname_label_end - suffixlen,
+ strncasecompare(pattern_wildcard + 1, hostname_label_end - suffixlen,
suffixlen) ?
CURL_HOST_MATCH : CURL_HOST_NOMATCH;
}
int Curl_cert_hostcheck(const char *match_pattern, const char *hostname)
{
- char *matchp;
- char *hostp;
int res = 0;
if(!match_pattern || !*match_pattern ||
!hostname || !*hostname) /* sanity check */
;
else {
- matchp = strdup(match_pattern);
+ char *matchp = strdup(match_pattern);
if(matchp) {
- hostp = strdup(hostname);
+ char *hostp = strdup(hostname);
if(hostp) {
if(hostmatch(hostp, matchp) == CURL_HOST_MATCH)
- res= 1;
+ res = 1;
free(hostp);
}
free(matchp);
@@ -147,4 +147,4 @@ int Curl_cert_hostcheck(const char *match_pattern, const char *hostname)
return res;
}
-#endif /* OPENSSL, AXTLS, GSKIT or schannel+wince */
+#endif /* OPENSSL, GSKIT or schannel+wince */
diff --git a/Utilities/cmcurl/lib/hostcheck.h b/Utilities/cmcurl/lib/hostcheck.h
index 86e3b96a9..f562df9ae 100644
--- a/Utilities/cmcurl/lib/hostcheck.h
+++ b/Utilities/cmcurl/lib/hostcheck.h
@@ -29,4 +29,3 @@
int Curl_cert_hostcheck(const char *match_pattern, const char *hostname);
#endif /* HEADER_CURL_HOSTCHECK_H */
-
diff --git a/Utilities/cmcurl/lib/hostip.c b/Utilities/cmcurl/lib/hostip.c
index 619ec84b5..cf33ed8f4 100644
--- a/Utilities/cmcurl/lib/hostip.c
+++ b/Utilities/cmcurl/lib/hostip.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -25,6 +25,9 @@
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
+#ifdef HAVE_NETINET_IN6_H
+#include <netinet/in6.h>
+#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
@@ -51,10 +54,13 @@
#include "sendf.h"
#include "hostip.h"
#include "hash.h"
+#include "rand.h"
#include "share.h"
#include "strerror.h"
#include "url.h"
#include "inet_ntop.h"
+#include "multiif.h"
+#include "doh.h"
#include "warnless.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -67,6 +73,8 @@
#define USE_ALARM_TIMEOUT
#endif
+#define MAX_HOSTCACHE_LEN (255 + 7) /* max FQDN + colon + port number + zero */
+
/*
* hostip.c explained
* ==================
@@ -106,43 +114,9 @@
* CURLRES_* defines based on the config*.h and curl_setup.h defines.
*/
-/* These two symbols are for the global DNS cache */
-static struct curl_hash hostname_cache;
-static int host_cache_initialized;
-
static void freednsentry(void *freethis);
/*
- * Curl_global_host_cache_init() initializes and sets up a global DNS cache.
- * Global DNS cache is general badness. Do not use. This will be removed in
- * a future version. Use the share interface instead!
- *
- * Returns a struct curl_hash pointer on success, NULL on failure.
- */
-struct curl_hash *Curl_global_host_cache_init(void)
-{
- int rc = 0;
- if(!host_cache_initialized) {
- rc = Curl_hash_init(&hostname_cache, 7, Curl_hash_str,
- Curl_str_key_compare, freednsentry);
- if(!rc)
- host_cache_initialized = 1;
- }
- return rc?NULL:&hostname_cache;
-}
-
-/*
- * Destroy and cleanup the global DNS cache
- */
-void Curl_global_host_cache_dtor(void)
-{
- if(host_cache_initialized) {
- Curl_hash_destroy(&hostname_cache);
- host_cache_initialized = 0;
- }
-}
-
-/*
* Return # of addresses in a Curl_addrinfo struct
*/
int Curl_num_addresses(const Curl_addrinfo *addr)
@@ -192,23 +166,19 @@ Curl_printable_address(const Curl_addrinfo *ai, char *buf, size_t bufsize)
}
/*
- * Return a hostcache id string for the provided host + port, to be used by
- * the DNS caching.
+ * Create a hostcache id string for the provided host + port, to be used by
+ * the DNS caching. Without alloc.
*/
-static char *
-create_hostcache_id(const char *name, int port)
+static void
+create_hostcache_id(const char *name, int port, char *ptr, size_t buflen)
{
- /* create and return the new allocated entry */
- char *id = aprintf("%s:%d", name, port);
- char *ptr = id;
- if(ptr) {
- /* lower case the name part */
- while(*ptr && (*ptr != ':')) {
- *ptr = (char)TOLOWER(*ptr);
- ptr++;
- }
- }
- return id;
+ size_t len = strlen(name);
+ if(len > (buflen - 7))
+ len = buflen - 7;
+ /* store and lower case the name */
+ while(len--)
+ *ptr++ = (char)TOLOWER(*name++);
+ msnprintf(ptr, 7, ":%u", port);
}
struct hostcache_prune_data {
@@ -290,23 +260,28 @@ fetch_addr(struct connectdata *conn,
const char *hostname,
int port)
{
- char *entry_id = NULL;
struct Curl_dns_entry *dns = NULL;
size_t entry_len;
struct Curl_easy *data = conn->data;
+ char entry_id[MAX_HOSTCACHE_LEN];
/* Create an entry id, based upon the hostname and port */
- entry_id = create_hostcache_id(hostname, port);
- /* If we can't create the entry id, fail */
- if(!entry_id)
- return dns;
-
+ create_hostcache_id(hostname, port, entry_id, sizeof(entry_id));
entry_len = strlen(entry_id);
/* See if its already in our dns cache */
- dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len+1);
+ dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len + 1);
+
+ /* No entry found in cache, check if we might have a wildcard entry */
+ if(!dns && data->change.wildcard_resolve) {
+ create_hostcache_id("*", port, entry_id, sizeof(entry_id));
+ entry_len = strlen(entry_id);
+
+ /* See if it's already in our dns cache */
+ dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len + 1);
+ }
- if(dns && (data->set.dns_cache_timeout != -1)) {
+ if(dns && (data->set.dns_cache_timeout != -1)) {
/* See whether the returned entry is stale. Done before we release lock */
struct hostcache_prune_data user;
@@ -316,13 +291,10 @@ fetch_addr(struct connectdata *conn,
if(hostcache_timestamp_remove(&user, dns)) {
infof(data, "Hostname in DNS cache was stale, zapped\n");
dns = NULL; /* the memory deallocation is being handled by the hash */
- Curl_hash_delete(data->dns.hostcache, entry_id, entry_len+1);
+ Curl_hash_delete(data->dns.hostcache, entry_id, entry_len + 1);
}
}
- /* free the allocated entry_id again */
- free(entry_id);
-
return dns;
}
@@ -362,6 +334,75 @@ Curl_fetch_addr(struct connectdata *conn,
return dns;
}
+#ifndef CURL_DISABLE_SHUFFLE_DNS
+UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
+ Curl_addrinfo **addr);
+/*
+ * Curl_shuffle_addr() shuffles the order of addresses in a 'Curl_addrinfo'
+ * struct by re-linking its linked list.
+ *
+ * The addr argument should be the address of a pointer to the head node of a
+ * `Curl_addrinfo` list and it will be modified to point to the new head after
+ * shuffling.
+ *
+ * Not declared static only to make it easy to use in a unit test!
+ *
+ * @unittest: 1608
+ */
+UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
+ Curl_addrinfo **addr)
+{
+ CURLcode result = CURLE_OK;
+ const int num_addrs = Curl_num_addresses(*addr);
+
+ if(num_addrs > 1) {
+ Curl_addrinfo **nodes;
+ infof(data, "Shuffling %i addresses", num_addrs);
+
+ nodes = malloc(num_addrs*sizeof(*nodes));
+ if(nodes) {
+ int i;
+ unsigned int *rnd;
+ const size_t rnd_size = num_addrs * sizeof(*rnd);
+
+ /* build a plain array of Curl_addrinfo pointers */
+ nodes[0] = *addr;
+ for(i = 1; i < num_addrs; i++) {
+ nodes[i] = nodes[i-1]->ai_next;
+ }
+
+ rnd = malloc(rnd_size);
+ if(rnd) {
+ /* Fisher-Yates shuffle */
+ if(Curl_rand(data, (unsigned char *)rnd, rnd_size) == CURLE_OK) {
+ Curl_addrinfo *swap_tmp;
+ for(i = num_addrs - 1; i > 0; i--) {
+ swap_tmp = nodes[rnd[i] % (i + 1)];
+ nodes[rnd[i] % (i + 1)] = nodes[i];
+ nodes[i] = swap_tmp;
+ }
+
+ /* relink list in the new order */
+ for(i = 1; i < num_addrs; i++) {
+ nodes[i-1]->ai_next = nodes[i];
+ }
+
+ nodes[num_addrs-1]->ai_next = NULL;
+ *addr = nodes[0];
+ }
+ free(rnd);
+ }
+ else
+ result = CURLE_OUT_OF_MEMORY;
+ free(nodes);
+ }
+ else
+ result = CURLE_OUT_OF_MEMORY;
+ }
+ return result;
+}
+#endif
+
/*
* Curl_cache_addr() stores a 'Curl_addrinfo' struct in the DNS cache.
*
@@ -377,25 +418,30 @@ Curl_cache_addr(struct Curl_easy *data,
const char *hostname,
int port)
{
- char *entry_id;
+ char entry_id[MAX_HOSTCACHE_LEN];
size_t entry_len;
struct Curl_dns_entry *dns;
struct Curl_dns_entry *dns2;
- /* Create an entry id, based upon the hostname and port */
- entry_id = create_hostcache_id(hostname, port);
- /* If we can't create the entry id, fail */
- if(!entry_id)
- return NULL;
- entry_len = strlen(entry_id);
+#ifndef CURL_DISABLE_SHUFFLE_DNS
+ /* shuffle addresses if requested */
+ if(data->set.dns_shuffle_addresses) {
+ CURLcode result = Curl_shuffle_addr(data, &addr);
+ if(result)
+ return NULL;
+ }
+#endif
/* Create a new cache entry */
dns = calloc(1, sizeof(struct Curl_dns_entry));
if(!dns) {
- free(entry_id);
return NULL;
}
+ /* Create an entry id, based upon the hostname and port */
+ create_hostcache_id(hostname, port, entry_id, sizeof(entry_id));
+ entry_len = strlen(entry_id);
+
dns->inuse = 1; /* the cache has the first reference */
dns->addr = addr; /* this is the address(es) */
time(&dns->timestamp);
@@ -403,20 +449,15 @@ Curl_cache_addr(struct Curl_easy *data,
dns->timestamp = 1; /* zero indicates CURLOPT_RESOLVE entry */
/* Store the resolved data in our DNS cache. */
- dns2 = Curl_hash_add(data->dns.hostcache, entry_id, entry_len+1,
+ dns2 = Curl_hash_add(data->dns.hostcache, entry_id, entry_len + 1,
(void *)dns);
if(!dns2) {
free(dns);
- free(entry_id);
return NULL;
}
dns = dns2;
dns->inuse++; /* mark entry as in-use */
-
- /* free the allocated entry_id */
- free(entry_id);
-
return dns;
}
@@ -444,6 +485,7 @@ Curl_cache_addr(struct Curl_easy *data,
int Curl_resolv(struct connectdata *conn,
const char *hostname,
int port,
+ bool allowDOH,
struct Curl_dns_entry **entry)
{
struct Curl_dns_entry *dns = NULL;
@@ -471,30 +513,45 @@ int Curl_resolv(struct connectdata *conn,
/* The entry was not in the cache. Resolve it to IP address */
Curl_addrinfo *addr;
- int respwait;
+ int respwait = 0;
/* Check what IP specifics the app has requested and if we can provide it.
* If not, bail out. */
if(!Curl_ipvalid(conn))
return CURLRESOLV_ERROR;
- /* If Curl_getaddrinfo() returns NULL, 'respwait' might be set to a
- non-zero value indicating that we need to wait for the response to the
- resolve call */
- addr = Curl_getaddrinfo(conn,
+ /* notify the resolver start callback */
+ if(data->set.resolver_start) {
+ int st;
+ Curl_set_in_callback(data, true);
+ st = data->set.resolver_start(data->state.resolver, NULL,
+ data->set.resolver_start_client);
+ Curl_set_in_callback(data, false);
+ if(st)
+ return CURLRESOLV_ERROR;
+ }
+
+ if(allowDOH && data->set.doh) {
+ addr = Curl_doh(conn, hostname, port, &respwait);
+ }
+ else {
+ /* If Curl_getaddrinfo() returns NULL, 'respwait' might be set to a
+ non-zero value indicating that we need to wait for the response to the
+ resolve call */
+ addr = Curl_getaddrinfo(conn,
#ifdef DEBUGBUILD
- (data->set.str[STRING_DEVICE]
- && !strcmp(data->set.str[STRING_DEVICE],
- "LocalHost"))?"localhost":
+ (data->set.str[STRING_DEVICE]
+ && !strcmp(data->set.str[STRING_DEVICE],
+ "LocalHost"))?"localhost":
#endif
- hostname, port, &respwait);
-
+ hostname, port, &respwait);
+ }
if(!addr) {
if(respwait) {
/* the response to our resolve call will come asynchronously at
a later time, good or bad */
/* First, check that we haven't received the info by now */
- result = Curl_resolver_is_resolved(conn, &dns);
+ result = Curl_resolv_check(conn, &dns);
if(result) /* error detected */
return CURLRESOLV_ERROR;
if(dns)
@@ -600,7 +657,7 @@ int Curl_resolv_timeout(struct connectdata *conn,
if(!timeout)
/* USE_ALARM_TIMEOUT defined, but no timeout actually requested */
- return Curl_resolv(conn, hostname, port, entry);
+ return Curl_resolv(conn, hostname, port, TRUE, entry);
if(timeout < 1000) {
/* The alarm() function only provides integer second resolution, so if
@@ -662,7 +719,7 @@ int Curl_resolv_timeout(struct connectdata *conn,
/* Perform the actual name resolution. This might be interrupted by an
* alarm if it takes too long.
*/
- rc = Curl_resolv(conn, hostname, port, entry);
+ rc = Curl_resolv(conn, hostname, port, TRUE, entry);
#ifdef USE_ALARM_TIMEOUT
clean_up:
@@ -688,8 +745,8 @@ clean_up:
the time we spent until now! */
if(prev_alarm) {
/* there was an alarm() set before us, now put it back */
- unsigned long elapsed_secs = (unsigned long) (Curl_tvdiff(Curl_tvnow(),
- conn->created) / 1000);
+ timediff_t elapsed_secs = Curl_timediff(Curl_now(),
+ conn->created) / 1000;
/* the alarm period is counted in even number of seconds */
unsigned long alarm_set = prev_alarm - elapsed_secs;
@@ -778,14 +835,16 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
{
struct curl_slist *hostp;
char hostname[256];
- char address[256];
- int port;
+ int port = 0;
+
+ /* Default is no wildcard found */
+ data->change.wildcard_resolve = false;
for(hostp = data->change.resolve; hostp; hostp = hostp->next) {
+ char entry_id[MAX_HOSTCACHE_LEN];
if(!hostp->data)
continue;
if(hostp->data[0] == '-') {
- char *entry_id;
size_t entry_len;
if(2 != sscanf(hostp->data + 1, "%255[^:]:%d", hostname, &port)) {
@@ -795,90 +854,217 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
}
/* Create an entry id, based upon the hostname and port */
- entry_id = create_hostcache_id(hostname, port);
- /* If we can't create the entry id, fail */
- if(!entry_id) {
- return CURLE_OUT_OF_MEMORY;
- }
-
+ create_hostcache_id(hostname, port, entry_id, sizeof(entry_id));
entry_len = strlen(entry_id);
if(data->share)
Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
/* delete entry, ignore if it didn't exist */
- Curl_hash_delete(data->dns.hostcache, entry_id, entry_len+1);
+ Curl_hash_delete(data->dns.hostcache, entry_id, entry_len + 1);
if(data->share)
Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
-
- /* free the allocated entry_id again */
- free(entry_id);
}
else {
struct Curl_dns_entry *dns;
- Curl_addrinfo *addr;
- char *entry_id;
+ Curl_addrinfo *head = NULL, *tail = NULL;
size_t entry_len;
+ char address[64];
+#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
+ char *addresses = NULL;
+#endif
+ char *addr_begin;
+ char *addr_end;
+ char *port_ptr;
+ char *end_ptr;
+ char *host_end;
+ unsigned long tmp_port;
+ bool error = true;
+
+ host_end = strchr(hostp->data, ':');
+ if(!host_end ||
+ ((host_end - hostp->data) >= (ptrdiff_t)sizeof(hostname)))
+ goto err;
+
+ memcpy(hostname, hostp->data, host_end - hostp->data);
+ hostname[host_end - hostp->data] = '\0';
+
+ port_ptr = host_end + 1;
+ tmp_port = strtoul(port_ptr, &end_ptr, 10);
+ if(tmp_port > USHRT_MAX || end_ptr == port_ptr || *end_ptr != ':')
+ goto err;
+
+ port = (int)tmp_port;
+#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
+ addresses = end_ptr + 1;
+#endif
- if(3 != sscanf(hostp->data, "%255[^:]:%d:%255s", hostname, &port,
- address)) {
- infof(data, "Couldn't parse CURLOPT_RESOLVE entry '%s'!\n",
- hostp->data);
- continue;
+ while(*end_ptr) {
+ size_t alen;
+ Curl_addrinfo *ai;
+
+ addr_begin = end_ptr + 1;
+ addr_end = strchr(addr_begin, ',');
+ if(!addr_end)
+ addr_end = addr_begin + strlen(addr_begin);
+ end_ptr = addr_end;
+
+ /* allow IP(v6) address within [brackets] */
+ if(*addr_begin == '[') {
+ if(addr_end == addr_begin || *(addr_end - 1) != ']')
+ goto err;
+ ++addr_begin;
+ --addr_end;
+ }
+
+ alen = addr_end - addr_begin;
+ if(!alen)
+ continue;
+
+ if(alen >= sizeof(address))
+ goto err;
+
+ memcpy(address, addr_begin, alen);
+ address[alen] = '\0';
+
+#ifndef ENABLE_IPV6
+ if(strchr(address, ':')) {
+ infof(data, "Ignoring resolve address '%s', missing IPv6 support.\n",
+ address);
+ continue;
+ }
+#endif
+
+ ai = Curl_str2addr(address, port);
+ if(!ai) {
+ infof(data, "Resolve address '%s' found illegal!\n", address);
+ goto err;
+ }
+
+ if(tail) {
+ tail->ai_next = ai;
+ tail = tail->ai_next;
+ }
+ else {
+ head = tail = ai;
+ }
}
- addr = Curl_str2addr(address, port);
- if(!addr) {
- infof(data, "Address in '%s' found illegal!\n", hostp->data);
+ if(!head)
+ goto err;
+
+ error = false;
+ err:
+ if(error) {
+ infof(data, "Couldn't parse CURLOPT_RESOLVE entry '%s'!\n",
+ hostp->data);
+ Curl_freeaddrinfo(head);
continue;
}
/* Create an entry id, based upon the hostname and port */
- entry_id = create_hostcache_id(hostname, port);
- /* If we can't create the entry id, fail */
- if(!entry_id) {
- Curl_freeaddrinfo(addr);
- return CURLE_OUT_OF_MEMORY;
- }
-
+ create_hostcache_id(hostname, port, entry_id, sizeof(entry_id));
entry_len = strlen(entry_id);
if(data->share)
Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
/* See if its already in our dns cache */
- dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len+1);
-
- /* free the allocated entry_id again */
- free(entry_id);
+ dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len + 1);
+
+ if(dns) {
+ infof(data, "RESOLVE %s:%d is - old addresses discarded!\n",
+ hostname, port);
+ /* delete old entry entry, there are two reasons for this
+ 1. old entry may have different addresses.
+ 2. even if entry with correct addresses is already in the cache,
+ but if it is close to expire, then by the time next http
+ request is made, it can get expired and pruned because old
+ entry is not necessarily marked as added by CURLOPT_RESOLVE. */
+
+ Curl_hash_delete(data->dns.hostcache, entry_id, entry_len + 1);
+ }
- if(!dns) {
- /* if not in the cache already, put this host in the cache */
- dns = Curl_cache_addr(data, addr, hostname, port);
- if(dns) {
- dns->timestamp = 0; /* mark as added by CURLOPT_RESOLVE */
- /* release the returned reference; the cache itself will keep the
- * entry alive: */
- dns->inuse--;
- }
+ /* put this new host in the cache */
+ dns = Curl_cache_addr(data, head, hostname, port);
+ if(dns) {
+ dns->timestamp = 0; /* mark as added by CURLOPT_RESOLVE */
+ /* release the returned reference; the cache itself will keep the
+ * entry alive: */
+ dns->inuse--;
}
- else
- /* this is a duplicate, free it again */
- Curl_freeaddrinfo(addr);
if(data->share)
Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
if(!dns) {
- Curl_freeaddrinfo(addr);
+ Curl_freeaddrinfo(head);
return CURLE_OUT_OF_MEMORY;
}
infof(data, "Added %s:%d:%s to DNS cache\n",
- hostname, port, address);
+ hostname, port, addresses);
+
+ /* Wildcard hostname */
+ if(hostname[0] == '*' && hostname[1] == '\0') {
+ infof(data, "RESOLVE %s:%d is wildcard, enabling wildcard checks\n",
+ hostname, port);
+ data->change.wildcard_resolve = true;
+ }
}
}
data->change.resolve = NULL; /* dealt with now */
return CURLE_OK;
}
+
+CURLcode Curl_resolv_check(struct connectdata *conn,
+ struct Curl_dns_entry **dns)
+{
+ if(conn->data->set.doh)
+ return Curl_doh_is_resolved(conn, dns);
+ return Curl_resolver_is_resolved(conn, dns);
+}
+
+int Curl_resolv_getsock(struct connectdata *conn,
+ curl_socket_t *socks,
+ int numsocks)
+{
+#ifdef CURLRES_ASYNCH
+ if(conn->data->set.doh)
+ /* nothing to wait for during DOH resolve, those handles have their own
+ sockets */
+ return GETSOCK_BLANK;
+ return Curl_resolver_getsock(conn, socks, numsocks);
+#else
+ (void)conn;
+ (void)socks;
+ (void)numsocks;
+ return GETSOCK_BLANK;
+#endif
+}
+
+/* Call this function after Curl_connect() has returned async=TRUE and
+ then a successful name resolve has been received.
+
+ Note: this function disconnects and frees the conn data in case of
+ resolve failure */
+CURLcode Curl_once_resolved(struct connectdata *conn,
+ bool *protocol_done)
+{
+ CURLcode result;
+
+ if(conn->async.dns) {
+ conn->dns_entry = conn->async.dns;
+ conn->async.dns = NULL;
+ }
+
+ result = Curl_setup_conn(conn, protocol_done);
+
+ if(result)
+ /* We're not allowed to return failure with memory left allocated
+ in the connectdata struct, free those here */
+ Curl_disconnect(conn->data, conn, TRUE); /* close the connection */
+
+ return result;
+}
diff --git a/Utilities/cmcurl/lib/hostip.h b/Utilities/cmcurl/lib/hostip.h
index 298eeeee3..9dc0d5a17 100644
--- a/Utilities/cmcurl/lib/hostip.h
+++ b/Utilities/cmcurl/lib/hostip.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -83,8 +83,11 @@ struct Curl_dns_entry {
#define CURLRESOLV_ERROR -1
#define CURLRESOLV_RESOLVED 0
#define CURLRESOLV_PENDING 1
-int Curl_resolv(struct connectdata *conn, const char *hostname,
- int port, struct Curl_dns_entry **dnsentry);
+int Curl_resolv(struct connectdata *conn,
+ const char *hostname,
+ int port,
+ bool allowDOH,
+ struct Curl_dns_entry **dnsentry);
int Curl_resolv_timeout(struct connectdata *conn, const char *hostname,
int port, struct Curl_dns_entry **dnsentry,
time_t timeoutms);
@@ -145,12 +148,7 @@ int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa,
/* IPv4 threadsafe resolve function used for synch and asynch builds */
Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, int port);
-CURLcode Curl_async_resolved(struct connectdata *conn,
- bool *protocol_connect);
-
-#ifndef CURLRES_ASYNCH
-#define Curl_async_resolved(x,y) CURLE_OK
-#endif
+CURLcode Curl_once_resolved(struct connectdata *conn, bool *protocol_connect);
/*
* Curl_addrinfo_callback() is used when we build with any asynch specialty.
@@ -182,6 +180,7 @@ struct Curl_dns_entry *
Curl_fetch_addr(struct connectdata *conn,
const char *hostname,
int port);
+
/*
* Curl_cache_addr() stores a 'Curl_addrinfo' struct in the DNS cache.
*
@@ -247,4 +246,10 @@ void Curl_hostcache_destroy(struct Curl_easy *data);
*/
CURLcode Curl_loadhostpairs(struct Curl_easy *data);
+CURLcode Curl_resolv_check(struct connectdata *conn,
+ struct Curl_dns_entry **dns);
+int Curl_resolv_getsock(struct connectdata *conn,
+ curl_socket_t *socks,
+ int numsocks);
+
#endif /* HEADER_CURL_HOSTIP_H */
diff --git a/Utilities/cmcurl/lib/hostip4.c b/Utilities/cmcurl/lib/hostip4.c
index e459328ac..e6ba710d8 100644
--- a/Utilities/cmcurl/lib/hostip4.c
+++ b/Utilities/cmcurl/lib/hostip4.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,6 +22,11 @@
#include "curl_setup.h"
+/***********************************************************************
+ * Only for plain IPv4 builds
+ **********************************************************************/
+#ifdef CURLRES_IPV4 /* plain IPv4 code coming up */
+
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
@@ -53,10 +58,6 @@
#include "curl_memory.h"
#include "memdebug.h"
-/***********************************************************************
- * Only for plain IPv4 builds
- **********************************************************************/
-#ifdef CURLRES_IPV4 /* plain IPv4 code coming up */
/*
* Curl_ipvalid() checks what CURL_IPRESOLVE_* requirements that might've
* been set and returns TRUE if they are OK.
@@ -144,7 +145,7 @@ Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
hints.ai_family = PF_INET;
hints.ai_socktype = SOCK_STREAM;
if(port) {
- snprintf(sbuf, sizeof(sbuf), "%d", port);
+ msnprintf(sbuf, sizeof(sbuf), "%d", port);
sbufptr = sbuf;
}
@@ -249,7 +250,7 @@ Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
*/
if(CURL_HOSTENT_SIZE >=
- (sizeof(struct hostent)+sizeof(struct hostent_data))) {
+ (sizeof(struct hostent) + sizeof(struct hostent_data))) {
/* August 22nd, 2000: Albert Chin-A-Young brought an updated version
* that should work! September 20: Richard Prescott worked on the buffer
diff --git a/Utilities/cmcurl/lib/hostip6.c b/Utilities/cmcurl/lib/hostip6.c
index 4ebfc2dcf..5511f1aab 100644
--- a/Utilities/cmcurl/lib/hostip6.c
+++ b/Utilities/cmcurl/lib/hostip6.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,6 +22,11 @@
#include "curl_setup.h"
+/***********************************************************************
+ * Only for IPv6-enabled builds
+ **********************************************************************/
+#ifdef CURLRES_IPV6
+
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
@@ -54,44 +59,6 @@
#include "curl_memory.h"
#include "memdebug.h"
-/***********************************************************************
- * Only for IPv6-enabled builds
- **********************************************************************/
-#ifdef CURLRES_IPV6
-
-#if defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO)
-/* These are strictly for memory tracing and are using the same style as the
- * family otherwise present in memdebug.c. I put these ones here since they
- * require a bunch of structs I didn't want to include in memdebug.c
- */
-
-/*
- * For CURLRES_ARS, this should be written using ares_gethostbyaddr()
- * (ignoring the fact c-ares doesn't return 'serv').
- */
-
-int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa,
- GETNAMEINFO_TYPE_ARG2 salen,
- char *host, GETNAMEINFO_TYPE_ARG46 hostlen,
- char *serv, GETNAMEINFO_TYPE_ARG46 servlen,
- GETNAMEINFO_TYPE_ARG7 flags,
- int line, const char *source)
-{
- int res = (getnameinfo)(sa, salen,
- host, hostlen,
- serv, servlen,
- flags);
- if(0 == res)
- /* success */
- curl_memlog("GETNAME %s:%d getnameinfo()\n",
- source, line);
- else
- curl_memlog("GETNAME %s:%d getnameinfo() failed = %d\n",
- source, line, res);
- return res;
-}
-#endif /* defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO) */
-
/*
* Curl_ipv6works() returns TRUE if IPv6 seems to work.
*/
@@ -134,14 +101,16 @@ static void dump_addrinfo(struct connectdata *conn, const Curl_addrinfo *ai)
{
printf("dump_addrinfo:\n");
for(; ai; ai = ai->ai_next) {
- char buf[INET6_ADDRSTRLEN];
-
+ char buf[INET6_ADDRSTRLEN];
printf(" fam %2d, CNAME %s, ",
ai->ai_family, ai->ai_canonname ? ai->ai_canonname : "<none>");
if(Curl_printable_address(ai, buf, sizeof(buf)))
printf("%s\n", buf);
- else
- printf("failed; %s\n", Curl_strerror(conn, SOCKERRNO));
+ else {
+ char buffer[STRERROR_LEN];
+ printf("failed; %s\n",
+ Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
+ }
}
}
#else
@@ -211,8 +180,8 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
#endif
if(port) {
- snprintf(sbuf, sizeof(sbuf), "%d", port);
- sbufptr=sbuf;
+ msnprintf(sbuf, sizeof(sbuf), "%d", port);
+ sbufptr = sbuf;
}
error = Curl_getaddrinfo_ex(hostname, sbufptr, &hints, &res);
diff --git a/Utilities/cmcurl/lib/hostsyn.c b/Utilities/cmcurl/lib/hostsyn.c
index 1a95263c6..3de6746f5 100644
--- a/Utilities/cmcurl/lib/hostsyn.c
+++ b/Utilities/cmcurl/lib/hostsyn.c
@@ -22,6 +22,11 @@
#include "curl_setup.h"
+/***********************************************************************
+ * Only for builds using synchronous name resolves
+ **********************************************************************/
+#ifdef CURLRES_SYNCH
+
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
@@ -51,11 +56,6 @@
/* The last #include file should be: */
#include "memdebug.h"
-/***********************************************************************
- * Only for builds using synchronous name resolves
- **********************************************************************/
-#ifdef CURLRES_SYNCH
-
/*
* Function provided by the resolver backend to set DNS servers to use.
*/
diff --git a/Utilities/cmcurl/lib/http.c b/Utilities/cmcurl/lib/http.c
index 21574e21d..338c59a22 100644
--- a/Utilities/cmcurl/lib/http.c
+++ b/Utilities/cmcurl/lib/http.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -50,6 +50,7 @@
#include "transfer.h"
#include "sendf.h"
#include "formdata.h"
+#include "mime.h"
#include "progress.h"
#include "curl_base64.h"
#include "cookie.h"
@@ -72,11 +73,10 @@
#include "http_proxy.h"
#include "warnless.h"
#include "non-ascii.h"
-#include "conncache.h"
-#include "pipeline.h"
#include "http2.h"
#include "connect.h"
#include "strdup.h"
+#include "altsvc.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
@@ -92,6 +92,10 @@ static int http_getsock_do(struct connectdata *conn,
int numsocks);
static int http_should_fail(struct connectdata *conn);
+#ifndef CURL_DISABLE_PROXY
+static CURLcode add_haproxy_protocol_header(struct connectdata *conn);
+#endif
+
#ifdef USE_SSL
static CURLcode https_connecting(struct connectdata *conn, bool *done);
static int https_getsock(struct connectdata *conn,
@@ -100,13 +104,14 @@ static int https_getsock(struct connectdata *conn,
#else
#define https_connecting(x,y) CURLE_COULDNT_CONNECT
#endif
+static CURLcode http_setup_conn(struct connectdata *conn);
/*
* HTTP handler interface.
*/
const struct Curl_handler Curl_handler_http = {
"HTTP", /* scheme */
- Curl_http_setup_conn, /* setup_connection */
+ http_setup_conn, /* setup_connection */
Curl_http, /* do_it */
Curl_http_done, /* done */
ZERO_NULL, /* do_more */
@@ -119,6 +124,7 @@ const struct Curl_handler Curl_handler_http = {
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_HTTP, /* defport */
CURLPROTO_HTTP, /* protocol */
PROTOPT_CREDSPERREQUEST /* flags */
@@ -130,7 +136,7 @@ const struct Curl_handler Curl_handler_http = {
*/
const struct Curl_handler Curl_handler_https = {
"HTTPS", /* scheme */
- Curl_http_setup_conn, /* setup_connection */
+ http_setup_conn, /* setup_connection */
Curl_http, /* do_it */
Curl_http_done, /* done */
ZERO_NULL, /* do_more */
@@ -143,60 +149,44 @@ const struct Curl_handler Curl_handler_https = {
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_HTTPS, /* defport */
CURLPROTO_HTTPS, /* protocol */
PROTOPT_SSL | PROTOPT_CREDSPERREQUEST | PROTOPT_ALPN_NPN /* flags */
};
#endif
-CURLcode Curl_http_setup_conn(struct connectdata *conn)
+static CURLcode http_setup_conn(struct connectdata *conn)
{
/* allocate the HTTP-specific struct for the Curl_easy, only to survive
during this request */
struct HTTP *http;
- DEBUGASSERT(conn->data->req.protop == NULL);
+ struct Curl_easy *data = conn->data;
+ DEBUGASSERT(data->req.protop == NULL);
http = calloc(1, sizeof(struct HTTP));
if(!http)
return CURLE_OUT_OF_MEMORY;
- conn->data->req.protop = http;
-
- Curl_http2_setup_conn(conn);
- Curl_http2_setup_req(conn->data);
+ Curl_mime_initpart(&http->form, conn->data);
+ data->req.protop = http;
+ if(!CONN_INUSE(conn))
+ /* if not already multi-using, setup connection details */
+ Curl_http2_setup_conn(conn);
+ Curl_http2_setup_req(data);
return CURLE_OK;
}
-/*
- * checkheaders() checks the linked list of custom HTTP headers for a
- * particular header (prefix).
- *
- * Returns a pointer to the first matching header or NULL if none matched.
- */
-char *Curl_checkheaders(const struct connectdata *conn,
- const char *thisheader)
-{
- struct curl_slist *head;
- size_t thislen = strlen(thisheader);
- struct Curl_easy *data = conn->data;
-
- for(head = data->set.headers;head; head=head->next) {
- if(strncasecompare(head->data, thisheader, thislen))
- return head->data;
- }
-
- return NULL;
-}
-
+#ifndef CURL_DISABLE_PROXY
/*
* checkProxyHeaders() checks the linked list of custom proxy headers
* if proxy headers are not available, then it will lookup into http header
* link list
*
- * It takes a connectdata struct as input instead of the Curl_easy simply
- * to know if this is a proxy request or not, as it then might check a
- * different header list.
+ * It takes a connectdata struct as input instead of the Curl_easy simply to
+ * know if this is a proxy request or not, as it then might check a different
+ * header list. Provide the header prefix without colon!.
*/
char *Curl_checkProxyheaders(const struct connectdata *conn,
const char *thisheader)
@@ -207,13 +197,18 @@ char *Curl_checkProxyheaders(const struct connectdata *conn,
for(head = (conn->bits.proxy && data->set.sep_headers) ?
data->set.proxyheaders : data->set.headers;
- head; head=head->next) {
- if(strncasecompare(head->data, thisheader, thislen))
+ head; head = head->next) {
+ if(strncasecompare(head->data, thisheader, thislen) &&
+ Curl_headersep(head->data[thislen]))
return head->data;
}
return NULL;
}
+#else
+/* disabled */
+#define Curl_checkProxyheaders(x,y) NULL
+#endif
/*
* Strip off leading and trailing whitespace from the value in the
@@ -228,8 +223,6 @@ char *Curl_copy_header_value(const char *header)
char *value;
size_t len;
- DEBUGASSERT(header);
-
/* Find the end of the header name */
while(*header && (*header != ':'))
++header;
@@ -270,6 +263,7 @@ char *Curl_copy_header_value(const char *header)
return value;
}
+#ifndef CURL_DISABLE_HTTP_AUTH
/*
* http_output_basic() sets up an Authorization: header (or the proxy version)
* for HTTP Basic authentication.
@@ -326,22 +320,51 @@ static CURLcode http_output_basic(struct connectdata *conn, bool proxy)
return result;
}
+/*
+ * http_output_bearer() sets up an Authorization: header
+ * for HTTP Bearer authentication.
+ *
+ * Returns CURLcode.
+ */
+static CURLcode http_output_bearer(struct connectdata *conn)
+{
+ char **userp;
+ CURLcode result = CURLE_OK;
+
+ userp = &conn->allocptr.userpwd;
+ free(*userp);
+ *userp = aprintf("Authorization: Bearer %s\r\n",
+ conn->oauth_bearer);
+
+ if(!*userp) {
+ result = CURLE_OUT_OF_MEMORY;
+ goto fail;
+ }
+
+ fail:
+ return result;
+}
+
+#endif
+
/* pickoneauth() selects the most favourable authentication method from the
* ones available and the ones we want.
*
* return TRUE if one was picked
*/
-static bool pickoneauth(struct auth *pick)
+static bool pickoneauth(struct auth *pick, unsigned long mask)
{
bool picked;
/* only deal with authentication we want */
- unsigned long avail = pick->avail & pick->want;
+ unsigned long avail = pick->avail & pick->want & mask;
picked = TRUE;
/* The order of these checks is highly relevant, as this will be the order
of preference in case of the existence of multiple accepted types. */
if(avail & CURLAUTH_NEGOTIATE)
pick->picked = CURLAUTH_NEGOTIATE;
+ else if(avail & CURLAUTH_BEARER)
+ pick->picked = CURLAUTH_BEARER;
else if(avail & CURLAUTH_DIGEST)
pick->picked = CURLAUTH_DIGEST;
else if(avail & CURLAUTH_NTLM)
@@ -402,7 +425,7 @@ static CURLcode http_perhapsrewind(struct connectdata *conn)
break;
}
- bytessent = http->writebytecount;
+ bytessent = data->req.writebytecount;
if(conn->bits.authneg) {
/* This is a state where we are known to be negotiating and we don't send
@@ -425,6 +448,7 @@ static CURLcode http_perhapsrewind(struct connectdata *conn)
expectsend = data->state.infilesize;
break;
case HTTPREQ_POST_FORM:
+ case HTTPREQ_POST_MIME:
expectsend = http->postsize;
break;
default:
@@ -442,13 +466,13 @@ static CURLcode http_perhapsrewind(struct connectdata *conn)
(data->state.authproxy.picked == CURLAUTH_NTLM_WB) ||
(data->state.authhost.picked == CURLAUTH_NTLM_WB)) {
if(((expectsend - bytessent) < 2000) ||
- (conn->ntlm.state != NTLMSTATE_NONE) ||
- (conn->proxyntlm.state != NTLMSTATE_NONE)) {
+ (conn->http_ntlm_state != NTLMSTATE_NONE) ||
+ (conn->proxy_ntlm_state != NTLMSTATE_NONE)) {
/* The NTLM-negotiation has started *OR* there is just a little (<2K)
data left to send, keep on sending. */
/* rewind data when completely done sending! */
- if(!conn->bits.authneg) {
+ if(!conn->bits.authneg && (conn->writesockfd != CURL_SOCKET_BAD)) {
conn->bits.rewindaftersend = TRUE;
infof(data, "Rewind stream after send\n");
}
@@ -465,8 +489,36 @@ static CURLcode http_perhapsrewind(struct connectdata *conn)
(curl_off_t)(expectsend - bytessent));
}
#endif
+#if defined(USE_SPNEGO)
+ /* There is still data left to send */
+ if((data->state.authproxy.picked == CURLAUTH_NEGOTIATE) ||
+ (data->state.authhost.picked == CURLAUTH_NEGOTIATE)) {
+ if(((expectsend - bytessent) < 2000) ||
+ (conn->http_negotiate_state != GSS_AUTHNONE) ||
+ (conn->proxy_negotiate_state != GSS_AUTHNONE)) {
+ /* The NEGOTIATE-negotiation has started *OR*
+ there is just a little (<2K) data left to send, keep on sending. */
+
+ /* rewind data when completely done sending! */
+ if(!conn->bits.authneg && (conn->writesockfd != CURL_SOCKET_BAD)) {
+ conn->bits.rewindaftersend = TRUE;
+ infof(data, "Rewind stream after send\n");
+ }
- /* This is not NTLM or many bytes left to send: close */
+ return CURLE_OK;
+ }
+
+ if(conn->bits.close)
+ /* this is already marked to get closed */
+ return CURLE_OK;
+
+ infof(data, "NEGOTIATE send, close instead of sending %"
+ CURL_FORMAT_CURL_OFF_T " bytes\n",
+ (curl_off_t)(expectsend - bytessent));
+ }
+#endif
+
+ /* This is not NEGOTIATE/NTLM or many bytes left to send: close */
streamclose(conn, "Mid-auth HTTP and much data left to send");
data->req.size = 0; /* don't download any more than 0 bytes */
@@ -494,6 +546,10 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
bool pickhost = FALSE;
bool pickproxy = FALSE;
CURLcode result = CURLE_OK;
+ unsigned long authmask = ~0ul;
+
+ if(!conn->oauth_bearer)
+ authmask &= (unsigned long)~CURLAUTH_BEARER;
if(100 <= data->req.httpcode && 199 >= data->req.httpcode)
/* this is a transient response code, ignore */
@@ -502,30 +558,29 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
if(data->state.authproblem)
return data->set.http_fail_on_error?CURLE_HTTP_RETURNED_ERROR:CURLE_OK;
- if(conn->bits.user_passwd &&
+ if((conn->bits.user_passwd || conn->oauth_bearer) &&
((data->req.httpcode == 401) ||
(conn->bits.authneg && data->req.httpcode < 300))) {
- pickhost = pickoneauth(&data->state.authhost);
+ pickhost = pickoneauth(&data->state.authhost, authmask);
if(!pickhost)
data->state.authproblem = TRUE;
+ if(data->state.authhost.picked == CURLAUTH_NTLM &&
+ conn->httpversion > 11) {
+ infof(data, "Forcing HTTP/1.1 for NTLM");
+ connclose(conn, "Force HTTP/1.1 connection");
+ conn->data->set.httpversion = CURL_HTTP_VERSION_1_1;
+ }
}
if(conn->bits.proxy_user_passwd &&
((data->req.httpcode == 407) ||
(conn->bits.authneg && data->req.httpcode < 300))) {
- pickproxy = pickoneauth(&data->state.authproxy);
+ pickproxy = pickoneauth(&data->state.authproxy,
+ authmask & ~CURLAUTH_BEARER);
if(!pickproxy)
data->state.authproblem = TRUE;
}
if(pickhost || pickproxy) {
- /* In case this is GSS auth, the newurl field is already allocated so
- we must make sure to free it before allocating a new one. As figured
- out in bug #2284386 */
- Curl_safefree(data->req.newurl);
- data->req.newurl = strdup(data->change.url); /* clone URL */
- if(!data->req.newurl)
- return CURLE_OUT_OF_MEMORY;
-
if((data->set.httpreq != HTTPREQ_GET) &&
(data->set.httpreq != HTTPREQ_HEAD) &&
!conn->bits.rewindaftersend) {
@@ -533,6 +588,13 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
if(result)
return result;
}
+ /* In case this is GSS auth, the newurl field is already allocated so
+ we must make sure to free it before allocating a new one. As figured
+ out in bug #2284386 */
+ Curl_safefree(data->req.newurl);
+ data->req.newurl = strdup(data->change.url); /* clone URL */
+ if(!data->req.newurl)
+ return CURLE_OUT_OF_MEMORY;
}
else if((data->req.httpcode < 300) &&
(!data->state.authhost.done) &&
@@ -558,6 +620,7 @@ CURLcode Curl_http_auth_act(struct connectdata *conn)
return result;
}
+#ifndef CURL_DISABLE_HTTP_AUTH
/*
* Output the correct authentication header depending on the auth type
* and whether or not it is to a proxy.
@@ -574,10 +637,6 @@ output_auth_headers(struct connectdata *conn,
#if !defined(CURL_DISABLE_VERBOSE_STRINGS) || defined(USE_SPNEGO)
struct Curl_easy *data = conn->data;
#endif
-#ifdef USE_SPNEGO
- struct negotiatedata *negdata = proxy ?
- &data->state.proxyneg : &data->state.negotiate;
-#endif
#ifdef CURL_DISABLE_CRYPTO_AUTH
(void)request;
@@ -585,15 +644,11 @@ output_auth_headers(struct connectdata *conn,
#endif
#ifdef USE_SPNEGO
- negdata->state = GSS_AUTHNONE;
- if((authstatus->picked == CURLAUTH_NEGOTIATE) &&
- negdata->context && !GSS_ERROR(negdata->status)) {
+ if((authstatus->picked == CURLAUTH_NEGOTIATE)) {
auth = "Negotiate";
result = Curl_output_negotiate(conn, proxy);
if(result)
return result;
- authstatus->done = TRUE;
- negdata->state = GSS_AUTHSENT;
}
else
#endif
@@ -608,7 +663,7 @@ output_auth_headers(struct connectdata *conn,
#endif
#if defined(USE_NTLM) && defined(NTLM_WB_ENABLED)
if(authstatus->picked == CURLAUTH_NTLM_WB) {
- auth="NTLM_WB";
+ auth = "NTLM_WB";
result = Curl_output_ntlm_wb(conn, proxy);
if(result)
return result;
@@ -630,9 +685,9 @@ output_auth_headers(struct connectdata *conn,
if(authstatus->picked == CURLAUTH_BASIC) {
/* Basic */
if((proxy && conn->bits.proxy_user_passwd &&
- !Curl_checkProxyheaders(conn, "Proxy-authorization:")) ||
+ !Curl_checkProxyheaders(conn, "Proxy-authorization")) ||
(!proxy && conn->bits.user_passwd &&
- !Curl_checkheaders(conn, "Authorization:"))) {
+ !Curl_checkheaders(conn, "Authorization"))) {
auth = "Basic";
result = http_output_basic(conn, proxy);
if(result)
@@ -643,6 +698,20 @@ output_auth_headers(struct connectdata *conn,
functions work that way */
authstatus->done = TRUE;
}
+ if(authstatus->picked == CURLAUTH_BEARER) {
+ /* Bearer */
+ if((!proxy && conn->oauth_bearer &&
+ !Curl_checkheaders(conn, "Authorization:"))) {
+ auth = "Bearer";
+ result = http_output_bearer(conn);
+ if(result)
+ return result;
+ }
+
+ /* NOTE: this function should set 'done' TRUE, as the other auth
+ functions work that way */
+ authstatus->done = TRUE;
+ }
if(auth) {
infof(data, "%s auth using %s with user '%s'\n",
@@ -665,7 +734,7 @@ output_auth_headers(struct connectdata *conn,
*
* @param conn all information about the current connection
* @param request pointer to the request keyword
- * @param path pointer to the requested path
+ * @param path pointer to the requested path; should include query part
* @param proxytunnel boolean if this is the request setting up a "proxy
* tunnel"
*
@@ -689,7 +758,7 @@ Curl_http_output_auth(struct connectdata *conn,
authproxy = &data->state.authproxy;
if((conn->bits.httpproxy && conn->bits.proxy_user_passwd) ||
- conn->bits.user_passwd)
+ conn->bits.user_passwd || conn->oauth_bearer)
/* continue please */;
else {
authhost->done = TRUE;
@@ -712,7 +781,7 @@ Curl_http_output_auth(struct connectdata *conn,
#ifndef CURL_DISABLE_PROXY
/* Send proxy authentication header if needed */
if(conn->bits.httpproxy &&
- (conn->bits.tunnel_proxy == proxytunnel)) {
+ (conn->bits.tunnel_proxy == (bit)proxytunnel)) {
result = output_auth_headers(conn, authproxy, request, path, TRUE);
if(result)
return result;
@@ -730,7 +799,7 @@ Curl_http_output_auth(struct connectdata *conn,
if(!data->state.this_is_a_follow ||
conn->bits.netrc ||
!data->state.first_host ||
- data->set.http_disable_hostname_check_before_authentication ||
+ data->set.allow_auth_to_other_hosts ||
strcasecompare(data->state.first_host, conn->host.name)) {
result = output_auth_headers(conn, authhost, request, path, FALSE);
}
@@ -740,6 +809,22 @@ Curl_http_output_auth(struct connectdata *conn,
return result;
}
+#else
+/* when disabled */
+CURLcode
+Curl_http_output_auth(struct connectdata *conn,
+ const char *request,
+ const char *path,
+ bool proxytunnel)
+{
+ (void)conn;
+ (void)request;
+ (void)path;
+ (void)proxytunnel;
+ return CURLE_OK;
+}
+#endif
+
/*
* Curl_http_input_auth() deals with Proxy-Authenticate: and WWW-Authenticate:
* headers. They are dealt with both in the transfer.c main loop and in the
@@ -755,8 +840,8 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy,
struct Curl_easy *data = conn->data;
#ifdef USE_SPNEGO
- struct negotiatedata *negdata = proxy?
- &data->state.proxyneg:&data->state.negotiate;
+ curlnegotiate *negstate = proxy ? &conn->proxy_negotiate_state :
+ &conn->http_negotiate_state;
#endif
unsigned long *availp;
struct auth *authp;
@@ -795,21 +880,18 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy,
authp->avail |= CURLAUTH_NEGOTIATE;
if(authp->picked == CURLAUTH_NEGOTIATE) {
- if(negdata->state == GSS_AUTHSENT ||
- negdata->state == GSS_AUTHNONE) {
- CURLcode result = Curl_input_negotiate(conn, proxy, auth);
- if(!result) {
- DEBUGASSERT(!data->req.newurl);
- data->req.newurl = strdup(data->change.url);
- if(!data->req.newurl)
- return CURLE_OUT_OF_MEMORY;
- data->state.authproblem = FALSE;
- /* we received a GSS auth token and we dealt with it fine */
- negdata->state = GSS_AUTHRECV;
- }
- else
- data->state.authproblem = TRUE;
+ CURLcode result = Curl_input_negotiate(conn, proxy, auth);
+ if(!result) {
+ DEBUGASSERT(!data->req.newurl);
+ data->req.newurl = strdup(data->change.url);
+ if(!data->req.newurl)
+ return CURLE_OUT_OF_MEMORY;
+ data->state.authproblem = FALSE;
+ /* we received a GSS auth token and we dealt with it fine */
+ *negstate = GSS_AUTHRECV;
}
+ else
+ data->state.authproblem = TRUE;
}
}
}
@@ -837,19 +919,10 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy,
*availp |= CURLAUTH_NTLM_WB;
authp->avail |= CURLAUTH_NTLM_WB;
- /* Get the challenge-message which will be passed to
- * ntlm_auth for generating the type 3 message later */
- while(*auth && ISSPACE(*auth))
- auth++;
- if(checkprefix("NTLM", auth)) {
- auth += strlen("NTLM");
- while(*auth && ISSPACE(*auth))
- auth++;
- if(*auth) {
- conn->challenge_header = strdup(auth);
- if(!conn->challenge_header)
- return CURLE_OUT_OF_MEMORY;
- }
+ result = Curl_input_ntlm_wb(conn, proxy, auth);
+ if(result) {
+ infof(data, "Authentication problem. Ignoring this.\n");
+ data->state.authproblem = TRUE;
}
}
#endif
@@ -898,6 +971,18 @@ CURLcode Curl_http_input_auth(struct connectdata *conn, bool proxy,
data->state.authproblem = TRUE;
}
}
+ else
+ if(checkprefix("Bearer", auth)) {
+ *availp |= CURLAUTH_BEARER;
+ authp->avail |= CURLAUTH_BEARER;
+ if(authp->picked == CURLAUTH_BEARER) {
+ /* We asked for Bearer authentication but got a 40X back
+ anyway, which basically means our token isn't valid. */
+ authp->avail = CURLAUTH_NONE;
+ infof(data, "Authentication problem. Ignoring this.\n");
+ data->state.authproblem = TRUE;
+ }
+ }
/* there may be multiple methods on one line, so keep reading */
while(*auth && *auth != ',') /* read up to the next comma */
@@ -1020,7 +1105,7 @@ static size_t readmoredata(char *buffer,
http->sending++; /* move one step up */
- http->backup.postsize=0;
+ http->backup.postsize = 0;
}
else
http->postsize = 0;
@@ -1049,11 +1134,13 @@ Curl_send_buffer *Curl_add_buffer_init(void)
/*
* Curl_add_buffer_free() frees all associated resources.
*/
-void Curl_add_buffer_free(Curl_send_buffer *buff)
+void Curl_add_buffer_free(Curl_send_buffer **inp)
{
- if(buff) /* deal with NULL input */
- free(buff->buffer);
- free(buff);
+ Curl_send_buffer *in = *inp;
+ if(in) /* deal with NULL input */
+ free(in->buffer);
+ free(in);
+ *inp = NULL;
}
/*
@@ -1062,26 +1149,27 @@ void Curl_add_buffer_free(Curl_send_buffer *buff)
*
* Returns CURLcode
*/
-CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
+CURLcode Curl_add_buffer_send(Curl_send_buffer **inp,
struct connectdata *conn,
- /* add the number of sent bytes to this
- counter */
- long *bytes_written,
+ /* add the number of sent bytes to this
+ counter */
+ curl_off_t *bytes_written,
- /* how much of the buffer contains body data */
+ /* how much of the buffer contains body data */
size_t included_body_bytes,
int socketindex)
-
{
ssize_t amount;
CURLcode result;
char *ptr;
size_t size;
- struct HTTP *http = conn->data->req.protop;
+ struct Curl_easy *data = conn->data;
+ struct HTTP *http = data->req.protop;
size_t sendsize;
curl_socket_t sockfd;
size_t headersize;
+ Curl_send_buffer *in = *inp;
DEBUGASSERT(socketindex <= SECONDARYSOCKET);
@@ -1098,11 +1186,11 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
DEBUGASSERT(size > included_body_bytes);
- result = Curl_convert_to_network(conn->data, ptr, headersize);
+ result = Curl_convert_to_network(data, ptr, headersize);
/* Curl_convert_to_network calls failf if unsuccessful */
if(result) {
/* conversion failed, free memory and return to the caller */
- Curl_add_buffer_free(in);
+ Curl_add_buffer_free(inp);
return result;
}
@@ -1123,8 +1211,14 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
must copy the data to the uploadbuffer first, since that is the buffer
we will be using if this send is retried later.
*/
- memcpy(conn->data->state.uploadbuffer, ptr, sendsize);
- ptr = conn->data->state.uploadbuffer;
+ result = Curl_get_upload_buffer(data);
+ if(result) {
+ /* malloc failed, free memory and return to the caller */
+ Curl_add_buffer_free(&in);
+ return result;
+ }
+ memcpy(data->state.ulbuf, ptr, sendsize);
+ ptr = data->state.ulbuf;
}
else
sendsize = size;
@@ -1141,14 +1235,14 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
size_t headlen = (size_t)amount>headersize ? headersize : (size_t)amount;
size_t bodylen = amount - headlen;
- if(conn->data->set.verbose) {
+ if(data->set.verbose) {
/* this data _may_ contain binary stuff */
- Curl_debug(conn->data, CURLINFO_HEADER_OUT, ptr, headlen, conn);
+ Curl_debug(data, CURLINFO_HEADER_OUT, ptr, headlen);
if(bodylen) {
/* there was body data sent beyond the initial header part, pass that
on to the debug callback too */
- Curl_debug(conn->data, CURLINFO_DATA_OUT,
- ptr+headlen, bodylen, conn);
+ Curl_debug(data, CURLINFO_DATA_OUT,
+ ptr + headlen, bodylen);
}
}
@@ -1160,7 +1254,8 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
if(http) {
/* if we sent a piece of the body here, up the byte counter for it
accordingly */
- http->writebytecount += bodylen;
+ data->req.writebytecount += bodylen;
+ Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
if((size_t)amount != size) {
/* The whole request could not be sent in one system call. We must
@@ -1172,14 +1267,14 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
ptr = in->buffer + amount;
/* backup the currently set pointers */
- http->backup.fread_func = conn->data->state.fread_func;
- http->backup.fread_in = conn->data->state.in;
+ http->backup.fread_func = data->state.fread_func;
+ http->backup.fread_in = data->state.in;
http->backup.postdata = http->postdata;
http->backup.postsize = http->postsize;
/* set the new pointers for the request-sending */
- conn->data->state.fread_func = (curl_read_callback)readmoredata;
- conn->data->state.in = (void *)conn;
+ data->state.fread_func = (curl_read_callback)readmoredata;
+ data->state.in = (void *)conn;
http->postdata = ptr;
http->postsize = (curl_off_t)size;
@@ -1201,10 +1296,9 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
This needs FIXing.
*/
return CURLE_SEND_ERROR;
- Curl_pipeline_leave_write(conn);
}
}
- Curl_add_buffer_free(in);
+ Curl_add_buffer_free(&in);
return result;
}
@@ -1213,32 +1307,35 @@ CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
/*
* add_bufferf() add the formatted input to the buffer.
*/
-CURLcode Curl_add_bufferf(Curl_send_buffer *in, const char *fmt, ...)
+CURLcode Curl_add_bufferf(Curl_send_buffer **inp, const char *fmt, ...)
{
char *s;
va_list ap;
+ Curl_send_buffer *in = *inp;
va_start(ap, fmt);
s = vaprintf(fmt, ap); /* this allocs a new string to append */
va_end(ap);
if(s) {
- CURLcode result = Curl_add_buffer(in, s, strlen(s));
+ CURLcode result = Curl_add_buffer(inp, s, strlen(s));
free(s);
return result;
}
/* If we failed, we cleanup the whole buffer and return error */
free(in->buffer);
free(in);
+ *inp = NULL;
return CURLE_OUT_OF_MEMORY;
}
/*
- * add_buffer() appends a memory chunk to the existing buffer
+ * Curl_add_buffer() appends a memory chunk to the existing buffer
*/
-CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size)
+CURLcode Curl_add_buffer(Curl_send_buffer **inp, const void *inptr,
+ size_t size)
{
char *new_rb;
- size_t new_size;
+ Curl_send_buffer *in = *inp;
if(~size < in->size_used) {
/* If resulting used size of send buffer would wrap size_t, cleanup
@@ -1246,21 +1343,22 @@ CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size)
size will fit into a single allocatable memory chunk */
Curl_safefree(in->buffer);
free(in);
+ *inp = NULL;
return CURLE_OUT_OF_MEMORY;
}
if(!in->buffer ||
((in->size_used + size) > (in->size_max - 1))) {
-
/* If current buffer size isn't enough to hold the result, use a
buffer size that doubles the required size. If this new size
would wrap size_t, then just use the largest possible one */
+ size_t new_size;
if((size > (size_t)-1 / 2) || (in->size_used > (size_t)-1 / 2) ||
(~(size * 2) < (in->size_used * 2)))
new_size = (size_t)-1;
else
- new_size = (in->size_used+size) * 2;
+ new_size = (in->size_used + size) * 2;
if(in->buffer)
/* we have a buffer, enlarge the existing one */
@@ -1272,6 +1370,7 @@ CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size)
if(!new_rb) {
/* If we failed, we cleanup the whole buffer and return error */
free(in);
+ *inp = NULL;
return CURLE_OUT_OF_MEMORY;
}
@@ -1337,7 +1436,7 @@ Curl_compareheader(const char *headerline, /* line to check */
clen = strlen(content); /* length of the word to find */
/* find the content string in the rest of the line */
- for(;len>=clen;len--, start++) {
+ for(; len >= clen; len--, start++) {
if(strncasecompare(start, content, clen))
return TRUE; /* match! */
}
@@ -1369,10 +1468,19 @@ CURLcode Curl_http_connect(struct connectdata *conn, bool *done)
if(CONNECT_FIRSTSOCKET_PROXY_SSL())
return CURLE_OK; /* wait for HTTPS proxy SSL initialization to complete */
- if(conn->tunnel_state[FIRSTSOCKET] == TUNNEL_CONNECT)
+ if(Curl_connect_ongoing(conn))
/* nothing else to do except wait right now - we're not done here. */
return CURLE_OK;
+#ifndef CURL_DISABLE_PROXY
+ if(conn->data->set.haproxyprotocol) {
+ /* add HAProxy PROXY protocol header */
+ result = add_haproxy_protocol_header(conn);
+ if(result)
+ return result;
+ }
+#endif
+
if(conn->given->protocol & CURLPROTO_HTTPS) {
/* perform SSL initialization */
result = https_connecting(conn, done);
@@ -1398,6 +1506,49 @@ static int http_getsock_do(struct connectdata *conn,
return GETSOCK_WRITESOCK(0);
}
+#ifndef CURL_DISABLE_PROXY
+static CURLcode add_haproxy_protocol_header(struct connectdata *conn)
+{
+ char proxy_header[128];
+ Curl_send_buffer *req_buffer;
+ CURLcode result;
+ char tcp_version[5];
+
+ /* Emit the correct prefix for IPv6 */
+ if(conn->bits.ipv6) {
+ strcpy(tcp_version, "TCP6");
+ }
+ else {
+ strcpy(tcp_version, "TCP4");
+ }
+
+ msnprintf(proxy_header,
+ sizeof(proxy_header),
+ "PROXY %s %s %s %li %li\r\n",
+ tcp_version,
+ conn->data->info.conn_local_ip,
+ conn->data->info.conn_primary_ip,
+ conn->data->info.conn_local_port,
+ conn->data->info.conn_primary_port);
+
+ req_buffer = Curl_add_buffer_init();
+ if(!req_buffer)
+ return CURLE_OUT_OF_MEMORY;
+
+ result = Curl_add_bufferf(&req_buffer, proxy_header);
+ if(result)
+ return result;
+
+ result = Curl_add_buffer_send(&req_buffer,
+ conn,
+ &conn->data->info.request_size,
+ 0,
+ FIRSTSOCKET);
+
+ return result;
+}
+#endif
+
#ifdef USE_SSL
static CURLcode https_connecting(struct connectdata *conn, bool *done)
{
@@ -1440,20 +1591,6 @@ CURLcode Curl_http_done(struct connectdata *conn,
Curl_unencode_cleanup(conn);
-#ifdef USE_SPNEGO
- if(data->state.proxyneg.state == GSS_AUTHSENT ||
- data->state.negotiate.state == GSS_AUTHSENT) {
- /* add forbid re-use if http-code != 401/407 as a WA only needed for
- * 401/407 that signal auth failure (empty) otherwise state will be RECV
- * with current code.
- * Do not close CONNECT_ONLY connections. */
- if((data->req.httpcode != 401) && (data->req.httpcode != 407) &&
- !data->set.connect_only)
- streamclose(conn, "Negotiate transfer completed");
- Curl_cleanup_negotiate(data);
- }
-#endif
-
/* set the proper values (possibly modified on POST) */
conn->seek_func = data->set.seek_func; /* restore */
conn->seek_client = data->set.seek_client; /* restore */
@@ -1462,24 +1599,12 @@ CURLcode Curl_http_done(struct connectdata *conn,
return CURLE_OK;
if(http->send_buffer) {
- Curl_add_buffer_free(http->send_buffer);
- http->send_buffer = NULL; /* clear the pointer */
+ Curl_add_buffer_free(&http->send_buffer);
}
Curl_http2_done(conn, premature);
- if(HTTPREQ_POST_FORM == data->set.httpreq) {
- data->req.bytecount = http->readbytecount + http->writebytecount;
-
- Curl_formclean(&http->sendit); /* Now free that whole lot */
- if(http->form.fp) {
- /* a file being uploaded was left opened, close it! */
- fclose(http->form.fp);
- http->form.fp = NULL;
- }
- }
- else if(HTTPREQ_PUT == data->set.httpreq)
- data->req.bytecount = http->readbytecount + http->writebytecount;
+ Curl_mime_cleanpart(&http->form);
if(status)
return status;
@@ -1488,7 +1613,7 @@ CURLcode Curl_http_done(struct connectdata *conn,
entire operation is complete */
!conn->bits.retry &&
!data->set.connect_only &&
- (http->readbytecount +
+ (data->req.bytecount +
data->req.headerbytecount -
data->req.deductheadercount) <= 0) {
/* If this connection isn't simply closed to be retried, AND nothing was
@@ -1542,7 +1667,6 @@ static CURLcode expect100(struct Curl_easy *data,
Curl_send_buffer *req_buffer)
{
CURLcode result = CURLE_OK;
- const char *ptr;
data->state.expect100header = FALSE; /* default to false unless it is set
to TRUE below */
if(use_http_1_1plus(data, conn) &&
@@ -1550,14 +1674,14 @@ static CURLcode expect100(struct Curl_easy *data,
/* if not doing HTTP 1.0 or version 2, or disabled explicitly, we add an
Expect: 100-continue to the headers which actually speeds up post
operations (as there is one packet coming back from the web server) */
- ptr = Curl_checkheaders(conn, "Expect:");
+ const char *ptr = Curl_checkheaders(conn, "Expect");
if(ptr) {
data->state.expect100header =
Curl_compareheader(ptr, "Expect:", "100-continue");
}
else {
- result = Curl_add_bufferf(req_buffer,
- "Expect: 100-continue\r\n");
+ result = Curl_add_bufferf(&req_buffer,
+ "Expect: 100-continue\r\n");
if(!result)
data->state.expect100header = TRUE;
}
@@ -1572,6 +1696,50 @@ enum proxy_use {
HEADER_CONNECT /* sending CONNECT to a proxy */
};
+/* used to compile the provided trailers into one buffer
+ will return an error code if one of the headers is
+ not formatted correctly */
+CURLcode Curl_http_compile_trailers(struct curl_slist *trailers,
+ Curl_send_buffer *buffer,
+ struct Curl_easy *handle)
+{
+ char *ptr = NULL;
+ CURLcode result = CURLE_OK;
+ const char *endofline_native = NULL;
+ const char *endofline_network = NULL;
+
+ if(
+#ifdef CURL_DO_LINEEND_CONV
+ (handle->set.prefer_ascii) ||
+#endif
+ (handle->set.crlf)) {
+ /* \n will become \r\n later on */
+ endofline_native = "\n";
+ endofline_network = "\x0a";
+ }
+ else {
+ endofline_native = "\r\n";
+ endofline_network = "\x0d\x0a";
+ }
+
+ while(trailers) {
+ /* only add correctly formatted trailers */
+ ptr = strchr(trailers->data, ':');
+ if(ptr && *(ptr + 1) == ' ') {
+ result = Curl_add_bufferf(&buffer, "%s%s", trailers->data,
+ endofline_native);
+ if(result)
+ return result;
+ }
+ else
+ infof(handle, "Malformatted trailing header ! Skipping trailer.");
+ trailers = trailers->next;
+ }
+ result = Curl_add_buffer(&buffer, endofline_network,
+ strlen(endofline_network));
+ return result;
+}
+
CURLcode Curl_add_custom_headers(struct connectdata *conn,
bool is_connect,
Curl_send_buffer *req_buffer)
@@ -1579,7 +1747,7 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
char *ptr;
struct curl_slist *h[2];
struct curl_slist *headers;
- int numlists=1; /* by default */
+ int numlists = 1; /* by default */
struct Curl_easy *data = conn->data;
int i;
@@ -1611,11 +1779,43 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
}
/* loop through one or two lists */
- for(i=0; i < numlists; i++) {
+ for(i = 0; i < numlists; i++) {
headers = h[i];
while(headers) {
+ char *semicolonp = NULL;
ptr = strchr(headers->data, ':');
+ if(!ptr) {
+ char *optr;
+ /* no colon, semicolon? */
+ ptr = strchr(headers->data, ';');
+ if(ptr) {
+ optr = ptr;
+ ptr++; /* pass the semicolon */
+ while(*ptr && ISSPACE(*ptr))
+ ptr++;
+
+ if(*ptr) {
+ /* this may be used for something else in the future */
+ optr = NULL;
+ }
+ else {
+ if(*(--ptr) == ';') {
+ /* copy the source */
+ semicolonp = strdup(headers->data);
+ if(!semicolonp) {
+ Curl_add_buffer_free(&req_buffer);
+ return CURLE_OUT_OF_MEMORY;
+ }
+ /* put a colon where the semicolon is */
+ semicolonp[ptr - headers->data] = ':';
+ /* point at the colon */
+ optr = &semicolonp [ptr - headers->data];
+ }
+ }
+ ptr = optr;
+ }
+ }
if(ptr) {
/* we require a colon for this to be a true header */
@@ -1623,63 +1823,54 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
while(*ptr && ISSPACE(*ptr))
ptr++;
- if(*ptr) {
- /* only send this if the contents was non-blank */
+ if(*ptr || semicolonp) {
+ /* only send this if the contents was non-blank or done special */
+ CURLcode result = CURLE_OK;
+ char *compare = semicolonp ? semicolonp : headers->data;
if(conn->allocptr.host &&
/* a Host: header was sent already, don't pass on any custom Host:
header as that will produce *two* in the same request! */
- checkprefix("Host:", headers->data))
+ checkprefix("Host:", compare))
;
else if(data->set.httpreq == HTTPREQ_POST_FORM &&
/* this header (extended by formdata.c) is sent later */
- checkprefix("Content-Type:", headers->data))
+ checkprefix("Content-Type:", compare))
+ ;
+ else if(data->set.httpreq == HTTPREQ_POST_MIME &&
+ /* this header is sent later */
+ checkprefix("Content-Type:", compare))
;
else if(conn->bits.authneg &&
/* while doing auth neg, don't allow the custom length since
we will force length zero then */
- checkprefix("Content-Length", headers->data))
+ checkprefix("Content-Length:", compare))
;
else if(conn->allocptr.te &&
/* when asking for Transfer-Encoding, don't pass on a custom
Connection: */
- checkprefix("Connection", headers->data))
+ checkprefix("Connection:", compare))
;
else if((conn->httpversion == 20) &&
- checkprefix("Transfer-Encoding:", headers->data))
+ checkprefix("Transfer-Encoding:", compare))
/* HTTP/2 doesn't support chunked requests */
;
+ else if((checkprefix("Authorization:", compare) ||
+ checkprefix("Cookie:", compare)) &&
+ /* be careful of sending this potentially sensitive header to
+ other hosts */
+ (data->state.this_is_a_follow &&
+ data->state.first_host &&
+ !data->set.allow_auth_to_other_hosts &&
+ !strcasecompare(data->state.first_host, conn->host.name)))
+ ;
else {
- CURLcode result = Curl_add_bufferf(req_buffer, "%s\r\n",
- headers->data);
- if(result)
- return result;
- }
- }
- }
- else {
- ptr = strchr(headers->data, ';');
- if(ptr) {
-
- ptr++; /* pass the semicolon */
- while(*ptr && ISSPACE(*ptr))
- ptr++;
-
- if(*ptr) {
- /* this may be used for something else in the future */
- }
- else {
- if(*(--ptr) == ';') {
- CURLcode result;
-
- /* send no-value custom header if terminated by semicolon */
- *ptr = ':';
- result = Curl_add_bufferf(req_buffer, "%s\r\n",
- headers->data);
- if(result)
- return result;
- }
+ result = Curl_add_bufferf(&req_buffer, "%s\r\n", compare);
}
+ if(semicolonp)
+ free(semicolonp);
+ if(result)
+ return result;
}
}
headers = headers->next;
@@ -1689,6 +1880,7 @@ CURLcode Curl_add_custom_headers(struct connectdata *conn,
return CURLE_OK;
}
+#ifndef CURL_DISABLE_PARSEDATE
CURLcode Curl_add_timecondition(struct Curl_easy *data,
Curl_send_buffer *req_buffer)
{
@@ -1732,21 +1924,31 @@ CURLcode Curl_add_timecondition(struct Curl_easy *data,
*/
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
- snprintf(datestr, sizeof(datestr),
- "%s: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
- condp,
- Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
- tm->tm_mday,
- Curl_month[tm->tm_mon],
- tm->tm_year + 1900,
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec);
-
- result = Curl_add_buffer(req_buffer, datestr, strlen(datestr));
+ msnprintf(datestr, sizeof(datestr),
+ "%s: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
+ condp,
+ Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
+ tm->tm_mday,
+ Curl_month[tm->tm_mon],
+ tm->tm_year + 1900,
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec);
+
+ result = Curl_add_buffer(&req_buffer, datestr, strlen(datestr));
return result;
}
+#else
+/* disabled */
+CURLcode Curl_add_timecondition(struct Curl_easy *data,
+ Curl_send_buffer *req_buffer)
+{
+ (void)data;
+ (void)req_buffer;
+ return CURLE_OK;
+}
+#endif
/*
* Curl_http() gets called from the generic multi_do() function when a HTTP
@@ -1758,7 +1960,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
struct Curl_easy *data = conn->data;
CURLcode result = CURLE_OK;
struct HTTP *http;
- const char *ppath = data->state.path;
+ const char *path = data->state.up.path;
+ const char *query = data->state.up.query;
bool paste_ftp_userpwd = FALSE;
char ftp_typecode[sizeof("/;type=?")] = "";
const char *host = conn->host.name;
@@ -1773,7 +1976,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
const char *httpstring;
Curl_send_buffer *req_buffer;
curl_off_t postsize = 0; /* curl_off_t to handle large file sizes */
- int seekerr = CURL_SEEKFUNC_OK;
/* Always consider the DO phase done after this function call, even if there
may be parts of the request that is not yet sent, since we can deal with
@@ -1798,6 +2000,13 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
#ifdef USE_NGHTTP2
if(conn->data->set.httpversion ==
CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE) {
+ if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
+ /* We don't support HTTP/2 proxies yet. Also it's debatable whether
+ or not this setting should apply to HTTP/2 proxies. */
+ infof(data, "Ignoring HTTP/2 prior knowledge due to proxy\n");
+ break;
+ }
+
DEBUGF(infof(data, "HTTP/2 over clean TCP\n"));
conn->httpversion = 20;
@@ -1817,6 +2026,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
http = data->req.protop;
+ DEBUGASSERT(http);
if(!data->state.this_is_a_follow) {
/* Free to avoid leaking memory on multiple requests*/
@@ -1828,7 +2038,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
data->state.first_remote_port = conn->remote_port;
}
- http->writebytecount = http->readbytecount = 0;
if((conn->handler->protocol&(PROTO_FAMILY_HTTP|CURLPROTO_FTP)) &&
data->set.upload) {
@@ -1846,11 +2055,15 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
switch(httpreq) {
case HTTPREQ_POST:
case HTTPREQ_POST_FORM:
+ case HTTPREQ_POST_MIME:
request = "POST";
break;
case HTTPREQ_PUT:
request = "PUT";
break;
+ case HTTPREQ_OPTIONS:
+ request = "OPTIONS";
+ break;
default: /* this should never happen */
case HTTPREQ_GET:
request = "GET";
@@ -1866,17 +2079,27 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
it might have been used in the proxy connect, but if we have got a header
with the user-agent string specified, we erase the previously made string
here. */
- if(Curl_checkheaders(conn, "User-Agent:")) {
+ if(Curl_checkheaders(conn, "User-Agent")) {
free(conn->allocptr.uagent);
- conn->allocptr.uagent=NULL;
+ conn->allocptr.uagent = NULL;
}
/* setup the authentication headers */
- result = Curl_http_output_auth(conn, request, ppath, FALSE);
- if(result)
- return result;
+ {
+ char *pq = NULL;
+ if(query && *query) {
+ pq = aprintf("%s?%s", path, query);
+ if(!pq)
+ return CURLE_OUT_OF_MEMORY;
+ }
+ result = Curl_http_output_auth(conn, request, (pq ? pq : path), FALSE);
+ free(pq);
+ if(result)
+ return result;
+ }
- if((data->state.authhost.multipass || data->state.authproxy.multipass) &&
+ if(((data->state.authhost.multipass && !data->state.authhost.done)
+ || (data->state.authproxy.multipass && !data->state.authproxy.done)) &&
(httpreq != HTTPREQ_GET) &&
(httpreq != HTTPREQ_HEAD)) {
/* Auth is required and we are not authenticated yet. Make a PUT or POST
@@ -1887,7 +2110,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
conn->bits.authneg = FALSE;
Curl_safefree(conn->allocptr.ref);
- if(data->change.referer && !Curl_checkheaders(conn, "Referer:")) {
+ if(data->change.referer && !Curl_checkheaders(conn, "Referer")) {
conn->allocptr.ref = aprintf("Referer: %s\r\n", data->change.referer);
if(!conn->allocptr.ref)
return CURLE_OUT_OF_MEMORY;
@@ -1896,11 +2119,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
conn->allocptr.ref = NULL;
#if !defined(CURL_DISABLE_COOKIES)
- if(data->set.str[STRING_COOKIE] && !Curl_checkheaders(conn, "Cookie:"))
+ if(data->set.str[STRING_COOKIE] && !Curl_checkheaders(conn, "Cookie"))
addcookies = data->set.str[STRING_COOKIE];
#endif
- if(!Curl_checkheaders(conn, "Accept-Encoding:") &&
+ if(!Curl_checkheaders(conn, "Accept-Encoding") &&
data->set.str[STRING_ENCODING]) {
Curl_safefree(conn->allocptr.accept_encoding);
conn->allocptr.accept_encoding =
@@ -1916,37 +2139,89 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
#ifdef HAVE_LIBZ
/* we only consider transfer-encoding magic if libz support is built-in */
- if(!Curl_checkheaders(conn, "TE:") &&
+ if(!Curl_checkheaders(conn, "TE") &&
data->set.http_transfer_encoding) {
/* When we are to insert a TE: header in the request, we must also insert
TE in a Connection: header, so we need to merge the custom provided
Connection: header and prevent the original to get sent. Note that if
the user has inserted his/hers own TE: header we don't do this magic
but then assume that the user will handle it all! */
- char *cptr = Curl_checkheaders(conn, "Connection:");
+ char *cptr = Curl_checkheaders(conn, "Connection");
#define TE_HEADER "TE: gzip\r\n"
Curl_safefree(conn->allocptr.te);
+ if(cptr) {
+ cptr = Curl_copy_header_value(cptr);
+ if(!cptr)
+ return CURLE_OUT_OF_MEMORY;
+ }
+
/* Create the (updated) Connection: header */
- conn->allocptr.te = cptr? aprintf("%s, TE\r\n" TE_HEADER, cptr):
- strdup("Connection: TE\r\n" TE_HEADER);
+ conn->allocptr.te = aprintf("Connection: %s%sTE\r\n" TE_HEADER,
+ cptr ? cptr : "", (cptr && *cptr) ? ", ":"");
+ free(cptr);
if(!conn->allocptr.te)
return CURLE_OUT_OF_MEMORY;
}
#endif
- ptr = Curl_checkheaders(conn, "Transfer-Encoding:");
+ switch(httpreq) {
+ case HTTPREQ_POST_MIME:
+ http->sendit = &data->set.mimepost;
+ break;
+ case HTTPREQ_POST_FORM:
+ /* Convert the form structure into a mime structure. */
+ Curl_mime_cleanpart(&http->form);
+ result = Curl_getformdata(data, &http->form, data->set.httppost,
+ data->state.fread_func);
+ if(result)
+ return result;
+ http->sendit = &http->form;
+ break;
+ default:
+ http->sendit = NULL;
+ }
+
+#ifndef CURL_DISABLE_MIME
+ if(http->sendit) {
+ const char *cthdr = Curl_checkheaders(conn, "Content-Type");
+
+ /* Read and seek body only. */
+ http->sendit->flags |= MIME_BODY_ONLY;
+
+ /* Prepare the mime structure headers & set content type. */
+
+ if(cthdr)
+ for(cthdr += 13; *cthdr == ' '; cthdr++)
+ ;
+ else if(http->sendit->kind == MIMEKIND_MULTIPART)
+ cthdr = "multipart/form-data";
+
+ curl_mime_headers(http->sendit, data->set.headers, 0);
+ result = Curl_mime_prepare_headers(http->sendit, cthdr,
+ NULL, MIMESTRATEGY_FORM);
+ curl_mime_headers(http->sendit, NULL, 0);
+ if(!result)
+ result = Curl_mime_rewind(http->sendit);
+ if(result)
+ return result;
+ http->postsize = Curl_mime_size(http->sendit);
+ }
+#endif
+
+ ptr = Curl_checkheaders(conn, "Transfer-Encoding");
if(ptr) {
/* Some kind of TE is requested, check if 'chunked' is chosen */
data->req.upload_chunky =
Curl_compareheader(ptr, "Transfer-Encoding:", "chunked");
}
else {
- if((conn->handler->protocol&PROTO_FAMILY_HTTP) &&
- data->set.upload &&
- (data->state.infilesize == -1)) {
+ if((conn->handler->protocol & PROTO_FAMILY_HTTP) &&
+ (((httpreq == HTTPREQ_POST_MIME || httpreq == HTTPREQ_POST_FORM) &&
+ http->postsize < 0) ||
+ (data->set.upload && data->state.infilesize == -1))) {
if(conn->bits.authneg)
/* don't enable chunked during auth neg */
;
@@ -1970,7 +2245,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
Curl_safefree(conn->allocptr.host);
- ptr = Curl_checkheaders(conn, "Host:");
+ ptr = Curl_checkheaders(conn, "Host");
if(ptr && (!data->state.this_is_a_follow ||
strcasecompare(data->state.first_host, conn->host.name))) {
#if !defined(CURL_DISABLE_COOKIES)
@@ -1988,7 +2263,6 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
else {
/* If the host begins with '[', we start searching for the port after
the bracket has been closed */
- int startsearch = 0;
if(*cookiehost == '[') {
char *closingbracket;
/* since the 'cookiehost' is an allocated memory area that will be
@@ -1999,6 +2273,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
*closingbracket = 0;
}
else {
+ int startsearch = 0;
char *colon = strchr(cookiehost + startsearch, ':');
if(colon)
*colon = 0; /* The host must not include an embedded port number */
@@ -2009,7 +2284,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
#endif
if(strcmp("Host:", ptr)) {
- conn->allocptr.host = aprintf("%s\r\n", ptr);
+ conn->allocptr.host = aprintf("Host:%s\r\n", &ptr[5]);
if(!conn->allocptr.host)
return CURLE_OUT_OF_MEMORY;
}
@@ -2032,7 +2307,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
host,
conn->bits.ipv6_ip?"]":"");
else
- conn->allocptr.host = aprintf("Host: %s%s%s:%hu\r\n",
+ conn->allocptr.host = aprintf("Host: %s%s%s:%d\r\n",
conn->bits.ipv6_ip?"[":"",
host,
conn->bits.ipv6_ip?"]":"",
@@ -2044,53 +2319,65 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
#ifndef CURL_DISABLE_PROXY
- if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
+ if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
/* Using a proxy but does not tunnel through it */
/* The path sent to the proxy is in fact the entire URL. But if the remote
host is a IDN-name, we must make sure that the request we produce only
uses the encoded host name! */
+
+ /* and no fragment part */
+ CURLUcode uc;
+ char *url;
+ CURLU *h = curl_url_dup(data->state.uh);
+ if(!h)
+ return CURLE_OUT_OF_MEMORY;
+
if(conn->host.dispname != conn->host.name) {
- char *url = data->change.url;
- ptr = strstr(url, conn->host.dispname);
- if(ptr) {
- /* This is where the display name starts in the URL, now replace this
- part with the encoded name. TODO: This method of replacing the host
- name is rather crude as I believe there's a slight risk that the
- user has entered a user name or password that contain the host name
- string. */
- size_t currlen = strlen(conn->host.dispname);
- size_t newlen = strlen(conn->host.name);
- size_t urllen = strlen(url);
-
- char *newurl;
-
- newurl = malloc(urllen + newlen - currlen + 1);
- if(newurl) {
- /* copy the part before the host name */
- memcpy(newurl, url, ptr - url);
- /* append the new host name instead of the old */
- memcpy(newurl + (ptr - url), conn->host.name, newlen);
- /* append the piece after the host name */
- memcpy(newurl + newlen + (ptr - url),
- ptr + currlen, /* copy the trailing zero byte too */
- urllen - (ptr-url) - currlen + 1);
- if(data->change.url_alloc) {
- Curl_safefree(data->change.url);
- data->change.url_alloc = FALSE;
- }
- data->change.url = newurl;
- data->change.url_alloc = TRUE;
- }
- else
- return CURLE_OUT_OF_MEMORY;
+ uc = curl_url_set(h, CURLUPART_HOST, conn->host.name, 0);
+ if(uc) {
+ curl_url_cleanup(h);
+ return CURLE_OUT_OF_MEMORY;
+ }
+ }
+ uc = curl_url_set(h, CURLUPART_FRAGMENT, NULL, 0);
+ if(uc) {
+ curl_url_cleanup(h);
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ if(strcasecompare("http", data->state.up.scheme)) {
+ /* when getting HTTP, we don't want the userinfo the URL */
+ uc = curl_url_set(h, CURLUPART_USER, NULL, 0);
+ if(uc) {
+ curl_url_cleanup(h);
+ return CURLE_OUT_OF_MEMORY;
+ }
+ uc = curl_url_set(h, CURLUPART_PASSWORD, NULL, 0);
+ if(uc) {
+ curl_url_cleanup(h);
+ return CURLE_OUT_OF_MEMORY;
}
}
- ppath = data->change.url;
- if(checkprefix("ftp://", ppath)) {
+ /* now extract the new version of the URL */
+ uc = curl_url_get(h, CURLUPART_URL, &url, 0);
+ if(uc) {
+ curl_url_cleanup(h);
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ if(data->change.url_alloc)
+ free(data->change.url);
+
+ data->change.url = url;
+ data->change.url_alloc = TRUE;
+
+ curl_url_cleanup(h);
+
+ if(strcasecompare("ftp", data->state.up.scheme)) {
if(data->set.proxy_transfer_mode) {
/* when doing ftp, append ;type=<a|i> if not present */
- char *type = strstr(ppath, ";type=");
+ char *type = strstr(path, ";type=");
if(type && type[6] && type[7] == 0) {
switch(Curl_raw_toupper(type[6])) {
case 'A':
@@ -2105,11 +2392,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
char *p = ftp_typecode;
/* avoid sending invalid URLs like ftp://example.com;type=i if the
* user specified ftp://example.com without the slash */
- if(!*data->state.path && ppath[strlen(ppath) - 1] != '/') {
+ if(!*data->state.up.path && path[strlen(path) - 1] != '/') {
*p++ = '/';
}
- snprintf(p, sizeof(ftp_typecode) - 1, ";type=%c",
- data->set.prefer_ascii ? 'a' : 'i');
+ msnprintf(p, sizeof(ftp_typecode) - 1, ";type=%c",
+ data->set.prefer_ascii ? 'a' : 'i');
}
}
if(conn->bits.user_passwd && !conn->bits.userpwd_in_url)
@@ -2118,21 +2405,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
#endif /* CURL_DISABLE_PROXY */
- if(HTTPREQ_POST_FORM == httpreq) {
- /* we must build the whole post sequence first, so that we have a size of
- the whole transfer before we start to send it */
- result = Curl_getformdata(data, &http->sendit, data->set.httppost,
- Curl_checkheaders(conn, "Content-Type:"),
- &http->postsize);
- if(result)
- return result;
- }
-
- http->p_accept = Curl_checkheaders(conn, "Accept:")?NULL:"Accept: */*\r\n";
+ http->p_accept = Curl_checkheaders(conn, "Accept")?NULL:"Accept: */*\r\n";
- if(( (HTTPREQ_POST == httpreq) ||
- (HTTPREQ_POST_FORM == httpreq) ||
- (HTTPREQ_PUT == httpreq) ) &&
+ if((HTTPREQ_POST == httpreq || HTTPREQ_PUT == httpreq) &&
data->state.resume_from) {
/**********************************************************************
* Resuming upload in HTTP means that we PUT or POST and that we have
@@ -2140,6 +2415,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
* a Range: header that will be passed along. We need to "fast forward"
* the file the given number of bytes and decrease the assume upload
* file size before we continue this venture in the dark lands of HTTP.
+ * Resuming mime/form posting at an offset > 0 has no sense and is ignored.
*********************************************************************/
if(data->state.resume_from < 0) {
@@ -2155,13 +2431,16 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
/* Now, let's read off the proper amount of bytes from the
input. */
+ int seekerr = CURL_SEEKFUNC_CANTSEEK;
if(conn->seek_func) {
+ Curl_set_in_callback(data, true);
seekerr = conn->seek_func(conn->seek_client, data->state.resume_from,
SEEK_SET);
+ Curl_set_in_callback(data, false);
}
if(seekerr != CURL_SEEKFUNC_OK) {
- curl_off_t passed=0;
+ curl_off_t passed = 0;
if(seekerr != CURL_SEEKFUNC_CANTSEEK) {
failf(data, "Could not seek stream");
@@ -2208,14 +2487,14 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
* ones if any such are specified.
*/
if(((httpreq == HTTPREQ_GET) || (httpreq == HTTPREQ_HEAD)) &&
- !Curl_checkheaders(conn, "Range:")) {
+ !Curl_checkheaders(conn, "Range")) {
/* if a line like this was already allocated, free the previous one */
free(conn->allocptr.rangeline);
conn->allocptr.rangeline = aprintf("Range: bytes=%s\r\n",
data->state.range);
}
- else if((httpreq != HTTPREQ_GET) &&
- !Curl_checkheaders(conn, "Content-Range:")) {
+ else if((httpreq == HTTPREQ_POST || httpreq == HTTPREQ_PUT) &&
+ !Curl_checkheaders(conn, "Content-Range")) {
/* if a line like this was already allocated, free the previous one */
free(conn->allocptr.rangeline);
@@ -2232,7 +2511,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
else if(data->state.resume_from) {
/* This is because "resume" was selected */
- curl_off_t total_expected_size=
+ curl_off_t total_expected_size =
data->state.resume_from + data->state.infilesize;
conn->allocptr.rangeline =
aprintf("Content-Range: bytes %s%" CURL_FORMAT_CURL_OFF_T
@@ -2262,22 +2541,36 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
/* add the main request stuff */
/* GET/HEAD/POST/PUT */
- result = Curl_add_bufferf(req_buffer, "%s ", request);
+ result = Curl_add_bufferf(&req_buffer, "%s ", request);
if(result)
return result;
+ if(data->set.str[STRING_TARGET]) {
+ path = data->set.str[STRING_TARGET];
+ query = NULL;
+ }
+
/* url */
- if(paste_ftp_userpwd)
- result = Curl_add_bufferf(req_buffer, "ftp://%s:%s@%s",
+ if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) {
+ char *url = data->change.url;
+ result = Curl_add_buffer(&req_buffer, url, strlen(url));
+ }
+ else if(paste_ftp_userpwd)
+ result = Curl_add_bufferf(&req_buffer, "ftp://%s:%s@%s",
conn->user, conn->passwd,
- ppath + sizeof("ftp://") - 1);
- else
- result = Curl_add_buffer(req_buffer, ppath, strlen(ppath));
+ path + sizeof("ftp://") - 1);
+ else {
+ result = Curl_add_buffer(&req_buffer, path, strlen(path));
+ if(result)
+ return result;
+ if(query)
+ result = Curl_add_bufferf(&req_buffer, "?%s", query);
+ }
if(result)
return result;
result =
- Curl_add_bufferf(req_buffer,
+ Curl_add_bufferf(&req_buffer,
"%s" /* ftp typecode (;type=x) */
" HTTP/%s\r\n" /* HTTP version */
"%s" /* host */
@@ -2314,7 +2607,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
conn->allocptr.ref:"" /* Referer: <data> */,
(conn->bits.httpproxy &&
!conn->bits.tunnel_proxy &&
- !Curl_checkProxyheaders(conn, "Proxy-Connection:"))?
+ !Curl_checkProxyheaders(conn, "Proxy-Connection"))?
"Proxy-Connection: Keep-Alive\r\n":"",
te
);
@@ -2339,30 +2632,30 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
#if !defined(CURL_DISABLE_COOKIES)
if(data->cookies || addcookies) {
- struct Cookie *co=NULL; /* no cookies from start */
- int count=0;
+ struct Cookie *co = NULL; /* no cookies from start */
+ int count = 0;
if(data->cookies) {
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
co = Curl_cookie_getlist(data->cookies,
conn->allocptr.cookiehost?
conn->allocptr.cookiehost:host,
- data->state.path,
+ data->state.up.path,
(conn->handler->protocol&CURLPROTO_HTTPS)?
TRUE:FALSE);
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
}
if(co) {
- struct Cookie *store=co;
+ struct Cookie *store = co;
/* now loop through all cookies that matched */
while(co) {
if(co->value) {
if(0 == count) {
- result = Curl_add_bufferf(req_buffer, "Cookie: ");
+ result = Curl_add_bufferf(&req_buffer, "Cookie: ");
if(result)
break;
}
- result = Curl_add_bufferf(req_buffer,
+ result = Curl_add_bufferf(&req_buffer,
"%s%s=%s", count?"; ":"",
co->name, co->value);
if(result)
@@ -2375,15 +2668,15 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
if(addcookies && !result) {
if(!count)
- result = Curl_add_bufferf(req_buffer, "Cookie: ");
+ result = Curl_add_bufferf(&req_buffer, "Cookie: ");
if(!result) {
- result = Curl_add_bufferf(req_buffer, "%s%s", count?"; ":"",
+ result = Curl_add_bufferf(&req_buffer, "%s%s", count?"; ":"",
addcookies);
count++;
}
}
if(count && !result)
- result = Curl_add_buffer(req_buffer, "\r\n", 2);
+ result = Curl_add_buffer(&req_buffer, "\r\n", 2);
if(result)
return result;
@@ -2407,149 +2700,139 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
switch(httpreq) {
- case HTTPREQ_POST_FORM:
- if(!http->sendit || conn->bits.authneg) {
- /* nothing to post! */
- result = Curl_add_bufferf(req_buffer, "Content-Length: 0\r\n\r\n");
- if(result)
- return result;
-
- result = Curl_add_buffer_send(req_buffer, conn,
- &data->info.request_size, 0, FIRSTSOCKET);
- if(result)
- failf(data, "Failed sending POST request");
- else
- /* setup variables for the upcoming transfer */
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, &http->readbytecount,
- -1, NULL);
- break;
- }
-
- if(Curl_FormInit(&http->form, http->sendit)) {
- failf(data, "Internal HTTP POST error!");
- return CURLE_HTTP_POST_ERROR;
- }
-
- /* Get the currently set callback function pointer and store that in the
- form struct since we might want the actual user-provided callback later
- on. The data->set.fread_func pointer itself will be changed for the
- multipart case to the function that returns a multipart formatted
- stream. */
- http->form.fread_func = data->state.fread_func;
-
- /* Set the read function to read from the generated form data */
- data->state.fread_func = (curl_read_callback)Curl_FormReader;
- data->state.in = &http->form;
+ case HTTPREQ_PUT: /* Let's PUT the data to the server! */
- http->sending = HTTPSEND_BODY;
+ if(conn->bits.authneg)
+ postsize = 0;
+ else
+ postsize = data->state.infilesize;
- if(!data->req.upload_chunky &&
- !Curl_checkheaders(conn, "Content-Length:")) {
+ if((postsize != -1) && !data->req.upload_chunky &&
+ (conn->bits.authneg || !Curl_checkheaders(conn, "Content-Length"))) {
/* only add Content-Length if not uploading chunked */
- result = Curl_add_bufferf(req_buffer,
+ result = Curl_add_bufferf(&req_buffer,
"Content-Length: %" CURL_FORMAT_CURL_OFF_T
- "\r\n", http->postsize);
+ "\r\n", postsize);
if(result)
return result;
}
- result = expect100(data, conn, req_buffer);
- if(result)
- return result;
-
- {
-
- /* Get Content-Type: line from Curl_formpostheader.
- */
- char *contentType;
- size_t linelength=0;
- contentType = Curl_formpostheader((void *)&http->form,
- &linelength);
- if(!contentType) {
- failf(data, "Could not get Content-Type header line!");
- return CURLE_HTTP_POST_ERROR;
- }
-
- result = Curl_add_buffer(req_buffer, contentType, linelength);
+ if(postsize != 0) {
+ result = expect100(data, conn, req_buffer);
if(result)
return result;
}
- /* make the request end in a true CRLF */
- result = Curl_add_buffer(req_buffer, "\r\n", 2);
+ result = Curl_add_buffer(&req_buffer, "\r\n", 2); /* end of headers */
if(result)
return result;
- /* set upload size to the progress meter */
- Curl_pgrsSetUploadSize(data, http->postsize);
+ /* set the upload size to the progress meter */
+ Curl_pgrsSetUploadSize(data, postsize);
- /* fire away the whole request to the server */
- result = Curl_add_buffer_send(req_buffer, conn,
+ /* this sends the buffer and frees all the buffer resources */
+ result = Curl_add_buffer_send(&req_buffer, conn,
&data->info.request_size, 0, FIRSTSOCKET);
if(result)
- failf(data, "Failed sending POST request");
+ failf(data, "Failed sending PUT request");
else
- /* setup variables for the upcoming transfer */
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE,
- &http->readbytecount, FIRSTSOCKET,
- &http->writebytecount);
-
- if(result) {
- Curl_formclean(&http->sendit); /* free that whole lot */
- return result;
- }
-
- /* convert the form data */
- result = Curl_convert_form(data, http->sendit);
- if(result) {
- Curl_formclean(&http->sendit); /* free that whole lot */
+ /* prepare for transfer */
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, TRUE,
+ postsize?FIRSTSOCKET:-1);
+ if(result)
return result;
- }
-
break;
- case HTTPREQ_PUT: /* Let's PUT the data to the server! */
+ case HTTPREQ_POST_FORM:
+ case HTTPREQ_POST_MIME:
+ /* This is form posting using mime data. */
+ if(conn->bits.authneg) {
+ /* nothing to post! */
+ result = Curl_add_bufferf(&req_buffer, "Content-Length: 0\r\n\r\n");
+ if(result)
+ return result;
- if(conn->bits.authneg)
- postsize = 0;
- else
- postsize = data->state.infilesize;
+ result = Curl_add_buffer_send(&req_buffer, conn,
+ &data->info.request_size, 0, FIRSTSOCKET);
+ if(result)
+ failf(data, "Failed sending POST request");
+ else
+ /* setup variables for the upcoming transfer */
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, TRUE, -1);
+ break;
+ }
- if((postsize != -1) && !data->req.upload_chunky &&
- (conn->bits.authneg || !Curl_checkheaders(conn, "Content-Length:"))) {
- /* only add Content-Length if not uploading chunked */
- result = Curl_add_bufferf(req_buffer,
+ data->state.infilesize = postsize = http->postsize;
+
+ /* We only set Content-Length and allow a custom Content-Length if
+ we don't upload data chunked, as RFC2616 forbids us to set both
+ kinds of headers (Transfer-Encoding: chunked and Content-Length) */
+ if(postsize != -1 && !data->req.upload_chunky &&
+ (conn->bits.authneg || !Curl_checkheaders(conn, "Content-Length"))) {
+ /* we allow replacing this header if not during auth negotiation,
+ although it isn't very wise to actually set your own */
+ result = Curl_add_bufferf(&req_buffer,
"Content-Length: %" CURL_FORMAT_CURL_OFF_T
"\r\n", postsize);
if(result)
return result;
}
- if(postsize != 0) {
+#ifndef CURL_DISABLE_MIME
+ /* Output mime-generated headers. */
+ {
+ struct curl_slist *hdr;
+
+ for(hdr = http->sendit->curlheaders; hdr; hdr = hdr->next) {
+ result = Curl_add_bufferf(&req_buffer, "%s\r\n", hdr->data);
+ if(result)
+ return result;
+ }
+ }
+#endif
+
+ /* For really small posts we don't use Expect: headers at all, and for
+ the somewhat bigger ones we allow the app to disable it. Just make
+ sure that the expect100header is always set to the preferred value
+ here. */
+ ptr = Curl_checkheaders(conn, "Expect");
+ if(ptr) {
+ data->state.expect100header =
+ Curl_compareheader(ptr, "Expect:", "100-continue");
+ }
+ else if(postsize > EXPECT_100_THRESHOLD || postsize < 0) {
result = expect100(data, conn, req_buffer);
if(result)
return result;
}
+ else
+ data->state.expect100header = FALSE;
- result = Curl_add_buffer(req_buffer, "\r\n", 2); /* end of headers */
+ /* make the request end in a true CRLF */
+ result = Curl_add_buffer(&req_buffer, "\r\n", 2);
if(result)
return result;
/* set the upload size to the progress meter */
Curl_pgrsSetUploadSize(data, postsize);
+ /* Read from mime structure. */
+ data->state.fread_func = (curl_read_callback) Curl_mime_read;
+ data->state.in = (void *) http->sendit;
+ http->sending = HTTPSEND_BODY;
+
/* this sends the buffer and frees all the buffer resources */
- result = Curl_add_buffer_send(req_buffer, conn,
+ result = Curl_add_buffer_send(&req_buffer, conn,
&data->info.request_size, 0, FIRSTSOCKET);
if(result)
- failf(data, "Failed sending PUT request");
+ failf(data, "Failed sending POST request");
else
/* prepare for transfer */
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE,
- &http->readbytecount, postsize?FIRSTSOCKET:-1,
- postsize?&http->writebytecount:NULL);
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, TRUE,
+ postsize?FIRSTSOCKET:-1);
if(result)
return result;
+
break;
case HTTPREQ_POST:
@@ -2565,18 +2848,18 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
we don't upload data chunked, as RFC2616 forbids us to set both
kinds of headers (Transfer-Encoding: chunked and Content-Length) */
if((postsize != -1) && !data->req.upload_chunky &&
- (conn->bits.authneg || !Curl_checkheaders(conn, "Content-Length:"))) {
+ (conn->bits.authneg || !Curl_checkheaders(conn, "Content-Length"))) {
/* we allow replacing this header if not during auth negotiation,
although it isn't very wise to actually set your own */
- result = Curl_add_bufferf(req_buffer,
+ result = Curl_add_bufferf(&req_buffer,
"Content-Length: %" CURL_FORMAT_CURL_OFF_T
"\r\n", postsize);
if(result)
return result;
}
- if(!Curl_checkheaders(conn, "Content-Type:")) {
- result = Curl_add_bufferf(req_buffer,
+ if(!Curl_checkheaders(conn, "Content-Type")) {
+ result = Curl_add_bufferf(&req_buffer,
"Content-Type: application/"
"x-www-form-urlencoded\r\n");
if(result)
@@ -2587,12 +2870,12 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
the somewhat bigger ones we allow the app to disable it. Just make
sure that the expect100header is always set to the preferred value
here. */
- ptr = Curl_checkheaders(conn, "Expect:");
+ ptr = Curl_checkheaders(conn, "Expect");
if(ptr) {
data->state.expect100header =
Curl_compareheader(ptr, "Expect:", "100-continue");
}
- else if(postsize > TINY_INITIAL_POST_SIZE || postsize < 0) {
+ else if(postsize > EXPECT_100_THRESHOLD || postsize < 0) {
result = expect100(data, conn, req_buffer);
if(result)
return result;
@@ -2606,7 +2889,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
its size. */
if(conn->httpversion != 20 &&
!data->state.expect100header &&
- (postsize < MAX_INITIAL_POST_SIZE)) {
+ (postsize < MAX_INITIAL_POST_SIZE)) {
/* if we don't use expect: 100 AND
postsize is less than MAX_INITIAL_POST_SIZE
@@ -2614,31 +2897,31 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
is no magic limit but only set to prevent really huge POSTs to
get the data duplicated with malloc() and family. */
- result = Curl_add_buffer(req_buffer, "\r\n", 2); /* end of headers! */
+ result = Curl_add_buffer(&req_buffer, "\r\n", 2); /* end of headers! */
if(result)
return result;
if(!data->req.upload_chunky) {
/* We're not sending it 'chunked', append it to the request
already now to reduce the number if send() calls */
- result = Curl_add_buffer(req_buffer, data->set.postfields,
+ result = Curl_add_buffer(&req_buffer, data->set.postfields,
(size_t)postsize);
included_body = postsize;
}
else {
if(postsize) {
/* Append the POST data chunky-style */
- result = Curl_add_bufferf(req_buffer, "%x\r\n", (int)postsize);
+ result = Curl_add_bufferf(&req_buffer, "%x\r\n", (int)postsize);
if(!result) {
- result = Curl_add_buffer(req_buffer, data->set.postfields,
+ result = Curl_add_buffer(&req_buffer, data->set.postfields,
(size_t)postsize);
if(!result)
- result = Curl_add_buffer(req_buffer, "\r\n", 2);
+ result = Curl_add_buffer(&req_buffer, "\r\n", 2);
included_body = postsize + 2;
}
}
if(!result)
- result = Curl_add_buffer(req_buffer, "\x30\x0d\x0a\x0d\x0a", 5);
+ result = Curl_add_buffer(&req_buffer, "\x30\x0d\x0a\x0d\x0a", 5);
/* 0 CR LF CR LF */
included_body += 5;
}
@@ -2660,20 +2943,20 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
/* set the upload size to the progress meter */
Curl_pgrsSetUploadSize(data, http->postsize);
- result = Curl_add_buffer(req_buffer, "\r\n", 2); /* end of headers! */
+ result = Curl_add_buffer(&req_buffer, "\r\n", 2); /* end of headers! */
if(result)
return result;
}
}
else {
- result = Curl_add_buffer(req_buffer, "\r\n", 2); /* end of headers! */
+ result = Curl_add_buffer(&req_buffer, "\r\n", 2); /* end of headers! */
if(result)
return result;
if(data->req.upload_chunky && conn->bits.authneg) {
/* Chunky upload is selected and we're negotiating auth still, send
end-of-data only */
- result = Curl_add_buffer(req_buffer,
+ result = Curl_add_buffer(&req_buffer,
"\x30\x0d\x0a\x0d\x0a", 5);
/* 0 CR LF CR LF */
if(result)
@@ -2694,50 +2977,48 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
}
}
/* issue the request */
- result = Curl_add_buffer_send(req_buffer, conn, &data->info.request_size,
+ result = Curl_add_buffer_send(&req_buffer, conn, &data->info.request_size,
(size_t)included_body, FIRSTSOCKET);
if(result)
failf(data, "Failed sending HTTP POST request");
else
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE,
- &http->readbytecount, http->postdata?FIRSTSOCKET:-1,
- http->postdata?&http->writebytecount:NULL);
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, TRUE,
+ http->postdata?FIRSTSOCKET:-1);
break;
default:
- result = Curl_add_buffer(req_buffer, "\r\n", 2);
+ result = Curl_add_buffer(&req_buffer, "\r\n", 2);
if(result)
return result;
/* issue the request */
- result = Curl_add_buffer_send(req_buffer, conn,
+ result = Curl_add_buffer_send(&req_buffer, conn,
&data->info.request_size, 0, FIRSTSOCKET);
if(result)
failf(data, "Failed sending HTTP request");
else
/* HTTP GET/HEAD download: */
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, &http->readbytecount,
- http->postdata?FIRSTSOCKET:-1,
- http->postdata?&http->writebytecount:NULL);
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, TRUE,
+ http->postdata?FIRSTSOCKET:-1);
}
if(result)
return result;
- if(http->writebytecount) {
+ if(data->req.writebytecount) {
/* if a request-body has been sent off, we make sure this progress is noted
properly */
- Curl_pgrsSetUploadCounter(data, http->writebytecount);
+ Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
- if(http->writebytecount >= postsize) {
+ if(data->req.writebytecount >= postsize) {
/* already sent the entire request body, mark the "upload" as
complete */
infof(data, "upload completely sent off: %" CURL_FORMAT_CURL_OFF_T
" out of %" CURL_FORMAT_CURL_OFF_T " bytes\n",
- http->writebytecount, postsize);
+ data->req.writebytecount, postsize);
data->req.upload_done = TRUE;
data->req.keepon &= ~KEEP_SEND; /* we're done writing */
data->req.exp100 = EXP100_SEND_DATA; /* already sent */
@@ -2753,17 +3034,32 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
return result;
}
+typedef enum {
+ STATUS_UNKNOWN, /* not enough data to tell yet */
+ STATUS_DONE, /* a status line was read */
+ STATUS_BAD /* not a status line */
+} statusline;
+
+
+/* Check a string for a prefix. Check no more than 'len' bytes */
+static bool checkprefixmax(const char *prefix, const char *buffer, size_t len)
+{
+ size_t ch = CURLMIN(strlen(prefix), len);
+ return curl_strnequal(prefix, buffer, ch);
+}
+
/*
* checkhttpprefix()
*
* Returns TRUE if member of the list matches prefix of string
*/
-static bool
+static statusline
checkhttpprefix(struct Curl_easy *data,
- const char *s)
+ const char *s, size_t len)
{
struct curl_slist *head = data->set.http200aliases;
- bool rc = FALSE;
+ statusline rc = STATUS_BAD;
+ statusline onmatch = len >= 5? STATUS_DONE : STATUS_UNKNOWN;
#ifdef CURL_DOES_CONVERSIONS
/* convert from the network encoding using a scratch area */
char *scratch = strdup(s);
@@ -2771,7 +3067,7 @@ checkhttpprefix(struct Curl_easy *data,
failf(data, "Failed to allocate memory for conversion!");
return FALSE; /* can't return CURLE_OUT_OF_MEMORY so return FALSE */
}
- if(CURLE_OK != Curl_convert_from_network(data, scratch, strlen(s)+1)) {
+ if(CURLE_OK != Curl_convert_from_network(data, scratch, strlen(s) + 1)) {
/* Curl_convert_from_network calls failf if unsuccessful */
free(scratch);
return FALSE; /* can't return CURLE_foobar so return FALSE */
@@ -2780,15 +3076,15 @@ checkhttpprefix(struct Curl_easy *data,
#endif /* CURL_DOES_CONVERSIONS */
while(head) {
- if(checkprefix(head->data, s)) {
- rc = TRUE;
+ if(checkprefixmax(head->data, s, len)) {
+ rc = onmatch;
break;
}
head = head->next;
}
- if(!rc && (checkprefix("HTTP/", s)))
- rc = TRUE;
+ if((rc != STATUS_DONE) && (checkprefixmax("HTTP/", s, len)))
+ rc = onmatch;
#ifdef CURL_DOES_CONVERSIONS
free(scratch);
@@ -2797,10 +3093,12 @@ checkhttpprefix(struct Curl_easy *data,
}
#ifndef CURL_DISABLE_RTSP
-static bool
+static statusline
checkrtspprefix(struct Curl_easy *data,
- const char *s)
+ const char *s, size_t len)
{
+ statusline result = STATUS_BAD;
+ statusline onmatch = len >= 5? STATUS_DONE : STATUS_UNKNOWN;
#ifdef CURL_DOES_CONVERSIONS
/* convert from the network encoding using a scratch area */
@@ -2809,33 +3107,35 @@ checkrtspprefix(struct Curl_easy *data,
failf(data, "Failed to allocate memory for conversion!");
return FALSE; /* can't return CURLE_OUT_OF_MEMORY so return FALSE */
}
- if(CURLE_OK != Curl_convert_from_network(data, scratch, strlen(s)+1)) {
+ if(CURLE_OK != Curl_convert_from_network(data, scratch, strlen(s) + 1)) {
/* Curl_convert_from_network calls failf if unsuccessful */
- free(scratch);
- return FALSE; /* can't return CURLE_foobar so return FALSE */
+ result = FALSE; /* can't return CURLE_foobar so return FALSE */
}
- s = scratch;
+ else if(checkprefixmax("RTSP/", scratch, len))
+ result = onmatch;
+ free(scratch);
#else
(void)data; /* unused */
+ if(checkprefixmax("RTSP/", s, len))
+ result = onmatch;
#endif /* CURL_DOES_CONVERSIONS */
- if(checkprefix("RTSP/", s))
- return TRUE;
- return FALSE;
+
+ return result;
}
#endif /* CURL_DISABLE_RTSP */
-static bool
+static statusline
checkprotoprefix(struct Curl_easy *data, struct connectdata *conn,
- const char *s)
+ const char *s, size_t len)
{
#ifndef CURL_DISABLE_RTSP
if(conn->handler->protocol & CURLPROTO_RTSP)
- return checkrtspprefix(data, s);
+ return checkrtspprefix(data, s, len);
#else
(void)conn;
#endif /* CURL_DISABLE_RTSP */
- return checkhttpprefix(data, s);
+ return checkhttpprefix(data, s, len);
}
/*
@@ -2847,29 +3147,28 @@ static CURLcode header_append(struct Curl_easy *data,
struct SingleRequest *k,
size_t length)
{
- if(k->hbuflen + length >= data->state.headersize) {
+ size_t newsize = k->hbuflen + length;
+ if(newsize > CURL_MAX_HTTP_HEADER) {
+ /* The reason to have a max limit for this is to avoid the risk of a bad
+ server feeding libcurl with a never-ending header that will cause
+ reallocs infinitely */
+ failf(data, "Rejected %zu bytes header (max is %d)!", newsize,
+ CURL_MAX_HTTP_HEADER);
+ return CURLE_OUT_OF_MEMORY;
+ }
+ if(newsize >= data->state.headersize) {
/* We enlarge the header buffer as it is too small */
char *newbuff;
size_t hbufp_index;
- size_t newsize;
-
- if(k->hbuflen + length > CURL_MAX_HTTP_HEADER) {
- /* The reason to have a max limit for this is to avoid the risk of a bad
- server feeding libcurl with a never-ending header that will cause
- reallocs infinitely */
- failf(data, "Avoided giant realloc for header (max is %d)!",
- CURL_MAX_HTTP_HEADER);
- return CURLE_OUT_OF_MEMORY;
- }
- newsize=CURLMAX((k->hbuflen+ length)*3/2, data->state.headersize*2);
+ newsize = CURLMAX((k->hbuflen + length) * 3 / 2, data->state.headersize*2);
hbufp_index = k->hbufp - data->state.headerbuff;
newbuff = realloc(data->state.headerbuff, newsize);
if(!newbuff) {
failf(data, "Failed to alloc memory for big header!");
return CURLE_OUT_OF_MEMORY;
}
- data->state.headersize=newsize;
+ data->state.headersize = newsize;
data->state.headerbuff = newbuff;
k->hbufp = data->state.headerbuff + hbufp_index;
}
@@ -2928,6 +3227,8 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
{
CURLcode result;
struct SingleRequest *k = &data->req;
+ ssize_t onread = *nread;
+ char *ostr = k->str;
/* header line within buffer loop */
do {
@@ -2948,12 +3249,19 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
if(result)
return result;
- if(!k->headerline && (k->hbuflen>5)) {
- /* make a first check that this looks like a protocol header */
- if(!checkprotoprefix(data, conn, data->state.headerbuff)) {
+ if(!k->headerline) {
+ /* check if this looks like a protocol header */
+ statusline st = checkprotoprefix(data, conn, data->state.headerbuff,
+ k->hbuflen);
+ if(st == STATUS_BAD) {
/* this is not the beginning of a protocol first header line */
k->header = FALSE;
k->badheader = HEADER_ALLBAD;
+ streamclose(conn, "bad HTTP: No end-of-message indicator");
+ if(!data->set.http09_allowed) {
+ failf(data, "Received HTTP/0.9 when not allowed\n");
+ return CURLE_UNSUPPORTED_PROTOCOL;
+ }
break;
}
}
@@ -2962,7 +3270,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
}
/* decrease the size of the remaining (supposed) header line */
- rest_length = (k->end_ptr - k->str)+1;
+ rest_length = (k->end_ptr - k->str) + 1;
*nread -= (ssize_t)rest_length;
k->str = k->end_ptr + 1; /* move past new line */
@@ -2982,9 +3290,15 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
if(!k->headerline) {
/* the first read header */
- if((k->hbuflen>5) &&
- !checkprotoprefix(data, conn, data->state.headerbuff)) {
+ statusline st = checkprotoprefix(data, conn, data->state.headerbuff,
+ k->hbuflen);
+ if(st == STATUS_BAD) {
+ streamclose(conn, "bad HTTP: No end-of-message indicator");
/* this is not the beginning of a protocol first header line */
+ if(!data->set.http09_allowed) {
+ failf(data, "Received HTTP/0.9 when not allowed\n");
+ return CURLE_UNSUPPORTED_PROTOCOL;
+ }
k->header = FALSE;
if(*nread)
/* since there's more, this is a partial bad header */
@@ -2992,7 +3306,9 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
else {
/* this was all we read so it's all a bad header */
k->badheader = HEADER_ALLBAD;
- *nread = (ssize_t)rest_length;
+ *nread = onread;
+ k->str = ostr;
+ return CURLE_OK;
}
break;
}
@@ -3080,7 +3396,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
!(conn->handler->protocol & CURLPROTO_RTSP) &&
data->set.httpreq != HTTPREQ_HEAD) {
/* On HTTP 1.1, when connection is not to get closed, but no
- Content-Length nor Content-Encoding chunked have been
+ Content-Length nor Transfer-Encoding chunked have been
received, according to RFC2616 section 4.4 point 5, we
assume that the server will close the connection to
signal the end of the document. */
@@ -3095,14 +3411,31 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
#if defined(USE_NTLM)
if(conn->bits.close &&
(((data->req.httpcode == 401) &&
- (conn->ntlm.state == NTLMSTATE_TYPE2)) ||
+ (conn->http_ntlm_state == NTLMSTATE_TYPE2)) ||
((data->req.httpcode == 407) &&
- (conn->proxyntlm.state == NTLMSTATE_TYPE2)))) {
+ (conn->proxy_ntlm_state == NTLMSTATE_TYPE2)))) {
infof(data, "Connection closure while negotiating auth (HTTP 1.0?)\n");
data->state.authproblem = TRUE;
}
#endif
-
+#if defined(USE_SPNEGO)
+ if(conn->bits.close &&
+ (((data->req.httpcode == 401) &&
+ (conn->http_negotiate_state == GSS_AUTHRECV)) ||
+ ((data->req.httpcode == 407) &&
+ (conn->proxy_negotiate_state == GSS_AUTHRECV)))) {
+ infof(data, "Connection closure while negotiating auth (HTTP 1.0?)\n");
+ data->state.authproblem = TRUE;
+ }
+ if((conn->http_negotiate_state == GSS_AUTHDONE) &&
+ (data->req.httpcode != 401)) {
+ conn->http_negotiate_state = GSS_AUTHSUCC;
+ }
+ if((conn->proxy_negotiate_state == GSS_AUTHDONE) &&
+ (data->req.httpcode != 407)) {
+ conn->proxy_negotiate_state = GSS_AUTHSUCC;
+ }
+#endif
/*
* When all the headers have been parsed, see if we should give
* up and return an error.
@@ -3161,6 +3494,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
case HTTPREQ_PUT:
case HTTPREQ_POST:
case HTTPREQ_POST_FORM:
+ case HTTPREQ_POST_MIME:
/* We got an error response. If this happened before the whole
* request body has been sent we stop sending and mark the
* connection for closure after we've read the entire response.
@@ -3263,7 +3597,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
if(data->set.verbose)
Curl_debug(data, CURLINFO_HEADER_IN,
- k->str_start, headerlen, conn);
+ k->str_start, headerlen);
break; /* exit header line loop */
}
@@ -3288,7 +3622,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
#define HEADER1 scratch
#define SCRATCHSIZE 21
CURLcode res;
- char scratch[SCRATCHSIZE+1]; /* "HTTP/major.minor 123" */
+ char scratch[SCRATCHSIZE + 1]; /* "HTTP/major.minor 123" */
/* We can't really convert this yet because we
don't know if it's the 1st header line or the body.
So we do a partial conversion into a scratch area,
@@ -3314,19 +3648,22 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
* says. We try to allow any number here, but we cannot make
* guarantees on future behaviors since it isn't within the protocol.
*/
+ char separator;
nc = sscanf(HEADER1,
- " HTTP/%d.%d %d",
+ " HTTP/%1d.%1d%c%3d",
&httpversion_major,
&conn->httpversion,
+ &separator,
&k->httpcode);
if(nc == 1 && httpversion_major == 2 &&
1 == sscanf(HEADER1, " HTTP/2 %d", &k->httpcode)) {
conn->httpversion = 0;
- nc = 3;
+ nc = 4;
+ separator = ' ';
}
- if(nc==3) {
+ if((nc == 4) && (' ' == separator)) {
conn->httpversion += 10 * httpversion_major;
if(k->upgr101 == UPGR101_RECEIVED) {
@@ -3334,38 +3671,47 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
if(conn->httpversion != 20)
infof(data, "Lying server, not serving HTTP/2\n");
}
+ if(conn->httpversion < 20) {
+ conn->bundle->multiuse = BUNDLE_NO_MULTIUSE;
+ infof(data, "Mark bundle as not supporting multiuse\n");
+ }
}
- else {
+ else if(!nc) {
/* this is the real world, not a Nirvana
NCSA 1.5.x returns this crap when asked for HTTP/1.1
*/
- nc=sscanf(HEADER1, " HTTP %3d", &k->httpcode);
+ nc = sscanf(HEADER1, " HTTP %3d", &k->httpcode);
conn->httpversion = 10;
/* If user has set option HTTP200ALIASES,
compare header line against list of aliases
*/
if(!nc) {
- if(checkhttpprefix(data, k->p)) {
+ if(checkhttpprefix(data, k->p, k->hbuflen) == STATUS_DONE) {
nc = 1;
k->httpcode = 200;
conn->httpversion = 10;
}
}
}
+ else {
+ failf(data, "Unsupported HTTP version in response\n");
+ return CURLE_UNSUPPORTED_PROTOCOL;
+ }
}
else if(conn->handler->protocol & CURLPROTO_RTSP) {
+ char separator;
nc = sscanf(HEADER1,
- " RTSP/%d.%d %3d",
+ " RTSP/%1d.%1d%c%3d",
&rtspversion_major,
&conn->rtspversion,
+ &separator,
&k->httpcode);
- if(nc==3) {
+ if((nc == 4) && (' ' == separator)) {
conn->rtspversion += 10 * rtspversion_major;
conn->httpversion = 11; /* For us, RTSP acts like HTTP 1.1 */
}
else {
- /* TODO: do we care about the other cases here? */
nc = 0;
}
}
@@ -3387,21 +3733,18 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
* depending on how authentication is working. Other codes
* are definitely errors, so give up here.
*/
- if(data->set.http_fail_on_error && (k->httpcode >= 400) &&
+ if(data->state.resume_from && data->set.httpreq == HTTPREQ_GET &&
+ k->httpcode == 416) {
+ /* "Requested Range Not Satisfiable", just proceed and
+ pretend this is no error */
+ k->ignorebody = TRUE; /* Avoid appending error msg to good data. */
+ }
+ else if(data->set.http_fail_on_error && (k->httpcode >= 400) &&
((k->httpcode != 401) || !conn->bits.user_passwd) &&
((k->httpcode != 407) || !conn->bits.proxy_user_passwd) ) {
-
- if(data->state.resume_from &&
- (data->set.httpreq==HTTPREQ_GET) &&
- (k->httpcode == 416)) {
- /* "Requested Range Not Satisfiable", just proceed and
- pretend this is no error */
- }
- else {
- /* serious error, go home! */
- print_http_error(data);
- return CURLE_HTTP_RETURNED_ERROR;
- }
+ /* serious error, go home! */
+ print_http_error(data);
+ return CURLE_HTTP_RETURNED_ERROR;
}
if(conn->httpversion == 10) {
@@ -3421,26 +3764,12 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
}
else if(conn->httpversion >= 11 &&
!conn->bits.close) {
- /* If HTTP version is >= 1.1 and connection is persistent
- server supports pipelining. */
+ /* If HTTP version is >= 1.1 and connection is persistent */
DEBUGF(infof(data,
- "HTTP 1.1 or later with persistent connection, "
- "pipelining supported\n"));
- /* Activate pipelining if needed */
- if(conn->bundle) {
- if(!Curl_pipeline_site_blacklisted(data, conn))
- conn->bundle->multiuse = BUNDLE_PIPELINING;
- }
+ "HTTP 1.1 or later with persistent connection\n"));
}
switch(k->httpcode) {
- case 204:
- /* (quote from RFC2616, section 10.2.5): The server has
- * fulfilled the request but does not need to return an
- * entity-body ... The 204 response MUST NOT include a
- * message-body, and thus is always terminated by the first
- * empty line after the header fields. */
- /* FALLTHROUGH */
case 304:
/* (quote from RFC2616, section 10.3.5): The 304 response
* MUST NOT contain a message-body, and thus is always
@@ -3448,8 +3777,15 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
* fields. */
if(data->set.timecondition)
data->info.timecond = TRUE;
- k->size=0;
- k->maxdownload=0;
+ /* FALLTHROUGH */
+ case 204:
+ /* (quote from RFC2616, section 10.2.5): The server has
+ * fulfilled the request but does not need to return an
+ * entity-body ... The 204 response MUST NOT include a
+ * message-body, and thus is always terminated by the first
+ * empty line after the header fields. */
+ k->size = 0;
+ k->maxdownload = 0;
k->ignorecl = TRUE; /* ignore Content-Length headers */
break;
default:
@@ -3471,13 +3807,15 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
/* Check for Content-Length: header lines to get size */
if(!k->ignorecl && !data->set.ignorecl &&
checkprefix("Content-Length:", k->p)) {
- curl_off_t contentlength = curlx_strtoofft(k->p+15, NULL, 10);
- if(data->set.max_filesize &&
- contentlength > data->set.max_filesize) {
- failf(data, "Maximum file size exceeded");
- return CURLE_FILESIZE_EXCEEDED;
- }
- if(contentlength >= 0) {
+ curl_off_t contentlength;
+ CURLofft offt = curlx_strtoofft(k->p + 15, NULL, 10, &contentlength);
+
+ if(offt == CURL_OFFT_OK) {
+ if(data->set.max_filesize &&
+ contentlength > data->set.max_filesize) {
+ failf(data, "Maximum file size exceeded");
+ return CURLE_FILESIZE_EXCEEDED;
+ }
k->size = contentlength;
k->maxdownload = k->size;
/* we set the progress download size already at this point
@@ -3485,13 +3823,19 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
info as soon as possible */
Curl_pgrsSetDownloadSize(data, k->size);
}
+ else if(offt == CURL_OFFT_FLOW) {
+ /* out of range */
+ if(data->set.max_filesize) {
+ failf(data, "Maximum file size exceeded");
+ return CURLE_FILESIZE_EXCEEDED;
+ }
+ streamclose(conn, "overflow content-length");
+ infof(data, "Overflow Content-Length: value!\n");
+ }
else {
- /* Negative Content-Length is really odd, and we know it
- happens for example when older Apache servers send large
- files */
- streamclose(conn, "negative content-length");
- infof(data, "Negative content-length: %" CURL_FORMAT_CURL_OFF_T
- ", closing after transfer\n", contentlength);
+ /* negative or just rubbish - bad HTTP */
+ failf(data, "Invalid Content-Length: value");
+ return CURLE_WEIRD_SERVER_REPLY;
}
}
/* check for Content-Type: header lines to get the MIME-type */
@@ -3507,19 +3851,6 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
data->info.contenttype = contenttype;
}
}
- else if(checkprefix("Server:", k->p)) {
- if(conn->httpversion < 20) {
- /* only do this for non-h2 servers */
- char *server_name = Curl_copy_header_value(k->p);
-
- /* Turn off pipelining if the server version is blacklisted */
- if(conn->bundle && (conn->bundle->multiuse == BUNDLE_PIPELINING)) {
- if(Curl_pipeline_server_blacklisted(data, server_name))
- conn->bundle->multiuse = BUNDLE_NO_MULTIUSE;
- }
- free(server_name);
- }
- }
else if((conn->httpversion == 10) &&
conn->bits.httpproxy &&
Curl_compareheader(k->p,
@@ -3576,51 +3907,9 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
* of chunks, and a chunk-data set to zero signals the
* end-of-chunks. */
- char *start;
-
- /* Find the first non-space letter */
- start = k->p + 18;
-
- for(;;) {
- /* skip whitespaces and commas */
- while(*start && (ISSPACE(*start) || (*start == ',')))
- start++;
-
- if(checkprefix("chunked", start)) {
- k->chunk = TRUE; /* chunks coming our way */
-
- /* init our chunky engine */
- Curl_httpchunk_init(conn);
-
- start += 7;
- }
-
- if(k->auto_decoding)
- /* TODO: we only support the first mentioned compression for now */
- break;
-
- if(checkprefix("identity", start)) {
- k->auto_decoding = IDENTITY;
- start += 8;
- }
- else if(checkprefix("deflate", start)) {
- k->auto_decoding = DEFLATE;
- start += 7;
- }
- else if(checkprefix("gzip", start)) {
- k->auto_decoding = GZIP;
- start += 4;
- }
- else if(checkprefix("x-gzip", start)) {
- k->auto_decoding = GZIP;
- start += 6;
- }
- else
- /* unknown! */
- break;
-
- }
-
+ result = Curl_build_unencoding_stack(conn, k->p + 18, TRUE);
+ if(result)
+ return result;
}
else if(checkprefix("Content-Encoding:", k->p) &&
data->set.str[STRING_ENCODING]) {
@@ -3631,21 +3920,9 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
* 2616). zlib cannot handle compress. However, errors are
* handled further down when the response body is processed
*/
- char *start;
-
- /* Find the first non-space letter */
- start = k->p + 17;
- while(*start && ISSPACE(*start))
- start++;
-
- /* Record the content-encoding for later use */
- if(checkprefix("identity", start))
- k->auto_decoding = IDENTITY;
- else if(checkprefix("deflate", start))
- k->auto_decoding = DEFLATE;
- else if(checkprefix("gzip", start)
- || checkprefix("x-gzip", start))
- k->auto_decoding = GZIP;
+ result = Curl_build_unencoding_stack(conn, k->p + 17, FALSE);
+ if(result)
+ return result;
}
else if(checkprefix("Content-Range:", k->p)) {
/* Content-Range: bytes [num]-
@@ -3667,11 +3944,11 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
/* if it truly stopped on a digit */
if(ISDIGIT(*ptr)) {
- k->offset = curlx_strtoofft(ptr, NULL, 10);
-
- if(data->state.resume_from == k->offset)
- /* we asked for a resume and we got it */
- k->content_range = TRUE;
+ if(!curlx_strtoofft(ptr, NULL, 10, &k->offset)) {
+ if(data->state.resume_from == k->offset)
+ /* we asked for a resume and we got it */
+ k->content_range = TRUE;
+ }
}
else
data->state.resume_from = 0; /* get everything */
@@ -3682,22 +3959,24 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
Curl_share_lock(data, CURL_LOCK_DATA_COOKIE,
CURL_LOCK_ACCESS_SINGLE);
Curl_cookie_add(data,
- data->cookies, TRUE, k->p+11,
+ data->cookies, TRUE, FALSE, k->p + 11,
/* If there is a custom-set Host: name, use it
here, or else use real peer host name. */
conn->allocptr.cookiehost?
conn->allocptr.cookiehost:conn->host.name,
- data->state.path);
+ data->state.up.path,
+ (conn->handler->protocol&CURLPROTO_HTTPS)?
+ TRUE:FALSE);
Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
}
#endif
else if(checkprefix("Last-Modified:", k->p) &&
(data->set.timecondition || data->set.get_filetime) ) {
- time_t secs=time(NULL);
- k->timeofdoc = curl_getdate(k->p+strlen("Last-Modified:"),
+ time_t secs = time(NULL);
+ k->timeofdoc = curl_getdate(k->p + strlen("Last-Modified:"),
&secs);
if(data->set.get_filetime)
- data->info.filetime = (long)k->timeofdoc;
+ data->info.filetime = k->timeofdoc;
}
else if((checkprefix("WWW-Authenticate:", k->p) &&
(401 == k->httpcode)) ||
@@ -3716,6 +3995,22 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
if(result)
return result;
}
+ #ifdef USE_SPNEGO
+ else if(checkprefix("Persistent-Auth", k->p)) {
+ struct negotiatedata *negdata = &conn->negotiate;
+ struct auth *authp = &data->state.authhost;
+ if(authp->picked == CURLAUTH_NEGOTIATE) {
+ char *persistentauth = Curl_copy_header_value(k->p);
+ if(!persistentauth)
+ return CURLE_OUT_OF_MEMORY;
+ negdata->noauthpersist = checkprefix("false", persistentauth);
+ negdata->havenoauthpersist = TRUE;
+ infof(data, "Negotiate: noauthpersist -> %d, header part: %s",
+ negdata->noauthpersist, persistentauth);
+ free(persistentauth);
+ }
+ }
+ #endif
else if((k->httpcode >= 300 && k->httpcode < 400) &&
checkprefix("Location:", k->p) &&
!data->req.location) {
@@ -3743,6 +4038,27 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
}
}
}
+#ifdef USE_ALTSVC
+ /* If enabled, the header is incoming and this is over HTTPS */
+ else if(data->asi && checkprefix("Alt-Svc:", k->p) &&
+ ((conn->handler->flags & PROTOPT_SSL) ||
+#ifdef CURLDEBUG
+ /* allow debug builds to circumvent the HTTPS restriction */
+ getenv("CURL_ALTSVC_HTTP")
+#else
+ 0
+#endif
+ )) {
+ /* the ALPN of the current request */
+ enum alpnid id = (conn->httpversion == 20) ? ALPN_h2 : ALPN_h1;
+ result = Curl_altsvc_parse(data, data->asi,
+ &k->p[ strlen("Alt-Svc:") ],
+ id, conn->host.name,
+ curlx_uitous(conn->remote_port));
+ if(result)
+ return result;
+ }
+#endif
else if(conn->handler->protocol & CURLPROTO_RTSP) {
result = Curl_rtsp_parseheader(conn, k->p);
if(result)
@@ -3758,8 +4074,7 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
writetype |= CLIENTWRITE_BODY;
if(data->set.verbose)
- Curl_debug(data, CURLINFO_HEADER_IN,
- k->p, (size_t)k->hbuflen, conn);
+ Curl_debug(data, CURLINFO_HEADER_IN, k->p, (size_t)k->hbuflen);
result = Curl_client_write(conn, writetype, k->p, k->hbuflen);
if(result)
diff --git a/Utilities/cmcurl/lib/http.h b/Utilities/cmcurl/lib/http.h
index 7ce4bd9a0..a59fe7af0 100644
--- a/Utilities/cmcurl/lib/http.h
+++ b/Utilities/cmcurl/lib/http.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -40,8 +40,6 @@ bool Curl_compareheader(const char *headerline, /* line to check */
const char *header, /* header keyword _with_ colon */
const char *content); /* content string to find */
-char *Curl_checkheaders(const struct connectdata *conn,
- const char *thisheader);
char *Curl_copy_header_value(const char *header);
char *Curl_checkProxyheaders(const struct connectdata *conn,
@@ -60,12 +58,14 @@ struct Curl_send_buffer {
typedef struct Curl_send_buffer Curl_send_buffer;
Curl_send_buffer *Curl_add_buffer_init(void);
-void Curl_add_buffer_free(Curl_send_buffer *buff);
-CURLcode Curl_add_bufferf(Curl_send_buffer *in, const char *fmt, ...);
-CURLcode Curl_add_buffer(Curl_send_buffer *in, const void *inptr, size_t size);
-CURLcode Curl_add_buffer_send(Curl_send_buffer *in,
+void Curl_add_buffer_free(Curl_send_buffer **inp);
+CURLcode Curl_add_bufferf(Curl_send_buffer **inp, const char *fmt, ...)
+ WARN_UNUSED_RESULT;
+CURLcode Curl_add_buffer(Curl_send_buffer **inp, const void *inptr,
+ size_t size) WARN_UNUSED_RESULT;
+CURLcode Curl_add_buffer_send(Curl_send_buffer **inp,
struct connectdata *conn,
- long *bytes_written,
+ curl_off_t *bytes_written,
size_t included_body_bytes,
int socketindex);
@@ -74,6 +74,9 @@ CURLcode Curl_add_timecondition(struct Curl_easy *data,
CURLcode Curl_add_custom_headers(struct connectdata *conn,
bool is_connect,
Curl_send_buffer *req_buffer);
+CURLcode Curl_http_compile_trailers(struct curl_slist *trailers,
+ Curl_send_buffer *buffer,
+ struct Curl_easy *handle);
/* protocol-specific functions set up to be called by the main engine */
CURLcode Curl_http(struct connectdata *conn, bool *done);
@@ -106,7 +109,7 @@ CURLcode Curl_http_perhapsrewind(struct connectdata *conn);
This value used to be fairly big (100K), but we must take into account that
if the server rejects the POST due for authentication reasons, this data
- will always be uncondtionally sent and thus it may not be larger than can
+ will always be unconditionally sent and thus it may not be larger than can
always be afforded to send twice.
It must not be greater than 64K to work on VMS.
@@ -115,8 +118,13 @@ CURLcode Curl_http_perhapsrewind(struct connectdata *conn);
#define MAX_INITIAL_POST_SIZE (64*1024)
#endif
-#ifndef TINY_INITIAL_POST_SIZE
-#define TINY_INITIAL_POST_SIZE 1024
+/* EXPECT_100_THRESHOLD is the request body size limit for when libcurl will
+ * automatically add an "Expect: 100-continue" header in HTTP requests. When
+ * the size is unknown, it will always add it.
+ *
+ */
+#ifndef EXPECT_100_THRESHOLD
+#define EXPECT_100_THRESHOLD 1024
#endif
#endif /* CURL_DISABLE_HTTP */
@@ -125,17 +133,15 @@ CURLcode Curl_http_perhapsrewind(struct connectdata *conn);
* HTTP unique setup
***************************************************************************/
struct HTTP {
- struct FormData *sendit;
+ curl_mimepart *sendit;
curl_off_t postsize; /* off_t to handle large file sizes */
const char *postdata;
const char *p_pragma; /* Pragma: string */
const char *p_accept; /* Accept: string */
- curl_off_t readbytecount;
- curl_off_t writebytecount;
/* For FORM posting */
- struct Form form;
+ curl_mimepart form;
struct back {
curl_read_callback fread_func; /* backup storage for fread pointer */
@@ -151,9 +157,11 @@ struct HTTP {
HTTPSEND_LAST /* never use this */
} sending;
- void *send_buffer; /* used if the request couldn't be sent in one chunk,
- points to an allocated send_buffer struct */
-
+#ifndef CURL_DISABLE_HTTP
+ Curl_send_buffer *send_buffer; /* used if the request couldn't be sent in
+ one chunk, points to an allocated
+ send_buffer struct */
+#endif
#ifdef USE_NGHTTP2
/*********** for HTTP/2 we store stream-local data here *************/
int32_t stream_id; /* stream we are interested in */
@@ -169,8 +177,6 @@ struct HTTP {
size_t pauselen; /* the number of bytes left in data */
bool closed; /* TRUE on HTTP2 stream close */
bool close_handled; /* TRUE if stream closure is handled by libcurl */
- uint32_t error_code; /* HTTP/2 error code */
-
char *mem; /* points to a buffer in memory to store received data */
size_t len; /* size of the buffer 'mem' points to */
size_t memlen; /* size of data copied to mem */
@@ -185,9 +191,6 @@ struct HTTP {
#endif
};
-typedef int (*sending)(void); /* Curl_send */
-typedef int (*recving)(void); /* Curl_recv */
-
#ifdef USE_NGHTTP2
/* h2 settings for this connection */
struct h2settings {
@@ -196,15 +199,14 @@ struct h2settings {
};
#endif
-
struct http_conn {
#ifdef USE_NGHTTP2
#define H2_BINSETTINGS_LEN 80
nghttp2_session *h2;
uint8_t binsettings[H2_BINSETTINGS_LEN];
size_t binlen; /* length of the binsettings data */
- sending send_underlying; /* underlying send Curl_send callback */
- recving recv_underlying; /* underlying recv Curl_recv callback */
+ Curl_send *send_underlying; /* underlying send Curl_send callback */
+ Curl_recv *recv_underlying; /* underlying recv Curl_recv callback */
char *inbuf; /* buffer to receive data from underlying socket */
size_t inbuflen; /* number of bytes filled in inbuf */
size_t nread_inbuf; /* number of bytes read from in inbuf */
@@ -223,6 +225,7 @@ struct http_conn {
/* list of settings that will be sent */
nghttp2_settings_entry local_settings[3];
size_t local_settings_num;
+ uint32_t error_code; /* HTTP/2 error code */
#else
int unused; /* prevent a compiler warning */
#endif
@@ -255,4 +258,3 @@ Curl_http_output_auth(struct connectdata *conn,
up the proxy tunnel */
#endif /* HEADER_CURL_HTTP_H */
-
diff --git a/Utilities/cmcurl/lib/http2.c b/Utilities/cmcurl/lib/http2.c
index f8e23c517..8e7bc217e 100644
--- a/Utilities/cmcurl/lib/http2.c
+++ b/Utilities/cmcurl/lib/http2.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -28,10 +28,10 @@
#include "http2.h"
#include "http.h"
#include "sendf.h"
+#include "select.h"
#include "curl_base64.h"
#include "strcase.h"
#include "multiif.h"
-#include "conncache.h"
#include "url.h"
#include "connect.h"
#include "strtoofft.h"
@@ -41,7 +41,7 @@
#include "curl_memory.h"
#include "memdebug.h"
-#define MIN(x,y) ((x)<(y)?(x):(y))
+#define H2_BUFSIZE 32768
#if (NGHTTP2_VERSION_NUM < 0x010000)
#error too old nghttp2 version, upgrade!
@@ -65,6 +65,22 @@
#define HTTP2_HUGE_WINDOW_SIZE (1 << 30)
+#ifdef DEBUG_HTTP2
+#define H2BUGF(x) x
+#else
+#define H2BUGF(x) do { } WHILE_FALSE
+#endif
+
+
+static ssize_t http2_recv(struct connectdata *conn, int sockindex,
+ char *mem, size_t len, CURLcode *err);
+static bool http2_connisdead(struct connectdata *conn);
+static int h2_session_send(struct Curl_easy *data,
+ nghttp2_session *h2);
+static int h2_process_pending_input(struct connectdata *conn,
+ struct http_conn *httpc,
+ CURLcode *err);
+
/*
* Curl_http2_init_state() is called when the easy handle is created and
* allows for HTTP/2 specific init of state.
@@ -91,18 +107,19 @@ static int http2_perform_getsock(const struct connectdata *conn,
int numsocks)
{
const struct http_conn *c = &conn->proto.httpc;
+ struct SingleRequest *k = &conn->data->req;
int bitmap = GETSOCK_BLANK;
(void)numsocks;
- /* TODO We should check underlying socket state if it is SSL socket
- because of renegotiation. */
sock[0] = conn->sock[FIRSTSOCKET];
/* in a HTTP/2 connection we can basically always get a frame so we should
always be ready for one */
bitmap |= GETSOCK_READSOCK(FIRSTSOCKET);
- if(nghttp2_session_want_write(c->h2))
+ /* we're still uploading or the HTTP/2 layer wants to send data */
+ if(((k->keepon & (KEEP_SEND|KEEP_SEND_PAUSE)) == KEEP_SEND) ||
+ nghttp2_session_want_write(c->h2))
bitmap |= GETSOCK_WRITESOCK(FIRSTSOCKET);
return bitmap;
@@ -122,10 +139,8 @@ static int http2_getsock(struct connectdata *conn,
static void http2_stream_free(struct HTTP *http)
{
if(http) {
- Curl_add_buffer_free(http->header_recvbuf);
- http->header_recvbuf = NULL; /* clear the pointer */
- Curl_add_buffer_free(http->trailer_recvbuf);
- http->trailer_recvbuf = NULL; /* clear the pointer */
+ Curl_add_buffer_free(&http->header_recvbuf);
+ Curl_add_buffer_free(&http->trailer_recvbuf);
for(; http->push_headers_used > 0; --http->push_headers_used) {
free(http->push_headers[http->push_headers_used - 1]);
}
@@ -134,23 +149,126 @@ static void http2_stream_free(struct HTTP *http)
}
}
+/*
+ * Disconnects *a* connection used for HTTP/2. It might be an old one from the
+ * connection cache and not the "main" one. Don't touch the easy handle!
+ */
+
static CURLcode http2_disconnect(struct connectdata *conn,
bool dead_connection)
{
struct http_conn *c = &conn->proto.httpc;
(void)dead_connection;
- DEBUGF(infof(conn->data, "HTTP/2 DISCONNECT starts now\n"));
+ H2BUGF(infof(conn->data, "HTTP/2 DISCONNECT starts now\n"));
nghttp2_session_del(c->h2);
Curl_safefree(c->inbuf);
- http2_stream_free(conn->data->req.protop);
- DEBUGF(infof(conn->data, "HTTP/2 DISCONNECT done\n"));
+ H2BUGF(infof(conn->data, "HTTP/2 DISCONNECT done\n"));
return CURLE_OK;
}
+/*
+ * The server may send us data at any point (e.g. PING frames). Therefore,
+ * we cannot assume that an HTTP/2 socket is dead just because it is readable.
+ *
+ * Instead, if it is readable, run Curl_connalive() to peek at the socket
+ * and distinguish between closed and data.
+ */
+static bool http2_connisdead(struct connectdata *conn)
+{
+ int sval;
+ bool dead = TRUE;
+
+ if(conn->bits.close)
+ return TRUE;
+
+ sval = SOCKET_READABLE(conn->sock[FIRSTSOCKET], 0);
+ if(sval == 0) {
+ /* timeout */
+ dead = FALSE;
+ }
+ else if(sval & CURL_CSELECT_ERR) {
+ /* socket is in an error state */
+ dead = TRUE;
+ }
+ else if(sval & CURL_CSELECT_IN) {
+ /* readable with no error. could still be closed */
+ dead = !Curl_connalive(conn);
+ if(!dead) {
+ /* This happens before we've sent off a request and the connection is
+ not in use by any other transfer, there shouldn't be any data here,
+ only "protocol frames" */
+ CURLcode result;
+ struct http_conn *httpc = &conn->proto.httpc;
+ ssize_t nread = -1;
+ if(httpc->recv_underlying)
+ /* if called "too early", this pointer isn't setup yet! */
+ nread = ((Curl_recv *)httpc->recv_underlying)(
+ conn, FIRSTSOCKET, httpc->inbuf, H2_BUFSIZE, &result);
+ if(nread != -1) {
+ infof(conn->data,
+ "%d bytes stray data read before trying h2 connection\n",
+ (int)nread);
+ httpc->nread_inbuf = 0;
+ httpc->inbuflen = nread;
+ (void)h2_process_pending_input(conn, httpc, &result);
+ }
+ else
+ /* the read failed so let's say this is dead anyway */
+ dead = TRUE;
+ }
+ }
+
+ return dead;
+}
+
+static unsigned int http2_conncheck(struct connectdata *check,
+ unsigned int checks_to_perform)
+{
+ unsigned int ret_val = CONNRESULT_NONE;
+ struct http_conn *c = &check->proto.httpc;
+ int rc;
+ bool send_frames = false;
+
+ if(checks_to_perform & CONNCHECK_ISDEAD) {
+ if(http2_connisdead(check))
+ ret_val |= CONNRESULT_DEAD;
+ }
+
+ if(checks_to_perform & CONNCHECK_KEEPALIVE) {
+ struct curltime now = Curl_now();
+ time_t elapsed = Curl_timediff(now, check->keepalive);
+
+ if(elapsed > check->upkeep_interval_ms) {
+ /* Perform an HTTP/2 PING */
+ rc = nghttp2_submit_ping(c->h2, 0, ZERO_NULL);
+ if(!rc) {
+ /* Successfully added a PING frame to the session. Need to flag this
+ so the frame is sent. */
+ send_frames = true;
+ }
+ else {
+ failf(check->data, "nghttp2_submit_ping() failed: %s(%d)",
+ nghttp2_strerror(rc), rc);
+ }
+
+ check->keepalive = now;
+ }
+ }
+
+ if(send_frames) {
+ rc = nghttp2_session_send(c->h2);
+ if(rc)
+ failf(check->data, "nghttp2_session_send() failed: %s(%d)",
+ nghttp2_strerror(rc), rc);
+ }
+
+ return ret_val;
+}
+
/* called from Curl_http_setup_conn */
void Curl_http2_setup_req(struct Curl_easy *data)
{
@@ -161,7 +279,6 @@ void Curl_http2_setup_req(struct Curl_easy *data)
http->status_code = -1;
http->pausedata = NULL;
http->pauselen = 0;
- http->error_code = NGHTTP2_NO_ERROR;
http->closed = FALSE;
http->close_handled = FALSE;
http->mem = data->state.buffer;
@@ -174,6 +291,7 @@ void Curl_http2_setup_conn(struct connectdata *conn)
{
conn->proto.httpc.settings.max_concurrent_streams =
DEFAULT_MAX_CONCURRENT_STREAMS;
+ conn->proto.httpc.error_code = NGHTTP2_NO_ERROR;
}
/*
@@ -196,6 +314,7 @@ static const struct Curl_handler Curl_handler_http2 = {
http2_perform_getsock, /* perform_getsock */
http2_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ http2_conncheck, /* connection_check */
PORT_HTTP, /* defport */
CURLPROTO_HTTP, /* protocol */
PROTOPT_STREAM /* flags */
@@ -216,6 +335,7 @@ static const struct Curl_handler Curl_handler_http2_ssl = {
http2_perform_getsock, /* perform_getsock */
http2_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ http2_conncheck, /* connection_check */
PORT_HTTP, /* defport */
CURLPROTO_HTTPS, /* protocol */
PROTOPT_SSL | PROTOPT_STREAM /* flags */
@@ -228,14 +348,14 @@ static const struct Curl_handler Curl_handler_http2_ssl = {
int Curl_http2_ver(char *p, size_t len)
{
nghttp2_info *h2 = nghttp2_version(0);
- return snprintf(p, len, " nghttp2/%s", h2->version_str);
+ return msnprintf(p, len, " nghttp2/%s", h2->version_str);
}
/* HTTP/2 error code to name based on the Error Code Registry.
https://tools.ietf.org/html/rfc7540#page-77
nghttp2_error_code enums are identical.
*/
-const char *Curl_http2_strerror(uint32_t err)
+static const char *http2_strerror(uint32_t err)
{
#ifndef NGHTTP2_HAS_HTTP2_STRERROR
const char *str[] = {
@@ -254,7 +374,7 @@ const char *Curl_http2_strerror(uint32_t err)
"INADEQUATE_SECURITY", /* 0xC */
"HTTP_1_1_REQUIRED" /* 0xD */
};
- return (err < sizeof str / sizeof str[0]) ? str[err] : "unknown";
+ return (err < sizeof(str) / sizeof(str[0])) ? str[err] : "unknown";
#else
return nghttp2_http2_strerror(err);
#endif
@@ -277,6 +397,10 @@ static ssize_t send_callback(nghttp2_session *h2,
(void)h2;
(void)flags;
+ if(!c->send_underlying)
+ /* called before setup properly! */
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
+
written = ((Curl_send*)c->send_underlying)(conn, FIRSTSOCKET,
data, length, &result);
@@ -338,18 +462,40 @@ char *curl_pushheader_byname(struct curl_pushheaders *h, const char *header)
struct HTTP *stream = h->data->req.protop;
size_t len = strlen(header);
size_t i;
- for(i=0; i<stream->push_headers_used; i++) {
+ for(i = 0; i<stream->push_headers_used; i++) {
if(!strncmp(header, stream->push_headers[i], len)) {
/* sub-match, make sure that it is followed by a colon */
if(stream->push_headers[i][len] != ':')
continue;
- return &stream->push_headers[i][len+1];
+ return &stream->push_headers[i][len + 1];
}
}
}
return NULL;
}
+/*
+ * This specific transfer on this connection has been "drained".
+ */
+static void drained_transfer(struct Curl_easy *data,
+ struct http_conn *httpc)
+{
+ DEBUGASSERT(httpc->drain_total >= data->state.drain);
+ httpc->drain_total -= data->state.drain;
+ data->state.drain = 0;
+}
+
+/*
+ * Mark this transfer to get "drained".
+ */
+static void drain_this(struct Curl_easy *data,
+ struct http_conn *httpc)
+{
+ data->state.drain++;
+ httpc->drain_total++;
+ DEBUGASSERT(httpc->drain_total >= data->state.drain);
+}
+
static struct Curl_easy *duphandle(struct Curl_easy *data)
{
struct Curl_easy *second = curl_easy_duphandle(data);
@@ -383,7 +529,7 @@ static int push_promise(struct Curl_easy *data,
const nghttp2_push_promise *frame)
{
int rv;
- DEBUGF(infof(data, "PUSH_PROMISE received, stream %u!\n",
+ H2BUGF(infof(data, "PUSH_PROMISE received, stream %u!\n",
frame->promised_stream_id));
if(data->multi->push_cb) {
struct HTTP *stream;
@@ -403,7 +549,7 @@ static int push_promise(struct Curl_easy *data,
heads.data = data;
heads.frame = frame;
/* ask the application */
- DEBUGF(infof(data, "Got PUSH_PROMISE, ask application!\n"));
+ H2BUGF(infof(data, "Got PUSH_PROMISE, ask application!\n"));
stream = data->req.protop;
if(!stream) {
@@ -413,12 +559,14 @@ static int push_promise(struct Curl_easy *data,
goto fail;
}
+ Curl_set_in_callback(data, true);
rv = data->multi->push_cb(data, newhandle,
stream->push_headers_used, &heads,
data->multi->push_userp);
+ Curl_set_in_callback(data, false);
/* free the headers again */
- for(i=0; i<stream->push_headers_used; i++)
+ for(i = 0; i<stream->push_headers_used; i++)
free(stream->push_headers[i]);
free(stream->push_headers);
stream->push_headers = NULL;
@@ -427,6 +575,7 @@ static int push_promise(struct Curl_easy *data,
if(rv) {
/* denied, kill off the new handle again */
http2_stream_free(newhandle->req.protop);
+ newhandle->req.protop = NULL;
(void)Curl_close(newhandle);
goto fail;
}
@@ -442,23 +591,43 @@ static int push_promise(struct Curl_easy *data,
if(rc) {
infof(data, "failed to add handle to multi\n");
http2_stream_free(newhandle->req.protop);
+ newhandle->req.protop = NULL;
Curl_close(newhandle);
rv = 1;
goto fail;
}
httpc = &conn->proto.httpc;
- nghttp2_session_set_stream_user_data(httpc->h2,
- frame->promised_stream_id, newhandle);
+ rv = nghttp2_session_set_stream_user_data(httpc->h2,
+ frame->promised_stream_id,
+ newhandle);
+ if(rv) {
+ infof(data, "failed to set user_data for stream %d\n",
+ frame->promised_stream_id);
+ DEBUGASSERT(0);
+ goto fail;
+ }
}
else {
- DEBUGF(infof(data, "Got PUSH_PROMISE, ignore it!\n"));
+ H2BUGF(infof(data, "Got PUSH_PROMISE, ignore it!\n"));
rv = 1;
}
fail:
return rv;
}
+/*
+ * multi_connchanged() is called to tell that there is a connection in
+ * this multi handle that has changed state (multiplexing become possible, the
+ * number of allowed streams changed or similar), and a subsequent use of this
+ * multi handle should move CONNECT_PEND handles back to CONNECT to have them
+ * retry.
+ */
+static void multi_connchanged(struct Curl_multi *multi)
+{
+ multi->recheckstate = TRUE;
+}
+
static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
void *userp)
{
@@ -466,41 +635,39 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
struct http_conn *httpc = &conn->proto.httpc;
struct Curl_easy *data_s = NULL;
struct HTTP *stream = NULL;
- static int lastStream = -1;
int rv;
size_t left, ncopy;
int32_t stream_id = frame->hd.stream_id;
+ CURLcode result;
if(!stream_id) {
/* stream ID zero is for connection-oriented stuff */
if(frame->hd.type == NGHTTP2_SETTINGS) {
uint32_t max_conn = httpc->settings.max_concurrent_streams;
- DEBUGF(infof(conn->data, "Got SETTINGS\n"));
+ H2BUGF(infof(conn->data, "Got SETTINGS\n"));
httpc->settings.max_concurrent_streams =
nghttp2_session_get_remote_settings(
session, NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS);
httpc->settings.enable_push =
nghttp2_session_get_remote_settings(
session, NGHTTP2_SETTINGS_ENABLE_PUSH);
- DEBUGF(infof(conn->data, "MAX_CONCURRENT_STREAMS == %d\n",
+ H2BUGF(infof(conn->data, "MAX_CONCURRENT_STREAMS == %d\n",
httpc->settings.max_concurrent_streams));
- DEBUGF(infof(conn->data, "ENABLE_PUSH == %s\n",
+ H2BUGF(infof(conn->data, "ENABLE_PUSH == %s\n",
httpc->settings.enable_push?"TRUE":"false"));
if(max_conn != httpc->settings.max_concurrent_streams) {
/* only signal change if the value actually changed */
infof(conn->data,
- "Connection state changed (MAX_CONCURRENT_STREAMS updated)!\n");
- Curl_multi_connchanged(conn->data->multi);
+ "Connection state changed (MAX_CONCURRENT_STREAMS == %u)!\n",
+ httpc->settings.max_concurrent_streams);
+ multi_connchanged(conn->data->multi);
}
}
return 0;
}
data_s = nghttp2_session_get_stream_user_data(session, stream_id);
- if(lastStream != stream_id) {
- lastStream = stream_id;
- }
if(!data_s) {
- DEBUGF(infof(conn->data,
+ H2BUGF(infof(conn->data,
"No Curl_easy associated with stream: %x\n",
stream_id));
return 0;
@@ -508,12 +675,12 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
stream = data_s->req.protop;
if(!stream) {
- DEBUGF(infof(conn->data, "No proto pointer for stream: %x\n",
+ H2BUGF(infof(data_s, "No proto pointer for stream: %x\n",
stream_id));
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
- DEBUGF(infof(data_s, "on_frame_recv() header %x stream %x\n",
+ H2BUGF(infof(data_s, "on_frame_recv() header %x stream %x\n",
frame->hd.type, stream_id));
switch(frame->hd.type) {
@@ -536,8 +703,10 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
}
/* nghttp2 guarantees that :status is received, and we store it to
- stream->status_code */
- DEBUGASSERT(stream->status_code != -1);
+ stream->status_code. Fuzzing has proven this can still be reached
+ without status code having been set. */
+ if(stream->status_code == -1)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
/* Only final status code signals the end of header */
if(stream->status_code / 100 != 1) {
@@ -545,24 +714,25 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
stream->status_code = -1;
}
- Curl_add_buffer(stream->header_recvbuf, "\r\n", 2);
+ result = Curl_add_buffer(&stream->header_recvbuf, "\r\n", 2);
+ if(result)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
left = stream->header_recvbuf->size_used - stream->nread_header_recvbuf;
- ncopy = MIN(stream->len, left);
+ ncopy = CURLMIN(stream->len, left);
memcpy(&stream->mem[stream->memlen],
stream->header_recvbuf->buffer + stream->nread_header_recvbuf,
ncopy);
stream->nread_header_recvbuf += ncopy;
- DEBUGF(infof(data_s, "Store %zu bytes headers from stream %u at %p\n",
+ H2BUGF(infof(data_s, "Store %zu bytes headers from stream %u at %p\n",
ncopy, stream_id, stream->mem));
stream->len -= ncopy;
stream->memlen += ncopy;
- data_s->state.drain++;
- httpc->drain_total++;
+ drain_this(data_s, httpc);
{
/* get the pointer from userp again since it was re-assigned above */
struct connectdata *conn_s = (struct connectdata *)userp;
@@ -584,32 +754,13 @@ static int on_frame_recv(nghttp2_session *session, const nghttp2_frame *frame,
}
break;
default:
- DEBUGF(infof(conn->data, "Got frame type %x for stream %u!\n",
+ H2BUGF(infof(data_s, "Got frame type %x for stream %u!\n",
frame->hd.type, stream_id));
break;
}
return 0;
}
-static int on_invalid_frame_recv(nghttp2_session *session,
- const nghttp2_frame *frame,
- int lib_error_code, void *userp)
-{
- struct Curl_easy *data_s = NULL;
- (void)userp;
-#if !defined(DEBUGBUILD) || defined(CURL_DISABLE_VERBOSE_STRINGS)
- (void)lib_error_code;
-#endif
-
- data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id);
- if(data_s) {
- DEBUGF(infof(data_s,
- "on_invalid_frame_recv() was called, error=%d:%s\n",
- lib_error_code, nghttp2_strerror(lib_error_code)));
- }
- return 0;
-}
-
static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
int32_t stream_id,
const uint8_t *data, size_t len, void *userp)
@@ -635,20 +786,19 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
if(!stream)
return NGHTTP2_ERR_CALLBACK_FAILURE;
- nread = MIN(stream->len, len);
+ nread = CURLMIN(stream->len, len);
memcpy(&stream->mem[stream->memlen], data, nread);
stream->len -= nread;
stream->memlen += nread;
- data_s->state.drain++;
- conn->proto.httpc.drain_total++;
+ drain_this(data_s, &conn->proto.httpc);
/* if we receive data for another handle, wake that up */
if(conn->data != data_s)
Curl_expire(data_s, 0, EXPIRE_RUN_NOW);
- DEBUGF(infof(data_s, "%zu data received for stream %u "
+ H2BUGF(infof(data_s, "%zu data received for stream %u "
"(%zu left in buffer %p, total %zu)\n",
nread, stream_id,
stream->len, stream->mem,
@@ -657,10 +807,10 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
if(nread < len) {
stream->pausedata = data + nread;
stream->pauselen = len - nread;
- DEBUGF(infof(data_s, "NGHTTP2_ERR_PAUSE - %zu bytes out of buffer"
+ H2BUGF(infof(data_s, "NGHTTP2_ERR_PAUSE - %zu bytes out of buffer"
", stream %u\n",
len - nread, stream_id));
- data_s->easy_conn->proto.httpc.pause_stream_id = stream_id;
+ data_s->conn->proto.httpc.pause_stream_id = stream_id;
return NGHTTP2_ERR_PAUSE;
}
@@ -668,7 +818,7 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
/* pause execution of nghttp2 if we received data for another handle
in order to process them first. */
if(conn->data != data_s) {
- data_s->easy_conn->proto.httpc.pause_stream_id = stream_id;
+ data_s->conn->proto.httpc.pause_stream_id = stream_id;
return NGHTTP2_ERR_PAUSE;
}
@@ -676,62 +826,18 @@ static int on_data_chunk_recv(nghttp2_session *session, uint8_t flags,
return 0;
}
-static int before_frame_send(nghttp2_session *session,
- const nghttp2_frame *frame,
- void *userp)
-{
- struct Curl_easy *data_s;
- (void)userp;
-
- data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id);
- if(data_s) {
- DEBUGF(infof(data_s, "before_frame_send() was called\n"));
- }
-
- return 0;
-}
-static int on_frame_send(nghttp2_session *session,
- const nghttp2_frame *frame,
- void *userp)
-{
- struct Curl_easy *data_s;
- (void)userp;
-
- data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id);
- if(data_s) {
- DEBUGF(infof(data_s, "on_frame_send() was called, length = %zd\n",
- frame->hd.length));
- }
- return 0;
-}
-static int on_frame_not_send(nghttp2_session *session,
- const nghttp2_frame *frame,
- int lib_error_code, void *userp)
-{
- struct Curl_easy *data_s;
- (void)userp;
-#if !defined(DEBUGBUILD) || defined(CURL_DISABLE_VERBOSE_STRINGS)
- (void)lib_error_code;
-#endif
-
- data_s = nghttp2_session_get_stream_user_data(session, frame->hd.stream_id);
- if(data_s) {
- DEBUGF(infof(data_s,
- "on_frame_not_send() was called, lib_error_code = %d\n",
- lib_error_code));
- }
- return 0;
-}
static int on_stream_close(nghttp2_session *session, int32_t stream_id,
uint32_t error_code, void *userp)
{
struct Curl_easy *data_s;
struct HTTP *stream;
struct connectdata *conn = (struct connectdata *)userp;
+ int rv;
(void)session;
(void)stream_id;
if(stream_id) {
+ struct http_conn *httpc;
/* get the stream from the hash based on Stream ID, stream ID zero is for
connection-oriented stuff */
data_s = nghttp2_session_get_stream_user_data(session, stream_id);
@@ -740,20 +846,30 @@ static int on_stream_close(nghttp2_session *session, int32_t stream_id,
decided to reject stream (e.g., PUSH_PROMISE). */
return 0;
}
- DEBUGF(infof(data_s, "on_stream_close(), %s (err %d), stream %u\n",
- Curl_http2_strerror(error_code), error_code, stream_id));
+ H2BUGF(infof(data_s, "on_stream_close(), %s (err %d), stream %u\n",
+ http2_strerror(error_code), error_code, stream_id));
stream = data_s->req.protop;
if(!stream)
return NGHTTP2_ERR_CALLBACK_FAILURE;
- stream->error_code = error_code;
stream->closed = TRUE;
- data_s->state.drain++;
- conn->proto.httpc.drain_total++;
+ httpc = &conn->proto.httpc;
+ drain_this(data_s, httpc);
+ httpc->error_code = error_code;
/* remove the entry from the hash as the stream is now gone */
- nghttp2_session_set_stream_user_data(session, stream_id, 0);
- DEBUGF(infof(data_s, "Removed stream %u hash!\n", stream_id));
+ rv = nghttp2_session_set_stream_user_data(session, stream_id, 0);
+ if(rv) {
+ infof(data_s, "http/2: failed to clear user_data for stream %d!\n",
+ stream_id);
+ DEBUGASSERT(0);
+ }
+ if(stream_id == httpc->pause_stream_id) {
+ H2BUGF(infof(data_s, "Stopped the pause stream!\n"));
+ httpc->pause_stream_id = 0;
+ }
+ H2BUGF(infof(data_s, "Removed stream %u hash!\n", stream_id));
+ stream->stream_id = 0; /* cleared */
}
return 0;
}
@@ -770,7 +886,7 @@ static int on_begin_headers(nghttp2_session *session,
return 0;
}
- DEBUGF(infof(data_s, "on_begin_headers() was called\n"));
+ H2BUGF(infof(data_s, "on_begin_headers() was called\n"));
if(frame->hd.type != NGHTTP2_HEADERS) {
return 0;
@@ -781,16 +897,12 @@ static int on_begin_headers(nghttp2_session *session,
return 0;
}
- /* This is trailer HEADERS started. Allocate buffer for them. */
- DEBUGF(infof(data_s, "trailer field started\n"));
-
- DEBUGASSERT(stream->trailer_recvbuf == NULL);
-
- stream->trailer_recvbuf = Curl_add_buffer_init();
if(!stream->trailer_recvbuf) {
- return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
+ stream->trailer_recvbuf = Curl_add_buffer_init();
+ if(!stream->trailer_recvbuf) {
+ return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
+ }
}
-
return 0;
}
@@ -832,6 +944,7 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
struct Curl_easy *data_s;
int32_t stream_id = frame->hd.stream_id;
struct connectdata *conn = (struct connectdata *)userp;
+ CURLcode result;
(void)flags;
DEBUGASSERT(stream_id); /* should never be a zero stream ID here */
@@ -854,10 +967,34 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
if(frame->hd.type == NGHTTP2_PUSH_PROMISE) {
char *h;
+ if(!strcmp(":authority", (const char *)name)) {
+ /* pseudo headers are lower case */
+ int rc = 0;
+ char *check = aprintf("%s:%d", conn->host.name, conn->remote_port);
+ if(!check)
+ /* no memory */
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
+ if(!Curl_strcasecompare(check, (const char *)value)) {
+ /* This is push is not for the same authority that was asked for in
+ * the URL. RFC 7540 section 8.2 says: "A client MUST treat a
+ * PUSH_PROMISE for which the server is not authoritative as a stream
+ * error of type PROTOCOL_ERROR."
+ */
+ (void)nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE,
+ stream_id, NGHTTP2_PROTOCOL_ERROR);
+ rc = NGHTTP2_ERR_CALLBACK_FAILURE;
+ }
+ free(check);
+ if(rc)
+ return rc;
+ }
+
if(!stream->push_headers) {
stream->push_headers_alloc = 10;
stream->push_headers = malloc(stream->push_headers_alloc *
sizeof(char *));
+ if(!stream->push_headers)
+ return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
stream->push_headers_used = 0;
}
else if(stream->push_headers_used ==
@@ -880,17 +1017,27 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
if(stream->bodystarted) {
/* This is trailer fields. */
- /* 3 is for ":" and "\r\n". */
- uint32_t n = (uint32_t)(namelen + valuelen + 3);
+ /* 4 is for ": " and "\r\n". */
+ uint32_t n = (uint32_t)(namelen + valuelen + 4);
- DEBUGF(infof(data_s, "h2 trailer: %.*s: %.*s\n", namelen, name, valuelen,
+ H2BUGF(infof(data_s, "h2 trailer: %.*s: %.*s\n", namelen, name, valuelen,
value));
- Curl_add_buffer(stream->trailer_recvbuf, &n, sizeof(n));
- Curl_add_buffer(stream->trailer_recvbuf, name, namelen);
- Curl_add_buffer(stream->trailer_recvbuf, ": ", 2);
- Curl_add_buffer(stream->trailer_recvbuf, value, valuelen);
- Curl_add_buffer(stream->trailer_recvbuf, "\r\n\0", 3);
+ result = Curl_add_buffer(&stream->trailer_recvbuf, &n, sizeof(n));
+ if(result)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
+ result = Curl_add_buffer(&stream->trailer_recvbuf, name, namelen);
+ if(result)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
+ result = Curl_add_buffer(&stream->trailer_recvbuf, ": ", 2);
+ if(result)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
+ result = Curl_add_buffer(&stream->trailer_recvbuf, value, valuelen);
+ if(result)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
+ result = Curl_add_buffer(&stream->trailer_recvbuf, "\r\n\0", 3);
+ if(result)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
return 0;
}
@@ -903,15 +1050,21 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
stream->status_code = decode_status_code(value, valuelen);
DEBUGASSERT(stream->status_code != -1);
- Curl_add_buffer(stream->header_recvbuf, "HTTP/2 ", 7);
- Curl_add_buffer(stream->header_recvbuf, value, valuelen);
+ result = Curl_add_buffer(&stream->header_recvbuf, "HTTP/2 ", 7);
+ if(result)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
+ result = Curl_add_buffer(&stream->header_recvbuf, value, valuelen);
+ if(result)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
/* the space character after the status code is mandatory */
- Curl_add_buffer(stream->header_recvbuf, " \r\n", 3);
+ result = Curl_add_buffer(&stream->header_recvbuf, " \r\n", 3);
+ if(result)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
/* if we receive data for another handle, wake that up */
if(conn->data != data_s)
Curl_expire(data_s, 0, EXPIRE_RUN_NOW);
- DEBUGF(infof(data_s, "h2 status: HTTP/2 %03d (easy %p)\n",
+ H2BUGF(infof(data_s, "h2 status: HTTP/2 %03d (easy %p)\n",
stream->status_code, data_s));
return 0;
}
@@ -919,15 +1072,23 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
/* nghttp2 guarantees that namelen > 0, and :status was already
received, and this is not pseudo-header field . */
/* convert to a HTTP1-style header */
- Curl_add_buffer(stream->header_recvbuf, name, namelen);
- Curl_add_buffer(stream->header_recvbuf, ": ", 2);
- Curl_add_buffer(stream->header_recvbuf, value, valuelen);
- Curl_add_buffer(stream->header_recvbuf, "\r\n", 2);
+ result = Curl_add_buffer(&stream->header_recvbuf, name, namelen);
+ if(result)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
+ result = Curl_add_buffer(&stream->header_recvbuf, ": ", 2);
+ if(result)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
+ result = Curl_add_buffer(&stream->header_recvbuf, value, valuelen);
+ if(result)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
+ result = Curl_add_buffer(&stream->header_recvbuf, "\r\n", 2);
+ if(result)
+ return NGHTTP2_ERR_CALLBACK_FAILURE;
/* if we receive data for another handle, wake that up */
if(conn->data != data_s)
Curl_expire(data_s, 0, EXPIRE_RUN_NOW);
- DEBUGF(infof(data_s, "h2 header: %.*s: %.*s\n", namelen, name, valuelen,
+ H2BUGF(infof(data_s, "h2 header: %.*s: %.*s\n", namelen, name, valuelen,
value));
return 0; /* 0 is successful */
@@ -962,7 +1123,7 @@ static ssize_t data_source_read_callback(nghttp2_session *session,
else
return NGHTTP2_ERR_INVALID_ARGUMENT;
- nread = MIN(stream->upload_len, length);
+ nread = CURLMIN(stream->upload_len, length);
if(nread > 0) {
memcpy(buf, stream->upload_mem, nread);
stream->upload_mem += nread;
@@ -976,16 +1137,15 @@ static ssize_t data_source_read_callback(nghttp2_session *session,
else if(nread == 0)
return NGHTTP2_ERR_DEFERRED;
- DEBUGF(infof(data_s, "data_source_read_callback: "
+ H2BUGF(infof(data_s, "data_source_read_callback: "
"returns %zu bytes stream %u\n",
nread, stream_id));
return nread;
}
-#define H2_BUFSIZE 32768
-
-#ifdef NGHTTP2_HAS_ERROR_CALLBACK
+#if defined(NGHTTP2_HAS_ERROR_CALLBACK) && \
+ !defined(CURL_DISABLE_VERBOSE_STRINGS)
static int error_callback(nghttp2_session *session,
const char *msg,
size_t len,
@@ -1021,12 +1181,11 @@ void Curl_http2_done(struct connectdata *conn, bool premature)
struct HTTP *http = data->req.protop;
struct http_conn *httpc = &conn->proto.httpc;
+ /* there might be allocated resources done before this got the 'h2' pointer
+ setup */
if(http->header_recvbuf) {
- DEBUGF(infof(data, "free header_recvbuf!!\n"));
- Curl_add_buffer_free(http->header_recvbuf);
- http->header_recvbuf = NULL; /* clear the pointer */
- Curl_add_buffer_free(http->trailer_recvbuf);
- http->trailer_recvbuf = NULL; /* clear the pointer */
+ Curl_add_buffer_free(&http->header_recvbuf);
+ Curl_add_buffer_free(&http->trailer_recvbuf);
if(http->push_headers) {
/* if they weren't used and then freed before */
for(; http->push_headers_used > 0; --http->push_headers_used) {
@@ -1037,17 +1196,32 @@ void Curl_http2_done(struct connectdata *conn, bool premature)
}
}
+ if(!httpc->h2) /* not HTTP/2 ? */
+ return;
+
+ if(data->state.drain)
+ drained_transfer(data, httpc);
+
if(premature) {
/* RST_STREAM */
- nghttp2_submit_rst_stream(httpc->h2, NGHTTP2_FLAG_NONE, http->stream_id,
- NGHTTP2_STREAM_CLOSED);
+ if(!nghttp2_submit_rst_stream(httpc->h2, NGHTTP2_FLAG_NONE,
+ http->stream_id, NGHTTP2_STREAM_CLOSED))
+ (void)nghttp2_session_send(httpc->h2);
+
if(http->stream_id == httpc->pause_stream_id) {
infof(data, "stopped the pause stream!\n");
httpc->pause_stream_id = 0;
}
}
- if(http->stream_id) {
- nghttp2_session_set_stream_user_data(httpc->h2, http->stream_id, 0);
+ /* -1 means unassigned and 0 means cleared */
+ if(http->stream_id > 0) {
+ int rv = nghttp2_session_set_stream_user_data(httpc->h2,
+ http->stream_id, 0);
+ if(rv) {
+ infof(data, "http/2: failed to clear user_data for stream %d!\n",
+ http->stream_id);
+ DEBUGASSERT(0);
+ }
http->stream_id = 0;
}
}
@@ -1055,7 +1229,7 @@ void Curl_http2_done(struct connectdata *conn, bool premature)
/*
* Initialize nghttp2 for a Curl connection
*/
-CURLcode Curl_http2_init(struct connectdata *conn)
+static CURLcode http2_init(struct connectdata *conn)
{
if(!conn->proto.httpc.h2) {
int rc;
@@ -1077,21 +1251,9 @@ CURLcode Curl_http2_init(struct connectdata *conn)
/* nghttp2_on_frame_recv_callback */
nghttp2_session_callbacks_set_on_frame_recv_callback
(callbacks, on_frame_recv);
- /* nghttp2_on_invalid_frame_recv_callback */
- nghttp2_session_callbacks_set_on_invalid_frame_recv_callback
- (callbacks, on_invalid_frame_recv);
/* nghttp2_on_data_chunk_recv_callback */
nghttp2_session_callbacks_set_on_data_chunk_recv_callback
(callbacks, on_data_chunk_recv);
- /* nghttp2_before_frame_send_callback */
- nghttp2_session_callbacks_set_before_frame_send_callback
- (callbacks, before_frame_send);
- /* nghttp2_on_frame_send_callback */
- nghttp2_session_callbacks_set_on_frame_send_callback
- (callbacks, on_frame_send);
- /* nghttp2_on_frame_not_send_callback */
- nghttp2_session_callbacks_set_on_frame_not_send_callback
- (callbacks, on_frame_not_send);
/* nghttp2_on_stream_close_callback */
nghttp2_session_callbacks_set_on_stream_close_callback
(callbacks, on_stream_close);
@@ -1101,7 +1263,9 @@ CURLcode Curl_http2_init(struct connectdata *conn)
/* nghttp2_on_header_callback */
nghttp2_session_callbacks_set_on_header_callback(callbacks, on_header);
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
nghttp2_session_callbacks_set_error_callback(callbacks, error_callback);
+#endif
/* The nghttp2 session is not yet setup, do it */
rc = nghttp2_session_client_new(&conn->proto.httpc.h2, callbacks, conn);
@@ -1138,16 +1302,19 @@ CURLcode Curl_http2_request_upgrade(Curl_send_buffer *req,
httpc->local_settings_num);
if(!binlen) {
failf(conn->data, "nghttp2 unexpectedly failed on pack_settings_payload");
+ Curl_add_buffer_free(&req);
return CURLE_FAILED_INIT;
}
conn->proto.httpc.binlen = binlen;
result = Curl_base64url_encode(conn->data, (const char *)binsettings, binlen,
&base64, &blen);
- if(result)
+ if(result) {
+ Curl_add_buffer_free(&req);
return result;
+ }
- result = Curl_add_bufferf(req,
+ result = Curl_add_bufferf(&req,
"Connection: Upgrade, HTTP2-Settings\r\n"
"Upgrade: %s\r\n"
"HTTP2-Settings: %s\r\n",
@@ -1168,22 +1335,20 @@ static int should_close_session(struct http_conn *httpc)
!nghttp2_session_want_write(httpc->h2);
}
-static int h2_session_send(struct Curl_easy *data,
- nghttp2_session *h2);
-
/*
* h2_process_pending_input() processes pending input left in
* httpc->inbuf. Then, call h2_session_send() to send pending data.
* This function returns 0 if it succeeds, or -1 and error code will
* be assigned to *err.
*/
-static int h2_process_pending_input(struct Curl_easy *data,
+static int h2_process_pending_input(struct connectdata *conn,
struct http_conn *httpc,
CURLcode *err)
{
ssize_t nread;
char *inbuf;
ssize_t rv;
+ struct Curl_easy *data = conn->data;
nread = httpc->inbuflen - httpc->nread_inbuf;
inbuf = httpc->inbuf + httpc->nread_inbuf;
@@ -1192,13 +1357,13 @@ static int h2_process_pending_input(struct Curl_easy *data,
if(rv < 0) {
failf(data,
"h2_process_pending_input: nghttp2_session_mem_recv() returned "
- "%d:%s\n", rv, nghttp2_strerror((int)rv));
+ "%zd:%s\n", rv, nghttp2_strerror((int)rv));
*err = CURLE_RECV_ERROR;
return -1;
}
if(nread == rv) {
- DEBUGF(infof(data,
+ H2BUGF(infof(data,
"h2_process_pending_input: All data in connection buffer "
"processed\n"));
httpc->inbuflen = 0;
@@ -1206,7 +1371,7 @@ static int h2_process_pending_input(struct Curl_easy *data,
}
else {
httpc->nread_inbuf += rv;
- DEBUGF(infof(data,
+ H2BUGF(infof(data,
"h2_process_pending_input: %zu bytes left in connection "
"buffer\n",
httpc->inbuflen - httpc->nread_inbuf));
@@ -1219,9 +1384,15 @@ static int h2_process_pending_input(struct Curl_easy *data,
}
if(should_close_session(httpc)) {
- DEBUGF(infof(data,
+ H2BUGF(infof(data,
"h2_process_pending_input: nothing to do in this session\n"));
- *err = CURLE_HTTP2;
+ if(httpc->error_code)
+ *err = CURLE_HTTP2;
+ else {
+ /* not an error per se, but should still close the connection */
+ connclose(conn, "GOAWAY received");
+ *err = CURLE_OK;
+ }
return -1;
}
@@ -1252,13 +1423,12 @@ CURLcode Curl_http2_done_sending(struct connectdata *conn)
that it can signal EOF to nghttp2 */
(void)nghttp2_session_resume_data(h2, stream->stream_id);
- (void)h2_process_pending_input(conn->data, httpc, &result);
+ (void)h2_process_pending_input(conn, httpc, &result);
}
}
return result;
}
-
static ssize_t http2_handle_stream_close(struct connectdata *conn,
struct Curl_easy *data,
struct HTTP *stream, CURLcode *err)
@@ -1271,12 +1441,10 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn,
httpc->pause_stream_id = 0;
}
- DEBUGASSERT(httpc->drain_total >= data->state.drain);
- httpc->drain_total -= data->state.drain;
- data->state.drain = 0;
+ drained_transfer(data, httpc);
if(httpc->pause_stream_id == 0) {
- if(h2_process_pending_input(data, httpc, err) != 0) {
+ if(h2_process_pending_input(conn, httpc, err) != 0) {
return -1;
}
}
@@ -1285,17 +1453,25 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn,
/* Reset to FALSE to prevent infinite loop in readwrite_data function. */
stream->closed = FALSE;
- if(stream->error_code != NGHTTP2_NO_ERROR) {
- failf(data, "HTTP/2 stream %u was not closed cleanly: %s (err %d)",
- stream->stream_id, Curl_http2_strerror(stream->error_code),
- stream->error_code);
+ if(httpc->error_code == NGHTTP2_REFUSED_STREAM) {
+ H2BUGF(infof(data, "REFUSED_STREAM (%d), try again on a new connection!\n",
+ stream->stream_id));
+ connclose(conn, "REFUSED_STREAM"); /* don't use this anymore */
+ data->state.refused_stream = TRUE;
+ *err = CURLE_RECV_ERROR; /* trigger Curl_retry_request() later */
+ return -1;
+ }
+ else if(httpc->error_code != NGHTTP2_NO_ERROR) {
+ failf(data, "HTTP/2 stream %d was not closed cleanly: %s (err %u)",
+ stream->stream_id, http2_strerror(httpc->error_code),
+ httpc->error_code);
*err = CURLE_HTTP2_STREAM;
return -1;
}
if(!stream->bodystarted) {
- failf(data, "HTTP/2 stream %u was closed cleanly, but before getting "
- " all response header fields, teated as error",
+ failf(data, "HTTP/2 stream %d was closed cleanly, but before getting "
+ " all response header fields, treated as error",
stream->stream_id);
*err = CURLE_HTTP2_STREAM;
return -1;
@@ -1322,7 +1498,7 @@ static ssize_t http2_handle_stream_close(struct connectdata *conn,
stream->close_handled = TRUE;
- DEBUGF(infof(data, "http2_recv returns 0, http2_handle_stream_close\n"));
+ H2BUGF(infof(data, "http2_recv returns 0, http2_handle_stream_close\n"));
return 0;
}
@@ -1363,7 +1539,7 @@ static int h2_session_send(struct Curl_easy *data,
h2_pri_spec(data, &pri_spec);
- DEBUGF(infof(data, "Queuing PRIORITY on stream %u (easy %p)\n",
+ H2BUGF(infof(data, "Queuing PRIORITY on stream %u (easy %p)\n",
stream->stream_id, data));
rv = nghttp2_submit_priority(h2, NGHTTP2_FLAG_NONE, stream->stream_id,
&pri_spec);
@@ -1387,7 +1563,7 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
(void)sockindex; /* we always do HTTP2 on sockindex 0 */
if(should_close_session(httpc)) {
- DEBUGF(infof(data,
+ H2BUGF(infof(data,
"http2_recv: nothing to do in this session\n"));
*err = CURLE_HTTP2;
return -1;
@@ -1408,21 +1584,21 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
/* If there is body data pending for this stream to return, do that */
size_t left =
stream->header_recvbuf->size_used - stream->nread_header_recvbuf;
- size_t ncopy = MIN(len, left);
+ size_t ncopy = CURLMIN(len, left);
memcpy(mem, stream->header_recvbuf->buffer + stream->nread_header_recvbuf,
ncopy);
stream->nread_header_recvbuf += ncopy;
- DEBUGF(infof(data, "http2_recv: Got %d bytes from header_recvbuf\n",
+ H2BUGF(infof(data, "http2_recv: Got %d bytes from header_recvbuf\n",
(int)ncopy));
return ncopy;
}
- DEBUGF(infof(data, "http2_recv: easy %p (stream %u)\n",
+ H2BUGF(infof(data, "http2_recv: easy %p (stream %u)\n",
data, stream->stream_id));
if((data->state.drain) && stream->memlen) {
- DEBUGF(infof(data, "http2_recv: DRAIN %zu bytes stream %u!! (%p => %p)\n",
+ H2BUGF(infof(data, "http2_recv: DRAIN %zu bytes stream %u!! (%p => %p)\n",
stream->memlen, stream->stream_id,
stream->mem, mem));
if(mem != stream->mem) {
@@ -1436,7 +1612,7 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
/* We have paused nghttp2, but we have no pause data (see
on_data_chunk_recv). */
httpc->pause_stream_id = 0;
- if(h2_process_pending_input(data, httpc, &result) != 0) {
+ if(h2_process_pending_input(conn, httpc, &result) != 0) {
*err = result;
return -1;
}
@@ -1444,15 +1620,15 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
}
else if(stream->pausedata) {
DEBUGASSERT(httpc->pause_stream_id == stream->stream_id);
- nread = MIN(len, stream->pauselen);
+ nread = CURLMIN(len, stream->pauselen);
memcpy(mem, stream->pausedata, nread);
stream->pausedata += nread;
stream->pauselen -= nread;
- infof(data, "%zu data bytes written\n", nread);
+ infof(data, "%zd data bytes written\n", nread);
if(stream->pauselen == 0) {
- DEBUGF(infof(data, "Unpaused by stream %u\n", stream->stream_id));
+ H2BUGF(infof(data, "Unpaused by stream %u\n", stream->stream_id));
DEBUGASSERT(httpc->pause_stream_id == stream->stream_id);
httpc->pause_stream_id = 0;
@@ -1466,12 +1642,12 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
frames, then we have to call it again with 0-length data.
Without this, on_stream_close callback will not be called,
and stream could be hanged. */
- if(h2_process_pending_input(data, httpc, &result) != 0) {
+ if(h2_process_pending_input(conn, httpc, &result) != 0) {
*err = result;
return -1;
}
}
- DEBUGF(infof(data, "http2_recv: returns unpaused %zd bytes on stream %u\n",
+ H2BUGF(infof(data, "http2_recv: returns unpaused %zd bytes on stream %u\n",
nread, stream->stream_id));
return nread;
}
@@ -1484,7 +1660,7 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
socket is not read. But it seems that usually streams are
notified with its drain property, and socket is read again
quickly. */
- DEBUGF(infof(data, "stream %x is paused, pause id: %x\n",
+ H2BUGF(infof(data, "stream %x is paused, pause id: %x\n",
stream->stream_id, httpc->pause_stream_id));
*err = CURLE_AGAIN;
return -1;
@@ -1513,12 +1689,12 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
}
if(nread == 0) {
- failf(data, "Unexpected EOF");
- *err = CURLE_RECV_ERROR;
- return -1;
+ H2BUGF(infof(data, "end of stream\n"));
+ *err = CURLE_OK;
+ return 0;
}
- DEBUGF(infof(data, "nread=%zd\n", nread));
+ H2BUGF(infof(data, "nread=%zd\n", nread));
httpc->inbuflen = nread;
inbuf = httpc->inbuf;
@@ -1527,26 +1703,26 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
nread = httpc->inbuflen - httpc->nread_inbuf;
inbuf = httpc->inbuf + httpc->nread_inbuf;
- DEBUGF(infof(data, "Use data left in connection buffer, nread=%zd\n",
+ H2BUGF(infof(data, "Use data left in connection buffer, nread=%zd\n",
nread));
}
rv = nghttp2_session_mem_recv(httpc->h2, (const uint8_t *)inbuf, nread);
if(nghttp2_is_fatal((int)rv)) {
- failf(data, "nghttp2_session_mem_recv() returned %d:%s\n",
+ failf(data, "nghttp2_session_mem_recv() returned %zd:%s\n",
rv, nghttp2_strerror((int)rv));
*err = CURLE_RECV_ERROR;
- return 0;
+ return -1;
}
- DEBUGF(infof(data, "nghttp2_session_mem_recv() returns %zd\n", rv));
+ H2BUGF(infof(data, "nghttp2_session_mem_recv() returns %zd\n", rv));
if(nread == rv) {
- DEBUGF(infof(data, "All data in connection buffer processed\n"));
+ H2BUGF(infof(data, "All data in connection buffer processed\n"));
httpc->inbuflen = 0;
httpc->nread_inbuf = 0;
}
else {
httpc->nread_inbuf += rv;
- DEBUGF(infof(data, "%zu bytes left in connection buffer\n",
+ H2BUGF(infof(data, "%zu bytes left in connection buffer\n",
httpc->inbuflen - httpc->nread_inbuf));
}
/* Always send pending frames in nghttp2 session, because
@@ -1554,31 +1730,29 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
rv = h2_session_send(data, httpc->h2);
if(rv != 0) {
*err = CURLE_SEND_ERROR;
- return 0;
+ return -1;
}
if(should_close_session(httpc)) {
- DEBUGF(infof(data, "http2_recv: nothing to do in this session\n"));
+ H2BUGF(infof(data, "http2_recv: nothing to do in this session\n"));
*err = CURLE_HTTP2;
return -1;
}
}
if(stream->memlen) {
ssize_t retlen = stream->memlen;
- DEBUGF(infof(data, "http2_recv: returns %zd for stream %u\n",
+ H2BUGF(infof(data, "http2_recv: returns %zd for stream %u\n",
retlen, stream->stream_id));
stream->memlen = 0;
if(httpc->pause_stream_id == stream->stream_id) {
/* data for this stream is returned now, but this stream caused a pause
already so we need it called again asap */
- DEBUGF(infof(data, "Data returned for PAUSED stream %u\n",
+ H2BUGF(infof(data, "Data returned for PAUSED stream %u\n",
stream->stream_id));
}
else if(!stream->closed) {
- DEBUGASSERT(httpc->drain_total >= data->state.drain);
- httpc->drain_total -= data->state.drain;
- data->state.drain = 0; /* this stream is hereby drained */
+ drained_transfer(data, httpc);
}
return retlen;
@@ -1589,7 +1763,7 @@ static ssize_t http2_recv(struct connectdata *conn, int sockindex,
return http2_handle_stream_close(conn, data, stream, err);
}
*err = CURLE_AGAIN;
- DEBUGF(infof(data, "http2_recv returns AGAIN for stream %u\n",
+ H2BUGF(infof(data, "http2_recv returns AGAIN for stream %u\n",
stream->stream_id));
return -1;
}
@@ -1671,9 +1845,9 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
const void *mem, size_t len, CURLcode *err)
{
/*
- * BIG TODO: Currently, we send request in this function, but this
- * function is also used to send request body. It would be nice to
- * add dedicated function for request.
+ * Currently, we send request in this function, but this function is also
+ * used to send request body. It would be nice to add dedicated function for
+ * request.
*/
int rv;
struct http_conn *httpc = &conn->proto.httpc;
@@ -1691,7 +1865,7 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
(void)sockindex;
- DEBUGF(infof(conn->data, "http2_send len=%zu\n", len));
+ H2BUGF(infof(conn->data, "http2_send len=%zu\n", len));
if(stream->stream_id != -1) {
if(stream->close_handled) {
@@ -1720,7 +1894,7 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
stream->upload_len = 0;
if(should_close_session(httpc)) {
- DEBUGF(infof(conn->data, "http2_send: nothing to do in this session\n"));
+ H2BUGF(infof(conn->data, "http2_send: nothing to do in this session\n"));
*err = CURLE_HTTP2;
return -1;
}
@@ -1733,7 +1907,7 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
nghttp2_session_resume_data(h2, stream->stream_id);
}
- DEBUGF(infof(conn->data, "http2_send returns %zu for stream %u\n", len,
+ H2BUGF(infof(conn->data, "http2_send returns %zu for stream %u\n", len,
stream->stream_id));
return len;
}
@@ -1761,8 +1935,11 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
return -1;
}
- /* Extract :method, :path from request line */
- line_end = strstr(hdbuf, "\r\n");
+ /* Extract :method, :path from request line
+ We do line endings with CRLF so checking for CR is enough */
+ line_end = memchr(hdbuf, '\r', len);
+ if(!line_end)
+ goto fail;
/* Method does not contain spaces */
end = memchr(hdbuf, ' ', line_end - hdbuf);
@@ -1800,9 +1977,6 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
goto fail;
}
- hdbuf = end + 1;
-
- end = line_end;
nva[2].name = (unsigned char *)":scheme";
nva[2].namelen = strlen((char *)nva[2].name);
if(conn->handler->flags & PROTOPT_SSL)
@@ -1823,8 +1997,10 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
hdbuf = line_end + 2;
- line_end = strstr(hdbuf, "\r\n");
- if(line_end == hdbuf)
+ /* check for next CR, but only within the piece of data left in the given
+ buffer */
+ line_end = memchr(hdbuf, '\r', len - (hdbuf - (char *)mem));
+ if(!line_end || (line_end == hdbuf))
goto fail;
/* header continuation lines are not supported */
@@ -1892,7 +2068,7 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
for(i = 0; i < nheader; ++i) {
acc += nva[i].namelen + nva[i].valuelen;
- DEBUGF(infof(conn->data, "h2 header: %.*s:%.*s\n",
+ H2BUGF(infof(conn->data, "h2 header: %.*s:%.*s\n",
nva[i].namelen, nva[i].name,
nva[i].valuelen, nva[i].value));
}
@@ -1909,6 +2085,7 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
switch(conn->data->set.httpreq) {
case HTTPREQ_POST:
case HTTPREQ_POST_FORM:
+ case HTTPREQ_POST_MIME:
case HTTPREQ_PUT:
if(conn->data->state.infilesize != -1)
stream->upload_left = conn->data->state.infilesize;
@@ -1929,13 +2106,13 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
Curl_safefree(nva);
if(stream_id < 0) {
- DEBUGF(infof(conn->data, "http2_send() send error\n"));
+ H2BUGF(infof(conn->data, "http2_send() send error\n"));
*err = CURLE_SEND_ERROR;
return -1;
}
infof(conn->data, "Using Stream ID: %x (easy handle %p)\n",
- stream_id, conn->data);
+ stream_id, (void *)conn->data);
stream->stream_id = stream_id;
/* this does not call h2_session_send() since there can not have been any
@@ -1948,7 +2125,7 @@ static ssize_t http2_send(struct connectdata *conn, int sockindex,
}
if(should_close_session(httpc)) {
- DEBUGF(infof(conn->data, "http2_send: nothing to do in this session\n"));
+ H2BUGF(infof(conn->data, "http2_send: nothing to do in this session\n"));
*err = CURLE_HTTP2;
return -1;
}
@@ -1981,8 +2158,11 @@ CURLcode Curl_http2_setup(struct connectdata *conn)
stream->stream_id = -1;
- if(!stream->header_recvbuf)
+ if(!stream->header_recvbuf) {
stream->header_recvbuf = Curl_add_buffer_init();
+ if(!stream->header_recvbuf)
+ return CURLE_OUT_OF_MEMORY;
+ }
if((conn->handler == &Curl_handler_http2_ssl) ||
(conn->handler == &Curl_handler_http2))
@@ -1993,9 +2173,11 @@ CURLcode Curl_http2_setup(struct connectdata *conn)
else
conn->handler = &Curl_handler_http2;
- result = Curl_http2_init(conn);
- if(result)
+ result = http2_init(conn);
+ if(result) {
+ Curl_add_buffer_free(&stream->header_recvbuf);
return result;
+ }
infof(conn->data, "Using HTTP2, server supports multi-use\n");
stream->upload_left = 0;
@@ -2013,7 +2195,7 @@ CURLcode Curl_http2_setup(struct connectdata *conn)
conn->bundle->multiuse = BUNDLE_MULTIPLEX;
infof(conn->data, "Connection state changed (HTTP/2 confirmed)\n");
- Curl_multi_connchanged(conn->data->multi);
+ multi_connchanged(conn->data->multi);
return CURLE_OK;
}
@@ -2032,8 +2214,8 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
if(result)
return result;
- httpc->recv_underlying = (recving)conn->recv[FIRSTSOCKET];
- httpc->send_underlying = (sending)conn->send[FIRSTSOCKET];
+ httpc->recv_underlying = conn->recv[FIRSTSOCKET];
+ httpc->send_underlying = conn->send[FIRSTSOCKET];
conn->recv[FIRSTSOCKET] = http2_recv;
conn->send[FIRSTSOCKET] = http2_send;
@@ -2049,9 +2231,14 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
return CURLE_HTTP2;
}
- nghttp2_session_set_stream_user_data(httpc->h2,
- stream->stream_id,
- conn->data);
+ rv = nghttp2_session_set_stream_user_data(httpc->h2,
+ stream->stream_id,
+ data);
+ if(rv) {
+ infof(data, "http/2: failed to set user_data for stream %d!\n",
+ stream->stream_id);
+ DEBUGASSERT(0);
+ }
}
else {
populate_settings(conn, httpc);
@@ -2106,7 +2293,7 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
return CURLE_HTTP2;
}
- DEBUGF(infof(data, "nghttp2_session_mem_recv() returns %zd\n", nproc));
+ H2BUGF(infof(data, "nghttp2_session_mem_recv() returns %zd\n", nproc));
if((ssize_t)nread == nproc) {
httpc->inbuflen = 0;
@@ -2126,7 +2313,7 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
}
if(should_close_session(httpc)) {
- DEBUGF(infof(data,
+ H2BUGF(infof(data,
"nghttp2_session_send(): nothing to do in this session\n"));
return CURLE_HTTP2;
}
@@ -2134,12 +2321,15 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
return CURLE_OK;
}
-void Curl_http2_add_child(struct Curl_easy *parent, struct Curl_easy *child,
- bool exclusive)
+CURLcode Curl_http2_add_child(struct Curl_easy *parent,
+ struct Curl_easy *child,
+ bool exclusive)
{
if(parent) {
struct Curl_http2_dep **tail;
struct Curl_http2_dep *dep = calloc(1, sizeof(struct Curl_http2_dep));
+ if(!dep)
+ return CURLE_OUT_OF_MEMORY;
dep->data = child;
if(parent->set.stream_dependents && exclusive) {
@@ -2170,6 +2360,7 @@ void Curl_http2_add_child(struct Curl_easy *parent, struct Curl_easy *child,
child->set.stream_depends_on = parent;
child->set.stream_depends_e = exclusive;
+ return CURLE_OK;
}
void Curl_http2_remove_child(struct Curl_easy *parent, struct Curl_easy *child)
@@ -2212,6 +2403,14 @@ void Curl_http2_cleanup_dependencies(struct Curl_easy *data)
Curl_http2_remove_child(data->set.stream_depends_on, data);
}
+/* Only call this function for a transfer that already got a HTTP/2
+ CURLE_HTTP2_STREAM error! */
+bool Curl_h2_http_1_1_error(struct connectdata *conn)
+{
+ struct http_conn *httpc = &conn->proto.httpc;
+ return (httpc->error_code == NGHTTP2_HTTP_1_1_REQUIRED);
+}
+
#else /* !USE_NGHTTP2 */
/* Satisfy external references even if http2 is not compiled in. */
diff --git a/Utilities/cmcurl/lib/http2.h b/Utilities/cmcurl/lib/http2.h
index f405b3aeb..db6217b11 100644
--- a/Utilities/cmcurl/lib/http2.h
+++ b/Utilities/cmcurl/lib/http2.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -53,18 +53,21 @@ void Curl_http2_setup_conn(struct connectdata *conn);
void Curl_http2_setup_req(struct Curl_easy *data);
void Curl_http2_done(struct connectdata *conn, bool premature);
CURLcode Curl_http2_done_sending(struct connectdata *conn);
-void Curl_http2_add_child(struct Curl_easy *parent, struct Curl_easy *child,
- bool exclusive);
+CURLcode Curl_http2_add_child(struct Curl_easy *parent,
+ struct Curl_easy *child,
+ bool exclusive);
void Curl_http2_remove_child(struct Curl_easy *parent,
struct Curl_easy *child);
void Curl_http2_cleanup_dependencies(struct Curl_easy *data);
+
+/* returns true if the HTTP/2 stream error was HTTP_1_1_REQUIRED */
+bool Curl_h2_http_1_1_error(struct connectdata *conn);
#else /* USE_NGHTTP2 */
-#define Curl_http2_init(x) CURLE_UNSUPPORTED_PROTOCOL
#define Curl_http2_send_request(x) CURLE_UNSUPPORTED_PROTOCOL
#define Curl_http2_request_upgrade(x,y) CURLE_UNSUPPORTED_PROTOCOL
#define Curl_http2_setup(x) CURLE_UNSUPPORTED_PROTOCOL
#define Curl_http2_switched(x,y,z) CURLE_UNSUPPORTED_PROTOCOL
-#define Curl_http2_setup_conn(x)
+#define Curl_http2_setup_conn(x) Curl_nop_stmt
#define Curl_http2_setup_req(x)
#define Curl_http2_init_state(x)
#define Curl_http2_init_userset(x)
@@ -73,7 +76,7 @@ void Curl_http2_cleanup_dependencies(struct Curl_easy *data);
#define Curl_http2_add_child(x, y, z)
#define Curl_http2_remove_child(x, y)
#define Curl_http2_cleanup_dependencies(x)
+#define Curl_h2_http_1_1_error(x) 0
#endif
#endif /* HEADER_CURL_HTTP2_H */
-
diff --git a/Utilities/cmcurl/lib/http_chunks.c b/Utilities/cmcurl/lib/http_chunks.c
index 1bdf6974c..18dfcb282 100644
--- a/Utilities/cmcurl/lib/http_chunks.c
+++ b/Utilities/cmcurl/lib/http_chunks.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -74,20 +74,24 @@
*/
+#ifdef CURL_DOES_CONVERSIONS
/* Check for an ASCII hex digit.
- We avoid the use of isxdigit to accommodate non-ASCII hosts. */
-static bool Curl_isxdigit(char digit)
+ We avoid the use of ISXDIGIT to accommodate non-ASCII hosts. */
+static bool Curl_isxdigit_ascii(char digit)
{
- return ( (digit >= 0x30 && digit <= 0x39) /* 0-9 */
+ return (digit >= 0x30 && digit <= 0x39) /* 0-9 */
|| (digit >= 0x41 && digit <= 0x46) /* A-F */
- || (digit >= 0x61 && digit <= 0x66) /* a-f */) ? TRUE : FALSE;
+ || (digit >= 0x61 && digit <= 0x66); /* a-f */
}
+#else
+#define Curl_isxdigit_ascii(x) Curl_isxdigit(x)
+#endif
void Curl_httpchunk_init(struct connectdata *conn)
{
struct Curl_chunker *chunk = &conn->chunk;
- chunk->hexindex=0; /* start at 0 */
- chunk->dataleft=0; /* no data left yet! */
+ chunk->hexindex = 0; /* start at 0 */
+ chunk->dataleft = 0; /* no data left yet! */
chunk->state = CHUNK_HEX; /* we get hex first! */
}
@@ -107,7 +111,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
ssize_t datalen,
ssize_t *wrotep)
{
- CURLcode result=CURLE_OK;
+ CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
struct Curl_chunker *ch = &conn->chunk;
struct SingleRequest *k = &data->req;
@@ -128,7 +132,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
while(length) {
switch(ch->state) {
case CHUNK_HEX:
- if(Curl_isxdigit(*datap)) {
+ if(Curl_isxdigit_ascii(*datap)) {
if(ch->hexindex < MAXNUM_SIZE) {
ch->hexbuffer[ch->hexindex] = *datap;
datap++;
@@ -147,7 +151,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
return CHUNKE_ILLEGAL_HEX;
/* length and datap are unmodified */
- ch->hexbuffer[ch->hexindex]=0;
+ ch->hexbuffer[ch->hexindex] = 0;
/* convert to host encoding before calling strtoul */
result = Curl_convert_from_network(conn->data, ch->hexbuffer,
@@ -158,9 +162,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
return CHUNKE_ILLEGAL_HEX;
}
- ch->datasize=curlx_strtoofft(ch->hexbuffer, &endptr, 16);
- if((ch->datasize == CURL_OFF_T_MAX) && (errno == ERANGE))
- /* overflow is an error */
+ if(curlx_strtoofft(ch->hexbuffer, &endptr, 16, &ch->datasize))
return CHUNKE_ILLEGAL_HEX;
ch->state = CHUNK_LF; /* now wait for the CRLF */
}
@@ -172,7 +174,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
/* we're now expecting data to come, unless size was zero! */
if(0 == ch->datasize) {
ch->state = CHUNK_TRAILER; /* now check for trailers */
- conn->trlPos=0;
+ conn->trlPos = 0;
}
else
ch->state = CHUNK_DATA;
@@ -189,49 +191,17 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
piece = curlx_sotouz((ch->datasize >= length)?length:ch->datasize);
/* Write the data portion available */
-#ifdef HAVE_LIBZ
- switch(conn->data->set.http_ce_skip?
- IDENTITY : data->req.auto_decoding) {
- case IDENTITY:
-#endif
- if(!k->ignorebody) {
- if(!data->set.http_te_skip)
- result = Curl_client_write(conn, CLIENTWRITE_BODY, datap,
- piece);
- else
- result = CURLE_OK;
- }
-#ifdef HAVE_LIBZ
- break;
-
- case DEFLATE:
- /* update data->req.keep.str to point to the chunk data. */
- data->req.str = datap;
- result = Curl_unencode_deflate_write(conn, &data->req,
- (ssize_t)piece);
- break;
-
- case GZIP:
- /* update data->req.keep.str to point to the chunk data. */
- data->req.str = datap;
- result = Curl_unencode_gzip_write(conn, &data->req,
- (ssize_t)piece);
- break;
+ if(!conn->data->set.http_te_skip && !k->ignorebody) {
+ if(!conn->data->set.http_ce_skip && k->writer_stack)
+ result = Curl_unencode_write(conn, k->writer_stack, datap, piece);
+ else
+ result = Curl_client_write(conn, CLIENTWRITE_BODY, datap, piece);
- default:
- failf(conn->data,
- "Unrecognized content encoding type. "
- "libcurl understands `identity', `deflate' and `gzip' "
- "content encodings.");
- return CHUNKE_BAD_ENCODING;
+ if(result)
+ return CHUNKE_WRITE_ERROR;
}
-#endif
-
- if(result)
- return CHUNKE_WRITE_ERROR;
*wrote += piece;
-
ch->datasize -= piece; /* decrease amount left to expect */
datap += piece; /* move read pointer forward */
length -= piece; /* decrease space left in this round */
@@ -259,9 +229,9 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
if(conn->trlPos) {
/* we allocate trailer with 3 bytes extra room to fit this */
- conn->trailer[conn->trlPos++]=0x0d;
- conn->trailer[conn->trlPos++]=0x0a;
- conn->trailer[conn->trlPos]=0;
+ conn->trailer[conn->trlPos++] = 0x0d;
+ conn->trailer[conn->trlPos++] = 0x0a;
+ conn->trailer[conn->trlPos] = 0;
/* Convert to host encoding before calling Curl_client_write */
result = Curl_convert_from_network(conn->data, conn->trailer,
@@ -277,7 +247,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
if(result)
return CHUNKE_WRITE_ERROR;
}
- conn->trlPos=0;
+ conn->trlPos = 0;
ch->state = CHUNK_TRAILER_CR;
if(*datap == 0x0a)
/* already on the LF */
@@ -301,7 +271,7 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
ptr = realloc(conn->trailer, conn->trlMax + 3);
}
else {
- conn->trlMax=128;
+ conn->trlMax = 128;
ptr = malloc(conn->trlMax + 3);
}
if(!ptr)
diff --git a/Utilities/cmcurl/lib/http_chunks.h b/Utilities/cmcurl/lib/http_chunks.h
index 3a8b4ddf3..b969c5590 100644
--- a/Utilities/cmcurl/lib/http_chunks.h
+++ b/Utilities/cmcurl/lib/http_chunks.h
@@ -88,4 +88,3 @@ struct Curl_chunker {
};
#endif /* HEADER_CURL_HTTP_CHUNKS_H */
-
diff --git a/Utilities/cmcurl/lib/http_digest.c b/Utilities/cmcurl/lib/http_digest.c
index e2d865b0a..9616c30ed 100644
--- a/Utilities/cmcurl/lib/http_digest.c
+++ b/Utilities/cmcurl/lib/http_digest.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -28,6 +28,7 @@
#include "strcase.h"
#include "vauth/vauth.h"
#include "http_digest.h"
+
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
@@ -171,7 +172,7 @@ CURLcode Curl_output_digest(struct connectdata *conn,
return CURLE_OK;
}
-void Curl_digest_cleanup(struct Curl_easy *data)
+void Curl_http_auth_cleanup_digest(struct Curl_easy *data)
{
Curl_auth_digest_cleanup(&data->state.digest);
Curl_auth_digest_cleanup(&data->state.proxydigest);
diff --git a/Utilities/cmcurl/lib/http_digest.h b/Utilities/cmcurl/lib/http_digest.h
index fd225c7c1..73410ae88 100644
--- a/Utilities/cmcurl/lib/http_digest.h
+++ b/Utilities/cmcurl/lib/http_digest.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -23,6 +23,8 @@
***************************************************************************/
#include "curl_setup.h"
+#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_CRYPTO_AUTH)
+
/* this is for digest header input */
CURLcode Curl_input_digest(struct connectdata *conn,
bool proxy, const char *header);
@@ -33,10 +35,8 @@ CURLcode Curl_output_digest(struct connectdata *conn,
const unsigned char *request,
const unsigned char *uripath);
-#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_CRYPTO_AUTH)
-void Curl_digest_cleanup(struct Curl_easy *data);
-#else
-#define Curl_digest_cleanup(x) Curl_nop_stmt
-#endif
+void Curl_http_auth_cleanup_digest(struct Curl_easy *data);
+
+#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_CRYPTO_AUTH */
#endif /* HEADER_CURL_HTTP_DIGEST_H */
diff --git a/Utilities/cmcurl/lib/http_negotiate.c b/Utilities/cmcurl/lib/http_negotiate.c
index 51375e81d..c8f406444 100644
--- a/Utilities/cmcurl/lib/http_negotiate.c
+++ b/Utilities/cmcurl/lib/http_negotiate.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -49,6 +49,7 @@ CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy,
/* Point to the correct struct with this */
struct negotiatedata *neg_ctx;
+ curlnegotiate state;
if(proxy) {
userp = conn->http_proxy.user;
@@ -56,7 +57,8 @@ CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy,
service = data->set.str[STRING_PROXY_SERVICE_NAME] ?
data->set.str[STRING_PROXY_SERVICE_NAME] : "HTTP";
host = conn->http_proxy.host.name;
- neg_ctx = &data->state.proxyneg;
+ neg_ctx = &conn->proxyneg;
+ state = conn->proxy_negotiate_state;
}
else {
userp = conn->user;
@@ -64,7 +66,8 @@ CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy,
service = data->set.str[STRING_SERVICE_NAME] ?
data->set.str[STRING_SERVICE_NAME] : "HTTP";
host = conn->host.name;
- neg_ctx = &data->state.negotiate;
+ neg_ctx = &conn->negotiate;
+ state = conn->http_negotiate_state;
}
/* Not set means empty */
@@ -80,59 +83,138 @@ CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy,
header++;
len = strlen(header);
+ neg_ctx->havenegdata = len != 0;
if(!len) {
- /* Is this the first call in a new negotiation? */
- if(neg_ctx->context) {
- /* The server rejected our authentication and hasn't suppled any more
+ if(state == GSS_AUTHSUCC) {
+ infof(conn->data, "Negotiate auth restarted\n");
+ Curl_http_auth_cleanup_negotiate(conn);
+ }
+ else if(state != GSS_AUTHNONE) {
+ /* The server rejected our authentication and hasn't supplied any more
negotiation mechanisms */
+ Curl_http_auth_cleanup_negotiate(conn);
return CURLE_LOGIN_DENIED;
}
}
- /* Initilise the security context and decode our challenge */
+ /* Supports SSL channel binding for Windows ISS extended protection */
+#if defined(USE_WINDOWS_SSPI) && defined(SECPKG_ATTR_ENDPOINT_BINDINGS)
+ neg_ctx->sslContext = conn->sslContext;
+#endif
+
+ /* Initialize the security context and decode our challenge */
result = Curl_auth_decode_spnego_message(data, userp, passwdp, service,
host, header, neg_ctx);
if(result)
- Curl_auth_spnego_cleanup(neg_ctx);
+ Curl_http_auth_cleanup_negotiate(conn);
return result;
}
CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy)
{
- struct negotiatedata *neg_ctx = proxy ? &conn->data->state.proxyneg :
- &conn->data->state.negotiate;
+ struct negotiatedata *neg_ctx = proxy ? &conn->proxyneg :
+ &conn->negotiate;
+ struct auth *authp = proxy ? &conn->data->state.authproxy :
+ &conn->data->state.authhost;
+ curlnegotiate *state = proxy ? &conn->proxy_negotiate_state :
+ &conn->http_negotiate_state;
char *base64 = NULL;
size_t len = 0;
char *userp;
CURLcode result;
- result = Curl_auth_create_spnego_message(conn->data, neg_ctx, &base64, &len);
- if(result)
- return result;
+ authp->done = FALSE;
- userp = aprintf("%sAuthorization: Negotiate %s\r\n", proxy ? "Proxy-" : "",
- base64);
+ if(*state == GSS_AUTHRECV) {
+ if(neg_ctx->havenegdata) {
+ neg_ctx->havemultiplerequests = TRUE;
+ }
+ }
+ else if(*state == GSS_AUTHSUCC) {
+ if(!neg_ctx->havenoauthpersist) {
+ neg_ctx->noauthpersist = !neg_ctx->havemultiplerequests;
+ }
+ }
- if(proxy) {
- Curl_safefree(conn->allocptr.proxyuserpwd);
- conn->allocptr.proxyuserpwd = userp;
+ if(neg_ctx->noauthpersist ||
+ (*state != GSS_AUTHDONE && *state != GSS_AUTHSUCC)) {
+
+ if(neg_ctx->noauthpersist && *state == GSS_AUTHSUCC) {
+ infof(conn->data, "Curl_output_negotiate, "
+ "no persistent authentication: cleanup existing context");
+ Curl_http_auth_cleanup_negotiate(conn);
+ }
+ if(!neg_ctx->context) {
+ result = Curl_input_negotiate(conn, proxy, "Negotiate");
+ if(result == CURLE_LOGIN_DENIED) {
+ /* negotiate auth failed, let's continue unauthenticated to stay
+ * compatible with the behavior before curl-7_64_0-158-g6c6035532 */
+ conn->data->state.authproblem = TRUE;
+ return CURLE_OK;
+ }
+ else if(result)
+ return result;
+ }
+
+ result = Curl_auth_create_spnego_message(conn->data,
+ neg_ctx, &base64, &len);
+ if(result)
+ return result;
+
+ userp = aprintf("%sAuthorization: Negotiate %s\r\n", proxy ? "Proxy-" : "",
+ base64);
+
+ if(proxy) {
+ Curl_safefree(conn->allocptr.proxyuserpwd);
+ conn->allocptr.proxyuserpwd = userp;
+ }
+ else {
+ Curl_safefree(conn->allocptr.userpwd);
+ conn->allocptr.userpwd = userp;
+ }
+
+ free(base64);
+
+ if(userp == NULL) {
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ *state = GSS_AUTHSENT;
+ #ifdef HAVE_GSSAPI
+ if(neg_ctx->status == GSS_S_COMPLETE ||
+ neg_ctx->status == GSS_S_CONTINUE_NEEDED) {
+ *state = GSS_AUTHDONE;
+ }
+ #else
+ #ifdef USE_WINDOWS_SSPI
+ if(neg_ctx->status == SEC_E_OK ||
+ neg_ctx->status == SEC_I_CONTINUE_NEEDED) {
+ *state = GSS_AUTHDONE;
+ }
+ #endif
+ #endif
}
- else {
- Curl_safefree(conn->allocptr.userpwd);
- conn->allocptr.userpwd = userp;
+
+ if(*state == GSS_AUTHDONE || *state == GSS_AUTHSUCC) {
+ /* connection is already authenticated,
+ * don't send a header in future requests */
+ authp->done = TRUE;
}
- free(base64);
+ neg_ctx->havenegdata = FALSE;
- return (userp == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK;
+ return CURLE_OK;
}
-void Curl_cleanup_negotiate(struct Curl_easy *data)
+void Curl_http_auth_cleanup_negotiate(struct connectdata *conn)
{
- Curl_auth_spnego_cleanup(&data->state.negotiate);
- Curl_auth_spnego_cleanup(&data->state.proxyneg);
+ conn->http_negotiate_state = GSS_AUTHNONE;
+ conn->proxy_negotiate_state = GSS_AUTHNONE;
+
+ Curl_auth_cleanup_spnego(&conn->negotiate);
+ Curl_auth_cleanup_spnego(&conn->proxyneg);
}
#endif /* !CURL_DISABLE_HTTP && USE_SPNEGO */
diff --git a/Utilities/cmcurl/lib/http_negotiate.h b/Utilities/cmcurl/lib/http_negotiate.h
index c64e54825..4f0ac1686 100644
--- a/Utilities/cmcurl/lib/http_negotiate.h
+++ b/Utilities/cmcurl/lib/http_negotiate.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,7 +22,7 @@
*
***************************************************************************/
-#ifdef USE_SPNEGO
+#if !defined(CURL_DISABLE_HTTP) && defined(USE_SPNEGO)
/* this is for Negotiate header input */
CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy,
@@ -31,8 +31,8 @@ CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy,
/* this is for creating Negotiate header output */
CURLcode Curl_output_negotiate(struct connectdata *conn, bool proxy);
-void Curl_cleanup_negotiate(struct Curl_easy *data);
+void Curl_http_auth_cleanup_negotiate(struct connectdata *conn);
-#endif /* USE_SPNEGO */
+#endif /* !CURL_DISABLE_HTTP && USE_SPNEGO */
#endif /* HEADER_CURL_HTTP_NEGOTIATE_H */
diff --git a/Utilities/cmcurl/lib/http_ntlm.c b/Utilities/cmcurl/lib/http_ntlm.c
index 8a78bd293..e4a4fe05d 100644
--- a/Utilities/cmcurl/lib/http_ntlm.c
+++ b/Utilities/cmcurl/lib/http_ntlm.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -37,11 +37,14 @@
#include "sendf.h"
#include "strcase.h"
#include "http_ntlm.h"
+#include "curl_ntlm_core.h"
#include "curl_ntlm_wb.h"
#include "vauth/vauth.h"
#include "url.h"
-#if defined(USE_NSS)
+/* SSL backend-specific #if branches in this file must be kept in the order
+ documented in curl_ntlm_core. */
+#if defined(NTLM_NEEDS_NSS_INIT)
#include "vtls/nssg.h"
#elif defined(USE_WINDOWS_SSPI)
#include "curl_sspi.h"
@@ -65,9 +68,11 @@ CURLcode Curl_input_ntlm(struct connectdata *conn,
{
/* point to the correct struct with this */
struct ntlmdata *ntlm;
+ curlntlm *state;
CURLcode result = CURLE_OK;
ntlm = proxy ? &conn->proxyntlm : &conn->ntlm;
+ state = proxy ? &conn->proxy_ntlm_state : &conn->http_ntlm_state;
if(checkprefix("NTLM", header)) {
header += strlen("NTLM");
@@ -80,25 +85,25 @@ CURLcode Curl_input_ntlm(struct connectdata *conn,
if(result)
return result;
- ntlm->state = NTLMSTATE_TYPE2; /* We got a type-2 message */
+ *state = NTLMSTATE_TYPE2; /* We got a type-2 message */
}
else {
- if(ntlm->state == NTLMSTATE_LAST) {
+ if(*state == NTLMSTATE_LAST) {
infof(conn->data, "NTLM auth restarted\n");
- Curl_http_ntlm_cleanup(conn);
+ Curl_http_auth_cleanup_ntlm(conn);
}
- else if(ntlm->state == NTLMSTATE_TYPE3) {
+ else if(*state == NTLMSTATE_TYPE3) {
infof(conn->data, "NTLM handshake rejected\n");
- Curl_http_ntlm_cleanup(conn);
- ntlm->state = NTLMSTATE_NONE;
+ Curl_http_auth_cleanup_ntlm(conn);
+ *state = NTLMSTATE_NONE;
return CURLE_REMOTE_ACCESS_DENIED;
}
- else if(ntlm->state >= NTLMSTATE_TYPE1) {
+ else if(*state >= NTLMSTATE_TYPE1) {
infof(conn->data, "NTLM handshake failure (internal error)\n");
return CURLE_REMOTE_ACCESS_DENIED;
}
- ntlm->state = NTLMSTATE_TYPE1; /* We should send away a type-1 */
+ *state = NTLMSTATE_TYPE1; /* We should send away a type-1 */
}
}
@@ -118,18 +123,21 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
server, which is for a plain host or for a HTTP proxy */
char **allocuserpwd;
- /* point to the name and password for this */
+ /* point to the username, password, service and host */
const char *userp;
const char *passwdp;
+ const char *service = NULL;
+ const char *hostname = NULL;
/* point to the correct struct with this */
struct ntlmdata *ntlm;
+ curlntlm *state;
struct auth *authp;
DEBUGASSERT(conn);
DEBUGASSERT(conn->data);
-#ifdef USE_NSS
+#if defined(NTLM_NEEDS_NSS_INIT)
if(CURLE_OK != Curl_nss_force_init(conn->data))
return CURLE_OUT_OF_MEMORY;
#endif
@@ -138,14 +146,22 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
allocuserpwd = &conn->allocptr.proxyuserpwd;
userp = conn->http_proxy.user;
passwdp = conn->http_proxy.passwd;
+ service = conn->data->set.str[STRING_PROXY_SERVICE_NAME] ?
+ conn->data->set.str[STRING_PROXY_SERVICE_NAME] : "HTTP";
+ hostname = conn->http_proxy.host.name;
ntlm = &conn->proxyntlm;
+ state = &conn->proxy_ntlm_state;
authp = &conn->data->state.authproxy;
}
else {
allocuserpwd = &conn->allocptr.userpwd;
userp = conn->user;
passwdp = conn->passwd;
+ service = conn->data->set.str[STRING_SERVICE_NAME] ?
+ conn->data->set.str[STRING_SERVICE_NAME] : "HTTP";
+ hostname = conn->host.name;
ntlm = &conn->ntlm;
+ state = &conn->http_ntlm_state;
authp = &conn->data->state.authhost;
}
authp->done = FALSE;
@@ -164,13 +180,18 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
if(s_hSecDll == NULL)
return err;
}
+#ifdef SECPKG_ATTR_ENDPOINT_BINDINGS
+ ntlm->sslContext = conn->sslContext;
+#endif
#endif
- switch(ntlm->state) {
+ switch(*state) {
case NTLMSTATE_TYPE1:
default: /* for the weird cases we (re)start here */
/* Create a type-1 message */
- result = Curl_auth_create_ntlm_type1_message(userp, passwdp, ntlm, &base64,
+ result = Curl_auth_create_ntlm_type1_message(conn->data, userp, passwdp,
+ service, hostname,
+ ntlm, &base64,
&len);
if(result)
return result;
@@ -206,7 +227,7 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
DEBUG_OUT(fprintf(stderr, "**** %s\n ", *allocuserpwd));
- ntlm->state = NTLMSTATE_TYPE3; /* we send a type-3 */
+ *state = NTLMSTATE_TYPE3; /* we send a type-3 */
authp->done = TRUE;
}
break;
@@ -214,8 +235,8 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
case NTLMSTATE_TYPE3:
/* connection is already authenticated,
* don't send a header in future requests */
- ntlm->state = NTLMSTATE_LAST;
- /* fall-through */
+ *state = NTLMSTATE_LAST;
+ /* FALLTHROUGH */
case NTLMSTATE_LAST:
Curl_safefree(*allocuserpwd);
authp->done = TRUE;
@@ -225,13 +246,13 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy)
return CURLE_OK;
}
-void Curl_http_ntlm_cleanup(struct connectdata *conn)
+void Curl_http_auth_cleanup_ntlm(struct connectdata *conn)
{
- Curl_auth_ntlm_cleanup(&conn->ntlm);
- Curl_auth_ntlm_cleanup(&conn->proxyntlm);
+ Curl_auth_cleanup_ntlm(&conn->ntlm);
+ Curl_auth_cleanup_ntlm(&conn->proxyntlm);
#if defined(NTLM_WB_ENABLED)
- Curl_ntlm_wb_cleanup(conn);
+ Curl_http_auth_cleanup_ntlm_wb(conn);
#endif
}
diff --git a/Utilities/cmcurl/lib/http_ntlm.h b/Utilities/cmcurl/lib/http_ntlm.h
index d186bbe37..003714dbd 100644
--- a/Utilities/cmcurl/lib/http_ntlm.h
+++ b/Utilities/cmcurl/lib/http_ntlm.h
@@ -1,5 +1,5 @@
-#ifndef HEADER_CURL_NTLM_H
-#define HEADER_CURL_NTLM_H
+#ifndef HEADER_CURL_HTTP_NTLM_H
+#define HEADER_CURL_HTTP_NTLM_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -33,8 +33,8 @@ CURLcode Curl_input_ntlm(struct connectdata *conn, bool proxy,
/* this is for creating ntlm header output */
CURLcode Curl_output_ntlm(struct connectdata *conn, bool proxy);
-void Curl_http_ntlm_cleanup(struct connectdata *conn);
+void Curl_http_auth_cleanup_ntlm(struct connectdata *conn);
#endif /* !CURL_DISABLE_HTTP && USE_NTLM */
-#endif /* HEADER_CURL_NTLM_H */
+#endif /* HEADER_CURL_HTTP_NTLM_H */
diff --git a/Utilities/cmcurl/lib/http_proxy.c b/Utilities/cmcurl/lib/http_proxy.c
index 9894e2e5f..d7ed11761 100644
--- a/Utilities/cmcurl/lib/http_proxy.c
+++ b/Utilities/cmcurl/lib/http_proxy.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,11 +22,11 @@
#include "curl_setup.h"
+#include "http_proxy.h"
+
#if !defined(CURL_DISABLE_PROXY) && !defined(CURL_DISABLE_HTTP)
-#include "urldata.h"
#include <curl/curl.h>
-#include "http_proxy.h"
#include "sendf.h"
#include "http.h"
#include "url.h"
@@ -135,40 +135,77 @@ CURLcode Curl_proxy_connect(struct connectdata *conn, int sockindex)
return CURLE_OK;
}
-#define CONNECT_BUFFER_SIZE 16384
+bool Curl_connect_complete(struct connectdata *conn)
+{
+ return !conn->connect_state ||
+ (conn->connect_state->tunnel_state == TUNNEL_COMPLETE);
+}
+
+bool Curl_connect_ongoing(struct connectdata *conn)
+{
+ return conn->connect_state &&
+ (conn->connect_state->tunnel_state != TUNNEL_COMPLETE);
+}
+
+static CURLcode connect_init(struct connectdata *conn, bool reinit)
+{
+ struct http_connect_state *s;
+ if(!reinit) {
+ DEBUGASSERT(!conn->connect_state);
+ s = calloc(1, sizeof(struct http_connect_state));
+ if(!s)
+ return CURLE_OUT_OF_MEMORY;
+ infof(conn->data, "allocate connect buffer!\n");
+ conn->connect_state = s;
+ }
+ else {
+ DEBUGASSERT(conn->connect_state);
+ s = conn->connect_state;
+ }
+ s->tunnel_state = TUNNEL_INIT;
+ s->keepon = TRUE;
+ s->line_start = s->connect_buffer;
+ s->ptr = s->line_start;
+ s->cl = 0;
+ s->close_connection = FALSE;
+ return CURLE_OK;
+}
+
+static void connect_done(struct connectdata *conn)
+{
+ struct http_connect_state *s = conn->connect_state;
+ s->tunnel_state = TUNNEL_COMPLETE;
+ infof(conn->data, "CONNECT phase completed!\n");
+}
static CURLcode CONNECT(struct connectdata *conn,
int sockindex,
const char *hostname,
int remote_port)
{
- int subversion=0;
- struct Curl_easy *data=conn->data;
+ int subversion = 0;
+ struct Curl_easy *data = conn->data;
struct SingleRequest *k = &data->req;
CURLcode result;
curl_socket_t tunnelsocket = conn->sock[sockindex];
- curl_off_t cl=0;
- bool closeConnection = FALSE;
- bool chunked_encoding = FALSE;
- time_t check;
+ struct http_connect_state *s = conn->connect_state;
#define SELECT_OK 0
#define SELECT_ERROR 1
-#define SELECT_TIMEOUT 2
- int error = SELECT_OK;
- if(conn->tunnel_state[sockindex] == TUNNEL_COMPLETE)
+ if(Curl_connect_complete(conn))
return CURLE_OK; /* CONNECT is already completed */
conn->bits.proxy_connect_closed = FALSE;
do {
- if(TUNNEL_INIT == conn->tunnel_state[sockindex]) {
+ timediff_t check;
+ if(TUNNEL_INIT == s->tunnel_state) {
/* BEGIN CONNECT PHASE */
char *host_port;
Curl_send_buffer *req_buffer;
- infof(data, "Establish HTTP proxy tunnel to %s:%hu\n",
+ infof(data, "Establish HTTP proxy tunnel to %s:%d\n",
hostname, remote_port);
/* This only happens if we've looped here due to authentication
@@ -183,9 +220,9 @@ static CURLcode CONNECT(struct connectdata *conn,
if(!req_buffer)
return CURLE_OUT_OF_MEMORY;
- host_port = aprintf("%s:%hu", hostname, remote_port);
+ host_port = aprintf("%s:%d", hostname, remote_port);
if(!host_port) {
- Curl_add_buffer_free(req_buffer);
+ Curl_add_buffer_free(&req_buffer);
return CURLE_OUT_OF_MEMORY;
}
@@ -196,8 +233,8 @@ static CURLcode CONNECT(struct connectdata *conn,
if(!result) {
char *host = NULL;
- const char *proxyconn="";
- const char *useragent="";
+ const char *proxyconn = "";
+ const char *useragent = "";
const char *http = (conn->http_proxy.proxytype == CURLPROXY_HTTP_1_0) ?
"1.0" : "1.1";
bool ipv6_ip = conn->bits.ipv6_ip;
@@ -206,31 +243,31 @@ static CURLcode CONNECT(struct connectdata *conn,
/* the hostname may be different */
if(hostname != conn->host.name)
ipv6_ip = (strchr(hostname, ':') != NULL);
- hostheader= /* host:port with IPv6 support */
- aprintf("%s%s%s:%hu", ipv6_ip?"[":"", hostname, ipv6_ip?"]":"",
+ hostheader = /* host:port with IPv6 support */
+ aprintf("%s%s%s:%d", ipv6_ip?"[":"", hostname, ipv6_ip?"]":"",
remote_port);
if(!hostheader) {
- Curl_add_buffer_free(req_buffer);
+ Curl_add_buffer_free(&req_buffer);
return CURLE_OUT_OF_MEMORY;
}
- if(!Curl_checkProxyheaders(conn, "Host:")) {
+ if(!Curl_checkProxyheaders(conn, "Host")) {
host = aprintf("Host: %s\r\n", hostheader);
if(!host) {
free(hostheader);
- Curl_add_buffer_free(req_buffer);
+ Curl_add_buffer_free(&req_buffer);
return CURLE_OUT_OF_MEMORY;
}
}
- if(!Curl_checkProxyheaders(conn, "Proxy-Connection:"))
+ if(!Curl_checkProxyheaders(conn, "Proxy-Connection"))
proxyconn = "Proxy-Connection: Keep-Alive\r\n";
- if(!Curl_checkProxyheaders(conn, "User-Agent:") &&
+ if(!Curl_checkProxyheaders(conn, "User-Agent") &&
data->set.str[STRING_USERAGENT])
useragent = conn->allocptr.uagent;
result =
- Curl_add_bufferf(req_buffer,
+ Curl_add_bufferf(&req_buffer,
"CONNECT %s HTTP/%s\r\n"
"%s" /* Host: */
"%s" /* Proxy-Authorization */
@@ -253,13 +290,13 @@ static CURLcode CONNECT(struct connectdata *conn,
if(!result)
/* CRLF terminate the request */
- result = Curl_add_bufferf(req_buffer, "\r\n");
+ result = Curl_add_bufferf(&req_buffer, "\r\n");
if(!result) {
/* Send the connect request to the proxy */
/* BLOCKING */
result =
- Curl_add_buffer_send(req_buffer, conn,
+ Curl_add_buffer_send(&req_buffer, conn,
&data->info.request_size, 0, sockindex);
}
req_buffer = NULL;
@@ -267,69 +304,50 @@ static CURLcode CONNECT(struct connectdata *conn,
failf(data, "Failed sending CONNECT to proxy");
}
- Curl_add_buffer_free(req_buffer);
+ Curl_add_buffer_free(&req_buffer);
if(result)
return result;
- conn->tunnel_state[sockindex] = TUNNEL_CONNECT;
+ s->tunnel_state = TUNNEL_CONNECT;
+ s->perline = 0;
} /* END CONNECT PHASE */
check = Curl_timeleft(data, NULL, TRUE);
if(check <= 0) {
failf(data, "Proxy CONNECT aborted due to timeout");
- return CURLE_RECV_ERROR;
+ return CURLE_OPERATION_TIMEDOUT;
}
if(!Curl_conn_data_pending(conn, sockindex))
/* return so we'll be called again polling-style */
return CURLE_OK;
- DEBUGF(infof(data, "Read response immediately from proxy CONNECT\n"));
/* at this point, the tunnel_connecting phase is over. */
{ /* READING RESPONSE PHASE */
- size_t nread; /* total size read */
- int perline; /* count bytes per line */
- int keepon=TRUE;
- ssize_t gotbytes;
- char *ptr;
- char *line_start;
+ int error = SELECT_OK;
- ptr = conn->connect_buffer;
- line_start = ptr;
+ while(s->keepon && !error) {
+ ssize_t gotbytes;
- nread = 0;
- perline = 0;
-
- while(nread < (size_t)CONNECT_BUFFER_SIZE && keepon && !error) {
- if(Curl_pgrsUpdate(conn))
- return CURLE_ABORTED_BY_CALLBACK;
-
- if(ptr >= &conn->connect_buffer[CONNECT_BUFFER_SIZE]) {
+ /* make sure we have space to read more data */
+ if(s->ptr >= &s->connect_buffer[CONNECT_BUFFER_SIZE]) {
failf(data, "CONNECT response too large!");
return CURLE_RECV_ERROR;
}
- check = Curl_timeleft(data, NULL, TRUE);
- if(check <= 0) {
- failf(data, "Proxy CONNECT aborted due to timeout");
- error = SELECT_TIMEOUT; /* already too little time */
- break;
- }
-
/* Read one byte at a time to avoid a race condition. Wait at most one
second before looping to ensure continuous pgrsUpdates. */
- result = Curl_read(conn, tunnelsocket, ptr, 1, &gotbytes);
- if(result == CURLE_AGAIN) {
- if(SOCKET_READABLE(tunnelsocket, check<1000L?check:1000) == -1) {
- error = SELECT_ERROR;
- failf(data, "Proxy CONNECT aborted due to select/poll error");
- break;
- }
- continue;
- }
+ result = Curl_read(conn, tunnelsocket, s->ptr, 1, &gotbytes);
+ if(result == CURLE_AGAIN)
+ /* socket buffer drained, return */
+ return CURLE_OK;
+
+ if(Curl_pgrsUpdate(conn))
+ return CURLE_ABORTED_BY_CALLBACK;
+
if(result) {
- keepon = FALSE;
+ s->keepon = FALSE;
break;
}
else if(gotbytes <= 0) {
@@ -343,24 +361,22 @@ static CURLcode CONNECT(struct connectdata *conn,
error = SELECT_ERROR;
failf(data, "Proxy CONNECT aborted");
}
- keepon = FALSE;
+ s->keepon = FALSE;
break;
}
- /* We got a byte of data */
- nread++;
- if(keepon > TRUE) {
+ if(s->keepon > TRUE) {
/* This means we are currently ignoring a response-body */
- nread = 0; /* make next read start over in the read buffer */
- ptr = conn->connect_buffer;
- if(cl) {
+ s->ptr = s->connect_buffer;
+ if(s->cl) {
/* A Content-Length based body: simply count down the counter
and make sure to break out of the loop when we're done! */
- cl--;
- if(cl <= 0) {
- keepon = FALSE;
+ s->cl--;
+ if(s->cl <= 0) {
+ s->keepon = FALSE;
+ s->tunnel_state = TUNNEL_COMPLETE;
break;
}
}
@@ -372,28 +388,29 @@ static CURLcode CONNECT(struct connectdata *conn,
/* now parse the chunked piece of data so that we can
properly tell when the stream ends */
- r = Curl_httpchunk_read(conn, ptr, 1, &tookcareof);
+ r = Curl_httpchunk_read(conn, s->ptr, 1, &tookcareof);
if(r == CHUNKE_STOP) {
/* we're done reading chunks! */
infof(data, "chunk reading DONE\n");
- keepon = FALSE;
+ s->keepon = FALSE;
/* we did the full CONNECT treatment, go COMPLETE */
- conn->tunnel_state[sockindex] = TUNNEL_COMPLETE;
+ s->tunnel_state = TUNNEL_COMPLETE;
}
}
continue;
}
- perline++; /* amount of bytes in this line so far */
+ s->perline++; /* amount of bytes in this line so far */
/* if this is not the end of a header line then continue */
- if(*ptr != 0x0a) {
- ptr++;
+ if(*s->ptr != 0x0a) {
+ s->ptr++;
continue;
}
/* convert from the network encoding */
- result = Curl_convert_from_network(data, line_start, perline);
+ result = Curl_convert_from_network(data, s->line_start,
+ (size_t)s->perline);
/* Curl_convert_from_network calls failf if unsuccessful */
if(result)
return result;
@@ -401,7 +418,7 @@ static CURLcode CONNECT(struct connectdata *conn,
/* output debug if that is requested */
if(data->set.verbose)
Curl_debug(data, CURLINFO_HEADER_IN,
- line_start, (size_t)perline, conn);
+ s->line_start, (size_t)s->perline);
if(!data->set.suppress_connect_headers) {
/* send the header to the callback */
@@ -409,35 +426,34 @@ static CURLcode CONNECT(struct connectdata *conn,
if(data->set.include_header)
writetype |= CLIENTWRITE_BODY;
- result = Curl_client_write(conn, writetype, line_start, perline);
+ result = Curl_client_write(conn, writetype,
+ s->line_start, s->perline);
if(result)
return result;
}
- data->info.header_size += (long)perline;
- data->req.headerbytecount += (long)perline;
+ data->info.header_size += (long)s->perline;
+ data->req.headerbytecount += (long)s->perline;
/* Newlines are CRLF, so the CR is ignored as the line isn't
really terminated until the LF comes. Treat a following CR
as end-of-headers as well.*/
- if(('\r' == line_start[0]) ||
- ('\n' == line_start[0])) {
+ if(('\r' == s->line_start[0]) ||
+ ('\n' == s->line_start[0])) {
/* end of response-headers from the proxy */
- nread = 0; /* make next read start over in the read
- buffer */
- ptr = conn->connect_buffer;
+ s->ptr = s->connect_buffer;
if((407 == k->httpcode) && !data->state.authproblem) {
/* If we get a 407 response code with content length
when we have no auth problem, we must ignore the
whole response-body */
- keepon = 2;
+ s->keepon = 2;
- if(cl) {
+ if(s->cl) {
infof(data, "Ignore %" CURL_FORMAT_CURL_OFF_T
- " bytes of response-body\n", cl);
+ " bytes of response-body\n", s->cl);
}
- else if(chunked_encoding) {
+ else if(s->chunked_encoding) {
CHUNKcode r;
infof(data, "Ignore chunked response-body\n");
@@ -448,46 +464,46 @@ static CURLcode CONNECT(struct connectdata *conn,
function returns! */
k->ignorebody = TRUE;
- if(line_start[1] == '\n') {
+ if(s->line_start[1] == '\n') {
/* this can only be a LF if the letter at index 0
was a CR */
- line_start++;
+ s->line_start++;
}
/* now parse the chunked piece of data so that we can
properly tell when the stream ends */
- r = Curl_httpchunk_read(conn, line_start + 1, 1, &gotbytes);
+ r = Curl_httpchunk_read(conn, s->line_start + 1, 1, &gotbytes);
if(r == CHUNKE_STOP) {
/* we're done reading chunks! */
infof(data, "chunk reading DONE\n");
- keepon = FALSE;
- /* we did the full CONNECT treatment, go to
- COMPLETE */
- conn->tunnel_state[sockindex] = TUNNEL_COMPLETE;
+ s->keepon = FALSE;
+ /* we did the full CONNECT treatment, go to COMPLETE */
+ s->tunnel_state = TUNNEL_COMPLETE;
}
}
else {
/* without content-length or chunked encoding, we
can't keep the connection alive since the close is
the end signal so we bail out at once instead */
- keepon = FALSE;
+ s->keepon = FALSE;
}
}
else
- keepon = FALSE;
- /* we did the full CONNECT treatment, go to COMPLETE */
- conn->tunnel_state[sockindex] = TUNNEL_COMPLETE;
+ s->keepon = FALSE;
+ if(!s->cl)
+ /* we did the full CONNECT treatment, go to COMPLETE */
+ s->tunnel_state = TUNNEL_COMPLETE;
continue;
}
- line_start[perline] = 0; /* zero terminate the buffer */
- if((checkprefix("WWW-Authenticate:", line_start) &&
+ s->line_start[s->perline] = 0; /* zero terminate the buffer */
+ if((checkprefix("WWW-Authenticate:", s->line_start) &&
(401 == k->httpcode)) ||
- (checkprefix("Proxy-authenticate:", line_start) &&
+ (checkprefix("Proxy-authenticate:", s->line_start) &&
(407 == k->httpcode))) {
bool proxy = (k->httpcode == 407) ? TRUE : FALSE;
- char *auth = Curl_copy_header_value(line_start);
+ char *auth = Curl_copy_header_value(s->line_start);
if(!auth)
return CURLE_OUT_OF_MEMORY;
@@ -498,7 +514,7 @@ static CURLcode CONNECT(struct connectdata *conn,
if(result)
return result;
}
- else if(checkprefix("Content-Length:", line_start)) {
+ else if(checkprefix("Content-Length:", s->line_start)) {
if(k->httpcode/100 == 2) {
/* A client MUST ignore any Content-Length or Transfer-Encoding
header fields received in a successful response to CONNECT.
@@ -507,13 +523,13 @@ static CURLcode CONNECT(struct connectdata *conn,
k->httpcode);
}
else {
- cl = curlx_strtoofft(line_start +
- strlen("Content-Length:"), NULL, 10);
+ (void)curlx_strtoofft(s->line_start +
+ strlen("Content-Length:"), NULL, 10, &s->cl);
}
}
- else if(Curl_compareheader(line_start, "Connection:", "close"))
- closeConnection = TRUE;
- else if(checkprefix("Transfer-Encoding:", line_start)) {
+ else if(Curl_compareheader(s->line_start, "Connection:", "close"))
+ s->close_connection = TRUE;
+ else if(checkprefix("Transfer-Encoding:", s->line_start)) {
if(k->httpcode/100 == 2) {
/* A client MUST ignore any Content-Length or Transfer-Encoding
header fields received in a successful response to CONNECT.
@@ -521,26 +537,27 @@ static CURLcode CONNECT(struct connectdata *conn,
infof(data, "Ignoring Transfer-Encoding in "
"CONNECT %03d response\n", k->httpcode);
}
- else if(Curl_compareheader(line_start,
+ else if(Curl_compareheader(s->line_start,
"Transfer-Encoding:", "chunked")) {
infof(data, "CONNECT responded chunked\n");
- chunked_encoding = TRUE;
+ s->chunked_encoding = TRUE;
/* init our chunky engine */
Curl_httpchunk_init(conn);
}
}
- else if(Curl_compareheader(line_start, "Proxy-Connection:", "close"))
- closeConnection = TRUE;
- else if(2 == sscanf(line_start, "HTTP/1.%d %d",
+ else if(Curl_compareheader(s->line_start,
+ "Proxy-Connection:", "close"))
+ s->close_connection = TRUE;
+ else if(2 == sscanf(s->line_start, "HTTP/1.%d %d",
&subversion,
&k->httpcode)) {
/* store the HTTP code from the proxy */
data->info.httpproxycode = k->httpcode;
}
- perline = 0; /* line starts over here */
- ptr = conn->connect_buffer;
- line_start = ptr;
+ s->perline = 0; /* line starts over here */
+ s->ptr = s->connect_buffer;
+ s->line_start = s->ptr;
} /* while there's buffer left and loop is requested */
if(Curl_pgrsUpdate(conn))
@@ -549,7 +566,7 @@ static CURLcode CONNECT(struct connectdata *conn,
if(error)
return CURLE_RECV_ERROR;
- if(data->info.httpproxycode != 200) {
+ if(data->info.httpproxycode/100 != 2) {
/* Deal with the possibly already received authenticate
headers. 'newurl' is set to a new URL if we must loop. */
result = Curl_http_auth_act(conn);
@@ -560,10 +577,10 @@ static CURLcode CONNECT(struct connectdata *conn,
/* the connection has been marked for closure, most likely in the
Curl_http_auth_act() function and thus we can kill it at once
below */
- closeConnection = TRUE;
+ s->close_connection = TRUE;
}
- if(closeConnection && data->req.newurl) {
+ if(s->close_connection && data->req.newurl) {
/* Connection closed by server. Don't use it anymore */
Curl_closesocket(conn, conn->sock[sockindex]);
conn->sock[sockindex] = CURL_SOCKET_BAD;
@@ -574,19 +591,17 @@ static CURLcode CONNECT(struct connectdata *conn,
/* If we are supposed to continue and request a new URL, which basically
* means the HTTP authentication is still going on so if the tunnel
* is complete we start over in INIT state */
- if(data->req.newurl &&
- (TUNNEL_COMPLETE == conn->tunnel_state[sockindex])) {
- conn->tunnel_state[sockindex] = TUNNEL_INIT;
- infof(data, "TUNNEL_STATE switched to: %d\n",
- conn->tunnel_state[sockindex]);
+ if(data->req.newurl && (TUNNEL_COMPLETE == s->tunnel_state)) {
+ connect_init(conn, TRUE); /* reinit */
}
} while(data->req.newurl);
- if(200 != data->req.httpcode) {
- if(closeConnection && data->req.newurl) {
+ if(data->info.httpproxycode/100 != 2) {
+ if(s->close_connection && data->req.newurl) {
conn->bits.proxy_connect_closed = TRUE;
infof(data, "Connect me again please\n");
+ connect_done(conn);
}
else {
free(data->req.newurl);
@@ -598,7 +613,7 @@ static CURLcode CONNECT(struct connectdata *conn,
}
/* to back to init state */
- conn->tunnel_state[sockindex] = TUNNEL_INIT;
+ s->tunnel_state = TUNNEL_INIT;
if(conn->bits.proxy_connect_closed)
/* this is not an error, just part of the connection negotiation */
@@ -608,7 +623,7 @@ static CURLcode CONNECT(struct connectdata *conn,
return CURLE_RECV_ERROR;
}
- conn->tunnel_state[sockindex] = TUNNEL_COMPLETE;
+ s->tunnel_state = TUNNEL_COMPLETE;
/* If a proxy-authorization header was used for the proxy, then we should
make sure that it isn't accidentally used for the document request
@@ -618,13 +633,24 @@ static CURLcode CONNECT(struct connectdata *conn,
data->state.authproxy.done = TRUE;
- infof(data, "Proxy replied OK to CONNECT request\n");
+ infof(data, "Proxy replied %d to CONNECT request\n",
+ data->info.httpproxycode);
data->req.ignorebody = FALSE; /* put it (back) to non-ignore state */
conn->bits.rewindaftersend = FALSE; /* make sure this isn't set for the
document request */
return CURLE_OK;
}
+void Curl_connect_free(struct Curl_easy *data)
+{
+ struct connectdata *conn = data->conn;
+ struct http_connect_state *s = conn->connect_state;
+ if(s) {
+ free(s);
+ conn->connect_state = NULL;
+ }
+}
+
/*
* Curl_proxyCONNECT() requires that we're connected to a HTTP proxy. This
* function will issue the necessary commands to get a seamless tunnel through
@@ -637,20 +663,23 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
int remote_port)
{
CURLcode result;
- if(TUNNEL_INIT == conn->tunnel_state[sockindex]) {
- if(!conn->connect_buffer) {
- conn->connect_buffer = malloc(CONNECT_BUFFER_SIZE);
- if(!conn->connect_buffer)
- return CURLE_OUT_OF_MEMORY;
- }
+ if(!conn->connect_state) {
+ result = connect_init(conn, FALSE);
+ if(result)
+ return result;
}
result = CONNECT(conn, sockindex, hostname, remote_port);
- if(result || (TUNNEL_COMPLETE == conn->tunnel_state[sockindex]))
- Curl_safefree(conn->connect_buffer);
+ if(result || Curl_connect_complete(conn))
+ connect_done(conn);
return result;
}
+#else
+void Curl_connect_free(struct Curl_easy *data)
+{
+ (void)data;
+}
#endif /* CURL_DISABLE_PROXY */
diff --git a/Utilities/cmcurl/lib/http_proxy.h b/Utilities/cmcurl/lib/http_proxy.h
index cbb1ab421..e19fa859a 100644
--- a/Utilities/cmcurl/lib/http_proxy.h
+++ b/Utilities/cmcurl/lib/http_proxy.h
@@ -22,6 +22,9 @@
*
***************************************************************************/
+#include "curl_setup.h"
+#include "urldata.h"
+
#if !defined(CURL_DISABLE_PROXY) && !defined(CURL_DISABLE_HTTP)
/* ftp can use this as well */
CURLcode Curl_proxyCONNECT(struct connectdata *conn,
@@ -33,9 +36,16 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
CURLcode Curl_proxy_connect(struct connectdata *conn, int sockindex);
+bool Curl_connect_complete(struct connectdata *conn);
+bool Curl_connect_ongoing(struct connectdata *conn);
+
#else
#define Curl_proxyCONNECT(x,y,z,w) CURLE_NOT_BUILT_IN
#define Curl_proxy_connect(x,y) CURLE_OK
+#define Curl_connect_complete(x) CURLE_OK
+#define Curl_connect_ongoing(x) FALSE
#endif
+void Curl_connect_free(struct Curl_easy *data);
+
#endif /* HEADER_CURL_HTTP_PROXY_H */
diff --git a/Utilities/cmcurl/lib/if2ip.c b/Utilities/cmcurl/lib/if2ip.c
index 4de81be60..d003de678 100644
--- a/Utilities/cmcurl/lib/if2ip.c
+++ b/Utilities/cmcurl/lib/if2ip.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -71,6 +71,8 @@ unsigned int Curl_ipv6_scope(const struct sockaddr *sa)
const unsigned char *b = sa6->sin6_addr.s6_addr;
unsigned short w = (unsigned short) ((b[0] << 8) | b[1]);
+ if((b[0] & 0xFE) == 0xFC) /* Handle ULAs */
+ return IPV6_SCOPE_UNIQUELOCAL;
switch(w & 0xFFC0) {
case 0xFE80:
return IPV6_SCOPE_LINKLOCAL;
@@ -94,26 +96,8 @@ unsigned int Curl_ipv6_scope(const struct sockaddr *sa)
#if defined(HAVE_GETIFADDRS)
-bool Curl_if_is_interface_name(const char *interf)
-{
- bool result = FALSE;
-
- struct ifaddrs *iface, *head;
-
- if(getifaddrs(&head) >= 0) {
- for(iface=head; iface != NULL; iface=iface->ifa_next) {
- if(strcasecompare(iface->ifa_name, interf)) {
- result = TRUE;
- break;
- }
- }
- freeifaddrs(head);
- }
- return result;
-}
-
if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
- unsigned int remote_scope_id, const char *interf,
+ unsigned int local_scope_id, const char *interf,
char *buf, int buf_size)
{
struct ifaddrs *iface, *head;
@@ -121,15 +105,15 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
#ifndef ENABLE_IPV6
(void) remote_scope;
-
-#ifndef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
- (void) remote_scope_id;
#endif
+#if !defined(HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID) || \
+ !defined(ENABLE_IPV6)
+ (void) local_scope_id;
#endif
if(getifaddrs(&head) >= 0) {
- for(iface = head; iface != NULL; iface=iface->ifa_next) {
+ for(iface = head; iface != NULL; iface = iface->ifa_next) {
if(iface->ifa_addr != NULL) {
if(iface->ifa_addr->sa_family == af) {
if(strcasecompare(iface->ifa_name, interf)) {
@@ -139,7 +123,9 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
char ipstr[64];
#ifdef ENABLE_IPV6
if(af == AF_INET6) {
+#ifdef HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID
unsigned int scopeid = 0;
+#endif
unsigned int ifscope = Curl_ipv6_scope(iface->ifa_addr);
if(ifscope != remote_scope) {
@@ -159,15 +145,16 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
->sin6_scope_id;
/* If given, scope id should match. */
- if(remote_scope_id && scopeid != remote_scope_id) {
+ if(local_scope_id && scopeid != local_scope_id) {
if(res == IF2IP_NOT_FOUND)
res = IF2IP_AF_NOT_SUPPORTED;
continue;
}
-#endif
+
if(scopeid)
- snprintf(scope, sizeof(scope), "%%%u", scopeid);
+ msnprintf(scope, sizeof(scope), "%%%u", scopeid);
+#endif
}
else
#endif
@@ -175,7 +162,7 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
&((struct sockaddr_in *)(void *)iface->ifa_addr)->sin_addr;
res = IF2IP_FOUND;
ip = (char *) Curl_inet_ntop(af, addr, ipstr, sizeof(ipstr));
- snprintf(buf, buf_size, "%s%s", ip, scope);
+ msnprintf(buf, buf_size, "%s%s", ip, scope);
break;
}
}
@@ -194,17 +181,8 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
#elif defined(HAVE_IOCTL_SIOCGIFADDR)
-bool Curl_if_is_interface_name(const char *interf)
-{
- /* This is here just to support the old interfaces */
- char buf[256];
-
- return (Curl_if2ip(AF_INET, 0 /* unused */, 0, interf, buf, sizeof(buf)) ==
- IF2IP_NOT_FOUND) ? FALSE : TRUE;
-}
-
if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
- unsigned int remote_scope_id, const char *interf,
+ unsigned int local_scope_id, const char *interf,
char *buf, int buf_size)
{
struct ifreq req;
@@ -214,7 +192,7 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
size_t len;
(void)remote_scope;
- (void)remote_scope_id;
+ (void)local_scope_id;
if(!interf || (af != AF_INET))
return IF2IP_NOT_FOUND;
@@ -228,7 +206,7 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
return IF2IP_NOT_FOUND;
memset(&req, 0, sizeof(req));
- memcpy(req.ifr_name, interf, len+1);
+ memcpy(req.ifr_name, interf, len + 1);
req.ifr_addr.sa_family = AF_INET;
if(ioctl(dummy, SIOCGIFADDR, &req) < 0) {
@@ -249,20 +227,13 @@ if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
#else
-bool Curl_if_is_interface_name(const char *interf)
-{
- (void) interf;
-
- return FALSE;
-}
-
if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
- unsigned int remote_scope_id, const char *interf,
+ unsigned int local_scope_id, const char *interf,
char *buf, int buf_size)
{
(void) af;
(void) remote_scope;
- (void) remote_scope_id;
+ (void) local_scope_id;
(void) interf;
(void) buf;
(void) buf_size;
diff --git a/Utilities/cmcurl/lib/if2ip.h b/Utilities/cmcurl/lib/if2ip.h
index f3a7ff0b2..f193d4257 100644
--- a/Utilities/cmcurl/lib/if2ip.h
+++ b/Utilities/cmcurl/lib/if2ip.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -27,12 +27,11 @@
#define IPV6_SCOPE_GLOBAL 0 /* Global scope. */
#define IPV6_SCOPE_LINKLOCAL 1 /* Link-local scope. */
#define IPV6_SCOPE_SITELOCAL 2 /* Site-local scope (deprecated). */
-#define IPV6_SCOPE_NODELOCAL 3 /* Loopback. */
+#define IPV6_SCOPE_UNIQUELOCAL 3 /* Unique local */
+#define IPV6_SCOPE_NODELOCAL 4 /* Loopback. */
unsigned int Curl_ipv6_scope(const struct sockaddr *sa);
-bool Curl_if_is_interface_name(const char *interf);
-
typedef enum {
IF2IP_NOT_FOUND = 0, /* Interface not found */
IF2IP_AF_NOT_SUPPORTED = 1, /* Int. exists but has no address for this af */
@@ -40,7 +39,7 @@ typedef enum {
} if2ip_result_t;
if2ip_result_t Curl_if2ip(int af, unsigned int remote_scope,
- unsigned int remote_scope_id, const char *interf,
+ unsigned int local_scope_id, const char *interf,
char *buf, int buf_size);
#ifdef __INTERIX
diff --git a/Utilities/cmcurl/lib/imap.c b/Utilities/cmcurl/lib/imap.c
index b528f77d9..bdcc69c67 100644
--- a/Utilities/cmcurl/lib/imap.c
+++ b/Utilities/cmcurl/lib/imap.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -28,6 +28,7 @@
* RFC4959 IMAP Extension for SASL Initial Client Response
* RFC5092 IMAP URL Scheme
* RFC6749 OAuth 2.0 Authorization Framework
+ * RFC8314 Use of TLS for Email Submission and Access
* Draft LOGIN SASL Mechanism <draft-murchison-sasl-login-00.txt>
*
***************************************************************************/
@@ -68,6 +69,7 @@
#include "http.h" /* for HTTP proxy tunnel stuff */
#include "socks.h"
#include "imap.h"
+#include "mime.h"
#include "strtoofft.h"
#include "strcase.h"
#include "vtls/vtls.h"
@@ -128,6 +130,7 @@ const struct Curl_handler Curl_handler_imap = {
ZERO_NULL, /* perform_getsock */
imap_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_IMAP, /* defport */
CURLPROTO_IMAP, /* protocol */
PROTOPT_CLOSEACTION| /* flags */
@@ -154,69 +157,23 @@ const struct Curl_handler Curl_handler_imaps = {
ZERO_NULL, /* perform_getsock */
imap_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_IMAPS, /* defport */
CURLPROTO_IMAPS, /* protocol */
- PROTOPT_CLOSEACTION | PROTOPT_SSL /* flags */
+ PROTOPT_CLOSEACTION | PROTOPT_SSL | /* flags */
+ PROTOPT_URLOPTIONS
};
#endif
-#ifndef CURL_DISABLE_HTTP
-/*
- * HTTP-proxyed IMAP protocol handler.
- */
-
-static const struct Curl_handler Curl_handler_imap_proxy = {
- "IMAP", /* scheme */
- Curl_http_setup_conn, /* setup_connection */
- Curl_http, /* do_it */
- Curl_http_done, /* done */
- ZERO_NULL, /* do_more */
- ZERO_NULL, /* connect_it */
- ZERO_NULL, /* connecting */
- ZERO_NULL, /* doing */
- ZERO_NULL, /* proto_getsock */
- ZERO_NULL, /* doing_getsock */
- ZERO_NULL, /* domore_getsock */
- ZERO_NULL, /* perform_getsock */
- ZERO_NULL, /* disconnect */
- ZERO_NULL, /* readwrite */
- PORT_IMAP, /* defport */
- CURLPROTO_HTTP, /* protocol */
- PROTOPT_NONE /* flags */
-};
-
-#ifdef USE_SSL
-/*
- * HTTP-proxyed IMAPS protocol handler.
- */
-
-static const struct Curl_handler Curl_handler_imaps_proxy = {
- "IMAPS", /* scheme */
- Curl_http_setup_conn, /* setup_connection */
- Curl_http, /* do_it */
- Curl_http_done, /* done */
- ZERO_NULL, /* do_more */
- ZERO_NULL, /* connect_it */
- ZERO_NULL, /* connecting */
- ZERO_NULL, /* doing */
- ZERO_NULL, /* proto_getsock */
- ZERO_NULL, /* doing_getsock */
- ZERO_NULL, /* domore_getsock */
- ZERO_NULL, /* perform_getsock */
- ZERO_NULL, /* disconnect */
- ZERO_NULL, /* readwrite */
- PORT_IMAPS, /* defport */
- CURLPROTO_HTTP, /* protocol */
- PROTOPT_NONE /* flags */
-};
-#endif
-#endif
+#define IMAP_RESP_OK 1
+#define IMAP_RESP_NOT_OK 2
+#define IMAP_RESP_PREAUTH 3
/* SASL parameters for the imap protocol */
static const struct SASLproto saslimap = {
"imap", /* The service name */
'+', /* Code received when continuation is expected */
- 'O', /* Code to receive upon authentication success */
+ IMAP_RESP_OK, /* Code to receive upon authentication success */
0, /* Maximum initial response length (no max) */
imap_perform_authenticate, /* Send authentication command */
imap_continue_authenticate, /* Send authentication continuation */
@@ -299,15 +256,11 @@ static bool imap_endofresp(struct connectdata *conn, char *line, size_t len,
len -= id_len + 1;
if(len >= 2 && !memcmp(line, "OK", 2))
- *resp = 'O';
- else if(len >= 2 && !memcmp(line, "NO", 2))
- *resp = 'N';
- else if(len >= 3 && !memcmp(line, "BAD", 3))
- *resp = 'B';
- else {
- failf(conn->data, "Bad tagged response");
- *resp = -1;
- }
+ *resp = IMAP_RESP_OK;
+ else if(len >= 7 && !memcmp(line, "PREAUTH", 7))
+ *resp = IMAP_RESP_PREAUTH;
+ else
+ *resp = IMAP_RESP_NOT_OK;
return TRUE;
}
@@ -324,15 +277,15 @@ static bool imap_endofresp(struct connectdata *conn, char *line, size_t len,
case IMAP_LIST:
if((!imap->custom && !imap_matchresp(line, len, "LIST")) ||
(imap->custom && !imap_matchresp(line, len, imap->custom) &&
- (strcmp(imap->custom, "STORE") ||
+ (!strcasecompare(imap->custom, "STORE") ||
!imap_matchresp(line, len, "FETCH")) &&
- strcmp(imap->custom, "SELECT") &&
- strcmp(imap->custom, "EXAMINE") &&
- strcmp(imap->custom, "SEARCH") &&
- strcmp(imap->custom, "EXPUNGE") &&
- strcmp(imap->custom, "LSUB") &&
- strcmp(imap->custom, "UID") &&
- strcmp(imap->custom, "NOOP")))
+ !strcasecompare(imap->custom, "SELECT") &&
+ !strcasecompare(imap->custom, "EXAMINE") &&
+ !strcasecompare(imap->custom, "SEARCH") &&
+ !strcasecompare(imap->custom, "EXPUNGE") &&
+ !strcasecompare(imap->custom, "LSUB") &&
+ !strcasecompare(imap->custom, "UID") &&
+ !strcasecompare(imap->custom, "NOOP")))
return FALSE;
break;
@@ -364,7 +317,7 @@ static bool imap_endofresp(struct connectdata *conn, char *line, size_t len,
a space and optionally some text as per RFC-3501 for the AUTHENTICATE and
APPEND commands and as outlined in Section 4. Examples of RFC-4959 but
some e-mail servers ignore this and only send a single + instead. */
- if(imap && !imap->custom && ((len == 3 && !memcmp("+", line, 1)) ||
+ if(imap && !imap->custom && ((len == 3 && line[0] == '+') ||
(len >= 2 && !memcmp("+ ", line, 2)))) {
switch(imapc->state) {
/* States which are interested in continuation responses */
@@ -393,23 +346,30 @@ static bool imap_endofresp(struct connectdata *conn, char *line, size_t len,
*/
static void imap_get_message(char *buffer, char **outptr)
{
- size_t len = 0;
+ size_t len = strlen(buffer);
char *message = NULL;
- /* Find the start of the message */
- for(message = buffer + 2; *message == ' ' || *message == '\t'; message++)
- ;
-
- /* Find the end of the message */
- for(len = strlen(message); len--;)
- if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' &&
- message[len] != '\t')
- break;
+ if(len > 2) {
+ /* Find the start of the message */
+ len -= 2;
+ for(message = buffer + 2; *message == ' ' || *message == '\t';
+ message++, len--)
+ ;
+
+ /* Find the end of the message */
+ for(; len--;)
+ if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' &&
+ message[len] != '\t')
+ break;
- /* Terminate the message */
- if(++len) {
- message[len] = '\0';
+ /* Terminate the message */
+ if(++len) {
+ message[len] = '\0';
+ }
}
+ else
+ /* junk input => zero length output */
+ message = &buffer[len];
*outptr = message;
}
@@ -463,7 +423,6 @@ static CURLcode imap_perform_capability(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct imap_conn *imapc = &conn->proto.imapc;
-
imapc->sasl.authmechs = SASL_AUTH_NONE; /* No known auth. mechanisms yet */
imapc->sasl.authused = SASL_AUTH_NONE; /* Clear the auth. mechanism used */
imapc->tls_supported = FALSE; /* Clear the TLS capability */
@@ -613,9 +572,10 @@ static CURLcode imap_perform_authentication(struct connectdata *conn)
struct imap_conn *imapc = &conn->proto.imapc;
saslprogress progress;
- /* Check we have enough data to authenticate with and end the
- connect phase if we don't */
- if(!Curl_sasl_can_authenticate(&imapc->sasl, conn)) {
+ /* Check if already authenticated OR if there is enough data to authenticate
+ with and end the connect phase if we don't */
+ if(imapc->preauth ||
+ !Curl_sasl_can_authenticate(&imapc->sasl, conn)) {
state(conn, IMAP_STOP);
return result;
}
@@ -650,7 +610,6 @@ static CURLcode imap_perform_list(struct connectdata *conn)
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
struct IMAP *imap = data->req.protop;
- char *mailbox;
if(imap->custom)
/* Send the custom request */
@@ -658,7 +617,8 @@ static CURLcode imap_perform_list(struct connectdata *conn)
imap->custom_params ? imap->custom_params : "");
else {
/* Make sure the mailbox is in the correct atom format if necessary */
- mailbox = imap->mailbox ? imap_atom(imap->mailbox, true) : strdup("");
+ char *mailbox = imap->mailbox ? imap_atom(imap->mailbox, true)
+ : strdup("");
if(!mailbox)
return CURLE_OUT_OF_MEMORY;
@@ -724,24 +684,37 @@ static CURLcode imap_perform_fetch(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
struct IMAP *imap = conn->data->req.protop;
-
/* Check we have a UID */
- if(!imap->uid) {
- failf(conn->data, "Cannot FETCH without a UID.");
- return CURLE_URL_MALFORMAT;
+ if(imap->uid) {
+
+ /* Send the FETCH command */
+ if(imap->partial)
+ result = imap_sendf(conn, "UID FETCH %s BODY[%s]<%s>",
+ imap->uid,
+ imap->section ? imap->section : "",
+ imap->partial);
+ else
+ result = imap_sendf(conn, "UID FETCH %s BODY[%s]",
+ imap->uid,
+ imap->section ? imap->section : "");
+ }
+ else if(imap->mindex) {
+
+ /* Send the FETCH command */
+ if(imap->partial)
+ result = imap_sendf(conn, "FETCH %s BODY[%s]<%s>",
+ imap->mindex,
+ imap->section ? imap->section : "",
+ imap->partial);
+ else
+ result = imap_sendf(conn, "FETCH %s BODY[%s]",
+ imap->mindex,
+ imap->section ? imap->section : "");
+ }
+ else {
+ failf(conn->data, "Cannot FETCH without a UID.");
+ return CURLE_URL_MALFORMAT;
}
-
- /* Send the FETCH command */
- if(imap->partial)
- result = imap_sendf(conn, "FETCH %s BODY[%s]<%s>",
- imap->uid,
- imap->section ? imap->section : "",
- imap->partial);
- else
- result = imap_sendf(conn, "FETCH %s BODY[%s]",
- imap->uid,
- imap->section ? imap->section : "");
-
if(!result)
state(conn, IMAP_FETCH);
@@ -757,18 +730,48 @@ static CURLcode imap_perform_fetch(struct connectdata *conn)
static CURLcode imap_perform_append(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
- struct IMAP *imap = conn->data->req.protop;
+ struct Curl_easy *data = conn->data;
+ struct IMAP *imap = data->req.protop;
char *mailbox;
/* Check we have a mailbox */
if(!imap->mailbox) {
- failf(conn->data, "Cannot APPEND without a mailbox.");
+ failf(data, "Cannot APPEND without a mailbox.");
return CURLE_URL_MALFORMAT;
}
+ /* Prepare the mime data if some. */
+ if(data->set.mimepost.kind != MIMEKIND_NONE) {
+ /* Use the whole structure as data. */
+ data->set.mimepost.flags &= ~MIME_BODY_ONLY;
+
+ /* Add external headers and mime version. */
+ curl_mime_headers(&data->set.mimepost, data->set.headers, 0);
+ result = Curl_mime_prepare_headers(&data->set.mimepost, NULL,
+ NULL, MIMESTRATEGY_MAIL);
+
+ if(!result)
+ if(!Curl_checkheaders(conn, "Mime-Version"))
+ result = Curl_mime_add_header(&data->set.mimepost.curlheaders,
+ "Mime-Version: 1.0");
+
+ /* Make sure we will read the entire mime structure. */
+ if(!result)
+ result = Curl_mime_rewind(&data->set.mimepost);
+
+ if(result)
+ return result;
+
+ data->state.infilesize = Curl_mime_size(&data->set.mimepost);
+
+ /* Read from mime structure. */
+ data->state.fread_func = (curl_read_callback) Curl_mime_read;
+ data->state.in = (void *) &data->set.mimepost;
+ }
+
/* Check we know the size of the upload */
- if(conn->data->state.infilesize < 0) {
- failf(conn->data, "Cannot APPEND with unknown input file size\n");
+ if(data->state.infilesize < 0) {
+ failf(data, "Cannot APPEND with unknown input file size\n");
return CURLE_UPLOAD_FAILED;
}
@@ -779,7 +782,7 @@ static CURLcode imap_perform_append(struct connectdata *conn)
/* Send the APPEND command */
result = imap_sendf(conn, "APPEND %s (\\Seen) {%" CURL_FORMAT_CURL_OFF_T "}",
- mailbox, conn->data->state.infilesize);
+ mailbox, data->state.infilesize);
free(mailbox);
@@ -839,19 +842,21 @@ static CURLcode imap_state_servergreet_resp(struct connectdata *conn,
int imapcode,
imapstate instate)
{
- CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
-
(void)instate; /* no use for this yet */
- if(imapcode != 'O') {
+ if(imapcode == IMAP_RESP_PREAUTH) {
+ /* PREAUTH */
+ struct imap_conn *imapc = &conn->proto.imapc;
+ imapc->preauth = TRUE;
+ infof(data, "PREAUTH connection, already authenticated!\n");
+ }
+ else if(imapcode != IMAP_RESP_OK) {
failf(data, "Got unexpected imap-server response");
- result = CURLE_WEIRD_SERVER_REPLY;
+ return CURLE_WEIRD_SERVER_REPLY;
}
- else
- result = imap_perform_capability(conn);
- return result;
+ return imap_perform_capability(conn);
}
/* For CAPABILITY responses */
@@ -863,7 +868,6 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn,
struct Curl_easy *data = conn->data;
struct imap_conn *imapc = &conn->proto.imapc;
const char *line = data->state.buffer;
- size_t wordlen;
(void)instate; /* no use for this yet */
@@ -873,6 +877,7 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn,
/* Loop through the data line */
for(;;) {
+ size_t wordlen;
while(*line &&
(*line == ' ' || *line == '\t' ||
*line == '\r' || *line == '\n')) {
@@ -918,7 +923,7 @@ static CURLcode imap_state_capability_resp(struct connectdata *conn,
line += wordlen;
}
}
- else if(imapcode == 'O') {
+ else if(imapcode == IMAP_RESP_OK) {
if(data->set.use_ssl && !conn->ssl[FIRSTSOCKET].use) {
/* We don't have a SSL/TLS connection yet, but SSL is requested */
if(imapc->tls_supported)
@@ -951,7 +956,7 @@ static CURLcode imap_state_starttls_resp(struct connectdata *conn,
(void)instate; /* no use for this yet */
- if(imapcode != 'O') {
+ if(imapcode != IMAP_RESP_OK) {
if(data->set.use_ssl != CURLUSESSL_TRY) {
failf(data, "STARTTLS denied");
result = CURLE_USE_SSL_FAILED;
@@ -1009,7 +1014,7 @@ static CURLcode imap_state_login_resp(struct connectdata *conn,
(void)instate; /* no use for this yet */
- if(imapcode != 'O') {
+ if(imapcode != IMAP_RESP_OK) {
failf(data, "Access denied. %c", imapcode);
result = CURLE_LOGIN_DENIED;
}
@@ -1037,8 +1042,8 @@ static CURLcode imap_state_listsearch_resp(struct connectdata *conn,
result = Curl_client_write(conn, CLIENTWRITE_BODY, line, len + 1);
line[len] = '\0';
}
- else if(imapcode != 'O')
- result = CURLE_QUOTE_ERROR; /* TODO: Fix error code */
+ else if(imapcode != IMAP_RESP_OK)
+ result = CURLE_QUOTE_ERROR;
else
/* End of DO phase */
state(conn, IMAP_STOP);
@@ -1055,21 +1060,21 @@ static CURLcode imap_state_select_resp(struct connectdata *conn, int imapcode,
struct IMAP *imap = conn->data->req.protop;
struct imap_conn *imapc = &conn->proto.imapc;
const char *line = data->state.buffer;
- char tmp[20];
(void)instate; /* no use for this yet */
if(imapcode == '*') {
/* See if this is an UIDVALIDITY response */
+ char tmp[20];
if(sscanf(line + 2, "OK [UIDVALIDITY %19[0123456789]]", tmp) == 1) {
Curl_safefree(imapc->mailbox_uidvalidity);
imapc->mailbox_uidvalidity = strdup(tmp);
}
}
- else if(imapcode == 'O') {
+ else if(imapcode == IMAP_RESP_OK) {
/* Check if the UIDVALIDITY has been specified and matches */
if(imap->uidvalidity && imapc->mailbox_uidvalidity &&
- strcmp(imap->uidvalidity, imapc->mailbox_uidvalidity)) {
+ !strcasecompare(imap->uidvalidity, imapc->mailbox_uidvalidity)) {
failf(conn->data, "Mailbox UIDVALIDITY has changed");
result = CURLE_REMOTE_FILE_NOT_FOUND;
}
@@ -1110,7 +1115,7 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
if(imapcode != '*') {
Curl_pgrsSetDownloadSize(data, -1);
state(conn, IMAP_STOP);
- return CURLE_REMOTE_FILE_NOT_FOUND; /* TODO: Fix error code */
+ return CURLE_REMOTE_FILE_NOT_FOUND;
}
/* Something like this is received "* 1 FETCH (BODY[TEXT] {2021}\r" so parse
@@ -1120,14 +1125,15 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
if(*ptr == '{') {
char *endptr;
- size = curlx_strtoofft(ptr + 1, &endptr, 10);
- if(endptr - ptr > 1 && endptr[0] == '}' &&
- endptr[1] == '\r' && endptr[2] == '\0')
- parsed = TRUE;
+ if(!curlx_strtoofft(ptr + 1, &endptr, 10, &size)) {
+ if(endptr - ptr > 1 && endptr[0] == '}' &&
+ endptr[1] == '\r' && endptr[2] == '\0')
+ parsed = TRUE;
+ }
}
if(parsed) {
- infof(data, "Found %" CURL_FORMAT_CURL_OFF_TU " bytes to download\n",
+ infof(data, "Found %" CURL_FORMAT_CURL_OFF_T " bytes to download\n",
size);
Curl_pgrsSetDownloadSize(data, size);
@@ -1141,16 +1147,19 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
/* The conversion from curl_off_t to size_t is always fine here */
chunk = (size_t)size;
+ if(!chunk) {
+ /* no size, we're done with the data */
+ state(conn, IMAP_STOP);
+ return CURLE_OK;
+ }
result = Curl_client_write(conn, CLIENTWRITE_BODY, pp->cache, chunk);
if(result)
return result;
data->req.bytecount += chunk;
- infof(data, "Written %" CURL_FORMAT_CURL_OFF_TU
- " bytes, %" CURL_FORMAT_CURL_OFF_TU
- " bytes are left for transfer\n", (curl_off_t)chunk,
- size - chunk);
+ infof(data, "Written %zu bytes, %" CURL_FORMAT_CURL_OFF_TU
+ " bytes are left for transfer\n", chunk, size - chunk);
/* Have we used the entire cache or just part of it?*/
if(pp->cache_size > chunk) {
@@ -1169,11 +1178,11 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
if(data->req.bytecount == size)
/* The entire data is already transferred! */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
else {
/* IMAP download */
data->req.maxdownload = size;
- Curl_setup_transfer(conn, FIRSTSOCKET, size, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, FIRSTSOCKET, size, FALSE, -1);
}
}
else {
@@ -1197,7 +1206,7 @@ static CURLcode imap_state_fetch_final_resp(struct connectdata *conn,
(void)instate; /* No use for this yet */
- if(imapcode != 'O')
+ if(imapcode != IMAP_RESP_OK)
result = CURLE_WEIRD_SERVER_REPLY;
else
/* End of DONE phase */
@@ -1223,7 +1232,7 @@ static CURLcode imap_state_append_resp(struct connectdata *conn, int imapcode,
Curl_pgrsSetUploadSize(data, data->state.infilesize);
/* IMAP upload */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, FIRSTSOCKET, NULL);
+ Curl_setup_transfer(data, -1, -1, FALSE, FIRSTSOCKET);
/* End of DO phase */
state(conn, IMAP_STOP);
@@ -1241,7 +1250,7 @@ static CURLcode imap_state_append_final_resp(struct connectdata *conn,
(void)instate; /* No use for this yet */
- if(imapcode != 'O')
+ if(imapcode != IMAP_RESP_OK)
result = CURLE_UPLOAD_FAILED;
else
/* End of DONE phase */
@@ -1354,19 +1363,20 @@ static CURLcode imap_multi_statemach(struct connectdata *conn, bool *done)
return result;
}
- result = Curl_pp_statemach(&imapc->pp, FALSE);
+ result = Curl_pp_statemach(&imapc->pp, FALSE, FALSE);
*done = (imapc->state == IMAP_STOP) ? TRUE : FALSE;
return result;
}
-static CURLcode imap_block_statemach(struct connectdata *conn)
+static CURLcode imap_block_statemach(struct connectdata *conn,
+ bool disconnecting)
{
CURLcode result = CURLE_OK;
struct imap_conn *imapc = &conn->proto.imapc;
while(imapc->state != IMAP_STOP && !result)
- result = Curl_pp_statemach(&imapc->pp, TRUE);
+ result = Curl_pp_statemach(&imapc->pp, TRUE, disconnecting);
return result;
}
@@ -1469,9 +1479,11 @@ static CURLcode imap_done(struct connectdata *conn, CURLcode status,
result = status; /* use the already set error code */
}
else if(!data->set.connect_only && !imap->custom &&
- (imap->uid || data->set.upload)) {
+ (imap->uid || imap->mindex || data->set.upload ||
+ data->set.mimepost.kind != MIMEKIND_NONE)) {
/* Handle responses after FETCH or APPEND transfer has finished */
- if(!data->set.upload)
+
+ if(!data->set.upload && data->set.mimepost.kind == MIMEKIND_NONE)
state(conn, IMAP_FETCH_FINAL);
else {
/* End the APPEND command first by sending an empty line */
@@ -1480,20 +1492,16 @@ static CURLcode imap_done(struct connectdata *conn, CURLcode status,
state(conn, IMAP_APPEND_FINAL);
}
- /* Run the state-machine
-
- TODO: when the multi interface is used, this _really_ should be using
- the imap_multi_statemach function but we have no general support for
- non-blocking DONE operations!
- */
+ /* Run the state-machine */
if(!result)
- result = imap_block_statemach(conn);
+ result = imap_block_statemach(conn, FALSE);
}
/* Cleanup our per-request based variables */
Curl_safefree(imap->mailbox);
Curl_safefree(imap->uidvalidity);
Curl_safefree(imap->uid);
+ Curl_safefree(imap->mindex);
Curl_safefree(imap->section);
Curl_safefree(imap->partial);
Curl_safefree(imap->query);
@@ -1535,26 +1543,26 @@ static CURLcode imap_perform(struct connectdata *conn, bool *connected,
/* Determine if the requested mailbox (with the same UIDVALIDITY if set)
has already been selected on this connection */
if(imap->mailbox && imapc->mailbox &&
- !strcmp(imap->mailbox, imapc->mailbox) &&
+ strcasecompare(imap->mailbox, imapc->mailbox) &&
(!imap->uidvalidity || !imapc->mailbox_uidvalidity ||
- !strcmp(imap->uidvalidity, imapc->mailbox_uidvalidity)))
+ strcasecompare(imap->uidvalidity, imapc->mailbox_uidvalidity)))
selected = TRUE;
/* Start the first command in the DO phase */
- if(conn->data->set.upload)
+ if(conn->data->set.upload || data->set.mimepost.kind != MIMEKIND_NONE)
/* APPEND can be executed directly */
result = imap_perform_append(conn);
else if(imap->custom && (selected || !imap->mailbox))
/* Custom command using the same mailbox or no mailbox */
result = imap_perform_list(conn);
- else if(!imap->custom && selected && imap->uid)
+ else if(!imap->custom && selected && (imap->uid || imap->mindex))
/* FETCH from the same mailbox */
result = imap_perform_fetch(conn);
else if(!imap->custom && selected && imap->query)
/* SEARCH the current mailbox */
result = imap_perform_search(conn);
else if(imap->mailbox && !selected &&
- (imap->custom || imap->uid || imap->query))
+ (imap->custom || imap->uid || imap->mindex || imap->query))
/* SELECT the mailbox */
result = imap_perform_select(conn);
else
@@ -1624,7 +1632,7 @@ static CURLcode imap_disconnect(struct connectdata *conn, bool dead_connection)
point! */
if(!dead_connection && imapc->pp.conn && imapc->pp.conn->bits.protoconnstart)
if(!imap_perform_logout(conn))
- (void)imap_block_statemach(conn); /* ignore errors on LOGOUT */
+ (void)imap_block_statemach(conn, TRUE); /* ignore errors on LOGOUT */
/* Disconnect from the server */
Curl_pp_disconnect(&imapc->pp);
@@ -1648,7 +1656,7 @@ static CURLcode imap_dophase_done(struct connectdata *conn, bool connected)
if(imap->transfer != FTPTRANSFER_BODY)
/* no data to transfer */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(conn->data, -1, -1, FALSE, -1);
return CURLE_OK;
}
@@ -1706,8 +1714,6 @@ static CURLcode imap_regular_transfer(struct connectdata *conn,
static CURLcode imap_setup_connection(struct connectdata *conn)
{
- struct Curl_easy *data = conn->data;
-
/* Initialise the IMAP layer */
CURLcode result = imap_init(conn);
if(result)
@@ -1716,32 +1722,6 @@ static CURLcode imap_setup_connection(struct connectdata *conn)
/* Clear the TLS upgraded flag */
conn->tls_upgraded = FALSE;
- /* Set up the proxy if necessary */
- if(conn->bits.httpproxy && !data->set.tunnel_thru_httpproxy) {
- /* Unless we have asked to tunnel IMAP operations through the proxy, we
- switch and use HTTP operations only */
-#ifndef CURL_DISABLE_HTTP
- if(conn->handler == &Curl_handler_imap)
- conn->handler = &Curl_handler_imap_proxy;
- else {
-#ifdef USE_SSL
- conn->handler = &Curl_handler_imaps_proxy;
-#else
- failf(data, "IMAPS not supported!");
- return CURLE_UNSUPPORTED_PROTOCOL;
-#endif
- }
-
- /* set it up as an HTTP connection instead */
- return conn->handler->setup_connection(conn);
-#else
- failf(data, "IMAP over http proxy requires HTTP support built-in!");
- return CURLE_UNSUPPORTED_PROTOCOL;
-#endif
- }
-
- data->state.path++; /* don't include the initial slash */
-
return CURLE_OK;
}
@@ -1766,8 +1746,8 @@ static CURLcode imap_sendf(struct connectdata *conn, const char *fmt, ...)
imapc->cmdid = (imapc->cmdid + 1) % 1000;
/* Calculate the tag based on the connection ID and command ID */
- snprintf(imapc->resptag, sizeof(imapc->resptag), "%c%03d",
- 'A' + curlx_sltosi(conn->connection_id % 26), imapc->cmdid);
+ msnprintf(imapc->resptag, sizeof(imapc->resptag), "%c%03d",
+ 'A' + curlx_sltosi(conn->connection_id % 26), imapc->cmdid);
/* Prefix the format with the tag */
taggedfmt = aprintf("%s %s", imapc->resptag, fmt);
@@ -1810,7 +1790,7 @@ static char *imap_atom(const char *str, bool escape_only)
return NULL;
/* Look for "atom-specials", counting the backslash and quote characters as
- these will need escapping */
+ these will need escaping */
p1 = str;
while(*p1) {
if(*p1 == '\\')
@@ -1836,7 +1816,7 @@ static char *imap_atom(const char *str, bool escape_only)
return strdup(str);
/* Calculate the new string length */
- newlen = strlen(str) + backsp_count + quote_count + (others_exists ? 2 : 0);
+ newlen = strlen(str) + backsp_count + quote_count + (escape_only ? 0 : 2);
/* Allocate the new string */
newstr = (char *) malloc((newlen + 1) * sizeof(char));
@@ -1845,7 +1825,7 @@ static char *imap_atom(const char *str, bool escape_only)
/* Surround the string in quotes if necessary */
p2 = newstr;
- if(others_exists) {
+ if(!escape_only) {
newstr[0] = '"';
newstr[newlen - 1] = '"';
p2++;
@@ -1973,7 +1953,7 @@ static CURLcode imap_parse_url_path(struct connectdata *conn)
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
struct IMAP *imap = data->req.protop;
- const char *begin = data->state.path;
+ const char *begin = &data->state.up.path[1]; /* skip leading slash */
const char *ptr = begin;
/* See how much of the URL is a valid path and decode it */
@@ -2045,6 +2025,13 @@ static CURLcode imap_parse_url_path(struct connectdata *conn)
imap->uid = value;
value = NULL;
}
+ else if(strcasecompare(name, "MAILINDEX") && !imap->mindex) {
+ if(valuelen > 0 && value[valuelen - 1] == '/')
+ value[valuelen - 1] = '\0';
+
+ imap->mindex = value;
+ value = NULL;
+ }
else if(strcasecompare(name, "SECTION") && !imap->section) {
if(valuelen > 0 && value[valuelen - 1] == '/')
value[valuelen - 1] = '\0';
@@ -2072,17 +2059,10 @@ static CURLcode imap_parse_url_path(struct connectdata *conn)
/* Does the URL contain a query parameter? Only valid when we have a mailbox
and no UID as per RFC-5092 */
- if(imap->mailbox && !imap->uid && *ptr == '?') {
- /* Find the length of the query parameter */
- begin = ++ptr;
- while(imap_is_bchar(*ptr))
- ptr++;
-
- /* Decode the query parameter */
- result = Curl_urldecode(data, begin, ptr - begin, &imap->query, NULL,
- TRUE);
- if(result)
- return result;
+ if(imap->mailbox && !imap->uid && !imap->mindex) {
+ /* Get the query parameter, URL decoded */
+ (void)curl_url_get(data->state.uh, CURLUPART_QUERY, &imap->query,
+ CURLU_URLDECODE);
}
/* Any extra stuff at the end of the URL is an error */
diff --git a/Utilities/cmcurl/lib/imap.h b/Utilities/cmcurl/lib/imap.h
index 5e0e228f5..0efcfd293 100644
--- a/Utilities/cmcurl/lib/imap.h
+++ b/Utilities/cmcurl/lib/imap.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2009 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2009 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -58,6 +58,7 @@ struct IMAP {
char *mailbox; /* Mailbox to select */
char *uidvalidity; /* UIDVALIDITY to check in select */
char *uid; /* Message UID to fetch */
+ char *mindex; /* Index in mail box of mail to fetch */
char *section; /* Message SECTION to fetch */
char *partial; /* Message PARTIAL to fetch */
char *query; /* Query to search for */
@@ -71,6 +72,7 @@ struct imap_conn {
struct pingpong pp;
imapstate state; /* Always use imap.c:state() to change state! */
bool ssldone; /* Is connect() over SSL done? */
+ bool preauth; /* Is this connection PREAUTH? */
struct SASL sasl; /* SASL-related parameters */
unsigned int preftype; /* Preferred authentication type */
int cmdid; /* Last used command ID */
diff --git a/Utilities/cmcurl/lib/inet_ntop.c b/Utilities/cmcurl/lib/inet_ntop.c
index 9afbdbb32..855981c66 100644
--- a/Utilities/cmcurl/lib/inet_ntop.c
+++ b/Utilities/cmcurl/lib/inet_ntop.c
@@ -49,21 +49,21 @@
*/
static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size)
{
- char tmp[sizeof "255.255.255.255"];
+ char tmp[sizeof("255.255.255.255")];
size_t len;
DEBUGASSERT(size >= 16);
tmp[0] = '\0';
- (void)snprintf(tmp, sizeof(tmp), "%d.%d.%d.%d",
- ((int)((unsigned char)src[0])) & 0xff,
- ((int)((unsigned char)src[1])) & 0xff,
- ((int)((unsigned char)src[2])) & 0xff,
- ((int)((unsigned char)src[3])) & 0xff);
+ (void)msnprintf(tmp, sizeof(tmp), "%d.%d.%d.%d",
+ ((int)((unsigned char)src[0])) & 0xff,
+ ((int)((unsigned char)src[1])) & 0xff,
+ ((int)((unsigned char)src[2])) & 0xff,
+ ((int)((unsigned char)src[3])) & 0xff);
len = strlen(tmp);
if(len == 0 || len >= size) {
- SET_ERRNO(ENOSPC);
+ errno = ENOSPC;
return (NULL);
}
strcpy(dst, tmp);
@@ -141,14 +141,14 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
*/
if(i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
- if(!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp))) {
- SET_ERRNO(ENOSPC);
+ if(!inet_ntop4(src + 12, tp, sizeof(tmp) - (tp - tmp))) {
+ errno = ENOSPC;
return (NULL);
}
tp += strlen(tp);
break;
}
- tp += snprintf(tp, 5, "%lx", words[i]);
+ tp += msnprintf(tp, 5, "%lx", words[i]);
}
/* Was it a trailing run of 0x00's?
@@ -160,7 +160,7 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
/* Check for overflow, copy, and we're done.
*/
if((size_t)(tp - tmp) > size) {
- SET_ERRNO(ENOSPC);
+ errno = ENOSPC;
return (NULL);
}
strcpy(dst, tmp);
@@ -177,8 +177,8 @@ static char *inet_ntop6 (const unsigned char *src, char *dst, size_t size)
*
* On Windows we store the error in the thread errno, not
* in the winsock error code. This is to avoid losing the
- * actual last winsock error. So use macro ERRNO to fetch the
- * errno this function sets when returning NULL, not SOCKERRNO.
+ * actual last winsock error. So when this function returns
+ * NULL, check errno not SOCKERRNO.
*/
char *Curl_inet_ntop(int af, const void *src, char *buf, size_t size)
{
@@ -190,7 +190,7 @@ char *Curl_inet_ntop(int af, const void *src, char *buf, size_t size)
return inet_ntop6((const unsigned char *)src, buf, size);
#endif
default:
- SET_ERRNO(EAFNOSUPPORT);
+ errno = EAFNOSUPPORT;
return NULL;
}
}
diff --git a/Utilities/cmcurl/lib/inet_ntop.h b/Utilities/cmcurl/lib/inet_ntop.h
index 9f4461271..d150bb693 100644
--- a/Utilities/cmcurl/lib/inet_ntop.h
+++ b/Utilities/cmcurl/lib/inet_ntop.h
@@ -35,4 +35,3 @@ char *Curl_inet_ntop(int af, const void *addr, char *buf, size_t size);
#endif
#endif /* HEADER_CURL_INET_NTOP_H */
-
diff --git a/Utilities/cmcurl/lib/inet_pton.c b/Utilities/cmcurl/lib/inet_pton.c
index 475f44abc..0d65ae0ec 100644
--- a/Utilities/cmcurl/lib/inet_pton.c
+++ b/Utilities/cmcurl/lib/inet_pton.c
@@ -57,8 +57,8 @@ static int inet_pton6(const char *src, unsigned char *dst);
* notice:
* On Windows we store the error in the thread errno, not
* in the winsock error code. This is to avoid losing the
- * actual last winsock error. So use macro ERRNO to fetch the
- * errno this function sets when returning (-1), not SOCKERRNO.
+ * actual last winsock error. So when this function returns
+ * -1, check errno not SOCKERRNO.
* author:
* Paul Vixie, 1996.
*/
@@ -73,7 +73,7 @@ Curl_inet_pton(int af, const char *src, void *dst)
return (inet_pton6(src, (unsigned char *)dst));
#endif
default:
- SET_ERRNO(EAFNOSUPPORT);
+ errno = EAFNOSUPPORT;
return (-1);
}
/* NOTREACHED */
@@ -153,7 +153,7 @@ inet_pton6(const char *src, unsigned char *dst)
static const char xdigits_l[] = "0123456789abcdef",
xdigits_u[] = "0123456789ABCDEF";
unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp;
- const char *xdigits, *curtok;
+ const char *curtok;
int ch, saw_xdigit;
size_t val;
@@ -168,6 +168,7 @@ inet_pton6(const char *src, unsigned char *dst)
saw_xdigit = 0;
val = 0;
while((ch = *src++) != '\0') {
+ const char *xdigits;
const char *pch;
pch = strchr((xdigits = xdigits_l), ch);
diff --git a/Utilities/cmcurl/lib/inet_pton.h b/Utilities/cmcurl/lib/inet_pton.h
index 9188d9598..0209b9b7b 100644
--- a/Utilities/cmcurl/lib/inet_pton.h
+++ b/Utilities/cmcurl/lib/inet_pton.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -29,9 +29,11 @@ int Curl_inet_pton(int, const char *, void *);
#ifdef HAVE_INET_PTON
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
+#elif defined(HAVE_WS2TCPIP_H)
+/* inet_pton() exists in Vista or later */
+#include <ws2tcpip.h>
#endif
#define Curl_inet_pton(x,y,z) inet_pton(x,y,z)
#endif
#endif /* HEADER_CURL_INET_PTON_H */
-
diff --git a/Utilities/cmcurl/lib/krb5.c b/Utilities/cmcurl/lib/krb5.c
index 69a35979a..147ab024e 100644
--- a/Utilities/cmcurl/lib/krb5.c
+++ b/Utilities/cmcurl/lib/krb5.c
@@ -1,8 +1,8 @@
/* GSSAPI/krb5 support for FTP - loosely based on old krb4.c
*
- * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
- * Copyright (c) 2004 - 2016 Daniel Stenberg
+ * Copyright (c) 2004 - 2017 Daniel Stenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -85,7 +85,7 @@ krb5_decode(void *app_data, void *buf, int len,
enc.value = buf;
enc.length = len;
- maj = gss_unseal(&min, *context, &enc, &dec, NULL, NULL);
+ maj = gss_unwrap(&min, *context, &enc, &dec, NULL, NULL);
if(maj != GSS_S_COMPLETE) {
if(len >= 4)
strcpy(buf, "599 ");
@@ -119,11 +119,11 @@ krb5_encode(void *app_data, const void *from, int length, int level, void **to)
int len;
/* NOTE that the cast is safe, neither of the krb5, gnu gss and heimdal
- * libraries modify the input buffer in gss_seal()
+ * libraries modify the input buffer in gss_wrap()
*/
dec.value = (void *)from;
dec.length = length;
- maj = gss_seal(&min, *context,
+ maj = gss_wrap(&min, *context,
level == PROT_PRIVATE,
GSS_C_QOP_DEFAULT,
&dec, &state, &enc);
@@ -206,7 +206,7 @@ krb5_auth(void *app_data, struct connectdata *conn)
if(maj != GSS_S_COMPLETE) {
gss_release_name(&min, &gssname);
if(service == srv_host) {
- Curl_failf(data, "Error importing service name %s@%s", service, host);
+ failf(data, "Error importing service name %s@%s", service, host);
return AUTH_ERROR;
}
service = srv_host;
@@ -265,6 +265,7 @@ krb5_auth(void *app_data, struct connectdata *conn)
result = CURLE_OUT_OF_MEMORY;
free(p);
+ free(cmd);
if(result) {
ret = -2;
@@ -282,6 +283,7 @@ krb5_auth(void *app_data, struct connectdata *conn)
break;
}
+ _gssresp.value = NULL; /* make sure it is initialized */
p = data->state.buffer + 4;
p = strstr(p, "ADAT=");
if(p) {
@@ -289,8 +291,7 @@ krb5_auth(void *app_data, struct connectdata *conn)
(unsigned char **)&_gssresp.value,
&_gssresp.length);
if(result) {
- Curl_failf(data, "base64-decoding: %s",
- curl_easy_strerror(result));
+ failf(data, "base64-decoding: %s", curl_easy_strerror(result));
ret = AUTH_CONTINUE;
break;
}
diff --git a/Utilities/cmcurl/lib/ldap.c b/Utilities/cmcurl/lib/ldap.c
index 79e84d94e..fd31faa3e 100644
--- a/Utilities/cmcurl/lib/ldap.c
+++ b/Utilities/cmcurl/lib/ldap.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -54,15 +54,6 @@
# endif /* HAVE_LDAP_SSL && HAVE_LDAP_SSL_H */
#endif
-/* These are macros in both <wincrypt.h> (in above <winldap.h>) and typedefs
- * in BoringSSL's <openssl/x509.h>
- */
-#ifdef HAVE_BORINGSSL
-# undef X509_NAME
-# undef X509_CERT_PAIR
-# undef X509_EXTENSIONS
-#endif
-
#include "urldata.h"
#include <curl/curl.h>
#include "sendf.h"
@@ -150,6 +141,7 @@ const struct Curl_handler Curl_handler_ldap = {
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_LDAP, /* defport */
CURLPROTO_LDAP, /* protocol */
PROTOPT_NONE /* flags */
@@ -175,6 +167,7 @@ const struct Curl_handler Curl_handler_ldaps = {
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_LDAPS, /* defport */
CURLPROTO_LDAPS, /* protocol */
PROTOPT_SSL /* flags */
@@ -188,9 +181,11 @@ static int ldap_win_bind_auth(LDAP *server, const char *user,
const char *passwd, unsigned long authflags)
{
ULONG method = 0;
- SEC_WINNT_AUTH_IDENTITY cred = { 0, };
+ SEC_WINNT_AUTH_IDENTITY cred;
int rc = LDAP_AUTH_METHOD_NOT_SUPPORTED;
+ memset(&cred, 0, sizeof(cred));
+
#if defined(USE_SPNEGO)
if(authflags & CURLAUTH_NEGOTIATE) {
method = LDAP_AUTH_NEGOTIATE;
@@ -233,7 +228,6 @@ static int ldap_win_bind(struct connectdata *conn, LDAP *server,
const char *user, const char *passwd)
{
int rc = LDAP_INVALID_CREDENTIALS;
- ULONG method = LDAP_AUTH_SIMPLE;
PTCHAR inuser = NULL;
PTCHAR inpass = NULL;
@@ -242,7 +236,7 @@ static int ldap_win_bind(struct connectdata *conn, LDAP *server,
inuser = Curl_convert_UTF8_to_tchar((char *) user);
inpass = Curl_convert_UTF8_to_tchar((char *) passwd);
- rc = ldap_bind_s(server, inuser, inpass, method);
+ rc = ldap_simple_bind_s(server, inuser, inpass);
Curl_unicodefree(inuser);
Curl_unicodefree(inpass);
@@ -266,7 +260,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
LDAPMessage *ldapmsg = NULL;
LDAPMessage *entryIterator;
int num = 0;
- struct Curl_easy *data=conn->data;
+ struct Curl_easy *data = conn->data;
int ldap_proto = LDAP_VERSION3;
int ldap_ssl = 0;
char *val_b64 = NULL;
@@ -480,7 +474,13 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
#endif
}
if(rc != 0) {
- failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
+#ifdef USE_WIN32_LDAP
+ failf(data, "LDAP local: bind via ldap_win_bind %s",
+ ldap_err2string(rc));
+#else
+ failf(data, "LDAP local: bind via ldap_simple_bind_s %s",
+ ldap_err2string(rc));
+#endif
result = CURLE_LDAP_CANNOT_BIND;
goto quit;
}
@@ -744,7 +744,7 @@ quit:
#endif
/* no data to transfer */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
connclose(conn, "LDAP connection always disable re-use");
return result;
@@ -839,14 +839,15 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
{
int rc = LDAP_SUCCESS;
char *path;
+ char *query;
char *p;
char *q;
size_t i;
if(!conn->data ||
- !conn->data->state.path ||
- conn->data->state.path[0] != '/' ||
- !checkprefix("LDAP", conn->data->change.url))
+ !conn->data->state.up.path ||
+ conn->data->state.up.path[0] != '/' ||
+ !strncasecompare("LDAP", conn->data->state.up.scheme, 4))
return LDAP_INVALID_SYNTAX;
ludp->lud_scope = LDAP_SCOPE_BASE;
@@ -854,15 +855,18 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
ludp->lud_host = conn->host.name;
/* Duplicate the path */
- p = path = strdup(conn->data->state.path + 1);
+ p = path = strdup(conn->data->state.up.path + 1);
if(!path)
return LDAP_NO_MEMORY;
- /* Parse the DN (Distinguished Name) */
- q = strchr(p, '?');
- if(q)
- *q++ = '\0';
+ /* Duplicate the query */
+ q = query = strdup(conn->data->state.up.query);
+ if(!query) {
+ free(path);
+ return LDAP_NO_MEMORY;
+ }
+ /* Parse the DN (Distinguished Name) */
if(*p) {
char *dn = p;
char *unescaped;
@@ -1039,6 +1043,7 @@ static int _ldap_url_parse2(const struct connectdata *conn, LDAPURLDesc *ludp)
quit:
free(path);
+ free(query);
return rc;
}
@@ -1064,8 +1069,6 @@ static int _ldap_url_parse(const struct connectdata *conn,
static void _ldap_free_urldesc(LDAPURLDesc *ludp)
{
- size_t i;
-
if(!ludp)
return;
@@ -1073,6 +1076,7 @@ static void _ldap_free_urldesc(LDAPURLDesc *ludp)
free(ludp->lud_filter);
if(ludp->lud_attrs) {
+ size_t i;
for(i = 0; i < ludp->lud_attrs_dups; i++)
free(ludp->lud_attrs[i]);
free(ludp->lud_attrs);
diff --git a/Utilities/cmcurl/lib/libcurl.rc b/Utilities/cmcurl/lib/libcurl.rc
index 3316fba19..4839d0a65 100644
--- a/Utilities/cmcurl/lib/libcurl.rc
+++ b/Utilities/cmcurl/lib/libcurl.rc
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,22 +22,22 @@
#include <winver.h>
#include "../include/curl/curlver.h"
-LANGUAGE 0x09,0x01
+LANGUAGE 0, 0
#define RC_VERSION LIBCURL_VERSION_MAJOR, LIBCURL_VERSION_MINOR, LIBCURL_VERSION_PATCH, 0
VS_VERSION_INFO VERSIONINFO
FILEVERSION RC_VERSION
PRODUCTVERSION RC_VERSION
- FILEFLAGSMASK 0x3fL
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#if defined(DEBUGBUILD) || defined(_DEBUG)
- FILEFLAGS 1
+ FILEFLAGS VS_FF_DEBUG
#else
- FILEFLAGS 0
+ FILEFLAGS 0L
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
- FILESUBTYPE 0x0L
+ FILESUBTYPE 0L
BEGIN
BLOCK "StringFileInfo"
diff --git a/Utilities/cmcurl/lib/llist.c b/Utilities/cmcurl/lib/llist.c
index 4bb0a51b8..f8769c2af 100644
--- a/Utilities/cmcurl/lib/llist.c
+++ b/Utilities/cmcurl/lib/llist.c
@@ -106,7 +106,11 @@ Curl_llist_remove(struct curl_llist *list, struct curl_llist_element *e,
e->next->prev = NULL;
}
else {
- e->prev->next = e->next;
+ if(!e->prev)
+ list->head = e->next;
+ else
+ e->prev->next = e->next;
+
if(!e->next)
list->tail = e->prev;
else
diff --git a/Utilities/cmcurl/lib/llist.h b/Utilities/cmcurl/lib/llist.h
index 6b644b99c..b9d4c89a9 100644
--- a/Utilities/cmcurl/lib/llist.h
+++ b/Utilities/cmcurl/lib/llist.h
@@ -51,4 +51,3 @@ void Curl_llist_move(struct curl_llist *, struct curl_llist_element *,
struct curl_llist *, struct curl_llist_element *);
#endif /* HEADER_CURL_LLIST_H */
-
diff --git a/Utilities/cmcurl/lib/md4.c b/Utilities/cmcurl/lib/md4.c
index 2bb7dcc25..e7c77bc36 100644
--- a/Utilities/cmcurl/lib/md4.c
+++ b/Utilities/cmcurl/lib/md4.c
@@ -1,9 +1,10 @@
/*
+ * !checksrc! disable COPYRIGHT
* This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
* MD4 Message-Digest Algorithm (RFC 1320).
*
* Homepage:
- http://openwall.info/wiki/people/solar/software/public-domain-source-code/md4
+ https://openwall.info/wiki/people/solar/software/public-domain-source-code/md4
*
* Author:
* Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
@@ -37,9 +38,11 @@
#include "curl_setup.h"
-/* The NSS, OS/400 and sometimes mbed TLS crypto libraries do not provide the
- * MD4 hash algorithm, so we have a local implementation of it */
+/* The NSS, OS/400, and when not included, OpenSSL and mbed TLS crypto
+ * libraries do not provide the MD4 hash algorithm, so we use this
+ * implementation of it */
#if defined(USE_NSS) || defined(USE_OS400CRYPTO) || \
+ (defined(USE_OPENSSL) && defined(OPENSSL_NO_MD4)) || \
(defined(USE_MBEDTLS) && !defined(MBEDTLS_MD4_C))
#include "curl_md4.h"
@@ -112,7 +115,6 @@ static const void *body(MD4_CTX *ctx, const void *data, unsigned long size)
{
const unsigned char *ptr;
MD4_u32plus a, b, c, d;
- MD4_u32plus saved_a, saved_b, saved_c, saved_d;
ptr = (const unsigned char *)data;
@@ -122,6 +124,8 @@ static const void *body(MD4_CTX *ctx, const void *data, unsigned long size)
d = ctx->d;
do {
+ MD4_u32plus saved_a, saved_b, saved_c, saved_d;
+
saved_a = a;
saved_b = b;
saved_c = c;
@@ -129,59 +133,59 @@ static const void *body(MD4_CTX *ctx, const void *data, unsigned long size)
/* Round 1 */
STEP(F, a, b, c, d, SET(0), 3)
- STEP(F, d, a, b, c, SET(1), 7)
- STEP(F, c, d, a, b, SET(2), 11)
- STEP(F, b, c, d, a, SET(3), 19)
- STEP(F, a, b, c, d, SET(4), 3)
- STEP(F, d, a, b, c, SET(5), 7)
- STEP(F, c, d, a, b, SET(6), 11)
- STEP(F, b, c, d, a, SET(7), 19)
- STEP(F, a, b, c, d, SET(8), 3)
- STEP(F, d, a, b, c, SET(9), 7)
- STEP(F, c, d, a, b, SET(10), 11)
- STEP(F, b, c, d, a, SET(11), 19)
- STEP(F, a, b, c, d, SET(12), 3)
- STEP(F, d, a, b, c, SET(13), 7)
- STEP(F, c, d, a, b, SET(14), 11)
- STEP(F, b, c, d, a, SET(15), 19)
+ STEP(F, d, a, b, c, SET(1), 7)
+ STEP(F, c, d, a, b, SET(2), 11)
+ STEP(F, b, c, d, a, SET(3), 19)
+ STEP(F, a, b, c, d, SET(4), 3)
+ STEP(F, d, a, b, c, SET(5), 7)
+ STEP(F, c, d, a, b, SET(6), 11)
+ STEP(F, b, c, d, a, SET(7), 19)
+ STEP(F, a, b, c, d, SET(8), 3)
+ STEP(F, d, a, b, c, SET(9), 7)
+ STEP(F, c, d, a, b, SET(10), 11)
+ STEP(F, b, c, d, a, SET(11), 19)
+ STEP(F, a, b, c, d, SET(12), 3)
+ STEP(F, d, a, b, c, SET(13), 7)
+ STEP(F, c, d, a, b, SET(14), 11)
+ STEP(F, b, c, d, a, SET(15), 19)
/* Round 2 */
- STEP(G, a, b, c, d, GET(0) + 0x5a827999, 3)
- STEP(G, d, a, b, c, GET(4) + 0x5a827999, 5)
- STEP(G, c, d, a, b, GET(8) + 0x5a827999, 9)
- STEP(G, b, c, d, a, GET(12) + 0x5a827999, 13)
- STEP(G, a, b, c, d, GET(1) + 0x5a827999, 3)
- STEP(G, d, a, b, c, GET(5) + 0x5a827999, 5)
- STEP(G, c, d, a, b, GET(9) + 0x5a827999, 9)
- STEP(G, b, c, d, a, GET(13) + 0x5a827999, 13)
- STEP(G, a, b, c, d, GET(2) + 0x5a827999, 3)
- STEP(G, d, a, b, c, GET(6) + 0x5a827999, 5)
- STEP(G, c, d, a, b, GET(10) + 0x5a827999, 9)
- STEP(G, b, c, d, a, GET(14) + 0x5a827999, 13)
- STEP(G, a, b, c, d, GET(3) + 0x5a827999, 3)
- STEP(G, d, a, b, c, GET(7) + 0x5a827999, 5)
- STEP(G, c, d, a, b, GET(11) + 0x5a827999, 9)
- STEP(G, b, c, d, a, GET(15) + 0x5a827999, 13)
+ STEP(G, a, b, c, d, GET(0) + 0x5a827999, 3)
+ STEP(G, d, a, b, c, GET(4) + 0x5a827999, 5)
+ STEP(G, c, d, a, b, GET(8) + 0x5a827999, 9)
+ STEP(G, b, c, d, a, GET(12) + 0x5a827999, 13)
+ STEP(G, a, b, c, d, GET(1) + 0x5a827999, 3)
+ STEP(G, d, a, b, c, GET(5) + 0x5a827999, 5)
+ STEP(G, c, d, a, b, GET(9) + 0x5a827999, 9)
+ STEP(G, b, c, d, a, GET(13) + 0x5a827999, 13)
+ STEP(G, a, b, c, d, GET(2) + 0x5a827999, 3)
+ STEP(G, d, a, b, c, GET(6) + 0x5a827999, 5)
+ STEP(G, c, d, a, b, GET(10) + 0x5a827999, 9)
+ STEP(G, b, c, d, a, GET(14) + 0x5a827999, 13)
+ STEP(G, a, b, c, d, GET(3) + 0x5a827999, 3)
+ STEP(G, d, a, b, c, GET(7) + 0x5a827999, 5)
+ STEP(G, c, d, a, b, GET(11) + 0x5a827999, 9)
+ STEP(G, b, c, d, a, GET(15) + 0x5a827999, 13)
/* Round 3 */
- STEP(H, a, b, c, d, GET(0) + 0x6ed9eba1, 3)
- STEP(H, d, a, b, c, GET(8) + 0x6ed9eba1, 9)
- STEP(H, c, d, a, b, GET(4) + 0x6ed9eba1, 11)
- STEP(H, b, c, d, a, GET(12) + 0x6ed9eba1, 15)
- STEP(H, a, b, c, d, GET(2) + 0x6ed9eba1, 3)
- STEP(H, d, a, b, c, GET(10) + 0x6ed9eba1, 9)
- STEP(H, c, d, a, b, GET(6) + 0x6ed9eba1, 11)
- STEP(H, b, c, d, a, GET(14) + 0x6ed9eba1, 15)
- STEP(H, a, b, c, d, GET(1) + 0x6ed9eba1, 3)
- STEP(H, d, a, b, c, GET(9) + 0x6ed9eba1, 9)
- STEP(H, c, d, a, b, GET(5) + 0x6ed9eba1, 11)
- STEP(H, b, c, d, a, GET(13) + 0x6ed9eba1, 15)
- STEP(H, a, b, c, d, GET(3) + 0x6ed9eba1, 3)
- STEP(H, d, a, b, c, GET(11) + 0x6ed9eba1, 9)
- STEP(H, c, d, a, b, GET(7) + 0x6ed9eba1, 11)
- STEP(H, b, c, d, a, GET(15) + 0x6ed9eba1, 15)
-
- a += saved_a;
+ STEP(H, a, b, c, d, GET(0) + 0x6ed9eba1, 3)
+ STEP(H, d, a, b, c, GET(8) + 0x6ed9eba1, 9)
+ STEP(H, c, d, a, b, GET(4) + 0x6ed9eba1, 11)
+ STEP(H, b, c, d, a, GET(12) + 0x6ed9eba1, 15)
+ STEP(H, a, b, c, d, GET(2) + 0x6ed9eba1, 3)
+ STEP(H, d, a, b, c, GET(10) + 0x6ed9eba1, 9)
+ STEP(H, c, d, a, b, GET(6) + 0x6ed9eba1, 11)
+ STEP(H, b, c, d, a, GET(14) + 0x6ed9eba1, 15)
+ STEP(H, a, b, c, d, GET(1) + 0x6ed9eba1, 3)
+ STEP(H, d, a, b, c, GET(9) + 0x6ed9eba1, 9)
+ STEP(H, c, d, a, b, GET(5) + 0x6ed9eba1, 11)
+ STEP(H, b, c, d, a, GET(13) + 0x6ed9eba1, 15)
+ STEP(H, a, b, c, d, GET(3) + 0x6ed9eba1, 3)
+ STEP(H, d, a, b, c, GET(11) + 0x6ed9eba1, 9)
+ STEP(H, c, d, a, b, GET(7) + 0x6ed9eba1, 11)
+ STEP(H, b, c, d, a, GET(15) + 0x6ed9eba1, 15)
+
+ a += saved_a;
b += saved_b;
c += saved_c;
d += saved_d;
@@ -211,7 +215,7 @@ static void MD4_Init(MD4_CTX *ctx)
static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
{
MD4_u32plus saved_lo;
- unsigned long used, available;
+ unsigned long used;
saved_lo = ctx->lo;
ctx->lo = (saved_lo + size) & 0x1fffffff;
@@ -222,7 +226,7 @@ static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
used = saved_lo & 0x3f;
if(used) {
- available = 64 - used;
+ unsigned long available = 64 - used;
if(size < available) {
memcpy(&ctx->buffer[used], data, size);
@@ -303,5 +307,7 @@ void Curl_md4it(unsigned char *output, const unsigned char *input, size_t len)
MD4_Update(&ctx, input, curlx_uztoui(len));
MD4_Final(output, &ctx);
}
+
#endif /* defined(USE_NSS) || defined(USE_OS400CRYPTO) ||
+ (defined(USE_OPENSSL) && defined(OPENSSL_NO_MD4)) ||
(defined(USE_MBEDTLS) && !defined(MBEDTLS_MD4_C)) */
diff --git a/Utilities/cmcurl/lib/md5.c b/Utilities/cmcurl/lib/md5.c
index 80301a141..2b81ca455 100644
--- a/Utilities/cmcurl/lib/md5.c
+++ b/Utilities/cmcurl/lib/md5.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -39,19 +39,19 @@
typedef struct md5_ctx MD5_CTX;
-static void MD5_Init(MD5_CTX * ctx)
+static void MD5_Init(MD5_CTX *ctx)
{
md5_init(ctx);
}
-static void MD5_Update(MD5_CTX * ctx,
+static void MD5_Update(MD5_CTX *ctx,
const unsigned char *input,
unsigned int inputLen)
{
md5_update(ctx, inputLen, input);
}
-static void MD5_Final(unsigned char digest[16], MD5_CTX * ctx)
+static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
{
md5_digest(ctx, 16, digest);
}
@@ -65,25 +65,25 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX * ctx)
typedef gcry_md_hd_t MD5_CTX;
-static void MD5_Init(MD5_CTX * ctx)
+static void MD5_Init(MD5_CTX *ctx)
{
gcry_md_open(ctx, GCRY_MD_MD5, 0);
}
-static void MD5_Update(MD5_CTX * ctx,
+static void MD5_Update(MD5_CTX *ctx,
const unsigned char *input,
unsigned int inputLen)
{
gcry_md_write(*ctx, input, inputLen);
}
-static void MD5_Final(unsigned char digest[16], MD5_CTX * ctx)
+static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
{
memcpy(digest, gcry_md_read(*ctx, 0), 16);
gcry_md_close(*ctx);
}
-#elif defined(USE_OPENSSL)
+#elif defined(USE_OPENSSL) && !defined(USE_AMISSL)
/* When OpenSSL is available we use the MD5-function from OpenSSL */
#include <openssl/md5.h>
#include "curl_memory.h"
@@ -124,7 +124,7 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
CC_MD5_Final(digest, ctx);
}
-#elif defined(_WIN32) && !defined(CURL_WINDOWS_APP)
+#elif defined(WIN32) && !defined(CURL_WINDOWS_APP)
#include <wincrypt.h>
#include "curl_memory.h"
@@ -163,13 +163,6 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
CryptReleaseContext(ctx->hCryptProv, 0);
}
-#elif defined(USE_AXTLS)
-#include <axTLS/config.h>
-#include <axTLS/os_int.h>
-#include <axTLS/crypto.h>
-#include "curl_memory.h"
-/* The last #include file should be: */
-#include "memdebug.h"
#else
/* When no other crypto library is available we use this code segment */
/*
@@ -177,7 +170,7 @@ static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
* MD5 Message-Digest Algorithm (RFC 1321).
*
* Homepage:
- http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
+ https://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
*
* Author:
* Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
@@ -282,7 +275,6 @@ static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
{
const unsigned char *ptr;
MD5_u32plus a, b, c, d;
- MD5_u32plus saved_a, saved_b, saved_c, saved_d;
ptr = (const unsigned char *)data;
@@ -292,6 +284,8 @@ static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
d = ctx->d;
do {
+ MD5_u32plus saved_a, saved_b, saved_c, saved_d;
+
saved_a = a;
saved_b = b;
saved_c = c;
@@ -299,77 +293,77 @@ static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
/* Round 1 */
STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7)
- STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12)
- STEP(F, c, d, a, b, SET(2), 0x242070db, 17)
- STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22)
- STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7)
- STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12)
- STEP(F, c, d, a, b, SET(6), 0xa8304613, 17)
- STEP(F, b, c, d, a, SET(7), 0xfd469501, 22)
- STEP(F, a, b, c, d, SET(8), 0x698098d8, 7)
- STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12)
- STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17)
- STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22)
- STEP(F, a, b, c, d, SET(12), 0x6b901122, 7)
- STEP(F, d, a, b, c, SET(13), 0xfd987193, 12)
- STEP(F, c, d, a, b, SET(14), 0xa679438e, 17)
- STEP(F, b, c, d, a, SET(15), 0x49b40821, 22)
+ STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12)
+ STEP(F, c, d, a, b, SET(2), 0x242070db, 17)
+ STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22)
+ STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7)
+ STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12)
+ STEP(F, c, d, a, b, SET(6), 0xa8304613, 17)
+ STEP(F, b, c, d, a, SET(7), 0xfd469501, 22)
+ STEP(F, a, b, c, d, SET(8), 0x698098d8, 7)
+ STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12)
+ STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17)
+ STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22)
+ STEP(F, a, b, c, d, SET(12), 0x6b901122, 7)
+ STEP(F, d, a, b, c, SET(13), 0xfd987193, 12)
+ STEP(F, c, d, a, b, SET(14), 0xa679438e, 17)
+ STEP(F, b, c, d, a, SET(15), 0x49b40821, 22)
/* Round 2 */
- STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5)
- STEP(G, d, a, b, c, GET(6), 0xc040b340, 9)
- STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14)
- STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20)
- STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5)
- STEP(G, d, a, b, c, GET(10), 0x02441453, 9)
- STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14)
- STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20)
- STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5)
- STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9)
- STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14)
- STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20)
- STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5)
- STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9)
- STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14)
- STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20)
+ STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5)
+ STEP(G, d, a, b, c, GET(6), 0xc040b340, 9)
+ STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14)
+ STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20)
+ STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5)
+ STEP(G, d, a, b, c, GET(10), 0x02441453, 9)
+ STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14)
+ STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20)
+ STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5)
+ STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9)
+ STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14)
+ STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20)
+ STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5)
+ STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9)
+ STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14)
+ STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20)
/* Round 3 */
- STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4)
- STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11)
- STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16)
- STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23)
- STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4)
- STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11)
- STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16)
- STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23)
- STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4)
- STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11)
- STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16)
- STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23)
- STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4)
- STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11)
- STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16)
- STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23)
+ STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4)
+ STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11)
+ STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16)
+ STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23)
+ STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4)
+ STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11)
+ STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16)
+ STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23)
+ STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4)
+ STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11)
+ STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16)
+ STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23)
+ STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4)
+ STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11)
+ STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16)
+ STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23)
/* Round 4 */
- STEP(I, a, b, c, d, GET(0), 0xf4292244, 6)
- STEP(I, d, a, b, c, GET(7), 0x432aff97, 10)
- STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15)
- STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21)
- STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6)
- STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10)
- STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15)
- STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21)
- STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6)
- STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10)
- STEP(I, c, d, a, b, GET(6), 0xa3014314, 15)
- STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21)
- STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6)
- STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10)
- STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15)
- STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21)
-
- a += saved_a;
+ STEP(I, a, b, c, d, GET(0), 0xf4292244, 6)
+ STEP(I, d, a, b, c, GET(7), 0x432aff97, 10)
+ STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15)
+ STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21)
+ STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6)
+ STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10)
+ STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15)
+ STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21)
+ STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6)
+ STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10)
+ STEP(I, c, d, a, b, GET(6), 0xa3014314, 15)
+ STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21)
+ STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6)
+ STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10)
+ STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15)
+ STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21)
+
+ a += saved_a;
b += saved_b;
c += saved_c;
d += saved_d;
@@ -399,7 +393,7 @@ static void MD5_Init(MD5_CTX *ctx)
static void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
{
MD5_u32plus saved_lo;
- unsigned long used, available;
+ unsigned long used;
saved_lo = ctx->lo;
ctx->lo = (saved_lo + size) & 0x1fffffff;
@@ -410,7 +404,7 @@ static void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
used = saved_lo & 0x3f;
if(used) {
- available = 64 - used;
+ unsigned long available = 64 - used;
if(size < available) {
memcpy(&ctx->buffer[used], data, size);
@@ -486,22 +480,33 @@ static void MD5_Final(unsigned char *result, MD5_CTX *ctx)
const HMAC_params Curl_HMAC_MD5[] = {
{
- (HMAC_hinit_func) MD5_Init, /* Hash initialization function. */
- (HMAC_hupdate_func) MD5_Update, /* Hash update function. */
- (HMAC_hfinal_func) MD5_Final, /* Hash computation end function. */
- sizeof(MD5_CTX), /* Size of hash context structure. */
- 64, /* Maximum key length. */
- 16 /* Result size. */
+ /* Hash initialization function. */
+ CURLX_FUNCTION_CAST(HMAC_hinit_func, MD5_Init),
+ /* Hash update function. */
+ CURLX_FUNCTION_CAST(HMAC_hupdate_func, MD5_Update),
+ /* Hash computation end function. */
+ CURLX_FUNCTION_CAST(HMAC_hfinal_func, MD5_Final),
+ /* Size of hash context structure. */
+ sizeof(MD5_CTX),
+ /* Maximum key length. */
+ 64,
+ /* Result size. */
+ 16
}
};
const MD5_params Curl_DIGEST_MD5[] = {
{
- (Curl_MD5_init_func) MD5_Init, /* Digest initialization function */
- (Curl_MD5_update_func) MD5_Update, /* Digest update function */
- (Curl_MD5_final_func) MD5_Final, /* Digest computation end function */
- sizeof(MD5_CTX), /* Size of digest context struct */
- 16 /* Result size */
+ /* Digest initialization function */
+ CURLX_FUNCTION_CAST(Curl_MD5_init_func, MD5_Init),
+ /* Digest update function */
+ CURLX_FUNCTION_CAST(Curl_MD5_update_func, MD5_Update),
+ /* Digest computation end function */
+ CURLX_FUNCTION_CAST(Curl_MD5_final_func, MD5_Final),
+ /* Size of digest context struct */
+ sizeof(MD5_CTX),
+ /* Result size */
+ 16
}
};
@@ -522,7 +527,7 @@ MD5_context *Curl_MD5_init(const MD5_params *md5params)
MD5_context *ctxt;
/* Create MD5 context */
- ctxt = malloc(sizeof *ctxt);
+ ctxt = malloc(sizeof(*ctxt));
if(!ctxt)
return ctxt;
@@ -541,23 +546,23 @@ MD5_context *Curl_MD5_init(const MD5_params *md5params)
return ctxt;
}
-int Curl_MD5_update(MD5_context *context,
- const unsigned char *data,
- unsigned int len)
+CURLcode Curl_MD5_update(MD5_context *context,
+ const unsigned char *data,
+ unsigned int len)
{
(*context->md5_hash->md5_update_func)(context->md5_hashctx, data, len);
- return 0;
+ return CURLE_OK;
}
-int Curl_MD5_final(MD5_context *context, unsigned char *result)
+CURLcode Curl_MD5_final(MD5_context *context, unsigned char *result)
{
(*context->md5_hash->md5_final_func)(result, context->md5_hashctx);
free(context->md5_hashctx);
free(context);
- return 0;
+ return CURLE_OK;
}
#endif /* CURL_DISABLE_CRYPTO_AUTH */
diff --git a/Utilities/cmcurl/lib/memdebug.c b/Utilities/cmcurl/lib/memdebug.c
index 2b8808ab0..ede60094b 100644
--- a/Utilities/cmcurl/lib/memdebug.c
+++ b/Utilities/cmcurl/lib/memdebug.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -100,29 +100,29 @@ struct memdebug {
* Don't use these with multithreaded test programs!
*/
-#define logfile curl_debuglogfile
-FILE *curl_debuglogfile = NULL;
+FILE *curl_dbg_logfile = NULL;
static bool memlimit = FALSE; /* enable memory limit */
static long memsize = 0; /* set number of mallocs allowed */
/* this sets the log file name */
-void curl_memdebug(const char *logname)
+void curl_dbg_memdebug(const char *logname)
{
- if(!logfile) {
+ if(!curl_dbg_logfile) {
if(logname && *logname)
- logfile = fopen(logname, FOPEN_WRITETEXT);
+ curl_dbg_logfile = fopen(logname, FOPEN_WRITETEXT);
else
- logfile = stderr;
+ curl_dbg_logfile = stderr;
#ifdef MEMDEBUG_LOG_SYNC
/* Flush the log file after every line so the log isn't lost in a crash */
- setbuf(logfile, (char *)NULL);
+ if(curl_dbg_logfile)
+ setbuf(curl_dbg_logfile, (char *)NULL);
#endif
}
}
/* This function sets the number of malloc() calls that should return
successfully! */
-void curl_memlimit(long limit)
+void curl_dbg_memlimit(long limit)
{
if(!memlimit) {
memlimit = TRUE;
@@ -139,14 +139,14 @@ static bool countcheck(const char *func, int line, const char *source)
if(!memsize) {
if(source) {
/* log to file */
- curl_memlog("LIMIT %s:%d %s reached memlimit\n",
- source, line, func);
+ curl_dbg_log("LIMIT %s:%d %s reached memlimit\n",
+ source, line, func);
/* log to stderr also */
fprintf(stderr, "LIMIT %s:%d %s reached memlimit\n",
source, line, func);
- fflush(logfile); /* because it might crash now */
+ fflush(curl_dbg_logfile); /* because it might crash now */
}
- SET_ERRNO(ENOMEM);
+ errno = ENOMEM;
return TRUE; /* RETURN ERROR! */
}
else
@@ -158,7 +158,7 @@ static bool countcheck(const char *func, int line, const char *source)
return FALSE; /* allow this */
}
-void *curl_domalloc(size_t wantedsize, int line, const char *source)
+void *curl_dbg_malloc(size_t wantedsize, int line, const char *source)
{
struct memdebug *mem;
size_t size;
@@ -169,7 +169,7 @@ void *curl_domalloc(size_t wantedsize, int line, const char *source)
return NULL;
/* alloc at least 64 bytes */
- size = sizeof(struct memdebug)+wantedsize;
+ size = sizeof(struct memdebug) + wantedsize;
mem = (Curl_cmalloc)(size);
if(mem) {
@@ -179,15 +179,15 @@ void *curl_domalloc(size_t wantedsize, int line, const char *source)
}
if(source)
- curl_memlog("MEM %s:%d malloc(%zu) = %p\n",
- source, line, wantedsize,
- mem ? (void *)mem->mem : (void *)0);
+ curl_dbg_log("MEM %s:%d malloc(%zu) = %p\n",
+ source, line, wantedsize,
+ mem ? (void *)mem->mem : (void *)0);
return (mem ? mem->mem : NULL);
}
-void *curl_docalloc(size_t wanted_elements, size_t wanted_size,
- int line, const char *source)
+void *curl_dbg_calloc(size_t wanted_elements, size_t wanted_size,
+ int line, const char *source)
{
struct memdebug *mem;
size_t size, user_size;
@@ -207,14 +207,14 @@ void *curl_docalloc(size_t wanted_elements, size_t wanted_size,
mem->size = user_size;
if(source)
- curl_memlog("MEM %s:%d calloc(%zu,%zu) = %p\n",
- source, line, wanted_elements, wanted_size,
- mem ? (void *)mem->mem : (void *)0);
+ curl_dbg_log("MEM %s:%d calloc(%zu,%zu) = %p\n",
+ source, line, wanted_elements, wanted_size,
+ mem ? (void *)mem->mem : (void *)0);
return (mem ? mem->mem : NULL);
}
-char *curl_dostrdup(const char *str, int line, const char *source)
+char *curl_dbg_strdup(const char *str, int line, const char *source)
{
char *mem;
size_t len;
@@ -224,21 +224,21 @@ char *curl_dostrdup(const char *str, int line, const char *source)
if(countcheck("strdup", line, source))
return NULL;
- len=strlen(str)+1;
+ len = strlen(str) + 1;
- mem=curl_domalloc(len, 0, NULL); /* NULL prevents logging */
+ mem = curl_dbg_malloc(len, 0, NULL); /* NULL prevents logging */
if(mem)
memcpy(mem, str, len);
if(source)
- curl_memlog("MEM %s:%d strdup(%p) (%zu) = %p\n",
- source, line, (const void *)str, len, (const void *)mem);
+ curl_dbg_log("MEM %s:%d strdup(%p) (%zu) = %p\n",
+ source, line, (const void *)str, len, (const void *)mem);
return mem;
}
#if defined(WIN32) && defined(UNICODE)
-wchar_t *curl_dowcsdup(const wchar_t *str, int line, const char *source)
+wchar_t *curl_dbg_wcsdup(const wchar_t *str, int line, const char *source)
{
wchar_t *mem;
size_t wsiz, bsiz;
@@ -251,12 +251,12 @@ wchar_t *curl_dowcsdup(const wchar_t *str, int line, const char *source)
wsiz = wcslen(str) + 1;
bsiz = wsiz * sizeof(wchar_t);
- mem = curl_domalloc(bsiz, 0, NULL); /* NULL prevents logging */
+ mem = curl_dbg_malloc(bsiz, 0, NULL); /* NULL prevents logging */
if(mem)
memcpy(mem, str, bsiz);
if(source)
- curl_memlog("MEM %s:%d wcsdup(%p) (%zu) = %p\n",
+ curl_dbg_log("MEM %s:%d wcsdup(%p) (%zu) = %p\n",
source, line, (void *)str, bsiz, (void *)mem);
return mem;
@@ -265,12 +265,12 @@ wchar_t *curl_dowcsdup(const wchar_t *str, int line, const char *source)
/* We provide a realloc() that accepts a NULL as pointer, which then
performs a malloc(). In order to work with ares. */
-void *curl_dorealloc(void *ptr, size_t wantedsize,
- int line, const char *source)
+void *curl_dbg_realloc(void *ptr, size_t wantedsize,
+ int line, const char *source)
{
- struct memdebug *mem=NULL;
+ struct memdebug *mem = NULL;
- size_t size = sizeof(struct memdebug)+wantedsize;
+ size_t size = sizeof(struct memdebug) + wantedsize;
DEBUGASSERT(wantedsize != 0);
@@ -292,7 +292,7 @@ void *curl_dorealloc(void *ptr, size_t wantedsize,
mem = (Curl_crealloc)(mem, size);
if(source)
- curl_memlog("MEM %s:%d realloc(%p, %zu) = %p\n",
+ curl_dbg_log("MEM %s:%d realloc(%p, %zu) = %p\n",
source, line, (void *)ptr, wantedsize,
mem ? (void *)mem->mem : (void *)0);
@@ -304,11 +304,10 @@ void *curl_dorealloc(void *ptr, size_t wantedsize,
return NULL;
}
-void curl_dofree(void *ptr, int line, const char *source)
+void curl_dbg_free(void *ptr, int line, const char *source)
{
- struct memdebug *mem;
-
if(ptr) {
+ struct memdebug *mem;
#ifdef __INTEL_COMPILER
# pragma warning(push)
@@ -330,11 +329,11 @@ void curl_dofree(void *ptr, int line, const char *source)
}
if(source)
- curl_memlog("MEM %s:%d free(%p)\n", source, line, (void *)ptr);
+ curl_dbg_log("MEM %s:%d free(%p)\n", source, line, (void *)ptr);
}
-curl_socket_t curl_socket(int domain, int type, int protocol,
- int line, const char *source)
+curl_socket_t curl_dbg_socket(int domain, int type, int protocol,
+ int line, const char *source)
{
const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ?
"FD %s:%d socket() = %d\n" :
@@ -342,18 +341,52 @@ curl_socket_t curl_socket(int domain, int type, int protocol,
"FD %s:%d socket() = %ld\n" :
"FD %s:%d socket() = %zd\n";
- curl_socket_t sockfd = socket(domain, type, protocol);
+ curl_socket_t sockfd;
+
+ if(countcheck("socket", line, source))
+ return CURL_SOCKET_BAD;
+
+ sockfd = socket(domain, type, protocol);
if(source && (sockfd != CURL_SOCKET_BAD))
- curl_memlog(fmt, source, line, sockfd);
+ curl_dbg_log(fmt, source, line, sockfd);
return sockfd;
}
+SEND_TYPE_RETV curl_dbg_send(SEND_TYPE_ARG1 sockfd,
+ SEND_QUAL_ARG2 SEND_TYPE_ARG2 buf,
+ SEND_TYPE_ARG3 len, SEND_TYPE_ARG4 flags, int line,
+ const char *source)
+{
+ SEND_TYPE_RETV rc;
+ if(countcheck("send", line, source))
+ return -1;
+ rc = send(sockfd, buf, len, flags);
+ if(source)
+ curl_dbg_log("SEND %s:%d send(%lu) = %ld\n",
+ source, line, (unsigned long)len, (long)rc);
+ return rc;
+}
+
+RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd, RECV_TYPE_ARG2 buf,
+ RECV_TYPE_ARG3 len, RECV_TYPE_ARG4 flags, int line,
+ const char *source)
+{
+ RECV_TYPE_RETV rc;
+ if(countcheck("recv", line, source))
+ return -1;
+ rc = recv(sockfd, buf, len, flags);
+ if(source)
+ curl_dbg_log("RECV %s:%d recv(%lu) = %ld\n",
+ source, line, (unsigned long)len, (long)rc);
+ return rc;
+}
+
#ifdef HAVE_SOCKETPAIR
-int curl_socketpair(int domain, int type, int protocol,
- curl_socket_t socket_vector[2],
- int line, const char *source)
+int curl_dbg_socketpair(int domain, int type, int protocol,
+ curl_socket_t socket_vector[2],
+ int line, const char *source)
{
const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ?
"FD %s:%d socketpair() = %d %d\n" :
@@ -364,14 +397,14 @@ int curl_socketpair(int domain, int type, int protocol,
int res = socketpair(domain, type, protocol, socket_vector);
if(source && (0 == res))
- curl_memlog(fmt, source, line, socket_vector[0], socket_vector[1]);
+ curl_dbg_log(fmt, source, line, socket_vector[0], socket_vector[1]);
return res;
}
#endif
-curl_socket_t curl_accept(curl_socket_t s, void *saddr, void *saddrlen,
- int line, const char *source)
+curl_socket_t curl_dbg_accept(curl_socket_t s, void *saddr, void *saddrlen,
+ int line, const char *source)
{
const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ?
"FD %s:%d accept() = %d\n" :
@@ -385,13 +418,13 @@ curl_socket_t curl_accept(curl_socket_t s, void *saddr, void *saddrlen,
curl_socket_t sockfd = accept(s, addr, addrlen);
if(source && (sockfd != CURL_SOCKET_BAD))
- curl_memlog(fmt, source, line, sockfd);
+ curl_dbg_log(fmt, source, line, sockfd);
return sockfd;
}
/* separate function to allow libcurl to mark a "faked" close */
-void curl_mark_sclose(curl_socket_t sockfd, int line, const char *source)
+void curl_dbg_mark_sclose(curl_socket_t sockfd, int line, const char *source)
{
const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ?
"FD %s:%d sclose(%d)\n":
@@ -400,54 +433,40 @@ void curl_mark_sclose(curl_socket_t sockfd, int line, const char *source)
"FD %s:%d sclose(%zd)\n";
if(source)
- curl_memlog(fmt, source, line, sockfd);
+ curl_dbg_log(fmt, source, line, sockfd);
}
/* this is our own defined way to close sockets on *ALL* platforms */
-int curl_sclose(curl_socket_t sockfd, int line, const char *source)
+int curl_dbg_sclose(curl_socket_t sockfd, int line, const char *source)
{
- int res=sclose(sockfd);
- curl_mark_sclose(sockfd, line, source);
+ int res = sclose(sockfd);
+ curl_dbg_mark_sclose(sockfd, line, source);
return res;
}
-FILE *curl_fopen(const char *file, const char *mode,
- int line, const char *source)
+FILE *curl_dbg_fopen(const char *file, const char *mode,
+ int line, const char *source)
{
- FILE *res=fopen(file, mode);
+ FILE *res = fopen(file, mode);
if(source)
- curl_memlog("FILE %s:%d fopen(\"%s\",\"%s\") = %p\n",
+ curl_dbg_log("FILE %s:%d fopen(\"%s\",\"%s\") = %p\n",
source, line, file, mode, (void *)res);
return res;
}
-#ifdef HAVE_FDOPEN
-FILE *curl_fdopen(int filedes, const char *mode,
- int line, const char *source)
-{
- FILE *res=fdopen(filedes, mode);
-
- if(source)
- curl_memlog("FILE %s:%d fdopen(\"%d\",\"%s\") = %p\n",
- source, line, filedes, mode, (void *)res);
-
- return res;
-}
-#endif
-
-int curl_fclose(FILE *file, int line, const char *source)
+int curl_dbg_fclose(FILE *file, int line, const char *source)
{
int res;
DEBUGASSERT(file != NULL);
- res=fclose(file);
-
if(source)
- curl_memlog("FILE %s:%d fclose(%p)\n",
- source, line, (void *)file);
+ curl_dbg_log("FILE %s:%d fclose(%p)\n",
+ source, line, (void *)file);
+
+ res = fclose(file);
return res;
}
@@ -455,13 +474,13 @@ int curl_fclose(FILE *file, int line, const char *source)
#define LOGLINE_BUFSIZE 1024
/* this does the writing to the memory tracking log file */
-void curl_memlog(const char *format, ...)
+void curl_dbg_log(const char *format, ...)
{
char *buf;
int nchars;
va_list ap;
- if(!logfile)
+ if(!curl_dbg_logfile)
return;
buf = (Curl_cmalloc)(LOGLINE_BUFSIZE);
@@ -469,14 +488,14 @@ void curl_memlog(const char *format, ...)
return;
va_start(ap, format);
- nchars = vsnprintf(buf, LOGLINE_BUFSIZE, format, ap);
+ nchars = mvsnprintf(buf, LOGLINE_BUFSIZE, format, ap);
va_end(ap);
if(nchars > LOGLINE_BUFSIZE - 1)
nchars = LOGLINE_BUFSIZE - 1;
if(nchars > 0)
- fwrite(buf, 1, (size_t)nchars, logfile);
+ fwrite(buf, 1, (size_t)nchars, curl_dbg_logfile);
(Curl_cfree)(buf);
}
diff --git a/Utilities/cmcurl/lib/memdebug.h b/Utilities/cmcurl/lib/memdebug.h
index 835dab38c..5236f60fa 100644
--- a/Utilities/cmcurl/lib/memdebug.h
+++ b/Utilities/cmcurl/lib/memdebug.h
@@ -8,7 +8,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -30,84 +30,92 @@
#define CURL_MT_LOGFNAME_BUFSIZE 512
-#define logfile curl_debuglogfile
-
-extern FILE *logfile;
+extern FILE *curl_dbg_logfile;
/* memory functions */
-CURL_EXTERN void *curl_domalloc(size_t size, int line, const char *source);
-CURL_EXTERN void *curl_docalloc(size_t elements, size_t size, int line,
- const char *source);
-CURL_EXTERN void *curl_dorealloc(void *ptr, size_t size, int line,
- const char *source);
-CURL_EXTERN void curl_dofree(void *ptr, int line, const char *source);
-CURL_EXTERN char *curl_dostrdup(const char *str, int line, const char *source);
-#if defined(WIN32) && defined(UNICODE)
-CURL_EXTERN wchar_t *curl_dowcsdup(const wchar_t *str, int line,
+CURL_EXTERN void *curl_dbg_malloc(size_t size, int line, const char *source);
+CURL_EXTERN void *curl_dbg_calloc(size_t elements, size_t size, int line,
+ const char *source);
+CURL_EXTERN void *curl_dbg_realloc(void *ptr, size_t size, int line,
const char *source);
+CURL_EXTERN void curl_dbg_free(void *ptr, int line, const char *source);
+CURL_EXTERN char *curl_dbg_strdup(const char *str, int line, const char *src);
+#if defined(WIN32) && defined(UNICODE)
+CURL_EXTERN wchar_t *curl_dbg_wcsdup(const wchar_t *str, int line,
+ const char *source);
#endif
-CURL_EXTERN void curl_memdebug(const char *logname);
-CURL_EXTERN void curl_memlimit(long limit);
-CURL_EXTERN void curl_memlog(const char *format, ...);
+CURL_EXTERN void curl_dbg_memdebug(const char *logname);
+CURL_EXTERN void curl_dbg_memlimit(long limit);
+CURL_EXTERN void curl_dbg_log(const char *format, ...);
/* file descriptor manipulators */
-CURL_EXTERN curl_socket_t curl_socket(int domain, int type, int protocol,
- int line, const char *source);
-CURL_EXTERN void curl_mark_sclose(curl_socket_t sockfd,
- int line, const char *source);
-CURL_EXTERN int curl_sclose(curl_socket_t sockfd,
- int line, const char *source);
-CURL_EXTERN curl_socket_t curl_accept(curl_socket_t s, void *a, void *alen,
+CURL_EXTERN curl_socket_t curl_dbg_socket(int domain, int type, int protocol,
+ int line, const char *source);
+CURL_EXTERN void curl_dbg_mark_sclose(curl_socket_t sockfd,
int line, const char *source);
-#ifdef HAVE_SOCKETPAIR
-CURL_EXTERN int curl_socketpair(int domain, int type, int protocol,
- curl_socket_t socket_vector[2],
+CURL_EXTERN int curl_dbg_sclose(curl_socket_t sockfd,
int line, const char *source);
+CURL_EXTERN curl_socket_t curl_dbg_accept(curl_socket_t s, void *a, void *alen,
+ int line, const char *source);
+#ifdef HAVE_SOCKETPAIR
+CURL_EXTERN int curl_dbg_socketpair(int domain, int type, int protocol,
+ curl_socket_t socket_vector[2],
+ int line, const char *source);
#endif
+/* send/receive sockets */
+CURL_EXTERN SEND_TYPE_RETV curl_dbg_send(SEND_TYPE_ARG1 sockfd,
+ SEND_QUAL_ARG2 SEND_TYPE_ARG2 buf,
+ SEND_TYPE_ARG3 len,
+ SEND_TYPE_ARG4 flags, int line,
+ const char *source);
+CURL_EXTERN RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd,
+ RECV_TYPE_ARG2 buf,
+ RECV_TYPE_ARG3 len,
+ RECV_TYPE_ARG4 flags, int line,
+ const char *source);
+
/* FILE functions */
-CURL_EXTERN FILE *curl_fopen(const char *file, const char *mode, int line,
- const char *source);
-#ifdef HAVE_FDOPEN
-CURL_EXTERN FILE *curl_fdopen(int filedes, const char *mode, int line,
- const char *source);
-#endif
-CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source);
+CURL_EXTERN FILE *curl_dbg_fopen(const char *file, const char *mode, int line,
+ const char *source);
+CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
#ifndef MEMDEBUG_NODEFINES
/* Set this symbol on the command-line, recompile all lib-sources */
#undef strdup
-#define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
-#define malloc(size) curl_domalloc(size, __LINE__, __FILE__)
-#define calloc(nbelem,size) curl_docalloc(nbelem, size, __LINE__, __FILE__)
-#define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__)
-#define free(ptr) curl_dofree(ptr, __LINE__, __FILE__)
+#define strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
+#define malloc(size) curl_dbg_malloc(size, __LINE__, __FILE__)
+#define calloc(nbelem,size) curl_dbg_calloc(nbelem, size, __LINE__, __FILE__)
+#define realloc(ptr,size) curl_dbg_realloc(ptr, size, __LINE__, __FILE__)
+#define free(ptr) curl_dbg_free(ptr, __LINE__, __FILE__)
+#define send(a,b,c,d) curl_dbg_send(a,b,c,d, __LINE__, __FILE__)
+#define recv(a,b,c,d) curl_dbg_recv(a,b,c,d, __LINE__, __FILE__)
#ifdef WIN32
# ifdef UNICODE
# undef wcsdup
-# define wcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
+# define wcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
# undef _wcsdup
-# define _wcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
+# define _wcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
# undef _tcsdup
-# define _tcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
+# define _tcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
# else
# undef _tcsdup
-# define _tcsdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
+# define _tcsdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
# endif
#endif
#undef socket
#define socket(domain,type,protocol)\
- curl_socket(domain, type, protocol, __LINE__, __FILE__)
+ curl_dbg_socket(domain, type, protocol, __LINE__, __FILE__)
#undef accept /* for those with accept as a macro */
#define accept(sock,addr,len)\
- curl_accept(sock, addr, len, __LINE__, __FILE__)
+ curl_dbg_accept(sock, addr, len, __LINE__, __FILE__)
#ifdef HAVE_SOCKETPAIR
#define socketpair(domain,type,protocol,socket_vector)\
- curl_socketpair(domain, type, protocol, socket_vector, __LINE__, __FILE__)
+ curl_dbg_socketpair(domain, type, protocol, socket_vector, __LINE__, __FILE__)
#endif
#ifdef HAVE_GETADDRINFO
@@ -116,38 +124,31 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source);
our macro as for other platforms. Instead, we redefine the new name they
define getaddrinfo to become! */
#define ogetaddrinfo(host,serv,hint,res) \
- curl_dogetaddrinfo(host, serv, hint, res, __LINE__, __FILE__)
+ curl_dbg_getaddrinfo(host, serv, hint, res, __LINE__, __FILE__)
#else
#undef getaddrinfo
#define getaddrinfo(host,serv,hint,res) \
- curl_dogetaddrinfo(host, serv, hint, res, __LINE__, __FILE__)
+ curl_dbg_getaddrinfo(host, serv, hint, res, __LINE__, __FILE__)
#endif
#endif /* HAVE_GETADDRINFO */
-#ifdef HAVE_GETNAMEINFO
-#undef getnameinfo
-#define getnameinfo(sa,salen,host,hostlen,serv,servlen,flags) \
- curl_dogetnameinfo(sa, salen, host, hostlen, serv, servlen, flags, \
- __LINE__, __FILE__)
-#endif /* HAVE_GETNAMEINFO */
-
#ifdef HAVE_FREEADDRINFO
#undef freeaddrinfo
#define freeaddrinfo(data) \
- curl_dofreeaddrinfo(data, __LINE__, __FILE__)
+ curl_dbg_freeaddrinfo(data, __LINE__, __FILE__)
#endif /* HAVE_FREEADDRINFO */
/* sclose is probably already defined, redefine it! */
#undef sclose
-#define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
+#define sclose(sockfd) curl_dbg_sclose(sockfd,__LINE__,__FILE__)
-#define fake_sclose(sockfd) curl_mark_sclose(sockfd,__LINE__,__FILE__)
+#define fake_sclose(sockfd) curl_dbg_mark_sclose(sockfd,__LINE__,__FILE__)
#undef fopen
-#define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
+#define fopen(file,mode) curl_dbg_fopen(file,mode,__LINE__,__FILE__)
#undef fdopen
-#define fdopen(file,mode) curl_fdopen(file,mode,__LINE__,__FILE__)
-#define fclose(file) curl_fclose(file,__LINE__,__FILE__)
+#define fdopen(file,mode) curl_dbg_fdopen(file,mode,__LINE__,__FILE__)
+#define fclose(file) curl_dbg_fclose(file,__LINE__,__FILE__)
#endif /* MEMDEBUG_NODEFINES */
diff --git a/Utilities/cmcurl/lib/mime.c b/Utilities/cmcurl/lib/mime.c
new file mode 100644
index 000000000..2135f72c2
--- /dev/null
+++ b/Utilities/cmcurl/lib/mime.c
@@ -0,0 +1,1904 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#include <curl/curl.h>
+
+#include "mime.h"
+#include "non-ascii.h"
+#include "urldata.h"
+#include "sendf.h"
+
+#if (!defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_MIME)) || \
+ !defined(CURL_DISABLE_SMTP) || !defined(CURL_DISABLE_IMAP)
+
+#if defined(HAVE_LIBGEN_H) && defined(HAVE_BASENAME)
+#include <libgen.h>
+#endif
+
+#include "rand.h"
+#include "slist.h"
+#include "strcase.h"
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "memdebug.h"
+
+#ifdef WIN32
+# ifndef R_OK
+# define R_OK 4
+# endif
+#endif
+
+
+#define READ_ERROR ((size_t) -1)
+
+/* Encoders. */
+static size_t encoder_nop_read(char *buffer, size_t size, bool ateof,
+ curl_mimepart *part);
+static curl_off_t encoder_nop_size(curl_mimepart *part);
+static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof,
+ curl_mimepart *part);
+static size_t encoder_base64_read(char *buffer, size_t size, bool ateof,
+ curl_mimepart *part);
+static curl_off_t encoder_base64_size(curl_mimepart *part);
+static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
+ curl_mimepart *part);
+static curl_off_t encoder_qp_size(curl_mimepart *part);
+
+static const mime_encoder encoders[] = {
+ {"binary", encoder_nop_read, encoder_nop_size},
+ {"8bit", encoder_nop_read, encoder_nop_size},
+ {"7bit", encoder_7bit_read, encoder_nop_size},
+ {"base64", encoder_base64_read, encoder_base64_size},
+ {"quoted-printable", encoder_qp_read, encoder_qp_size},
+ {ZERO_NULL, ZERO_NULL, ZERO_NULL}
+};
+
+/* Base64 encoding table */
+static const char base64[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+/* Quoted-printable character class table.
+ *
+ * We cannot rely on ctype functions since quoted-printable input data
+ * is assumed to be ascii-compatible, even on non-ascii platforms. */
+#define QP_OK 1 /* Can be represented by itself. */
+#define QP_SP 2 /* Space or tab. */
+#define QP_CR 3 /* Carriage return. */
+#define QP_LF 4 /* Line-feed. */
+static const unsigned char qp_class[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 00 - 07 */
+ 0, QP_SP, QP_LF, 0, 0, QP_CR, 0, 0, /* 08 - 0F */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 10 - 17 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 18 - 1F */
+ QP_SP, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, /* 20 - 27 */
+ QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, /* 28 - 2F */
+ QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, /* 30 - 37 */
+ QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, 0 , QP_OK, QP_OK, /* 38 - 3F */
+ QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, /* 40 - 47 */
+ QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, /* 48 - 4F */
+ QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, /* 50 - 57 */
+ QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, /* 58 - 5F */
+ QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, /* 60 - 67 */
+ QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, /* 68 - 6F */
+ QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, /* 70 - 77 */
+ QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, QP_OK, 0, /* 78 - 7F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80 - 8F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 90 - 9F */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A0 - AF */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* B0 - BF */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* C0 - CF */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* D0 - DF */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* E0 - EF */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* F0 - FF */
+};
+
+
+/* Binary --> hexadecimal ASCII table. */
+static const char aschex[] =
+ "\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x41\x42\x43\x44\x45\x46";
+
+
+
+#ifndef __VMS
+#define filesize(name, stat_data) (stat_data.st_size)
+#define fopen_read fopen
+
+#else
+
+#include <fabdef.h>
+/*
+ * get_vms_file_size does what it takes to get the real size of the file
+ *
+ * For fixed files, find out the size of the EOF block and adjust.
+ *
+ * For all others, have to read the entire file in, discarding the contents.
+ * Most posted text files will be small, and binary files like zlib archives
+ * and CD/DVD images should be either a STREAM_LF format or a fixed format.
+ *
+ */
+curl_off_t VmsRealFileSize(const char *name,
+ const struct_stat *stat_buf)
+{
+ char buffer[8192];
+ curl_off_t count;
+ int ret_stat;
+ FILE * file;
+
+ file = fopen(name, FOPEN_READTEXT); /* VMS */
+ if(file == NULL)
+ return 0;
+
+ count = 0;
+ ret_stat = 1;
+ while(ret_stat > 0) {
+ ret_stat = fread(buffer, 1, sizeof(buffer), file);
+ if(ret_stat != 0)
+ count += ret_stat;
+ }
+ fclose(file);
+
+ return count;
+}
+
+/*
+ *
+ * VmsSpecialSize checks to see if the stat st_size can be trusted and
+ * if not to call a routine to get the correct size.
+ *
+ */
+static curl_off_t VmsSpecialSize(const char *name,
+ const struct_stat *stat_buf)
+{
+ switch(stat_buf->st_fab_rfm) {
+ case FAB$C_VAR:
+ case FAB$C_VFC:
+ return VmsRealFileSize(name, stat_buf);
+ break;
+ default:
+ return stat_buf->st_size;
+ }
+}
+
+#define filesize(name, stat_data) VmsSpecialSize(name, &stat_data)
+
+/*
+ * vmsfopenread
+ *
+ * For upload to work as expected on VMS, different optional
+ * parameters must be added to the fopen command based on
+ * record format of the file.
+ *
+ */
+static FILE * vmsfopenread(const char *file, const char *mode)
+{
+ struct_stat statbuf;
+ int result;
+
+ result = stat(file, &statbuf);
+
+ switch(statbuf.st_fab_rfm) {
+ case FAB$C_VAR:
+ case FAB$C_VFC:
+ case FAB$C_STMCR:
+ return fopen(file, FOPEN_READTEXT); /* VMS */
+ break;
+ default:
+ return fopen(file, FOPEN_READTEXT, "rfm=stmlf", "ctx=stm");
+ }
+}
+
+#define fopen_read vmsfopenread
+#endif
+
+
+#ifndef HAVE_BASENAME
+/*
+ (Quote from The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004
+ Edition)
+
+ The basename() function shall take the pathname pointed to by path and
+ return a pointer to the final component of the pathname, deleting any
+ trailing '/' characters.
+
+ If the string pointed to by path consists entirely of the '/' character,
+ basename() shall return a pointer to the string "/". If the string pointed
+ to by path is exactly "//", it is implementation-defined whether '/' or "//"
+ is returned.
+
+ If path is a null pointer or points to an empty string, basename() shall
+ return a pointer to the string ".".
+
+ The basename() function may modify the string pointed to by path, and may
+ return a pointer to static storage that may then be overwritten by a
+ subsequent call to basename().
+
+ The basename() function need not be reentrant. A function that is not
+ required to be reentrant is not required to be thread-safe.
+
+*/
+static char *Curl_basename(char *path)
+{
+ /* Ignore all the details above for now and make a quick and simple
+ implementation here */
+ char *s1;
+ char *s2;
+
+ s1 = strrchr(path, '/');
+ s2 = strrchr(path, '\\');
+
+ if(s1 && s2) {
+ path = (s1 > s2? s1 : s2) + 1;
+ }
+ else if(s1)
+ path = s1 + 1;
+ else if(s2)
+ path = s2 + 1;
+
+ return path;
+}
+
+#define basename(x) Curl_basename((x))
+#endif
+
+
+/* Set readback state. */
+static void mimesetstate(mime_state *state, enum mimestate tok, void *ptr)
+{
+ state->state = tok;
+ state->ptr = ptr;
+ state->offset = 0;
+}
+
+
+/* Escape header string into allocated memory. */
+static char *escape_string(const char *src)
+{
+ size_t bytecount = 0;
+ size_t i;
+ char *dst;
+
+ for(i = 0; src[i]; i++)
+ if(src[i] == '"' || src[i] == '\\')
+ bytecount++;
+
+ bytecount += i;
+ dst = malloc(bytecount + 1);
+ if(!dst)
+ return NULL;
+
+ for(i = 0; *src; src++) {
+ if(*src == '"' || *src == '\\')
+ dst[i++] = '\\';
+ dst[i++] = *src;
+ }
+
+ dst[i] = '\0';
+ return dst;
+}
+
+/* Check if header matches. */
+static char *match_header(struct curl_slist *hdr, const char *lbl, size_t len)
+{
+ char *value = NULL;
+
+ if(strncasecompare(hdr->data, lbl, len) && hdr->data[len] == ':')
+ for(value = hdr->data + len + 1; *value == ' '; value++)
+ ;
+ return value;
+}
+
+/* Get a header from an slist. */
+static char *search_header(struct curl_slist *hdrlist, const char *hdr)
+{
+ size_t len = strlen(hdr);
+ char *value = NULL;
+
+ for(; !value && hdrlist; hdrlist = hdrlist->next)
+ value = match_header(hdrlist, hdr, len);
+
+ return value;
+}
+
+static char *strippath(const char *fullfile)
+{
+ char *filename;
+ char *base;
+ filename = strdup(fullfile); /* duplicate since basename() may ruin the
+ buffer it works on */
+ if(!filename)
+ return NULL;
+ base = strdup(basename(filename));
+
+ free(filename); /* free temporary buffer */
+
+ return base; /* returns an allocated string or NULL ! */
+}
+
+/* Initialize data encoder state. */
+static void cleanup_encoder_state(mime_encoder_state *p)
+{
+ p->pos = 0;
+ p->bufbeg = 0;
+ p->bufend = 0;
+}
+
+
+/* Dummy encoder. This is used for 8bit and binary content encodings. */
+static size_t encoder_nop_read(char *buffer, size_t size, bool ateof,
+ curl_mimepart *part)
+{
+ mime_encoder_state *st = &part->encstate;
+ size_t insize = st->bufend - st->bufbeg;
+
+ (void) ateof;
+
+ if(size > insize)
+ size = insize;
+ if(size)
+ memcpy(buffer, st->buf, size);
+ st->bufbeg += size;
+ return size;
+}
+
+static curl_off_t encoder_nop_size(curl_mimepart *part)
+{
+ return part->datasize;
+}
+
+
+/* 7bit encoder: the encoder is just a data validity check. */
+static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof,
+ curl_mimepart *part)
+{
+ mime_encoder_state *st = &part->encstate;
+ size_t cursize = st->bufend - st->bufbeg;
+
+ (void) ateof;
+
+ if(size > cursize)
+ size = cursize;
+
+ for(cursize = 0; cursize < size; cursize++) {
+ *buffer = st->buf[st->bufbeg];
+ if(*buffer++ & 0x80)
+ return cursize? cursize: READ_ERROR;
+ st->bufbeg++;
+ }
+
+ return cursize;
+}
+
+
+/* Base64 content encoder. */
+static size_t encoder_base64_read(char *buffer, size_t size, bool ateof,
+ curl_mimepart *part)
+{
+ mime_encoder_state *st = &part->encstate;
+ size_t cursize = 0;
+ int i;
+ char *ptr = buffer;
+
+ while(st->bufbeg < st->bufend) {
+ /* Line full ? */
+ if(st->pos > MAX_ENCODED_LINE_LENGTH - 4) {
+ /* Yes, we need 2 characters for CRLF. */
+ if(size < 2)
+ break;
+ *ptr++ = '\r';
+ *ptr++ = '\n';
+ st->pos = 0;
+ cursize += 2;
+ size -= 2;
+ }
+
+ /* Be sure there is enough space and input data for a base64 group. */
+ if(size < 4 || st->bufend - st->bufbeg < 3)
+ break;
+
+ /* Encode three bytes as four characters. */
+ i = st->buf[st->bufbeg++] & 0xFF;
+ i = (i << 8) | (st->buf[st->bufbeg++] & 0xFF);
+ i = (i << 8) | (st->buf[st->bufbeg++] & 0xFF);
+ *ptr++ = base64[(i >> 18) & 0x3F];
+ *ptr++ = base64[(i >> 12) & 0x3F];
+ *ptr++ = base64[(i >> 6) & 0x3F];
+ *ptr++ = base64[i & 0x3F];
+ cursize += 4;
+ st->pos += 4;
+ size -= 4;
+ }
+
+ /* If at eof, we have to flush the buffered data. */
+ if(ateof && size >= 4) {
+ /* Buffered data size can only be 0, 1 or 2. */
+ ptr[2] = ptr[3] = '=';
+ i = 0;
+ switch(st->bufend - st->bufbeg) {
+ case 2:
+ i = (st->buf[st->bufbeg + 1] & 0xFF) << 8;
+ /* FALLTHROUGH */
+ case 1:
+ i |= (st->buf[st->bufbeg] & 0xFF) << 16;
+ ptr[0] = base64[(i >> 18) & 0x3F];
+ ptr[1] = base64[(i >> 12) & 0x3F];
+ if(++st->bufbeg != st->bufend) {
+ ptr[2] = base64[(i >> 6) & 0x3F];
+ st->bufbeg++;
+ }
+ cursize += 4;
+ st->pos += 4;
+ break;
+ }
+ }
+
+#ifdef CURL_DOES_CONVERSIONS
+ /* This is now textual data, Convert character codes. */
+ if(part->easy && cursize) {
+ CURLcode result = Curl_convert_to_network(part->easy, buffer, cursize);
+ if(result)
+ return READ_ERROR;
+ }
+#endif
+
+ return cursize;
+}
+
+static curl_off_t encoder_base64_size(curl_mimepart *part)
+{
+ curl_off_t size = part->datasize;
+
+ if(size <= 0)
+ return size; /* Unknown size or no data. */
+
+ /* Compute base64 character count. */
+ size = 4 * (1 + (size - 1) / 3);
+
+ /* Effective character count must include CRLFs. */
+ return size + 2 * ((size - 1) / MAX_ENCODED_LINE_LENGTH);
+}
+
+
+/* Quoted-printable lookahead.
+ *
+ * Check if a CRLF or end of data is in input buffer at current position + n.
+ * Return -1 if more data needed, 1 if CRLF or end of data, else 0.
+ */
+static int qp_lookahead_eol(mime_encoder_state *st, int ateof, size_t n)
+{
+ n += st->bufbeg;
+ if(n >= st->bufend && ateof)
+ return 1;
+ if(n + 2 > st->bufend)
+ return ateof? 0: -1;
+ if(qp_class[st->buf[n] & 0xFF] == QP_CR &&
+ qp_class[st->buf[n + 1] & 0xFF] == QP_LF)
+ return 1;
+ return 0;
+}
+
+/* Quoted-printable encoder. */
+static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
+ curl_mimepart *part)
+{
+ mime_encoder_state *st = &part->encstate;
+ char *ptr = buffer;
+ size_t cursize = 0;
+ int softlinebreak;
+ char buf[4];
+
+ /* On all platforms, input is supposed to be ASCII compatible: for this
+ reason, we use hexadecimal ASCII codes in this function rather than
+ character constants that can be interpreted as non-ascii on some
+ platforms. Preserve ASCII encoding on output too. */
+ while(st->bufbeg < st->bufend) {
+ size_t len = 1;
+ size_t consumed = 1;
+ int i = st->buf[st->bufbeg];
+ buf[0] = (char) i;
+ buf[1] = aschex[(i >> 4) & 0xF];
+ buf[2] = aschex[i & 0xF];
+
+ switch(qp_class[st->buf[st->bufbeg] & 0xFF]) {
+ case QP_OK: /* Not a special character. */
+ break;
+ case QP_SP: /* Space or tab. */
+ /* Spacing must be escaped if followed by CRLF. */
+ switch(qp_lookahead_eol(st, ateof, 1)) {
+ case -1: /* More input data needed. */
+ return cursize;
+ case 0: /* No encoding needed. */
+ break;
+ default: /* CRLF after space or tab. */
+ buf[0] = '\x3D'; /* '=' */
+ len = 3;
+ break;
+ }
+ break;
+ case QP_CR: /* Carriage return. */
+ /* If followed by a line-feed, output the CRLF pair.
+ Else escape it. */
+ switch(qp_lookahead_eol(st, ateof, 0)) {
+ case -1: /* Need more data. */
+ return cursize;
+ case 1: /* CRLF found. */
+ buf[len++] = '\x0A'; /* Append '\n'. */
+ consumed = 2;
+ break;
+ default: /* Not followed by LF: escape. */
+ buf[0] = '\x3D'; /* '=' */
+ len = 3;
+ break;
+ }
+ break;
+ default: /* Character must be escaped. */
+ buf[0] = '\x3D'; /* '=' */
+ len = 3;
+ break;
+ }
+
+ /* Be sure the encoded character fits within maximum line length. */
+ if(buf[len - 1] != '\x0A') { /* '\n' */
+ softlinebreak = st->pos + len > MAX_ENCODED_LINE_LENGTH;
+ if(!softlinebreak && st->pos + len == MAX_ENCODED_LINE_LENGTH) {
+ /* We may use the current line only if end of data or followed by
+ a CRLF. */
+ switch(qp_lookahead_eol(st, ateof, consumed)) {
+ case -1: /* Need more data. */
+ return cursize;
+ break;
+ case 0: /* Not followed by a CRLF. */
+ softlinebreak = 1;
+ break;
+ }
+ }
+ if(softlinebreak) {
+ strcpy(buf, "\x3D\x0D\x0A"); /* "=\r\n" */
+ len = 3;
+ consumed = 0;
+ }
+ }
+
+ /* If the output buffer would overflow, do not store. */
+ if(len > size)
+ break;
+
+ /* Append to output buffer. */
+ memcpy(ptr, buf, len);
+ cursize += len;
+ ptr += len;
+ size -= len;
+ st->pos += len;
+ if(buf[len - 1] == '\x0A') /* '\n' */
+ st->pos = 0;
+ st->bufbeg += consumed;
+ }
+
+ return cursize;
+}
+
+static curl_off_t encoder_qp_size(curl_mimepart *part)
+{
+ /* Determining the size can only be done by reading the data: unless the
+ data size is 0, we return it as unknown (-1). */
+ return part->datasize? -1: 0;
+}
+
+
+/* In-memory data callbacks. */
+/* Argument is a pointer to the mime part. */
+static size_t mime_mem_read(char *buffer, size_t size, size_t nitems,
+ void *instream)
+{
+ curl_mimepart *part = (curl_mimepart *) instream;
+ size_t sz = (size_t) part->datasize - part->state.offset;
+ (void) size; /* Always 1.*/
+
+ if(sz > nitems)
+ sz = nitems;
+
+ if(sz)
+ memcpy(buffer, (char *) &part->data[part->state.offset], sz);
+
+ part->state.offset += sz;
+ return sz;
+}
+
+static int mime_mem_seek(void *instream, curl_off_t offset, int whence)
+{
+ curl_mimepart *part = (curl_mimepart *) instream;
+
+ switch(whence) {
+ case SEEK_CUR:
+ offset += part->state.offset;
+ break;
+ case SEEK_END:
+ offset += part->datasize;
+ break;
+ }
+
+ if(offset < 0 || offset > part->datasize)
+ return CURL_SEEKFUNC_FAIL;
+
+ part->state.offset = (size_t) offset;
+ return CURL_SEEKFUNC_OK;
+}
+
+static void mime_mem_free(void *ptr)
+{
+ Curl_safefree(((curl_mimepart *) ptr)->data);
+}
+
+
+/* Named file callbacks. */
+/* Argument is a pointer to the mime part. */
+static int mime_open_file(curl_mimepart * part)
+{
+ /* Open a MIMEKIND_FILE part. */
+
+ if(part->fp)
+ return 0;
+ part->fp = fopen_read(part->data, "rb");
+ return part->fp? 0: -1;
+}
+
+static size_t mime_file_read(char *buffer, size_t size, size_t nitems,
+ void *instream)
+{
+ curl_mimepart *part = (curl_mimepart *) instream;
+
+ if(mime_open_file(part))
+ return READ_ERROR;
+
+ return fread(buffer, size, nitems, part->fp);
+}
+
+static int mime_file_seek(void *instream, curl_off_t offset, int whence)
+{
+ curl_mimepart *part = (curl_mimepart *) instream;
+
+ if(whence == SEEK_SET && !offset && !part->fp)
+ return CURL_SEEKFUNC_OK; /* Not open: implicitly already at BOF. */
+
+ if(mime_open_file(part))
+ return CURL_SEEKFUNC_FAIL;
+
+ return fseek(part->fp, (long) offset, whence)?
+ CURL_SEEKFUNC_CANTSEEK: CURL_SEEKFUNC_OK;
+}
+
+static void mime_file_free(void *ptr)
+{
+ curl_mimepart *part = (curl_mimepart *) ptr;
+
+ if(part->fp) {
+ fclose(part->fp);
+ part->fp = NULL;
+ }
+ Curl_safefree(part->data);
+ part->data = NULL;
+}
+
+
+/* Subparts callbacks. */
+/* Argument is a pointer to the mime structure. */
+
+/* Readback a byte string segment. */
+static size_t readback_bytes(mime_state *state,
+ char *buffer, size_t bufsize,
+ const char *bytes, size_t numbytes,
+ const char *trail)
+{
+ size_t sz;
+
+ if(numbytes > state->offset) {
+ sz = numbytes - state->offset;
+ bytes += state->offset;
+ }
+ else {
+ size_t tsz = strlen(trail);
+
+ sz = state->offset - numbytes;
+ if(sz >= tsz)
+ return 0;
+ bytes = trail + sz;
+ sz = tsz - sz;
+ }
+
+ if(sz > bufsize)
+ sz = bufsize;
+
+ memcpy(buffer, bytes, sz);
+ state->offset += sz;
+ return sz;
+}
+
+/* Read a non-encoded part content. */
+static size_t read_part_content(curl_mimepart *part,
+ char *buffer, size_t bufsize)
+{
+ size_t sz = 0;
+
+ if(part->readfunc)
+ sz = part->readfunc(buffer, 1, bufsize, part->arg);
+ return sz;
+}
+
+/* Read and encode part content. */
+static size_t read_encoded_part_content(curl_mimepart *part,
+ char *buffer, size_t bufsize)
+{
+ mime_encoder_state *st = &part->encstate;
+ size_t cursize = 0;
+ size_t sz;
+ bool ateof = FALSE;
+
+ while(bufsize) {
+ if(st->bufbeg < st->bufend || ateof) {
+ /* Encode buffered data. */
+ sz = part->encoder->encodefunc(buffer, bufsize, ateof, part);
+ switch(sz) {
+ case 0:
+ if(ateof)
+ return cursize;
+ break;
+ case CURL_READFUNC_ABORT:
+ case CURL_READFUNC_PAUSE:
+ case READ_ERROR:
+ return cursize? cursize: sz;
+ default:
+ cursize += sz;
+ buffer += sz;
+ bufsize -= sz;
+ continue;
+ }
+ }
+
+ /* We need more data in input buffer. */
+ if(st->bufbeg) {
+ size_t len = st->bufend - st->bufbeg;
+
+ if(len)
+ memmove(st->buf, st->buf + st->bufbeg, len);
+ st->bufbeg = 0;
+ st->bufend = len;
+ }
+ if(st->bufend >= sizeof(st->buf))
+ return cursize? cursize: READ_ERROR; /* Buffer full. */
+ sz = read_part_content(part, st->buf + st->bufend,
+ sizeof(st->buf) - st->bufend);
+ switch(sz) {
+ case 0:
+ ateof = TRUE;
+ break;
+ case CURL_READFUNC_ABORT:
+ case CURL_READFUNC_PAUSE:
+ case READ_ERROR:
+ return cursize? cursize: sz;
+ default:
+ st->bufend += sz;
+ break;
+ }
+ }
+
+ return cursize;
+}
+
+/* Readback a mime part. */
+static size_t readback_part(curl_mimepart *part,
+ char *buffer, size_t bufsize)
+{
+ size_t cursize = 0;
+#ifdef CURL_DOES_CONVERSIONS
+ char *convbuf = buffer;
+#endif
+
+ /* Readback from part. */
+
+ while(bufsize) {
+ size_t sz = 0;
+ struct curl_slist *hdr = (struct curl_slist *) part->state.ptr;
+ switch(part->state.state) {
+ case MIMESTATE_BEGIN:
+ mimesetstate(&part->state,
+ (part->flags & MIME_BODY_ONLY)?
+ MIMESTATE_BODY: MIMESTATE_CURLHEADERS,
+ part->curlheaders);
+ break;
+ case MIMESTATE_USERHEADERS:
+ if(!hdr) {
+ mimesetstate(&part->state, MIMESTATE_EOH, NULL);
+ break;
+ }
+ if(match_header(hdr, "Content-Type", 12)) {
+ mimesetstate(&part->state, MIMESTATE_USERHEADERS, hdr->next);
+ break;
+ }
+ /* FALLTHROUGH */
+ case MIMESTATE_CURLHEADERS:
+ if(!hdr)
+ mimesetstate(&part->state, MIMESTATE_USERHEADERS, part->userheaders);
+ else {
+ sz = readback_bytes(&part->state, buffer, bufsize,
+ hdr->data, strlen(hdr->data), "\r\n");
+ if(!sz)
+ mimesetstate(&part->state, part->state.state, hdr->next);
+ }
+ break;
+ case MIMESTATE_EOH:
+ sz = readback_bytes(&part->state, buffer, bufsize, "\r\n", 2, "");
+ if(!sz)
+ mimesetstate(&part->state, MIMESTATE_BODY, NULL);
+ break;
+ case MIMESTATE_BODY:
+#ifdef CURL_DOES_CONVERSIONS
+ if(part->easy && convbuf < buffer) {
+ CURLcode result = Curl_convert_to_network(part->easy, convbuf,
+ buffer - convbuf);
+ if(result)
+ return READ_ERROR;
+ convbuf = buffer;
+ }
+#endif
+ cleanup_encoder_state(&part->encstate);
+ mimesetstate(&part->state, MIMESTATE_CONTENT, NULL);
+ break;
+ case MIMESTATE_CONTENT:
+ if(part->encoder)
+ sz = read_encoded_part_content(part, buffer, bufsize);
+ else
+ sz = read_part_content(part, buffer, bufsize);
+ switch(sz) {
+ case 0:
+ mimesetstate(&part->state, MIMESTATE_END, NULL);
+ /* Try sparing open file descriptors. */
+ if(part->kind == MIMEKIND_FILE && part->fp) {
+ fclose(part->fp);
+ part->fp = NULL;
+ }
+ /* FALLTHROUGH */
+ case CURL_READFUNC_ABORT:
+ case CURL_READFUNC_PAUSE:
+ case READ_ERROR:
+ return cursize? cursize: sz;
+ }
+ break;
+ case MIMESTATE_END:
+ return cursize;
+ default:
+ break; /* Other values not in part state. */
+ }
+
+ /* Bump buffer and counters according to read size. */
+ cursize += sz;
+ buffer += sz;
+ bufsize -= sz;
+ }
+
+#ifdef CURL_DOES_CONVERSIONS
+ if(part->easy && convbuf < buffer &&
+ part->state.state < MIMESTATE_BODY) {
+ CURLcode result = Curl_convert_to_network(part->easy, convbuf,
+ buffer - convbuf);
+ if(result)
+ return READ_ERROR;
+ }
+#endif
+
+ return cursize;
+}
+
+/* Readback from mime. */
+static size_t mime_subparts_read(char *buffer, size_t size, size_t nitems,
+ void *instream)
+{
+ curl_mime *mime = (curl_mime *) instream;
+ size_t cursize = 0;
+#ifdef CURL_DOES_CONVERSIONS
+ char *convbuf = buffer;
+#endif
+
+ (void) size; /* Always 1. */
+
+ while(nitems) {
+ size_t sz = 0;
+ curl_mimepart *part = mime->state.ptr;
+ switch(mime->state.state) {
+ case MIMESTATE_BEGIN:
+ case MIMESTATE_BODY:
+#ifdef CURL_DOES_CONVERSIONS
+ convbuf = buffer;
+#endif
+ mimesetstate(&mime->state, MIMESTATE_BOUNDARY1, mime->firstpart);
+ /* The first boundary always follows the header termination empty line,
+ so is always preceded by a CRLK. We can then spare 2 characters
+ by skipping the leading CRLF in boundary. */
+ mime->state.offset += 2;
+ break;
+ case MIMESTATE_BOUNDARY1:
+ sz = readback_bytes(&mime->state, buffer, nitems, "\r\n--", 4, "");
+ if(!sz)
+ mimesetstate(&mime->state, MIMESTATE_BOUNDARY2, part);
+ break;
+ case MIMESTATE_BOUNDARY2:
+ sz = readback_bytes(&mime->state, buffer, nitems, mime->boundary,
+ strlen(mime->boundary), part? "\r\n": "--\r\n");
+ if(!sz) {
+#ifdef CURL_DOES_CONVERSIONS
+ if(mime->easy && convbuf < buffer) {
+ CURLcode result = Curl_convert_to_network(mime->easy, convbuf,
+ buffer - convbuf);
+ if(result)
+ return READ_ERROR;
+ convbuf = buffer;
+ }
+#endif
+ mimesetstate(&mime->state, MIMESTATE_CONTENT, part);
+ }
+ break;
+ case MIMESTATE_CONTENT:
+ if(!part) {
+ mimesetstate(&mime->state, MIMESTATE_END, NULL);
+ break;
+ }
+ sz = readback_part(part, buffer, nitems);
+ switch(sz) {
+ case CURL_READFUNC_ABORT:
+ case CURL_READFUNC_PAUSE:
+ case READ_ERROR:
+ return cursize? cursize: sz;
+ case 0:
+#ifdef CURL_DOES_CONVERSIONS
+ convbuf = buffer;
+#endif
+ mimesetstate(&mime->state, MIMESTATE_BOUNDARY1, part->nextpart);
+ break;
+ }
+ break;
+ case MIMESTATE_END:
+ return cursize;
+ default:
+ break; /* other values not used in mime state. */
+ }
+
+ /* Bump buffer and counters according to read size. */
+ cursize += sz;
+ buffer += sz;
+ nitems -= sz;
+ }
+
+#ifdef CURL_DOES_CONVERSIONS
+ if(mime->easy && convbuf < buffer &&
+ mime->state.state <= MIMESTATE_CONTENT) {
+ CURLcode result = Curl_convert_to_network(mime->easy, convbuf,
+ buffer - convbuf);
+ if(result)
+ return READ_ERROR;
+ }
+#endif
+
+ return cursize;
+}
+
+static int mime_part_rewind(curl_mimepart *part)
+{
+ int res = CURL_SEEKFUNC_OK;
+ enum mimestate targetstate = MIMESTATE_BEGIN;
+
+ if(part->flags & MIME_BODY_ONLY)
+ targetstate = MIMESTATE_BODY;
+ cleanup_encoder_state(&part->encstate);
+ if(part->state.state > targetstate) {
+ res = CURL_SEEKFUNC_CANTSEEK;
+ if(part->seekfunc) {
+ res = part->seekfunc(part->arg, (curl_off_t) 0, SEEK_SET);
+ switch(res) {
+ case CURL_SEEKFUNC_OK:
+ case CURL_SEEKFUNC_FAIL:
+ case CURL_SEEKFUNC_CANTSEEK:
+ break;
+ case -1: /* For fseek() error. */
+ res = CURL_SEEKFUNC_CANTSEEK;
+ break;
+ default:
+ res = CURL_SEEKFUNC_FAIL;
+ break;
+ }
+ }
+ }
+
+ if(res == CURL_SEEKFUNC_OK)
+ mimesetstate(&part->state, targetstate, NULL);
+
+ return res;
+}
+
+static int mime_subparts_seek(void *instream, curl_off_t offset, int whence)
+{
+ curl_mime *mime = (curl_mime *) instream;
+ curl_mimepart *part;
+ int result = CURL_SEEKFUNC_OK;
+
+ if(whence != SEEK_SET || offset)
+ return CURL_SEEKFUNC_CANTSEEK; /* Only support full rewind. */
+
+ if(mime->state.state == MIMESTATE_BEGIN)
+ return CURL_SEEKFUNC_OK; /* Already rewound. */
+
+ for(part = mime->firstpart; part; part = part->nextpart) {
+ int res = mime_part_rewind(part);
+ if(res != CURL_SEEKFUNC_OK)
+ result = res;
+ }
+
+ if(result == CURL_SEEKFUNC_OK)
+ mimesetstate(&mime->state, MIMESTATE_BEGIN, NULL);
+
+ return result;
+}
+
+/* Release part content. */
+static void cleanup_part_content(curl_mimepart *part)
+{
+ if(part->freefunc)
+ part->freefunc(part->arg);
+
+ part->readfunc = NULL;
+ part->seekfunc = NULL;
+ part->freefunc = NULL;
+ part->arg = (void *) part; /* Defaults to part itself. */
+ part->data = NULL;
+ part->fp = NULL;
+ part->datasize = (curl_off_t) 0; /* No size yet. */
+ cleanup_encoder_state(&part->encstate);
+ part->kind = MIMEKIND_NONE;
+}
+
+static void mime_subparts_free(void *ptr)
+{
+ curl_mime *mime = (curl_mime *) ptr;
+
+ if(mime && mime->parent) {
+ mime->parent->freefunc = NULL; /* Be sure we won't be called again. */
+ cleanup_part_content(mime->parent); /* Avoid dangling pointer in part. */
+ }
+ curl_mime_free(mime);
+}
+
+/* Do not free subparts: unbind them. This is used for the top level only. */
+static void mime_subparts_unbind(void *ptr)
+{
+ curl_mime *mime = (curl_mime *) ptr;
+
+ if(mime && mime->parent) {
+ mime->parent->freefunc = NULL; /* Be sure we won't be called again. */
+ cleanup_part_content(mime->parent); /* Avoid dangling pointer in part. */
+ mime->parent = NULL;
+ }
+}
+
+
+void Curl_mime_cleanpart(curl_mimepart *part)
+{
+ cleanup_part_content(part);
+ curl_slist_free_all(part->curlheaders);
+ if(part->flags & MIME_USERHEADERS_OWNER)
+ curl_slist_free_all(part->userheaders);
+ Curl_safefree(part->mimetype);
+ Curl_safefree(part->name);
+ Curl_safefree(part->filename);
+ Curl_mime_initpart(part, part->easy);
+}
+
+/* Recursively delete a mime handle and its parts. */
+void curl_mime_free(curl_mime *mime)
+{
+ curl_mimepart *part;
+
+ if(mime) {
+ mime_subparts_unbind(mime); /* Be sure it's not referenced anymore. */
+ while(mime->firstpart) {
+ part = mime->firstpart;
+ mime->firstpart = part->nextpart;
+ Curl_mime_cleanpart(part);
+ free(part);
+ }
+ free(mime);
+ }
+}
+
+CURLcode Curl_mime_duppart(curl_mimepart *dst, const curl_mimepart *src)
+{
+ curl_mime *mime;
+ curl_mimepart *d;
+ const curl_mimepart *s;
+ CURLcode res = CURLE_OK;
+
+ /* Duplicate content. */
+ switch(src->kind) {
+ case MIMEKIND_NONE:
+ break;
+ case MIMEKIND_DATA:
+ res = curl_mime_data(dst, src->data, (size_t) src->datasize);
+ break;
+ case MIMEKIND_FILE:
+ res = curl_mime_filedata(dst, src->data);
+ /* Do not abort duplication if file is not readable. */
+ if(res == CURLE_READ_ERROR)
+ res = CURLE_OK;
+ break;
+ case MIMEKIND_CALLBACK:
+ res = curl_mime_data_cb(dst, src->datasize, src->readfunc,
+ src->seekfunc, src->freefunc, src->arg);
+ break;
+ case MIMEKIND_MULTIPART:
+ /* No one knows about the cloned subparts, thus always attach ownership
+ to the part. */
+ mime = curl_mime_init(dst->easy);
+ res = mime? curl_mime_subparts(dst, mime): CURLE_OUT_OF_MEMORY;
+
+ /* Duplicate subparts. */
+ for(s = ((curl_mime *) src->arg)->firstpart; !res && s; s = s->nextpart) {
+ d = curl_mime_addpart(mime);
+ res = d? Curl_mime_duppart(d, s): CURLE_OUT_OF_MEMORY;
+ }
+ break;
+ default: /* Invalid kind: should not occur. */
+ res = CURLE_BAD_FUNCTION_ARGUMENT; /* Internal error? */
+ break;
+ }
+
+ /* Duplicate headers. */
+ if(!res && src->userheaders) {
+ struct curl_slist *hdrs = Curl_slist_duplicate(src->userheaders);
+
+ if(!hdrs)
+ res = CURLE_OUT_OF_MEMORY;
+ else {
+ /* No one but this procedure knows about the new header list,
+ so always take ownership. */
+ res = curl_mime_headers(dst, hdrs, TRUE);
+ if(res)
+ curl_slist_free_all(hdrs);
+ }
+ }
+
+ /* Duplicate other fields. */
+ if(dst != NULL)
+ dst->encoder = src->encoder;
+ else
+ res = CURLE_WRITE_ERROR;
+ if(!res)
+ res = curl_mime_type(dst, src->mimetype);
+ if(!res)
+ res = curl_mime_name(dst, src->name);
+ if(!res)
+ res = curl_mime_filename(dst, src->filename);
+
+ /* If an error occurred, rollback. */
+ if(res && dst)
+ Curl_mime_cleanpart(dst);
+
+ return res;
+}
+
+/*
+ * Mime build functions.
+ */
+
+/* Create a mime handle. */
+curl_mime *curl_mime_init(struct Curl_easy *easy)
+{
+ curl_mime *mime;
+
+ mime = (curl_mime *) malloc(sizeof(*mime));
+
+ if(mime) {
+ mime->easy = easy;
+ mime->parent = NULL;
+ mime->firstpart = NULL;
+ mime->lastpart = NULL;
+
+ memset(mime->boundary, '-', 24);
+ if(Curl_rand_hex(easy, (unsigned char *) &mime->boundary[24],
+ MIME_RAND_BOUNDARY_CHARS + 1)) {
+ /* failed to get random separator, bail out */
+ free(mime);
+ return NULL;
+ }
+ mimesetstate(&mime->state, MIMESTATE_BEGIN, NULL);
+ }
+
+ return mime;
+}
+
+/* Initialize a mime part. */
+void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy)
+{
+ memset((char *) part, 0, sizeof(*part));
+ part->easy = easy;
+ mimesetstate(&part->state, MIMESTATE_BEGIN, NULL);
+}
+
+/* Create a mime part and append it to a mime handle's part list. */
+curl_mimepart *curl_mime_addpart(curl_mime *mime)
+{
+ curl_mimepart *part;
+
+ if(!mime)
+ return NULL;
+
+ part = (curl_mimepart *) malloc(sizeof(*part));
+
+ if(part) {
+ Curl_mime_initpart(part, mime->easy);
+ part->parent = mime;
+
+ if(mime->lastpart)
+ mime->lastpart->nextpart = part;
+ else
+ mime->firstpart = part;
+
+ mime->lastpart = part;
+ }
+
+ return part;
+}
+
+/* Set mime part name. */
+CURLcode curl_mime_name(curl_mimepart *part, const char *name)
+{
+ if(!part)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ Curl_safefree(part->name);
+ part->name = NULL;
+
+ if(name) {
+ part->name = strdup(name);
+ if(!part->name)
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ return CURLE_OK;
+}
+
+/* Set mime part remote file name. */
+CURLcode curl_mime_filename(curl_mimepart *part, const char *filename)
+{
+ if(!part)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ Curl_safefree(part->filename);
+ part->filename = NULL;
+
+ if(filename) {
+ part->filename = strdup(filename);
+ if(!part->filename)
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ return CURLE_OK;
+}
+
+/* Set mime part content from memory data. */
+CURLcode curl_mime_data(curl_mimepart *part,
+ const char *data, size_t datasize)
+{
+ if(!part)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ cleanup_part_content(part);
+
+ if(data) {
+ if(datasize == CURL_ZERO_TERMINATED)
+ datasize = strlen(data);
+
+ part->data = malloc(datasize + 1);
+ if(!part->data)
+ return CURLE_OUT_OF_MEMORY;
+
+ part->datasize = datasize;
+
+ if(datasize)
+ memcpy(part->data, data, datasize);
+ part->data[datasize] = '\0'; /* Set a nul terminator as sentinel. */
+
+ part->readfunc = mime_mem_read;
+ part->seekfunc = mime_mem_seek;
+ part->freefunc = mime_mem_free;
+ part->kind = MIMEKIND_DATA;
+ }
+
+ return CURLE_OK;
+}
+
+/* Set mime part content from named local file. */
+CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename)
+{
+ CURLcode result = CURLE_OK;
+
+ if(!part)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ cleanup_part_content(part);
+
+ if(filename) {
+ char *base;
+ struct_stat sbuf;
+
+ if(stat(filename, &sbuf) || access(filename, R_OK))
+ result = CURLE_READ_ERROR;
+
+ part->data = strdup(filename);
+ if(!part->data)
+ result = CURLE_OUT_OF_MEMORY;
+
+ part->datasize = -1;
+ if(!result && S_ISREG(sbuf.st_mode)) {
+ part->datasize = filesize(filename, sbuf);
+ part->seekfunc = mime_file_seek;
+ }
+
+ part->readfunc = mime_file_read;
+ part->freefunc = mime_file_free;
+ part->kind = MIMEKIND_FILE;
+
+ /* As a side effect, set the filename to the current file's base name.
+ It is possible to withdraw this by explicitly calling
+ curl_mime_filename() with a NULL filename argument after the current
+ call. */
+ base = strippath(filename);
+ if(!base)
+ result = CURLE_OUT_OF_MEMORY;
+ else {
+ CURLcode res = curl_mime_filename(part, base);
+
+ if(res)
+ result = res;
+ free(base);
+ }
+ }
+ return result;
+}
+
+/* Set mime part type. */
+CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype)
+{
+ if(!part)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ Curl_safefree(part->mimetype);
+ part->mimetype = NULL;
+
+ if(mimetype) {
+ part->mimetype = strdup(mimetype);
+ if(!part->mimetype)
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ return CURLE_OK;
+}
+
+/* Set mime data transfer encoder. */
+CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding)
+{
+ CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT;
+ const mime_encoder *mep;
+
+ if(!part)
+ return result;
+
+ part->encoder = NULL;
+
+ if(!encoding)
+ return CURLE_OK; /* Removing current encoder. */
+
+ for(mep = encoders; mep->name; mep++)
+ if(strcasecompare(encoding, mep->name)) {
+ part->encoder = mep;
+ result = CURLE_OK;
+ }
+
+ return result;
+}
+
+/* Set mime part headers. */
+CURLcode curl_mime_headers(curl_mimepart *part,
+ struct curl_slist *headers, int take_ownership)
+{
+ if(!part)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ if(part->flags & MIME_USERHEADERS_OWNER) {
+ if(part->userheaders != headers) /* Allow setting twice the same list. */
+ curl_slist_free_all(part->userheaders);
+ part->flags &= ~MIME_USERHEADERS_OWNER;
+ }
+ part->userheaders = headers;
+ if(headers && take_ownership)
+ part->flags |= MIME_USERHEADERS_OWNER;
+ return CURLE_OK;
+}
+
+/* Set mime part content from callback. */
+CURLcode curl_mime_data_cb(curl_mimepart *part, curl_off_t datasize,
+ curl_read_callback readfunc,
+ curl_seek_callback seekfunc,
+ curl_free_callback freefunc, void *arg)
+{
+ if(!part)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ cleanup_part_content(part);
+
+ if(readfunc) {
+ part->readfunc = readfunc;
+ part->seekfunc = seekfunc;
+ part->freefunc = freefunc;
+ part->arg = arg;
+ part->datasize = datasize;
+ part->kind = MIMEKIND_CALLBACK;
+ }
+
+ return CURLE_OK;
+}
+
+/* Set mime part content from subparts. */
+CURLcode Curl_mime_set_subparts(curl_mimepart *part,
+ curl_mime *subparts, int take_ownership)
+{
+ curl_mime *root;
+
+ if(!part)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ /* Accept setting twice the same subparts. */
+ if(part->kind == MIMEKIND_MULTIPART && part->arg == subparts)
+ return CURLE_OK;
+
+ cleanup_part_content(part);
+
+ if(subparts) {
+ /* Must belong to the same data handle. */
+ if(part->easy && subparts->easy && part->easy != subparts->easy)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ /* Should not have been attached already. */
+ if(subparts->parent)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ /* Should not be the part's root. */
+ root = part->parent;
+ if(root) {
+ while(root->parent && root->parent->parent)
+ root = root->parent->parent;
+ if(subparts == root) {
+ if(part->easy)
+ failf(part->easy, "Can't add itself as a subpart!");
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ }
+ }
+
+ subparts->parent = part;
+ part->readfunc = mime_subparts_read;
+ part->seekfunc = mime_subparts_seek;
+ part->freefunc = take_ownership? mime_subparts_free: mime_subparts_unbind;
+ part->arg = subparts;
+ part->datasize = -1;
+ part->kind = MIMEKIND_MULTIPART;
+ }
+
+ return CURLE_OK;
+}
+
+CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts)
+{
+ return Curl_mime_set_subparts(part, subparts, TRUE);
+}
+
+
+/* Readback from top mime. */
+/* Argument is the dummy top part. */
+size_t Curl_mime_read(char *buffer, size_t size, size_t nitems, void *instream)
+{
+ curl_mimepart *part = (curl_mimepart *) instream;
+
+ (void) size; /* Always 1. */
+ return readback_part(part, buffer, nitems);
+}
+
+/* Rewind mime stream. */
+CURLcode Curl_mime_rewind(curl_mimepart *part)
+{
+ return mime_part_rewind(part) == CURL_SEEKFUNC_OK?
+ CURLE_OK: CURLE_SEND_FAIL_REWIND;
+}
+
+/* Compute header list size. */
+static size_t slist_size(struct curl_slist *s,
+ size_t overhead, const char *skip)
+{
+ size_t size = 0;
+ size_t skiplen = skip? strlen(skip): 0;
+
+ for(; s; s = s->next)
+ if(!skip || !match_header(s, skip, skiplen))
+ size += strlen(s->data) + overhead;
+ return size;
+}
+
+/* Get/compute multipart size. */
+static curl_off_t multipart_size(curl_mime *mime)
+{
+ curl_off_t size;
+ size_t boundarysize;
+ curl_mimepart *part;
+
+ if(!mime)
+ return 0; /* Not present -> empty. */
+
+ boundarysize = 4 + strlen(mime->boundary) + 2;
+ size = boundarysize; /* Final boundary - CRLF after headers. */
+
+ for(part = mime->firstpart; part; part = part->nextpart) {
+ curl_off_t sz = Curl_mime_size(part);
+
+ if(sz < 0)
+ size = sz;
+
+ if(size >= 0)
+ size += boundarysize + sz;
+ }
+
+ return size;
+}
+
+/* Get/compute mime size. */
+curl_off_t Curl_mime_size(curl_mimepart *part)
+{
+ curl_off_t size;
+
+ if(part->kind == MIMEKIND_MULTIPART)
+ part->datasize = multipart_size(part->arg);
+
+ size = part->datasize;
+
+ if(part->encoder)
+ size = part->encoder->sizefunc(part);
+
+ if(size >= 0 && !(part->flags & MIME_BODY_ONLY)) {
+ /* Compute total part size. */
+ size += slist_size(part->curlheaders, 2, NULL);
+ size += slist_size(part->userheaders, 2, "Content-Type");
+ size += 2; /* CRLF after headers. */
+ }
+ return size;
+}
+
+/* Add a header. */
+/* VARARGS2 */
+CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...)
+{
+ struct curl_slist *hdr = NULL;
+ char *s = NULL;
+ va_list ap;
+
+ va_start(ap, fmt);
+ s = curl_mvaprintf(fmt, ap);
+ va_end(ap);
+
+ if(s) {
+ hdr = Curl_slist_append_nodup(*slp, s);
+ if(hdr)
+ *slp = hdr;
+ else
+ free(s);
+ }
+
+ return hdr? CURLE_OK: CURLE_OUT_OF_MEMORY;
+}
+
+/* Add a content type header. */
+static CURLcode add_content_type(struct curl_slist **slp,
+ const char *type, const char *boundary)
+{
+ return Curl_mime_add_header(slp, "Content-Type: %s%s%s", type,
+ boundary? "; boundary=": "",
+ boundary? boundary: "");
+}
+
+const char *Curl_mime_contenttype(const char *filename)
+{
+ /*
+ * If no content type was specified, we scan through a few well-known
+ * extensions and pick the first we match!
+ */
+ struct ContentType {
+ const char *extension;
+ const char *type;
+ };
+ static const struct ContentType ctts[] = {
+ {".gif", "image/gif"},
+ {".jpg", "image/jpeg"},
+ {".jpeg", "image/jpeg"},
+ {".png", "image/png"},
+ {".svg", "image/svg+xml"},
+ {".txt", "text/plain"},
+ {".htm", "text/html"},
+ {".html", "text/html"},
+ {".pdf", "application/pdf"},
+ {".xml", "application/xml"}
+ };
+
+ if(filename) {
+ size_t len1 = strlen(filename);
+ const char *nameend = filename + len1;
+ unsigned int i;
+
+ for(i = 0; i < sizeof(ctts) / sizeof(ctts[0]); i++) {
+ size_t len2 = strlen(ctts[i].extension);
+
+ if(len1 >= len2 && strcasecompare(nameend - len2, ctts[i].extension))
+ return ctts[i].type;
+ }
+ }
+ return NULL;
+}
+
+CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
+ const char *contenttype,
+ const char *disposition,
+ enum mimestrategy strategy)
+{
+ curl_mime *mime = NULL;
+ const char *boundary = NULL;
+ char *customct;
+ const char *cte = NULL;
+ CURLcode ret = CURLE_OK;
+
+ /* Get rid of previously prepared headers. */
+ curl_slist_free_all(part->curlheaders);
+ part->curlheaders = NULL;
+
+ /* Be sure we won't access old headers later. */
+ if(part->state.state == MIMESTATE_CURLHEADERS)
+ mimesetstate(&part->state, MIMESTATE_CURLHEADERS, NULL);
+
+ /* Check if content type is specified. */
+ customct = part->mimetype;
+ if(!customct)
+ customct = search_header(part->userheaders, "Content-Type");
+ if(customct)
+ contenttype = customct;
+
+ /* If content type is not specified, try to determine it. */
+ if(!contenttype) {
+ switch(part->kind) {
+ case MIMEKIND_MULTIPART:
+ contenttype = MULTIPART_CONTENTTYPE_DEFAULT;
+ break;
+ case MIMEKIND_FILE:
+ contenttype = Curl_mime_contenttype(part->filename);
+ if(!contenttype)
+ contenttype = Curl_mime_contenttype(part->data);
+ if(!contenttype && part->filename)
+ contenttype = FILE_CONTENTTYPE_DEFAULT;
+ break;
+ default:
+ contenttype = Curl_mime_contenttype(part->filename);
+ break;
+ }
+ }
+
+ if(part->kind == MIMEKIND_MULTIPART) {
+ mime = (curl_mime *) part->arg;
+ if(mime)
+ boundary = mime->boundary;
+ }
+ else if(contenttype && !customct &&
+ strcasecompare(contenttype, "text/plain"))
+ if(strategy == MIMESTRATEGY_MAIL || !part->filename)
+ contenttype = NULL;
+
+ /* Issue content-disposition header only if not already set by caller. */
+ if(!search_header(part->userheaders, "Content-Disposition")) {
+ if(!disposition)
+ if(part->filename || part->name ||
+ (contenttype && !strncasecompare(contenttype, "multipart/", 10)))
+ disposition = DISPOSITION_DEFAULT;
+ if(disposition && curl_strequal(disposition, "attachment") &&
+ !part->name && !part->filename)
+ disposition = NULL;
+ if(disposition) {
+ char *name = NULL;
+ char *filename = NULL;
+
+ if(part->name) {
+ name = escape_string(part->name);
+ if(!name)
+ ret = CURLE_OUT_OF_MEMORY;
+ }
+ if(!ret && part->filename) {
+ filename = escape_string(part->filename);
+ if(!filename)
+ ret = CURLE_OUT_OF_MEMORY;
+ }
+ if(!ret)
+ ret = Curl_mime_add_header(&part->curlheaders,
+ "Content-Disposition: %s%s%s%s%s%s%s",
+ disposition,
+ name? "; name=\"": "",
+ name? name: "",
+ name? "\"": "",
+ filename? "; filename=\"": "",
+ filename? filename: "",
+ filename? "\"": "");
+ Curl_safefree(name);
+ Curl_safefree(filename);
+ if(ret)
+ return ret;
+ }
+ }
+
+ /* Issue Content-Type header. */
+ if(contenttype) {
+ ret = add_content_type(&part->curlheaders, contenttype, boundary);
+ if(ret)
+ return ret;
+ }
+
+ /* Content-Transfer-Encoding header. */
+ if(!search_header(part->userheaders, "Content-Transfer-Encoding")) {
+ if(part->encoder)
+ cte = part->encoder->name;
+ else if(contenttype && strategy == MIMESTRATEGY_MAIL &&
+ part->kind != MIMEKIND_MULTIPART)
+ cte = "8bit";
+ if(cte) {
+ ret = Curl_mime_add_header(&part->curlheaders,
+ "Content-Transfer-Encoding: %s", cte);
+ if(ret)
+ return ret;
+ }
+ }
+
+ /* If we were reading curl-generated headers, restart with new ones (this
+ should not occur). */
+ if(part->state.state == MIMESTATE_CURLHEADERS)
+ mimesetstate(&part->state, MIMESTATE_CURLHEADERS, part->curlheaders);
+
+ /* Process subparts. */
+ if(part->kind == MIMEKIND_MULTIPART && mime) {
+ curl_mimepart *subpart;
+
+ disposition = NULL;
+ if(strcasecompare(contenttype, "multipart/form-data"))
+ disposition = "form-data";
+ for(subpart = mime->firstpart; subpart; subpart = subpart->nextpart) {
+ ret = Curl_mime_prepare_headers(subpart, NULL, disposition, strategy);
+ if(ret)
+ return ret;
+ }
+ }
+ return ret;
+}
+
+#else /* !CURL_DISABLE_HTTP || !CURL_DISABLE_SMTP || !CURL_DISABLE_IMAP */
+
+/* Mime not compiled in: define stubs for externally-referenced functions. */
+curl_mime *curl_mime_init(CURL *easy)
+{
+ (void) easy;
+ return NULL;
+}
+
+void curl_mime_free(curl_mime *mime)
+{
+ (void) mime;
+}
+
+curl_mimepart *curl_mime_addpart(curl_mime *mime)
+{
+ (void) mime;
+ return NULL;
+}
+
+CURLcode curl_mime_name(curl_mimepart *part, const char *name)
+{
+ (void) part;
+ (void) name;
+ return CURLE_NOT_BUILT_IN;
+}
+
+CURLcode curl_mime_filename(curl_mimepart *part, const char *filename)
+{
+ (void) part;
+ (void) filename;
+ return CURLE_NOT_BUILT_IN;
+}
+
+CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype)
+{
+ (void) part;
+ (void) mimetype;
+ return CURLE_NOT_BUILT_IN;
+}
+
+CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding)
+{
+ (void) part;
+ (void) encoding;
+ return CURLE_NOT_BUILT_IN;
+}
+
+CURLcode curl_mime_data(curl_mimepart *part,
+ const char *data, size_t datasize)
+{
+ (void) part;
+ (void) data;
+ (void) datasize;
+ return CURLE_NOT_BUILT_IN;
+}
+
+CURLcode curl_mime_filedata(curl_mimepart *part, const char *filename)
+{
+ (void) part;
+ (void) filename;
+ return CURLE_NOT_BUILT_IN;
+}
+
+CURLcode curl_mime_data_cb(curl_mimepart *part,
+ curl_off_t datasize,
+ curl_read_callback readfunc,
+ curl_seek_callback seekfunc,
+ curl_free_callback freefunc,
+ void *arg)
+{
+ (void) part;
+ (void) datasize;
+ (void) readfunc;
+ (void) seekfunc;
+ (void) freefunc;
+ (void) arg;
+ return CURLE_NOT_BUILT_IN;
+}
+
+CURLcode curl_mime_subparts(curl_mimepart *part, curl_mime *subparts)
+{
+ (void) part;
+ (void) subparts;
+ return CURLE_NOT_BUILT_IN;
+}
+
+CURLcode curl_mime_headers(curl_mimepart *part,
+ struct curl_slist *headers, int take_ownership)
+{
+ (void) part;
+ (void) headers;
+ (void) take_ownership;
+ return CURLE_NOT_BUILT_IN;
+}
+
+#endif /* if disabled */
diff --git a/Utilities/cmcurl/lib/mime.h b/Utilities/cmcurl/lib/mime.h
new file mode 100644
index 000000000..4c9a5fb71
--- /dev/null
+++ b/Utilities/cmcurl/lib/mime.h
@@ -0,0 +1,164 @@
+#ifndef HEADER_CURL_MIME_H
+#define HEADER_CURL_MIME_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#define MIME_RAND_BOUNDARY_CHARS 16 /* Nb. of random boundary chars. */
+#define MAX_ENCODED_LINE_LENGTH 76 /* Maximum encoded line length. */
+#define ENCODING_BUFFER_SIZE 256 /* Encoding temp buffers size. */
+
+/* Part flags. */
+#define MIME_USERHEADERS_OWNER (1 << 0)
+#define MIME_BODY_ONLY (1 << 1)
+
+#define FILE_CONTENTTYPE_DEFAULT "application/octet-stream"
+#define MULTIPART_CONTENTTYPE_DEFAULT "multipart/mixed"
+#define DISPOSITION_DEFAULT "attachment"
+
+/* Part source kinds. */
+enum mimekind {
+ MIMEKIND_NONE = 0, /* Part not set. */
+ MIMEKIND_DATA, /* Allocated mime data. */
+ MIMEKIND_FILE, /* Data from file. */
+ MIMEKIND_CALLBACK, /* Data from `read' callback. */
+ MIMEKIND_MULTIPART, /* Data is a mime subpart. */
+ MIMEKIND_LAST
+};
+
+/* Readback state tokens. */
+enum mimestate {
+ MIMESTATE_BEGIN, /* Readback has not yet started. */
+ MIMESTATE_CURLHEADERS, /* In curl-generated headers. */
+ MIMESTATE_USERHEADERS, /* In caller's supplied headers. */
+ MIMESTATE_EOH, /* End of headers. */
+ MIMESTATE_BODY, /* Placeholder. */
+ MIMESTATE_BOUNDARY1, /* In boundary prefix. */
+ MIMESTATE_BOUNDARY2, /* In boundary. */
+ MIMESTATE_CONTENT, /* In content. */
+ MIMESTATE_END, /* End of part reached. */
+ MIMESTATE_LAST
+};
+
+/* Mime headers strategies. */
+enum mimestrategy {
+ MIMESTRATEGY_MAIL, /* Mime mail. */
+ MIMESTRATEGY_FORM, /* HTTP post form. */
+ MIMESTRATEGY_LAST
+};
+
+/* Content transfer encoder. */
+typedef struct {
+ const char * name; /* Encoding name. */
+ size_t (*encodefunc)(char *buffer, size_t size, bool ateof,
+ curl_mimepart *part); /* Encoded read. */
+ curl_off_t (*sizefunc)(curl_mimepart *part); /* Encoded size. */
+} mime_encoder;
+
+/* Content transfer encoder state. */
+typedef struct {
+ size_t pos; /* Position on output line. */
+ size_t bufbeg; /* Next data index in input buffer. */
+ size_t bufend; /* First unused byte index in input buffer. */
+ char buf[ENCODING_BUFFER_SIZE]; /* Input buffer. */
+} mime_encoder_state;
+
+/* Mime readback state. */
+typedef struct {
+ enum mimestate state; /* Current state token. */
+ void *ptr; /* State-dependent pointer. */
+ size_t offset; /* State-dependent offset. */
+} mime_state;
+
+/* minimum buffer size for the boundary string */
+#define MIME_BOUNDARY_LEN (24 + MIME_RAND_BOUNDARY_CHARS + 1)
+
+/* A mime multipart. */
+struct curl_mime_s {
+ struct Curl_easy *easy; /* The associated easy handle. */
+ curl_mimepart *parent; /* Parent part. */
+ curl_mimepart *firstpart; /* First part. */
+ curl_mimepart *lastpart; /* Last part. */
+ char boundary[MIME_BOUNDARY_LEN]; /* The part boundary. */
+ mime_state state; /* Current readback state. */
+};
+
+/* A mime part. */
+struct curl_mimepart_s {
+ struct Curl_easy *easy; /* The associated easy handle. */
+ curl_mime *parent; /* Parent mime structure. */
+ curl_mimepart *nextpart; /* Forward linked list. */
+ enum mimekind kind; /* The part kind. */
+ char *data; /* Memory data or file name. */
+ curl_read_callback readfunc; /* Read function. */
+ curl_seek_callback seekfunc; /* Seek function. */
+ curl_free_callback freefunc; /* Argument free function. */
+ void *arg; /* Argument to callback functions. */
+ FILE *fp; /* File pointer. */
+ struct curl_slist *curlheaders; /* Part headers. */
+ struct curl_slist *userheaders; /* Part headers. */
+ char *mimetype; /* Part mime type. */
+ char *filename; /* Remote file name. */
+ char *name; /* Data name. */
+ curl_off_t datasize; /* Expected data size. */
+ unsigned int flags; /* Flags. */
+ mime_state state; /* Current readback state. */
+ const mime_encoder *encoder; /* Content data encoder. */
+ mime_encoder_state encstate; /* Data encoder state. */
+};
+
+#if (!defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_MIME)) || \
+ !defined(CURL_DISABLE_SMTP) || !defined(CURL_DISABLE_IMAP)
+
+/* Prototypes. */
+void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy);
+void Curl_mime_cleanpart(curl_mimepart *part);
+CURLcode Curl_mime_duppart(curl_mimepart *dst, const curl_mimepart *src);
+CURLcode Curl_mime_set_subparts(curl_mimepart *part,
+ curl_mime *subparts, int take_ownership);
+CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
+ const char *contenttype,
+ const char *disposition,
+ enum mimestrategy strategy);
+curl_off_t Curl_mime_size(curl_mimepart *part);
+size_t Curl_mime_read(char *buffer, size_t size, size_t nitems,
+ void *instream);
+CURLcode Curl_mime_rewind(curl_mimepart *part);
+CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...);
+const char *Curl_mime_contenttype(const char *filename);
+
+#else
+/* if disabled */
+#define Curl_mime_initpart(x,y)
+#define Curl_mime_cleanpart(x)
+#define Curl_mime_duppart(x,y) CURLE_OK /* Nothing to duplicate. Succeed */
+#define Curl_mime_set_subparts(a,b,c) CURLE_NOT_BUILT_IN
+#define Curl_mime_prepare_headers(a,b,c,d) CURLE_NOT_BUILT_IN
+#define Curl_mime_size(x) (curl_off_t) -1
+#define Curl_mime_read NULL
+#define Curl_mime_rewind(x) ((void)x, CURLE_NOT_BUILT_IN)
+#define Curl_mime_add_header(x,y,...) CURLE_NOT_BUILT_IN
+#endif
+
+
+#endif /* HEADER_CURL_MIME_H */
diff --git a/Utilities/cmcurl/lib/mprintf.c b/Utilities/cmcurl/lib/mprintf.c
index eb7ee0c6b..e19093678 100644
--- a/Utilities/cmcurl/lib/mprintf.c
+++ b/Utilities/cmcurl/lib/mprintf.c
@@ -46,10 +46,6 @@
* If SIZEOF_SIZE_T has not been defined, default to the size of long.
*/
-#ifndef SIZEOF_SIZE_T
-# define SIZEOF_SIZE_T CURL_SIZEOF_LONG
-#endif
-
#ifdef HAVE_LONGLONG
# define LONG_LONG_TYPE long long
# define HAVE_LONG_LONG_TYPE
@@ -111,7 +107,7 @@ static const char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
} WHILE_FALSE
/* Data type to read from the arglist */
-typedef enum {
+typedef enum {
FORMAT_UNKNOWN = 0,
FORMAT_STRING,
FORMAT_PTR,
@@ -181,7 +177,7 @@ struct asprintf {
static long dprintf_DollarString(char *input, char **end)
{
- int number=0;
+ int number = 0;
while(ISDIGIT(*input)) {
number *= 10;
number += *input-'0';
@@ -237,7 +233,7 @@ static int dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
long width;
long precision;
int flags;
- long max_param=0;
+ long max_param = 0;
long i;
while(*fmt) {
@@ -326,7 +322,7 @@ static int dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
break;
#if defined(MP_HAVE_INT_EXTENSIONS)
case 'I':
-#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
+#if (SIZEOF_CURL_OFF_T > SIZEOF_LONG)
flags |= FLAGS_LONGLONG;
#else
flags |= FLAGS_LONG;
@@ -348,14 +344,14 @@ static int dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
case 'z':
/* the code below generates a warning if -Wunreachable-code is
used */
-#if (SIZEOF_SIZE_T > CURL_SIZEOF_LONG)
+#if (SIZEOF_SIZE_T > SIZEOF_LONG)
flags |= FLAGS_LONGLONG;
#else
flags |= FLAGS_LONG;
#endif
break;
case 'O':
-#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
+#if (SIZEOF_CURL_OFF_T > SIZEOF_LONG)
flags |= FLAGS_LONGLONG;
#else
flags |= FLAGS_LONG;
@@ -380,7 +376,7 @@ static int dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
else
width = param_num;
if(width > max_param)
- max_param=width;
+ max_param = width;
break;
default:
break;
@@ -486,7 +482,7 @@ static int dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
}
/* Read the arg list parameters into our data list */
- for(i=0; i<max_param; i++) {
+ for(i = 0; i<max_param; i++) {
/* Width/precision arguments must be read before the main argument
they are attached to */
if(vto[i].flags & FLAGS_WIDTHPARAM) {
@@ -573,7 +569,7 @@ static int dprintf_formatf(
int done = 0;
long param; /* current parameter to read */
- long param_num=0; /* parameter counter */
+ long param_num = 0; /* parameter counter */
va_stack_t vto[MAX_PARAMETERS];
char *endpos[MAX_PARAMETERS];
@@ -643,7 +639,7 @@ static int dprintf_formatf(
/* If this is a positional parameter, the position must follow immediately
after the %, thus create a %<num>$ sequence */
- param=dprintf_DollarString(f, &f);
+ param = dprintf_DollarString(f, &f);
if(!param)
param = param_num;
@@ -839,7 +835,7 @@ static int dprintf_formatf(
while(width-- > 0)
OUTCHAR(' ');
- while((len-- > 0) && *str)
+ for(; len && *str; len--)
OUTCHAR(*str++);
if(p->flags&FLAGS_LEFT)
while(width-- > 0)
@@ -952,7 +948,7 @@ static int dprintf_formatf(
output characters */
(sprintf)(work, formatbuf, p->data.dnum);
DEBUGASSERT(strlen(work) <= sizeof(work));
- for(fptr=work; *fptr; fptr++)
+ for(fptr = work; *fptr; fptr++)
OUTCHAR(*fptr);
}
break;
@@ -984,7 +980,7 @@ static int dprintf_formatf(
/* fputc() look-alike */
static int addbyter(int output, FILE *data)
{
- struct nsprintf *infop=(struct nsprintf *)data;
+ struct nsprintf *infop = (struct nsprintf *)data;
unsigned char outc = (unsigned char)output;
if(infop->length < infop->max) {
@@ -1032,7 +1028,7 @@ int curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...)
/* fputc() look-alike */
static int alloc_addbyter(int output, FILE *data)
{
- struct asprintf *infop=(struct asprintf *)data;
+ struct asprintf *infop = (struct asprintf *)data;
unsigned char outc = (unsigned char)output;
if(!infop->buffer) {
@@ -1042,9 +1038,9 @@ static int alloc_addbyter(int output, FILE *data)
return -1; /* fail */
}
infop->alloc = 32;
- infop->len =0;
+ infop->len = 0;
}
- else if(infop->len+1 >= infop->alloc) {
+ else if(infop->len + 1 >= infop->alloc) {
char *newptr = NULL;
size_t newsize = infop->alloc*2;
@@ -1133,7 +1129,7 @@ int curl_msprintf(char *buffer, const char *format, ...)
va_start(ap_save, format);
retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
va_end(ap_save);
- *buffer=0; /* we terminate this with a zero byte */
+ *buffer = 0; /* we terminate this with a zero byte */
return retcode;
}
@@ -1162,7 +1158,7 @@ int curl_mvsprintf(char *buffer, const char *format, va_list ap_save)
{
int retcode;
retcode = dprintf_formatf(&buffer, storebuffer, format, ap_save);
- *buffer=0; /* we terminate this with a zero byte */
+ *buffer = 0; /* we terminate this with a zero byte */
return retcode;
}
diff --git a/Utilities/cmcurl/lib/multi.c b/Utilities/cmcurl/lib/multi.c
index c3a0d122c..c7c46eefc 100644
--- a/Utilities/cmcurl/lib/multi.c
+++ b/Utilities/cmcurl/lib/multi.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -31,6 +31,7 @@
#include "progress.h"
#include "easyif.h"
#include "share.h"
+#include "psl.h"
#include "multiif.h"
#include "sendf.h"
#include "timeval.h"
@@ -40,10 +41,11 @@
#include "speedcheck.h"
#include "conncache.h"
#include "multihandle.h"
-#include "pipeline.h"
#include "sigpipe.h"
#include "vtls/vtls.h"
#include "connect.h"
+#include "http_proxy.h"
+#include "http2.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
@@ -58,22 +60,26 @@
#define CURL_SOCKET_HASH_TABLE_SIZE 911
#endif
+#ifndef CURL_CONNECTION_HASH_SIZE
#define CURL_CONNECTION_HASH_SIZE 97
+#endif
#define CURL_MULTI_HANDLE 0x000bab1e
#define GOOD_MULTI_HANDLE(x) \
((x) && (x)->type == CURL_MULTI_HANDLE)
-static void singlesocket(struct Curl_multi *multi,
- struct Curl_easy *data);
+static CURLMcode singlesocket(struct Curl_multi *multi,
+ struct Curl_easy *data);
static int update_timer(struct Curl_multi *multi);
-static CURLMcode add_next_timeout(struct timeval now,
+static CURLMcode add_next_timeout(struct curltime now,
struct Curl_multi *multi,
struct Curl_easy *d);
static CURLMcode multi_timeout(struct Curl_multi *multi,
long *timeout_ms);
+static void process_pending_handles(struct Curl_multi *multi);
+static void detach_connnection(struct Curl_easy *data);
#ifdef DEBUGBUILD
static const char * const statename[]={
@@ -85,12 +91,10 @@ static const char * const statename[]={
"WAITPROXYCONNECT",
"SENDPROTOCONNECT",
"PROTOCONNECT",
- "WAITDO",
"DO",
"DOING",
"DO_MORE",
"DO_DONE",
- "WAITPERFORM",
"PERFORM",
"TOOFAST",
"DONE",
@@ -102,6 +106,16 @@ static const char * const statename[]={
/* function pointer called once when switching TO a state */
typedef void (*init_multistate_func)(struct Curl_easy *data);
+static void Curl_init_completed(struct Curl_easy *data)
+{
+ /* this is a completed transfer */
+
+ /* Important: reset the conn pointer so that we don't point to memory
+ that could be freed anytime */
+ detach_connnection(data);
+ Curl_expire_clear(data); /* stop all timers */
+}
+
/* always use this function to change state, to make debugging easier */
static void mstate(struct Curl_easy *data, CURLMstate state
#ifdef DEBUGBUILD
@@ -111,10 +125,23 @@ static void mstate(struct Curl_easy *data, CURLMstate state
{
CURLMstate oldstate = data->mstate;
static const init_multistate_func finit[CURLM_STATE_LAST] = {
- NULL,
- NULL,
+ NULL, /* INIT */
+ NULL, /* CONNECT_PEND */
Curl_init_CONNECT, /* CONNECT */
- /* the rest is NULL too */
+ NULL, /* WAITRESOLVE */
+ NULL, /* WAITCONNECT */
+ NULL, /* WAITPROXYCONNECT */
+ NULL, /* SENDPROTOCONNECT */
+ NULL, /* PROTOCONNECT */
+ Curl_connect_free, /* DO */
+ NULL, /* DOING */
+ NULL, /* DO_MORE */
+ NULL, /* DO_DONE */
+ NULL, /* PERFORM */
+ NULL, /* TOOFAST */
+ NULL, /* DONE */
+ Curl_init_completed, /* COMPLETED */
+ NULL /* MSGSENT */
};
#if defined(DEBUGBUILD) && defined(CURL_DISABLE_VERBOSE_STRINGS)
@@ -132,8 +159,8 @@ static void mstate(struct Curl_easy *data, CURLMstate state
data->mstate < CURLM_STATE_COMPLETED) {
long connection_id = -5000;
- if(data->easy_conn)
- connection_id = data->easy_conn->connection_id;
+ if(data->conn)
+ connection_id = data->conn->connection_id;
infof(data,
"STATE: %s => %s handle %p; line %d (connection #%ld)\n",
@@ -158,14 +185,17 @@ static void mstate(struct Curl_easy *data, CURLMstate state
#endif
/*
- * We add one of these structs to the sockhash for a particular socket
+ * We add one of these structs to the sockhash for each socket
*/
struct Curl_sh_entry {
- struct Curl_easy *easy;
- int action; /* what action READ/WRITE this socket waits for */
- curl_socket_t socket; /* mainly to ease debugging */
+ struct curl_llist list; /* list of easy handles using this socket */
+ unsigned int action; /* what combined action READ/WRITE this socket waits
+ for */
void *socketp; /* settable by users with curl_multi_assign() */
+ unsigned int users; /* number of transfers using this */
+ unsigned int readers; /* this many transfers want to read */
+ unsigned int writers; /* this many transfers want to write */
};
/* bits for 'action' having no bits means this socket is not expecting any
action */
@@ -184,8 +214,7 @@ static struct Curl_sh_entry *sh_getentry(struct curl_hash *sh,
/* make sure this socket is present in the hash for this handle */
static struct Curl_sh_entry *sh_addentry(struct curl_hash *sh,
- curl_socket_t s,
- struct Curl_easy *data)
+ curl_socket_t s)
{
struct Curl_sh_entry *there = sh_getentry(sh, s);
struct Curl_sh_entry *check;
@@ -199,8 +228,7 @@ static struct Curl_sh_entry *sh_addentry(struct curl_hash *sh,
if(!check)
return NULL; /* major failure */
- check->easy = data;
- check->socket = s;
+ Curl_llist_init(&check->list, NULL);
/* make/add new hash entry */
if(!Curl_hash_add(sh, (char *)&s, sizeof(curl_socket_t), check)) {
@@ -316,16 +344,6 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
Curl_llist_init(&multi->msglist, multi_freeamsg);
Curl_llist_init(&multi->pending, multi_freeamsg);
- /* allocate a new easy handle to use when closing cached connections */
- multi->closure_handle = curl_easy_init();
- if(!multi->closure_handle)
- goto error;
-
- multi->closure_handle->multi = multi;
- multi->closure_handle->state.conn_cache = &multi->conn_cache;
-
- multi->max_pipeline_length = 5;
-
/* -1 means it not set by user, use the default value */
multi->maxconnects = -1;
return multi;
@@ -335,8 +353,6 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
Curl_hash_destroy(&multi->sockhash);
Curl_hash_destroy(&multi->hostcache);
Curl_conncache_destroy(&multi->conn_cache);
- Curl_close(multi->closure_handle);
- multi->closure_handle = NULL;
Curl_llist_destroy(&multi->msglist, NULL);
Curl_llist_destroy(&multi->pending, NULL);
@@ -366,6 +382,9 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi,
if(data->multi)
return CURLM_ADDED_ALREADY;
+ if(multi->in_callback)
+ return CURLM_RECURSIVE_API_CALL;
+
/* Initialize timeout list for this handle */
Curl_llist_init(&data->state.timeoutlist, NULL);
@@ -375,37 +394,35 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi,
* potential multi's connection cache growing which won't be undone in this
* function no matter what.
*/
+ if(data->set.errorbuffer)
+ data->set.errorbuffer[0] = 0;
/* set the easy handle */
multistate(data, CURLM_STATE_INIT);
- if((data->set.global_dns_cache) &&
- (data->dns.hostcachetype != HCACHE_GLOBAL)) {
- /* global dns cache was requested but still isn't */
- struct curl_hash *global = Curl_global_host_cache_init();
- if(global) {
- /* only do this if the global cache init works */
- data->dns.hostcache = global;
- data->dns.hostcachetype = HCACHE_GLOBAL;
- }
- }
/* for multi interface connections, we share DNS cache automatically if the
easy handle's one is currently not set. */
- else if(!data->dns.hostcache ||
+ if(!data->dns.hostcache ||
(data->dns.hostcachetype == HCACHE_NONE)) {
data->dns.hostcache = &multi->hostcache;
data->dns.hostcachetype = HCACHE_MULTI;
}
- /* Point to the multi's connection cache */
- data->state.conn_cache = &multi->conn_cache;
-
- /* This adds the new entry at the 'end' of the doubly-linked circular
- list of Curl_easy structs to try and maintain a FIFO queue so
- the pipelined requests are in order. */
+ /* Point to the shared or multi handle connection cache */
+ if(data->share && (data->share->specifier & (1<< CURL_LOCK_DATA_CONNECT)))
+ data->state.conn_cache = &data->share->conn_cache;
+ else
+ data->state.conn_cache = &multi->conn_cache;
- /* We add this new entry last in the list. */
+#ifdef USE_LIBPSL
+ /* Do the same for PSL. */
+ if(data->share && (data->share->specifier & (1 << CURL_LOCK_DATA_PSL)))
+ data->psl = &data->share->psl;
+ else
+ data->psl = &multi->psl;
+#endif
+ /* We add the new entry last in the list. */
data->next = NULL; /* end of the line */
if(multi->easyp) {
struct Curl_easy *last = multi->easylp;
@@ -440,7 +457,7 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi,
happens if the lastcall time is set to the same time when the handle is
removed as when the next handle is added, as then the check in
update_timer() that prevents calling the application multiple times with
- the same timer infor will not trigger and then the new handle's timeout
+ the same timer info will not trigger and then the new handle's timeout
will not be notified to the app.
The work-around is thus simply to clear the 'lastcall' variable to force
@@ -452,9 +469,11 @@ CURLMcode curl_multi_add_handle(struct Curl_multi *multi,
state somewhat we clone the timeouts from each added handle so that the
closure handle always has the same timeouts as the most recently added
easy handle. */
- multi->closure_handle->set.timeout = data->set.timeout;
- multi->closure_handle->set.server_response_timeout =
+ data->state.conn_cache->closure_handle->set.timeout = data->set.timeout;
+ data->state.conn_cache->closure_handle->set.server_response_timeout =
data->set.server_response_timeout;
+ data->state.conn_cache->closure_handle->set.no_signal =
+ data->set.no_signal;
update_timer(multi);
return CURLM_OK;
@@ -476,66 +495,27 @@ static void debug_print_sock_hash(void *p)
}
#endif
-/* Mark the connection as 'idle', or close it if the cache is full.
- Returns TRUE if the connection is kept, or FALSE if it was closed. */
-static bool
-ConnectionDone(struct Curl_easy *data, struct connectdata *conn)
-{
- /* data->multi->maxconnects can be negative, deal with it. */
- size_t maxconnects =
- (data->multi->maxconnects < 0) ? data->multi->num_easy * 4:
- data->multi->maxconnects;
- struct connectdata *conn_candidate = NULL;
-
- /* Mark the current connection as 'unused' */
- conn->inuse = FALSE;
-
- if(maxconnects > 0 &&
- data->state.conn_cache->num_connections > maxconnects) {
- infof(data, "Connection cache is full, closing the oldest one.\n");
-
- conn_candidate = Curl_oldest_idle_connection(data);
-
- if(conn_candidate) {
- /* Set the connection's owner correctly */
- conn_candidate->data = data;
-
- /* the winner gets the honour of being disconnected */
- (void)Curl_disconnect(conn_candidate, /* dead_connection */ FALSE);
- }
- }
-
- return (conn_candidate == conn) ? FALSE : TRUE;
-}
-
-static CURLcode multi_done(struct connectdata **connp,
- CURLcode status, /* an error if this is called
- after an error was detected */
- bool premature)
+static CURLcode multi_done(struct Curl_easy *data,
+ CURLcode status, /* an error if this is called
+ after an error was detected */
+ bool premature)
{
CURLcode result;
- struct connectdata *conn;
- struct Curl_easy *data;
+ struct connectdata *conn = data->conn;
unsigned int i;
- DEBUGASSERT(*connp);
-
- conn = *connp;
- data = conn->data;
-
DEBUGF(infof(data, "multi_done\n"));
if(data->state.done)
/* Stop if multi_done() has already been called */
return CURLE_OK;
- Curl_getoff_all_pipelines(data, conn);
+ /* Stop the resolver and free its own resources (but not dns_entry yet). */
+ Curl_resolver_kill(conn);
/* Cleanup possible redirect junk */
- free(data->req.newurl);
- data->req.newurl = NULL;
- free(data->req.location);
- data->req.location = NULL;
+ Curl_safefree(data->req.newurl);
+ Curl_safefree(data->req.location);
switch(status) {
case CURLE_ABORTED_BY_CALLBACK:
@@ -564,34 +544,36 @@ static CURLcode multi_done(struct connectdata **connp,
result = CURLE_ABORTED_BY_CALLBACK;
}
- if(conn->send_pipe.size + conn->recv_pipe.size != 0 &&
- !data->set.reuse_forbid &&
- !conn->bits.close) {
- /* Stop if pipeline is not empty and we do not have to close
- connection. */
- data->easy_conn = NULL;
- DEBUGF(infof(data, "Connection still in use, no more multi_done now!\n"));
+ process_pending_handles(data->multi); /* connection / multiplex */
+
+ detach_connnection(data);
+ if(CONN_INUSE(conn)) {
+ /* Stop if still used. */
+ DEBUGF(infof(data, "Connection still in use %zu, "
+ "no more multi_done now!\n",
+ conn->easyq.size));
return CURLE_OK;
}
data->state.done = TRUE; /* called just now! */
- Curl_resolver_cancel(conn);
if(conn->dns_entry) {
Curl_resolv_unlock(data, conn->dns_entry); /* done with this */
conn->dns_entry = NULL;
}
+ Curl_hostcache_prune(data);
+ Curl_safefree(data->state.ulbuf);
/* if the transfer was completed in a paused state there can be buffered
data left to free */
- for(i=0; i < data->state.tempcount; i++) {
+ for(i = 0; i < data->state.tempcount; i++) {
free(data->state.tempwrite[i].buf);
}
data->state.tempcount = 0;
/* if data->set.reuse_forbid is TRUE, it means the libcurl client has
forced us to close this connection. This is ignored for requests taking
- place in a NTLM authentication handshake
+ place in a NTLM/NEGOTIATE authentication handshake
if conn->bits.close is TRUE, it means that the connection should be
closed in spite of all our efforts to be nice, due to protocol
@@ -606,11 +588,16 @@ static CURLcode multi_done(struct connectdata **connp,
if((data->set.reuse_forbid
#if defined(USE_NTLM)
- && !(conn->ntlm.state == NTLMSTATE_TYPE2 ||
- conn->proxyntlm.state == NTLMSTATE_TYPE2)
+ && !(conn->http_ntlm_state == NTLMSTATE_TYPE2 ||
+ conn->proxy_ntlm_state == NTLMSTATE_TYPE2)
+#endif
+#if defined(USE_SPNEGO)
+ && !(conn->http_negotiate_state == GSS_AUTHRECV ||
+ conn->proxy_negotiate_state == GSS_AUTHRECV)
#endif
- ) || conn->bits.close || premature) {
- CURLcode res2 = Curl_disconnect(conn, premature); /* close connection */
+ ) || conn->bits.close
+ || (premature && !(conn->handler->flags & PROTOPT_STREAM))) {
+ CURLcode res2 = Curl_disconnect(data, conn, premature);
/* If we had an error already, make sure we return that one. But
if we got a new error, return that. */
@@ -618,28 +605,27 @@ static CURLcode multi_done(struct connectdata **connp,
result = res2;
}
else {
- /* the connection is no longer in use */
- if(ConnectionDone(data, conn)) {
+ char buffer[256];
+ /* create string before returning the connection */
+ msnprintf(buffer, sizeof(buffer),
+ "Connection #%ld to host %s left intact",
+ conn->connection_id,
+ conn->bits.socksproxy ? conn->socks_proxy.host.dispname :
+ conn->bits.httpproxy ? conn->http_proxy.host.dispname :
+ conn->bits.conn_to_host ? conn->conn_to_host.dispname :
+ conn->host.dispname);
+
+ /* the connection is no longer in use by this transfer */
+ if(Curl_conncache_return_conn(conn)) {
/* remember the most recently used connection */
data->state.lastconnect = conn;
-
- infof(data, "Connection #%ld to host %s left intact\n",
- conn->connection_id,
- conn->bits.socksproxy ? conn->socks_proxy.host.dispname :
- conn->bits.httpproxy ? conn->http_proxy.host.dispname :
- conn->bits.conn_to_host ? conn->conn_to_host.dispname :
- conn->host.dispname);
+ infof(data, "%s\n", buffer);
}
else
data->state.lastconnect = NULL;
}
- *connp = NULL; /* to make the caller of this function better detect that
- this was either closed or handed over to the connection
- cache here, and therefore cannot be used from this point on
- */
Curl_free_request_state(data);
-
return result;
}
@@ -663,8 +649,11 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
if(!data->multi)
return CURLM_OK; /* it is already removed so let's say it is fine! */
+ if(multi->in_callback)
+ return CURLM_RECURSIVE_API_CALL;
+
premature = (data->mstate < CURLM_STATE_COMPLETED) ? TRUE : FALSE;
- easy_owns_conn = (data->easy_conn && (data->easy_conn->data == easy)) ?
+ easy_owns_conn = (data->conn && (data->conn->data == easy)) ?
TRUE : FALSE;
/* If the 'state' is not INIT or COMPLETED, we might need to do something
@@ -673,22 +662,15 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
/* this handle is "alive" so we need to count down the total number of
alive connections when this is removed */
multi->num_alive--;
-
- /* When this handle gets removed, other handles may be able to get the
- connection */
- Curl_multi_process_pending_handles(multi);
}
- if(data->easy_conn &&
+ if(data->conn &&
data->mstate > CURLM_STATE_DO &&
data->mstate < CURLM_STATE_COMPLETED) {
/* Set connection owner so that the DONE function closes it. We can
safely do this here since connection is killed. */
- data->easy_conn->data = easy;
- /* If the handle is in a pipeline and has started sending off its
- request but not received its response yet, we need to close
- connection. */
- streamclose(data->easy_conn, "Removed with partial response");
+ data->conn->data = easy;
+ streamclose(data->conn, "Removed with partial response");
easy_owns_conn = TRUE;
}
@@ -697,13 +679,7 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
curl_easy_cleanup is called. */
Curl_expire_clear(data);
- if(data->dns.hostcachetype == HCACHE_MULTI) {
- /* stop using the multi handle's DNS cache */
- data->dns.hostcache = NULL;
- data->dns.hostcachetype = HCACHE_NONE;
- }
-
- if(data->easy_conn) {
+ if(data->conn) {
/* we must call multi_done() here (if we still own the connection) so that
we don't leave a half-baked one around */
@@ -714,11 +690,20 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
Note that this ignores the return code simply because there's
nothing really useful to do with it anyway! */
- (void)multi_done(&data->easy_conn, data->result, premature);
+ (void)multi_done(data, data->result, premature);
}
- else
- /* Clear connection pipelines, if multi_done above was not called */
- Curl_getoff_all_pipelines(data, data->easy_conn);
+ }
+
+ if(data->connect_queue.ptr)
+ /* the handle was in the pending list waiting for an available connection,
+ so go ahead and remove it */
+ Curl_llist_remove(&multi->pending, &data->connect_queue, NULL);
+
+ if(data->dns.hostcachetype == HCACHE_MULTI) {
+ /* stop using the multi handle's DNS cache, *after* the possible
+ multi_done() call above */
+ data->dns.hostcache = NULL;
+ data->dns.hostcachetype = HCACHE_NONE;
}
Curl_wildcard_dtor(&data->wildcard);
@@ -738,11 +723,17 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
vanish with this handle */
/* Remove the association between the connection and the handle */
- if(data->easy_conn) {
- data->easy_conn->data = NULL;
- data->easy_conn = NULL;
+ if(data->conn) {
+ data->conn->data = NULL;
+ detach_connnection(data);
}
+#ifdef USE_LIBPSL
+ /* Remove the PSL association. */
+ if(data->psl == &multi->psl)
+ data->psl = NULL;
+#endif
+
data->multi = NULL; /* clear the association to this multi handle */
/* make sure there's no pending message in the queue sent from this easy
@@ -778,15 +769,31 @@ CURLMcode curl_multi_remove_handle(struct Curl_multi *multi,
return CURLM_OK;
}
-/* Return TRUE if the application asked for a certain set of pipelining */
-bool Curl_pipeline_wanted(const struct Curl_multi *multi, int bits)
+/* Return TRUE if the application asked for multiplexing */
+bool Curl_multiplex_wanted(const struct Curl_multi *multi)
{
- return (multi && (multi->pipelining & bits)) ? TRUE : FALSE;
+ return (multi && (multi->multiplexing));
}
-void Curl_multi_handlePipeBreak(struct Curl_easy *data)
+/* This is the only function that should clear data->conn. This will
+ occasionally be called with the pointer already cleared. */
+static void detach_connnection(struct Curl_easy *data)
{
- data->easy_conn = NULL;
+ struct connectdata *conn = data->conn;
+ if(conn)
+ Curl_llist_remove(&conn->easyq, &data->conn_queue, NULL);
+ data->conn = NULL;
+}
+
+/* This is the only function that should assign data->conn */
+void Curl_attach_connnection(struct Curl_easy *data,
+ struct connectdata *conn)
+{
+ DEBUGASSERT(!data->conn);
+ DEBUGASSERT(conn);
+ data->conn = conn;
+ Curl_llist_insert_next(&conn->easyq, conn->easyq.tail, data,
+ &data->conn_queue);
}
static int waitconnect_getsock(struct connectdata *conn,
@@ -794,8 +801,8 @@ static int waitconnect_getsock(struct connectdata *conn,
int numsocks)
{
int i;
- int s=0;
- int rc=0;
+ int s = 0;
+ int rc = 0;
if(!numsocks)
return GETSOCK_BLANK;
@@ -805,7 +812,7 @@ static int waitconnect_getsock(struct connectdata *conn,
return Curl_ssl_getsock(conn, sock, numsocks);
#endif
- for(i=0; i<2; i++) {
+ for(i = 0; i<2; i++) {
if(conn->tempsock[i] != CURL_SOCKET_BAD) {
sock[s] = conn->tempsock[i];
rc |= GETSOCK_WRITESOCK(s++);
@@ -826,7 +833,7 @@ static int waitproxyconnect_getsock(struct connectdata *conn,
/* when we've sent a CONNECT to a proxy, we should rather wait for the
socket to become readable to be able to get the response headers */
- if(conn->tunnel_state[FIRSTSOCKET] == TUNNEL_CONNECT)
+ if(conn->connect_state)
return GETSOCK_READSOCK(0);
return GETSOCK_WRITESOCK(0);
@@ -847,18 +854,16 @@ static int multi_getsock(struct Curl_easy *data,
of sockets */
int numsocks)
{
- /* If the pipe broke, or if there's no connection left for this easy handle,
- then we MUST bail out now with no bitmask set. The no connection case can
- happen when this is called from curl_multi_remove_handle() =>
- singlesocket() => multi_getsock().
+ /* The no connection case can happen when this is called from
+ curl_multi_remove_handle() => singlesocket() => multi_getsock().
*/
- if(data->state.pipe_broke || !data->easy_conn)
+ if(!data->conn)
return 0;
if(data->mstate > CURLM_STATE_CONNECT &&
data->mstate < CURLM_STATE_COMPLETED) {
/* Set up ownership correctly */
- data->easy_conn->data = data;
+ data->conn->data = data;
}
switch(data->mstate) {
@@ -879,31 +884,30 @@ static int multi_getsock(struct Curl_easy *data,
return 0;
case CURLM_STATE_WAITRESOLVE:
- return Curl_resolver_getsock(data->easy_conn, socks, numsocks);
+ return Curl_resolv_getsock(data->conn, socks, numsocks);
case CURLM_STATE_PROTOCONNECT:
case CURLM_STATE_SENDPROTOCONNECT:
- return Curl_protocol_getsock(data->easy_conn, socks, numsocks);
+ return Curl_protocol_getsock(data->conn, socks, numsocks);
case CURLM_STATE_DO:
case CURLM_STATE_DOING:
- return Curl_doing_getsock(data->easy_conn, socks, numsocks);
+ return Curl_doing_getsock(data->conn, socks, numsocks);
case CURLM_STATE_WAITPROXYCONNECT:
- return waitproxyconnect_getsock(data->easy_conn, socks, numsocks);
+ return waitproxyconnect_getsock(data->conn, socks, numsocks);
case CURLM_STATE_WAITCONNECT:
- return waitconnect_getsock(data->easy_conn, socks, numsocks);
+ return waitconnect_getsock(data->conn, socks, numsocks);
case CURLM_STATE_DO_MORE:
- return domore_getsock(data->easy_conn, socks, numsocks);
+ return domore_getsock(data->conn, socks, numsocks);
case CURLM_STATE_DO_DONE: /* since is set after DO is completed, we switch
to waiting for the same as the *PERFORM
states */
case CURLM_STATE_PERFORM:
- case CURLM_STATE_WAITPERFORM:
- return Curl_single_getsock(data->easy_conn, socks, numsocks);
+ return Curl_single_getsock(data->conn, socks, numsocks);
}
}
@@ -916,20 +920,22 @@ CURLMcode curl_multi_fdset(struct Curl_multi *multi,
Some easy handles may not have connected to the remote host yet,
and then we must make sure that is done. */
struct Curl_easy *data;
- int this_max_fd=-1;
+ int this_max_fd = -1;
curl_socket_t sockbunch[MAX_SOCKSPEREASYHANDLE];
- int bitmap;
int i;
(void)exc_fd_set; /* not used */
if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE;
- data=multi->easyp;
+ if(multi->in_callback)
+ return CURLM_RECURSIVE_API_CALL;
+
+ data = multi->easyp;
while(data) {
- bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE);
+ int bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE);
- for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++) {
+ for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++) {
curl_socket_t s = CURL_SOCKET_BAD;
if((bitmap & GETSOCK_READSOCK(i)) && VALID_SOCK((sockbunch[i]))) {
@@ -957,11 +963,12 @@ CURLMcode curl_multi_fdset(struct Curl_multi *multi,
#define NUM_POLLS_ON_STACK 10
-CURLMcode curl_multi_wait(struct Curl_multi *multi,
+CURLMcode Curl_multi_wait(struct Curl_multi *multi,
struct curl_waitfd extra_fds[],
unsigned int extra_nfds,
int timeout_ms,
- int *ret)
+ int *ret,
+ bool *gotsocket) /* if any socket was checked */
{
struct Curl_easy *data;
curl_socket_t sockbunch[MAX_SOCKSPEREASYHANDLE];
@@ -969,28 +976,27 @@ CURLMcode curl_multi_wait(struct Curl_multi *multi,
unsigned int i;
unsigned int nfds = 0;
unsigned int curlfds;
- struct pollfd *ufds = NULL;
bool ufds_malloc = FALSE;
long timeout_internal;
int retcode = 0;
struct pollfd a_few_on_stack[NUM_POLLS_ON_STACK];
+ struct pollfd *ufds = &a_few_on_stack[0];
+
+ if(gotsocket)
+ *gotsocket = FALSE;
if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE;
- /* If the internally desired timeout is actually shorter than requested from
- the outside, then use the shorter time! But only if the internal timer
- is actually larger than -1! */
- (void)multi_timeout(multi, &timeout_internal);
- if((timeout_internal >= 0) && (timeout_internal < (long)timeout_ms))
- timeout_ms = (int)timeout_internal;
+ if(multi->in_callback)
+ return CURLM_RECURSIVE_API_CALL;
/* Count up how many fds we have from the multi handle */
- data=multi->easyp;
+ data = multi->easyp;
while(data) {
bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE);
- for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++) {
+ for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++) {
curl_socket_t s = CURL_SOCKET_BAD;
if(bitmap & GETSOCK_READSOCK(i)) {
@@ -1009,18 +1015,25 @@ CURLMcode curl_multi_wait(struct Curl_multi *multi,
data = data->next; /* check next handle */
}
+ /* If the internally desired timeout is actually shorter than requested from
+ the outside, then use the shorter time! But only if the internal timer
+ is actually larger than -1! */
+ (void)multi_timeout(multi, &timeout_internal);
+ if((timeout_internal >= 0) && (timeout_internal < (long)timeout_ms))
+ timeout_ms = (int)timeout_internal;
+
curlfds = nfds; /* number of internal file descriptors */
nfds += extra_nfds; /* add the externally provided ones */
- if(nfds) {
- if(nfds > NUM_POLLS_ON_STACK) {
- ufds = malloc(nfds * sizeof(struct pollfd));
- if(!ufds)
- return CURLM_OUT_OF_MEMORY;
- ufds_malloc = TRUE;
- }
- else
- ufds = &a_few_on_stack[0];
+ if(nfds > NUM_POLLS_ON_STACK) {
+ /* 'nfds' is a 32 bit value and 'struct pollfd' is typically 8 bytes
+ big, so at 2^29 sockets this value might wrap. When a process gets
+ the capability to actually handle over 500 million sockets this
+ calculation needs a integer overflow check. */
+ ufds = malloc(nfds * sizeof(struct pollfd));
+ if(!ufds)
+ return CURLM_OUT_OF_MEMORY;
+ ufds_malloc = TRUE;
}
nfds = 0;
@@ -1029,11 +1042,11 @@ CURLMcode curl_multi_wait(struct Curl_multi *multi,
if(curlfds) {
/* Add the curl handles to our pollfds first */
- data=multi->easyp;
+ data = multi->easyp;
while(data) {
bitmap = multi_getsock(data, sockbunch, MAX_SOCKSPEREASYHANDLE);
- for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++) {
+ for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++) {
curl_socket_t s = CURL_SOCKET_BAD;
if(bitmap & GETSOCK_READSOCK(i)) {
@@ -1074,8 +1087,6 @@ CURLMcode curl_multi_wait(struct Curl_multi *multi,
int pollrc;
/* wait... */
pollrc = Curl_poll(ufds, nfds, timeout_ms);
- DEBUGF(infof(data, "Curl_poll(%d ds, %d ms) == %d\n",
- nfds, timeout_ms, pollrc));
if(pollrc > 0) {
retcode = pollrc;
@@ -1102,19 +1113,20 @@ CURLMcode curl_multi_wait(struct Curl_multi *multi,
free(ufds);
if(ret)
*ret = retcode;
+ if(gotsocket && (extra_fds || curlfds))
+ /* if any socket was checked */
+ *gotsocket = TRUE;
+
return CURLM_OK;
}
-/*
- * Curl_multi_connchanged() is called to tell that there is a connection in
- * this multi handle that has changed state (pipelining become possible, the
- * number of allowed streams changed or similar), and a subsequent use of this
- * multi handle should move CONNECT_PEND handles back to CONNECT to have them
- * retry.
- */
-void Curl_multi_connchanged(struct Curl_multi *multi)
+CURLMcode curl_multi_wait(struct Curl_multi *multi,
+ struct curl_waitfd extra_fds[],
+ unsigned int extra_nfds,
+ int timeout_ms,
+ int *ret)
{
- multi->recheckstate = TRUE;
+ return Curl_multi_wait(multi, extra_fds, extra_nfds, timeout_ms, ret, NULL);
}
/*
@@ -1139,6 +1151,9 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
{
CURLMcode rc;
+ if(multi->in_callback)
+ return CURLM_RECURSIVE_API_CALL;
+
rc = curl_multi_add_handle(multi, data);
if(!rc) {
struct SingleRequest *k = &data->req;
@@ -1149,111 +1164,36 @@ CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
/* take this handle to the perform state right away */
multistate(data, CURLM_STATE_PERFORM);
- data->easy_conn = conn;
+ Curl_attach_connnection(data, conn);
k->keepon |= KEEP_RECV; /* setup to receive! */
}
return rc;
}
-static CURLcode multi_reconnect_request(struct connectdata **connp)
-{
- CURLcode result = CURLE_OK;
- struct connectdata *conn = *connp;
- struct Curl_easy *data = conn->data;
-
- /* This was a re-use of a connection and we got a write error in the
- * DO-phase. Then we DISCONNECT this connection and have another attempt to
- * CONNECT and then DO again! The retry cannot possibly find another
- * connection to re-use, since we only keep one possible connection for
- * each. */
-
- infof(data, "Re-used connection seems dead, get a new one\n");
-
- connclose(conn, "Reconnect dead connection"); /* enforce close */
- result = multi_done(&conn, result, FALSE); /* we are so done with this */
-
- /* conn may no longer be a good pointer, clear it to avoid mistakes by
- parent functions */
- *connp = NULL;
-
- /*
- * We need to check for CURLE_SEND_ERROR here as well. This could happen
- * when the request failed on a FTP connection and thus multi_done() itself
- * tried to use the connection (again).
- */
- if(!result || (CURLE_SEND_ERROR == result)) {
- bool async;
- bool protocol_done = TRUE;
-
- /* Now, redo the connect and get a new connection */
- result = Curl_connect(data, connp, &async, &protocol_done);
- if(!result) {
- /* We have connected or sent away a name resolve query fine */
-
- conn = *connp; /* setup conn to again point to something nice */
- if(async) {
- /* Now, if async is TRUE here, we need to wait for the name
- to resolve */
- result = Curl_resolver_wait_resolv(conn, NULL);
- if(result)
- return result;
-
- /* Resolved, continue with the connection */
- result = Curl_async_resolved(conn, &protocol_done);
- if(result)
- return result;
- }
- }
- }
-
- return result;
-}
-
/*
* do_complete is called when the DO actions are complete.
*
* We init chunking and trailer bits to their default values here immediately
- * before receiving any header data for the current request in the pipeline.
+ * before receiving any header data for the current request.
*/
static void do_complete(struct connectdata *conn)
{
- conn->data->req.chunk=FALSE;
- conn->data->req.maxfd = (conn->sockfd>conn->writesockfd?
- conn->sockfd:conn->writesockfd)+1;
+ conn->data->req.chunk = FALSE;
Curl_pgrsTime(conn->data, TIMER_PRETRANSFER);
}
-static CURLcode multi_do(struct connectdata **connp, bool *done)
+static CURLcode multi_do(struct Curl_easy *data, bool *done)
{
- CURLcode result=CURLE_OK;
- struct connectdata *conn = *connp;
- struct Curl_easy *data = conn->data;
+ CURLcode result = CURLE_OK;
+ struct connectdata *conn = data->conn;
+
+ DEBUGASSERT(conn);
+ DEBUGASSERT(conn->handler);
if(conn->handler->do_it) {
/* generic protocol-specific function pointer set in curl_connect() */
result = conn->handler->do_it(conn, done);
- /* This was formerly done in transfer.c, but we better do it here */
- if((CURLE_SEND_ERROR == result) && conn->bits.reuse) {
- /*
- * If the connection is using an easy handle, call reconnect
- * to re-establish the connection. Otherwise, let the multi logic
- * figure out how to re-establish the connection.
- */
- if(!data->multi) {
- result = multi_reconnect_request(connp);
-
- if(!result) {
- /* ... finally back to actually retry the DO phase */
- conn = *connp; /* re-assign conn since multi_reconnect_request
- creates a new connection */
- result = conn->handler->do_it(conn, done);
- }
- }
- else
- return result;
- }
-
if(!result && *done)
/* do_complete must be called after the protocol-specific DO function */
do_complete(conn);
@@ -1266,15 +1206,13 @@ static CURLcode multi_do(struct connectdata **connp, bool *done)
* second stage DO state which (wrongly) was introduced to support FTP's
* second connection.
*
- * TODO: A future libcurl should be able to work away this state.
- *
* 'complete' can return 0 for incomplete, 1 for done and -1 for go back to
* DOING state there's more work to do!
*/
static CURLcode multi_do_more(struct connectdata *conn, int *complete)
{
- CURLcode result=CURLE_OK;
+ CURLcode result = CURLE_OK;
*complete = 0;
@@ -1289,7 +1227,7 @@ static CURLcode multi_do_more(struct connectdata *conn, int *complete)
}
static CURLMcode multi_runsingle(struct Curl_multi *multi,
- struct timeval now,
+ struct curltime now,
struct Curl_easy *data)
{
struct Curl_message *msg = NULL;
@@ -1300,10 +1238,9 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
bool done = FALSE;
CURLMcode rc;
CURLcode result = CURLE_OK;
- struct SingleRequest *k;
- time_t timeout_ms;
- time_t recv_timeout_ms;
- time_t send_timeout_ms;
+ timediff_t timeout_ms;
+ timediff_t recv_timeout_ms;
+ timediff_t send_timeout_ms;
int control;
if(!GOOD_EASY_HANDLE(data))
@@ -1315,86 +1252,71 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
bool stream_error = FALSE;
rc = CURLM_OK;
- /* Handle the case when the pipe breaks, i.e., the connection
- we're using gets cleaned up and we're left with nothing. */
- if(data->state.pipe_broke) {
- infof(data, "Pipe broke: handle %p, url = %s\n",
- (void *)data, data->state.path);
-
- if(data->mstate < CURLM_STATE_COMPLETED) {
- /* Head back to the CONNECT state */
- multistate(data, CURLM_STATE_CONNECT);
- rc = CURLM_CALL_MULTI_PERFORM;
- result = CURLE_OK;
- }
-
- data->state.pipe_broke = FALSE;
- data->easy_conn = NULL;
- continue;
- }
-
- if(!data->easy_conn &&
+ if(!data->conn &&
data->mstate > CURLM_STATE_CONNECT &&
data->mstate < CURLM_STATE_DONE) {
- /* In all these states, the code will blindly access 'data->easy_conn'
+ /* In all these states, the code will blindly access 'data->conn'
so this is precaution that it isn't NULL. And it silences static
analyzers. */
- failf(data, "In state %d with no easy_conn, bail out!\n", data->mstate);
+ failf(data, "In state %d with no conn, bail out!\n", data->mstate);
return CURLM_INTERNAL_ERROR;
}
if(multi_ischanged(multi, TRUE)) {
DEBUGF(infof(data, "multi changed, check CONNECT_PEND queue!\n"));
- Curl_multi_process_pending_handles(multi);
+ process_pending_handles(multi); /* multiplexed */
}
- if(data->easy_conn && data->mstate > CURLM_STATE_CONNECT &&
- data->mstate < CURLM_STATE_COMPLETED)
+ if(data->conn && data->mstate > CURLM_STATE_CONNECT &&
+ data->mstate < CURLM_STATE_COMPLETED) {
/* Make sure we set the connection's current owner */
- data->easy_conn->data = data;
+ data->conn->data = data;
+ }
- if(data->easy_conn &&
+ if(data->conn &&
(data->mstate >= CURLM_STATE_CONNECT) &&
(data->mstate < CURLM_STATE_COMPLETED)) {
/* we need to wait for the connect state as only then is the start time
stored, but we must not check already completed handles */
-
timeout_ms = Curl_timeleft(data, &now,
- (data->mstate <= CURLM_STATE_WAITDO)?
+ (data->mstate <= CURLM_STATE_DO)?
TRUE:FALSE);
if(timeout_ms < 0) {
/* Handle timed out */
if(data->mstate == CURLM_STATE_WAITRESOLVE)
- failf(data, "Resolving timed out after %ld milliseconds",
- Curl_tvdiff(now, data->progress.t_startsingle));
+ failf(data, "Resolving timed out after %" CURL_FORMAT_TIMEDIFF_T
+ " milliseconds",
+ Curl_timediff(now, data->progress.t_startsingle));
else if(data->mstate == CURLM_STATE_WAITCONNECT)
- failf(data, "Connection timed out after %ld milliseconds",
- Curl_tvdiff(now, data->progress.t_startsingle));
+ failf(data, "Connection timed out after %" CURL_FORMAT_TIMEDIFF_T
+ " milliseconds",
+ Curl_timediff(now, data->progress.t_startsingle));
else {
- k = &data->req;
+ struct SingleRequest *k = &data->req;
if(k->size != -1) {
- failf(data, "Operation timed out after %ld milliseconds with %"
- CURL_FORMAT_CURL_OFF_T " out of %"
+ failf(data, "Operation timed out after %" CURL_FORMAT_TIMEDIFF_T
+ " milliseconds with %" CURL_FORMAT_CURL_OFF_T " out of %"
CURL_FORMAT_CURL_OFF_T " bytes received",
- Curl_tvdiff(now, data->progress.t_startsingle),
+ Curl_timediff(now, data->progress.t_startsingle),
k->bytecount, k->size);
}
else {
- failf(data, "Operation timed out after %ld milliseconds with %"
- CURL_FORMAT_CURL_OFF_T " bytes received",
- Curl_tvdiff(now, data->progress.t_startsingle),
+ failf(data, "Operation timed out after %" CURL_FORMAT_TIMEDIFF_T
+ " milliseconds with %" CURL_FORMAT_CURL_OFF_T
+ " bytes received",
+ Curl_timediff(now, data->progress.t_startsingle),
k->bytecount);
}
}
/* Force connection closed if the connection has indeed been used */
if(data->mstate > CURLM_STATE_DO) {
- streamclose(data->easy_conn, "Disconnected with pending data");
+ streamclose(data->conn, "Disconnected with pending data");
stream_error = TRUE;
}
result = CURLE_OPERATION_TIMEDOUT;
- (void)multi_done(&data->easy_conn, result, TRUE);
+ (void)multi_done(data, result, TRUE);
/* Skip the statemachine and go directly to error handling section. */
goto statemachine_end;
}
@@ -1403,7 +1325,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
switch(data->mstate) {
case CURLM_STATE_INIT:
/* init this transfer. */
- result=Curl_pretransfer(data);
+ result = Curl_pretransfer(data);
if(!result) {
/* after init, go CONNECT */
@@ -1421,8 +1343,13 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
case CURLM_STATE_CONNECT:
/* Connect. We want to get a connection identifier filled in. */
Curl_pgrsTime(data, TIMER_STARTSINGLE);
- result = Curl_connect(data, &data->easy_conn,
- &async, &protocol_connect);
+ if(data->set.timeout)
+ Curl_expire(data, data->set.timeout, EXPIRE_TIMEOUT);
+
+ if(data->set.connecttimeout)
+ Curl_expire(data, data->set.connecttimeout, EXPIRE_CONNECTTIMEOUT);
+
+ result = Curl_connect(data, &async, &protocol_connect);
if(CURLE_NO_CONNECTION_AVAILABLE == result) {
/* There was no connection available. We will go to the pending
state and wait for an available connection. */
@@ -1434,33 +1361,31 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
result = CURLE_OK;
break;
}
+ else if(data->state.previouslypending) {
+ /* this transfer comes from the pending queue so try move another */
+ infof(data, "Transfer was pending, now try another\n");
+ process_pending_handles(data->multi);
+ }
if(!result) {
- /* Add this handle to the send or pend pipeline */
- result = Curl_add_handle_to_pipeline(data, data->easy_conn);
- if(result)
- stream_error = TRUE;
+ if(async)
+ /* We're now waiting for an asynchronous name lookup */
+ multistate(data, CURLM_STATE_WAITRESOLVE);
else {
- if(async)
- /* We're now waiting for an asynchronous name lookup */
- multistate(data, CURLM_STATE_WAITRESOLVE);
- else {
- /* after the connect has been sent off, go WAITCONNECT unless the
- protocol connect is already done and we can go directly to
- WAITDO or DO! */
- rc = CURLM_CALL_MULTI_PERFORM;
+ /* after the connect has been sent off, go WAITCONNECT unless the
+ protocol connect is already done and we can go directly to
+ WAITDO or DO! */
+ rc = CURLM_CALL_MULTI_PERFORM;
- if(protocol_connect)
- multistate(data, Curl_pipeline_wanted(multi, CURLPIPE_HTTP1)?
- CURLM_STATE_WAITDO:CURLM_STATE_DO);
- else {
+ if(protocol_connect)
+ multistate(data, CURLM_STATE_DO);
+ else {
#ifndef CURL_DISABLE_HTTP
- if(data->easy_conn->tunnel_state[FIRSTSOCKET] == TUNNEL_CONNECT)
- multistate(data, CURLM_STATE_WAITPROXYCONNECT);
- else
+ if(Curl_connect_ongoing(data->conn))
+ multistate(data, CURLM_STATE_WAITPROXYCONNECT);
+ else
#endif
- multistate(data, CURLM_STATE_WAITCONNECT);
- }
+ multistate(data, CURLM_STATE_WAITCONNECT);
}
}
}
@@ -1470,9 +1395,10 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* awaiting an asynch name resolve to complete */
{
struct Curl_dns_entry *dns = NULL;
- struct connectdata *conn = data->easy_conn;
+ struct connectdata *conn = data->conn;
const char *hostname;
+ DEBUGASSERT(conn);
if(conn->bits.httpproxy)
hostname = conn->http_proxy.host.name;
else if(conn->bits.conn_to_host)
@@ -1493,7 +1419,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
if(!dns)
- result = Curl_resolver_is_resolved(data->easy_conn, &dns);
+ result = Curl_resolv_check(data->conn, &dns);
/* Update sockets here, because the socket(s) may have been
closed and the application thus needs to be told, even if it
@@ -1506,21 +1432,20 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(dns) {
/* Perform the next step in the connection phase, and then move on
to the WAITCONNECT state */
- result = Curl_async_resolved(data->easy_conn, &protocol_connect);
+ result = Curl_once_resolved(data->conn, &protocol_connect);
if(result)
- /* if Curl_async_resolved() returns failure, the connection struct
+ /* if Curl_once_resolved() returns failure, the connection struct
is already freed and gone */
- data->easy_conn = NULL; /* no more connection */
+ data->conn = NULL; /* no more connection */
else {
/* call again please so that we get the next socket setup */
rc = CURLM_CALL_MULTI_PERFORM;
if(protocol_connect)
- multistate(data, Curl_pipeline_wanted(multi, CURLPIPE_HTTP1)?
- CURLM_STATE_WAITDO:CURLM_STATE_DO);
+ multistate(data, CURLM_STATE_DO);
else {
#ifndef CURL_DISABLE_HTTP
- if(data->easy_conn->tunnel_state[FIRSTSOCKET] == TUNNEL_CONNECT)
+ if(Curl_connect_ongoing(data->conn))
multistate(data, CURLM_STATE_WAITPROXYCONNECT);
else
#endif
@@ -1540,124 +1465,120 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
#ifndef CURL_DISABLE_HTTP
case CURLM_STATE_WAITPROXYCONNECT:
/* this is HTTP-specific, but sending CONNECT to a proxy is HTTP... */
- result = Curl_http_connect(data->easy_conn, &protocol_connect);
+ DEBUGASSERT(data->conn);
+ result = Curl_http_connect(data->conn, &protocol_connect);
- if(data->easy_conn->bits.proxy_connect_closed) {
+ if(data->conn->bits.proxy_connect_closed) {
rc = CURLM_CALL_MULTI_PERFORM;
/* connect back to proxy again */
result = CURLE_OK;
- multi_done(&data->easy_conn, CURLE_OK, FALSE);
+ multi_done(data, CURLE_OK, FALSE);
multistate(data, CURLM_STATE_CONNECT);
}
else if(!result) {
- if((data->easy_conn->http_proxy.proxytype != CURLPROXY_HTTPS ||
- data->easy_conn->bits.proxy_ssl_connected[FIRSTSOCKET]) &&
- (data->easy_conn->tunnel_state[FIRSTSOCKET] != TUNNEL_CONNECT)) {
+ if((data->conn->http_proxy.proxytype != CURLPROXY_HTTPS ||
+ data->conn->bits.proxy_ssl_connected[FIRSTSOCKET]) &&
+ Curl_connect_complete(data->conn)) {
rc = CURLM_CALL_MULTI_PERFORM;
/* initiate protocol connect phase */
multistate(data, CURLM_STATE_SENDPROTOCONNECT);
}
}
+ else if(result)
+ stream_error = TRUE;
break;
#endif
case CURLM_STATE_WAITCONNECT:
/* awaiting a completion of an asynch TCP connect */
- result = Curl_is_connected(data->easy_conn, FIRSTSOCKET, &connected);
+ DEBUGASSERT(data->conn);
+ result = Curl_is_connected(data->conn, FIRSTSOCKET, &connected);
if(connected && !result) {
#ifndef CURL_DISABLE_HTTP
- if((data->easy_conn->http_proxy.proxytype == CURLPROXY_HTTPS &&
- !data->easy_conn->bits.proxy_ssl_connected[FIRSTSOCKET]) ||
- (data->easy_conn->tunnel_state[FIRSTSOCKET] == TUNNEL_CONNECT)) {
+ if((data->conn->http_proxy.proxytype == CURLPROXY_HTTPS &&
+ !data->conn->bits.proxy_ssl_connected[FIRSTSOCKET]) ||
+ Curl_connect_ongoing(data->conn)) {
multistate(data, CURLM_STATE_WAITPROXYCONNECT);
break;
}
#endif
rc = CURLM_CALL_MULTI_PERFORM;
- multistate(data, data->easy_conn->bits.tunnel_proxy?
+ multistate(data, data->conn->bits.tunnel_proxy?
CURLM_STATE_WAITPROXYCONNECT:
CURLM_STATE_SENDPROTOCONNECT);
}
else if(result) {
/* failure detected */
- /* Just break, the cleaning up is handled all in one place */
+ Curl_posttransfer(data);
+ multi_done(data, result, TRUE);
stream_error = TRUE;
break;
}
break;
case CURLM_STATE_SENDPROTOCONNECT:
- result = Curl_protocol_connect(data->easy_conn, &protocol_connect);
- if(!protocol_connect)
+ result = Curl_protocol_connect(data->conn, &protocol_connect);
+ if(!result && !protocol_connect)
/* switch to waiting state */
multistate(data, CURLM_STATE_PROTOCONNECT);
else if(!result) {
/* protocol connect has completed, go WAITDO or DO */
- multistate(data, Curl_pipeline_wanted(multi, CURLPIPE_HTTP1)?
- CURLM_STATE_WAITDO:CURLM_STATE_DO);
+ multistate(data, CURLM_STATE_DO);
rc = CURLM_CALL_MULTI_PERFORM;
}
else if(result) {
/* failure detected */
Curl_posttransfer(data);
- multi_done(&data->easy_conn, result, TRUE);
+ multi_done(data, result, TRUE);
stream_error = TRUE;
}
break;
case CURLM_STATE_PROTOCONNECT:
/* protocol-specific connect phase */
- result = Curl_protocol_connecting(data->easy_conn, &protocol_connect);
+ result = Curl_protocol_connecting(data->conn, &protocol_connect);
if(!result && protocol_connect) {
/* after the connect has completed, go WAITDO or DO */
- multistate(data, Curl_pipeline_wanted(multi, CURLPIPE_HTTP1)?
- CURLM_STATE_WAITDO:CURLM_STATE_DO);
+ multistate(data, CURLM_STATE_DO);
rc = CURLM_CALL_MULTI_PERFORM;
}
else if(result) {
/* failure detected */
Curl_posttransfer(data);
- multi_done(&data->easy_conn, result, TRUE);
+ multi_done(data, result, TRUE);
stream_error = TRUE;
}
break;
- case CURLM_STATE_WAITDO:
- /* Wait for our turn to DO when we're pipelining requests */
- if(Curl_pipeline_checkget_write(data, data->easy_conn)) {
- /* Grabbed the channel */
- multistate(data, CURLM_STATE_DO);
- rc = CURLM_CALL_MULTI_PERFORM;
- }
- break;
-
case CURLM_STATE_DO:
if(data->set.connect_only) {
/* keep connection open for application to use the socket */
- connkeep(data->easy_conn, "CONNECT_ONLY");
+ connkeep(data->conn, "CONNECT_ONLY");
multistate(data, CURLM_STATE_DONE);
result = CURLE_OK;
rc = CURLM_CALL_MULTI_PERFORM;
}
else {
/* Perform the protocol's DO action */
- result = multi_do(&data->easy_conn, &dophase_done);
+ result = multi_do(data, &dophase_done);
- /* When multi_do() returns failure, data->easy_conn might be NULL! */
+ /* When multi_do() returns failure, data->conn might be NULL! */
if(!result) {
if(!dophase_done) {
+#ifndef CURL_DISABLE_FTP
/* some steps needed for wildcard matching */
- if(data->set.wildcardmatch) {
+ if(data->state.wildcardmatch) {
struct WildcardData *wc = &data->wildcard;
if(wc->state == CURLWC_DONE || wc->state == CURLWC_SKIP) {
/* skip some states if it is important */
- multi_done(&data->easy_conn, CURLE_OK, FALSE);
+ multi_done(data, CURLE_OK, FALSE);
multistate(data, CURLM_STATE_DONE);
rc = CURLM_CALL_MULTI_PERFORM;
break;
}
}
+#endif
/* DO was not completed in one function call, we must continue
DOING... */
multistate(data, CURLM_STATE_DOING);
@@ -1665,7 +1586,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
/* after DO, go DO_DONE... or DO_MORE */
- else if(data->easy_conn->bits.do_more) {
+ else if(data->conn->bits.do_more) {
/* we're supposed to do more, but we need to sit down, relax
and wait a little while first */
multistate(data, CURLM_STATE_DO_MORE);
@@ -1678,32 +1599,29 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
}
else if((CURLE_SEND_ERROR == result) &&
- data->easy_conn->bits.reuse) {
+ data->conn->bits.reuse) {
/*
* In this situation, a connection that we were trying to use
* may have unexpectedly died. If possible, send the connection
* back to the CONNECT phase so we can try again.
*/
char *newurl = NULL;
- followtype follow=FOLLOW_NONE;
+ followtype follow = FOLLOW_NONE;
CURLcode drc;
- bool retry = FALSE;
- drc = Curl_retry_request(data->easy_conn, &newurl);
+ drc = Curl_retry_request(data->conn, &newurl);
if(drc) {
/* a failure here pretty much implies an out of memory */
result = drc;
stream_error = TRUE;
}
- else
- retry = (newurl)?TRUE:FALSE;
Curl_posttransfer(data);
- drc = multi_done(&data->easy_conn, result, FALSE);
+ drc = multi_done(data, result, FALSE);
/* When set to retry the connection, we must to go back to
* the CONNECT state */
- if(retry) {
+ if(newurl) {
if(!drc || (drc == CURLE_SEND_ERROR)) {
follow = FOLLOW_RETRY;
drc = Curl_follow(data, newurl, follow);
@@ -1731,8 +1649,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
else {
/* failure detected */
Curl_posttransfer(data);
- if(data->easy_conn)
- multi_done(&data->easy_conn, result, FALSE);
+ if(data->conn)
+ multi_done(data, result, FALSE);
stream_error = TRUE;
}
}
@@ -1740,12 +1658,13 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
case CURLM_STATE_DOING:
/* we continue DOING until the DO phase is complete */
- result = Curl_protocol_doing(data->easy_conn,
+ DEBUGASSERT(data->conn);
+ result = Curl_protocol_doing(data->conn,
&dophase_done);
if(!result) {
if(dophase_done) {
/* after DO, go DO_DONE or DO_MORE */
- multistate(data, data->easy_conn->bits.do_more?
+ multistate(data, data->conn->bits.do_more?
CURLM_STATE_DO_MORE:
CURLM_STATE_DO_DONE);
rc = CURLM_CALL_MULTI_PERFORM;
@@ -1754,7 +1673,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
else {
/* failure detected */
Curl_posttransfer(data);
- multi_done(&data->easy_conn, result, FALSE);
+ multi_done(data, result, FALSE);
stream_error = TRUE;
}
break;
@@ -1763,15 +1682,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/*
* When we are connected, DO MORE and then go DO_DONE
*/
- result = multi_do_more(data->easy_conn, &control);
+ DEBUGASSERT(data->conn);
+ result = multi_do_more(data->conn, &control);
- /* No need to remove this handle from the send pipeline here since that
- is done in multi_done() */
if(!result) {
if(control) {
/* if positive, advance to DO_DONE
if negative, go back to DOING */
- multistate(data, control==1?
+ multistate(data, control == 1?
CURLM_STATE_DO_DONE:
CURLM_STATE_DOING);
rc = CURLM_CALL_MULTI_PERFORM;
@@ -1783,39 +1701,38 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
else {
/* failure detected */
Curl_posttransfer(data);
- multi_done(&data->easy_conn, result, FALSE);
+ multi_done(data, result, FALSE);
stream_error = TRUE;
}
break;
case CURLM_STATE_DO_DONE:
- /* Move ourselves from the send to recv pipeline */
- Curl_move_handle_from_send_to_recv_pipe(data, data->easy_conn);
- /* Check if we can move pending requests to send pipe */
- Curl_multi_process_pending_handles(multi);
+ DEBUGASSERT(data->conn);
+ if(data->conn->bits.multiplex)
+ /* Check if we can move pending requests to send pipe */
+ process_pending_handles(multi); /* multiplexed */
/* Only perform the transfer if there's a good socket to work with.
Having both BAD is a signal to skip immediately to DONE */
- if((data->easy_conn->sockfd != CURL_SOCKET_BAD) ||
- (data->easy_conn->writesockfd != CURL_SOCKET_BAD))
- multistate(data, CURLM_STATE_WAITPERFORM);
- else
- multistate(data, CURLM_STATE_DONE);
- rc = CURLM_CALL_MULTI_PERFORM;
- break;
-
- case CURLM_STATE_WAITPERFORM:
- /* Wait for our turn to PERFORM */
- if(Curl_pipeline_checkget_read(data, data->easy_conn)) {
- /* Grabbed the channel */
+ if((data->conn->sockfd != CURL_SOCKET_BAD) ||
+ (data->conn->writesockfd != CURL_SOCKET_BAD))
multistate(data, CURLM_STATE_PERFORM);
- rc = CURLM_CALL_MULTI_PERFORM;
+ else {
+#ifndef CURL_DISABLE_FTP
+ if(data->state.wildcardmatch &&
+ ((data->conn->handler->flags & PROTOPT_WILDCARD) == 0)) {
+ data->wildcard.state = CURLWC_DONE;
+ }
+#endif
+ multistate(data, CURLM_STATE_DONE);
}
+ rc = CURLM_CALL_MULTI_PERFORM;
break;
case CURLM_STATE_TOOFAST: /* limit-rate exceeded in either direction */
+ DEBUGASSERT(data->conn);
/* if both rates are within spec, resume transfer */
- if(Curl_pgrsUpdate(data->easy_conn))
+ if(Curl_pgrsUpdate(data->conn))
result = CURLE_ABORTED_BY_CALLBACK;
else
result = Curl_speedcheck(data, now);
@@ -1823,22 +1740,26 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
if(!result) {
send_timeout_ms = 0;
if(data->set.max_send_speed > 0)
- send_timeout_ms = Curl_pgrsLimitWaitTime(data->progress.uploaded,
- data->progress.ul_limit_size,
- data->set.max_send_speed,
- data->progress.ul_limit_start,
- now);
+ send_timeout_ms =
+ Curl_pgrsLimitWaitTime(data->progress.uploaded,
+ data->progress.ul_limit_size,
+ data->set.max_send_speed,
+ data->progress.ul_limit_start,
+ now);
recv_timeout_ms = 0;
if(data->set.max_recv_speed > 0)
- recv_timeout_ms = Curl_pgrsLimitWaitTime(data->progress.downloaded,
- data->progress.dl_limit_size,
- data->set.max_recv_speed,
- data->progress.dl_limit_start,
- now);
-
- if(send_timeout_ms <= 0 && recv_timeout_ms <= 0)
+ recv_timeout_ms =
+ Curl_pgrsLimitWaitTime(data->progress.downloaded,
+ data->progress.dl_limit_size,
+ data->set.max_recv_speed,
+ data->progress.dl_limit_start,
+ now);
+
+ if(!send_timeout_ms && !recv_timeout_ms) {
multistate(data, CURLM_STATE_PERFORM);
+ Curl_ratelimit(data, now);
+ }
else if(send_timeout_ms >= recv_timeout_ms)
Curl_expire(data, send_timeout_ms, EXPIRE_TOOFAST);
else
@@ -1870,7 +1791,8 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
data->progress.dl_limit_start,
now);
- if(send_timeout_ms > 0 || recv_timeout_ms > 0) {
+ if(send_timeout_ms || recv_timeout_ms) {
+ Curl_ratelimit(data, now);
multistate(data, CURLM_STATE_TOOFAST);
if(send_timeout_ms >= recv_timeout_ms)
Curl_expire(data, send_timeout_ms, EXPIRE_TOOFAST);
@@ -1880,26 +1802,18 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
/* read/write data if it is ready to do so */
- result = Curl_readwrite(data->easy_conn, data, &done, &comeback);
-
- k = &data->req;
-
- if(!(k->keepon & KEEP_RECV))
- /* We're done receiving */
- Curl_pipeline_leave_read(data->easy_conn);
-
- if(!(k->keepon & KEEP_SEND))
- /* We're done sending */
- Curl_pipeline_leave_write(data->easy_conn);
+ result = Curl_readwrite(data->conn, data, &done, &comeback);
if(done || (result == CURLE_RECV_ERROR)) {
/* If CURLE_RECV_ERROR happens early enough, we assume it was a race
* condition and the server closed the re-used connection exactly when
* we wanted to use it, so figure out if that is indeed the case.
*/
- CURLcode ret = Curl_retry_request(data->easy_conn, &newurl);
+ CURLcode ret = Curl_retry_request(data->conn, &newurl);
if(!ret)
retry = (newurl)?TRUE:FALSE;
+ else if(!result)
+ result = ret;
if(retry) {
/* if we are to retry, set the result to OK and consider the
@@ -1908,6 +1822,27 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
done = TRUE;
}
}
+ else if((CURLE_HTTP2_STREAM == result) &&
+ Curl_h2_http_1_1_error(data->conn)) {
+ CURLcode ret = Curl_retry_request(data->conn, &newurl);
+
+ if(!ret) {
+ infof(data, "Downgrades to HTTP/1.1!\n");
+ data->set.httpversion = CURL_HTTP_VERSION_1_1;
+ /* clear the error message bit too as we ignore the one we got */
+ data->state.errorbuf = FALSE;
+ if(!newurl)
+ /* typically for HTTP_1_1_REQUIRED error on first flight */
+ newurl = strdup(data->change.url);
+ /* if we are to retry, set the result to OK and consider the request
+ as done */
+ retry = TRUE;
+ result = CURLE_OK;
+ done = TRUE;
+ }
+ else
+ result = ret;
+ }
if(result) {
/*
@@ -1918,29 +1853,19 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
* happened in the data connection.
*/
- if(!(data->easy_conn->handler->flags & PROTOPT_DUAL) &&
+ if(!(data->conn->handler->flags & PROTOPT_DUAL) &&
result != CURLE_HTTP2_STREAM)
- streamclose(data->easy_conn, "Transfer returned error");
+ streamclose(data->conn, "Transfer returned error");
Curl_posttransfer(data);
- multi_done(&data->easy_conn, result, TRUE);
+ multi_done(data, result, TRUE);
}
else if(done) {
- followtype follow=FOLLOW_NONE;
+ followtype follow = FOLLOW_NONE;
/* call this even if the readwrite function returned error */
Curl_posttransfer(data);
- /* we're no longer receiving */
- Curl_removeHandleFromPipeline(data, &data->easy_conn->recv_pipe);
-
- /* expire the new receiving pipeline head */
- if(data->easy_conn->recv_pipe.head)
- Curl_expire(data->easy_conn->recv_pipe.head->ptr, 0, EXPIRE_RUN_NOW);
-
- /* Check if we can move pending requests to send pipe */
- Curl_multi_process_pending_handles(multi);
-
/* When we follow redirects or is set to retry the connection, we must
to go back to the CONNECT state */
if(data->req.newurl || retry) {
@@ -1954,14 +1879,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
else
follow = FOLLOW_RETRY;
- result = multi_done(&data->easy_conn, CURLE_OK, FALSE);
+ (void)multi_done(data, CURLE_OK, FALSE);
+ /* multi_done() might return CURLE_GOT_NOTHING */
+ result = Curl_follow(data, newurl, follow);
if(!result) {
- result = Curl_follow(data, newurl, follow);
- if(!result) {
- multistate(data, CURLM_STATE_CONNECT);
- rc = CURLM_CALL_MULTI_PERFORM;
- }
+ multistate(data, CURLM_STATE_CONNECT);
+ rc = CURLM_CALL_MULTI_PERFORM;
}
+ free(newurl);
}
else {
/* after the transfer is done, go DONE */
@@ -1973,18 +1898,21 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
newurl = data->req.location;
data->req.location = NULL;
result = Curl_follow(data, newurl, FOLLOW_FAKE);
- if(result)
+ free(newurl);
+ if(result) {
stream_error = TRUE;
+ result = multi_done(data, result, TRUE);
+ }
}
- multistate(data, CURLM_STATE_DONE);
- rc = CURLM_CALL_MULTI_PERFORM;
+ if(!result) {
+ multistate(data, CURLM_STATE_DONE);
+ rc = CURLM_CALL_MULTI_PERFORM;
+ }
}
}
else if(comeback)
rc = CURLM_CALL_MULTI_PERFORM;
-
- free(newurl);
break;
}
@@ -1992,32 +1920,32 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* this state is highly transient, so run another loop after this */
rc = CURLM_CALL_MULTI_PERFORM;
- if(data->easy_conn) {
+ if(data->conn) {
CURLcode res;
- /* Remove ourselves from the receive pipeline, if we are there. */
- Curl_removeHandleFromPipeline(data, &data->easy_conn->recv_pipe);
- /* Check if we can move pending requests to send pipe */
- Curl_multi_process_pending_handles(multi);
+ if(data->conn->bits.multiplex)
+ /* Check if we can move pending requests to connection */
+ process_pending_handles(multi); /* multiplexing */
/* post-transfer command */
- res = multi_done(&data->easy_conn, result, FALSE);
+ res = multi_done(data, result, FALSE);
/* allow a previously set error code take precedence */
if(!result)
result = res;
/*
- * If there are other handles on the pipeline, multi_done won't set
- * easy_conn to NULL. In such a case, curl_multi_remove_handle() can
+ * If there are other handles on the connection, multi_done won't set
+ * conn to NULL. In such a case, curl_multi_remove_handle() can
* access free'd data, if the connection is free'd and the handle
* removed before we perform the processing in CURLM_STATE_COMPLETED
*/
- if(data->easy_conn)
- data->easy_conn = NULL;
+ if(data->conn)
+ detach_connnection(data);
}
- if(data->set.wildcardmatch) {
+#ifndef CURL_DISABLE_FTP
+ if(data->state.wildcardmatch) {
if(data->wildcard.state != CURLWC_DONE) {
/* if a wildcard is set and we are not ending -> lets start again
with CURLM_STATE_INIT */
@@ -2025,23 +1953,13 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
break;
}
}
-
+#endif
/* after we have DONE what we're supposed to do, go COMPLETED, and
it doesn't matter what the multi_done() returned! */
multistate(data, CURLM_STATE_COMPLETED);
break;
case CURLM_STATE_COMPLETED:
- /* this is a completed transfer, it is likely to still be connected */
-
- /* This node should be delinked from the list now and we should post
- an information message that we are complete. */
-
- /* Important: reset the conn pointer so that we don't point to memory
- that could be freed anytime */
- data->easy_conn = NULL;
-
- Curl_expire_clear(data); /* stop all timers */
break;
case CURLM_STATE_MSGSENT:
@@ -2063,28 +1981,20 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
/* NOTE: no attempt to disconnect connections must be made
in the case blocks above - cleanup happens only here */
- data->state.pipe_broke = FALSE;
-
/* Check if we can move pending requests to send pipe */
- Curl_multi_process_pending_handles(multi);
-
- if(data->easy_conn) {
- /* if this has a connection, unsubscribe from the pipelines */
- Curl_pipeline_leave_write(data->easy_conn);
- Curl_pipeline_leave_read(data->easy_conn);
- Curl_removeHandleFromPipeline(data, &data->easy_conn->send_pipe);
- Curl_removeHandleFromPipeline(data, &data->easy_conn->recv_pipe);
+ process_pending_handles(multi); /* connection */
+ if(data->conn) {
if(stream_error) {
/* Don't attempt to send data over a connection that timed out */
bool dead_connection = result == CURLE_OPERATION_TIMEDOUT;
/* disconnect properly */
- Curl_disconnect(data->easy_conn, dead_connection);
+ Curl_disconnect(data, data->conn, dead_connection);
- /* This is where we make sure that the easy_conn pointer is reset.
+ /* This is where we make sure that the conn pointer is reset.
We don't have to do this in every case block above where a
failure is detected */
- data->easy_conn = NULL;
+ detach_connnection(data);
}
}
else if(data->mstate == CURLM_STATE_CONNECT) {
@@ -2093,13 +2003,14 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
multistate(data, CURLM_STATE_COMPLETED);
+ rc = CURLM_CALL_MULTI_PERFORM;
}
/* if there's still a connection to use, call the progress function */
- else if(data->easy_conn && Curl_pgrsUpdate(data->easy_conn)) {
+ else if(data->conn && Curl_pgrsUpdate(data->conn)) {
/* aborted due to progress callback return code must close the
connection */
result = CURLE_ABORTED_BY_CALLBACK;
- streamclose(data->easy_conn, "Aborted by callback");
+ streamclose(data->conn, "Aborted by callback");
/* if not yet in DONE state, go there, otherwise COMPLETED */
multistate(data, (data->mstate < CURLM_STATE_DONE)?
@@ -2109,22 +2020,26 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
}
if(CURLM_STATE_COMPLETED == data->mstate) {
- /* now fill in the Curl_message with this info */
- msg = &data->msg;
-
- msg->extmsg.msg = CURLMSG_DONE;
- msg->extmsg.easy_handle = data;
- msg->extmsg.data.result = result;
+ if(data->set.fmultidone) {
+ /* signal via callback instead */
+ data->set.fmultidone(data, result);
+ }
+ else {
+ /* now fill in the Curl_message with this info */
+ msg = &data->msg;
- rc = multi_addmsg(multi, msg);
+ msg->extmsg.msg = CURLMSG_DONE;
+ msg->extmsg.easy_handle = data;
+ msg->extmsg.data.result = result;
+ rc = multi_addmsg(multi, msg);
+ DEBUGASSERT(!data->conn);
+ }
multistate(data, CURLM_STATE_MSGSENT);
}
} while((rc == CURLM_CALL_MULTI_PERFORM) || multi_ischanged(multi, FALSE));
data->result = result;
-
-
return rc;
}
@@ -2132,14 +2047,17 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
CURLMcode curl_multi_perform(struct Curl_multi *multi, int *running_handles)
{
struct Curl_easy *data;
- CURLMcode returncode=CURLM_OK;
+ CURLMcode returncode = CURLM_OK;
struct Curl_tree *t;
- struct timeval now = Curl_tvnow();
+ struct curltime now = Curl_now();
if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE;
- data=multi->easyp;
+ if(multi->in_callback)
+ return CURLM_RECURSIVE_API_CALL;
+
+ data = multi->easyp;
while(data) {
CURLMcode result;
SIGPIPE_VARIABLE(pipe_st);
@@ -2180,61 +2098,24 @@ CURLMcode curl_multi_perform(struct Curl_multi *multi, int *running_handles)
return returncode;
}
-static void close_all_connections(struct Curl_multi *multi)
-{
- struct connectdata *conn;
-
- conn = Curl_conncache_find_first_connection(&multi->conn_cache);
- while(conn) {
- SIGPIPE_VARIABLE(pipe_st);
- conn->data = multi->closure_handle;
-
- sigpipe_ignore(conn->data, &pipe_st);
- conn->data->easy_conn = NULL; /* clear the easy handle's connection
- pointer */
- /* This will remove the connection from the cache */
- connclose(conn, "kill all");
- (void)Curl_disconnect(conn, FALSE);
- sigpipe_restore(&pipe_st);
-
- conn = Curl_conncache_find_first_connection(&multi->conn_cache);
- }
-}
-
CURLMcode curl_multi_cleanup(struct Curl_multi *multi)
{
struct Curl_easy *data;
struct Curl_easy *nextdata;
if(GOOD_MULTI_HANDLE(multi)) {
- bool restore_pipe = FALSE;
- SIGPIPE_VARIABLE(pipe_st);
+ if(multi->in_callback)
+ return CURLM_RECURSIVE_API_CALL;
multi->type = 0; /* not good anymore */
- /* Close all the connections in the connection cache */
- close_all_connections(multi);
-
- if(multi->closure_handle) {
- sigpipe_ignore(multi->closure_handle, &pipe_st);
- restore_pipe = TRUE;
-
- multi->closure_handle->dns.hostcache = &multi->hostcache;
- Curl_hostcache_clean(multi->closure_handle,
- multi->closure_handle->dns.hostcache);
-
- Curl_close(multi->closure_handle);
- }
-
- Curl_hash_destroy(&multi->sockhash);
- Curl_conncache_destroy(&multi->conn_cache);
- Curl_llist_destroy(&multi->msglist, NULL);
- Curl_llist_destroy(&multi->pending, NULL);
-
- /* remove all easy handles */
+ /* Firsrt remove all remaining easy handles */
data = multi->easyp;
while(data) {
- nextdata=data->next;
+ nextdata = data->next;
+ if(!data->state.done && data->conn)
+ /* if DONE was never called for this handle */
+ (void)multi_done(data, CURLE_OK, TRUE);
if(data->dns.hostcachetype == HCACHE_MULTI) {
/* clear out the usage of the shared DNS cache */
Curl_hostcache_clean(data, data->dns.hostcache);
@@ -2246,18 +2127,25 @@ CURLMcode curl_multi_cleanup(struct Curl_multi *multi)
data->state.conn_cache = NULL;
data->multi = NULL; /* clear the association */
+#ifdef USE_LIBPSL
+ if(data->psl == &multi->psl)
+ data->psl = NULL;
+#endif
+
data = nextdata;
}
- Curl_hash_destroy(&multi->hostcache);
+ /* Close all the connections in the connection cache */
+ Curl_conncache_close_all_connections(&multi->conn_cache);
- /* Free the blacklists by setting them to NULL */
- Curl_pipeline_set_site_blacklist(NULL, &multi->pipelining_site_bl);
- Curl_pipeline_set_server_blacklist(NULL, &multi->pipelining_server_bl);
+ Curl_hash_destroy(&multi->sockhash);
+ Curl_conncache_destroy(&multi->conn_cache);
+ Curl_llist_destroy(&multi->msglist, NULL);
+ Curl_llist_destroy(&multi->pending, NULL);
+ Curl_hash_destroy(&multi->hostcache);
+ Curl_psl_destroy(&multi->psl);
free(multi);
- if(restore_pipe)
- sigpipe_restore(&pipe_st);
return CURLM_OK;
}
@@ -2280,7 +2168,9 @@ CURLMsg *curl_multi_info_read(struct Curl_multi *multi, int *msgs_in_queue)
*msgs_in_queue = 0; /* default to none */
- if(GOOD_MULTI_HANDLE(multi) && Curl_llist_count(&multi->msglist)) {
+ if(GOOD_MULTI_HANDLE(multi) &&
+ !multi->in_callback &&
+ Curl_llist_count(&multi->msglist)) {
/* there is one or more messages in the list */
struct curl_llist_element *e;
@@ -2304,8 +2194,8 @@ CURLMsg *curl_multi_info_read(struct Curl_multi *multi, int *msgs_in_queue)
* and if we have a different state in any of those sockets from last time we
* call the callback accordingly.
*/
-static void singlesocket(struct Curl_multi *multi,
- struct Curl_easy *data)
+static CURLMcode singlesocket(struct Curl_multi *multi,
+ struct Curl_easy *data)
{
curl_socket_t socks[MAX_SOCKSPEREASYHANDLE];
int i;
@@ -2313,8 +2203,9 @@ static void singlesocket(struct Curl_multi *multi,
curl_socket_t s;
int num;
unsigned int curraction;
+ int actions[MAX_SOCKSPEREASYHANDLE];
- for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++)
+ for(i = 0; i< MAX_SOCKSPEREASYHANDLE; i++)
socks[i] = CURL_SOCKET_BAD;
/* Fill in the 'current' struct with the state as it is now: what sockets to
@@ -2326,10 +2217,13 @@ static void singlesocket(struct Curl_multi *multi,
longer supervised ones and add new ones */
/* walk over the sockets we got right now */
- for(i=0; (i< MAX_SOCKSPEREASYHANDLE) &&
+ for(i = 0; (i< MAX_SOCKSPEREASYHANDLE) &&
(curraction & (GETSOCK_READSOCK(i) | GETSOCK_WRITESOCK(i)));
i++) {
- int action = CURL_POLL_NONE;
+ unsigned int action = CURL_POLL_NONE;
+ unsigned int prevaction = 0;
+ unsigned int comboaction;
+ bool sincebefore = FALSE;
s = socks[i];
@@ -2341,107 +2235,127 @@ static void singlesocket(struct Curl_multi *multi,
if(curraction & GETSOCK_WRITESOCK(i))
action |= CURL_POLL_OUT;
+ actions[i] = action;
if(entry) {
- /* yeps, already present so check if it has the same action set */
- if(entry->action == action)
- /* same, continue */
- continue;
+ /* check if new for this transfer */
+ for(i = 0; i< data->numsocks; i++) {
+ if(s == data->sockets[i]) {
+ prevaction = data->actions[i];
+ sincebefore = TRUE;
+ break;
+ }
+ }
+
}
else {
- /* this is a socket we didn't have before, add it! */
- entry = sh_addentry(&multi->sockhash, s, data);
+ /* this is a socket we didn't have before, add it to the hash! */
+ entry = sh_addentry(&multi->sockhash, s);
if(!entry)
/* fatal */
- return;
+ return CURLM_OUT_OF_MEMORY;
+ }
+ if(sincebefore && (prevaction != action)) {
+ /* Socket was used already, but different action now */
+ if(prevaction & CURL_POLL_IN)
+ entry->readers--;
+ if(prevaction & CURL_POLL_OUT)
+ entry->writers--;
+ if(action & CURL_POLL_IN)
+ entry->readers++;
+ if(action & CURL_POLL_OUT)
+ entry->writers++;
}
+ else if(!sincebefore) {
+ /* a new user */
+ entry->users++;
+ if(action & CURL_POLL_IN)
+ entry->readers++;
+ if(action & CURL_POLL_OUT)
+ entry->writers++;
+
+ /* add 'data' to the list of handles using this socket! */
+ Curl_llist_insert_next(&entry->list, entry->list.tail,
+ data, &data->sh_queue);
+ }
+
+ comboaction = (entry->writers? CURL_POLL_OUT : 0) |
+ (entry->readers ? CURL_POLL_IN : 0);
+
+#if 0
+ infof(data, "--- Comboaction: %u readers %u writers\n",
+ entry->readers, entry->writers);
+#endif
+ /* check if it has the same action set */
+ if(entry->action == comboaction)
+ /* same, continue */
+ continue;
/* we know (entry != NULL) at this point, see the logic above */
if(multi->socket_cb)
multi->socket_cb(data,
s,
- action,
+ comboaction,
multi->socket_userp,
entry->socketp);
- entry->action = action; /* store the current action state */
+ entry->action = comboaction; /* store the current action state */
}
num = i; /* number of sockets */
/* when we've walked over all the sockets we should have right now, we must
make sure to detect sockets that are removed */
- for(i=0; i< data->numsocks; i++) {
+ for(i = 0; i< data->numsocks; i++) {
int j;
+ bool stillused = FALSE;
s = data->sockets[i];
- for(j=0; j<num; j++) {
+ for(j = 0; j < num; j++) {
if(s == socks[j]) {
/* this is still supervised */
- s = CURL_SOCKET_BAD;
+ stillused = TRUE;
break;
}
}
+ if(stillused)
+ continue;
entry = sh_getentry(&multi->sockhash, s);
+ /* if this is NULL here, the socket has been closed and notified so
+ already by Curl_multi_closed() */
if(entry) {
- /* this socket has been removed. Tell the app to remove it */
- bool remove_sock_from_hash = TRUE;
-
- /* check if the socket to be removed serves a connection which has
- other easy-s in a pipeline. In this case the socket should not be
- removed. */
- struct connectdata *easy_conn = data->easy_conn;
- if(easy_conn) {
- if(easy_conn->recv_pipe.size > 1) {
- /* the handle should not be removed from the pipe yet */
- remove_sock_from_hash = FALSE;
-
- /* Update the sockhash entry to instead point to the next in line
- for the recv_pipe, or the first (in case this particular easy
- isn't already) */
- if(entry->easy == data) {
- if(Curl_recvpipe_head(data, easy_conn))
- entry->easy = easy_conn->recv_pipe.head->next->ptr;
- else
- entry->easy = easy_conn->recv_pipe.head->ptr;
- }
- }
- if(easy_conn->send_pipe.size > 1) {
- /* the handle should not be removed from the pipe yet */
- remove_sock_from_hash = FALSE;
-
- /* Update the sockhash entry to instead point to the next in line
- for the send_pipe, or the first (in case this particular easy
- isn't already) */
- if(entry->easy == data) {
- if(Curl_sendpipe_head(data, easy_conn))
- entry->easy = easy_conn->send_pipe.head->next->ptr;
- else
- entry->easy = easy_conn->send_pipe.head->ptr;
- }
- }
- /* Don't worry about overwriting recv_pipe head with send_pipe_head,
- when action will be asked on the socket (see multi_socket()), the
- head of the correct pipe will be taken according to the
- action. */
- }
-
- if(remove_sock_from_hash) {
- /* in this case 'entry' is always non-NULL */
+ int oldactions = data->actions[i];
+ /* this socket has been removed. Decrease user count */
+ entry->users--;
+ if(oldactions & CURL_POLL_OUT)
+ entry->writers--;
+ if(oldactions & CURL_POLL_IN)
+ entry->readers--;
+ if(!entry->users) {
if(multi->socket_cb)
- multi->socket_cb(data,
- s,
- CURL_POLL_REMOVE,
+ multi->socket_cb(data, s, CURL_POLL_REMOVE,
multi->socket_userp,
entry->socketp);
sh_delentry(&multi->sockhash, s);
}
- } /* if sockhash entry existed */
+ else {
+ /* remove this transfer as a user of this socket */
+ Curl_llist_remove(&entry->list, &data->sh_queue, NULL);
+ }
+ }
} /* for loop over numsocks */
memcpy(data->sockets, socks, num*sizeof(curl_socket_t));
+ memcpy(data->actions, actions, num*sizeof(int));
data->numsocks = num;
+ return CURLM_OK;
}
+void Curl_updatesocket(struct Curl_easy *data)
+{
+ singlesocket(data->multi, data);
+}
+
+
/*
* Curl_multi_closed()
*
@@ -2452,22 +2366,25 @@ static void singlesocket(struct Curl_multi *multi,
* socket again and it gets the same file descriptor number.
*/
-void Curl_multi_closed(struct connectdata *conn, curl_socket_t s)
+void Curl_multi_closed(struct Curl_easy *data, curl_socket_t s)
{
- struct Curl_multi *multi = conn->data->multi;
- if(multi) {
- /* this is set if this connection is part of a handle that is added to
- a multi handle, and only then this is necessary */
- struct Curl_sh_entry *entry = sh_getentry(&multi->sockhash, s);
-
- if(entry) {
- if(multi->socket_cb)
- multi->socket_cb(conn->data, s, CURL_POLL_REMOVE,
- multi->socket_userp,
- entry->socketp);
+ if(data) {
+ /* if there's still an easy handle associated with this connection */
+ struct Curl_multi *multi = data->multi;
+ if(multi) {
+ /* this is set if this connection is part of a handle that is added to
+ a multi handle, and only then this is necessary */
+ struct Curl_sh_entry *entry = sh_getentry(&multi->sockhash, s);
+
+ if(entry) {
+ if(multi->socket_cb)
+ multi->socket_cb(data, s, CURL_POLL_REMOVE,
+ multi->socket_userp,
+ entry->socketp);
- /* now remove it from the socket hash */
- sh_delentry(&multi->sockhash, s);
+ /* now remove it from the socket hash */
+ sh_delentry(&multi->sockhash, s);
+ }
}
}
}
@@ -2484,11 +2401,11 @@ void Curl_multi_closed(struct connectdata *conn, curl_socket_t s)
* The splay tree only has each sessionhandle as a single node and the nearest
* timeout is used to sort it on.
*/
-static CURLMcode add_next_timeout(struct timeval now,
+static CURLMcode add_next_timeout(struct curltime now,
struct Curl_multi *multi,
struct Curl_easy *d)
{
- struct timeval *tv = &d->state.expiretime;
+ struct curltime *tv = &d->state.expiretime;
struct curl_llist *list = &d->state.timeoutlist;
struct curl_llist_element *e;
struct time_node *node = NULL;
@@ -2498,9 +2415,9 @@ static CURLMcode add_next_timeout(struct timeval now,
timeout in *tv */
for(e = list->head; e;) {
struct curl_llist_element *n = e->next;
- time_t diff;
+ timediff_t diff;
node = (struct time_node *)e->ptr;
- diff = curlx_tvdiff(node->time, now);
+ diff = Curl_timediff(node->time, now);
if(diff <= 0)
/* remove outdated entry */
Curl_llist_remove(list, e, NULL);
@@ -2520,10 +2437,8 @@ static CURLMcode add_next_timeout(struct timeval now,
/* copy the first entry to 'tv' */
memcpy(tv, &node->time, sizeof(*tv));
- /* remove first entry from list */
- Curl_llist_remove(list, e, NULL);
-
- /* insert this node again into the splay */
+ /* Insert this node again into the splay. Keep the timer in the list in
+ case we need to recompute future timers. */
multi->timetree = Curl_splayinsert(*tv, multi->timetree,
&d->state.timenode);
}
@@ -2539,7 +2454,7 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
CURLMcode result = CURLM_OK;
struct Curl_easy *data = NULL;
struct Curl_tree *t;
- struct timeval now = Curl_tvnow();
+ struct curltime now = Curl_now();
if(checkall) {
/* *perform() deals with running_handles on its own */
@@ -2548,9 +2463,9 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
/* walk through each easy handle and do the socket state change magic
and callbacks */
if(result != CURLM_BAD_HANDLE) {
- data=multi->easyp;
- while(data) {
- singlesocket(multi, data);
+ data = multi->easyp;
+ while(data && !result) {
+ result = singlesocket(multi, data);
data = data->next;
}
}
@@ -2570,44 +2485,38 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
and just move on. */
;
else {
+ struct curl_llist *list = &entry->list;
+ struct curl_llist_element *e;
SIGPIPE_VARIABLE(pipe_st);
- data = entry->easy;
-
- if(data->magic != CURLEASY_MAGIC_NUMBER)
- /* bad bad bad bad bad bad bad */
- return CURLM_INTERNAL_ERROR;
-
- /* If the pipeline is enabled, take the handle which is in the head of
- the pipeline. If we should write into the socket, take the send_pipe
- head. If we should read from the socket, take the recv_pipe head. */
- if(data->easy_conn) {
- if((ev_bitmask & CURL_POLL_OUT) &&
- data->easy_conn->send_pipe.head)
- data = data->easy_conn->send_pipe.head->ptr;
- else if((ev_bitmask & CURL_POLL_IN) &&
- data->easy_conn->recv_pipe.head)
- data = data->easy_conn->recv_pipe.head->ptr;
- }
+ /* the socket can be shared by many transfers, iterate */
+ for(e = list->head; e; e = e->next) {
+ data = (struct Curl_easy *)e->ptr;
- if(data->easy_conn &&
- !(data->easy_conn->handler->flags & PROTOPT_DIRLOCK))
- /* set socket event bitmask if they're not locked */
- data->easy_conn->cselect_bits = ev_bitmask;
+ if(data->magic != CURLEASY_MAGIC_NUMBER)
+ /* bad bad bad bad bad bad bad */
+ return CURLM_INTERNAL_ERROR;
- sigpipe_ignore(data, &pipe_st);
- result = multi_runsingle(multi, now, data);
- sigpipe_restore(&pipe_st);
+ if(data->conn && !(data->conn->handler->flags & PROTOPT_DIRLOCK))
+ /* set socket event bitmask if they're not locked */
+ data->conn->cselect_bits = ev_bitmask;
- if(data->easy_conn &&
- !(data->easy_conn->handler->flags & PROTOPT_DIRLOCK))
- /* clear the bitmask only if not locked */
- data->easy_conn->cselect_bits = 0;
+ sigpipe_ignore(data, &pipe_st);
+ result = multi_runsingle(multi, now, data);
+ sigpipe_restore(&pipe_st);
- if(CURLM_OK >= result)
- /* get the socket(s) and check if the state has been changed since
- last */
- singlesocket(multi, data);
+ if(data->conn && !(data->conn->handler->flags & PROTOPT_DIRLOCK))
+ /* clear the bitmask only if not locked */
+ data->conn->cselect_bits = 0;
+
+ if(CURLM_OK >= result) {
+ /* get the socket(s) and check if the state has been changed since
+ last */
+ result = singlesocket(multi, data);
+ if(result)
+ return result;
+ }
+ }
/* Now we fall-through and do the timer-based stuff, since we don't want
to force the user to have to deal with timeouts as long as at least
@@ -2615,8 +2524,8 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
data = NULL; /* set data to NULL again to avoid calling
multi_runsingle() in case there's no need to */
- now = Curl_tvnow(); /* get a newer time since the multi_runsingle() loop
- may have taken some time */
+ now = Curl_now(); /* get a newer time since the multi_runsingle() loop
+ may have taken some time */
}
}
else {
@@ -2641,10 +2550,13 @@ static CURLMcode multi_socket(struct Curl_multi *multi,
result = multi_runsingle(multi, now, data);
sigpipe_restore(&pipe_st);
- if(CURLM_OK >= result)
+ if(CURLM_OK >= result) {
/* get the socket(s) and check if the state has been changed since
last */
- singlesocket(multi, data);
+ result = singlesocket(multi, data);
+ if(result)
+ return result;
+ }
}
/* Check if there's one (more) expired timer to deal with! This function
@@ -2672,6 +2584,9 @@ CURLMcode curl_multi_setopt(struct Curl_multi *multi,
if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE;
+ if(multi->in_callback)
+ return CURLM_RECURSIVE_API_CALL;
+
va_start(param, option);
switch(option) {
@@ -2688,7 +2603,7 @@ CURLMcode curl_multi_setopt(struct Curl_multi *multi,
multi->push_userp = va_arg(param, void *);
break;
case CURLMOPT_PIPELINING:
- multi->pipelining = va_arg(param, long);
+ multi->multiplexing = va_arg(param, long) & CURLPIPE_MULTIPLEX;
break;
case CURLMOPT_TIMERFUNCTION:
multi->timer_cb = va_arg(param, curl_multi_timer_callback);
@@ -2702,25 +2617,19 @@ CURLMcode curl_multi_setopt(struct Curl_multi *multi,
case CURLMOPT_MAX_HOST_CONNECTIONS:
multi->max_host_connections = va_arg(param, long);
break;
+ case CURLMOPT_MAX_TOTAL_CONNECTIONS:
+ multi->max_total_connections = va_arg(param, long);
+ break;
+ /* options formerly used for pipelining */
case CURLMOPT_MAX_PIPELINE_LENGTH:
- multi->max_pipeline_length = va_arg(param, long);
break;
case CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE:
- multi->content_length_penalty_size = va_arg(param, long);
break;
case CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE:
- multi->chunk_length_penalty_size = va_arg(param, long);
break;
case CURLMOPT_PIPELINING_SITE_BL:
- res = Curl_pipeline_set_site_blacklist(va_arg(param, char **),
- &multi->pipelining_site_bl);
break;
case CURLMOPT_PIPELINING_SERVER_BL:
- res = Curl_pipeline_set_server_blacklist(va_arg(param, char **),
- &multi->pipelining_server_bl);
- break;
- case CURLMOPT_MAX_TOTAL_CONNECTIONS:
- multi->max_total_connections = va_arg(param, long);
break;
default:
res = CURLM_UNKNOWN_OPTION;
@@ -2736,7 +2645,10 @@ CURLMcode curl_multi_setopt(struct Curl_multi *multi,
CURLMcode curl_multi_socket(struct Curl_multi *multi, curl_socket_t s,
int *running_handles)
{
- CURLMcode result = multi_socket(multi, FALSE, s, 0, running_handles);
+ CURLMcode result;
+ if(multi->in_callback)
+ return CURLM_RECURSIVE_API_CALL;
+ result = multi_socket(multi, FALSE, s, 0, running_handles);
if(CURLM_OK >= result)
update_timer(multi);
return result;
@@ -2745,8 +2657,10 @@ CURLMcode curl_multi_socket(struct Curl_multi *multi, curl_socket_t s,
CURLMcode curl_multi_socket_action(struct Curl_multi *multi, curl_socket_t s,
int ev_bitmask, int *running_handles)
{
- CURLMcode result = multi_socket(multi, FALSE, s,
- ev_bitmask, running_handles);
+ CURLMcode result;
+ if(multi->in_callback)
+ return CURLM_RECURSIVE_API_CALL;
+ result = multi_socket(multi, FALSE, s, ev_bitmask, running_handles);
if(CURLM_OK >= result)
update_timer(multi);
return result;
@@ -2755,8 +2669,10 @@ CURLMcode curl_multi_socket_action(struct Curl_multi *multi, curl_socket_t s,
CURLMcode curl_multi_socket_all(struct Curl_multi *multi, int *running_handles)
{
- CURLMcode result = multi_socket(multi, TRUE, CURL_SOCKET_BAD, 0,
- running_handles);
+ CURLMcode result;
+ if(multi->in_callback)
+ return CURLM_RECURSIVE_API_CALL;
+ result = multi_socket(multi, TRUE, CURL_SOCKET_BAD, 0, running_handles);
if(CURLM_OK >= result)
update_timer(multi);
return result;
@@ -2765,19 +2681,19 @@ CURLMcode curl_multi_socket_all(struct Curl_multi *multi, int *running_handles)
static CURLMcode multi_timeout(struct Curl_multi *multi,
long *timeout_ms)
{
- static struct timeval tv_zero = {0, 0};
+ static struct curltime tv_zero = {0, 0};
if(multi->timetree) {
/* we have a tree of expire times */
- struct timeval now = Curl_tvnow();
+ struct curltime now = Curl_now();
/* splay the lowest to the bottom */
multi->timetree = Curl_splay(tv_zero, multi->timetree);
if(Curl_splaycomparekeys(multi->timetree->key, now) > 0) {
/* some time left before expiration */
- *timeout_ms = (long)curlx_tvdiff(multi->timetree->key, now);
- if(!*timeout_ms)
+ timediff_t diff = Curl_timediff(multi->timetree->key, now);
+ if(diff <= 0)
/*
* Since we only provide millisecond resolution on the returned value
* and the diff might be less than one millisecond here, we don't
@@ -2785,7 +2701,11 @@ static CURLMcode multi_timeout(struct Curl_multi *multi,
* processors while the diff is still present but less than one
* millisecond! instead we return 1 until the time is ripe.
*/
- *timeout_ms=1;
+ *timeout_ms = 1;
+ else
+ /* this should be safe even on 64 bit archs, as we don't use that
+ overly long timeouts */
+ *timeout_ms = (long)diff;
}
else
/* 0 means immediately */
@@ -2804,6 +2724,9 @@ CURLMcode curl_multi_timeout(struct Curl_multi *multi,
if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE;
+ if(multi->in_callback)
+ return CURLM_RECURSIVE_API_CALL;
+
return multi_timeout(multi, timeout_ms);
}
@@ -2821,7 +2744,7 @@ static int update_timer(struct Curl_multi *multi)
return -1;
}
if(timeout_ms < 0) {
- static const struct timeval none={0, 0};
+ static const struct curltime none = {0, 0};
if(Curl_splaycomparekeys(none, multi->timer_lastcall)) {
multi->timer_lastcall = none;
/* there's no timeout now but there was one previously, tell the app to
@@ -2872,7 +2795,7 @@ multi_deltimeout(struct Curl_easy *data, expire_id eid)
*/
static CURLMcode
multi_addtimeout(struct Curl_easy *data,
- struct timeval *stamp,
+ struct curltime *stamp,
expire_id eid)
{
struct curl_llist_element *e;
@@ -2892,7 +2815,7 @@ multi_addtimeout(struct Curl_easy *data,
/* find the correct spot in the list */
for(e = timeoutlist->head; e; e = e->next) {
struct time_node *check = (struct time_node *)e->ptr;
- time_t diff = curlx_tvdiff(check->time, node->time);
+ timediff_t diff = Curl_timediff(check->time, node->time);
if(diff > 0)
break;
prev = e;
@@ -2920,9 +2843,8 @@ multi_addtimeout(struct Curl_easy *data,
void Curl_expire(struct Curl_easy *data, time_t milli, expire_id id)
{
struct Curl_multi *multi = data->multi;
- struct timeval *nowp = &data->state.expiretime;
- int rc;
- struct timeval set;
+ struct curltime *nowp = &data->state.expiretime;
+ struct curltime set;
/* this is only interesting while there is still an associated multi struct
remaining! */
@@ -2931,35 +2853,35 @@ void Curl_expire(struct Curl_easy *data, time_t milli, expire_id id)
DEBUGASSERT(id < EXPIRE_LAST);
- set = Curl_tvnow();
- set.tv_sec += (long)(milli/1000);
- set.tv_usec += (long)(milli%1000)*1000;
+ set = Curl_now();
+ set.tv_sec += milli/1000;
+ set.tv_usec += (unsigned int)(milli%1000)*1000;
if(set.tv_usec >= 1000000) {
set.tv_sec++;
set.tv_usec -= 1000000;
}
+ /* Remove any timer with the same id just in case. */
+ multi_deltimeout(data, id);
+
+ /* Add it to the timer list. It must stay in the list until it has expired
+ in case we need to recompute the minimum timer later. */
+ multi_addtimeout(data, &set, id);
+
if(nowp->tv_sec || nowp->tv_usec) {
/* This means that the struct is added as a node in the splay tree.
Compare if the new time is earlier, and only remove-old/add-new if it
is. */
- time_t diff = curlx_tvdiff(set, *nowp);
-
- /* remove the previous timer first, if there */
- multi_deltimeout(data, id);
+ timediff_t diff = Curl_timediff(set, *nowp);
+ int rc;
if(diff > 0) {
- /* the new expire time was later so just add it to the queue
- and get out */
- multi_addtimeout(data, &set, id);
+ /* The current splay tree entry is sooner than this new expiry time.
+ We don't need to update our splay tree entry. */
return;
}
- /* the new time is newer than the presently set one, so add the current
- to the queue and update the head */
- multi_addtimeout(data, nowp, id);
-
/* Since this is an updated time, we must remove the previous entry from
the splay tree first and then re-add the new value */
rc = Curl_splayremovebyaddr(multi->timetree,
@@ -2969,6 +2891,8 @@ void Curl_expire(struct Curl_easy *data, time_t milli, expire_id id)
infof(data, "Internal error removing splay node = %d\n", rc);
}
+ /* Indicate that we are in the splay tree and insert the new timer expiry
+ value since it is our local minimum. */
*nowp = set;
data->state.timenode.payload = data;
multi->timetree = Curl_splayinsert(*nowp, multi->timetree,
@@ -2995,8 +2919,7 @@ void Curl_expire_done(struct Curl_easy *data, expire_id id)
void Curl_expire_clear(struct Curl_easy *data)
{
struct Curl_multi *multi = data->multi;
- struct timeval *nowp = &data->state.expiretime;
- int rc;
+ struct curltime *nowp = &data->state.expiretime;
/* this is only interesting while there is still an associated multi struct
remaining! */
@@ -3007,6 +2930,7 @@ void Curl_expire_clear(struct Curl_easy *data)
/* Since this is an cleared time, we must remove the previous entry from
the splay tree */
struct curl_llist *list = &data->state.timeoutlist;
+ int rc;
rc = Curl_splayremovebyaddr(multi->timetree,
&data->state.timenode,
@@ -3020,7 +2944,7 @@ void Curl_expire_clear(struct Curl_easy *data)
}
#ifdef DEBUGBUILD
- infof(data, "Expire cleared\n");
+ infof(data, "Expire cleared (transfer %p)\n", data);
#endif
nowp->tv_sec = 0;
nowp->tv_usec = 0;
@@ -3035,6 +2959,9 @@ CURLMcode curl_multi_assign(struct Curl_multi *multi, curl_socket_t s,
{
struct Curl_sh_entry *there = NULL;
+ if(multi->in_callback)
+ return CURLM_RECURSIVE_API_CALL;
+
there = sh_getentry(&multi->sockhash, s);
if(!there)
@@ -3055,48 +2982,60 @@ size_t Curl_multi_max_total_connections(struct Curl_multi *multi)
return multi ? multi->max_total_connections : 0;
}
-curl_off_t Curl_multi_content_length_penalty_size(struct Curl_multi *multi)
-{
- return multi ? multi->content_length_penalty_size : 0;
-}
-
-curl_off_t Curl_multi_chunk_length_penalty_size(struct Curl_multi *multi)
-{
- return multi ? multi->chunk_length_penalty_size : 0;
-}
+/*
+ * When information about a connection has appeared, call this!
+ */
-struct curl_llist *Curl_multi_pipelining_site_bl(struct Curl_multi *multi)
+void Curl_multiuse_state(struct connectdata *conn,
+ int bundlestate) /* use BUNDLE_* defines */
{
- return &multi->pipelining_site_bl;
-}
+ DEBUGASSERT(conn);
+ DEBUGASSERT(conn->bundle);
+ DEBUGASSERT(conn->data);
+ DEBUGASSERT(conn->data->multi);
-struct curl_llist *Curl_multi_pipelining_server_bl(struct Curl_multi *multi)
-{
- return &multi->pipelining_server_bl;
+ conn->bundle->multiuse = bundlestate;
+ process_pending_handles(conn->data->multi);
}
-void Curl_multi_process_pending_handles(struct Curl_multi *multi)
+static void process_pending_handles(struct Curl_multi *multi)
{
struct curl_llist_element *e = multi->pending.head;
-
- while(e) {
+ if(e) {
struct Curl_easy *data = e->ptr;
- struct curl_llist_element *next = e->next;
- if(data->mstate == CURLM_STATE_CONNECT_PEND) {
- multistate(data, CURLM_STATE_CONNECT);
+ DEBUGASSERT(data->mstate == CURLM_STATE_CONNECT_PEND);
- /* Remove this node from the list */
- Curl_llist_remove(&multi->pending, e, NULL);
+ multistate(data, CURLM_STATE_CONNECT);
- /* Make sure that the handle will be processed soonish. */
- Curl_expire(data, 0, EXPIRE_RUN_NOW);
- }
+ /* Remove this node from the list */
+ Curl_llist_remove(&multi->pending, e, NULL);
+
+ /* Make sure that the handle will be processed soonish. */
+ Curl_expire(data, 0, EXPIRE_RUN_NOW);
+
+ /* mark this as having been in the pending queue */
+ data->state.previouslypending = TRUE;
+ }
+}
- e = next; /* operate on next handle */
+void Curl_set_in_callback(struct Curl_easy *data, bool value)
+{
+ /* might get called when there is no data pointer! */
+ if(data) {
+ if(data->multi_easy)
+ data->multi_easy->in_callback = value;
+ else if(data->multi)
+ data->multi->in_callback = value;
}
}
+bool Curl_is_in_callback(struct Curl_easy *easy)
+{
+ return ((easy->multi && easy->multi->in_callback) ||
+ (easy->multi_easy && easy->multi_easy->in_callback));
+}
+
#ifdef DEBUGBUILD
void Curl_multi_dump(struct Curl_multi *multi)
{
@@ -3104,13 +3043,13 @@ void Curl_multi_dump(struct Curl_multi *multi)
int i;
fprintf(stderr, "* Multi status: %d handles, %d alive\n",
multi->num_easy, multi->num_alive);
- for(data=multi->easyp; data; data = data->next) {
+ for(data = multi->easyp; data; data = data->next) {
if(data->mstate < CURLM_STATE_COMPLETED) {
/* only display handles that are not completed */
fprintf(stderr, "handle %p, state %s, %d sockets\n",
(void *)data,
statename[data->mstate], data->numsocks);
- for(i=0; i < data->numsocks; i++) {
+ for(i = 0; i < data->numsocks; i++) {
curl_socket_t s = data->sockets[i];
struct Curl_sh_entry *entry = sh_getentry(&multi->sockhash, s);
@@ -3120,8 +3059,8 @@ void Curl_multi_dump(struct Curl_multi *multi)
continue;
}
fprintf(stderr, "[%s %s] ",
- entry->action&CURL_POLL_IN?"RECVING":"",
- entry->action&CURL_POLL_OUT?"SENDING":"");
+ (entry->action&CURL_POLL_IN)?"RECVING":"",
+ (entry->action&CURL_POLL_OUT)?"SENDING":"");
}
if(data->numsocks)
fprintf(stderr, "\n");
diff --git a/Utilities/cmcurl/lib/multihandle.h b/Utilities/cmcurl/lib/multihandle.h
index e6ffbf5b6..279379ae0 100644
--- a/Utilities/cmcurl/lib/multihandle.h
+++ b/Utilities/cmcurl/lib/multihandle.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -23,6 +23,7 @@
***************************************************************************/
#include "conncache.h"
+#include "psl.h"
struct Curl_message {
struct curl_llist_element list;
@@ -45,18 +46,16 @@ typedef enum {
CURLM_STATE_SENDPROTOCONNECT, /* 6 - initiate protocol connect procedure */
CURLM_STATE_PROTOCONNECT, /* 7 - completing the protocol-specific connect
phase */
- CURLM_STATE_WAITDO, /* 8 - wait for our turn to send the request */
- CURLM_STATE_DO, /* 9 - start send off the request (part 1) */
- CURLM_STATE_DOING, /* 10 - sending off the request (part 1) */
- CURLM_STATE_DO_MORE, /* 11 - send off the request (part 2) */
- CURLM_STATE_DO_DONE, /* 12 - done sending off request */
- CURLM_STATE_WAITPERFORM, /* 13 - wait for our turn to read the response */
- CURLM_STATE_PERFORM, /* 14 - transfer data */
- CURLM_STATE_TOOFAST, /* 15 - wait because limit-rate exceeded */
- CURLM_STATE_DONE, /* 16 - post data transfer operation */
- CURLM_STATE_COMPLETED, /* 17 - operation complete */
- CURLM_STATE_MSGSENT, /* 18 - the operation complete message is sent */
- CURLM_STATE_LAST /* 19 - not a true state, never use this */
+ CURLM_STATE_DO, /* 8 - start send off the request (part 1) */
+ CURLM_STATE_DOING, /* 9 - sending off the request (part 1) */
+ CURLM_STATE_DO_MORE, /* 10 - send off the request (part 2) */
+ CURLM_STATE_DO_DONE, /* 11 - done sending off request */
+ CURLM_STATE_PERFORM, /* 12 - transfer data */
+ CURLM_STATE_TOOFAST, /* 13 - wait because limit-rate exceeded */
+ CURLM_STATE_DONE, /* 14 - post data transfer operation */
+ CURLM_STATE_COMPLETED, /* 15 - operation complete */
+ CURLM_STATE_MSGSENT, /* 16 - the operation complete message is sent */
+ CURLM_STATE_LAST /* 17 - not a true state, never use this */
} CURLMstate;
/* we support N sockets per easy handle. Set the corresponding bit to what
@@ -65,7 +64,7 @@ typedef enum {
#define GETSOCK_READABLE (0x00ff)
#define GETSOCK_WRITABLE (0xff00)
-#define CURLPIPE_ANY (CURLPIPE_HTTP1 | CURLPIPE_MULTIPLEX)
+#define CURLPIPE_ANY (CURLPIPE_MULTIPLEX)
/* This is the struct known as CURLM on the outside */
struct Curl_multi {
@@ -97,6 +96,11 @@ struct Curl_multi {
/* Hostname cache */
struct curl_hash hostcache;
+#ifdef USE_LIBPSL
+ /* PSL cache. */
+ struct PslCache psl;
+#endif
+
/* timetree points to the splay-tree of time nodes to figure out expire
times of all currently set timers */
struct Curl_tree *timetree;
@@ -106,18 +110,14 @@ struct Curl_multi {
same actual socket) */
struct curl_hash sockhash;
- /* pipelining wanted bits (CURLPIPE*) */
- long pipelining;
+ /* multiplexing wanted */
+ bool multiplexing;
bool recheckstate; /* see Curl_multi_connchanged */
/* Shared connection cache (bundles)*/
struct conncache conn_cache;
- /* This handle will be used for closing the cached connections in
- curl_multi_cleanup() */
- struct Curl_easy *closure_handle;
-
long maxconnects; /* if >0, a fixed limit of the maximum number of entries
we're allowed to grow the connection cache to */
@@ -127,29 +127,12 @@ struct Curl_multi {
long max_total_connections; /* if >0, a fixed limit of the maximum number
of connections in total */
- long max_pipeline_length; /* if >0, maximum number of requests in a
- pipeline */
-
- long content_length_penalty_size; /* a connection with a
- content-length bigger than
- this is not considered
- for pipelining */
-
- long chunk_length_penalty_size; /* a connection with a chunk length
- bigger than this is not
- considered for pipelining */
-
- struct curl_llist pipelining_site_bl; /* List of sites that are blacklisted
- from pipelining */
-
- struct curl_llist pipelining_server_bl; /* List of server types that are
- blacklisted from pipelining */
-
/* timer callback and user data pointer for the *socket() API */
curl_multi_timer_callback timer_cb;
void *timer_userp;
- struct timeval timer_lastcall; /* the fixed time for the timeout for the
+ struct curltime timer_lastcall; /* the fixed time for the timeout for the
previous callback */
+ bool in_callback; /* true while executing a callback */
};
#endif /* HEADER_CURL_MULTIHANDLE_H */
diff --git a/Utilities/cmcurl/lib/multiif.h b/Utilities/cmcurl/lib/multiif.h
index a877571a0..e8a5e7062 100644
--- a/Utilities/cmcurl/lib/multiif.h
+++ b/Utilities/cmcurl/lib/multiif.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -26,11 +26,16 @@
* Prototypes for library-wide functions provided by multi.c
*/
+void Curl_updatesocket(struct Curl_easy *data);
void Curl_expire(struct Curl_easy *data, time_t milli, expire_id);
void Curl_expire_clear(struct Curl_easy *data);
void Curl_expire_done(struct Curl_easy *data, expire_id id);
-bool Curl_pipeline_wanted(const struct Curl_multi* multi, int bits);
-void Curl_multi_handlePipeBreak(struct Curl_easy *data);
+void Curl_detach_connnection(struct Curl_easy *data);
+void Curl_attach_connnection(struct Curl_easy *data,
+ struct connectdata *conn);
+bool Curl_multiplex_wanted(const struct Curl_multi *multi);
+void Curl_set_in_callback(struct Curl_easy *data, bool value);
+bool Curl_is_in_callback(struct Curl_easy *easy);
/* Internal version of curl_multi_init() accepts size parameters for the
socket and connection hashes */
@@ -56,27 +61,14 @@ struct Curl_multi *Curl_multi_handle(int hashsize, int chashsize);
void Curl_multi_dump(struct Curl_multi *multi);
#endif
-void Curl_multi_process_pending_handles(struct Curl_multi *multi);
-
/* Return the value of the CURLMOPT_MAX_HOST_CONNECTIONS option */
size_t Curl_multi_max_host_connections(struct Curl_multi *multi);
-/* Return the value of the CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE option */
-curl_off_t Curl_multi_content_length_penalty_size(struct Curl_multi *multi);
-
-/* Return the value of the CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE option */
-curl_off_t Curl_multi_chunk_length_penalty_size(struct Curl_multi *multi);
-
-/* Return the value of the CURLMOPT_PIPELINING_SITE_BL option */
-struct curl_llist *Curl_multi_pipelining_site_bl(struct Curl_multi *multi);
-
-/* Return the value of the CURLMOPT_PIPELINING_SERVER_BL option */
-struct curl_llist *Curl_multi_pipelining_server_bl(struct Curl_multi *multi);
-
/* Return the value of the CURLMOPT_MAX_TOTAL_CONNECTIONS option */
size_t Curl_multi_max_total_connections(struct Curl_multi *multi);
-void Curl_multi_connchanged(struct Curl_multi *multi);
+void Curl_multiuse_state(struct connectdata *conn,
+ int bundlestate); /* use BUNDLE_* defines */
/*
* Curl_multi_closed()
@@ -88,7 +80,7 @@ void Curl_multi_connchanged(struct Curl_multi *multi);
* socket again and it gets the same file descriptor number.
*/
-void Curl_multi_closed(struct connectdata *conn, curl_socket_t s);
+void Curl_multi_closed(struct Curl_easy *data, curl_socket_t s);
/*
* Add a handle and move it into PERFORM state at once. For pushed streams.
@@ -96,4 +88,12 @@ void Curl_multi_closed(struct connectdata *conn, curl_socket_t s);
CURLMcode Curl_multi_add_perform(struct Curl_multi *multi,
struct Curl_easy *data,
struct connectdata *conn);
+
+CURLMcode Curl_multi_wait(struct Curl_multi *multi,
+ struct curl_waitfd extra_fds[],
+ unsigned int extra_nfds,
+ int timeout_ms,
+ int *ret,
+ bool *gotsocket); /* if any socket was checked */
+
#endif /* HEADER_CURL_MULTIIF_H */
diff --git a/Utilities/cmcurl/lib/netrc.c b/Utilities/cmcurl/lib/netrc.c
index 996711d11..1bd998f9c 100644
--- a/Utilities/cmcurl/lib/netrc.c
+++ b/Utilities/cmcurl/lib/netrc.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -21,6 +21,7 @@
***************************************************************************/
#include "curl_setup.h"
+#ifndef CURL_DISABLE_NETRC
#ifdef HAVE_PWD_H
#include <pwd.h>
@@ -53,17 +54,24 @@ enum host_lookup_state {
int Curl_parsenetrc(const char *host,
char **loginp,
char **passwordp,
+ bool *login_changed,
+ bool *password_changed,
char *netrcfile)
{
FILE *file;
- int retcode=1;
- int specific_login = (*loginp && **loginp != 0);
+ int retcode = 1;
+ char *login = *loginp;
+ char *password = *passwordp;
+ bool specific_login = (login && *login != 0);
+ bool login_alloc = FALSE;
+ bool password_alloc = FALSE;
bool netrc_alloc = FALSE;
- enum host_lookup_state state=NOTHING;
+ enum host_lookup_state state = NOTHING;
- char state_login=0; /* Found a login keyword */
- char state_password=0; /* Found a password keyword */
- int state_our_login=FALSE; /* With specific_login, found *our* login name */
+ char state_login = 0; /* Found a login keyword */
+ char state_password = 0; /* Found a password keyword */
+ int state_our_login = FALSE; /* With specific_login, found *our* login
+ name */
#define NETRC DOT_CHAR "netrc"
@@ -88,7 +96,7 @@ int Curl_parsenetrc(const char *host,
}
else {
struct passwd *pw;
- pw= getpwuid(geteuid());
+ pw = getpwuid(geteuid());
if(pw) {
home = pw->pw_dir;
}
@@ -113,16 +121,19 @@ int Curl_parsenetrc(const char *host,
if(file) {
char *tok;
char *tok_buf;
- bool done=FALSE;
- char netrcbuffer[256];
+ bool done = FALSE;
+ char netrcbuffer[4096];
int netrcbuffsize = (int)sizeof(netrcbuffer);
while(!done && fgets(netrcbuffer, netrcbuffsize, file)) {
- tok=strtok_r(netrcbuffer, " \t\n", &tok_buf);
+ tok = strtok_r(netrcbuffer, " \t\n", &tok_buf);
+ if(tok && *tok == '#')
+ /* treat an initial hash as a comment line */
+ continue;
while(!done && tok) {
- if((*loginp && **loginp) && (*passwordp && **passwordp)) {
- done=TRUE;
+ if((login && *login) && (password && *password)) {
+ done = TRUE;
break;
}
@@ -133,54 +144,63 @@ int Curl_parsenetrc(const char *host,
delimiter that starts the stuff entered for this machine,
after this we need to search for 'login' and
'password'. */
- state=HOSTFOUND;
+ state = HOSTFOUND;
}
else if(strcasecompare("default", tok)) {
- state=HOSTVALID;
- retcode=0; /* we did find our host */
+ state = HOSTVALID;
+ retcode = 0; /* we did find our host */
}
break;
case HOSTFOUND:
if(strcasecompare(host, tok)) {
/* and yes, this is our host! */
- state=HOSTVALID;
- retcode=0; /* we did find our host */
+ state = HOSTVALID;
+ retcode = 0; /* we did find our host */
}
else
/* not our host */
- state=NOTHING;
+ state = NOTHING;
break;
case HOSTVALID:
/* we are now parsing sub-keywords concerning "our" host */
if(state_login) {
if(specific_login) {
- state_our_login = strcasecompare(*loginp, tok);
+ state_our_login = strcasecompare(login, tok);
}
- else {
- free(*loginp);
- *loginp = strdup(tok);
- if(!*loginp) {
+ else if(!login || strcmp(login, tok)) {
+ if(login_alloc) {
+ free(login);
+ login_alloc = FALSE;
+ }
+ login = strdup(tok);
+ if(!login) {
retcode = -1; /* allocation failed */
goto out;
}
+ login_alloc = TRUE;
}
- state_login=0;
+ state_login = 0;
}
else if(state_password) {
- if(state_our_login || !specific_login) {
- free(*passwordp);
- *passwordp = strdup(tok);
- if(!*passwordp) {
+ if((state_our_login || !specific_login)
+ && (!password || strcmp(password, tok))) {
+ if(password_alloc) {
+ free(password);
+ password_alloc = FALSE;
+ }
+ password = strdup(tok);
+ if(!password) {
retcode = -1; /* allocation failed */
goto out;
}
+ password_alloc = TRUE;
}
- state_password=0;
+ state_password = 0;
}
else if(strcasecompare("login", tok))
- state_login=1;
+ state_login = 1;
else if(strcasecompare("password", tok))
- state_password=1;
+ state_password = 1;
else if(strcasecompare("machine", tok)) {
/* ok, there's machine here go => */
state = HOSTFOUND;
@@ -194,8 +214,32 @@ int Curl_parsenetrc(const char *host,
} /* while fgets() */
out:
+ if(!retcode) {
+ *login_changed = FALSE;
+ *password_changed = FALSE;
+ if(login_alloc) {
+ if(*loginp)
+ free(*loginp);
+ *loginp = login;
+ *login_changed = TRUE;
+ }
+ if(password_alloc) {
+ if(*passwordp)
+ free(*passwordp);
+ *passwordp = password;
+ *password_changed = TRUE;
+ }
+ }
+ else {
+ if(login_alloc)
+ free(login);
+ if(password_alloc)
+ free(password);
+ }
fclose(file);
}
return retcode;
}
+
+#endif
diff --git a/Utilities/cmcurl/lib/netrc.h b/Utilities/cmcurl/lib/netrc.h
index d980166e6..7f56c4b4d 100644
--- a/Utilities/cmcurl/lib/netrc.h
+++ b/Utilities/cmcurl/lib/netrc.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,15 +22,24 @@
*
***************************************************************************/
+#include "curl_setup.h"
+#ifndef CURL_DISABLE_NETRC
+
/* returns -1 on failure, 0 if the host is found, 1 is the host isn't found */
int Curl_parsenetrc(const char *host,
char **loginp,
char **passwordp,
+ bool *login_changed,
+ bool *password_changed,
char *filename);
/* Assume: (*passwordp)[0]=0, host[0] != 0.
* If (*loginp)[0] = 0, search for login and password within a machine
* section in the netrc.
* If (*loginp)[0] != 0, search for password within machine and login.
*/
+#else
+/* disabled */
+#define Curl_parsenetrc(a,b,c,d,e,f) 1
+#endif
#endif /* HEADER_CURL_NETRC_H */
diff --git a/Utilities/cmcurl/lib/non-ascii.c b/Utilities/cmcurl/lib/non-ascii.c
index 2f5de4c68..42beaec45 100644
--- a/Utilities/cmcurl/lib/non-ascii.c
+++ b/Utilities/cmcurl/lib/non-ascii.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -30,6 +30,7 @@
#include "formdata.h"
#include "sendf.h"
#include "urldata.h"
+#include "multiif.h"
#include "curl_memory.h"
/* The last #include file should be: */
@@ -77,14 +78,17 @@ CURLcode Curl_convert_clone(struct Curl_easy *data,
/*
* Curl_convert_to_network() is an internal function for performing ASCII
- * conversions on non-ASCII platforms. It convers the buffer _in place_.
+ * conversions on non-ASCII platforms. It converts the buffer _in place_.
*/
CURLcode Curl_convert_to_network(struct Curl_easy *data,
char *buffer, size_t length)
{
- if(data->set.convtonetwork) {
+ if(data && data->set.convtonetwork) {
/* use translation callback */
- CURLcode result = data->set.convtonetwork(buffer, length);
+ CURLcode result;
+ Curl_set_in_callback(data, true);
+ result = data->set.convtonetwork(buffer, length);
+ Curl_set_in_callback(data, false);
if(result) {
failf(data,
"CURLOPT_CONV_TO_NETWORK_FUNCTION callback returned %d: %s",
@@ -96,34 +100,37 @@ CURLcode Curl_convert_to_network(struct Curl_easy *data,
else {
#ifdef HAVE_ICONV
/* do the translation ourselves */
+ iconv_t tmpcd = (iconv_t) -1;
+ iconv_t *cd = &tmpcd;
char *input_ptr, *output_ptr;
size_t in_bytes, out_bytes, rc;
- int error;
/* open an iconv conversion descriptor if necessary */
- if(data->outbound_cd == (iconv_t)-1) {
- data->outbound_cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
- CURL_ICONV_CODESET_OF_HOST);
- if(data->outbound_cd == (iconv_t)-1) {
- error = ERRNO;
+ if(data)
+ cd = &data->outbound_cd;
+ if(*cd == (iconv_t)-1) {
+ *cd = iconv_open(CURL_ICONV_CODESET_OF_NETWORK,
+ CURL_ICONV_CODESET_OF_HOST);
+ if(*cd == (iconv_t)-1) {
failf(data,
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
CURL_ICONV_CODESET_OF_NETWORK,
CURL_ICONV_CODESET_OF_HOST,
- error, strerror(error));
+ errno, strerror(errno));
return CURLE_CONV_FAILED;
}
}
/* call iconv */
input_ptr = output_ptr = buffer;
in_bytes = out_bytes = length;
- rc = iconv(data->outbound_cd, (const char **)&input_ptr, &in_bytes,
+ rc = iconv(*cd, &input_ptr, &in_bytes,
&output_ptr, &out_bytes);
+ if(!data)
+ iconv_close(tmpcd);
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
- error = ERRNO;
failf(data,
"The Curl_convert_to_network iconv call failed with errno %i: %s",
- error, strerror(error));
+ errno, strerror(errno));
return CURLE_CONV_FAILED;
}
#else
@@ -137,14 +144,17 @@ CURLcode Curl_convert_to_network(struct Curl_easy *data,
/*
* Curl_convert_from_network() is an internal function for performing ASCII
- * conversions on non-ASCII platforms. It convers the buffer _in place_.
+ * conversions on non-ASCII platforms. It converts the buffer _in place_.
*/
CURLcode Curl_convert_from_network(struct Curl_easy *data,
char *buffer, size_t length)
{
- if(data->set.convfromnetwork) {
+ if(data && data->set.convfromnetwork) {
/* use translation callback */
- CURLcode result = data->set.convfromnetwork(buffer, length);
+ CURLcode result;
+ Curl_set_in_callback(data, true);
+ result = data->set.convfromnetwork(buffer, length);
+ Curl_set_in_callback(data, false);
if(result) {
failf(data,
"CURLOPT_CONV_FROM_NETWORK_FUNCTION callback returned %d: %s",
@@ -156,34 +166,37 @@ CURLcode Curl_convert_from_network(struct Curl_easy *data,
else {
#ifdef HAVE_ICONV
/* do the translation ourselves */
+ iconv_t tmpcd = (iconv_t) -1;
+ iconv_t *cd = &tmpcd;
char *input_ptr, *output_ptr;
size_t in_bytes, out_bytes, rc;
- int error;
/* open an iconv conversion descriptor if necessary */
- if(data->inbound_cd == (iconv_t)-1) {
- data->inbound_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
- CURL_ICONV_CODESET_OF_NETWORK);
- if(data->inbound_cd == (iconv_t)-1) {
- error = ERRNO;
+ if(data)
+ cd = &data->inbound_cd;
+ if(*cd == (iconv_t)-1) {
+ *cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
+ CURL_ICONV_CODESET_OF_NETWORK);
+ if(*cd == (iconv_t)-1) {
failf(data,
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
CURL_ICONV_CODESET_OF_HOST,
CURL_ICONV_CODESET_OF_NETWORK,
- error, strerror(error));
+ errno, strerror(errno));
return CURLE_CONV_FAILED;
}
}
/* call iconv */
input_ptr = output_ptr = buffer;
in_bytes = out_bytes = length;
- rc = iconv(data->inbound_cd, (const char **)&input_ptr, &in_bytes,
+ rc = iconv(*cd, &input_ptr, &in_bytes,
&output_ptr, &out_bytes);
+ if(!data)
+ iconv_close(tmpcd);
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
- error = ERRNO;
failf(data,
"Curl_convert_from_network iconv call failed with errno %i: %s",
- error, strerror(error));
+ errno, strerror(errno));
return CURLE_CONV_FAILED;
}
#else
@@ -202,9 +215,12 @@ CURLcode Curl_convert_from_network(struct Curl_easy *data,
CURLcode Curl_convert_from_utf8(struct Curl_easy *data,
char *buffer, size_t length)
{
- if(data->set.convfromutf8) {
+ if(data && data->set.convfromutf8) {
/* use translation callback */
- CURLcode result = data->set.convfromutf8(buffer, length);
+ CURLcode result;
+ Curl_set_in_callback(data, true);
+ result = data->set.convfromutf8(buffer, length);
+ Curl_set_in_callback(data, false);
if(result) {
failf(data,
"CURLOPT_CONV_FROM_UTF8_FUNCTION callback returned %d: %s",
@@ -216,35 +232,38 @@ CURLcode Curl_convert_from_utf8(struct Curl_easy *data,
else {
#ifdef HAVE_ICONV
/* do the translation ourselves */
- const char *input_ptr;
+ iconv_t tmpcd = (iconv_t) -1;
+ iconv_t *cd = &tmpcd;
+ char *input_ptr;
char *output_ptr;
size_t in_bytes, out_bytes, rc;
- int error;
/* open an iconv conversion descriptor if necessary */
- if(data->utf8_cd == (iconv_t)-1) {
- data->utf8_cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
- CURL_ICONV_CODESET_FOR_UTF8);
- if(data->utf8_cd == (iconv_t)-1) {
- error = ERRNO;
+ if(data)
+ cd = &data->utf8_cd;
+ if(*cd == (iconv_t)-1) {
+ *cd = iconv_open(CURL_ICONV_CODESET_OF_HOST,
+ CURL_ICONV_CODESET_FOR_UTF8);
+ if(*cd == (iconv_t)-1) {
failf(data,
"The iconv_open(\"%s\", \"%s\") call failed with errno %i: %s",
CURL_ICONV_CODESET_OF_HOST,
CURL_ICONV_CODESET_FOR_UTF8,
- error, strerror(error));
+ errno, strerror(errno));
return CURLE_CONV_FAILED;
}
}
/* call iconv */
input_ptr = output_ptr = buffer;
in_bytes = out_bytes = length;
- rc = iconv(data->utf8_cd, &input_ptr, &in_bytes,
+ rc = iconv(*cd, &input_ptr, &in_bytes,
&output_ptr, &out_bytes);
+ if(!data)
+ iconv_close(tmpcd);
if((rc == ICONV_ERROR) || (in_bytes != 0)) {
- error = ERRNO;
failf(data,
"The Curl_convert_from_utf8 iconv call failed with errno %i: %s",
- error, strerror(error));
+ errno, strerror(errno));
return CURLE_CONV_FAILED;
}
if(output_ptr < input_ptr) {
@@ -310,29 +329,4 @@ void Curl_convert_close(struct Curl_easy *data)
#endif /* HAVE_ICONV */
}
-/*
- * Curl_convert_form() is used from http.c, this converts any form items that
- need to be sent in the network encoding. Returns CURLE_OK on success.
- */
-CURLcode Curl_convert_form(struct Curl_easy *data, struct FormData *form)
-{
- CURLcode result;
-
- if(!data)
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- while(form) {
- if(form->type == FORM_DATA) {
- result = Curl_convert_to_network(data, form->line, form->length);
- /* Curl_convert_to_network calls failf if unsuccessful */
- if(result)
- return result;
- }
-
- form = form->next;
- }
-
- return CURLE_OK;
-}
-
#endif /* CURL_DOES_CONVERSIONS */
diff --git a/Utilities/cmcurl/lib/non-ascii.h b/Utilities/cmcurl/lib/non-ascii.h
index e27f1f41f..5fb5771e0 100644
--- a/Utilities/cmcurl/lib/non-ascii.h
+++ b/Utilities/cmcurl/lib/non-ascii.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -48,7 +48,6 @@ CURLcode Curl_convert_from_network(struct Curl_easy *data,
char *buffer, size_t length);
CURLcode Curl_convert_from_utf8(struct Curl_easy *data,
char *buffer, size_t length);
-CURLcode Curl_convert_form(struct Curl_easy *data, struct FormData *form);
#else
#define Curl_convert_clone(a,b,c,d) ((void)a, CURLE_OK)
#define Curl_convert_init(x) Curl_nop_stmt
@@ -57,7 +56,6 @@ CURLcode Curl_convert_form(struct Curl_easy *data, struct FormData *form);
#define Curl_convert_to_network(a,b,c) ((void)a, CURLE_OK)
#define Curl_convert_from_network(a,b,c) ((void)a, CURLE_OK)
#define Curl_convert_from_utf8(a,b,c) ((void)a, CURLE_OK)
-#define Curl_convert_form(a,b) CURLE_OK
#endif
#endif /* HEADER_CURL_NON_ASCII_H */
diff --git a/Utilities/cmcurl/lib/nonblock.c b/Utilities/cmcurl/lib/nonblock.c
index 5959281e5..4d105c1fe 100644
--- a/Utilities/cmcurl/lib/nonblock.c
+++ b/Utilities/cmcurl/lib/nonblock.c
@@ -48,7 +48,8 @@ int curlx_nonblock(curl_socket_t sockfd, /* operate on this */
int nonblock /* TRUE or FALSE */)
{
#if defined(USE_BLOCKING_SOCKETS)
-
+ (void)sockfd;
+ (void)nonblock;
return 0; /* returns success */
#elif defined(HAVE_FCNTL_O_NONBLOCK)
diff --git a/Utilities/cmcurl/lib/nonblock.h b/Utilities/cmcurl/lib/nonblock.h
index 98cdc25ab..eb18ea1c3 100644
--- a/Utilities/cmcurl/lib/nonblock.h
+++ b/Utilities/cmcurl/lib/nonblock.h
@@ -28,4 +28,3 @@ int curlx_nonblock(curl_socket_t sockfd, /* operate on this */
int nonblock /* TRUE or FALSE */);
#endif /* HEADER_CURL_NONBLOCK_H */
-
diff --git a/Utilities/cmcurl/lib/nwlib.c b/Utilities/cmcurl/lib/nwlib.c
index 290cbe31f..7bf5f51c3 100644
--- a/Utilities/cmcurl/lib/nwlib.c
+++ b/Utilities/cmcurl/lib/nwlib.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -186,18 +186,16 @@ int GetOrSetUpData(int id, libdata_t **appData,
app_data = (libdata_t *) get_app_data(id);
if(!app_data) {
- app_data = malloc(sizeof(libdata_t));
+ app_data = calloc(1, sizeof(libdata_t));
if(app_data) {
- memset(app_data, 0, sizeof(libdata_t));
-
app_data->tenbytes = malloc(10);
app_data->lock = NXMutexAlloc(0, 0, &liblock);
if(!app_data->tenbytes || !app_data->lock) {
if(app_data->lock)
NXMutexFree(app_data->lock);
-
+ free(app_data->tenbytes);
free(app_data);
app_data = (libdata_t *) NULL;
err = ENOMEM;
@@ -215,6 +213,9 @@ int GetOrSetUpData(int id, libdata_t **appData,
err = set_app_data(gLibId, app_data);
if(err) {
+ if(app_data->lock)
+ NXMutexFree(app_data->lock);
+ free(app_data->tenbytes);
free(app_data);
app_data = (libdata_t *) NULL;
err = ENOMEM;
diff --git a/Utilities/cmcurl/lib/openldap.c b/Utilities/cmcurl/lib/openldap.c
index 4b8cfb9c2..eeab2c7a7 100644
--- a/Utilities/cmcurl/lib/openldap.c
+++ b/Utilities/cmcurl/lib/openldap.c
@@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2010, Howard Chu, <hyc@openldap.org>
- * Copyright (C) 2011 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2011 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -51,6 +51,25 @@
#include "curl_memory.h"
#include "memdebug.h"
+/*
+ * Uncommenting this will enable the built-in debug logging of the openldap
+ * library. The debug log level can be set using the CURL_OPENLDAP_TRACE
+ * environment variable. The debug output is written to stderr.
+ *
+ * The library supports the following debug flags:
+ * LDAP_DEBUG_NONE 0x0000
+ * LDAP_DEBUG_TRACE 0x0001
+ * LDAP_DEBUG_CONSTRUCT 0x0002
+ * LDAP_DEBUG_DESTROY 0x0004
+ * LDAP_DEBUG_PARAMETER 0x0008
+ * LDAP_DEBUG_ANY 0xffff
+ *
+ * For example, use CURL_OPENLDAP_TRACE=0 for no debug,
+ * CURL_OPENLDAP_TRACE=2 for LDAP_DEBUG_CONSTRUCT messages only,
+ * CURL_OPENLDAP_TRACE=65535 for all debug message levels.
+ */
+/* #define CURL_OPENLDAP_DEBUG */
+
#ifndef _LDAP_PVT_H
extern int ldap_pvt_url_scheme2proto(const char *);
extern int ldap_init_fd(ber_socket_t fd, int proto, const char *url,
@@ -85,6 +104,7 @@ const struct Curl_handler Curl_handler_ldap = {
ZERO_NULL, /* perform_getsock */
ldap_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_LDAP, /* defport */
CURLPROTO_LDAP, /* protocol */
PROTOPT_NONE /* flags */
@@ -110,6 +130,7 @@ const struct Curl_handler Curl_handler_ldaps = {
ZERO_NULL, /* perform_getsock */
ldap_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_LDAPS, /* defport */
CURLPROTO_LDAP, /* protocol */
PROTOPT_SSL /* flags */
@@ -150,7 +171,7 @@ static CURLcode ldap_setup_connection(struct connectdata *conn)
{
ldapconninfo *li;
LDAPURLDesc *lud;
- struct Curl_easy *data=conn->data;
+ struct Curl_easy *data = conn->data;
int rc, proto;
CURLcode status;
@@ -175,9 +196,6 @@ static CURLcode ldap_setup_connection(struct connectdata *conn)
li->proto = proto;
conn->proto.generic = li;
connkeep(conn, "OpenLDAP default");
- /* TODO:
- * - provide option to choose SASL Binds instead of Simple
- */
return CURLE_OK;
}
@@ -196,11 +214,20 @@ static CURLcode ldap_connect(struct connectdata *conn, bool *done)
(void)done;
strcpy(hosturl, "ldap");
- ptr = hosturl+4;
+ ptr = hosturl + 4;
if(conn->handler->flags & PROTOPT_SSL)
*ptr++ = 's';
- snprintf(ptr, sizeof(hosturl)-(ptr-hosturl), "://%s:%d",
- conn->host.name, conn->remote_port);
+ msnprintf(ptr, sizeof(hosturl)-(ptr-hosturl), "://%s:%d",
+ conn->host.name, conn->remote_port);
+
+#ifdef CURL_OPENLDAP_DEBUG
+ static int do_trace = 0;
+ const char *env = getenv("CURL_OPENLDAP_TRACE");
+ do_trace = (env && strtol(env, NULL, 10) > 0);
+ if(do_trace) {
+ ldap_set_option(li->ld, LDAP_OPT_DEBUG_LEVEL, &do_trace);
+ }
+#endif
rc = ldap_init_fd(conn->sock[FIRSTSOCKET], li->proto, hosturl, &li->ld);
if(rc) {
@@ -256,7 +283,7 @@ static CURLcode ldap_connecting(struct connectdata *conn, bool *done)
tvp = &tv;
-retry:
+ retry:
if(!li->didbind) {
char *binddn;
struct berval passwd;
@@ -352,7 +379,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
int rc = 0;
LDAPURLDesc *ludp = NULL;
int msgid;
- struct Curl_easy *data=conn->data;
+ struct Curl_easy *data = conn->data;
connkeep(conn, "OpenLDAP do");
@@ -384,7 +411,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
return CURLE_OUT_OF_MEMORY;
lr->msgid = msgid;
data->req.protop = lr;
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, FALSE, -1);
*done = TRUE;
return CURLE_OK;
}
@@ -442,8 +469,8 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
return ret;
for(ent = ldap_first_message(li->ld, msg); ent;
- ent = ldap_next_message(li->ld, ent)) {
- struct berval bv, *bvals, **bvp = &bvals;
+ ent = ldap_next_message(li->ld, ent)) {
+ struct berval bv, *bvals;
int binary = 0, msgtype;
CURLcode writeerr;
@@ -480,8 +507,6 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
lr->nument++;
rc = ldap_get_dn_ber(li->ld, ent, &ber, &bv);
if(rc < 0) {
- /* TODO: verify that this is really how this return code should be
- handled */
*err = CURLE_RECV_ERROR;
return -1;
}
@@ -505,19 +530,41 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
}
data->req.bytecount += bv.bv_len + 5;
- for(rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, bvp);
- rc == LDAP_SUCCESS;
- rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, bvp)) {
+ for(rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, &bvals);
+ rc == LDAP_SUCCESS;
+ rc = ldap_get_attribute_ber(li->ld, ent, ber, &bv, &bvals)) {
int i;
- if(bv.bv_val == NULL) break;
+ if(bv.bv_val == NULL)
+ break;
if(bv.bv_len > 7 && !strncmp(bv.bv_val + bv.bv_len - 7, ";binary", 7))
binary = 1;
else
binary = 0;
- for(i=0; bvals[i].bv_val != NULL; i++) {
+ if(bvals == NULL) {
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
+ if(writeerr) {
+ *err = writeerr;
+ return -1;
+ }
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val,
+ bv.bv_len);
+ if(writeerr) {
+ *err = writeerr;
+ return -1;
+ }
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)":\n", 2);
+ if(writeerr) {
+ *err = writeerr;
+ return -1;
+ }
+ data->req.bytecount += bv.bv_len + 3;
+ continue;
+ }
+
+ for(i = 0; bvals[i].bv_val != NULL; i++) {
int binval = 0;
writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
if(writeerr) {
@@ -525,29 +572,29 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
return -1;
}
- writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val,
- bv.bv_len);
- if(writeerr) {
- *err = writeerr;
- return -1;
- }
+ writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)bv.bv_val,
+ bv.bv_len);
+ if(writeerr) {
+ *err = writeerr;
+ return -1;
+ }
writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)":", 1);
- if(writeerr) {
- *err = writeerr;
- return -1;
- }
+ if(writeerr) {
+ *err = writeerr;
+ return -1;
+ }
data->req.bytecount += bv.bv_len + 2;
if(!binary) {
/* check for leading or trailing whitespace */
if(ISSPACE(bvals[i].bv_val[0]) ||
- ISSPACE(bvals[i].bv_val[bvals[i].bv_len-1]))
+ ISSPACE(bvals[i].bv_val[bvals[i].bv_len-1]))
binval = 1;
else {
/* check for unprintable characters */
unsigned int j;
- for(j=0; j<bvals[i].bv_len; j++)
+ for(j = 0; j<bvals[i].bv_len; j++)
if(!ISPRINT(bvals[i].bv_val[j])) {
binval = 1;
break;
@@ -580,7 +627,7 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
data->req.bytecount += 2;
if(val_b64_sz > 0) {
writeerr = Curl_client_write(conn, CLIENTWRITE_BODY, val_b64,
- val_b64_sz);
+ val_b64_sz);
if(writeerr) {
*err = writeerr;
return -1;
@@ -675,7 +722,7 @@ ldapsb_tls_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
ber_slen_t ret;
CURLcode err = CURLE_RECV_ERROR;
- ret = li->recv(conn, FIRSTSOCKET, buf, len, &err);
+ ret = (li->recv)(conn, FIRSTSOCKET, buf, len, &err);
if(ret < 0 && err == CURLE_AGAIN) {
SET_SOCKERRNO(EWOULDBLOCK);
}
@@ -690,7 +737,7 @@ ldapsb_tls_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t len)
ber_slen_t ret;
CURLcode err = CURLE_SEND_ERROR;
- ret = li->send(conn, FIRSTSOCKET, buf, len, &err);
+ ret = (li->send)(conn, FIRSTSOCKET, buf, len, &err);
if(ret < 0 && err == CURLE_AGAIN) {
SET_SOCKERRNO(EWOULDBLOCK);
}
diff --git a/Utilities/cmcurl/lib/parsedate.c b/Utilities/cmcurl/lib/parsedate.c
index 3c783be48..7ae5eb8cd 100644
--- a/Utilities/cmcurl/lib/parsedate.c
+++ b/Utilities/cmcurl/lib/parsedate.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -75,29 +75,13 @@
#include "curl_setup.h"
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#include <curl/curl.h>
#include "strcase.h"
#include "warnless.h"
#include "parsedate.h"
-const char * const Curl_wkday[] =
-{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
-static const char * const weekday[] =
-{ "Monday", "Tuesday", "Wednesday", "Thursday",
- "Friday", "Saturday", "Sunday" };
-const char * const Curl_month[]=
-{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
-
-struct tzinfo {
- char name[5];
- int offset; /* +/- in minutes */
-};
-
/*
* parsedate()
*
@@ -116,11 +100,28 @@ static int parsedate(const char *date, time_t *output);
#define PARSEDATE_LATER 1
#define PARSEDATE_SOONER 2
+#ifndef CURL_DISABLE_PARSEDATE
+
+const char * const Curl_wkday[] =
+{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
+static const char * const weekday[] =
+{ "Monday", "Tuesday", "Wednesday", "Thursday",
+ "Friday", "Saturday", "Sunday" };
+const char * const Curl_month[]=
+{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
+
+struct tzinfo {
+ char name[5];
+ int offset; /* +/- in minutes */
+};
+
/* Here's a bunch of frequently used time zone names. These were supported
by the old getdate parser. */
#define tDAYZONE -60 /* offset for daylight savings time */
static const struct tzinfo tz[]= {
{"GMT", 0}, /* Greenwich Mean */
+ {"UT", 0}, /* Universal Time */
{"UTC", 0}, /* Universal (Coordinated) */
{"WET", 0}, /* Western European */
{"BST", 0 tDAYZONE}, /* British Summer */
@@ -167,20 +168,20 @@ static const struct tzinfo tz[]= {
RFC 1123) had their signs wrong. Here we use the correct signs to match
actual military usage.
*/
- {"A", +1 * 60}, /* Alpha */
- {"B", +2 * 60}, /* Bravo */
- {"C", +3 * 60}, /* Charlie */
- {"D", +4 * 60}, /* Delta */
- {"E", +5 * 60}, /* Echo */
- {"F", +6 * 60}, /* Foxtrot */
- {"G", +7 * 60}, /* Golf */
- {"H", +8 * 60}, /* Hotel */
- {"I", +9 * 60}, /* India */
+ {"A", 1 * 60}, /* Alpha */
+ {"B", 2 * 60}, /* Bravo */
+ {"C", 3 * 60}, /* Charlie */
+ {"D", 4 * 60}, /* Delta */
+ {"E", 5 * 60}, /* Echo */
+ {"F", 6 * 60}, /* Foxtrot */
+ {"G", 7 * 60}, /* Golf */
+ {"H", 8 * 60}, /* Hotel */
+ {"I", 9 * 60}, /* India */
/* "J", Juliet is not used as a timezone, to indicate the observer's local
time */
- {"K", +10 * 60}, /* Kilo */
- {"L", +11 * 60}, /* Lima */
- {"M", +12 * 60}, /* Mike */
+ {"K", 10 * 60}, /* Kilo */
+ {"L", 11 * 60}, /* Lima */
+ {"M", 12 * 60}, /* Mike */
{"N", -1 * 60}, /* November */
{"O", -2 * 60}, /* Oscar */
{"P", -3 * 60}, /* Papa */
@@ -205,14 +206,14 @@ static int checkday(const char *check, size_t len)
{
int i;
const char * const *what;
- bool found= FALSE;
+ bool found = FALSE;
if(len > 3)
what = &weekday[0];
else
what = &Curl_wkday[0];
- for(i=0; i<7; i++) {
+ for(i = 0; i<7; i++) {
if(strcasecompare(check, what[0])) {
- found=TRUE;
+ found = TRUE;
break;
}
what++;
@@ -224,12 +225,12 @@ static int checkmonth(const char *check)
{
int i;
const char * const *what;
- bool found= FALSE;
+ bool found = FALSE;
what = &Curl_month[0];
- for(i=0; i<12; i++) {
+ for(i = 0; i<12; i++) {
if(strcasecompare(check, what[0])) {
- found=TRUE;
+ found = TRUE;
break;
}
what++;
@@ -244,12 +245,12 @@ static int checktz(const char *check)
{
unsigned int i;
const struct tzinfo *what;
- bool found= FALSE;
+ bool found = FALSE;
what = tz;
- for(i=0; i< sizeof(tz)/sizeof(tz[0]); i++) {
+ for(i = 0; i< sizeof(tz)/sizeof(tz[0]); i++) {
if(strcasecompare(check, what->name)) {
- found=TRUE;
+ found = TRUE;
break;
}
what++;
@@ -278,26 +279,23 @@ struct my_tm {
int tm_hour;
int tm_mday;
int tm_mon;
- int tm_year;
+ int tm_year; /* full year */
};
/* struct tm to time since epoch in GMT time zone.
* This is similar to the standard mktime function but for GMT only, and
* doesn't suffer from the various bugs and portability problems that
* some systems' implementations have.
+ *
+ * Returns 0 on success, otherwise non-zero.
*/
-static time_t my_timegm(struct my_tm *tm)
+static void my_timegm(struct my_tm *tm, time_t *t)
{
static const int month_days_cumulative [12] =
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
int month, year, leap_days;
- if(tm->tm_year < 70)
- /* we don't support years before 1970 as they will cause this function
- to return a negative value */
- return -1;
-
- year = tm->tm_year + 1900;
+ year = tm->tm_year;
month = tm->tm_mon;
if(month < 0) {
year += (11 - month) / 12;
@@ -312,9 +310,9 @@ static time_t my_timegm(struct my_tm *tm)
leap_days = ((leap_days / 4) - (leap_days / 100) + (leap_days / 400)
- (1969 / 4) + (1969 / 100) - (1969 / 400));
- return ((((time_t) (year - 1970) * 365
- + leap_days + month_days_cumulative [month] + tm->tm_mday - 1) * 24
- + tm->tm_hour) * 60 + tm->tm_min) * 60 + tm->tm_sec;
+ *t = ((((time_t) (year - 1970) * 365
+ + leap_days + month_days_cumulative[month] + tm->tm_mday - 1) * 24
+ + tm->tm_hour) * 60 + tm->tm_min) * 60 + tm->tm_sec;
}
/*
@@ -331,21 +329,21 @@ static time_t my_timegm(struct my_tm *tm)
static int parsedate(const char *date, time_t *output)
{
time_t t = 0;
- int wdaynum=-1; /* day of the week number, 0-6 (mon-sun) */
- int monnum=-1; /* month of the year number, 0-11 */
- int mdaynum=-1; /* day of month, 1 - 31 */
- int hournum=-1;
- int minnum=-1;
- int secnum=-1;
- int yearnum=-1;
- int tzoff=-1;
+ int wdaynum = -1; /* day of the week number, 0-6 (mon-sun) */
+ int monnum = -1; /* month of the year number, 0-11 */
+ int mdaynum = -1; /* day of month, 1 - 31 */
+ int hournum = -1;
+ int minnum = -1;
+ int secnum = -1;
+ int yearnum = -1;
+ int tzoff = -1;
struct my_tm tm;
enum assume dignext = DATE_MDAY;
const char *indate = date; /* save the original pointer */
int part = 0; /* max 6 parts */
while(*date && (part < 6)) {
- bool found=FALSE;
+ bool found = FALSE;
skip(&date);
@@ -386,7 +384,7 @@ static int parsedate(const char *date, time_t *output)
/* a digit */
int val;
char *end;
- int len=0;
+ int len = 0;
if((secnum == -1) &&
(3 == sscanf(date, "%02d:%02d:%02d%n",
&hournum, &minnum, &secnum, &len))) {
@@ -404,12 +402,12 @@ static int parsedate(const char *date, time_t *output)
int error;
int old_errno;
- old_errno = ERRNO;
- SET_ERRNO(0);
+ old_errno = errno;
+ errno = 0;
lval = strtol(date, &end, 10);
- error = ERRNO;
- if(error != old_errno)
- SET_ERRNO(old_errno);
+ error = errno;
+ if(errno != old_errno)
+ errno = old_errno;
if(error)
return PARSEDATE_FAIL;
@@ -438,7 +436,7 @@ static int parsedate(const char *date, time_t *output)
tzoff = (val/100 * 60 + val%100)*60;
/* the + and - prefix indicates the local time compared to GMT,
- this we need ther reversed math to get what we want */
+ this we need their reversed math to get what we want */
tzoff = date[-1]=='+'?-tzoff:tzoff;
}
@@ -464,7 +462,7 @@ static int parsedate(const char *date, time_t *output)
if(!found && (dignext == DATE_YEAR) && (yearnum == -1)) {
yearnum = val;
found = TRUE;
- if(yearnum < 1900) {
+ if(yearnum < 100) {
if(yearnum > 70)
yearnum += 1900;
else
@@ -493,18 +491,39 @@ static int parsedate(const char *date, time_t *output)
/* lacks vital info, fail */
return PARSEDATE_FAIL;
-#if SIZEOF_TIME_T < 5
- /* 32 bit time_t can only hold dates to the beginning of 2038 */
- if(yearnum > 2037) {
- *output = 0x7fffffff;
- return PARSEDATE_LATER;
+#ifdef HAVE_TIME_T_UNSIGNED
+ if(yearnum < 1970) {
+ /* only positive numbers cannot return earlier */
+ *output = TIME_T_MIN;
+ return PARSEDATE_SOONER;
}
#endif
- if(yearnum < 1970) {
- *output = 0;
+#if (SIZEOF_TIME_T < 5)
+
+#ifdef HAVE_TIME_T_UNSIGNED
+ /* an unsigned 32 bit time_t can only hold dates to 2106 */
+ if(yearnum > 2105) {
+ *output = TIME_T_MAX;
+ return PARSEDATE_LATER;
+ }
+#else
+ /* a signed 32 bit time_t can only hold dates to the beginning of 2038 */
+ if(yearnum > 2037) {
+ *output = TIME_T_MAX;
+ return PARSEDATE_LATER;
+ }
+ if(yearnum < 1903) {
+ *output = TIME_T_MIN;
return PARSEDATE_SOONER;
}
+#endif
+
+#else
+ /* The Gregorian calendar was introduced 1582 */
+ if(yearnum < 1583)
+ return PARSEDATE_FAIL;
+#endif
if((mdaynum > 31) || (monnum > 11) ||
(hournum > 23) || (minnum > 59) || (secnum > 60))
@@ -515,35 +534,38 @@ static int parsedate(const char *date, time_t *output)
tm.tm_hour = hournum;
tm.tm_mday = mdaynum;
tm.tm_mon = monnum;
- tm.tm_year = yearnum - 1900;
+ tm.tm_year = yearnum;
- /* my_timegm() returns a time_t. time_t is often 32 bits, even on many
- architectures that feature 64 bit 'long'.
-
- Some systems have 64 bit time_t and deal with years beyond 2038. However,
- even on some of the systems with 64 bit time_t mktime() returns -1 for
- dates beyond 03:14:07 UTC, January 19, 2038. (Such as AIX 5100-06)
+ /* my_timegm() returns a time_t. time_t is often 32 bits, sometimes even on
+ architectures that feature 64 bit 'long' but ultimately time_t is the
+ correct data type to use.
*/
- t = my_timegm(&tm);
-
- /* time zone adjust (cast t to int to compare to negative one) */
- if(-1 != (int)t) {
-
- /* Add the time zone diff between local time zone and GMT. */
- long delta = (long)(tzoff!=-1?tzoff:0);
+ my_timegm(&tm, &t);
- if((delta>0) && (t > LONG_MAX - delta)) {
- *output = 0x7fffffff;
- return PARSEDATE_LATER; /* time_t overflow */
- }
+ /* Add the time zone diff between local time zone and GMT. */
+ if(tzoff == -1)
+ tzoff = 0;
- t += delta;
+ if((tzoff > 0) && (t > TIME_T_MAX - tzoff)) {
+ *output = TIME_T_MAX;
+ return PARSEDATE_LATER; /* time_t overflow */
}
+ t += tzoff;
+
*output = t;
return PARSEDATE_OK;
}
+#else
+/* disabled */
+static int parsedate(const char *date, time_t *output)
+{
+ (void)date;
+ *output = 0;
+ return PARSEDATE_OK; /* a lie */
+}
+#endif
time_t curl_getdate(const char *p, const time_t *now)
{
@@ -551,10 +573,10 @@ time_t curl_getdate(const char *p, const time_t *now)
int rc = parsedate(p, &parsed);
(void)now; /* legacy argument from the past that we ignore */
- switch(rc) {
- case PARSEDATE_OK:
- case PARSEDATE_LATER:
- case PARSEDATE_SOONER:
+ if(rc == PARSEDATE_OK) {
+ if(parsed == -1)
+ /* avoid returning -1 for a working scenario */
+ parsed++;
return parsed;
}
/* everything else is fail */
diff --git a/Utilities/cmcurl/lib/parsedate.h b/Utilities/cmcurl/lib/parsedate.h
index 2e59eb17c..8dc3b90ec 100644
--- a/Utilities/cmcurl/lib/parsedate.h
+++ b/Utilities/cmcurl/lib/parsedate.h
@@ -28,4 +28,3 @@ extern const char * const Curl_month[12];
CURLcode Curl_gmtime(time_t intime, struct tm *store);
#endif /* HEADER_CURL_PARSEDATE_H */
-
diff --git a/Utilities/cmcurl/lib/pingpong.c b/Utilities/cmcurl/lib/pingpong.c
index 5ed79b718..e9568ee3d 100644
--- a/Utilities/cmcurl/lib/pingpong.c
+++ b/Utilities/cmcurl/lib/pingpong.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -44,13 +44,12 @@
/* Returns timeout in ms. 0 or negative number means the timeout has already
triggered */
-time_t Curl_pp_state_timeout(struct pingpong *pp)
+time_t Curl_pp_state_timeout(struct pingpong *pp, bool disconnecting)
{
struct connectdata *conn = pp->conn;
- struct Curl_easy *data=conn->data;
+ struct Curl_easy *data = conn->data;
time_t timeout_ms; /* in milliseconds */
- time_t timeout2_ms; /* in milliseconds */
- long response_time= (data->set.server_response_timeout)?
+ long response_time = (data->set.server_response_timeout)?
data->set.server_response_timeout: pp->response_time;
/* if CURLOPT_SERVER_RESPONSE_TIMEOUT is set, use that to determine
@@ -61,12 +60,12 @@ time_t Curl_pp_state_timeout(struct pingpong *pp)
/* Without a requested timeout, we only wait 'response_time' seconds for the
full response to arrive before we bail out */
timeout_ms = response_time -
- Curl_tvdiff(Curl_tvnow(), pp->response); /* spent time */
+ Curl_timediff(Curl_now(), pp->response); /* spent time */
- if(data->set.timeout) {
+ if(data->set.timeout && !disconnecting) {
/* if timeout is requested, find out how much remaining time we have */
- timeout2_ms = data->set.timeout - /* timeout time */
- Curl_tvdiff(Curl_tvnow(), conn->now); /* spent time */
+ time_t timeout2_ms = data->set.timeout - /* timeout time */
+ Curl_timediff(Curl_now(), conn->now); /* spent time */
/* pick the lowest number */
timeout_ms = CURLMIN(timeout_ms, timeout2_ms);
@@ -78,17 +77,18 @@ time_t Curl_pp_state_timeout(struct pingpong *pp)
/*
* Curl_pp_statemach()
*/
-CURLcode Curl_pp_statemach(struct pingpong *pp, bool block)
+CURLcode Curl_pp_statemach(struct pingpong *pp, bool block,
+ bool disconnecting)
{
struct connectdata *conn = pp->conn;
curl_socket_t sock = conn->sock[FIRSTSOCKET];
int rc;
time_t interval_ms;
- time_t timeout_ms = Curl_pp_state_timeout(pp);
- struct Curl_easy *data=conn->data;
+ time_t timeout_ms = Curl_pp_state_timeout(pp, disconnecting);
+ struct Curl_easy *data = conn->data;
CURLcode result = CURLE_OK;
- if(timeout_ms <=0) {
+ if(timeout_ms <= 0) {
failf(data, "server response timeout");
return CURLE_OPERATION_TIMEDOUT; /* already too little time */
}
@@ -120,7 +120,7 @@ CURLcode Curl_pp_statemach(struct pingpong *pp, bool block)
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
else
- result = Curl_speedcheck(data, Curl_tvnow());
+ result = Curl_speedcheck(data, Curl_now());
if(result)
return result;
@@ -143,7 +143,7 @@ void Curl_pp_init(struct pingpong *pp)
pp->nread_resp = 0;
pp->linestart_resp = conn->data->state.buffer;
pp->pending_resp = TRUE;
- pp->response = Curl_tvnow(); /* start response time-out now! */
+ pp->response = Curl_now(); /* start response time-out now! */
}
@@ -168,16 +168,22 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
char *s;
CURLcode result;
struct connectdata *conn = pp->conn;
- struct Curl_easy *data = conn->data;
+ struct Curl_easy *data;
#ifdef HAVE_GSSAPI
- enum protection_level data_sec = conn->data_prot;
+ enum protection_level data_sec;
#endif
DEBUGASSERT(pp->sendleft == 0);
DEBUGASSERT(pp->sendsize == 0);
DEBUGASSERT(pp->sendthis == NULL);
+ if(!conn)
+ /* can't send without a connection! */
+ return CURLE_SEND_ERROR;
+
+ data = conn->data;
+
fmt_crlf = aprintf("%s\r\n", fmt); /* append a trailing CRLF */
if(!fmt_crlf)
return CURLE_OUT_OF_MEMORY;
@@ -205,6 +211,7 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
result = Curl_write(conn, conn->sock[FIRSTSOCKET], s, write_len,
&bytes_written);
#ifdef HAVE_GSSAPI
+ data_sec = conn->data_prot;
DEBUGASSERT(data_sec > PROT_NONE && data_sec < PROT_LAST);
conn->data_prot = data_sec;
#endif
@@ -215,8 +222,7 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
}
if(conn->data->set.verbose)
- Curl_debug(conn->data, CURLINFO_HEADER_OUT,
- s, (size_t)bytes_written, conn);
+ Curl_debug(conn->data, CURLINFO_HEADER_OUT, s, (size_t)bytes_written);
if(bytes_written != (ssize_t)write_len) {
/* the whole chunk was not sent, keep it around and adjust sizes */
@@ -228,7 +234,7 @@ CURLcode Curl_pp_vsendf(struct pingpong *pp,
free(s);
pp->sendthis = NULL;
pp->sendleft = pp->sendsize = 0;
- pp->response = Curl_tvnow();
+ pp->response = Curl_now();
}
return CURLE_OK;
@@ -270,7 +276,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
size_t *size) /* size of the response */
{
ssize_t perline; /* count bytes per line */
- bool keepon=TRUE;
+ bool keepon = TRUE;
ssize_t gotbytes;
char *ptr;
struct connectdata *conn = pp->conn;
@@ -281,7 +287,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
*code = 0; /* 0 for errors or not done */
*size = 0;
- ptr=buf + pp->nread_resp;
+ ptr = buf + pp->nread_resp;
/* number of bytes in the current line, so far */
perline = (ssize_t)(ptr-pp->linestart_resp);
@@ -297,7 +303,10 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
* it would have been populated with something of size int to begin
* with, even though its datatype may be larger than an int.
*/
- DEBUGASSERT((ptr+pp->cache_size) <= (buf+data->set.buffer_size+1));
+ if((ptr + pp->cache_size) > (buf + data->set.buffer_size + 1)) {
+ failf(data, "cached response data too big to handle");
+ return CURLE_RECV_ERROR;
+ }
memcpy(ptr, pp->cache, pp->cache_size);
gotbytes = (ssize_t)pp->cache_size;
free(pp->cache); /* free the cache */
@@ -351,7 +360,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
pp->nread_resp += gotbytes;
for(i = 0; i < gotbytes; ptr++, i++) {
perline++;
- if(*ptr=='\n') {
+ if(*ptr == '\n') {
/* a newline is CRLF in pp-talk, so the CR is ignored as
the line isn't really terminated until the LF comes */
@@ -361,7 +370,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
#endif
if(data->set.verbose)
Curl_debug(data, CURLINFO_HEADER_IN,
- pp->linestart_resp, (size_t)perline, conn);
+ pp->linestart_resp, (size_t)perline);
/*
* We pass all response-lines to the callback function registered
@@ -378,17 +387,17 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd,
start of the buffer and zero terminate, for old times sake */
size_t n = ptr - pp->linestart_resp;
memmove(buf, pp->linestart_resp, n);
- buf[n]=0; /* zero terminate */
- keepon=FALSE;
- pp->linestart_resp = ptr+1; /* advance pointer */
+ buf[n] = 0; /* zero terminate */
+ keepon = FALSE;
+ pp->linestart_resp = ptr + 1; /* advance pointer */
i++; /* skip this before getting out */
*size = pp->nread_resp; /* size of the response */
pp->nread_resp = 0; /* restart */
break;
}
- perline=0; /* line starts over here */
- pp->linestart_resp = ptr+1;
+ perline = 0; /* line starts over here */
+ pp->linestart_resp = ptr + 1;
}
}
@@ -490,9 +499,9 @@ CURLcode Curl_pp_flushsend(struct pingpong *pp)
}
else {
free(pp->sendthis);
- pp->sendthis=NULL;
+ pp->sendthis = NULL;
pp->sendleft = pp->sendsize = 0;
- pp->response = Curl_tvnow();
+ pp->response = Curl_now();
}
return CURLE_OK;
}
diff --git a/Utilities/cmcurl/lib/pingpong.h b/Utilities/cmcurl/lib/pingpong.h
index ee1a59b51..dbe1f8d3d 100644
--- a/Utilities/cmcurl/lib/pingpong.h
+++ b/Utilities/cmcurl/lib/pingpong.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -58,8 +58,8 @@ struct pingpong {
server */
size_t sendleft; /* number of bytes left to send from the sendthis buffer */
size_t sendsize; /* total size of the sendthis buffer */
- struct timeval response; /* set to Curl_tvnow() when a command has been sent
- off, used to time-out response reading */
+ struct curltime response; /* set to Curl_now() when a command has been sent
+ off, used to time-out response reading */
long response_time; /* When no timeout is given, this is the amount of
milliseconds we await for a server response. */
@@ -81,14 +81,15 @@ struct pingpong {
* called repeatedly until done. Set 'wait' to make it wait a while on the
* socket if there's no traffic.
*/
-CURLcode Curl_pp_statemach(struct pingpong *pp, bool block);
+CURLcode Curl_pp_statemach(struct pingpong *pp, bool block,
+ bool disconnecting);
/* initialize stuff to prepare for reading a fresh new response */
void Curl_pp_init(struct pingpong *pp);
/* Returns timeout in ms. 0 or negative number means the timeout has already
triggered */
-time_t Curl_pp_state_timeout(struct pingpong *pp);
+time_t Curl_pp_state_timeout(struct pingpong *pp, bool disconnecting);
/***********************************************************************
diff --git a/Utilities/cmcurl/lib/pipeline.c b/Utilities/cmcurl/lib/pipeline.c
deleted file mode 100644
index b8d203745..000000000
--- a/Utilities/cmcurl/lib/pipeline.c
+++ /dev/null
@@ -1,410 +0,0 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2013, Linus Nielsen Feltzing, <linus@haxx.se>
- * Copyright (C) 2013 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.haxx.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#include "curl_setup.h"
-
-#include <curl/curl.h>
-
-#include "urldata.h"
-#include "url.h"
-#include "progress.h"
-#include "multiif.h"
-#include "pipeline.h"
-#include "sendf.h"
-#include "strcase.h"
-
-#include "curl_memory.h"
-/* The last #include file should be: */
-#include "memdebug.h"
-
-struct site_blacklist_entry {
- struct curl_llist_element list;
- unsigned short port;
- char hostname[1];
-};
-
-static void site_blacklist_llist_dtor(void *user, void *element)
-{
- struct site_blacklist_entry *entry = element;
- (void)user;
- free(entry);
-}
-
-static void server_blacklist_llist_dtor(void *user, void *element)
-{
- (void)user;
- free(element);
-}
-
-bool Curl_pipeline_penalized(struct Curl_easy *data,
- struct connectdata *conn)
-{
- if(data) {
- bool penalized = FALSE;
- curl_off_t penalty_size =
- Curl_multi_content_length_penalty_size(data->multi);
- curl_off_t chunk_penalty_size =
- Curl_multi_chunk_length_penalty_size(data->multi);
- curl_off_t recv_size = -2; /* Make it easy to spot in the log */
-
- /* Find the head of the recv pipe, if any */
- if(conn->recv_pipe.head) {
- struct Curl_easy *recv_handle = conn->recv_pipe.head->ptr;
-
- recv_size = recv_handle->req.size;
-
- if(penalty_size > 0 && recv_size > penalty_size)
- penalized = TRUE;
- }
-
- if(chunk_penalty_size > 0 &&
- (curl_off_t)conn->chunk.datasize > chunk_penalty_size)
- penalized = TRUE;
-
- infof(data, "Conn: %ld (%p) Receive pipe weight: (%"
- CURL_FORMAT_CURL_OFF_T "/%zu), penalized: %s\n",
- conn->connection_id, (void *)conn, recv_size,
- conn->chunk.datasize, penalized?"TRUE":"FALSE");
- return penalized;
- }
- return FALSE;
-}
-
-static CURLcode addHandleToPipeline(struct Curl_easy *data,
- struct curl_llist *pipeline)
-{
- Curl_llist_insert_next(pipeline, pipeline->tail, data,
- &data->pipeline_queue);
- return CURLE_OK;
-}
-
-
-CURLcode Curl_add_handle_to_pipeline(struct Curl_easy *handle,
- struct connectdata *conn)
-{
- struct curl_llist_element *sendhead = conn->send_pipe.head;
- struct curl_llist *pipeline;
- CURLcode result;
-
- pipeline = &conn->send_pipe;
-
- result = addHandleToPipeline(handle, pipeline);
-
- if(pipeline == &conn->send_pipe && sendhead != conn->send_pipe.head) {
- /* this is a new one as head, expire it */
- Curl_pipeline_leave_write(conn); /* not in use yet */
- Curl_expire(conn->send_pipe.head->ptr, 0, EXPIRE_RUN_NOW);
- }
-
-#if 0 /* enable for pipeline debugging */
- print_pipeline(conn);
-#endif
-
- return result;
-}
-
-/* Move this transfer from the sending list to the receiving list.
-
- Pay special attention to the new sending list "leader" as it needs to get
- checked to update what sockets it acts on.
-
-*/
-void Curl_move_handle_from_send_to_recv_pipe(struct Curl_easy *handle,
- struct connectdata *conn)
-{
- struct curl_llist_element *curr;
-
- curr = conn->send_pipe.head;
- while(curr) {
- if(curr->ptr == handle) {
- Curl_llist_move(&conn->send_pipe, curr,
- &conn->recv_pipe, conn->recv_pipe.tail);
-
- if(conn->send_pipe.head) {
- /* Since there's a new easy handle at the start of the send pipeline,
- set its timeout value to 1ms to make it trigger instantly */
- Curl_pipeline_leave_write(conn); /* not used now */
-#ifdef DEBUGBUILD
- infof(conn->data, "%p is at send pipe head B!\n",
- (void *)conn->send_pipe.head->ptr);
-#endif
- Curl_expire(conn->send_pipe.head->ptr, 0, EXPIRE_RUN_NOW);
- }
-
- /* The receiver's list is not really interesting here since either this
- handle is now first in the list and we'll deal with it soon, or
- another handle is already first and thus is already taken care of */
-
- break; /* we're done! */
- }
- curr = curr->next;
- }
-}
-
-bool Curl_pipeline_site_blacklisted(struct Curl_easy *handle,
- struct connectdata *conn)
-{
- if(handle->multi) {
- struct curl_llist *blacklist =
- Curl_multi_pipelining_site_bl(handle->multi);
-
- if(blacklist) {
- struct curl_llist_element *curr;
-
- curr = blacklist->head;
- while(curr) {
- struct site_blacklist_entry *site;
-
- site = curr->ptr;
- if(strcasecompare(site->hostname, conn->host.name) &&
- site->port == conn->remote_port) {
- infof(handle, "Site %s:%d is pipeline blacklisted\n",
- conn->host.name, conn->remote_port);
- return TRUE;
- }
- curr = curr->next;
- }
- }
- }
- return FALSE;
-}
-
-CURLMcode Curl_pipeline_set_site_blacklist(char **sites,
- struct curl_llist *list)
-{
- /* Free the old list */
- if(list->size)
- Curl_llist_destroy(list, NULL);
-
- if(sites) {
- Curl_llist_init(list, (curl_llist_dtor) site_blacklist_llist_dtor);
-
- /* Parse the URLs and populate the list */
- while(*sites) {
- char *port;
- struct site_blacklist_entry *entry;
-
- entry = malloc(sizeof(struct site_blacklist_entry) + strlen(*sites));
- if(!entry) {
- Curl_llist_destroy(list, NULL);
- return CURLM_OUT_OF_MEMORY;
- }
- strcpy(entry->hostname, *sites);
-
- port = strchr(entry->hostname, ':');
- if(port) {
- *port = '\0';
- port++;
- entry->port = (unsigned short)strtol(port, NULL, 10);
- }
- else {
- /* Default port number for HTTP */
- entry->port = 80;
- }
-
- Curl_llist_insert_next(list, list->tail, entry, &entry->list);
- sites++;
- }
- }
-
- return CURLM_OK;
-}
-
-bool Curl_pipeline_server_blacklisted(struct Curl_easy *handle,
- char *server_name)
-{
- if(handle->multi && server_name) {
- struct curl_llist *blacklist =
- Curl_multi_pipelining_server_bl(handle->multi);
-
- if(blacklist) {
- struct curl_llist_element *curr;
-
- curr = blacklist->head;
- while(curr) {
- char *bl_server_name;
-
- bl_server_name = curr->ptr;
- if(strncasecompare(bl_server_name, server_name,
- strlen(bl_server_name))) {
- infof(handle, "Server %s is blacklisted\n", server_name);
- return TRUE;
- }
- curr = curr->next;
- }
- }
-
- DEBUGF(infof(handle, "Server %s is not blacklisted\n", server_name));
- }
- return FALSE;
-}
-
-struct blacklist_node {
- struct curl_llist_element list;
- char server_name[1];
-};
-
-CURLMcode Curl_pipeline_set_server_blacklist(char **servers,
- struct curl_llist *list)
-{
- /* Free the old list */
- if(list->size)
- Curl_llist_destroy(list, NULL);
-
- if(servers) {
- Curl_llist_init(list, (curl_llist_dtor) server_blacklist_llist_dtor);
-
- /* Parse the URLs and populate the list */
- while(*servers) {
- struct blacklist_node *n;
- size_t len = strlen(*servers);
-
- n = malloc(sizeof(struct blacklist_node) + len);
- if(!n) {
- Curl_llist_destroy(list, NULL);
- return CURLM_OUT_OF_MEMORY;
- }
- strcpy(n->server_name, *servers);
-
- Curl_llist_insert_next(list, list->tail, n->server_name,
- &n->list);
- servers++;
- }
- }
-
-
- return CURLM_OK;
-}
-
-static bool pipe_head(struct Curl_easy *data,
- struct curl_llist *pipeline)
-{
- if(pipeline) {
- struct curl_llist_element *curr = pipeline->head;
- if(curr)
- return (curr->ptr == data) ? TRUE : FALSE;
- }
- return FALSE;
-}
-
-/* returns TRUE if the given handle is head of the recv pipe */
-bool Curl_recvpipe_head(struct Curl_easy *data,
- struct connectdata *conn)
-{
- return pipe_head(data, &conn->recv_pipe);
-}
-
-/* returns TRUE if the given handle is head of the send pipe */
-bool Curl_sendpipe_head(struct Curl_easy *data,
- struct connectdata *conn)
-{
- return pipe_head(data, &conn->send_pipe);
-}
-
-
-/*
- * Check if the write channel is available and this handle as at the head,
- * then grab the channel and return TRUE.
- *
- * If not available, return FALSE.
- */
-
-bool Curl_pipeline_checkget_write(struct Curl_easy *data,
- struct connectdata *conn)
-{
- if(conn->bits.multiplex)
- /* when multiplexing, we can use it at once */
- return TRUE;
-
- if(!conn->writechannel_inuse && Curl_sendpipe_head(data, conn)) {
- /* Grab the channel */
- conn->writechannel_inuse = TRUE;
- return TRUE;
- }
- return FALSE;
-}
-
-
-/*
- * Check if the read channel is available and this handle as at the head, then
- * grab the channel and return TRUE.
- *
- * If not available, return FALSE.
- */
-
-bool Curl_pipeline_checkget_read(struct Curl_easy *data,
- struct connectdata *conn)
-{
- if(conn->bits.multiplex)
- /* when multiplexing, we can use it at once */
- return TRUE;
-
- if(!conn->readchannel_inuse && Curl_recvpipe_head(data, conn)) {
- /* Grab the channel */
- conn->readchannel_inuse = TRUE;
- return TRUE;
- }
- return FALSE;
-}
-
-/*
- * The current user of the pipeline write channel gives it up.
- */
-void Curl_pipeline_leave_write(struct connectdata *conn)
-{
- conn->writechannel_inuse = FALSE;
-}
-
-/*
- * The current user of the pipeline read channel gives it up.
- */
-void Curl_pipeline_leave_read(struct connectdata *conn)
-{
- conn->readchannel_inuse = FALSE;
-}
-
-
-#if 0
-void print_pipeline(struct connectdata *conn)
-{
- struct curl_llist_element *curr;
- struct connectbundle *cb_ptr;
- struct Curl_easy *data = conn->data;
-
- cb_ptr = conn->bundle;
-
- if(cb_ptr) {
- curr = cb_ptr->conn_list->head;
- while(curr) {
- conn = curr->ptr;
- infof(data, "- Conn %ld (%p) send_pipe: %zu, recv_pipe: %zu\n",
- conn->connection_id,
- (void *)conn,
- conn->send_pipe->size,
- conn->recv_pipe->size);
- curr = curr->next;
- }
- }
-}
-
-#endif
diff --git a/Utilities/cmcurl/lib/pipeline.h b/Utilities/cmcurl/lib/pipeline.h
deleted file mode 100644
index 413ba31a0..000000000
--- a/Utilities/cmcurl/lib/pipeline.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef HEADER_CURL_PIPELINE_H
-#define HEADER_CURL_PIPELINE_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2015 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
- * Copyright (C) 2013 - 2014, Linus Nielsen Feltzing, <linus@haxx.se>
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.haxx.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-CURLcode Curl_add_handle_to_pipeline(struct Curl_easy *handle,
- struct connectdata *conn);
-void Curl_move_handle_from_send_to_recv_pipe(struct Curl_easy *handle,
- struct connectdata *conn);
-bool Curl_pipeline_penalized(struct Curl_easy *data,
- struct connectdata *conn);
-
-bool Curl_pipeline_site_blacklisted(struct Curl_easy *handle,
- struct connectdata *conn);
-
-CURLMcode Curl_pipeline_set_site_blacklist(char **sites,
- struct curl_llist *list_ptr);
-
-bool Curl_pipeline_server_blacklisted(struct Curl_easy *handle,
- char *server_name);
-
-CURLMcode Curl_pipeline_set_server_blacklist(char **servers,
- struct curl_llist *list_ptr);
-
-bool Curl_pipeline_checkget_write(struct Curl_easy *data,
- struct connectdata *conn);
-bool Curl_pipeline_checkget_read(struct Curl_easy *data,
- struct connectdata *conn);
-void Curl_pipeline_leave_write(struct connectdata *conn);
-void Curl_pipeline_leave_read(struct connectdata *conn);
-bool Curl_recvpipe_head(struct Curl_easy *data,
- struct connectdata *conn);
-bool Curl_sendpipe_head(struct Curl_easy *data,
- struct connectdata *conn);
-
-#endif /* HEADER_CURL_PIPELINE_H */
diff --git a/Utilities/cmcurl/lib/pop3.c b/Utilities/cmcurl/lib/pop3.c
index 3feb3be83..c8f3965e4 100644
--- a/Utilities/cmcurl/lib/pop3.c
+++ b/Utilities/cmcurl/lib/pop3.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -30,6 +30,7 @@
* RFC4752 The Kerberos V5 ("GSSAPI") SASL Mechanism
* RFC5034 POP3 SASL Authentication Mechanism
* RFC6749 OAuth 2.0 Authorization Framework
+ * RFC8314 Use of TLS for Email Submission and Access
* Draft LOGIN SASL Mechanism <draft-murchison-sasl-login-00.txt>
*
***************************************************************************/
@@ -125,6 +126,7 @@ const struct Curl_handler Curl_handler_pop3 = {
ZERO_NULL, /* perform_getsock */
pop3_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_POP3, /* defport */
CURLPROTO_POP3, /* protocol */
PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */
@@ -151,6 +153,7 @@ const struct Curl_handler Curl_handler_pop3s = {
ZERO_NULL, /* perform_getsock */
pop3_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_POP3S, /* defport */
CURLPROTO_POP3S, /* protocol */
PROTOPT_CLOSEACTION | PROTOPT_SSL
@@ -158,58 +161,6 @@ const struct Curl_handler Curl_handler_pop3s = {
};
#endif
-#ifndef CURL_DISABLE_HTTP
-/*
- * HTTP-proxyed POP3 protocol handler.
- */
-
-static const struct Curl_handler Curl_handler_pop3_proxy = {
- "POP3", /* scheme */
- Curl_http_setup_conn, /* setup_connection */
- Curl_http, /* do_it */
- Curl_http_done, /* done */
- ZERO_NULL, /* do_more */
- ZERO_NULL, /* connect_it */
- ZERO_NULL, /* connecting */
- ZERO_NULL, /* doing */
- ZERO_NULL, /* proto_getsock */
- ZERO_NULL, /* doing_getsock */
- ZERO_NULL, /* domore_getsock */
- ZERO_NULL, /* perform_getsock */
- ZERO_NULL, /* disconnect */
- ZERO_NULL, /* readwrite */
- PORT_POP3, /* defport */
- CURLPROTO_HTTP, /* protocol */
- PROTOPT_NONE /* flags */
-};
-
-#ifdef USE_SSL
-/*
- * HTTP-proxyed POP3S protocol handler.
- */
-
-static const struct Curl_handler Curl_handler_pop3s_proxy = {
- "POP3S", /* scheme */
- Curl_http_setup_conn, /* setup_connection */
- Curl_http, /* do_it */
- Curl_http_done, /* done */
- ZERO_NULL, /* do_more */
- ZERO_NULL, /* connect_it */
- ZERO_NULL, /* connecting */
- ZERO_NULL, /* doing */
- ZERO_NULL, /* proto_getsock */
- ZERO_NULL, /* doing_getsock */
- ZERO_NULL, /* domore_getsock */
- ZERO_NULL, /* perform_getsock */
- ZERO_NULL, /* disconnect */
- ZERO_NULL, /* readwrite */
- PORT_POP3S, /* defport */
- CURLPROTO_HTTP, /* protocol */
- PROTOPT_NONE /* flags */
-};
-#endif
-#endif
-
/* SASL parameters for the pop3 protocol */
static const struct SASLproto saslpop3 = {
"pop", /* The service name */
@@ -258,7 +209,7 @@ static bool pop3_endofresp(struct connectdata *conn, char *line, size_t len,
/* Are we processing CAPA command responses? */
if(pop3c->state == POP3_CAPA) {
/* Do we have the terminating line? */
- if(len >= 1 && !memcmp(line, ".", 1))
+ if(len >= 1 && line[0] == '.')
/* Treat the response as a success */
*resp = '+';
else
@@ -276,7 +227,7 @@ static bool pop3_endofresp(struct connectdata *conn, char *line, size_t len,
}
/* Do we have a continuation response? */
- if(len >= 1 && !memcmp("+", line, 1)) {
+ if(len >= 1 && line[0] == '+') {
*resp = '*';
return TRUE;
@@ -293,23 +244,30 @@ static bool pop3_endofresp(struct connectdata *conn, char *line, size_t len,
*/
static void pop3_get_message(char *buffer, char **outptr)
{
- size_t len = 0;
+ size_t len = strlen(buffer);
char *message = NULL;
- /* Find the start of the message */
- for(message = buffer + 2; *message == ' ' || *message == '\t'; message++)
- ;
-
- /* Find the end of the message */
- for(len = strlen(message); len--;)
- if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' &&
- message[len] != '\t')
- break;
-
- /* Terminate the message */
- if(++len) {
- message[len] = '\0';
+ if(len > 2) {
+ /* Find the start of the message */
+ len -= 2;
+ for(message = buffer + 2; *message == ' ' || *message == '\t';
+ message++, len--)
+ ;
+
+ /* Find the end of the message */
+ for(; len--;)
+ if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' &&
+ message[len] != '\t')
+ break;
+
+ /* Terminate the message */
+ if(++len) {
+ message[len] = '\0';
+ }
}
+ else
+ /* junk input => zero length output */
+ message = &buffer[len];
*outptr = message;
}
@@ -486,7 +444,7 @@ static CURLcode pop3_perform_apop(struct connectdata *conn)
/* Convert the calculated 16 octet digest into a 32 byte hex string */
for(i = 0; i < MD5_DIGEST_LEN; i++)
- snprintf(&secret[2 * i], 3, "%02x", digest[i]);
+ msnprintf(&secret[2 * i], 3, "%02x", digest[i]);
result = Curl_pp_sendf(&pop3c->pp, "APOP %s %s", conn->user, secret);
@@ -656,7 +614,6 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn,
struct pop3_conn *pop3c = &conn->proto.pop3c;
const char *line = data->state.buffer;
size_t len = strlen(line);
- size_t i;
(void)instate; /* no use for this yet */
@@ -668,10 +625,12 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn,
/* Does the server support APOP authentication? */
if(len >= 4 && line[len - 2] == '>') {
/* Look for the APOP timestamp */
+ size_t i;
for(i = 3; i < len - 2; ++i) {
if(line[i] == '<') {
/* Calculate the length of the timestamp */
size_t timestamplen = len - 1 - i;
+ char *at;
if(!timestamplen)
break;
@@ -685,8 +644,15 @@ static CURLcode pop3_state_servergreet_resp(struct connectdata *conn,
memcpy(pop3c->apoptimestamp, line + i, timestamplen);
pop3c->apoptimestamp[timestamplen] = '\0';
- /* Store the APOP capability */
- pop3c->authtypes |= POP3_TYPE_APOP;
+ /* If the timestamp does not contain '@' it is not (as required by
+ RFC-1939) conformant to the RFC-822 message id syntax, and we
+ therefore do not use APOP authentication. */
+ at = strchr(pop3c->apoptimestamp, '@');
+ if(!at)
+ Curl_safefree(pop3c->apoptimestamp);
+ else
+ /* Store the APOP capability */
+ pop3c->authtypes |= POP3_TYPE_APOP;
break;
}
}
@@ -707,7 +673,6 @@ static CURLcode pop3_state_capa_resp(struct connectdata *conn, int pop3code,
struct pop3_conn *pop3c = &conn->proto.pop3c;
const char *line = data->state.buffer;
size_t len = strlen(line);
- size_t wordlen;
(void)instate; /* no use for this yet */
@@ -732,6 +697,7 @@ static CURLcode pop3_state_capa_resp(struct connectdata *conn, int pop3code,
/* Loop through the data line */
for(;;) {
size_t llen;
+ size_t wordlen;
unsigned int mechbit;
while(len &&
@@ -947,7 +913,7 @@ static CURLcode pop3_state_command_resp(struct connectdata *conn,
if(pop3->transfer == FTPTRANSFER_BODY) {
/* POP3 download */
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, FALSE, -1);
if(pp->cache) {
/* The header "cache" contains a bunch of data that is actually body
@@ -1060,19 +1026,20 @@ static CURLcode pop3_multi_statemach(struct connectdata *conn, bool *done)
return result;
}
- result = Curl_pp_statemach(&pop3c->pp, FALSE);
+ result = Curl_pp_statemach(&pop3c->pp, FALSE, FALSE);
*done = (pop3c->state == POP3_STOP) ? TRUE : FALSE;
return result;
}
-static CURLcode pop3_block_statemach(struct connectdata *conn)
+static CURLcode pop3_block_statemach(struct connectdata *conn,
+ bool disconnecting)
{
CURLcode result = CURLE_OK;
struct pop3_conn *pop3c = &conn->proto.pop3c;
while(pop3c->state != POP3_STOP && !result)
- result = Curl_pp_statemach(&pop3c->pp, TRUE);
+ result = Curl_pp_statemach(&pop3c->pp, TRUE, disconnecting);
return result;
}
@@ -1270,7 +1237,7 @@ static CURLcode pop3_disconnect(struct connectdata *conn, bool dead_connection)
point! */
if(!dead_connection && pop3c->pp.conn && pop3c->pp.conn->bits.protoconnstart)
if(!pop3_perform_quit(conn))
- (void)pop3_block_statemach(conn); /* ignore errors on QUIT */
+ (void)pop3_block_statemach(conn, TRUE); /* ignore errors on QUIT */
/* Disconnect from the server */
Curl_pp_disconnect(&pop3c->pp);
@@ -1346,8 +1313,6 @@ static CURLcode pop3_regular_transfer(struct connectdata *conn,
static CURLcode pop3_setup_connection(struct connectdata *conn)
{
- struct Curl_easy *data = conn->data;
-
/* Initialise the POP3 layer */
CURLcode result = pop3_init(conn);
if(result)
@@ -1356,32 +1321,6 @@ static CURLcode pop3_setup_connection(struct connectdata *conn)
/* Clear the TLS upgraded flag */
conn->tls_upgraded = FALSE;
- /* Set up the proxy if necessary */
- if(conn->bits.httpproxy && !data->set.tunnel_thru_httpproxy) {
- /* Unless we have asked to tunnel POP3 operations through the proxy, we
- switch and use HTTP operations only */
-#ifndef CURL_DISABLE_HTTP
- if(conn->handler == &Curl_handler_pop3)
- conn->handler = &Curl_handler_pop3_proxy;
- else {
-#ifdef USE_SSL
- conn->handler = &Curl_handler_pop3s_proxy;
-#else
- failf(data, "POP3S not supported!");
- return CURLE_UNSUPPORTED_PROTOCOL;
-#endif
- }
-
- /* set it up as an HTTP connection instead */
- return conn->handler->setup_connection(conn);
-#else
- failf(data, "POP3 over http proxy requires HTTP support built-in!");
- return CURLE_UNSUPPORTED_PROTOCOL;
-#endif
- }
-
- data->state.path++; /* don't include the initial slash */
-
return CURLE_OK;
}
@@ -1455,7 +1394,7 @@ static CURLcode pop3_parse_url_path(struct connectdata *conn)
/* The POP3 struct is already initialised in pop3_connect() */
struct Curl_easy *data = conn->data;
struct POP3 *pop3 = data->req.protop;
- const char *path = data->state.path;
+ const char *path = &data->state.up.path[1]; /* skip leading path */
/* URL decode the path for the message ID */
return Curl_urldecode(data, path, 0, &pop3->id, NULL, TRUE);
diff --git a/Utilities/cmcurl/lib/progress.c b/Utilities/cmcurl/lib/progress.c
index cfaf4049e..f586d59b4 100644
--- a/Utilities/cmcurl/lib/progress.c
+++ b/Utilities/cmcurl/lib/progress.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -24,35 +24,40 @@
#include "urldata.h"
#include "sendf.h"
+#include "multiif.h"
#include "progress.h"
#include "curl_printf.h"
+/* check rate limits within this many recent milliseconds, at minimum. */
+#define MIN_RATE_LIMIT_PERIOD 3000
+
+#ifndef CURL_DISABLE_PROGRESS_METER
/* Provide a string that is 2 + 1 + 2 + 1 + 2 = 8 letters long (plus the zero
byte) */
static void time2str(char *r, curl_off_t seconds)
{
- curl_off_t d, h, m, s;
+ curl_off_t h;
if(seconds <= 0) {
strcpy(r, "--:--:--");
return;
}
h = seconds / CURL_OFF_T_C(3600);
if(h <= CURL_OFF_T_C(99)) {
- m = (seconds - (h*CURL_OFF_T_C(3600))) / CURL_OFF_T_C(60);
- s = (seconds - (h*CURL_OFF_T_C(3600))) - (m*CURL_OFF_T_C(60));
- snprintf(r, 9, "%2" CURL_FORMAT_CURL_OFF_T ":%02" CURL_FORMAT_CURL_OFF_T
- ":%02" CURL_FORMAT_CURL_OFF_T, h, m, s);
+ curl_off_t m = (seconds - (h*CURL_OFF_T_C(3600))) / CURL_OFF_T_C(60);
+ curl_off_t s = (seconds - (h*CURL_OFF_T_C(3600))) - (m*CURL_OFF_T_C(60));
+ msnprintf(r, 9, "%2" CURL_FORMAT_CURL_OFF_T ":%02" CURL_FORMAT_CURL_OFF_T
+ ":%02" CURL_FORMAT_CURL_OFF_T, h, m, s);
}
else {
/* this equals to more than 99 hours, switch to a more suitable output
format to fit within the limits. */
- d = seconds / CURL_OFF_T_C(86400);
+ curl_off_t d = seconds / CURL_OFF_T_C(86400);
h = (seconds - (d*CURL_OFF_T_C(86400))) / CURL_OFF_T_C(3600);
if(d <= CURL_OFF_T_C(999))
- snprintf(r, 9, "%3" CURL_FORMAT_CURL_OFF_T
- "d %02" CURL_FORMAT_CURL_OFF_T "h", d, h);
+ msnprintf(r, 9, "%3" CURL_FORMAT_CURL_OFF_T
+ "d %02" CURL_FORMAT_CURL_OFF_T "h", d, h);
else
- snprintf(r, 9, "%7" CURL_FORMAT_CURL_OFF_T "d", d);
+ msnprintf(r, 9, "%7" CURL_FORMAT_CURL_OFF_T "d", d);
}
}
@@ -68,40 +73,40 @@ static char *max5data(curl_off_t bytes, char *max5)
#define ONE_PETABYTE (CURL_OFF_T_C(1024) * ONE_TERABYTE)
if(bytes < CURL_OFF_T_C(100000))
- snprintf(max5, 6, "%5" CURL_FORMAT_CURL_OFF_T, bytes);
+ msnprintf(max5, 6, "%5" CURL_FORMAT_CURL_OFF_T, bytes);
else if(bytes < CURL_OFF_T_C(10000) * ONE_KILOBYTE)
- snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "k", bytes/ONE_KILOBYTE);
+ msnprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "k", bytes/ONE_KILOBYTE);
else if(bytes < CURL_OFF_T_C(100) * ONE_MEGABYTE)
/* 'XX.XM' is good as long as we're less than 100 megs */
- snprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
- CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE,
- (bytes%ONE_MEGABYTE) / (ONE_MEGABYTE/CURL_OFF_T_C(10)) );
+ msnprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
+ CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE,
+ (bytes%ONE_MEGABYTE) / (ONE_MEGABYTE/CURL_OFF_T_C(10)) );
#if (CURL_SIZEOF_CURL_OFF_T > 4)
else if(bytes < CURL_OFF_T_C(10000) * ONE_MEGABYTE)
/* 'XXXXM' is good until we're at 10000MB or above */
- snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE);
+ msnprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE);
else if(bytes < CURL_OFF_T_C(100) * ONE_GIGABYTE)
/* 10000 MB - 100 GB, we show it as XX.XG */
- snprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
- CURL_FORMAT_CURL_OFF_T "G", bytes/ONE_GIGABYTE,
- (bytes%ONE_GIGABYTE) / (ONE_GIGABYTE/CURL_OFF_T_C(10)) );
+ msnprintf(max5, 6, "%2" CURL_FORMAT_CURL_OFF_T ".%0"
+ CURL_FORMAT_CURL_OFF_T "G", bytes/ONE_GIGABYTE,
+ (bytes%ONE_GIGABYTE) / (ONE_GIGABYTE/CURL_OFF_T_C(10)) );
else if(bytes < CURL_OFF_T_C(10000) * ONE_GIGABYTE)
/* up to 10000GB, display without decimal: XXXXG */
- snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "G", bytes/ONE_GIGABYTE);
+ msnprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "G", bytes/ONE_GIGABYTE);
else if(bytes < CURL_OFF_T_C(10000) * ONE_TERABYTE)
/* up to 10000TB, display without decimal: XXXXT */
- snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "T", bytes/ONE_TERABYTE);
+ msnprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "T", bytes/ONE_TERABYTE);
else
/* up to 10000PB, display without decimal: XXXXP */
- snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "P", bytes/ONE_PETABYTE);
+ msnprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "P", bytes/ONE_PETABYTE);
/* 16384 petabytes (16 exabytes) is the maximum a 64 bit unsigned number
can hold, but our data type is signed so 8192PB will be the maximum. */
@@ -109,12 +114,13 @@ static char *max5data(curl_off_t bytes, char *max5)
#else
else
- snprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE);
+ msnprintf(max5, 6, "%4" CURL_FORMAT_CURL_OFF_T "M", bytes/ONE_MEGABYTE);
#endif
return max5;
}
+#endif
/*
@@ -134,7 +140,7 @@ int Curl_pgrsDone(struct connectdata *conn)
{
int rc;
struct Curl_easy *data = conn->data;
- data->progress.lastshow=0;
+ data->progress.lastshow = 0;
rc = Curl_pgrsUpdate(conn); /* the final (forced) update */
if(rc)
return rc;
@@ -149,21 +155,20 @@ int Curl_pgrsDone(struct connectdata *conn)
return 0;
}
-/* reset all times except redirect, and reset the known transfer sizes */
-void Curl_pgrsResetTimesSizes(struct Curl_easy *data)
+/* reset the known transfer sizes */
+void Curl_pgrsResetTransferSizes(struct Curl_easy *data)
{
- data->progress.t_nslookup = 0.0;
- data->progress.t_connect = 0.0;
- data->progress.t_pretransfer = 0.0;
- data->progress.t_starttransfer = 0.0;
-
Curl_pgrsSetDownloadSize(data, -1);
Curl_pgrsSetUploadSize(data, -1);
}
+/*
+ * @unittest: 1399
+ */
void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
{
- struct timeval now = Curl_tvnow();
+ struct curltime now = Curl_now();
+ time_t *delta = NULL;
switch(timer) {
default:
@@ -177,56 +182,70 @@ void Curl_pgrsTime(struct Curl_easy *data, timerid timer)
case TIMER_STARTSINGLE:
/* This is set at the start of each single fetch */
data->progress.t_startsingle = now;
+ data->progress.is_t_startransfer_set = false;
break;
-
case TIMER_STARTACCEPT:
- data->progress.t_acceptdata = Curl_tvnow();
+ data->progress.t_acceptdata = now;
break;
-
case TIMER_NAMELOOKUP:
- data->progress.t_nslookup =
- Curl_tvdiff_secs(now, data->progress.t_startsingle);
+ delta = &data->progress.t_nslookup;
break;
case TIMER_CONNECT:
- data->progress.t_connect =
- Curl_tvdiff_secs(now, data->progress.t_startsingle);
+ delta = &data->progress.t_connect;
break;
case TIMER_APPCONNECT:
- data->progress.t_appconnect =
- Curl_tvdiff_secs(now, data->progress.t_startsingle);
+ delta = &data->progress.t_appconnect;
break;
case TIMER_PRETRANSFER:
- data->progress.t_pretransfer =
- Curl_tvdiff_secs(now, data->progress.t_startsingle);
+ delta = &data->progress.t_pretransfer;
break;
case TIMER_STARTTRANSFER:
- data->progress.t_starttransfer =
- Curl_tvdiff_secs(now, data->progress.t_startsingle);
- break;
+ delta = &data->progress.t_starttransfer;
+ /* prevent updating t_starttransfer unless:
+ * 1) this is the first time we're setting t_starttransfer
+ * 2) a redirect has occurred since the last time t_starttransfer was set
+ * This prevents repeated invocations of the function from incorrectly
+ * changing the t_starttransfer time.
+ */
+ if(data->progress.is_t_startransfer_set) {
+ return;
+ }
+ else {
+ data->progress.is_t_startransfer_set = true;
+ break;
+ }
case TIMER_POSTRANSFER:
/* this is the normal end-of-transfer thing */
break;
case TIMER_REDIRECT:
- data->progress.t_redirect = Curl_tvdiff_secs(now, data->progress.start);
+ data->progress.t_redirect = Curl_timediff_us(now, data->progress.start);
break;
}
+ if(delta) {
+ timediff_t us = Curl_timediff_us(now, data->progress.t_startsingle);
+ if(us < 1)
+ us = 1; /* make sure at least one microsecond passed */
+ *delta += us;
+ }
}
void Curl_pgrsStartNow(struct Curl_easy *data)
{
data->progress.speeder_c = 0; /* reset the progress meter display */
- data->progress.start = Curl_tvnow();
+ data->progress.start = Curl_now();
+ data->progress.is_t_startransfer_set = false;
data->progress.ul_limit_start.tv_sec = 0;
data->progress.ul_limit_start.tv_usec = 0;
data->progress.dl_limit_start.tv_sec = 0;
data->progress.dl_limit_start.tv_usec = 0;
/* clear all bits except HIDE and HEADERS_OUT */
data->progress.flags &= PGRS_HIDE|PGRS_HEADERS_OUT;
+ Curl_ratelimit(data, data->progress.start);
}
/*
- * This is used to handle speed limits, calculating how much milliseconds we
- * need to wait until we're back under the speed limit, if needed.
+ * This is used to handle speed limits, calculating how many milliseconds to
+ * wait until we're back under the speed limit, if needed.
*
* The way it works is by having a "starting point" (time & amount of data
* transferred by then) used in the speed computation, to be used instead of
@@ -238,73 +257,87 @@ void Curl_pgrsStartNow(struct Curl_easy *data)
* the starting point, the limit (in bytes/s), the time of the starting point
* and the current time.
*
- * Returns -1 if no waiting is needed (not enough data transferred since
- * starting point yet), 0 when no waiting is needed but the starting point
- * should be reset (to current), or the number of milliseconds to wait to get
- * back under the speed limit.
+ * Returns 0 if no waiting is needed or when no waiting is needed but the
+ * starting point should be reset (to current); or the number of milliseconds
+ * to wait to get back under the speed limit.
*/
-long Curl_pgrsLimitWaitTime(curl_off_t cursize,
- curl_off_t startsize,
- curl_off_t limit,
- struct timeval start,
- struct timeval now)
+timediff_t Curl_pgrsLimitWaitTime(curl_off_t cursize,
+ curl_off_t startsize,
+ curl_off_t limit,
+ struct curltime start,
+ struct curltime now)
{
curl_off_t size = cursize - startsize;
time_t minimum;
time_t actual;
- /* we don't have a starting point yet -- return 0 so it gets (re)set */
- if(start.tv_sec == 0 && start.tv_usec == 0)
+ if(!limit || !size)
return 0;
- /* not enough data yet */
- if(size < limit)
- return -1;
-
- minimum = (time_t) (CURL_OFF_T_C(1000) * size / limit);
- actual = Curl_tvdiff(now, start);
+ /*
+ * 'minimum' is the number of milliseconds 'size' should take to download to
+ * stay below 'limit'.
+ */
+ if(size < CURL_OFF_T_MAX/1000)
+ minimum = (time_t) (CURL_OFF_T_C(1000) * size / limit);
+ else {
+ minimum = (time_t) (size / limit);
+ if(minimum < TIME_T_MAX/1000)
+ minimum *= 1000;
+ else
+ minimum = TIME_T_MAX;
+ }
- if(actual < minimum)
- /* this is a conversion on some systems (64bit time_t => 32bit long) */
- return (long)(minimum - actual);
+ /*
+ * 'actual' is the time in milliseconds it took to actually download the
+ * last 'size' bytes.
+ */
+ actual = Curl_timediff(now, start);
+ if(actual < minimum) {
+ /* if it downloaded the data faster than the limit, make it wait the
+ difference */
+ return (minimum - actual);
+ }
return 0;
}
+/*
+ * Set the number of downloaded bytes so far.
+ */
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size)
{
- struct timeval now = Curl_tvnow();
-
data->progress.downloaded = size;
+}
- /* download speed limit */
- if((data->set.max_recv_speed > 0) &&
- (Curl_pgrsLimitWaitTime(data->progress.downloaded,
- data->progress.dl_limit_size,
- data->set.max_recv_speed,
- data->progress.dl_limit_start,
- now) == 0)) {
- data->progress.dl_limit_start = now;
- data->progress.dl_limit_size = size;
+/*
+ * Update the timestamp and sizestamp to use for rate limit calculations.
+ */
+void Curl_ratelimit(struct Curl_easy *data, struct curltime now)
+{
+ /* don't set a new stamp unless the time since last update is long enough */
+ if(data->set.max_recv_speed > 0) {
+ if(Curl_timediff(now, data->progress.dl_limit_start) >=
+ MIN_RATE_LIMIT_PERIOD) {
+ data->progress.dl_limit_start = now;
+ data->progress.dl_limit_size = data->progress.downloaded;
+ }
+ }
+ if(data->set.max_send_speed > 0) {
+ if(Curl_timediff(now, data->progress.ul_limit_start) >=
+ MIN_RATE_LIMIT_PERIOD) {
+ data->progress.ul_limit_start = now;
+ data->progress.ul_limit_size = data->progress.uploaded;
+ }
}
}
+/*
+ * Set the number of uploaded bytes so far.
+ */
void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size)
{
- struct timeval now = Curl_tvnow();
-
data->progress.uploaded = size;
-
- /* upload speed limit */
- if((data->set.max_send_speed > 0) &&
- (Curl_pgrsLimitWaitTime(data->progress.uploaded,
- data->progress.ul_limit_size,
- data->set.max_send_speed,
- data->progress.ul_limit_start,
- now) == 0)) {
- data->progress.ul_limit_start = now;
- data->progress.ul_limit_size = size;
- }
}
void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size)
@@ -331,60 +364,49 @@ void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size)
}
}
-/*
- * Curl_pgrsUpdate() returns 0 for success or the value returned by the
- * progress callback!
- */
-int Curl_pgrsUpdate(struct connectdata *conn)
+#ifndef CURL_DISABLE_PROGRESS_METER
+static void progress_meter(struct connectdata *conn)
{
- struct timeval now;
- int result;
- char max5[6][10];
- curl_off_t dlpercen=0;
- curl_off_t ulpercen=0;
- curl_off_t total_percen=0;
- curl_off_t total_transfer;
- curl_off_t total_expected_transfer;
+ struct curltime now;
curl_off_t timespent;
+ curl_off_t timespent_ms; /* milliseconds */
struct Curl_easy *data = conn->data;
- int nowindex = data->progress.speeder_c% CURR_TIME;
- int checkindex;
- int countindex; /* amount of seconds stored in the speeder array */
- char time_left[10];
- char time_total[10];
- char time_spent[10];
- curl_off_t ulestimate=0;
- curl_off_t dlestimate=0;
- curl_off_t total_estimate;
- bool shownow=FALSE;
-
- now = Curl_tvnow(); /* what time is it */
+ bool shownow = FALSE;
+ curl_off_t dl = data->progress.downloaded;
+ curl_off_t ul = data->progress.uploaded;
+
+ now = Curl_now(); /* what time is it */
/* The time spent so far (from the start) */
- data->progress.timespent = curlx_tvdiff_secs(now, data->progress.start);
- timespent = (curl_off_t)data->progress.timespent;
+ data->progress.timespent = Curl_timediff_us(now, data->progress.start);
+ timespent = (curl_off_t)data->progress.timespent/1000000; /* seconds */
+ timespent_ms = (curl_off_t)data->progress.timespent/1000; /* ms */
/* The average download speed this far */
- data->progress.dlspeed = (curl_off_t)
- ((double)data->progress.downloaded/
- (data->progress.timespent>0?data->progress.timespent:1));
+ if(dl < CURL_OFF_T_MAX/1000)
+ data->progress.dlspeed = (dl * 1000 / (timespent_ms>0?timespent_ms:1));
+ else
+ data->progress.dlspeed = (dl / (timespent>0?timespent:1));
/* The average upload speed this far */
- data->progress.ulspeed = (curl_off_t)
- ((double)data->progress.uploaded/
- (data->progress.timespent>0?data->progress.timespent:1));
+ if(ul < CURL_OFF_T_MAX/1000)
+ data->progress.ulspeed = (ul * 1000 / (timespent_ms>0?timespent_ms:1));
+ else
+ data->progress.ulspeed = (ul / (timespent>0?timespent:1));
/* Calculations done at most once a second, unless end is reached */
if(data->progress.lastshow != now.tv_sec) {
- shownow = TRUE;
+ int countindex; /* amount of seconds stored in the speeder array */
+ int nowindex = data->progress.speeder_c% CURR_TIME;
+ if(!(data->progress.flags & PGRS_HIDE))
+ shownow = TRUE;
data->progress.lastshow = now.tv_sec;
- /* Let's do the "current speed" thing, which should use the fastest
- of the dl/ul speeds. Store the faster speed at entry 'nowindex'. */
+ /* Let's do the "current speed" thing, with the dl + ul speeds
+ combined. Store the speed at entry 'nowindex'. */
data->progress.speeder[ nowindex ] =
- data->progress.downloaded>data->progress.uploaded?
- data->progress.downloaded:data->progress.uploaded;
+ data->progress.downloaded + data->progress.uploaded;
/* remember the exact time for this moment */
data->progress.speeder_time [ nowindex ] = now;
@@ -397,24 +419,25 @@ int Curl_pgrsUpdate(struct connectdata *conn)
array. With N_ENTRIES filled in, we have about N_ENTRIES-1 seconds of
transfer. Imagine, after one second we have filled in two entries,
after two seconds we've filled in three entries etc. */
- countindex = ((data->progress.speeder_c>=CURR_TIME)?
+ countindex = ((data->progress.speeder_c >= CURR_TIME)?
CURR_TIME:data->progress.speeder_c) - 1;
/* first of all, we don't do this if there's no counted seconds yet */
if(countindex) {
- time_t span_ms;
+ int checkindex;
+ timediff_t span_ms;
/* Get the index position to compare with the 'nowindex' position.
Get the oldest entry possible. While we have less than CURR_TIME
entries, the first entry will remain the oldest. */
- checkindex = (data->progress.speeder_c>=CURR_TIME)?
+ checkindex = (data->progress.speeder_c >= CURR_TIME)?
data->progress.speeder_c%CURR_TIME:0;
/* Figure out the exact time for the time span */
- span_ms = Curl_tvdiff(now,
- data->progress.speeder_time[checkindex]);
+ span_ms = Curl_timediff(now,
+ data->progress.speeder_time[checkindex]);
if(0 == span_ms)
- span_ms=1; /* at least one millisecond MUST have passed */
+ span_ms = 1; /* at least one millisecond MUST have passed */
/* Calculate the average speed the last 'span_ms' milliseconds */
{
@@ -433,45 +456,30 @@ int Curl_pgrsUpdate(struct connectdata *conn)
}
}
else
- /* the first second we use the main average */
+ /* the first second we use the average */
data->progress.current_speed =
- (data->progress.ulspeed>data->progress.dlspeed)?
- data->progress.ulspeed:data->progress.dlspeed;
+ data->progress.ulspeed + data->progress.dlspeed;
} /* Calculations end */
-
- if(!(data->progress.flags & PGRS_HIDE)) {
- /* progress meter has not been shut off */
-
- if(data->set.fxferinfo) {
- /* There's a callback set, call that */
- result= data->set.fxferinfo(data->set.progress_client,
- data->progress.size_dl,
- data->progress.downloaded,
- data->progress.size_ul,
- data->progress.uploaded);
- if(result)
- failf(data, "Callback aborted");
- return result;
- }
- if(data->set.fprogress) {
- /* The older deprecated callback is set, call that */
- result= data->set.fprogress(data->set.progress_client,
- (double)data->progress.size_dl,
- (double)data->progress.downloaded,
- (double)data->progress.size_ul,
- (double)data->progress.uploaded);
- if(result)
- failf(data, "Callback aborted");
- return result;
- }
-
- if(!shownow)
- /* only show the internal progress meter once per second */
- return 0;
-
+ if(!shownow)
+ /* only show the internal progress meter once per second */
+ return;
+ else {
/* If there's no external callback set, use internal code to show
progress */
+ /* progress meter has not been shut off */
+ char max5[6][10];
+ curl_off_t dlpercen = 0;
+ curl_off_t ulpercen = 0;
+ curl_off_t total_percen = 0;
+ curl_off_t total_transfer;
+ curl_off_t total_expected_transfer;
+ char time_left[10];
+ char time_total[10];
+ char time_spent[10];
+ curl_off_t ulestimate = 0;
+ curl_off_t dlestimate = 0;
+ curl_off_t total_estimate;
if(!(data->progress.flags & PGRS_HEADERS_OUT)) {
if(data->state.resume_from) {
@@ -524,9 +532,9 @@ int Curl_pgrsUpdate(struct connectdata *conn)
/* Get the total amount of data expected to get transferred */
total_expected_transfer =
- (data->progress.flags & PGRS_UL_SIZE_KNOWN?
+ ((data->progress.flags & PGRS_UL_SIZE_KNOWN)?
data->progress.size_ul:data->progress.uploaded)+
- (data->progress.flags & PGRS_DL_SIZE_KNOWN?
+ ((data->progress.flags & PGRS_DL_SIZE_KNOWN)?
data->progress.size_dl:data->progress.downloaded);
/* We have transferred this much so far */
@@ -555,13 +563,57 @@ int Curl_pgrsUpdate(struct connectdata *conn)
time_total, /* 8 letters */ /* total time */
time_spent, /* 8 letters */ /* time spent */
time_left, /* 8 letters */ /* time left */
- max5data(data->progress.current_speed, max5[5]) /* current speed */
- );
+ max5data(data->progress.current_speed, max5[5])
+ );
/* we flush the output stream to make it appear as soon as possible */
fflush(data->set.err);
+ } /* don't show now */
+}
+#else
+ /* progress bar disabled */
+#define progress_meter(x)
+#endif
+
- } /* !(data->progress.flags & PGRS_HIDE) */
+/*
+ * Curl_pgrsUpdate() returns 0 for success or the value returned by the
+ * progress callback!
+ */
+int Curl_pgrsUpdate(struct connectdata *conn)
+{
+ struct Curl_easy *data = conn->data;
+ if(!(data->progress.flags & PGRS_HIDE)) {
+ if(data->set.fxferinfo) {
+ int result;
+ /* There's a callback set, call that */
+ Curl_set_in_callback(data, true);
+ result = data->set.fxferinfo(data->set.progress_client,
+ data->progress.size_dl,
+ data->progress.downloaded,
+ data->progress.size_ul,
+ data->progress.uploaded);
+ Curl_set_in_callback(data, false);
+ if(result)
+ failf(data, "Callback aborted");
+ return result;
+ }
+ if(data->set.fprogress) {
+ int result;
+ /* The older deprecated callback is set, call that */
+ Curl_set_in_callback(data, true);
+ result = data->set.fprogress(data->set.progress_client,
+ (double)data->progress.size_dl,
+ (double)data->progress.downloaded,
+ (double)data->progress.size_ul,
+ (double)data->progress.uploaded);
+ Curl_set_in_callback(data, false);
+ if(result)
+ failf(data, "Callback aborted");
+ return result;
+ }
+ }
+ progress_meter(conn);
return 0;
}
diff --git a/Utilities/cmcurl/lib/progress.h b/Utilities/cmcurl/lib/progress.h
index 155ff04fe..3515ac6d5 100644
--- a/Utilities/cmcurl/lib/progress.h
+++ b/Utilities/cmcurl/lib/progress.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -46,32 +46,19 @@ void Curl_pgrsSetDownloadSize(struct Curl_easy *data, curl_off_t size);
void Curl_pgrsSetUploadSize(struct Curl_easy *data, curl_off_t size);
void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size);
void Curl_pgrsSetUploadCounter(struct Curl_easy *data, curl_off_t size);
+void Curl_ratelimit(struct Curl_easy *data, struct curltime now);
int Curl_pgrsUpdate(struct connectdata *);
-void Curl_pgrsResetTimesSizes(struct Curl_easy *data);
+void Curl_pgrsResetTransferSizes(struct Curl_easy *data);
void Curl_pgrsTime(struct Curl_easy *data, timerid timer);
-long Curl_pgrsLimitWaitTime(curl_off_t cursize,
- curl_off_t startsize,
- curl_off_t limit,
- struct timeval start,
- struct timeval now);
+timediff_t Curl_pgrsLimitWaitTime(curl_off_t cursize,
+ curl_off_t startsize,
+ curl_off_t limit,
+ struct curltime start,
+ struct curltime now);
-/* Don't show progress for sizes smaller than: */
-#define LEAST_SIZE_PROGRESS BUFSIZE
-
-#define PROGRESS_DOWNLOAD (1<<0)
-#define PROGRESS_UPLOAD (1<<1)
-#define PROGRESS_DOWN_AND_UP (PROGRESS_UPLOAD | PROGRESS_DOWNLOAD)
-
-#define PGRS_SHOW_DL (1<<0)
-#define PGRS_SHOW_UL (1<<1)
-#define PGRS_DONE_DL (1<<2)
-#define PGRS_DONE_UL (1<<3)
#define PGRS_HIDE (1<<4)
#define PGRS_UL_SIZE_KNOWN (1<<5)
#define PGRS_DL_SIZE_KNOWN (1<<6)
-
#define PGRS_HEADERS_OUT (1<<7) /* set when the headers have been written */
-
#endif /* HEADER_CURL_PROGRESS_H */
-
diff --git a/Utilities/cmcurl/lib/psl.c b/Utilities/cmcurl/lib/psl.c
new file mode 100644
index 000000000..568baff03
--- /dev/null
+++ b/Utilities/cmcurl/lib/psl.c
@@ -0,0 +1,111 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#include <curl/curl.h>
+
+#ifdef USE_LIBPSL
+
+#include "psl.h"
+#include "share.h"
+
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "memdebug.h"
+
+void Curl_psl_destroy(struct PslCache *pslcache)
+{
+ if(pslcache->psl) {
+ if(pslcache->dynamic)
+ psl_free((psl_ctx_t *) pslcache->psl);
+ pslcache->psl = NULL;
+ pslcache->dynamic = FALSE;
+ }
+}
+
+static time_t now_seconds(void)
+{
+ struct curltime now = Curl_now();
+
+ return now.tv_sec;
+}
+
+const psl_ctx_t *Curl_psl_use(struct Curl_easy *easy)
+{
+ struct PslCache *pslcache = easy->psl;
+ const psl_ctx_t *psl;
+ time_t now;
+
+ if(!pslcache)
+ return NULL;
+
+ Curl_share_lock(easy, CURL_LOCK_DATA_PSL, CURL_LOCK_ACCESS_SHARED);
+ now = now_seconds();
+ if(!pslcache->psl || pslcache->expires <= now) {
+ /* Let a chance to other threads to do the job: avoids deadlock. */
+ Curl_share_unlock(easy, CURL_LOCK_DATA_PSL);
+
+ /* Update cache: this needs an exclusive lock. */
+ Curl_share_lock(easy, CURL_LOCK_DATA_PSL, CURL_LOCK_ACCESS_SINGLE);
+
+ /* Recheck in case another thread did the job. */
+ now = now_seconds();
+ if(!pslcache->psl || pslcache->expires <= now) {
+ bool dynamic = FALSE;
+ time_t expires = TIME_T_MAX;
+
+#if defined(PSL_VERSION_NUMBER) && PSL_VERSION_NUMBER >= 0x001000
+ psl = psl_latest(NULL);
+ dynamic = psl != NULL;
+ /* Take care of possible time computation overflow. */
+ expires = now < TIME_T_MAX - PSL_TTL? now + PSL_TTL: TIME_T_MAX;
+
+ /* Only get the built-in PSL if we do not already have the "latest". */
+ if(!psl && !pslcache->dynamic)
+#endif
+
+ psl = psl_builtin();
+
+ if(psl) {
+ Curl_psl_destroy(pslcache);
+ pslcache->psl = psl;
+ pslcache->dynamic = dynamic;
+ pslcache->expires = expires;
+ }
+ }
+ Curl_share_unlock(easy, CURL_LOCK_DATA_PSL); /* Release exclusive lock. */
+ Curl_share_lock(easy, CURL_LOCK_DATA_PSL, CURL_LOCK_ACCESS_SHARED);
+ }
+ psl = pslcache->psl;
+ if(!psl)
+ Curl_share_unlock(easy, CURL_LOCK_DATA_PSL);
+ return psl;
+}
+
+void Curl_psl_release(struct Curl_easy *easy)
+{
+ Curl_share_unlock(easy, CURL_LOCK_DATA_PSL);
+}
+
+#endif /* USE_LIBPSL */
diff --git a/Utilities/cmcurl/lib/psl.h b/Utilities/cmcurl/lib/psl.h
new file mode 100644
index 000000000..e9f99d03e
--- /dev/null
+++ b/Utilities/cmcurl/lib/psl.h
@@ -0,0 +1,47 @@
+#ifndef HEADER_PSL_H
+#define HEADER_PSL_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#ifdef USE_LIBPSL
+#include <libpsl.h>
+
+#define PSL_TTL (72 * 3600) /* PSL time to live before a refresh. */
+
+struct PslCache {
+ const psl_ctx_t *psl; /* The PSL. */
+ time_t expires; /* Time this PSL life expires. */
+ bool dynamic; /* PSL should be released when no longer needed. */
+};
+
+const psl_ctx_t *Curl_psl_use(struct Curl_easy *easy);
+void Curl_psl_release(struct Curl_easy *easy);
+void Curl_psl_destroy(struct PslCache *pslcache);
+
+#else
+
+#define Curl_psl_use(easy) NULL
+#define Curl_psl_release(easy)
+#define Curl_psl_destroy(pslcache)
+
+#endif /* USE_LIBPSL */
+#endif /* HEADER_PSL_H */
diff --git a/Utilities/cmcurl/lib/rand.c b/Utilities/cmcurl/lib/rand.c
index b6f40ac0a..6ee45feb1 100644
--- a/Utilities/cmcurl/lib/rand.c
+++ b/Utilities/cmcurl/lib/rand.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -86,7 +86,7 @@ static CURLcode randit(struct Curl_easy *data, unsigned int *rnd)
#endif
if(!seeded) {
- struct timeval now = curlx_tvnow();
+ struct curltime now = Curl_now();
infof(data, "WARNING: Using weak random seed\n");
randseed += (unsigned int)now.tv_usec + (unsigned int)now.tv_sec;
randseed = randseed * 1103515245 + 12345;
@@ -157,6 +157,12 @@ CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
unsigned char *bufp = buffer;
DEBUGASSERT(num > 1);
+#ifdef __clang_analyzer__
+ /* This silences a scan-build warning about accessing this buffer with
+ uninitialized memory. */
+ memset(buffer, 0, sizeof(buffer));
+#endif
+
if((num/2 >= sizeof(buffer)) || !(num&1))
/* make sure it fits in the local buffer and that it is an odd number! */
return CURLE_BAD_FUNCTION_ARGUMENT;
@@ -168,6 +174,8 @@ CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
return result;
while(num) {
+ /* clang-tidy warns on this line without this comment: */
+ /* NOLINTNEXTLINE(clang-analyzer-core.UndefinedBinaryOperatorResult) */
*rnd++ = hex[(*bufp & 0xF0)>>4];
*rnd++ = hex[*bufp & 0x0F];
bufp++;
diff --git a/Utilities/cmcurl/lib/rand.h b/Utilities/cmcurl/lib/rand.h
index c6fae3553..5deb04161 100644
--- a/Utilities/cmcurl/lib/rand.h
+++ b/Utilities/cmcurl/lib/rand.h
@@ -39,8 +39,11 @@
*/
CURLcode Curl_rand(struct Curl_easy *data, unsigned char *rnd, size_t num);
-/* Same as above but outputs only random lowercase hex characters.
- Does NOT terminate.*/
+/*
+ * Curl_rand_hex() fills the 'rnd' buffer with a given 'num' size with random
+ * hexadecimal digits PLUS a zero terminating byte. It must be an odd number
+ * size.
+ */
CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
size_t num);
diff --git a/Utilities/cmcurl/lib/rtsp.c b/Utilities/cmcurl/lib/rtsp.c
index 1810cdafb..74cf23244 100644
--- a/Utilities/cmcurl/lib/rtsp.c
+++ b/Utilities/cmcurl/lib/rtsp.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -42,16 +42,6 @@
#include "curl_memory.h"
#include "memdebug.h"
-/*
- * TODO (general)
- * -incoming server requests
- * -server CSeq counter
- * -digest authentication
- * -connect thru proxy
- * -pipelining?
- */
-
-
#define RTP_PKT_CHANNEL(p) ((int)((unsigned char)((p)[1])))
#define RTP_PKT_LENGTH(p) ((((int)((unsigned char)((p)[2]))) << 8) | \
@@ -80,7 +70,8 @@ static CURLcode rtsp_rtp_readwrite(struct Curl_easy *data,
bool *readmore);
static CURLcode rtsp_setup_connection(struct connectdata *conn);
-
+static unsigned int rtsp_conncheck(struct connectdata *check,
+ unsigned int checks_to_perform);
/* this returns the socket to wait for in the DO and DOING state for the multi
interface and then we're always _sending_ a request and thus we wait for
@@ -117,6 +108,7 @@ const struct Curl_handler Curl_handler_rtsp = {
ZERO_NULL, /* perform_getsock */
rtsp_disconnect, /* disconnect */
rtsp_rtp_readwrite, /* readwrite */
+ rtsp_conncheck, /* connection_check */
PORT_RTSP, /* defport */
CURLPROTO_RTSP, /* protocol */
PROTOPT_NONE /* flags */
@@ -143,7 +135,7 @@ static CURLcode rtsp_setup_connection(struct connectdata *conn)
* Instead, if it is readable, run Curl_connalive() to peek at the socket
* and distinguish between closed and data.
*/
-bool Curl_rtsp_connisdead(struct connectdata *check)
+static bool rtsp_connisdead(struct connectdata *check)
{
int sval;
bool ret_val = TRUE;
@@ -165,6 +157,23 @@ bool Curl_rtsp_connisdead(struct connectdata *check)
return ret_val;
}
+/*
+ * Function to check on various aspects of a connection.
+ */
+static unsigned int rtsp_conncheck(struct connectdata *check,
+ unsigned int checks_to_perform)
+{
+ unsigned int ret_val = CONNRESULT_NONE;
+
+ if(checks_to_perform & CONNCHECK_ISDEAD) {
+ if(rtsp_connisdead(check))
+ ret_val |= CONNRESULT_DEAD;
+ }
+
+ return ret_val;
+}
+
+
static CURLcode rtsp_connect(struct connectdata *conn, bool *done)
{
CURLcode httpStatus;
@@ -197,8 +206,6 @@ static CURLcode rtsp_done(struct connectdata *conn,
struct Curl_easy *data = conn->data;
struct RTSP *rtsp = data->req.protop;
CURLcode httpStatus;
- long CSeq_sent;
- long CSeq_recv;
/* Bypass HTTP empty-reply checks on receive */
if(data->set.rtspreq == RTSPREQ_RECEIVE)
@@ -208,8 +215,8 @@ static CURLcode rtsp_done(struct connectdata *conn,
if(rtsp) {
/* Check the sequence numbers */
- CSeq_sent = rtsp->CSeq_sent;
- CSeq_recv = rtsp->CSeq_recv;
+ long CSeq_sent = rtsp->CSeq_sent;
+ long CSeq_recv = rtsp->CSeq_recv;
if((data->set.rtspreq != RTSPREQ_RECEIVE) && (CSeq_sent != CSeq_recv)) {
failf(data,
"The CSeq of this request %ld did not match the response %ld",
@@ -219,7 +226,6 @@ static CURLcode rtsp_done(struct connectdata *conn,
if(data->set.rtspreq == RTSPREQ_RECEIVE &&
(conn->proto.rtspc.rtp_channel == -1)) {
infof(data, "Got an RTP Receive with a CSeq of %ld\n", CSeq_recv);
- /* TODO CPC: Server -> Client logic here */
}
}
@@ -229,10 +235,9 @@ static CURLcode rtsp_done(struct connectdata *conn,
static CURLcode rtsp_do(struct connectdata *conn, bool *done)
{
struct Curl_easy *data = conn->data;
- CURLcode result=CURLE_OK;
+ CURLcode result = CURLE_OK;
Curl_RtspReq rtspreq = data->set.rtspreq;
struct RTSP *rtsp = data->req.protop;
- struct HTTP *http;
Curl_send_buffer *req_buffer;
curl_off_t postsize = 0; /* for ANNOUNCE and SET_PARAMETER */
curl_off_t putsize = 0; /* for ANNOUNCE and SET_PARAMETER */
@@ -251,10 +256,6 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
*done = TRUE;
- http = &(rtsp->http_wrapper);
- /* Assert that no one has changed the RTSP struct in an evil way */
- DEBUGASSERT((void *)http == (void *)rtsp);
-
rtsp->CSeq_sent = data->state.rtsp_next_client_CSeq;
rtsp->CSeq_recv = 0;
@@ -311,8 +312,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
}
if(rtspreq == RTSPREQ_RECEIVE) {
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE,
- &http->readbytecount, -1, NULL);
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, TRUE, -1);
return result;
}
@@ -325,8 +325,6 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
return CURLE_BAD_FUNCTION_ARGUMENT;
}
- /* TODO: proxy? */
-
/* Stream URI. Default to server '*' if not specified */
if(data->set.str[STRING_RTSP_STREAM_URI]) {
p_stream_uri = data->set.str[STRING_RTSP_STREAM_URI];
@@ -336,7 +334,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
}
/* Transport Header for SETUP requests */
- p_transport = Curl_checkheaders(conn, "Transport:");
+ p_transport = Curl_checkheaders(conn, "Transport");
if(rtspreq == RTSPREQ_SETUP && !p_transport) {
/* New Transport: setting? */
if(data->set.str[STRING_RTSP_TRANSPORT]) {
@@ -360,11 +358,11 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
/* Accept Headers for DESCRIBE requests */
if(rtspreq == RTSPREQ_DESCRIBE) {
/* Accept Header */
- p_accept = Curl_checkheaders(conn, "Accept:")?
+ p_accept = Curl_checkheaders(conn, "Accept")?
NULL:"Accept: application/sdp\r\n";
/* Accept-Encoding header */
- if(!Curl_checkheaders(conn, "Accept-Encoding:") &&
+ if(!Curl_checkheaders(conn, "Accept-Encoding") &&
data->set.str[STRING_ENCODING]) {
Curl_safefree(conn->allocptr.accept_encoding);
conn->allocptr.accept_encoding =
@@ -381,11 +379,11 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
it might have been used in the proxy connect, but if we have got a header
with the user-agent string specified, we erase the previously made string
here. */
- if(Curl_checkheaders(conn, "User-Agent:") && conn->allocptr.uagent) {
+ if(Curl_checkheaders(conn, "User-Agent") && conn->allocptr.uagent) {
Curl_safefree(conn->allocptr.uagent);
conn->allocptr.uagent = NULL;
}
- else if(!Curl_checkheaders(conn, "User-Agent:") &&
+ else if(!Curl_checkheaders(conn, "User-Agent") &&
data->set.str[STRING_USERAGENT]) {
p_uagent = conn->allocptr.uagent;
}
@@ -400,7 +398,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
/* Referrer */
Curl_safefree(conn->allocptr.ref);
- if(data->change.referer && !Curl_checkheaders(conn, "Referer:"))
+ if(data->change.referer && !Curl_checkheaders(conn, "Referer"))
conn->allocptr.ref = aprintf("Referer: %s\r\n", data->change.referer);
else
conn->allocptr.ref = NULL;
@@ -417,7 +415,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
(rtspreq & (RTSPREQ_PLAY | RTSPREQ_PAUSE | RTSPREQ_RECORD))) {
/* Check to see if there is a range set in the custom headers */
- if(!Curl_checkheaders(conn, "Range:") && data->state.range) {
+ if(!Curl_checkheaders(conn, "Range") && data->state.range) {
Curl_safefree(conn->allocptr.rangeline);
conn->allocptr.rangeline = aprintf("Range: %s\r\n", data->state.range);
p_range = conn->allocptr.rangeline;
@@ -427,11 +425,11 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
/*
* Sanity check the custom headers
*/
- if(Curl_checkheaders(conn, "CSeq:")) {
+ if(Curl_checkheaders(conn, "CSeq")) {
failf(data, "CSeq cannot be set as a custom header.");
return CURLE_RTSP_CSEQ_ERROR;
}
- if(Curl_checkheaders(conn, "Session:")) {
+ if(Curl_checkheaders(conn, "Session")) {
failf(data, "Session ID cannot be set as a custom header.");
return CURLE_BAD_FUNCTION_ARGUMENT;
}
@@ -443,7 +441,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
return CURLE_OUT_OF_MEMORY;
result =
- Curl_add_bufferf(req_buffer,
+ Curl_add_bufferf(&req_buffer,
"%s %s RTSP/1.0\r\n" /* Request Stream-URI RTSP/1.0 */
"CSeq: %ld\r\n", /* CSeq */
p_request, p_stream_uri, rtsp->CSeq_sent);
@@ -455,7 +453,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
* to make comparison easier
*/
if(p_session_id) {
- result = Curl_add_bufferf(req_buffer, "Session: %s\r\n", p_session_id);
+ result = Curl_add_bufferf(&req_buffer, "Session: %s\r\n", p_session_id);
if(result)
return result;
}
@@ -463,7 +461,7 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
/*
* Shared HTTP-like options
*/
- result = Curl_add_bufferf(req_buffer,
+ result = Curl_add_bufferf(&req_buffer,
"%s" /* transport */
"%s" /* accept */
"%s" /* accept-encoding */
@@ -521,28 +519,29 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
if(putsize > 0 || postsize > 0) {
/* As stated in the http comments, it is probably not wise to
* actually set a custom Content-Length in the headers */
- if(!Curl_checkheaders(conn, "Content-Length:")) {
- result = Curl_add_bufferf(req_buffer,
- "Content-Length: %" CURL_FORMAT_CURL_OFF_T"\r\n",
- (data->set.upload ? putsize : postsize));
+ if(!Curl_checkheaders(conn, "Content-Length")) {
+ result =
+ Curl_add_bufferf(&req_buffer,
+ "Content-Length: %" CURL_FORMAT_CURL_OFF_T"\r\n",
+ (data->set.upload ? putsize : postsize));
if(result)
return result;
}
if(rtspreq == RTSPREQ_SET_PARAMETER ||
rtspreq == RTSPREQ_GET_PARAMETER) {
- if(!Curl_checkheaders(conn, "Content-Type:")) {
- result = Curl_add_bufferf(req_buffer,
- "Content-Type: text/parameters\r\n");
+ if(!Curl_checkheaders(conn, "Content-Type")) {
+ result = Curl_add_bufferf(&req_buffer,
+ "Content-Type: text/parameters\r\n");
if(result)
return result;
}
}
if(rtspreq == RTSPREQ_ANNOUNCE) {
- if(!Curl_checkheaders(conn, "Content-Type:")) {
- result = Curl_add_bufferf(req_buffer,
- "Content-Type: application/sdp\r\n");
+ if(!Curl_checkheaders(conn, "Content-Type")) {
+ result = Curl_add_bufferf(&req_buffer,
+ "Content-Type: application/sdp\r\n");
if(result)
return result;
}
@@ -560,36 +559,34 @@ static CURLcode rtsp_do(struct connectdata *conn, bool *done)
/* RTSP never allows chunked transfer */
data->req.forbidchunk = TRUE;
/* Finish the request buffer */
- result = Curl_add_buffer(req_buffer, "\r\n", 2);
+ result = Curl_add_buffer(&req_buffer, "\r\n", 2);
if(result)
return result;
if(postsize > 0) {
- result = Curl_add_buffer(req_buffer, data->set.postfields,
+ result = Curl_add_buffer(&req_buffer, data->set.postfields,
(size_t)postsize);
if(result)
return result;
}
/* issue the request */
- result = Curl_add_buffer_send(req_buffer, conn,
+ result = Curl_add_buffer_send(&req_buffer, conn,
&data->info.request_size, 0, FIRSTSOCKET);
if(result) {
failf(data, "Failed sending RTSP request");
return result;
}
- Curl_setup_transfer(conn, FIRSTSOCKET, -1, TRUE, &http->readbytecount,
- putsize?FIRSTSOCKET:-1,
- putsize?&http->writebytecount:NULL);
+ Curl_setup_transfer(data, FIRSTSOCKET, -1, TRUE, putsize?FIRSTSOCKET:-1);
/* Increment the CSeq on success */
data->state.rtsp_next_client_CSeq++;
- if(http->writebytecount) {
+ if(data->req.writebytecount) {
/* if a request-body has been sent off, we make sure this progress is
noted properly */
- Curl_pgrsSetUploadCounter(data, http->writebytecount);
+ Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
}
@@ -728,14 +725,29 @@ CURLcode rtp_client_write(struct connectdata *conn, char *ptr, size_t len)
struct Curl_easy *data = conn->data;
size_t wrote;
curl_write_callback writeit;
+ void *user_ptr;
if(len == 0) {
failf(data, "Cannot write a 0 size RTP packet.");
return CURLE_WRITE_ERROR;
}
- writeit = data->set.fwrite_rtp?data->set.fwrite_rtp:data->set.fwrite_func;
- wrote = writeit(ptr, 1, len, data->set.rtp_out);
+ /* If the user has configured CURLOPT_INTERLEAVEFUNCTION then use that
+ function and any configured CURLOPT_INTERLEAVEDATA to write out the RTP
+ data. Otherwise, use the CURLOPT_WRITEFUNCTION with the CURLOPT_WRITEDATA
+ pointer to write out the RTP data. */
+ if(data->set.fwrite_rtp) {
+ writeit = data->set.fwrite_rtp;
+ user_ptr = data->set.rtp_out;
+ }
+ else {
+ writeit = data->set.fwrite_func;
+ user_ptr = data->set.out;
+ }
+
+ Curl_set_in_callback(data, true);
+ wrote = writeit(ptr, 1, len, user_ptr);
+ Curl_set_in_callback(data, false);
if(CURL_WRITEFUNC_PAUSE == wrote) {
failf(data, "Cannot pause RTP");
diff --git a/Utilities/cmcurl/lib/rtsp.h b/Utilities/cmcurl/lib/rtsp.h
index 5a8d5556f..2f9cc32c8 100644
--- a/Utilities/cmcurl/lib/rtsp.h
+++ b/Utilities/cmcurl/lib/rtsp.h
@@ -25,13 +25,11 @@
extern const struct Curl_handler Curl_handler_rtsp;
-bool Curl_rtsp_connisdead(struct connectdata *check);
CURLcode Curl_rtsp_parseheader(struct connectdata *conn, char *header);
#else
/* disabled */
#define Curl_rtsp_parseheader(x,y) CURLE_NOT_BUILT_IN
-#define Curl_rtsp_connisdead(x) TRUE
#endif /* CURL_DISABLE_RTSP */
@@ -66,4 +64,3 @@ struct RTSP {
#endif /* HEADER_CURL_RTSP_H */
-
diff --git a/Utilities/cmcurl/lib/security.c b/Utilities/cmcurl/lib/security.c
index f4a876341..76951548d 100644
--- a/Utilities/cmcurl/lib/security.c
+++ b/Utilities/cmcurl/lib/security.c
@@ -7,10 +7,10 @@
* rewrite to work around the paragraph 2 in the BSD licenses as explained
* below.
*
- * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1998, 1999, 2017 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
*
- * Copyright (C) 2001 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2001 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* All rights reserved.
*
@@ -50,9 +50,7 @@
#include <netdb.h>
#endif
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#include "urldata.h"
#include "curl_base64.h"
@@ -63,7 +61,9 @@
#include "strcase.h"
#include "warnless.h"
#include "strdup.h"
-/* The last #include file should be: */
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
#include "memdebug.h"
static const struct {
@@ -115,12 +115,12 @@ static char level_to_char(int level)
static int ftp_send_command(struct connectdata *conn, const char *message, ...)
{
int ftp_code;
- ssize_t nread=0;
+ ssize_t nread = 0;
va_list args;
char print_buffer[50];
va_start(args, message);
- vsnprintf(print_buffer, sizeof(print_buffer), message, args);
+ mvsnprintf(print_buffer, sizeof(print_buffer), message, args);
va_end(args);
if(Curl_ftpsend(conn, print_buffer)) {
@@ -142,7 +142,7 @@ socket_read(curl_socket_t fd, void *to, size_t len)
{
char *to_p = to;
CURLcode result;
- ssize_t nread;
+ ssize_t nread = 0;
while(len > 0) {
result = Curl_read_plain(fd, to_p, len, &nread);
@@ -151,7 +151,6 @@ socket_read(curl_socket_t fd, void *to, size_t len)
to_p += nread;
}
else {
- /* FIXME: We are doing a busy wait */
if(result == CURLE_AGAIN)
continue;
return result;
@@ -179,7 +178,6 @@ socket_write(struct connectdata *conn, curl_socket_t fd, const void *to,
to_p += written;
}
else {
- /* FIXME: We are doing a busy wait */
if(result == CURLE_AGAIN)
continue;
return result;
@@ -265,13 +263,11 @@ static ssize_t sec_recv(struct connectdata *conn, int sockindex,
total_read += bytes_read;
buffer += bytes_read;
}
- /* FIXME: Check for overflow */
return total_read;
}
/* Send |length| bytes from |from| to the |fd| socket taking care of encoding
and negociating with the server. |from| can be NULL. */
-/* FIXME: We don't check for errors nor report any! */
static void do_sec_send(struct connectdata *conn, curl_socket_t fd,
const char *from, int length)
{
@@ -392,7 +388,7 @@ int Curl_sec_read_msg(struct connectdata *conn, char *buffer,
if(conn->data->set.verbose) {
buf[decoded_len] = '\n';
- Curl_debug(conn->data, CURLINFO_HEADER_IN, buf, decoded_len + 1, conn);
+ Curl_debug(conn->data, CURLINFO_HEADER_IN, buf, decoded_len + 1);
}
buf[decoded_len] = '\0';
@@ -406,25 +402,21 @@ int Curl_sec_read_msg(struct connectdata *conn, char *buffer,
if(buf[decoded_len - 1] == '\n')
buf[decoded_len - 1] = '\0';
- /* FIXME: Is |buffer| length always greater than |decoded_len|? */
strcpy(buffer, buf);
free(buf);
return ret_code;
}
-/* FIXME: The error code returned here is never checked. */
static int sec_set_protection_level(struct connectdata *conn)
{
int code;
- char *pbsz;
- static unsigned int buffer_size = 1 << 20; /* 1048576 */
enum protection_level level = conn->request_data_prot;
DEBUGASSERT(level > PROT_NONE && level < PROT_LAST);
if(!conn->sec_complete) {
infof(conn->data, "Trying to change the protection level after the"
- "completion of the data exchange.\n");
+ " completion of the data exchange.\n");
return -1;
}
@@ -433,6 +425,9 @@ static int sec_set_protection_level(struct connectdata *conn)
return 0;
if(level) {
+ char *pbsz;
+ static unsigned int buffer_size = 1 << 20; /* 1048576 */
+
code = ftp_send_command(conn, "PBSZ %u", buffer_size);
if(code < 0)
return -1;
@@ -490,7 +485,7 @@ static CURLcode choose_mech(struct connectdata *conn)
tmp_allocation = realloc(conn->app_data, mech->size);
if(tmp_allocation == NULL) {
- failf(data, "Failed realloc of size %u", mech->size);
+ failf(data, "Failed realloc of size %zu", mech->size);
mech = NULL;
return CURLE_OUT_OF_MEMORY;
}
@@ -508,7 +503,6 @@ static CURLcode choose_mech(struct connectdata *conn)
infof(data, "Trying mechanism %s...\n", mech->name);
ret = ftp_send_command(conn, "AUTH %s", mech->name);
if(ret < 0)
- /* FIXME: This error is too generic but it is OK for now. */
return CURLE_COULDNT_CONNECT;
if(ret/100 != 3) {
@@ -575,7 +569,6 @@ Curl_sec_end(struct connectdata *conn)
conn->in_buffer.data = NULL;
conn->in_buffer.size = 0;
conn->in_buffer.index = 0;
- /* FIXME: Is this really needed? */
conn->in_buffer.eof_flag = 0;
}
conn->sec_complete = 0;
diff --git a/Utilities/cmcurl/lib/select.c b/Utilities/cmcurl/lib/select.c
index 443007227..6e7389015 100644
--- a/Utilities/cmcurl/lib/select.c
+++ b/Utilities/cmcurl/lib/select.c
@@ -51,7 +51,7 @@
#include "warnless.h"
/* Convenience local macros */
-#define ELAPSED_MS() (int)curlx_tvdiff(curlx_tvnow(), initial_tv)
+#define ELAPSED_MS() (int)Curl_timediff(Curl_now(), initial_tv)
int Curl_ack_eintr = 0;
#define ERROR_NOT_EINTR(error) (Curl_ack_eintr || error != EINTR)
@@ -78,9 +78,8 @@ int Curl_wait_ms(int timeout_ms)
#ifndef HAVE_POLL_FINE
struct timeval pending_tv;
#endif
- struct timeval initial_tv;
+ struct curltime initial_tv;
int pending_ms;
- int error;
#endif
int r = 0;
@@ -96,8 +95,9 @@ int Curl_wait_ms(int timeout_ms)
Sleep(timeout_ms);
#else
pending_ms = timeout_ms;
- initial_tv = curlx_tvnow();
+ initial_tv = Curl_now();
do {
+ int error;
#if defined(HAVE_POLL_FINE)
r = poll(NULL, 0, pending_ms);
#else
@@ -158,9 +158,8 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
fd_set fds_err;
curl_socket_t maxfd;
#endif
- struct timeval initial_tv = {0, 0};
+ struct curltime initial_tv = {0, 0};
int pending_ms = 0;
- int error;
int r;
int ret;
@@ -177,14 +176,14 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
return r;
}
- /* Avoid initial timestamp, avoid curlx_tvnow() call, when elapsed
+ /* Avoid initial timestamp, avoid Curl_now() call, when elapsed
time in this function does not need to be measured. This happens
when function is called with a zero timeout or a negative timeout
value indicating a blocking call should be performed. */
if(timeout_ms > 0) {
pending_ms = (int)timeout_ms;
- initial_tv = curlx_tvnow();
+ initial_tv = Curl_now();
}
#ifdef HAVE_POLL_FINE
@@ -210,6 +209,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
}
do {
+ int error;
if(timeout_ms < 0)
pending_ms = -1;
else if(!timeout_ms)
@@ -291,6 +291,7 @@ int Curl_socket_check(curl_socket_t readfd0, /* two sockets to read from */
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
do {
+ int error;
if(timeout_ms > 0) {
pending_tv.tv_sec = pending_ms / 1000;
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
@@ -398,11 +399,10 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
fd_set fds_err;
curl_socket_t maxfd;
#endif
- struct timeval initial_tv = {0, 0};
+ struct curltime initial_tv = {0, 0};
bool fds_none = TRUE;
unsigned int i;
int pending_ms = 0;
- int error;
int r;
if(ufds) {
@@ -418,19 +418,20 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
return r;
}
- /* Avoid initial timestamp, avoid curlx_tvnow() call, when elapsed
+ /* Avoid initial timestamp, avoid Curl_now() call, when elapsed
time in this function does not need to be measured. This happens
when function is called with a zero timeout or a negative timeout
value indicating a blocking call should be performed. */
if(timeout_ms > 0) {
pending_ms = timeout_ms;
- initial_tv = curlx_tvnow();
+ initial_tv = Curl_now();
}
#ifdef HAVE_POLL_FINE
do {
+ int error;
if(timeout_ms < 0)
pending_ms = -1;
else if(!timeout_ms)
@@ -502,6 +503,7 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
ptimeout = (timeout_ms < 0) ? NULL : &pending_tv;
do {
+ int error;
if(timeout_ms > 0) {
pending_tv.tv_sec = pending_ms / 1000;
pending_tv.tv_usec = (pending_ms % 1000) * 1000;
@@ -571,8 +573,8 @@ int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms)
*
* Return values are the same as select's.
*/
-int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes,
- fd_set* excepts, struct timeval* tv)
+int tpf_select_libcurl(int maxfds, fd_set *reads, fd_set *writes,
+ fd_set *excepts, struct timeval *tv)
{
int rc;
diff --git a/Utilities/cmcurl/lib/select.h b/Utilities/cmcurl/lib/select.h
index 4ed5dd2f8..9a1ba45a7 100644
--- a/Utilities/cmcurl/lib/select.h
+++ b/Utilities/cmcurl/lib/select.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -36,7 +36,8 @@
#if !defined(HAVE_STRUCT_POLLFD) && \
!defined(HAVE_SYS_POLL_H) && \
- !defined(HAVE_POLL_H)
+ !defined(HAVE_POLL_H) && \
+ !defined(POLLIN)
#define POLLIN 0x01
#define POLLPRI 0x02
@@ -112,4 +113,3 @@ int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes,
#endif
#endif /* HEADER_CURL_SELECT_H */
-
diff --git a/Utilities/cmcurl/lib/sendf.c b/Utilities/cmcurl/lib/sendf.c
index 595c36177..5913ea406 100644
--- a/Utilities/cmcurl/lib/sendf.c
+++ b/Utilities/cmcurl/lib/sendf.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,6 +22,14 @@
#include "curl_setup.h"
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#ifdef HAVE_LINUX_TCP_H
+#include <linux/tcp.h>
+#endif
+
#include <curl/curl.h>
#include "urldata.h"
@@ -29,6 +37,7 @@
#include "connect.h"
#include "vtls/vtls.h"
#include "ssh.h"
+#include "easyif.h"
#include "multiif.h"
#include "non-ascii.h"
#include "strerror.h"
@@ -63,7 +72,7 @@ static size_t convert_lineends(struct Curl_easy *data,
if(*startPtr == '\n') {
/* This block of incoming data starts with the
previous block's LF so get rid of it */
- memmove(startPtr, startPtr+1, size-1);
+ memmove(startPtr, startPtr + 1, size-1);
size--;
/* and it wasn't a bare CR but a CRLF conversion instead */
data->state.crlf_conversions++;
@@ -75,7 +84,7 @@ static size_t convert_lineends(struct Curl_easy *data,
inPtr = outPtr = memchr(startPtr, '\r', size);
if(inPtr) {
/* at least one CR, now look for CRLF */
- while(inPtr < (startPtr+size-1)) {
+ while(inPtr < (startPtr + size-1)) {
/* note that it's size-1, so we'll never look past the last byte */
if(memcmp(inPtr, "\r\n", 2) == 0) {
/* CRLF found, bump past the CR and copy the NL */
@@ -98,7 +107,7 @@ static size_t convert_lineends(struct Curl_easy *data,
inPtr++;
} /* end of while loop */
- if(inPtr < startPtr+size) {
+ if(inPtr < startPtr + size) {
/* handle last byte */
if(*inPtr == '\r') {
/* deal with a CR at the end of the buffer */
@@ -112,7 +121,7 @@ static size_t convert_lineends(struct Curl_easy *data,
}
outPtr++;
}
- if(outPtr < startPtr+size)
+ if(outPtr < startPtr + size)
/* tidy up by null terminating the now shorter data */
*outPtr = '\0';
@@ -228,10 +237,21 @@ void Curl_infof(struct Curl_easy *data, const char *fmt, ...)
size_t len;
char print_buffer[2048 + 1];
va_start(ap, fmt);
- vsnprintf(print_buffer, sizeof(print_buffer), fmt, ap);
+ len = mvsnprintf(print_buffer, sizeof(print_buffer), fmt, ap);
+ /*
+ * Indicate truncation of the input by replacing the last 3 characters
+ * with "...", and transfer the newline over in case the format had one.
+ */
+ if(len >= sizeof(print_buffer)) {
+ len = strlen(fmt);
+ if(fmt[--len] == '\n')
+ msnprintf(print_buffer + (sizeof(print_buffer) - 5), 5, "...\n");
+ else
+ msnprintf(print_buffer + (sizeof(print_buffer) - 4), 4, "...");
+ }
va_end(ap);
len = strlen(print_buffer);
- Curl_debug(data, CURLINFO_TEXT, print_buffer, len, NULL);
+ Curl_debug(data, CURLINFO_TEXT, print_buffer, len);
}
}
@@ -241,25 +261,25 @@ void Curl_infof(struct Curl_easy *data, const char *fmt, ...)
void Curl_failf(struct Curl_easy *data, const char *fmt, ...)
{
- va_list ap;
- size_t len;
- char error[CURL_ERROR_SIZE + 2];
- va_start(ap, fmt);
-
- vsnprintf(error, CURL_ERROR_SIZE, fmt, ap);
- len = strlen(error);
+ if(data->set.verbose || data->set.errorbuffer) {
+ va_list ap;
+ size_t len;
+ char error[CURL_ERROR_SIZE + 2];
+ va_start(ap, fmt);
+ mvsnprintf(error, CURL_ERROR_SIZE, fmt, ap);
+ len = strlen(error);
- if(data->set.errorbuffer && !data->state.errorbuf) {
- strcpy(data->set.errorbuffer, error);
- data->state.errorbuf = TRUE; /* wrote error string */
- }
- if(data->set.verbose) {
- error[len] = '\n';
- error[++len] = '\0';
- Curl_debug(data, CURLINFO_TEXT, error, len, NULL);
+ if(data->set.errorbuffer && !data->state.errorbuf) {
+ strcpy(data->set.errorbuffer, error);
+ data->state.errorbuf = TRUE; /* wrote error string */
+ }
+ if(data->set.verbose) {
+ error[len] = '\n';
+ error[++len] = '\0';
+ Curl_debug(data, CURLINFO_TEXT, error, len);
+ }
+ va_end(ap);
}
-
- va_end(ap);
}
/* Curl_sendf() sends formatted data to the server */
@@ -279,7 +299,7 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn,
if(!s)
return CURLE_OUT_OF_MEMORY; /* failure */
- bytes_written=0;
+ bytes_written = 0;
write_len = strlen(s);
sptr = s;
@@ -291,7 +311,7 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn,
break;
if(data->set.verbose)
- Curl_debug(data, CURLINFO_DATA_OUT, sptr, (size_t)bytes_written, conn);
+ Curl_debug(data, CURLINFO_DATA_OUT, sptr, (size_t)bytes_written);
if((size_t)bytes_written != write_len) {
/* if not all was written at once, we must advance the pointer, decrease
@@ -360,7 +380,7 @@ ssize_t Curl_send_plain(struct connectdata *conn, int num,
available. */
pre_receive_plain(conn, num);
-#ifdef MSG_FASTOPEN /* Linux */
+#if defined(MSG_FASTOPEN) && !defined(TCP_FASTOPEN_CONNECT) /* Linux */
if(conn->bits.tcp_fastopen) {
bytes_written = sendto(sockfd, mem, len, MSG_FASTOPEN,
conn->ip_addr->ai_addr, conn->ip_addr->ai_addrlen);
@@ -380,19 +400,20 @@ ssize_t Curl_send_plain(struct connectdata *conn, int num,
(WSAEWOULDBLOCK == err)
#else
/* errno may be EWOULDBLOCK or on some systems EAGAIN when it returned
- due to its inability to send off data without blocking. We therefor
+ due to its inability to send off data without blocking. We therefore
treat both error codes the same here */
(EWOULDBLOCK == err) || (EAGAIN == err) || (EINTR == err) ||
(EINPROGRESS == err)
#endif
) {
/* this is just a case of EWOULDBLOCK */
- bytes_written=0;
+ bytes_written = 0;
*code = CURLE_AGAIN;
}
else {
+ char buffer[STRERROR_LEN];
failf(conn->data, "Send failure: %s",
- Curl_strerror(conn, err));
+ Curl_strerror(err, buffer, sizeof(buffer)));
conn->data->state.os_errno = err;
*code = CURLE_SEND_ERROR;
}
@@ -447,7 +468,7 @@ ssize_t Curl_recv_plain(struct connectdata *conn, int num, char *buf,
(WSAEWOULDBLOCK == err)
#else
/* errno may be EWOULDBLOCK or on some systems EAGAIN when it returned
- due to its inability to send off data without blocking. We therefor
+ due to its inability to send off data without blocking. We therefore
treat both error codes the same here */
(EWOULDBLOCK == err) || (EAGAIN == err) || (EINTR == err)
#endif
@@ -456,8 +477,9 @@ ssize_t Curl_recv_plain(struct connectdata *conn, int num, char *buf,
*code = CURLE_AGAIN;
}
else {
+ char buffer[STRERROR_LEN];
failf(conn->data, "Recv failure: %s",
- Curl_strerror(conn, err));
+ Curl_strerror(err, buffer, sizeof(buffer)));
conn->data->state.os_errno = err;
*code = CURLE_RECV_ERROR;
}
@@ -480,7 +502,7 @@ static CURLcode pausewrite(struct Curl_easy *data,
bool newtype = TRUE;
if(s->tempcount) {
- for(i=0; i< s->tempcount; i++) {
+ for(i = 0; i< s->tempcount; i++) {
if(s->tempwrite[i].type == type) {
/* data for this type exists */
newtype = FALSE;
@@ -532,18 +554,20 @@ static CURLcode pausewrite(struct Curl_easy *data,
}
-/* Curl_client_chop_write() writes chunks of data not larger than
- * CURL_MAX_WRITE_SIZE via client write callback(s) and
- * takes care of pause requests from the callbacks.
+/* chop_write() writes chunks of data not larger than CURL_MAX_WRITE_SIZE via
+ * client write callback(s) and takes care of pause requests from the
+ * callbacks.
*/
-CURLcode Curl_client_chop_write(struct connectdata *conn,
- int type,
- char *ptr,
- size_t len)
+static CURLcode chop_write(struct connectdata *conn,
+ int type,
+ char *optr,
+ size_t olen)
{
struct Curl_easy *data = conn->data;
curl_write_callback writeheader = NULL;
curl_write_callback writebody = NULL;
+ char *ptr = optr;
+ size_t len = olen;
if(!len)
return CURLE_OK;
@@ -571,7 +595,10 @@ CURLcode Curl_client_chop_write(struct connectdata *conn,
size_t chunklen = len <= CURL_MAX_WRITE_SIZE? len: CURL_MAX_WRITE_SIZE;
if(writebody) {
- size_t wrote = writebody(ptr, 1, chunklen, data->set.out);
+ size_t wrote;
+ Curl_set_in_callback(data, true);
+ wrote = writebody(ptr, 1, chunklen, data->set.out);
+ Curl_set_in_callback(data, false);
if(CURL_WRITEFUNC_PAUSE == wrote) {
if(conn->handler->flags & PROTOPT_NONETWORK) {
@@ -589,25 +616,30 @@ CURLcode Curl_client_chop_write(struct connectdata *conn,
}
}
- if(writeheader) {
- size_t wrote = writeheader(ptr, 1, chunklen, data->set.writeheader);
-
- if(CURL_WRITEFUNC_PAUSE == wrote)
- /* here we pass in the HEADER bit only since if this was body as well
- then it was passed already and clearly that didn't trigger the
- pause, so this is saved for later with the HEADER bit only */
- return pausewrite(data, CLIENTWRITE_HEADER, ptr, len);
-
- if(wrote != chunklen) {
- failf(data, "Failed writing header");
- return CURLE_WRITE_ERROR;
- }
- }
-
ptr += chunklen;
len -= chunklen;
}
+ if(writeheader) {
+ size_t wrote;
+ ptr = optr;
+ len = olen;
+ Curl_set_in_callback(data, true);
+ wrote = writeheader(ptr, 1, len, data->set.writeheader);
+ Curl_set_in_callback(data, false);
+
+ if(CURL_WRITEFUNC_PAUSE == wrote)
+ /* here we pass in the HEADER bit only since if this was body as well
+ then it was passed already and clearly that didn't trigger the
+ pause, so this is saved for later with the HEADER bit only */
+ return pausewrite(data, CLIENTWRITE_HEADER, ptr, len);
+
+ if(wrote != len) {
+ failf(data, "Failed writing header");
+ return CURLE_WRITE_ERROR;
+ }
+ }
+
return CURLE_OK;
}
@@ -649,7 +681,7 @@ CURLcode Curl_client_write(struct connectdata *conn,
#endif /* CURL_DO_LINEEND_CONV */
}
- return Curl_client_chop_write(conn, type, ptr, len);
+ return chop_write(conn, type, ptr, len);
}
CURLcode Curl_read_plain(curl_socket_t sockfd,
@@ -695,59 +727,28 @@ CURLcode Curl_read(struct connectdata *conn, /* connection data */
char *buffertofill = NULL;
struct Curl_easy *data = conn->data;
- /* if HTTP/1 pipelining is both wanted and possible */
- bool pipelining = Curl_pipeline_wanted(data->multi, CURLPIPE_HTTP1) &&
- (conn->bundle->multiuse == BUNDLE_PIPELINING);
-
/* Set 'num' to 0 or 1, depending on which socket that has been sent here.
If it is the second socket, we set num to 1. Otherwise to 0. This lets
us use the correct ssl handle. */
int num = (sockfd == conn->sock[SECONDARYSOCKET]);
- *n=0; /* reset amount to zero */
-
- /* If session can pipeline, check connection buffer */
- if(pipelining) {
- size_t bytestocopy = CURLMIN(conn->buf_len - conn->read_pos,
- sizerequested);
+ *n = 0; /* reset amount to zero */
- /* Copy from our master buffer first if we have some unread data there*/
- if(bytestocopy > 0) {
- memcpy(buf, conn->master_buffer + conn->read_pos, bytestocopy);
- conn->read_pos += bytestocopy;
- conn->bits.stream_was_rewound = FALSE;
-
- *n = (ssize_t)bytestocopy;
- return CURLE_OK;
- }
- /* If we come here, it means that there is no data to read from the buffer,
- * so we read from the socket */
- bytesfromsocket = CURLMIN(sizerequested, MASTERBUF_SIZE);
- buffertofill = conn->master_buffer;
- }
- else {
- bytesfromsocket = CURLMIN(sizerequested, (size_t)data->set.buffer_size);
- buffertofill = buf;
- }
+ bytesfromsocket = CURLMIN(sizerequested, (size_t)data->set.buffer_size);
+ buffertofill = buf;
nread = conn->recv[num](conn, num, buffertofill, bytesfromsocket, &result);
if(nread < 0)
return result;
- if(pipelining) {
- memcpy(buf, conn->master_buffer, nread);
- conn->buf_len = nread;
- conn->read_pos = nread;
- }
-
*n += nread;
return CURLE_OK;
}
/* return 0 on success */
-static int showit(struct Curl_easy *data, curl_infotype type,
- char *ptr, size_t size)
+int Curl_debug(struct Curl_easy *data, curl_infotype type,
+ char *ptr, size_t size)
{
static const char s_infotype[CURLINFO_END][3] = {
"* ", "< ", "> ", "{ ", "} ", "{ ", "} " };
@@ -790,8 +791,11 @@ static int showit(struct Curl_easy *data, curl_infotype type,
}
#endif /* CURL_DOES_CONVERSIONS */
- if(data->set.fdebug)
+ if(data->set.fdebug) {
+ Curl_set_in_callback(data, true);
rc = (*data->set.fdebug)(data, type, ptr, size, data->set.debugdata);
+ Curl_set_in_callback(data, false);
+ }
else {
switch(type) {
case CURLINFO_TEXT:
@@ -815,41 +819,3 @@ static int showit(struct Curl_easy *data, curl_infotype type,
#endif
return rc;
}
-
-int Curl_debug(struct Curl_easy *data, curl_infotype type,
- char *ptr, size_t size,
- struct connectdata *conn)
-{
- int rc;
- if(data->set.printhost && conn && conn->host.dispname) {
- char buffer[160];
- const char *t=NULL;
- const char *w="Data";
- switch(type) {
- case CURLINFO_HEADER_IN:
- w = "Header";
- /* FALLTHROUGH */
- case CURLINFO_DATA_IN:
- t = "from";
- break;
- case CURLINFO_HEADER_OUT:
- w = "Header";
- /* FALLTHROUGH */
- case CURLINFO_DATA_OUT:
- t = "to";
- break;
- default:
- break;
- }
-
- if(t) {
- snprintf(buffer, sizeof(buffer), "[%s %s %s]", w, t,
- conn->host.dispname);
- rc = showit(data, CURLINFO_TEXT, buffer, strlen(buffer));
- if(rc)
- return rc;
- }
- }
- rc = showit(data, type, ptr, size);
- return rc;
-}
diff --git a/Utilities/cmcurl/lib/sendf.h b/Utilities/cmcurl/lib/sendf.h
index fbe4f99c8..c68b017da 100644
--- a/Utilities/cmcurl/lib/sendf.h
+++ b/Utilities/cmcurl/lib/sendf.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -36,7 +36,7 @@ void Curl_failf(struct Curl_easy *, const char *fmt, ...);
#elif defined(HAVE_VARIADIC_MACROS_GCC)
#define infof(x...) Curl_nop_stmt
#else
-#define infof (void)
+#error "missing VARIADIC macro define, fix and rebuild!"
#endif
#else /* CURL_DISABLE_VERBOSE_STRINGS */
@@ -51,8 +51,6 @@ void Curl_failf(struct Curl_easy *, const char *fmt, ...);
#define CLIENTWRITE_HEADER (1<<1)
#define CLIENTWRITE_BOTH (CLIENTWRITE_BODY|CLIENTWRITE_HEADER)
-CURLcode Curl_client_chop_write(struct connectdata *conn, int type, char *ptr,
- size_t len) WARN_UNUSED_RESULT;
CURLcode Curl_client_write(struct connectdata *conn, int type, char *ptr,
size_t len) WARN_UNUSED_RESULT;
@@ -86,9 +84,8 @@ CURLcode Curl_write_plain(struct connectdata *conn,
ssize_t *written);
/* the function used to output verbose information */
-int Curl_debug(struct Curl_easy *handle, curl_infotype type,
- char *data, size_t size,
- struct connectdata *conn);
+int Curl_debug(struct Curl_easy *data, curl_infotype type,
+ char *ptr, size_t size);
#endif /* HEADER_CURL_SENDF_H */
diff --git a/Utilities/cmcurl/lib/setopt.c b/Utilities/cmcurl/lib/setopt.c
new file mode 100644
index 000000000..92cd5b271
--- /dev/null
+++ b/Utilities/cmcurl/lib/setopt.c
@@ -0,0 +1,2777 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#include <limits.h>
+
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#ifdef HAVE_LINUX_TCP_H
+#include <linux/tcp.h>
+#endif
+
+#include "urldata.h"
+#include "url.h"
+#include "progress.h"
+#include "content_encoding.h"
+#include "strcase.h"
+#include "share.h"
+#include "vtls/vtls.h"
+#include "warnless.h"
+#include "sendf.h"
+#include "http2.h"
+#include "setopt.h"
+#include "multiif.h"
+#include "altsvc.h"
+
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "memdebug.h"
+
+CURLcode Curl_setstropt(char **charp, const char *s)
+{
+ /* Release the previous storage at `charp' and replace by a dynamic storage
+ copy of `s'. Return CURLE_OK or CURLE_OUT_OF_MEMORY. */
+
+ Curl_safefree(*charp);
+
+ if(s) {
+ char *str = strdup(s);
+
+ if(str) {
+ size_t len = strlen(str);
+ if(len > CURL_MAX_INPUT_LENGTH) {
+ free(str);
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ }
+ }
+ if(!str)
+ return CURLE_OUT_OF_MEMORY;
+
+ *charp = str;
+ }
+
+ return CURLE_OK;
+}
+
+static CURLcode setstropt_userpwd(char *option, char **userp, char **passwdp)
+{
+ CURLcode result = CURLE_OK;
+ char *user = NULL;
+ char *passwd = NULL;
+
+ /* Parse the login details if specified. It not then we treat NULL as a hint
+ to clear the existing data */
+ if(option) {
+ result = Curl_parse_login_details(option, strlen(option),
+ (userp ? &user : NULL),
+ (passwdp ? &passwd : NULL),
+ NULL);
+ }
+
+ if(!result) {
+ /* Store the username part of option if required */
+ if(userp) {
+ if(!user && option && option[0] == ':') {
+ /* Allocate an empty string instead of returning NULL as user name */
+ user = strdup("");
+ if(!user)
+ result = CURLE_OUT_OF_MEMORY;
+ }
+
+ Curl_safefree(*userp);
+ *userp = user;
+ }
+
+ /* Store the password part of option if required */
+ if(passwdp) {
+ Curl_safefree(*passwdp);
+ *passwdp = passwd;
+ }
+ }
+
+ return result;
+}
+
+#define C_SSLVERSION_VALUE(x) (x & 0xffff)
+#define C_SSLVERSION_MAX_VALUE(x) (x & 0xffff0000)
+
+static CURLcode vsetopt(struct Curl_easy *data, CURLoption option,
+ va_list param)
+{
+ char *argptr;
+ CURLcode result = CURLE_OK;
+ long arg;
+ unsigned long uarg;
+ curl_off_t bigsize;
+
+ switch(option) {
+ case CURLOPT_DNS_CACHE_TIMEOUT:
+ arg = va_arg(param, long);
+ if(arg < -1)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.dns_cache_timeout = arg;
+ break;
+ case CURLOPT_DNS_USE_GLOBAL_CACHE:
+ /* deprecated */
+ break;
+ case CURLOPT_SSL_CIPHER_LIST:
+ /* set a list of cipher we want to use in the SSL connection */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER_LIST_ORIG],
+ va_arg(param, char *));
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_SSL_CIPHER_LIST:
+ /* set a list of cipher we want to use in the SSL connection for proxy */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER_LIST_PROXY],
+ va_arg(param, char *));
+ break;
+#endif
+ case CURLOPT_TLS13_CIPHERS:
+ if(Curl_ssl_tls13_ciphersuites()) {
+ /* set preferred list of TLS 1.3 cipher suites */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST_ORIG],
+ va_arg(param, char *));
+ }
+ else
+ return CURLE_NOT_BUILT_IN;
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_TLS13_CIPHERS:
+ if(Curl_ssl_tls13_ciphersuites()) {
+ /* set preferred list of TLS 1.3 cipher suites for proxy */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_CIPHER13_LIST_PROXY],
+ va_arg(param, char *));
+ }
+ else
+ return CURLE_NOT_BUILT_IN;
+ break;
+#endif
+ case CURLOPT_RANDOM_FILE:
+ /*
+ * This is the path name to a file that contains random data to seed
+ * the random SSL stuff with. The file is only used for reading.
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_RANDOM_FILE],
+ va_arg(param, char *));
+ break;
+ case CURLOPT_EGDSOCKET:
+ /*
+ * The Entropy Gathering Daemon socket pathname
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_EGDSOCKET],
+ va_arg(param, char *));
+ break;
+ case CURLOPT_MAXCONNECTS:
+ /*
+ * Set the absolute number of maximum simultaneous alive connection that
+ * libcurl is allowed to have.
+ */
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.maxconnects = arg;
+ break;
+ case CURLOPT_FORBID_REUSE:
+ /*
+ * When this transfer is done, it must not be left to be reused by a
+ * subsequent transfer but shall be closed immediately.
+ */
+ data->set.reuse_forbid = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_FRESH_CONNECT:
+ /*
+ * This transfer shall not use a previously cached connection but
+ * should be made with a fresh new connect!
+ */
+ data->set.reuse_fresh = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_VERBOSE:
+ /*
+ * Verbose means infof() calls that give a lot of information about
+ * the connection and transfer procedures as well as internal choices.
+ */
+ data->set.verbose = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_HEADER:
+ /*
+ * Set to include the header in the general data output stream.
+ */
+ data->set.include_header = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_NOPROGRESS:
+ /*
+ * Shut off the internal supported progress meter
+ */
+ data->set.hide_progress = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ if(data->set.hide_progress)
+ data->progress.flags |= PGRS_HIDE;
+ else
+ data->progress.flags &= ~PGRS_HIDE;
+ break;
+ case CURLOPT_NOBODY:
+ /*
+ * Do not include the body part in the output data stream.
+ */
+ data->set.opt_no_body = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_FAILONERROR:
+ /*
+ * Don't output the >=400 error code HTML-page, but instead only
+ * return error.
+ */
+ data->set.http_fail_on_error = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_KEEP_SENDING_ON_ERROR:
+ data->set.http_keep_sending_on_error = (0 != va_arg(param, long)) ?
+ TRUE : FALSE;
+ break;
+ case CURLOPT_UPLOAD:
+ case CURLOPT_PUT:
+ /*
+ * We want to sent data to the remote host. If this is HTTP, that equals
+ * using the PUT request.
+ */
+ data->set.upload = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ if(data->set.upload) {
+ /* If this is HTTP, PUT is what's needed to "upload" */
+ data->set.httpreq = HTTPREQ_PUT;
+ data->set.opt_no_body = FALSE; /* this is implied */
+ }
+ else
+ /* In HTTP, the opposite of upload is GET (unless NOBODY is true as
+ then this can be changed to HEAD later on) */
+ data->set.httpreq = HTTPREQ_GET;
+ break;
+ case CURLOPT_REQUEST_TARGET:
+ result = Curl_setstropt(&data->set.str[STRING_TARGET],
+ va_arg(param, char *));
+ break;
+ case CURLOPT_FILETIME:
+ /*
+ * Try to get the file time of the remote document. The time will
+ * later (possibly) become available using curl_easy_getinfo().
+ */
+ data->set.get_filetime = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_SERVER_RESPONSE_TIMEOUT:
+ /*
+ * Option that specifies how quickly an server response must be obtained
+ * before it is considered failure. For pingpong protocols.
+ */
+ arg = va_arg(param, long);
+ if((arg >= 0) && (arg <= (INT_MAX/1000)))
+ data->set.server_response_timeout = arg * 1000;
+ else
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ break;
+#ifndef CURL_DISABLE_TFTP
+ case CURLOPT_TFTP_NO_OPTIONS:
+ /*
+ * Option that prevents libcurl from sending TFTP option requests to the
+ * server.
+ */
+ data->set.tftp_no_options = va_arg(param, long) != 0;
+ break;
+ case CURLOPT_TFTP_BLKSIZE:
+ /*
+ * TFTP option that specifies the block size to use for data transmission.
+ */
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.tftp_blksize = arg;
+ break;
+#endif
+#ifndef CURL_DISABLE_NETRC
+ case CURLOPT_NETRC:
+ /*
+ * Parse the $HOME/.netrc file
+ */
+ arg = va_arg(param, long);
+ if((arg < CURL_NETRC_IGNORED) || (arg > CURL_NETRC_REQUIRED))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.use_netrc = (enum CURL_NETRC_OPTION)arg;
+ break;
+ case CURLOPT_NETRC_FILE:
+ /*
+ * Use this file instead of the $HOME/.netrc file
+ */
+ result = Curl_setstropt(&data->set.str[STRING_NETRC_FILE],
+ va_arg(param, char *));
+ break;
+#endif
+ case CURLOPT_TRANSFERTEXT:
+ /*
+ * This option was previously named 'FTPASCII'. Renamed to work with
+ * more protocols than merely FTP.
+ *
+ * Transfer using ASCII (instead of BINARY).
+ */
+ data->set.prefer_ascii = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_TIMECONDITION:
+ /*
+ * Set HTTP time condition. This must be one of the defines in the
+ * curl/curl.h header file.
+ */
+ arg = va_arg(param, long);
+ if((arg < CURL_TIMECOND_NONE) || (arg > CURL_TIMECOND_LASTMOD))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.timecondition = (curl_TimeCond)arg;
+ break;
+ case CURLOPT_TIMEVALUE:
+ /*
+ * This is the value to compare with the remote document with the
+ * method set with CURLOPT_TIMECONDITION
+ */
+ data->set.timevalue = (time_t)va_arg(param, long);
+ break;
+
+ case CURLOPT_TIMEVALUE_LARGE:
+ /*
+ * This is the value to compare with the remote document with the
+ * method set with CURLOPT_TIMECONDITION
+ */
+ data->set.timevalue = (time_t)va_arg(param, curl_off_t);
+ break;
+
+ case CURLOPT_SSLVERSION:
+ case CURLOPT_PROXY_SSLVERSION:
+ /*
+ * Set explicit SSL version to try to connect with, as some SSL
+ * implementations are lame.
+ */
+#ifdef USE_SSL
+ {
+ long version, version_max;
+ struct ssl_primary_config *primary = (option == CURLOPT_SSLVERSION ?
+ &data->set.ssl.primary :
+ &data->set.proxy_ssl.primary);
+
+ arg = va_arg(param, long);
+
+ version = C_SSLVERSION_VALUE(arg);
+ version_max = C_SSLVERSION_MAX_VALUE(arg);
+
+ if(version < CURL_SSLVERSION_DEFAULT ||
+ version >= CURL_SSLVERSION_LAST ||
+ version_max < CURL_SSLVERSION_MAX_NONE ||
+ version_max >= CURL_SSLVERSION_MAX_LAST)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ primary->version = version;
+ primary->version_max = version_max;
+ }
+#else
+ result = CURLE_UNKNOWN_OPTION;
+#endif
+ break;
+
+#ifndef CURL_DISABLE_HTTP
+ case CURLOPT_AUTOREFERER:
+ /*
+ * Switch on automatic referer that gets set if curl follows locations.
+ */
+ data->set.http_auto_referer = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_ACCEPT_ENCODING:
+ /*
+ * String to use at the value of Accept-Encoding header.
+ *
+ * If the encoding is set to "" we use an Accept-Encoding header that
+ * encompasses all the encodings we support.
+ * If the encoding is set to NULL we don't send an Accept-Encoding header
+ * and ignore an received Content-Encoding header.
+ *
+ */
+ argptr = va_arg(param, char *);
+ if(argptr && !*argptr) {
+ argptr = Curl_all_content_encodings();
+ if(!argptr)
+ result = CURLE_OUT_OF_MEMORY;
+ else {
+ result = Curl_setstropt(&data->set.str[STRING_ENCODING], argptr);
+ free(argptr);
+ }
+ }
+ else
+ result = Curl_setstropt(&data->set.str[STRING_ENCODING], argptr);
+ break;
+
+ case CURLOPT_TRANSFER_ENCODING:
+ data->set.http_transfer_encoding = (0 != va_arg(param, long)) ?
+ TRUE : FALSE;
+ break;
+
+ case CURLOPT_FOLLOWLOCATION:
+ /*
+ * Follow Location: header hints on a HTTP-server.
+ */
+ data->set.http_follow_location = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_UNRESTRICTED_AUTH:
+ /*
+ * Send authentication (user+password) when following locations, even when
+ * hostname changed.
+ */
+ data->set.allow_auth_to_other_hosts =
+ (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_MAXREDIRS:
+ /*
+ * The maximum amount of hops you allow curl to follow Location:
+ * headers. This should mostly be used to detect never-ending loops.
+ */
+ arg = va_arg(param, long);
+ if(arg < -1)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.maxredirs = arg;
+ break;
+
+ case CURLOPT_POSTREDIR:
+ /*
+ * Set the behaviour of POST when redirecting
+ * CURL_REDIR_GET_ALL - POST is changed to GET after 301 and 302
+ * CURL_REDIR_POST_301 - POST is kept as POST after 301
+ * CURL_REDIR_POST_302 - POST is kept as POST after 302
+ * CURL_REDIR_POST_303 - POST is kept as POST after 303
+ * CURL_REDIR_POST_ALL - POST is kept as POST after 301, 302 and 303
+ * other - POST is kept as POST after 301 and 302
+ */
+ arg = va_arg(param, long);
+ if(arg < CURL_REDIR_GET_ALL)
+ /* no return error on too high numbers since the bitmask could be
+ extended in a future */
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.keep_post = arg & CURL_REDIR_POST_ALL;
+ break;
+
+ case CURLOPT_POST:
+ /* Does this option serve a purpose anymore? Yes it does, when
+ CURLOPT_POSTFIELDS isn't used and the POST data is read off the
+ callback! */
+ if(va_arg(param, long)) {
+ data->set.httpreq = HTTPREQ_POST;
+ data->set.opt_no_body = FALSE; /* this is implied */
+ }
+ else
+ data->set.httpreq = HTTPREQ_GET;
+ break;
+
+ case CURLOPT_COPYPOSTFIELDS:
+ /*
+ * A string with POST data. Makes curl HTTP POST. Even if it is NULL.
+ * If needed, CURLOPT_POSTFIELDSIZE must have been set prior to
+ * CURLOPT_COPYPOSTFIELDS and not altered later.
+ */
+ argptr = va_arg(param, char *);
+
+ if(!argptr || data->set.postfieldsize == -1)
+ result = Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], argptr);
+ else {
+ /*
+ * Check that requested length does not overflow the size_t type.
+ */
+
+ if((data->set.postfieldsize < 0) ||
+ ((sizeof(curl_off_t) != sizeof(size_t)) &&
+ (data->set.postfieldsize > (curl_off_t)((size_t)-1))))
+ result = CURLE_OUT_OF_MEMORY;
+ else {
+ char *p;
+
+ (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
+
+ /* Allocate even when size == 0. This satisfies the need of possible
+ later address compare to detect the COPYPOSTFIELDS mode, and
+ to mark that postfields is used rather than read function or
+ form data.
+ */
+ p = malloc((size_t)(data->set.postfieldsize?
+ data->set.postfieldsize:1));
+
+ if(!p)
+ result = CURLE_OUT_OF_MEMORY;
+ else {
+ if(data->set.postfieldsize)
+ memcpy(p, argptr, (size_t)data->set.postfieldsize);
+
+ data->set.str[STRING_COPYPOSTFIELDS] = p;
+ }
+ }
+ }
+
+ data->set.postfields = data->set.str[STRING_COPYPOSTFIELDS];
+ data->set.httpreq = HTTPREQ_POST;
+ break;
+
+ case CURLOPT_POSTFIELDS:
+ /*
+ * Like above, but use static data instead of copying it.
+ */
+ data->set.postfields = va_arg(param, void *);
+ /* Release old copied data. */
+ (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
+ data->set.httpreq = HTTPREQ_POST;
+ break;
+
+ case CURLOPT_POSTFIELDSIZE:
+ /*
+ * The size of the POSTFIELD data to prevent libcurl to do strlen() to
+ * figure it out. Enables binary posts.
+ */
+ bigsize = va_arg(param, long);
+ if(bigsize < -1)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ if(data->set.postfieldsize < bigsize &&
+ data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
+ /* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
+ (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
+ data->set.postfields = NULL;
+ }
+
+ data->set.postfieldsize = bigsize;
+ break;
+
+ case CURLOPT_POSTFIELDSIZE_LARGE:
+ /*
+ * The size of the POSTFIELD data to prevent libcurl to do strlen() to
+ * figure it out. Enables binary posts.
+ */
+ bigsize = va_arg(param, curl_off_t);
+ if(bigsize < -1)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ if(data->set.postfieldsize < bigsize &&
+ data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
+ /* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
+ (void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
+ data->set.postfields = NULL;
+ }
+
+ data->set.postfieldsize = bigsize;
+ break;
+
+ case CURLOPT_HTTPPOST:
+ /*
+ * Set to make us do HTTP POST
+ */
+ data->set.httppost = va_arg(param, struct curl_httppost *);
+ data->set.httpreq = HTTPREQ_POST_FORM;
+ data->set.opt_no_body = FALSE; /* this is implied */
+ break;
+#endif /* CURL_DISABLE_HTTP */
+
+ case CURLOPT_MIMEPOST:
+ /*
+ * Set to make us do MIME/form POST
+ */
+ result = Curl_mime_set_subparts(&data->set.mimepost,
+ va_arg(param, curl_mime *), FALSE);
+ if(!result) {
+ data->set.httpreq = HTTPREQ_POST_MIME;
+ data->set.opt_no_body = FALSE; /* this is implied */
+ }
+ break;
+
+ case CURLOPT_REFERER:
+ /*
+ * String to set in the HTTP Referer: field.
+ */
+ if(data->change.referer_alloc) {
+ Curl_safefree(data->change.referer);
+ data->change.referer_alloc = FALSE;
+ }
+ result = Curl_setstropt(&data->set.str[STRING_SET_REFERER],
+ va_arg(param, char *));
+ data->change.referer = data->set.str[STRING_SET_REFERER];
+ break;
+
+ case CURLOPT_USERAGENT:
+ /*
+ * String to use in the HTTP User-Agent field
+ */
+ result = Curl_setstropt(&data->set.str[STRING_USERAGENT],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_HTTPHEADER:
+ /*
+ * Set a list with HTTP headers to use (or replace internals with)
+ */
+ data->set.headers = va_arg(param, struct curl_slist *);
+ break;
+
+#ifndef CURL_DISABLE_HTTP
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXYHEADER:
+ /*
+ * Set a list with proxy headers to use (or replace internals with)
+ *
+ * Since CURLOPT_HTTPHEADER was the only way to set HTTP headers for a
+ * long time we remain doing it this way until CURLOPT_PROXYHEADER is
+ * used. As soon as this option has been used, if set to anything but
+ * NULL, custom headers for proxies are only picked from this list.
+ *
+ * Set this option to NULL to restore the previous behavior.
+ */
+ data->set.proxyheaders = va_arg(param, struct curl_slist *);
+ break;
+#endif
+ case CURLOPT_HEADEROPT:
+ /*
+ * Set header option.
+ */
+ arg = va_arg(param, long);
+ data->set.sep_headers = (bool)((arg & CURLHEADER_SEPARATE)? TRUE: FALSE);
+ break;
+
+ case CURLOPT_HTTP200ALIASES:
+ /*
+ * Set a list of aliases for HTTP 200 in response header
+ */
+ data->set.http200aliases = va_arg(param, struct curl_slist *);
+ break;
+
+#if !defined(CURL_DISABLE_COOKIES)
+ case CURLOPT_COOKIE:
+ /*
+ * Cookie string to send to the remote server in the request.
+ */
+ result = Curl_setstropt(&data->set.str[STRING_COOKIE],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_COOKIEFILE:
+ /*
+ * Set cookie file to read and parse. Can be used multiple times.
+ */
+ argptr = (char *)va_arg(param, void *);
+ if(argptr) {
+ struct curl_slist *cl;
+ /* append the cookie file name to the list of file names, and deal with
+ them later */
+ cl = curl_slist_append(data->change.cookielist, argptr);
+ if(!cl) {
+ curl_slist_free_all(data->change.cookielist);
+ data->change.cookielist = NULL;
+ return CURLE_OUT_OF_MEMORY;
+ }
+ data->change.cookielist = cl; /* store the list for later use */
+ }
+ break;
+
+ case CURLOPT_COOKIEJAR:
+ /*
+ * Set cookie file name to dump all cookies to when we're done.
+ */
+ {
+ struct CookieInfo *newcookies;
+ result = Curl_setstropt(&data->set.str[STRING_COOKIEJAR],
+ va_arg(param, char *));
+
+ /*
+ * Activate the cookie parser. This may or may not already
+ * have been made.
+ */
+ newcookies = Curl_cookie_init(data, NULL, data->cookies,
+ data->set.cookiesession);
+ if(!newcookies)
+ result = CURLE_OUT_OF_MEMORY;
+ data->cookies = newcookies;
+ }
+ break;
+
+ case CURLOPT_COOKIESESSION:
+ /*
+ * Set this option to TRUE to start a new "cookie session". It will
+ * prevent the forthcoming read-cookies-from-file actions to accept
+ * cookies that are marked as being session cookies, as they belong to a
+ * previous session.
+ *
+ * In the original Netscape cookie spec, "session cookies" are cookies
+ * with no expire date set. RFC2109 describes the same action if no
+ * 'Max-Age' is set and RFC2965 includes the RFC2109 description and adds
+ * a 'Discard' action that can enforce the discard even for cookies that
+ * have a Max-Age.
+ *
+ * We run mostly with the original cookie spec, as hardly anyone implements
+ * anything else.
+ */
+ data->set.cookiesession = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_COOKIELIST:
+ argptr = va_arg(param, char *);
+
+ if(argptr == NULL)
+ break;
+
+ if(strcasecompare(argptr, "ALL")) {
+ /* clear all cookies */
+ Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
+ Curl_cookie_clearall(data->cookies);
+ Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
+ }
+ else if(strcasecompare(argptr, "SESS")) {
+ /* clear session cookies */
+ Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
+ Curl_cookie_clearsess(data->cookies);
+ Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
+ }
+ else if(strcasecompare(argptr, "FLUSH")) {
+ /* flush cookies to file, takes care of the locking */
+ Curl_flush_cookies(data, 0);
+ }
+ else if(strcasecompare(argptr, "RELOAD")) {
+ /* reload cookies from file */
+ Curl_cookie_loadfiles(data);
+ break;
+ }
+ else {
+ if(!data->cookies)
+ /* if cookie engine was not running, activate it */
+ data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE);
+
+ argptr = strdup(argptr);
+ if(!argptr || !data->cookies) {
+ result = CURLE_OUT_OF_MEMORY;
+ free(argptr);
+ }
+ else {
+ Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
+
+ if(checkprefix("Set-Cookie:", argptr))
+ /* HTTP Header format line */
+ Curl_cookie_add(data, data->cookies, TRUE, FALSE, argptr + 11, NULL,
+ NULL, TRUE);
+
+ else
+ /* Netscape format line */
+ Curl_cookie_add(data, data->cookies, FALSE, FALSE, argptr, NULL,
+ NULL, TRUE);
+
+ Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
+ free(argptr);
+ }
+ }
+
+ break;
+#endif /* !CURL_DISABLE_COOKIES */
+
+ case CURLOPT_HTTPGET:
+ /*
+ * Set to force us do HTTP GET
+ */
+ if(va_arg(param, long)) {
+ data->set.httpreq = HTTPREQ_GET;
+ data->set.upload = FALSE; /* switch off upload */
+ data->set.opt_no_body = FALSE; /* this is implied */
+ }
+ break;
+
+ case CURLOPT_HTTP_VERSION:
+ /*
+ * This sets a requested HTTP version to be used. The value is one of
+ * the listed enums in curl/curl.h.
+ */
+ arg = va_arg(param, long);
+ if(arg < CURL_HTTP_VERSION_NONE)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+#ifndef USE_NGHTTP2
+ if(arg >= CURL_HTTP_VERSION_2)
+ return CURLE_UNSUPPORTED_PROTOCOL;
+#else
+ if(arg > CURL_HTTP_VERSION_2_PRIOR_KNOWLEDGE)
+ return CURLE_UNSUPPORTED_PROTOCOL;
+ if(arg == CURL_HTTP_VERSION_NONE)
+ arg = CURL_HTTP_VERSION_2TLS;
+#endif
+ data->set.httpversion = arg;
+ break;
+
+ case CURLOPT_EXPECT_100_TIMEOUT_MS:
+ /*
+ * Time to wait for a response to a HTTP request containing an
+ * Expect: 100-continue header before sending the data anyway.
+ */
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.expect_100_timeout = arg;
+ break;
+
+ case CURLOPT_HTTP09_ALLOWED:
+ arg = va_arg(param, unsigned long);
+ if(arg > 1L)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.http09_allowed = arg ? TRUE : FALSE;
+ break;
+#endif /* CURL_DISABLE_HTTP */
+
+ case CURLOPT_HTTPAUTH:
+ /*
+ * Set HTTP Authentication type BITMASK.
+ */
+ {
+ int bitcheck;
+ bool authbits;
+ unsigned long auth = va_arg(param, unsigned long);
+
+ if(auth == CURLAUTH_NONE) {
+ data->set.httpauth = auth;
+ break;
+ }
+
+ /* the DIGEST_IE bit is only used to set a special marker, for all the
+ rest we need to handle it as normal DIGEST */
+ data->state.authhost.iestyle =
+ (bool)((auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE);
+
+ if(auth & CURLAUTH_DIGEST_IE) {
+ auth |= CURLAUTH_DIGEST; /* set standard digest bit */
+ auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */
+ }
+
+ /* switch off bits we can't support */
+#ifndef USE_NTLM
+ auth &= ~CURLAUTH_NTLM; /* no NTLM support */
+ auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
+#elif !defined(NTLM_WB_ENABLED)
+ auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
+#endif
+#ifndef USE_SPNEGO
+ auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without
+ GSS-API or SSPI */
+#endif
+
+ /* check if any auth bit lower than CURLAUTH_ONLY is still set */
+ bitcheck = 0;
+ authbits = FALSE;
+ while(bitcheck < 31) {
+ if(auth & (1UL << bitcheck++)) {
+ authbits = TRUE;
+ break;
+ }
+ }
+ if(!authbits)
+ return CURLE_NOT_BUILT_IN; /* no supported types left! */
+
+ data->set.httpauth = auth;
+ }
+ break;
+
+ case CURLOPT_CUSTOMREQUEST:
+ /*
+ * Set a custom string to use as request
+ */
+ result = Curl_setstropt(&data->set.str[STRING_CUSTOMREQUEST],
+ va_arg(param, char *));
+
+ /* we don't set
+ data->set.httpreq = HTTPREQ_CUSTOM;
+ here, we continue as if we were using the already set type
+ and this just changes the actual request keyword */
+ break;
+
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_HTTPPROXYTUNNEL:
+ /*
+ * Tunnel operations through the proxy instead of normal proxy use
+ */
+ data->set.tunnel_thru_httpproxy = (0 != va_arg(param, long)) ?
+ TRUE : FALSE;
+ break;
+
+ case CURLOPT_PROXYPORT:
+ /*
+ * Explicitly set HTTP proxy port number.
+ */
+ arg = va_arg(param, long);
+ if((arg < 0) || (arg > 65535))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.proxyport = arg;
+ break;
+
+ case CURLOPT_PROXYAUTH:
+ /*
+ * Set HTTP Authentication type BITMASK.
+ */
+ {
+ int bitcheck;
+ bool authbits;
+ unsigned long auth = va_arg(param, unsigned long);
+
+ if(auth == CURLAUTH_NONE) {
+ data->set.proxyauth = auth;
+ break;
+ }
+
+ /* the DIGEST_IE bit is only used to set a special marker, for all the
+ rest we need to handle it as normal DIGEST */
+ data->state.authproxy.iestyle =
+ (bool)((auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE);
+
+ if(auth & CURLAUTH_DIGEST_IE) {
+ auth |= CURLAUTH_DIGEST; /* set standard digest bit */
+ auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */
+ }
+ /* switch off bits we can't support */
+#ifndef USE_NTLM
+ auth &= ~CURLAUTH_NTLM; /* no NTLM support */
+ auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
+#elif !defined(NTLM_WB_ENABLED)
+ auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
+#endif
+#ifndef USE_SPNEGO
+ auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without
+ GSS-API or SSPI */
+#endif
+
+ /* check if any auth bit lower than CURLAUTH_ONLY is still set */
+ bitcheck = 0;
+ authbits = FALSE;
+ while(bitcheck < 31) {
+ if(auth & (1UL << bitcheck++)) {
+ authbits = TRUE;
+ break;
+ }
+ }
+ if(!authbits)
+ return CURLE_NOT_BUILT_IN; /* no supported types left! */
+
+ data->set.proxyauth = auth;
+ }
+ break;
+
+ case CURLOPT_PROXY:
+ /*
+ * Set proxy server:port to use as proxy.
+ *
+ * If the proxy is set to "" (and CURLOPT_SOCKS_PROXY is set to "" or NULL)
+ * we explicitly say that we don't want to use a proxy
+ * (even though there might be environment variables saying so).
+ *
+ * Setting it to NULL, means no proxy but allows the environment variables
+ * to decide for us (if CURLOPT_SOCKS_PROXY setting it to NULL).
+ */
+ result = Curl_setstropt(&data->set.str[STRING_PROXY],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_PRE_PROXY:
+ /*
+ * Set proxy server:port to use as SOCKS proxy.
+ *
+ * If the proxy is set to "" or NULL we explicitly say that we don't want
+ * to use the socks proxy.
+ */
+ result = Curl_setstropt(&data->set.str[STRING_PRE_PROXY],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_PROXYTYPE:
+ /*
+ * Set proxy type. HTTP/HTTP_1_0/SOCKS4/SOCKS4a/SOCKS5/SOCKS5_HOSTNAME
+ */
+ arg = va_arg(param, long);
+ if((arg < CURLPROXY_HTTP) || (arg > CURLPROXY_SOCKS5_HOSTNAME))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.proxytype = (curl_proxytype)arg;
+ break;
+
+ case CURLOPT_PROXY_TRANSFER_MODE:
+ /*
+ * set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy
+ */
+ switch(va_arg(param, long)) {
+ case 0:
+ data->set.proxy_transfer_mode = FALSE;
+ break;
+ case 1:
+ data->set.proxy_transfer_mode = TRUE;
+ break;
+ default:
+ /* reserve other values for future use */
+ result = CURLE_UNKNOWN_OPTION;
+ break;
+ }
+ break;
+#endif /* CURL_DISABLE_PROXY */
+
+ case CURLOPT_SOCKS5_AUTH:
+ data->set.socks5auth = va_arg(param, unsigned long);
+ if(data->set.socks5auth & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI))
+ result = CURLE_NOT_BUILT_IN;
+ break;
+#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
+ case CURLOPT_SOCKS5_GSSAPI_NEC:
+ /*
+ * Set flag for NEC SOCK5 support
+ */
+ data->set.socks5_gssapi_nec = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+#endif
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_SOCKS5_GSSAPI_SERVICE:
+ case CURLOPT_PROXY_SERVICE_NAME:
+ /*
+ * Set proxy authentication service name for Kerberos 5 and SPNEGO
+ */
+ result = Curl_setstropt(&data->set.str[STRING_PROXY_SERVICE_NAME],
+ va_arg(param, char *));
+ break;
+#endif
+ case CURLOPT_SERVICE_NAME:
+ /*
+ * Set authentication service name for DIGEST-MD5, Kerberos 5 and SPNEGO
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SERVICE_NAME],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_HEADERDATA:
+ /*
+ * Custom pointer to pass the header write callback function
+ */
+ data->set.writeheader = (void *)va_arg(param, void *);
+ break;
+ case CURLOPT_ERRORBUFFER:
+ /*
+ * Error buffer provided by the caller to get the human readable
+ * error string in.
+ */
+ data->set.errorbuffer = va_arg(param, char *);
+ break;
+ case CURLOPT_WRITEDATA:
+ /*
+ * FILE pointer to write to. Or possibly
+ * used as argument to the write callback.
+ */
+ data->set.out = va_arg(param, void *);
+ break;
+
+ case CURLOPT_DIRLISTONLY:
+ /*
+ * An option that changes the command to one that asks for a list only, no
+ * file info details. Used for FTP, POP3 and SFTP.
+ */
+ data->set.ftp_list_only = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_APPEND:
+ /*
+ * We want to upload and append to an existing file. Used for FTP and
+ * SFTP.
+ */
+ data->set.ftp_append = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+#ifndef CURL_DISABLE_FTP
+ case CURLOPT_FTP_FILEMETHOD:
+ /*
+ * How do access files over FTP.
+ */
+ arg = va_arg(param, long);
+ if((arg < CURLFTPMETHOD_DEFAULT) || (arg > CURLFTPMETHOD_SINGLECWD))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.ftp_filemethod = (curl_ftpfile)arg;
+ break;
+ case CURLOPT_FTPPORT:
+ /*
+ * Use FTP PORT, this also specifies which IP address to use
+ */
+ result = Curl_setstropt(&data->set.str[STRING_FTPPORT],
+ va_arg(param, char *));
+ data->set.ftp_use_port = (data->set.str[STRING_FTPPORT]) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_FTP_USE_EPRT:
+ data->set.ftp_use_eprt = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_FTP_USE_EPSV:
+ data->set.ftp_use_epsv = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_FTP_USE_PRET:
+ data->set.ftp_use_pret = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_FTP_SSL_CCC:
+ arg = va_arg(param, long);
+ if((arg < CURLFTPSSL_CCC_NONE) || (arg > CURLFTPSSL_CCC_ACTIVE))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.ftp_ccc = (curl_ftpccc)arg;
+ break;
+
+ case CURLOPT_FTP_SKIP_PASV_IP:
+ /*
+ * Enable or disable FTP_SKIP_PASV_IP, which will disable/enable the
+ * bypass of the IP address in PASV responses.
+ */
+ data->set.ftp_skip_ip = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_FTP_ACCOUNT:
+ result = Curl_setstropt(&data->set.str[STRING_FTP_ACCOUNT],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_FTP_ALTERNATIVE_TO_USER:
+ result = Curl_setstropt(&data->set.str[STRING_FTP_ALTERNATIVE_TO_USER],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_FTPSSLAUTH:
+ /*
+ * Set a specific auth for FTP-SSL transfers.
+ */
+ arg = va_arg(param, long);
+ if((arg < CURLFTPAUTH_DEFAULT) || (arg > CURLFTPAUTH_TLS))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.ftpsslauth = (curl_ftpauth)arg;
+ break;
+ case CURLOPT_KRBLEVEL:
+ /*
+ * A string that defines the kerberos security level.
+ */
+ result = Curl_setstropt(&data->set.str[STRING_KRB_LEVEL],
+ va_arg(param, char *));
+ data->set.krb = (data->set.str[STRING_KRB_LEVEL]) ? TRUE : FALSE;
+ break;
+#endif
+ case CURLOPT_FTP_CREATE_MISSING_DIRS:
+ /*
+ * An FTP/SFTP option that modifies an upload to create missing
+ * directories on the server.
+ */
+ switch(va_arg(param, long)) {
+ case 0:
+ data->set.ftp_create_missing_dirs = 0;
+ break;
+ case 1:
+ data->set.ftp_create_missing_dirs = 1;
+ break;
+ case 2:
+ data->set.ftp_create_missing_dirs = 2;
+ break;
+ default:
+ /* reserve other values for future use */
+ result = CURLE_UNKNOWN_OPTION;
+ break;
+ }
+ break;
+ case CURLOPT_READDATA:
+ /*
+ * FILE pointer to read the file to be uploaded from. Or possibly
+ * used as argument to the read callback.
+ */
+ data->set.in_set = va_arg(param, void *);
+ break;
+ case CURLOPT_INFILESIZE:
+ /*
+ * If known, this should inform curl about the file size of the
+ * to-be-uploaded file.
+ */
+ arg = va_arg(param, long);
+ if(arg < -1)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.filesize = arg;
+ break;
+ case CURLOPT_INFILESIZE_LARGE:
+ /*
+ * If known, this should inform curl about the file size of the
+ * to-be-uploaded file.
+ */
+ bigsize = va_arg(param, curl_off_t);
+ if(bigsize < -1)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.filesize = bigsize;
+ break;
+ case CURLOPT_LOW_SPEED_LIMIT:
+ /*
+ * The low speed limit that if transfers are below this for
+ * CURLOPT_LOW_SPEED_TIME, the transfer is aborted.
+ */
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.low_speed_limit = arg;
+ break;
+ case CURLOPT_MAX_SEND_SPEED_LARGE:
+ /*
+ * When transfer uploads are faster then CURLOPT_MAX_SEND_SPEED_LARGE
+ * bytes per second the transfer is throttled..
+ */
+ bigsize = va_arg(param, curl_off_t);
+ if(bigsize < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.max_send_speed = bigsize;
+ break;
+ case CURLOPT_MAX_RECV_SPEED_LARGE:
+ /*
+ * When receiving data faster than CURLOPT_MAX_RECV_SPEED_LARGE bytes per
+ * second the transfer is throttled..
+ */
+ bigsize = va_arg(param, curl_off_t);
+ if(bigsize < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.max_recv_speed = bigsize;
+ break;
+ case CURLOPT_LOW_SPEED_TIME:
+ /*
+ * The low speed time that if transfers are below the set
+ * CURLOPT_LOW_SPEED_LIMIT during this time, the transfer is aborted.
+ */
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.low_speed_time = arg;
+ break;
+ case CURLOPT_CURLU:
+ /*
+ * pass CURLU to set URL
+ */
+ data->set.uh = va_arg(param, CURLU *);
+ break;
+ case CURLOPT_URL:
+ /*
+ * The URL to fetch.
+ */
+ if(data->change.url_alloc) {
+ /* the already set URL is allocated, free it first! */
+ Curl_safefree(data->change.url);
+ data->change.url_alloc = FALSE;
+ }
+ result = Curl_setstropt(&data->set.str[STRING_SET_URL],
+ va_arg(param, char *));
+ data->change.url = data->set.str[STRING_SET_URL];
+ break;
+ case CURLOPT_PORT:
+ /*
+ * The port number to use when getting the URL
+ */
+ arg = va_arg(param, long);
+ if((arg < 0) || (arg > 65535))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.use_port = arg;
+ break;
+ case CURLOPT_TIMEOUT:
+ /*
+ * The maximum time you allow curl to use for a single transfer
+ * operation.
+ */
+ arg = va_arg(param, long);
+ if((arg >= 0) && (arg <= (INT_MAX/1000)))
+ data->set.timeout = arg * 1000;
+ else
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ break;
+
+ case CURLOPT_TIMEOUT_MS:
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.timeout = arg;
+ break;
+
+ case CURLOPT_CONNECTTIMEOUT:
+ /*
+ * The maximum time you allow curl to use to connect.
+ */
+ arg = va_arg(param, long);
+ if((arg >= 0) && (arg <= (INT_MAX/1000)))
+ data->set.connecttimeout = arg * 1000;
+ else
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ break;
+
+ case CURLOPT_CONNECTTIMEOUT_MS:
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.connecttimeout = arg;
+ break;
+
+ case CURLOPT_ACCEPTTIMEOUT_MS:
+ /*
+ * The maximum time you allow curl to wait for server connect
+ */
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.accepttimeout = arg;
+ break;
+
+ case CURLOPT_USERPWD:
+ /*
+ * user:password to use in the operation
+ */
+ result = setstropt_userpwd(va_arg(param, char *),
+ &data->set.str[STRING_USERNAME],
+ &data->set.str[STRING_PASSWORD]);
+ break;
+
+ case CURLOPT_USERNAME:
+ /*
+ * authentication user name to use in the operation
+ */
+ result = Curl_setstropt(&data->set.str[STRING_USERNAME],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_PASSWORD:
+ /*
+ * authentication password to use in the operation
+ */
+ result = Curl_setstropt(&data->set.str[STRING_PASSWORD],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_LOGIN_OPTIONS:
+ /*
+ * authentication options to use in the operation
+ */
+ result = Curl_setstropt(&data->set.str[STRING_OPTIONS],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_XOAUTH2_BEARER:
+ /*
+ * OAuth 2.0 bearer token to use in the operation
+ */
+ result = Curl_setstropt(&data->set.str[STRING_BEARER],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_POSTQUOTE:
+ /*
+ * List of RAW FTP commands to use after a transfer
+ */
+ data->set.postquote = va_arg(param, struct curl_slist *);
+ break;
+ case CURLOPT_PREQUOTE:
+ /*
+ * List of RAW FTP commands to use prior to RETR (Wesley Laxton)
+ */
+ data->set.prequote = va_arg(param, struct curl_slist *);
+ break;
+ case CURLOPT_QUOTE:
+ /*
+ * List of RAW FTP commands to use before a transfer
+ */
+ data->set.quote = va_arg(param, struct curl_slist *);
+ break;
+ case CURLOPT_RESOLVE:
+ /*
+ * List of NAME:[address] names to populate the DNS cache with
+ * Prefix the NAME with dash (-) to _remove_ the name from the cache.
+ *
+ * Names added with this API will remain in the cache until explicitly
+ * removed or the handle is cleaned up.
+ *
+ * This API can remove any name from the DNS cache, but only entries
+ * that aren't actually in use right now will be pruned immediately.
+ */
+ data->set.resolve = va_arg(param, struct curl_slist *);
+ data->change.resolve = data->set.resolve;
+ break;
+ case CURLOPT_PROGRESSFUNCTION:
+ /*
+ * Progress callback function
+ */
+ data->set.fprogress = va_arg(param, curl_progress_callback);
+ if(data->set.fprogress)
+ data->progress.callback = TRUE; /* no longer internal */
+ else
+ data->progress.callback = FALSE; /* NULL enforces internal */
+ break;
+
+ case CURLOPT_XFERINFOFUNCTION:
+ /*
+ * Transfer info callback function
+ */
+ data->set.fxferinfo = va_arg(param, curl_xferinfo_callback);
+ if(data->set.fxferinfo)
+ data->progress.callback = TRUE; /* no longer internal */
+ else
+ data->progress.callback = FALSE; /* NULL enforces internal */
+
+ break;
+
+ case CURLOPT_PROGRESSDATA:
+ /*
+ * Custom client data to pass to the progress callback
+ */
+ data->set.progress_client = va_arg(param, void *);
+ break;
+
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXYUSERPWD:
+ /*
+ * user:password needed to use the proxy
+ */
+ result = setstropt_userpwd(va_arg(param, char *),
+ &data->set.str[STRING_PROXYUSERNAME],
+ &data->set.str[STRING_PROXYPASSWORD]);
+ break;
+ case CURLOPT_PROXYUSERNAME:
+ /*
+ * authentication user name to use in the operation
+ */
+ result = Curl_setstropt(&data->set.str[STRING_PROXYUSERNAME],
+ va_arg(param, char *));
+ break;
+ case CURLOPT_PROXYPASSWORD:
+ /*
+ * authentication password to use in the operation
+ */
+ result = Curl_setstropt(&data->set.str[STRING_PROXYPASSWORD],
+ va_arg(param, char *));
+ break;
+ case CURLOPT_NOPROXY:
+ /*
+ * proxy exception list
+ */
+ result = Curl_setstropt(&data->set.str[STRING_NOPROXY],
+ va_arg(param, char *));
+ break;
+#endif
+
+ case CURLOPT_RANGE:
+ /*
+ * What range of the file you want to transfer
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SET_RANGE],
+ va_arg(param, char *));
+ break;
+ case CURLOPT_RESUME_FROM:
+ /*
+ * Resume transfer at the given file position
+ */
+ arg = va_arg(param, long);
+ if(arg < -1)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.set_resume_from = arg;
+ break;
+ case CURLOPT_RESUME_FROM_LARGE:
+ /*
+ * Resume transfer at the given file position
+ */
+ bigsize = va_arg(param, curl_off_t);
+ if(bigsize < -1)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.set_resume_from = bigsize;
+ break;
+ case CURLOPT_DEBUGFUNCTION:
+ /*
+ * stderr write callback.
+ */
+ data->set.fdebug = va_arg(param, curl_debug_callback);
+ /*
+ * if the callback provided is NULL, it'll use the default callback
+ */
+ break;
+ case CURLOPT_DEBUGDATA:
+ /*
+ * Set to a void * that should receive all error writes. This
+ * defaults to CURLOPT_STDERR for normal operations.
+ */
+ data->set.debugdata = va_arg(param, void *);
+ break;
+ case CURLOPT_STDERR:
+ /*
+ * Set to a FILE * that should receive all error writes. This
+ * defaults to stderr for normal operations.
+ */
+ data->set.err = va_arg(param, FILE *);
+ if(!data->set.err)
+ data->set.err = stderr;
+ break;
+ case CURLOPT_HEADERFUNCTION:
+ /*
+ * Set header write callback
+ */
+ data->set.fwrite_header = va_arg(param, curl_write_callback);
+ break;
+ case CURLOPT_WRITEFUNCTION:
+ /*
+ * Set data write callback
+ */
+ data->set.fwrite_func = va_arg(param, curl_write_callback);
+ if(!data->set.fwrite_func) {
+ data->set.is_fwrite_set = 0;
+ /* When set to NULL, reset to our internal default function */
+ data->set.fwrite_func = (curl_write_callback)fwrite;
+ }
+ else
+ data->set.is_fwrite_set = 1;
+ break;
+ case CURLOPT_READFUNCTION:
+ /*
+ * Read data callback
+ */
+ data->set.fread_func_set = va_arg(param, curl_read_callback);
+ if(!data->set.fread_func_set) {
+ data->set.is_fread_set = 0;
+ /* When set to NULL, reset to our internal default function */
+ data->set.fread_func_set = (curl_read_callback)fread;
+ }
+ else
+ data->set.is_fread_set = 1;
+ break;
+ case CURLOPT_SEEKFUNCTION:
+ /*
+ * Seek callback. Might be NULL.
+ */
+ data->set.seek_func = va_arg(param, curl_seek_callback);
+ break;
+ case CURLOPT_SEEKDATA:
+ /*
+ * Seek control callback. Might be NULL.
+ */
+ data->set.seek_client = va_arg(param, void *);
+ break;
+ case CURLOPT_CONV_FROM_NETWORK_FUNCTION:
+ /*
+ * "Convert from network encoding" callback
+ */
+ data->set.convfromnetwork = va_arg(param, curl_conv_callback);
+ break;
+ case CURLOPT_CONV_TO_NETWORK_FUNCTION:
+ /*
+ * "Convert to network encoding" callback
+ */
+ data->set.convtonetwork = va_arg(param, curl_conv_callback);
+ break;
+ case CURLOPT_CONV_FROM_UTF8_FUNCTION:
+ /*
+ * "Convert from UTF-8 encoding" callback
+ */
+ data->set.convfromutf8 = va_arg(param, curl_conv_callback);
+ break;
+ case CURLOPT_IOCTLFUNCTION:
+ /*
+ * I/O control callback. Might be NULL.
+ */
+ data->set.ioctl_func = va_arg(param, curl_ioctl_callback);
+ break;
+ case CURLOPT_IOCTLDATA:
+ /*
+ * I/O control data pointer. Might be NULL.
+ */
+ data->set.ioctl_client = va_arg(param, void *);
+ break;
+ case CURLOPT_SSLCERT:
+ /*
+ * String that holds file name of the SSL certificate to use
+ */
+ result = Curl_setstropt(&data->set.str[STRING_CERT_ORIG],
+ va_arg(param, char *));
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_SSLCERT:
+ /*
+ * String that holds file name of the SSL certificate to use for proxy
+ */
+ result = Curl_setstropt(&data->set.str[STRING_CERT_PROXY],
+ va_arg(param, char *));
+ break;
+#endif
+ case CURLOPT_SSLCERTTYPE:
+ /*
+ * String that holds file type of the SSL certificate to use
+ */
+ result = Curl_setstropt(&data->set.str[STRING_CERT_TYPE_ORIG],
+ va_arg(param, char *));
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_SSLCERTTYPE:
+ /*
+ * String that holds file type of the SSL certificate to use for proxy
+ */
+ result = Curl_setstropt(&data->set.str[STRING_CERT_TYPE_PROXY],
+ va_arg(param, char *));
+ break;
+#endif
+ case CURLOPT_SSLKEY:
+ /*
+ * String that holds file name of the SSL key to use
+ */
+ result = Curl_setstropt(&data->set.str[STRING_KEY_ORIG],
+ va_arg(param, char *));
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_SSLKEY:
+ /*
+ * String that holds file name of the SSL key to use for proxy
+ */
+ result = Curl_setstropt(&data->set.str[STRING_KEY_PROXY],
+ va_arg(param, char *));
+ break;
+#endif
+ case CURLOPT_SSLKEYTYPE:
+ /*
+ * String that holds file type of the SSL key to use
+ */
+ result = Curl_setstropt(&data->set.str[STRING_KEY_TYPE_ORIG],
+ va_arg(param, char *));
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_SSLKEYTYPE:
+ /*
+ * String that holds file type of the SSL key to use for proxy
+ */
+ result = Curl_setstropt(&data->set.str[STRING_KEY_TYPE_PROXY],
+ va_arg(param, char *));
+ break;
+#endif
+ case CURLOPT_KEYPASSWD:
+ /*
+ * String that holds the SSL or SSH private key password.
+ */
+ result = Curl_setstropt(&data->set.str[STRING_KEY_PASSWD_ORIG],
+ va_arg(param, char *));
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_KEYPASSWD:
+ /*
+ * String that holds the SSL private key password for proxy.
+ */
+ result = Curl_setstropt(&data->set.str[STRING_KEY_PASSWD_PROXY],
+ va_arg(param, char *));
+ break;
+#endif
+ case CURLOPT_SSLENGINE:
+ /*
+ * String that holds the SSL crypto engine.
+ */
+ argptr = va_arg(param, char *);
+ if(argptr && argptr[0]) {
+ result = Curl_setstropt(&data->set.str[STRING_SSL_ENGINE], argptr);
+ if(!result) {
+ result = Curl_ssl_set_engine(data, argptr);
+ }
+ }
+ break;
+
+ case CURLOPT_SSLENGINE_DEFAULT:
+ /*
+ * flag to set engine as default.
+ */
+ Curl_setstropt(&data->set.str[STRING_SSL_ENGINE], NULL);
+ result = Curl_ssl_set_engine_default(data);
+ break;
+ case CURLOPT_CRLF:
+ /*
+ * Kludgy option to enable CRLF conversions. Subject for removal.
+ */
+ data->set.crlf = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_HAPROXYPROTOCOL:
+ /*
+ * Set to send the HAProxy Proxy Protocol header
+ */
+ data->set.haproxyprotocol = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+#endif
+ case CURLOPT_INTERFACE:
+ /*
+ * Set what interface or address/hostname to bind the socket to when
+ * performing an operation and thus what from-IP your connection will use.
+ */
+ result = Curl_setstropt(&data->set.str[STRING_DEVICE],
+ va_arg(param, char *));
+ break;
+ case CURLOPT_LOCALPORT:
+ /*
+ * Set what local port to bind the socket to when performing an operation.
+ */
+ arg = va_arg(param, long);
+ if((arg < 0) || (arg > 65535))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.localport = curlx_sltous(arg);
+ break;
+ case CURLOPT_LOCALPORTRANGE:
+ /*
+ * Set number of local ports to try, starting with CURLOPT_LOCALPORT.
+ */
+ arg = va_arg(param, long);
+ if((arg < 0) || (arg > 65535))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.localportrange = curlx_sltosi(arg);
+ break;
+ case CURLOPT_GSSAPI_DELEGATION:
+ /*
+ * GSS-API credential delegation bitmask
+ */
+ arg = va_arg(param, long);
+ if(arg < CURLGSSAPI_DELEGATION_NONE)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.gssapi_delegation = arg;
+ break;
+ case CURLOPT_SSL_VERIFYPEER:
+ /*
+ * Enable peer SSL verifying.
+ */
+ data->set.ssl.primary.verifypeer = (0 != va_arg(param, long)) ?
+ TRUE : FALSE;
+
+ /* Update the current connection ssl_config. */
+ if(data->conn) {
+ data->conn->ssl_config.verifypeer =
+ data->set.ssl.primary.verifypeer;
+ }
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_SSL_VERIFYPEER:
+ /*
+ * Enable peer SSL verifying for proxy.
+ */
+ data->set.proxy_ssl.primary.verifypeer =
+ (0 != va_arg(param, long))?TRUE:FALSE;
+
+ /* Update the current connection proxy_ssl_config. */
+ if(data->conn) {
+ data->conn->proxy_ssl_config.verifypeer =
+ data->set.proxy_ssl.primary.verifypeer;
+ }
+ break;
+#endif
+ case CURLOPT_SSL_VERIFYHOST:
+ /*
+ * Enable verification of the host name in the peer certificate
+ */
+ arg = va_arg(param, long);
+
+ /* Obviously people are not reading documentation and too many thought
+ this argument took a boolean when it wasn't and misused it. We thus ban
+ 1 as a sensible input and we warn about its use. Then we only have the
+ 2 action internally stored as TRUE. */
+
+ if(1 == arg) {
+ failf(data, "CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!");
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ }
+
+ data->set.ssl.primary.verifyhost = (0 != arg) ? TRUE : FALSE;
+
+ /* Update the current connection ssl_config. */
+ if(data->conn) {
+ data->conn->ssl_config.verifyhost =
+ data->set.ssl.primary.verifyhost;
+ }
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_SSL_VERIFYHOST:
+ /*
+ * Enable verification of the host name in the peer certificate for proxy
+ */
+ arg = va_arg(param, long);
+
+ /* Obviously people are not reading documentation and too many thought
+ this argument took a boolean when it wasn't and misused it. We thus ban
+ 1 as a sensible input and we warn about its use. Then we only have the
+ 2 action internally stored as TRUE. */
+
+ if(1 == arg) {
+ failf(data, "CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!");
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ }
+
+ data->set.proxy_ssl.primary.verifyhost = (0 != arg)?TRUE:FALSE;
+
+ /* Update the current connection proxy_ssl_config. */
+ if(data->conn) {
+ data->conn->proxy_ssl_config.verifyhost =
+ data->set.proxy_ssl.primary.verifyhost;
+ }
+ break;
+#endif
+ case CURLOPT_SSL_VERIFYSTATUS:
+ /*
+ * Enable certificate status verifying.
+ */
+ if(!Curl_ssl_cert_status_request()) {
+ result = CURLE_NOT_BUILT_IN;
+ break;
+ }
+
+ data->set.ssl.primary.verifystatus = (0 != va_arg(param, long)) ?
+ TRUE : FALSE;
+
+ /* Update the current connection ssl_config. */
+ if(data->conn) {
+ data->conn->ssl_config.verifystatus =
+ data->set.ssl.primary.verifystatus;
+ }
+ break;
+ case CURLOPT_SSL_CTX_FUNCTION:
+ /*
+ * Set a SSL_CTX callback
+ */
+#ifdef USE_SSL
+ if(Curl_ssl->supports & SSLSUPP_SSL_CTX)
+ data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback);
+ else
+#endif
+ result = CURLE_NOT_BUILT_IN;
+ break;
+ case CURLOPT_SSL_CTX_DATA:
+ /*
+ * Set a SSL_CTX callback parameter pointer
+ */
+#ifdef USE_SSL
+ if(Curl_ssl->supports & SSLSUPP_SSL_CTX)
+ data->set.ssl.fsslctxp = va_arg(param, void *);
+ else
+#endif
+ result = CURLE_NOT_BUILT_IN;
+ break;
+ case CURLOPT_SSL_FALSESTART:
+ /*
+ * Enable TLS false start.
+ */
+ if(!Curl_ssl_false_start()) {
+ result = CURLE_NOT_BUILT_IN;
+ break;
+ }
+
+ data->set.ssl.falsestart = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_CERTINFO:
+#ifdef USE_SSL
+ if(Curl_ssl->supports & SSLSUPP_CERTINFO)
+ data->set.ssl.certinfo = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ else
+#endif
+ result = CURLE_NOT_BUILT_IN;
+ break;
+ case CURLOPT_PINNEDPUBLICKEY:
+ /*
+ * Set pinned public key for SSL connection.
+ * Specify file name of the public key in DER format.
+ */
+#ifdef USE_SSL
+ if(Curl_ssl->supports & SSLSUPP_PINNEDPUBKEY)
+ result = Curl_setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG],
+ va_arg(param, char *));
+ else
+#endif
+ result = CURLE_NOT_BUILT_IN;
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_PINNEDPUBLICKEY:
+ /*
+ * Set pinned public key for SSL connection.
+ * Specify file name of the public key in DER format.
+ */
+#ifdef USE_SSL
+ if(Curl_ssl->supports & SSLSUPP_PINNEDPUBKEY)
+ result = Curl_setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY],
+ va_arg(param, char *));
+ else
+#endif
+ result = CURLE_NOT_BUILT_IN;
+ break;
+#endif
+ case CURLOPT_CAINFO:
+ /*
+ * Set CA info for SSL connection. Specify file name of the CA certificate
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_CAFILE_ORIG],
+ va_arg(param, char *));
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_CAINFO:
+ /*
+ * Set CA info SSL connection for proxy. Specify file name of the
+ * CA certificate
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_CAFILE_PROXY],
+ va_arg(param, char *));
+ break;
+#endif
+ case CURLOPT_CAPATH:
+ /*
+ * Set CA path info for SSL connection. Specify directory name of the CA
+ * certificates which have been prepared using openssl c_rehash utility.
+ */
+#ifdef USE_SSL
+ if(Curl_ssl->supports & SSLSUPP_CA_PATH)
+ /* This does not work on windows. */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_CAPATH_ORIG],
+ va_arg(param, char *));
+ else
+#endif
+ result = CURLE_NOT_BUILT_IN;
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_CAPATH:
+ /*
+ * Set CA path info for SSL connection proxy. Specify directory name of the
+ * CA certificates which have been prepared using openssl c_rehash utility.
+ */
+#ifdef USE_SSL
+ if(Curl_ssl->supports & SSLSUPP_CA_PATH)
+ /* This does not work on windows. */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_CAPATH_PROXY],
+ va_arg(param, char *));
+ else
+#endif
+ result = CURLE_NOT_BUILT_IN;
+ break;
+#endif
+ case CURLOPT_CRLFILE:
+ /*
+ * Set CRL file info for SSL connection. Specify file name of the CRL
+ * to check certificates revocation
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_CRLFILE_ORIG],
+ va_arg(param, char *));
+ break;
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_CRLFILE:
+ /*
+ * Set CRL file info for SSL connection for proxy. Specify file name of the
+ * CRL to check certificates revocation
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_CRLFILE_PROXY],
+ va_arg(param, char *));
+ break;
+#endif
+ case CURLOPT_ISSUERCERT:
+ /*
+ * Set Issuer certificate file
+ * to check certificates issuer
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SSL_ISSUERCERT_ORIG],
+ va_arg(param, char *));
+ break;
+#ifndef CURL_DISABLE_TELNET
+ case CURLOPT_TELNETOPTIONS:
+ /*
+ * Set a linked list of telnet options
+ */
+ data->set.telnet_options = va_arg(param, struct curl_slist *);
+ break;
+#endif
+ case CURLOPT_BUFFERSIZE:
+ /*
+ * The application kindly asks for a differently sized receive buffer.
+ * If it seems reasonable, we'll use it.
+ */
+ arg = va_arg(param, long);
+
+ if(arg > READBUFFER_MAX)
+ arg = READBUFFER_MAX;
+ else if(arg < 1)
+ arg = READBUFFER_SIZE;
+ else if(arg < READBUFFER_MIN)
+ arg = READBUFFER_MIN;
+
+ /* Resize if new size */
+ if(arg != data->set.buffer_size) {
+ char *newbuff = realloc(data->state.buffer, arg + 1);
+ if(!newbuff) {
+ DEBUGF(fprintf(stderr, "Error: realloc of buffer failed\n"));
+ result = CURLE_OUT_OF_MEMORY;
+ }
+ else
+ data->state.buffer = newbuff;
+ }
+ data->set.buffer_size = arg;
+
+ break;
+
+ case CURLOPT_UPLOAD_BUFFERSIZE:
+ /*
+ * The application kindly asks for a differently sized upload buffer.
+ * Cap it to sensible.
+ */
+ arg = va_arg(param, long);
+
+ if(arg > UPLOADBUFFER_MAX)
+ arg = UPLOADBUFFER_MAX;
+ else if(arg < UPLOADBUFFER_MIN)
+ arg = UPLOADBUFFER_MIN;
+
+ data->set.upload_buffer_size = arg;
+ Curl_safefree(data->state.ulbuf); /* force a realloc next opportunity */
+ break;
+
+ case CURLOPT_NOSIGNAL:
+ /*
+ * The application asks not to set any signal() or alarm() handlers,
+ * even when using a timeout.
+ */
+ data->set.no_signal = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_SHARE:
+ {
+ struct Curl_share *set;
+ set = va_arg(param, struct Curl_share *);
+
+ /* disconnect from old share, if any */
+ if(data->share) {
+ Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
+
+ if(data->dns.hostcachetype == HCACHE_SHARED) {
+ data->dns.hostcache = NULL;
+ data->dns.hostcachetype = HCACHE_NONE;
+ }
+
+#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
+ if(data->share->cookies == data->cookies)
+ data->cookies = NULL;
+#endif
+
+ if(data->share->sslsession == data->state.session)
+ data->state.session = NULL;
+
+#ifdef USE_LIBPSL
+ if(data->psl == &data->share->psl)
+ data->psl = data->multi? &data->multi->psl: NULL;
+#endif
+
+ data->share->dirty--;
+
+ Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
+ data->share = NULL;
+ }
+
+ /* use new share if it set */
+ data->share = set;
+ if(data->share) {
+
+ Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
+
+ data->share->dirty++;
+
+ if(data->share->specifier & (1<< CURL_LOCK_DATA_DNS)) {
+ /* use shared host cache */
+ data->dns.hostcache = &data->share->hostcache;
+ data->dns.hostcachetype = HCACHE_SHARED;
+ }
+#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
+ if(data->share->cookies) {
+ /* use shared cookie list, first free own one if any */
+ Curl_cookie_cleanup(data->cookies);
+ /* enable cookies since we now use a share that uses cookies! */
+ data->cookies = data->share->cookies;
+ }
+#endif /* CURL_DISABLE_HTTP */
+ if(data->share->sslsession) {
+ data->set.general_ssl.max_ssl_sessions = data->share->max_ssl_sessions;
+ data->state.session = data->share->sslsession;
+ }
+#ifdef USE_LIBPSL
+ if(data->share->specifier & (1 << CURL_LOCK_DATA_PSL))
+ data->psl = &data->share->psl;
+#endif
+
+ Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
+ }
+ /* check for host cache not needed,
+ * it will be done by curl_easy_perform */
+ }
+ break;
+
+ case CURLOPT_PRIVATE:
+ /*
+ * Set private data pointer.
+ */
+ data->set.private_data = va_arg(param, void *);
+ break;
+
+ case CURLOPT_MAXFILESIZE:
+ /*
+ * Set the maximum size of a file to download.
+ */
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.max_filesize = arg;
+ break;
+
+#ifdef USE_SSL
+ case CURLOPT_USE_SSL:
+ /*
+ * Make transfers attempt to use SSL/TLS.
+ */
+ arg = va_arg(param, long);
+ if((arg < CURLUSESSL_NONE) || (arg > CURLUSESSL_ALL))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.use_ssl = (curl_usessl)arg;
+ break;
+
+ case CURLOPT_SSL_OPTIONS:
+ arg = va_arg(param, long);
+ data->set.ssl.enable_beast =
+ (bool)((arg&CURLSSLOPT_ALLOW_BEAST) ? TRUE : FALSE);
+ data->set.ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
+ break;
+
+#ifndef CURL_DISABLE_PROXY
+ case CURLOPT_PROXY_SSL_OPTIONS:
+ arg = va_arg(param, long);
+ data->set.proxy_ssl.enable_beast =
+ (bool)((arg&CURLSSLOPT_ALLOW_BEAST) ? TRUE : FALSE);
+ data->set.proxy_ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
+ break;
+#endif
+
+#endif
+ case CURLOPT_IPRESOLVE:
+ arg = va_arg(param, long);
+ if((arg < CURL_IPRESOLVE_WHATEVER) || (arg > CURL_IPRESOLVE_V6))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.ipver = arg;
+ break;
+
+ case CURLOPT_MAXFILESIZE_LARGE:
+ /*
+ * Set the maximum size of a file to download.
+ */
+ bigsize = va_arg(param, curl_off_t);
+ if(bigsize < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.max_filesize = bigsize;
+ break;
+
+ case CURLOPT_TCP_NODELAY:
+ /*
+ * Enable or disable TCP_NODELAY, which will disable/enable the Nagle
+ * algorithm
+ */
+ data->set.tcp_nodelay = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_IGNORE_CONTENT_LENGTH:
+ data->set.ignorecl = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_CONNECT_ONLY:
+ /*
+ * No data transfer, set up connection and let application use the socket
+ */
+ data->set.connect_only = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_SOCKOPTFUNCTION:
+ /*
+ * socket callback function: called after socket() but before connect()
+ */
+ data->set.fsockopt = va_arg(param, curl_sockopt_callback);
+ break;
+
+ case CURLOPT_SOCKOPTDATA:
+ /*
+ * socket callback data pointer. Might be NULL.
+ */
+ data->set.sockopt_client = va_arg(param, void *);
+ break;
+
+ case CURLOPT_OPENSOCKETFUNCTION:
+ /*
+ * open/create socket callback function: called instead of socket(),
+ * before connect()
+ */
+ data->set.fopensocket = va_arg(param, curl_opensocket_callback);
+ break;
+
+ case CURLOPT_OPENSOCKETDATA:
+ /*
+ * socket callback data pointer. Might be NULL.
+ */
+ data->set.opensocket_client = va_arg(param, void *);
+ break;
+
+ case CURLOPT_CLOSESOCKETFUNCTION:
+ /*
+ * close socket callback function: called instead of close()
+ * when shutting down a connection
+ */
+ data->set.fclosesocket = va_arg(param, curl_closesocket_callback);
+ break;
+
+ case CURLOPT_RESOLVER_START_FUNCTION:
+ /*
+ * resolver start callback function: called before a new resolver request
+ * is started
+ */
+ data->set.resolver_start = va_arg(param, curl_resolver_start_callback);
+ break;
+
+ case CURLOPT_RESOLVER_START_DATA:
+ /*
+ * resolver start callback data pointer. Might be NULL.
+ */
+ data->set.resolver_start_client = va_arg(param, void *);
+ break;
+
+ case CURLOPT_CLOSESOCKETDATA:
+ /*
+ * socket callback data pointer. Might be NULL.
+ */
+ data->set.closesocket_client = va_arg(param, void *);
+ break;
+
+ case CURLOPT_SSL_SESSIONID_CACHE:
+ data->set.ssl.primary.sessionid = (0 != va_arg(param, long)) ?
+ TRUE : FALSE;
+ data->set.proxy_ssl.primary.sessionid = data->set.ssl.primary.sessionid;
+ break;
+
+#ifdef USE_SSH
+ /* we only include SSH options if explicitly built to support SSH */
+ case CURLOPT_SSH_AUTH_TYPES:
+ data->set.ssh_auth_types = va_arg(param, long);
+ break;
+
+ case CURLOPT_SSH_PUBLIC_KEYFILE:
+ /*
+ * Use this file instead of the $HOME/.ssh/id_dsa.pub file
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SSH_PUBLIC_KEY],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_SSH_PRIVATE_KEYFILE:
+ /*
+ * Use this file instead of the $HOME/.ssh/id_dsa file
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SSH_PRIVATE_KEY],
+ va_arg(param, char *));
+ break;
+ case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
+ /*
+ * Option to allow for the MD5 of the host public key to be checked
+ * for validation purposes.
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_SSH_KNOWNHOSTS:
+ /*
+ * Store the file name to read known hosts from.
+ */
+ result = Curl_setstropt(&data->set.str[STRING_SSH_KNOWNHOSTS],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_SSH_KEYFUNCTION:
+ /* setting to NULL is fine since the ssh.c functions themselves will
+ then rever to use the internal default */
+ data->set.ssh_keyfunc = va_arg(param, curl_sshkeycallback);
+ break;
+
+ case CURLOPT_SSH_KEYDATA:
+ /*
+ * Custom client data to pass to the SSH keyfunc callback
+ */
+ data->set.ssh_keyfunc_userp = va_arg(param, void *);
+ break;
+
+ case CURLOPT_SSH_COMPRESSION:
+ data->set.ssh_compression = (0 != va_arg(param, long))?TRUE:FALSE;
+ break;
+#endif /* USE_SSH */
+
+ case CURLOPT_HTTP_TRANSFER_DECODING:
+ /*
+ * disable libcurl transfer encoding is used
+ */
+ data->set.http_te_skip = (0 == va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+ case CURLOPT_HTTP_CONTENT_DECODING:
+ /*
+ * raw data passed to the application when content encoding is used
+ */
+ data->set.http_ce_skip = (0 == va_arg(param, long)) ? TRUE : FALSE;
+ break;
+
+#if !defined(CURL_DISABLE_FTP) || defined(USE_SSH)
+ case CURLOPT_NEW_FILE_PERMS:
+ /*
+ * Uses these permissions instead of 0644
+ */
+ arg = va_arg(param, long);
+ if((arg < 0) || (arg > 0777))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.new_file_perms = arg;
+ break;
+
+ case CURLOPT_NEW_DIRECTORY_PERMS:
+ /*
+ * Uses these permissions instead of 0755
+ */
+ arg = va_arg(param, long);
+ if((arg < 0) || (arg > 0777))
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.new_directory_perms = arg;
+ break;
+#endif
+
+ case CURLOPT_ADDRESS_SCOPE:
+ /*
+ * Use this scope id when using IPv6
+ * We always get longs when passed plain numericals so we should check
+ * that the value fits into an unsigned 32 bit integer.
+ */
+ uarg = va_arg(param, unsigned long);
+#if SIZEOF_LONG > 4
+ if(uarg > UINT_MAX)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+#endif
+ data->set.scope_id = (unsigned int)uarg;
+ break;
+
+ case CURLOPT_PROTOCOLS:
+ /* set the bitmask for the protocols that are allowed to be used for the
+ transfer, which thus helps the app which takes URLs from users or other
+ external inputs and want to restrict what protocol(s) to deal
+ with. Defaults to CURLPROTO_ALL. */
+ data->set.allowed_protocols = va_arg(param, long);
+ break;
+
+ case CURLOPT_REDIR_PROTOCOLS:
+ /* set the bitmask for the protocols that libcurl is allowed to follow to,
+ as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs
+ to be set in both bitmasks to be allowed to get redirected to. Defaults
+ to all protocols except FILE and SCP. */
+ data->set.redir_protocols = va_arg(param, long);
+ break;
+
+ case CURLOPT_DEFAULT_PROTOCOL:
+ /* Set the protocol to use when the URL doesn't include any protocol */
+ result = Curl_setstropt(&data->set.str[STRING_DEFAULT_PROTOCOL],
+ va_arg(param, char *));
+ break;
+#ifndef CURL_DISABLE_SMTP
+ case CURLOPT_MAIL_FROM:
+ /* Set the SMTP mail originator */
+ result = Curl_setstropt(&data->set.str[STRING_MAIL_FROM],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_MAIL_AUTH:
+ /* Set the SMTP auth originator */
+ result = Curl_setstropt(&data->set.str[STRING_MAIL_AUTH],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_MAIL_RCPT:
+ /* Set the list of mail recipients */
+ data->set.mail_rcpt = va_arg(param, struct curl_slist *);
+ break;
+#endif
+
+ case CURLOPT_SASL_IR:
+ /* Enable/disable SASL initial response */
+ data->set.sasl_ir = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+#ifndef CURL_DISABLE_RTSP
+ case CURLOPT_RTSP_REQUEST:
+ {
+ /*
+ * Set the RTSP request method (OPTIONS, SETUP, PLAY, etc...)
+ * Would this be better if the RTSPREQ_* were just moved into here?
+ */
+ long curl_rtspreq = va_arg(param, long);
+ Curl_RtspReq rtspreq = RTSPREQ_NONE;
+ switch(curl_rtspreq) {
+ case CURL_RTSPREQ_OPTIONS:
+ rtspreq = RTSPREQ_OPTIONS;
+ break;
+
+ case CURL_RTSPREQ_DESCRIBE:
+ rtspreq = RTSPREQ_DESCRIBE;
+ break;
+
+ case CURL_RTSPREQ_ANNOUNCE:
+ rtspreq = RTSPREQ_ANNOUNCE;
+ break;
+
+ case CURL_RTSPREQ_SETUP:
+ rtspreq = RTSPREQ_SETUP;
+ break;
+
+ case CURL_RTSPREQ_PLAY:
+ rtspreq = RTSPREQ_PLAY;
+ break;
+
+ case CURL_RTSPREQ_PAUSE:
+ rtspreq = RTSPREQ_PAUSE;
+ break;
+
+ case CURL_RTSPREQ_TEARDOWN:
+ rtspreq = RTSPREQ_TEARDOWN;
+ break;
+
+ case CURL_RTSPREQ_GET_PARAMETER:
+ rtspreq = RTSPREQ_GET_PARAMETER;
+ break;
+
+ case CURL_RTSPREQ_SET_PARAMETER:
+ rtspreq = RTSPREQ_SET_PARAMETER;
+ break;
+
+ case CURL_RTSPREQ_RECORD:
+ rtspreq = RTSPREQ_RECORD;
+ break;
+
+ case CURL_RTSPREQ_RECEIVE:
+ rtspreq = RTSPREQ_RECEIVE;
+ break;
+ default:
+ rtspreq = RTSPREQ_NONE;
+ }
+
+ data->set.rtspreq = rtspreq;
+ break;
+ }
+
+
+ case CURLOPT_RTSP_SESSION_ID:
+ /*
+ * Set the RTSP Session ID manually. Useful if the application is
+ * resuming a previously established RTSP session
+ */
+ result = Curl_setstropt(&data->set.str[STRING_RTSP_SESSION_ID],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_RTSP_STREAM_URI:
+ /*
+ * Set the Stream URI for the RTSP request. Unless the request is
+ * for generic server options, the application will need to set this.
+ */
+ result = Curl_setstropt(&data->set.str[STRING_RTSP_STREAM_URI],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_RTSP_TRANSPORT:
+ /*
+ * The content of the Transport: header for the RTSP request
+ */
+ result = Curl_setstropt(&data->set.str[STRING_RTSP_TRANSPORT],
+ va_arg(param, char *));
+ break;
+
+ case CURLOPT_RTSP_CLIENT_CSEQ:
+ /*
+ * Set the CSEQ number to issue for the next RTSP request. Useful if the
+ * application is resuming a previously broken connection. The CSEQ
+ * will increment from this new number henceforth.
+ */
+ data->state.rtsp_next_client_CSeq = va_arg(param, long);
+ break;
+
+ case CURLOPT_RTSP_SERVER_CSEQ:
+ /* Same as the above, but for server-initiated requests */
+ data->state.rtsp_next_client_CSeq = va_arg(param, long);
+ break;
+
+ case CURLOPT_INTERLEAVEDATA:
+ data->set.rtp_out = va_arg(param, void *);
+ break;
+ case CURLOPT_INTERLEAVEFUNCTION:
+ /* Set the user defined RTP write function */
+ data->set.fwrite_rtp = va_arg(param, curl_write_callback);
+ break;
+#endif
+#ifndef CURL_DISABLE_FTP
+ case CURLOPT_WILDCARDMATCH:
+ data->set.wildcard_enabled = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_CHUNK_BGN_FUNCTION:
+ data->set.chunk_bgn = va_arg(param, curl_chunk_bgn_callback);
+ break;
+ case CURLOPT_CHUNK_END_FUNCTION:
+ data->set.chunk_end = va_arg(param, curl_chunk_end_callback);
+ break;
+ case CURLOPT_FNMATCH_FUNCTION:
+ data->set.fnmatch = va_arg(param, curl_fnmatch_callback);
+ break;
+ case CURLOPT_CHUNK_DATA:
+ data->wildcard.customptr = va_arg(param, void *);
+ break;
+ case CURLOPT_FNMATCH_DATA:
+ data->set.fnmatch_data = va_arg(param, void *);
+ break;
+#endif
+#ifdef USE_TLS_SRP
+ case CURLOPT_TLSAUTH_USERNAME:
+ result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME_ORIG],
+ va_arg(param, char *));
+ if(data->set.str[STRING_TLSAUTH_USERNAME_ORIG] && !data->set.ssl.authtype)
+ data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
+ break;
+ case CURLOPT_PROXY_TLSAUTH_USERNAME:
+ result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_USERNAME_PROXY],
+ va_arg(param, char *));
+ if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
+ !data->set.proxy_ssl.authtype)
+ data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
+ break;
+ case CURLOPT_TLSAUTH_PASSWORD:
+ result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_ORIG],
+ va_arg(param, char *));
+ if(data->set.str[STRING_TLSAUTH_USERNAME_ORIG] && !data->set.ssl.authtype)
+ data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
+ break;
+ case CURLOPT_PROXY_TLSAUTH_PASSWORD:
+ result = Curl_setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_PROXY],
+ va_arg(param, char *));
+ if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
+ !data->set.proxy_ssl.authtype)
+ data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
+ break;
+ case CURLOPT_TLSAUTH_TYPE:
+ argptr = va_arg(param, char *);
+ if(!argptr ||
+ strncasecompare(argptr, "SRP", strlen("SRP")))
+ data->set.ssl.authtype = CURL_TLSAUTH_SRP;
+ else
+ data->set.ssl.authtype = CURL_TLSAUTH_NONE;
+ break;
+ case CURLOPT_PROXY_TLSAUTH_TYPE:
+ argptr = va_arg(param, char *);
+ if(!argptr ||
+ strncasecompare(argptr, "SRP", strlen("SRP")))
+ data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP;
+ else
+ data->set.proxy_ssl.authtype = CURL_TLSAUTH_NONE;
+ break;
+#endif
+#ifdef USE_ARES
+ case CURLOPT_DNS_SERVERS:
+ result = Curl_set_dns_servers(data, va_arg(param, char *));
+ break;
+ case CURLOPT_DNS_INTERFACE:
+ result = Curl_set_dns_interface(data, va_arg(param, char *));
+ break;
+ case CURLOPT_DNS_LOCAL_IP4:
+ result = Curl_set_dns_local_ip4(data, va_arg(param, char *));
+ break;
+ case CURLOPT_DNS_LOCAL_IP6:
+ result = Curl_set_dns_local_ip6(data, va_arg(param, char *));
+ break;
+#endif
+ case CURLOPT_TCP_KEEPALIVE:
+ data->set.tcp_keepalive = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_TCP_KEEPIDLE:
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.tcp_keepidle = arg;
+ break;
+ case CURLOPT_TCP_KEEPINTVL:
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.tcp_keepintvl = arg;
+ break;
+ case CURLOPT_TCP_FASTOPEN:
+#if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN) || \
+ defined(TCP_FASTOPEN_CONNECT)
+ data->set.tcp_fastopen = (0 != va_arg(param, long))?TRUE:FALSE;
+#else
+ result = CURLE_NOT_BUILT_IN;
+#endif
+ break;
+#ifdef USE_NGHTTP2
+ case CURLOPT_SSL_ENABLE_NPN:
+ data->set.ssl_enable_npn = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_SSL_ENABLE_ALPN:
+ data->set.ssl_enable_alpn = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+#endif
+#ifdef USE_UNIX_SOCKETS
+ case CURLOPT_UNIX_SOCKET_PATH:
+ data->set.abstract_unix_socket = FALSE;
+ result = Curl_setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH],
+ va_arg(param, char *));
+ break;
+ case CURLOPT_ABSTRACT_UNIX_SOCKET:
+ data->set.abstract_unix_socket = TRUE;
+ result = Curl_setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH],
+ va_arg(param, char *));
+ break;
+#endif
+
+ case CURLOPT_PATH_AS_IS:
+ data->set.path_as_is = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_PIPEWAIT:
+ data->set.pipewait = (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+ case CURLOPT_STREAM_WEIGHT:
+#ifndef USE_NGHTTP2
+ return CURLE_NOT_BUILT_IN;
+#else
+ arg = va_arg(param, long);
+ if((arg >= 1) && (arg <= 256))
+ data->set.stream_weight = (int)arg;
+ break;
+#endif
+ case CURLOPT_STREAM_DEPENDS:
+ case CURLOPT_STREAM_DEPENDS_E:
+ {
+#ifndef USE_NGHTTP2
+ return CURLE_NOT_BUILT_IN;
+#else
+ struct Curl_easy *dep = va_arg(param, struct Curl_easy *);
+ if(!dep || GOOD_EASY_HANDLE(dep)) {
+ if(data->set.stream_depends_on) {
+ Curl_http2_remove_child(data->set.stream_depends_on, data);
+ }
+ Curl_http2_add_child(dep, data, (option == CURLOPT_STREAM_DEPENDS_E));
+ }
+ break;
+#endif
+ }
+ case CURLOPT_CONNECT_TO:
+ data->set.connect_to = va_arg(param, struct curl_slist *);
+ break;
+ case CURLOPT_SUPPRESS_CONNECT_HEADERS:
+ data->set.suppress_connect_headers = (0 != va_arg(param, long))?TRUE:FALSE;
+ break;
+ case CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS:
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.happy_eyeballs_timeout = arg;
+ break;
+#ifndef CURL_DISABLE_SHUFFLE_DNS
+ case CURLOPT_DNS_SHUFFLE_ADDRESSES:
+ data->set.dns_shuffle_addresses = (0 != va_arg(param, long)) ? TRUE:FALSE;
+ break;
+#endif
+ case CURLOPT_DISALLOW_USERNAME_IN_URL:
+ data->set.disallow_username_in_url =
+ (0 != va_arg(param, long)) ? TRUE : FALSE;
+ break;
+#ifndef CURL_DISABLE_DOH
+ case CURLOPT_DOH_URL:
+ result = Curl_setstropt(&data->set.str[STRING_DOH],
+ va_arg(param, char *));
+ data->set.doh = data->set.str[STRING_DOH]?TRUE:FALSE;
+ break;
+#endif
+ case CURLOPT_UPKEEP_INTERVAL_MS:
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.upkeep_interval_ms = arg;
+ break;
+ case CURLOPT_MAXAGE_CONN:
+ arg = va_arg(param, long);
+ if(arg < 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ data->set.maxage_conn = arg;
+ break;
+ case CURLOPT_TRAILERFUNCTION:
+#ifndef CURL_DISABLE_HTTP
+ data->set.trailer_callback = va_arg(param, curl_trailer_callback);
+#endif
+ break;
+ case CURLOPT_TRAILERDATA:
+#ifndef CURL_DISABLE_HTTP
+ data->set.trailer_data = va_arg(param, void *);
+#endif
+ break;
+#ifdef USE_ALTSVC
+ case CURLOPT_ALTSVC:
+ if(!data->asi) {
+ data->asi = Curl_altsvc_init();
+ if(!data->asi)
+ return CURLE_OUT_OF_MEMORY;
+ }
+ argptr = va_arg(param, char *);
+ result = Curl_setstropt(&data->set.str[STRING_ALTSVC], argptr);
+ if(result)
+ return result;
+ (void)Curl_altsvc_load(data->asi, argptr);
+ break;
+ case CURLOPT_ALTSVC_CTRL:
+ if(!data->asi) {
+ data->asi = Curl_altsvc_init();
+ if(!data->asi)
+ return CURLE_OUT_OF_MEMORY;
+ }
+ arg = va_arg(param, long);
+ result = Curl_altsvc_ctrl(data->asi, arg);
+ if(result)
+ return result;
+ break;
+#endif
+ default:
+ /* unknown tag and its companion, just ignore: */
+ result = CURLE_UNKNOWN_OPTION;
+ break;
+ }
+
+ return result;
+}
+
+/*
+ * curl_easy_setopt() is the external interface for setting options on an
+ * easy handle.
+ *
+ * NOTE: This is one of few API functions that are allowed to be called from
+ * within a callback.
+ */
+
+#undef curl_easy_setopt
+CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...)
+{
+ va_list arg;
+ CURLcode result;
+
+ if(!data)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+
+ va_start(arg, tag);
+
+ result = vsetopt(data, tag, arg);
+
+ va_end(arg);
+ return result;
+}
diff --git a/Utilities/cmcurl/lib/setopt.h b/Utilities/cmcurl/lib/setopt.h
new file mode 100644
index 000000000..c658e04ae
--- /dev/null
+++ b/Utilities/cmcurl/lib/setopt.h
@@ -0,0 +1,29 @@
+#ifndef HEADER_CURL_SETOPT_H
+#define HEADER_CURL_SETOPT_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+CURLcode Curl_setstropt(char **charp, const char *s);
+CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option,
+ va_list arg);
+
+#endif /* HEADER_CURL_SETOPT_H */
diff --git a/Utilities/cmcurl/lib/sha256.c b/Utilities/cmcurl/lib/sha256.c
new file mode 100644
index 000000000..f9287af23
--- /dev/null
+++ b/Utilities/cmcurl/lib/sha256.c
@@ -0,0 +1,267 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2018, Florin Petriuc, <petriuc.florin@gmail.com>
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#ifndef CURL_DISABLE_CRYPTO_AUTH
+
+#include "warnless.h"
+#include "curl_sha256.h"
+
+#if defined(USE_OPENSSL)
+
+#include <openssl/opensslv.h>
+
+#if (OPENSSL_VERSION_NUMBER >= 0x0090800fL)
+#define USE_OPENSSL_SHA256
+#endif
+
+#endif
+
+#ifdef USE_OPENSSL_SHA256
+/* When OpenSSL is available we use the SHA256-function from OpenSSL */
+#include <openssl/sha.h>
+#else
+
+/* When no other crypto library is available we use this code segment */
+
+/* ===== start - public domain SHA256 implementation ===== */
+/* This is based on SHA256 implementation in LibTomCrypt that was released into
+ * public domain by Tom St Denis. */
+
+#define WPA_GET_BE32(a) ((((unsigned long)(a)[0]) << 24) | \
+ (((unsigned long)(a)[1]) << 16) | \
+ (((unsigned long)(a)[2]) << 8) | \
+ ((unsigned long)(a)[3]))
+#define WPA_PUT_BE32(a, val) \
+do { \
+ (a)[0] = (unsigned char)((((unsigned long) (val)) >> 24) & 0xff); \
+ (a)[1] = (unsigned char)((((unsigned long) (val)) >> 16) & 0xff); \
+ (a)[2] = (unsigned char)((((unsigned long) (val)) >> 8) & 0xff); \
+ (a)[3] = (unsigned char)(((unsigned long) (val)) & 0xff); \
+} while(0)
+
+#ifdef HAVE_LONGLONG
+#define WPA_PUT_BE64(a, val) \
+do { \
+ (a)[0] = (unsigned char)(((unsigned long long)(val)) >> 56); \
+ (a)[1] = (unsigned char)(((unsigned long long)(val)) >> 48); \
+ (a)[2] = (unsigned char)(((unsigned long long)(val)) >> 40); \
+ (a)[3] = (unsigned char)(((unsigned long long)(val)) >> 32); \
+ (a)[4] = (unsigned char)(((unsigned long long)(val)) >> 24); \
+ (a)[5] = (unsigned char)(((unsigned long long)(val)) >> 16); \
+ (a)[6] = (unsigned char)(((unsigned long long)(val)) >> 8); \
+ (a)[7] = (unsigned char)(((unsigned long long)(val)) & 0xff); \
+} while(0)
+#else
+#define WPA_PUT_BE64(a, val) \
+do { \
+ (a)[0] = (unsigned char)(((unsigned __int64)(val)) >> 56); \
+ (a)[1] = (unsigned char)(((unsigned __int64)(val)) >> 48); \
+ (a)[2] = (unsigned char)(((unsigned __int64)(val)) >> 40); \
+ (a)[3] = (unsigned char)(((unsigned __int64)(val)) >> 32); \
+ (a)[4] = (unsigned char)(((unsigned __int64)(val)) >> 24); \
+ (a)[5] = (unsigned char)(((unsigned __int64)(val)) >> 16); \
+ (a)[6] = (unsigned char)(((unsigned __int64)(val)) >> 8); \
+ (a)[7] = (unsigned char)(((unsigned __int64)(val)) & 0xff); \
+} while(0)
+#endif
+
+typedef struct sha256_state {
+#ifdef HAVE_LONGLONG
+ unsigned long long length;
+#else
+ unsigned __int64 length;
+#endif
+ unsigned long state[8], curlen;
+ unsigned char buf[64];
+} SHA256_CTX;
+/* the K array */
+static const unsigned long K[64] = {
+ 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL,
+ 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL,
+ 0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL,
+ 0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
+ 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL,
+ 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL,
+ 0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL,
+ 0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
+ 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL,
+ 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL,
+ 0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL,
+ 0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
+ 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
+};
+/* Various logical functions */
+#define RORc(x, y) \
+(((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y) & 31)) | \
+ ((unsigned long)(x) << (unsigned long)(32 - ((y) & 31)))) & 0xFFFFFFFFUL)
+#define Ch(x,y,z) (z ^ (x & (y ^ z)))
+#define Maj(x,y,z) (((x | y) & z) | (x & y))
+#define S(x, n) RORc((x), (n))
+#define R(x, n) (((x)&0xFFFFFFFFUL)>>(n))
+#define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22))
+#define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25))
+#define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3))
+#define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10))
+/* compress 512-bits */
+static int sha256_compress(struct sha256_state *md,
+ unsigned char *buf)
+{
+ unsigned long S[8], W[64];
+ int i;
+ /* copy state into S */
+ for(i = 0; i < 8; i++) {
+ S[i] = md->state[i];
+ }
+ /* copy the state into 512-bits into W[0..15] */
+ for(i = 0; i < 16; i++)
+ W[i] = WPA_GET_BE32(buf + (4 * i));
+ /* fill W[16..63] */
+ for(i = 16; i < 64; i++) {
+ W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) +
+ W[i - 16];
+ }
+ /* Compress */
+#define RND(a,b,c,d,e,f,g,h,i) \
+ unsigned long t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
+ unsigned long t1 = Sigma0(a) + Maj(a, b, c); \
+ d += t0; \
+ h = t0 + t1;
+ for(i = 0; i < 64; ++i) {
+ unsigned long t;
+ RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i);
+ t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4];
+ S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t;
+ }
+ /* feedback */
+ for(i = 0; i < 8; i++) {
+ md->state[i] = md->state[i] + S[i];
+ }
+ return 0;
+}
+/* Initialize the hash state */
+static void SHA256_Init(struct sha256_state *md)
+{
+ md->curlen = 0;
+ md->length = 0;
+ md->state[0] = 0x6A09E667UL;
+ md->state[1] = 0xBB67AE85UL;
+ md->state[2] = 0x3C6EF372UL;
+ md->state[3] = 0xA54FF53AUL;
+ md->state[4] = 0x510E527FUL;
+ md->state[5] = 0x9B05688CUL;
+ md->state[6] = 0x1F83D9ABUL;
+ md->state[7] = 0x5BE0CD19UL;
+}
+/**
+ Process a block of memory though the hash
+ @param md The hash state
+ @param in The data to hash
+ @param inlen The length of the data (octets)
+ @return CRYPT_OK if successful
+*/
+static int SHA256_Update(struct sha256_state *md,
+ const unsigned char *in,
+ unsigned long inlen)
+{
+ unsigned long n;
+#define block_size 64
+ if(md->curlen > sizeof(md->buf))
+ return -1;
+ while(inlen > 0) {
+ if(md->curlen == 0 && inlen >= block_size) {
+ if(sha256_compress(md, (unsigned char *)in) < 0)
+ return -1;
+ md->length += block_size * 8;
+ in += block_size;
+ inlen -= block_size;
+ }
+ else {
+ n = CURLMIN(inlen, (block_size - md->curlen));
+ memcpy(md->buf + md->curlen, in, n);
+ md->curlen += n;
+ in += n;
+ inlen -= n;
+ if(md->curlen == block_size) {
+ if(sha256_compress(md, md->buf) < 0)
+ return -1;
+ md->length += 8 * block_size;
+ md->curlen = 0;
+ }
+ }
+ }
+ return 0;
+}
+/**
+ Terminate the hash to get the digest
+ @param md The hash state
+ @param out [out] The destination of the hash (32 bytes)
+ @return CRYPT_OK if successful
+*/
+static int SHA256_Final(unsigned char *out,
+ struct sha256_state *md)
+{
+ int i;
+ if(md->curlen >= sizeof(md->buf))
+ return -1;
+ /* increase the length of the message */
+ md->length += md->curlen * 8;
+ /* append the '1' bit */
+ md->buf[md->curlen++] = (unsigned char)0x80;
+ /* if the length is currently above 56 bytes we append zeros
+ * then compress. Then we can fall back to padding zeros and length
+ * encoding like normal.
+ */
+ if(md->curlen > 56) {
+ while(md->curlen < 64) {
+ md->buf[md->curlen++] = (unsigned char)0;
+ }
+ sha256_compress(md, md->buf);
+ md->curlen = 0;
+ }
+ /* pad up to 56 bytes of zeroes */
+ while(md->curlen < 56) {
+ md->buf[md->curlen++] = (unsigned char)0;
+ }
+ /* store length */
+ WPA_PUT_BE64(md->buf + 56, md->length);
+ sha256_compress(md, md->buf);
+ /* copy output */
+ for(i = 0; i < 8; i++)
+ WPA_PUT_BE32(out + (4 * i), md->state[i]);
+ return 0;
+}
+/* ===== end - public domain SHA256 implementation ===== */
+
+#endif
+
+void Curl_sha256it(unsigned char *outbuffer, /* 32 unsigned chars */
+ const unsigned char *input)
+{
+ SHA256_CTX ctx;
+ SHA256_Init(&ctx);
+ SHA256_Update(&ctx, input, curlx_uztoui(strlen((char *)input)));
+ SHA256_Final(outbuffer, &ctx);
+}
+
+#endif /* CURL_DISABLE_CRYPTO_AUTH */
diff --git a/Utilities/cmcurl/lib/share.c b/Utilities/cmcurl/lib/share.c
index 5b3957fcf..3d5108610 100644
--- a/Utilities/cmcurl/lib/share.c
+++ b/Utilities/cmcurl/lib/share.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -25,6 +25,7 @@
#include <curl/curl.h>
#include "urldata.h"
#include "share.h"
+#include "psl.h"
#include "vtls/vtls.h"
#include "curl_memory.h"
@@ -102,6 +103,14 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)
break;
case CURL_LOCK_DATA_CONNECT: /* not supported (yet) */
+ if(Curl_conncache_init(&share->conn_cache, 103))
+ res = CURLSHE_NOMEM;
+ break;
+
+ case CURL_LOCK_DATA_PSL:
+#ifndef USE_LIBPSL
+ res = CURLSHE_NOT_BUILT_IN;
+#endif
break;
default:
@@ -186,6 +195,8 @@ curl_share_cleanup(struct Curl_share *share)
return CURLSHE_IN_USE;
}
+ Curl_conncache_close_all_connections(&share->conn_cache);
+ Curl_conncache_destroy(&share->conn_cache);
Curl_hash_destroy(&share->hostcache);
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
@@ -201,6 +212,8 @@ curl_share_cleanup(struct Curl_share *share)
}
#endif
+ Curl_psl_destroy(&share->psl);
+
if(share->unlockfunc)
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
free(share);
diff --git a/Utilities/cmcurl/lib/share.h b/Utilities/cmcurl/lib/share.h
index c039a16cb..a7dea41ad 100644
--- a/Utilities/cmcurl/lib/share.h
+++ b/Utilities/cmcurl/lib/share.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -25,7 +25,9 @@
#include "curl_setup.h"
#include <curl/curl.h>
#include "cookie.h"
+#include "psl.h"
#include "urldata.h"
+#include "conncache.h"
/* SalfordC says "A structure member may not be volatile". Hence:
*/
@@ -43,11 +45,14 @@ struct Curl_share {
curl_lock_function lockfunc;
curl_unlock_function unlockfunc;
void *clientdata;
-
+ struct conncache conn_cache;
struct curl_hash hostcache;
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
struct CookieInfo *cookies;
#endif
+#ifdef USE_LIBPSL
+ struct PslCache psl;
+#endif
struct curl_ssl_session *sslsession;
size_t max_ssl_sessions;
diff --git a/Utilities/cmcurl/lib/sigpipe.h b/Utilities/cmcurl/lib/sigpipe.h
index 800f9d3b4..3960a139d 100644
--- a/Utilities/cmcurl/lib/sigpipe.h
+++ b/Utilities/cmcurl/lib/sigpipe.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -23,7 +23,8 @@
***************************************************************************/
#include "curl_setup.h"
-#if defined(HAVE_SIGNAL_H) && defined(HAVE_SIGACTION) && defined(USE_OPENSSL)
+#if defined(HAVE_SIGNAL_H) && defined(HAVE_SIGACTION) && \
+ (defined(USE_OPENSSL) || defined(USE_MBEDTLS))
#include <signal.h>
struct sigpipe_ignore {
diff --git a/Utilities/cmcurl/lib/slist.c b/Utilities/cmcurl/lib/slist.c
index e5adc0e71..392b84d13 100644
--- a/Utilities/cmcurl/lib/slist.c
+++ b/Utilities/cmcurl/lib/slist.c
@@ -142,4 +142,3 @@ void curl_slist_free_all(struct curl_slist *list)
item = next;
} while(next);
}
-
diff --git a/Utilities/cmcurl/lib/slist.h b/Utilities/cmcurl/lib/slist.h
index b3f498c35..d73dbf672 100644
--- a/Utilities/cmcurl/lib/slist.h
+++ b/Utilities/cmcurl/lib/slist.h
@@ -37,4 +37,3 @@ struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list,
char *data);
#endif /* HEADER_CURL_SLIST_H */
-
diff --git a/Utilities/cmcurl/lib/smb.c b/Utilities/cmcurl/lib/smb.c
index 5b1ffa9b7..76c99a230 100644
--- a/Utilities/cmcurl/lib/smb.c
+++ b/Utilities/cmcurl/lib/smb.c
@@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2014, Bill Nagel <wnagel@tycoint.com>, Exacq Technologies
- * Copyright (C) 2016-2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2016-2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -34,7 +34,7 @@
#include <process.h>
#ifdef CURL_WINDOWS_APP
#define getpid GetCurrentProcessId
-#else
+#elif !defined(MSDOS)
#define getpid _getpid
#endif
#endif
@@ -59,6 +59,7 @@
static CURLcode smb_setup_connection(struct connectdata *conn);
static CURLcode smb_connect(struct connectdata *conn, bool *done);
static CURLcode smb_connection_state(struct connectdata *conn, bool *done);
+static CURLcode smb_do(struct connectdata *conn, bool *done);
static CURLcode smb_request_state(struct connectdata *conn, bool *done);
static CURLcode smb_done(struct connectdata *conn, CURLcode status,
bool premature);
@@ -73,7 +74,7 @@ static CURLcode smb_parse_url_path(struct connectdata *conn);
const struct Curl_handler Curl_handler_smb = {
"SMB", /* scheme */
smb_setup_connection, /* setup_connection */
- ZERO_NULL, /* do_it */
+ smb_do, /* do_it */
smb_done, /* done */
ZERO_NULL, /* do_more */
smb_connect, /* connect_it */
@@ -85,6 +86,7 @@ const struct Curl_handler Curl_handler_smb = {
ZERO_NULL, /* perform_getsock */
smb_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_SMB, /* defport */
CURLPROTO_SMB, /* protocol */
PROTOPT_NONE /* flags */
@@ -97,7 +99,7 @@ const struct Curl_handler Curl_handler_smb = {
const struct Curl_handler Curl_handler_smbs = {
"SMBS", /* scheme */
smb_setup_connection, /* setup_connection */
- ZERO_NULL, /* do_it */
+ smb_do, /* do_it */
smb_done, /* done */
ZERO_NULL, /* do_more */
smb_connect, /* connect_it */
@@ -109,6 +111,7 @@ const struct Curl_handler Curl_handler_smbs = {
ZERO_NULL, /* perform_getsock */
smb_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_SMBS, /* defport */
CURLPROTO_SMBS, /* protocol */
PROTOPT_SSL /* flags */
@@ -144,19 +147,12 @@ static unsigned int smb_swap32(unsigned int x)
((x >> 24) & 0xff);
}
-#ifdef HAVE_LONGLONG
-static unsigned long long smb_swap64(unsigned long long x)
+static curl_off_t smb_swap64(curl_off_t x)
{
- return ((unsigned long long) smb_swap32((unsigned int) x) << 32) |
+ return ((curl_off_t) smb_swap32((unsigned int) x) << 32) |
smb_swap32((unsigned int) (x >> 32));
}
-#else
-static unsigned __int64 smb_swap64(unsigned __int64 x)
-{
- return ((unsigned __int64) smb_swap32((unsigned int) x) << 32) |
- smb_swap32((unsigned int) (x >> 32));
-}
-#endif
+
#else
# define smb_swap16(x) (x)
# define smb_swap32(x) (x)
@@ -178,7 +174,6 @@ enum smb_req_state {
/* SMB request data */
struct smb_request {
enum smb_req_state state;
- char *share;
char *path;
unsigned short tid; /* Even if we connect to the same tree as another */
unsigned short fid; /* request, the tid will be different */
@@ -187,7 +182,7 @@ struct smb_request {
static void conn_state(struct connectdata *conn, enum smb_conn_state newstate)
{
- struct smb_conn *smb = &conn->proto.smbc;
+ struct smb_conn *smbc = &conn->proto.smbc;
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
/* For debug purposes */
static const char * const names[] = {
@@ -199,12 +194,12 @@ static void conn_state(struct connectdata *conn, enum smb_conn_state newstate)
/* LAST */
};
- if(smb->state != newstate)
+ if(smbc->state != newstate)
infof(conn->data, "SMB conn %p state change from %s to %s\n",
- (void *)smb, names[smb->state], names[newstate]);
+ (void *)smbc, names[smbc->state], names[newstate]);
#endif
- smb->state = newstate;
+ smbc->state = newstate;
}
static void request_state(struct connectdata *conn,
@@ -233,6 +228,8 @@ static void request_state(struct connectdata *conn,
req->state = newstate;
}
+/* this should setup things in the connection, not in the easy
+ handle */
static CURLcode smb_setup_connection(struct connectdata *conn)
{
struct smb_request *req;
@@ -258,7 +255,6 @@ static CURLcode smb_connect(struct connectdata *conn, bool *done)
return CURLE_LOGIN_DENIED;
/* Initialize the connection state */
- memset(smbc, 0, sizeof(*smbc));
smbc->state = SMB_CONNECTING;
smbc->recv_buf = malloc(MAX_MESSAGE_SIZE);
if(!smbc->recv_buf)
@@ -371,7 +367,7 @@ static CURLcode smb_send(struct connectdata *conn, ssize_t len,
ssize_t bytes_written;
CURLcode result;
- result = Curl_write(conn, FIRSTSOCKET, conn->data->state.uploadbuffer,
+ result = Curl_write(conn, FIRSTSOCKET, conn->data->state.ulbuf,
len, &bytes_written);
if(result)
return result;
@@ -397,7 +393,7 @@ static CURLcode smb_flush(struct connectdata *conn)
return CURLE_OK;
result = Curl_write(conn, FIRSTSOCKET,
- conn->data->state.uploadbuffer + smbc->sent,
+ conn->data->state.ulbuf + smbc->sent,
len, &bytes_written);
if(result)
return result;
@@ -413,9 +409,12 @@ static CURLcode smb_flush(struct connectdata *conn)
static CURLcode smb_send_message(struct connectdata *conn, unsigned char cmd,
const void *msg, size_t msg_len)
{
- smb_format_message(conn, (struct smb_header *)conn->data->state.uploadbuffer,
+ CURLcode result = Curl_get_upload_buffer(conn->data);
+ if(result)
+ return result;
+ smb_format_message(conn, (struct smb_header *)conn->data->state.ulbuf,
cmd, msg_len);
- memcpy(conn->data->state.uploadbuffer + sizeof(struct smb_header),
+ memcpy(conn->data->state.ulbuf + sizeof(struct smb_header),
msg, msg_len);
return smb_send(conn, sizeof(struct smb_header) + msg_len, 0);
@@ -480,11 +479,11 @@ static CURLcode smb_send_setup(struct connectdata *conn)
static CURLcode smb_send_tree_connect(struct connectdata *conn)
{
- struct smb_request *req = conn->data->req.protop;
struct smb_tree_connect msg;
+ struct smb_conn *smbc = &conn->proto.smbc;
char *p = msg.bytes;
- size_t byte_count = strlen(conn->host.name) + strlen(req->share);
+ size_t byte_count = strlen(conn->host.name) + strlen(smbc->share);
byte_count += strlen(SERVICENAME) + 5; /* 2 nulls and 3 backslashes */
if(byte_count > sizeof(msg.bytes))
return CURLE_FILESIZE_EXCEEDED;
@@ -496,7 +495,7 @@ static CURLcode smb_send_tree_connect(struct connectdata *conn)
MSGCAT("\\\\");
MSGCAT(conn->host.name);
MSGCAT("\\");
- MSGCATNULL(req->share);
+ MSGCATNULL(smbc->share);
MSGCATNULL(SERVICENAME); /* Match any type of service */
byte_count = p - msg.bytes;
msg.byte_count = smb_swap16((unsigned short)byte_count);
@@ -576,11 +575,15 @@ static CURLcode smb_send_read(struct connectdata *conn)
static CURLcode smb_send_write(struct connectdata *conn)
{
- struct smb_write *msg = (struct smb_write *)conn->data->state.uploadbuffer;
+ struct smb_write *msg;
struct smb_request *req = conn->data->req.protop;
curl_off_t offset = conn->data->req.offset;
-
curl_off_t upload_size = conn->data->req.size - conn->data->req.bytecount;
+ CURLcode result = Curl_get_upload_buffer(conn->data);
+ if(result)
+ return result;
+ msg = (struct smb_write *)conn->data->state.ulbuf;
+
if(upload_size >= MAX_PAYLOAD_SIZE - 1) /* There is one byte of padding */
upload_size = MAX_PAYLOAD_SIZE - 1;
@@ -607,9 +610,10 @@ static CURLcode smb_send_and_recv(struct connectdata *conn, void **msg)
/* Check if there is data in the transfer buffer */
if(!smbc->send_size && smbc->upload_size) {
- int nread = smbc->upload_size > UPLOAD_BUFSIZE ? UPLOAD_BUFSIZE :
- (int) smbc->upload_size;
- conn->data->req.upload_fromhere = conn->data->state.uploadbuffer;
+ size_t nread = smbc->upload_size > conn->data->set.upload_buffer_size ?
+ conn->data->set.upload_buffer_size :
+ smbc->upload_size;
+ conn->data->req.upload_fromhere = conn->data->state.ulbuf;
result = Curl_fillreadbuffer(conn, nread, &nread);
if(result && result != CURLE_AGAIN)
return result;
@@ -646,7 +650,7 @@ static CURLcode smb_connection_state(struct connectdata *conn, bool *done)
if(smbc->state == SMB_CONNECTING) {
#ifdef USE_SSL
if((conn->handler->flags & PROTOPT_SSL)) {
- bool ssl_done;
+ bool ssl_done = FALSE;
result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &ssl_done);
if(result && result != CURLE_AGAIN)
return result;
@@ -713,6 +717,24 @@ static CURLcode smb_connection_state(struct connectdata *conn, bool *done)
return CURLE_OK;
}
+/*
+ * Convert a timestamp from the Windows world (100 nsec units from 1 Jan 1601)
+ * to Posix time. Cap the output to fit within a time_t.
+ */
+static void get_posix_time(time_t *out, curl_off_t timestamp)
+{
+ timestamp -= 116444736000000000;
+ timestamp /= 10000000;
+#if SIZEOF_TIME_T < SIZEOF_CURL_OFF_T
+ if(timestamp > TIME_T_MAX)
+ *out = TIME_T_MAX;
+ else if(timestamp < TIME_T_MIN)
+ *out = TIME_T_MIN;
+ else
+#endif
+ *out = (time_t) timestamp;
+}
+
static CURLcode smb_request_state(struct connectdata *conn, bool *done)
{
struct smb_request *req = conn->data->req.protop;
@@ -723,6 +745,7 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
unsigned short off;
CURLcode result;
void *msg = NULL;
+ const struct smb_nt_create_response *smb_m;
/* Start the request */
if(req->state == SMB_REQUESTING) {
@@ -765,7 +788,8 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
next_state = SMB_TREE_DISCONNECT;
break;
}
- req->fid = smb_swap16(((struct smb_nt_create_response *)msg)->fid);
+ smb_m = (const struct smb_nt_create_response*) msg;
+ req->fid = smb_swap16(smb_m->fid);
conn->data->req.offset = 0;
if(conn->data->set.upload) {
conn->data->req.size = conn->data->state.infilesize;
@@ -773,10 +797,18 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
next_state = SMB_UPLOAD;
}
else {
- conn->data->req.size =
- smb_swap64(((struct smb_nt_create_response *)msg)->end_of_file);
- Curl_pgrsSetDownloadSize(conn->data, conn->data->req.size);
- next_state = SMB_DOWNLOAD;
+ smb_m = (const struct smb_nt_create_response*) msg;
+ conn->data->req.size = smb_swap64(smb_m->end_of_file);
+ if(conn->data->req.size < 0) {
+ req->result = CURLE_WEIRD_SERVER_REPLY;
+ next_state = SMB_CLOSE;
+ }
+ else {
+ Curl_pgrsSetDownloadSize(conn->data, conn->data->req.size);
+ if(conn->data->set.get_filetime)
+ get_posix_time(&conn->data->info.filetime, smb_m->last_change_time);
+ next_state = SMB_DOWNLOAD;
+ }
}
break;
@@ -887,48 +919,40 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
static CURLcode smb_done(struct connectdata *conn, CURLcode status,
bool premature)
{
- struct smb_request *req = conn->data->req.protop;
-
(void) premature;
-
- Curl_safefree(req->share);
Curl_safefree(conn->data->req.protop);
-
return status;
}
static CURLcode smb_disconnect(struct connectdata *conn, bool dead)
{
struct smb_conn *smbc = &conn->proto.smbc;
- struct smb_request *req = conn->data->req.protop;
-
(void) dead;
-
+ Curl_safefree(smbc->share);
Curl_safefree(smbc->domain);
Curl_safefree(smbc->recv_buf);
-
- /* smb_done is not always called, so cleanup the request */
- if(req) {
- Curl_safefree(req->share);
- }
-
return CURLE_OK;
}
static int smb_getsock(struct connectdata *conn, curl_socket_t *socks,
int numsocks)
{
- struct smb_conn *smbc = &conn->proto.smbc;
-
if(!numsocks)
return GETSOCK_BLANK;
socks[0] = conn->sock[FIRSTSOCKET];
+ return GETSOCK_READSOCK(0) | GETSOCK_WRITESOCK(0);
+}
- if(smbc->send_size || smbc->upload_size)
- return GETSOCK_WRITESOCK(0);
+static CURLcode smb_do(struct connectdata *conn, bool *done)
+{
+ struct smb_conn *smbc = &conn->proto.smbc;
- return GETSOCK_READSOCK(0);
+ *done = FALSE;
+ if(smbc->share) {
+ return CURLE_OK;
+ }
+ return CURLE_URL_MALFORMAT;
}
static CURLcode smb_parse_url_path(struct connectdata *conn)
@@ -936,30 +960,28 @@ static CURLcode smb_parse_url_path(struct connectdata *conn)
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
struct smb_request *req = data->req.protop;
+ struct smb_conn *smbc = &conn->proto.smbc;
char *path;
char *slash;
/* URL decode the path */
- result = Curl_urldecode(data, data->state.path, 0, &path, NULL, TRUE);
+ result = Curl_urldecode(data, data->state.up.path, 0, &path, NULL, TRUE);
if(result)
return result;
/* Parse the path for the share */
- req->share = strdup((*path == '/' || *path == '\\') ? path + 1 : path);
- if(!req->share) {
- free(path);
-
+ smbc->share = strdup((*path == '/' || *path == '\\') ? path + 1 : path);
+ free(path);
+ if(!smbc->share)
return CURLE_OUT_OF_MEMORY;
- }
- slash = strchr(req->share, '/');
+ slash = strchr(smbc->share, '/');
if(!slash)
- slash = strchr(req->share, '\\');
+ slash = strchr(smbc->share, '\\');
/* The share must be present */
if(!slash) {
- free(path);
-
+ Curl_safefree(smbc->share);
return CURLE_URL_MALFORMAT;
}
@@ -967,13 +989,11 @@ static CURLcode smb_parse_url_path(struct connectdata *conn)
backslashes */
*slash++ = 0;
req->path = slash;
+
for(; *slash; slash++) {
if(*slash == '/')
*slash = '\\';
}
-
- free(path);
-
return CURLE_OK;
}
diff --git a/Utilities/cmcurl/lib/smb.h b/Utilities/cmcurl/lib/smb.h
index 1a4f66e5a..9ce6b5615 100644
--- a/Utilities/cmcurl/lib/smb.h
+++ b/Utilities/cmcurl/lib/smb.h
@@ -8,6 +8,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2014, Bill Nagel <wnagel@tycoint.com>, Exacq Technologies
+ * Copyright (C) 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -34,6 +35,7 @@ struct smb_conn {
enum smb_conn_state state;
char *user;
char *domain;
+ char *share;
unsigned char challenge[8];
unsigned int session_key;
unsigned short uid;
@@ -165,11 +167,7 @@ struct smb_nt_create {
unsigned int flags;
unsigned int root_fid;
unsigned int access;
-#ifdef HAVE_LONGLONG
- unsigned long long allocation_size;
-#else
- unsigned __int64 allocation_size;
-#endif
+ curl_off_t allocation_size;
unsigned int ext_file_attributes;
unsigned int share_access;
unsigned int create_disposition;
@@ -187,25 +185,15 @@ struct smb_nt_create_response {
unsigned char op_lock_level;
unsigned short fid;
unsigned int create_disposition;
-#ifdef HAVE_LONGLONG
- unsigned long long create_time;
- unsigned long long last_access_time;
- unsigned long long last_write_time;
- unsigned long long last_change_time;
-#else
- unsigned __int64 create_time;
- unsigned __int64 last_access_time;
- unsigned __int64 last_write_time;
- unsigned __int64 last_change_time;
-#endif
+
+ curl_off_t create_time;
+ curl_off_t last_access_time;
+ curl_off_t last_write_time;
+ curl_off_t last_change_time;
unsigned int ext_file_attributes;
-#ifdef HAVE_LONGLONG
- unsigned long long allocation_size;
- unsigned long long end_of_file;
-#else
- unsigned __int64 allocation_size;
- unsigned __int64 end_of_file;
-#endif
+ curl_off_t allocation_size;
+ curl_off_t end_of_file;
+
} PACK;
struct smb_read {
diff --git a/Utilities/cmcurl/lib/smtp.c b/Utilities/cmcurl/lib/smtp.c
index fe064cb2f..4a3462b84 100644
--- a/Utilities/cmcurl/lib/smtp.c
+++ b/Utilities/cmcurl/lib/smtp.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -28,6 +28,7 @@
* RFC4954 SMTP Authentication
* RFC5321 SMTP protocol
* RFC6749 OAuth 2.0 Authorization Framework
+ * RFC8314 Use of TLS for Email Submission and Access
* Draft SMTP URL Interface <draft-earhart-url-smtp-00.txt>
* Draft LOGIN SASL Mechanism <draft-murchison-sasl-login-00.txt>
*
@@ -67,6 +68,7 @@
#include "transfer.h"
#include "escape.h"
#include "http.h" /* for HTTP proxy tunnel stuff */
+#include "mime.h"
#include "socks.h"
#include "smtp.h"
#include "strtoofft.h"
@@ -124,6 +126,7 @@ const struct Curl_handler Curl_handler_smtp = {
ZERO_NULL, /* perform_getsock */
smtp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_SMTP, /* defport */
CURLPROTO_SMTP, /* protocol */
PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY | /* flags */
@@ -150,6 +153,7 @@ const struct Curl_handler Curl_handler_smtps = {
ZERO_NULL, /* perform_getsock */
smtp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_SMTPS, /* defport */
CURLPROTO_SMTPS, /* protocol */
PROTOPT_CLOSEACTION | PROTOPT_SSL
@@ -157,58 +161,6 @@ const struct Curl_handler Curl_handler_smtps = {
};
#endif
-#ifndef CURL_DISABLE_HTTP
-/*
- * HTTP-proxyed SMTP protocol handler.
- */
-
-static const struct Curl_handler Curl_handler_smtp_proxy = {
- "SMTP", /* scheme */
- Curl_http_setup_conn, /* setup_connection */
- Curl_http, /* do_it */
- Curl_http_done, /* done */
- ZERO_NULL, /* do_more */
- ZERO_NULL, /* connect_it */
- ZERO_NULL, /* connecting */
- ZERO_NULL, /* doing */
- ZERO_NULL, /* proto_getsock */
- ZERO_NULL, /* doing_getsock */
- ZERO_NULL, /* domore_getsock */
- ZERO_NULL, /* perform_getsock */
- ZERO_NULL, /* disconnect */
- ZERO_NULL, /* readwrite */
- PORT_SMTP, /* defport */
- CURLPROTO_HTTP, /* protocol */
- PROTOPT_NONE /* flags */
-};
-
-#ifdef USE_SSL
-/*
- * HTTP-proxyed SMTPS protocol handler.
- */
-
-static const struct Curl_handler Curl_handler_smtps_proxy = {
- "SMTPS", /* scheme */
- Curl_http_setup_conn, /* setup_connection */
- Curl_http, /* do_it */
- Curl_http_done, /* done */
- ZERO_NULL, /* do_more */
- ZERO_NULL, /* connect_it */
- ZERO_NULL, /* connecting */
- ZERO_NULL, /* doing */
- ZERO_NULL, /* proto_getsock */
- ZERO_NULL, /* doing_getsock */
- ZERO_NULL, /* domore_getsock */
- ZERO_NULL, /* perform_getsock */
- ZERO_NULL, /* disconnect */
- ZERO_NULL, /* readwrite */
- PORT_SMTPS, /* defport */
- CURLPROTO_HTTP, /* protocol */
- PROTOPT_NONE /* flags */
-};
-#endif
-#endif
-
/* SASL parameters for the smtp protocol */
static const struct SASLproto saslsmtp = {
"smtp", /* The service name */
@@ -256,8 +208,12 @@ static bool smtp_endofresp(struct connectdata *conn, char *line, size_t len,
Section 4. Examples of RFC-4954 but some e-mail servers ignore this and
only send the response code instead as per Section 4.2. */
if(line[3] == ' ' || len == 5) {
+ char tmpline[6];
+
result = TRUE;
- *resp = curlx_sltosi(strtol(line, NULL, 10));
+ memset(tmpline, '\0', sizeof(tmpline));
+ memcpy(tmpline, line, (len == 5 ? 5 : 3));
+ *resp = curlx_sltosi(strtol(tmpline, NULL, 10));
/* Make sure real server never sends internal value */
if(*resp == 1)
@@ -281,23 +237,30 @@ static bool smtp_endofresp(struct connectdata *conn, char *line, size_t len,
*/
static void smtp_get_message(char *buffer, char **outptr)
{
- size_t len = 0;
+ size_t len = strlen(buffer);
char *message = NULL;
- /* Find the start of the message */
- for(message = buffer + 4; *message == ' ' || *message == '\t'; message++)
- ;
-
- /* Find the end of the message */
- for(len = strlen(message); len--;)
- if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' &&
- message[len] != '\t')
- break;
-
- /* Terminate the message */
- if(++len) {
- message[len] = '\0';
+ if(len > 4) {
+ /* Find the start of the message */
+ len -= 4;
+ for(message = buffer + 4; *message == ' ' || *message == '\t';
+ message++, len--)
+ ;
+
+ /* Find the end of the message */
+ for(; len--;)
+ if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' &&
+ message[len] != '\t')
+ break;
+
+ /* Terminate the message */
+ if(++len) {
+ message[len] = '\0';
+ }
}
+ else
+ /* junk input => zero length output */
+ message = &buffer[len];
*outptr = message;
}
@@ -580,8 +543,40 @@ static CURLcode smtp_perform_mail(struct connectdata *conn)
}
}
+ /* Prepare the mime data if some. */
+ if(data->set.mimepost.kind != MIMEKIND_NONE) {
+ /* Use the whole structure as data. */
+ data->set.mimepost.flags &= ~MIME_BODY_ONLY;
+
+ /* Add external headers and mime version. */
+ curl_mime_headers(&data->set.mimepost, data->set.headers, 0);
+ result = Curl_mime_prepare_headers(&data->set.mimepost, NULL,
+ NULL, MIMESTRATEGY_MAIL);
+
+ if(!result)
+ if(!Curl_checkheaders(conn, "Mime-Version"))
+ result = Curl_mime_add_header(&data->set.mimepost.curlheaders,
+ "Mime-Version: 1.0");
+
+ /* Make sure we will read the entire mime structure. */
+ if(!result)
+ result = Curl_mime_rewind(&data->set.mimepost);
+
+ if(result) {
+ free(from);
+ free(auth);
+ return result;
+ }
+
+ data->state.infilesize = Curl_mime_size(&data->set.mimepost);
+
+ /* Read from mime structure. */
+ data->state.fread_func = (curl_read_callback) Curl_mime_read;
+ data->state.in = (void *) &data->set.mimepost;
+ }
+
/* Calculate the optional SIZE parameter */
- if(conn->proto.smtpc.size_supported && conn->data->state.infilesize > 0) {
+ if(conn->proto.smtpc.size_supported && data->state.infilesize > 0) {
size = aprintf("%" CURL_FORMAT_CURL_OFF_T, data->state.infilesize);
if(!size) {
@@ -714,7 +709,6 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode,
struct smtp_conn *smtpc = &conn->proto.smtpc;
const char *line = data->state.buffer;
size_t len = strlen(line);
- size_t wordlen;
(void)instate; /* no use for this yet */
@@ -749,6 +743,7 @@ static CURLcode smtp_state_ehlo_resp(struct connectdata *conn, int smtpcode,
/* Loop through the data line */
for(;;) {
size_t llen;
+ size_t wordlen;
unsigned int mechbit;
while(len &&
@@ -965,7 +960,7 @@ static CURLcode smtp_state_data_resp(struct connectdata *conn, int smtpcode,
Curl_pgrsSetUploadSize(data, data->state.infilesize);
/* SMTP upload */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, FIRSTSOCKET, NULL);
+ Curl_setup_transfer(data, -1, -1, FALSE, FIRSTSOCKET);
/* End of DO phase */
state(conn, SMTP_STOP);
@@ -1090,19 +1085,20 @@ static CURLcode smtp_multi_statemach(struct connectdata *conn, bool *done)
return result;
}
- result = Curl_pp_statemach(&smtpc->pp, FALSE);
+ result = Curl_pp_statemach(&smtpc->pp, FALSE, FALSE);
*done = (smtpc->state == SMTP_STOP) ? TRUE : FALSE;
return result;
}
-static CURLcode smtp_block_statemach(struct connectdata *conn)
+static CURLcode smtp_block_statemach(struct connectdata *conn,
+ bool disconnecting)
{
CURLcode result = CURLE_OK;
struct smtp_conn *smtpc = &conn->proto.smtpc;
while(smtpc->state != SMTP_STOP && !result)
- result = Curl_pp_statemach(&smtpc->pp, TRUE);
+ result = Curl_pp_statemach(&smtpc->pp, TRUE, disconnecting);
return result;
}
@@ -1205,11 +1201,15 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status,
if(!smtp || !pp->conn)
return CURLE_OK;
+ /* Cleanup our per-request based variables */
+ Curl_safefree(smtp->custom);
+
if(status) {
connclose(conn, "SMTP done with bad status"); /* marked for closure */
result = status; /* use the already set error code */
}
- else if(!data->set.connect_only && data->set.upload && data->set.mail_rcpt) {
+ else if(!data->set.connect_only && data->set.mail_rcpt &&
+ (data->set.upload || data->set.mimepost.kind)) {
/* Calculate the EOB taking into account any terminating CRLF from the
previous line of the email or the CRLF of the DATA command when there
is "no mail data". RFC-5321, sect. 4.1.1.4.
@@ -1219,7 +1219,7 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status,
returned CURLE_AGAIN, we duplicate the EOB now rather than when the
bytes written doesn't equal len. */
if(smtp->trailing_crlf || !conn->data->state.infilesize) {
- eob = strdup(SMTP_EOB + 2);
+ eob = strdup(&SMTP_EOB[2]);
len = SMTP_EOB_LEN - 2;
}
else {
@@ -1246,25 +1246,17 @@ static CURLcode smtp_done(struct connectdata *conn, CURLcode status,
}
else {
/* Successfully sent so adjust the response timeout relative to now */
- pp->response = Curl_tvnow();
+ pp->response = Curl_now();
free(eob);
}
state(conn, SMTP_POSTDATA);
- /* Run the state-machine
-
- TODO: when the multi interface is used, this _really_ should be using
- the smtp_multi_statemach function but we have no general support for
- non-blocking DONE operations!
- */
- result = smtp_block_statemach(conn);
+ /* Run the state-machine */
+ result = smtp_block_statemach(conn, FALSE);
}
- /* Cleanup our per-request based variables */
- Curl_safefree(smtp->custom);
-
/* Clear the transfer mode for the next request */
smtp->transfer = FTPTRANSFER_BODY;
@@ -1298,8 +1290,13 @@ static CURLcode smtp_perform(struct connectdata *conn, bool *connected,
/* Store the first recipient (or NULL if not specified) */
smtp->rcpt = data->set.mail_rcpt;
+ /* Initial data character is the first character in line: it is implicitly
+ preceded by a virtual CRLF. */
+ smtp->trailing_crlf = TRUE;
+ smtp->eob = 2;
+
/* Start the first command in the DO phase */
- if(data->set.upload && data->set.mail_rcpt)
+ if((data->set.upload || data->set.mimepost.kind) && data->set.mail_rcpt)
/* MAIL transfer */
result = smtp_perform_mail(conn);
else
@@ -1364,7 +1361,7 @@ static CURLcode smtp_disconnect(struct connectdata *conn, bool dead_connection)
point! */
if(!dead_connection && smtpc->pp.conn && smtpc->pp.conn->bits.protoconnstart)
if(!smtp_perform_quit(conn))
- (void)smtp_block_statemach(conn); /* ignore errors on QUIT */
+ (void)smtp_block_statemach(conn, TRUE); /* ignore errors on QUIT */
/* Disconnect from the server */
Curl_pp_disconnect(&smtpc->pp);
@@ -1387,7 +1384,7 @@ static CURLcode smtp_dophase_done(struct connectdata *conn, bool connected)
if(smtp->transfer != FTPTRANSFER_BODY)
/* no data to transfer */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(conn->data, -1, -1, FALSE, -1);
return CURLE_OK;
}
@@ -1445,43 +1442,16 @@ static CURLcode smtp_regular_transfer(struct connectdata *conn,
static CURLcode smtp_setup_connection(struct connectdata *conn)
{
- struct Curl_easy *data = conn->data;
CURLcode result;
/* Clear the TLS upgraded flag */
conn->tls_upgraded = FALSE;
- /* Set up the proxy if necessary */
- if(conn->bits.httpproxy && !data->set.tunnel_thru_httpproxy) {
- /* Unless we have asked to tunnel SMTP operations through the proxy, we
- switch and use HTTP operations only */
-#ifndef CURL_DISABLE_HTTP
- if(conn->handler == &Curl_handler_smtp)
- conn->handler = &Curl_handler_smtp_proxy;
- else {
-#ifdef USE_SSL
- conn->handler = &Curl_handler_smtps_proxy;
-#else
- failf(data, "SMTPS not supported!");
- return CURLE_UNSUPPORTED_PROTOCOL;
-#endif
- }
- /* set it up as a HTTP connection instead */
- return conn->handler->setup_connection(conn);
-
-#else
- failf(data, "SMTP over http proxy requires HTTP support built-in!");
- return CURLE_UNSUPPORTED_PROTOCOL;
-#endif
- }
-
/* Initialise the SMTP layer */
result = smtp_init(conn);
if(result)
return result;
- data->state.path++; /* don't include the initial slash */
-
return CURLE_OK;
}
@@ -1535,7 +1505,7 @@ static CURLcode smtp_parse_url_path(struct connectdata *conn)
/* The SMTP struct is already initialised in smtp_connect() */
struct Curl_easy *data = conn->data;
struct smtp_conn *smtpc = &conn->proto.smtpc;
- const char *path = data->state.path;
+ const char *path = &data->state.up.path[1]; /* skip leading path */
char localhost[HOSTNAME_MAX + 1];
/* Calculate the path if necessary */
@@ -1591,13 +1561,14 @@ CURLcode Curl_smtp_escape_eob(struct connectdata *conn, const ssize_t nread)
if(!scratch || data->set.crlf) {
oldscratch = scratch;
- scratch = newscratch = malloc(2 * data->set.buffer_size);
+ scratch = newscratch = malloc(2 * data->set.upload_buffer_size);
if(!newscratch) {
failf(data, "Failed to alloc scratch buffer!");
return CURLE_OUT_OF_MEMORY;
}
}
+ DEBUGASSERT(data->set.upload_buffer_size >= (size_t)nread);
/* Have we already sent part of the EOB? */
eob_sent = smtp->eob;
diff --git a/Utilities/cmcurl/lib/sockaddr.h b/Utilities/cmcurl/lib/sockaddr.h
index 95ba4c3c9..db146803a 100644
--- a/Utilities/cmcurl/lib/sockaddr.h
+++ b/Utilities/cmcurl/lib/sockaddr.h
@@ -40,4 +40,3 @@ struct Curl_sockaddr_storage {
};
#endif /* HEADER_CURL_SOCKADDR_H */
-
diff --git a/Utilities/cmcurl/lib/socks.c b/Utilities/cmcurl/lib/socks.c
index 97a44b296..d8fcc3bbb 100644
--- a/Utilities/cmcurl/lib/socks.c
+++ b/Utilities/cmcurl/lib/socks.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -54,13 +54,12 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
ssize_t buffersize, /* max amount to read */
ssize_t *n) /* amount bytes read */
{
- ssize_t nread;
+ ssize_t nread = 0;
ssize_t allread = 0;
int result;
- time_t timeleft;
*n = 0;
for(;;) {
- timeleft = Curl_timeleft(conn->data, NULL, TRUE);
+ timediff_t timeleft = Curl_timeleft(conn->data, NULL, TRUE);
if(timeleft < 0) {
/* we already got the timeout */
result = CURLE_OPERATION_TIMEDOUT;
@@ -99,13 +98,13 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
* destination server.
*
* Reference :
-* http://socks.permeo.com/protocol/socks4.protocol
+* https://www.openssh.com/txt/socks4.protocol
*
* Note :
* Set protocol4a=true for "SOCKS 4A (Simple Extension to SOCKS 4 Protocol)"
* Nonsupport "Identification Protocol (RFC1413)"
*/
-CURLcode Curl_SOCKS4(const char *proxy_name,
+CURLcode Curl_SOCKS4(const char *proxy_user,
const char *hostname,
int remote_port,
int sockindex,
@@ -116,7 +115,6 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
#define SOCKS4REQLEN 262
unsigned char socksreq[SOCKS4REQLEN]; /* room for SOCKS4 request incl. user
id */
- int result;
CURLcode code;
curl_socket_t sock = conn->sock[sockindex];
struct Curl_easy *data = conn->data;
@@ -154,10 +152,10 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
/* DNS resolve only for SOCKS4, not SOCKS4a */
if(!protocol4a) {
struct Curl_dns_entry *dns;
- Curl_addrinfo *hp=NULL;
+ Curl_addrinfo *hp = NULL;
int rc;
- rc = Curl_resolv(conn, hostname, remote_port, &dns);
+ rc = Curl_resolv(conn, hostname, remote_port, FALSE, &dns);
if(rc == CURLRESOLV_ERROR)
return CURLE_COULDNT_RESOLVE_PROXY;
@@ -171,7 +169,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
* returns a Curl_addrinfo pointer that may not always look the same.
*/
if(dns)
- hp=dns->addr;
+ hp = dns->addr;
if(hp) {
char buf[64];
Curl_printable_address(hp, buf, sizeof(buf));
@@ -206,25 +204,26 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
* This is currently not supporting "Identification Protocol (RFC1413)".
*/
socksreq[8] = 0; /* ensure empty userid is NUL-terminated */
- if(proxy_name) {
- size_t plen = strlen(proxy_name);
+ if(proxy_user) {
+ size_t plen = strlen(proxy_user);
if(plen >= sizeof(socksreq) - 8) {
failf(data, "Too long SOCKS proxy name, can't use!\n");
return CURLE_COULDNT_CONNECT;
}
/* copy the proxy name WITH trailing zero */
- memcpy(socksreq + 8, proxy_name, plen+1);
+ memcpy(socksreq + 8, proxy_user, plen + 1);
}
/*
* Make connection
*/
{
+ int result;
ssize_t actualread;
ssize_t written;
ssize_t hostnamelen = 0;
- int packetsize = 9 +
- (int)strlen((char *)socksreq + 8); /* size including NUL */
+ ssize_t packetsize = 9 +
+ strlen((char *)socksreq + 8); /* size including NUL */
/* If SOCKS4a, set special invalid IP address 0.0.0.x */
if(protocol4a) {
@@ -291,7 +290,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
/* wrong version ? */
if(socksreq[0] != 0) {
failf(data,
- "SOCKS4 reply has wrong version, version should be 4.");
+ "SOCKS4 reply has wrong version, version should be 0.");
return CURLE_COULDNT_CONNECT;
}
@@ -306,7 +305,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
", request rejected or failed.",
(unsigned char)socksreq[4], (unsigned char)socksreq[5],
(unsigned char)socksreq[6], (unsigned char)socksreq[7],
- (((unsigned char)socksreq[8] << 8) | (unsigned char)socksreq[9]),
+ (((unsigned char)socksreq[2] << 8) | (unsigned char)socksreq[3]),
(unsigned char)socksreq[1]);
return CURLE_COULDNT_CONNECT;
case 92:
@@ -316,7 +315,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
"identd on the client.",
(unsigned char)socksreq[4], (unsigned char)socksreq[5],
(unsigned char)socksreq[6], (unsigned char)socksreq[7],
- (((unsigned char)socksreq[8] << 8) | (unsigned char)socksreq[9]),
+ (((unsigned char)socksreq[2] << 8) | (unsigned char)socksreq[3]),
(unsigned char)socksreq[1]);
return CURLE_COULDNT_CONNECT;
case 93:
@@ -326,7 +325,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
"report different user-ids.",
(unsigned char)socksreq[4], (unsigned char)socksreq[5],
(unsigned char)socksreq[6], (unsigned char)socksreq[7],
- (((unsigned char)socksreq[8] << 8) | (unsigned char)socksreq[9]),
+ (((unsigned char)socksreq[2] << 8) | (unsigned char)socksreq[3]),
(unsigned char)socksreq[1]);
return CURLE_COULDNT_CONNECT;
default:
@@ -335,7 +334,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
", Unknown.",
(unsigned char)socksreq[4], (unsigned char)socksreq[5],
(unsigned char)socksreq[6], (unsigned char)socksreq[7],
- (((unsigned char)socksreq[8] << 8) | (unsigned char)socksreq[9]),
+ (((unsigned char)socksreq[2] << 8) | (unsigned char)socksreq[3]),
(unsigned char)socksreq[1]);
return CURLE_COULDNT_CONNECT;
}
@@ -350,7 +349,7 @@ CURLcode Curl_SOCKS4(const char *proxy_name,
* This function logs in to a SOCKS5 proxy and sends the specifics to the final
* destination server.
*/
-CURLcode Curl_SOCKS5(const char *proxy_name,
+CURLcode Curl_SOCKS5(const char *proxy_user,
const char *proxy_password,
const char *hostname,
int remote_port,
@@ -375,17 +374,20 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
*/
unsigned char socksreq[600]; /* room for large user/pw (255 max each) */
+ int idx;
ssize_t actualread;
ssize_t written;
int result;
CURLcode code;
curl_socket_t sock = conn->sock[sockindex];
struct Curl_easy *data = conn->data;
- time_t timeout;
+ timediff_t timeout;
bool socks5_resolve_local =
(conn->socks_proxy.proxytype == CURLPROXY_SOCKS5) ? TRUE : FALSE;
const size_t hostname_len = strlen(hostname);
ssize_t len = 0;
+ const unsigned long auth = data->set.socks5auth;
+ bool allow_gssapi = FALSE;
if(conn->bits.httpproxy)
infof(conn->data, "SOCKS5: connecting to HTTP proxy %s port %d\n",
@@ -426,18 +428,29 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
return CURLE_COULDNT_CONNECT;
}
- socksreq[0] = 5; /* version */
+ if(auth & ~(CURLAUTH_BASIC | CURLAUTH_GSSAPI))
+ infof(conn->data,
+ "warning: unsupported value passed to CURLOPT_SOCKS5_AUTH: %lu\n",
+ auth);
+ if(!(auth & CURLAUTH_BASIC))
+ /* disable username/password auth */
+ proxy_user = NULL;
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
- socksreq[1] = (char)(proxy_name ? 3 : 2); /* number of methods (below) */
- socksreq[2] = 0; /* no authentication */
- socksreq[3] = 1; /* GSS-API */
- socksreq[4] = 2; /* username/password */
-#else
- socksreq[1] = (char)(proxy_name ? 2 : 1); /* number of methods (below) */
- socksreq[2] = 0; /* no authentication */
- socksreq[3] = 2; /* username/password */
+ if(auth & CURLAUTH_GSSAPI)
+ allow_gssapi = TRUE;
#endif
+ idx = 0;
+ socksreq[idx++] = 5; /* version */
+ idx++; /* reserve for the number of authentication methods */
+ socksreq[idx++] = 0; /* no authentication */
+ if(allow_gssapi)
+ socksreq[idx++] = 1; /* GSS-API */
+ if(proxy_user)
+ socksreq[idx++] = 2; /* username/password */
+ /* write the number of authentication methods */
+ socksreq[1] = (unsigned char) (idx - 2);
+
(void)curlx_nonblock(sock, FALSE);
infof(data, "SOCKS5 communication to %s:%d\n", hostname, remote_port);
@@ -469,7 +482,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
(void)curlx_nonblock(sock, FALSE);
- result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
+ result = Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
if(result || (actualread != 2)) {
failf(data, "Unable to receive initial SOCKS5 response.");
return CURLE_COULDNT_CONNECT;
@@ -484,7 +497,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
;
}
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
- else if(socksreq[1] == 1) {
+ else if(allow_gssapi && (socksreq[1] == 1)) {
code = Curl_SOCKS5_gssapi_negotiate(sockindex, conn);
if(code) {
failf(data, "Unable to negotiate SOCKS5 GSS-API context.");
@@ -494,13 +507,13 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
#endif
else if(socksreq[1] == 2) {
/* Needs user name and password */
- size_t proxy_name_len, proxy_password_len;
- if(proxy_name && proxy_password) {
- proxy_name_len = strlen(proxy_name);
+ size_t proxy_user_len, proxy_password_len;
+ if(proxy_user && proxy_password) {
+ proxy_user_len = strlen(proxy_user);
proxy_password_len = strlen(proxy_password);
}
else {
- proxy_name_len = 0;
+ proxy_user_len = 0;
proxy_password_len = 0;
}
@@ -513,13 +526,25 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
*/
len = 0;
socksreq[len++] = 1; /* username/pw subnegotiation version */
- socksreq[len++] = (unsigned char) proxy_name_len;
- if(proxy_name && proxy_name_len)
- memcpy(socksreq + len, proxy_name, proxy_name_len);
- len += proxy_name_len;
+ socksreq[len++] = (unsigned char) proxy_user_len;
+ if(proxy_user && proxy_user_len) {
+ /* the length must fit in a single byte */
+ if(proxy_user_len >= 255) {
+ failf(data, "Excessive user name length for proxy auth");
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ }
+ memcpy(socksreq + len, proxy_user, proxy_user_len);
+ }
+ len += proxy_user_len;
socksreq[len++] = (unsigned char) proxy_password_len;
- if(proxy_password && proxy_password_len)
+ if(proxy_password && proxy_password_len) {
+ /* the length must fit in a single byte */
+ if(proxy_password_len > 255) {
+ failf(data, "Excessive password length for proxy auth");
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+ }
memcpy(socksreq + len, proxy_password, proxy_password_len);
+ }
len += proxy_password_len;
code = Curl_write_plain(conn, sock, (char *)socksreq, len, &written);
@@ -528,7 +553,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
return CURLE_COULDNT_CONNECT;
}
- result=Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
+ result = Curl_blockread_all(conn, sock, (char *)socksreq, 2, &actualread);
if(result || (actualread != 2)) {
failf(data, "Unable to receive SOCKS5 sub-negotiation response.");
return CURLE_COULDNT_CONNECT;
@@ -545,17 +570,13 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
}
else {
/* error */
-#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
- if(socksreq[1] == 255) {
-#else
- if(socksreq[1] == 1) {
+ if(!allow_gssapi && (socksreq[1] == 1)) {
failf(data,
"SOCKS5 GSSAPI per-message authentication is not supported.");
return CURLE_COULDNT_CONNECT;
}
if(socksreq[1] == 255) {
-#endif
- if(!proxy_name || !*proxy_name) {
+ if(!proxy_user || !*proxy_user) {
failf(data,
"No authentication method was acceptable. (It is quite likely"
" that the SOCKS5 server wanted a username/password, since none"
@@ -588,7 +609,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
else {
struct Curl_dns_entry *dns;
Curl_addrinfo *hp = NULL;
- int rc = Curl_resolv(conn, hostname, remote_port, &dns);
+ int rc = Curl_resolv(conn, hostname, remote_port, FALSE, &dns);
if(rc == CURLRESOLV_ERROR)
return CURLE_COULDNT_RESOLVE_HOST;
@@ -605,13 +626,13 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
* returns a Curl_addrinfo pointer that may not always look the same.
*/
if(dns)
- hp=dns->addr;
+ hp = dns->addr;
if(hp) {
- int i;
char buf[64];
Curl_printable_address(hp, buf, sizeof(buf));
if(hp->ai_family == AF_INET) {
+ int i;
struct sockaddr_in *saddr_in;
socksreq[len++] = 1; /* ATYP: IPv4 = 1 */
@@ -624,6 +645,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
}
#ifdef ENABLE_IPV6
else if(hp->ai_family == AF_INET6) {
+ int i;
struct sockaddr_in6 *saddr_in6;
socksreq[len++] = 4; /* ATYP: IPv6 = 4 */
@@ -779,4 +801,3 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
}
#endif /* CURL_DISABLE_PROXY */
-
diff --git a/Utilities/cmcurl/lib/socks.h b/Utilities/cmcurl/lib/socks.h
index 348707e74..daa07c127 100644
--- a/Utilities/cmcurl/lib/socks.h
+++ b/Utilities/cmcurl/lib/socks.h
@@ -73,4 +73,3 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
#endif /* CURL_DISABLE_PROXY */
#endif /* HEADER_CURL_SOCKS_H */
-
diff --git a/Utilities/cmcurl/lib/socks_gssapi.c b/Utilities/cmcurl/lib/socks_gssapi.c
index 54d063504..65294bbeb 100644
--- a/Utilities/cmcurl/lib/socks_gssapi.c
+++ b/Utilities/cmcurl/lib/socks_gssapi.c
@@ -5,8 +5,8 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2009, 2011, Markus Moeller, <markus_moeller@compuserve.com>
- * Copyright (C) 2012 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2009, Markus Moeller, <markus_moeller@compuserve.com>
+ * Copyright (C) 2012 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -65,7 +65,7 @@ static int check_gss_err(struct Curl_easy *data,
&msg_ctx, &status_string);
if(maj_stat == GSS_S_COMPLETE) {
if(sizeof(buf) > len + status_string.length + 1) {
- strcpy(buf+len, (char *) status_string.value);
+ strcpy(buf + len, (char *) status_string.value);
len += status_string.length;
}
gss_release_buffer(&min_stat, &status_string);
@@ -74,7 +74,7 @@ static int check_gss_err(struct Curl_easy *data,
gss_release_buffer(&min_stat, &status_string);
}
if(sizeof(buf) > len + 3) {
- strcpy(buf+len, ".\n");
+ strcpy(buf + len, ".\n");
len += 2;
}
msg_ctx = 0;
@@ -86,7 +86,7 @@ static int check_gss_err(struct Curl_easy *data,
&msg_ctx, &status_string);
if(maj_stat == GSS_S_COMPLETE) {
if(sizeof(buf) > len + status_string.length)
- strcpy(buf+len, (char *) status_string.value);
+ strcpy(buf + len, (char *) status_string.value);
gss_release_buffer(&min_stat, &status_string);
break;
}
@@ -119,7 +119,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_name_t server = GSS_C_NO_NAME;
gss_name_t gss_client_name = GSS_C_NO_NAME;
unsigned short us_length;
- char *user=NULL;
+ char *user = NULL;
unsigned char socksreq[4]; /* room for GSS-API exchange header only */
const char *serviceptr = data->set.str[STRING_PROXY_SERVICE_NAME] ?
data->set.str[STRING_PROXY_SERVICE_NAME] : "rcmd";
@@ -146,12 +146,13 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
}
else {
service.value = malloc(serviceptr_length +
- strlen(conn->socks_proxy.host.name)+2);
+ strlen(conn->socks_proxy.host.name) + 2);
if(!service.value)
return CURLE_OUT_OF_MEMORY;
- service.length = serviceptr_length + strlen(conn->socks_proxy.host.name)+1;
- snprintf(service.value, service.length+1, "%s@%s",
- serviceptr, conn->socks_proxy.host.name);
+ service.length = serviceptr_length +
+ strlen(conn->socks_proxy.host.name) + 1;
+ msnprintf(service.value, service.length + 1, "%s@%s",
+ serviceptr, conn->socks_proxy.host.name);
gss_major_status = gss_import_name(&gss_minor_status, &service,
GSS_C_NT_HOSTBASED_SERVICE, &server);
@@ -196,7 +197,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
socksreq[0] = 1; /* GSS-API subnegotiation version */
socksreq[1] = 1; /* authentication message type */
us_length = htons((short)gss_send_token.length);
- memcpy(socksreq+2, &us_length, sizeof(short));
+ memcpy(socksreq + 2, &us_length, sizeof(short));
code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written);
if(code || (4 != written)) {
@@ -236,7 +237,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
* +----+------+-----+----------------+
*/
- result=Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
+ result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
if(result || (actualread != 4)) {
failf(data, "Failed to receive GSS-API authentication response.");
gss_release_name(&gss_status, &server);
@@ -261,11 +262,11 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
return CURLE_COULDNT_CONNECT;
}
- memcpy(&us_length, socksreq+2, sizeof(short));
+ memcpy(&us_length, socksreq + 2, sizeof(short));
us_length = ntohs(us_length);
- gss_recv_token.length=us_length;
- gss_recv_token.value=malloc(us_length);
+ gss_recv_token.length = us_length;
+ gss_recv_token.value = malloc(us_length);
if(!gss_recv_token.value) {
failf(data,
"Could not allocate memory for GSS-API authentication "
@@ -275,8 +276,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
return CURLE_OUT_OF_MEMORY;
}
- result=Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
- gss_recv_token.length, &actualread);
+ result = Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
+ gss_recv_token.length, &actualread);
if(result || (actualread != us_length)) {
failf(data, "Failed to receive GSS-API authentication token.");
@@ -312,7 +313,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
failf(data, "Failed to determine user name.");
return CURLE_COULDNT_CONNECT;
}
- user=malloc(gss_send_token.length+1);
+ user = malloc(gss_send_token.length + 1);
if(!user) {
gss_delete_sec_context(&gss_status, &gss_context, NULL);
gss_release_name(&gss_status, &gss_client_name);
@@ -326,7 +327,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_release_buffer(&gss_status, &gss_send_token);
infof(data, "SOCKS5 server authencticated user %s with GSS-API.\n",user);
free(user);
- user=NULL;
+ user = NULL;
/* Do encryption */
socksreq[0] = 1; /* GSS-API subnegotiation version */
@@ -341,7 +342,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_enc = 1;
infof(data, "SOCKS5 server supports GSS-API %s data protection.\n",
- (gss_enc==0)?"no":((gss_enc==1)?"integrity":"confidentiality"));
+ (gss_enc == 0)?"no":((gss_enc==1)?"integrity":"confidentiality"));
/* force for the moment to no data protection */
gss_enc = 0;
/*
@@ -376,7 +377,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
*/
if(data->set.socks5_gssapi_nec) {
us_length = htons((short)1);
- memcpy(socksreq+2, &us_length, sizeof(short));
+ memcpy(socksreq + 2, &us_length, sizeof(short));
}
else {
gss_send_token.length = 1;
@@ -401,7 +402,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_release_buffer(&gss_status, &gss_send_token);
us_length = htons((short)gss_w_token.length);
- memcpy(socksreq+2, &us_length, sizeof(short));
+ memcpy(socksreq + 2, &us_length, sizeof(short));
}
code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written);
@@ -433,7 +434,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_release_buffer(&gss_status, &gss_w_token);
}
- result=Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
+ result = Curl_blockread_all(conn, sock, (char *)socksreq, 4, &actualread);
if(result || (actualread != 4)) {
failf(data, "Failed to receive GSS-API encryption response.");
gss_delete_sec_context(&gss_status, &gss_context, NULL);
@@ -455,17 +456,17 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
return CURLE_COULDNT_CONNECT;
}
- memcpy(&us_length, socksreq+2, sizeof(short));
+ memcpy(&us_length, socksreq + 2, sizeof(short));
us_length = ntohs(us_length);
- gss_recv_token.length= us_length;
- gss_recv_token.value=malloc(gss_recv_token.length);
+ gss_recv_token.length = us_length;
+ gss_recv_token.value = malloc(gss_recv_token.length);
if(!gss_recv_token.value) {
gss_delete_sec_context(&gss_status, &gss_context, NULL);
return CURLE_OUT_OF_MEMORY;
}
- result=Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
- gss_recv_token.length, &actualread);
+ result = Curl_blockread_all(conn, sock, (char *)gss_recv_token.value,
+ gss_recv_token.length, &actualread);
if(result || (actualread != us_length)) {
failf(data, "Failed to receive GSS-API encryptrion type.");
@@ -513,8 +514,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
}
infof(data, "SOCKS5 access with%s protection granted.\n",
- (socksreq[0]==0)?"out GSS-API data":
- ((socksreq[0]==1)?" GSS-API integrity":" GSS-API confidentiality"));
+ (socksreq[0] == 0)?"out GSS-API data":
+ ((socksreq[0] == 1)?" GSS-API integrity":" GSS-API confidentiality"));
conn->socks5_gssapi_enctype = socksreq[0];
if(socksreq[0] == 0)
diff --git a/Utilities/cmcurl/lib/socks_sspi.c b/Utilities/cmcurl/lib/socks_sspi.c
index edc73ad2e..57027ef68 100644
--- a/Utilities/cmcurl/lib/socks_sspi.c
+++ b/Utilities/cmcurl/lib/socks_sspi.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2012 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2009, 2011, Markus Moeller, <markus_moeller@compuserve.com>
*
* This software is licensed as described in the file COPYING, which
@@ -51,8 +51,9 @@ static int check_sspi_err(struct connectdata *conn,
status != SEC_I_COMPLETE_AND_CONTINUE &&
status != SEC_I_COMPLETE_NEEDED &&
status != SEC_I_CONTINUE_NEEDED) {
+ char buffer[STRERROR_LEN];
failf(conn->data, "SSPI error: %s failed: %s", function,
- Curl_sspi_strerror(conn, status));
+ Curl_sspi_strerror(status, buffer, sizeof(buffer)));
return 1;
}
return 0;
@@ -107,9 +108,9 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
strlen(conn->socks_proxy.host.name) + 2);
if(!service_name)
return CURLE_OUT_OF_MEMORY;
- snprintf(service_name, service_length +
- strlen(conn->socks_proxy.host.name)+2, "%s/%s",
- service, conn->socks_proxy.host.name);
+ msnprintf(service_name, service_length +
+ strlen(conn->socks_proxy.host.name) + 2, "%s/%s",
+ service, conn->socks_proxy.host.name);
}
input_desc.cBuffers = 1;
@@ -199,7 +200,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
socksreq[0] = 1; /* GSS-API subnegotiation version */
socksreq[1] = 1; /* authentication message type */
us_length = htons((short)sspi_send_token.cbBuffer);
- memcpy(socksreq+2, &us_length, sizeof(short));
+ memcpy(socksreq + 2, &us_length, sizeof(short));
code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written);
if(code || (4 != written)) {
@@ -283,7 +284,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
return CURLE_COULDNT_CONNECT;
}
- memcpy(&us_length, socksreq+2, sizeof(short));
+ memcpy(&us_length, socksreq + 2, sizeof(short));
us_length = ntohs(us_length);
sspi_recv_token.cbBuffer = us_length;
@@ -341,7 +342,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
gss_enc = 1;
infof(data, "SOCKS5 server supports GSS-API %s data protection.\n",
- (gss_enc==0)?"no":((gss_enc==1)?"integrity":"confidentiality") );
+ (gss_enc == 0)?"no":((gss_enc == 1)?"integrity":"confidentiality") );
/* force to no data protection, avoid encryption/decryption for now */
gss_enc = 0;
/*
@@ -377,7 +378,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
if(data->set.socks5_gssapi_nec) {
us_length = htons((short)1);
- memcpy(socksreq+2, &us_length, sizeof(short));
+ memcpy(socksreq + 2, &us_length, sizeof(short));
}
else {
status = s_pSecFn->QueryContextAttributes(&sspi_context,
@@ -445,8 +446,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
memcpy((PUCHAR) sspi_send_token.pvBuffer +(int)sspi_w_token[0].cbBuffer,
sspi_w_token[1].pvBuffer, sspi_w_token[1].cbBuffer);
memcpy((PUCHAR) sspi_send_token.pvBuffer
- +sspi_w_token[0].cbBuffer
- +sspi_w_token[1].cbBuffer,
+ + sspi_w_token[0].cbBuffer
+ + sspi_w_token[1].cbBuffer,
sspi_w_token[2].pvBuffer, sspi_w_token[2].cbBuffer);
s_pSecFn->FreeContextBuffer(sspi_w_token[0].pvBuffer);
@@ -460,7 +461,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
sspi_w_token[2].cbBuffer = 0;
us_length = htons((short)sspi_send_token.cbBuffer);
- memcpy(socksreq+2, &us_length, sizeof(short));
+ memcpy(socksreq + 2, &us_length, sizeof(short));
}
code = Curl_write_plain(conn, sock, (char *)socksreq, 4, &written);
@@ -517,7 +518,7 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
return CURLE_COULDNT_CONNECT;
}
- memcpy(&us_length, socksreq+2, sizeof(short));
+ memcpy(&us_length, socksreq + 2, sizeof(short));
us_length = ntohs(us_length);
sspi_w_token[0].cbBuffer = us_length;
@@ -588,8 +589,8 @@ CURLcode Curl_SOCKS5_gssapi_negotiate(int sockindex,
}
infof(data, "SOCKS5 access with%s protection granted.\n",
- (socksreq[0]==0)?"out GSS-API data":
- ((socksreq[0]==1)?" GSS-API integrity":" GSS-API confidentiality"));
+ (socksreq[0] == 0)?"out GSS-API data":
+ ((socksreq[0] == 1)?" GSS-API integrity":" GSS-API confidentiality"));
/* For later use if encryption is required
conn->socks5_gssapi_enctype = socksreq[0];
diff --git a/Utilities/cmcurl/lib/speedcheck.c b/Utilities/cmcurl/lib/speedcheck.c
index 8addedde5..3aeea9111 100644
--- a/Utilities/cmcurl/lib/speedcheck.c
+++ b/Utilities/cmcurl/lib/speedcheck.c
@@ -30,14 +30,14 @@
void Curl_speedinit(struct Curl_easy *data)
{
- memset(&data->state.keeps_speed, 0, sizeof(struct timeval));
+ memset(&data->state.keeps_speed, 0, sizeof(struct curltime));
}
/*
* @unittest: 1606
*/
CURLcode Curl_speedcheck(struct Curl_easy *data,
- struct timeval now)
+ struct curltime now)
{
if((data->progress.current_speed >= 0) && data->set.low_speed_time) {
if(data->progress.current_speed < data->set.low_speed_limit) {
@@ -46,7 +46,7 @@ CURLcode Curl_speedcheck(struct Curl_easy *data,
data->state.keeps_speed = now;
else {
/* how long has it been under the limit */
- time_t howlong = Curl_tvdiff(now, data->state.keeps_speed);
+ timediff_t howlong = Curl_timediff(now, data->state.keeps_speed);
if(howlong >= data->set.low_speed_time * 1000) {
/* too long */
diff --git a/Utilities/cmcurl/lib/speedcheck.h b/Utilities/cmcurl/lib/speedcheck.h
index 7dbe3d6d7..5c2dc9a22 100644
--- a/Utilities/cmcurl/lib/speedcheck.h
+++ b/Utilities/cmcurl/lib/speedcheck.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -28,6 +28,6 @@
void Curl_speedinit(struct Curl_easy *data);
CURLcode Curl_speedcheck(struct Curl_easy *data,
- struct timeval now);
+ struct curltime now);
#endif /* HEADER_CURL_SPEEDCHECK_H */
diff --git a/Utilities/cmcurl/lib/splay.c b/Utilities/cmcurl/lib/splay.c
index 1b301f95d..0f5fcd1e8 100644
--- a/Utilities/cmcurl/lib/splay.c
+++ b/Utilities/cmcurl/lib/splay.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1997 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1997 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -37,11 +37,10 @@
* Splay using the key i (which may or may not be in the tree.) The starting
* root is t.
*/
-struct Curl_tree *Curl_splay(struct timeval i,
+struct Curl_tree *Curl_splay(struct curltime i,
struct Curl_tree *t)
{
struct Curl_tree N, *l, *r, *y;
- long comp;
if(t == NULL)
return t;
@@ -49,7 +48,7 @@ struct Curl_tree *Curl_splay(struct timeval i,
l = r = &N;
for(;;) {
- comp = compare(i, t->key);
+ long comp = compare(i, t->key);
if(comp < 0) {
if(t->smaller == NULL)
break;
@@ -97,24 +96,26 @@ struct Curl_tree *Curl_splay(struct timeval i,
*
* @unittest: 1309
*/
-struct Curl_tree *Curl_splayinsert(struct timeval i,
+struct Curl_tree *Curl_splayinsert(struct curltime i,
struct Curl_tree *t,
struct Curl_tree *node)
{
- static const struct timeval KEY_NOTUSED = {-1, -1}; /* will *NEVER* appear */
+ static const struct curltime KEY_NOTUSED = {
+ (time_t)-1, (unsigned int)-1
+ }; /* will *NEVER* appear */
if(node == NULL)
return t;
if(t != NULL) {
t = Curl_splay(i, t);
- if(compare(i, t->key)==0) {
+ if(compare(i, t->key) == 0) {
/* There already exists a node in the tree with the very same key. Build
a doubly-linked circular list of nodes. We add the new 'node' struct
to the end of this list. */
node->key = KEY_NOTUSED; /* we set the key in the sub node to NOTUSED
- to quickly identify this node as a subnode */
+ to quickly identify this node as a subnode */
node->samen = t;
node->samep = t->samep;
t->samep->samen = node;
@@ -149,11 +150,11 @@ struct Curl_tree *Curl_splayinsert(struct timeval i,
/* Finds and deletes the best-fit node from the tree. Return a pointer to the
resulting tree. best-fit means the smallest node if it is not larger than
the key */
-struct Curl_tree *Curl_splaygetbest(struct timeval i,
- struct Curl_tree *t,
- struct Curl_tree **removed)
+struct Curl_tree *Curl_splaygetbest(struct curltime i,
+ struct Curl_tree *t,
+ struct Curl_tree **removed)
{
- static struct timeval tv_zero = {0, 0};
+ static struct curltime tv_zero = {0, 0};
struct Curl_tree *x;
if(!t) {
@@ -197,7 +198,7 @@ struct Curl_tree *Curl_splaygetbest(struct timeval i,
/* Deletes the very node we point out from the tree if it's there. Stores a
* pointer to the new resulting tree in 'newroot'.
*
- * Returns zero on success and non-zero on errors! TODO: document error codes.
+ * Returns zero on success and non-zero on errors!
* When returning error, it does not touch the 'newroot' pointer.
*
* NOTE: when the last node of the tree is removed, there's no tree left so
@@ -209,7 +210,9 @@ int Curl_splayremovebyaddr(struct Curl_tree *t,
struct Curl_tree *removenode,
struct Curl_tree **newroot)
{
- static const struct timeval KEY_NOTUSED = {-1, -1}; /* will *NEVER* appear */
+ static const struct curltime KEY_NOTUSED = {
+ (time_t)-1, (unsigned int)-1
+ }; /* will *NEVER* appear */
struct Curl_tree *x;
if(!t || !removenode)
@@ -271,4 +274,3 @@ int Curl_splayremovebyaddr(struct Curl_tree *t,
return 0;
}
-
diff --git a/Utilities/cmcurl/lib/splay.h b/Utilities/cmcurl/lib/splay.h
index da81894d1..4612ec271 100644
--- a/Utilities/cmcurl/lib/splay.h
+++ b/Utilities/cmcurl/lib/splay.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1997 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1997 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,30 +22,31 @@
*
***************************************************************************/
#include "curl_setup.h"
+#include "timeval.h"
struct Curl_tree {
struct Curl_tree *smaller; /* smaller node */
struct Curl_tree *larger; /* larger node */
struct Curl_tree *samen; /* points to the next node with identical key */
struct Curl_tree *samep; /* points to the prev node with identical key */
- struct timeval key; /* this node's "sort" key */
+ struct curltime key; /* this node's "sort" key */
void *payload; /* data the splay code doesn't care about */
};
-struct Curl_tree *Curl_splay(struct timeval i,
+struct Curl_tree *Curl_splay(struct curltime i,
struct Curl_tree *t);
-struct Curl_tree *Curl_splayinsert(struct timeval key,
+struct Curl_tree *Curl_splayinsert(struct curltime key,
struct Curl_tree *t,
struct Curl_tree *newnode);
#if 0
-struct Curl_tree *Curl_splayremove(struct timeval key,
+struct Curl_tree *Curl_splayremove(struct curltime key,
struct Curl_tree *t,
struct Curl_tree **removed);
#endif
-struct Curl_tree *Curl_splaygetbest(struct timeval key,
+struct Curl_tree *Curl_splaygetbest(struct curltime key,
struct Curl_tree *t,
struct Curl_tree **removed);
@@ -53,8 +54,8 @@ int Curl_splayremovebyaddr(struct Curl_tree *t,
struct Curl_tree *removenode,
struct Curl_tree **newroot);
-#define Curl_splaycomparekeys(i,j) ( ((i.tv_sec) < (j.tv_sec)) ? -1 : \
- ( ((i.tv_sec) > (j.tv_sec)) ? 1 : \
+#define Curl_splaycomparekeys(i,j) ( ((i.tv_sec) < (j.tv_sec)) ? -1 : \
+ ( ((i.tv_sec) > (j.tv_sec)) ? 1 : \
( ((i.tv_usec) < (j.tv_usec)) ? -1 : \
( ((i.tv_usec) > (j.tv_usec)) ? 1 : 0))))
diff --git a/Utilities/cmcurl/lib/ssh-libssh.c b/Utilities/cmcurl/lib/ssh-libssh.c
new file mode 100644
index 000000000..6cfd6bda8
--- /dev/null
+++ b/Utilities/cmcurl/lib/ssh-libssh.c
@@ -0,0 +1,2740 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2017 - 2019 Red Hat, Inc.
+ *
+ * Authors: Nikos Mavrogiannopoulos, Tomas Mraz, Stanislav Zidek,
+ * Robert Kolcun, Andreas Schneider
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#ifdef USE_LIBSSH
+
+#include <limits.h>
+
+#include <libssh/libssh.h>
+#include <libssh/sftp.h>
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#ifdef HAVE_UTSNAME_H
+#include <sys/utsname.h>
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef __VMS
+#include <in.h>
+#include <inet.h>
+#endif
+
+#if (defined(NETWARE) && defined(__NOVELL_LIBC__))
+#undef in_addr_t
+#define in_addr_t unsigned long
+#endif
+
+#include <curl/curl.h>
+#include "urldata.h"
+#include "sendf.h"
+#include "hostip.h"
+#include "progress.h"
+#include "transfer.h"
+#include "escape.h"
+#include "http.h" /* for HTTP proxy tunnel stuff */
+#include "ssh.h"
+#include "url.h"
+#include "speedcheck.h"
+#include "getinfo.h"
+#include "strdup.h"
+#include "strcase.h"
+#include "vtls/vtls.h"
+#include "connect.h"
+#include "strerror.h"
+#include "inet_ntop.h"
+#include "parsedate.h" /* for the week day and month names */
+#include "sockaddr.h" /* required for Curl_sockaddr_storage */
+#include "strtoofft.h"
+#include "multiif.h"
+#include "select.h"
+#include "warnless.h"
+
+/* for permission and open flags */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "memdebug.h"
+#include "curl_path.h"
+
+/* A recent macro provided by libssh. Or make our own. */
+#ifndef SSH_STRING_FREE_CHAR
+/* !checksrc! disable ASSIGNWITHINCONDITION 1 */
+#define SSH_STRING_FREE_CHAR(x) \
+ do { if((x) != NULL) { ssh_string_free_char(x); x = NULL; } } while(0)
+#endif
+
+/* Local functions: */
+static CURLcode myssh_connect(struct connectdata *conn, bool *done);
+static CURLcode myssh_multi_statemach(struct connectdata *conn,
+ bool *done);
+static CURLcode myssh_do_it(struct connectdata *conn, bool *done);
+
+static CURLcode scp_done(struct connectdata *conn,
+ CURLcode, bool premature);
+static CURLcode scp_doing(struct connectdata *conn, bool *dophase_done);
+static CURLcode scp_disconnect(struct connectdata *conn,
+ bool dead_connection);
+
+static CURLcode sftp_done(struct connectdata *conn,
+ CURLcode, bool premature);
+static CURLcode sftp_doing(struct connectdata *conn,
+ bool *dophase_done);
+static CURLcode sftp_disconnect(struct connectdata *conn, bool dead);
+static
+CURLcode sftp_perform(struct connectdata *conn,
+ bool *connected,
+ bool *dophase_done);
+
+static void sftp_quote(struct connectdata *conn);
+static void sftp_quote_stat(struct connectdata *conn);
+
+static int myssh_getsock(struct connectdata *conn, curl_socket_t *sock,
+ int numsocks);
+
+static int myssh_perform_getsock(const struct connectdata *conn,
+ curl_socket_t *sock,
+ int numsocks);
+
+static CURLcode myssh_setup_connection(struct connectdata *conn);
+
+/*
+ * SCP protocol handler.
+ */
+
+const struct Curl_handler Curl_handler_scp = {
+ "SCP", /* scheme */
+ myssh_setup_connection, /* setup_connection */
+ myssh_do_it, /* do_it */
+ scp_done, /* done */
+ ZERO_NULL, /* do_more */
+ myssh_connect, /* connect_it */
+ myssh_multi_statemach, /* connecting */
+ scp_doing, /* doing */
+ myssh_getsock, /* proto_getsock */
+ myssh_getsock, /* doing_getsock */
+ ZERO_NULL, /* domore_getsock */
+ myssh_perform_getsock, /* perform_getsock */
+ scp_disconnect, /* disconnect */
+ ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
+ PORT_SSH, /* defport */
+ CURLPROTO_SCP, /* protocol */
+ PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION | PROTOPT_NOURLQUERY /* flags */
+};
+
+/*
+ * SFTP protocol handler.
+ */
+
+const struct Curl_handler Curl_handler_sftp = {
+ "SFTP", /* scheme */
+ myssh_setup_connection, /* setup_connection */
+ myssh_do_it, /* do_it */
+ sftp_done, /* done */
+ ZERO_NULL, /* do_more */
+ myssh_connect, /* connect_it */
+ myssh_multi_statemach, /* connecting */
+ sftp_doing, /* doing */
+ myssh_getsock, /* proto_getsock */
+ myssh_getsock, /* doing_getsock */
+ ZERO_NULL, /* domore_getsock */
+ myssh_perform_getsock, /* perform_getsock */
+ sftp_disconnect, /* disconnect */
+ ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
+ PORT_SSH, /* defport */
+ CURLPROTO_SFTP, /* protocol */
+ PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION
+ | PROTOPT_NOURLQUERY /* flags */
+};
+
+static CURLcode sftp_error_to_CURLE(int err)
+{
+ switch(err) {
+ case SSH_FX_OK:
+ return CURLE_OK;
+
+ case SSH_FX_NO_SUCH_FILE:
+ case SSH_FX_NO_SUCH_PATH:
+ return CURLE_REMOTE_FILE_NOT_FOUND;
+
+ case SSH_FX_PERMISSION_DENIED:
+ case SSH_FX_WRITE_PROTECT:
+ return CURLE_REMOTE_ACCESS_DENIED;
+
+ case SSH_FX_FILE_ALREADY_EXISTS:
+ return CURLE_REMOTE_FILE_EXISTS;
+
+ default:
+ break;
+ }
+
+ return CURLE_SSH;
+}
+
+#ifndef DEBUGBUILD
+#define state(x,y) mystate(x,y)
+#else
+#define state(x,y) mystate(x,y, __LINE__)
+#endif
+
+/*
+ * SSH State machine related code
+ */
+/* This is the ONLY way to change SSH state! */
+static void mystate(struct connectdata *conn, sshstate nowstate
+#ifdef DEBUGBUILD
+ , int lineno
+#endif
+ )
+{
+ struct ssh_conn *sshc = &conn->proto.sshc;
+#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
+ /* for debug purposes */
+ static const char *const names[] = {
+ "SSH_STOP",
+ "SSH_INIT",
+ "SSH_S_STARTUP",
+ "SSH_HOSTKEY",
+ "SSH_AUTHLIST",
+ "SSH_AUTH_PKEY_INIT",
+ "SSH_AUTH_PKEY",
+ "SSH_AUTH_PASS_INIT",
+ "SSH_AUTH_PASS",
+ "SSH_AUTH_AGENT_INIT",
+ "SSH_AUTH_AGENT_LIST",
+ "SSH_AUTH_AGENT",
+ "SSH_AUTH_HOST_INIT",
+ "SSH_AUTH_HOST",
+ "SSH_AUTH_KEY_INIT",
+ "SSH_AUTH_KEY",
+ "SSH_AUTH_GSSAPI",
+ "SSH_AUTH_DONE",
+ "SSH_SFTP_INIT",
+ "SSH_SFTP_REALPATH",
+ "SSH_SFTP_QUOTE_INIT",
+ "SSH_SFTP_POSTQUOTE_INIT",
+ "SSH_SFTP_QUOTE",
+ "SSH_SFTP_NEXT_QUOTE",
+ "SSH_SFTP_QUOTE_STAT",
+ "SSH_SFTP_QUOTE_SETSTAT",
+ "SSH_SFTP_QUOTE_SYMLINK",
+ "SSH_SFTP_QUOTE_MKDIR",
+ "SSH_SFTP_QUOTE_RENAME",
+ "SSH_SFTP_QUOTE_RMDIR",
+ "SSH_SFTP_QUOTE_UNLINK",
+ "SSH_SFTP_QUOTE_STATVFS",
+ "SSH_SFTP_GETINFO",
+ "SSH_SFTP_FILETIME",
+ "SSH_SFTP_TRANS_INIT",
+ "SSH_SFTP_UPLOAD_INIT",
+ "SSH_SFTP_CREATE_DIRS_INIT",
+ "SSH_SFTP_CREATE_DIRS",
+ "SSH_SFTP_CREATE_DIRS_MKDIR",
+ "SSH_SFTP_READDIR_INIT",
+ "SSH_SFTP_READDIR",
+ "SSH_SFTP_READDIR_LINK",
+ "SSH_SFTP_READDIR_BOTTOM",
+ "SSH_SFTP_READDIR_DONE",
+ "SSH_SFTP_DOWNLOAD_INIT",
+ "SSH_SFTP_DOWNLOAD_STAT",
+ "SSH_SFTP_CLOSE",
+ "SSH_SFTP_SHUTDOWN",
+ "SSH_SCP_TRANS_INIT",
+ "SSH_SCP_UPLOAD_INIT",
+ "SSH_SCP_DOWNLOAD_INIT",
+ "SSH_SCP_DOWNLOAD",
+ "SSH_SCP_DONE",
+ "SSH_SCP_SEND_EOF",
+ "SSH_SCP_WAIT_EOF",
+ "SSH_SCP_WAIT_CLOSE",
+ "SSH_SCP_CHANNEL_FREE",
+ "SSH_SESSION_DISCONNECT",
+ "SSH_SESSION_FREE",
+ "QUIT"
+ };
+
+
+ if(sshc->state != nowstate) {
+ infof(conn->data, "SSH %p state change from %s to %s (line %d)\n",
+ (void *) sshc, names[sshc->state], names[nowstate],
+ lineno);
+ }
+#endif
+
+ sshc->state = nowstate;
+}
+
+/* Multiple options:
+ * 1. data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5] is set with an MD5
+ * hash (90s style auth, not sure we should have it here)
+ * 2. data->set.ssh_keyfunc callback is set. Then we do trust on first
+ * use. We even save on knownhosts if CURLKHSTAT_FINE_ADD_TO_FILE
+ * is returned by it.
+ * 3. none of the above. We only accept if it is present on known hosts.
+ *
+ * Returns SSH_OK or SSH_ERROR.
+ */
+static int myssh_is_known(struct connectdata *conn)
+{
+ int rc;
+ struct Curl_easy *data = conn->data;
+ struct ssh_conn *sshc = &conn->proto.sshc;
+ ssh_key pubkey;
+ size_t hlen;
+ unsigned char *hash = NULL;
+ char *base64 = NULL;
+ int vstate;
+ enum curl_khmatch keymatch;
+ struct curl_khkey foundkey;
+ curl_sshkeycallback func =
+ data->set.ssh_keyfunc;
+
+ rc = ssh_get_publickey(sshc->ssh_session, &pubkey);
+ if(rc != SSH_OK)
+ return rc;
+
+ if(data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5]) {
+ rc = ssh_get_publickey_hash(pubkey, SSH_PUBLICKEY_HASH_MD5,
+ &hash, &hlen);
+ if(rc != SSH_OK)
+ goto cleanup;
+
+ if(hlen != strlen(data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5]) ||
+ memcmp(&data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5], hash, hlen)) {
+ rc = SSH_ERROR;
+ goto cleanup;
+ }
+
+ rc = SSH_OK;
+ goto cleanup;
+ }
+
+ if(data->set.ssl.primary.verifyhost != TRUE) {
+ rc = SSH_OK;
+ goto cleanup;
+ }
+
+ vstate = ssh_is_server_known(sshc->ssh_session);
+ switch(vstate) {
+ case SSH_SERVER_KNOWN_OK:
+ keymatch = CURLKHMATCH_OK;
+ break;
+ case SSH_SERVER_FILE_NOT_FOUND:
+ /* fallthrough */
+ case SSH_SERVER_NOT_KNOWN:
+ keymatch = CURLKHMATCH_MISSING;
+ break;
+ default:
+ keymatch = CURLKHMATCH_MISMATCH;
+ break;
+ }
+
+ if(func) { /* use callback to determine action */
+ rc = ssh_pki_export_pubkey_base64(pubkey, &base64);
+ if(rc != SSH_OK)
+ goto cleanup;
+
+ foundkey.key = base64;
+ foundkey.len = strlen(base64);
+
+ switch(ssh_key_type(pubkey)) {
+ case SSH_KEYTYPE_RSA:
+ foundkey.keytype = CURLKHTYPE_RSA;
+ break;
+ case SSH_KEYTYPE_RSA1:
+ foundkey.keytype = CURLKHTYPE_RSA1;
+ break;
+ case SSH_KEYTYPE_ECDSA:
+ foundkey.keytype = CURLKHTYPE_ECDSA;
+ break;
+#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,7,0)
+ case SSH_KEYTYPE_ED25519:
+ foundkey.keytype = CURLKHTYPE_ED25519;
+ break;
+#endif
+ case SSH_KEYTYPE_DSS:
+ foundkey.keytype = CURLKHTYPE_DSS;
+ break;
+ default:
+ rc = SSH_ERROR;
+ goto cleanup;
+ }
+
+ /* we don't have anything equivalent to knownkey. Always NULL */
+ Curl_set_in_callback(data, true);
+ rc = func(data, NULL, &foundkey, /* from the remote host */
+ keymatch, data->set.ssh_keyfunc_userp);
+ Curl_set_in_callback(data, false);
+
+ switch(rc) {
+ case CURLKHSTAT_FINE_ADD_TO_FILE:
+ rc = ssh_write_knownhost(sshc->ssh_session);
+ if(rc != SSH_OK) {
+ goto cleanup;
+ }
+ break;
+ case CURLKHSTAT_FINE:
+ break;
+ default: /* REJECT/DEFER */
+ rc = SSH_ERROR;
+ goto cleanup;
+ }
+ }
+ else {
+ if(keymatch != CURLKHMATCH_OK) {
+ rc = SSH_ERROR;
+ goto cleanup;
+ }
+ }
+ rc = SSH_OK;
+
+cleanup:
+ if(hash)
+ ssh_clean_pubkey_hash(&hash);
+ ssh_key_free(pubkey);
+ return rc;
+}
+
+#define MOVE_TO_ERROR_STATE(_r) { \
+ state(conn, SSH_SESSION_DISCONNECT); \
+ sshc->actualcode = _r; \
+ rc = SSH_ERROR; \
+ break; \
+}
+
+#define MOVE_TO_SFTP_CLOSE_STATE() { \
+ state(conn, SSH_SFTP_CLOSE); \
+ sshc->actualcode = sftp_error_to_CURLE(sftp_get_error(sshc->sftp_session)); \
+ rc = SSH_ERROR; \
+ break; \
+}
+
+#define MOVE_TO_LAST_AUTH \
+ if(sshc->auth_methods & SSH_AUTH_METHOD_PASSWORD) { \
+ rc = SSH_OK; \
+ state(conn, SSH_AUTH_PASS_INIT); \
+ break; \
+ } \
+ else { \
+ MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED); \
+ }
+
+#define MOVE_TO_TERTIARY_AUTH \
+ if(sshc->auth_methods & SSH_AUTH_METHOD_INTERACTIVE) { \
+ rc = SSH_OK; \
+ state(conn, SSH_AUTH_KEY_INIT); \
+ break; \
+ } \
+ else { \
+ MOVE_TO_LAST_AUTH; \
+ }
+
+#define MOVE_TO_SECONDARY_AUTH \
+ if(sshc->auth_methods & SSH_AUTH_METHOD_GSSAPI_MIC) { \
+ rc = SSH_OK; \
+ state(conn, SSH_AUTH_GSSAPI); \
+ break; \
+ } \
+ else { \
+ MOVE_TO_TERTIARY_AUTH; \
+ }
+
+static
+int myssh_auth_interactive(struct connectdata *conn)
+{
+ int rc;
+ struct ssh_conn *sshc = &conn->proto.sshc;
+ int nprompts;
+
+restart:
+ switch(sshc->kbd_state) {
+ case 0:
+ rc = ssh_userauth_kbdint(sshc->ssh_session, NULL, NULL);
+ if(rc == SSH_AUTH_AGAIN)
+ return SSH_AGAIN;
+
+ if(rc != SSH_AUTH_INFO)
+ return SSH_ERROR;
+
+ nprompts = ssh_userauth_kbdint_getnprompts(sshc->ssh_session);
+ if(nprompts == SSH_ERROR || nprompts != 1)
+ return SSH_ERROR;
+
+ rc = ssh_userauth_kbdint_setanswer(sshc->ssh_session, 0, conn->passwd);
+ if(rc < 0)
+ return SSH_ERROR;
+
+ /* FALLTHROUGH */
+ case 1:
+ sshc->kbd_state = 1;
+
+ rc = ssh_userauth_kbdint(sshc->ssh_session, NULL, NULL);
+ if(rc == SSH_AUTH_AGAIN)
+ return SSH_AGAIN;
+ else if(rc == SSH_AUTH_SUCCESS)
+ rc = SSH_OK;
+ else if(rc == SSH_AUTH_INFO) {
+ nprompts = ssh_userauth_kbdint_getnprompts(sshc->ssh_session);
+ if(nprompts != 0)
+ return SSH_ERROR;
+
+ sshc->kbd_state = 2;
+ goto restart;
+ }
+ else
+ rc = SSH_ERROR;
+ break;
+ case 2:
+ sshc->kbd_state = 2;
+
+ rc = ssh_userauth_kbdint(sshc->ssh_session, NULL, NULL);
+ if(rc == SSH_AUTH_AGAIN)
+ return SSH_AGAIN;
+ else if(rc == SSH_AUTH_SUCCESS)
+ rc = SSH_OK;
+ else
+ rc = SSH_ERROR;
+
+ break;
+ default:
+ return SSH_ERROR;
+ }
+
+ sshc->kbd_state = 0;
+ return rc;
+}
+
+/*
+ * ssh_statemach_act() runs the SSH state machine as far as it can without
+ * blocking and without reaching the end. The data the pointer 'block' points
+ * to will be set to TRUE if the libssh function returns SSH_AGAIN
+ * meaning it wants to be called again when the socket is ready
+ */
+static CURLcode myssh_statemach_act(struct connectdata *conn, bool *block)
+{
+ CURLcode result = CURLE_OK;
+ struct Curl_easy *data = conn->data;
+ struct SSHPROTO *protop = data->req.protop;
+ struct ssh_conn *sshc = &conn->proto.sshc;
+ curl_socket_t sock = conn->sock[FIRSTSOCKET];
+ int rc = SSH_NO_ERROR, err;
+ char *new_readdir_line;
+ int seekerr = CURL_SEEKFUNC_OK;
+ const char *err_msg;
+ *block = 0; /* we're not blocking by default */
+
+ do {
+
+ switch(sshc->state) {
+ case SSH_INIT:
+ sshc->secondCreateDirs = 0;
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_OK;
+
+#if 0
+ ssh_set_log_level(SSH_LOG_PROTOCOL);
+#endif
+
+ /* Set libssh to non-blocking, since everything internally is
+ non-blocking */
+ ssh_set_blocking(sshc->ssh_session, 0);
+
+ state(conn, SSH_S_STARTUP);
+ /* FALLTHROUGH */
+
+ case SSH_S_STARTUP:
+ rc = ssh_connect(sshc->ssh_session);
+ if(rc == SSH_AGAIN)
+ break;
+
+ if(rc != SSH_OK) {
+ failf(data, "Failure establishing ssh session");
+ MOVE_TO_ERROR_STATE(CURLE_FAILED_INIT);
+ }
+
+ state(conn, SSH_HOSTKEY);
+
+ /* FALLTHROUGH */
+ case SSH_HOSTKEY:
+
+ rc = myssh_is_known(conn);
+ if(rc != SSH_OK) {
+ MOVE_TO_ERROR_STATE(CURLE_PEER_FAILED_VERIFICATION);
+ }
+
+ state(conn, SSH_AUTHLIST);
+ /* FALLTHROUGH */
+ case SSH_AUTHLIST:{
+ sshc->authed = FALSE;
+
+ rc = ssh_userauth_none(sshc->ssh_session, NULL);
+ if(rc == SSH_AUTH_AGAIN) {
+ rc = SSH_AGAIN;
+ break;
+ }
+
+ if(rc == SSH_AUTH_SUCCESS) {
+ sshc->authed = TRUE;
+ infof(data, "Authenticated with none\n");
+ state(conn, SSH_AUTH_DONE);
+ break;
+ }
+ else if(rc == SSH_AUTH_ERROR) {
+ MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED);
+ }
+
+ sshc->auth_methods = ssh_userauth_list(sshc->ssh_session, NULL);
+ if(sshc->auth_methods & SSH_AUTH_METHOD_PUBLICKEY) {
+ state(conn, SSH_AUTH_PKEY_INIT);
+ infof(data, "Authentication using SSH public key file\n");
+ }
+ else if(sshc->auth_methods & SSH_AUTH_METHOD_GSSAPI_MIC) {
+ state(conn, SSH_AUTH_GSSAPI);
+ }
+ else if(sshc->auth_methods & SSH_AUTH_METHOD_INTERACTIVE) {
+ state(conn, SSH_AUTH_KEY_INIT);
+ }
+ else if(sshc->auth_methods & SSH_AUTH_METHOD_PASSWORD) {
+ state(conn, SSH_AUTH_PASS_INIT);
+ }
+ else { /* unsupported authentication method */
+ MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED);
+ }
+
+ break;
+ }
+ case SSH_AUTH_PKEY_INIT:
+ if(!(data->set.ssh_auth_types & CURLSSH_AUTH_PUBLICKEY)) {
+ MOVE_TO_SECONDARY_AUTH;
+ }
+
+ /* Two choices, (1) private key was given on CMD,
+ * (2) use the "default" keys. */
+ if(data->set.str[STRING_SSH_PRIVATE_KEY]) {
+ if(sshc->pubkey && !data->set.ssl.key_passwd) {
+ rc = ssh_userauth_try_publickey(sshc->ssh_session, NULL,
+ sshc->pubkey);
+ if(rc == SSH_AUTH_AGAIN) {
+ rc = SSH_AGAIN;
+ break;
+ }
+
+ if(rc != SSH_OK) {
+ MOVE_TO_SECONDARY_AUTH;
+ }
+ }
+
+ rc = ssh_pki_import_privkey_file(data->
+ set.str[STRING_SSH_PRIVATE_KEY],
+ data->set.ssl.key_passwd, NULL,
+ NULL, &sshc->privkey);
+ if(rc != SSH_OK) {
+ failf(data, "Could not load private key file %s",
+ data->set.str[STRING_SSH_PRIVATE_KEY]);
+ MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED);
+ break;
+ }
+
+ state(conn, SSH_AUTH_PKEY);
+ break;
+
+ }
+ else {
+ rc = ssh_userauth_publickey_auto(sshc->ssh_session, NULL,
+ data->set.ssl.key_passwd);
+ if(rc == SSH_AUTH_AGAIN) {
+ rc = SSH_AGAIN;
+ break;
+ }
+ if(rc == SSH_AUTH_SUCCESS) {
+ rc = SSH_OK;
+ sshc->authed = TRUE;
+ infof(data, "Completed public key authentication\n");
+ state(conn, SSH_AUTH_DONE);
+ break;
+ }
+
+ MOVE_TO_SECONDARY_AUTH;
+ }
+ break;
+ case SSH_AUTH_PKEY:
+ rc = ssh_userauth_publickey(sshc->ssh_session, NULL, sshc->privkey);
+ if(rc == SSH_AUTH_AGAIN) {
+ rc = SSH_AGAIN;
+ break;
+ }
+
+ if(rc == SSH_AUTH_SUCCESS) {
+ sshc->authed = TRUE;
+ infof(data, "Completed public key authentication\n");
+ state(conn, SSH_AUTH_DONE);
+ break;
+ }
+ else {
+ infof(data, "Failed public key authentication (rc: %d)\n", rc);
+ MOVE_TO_SECONDARY_AUTH;
+ }
+ break;
+
+ case SSH_AUTH_GSSAPI:
+ if(!(data->set.ssh_auth_types & CURLSSH_AUTH_GSSAPI)) {
+ MOVE_TO_TERTIARY_AUTH;
+ }
+
+ rc = ssh_userauth_gssapi(sshc->ssh_session);
+ if(rc == SSH_AUTH_AGAIN) {
+ rc = SSH_AGAIN;
+ break;
+ }
+
+ if(rc == SSH_AUTH_SUCCESS) {
+ rc = SSH_OK;
+ sshc->authed = TRUE;
+ infof(data, "Completed gssapi authentication\n");
+ state(conn, SSH_AUTH_DONE);
+ break;
+ }
+
+ MOVE_TO_TERTIARY_AUTH;
+ break;
+
+ case SSH_AUTH_KEY_INIT:
+ if(data->set.ssh_auth_types & CURLSSH_AUTH_KEYBOARD) {
+ state(conn, SSH_AUTH_KEY);
+ }
+ else {
+ MOVE_TO_LAST_AUTH;
+ }
+ break;
+
+ case SSH_AUTH_KEY:
+
+ /* Authentication failed. Continue with keyboard-interactive now. */
+ rc = myssh_auth_interactive(conn);
+ if(rc == SSH_AGAIN) {
+ break;
+ }
+ if(rc == SSH_OK) {
+ sshc->authed = TRUE;
+ infof(data, "completed keyboard interactive authentication\n");
+ }
+ state(conn, SSH_AUTH_DONE);
+ break;
+
+ case SSH_AUTH_PASS_INIT:
+ if(!(data->set.ssh_auth_types & CURLSSH_AUTH_PASSWORD)) {
+ /* Host key authentication is intentionally not implemented */
+ MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED);
+ }
+ state(conn, SSH_AUTH_PASS);
+ /* FALLTHROUGH */
+
+ case SSH_AUTH_PASS:
+ rc = ssh_userauth_password(sshc->ssh_session, NULL, conn->passwd);
+ if(rc == SSH_AUTH_AGAIN) {
+ rc = SSH_AGAIN;
+ break;
+ }
+
+ if(rc == SSH_AUTH_SUCCESS) {
+ sshc->authed = TRUE;
+ infof(data, "Completed password authentication\n");
+ state(conn, SSH_AUTH_DONE);
+ }
+ else {
+ MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED);
+ }
+ break;
+
+ case SSH_AUTH_DONE:
+ if(!sshc->authed) {
+ failf(data, "Authentication failure");
+ MOVE_TO_ERROR_STATE(CURLE_LOGIN_DENIED);
+ break;
+ }
+
+ /*
+ * At this point we have an authenticated ssh session.
+ */
+ infof(data, "Authentication complete\n");
+
+ Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSH is connected */
+
+ conn->sockfd = sock;
+ conn->writesockfd = CURL_SOCKET_BAD;
+
+ if(conn->handler->protocol == CURLPROTO_SFTP) {
+ state(conn, SSH_SFTP_INIT);
+ break;
+ }
+ infof(data, "SSH CONNECT phase done\n");
+ state(conn, SSH_STOP);
+ break;
+
+ case SSH_SFTP_INIT:
+ ssh_set_blocking(sshc->ssh_session, 1);
+
+ sshc->sftp_session = sftp_new(sshc->ssh_session);
+ if(!sshc->sftp_session) {
+ failf(data, "Failure initializing sftp session: %s",
+ ssh_get_error(sshc->ssh_session));
+ MOVE_TO_ERROR_STATE(CURLE_COULDNT_CONNECT);
+ break;
+ }
+
+ rc = sftp_init(sshc->sftp_session);
+ if(rc != SSH_OK) {
+ rc = sftp_get_error(sshc->sftp_session);
+ failf(data, "Failure initializing sftp session: %s",
+ ssh_get_error(sshc->ssh_session));
+ MOVE_TO_ERROR_STATE(sftp_error_to_CURLE(rc));
+ break;
+ }
+ state(conn, SSH_SFTP_REALPATH);
+ /* FALLTHROUGH */
+ case SSH_SFTP_REALPATH:
+ /*
+ * Get the "home" directory
+ */
+ sshc->homedir = sftp_canonicalize_path(sshc->sftp_session, ".");
+ if(sshc->homedir == NULL) {
+ MOVE_TO_ERROR_STATE(CURLE_COULDNT_CONNECT);
+ }
+ conn->data->state.most_recent_ftp_entrypath = sshc->homedir;
+
+ /* This is the last step in the SFTP connect phase. Do note that while
+ we get the homedir here, we get the "workingpath" in the DO action
+ since the homedir will remain the same between request but the
+ working path will not. */
+ DEBUGF(infof(data, "SSH CONNECT phase done\n"));
+ state(conn, SSH_STOP);
+ break;
+
+ case SSH_SFTP_QUOTE_INIT:
+
+ result = Curl_getworkingpath(conn, sshc->homedir, &protop->path);
+ if(result) {
+ sshc->actualcode = result;
+ state(conn, SSH_STOP);
+ break;
+ }
+
+ if(data->set.quote) {
+ infof(data, "Sending quote commands\n");
+ sshc->quote_item = data->set.quote;
+ state(conn, SSH_SFTP_QUOTE);
+ }
+ else {
+ state(conn, SSH_SFTP_GETINFO);
+ }
+ break;
+
+ case SSH_SFTP_POSTQUOTE_INIT:
+ if(data->set.postquote) {
+ infof(data, "Sending quote commands\n");
+ sshc->quote_item = data->set.postquote;
+ state(conn, SSH_SFTP_QUOTE);
+ }
+ else {
+ state(conn, SSH_STOP);
+ }
+ break;
+
+ case SSH_SFTP_QUOTE:
+ /* Send any quote commands */
+ sftp_quote(conn);
+ break;
+
+ case SSH_SFTP_NEXT_QUOTE:
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+
+ sshc->quote_item = sshc->quote_item->next;
+
+ if(sshc->quote_item) {
+ state(conn, SSH_SFTP_QUOTE);
+ }
+ else {
+ if(sshc->nextstate != SSH_NO_STATE) {
+ state(conn, sshc->nextstate);
+ sshc->nextstate = SSH_NO_STATE;
+ }
+ else {
+ state(conn, SSH_SFTP_GETINFO);
+ }
+ }
+ break;
+
+ case SSH_SFTP_QUOTE_STAT:
+ sftp_quote_stat(conn);
+ break;
+
+ case SSH_SFTP_QUOTE_SETSTAT:
+ rc = sftp_setstat(sshc->sftp_session, sshc->quote_path2,
+ sshc->quote_attrs);
+ if(rc != 0 && !sshc->acceptfail) {
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+ failf(data, "Attempt to set SFTP stats failed: %s",
+ ssh_get_error(sshc->ssh_session));
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ /* sshc->actualcode = sftp_error_to_CURLE(err);
+ * we do not send the actual error; we return
+ * the error the libssh2 backend is returning */
+ break;
+ }
+ state(conn, SSH_SFTP_NEXT_QUOTE);
+ break;
+
+ case SSH_SFTP_QUOTE_SYMLINK:
+ rc = sftp_symlink(sshc->sftp_session, sshc->quote_path2,
+ sshc->quote_path1);
+ if(rc != 0 && !sshc->acceptfail) {
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+ failf(data, "symlink command failed: %s",
+ ssh_get_error(sshc->ssh_session));
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ break;
+ }
+ state(conn, SSH_SFTP_NEXT_QUOTE);
+ break;
+
+ case SSH_SFTP_QUOTE_MKDIR:
+ rc = sftp_mkdir(sshc->sftp_session, sshc->quote_path1,
+ (mode_t)data->set.new_directory_perms);
+ if(rc != 0 && !sshc->acceptfail) {
+ Curl_safefree(sshc->quote_path1);
+ failf(data, "mkdir command failed: %s",
+ ssh_get_error(sshc->ssh_session));
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ break;
+ }
+ state(conn, SSH_SFTP_NEXT_QUOTE);
+ break;
+
+ case SSH_SFTP_QUOTE_RENAME:
+ rc = sftp_rename(sshc->sftp_session, sshc->quote_path1,
+ sshc->quote_path2);
+ if(rc != 0 && !sshc->acceptfail) {
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+ failf(data, "rename command failed: %s",
+ ssh_get_error(sshc->ssh_session));
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ break;
+ }
+ state(conn, SSH_SFTP_NEXT_QUOTE);
+ break;
+
+ case SSH_SFTP_QUOTE_RMDIR:
+ rc = sftp_rmdir(sshc->sftp_session, sshc->quote_path1);
+ if(rc != 0 && !sshc->acceptfail) {
+ Curl_safefree(sshc->quote_path1);
+ failf(data, "rmdir command failed: %s",
+ ssh_get_error(sshc->ssh_session));
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ break;
+ }
+ state(conn, SSH_SFTP_NEXT_QUOTE);
+ break;
+
+ case SSH_SFTP_QUOTE_UNLINK:
+ rc = sftp_unlink(sshc->sftp_session, sshc->quote_path1);
+ if(rc != 0 && !sshc->acceptfail) {
+ Curl_safefree(sshc->quote_path1);
+ failf(data, "rm command failed: %s",
+ ssh_get_error(sshc->ssh_session));
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ break;
+ }
+ state(conn, SSH_SFTP_NEXT_QUOTE);
+ break;
+
+ case SSH_SFTP_QUOTE_STATVFS:
+ {
+ sftp_statvfs_t statvfs;
+
+ statvfs = sftp_statvfs(sshc->sftp_session, sshc->quote_path1);
+ if(!statvfs && !sshc->acceptfail) {
+ Curl_safefree(sshc->quote_path1);
+ failf(data, "statvfs command failed: %s",
+ ssh_get_error(sshc->ssh_session));
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ break;
+ }
+ else if(statvfs) {
+ char *tmp = aprintf("statvfs:\n"
+ "f_bsize: %llu\n" "f_frsize: %llu\n"
+ "f_blocks: %llu\n" "f_bfree: %llu\n"
+ "f_bavail: %llu\n" "f_files: %llu\n"
+ "f_ffree: %llu\n" "f_favail: %llu\n"
+ "f_fsid: %llu\n" "f_flag: %llu\n"
+ "f_namemax: %llu\n",
+ statvfs->f_bsize, statvfs->f_frsize,
+ statvfs->f_blocks, statvfs->f_bfree,
+ statvfs->f_bavail, statvfs->f_files,
+ statvfs->f_ffree, statvfs->f_favail,
+ statvfs->f_fsid, statvfs->f_flag,
+ statvfs->f_namemax);
+ sftp_statvfs_free(statvfs);
+
+ if(!tmp) {
+ result = CURLE_OUT_OF_MEMORY;
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ break;
+ }
+
+ result = Curl_client_write(conn, CLIENTWRITE_HEADER, tmp, strlen(tmp));
+ free(tmp);
+ if(result) {
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = result;
+ }
+ }
+ state(conn, SSH_SFTP_NEXT_QUOTE);
+ break;
+ }
+
+ case SSH_SFTP_GETINFO:
+ if(data->set.get_filetime) {
+ state(conn, SSH_SFTP_FILETIME);
+ }
+ else {
+ state(conn, SSH_SFTP_TRANS_INIT);
+ }
+ break;
+
+ case SSH_SFTP_FILETIME:
+ {
+ sftp_attributes attrs;
+
+ attrs = sftp_stat(sshc->sftp_session, protop->path);
+ if(attrs != 0) {
+ data->info.filetime = attrs->mtime;
+ sftp_attributes_free(attrs);
+ }
+
+ state(conn, SSH_SFTP_TRANS_INIT);
+ break;
+ }
+
+ case SSH_SFTP_TRANS_INIT:
+ if(data->set.upload)
+ state(conn, SSH_SFTP_UPLOAD_INIT);
+ else {
+ if(protop->path[strlen(protop->path)-1] == '/')
+ state(conn, SSH_SFTP_READDIR_INIT);
+ else
+ state(conn, SSH_SFTP_DOWNLOAD_INIT);
+ }
+ break;
+
+ case SSH_SFTP_UPLOAD_INIT:
+ {
+ int flags;
+
+ if(data->state.resume_from != 0) {
+ sftp_attributes attrs;
+
+ if(data->state.resume_from < 0) {
+ attrs = sftp_stat(sshc->sftp_session, protop->path);
+ if(attrs != 0) {
+ curl_off_t size = attrs->size;
+ if(size < 0) {
+ failf(data, "Bad file size (%" CURL_FORMAT_CURL_OFF_T ")", size);
+ MOVE_TO_ERROR_STATE(CURLE_BAD_DOWNLOAD_RESUME);
+ }
+ data->state.resume_from = attrs->size;
+
+ sftp_attributes_free(attrs);
+ }
+ else {
+ data->state.resume_from = 0;
+ }
+ }
+ }
+
+ if(data->set.ftp_append)
+ /* Try to open for append, but create if nonexisting */
+ flags = O_WRONLY|O_CREAT|O_APPEND;
+ else if(data->state.resume_from > 0)
+ /* If we have restart position then open for append */
+ flags = O_WRONLY|O_APPEND;
+ else
+ /* Clear file before writing (normal behaviour) */
+ flags = O_WRONLY|O_APPEND|O_CREAT|O_TRUNC;
+
+ if(sshc->sftp_file)
+ sftp_close(sshc->sftp_file);
+ sshc->sftp_file =
+ sftp_open(sshc->sftp_session, protop->path,
+ flags, (mode_t)data->set.new_file_perms);
+ if(!sshc->sftp_file) {
+ err = sftp_get_error(sshc->sftp_session);
+
+ if(((err == SSH_FX_NO_SUCH_FILE || err == SSH_FX_FAILURE ||
+ err == SSH_FX_NO_SUCH_PATH)) &&
+ (data->set.ftp_create_missing_dirs &&
+ (strlen(protop->path) > 1))) {
+ /* try to create the path remotely */
+ rc = 0;
+ sshc->secondCreateDirs = 1;
+ state(conn, SSH_SFTP_CREATE_DIRS_INIT);
+ break;
+ }
+ else {
+ MOVE_TO_SFTP_CLOSE_STATE();
+ }
+ }
+
+ /* If we have a restart point then we need to seek to the correct
+ position. */
+ if(data->state.resume_from > 0) {
+ /* Let's read off the proper amount of bytes from the input. */
+ if(conn->seek_func) {
+ Curl_set_in_callback(data, true);
+ seekerr = conn->seek_func(conn->seek_client, data->state.resume_from,
+ SEEK_SET);
+ Curl_set_in_callback(data, false);
+ }
+
+ if(seekerr != CURL_SEEKFUNC_OK) {
+ curl_off_t passed = 0;
+
+ if(seekerr != CURL_SEEKFUNC_CANTSEEK) {
+ failf(data, "Could not seek stream");
+ return CURLE_FTP_COULDNT_USE_REST;
+ }
+ /* seekerr == CURL_SEEKFUNC_CANTSEEK (can't seek to offset) */
+ do {
+ size_t readthisamountnow =
+ (data->state.resume_from - passed > data->set.buffer_size) ?
+ (size_t)data->set.buffer_size :
+ curlx_sotouz(data->state.resume_from - passed);
+
+ size_t actuallyread =
+ data->state.fread_func(data->state.buffer, 1,
+ readthisamountnow, data->state.in);
+
+ passed += actuallyread;
+ if((actuallyread == 0) || (actuallyread > readthisamountnow)) {
+ /* this checks for greater-than only to make sure that the
+ CURL_READFUNC_ABORT return code still aborts */
+ failf(data, "Failed to read data");
+ MOVE_TO_ERROR_STATE(CURLE_FTP_COULDNT_USE_REST);
+ }
+ } while(passed < data->state.resume_from);
+ }
+
+ /* now, decrease the size of the read */
+ if(data->state.infilesize > 0) {
+ data->state.infilesize -= data->state.resume_from;
+ data->req.size = data->state.infilesize;
+ Curl_pgrsSetUploadSize(data, data->state.infilesize);
+ }
+
+ rc = sftp_seek64(sshc->sftp_file, data->state.resume_from);
+ if(rc != 0) {
+ MOVE_TO_SFTP_CLOSE_STATE();
+ }
+ }
+ if(data->state.infilesize > 0) {
+ data->req.size = data->state.infilesize;
+ Curl_pgrsSetUploadSize(data, data->state.infilesize);
+ }
+ /* upload data */
+ Curl_setup_transfer(data, -1, -1, FALSE, FIRSTSOCKET);
+
+ /* not set by Curl_setup_transfer to preserve keepon bits */
+ conn->sockfd = conn->writesockfd;
+
+ /* store this original bitmask setup to use later on if we can't
+ figure out a "real" bitmask */
+ sshc->orig_waitfor = data->req.keepon;
+
+ /* we want to use the _sending_ function even when the socket turns
+ out readable as the underlying libssh sftp send function will deal
+ with both accordingly */
+ conn->cselect_bits = CURL_CSELECT_OUT;
+
+ /* since we don't really wait for anything at this point, we want the
+ state machine to move on as soon as possible so we set a very short
+ timeout here */
+ Curl_expire(data, 0, EXPIRE_RUN_NOW);
+
+ state(conn, SSH_STOP);
+ break;
+ }
+
+ case SSH_SFTP_CREATE_DIRS_INIT:
+ if(strlen(protop->path) > 1) {
+ sshc->slash_pos = protop->path + 1; /* ignore the leading '/' */
+ state(conn, SSH_SFTP_CREATE_DIRS);
+ }
+ else {
+ state(conn, SSH_SFTP_UPLOAD_INIT);
+ }
+ break;
+
+ case SSH_SFTP_CREATE_DIRS:
+ sshc->slash_pos = strchr(sshc->slash_pos, '/');
+ if(sshc->slash_pos) {
+ *sshc->slash_pos = 0;
+
+ infof(data, "Creating directory '%s'\n", protop->path);
+ state(conn, SSH_SFTP_CREATE_DIRS_MKDIR);
+ break;
+ }
+ state(conn, SSH_SFTP_UPLOAD_INIT);
+ break;
+
+ case SSH_SFTP_CREATE_DIRS_MKDIR:
+ /* 'mode' - parameter is preliminary - default to 0644 */
+ rc = sftp_mkdir(sshc->sftp_session, protop->path,
+ (mode_t)data->set.new_directory_perms);
+ *sshc->slash_pos = '/';
+ ++sshc->slash_pos;
+ if(rc < 0) {
+ /*
+ * Abort if failure wasn't that the dir already exists or the
+ * permission was denied (creation might succeed further down the
+ * path) - retry on unspecific FAILURE also
+ */
+ err = sftp_get_error(sshc->sftp_session);
+ if((err != SSH_FX_FILE_ALREADY_EXISTS) &&
+ (err != SSH_FX_FAILURE) &&
+ (err != SSH_FX_PERMISSION_DENIED)) {
+ MOVE_TO_SFTP_CLOSE_STATE();
+ }
+ rc = 0; /* clear rc and continue */
+ }
+ state(conn, SSH_SFTP_CREATE_DIRS);
+ break;
+
+ case SSH_SFTP_READDIR_INIT:
+ Curl_pgrsSetDownloadSize(data, -1);
+ if(data->set.opt_no_body) {
+ state(conn, SSH_STOP);
+ break;
+ }
+
+ /*
+ * This is a directory that we are trying to get, so produce a directory
+ * listing
+ */
+ sshc->sftp_dir = sftp_opendir(sshc->sftp_session,
+ protop->path);
+ if(!sshc->sftp_dir) {
+ failf(data, "Could not open directory for reading: %s",
+ ssh_get_error(sshc->ssh_session));
+ MOVE_TO_SFTP_CLOSE_STATE();
+ }
+ state(conn, SSH_SFTP_READDIR);
+ break;
+
+ case SSH_SFTP_READDIR:
+
+ if(sshc->readdir_attrs)
+ sftp_attributes_free(sshc->readdir_attrs);
+
+ sshc->readdir_attrs = sftp_readdir(sshc->sftp_session, sshc->sftp_dir);
+ if(sshc->readdir_attrs) {
+ sshc->readdir_filename = sshc->readdir_attrs->name;
+ sshc->readdir_longentry = sshc->readdir_attrs->longname;
+ sshc->readdir_len = strlen(sshc->readdir_filename);
+
+ if(data->set.ftp_list_only) {
+ char *tmpLine;
+
+ tmpLine = aprintf("%s\n", sshc->readdir_filename);
+ if(tmpLine == NULL) {
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->actualcode = CURLE_OUT_OF_MEMORY;
+ break;
+ }
+ result = Curl_client_write(conn, CLIENTWRITE_BODY,
+ tmpLine, sshc->readdir_len + 1);
+ free(tmpLine);
+
+ if(result) {
+ state(conn, SSH_STOP);
+ break;
+ }
+ /* since this counts what we send to the client, we include the
+ newline in this counter */
+ data->req.bytecount += sshc->readdir_len + 1;
+
+ /* output debug output if that is requested */
+ if(data->set.verbose) {
+ Curl_debug(data, CURLINFO_DATA_OUT,
+ (char *)sshc->readdir_filename,
+ sshc->readdir_len);
+ }
+ }
+ else {
+ sshc->readdir_currLen = strlen(sshc->readdir_longentry);
+ sshc->readdir_totalLen = 80 + sshc->readdir_currLen;
+ sshc->readdir_line = calloc(sshc->readdir_totalLen, 1);
+ if(!sshc->readdir_line) {
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->actualcode = CURLE_OUT_OF_MEMORY;
+ break;
+ }
+
+ memcpy(sshc->readdir_line, sshc->readdir_longentry,
+ sshc->readdir_currLen);
+ if((sshc->readdir_attrs->flags & SSH_FILEXFER_ATTR_PERMISSIONS) &&
+ ((sshc->readdir_attrs->permissions & S_IFMT) ==
+ S_IFLNK)) {
+ sshc->readdir_linkPath = malloc(PATH_MAX + 1);
+ if(sshc->readdir_linkPath == NULL) {
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->actualcode = CURLE_OUT_OF_MEMORY;
+ break;
+ }
+
+ msnprintf(sshc->readdir_linkPath, PATH_MAX, "%s%s", protop->path,
+ sshc->readdir_filename);
+
+ state(conn, SSH_SFTP_READDIR_LINK);
+ break;
+ }
+ state(conn, SSH_SFTP_READDIR_BOTTOM);
+ break;
+ }
+ }
+ else if(sshc->readdir_attrs == NULL && sftp_dir_eof(sshc->sftp_dir)) {
+ state(conn, SSH_SFTP_READDIR_DONE);
+ break;
+ }
+ else {
+ failf(data, "Could not open remote file for reading: %s",
+ ssh_get_error(sshc->ssh_session));
+ MOVE_TO_SFTP_CLOSE_STATE();
+ break;
+ }
+ break;
+
+ case SSH_SFTP_READDIR_LINK:
+ if(sshc->readdir_link_attrs)
+ sftp_attributes_free(sshc->readdir_link_attrs);
+
+ sshc->readdir_link_attrs = sftp_lstat(sshc->sftp_session,
+ sshc->readdir_linkPath);
+ if(sshc->readdir_link_attrs == 0) {
+ failf(data, "Could not read symlink for reading: %s",
+ ssh_get_error(sshc->ssh_session));
+ MOVE_TO_SFTP_CLOSE_STATE();
+ }
+
+ if(sshc->readdir_link_attrs->name == NULL) {
+ sshc->readdir_tmp = sftp_readlink(sshc->sftp_session,
+ sshc->readdir_linkPath);
+ if(sshc->readdir_filename == NULL)
+ sshc->readdir_len = 0;
+ else
+ sshc->readdir_len = strlen(sshc->readdir_tmp);
+ sshc->readdir_longentry = NULL;
+ sshc->readdir_filename = sshc->readdir_tmp;
+ }
+ else {
+ sshc->readdir_len = strlen(sshc->readdir_link_attrs->name);
+ sshc->readdir_filename = sshc->readdir_link_attrs->name;
+ sshc->readdir_longentry = sshc->readdir_link_attrs->longname;
+ }
+
+ Curl_safefree(sshc->readdir_linkPath);
+
+ /* get room for the filename and extra output */
+ sshc->readdir_totalLen += 4 + sshc->readdir_len;
+ new_readdir_line = Curl_saferealloc(sshc->readdir_line,
+ sshc->readdir_totalLen);
+ if(!new_readdir_line) {
+ sshc->readdir_line = NULL;
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->actualcode = CURLE_OUT_OF_MEMORY;
+ break;
+ }
+ sshc->readdir_line = new_readdir_line;
+
+ sshc->readdir_currLen += msnprintf(sshc->readdir_line +
+ sshc->readdir_currLen,
+ sshc->readdir_totalLen -
+ sshc->readdir_currLen,
+ " -> %s",
+ sshc->readdir_filename);
+
+ sftp_attributes_free(sshc->readdir_link_attrs);
+ sshc->readdir_link_attrs = NULL;
+ sshc->readdir_filename = NULL;
+ sshc->readdir_longentry = NULL;
+
+ state(conn, SSH_SFTP_READDIR_BOTTOM);
+ /* FALLTHROUGH */
+ case SSH_SFTP_READDIR_BOTTOM:
+ sshc->readdir_currLen += msnprintf(sshc->readdir_line +
+ sshc->readdir_currLen,
+ sshc->readdir_totalLen -
+ sshc->readdir_currLen, "\n");
+ result = Curl_client_write(conn, CLIENTWRITE_BODY,
+ sshc->readdir_line,
+ sshc->readdir_currLen);
+
+ if(!result) {
+
+ /* output debug output if that is requested */
+ if(data->set.verbose) {
+ Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line,
+ sshc->readdir_currLen);
+ }
+ data->req.bytecount += sshc->readdir_currLen;
+ }
+ Curl_safefree(sshc->readdir_line);
+ ssh_string_free_char(sshc->readdir_tmp);
+ sshc->readdir_tmp = NULL;
+
+ if(result) {
+ state(conn, SSH_STOP);
+ }
+ else
+ state(conn, SSH_SFTP_READDIR);
+ break;
+
+ case SSH_SFTP_READDIR_DONE:
+ sftp_closedir(sshc->sftp_dir);
+ sshc->sftp_dir = NULL;
+
+ /* no data to transfer */
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
+ state(conn, SSH_STOP);
+ break;
+
+ case SSH_SFTP_DOWNLOAD_INIT:
+ /*
+ * Work on getting the specified file
+ */
+ if(sshc->sftp_file)
+ sftp_close(sshc->sftp_file);
+
+ sshc->sftp_file = sftp_open(sshc->sftp_session, protop->path,
+ O_RDONLY, (mode_t)data->set.new_file_perms);
+ if(!sshc->sftp_file) {
+ failf(data, "Could not open remote file for reading: %s",
+ ssh_get_error(sshc->ssh_session));
+
+ MOVE_TO_SFTP_CLOSE_STATE();
+ }
+
+ state(conn, SSH_SFTP_DOWNLOAD_STAT);
+ break;
+
+ case SSH_SFTP_DOWNLOAD_STAT:
+ {
+ sftp_attributes attrs;
+ curl_off_t size;
+
+ attrs = sftp_fstat(sshc->sftp_file);
+ if(!attrs ||
+ !(attrs->flags & SSH_FILEXFER_ATTR_SIZE) ||
+ (attrs->size == 0)) {
+ /*
+ * sftp_fstat didn't return an error, so maybe the server
+ * just doesn't support stat()
+ * OR the server doesn't return a file size with a stat()
+ * OR file size is 0
+ */
+ data->req.size = -1;
+ data->req.maxdownload = -1;
+ Curl_pgrsSetDownloadSize(data, -1);
+ size = 0;
+ }
+ else {
+ size = attrs->size;
+
+ sftp_attributes_free(attrs);
+
+ if(size < 0) {
+ failf(data, "Bad file size (%" CURL_FORMAT_CURL_OFF_T ")", size);
+ return CURLE_BAD_DOWNLOAD_RESUME;
+ }
+ if(conn->data->state.use_range) {
+ curl_off_t from, to;
+ char *ptr;
+ char *ptr2;
+ CURLofft to_t;
+ CURLofft from_t;
+
+ from_t = curlx_strtoofft(conn->data->state.range, &ptr, 0, &from);
+ if(from_t == CURL_OFFT_FLOW) {
+ return CURLE_RANGE_ERROR;
+ }
+ while(*ptr && (ISSPACE(*ptr) || (*ptr == '-')))
+ ptr++;
+ to_t = curlx_strtoofft(ptr, &ptr2, 0, &to);
+ if(to_t == CURL_OFFT_FLOW) {
+ return CURLE_RANGE_ERROR;
+ }
+ if((to_t == CURL_OFFT_INVAL) /* no "to" value given */
+ || (to >= size)) {
+ to = size - 1;
+ }
+ if(from_t) {
+ /* from is relative to end of file */
+ from = size - to;
+ to = size - 1;
+ }
+ if(from > size) {
+ failf(data, "Offset (%"
+ CURL_FORMAT_CURL_OFF_T ") was beyond file size (%"
+ CURL_FORMAT_CURL_OFF_T ")", from, size);
+ return CURLE_BAD_DOWNLOAD_RESUME;
+ }
+ if(from > to) {
+ from = to;
+ size = 0;
+ }
+ else {
+ size = to - from + 1;
+ }
+
+ rc = sftp_seek64(sshc->sftp_file, from);
+ if(rc != 0) {
+ MOVE_TO_SFTP_CLOSE_STATE();
+ }
+ }
+ data->req.size = size;
+ data->req.maxdownload = size;
+ Curl_pgrsSetDownloadSize(data, size);
+ }
+
+ /* We can resume if we can seek to the resume position */
+ if(data->state.resume_from) {
+ if(data->state.resume_from < 0) {
+ /* We're supposed to download the last abs(from) bytes */
+ if((curl_off_t)size < -data->state.resume_from) {
+ failf(data, "Offset (%"
+ CURL_FORMAT_CURL_OFF_T ") was beyond file size (%"
+ CURL_FORMAT_CURL_OFF_T ")",
+ data->state.resume_from, size);
+ return CURLE_BAD_DOWNLOAD_RESUME;
+ }
+ /* download from where? */
+ data->state.resume_from += size;
+ }
+ else {
+ if((curl_off_t)size < data->state.resume_from) {
+ failf(data, "Offset (%" CURL_FORMAT_CURL_OFF_T
+ ") was beyond file size (%" CURL_FORMAT_CURL_OFF_T ")",
+ data->state.resume_from, size);
+ return CURLE_BAD_DOWNLOAD_RESUME;
+ }
+ }
+ /* Does a completed file need to be seeked and started or closed ? */
+ /* Now store the number of bytes we are expected to download */
+ data->req.size = size - data->state.resume_from;
+ data->req.maxdownload = size - data->state.resume_from;
+ Curl_pgrsSetDownloadSize(data,
+ size - data->state.resume_from);
+
+ rc = sftp_seek64(sshc->sftp_file, data->state.resume_from);
+ if(rc != 0) {
+ MOVE_TO_SFTP_CLOSE_STATE();
+ }
+ }
+ }
+
+ /* Setup the actual download */
+ if(data->req.size == 0) {
+ /* no data to transfer */
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
+ infof(data, "File already completely downloaded\n");
+ state(conn, SSH_STOP);
+ break;
+ }
+ Curl_setup_transfer(data, FIRSTSOCKET, data->req.size, FALSE, -1);
+
+ /* not set by Curl_setup_transfer to preserve keepon bits */
+ conn->writesockfd = conn->sockfd;
+
+ /* we want to use the _receiving_ function even when the socket turns
+ out writableable as the underlying libssh recv function will deal
+ with both accordingly */
+ conn->cselect_bits = CURL_CSELECT_IN;
+
+ if(result) {
+ /* this should never occur; the close state should be entered
+ at the time the error occurs */
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->actualcode = result;
+ }
+ else {
+ sshc->sftp_recv_state = 0;
+ state(conn, SSH_STOP);
+ }
+ break;
+
+ case SSH_SFTP_CLOSE:
+ if(sshc->sftp_file) {
+ sftp_close(sshc->sftp_file);
+ sshc->sftp_file = NULL;
+ }
+ Curl_safefree(protop->path);
+
+ DEBUGF(infof(data, "SFTP DONE done\n"));
+
+ /* Check if nextstate is set and move .nextstate could be POSTQUOTE_INIT
+ After nextstate is executed, the control should come back to
+ SSH_SFTP_CLOSE to pass the correct result back */
+ if(sshc->nextstate != SSH_NO_STATE &&
+ sshc->nextstate != SSH_SFTP_CLOSE) {
+ state(conn, sshc->nextstate);
+ sshc->nextstate = SSH_SFTP_CLOSE;
+ }
+ else {
+ state(conn, SSH_STOP);
+ result = sshc->actualcode;
+ }
+ break;
+
+ case SSH_SFTP_SHUTDOWN:
+ /* during times we get here due to a broken transfer and then the
+ sftp_handle might not have been taken down so make sure that is done
+ before we proceed */
+
+ if(sshc->sftp_file) {
+ sftp_close(sshc->sftp_file);
+ sshc->sftp_file = NULL;
+ }
+
+ if(sshc->sftp_session) {
+ sftp_free(sshc->sftp_session);
+ sshc->sftp_session = NULL;
+ }
+
+ SSH_STRING_FREE_CHAR(sshc->homedir);
+ conn->data->state.most_recent_ftp_entrypath = NULL;
+
+ state(conn, SSH_SESSION_DISCONNECT);
+ break;
+
+
+ case SSH_SCP_TRANS_INIT:
+ result = Curl_getworkingpath(conn, sshc->homedir, &protop->path);
+ if(result) {
+ sshc->actualcode = result;
+ state(conn, SSH_STOP);
+ break;
+ }
+
+ /* Functions from the SCP subsystem cannot handle/return SSH_AGAIN */
+ ssh_set_blocking(sshc->ssh_session, 1);
+
+ if(data->set.upload) {
+ if(data->state.infilesize < 0) {
+ failf(data, "SCP requires a known file size for upload");
+ sshc->actualcode = CURLE_UPLOAD_FAILED;
+ MOVE_TO_ERROR_STATE(CURLE_UPLOAD_FAILED);
+ }
+
+ sshc->scp_session =
+ ssh_scp_new(sshc->ssh_session, SSH_SCP_WRITE, protop->path);
+ state(conn, SSH_SCP_UPLOAD_INIT);
+ }
+ else {
+ sshc->scp_session =
+ ssh_scp_new(sshc->ssh_session, SSH_SCP_READ, protop->path);
+ state(conn, SSH_SCP_DOWNLOAD_INIT);
+ }
+
+ if(!sshc->scp_session) {
+ err_msg = ssh_get_error(sshc->ssh_session);
+ failf(conn->data, "%s", err_msg);
+ MOVE_TO_ERROR_STATE(CURLE_UPLOAD_FAILED);
+ }
+
+ break;
+
+ case SSH_SCP_UPLOAD_INIT:
+
+ rc = ssh_scp_init(sshc->scp_session);
+ if(rc != SSH_OK) {
+ err_msg = ssh_get_error(sshc->ssh_session);
+ failf(conn->data, "%s", err_msg);
+ MOVE_TO_ERROR_STATE(CURLE_UPLOAD_FAILED);
+ }
+
+ rc = ssh_scp_push_file(sshc->scp_session, protop->path,
+ data->state.infilesize,
+ (int)data->set.new_file_perms);
+ if(rc != SSH_OK) {
+ err_msg = ssh_get_error(sshc->ssh_session);
+ failf(conn->data, "%s", err_msg);
+ MOVE_TO_ERROR_STATE(CURLE_UPLOAD_FAILED);
+ }
+
+ /* upload data */
+ Curl_setup_transfer(data, -1, data->req.size, FALSE, FIRSTSOCKET);
+
+ /* not set by Curl_setup_transfer to preserve keepon bits */
+ conn->sockfd = conn->writesockfd;
+
+ /* store this original bitmask setup to use later on if we can't
+ figure out a "real" bitmask */
+ sshc->orig_waitfor = data->req.keepon;
+
+ /* we want to use the _sending_ function even when the socket turns
+ out readable as the underlying libssh scp send function will deal
+ with both accordingly */
+ conn->cselect_bits = CURL_CSELECT_OUT;
+
+ state(conn, SSH_STOP);
+
+ break;
+
+ case SSH_SCP_DOWNLOAD_INIT:
+
+ rc = ssh_scp_init(sshc->scp_session);
+ if(rc != SSH_OK) {
+ err_msg = ssh_get_error(sshc->ssh_session);
+ failf(conn->data, "%s", err_msg);
+ MOVE_TO_ERROR_STATE(CURLE_COULDNT_CONNECT);
+ }
+ state(conn, SSH_SCP_DOWNLOAD);
+ /* FALLTHROUGH */
+
+ case SSH_SCP_DOWNLOAD:{
+ curl_off_t bytecount;
+
+ rc = ssh_scp_pull_request(sshc->scp_session);
+ if(rc != SSH_SCP_REQUEST_NEWFILE) {
+ err_msg = ssh_get_error(sshc->ssh_session);
+ failf(conn->data, "%s", err_msg);
+ MOVE_TO_ERROR_STATE(CURLE_REMOTE_FILE_NOT_FOUND);
+ break;
+ }
+
+ /* download data */
+ bytecount = ssh_scp_request_get_size(sshc->scp_session);
+ data->req.maxdownload = (curl_off_t) bytecount;
+ Curl_setup_transfer(data, FIRSTSOCKET, bytecount, FALSE, -1);
+
+ /* not set by Curl_setup_transfer to preserve keepon bits */
+ conn->writesockfd = conn->sockfd;
+
+ /* we want to use the _receiving_ function even when the socket turns
+ out writableable as the underlying libssh recv function will deal
+ with both accordingly */
+ conn->cselect_bits = CURL_CSELECT_IN;
+
+ state(conn, SSH_STOP);
+ break;
+ }
+ case SSH_SCP_DONE:
+ if(data->set.upload)
+ state(conn, SSH_SCP_SEND_EOF);
+ else
+ state(conn, SSH_SCP_CHANNEL_FREE);
+ break;
+
+ case SSH_SCP_SEND_EOF:
+ if(sshc->scp_session) {
+ rc = ssh_scp_close(sshc->scp_session);
+ if(rc == SSH_AGAIN) {
+ /* Currently the ssh_scp_close handles waiting for EOF in
+ * blocking way.
+ */
+ break;
+ }
+ if(rc != SSH_OK) {
+ infof(data, "Failed to close libssh scp channel: %s\n",
+ ssh_get_error(sshc->ssh_session));
+ }
+ }
+
+ state(conn, SSH_SCP_CHANNEL_FREE);
+ break;
+
+ case SSH_SCP_CHANNEL_FREE:
+ if(sshc->scp_session) {
+ ssh_scp_free(sshc->scp_session);
+ sshc->scp_session = NULL;
+ }
+ DEBUGF(infof(data, "SCP DONE phase complete\n"));
+
+ ssh_set_blocking(sshc->ssh_session, 0);
+
+ state(conn, SSH_SESSION_DISCONNECT);
+ /* FALLTHROUGH */
+
+ case SSH_SESSION_DISCONNECT:
+ /* during weird times when we've been prematurely aborted, the channel
+ is still alive when we reach this state and we MUST kill the channel
+ properly first */
+ if(sshc->scp_session) {
+ ssh_scp_free(sshc->scp_session);
+ sshc->scp_session = NULL;
+ }
+
+ ssh_disconnect(sshc->ssh_session);
+
+ SSH_STRING_FREE_CHAR(sshc->homedir);
+ conn->data->state.most_recent_ftp_entrypath = NULL;
+
+ state(conn, SSH_SESSION_FREE);
+ /* FALLTHROUGH */
+ case SSH_SESSION_FREE:
+ if(sshc->ssh_session) {
+ ssh_free(sshc->ssh_session);
+ sshc->ssh_session = NULL;
+ }
+
+ /* worst-case scenario cleanup */
+
+ DEBUGASSERT(sshc->ssh_session == NULL);
+ DEBUGASSERT(sshc->scp_session == NULL);
+
+ if(sshc->readdir_tmp) {
+ ssh_string_free_char(sshc->readdir_tmp);
+ sshc->readdir_tmp = NULL;
+ }
+
+ if(sshc->quote_attrs)
+ sftp_attributes_free(sshc->quote_attrs);
+
+ if(sshc->readdir_attrs)
+ sftp_attributes_free(sshc->readdir_attrs);
+
+ if(sshc->readdir_link_attrs)
+ sftp_attributes_free(sshc->readdir_link_attrs);
+
+ if(sshc->privkey)
+ ssh_key_free(sshc->privkey);
+ if(sshc->pubkey)
+ ssh_key_free(sshc->pubkey);
+
+ Curl_safefree(sshc->rsa_pub);
+ Curl_safefree(sshc->rsa);
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+ Curl_safefree(sshc->readdir_line);
+ Curl_safefree(sshc->readdir_linkPath);
+ SSH_STRING_FREE_CHAR(sshc->homedir);
+
+ /* the code we are about to return */
+ result = sshc->actualcode;
+
+ memset(sshc, 0, sizeof(struct ssh_conn));
+
+ connclose(conn, "SSH session free");
+ sshc->state = SSH_SESSION_FREE; /* current */
+ sshc->nextstate = SSH_NO_STATE;
+ state(conn, SSH_STOP);
+ break;
+
+ case SSH_QUIT:
+ /* fallthrough, just stop! */
+ default:
+ /* internal error */
+ sshc->nextstate = SSH_NO_STATE;
+ state(conn, SSH_STOP);
+ break;
+
+ }
+ } while(!rc && (sshc->state != SSH_STOP));
+
+
+ if(rc == SSH_AGAIN) {
+ /* we would block, we need to wait for the socket to be ready (in the
+ right direction too)! */
+ *block = TRUE;
+ }
+
+ return result;
+}
+
+
+/* called by the multi interface to figure out what socket(s) to wait for and
+ for what actions in the DO_DONE, PERFORM and WAITPERFORM states */
+static int myssh_perform_getsock(const struct connectdata *conn,
+ curl_socket_t *sock, /* points to numsocks
+ number of sockets */
+ int numsocks)
+{
+ int bitmap = GETSOCK_BLANK;
+ (void) numsocks;
+
+ sock[0] = conn->sock[FIRSTSOCKET];
+
+ if(conn->waitfor & KEEP_RECV)
+ bitmap |= GETSOCK_READSOCK(FIRSTSOCKET);
+
+ if(conn->waitfor & KEEP_SEND)
+ bitmap |= GETSOCK_WRITESOCK(FIRSTSOCKET);
+
+ return bitmap;
+}
+
+/* Generic function called by the multi interface to figure out what socket(s)
+ to wait for and for what actions during the DOING and PROTOCONNECT states*/
+static int myssh_getsock(struct connectdata *conn,
+ curl_socket_t *sock, /* points to numsocks
+ number of sockets */
+ int numsocks)
+{
+ /* if we know the direction we can use the generic *_getsock() function even
+ for the protocol_connect and doing states */
+ return myssh_perform_getsock(conn, sock, numsocks);
+}
+
+static void myssh_block2waitfor(struct connectdata *conn, bool block)
+{
+ struct ssh_conn *sshc = &conn->proto.sshc;
+
+ /* If it didn't block, or nothing was returned by ssh_get_poll_flags
+ * have the original set */
+ conn->waitfor = sshc->orig_waitfor;
+
+ if(block) {
+ int dir = ssh_get_poll_flags(sshc->ssh_session);
+ if(dir & SSH_READ_PENDING) {
+ /* translate the libssh define bits into our own bit defines */
+ conn->waitfor = KEEP_RECV;
+ }
+ else if(dir & SSH_WRITE_PENDING) {
+ conn->waitfor = KEEP_SEND;
+ }
+ }
+}
+
+/* called repeatedly until done from multi.c */
+static CURLcode myssh_multi_statemach(struct connectdata *conn,
+ bool *done)
+{
+ struct ssh_conn *sshc = &conn->proto.sshc;
+ CURLcode result = CURLE_OK;
+ bool block; /* we store the status and use that to provide a ssh_getsock()
+ implementation */
+
+ result = myssh_statemach_act(conn, &block);
+ *done = (sshc->state == SSH_STOP) ? TRUE : FALSE;
+ myssh_block2waitfor(conn, block);
+
+ return result;
+}
+
+static CURLcode myssh_block_statemach(struct connectdata *conn,
+ bool disconnect)
+{
+ struct ssh_conn *sshc = &conn->proto.sshc;
+ CURLcode result = CURLE_OK;
+ struct Curl_easy *data = conn->data;
+
+ while((sshc->state != SSH_STOP) && !result) {
+ bool block;
+ timediff_t left = 1000;
+ struct curltime now = Curl_now();
+
+ result = myssh_statemach_act(conn, &block);
+ if(result)
+ break;
+
+ if(!disconnect) {
+ if(Curl_pgrsUpdate(conn))
+ return CURLE_ABORTED_BY_CALLBACK;
+
+ result = Curl_speedcheck(data, now);
+ if(result)
+ break;
+
+ left = Curl_timeleft(data, NULL, FALSE);
+ if(left < 0) {
+ failf(data, "Operation timed out");
+ return CURLE_OPERATION_TIMEDOUT;
+ }
+ }
+
+ if(!result && block) {
+ curl_socket_t fd_read = conn->sock[FIRSTSOCKET];
+ /* wait for the socket to become ready */
+ (void) Curl_socket_check(fd_read, CURL_SOCKET_BAD,
+ CURL_SOCKET_BAD, left > 1000 ? 1000 : left);
+ }
+
+ }
+
+ return result;
+}
+
+/*
+ * SSH setup connection
+ */
+static CURLcode myssh_setup_connection(struct connectdata *conn)
+{
+ struct SSHPROTO *ssh;
+
+ conn->data->req.protop = ssh = calloc(1, sizeof(struct SSHPROTO));
+ if(!ssh)
+ return CURLE_OUT_OF_MEMORY;
+
+ return CURLE_OK;
+}
+
+static Curl_recv scp_recv, sftp_recv;
+static Curl_send scp_send, sftp_send;
+
+/*
+ * Curl_ssh_connect() gets called from Curl_protocol_connect() to allow us to
+ * do protocol-specific actions at connect-time.
+ */
+static CURLcode myssh_connect(struct connectdata *conn, bool *done)
+{
+ struct ssh_conn *ssh;
+ CURLcode result;
+ curl_socket_t sock = conn->sock[FIRSTSOCKET];
+ struct Curl_easy *data = conn->data;
+
+ /* initialize per-handle data if not already */
+ if(!data->req.protop)
+ myssh_setup_connection(conn);
+
+ /* We default to persistent connections. We set this already in this connect
+ function to make the re-use checks properly be able to check this bit. */
+ connkeep(conn, "SSH default");
+
+ if(conn->handler->protocol & CURLPROTO_SCP) {
+ conn->recv[FIRSTSOCKET] = scp_recv;
+ conn->send[FIRSTSOCKET] = scp_send;
+ }
+ else {
+ conn->recv[FIRSTSOCKET] = sftp_recv;
+ conn->send[FIRSTSOCKET] = sftp_send;
+ }
+
+ ssh = &conn->proto.sshc;
+
+ ssh->ssh_session = ssh_new();
+ if(ssh->ssh_session == NULL) {
+ failf(data, "Failure initialising ssh session");
+ return CURLE_FAILED_INIT;
+ }
+
+ ssh_options_set(ssh->ssh_session, SSH_OPTIONS_FD, &sock);
+
+ if(conn->user) {
+ infof(data, "User: %s\n", conn->user);
+ ssh_options_set(ssh->ssh_session, SSH_OPTIONS_USER, conn->user);
+ }
+
+ if(data->set.str[STRING_SSH_KNOWNHOSTS]) {
+ infof(data, "Known hosts: %s\n", data->set.str[STRING_SSH_KNOWNHOSTS]);
+ ssh_options_set(ssh->ssh_session, SSH_OPTIONS_KNOWNHOSTS,
+ data->set.str[STRING_SSH_KNOWNHOSTS]);
+ }
+
+ ssh_options_set(ssh->ssh_session, SSH_OPTIONS_HOST, conn->host.name);
+ if(conn->remote_port)
+ ssh_options_set(ssh->ssh_session, SSH_OPTIONS_PORT,
+ &conn->remote_port);
+
+ if(data->set.ssh_compression) {
+ ssh_options_set(ssh->ssh_session, SSH_OPTIONS_COMPRESSION,
+ "zlib,zlib@openssh.com,none");
+ }
+
+ ssh->privkey = NULL;
+ ssh->pubkey = NULL;
+
+ if(data->set.str[STRING_SSH_PUBLIC_KEY]) {
+ int rc = ssh_pki_import_pubkey_file(data->set.str[STRING_SSH_PUBLIC_KEY],
+ &ssh->pubkey);
+ if(rc != SSH_OK) {
+ failf(data, "Could not load public key file");
+ /* ignore */
+ }
+ }
+
+ /* we do not verify here, we do it at the state machine,
+ * after connection */
+
+ state(conn, SSH_INIT);
+
+ result = myssh_multi_statemach(conn, done);
+
+ return result;
+}
+
+/* called from multi.c while DOing */
+static CURLcode scp_doing(struct connectdata *conn, bool *dophase_done)
+{
+ CURLcode result;
+
+ result = myssh_multi_statemach(conn, dophase_done);
+
+ if(*dophase_done) {
+ DEBUGF(infof(conn->data, "DO phase is complete\n"));
+ }
+ return result;
+}
+
+/*
+ ***********************************************************************
+ *
+ * scp_perform()
+ *
+ * This is the actual DO function for SCP. Get a file according to
+ * the options previously setup.
+ */
+
+static
+CURLcode scp_perform(struct connectdata *conn,
+ bool *connected, bool *dophase_done)
+{
+ CURLcode result = CURLE_OK;
+
+ DEBUGF(infof(conn->data, "DO phase starts\n"));
+
+ *dophase_done = FALSE; /* not done yet */
+
+ /* start the first command in the DO phase */
+ state(conn, SSH_SCP_TRANS_INIT);
+
+ result = myssh_multi_statemach(conn, dophase_done);
+
+ *connected = conn->bits.tcpconnect[FIRSTSOCKET];
+
+ if(*dophase_done) {
+ DEBUGF(infof(conn->data, "DO phase is complete\n"));
+ }
+
+ return result;
+}
+
+static CURLcode myssh_do_it(struct connectdata *conn, bool *done)
+{
+ CURLcode result;
+ bool connected = 0;
+ struct Curl_easy *data = conn->data;
+ struct ssh_conn *sshc = &conn->proto.sshc;
+
+ *done = FALSE; /* default to false */
+
+ data->req.size = -1; /* make sure this is unknown at this point */
+
+ sshc->actualcode = CURLE_OK; /* reset error code */
+ sshc->secondCreateDirs = 0; /* reset the create dir attempt state
+ variable */
+
+ Curl_pgrsSetUploadCounter(data, 0);
+ Curl_pgrsSetDownloadCounter(data, 0);
+ Curl_pgrsSetUploadSize(data, -1);
+ Curl_pgrsSetDownloadSize(data, -1);
+
+ if(conn->handler->protocol & CURLPROTO_SCP)
+ result = scp_perform(conn, &connected, done);
+ else
+ result = sftp_perform(conn, &connected, done);
+
+ return result;
+}
+
+/* BLOCKING, but the function is using the state machine so the only reason
+ this is still blocking is that the multi interface code has no support for
+ disconnecting operations that takes a while */
+static CURLcode scp_disconnect(struct connectdata *conn,
+ bool dead_connection)
+{
+ CURLcode result = CURLE_OK;
+ struct ssh_conn *ssh = &conn->proto.sshc;
+ (void) dead_connection;
+
+ if(ssh->ssh_session) {
+ /* only if there's a session still around to use! */
+
+ state(conn, SSH_SESSION_DISCONNECT);
+
+ result = myssh_block_statemach(conn, TRUE);
+ }
+
+ return result;
+}
+
+/* generic done function for both SCP and SFTP called from their specific
+ done functions */
+static CURLcode myssh_done(struct connectdata *conn, CURLcode status)
+{
+ CURLcode result = CURLE_OK;
+ struct SSHPROTO *protop = conn->data->req.protop;
+
+ if(!status) {
+ /* run the state-machine */
+ result = myssh_block_statemach(conn, FALSE);
+ }
+ else
+ result = status;
+
+ if(protop)
+ Curl_safefree(protop->path);
+ if(Curl_pgrsDone(conn))
+ return CURLE_ABORTED_BY_CALLBACK;
+
+ conn->data->req.keepon = 0; /* clear all bits */
+ return result;
+}
+
+
+static CURLcode scp_done(struct connectdata *conn, CURLcode status,
+ bool premature)
+{
+ (void) premature; /* not used */
+
+ if(!status)
+ state(conn, SSH_SCP_DONE);
+
+ return myssh_done(conn, status);
+
+}
+
+static ssize_t scp_send(struct connectdata *conn, int sockindex,
+ const void *mem, size_t len, CURLcode *err)
+{
+ int rc;
+ (void) sockindex; /* we only support SCP on the fixed known primary socket */
+ (void) err;
+
+ rc = ssh_scp_write(conn->proto.sshc.scp_session, mem, len);
+
+#if 0
+ /* The following code is misleading, mostly added as wishful thinking
+ * that libssh at some point will implement non-blocking ssh_scp_write/read.
+ * Currently rc can only be number of bytes read or SSH_ERROR. */
+ myssh_block2waitfor(conn, (rc == SSH_AGAIN) ? TRUE : FALSE);
+
+ if(rc == SSH_AGAIN) {
+ *err = CURLE_AGAIN;
+ return 0;
+ }
+ else
+#endif
+ if(rc != SSH_OK) {
+ *err = CURLE_SSH;
+ return -1;
+ }
+
+ return len;
+}
+
+static ssize_t scp_recv(struct connectdata *conn, int sockindex,
+ char *mem, size_t len, CURLcode *err)
+{
+ ssize_t nread;
+ (void) err;
+ (void) sockindex; /* we only support SCP on the fixed known primary socket */
+
+ /* libssh returns int */
+ nread = ssh_scp_read(conn->proto.sshc.scp_session, mem, len);
+
+#if 0
+ /* The following code is misleading, mostly added as wishful thinking
+ * that libssh at some point will implement non-blocking ssh_scp_write/read.
+ * Currently rc can only be SSH_OK or SSH_ERROR. */
+
+ myssh_block2waitfor(conn, (nread == SSH_AGAIN) ? TRUE : FALSE);
+ if(nread == SSH_AGAIN) {
+ *err = CURLE_AGAIN;
+ nread = -1;
+ }
+#endif
+
+ return nread;
+}
+
+/*
+ * =============== SFTP ===============
+ */
+
+/*
+ ***********************************************************************
+ *
+ * sftp_perform()
+ *
+ * This is the actual DO function for SFTP. Get a file/directory according to
+ * the options previously setup.
+ */
+
+static
+CURLcode sftp_perform(struct connectdata *conn,
+ bool *connected,
+ bool *dophase_done)
+{
+ CURLcode result = CURLE_OK;
+
+ DEBUGF(infof(conn->data, "DO phase starts\n"));
+
+ *dophase_done = FALSE; /* not done yet */
+
+ /* start the first command in the DO phase */
+ state(conn, SSH_SFTP_QUOTE_INIT);
+
+ /* run the state-machine */
+ result = myssh_multi_statemach(conn, dophase_done);
+
+ *connected = conn->bits.tcpconnect[FIRSTSOCKET];
+
+ if(*dophase_done) {
+ DEBUGF(infof(conn->data, "DO phase is complete\n"));
+ }
+
+ return result;
+}
+
+/* called from multi.c while DOing */
+static CURLcode sftp_doing(struct connectdata *conn,
+ bool *dophase_done)
+{
+ CURLcode result = myssh_multi_statemach(conn, dophase_done);
+ if(*dophase_done) {
+ DEBUGF(infof(conn->data, "DO phase is complete\n"));
+ }
+ return result;
+}
+
+/* BLOCKING, but the function is using the state machine so the only reason
+ this is still blocking is that the multi interface code has no support for
+ disconnecting operations that takes a while */
+static CURLcode sftp_disconnect(struct connectdata *conn, bool dead_connection)
+{
+ CURLcode result = CURLE_OK;
+ (void) dead_connection;
+
+ DEBUGF(infof(conn->data, "SSH DISCONNECT starts now\n"));
+
+ if(conn->proto.sshc.ssh_session) {
+ /* only if there's a session still around to use! */
+ state(conn, SSH_SFTP_SHUTDOWN);
+ result = myssh_block_statemach(conn, TRUE);
+ }
+
+ DEBUGF(infof(conn->data, "SSH DISCONNECT is done\n"));
+
+ return result;
+
+}
+
+static CURLcode sftp_done(struct connectdata *conn, CURLcode status,
+ bool premature)
+{
+ struct ssh_conn *sshc = &conn->proto.sshc;
+
+ if(!status) {
+ /* Post quote commands are executed after the SFTP_CLOSE state to avoid
+ errors that could happen due to open file handles during POSTQUOTE
+ operation */
+ if(!premature && conn->data->set.postquote && !conn->bits.retry)
+ sshc->nextstate = SSH_SFTP_POSTQUOTE_INIT;
+ state(conn, SSH_SFTP_CLOSE);
+ }
+ return myssh_done(conn, status);
+}
+
+/* return number of sent bytes */
+static ssize_t sftp_send(struct connectdata *conn, int sockindex,
+ const void *mem, size_t len, CURLcode *err)
+{
+ ssize_t nwrite;
+ (void)sockindex;
+
+ nwrite = sftp_write(conn->proto.sshc.sftp_file, mem, len);
+
+ myssh_block2waitfor(conn, FALSE);
+
+#if 0 /* not returned by libssh on write */
+ if(nwrite == SSH_AGAIN) {
+ *err = CURLE_AGAIN;
+ nwrite = 0;
+ }
+ else
+#endif
+ if(nwrite < 0) {
+ *err = CURLE_SSH;
+ nwrite = -1;
+ }
+
+ return nwrite;
+}
+
+/*
+ * Return number of received (decrypted) bytes
+ * or <0 on error
+ */
+static ssize_t sftp_recv(struct connectdata *conn, int sockindex,
+ char *mem, size_t len, CURLcode *err)
+{
+ ssize_t nread;
+ (void)sockindex;
+
+ DEBUGASSERT(len < CURL_MAX_READ_SIZE);
+
+ switch(conn->proto.sshc.sftp_recv_state) {
+ case 0:
+ conn->proto.sshc.sftp_file_index =
+ sftp_async_read_begin(conn->proto.sshc.sftp_file,
+ (uint32_t)len);
+ if(conn->proto.sshc.sftp_file_index < 0) {
+ *err = CURLE_RECV_ERROR;
+ return -1;
+ }
+
+ /* FALLTHROUGH */
+ case 1:
+ conn->proto.sshc.sftp_recv_state = 1;
+
+ nread = sftp_async_read(conn->proto.sshc.sftp_file,
+ mem, (uint32_t)len,
+ conn->proto.sshc.sftp_file_index);
+
+ myssh_block2waitfor(conn, (nread == SSH_AGAIN)?TRUE:FALSE);
+
+ if(nread == SSH_AGAIN) {
+ *err = CURLE_AGAIN;
+ return -1;
+ }
+ else if(nread < 0) {
+ *err = CURLE_RECV_ERROR;
+ return -1;
+ }
+
+ conn->proto.sshc.sftp_recv_state = 0;
+ return nread;
+
+ default:
+ /* we never reach here */
+ return -1;
+ }
+}
+
+static void sftp_quote(struct connectdata *conn)
+{
+ const char *cp;
+ struct Curl_easy *data = conn->data;
+ struct SSHPROTO *protop = data->req.protop;
+ struct ssh_conn *sshc = &conn->proto.sshc;
+ CURLcode result;
+
+ /*
+ * Support some of the "FTP" commands
+ */
+ char *cmd = sshc->quote_item->data;
+ sshc->acceptfail = FALSE;
+
+ /* if a command starts with an asterisk, which a legal SFTP command never
+ can, the command will be allowed to fail without it causing any
+ aborts or cancels etc. It will cause libcurl to act as if the command
+ is successful, whatever the server reponds. */
+
+ if(cmd[0] == '*') {
+ cmd++;
+ sshc->acceptfail = TRUE;
+ }
+
+ if(strcasecompare("pwd", cmd)) {
+ /* output debug output if that is requested */
+ char *tmp = aprintf("257 \"%s\" is current directory.\n",
+ protop->path);
+ if(!tmp) {
+ sshc->actualcode = CURLE_OUT_OF_MEMORY;
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ return;
+ }
+ if(data->set.verbose) {
+ Curl_debug(data, CURLINFO_HEADER_OUT, (char *) "PWD\n", 4);
+ Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp));
+ }
+ /* this sends an FTP-like "header" to the header callback so that the
+ current directory can be read very similar to how it is read when
+ using ordinary FTP. */
+ result = Curl_client_write(conn, CLIENTWRITE_HEADER, tmp, strlen(tmp));
+ free(tmp);
+ if(result) {
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = result;
+ }
+ else
+ state(conn, SSH_SFTP_NEXT_QUOTE);
+ return;
+ }
+
+ /*
+ * the arguments following the command must be separated from the
+ * command with a space so we can check for it unconditionally
+ */
+ cp = strchr(cmd, ' ');
+ if(cp == NULL) {
+ failf(data, "Syntax error in SFTP command. Supply parameter(s)!");
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ return;
+ }
+
+ /*
+ * also, every command takes at least one argument so we get that
+ * first argument right now
+ */
+ result = Curl_get_pathname(&cp, &sshc->quote_path1, sshc->homedir);
+ if(result) {
+ if(result == CURLE_OUT_OF_MEMORY)
+ failf(data, "Out of memory");
+ else
+ failf(data, "Syntax error: Bad first parameter");
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = result;
+ return;
+ }
+
+ /*
+ * SFTP is a binary protocol, so we don't send text commands
+ * to the server. Instead, we scan for commands used by
+ * OpenSSH's sftp program and call the appropriate libssh
+ * functions.
+ */
+ if(strncasecompare(cmd, "chgrp ", 6) ||
+ strncasecompare(cmd, "chmod ", 6) ||
+ strncasecompare(cmd, "chown ", 6)) {
+ /* attribute change */
+
+ /* sshc->quote_path1 contains the mode to set */
+ /* get the destination */
+ result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir);
+ if(result) {
+ if(result == CURLE_OUT_OF_MEMORY)
+ failf(data, "Out of memory");
+ else
+ failf(data, "Syntax error in chgrp/chmod/chown: "
+ "Bad second parameter");
+ Curl_safefree(sshc->quote_path1);
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = result;
+ return;
+ }
+ sshc->quote_attrs = NULL;
+ state(conn, SSH_SFTP_QUOTE_STAT);
+ return;
+ }
+ if(strncasecompare(cmd, "ln ", 3) ||
+ strncasecompare(cmd, "symlink ", 8)) {
+ /* symbolic linking */
+ /* sshc->quote_path1 is the source */
+ /* get the destination */
+ result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir);
+ if(result) {
+ if(result == CURLE_OUT_OF_MEMORY)
+ failf(data, "Out of memory");
+ else
+ failf(data, "Syntax error in ln/symlink: Bad second parameter");
+ Curl_safefree(sshc->quote_path1);
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = result;
+ return;
+ }
+ state(conn, SSH_SFTP_QUOTE_SYMLINK);
+ return;
+ }
+ else if(strncasecompare(cmd, "mkdir ", 6)) {
+ /* create dir */
+ state(conn, SSH_SFTP_QUOTE_MKDIR);
+ return;
+ }
+ else if(strncasecompare(cmd, "rename ", 7)) {
+ /* rename file */
+ /* first param is the source path */
+ /* second param is the dest. path */
+ result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir);
+ if(result) {
+ if(result == CURLE_OUT_OF_MEMORY)
+ failf(data, "Out of memory");
+ else
+ failf(data, "Syntax error in rename: Bad second parameter");
+ Curl_safefree(sshc->quote_path1);
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = result;
+ return;
+ }
+ state(conn, SSH_SFTP_QUOTE_RENAME);
+ return;
+ }
+ else if(strncasecompare(cmd, "rmdir ", 6)) {
+ /* delete dir */
+ state(conn, SSH_SFTP_QUOTE_RMDIR);
+ return;
+ }
+ else if(strncasecompare(cmd, "rm ", 3)) {
+ state(conn, SSH_SFTP_QUOTE_UNLINK);
+ return;
+ }
+#ifdef HAS_STATVFS_SUPPORT
+ else if(strncasecompare(cmd, "statvfs ", 8)) {
+ state(conn, SSH_SFTP_QUOTE_STATVFS);
+ return;
+ }
+#endif
+
+ failf(data, "Unknown SFTP command");
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+}
+
+static void sftp_quote_stat(struct connectdata *conn)
+{
+ struct Curl_easy *data = conn->data;
+ struct ssh_conn *sshc = &conn->proto.sshc;
+ char *cmd = sshc->quote_item->data;
+ sshc->acceptfail = FALSE;
+
+ /* if a command starts with an asterisk, which a legal SFTP command never
+ can, the command will be allowed to fail without it causing any
+ aborts or cancels etc. It will cause libcurl to act as if the command
+ is successful, whatever the server reponds. */
+
+ if(cmd[0] == '*') {
+ cmd++;
+ sshc->acceptfail = TRUE;
+ }
+
+ /* We read the file attributes, store them in sshc->quote_attrs
+ * and modify them accordingly to command. Then we switch to
+ * QUOTE_SETSTAT state to write new ones.
+ */
+
+ if(sshc->quote_attrs)
+ sftp_attributes_free(sshc->quote_attrs);
+ sshc->quote_attrs = sftp_stat(sshc->sftp_session, sshc->quote_path2);
+ if(sshc->quote_attrs == NULL) {
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+ failf(data, "Attempt to get SFTP stats failed: %d",
+ sftp_get_error(sshc->sftp_session));
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ return;
+ }
+
+ /* Now set the new attributes... */
+ if(strncasecompare(cmd, "chgrp", 5)) {
+ sshc->quote_attrs->gid = (uint32_t)strtoul(sshc->quote_path1, NULL, 10);
+ if(sshc->quote_attrs->gid == 0 && !ISDIGIT(sshc->quote_path1[0]) &&
+ !sshc->acceptfail) {
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+ failf(data, "Syntax error: chgrp gid not a number");
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ return;
+ }
+ sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_UIDGID;
+ }
+ else if(strncasecompare(cmd, "chmod", 5)) {
+ mode_t perms;
+ perms = (mode_t)strtoul(sshc->quote_path1, NULL, 8);
+ /* permissions are octal */
+ if(perms == 0 && !ISDIGIT(sshc->quote_path1[0])) {
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+ failf(data, "Syntax error: chmod permissions not a number");
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ return;
+ }
+ sshc->quote_attrs->permissions = perms;
+ sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_PERMISSIONS;
+ }
+ else if(strncasecompare(cmd, "chown", 5)) {
+ sshc->quote_attrs->uid = (uint32_t)strtoul(sshc->quote_path1, NULL, 10);
+ if(sshc->quote_attrs->uid == 0 && !ISDIGIT(sshc->quote_path1[0]) &&
+ !sshc->acceptfail) {
+ Curl_safefree(sshc->quote_path1);
+ Curl_safefree(sshc->quote_path2);
+ failf(data, "Syntax error: chown uid not a number");
+ state(conn, SSH_SFTP_CLOSE);
+ sshc->nextstate = SSH_NO_STATE;
+ sshc->actualcode = CURLE_QUOTE_ERROR;
+ return;
+ }
+ sshc->quote_attrs->flags |= SSH_FILEXFER_ATTR_UIDGID;
+ }
+
+ /* Now send the completed structure... */
+ state(conn, SSH_SFTP_QUOTE_SETSTAT);
+ return;
+}
+
+
+#endif /* USE_LIBSSH */
diff --git a/Utilities/cmcurl/lib/ssh.c b/Utilities/cmcurl/lib/ssh.c
index 00aeca978..a265c3c9a 100644
--- a/Utilities/cmcurl/lib/ssh.c
+++ b/Utilities/cmcurl/lib/ssh.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -26,9 +26,7 @@
#ifdef USE_LIBSSH2
-#ifdef HAVE_LIMITS_H
-# include <limits.h>
-#endif
+#include <limits.h>
#include <libssh2.h>
#include <libssh2_sftp.h>
@@ -83,25 +81,13 @@
#include "multiif.h"
#include "select.h"
#include "warnless.h"
+#include "curl_path.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"
-#ifdef WIN32
-# undef PATH_MAX
-# define PATH_MAX MAX_PATH
-# ifndef R_OK
-# define R_OK 4
-# endif
-#endif
-
-#ifndef PATH_MAX
-#define PATH_MAX 1024 /* just an extra precaution since there are systems that
- have their definition hidden well */
-#endif
-
#if LIBSSH2_VERSION_NUM >= 0x010206
/* libssh2_sftp_statvfs and friends were added in 1.2.6 */
#define HAS_STATVFS_SUPPORT 1
@@ -120,16 +106,10 @@ static LIBSSH2_ALLOC_FUNC(my_libssh2_malloc);
static LIBSSH2_REALLOC_FUNC(my_libssh2_realloc);
static LIBSSH2_FREE_FUNC(my_libssh2_free);
-static CURLcode get_pathname(const char **cpp, char **path);
-
static CURLcode ssh_connect(struct connectdata *conn, bool *done);
static CURLcode ssh_multi_statemach(struct connectdata *conn, bool *done);
static CURLcode ssh_do(struct connectdata *conn, bool *done);
-static CURLcode ssh_getworkingpath(struct connectdata *conn,
- char *homedir, /* when SFTP is used */
- char **path);
-
static CURLcode scp_done(struct connectdata *conn,
CURLcode, bool premature);
static CURLcode scp_doing(struct connectdata *conn,
@@ -177,6 +157,7 @@ const struct Curl_handler Curl_handler_scp = {
ssh_perform_getsock, /* perform_getsock */
scp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_SSH, /* defport */
CURLPROTO_SCP, /* protocol */
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION
@@ -203,6 +184,7 @@ const struct Curl_handler Curl_handler_sftp = {
ssh_perform_getsock, /* perform_getsock */
sftp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_SSH, /* defport */
CURLPROTO_SFTP, /* protocol */
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION
@@ -277,6 +259,11 @@ static CURLcode libssh2_session_error_to_CURLE(int err)
case LIBSSH2_ERROR_NONE:
return CURLE_OK;
+ /* This is the error returned by libssh2_scp_recv2
+ * on unknown file */
+ case LIBSSH2_ERROR_SCP_PROTOCOL:
+ return CURLE_REMOTE_FILE_NOT_FOUND;
+
case LIBSSH2_ERROR_SOCKET_NONE:
return CURLE_COULDNT_CONNECT;
@@ -303,10 +290,6 @@ static CURLcode libssh2_session_error_to_CURLE(int err)
return CURLE_AGAIN;
}
- /* TODO: map some more of the libssh2 errors to the more appropriate CURLcode
- error code, and possibly add a few new SSH-related one. We must however
- not return or even depend on libssh2 errors in the public libcurl API */
-
return CURLE_SSH;
}
@@ -355,6 +338,7 @@ static void state(struct connectdata *conn, sshstate nowstate)
"SSH_AUTH_HOST",
"SSH_AUTH_KEY_INIT",
"SSH_AUTH_KEY",
+ "SSH_AUTH_GSSAPI",
"SSH_AUTH_DONE",
"SSH_SFTP_INIT",
"SSH_SFTP_REALPATH",
@@ -389,6 +373,7 @@ static void state(struct connectdata *conn, sshstate nowstate)
"SSH_SCP_TRANS_INIT",
"SSH_SCP_UPLOAD_INIT",
"SSH_SCP_DOWNLOAD_INIT",
+ "SSH_SCP_DOWNLOAD",
"SSH_SCP_DONE",
"SSH_SCP_SEND_EOF",
"SSH_SCP_WAIT_EOF",
@@ -399,6 +384,9 @@ static void state(struct connectdata *conn, sshstate nowstate)
"QUIT"
};
+ /* a precaution to make sure the lists are in sync */
+ DEBUGASSERT(sizeof(names)/sizeof(names[0]) == SSH_LAST);
+
if(sshc->state != nowstate) {
infof(conn->data, "SFTP %p state change from %s to %s\n",
(void *)sshc, names[sshc->state], names[nowstate]);
@@ -408,70 +396,6 @@ static void state(struct connectdata *conn, sshstate nowstate)
sshc->state = nowstate;
}
-/* figure out the path to work with in this particular request */
-static CURLcode ssh_getworkingpath(struct connectdata *conn,
- char *homedir, /* when SFTP is used */
- char **path) /* returns the allocated
- real path to work with */
-{
- struct Curl_easy *data = conn->data;
- char *real_path = NULL;
- char *working_path;
- size_t working_path_len;
- CURLcode result =
- Curl_urldecode(data, data->state.path, 0, &working_path,
- &working_path_len, FALSE);
- if(result)
- return result;
-
- /* Check for /~/, indicating relative to the user's home directory */
- if(conn->handler->protocol & CURLPROTO_SCP) {
- real_path = malloc(working_path_len+1);
- if(real_path == NULL) {
- free(working_path);
- return CURLE_OUT_OF_MEMORY;
- }
- if((working_path_len > 3) && (!memcmp(working_path, "/~/", 3)))
- /* It is referenced to the home directory, so strip the leading '/~/' */
- memcpy(real_path, working_path+3, 4 + working_path_len-3);
- else
- memcpy(real_path, working_path, 1 + working_path_len);
- }
- else if(conn->handler->protocol & CURLPROTO_SFTP) {
- if((working_path_len > 1) && (working_path[1] == '~')) {
- size_t homelen = strlen(homedir);
- real_path = malloc(homelen + working_path_len + 1);
- if(real_path == NULL) {
- free(working_path);
- return CURLE_OUT_OF_MEMORY;
- }
- /* It is referenced to the home directory, so strip the
- leading '/' */
- memcpy(real_path, homedir, homelen);
- real_path[homelen] = '/';
- real_path[homelen+1] = '\0';
- if(working_path_len > 3) {
- memcpy(real_path+homelen+1, working_path + 3,
- 1 + working_path_len -3);
- }
- }
- else {
- real_path = malloc(working_path_len+1);
- if(real_path == NULL) {
- free(working_path);
- return CURLE_OUT_OF_MEMORY;
- }
- memcpy(real_path, working_path, 1+working_path_len);
- }
- }
-
- free(working_path);
-
- /* store the pointer for the caller to receive */
- *path = real_path;
-
- return CURLE_OK;
-}
#ifdef HAVE_LIBSSH2_KNOWNHOST_API
static int sshkeycallback(struct Curl_easy *easy,
@@ -600,9 +524,11 @@ static CURLcode ssh_knownhost(struct connectdata *conn)
keymatch = (enum curl_khmatch)keycheck;
/* Ask the callback how to behave */
+ Curl_set_in_callback(data, true);
rc = func(data, knownkeyp, /* from the knownhosts file */
&foundkey, /* from the remote host */
keymatch, data->set.ssh_keyfunc_userp);
+ Curl_set_in_callback(data, false);
}
else
/* no remotekey means failure! */
@@ -661,15 +587,15 @@ static CURLcode ssh_check_fingerprint(struct connectdata *conn)
struct Curl_easy *data = conn->data;
const char *pubkey_md5 = data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5];
char md5buffer[33];
- int i;
const char *fingerprint = libssh2_hostkey_hash(sshc->ssh_session,
LIBSSH2_HOSTKEY_HASH_MD5);
if(fingerprint) {
/* The fingerprint points to static storage (!), don't free() it. */
+ int i;
for(i = 0; i < 16; i++)
- snprintf(&md5buffer[i*2], 3, "%02x", (unsigned char) fingerprint[i]);
+ msnprintf(&md5buffer[i*2], 3, "%02x", (unsigned char) fingerprint[i]);
infof(data, "SSH MD5 fingerprint: %s\n", md5buffer);
}
@@ -729,7 +655,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
libssh2_session_set_blocking(sshc->ssh_session, 0);
state(conn, SSH_S_STARTUP);
- /* fall-through */
+ /* FALLTHROUGH */
case SSH_S_STARTUP:
rc = libssh2_session_startup(sshc->ssh_session, (int)sock);
@@ -737,7 +663,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc) {
- failf(data, "Failure establishing ssh session");
+ char *err_msg = NULL;
+ (void)libssh2_session_last_error(sshc->ssh_session, &err_msg, NULL, 0);
+ failf(data, "Failure establishing ssh session: %d, %s", rc, err_msg);
+
state(conn, SSH_SESSION_FREE);
sshc->actualcode = CURLE_FAILED_INIT;
break;
@@ -745,7 +674,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
state(conn, SSH_HOSTKEY);
- /* fall-through */
+ /* FALLTHROUGH */
case SSH_HOSTKEY:
/*
* Before we authenticate we should check the hostkey's fingerprint
@@ -804,18 +733,17 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
if((data->set.ssh_auth_types & CURLSSH_AUTH_PUBLICKEY) &&
(strstr(sshc->authlist, "publickey") != NULL)) {
- char *home = NULL;
bool out_of_memory = FALSE;
sshc->rsa_pub = sshc->rsa = NULL;
- /* To ponder about: should really the lib be messing about with the
- HOME environment variable etc? */
- home = curl_getenv("HOME");
-
if(data->set.str[STRING_SSH_PRIVATE_KEY])
sshc->rsa = strdup(data->set.str[STRING_SSH_PRIVATE_KEY]);
else {
+ /* To ponder about: should really the lib be messing about with the
+ HOME environment variable etc? */
+ char *home = curl_getenv("HOME");
+
/* If no private key file is specified, try some common paths. */
if(home) {
/* Try ~/.ssh first. */
@@ -831,6 +759,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
Curl_safefree(sshc->rsa);
}
}
+ free(home);
}
if(!out_of_memory && !sshc->rsa) {
/* Nothing found; try the current dir. */
@@ -854,15 +783,14 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
* This is done by simply passing sshc->rsa_pub = NULL.
*/
if(data->set.str[STRING_SSH_PUBLIC_KEY]
- /* treat empty string the same way as NULL */
- && data->set.str[STRING_SSH_PUBLIC_KEY][0]) {
+ /* treat empty string the same way as NULL */
+ && data->set.str[STRING_SSH_PUBLIC_KEY][0]) {
sshc->rsa_pub = strdup(data->set.str[STRING_SSH_PUBLIC_KEY]);
if(!sshc->rsa_pub)
out_of_memory = TRUE;
}
if(out_of_memory || sshc->rsa == NULL) {
- free(home);
Curl_safefree(sshc->rsa);
Curl_safefree(sshc->rsa_pub);
state(conn, SSH_SESSION_FREE);
@@ -874,8 +802,6 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
if(!sshc->passphrase)
sshc->passphrase = "";
- free(home);
-
if(sshc->rsa_pub)
infof(data, "Using SSH public key file '%s'\n", sshc->rsa_pub);
infof(data, "Using SSH private key file '%s'\n", sshc->rsa);
@@ -909,7 +835,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
state(conn, SSH_AUTH_DONE);
}
else {
- char *err_msg;
+ char *err_msg = NULL;
(void)libssh2_session_last_error(sshc->ssh_session,
&err_msg, NULL, 0);
infof(data, "SSH public key authentication failed: %s\n", err_msg);
@@ -1032,11 +958,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
sshc->sshagent_identity);
if(rc < 0) {
- if(rc != LIBSSH2_ERROR_EAGAIN)
+ if(rc != LIBSSH2_ERROR_EAGAIN) {
/* tried and failed? go to next identity */
sshc->sshagent_prev_identity = sshc->sshagent_identity;
- else
- break;
+ }
+ break;
}
}
@@ -1116,7 +1042,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
*/
sshc->sftp_session = libssh2_sftp_init(sshc->ssh_session);
if(!sshc->sftp_session) {
- char *err_msg;
+ char *err_msg = NULL;
if(libssh2_session_last_errno(sshc->ssh_session) ==
LIBSSH2_ERROR_EAGAIN) {
rc = LIBSSH2_ERROR_EAGAIN;
@@ -1182,7 +1108,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
case SSH_SFTP_QUOTE_INIT:
- result = ssh_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
+ result = Curl_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
if(result) {
sshc->actualcode = result;
state(conn, SSH_STOP);
@@ -1217,6 +1143,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
/*
* Support some of the "FTP" commands
+ *
+ * 'sshc->quote_item' is already verified to be non-NULL before it
+ * switched to this state.
*/
char *cmd = sshc->quote_item->data;
sshc->acceptfail = FALSE;
@@ -1242,8 +1171,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(data->set.verbose) {
- Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"PWD\n", 4, conn);
- Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp), conn);
+ Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"PWD\n", 4);
+ Curl_debug(data, CURLINFO_HEADER_IN, tmp, strlen(tmp));
}
/* this sends an FTP-like "header" to the header callback so that the
current directory can be read very similar to how it is read when
@@ -1259,7 +1188,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
state(conn, SSH_SFTP_NEXT_QUOTE);
break;
}
- if(cmd) {
+ {
/*
* the arguments following the command must be separated from the
* command with a space so we can check for it unconditionally
@@ -1277,7 +1206,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
* also, every command takes at least one argument so we get that
* first argument right now
*/
- result = get_pathname(&cp, &sshc->quote_path1);
+ result = Curl_get_pathname(&cp, &sshc->quote_path1, sshc->homedir);
if(result) {
if(result == CURLE_OUT_OF_MEMORY)
failf(data, "Out of memory");
@@ -1302,7 +1231,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
/* sshc->quote_path1 contains the mode to set */
/* get the destination */
- result = get_pathname(&cp, &sshc->quote_path2);
+ result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir);
if(result) {
if(result == CURLE_OUT_OF_MEMORY)
failf(data, "Out of memory");
@@ -1320,11 +1249,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(strncasecompare(cmd, "ln ", 3) ||
- strncasecompare(cmd, "symlink ", 8)) {
+ strncasecompare(cmd, "symlink ", 8)) {
/* symbolic linking */
/* sshc->quote_path1 is the source */
/* get the destination */
- result = get_pathname(&cp, &sshc->quote_path2);
+ result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir);
if(result) {
if(result == CURLE_OUT_OF_MEMORY)
failf(data, "Out of memory");
@@ -1349,7 +1278,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
/* rename file */
/* first param is the source path */
/* second param is the dest. path */
- result = get_pathname(&cp, &sshc->quote_path2);
+ result = Curl_get_pathname(&cp, &sshc->quote_path2, sshc->homedir);
if(result) {
if(result == CURLE_OUT_OF_MEMORY)
failf(data, "Out of memory");
@@ -1389,9 +1318,6 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
}
- if(!sshc->quote_item) {
- state(conn, SSH_SFTP_GETINFO);
- }
break;
case SSH_SFTP_NEXT_QUOTE:
@@ -1704,7 +1630,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc == 0) {
- data->info.filetime = (long)attrs.mtime;
+ data->info.filetime = attrs.mtime;
}
state(conn, SSH_SFTP_TRANS_INIT);
@@ -1811,7 +1737,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
zero even though libssh2_sftp_open() failed previously! We need
to work around that! */
sshc->actualcode = CURLE_SSH;
- err=-1;
+ err = -1;
}
failf(data, "Upload failed: %s (%d/%d)",
err>= LIBSSH2_FX_OK?sftp_libssh2_strerror(err):"ssh error",
@@ -1824,12 +1750,14 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
if(data->state.resume_from > 0) {
/* Let's read off the proper amount of bytes from the input. */
if(conn->seek_func) {
+ Curl_set_in_callback(data, true);
seekerr = conn->seek_func(conn->seek_client, data->state.resume_from,
SEEK_SET);
+ Curl_set_in_callback(data, false);
}
if(seekerr != CURL_SEEKFUNC_OK) {
- curl_off_t passed=0;
+ curl_off_t passed = 0;
if(seekerr != CURL_SEEKFUNC_CANTSEEK) {
failf(data, "Could not seek stream");
@@ -1842,9 +1770,12 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
(size_t)data->set.buffer_size :
curlx_sotouz(data->state.resume_from - passed);
- size_t actuallyread =
- data->state.fread_func(data->state.buffer, 1,
- readthisamountnow, data->state.in);
+ size_t actuallyread;
+ Curl_set_in_callback(data, true);
+ actuallyread = data->state.fread_func(data->state.buffer, 1,
+ readthisamountnow,
+ data->state.in);
+ Curl_set_in_callback(data, false);
passed += actuallyread;
if((actuallyread == 0) || (actuallyread > readthisamountnow)) {
@@ -1870,7 +1801,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
Curl_pgrsSetUploadSize(data, data->state.infilesize);
}
/* upload data */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, FIRSTSOCKET, NULL);
+ Curl_setup_transfer(data, -1, -1, FALSE, FIRSTSOCKET);
/* not set by Curl_setup_transfer to preserve keepon bits */
conn->sockfd = conn->writesockfd;
@@ -1981,13 +1912,13 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
sshc->actualcode = result?result:CURLE_SSH;
break;
}
- sshc->readdir_filename = malloc(PATH_MAX+1);
+ sshc->readdir_filename = malloc(PATH_MAX + 1);
if(!sshc->readdir_filename) {
state(conn, SSH_SFTP_CLOSE);
sshc->actualcode = CURLE_OUT_OF_MEMORY;
break;
}
- sshc->readdir_longentry = malloc(PATH_MAX+1);
+ sshc->readdir_longentry = malloc(PATH_MAX + 1);
if(!sshc->readdir_longentry) {
Curl_safefree(sshc->readdir_filename);
state(conn, SSH_SFTP_CLOSE);
@@ -1998,17 +1929,17 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
case SSH_SFTP_READDIR:
- sshc->readdir_len = libssh2_sftp_readdir_ex(sshc->sftp_handle,
- sshc->readdir_filename,
- PATH_MAX,
- sshc->readdir_longentry,
- PATH_MAX,
- &sshc->readdir_attrs);
- if(sshc->readdir_len == LIBSSH2_ERROR_EAGAIN) {
- rc = LIBSSH2_ERROR_EAGAIN;
+ rc = libssh2_sftp_readdir_ex(sshc->sftp_handle,
+ sshc->readdir_filename,
+ PATH_MAX,
+ sshc->readdir_longentry,
+ PATH_MAX,
+ &sshc->readdir_attrs);
+ if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
}
- if(sshc->readdir_len > 0) {
+ if(rc > 0) {
+ sshc->readdir_len = (size_t) rc;
sshc->readdir_filename[sshc->readdir_len] = '\0';
if(data->set.ftp_list_only) {
@@ -2021,7 +1952,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
result = Curl_client_write(conn, CLIENTWRITE_BODY,
- tmpLine, sshc->readdir_len+1);
+ tmpLine, sshc->readdir_len + 1);
free(tmpLine);
if(result) {
@@ -2030,16 +1961,16 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
}
/* since this counts what we send to the client, we include the
newline in this counter */
- data->req.bytecount += sshc->readdir_len+1;
+ data->req.bytecount += sshc->readdir_len + 1;
/* output debug output if that is requested */
if(data->set.verbose) {
Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_filename,
- sshc->readdir_len, conn);
+ sshc->readdir_len);
}
}
else {
- sshc->readdir_currLen = (int)strlen(sshc->readdir_longentry);
+ sshc->readdir_currLen = strlen(sshc->readdir_longentry);
sshc->readdir_totalLen = 80 + sshc->readdir_currLen;
sshc->readdir_line = calloc(sshc->readdir_totalLen, 1);
if(!sshc->readdir_line) {
@@ -2064,8 +1995,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
- snprintf(sshc->readdir_linkPath, PATH_MAX, "%s%s", sftp_scp->path,
- sshc->readdir_filename);
+ msnprintf(sshc->readdir_linkPath, PATH_MAX, "%s%s", sftp_scp->path,
+ sshc->readdir_filename);
state(conn, SSH_SFTP_READDIR_LINK);
break;
}
@@ -2073,13 +2004,13 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
}
- else if(sshc->readdir_len == 0) {
+ else if(rc == 0) {
Curl_safefree(sshc->readdir_filename);
Curl_safefree(sshc->readdir_longentry);
state(conn, SSH_SFTP_READDIR_DONE);
break;
}
- else if(sshc->readdir_len <= 0) {
+ else if(rc < 0) {
err = sftp_libssh2_last_error(sshc->sftp_session);
result = sftp_libssh2_error_to_CURLE(err);
sshc->actualcode = result?result:CURLE_SSH;
@@ -2094,16 +2025,16 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
case SSH_SFTP_READDIR_LINK:
- sshc->readdir_len =
+ rc =
libssh2_sftp_symlink_ex(sshc->sftp_session,
sshc->readdir_linkPath,
curlx_uztoui(strlen(sshc->readdir_linkPath)),
sshc->readdir_filename,
PATH_MAX, LIBSSH2_SFTP_READLINK);
- if(sshc->readdir_len == LIBSSH2_ERROR_EAGAIN) {
- rc = LIBSSH2_ERROR_EAGAIN;
+ if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
}
+ sshc->readdir_len = (size_t) rc;
Curl_safefree(sshc->readdir_linkPath);
/* get room for the filename and extra output */
@@ -2120,21 +2051,21 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
}
sshc->readdir_line = new_readdir_line;
- sshc->readdir_currLen += snprintf(sshc->readdir_line +
- sshc->readdir_currLen,
- sshc->readdir_totalLen -
- sshc->readdir_currLen,
- " -> %s",
- sshc->readdir_filename);
+ sshc->readdir_currLen += msnprintf(sshc->readdir_line +
+ sshc->readdir_currLen,
+ sshc->readdir_totalLen -
+ sshc->readdir_currLen,
+ " -> %s",
+ sshc->readdir_filename);
state(conn, SSH_SFTP_READDIR_BOTTOM);
break;
case SSH_SFTP_READDIR_BOTTOM:
- sshc->readdir_currLen += snprintf(sshc->readdir_line +
- sshc->readdir_currLen,
- sshc->readdir_totalLen -
- sshc->readdir_currLen, "\n");
+ sshc->readdir_currLen += msnprintf(sshc->readdir_line +
+ sshc->readdir_currLen,
+ sshc->readdir_totalLen -
+ sshc->readdir_currLen, "\n");
result = Curl_client_write(conn, CLIENTWRITE_BODY,
sshc->readdir_line,
sshc->readdir_currLen);
@@ -2144,7 +2075,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
/* output debug output if that is requested */
if(data->set.verbose) {
Curl_debug(data, CURLINFO_DATA_OUT, sshc->readdir_line,
- sshc->readdir_currLen, conn);
+ sshc->readdir_currLen);
}
data->req.bytecount += sshc->readdir_currLen;
}
@@ -2167,7 +2098,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
Curl_safefree(sshc->readdir_longentry);
/* no data to transfer */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
state(conn, SSH_STOP);
break;
@@ -2208,8 +2139,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc ||
- !(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) ||
- (attrs.filesize == 0)) {
+ !(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) ||
+ (attrs.filesize == 0)) {
/*
* libssh2_sftp_open() didn't return an error, so maybe the server
* just doesn't support stat()
@@ -2231,18 +2162,25 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
curl_off_t from, to;
char *ptr;
char *ptr2;
+ CURLofft to_t;
+ CURLofft from_t;
- from=curlx_strtoofft(conn->data->state.range, &ptr, 0);
- while(*ptr && (ISSPACE(*ptr) || (*ptr=='-')))
+ from_t = curlx_strtoofft(conn->data->state.range, &ptr, 0, &from);
+ if(from_t == CURL_OFFT_FLOW)
+ return CURLE_RANGE_ERROR;
+ while(*ptr && (ISSPACE(*ptr) || (*ptr == '-')))
ptr++;
- to=curlx_strtoofft(ptr, &ptr2, 0);
- if((ptr == ptr2) /* no "to" value given */
+ to_t = curlx_strtoofft(ptr, &ptr2, 0, &to);
+ if(to_t == CURL_OFFT_FLOW)
+ return CURLE_RANGE_ERROR;
+ if((to_t == CURL_OFFT_INVAL) /* no "to" value given */
|| (to >= size)) {
to = size - 1;
}
- if(from < 0) {
+ if(from_t) {
/* from is relative to end of file */
- from += size;
+ from = size - to;
+ to = size - 1;
}
if(from > size) {
failf(data, "Offset (%"
@@ -2300,13 +2238,12 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
/* Setup the actual download */
if(data->req.size == 0) {
/* no data to transfer */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
infof(data, "File already completely downloaded\n");
state(conn, SSH_STOP);
break;
}
- Curl_setup_transfer(conn, FIRSTSOCKET, data->req.size,
- FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, FIRSTSOCKET, data->req.size, FALSE, -1);
/* not set by Curl_setup_transfer to preserve keepon bits */
conn->writesockfd = conn->sockfd;
@@ -2334,12 +2271,15 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc < 0) {
- infof(data, "Failed to close libssh2 file\n");
+ char *err_msg = NULL;
+ (void)libssh2_session_last_error(sshc->ssh_session,
+ &err_msg, NULL, 0);
+ infof(data, "Failed to close libssh2 file: %d %s\n", rc, err_msg);
}
sshc->sftp_handle = NULL;
}
- if(sftp_scp)
- Curl_safefree(sftp_scp->path);
+
+ Curl_safefree(sftp_scp->path);
DEBUGF(infof(data, "SFTP DONE done\n"));
@@ -2368,7 +2308,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc < 0) {
- infof(data, "Failed to close libssh2 file\n");
+ char *err_msg = NULL;
+ (void)libssh2_session_last_error(sshc->ssh_session, &err_msg,
+ NULL, 0);
+ infof(data, "Failed to close libssh2 file: %d %s\n", rc, err_msg);
}
sshc->sftp_handle = NULL;
}
@@ -2390,7 +2333,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
case SSH_SCP_TRANS_INIT:
- result = ssh_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
+ result = Curl_getworkingpath(conn, sshc->homedir, &sftp_scp->path);
if(result) {
sshc->actualcode = result;
state(conn, SSH_STOP);
@@ -2423,7 +2366,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
data->state.infilesize);
if(!sshc->ssh_channel) {
int ssh_err;
- char *err_msg;
+ char *err_msg = NULL;
if(libssh2_session_last_errno(sshc->ssh_session) ==
LIBSSH2_ERROR_EAGAIN) {
@@ -2436,12 +2379,15 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
failf(conn->data, "%s", err_msg);
state(conn, SSH_SCP_CHANNEL_FREE);
sshc->actualcode = libssh2_session_error_to_CURLE(ssh_err);
+ /* Map generic errors to upload failed */
+ if(sshc->actualcode == CURLE_SSH ||
+ sshc->actualcode == CURLE_REMOTE_FILE_NOT_FOUND)
+ sshc->actualcode = CURLE_UPLOAD_FAILED;
break;
}
/* upload data */
- Curl_setup_transfer(conn, -1, data->req.size, FALSE, NULL,
- FIRSTSOCKET, NULL);
+ Curl_setup_transfer(data, -1, data->req.size, FALSE, FIRSTSOCKET);
/* not set by Curl_setup_transfer to preserve keepon bits */
conn->sockfd = conn->writesockfd;
@@ -2473,9 +2419,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
* be set in sb
*/
- /*
- * If support for >2GB files exists, use it.
- */
+ /*
+ * If support for >2GB files exists, use it.
+ */
/* get a fresh new channel from the ssh layer */
#if LIBSSH2_VERSION_NUM < 0x010700
@@ -2492,7 +2438,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
if(!sshc->ssh_channel) {
int ssh_err;
- char *err_msg;
+ char *err_msg = NULL;
if(libssh2_session_last_errno(sshc->ssh_session) ==
LIBSSH2_ERROR_EAGAIN) {
@@ -2512,7 +2458,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
/* download data */
bytecount = (curl_off_t)sb.st_size;
data->req.maxdownload = (curl_off_t)sb.st_size;
- Curl_setup_transfer(conn, FIRSTSOCKET, bytecount, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, FIRSTSOCKET, bytecount, FALSE, -1);
/* not set by Curl_setup_transfer to preserve keepon bits */
conn->writesockfd = conn->sockfd;
@@ -2545,7 +2491,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc) {
- infof(data, "Failed to send libssh2 channel EOF\n");
+ char *err_msg = NULL;
+ (void)libssh2_session_last_error(sshc->ssh_session,
+ &err_msg, NULL, 0);
+ infof(data, "Failed to send libssh2 channel EOF: %d %s\n",
+ rc, err_msg);
}
}
state(conn, SSH_SCP_WAIT_EOF);
@@ -2558,7 +2508,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc) {
- infof(data, "Failed to get channel EOF: %d\n", rc);
+ char *err_msg = NULL;
+ (void)libssh2_session_last_error(sshc->ssh_session,
+ &err_msg, NULL, 0);
+ infof(data, "Failed to get channel EOF: %d %s\n", rc, err_msg);
}
}
state(conn, SSH_SCP_WAIT_CLOSE);
@@ -2571,7 +2524,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc) {
- infof(data, "Channel failed to close: %d\n", rc);
+ char *err_msg = NULL;
+ (void)libssh2_session_last_error(sshc->ssh_session,
+ &err_msg, NULL, 0);
+ infof(data, "Channel failed to close: %d %s\n", rc, err_msg);
}
}
state(conn, SSH_SCP_CHANNEL_FREE);
@@ -2584,7 +2540,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc < 0) {
- infof(data, "Failed to free libssh2 scp subsystem\n");
+ char *err_msg = NULL;
+ (void)libssh2_session_last_error(sshc->ssh_session,
+ &err_msg, NULL, 0);
+ infof(data, "Failed to free libssh2 scp subsystem: %d %s\n",
+ rc, err_msg);
}
sshc->ssh_channel = NULL;
}
@@ -2606,7 +2566,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc < 0) {
- infof(data, "Failed to free libssh2 scp subsystem\n");
+ char *err_msg = NULL;
+ (void)libssh2_session_last_error(sshc->ssh_session,
+ &err_msg, NULL, 0);
+ infof(data, "Failed to free libssh2 scp subsystem: %d %s\n",
+ rc, err_msg);
}
sshc->ssh_channel = NULL;
}
@@ -2617,7 +2581,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc < 0) {
- infof(data, "Failed to disconnect libssh2 session\n");
+ char *err_msg = NULL;
+ (void)libssh2_session_last_error(sshc->ssh_session,
+ &err_msg, NULL, 0);
+ infof(data, "Failed to disconnect libssh2 session: %d %s\n",
+ rc, err_msg);
}
}
@@ -2642,7 +2610,11 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc < 0) {
- infof(data, "Failed to disconnect from libssh2 agent\n");
+ char *err_msg = NULL;
+ (void)libssh2_session_last_error(sshc->ssh_session,
+ &err_msg, NULL, 0);
+ infof(data, "Failed to disconnect from libssh2 agent: %d %s\n",
+ rc, err_msg);
}
libssh2_agent_free(sshc->ssh_agent);
sshc->ssh_agent = NULL;
@@ -2660,7 +2632,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
}
if(rc < 0) {
- infof(data, "Failed to free libssh2 session\n");
+ char *err_msg = NULL;
+ (void)libssh2_session_last_error(sshc->ssh_session,
+ &err_msg, NULL, 0);
+ infof(data, "Failed to free libssh2 session: %d %s\n", rc, err_msg);
}
sshc->ssh_session = NULL;
}
@@ -2807,9 +2782,12 @@ static CURLcode ssh_multi_statemach(struct connectdata *conn, bool *done)
CURLcode result = CURLE_OK;
bool block; /* we store the status and use that to provide a ssh_getsock()
implementation */
-
- result = ssh_statemach_act(conn, &block);
- *done = (sshc->state == SSH_STOP) ? TRUE : FALSE;
+ do {
+ result = ssh_statemach_act(conn, &block);
+ *done = (sshc->state == SSH_STOP) ? TRUE : FALSE;
+ /* if there's no error, it isn't done and it didn't EWOULDBLOCK, then
+ try again */
+ } while(!result && !*done && !block);
ssh_block2waitfor(conn, block);
return result;
@@ -2824,8 +2802,8 @@ static CURLcode ssh_block_statemach(struct connectdata *conn,
while((sshc->state != SSH_STOP) && !result) {
bool block;
- time_t left = 1000;
- struct timeval now = Curl_tvnow();
+ timediff_t left = 1000;
+ struct curltime now = Curl_now();
result = ssh_statemach_act(conn, &block);
if(result)
@@ -2933,12 +2911,19 @@ static CURLcode ssh_connect(struct connectdata *conn, bool *done)
return CURLE_FAILED_INIT;
}
+ if(data->set.ssh_compression) {
+#if LIBSSH2_VERSION_NUM >= 0x010208
+ if(libssh2_session_flag(ssh->ssh_session, LIBSSH2_FLAG_COMPRESS, 1) < 0)
+#endif
+ infof(data, "Failed to enable compression for ssh session\n");
+ }
+
#ifdef HAVE_LIBSSH2_KNOWNHOST_API
if(data->set.str[STRING_SSH_KNOWNHOSTS]) {
int rc;
ssh->kh = libssh2_knownhost_init(ssh->ssh_session);
if(!ssh->kh) {
- /* eeek. TODO: free the ssh_session! */
+ libssh2_session_free(ssh->ssh_session);
return CURLE_FAILED_INIT;
}
@@ -3029,8 +3014,8 @@ static CURLcode ssh_do(struct connectdata *conn, bool *done)
data->req.size = -1; /* make sure this is unknown at this point */
sshc->actualcode = CURLE_OK; /* reset error code */
- sshc->secondCreateDirs =0; /* reset the create dir attempt state
- variable */
+ sshc->secondCreateDirs = 0; /* reset the create dir attempt state
+ variable */
Curl_pgrsSetUploadCounter(data, 0);
Curl_pgrsSetDownloadCounter(data, 0);
@@ -3073,12 +3058,7 @@ static CURLcode ssh_done(struct connectdata *conn, CURLcode status)
struct SSHPROTO *sftp_scp = conn->data->req.protop;
if(!status) {
- /* run the state-machine
-
- TODO: when the multi interface is used, this _really_ should be using
- the ssh_multi_statemach function but we have no general support for
- non-blocking DONE operations!
- */
+ /* run the state-machine */
result = ssh_block_statemach(conn, FALSE);
}
else
@@ -3231,12 +3211,9 @@ static CURLcode sftp_done(struct connectdata *conn, CURLcode status,
/* Post quote commands are executed after the SFTP_CLOSE state to avoid
errors that could happen due to open file handles during POSTQUOTE
operation */
- if(!status && !premature && conn->data->set.postquote) {
+ if(!premature && conn->data->set.postquote && !conn->bits.retry)
sshc->nextstate = SSH_SFTP_POSTQUOTE_INIT;
- state(conn, SSH_SFTP_CLOSE);
- }
- else
- state(conn, SSH_SFTP_CLOSE);
+ state(conn, SSH_SFTP_CLOSE);
}
return ssh_done(conn, status);
}
@@ -3291,93 +3268,6 @@ static ssize_t sftp_recv(struct connectdata *conn, int sockindex,
return nread;
}
-/* The get_pathname() function is being borrowed from OpenSSH sftp.c
- version 4.6p1. */
-/*
- * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-static CURLcode
-get_pathname(const char **cpp, char **path)
-{
- const char *cp = *cpp, *end;
- char quot;
- unsigned int i, j;
- static const char WHITESPACE[] = " \t\r\n";
-
- cp += strspn(cp, WHITESPACE);
- if(!*cp) {
- *cpp = cp;
- *path = NULL;
- return CURLE_QUOTE_ERROR;
- }
-
- *path = malloc(strlen(cp) + 1);
- if(*path == NULL)
- return CURLE_OUT_OF_MEMORY;
-
- /* Check for quoted filenames */
- if(*cp == '\"' || *cp == '\'') {
- quot = *cp++;
-
- /* Search for terminating quote, unescape some chars */
- for(i = j = 0; i <= strlen(cp); i++) {
- if(cp[i] == quot) { /* Found quote */
- i++;
- (*path)[j] = '\0';
- break;
- }
- if(cp[i] == '\0') { /* End of string */
- /*error("Unterminated quote");*/
- goto fail;
- }
- if(cp[i] == '\\') { /* Escaped characters */
- i++;
- if(cp[i] != '\'' && cp[i] != '\"' &&
- cp[i] != '\\') {
- /*error("Bad escaped character '\\%c'",
- cp[i]);*/
- goto fail;
- }
- }
- (*path)[j++] = cp[i];
- }
-
- if(j == 0) {
- /*error("Empty quotes");*/
- goto fail;
- }
- *cpp = cp + i + strspn(cp + i, WHITESPACE);
- }
- else {
- /* Read to end of filename */
- end = strpbrk(cp, WHITESPACE);
- if(end == NULL)
- end = strchr(cp, '\0');
- *cpp = end + strspn(end, WHITESPACE);
-
- memcpy(*path, cp, end - cp);
- (*path)[end - cp] = '\0';
- }
- return CURLE_OK;
-
- fail:
- Curl_safefree(*path);
- return CURLE_QUOTE_ERROR;
-}
-
-
static const char *sftp_libssh2_strerror(int err)
{
switch(err) {
diff --git a/Utilities/cmcurl/lib/ssh.h b/Utilities/cmcurl/lib/ssh.h
index b350dcf3a..0620aac32 100644
--- a/Utilities/cmcurl/lib/ssh.h
+++ b/Utilities/cmcurl/lib/ssh.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -24,9 +24,12 @@
#include "curl_setup.h"
-#ifdef HAVE_LIBSSH2_H
+#if defined(HAVE_LIBSSH2_H)
#include <libssh2.h>
#include <libssh2_sftp.h>
+#elif defined(HAVE_LIBSSH_LIBSSH_H)
+#include <libssh/libssh.h>
+#include <libssh/sftp.h>
#endif /* HAVE_LIBSSH2_H */
/****************************************************************************
@@ -51,6 +54,7 @@ typedef enum {
SSH_AUTH_HOST,
SSH_AUTH_KEY_INIT,
SSH_AUTH_KEY,
+ SSH_AUTH_GSSAPI,
SSH_AUTH_DONE,
SSH_SFTP_INIT,
SSH_SFTP_REALPATH, /* Last state in SSH-CONNECT */
@@ -86,6 +90,7 @@ typedef enum {
SSH_SCP_TRANS_INIT, /* First state in SCP-DO */
SSH_SCP_UPLOAD_INIT,
SSH_SCP_DOWNLOAD_INIT,
+ SSH_SCP_DOWNLOAD,
SSH_SCP_DONE,
SSH_SCP_SEND_EOF,
SSH_SCP_WAIT_EOF,
@@ -109,7 +114,8 @@ struct SSHPROTO {
struct */
struct ssh_conn {
const char *authlist; /* List of auth. methods, managed by libssh2 */
-#ifdef USE_LIBSSH2
+
+ /* common */
const char *passphrase; /* pass-phrase to use */
char *rsa_pub; /* path name */
char *rsa; /* path name */
@@ -120,17 +126,12 @@ struct ssh_conn {
struct curl_slist *quote_item; /* for the quote option */
char *quote_path1; /* two generic pointers for the QUOTE stuff */
char *quote_path2;
- LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */
+
bool acceptfail; /* used by the SFTP_QUOTE (continue if
quote command fails) */
char *homedir; /* when doing SFTP we figure out home dir in the
connect phase */
-
- /* Here's a set of struct members used by the SFTP_READDIR state */
- LIBSSH2_SFTP_ATTRIBUTES readdir_attrs;
- char *readdir_filename;
- char *readdir_longentry;
- int readdir_len, readdir_totalLen, readdir_currLen;
+ size_t readdir_len, readdir_totalLen, readdir_currLen;
char *readdir_line;
char *readdir_linkPath;
/* end of READDIR stuff */
@@ -139,11 +140,42 @@ struct ssh_conn {
second attempt has been made to change
to/create a directory */
char *slash_pos; /* used by the SFTP_CREATE_DIRS state */
+
+ int orig_waitfor; /* default READ/WRITE bits wait for */
+
+#if defined(USE_LIBSSH)
+/* our variables */
+ unsigned kbd_state; /* 0 or 1 */
+ ssh_key privkey;
+ ssh_key pubkey;
+ int auth_methods;
+ ssh_session ssh_session;
+ ssh_scp scp_session;
+ sftp_session sftp_session;
+ sftp_file sftp_file;
+ sftp_dir sftp_dir;
+
+ unsigned sftp_recv_state; /* 0 or 1 */
+ int sftp_file_index; /* for async read */
+ sftp_attributes readdir_attrs; /* used by the SFTP readdir actions */
+ sftp_attributes readdir_link_attrs; /* used by the SFTP readdir actions */
+ sftp_attributes quote_attrs; /* used by the SFTP_QUOTE state */
+
+ const char *readdir_filename; /* points within readdir_attrs */
+ const char *readdir_longentry;
+ char *readdir_tmp;
+#elif defined(USE_LIBSSH2)
+ char *readdir_filename;
+ char *readdir_longentry;
+
+ LIBSSH2_SFTP_ATTRIBUTES quote_attrs; /* used by the SFTP_QUOTE state */
+
+ /* Here's a set of struct members used by the SFTP_READDIR state */
+ LIBSSH2_SFTP_ATTRIBUTES readdir_attrs;
LIBSSH2_SESSION *ssh_session; /* Secure Shell session */
LIBSSH2_CHANNEL *ssh_channel; /* Secure Shell channel handle */
LIBSSH2_SFTP *sftp_session; /* SFTP handle */
LIBSSH2_SFTP_HANDLE *sftp_handle;
- int orig_waitfor; /* default READ/WRITE bits wait for */
#ifdef HAVE_LIBSSH2_AGENT_API
LIBSSH2_AGENT *ssh_agent; /* proxy to ssh-agent/pageant */
@@ -156,10 +188,17 @@ struct ssh_conn {
#ifdef HAVE_LIBSSH2_KNOWNHOST_API
LIBSSH2_KNOWNHOSTS *kh;
#endif
-#endif /* USE_LIBSSH2 */
+#endif /* USE_LIBSSH */
};
-#ifdef USE_LIBSSH2
+#if defined(USE_LIBSSH)
+
+#define CURL_LIBSSH_VERSION ssh_version(0)
+
+extern const struct Curl_handler Curl_handler_scp;
+extern const struct Curl_handler Curl_handler_sftp;
+
+#elif defined(USE_LIBSSH2)
/* Feature detection based on version numbers to better work with
non-configure platforms */
@@ -190,6 +229,14 @@ struct ssh_conn {
#define HAVE_LIBSSH2_SESSION_HANDSHAKE 1
#endif
+#ifdef HAVE_LIBSSH2_VERSION
+/* get it run-time if possible */
+#define CURL_LIBSSH2_VERSION libssh2_version(0)
+#else
+/* use build-time if run-time not possible */
+#define CURL_LIBSSH2_VERSION LIBSSH2_VERSION
+#endif
+
extern const struct Curl_handler Curl_handler_scp;
extern const struct Curl_handler Curl_handler_sftp;
diff --git a/Utilities/cmcurl/lib/strcase.c b/Utilities/cmcurl/lib/strcase.c
index a74a4be57..24bcca932 100644
--- a/Utilities/cmcurl/lib/strcase.c
+++ b/Utilities/cmcurl/lib/strcase.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -94,10 +94,11 @@ char Curl_raw_toupper(char in)
}
/*
- * Curl_raw_equal() is for doing "raw" case insensitive strings. This is meant
- * to be locale independent and only compare strings we know are safe for
- * this. See https://daniel.haxx.se/blog/2008/10/15/strcasecmp-in-turkish/ for
- * some further explanation to why this function is necessary.
+ * Curl_strcasecompare() is for doing "raw" case insensitive strings. This is
+ * meant to be locale independent and only compare strings we know are safe
+ * for this. See
+ * https://daniel.haxx.se/blog/2008/10/15/strcasecmp-in-turkish/ for some
+ * further explanation to why this function is necessary.
*
* The function is capable of comparing a-z case insensitively even for
* non-ascii.
diff --git a/Utilities/cmcurl/lib/strcase.h b/Utilities/cmcurl/lib/strcase.h
index ea2abc8b6..6fee3840e 100644
--- a/Utilities/cmcurl/lib/strcase.h
+++ b/Utilities/cmcurl/lib/strcase.h
@@ -46,6 +46,5 @@ char Curl_raw_toupper(char in);
#define checkprefix(a,b) curl_strnequal(a,b,strlen(a))
void Curl_strntoupper(char *dest, const char *src, size_t n);
-char Curl_raw_toupper(char in);
#endif /* HEADER_CURL_STRCASE_H */
diff --git a/Utilities/cmcurl/lib/strdup.c b/Utilities/cmcurl/lib/strdup.c
index 136b69377..51e7978b7 100644
--- a/Utilities/cmcurl/lib/strdup.c
+++ b/Utilities/cmcurl/lib/strdup.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -44,11 +44,11 @@ char *curlx_strdup(const char *str)
if(len >= ((size_t)-1) / sizeof(char))
return (char *)NULL;
- newstr = malloc((len+1)*sizeof(char));
+ newstr = malloc((len + 1)*sizeof(char));
if(!newstr)
return (char *)NULL;
- memcpy(newstr, str, (len+1)*sizeof(char));
+ memcpy(newstr, str, (len + 1)*sizeof(char));
return newstr;
@@ -81,7 +81,7 @@ void *Curl_memdup(const void *src, size_t length)
* Curl_saferealloc(ptr, size)
*
* Does a normal realloc(), but will free the data pointer if the realloc
- * fails. If 'size' is zero, it will free the data and return a failure.
+ * fails. If 'size' is non-zero, it will free the data and return a failure.
*
* This convenience function is provided and used to help us avoid a common
* mistake pattern when we could pass in a zero, catch the NULL return and end
diff --git a/Utilities/cmcurl/lib/strerror.c b/Utilities/cmcurl/lib/strerror.c
index 7e5cde47b..e273f3765 100644
--- a/Utilities/cmcurl/lib/strerror.c
+++ b/Utilities/cmcurl/lib/strerror.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2004 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2004 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -49,6 +49,10 @@
#include "curl_memory.h"
#include "memdebug.h"
+#if defined(WIN32) || defined(_WIN32_WCE)
+#define PRESERVE_WINDOWS_ERROR_CODE
+#endif
+
const char *
curl_easy_strerror(CURLcode error)
{
@@ -187,9 +191,6 @@ curl_easy_strerror(CURLcode error)
case CURLE_TELNET_OPTION_SYNTAX :
return "Malformed telnet option";
- case CURLE_PEER_FAILED_VERIFICATION:
- return "SSL peer certificate or SSH remote key was not OK";
-
case CURLE_GOT_NOTHING:
return "Server returned nothing (no headers, no data)";
@@ -214,9 +215,8 @@ curl_easy_strerror(CURLcode error)
case CURLE_SSL_CIPHER:
return "Couldn't use specified SSL cipher";
- case CURLE_SSL_CACERT:
- return "Peer certificate cannot be authenticated with given CA "
- "certificates";
+ case CURLE_PEER_FAILED_VERIFICATION:
+ return "SSL peer certificate or SSH remote key was not OK";
case CURLE_SSL_CACERT_BADFILE:
return "Problem with the SSL CA cert (path? access rights?)";
@@ -308,6 +308,9 @@ curl_easy_strerror(CURLcode error)
case CURLE_HTTP2_STREAM:
return "Stream error in the HTTP/2 framing layer";
+ case CURLE_RECURSIVE_API_CALL:
+ return "API function called from within callback";
+
/* error codes not used by current libcurl */
case CURLE_OBSOLETE20:
case CURLE_OBSOLETE24:
@@ -317,6 +320,7 @@ curl_easy_strerror(CURLcode error)
case CURLE_OBSOLETE44:
case CURLE_OBSOLETE46:
case CURLE_OBSOLETE50:
+ case CURLE_OBSOLETE51:
case CURLE_OBSOLETE57:
case CURL_LAST:
break;
@@ -376,6 +380,9 @@ curl_multi_strerror(CURLMcode error)
case CURLM_ADDED_ALREADY:
return "The easy handle is already added to a multi handle";
+ case CURLM_RECURSIVE_API_CALL:
+ return "API function called from within callback";
+
case CURLM_LAST:
break;
}
@@ -432,6 +439,10 @@ curl_share_strerror(CURLSHcode error)
static const char *
get_winsock_error (int err, char *buf, size_t len)
{
+#ifdef PRESERVE_WINDOWS_ERROR_CODE
+ DWORD old_win_err = GetLastError();
+#endif
+ int old_errno = errno;
const char *p;
#ifndef CURL_DISABLE_VERBOSE_STRINGS
@@ -611,6 +622,15 @@ get_winsock_error (int err, char *buf, size_t len)
#endif
strncpy(buf, p, len);
buf [len-1] = '\0';
+
+ if(errno != old_errno)
+ errno = old_errno;
+
+#ifdef PRESERVE_WINDOWS_ERROR_CODE
+ if(old_win_err != GetLastError())
+ SetLastError(old_win_err);
+#endif
+
return buf;
}
#endif /* USE_WINSOCK */
@@ -626,17 +646,18 @@ get_winsock_error (int err, char *buf, size_t len)
* We don't do range checking (on systems other than Windows) since there is
* no good reliable and portable way to do it.
*/
-const char *Curl_strerror(struct connectdata *conn, int err)
+const char *Curl_strerror(int err, char *buf, size_t buflen)
{
- char *buf, *p;
+#ifdef PRESERVE_WINDOWS_ERROR_CODE
+ DWORD old_win_err = GetLastError();
+#endif
+ int old_errno = errno;
+ char *p;
size_t max;
- int old_errno = ERRNO;
- DEBUGASSERT(conn);
DEBUGASSERT(err >= 0);
- buf = conn->syserr_buf;
- max = sizeof(conn->syserr_buf)-1;
+ max = buflen - 1;
*buf = '\0';
#ifdef USE_WINSOCK
@@ -658,7 +679,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
if(!get_winsock_error(err, buf, max) &&
!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err,
LANG_NEUTRAL, buf, (DWORD)max, NULL))
- snprintf(buf, max, "Unknown error %d (%#x)", err, err);
+ msnprintf(buf, max, "Unknown error %d (%#x)", err, err);
}
#endif
@@ -672,7 +693,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
*/
if(0 != strerror_r(err, buf, max)) {
if('\0' == buf[0])
- snprintf(buf, max, "Unknown error %d", err);
+ msnprintf(buf, max, "Unknown error %d", err);
}
#elif defined(HAVE_STRERROR_R) && defined(HAVE_GLIBC_STRERROR_R)
/*
@@ -686,7 +707,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
if(msg)
strncpy(buf, msg, max);
else
- snprintf(buf, max, "Unknown error %d", err);
+ msnprintf(buf, max, "Unknown error %d", err);
}
#elif defined(HAVE_STRERROR_R) && defined(HAVE_VXWORKS_STRERROR_R)
/*
@@ -698,7 +719,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
if(OK == strerror_r(err, buffer))
strncpy(buf, buffer, max);
else
- snprintf(buf, max, "Unknown error %d", err);
+ msnprintf(buf, max, "Unknown error %d", err);
}
#else
{
@@ -706,7 +727,7 @@ const char *Curl_strerror(struct connectdata *conn, int err)
if(msg)
strncpy(buf, msg, max);
else
- snprintf(buf, max, "Unknown error %d", err);
+ msnprintf(buf, max, "Unknown error %d", err);
}
#endif
@@ -722,36 +743,40 @@ const char *Curl_strerror(struct connectdata *conn, int err)
if(p && (p - buf) >= 1)
*p = '\0';
- if(old_errno != ERRNO)
- SET_ERRNO(old_errno);
+ if(errno != old_errno)
+ errno = old_errno;
+
+#ifdef PRESERVE_WINDOWS_ERROR_CODE
+ if(old_win_err != GetLastError())
+ SetLastError(old_win_err);
+#endif
return buf;
}
#ifdef USE_WINDOWS_SSPI
-const char *Curl_sspi_strerror (struct connectdata *conn, int err)
+const char *Curl_sspi_strerror(int err, char *buf, size_t buflen)
{
+#ifdef PRESERVE_WINDOWS_ERROR_CODE
+ DWORD old_win_err = GetLastError();
+#endif
+ int old_errno = errno;
+ const char *txt;
+ char *outbuf;
+ size_t outmax;
#ifndef CURL_DISABLE_VERBOSE_STRINGS
char txtbuf[80];
- char msgbuf[sizeof(conn->syserr_buf)];
+ char msgbuf[256];
char *p, *str, *msg = NULL;
bool msg_formatted = FALSE;
- int old_errno;
#endif
- const char *txt;
- char *outbuf;
- size_t outmax;
-
- DEBUGASSERT(conn);
- outbuf = conn->syserr_buf;
- outmax = sizeof(conn->syserr_buf)-1;
+ outbuf = buf;
+ outmax = buflen - 1;
*outbuf = '\0';
#ifndef CURL_DISABLE_VERBOSE_STRINGS
- old_errno = ERRNO;
-
switch(err) {
case SEC_E_OK:
txt = "No error";
@@ -1003,14 +1028,14 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err)
if(err == SEC_E_OK)
strncpy(outbuf, txt, outmax);
else if(err == SEC_E_ILLEGAL_MESSAGE)
- snprintf(outbuf, outmax,
- "SEC_E_ILLEGAL_MESSAGE (0x%08X) - This error usually occurs "
- "when a fatal SSL/TLS alert is received (e.g. handshake failed). "
- "More detail may be available in the Windows System event log.",
- err);
+ msnprintf(outbuf, outmax,
+ "SEC_E_ILLEGAL_MESSAGE (0x%08X) - This error usually occurs "
+ "when a fatal SSL/TLS alert is received (e.g. handshake failed)."
+ " More detail may be available in the Windows System event log.",
+ err);
else {
str = txtbuf;
- snprintf(txtbuf, sizeof(txtbuf), "%s (0x%08X)", txt, err);
+ msnprintf(txtbuf, sizeof(txtbuf), "%s (0x%08X)", txt, err);
txtbuf[sizeof(txtbuf)-1] = '\0';
#ifdef _WIN32_WCE
@@ -1046,14 +1071,11 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err)
msg = msgbuf;
}
if(msg)
- snprintf(outbuf, outmax, "%s - %s", str, msg);
+ msnprintf(outbuf, outmax, "%s - %s", str, msg);
else
strncpy(outbuf, str, outmax);
}
- if(old_errno != ERRNO)
- SET_ERRNO(old_errno);
-
#else
if(err == SEC_E_OK)
@@ -1067,6 +1089,14 @@ const char *Curl_sspi_strerror (struct connectdata *conn, int err)
outbuf[outmax] = '\0';
+ if(errno != old_errno)
+ errno = old_errno;
+
+#ifdef PRESERVE_WINDOWS_ERROR_CODE
+ if(old_win_err != GetLastError())
+ SetLastError(old_win_err);
+#endif
+
return outbuf;
}
#endif /* USE_WINDOWS_SSPI */
diff --git a/Utilities/cmcurl/lib/strerror.h b/Utilities/cmcurl/lib/strerror.h
index 627273eb2..683b5b4a3 100644
--- a/Utilities/cmcurl/lib/strerror.h
+++ b/Utilities/cmcurl/lib/strerror.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -24,14 +24,11 @@
#include "urldata.h"
-const char *Curl_strerror (struct connectdata *conn, int err);
-
-#ifdef USE_LIBIDN2
-const char *Curl_idn_strerror (struct connectdata *conn, int err);
-#endif
+#define STRERROR_LEN 128 /* a suitable length */
+const char *Curl_strerror(int err, char *buf, size_t buflen);
#ifdef USE_WINDOWS_SSPI
-const char *Curl_sspi_strerror (struct connectdata *conn, int err);
+const char *Curl_sspi_strerror(int err, char *buf, size_t buflen);
#endif
#endif /* HEADER_CURL_STRERROR_H */
diff --git a/Utilities/cmcurl/lib/strtoofft.c b/Utilities/cmcurl/lib/strtoofft.c
index b854bf4de..546a3ff75 100644
--- a/Utilities/cmcurl/lib/strtoofft.c
+++ b/Utilities/cmcurl/lib/strtoofft.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -20,6 +20,7 @@
*
***************************************************************************/
+#include <errno.h>
#include "curl_setup.h"
#include "strtoofft.h"
@@ -29,10 +30,32 @@
*
* In the ISO C standard (IEEE Std 1003.1), there is a strtoimax() function we
* could use in case strtoll() doesn't exist... See
- * http://www.opengroup.org/onlinepubs/009695399/functions/strtoimax.html
+ * https://www.opengroup.org/onlinepubs/009695399/functions/strtoimax.html
*/
-#ifdef NEED_CURL_STRTOLL
+#if (SIZEOF_CURL_OFF_T > SIZEOF_LONG)
+# ifdef HAVE_STRTOLL
+# define strtooff strtoll
+# else
+# if defined(_MSC_VER) && (_MSC_VER >= 1300) && (_INTEGRAL_MAX_BITS >= 64)
+# if defined(_SAL_VERSION)
+ _Check_return_ _CRTIMP __int64 __cdecl _strtoi64(
+ _In_z_ const char *_String,
+ _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix);
+# else
+ _CRTIMP __int64 __cdecl _strtoi64(const char *_String,
+ char **_EndPtr, int _Radix);
+# endif
+# define strtooff _strtoi64
+# else
+# define PRIVATE_STRTOOFF 1
+# endif
+# endif
+#else
+# define strtooff strtol
+#endif
+
+#ifdef PRIVATE_STRTOOFF
/* Range tests can be used for alphanum decoding if characters are consecutive,
like in ASCII. Else an array is scanned. Determine this condition now. */
@@ -48,11 +71,10 @@ static const char valchars[] =
static int get_char(char c, int base);
/**
- * Emulated version of the strtoll function. This extracts a long long
+ * Custom version of the strtooff function. This extracts a curl_off_t
* value from the given input string and returns it.
*/
-curl_off_t
-curlx_strtoll(const char *nptr, char **endptr, int base)
+static curl_off_t strtooff(const char *nptr, char **endptr, int base)
{
char *end;
int is_negative = 0;
@@ -132,7 +154,7 @@ curlx_strtoll(const char *nptr, char **endptr, int base)
else
value = CURL_OFF_T_MAX;
- SET_ERRNO(ERANGE);
+ errno = ERANGE;
}
if(endptr)
@@ -186,3 +208,35 @@ static int get_char(char c, int base)
return value;
}
#endif /* Only present if we need strtoll, but don't have it. */
+
+/*
+ * Parse a *positive* up to 64 bit number written in ascii.
+ */
+CURLofft curlx_strtoofft(const char *str, char **endp, int base,
+ curl_off_t *num)
+{
+ char *end;
+ curl_off_t number;
+ errno = 0;
+ *num = 0; /* clear by default */
+
+ while(*str && ISSPACE(*str))
+ str++;
+ if('-' == *str) {
+ if(endp)
+ *endp = (char *)str; /* didn't actually move */
+ return CURL_OFFT_INVAL; /* nothing parsed */
+ }
+ number = strtooff(str, &end, base);
+ if(endp)
+ *endp = end;
+ if(errno == ERANGE)
+ /* overflow/underflow */
+ return CURL_OFFT_FLOW;
+ else if(str == end)
+ /* nothing parsed */
+ return CURL_OFFT_INVAL;
+
+ *num = number;
+ return CURL_OFFT_OK;
+}
diff --git a/Utilities/cmcurl/lib/strtoofft.h b/Utilities/cmcurl/lib/strtoofft.h
index f4039f3a3..be19cd716 100644
--- a/Utilities/cmcurl/lib/strtoofft.h
+++ b/Utilities/cmcurl/lib/strtoofft.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -40,36 +40,13 @@
* of 'long' the conversion function to use is strtol().
*/
-#if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
-# ifdef HAVE_STRTOLL
-# define curlx_strtoofft strtoll
-# else
-# if defined(_MSC_VER) && (_MSC_VER >= 1300) && (_INTEGRAL_MAX_BITS >= 64)
-# if defined(_SAL_VERSION)
- _Check_return_ _CRTIMP __int64 __cdecl _strtoi64(
- _In_z_ const char *_String,
- _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix);
-# else
- _CRTIMP __int64 __cdecl _strtoi64(const char *_String,
- char **_EndPtr, int _Radix);
-# endif
-# define curlx_strtoofft _strtoi64
-# else
- curl_off_t curlx_strtoll(const char *nptr, char **endptr, int base);
-# define curlx_strtoofft curlx_strtoll
-# define NEED_CURL_STRTOLL 1
-# endif
-# endif
-#else
-# define curlx_strtoofft strtol
-#endif
+typedef enum {
+ CURL_OFFT_OK, /* parsed fine */
+ CURL_OFFT_FLOW, /* over or underflow */
+ CURL_OFFT_INVAL /* nothing was parsed */
+} CURLofft;
-#if (CURL_SIZEOF_CURL_OFF_T == 4)
-# define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFF)
-#else
- /* assume CURL_SIZEOF_CURL_OFF_T == 8 */
-# define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF)
-#endif
-#define CURL_OFF_T_MIN (-CURL_OFF_T_MAX - CURL_OFF_T_C(1))
+CURLofft curlx_strtoofft(const char *str, char **endp, int base,
+ curl_off_t *num);
#endif /* HEADER_CURL_STRTOOFFT_H */
diff --git a/Utilities/cmcurl/lib/system_win32.c b/Utilities/cmcurl/lib/system_win32.c
index cfbbf3279..f7f817dd4 100644
--- a/Utilities/cmcurl/lib/system_win32.c
+++ b/Utilities/cmcurl/lib/system_win32.c
@@ -26,11 +26,94 @@
#include <curl/curl.h>
#include "system_win32.h"
+#include "curl_sspi.h"
+#include "warnless.h"
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"
+LARGE_INTEGER Curl_freq;
+bool Curl_isVistaOrGreater;
+
+/* Curl_win32_init() performs win32 global initialization */
+CURLcode Curl_win32_init(long flags)
+{
+ /* CURL_GLOBAL_WIN32 controls the *optional* part of the initialization which
+ is just for Winsock at the moment. Any required win32 initialization
+ should take place after this block. */
+ if(flags & CURL_GLOBAL_WIN32) {
+#ifdef USE_WINSOCK
+ WORD wVersionRequested;
+ WSADATA wsaData;
+ int res;
+
+#if defined(ENABLE_IPV6) && (USE_WINSOCK < 2)
+#error IPV6_requires_winsock2
+#endif
+
+ wVersionRequested = MAKEWORD(USE_WINSOCK, USE_WINSOCK);
+
+ res = WSAStartup(wVersionRequested, &wsaData);
+
+ if(res != 0)
+ /* Tell the user that we couldn't find a usable */
+ /* winsock.dll. */
+ return CURLE_FAILED_INIT;
+
+ /* Confirm that the Windows Sockets DLL supports what we need.*/
+ /* Note that if the DLL supports versions greater */
+ /* than wVersionRequested, it will still return */
+ /* wVersionRequested in wVersion. wHighVersion contains the */
+ /* highest supported version. */
+
+ if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) ||
+ HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested) ) {
+ /* Tell the user that we couldn't find a usable */
+
+ /* winsock.dll. */
+ WSACleanup();
+ return CURLE_FAILED_INIT;
+ }
+ /* The Windows Sockets DLL is acceptable. Proceed. */
+ #elif defined(USE_LWIPSOCK)
+ lwip_init();
+ #endif
+ } /* CURL_GLOBAL_WIN32 */
+
+#ifdef USE_WINDOWS_SSPI
+ {
+ CURLcode result = Curl_sspi_global_init();
+ if(result)
+ return result;
+ }
+#endif
+
+ if(Curl_verify_windows_version(6, 0, PLATFORM_WINNT,
+ VERSION_GREATER_THAN_EQUAL)) {
+ Curl_isVistaOrGreater = TRUE;
+ QueryPerformanceFrequency(&Curl_freq);
+ }
+ else
+ Curl_isVistaOrGreater = FALSE;
+
+ return CURLE_OK;
+}
+
+/* Curl_win32_cleanup() is the opposite of Curl_win32_init() */
+void Curl_win32_cleanup(long init_flags)
+{
+#ifdef USE_WINDOWS_SSPI
+ Curl_sspi_global_cleanup();
+#endif
+
+ if(init_flags & CURL_GLOBAL_WIN32) {
+#ifdef USE_WINSOCK
+ WSACleanup();
+#endif
+ }
+}
+
#if defined(USE_WINDOWS_SSPI) || (!defined(CURL_DISABLE_TELNET) && \
defined(USE_WINSOCK))
@@ -134,8 +217,9 @@ bool Curl_verify_windows_version(const unsigned int majorVersion,
break;
case VERSION_LESS_THAN_EQUAL:
- if(osver.dwMajorVersion <= majorVersion &&
- osver.dwMinorVersion <= minorVersion)
+ if(osver.dwMajorVersion < majorVersion ||
+ (osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion <= minorVersion))
matched = TRUE;
break;
@@ -146,8 +230,9 @@ bool Curl_verify_windows_version(const unsigned int majorVersion,
break;
case VERSION_GREATER_THAN_EQUAL:
- if(osver.dwMajorVersion >= majorVersion &&
- osver.dwMinorVersion >= minorVersion)
+ if(osver.dwMajorVersion > majorVersion ||
+ (osver.dwMajorVersion == majorVersion &&
+ osver.dwMinorVersion >= minorVersion))
matched = TRUE;
break;
@@ -278,7 +363,9 @@ HMODULE Curl_load_library(LPCTSTR filename)
/* Attempt to find LoadLibraryEx() which is only available on Windows 2000
and above */
- pLoadLibraryEx = (LOADLIBRARYEX_FN) GetProcAddress(hKernel32, LOADLIBARYEX);
+ pLoadLibraryEx =
+ CURLX_FUNCTION_CAST(LOADLIBRARYEX_FN,
+ (GetProcAddress(hKernel32, LOADLIBARYEX)));
/* Detect if there's already a path in the filename and load the library if
there is. Note: Both back slashes and forward slashes have been supported
diff --git a/Utilities/cmcurl/lib/system_win32.h b/Utilities/cmcurl/lib/system_win32.h
index 1e772856b..926328a9a 100644
--- a/Utilities/cmcurl/lib/system_win32.h
+++ b/Utilities/cmcurl/lib/system_win32.h
@@ -26,6 +26,12 @@
#if defined(WIN32)
+extern LARGE_INTEGER Curl_freq;
+extern bool Curl_isVistaOrGreater;
+
+CURLcode Curl_win32_init(long flags);
+void Curl_win32_cleanup(long init_flags);
+
/* Version condition */
typedef enum {
VERSION_LESS_THAN,
diff --git a/Utilities/cmcurl/lib/telnet.c b/Utilities/cmcurl/lib/telnet.c
index 155d4b260..955255c36 100644
--- a/Utilities/cmcurl/lib/telnet.c
+++ b/Utilities/cmcurl/lib/telnet.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -52,10 +52,6 @@
#include "connect.h"
#include "progress.h"
#include "system_win32.h"
-
-#define TELOPTS
-#define TELCMDS
-
#include "arpa_telnet.h"
#include "select.h"
#include "strcase.h"
@@ -74,10 +70,10 @@
x->subend = x->subpointer; \
CURL_SB_CLEAR(x); \
} WHILE_FALSE
-#define CURL_SB_ACCUM(x,c) \
- do { \
- if(x->subpointer < (x->subbuffer+sizeof x->subbuffer)) \
- *x->subpointer++ = (c); \
+#define CURL_SB_ACCUM(x,c) \
+ do { \
+ if(x->subpointer < (x->subbuffer + sizeof(x->subbuffer))) \
+ *x->subpointer++ = (c); \
} WHILE_FALSE
#define CURL_SB_GET(x) ((*x->subpointer++)&0xff)
@@ -92,6 +88,7 @@
#endif
#ifdef USE_WINSOCK
+typedef WSAEVENT (WINAPI *WSOCK2_EVENT)(void);
typedef FARPROC WSOCK2_FUNC;
static CURLcode check_wsock2(struct Curl_easy *data);
#endif
@@ -109,8 +106,10 @@ static void printoption(struct Curl_easy *data,
static void negotiate(struct connectdata *);
static void send_negotiation(struct connectdata *, int cmd, int option);
-static void set_local_option(struct connectdata *, int cmd, int option);
-static void set_remote_option(struct connectdata *, int cmd, int option);
+static void set_local_option(struct connectdata *conn,
+ int option, int newstate);
+static void set_remote_option(struct connectdata *conn,
+ int option, int newstate);
static void printsub(struct Curl_easy *data,
int direction, unsigned char *pointer,
@@ -192,6 +191,7 @@ const struct Curl_handler Curl_handler_telnet = {
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_TELNET, /* defport */
CURLPROTO_TELNET, /* protocol */
PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */
@@ -294,8 +294,8 @@ static void negotiate(struct connectdata *conn)
int i;
struct TELNET *tn = (struct TELNET *) conn->data->req.protop;
- for(i = 0;i < CURL_NTELOPTS;i++) {
- if(i==CURL_TELOPT_ECHO)
+ for(i = 0; i < CURL_NTELOPTS; i++) {
+ if(i == CURL_TELOPT_ECHO)
continue;
if(tn->us_preferred[i] == CURL_YES)
@@ -310,9 +310,6 @@ static void negotiate(struct connectdata *conn)
static void printoption(struct Curl_easy *data,
const char *direction, int cmd, int option)
{
- const char *fmt;
- const char *opt;
-
if(data->set.verbose) {
if(cmd == CURL_IAC) {
if(CURL_TELCMD_OK(option))
@@ -321,9 +318,12 @@ static void printoption(struct Curl_easy *data,
infof(data, "%s IAC %d\n", direction, option);
}
else {
- fmt = (cmd == CURL_WILL) ? "WILL" : (cmd == CURL_WONT) ? "WONT" :
- (cmd == CURL_DO) ? "DO" : (cmd == CURL_DONT) ? "DONT" : 0;
+ const char *fmt = (cmd == CURL_WILL) ? "WILL" :
+ (cmd == CURL_WONT) ? "WONT" :
+ (cmd == CURL_DO) ? "DO" :
+ (cmd == CURL_DONT) ? "DONT" : 0;
if(fmt) {
+ const char *opt;
if(CURL_TELOPT_OK(option))
opt = CURL_TELOPT(option);
else if(option == CURL_TELOPT_EXOPL)
@@ -347,7 +347,6 @@ static void send_negotiation(struct connectdata *conn, int cmd, int option)
{
unsigned char buf[3];
ssize_t bytes_written;
- int err;
struct Curl_easy *data = conn->data;
buf[0] = CURL_IAC;
@@ -356,7 +355,7 @@ static void send_negotiation(struct connectdata *conn, int cmd, int option)
bytes_written = swrite(conn->sock[FIRSTSOCKET], buf, 3);
if(bytes_written < 0) {
- err = SOCKERRNO;
+ int err = SOCKERRNO;
failf(data,"Sending data failed (%d)",err);
}
@@ -709,9 +708,8 @@ static void printsub(struct Curl_easy *data,
unsigned char *pointer, /* where suboption data is */
size_t length) /* length of suboption data */
{
- unsigned int i = 0;
-
if(data->set.verbose) {
+ unsigned int i = 0;
if(direction) {
infof(data, "%s IAC SB ", (direction == '<')? "RCVD":"SENT");
if(length >= 3) {
@@ -763,7 +761,7 @@ static void printsub(struct Curl_easy *data,
switch(pointer[0]) {
case CURL_TELOPT_NAWS:
if(length > 4)
- infof(data, "Width: %hu ; Height: %hu", (pointer[1]<<8) | pointer[2],
+ infof(data, "Width: %d ; Height: %d", (pointer[1]<<8) | pointer[2],
(pointer[3]<<8) | pointer[4]);
break;
default:
@@ -791,7 +789,7 @@ static void printsub(struct Curl_easy *data,
case CURL_TELOPT_NEW_ENVIRON:
if(pointer[1] == CURL_TELQUAL_IS) {
infof(data, " ");
- for(i = 3;i < length;i++) {
+ for(i = 3; i < length; i++) {
switch(pointer[i]) {
case CURL_NEW_ENV_VAR:
infof(data, ", ");
@@ -831,7 +829,7 @@ static CURLcode check_telnet_options(struct connectdata *conn)
/* Add the user name as an environment variable if it
was given on the command line */
if(conn->bits.user_passwd) {
- snprintf(option_arg, sizeof(option_arg), "USER,%s", conn->user);
+ msnprintf(option_arg, sizeof(option_arg), "USER,%s", conn->user);
beg = curl_slist_append(tn->telnet_vars, option_arg);
if(!beg) {
curl_slist_free_all(tn->telnet_vars);
@@ -842,7 +840,7 @@ static CURLcode check_telnet_options(struct connectdata *conn)
tn->us_preferred[CURL_TELOPT_NEW_ENVIRON] = CURL_YES;
}
- for(head = data->set.telnet_options; head; head=head->next) {
+ for(head = data->set.telnet_options; head; head = head->next) {
if(sscanf(head->data, "%127[^= ]%*[ =]%255s",
option_keyword, option_arg) == 2) {
@@ -889,8 +887,8 @@ static CURLcode check_telnet_options(struct connectdata *conn)
/* To take care or not of the 8th bit in data exchange */
if(strcasecompare(option_keyword, "BINARY")) {
- binary_option=atoi(option_arg);
- if(binary_option!=1) {
+ binary_option = atoi(option_arg);
+ if(binary_option != 1) {
tn->us_preferred[CURL_TELOPT_BINARY] = CURL_NO;
tn->him_preferred[CURL_TELOPT_BINARY] = CURL_NO;
}
@@ -898,7 +896,7 @@ static CURLcode check_telnet_options(struct connectdata *conn)
}
failf(data, "Unknown telnet option %s", head->data);
- result = CURLE_UNKNOWN_TELNET_OPTION;
+ result = CURLE_UNKNOWN_OPTION;
break;
}
failf(data, "Syntax error in telnet option: %s", head->data);
@@ -927,20 +925,19 @@ static void suboption(struct connectdata *conn)
unsigned char temp[2048];
ssize_t bytes_written;
size_t len;
- size_t tmplen;
int err;
char varname[128] = "";
char varval[128] = "";
struct Curl_easy *data = conn->data;
struct TELNET *tn = (struct TELNET *)data->req.protop;
- printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn)+2);
+ printsub(data, '<', (unsigned char *)tn->subbuffer, CURL_SB_LEN(tn) + 2);
switch(CURL_SB_GET(tn)) {
case CURL_TELOPT_TTYPE:
len = strlen(tn->subopt_ttype) + 4 + 2;
- snprintf((char *)temp, sizeof(temp),
- "%c%c%c%c%s%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_TTYPE,
- CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC, CURL_SE);
+ msnprintf((char *)temp, sizeof(temp),
+ "%c%c%c%c%s%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_TTYPE,
+ CURL_TELQUAL_IS, tn->subopt_ttype, CURL_IAC, CURL_SE);
bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
if(bytes_written < 0) {
err = SOCKERRNO;
@@ -950,9 +947,9 @@ static void suboption(struct connectdata *conn)
break;
case CURL_TELOPT_XDISPLOC:
len = strlen(tn->subopt_xdisploc) + 4 + 2;
- snprintf((char *)temp, sizeof(temp),
- "%c%c%c%c%s%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_XDISPLOC,
- CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC, CURL_SE);
+ msnprintf((char *)temp, sizeof(temp),
+ "%c%c%c%c%s%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_XDISPLOC,
+ CURL_TELQUAL_IS, tn->subopt_xdisploc, CURL_IAC, CURL_SE);
bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
if(bytes_written < 0) {
err = SOCKERRNO;
@@ -961,25 +958,25 @@ static void suboption(struct connectdata *conn)
printsub(data, '>', &temp[2], len-2);
break;
case CURL_TELOPT_NEW_ENVIRON:
- snprintf((char *)temp, sizeof(temp),
- "%c%c%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_NEW_ENVIRON,
- CURL_TELQUAL_IS);
+ msnprintf((char *)temp, sizeof(temp),
+ "%c%c%c%c", CURL_IAC, CURL_SB, CURL_TELOPT_NEW_ENVIRON,
+ CURL_TELQUAL_IS);
len = 4;
- for(v = tn->telnet_vars;v;v = v->next) {
- tmplen = (strlen(v->data) + 1);
+ for(v = tn->telnet_vars; v; v = v->next) {
+ size_t tmplen = (strlen(v->data) + 1);
/* Add the variable only if it fits */
if(len + tmplen < (int)sizeof(temp)-6) {
if(sscanf(v->data, "%127[^,],%127s", varname, varval)) {
- snprintf((char *)&temp[len], sizeof(temp) - len,
- "%c%s%c%s", CURL_NEW_ENV_VAR, varname,
- CURL_NEW_ENV_VALUE, varval);
+ msnprintf((char *)&temp[len], sizeof(temp) - len,
+ "%c%s%c%s", CURL_NEW_ENV_VAR, varname,
+ CURL_NEW_ENV_VALUE, varval);
len += tmplen;
}
}
}
- snprintf((char *)&temp[len], sizeof(temp) - len,
- "%c%c", CURL_IAC, CURL_SE);
+ msnprintf((char *)&temp[len], sizeof(temp) - len,
+ "%c%c", CURL_IAC, CURL_SE);
len += 2;
bytes_written = swrite(conn->sock[FIRSTSOCKET], temp, len);
if(bytes_written < 0) {
@@ -1016,10 +1013,10 @@ static void sendsuboption(struct connectdata *conn, int option)
CURL_SB_ACCUM(tn, CURL_IAC);
CURL_SB_ACCUM(tn, CURL_SB);
CURL_SB_ACCUM(tn, CURL_TELOPT_NAWS);
- /* We must deal either with litte or big endian processors */
+ /* We must deal either with little or big endian processors */
/* Window size must be sent according to the 'network order' */
- x=htons(tn->subopt_wsx);
- y=htons(tn->subopt_wsy);
+ x = htons(tn->subopt_wsx);
+ y = htons(tn->subopt_wsy);
uc1 = (unsigned char *)&x;
uc2 = (unsigned char *)&y;
CURL_SB_ACCUM(tn, uc1[0]);
@@ -1032,7 +1029,7 @@ static void sendsuboption(struct connectdata *conn, int option)
CURL_SB_TERM(tn);
/* data suboption is now ready */
- printsub(data, '>', (unsigned char *)tn->subbuffer+2,
+ printsub(data, '>', (unsigned char *)tn->subbuffer + 2,
CURL_SB_LEN(tn)-2);
/* we send the header of the suboption... */
@@ -1043,9 +1040,9 @@ static void sendsuboption(struct connectdata *conn, int option)
}
/* ... then the window size with the send_telnet_data() function
to deal with 0xFF cases ... */
- send_telnet_data(conn, (char *)tn->subbuffer+3, 4);
+ send_telnet_data(conn, (char *)tn->subbuffer + 3, 4);
/* ... and the footer */
- bytes_written = swrite(conn->sock[FIRSTSOCKET], tn->subbuffer+7, 2);
+ bytes_written = swrite(conn->sock[FIRSTSOCKET], tn->subbuffer + 7, 2);
if(bytes_written < 0) {
err = SOCKERRNO;
failf(data, "Sending data failed (%d)", err);
@@ -1063,7 +1060,7 @@ CURLcode telrcv(struct connectdata *conn,
unsigned char c;
CURLcode result;
int in = 0;
- int startwrite=-1;
+ int startwrite = -1;
struct Curl_easy *data = conn->data;
struct TELNET *tn = (struct TELNET *)data->req.protop;
@@ -1202,8 +1199,7 @@ CURLcode telrcv(struct connectdata *conn,
CURL_SB_ACCUM(tn, c);
tn->telrcv_state = CURL_TS_SB;
}
- else
- {
+ else {
CURL_SB_ACCUM(tn, CURL_IAC);
CURL_SB_ACCUM(tn, CURL_SE);
tn->subpointer -= 2;
@@ -1223,7 +1219,7 @@ CURLcode telrcv(struct connectdata *conn,
static CURLcode send_telnet_data(struct connectdata *conn,
char *buffer, ssize_t nread)
{
- ssize_t escapes, i, j, outlen;
+ ssize_t escapes, i, outlen;
unsigned char *outbuf = NULL;
CURLcode result = CURLE_OK;
ssize_t bytes_written, total_written;
@@ -1238,6 +1234,7 @@ static CURLcode send_telnet_data(struct connectdata *conn,
if(outlen == nread)
outbuf = (unsigned char *)buffer;
else {
+ ssize_t j;
outbuf = malloc(nread + escapes + 1);
if(!outbuf)
return CURLE_OUT_OF_MEMORY;
@@ -1306,7 +1303,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
#ifdef USE_WINSOCK
HMODULE wsock2;
WSOCK2_FUNC close_event_func;
- WSOCK2_FUNC create_event_func;
+ WSOCK2_EVENT create_event_func;
WSOCK2_FUNC event_select_func;
WSOCK2_FUNC enum_netevents_func;
WSAEVENT event_handle;
@@ -1315,7 +1312,6 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
HANDLE objs[2];
DWORD obj_count;
DWORD wait_timeout;
- DWORD waitret;
DWORD readfile_read;
int err;
#else
@@ -1326,7 +1322,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
curl_off_t total_ul = 0;
#endif
ssize_t nread;
- struct timeval now;
+ struct curltime now;
bool keepon = TRUE;
char *buf = data->state.buffer;
struct TELNET *tn;
@@ -1356,14 +1352,16 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
/* load ws2_32.dll and get the function pointers we need. */
wsock2 = Curl_load_library(TEXT("WS2_32.DLL"));
if(wsock2 == NULL) {
- failf(data, "failed to load WS2_32.DLL (%d)", ERRNO);
+ failf(data, "failed to load WS2_32.DLL (%u)", GetLastError());
return CURLE_FAILED_INIT;
}
/* Grab a pointer to WSACreateEvent */
- create_event_func = GetProcAddress(wsock2, "WSACreateEvent");
+ create_event_func =
+ CURLX_FUNCTION_CAST(WSOCK2_EVENT,
+ (GetProcAddress(wsock2, "WSACreateEvent")));
if(create_event_func == NULL) {
- failf(data, "failed to find WSACreateEvent function (%d)", ERRNO);
+ failf(data, "failed to find WSACreateEvent function (%u)", GetLastError());
FreeLibrary(wsock2);
return CURLE_FAILED_INIT;
}
@@ -1371,7 +1369,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
/* And WSACloseEvent */
close_event_func = GetProcAddress(wsock2, "WSACloseEvent");
if(close_event_func == NULL) {
- failf(data, "failed to find WSACloseEvent function (%d)", ERRNO);
+ failf(data, "failed to find WSACloseEvent function (%u)", GetLastError());
FreeLibrary(wsock2);
return CURLE_FAILED_INIT;
}
@@ -1379,7 +1377,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
/* And WSAEventSelect */
event_select_func = GetProcAddress(wsock2, "WSAEventSelect");
if(event_select_func == NULL) {
- failf(data, "failed to find WSAEventSelect function (%d)", ERRNO);
+ failf(data, "failed to find WSAEventSelect function (%u)", GetLastError());
FreeLibrary(wsock2);
return CURLE_FAILED_INIT;
}
@@ -1387,7 +1385,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
/* And WSAEnumNetworkEvents */
enum_netevents_func = GetProcAddress(wsock2, "WSAEnumNetworkEvents");
if(enum_netevents_func == NULL) {
- failf(data, "failed to find WSAEnumNetworkEvents function (%d)", ERRNO);
+ failf(data, "failed to find WSAEnumNetworkEvents function (%u)",
+ GetLastError());
FreeLibrary(wsock2);
return CURLE_FAILED_INIT;
}
@@ -1437,7 +1436,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
/* Keep on listening and act on events */
while(keepon) {
const DWORD buf_size = (DWORD)data->set.buffer_size;
- waitret = WaitForMultipleObjects(obj_count, objs, FALSE, wait_timeout);
+ DWORD waitret = WaitForMultipleObjects(obj_count, objs,
+ FALSE, wait_timeout);
switch(waitret) {
case WAIT_TIMEOUT:
{
@@ -1458,7 +1458,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
if(n == 0) /* no bytes */
break;
- readfile_read = (DWORD)n; /* fall thru with number of bytes read */
+ /* fall through with number of bytes read */
+ readfile_read = (DWORD)n;
}
else {
/* read from stdin */
@@ -1558,8 +1559,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
}
if(data->set.timeout) {
- now = Curl_tvnow();
- if(Curl_tvdiff(now, conn->created) >= data->set.timeout) {
+ now = Curl_now();
+ if(Curl_timediff(now, conn->created) >= data->set.timeout) {
failf(data, "Time-out");
result = CURLE_OPERATION_TIMEDOUT;
keepon = FALSE;
@@ -1580,7 +1581,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
/* We called LoadLibrary, so call FreeLibrary */
if(!FreeLibrary(wsock2))
- infof(data, "FreeLibrary(wsock2) failed (%d)", ERRNO);
+ infof(data, "FreeLibrary(wsock2) failed (%u)", GetLastError());
#else
pfd[0].fd = sockfd;
pfd[0].events = POLLIN;
@@ -1605,7 +1606,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
case 0: /* timeout */
pfd[0].revents = 0;
pfd[1].revents = 0;
- /* fall through */
+ /* FALLTHROUGH */
default: /* read! */
if(pfd[0].revents & POLLIN) {
/* read data from network */
@@ -1676,8 +1677,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
} /* poll switch statement */
if(data->set.timeout) {
- now = Curl_tvnow();
- if(Curl_tvdiff(now, conn->created) >= data->set.timeout) {
+ now = Curl_now();
+ if(Curl_timediff(now, conn->created) >= data->set.timeout) {
failf(data, "Time-out");
result = CURLE_OPERATION_TIMEDOUT;
keepon = FALSE;
@@ -1691,7 +1692,7 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
}
#endif
/* mark this as "no further transfer wanted" */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
return result;
}
diff --git a/Utilities/cmcurl/lib/telnet.h b/Utilities/cmcurl/lib/telnet.h
index 419a399b7..668a78a13 100644
--- a/Utilities/cmcurl/lib/telnet.h
+++ b/Utilities/cmcurl/lib/telnet.h
@@ -26,4 +26,3 @@ extern const struct Curl_handler Curl_handler_telnet;
#endif
#endif /* HEADER_CURL_TELNET_H */
-
diff --git a/Utilities/cmcurl/lib/tftp.c b/Utilities/cmcurl/lib/tftp.c
index b2b3efe0c..289cda282 100644
--- a/Utilities/cmcurl/lib/tftp.c
+++ b/Utilities/cmcurl/lib/tftp.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -76,12 +76,12 @@
#define TFTP_OPTION_INTERVAL "timeout"
typedef enum {
- TFTP_MODE_NETASCII=0,
+ TFTP_MODE_NETASCII = 0,
TFTP_MODE_OCTET
} tftp_mode_t;
typedef enum {
- TFTP_STATE_START=0,
+ TFTP_STATE_START = 0,
TFTP_STATE_RX,
TFTP_STATE_TX,
TFTP_STATE_FIN
@@ -100,7 +100,7 @@ typedef enum {
} tftp_event_t;
typedef enum {
- TFTP_ERR_UNDEF=0,
+ TFTP_ERR_UNDEF = 0,
TFTP_ERR_NOTFOUND,
TFTP_ERR_PERM,
TFTP_ERR_DISKFULL,
@@ -181,6 +181,7 @@ const struct Curl_handler Curl_handler_tftp = {
ZERO_NULL, /* perform_getsock */
tftp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
PORT_TFTP, /* defport */
CURLPROTO_TFTP, /* protocol */
PROTOPT_NONE | PROTOPT_NOURLQUERY /* flags */
@@ -199,7 +200,7 @@ const struct Curl_handler Curl_handler_tftp = {
static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
{
time_t maxtime, timeout;
- time_t timeout_ms;
+ timediff_t timeout_ms;
bool start = (state->state == TFTP_STATE_START) ? TRUE : FALSE;
time(&state->start_time);
@@ -216,7 +217,7 @@ static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
if(start) {
maxtime = (time_t)(timeout_ms + 500) / 1000;
- state->max_time = state->start_time+maxtime;
+ state->max_time = state->start_time + maxtime;
/* Set per-block timeout to total */
timeout = maxtime;
@@ -231,7 +232,7 @@ static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
/* Compute the re-start interval to suit the timeout */
state->retry_time = (int)timeout/state->retry_max;
if(state->retry_time<1)
- state->retry_time=1;
+ state->retry_time = 1;
}
else {
@@ -240,7 +241,7 @@ static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
else
maxtime = 3600;
- state->max_time = state->start_time+maxtime;
+ state->max_time = state->start_time + maxtime;
/* Set per-block timeout to total */
timeout = maxtime;
@@ -250,15 +251,15 @@ static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
}
/* But bound the total number */
if(state->retry_max<3)
- state->retry_max=3;
+ state->retry_max = 3;
if(state->retry_max>50)
- state->retry_max=50;
+ state->retry_max = 50;
/* Compute the re-ACK interval to suit the timeout */
state->retry_time = (int)(timeout/state->retry_max);
if(state->retry_time<1)
- state->retry_time=1;
+ state->retry_time = 1;
infof(state->conn->data,
"set timeouts for state %d; Total %ld, retry %d maxtry %d\n",
@@ -320,7 +321,7 @@ static const char *tftp_option_get(const char *buf, size_t len,
return NULL;
*option = buf;
- loc += Curl_strnlen(buf+loc, len-loc);
+ loc += Curl_strnlen(buf + loc, len-loc);
loc++; /* NULL term */
if(loc > len)
@@ -450,7 +451,6 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
ssize_t senddata;
const char *mode = "octet";
char *filename;
- char buf[64];
struct Curl_easy *data = state->conn->data;
CURLcode result = CURLE_OK;
@@ -474,7 +474,7 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
/* If we are uploading, send an WRQ */
setpacketevent(&state->spacket, TFTP_EVENT_WRQ);
state->conn->data->req.upload_fromhere =
- (char *)state->spacket.data+4;
+ (char *)state->spacket.data + 4;
if(data->state.infilesize != -1)
Curl_pgrsSetUploadSize(data, data->state.infilesize);
}
@@ -485,45 +485,52 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
/* As RFC3617 describes the separator slash is not actually part of the
file name so we skip the always-present first letter of the path
string. */
- result = Curl_urldecode(data, &state->conn->data->state.path[1], 0,
+ result = Curl_urldecode(data, &state->conn->data->state.up.path[1], 0,
&filename, NULL, FALSE);
if(result)
return result;
- snprintf((char *)state->spacket.data+2,
- state->blksize,
- "%s%c%s%c", filename, '\0', mode, '\0');
+ if(strlen(filename) > (state->blksize - strlen(mode) - 4)) {
+ failf(data, "TFTP file name too long\n");
+ free(filename);
+ return CURLE_TFTP_ILLEGAL; /* too long file name field */
+ }
+
+ msnprintf((char *)state->spacket.data + 2,
+ state->blksize,
+ "%s%c%s%c", filename, '\0', mode, '\0');
sbytes = 4 + strlen(filename) + strlen(mode);
/* optional addition of TFTP options */
if(!data->set.tftp_no_options) {
+ char buf[64];
/* add tsize option */
if(data->set.upload && (data->state.infilesize != -1))
- snprintf(buf, sizeof(buf), "%" CURL_FORMAT_CURL_OFF_T,
- data->state.infilesize);
+ msnprintf(buf, sizeof(buf), "%" CURL_FORMAT_CURL_OFF_T,
+ data->state.infilesize);
else
strcpy(buf, "0"); /* the destination is large enough */
sbytes += tftp_option_add(state, sbytes,
- (char *)state->spacket.data+sbytes,
+ (char *)state->spacket.data + sbytes,
TFTP_OPTION_TSIZE);
sbytes += tftp_option_add(state, sbytes,
- (char *)state->spacket.data+sbytes, buf);
+ (char *)state->spacket.data + sbytes, buf);
/* add blksize option */
- snprintf(buf, sizeof(buf), "%d", state->requested_blksize);
+ msnprintf(buf, sizeof(buf), "%d", state->requested_blksize);
sbytes += tftp_option_add(state, sbytes,
- (char *)state->spacket.data+sbytes,
+ (char *)state->spacket.data + sbytes,
TFTP_OPTION_BLKSIZE);
sbytes += tftp_option_add(state, sbytes,
- (char *)state->spacket.data+sbytes, buf);
+ (char *)state->spacket.data + sbytes, buf);
/* add timeout option */
- snprintf(buf, sizeof(buf), "%d", state->retry_time);
+ msnprintf(buf, sizeof(buf), "%d", state->retry_time);
sbytes += tftp_option_add(state, sbytes,
- (char *)state->spacket.data+sbytes,
+ (char *)state->spacket.data + sbytes,
TFTP_OPTION_INTERVAL);
sbytes += tftp_option_add(state, sbytes,
- (char *)state->spacket.data+sbytes, buf);
+ (char *)state->spacket.data + sbytes, buf);
}
/* the typecase for the 3rd argument is mostly for systems that do
@@ -533,7 +540,8 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
state->conn->ip_addr->ai_addr,
state->conn->ip_addr->ai_addrlen);
if(senddata != (ssize_t)sbytes) {
- failf(data, "%s", Curl_strerror(state->conn, SOCKERRNO));
+ char buffer[STRERROR_LEN];
+ failf(data, "%s", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
}
free(filename);
break;
@@ -569,7 +577,7 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
/* the next blocknum is x + 1 but it needs to wrap at an unsigned 16bit
boundary */
-#define NEXT_BLOCKNUM(x) (((x)+1)&0xffff)
+#define NEXT_BLOCKNUM(x) (((x) + 1)&0xffff)
/**********************************************************
*
@@ -583,6 +591,7 @@ static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event)
ssize_t sbytes;
int rblock;
struct Curl_easy *data = state->conn->data;
+ char buffer[STRERROR_LEN];
switch(event) {
@@ -615,12 +624,12 @@ static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event)
(struct sockaddr *)&state->remote_addr,
state->remote_addrlen);
if(sbytes < 0) {
- failf(data, "%s", Curl_strerror(state->conn, SOCKERRNO));
+ failf(data, "%s", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
return CURLE_SEND_ERROR;
}
/* Check if completed (That is, a less than full packet is received) */
- if(state->rbytes < (ssize_t)state->blksize+4) {
+ if(state->rbytes < (ssize_t)state->blksize + 4) {
state->state = TFTP_STATE_FIN;
}
else {
@@ -640,7 +649,7 @@ static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event)
(struct sockaddr *)&state->remote_addr,
state->remote_addrlen);
if(sbytes < 0) {
- failf(data, "%s", Curl_strerror(state->conn, SOCKERRNO));
+ failf(data, "%s", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
return CURLE_SEND_ERROR;
}
@@ -666,7 +675,7 @@ static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event)
(struct sockaddr *)&state->remote_addr,
state->remote_addrlen);
if(sbytes<0) {
- failf(data, "%s", Curl_strerror(state->conn, SOCKERRNO));
+ failf(data, "%s", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
return CURLE_SEND_ERROR;
}
}
@@ -703,10 +712,10 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
{
struct Curl_easy *data = state->conn->data;
ssize_t sbytes;
- int rblock;
CURLcode result = CURLE_OK;
struct SingleRequest *k = &data->req;
- int cb; /* Bytes currently read */
+ size_t cb; /* Bytes currently read */
+ char buffer[STRERROR_LEN];
switch(event) {
@@ -714,7 +723,7 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
case TFTP_EVENT_OACK:
if(event == TFTP_EVENT_ACK) {
/* Ack the packet */
- rblock = getrpacketblock(&state->rpacket);
+ int rblock = getrpacketblock(&state->rpacket);
if(rblock != state->block &&
/* There's a bug in tftpd-hpa that causes it to send us an ack for
@@ -736,12 +745,13 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
else {
/* Re-send the data packet */
sbytes = sendto(state->sockfd, (void *)state->spacket.data,
- 4+state->sbytes, SEND_4TH_ARG,
+ 4 + state->sbytes, SEND_4TH_ARG,
(struct sockaddr *)&state->remote_addr,
state->remote_addrlen);
/* Check all sbytes were sent */
if(sbytes<0) {
- failf(data, "%s", Curl_strerror(state->conn, SOCKERRNO));
+ failf(data, "%s", Curl_strerror(SOCKERRNO,
+ buffer, sizeof(buffer)));
result = CURLE_SEND_ERROR;
}
}
@@ -759,7 +769,7 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
state->retries = 0;
setpacketevent(&state->spacket, TFTP_EVENT_DATA);
setpacketblock(&state->spacket, state->block);
- if(state->block > 1 && state->sbytes < (int)state->blksize) {
+ if(state->block > 1 && state->sbytes < state->blksize) {
state->state = TFTP_STATE_FIN;
return CURLE_OK;
}
@@ -769,13 +779,13 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
* data block.
* */
state->sbytes = 0;
- state->conn->data->req.upload_fromhere = (char *)state->spacket.data+4;
+ state->conn->data->req.upload_fromhere = (char *)state->spacket.data + 4;
do {
result = Curl_fillreadbuffer(state->conn, state->blksize - state->sbytes,
&cb);
if(result)
return result;
- state->sbytes += cb;
+ state->sbytes += (int)cb;
state->conn->data->req.upload_fromhere += cb;
} while(state->sbytes < state->blksize && cb != 0);
@@ -785,7 +795,7 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
state->remote_addrlen);
/* Check all sbytes were sent */
if(sbytes<0) {
- failf(data, "%s", Curl_strerror(state->conn, SOCKERRNO));
+ failf(data, "%s", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
return CURLE_SEND_ERROR;
}
/* Update the progress meter */
@@ -806,12 +816,12 @@ static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
else {
/* Re-send the data packet */
sbytes = sendto(state->sockfd, (void *)state->spacket.data,
- 4+state->sbytes, SEND_4TH_ARG,
+ 4 + state->sbytes, SEND_4TH_ARG,
(struct sockaddr *)&state->remote_addr,
state->remote_addrlen);
/* Check all sbytes were sent */
if(sbytes<0) {
- failf(data, "%s", Curl_strerror(state->conn, SOCKERRNO));
+ failf(data, "%s", Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
return CURLE_SEND_ERROR;
}
/* since this was a re-send, we remain at the still byte position */
@@ -962,7 +972,7 @@ static CURLcode tftp_disconnect(struct connectdata *conn, bool dead_connection)
static CURLcode tftp_connect(struct connectdata *conn, bool *done)
{
tftp_state_data_t *state;
- int blksize, rc;
+ int blksize;
blksize = TFTP_BLKSIZE_DEFAULT;
@@ -999,11 +1009,11 @@ static CURLcode tftp_connect(struct connectdata *conn, bool *done)
state->sockfd = state->conn->sock[FIRSTSOCKET];
state->state = TFTP_STATE_START;
state->error = TFTP_ERR_NONE;
- state->blksize = TFTP_BLKSIZE_DEFAULT;
+ state->blksize = blksize;
state->requested_blksize = blksize;
((struct sockaddr *)&state->local_addr)->sa_family =
- (unsigned short)(conn->ip_addr->ai_family);
+ (CURL_SA_FAMILY_T)(conn->ip_addr->ai_family);
tftp_set_timeouts(state);
@@ -1021,11 +1031,12 @@ static CURLcode tftp_connect(struct connectdata *conn, bool *done)
* assume uses the same IP version and thus hopefully this works for both
* IPv4 and IPv6...
*/
- rc = bind(state->sockfd, (struct sockaddr *)&state->local_addr,
- conn->ip_addr->ai_addrlen);
+ int rc = bind(state->sockfd, (struct sockaddr *)&state->local_addr,
+ conn->ip_addr->ai_addrlen);
if(rc) {
+ char buffer[STRERROR_LEN];
failf(conn->data, "bind() failed; %s",
- Curl_strerror(conn, SOCKERRNO));
+ Curl_strerror(SOCKERRNO, buffer, sizeof(buffer)));
return CURLE_COULDNT_CONNECT;
}
conn->bits.bound = TRUE;
@@ -1102,11 +1113,11 @@ static CURLcode tftp_receive_packet(struct connectdata *conn)
fromlen = sizeof(fromaddr);
state->rbytes = (int)recvfrom(state->sockfd,
(void *)state->rpacket.data,
- state->blksize+4,
+ state->blksize + 4,
0,
(struct sockaddr *)&fromaddr,
&fromlen);
- if(state->remote_addrlen==0) {
+ if(state->remote_addrlen == 0) {
memcpy(&state->remote_addr, &fromaddr, fromlen);
state->remote_addrlen = fromlen;
}
@@ -1128,7 +1139,7 @@ static CURLcode tftp_receive_packet(struct connectdata *conn)
if(state->rbytes > 4 &&
(NEXT_BLOCKNUM(state->block) == getrpacketblock(&state->rpacket))) {
result = Curl_client_write(conn, CLIENTWRITE_BODY,
- (char *)state->rpacket.data+4,
+ (char *)state->rpacket.data + 4,
state->rbytes-4);
if(result) {
tftp_state_machine(state, TFTP_EVENT_ERROR);
@@ -1141,15 +1152,18 @@ static CURLcode tftp_receive_packet(struct connectdata *conn)
case TFTP_EVENT_ERROR:
{
unsigned short error = getrpacketblock(&state->rpacket);
+ char *str = (char *)state->rpacket.data + 4;
+ size_t strn = state->rbytes - 4;
state->error = (tftp_error_t)error;
- infof(data, "%s\n", (const char *)state->rpacket.data+4);
+ if(Curl_strnlen(str, strn) < strn)
+ infof(data, "TFTP error: %s\n", str);
break;
}
case TFTP_EVENT_ACK:
break;
case TFTP_EVENT_OACK:
result = tftp_parse_option_ack(state,
- (const char *)state->rpacket.data+2,
+ (const char *)state->rpacket.data + 2,
state->rbytes-2);
if(result)
return result;
@@ -1193,7 +1207,7 @@ static long tftp_state_timeout(struct connectdata *conn, tftp_event_t *event)
state->state = TFTP_STATE_FIN;
return 0;
}
- if(current > state->rx_time+state->retry_time) {
+ if(current > state->rx_time + state->retry_time) {
if(event)
*event = TFTP_EVENT_TIMEOUT;
time(&state->rx_time); /* update even though we received nothing */
@@ -1214,7 +1228,6 @@ static long tftp_state_timeout(struct connectdata *conn, tftp_event_t *event)
**********************************************************/
static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
{
- int rc;
tftp_event_t event;
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
@@ -1234,16 +1247,17 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
*done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE;
if(*done)
/* Tell curl we're done */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
}
else {
/* no timeouts to handle, check our socket */
- rc = SOCKET_READABLE(state->sockfd, 0);
+ int rc = SOCKET_READABLE(state->sockfd, 0);
if(rc == -1) {
/* bail out */
int error = SOCKERRNO;
- failf(data, "%s", Curl_strerror(conn, error));
+ char buffer[STRERROR_LEN];
+ failf(data, "%s", Curl_strerror(error, buffer, sizeof(buffer)));
state->event = TFTP_EVENT_ERROR;
}
else if(rc != 0) {
@@ -1256,7 +1270,7 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
*done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE;
if(*done)
/* Tell curl we're done */
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
}
/* if rc == 0, then select() timed out */
}
@@ -1286,7 +1300,7 @@ static CURLcode tftp_doing(struct connectdata *conn, bool *dophase_done)
if(Curl_pgrsUpdate(conn))
result = CURLE_ABORTED_BY_CALLBACK;
else
- result = Curl_speedcheck(conn->data, Curl_tvnow());
+ result = Curl_speedcheck(conn->data, Curl_now());
}
return result;
}
@@ -1344,7 +1358,7 @@ static CURLcode tftp_do(struct connectdata *conn, bool *done)
state = (tftp_state_data_t *)conn->proto.tftpc;
if(!state)
- return CURLE_BAD_CALLING_ORDER;
+ return CURLE_TFTP_ILLEGAL;
result = tftp_perform(conn, done);
@@ -1361,18 +1375,18 @@ static CURLcode tftp_setup_connection(struct connectdata * conn)
{
struct Curl_easy *data = conn->data;
char *type;
- char command;
conn->socktype = SOCK_DGRAM; /* UDP datagram based */
/* TFTP URLs support an extension like ";mode=<typecode>" that
* we'll try to get now! */
- type = strstr(data->state.path, ";mode=");
+ type = strstr(data->state.up.path, ";mode=");
if(!type)
type = strstr(conn->host.rawalloc, ";mode=");
if(type) {
+ char command;
*type = 0; /* it was in the middle of the hostname */
command = Curl_raw_toupper(type[6]);
diff --git a/Utilities/cmcurl/lib/tftp.h b/Utilities/cmcurl/lib/tftp.h
index c2325b232..1335f64bd 100644
--- a/Utilities/cmcurl/lib/tftp.h
+++ b/Utilities/cmcurl/lib/tftp.h
@@ -26,4 +26,3 @@ extern const struct Curl_handler Curl_handler_tftp;
#endif
#endif /* HEADER_CURL_TFTP_H */
-
diff --git a/Utilities/cmcurl/lib/timeval.c b/Utilities/cmcurl/lib/timeval.c
index bed44c573..e2bd7fd14 100644
--- a/Utilities/cmcurl/lib/timeval.c
+++ b/Utilities/cmcurl/lib/timeval.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -24,31 +24,40 @@
#if defined(WIN32) && !defined(MSDOS)
-struct timeval curlx_tvnow(void)
+/* set in win32_init() */
+extern LARGE_INTEGER Curl_freq;
+extern bool Curl_isVistaOrGreater;
+
+struct curltime Curl_now(void)
{
- /*
- ** GetTickCount() is available on _all_ Windows versions from W95 up
- ** to nowadays. Returns milliseconds elapsed since last system boot,
- ** increases monotonically and wraps once 49.7 days have elapsed.
- */
- struct timeval now;
-#if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || \
- (_WIN32_WINNT < _WIN32_WINNT_VISTA)
- DWORD milliseconds = GetTickCount();
- now.tv_sec = milliseconds / 1000;
- now.tv_usec = (milliseconds % 1000) * 1000;
-#else
- ULONGLONG milliseconds = GetTickCount64();
- now.tv_sec = (long) (milliseconds / 1000);
- now.tv_usec = (long) (milliseconds % 1000) * 1000;
+ struct curltime now;
+ if(Curl_isVistaOrGreater) { /* QPC timer might have issues pre-Vista */
+ LARGE_INTEGER count;
+ QueryPerformanceCounter(&count);
+ now.tv_sec = (time_t)(count.QuadPart / Curl_freq.QuadPart);
+ now.tv_usec = (int)((count.QuadPart % Curl_freq.QuadPart) * 1000000 /
+ Curl_freq.QuadPart);
+ }
+ else {
+ /* Disable /analyze warning that GetTickCount64 is preferred */
+#if defined(_MSC_VER)
+#pragma warning(push)
+#pragma warning(disable:28159)
+#endif
+ DWORD milliseconds = GetTickCount();
+#if defined(_MSC_VER)
+#pragma warning(pop)
#endif
+ now.tv_sec = milliseconds / 1000;
+ now.tv_usec = (milliseconds % 1000) * 1000;
+ }
return now;
}
#elif defined(HAVE_CLOCK_GETTIME_MONOTONIC)
-struct timeval curlx_tvnow(void)
+struct curltime Curl_now(void)
{
/*
** clock_gettime() is granted to be increased monotonically when the
@@ -57,11 +66,30 @@ struct timeval curlx_tvnow(void)
** in any case the time starting point does not change once that the
** system has started up.
*/
+#ifdef HAVE_GETTIMEOFDAY
struct timeval now;
+#endif
+ struct curltime cnow;
struct timespec tsnow;
- if(0 == clock_gettime(CLOCK_MONOTONIC, &tsnow)) {
- now.tv_sec = tsnow.tv_sec;
- now.tv_usec = tsnow.tv_nsec / 1000;
+
+ /*
+ ** clock_gettime() may be defined by Apple's SDK as weak symbol thus
+ ** code compiles but fails during run-time if clock_gettime() is
+ ** called on unsupported OS version.
+ */
+#if defined(__APPLE__) && (HAVE_BUILTIN_AVAILABLE == 1)
+ bool have_clock_gettime = FALSE;
+ if(__builtin_available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *))
+ have_clock_gettime = TRUE;
+#endif
+
+ if(
+#if defined(__APPLE__) && (HAVE_BUILTIN_AVAILABLE == 1)
+ have_clock_gettime &&
+#endif
+ (0 == clock_gettime(CLOCK_MONOTONIC, &tsnow))) {
+ cnow.tv_sec = tsnow.tv_sec;
+ cnow.tv_usec = (unsigned int)(tsnow.tv_nsec / 1000);
}
/*
** Even when the configure process has truly detected monotonic clock
@@ -69,20 +97,54 @@ struct timeval curlx_tvnow(void)
** run-time. When this occurs simply fallback to other time source.
*/
#ifdef HAVE_GETTIMEOFDAY
- else
+ else {
(void)gettimeofday(&now, NULL);
+ cnow.tv_sec = now.tv_sec;
+ cnow.tv_usec = (unsigned int)now.tv_usec;
+ }
#else
else {
- now.tv_sec = (long)time(NULL);
- now.tv_usec = 0;
+ cnow.tv_sec = time(NULL);
+ cnow.tv_usec = 0;
}
#endif
- return now;
+ return cnow;
+}
+
+#elif defined(HAVE_MACH_ABSOLUTE_TIME)
+
+#include <stdint.h>
+#include <mach/mach_time.h>
+
+struct curltime Curl_now(void)
+{
+ /*
+ ** Monotonic timer on Mac OS is provided by mach_absolute_time(), which
+ ** returns time in Mach "absolute time units," which are platform-dependent.
+ ** To convert to nanoseconds, one must use conversion factors specified by
+ ** mach_timebase_info().
+ */
+ static mach_timebase_info_data_t timebase;
+ struct curltime cnow;
+ uint64_t usecs;
+
+ if(0 == timebase.denom)
+ (void) mach_timebase_info(&timebase);
+
+ usecs = mach_absolute_time();
+ usecs *= timebase.numer;
+ usecs /= timebase.denom;
+ usecs /= 1000;
+
+ cnow.tv_sec = usecs / 1000000;
+ cnow.tv_usec = (int)(usecs % 1000000);
+
+ return cnow;
}
#elif defined(HAVE_GETTIMEOFDAY)
-struct timeval curlx_tvnow(void)
+struct curltime Curl_now(void)
{
/*
** gettimeofday() is not granted to be increased monotonically, due to
@@ -90,54 +152,62 @@ struct timeval curlx_tvnow(void)
** forward or backward in time.
*/
struct timeval now;
+ struct curltime ret;
(void)gettimeofday(&now, NULL);
- return now;
+ ret.tv_sec = now.tv_sec;
+ ret.tv_usec = (int)now.tv_usec;
+ return ret;
}
#else
-struct timeval curlx_tvnow(void)
+struct curltime Curl_now(void)
{
/*
** time() returns the value of time in seconds since the Epoch.
*/
- struct timeval now;
- now.tv_sec = (long)time(NULL);
+ struct curltime now;
+ now.tv_sec = time(NULL);
now.tv_usec = 0;
return now;
}
#endif
+#if SIZEOF_TIME_T < 8
+#define TIME_MAX INT_MAX
+#define TIME_MIN INT_MIN
+#else
+#define TIME_MAX 9223372036854775807LL
+#define TIME_MIN -9223372036854775807LL
+#endif
+
/*
- * Make sure that the first argument is the more recent time, as otherwise
- * we'll get a weird negative time-diff back...
+ * Returns: time difference in number of milliseconds. For too large diffs it
+ * returns max value.
*
- * Returns: the time difference in number of milliseconds. For large diffs it
- * returns 0x7fffffff on 32bit time_t systems.
+ * @unittest: 1323
*/
-time_t curlx_tvdiff(struct timeval newer, struct timeval older)
+timediff_t Curl_timediff(struct curltime newer, struct curltime older)
{
-#if SIZEOF_TIME_T < 8
- /* for 32bit time_t systems, add a precaution to avoid overflow for really
- big time differences */
- time_t diff = newer.tv_sec-older.tv_sec;
- if(diff >= (0x7fffffff/1000))
- return 0x7fffffff;
-#endif
- return (newer.tv_sec-older.tv_sec)*1000+
- (time_t)(newer.tv_usec-older.tv_usec)/1000;
+ timediff_t diff = (timediff_t)newer.tv_sec-older.tv_sec;
+ if(diff >= (TIME_MAX/1000))
+ return TIME_MAX;
+ else if(diff <= (TIME_MIN/1000))
+ return TIME_MIN;
+ return diff * 1000 + (newer.tv_usec-older.tv_usec)/1000;
}
/*
- * Same as curlx_tvdiff but with full usec resolution.
- *
- * Returns: the time difference in seconds with subsecond resolution.
+ * Returns: time difference in number of microseconds. For too large diffs it
+ * returns max value.
*/
-double curlx_tvdiff_secs(struct timeval newer, struct timeval older)
+timediff_t Curl_timediff_us(struct curltime newer, struct curltime older)
{
- if(newer.tv_sec != older.tv_sec)
- return (double)(newer.tv_sec-older.tv_sec)+
- (double)(newer.tv_usec-older.tv_usec)/1000000.0;
- return (double)(newer.tv_usec-older.tv_usec)/1000000.0;
+ timediff_t diff = (timediff_t)newer.tv_sec-older.tv_sec;
+ if(diff >= (TIME_MAX/1000000))
+ return TIME_MAX;
+ else if(diff <= (TIME_MIN/1000000))
+ return TIME_MIN;
+ return diff * 1000000 + newer.tv_usec-older.tv_usec;
}
diff --git a/Utilities/cmcurl/lib/timeval.h b/Utilities/cmcurl/lib/timeval.h
index 33969354d..96867d713 100644
--- a/Utilities/cmcurl/lib/timeval.h
+++ b/Utilities/cmcurl/lib/timeval.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,14 +22,22 @@
*
***************************************************************************/
-/*
- * CAUTION: this header is designed to work when included by the app-side
- * as well as the library. Do not mix with library internals!
- */
-
#include "curl_setup.h"
-struct timeval curlx_tvnow(void);
+#if SIZEOF_TIME_T < 8
+typedef int timediff_t;
+#define CURL_FORMAT_TIMEDIFF_T "d"
+#else
+typedef curl_off_t timediff_t;
+#define CURL_FORMAT_TIMEDIFF_T CURL_FORMAT_CURL_OFF_T
+#endif
+
+struct curltime {
+ time_t tv_sec; /* seconds */
+ int tv_usec; /* microseconds */
+};
+
+struct curltime Curl_now(void);
/*
* Make sure that the first argument (t1) is the more recent time and t2 is
@@ -37,20 +45,14 @@ struct timeval curlx_tvnow(void);
*
* Returns: the time difference in number of milliseconds.
*/
-time_t curlx_tvdiff(struct timeval t1, struct timeval t2);
+timediff_t Curl_timediff(struct curltime t1, struct curltime t2);
/*
- * Same as curlx_tvdiff but with full usec resolution.
+ * Make sure that the first argument (t1) is the more recent time and t2 is
+ * the older time, as otherwise you get a weird negative time-diff back...
*
- * Returns: the time difference in seconds with subsecond resolution.
+ * Returns: the time difference in number of microseconds.
*/
-double curlx_tvdiff_secs(struct timeval t1, struct timeval t2);
-
-/* These two defines below exist to provide the older API for library
- internals only. */
-#define Curl_tvnow() curlx_tvnow()
-#define Curl_tvdiff(x,y) curlx_tvdiff(x,y)
-#define Curl_tvdiff_secs(x,y) curlx_tvdiff_secs(x,y)
+timediff_t Curl_timediff_us(struct curltime newer, struct curltime older);
#endif /* HEADER_CURL_TIMEVAL_H */
-
diff --git a/Utilities/cmcurl/lib/transfer.c b/Utilities/cmcurl/lib/transfer.c
index 43e8f64aa..514330e8c 100644
--- a/Utilities/cmcurl/lib/transfer.c
+++ b/Utilities/cmcurl/lib/transfer.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -73,21 +73,93 @@
#include "connect.h"
#include "non-ascii.h"
#include "http2.h"
+#include "mime.h"
+#include "strcase.h"
+#include "urlapi-int.h"
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"
+#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \
+ !defined(CURL_DISABLE_IMAP)
+/*
+ * checkheaders() checks the linked list of custom headers for a
+ * particular header (prefix). Provide the prefix without colon!
+ *
+ * Returns a pointer to the first matching header or NULL if none matched.
+ */
+char *Curl_checkheaders(const struct connectdata *conn,
+ const char *thisheader)
+{
+ struct curl_slist *head;
+ size_t thislen = strlen(thisheader);
+ struct Curl_easy *data = conn->data;
+
+ for(head = data->set.headers; head; head = head->next) {
+ if(strncasecompare(head->data, thisheader, thislen) &&
+ Curl_headersep(head->data[thislen]) )
+ return head->data;
+ }
+
+ return NULL;
+}
+#endif
+
+CURLcode Curl_get_upload_buffer(struct Curl_easy *data)
+{
+ if(!data->state.ulbuf) {
+ data->state.ulbuf = malloc(data->set.upload_buffer_size);
+ if(!data->state.ulbuf)
+ return CURLE_OUT_OF_MEMORY;
+ }
+ return CURLE_OK;
+}
+
+#ifndef CURL_DISABLE_HTTP
+/*
+ * This function will be called to loop through the trailers buffer
+ * until no more data is available for sending.
+ */
+static size_t Curl_trailers_read(char *buffer, size_t size, size_t nitems,
+ void *raw)
+{
+ struct Curl_easy *data = (struct Curl_easy *)raw;
+ Curl_send_buffer *trailers_buf = data->state.trailers_buf;
+ size_t bytes_left = trailers_buf->size_used-data->state.trailers_bytes_sent;
+ size_t to_copy = (size*nitems < bytes_left) ? size*nitems : bytes_left;
+ if(to_copy) {
+ memcpy(buffer,
+ &trailers_buf->buffer[data->state.trailers_bytes_sent],
+ to_copy);
+ data->state.trailers_bytes_sent += to_copy;
+ }
+ return to_copy;
+}
+
+static size_t Curl_trailers_left(void *raw)
+{
+ struct Curl_easy *data = (struct Curl_easy *)raw;
+ Curl_send_buffer *trailers_buf = data->state.trailers_buf;
+ return trailers_buf->size_used - data->state.trailers_bytes_sent;
+}
+#endif
+
/*
* This function will call the read callback to fill our buffer with data
* to upload.
*/
-CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
+CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes,
+ size_t *nreadp)
{
struct Curl_easy *data = conn->data;
- size_t buffersize = (size_t)bytes;
- int nread;
+ size_t buffersize = bytes;
+ size_t nread;
+
+ curl_read_callback readfunc = NULL;
+ void *extra_data = NULL;
+
#ifdef CURL_DOES_CONVERSIONS
bool sending_http_headers = FALSE;
@@ -101,16 +173,76 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
}
#endif
- if(data->req.upload_chunky) {
+#ifndef CURL_DISABLE_HTTP
+ if(data->state.trailers_state == TRAILERS_INITIALIZED) {
+ struct curl_slist *trailers = NULL;
+ CURLcode c;
+ int trailers_ret_code;
+
+ /* at this point we already verified that the callback exists
+ so we compile and store the trailers buffer, then proceed */
+ infof(data,
+ "Moving trailers state machine from initialized to sending.\n");
+ data->state.trailers_state = TRAILERS_SENDING;
+ data->state.trailers_buf = Curl_add_buffer_init();
+ if(!data->state.trailers_buf) {
+ failf(data, "Unable to allocate trailing headers buffer !");
+ return CURLE_OUT_OF_MEMORY;
+ }
+ data->state.trailers_bytes_sent = 0;
+ Curl_set_in_callback(data, true);
+ trailers_ret_code = data->set.trailer_callback(&trailers,
+ data->set.trailer_data);
+ Curl_set_in_callback(data, false);
+ if(trailers_ret_code == CURL_TRAILERFUNC_OK) {
+ c = Curl_http_compile_trailers(trailers, data->state.trailers_buf, data);
+ }
+ else {
+ failf(data, "operation aborted by trailing headers callback");
+ *nreadp = 0;
+ c = CURLE_ABORTED_BY_CALLBACK;
+ }
+ if(c != CURLE_OK) {
+ Curl_add_buffer_free(&data->state.trailers_buf);
+ curl_slist_free_all(trailers);
+ return c;
+ }
+ infof(data, "Successfully compiled trailers.\r\n");
+ curl_slist_free_all(trailers);
+ }
+#endif
+
+ /* if we are transmitting trailing data, we don't need to write
+ a chunk size so we skip this */
+ if(data->req.upload_chunky &&
+ data->state.trailers_state == TRAILERS_NONE) {
/* if chunked Transfer-Encoding */
buffersize -= (8 + 2 + 2); /* 32bit hex + CRLF + CRLF */
data->req.upload_fromhere += (8 + 2); /* 32bit hex + CRLF */
}
- /* this function returns a size_t, so we typecast to int to prevent warnings
- with picky compilers */
- nread = (int)data->state.fread_func(data->req.upload_fromhere, 1,
- buffersize, data->state.in);
+#ifndef CURL_DISABLE_HTTP
+ if(data->state.trailers_state == TRAILERS_SENDING) {
+ /* if we're here then that means that we already sent the last empty chunk
+ but we didn't send a final CR LF, so we sent 0 CR LF. We then start
+ pulling trailing data until we ²have no more at which point we
+ simply return to the previous point in the state machine as if
+ nothing happened.
+ */
+ readfunc = Curl_trailers_read;
+ extra_data = (void *)data;
+ }
+ else
+#endif
+ {
+ readfunc = data->state.fread_func;
+ extra_data = data->state.in;
+ }
+
+ Curl_set_in_callback(data, true);
+ nread = readfunc(data->req.upload_fromhere, 1,
+ buffersize, extra_data);
+ Curl_set_in_callback(data, false);
if(nread == CURL_READFUNC_ABORT) {
failf(data, "operation aborted by callback");
@@ -138,7 +270,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
return CURLE_OK; /* nothing was read */
}
- else if((size_t)nread > buffersize) {
+ else if(nread > buffersize) {
/* the read function returned a too large value */
*nreadp = 0;
failf(data, "read function returned funny value");
@@ -161,10 +293,10 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
here, knowing they'll become CRLFs later on.
*/
- char hexbuffer[11];
+ bool added_crlf = FALSE;
+ int hexlen = 0;
const char *endofline_native;
const char *endofline_network;
- int hexlen;
if(
#ifdef CURL_DO_LINEEND_CONV
@@ -179,43 +311,81 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
endofline_native = "\r\n";
endofline_network = "\x0d\x0a";
}
- hexlen = snprintf(hexbuffer, sizeof(hexbuffer),
- "%x%s", nread, endofline_native);
- /* move buffer pointer */
- data->req.upload_fromhere -= hexlen;
- nread += hexlen;
+ /* if we're not handling trailing data, proceed as usual */
+ if(data->state.trailers_state != TRAILERS_SENDING) {
+ char hexbuffer[11] = "";
+ hexlen = msnprintf(hexbuffer, sizeof(hexbuffer),
+ "%zx%s", nread, endofline_native);
- /* copy the prefix to the buffer, leaving out the NUL */
- memcpy(data->req.upload_fromhere, hexbuffer, hexlen);
+ /* move buffer pointer */
+ data->req.upload_fromhere -= hexlen;
+ nread += hexlen;
- /* always append ASCII CRLF to the data */
- memcpy(data->req.upload_fromhere + nread,
- endofline_network,
- strlen(endofline_network));
+ /* copy the prefix to the buffer, leaving out the NUL */
+ memcpy(data->req.upload_fromhere, hexbuffer, hexlen);
-#ifdef CURL_DOES_CONVERSIONS
- CURLcode result;
- int length;
- if(data->set.prefer_ascii) {
- /* translate the protocol and data */
- length = nread;
+ /* always append ASCII CRLF to the data unless
+ we have a valid trailer callback */
+#ifndef CURL_DISABLE_HTTP
+ if((nread-hexlen) == 0 &&
+ data->set.trailer_callback != NULL &&
+ data->state.trailers_state == TRAILERS_NONE) {
+ data->state.trailers_state = TRAILERS_INITIALIZED;
+ }
+ else
+#endif
+ {
+ memcpy(data->req.upload_fromhere + nread,
+ endofline_network,
+ strlen(endofline_network));
+ added_crlf = TRUE;
+ }
}
- else {
- /* just translate the protocol portion */
- length = strlen(hexbuffer);
+
+#ifdef CURL_DOES_CONVERSIONS
+ {
+ CURLcode result;
+ size_t length;
+ if(data->set.prefer_ascii)
+ /* translate the protocol and data */
+ length = nread;
+ else
+ /* just translate the protocol portion */
+ length = hexlen;
+ if(length) {
+ result = Curl_convert_to_network(data, data->req.upload_fromhere,
+ length);
+ /* Curl_convert_to_network calls failf if unsuccessful */
+ if(result)
+ return result;
+ }
}
- result = Curl_convert_to_network(data, data->req.upload_fromhere, length);
- /* Curl_convert_to_network calls failf if unsuccessful */
- if(result)
- return result;
#endif /* CURL_DOES_CONVERSIONS */
- if((nread - hexlen) == 0)
- /* mark this as done once this chunk is transferred */
+#ifndef CURL_DISABLE_HTTP
+ if(data->state.trailers_state == TRAILERS_SENDING &&
+ !Curl_trailers_left(data)) {
+ Curl_add_buffer_free(&data->state.trailers_buf);
+ data->state.trailers_state = TRAILERS_DONE;
+ data->set.trailer_data = NULL;
+ data->set.trailer_callback = NULL;
+ /* mark the transfer as done */
data->req.upload_done = TRUE;
+ infof(data, "Signaling end of chunked upload after trailers.\n");
+ }
+ else
+#endif
+ if((nread - hexlen) == 0 &&
+ data->state.trailers_state != TRAILERS_INITIALIZED) {
+ /* mark this as done once this chunk is transferred */
+ data->req.upload_done = TRUE;
+ infof(data,
+ "Signaling end of chunked upload via terminating chunk.\n");
+ }
- nread+=(int)strlen(endofline_native); /* for the added end of line */
+ if(added_crlf)
+ nread += strlen(endofline_network); /* for the added end of line */
}
#ifdef CURL_DOES_CONVERSIONS
else if((data->set.prefer_ascii) && (!sending_http_headers)) {
@@ -241,6 +411,7 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
CURLcode Curl_readrewind(struct connectdata *conn)
{
struct Curl_easy *data = conn->data;
+ curl_mimepart *mimepart = &data->set.mimepost;
conn->bits.rewindaftersend = FALSE; /* we rewind now */
@@ -253,14 +424,28 @@ CURLcode Curl_readrewind(struct connectdata *conn)
/* We have sent away data. If not using CURLOPT_POSTFIELDS or
CURLOPT_HTTPPOST, call app to rewind
*/
- if(data->set.postfields ||
- (data->set.httpreq == HTTPREQ_POST_FORM))
+ if(conn->handler->protocol & PROTO_FAMILY_HTTP) {
+ struct HTTP *http = data->req.protop;
+
+ if(http->sendit)
+ mimepart = http->sendit;
+ }
+ if(data->set.postfields)
; /* do nothing */
+ else if(data->set.httpreq == HTTPREQ_POST_MIME ||
+ data->set.httpreq == HTTPREQ_POST_FORM) {
+ if(Curl_mime_rewind(mimepart)) {
+ failf(data, "Cannot rewind mime/post data");
+ return CURLE_SEND_FAIL_REWIND;
+ }
+ }
else {
if(data->set.seek_func) {
int err;
+ Curl_set_in_callback(data, true);
err = (data->set.seek_func)(data->set.seek_client, 0, SEEK_SET);
+ Curl_set_in_callback(data, false);
if(err) {
failf(data, "seek callback returned error %d", (int)err);
return CURLE_SEND_FAIL_REWIND;
@@ -269,12 +454,13 @@ CURLcode Curl_readrewind(struct connectdata *conn)
else if(data->set.ioctl_func) {
curlioerr err;
+ Curl_set_in_callback(data, true);
err = (data->set.ioctl_func)(data, CURLIOCMD_RESTARTREAD,
data->set.ioctl_client);
+ Curl_set_in_callback(data, false);
infof(data, "the ioctl callback returned %d\n", (int)err);
if(err) {
- /* FIXME: convert to a human readable error message */
failf(data, "ioctl callback returned error %d", (int)err);
return CURLE_SEND_FAIL_REWIND;
}
@@ -304,7 +490,7 @@ static int data_pending(const struct connectdata *conn)
return conn->handler->protocol&(CURLPROTO_SCP|CURLPROTO_SFTP) ||
#if defined(USE_NGHTTP2)
Curl_ssl_data_pending(conn, FIRSTSOCKET) ||
- /* For HTTP/2, we may read up everything including responde body
+ /* For HTTP/2, we may read up everything including response body
with header fields in Curl_http_readwrite_headers. If no
content-length is provided, curl waits for the connection
close, which we emulate it using conn->proto.httpc.closed =
@@ -317,35 +503,6 @@ static int data_pending(const struct connectdata *conn)
#endif
}
-static void read_rewind(struct connectdata *conn,
- size_t thismuch)
-{
- DEBUGASSERT(conn->read_pos >= thismuch);
-
- conn->read_pos -= thismuch;
- conn->bits.stream_was_rewound = TRUE;
-
-#ifdef DEBUGBUILD
- {
- char buf[512 + 1];
- size_t show;
-
- show = CURLMIN(conn->buf_len - conn->read_pos, sizeof(buf)-1);
- if(conn->master_buffer) {
- memcpy(buf, conn->master_buffer + conn->read_pos, show);
- buf[show] = '\0';
- }
- else {
- buf[0] = '\0';
- }
-
- DEBUGF(infof(conn->data,
- "Buffer after stream rewind (read_pos = %zu): [%s]\n",
- conn->read_pos, buf));
- }
-#endif
-}
-
/*
* Check to see if CURLOPT_TIMECONDITION was met by comparing the time of the
* remote document with the time provided by CURLOPT_TIMEVAL
@@ -395,7 +552,6 @@ static CURLcode readwrite_data(struct Curl_easy *data,
CURLcode result = CURLE_OK;
ssize_t nread; /* number of bytes read */
size_t excess = 0; /* excess bytes read */
- bool is_empty_data = FALSE;
bool readmore = FALSE; /* used by RTP to signal for more data */
int maxloops = 100;
@@ -405,6 +561,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
/* This is where we loop until we have read everything there is to
read or we get a CURLE_AGAIN */
do {
+ bool is_empty_data = FALSE;
size_t buffersize = data->set.buffer_size;
size_t bytestoread = buffersize;
@@ -420,9 +577,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
conn->httpversion == 20) &&
#endif
k->size != -1 && !k->header) {
- /* make sure we don't read "too much" if we can help it since we
- might be pipelining and then someone else might want to read what
- follows! */
+ /* make sure we don't read too much */
curl_off_t totalleft = k->size - k->bytecount;
if(totalleft < (curl_off_t)bytestoread)
bytestoread = (size_t)totalleft;
@@ -450,7 +605,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
if(k->exp100 > EXP100_SEND_DATA)
/* set time stamp to compare with when waiting for the 100 */
- k->start100 = Curl_tvnow();
+ k->start100 = Curl_now();
}
*didwhat |= KEEP_RECV;
@@ -461,7 +616,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
if(0 < nread || is_empty_data) {
k->buf[nread] = 0;
}
- else if(0 >= nread) {
+ else {
/* if we receive 0 or less here, the server closed the connection
and we bail out from this! */
DEBUGF(infof(data, "nread <= 0, server closed connection, bailing\n"));
@@ -504,20 +659,11 @@ static CURLcode readwrite_data(struct Curl_easy *data,
/* We've stopped dealing with input, get out of the do-while loop */
if(nread > 0) {
- if(Curl_pipeline_wanted(conn->data->multi, CURLPIPE_HTTP1)) {
- infof(data,
- "Rewinding stream by : %zd"
- " bytes on url %s (zero-length body)\n",
- nread, data->state.path);
- read_rewind(conn, (size_t)nread);
- }
- else {
- infof(data,
- "Excess found in a non pipelined read:"
- " excess = %zd"
- " url = %s (zero-length body)\n",
- nread, data->state.path);
- }
+ infof(data,
+ "Excess found:"
+ " excess = %zd"
+ " url = %s (zero-length body)\n",
+ nread, data->state.up.path);
}
break;
@@ -560,7 +706,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
infof(data, "Ignoring the response-body\n");
}
if(data->state.resume_from && !k->content_range &&
- (data->set.httpreq==HTTPREQ_GET) &&
+ (data->set.httpreq == HTTPREQ_GET) &&
!k->ignorebody) {
if(k->size == data->state.resume_from) {
@@ -611,14 +757,14 @@ static CURLcode readwrite_data(struct Curl_easy *data,
if(data->set.verbose) {
if(k->badheader) {
Curl_debug(data, CURLINFO_DATA_IN, data->state.headerbuff,
- (size_t)k->hbuflen, conn);
+ (size_t)k->hbuflen);
if(k->badheader == HEADER_PARTHEADER)
Curl_debug(data, CURLINFO_DATA_IN,
- k->str, (size_t)nread, conn);
+ k->str, (size_t)nread);
}
else
Curl_debug(data, CURLINFO_DATA_IN,
- k->str, (size_t)nread, conn);
+ k->str, (size_t)nread);
}
#ifndef CURL_DISABLE_HTTP
@@ -648,19 +794,12 @@ static CURLcode readwrite_data(struct Curl_easy *data,
/* There are now possibly N number of bytes at the end of the
str buffer that weren't written to the client.
-
- We DO care about this data if we are pipelining.
Push it back to be read on the next pass. */
dataleft = conn->chunk.dataleft;
if(dataleft != 0) {
infof(conn->data, "Leftovers after chunking: %zu bytes\n",
dataleft);
- if(Curl_pipeline_wanted(conn->data->multi, CURLPIPE_HTTP1)) {
- /* only attempt the rewind if we truly are pipelining */
- infof(conn->data, "Rewinding %zu bytes\n",dataleft);
- read_rewind(conn, dataleft);
- }
}
}
/* If it returned OK, we just keep going */
@@ -668,7 +807,7 @@ static CURLcode readwrite_data(struct Curl_easy *data,
#endif /* CURL_DISABLE_HTTP */
/* Account for body content stored in the header buffer */
- if(k->badheader && !k->ignorebody) {
+ if((k->badheader == HEADER_PARTHEADER) && !k->ignorebody) {
DEBUGF(infof(data, "Increasing bytecount by %zu from hbuflen\n",
k->hbuflen));
k->bytecount += k->hbuflen;
@@ -679,25 +818,13 @@ static CURLcode readwrite_data(struct Curl_easy *data,
excess = (size_t)(k->bytecount + nread - k->maxdownload);
if(excess > 0 && !k->ignorebody) {
- if(Curl_pipeline_wanted(conn->data->multi, CURLPIPE_HTTP1)) {
- infof(data,
- "Rewinding stream by : %zu"
- " bytes on url %s (size = %" CURL_FORMAT_CURL_OFF_T
- ", maxdownload = %" CURL_FORMAT_CURL_OFF_T
- ", bytecount = %" CURL_FORMAT_CURL_OFF_T ", nread = %zd)\n",
- excess, data->state.path,
- k->size, k->maxdownload, k->bytecount, nread);
- read_rewind(conn, excess);
- }
- else {
- infof(data,
- "Excess found in a non pipelined read:"
- " excess = %zu"
- ", size = %" CURL_FORMAT_CURL_OFF_T
- ", maxdownload = %" CURL_FORMAT_CURL_OFF_T
- ", bytecount = %" CURL_FORMAT_CURL_OFF_T "\n",
- excess, k->size, k->maxdownload, k->bytecount);
- }
+ infof(data,
+ "Excess found in a read:"
+ " excess = %zu"
+ ", size = %" CURL_FORMAT_CURL_OFF_T
+ ", maxdownload = %" CURL_FORMAT_CURL_OFF_T
+ ", bytecount = %" CURL_FORMAT_CURL_OFF_T "\n",
+ excess, k->size, k->maxdownload, k->bytecount);
}
nread = (ssize_t) (k->maxdownload - k->bytecount);
@@ -737,48 +864,19 @@ static CURLcode readwrite_data(struct Curl_easy *data,
in http_chunks.c.
Make sure that ALL_CONTENT_ENCODINGS contains all the
encodings handled here. */
-#ifdef HAVE_LIBZ
- switch(conn->data->set.http_ce_skip ?
- IDENTITY : k->auto_decoding) {
- case IDENTITY:
-#endif
- /* This is the default when the server sends no
- Content-Encoding header. See Curl_readwrite_init; the
- memset() call initializes k->auto_decoding to zero. */
+ if(conn->data->set.http_ce_skip || !k->writer_stack) {
if(!k->ignorebody) {
-
#ifndef CURL_DISABLE_POP3
- if(conn->handler->protocol&PROTO_FAMILY_POP3)
+ if(conn->handler->protocol & PROTO_FAMILY_POP3)
result = Curl_pop3_write(conn, k->str, nread);
else
#endif /* CURL_DISABLE_POP3 */
-
result = Curl_client_write(conn, CLIENTWRITE_BODY, k->str,
nread);
}
-#ifdef HAVE_LIBZ
- break;
-
- case DEFLATE:
- /* Assume CLIENTWRITE_BODY; headers are not encoded. */
- if(!k->ignorebody)
- result = Curl_unencode_deflate_write(conn, k, nread);
- break;
-
- case GZIP:
- /* Assume CLIENTWRITE_BODY; headers are not encoded. */
- if(!k->ignorebody)
- result = Curl_unencode_gzip_write(conn, k, nread);
- break;
-
- default:
- failf(data, "Unrecognized content encoding type. "
- "libcurl understands `identity', `deflate' and `gzip' "
- "content encodings.");
- result = CURLE_BAD_CONTENT_ENCODING;
- break;
}
-#endif
+ else if(!k->ignorebody)
+ result = Curl_unencode_write(conn, k->writer_stack, k->str, nread);
}
k->badheader = HEADER_NORMAL; /* taken care of now */
@@ -788,10 +886,15 @@ static CURLcode readwrite_data(struct Curl_easy *data,
} /* if(!header and data to read) */
- if(conn->handler->readwrite &&
- (excess > 0 && !conn->bits.stream_was_rewound)) {
+ if(conn->handler->readwrite && excess && !conn->bits.stream_was_rewound) {
/* Parse the excess data */
k->str += nread;
+
+ if(&k->str[excess] > &k->buf[data->set.buffer_size]) {
+ /* the excess amount was too excessive(!), make sure
+ it doesn't read out of buffer */
+ excess = &k->buf[data->set.buffer_size] - k->str;
+ }
nread = (ssize_t)excess;
result = conn->handler->readwrite(data, conn, &nread, &readmore);
@@ -809,6 +912,11 @@ static CURLcode readwrite_data(struct Curl_easy *data,
k->keepon &= ~KEEP_RECV;
}
+ if(k->keepon & KEEP_RECV_PAUSE) {
+ /* this is a paused transfer */
+ break;
+ }
+
} while(data_pending(conn) && maxloops--);
if(maxloops <= 0) {
@@ -844,6 +952,26 @@ static CURLcode done_sending(struct connectdata *conn,
return CURLE_OK;
}
+#if defined(WIN32) && !defined(USE_LWIPSOCK)
+#ifndef SIO_IDEAL_SEND_BACKLOG_QUERY
+#define SIO_IDEAL_SEND_BACKLOG_QUERY 0x4004747B
+#endif
+
+static void win_update_buffer_size(curl_socket_t sockfd)
+{
+ int result;
+ ULONG ideal;
+ DWORD ideallen;
+ result = WSAIoctl(sockfd, SIO_IDEAL_SEND_BACKLOG_QUERY, 0, 0,
+ &ideal, sizeof(ideal), &ideallen, 0, 0);
+ if(result == 0) {
+ setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF,
+ (const char *)&ideal, sizeof(ideal));
+ }
+}
+#else
+#define win_update_buffer_size(x)
+#endif
/*
* Send data to upload to the server, when the socket is writable.
@@ -865,17 +993,19 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
*didwhat |= KEEP_SEND;
do {
-
/* only read more data if there's no upload data already
present in the upload buffer */
if(0 == k->upload_present) {
+ result = Curl_get_upload_buffer(data);
+ if(result)
+ return result;
/* init the "upload from here" pointer */
- k->upload_fromhere = data->state.uploadbuffer;
+ k->upload_fromhere = data->state.ulbuf;
if(!k->upload_done) {
/* HTTP pollution, this should be written nicer to become more
protocol agnostic. */
- int fillcount;
+ size_t fillcount;
struct HTTP *http = k->protop;
if((k->exp100 == EXP100_SENDING_REQUEST) &&
@@ -885,9 +1015,8 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
go into the Expect: 100 state and await such a header */
k->exp100 = EXP100_AWAITING_CONTINUE; /* wait for the header */
k->keepon &= ~KEEP_SEND; /* disable writing */
- k->start100 = Curl_tvnow(); /* timeout count starts now */
+ k->start100 = Curl_now(); /* timeout count starts now */
*didwhat &= ~KEEP_SEND; /* we didn't write anything actually */
-
/* set a timeout for the multi interface */
Curl_expire(data, data->set.expect_100_timeout, EXPIRE_100_TIMEOUT);
break;
@@ -902,11 +1031,12 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
sending_http_headers = FALSE;
}
- result = Curl_fillreadbuffer(conn, UPLOAD_BUFSIZE, &fillcount);
+ result = Curl_fillreadbuffer(conn, data->set.upload_buffer_size,
+ &fillcount);
if(result)
return result;
- nread = (ssize_t)fillcount;
+ nread = fillcount;
}
else
nread = 0; /* we're done uploading/reading */
@@ -915,7 +1045,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
/* this is a paused transfer */
break;
}
- if(nread<=0) {
+ if(nread <= 0) {
result = done_sending(conn, k);
if(result)
return result;
@@ -934,7 +1064,7 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
(data->set.crlf))) {
/* Do we need to allocate a scratch buffer? */
if(!data->state.scratch) {
- data->state.scratch = malloc(2 * data->set.buffer_size);
+ data->state.scratch = malloc(2 * data->set.upload_buffer_size);
if(!data->state.scratch) {
failf(data, "Failed to alloc scratch buffer!");
@@ -995,18 +1125,21 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
k->upload_fromhere, /* buffer pointer */
k->upload_present, /* buffer size */
&bytes_written); /* actually sent */
-
if(result)
return result;
+ win_update_buffer_size(conn->writesockfd);
+
if(data->set.verbose)
/* show the data before we change the pointer upload_fromhere */
Curl_debug(data, CURLINFO_DATA_OUT, k->upload_fromhere,
- (size_t)bytes_written, conn);
+ (size_t)bytes_written);
k->writebytecount += bytes_written;
+ Curl_pgrsSetUploadCounter(data, k->writebytecount);
- if(k->writebytecount == data->state.infilesize) {
+ if((!k->upload_chunky || k->forbidchunk) &&
+ (k->writebytecount == data->state.infilesize)) {
/* we have sent all data we were supposed to */
k->upload_done = TRUE;
infof(data, "We are completely uploaded and fine\n");
@@ -1024,7 +1157,10 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
}
else {
/* we've uploaded that buffer now */
- k->upload_fromhere = data->state.uploadbuffer;
+ result = Curl_get_upload_buffer(data);
+ if(result)
+ return result;
+ k->upload_fromhere = data->state.ulbuf;
k->upload_present = 0; /* no more bytes left */
if(k->upload_done) {
@@ -1034,7 +1170,6 @@ static CURLcode readwrite_upload(struct Curl_easy *data,
}
}
- Curl_pgrsSetUploadCounter(data, k->writebytecount);
} WHILE_FALSE; /* just to break out from! */
@@ -1055,7 +1190,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
{
struct SingleRequest *k = &data->req;
CURLcode result;
- int didwhat=0;
+ int didwhat = 0;
curl_socket_t fd_read;
curl_socket_t fd_write;
@@ -1110,13 +1245,9 @@ CURLcode Curl_readwrite(struct connectdata *conn,
return result;
}
- k->now = Curl_tvnow();
+ k->now = Curl_now();
if(didwhat) {
- /* Update read/write counters */
- if(k->bytecountp)
- *k->bytecountp = k->bytecount; /* read count */
- if(k->writebytecountp)
- *k->writebytecountp = k->writebytecount; /* write count */
+ ;
}
else {
/* no read no write, this is a timeout? */
@@ -1134,7 +1265,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
*/
- time_t ms = Curl_tvdiff(k->now, k->start100);
+ timediff_t ms = Curl_timediff(k->now, k->start100);
if(ms >= data->set.expect_100_timeout) {
/* we've waited long enough, continue anyway */
k->exp100 = EXP100_SEND_DATA;
@@ -1155,16 +1286,17 @@ CURLcode Curl_readwrite(struct connectdata *conn,
if(k->keepon) {
if(0 > Curl_timeleft(data, &k->now, FALSE)) {
if(k->size != -1) {
- failf(data, "Operation timed out after %ld milliseconds with %"
- CURL_FORMAT_CURL_OFF_T " out of %"
+ failf(data, "Operation timed out after %" CURL_FORMAT_TIMEDIFF_T
+ " milliseconds with %" CURL_FORMAT_CURL_OFF_T " out of %"
CURL_FORMAT_CURL_OFF_T " bytes received",
- Curl_tvdiff(k->now, data->progress.t_startsingle), k->bytecount,
- k->size);
+ Curl_timediff(k->now, data->progress.t_startsingle),
+ k->bytecount, k->size);
}
else {
- failf(data, "Operation timed out after %ld milliseconds with %"
- CURL_FORMAT_CURL_OFF_T " bytes received",
- Curl_tvdiff(k->now, data->progress.t_startsingle), k->bytecount);
+ failf(data, "Operation timed out after %" CURL_FORMAT_TIMEDIFF_T
+ " milliseconds with %" CURL_FORMAT_CURL_OFF_T " bytes received",
+ Curl_timediff(k->now, data->progress.t_startsingle),
+ k->bytecount);
}
return CURLE_OPERATION_TIMEDOUT;
}
@@ -1283,12 +1415,32 @@ void Curl_init_CONNECT(struct Curl_easy *data)
CURLcode Curl_pretransfer(struct Curl_easy *data)
{
CURLcode result;
- if(!data->change.url) {
+
+ if(!data->change.url && !data->set.uh) {
/* we can't do anything without URL */
failf(data, "No URL set!");
return CURLE_URL_MALFORMAT;
}
+ /* since the URL may have been redirected in a previous use of this handle */
+ if(data->change.url_alloc) {
+ /* the already set URL is allocated, free it first! */
+ Curl_safefree(data->change.url);
+ data->change.url_alloc = FALSE;
+ }
+
+ if(!data->change.url && data->set.uh) {
+ CURLUcode uc;
+ uc = curl_url_get(data->set.uh,
+ CURLUPART_URL, &data->set.str[STRING_SET_URL], 0);
+ if(uc) {
+ failf(data, "No URL set!");
+ return CURLE_URL_MALFORMAT;
+ }
+ }
+
+ data->change.url = data->set.str[STRING_SET_URL];
+
/* Init the SSL session ID cache here. We do it here since we want to do it
after the *_setopt() calls (that could specify the size of the cache) but
before any transfer takes place. */
@@ -1296,7 +1448,8 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
if(result)
return result;
- data->set.followlocation=0; /* reset the location-follow counter */
+ data->state.wildcardmatch = data->set.wildcard_enabled;
+ data->set.followlocation = 0; /* reset the location-follow counter */
data->state.this_is_a_follow = FALSE; /* reset this */
data->state.errorbuf = FALSE; /* no error has occurred */
data->state.httpversion = 0; /* don't assume any particular server version */
@@ -1309,11 +1462,14 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
if(data->set.httpreq == HTTPREQ_PUT)
data->state.infilesize = data->set.filesize;
- else {
+ else if((data->set.httpreq != HTTPREQ_GET) &&
+ (data->set.httpreq != HTTPREQ_HEAD)) {
data->state.infilesize = data->set.postfieldsize;
if(data->set.postfields && (data->state.infilesize == -1))
data->state.infilesize = (curl_off_t)strlen(data->set.postfields);
}
+ else
+ data->state.infilesize = 0;
/* If there is a list of cookie files to read, do it now! */
if(data->change.cookielist)
@@ -1338,22 +1494,17 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
#endif
Curl_initinfo(data); /* reset session-specific information "variables" */
- Curl_pgrsResetTimesSizes(data);
+ Curl_pgrsResetTransferSizes(data);
Curl_pgrsStartNow(data);
- if(data->set.timeout)
- Curl_expire(data, data->set.timeout, EXPIRE_TIMEOUT);
-
- if(data->set.connecttimeout)
- Curl_expire(data, data->set.connecttimeout, EXPIRE_CONNECTTIMEOUT);
-
/* In case the handle is re-used and an authentication method was picked
in the session we need to make sure we only use the one(s) we now
consider to be fine */
data->state.authhost.picked &= data->state.authhost.want;
data->state.authproxy.picked &= data->state.authproxy.want;
- if(data->set.wildcardmatch) {
+#ifndef CURL_DISABLE_FTP
+ if(data->state.wildcardmatch) {
struct WildcardData *wc = &data->wildcard;
if(wc->state < CURLWC_INIT) {
result = Curl_wildcard_init(wc); /* init wildcard structures */
@@ -1361,6 +1512,7 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
return CURLE_OUT_OF_MEMORY;
}
}
+#endif
}
return result;
@@ -1382,249 +1534,11 @@ CURLcode Curl_posttransfer(struct Curl_easy *data)
return CURLE_OK;
}
-#ifndef CURL_DISABLE_HTTP
-/*
- * strlen_url() returns the length of the given URL if the spaces within the
- * URL were properly URL encoded.
- */
-static size_t strlen_url(const char *url)
-{
- const unsigned char *ptr;
- size_t newlen=0;
- bool left=TRUE; /* left side of the ? */
-
- for(ptr=(unsigned char *)url; *ptr; ptr++) {
- switch(*ptr) {
- case '?':
- left=FALSE;
- /* fall through */
- default:
- if(*ptr >= 0x80)
- newlen += 2;
- newlen++;
- break;
- case ' ':
- if(left)
- newlen+=3;
- else
- newlen++;
- break;
- }
- }
- return newlen;
-}
-
-/* strcpy_url() copies a url to a output buffer and URL-encodes the spaces in
- * the source URL accordingly.
- */
-static void strcpy_url(char *output, const char *url)
-{
- /* we must add this with whitespace-replacing */
- bool left=TRUE;
- const unsigned char *iptr;
- char *optr = output;
- for(iptr = (unsigned char *)url; /* read from here */
- *iptr; /* until zero byte */
- iptr++) {
- switch(*iptr) {
- case '?':
- left=FALSE;
- /* fall through */
- default:
- if(*iptr >= 0x80) {
- snprintf(optr, 4, "%%%02x", *iptr);
- optr += 3;
- }
- else
- *optr++=*iptr;
- break;
- case ' ':
- if(left) {
- *optr++='%'; /* add a '%' */
- *optr++='2'; /* add a '2' */
- *optr++='0'; /* add a '0' */
- }
- else
- *optr++='+'; /* add a '+' here */
- break;
- }
- }
- *optr=0; /* zero terminate output buffer */
-
-}
-
-/*
- * Returns true if the given URL is absolute (as opposed to relative)
- */
-static bool is_absolute_url(const char *url)
-{
- char prot[16]; /* URL protocol string storage */
- char letter; /* used for a silly sscanf */
-
- return (2 == sscanf(url, "%15[^?&/:]://%c", prot, &letter)) ? TRUE : FALSE;
-}
-
-/*
- * Concatenate a relative URL to a base URL making it absolute.
- * URL-encodes any spaces.
- * The returned pointer must be freed by the caller unless NULL
- * (returns NULL on out of memory).
- */
-static char *concat_url(const char *base, const char *relurl)
-{
- /***
- TRY to append this new path to the old URL
- to the right of the host part. Oh crap, this is doomed to cause
- problems in the future...
- */
- char *newest;
- char *protsep;
- char *pathsep;
- size_t newlen;
-
- const char *useurl = relurl;
- size_t urllen;
-
- /* we must make our own copy of the URL to play with, as it may
- point to read-only data */
- char *url_clone=strdup(base);
-
- if(!url_clone)
- return NULL; /* skip out of this NOW */
-
- /* protsep points to the start of the host name */
- protsep=strstr(url_clone, "//");
- if(!protsep)
- protsep=url_clone;
- else
- protsep+=2; /* pass the slashes */
-
- if('/' != relurl[0]) {
- int level=0;
-
- /* First we need to find out if there's a ?-letter in the URL,
- and cut it and the right-side of that off */
- pathsep = strchr(protsep, '?');
- if(pathsep)
- *pathsep=0;
-
- /* we have a relative path to append to the last slash if there's one
- available, or if the new URL is just a query string (starts with a
- '?') we append the new one at the end of the entire currently worked
- out URL */
- if(useurl[0] != '?') {
- pathsep = strrchr(protsep, '/');
- if(pathsep)
- *pathsep=0;
- }
-
- /* Check if there's any slash after the host name, and if so, remember
- that position instead */
- pathsep = strchr(protsep, '/');
- if(pathsep)
- protsep = pathsep+1;
- else
- protsep = NULL;
-
- /* now deal with one "./" or any amount of "../" in the newurl
- and act accordingly */
-
- if((useurl[0] == '.') && (useurl[1] == '/'))
- useurl+=2; /* just skip the "./" */
-
- while((useurl[0] == '.') &&
- (useurl[1] == '.') &&
- (useurl[2] == '/')) {
- level++;
- useurl+=3; /* pass the "../" */
- }
-
- if(protsep) {
- while(level--) {
- /* cut off one more level from the right of the original URL */
- pathsep = strrchr(protsep, '/');
- if(pathsep)
- *pathsep=0;
- else {
- *protsep=0;
- break;
- }
- }
- }
- }
- else {
- /* We got a new absolute path for this server */
-
- if((relurl[0] == '/') && (relurl[1] == '/')) {
- /* the new URL starts with //, just keep the protocol part from the
- original one */
- *protsep=0;
- useurl = &relurl[2]; /* we keep the slashes from the original, so we
- skip the new ones */
- }
- else {
- /* cut off the original URL from the first slash, or deal with URLs
- without slash */
- pathsep = strchr(protsep, '/');
- if(pathsep) {
- /* When people use badly formatted URLs, such as
- "http://www.url.com?dir=/home/daniel" we must not use the first
- slash, if there's a ?-letter before it! */
- char *sep = strchr(protsep, '?');
- if(sep && (sep < pathsep))
- pathsep = sep;
- *pathsep=0;
- }
- else {
- /* There was no slash. Now, since we might be operating on a badly
- formatted URL, such as "http://www.url.com?id=2380" which doesn't
- use a slash separator as it is supposed to, we need to check for a
- ?-letter as well! */
- pathsep = strchr(protsep, '?');
- if(pathsep)
- *pathsep=0;
- }
- }
- }
-
- /* If the new part contains a space, this is a mighty stupid redirect
- but we still make an effort to do "right". To the left of a '?'
- letter we replace each space with %20 while it is replaced with '+'
- on the right side of the '?' letter.
- */
- newlen = strlen_url(useurl);
-
- urllen = strlen(url_clone);
-
- newest = malloc(urllen + 1 + /* possible slash */
- newlen + 1 /* zero byte */);
-
- if(!newest) {
- free(url_clone); /* don't leak this */
- return NULL;
- }
-
- /* copy over the root url part */
- memcpy(newest, url_clone, urllen);
-
- /* check if we need to append a slash */
- if(('/' == useurl[0]) || (protsep && !*protsep) || ('?' == useurl[0]))
- ;
- else
- newest[urllen++]='/';
-
- /* then append the new piece on the right side */
- strcpy_url(&newest[urllen], useurl);
-
- free(url_clone);
-
- return newest;
-}
-#endif /* CURL_DISABLE_HTTP */
-
/*
* Curl_follow() handles the URL redirect magic. Pass in the 'newurl' string
* as given by the remote server and set up the new URL to request.
+ *
+ * This function DOES NOT FREE the given url.
*/
CURLcode Curl_follow(struct Curl_easy *data,
char *newurl, /* the Location: string */
@@ -1641,6 +1555,7 @@ CURLcode Curl_follow(struct Curl_easy *data,
/* Location: redirect */
bool disallowport = FALSE;
bool reachedmax = FALSE;
+ CURLUcode uc;
if(type == FOLLOW_REDIR) {
if((data->set.maxredirs != -1) &&
@@ -1673,31 +1588,28 @@ CURLcode Curl_follow(struct Curl_easy *data,
}
}
- if(!is_absolute_url(newurl)) {
- /***
- *DANG* this is an RFC 2068 violation. The URL is supposed
- to be absolute and this doesn't seem to be that!
- */
- char *absolute = concat_url(data->change.url, newurl);
- if(!absolute)
- return CURLE_OUT_OF_MEMORY;
- newurl = absolute;
- }
- else {
- /* The new URL MAY contain space or high byte values, that means a mighty
- stupid redirect URL but we still make an effort to do "right". */
- char *newest;
- size_t newlen = strlen_url(newurl);
-
+ if(Curl_is_absolute_url(newurl, NULL, MAX_SCHEME_LEN))
/* This is an absolute URL, don't allow the custom port number */
disallowport = TRUE;
- newest = malloc(newlen+1); /* get memory for this */
- if(!newest)
+ DEBUGASSERT(data->state.uh);
+ uc = curl_url_set(data->state.uh, CURLUPART_URL, newurl,
+ (type == FOLLOW_FAKE) ? CURLU_NON_SUPPORT_SCHEME : 0);
+ if(uc) {
+ if(type != FOLLOW_FAKE)
+ return Curl_uc_to_curlcode(uc);
+
+ /* the URL could not be parsed for some reason, but since this is FAKE
+ mode, just duplicate the field as-is */
+ newurl = strdup(newurl);
+ if(!newurl)
return CURLE_OUT_OF_MEMORY;
- strcpy_url(newest, newurl); /* create a space-free URL */
- newurl = newest; /* use this instead now */
+ }
+ else {
+ uc = curl_url_get(data->state.uh, CURLUPART_URL, &newurl, 0);
+ if(uc)
+ return Curl_uc_to_curlcode(uc);
}
if(type == FOLLOW_FAKE) {
@@ -1715,10 +1627,8 @@ CURLcode Curl_follow(struct Curl_easy *data,
if(disallowport)
data->state.allow_port = FALSE;
- if(data->change.url_alloc) {
+ if(data->change.url_alloc)
Curl_safefree(data->change.url);
- data->change.url_alloc = FALSE;
- }
data->change.url = newurl;
data->change.url_alloc = TRUE;
@@ -1763,7 +1673,8 @@ CURLcode Curl_follow(struct Curl_easy *data,
* can be overridden with CURLOPT_POSTREDIR.
*/
if((data->set.httpreq == HTTPREQ_POST
- || data->set.httpreq == HTTPREQ_POST_FORM)
+ || data->set.httpreq == HTTPREQ_POST_FORM
+ || data->set.httpreq == HTTPREQ_POST_MIME)
&& !(data->set.keep_post & CURL_REDIR_POST_301)) {
infof(data, "Switch from POST to GET\n");
data->set.httpreq = HTTPREQ_GET;
@@ -1787,7 +1698,8 @@ CURLcode Curl_follow(struct Curl_easy *data,
* can be overridden with CURLOPT_POSTREDIR.
*/
if((data->set.httpreq == HTTPREQ_POST
- || data->set.httpreq == HTTPREQ_POST_FORM)
+ || data->set.httpreq == HTTPREQ_POST_FORM
+ || data->set.httpreq == HTTPREQ_POST_MIME)
&& !(data->set.keep_post & CURL_REDIR_POST_302)) {
infof(data, "Switch from POST to GET\n");
data->set.httpreq = HTTPREQ_GET;
@@ -1820,7 +1732,7 @@ CURLcode Curl_follow(struct Curl_easy *data,
break;
}
Curl_pgrsTime(data, TIMER_REDIRECT);
- Curl_pgrsResetTimesSizes(data);
+ Curl_pgrsResetTransferSizes(data);
return CURLE_OK;
#endif /* CURL_DISABLE_HTTP */
@@ -1833,7 +1745,7 @@ CURLcode Curl_retry_request(struct connectdata *conn,
char **url)
{
struct Curl_easy *data = conn->data;
-
+ bool retry = FALSE;
*url = NULL;
/* if we're talking upload, we can't do the checks below, unless the protocol
@@ -1846,7 +1758,7 @@ CURLcode Curl_retry_request(struct connectdata *conn,
conn->bits.reuse &&
(!data->set.opt_no_body
|| (conn->handler->protocol & PROTO_FAMILY_HTTP)) &&
- (data->set.rtspreq != RTSPREQ_RECEIVE)) {
+ (data->set.rtspreq != RTSPREQ_RECEIVE))
/* We got no data, we attempted to re-use a connection. For HTTP this
can be a retry so we try again regardless if we expected a body.
For other protocols we only try again only if we expected a body.
@@ -1854,6 +1766,19 @@ CURLcode Curl_retry_request(struct connectdata *conn,
This might happen if the connection was left alive when we were
done using it before, but that was closed when we wanted to read from
it again. Bad luck. Retry the same request on a fresh connect! */
+ retry = TRUE;
+ else if(data->state.refused_stream &&
+ (data->req.bytecount + data->req.headerbytecount == 0) ) {
+ /* This was sent on a refused stream, safe to rerun. A refused stream
+ error can typically only happen on HTTP/2 level if the stream is safe
+ to issue again, but the nghttp2 API can deliver the message to other
+ streams as well, which is why this adds the check the data counters
+ too. */
+ infof(conn->data, "REFUSED_STREAM, retrying a fresh connect\n");
+ data->state.refused_stream = FALSE; /* clear again */
+ retry = TRUE;
+ }
+ if(retry) {
infof(conn->data, "Connection died, retrying a fresh connect\n");
*url = strdup(conn->data->change.url);
if(!*url)
@@ -1868,9 +1793,13 @@ CURLcode Curl_retry_request(struct connectdata *conn,
if(conn->handler->protocol&PROTO_FAMILY_HTTP) {
- struct HTTP *http = data->req.protop;
- if(http->writebytecount)
- return Curl_readrewind(conn);
+ if(data->req.writebytecount) {
+ CURLcode result = Curl_readrewind(conn);
+ if(result) {
+ Curl_safefree(*url);
+ return result;
+ }
+ }
}
}
return CURLE_OK;
@@ -1882,36 +1811,35 @@ CURLcode Curl_retry_request(struct connectdata *conn,
*/
void
Curl_setup_transfer(
- struct connectdata *conn, /* connection data */
+ struct Curl_easy *data, /* transfer */
int sockindex, /* socket index to read from or -1 */
curl_off_t size, /* -1 if unknown at this point */
bool getheader, /* TRUE if header parsing is wanted */
- curl_off_t *bytecountp, /* return number of bytes read or NULL */
- int writesockindex, /* socket index to write to, it may very well be
+ int writesockindex /* socket index to write to, it may very well be
the same we read from. -1 disables */
- curl_off_t *writecountp /* return number of bytes written or NULL */
)
{
- struct Curl_easy *data;
- struct SingleRequest *k;
-
+ struct SingleRequest *k = &data->req;
+ struct connectdata *conn = data->conn;
DEBUGASSERT(conn != NULL);
-
- data = conn->data;
- k = &data->req;
-
DEBUGASSERT((sockindex <= 1) && (sockindex >= -1));
- /* now copy all input parameters */
- conn->sockfd = sockindex == -1 ?
+ if(conn->bits.multiplex || conn->httpversion == 20) {
+ /* when multiplexing, the read/write sockets need to be the same! */
+ conn->sockfd = sockindex == -1 ?
+ ((writesockindex == -1 ? CURL_SOCKET_BAD : conn->sock[writesockindex])) :
+ conn->sock[sockindex];
+ conn->writesockfd = conn->sockfd;
+ }
+ else {
+ conn->sockfd = sockindex == -1 ?
CURL_SOCKET_BAD : conn->sock[sockindex];
- conn->writesockfd = writesockindex == -1 ?
+ conn->writesockfd = writesockindex == -1 ?
CURL_SOCKET_BAD:conn->sock[writesockindex];
+ }
k->getheader = getheader;
k->size = size;
- k->bytecountp = bytecountp;
- k->writebytecountp = writecountp;
/* The code sequence below is placed in this function just because all
necessary input is not always known in do_complete() as this function may
@@ -1925,10 +1853,10 @@ Curl_setup_transfer(
/* we want header and/or body, if neither then don't do this! */
if(k->getheader || !data->set.opt_no_body) {
- if(conn->sockfd != CURL_SOCKET_BAD)
+ if(sockindex != -1)
k->keepon |= KEEP_RECV;
- if(conn->writesockfd != CURL_SOCKET_BAD) {
+ if(writesockindex != -1) {
struct HTTP *http = data->req.protop;
/* HTTP 1.1 magic:
@@ -1944,7 +1872,7 @@ Curl_setup_transfer(
(http->sending == HTTPSEND_BODY)) {
/* wait with write until we either got 100-continue or a timeout */
k->exp100 = EXP100_AWAITING_CONTINUE;
- k->start100 = Curl_tvnow();
+ k->start100 = Curl_now();
/* Set a timeout for the multi interface. Add the inaccuracy margin so
that we don't fire slightly too early and get denied to run. */
@@ -1959,7 +1887,7 @@ Curl_setup_transfer(
/* enable the write bit when we're not waiting for continue */
k->keepon |= KEEP_SEND;
}
- } /* if(conn->writesockfd != CURL_SOCKET_BAD) */
+ } /* if(writesockindex != -1) */
} /* if(k->getheader || !data->set.opt_no_body) */
}
diff --git a/Utilities/cmcurl/lib/transfer.h b/Utilities/cmcurl/lib/transfer.h
index 518967260..a9bff6348 100644
--- a/Utilities/cmcurl/lib/transfer.h
+++ b/Utilities/cmcurl/lib/transfer.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,6 +22,10 @@
*
***************************************************************************/
+#define Curl_headersep(x) ((((x)==':') || ((x)==';')))
+char *Curl_checkheaders(const struct connectdata *conn,
+ const char *thisheader);
+
void Curl_init_CONNECT(struct Curl_easy *data);
CURLcode Curl_pretransfer(struct Curl_easy *data);
@@ -47,22 +51,21 @@ int Curl_single_getsock(const struct connectdata *conn,
curl_socket_t *socks,
int numsocks);
CURLcode Curl_readrewind(struct connectdata *conn);
-CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp);
+CURLcode Curl_fillreadbuffer(struct connectdata *conn, size_t bytes,
+ size_t *nreadp);
CURLcode Curl_retry_request(struct connectdata *conn, char **url);
bool Curl_meets_timecondition(struct Curl_easy *data, time_t timeofdoc);
+CURLcode Curl_get_upload_buffer(struct Curl_easy *data);
/* This sets up a forthcoming transfer */
void
-Curl_setup_transfer (struct connectdata *data,
- int sockindex, /* socket index to read from or -1 */
- curl_off_t size, /* -1 if unknown at this point */
- bool getheader, /* TRUE if header parsing is wanted */
- curl_off_t *bytecountp, /* return number of bytes read */
- int writesockindex, /* socket index to write to, it may
- very well be the same we read from.
- -1 disables */
- curl_off_t *writecountp /* return number of bytes written */
-);
+Curl_setup_transfer (struct Curl_easy *data,
+ int sockindex, /* socket index to read from or -1 */
+ curl_off_t size, /* -1 if unknown at this point */
+ bool getheader, /* TRUE if header parsing is wanted */
+ int writesockindex /* socket index to write to. May be
+ the same we read from. -1
+ disables */
+ );
#endif /* HEADER_CURL_TRANSFER_H */
-
diff --git a/Utilities/cmcurl/lib/url.c b/Utilities/cmcurl/lib/url.c
index 87446dbca..c441ae716 100644
--- a/Utilities/cmcurl/lib/url.c
+++ b/Utilities/cmcurl/lib/url.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -55,9 +55,7 @@
#error "We can't compile without socket() support!"
#endif
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#ifdef USE_LIBIDN2
#include <idn2.h>
@@ -71,6 +69,7 @@ bool curl_win32_idn_to_ascii(const char *in, char **out);
#include "netrc.h"
#include "formdata.h"
+#include "mime.h"
#include "vtls/vtls.h"
#include "hostip.h"
#include "transfer.h"
@@ -93,6 +92,7 @@ bool curl_win32_idn_to_ascii(const char *in, char **out);
#include "non-ascii.h"
#include "inet_pton.h"
#include "getinfo.h"
+#include "urlapi-int.h"
/* And now for the protocols */
#include "ftp.h"
@@ -109,41 +109,26 @@ bool curl_win32_idn_to_ascii(const char *in, char **out);
#include "connect.h"
#include "inet_ntop.h"
#include "http_ntlm.h"
-#include "curl_ntlm_wb.h"
#include "socks.h"
#include "curl_rtmp.h"
#include "gopher.h"
#include "http_proxy.h"
#include "conncache.h"
#include "multihandle.h"
-#include "pipeline.h"
#include "dotdot.h"
#include "strdup.h"
+#include "setopt.h"
+#include "altsvc.h"
+
/* The last 3 #include files should be in this order */
#include "curl_printf.h"
#include "curl_memory.h"
#include "memdebug.h"
-/* Local static prototypes */
-static struct connectdata *
-find_oldest_idle_connection_in_bundle(struct Curl_easy *data,
- struct connectbundle *bundle);
static void conn_free(struct connectdata *conn);
-static void free_fixed_hostname(struct hostname *host);
-static void signalPipeClose(struct curl_llist *pipeline, bool pipe_broke);
-static CURLcode parse_url_login(struct Curl_easy *data,
- struct connectdata *conn,
- char **userptr, char **passwdptr,
- char **optionsptr);
-static CURLcode parse_login_details(const char *login, const size_t len,
- char **userptr, char **passwdptr,
- char **optionsptr);
+static void free_idnconverted_hostname(struct hostname *host);
static unsigned int get_protocol_family(unsigned int protocol);
-#define READBUFFER_SIZE CURL_MAX_WRITE_SIZE
-#define READBUFFER_MAX CURL_MAX_READ_SIZE
-#define READBUFFER_MIN 1024
-
/* Some parts of the code (e.g. chunked encoding) assume this buffer has at
* more than just a few bytes to play with. Don't let it become too small or
* bad things will happen.
@@ -200,8 +185,11 @@ static const struct Curl_handler * const protocols[] = {
&Curl_handler_tftp,
#endif
-#ifdef USE_LIBSSH2
+#if defined(USE_SSH)
&Curl_handler_scp,
+#endif
+
+#if defined(USE_SSH)
&Curl_handler_sftp,
#endif
@@ -274,6 +262,7 @@ static const struct Curl_handler Curl_handler_dummy = {
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
+ ZERO_NULL, /* connection_check */
0, /* defport */
0, /* protocol */
PROTOPT_NONE /* flags */
@@ -283,7 +272,7 @@ void Curl_freeset(struct Curl_easy *data)
{
/* Free all dynamic strings stored in the data->set substructure. */
enum dupstring i;
- for(i=(enum dupstring)0; i < STRING_LAST; i++) {
+ for(i = (enum dupstring)0; i < STRING_LAST; i++) {
Curl_safefree(data->set.str[i]);
}
@@ -297,98 +286,24 @@ void Curl_freeset(struct Curl_easy *data)
data->change.url_alloc = FALSE;
}
data->change.url = NULL;
-}
-
-static CURLcode setstropt(char **charp, const char *s)
-{
- /* Release the previous storage at `charp' and replace by a dynamic storage
- copy of `s'. Return CURLE_OK or CURLE_OUT_OF_MEMORY. */
-
- Curl_safefree(*charp);
-
- if(s) {
- char *str = strdup(s);
-
- if(!str)
- return CURLE_OUT_OF_MEMORY;
-
- *charp = str;
- }
- return CURLE_OK;
+ Curl_mime_cleanpart(&data->set.mimepost);
}
-static CURLcode setstropt_userpwd(char *option, char **userp, char **passwdp)
+/* free the URL pieces */
+static void up_free(struct Curl_easy *data)
{
- CURLcode result = CURLE_OK;
- char *user = NULL;
- char *passwd = NULL;
-
- /* Parse the login details if specified. It not then we treat NULL as a hint
- to clear the existing data */
- if(option) {
- result = parse_login_details(option, strlen(option),
- (userp ? &user : NULL),
- (passwdp ? &passwd : NULL),
- NULL);
- }
-
- if(!result) {
- /* Store the username part of option if required */
- if(userp) {
- if(!user && option && option[0] == ':') {
- /* Allocate an empty string instead of returning NULL as user name */
- user = strdup("");
- if(!user)
- result = CURLE_OUT_OF_MEMORY;
- }
-
- Curl_safefree(*userp);
- *userp = user;
- }
-
- /* Store the password part of option if required */
- if(passwdp) {
- Curl_safefree(*passwdp);
- *passwdp = passwd;
- }
- }
-
- return result;
-}
-
-CURLcode Curl_dupset(struct Curl_easy *dst, struct Curl_easy *src)
-{
- CURLcode result = CURLE_OK;
- enum dupstring i;
-
- /* Copy src->set into dst->set first, then deal with the strings
- afterwards */
- dst->set = src->set;
-
- /* clear all string pointers first */
- memset(dst->set.str, 0, STRING_LAST * sizeof(char *));
-
- /* duplicate all strings */
- for(i=(enum dupstring)0; i< STRING_LASTZEROTERMINATED; i++) {
- result = setstropt(&dst->set.str[i], src->set.str[i]);
- if(result)
- return result;
- }
-
- /* duplicate memory areas pointed to */
- i = STRING_COPYPOSTFIELDS;
- if(src->set.postfieldsize && src->set.str[i]) {
- /* postfieldsize is curl_off_t, Curl_memdup() takes a size_t ... */
- dst->set.str[i] = Curl_memdup(src->set.str[i],
- curlx_sotouz(src->set.postfieldsize));
- if(!dst->set.str[i])
- return CURLE_OUT_OF_MEMORY;
- /* point to the new copy */
- dst->set.postfields = dst->set.str[i];
- }
-
- return CURLE_OK;
+ struct urlpieces *up = &data->state.up;
+ Curl_safefree(up->scheme);
+ Curl_safefree(up->hostname);
+ Curl_safefree(up->port);
+ Curl_safefree(up->user);
+ Curl_safefree(up->password);
+ Curl_safefree(up->options);
+ Curl_safefree(up->path);
+ Curl_safefree(up->query);
+ curl_url_cleanup(data->state.uh);
+ data->state.uh = NULL;
}
/*
@@ -410,16 +325,17 @@ CURLcode Curl_close(struct Curl_easy *data)
Curl_expire_clear(data); /* shut off timers */
m = data->multi;
-
if(m)
/* This handle is still part of a multi handle, take care of this first
and detach this handle from there. */
curl_multi_remove_handle(data->multi, data);
- if(data->multi_easy)
+ if(data->multi_easy) {
/* when curl_easy_perform() is used, it creates its own multi handle to
use and this is the one */
curl_multi_cleanup(data->multi_easy);
+ data->multi_easy = NULL;
+ }
/* Destroy the timeout list that is held in the easy handle. It is
/normally/ done by curl_multi_remove_handle() but this is "just in
@@ -433,10 +349,6 @@ CURLcode Curl_close(struct Curl_easy *data)
if(data->state.rangestringalloc)
free(data->state.range);
- /* Free the pathbuffer */
- Curl_safefree(data->state.pathbuffer);
- data->state.path = NULL;
-
/* freed here just in case DONE wasn't called */
Curl_free_request_state(data);
@@ -456,19 +368,19 @@ CURLcode Curl_close(struct Curl_easy *data)
}
data->change.referer = NULL;
- if(data->change.url_alloc) {
- Curl_safefree(data->change.url);
- data->change.url_alloc = FALSE;
- }
- data->change.url = NULL;
-
+ up_free(data);
Curl_safefree(data->state.buffer);
Curl_safefree(data->state.headerbuff);
-
+ Curl_safefree(data->state.ulbuf);
Curl_flush_cookies(data, 1);
-
- Curl_digest_cleanup(data);
-
+#ifdef USE_ALTSVC
+ Curl_altsvc_save(data->asi, data->set.str[STRING_ALTSVC]);
+ Curl_altsvc_cleanup(data->asi);
+ data->asi = NULL;
+#endif
+#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_CRYPTO_AUTH)
+ Curl_http_auth_cleanup_digest(data);
+#endif
Curl_safefree(data->info.contenttype);
Curl_safefree(data->info.wouldredirect);
@@ -485,12 +397,8 @@ CURLcode Curl_close(struct Curl_easy *data)
Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
}
- if(data->set.wildcardmatch) {
- /* destruct wildcard structures if it is needed */
- struct WildcardData *wc = &data->wildcard;
- Curl_wildcard_dtor(wc);
- }
-
+ /* destruct wildcard structures if it is needed */
+ Curl_wildcard_dtor(&data->wildcard);
Curl_freeset(data);
free(data);
return CURLE_OK;
@@ -500,8 +408,9 @@ CURLcode Curl_close(struct Curl_easy *data)
* Initialize the UserDefined fields within a Curl_easy.
* This may be safely called on a new or existing Curl_easy.
*/
-CURLcode Curl_init_userdefined(struct UserDefined *set)
+CURLcode Curl_init_userdefined(struct Curl_easy *data)
{
+ struct UserDefined *set = &data->set;
CURLcode result = CURLE_OK;
set->out = stdout; /* default output to stdout */
@@ -530,11 +439,12 @@ CURLcode Curl_init_userdefined(struct UserDefined *set)
set->httpreq = HTTPREQ_GET; /* Default HTTP request */
set->rtspreq = RTSPREQ_OPTIONS; /* Default RTSP request */
+#ifndef CURL_DISABLE_FILE
set->ftp_use_epsv = TRUE; /* FTP defaults to EPSV operations */
set->ftp_use_eprt = TRUE; /* FTP defaults to EPRT operations */
set->ftp_use_pret = FALSE; /* mainly useful for drftpd servers */
set->ftp_filemethod = FTPFILE_MULTICWD;
-
+#endif
set->dns_cache_timeout = 60; /* Timeout every 60 seconds by default */
/* Set the default size of the SSL session ID cache */
@@ -545,9 +455,14 @@ CURLcode Curl_init_userdefined(struct UserDefined *set)
set->httpauth = CURLAUTH_BASIC; /* defaults to basic */
set->proxyauth = CURLAUTH_BASIC; /* defaults to basic */
+ /* SOCKS5 proxy auth defaults to username/password + GSS-API */
+ set->socks5auth = CURLAUTH_BASIC | CURLAUTH_GSSAPI;
+
/* make libcurl quiet by default: */
set->hide_progress = TRUE; /* CURLOPT_NOPROGRESS changes these */
+ Curl_mime_initpart(&set->mimepost, data);
+
/*
* libcurl 7.10 introduced SSL verification *by default*! This needs to be
* switched off unless wanted.
@@ -582,46 +497,61 @@ CURLcode Curl_init_userdefined(struct UserDefined *set)
set->socks5_gssapi_nec = FALSE;
#endif
- /* This is our preferred CA cert bundle/path since install time */
+ /* Set the default CA cert bundle/path detected/specified at build time.
+ *
+ * If Schannel is the selected SSL backend then these locations are
+ * ignored. We allow setting CA location for schannel only when explicitly
+ * specified by the user via CURLOPT_CAINFO / --cacert.
+ */
+ if(Curl_ssl_backend() != CURLSSLBACKEND_SCHANNEL) {
#if defined(CURL_CA_BUNDLE)
- result = setstropt(&set->str[STRING_SSL_CAFILE_ORIG], CURL_CA_BUNDLE);
- if(result)
- return result;
+ result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_ORIG], CURL_CA_BUNDLE);
+ if(result)
+ return result;
- result = setstropt(&set->str[STRING_SSL_CAFILE_PROXY], CURL_CA_BUNDLE);
- if(result)
- return result;
+ result = Curl_setstropt(&set->str[STRING_SSL_CAFILE_PROXY],
+ CURL_CA_BUNDLE);
+ if(result)
+ return result;
#endif
#if defined(CURL_CA_PATH)
- result = setstropt(&set->str[STRING_SSL_CAPATH_ORIG], CURL_CA_PATH);
- if(result)
- return result;
+ result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_ORIG], CURL_CA_PATH);
+ if(result)
+ return result;
- result = setstropt(&set->str[STRING_SSL_CAPATH_PROXY], CURL_CA_PATH);
- if(result)
- return result;
+ result = Curl_setstropt(&set->str[STRING_SSL_CAPATH_PROXY], CURL_CA_PATH);
+ if(result)
+ return result;
#endif
+ }
- set->wildcardmatch = FALSE;
+ set->wildcard_enabled = FALSE;
set->chunk_bgn = ZERO_NULL;
set->chunk_end = ZERO_NULL;
-
- /* tcp keepalives are disabled by default, but provide reasonable values for
- * the interval and idle times.
- */
set->tcp_keepalive = FALSE;
set->tcp_keepintvl = 60;
set->tcp_keepidle = 60;
set->tcp_fastopen = FALSE;
set->tcp_nodelay = TRUE;
-
set->ssl_enable_npn = TRUE;
set->ssl_enable_alpn = TRUE;
-
set->expect_100_timeout = 1000L; /* Wait for a second by default. */
set->sep_headers = TRUE; /* separated header lists by default */
set->buffer_size = READBUFFER_SIZE;
-
+ set->upload_buffer_size = UPLOADBUFFER_DEFAULT;
+ set->happy_eyeballs_timeout = CURL_HET_DEFAULT;
+ set->fnmatch = ZERO_NULL;
+ set->upkeep_interval_ms = CURL_UPKEEP_INTERVAL_DEFAULT;
+ set->maxconnects = DEFAULT_CONNCACHE_SIZE; /* for easy handles */
+ set->maxage_conn = 118;
+ set->http09_allowed = TRUE;
+ set->httpversion =
+#ifdef USE_NGHTTP2
+ CURL_HTTP_VERSION_2TLS
+#else
+ CURL_HTTP_VERSION_1_1
+#endif
+ ;
Curl_http2_init_userset(set);
return result;
}
@@ -649,7 +579,7 @@ CURLcode Curl_open(struct Curl_easy **curl)
data->magic = CURLEASY_MAGIC_NUMBER;
- result = Curl_resolver_init(&data->state.resolver);
+ result = Curl_resolver_init(data, &data->state.resolver);
if(result) {
DEBUGF(fprintf(stderr, "Error: resolver_init failed\n"));
free(data);
@@ -663,30 +593,27 @@ CURLcode Curl_open(struct Curl_easy **curl)
DEBUGF(fprintf(stderr, "Error: malloc of buffer failed\n"));
result = CURLE_OUT_OF_MEMORY;
}
-
- data->state.headerbuff = malloc(HEADERSIZE);
- if(!data->state.headerbuff) {
- DEBUGF(fprintf(stderr, "Error: malloc of headerbuff failed\n"));
- result = CURLE_OUT_OF_MEMORY;
- }
else {
- result = Curl_init_userdefined(&data->set);
-
- data->state.headersize=HEADERSIZE;
-
- Curl_convert_init(data);
+ data->state.headerbuff = malloc(HEADERSIZE);
+ if(!data->state.headerbuff) {
+ DEBUGF(fprintf(stderr, "Error: malloc of headerbuff failed\n"));
+ result = CURLE_OUT_OF_MEMORY;
+ }
+ else {
+ result = Curl_init_userdefined(data);
- Curl_initinfo(data);
+ data->state.headersize = HEADERSIZE;
+ Curl_convert_init(data);
+ Curl_initinfo(data);
- /* most recent connection is not yet defined */
- data->state.lastconnect = NULL;
+ /* most recent connection is not yet defined */
+ data->state.lastconnect = NULL;
- data->progress.flags |= PGRS_HIDE;
- data->state.current_speed = -1; /* init to negative == impossible */
- data->set.fnmatch = ZERO_NULL;
- data->set.maxconnects = DEFAULT_CONNCACHE_SIZE; /* for easy handles */
+ data->progress.flags |= PGRS_HIDE;
+ data->state.current_speed = -1; /* init to negative == impossible */
- Curl_http2_init_state(&data->state);
+ Curl_http2_init_state(&data->state);
+ }
}
if(result) {
@@ -703,2235 +630,6 @@ CURLcode Curl_open(struct Curl_easy **curl)
return result;
}
-#define C_SSLVERSION_VALUE(x) (x & 0xffff)
-#define C_SSLVERSION_MAX_VALUE(x) (x & 0xffff0000)
-
-CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option,
- va_list param)
-{
- char *argptr;
- CURLcode result = CURLE_OK;
- long arg;
-#ifndef CURL_DISABLE_HTTP
- curl_off_t bigsize;
-#endif
-
- switch(option) {
- case CURLOPT_DNS_CACHE_TIMEOUT:
- data->set.dns_cache_timeout = va_arg(param, long);
- break;
- case CURLOPT_DNS_USE_GLOBAL_CACHE:
- /* remember we want this enabled */
- arg = va_arg(param, long);
- data->set.global_dns_cache = (0 != arg) ? TRUE : FALSE;
- break;
- case CURLOPT_SSL_CIPHER_LIST:
- /* set a list of cipher we want to use in the SSL connection */
- result = setstropt(&data->set.str[STRING_SSL_CIPHER_LIST_ORIG],
- va_arg(param, char *));
- break;
- case CURLOPT_PROXY_SSL_CIPHER_LIST:
- /* set a list of cipher we want to use in the SSL connection for proxy */
- result = setstropt(&data->set.str[STRING_SSL_CIPHER_LIST_PROXY],
- va_arg(param, char *));
- break;
-
- case CURLOPT_RANDOM_FILE:
- /*
- * This is the path name to a file that contains random data to seed
- * the random SSL stuff with. The file is only used for reading.
- */
- result = setstropt(&data->set.str[STRING_SSL_RANDOM_FILE],
- va_arg(param, char *));
- break;
- case CURLOPT_EGDSOCKET:
- /*
- * The Entropy Gathering Daemon socket pathname
- */
- result = setstropt(&data->set.str[STRING_SSL_EGDSOCKET],
- va_arg(param, char *));
- break;
- case CURLOPT_MAXCONNECTS:
- /*
- * Set the absolute number of maximum simultaneous alive connection that
- * libcurl is allowed to have.
- */
- data->set.maxconnects = va_arg(param, long);
- break;
- case CURLOPT_FORBID_REUSE:
- /*
- * When this transfer is done, it must not be left to be reused by a
- * subsequent transfer but shall be closed immediately.
- */
- data->set.reuse_forbid = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_FRESH_CONNECT:
- /*
- * This transfer shall not use a previously cached connection but
- * should be made with a fresh new connect!
- */
- data->set.reuse_fresh = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_VERBOSE:
- /*
- * Verbose means infof() calls that give a lot of information about
- * the connection and transfer procedures as well as internal choices.
- */
- data->set.verbose = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_HEADER:
- /*
- * Set to include the header in the general data output stream.
- */
- data->set.include_header = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_NOPROGRESS:
- /*
- * Shut off the internal supported progress meter
- */
- data->set.hide_progress = (0 != va_arg(param, long)) ? TRUE : FALSE;
- if(data->set.hide_progress)
- data->progress.flags |= PGRS_HIDE;
- else
- data->progress.flags &= ~PGRS_HIDE;
- break;
- case CURLOPT_NOBODY:
- /*
- * Do not include the body part in the output data stream.
- */
- data->set.opt_no_body = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_FAILONERROR:
- /*
- * Don't output the >=400 error code HTML-page, but instead only
- * return error.
- */
- data->set.http_fail_on_error = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_KEEP_SENDING_ON_ERROR:
- data->set.http_keep_sending_on_error = (0 != va_arg(param, long)) ?
- TRUE : FALSE;
- break;
- case CURLOPT_UPLOAD:
- case CURLOPT_PUT:
- /*
- * We want to sent data to the remote host. If this is HTTP, that equals
- * using the PUT request.
- */
- data->set.upload = (0 != va_arg(param, long)) ? TRUE : FALSE;
- if(data->set.upload) {
- /* If this is HTTP, PUT is what's needed to "upload" */
- data->set.httpreq = HTTPREQ_PUT;
- data->set.opt_no_body = FALSE; /* this is implied */
- }
- else
- /* In HTTP, the opposite of upload is GET (unless NOBODY is true as
- then this can be changed to HEAD later on) */
- data->set.httpreq = HTTPREQ_GET;
- break;
- case CURLOPT_FILETIME:
- /*
- * Try to get the file time of the remote document. The time will
- * later (possibly) become available using curl_easy_getinfo().
- */
- data->set.get_filetime = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_FTP_CREATE_MISSING_DIRS:
- /*
- * An FTP option that modifies an upload to create missing directories on
- * the server.
- */
- switch(va_arg(param, long)) {
- case 0:
- data->set.ftp_create_missing_dirs = 0;
- break;
- case 1:
- data->set.ftp_create_missing_dirs = 1;
- break;
- case 2:
- data->set.ftp_create_missing_dirs = 2;
- break;
- default:
- /* reserve other values for future use */
- result = CURLE_UNKNOWN_OPTION;
- break;
- }
- break;
- case CURLOPT_SERVER_RESPONSE_TIMEOUT:
- /*
- * Option that specifies how quickly an server response must be obtained
- * before it is considered failure. For pingpong protocols.
- */
- data->set.server_response_timeout = va_arg(param, long) * 1000;
- break;
- case CURLOPT_TFTP_NO_OPTIONS:
- /*
- * Option that prevents libcurl from sending TFTP option requests to the
- * server.
- */
- data->set.tftp_no_options = va_arg(param, long) != 0;
- break;
- case CURLOPT_TFTP_BLKSIZE:
- /*
- * TFTP option that specifies the block size to use for data transmission.
- */
- data->set.tftp_blksize = va_arg(param, long);
- break;
- case CURLOPT_DIRLISTONLY:
- /*
- * An option that changes the command to one that asks for a list
- * only, no file info details.
- */
- data->set.ftp_list_only = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_APPEND:
- /*
- * We want to upload and append to an existing file.
- */
- data->set.ftp_append = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_FTP_FILEMETHOD:
- /*
- * How do access files over FTP.
- */
- data->set.ftp_filemethod = (curl_ftpfile)va_arg(param, long);
- break;
- case CURLOPT_NETRC:
- /*
- * Parse the $HOME/.netrc file
- */
- data->set.use_netrc = (enum CURL_NETRC_OPTION)va_arg(param, long);
- break;
- case CURLOPT_NETRC_FILE:
- /*
- * Use this file instead of the $HOME/.netrc file
- */
- result = setstropt(&data->set.str[STRING_NETRC_FILE],
- va_arg(param, char *));
- break;
- case CURLOPT_TRANSFERTEXT:
- /*
- * This option was previously named 'FTPASCII'. Renamed to work with
- * more protocols than merely FTP.
- *
- * Transfer using ASCII (instead of BINARY).
- */
- data->set.prefer_ascii = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_TIMECONDITION:
- /*
- * Set HTTP time condition. This must be one of the defines in the
- * curl/curl.h header file.
- */
- data->set.timecondition = (curl_TimeCond)va_arg(param, long);
- break;
- case CURLOPT_TIMEVALUE:
- /*
- * This is the value to compare with the remote document with the
- * method set with CURLOPT_TIMECONDITION
- */
- data->set.timevalue = (time_t)va_arg(param, long);
- break;
- case CURLOPT_SSLVERSION:
- /*
- * Set explicit SSL version to try to connect with, as some SSL
- * implementations are lame.
- */
-#ifdef USE_SSL
- arg = va_arg(param, long);
- data->set.ssl.primary.version = C_SSLVERSION_VALUE(arg);
- data->set.ssl.primary.version_max = C_SSLVERSION_MAX_VALUE(arg);
-#else
- result = CURLE_UNKNOWN_OPTION;
-#endif
- break;
- case CURLOPT_PROXY_SSLVERSION:
- /*
- * Set explicit SSL version to try to connect with for proxy, as some SSL
- * implementations are lame.
- */
-#ifdef USE_SSL
- arg = va_arg(param, long);
- data->set.proxy_ssl.primary.version = C_SSLVERSION_VALUE(arg);
- data->set.proxy_ssl.primary.version_max = C_SSLVERSION_MAX_VALUE(arg);
-#else
- result = CURLE_UNKNOWN_OPTION;
-#endif
- break;
-
-#ifndef CURL_DISABLE_HTTP
- case CURLOPT_AUTOREFERER:
- /*
- * Switch on automatic referer that gets set if curl follows locations.
- */
- data->set.http_auto_referer = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_ACCEPT_ENCODING:
- /*
- * String to use at the value of Accept-Encoding header.
- *
- * If the encoding is set to "" we use an Accept-Encoding header that
- * encompasses all the encodings we support.
- * If the encoding is set to NULL we don't send an Accept-Encoding header
- * and ignore an received Content-Encoding header.
- *
- */
- argptr = va_arg(param, char *);
- result = setstropt(&data->set.str[STRING_ENCODING],
- (argptr && !*argptr)?
- ALL_CONTENT_ENCODINGS: argptr);
- break;
-
- case CURLOPT_TRANSFER_ENCODING:
- data->set.http_transfer_encoding = (0 != va_arg(param, long)) ?
- TRUE : FALSE;
- break;
-
- case CURLOPT_FOLLOWLOCATION:
- /*
- * Follow Location: header hints on a HTTP-server.
- */
- data->set.http_follow_location = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_UNRESTRICTED_AUTH:
- /*
- * Send authentication (user+password) when following locations, even when
- * hostname changed.
- */
- data->set.http_disable_hostname_check_before_authentication =
- (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_MAXREDIRS:
- /*
- * The maximum amount of hops you allow curl to follow Location:
- * headers. This should mostly be used to detect never-ending loops.
- */
- data->set.maxredirs = va_arg(param, long);
- break;
-
- case CURLOPT_POSTREDIR:
- {
- /*
- * Set the behaviour of POST when redirecting
- * CURL_REDIR_GET_ALL - POST is changed to GET after 301 and 302
- * CURL_REDIR_POST_301 - POST is kept as POST after 301
- * CURL_REDIR_POST_302 - POST is kept as POST after 302
- * CURL_REDIR_POST_303 - POST is kept as POST after 303
- * CURL_REDIR_POST_ALL - POST is kept as POST after 301, 302 and 303
- * other - POST is kept as POST after 301 and 302
- */
- arg = va_arg(param, long);
- data->set.keep_post = arg & CURL_REDIR_POST_ALL;
- }
- break;
-
- case CURLOPT_POST:
- /* Does this option serve a purpose anymore? Yes it does, when
- CURLOPT_POSTFIELDS isn't used and the POST data is read off the
- callback! */
- if(va_arg(param, long)) {
- data->set.httpreq = HTTPREQ_POST;
- data->set.opt_no_body = FALSE; /* this is implied */
- }
- else
- data->set.httpreq = HTTPREQ_GET;
- break;
-
- case CURLOPT_COPYPOSTFIELDS:
- /*
- * A string with POST data. Makes curl HTTP POST. Even if it is NULL.
- * If needed, CURLOPT_POSTFIELDSIZE must have been set prior to
- * CURLOPT_COPYPOSTFIELDS and not altered later.
- */
- argptr = va_arg(param, char *);
-
- if(!argptr || data->set.postfieldsize == -1)
- result = setstropt(&data->set.str[STRING_COPYPOSTFIELDS], argptr);
- else {
- /*
- * Check that requested length does not overflow the size_t type.
- */
-
- if((data->set.postfieldsize < 0) ||
- ((sizeof(curl_off_t) != sizeof(size_t)) &&
- (data->set.postfieldsize > (curl_off_t)((size_t)-1))))
- result = CURLE_OUT_OF_MEMORY;
- else {
- char *p;
-
- (void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
-
- /* Allocate even when size == 0. This satisfies the need of possible
- later address compare to detect the COPYPOSTFIELDS mode, and
- to mark that postfields is used rather than read function or
- form data.
- */
- p = malloc((size_t)(data->set.postfieldsize?
- data->set.postfieldsize:1));
-
- if(!p)
- result = CURLE_OUT_OF_MEMORY;
- else {
- if(data->set.postfieldsize)
- memcpy(p, argptr, (size_t)data->set.postfieldsize);
-
- data->set.str[STRING_COPYPOSTFIELDS] = p;
- }
- }
- }
-
- data->set.postfields = data->set.str[STRING_COPYPOSTFIELDS];
- data->set.httpreq = HTTPREQ_POST;
- break;
-
- case CURLOPT_POSTFIELDS:
- /*
- * Like above, but use static data instead of copying it.
- */
- data->set.postfields = va_arg(param, void *);
- /* Release old copied data. */
- (void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
- data->set.httpreq = HTTPREQ_POST;
- break;
-
- case CURLOPT_POSTFIELDSIZE:
- /*
- * The size of the POSTFIELD data to prevent libcurl to do strlen() to
- * figure it out. Enables binary posts.
- */
- bigsize = va_arg(param, long);
-
- if(data->set.postfieldsize < bigsize &&
- data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
- /* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
- (void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
- data->set.postfields = NULL;
- }
-
- data->set.postfieldsize = bigsize;
- break;
-
- case CURLOPT_POSTFIELDSIZE_LARGE:
- /*
- * The size of the POSTFIELD data to prevent libcurl to do strlen() to
- * figure it out. Enables binary posts.
- */
- bigsize = va_arg(param, curl_off_t);
-
- if(data->set.postfieldsize < bigsize &&
- data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
- /* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
- (void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
- data->set.postfields = NULL;
- }
-
- data->set.postfieldsize = bigsize;
- break;
-
- case CURLOPT_HTTPPOST:
- /*
- * Set to make us do HTTP POST
- */
- data->set.httppost = va_arg(param, struct curl_httppost *);
- data->set.httpreq = HTTPREQ_POST_FORM;
- data->set.opt_no_body = FALSE; /* this is implied */
- break;
-
- case CURLOPT_REFERER:
- /*
- * String to set in the HTTP Referer: field.
- */
- if(data->change.referer_alloc) {
- Curl_safefree(data->change.referer);
- data->change.referer_alloc = FALSE;
- }
- result = setstropt(&data->set.str[STRING_SET_REFERER],
- va_arg(param, char *));
- data->change.referer = data->set.str[STRING_SET_REFERER];
- break;
-
- case CURLOPT_USERAGENT:
- /*
- * String to use in the HTTP User-Agent field
- */
- result = setstropt(&data->set.str[STRING_USERAGENT],
- va_arg(param, char *));
- break;
-
- case CURLOPT_HTTPHEADER:
- /*
- * Set a list with HTTP headers to use (or replace internals with)
- */
- data->set.headers = va_arg(param, struct curl_slist *);
- break;
-
- case CURLOPT_PROXYHEADER:
- /*
- * Set a list with proxy headers to use (or replace internals with)
- *
- * Since CURLOPT_HTTPHEADER was the only way to set HTTP headers for a
- * long time we remain doing it this way until CURLOPT_PROXYHEADER is
- * used. As soon as this option has been used, if set to anything but
- * NULL, custom headers for proxies are only picked from this list.
- *
- * Set this option to NULL to restore the previous behavior.
- */
- data->set.proxyheaders = va_arg(param, struct curl_slist *);
- break;
-
- case CURLOPT_HEADEROPT:
- /*
- * Set header option.
- */
- arg = va_arg(param, long);
- data->set.sep_headers = (arg & CURLHEADER_SEPARATE)? TRUE: FALSE;
- break;
-
- case CURLOPT_HTTP200ALIASES:
- /*
- * Set a list of aliases for HTTP 200 in response header
- */
- data->set.http200aliases = va_arg(param, struct curl_slist *);
- break;
-
-#if !defined(CURL_DISABLE_COOKIES)
- case CURLOPT_COOKIE:
- /*
- * Cookie string to send to the remote server in the request.
- */
- result = setstropt(&data->set.str[STRING_COOKIE],
- va_arg(param, char *));
- break;
-
- case CURLOPT_COOKIEFILE:
- /*
- * Set cookie file to read and parse. Can be used multiple times.
- */
- argptr = (char *)va_arg(param, void *);
- if(argptr) {
- struct curl_slist *cl;
- /* append the cookie file name to the list of file names, and deal with
- them later */
- cl = curl_slist_append(data->change.cookielist, argptr);
- if(!cl) {
- curl_slist_free_all(data->change.cookielist);
- data->change.cookielist = NULL;
- return CURLE_OUT_OF_MEMORY;
- }
- data->change.cookielist = cl; /* store the list for later use */
- }
- break;
-
- case CURLOPT_COOKIEJAR:
- /*
- * Set cookie file name to dump all cookies to when we're done.
- */
- {
- struct CookieInfo *newcookies;
- result = setstropt(&data->set.str[STRING_COOKIEJAR],
- va_arg(param, char *));
-
- /*
- * Activate the cookie parser. This may or may not already
- * have been made.
- */
- newcookies = Curl_cookie_init(data, NULL, data->cookies,
- data->set.cookiesession);
- if(!newcookies)
- result = CURLE_OUT_OF_MEMORY;
- data->cookies = newcookies;
- }
- break;
-
- case CURLOPT_COOKIESESSION:
- /*
- * Set this option to TRUE to start a new "cookie session". It will
- * prevent the forthcoming read-cookies-from-file actions to accept
- * cookies that are marked as being session cookies, as they belong to a
- * previous session.
- *
- * In the original Netscape cookie spec, "session cookies" are cookies
- * with no expire date set. RFC2109 describes the same action if no
- * 'Max-Age' is set and RFC2965 includes the RFC2109 description and adds
- * a 'Discard' action that can enforce the discard even for cookies that
- * have a Max-Age.
- *
- * We run mostly with the original cookie spec, as hardly anyone implements
- * anything else.
- */
- data->set.cookiesession = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_COOKIELIST:
- argptr = va_arg(param, char *);
-
- if(argptr == NULL)
- break;
-
- if(strcasecompare(argptr, "ALL")) {
- /* clear all cookies */
- Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
- Curl_cookie_clearall(data->cookies);
- Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
- }
- else if(strcasecompare(argptr, "SESS")) {
- /* clear session cookies */
- Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
- Curl_cookie_clearsess(data->cookies);
- Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
- }
- else if(strcasecompare(argptr, "FLUSH")) {
- /* flush cookies to file, takes care of the locking */
- Curl_flush_cookies(data, 0);
- }
- else if(strcasecompare(argptr, "RELOAD")) {
- /* reload cookies from file */
- Curl_cookie_loadfiles(data);
- break;
- }
- else {
- if(!data->cookies)
- /* if cookie engine was not running, activate it */
- data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE);
-
- argptr = strdup(argptr);
- if(!argptr || !data->cookies) {
- result = CURLE_OUT_OF_MEMORY;
- free(argptr);
- }
- else {
- Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
-
- if(checkprefix("Set-Cookie:", argptr))
- /* HTTP Header format line */
- Curl_cookie_add(data, data->cookies, TRUE, argptr + 11, NULL, NULL);
-
- else
- /* Netscape format line */
- Curl_cookie_add(data, data->cookies, FALSE, argptr, NULL, NULL);
-
- Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE);
- free(argptr);
- }
- }
-
- break;
-#endif /* CURL_DISABLE_COOKIES */
-
- case CURLOPT_HTTPGET:
- /*
- * Set to force us do HTTP GET
- */
- if(va_arg(param, long)) {
- data->set.httpreq = HTTPREQ_GET;
- data->set.upload = FALSE; /* switch off upload */
- data->set.opt_no_body = FALSE; /* this is implied */
- }
- break;
-
- case CURLOPT_HTTP_VERSION:
- /*
- * This sets a requested HTTP version to be used. The value is one of
- * the listed enums in curl/curl.h.
- */
- arg = va_arg(param, long);
-#ifndef USE_NGHTTP2
- if(arg >= CURL_HTTP_VERSION_2)
- return CURLE_UNSUPPORTED_PROTOCOL;
-#endif
- data->set.httpversion = arg;
- break;
-
- case CURLOPT_HTTPAUTH:
- /*
- * Set HTTP Authentication type BITMASK.
- */
- {
- int bitcheck;
- bool authbits;
- unsigned long auth = va_arg(param, unsigned long);
-
- if(auth == CURLAUTH_NONE) {
- data->set.httpauth = auth;
- break;
- }
-
- /* the DIGEST_IE bit is only used to set a special marker, for all the
- rest we need to handle it as normal DIGEST */
- data->state.authhost.iestyle = (auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE;
-
- if(auth & CURLAUTH_DIGEST_IE) {
- auth |= CURLAUTH_DIGEST; /* set standard digest bit */
- auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */
- }
-
- /* switch off bits we can't support */
-#ifndef USE_NTLM
- auth &= ~CURLAUTH_NTLM; /* no NTLM support */
- auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
-#elif !defined(NTLM_WB_ENABLED)
- auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
-#endif
-#ifndef USE_SPNEGO
- auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without
- GSS-API or SSPI */
-#endif
-
- /* check if any auth bit lower than CURLAUTH_ONLY is still set */
- bitcheck = 0;
- authbits = FALSE;
- while(bitcheck < 31) {
- if(auth & (1UL << bitcheck++)) {
- authbits = TRUE;
- break;
- }
- }
- if(!authbits)
- return CURLE_NOT_BUILT_IN; /* no supported types left! */
-
- data->set.httpauth = auth;
- }
- break;
-
- case CURLOPT_EXPECT_100_TIMEOUT_MS:
- /*
- * Time to wait for a response to a HTTP request containing an
- * Expect: 100-continue header before sending the data anyway.
- */
- data->set.expect_100_timeout = va_arg(param, long);
- break;
-
-#endif /* CURL_DISABLE_HTTP */
-
- case CURLOPT_CUSTOMREQUEST:
- /*
- * Set a custom string to use as request
- */
- result = setstropt(&data->set.str[STRING_CUSTOMREQUEST],
- va_arg(param, char *));
-
- /* we don't set
- data->set.httpreq = HTTPREQ_CUSTOM;
- here, we continue as if we were using the already set type
- and this just changes the actual request keyword */
- break;
-
-#ifndef CURL_DISABLE_PROXY
- case CURLOPT_HTTPPROXYTUNNEL:
- /*
- * Tunnel operations through the proxy instead of normal proxy use
- */
- data->set.tunnel_thru_httpproxy = (0 != va_arg(param, long)) ?
- TRUE : FALSE;
- break;
-
- case CURLOPT_PROXYPORT:
- /*
- * Explicitly set HTTP proxy port number.
- */
- data->set.proxyport = va_arg(param, long);
- break;
-
- case CURLOPT_PROXYAUTH:
- /*
- * Set HTTP Authentication type BITMASK.
- */
- {
- int bitcheck;
- bool authbits;
- unsigned long auth = va_arg(param, unsigned long);
-
- if(auth == CURLAUTH_NONE) {
- data->set.proxyauth = auth;
- break;
- }
-
- /* the DIGEST_IE bit is only used to set a special marker, for all the
- rest we need to handle it as normal DIGEST */
- data->state.authproxy.iestyle = (auth & CURLAUTH_DIGEST_IE) ? TRUE : FALSE;
-
- if(auth & CURLAUTH_DIGEST_IE) {
- auth |= CURLAUTH_DIGEST; /* set standard digest bit */
- auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */
- }
- /* switch off bits we can't support */
-#ifndef USE_NTLM
- auth &= ~CURLAUTH_NTLM; /* no NTLM support */
- auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
-#elif !defined(NTLM_WB_ENABLED)
- auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */
-#endif
-#ifndef USE_SPNEGO
- auth &= ~CURLAUTH_NEGOTIATE; /* no Negotiate (SPNEGO) auth without
- GSS-API or SSPI */
-#endif
-
- /* check if any auth bit lower than CURLAUTH_ONLY is still set */
- bitcheck = 0;
- authbits = FALSE;
- while(bitcheck < 31) {
- if(auth & (1UL << bitcheck++)) {
- authbits = TRUE;
- break;
- }
- }
- if(!authbits)
- return CURLE_NOT_BUILT_IN; /* no supported types left! */
-
- data->set.proxyauth = auth;
- }
- break;
-
- case CURLOPT_PROXY:
- /*
- * Set proxy server:port to use as proxy.
- *
- * If the proxy is set to "" (and CURLOPT_SOCKS_PROXY is set to "" or NULL)
- * we explicitly say that we don't want to use a proxy
- * (even though there might be environment variables saying so).
- *
- * Setting it to NULL, means no proxy but allows the environment variables
- * to decide for us (if CURLOPT_SOCKS_PROXY setting it to NULL).
- */
- result = setstropt(&data->set.str[STRING_PROXY],
- va_arg(param, char *));
- break;
-
- case CURLOPT_PRE_PROXY:
- /*
- * Set proxy server:port to use as SOCKS proxy.
- *
- * If the proxy is set to "" or NULL we explicitly say that we don't want
- * to use the socks proxy.
- */
- result = setstropt(&data->set.str[STRING_PRE_PROXY],
- va_arg(param, char *));
- break;
-
- case CURLOPT_PROXYTYPE:
- /*
- * Set proxy type. HTTP/HTTP_1_0/SOCKS4/SOCKS4a/SOCKS5/SOCKS5_HOSTNAME
- */
- data->set.proxytype = (curl_proxytype)va_arg(param, long);
- break;
-
- case CURLOPT_PROXY_TRANSFER_MODE:
- /*
- * set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy
- */
- switch(va_arg(param, long)) {
- case 0:
- data->set.proxy_transfer_mode = FALSE;
- break;
- case 1:
- data->set.proxy_transfer_mode = TRUE;
- break;
- default:
- /* reserve other values for future use */
- result = CURLE_UNKNOWN_OPTION;
- break;
- }
- break;
-#endif /* CURL_DISABLE_PROXY */
-
-#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
- case CURLOPT_SOCKS5_GSSAPI_NEC:
- /*
- * Set flag for NEC SOCK5 support
- */
- data->set.socks5_gssapi_nec = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_SOCKS5_GSSAPI_SERVICE:
- case CURLOPT_PROXY_SERVICE_NAME:
- /*
- * Set proxy authentication service name for Kerberos 5 and SPNEGO
- */
- result = setstropt(&data->set.str[STRING_PROXY_SERVICE_NAME],
- va_arg(param, char *));
- break;
-#endif
-
-#if !defined(CURL_DISABLE_CRYPTO_AUTH) || defined(USE_KERBEROS5) || \
- defined(USE_SPNEGO)
- case CURLOPT_SERVICE_NAME:
- /*
- * Set authentication service name for DIGEST-MD5, Kerberos 5 and SPNEGO
- */
- result = setstropt(&data->set.str[STRING_SERVICE_NAME],
- va_arg(param, char *));
- break;
-
-#endif
-
- case CURLOPT_HEADERDATA:
- /*
- * Custom pointer to pass the header write callback function
- */
- data->set.writeheader = (void *)va_arg(param, void *);
- break;
- case CURLOPT_ERRORBUFFER:
- /*
- * Error buffer provided by the caller to get the human readable
- * error string in.
- */
- data->set.errorbuffer = va_arg(param, char *);
- break;
- case CURLOPT_WRITEDATA:
- /*
- * FILE pointer to write to. Or possibly
- * used as argument to the write callback.
- */
- data->set.out = va_arg(param, void *);
- break;
- case CURLOPT_FTPPORT:
- /*
- * Use FTP PORT, this also specifies which IP address to use
- */
- result = setstropt(&data->set.str[STRING_FTPPORT],
- va_arg(param, char *));
- data->set.ftp_use_port = (data->set.str[STRING_FTPPORT]) ? TRUE : FALSE;
- break;
-
- case CURLOPT_FTP_USE_EPRT:
- data->set.ftp_use_eprt = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_FTP_USE_EPSV:
- data->set.ftp_use_epsv = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_FTP_USE_PRET:
- data->set.ftp_use_pret = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_FTP_SSL_CCC:
- data->set.ftp_ccc = (curl_ftpccc)va_arg(param, long);
- break;
-
- case CURLOPT_FTP_SKIP_PASV_IP:
- /*
- * Enable or disable FTP_SKIP_PASV_IP, which will disable/enable the
- * bypass of the IP address in PASV responses.
- */
- data->set.ftp_skip_ip = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_READDATA:
- /*
- * FILE pointer to read the file to be uploaded from. Or possibly
- * used as argument to the read callback.
- */
- data->set.in_set = va_arg(param, void *);
- break;
- case CURLOPT_INFILESIZE:
- /*
- * If known, this should inform curl about the file size of the
- * to-be-uploaded file.
- */
- data->set.filesize = va_arg(param, long);
- break;
- case CURLOPT_INFILESIZE_LARGE:
- /*
- * If known, this should inform curl about the file size of the
- * to-be-uploaded file.
- */
- data->set.filesize = va_arg(param, curl_off_t);
- break;
- case CURLOPT_LOW_SPEED_LIMIT:
- /*
- * The low speed limit that if transfers are below this for
- * CURLOPT_LOW_SPEED_TIME, the transfer is aborted.
- */
- data->set.low_speed_limit=va_arg(param, long);
- break;
- case CURLOPT_MAX_SEND_SPEED_LARGE:
- /*
- * When transfer uploads are faster then CURLOPT_MAX_SEND_SPEED_LARGE
- * bytes per second the transfer is throttled..
- */
- data->set.max_send_speed=va_arg(param, curl_off_t);
- break;
- case CURLOPT_MAX_RECV_SPEED_LARGE:
- /*
- * When receiving data faster than CURLOPT_MAX_RECV_SPEED_LARGE bytes per
- * second the transfer is throttled..
- */
- data->set.max_recv_speed=va_arg(param, curl_off_t);
- break;
- case CURLOPT_LOW_SPEED_TIME:
- /*
- * The low speed time that if transfers are below the set
- * CURLOPT_LOW_SPEED_LIMIT during this time, the transfer is aborted.
- */
- data->set.low_speed_time=va_arg(param, long);
- break;
- case CURLOPT_URL:
- /*
- * The URL to fetch.
- */
- if(data->change.url_alloc) {
- /* the already set URL is allocated, free it first! */
- Curl_safefree(data->change.url);
- data->change.url_alloc = FALSE;
- }
- result = setstropt(&data->set.str[STRING_SET_URL],
- va_arg(param, char *));
- data->change.url = data->set.str[STRING_SET_URL];
- break;
- case CURLOPT_PORT:
- /*
- * The port number to use when getting the URL
- */
- data->set.use_port = va_arg(param, long);
- break;
- case CURLOPT_TIMEOUT:
- /*
- * The maximum time you allow curl to use for a single transfer
- * operation.
- */
- data->set.timeout = va_arg(param, long) * 1000L;
- break;
-
- case CURLOPT_TIMEOUT_MS:
- data->set.timeout = va_arg(param, long);
- break;
-
- case CURLOPT_CONNECTTIMEOUT:
- /*
- * The maximum time you allow curl to use to connect.
- */
- data->set.connecttimeout = va_arg(param, long) * 1000L;
- break;
-
- case CURLOPT_CONNECTTIMEOUT_MS:
- data->set.connecttimeout = va_arg(param, long);
- break;
-
- case CURLOPT_ACCEPTTIMEOUT_MS:
- /*
- * The maximum time you allow curl to wait for server connect
- */
- data->set.accepttimeout = va_arg(param, long);
- break;
-
- case CURLOPT_USERPWD:
- /*
- * user:password to use in the operation
- */
- result = setstropt_userpwd(va_arg(param, char *),
- &data->set.str[STRING_USERNAME],
- &data->set.str[STRING_PASSWORD]);
- break;
-
- case CURLOPT_USERNAME:
- /*
- * authentication user name to use in the operation
- */
- result = setstropt(&data->set.str[STRING_USERNAME],
- va_arg(param, char *));
- break;
-
- case CURLOPT_PASSWORD:
- /*
- * authentication password to use in the operation
- */
- result = setstropt(&data->set.str[STRING_PASSWORD],
- va_arg(param, char *));
- break;
-
- case CURLOPT_LOGIN_OPTIONS:
- /*
- * authentication options to use in the operation
- */
- result = setstropt(&data->set.str[STRING_OPTIONS],
- va_arg(param, char *));
- break;
-
- case CURLOPT_XOAUTH2_BEARER:
- /*
- * OAuth 2.0 bearer token to use in the operation
- */
- result = setstropt(&data->set.str[STRING_BEARER],
- va_arg(param, char *));
- break;
-
- case CURLOPT_POSTQUOTE:
- /*
- * List of RAW FTP commands to use after a transfer
- */
- data->set.postquote = va_arg(param, struct curl_slist *);
- break;
- case CURLOPT_PREQUOTE:
- /*
- * List of RAW FTP commands to use prior to RETR (Wesley Laxton)
- */
- data->set.prequote = va_arg(param, struct curl_slist *);
- break;
- case CURLOPT_QUOTE:
- /*
- * List of RAW FTP commands to use before a transfer
- */
- data->set.quote = va_arg(param, struct curl_slist *);
- break;
- case CURLOPT_RESOLVE:
- /*
- * List of NAME:[address] names to populate the DNS cache with
- * Prefix the NAME with dash (-) to _remove_ the name from the cache.
- *
- * Names added with this API will remain in the cache until explicitly
- * removed or the handle is cleaned up.
- *
- * This API can remove any name from the DNS cache, but only entries
- * that aren't actually in use right now will be pruned immediately.
- */
- data->set.resolve = va_arg(param, struct curl_slist *);
- data->change.resolve = data->set.resolve;
- break;
- case CURLOPT_PROGRESSFUNCTION:
- /*
- * Progress callback function
- */
- data->set.fprogress = va_arg(param, curl_progress_callback);
- if(data->set.fprogress)
- data->progress.callback = TRUE; /* no longer internal */
- else
- data->progress.callback = FALSE; /* NULL enforces internal */
- break;
-
- case CURLOPT_XFERINFOFUNCTION:
- /*
- * Transfer info callback function
- */
- data->set.fxferinfo = va_arg(param, curl_xferinfo_callback);
- if(data->set.fxferinfo)
- data->progress.callback = TRUE; /* no longer internal */
- else
- data->progress.callback = FALSE; /* NULL enforces internal */
-
- break;
-
- case CURLOPT_PROGRESSDATA:
- /*
- * Custom client data to pass to the progress callback
- */
- data->set.progress_client = va_arg(param, void *);
- break;
-
-#ifndef CURL_DISABLE_PROXY
- case CURLOPT_PROXYUSERPWD:
- /*
- * user:password needed to use the proxy
- */
- result = setstropt_userpwd(va_arg(param, char *),
- &data->set.str[STRING_PROXYUSERNAME],
- &data->set.str[STRING_PROXYPASSWORD]);
- break;
- case CURLOPT_PROXYUSERNAME:
- /*
- * authentication user name to use in the operation
- */
- result = setstropt(&data->set.str[STRING_PROXYUSERNAME],
- va_arg(param, char *));
- break;
- case CURLOPT_PROXYPASSWORD:
- /*
- * authentication password to use in the operation
- */
- result = setstropt(&data->set.str[STRING_PROXYPASSWORD],
- va_arg(param, char *));
- break;
- case CURLOPT_NOPROXY:
- /*
- * proxy exception list
- */
- result = setstropt(&data->set.str[STRING_NOPROXY],
- va_arg(param, char *));
- break;
-#endif
-
- case CURLOPT_RANGE:
- /*
- * What range of the file you want to transfer
- */
- result = setstropt(&data->set.str[STRING_SET_RANGE],
- va_arg(param, char *));
- break;
- case CURLOPT_RESUME_FROM:
- /*
- * Resume transfer at the give file position
- */
- data->set.set_resume_from = va_arg(param, long);
- break;
- case CURLOPT_RESUME_FROM_LARGE:
- /*
- * Resume transfer at the give file position
- */
- data->set.set_resume_from = va_arg(param, curl_off_t);
- break;
- case CURLOPT_DEBUGFUNCTION:
- /*
- * stderr write callback.
- */
- data->set.fdebug = va_arg(param, curl_debug_callback);
- /*
- * if the callback provided is NULL, it'll use the default callback
- */
- break;
- case CURLOPT_DEBUGDATA:
- /*
- * Set to a void * that should receive all error writes. This
- * defaults to CURLOPT_STDERR for normal operations.
- */
- data->set.debugdata = va_arg(param, void *);
- break;
- case CURLOPT_STDERR:
- /*
- * Set to a FILE * that should receive all error writes. This
- * defaults to stderr for normal operations.
- */
- data->set.err = va_arg(param, FILE *);
- if(!data->set.err)
- data->set.err = stderr;
- break;
- case CURLOPT_HEADERFUNCTION:
- /*
- * Set header write callback
- */
- data->set.fwrite_header = va_arg(param, curl_write_callback);
- break;
- case CURLOPT_WRITEFUNCTION:
- /*
- * Set data write callback
- */
- data->set.fwrite_func = va_arg(param, curl_write_callback);
- if(!data->set.fwrite_func) {
- data->set.is_fwrite_set = 0;
- /* When set to NULL, reset to our internal default function */
- data->set.fwrite_func = (curl_write_callback)fwrite;
- }
- else
- data->set.is_fwrite_set = 1;
- break;
- case CURLOPT_READFUNCTION:
- /*
- * Read data callback
- */
- data->set.fread_func_set = va_arg(param, curl_read_callback);
- if(!data->set.fread_func_set) {
- data->set.is_fread_set = 0;
- /* When set to NULL, reset to our internal default function */
- data->set.fread_func_set = (curl_read_callback)fread;
- }
- else
- data->set.is_fread_set = 1;
- break;
- case CURLOPT_SEEKFUNCTION:
- /*
- * Seek callback. Might be NULL.
- */
- data->set.seek_func = va_arg(param, curl_seek_callback);
- break;
- case CURLOPT_SEEKDATA:
- /*
- * Seek control callback. Might be NULL.
- */
- data->set.seek_client = va_arg(param, void *);
- break;
- case CURLOPT_CONV_FROM_NETWORK_FUNCTION:
- /*
- * "Convert from network encoding" callback
- */
- data->set.convfromnetwork = va_arg(param, curl_conv_callback);
- break;
- case CURLOPT_CONV_TO_NETWORK_FUNCTION:
- /*
- * "Convert to network encoding" callback
- */
- data->set.convtonetwork = va_arg(param, curl_conv_callback);
- break;
- case CURLOPT_CONV_FROM_UTF8_FUNCTION:
- /*
- * "Convert from UTF-8 encoding" callback
- */
- data->set.convfromutf8 = va_arg(param, curl_conv_callback);
- break;
- case CURLOPT_IOCTLFUNCTION:
- /*
- * I/O control callback. Might be NULL.
- */
- data->set.ioctl_func = va_arg(param, curl_ioctl_callback);
- break;
- case CURLOPT_IOCTLDATA:
- /*
- * I/O control data pointer. Might be NULL.
- */
- data->set.ioctl_client = va_arg(param, void *);
- break;
- case CURLOPT_SSLCERT:
- /*
- * String that holds file name of the SSL certificate to use
- */
- result = setstropt(&data->set.str[STRING_CERT_ORIG],
- va_arg(param, char *));
- break;
- case CURLOPT_PROXY_SSLCERT:
- /*
- * String that holds file name of the SSL certificate to use for proxy
- */
- result = setstropt(&data->set.str[STRING_CERT_PROXY],
- va_arg(param, char *));
- break;
- case CURLOPT_SSLCERTTYPE:
- /*
- * String that holds file type of the SSL certificate to use
- */
- result = setstropt(&data->set.str[STRING_CERT_TYPE_ORIG],
- va_arg(param, char *));
- break;
- case CURLOPT_PROXY_SSLCERTTYPE:
- /*
- * String that holds file type of the SSL certificate to use for proxy
- */
- result = setstropt(&data->set.str[STRING_CERT_TYPE_PROXY],
- va_arg(param, char *));
- break;
- case CURLOPT_SSLKEY:
- /*
- * String that holds file name of the SSL key to use
- */
- result = setstropt(&data->set.str[STRING_KEY_ORIG],
- va_arg(param, char *));
- break;
- case CURLOPT_PROXY_SSLKEY:
- /*
- * String that holds file name of the SSL key to use for proxy
- */
- result = setstropt(&data->set.str[STRING_KEY_PROXY],
- va_arg(param, char *));
- break;
- case CURLOPT_SSLKEYTYPE:
- /*
- * String that holds file type of the SSL key to use
- */
- result = setstropt(&data->set.str[STRING_KEY_TYPE_ORIG],
- va_arg(param, char *));
- break;
- case CURLOPT_PROXY_SSLKEYTYPE:
- /*
- * String that holds file type of the SSL key to use for proxy
- */
- result = setstropt(&data->set.str[STRING_KEY_TYPE_PROXY],
- va_arg(param, char *));
- break;
- case CURLOPT_KEYPASSWD:
- /*
- * String that holds the SSL or SSH private key password.
- */
- result = setstropt(&data->set.str[STRING_KEY_PASSWD_ORIG],
- va_arg(param, char *));
- break;
- case CURLOPT_PROXY_KEYPASSWD:
- /*
- * String that holds the SSL private key password for proxy.
- */
- result = setstropt(&data->set.str[STRING_KEY_PASSWD_PROXY],
- va_arg(param, char *));
- break;
- case CURLOPT_SSLENGINE:
- /*
- * String that holds the SSL crypto engine.
- */
- argptr = va_arg(param, char *);
- if(argptr && argptr[0])
- result = Curl_ssl_set_engine(data, argptr);
- break;
-
- case CURLOPT_SSLENGINE_DEFAULT:
- /*
- * flag to set engine as default.
- */
- result = Curl_ssl_set_engine_default(data);
- break;
- case CURLOPT_CRLF:
- /*
- * Kludgy option to enable CRLF conversions. Subject for removal.
- */
- data->set.crlf = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_INTERFACE:
- /*
- * Set what interface or address/hostname to bind the socket to when
- * performing an operation and thus what from-IP your connection will use.
- */
- result = setstropt(&data->set.str[STRING_DEVICE],
- va_arg(param, char *));
- break;
- case CURLOPT_LOCALPORT:
- /*
- * Set what local port to bind the socket to when performing an operation.
- */
- arg = va_arg(param, long);
- if((arg < 0) || (arg > 65535))
- return CURLE_BAD_FUNCTION_ARGUMENT;
- data->set.localport = curlx_sltous(arg);
- break;
- case CURLOPT_LOCALPORTRANGE:
- /*
- * Set number of local ports to try, starting with CURLOPT_LOCALPORT.
- */
- arg = va_arg(param, long);
- if((arg < 0) || (arg > 65535))
- return CURLE_BAD_FUNCTION_ARGUMENT;
- data->set.localportrange = curlx_sltosi(arg);
- break;
- case CURLOPT_KRBLEVEL:
- /*
- * A string that defines the kerberos security level.
- */
- result = setstropt(&data->set.str[STRING_KRB_LEVEL],
- va_arg(param, char *));
- data->set.krb = (data->set.str[STRING_KRB_LEVEL]) ? TRUE : FALSE;
- break;
- case CURLOPT_GSSAPI_DELEGATION:
- /*
- * GSS-API credential delegation
- */
- data->set.gssapi_delegation = va_arg(param, long);
- break;
- case CURLOPT_SSL_VERIFYPEER:
- /*
- * Enable peer SSL verifying.
- */
- data->set.ssl.primary.verifypeer = (0 != va_arg(param, long)) ?
- TRUE : FALSE;
- break;
- case CURLOPT_PROXY_SSL_VERIFYPEER:
- /*
- * Enable peer SSL verifying for proxy.
- */
- data->set.proxy_ssl.primary.verifypeer =
- (0 != va_arg(param, long))?TRUE:FALSE;
- break;
- case CURLOPT_SSL_VERIFYHOST:
- /*
- * Enable verification of the host name in the peer certificate
- */
- arg = va_arg(param, long);
-
- /* Obviously people are not reading documentation and too many thought
- this argument took a boolean when it wasn't and misused it. We thus ban
- 1 as a sensible input and we warn about its use. Then we only have the
- 2 action internally stored as TRUE. */
-
- if(1 == arg) {
- failf(data, "CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!");
- return CURLE_BAD_FUNCTION_ARGUMENT;
- }
-
- data->set.ssl.primary.verifyhost = (0 != arg) ? TRUE : FALSE;
- break;
- case CURLOPT_PROXY_SSL_VERIFYHOST:
- /*
- * Enable verification of the host name in the peer certificate for proxy
- */
- arg = va_arg(param, long);
-
- /* Obviously people are not reading documentation and too many thought
- this argument took a boolean when it wasn't and misused it. We thus ban
- 1 as a sensible input and we warn about its use. Then we only have the
- 2 action internally stored as TRUE. */
-
- if(1 == arg) {
- failf(data, "CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!");
- return CURLE_BAD_FUNCTION_ARGUMENT;
- }
-
- data->set.proxy_ssl.primary.verifyhost = (0 != arg)?TRUE:FALSE;
- break;
- case CURLOPT_SSL_VERIFYSTATUS:
- /*
- * Enable certificate status verifying.
- */
- if(!Curl_ssl_cert_status_request()) {
- result = CURLE_NOT_BUILT_IN;
- break;
- }
-
- data->set.ssl.primary.verifystatus = (0 != va_arg(param, long)) ?
- TRUE : FALSE;
- break;
- case CURLOPT_SSL_CTX_FUNCTION:
-#ifdef have_curlssl_ssl_ctx
- /*
- * Set a SSL_CTX callback
- */
- data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback);
-#else
- result = CURLE_NOT_BUILT_IN;
-#endif
- break;
- case CURLOPT_SSL_CTX_DATA:
-#ifdef have_curlssl_ssl_ctx
- /*
- * Set a SSL_CTX callback parameter pointer
- */
- data->set.ssl.fsslctxp = va_arg(param, void *);
-#else
- result = CURLE_NOT_BUILT_IN;
-#endif
- break;
- case CURLOPT_SSL_FALSESTART:
- /*
- * Enable TLS false start.
- */
- if(!Curl_ssl_false_start()) {
- result = CURLE_NOT_BUILT_IN;
- break;
- }
-
- data->set.ssl.falsestart = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_CERTINFO:
-#ifdef have_curlssl_certinfo
- data->set.ssl.certinfo = (0 != va_arg(param, long)) ? TRUE : FALSE;
-#else
- result = CURLE_NOT_BUILT_IN;
-#endif
- break;
- case CURLOPT_PINNEDPUBLICKEY:
-#ifdef have_curlssl_pinnedpubkey /* only by supported backends */
- /*
- * Set pinned public key for SSL connection.
- * Specify file name of the public key in DER format.
- */
- result = setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG],
- va_arg(param, char *));
-#else
- result = CURLE_NOT_BUILT_IN;
-#endif
- break;
- case CURLOPT_PROXY_PINNEDPUBLICKEY:
-#ifdef have_curlssl_pinnedpubkey /* only by supported backends */
- /*
- * Set pinned public key for SSL connection.
- * Specify file name of the public key in DER format.
- */
- result = setstropt(&data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY],
- va_arg(param, char *));
-#else
- result = CURLE_NOT_BUILT_IN;
-#endif
- break;
- case CURLOPT_CAINFO:
- /*
- * Set CA info for SSL connection. Specify file name of the CA certificate
- */
- result = setstropt(&data->set.str[STRING_SSL_CAFILE_ORIG],
- va_arg(param, char *));
- break;
- case CURLOPT_PROXY_CAINFO:
- /*
- * Set CA info SSL connection for proxy. Specify file name of the
- * CA certificate
- */
- result = setstropt(&data->set.str[STRING_SSL_CAFILE_PROXY],
- va_arg(param, char *));
- break;
- case CURLOPT_CAPATH:
-#ifdef have_curlssl_ca_path /* not supported by all backends */
- /*
- * Set CA path info for SSL connection. Specify directory name of the CA
- * certificates which have been prepared using openssl c_rehash utility.
- */
- /* This does not work on windows. */
- result = setstropt(&data->set.str[STRING_SSL_CAPATH_ORIG],
- va_arg(param, char *));
-#else
- result = CURLE_NOT_BUILT_IN;
-#endif
- break;
- case CURLOPT_PROXY_CAPATH:
-#ifdef have_curlssl_ca_path /* not supported by all backends */
- /*
- * Set CA path info for SSL connection proxy. Specify directory name of the
- * CA certificates which have been prepared using openssl c_rehash utility.
- */
- /* This does not work on windows. */
- result = setstropt(&data->set.str[STRING_SSL_CAPATH_PROXY],
- va_arg(param, char *));
-#else
- result = CURLE_NOT_BUILT_IN;
-#endif
- break;
- case CURLOPT_CRLFILE:
- /*
- * Set CRL file info for SSL connection. Specify file name of the CRL
- * to check certificates revocation
- */
- result = setstropt(&data->set.str[STRING_SSL_CRLFILE_ORIG],
- va_arg(param, char *));
- break;
- case CURLOPT_PROXY_CRLFILE:
- /*
- * Set CRL file info for SSL connection for proxy. Specify file name of the
- * CRL to check certificates revocation
- */
- result = setstropt(&data->set.str[STRING_SSL_CRLFILE_PROXY],
- va_arg(param, char *));
- break;
- case CURLOPT_ISSUERCERT:
- /*
- * Set Issuer certificate file
- * to check certificates issuer
- */
- result = setstropt(&data->set.str[STRING_SSL_ISSUERCERT_ORIG],
- va_arg(param, char *));
- break;
- case CURLOPT_TELNETOPTIONS:
- /*
- * Set a linked list of telnet options
- */
- data->set.telnet_options = va_arg(param, struct curl_slist *);
- break;
-
- case CURLOPT_BUFFERSIZE:
- /*
- * The application kindly asks for a differently sized receive buffer.
- * If it seems reasonable, we'll use it.
- */
- arg = va_arg(param, long);
-
- if(arg > READBUFFER_MAX)
- arg = READBUFFER_MAX;
- else if(arg < 1)
- arg = READBUFFER_SIZE;
- else if(arg < READBUFFER_MIN)
- arg = READBUFFER_MIN;
-
- /* Resize if new size */
- if(arg != data->set.buffer_size) {
- char *newbuff = realloc(data->state.buffer, arg + 1);
- if(!newbuff) {
- DEBUGF(fprintf(stderr, "Error: realloc of buffer failed\n"));
- result = CURLE_OUT_OF_MEMORY;
- }
- else
- data->state.buffer = newbuff;
- }
- data->set.buffer_size = arg;
-
- break;
-
- case CURLOPT_NOSIGNAL:
- /*
- * The application asks not to set any signal() or alarm() handlers,
- * even when using a timeout.
- */
- data->set.no_signal = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_SHARE:
- {
- struct Curl_share *set;
- set = va_arg(param, struct Curl_share *);
-
- /* disconnect from old share, if any */
- if(data->share) {
- Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
-
- if(data->dns.hostcachetype == HCACHE_SHARED) {
- data->dns.hostcache = NULL;
- data->dns.hostcachetype = HCACHE_NONE;
- }
-
-#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
- if(data->share->cookies == data->cookies)
- data->cookies = NULL;
-#endif
-
- if(data->share->sslsession == data->state.session)
- data->state.session = NULL;
-
- data->share->dirty--;
-
- Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
- data->share = NULL;
- }
-
- /* use new share if it set */
- data->share = set;
- if(data->share) {
-
- Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);
-
- data->share->dirty++;
-
- if(data->share->specifier & (1<< CURL_LOCK_DATA_DNS)) {
- /* use shared host cache */
- data->dns.hostcache = &data->share->hostcache;
- data->dns.hostcachetype = HCACHE_SHARED;
- }
-#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
- if(data->share->cookies) {
- /* use shared cookie list, first free own one if any */
- Curl_cookie_cleanup(data->cookies);
- /* enable cookies since we now use a share that uses cookies! */
- data->cookies = data->share->cookies;
- }
-#endif /* CURL_DISABLE_HTTP */
- if(data->share->sslsession) {
- data->set.general_ssl.max_ssl_sessions = data->share->max_ssl_sessions;
- data->state.session = data->share->sslsession;
- }
- Curl_share_unlock(data, CURL_LOCK_DATA_SHARE);
-
- }
- /* check for host cache not needed,
- * it will be done by curl_easy_perform */
- }
- break;
-
- case CURLOPT_PRIVATE:
- /*
- * Set private data pointer.
- */
- data->set.private_data = va_arg(param, void *);
- break;
-
- case CURLOPT_MAXFILESIZE:
- /*
- * Set the maximum size of a file to download.
- */
- data->set.max_filesize = va_arg(param, long);
- break;
-
-#ifdef USE_SSL
- case CURLOPT_USE_SSL:
- /*
- * Make transfers attempt to use SSL/TLS.
- */
- data->set.use_ssl = (curl_usessl)va_arg(param, long);
- break;
-
- case CURLOPT_SSL_OPTIONS:
- arg = va_arg(param, long);
- data->set.ssl.enable_beast = arg&CURLSSLOPT_ALLOW_BEAST?TRUE:FALSE;
- data->set.ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
- break;
-
- case CURLOPT_PROXY_SSL_OPTIONS:
- arg = va_arg(param, long);
- data->set.proxy_ssl.enable_beast = arg&CURLSSLOPT_ALLOW_BEAST?TRUE:FALSE;
- data->set.proxy_ssl.no_revoke = !!(arg & CURLSSLOPT_NO_REVOKE);
- break;
-
-#endif
- case CURLOPT_FTPSSLAUTH:
- /*
- * Set a specific auth for FTP-SSL transfers.
- */
- data->set.ftpsslauth = (curl_ftpauth)va_arg(param, long);
- break;
-
- case CURLOPT_IPRESOLVE:
- data->set.ipver = va_arg(param, long);
- break;
-
- case CURLOPT_MAXFILESIZE_LARGE:
- /*
- * Set the maximum size of a file to download.
- */
- data->set.max_filesize = va_arg(param, curl_off_t);
- break;
-
- case CURLOPT_TCP_NODELAY:
- /*
- * Enable or disable TCP_NODELAY, which will disable/enable the Nagle
- * algorithm
- */
- data->set.tcp_nodelay = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_FTP_ACCOUNT:
- result = setstropt(&data->set.str[STRING_FTP_ACCOUNT],
- va_arg(param, char *));
- break;
-
- case CURLOPT_IGNORE_CONTENT_LENGTH:
- data->set.ignorecl = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_CONNECT_ONLY:
- /*
- * No data transfer, set up connection and let application use the socket
- */
- data->set.connect_only = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_FTP_ALTERNATIVE_TO_USER:
- result = setstropt(&data->set.str[STRING_FTP_ALTERNATIVE_TO_USER],
- va_arg(param, char *));
- break;
-
- case CURLOPT_SOCKOPTFUNCTION:
- /*
- * socket callback function: called after socket() but before connect()
- */
- data->set.fsockopt = va_arg(param, curl_sockopt_callback);
- break;
-
- case CURLOPT_SOCKOPTDATA:
- /*
- * socket callback data pointer. Might be NULL.
- */
- data->set.sockopt_client = va_arg(param, void *);
- break;
-
- case CURLOPT_OPENSOCKETFUNCTION:
- /*
- * open/create socket callback function: called instead of socket(),
- * before connect()
- */
- data->set.fopensocket = va_arg(param, curl_opensocket_callback);
- break;
-
- case CURLOPT_OPENSOCKETDATA:
- /*
- * socket callback data pointer. Might be NULL.
- */
- data->set.opensocket_client = va_arg(param, void *);
- break;
-
- case CURLOPT_CLOSESOCKETFUNCTION:
- /*
- * close socket callback function: called instead of close()
- * when shutting down a connection
- */
- data->set.fclosesocket = va_arg(param, curl_closesocket_callback);
- break;
-
- case CURLOPT_CLOSESOCKETDATA:
- /*
- * socket callback data pointer. Might be NULL.
- */
- data->set.closesocket_client = va_arg(param, void *);
- break;
-
- case CURLOPT_SSL_SESSIONID_CACHE:
- data->set.ssl.primary.sessionid = (0 != va_arg(param, long)) ?
- TRUE : FALSE;
- data->set.proxy_ssl.primary.sessionid = data->set.ssl.primary.sessionid;
- break;
-
-#ifdef USE_LIBSSH2
- /* we only include SSH options if explicitly built to support SSH */
- case CURLOPT_SSH_AUTH_TYPES:
- data->set.ssh_auth_types = va_arg(param, long);
- break;
-
- case CURLOPT_SSH_PUBLIC_KEYFILE:
- /*
- * Use this file instead of the $HOME/.ssh/id_dsa.pub file
- */
- result = setstropt(&data->set.str[STRING_SSH_PUBLIC_KEY],
- va_arg(param, char *));
- break;
-
- case CURLOPT_SSH_PRIVATE_KEYFILE:
- /*
- * Use this file instead of the $HOME/.ssh/id_dsa file
- */
- result = setstropt(&data->set.str[STRING_SSH_PRIVATE_KEY],
- va_arg(param, char *));
- break;
- case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
- /*
- * Option to allow for the MD5 of the host public key to be checked
- * for validation purposes.
- */
- result = setstropt(&data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5],
- va_arg(param, char *));
- break;
-#ifdef HAVE_LIBSSH2_KNOWNHOST_API
- case CURLOPT_SSH_KNOWNHOSTS:
- /*
- * Store the file name to read known hosts from.
- */
- result = setstropt(&data->set.str[STRING_SSH_KNOWNHOSTS],
- va_arg(param, char *));
- break;
-
- case CURLOPT_SSH_KEYFUNCTION:
- /* setting to NULL is fine since the ssh.c functions themselves will
- then rever to use the internal default */
- data->set.ssh_keyfunc = va_arg(param, curl_sshkeycallback);
- break;
-
- case CURLOPT_SSH_KEYDATA:
- /*
- * Custom client data to pass to the SSH keyfunc callback
- */
- data->set.ssh_keyfunc_userp = va_arg(param, void *);
- break;
-#endif /* HAVE_LIBSSH2_KNOWNHOST_API */
-
-#endif /* USE_LIBSSH2 */
-
- case CURLOPT_HTTP_TRANSFER_DECODING:
- /*
- * disable libcurl transfer encoding is used
- */
- data->set.http_te_skip = (0 == va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_HTTP_CONTENT_DECODING:
- /*
- * raw data passed to the application when content encoding is used
- */
- data->set.http_ce_skip = (0 == va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_NEW_FILE_PERMS:
- /*
- * Uses these permissions instead of 0644
- */
- data->set.new_file_perms = va_arg(param, long);
- break;
-
- case CURLOPT_NEW_DIRECTORY_PERMS:
- /*
- * Uses these permissions instead of 0755
- */
- data->set.new_directory_perms = va_arg(param, long);
- break;
-
- case CURLOPT_ADDRESS_SCOPE:
- /*
- * We always get longs when passed plain numericals, but for this value we
- * know that an unsigned int will always hold the value so we blindly
- * typecast to this type
- */
- arg = va_arg(param, long);
- if((arg < 0) || (arg > 0xf))
- return CURLE_BAD_FUNCTION_ARGUMENT;
- data->set.scope_id = curlx_sltoui(arg);
- break;
-
- case CURLOPT_PROTOCOLS:
- /* set the bitmask for the protocols that are allowed to be used for the
- transfer, which thus helps the app which takes URLs from users or other
- external inputs and want to restrict what protocol(s) to deal
- with. Defaults to CURLPROTO_ALL. */
- data->set.allowed_protocols = va_arg(param, long);
- break;
-
- case CURLOPT_REDIR_PROTOCOLS:
- /* set the bitmask for the protocols that libcurl is allowed to follow to,
- as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs
- to be set in both bitmasks to be allowed to get redirected to. Defaults
- to all protocols except FILE and SCP. */
- data->set.redir_protocols = va_arg(param, long);
- break;
-
- case CURLOPT_DEFAULT_PROTOCOL:
- /* Set the protocol to use when the URL doesn't include any protocol */
- result = setstropt(&data->set.str[STRING_DEFAULT_PROTOCOL],
- va_arg(param, char *));
- break;
-
- case CURLOPT_MAIL_FROM:
- /* Set the SMTP mail originator */
- result = setstropt(&data->set.str[STRING_MAIL_FROM],
- va_arg(param, char *));
- break;
-
- case CURLOPT_MAIL_AUTH:
- /* Set the SMTP auth originator */
- result = setstropt(&data->set.str[STRING_MAIL_AUTH],
- va_arg(param, char *));
- break;
-
- case CURLOPT_MAIL_RCPT:
- /* Set the list of mail recipients */
- data->set.mail_rcpt = va_arg(param, struct curl_slist *);
- break;
-
- case CURLOPT_SASL_IR:
- /* Enable/disable SASL initial response */
- data->set.sasl_ir = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
- case CURLOPT_RTSP_REQUEST:
- {
- /*
- * Set the RTSP request method (OPTIONS, SETUP, PLAY, etc...)
- * Would this be better if the RTSPREQ_* were just moved into here?
- */
- long curl_rtspreq = va_arg(param, long);
- Curl_RtspReq rtspreq = RTSPREQ_NONE;
- switch(curl_rtspreq) {
- case CURL_RTSPREQ_OPTIONS:
- rtspreq = RTSPREQ_OPTIONS;
- break;
-
- case CURL_RTSPREQ_DESCRIBE:
- rtspreq = RTSPREQ_DESCRIBE;
- break;
-
- case CURL_RTSPREQ_ANNOUNCE:
- rtspreq = RTSPREQ_ANNOUNCE;
- break;
-
- case CURL_RTSPREQ_SETUP:
- rtspreq = RTSPREQ_SETUP;
- break;
-
- case CURL_RTSPREQ_PLAY:
- rtspreq = RTSPREQ_PLAY;
- break;
-
- case CURL_RTSPREQ_PAUSE:
- rtspreq = RTSPREQ_PAUSE;
- break;
-
- case CURL_RTSPREQ_TEARDOWN:
- rtspreq = RTSPREQ_TEARDOWN;
- break;
-
- case CURL_RTSPREQ_GET_PARAMETER:
- rtspreq = RTSPREQ_GET_PARAMETER;
- break;
-
- case CURL_RTSPREQ_SET_PARAMETER:
- rtspreq = RTSPREQ_SET_PARAMETER;
- break;
-
- case CURL_RTSPREQ_RECORD:
- rtspreq = RTSPREQ_RECORD;
- break;
-
- case CURL_RTSPREQ_RECEIVE:
- rtspreq = RTSPREQ_RECEIVE;
- break;
- default:
- rtspreq = RTSPREQ_NONE;
- }
-
- data->set.rtspreq = rtspreq;
- break;
- }
-
-
- case CURLOPT_RTSP_SESSION_ID:
- /*
- * Set the RTSP Session ID manually. Useful if the application is
- * resuming a previously established RTSP session
- */
- result = setstropt(&data->set.str[STRING_RTSP_SESSION_ID],
- va_arg(param, char *));
- break;
-
- case CURLOPT_RTSP_STREAM_URI:
- /*
- * Set the Stream URI for the RTSP request. Unless the request is
- * for generic server options, the application will need to set this.
- */
- result = setstropt(&data->set.str[STRING_RTSP_STREAM_URI],
- va_arg(param, char *));
- break;
-
- case CURLOPT_RTSP_TRANSPORT:
- /*
- * The content of the Transport: header for the RTSP request
- */
- result = setstropt(&data->set.str[STRING_RTSP_TRANSPORT],
- va_arg(param, char *));
- break;
-
- case CURLOPT_RTSP_CLIENT_CSEQ:
- /*
- * Set the CSEQ number to issue for the next RTSP request. Useful if the
- * application is resuming a previously broken connection. The CSEQ
- * will increment from this new number henceforth.
- */
- data->state.rtsp_next_client_CSeq = va_arg(param, long);
- break;
-
- case CURLOPT_RTSP_SERVER_CSEQ:
- /* Same as the above, but for server-initiated requests */
- data->state.rtsp_next_client_CSeq = va_arg(param, long);
- break;
-
- case CURLOPT_INTERLEAVEDATA:
- data->set.rtp_out = va_arg(param, void *);
- break;
- case CURLOPT_INTERLEAVEFUNCTION:
- /* Set the user defined RTP write function */
- data->set.fwrite_rtp = va_arg(param, curl_write_callback);
- break;
-
- case CURLOPT_WILDCARDMATCH:
- data->set.wildcardmatch = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_CHUNK_BGN_FUNCTION:
- data->set.chunk_bgn = va_arg(param, curl_chunk_bgn_callback);
- break;
- case CURLOPT_CHUNK_END_FUNCTION:
- data->set.chunk_end = va_arg(param, curl_chunk_end_callback);
- break;
- case CURLOPT_FNMATCH_FUNCTION:
- data->set.fnmatch = va_arg(param, curl_fnmatch_callback);
- break;
- case CURLOPT_CHUNK_DATA:
- data->wildcard.customptr = va_arg(param, void *);
- break;
- case CURLOPT_FNMATCH_DATA:
- data->set.fnmatch_data = va_arg(param, void *);
- break;
-#ifdef USE_TLS_SRP
- case CURLOPT_TLSAUTH_USERNAME:
- result = setstropt(&data->set.str[STRING_TLSAUTH_USERNAME_ORIG],
- va_arg(param, char *));
- if(data->set.str[STRING_TLSAUTH_USERNAME_ORIG] && !data->set.ssl.authtype)
- data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
- break;
- case CURLOPT_PROXY_TLSAUTH_USERNAME:
- result = setstropt(&data->set.str[STRING_TLSAUTH_USERNAME_PROXY],
- va_arg(param, char *));
- if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
- !data->set.proxy_ssl.authtype)
- data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
- break;
- case CURLOPT_TLSAUTH_PASSWORD:
- result = setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_ORIG],
- va_arg(param, char *));
- if(data->set.str[STRING_TLSAUTH_USERNAME_ORIG] && !data->set.ssl.authtype)
- data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
- break;
- case CURLOPT_PROXY_TLSAUTH_PASSWORD:
- result = setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD_PROXY],
- va_arg(param, char *));
- if(data->set.str[STRING_TLSAUTH_USERNAME_PROXY] &&
- !data->set.proxy_ssl.authtype)
- data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */
- break;
- case CURLOPT_TLSAUTH_TYPE:
- argptr = va_arg(param, char *);
- if(!argptr ||
- strncasecompare(argptr, "SRP", strlen("SRP")))
- data->set.ssl.authtype = CURL_TLSAUTH_SRP;
- else
- data->set.ssl.authtype = CURL_TLSAUTH_NONE;
- break;
- case CURLOPT_PROXY_TLSAUTH_TYPE:
- argptr = va_arg(param, char *);
- if(!argptr ||
- strncasecompare(argptr, "SRP", strlen("SRP")))
- data->set.proxy_ssl.authtype = CURL_TLSAUTH_SRP;
- else
- data->set.proxy_ssl.authtype = CURL_TLSAUTH_NONE;
- break;
-#endif
- case CURLOPT_DNS_SERVERS:
- result = Curl_set_dns_servers(data, va_arg(param, char *));
- break;
- case CURLOPT_DNS_INTERFACE:
- result = Curl_set_dns_interface(data, va_arg(param, char *));
- break;
- case CURLOPT_DNS_LOCAL_IP4:
- result = Curl_set_dns_local_ip4(data, va_arg(param, char *));
- break;
- case CURLOPT_DNS_LOCAL_IP6:
- result = Curl_set_dns_local_ip6(data, va_arg(param, char *));
- break;
-
- case CURLOPT_TCP_KEEPALIVE:
- data->set.tcp_keepalive = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_TCP_KEEPIDLE:
- data->set.tcp_keepidle = va_arg(param, long);
- break;
- case CURLOPT_TCP_KEEPINTVL:
- data->set.tcp_keepintvl = va_arg(param, long);
- break;
- case CURLOPT_TCP_FASTOPEN:
-#if defined(CONNECT_DATA_IDEMPOTENT) || defined(MSG_FASTOPEN)
- data->set.tcp_fastopen = (0 != va_arg(param, long))?TRUE:FALSE;
-#else
- result = CURLE_NOT_BUILT_IN;
-#endif
- break;
- case CURLOPT_SSL_ENABLE_NPN:
- data->set.ssl_enable_npn = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_SSL_ENABLE_ALPN:
- data->set.ssl_enable_alpn = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
-
-#ifdef USE_UNIX_SOCKETS
- case CURLOPT_UNIX_SOCKET_PATH:
- data->set.abstract_unix_socket = FALSE;
- result = setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH],
- va_arg(param, char *));
- break;
- case CURLOPT_ABSTRACT_UNIX_SOCKET:
- data->set.abstract_unix_socket = TRUE;
- result = setstropt(&data->set.str[STRING_UNIX_SOCKET_PATH],
- va_arg(param, char *));
- break;
-#endif
-
- case CURLOPT_PATH_AS_IS:
- data->set.path_as_is = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_PIPEWAIT:
- data->set.pipewait = (0 != va_arg(param, long)) ? TRUE : FALSE;
- break;
- case CURLOPT_STREAM_WEIGHT:
-#ifndef USE_NGHTTP2
- return CURLE_NOT_BUILT_IN;
-#else
- arg = va_arg(param, long);
- if((arg>=1) && (arg <= 256))
- data->set.stream_weight = (int)arg;
- break;
-#endif
- case CURLOPT_STREAM_DEPENDS:
- case CURLOPT_STREAM_DEPENDS_E:
- {
-#ifndef USE_NGHTTP2
- return CURLE_NOT_BUILT_IN;
-#else
- struct Curl_easy *dep = va_arg(param, struct Curl_easy *);
- if(!dep || GOOD_EASY_HANDLE(dep)) {
- if(data->set.stream_depends_on) {
- Curl_http2_remove_child(data->set.stream_depends_on, data);
- }
- Curl_http2_add_child(dep, data, (option == CURLOPT_STREAM_DEPENDS_E));
- }
- break;
-#endif
- }
- case CURLOPT_CONNECT_TO:
- data->set.connect_to = va_arg(param, struct curl_slist *);
- break;
- case CURLOPT_SUPPRESS_CONNECT_HEADERS:
- data->set.suppress_connect_headers = (0 != va_arg(param, long))?TRUE:FALSE;
- break;
- default:
- /* unknown tag and its companion, just ignore: */
- result = CURLE_UNKNOWN_OPTION;
- break;
- }
-
- return result;
-}
-
#ifdef USE_RECV_BEFORE_SEND_WORKAROUND
static void conn_reset_postponed_data(struct connectdata *conn, int num)
{
@@ -2970,11 +668,15 @@ static void conn_reset_all_postponed_data(struct connectdata *conn)
#define conn_reset_all_postponed_data(c) do {} WHILE_FALSE
#endif /* ! USE_RECV_BEFORE_SEND_WORKAROUND */
-static void conn_free(struct connectdata *conn)
+
+static void conn_shutdown(struct connectdata *conn)
{
if(!conn)
return;
+ infof(conn->data, "Closing connection %ld\n", conn->connection_id);
+ DEBUGASSERT(conn->data);
+
/* possible left-overs from the async name resolvers */
Curl_resolver_cancel(conn);
@@ -2993,10 +695,20 @@ static void conn_free(struct connectdata *conn)
if(CURL_SOCKET_BAD != conn->tempsock[1])
Curl_closesocket(conn, conn->tempsock[1]);
-#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
- defined(NTLM_WB_ENABLED)
- Curl_ntlm_wb_cleanup(conn);
-#endif
+ /* unlink ourselves. this should be called last since other shutdown
+ procedures need a valid conn->data and this may clear it. */
+ Curl_conncache_remove_conn(conn->data, conn, TRUE);
+}
+
+static void conn_free(struct connectdata *conn)
+{
+ if(!conn)
+ return;
+
+ free_idnconverted_hostname(&conn->host);
+ free_idnconverted_hostname(&conn->conn_to_host);
+ free_idnconverted_hostname(&conn->http_proxy.host);
+ free_idnconverted_hostname(&conn->socks_proxy.host);
Curl_safefree(conn->user);
Curl_safefree(conn->passwd);
@@ -3019,17 +731,14 @@ static void conn_free(struct connectdata *conn)
Curl_safefree(conn->trailer);
Curl_safefree(conn->host.rawalloc); /* host name buffer */
Curl_safefree(conn->conn_to_host.rawalloc); /* host name buffer */
+ Curl_safefree(conn->hostname_resolve);
Curl_safefree(conn->secondaryhostname);
Curl_safefree(conn->http_proxy.host.rawalloc); /* http proxy name buffer */
Curl_safefree(conn->socks_proxy.host.rawalloc); /* socks proxy name buffer */
- Curl_safefree(conn->master_buffer);
- Curl_safefree(conn->connect_buffer);
+ Curl_safefree(conn->connect_state);
conn_reset_all_postponed_data(conn);
-
- Curl_llist_destroy(&conn->send_pipe, NULL);
- Curl_llist_destroy(&conn->recv_pipe, NULL);
-
+ Curl_llist_destroy(&conn->easyq, NULL);
Curl_safefree(conn->localdev);
Curl_free_primary_ssl_config(&conn->ssl_config);
Curl_free_primary_ssl_config(&conn->proxy_ssl_config);
@@ -3038,6 +747,9 @@ static void conn_free(struct connectdata *conn)
Curl_safefree(conn->unix_domain_socket);
#endif
+#ifdef USE_SSL
+ Curl_safefree(conn->ssl_extra);
+#endif
free(conn); /* free all the connection oriented data */
}
@@ -3046,20 +758,23 @@ static void conn_free(struct connectdata *conn)
* primary connection, like when freeing room in the connection cache or
* killing of a dead old connection.
*
+ * A connection needs an easy handle when closing down. We support this passed
+ * in separately since the connection to get closed here is often already
+ * disassociated from an easy handle.
+ *
* This function MUST NOT reset state in the Curl_easy struct if that
* isn't strictly bound to the life-time of *this* particular connection.
*
*/
-CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection)
+CURLcode Curl_disconnect(struct Curl_easy *data,
+ struct connectdata *conn, bool dead_connection)
{
- struct Curl_easy *data;
if(!conn)
return CURLE_OK; /* this is closed and fine already */
- data = conn->data;
if(!data) {
- DEBUGF(fprintf(stderr, "DISCONNECT without easy handle, ignoring\n"));
+ DEBUGF(infof(data, "DISCONNECT without easy handle, ignoring\n"));
return CURLE_OK;
}
@@ -3067,10 +782,8 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection)
* If this connection isn't marked to force-close, leave it open if there
* are other users of it
*/
- if(!conn->bits.close &&
- (conn->send_pipe.size + conn->recv_pipe.size)) {
- DEBUGF(infof(data, "Curl_disconnect, usecounter: %d\n",
- conn->send_pipe.size + conn->recv_pipe.size));
+ if(CONN_INUSE(conn) && !dead_connection) {
+ DEBUGF(infof(data, "Curl_disconnect when inuse: %zu\n", CONN_INUSE(conn)));
return CURLE_OK;
}
@@ -3083,32 +796,27 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection)
#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM)
/* Cleanup NTLM connection-related data */
- Curl_http_ntlm_cleanup(conn);
+ Curl_http_auth_cleanup_ntlm(conn);
#endif
+#if !defined(CURL_DISABLE_HTTP) && defined(USE_SPNEGO)
+ /* Cleanup NEGOTIATE connection-related data */
+ Curl_http_auth_cleanup_negotiate(conn);
+#endif
+
+ /* the protocol specific disconnect handler and conn_shutdown need a transfer
+ for the connection! */
+ conn->data = data;
+
+ if(conn->bits.connect_only)
+ /* treat the connection as dead in CONNECT_ONLY situations */
+ dead_connection = TRUE;
if(conn->handler->disconnect)
/* This is set if protocol-specific cleanups should be made */
conn->handler->disconnect(conn, dead_connection);
- /* unlink ourselves! */
- infof(data, "Closing connection %ld\n", conn->connection_id);
- Curl_conncache_remove_conn(data->state.conn_cache, conn);
-
- free_fixed_hostname(&conn->host);
- free_fixed_hostname(&conn->conn_to_host);
- free_fixed_hostname(&conn->http_proxy.host);
- free_fixed_hostname(&conn->socks_proxy.host);
-
- Curl_ssl_close(conn, FIRSTSOCKET);
-
- /* Indicate to all handles on the pipe that we're dead */
- if(Curl_pipeline_wanted(data->multi, CURLPIPE_ANY)) {
- signalPipeClose(&conn->send_pipe, TRUE);
- signalPipeClose(&conn->recv_pipe, TRUE);
- }
-
+ conn_shutdown(conn);
conn_free(conn);
-
return CURLE_OK;
}
@@ -3131,28 +839,21 @@ static bool SocketIsDead(curl_socket_t sock)
}
/*
- * IsPipeliningPossible()
+ * IsMultiplexingPossible()
*
- * Return a bitmask with the available pipelining and multiplexing options for
- * the given requested connection.
+ * Return a bitmask with the available multiplexing options for the given
+ * requested connection.
*/
-static int IsPipeliningPossible(const struct Curl_easy *handle,
- const struct connectdata *conn)
+static int IsMultiplexingPossible(const struct Curl_easy *handle,
+ const struct connectdata *conn)
{
int avail = 0;
- /* If a HTTP protocol and pipelining is enabled */
+ /* If a HTTP protocol and multiplexing is enabled */
if((conn->handler->protocol & PROTO_FAMILY_HTTP) &&
(!conn->bits.protoconnstart || !conn->bits.close)) {
- if(Curl_pipeline_wanted(handle->multi, CURLPIPE_HTTP1) &&
- (handle->set.httpversion != CURL_HTTP_VERSION_1_0) &&
- (handle->set.httpreq == HTTPREQ_GET ||
- handle->set.httpreq == HTTPREQ_HEAD))
- /* didn't ask for HTTP/1.0 and a GET or HEAD */
- avail |= CURLPIPE_HTTP1;
-
- if(Curl_pipeline_wanted(handle->multi, CURLPIPE_MULTIPLEX) &&
+ if(Curl_multiplex_wanted(handle->multi) &&
(handle->set.httpversion >= CURL_HTTP_VERSION_2))
/* allows HTTP/2 */
avail |= CURLPIPE_MULTIPLEX;
@@ -3160,144 +861,7 @@ static int IsPipeliningPossible(const struct Curl_easy *handle,
return avail;
}
-int Curl_removeHandleFromPipeline(struct Curl_easy *handle,
- struct curl_llist *pipeline)
-{
- if(pipeline) {
- struct curl_llist_element *curr;
-
- curr = pipeline->head;
- while(curr) {
- if(curr->ptr == handle) {
- Curl_llist_remove(pipeline, curr, NULL);
- return 1; /* we removed a handle */
- }
- curr = curr->next;
- }
- }
-
- return 0;
-}
-
-#if 0 /* this code is saved here as it is useful for debugging purposes */
-static void Curl_printPipeline(struct curl_llist *pipeline)
-{
- struct curl_llist_element *curr;
-
- curr = pipeline->head;
- while(curr) {
- struct Curl_easy *data = (struct Curl_easy *) curr->ptr;
- infof(data, "Handle in pipeline: %s\n", data->state.path);
- curr = curr->next;
- }
-}
-#endif
-
-static struct Curl_easy* gethandleathead(struct curl_llist *pipeline)
-{
- struct curl_llist_element *curr = pipeline->head;
- if(curr) {
- return (struct Curl_easy *) curr->ptr;
- }
-
- return NULL;
-}
-
-/* remove the specified connection from all (possible) pipelines and related
- queues */
-void Curl_getoff_all_pipelines(struct Curl_easy *data,
- struct connectdata *conn)
-{
- bool recv_head = (conn->readchannel_inuse &&
- Curl_recvpipe_head(data, conn));
- bool send_head = (conn->writechannel_inuse &&
- Curl_sendpipe_head(data, conn));
-
- if(Curl_removeHandleFromPipeline(data, &conn->recv_pipe) && recv_head)
- Curl_pipeline_leave_read(conn);
- if(Curl_removeHandleFromPipeline(data, &conn->send_pipe) && send_head)
- Curl_pipeline_leave_write(conn);
-}
-
-static void signalPipeClose(struct curl_llist *pipeline, bool pipe_broke)
-{
- struct curl_llist_element *curr;
-
- if(!pipeline)
- return;
-
- curr = pipeline->head;
- while(curr) {
- struct curl_llist_element *next = curr->next;
- struct Curl_easy *data = (struct Curl_easy *) curr->ptr;
-
-#ifdef DEBUGBUILD /* debug-only code */
- if(data->magic != CURLEASY_MAGIC_NUMBER) {
- /* MAJOR BADNESS */
- infof(data, "signalPipeClose() found BAAD easy handle\n");
- }
-#endif
-
- if(pipe_broke)
- data->state.pipe_broke = TRUE;
- Curl_multi_handlePipeBreak(data);
- Curl_llist_remove(pipeline, curr, NULL);
- curr = next;
- }
-}
-
-/*
- * This function finds the connection in the connection
- * cache that has been unused for the longest time.
- *
- * Returns the pointer to the oldest idle connection, or NULL if none was
- * found.
- */
-struct connectdata *
-Curl_oldest_idle_connection(struct Curl_easy *data)
-{
- struct conncache *bc = data->state.conn_cache;
- struct curl_hash_iterator iter;
- struct curl_llist_element *curr;
- struct curl_hash_element *he;
- time_t highscore=-1;
- time_t score;
- struct timeval now;
- struct connectdata *conn_candidate = NULL;
- struct connectbundle *bundle;
-
- now = Curl_tvnow();
-
- Curl_hash_start_iterate(&bc->hash, &iter);
-
- he = Curl_hash_next_element(&iter);
- while(he) {
- struct connectdata *conn;
-
- bundle = he->ptr;
-
- curr = bundle->conn_list.head;
- while(curr) {
- conn = curr->ptr;
-
- if(!conn->inuse) {
- /* Set higher score for the age passed since the connection was used */
- score = Curl_tvdiff(now, conn->now);
-
- if(score > highscore) {
- highscore = score;
- conn_candidate = conn;
- }
- }
- curr = curr->next;
- }
-
- he = Curl_hash_next_element(&iter);
- }
-
- return conn_candidate;
-}
-
+#ifndef CURL_DISABLE_PROXY
static bool
proxy_info_matches(const struct proxy_info* data,
const struct proxy_info* needle)
@@ -3309,92 +873,68 @@ proxy_info_matches(const struct proxy_info* data,
return FALSE;
}
-
+#else
+/* disabled, won't get called */
+#define proxy_info_matches(x,y) FALSE
+#endif
/*
- * This function finds the connection in the connection
- * bundle that has been unused for the longest time.
+ * This function checks if the given connection is dead and extracts it from
+ * the connection cache if so.
*
- * Returns the pointer to the oldest idle connection, or NULL if none was
- * found.
- */
-static struct connectdata *
-find_oldest_idle_connection_in_bundle(struct Curl_easy *data,
- struct connectbundle *bundle)
-{
- struct curl_llist_element *curr;
- time_t highscore=-1;
- time_t score;
- struct timeval now;
- struct connectdata *conn_candidate = NULL;
- struct connectdata *conn;
-
- (void)data;
-
- now = Curl_tvnow();
-
- curr = bundle->conn_list.head;
- while(curr) {
- conn = curr->ptr;
-
- if(!conn->inuse) {
- /* Set higher score for the age passed since the connection was used */
- score = Curl_tvdiff(now, conn->now);
-
- if(score > highscore) {
- highscore = score;
- conn_candidate = conn;
- }
- }
- curr = curr->next;
- }
-
- return conn_candidate;
-}
-
-/*
- * This function checks if given connection is dead and disconnects if so.
- * (That also removes it from the connection cache.)
+ * When this is called as a Curl_conncache_foreach() callback, the connection
+ * cache lock is held!
*
- * Returns TRUE if the connection actually was dead and disconnected.
+ * Returns TRUE if the connection was dead and extracted.
*/
-static bool disconnect_if_dead(struct connectdata *conn,
- struct Curl_easy *data)
+static bool extract_if_dead(struct connectdata *conn,
+ struct Curl_easy *data)
{
- size_t pipeLen = conn->send_pipe.size + conn->recv_pipe.size;
- if(!pipeLen && !conn->inuse) {
- /* The check for a dead socket makes sense only if there are no
- handles in pipeline and the connection isn't already marked in
+ if(!CONN_INUSE(conn) && !conn->data) {
+ /* The check for a dead socket makes sense only if the connection isn't in
use */
bool dead;
- if(conn->handler->protocol & CURLPROTO_RTSP)
- /* RTSP is a special case due to RTP interleaving */
- dead = Curl_rtsp_connisdead(conn);
- else
+ if(conn->handler->connection_check) {
+ /* The protocol has a special method for checking the state of the
+ connection. Use it to check if the connection is dead. */
+ unsigned int state;
+ struct Curl_easy *olddata = conn->data;
+ conn->data = data; /* use this transfer for now */
+ state = conn->handler->connection_check(conn, CONNCHECK_ISDEAD);
+ conn->data = olddata;
+ dead = (state & CONNRESULT_DEAD);
+ }
+ else {
+ /* Use the general method for determining the death of a connection */
dead = SocketIsDead(conn->sock[FIRSTSOCKET]);
+ }
if(dead) {
- conn->data = data;
infof(data, "Connection %ld seems to be dead!\n", conn->connection_id);
-
- /* disconnect resources */
- Curl_disconnect(conn, /* dead_connection */TRUE);
+ Curl_conncache_remove_conn(data, conn, FALSE);
return TRUE;
}
}
return FALSE;
}
+struct prunedead {
+ struct Curl_easy *data;
+ struct connectdata *extracted;
+};
+
/*
- * Wrapper to use disconnect_if_dead() function in Curl_conncache_foreach()
+ * Wrapper to use extract_if_dead() function in Curl_conncache_foreach()
*
- * Returns always 0.
*/
-static int call_disconnect_if_dead(struct connectdata *conn,
- void *param)
+static int call_extract_if_dead(struct connectdata *conn, void *param)
{
- struct Curl_easy* data = (struct Curl_easy*)param;
- disconnect_if_dead(conn, data);
+ struct prunedead *p = (struct prunedead *)param;
+ if(extract_if_dead(conn, p->data)) {
+ /* stop the iteration here, pass back the connection that was extracted */
+ p->extracted = conn;
+ return 1;
+ }
return 0; /* continue iteration */
}
@@ -3405,23 +945,41 @@ static int call_disconnect_if_dead(struct connectdata *conn,
*/
static void prune_dead_connections(struct Curl_easy *data)
{
- struct timeval now = Curl_tvnow();
- time_t elapsed = Curl_tvdiff(now, data->state.conn_cache->last_cleanup);
+ struct curltime now = Curl_now();
+ time_t elapsed = Curl_timediff(now, data->state.conn_cache->last_cleanup);
if(elapsed >= 1000L) {
- Curl_conncache_foreach(data->state.conn_cache, data,
- call_disconnect_if_dead);
+ struct prunedead prune;
+ prune.data = data;
+ prune.extracted = NULL;
+ while(Curl_conncache_foreach(data, data->state.conn_cache, &prune,
+ call_extract_if_dead)) {
+ /* disconnect it */
+ (void)Curl_disconnect(data, prune.extracted, /* dead_connection */TRUE);
+ }
data->state.conn_cache->last_cleanup = now;
}
}
+/* A connection has to have been idle for a shorter time than 'maxage_conn' to
+ be subject for reuse. The success rate is just too low after this. */
-static size_t max_pipeline_length(struct Curl_multi *multi)
+static bool conn_maxage(struct Curl_easy *data,
+ struct connectdata *conn,
+ struct curltime now)
{
- return multi ? multi->max_pipeline_length : 0;
-}
-
+ if(!conn->data) {
+ timediff_t idletime = Curl_timediff(now, conn->lastused);
+ idletime /= 1000; /* integer seconds is fine */
+ if(idletime/1000 > data->set.maxage_conn) {
+ infof(data, "Too old connection (%ld seconds), disconnect it\n",
+ idletime);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
/*
* Given one filled in connection struct (named needle), this function should
* detect if there already is one that has all the significant details
@@ -3431,8 +989,7 @@ static size_t max_pipeline_length(struct Curl_multi *multi)
* connection as 'in-use'. It must later be called with ConnectionDone() to
* return back to 'idle' (unused) state.
*
- * The force_reuse flag is set if the connection must be used, even if
- * the pipelining strategy wants to open a new connection instead of reusing.
+ * The force_reuse flag is set if the connection must be used.
*/
static bool
ConnectionExists(struct Curl_easy *data,
@@ -3444,8 +1001,9 @@ ConnectionExists(struct Curl_easy *data,
struct connectdata *check;
struct connectdata *chosen = 0;
bool foundPendingCandidate = FALSE;
- int canpipe = IsPipeliningPossible(data, needle);
+ bool canmultiplex = IsMultiplexingPossible(data, needle);
struct connectbundle *bundle;
+ struct curltime now = Curl_now();
#ifdef USE_NTLM
bool wantNTLMhttp = ((data->state.authhost.want &
@@ -3460,58 +1018,47 @@ ConnectionExists(struct Curl_easy *data,
*force_reuse = FALSE;
*waitpipe = FALSE;
- /* We can't pipeline if the site is blacklisted */
- if((canpipe & CURLPIPE_HTTP1) &&
- Curl_pipeline_site_blacklisted(data, needle))
- canpipe &= ~ CURLPIPE_HTTP1;
-
- /* Look up the bundle with all the connections to this
- particular host */
+ /* Look up the bundle with all the connections to this particular host.
+ Locks the connection cache, beware of early returns! */
bundle = Curl_conncache_find_bundle(needle, data->state.conn_cache);
if(bundle) {
/* Max pipe length is zero (unlimited) for multiplexed connections */
- size_t max_pipe_len = (bundle->multiuse != BUNDLE_MULTIPLEX)?
- max_pipeline_length(data->multi):0;
- size_t best_pipe_len = max_pipe_len;
struct curl_llist_element *curr;
infof(data, "Found bundle for host %s: %p [%s]\n",
(needle->bits.conn_to_host ? needle->conn_to_host.name :
needle->host.name), (void *)bundle,
- (bundle->multiuse == BUNDLE_PIPELINING ?
- "can pipeline" :
- (bundle->multiuse == BUNDLE_MULTIPLEX ?
- "can multiplex" : "serially")));
-
- /* We can't pipeline if we don't know anything about the server */
- if(canpipe) {
- if(bundle->multiuse <= BUNDLE_UNKNOWN) {
+ (bundle->multiuse == BUNDLE_MULTIPLEX ?
+ "can multiplex" : "serially"));
+
+ /* We can't multiplex if we don't know anything about the server */
+ if(canmultiplex) {
+ if(bundle->multiuse == BUNDLE_UNKNOWN) {
if((bundle->multiuse == BUNDLE_UNKNOWN) && data->set.pipewait) {
- infof(data, "Server doesn't support multi-use yet, wait\n");
+ infof(data, "Server doesn't support multiplex yet, wait\n");
*waitpipe = TRUE;
+ Curl_conncache_unlock(data);
return FALSE; /* no re-use */
}
- infof(data, "Server doesn't support multi-use (yet)\n");
- canpipe = 0;
+ infof(data, "Server doesn't support multiplex (yet)\n");
+ canmultiplex = FALSE;
}
- if((bundle->multiuse == BUNDLE_PIPELINING) &&
- !Curl_pipeline_wanted(data->multi, CURLPIPE_HTTP1)) {
- /* not asked for, switch off */
- infof(data, "Could pipeline, but not asked to!\n");
- canpipe = 0;
- }
- else if((bundle->multiuse == BUNDLE_MULTIPLEX) &&
- !Curl_pipeline_wanted(data->multi, CURLPIPE_MULTIPLEX)) {
+ if((bundle->multiuse == BUNDLE_MULTIPLEX) &&
+ !Curl_multiplex_wanted(data->multi)) {
infof(data, "Could multiplex, but not asked to!\n");
- canpipe = 0;
+ canmultiplex = FALSE;
+ }
+ if(bundle->multiuse == BUNDLE_NO_MULTIUSE) {
+ infof(data, "Can not multiplex, even if we wanted to!\n");
+ canmultiplex = FALSE;
}
}
curr = bundle->conn_list.head;
while(curr) {
bool match = FALSE;
- size_t pipeLen;
+ size_t multiplexed;
/*
* Note that if we use a HTTP proxy in normal mode (no tunneling), we
@@ -3520,32 +1067,25 @@ ConnectionExists(struct Curl_easy *data,
check = curr->ptr;
curr = curr->next;
- if(disconnect_if_dead(check, data))
+ if(check->bits.connect_only)
+ /* connect-only connections will not be reused */
continue;
- pipeLen = check->send_pipe.size + check->recv_pipe.size;
+ if(conn_maxage(data, check, now) || extract_if_dead(check, data)) {
+ /* disconnect it */
+ (void)Curl_disconnect(data, check, /* dead_connection */TRUE);
+ continue;
+ }
+
+ multiplexed = CONN_INUSE(check) &&
+ (bundle->multiuse == BUNDLE_MULTIPLEX);
- if(canpipe) {
+ if(canmultiplex) {
if(check->bits.protoconnstart && check->bits.close)
continue;
-
- if(!check->bits.multiplex) {
- /* If not multiplexing, make sure the connection is fine for HTTP/1
- pipelining */
- struct Curl_easy* sh = gethandleathead(&check->send_pipe);
- struct Curl_easy* rh = gethandleathead(&check->recv_pipe);
- if(sh) {
- if(!(IsPipeliningPossible(sh, check) & CURLPIPE_HTTP1))
- continue;
- }
- else if(rh) {
- if(!(IsPipeliningPossible(rh, check) & CURLPIPE_HTTP1))
- continue;
- }
- }
}
else {
- if(pipeLen > 0) {
+ if(multiplexed) {
/* can only happen within multi handles, and means that another easy
handle is using this connection */
continue;
@@ -3570,13 +1110,6 @@ ConnectionExists(struct Curl_easy *data,
to get closed. */
infof(data, "Connection #%ld isn't open enough, can't reuse\n",
check->connection_id);
-#ifdef DEBUGBUILD
- if(check->recv_pipe.size > 0) {
- infof(data,
- "BAD! Unconnected #%ld has a non-empty recv pipeline!\n",
- check->connection_id);
- }
-#endif
continue;
}
}
@@ -3647,11 +1180,17 @@ ConnectionExists(struct Curl_easy *data,
}
}
- if(!canpipe && check->inuse)
- /* this request can't be pipelined but the checked connection is
+ if(!canmultiplex && check->data)
+ /* this request can't be multiplexed but the checked connection is
already in use so we skip it */
continue;
+ if(CONN_INUSE(check) && check->data &&
+ (check->data->multi != needle->data->multi))
+ /* this could be subject for multiplex use, but only if they belong to
+ * the same multi handle */
+ continue;
+
if(needle->localdev || needle->localport) {
/* If we are bound to a specific local end (IP+port), we must not
re-use a random other one, although if we didn't ask for a
@@ -3740,7 +1279,7 @@ ConnectionExists(struct Curl_easy *data,
strcmp(needle->passwd, check->passwd))
continue;
}
- else if(check->ntlm.state != NTLMSTATE_NONE) {
+ else if(check->http_ntlm_state != NTLMSTATE_NONE) {
/* Connection is using NTLM auth but we don't want NTLM */
continue;
}
@@ -3756,7 +1295,7 @@ ConnectionExists(struct Curl_easy *data,
strcmp(needle->http_proxy.passwd, check->http_proxy.passwd))
continue;
}
- else if(check->proxyntlm.state != NTLMSTATE_NONE) {
+ else if(check->proxy_ntlm_state != NTLMSTATE_NONE) {
/* Proxy connection is using NTLM auth but we don't want NTLM */
continue;
}
@@ -3766,9 +1305,9 @@ ConnectionExists(struct Curl_easy *data,
chosen = check;
if((wantNTLMhttp &&
- (check->ntlm.state != NTLMSTATE_NONE)) ||
+ (check->http_ntlm_state != NTLMSTATE_NONE)) ||
(wantProxyNTLMhttp &&
- (check->proxyntlm.state != NTLMSTATE_NONE))) {
+ (check->proxy_ntlm_state != NTLMSTATE_NONE))) {
/* We must use this connection, no other */
*force_reuse = TRUE;
break;
@@ -3778,55 +1317,32 @@ ConnectionExists(struct Curl_easy *data,
continue;
}
#endif
- if(canpipe) {
- /* We can pipeline if we want to. Let's continue looking for
- the optimal connection to use, i.e the shortest pipe that is not
- blacklisted. */
+ if(canmultiplex) {
+ /* We can multiplex if we want to. Let's continue looking for
+ the optimal connection to use. */
- if(pipeLen == 0) {
+ if(!multiplexed) {
/* We have the optimal connection. Let's stop looking. */
chosen = check;
break;
}
- /* We can't use the connection if the pipe is full */
- if(max_pipe_len && (pipeLen >= max_pipe_len)) {
- infof(data, "Pipe is full, skip (%zu)\n", pipeLen);
- continue;
- }
#ifdef USE_NGHTTP2
/* If multiplexed, make sure we don't go over concurrency limit */
if(check->bits.multiplex) {
/* Multiplexed connections can only be HTTP/2 for now */
struct http_conn *httpc = &check->proto.httpc;
- if(pipeLen >= httpc->settings.max_concurrent_streams) {
+ if(multiplexed >= httpc->settings.max_concurrent_streams) {
infof(data, "MAX_CONCURRENT_STREAMS reached, skip (%zu)\n",
- pipeLen);
+ multiplexed);
continue;
}
}
#endif
- /* We can't use the connection if the pipe is penalized */
- if(Curl_pipeline_penalized(data, check)) {
- infof(data, "Penalized, skip\n");
- continue;
- }
-
- if(max_pipe_len) {
- if(pipeLen < best_pipe_len) {
- /* This connection has a shorter pipe so far. We'll pick this
- and continue searching */
- chosen = check;
- best_pipe_len = pipeLen;
- continue;
- }
- }
- else {
- /* When not pipelining (== multiplexed), we have a match here! */
- chosen = check;
- infof(data, "Multiplexed connection found!\n");
- break;
- }
+ /* When not multiplexed, we have a match here! */
+ chosen = check;
+ infof(data, "Multiplexed connection found!\n");
+ break;
}
else {
/* We have found a connection. Let's stop searching. */
@@ -3838,9 +1354,13 @@ ConnectionExists(struct Curl_easy *data,
}
if(chosen) {
+ /* mark it as used before releasing the lock */
+ chosen->data = data; /* own it! */
+ Curl_conncache_unlock(data);
*usethis = chosen;
return TRUE; /* yes, we found one to use! */
}
+ Curl_conncache_unlock(data);
if(foundPendingCandidate && data->set.pipewait) {
infof(data,
@@ -3925,7 +1445,11 @@ int Curl_protocol_getsock(struct connectdata *conn,
{
if(conn->handler->proto_getsock)
return conn->handler->proto_getsock(conn, socks, numsocks);
- return GETSOCK_BLANK;
+ /* Backup getsock logic. Since there is a live socket in use, we must wait
+ for it or it will be removed from watching when the multi_socket API is
+ used. */
+ socks[0] = conn->sock[FIRSTSOCKET];
+ return GETSOCK_READSOCK(0) | GETSOCK_WRITESOCK(0);
}
int Curl_doing_getsock(struct connectdata *conn,
@@ -3946,7 +1470,7 @@ int Curl_doing_getsock(struct connectdata *conn,
CURLcode Curl_protocol_connecting(struct connectdata *conn,
bool *done)
{
- CURLcode result=CURLE_OK;
+ CURLcode result = CURLE_OK;
if(conn && conn->handler->connecting) {
*done = FALSE;
@@ -3965,7 +1489,7 @@ CURLcode Curl_protocol_connecting(struct connectdata *conn,
CURLcode Curl_protocol_doing(struct connectdata *conn, bool *done)
{
- CURLcode result=CURLE_OK;
+ CURLcode result = CURLE_OK;
if(conn && conn->handler->doing) {
*done = FALSE;
@@ -3985,7 +1509,7 @@ CURLcode Curl_protocol_doing(struct connectdata *conn, bool *done)
CURLcode Curl_protocol_connect(struct connectdata *conn,
bool *protocol_done)
{
- CURLcode result=CURLE_OK;
+ CURLcode result = CURLE_OK;
*protocol_done = FALSE;
@@ -4013,7 +1537,7 @@ CURLcode Curl_protocol_connect(struct connectdata *conn,
return CURLE_OK;
if(conn->bits.tunnel_proxy && conn->bits.httpproxy &&
- (conn->tunnel_state[FIRSTSOCKET] != TUNNEL_COMPLETE))
+ Curl_connect_ongoing(conn))
/* when using an HTTP tunnel proxy, await complete tunnel establishment
before proceeding further. Return CURLE_OK so we'll be called again */
return CURLE_OK;
@@ -4051,11 +1575,25 @@ static bool is_ASCII_name(const char *hostname)
}
/*
- * Perform any necessary IDN conversion of hostname
+ * Strip single trailing dot in the hostname,
+ * primarily for SNI and http host header.
*/
-static void fix_hostname(struct connectdata *conn, struct hostname *host)
+static void strip_trailing_dot(struct hostname *host)
{
size_t len;
+ if(!host || !host->name)
+ return;
+ len = strlen(host->name);
+ if(len && (host->name[len-1] == '.'))
+ host->name[len-1] = 0;
+}
+
+/*
+ * Perform any necessary IDN conversion of hostname
+ */
+static CURLcode idnconvert_hostname(struct connectdata *conn,
+ struct hostname *host)
+{
struct Curl_easy *data = conn->data;
#ifndef USE_LIBIDN2
@@ -4068,12 +1606,6 @@ static void fix_hostname(struct connectdata *conn, struct hostname *host)
/* set the name we use to display the host name */
host->dispname = host->name;
- len = strlen(host->name);
- if(len && (host->name[len-1] == '.'))
- /* strip off a single trailing dot if present, primarily for SNI but
- there's no use for it */
- host->name[len-1]=0;
-
/* Check name for non-ASCII and convert hostname to ACE form if we can */
if(!is_ASCII_name(host->name)) {
#ifdef USE_LIBIDN2
@@ -4093,9 +1625,11 @@ static void fix_hostname(struct connectdata *conn, struct hostname *host)
/* change the name pointer to point to the encoded hostname */
host->name = host->encalloc;
}
- else
- infof(data, "Failed to convert %s to ACE; %s\n", host->name,
+ else {
+ failf(data, "Failed to convert %s to ACE; %s\n", host->name,
idn2_strerror(rc));
+ return CURLE_URL_MALFORMAT;
+ }
}
#elif defined(USE_WIN32_IDN)
char *ace_hostname = NULL;
@@ -4105,18 +1639,21 @@ static void fix_hostname(struct connectdata *conn, struct hostname *host)
/* change the name pointer to point to the encoded hostname */
host->name = host->encalloc;
}
- else
- infof(data, "Failed to convert %s to ACE;\n", host->name);
+ else {
+ failf(data, "Failed to convert %s to ACE;\n", host->name);
+ return CURLE_URL_MALFORMAT;
+ }
#else
infof(data, "IDN support not present, can't parse Unicode domains\n");
#endif
}
+ return CURLE_OK;
}
/*
- * Frees data allocated by fix_hostname()
+ * Frees data allocated by idnconvert_hostname()
*/
-static void free_fixed_hostname(struct hostname *host)
+static void free_idnconverted_hostname(struct hostname *host)
{
#if defined(USE_LIBIDN2)
if(host->encalloc) {
@@ -4125,7 +1662,7 @@ static void free_fixed_hostname(struct hostname *host)
host->encalloc = NULL;
}
#elif defined(USE_WIN32_IDN)
- free(host->encalloc); /* must be freed withidn_free() since this was
+ free(host->encalloc); /* must be freed with free() since this was
allocated by curl_win32_idn_to_ascii */
host->encalloc = NULL;
#else
@@ -4149,6 +1686,26 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
if(!conn)
return NULL;
+#ifdef USE_SSL
+ /* The SSL backend-specific data (ssl_backend_data) objects are allocated as
+ a separate array to ensure suitable alignment.
+ Note that these backend pointers can be swapped by vtls (eg ssl backend
+ data becomes proxy backend data). */
+ {
+ size_t sslsize = Curl_ssl->sizeof_ssl_backend_data;
+ char *ssl = calloc(4, sslsize);
+ if(!ssl) {
+ free(conn);
+ return NULL;
+ }
+ conn->ssl_extra = ssl;
+ conn->ssl[0].backend = (void *)ssl;
+ conn->ssl[1].backend = (void *)(ssl + sslsize);
+ conn->proxy_ssl[0].backend = (void *)(ssl + 2 * sslsize);
+ conn->proxy_ssl[1].backend = (void *)(ssl + 3 * sslsize);
+ }
+#endif
+
conn->handler = &Curl_handler_dummy; /* Be sure we have a handler defined
already from start to avoid NULL
situations and checks */
@@ -4173,7 +1730,13 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
connclose(conn, "Default to force-close");
/* Store creation time to help future close decision making */
- conn->created = Curl_tvnow();
+ conn->created = Curl_now();
+
+ /* Store current time to give a baseline to keepalive connection times. */
+ conn->keepalive = Curl_now();
+
+ /* Store off the configured connection upkeep time. */
+ conn->upkeep_interval_ms = data->set.upkeep_interval_ms;
conn->data = data; /* Setup the association between this connection
and the Curl_easy */
@@ -4181,16 +1744,7 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
conn->http_proxy.proxytype = data->set.proxytype;
conn->socks_proxy.proxytype = CURLPROXY_SOCKS4;
-#ifdef CURL_DISABLE_PROXY
-
- conn->bits.proxy = FALSE;
- conn->bits.httpproxy = FALSE;
- conn->bits.socksproxy = FALSE;
- conn->bits.proxy_user_passwd = FALSE;
- conn->bits.tunnel_proxy = FALSE;
-
-#else /* CURL_DISABLE_PROXY */
-
+#if !defined(CURL_DISABLE_PROXY)
/* note that these two proxy bits are now just on what looks to be
requested, they may be altered down the road */
conn->bits.proxy = (data->set.str[STRING_PROXY] &&
@@ -4211,13 +1765,13 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
conn->bits.proxy_user_passwd =
(data->set.str[STRING_PROXYUSERNAME]) ? TRUE : FALSE;
conn->bits.tunnel_proxy = data->set.tunnel_thru_httpproxy;
-
#endif /* CURL_DISABLE_PROXY */
conn->bits.user_passwd = (data->set.str[STRING_USERNAME]) ? TRUE : FALSE;
+#ifndef CURL_DISABLE_FTP
conn->bits.ftp_use_epsv = data->set.ftp_use_epsv;
conn->bits.ftp_use_eprt = data->set.ftp_use_eprt;
-
+#endif
conn->ssl_config.verifystatus = data->set.ssl.primary.verifystatus;
conn->ssl_config.verifypeer = data->set.ssl.primary.verifypeer;
conn->ssl_config.verifyhost = data->set.ssl.primary.verifyhost;
@@ -4225,28 +1779,16 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
data->set.proxy_ssl.primary.verifystatus;
conn->proxy_ssl_config.verifypeer = data->set.proxy_ssl.primary.verifypeer;
conn->proxy_ssl_config.verifyhost = data->set.proxy_ssl.primary.verifyhost;
-
conn->ip_version = data->set.ipver;
+ conn->bits.connect_only = data->set.connect_only;
#if !defined(CURL_DISABLE_HTTP) && defined(USE_NTLM) && \
defined(NTLM_WB_ENABLED)
conn->ntlm_auth_hlpr_socket = CURL_SOCKET_BAD;
- conn->ntlm_auth_hlpr_pid = 0;
- conn->challenge_header = NULL;
- conn->response_header = NULL;
#endif
- if(Curl_pipeline_wanted(data->multi, CURLPIPE_HTTP1) &&
- !conn->master_buffer) {
- /* Allocate master_buffer to be used for HTTP/1 pipelining */
- conn->master_buffer = calloc(MASTERBUF_SIZE, sizeof(char));
- if(!conn->master_buffer)
- goto error;
- }
-
- /* Initialize the pipeline lists */
- Curl_llist_init(&conn->send_pipe, (curl_llist_dtor) llist_dtor);
- Curl_llist_init(&conn->recv_pipe, (curl_llist_dtor) llist_dtor);
+ /* Initialize the easy handle list */
+ Curl_llist_init(&conn->easyq, (curl_llist_dtor) llist_dtor);
#ifdef HAVE_GSSAPI
conn->data_prot = PROT_CLEAR;
@@ -4269,39 +1811,46 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
return conn;
error:
- Curl_llist_destroy(&conn->send_pipe, NULL);
- Curl_llist_destroy(&conn->recv_pipe, NULL);
-
- free(conn->master_buffer);
+ Curl_llist_destroy(&conn->easyq, NULL);
free(conn->localdev);
+#ifdef USE_SSL
+ free(conn->ssl_extra);
+#endif
free(conn);
return NULL;
}
-static CURLcode findprotocol(struct Curl_easy *data,
- struct connectdata *conn,
- const char *protostr)
+/* returns the handler if the given scheme is built-in */
+const struct Curl_handler *Curl_builtin_scheme(const char *scheme)
{
const struct Curl_handler * const *pp;
const struct Curl_handler *p;
-
- /* Scan protocol handler table and match against 'protostr' to set a few
- variables based on the URL. Now that the handler may be changed later
- when the protocol specific setup function is called. */
- for(pp = protocols; (p = *pp) != NULL; pp++) {
- if(strcasecompare(p->scheme, protostr)) {
+ /* Scan protocol handler table and match against 'scheme'. The handler may
+ be changed later when the protocol specific setup function is called. */
+ for(pp = protocols; (p = *pp) != NULL; pp++)
+ if(strcasecompare(p->scheme, scheme))
/* Protocol found in table. Check if allowed */
- if(!(data->set.allowed_protocols & p->protocol))
- /* nope, get out */
- break;
+ return p;
+ return NULL; /* not found */
+}
- /* it is allowed for "normal" request, now do an extra check if this is
- the result of a redirect */
- if(data->state.this_is_a_follow &&
- !(data->set.redir_protocols & p->protocol))
- /* nope, get out */
- break;
+static CURLcode findprotocol(struct Curl_easy *data,
+ struct connectdata *conn,
+ const char *protostr)
+{
+ const struct Curl_handler *p = Curl_builtin_scheme(protostr);
+
+ if(p && /* Protocol found in table. Check if allowed */
+ (data->set.allowed_protocols & p->protocol)) {
+
+ /* it is allowed for "normal" request, now do an extra check if this is
+ the result of a redirect */
+ if(data->state.this_is_a_follow &&
+ !(data->set.redir_protocols & p->protocol))
+ /* nope, get out */
+ ;
+ else {
/* Perform setup complement if some. */
conn->handler = conn->given = p;
@@ -4310,7 +1859,6 @@ static CURLcode findprotocol(struct Curl_easy *data,
}
}
-
/* The protocol was not found in the table, but we don't have to assign it
to anything since it is already assigned to a dummy-struct in the
create_conn() function when the connectdata struct is allocated. */
@@ -4320,454 +1868,190 @@ static CURLcode findprotocol(struct Curl_easy *data,
return CURLE_UNSUPPORTED_PROTOCOL;
}
+
+CURLcode Curl_uc_to_curlcode(CURLUcode uc)
+{
+ switch(uc) {
+ default:
+ return CURLE_URL_MALFORMAT;
+ case CURLUE_UNSUPPORTED_SCHEME:
+ return CURLE_UNSUPPORTED_PROTOCOL;
+ case CURLUE_OUT_OF_MEMORY:
+ return CURLE_OUT_OF_MEMORY;
+ case CURLUE_USER_NOT_ALLOWED:
+ return CURLE_LOGIN_DENIED;
+ }
+}
+
/*
* Parse URL and fill in the relevant members of the connection struct.
*/
static CURLcode parseurlandfillconn(struct Curl_easy *data,
- struct connectdata *conn,
- bool *prot_missing,
- char **userp, char **passwdp,
- char **optionsp)
+ struct connectdata *conn)
{
- char *at;
- char *fragment;
- char *path = data->state.path;
- char *query;
- int i;
- int rc;
- const char *protop = "";
CURLcode result;
- bool rebuild_url = FALSE;
- bool url_has_scheme = FALSE;
- char protobuf[16];
-
- *prot_missing = FALSE;
+ CURLU *uh;
+ CURLUcode uc;
+ char *hostname;
- /* We might pass the entire URL into the request so we need to make sure
- * there are no bad characters in there.*/
- if(strpbrk(data->change.url, "\r\n")) {
- failf(data, "Illegal characters found in URL");
- return CURLE_URL_MALFORMAT;
- }
+ up_free(data); /* cleanup previous leftovers first */
- /*************************************************************
- * Parse the URL.
- *
- * We need to parse the url even when using the proxy, because we will need
- * the hostname and port in case we are trying to SSL connect through the
- * proxy -- and we don't know if we will need to use SSL until we parse the
- * url ...
- ************************************************************/
- if(data->change.url[0] == ':') {
- failf(data, "Bad URL, colon is first character");
- return CURLE_URL_MALFORMAT;
+ /* parse the URL */
+ if(data->set.uh) {
+ uh = data->state.uh = curl_url_dup(data->set.uh);
}
-
- /* Make sure we don't mistake a drive letter for a scheme, for example:
- curld --proto-default file c:/foo/bar.txt */
- if((('a' <= data->change.url[0] && data->change.url[0] <= 'z') ||
- ('A' <= data->change.url[0] && data->change.url[0] <= 'Z')) &&
- data->change.url[1] == ':' && data->set.str[STRING_DEFAULT_PROTOCOL] &&
- strcasecompare(data->set.str[STRING_DEFAULT_PROTOCOL], "file")) {
- ; /* do nothing */
- }
- else { /* check for a scheme */
- for(i = 0; i < 16 && data->change.url[i]; ++i) {
- if(data->change.url[i] == '/')
- break;
- if(data->change.url[i] == ':') {
- url_has_scheme = TRUE;
- break;
- }
- }
+ else {
+ uh = data->state.uh = curl_url();
}
- /* handle the file: scheme */
- if((url_has_scheme && strncasecompare(data->change.url, "file:", 5)) ||
- (!url_has_scheme && data->set.str[STRING_DEFAULT_PROTOCOL] &&
- strcasecompare(data->set.str[STRING_DEFAULT_PROTOCOL], "file"))) {
- bool path_has_drive = FALSE;
-
- if(url_has_scheme)
- rc = sscanf(data->change.url, "%*15[^\n/:]:%[^\n]", path);
- else
- rc = sscanf(data->change.url, "%[^\n]", path);
-
- if(rc != 1) {
- failf(data, "Bad URL");
- return CURLE_URL_MALFORMAT;
- }
-
- if(url_has_scheme && path[0] == '/' && path[1] == '/') {
- /* Allow omitted hostname (e.g. file:/<path>). This is not strictly
- * speaking a valid file: URL by RFC 1738, but treating file:/<path> as
- * file://localhost/<path> is similar to how other schemes treat missing
- * hostnames. See RFC 1808. */
-
- /* This cannot be done with strcpy() in a portable manner, since the
- memory areas overlap! */
- memmove(path, path + 2, strlen(path + 2)+1);
- }
-
- /* the path may start with a drive letter. for backwards compatibility
- we skip some processing on those paths. */
- path_has_drive = (('a' <= path[0] && path[0] <= 'z') ||
- ('A' <= path[0] && path[0] <= 'Z')) && path[1] == ':';
-
- /*
- * we deal with file://<host>/<path> differently since it supports no
- * hostname other than "localhost" and "127.0.0.1", which is unique among
- * the URL protocols specified in RFC 1738
- */
- if(path[0] != '/' && !path_has_drive) {
- /* the URL includes a host name, it must match "localhost" or
- "127.0.0.1" to be valid */
- char *ptr;
- if(!checkprefix("localhost/", path) &&
- !checkprefix("127.0.0.1/", path)) {
- failf(data, "Invalid file://hostname/, "
- "expected localhost or 127.0.0.1 or none");
- return CURLE_URL_MALFORMAT;
- }
- ptr = &path[9]; /* now points to the slash after the host */
-
- /* there was a host name and slash present
-
- RFC1738 (section 3.1, page 5) says:
-
- The rest of the locator consists of data specific to the scheme,
- and is known as the "url-path". It supplies the details of how the
- specified resource can be accessed. Note that the "/" between the
- host (or port) and the url-path is NOT part of the url-path.
-
- As most agents use file://localhost/foo to get '/foo' although the
- slash preceding foo is a separator and not a slash for the path,
- a URL as file://localhost//foo must be valid as well, to refer to
- the same file with an absolute path.
- */
-
- if('/' == ptr[1])
- /* if there was two slashes, we skip the first one as that is then
- used truly as a separator */
- ptr++;
-
- /* This cannot be made with strcpy, as the memory chunks overlap! */
- memmove(path, ptr, strlen(ptr)+1);
-
- path_has_drive = (('a' <= path[0] && path[0] <= 'z') ||
- ('A' <= path[0] && path[0] <= 'Z')) && path[1] == ':';
- }
+ if(!uh)
+ return CURLE_OUT_OF_MEMORY;
-#if !defined(MSDOS) && !defined(WIN32) && !defined(__CYGWIN__)
- if(path_has_drive) {
- failf(data, "File drive letters are only accepted in MSDOS/Windows.");
- return CURLE_URL_MALFORMAT;
+ if(data->set.str[STRING_DEFAULT_PROTOCOL] &&
+ !Curl_is_absolute_url(data->change.url, NULL, MAX_SCHEME_LEN)) {
+ char *url;
+ if(data->change.url_alloc)
+ free(data->change.url);
+ url = aprintf("%s://%s", data->set.str[STRING_DEFAULT_PROTOCOL],
+ data->change.url);
+ if(!url)
+ return CURLE_OUT_OF_MEMORY;
+ data->change.url = url;
+ data->change.url_alloc = TRUE;
+ }
+
+ if(!data->set.uh) {
+ uc = curl_url_set(uh, CURLUPART_URL, data->change.url,
+ CURLU_GUESS_SCHEME |
+ CURLU_NON_SUPPORT_SCHEME |
+ (data->set.disallow_username_in_url ?
+ CURLU_DISALLOW_USER : 0) |
+ (data->set.path_as_is ? CURLU_PATH_AS_IS : 0));
+ if(uc) {
+ DEBUGF(infof(data, "curl_url_set rejected %s\n", data->change.url));
+ return Curl_uc_to_curlcode(uc);
}
-#endif
-
- protop = "file"; /* protocol string */
- *prot_missing = !url_has_scheme;
}
- else {
- /* clear path */
- char slashbuf[4];
- path[0]=0;
-
- rc = sscanf(data->change.url,
- "%15[^\n/:]:%3[/]%[^\n/?#]%[^\n]",
- protobuf, slashbuf, conn->host.name, path);
- if(2 == rc) {
- failf(data, "Bad URL");
- return CURLE_URL_MALFORMAT;
- }
- if(3 > rc) {
-
- /*
- * The URL was badly formatted, let's try the browser-style _without_
- * protocol specified like 'http://'.
- */
- rc = sscanf(data->change.url, "%[^\n/?#]%[^\n]", conn->host.name, path);
- if(1 > rc) {
- /*
- * We couldn't even get this format.
- * djgpp 2.04 has a sscanf() bug where 'conn->host.name' is
- * assigned, but the return value is EOF!
- */
-#if defined(__DJGPP__) && (DJGPP_MINOR == 4)
- if(!(rc == -1 && *conn->host.name))
-#endif
- {
- failf(data, "<url> malformed");
- return CURLE_URL_MALFORMAT;
- }
- }
- /*
- * Since there was no protocol part specified in the URL use the
- * user-specified default protocol. If we weren't given a default make a
- * guess by matching some protocols against the host's outermost
- * sub-domain name. Finally if there was no match use HTTP.
- */
+ uc = curl_url_get(uh, CURLUPART_SCHEME, &data->state.up.scheme, 0);
+ if(uc)
+ return Curl_uc_to_curlcode(uc);
- protop = data->set.str[STRING_DEFAULT_PROTOCOL];
- if(!protop) {
- /* Note: if you add a new protocol, please update the list in
- * lib/version.c too! */
- if(checkprefix("FTP.", conn->host.name))
- protop = "ftp";
- else if(checkprefix("DICT.", conn->host.name))
- protop = "DICT";
- else if(checkprefix("LDAP.", conn->host.name))
- protop = "LDAP";
- else if(checkprefix("IMAP.", conn->host.name))
- protop = "IMAP";
- else if(checkprefix("SMTP.", conn->host.name))
- protop = "smtp";
- else if(checkprefix("POP3.", conn->host.name))
- protop = "pop3";
- else
- protop = "http";
- }
+ result = findprotocol(data, conn, data->state.up.scheme);
+ if(result)
+ return result;
- *prot_missing = TRUE; /* not given in URL */
- }
- else {
- size_t s = strlen(slashbuf);
- protop = protobuf;
- if(s != 2) {
- infof(data, "Unwillingly accepted illegal URL using %d slash%s!\n",
- s, s>1?"es":"");
-
- if(data->change.url_alloc)
- free(data->change.url);
- /* repair the URL to use two slashes */
- data->change.url = aprintf("%s://%s%s",
- protobuf, conn->host.name, path);
- if(!data->change.url)
- return CURLE_OUT_OF_MEMORY;
- data->change.url_alloc = TRUE;
- }
- }
+ uc = curl_url_get(uh, CURLUPART_USER, &data->state.up.user,
+ CURLU_URLDECODE);
+ if(!uc) {
+ conn->user = strdup(data->state.up.user);
+ if(!conn->user)
+ return CURLE_OUT_OF_MEMORY;
+ conn->bits.user_passwd = TRUE;
}
+ else if(uc != CURLUE_NO_USER)
+ return Curl_uc_to_curlcode(uc);
- /* We search for '?' in the host name (but only on the right side of a
- * @-letter to allow ?-letters in username and password) to handle things
- * like http://example.com?param= (notice the missing '/').
- */
- at = strchr(conn->host.name, '@');
- if(at)
- query = strchr(at+1, '?');
- else
- query = strchr(conn->host.name, '?');
-
- if(query) {
- /* We must insert a slash before the '?'-letter in the URL. If the URL had
- a slash after the '?', that is where the path currently begins and the
- '?string' is still part of the host name.
-
- We must move the trailing part from the host name and put it first in
- the path. And have it all prefixed with a slash.
- */
-
- size_t hostlen = strlen(query);
- size_t pathlen = strlen(path);
-
- /* move the existing path plus the zero byte forward, to make room for
- the host-name part */
- memmove(path+hostlen+1, path, pathlen+1);
-
- /* now copy the trailing host part in front of the existing path */
- memcpy(path+1, query, hostlen);
-
- path[0]='/'; /* prepend the missing slash */
- rebuild_url = TRUE;
-
- *query=0; /* now cut off the hostname at the ? */
- }
- else if(!path[0]) {
- /* if there's no path set, use a single slash */
- strcpy(path, "/");
- rebuild_url = TRUE;
+ uc = curl_url_get(uh, CURLUPART_PASSWORD, &data->state.up.password,
+ CURLU_URLDECODE);
+ if(!uc) {
+ conn->passwd = strdup(data->state.up.password);
+ if(!conn->passwd)
+ return CURLE_OUT_OF_MEMORY;
+ conn->bits.user_passwd = TRUE;
}
+ else if(uc != CURLUE_NO_PASSWORD)
+ return Curl_uc_to_curlcode(uc);
- /* If the URL is malformatted (missing a '/' after hostname before path) we
- * insert a slash here. The only letters except '/' that can start a path is
- * '?' and '#' - as controlled by the two sscanf() patterns above.
- */
- if(path[0] != '/') {
- /* We need this function to deal with overlapping memory areas. We know
- that the memory area 'path' points to is 'urllen' bytes big and that
- is bigger than the path. Use +1 to move the zero byte too. */
- memmove(&path[1], path, strlen(path)+1);
- path[0] = '/';
- rebuild_url = TRUE;
- }
- else if(!data->set.path_as_is) {
- /* sanitise paths and remove ../ and ./ sequences according to RFC3986 */
- char *newp = Curl_dedotdotify(path);
- if(!newp)
+ uc = curl_url_get(uh, CURLUPART_OPTIONS, &data->state.up.options,
+ CURLU_URLDECODE);
+ if(!uc) {
+ conn->options = strdup(data->state.up.options);
+ if(!conn->options)
return CURLE_OUT_OF_MEMORY;
-
- if(strcmp(newp, path)) {
- rebuild_url = TRUE;
- free(data->state.pathbuffer);
- data->state.pathbuffer = newp;
- data->state.path = newp;
- path = newp;
- }
- else
- free(newp);
}
+ else if(uc != CURLUE_NO_OPTIONS)
+ return Curl_uc_to_curlcode(uc);
- /*
- * "rebuild_url" means that one or more URL components have been modified so
- * we need to generate an updated full version. We need the corrected URL
- * when communicating over HTTP proxy and we don't know at this point if
- * we're using a proxy or not.
- */
- if(rebuild_url) {
- char *reurl;
-
- size_t plen = strlen(path); /* new path, should be 1 byte longer than
- the original */
- size_t prefixlen = strlen(conn->host.name);
-
- if(!*prot_missing) {
- size_t protolen = strlen(protop);
-
- if(curl_strnequal(protop, data->change.url, protolen))
- prefixlen += protolen;
- else {
- failf(data, "<url> malformed");
- return CURLE_URL_MALFORMAT;
- }
-
- if(curl_strnequal("://", &data->change.url[protolen], 3))
- prefixlen += 3;
- /* only file: is allowed to omit one or both slashes */
- else if(curl_strnequal("file:", data->change.url, 5))
- prefixlen += 1 + (data->change.url[5] == '/');
- else {
- failf(data, "<url> malformed");
- return CURLE_URL_MALFORMAT;
- }
- }
-
- reurl = malloc(prefixlen + plen + 1);
- if(!reurl)
+ uc = curl_url_get(uh, CURLUPART_HOST, &data->state.up.hostname, 0);
+ if(uc) {
+ if(!strcasecompare("file", data->state.up.scheme))
return CURLE_OUT_OF_MEMORY;
+ }
- /* copy the prefix */
- memcpy(reurl, data->change.url, prefixlen);
-
- /* append the trailing piece + zerobyte */
- memcpy(&reurl[prefixlen], path, plen + 1);
-
- /* possible free the old one */
- if(data->change.url_alloc) {
- Curl_safefree(data->change.url);
- data->change.url_alloc = FALSE;
- }
-
- infof(data, "Rebuilt URL to: %s\n", reurl);
+ uc = curl_url_get(uh, CURLUPART_PATH, &data->state.up.path, 0);
+ if(uc)
+ return Curl_uc_to_curlcode(uc);
- data->change.url = reurl;
- data->change.url_alloc = TRUE; /* free this later */
+ uc = curl_url_get(uh, CURLUPART_PORT, &data->state.up.port,
+ CURLU_DEFAULT_PORT);
+ if(uc) {
+ if(!strcasecompare("file", data->state.up.scheme))
+ return CURLE_OUT_OF_MEMORY;
+ }
+ else {
+ unsigned long port = strtoul(data->state.up.port, NULL, 10);
+ conn->remote_port = curlx_ultous(port);
}
- result = findprotocol(data, conn, protop);
- if(result)
- return result;
+ (void)curl_url_get(uh, CURLUPART_QUERY, &data->state.up.query, 0);
- /*
- * Parse the login details from the URL and strip them out of
- * the host name
- */
- result = parse_url_login(data, conn, userp, passwdp, optionsp);
- if(result)
- return result;
+ hostname = data->state.up.hostname;
+ if(!hostname)
+ /* this is for file:// transfers, get a dummy made */
+ hostname = (char *)"";
- if(conn->host.name[0] == '[') {
- /* This looks like an IPv6 address literal. See if there is an address
- scope if there is no location header */
- char *percent = strchr(conn->host.name, '%');
- if(percent) {
- unsigned int identifier_offset = 3;
+ if(hostname[0] == '[') {
+ /* This looks like an IPv6 address literal. See if there is an address
+ scope. */
+ char *zoneid;
+ size_t hlen;
+ uc = curl_url_get(uh, CURLUPART_ZONEID, &zoneid, 0);
+ conn->bits.ipv6_ip = TRUE;
+
+ /* cut off the brackets! */
+ hostname++;
+ hlen = strlen(hostname);
+ hostname[hlen - 1] = 0;
+ if(!uc && zoneid) {
char *endp;
unsigned long scope;
- if(strncmp("%25", percent, 3) != 0) {
- infof(data,
- "Please URL encode %% as %%25, see RFC 6874.\n");
- identifier_offset = 1;
- }
- scope = strtoul(percent + identifier_offset, &endp, 10);
- if(*endp == ']') {
- /* The address scope was well formed. Knock it out of the
- hostname. */
- memmove(percent, endp, strlen(endp)+1);
+ scope = strtoul(zoneid, &endp, 10);
+ if(!*endp && (scope < UINT_MAX)) {
+ /* A plain number, use it direcly as a scope id. */
conn->scope_id = (unsigned int)scope;
}
+#ifdef HAVE_IF_NAMETOINDEX
else {
/* Zone identifier is not numeric */
-#if defined(HAVE_NET_IF_H) && defined(IFNAMSIZ) && defined(HAVE_IF_NAMETOINDEX)
- char ifname[IFNAMSIZ + 2];
- char *square_bracket;
unsigned int scopeidx = 0;
- strncpy(ifname, percent + identifier_offset, IFNAMSIZ + 2);
- /* Ensure nullbyte termination */
- ifname[IFNAMSIZ + 1] = '\0';
- square_bracket = strchr(ifname, ']');
- if(square_bracket) {
- /* Remove ']' */
- *square_bracket = '\0';
- scopeidx = if_nametoindex(ifname);
- if(scopeidx == 0) {
- infof(data, "Invalid network interface: %s; %s\n", ifname,
- strerror(errno));
- }
- }
- if(scopeidx > 0) {
- char *p = percent + identifier_offset + strlen(ifname);
-
- /* Remove zone identifier from hostname */
- memmove(percent, p, strlen(p) + 1);
- conn->scope_id = scopeidx;
- }
+ scopeidx = if_nametoindex(zoneid);
+ if(!scopeidx)
+ infof(data, "Invalid zoneid id: %s; %s\n", zoneid,
+ strerror(errno));
else
-#endif /* HAVE_NET_IF_H && IFNAMSIZ */
- infof(data, "Invalid IPv6 address format\n");
+ conn->scope_id = scopeidx;
+
}
+#endif /* HAVE_IF_NAMETOINDEX */
+ free(zoneid);
}
}
+ /* make sure the connect struct gets its own copy of the host name */
+ conn->host.rawalloc = strdup(hostname);
+ if(!conn->host.rawalloc)
+ return CURLE_OUT_OF_MEMORY;
+ conn->host.name = conn->host.rawalloc;
+
if(data->set.scope_id)
/* Override any scope that was set above. */
conn->scope_id = data->set.scope_id;
- /* Remove the fragment part of the path. Per RFC 2396, this is always the
- last part of the URI. We are looking for the first '#' so that we deal
- gracefully with non conformant URI such as http://example.com#foo#bar. */
- fragment = strchr(path, '#');
- if(fragment) {
- *fragment = 0;
-
- /* we know the path part ended with a fragment, so we know the full URL
- string does too and we need to cut it off from there so it isn't used
- over proxy */
- fragment = strchr(data->change.url, '#');
- if(fragment)
- *fragment = 0;
- }
-
- /*
- * So if the URL was A://B/C#D,
- * protop is A
- * conn->host.name is B
- * data->state.path is /C
- */
return CURLE_OK;
}
+
/*
* If we're doing a resumed transfer, we need to setup our stuff
* properly.
@@ -4781,7 +2065,7 @@ static CURLcode setup_range(struct Curl_easy *data)
free(s->range);
if(s->resume_from)
- s->range = aprintf("%" CURL_FORMAT_CURL_OFF_TU "-", s->resume_from);
+ s->range = aprintf("%" CURL_FORMAT_CURL_OFF_T "-", s->resume_from);
else
s->range = strdup(data->set.str[STRING_SET_RANGE]);
@@ -4813,18 +2097,6 @@ static CURLcode setup_connection_internals(struct connectdata *conn)
{
const struct Curl_handler * p;
CURLcode result;
- struct Curl_easy *data = conn->data;
-
- /* in some case in the multi state-machine, we go back to the CONNECT state
- and then a second (or third or...) call to this function will be made
- without doing a DISCONNECT or DONE in between (since the connection is
- yet in place) and therefore this function needs to first make sure
- there's no lingering previous data allocated. */
- Curl_free_request_state(data);
-
- memset(&data->req, 0, sizeof(struct SingleRequest));
- data->req.maxdownload = -1;
-
conn->socktype = SOCK_STREAM; /* most of them are TCP streams */
/* Perform setup complement if some. */
@@ -4871,14 +2143,13 @@ static bool check_noproxy(const char *name, const char *no_proxy)
* not be proxied, or an asterisk to override
* all proxy variables)
*/
- size_t tok_start;
- size_t tok_end;
- const char *separator = ", ";
- size_t no_proxy_len;
- size_t namelen;
- char *endptr;
-
if(no_proxy && no_proxy[0]) {
+ size_t tok_start;
+ size_t tok_end;
+ const char *separator = ", ";
+ size_t no_proxy_len;
+ size_t namelen;
+ char *endptr;
if(strcasecompare("*", no_proxy)) {
return TRUE;
}
@@ -4886,9 +2157,14 @@ static bool check_noproxy(const char *name, const char *no_proxy)
/* NO_PROXY was specified and it wasn't just an asterisk */
no_proxy_len = strlen(no_proxy);
- endptr = strchr(name, ':');
- if(endptr)
+ if(name[0] == '[') {
+ /* IPv6 numerical address */
+ endptr = strchr(name, ']');
+ if(!endptr)
+ return FALSE;
+ name++;
namelen = endptr - name;
+ }
else
namelen = strlen(name);
@@ -4974,7 +2250,7 @@ static char *detect_proxy(struct connectdata *conn)
strcpy(envp, "_proxy");
/* read the protocol proxy: */
- prox=curl_getenv(proxy_env);
+ prox = curl_getenv(proxy_env);
/*
* We don't try the uppercase version of HTTP_PROXY because of
@@ -4991,16 +2267,23 @@ static char *detect_proxy(struct connectdata *conn)
if(!prox && !strcasecompare("http_proxy", proxy_env)) {
/* There was no lowercase variable, try the uppercase version: */
Curl_strntoupper(proxy_env, proxy_env, sizeof(proxy_env));
- prox=curl_getenv(proxy_env);
+ prox = curl_getenv(proxy_env);
}
- if(prox)
+ envp = proxy_env;
+ if(prox) {
proxy = prox; /* use this */
+ }
else {
- proxy = curl_getenv("all_proxy"); /* default proxy to use */
- if(!proxy)
- proxy=curl_getenv("ALL_PROXY");
+ envp = (char *)"all_proxy";
+ proxy = curl_getenv(envp); /* default proxy to use */
+ if(!proxy) {
+ envp = (char *)"ALL_PROXY";
+ proxy = curl_getenv(envp);
+ }
}
+ if(proxy)
+ infof(conn->data, "Uses proxy env variable %s == '%s'\n", envp, proxy);
return proxy;
}
@@ -5015,136 +2298,100 @@ static CURLcode parse_proxy(struct Curl_easy *data,
struct connectdata *conn, char *proxy,
curl_proxytype proxytype)
{
- char *prox_portno;
- char *endofprot;
-
- /* We use 'proxyptr' to point to the proxy name from now on... */
- char *proxyptr;
char *portptr;
- char *atsign;
long port = -1;
char *proxyuser = NULL;
char *proxypasswd = NULL;
+ char *host;
bool sockstype;
+ CURLUcode uc;
+ struct proxy_info *proxyinfo;
+ CURLU *uhp = curl_url();
+ CURLcode result = CURLE_OK;
+ char *scheme = NULL;
+
+ /* When parsing the proxy, allowing non-supported schemes since we have
+ these made up ones for proxies. Guess scheme for URLs without it. */
+ uc = curl_url_set(uhp, CURLUPART_URL, proxy,
+ CURLU_NON_SUPPORT_SCHEME|CURLU_GUESS_SCHEME);
+ if(!uc) {
+ /* parsed okay as a URL */
+ uc = curl_url_get(uhp, CURLUPART_SCHEME, &scheme, 0);
+ if(uc) {
+ result = CURLE_OUT_OF_MEMORY;
+ goto error;
+ }
- /* We do the proxy host string parsing here. We want the host name and the
- * port name. Accept a protocol:// prefix
- */
-
- /* Parse the protocol part if present */
- endofprot = strstr(proxy, "://");
- if(endofprot) {
- proxyptr = endofprot+3;
- if(checkprefix("https", proxy))
+ if(strcasecompare("https", scheme))
proxytype = CURLPROXY_HTTPS;
- else if(checkprefix("socks5h", proxy))
+ else if(strcasecompare("socks5h", scheme))
proxytype = CURLPROXY_SOCKS5_HOSTNAME;
- else if(checkprefix("socks5", proxy))
+ else if(strcasecompare("socks5", scheme))
proxytype = CURLPROXY_SOCKS5;
- else if(checkprefix("socks4a", proxy))
+ else if(strcasecompare("socks4a", scheme))
proxytype = CURLPROXY_SOCKS4A;
- else if(checkprefix("socks4", proxy) || checkprefix("socks", proxy))
+ else if(strcasecompare("socks4", scheme) ||
+ strcasecompare("socks", scheme))
proxytype = CURLPROXY_SOCKS4;
- else if(checkprefix("http:", proxy))
+ else if(strcasecompare("http", scheme))
; /* leave it as HTTP or HTTP/1.0 */
else {
/* Any other xxx:// reject! */
failf(data, "Unsupported proxy scheme for \'%s\'", proxy);
- return CURLE_COULDNT_CONNECT;
+ result = CURLE_COULDNT_CONNECT;
+ goto error;
}
}
- else
- proxyptr = proxy; /* No xxx:// head: It's a HTTP proxy */
-
-#ifndef HTTPS_PROXY_SUPPORT
- if(proxytype == CURLPROXY_HTTPS) {
- failf(data, "Unsupported proxy \'%s\'"
- ", libcurl is built without the HTTPS-proxy support.", proxy);
- return CURLE_NOT_BUILT_IN;
+ else {
+ failf(data, "Unsupported proxy syntax in \'%s\'", proxy);
+ result = CURLE_COULDNT_RESOLVE_PROXY;
+ goto error;
}
-#endif
- sockstype = proxytype == CURLPROXY_SOCKS5_HOSTNAME ||
- proxytype == CURLPROXY_SOCKS5 ||
- proxytype == CURLPROXY_SOCKS4A ||
- proxytype == CURLPROXY_SOCKS4;
+#ifdef USE_SSL
+ if(!(Curl_ssl->supports & SSLSUPP_HTTPS_PROXY))
+#endif
+ if(proxytype == CURLPROXY_HTTPS) {
+ failf(data, "Unsupported proxy \'%s\', libcurl is built without the "
+ "HTTPS-proxy support.", proxy);
+ result = CURLE_NOT_BUILT_IN;
+ goto error;
+ }
- /* Is there a username and password given in this proxy url? */
- atsign = strchr(proxyptr, '@');
- if(atsign) {
- CURLcode result =
- parse_login_details(proxyptr, atsign - proxyptr,
- &proxyuser, &proxypasswd, NULL);
- if(result)
- return result;
- proxyptr = atsign + 1;
- }
+ sockstype =
+ proxytype == CURLPROXY_SOCKS5_HOSTNAME ||
+ proxytype == CURLPROXY_SOCKS5 ||
+ proxytype == CURLPROXY_SOCKS4A ||
+ proxytype == CURLPROXY_SOCKS4;
- /* start scanning for port number at this point */
- portptr = proxyptr;
+ proxyinfo = sockstype ? &conn->socks_proxy : &conn->http_proxy;
+ proxyinfo->proxytype = proxytype;
- /* detect and extract RFC6874-style IPv6-addresses */
- if(*proxyptr == '[') {
- char *ptr = ++proxyptr; /* advance beyond the initial bracket */
- while(*ptr && (ISXDIGIT(*ptr) || (*ptr == ':') || (*ptr == '.')))
- ptr++;
- if(*ptr == '%') {
- /* There might be a zone identifier */
- if(strncmp("%25", ptr, 3))
- infof(data, "Please URL encode %% as %%25, see RFC 6874.\n");
- ptr++;
- /* Allow unreserved characters as defined in RFC 3986 */
- while(*ptr && (ISALPHA(*ptr) || ISXDIGIT(*ptr) || (*ptr == '-') ||
- (*ptr == '.') || (*ptr == '_') || (*ptr == '~')))
- ptr++;
+ /* Is there a username and password given in this proxy url? */
+ curl_url_get(uhp, CURLUPART_USER, &proxyuser, CURLU_URLDECODE);
+ curl_url_get(uhp, CURLUPART_PASSWORD, &proxypasswd, CURLU_URLDECODE);
+ if(proxyuser || proxypasswd) {
+ Curl_safefree(proxyinfo->user);
+ proxyinfo->user = proxyuser;
+ Curl_safefree(proxyinfo->passwd);
+ if(!proxypasswd) {
+ proxypasswd = strdup("");
+ if(!proxypasswd) {
+ result = CURLE_OUT_OF_MEMORY;
+ goto error;
+ }
}
- if(*ptr == ']')
- /* yeps, it ended nicely with a bracket as well */
- *ptr++ = 0;
- else
- infof(data, "Invalid IPv6 address format\n");
- portptr = ptr;
- /* Note that if this didn't end with a bracket, we still advanced the
- * proxyptr first, but I can't see anything wrong with that as no host
- * name nor a numeric can legally start with a bracket.
- */
+ proxyinfo->passwd = proxypasswd;
+ conn->bits.proxy_user_passwd = TRUE; /* enable it */
}
- /* Get port number off proxy.server.com:1080 */
- prox_portno = strchr(portptr, ':');
- if(prox_portno) {
- char *endp = NULL;
+ curl_url_get(uhp, CURLUPART_PORT, &portptr, 0);
- *prox_portno = 0x0; /* cut off number from host name */
- prox_portno ++;
- /* now set the local port number */
- port = strtol(prox_portno, &endp, 10);
- if((endp && *endp && (*endp != '/') && (*endp != ' ')) ||
- (port < 0) || (port > 65535)) {
- /* meant to detect for example invalid IPv6 numerical addresses without
- brackets: "2a00:fac0:a000::7:13". Accept a trailing slash only
- because we then allow "URL style" with the number followed by a
- slash, used in curl test cases already. Space is also an acceptable
- terminating symbol. */
- infof(data, "No valid port number in proxy string (%s)\n",
- prox_portno);
- }
- else
- conn->port = port;
+ if(portptr) {
+ port = strtol(portptr, NULL, 10);
+ free(portptr);
}
else {
- if(proxyptr[0]=='/')
- /* If the first character in the proxy string is a slash, fail
- immediately. The following code will otherwise clear the string which
- will lead to code running as if no proxy was set! */
- return CURLE_COULDNT_RESOLVE_PROXY;
-
- /* without a port number after the host name, some people seem to use
- a slash so we strip everything from the first slash */
- atsign = strchr(proxyptr, '/');
- if(atsign)
- *atsign = '\0'; /* cut off path part from host name */
-
if(data->set.proxyport)
/* None given in the proxy string, then get the default one if it is
given */
@@ -5156,57 +2403,32 @@ static CURLcode parse_proxy(struct Curl_easy *data,
port = CURL_DEFAULT_PROXY_PORT;
}
}
-
- if(*proxyptr) {
- struct proxy_info *proxyinfo =
- sockstype ? &conn->socks_proxy : &conn->http_proxy;
- proxyinfo->proxytype = proxytype;
-
- if(proxyuser) {
- /* found user and password, rip them out. note that we are unescaping
- them, as there is otherwise no way to have a username or password
- with reserved characters like ':' in them. */
- Curl_safefree(proxyinfo->user);
- proxyinfo->user = curl_easy_unescape(data, proxyuser, 0, NULL);
- Curl_safefree(proxyuser);
-
- if(!proxyinfo->user) {
- Curl_safefree(proxypasswd);
- return CURLE_OUT_OF_MEMORY;
- }
-
- Curl_safefree(proxyinfo->passwd);
- if(proxypasswd && strlen(proxypasswd) < MAX_CURL_PASSWORD_LENGTH)
- proxyinfo->passwd = curl_easy_unescape(data, proxypasswd, 0, NULL);
- else
- proxyinfo->passwd = strdup("");
- Curl_safefree(proxypasswd);
-
- if(!proxyinfo->passwd)
- return CURLE_OUT_OF_MEMORY;
-
- conn->bits.proxy_user_passwd = TRUE; /* enable it */
- }
-
- if(port >= 0) {
- proxyinfo->port = port;
- if(conn->port < 0 || sockstype || !conn->socks_proxy.host.rawalloc)
- conn->port = port;
- }
-
- /* now, clone the cleaned proxy host name */
- Curl_safefree(proxyinfo->host.rawalloc);
- proxyinfo->host.rawalloc = strdup(proxyptr);
- proxyinfo->host.name = proxyinfo->host.rawalloc;
-
- if(!proxyinfo->host.rawalloc)
- return CURLE_OUT_OF_MEMORY;
+ if(port >= 0) {
+ proxyinfo->port = port;
+ if(conn->port < 0 || sockstype || !conn->socks_proxy.host.rawalloc)
+ conn->port = port;
}
- Curl_safefree(proxyuser);
- Curl_safefree(proxypasswd);
+ /* now, clone the proxy host name */
+ uc = curl_url_get(uhp, CURLUPART_HOST, &host, CURLU_URLDECODE);
+ if(uc) {
+ result = CURLE_OUT_OF_MEMORY;
+ goto error;
+ }
+ Curl_safefree(proxyinfo->host.rawalloc);
+ proxyinfo->host.rawalloc = host;
+ if(host[0] == '[') {
+ /* this is a numerical IPv6, strip off the brackets */
+ size_t len = strlen(host);
+ host[len-1] = 0; /* clear the trailing bracket */
+ host++;
+ }
+ proxyinfo->host.name = host;
- return CURLE_OK;
+ error:
+ free(scheme);
+ curl_url_cleanup(uhp);
+ return result;
}
/*
@@ -5280,22 +2502,27 @@ static CURLcode create_conn_helper_init_proxy(struct connectdata *conn)
}
}
- no_proxy = curl_getenv("no_proxy");
- if(!no_proxy)
- no_proxy = curl_getenv("NO_PROXY");
+ if(!data->set.str[STRING_NOPROXY]) {
+ const char *p = "no_proxy";
+ no_proxy = curl_getenv(p);
+ if(!no_proxy) {
+ p = "NO_PROXY";
+ no_proxy = curl_getenv(p);
+ }
+ if(no_proxy) {
+ infof(conn->data, "Uses proxy env variable %s == '%s'\n", p, no_proxy);
+ }
+ }
- if(check_noproxy(conn->host.name, data->set.str[STRING_NOPROXY]) ||
- (!data->set.str[STRING_NOPROXY] &&
- check_noproxy(conn->host.name, no_proxy))) {
+ if(check_noproxy(conn->host.name, data->set.str[STRING_NOPROXY] ?
+ data->set.str[STRING_NOPROXY] : no_proxy)) {
Curl_safefree(proxy);
Curl_safefree(socksproxy);
}
- else if(!proxy && !socksproxy)
#ifndef CURL_DISABLE_HTTP
+ else if(!proxy && !socksproxy)
/* if the host is not in the noproxy list, detect proxy. */
proxy = detect_proxy(conn);
-#else /* !CURL_DISABLE_HTTP */
- proxy = NULL;
#endif /* CURL_DISABLE_HTTP */
Curl_safefree(no_proxy);
@@ -5348,12 +2575,15 @@ static CURLcode create_conn_helper_init_proxy(struct connectdata *conn)
result = CURLE_UNSUPPORTED_PROTOCOL;
goto out;
#else
- /* force this connection's protocol to become HTTP if not already
- compatible - if it isn't tunneling through */
- if(!(conn->handler->protocol & PROTO_FAMILY_HTTP) &&
- !conn->bits.tunnel_proxy)
- conn->handler = &Curl_handler_http;
-
+ /* force this connection's protocol to become HTTP if compatible */
+ if(!(conn->handler->protocol & PROTO_FAMILY_HTTP)) {
+ if((conn->handler->flags & PROTOPT_PROXY_AS_HTTP) &&
+ !conn->bits.tunnel_proxy)
+ conn->handler = &Curl_handler_http;
+ else
+ /* if not converting to HTTP over the proxy, enforce tunneling */
+ conn->bits.tunnel_proxy = TRUE;
+ }
conn->bits.httpproxy = TRUE;
#endif
}
@@ -5402,124 +2632,7 @@ out:
#endif /* CURL_DISABLE_PROXY */
/*
- * parse_url_login()
- *
- * Parse the login details (user name, password and options) from the URL and
- * strip them out of the host name
- *
- * Inputs: data->set.use_netrc (CURLOPT_NETRC)
- * conn->host.name
- *
- * Outputs: (almost :- all currently undefined)
- * conn->bits.user_passwd - non-zero if non-default passwords exist
- * user - non-zero length if defined
- * passwd - non-zero length if defined
- * options - non-zero length if defined
- * conn->host.name - remove user name and password
- */
-static CURLcode parse_url_login(struct Curl_easy *data,
- struct connectdata *conn,
- char **user, char **passwd, char **options)
-{
- CURLcode result = CURLE_OK;
- char *userp = NULL;
- char *passwdp = NULL;
- char *optionsp = NULL;
-
- /* At this point, we're hoping all the other special cases have
- * been taken care of, so conn->host.name is at most
- * [user[:password][;options]]@]hostname
- *
- * We need somewhere to put the embedded details, so do that first.
- */
-
- char *ptr = strchr(conn->host.name, '@');
- char *login = conn->host.name;
-
- DEBUGASSERT(!**user);
- DEBUGASSERT(!**passwd);
- DEBUGASSERT(!**options);
- DEBUGASSERT(conn->handler);
-
- if(!ptr)
- goto out;
-
- /* We will now try to extract the
- * possible login information in a string like:
- * ftp://user:password@ftp.my.site:8021/README */
- conn->host.name = ++ptr;
-
- /* So the hostname is sane. Only bother interpreting the
- * results if we could care. It could still be wasted
- * work because it might be overtaken by the programmatically
- * set user/passwd, but doing that first adds more cases here :-(
- */
-
- if(data->set.use_netrc == CURL_NETRC_REQUIRED)
- goto out;
-
- /* We could use the login information in the URL so extract it. Only parse
- options if the handler says we should. */
- result = parse_login_details(login, ptr - login - 1,
- &userp, &passwdp,
- (conn->handler->flags & PROTOPT_URLOPTIONS)?
- &optionsp:NULL);
- if(result)
- goto out;
-
- if(userp) {
- char *newname;
-
- /* We have a user in the URL */
- conn->bits.userpwd_in_url = TRUE;
- conn->bits.user_passwd = TRUE; /* enable user+password */
-
- /* Decode the user */
- result = Curl_urldecode(data, userp, 0, &newname, NULL, FALSE);
- if(result) {
- goto out;
- }
-
- free(*user);
- *user = newname;
- }
-
- if(passwdp) {
- /* We have a password in the URL so decode it */
- char *newpasswd;
- result = Curl_urldecode(data, passwdp, 0, &newpasswd, NULL, FALSE);
- if(result) {
- goto out;
- }
-
- free(*passwd);
- *passwd = newpasswd;
- }
-
- if(optionsp) {
- /* We have an options list in the URL so decode it */
- char *newoptions;
- result = Curl_urldecode(data, optionsp, 0, &newoptions, NULL, FALSE);
- if(result) {
- goto out;
- }
-
- free(*options);
- *options = newoptions;
- }
-
-
- out:
-
- free(userp);
- free(passwdp);
- free(optionsp);
-
- return result;
-}
-
-/*
- * parse_login_details()
+ * Curl_parse_login_details()
*
* This is used to parse a login string for user name, password and options in
* the following formats:
@@ -5540,16 +2653,16 @@ static CURLcode parse_url_login(struct Curl_easy *data,
* len [in] - The length of the login string.
* userp [in/out] - The address where a pointer to newly allocated memory
* holding the user will be stored upon completion.
- * passdwp [in/out] - The address where a pointer to newly allocated memory
+ * passwdp [in/out] - The address where a pointer to newly allocated memory
* holding the password will be stored upon completion.
* optionsp [in/out] - The address where a pointer to newly allocated memory
* holding the options will be stored upon completion.
*
* Returns CURLE_OK on success.
*/
-static CURLcode parse_login_details(const char *login, const size_t len,
- char **userp, char **passwdp,
- char **optionsp)
+CURLcode Curl_parse_login_details(const char *login, const size_t len,
+ char **userp, char **passwdp,
+ char **optionsp)
{
CURLcode result = CURLE_OK;
char *ubuf = NULL;
@@ -5651,125 +2764,23 @@ static CURLcode parse_login_details(const char *login, const size_t len,
* No matter if we use a proxy or not, we have to figure out the remote
* port number of various reasons.
*
- * To be able to detect port number flawlessly, we must not confuse them
- * IPv6-specified addresses in the [0::1] style. (RFC2732)
- *
- * The conn->host.name is currently [user:passwd@]host[:port] where host
- * could be a hostname, IPv4 address or IPv6 address.
- *
* The port number embedded in the URL is replaced, if necessary.
*************************************************************/
static CURLcode parse_remote_port(struct Curl_easy *data,
struct connectdata *conn)
{
- char *portptr;
- char endbracket;
-
- /* Note that at this point, the IPv6 address cannot contain any scope
- suffix as that has already been removed in the parseurlandfillconn()
- function */
- if((1 == sscanf(conn->host.name, "[%*45[0123456789abcdefABCDEF:.]%c",
- &endbracket)) &&
- (']' == endbracket)) {
- /* this is a RFC2732-style specified IP-address */
- conn->bits.ipv6_ip = TRUE;
-
- conn->host.name++; /* skip over the starting bracket */
- portptr = strchr(conn->host.name, ']');
- if(portptr) {
- *portptr++ = '\0'; /* zero terminate, killing the bracket */
- if(':' != *portptr)
- portptr = NULL; /* no port number available */
- }
- }
- else {
-#ifdef ENABLE_IPV6
- struct in6_addr in6;
- if(Curl_inet_pton(AF_INET6, conn->host.name, &in6) > 0) {
- /* This is a numerical IPv6 address, meaning this is a wrongly formatted
- URL */
- failf(data, "IPv6 numerical address used in URL without brackets");
- return CURLE_URL_MALFORMAT;
- }
-#endif
-
- portptr = strchr(conn->host.name, ':');
- }
if(data->set.use_port && data->state.allow_port) {
- /* if set, we use this and ignore the port possibly given in the URL */
+ /* if set, we use this instead of the port possibly given in the URL */
+ char portbuf[16];
+ CURLUcode uc;
conn->remote_port = (unsigned short)data->set.use_port;
- if(portptr)
- *portptr = '\0'; /* cut off the name there anyway - if there was a port
- number - since the port number is to be ignored! */
- if(conn->bits.httpproxy) {
- /* we need to create new URL with the new port number */
- char *url;
- char type[12]="";
-
- if(conn->bits.type_set)
- snprintf(type, sizeof(type), ";type=%c",
- data->set.prefer_ascii?'A':
- (data->set.ftp_list_only?'D':'I'));
-
- /*
- * This synthesized URL isn't always right--suffixes like ;type=A are
- * stripped off. It would be better to work directly from the original
- * URL and simply replace the port part of it.
- */
- url = aprintf("%s://%s%s%s:%hu%s%s%s", conn->given->scheme,
- conn->bits.ipv6_ip?"[":"", conn->host.name,
- conn->bits.ipv6_ip?"]":"", conn->remote_port,
- data->state.slash_removed?"/":"", data->state.path,
- type);
- if(!url)
- return CURLE_OUT_OF_MEMORY;
-
- if(data->change.url_alloc) {
- Curl_safefree(data->change.url);
- data->change.url_alloc = FALSE;
- }
-
- data->change.url = url;
- data->change.url_alloc = TRUE;
- }
- }
- else if(portptr) {
- /* no CURLOPT_PORT given, extract the one from the URL */
-
- char *rest;
- long port;
-
- port=strtol(portptr+1, &rest, 10); /* Port number must be decimal */
-
- if((port < 0) || (port > 0xffff)) {
- /* Single unix standard says port numbers are 16 bits long */
- failf(data, "Port number out of range");
- return CURLE_URL_MALFORMAT;
- }
-
- if(rest[0]) {
- failf(data, "Port number ended with '%c'", rest[0]);
- return CURLE_URL_MALFORMAT;
- }
-
- if(rest != &portptr[1]) {
- *portptr = '\0'; /* cut off the name there */
- conn->remote_port = curlx_ultous(port);
- }
- else {
- /* Browser behavior adaptation. If there's a colon with no digits after,
- just cut off the name there which makes us ignore the colon and just
- use the default port. Firefox and Chrome both do that. */
- *portptr = '\0';
- }
+ msnprintf(portbuf, sizeof(portbuf), "%d", conn->remote_port);
+ uc = curl_url_set(data->state.uh, CURLUPART_PORT, portbuf, 0);
+ if(uc)
+ return CURLE_OUT_OF_MEMORY;
}
- /* only if remote_port was not already parsed off the URL we use the
- default port number */
- if(conn->remote_port < 0)
- conn->remote_port = (unsigned short)conn->given->defport;
-
return CURLE_OK;
}
@@ -5781,11 +2792,30 @@ static CURLcode override_login(struct Curl_easy *data,
struct connectdata *conn,
char **userp, char **passwdp, char **optionsp)
{
+ bool user_changed = FALSE;
+ bool passwd_changed = FALSE;
+ CURLUcode uc;
+
+ if(data->set.use_netrc == CURL_NETRC_REQUIRED && conn->bits.user_passwd) {
+ /* ignore user+password in the URL */
+ if(*userp) {
+ Curl_safefree(*userp);
+ user_changed = TRUE;
+ }
+ if(*passwdp) {
+ Curl_safefree(*passwdp);
+ passwd_changed = TRUE;
+ }
+ conn->bits.user_passwd = FALSE; /* disable user+password */
+ }
+
if(data->set.str[STRING_USERNAME]) {
free(*userp);
*userp = strdup(data->set.str[STRING_USERNAME]);
if(!*userp)
return CURLE_OUT_OF_MEMORY;
+ conn->bits.user_passwd = TRUE; /* enable user+password */
+ user_changed = TRUE;
}
if(data->set.str[STRING_PASSWORD]) {
@@ -5793,6 +2823,8 @@ static CURLcode override_login(struct Curl_easy *data,
*passwdp = strdup(data->set.str[STRING_PASSWORD]);
if(!*passwdp)
return CURLE_OUT_OF_MEMORY;
+ conn->bits.user_passwd = TRUE; /* enable user+password */
+ passwd_changed = TRUE;
}
if(data->set.str[STRING_OPTIONS]) {
@@ -5803,10 +2835,16 @@ static CURLcode override_login(struct Curl_easy *data,
}
conn->bits.netrc = FALSE;
- if(data->set.use_netrc != CURL_NETRC_IGNORED) {
- int ret = Curl_parsenetrc(conn->host.name,
- userp, passwdp,
- data->set.str[STRING_NETRC_FILE]);
+ if(data->set.use_netrc != CURL_NETRC_IGNORED &&
+ (!*userp || !**userp || !*passwdp || !**passwdp)) {
+ bool netrc_user_changed = FALSE;
+ bool netrc_passwd_changed = FALSE;
+ int ret;
+
+ ret = Curl_parsenetrc(conn->host.name,
+ userp, passwdp,
+ &netrc_user_changed, &netrc_passwd_changed,
+ data->set.str[STRING_NETRC_FILE]);
if(ret > 0) {
infof(data, "Couldn't find host %s in the "
DOT_CHAR "netrc file; using defaults\n",
@@ -5820,55 +2858,65 @@ static CURLcode override_login(struct Curl_easy *data,
file, so that it is safe to use even if we followed a Location: to a
different host or similar. */
conn->bits.netrc = TRUE;
-
conn->bits.user_passwd = TRUE; /* enable user+password */
+
+ if(netrc_user_changed) {
+ user_changed = TRUE;
+ }
+ if(netrc_passwd_changed) {
+ passwd_changed = TRUE;
+ }
}
}
+ /* for updated strings, we update them in the URL */
+ if(user_changed) {
+ uc = curl_url_set(data->state.uh, CURLUPART_USER, *userp, 0);
+ if(uc)
+ return Curl_uc_to_curlcode(uc);
+ }
+ if(passwd_changed) {
+ uc = curl_url_set(data->state.uh, CURLUPART_PASSWORD, *passwdp, 0);
+ if(uc)
+ return Curl_uc_to_curlcode(uc);
+ }
return CURLE_OK;
}
/*
* Set the login details so they're available in the connection
*/
-static CURLcode set_login(struct connectdata *conn,
- const char *user, const char *passwd,
- const char *options)
+static CURLcode set_login(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
+ const char *setuser = CURL_DEFAULT_USER;
+ const char *setpasswd = CURL_DEFAULT_PASSWORD;
/* If our protocol needs a password and we have none, use the defaults */
- if((conn->handler->flags & PROTOPT_NEEDSPWD) && !conn->bits.user_passwd) {
- /* Store the default user */
- conn->user = strdup(CURL_DEFAULT_USER);
-
- /* Store the default password */
- if(conn->user)
- conn->passwd = strdup(CURL_DEFAULT_PASSWORD);
- else
- conn->passwd = NULL;
-
- /* This is the default password, so DON'T set conn->bits.user_passwd */
- }
+ if((conn->handler->flags & PROTOPT_NEEDSPWD) && !conn->bits.user_passwd)
+ ;
else {
- /* Store the user, zero-length if not set */
- conn->user = strdup(user);
-
- /* Store the password (only if user is present), zero-length if not set */
- if(conn->user)
- conn->passwd = strdup(passwd);
- else
- conn->passwd = NULL;
+ setuser = "";
+ setpasswd = "";
+ }
+ /* Store the default user */
+ if(!conn->user) {
+ conn->user = strdup(setuser);
+ if(!conn->user)
+ return CURLE_OUT_OF_MEMORY;
}
- if(!conn->user || !conn->passwd)
- result = CURLE_OUT_OF_MEMORY;
-
- /* Store the options, null if not set */
- if(!result && options[0]) {
- conn->options = strdup(options);
+ /* Store the default password */
+ if(!conn->passwd) {
+ conn->passwd = strdup(setpasswd);
+ if(!conn->passwd)
+ result = CURLE_OUT_OF_MEMORY;
+ }
- if(!conn->options)
+ /* if there's a user without password, consider password blank */
+ if(conn->user && !conn->passwd) {
+ conn->passwd = strdup("");
+ if(!conn->passwd)
result = CURLE_OUT_OF_MEMORY;
}
@@ -5912,6 +2960,7 @@ static CURLcode parse_connect_to_host_port(struct Curl_easy *data,
/* detect and extract RFC6874-style IPv6-addresses */
if(*hostptr == '[') {
+#ifdef ENABLE_IPV6
char *ptr = ++hostptr; /* advance beyond the initial bracket */
while(*ptr && (ISXDIGIT(*ptr) || (*ptr == ':') || (*ptr == '.')))
ptr++;
@@ -5935,6 +2984,11 @@ static CURLcode parse_connect_to_host_port(struct Curl_easy *data,
* hostptr first, but I can't see anything wrong with that as no host
* name nor a numeric can legally start with a bracket.
*/
+#else
+ failf(data, "Use of IPv6 in *_CONNECT_TO without IPv6 support built-in!");
+ free(host_dup);
+ return CURLE_NOT_BUILT_IN;
+#endif
}
/* Get port number off server.com:1080 */
@@ -6086,6 +3140,34 @@ static CURLcode parse_connect_to_slist(struct Curl_easy *data,
conn_to_host = conn_to_host->next;
}
+#ifdef USE_ALTSVC
+ if(data->asi && !host && (port == -1) &&
+ (conn->handler->protocol == CURLPROTO_HTTPS)) {
+ /* no connect_to match, try alt-svc! */
+ const char *nhost;
+ int nport;
+ enum alpnid nalpnid;
+ bool hit;
+ host = conn->host.rawalloc;
+ hit = Curl_altsvc_lookup(data->asi,
+ ALPN_h1, host, conn->remote_port, /* from */
+ &nalpnid, &nhost, &nport /* to */);
+ if(hit) {
+ char *hostd = strdup((char *)nhost);
+ if(!hostd)
+ return CURLE_OUT_OF_MEMORY;
+ conn->conn_to_host.rawalloc = hostd;
+ conn->conn_to_host.name = hostd;
+ conn->bits.conn_to_host = TRUE;
+ conn->conn_to_port = nport;
+ conn->bits.conn_to_port = TRUE;
+ infof(data, "Alt-svc connecting from [%s]%s:%d to [%s]%s:%d\n",
+ Curl_alpnid2str(ALPN_h1), host, conn->remote_port,
+ Curl_alpnid2str(nalpnid), hostd, nport);
+ }
+ }
+#endif
+
return result;
}
@@ -6096,15 +3178,17 @@ static CURLcode resolve_server(struct Curl_easy *data,
struct connectdata *conn,
bool *async)
{
- CURLcode result=CURLE_OK;
- time_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
+ CURLcode result = CURLE_OK;
+ timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
+ DEBUGASSERT(conn);
+ DEBUGASSERT(data);
/*************************************************************
* Resolve the name of the server or proxy
*************************************************************/
if(conn->bits.reuse)
/* We're reusing the connection - no need to resolve anything, and
- fix_hostname() was called already in create_conn() for the re-use
+ idnconvert_hostname() was called already in create_conn() for the re-use
case. */
*async = FALSE;
@@ -6159,7 +3243,10 @@ static CURLcode resolve_server(struct Curl_easy *data,
conn->port = conn->remote_port;
/* Resolve target host right on */
- rc = Curl_resolv_timeout(conn, connhost->name, (int)conn->port,
+ conn->hostname_resolve = strdup(connhost->name);
+ if(!conn->hostname_resolve)
+ return CURLE_OUT_OF_MEMORY;
+ rc = Curl_resolv_timeout(conn, conn->hostname_resolve, (int)conn->port,
&hostaddr, timeout_ms);
if(rc == CURLRESOLV_PENDING)
*async = TRUE;
@@ -6180,7 +3267,10 @@ static CURLcode resolve_server(struct Curl_easy *data,
&conn->socks_proxy.host : &conn->http_proxy.host;
/* resolve proxy */
- rc = Curl_resolv_timeout(conn, host->name, (int)conn->port,
+ conn->hostname_resolve = strdup(host->name);
+ if(!conn->hostname_resolve)
+ return CURLE_OUT_OF_MEMORY;
+ rc = Curl_resolv_timeout(conn, conn->hostname_resolve, (int)conn->port,
&hostaddr, timeout_ms);
if(rc == CURLRESOLV_PENDING)
@@ -6210,8 +3300,8 @@ static CURLcode resolve_server(struct Curl_easy *data,
static void reuse_conn(struct connectdata *old_conn,
struct connectdata *conn)
{
- free_fixed_hostname(&old_conn->http_proxy.host);
- free_fixed_hostname(&old_conn->socks_proxy.host);
+ free_idnconverted_hostname(&old_conn->http_proxy.host);
+ free_idnconverted_hostname(&old_conn->socks_proxy.host);
free(old_conn->http_proxy.host.rawalloc);
free(old_conn->socks_proxy.host.rawalloc);
@@ -6255,15 +3345,18 @@ static void reuse_conn(struct connectdata *old_conn,
/* host can change, when doing keepalive with a proxy or if the case is
different this time etc */
- free_fixed_hostname(&conn->host);
- free_fixed_hostname(&conn->conn_to_host);
+ free_idnconverted_hostname(&conn->host);
+ free_idnconverted_hostname(&conn->conn_to_host);
Curl_safefree(conn->host.rawalloc);
Curl_safefree(conn->conn_to_host.rawalloc);
- conn->host=old_conn->host;
- conn->bits.conn_to_host = old_conn->bits.conn_to_host;
+ conn->host = old_conn->host;
conn->conn_to_host = old_conn->conn_to_host;
- conn->bits.conn_to_port = old_conn->bits.conn_to_port;
conn->conn_to_port = old_conn->conn_to_port;
+ conn->remote_port = old_conn->remote_port;
+ Curl_safefree(conn->hostname_resolve);
+
+ conn->hostname_resolve = old_conn->hostname_resolve;
+ old_conn->hostname_resolve = NULL;
/* persist connection info in session handle */
Curl_persistconninfo(conn);
@@ -6275,16 +3368,13 @@ static void reuse_conn(struct connectdata *old_conn,
Curl_safefree(old_conn->user);
Curl_safefree(old_conn->passwd);
+ Curl_safefree(old_conn->options);
Curl_safefree(old_conn->http_proxy.user);
Curl_safefree(old_conn->socks_proxy.user);
Curl_safefree(old_conn->http_proxy.passwd);
Curl_safefree(old_conn->socks_proxy.passwd);
Curl_safefree(old_conn->localdev);
-
- Curl_llist_destroy(&old_conn->send_pipe, NULL);
- Curl_llist_destroy(&old_conn->recv_pipe, NULL);
-
- Curl_safefree(old_conn->master_buffer);
+ Curl_llist_destroy(&old_conn->easyq, NULL);
#ifdef USE_UNIX_SOCKETS
Curl_safefree(old_conn->unix_domain_socket);
@@ -6314,12 +3404,7 @@ static CURLcode create_conn(struct Curl_easy *data,
CURLcode result = CURLE_OK;
struct connectdata *conn;
struct connectdata *conn_temp = NULL;
- size_t urllen;
- char *user = NULL;
- char *passwd = NULL;
- char *options = NULL;
bool reuse;
- bool prot_missing = FALSE;
bool connections_available = TRUE;
bool force_reuse = FALSE;
bool waitpipe = FALSE;
@@ -6327,11 +3412,11 @@ static CURLcode create_conn(struct Curl_easy *data,
size_t max_total_connections = Curl_multi_max_total_connections(data->multi);
*async = FALSE;
+ *in_connect = NULL;
/*************************************************************
* Check input data
*************************************************************/
-
if(!data->change.url) {
result = CURLE_URL_MALFORMAT;
goto out;
@@ -6353,107 +3438,10 @@ static CURLcode create_conn(struct Curl_easy *data,
any failure */
*in_connect = conn;
- /* This initing continues below, see the comment "Continue connectdata
- * initialization here" */
-
- /***********************************************************
- * We need to allocate memory to store the path in. We get the size of the
- * full URL to be sure, and we need to make it at least 256 bytes since
- * other parts of the code will rely on this fact
- ***********************************************************/
-#define LEAST_PATH_ALLOC 256
- urllen=strlen(data->change.url);
- if(urllen < LEAST_PATH_ALLOC)
- urllen=LEAST_PATH_ALLOC;
-
- /*
- * We malloc() the buffers below urllen+2 to make room for 2 possibilities:
- * 1 - an extra terminating zero
- * 2 - an extra slash (in case a syntax like "www.host.com?moo" is used)
- */
-
- Curl_safefree(data->state.pathbuffer);
- data->state.path = NULL;
-
- data->state.pathbuffer = malloc(urllen+2);
- if(NULL == data->state.pathbuffer) {
- result = CURLE_OUT_OF_MEMORY; /* really bad error */
- goto out;
- }
- data->state.path = data->state.pathbuffer;
-
- conn->host.rawalloc = malloc(urllen+2);
- if(NULL == conn->host.rawalloc) {
- Curl_safefree(data->state.pathbuffer);
- data->state.path = NULL;
- result = CURLE_OUT_OF_MEMORY;
- goto out;
- }
-
- conn->host.name = conn->host.rawalloc;
- conn->host.name[0] = 0;
-
- user = strdup("");
- passwd = strdup("");
- options = strdup("");
- if(!user || !passwd || !options) {
- result = CURLE_OUT_OF_MEMORY;
- goto out;
- }
-
- result = parseurlandfillconn(data, conn, &prot_missing, &user, &passwd,
- &options);
+ result = parseurlandfillconn(data, conn);
if(result)
goto out;
- /*************************************************************
- * No protocol part in URL was used, add it!
- *************************************************************/
- if(prot_missing) {
- /* We're guessing prefixes here and if we're told to use a proxy or if
- we're gonna follow a Location: later or... then we need the protocol
- part added so that we have a valid URL. */
- char *reurl;
- char *ch_lower;
-
- reurl = aprintf("%s://%s", conn->handler->scheme, data->change.url);
-
- if(!reurl) {
- result = CURLE_OUT_OF_MEMORY;
- goto out;
- }
-
- /* Change protocol prefix to lower-case */
- for(ch_lower = reurl; *ch_lower != ':'; ch_lower++)
- *ch_lower = (char)TOLOWER(*ch_lower);
-
- if(data->change.url_alloc) {
- Curl_safefree(data->change.url);
- data->change.url_alloc = FALSE;
- }
-
- data->change.url = reurl;
- data->change.url_alloc = TRUE; /* free this later */
- }
-
- /*************************************************************
- * If the protocol can't handle url query strings, then cut
- * off the unhandable part
- *************************************************************/
- if((conn->given->flags&PROTOPT_NOURLQUERY)) {
- char *path_q_sep = strchr(conn->data->state.path, '?');
- if(path_q_sep) {
- /* according to rfc3986, allow the query (?foo=bar)
- also on protocols that can't handle it.
-
- cut the string-part after '?'
- */
-
- /* terminate the string */
- path_q_sep[0] = 0;
- }
- }
-
if(data->set.str[STRING_BEARER]) {
conn->oauth_bearer = strdup(data->set.str[STRING_BEARER]);
if(!conn->oauth_bearer) {
@@ -6497,10 +3485,12 @@ static CURLcode create_conn(struct Curl_easy *data,
/* Check for overridden login details and set them accordingly so they
they are known when protocol->setup_connection is called! */
- result = override_login(data, conn, &user, &passwd, &options);
+ result = override_login(data, conn, &conn->user, &conn->passwd,
+ &conn->options);
if(result)
goto out;
- result = set_login(conn, user, passwd, options);
+
+ result = set_login(conn); /* default credentials */
if(result)
goto out;
@@ -6513,19 +3503,30 @@ static CURLcode create_conn(struct Curl_easy *data,
goto out;
/*************************************************************
- * IDN-fix the hostnames
+ * IDN-convert the hostnames
*************************************************************/
- fix_hostname(conn, &conn->host);
- if(conn->bits.conn_to_host)
- fix_hostname(conn, &conn->conn_to_host);
- if(conn->bits.httpproxy)
- fix_hostname(conn, &conn->http_proxy.host);
- if(conn->bits.socksproxy)
- fix_hostname(conn, &conn->socks_proxy.host);
+ result = idnconvert_hostname(conn, &conn->host);
+ if(result)
+ goto out;
+ if(conn->bits.conn_to_host) {
+ result = idnconvert_hostname(conn, &conn->conn_to_host);
+ if(result)
+ goto out;
+ }
+ if(conn->bits.httpproxy) {
+ result = idnconvert_hostname(conn, &conn->http_proxy.host);
+ if(result)
+ goto out;
+ }
+ if(conn->bits.socksproxy) {
+ result = idnconvert_hostname(conn, &conn->socks_proxy.host);
+ if(result)
+ goto out;
+ }
/*************************************************************
* Check whether the host and the "connect to host" are equal.
- * Do this after the hostnames have been IDN-fixed.
+ * Do this after the hostnames have been IDN-converted.
*************************************************************/
if(conn->bits.conn_to_host &&
strcasecompare(conn->conn_to_host.name, conn->host.name)) {
@@ -6572,14 +3573,16 @@ static CURLcode create_conn(struct Curl_easy *data,
/* this is supposed to be the connect function so we better at least check
that the file is present here! */
DEBUGASSERT(conn->handler->connect_it);
+ Curl_persistconninfo(conn);
result = conn->handler->connect_it(conn, &done);
/* Setup a "faked" transfer that'll do nothing */
if(!result) {
- conn->data = data;
conn->bits.tcpconnect[FIRSTSOCKET] = TRUE; /* we are "connected */
- Curl_conncache_add_conn(data->state.conn_cache, conn);
+ result = Curl_conncache_add_conn(data->state.conn_cache, conn);
+ if(result)
+ goto out;
/*
* Setup whatever necessary for a resumed transfer
@@ -6591,9 +3594,8 @@ static CURLcode create_conn(struct Curl_easy *data,
(void)conn->handler->done(conn, result, FALSE);
goto out;
}
-
- Curl_setup_transfer(conn, -1, -1, FALSE, NULL, /* no download */
- -1, NULL); /* no upload */
+ Curl_attach_connnection(data, conn);
+ Curl_setup_transfer(data, -1, -1, FALSE, -1);
}
/* since we skip do_init() */
@@ -6625,6 +3627,10 @@ static CURLcode create_conn(struct Curl_easy *data,
data->set.str[STRING_SSL_CIPHER_LIST_ORIG];
data->set.proxy_ssl.primary.cipher_list =
data->set.str[STRING_SSL_CIPHER_LIST_PROXY];
+ data->set.ssl.primary.cipher_list13 =
+ data->set.str[STRING_SSL_CIPHER13_LIST_ORIG];
+ data->set.proxy_ssl.primary.cipher_list13 =
+ data->set.str[STRING_SSL_CIPHER13_LIST_PROXY];
data->set.ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_ORIG];
data->set.proxy_ssl.CRLfile = data->set.str[STRING_SSL_CRLFILE_PROXY];
@@ -6669,29 +3675,34 @@ static CURLcode create_conn(struct Curl_easy *data,
* new one.
*************************************************************/
+ DEBUGASSERT(conn->user);
+ DEBUGASSERT(conn->passwd);
+
/* reuse_fresh is TRUE if we are told to use a new connection by force, but
we only acknowledge this option if this is not a re-used connection
already (which happens due to follow-location or during a HTTP
- authentication phase). */
- if(data->set.reuse_fresh && !data->state.this_is_a_follow)
+ authentication phase). CONNECT_ONLY transfers also refuse reuse. */
+ if((data->set.reuse_fresh && !data->state.this_is_a_follow) ||
+ data->set.connect_only)
reuse = FALSE;
else
reuse = ConnectionExists(data, conn, &conn_temp, &force_reuse, &waitpipe);
- /* If we found a reusable connection, we may still want to
- open a new connection if we are pipelining. */
- if(reuse && !force_reuse && IsPipeliningPossible(data, conn_temp)) {
- size_t pipelen = conn_temp->send_pipe.size + conn_temp->recv_pipe.size;
- if(pipelen > 0) {
- infof(data, "Found connection %ld, with requests in the pipe (%zu)\n",
- conn_temp->connection_id, pipelen);
+ /* If we found a reusable connection that is now marked as in use, we may
+ still want to open a new connection if we are multiplexing. */
+ if(reuse && !force_reuse && IsMultiplexingPossible(data, conn_temp)) {
+ size_t multiplexed = CONN_INUSE(conn_temp);
+ if(multiplexed > 0) {
+ infof(data, "Found connection %ld, with %zu requests on it\n",
+ conn_temp->connection_id, multiplexed);
- if(conn_temp->bundle->num_connections < max_host_connections &&
- data->state.conn_cache->num_connections < max_total_connections) {
+ if(Curl_conncache_bundle_size(conn_temp) < max_host_connections &&
+ Curl_conncache_size(data) < max_total_connections) {
/* We want a new connection anyway */
reuse = FALSE;
infof(data, "We can reuse, but we want a new connection anyway\n");
+ Curl_conncache_return_conn(conn_temp);
}
}
}
@@ -6703,9 +3714,10 @@ static CURLcode create_conn(struct Curl_easy *data,
* just allocated before we can move along and use the previously
* existing one.
*/
- conn_temp->inuse = TRUE; /* mark this as being in use so that no other
- handle in a multi stack may nick it */
reuse_conn(conn, conn_temp);
+#ifdef USE_SSL
+ free(conn->ssl_extra);
+#endif
free(conn); /* we don't need this anymore */
conn = conn_temp;
*in_connect = conn;
@@ -6721,7 +3733,6 @@ static CURLcode create_conn(struct Curl_easy *data,
/* We have decided that we want a new connection. However, we may not
be able to do that if we have reached the limit of how many
connections we are allowed to open. */
- struct connectbundle *bundle = NULL;
if(conn->handler->flags & PROTOPT_ALPN_NPN) {
/* The protocol wants it, so set the bits if enabled in the easy handle
@@ -6733,44 +3744,46 @@ static CURLcode create_conn(struct Curl_easy *data,
}
if(waitpipe)
- /* There is a connection that *might* become usable for pipelining
+ /* There is a connection that *might* become usable for multiplexing
"soon", and we wait for that */
connections_available = FALSE;
- else
- bundle = Curl_conncache_find_bundle(conn, data->state.conn_cache);
+ else {
+ /* this gets a lock on the conncache */
+ struct connectbundle *bundle =
+ Curl_conncache_find_bundle(conn, data->state.conn_cache);
- if(max_host_connections > 0 && bundle &&
- (bundle->num_connections >= max_host_connections)) {
- struct connectdata *conn_candidate;
+ if(max_host_connections > 0 && bundle &&
+ (bundle->num_connections >= max_host_connections)) {
+ struct connectdata *conn_candidate;
- /* The bundle is full. Let's see if we can kill a connection. */
- conn_candidate = find_oldest_idle_connection_in_bundle(data, bundle);
+ /* The bundle is full. Extract the oldest connection. */
+ conn_candidate = Curl_conncache_extract_bundle(data, bundle);
+ Curl_conncache_unlock(data);
- if(conn_candidate) {
- /* Set the connection's owner correctly, then kill it */
- conn_candidate->data = data;
- (void)Curl_disconnect(conn_candidate, /* dead_connection */ FALSE);
- }
- else {
- infof(data, "No more connections allowed to host: %d\n",
- max_host_connections);
- connections_available = FALSE;
+ if(conn_candidate)
+ (void)Curl_disconnect(data, conn_candidate,
+ /* dead_connection */ FALSE);
+ else {
+ infof(data, "No more connections allowed to host: %zu\n",
+ max_host_connections);
+ connections_available = FALSE;
+ }
}
+ else
+ Curl_conncache_unlock(data);
+
}
if(connections_available &&
(max_total_connections > 0) &&
- (data->state.conn_cache->num_connections >= max_total_connections)) {
+ (Curl_conncache_size(data) >= max_total_connections)) {
struct connectdata *conn_candidate;
/* The cache is full. Let's see if we can kill a connection. */
- conn_candidate = Curl_oldest_idle_connection(data);
-
- if(conn_candidate) {
- /* Set the connection's owner correctly, then kill it */
- conn_candidate->data = data;
- (void)Curl_disconnect(conn_candidate, /* dead_connection */ FALSE);
- }
+ conn_candidate = Curl_conncache_extract_oldest(data);
+ if(conn_candidate)
+ (void)Curl_disconnect(data, conn_candidate,
+ /* dead_connection */ FALSE);
else {
infof(data, "No connections available in cache\n");
connections_available = FALSE;
@@ -6791,7 +3804,9 @@ static CURLcode create_conn(struct Curl_easy *data,
* This is a brand new connection, so let's store it in the connection
* cache of ours!
*/
- Curl_conncache_add_conn(data->state.conn_cache, conn);
+ result = Curl_conncache_add_conn(data->state.conn_cache, conn);
+ if(result)
+ goto out;
}
#if defined(USE_NTLM)
@@ -6814,9 +3829,6 @@ static CURLcode create_conn(struct Curl_easy *data,
#endif
}
- /* Mark the connection as used */
- conn->inuse = TRUE;
-
/* Setup and init stuff before DO starts, in preparing for the transfer. */
Curl_init_do(data, conn);
@@ -6841,11 +3853,16 @@ static CURLcode create_conn(struct Curl_easy *data,
*************************************************************/
result = resolve_server(data, conn, async);
-out:
+ /* Strip trailing dots. resolve_server copied the name. */
+ strip_trailing_dot(&conn->host);
+ if(conn->bits.httpproxy)
+ strip_trailing_dot(&conn->http_proxy.host);
+ if(conn->bits.socksproxy)
+ strip_trailing_dot(&conn->socks_proxy.host);
+ if(conn->bits.conn_to_host)
+ strip_trailing_dot(&conn->conn_to_host);
- free(options);
- free(passwd);
- free(user);
+out:
return result;
}
@@ -6899,7 +3916,7 @@ CURLcode Curl_setup_conn(struct connectdata *conn,
/* set start time here for timeout purposes in the connect procedure, it
is later set again for the progress meter purpose */
- conn->now = Curl_tvnow();
+ conn->now = Curl_now();
if(CURL_SOCKET_BAD == conn->sock[FIRSTSOCKET]) {
conn->bits.tcpconnect[FIRSTSOCKET] = FALSE;
@@ -6916,61 +3933,51 @@ CURLcode Curl_setup_conn(struct connectdata *conn,
Curl_verboseconnect(conn);
}
- conn->now = Curl_tvnow(); /* time this *after* the connect is done, we
- set this here perhaps a second time */
-
-#ifdef __EMX__
- /*
- * This check is quite a hack. We're calling _fsetmode to fix the problem
- * with fwrite converting newline characters (you get mangled text files,
- * and corrupted binary files when you download to stdout and redirect it to
- * a file).
- */
-
- if((data->set.out)->_handle == NULL) {
- _fsetmode(stdout, "b");
- }
-#endif
-
+ conn->now = Curl_now(); /* time this *after* the connect is done, we set
+ this here perhaps a second time */
return result;
}
CURLcode Curl_connect(struct Curl_easy *data,
- struct connectdata **in_connect,
bool *asyncp,
bool *protocol_done)
{
CURLcode result;
+ struct connectdata *conn;
*asyncp = FALSE; /* assume synchronous resolves by default */
+ /* init the single-transfer specific data */
+ Curl_free_request_state(data);
+ memset(&data->req, 0, sizeof(struct SingleRequest));
+ data->req.maxdownload = -1;
+
/* call the stuff that needs to be called */
- result = create_conn(data, in_connect, asyncp);
+ result = create_conn(data, &conn, asyncp);
if(!result) {
- /* no error */
- if((*in_connect)->send_pipe.size || (*in_connect)->recv_pipe.size)
- /* pipelining */
+ if(CONN_INUSE(conn))
+ /* multiplexed */
*protocol_done = TRUE;
else if(!*asyncp) {
/* DNS resolution is done: that's either because this is a reused
connection, in which case DNS was unnecessary, or because DNS
really did finish already (synch resolver/fast async resolve) */
- result = Curl_setup_conn(*in_connect, protocol_done);
+ result = Curl_setup_conn(conn, protocol_done);
}
}
if(result == CURLE_NO_CONNECTION_AVAILABLE) {
- *in_connect = NULL;
return result;
}
-
- if(result && *in_connect) {
- /* We're not allowed to return failure with memory left allocated
- in the connectdata struct, free those here */
- Curl_disconnect(*in_connect, FALSE); /* close the connection */
- *in_connect = NULL; /* return a NULL */
+ else if(result && conn) {
+ /* We're not allowed to return failure with memory left allocated in the
+ connectdata struct, free those here */
+ Curl_disconnect(data, conn, TRUE);
}
+ else if(!result && !data->conn)
+ /* FILE: transfers already have the connection attached */
+ Curl_attach_connnection(data, conn);
return result;
}
@@ -6989,13 +3996,19 @@ CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn)
{
struct SingleRequest *k = &data->req;
- if(conn)
+ if(conn) {
conn->bits.do_more = FALSE; /* by default there's no curl_do_more() to
- * use */
+ use */
+ /* if the protocol used doesn't support wildcards, switch it off */
+ if(data->state.wildcardmatch &&
+ !(conn->handler->flags & PROTOPT_WILDCARD))
+ data->state.wildcardmatch = FALSE;
+ }
data->state.done = FALSE; /* *_done() is not called yet */
data->state.expect100header = FALSE;
+
if(data->set.opt_no_body)
/* in HTTP lingo, no body means using the HEAD request... */
data->set.httpreq = HTTPREQ_HEAD;
@@ -7007,7 +4020,7 @@ CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn)
HTTP. */
data->set.httpreq = HTTPREQ_GET;
- k->start = Curl_tvnow(); /* start time */
+ k->start = Curl_now(); /* start time */
k->now = k->start; /* current time is now */
k->header = TRUE; /* assume header */
@@ -7015,7 +4028,7 @@ CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn)
k->buf = data->state.buffer;
k->hbufp = data->state.headerbuff;
- k->ignorebody=FALSE;
+ k->ignorebody = FALSE;
Curl_speedinit(data);
@@ -7134,3 +4147,34 @@ static unsigned int get_protocol_family(unsigned int protocol)
return family;
}
+
+
+/*
+ * Wrapper to call functions in Curl_conncache_foreach()
+ *
+ * Returns always 0.
+ */
+static int conn_upkeep(struct connectdata *conn,
+ void *param)
+{
+ /* Param is unused. */
+ (void)param;
+
+ if(conn->handler->connection_check) {
+ /* Do a protocol-specific keepalive check on the connection. */
+ conn->handler->connection_check(conn, CONNCHECK_KEEPALIVE);
+ }
+
+ return 0; /* continue iteration */
+}
+
+CURLcode Curl_upkeep(struct conncache *conn_cache,
+ void *data)
+{
+ /* Loop over every connection and make connection alive. */
+ Curl_conncache_foreach(data,
+ conn_cache,
+ data,
+ conn_upkeep);
+ return CURLE_OK;
+}
diff --git a/Utilities/cmcurl/lib/url.h b/Utilities/cmcurl/lib/url.h
index f13c8e664..4db9e8653 100644
--- a/Utilities/cmcurl/lib/url.h
+++ b/Utilities/cmcurl/lib/url.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -23,21 +23,38 @@
***************************************************************************/
#include "curl_setup.h"
+#define READBUFFER_SIZE CURL_MAX_WRITE_SIZE
+#define READBUFFER_MAX CURL_MAX_READ_SIZE
+#define READBUFFER_MIN 1024
+
+/* The default upload buffer size, should not be smaller than
+ CURL_MAX_WRITE_SIZE, as it needs to hold a full buffer as could be sent in
+ a write callback.
+
+ The size was 16KB for many years but was bumped to 64KB because it makes
+ libcurl able to do significantly faster uploads in some circumstances. Even
+ larger buffers can help further, but this is deemed a fair memory/speed
+ compromise. */
+#define UPLOADBUFFER_DEFAULT 65536
+#define UPLOADBUFFER_MAX (2*1024*1024)
+#define UPLOADBUFFER_MIN CURL_MAX_WRITE_SIZE
+
/*
* Prototypes for library-wide functions provided by url.c
*/
CURLcode Curl_init_do(struct Curl_easy *data, struct connectdata *conn);
CURLcode Curl_open(struct Curl_easy **curl);
-CURLcode Curl_init_userdefined(struct UserDefined *set);
-CURLcode Curl_setopt(struct Curl_easy *data, CURLoption option,
- va_list arg);
-CURLcode Curl_dupset(struct Curl_easy * dst, struct Curl_easy * src);
+CURLcode Curl_init_userdefined(struct Curl_easy *data);
+
void Curl_freeset(struct Curl_easy * data);
+/* free the URL pieces */
+void Curl_up_free(struct Curl_easy *data);
+CURLcode Curl_uc_to_curlcode(CURLUcode uc);
CURLcode Curl_close(struct Curl_easy *data); /* opposite of curl_open() */
-CURLcode Curl_connect(struct Curl_easy *, struct connectdata **,
- bool *async, bool *protocol_connect);
-CURLcode Curl_disconnect(struct connectdata *, bool dead_connection);
+CURLcode Curl_connect(struct Curl_easy *, bool *async, bool *protocol_connect);
+CURLcode Curl_disconnect(struct Curl_easy *data,
+ struct connectdata *, bool dead_connection);
CURLcode Curl_protocol_connect(struct connectdata *conn, bool *done);
CURLcode Curl_protocol_connecting(struct connectdata *conn, bool *done);
CURLcode Curl_protocol_doing(struct connectdata *conn, bool *done);
@@ -51,20 +68,13 @@ int Curl_protocol_getsock(struct connectdata *conn,
int Curl_doing_getsock(struct connectdata *conn,
curl_socket_t *socks,
int numsocks);
-
-bool Curl_isPipeliningEnabled(const struct Curl_easy *handle);
-CURLcode Curl_addHandleToPipeline(struct Curl_easy *handle,
- struct curl_llist *pipeline);
-int Curl_removeHandleFromPipeline(struct Curl_easy *handle,
- struct curl_llist *pipeline);
-struct connectdata *
-Curl_oldest_idle_connection(struct Curl_easy *data);
-/* remove the specified connection from all (possible) pipelines and related
- queues */
-void Curl_getoff_all_pipelines(struct Curl_easy *data,
- struct connectdata *conn);
-
+CURLcode Curl_parse_login_details(const char *login, const size_t len,
+ char **userptr, char **passwdptr,
+ char **optionsptr);
void Curl_close_connections(struct Curl_easy *data);
+CURLcode Curl_upkeep(struct conncache *conn_cache, void *data);
+
+const struct Curl_handler *Curl_builtin_scheme(const char *scheme);
#define CURL_DEFAULT_PROXY_PORT 1080 /* default proxy port unless specified */
#define CURL_DEFAULT_HTTPS_PROXY_PORT 443 /* default https proxy port unless
diff --git a/Utilities/cmcurl/lib/urlapi-int.h b/Utilities/cmcurl/lib/urlapi-int.h
new file mode 100644
index 000000000..5f059c203
--- /dev/null
+++ b/Utilities/cmcurl/lib/urlapi-int.h
@@ -0,0 +1,37 @@
+#ifndef HEADER_CURL_URLAPI_INT_H
+#define HEADER_CURL_URLAPI_INT_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "curl_setup.h"
+/* scheme is not URL encoded, the longest libcurl supported ones are... */
+#define MAX_SCHEME_LEN 40
+
+bool Curl_is_absolute_url(const char *url, char *scheme, size_t buflen);
+char *Curl_concat_url(const char *base, const char *relurl);
+size_t Curl_strlen_url(const char *url, bool relative);
+void Curl_strcpy_url(char *output, const char *url, bool relative);
+
+#ifdef DEBUGBUILD
+CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname);
+#endif
+
+#endif /* HEADER_CURL_URLAPI_INT_H */
diff --git a/Utilities/cmcurl/lib/urlapi.c b/Utilities/cmcurl/lib/urlapi.c
new file mode 100644
index 000000000..d07e4f5df
--- /dev/null
+++ b/Utilities/cmcurl/lib/urlapi.c
@@ -0,0 +1,1440 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+#include "curl_setup.h"
+
+#include "urldata.h"
+#include "urlapi-int.h"
+#include "strcase.h"
+#include "dotdot.h"
+#include "url.h"
+#include "escape.h"
+#include "curl_ctype.h"
+
+/* The last 3 #include files should be in this order */
+#include "curl_printf.h"
+#include "curl_memory.h"
+#include "memdebug.h"
+
+ /* MSDOS/Windows style drive prefix, eg c: in c:foo */
+#define STARTS_WITH_DRIVE_PREFIX(str) \
+ ((('a' <= str[0] && str[0] <= 'z') || \
+ ('A' <= str[0] && str[0] <= 'Z')) && \
+ (str[1] == ':'))
+
+ /* MSDOS/Windows style drive prefix, optionally with
+ * a '|' instead of ':', followed by a slash or NUL */
+#define STARTS_WITH_URL_DRIVE_PREFIX(str) \
+ ((('a' <= (str)[0] && (str)[0] <= 'z') || \
+ ('A' <= (str)[0] && (str)[0] <= 'Z')) && \
+ ((str)[1] == ':' || (str)[1] == '|') && \
+ ((str)[2] == '/' || (str)[2] == '\\' || (str)[2] == 0))
+
+/* Internal representation of CURLU. Point to URL-encoded strings. */
+struct Curl_URL {
+ char *scheme;
+ char *user;
+ char *password;
+ char *options; /* IMAP only? */
+ char *host;
+ char *zoneid; /* for numerical IPv6 addresses */
+ char *port;
+ char *path;
+ char *query;
+ char *fragment;
+
+ char *scratch; /* temporary scratch area */
+ long portnum; /* the numerical version */
+};
+
+#define DEFAULT_SCHEME "https"
+
+static void free_urlhandle(struct Curl_URL *u)
+{
+ free(u->scheme);
+ free(u->user);
+ free(u->password);
+ free(u->options);
+ free(u->host);
+ free(u->zoneid);
+ free(u->port);
+ free(u->path);
+ free(u->query);
+ free(u->fragment);
+ free(u->scratch);
+}
+
+/* move the full contents of one handle onto another and
+ free the original */
+static void mv_urlhandle(struct Curl_URL *from,
+ struct Curl_URL *to)
+{
+ free_urlhandle(to);
+ *to = *from;
+ free(from);
+}
+
+/*
+ * Find the separator at the end of the host name, or the '?' in cases like
+ * http://www.url.com?id=2380
+ */
+static const char *find_host_sep(const char *url)
+{
+ const char *sep;
+ const char *query;
+
+ /* Find the start of the hostname */
+ sep = strstr(url, "//");
+ if(!sep)
+ sep = url;
+ else
+ sep += 2;
+
+ query = strchr(sep, '?');
+ sep = strchr(sep, '/');
+
+ if(!sep)
+ sep = url + strlen(url);
+
+ if(!query)
+ query = url + strlen(url);
+
+ return sep < query ? sep : query;
+}
+
+/*
+ * Decide in an encoding-independent manner whether a character in an
+ * URL must be escaped. The same criterion must be used in strlen_url()
+ * and strcpy_url().
+ */
+static bool urlchar_needs_escaping(int c)
+{
+ return !(ISCNTRL(c) || ISSPACE(c) || ISGRAPH(c));
+}
+
+/*
+ * strlen_url() returns the length of the given URL if the spaces within the
+ * URL were properly URL encoded.
+ * URL encoding should be skipped for host names, otherwise IDN resolution
+ * will fail.
+ */
+static size_t strlen_url(const char *url, bool relative)
+{
+ const unsigned char *ptr;
+ size_t newlen = 0;
+ bool left = TRUE; /* left side of the ? */
+ const unsigned char *host_sep = (const unsigned char *) url;
+
+ if(!relative)
+ host_sep = (const unsigned char *) find_host_sep(url);
+
+ for(ptr = (unsigned char *)url; *ptr; ptr++) {
+
+ if(ptr < host_sep) {
+ ++newlen;
+ continue;
+ }
+
+ switch(*ptr) {
+ case '?':
+ left = FALSE;
+ /* FALLTHROUGH */
+ default:
+ if(urlchar_needs_escaping(*ptr))
+ newlen += 2;
+ newlen++;
+ break;
+ case ' ':
+ if(left)
+ newlen += 3;
+ else
+ newlen++;
+ break;
+ }
+ }
+ return newlen;
+}
+
+/* strcpy_url() copies a url to a output buffer and URL-encodes the spaces in
+ * the source URL accordingly.
+ * URL encoding should be skipped for host names, otherwise IDN resolution
+ * will fail.
+ */
+static void strcpy_url(char *output, const char *url, bool relative)
+{
+ /* we must add this with whitespace-replacing */
+ bool left = TRUE;
+ const unsigned char *iptr;
+ char *optr = output;
+ const unsigned char *host_sep = (const unsigned char *) url;
+
+ if(!relative)
+ host_sep = (const unsigned char *) find_host_sep(url);
+
+ for(iptr = (unsigned char *)url; /* read from here */
+ *iptr; /* until zero byte */
+ iptr++) {
+
+ if(iptr < host_sep) {
+ *optr++ = *iptr;
+ continue;
+ }
+
+ switch(*iptr) {
+ case '?':
+ left = FALSE;
+ /* FALLTHROUGH */
+ default:
+ if(urlchar_needs_escaping(*iptr)) {
+ msnprintf(optr, 4, "%%%02x", *iptr);
+ optr += 3;
+ }
+ else
+ *optr++=*iptr;
+ break;
+ case ' ':
+ if(left) {
+ *optr++='%'; /* add a '%' */
+ *optr++='2'; /* add a '2' */
+ *optr++='0'; /* add a '0' */
+ }
+ else
+ *optr++='+'; /* add a '+' here */
+ break;
+ }
+ }
+ *optr = 0; /* zero terminate output buffer */
+
+}
+
+/*
+ * Returns true if the given URL is absolute (as opposed to relative) within
+ * the buffer size. Returns the scheme in the buffer if TRUE and 'buf' is
+ * non-NULL.
+ */
+bool Curl_is_absolute_url(const char *url, char *buf, size_t buflen)
+{
+ size_t i;
+#ifdef WIN32
+ if(STARTS_WITH_DRIVE_PREFIX(url))
+ return FALSE;
+#endif
+ for(i = 0; i < buflen && url[i]; ++i) {
+ char s = url[i];
+ if((s == ':') && (url[i + 1] == '/')) {
+ if(buf)
+ buf[i] = 0;
+ return TRUE;
+ }
+ /* RFC 3986 3.1 explains:
+ scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
+ */
+ else if(ISALNUM(s) || (s == '+') || (s == '-') || (s == '.') ) {
+ if(buf)
+ buf[i] = (char)TOLOWER(s);
+ }
+ else
+ break;
+ }
+ return FALSE;
+}
+
+/*
+ * Concatenate a relative URL to a base URL making it absolute.
+ * URL-encodes any spaces.
+ * The returned pointer must be freed by the caller unless NULL
+ * (returns NULL on out of memory).
+ */
+static char *concat_url(const char *base, const char *relurl)
+{
+ /***
+ TRY to append this new path to the old URL
+ to the right of the host part. Oh crap, this is doomed to cause
+ problems in the future...
+ */
+ char *newest;
+ char *protsep;
+ char *pathsep;
+ size_t newlen;
+ bool host_changed = FALSE;
+
+ const char *useurl = relurl;
+ size_t urllen;
+
+ /* we must make our own copy of the URL to play with, as it may
+ point to read-only data */
+ char *url_clone = strdup(base);
+
+ if(!url_clone)
+ return NULL; /* skip out of this NOW */
+
+ /* protsep points to the start of the host name */
+ protsep = strstr(url_clone, "//");
+ if(!protsep)
+ protsep = url_clone;
+ else
+ protsep += 2; /* pass the slashes */
+
+ if('/' != relurl[0]) {
+ int level = 0;
+
+ /* First we need to find out if there's a ?-letter in the URL,
+ and cut it and the right-side of that off */
+ pathsep = strchr(protsep, '?');
+ if(pathsep)
+ *pathsep = 0;
+
+ /* we have a relative path to append to the last slash if there's one
+ available, or if the new URL is just a query string (starts with a
+ '?') we append the new one at the end of the entire currently worked
+ out URL */
+ if(useurl[0] != '?') {
+ pathsep = strrchr(protsep, '/');
+ if(pathsep)
+ *pathsep = 0;
+ }
+
+ /* Check if there's any slash after the host name, and if so, remember
+ that position instead */
+ pathsep = strchr(protsep, '/');
+ if(pathsep)
+ protsep = pathsep + 1;
+ else
+ protsep = NULL;
+
+ /* now deal with one "./" or any amount of "../" in the newurl
+ and act accordingly */
+
+ if((useurl[0] == '.') && (useurl[1] == '/'))
+ useurl += 2; /* just skip the "./" */
+
+ while((useurl[0] == '.') &&
+ (useurl[1] == '.') &&
+ (useurl[2] == '/')) {
+ level++;
+ useurl += 3; /* pass the "../" */
+ }
+
+ if(protsep) {
+ while(level--) {
+ /* cut off one more level from the right of the original URL */
+ pathsep = strrchr(protsep, '/');
+ if(pathsep)
+ *pathsep = 0;
+ else {
+ *protsep = 0;
+ break;
+ }
+ }
+ }
+ }
+ else {
+ /* We got a new absolute path for this server */
+
+ if((relurl[0] == '/') && (relurl[1] == '/')) {
+ /* the new URL starts with //, just keep the protocol part from the
+ original one */
+ *protsep = 0;
+ useurl = &relurl[2]; /* we keep the slashes from the original, so we
+ skip the new ones */
+ host_changed = TRUE;
+ }
+ else {
+ /* cut off the original URL from the first slash, or deal with URLs
+ without slash */
+ pathsep = strchr(protsep, '/');
+ if(pathsep) {
+ /* When people use badly formatted URLs, such as
+ "http://www.url.com?dir=/home/daniel" we must not use the first
+ slash, if there's a ?-letter before it! */
+ char *sep = strchr(protsep, '?');
+ if(sep && (sep < pathsep))
+ pathsep = sep;
+ *pathsep = 0;
+ }
+ else {
+ /* There was no slash. Now, since we might be operating on a badly
+ formatted URL, such as "http://www.url.com?id=2380" which doesn't
+ use a slash separator as it is supposed to, we need to check for a
+ ?-letter as well! */
+ pathsep = strchr(protsep, '?');
+ if(pathsep)
+ *pathsep = 0;
+ }
+ }
+ }
+
+ /* If the new part contains a space, this is a mighty stupid redirect
+ but we still make an effort to do "right". To the left of a '?'
+ letter we replace each space with %20 while it is replaced with '+'
+ on the right side of the '?' letter.
+ */
+ newlen = strlen_url(useurl, !host_changed);
+
+ urllen = strlen(url_clone);
+
+ newest = malloc(urllen + 1 + /* possible slash */
+ newlen + 1 /* zero byte */);
+
+ if(!newest) {
+ free(url_clone); /* don't leak this */
+ return NULL;
+ }
+
+ /* copy over the root url part */
+ memcpy(newest, url_clone, urllen);
+
+ /* check if we need to append a slash */
+ if(('/' == useurl[0]) || (protsep && !*protsep) || ('?' == useurl[0]))
+ ;
+ else
+ newest[urllen++]='/';
+
+ /* then append the new piece on the right side */
+ strcpy_url(&newest[urllen], useurl, !host_changed);
+
+ free(url_clone);
+
+ return newest;
+}
+
+/*
+ * parse_hostname_login()
+ *
+ * Parse the login details (user name, password and options) from the URL and
+ * strip them out of the host name
+ *
+ */
+static CURLUcode parse_hostname_login(struct Curl_URL *u,
+ const struct Curl_handler *h,
+ char **hostname,
+ unsigned int flags)
+{
+ CURLUcode result = CURLUE_OK;
+ CURLcode ccode;
+ char *userp = NULL;
+ char *passwdp = NULL;
+ char *optionsp = NULL;
+
+ /* At this point, we're hoping all the other special cases have
+ * been taken care of, so conn->host.name is at most
+ * [user[:password][;options]]@]hostname
+ *
+ * We need somewhere to put the embedded details, so do that first.
+ */
+
+ char *ptr = strchr(*hostname, '@');
+ char *login = *hostname;
+
+ if(!ptr)
+ goto out;
+
+ /* We will now try to extract the
+ * possible login information in a string like:
+ * ftp://user:password@ftp.my.site:8021/README */
+ *hostname = ++ptr;
+
+ /* We could use the login information in the URL so extract it. Only parse
+ options if the handler says we should. Note that 'h' might be NULL! */
+ ccode = Curl_parse_login_details(login, ptr - login - 1,
+ &userp, &passwdp,
+ (h && (h->flags & PROTOPT_URLOPTIONS)) ?
+ &optionsp:NULL);
+ if(ccode) {
+ result = CURLUE_MALFORMED_INPUT;
+ goto out;
+ }
+
+ if(userp) {
+ if(flags & CURLU_DISALLOW_USER) {
+ /* Option DISALLOW_USER is set and url contains username. */
+ result = CURLUE_USER_NOT_ALLOWED;
+ goto out;
+ }
+
+ u->user = userp;
+ }
+
+ if(passwdp)
+ u->password = passwdp;
+
+ if(optionsp)
+ u->options = optionsp;
+
+ return CURLUE_OK;
+ out:
+
+ free(userp);
+ free(passwdp);
+ free(optionsp);
+
+ return result;
+}
+
+UNITTEST CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname)
+{
+ char *portptr = NULL;
+ char endbracket;
+ int len;
+
+ /*
+ * Find the end of an IPv6 address, either on the ']' ending bracket or
+ * a percent-encoded zone index.
+ */
+ if(1 == sscanf(hostname, "[%*45[0123456789abcdefABCDEF:.]%c%n",
+ &endbracket, &len)) {
+ if(']' == endbracket)
+ portptr = &hostname[len];
+ else if('%' == endbracket) {
+ int zonelen = len;
+ if(1 == sscanf(hostname + zonelen, "%*[^]]%c%n", &endbracket, &len)) {
+ if(']' != endbracket)
+ return CURLUE_MALFORMED_INPUT;
+ portptr = &hostname[--zonelen + len + 1];
+ }
+ else
+ return CURLUE_MALFORMED_INPUT;
+ }
+ else
+ return CURLUE_MALFORMED_INPUT;
+
+ /* this is a RFC2732-style specified IP-address */
+ if(portptr && *portptr) {
+ if(*portptr != ':')
+ return CURLUE_MALFORMED_INPUT;
+ }
+ else
+ portptr = NULL;
+ }
+ else
+ portptr = strchr(hostname, ':');
+
+ if(portptr) {
+ char *rest;
+ long port;
+ char portbuf[7];
+
+ /* Browser behavior adaptation. If there's a colon with no digits after,
+ just cut off the name there which makes us ignore the colon and just
+ use the default port. Firefox, Chrome and Safari all do that. */
+ if(!portptr[1]) {
+ *portptr = '\0';
+ return CURLUE_OK;
+ }
+
+ if(!ISDIGIT(portptr[1]))
+ return CURLUE_BAD_PORT_NUMBER;
+
+ port = strtol(portptr + 1, &rest, 10); /* Port number must be decimal */
+
+ if((port <= 0) || (port > 0xffff))
+ /* Single unix standard says port numbers are 16 bits long, but we don't
+ treat port zero as OK. */
+ return CURLUE_BAD_PORT_NUMBER;
+
+ if(rest[0])
+ return CURLUE_BAD_PORT_NUMBER;
+
+ *portptr++ = '\0'; /* cut off the name there */
+ *rest = 0;
+ /* generate a new port number string to get rid of leading zeroes etc */
+ msnprintf(portbuf, sizeof(portbuf), "%ld", port);
+ u->portnum = port;
+ u->port = strdup(portbuf);
+ if(!u->port)
+ return CURLUE_OUT_OF_MEMORY;
+ }
+
+ return CURLUE_OK;
+}
+
+/* scan for byte values < 31 or 127 */
+static CURLUcode junkscan(char *part)
+{
+ if(part) {
+ static const char badbytes[]={
+ /* */ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ 0x7f,
+ 0x00 /* zero terminate */
+ };
+ size_t n = strlen(part);
+ size_t nfine = strcspn(part, badbytes);
+ if(nfine != n)
+ /* since we don't know which part is scanned, return a generic error
+ code */
+ return CURLUE_MALFORMED_INPUT;
+ }
+ return CURLUE_OK;
+}
+
+static CURLUcode hostname_check(struct Curl_URL *u, char *hostname)
+{
+ const char *l = NULL; /* accepted characters */
+ size_t len;
+ size_t hlen = strlen(hostname);
+
+ if(hostname[0] == '[') {
+ hostname++;
+ l = "0123456789abcdefABCDEF::.";
+ hlen -= 2;
+ }
+
+ if(l) {
+ /* only valid letters are ok */
+ len = strspn(hostname, l);
+ if(hlen != len) {
+ if(hostname[len] == '%') {
+ /* this could now be '%[zone id]' */
+ char zoneid[16];
+ int i = 0;
+ char *h = &hostname[len + 1];
+ /* pass '25' if present and is a url encoded percent sign */
+ if(!strncmp(h, "25", 2) && h[2] && (h[2] != ']'))
+ h += 2;
+ while(*h && (*h != ']') && (i < 15))
+ zoneid[i++] = *h++;
+ if(!i || (']' != *h))
+ return CURLUE_MALFORMED_INPUT;
+ zoneid[i] = 0;
+ u->zoneid = strdup(zoneid);
+ if(!u->zoneid)
+ return CURLUE_OUT_OF_MEMORY;
+ hostname[len] = ']'; /* insert end bracket */
+ hostname[len + 1] = 0; /* terminate the hostname */
+ }
+ else
+ return CURLUE_MALFORMED_INPUT;
+ /* hostname is fine */
+ }
+ }
+ else {
+ /* letters from the second string is not ok */
+ len = strcspn(hostname, " ");
+ if(hlen != len)
+ /* hostname with bad content */
+ return CURLUE_MALFORMED_INPUT;
+ }
+ if(!hostname[0])
+ return CURLUE_NO_HOST;
+ return CURLUE_OK;
+}
+
+#define HOSTNAME_END(x) (((x) == '/') || ((x) == '?') || ((x) == '#'))
+
+static CURLUcode seturl(const char *url, CURLU *u, unsigned int flags)
+{
+ char *path;
+ bool path_alloced = FALSE;
+ char *hostname;
+ char *query = NULL;
+ char *fragment = NULL;
+ CURLUcode result;
+ bool url_has_scheme = FALSE;
+ char schemebuf[MAX_SCHEME_LEN + 1];
+ char *schemep = NULL;
+ size_t schemelen = 0;
+ size_t urllen;
+ const struct Curl_handler *h = NULL;
+
+ if(!url)
+ return CURLUE_MALFORMED_INPUT;
+
+ /*************************************************************
+ * Parse the URL.
+ ************************************************************/
+ /* allocate scratch area */
+ urllen = strlen(url);
+ if(urllen > CURL_MAX_INPUT_LENGTH)
+ /* excessive input length */
+ return CURLUE_MALFORMED_INPUT;
+
+ path = u->scratch = malloc(urllen * 2 + 2);
+ if(!path)
+ return CURLUE_OUT_OF_MEMORY;
+
+ hostname = &path[urllen + 1];
+ hostname[0] = 0;
+
+ if(Curl_is_absolute_url(url, schemebuf, sizeof(schemebuf))) {
+ url_has_scheme = TRUE;
+ schemelen = strlen(schemebuf);
+ }
+
+ /* handle the file: scheme */
+ if(url_has_scheme && strcasecompare(schemebuf, "file")) {
+ /* path has been allocated large enough to hold this */
+ strcpy(path, &url[5]);
+
+ hostname = NULL; /* no host for file: URLs */
+ u->scheme = strdup("file");
+ if(!u->scheme)
+ return CURLUE_OUT_OF_MEMORY;
+
+ /* Extra handling URLs with an authority component (i.e. that start with
+ * "file://")
+ *
+ * We allow omitted hostname (e.g. file:/<path>) -- valid according to
+ * RFC 8089, but not the (current) WHAT-WG URL spec.
+ */
+ if(path[0] == '/' && path[1] == '/') {
+ /* swallow the two slashes */
+ char *ptr = &path[2];
+
+ /*
+ * According to RFC 8089, a file: URL can be reliably dereferenced if:
+ *
+ * o it has no/blank hostname, or
+ *
+ * o the hostname matches "localhost" (case-insensitively), or
+ *
+ * o the hostname is a FQDN that resolves to this machine.
+ *
+ * For brevity, we only consider URLs with empty, "localhost", or
+ * "127.0.0.1" hostnames as local.
+ *
+ * Additionally, there is an exception for URLs with a Windows drive
+ * letter in the authority (which was accidentally omitted from RFC 8089
+ * Appendix E, but believe me, it was meant to be there. --MK)
+ */
+ if(ptr[0] != '/' && !STARTS_WITH_URL_DRIVE_PREFIX(ptr)) {
+ /* the URL includes a host name, it must match "localhost" or
+ "127.0.0.1" to be valid */
+ if(!checkprefix("localhost/", ptr) &&
+ !checkprefix("127.0.0.1/", ptr)) {
+ /* Invalid file://hostname/, expected localhost or 127.0.0.1 or
+ none */
+ return CURLUE_MALFORMED_INPUT;
+ }
+ ptr += 9; /* now points to the slash after the host */
+ }
+
+ path = ptr;
+ }
+
+#if !defined(MSDOS) && !defined(WIN32) && !defined(__CYGWIN__)
+ /* Don't allow Windows drive letters when not in Windows.
+ * This catches both "file:/c:" and "file:c:" */
+ if(('/' == path[0] && STARTS_WITH_URL_DRIVE_PREFIX(&path[1])) ||
+ STARTS_WITH_URL_DRIVE_PREFIX(path)) {
+ /* File drive letters are only accepted in MSDOS/Windows */
+ return CURLUE_MALFORMED_INPUT;
+ }
+#else
+ /* If the path starts with a slash and a drive letter, ditch the slash */
+ if('/' == path[0] && STARTS_WITH_URL_DRIVE_PREFIX(&path[1])) {
+ /* This cannot be done with strcpy, as the memory chunks overlap! */
+ memmove(path, &path[1], strlen(&path[1]) + 1);
+ }
+#endif
+
+ }
+ else {
+ /* clear path */
+ const char *p;
+ const char *hostp;
+ size_t len;
+ path[0] = 0;
+
+ if(url_has_scheme) {
+ int i = 0;
+ p = &url[schemelen + 1];
+ while(p && (*p == '/') && (i < 4)) {
+ p++;
+ i++;
+ }
+ if((i < 1) || (i>3))
+ /* less than one or more than three slashes */
+ return CURLUE_MALFORMED_INPUT;
+
+ schemep = schemebuf;
+ if(!Curl_builtin_scheme(schemep) &&
+ !(flags & CURLU_NON_SUPPORT_SCHEME))
+ return CURLUE_UNSUPPORTED_SCHEME;
+
+ if(junkscan(schemep))
+ return CURLUE_MALFORMED_INPUT;
+ }
+ else {
+ /* no scheme! */
+
+ if(!(flags & (CURLU_DEFAULT_SCHEME|CURLU_GUESS_SCHEME)))
+ return CURLUE_MALFORMED_INPUT;
+ if(flags & CURLU_DEFAULT_SCHEME)
+ schemep = (char *) DEFAULT_SCHEME;
+
+ /*
+ * The URL was badly formatted, let's try without scheme specified.
+ */
+ p = url;
+ }
+ hostp = p; /* host name starts here */
+
+ while(*p && !HOSTNAME_END(*p)) /* find end of host name */
+ p++;
+
+ len = p - hostp;
+ if(!len)
+ return CURLUE_MALFORMED_INPUT;
+
+ memcpy(hostname, hostp, len);
+ hostname[len] = 0;
+
+ if((flags & CURLU_GUESS_SCHEME) && !schemep) {
+ /* legacy curl-style guess based on host name */
+ if(checkprefix("ftp.", hostname))
+ schemep = (char *)"ftp";
+ else if(checkprefix("dict.", hostname))
+ schemep = (char *)"dict";
+ else if(checkprefix("ldap.", hostname))
+ schemep = (char *)"ldap";
+ else if(checkprefix("imap.", hostname))
+ schemep = (char *)"imap";
+ else if(checkprefix("smtp.", hostname))
+ schemep = (char *)"smtp";
+ else if(checkprefix("pop3.", hostname))
+ schemep = (char *)"pop3";
+ else
+ schemep = (char *)"http";
+ }
+
+ len = strlen(p);
+ memcpy(path, p, len);
+ path[len] = 0;
+
+ u->scheme = strdup(schemep);
+ if(!u->scheme)
+ return CURLUE_OUT_OF_MEMORY;
+ }
+
+ /* if this is a known scheme, get some details */
+ h = Curl_builtin_scheme(u->scheme);
+
+ if(junkscan(path))
+ return CURLUE_MALFORMED_INPUT;
+
+ query = strchr(path, '?');
+ if(query)
+ *query++ = 0;
+
+ fragment = strchr(query?query:path, '#');
+ if(fragment)
+ *fragment++ = 0;
+
+ if(!path[0])
+ /* if there's no path set, unset */
+ path = NULL;
+ else if(!(flags & CURLU_PATH_AS_IS)) {
+ /* sanitise paths and remove ../ and ./ sequences according to RFC3986 */
+ char *newp = Curl_dedotdotify(path);
+ if(!newp)
+ return CURLUE_OUT_OF_MEMORY;
+
+ if(strcmp(newp, path)) {
+ /* if we got a new version */
+ path = newp;
+ path_alloced = TRUE;
+ }
+ else
+ free(newp);
+ }
+ if(path) {
+ u->path = path_alloced?path:strdup(path);
+ if(!u->path)
+ return CURLUE_OUT_OF_MEMORY;
+ }
+
+ if(hostname) {
+ /*
+ * Parse the login details and strip them out of the host name.
+ */
+ if(junkscan(hostname))
+ return CURLUE_MALFORMED_INPUT;
+
+ result = parse_hostname_login(u, h, &hostname, flags);
+ if(result)
+ return result;
+
+ result = Curl_parse_port(u, hostname);
+ if(result)
+ return result;
+
+ result = hostname_check(u, hostname);
+ if(result)
+ return result;
+
+ u->host = strdup(hostname);
+ if(!u->host)
+ return CURLUE_OUT_OF_MEMORY;
+ }
+
+ if(query) {
+ u->query = strdup(query);
+ if(!u->query)
+ return CURLUE_OUT_OF_MEMORY;
+ }
+ if(fragment && fragment[0]) {
+ u->fragment = strdup(fragment);
+ if(!u->fragment)
+ return CURLUE_OUT_OF_MEMORY;
+ }
+
+ free(u->scratch);
+ u->scratch = NULL;
+
+ return CURLUE_OK;
+}
+
+/*
+ * Parse the URL and set the relevant members of the Curl_URL struct.
+ */
+static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags)
+{
+ CURLUcode result = seturl(url, u, flags);
+ if(result) {
+ free_urlhandle(u);
+ memset(u, 0, sizeof(struct Curl_URL));
+ }
+ return result;
+}
+
+/*
+ */
+CURLU *curl_url(void)
+{
+ return calloc(sizeof(struct Curl_URL), 1);
+}
+
+void curl_url_cleanup(CURLU *u)
+{
+ if(u) {
+ free_urlhandle(u);
+ free(u);
+ }
+}
+
+#define DUP(dest, src, name) \
+ if(src->name) { \
+ dest->name = strdup(src->name); \
+ if(!dest->name) \
+ goto fail; \
+ }
+
+CURLU *curl_url_dup(CURLU *in)
+{
+ struct Curl_URL *u = calloc(sizeof(struct Curl_URL), 1);
+ if(u) {
+ DUP(u, in, scheme);
+ DUP(u, in, user);
+ DUP(u, in, password);
+ DUP(u, in, options);
+ DUP(u, in, host);
+ DUP(u, in, port);
+ DUP(u, in, path);
+ DUP(u, in, query);
+ DUP(u, in, fragment);
+ u->portnum = in->portnum;
+ }
+ return u;
+ fail:
+ curl_url_cleanup(u);
+ return NULL;
+}
+
+CURLUcode curl_url_get(CURLU *u, CURLUPart what,
+ char **part, unsigned int flags)
+{
+ char *ptr;
+ CURLUcode ifmissing = CURLUE_UNKNOWN_PART;
+ char portbuf[7];
+ bool urldecode = (flags & CURLU_URLDECODE)?1:0;
+ bool plusdecode = FALSE;
+ (void)flags;
+ if(!u)
+ return CURLUE_BAD_HANDLE;
+ if(!part)
+ return CURLUE_BAD_PARTPOINTER;
+ *part = NULL;
+
+ switch(what) {
+ case CURLUPART_SCHEME:
+ ptr = u->scheme;
+ ifmissing = CURLUE_NO_SCHEME;
+ urldecode = FALSE; /* never for schemes */
+ break;
+ case CURLUPART_USER:
+ ptr = u->user;
+ ifmissing = CURLUE_NO_USER;
+ break;
+ case CURLUPART_PASSWORD:
+ ptr = u->password;
+ ifmissing = CURLUE_NO_PASSWORD;
+ break;
+ case CURLUPART_OPTIONS:
+ ptr = u->options;
+ ifmissing = CURLUE_NO_OPTIONS;
+ break;
+ case CURLUPART_HOST:
+ ptr = u->host;
+ ifmissing = CURLUE_NO_HOST;
+ break;
+ case CURLUPART_ZONEID:
+ ptr = u->zoneid;
+ break;
+ case CURLUPART_PORT:
+ ptr = u->port;
+ ifmissing = CURLUE_NO_PORT;
+ urldecode = FALSE; /* never for port */
+ if(!ptr && (flags & CURLU_DEFAULT_PORT) && u->scheme) {
+ /* there's no stored port number, but asked to deliver
+ a default one for the scheme */
+ const struct Curl_handler *h =
+ Curl_builtin_scheme(u->scheme);
+ if(h) {
+ msnprintf(portbuf, sizeof(portbuf), "%ld", h->defport);
+ ptr = portbuf;
+ }
+ }
+ else if(ptr && u->scheme) {
+ /* there is a stored port number, but ask to inhibit if
+ it matches the default one for the scheme */
+ const struct Curl_handler *h =
+ Curl_builtin_scheme(u->scheme);
+ if(h && (h->defport == u->portnum) &&
+ (flags & CURLU_NO_DEFAULT_PORT))
+ ptr = NULL;
+ }
+ break;
+ case CURLUPART_PATH:
+ ptr = u->path;
+ if(!ptr) {
+ ptr = u->path = strdup("/");
+ if(!u->path)
+ return CURLUE_OUT_OF_MEMORY;
+ }
+ break;
+ case CURLUPART_QUERY:
+ ptr = u->query;
+ ifmissing = CURLUE_NO_QUERY;
+ plusdecode = urldecode;
+ break;
+ case CURLUPART_FRAGMENT:
+ ptr = u->fragment;
+ ifmissing = CURLUE_NO_FRAGMENT;
+ break;
+ case CURLUPART_URL: {
+ char *url;
+ char *scheme;
+ char *options = u->options;
+ char *port = u->port;
+ char *allochost = NULL;
+ if(u->scheme && strcasecompare("file", u->scheme)) {
+ url = aprintf("file://%s%s%s",
+ u->path,
+ u->fragment? "#": "",
+ u->fragment? u->fragment : "");
+ }
+ else if(!u->host)
+ return CURLUE_NO_HOST;
+ else {
+ const struct Curl_handler *h = NULL;
+ if(u->scheme)
+ scheme = u->scheme;
+ else if(flags & CURLU_DEFAULT_SCHEME)
+ scheme = (char *) DEFAULT_SCHEME;
+ else
+ return CURLUE_NO_SCHEME;
+
+ if(scheme) {
+ h = Curl_builtin_scheme(scheme);
+ if(!port && (flags & CURLU_DEFAULT_PORT)) {
+ /* there's no stored port number, but asked to deliver
+ a default one for the scheme */
+ if(h) {
+ msnprintf(portbuf, sizeof(portbuf), "%ld", h->defport);
+ port = portbuf;
+ }
+ }
+ else if(port) {
+ /* there is a stored port number, but asked to inhibit if it matches
+ the default one for the scheme */
+ if(h && (h->defport == u->portnum) &&
+ (flags & CURLU_NO_DEFAULT_PORT))
+ port = NULL;
+ }
+ }
+ if(h && !(h->flags & PROTOPT_URLOPTIONS))
+ options = NULL;
+
+ if((u->host[0] == '[') && u->zoneid) {
+ /* make it '[ host %25 zoneid ]' */
+ size_t hostlen = strlen(u->host);
+ size_t alen = hostlen + 3 + strlen(u->zoneid) + 1;
+ allochost = malloc(alen);
+ if(!allochost)
+ return CURLUE_OUT_OF_MEMORY;
+ memcpy(allochost, u->host, hostlen - 1);
+ msnprintf(&allochost[hostlen - 1], alen - hostlen + 1,
+ "%%25%s]", u->zoneid);
+ }
+
+ url = aprintf("%s://%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+ scheme,
+ u->user ? u->user : "",
+ u->password ? ":": "",
+ u->password ? u->password : "",
+ options ? ";" : "",
+ options ? options : "",
+ (u->user || u->password || options) ? "@": "",
+ allochost ? allochost : u->host,
+ port ? ":": "",
+ port ? port : "",
+ (u->path && (u->path[0] != '/')) ? "/": "",
+ u->path ? u->path : "/",
+ (u->query && u->query[0]) ? "?": "",
+ (u->query && u->query[0]) ? u->query : "",
+ u->fragment? "#": "",
+ u->fragment? u->fragment : "");
+ free(allochost);
+ }
+ if(!url)
+ return CURLUE_OUT_OF_MEMORY;
+ *part = url;
+ return CURLUE_OK;
+ }
+ default:
+ ptr = NULL;
+ break;
+ }
+ if(ptr) {
+ *part = strdup(ptr);
+ if(!*part)
+ return CURLUE_OUT_OF_MEMORY;
+ if(plusdecode) {
+ /* convert + to space */
+ char *plus;
+ for(plus = *part; *plus; ++plus) {
+ if(*plus == '+')
+ *plus = ' ';
+ }
+ }
+ if(urldecode) {
+ char *decoded;
+ size_t dlen;
+ CURLcode res = Curl_urldecode(NULL, *part, 0, &decoded, &dlen, TRUE);
+ free(*part);
+ if(res) {
+ *part = NULL;
+ return CURLUE_URLDECODE;
+ }
+ *part = decoded;
+ }
+ return CURLUE_OK;
+ }
+ else
+ return ifmissing;
+}
+
+CURLUcode curl_url_set(CURLU *u, CURLUPart what,
+ const char *part, unsigned int flags)
+{
+ char **storep = NULL;
+ long port = 0;
+ bool urlencode = (flags & CURLU_URLENCODE)? 1 : 0;
+ bool plusencode = FALSE;
+ bool urlskipslash = FALSE;
+ bool appendquery = FALSE;
+ bool equalsencode = FALSE;
+
+ if(!u)
+ return CURLUE_BAD_HANDLE;
+ if(!part) {
+ /* setting a part to NULL clears it */
+ switch(what) {
+ case CURLUPART_URL:
+ break;
+ case CURLUPART_SCHEME:
+ storep = &u->scheme;
+ break;
+ case CURLUPART_USER:
+ storep = &u->user;
+ break;
+ case CURLUPART_PASSWORD:
+ storep = &u->password;
+ break;
+ case CURLUPART_OPTIONS:
+ storep = &u->options;
+ break;
+ case CURLUPART_HOST:
+ storep = &u->host;
+ break;
+ case CURLUPART_ZONEID:
+ storep = &u->zoneid;
+ break;
+ case CURLUPART_PORT:
+ u->portnum = 0;
+ storep = &u->port;
+ break;
+ case CURLUPART_PATH:
+ storep = &u->path;
+ break;
+ case CURLUPART_QUERY:
+ storep = &u->query;
+ break;
+ case CURLUPART_FRAGMENT:
+ storep = &u->fragment;
+ break;
+ default:
+ return CURLUE_UNKNOWN_PART;
+ }
+ if(storep && *storep) {
+ free(*storep);
+ *storep = NULL;
+ }
+ return CURLUE_OK;
+ }
+
+ switch(what) {
+ case CURLUPART_SCHEME:
+ if(strlen(part) > MAX_SCHEME_LEN)
+ /* too long */
+ return CURLUE_MALFORMED_INPUT;
+ if(!(flags & CURLU_NON_SUPPORT_SCHEME) &&
+ /* verify that it is a fine scheme */
+ !Curl_builtin_scheme(part))
+ return CURLUE_UNSUPPORTED_SCHEME;
+ storep = &u->scheme;
+ urlencode = FALSE; /* never */
+ break;
+ case CURLUPART_USER:
+ storep = &u->user;
+ break;
+ case CURLUPART_PASSWORD:
+ storep = &u->password;
+ break;
+ case CURLUPART_OPTIONS:
+ storep = &u->options;
+ break;
+ case CURLUPART_HOST:
+ storep = &u->host;
+ free(u->zoneid);
+ u->zoneid = NULL;
+ break;
+ case CURLUPART_ZONEID:
+ storep = &u->zoneid;
+ break;
+ case CURLUPART_PORT:
+ {
+ char *endp;
+ urlencode = FALSE; /* never */
+ port = strtol(part, &endp, 10); /* Port number must be decimal */
+ if((port <= 0) || (port > 0xffff))
+ return CURLUE_BAD_PORT_NUMBER;
+ if(*endp)
+ /* weirdly provided number, not good! */
+ return CURLUE_MALFORMED_INPUT;
+ storep = &u->port;
+ }
+ break;
+ case CURLUPART_PATH:
+ urlskipslash = TRUE;
+ storep = &u->path;
+ break;
+ case CURLUPART_QUERY:
+ plusencode = urlencode;
+ appendquery = (flags & CURLU_APPENDQUERY)?1:0;
+ equalsencode = appendquery;
+ storep = &u->query;
+ break;
+ case CURLUPART_FRAGMENT:
+ storep = &u->fragment;
+ break;
+ case CURLUPART_URL: {
+ /*
+ * Allow a new URL to replace the existing (if any) contents.
+ *
+ * If the existing contents is enough for a URL, allow a relative URL to
+ * replace it.
+ */
+ CURLUcode result;
+ char *oldurl;
+ char *redired_url;
+ CURLU *handle2;
+
+ if(Curl_is_absolute_url(part, NULL, MAX_SCHEME_LEN + 1)) {
+ handle2 = curl_url();
+ if(!handle2)
+ return CURLUE_OUT_OF_MEMORY;
+ result = parseurl(part, handle2, flags);
+ if(!result)
+ mv_urlhandle(handle2, u);
+ else
+ curl_url_cleanup(handle2);
+ return result;
+ }
+ /* extract the full "old" URL to do the redirect on */
+ result = curl_url_get(u, CURLUPART_URL, &oldurl, flags);
+ if(result) {
+ /* couldn't get the old URL, just use the new! */
+ handle2 = curl_url();
+ if(!handle2)
+ return CURLUE_OUT_OF_MEMORY;
+ result = parseurl(part, handle2, flags);
+ if(!result)
+ mv_urlhandle(handle2, u);
+ else
+ curl_url_cleanup(handle2);
+ return result;
+ }
+
+ /* apply the relative part to create a new URL */
+ redired_url = concat_url(oldurl, part);
+ free(oldurl);
+ if(!redired_url)
+ return CURLUE_OUT_OF_MEMORY;
+
+ /* now parse the new URL */
+ handle2 = curl_url();
+ if(!handle2) {
+ free(redired_url);
+ return CURLUE_OUT_OF_MEMORY;
+ }
+ result = parseurl(redired_url, handle2, flags);
+ free(redired_url);
+ if(!result)
+ mv_urlhandle(handle2, u);
+ else
+ curl_url_cleanup(handle2);
+ return result;
+ }
+ default:
+ return CURLUE_UNKNOWN_PART;
+ }
+ if(storep) {
+ const char *newp = part;
+ size_t nalloc = strlen(part);
+
+ if(nalloc > CURL_MAX_INPUT_LENGTH)
+ /* excessive input length */
+ return CURLUE_MALFORMED_INPUT;
+
+ if(urlencode) {
+ const unsigned char *i;
+ char *o;
+ bool free_part = FALSE;
+ char *enc = malloc(nalloc * 3 + 1); /* for worst case! */
+ if(!enc)
+ return CURLUE_OUT_OF_MEMORY;
+ if(plusencode) {
+ /* space to plus */
+ i = (const unsigned char *)part;
+ for(o = enc; *i; ++o, ++i)
+ *o = (*i == ' ') ? '+' : *i;
+ *o = 0; /* zero terminate */
+ part = strdup(enc);
+ if(!part) {
+ free(enc);
+ return CURLUE_OUT_OF_MEMORY;
+ }
+ free_part = TRUE;
+ }
+ for(i = (const unsigned char *)part, o = enc; *i; i++) {
+ if(Curl_isunreserved(*i) ||
+ ((*i == '/') && urlskipslash) ||
+ ((*i == '=') && equalsencode) ||
+ ((*i == '+') && plusencode)) {
+ if((*i == '=') && equalsencode)
+ /* only skip the first equals sign */
+ equalsencode = FALSE;
+ *o = *i;
+ o++;
+ }
+ else {
+ msnprintf(o, 4, "%%%02x", *i);
+ o += 3;
+ }
+ }
+ *o = 0; /* zero terminate */
+ newp = enc;
+ if(free_part)
+ free((char *)part);
+ }
+ else {
+ char *p;
+ newp = strdup(part);
+ if(!newp)
+ return CURLUE_OUT_OF_MEMORY;
+ p = (char *)newp;
+ while(*p) {
+ /* make sure percent encoded are lower case */
+ if((*p == '%') && ISXDIGIT(p[1]) && ISXDIGIT(p[2]) &&
+ (ISUPPER(p[1]) || ISUPPER(p[2]))) {
+ p[1] = (char)TOLOWER(p[1]);
+ p[2] = (char)TOLOWER(p[2]);
+ p += 3;
+ }
+ else
+ p++;
+ }
+ }
+
+ if(appendquery) {
+ /* Append the string onto the old query. Add a '&' separator if none is
+ present at the end of the exsting query already */
+ size_t querylen = u->query ? strlen(u->query) : 0;
+ bool addamperand = querylen && (u->query[querylen -1] != '&');
+ if(querylen) {
+ size_t newplen = strlen(newp);
+ char *p = malloc(querylen + addamperand + newplen + 1);
+ if(!p) {
+ free((char *)newp);
+ return CURLUE_OUT_OF_MEMORY;
+ }
+ strcpy(p, u->query); /* original query */
+ if(addamperand)
+ p[querylen] = '&'; /* ampersand */
+ strcpy(&p[querylen + addamperand], newp); /* new suffix */
+ free((char *)newp);
+ free(*storep);
+ *storep = p;
+ return CURLUE_OK;
+ }
+ }
+
+ if(what == CURLUPART_HOST) {
+ if(hostname_check(u, (char *)newp)) {
+ free((char *)newp);
+ return CURLUE_MALFORMED_INPUT;
+ }
+ }
+
+ free(*storep);
+ *storep = (char *)newp;
+ }
+ /* set after the string, to make it not assigned if the allocation above
+ fails */
+ if(port)
+ u->portnum = port;
+ return CURLUE_OK;
+}
diff --git a/Utilities/cmcurl/lib/urldata.h b/Utilities/cmcurl/lib/urldata.h
index d4a4a98dc..d759592d9 100644
--- a/Utilities/cmcurl/lib/urldata.h
+++ b/Utilities/cmcurl/lib/urldata.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -77,94 +77,25 @@
/* Default FTP/IMAP etc response timeout in milliseconds.
Symbian OS panics when given a timeout much greater than 1/2 hour.
*/
-#define RESP_TIMEOUT (1800*1000)
+#define RESP_TIMEOUT (120*1000)
+
+/* Max string intput length is a precaution against abuse and to detect junk
+ input easier and better. */
+#define CURL_MAX_INPUT_LENGTH 8000000
#include "cookie.h"
+#include "psl.h"
#include "formdata.h"
-#ifdef USE_OPENSSL
-#include <openssl/ssl.h>
-#ifdef HAVE_OPENSSL_ENGINE_H
-#include <openssl/engine.h>
-#endif
-#endif /* USE_OPENSSL */
-
-#ifdef USE_GNUTLS
-#include <gnutls/gnutls.h>
-#endif
-
-#ifdef USE_MBEDTLS
-
-#include <mbedtls/ssl.h>
-#include <mbedtls/version.h>
-#include <mbedtls/entropy.h>
-#include <mbedtls/ctr_drbg.h>
-
-#elif defined USE_POLARSSL
-
-#include <polarssl/ssl.h>
-#include <polarssl/version.h>
-#if POLARSSL_VERSION_NUMBER<0x01010000
-#include <polarssl/havege.h>
-#else
-#include <polarssl/entropy.h>
-#include <polarssl/ctr_drbg.h>
-#endif /* POLARSSL_VERSION_NUMBER<0x01010000 */
-
-#endif /* USE_POLARSSL */
-
-#ifdef USE_CYASSL
-#undef OCSP_REQUEST /* avoid cyassl/openssl/ssl.h clash with wincrypt.h */
-#undef OCSP_RESPONSE /* avoid cyassl/openssl/ssl.h clash with wincrypt.h */
-#include <cyassl/openssl/ssl.h>
-#endif
-
-#ifdef USE_NSS
-#include <nspr.h>
-#include <pk11pub.h>
-#endif
-
-#ifdef USE_GSKIT
-#include <gskssl.h>
-#endif
-
-#ifdef USE_AXTLS
-#include <axTLS/config.h>
-#include <axTLS/ssl.h>
-#undef malloc
-#undef calloc
-#undef realloc
-#endif /* USE_AXTLS */
-
-#if defined(USE_SCHANNEL) || defined(USE_WINDOWS_SSPI)
-#include "curl_sspi.h"
-#endif
-#ifdef USE_SCHANNEL
-#include <schnlsp.h>
-#include <schannel.h>
-#endif
-
-#ifdef USE_DARWINSSL
-#include <Security/Security.h>
-/* For some reason, when building for iOS, the omnibus header above does
- * not include SecureTransport.h as of iOS SDK 5.1. */
-#include <Security/SecureTransport.h>
-#endif
-
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
+#ifdef HAVE_NETINET_IN6_H
+#include <netinet/in6.h>
+#endif
#include "timeval.h"
-#ifdef HAVE_ZLIB_H
-#include <zlib.h> /* for content-encoding */
-#ifdef __SYMBIAN32__
-/* zlib pollutes the namespace with this definition */
-#undef WIN32
-#endif
-#endif
-
#include <curl/curl.h>
#include "http_chunks.h" /* for the structs and enum stuff */
@@ -172,6 +103,21 @@
#include "hash.h"
#include "splay.h"
+/* return the count of bytes sent, or -1 on error */
+typedef ssize_t (Curl_send)(struct connectdata *conn, /* connection data */
+ int sockindex, /* socketindex */
+ const void *buf, /* data to write */
+ size_t len, /* max amount to write */
+ CURLcode *err); /* error to return */
+
+/* return the count of bytes read, or -1 on error */
+typedef ssize_t (Curl_recv)(struct connectdata *conn, /* connection data */
+ int sockindex, /* socketindex */
+ char *buf, /* store data here */
+ size_t len, /* max amount to read */
+ CURLcode *err); /* error to return */
+
+#include "mime.h"
#include "imap.h"
#include "pop3.h"
#include "smtp.h"
@@ -187,12 +133,14 @@
#ifdef HAVE_GSSAPI
# ifdef HAVE_GSSGNU
# include <gss.h>
-# elif defined HAVE_GSSMIT
+# elif defined HAVE_GSSAPI_GSSAPI_H
# include <gssapi/gssapi.h>
-# include <gssapi/gssapi_generic.h>
# else
# include <gssapi.h>
# endif
+# ifdef HAVE_GSSAPI_GSSAPI_GENERIC_H
+# include <gssapi/gssapi_generic.h>
+# endif
#endif
#ifdef HAVE_LIBSSH2_H
@@ -200,13 +148,6 @@
#include <libssh2_sftp.h>
#endif /* HAVE_LIBSSH2_H */
-/* The upload buffer size, should not be smaller than CURL_MAX_WRITE_SIZE, as
- it needs to hold a full buffer as could be sent in a write callback */
-#define UPLOAD_BUFSIZE CURL_MAX_WRITE_SIZE
-
-/* The "master buffer" is for HTTP pipelining */
-#define MASTERBUF_SIZE 16384
-
/* Initial size of the buffer to store headers in, it'll be enlarged in case
of need. */
#define HEADERSIZE 256
@@ -215,10 +156,8 @@
#define GOOD_EASY_HANDLE(x) \
((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER))
-/* Some convenience macros to get the larger/smaller value out of two given.
- We prefix with CURL to prevent name collisions. */
-#define CURLMAX(x,y) ((x)>(y)?(x):(y))
-#define CURLMIN(x,y) ((x)<(y)?(x):(y))
+/* the type we use for storing a single boolean bit */
+typedef unsigned int bit;
#ifdef HAVE_GSSAPI
/* Types needed for krb5-ftp connections */
@@ -226,7 +165,7 @@ struct krb5buffer {
void *data;
size_t size;
size_t index;
- int eof_flag;
+ bit eof_flag:1;
};
enum protection_level {
@@ -240,20 +179,6 @@ enum protection_level {
};
#endif
-#ifdef USE_SCHANNEL
-/* Structs to store Schannel handles */
-struct curl_schannel_cred {
- CredHandle cred_handle;
- TimeStamp time_stamp;
- int refcount;
-};
-
-struct curl_schannel_ctxt {
- CtxtHandle ctxt_handle;
- TimeStamp time_stamp;
-};
-#endif
-
/* enum for the nonblocking SSL connection state machine */
typedef enum {
ssl_connect_1,
@@ -270,128 +195,59 @@ typedef enum {
ssl_connection_complete
} ssl_connection_state;
+/* SSL backend-specific data; declared differently by each SSL backend */
+struct ssl_backend_data;
+
/* struct for data related to each SSL connection */
struct ssl_connect_data {
/* Use ssl encrypted communications TRUE/FALSE, not necessarily using it atm
but at least asked to or meaning to use it. See 'state' for the exact
current state of the connection. */
- bool use;
ssl_connection_state state;
ssl_connect_state connecting_state;
-#if defined(USE_OPENSSL)
- /* these ones requires specific SSL-types */
- SSL_CTX* ctx;
- SSL* handle;
- X509* server_cert;
-#elif defined(USE_GNUTLS)
- gnutls_session_t session;
- gnutls_certificate_credentials_t cred;
-#ifdef USE_TLS_SRP
- gnutls_srp_client_credentials_t srp_client_cred;
-#endif
-#elif defined(USE_MBEDTLS)
- mbedtls_ctr_drbg_context ctr_drbg;
- mbedtls_entropy_context entropy;
- mbedtls_ssl_context ssl;
- int server_fd;
- mbedtls_x509_crt cacert;
- mbedtls_x509_crt clicert;
- mbedtls_x509_crl crl;
- mbedtls_pk_context pk;
- mbedtls_ssl_config config;
- const char *protocols[3];
-#elif defined(USE_POLARSSL)
- ctr_drbg_context ctr_drbg;
- entropy_context entropy;
- ssl_context ssl;
- int server_fd;
- x509_crt cacert;
- x509_crt clicert;
- x509_crl crl;
- rsa_context rsa;
-#elif defined(USE_CYASSL)
- SSL_CTX* ctx;
- SSL* handle;
-#elif defined(USE_NSS)
- PRFileDesc *handle;
- char *client_nickname;
- struct Curl_easy *data;
- struct curl_llist obj_list;
- PK11GenericObject *obj_clicert;
-#elif defined(USE_GSKIT)
- gsk_handle handle;
- int iocport;
- int localfd;
- int remotefd;
-#elif defined(USE_AXTLS)
- SSL_CTX* ssl_ctx;
- SSL* ssl;
-#elif defined(USE_SCHANNEL)
- struct curl_schannel_cred *cred;
- struct curl_schannel_ctxt *ctxt;
- SecPkgContext_StreamSizes stream_sizes;
- size_t encdata_length, decdata_length;
- size_t encdata_offset, decdata_offset;
- unsigned char *encdata_buffer, *decdata_buffer;
- /* encdata_is_incomplete: if encdata contains only a partial record that
- can't be decrypted without another Curl_read_plain (that is, status is
- SEC_E_INCOMPLETE_MESSAGE) then set this true. after Curl_read_plain writes
- more bytes into encdata then set this back to false. */
- bool encdata_is_incomplete;
- unsigned long req_flags, ret_flags;
- CURLcode recv_unrecoverable_err; /* schannel_recv had an unrecoverable err */
- bool recv_sspi_close_notify; /* true if connection closed by close_notify */
- bool recv_connection_closed; /* true if connection closed, regardless how */
- bool use_alpn; /* true if ALPN is used for this connection */
-#elif defined(USE_DARWINSSL)
- SSLContextRef ssl_ctx;
- curl_socket_t ssl_sockfd;
- bool ssl_direction; /* true if writing, false if reading */
- size_t ssl_write_buffered_length;
-#elif defined(USE_SSL)
-#error "SSL backend specific information missing from ssl_connect_data"
+#if defined(USE_SSL)
+ struct ssl_backend_data *backend;
#endif
+ bit use:1;
};
struct ssl_primary_config {
long version; /* what version the client wants to use */
long version_max; /* max supported version the client wants to use*/
- bool verifypeer; /* set TRUE if this is desired */
- bool verifyhost; /* set TRUE if CN/SAN must match hostname */
- bool verifystatus; /* set TRUE if certificate status must be checked */
char *CApath; /* certificate dir (doesn't work on windows) */
char *CAfile; /* certificate to verify peer against */
char *clientcert;
char *random_file; /* path to file containing "random" data */
char *egdsocket; /* path to file containing the EGD daemon socket */
char *cipher_list; /* list of ciphers to use */
- bool sessionid; /* cache session IDs or not */
+ char *cipher_list13; /* list of TLS 1.3 cipher suites to use */
+ bit verifypeer:1; /* set TRUE if this is desired */
+ bit verifyhost:1; /* set TRUE if CN/SAN must match hostname */
+ bit verifystatus:1; /* set TRUE if certificate status must be checked */
+ bit sessionid:1; /* cache session IDs or not */
};
struct ssl_config_data {
struct ssl_primary_config primary;
- bool enable_beast; /* especially allow this flaw for interoperability's
- sake*/
- bool no_revoke; /* disable SSL certificate revocation checks */
long certverifyresult; /* result from the certificate verification */
char *CRLfile; /* CRL to check certificate revocation */
char *issuercert;/* optional issuer certificate filename */
curl_ssl_ctx_callback fsslctx; /* function to initialize ssl ctx */
void *fsslctxp; /* parameter for call back */
- bool certinfo; /* gather lots of certificate info */
- bool falsestart;
-
char *cert; /* client certificate file name */
char *cert_type; /* format for certificate (default: PEM)*/
char *key; /* private key file name */
char *key_type; /* format for private key (default: PEM) */
char *key_passwd; /* plain text private key password */
-
#ifdef USE_TLS_SRP
char *username; /* TLS username (for, e.g., SRP) */
char *password; /* TLS password (for, e.g., SRP) */
enum CURL_TLSAUTH authtype; /* TLS authentication type (default SRP) */
#endif
+ bit certinfo:1; /* gather lots of certificate info */
+ bit falsestart:1;
+ bit enable_beast:1; /* allow this flaw for interoperability's sake*/
+ bit no_revoke:1; /* disable SSL certificate revocation checks */
};
struct ssl_general_config {
@@ -411,22 +267,31 @@ struct curl_ssl_session {
struct ssl_primary_config ssl_config; /* setup for this session */
};
+#ifdef USE_WINDOWS_SSPI
+#include "curl_sspi.h"
+#endif
+
/* Struct used for Digest challenge-response authentication */
struct digestdata {
#if defined(USE_WINDOWS_SSPI)
BYTE *input_token;
size_t input_token_len;
CtxtHandle *http_context;
+ /* copy of user/passwd used to make the identity for http_context.
+ either may be NULL. */
+ char *user;
+ char *passwd;
#else
char *nonce;
char *cnonce;
char *realm;
int algo;
- bool stale; /* set true for re-negotiation */
char *opaque;
char *qop;
char *algorithm;
int nc; /* nounce count */
+ bit stale:1; /* set true for re-negotiation */
+ bit userhash:1;
#endif
};
@@ -438,9 +303,13 @@ typedef enum {
NTLMSTATE_LAST
} curlntlm;
-#ifdef USE_WINDOWS_SSPI
-#include "curl_sspi.h"
-#endif
+typedef enum {
+ GSS_AUTHNONE,
+ GSS_AUTHRECV,
+ GSS_AUTHSENT,
+ GSS_AUTHDONE,
+ GSS_AUTHSUCC
+} curlnegotiate;
#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
#include <iconv.h>
@@ -467,8 +336,13 @@ struct kerberos5data {
/* Struct used for NTLM challenge-response authentication */
#if defined(USE_NTLM)
struct ntlmdata {
- curlntlm state;
#ifdef USE_WINDOWS_SSPI
+/* The sslContext is used for the Schannel bindings. The
+ * api is available on the Windows 7 SDK and later.
+ */
+#ifdef SECPKG_ATTR_ENDPOINT_BINDINGS
+ CtxtHandle *sslContext;
+#endif
CredHandle *credentials;
CtxtHandle *context;
SEC_WINNT_AUTH_IDENTITY identity;
@@ -477,6 +351,7 @@ struct ntlmdata {
BYTE *output_token;
BYTE *input_token;
size_t input_token_len;
+ TCHAR *spn;
#else
unsigned int flags;
unsigned char nonce[8];
@@ -486,11 +361,9 @@ struct ntlmdata {
};
#endif
+/* Struct used for Negotiate (SPNEGO) authentication */
#ifdef USE_SPNEGO
struct negotiatedata {
- /* When doing Negotiate (SPNEGO) auth, we first need to send a token
- and then validate the received one. */
- enum { GSS_AUTHNONE, GSS_AUTHRECV, GSS_AUTHSENT } state;
#ifdef HAVE_GSSAPI
OM_uint32 status;
gss_ctx_id_t context;
@@ -498,6 +371,9 @@ struct negotiatedata {
gss_buffer_desc output_token;
#else
#ifdef USE_WINDOWS_SSPI
+#ifdef SECPKG_ATTR_ENDPOINT_BINDINGS
+ CtxtHandle *sslContext;
+#endif
DWORD status;
CredHandle *credentials;
CtxtHandle *context;
@@ -509,6 +385,10 @@ struct negotiatedata {
size_t output_token_length;
#endif
#endif
+ bool noauthpersist;
+ bool havenoauthpersist;
+ bool havenegdata;
+ bool havemultiplerequests;
};
#endif
@@ -518,69 +398,67 @@ struct negotiatedata {
*/
struct ConnectBits {
/* always modify bits.close with the connclose() and connkeep() macros! */
- bool close; /* if set, we close the connection after this request */
- bool reuse; /* if set, this is a re-used connection */
- bool conn_to_host; /* if set, this connection has a "connect to host"
- that overrides the host in the URL */
- bool conn_to_port; /* if set, this connection has a "connect to port"
- that overrides the port in the URL (remote port) */
- bool proxy; /* if set, this transfer is done through a proxy - any type */
- bool httpproxy; /* if set, this transfer is done through a http proxy */
- bool socksproxy; /* if set, this transfer is done through a socks proxy */
- bool user_passwd; /* do we use user+password for this connection? */
- bool proxy_user_passwd; /* user+password for the proxy? */
- bool ipv6_ip; /* we communicate with a remote site specified with pure IPv6
- IP address */
- bool ipv6; /* we communicate with a site using an IPv6 address */
-
- bool do_more; /* this is set TRUE if the ->curl_do_more() function is
- supposed to be called, after ->curl_do() */
- bool tcpconnect[2]; /* the TCP layer (or similar) is connected, this is set
- the first time on the first connect function call */
- bool protoconnstart;/* the protocol layer has STARTED its operation after
- the TCP layer connect */
-
- bool retry; /* this connection is about to get closed and then
- re-attempted at another connection. */
- bool tunnel_proxy; /* if CONNECT is used to "tunnel" through the proxy.
- This is implicit when SSL-protocols are used through
- proxies, but can also be enabled explicitly by
- apps */
- bool authneg; /* TRUE when the auth phase has started, which means
- that we are creating a request with an auth header,
- but it is not the final request in the auth
- negotiation. */
- bool rewindaftersend;/* TRUE when the sending couldn't be stopped even
- though it will be discarded. When the whole send
- operation is done, we must call the data rewind
- callback. */
- bool ftp_use_epsv; /* As set with CURLOPT_FTP_USE_EPSV, but if we find out
- EPSV doesn't work we disable it for the forthcoming
- requests */
-
- bool ftp_use_eprt; /* As set with CURLOPT_FTP_USE_EPRT, but if we find out
- EPRT doesn't work we disable it for the forthcoming
- requests */
- bool ftp_use_data_ssl; /* Enabled SSL for the data connection */
- bool netrc; /* name+password provided by netrc */
- bool userpwd_in_url; /* name+password found in url */
- bool stream_was_rewound; /* Indicates that the stream was rewound after a
- request read past the end of its response byte
- boundary */
- bool proxy_connect_closed; /* set true if a proxy disconnected the
- connection in a CONNECT request with auth, so
- that libcurl should reconnect and continue. */
- bool bound; /* set true if bind() has already been done on this socket/
- connection */
- bool type_set; /* type= was used in the URL */
- bool multiplex; /* connection is multiplexed */
-
- bool tcp_fastopen; /* use TCP Fast Open */
- bool tls_enable_npn; /* TLS NPN extension? */
- bool tls_enable_alpn; /* TLS ALPN extension? */
bool proxy_ssl_connected[2]; /* TRUE when SSL initialization for HTTPS proxy
is complete */
- bool socksproxy_connecting; /* connecting through a socks proxy */
+ bool tcpconnect[2]; /* the TCP layer (or similar) is connected, this is set
+ the first time on the first connect function call */
+ bit close:1; /* if set, we close the connection after this request */
+ bit reuse:1; /* if set, this is a re-used connection */
+ bit conn_to_host:1; /* if set, this connection has a "connect to host"
+ that overrides the host in the URL */
+ bit conn_to_port:1; /* if set, this connection has a "connect to port"
+ that overrides the port in the URL (remote port) */
+ bit proxy:1; /* if set, this transfer is done through a proxy - any type */
+ bit httpproxy:1; /* if set, this transfer is done through a http proxy */
+ bit socksproxy:1; /* if set, this transfer is done through a socks proxy */
+ bit user_passwd:1; /* do we use user+password for this connection? */
+ bit proxy_user_passwd:1; /* user+password for the proxy? */
+ bit ipv6_ip:1; /* we communicate with a remote site specified with pure IPv6
+ IP address */
+ bit ipv6:1; /* we communicate with a site using an IPv6 address */
+ bit do_more:1; /* this is set TRUE if the ->curl_do_more() function is
+ supposed to be called, after ->curl_do() */
+ bit protoconnstart:1;/* the protocol layer has STARTED its operation after
+ the TCP layer connect */
+ bit retry:1; /* this connection is about to get closed and then
+ re-attempted at another connection. */
+ bit tunnel_proxy:1; /* if CONNECT is used to "tunnel" through the proxy.
+ This is implicit when SSL-protocols are used through
+ proxies, but can also be enabled explicitly by
+ apps */
+ bit authneg:1; /* TRUE when the auth phase has started, which means
+ that we are creating a request with an auth header,
+ but it is not the final request in the auth
+ negotiation. */
+ bit rewindaftersend:1;/* TRUE when the sending couldn't be stopped even
+ though it will be discarded. When the whole send
+ operation is done, we must call the data rewind
+ callback. */
+#ifndef CURL_DISABLE_FTP
+ bit ftp_use_epsv:1; /* As set with CURLOPT_FTP_USE_EPSV, but if we find out
+ EPSV doesn't work we disable it for the forthcoming
+ requests */
+ bit ftp_use_eprt:1; /* As set with CURLOPT_FTP_USE_EPRT, but if we find out
+ EPRT doesn't work we disable it for the forthcoming
+ requests */
+ bit ftp_use_data_ssl:1; /* Enabled SSL for the data connection */
+#endif
+ bit netrc:1; /* name+password provided by netrc */
+ bit userpwd_in_url:1; /* name+password found in url */
+ bit stream_was_rewound:1; /* The stream was rewound after a request read
+ past the end of its response byte boundary */
+ bit proxy_connect_closed:1; /* TRUE if a proxy disconnected the connection
+ in a CONNECT request with auth, so that
+ libcurl should reconnect and continue. */
+ bit bound:1; /* set true if bind() has already been done on this socket/
+ connection */
+ bit type_set:1; /* type= was used in the URL */
+ bit multiplex:1; /* connection is multiplexed */
+ bit tcp_fastopen:1; /* use TCP Fast Open */
+ bit tls_enable_npn:1; /* TLS NPN extension? */
+ bit tls_enable_alpn:1; /* TLS ALPN extension? */
+ bit socksproxy_connecting:1; /* connecting through a socks proxy */
+ bit connect_only:1;
};
struct hostname {
@@ -607,27 +485,14 @@ struct hostname {
#define KEEP_RECVBITS (KEEP_RECV | KEEP_RECV_HOLD | KEEP_RECV_PAUSE)
#define KEEP_SENDBITS (KEEP_SEND | KEEP_SEND_HOLD | KEEP_SEND_PAUSE)
-
-#ifdef HAVE_LIBZ
-typedef enum {
- ZLIB_UNINIT, /* uninitialized */
- ZLIB_INIT, /* initialized */
- ZLIB_GZIP_HEADER, /* reading gzip header */
- ZLIB_GZIP_INFLATING, /* inflating gzip stream */
- ZLIB_INIT_GZIP /* initialized in transparent gzip mode */
-} zlibInitState;
-#endif
-
-#ifdef CURLRES_ASYNCH
struct Curl_async {
char *hostname;
int port;
struct Curl_dns_entry *dns;
- bool done; /* set TRUE when the lookup is complete */
int status; /* if done is TRUE, this is the status from the callback */
void *os_specific; /* 'struct thread_data' for Windows */
+ bit done:1; /* set TRUE when the lookup is complete */
};
-#endif
#define FIRSTSOCKET 0
#define SECONDARYSOCKET 1
@@ -653,6 +518,28 @@ enum upgrade101 {
UPGR101_WORKING /* talking upgraded protocol */
};
+struct dohresponse {
+ unsigned char *memory;
+ size_t size;
+};
+
+/* one of these for each DoH request */
+struct dnsprobe {
+ CURL *easy;
+ int dnstype;
+ unsigned char dohbuffer[512];
+ size_t dohlen;
+ struct dohresponse serverdoh;
+};
+
+struct dohdata {
+ struct curl_slist *headers;
+ struct dnsprobe probe[2];
+ unsigned int pending; /* still outstanding requests */
+ const char *host;
+ int port;
+};
+
/*
* Request specific data in the easy handle (Curl_easy). Previously,
* these members were on the connectdata struct but since a conn struct may
@@ -662,25 +549,21 @@ enum upgrade101 {
*/
struct SingleRequest {
curl_off_t size; /* -1 if unknown at this point */
- curl_off_t *bytecountp; /* return number of bytes read or NULL */
-
curl_off_t maxdownload; /* in bytes, the maximum amount of data to fetch,
-1 means unlimited */
- curl_off_t *writebytecountp; /* return number of bytes written or NULL */
-
curl_off_t bytecount; /* total number of bytes read */
curl_off_t writebytecount; /* number of bytes written */
- long headerbytecount; /* only count received headers */
- long deductheadercount; /* this amount of bytes doesn't count when we check
- if anything has been transferred at the end of a
- connection. We use this counter to make only a
- 100 reply (without a following second response
- code) result in a CURLE_GOT_NOTHING error code */
+ curl_off_t headerbytecount; /* only count received headers */
+ curl_off_t deductheadercount; /* this amount of bytes doesn't count when we
+ check if anything has been transferred at
+ the end of a connection. We use this
+ counter to make only a 100 reply (without a
+ following second response code) result in a
+ CURLE_GOT_NOTHING error code */
- struct timeval start; /* transfer started at this time */
- struct timeval now; /* current time */
- bool header; /* incoming data has HTTP header */
+ struct curltime start; /* transfer started at this time */
+ struct curltime now; /* current time */
enum {
HEADER_NORMAL, /* no bad header at all */
HEADER_PARTHEADER, /* part of the chunk is a bad header, the rest
@@ -696,42 +579,20 @@ struct SingleRequest {
char *str_start; /* within buf */
char *end_ptr; /* within buf */
char *p; /* within headerbuff */
- bool content_range; /* set TRUE if Content-Range: was found */
curl_off_t offset; /* possible resume offset read from the
Content-Range: header */
int httpcode; /* error code from the 'HTTP/1.? XXX' or
'RTSP/1.? XXX' line */
- struct timeval start100; /* time stamp to wait for the 100 code from */
+ struct curltime start100; /* time stamp to wait for the 100 code from */
enum expect100 exp100; /* expect 100 continue state */
enum upgrade101 upgr101; /* 101 upgrade state */
- int auto_decoding; /* What content encoding. sec 3.5, RFC2616. */
-
-#define IDENTITY 0 /* No encoding */
-#define DEFLATE 1 /* zlib deflate [RFC 1950 & 1951] */
-#define GZIP 2 /* gzip algorithm [RFC 1952] */
-
-#ifdef HAVE_LIBZ
- zlibInitState zlib_init; /* possible zlib init state;
- undefined if Content-Encoding header. */
- z_stream z; /* State structure for zlib. */
-#endif
-
+ struct contenc_writer_s *writer_stack; /* Content unencoding stack. */
+ /* See sec 3.5, RFC2616. */
time_t timeofdoc;
long bodywrites;
-
char *buf;
- curl_socket_t maxfd;
-
int keepon;
-
- bool upload_done; /* set to TRUE when doing chunked transfer-encoding upload
- and we're uploading the last chunk */
-
- bool ignorebody; /* we read a response-body but we ignore it! */
- bool ignorecl; /* This HTTP response has no body so we ignore the Content-
- Length: header */
-
char *location; /* This points to an allocated version of the Location:
header data */
char *newurl; /* Set to the new URL to use when a redirect or a retry is
@@ -741,23 +602,30 @@ struct SingleRequest {
still left in the buffer, aimed for upload. */
ssize_t upload_present;
- /* 'upload_fromhere' is used as a read-pointer when we uploaded parts of a
- buffer, so the next read should read from where this pointer points to,
- and the 'upload_present' contains the number of bytes available at this
- position */
+ /* 'upload_fromhere' is used as a read-pointer when we uploaded parts of a
+ buffer, so the next read should read from where this pointer points to,
+ and the 'upload_present' contains the number of bytes available at this
+ position */
char *upload_fromhere;
-
- bool chunk; /* if set, this is a chunked transfer-encoding */
- bool upload_chunky; /* set TRUE if we are doing chunked transfer-encoding
- on upload */
- bool getheader; /* TRUE if header parsing is wanted */
-
- bool forbidchunk; /* used only to explicitly forbid chunk-upload for
- specific upload buffers. See readmoredata() in
- http.c for details. */
-
void *protop; /* Allocated protocol-specific data. Each protocol
handler makes sure this points to data it needs. */
+#ifndef CURL_DISABLE_DOH
+ struct dohdata doh; /* DoH specific data for this request */
+#endif
+ bit header:1; /* incoming data has HTTP header */
+ bit content_range:1; /* set TRUE if Content-Range: was found */
+ bit upload_done:1; /* set to TRUE when doing chunked transfer-encoding
+ upload and we're uploading the last chunk */
+ bit ignorebody:1; /* we read a response-body but we ignore it! */
+ bit ignorecl:1; /* This HTTP response has no body so we ignore the
+ Content-Length: header */
+ bit chunk:1; /* if set, this is a chunked transfer-encoding */
+ bit upload_chunky:1; /* set TRUE if we are doing chunked transfer-encoding
+ on upload */
+ bit getheader:1; /* TRUE if header parsing is wanted */
+ bit forbidchunk:1; /* used only to explicitly forbid chunk-upload for
+ specific upload buffers. See readmoredata() in http.c
+ for details. */
};
/*
@@ -788,7 +656,7 @@ struct Curl_handler {
*/
CURLcode (*connect_it)(struct connectdata *, bool *done);
- /* See above. Currently only used for FTP. */
+ /* See above. */
CURLcode (*connecting)(struct connectdata *, bool *done);
CURLcode (*doing)(struct connectdata *, bool *done);
@@ -829,6 +697,12 @@ struct Curl_handler {
CURLcode (*readwrite)(struct Curl_easy *data, struct connectdata *conn,
ssize_t *nread, bool *readmore);
+ /* This function can perform various checks on the connection. See
+ CONNCHECK_* for more information about the checks that can be performed,
+ and CONNRESULT_* for the results that can be returned. */
+ unsigned int (*connection_check)(struct connectdata *conn,
+ unsigned int checks_to_perform);
+
long defport; /* Default port. */
unsigned int protocol; /* See CURLPROTO_* - this needs to be the single
specific protocol bit */
@@ -855,20 +729,17 @@ struct Curl_handler {
#define PROTOPT_STREAM (1<<9) /* a protocol with individual logical streams */
#define PROTOPT_URLOPTIONS (1<<10) /* allow options part in the userinfo field
of the URL */
+#define PROTOPT_PROXY_AS_HTTP (1<<11) /* allow this non-HTTP scheme over a
+ HTTP proxy as HTTP proxies may know
+ this protocol and act as a gateway */
+#define PROTOPT_WILDCARD (1<<12) /* protocol supports wildcard matching */
-/* return the count of bytes sent, or -1 on error */
-typedef ssize_t (Curl_send)(struct connectdata *conn, /* connection data */
- int sockindex, /* socketindex */
- const void *buf, /* data to write */
- size_t len, /* max amount to write */
- CURLcode *err); /* error to return */
+#define CONNCHECK_NONE 0 /* No checks */
+#define CONNCHECK_ISDEAD (1<<0) /* Check if the connection is dead. */
+#define CONNCHECK_KEEPALIVE (1<<1) /* Perform any keepalive function. */
-/* return the count of bytes read, or -1 on error */
-typedef ssize_t (Curl_recv)(struct connectdata *conn, /* connection data */
- int sockindex, /* socketindex */
- char *buf, /* store data here */
- size_t len, /* max amount to read */
- CURLcode *err); /* error to return */
+#define CONNRESULT_NONE 0 /* No extra information. */
+#define CONNRESULT_DEAD (1<<0) /* The connection is dead. */
#ifdef USE_RECV_BEFORE_SEND_WORKAROUND
struct postponed_data {
@@ -892,6 +763,25 @@ struct proxy_info {
char *passwd; /* proxy password string, allocated */
};
+#define CONNECT_BUFFER_SIZE 16384
+
+/* struct for HTTP CONNECT state data */
+struct http_connect_state {
+ char connect_buffer[CONNECT_BUFFER_SIZE];
+ int perline; /* count bytes per line */
+ int keepon;
+ char *line_start;
+ char *ptr; /* where to store more data */
+ curl_off_t cl; /* size of content to read and ignore */
+ enum {
+ TUNNEL_INIT, /* init/default/no tunnel state */
+ TUNNEL_CONNECT, /* CONNECT has been sent off */
+ TUNNEL_COMPLETE /* CONNECT response received completely */
+ } tunnel_state;
+ bit chunked_encoding:1;
+ bit close_connection:1;
+};
+
/*
* The connectdata struct contains all fields and variables that should be
* unique for an entire connection.
@@ -912,10 +802,11 @@ struct connectdata {
curl_closesocket_callback fclosesocket; /* function closing the socket(s) */
void *closesocket_client;
- bool inuse; /* This is a marker for the connection cache logic. If this is
- TRUE this handle is being used by an easy handle and cannot
- be used by any other easy handle without careful
- consideration (== only for pipelining). */
+ /* This is used by the connection cache logic. If this returns TRUE, this
+ handle is still used by one or more easy handles and can only used by any
+ other easy handle without careful consideration (== only for
+ multiplexing) and it cannot be used by another multi handle! */
+#define CONN_INUSE(c) ((c)->easyq.size)
/**** Fields set when inited and not modified again */
long connection_id; /* Contains a unique number to make it easier to
@@ -943,6 +834,7 @@ struct connectdata {
int socktype; /* SOCK_STREAM or SOCK_DGRAM */
struct hostname host;
+ char *hostname_resolve; /* host name to resolve to address, allocated */
char *secondaryhostname; /* secondary socket host name (ftp) */
struct hostname conn_to_host; /* the host to connect to. valid only if
bits.conn_to_host is set */
@@ -983,8 +875,9 @@ struct connectdata {
int httpversion; /* the HTTP version*10 reported by the server */
int rtspversion; /* the RTSP version*10 reported by the server */
- struct timeval now; /* "current" time */
- struct timeval created; /* creation time */
+ struct curltime now; /* "current" time */
+ struct curltime created; /* creation time */
+ struct curltime lastused; /* when returned to the connection cache */
curl_socket_t sock[2]; /* two sockets, the second is used for the data
transfer when doing FTP */
curl_socket_t tempsock[2]; /* temporary sockets for happy eyeballs */
@@ -998,16 +891,17 @@ struct connectdata {
#endif /* USE_RECV_BEFORE_SEND_WORKAROUND */
struct ssl_connect_data ssl[2]; /* this is for ssl-stuff */
struct ssl_connect_data proxy_ssl[2]; /* this is for proxy ssl-stuff */
+#ifdef USE_SSL
+ void *ssl_extra; /* separately allocated backend-specific data */
+#endif
struct ssl_primary_config ssl_config;
struct ssl_primary_config proxy_ssl_config;
- bool tls_upgraded;
-
struct ConnectBits bits; /* various state-flags for this connection */
/* connecttime: when connect() is called on the current IP address. Used to
be able to track when to move on to try next IP - but only when the multi
interface is used. */
- struct timeval connecttime;
+ struct curltime connecttime;
/* The two fields below get set in Curl_connecthost */
int num_addr; /* number of addresses to try to connect to */
time_t timeoutms_per_addr; /* how long time in milliseconds to spend on
@@ -1018,6 +912,13 @@ struct connectdata {
long ip_version; /* copied from the Curl_easy at creation time */
+ /* Protocols can use a custom keepalive mechanism to keep connections alive.
+ This allows those protocols to track the last time the keepalive mechanism
+ was used on this connection. */
+ struct curltime keepalive;
+
+ long upkeep_interval_ms; /* Time between calls for connection upkeep. */
+
/**** curl_get() phase fields */
curl_socket_t sockfd; /* socket to read from or CURL_SOCKET_BAD */
@@ -1025,7 +926,7 @@ struct connectdata {
well be the same we read from.
CURL_SOCKET_BAD disables */
- /** Dynamicly allocated strings, MUST be freed before this **/
+ /** Dynamically allocated strings, MUST be freed before this **/
/** struct is killed. **/
struct dynamically_allocated_data {
char *proxyuserpwd;
@@ -1041,7 +942,7 @@ struct connectdata {
} allocptr;
#ifdef HAVE_GSSAPI
- int sec_complete; /* if Kerberos is enabled for this connection */
+ bit sec_complete:1; /* if Kerberos is enabled for this connection */
enum protection_level command_prot;
enum protection_level data_prot;
enum protection_level request_data_prot;
@@ -1056,30 +957,19 @@ struct connectdata {
struct kerberos5data krb5; /* variables into the structure definition, */
#endif /* however, some of them are ftp specific. */
- /* the two following *_inuse fields are only flags, not counters in any way.
- If TRUE it means the channel is in use, and if FALSE it means the channel
- is up for grabs by one. */
-
- bool readchannel_inuse; /* whether the read channel is in use by an easy
- handle */
- bool writechannel_inuse; /* whether the write channel is in use by an easy
- handle */
- struct curl_llist send_pipe; /* List of handles waiting to send on this
- pipeline */
- struct curl_llist recv_pipe; /* List of handles waiting to read their
- responses on this pipeline */
- char *master_buffer; /* The master buffer allocated on-demand;
- used for pipelining. */
- size_t read_pos; /* Current read position in the master buffer */
- size_t buf_len; /* Length of the buffer?? */
-
-
+ struct curl_llist easyq; /* List of easy handles using this connection */
curl_seek_callback seek_func; /* function that seeks the input */
void *seek_client; /* pointer to pass to the seek() above */
/*************** Request - specific items ************/
+#if defined(USE_WINDOWS_SSPI) && defined(SECPKG_ATTR_ENDPOINT_BINDINGS)
+ CtxtHandle *sslContext;
+#endif
#if defined(USE_NTLM)
+ curlntlm http_ntlm_state;
+ curlntlm proxy_ntlm_state;
+
struct ntlmdata ntlm; /* NTLM differs from other authentication schemes
because it authenticates connections, not
single requests! */
@@ -1094,12 +984,16 @@ struct connectdata {
#endif
#endif
- char syserr_buf [256]; /* buffer for Curl_strerror() */
+#ifdef USE_SPNEGO
+ curlnegotiate http_negotiate_state;
+ curlnegotiate proxy_negotiate_state;
+
+ struct negotiatedata negotiate; /* state data for host Negotiate auth */
+ struct negotiatedata proxyneg; /* state data for proxy Negotiate auth */
+#endif
-#ifdef CURLRES_ASYNCH
/* data used for the asynch name resolve callback */
struct Curl_async async;
-#endif
/* These three are used for chunked-encoding trailer support */
char *trailer; /* allocated buffer to store trailer in */
@@ -1134,22 +1028,22 @@ struct connectdata {
char *localdev;
unsigned short localport;
int localportrange;
-
- /* tunnel as in tunnel through a HTTP proxy with CONNECT */
- enum {
- TUNNEL_INIT, /* init/default/no tunnel state */
- TUNNEL_CONNECT, /* CONNECT has been sent off */
- TUNNEL_COMPLETE /* CONNECT response received completely */
- } tunnel_state[2]; /* two separate ones to allow FTP */
+ struct http_connect_state *connect_state; /* for HTTP CONNECT */
struct connectbundle *bundle; /* The bundle we are member of */
-
int negnpn; /* APLN or NPN TLS negotiated protocol, CURL_HTTP_VERSION* */
- char *connect_buffer; /* for CONNECT business */
#ifdef USE_UNIX_SOCKETS
char *unix_domain_socket;
- bool abstract_unix_socket;
+ bit abstract_unix_socket:1;
#endif
+ bit tls_upgraded:1;
+ /* the two following *_inuse fields are only flags, not counters in any way.
+ If TRUE it means the channel is in use, and if FALSE it means the channel
+ is up for grabs by one. */
+ bit readchannel_inuse:1; /* whether the read channel is in use by an easy
+ handle */
+ bit writechannel_inuse:1; /* whether the write channel is in use by an easy
+ handle */
};
/* The end of connectdata. */
@@ -1162,14 +1056,10 @@ struct PureInfo {
int httpcode; /* Recent HTTP, FTP, RTSP or SMTP response code */
int httpproxycode; /* response code from proxy when received separate */
int httpversion; /* the http version number X.Y = X*10+Y */
- long filetime; /* If requested, this is might get set. Set to -1 if the time
- was unretrievable. We cannot have this of type time_t,
- since time_t is unsigned on several platforms such as
- OpenVMS. */
- bool timecond; /* set to TRUE if the time condition didn't match, which
- thus made the document NOT get fetched */
- long header_size; /* size of read header(s) in bytes */
- long request_size; /* the amount of bytes sent in the request(s) */
+ time_t filetime; /* If requested, this is might get set. Set to -1 if the
+ time was unretrievable. */
+ curl_off_t header_size; /* size of read header(s) in bytes */
+ curl_off_t request_size; /* the amount of bytes sent in the request(s) */
unsigned long proxyauthavail; /* what proxy auth types were announced */
unsigned long httpauthavail; /* what host auth types were announced */
long numconnects; /* how many new connection did libcurl created */
@@ -1186,16 +1076,16 @@ struct PureInfo {
char conn_primary_ip[MAX_IPADR_LEN];
long conn_primary_port;
-
char conn_local_ip[MAX_IPADR_LEN];
long conn_local_port;
-
const char *conn_scheme;
unsigned int conn_protocol;
-
struct curl_certinfo certs; /* info about the certs, only populated in
OpenSSL builds. Asked for with
CURLOPT_CERTINFO / CURLINFO_CERTINFO */
+
+ bit timecond:1; /* set to TRUE if the time condition didn't match, which
+ thus made the document NOT get fetched */
};
@@ -1209,39 +1099,41 @@ struct Progress {
curl_off_t current_speed; /* uses the currently fastest transfer */
- bool callback; /* set when progress callback is used */
int width; /* screen width at download start */
int flags; /* see progress.h */
- double timespent;
+ time_t timespent;
curl_off_t dlspeed;
curl_off_t ulspeed;
- double t_nslookup;
- double t_connect;
- double t_appconnect;
- double t_pretransfer;
- double t_starttransfer;
- double t_redirect;
+ time_t t_nslookup;
+ time_t t_connect;
+ time_t t_appconnect;
+ time_t t_pretransfer;
+ time_t t_starttransfer;
+ time_t t_redirect;
+
+ struct curltime start;
+ struct curltime t_startsingle;
+ struct curltime t_startop;
+ struct curltime t_acceptdata;
- struct timeval start;
- struct timeval t_startsingle;
- struct timeval t_startop;
- struct timeval t_acceptdata;
/* upload speed limit */
- struct timeval ul_limit_start;
+ struct curltime ul_limit_start;
curl_off_t ul_limit_size;
/* download speed limit */
- struct timeval dl_limit_start;
+ struct curltime dl_limit_start;
curl_off_t dl_limit_size;
-#define CURR_TIME (5+1) /* 6 entries for 5 seconds */
+#define CURR_TIME (5 + 1) /* 6 entries for 5 seconds */
curl_off_t speeder[ CURR_TIME ];
- struct timeval speeder_time[ CURR_TIME ];
+ struct curltime speeder_time[ CURR_TIME ];
int speeder_c;
+ bit callback:1; /* set when progress callback is used */
+ bit is_t_startransfer_set:1;
};
typedef enum {
@@ -1249,9 +1141,10 @@ typedef enum {
HTTPREQ_GET,
HTTPREQ_POST,
HTTPREQ_POST_FORM, /* we make a difference internally */
+ HTTPREQ_POST_MIME, /* we make a difference internally */
HTTPREQ_PUT,
HTTPREQ_HEAD,
- HTTPREQ_CUSTOM,
+ HTTPREQ_OPTIONS,
HTTPREQ_LAST /* last in list */
} Curl_HttpReq;
@@ -1288,12 +1181,12 @@ struct auth {
unsigned long picked;
unsigned long avail; /* Bitmask for what the server reports to support for
this resource */
- bool done; /* TRUE when the auth phase is done and ready to do the *actual*
- request */
- bool multipass; /* TRUE if this is not yet authenticated but within the
- auth multipass negotiation */
- bool iestyle; /* TRUE if digest should be done IE-style or FALSE if it should
- be RFC compliant */
+ bit done:1; /* TRUE when the auth phase is done and ready to do the
+ *actual* request */
+ bit multipass:1; /* TRUE if this is not yet authenticated but within the
+ auth multipass negotiation */
+ bit iestyle:1; /* TRUE if digest should be done IE-style or FALSE if it
+ should be RFC compliant */
};
struct Curl_http2_dep {
@@ -1302,7 +1195,7 @@ struct Curl_http2_dep {
};
/*
- * This struct is for holding data that was attemped to get sent to the user's
+ * This struct is for holding data that was attempted to get sent to the user's
* callback but is held due to pausing. One instance per type (BOTH, HEADER,
* BODY).
*/
@@ -1320,6 +1213,7 @@ typedef enum {
EXPIRE_ASYNC_NAME,
EXPIRE_CONNECTTIMEOUT,
EXPIRE_DNS_PER_NAME,
+ EXPIRE_HAPPY_EYEBALLS_DNS, /* See asyn-ares.c */
EXPIRE_HAPPY_EYEBALLS,
EXPIRE_MULTI_PENDING,
EXPIRE_RUN_NOW,
@@ -1329,27 +1223,43 @@ typedef enum {
EXPIRE_LAST /* not an actual timer, used as a marker only */
} expire_id;
+
+typedef enum {
+ TRAILERS_NONE,
+ TRAILERS_INITIALIZED,
+ TRAILERS_SENDING,
+ TRAILERS_DONE
+} trailers_state;
+
+
/*
* One instance for each timeout an easy handle can set.
*/
struct time_node {
struct curl_llist_element list;
- struct timeval time;
+ struct curltime time;
expire_id eid;
};
+/* individual pieces of the URL */
+struct urlpieces {
+ char *scheme;
+ char *hostname;
+ char *port;
+ char *user;
+ char *password;
+ char *options;
+ char *path;
+ char *query;
+};
+
struct UrlState {
/* Points to the connection cache */
struct conncache *conn_cache;
- /* when curl_easy_perform() is called, the multi handle is "owned" by
- the easy handle so curl_easy_cleanup() on such an easy handle will
- also close the multi handle! */
- bool multi_owned_by_easy;
-
/* buffers to store authentication data in, as parsed from input options */
- struct timeval keeps_speed; /* for the progress meter really */
+ struct curltime keeps_speed; /* for the progress meter really */
struct connectdata *lastconnect; /* The last connection, NULL if undefined */
@@ -1357,11 +1267,9 @@ struct UrlState {
size_t headersize; /* size of the allocation */
char *buffer; /* download buffer */
- char uploadbuffer[UPLOAD_BUFSIZE+1]; /* upload buffer */
+ char *ulbuf; /* allocated upload buffer or NULL */
curl_off_t current_speed; /* the ProgressShow() function sets this,
bytes / second */
- bool this_is_a_follow; /* this is a followed Location: request */
-
char *first_host; /* host name of the first (not followed) request.
if set, this should be the host name that we will
sent authorization to, no else. Used to make Location:
@@ -1374,36 +1282,24 @@ struct UrlState {
unsigned int tempcount; /* number of entries in use in tempwrite, 0 - 3 */
struct tempbuf tempwrite[3]; /* BOTH, HEADER, BODY */
char *scratch; /* huge buffer[set.buffer_size*2] for upload CRLF replacing */
- bool errorbuf; /* Set to TRUE if the error buffer is already filled in.
- This must be set to FALSE every time _easy_perform() is
- called. */
int os_errno; /* filled in with errno whenever an error occurs */
#ifdef HAVE_SIGNAL
/* storage for the previous bag^H^H^HSIGPIPE signal handler :-) */
void (*prev_signal)(int sig);
#endif
- bool allow_port; /* Is set.use_port allowed to take effect or not. This
- is always set TRUE when curl_easy_perform() is called. */
struct digestdata digest; /* state data for host Digest auth */
struct digestdata proxydigest; /* state data for proxy Digest auth */
-#ifdef USE_SPNEGO
- struct negotiatedata negotiate; /* state data for host Negotiate auth */
- struct negotiatedata proxyneg; /* state data for proxy Negotiate auth */
-#endif
-
struct auth authhost; /* auth details for host */
struct auth authproxy; /* auth details for proxy */
-
- bool authproblem; /* TRUE if there's some problem authenticating */
-
void *resolver; /* resolver state, if it is used in the URL state -
ares_channel f.e. */
-#if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H)
- ENGINE *engine;
+#if defined(USE_OPENSSL)
+ /* void instead of ENGINE to avoid bleeding OpenSSL into this header */
+ void *engine;
#endif /* USE_OPENSSL */
- struct timeval expiretime; /* set this with Curl_expire() only */
+ struct curltime expiretime; /* set this with Curl_expire() only */
struct Curl_tree timenode; /* for the splay stuff */
struct curl_llist timeoutlist; /* list of pending timeouts */
struct time_node expires[EXPIRE_LAST]; /* nodes for each expire type */
@@ -1411,33 +1307,18 @@ struct UrlState {
/* a place to store the most recently set FTP entrypath */
char *most_recent_ftp_entrypath;
- /* set after initial USER failure, to prevent an authentication loop */
- bool ftp_trying_alternative;
-
int httpversion; /* the lowest HTTP version*10 reported by any server
involved in this request */
- bool expect100header; /* TRUE if we added Expect: 100-continue */
-
- bool pipe_broke; /* TRUE if the connection we were pipelined on broke
- and we need to restart from the beginning */
#if !defined(WIN32) && !defined(MSDOS) && !defined(__EMX__) && \
!defined(__SYMBIAN32__)
/* do FTP line-end conversions on most platforms */
#define CURL_DO_LINEEND_CONV
/* for FTP downloads: track CRLF sequences that span blocks */
- bool prev_block_had_trailing_cr;
+ bit prev_block_had_trailing_cr:1;
/* for FTP downloads: how many CRLFs did we converted to LFs? */
curl_off_t crlf_conversions;
#endif
- char *pathbuffer;/* allocated buffer to store the URL's path part in */
- char *path; /* path to use, points to somewhere within the pathbuffer
- area */
- bool slash_removed; /* set TRUE if the 'path' points to a path where the
- initial URL slash separator has been taken off */
- bool use_range;
- bool rangestringalloc; /* the range string is malloc()'ed */
-
char *range; /* range, if used. See README for detailed specification on
this syntax. */
curl_off_t resume_from; /* continue [ftp] transfer from here */
@@ -1453,16 +1334,48 @@ struct UrlState {
size_t drain; /* Increased when this stream has data to read, even if its
socket is not necessarily is readable. Decreased when
checked. */
- bool done; /* set to FALSE when Curl_init_do() is called and set to TRUE
- when multi_done() is called, to prevent multi_done() to get
- invoked twice when the multi interface is used. */
curl_read_callback fread_func; /* read callback/function */
void *in; /* CURLOPT_READDATA */
struct Curl_easy *stream_depends_on;
- bool stream_depends_e; /* set or don't set the Exclusive bit */
int stream_weight;
+ CURLU *uh; /* URL handle for the current parsed URL */
+ struct urlpieces up;
+#ifndef CURL_DISABLE_HTTP
+ size_t trailers_bytes_sent;
+ Curl_send_buffer *trailers_buf; /* a buffer containing the compiled trailing
+ headers */
+#endif
+ trailers_state trailers_state; /* whether we are sending trailers
+ and what stage are we at */
+#ifdef CURLDEBUG
+ bit conncache_lock:1;
+#endif
+ /* when curl_easy_perform() is called, the multi handle is "owned" by
+ the easy handle so curl_easy_cleanup() on such an easy handle will
+ also close the multi handle! */
+ bit multi_owned_by_easy:1;
+
+ bit this_is_a_follow:1; /* this is a followed Location: request */
+ bit refused_stream:1; /* this was refused, try again */
+ bit errorbuf:1; /* Set to TRUE if the error buffer is already filled in.
+ This must be set to FALSE every time _easy_perform() is
+ called. */
+ bit allow_port:1; /* Is set.use_port allowed to take effect or not. This
+ is always set TRUE when curl_easy_perform() is called. */
+ bit authproblem:1; /* TRUE if there's some problem authenticating */
+ /* set after initial USER failure, to prevent an authentication loop */
+ bit ftp_trying_alternative:1;
+ bit wildcardmatch:1; /* enable wildcard matching */
+ bit expect100header:1; /* TRUE if we added Expect: 100-continue */
+ bit use_range:1;
+ bit rangestringalloc:1; /* the range string is malloc()'ed */
+ bit done:1; /* set to FALSE when Curl_init_do() is called and set to TRUE
+ when multi_done() is called, to prevent multi_done() to get
+ invoked twice when the multi interface is used. */
+ bit stream_depends_e:1; /* set or don't set the Exclusive bit */
+ bit previouslypending:1; /* this transfer WAS in the multi->pending queue */
};
@@ -1475,13 +1388,15 @@ struct UrlState {
struct DynamicStatic {
char *url; /* work URL, copied from UserDefined */
- bool url_alloc; /* URL string is malloc()'ed */
char *referer; /* referer string */
- bool referer_alloc; /* referer sting is malloc()ed */
struct curl_slist *cookielist; /* list of cookie files set by
curl_easy_setopt(COOKIEFILE) calls */
struct curl_slist *resolve; /* set to point to the set.resolve list when
this should be dealt with in pretransfer */
+ bit url_alloc:1; /* URL string is malloc()'ed */
+ bit referer_alloc:1; /* referer string is malloc()ed */
+ bit wildcard_resolve:1; /* Set to true if any resolve change is a
+ wildcard */
};
/*
@@ -1531,6 +1446,8 @@ enum dupstring {
STRING_SSL_PINNEDPUBLICKEY_PROXY, /* public key file to verify proxy */
STRING_SSL_CIPHER_LIST_ORIG, /* list of ciphers to use */
STRING_SSL_CIPHER_LIST_PROXY, /* list of ciphers to use */
+ STRING_SSL_CIPHER13_LIST_ORIG, /* list of TLS 1.3 ciphers to use */
+ STRING_SSL_CIPHER13_LIST_PROXY, /* list of TLS 1.3 ciphers to use */
STRING_SSL_EGDSOCKET, /* path to file containing the EGD daemon socket */
STRING_SSL_RANDOM_FILE, /* path to file containing "random" data */
STRING_USERAGENT, /* User-Agent string */
@@ -1538,6 +1455,7 @@ enum dupstring {
STRING_SSL_CRLFILE_PROXY, /* crl file to check certificate */
STRING_SSL_ISSUERCERT_ORIG, /* issuer cert file to check certificate */
STRING_SSL_ISSUERCERT_PROXY, /* issuer cert file to check certificate */
+ STRING_SSL_ENGINE, /* name of ssl engine */
STRING_USERNAME, /* <username>, if used */
STRING_PASSWORD, /* <password>, if used */
STRING_OPTIONS, /* <options>, if used */
@@ -1548,19 +1466,14 @@ enum dupstring {
STRING_RTSP_SESSION_ID, /* Session ID to use */
STRING_RTSP_STREAM_URI, /* Stream URI for this request */
STRING_RTSP_TRANSPORT, /* Transport for this session */
-#ifdef USE_LIBSSH2
+#ifdef USE_SSH
STRING_SSH_PRIVATE_KEY, /* path to the private key file for auth */
STRING_SSH_PUBLIC_KEY, /* path to the public key file for auth */
STRING_SSH_HOST_PUBLIC_KEY_MD5, /* md5 of host public key in ascii hex */
STRING_SSH_KNOWNHOSTS, /* file name of knownhosts file */
#endif
-#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
STRING_PROXY_SERVICE_NAME, /* Proxy service name */
-#endif
-#if !defined(CURL_DISABLE_CRYPTO_AUTH) || defined(USE_KERBEROS5) || \
- defined(USE_SPNEGO)
STRING_SERVICE_NAME, /* Service name */
-#endif
STRING_MAIL_FROM,
STRING_MAIL_AUTH,
@@ -1574,19 +1487,27 @@ enum dupstring {
#ifdef USE_UNIX_SOCKETS
STRING_UNIX_SOCKET_PATH, /* path to Unix socket, if used */
#endif
-
+ STRING_TARGET, /* CURLOPT_REQUEST_TARGET */
+ STRING_DOH, /* CURLOPT_DOH_URL */
+#ifdef USE_ALTSVC
+ STRING_ALTSVC, /* CURLOPT_ALTSVC */
+#endif
/* -- end of zero-terminated strings -- */
STRING_LASTZEROTERMINATED,
- /* -- below this are pointers to binary data that cannot be strdup'ed.
- Each such pointer must be added manually to Curl_dupset() --- */
+ /* -- below this are pointers to binary data that cannot be strdup'ed. --- */
STRING_COPYPOSTFIELDS, /* if POST, set the fields' values here */
STRING_LAST /* not used, just an end-of-list marker */
};
+/* callback that gets called when this easy handle is completed within a multi
+ handle. Only used for internally created transfers, like for example
+ DoH. */
+typedef int (*multidone_func)(struct Curl_easy *easy, CURLcode result);
+
struct UserDefined {
FILE *err; /* the stderr user data goes here */
void *debugdata; /* the data that will be passed to fdebug */
@@ -1601,14 +1522,13 @@ struct UserDefined {
long use_port; /* which port to use (when not using default) */
unsigned long httpauth; /* kind of HTTP authentication to use (bitmask) */
unsigned long proxyauth; /* kind of proxy authentication to use (bitmask) */
+ unsigned long socks5auth;/* kind of SOCKS5 authentication to use (bitmask) */
long followlocation; /* as in HTTP Location: */
long maxredirs; /* maximum no. of http(s) redirects to follow, set to -1
for infinity */
int keep_post; /* keep POSTs as POSTs after a 30x request; each
bit represents a request, from 301 to 303 */
- bool free_referer; /* set TRUE if 'referer' points to a string we
- allocated */
void *postfields; /* if POST, set the fields' values here */
curl_seek_callback seek_func; /* function that seeks the input */
curl_off_t postfieldsize; /* if POST, this might have a size to use instead
@@ -1621,8 +1541,6 @@ struct UserDefined {
curl_write_callback fwrite_header; /* function that stores headers */
curl_write_callback fwrite_rtp; /* function that stores interleaved RTP */
curl_read_callback fread_func_set; /* function that reads the input */
- int is_fread_set; /* boolean, has read callback been set to non-NULL? */
- int is_fwrite_set; /* boolean, has write callback been set to non-NULL? */
curl_progress_callback fprogress; /* OLD and deprecated progress callback */
curl_xferinfo_callback fxferinfo; /* progress callback */
curl_debug_callback fdebug; /* function that write informational data */
@@ -1651,9 +1569,11 @@ struct UserDefined {
long timeout; /* in milliseconds, 0 means no timeout */
long connecttimeout; /* in milliseconds, 0 means no timeout */
long accepttimeout; /* in milliseconds, 0 means no timeout */
+ long happy_eyeballs_timeout; /* in milliseconds, 0 is a valid value */
long server_response_timeout; /* in milliseconds, 0 means no timeout */
+ long maxage_conn; /* in seconds, max idle time to allow a connection that
+ is to be reused */
long tftp_blksize; /* in bytes, 0 means use default */
- bool tftp_no_options; /* do not send TFTP options requests */
curl_off_t filesize; /* size of file to upload, -1 means unknown */
long low_speed_limit; /* bytes/second */
long low_speed_time; /* number of seconds */
@@ -1663,10 +1583,8 @@ struct UserDefined {
curl_off_t set_resume_from; /* continue [ftp] transfer from here */
struct curl_slist *headers; /* linked list of extra headers */
struct curl_slist *proxyheaders; /* linked list of extra CONNECT headers */
- struct curl_httppost *httppost; /* linked list of POST data */
- bool sep_headers; /* handle host and proxy headers separately */
- bool cookiesession; /* new cookie session? */
- bool crlf; /* convert crlf on ftp upload(?) */
+ struct curl_httppost *httppost; /* linked list of old POST data */
+ curl_mimepart mimepost; /* MIME/POST data. */
struct curl_slist *quote; /* after connection is established */
struct curl_slist *postquote; /* after the transfer */
struct curl_slist *prequote; /* before the transfer, after type */
@@ -1691,89 +1609,38 @@ struct UserDefined {
curl_proxytype proxytype; /* what kind of proxy that is in use */
long dns_cache_timeout; /* DNS cache timeout */
long buffer_size; /* size of receive buffer to use */
+ size_t upload_buffer_size; /* size of upload buffer to use,
+ keep it >= CURL_MAX_WRITE_SIZE */
void *private_data; /* application-private data */
-
struct curl_slist *http200aliases; /* linked list of aliases for http200 */
-
long ipver; /* the CURL_IPRESOLVE_* defines in the public header file
0 - whatever, 1 - v2, 2 - v6 */
-
curl_off_t max_filesize; /* Maximum file size to download */
-
+#ifndef CURL_DISABLE_FTP
curl_ftpfile ftp_filemethod; /* how to get to a file when FTP is used */
-
+ curl_ftpauth ftpsslauth; /* what AUTH XXX to be attempted */
+ curl_ftpccc ftp_ccc; /* FTP CCC options */
+#endif
int ftp_create_missing_dirs; /* 1 - create directories that don't exist
2 - the same but also allow MKD to fail once
*/
-
curl_sshkeycallback ssh_keyfunc; /* key matching callback */
void *ssh_keyfunc_userp; /* custom pointer to callback */
-
-/* Here follows boolean settings that define how to behave during
- this session. They are STATIC, set by libcurl users or at least initially
- and they don't change during operations. */
-
- bool printhost; /* printing host name in debug info */
- bool get_filetime; /* get the time and get of the remote file */
- bool tunnel_thru_httpproxy; /* use CONNECT through a HTTP proxy */
- bool prefer_ascii; /* ASCII rather than binary */
- bool ftp_append; /* append, not overwrite, on upload */
- bool ftp_list_only; /* switch FTP command for listing directories */
- bool ftp_use_port; /* use the FTP PORT command */
- bool hide_progress; /* don't use the progress meter */
- bool http_fail_on_error; /* fail on HTTP error codes >= 400 */
- bool http_keep_sending_on_error; /* for HTTP status codes >= 300 */
- bool http_follow_location; /* follow HTTP redirects */
- bool http_transfer_encoding; /* request compressed HTTP transfer-encoding */
- bool http_disable_hostname_check_before_authentication;
- bool include_header; /* include received protocol headers in data output */
- bool http_set_referer; /* is a custom referer used */
- bool http_auto_referer; /* set "correct" referer when following location: */
- bool opt_no_body; /* as set with CURLOPT_NOBODY */
- bool upload; /* upload request */
enum CURL_NETRC_OPTION
use_netrc; /* defined in include/curl.h */
- bool verbose; /* output verbosity */
- bool krb; /* Kerberos connection requested */
- bool reuse_forbid; /* forbidden to be reused, close after use */
- bool reuse_fresh; /* do not re-use an existing connection */
- bool ftp_use_epsv; /* if EPSV is to be attempted or not */
- bool ftp_use_eprt; /* if EPRT is to be attempted or not */
- bool ftp_use_pret; /* if PRET is to be used before PASV or not */
-
curl_usessl use_ssl; /* if AUTH TLS is to be attempted etc, for FTP or
IMAP or POP3 or others! */
- curl_ftpauth ftpsslauth; /* what AUTH XXX to be attempted */
- curl_ftpccc ftp_ccc; /* FTP CCC options */
- bool no_signal; /* do not use any signal/alarm handler */
- bool global_dns_cache; /* subject for future removal */
- bool tcp_nodelay; /* whether to enable TCP_NODELAY or not */
- bool ignorecl; /* ignore content length */
- bool ftp_skip_ip; /* skip the IP address the FTP server passes on to
- us */
- bool connect_only; /* make connection, let application use the socket */
- long ssh_auth_types; /* allowed SSH auth types */
- bool http_te_skip; /* pass the raw body data to the user, even when
- transfer-encoded (chunked, compressed) */
- bool http_ce_skip; /* pass the raw body data to the user, even when
- content-encoded (chunked, compressed) */
long new_file_perms; /* Permissions to use when creating remote files */
long new_directory_perms; /* Permissions to use when creating remote dirs */
- bool proxy_transfer_mode; /* set transfer mode (;type=<a|i>) when doing FTP
- via an HTTP proxy */
+ long ssh_auth_types; /* allowed SSH auth types */
char *str[STRING_LAST]; /* array of strings, pointing to allocated memory */
unsigned int scope_id; /* Scope id for IPv6 */
long allowed_protocols;
long redir_protocols;
-#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
- bool socks5_gssapi_nec; /* Flag to support NEC SOCKS5 server */
-#endif
struct curl_slist *mail_rcpt; /* linked list of mail recipients */
- bool sasl_ir; /* Enable/disable SASL initial response */
/* Common RTSP header options */
Curl_RtspReq rtspreq; /* RTSP request type */
long rtspversion; /* like httpversion, for RTSP */
- bool wildcardmatch; /* enable wildcard matching */
curl_chunk_bgn_callback chunk_bgn; /* called before part of transfer
starts */
curl_chunk_end_callback chunk_end; /* called after part transferring
@@ -1785,36 +1652,109 @@ struct UserDefined {
long gssapi_delegation; /* GSS-API credential delegation, see the
documentation of CURLOPT_GSSAPI_DELEGATION */
- bool tcp_keepalive; /* use TCP keepalives */
long tcp_keepidle; /* seconds in idle before sending keepalive probe */
long tcp_keepintvl; /* seconds between TCP keepalive probes */
- bool tcp_fastopen; /* use TCP Fast Open */
- size_t maxconnects; /* Max idle connections in the connection cache */
+ size_t maxconnects; /* Max idle connections in the connection cache */
- bool ssl_enable_npn; /* TLS NPN extension? */
- bool ssl_enable_alpn; /* TLS ALPN extension? */
- bool path_as_is; /* allow dotdots? */
- bool pipewait; /* wait for pipe/multiplex status before starting a
- new connection */
long expect_100_timeout; /* in milliseconds */
- bool suppress_connect_headers; /* suppress proxy CONNECT response headers
- from user callbacks */
-
struct Curl_easy *stream_depends_on;
- bool stream_depends_e; /* set or don't set the Exclusive bit */
int stream_weight;
-
struct Curl_http2_dep *stream_dependents;
- bool abstract_unix_socket;
+ curl_resolver_start_callback resolver_start; /* optional callback called
+ before resolver start */
+ void *resolver_start_client; /* pointer to pass to resolver start callback */
+ long upkeep_interval_ms; /* Time between calls for connection upkeep. */
+ multidone_func fmultidone;
+ struct Curl_easy *dohfor; /* this is a DoH request for that transfer */
+ CURLU *uh; /* URL handle for the current parsed URL */
+ void *trailer_data; /* pointer to pass to trailer data callback */
+ curl_trailer_callback trailer_callback; /* trailing data callback */
+ bit is_fread_set:1; /* has read callback been set to non-NULL? */
+ bit is_fwrite_set:1; /* has write callback been set to non-NULL? */
+ bit free_referer:1; /* set TRUE if 'referer' points to a string we
+ allocated */
+ bit tftp_no_options:1; /* do not send TFTP options requests */
+ bit sep_headers:1; /* handle host and proxy headers separately */
+ bit cookiesession:1; /* new cookie session? */
+ bit crlf:1; /* convert crlf on ftp upload(?) */
+ bit strip_path_slash:1; /* strip off initial slash from path */
+ bit ssh_compression:1; /* enable SSH compression */
+
+/* Here follows boolean settings that define how to behave during
+ this session. They are STATIC, set by libcurl users or at least initially
+ and they don't change during operations. */
+ bit get_filetime:1; /* get the time and get of the remote file */
+ bit tunnel_thru_httpproxy:1; /* use CONNECT through a HTTP proxy */
+ bit prefer_ascii:1; /* ASCII rather than binary */
+ bit ftp_append:1; /* append, not overwrite, on upload */
+ bit ftp_list_only:1; /* switch FTP command for listing directories */
+#ifndef CURL_DISABLE_FTP
+ bit ftp_use_port:1; /* use the FTP PORT command */
+ bit ftp_use_epsv:1; /* if EPSV is to be attempted or not */
+ bit ftp_use_eprt:1; /* if EPRT is to be attempted or not */
+ bit ftp_use_pret:1; /* if PRET is to be used before PASV or not */
+ bit ftp_skip_ip:1; /* skip the IP address the FTP server passes on to
+ us */
+#endif
+ bit hide_progress:1; /* don't use the progress meter */
+ bit http_fail_on_error:1; /* fail on HTTP error codes >= 400 */
+ bit http_keep_sending_on_error:1; /* for HTTP status codes >= 300 */
+ bit http_follow_location:1; /* follow HTTP redirects */
+ bit http_transfer_encoding:1; /* request compressed HTTP
+ transfer-encoding */
+ bit allow_auth_to_other_hosts:1;
+ bit include_header:1; /* include received protocol headers in data output */
+ bit http_set_referer:1; /* is a custom referer used */
+ bit http_auto_referer:1; /* set "correct" referer when following
+ location: */
+ bit opt_no_body:1; /* as set with CURLOPT_NOBODY */
+ bit upload:1; /* upload request */
+ bit verbose:1; /* output verbosity */
+ bit krb:1; /* Kerberos connection requested */
+ bit reuse_forbid:1; /* forbidden to be reused, close after use */
+ bit reuse_fresh:1; /* do not re-use an existing connection */
+
+ bit no_signal:1; /* do not use any signal/alarm handler */
+ bit tcp_nodelay:1; /* whether to enable TCP_NODELAY or not */
+ bit ignorecl:1; /* ignore content length */
+ bit connect_only:1; /* make connection, let application use the socket */
+ bit http_te_skip:1; /* pass the raw body data to the user, even when
+ transfer-encoded (chunked, compressed) */
+ bit http_ce_skip:1; /* pass the raw body data to the user, even when
+ content-encoded (chunked, compressed) */
+ bit proxy_transfer_mode:1; /* set transfer mode (;type=<a|i>) when doing
+ FTP via an HTTP proxy */
+#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
+ bit socks5_gssapi_nec:1; /* Flag to support NEC SOCKS5 server */
+#endif
+ bit sasl_ir:1; /* Enable/disable SASL initial response */
+ bit wildcard_enabled:1; /* enable wildcard matching */
+ bit tcp_keepalive:1; /* use TCP keepalives */
+ bit tcp_fastopen:1; /* use TCP Fast Open */
+ bit ssl_enable_npn:1; /* TLS NPN extension? */
+ bit ssl_enable_alpn:1;/* TLS ALPN extension? */
+ bit path_as_is:1; /* allow dotdots? */
+ bit pipewait:1; /* wait for multiplex status before starting a new
+ connection */
+ bit suppress_connect_headers:1; /* suppress proxy CONNECT response headers
+ from user callbacks */
+ bit dns_shuffle_addresses:1; /* whether to shuffle addresses before use */
+ bit stream_depends_e:1; /* set or don't set the Exclusive bit */
+ bit haproxyprotocol:1; /* whether to send HAProxy PROXY protocol v1
+ header */
+ bit abstract_unix_socket:1;
+ bit disallow_username_in_url:1; /* disallow username in url */
+ bit doh:1; /* DNS-over-HTTPS enabled */
+ bit doh_get:1; /* use GET for DoH requests, instead of POST */
+ bit http09_allowed:1; /* allow HTTP/0.9 responses */
};
struct Names {
struct curl_hash *hostcache;
enum {
HCACHE_NONE, /* not pointing to anything */
- HCACHE_GLOBAL, /* points to the (shrug) global one */
HCACHE_MULTI, /* points to a shared one in the multi handle */
HCACHE_SHARED /* points to a shared one in a shared object */
} hostcachetype;
@@ -1835,9 +1775,10 @@ struct Curl_easy {
struct Curl_easy *next;
struct Curl_easy *prev;
- struct connectdata *easy_conn; /* the "unit's" connection */
+ struct connectdata *conn;
struct curl_llist_element connect_queue;
- struct curl_llist_element pipeline_queue;
+ struct curl_llist_element sh_queue; /* list per Curl_sh_entry */
+ struct curl_llist_element conn_queue; /* list per connectdata */
CURLMstate mstate; /* the handle's state */
CURLcode result; /* previous result */
@@ -1849,6 +1790,8 @@ struct Curl_easy {
the state etc are also kept. This array is mostly used to detect when a
socket is to be removed from the hash. See singlesocket(). */
curl_socket_t sockets[MAX_SOCKSPEREASYHANDLE];
+ int actions[MAX_SOCKSPEREASYHANDLE]; /* action for each socket in
+ sockets[] */
int numsocks;
struct Names dns;
@@ -1859,6 +1802,9 @@ struct Curl_easy {
struct to which this "belongs" when used
by the easy interface */
struct Curl_share *share; /* Share, handles global variable mutexing */
+#ifdef USE_LIBPSL
+ struct PslCache *psl; /* The associated PSL cache. */
+#endif
struct SingleRequest req; /* Request-specific data */
struct UserDefined set; /* values set by the libcurl user */
struct DynamicStatic change; /* possibly modified userdefined data */
@@ -1866,10 +1812,15 @@ struct Curl_easy {
NOTE that the 'cookie' field in the
UserDefined struct defines if the "engine"
is to be used or not. */
+#ifdef USE_ALTSVC
+ struct altsvcinfo *asi; /* the alt-svc cache */
+#endif
struct Progress progress; /* for all the progress meter data */
struct UrlState state; /* struct for fields used for state info and
other dynamic purposes */
+#ifndef CURL_DISABLE_FTP
struct WildcardData wildcard; /* wildcard download state info */
+#endif
struct PureInfo info; /* stats, reports and info data */
struct curl_tlssessioninfo tsi; /* Information about the TLS session, only
valid after a client has asked for it */
diff --git a/Utilities/cmcurl/lib/vauth/cleartext.c b/Utilities/cmcurl/lib/vauth/cleartext.c
index a761ae784..6f452c169 100644
--- a/Utilities/cmcurl/lib/vauth/cleartext.c
+++ b/Utilities/cmcurl/lib/vauth/cleartext.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -25,6 +25,9 @@
#include "curl_setup.h"
+#if !defined(CURL_DISABLE_IMAP) || !defined(CURL_DISABLE_SMTP) || \
+ !defined(CURL_DISABLE_POP3)
+
#include <curl/curl.h>
#include "urldata.h"
@@ -49,8 +52,9 @@
* Parameters:
*
* data [in] - The session handle.
- * userp [in] - The user name.
- * passdwp [in] - The user's password.
+ * authzid [in] - The authorization identity.
+ * authcid [in] - The authentication identity.
+ * passwd [in] - The password.
* outptr [in/out] - The address where a pointer to newly allocated memory
* holding the result will be stored upon completion.
* outlen [out] - The length of the output message.
@@ -58,42 +62,40 @@
* Returns CURLE_OK on success.
*/
CURLcode Curl_auth_create_plain_message(struct Curl_easy *data,
- const char *userp,
- const char *passwdp,
+ const char *authzid,
+ const char *authcid,
+ const char *passwd,
char **outptr, size_t *outlen)
{
CURLcode result;
char *plainauth;
- size_t ulen;
+ size_t zlen;
+ size_t clen;
size_t plen;
size_t plainlen;
*outlen = 0;
*outptr = NULL;
- ulen = strlen(userp);
- plen = strlen(passwdp);
+ zlen = (authzid == NULL ? 0 : strlen(authzid));
+ clen = strlen(authcid);
+ plen = strlen(passwd);
- /* Compute binary message length, checking for overflows. */
- plainlen = 2 * ulen;
- if(plainlen < ulen)
- return CURLE_OUT_OF_MEMORY;
- plainlen += plen;
- if(plainlen < plen)
- return CURLE_OUT_OF_MEMORY;
- plainlen += 2;
- if(plainlen < 2)
+ /* Compute binary message length. Check for overflows. */
+ if(((zlen + clen) > SIZE_T_MAX/4) || (plen > (SIZE_T_MAX/2 - 2)))
return CURLE_OUT_OF_MEMORY;
+ plainlen = zlen + clen + plen + 2;
plainauth = malloc(plainlen);
if(!plainauth)
return CURLE_OUT_OF_MEMORY;
/* Calculate the reply */
- memcpy(plainauth, userp, ulen);
- plainauth[ulen] = '\0';
- memcpy(plainauth + ulen + 1, userp, ulen);
- plainauth[2 * ulen + 1] = '\0';
- memcpy(plainauth + 2 * ulen + 2, passwdp, plen);
+ if(zlen != 0)
+ memcpy(plainauth, authzid, zlen);
+ plainauth[zlen] = '\0';
+ memcpy(plainauth + zlen + 1, authcid, clen);
+ plainauth[zlen + clen + 1] = '\0';
+ memcpy(plainauth + zlen + clen + 2, passwd, plen);
/* Base64 encode the reply */
result = Curl_base64_encode(data, plainauth, plainlen, outptr, outlen);
@@ -163,3 +165,5 @@ CURLcode Curl_auth_create_external_message(struct Curl_easy *data,
/* This is the same formatting as the login message */
return Curl_auth_create_login_message(data, user, outptr, outlen);
}
+
+#endif /* if no users */
diff --git a/Utilities/cmcurl/lib/vauth/cram.c b/Utilities/cmcurl/lib/vauth/cram.c
index 3074a163a..d148618b0 100644
--- a/Utilities/cmcurl/lib/vauth/cram.c
+++ b/Utilities/cmcurl/lib/vauth/cram.c
@@ -81,7 +81,7 @@ CURLcode Curl_auth_decode_cram_md5_message(const char *chlg64, char **outptr,
* data [in] - The session handle.
* chlg [in] - The challenge.
* userp [in] - The user name.
- * passdwp [in] - The user's password.
+ * passwdp [in] - The user's password.
* outptr [in/out] - The address where a pointer to newly allocated memory
* holding the result will be stored upon completion.
* outlen [out] - The length of the output message.
diff --git a/Utilities/cmcurl/lib/vauth/digest.c b/Utilities/cmcurl/lib/vauth/digest.c
index 185098ed6..f9cdc9dd0 100644
--- a/Utilities/cmcurl/lib/vauth/digest.c
+++ b/Utilities/cmcurl/lib/vauth/digest.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -19,6 +19,7 @@
* KIND, either express or implied.
*
* RFC2831 DIGEST-MD5 authentication
+ * RFC7616 DIGEST-SHA256, DIGEST-SHA512-256 authentication
*
***************************************************************************/
@@ -34,6 +35,7 @@
#include "curl_base64.h"
#include "curl_hmac.h"
#include "curl_md5.h"
+#include "curl_sha256.h"
#include "vtls/vtls.h"
#include "warnless.h"
#include "strtok.h"
@@ -141,13 +143,22 @@ static void auth_digest_md5_to_ascii(unsigned char *source, /* 16 bytes */
{
int i;
for(i = 0; i < 16; i++)
- snprintf((char *) &dest[i * 2], 3, "%02x", source[i]);
+ msnprintf((char *) &dest[i * 2], 3, "%02x", source[i]);
+}
+
+/* Convert sha256 chunk to RFC7616 -suitable ascii string*/
+static void auth_digest_sha256_to_ascii(unsigned char *source, /* 32 bytes */
+ unsigned char *dest) /* 65 bytes */
+{
+ int i;
+ for(i = 0; i < 32; i++)
+ msnprintf((char *) &dest[i * 2], 3, "%02x", source[i]);
}
/* Perform quoted-string escaping as described in RFC2616 and its errata */
static char *auth_digest_string_quoted(const char *source)
{
- char *dest, *d;
+ char *dest;
const char *s = source;
size_t n = 1; /* null terminator */
@@ -162,8 +173,8 @@ static char *auth_digest_string_quoted(const char *source)
dest = malloc(n);
if(dest) {
+ char *d = dest;
s = source;
- d = dest;
while(*s) {
if(*s == '"' || *s == '\\') {
*d++ = '\\';
@@ -331,7 +342,7 @@ bool Curl_auth_is_digest_supported(void)
* data [in] - The session handle.
* chlg64 [in] - The base64 encoded challenge message.
* userp [in] - The user name.
- * passdwp [in] - The user's password.
+ * passwdp [in] - The user's password.
* service [in] - The service type such as http, smtp, pop or imap.
* outptr [in/out] - The address where a pointer to newly allocated memory
* holding the result will be stored upon completion.
@@ -421,7 +432,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
/* Convert calculated 16 octet hex into 32 bytes string */
for(i = 0; i < MD5_DIGEST_LEN; i++)
- snprintf(&HA1_hex[2 * i], 3, "%02x", digest[i]);
+ msnprintf(&HA1_hex[2 * i], 3, "%02x", digest[i]);
/* Generate our SPN */
spn = Curl_auth_build_spn(service, realm, NULL);
@@ -444,7 +455,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
Curl_MD5_final(ctxt, digest);
for(i = 0; i < MD5_DIGEST_LEN; i++)
- snprintf(&HA2_hex[2 * i], 3, "%02x", digest[i]);
+ msnprintf(&HA2_hex[2 * i], 3, "%02x", digest[i]);
/* Now calculate the response hash */
ctxt = Curl_MD5_init(Curl_DIGEST_MD5);
@@ -474,7 +485,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
Curl_MD5_final(ctxt, digest);
for(i = 0; i < MD5_DIGEST_LEN; i++)
- snprintf(&resp_hash_hex[2 * i], 3, "%02x", digest[i]);
+ msnprintf(&resp_hash_hex[2 * i], 3, "%02x", digest[i]);
/* Generate the response */
response = aprintf("username=\"%s\",realm=\"%s\",nonce=\"%s\","
@@ -602,9 +613,22 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
digest->algo = CURLDIGESTALGO_MD5SESS;
else if(strcasecompare(content, "MD5"))
digest->algo = CURLDIGESTALGO_MD5;
+ else if(strcasecompare(content, "SHA-256"))
+ digest->algo = CURLDIGESTALGO_SHA256;
+ else if(strcasecompare(content, "SHA-256-SESS"))
+ digest->algo = CURLDIGESTALGO_SHA256SESS;
+ else if(strcasecompare(content, "SHA-512-256"))
+ digest->algo = CURLDIGESTALGO_SHA512_256;
+ else if(strcasecompare(content, "SHA-512-256-SESS"))
+ digest->algo = CURLDIGESTALGO_SHA512_256SESS;
else
return CURLE_BAD_CONTENT_ENCODING;
}
+ else if(strcasecompare(value, "userhash")) {
+ if(strcasecompare(content, "true")) {
+ digest->userhash = TRUE;
+ }
+ }
else {
/* Unknown specifier, ignore it! */
}
@@ -635,7 +659,7 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
}
/*
- * Curl_auth_create_digest_http_message()
+ * _Curl_auth_create_digest_http_message()
*
* This is used to generate a HTTP DIGEST response message ready for sending
* to the recipient.
@@ -644,7 +668,7 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
*
* data [in] - The session handle.
* userp [in] - The user name.
- * passdwp [in] - The user's password.
+ * passwdp [in] - The user's password.
* request [in] - The HTTP request.
* uripath [in] - The path of the HTTP uri.
* digest [in/out] - The digest data struct being used and modified.
@@ -654,21 +678,24 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
*
* Returns CURLE_OK on success.
*/
-CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
- const char *userp,
- const char *passwdp,
- const unsigned char *request,
- const unsigned char *uripath,
- struct digestdata *digest,
- char **outptr, size_t *outlen)
+static CURLcode _Curl_auth_create_digest_http_message(
+ struct Curl_easy *data,
+ const char *userp,
+ const char *passwdp,
+ const unsigned char *request,
+ const unsigned char *uripath,
+ struct digestdata *digest,
+ char **outptr, size_t *outlen,
+ void (*convert_to_ascii)(unsigned char *, unsigned char *),
+ void (*hash)(unsigned char *, const unsigned char *))
{
CURLcode result;
- unsigned char md5buf[16]; /* 16 bytes/128 bits */
- unsigned char request_digest[33];
- unsigned char *md5this;
- unsigned char ha1[33]; /* 32 digits and 1 zero byte */
- unsigned char ha2[33]; /* 32 digits and 1 zero byte */
- char cnoncebuf[33];
+ unsigned char hashbuf[32]; /* 32 bytes/256 bits */
+ unsigned char request_digest[65];
+ unsigned char *hashthis;
+ unsigned char ha1[65]; /* 64 digits and 1 zero byte */
+ unsigned char ha2[65]; /* 64 digits and 1 zero byte */
+ char userh[65];
char *cnonce = NULL;
size_t cnonce_sz = 0;
char *userp_quoted;
@@ -679,6 +706,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
digest->nc = 1;
if(!digest->cnonce) {
+ char cnoncebuf[33];
result = Curl_rand_hex(data, (unsigned char *)cnoncebuf,
sizeof(cnoncebuf));
if(result)
@@ -692,6 +720,17 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
digest->cnonce = cnonce;
}
+ if(digest->userhash) {
+ hashthis = (unsigned char *) aprintf("%s:%s", userp, digest->realm);
+ if(!hashthis)
+ return CURLE_OUT_OF_MEMORY;
+
+ CURL_OUTPUT_DIGEST_CONV(data, hashthis);
+ hash(hashbuf, hashthis);
+ free(hashthis);
+ convert_to_ascii(hashbuf, (unsigned char *)userh);
+ }
+
/*
If the algorithm is "MD5" or unspecified (which then defaults to MD5):
@@ -703,26 +742,29 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
unq(nonce-value) ":" unq(cnonce-value)
*/
- md5this = (unsigned char *)
- aprintf("%s:%s:%s", userp, digest->realm, passwdp);
- if(!md5this)
+ hashthis = (unsigned char *)
+ aprintf("%s:%s:%s", digest->userhash ? userh : userp,
+ digest->realm, passwdp);
+ if(!hashthis)
return CURLE_OUT_OF_MEMORY;
- CURL_OUTPUT_DIGEST_CONV(data, md5this); /* convert on non-ASCII machines */
- Curl_md5it(md5buf, md5this);
- free(md5this);
- auth_digest_md5_to_ascii(md5buf, ha1);
+ CURL_OUTPUT_DIGEST_CONV(data, hashthis); /* convert on non-ASCII machines */
+ hash(hashbuf, hashthis);
+ free(hashthis);
+ convert_to_ascii(hashbuf, ha1);
- if(digest->algo == CURLDIGESTALGO_MD5SESS) {
+ if(digest->algo == CURLDIGESTALGO_MD5SESS ||
+ digest->algo == CURLDIGESTALGO_SHA256SESS ||
+ digest->algo == CURLDIGESTALGO_SHA512_256SESS) {
/* nonce and cnonce are OUTSIDE the hash */
tmp = aprintf("%s:%s:%s", ha1, digest->nonce, digest->cnonce);
if(!tmp)
return CURLE_OUT_OF_MEMORY;
CURL_OUTPUT_DIGEST_CONV(data, tmp); /* Convert on non-ASCII machines */
- Curl_md5it(md5buf, (unsigned char *) tmp);
+ hash(hashbuf, (unsigned char *) tmp);
free(tmp);
- auth_digest_md5_to_ascii(md5buf, ha1);
+ convert_to_ascii(hashbuf, ha1);
}
/*
@@ -738,27 +780,33 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
5.1.1 of RFC 2616)
*/
- md5this = (unsigned char *) aprintf("%s:%s", request, uripath);
+ hashthis = (unsigned char *) aprintf("%s:%s", request, uripath);
+ if(!hashthis)
+ return CURLE_OUT_OF_MEMORY;
if(digest->qop && strcasecompare(digest->qop, "auth-int")) {
- /* We don't support auth-int for PUT or POST at the moment.
- TODO: replace md5 of empty string with entity-body for PUT/POST */
- unsigned char *md5this2 = (unsigned char *)
- aprintf("%s:%s", md5this, "d41d8cd98f00b204e9800998ecf8427e");
- free(md5this);
- md5this = md5this2;
+ /* We don't support auth-int for PUT or POST */
+ char hashed[65];
+ unsigned char *hashthis2;
+
+ hash(hashbuf, (const unsigned char *)"");
+ convert_to_ascii(hashbuf, (unsigned char *)hashed);
+
+ hashthis2 = (unsigned char *)aprintf("%s:%s", hashthis, hashed);
+ free(hashthis);
+ hashthis = hashthis2;
}
- if(!md5this)
+ if(!hashthis)
return CURLE_OUT_OF_MEMORY;
- CURL_OUTPUT_DIGEST_CONV(data, md5this); /* convert on non-ASCII machines */
- Curl_md5it(md5buf, md5this);
- free(md5this);
- auth_digest_md5_to_ascii(md5buf, ha2);
+ CURL_OUTPUT_DIGEST_CONV(data, hashthis); /* convert on non-ASCII machines */
+ hash(hashbuf, hashthis);
+ free(hashthis);
+ convert_to_ascii(hashbuf, ha2);
if(digest->qop) {
- md5this = (unsigned char *) aprintf("%s:%s:%08x:%s:%s:%s",
+ hashthis = (unsigned char *) aprintf("%s:%s:%08x:%s:%s:%s",
ha1,
digest->nonce,
digest->nc,
@@ -767,19 +815,19 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
ha2);
}
else {
- md5this = (unsigned char *) aprintf("%s:%s:%s",
+ hashthis = (unsigned char *) aprintf("%s:%s:%s",
ha1,
digest->nonce,
ha2);
}
- if(!md5this)
+ if(!hashthis)
return CURLE_OUT_OF_MEMORY;
- CURL_OUTPUT_DIGEST_CONV(data, md5this); /* convert on non-ASCII machines */
- Curl_md5it(md5buf, md5this);
- free(md5this);
- auth_digest_md5_to_ascii(md5buf, request_digest);
+ CURL_OUTPUT_DIGEST_CONV(data, hashthis); /* convert on non-ASCII machines */
+ hash(hashbuf, hashthis);
+ free(hashthis);
+ convert_to_ascii(hashbuf, request_digest);
/* For test case 64 (snooped from a Mozilla 1.3a request)
@@ -794,7 +842,7 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
characters. algorithm and qop with standard values only contain web-safe
characters.
*/
- userp_quoted = auth_digest_string_quoted(userp);
+ userp_quoted = auth_digest_string_quoted(digest->userhash ? userh : userp);
if(!userp_quoted)
return CURLE_OUT_OF_MEMORY;
@@ -858,6 +906,16 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
response = tmp;
}
+ if(digest->userhash) {
+ /* Append the userhash */
+ tmp = aprintf("%s, userhash=true", response);
+ free(response);
+ if(!tmp)
+ return CURLE_OUT_OF_MEMORY;
+
+ response = tmp;
+ }
+
/* Return the output */
*outptr = response;
*outlen = strlen(response);
@@ -866,6 +924,58 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
}
/*
+ * Curl_auth_create_digest_http_message()
+ *
+ * This is used to generate a HTTP DIGEST response message ready for sending
+ * to the recipient.
+ *
+ * Parameters:
+ *
+ * data [in] - The session handle.
+ * userp [in] - The user name.
+ * passwdp [in] - The user's password.
+ * request [in] - The HTTP request.
+ * uripath [in] - The path of the HTTP uri.
+ * digest [in/out] - The digest data struct being used and modified.
+ * outptr [in/out] - The address where a pointer to newly allocated memory
+ * holding the result will be stored upon completion.
+ * outlen [out] - The length of the output message.
+ *
+ * Returns CURLE_OK on success.
+ */
+CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
+ const char *userp,
+ const char *passwdp,
+ const unsigned char *request,
+ const unsigned char *uripath,
+ struct digestdata *digest,
+ char **outptr, size_t *outlen)
+{
+ switch(digest->algo) {
+ case CURLDIGESTALGO_MD5:
+ case CURLDIGESTALGO_MD5SESS:
+ return _Curl_auth_create_digest_http_message(data, userp, passwdp,
+ request, uripath, digest,
+ outptr, outlen,
+ auth_digest_md5_to_ascii,
+ Curl_md5it);
+
+ case CURLDIGESTALGO_SHA256:
+ case CURLDIGESTALGO_SHA256SESS:
+ case CURLDIGESTALGO_SHA512_256:
+ case CURLDIGESTALGO_SHA512_256SESS:
+ return _Curl_auth_create_digest_http_message(data, userp, passwdp,
+ request, uripath, digest,
+ outptr, outlen,
+ auth_digest_sha256_to_ascii,
+ Curl_sha256it);
+
+ default:
+ return CURLE_UNSUPPORTED_PROTOCOL;
+ }
+}
+
+/*
* Curl_auth_digest_cleanup()
*
* This is used to clean up the digest specific data.
@@ -887,6 +997,7 @@ void Curl_auth_digest_cleanup(struct digestdata *digest)
digest->nc = 0;
digest->algo = CURLDIGESTALGO_MD5; /* default algorithm */
digest->stale = FALSE; /* default means normal, not stale */
+ digest->userhash = FALSE;
}
#endif /* !USE_WINDOWS_SSPI */
diff --git a/Utilities/cmcurl/lib/vauth/digest.h b/Utilities/cmcurl/lib/vauth/digest.h
index 5722dcece..8686c44a4 100644
--- a/Utilities/cmcurl/lib/vauth/digest.h
+++ b/Utilities/cmcurl/lib/vauth/digest.h
@@ -31,7 +31,11 @@
enum {
CURLDIGESTALGO_MD5,
- CURLDIGESTALGO_MD5SESS
+ CURLDIGESTALGO_MD5SESS,
+ CURLDIGESTALGO_SHA256,
+ CURLDIGESTALGO_SHA256SESS,
+ CURLDIGESTALGO_SHA512_256,
+ CURLDIGESTALGO_SHA512_256SESS
};
/* This is used to extract the realm from a challenge message */
diff --git a/Utilities/cmcurl/lib/vauth/digest_sspi.c b/Utilities/cmcurl/lib/vauth/digest_sspi.c
index 0bd94442d..fe8093e8b 100644
--- a/Utilities/cmcurl/lib/vauth/digest_sspi.c
+++ b/Utilities/cmcurl/lib/vauth/digest_sspi.c
@@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2014 - 2016, Steve Holme, <steve_holme@hotmail.com>.
- * Copyright (C) 2015 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2015 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -75,7 +75,7 @@ bool Curl_auth_is_digest_supported(void)
* data [in] - The session handle.
* chlg64 [in] - The base64 encoded challenge message.
* userp [in] - The user name in the format User or Domain\User.
- * passdwp [in] - The user's password.
+ * passwdp [in] - The user's password.
* service [in] - The service type such as http, smtp, pop or imap.
* outptr [in/out] - The address where a pointer to newly allocated memory
* holding the result will be stored upon completion.
@@ -146,7 +146,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
}
/* Generate our SPN */
- spn = Curl_auth_build_spn(service, data->easy_conn->host.name, NULL);
+ spn = Curl_auth_build_spn(service, data->conn->host.name, NULL);
if(!spn) {
free(output_token);
free(input_token);
@@ -352,8 +352,8 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
if(!Curl_auth_digest_get_pair(p, value, content, &p))
break;
- if(Curl_strcasecompare(value, "stale")
- && Curl_strcasecompare(content, "true")) {
+ if(strcasecompare(value, "stale") &&
+ strcasecompare(content, "true")) {
stale = true;
break;
}
@@ -391,7 +391,7 @@ CURLcode Curl_auth_decode_digest_http_message(const char *chlg,
*
* data [in] - The session handle.
* userp [in] - The user name in the format User or Domain\User.
- * passdwp [in] - The user's password.
+ * passwdp [in] - The user's password.
* request [in] - The HTTP request.
* uripath [in] - The path of the HTTP uri.
* digest [in/out] - The digest data struct being used and modified.
@@ -438,6 +438,20 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
return CURLE_OUT_OF_MEMORY;
}
+ /* If the user/passwd that was used to make the identity for http_context
+ has changed then delete that context. */
+ if((userp && !digest->user) || (!userp && digest->user) ||
+ (passwdp && !digest->passwd) || (!passwdp && digest->passwd) ||
+ (userp && digest->user && strcmp(userp, digest->user)) ||
+ (passwdp && digest->passwd && strcmp(passwdp, digest->passwd))) {
+ if(digest->http_context) {
+ s_pSecFn->DeleteSecurityContext(digest->http_context);
+ Curl_safefree(digest->http_context);
+ }
+ Curl_safefree(digest->user);
+ Curl_safefree(digest->passwd);
+ }
+
if(digest->http_context) {
chlg_desc.ulVersion = SECBUFFER_VERSION;
chlg_desc.cBuffers = 5;
@@ -479,6 +493,10 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
TimeStamp expiry; /* For Windows 9x compatibility of SSPI calls */
TCHAR *spn;
+ /* free the copy of user/passwd used to make the previous identity */
+ Curl_safefree(digest->user);
+ Curl_safefree(digest->passwd);
+
if(userp && *userp) {
/* Populate our identity structure */
if(Curl_create_sspi_identity(userp, passwdp, &identity)) {
@@ -500,6 +518,25 @@ CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
/* Use the current Windows user */
p_identity = NULL;
+ if(userp) {
+ digest->user = strdup(userp);
+
+ if(!digest->user) {
+ free(output_token);
+ return CURLE_OUT_OF_MEMORY;
+ }
+ }
+
+ if(passwdp) {
+ digest->passwd = strdup(passwdp);
+
+ if(!digest->passwd) {
+ free(output_token);
+ Curl_safefree(digest->user);
+ return CURLE_OUT_OF_MEMORY;
+ }
+ }
+
/* Acquire our credentials handle */
status = s_pSecFn->AcquireCredentialsHandle(NULL,
(TCHAR *) TEXT(SP_NAME_DIGEST),
@@ -623,6 +660,10 @@ void Curl_auth_digest_cleanup(struct digestdata *digest)
s_pSecFn->DeleteSecurityContext(digest->http_context);
Curl_safefree(digest->http_context);
}
+
+ /* Free the copy of user/passwd used to make the identity for http_context */
+ Curl_safefree(digest->user);
+ Curl_safefree(digest->passwd);
}
#endif /* USE_WINDOWS_SSPI && !CURL_DISABLE_CRYPTO_AUTH */
diff --git a/Utilities/cmcurl/lib/vauth/krb5_gssapi.c b/Utilities/cmcurl/lib/vauth/krb5_gssapi.c
index 560ecc5bc..ea0a5f189 100644
--- a/Utilities/cmcurl/lib/vauth/krb5_gssapi.c
+++ b/Utilities/cmcurl/lib/vauth/krb5_gssapi.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2014 - 2017, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2014 - 2019, Steve Holme, <steve_holme@hotmail.com>.
* Copyright (C) 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
@@ -65,7 +65,7 @@ bool Curl_auth_is_gssapi_supported(void)
*
* data [in] - The session handle.
* userp [in] - The user name.
- * passdwp [in] - The user's password.
+ * passwdp [in] - The user's password.
* service [in] - The service type such as http, smtp, pop or imap.
* host [in[ - The host name.
* mutual_auth [in] - Flag specifying whether or not mutual authentication
@@ -372,7 +372,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
}
/*
- * Curl_auth_gssapi_cleanup()
+ * Curl_auth_cleanup_gssapi()
*
* This is used to clean up the GSSAPI (Kerberos V5) specific data.
*
@@ -381,7 +381,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
* krb5 [in/out] - The Kerberos 5 data struct being cleaned up.
*
*/
-void Curl_auth_gssapi_cleanup(struct kerberos5data *krb5)
+void Curl_auth_cleanup_gssapi(struct kerberos5data *krb5)
{
OM_uint32 minor_status;
diff --git a/Utilities/cmcurl/lib/vauth/krb5_sspi.c b/Utilities/cmcurl/lib/vauth/krb5_sspi.c
index 1b4cef486..1f6e462bf 100644
--- a/Utilities/cmcurl/lib/vauth/krb5_sspi.c
+++ b/Utilities/cmcurl/lib/vauth/krb5_sspi.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2014 - 2017, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2014 - 2019, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -71,7 +71,7 @@ bool Curl_auth_is_gssapi_supported(void)
*
* data [in] - The session handle.
* userp [in] - The user name in the format User or Domain\User.
- * passdwp [in] - The user's password.
+ * passwdp [in] - The user's password.
* service [in] - The service type such as http, smtp, pop or imap.
* host [in] - The host name.
* mutual_auth [in] - Flag specifying whether or not mutual authentication
@@ -135,7 +135,7 @@ CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data,
}
if(!krb5->credentials) {
- /* Do we have credientials to use or are we using single sign-on? */
+ /* Do we have credentials to use or are we using single sign-on? */
if(userp && *userp) {
/* Populate our identity structure */
result = Curl_create_sspi_identity(userp, passwdp, &krb5->identity);
@@ -150,12 +150,10 @@ CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data,
krb5->p_identity = NULL;
/* Allocate our credentials handle */
- krb5->credentials = malloc(sizeof(CredHandle));
+ krb5->credentials = calloc(1, sizeof(CredHandle));
if(!krb5->credentials)
return CURLE_OUT_OF_MEMORY;
- memset(krb5->credentials, 0, sizeof(CredHandle));
-
/* Acquire our credentials handle */
status = s_pSecFn->AcquireCredentialsHandle(NULL,
(TCHAR *)
@@ -167,11 +165,9 @@ CURLcode Curl_auth_create_gssapi_user_message(struct Curl_easy *data,
return CURLE_LOGIN_DENIED;
/* Allocate our new context handle */
- krb5->context = malloc(sizeof(CtxtHandle));
+ krb5->context = calloc(1, sizeof(CtxtHandle));
if(!krb5->context)
return CURLE_OUT_OF_MEMORY;
-
- memset(krb5->context, 0, sizeof(CtxtHandle));
}
if(chlg64 && *chlg64) {
@@ -478,7 +474,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
}
/*
- * Curl_auth_gssapi_cleanup()
+ * Curl_auth_cleanup_gssapi()
*
* This is used to clean up the GSSAPI (Kerberos V5) specific data.
*
@@ -487,7 +483,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
* krb5 [in/out] - The Kerberos 5 data struct being cleaned up.
*
*/
-void Curl_auth_gssapi_cleanup(struct kerberos5data *krb5)
+void Curl_auth_cleanup_gssapi(struct kerberos5data *krb5)
{
/* Free our security context */
if(krb5->context) {
diff --git a/Utilities/cmcurl/lib/vauth/ntlm.c b/Utilities/cmcurl/lib/vauth/ntlm.c
index 42196455f..047c2b5a3 100644
--- a/Utilities/cmcurl/lib/vauth/ntlm.c
+++ b/Utilities/cmcurl/lib/vauth/ntlm.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -44,7 +44,9 @@
#include "rand.h"
#include "vtls/vtls.h"
-#ifdef USE_NSS
+/* SSL backend-specific #if branches in this file must be kept in the order
+ documented in curl_ntlm_core. */
+#if defined(NTLM_NEEDS_NSS_INIT)
#include "vtls/nssg.h" /* for Curl_nss_force_init() */
#endif
@@ -61,9 +63,9 @@
/* "NTLMSSP" signature is always in ASCII regardless of the platform */
#define NTLMSSP_SIGNATURE "\x4e\x54\x4c\x4d\x53\x53\x50"
-#define SHORTPAIR(x) ((x) & 0xff), (((x) >> 8) & 0xff)
-#define LONGQUARTET(x) ((x) & 0xff), (((x) >> 8) & 0xff), \
- (((x) >> 16) & 0xff), (((x) >> 24) & 0xff)
+#define SHORTPAIR(x) ((int)((x) & 0xff)), ((int)(((x) >> 8) & 0xff))
+#define LONGQUARTET(x) ((int)((x) & 0xff)), ((int)(((x) >> 8) & 0xff)), \
+ ((int)(((x) >> 16) & 0xff)), ((int)(((x) >> 24) & 0xff))
#if DEBUG_ME
# define DEBUG_OUT(x) x
@@ -180,10 +182,11 @@ static CURLcode ntlm_decode_type2_target(struct Curl_easy *data,
target_info_len = Curl_read16_le(&buffer[40]);
target_info_offset = Curl_read32_le(&buffer[44]);
if(target_info_len > 0) {
- if(((target_info_offset + target_info_len) > size) ||
+ if((target_info_offset >= size) ||
+ ((target_info_offset + target_info_len) > size) ||
(target_info_offset < 48)) {
infof(data, "NTLM handshake failure (bad type-2 message). "
- "Target Info Offset Len is set incorrect by the peer\n");
+ "Target Info Offset Len is set incorrect by the peer\n");
return CURLE_BAD_CONTENT_ENCODING;
}
@@ -272,7 +275,7 @@ CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data,
unsigned char *type2 = NULL;
size_t type2_len = 0;
-#if defined(USE_NSS)
+#if defined(NTLM_NEEDS_NSS_INIT)
/* Make sure the crypto backend is initialized */
result = Curl_nss_force_init(data);
if(result)
@@ -350,8 +353,11 @@ static void unicodecpy(unsigned char *dest, const char *src, size_t length)
*
* Parameters:
*
+ * data [in] - The session handle.
* userp [in] - The user name in the format User or Domain\User.
- * passdwp [in] - The user's password.
+ * passwdp [in] - The user's password.
+ * service [in] - The service type such as http, smtp, pop or imap.
+ * host [in] - The host name.
* ntlm [in/out] - The NTLM data struct being used and modified.
* outptr [in/out] - The address where a pointer to newly allocated memory
* holding the result will be stored upon completion.
@@ -359,8 +365,11 @@ static void unicodecpy(unsigned char *dest, const char *src, size_t length)
*
* Returns CURLE_OK on success.
*/
-CURLcode Curl_auth_create_ntlm_type1_message(const char *userp,
+CURLcode Curl_auth_create_ntlm_type1_message(struct Curl_easy *data,
+ const char *userp,
const char *passwdp,
+ const char *service,
+ const char *hostname,
struct ntlmdata *ntlm,
char **outptr, size_t *outlen)
{
@@ -390,47 +399,49 @@ CURLcode Curl_auth_create_ntlm_type1_message(const char *userp,
domain are empty */
(void)userp;
(void)passwdp;
+ (void)service,
+ (void)hostname,
/* Clean up any former leftovers and initialise to defaults */
- Curl_auth_ntlm_cleanup(ntlm);
+ Curl_auth_cleanup_ntlm(ntlm);
#if defined(USE_NTRESPONSES) && defined(USE_NTLM2SESSION)
#define NTLM2FLAG NTLMFLAG_NEGOTIATE_NTLM2_KEY
#else
#define NTLM2FLAG 0
#endif
- snprintf((char *)ntlmbuf, NTLM_BUFSIZE,
- NTLMSSP_SIGNATURE "%c"
- "\x01%c%c%c" /* 32-bit type = 1 */
- "%c%c%c%c" /* 32-bit NTLM flag field */
- "%c%c" /* domain length */
- "%c%c" /* domain allocated space */
- "%c%c" /* domain name offset */
- "%c%c" /* 2 zeroes */
- "%c%c" /* host length */
- "%c%c" /* host allocated space */
- "%c%c" /* host name offset */
- "%c%c" /* 2 zeroes */
- "%s" /* host name */
- "%s", /* domain string */
- 0, /* trailing zero */
- 0, 0, 0, /* part of type-1 long */
-
- LONGQUARTET(NTLMFLAG_NEGOTIATE_OEM |
- NTLMFLAG_REQUEST_TARGET |
- NTLMFLAG_NEGOTIATE_NTLM_KEY |
- NTLM2FLAG |
- NTLMFLAG_NEGOTIATE_ALWAYS_SIGN),
- SHORTPAIR(domlen),
- SHORTPAIR(domlen),
- SHORTPAIR(domoff),
- 0, 0,
- SHORTPAIR(hostlen),
- SHORTPAIR(hostlen),
- SHORTPAIR(hostoff),
- 0, 0,
- host, /* this is empty */
- domain /* this is empty */);
+ msnprintf((char *)ntlmbuf, NTLM_BUFSIZE,
+ NTLMSSP_SIGNATURE "%c"
+ "\x01%c%c%c" /* 32-bit type = 1 */
+ "%c%c%c%c" /* 32-bit NTLM flag field */
+ "%c%c" /* domain length */
+ "%c%c" /* domain allocated space */
+ "%c%c" /* domain name offset */
+ "%c%c" /* 2 zeroes */
+ "%c%c" /* host length */
+ "%c%c" /* host allocated space */
+ "%c%c" /* host name offset */
+ "%c%c" /* 2 zeroes */
+ "%s" /* host name */
+ "%s", /* domain string */
+ 0, /* trailing zero */
+ 0, 0, 0, /* part of type-1 long */
+
+ LONGQUARTET(NTLMFLAG_NEGOTIATE_OEM |
+ NTLMFLAG_REQUEST_TARGET |
+ NTLMFLAG_NEGOTIATE_NTLM_KEY |
+ NTLM2FLAG |
+ NTLMFLAG_NEGOTIATE_ALWAYS_SIGN),
+ SHORTPAIR(domlen),
+ SHORTPAIR(domlen),
+ SHORTPAIR(domoff),
+ 0, 0,
+ SHORTPAIR(hostlen),
+ SHORTPAIR(hostlen),
+ SHORTPAIR(hostoff),
+ 0, 0,
+ host, /* this is empty */
+ domain /* this is empty */);
/* Initial packet length */
size = 32 + hostlen + domlen;
@@ -458,7 +469,7 @@ CURLcode Curl_auth_create_ntlm_type1_message(const char *userp,
});
/* Return with binary blob encoded into base64 */
- return Curl_base64_encode(NULL, (char *)ntlmbuf, size, outptr, outlen);
+ return Curl_base64_encode(data, (char *)ntlmbuf, size, outptr, outlen);
}
/*
@@ -471,7 +482,7 @@ CURLcode Curl_auth_create_ntlm_type1_message(const char *userp,
*
* data [in] - The session handle.
* userp [in] - The user name in the format User or Domain\User.
- * passdwp [in] - The user's password.
+ * passwdp [in] - The user's password.
* ntlm [in/out] - The NTLM data struct being used and modified.
* outptr [in/out] - The address where a pointer to newly allocated memory
* holding the result will be stored upon completion.
@@ -539,8 +550,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
else
user = userp;
- if(user)
- userlen = strlen(user);
+ userlen = strlen(user);
/* Get the machine's un-qualified host name as NTLM doesn't like the fully
qualified domain name */
@@ -553,7 +563,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
}
#if defined(USE_NTRESPONSES) && defined(USE_NTLM_V2)
- if(ntlm->target_info_len) {
+ if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) {
unsigned char ntbuffer[0x18];
unsigned char entropy[8];
unsigned char ntlmv2hash[0x18];
@@ -590,7 +600,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
#if defined(USE_NTRESPONSES) && defined(USE_NTLM2SESSION)
/* We don't support NTLM2 if we don't have USE_NTRESPONSES */
- if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM2_KEY) {
+ if(ntlm->flags & NTLMFLAG_NEGOTIATE_NTLM_KEY) {
unsigned char ntbuffer[0x18];
unsigned char tmp[0x18];
unsigned char md5sum[MD5_DIGEST_LENGTH];
@@ -622,7 +632,9 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
Curl_ntlm_core_lm_resp(ntbuffer, md5sum, ntresp);
/* End of NTLM2 Session code */
-
+ /* NTLM v2 session security is a misnomer because it is not NTLM v2.
+ It is NTLM v1 using the extended session security that is also
+ in NTLM v2 */
}
else
#endif
@@ -669,88 +681,88 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
hostoff = useroff + userlen;
/* Create the big type-3 message binary blob */
- size = snprintf((char *)ntlmbuf, NTLM_BUFSIZE,
- NTLMSSP_SIGNATURE "%c"
- "\x03%c%c%c" /* 32-bit type = 3 */
-
- "%c%c" /* LanManager length */
- "%c%c" /* LanManager allocated space */
- "%c%c" /* LanManager offset */
- "%c%c" /* 2 zeroes */
-
- "%c%c" /* NT-response length */
- "%c%c" /* NT-response allocated space */
- "%c%c" /* NT-response offset */
- "%c%c" /* 2 zeroes */
-
- "%c%c" /* domain length */
- "%c%c" /* domain allocated space */
- "%c%c" /* domain name offset */
- "%c%c" /* 2 zeroes */
-
- "%c%c" /* user length */
- "%c%c" /* user allocated space */
- "%c%c" /* user offset */
- "%c%c" /* 2 zeroes */
-
- "%c%c" /* host length */
- "%c%c" /* host allocated space */
- "%c%c" /* host offset */
- "%c%c" /* 2 zeroes */
-
- "%c%c" /* session key length (unknown purpose) */
- "%c%c" /* session key allocated space (unknown purpose) */
- "%c%c" /* session key offset (unknown purpose) */
- "%c%c" /* 2 zeroes */
-
- "%c%c%c%c", /* flags */
-
- /* domain string */
- /* user string */
- /* host string */
- /* LanManager response */
- /* NT response */
-
- 0, /* zero termination */
- 0, 0, 0, /* type-3 long, the 24 upper bits */
-
- SHORTPAIR(0x18), /* LanManager response length, twice */
- SHORTPAIR(0x18),
- SHORTPAIR(lmrespoff),
- 0x0, 0x0,
+ size = msnprintf((char *)ntlmbuf, NTLM_BUFSIZE,
+ NTLMSSP_SIGNATURE "%c"
+ "\x03%c%c%c" /* 32-bit type = 3 */
+
+ "%c%c" /* LanManager length */
+ "%c%c" /* LanManager allocated space */
+ "%c%c" /* LanManager offset */
+ "%c%c" /* 2 zeroes */
+
+ "%c%c" /* NT-response length */
+ "%c%c" /* NT-response allocated space */
+ "%c%c" /* NT-response offset */
+ "%c%c" /* 2 zeroes */
+
+ "%c%c" /* domain length */
+ "%c%c" /* domain allocated space */
+ "%c%c" /* domain name offset */
+ "%c%c" /* 2 zeroes */
+
+ "%c%c" /* user length */
+ "%c%c" /* user allocated space */
+ "%c%c" /* user offset */
+ "%c%c" /* 2 zeroes */
+
+ "%c%c" /* host length */
+ "%c%c" /* host allocated space */
+ "%c%c" /* host offset */
+ "%c%c" /* 2 zeroes */
+
+ "%c%c" /* session key length (unknown purpose) */
+ "%c%c" /* session key allocated space (unknown purpose) */
+ "%c%c" /* session key offset (unknown purpose) */
+ "%c%c" /* 2 zeroes */
+
+ "%c%c%c%c", /* flags */
+
+ /* domain string */
+ /* user string */
+ /* host string */
+ /* LanManager response */
+ /* NT response */
+
+ 0, /* zero termination */
+ 0, 0, 0, /* type-3 long, the 24 upper bits */
+
+ SHORTPAIR(0x18), /* LanManager response length, twice */
+ SHORTPAIR(0x18),
+ SHORTPAIR(lmrespoff),
+ 0x0, 0x0,
#ifdef USE_NTRESPONSES
- SHORTPAIR(ntresplen), /* NT-response length, twice */
- SHORTPAIR(ntresplen),
- SHORTPAIR(ntrespoff),
- 0x0, 0x0,
+ SHORTPAIR(ntresplen), /* NT-response length, twice */
+ SHORTPAIR(ntresplen),
+ SHORTPAIR(ntrespoff),
+ 0x0, 0x0,
#else
- 0x0, 0x0,
- 0x0, 0x0,
- 0x0, 0x0,
- 0x0, 0x0,
+ 0x0, 0x0,
+ 0x0, 0x0,
+ 0x0, 0x0,
+ 0x0, 0x0,
#endif
- SHORTPAIR(domlen),
- SHORTPAIR(domlen),
- SHORTPAIR(domoff),
- 0x0, 0x0,
+ SHORTPAIR(domlen),
+ SHORTPAIR(domlen),
+ SHORTPAIR(domoff),
+ 0x0, 0x0,
- SHORTPAIR(userlen),
- SHORTPAIR(userlen),
- SHORTPAIR(useroff),
- 0x0, 0x0,
+ SHORTPAIR(userlen),
+ SHORTPAIR(userlen),
+ SHORTPAIR(useroff),
+ 0x0, 0x0,
- SHORTPAIR(hostlen),
- SHORTPAIR(hostlen),
- SHORTPAIR(hostoff),
- 0x0, 0x0,
+ SHORTPAIR(hostlen),
+ SHORTPAIR(hostlen),
+ SHORTPAIR(hostoff),
+ 0x0, 0x0,
- 0x0, 0x0,
- 0x0, 0x0,
- 0x0, 0x0,
- 0x0, 0x0,
+ 0x0, 0x0,
+ 0x0, 0x0,
+ 0x0, 0x0,
+ 0x0, 0x0,
- LONGQUARTET(ntlm->flags));
+ LONGQUARTET(ntlm->flags));
DEBUGASSERT(size == 64);
DEBUGASSERT(size == (size_t)lmrespoff);
@@ -767,11 +779,14 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
});
#ifdef USE_NTRESPONSES
- if(size < (NTLM_BUFSIZE - ntresplen)) {
- DEBUGASSERT(size == (size_t)ntrespoff);
- memcpy(&ntlmbuf[size], ptr_ntresp, ntresplen);
- size += ntresplen;
+ /* ntresplen + size should not be risking an integer overflow here */
+ if(ntresplen + size > sizeof(ntlmbuf)) {
+ failf(data, "incoming NTLM message too big");
+ return CURLE_OUT_OF_MEMORY;
}
+ DEBUGASSERT(size == (size_t)ntrespoff);
+ memcpy(&ntlmbuf[size], ptr_ntresp, ntresplen);
+ size += ntresplen;
DEBUG_OUT({
fprintf(stderr, "\n ntresp=");
@@ -827,24 +842,24 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
return CURLE_CONV_FAILED;
/* Return with binary blob encoded into base64 */
- result = Curl_base64_encode(NULL, (char *)ntlmbuf, size, outptr, outlen);
+ result = Curl_base64_encode(data, (char *)ntlmbuf, size, outptr, outlen);
- Curl_auth_ntlm_cleanup(ntlm);
+ Curl_auth_cleanup_ntlm(ntlm);
return result;
}
/*
-* Curl_auth_ntlm_cleanup()
-*
-* This is used to clean up the NTLM specific data.
-*
-* Parameters:
-*
-* ntlm [in/out] - The NTLM data struct being cleaned up.
-*
-*/
-void Curl_auth_ntlm_cleanup(struct ntlmdata *ntlm)
+ * Curl_auth_cleanup_ntlm()
+ *
+ * This is used to clean up the NTLM specific data.
+ *
+ * Parameters:
+ *
+ * ntlm [in/out] - The NTLM data struct being cleaned up.
+ *
+ */
+void Curl_auth_cleanup_ntlm(struct ntlmdata *ntlm)
{
/* Free the target info */
Curl_safefree(ntlm->target_info);
diff --git a/Utilities/cmcurl/lib/vauth/ntlm.h b/Utilities/cmcurl/lib/vauth/ntlm.h
index f906a3c7a..1136b0f8d 100644
--- a/Utilities/cmcurl/lib/vauth/ntlm.h
+++ b/Utilities/cmcurl/lib/vauth/ntlm.h
@@ -1,5 +1,5 @@
-#ifndef HEADER_CURL_NTLM_H
-#define HEADER_CURL_NTLM_H
+#ifndef HEADER_VAUTH_NTLM_H
+#define HEADER_VAUTH_NTLM_H
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -140,4 +140,4 @@
#endif /* USE_NTLM */
-#endif /* HEADER_CURL_NTLM_H */
+#endif /* HEADER_VAUTH_NTLM_H */
diff --git a/Utilities/cmcurl/lib/vauth/ntlm_sspi.c b/Utilities/cmcurl/lib/vauth/ntlm_sspi.c
index c3305176d..589cca16c 100644
--- a/Utilities/cmcurl/lib/vauth/ntlm_sspi.c
+++ b/Utilities/cmcurl/lib/vauth/ntlm_sspi.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -29,6 +29,7 @@
#include "vauth/vauth.h"
#include "urldata.h"
#include "curl_base64.h"
+#include "curl_ntlm_core.h"
#include "warnless.h"
#include "curl_multibyte.h"
#include "sendf.h"
@@ -66,8 +67,11 @@ bool Curl_auth_is_ntlm_supported(void)
*
* Parameters:
*
+ * data [in] - The session handle.
* userp [in] - The user name in the format User or Domain\User.
- * passdwp [in] - The user's password.
+ * passwdp [in] - The user's password.
+ * service [in] - The service type such as http, smtp, pop or imap.
+ * host [in] - The host name.
* ntlm [in/out] - The NTLM data struct being used and modified.
* outptr [in/out] - The address where a pointer to newly allocated memory
* holding the result will be stored upon completion.
@@ -75,8 +79,11 @@ bool Curl_auth_is_ntlm_supported(void)
*
* Returns CURLE_OK on success.
*/
-CURLcode Curl_auth_create_ntlm_type1_message(const char *userp,
+CURLcode Curl_auth_create_ntlm_type1_message(struct Curl_easy *data,
+ const char *userp,
const char *passwdp,
+ const char *service,
+ const char *host,
struct ntlmdata *ntlm,
char **outptr, size_t *outlen)
{
@@ -88,7 +95,7 @@ CURLcode Curl_auth_create_ntlm_type1_message(const char *userp,
TimeStamp expiry; /* For Windows 9x compatibility of SSPI calls */
/* Clean up any former leftovers and initialise to defaults */
- Curl_auth_ntlm_cleanup(ntlm);
+ Curl_auth_cleanup_ntlm(ntlm);
/* Query the security package for NTLM */
status = s_pSecFn->QuerySecurityPackageInfo((TCHAR *) TEXT(SP_NAME_NTLM),
@@ -122,12 +129,10 @@ CURLcode Curl_auth_create_ntlm_type1_message(const char *userp,
ntlm->p_identity = NULL;
/* Allocate our credentials handle */
- ntlm->credentials = malloc(sizeof(CredHandle));
+ ntlm->credentials = calloc(1, sizeof(CredHandle));
if(!ntlm->credentials)
return CURLE_OUT_OF_MEMORY;
- memset(ntlm->credentials, 0, sizeof(CredHandle));
-
/* Acquire our credentials handle */
status = s_pSecFn->AcquireCredentialsHandle(NULL,
(TCHAR *) TEXT(SP_NAME_NTLM),
@@ -138,11 +143,13 @@ CURLcode Curl_auth_create_ntlm_type1_message(const char *userp,
return CURLE_LOGIN_DENIED;
/* Allocate our new context handle */
- ntlm->context = malloc(sizeof(CtxtHandle));
+ ntlm->context = calloc(1, sizeof(CtxtHandle));
if(!ntlm->context)
return CURLE_OUT_OF_MEMORY;
- memset(ntlm->context, 0, sizeof(CtxtHandle));
+ ntlm->spn = Curl_auth_build_spn(service, host, NULL);
+ if(!ntlm->spn)
+ return CURLE_OUT_OF_MEMORY;
/* Setup the type-1 "output" security buffer */
type_1_desc.ulVersion = SECBUFFER_VERSION;
@@ -154,7 +161,7 @@ CURLcode Curl_auth_create_ntlm_type1_message(const char *userp,
/* Generate our type-1 message */
status = s_pSecFn->InitializeSecurityContext(ntlm->credentials, NULL,
- (TCHAR *) TEXT(""),
+ ntlm->spn,
0, 0, SECURITY_NETWORK_DREP,
NULL, 0,
ntlm->context, &type_1_desc,
@@ -166,7 +173,7 @@ CURLcode Curl_auth_create_ntlm_type1_message(const char *userp,
return CURLE_RECV_ERROR;
/* Base64 encode the response */
- return Curl_base64_encode(NULL, (char *) ntlm->output_token,
+ return Curl_base64_encode(data, (char *) ntlm->output_token,
type_1_buf.cbBuffer, outptr, outlen);
}
@@ -227,7 +234,7 @@ CURLcode Curl_auth_decode_ntlm_type2_message(struct Curl_easy *data,
*
* data [in] - The session handle.
* userp [in] - The user name in the format User or Domain\User.
- * passdwp [in] - The user's password.
+ * passwdp [in] - The user's password.
* ntlm [in/out] - The NTLM data struct being used and modified.
* outptr [in/out] - The address where a pointer to newly allocated memory
* holding the result will be stored upon completion.
@@ -242,7 +249,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
char **outptr, size_t *outlen)
{
CURLcode result = CURLE_OK;
- SecBuffer type_2_buf;
+ SecBuffer type_2_bufs[2];
SecBuffer type_3_buf;
SecBufferDesc type_2_desc;
SecBufferDesc type_3_desc;
@@ -254,12 +261,39 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
(void) userp;
/* Setup the type-2 "input" security buffer */
- type_2_desc.ulVersion = SECBUFFER_VERSION;
- type_2_desc.cBuffers = 1;
- type_2_desc.pBuffers = &type_2_buf;
- type_2_buf.BufferType = SECBUFFER_TOKEN;
- type_2_buf.pvBuffer = ntlm->input_token;
- type_2_buf.cbBuffer = curlx_uztoul(ntlm->input_token_len);
+ type_2_desc.ulVersion = SECBUFFER_VERSION;
+ type_2_desc.cBuffers = 1;
+ type_2_desc.pBuffers = &type_2_bufs[0];
+ type_2_bufs[0].BufferType = SECBUFFER_TOKEN;
+ type_2_bufs[0].pvBuffer = ntlm->input_token;
+ type_2_bufs[0].cbBuffer = curlx_uztoul(ntlm->input_token_len);
+
+#ifdef SECPKG_ATTR_ENDPOINT_BINDINGS
+ /* ssl context comes from schannel.
+ * When extended protection is used in IIS server,
+ * we have to pass a second SecBuffer to the SecBufferDesc
+ * otherwise IIS will not pass the authentication (401 response).
+ * Minimum supported version is Windows 7.
+ * https://docs.microsoft.com/en-us/security-updates
+ * /SecurityAdvisories/2009/973811
+ */
+ if(ntlm->sslContext) {
+ SEC_CHANNEL_BINDINGS channelBindings;
+ SecPkgContext_Bindings pkgBindings;
+ pkgBindings.Bindings = &channelBindings;
+ status = s_pSecFn->QueryContextAttributes(
+ ntlm->sslContext,
+ SECPKG_ATTR_ENDPOINT_BINDINGS,
+ &pkgBindings
+ );
+ if(status == SEC_E_OK) {
+ type_2_desc.cBuffers++;
+ type_2_bufs[1].BufferType = SECBUFFER_CHANNEL_BINDINGS;
+ type_2_bufs[1].cbBuffer = pkgBindings.BindingsLength;
+ type_2_bufs[1].pvBuffer = pkgBindings.Bindings;
+ }
+ }
+#endif
/* Setup the type-3 "output" security buffer */
type_3_desc.ulVersion = SECBUFFER_VERSION;
@@ -272,7 +306,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
/* Generate our type-3 message */
status = s_pSecFn->InitializeSecurityContext(ntlm->credentials,
ntlm->context,
- (TCHAR *) TEXT(""),
+ ntlm->spn,
0, 0, SECURITY_NETWORK_DREP,
&type_2_desc,
0, ntlm->context,
@@ -289,13 +323,13 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
result = Curl_base64_encode(data, (char *) ntlm->output_token,
type_3_buf.cbBuffer, outptr, outlen);
- Curl_auth_ntlm_cleanup(ntlm);
+ Curl_auth_cleanup_ntlm(ntlm);
return result;
}
/*
- * Curl_auth_ntlm_cleanup()
+ * Curl_auth_cleanup_ntlm()
*
* This is used to clean up the NTLM specific data.
*
@@ -304,7 +338,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
* ntlm [in/out] - The NTLM data struct being cleaned up.
*
*/
-void Curl_auth_ntlm_cleanup(struct ntlmdata *ntlm)
+void Curl_auth_cleanup_ntlm(struct ntlmdata *ntlm)
{
/* Free our security context */
if(ntlm->context) {
@@ -330,6 +364,8 @@ void Curl_auth_ntlm_cleanup(struct ntlmdata *ntlm)
/* Reset any variables */
ntlm->token_max = 0;
+
+ Curl_safefree(ntlm->spn);
}
#endif /* USE_WINDOWS_SSPI && USE_NTLM */
diff --git a/Utilities/cmcurl/lib/vauth/oauth2.c b/Utilities/cmcurl/lib/vauth/oauth2.c
index 6288f89a3..b4e9f8e70 100644
--- a/Utilities/cmcurl/lib/vauth/oauth2.c
+++ b/Utilities/cmcurl/lib/vauth/oauth2.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -24,6 +24,9 @@
#include "curl_setup.h"
+#if !defined(CURL_DISABLE_IMAP) || !defined(CURL_DISABLE_SMTP) || \
+ !defined(CURL_DISABLE_POP3)
+
#include <curl/curl.h>
#include "urldata.h"
@@ -46,8 +49,8 @@
*
* data[in] - The session handle.
* user[in] - The user name.
- * host[in] - The host name(for OAUTHBEARER).
- * port[in] - The port(for OAUTHBEARER when not Port 80).
+ * host[in] - The host name.
+ * port[in] - The port(when not Port 80).
* bearer[in] - The bearer token.
* outptr[in / out] - The address where a pointer to newly allocated memory
* holding the result will be stored upon completion.
@@ -66,13 +69,11 @@ CURLcode Curl_auth_create_oauth_bearer_message(struct Curl_easy *data,
char *oauth = NULL;
/* Generate the message */
- if(host == NULL && (port == 0 || port == 80))
- oauth = aprintf("user=%s\1auth=Bearer %s\1\1", user, bearer);
- else if(port == 0 || port == 80)
- oauth = aprintf("user=%s\1host=%s\1auth=Bearer %s\1\1", user, host,
+ if(port == 0 || port == 80)
+ oauth = aprintf("n,a=%s,\1host=%s\1auth=Bearer %s\1\1", user, host,
bearer);
else
- oauth = aprintf("user=%s\1host=%s\1port=%ld\1auth=Bearer %s\1\1", user,
+ oauth = aprintf("n,a=%s,\1host=%s\1port=%ld\1auth=Bearer %s\1\1", user,
host, port, bearer);
if(!oauth)
return CURLE_OUT_OF_MEMORY;
@@ -84,3 +85,42 @@ CURLcode Curl_auth_create_oauth_bearer_message(struct Curl_easy *data,
return result;
}
+
+/*
+ * Curl_auth_create_xoauth_bearer_message()
+ *
+ * This is used to generate an already encoded XOAuth 2.0 message ready for
+ * sending to the recipient.
+ *
+ * Parameters:
+ *
+ * data[in] - The session handle.
+ * user[in] - The user name.
+ * bearer[in] - The bearer token.
+ * outptr[in / out] - The address where a pointer to newly allocated memory
+ * holding the result will be stored upon completion.
+ * outlen[out] - The length of the output message.
+ *
+ * Returns CURLE_OK on success.
+ */
+CURLcode Curl_auth_create_xoauth_bearer_message(struct Curl_easy *data,
+ const char *user,
+ const char *bearer,
+ char **outptr, size_t *outlen)
+{
+ CURLcode result = CURLE_OK;
+
+ /* Generate the message */
+ char *xoauth = aprintf("user=%s\1auth=Bearer %s\1\1", user, bearer);
+ if(!xoauth)
+ return CURLE_OUT_OF_MEMORY;
+
+ /* Base64 encode the reply */
+ result = Curl_base64_encode(data, xoauth, strlen(xoauth), outptr, outlen);
+
+ free(xoauth);
+
+ return result;
+}
+#endif /* disabled, no users */
+
diff --git a/Utilities/cmcurl/lib/vauth/spnego_gssapi.c b/Utilities/cmcurl/lib/vauth/spnego_gssapi.c
index 8840db8fd..5d43e1100 100644
--- a/Utilities/cmcurl/lib/vauth/spnego_gssapi.c
+++ b/Utilities/cmcurl/lib/vauth/spnego_gssapi.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -64,7 +64,7 @@ bool Curl_auth_is_spnego_supported(void)
*
* data [in] - The session handle.
* userp [in] - The user name in the format User or Domain\User.
- * passdwp [in] - The user's password.
+ * passwdp [in] - The user's password.
* service [in] - The service type such as http, smtp, pop or imap.
* host [in] - The host name.
* chlg64 [in] - The optional base64 encoded challenge message.
@@ -97,7 +97,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
/* We finished successfully our part of authentication, but server
* rejected it (since we're again here). Exit with an error since we
* can't invent anything better */
- Curl_auth_spnego_cleanup(nego);
+ Curl_auth_cleanup_spnego(nego);
return CURLE_LOGIN_DENIED;
}
@@ -170,7 +170,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
Curl_gss_log_error(data, "gss_init_sec_context() failed: ",
major_status, minor_status);
- return CURLE_OUT_OF_MEMORY;
+ return CURLE_LOGIN_DENIED;
}
if(!output_token.value || !output_token.length) {
@@ -180,6 +180,10 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
return CURLE_OUT_OF_MEMORY;
}
+ /* Free previous token */
+ if(nego->output_token.length && nego->output_token.value)
+ gss_release_buffer(&unused_status, &nego->output_token);
+
nego->output_token = output_token;
return CURLE_OK;
@@ -234,7 +238,7 @@ CURLcode Curl_auth_create_spnego_message(struct Curl_easy *data,
}
/*
- * Curl_auth_spnego_cleanup()
+ * Curl_auth_cleanup_spnego()
*
* This is used to clean up the SPNEGO (Negotiate) specific data.
*
@@ -243,7 +247,7 @@ CURLcode Curl_auth_create_spnego_message(struct Curl_easy *data,
* nego [in/out] - The Negotiate data struct being cleaned up.
*
*/
-void Curl_auth_spnego_cleanup(struct negotiatedata *nego)
+void Curl_auth_cleanup_spnego(struct negotiatedata *nego)
{
OM_uint32 minor_status;
@@ -269,6 +273,10 @@ void Curl_auth_spnego_cleanup(struct negotiatedata *nego)
/* Reset any variables */
nego->status = 0;
+ nego->noauthpersist = FALSE;
+ nego->havenoauthpersist = FALSE;
+ nego->havenegdata = FALSE;
+ nego->havemultiplerequests = FALSE;
}
#endif /* HAVE_GSSAPI && USE_SPNEGO */
diff --git a/Utilities/cmcurl/lib/vauth/spnego_sspi.c b/Utilities/cmcurl/lib/vauth/spnego_sspi.c
index a6797cdaf..4b21cc769 100644
--- a/Utilities/cmcurl/lib/vauth/spnego_sspi.c
+++ b/Utilities/cmcurl/lib/vauth/spnego_sspi.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -71,8 +71,8 @@ bool Curl_auth_is_spnego_supported(void)
* Parameters:
*
* data [in] - The session handle.
- * userp [in] - The user name in the format User or Domain\User.
- * passdwp [in] - The user's password.
+ * user [in] - The user name in the format User or Domain\User.
+ * password [in] - The user's password.
* service [in] - The service type such as http, smtp, pop or imap.
* host [in] - The host name.
* chlg64 [in] - The optional base64 encoded challenge message.
@@ -92,7 +92,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
size_t chlglen = 0;
unsigned char *chlg = NULL;
PSecPkgInfo SecurityPackage;
- SecBuffer chlg_buf;
+ SecBuffer chlg_buf[2];
SecBuffer resp_buf;
SecBufferDesc chlg_desc;
SecBufferDesc resp_desc;
@@ -107,7 +107,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
/* We finished successfully our part of authentication, but server
* rejected it (since we're again here). Exit with an error since we
* can't invent anything better */
- Curl_auth_spnego_cleanup(nego);
+ Curl_auth_cleanup_spnego(nego);
return CURLE_LOGIN_DENIED;
}
@@ -138,7 +138,7 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
}
if(!nego->credentials) {
- /* Do we have credientials to use or are we using single sign-on? */
+ /* Do we have credentials to use or are we using single sign-on? */
if(user && *user) {
/* Populate our identity structure */
result = Curl_create_sspi_identity(user, password, &nego->identity);
@@ -153,12 +153,10 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
nego->p_identity = NULL;
/* Allocate our credentials handle */
- nego->credentials = malloc(sizeof(CredHandle));
+ nego->credentials = calloc(1, sizeof(CredHandle));
if(!nego->credentials)
return CURLE_OUT_OF_MEMORY;
- memset(nego->credentials, 0, sizeof(CredHandle));
-
/* Acquire our credentials handle */
nego->status =
s_pSecFn->AcquireCredentialsHandle(NULL,
@@ -170,11 +168,9 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
return CURLE_LOGIN_DENIED;
/* Allocate our new context handle */
- nego->context = malloc(sizeof(CtxtHandle));
+ nego->context = calloc(1, sizeof(CtxtHandle));
if(!nego->context)
return CURLE_OUT_OF_MEMORY;
-
- memset(nego->context, 0, sizeof(CtxtHandle));
}
if(chlg64 && *chlg64) {
@@ -193,12 +189,39 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
}
/* Setup the challenge "input" security buffer */
- chlg_desc.ulVersion = SECBUFFER_VERSION;
- chlg_desc.cBuffers = 1;
- chlg_desc.pBuffers = &chlg_buf;
- chlg_buf.BufferType = SECBUFFER_TOKEN;
- chlg_buf.pvBuffer = chlg;
- chlg_buf.cbBuffer = curlx_uztoul(chlglen);
+ chlg_desc.ulVersion = SECBUFFER_VERSION;
+ chlg_desc.cBuffers = 1;
+ chlg_desc.pBuffers = &chlg_buf[0];
+ chlg_buf[0].BufferType = SECBUFFER_TOKEN;
+ chlg_buf[0].pvBuffer = chlg;
+ chlg_buf[0].cbBuffer = curlx_uztoul(chlglen);
+
+#ifdef SECPKG_ATTR_ENDPOINT_BINDINGS
+ /* ssl context comes from Schannel.
+ * When extended protection is used in IIS server,
+ * we have to pass a second SecBuffer to the SecBufferDesc
+ * otherwise IIS will not pass the authentication (401 response).
+ * Minimum supported version is Windows 7.
+ * https://docs.microsoft.com/en-us/security-updates
+ * /SecurityAdvisories/2009/973811
+ */
+ if(nego->sslContext) {
+ SEC_CHANNEL_BINDINGS channelBindings;
+ SecPkgContext_Bindings pkgBindings;
+ pkgBindings.Bindings = &channelBindings;
+ nego->status = s_pSecFn->QueryContextAttributes(
+ nego->sslContext,
+ SECPKG_ATTR_ENDPOINT_BINDINGS,
+ &pkgBindings
+ );
+ if(nego->status == SEC_E_OK) {
+ chlg_desc.cBuffers++;
+ chlg_buf[1].BufferType = SECBUFFER_CHANNEL_BINDINGS;
+ chlg_buf[1].cbBuffer = pkgBindings.BindingsLength;
+ chlg_buf[1].pvBuffer = pkgBindings.Bindings;
+ }
+ }
+#endif
}
/* Setup the response "output" security buffer */
@@ -225,8 +248,9 @@ CURLcode Curl_auth_decode_spnego_message(struct Curl_easy *data,
free(chlg);
if(GSS_ERROR(nego->status)) {
+ char buffer[STRERROR_LEN];
failf(data, "InitializeSecurityContext failed: %s",
- Curl_sspi_strerror(data->easy_conn, nego->status));
+ Curl_sspi_strerror(nego->status, buffer, sizeof(buffer)));
return CURLE_OUT_OF_MEMORY;
}
@@ -283,7 +307,7 @@ CURLcode Curl_auth_create_spnego_message(struct Curl_easy *data,
}
/*
- * Curl_auth_spnego_cleanup()
+ * Curl_auth_cleanup_spnego()
*
* This is used to clean up the SPNEGO (Negotiate) specific data.
*
@@ -292,7 +316,7 @@ CURLcode Curl_auth_create_spnego_message(struct Curl_easy *data,
* nego [in/out] - The Negotiate data struct being cleaned up.
*
*/
-void Curl_auth_spnego_cleanup(struct negotiatedata *nego)
+void Curl_auth_cleanup_spnego(struct negotiatedata *nego)
{
/* Free our security context */
if(nego->context) {
@@ -319,6 +343,10 @@ void Curl_auth_spnego_cleanup(struct negotiatedata *nego)
/* Reset any variables */
nego->status = 0;
nego->token_max = 0;
+ nego->noauthpersist = FALSE;
+ nego->havenoauthpersist = FALSE;
+ nego->havenegdata = FALSE;
+ nego->havemultiplerequests = FALSE;
}
#endif /* USE_WINDOWS_SSPI && USE_SPNEGO */
diff --git a/Utilities/cmcurl/lib/vauth/vauth.c b/Utilities/cmcurl/lib/vauth/vauth.c
index b995f34e2..a9c5c9c4f 100644
--- a/Utilities/cmcurl/lib/vauth/vauth.c
+++ b/Utilities/cmcurl/lib/vauth/vauth.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2014 - 2016, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2014 - 2019, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -105,26 +105,26 @@ TCHAR *Curl_auth_build_spn(const char *service, const char *host,
#endif /* USE_WINDOWS_SSPI */
/*
-* Curl_auth_user_contains_domain()
-*
-* This is used to test if the specified user contains a Windows domain name as
-* follows:
-*
-* User\Domain (Down-level Logon Name)
-* User/Domain (curl Down-level format - for compatibility with existing code)
-* User@Domain (User Principal Name)
-*
-* Note: The user name may be empty when using a GSS-API library or Windows SSPI
-* as the user and domain are either obtained from the credientals cache when
-* using GSS-API or via the currently logged in user's credientals when using
-* Windows SSPI.
-*
-* Parameters:
-*
-* user [in] - The user name.
-*
-* Returns TRUE on success; otherwise FALSE.
-*/
+ * Curl_auth_user_contains_domain()
+ *
+ * This is used to test if the specified user contains a Windows domain name as
+ * follows:
+ *
+ * Domain\User (Down-level Logon Name)
+ * Domain/User (curl Down-level format - for compatibility with existing code)
+ * User@Domain (User Principal Name)
+ *
+ * Note: The user name may be empty when using a GSS-API library or Windows
+ * SSPI as the user and domain are either obtained from the credentials cache
+ * when using GSS-API or via the currently logged in user's credentials when
+ * using Windows SSPI.
+ *
+ * Parameters:
+ *
+ * user [in] - The user name.
+ *
+ * Returns TRUE on success; otherwise FALSE.
+ */
bool Curl_auth_user_contains_domain(const char *user)
{
bool valid = FALSE;
@@ -138,7 +138,7 @@ bool Curl_auth_user_contains_domain(const char *user)
}
#if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)
else
- /* User and domain are obtained from the GSS-API credientials cache or the
+ /* User and domain are obtained from the GSS-API credentials cache or the
currently logged in user from Windows */
valid = TRUE;
#endif
diff --git a/Utilities/cmcurl/lib/vauth/vauth.h b/Utilities/cmcurl/lib/vauth/vauth.h
index 9d61228c3..73bd25ed5 100644
--- a/Utilities/cmcurl/lib/vauth/vauth.h
+++ b/Utilities/cmcurl/lib/vauth/vauth.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2014 - 2016, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2014 - 2019, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -60,8 +60,9 @@ bool Curl_auth_user_contains_domain(const char *user);
/* This is used to generate a base64 encoded PLAIN cleartext message */
CURLcode Curl_auth_create_plain_message(struct Curl_easy *data,
- const char *userp,
- const char *passwdp,
+ const char *authzid,
+ const char *authcid,
+ const char *passwd,
char **outptr, size_t *outlen);
/* This is used to generate a base64 encoded LOGIN cleartext message */
@@ -119,8 +120,11 @@ void Curl_auth_digest_cleanup(struct digestdata *digest);
bool Curl_auth_is_ntlm_supported(void);
/* This is used to generate a base64 encoded NTLM type-1 message */
-CURLcode Curl_auth_create_ntlm_type1_message(const char *userp,
+CURLcode Curl_auth_create_ntlm_type1_message(struct Curl_easy *data,
+ const char *userp,
const char *passwdp,
+ const char *service,
+ const char *host,
struct ntlmdata *ntlm,
char **outptr,
size_t *outlen);
@@ -138,7 +142,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data,
char **outptr, size_t *outlen);
/* This is used to clean up the NTLM specific data */
-void Curl_auth_ntlm_cleanup(struct ntlmdata *ntlm);
+void Curl_auth_cleanup_ntlm(struct ntlmdata *ntlm);
#endif /* USE_NTLM */
/* This is used to generate a base64 encoded OAuth 2.0 message */
@@ -148,6 +152,13 @@ CURLcode Curl_auth_create_oauth_bearer_message(struct Curl_easy *data,
const long port,
const char *bearer,
char **outptr, size_t *outlen);
+
+/* This is used to generate a base64 encoded XOAuth 2.0 message */
+CURLcode Curl_auth_create_xoauth_bearer_message(struct Curl_easy *data,
+ const char *user,
+ const char *bearer,
+ char **outptr, size_t *outlen);
+
#if defined(USE_KERBEROS5)
/* This is used to evaluate if GSSAPI (Kerberos V5) is supported */
bool Curl_auth_is_gssapi_supported(void);
@@ -173,7 +184,7 @@ CURLcode Curl_auth_create_gssapi_security_message(struct Curl_easy *data,
size_t *outlen);
/* This is used to clean up the GSSAPI specific data */
-void Curl_auth_gssapi_cleanup(struct kerberos5data *krb5);
+void Curl_auth_cleanup_gssapi(struct kerberos5data *krb5);
#endif /* USE_KERBEROS5 */
#if defined(USE_SPNEGO)
@@ -197,7 +208,7 @@ CURLcode Curl_auth_create_spnego_message(struct Curl_easy *data,
char **outptr, size_t *outlen);
/* This is used to clean up the SPNEGO specifiec data */
-void Curl_auth_spnego_cleanup(struct negotiatedata *nego);
+void Curl_auth_cleanup_spnego(struct negotiatedata *nego);
#endif /* USE_SPNEGO */
diff --git a/Utilities/cmcurl/lib/version.c b/Utilities/cmcurl/lib/version.c
index 3d1776813..14b0531d3 100644
--- a/Utilities/cmcurl/lib/version.c
+++ b/Utilities/cmcurl/lib/version.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -26,11 +26,12 @@
#include "urldata.h"
#include "vtls/vtls.h"
#include "http2.h"
+#include "ssh.h"
#include "curl_printf.h"
#ifdef USE_ARES
# if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && \
- (defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
+ (defined(WIN32) || defined(__SYMBIAN32__))
# define CARES_STATICLIB
# endif
# include <ares.h>
@@ -64,6 +65,18 @@
#define CURL_LIBSSH2_VERSION LIBSSH2_VERSION
#endif
+#ifdef HAVE_ZLIB_H
+#include <zlib.h>
+#ifdef __SYMBIAN32__
+/* zlib pollutes the namespace with this definition */
+#undef WIN32
+#endif
+#endif
+
+#ifdef HAVE_BROTLI
+#include <brotli/decode.h>
+#endif
+
void Curl_version_init(void);
/* For thread safety purposes this function is called by global_init so that
@@ -74,6 +87,18 @@ void Curl_version_init(void)
curl_version_info(CURLVERSION_NOW);
}
+#ifdef HAVE_BROTLI
+static size_t brotli_version(char *buf, size_t bufsz)
+{
+ uint32_t brotli_version = BrotliDecoderVersion();
+ unsigned int major = brotli_version >> 24;
+ unsigned int minor = (brotli_version & 0x00FFFFFF) >> 12;
+ unsigned int patch = brotli_version & 0x00000FFF;
+
+ return msnprintf(buf, bufsz, "%u.%u.%u", major, minor, patch);
+}
+#endif
+
char *curl_version(void)
{
static bool initialized;
@@ -101,46 +126,59 @@ char *curl_version(void)
}
#ifdef HAVE_LIBZ
- len = snprintf(ptr, left, " zlib/%s", zlibVersion());
+ len = msnprintf(ptr, left, " zlib/%s", zlibVersion());
+ left -= len;
+ ptr += len;
+#endif
+#ifdef HAVE_BROTLI
+ len = msnprintf(ptr, left, "%s", " brotli/");
+ left -= len;
+ ptr += len;
+ len = brotli_version(ptr, left);
left -= len;
ptr += len;
#endif
#ifdef USE_ARES
/* this function is only present in c-ares, not in the original ares */
- len = snprintf(ptr, left, " c-ares/%s", ares_version(NULL));
+ len = msnprintf(ptr, left, " c-ares/%s", ares_version(NULL));
left -= len;
ptr += len;
#endif
#ifdef USE_LIBIDN2
if(idn2_check_version(IDN2_VERSION)) {
- len = snprintf(ptr, left, " libidn2/%s", idn2_check_version(NULL));
+ len = msnprintf(ptr, left, " libidn2/%s", idn2_check_version(NULL));
left -= len;
ptr += len;
}
#endif
#ifdef USE_LIBPSL
- len = snprintf(ptr, left, " libpsl/%s", psl_get_version());
+ len = msnprintf(ptr, left, " libpsl/%s", psl_get_version());
left -= len;
ptr += len;
#endif
#ifdef USE_WIN32_IDN
- len = snprintf(ptr, left, " WinIDN");
+ len = msnprintf(ptr, left, " WinIDN");
left -= len;
ptr += len;
#endif
#if defined(HAVE_ICONV) && defined(CURL_DOES_CONVERSIONS)
#ifdef _LIBICONV_VERSION
- len = snprintf(ptr, left, " iconv/%d.%d",
- _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255);
+ len = msnprintf(ptr, left, " iconv/%d.%d",
+ _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 255);
#else
/* version unknown */
- len = snprintf(ptr, left, " iconv");
+ len = msnprintf(ptr, left, " iconv");
#endif /* _LIBICONV_VERSION */
left -= len;
ptr += len;
#endif
#ifdef USE_LIBSSH2
- len = snprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_VERSION);
+ len = msnprintf(ptr, left, " libssh2/%s", CURL_LIBSSH2_VERSION);
+ left -= len;
+ ptr += len;
+#endif
+#ifdef USE_LIBSSH
+ len = msnprintf(ptr, left, " libssh/%s", CURL_LIBSSH_VERSION);
left -= len;
ptr += len;
#endif
@@ -159,14 +197,14 @@ char *curl_version(void)
else
suff[0] = '\0';
- snprintf(ptr, left, " librtmp/%d.%d%s",
- RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff,
- suff);
+ msnprintf(ptr, left, " librtmp/%d.%d%s",
+ RTMP_LIB_VERSION >> 16, (RTMP_LIB_VERSION >> 8) & 0xff,
+ suff);
/*
If another lib version is added below this one, this code would
also have to do:
- len = what snprintf() returned
+ len = what msnprintf() returned
left -= len;
ptr += len;
@@ -174,6 +212,10 @@ char *curl_version(void)
}
#endif
+ /* Silent scan-build even if librtmp is not enabled. */
+ (void) left;
+ (void) ptr;
+
initialized = true;
return version;
}
@@ -232,10 +274,8 @@ static const char * const protocols[] = {
#ifndef CURL_DISABLE_RTSP
"rtsp",
#endif
-#ifdef USE_LIBSSH2
+#if defined(USE_SSH)
"scp",
-#endif
-#ifdef USE_LIBSSH2
"sftp",
#endif
#if !defined(CURL_DISABLE_SMB) && defined(USE_NTLM) && \
@@ -324,8 +364,14 @@ static curl_version_info_data version_info = {
#if defined(USE_LIBPSL)
| CURL_VERSION_PSL
#endif
-#if defined(HTTPS_PROXY_SUPPORT)
- | CURL_VERSION_HTTPS_PROXY
+#if defined(CURL_WITH_MULTI_SSL)
+ | CURL_VERSION_MULTI_SSL
+#endif
+#if defined(HAVE_BROTLI)
+ | CURL_VERSION_BROTLI
+#endif
+#if defined(USE_ALTSVC)
+ | CURL_VERSION_ALTSVC
#endif
,
NULL, /* ssl_version */
@@ -337,17 +383,26 @@ static curl_version_info_data version_info = {
NULL, /* libidn version */
0, /* iconv version */
NULL, /* ssh lib version */
+ 0, /* brotli_ver_num */
+ NULL, /* brotli version */
};
curl_version_info_data *curl_version_info(CURLversion stamp)
{
static bool initialized;
-#ifdef USE_LIBSSH2
+#if defined(USE_SSH)
static char ssh_buffer[80];
#endif
#ifdef USE_SSL
+#ifdef CURL_WITH_MULTI_SSL
+ static char ssl_buffer[200];
+#else
static char ssl_buffer[80];
#endif
+#endif
+#ifdef HAVE_BROTLI
+ static char brotli_buffer[80];
+#endif
if(initialized)
return &version_info;
@@ -355,6 +410,10 @@ curl_version_info_data *curl_version_info(CURLversion stamp)
#ifdef USE_SSL
Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
version_info.ssl_version = ssl_buffer;
+ if(Curl_ssl->supports & SSLSUPP_HTTPS_PROXY)
+ version_info.features |= CURL_VERSION_HTTPS_PROXY;
+ else
+ version_info.features &= ~CURL_VERSION_HTTPS_PROXY;
#endif
#ifdef HAVE_LIBZ
@@ -387,11 +446,20 @@ curl_version_info_data *curl_version_info(CURLversion stamp)
#endif /* _LIBICONV_VERSION */
#endif
-#ifdef USE_LIBSSH2
- snprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION);
+#if defined(USE_LIBSSH2)
+ msnprintf(ssh_buffer, sizeof(ssh_buffer), "libssh2/%s", LIBSSH2_VERSION);
+ version_info.libssh_version = ssh_buffer;
+#elif defined(USE_LIBSSH)
+ msnprintf(ssh_buffer, sizeof(ssh_buffer), "libssh/%s", CURL_LIBSSH_VERSION);
version_info.libssh_version = ssh_buffer;
#endif
+#ifdef HAVE_BROTLI
+ version_info.brotli_ver_num = BrotliDecoderVersion();
+ brotli_version(brotli_buffer, sizeof(brotli_buffer));
+ version_info.brotli_version = brotli_buffer;
+#endif
+
(void)stamp; /* avoid compiler warnings, we don't use this */
initialized = true;
diff --git a/Utilities/cmcurl/lib/vtls/axtls.c b/Utilities/cmcurl/lib/vtls/axtls.c
deleted file mode 100644
index f0e376640..000000000
--- a/Utilities/cmcurl/lib/vtls/axtls.c
+++ /dev/null
@@ -1,706 +0,0 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2010, DirecTV, Contact: Eric Hu, <ehu@directv.com>.
- * Copyright (C) 2010 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.haxx.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-/*
- * Source file for all axTLS-specific code for the TLS/SSL layer. No code
- * but vtls.c should ever call or use these functions.
- */
-
-#include "curl_setup.h"
-
-#ifdef USE_AXTLS
-#include <axTLS/config.h>
-#include <axTLS/ssl.h>
-#include "axtls.h"
-
-#include "sendf.h"
-#include "inet_pton.h"
-#include "vtls.h"
-#include "parsedate.h"
-#include "connect.h" /* for the connect timeout */
-#include "select.h"
-#include "curl_printf.h"
-#include "hostcheck.h"
-#include <unistd.h>
-
-/* The last #include files should be: */
-#include "curl_memory.h"
-#include "memdebug.h"
-
-
-/* Global axTLS init, called from Curl_ssl_init() */
-int Curl_axtls_init(void)
-{
-/* axTLS has no global init. Everything is done through SSL and SSL_CTX
- * structs stored in connectdata structure. Perhaps can move to axtls.h.
- */
- return 1;
-}
-
-int Curl_axtls_cleanup(void)
-{
- /* axTLS has no global cleanup. Perhaps can move this to axtls.h. */
- return 1;
-}
-
-static CURLcode map_error_to_curl(int axtls_err)
-{
- switch(axtls_err) {
- case SSL_ERROR_NOT_SUPPORTED:
- case SSL_ERROR_INVALID_VERSION:
- case -70: /* protocol version alert from server */
- return CURLE_UNSUPPORTED_PROTOCOL;
- break;
- case SSL_ERROR_NO_CIPHER:
- return CURLE_SSL_CIPHER;
- break;
- case SSL_ERROR_BAD_CERTIFICATE: /* this may be bad server cert too */
- case SSL_ERROR_NO_CERT_DEFINED:
- case -42: /* bad certificate alert from server */
- case -43: /* unsupported cert alert from server */
- case -44: /* cert revoked alert from server */
- case -45: /* cert expired alert from server */
- case -46: /* cert unknown alert from server */
- return CURLE_SSL_CERTPROBLEM;
- break;
- case SSL_X509_ERROR(X509_NOT_OK):
- case SSL_X509_ERROR(X509_VFY_ERROR_NO_TRUSTED_CERT):
- case SSL_X509_ERROR(X509_VFY_ERROR_BAD_SIGNATURE):
- case SSL_X509_ERROR(X509_VFY_ERROR_NOT_YET_VALID):
- case SSL_X509_ERROR(X509_VFY_ERROR_EXPIRED):
- case SSL_X509_ERROR(X509_VFY_ERROR_SELF_SIGNED):
- case SSL_X509_ERROR(X509_VFY_ERROR_INVALID_CHAIN):
- case SSL_X509_ERROR(X509_VFY_ERROR_UNSUPPORTED_DIGEST):
- case SSL_X509_ERROR(X509_INVALID_PRIV_KEY):
- return CURLE_PEER_FAILED_VERIFICATION;
- break;
- case -48: /* unknown ca alert from server */
- return CURLE_SSL_CACERT;
- break;
- case -49: /* access denied alert from server */
- return CURLE_REMOTE_ACCESS_DENIED;
- break;
- case SSL_ERROR_CONN_LOST:
- case SSL_ERROR_SOCK_SETUP_FAILURE:
- case SSL_ERROR_INVALID_HANDSHAKE:
- case SSL_ERROR_INVALID_PROT_MSG:
- case SSL_ERROR_INVALID_HMAC:
- case SSL_ERROR_INVALID_SESSION:
- case SSL_ERROR_INVALID_KEY: /* it's too bad this doesn't map better */
- case SSL_ERROR_FINISHED_INVALID:
- case SSL_ERROR_NO_CLIENT_RENOG:
- default:
- return CURLE_SSL_CONNECT_ERROR;
- break;
- }
-}
-
-static Curl_recv axtls_recv;
-static Curl_send axtls_send;
-
-static void free_ssl_structs(struct ssl_connect_data *connssl)
-{
- if(connssl->ssl) {
- ssl_free(connssl->ssl);
- connssl->ssl = NULL;
- }
- if(connssl->ssl_ctx) {
- ssl_ctx_free(connssl->ssl_ctx);
- connssl->ssl_ctx = NULL;
- }
-}
-
-/*
- * For both blocking and non-blocking connects, this function sets up the
- * ssl context and state. This function is called after the TCP connect
- * has completed.
- */
-static CURLcode connect_prep(struct connectdata *conn, int sockindex)
-{
- struct Curl_easy *data = conn->data;
- SSL_CTX *ssl_ctx;
- SSL *ssl = NULL;
- int cert_types[] = {SSL_OBJ_X509_CERT, SSL_OBJ_PKCS12, 0};
- int key_types[] = {SSL_OBJ_RSA_KEY, SSL_OBJ_PKCS8, SSL_OBJ_PKCS12, 0};
- int i, ssl_fcn_return;
-
- /* Assuming users will not compile in custom key/cert to axTLS.
- * Also, even for blocking connects, use axTLS non-blocking feature.
- */
- uint32_t client_option = SSL_NO_DEFAULT_KEY |
- SSL_SERVER_VERIFY_LATER |
- SSL_CONNECT_IN_PARTS;
-
- if(conn->ssl[sockindex].state == ssl_connection_complete)
- /* to make us tolerant against being called more than once for the
- same connection */
- return CURLE_OK;
-
- if(SSL_CONN_CONFIG(version_max) != CURL_SSLVERSION_MAX_NONE) {
- failf(data, "axtls does not support CURL_SSLVERSION_MAX");
- return CURLE_SSL_CONNECT_ERROR;
- }
-
-
- /* axTLS only supports TLSv1 */
- /* check to see if we've been told to use an explicit SSL/TLS version */
- switch(SSL_CONN_CONFIG(version)) {
- case CURL_SSLVERSION_DEFAULT:
- case CURL_SSLVERSION_TLSv1:
- break;
- default:
- failf(data, "axTLS only supports TLS 1.0 and 1.1, "
- "and it cannot be specified which one to use");
- return CURLE_SSL_CONNECT_ERROR;
- }
-
-#ifdef AXTLSDEBUG
- client_option |= SSL_DISPLAY_STATES | SSL_DISPLAY_RSA | SSL_DISPLAY_CERTS;
-#endif /* AXTLSDEBUG */
-
- /* Allocate an SSL_CTX struct */
- ssl_ctx = ssl_ctx_new(client_option, SSL_DEFAULT_CLNT_SESS);
- if(ssl_ctx == NULL) {
- failf(data, "unable to create client SSL context");
- return CURLE_SSL_CONNECT_ERROR;
- }
-
- conn->ssl[sockindex].ssl_ctx = ssl_ctx;
- conn->ssl[sockindex].ssl = NULL;
-
- /* Load the trusted CA cert bundle file */
- if(SSL_CONN_CONFIG(CAfile)) {
- if(ssl_obj_load(ssl_ctx, SSL_OBJ_X509_CACERT,
- SSL_CONN_CONFIG(CAfile), NULL) != SSL_OK) {
- infof(data, "error reading ca cert file %s \n",
- SSL_CONN_CONFIG(CAfile));
- if(SSL_CONN_CONFIG(verifypeer)) {
- return CURLE_SSL_CACERT_BADFILE;
- }
- }
- else
- infof(data, "found certificates in %s\n", SSL_CONN_CONFIG(CAfile));
- }
-
- /* gtls.c tasks we're skipping for now:
- * 1) certificate revocation list checking
- * 2) dns name assignment to host
- * 3) set protocol priority. axTLS is TLSv1 only, so can probably ignore
- * 4) set certificate priority. axTLS ignores type and sends certs in
- * order added. can probably ignore this.
- */
-
- /* Load client certificate */
- if(SSL_SET_OPTION(cert)) {
- i=0;
- /* Instead of trying to analyze cert type here, let axTLS try them all. */
- while(cert_types[i] != 0) {
- ssl_fcn_return = ssl_obj_load(ssl_ctx, cert_types[i],
- SSL_SET_OPTION(cert), NULL);
- if(ssl_fcn_return == SSL_OK) {
- infof(data, "successfully read cert file %s \n",
- SSL_SET_OPTION(cert));
- break;
- }
- i++;
- }
- /* Tried all cert types, none worked. */
- if(cert_types[i] == 0) {
- failf(data, "%s is not x509 or pkcs12 format",
- SSL_SET_OPTION(cert));
- return CURLE_SSL_CERTPROBLEM;
- }
- }
-
- /* Load client key.
- If a pkcs12 file successfully loaded a cert, then there's nothing to do
- because the key has already been loaded. */
- if(SSL_SET_OPTION(key) && cert_types[i] != SSL_OBJ_PKCS12) {
- i=0;
- /* Instead of trying to analyze key type here, let axTLS try them all. */
- while(key_types[i] != 0) {
- ssl_fcn_return = ssl_obj_load(ssl_ctx, key_types[i],
- SSL_SET_OPTION(key), NULL);
- if(ssl_fcn_return == SSL_OK) {
- infof(data, "successfully read key file %s \n",
- SSL_SET_OPTION(key));
- break;
- }
- i++;
- }
- /* Tried all key types, none worked. */
- if(key_types[i] == 0) {
- failf(data, "Failure: %s is not a supported key file",
- SSL_SET_OPTION(key));
- return CURLE_SSL_CONNECT_ERROR;
- }
- }
-
- /* gtls.c does more here that is being left out for now
- * 1) set session credentials. can probably ignore since axtls puts this
- * info in the ssl_ctx struct
- * 2) setting up callbacks. these seem gnutls specific
- */
-
- if(SSL_SET_OPTION(primary.sessionid)) {
- const uint8_t *ssl_sessionid;
- size_t ssl_idsize;
-
- /* In axTLS, handshaking happens inside ssl_client_new. */
- Curl_ssl_sessionid_lock(conn);
- if(!Curl_ssl_getsessionid(conn, (void **) &ssl_sessionid, &ssl_idsize,
- sockindex)) {
- /* we got a session id, use it! */
- infof(data, "SSL re-using session ID\n");
- ssl = ssl_client_new(ssl_ctx, conn->sock[sockindex],
- ssl_sessionid, (uint8_t)ssl_idsize, NULL);
- }
- Curl_ssl_sessionid_unlock(conn);
- }
-
- if(!ssl)
- ssl = ssl_client_new(ssl_ctx, conn->sock[sockindex], NULL, 0, NULL);
-
- conn->ssl[sockindex].ssl = ssl;
- return CURLE_OK;
-}
-
-/*
- * For both blocking and non-blocking connects, this function finalizes the
- * SSL connection.
- */
-static CURLcode connect_finish(struct connectdata *conn, int sockindex)
-{
- struct Curl_easy *data = conn->data;
- SSL *ssl = conn->ssl[sockindex].ssl;
- const char *peer_CN;
- uint32_t dns_altname_index;
- const char *dns_altname;
- int8_t found_subject_alt_names = 0;
- int8_t found_subject_alt_name_matching_conn = 0;
- const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
- conn->host.name;
- const char * const dispname = SSL_IS_PROXY() ?
- conn->http_proxy.host.dispname : conn->host.dispname;
-
- /* Here, gtls.c gets the peer certificates and fails out depending on
- * settings in "data." axTLS api doesn't have get cert chain fcn, so omit?
- */
-
- /* Verify server's certificate */
- if(SSL_CONN_CONFIG(verifypeer)) {
- if(ssl_verify_cert(ssl) != SSL_OK) {
- Curl_axtls_close(conn, sockindex);
- failf(data, "server cert verify failed");
- return CURLE_PEER_FAILED_VERIFICATION;
- }
- }
- else
- infof(data, "\t server certificate verification SKIPPED\n");
-
- /* Here, gtls.c does issuer verification. axTLS has no straightforward
- * equivalent, so omitting for now.*/
-
- /* Here, gtls.c does the following
- * 1) x509 hostname checking per RFC2818. axTLS doesn't support this, but
- * it seems useful. This is now implemented, by Oscar Koeroo
- * 2) checks cert validity based on time. axTLS does this in ssl_verify_cert
- * 3) displays a bunch of cert information. axTLS doesn't support most of
- * this, but a couple fields are available.
- */
-
- /* There is no (DNS) Altnames count in the version 1.4.8 API. There is a
- risk of an inifite loop */
- for(dns_altname_index = 0; ; dns_altname_index++) {
- dns_altname = ssl_get_cert_subject_alt_dnsname(ssl, dns_altname_index);
- if(dns_altname == NULL) {
- break;
- }
- found_subject_alt_names = 1;
-
- infof(data, "\tComparing subject alt name DNS with hostname: %s <-> %s\n",
- dns_altname, hostname);
- if(Curl_cert_hostcheck(dns_altname, hostname)) {
- found_subject_alt_name_matching_conn = 1;
- break;
- }
- }
-
- /* RFC2818 checks */
- if(found_subject_alt_names && !found_subject_alt_name_matching_conn) {
- if(SSL_CONN_CONFIG(verifyhost)) {
- /* Break connection ! */
- Curl_axtls_close(conn, sockindex);
- failf(data, "\tsubjectAltName(s) do not match %s\n", dispname);
- return CURLE_PEER_FAILED_VERIFICATION;
- }
- else
- infof(data, "\tsubjectAltName(s) do not match %s\n", dispname);
- }
- else if(found_subject_alt_names == 0) {
- /* Per RFC2818, when no Subject Alt Names were available, examine the peer
- CN as a legacy fallback */
- peer_CN = ssl_get_cert_dn(ssl, SSL_X509_CERT_COMMON_NAME);
- if(peer_CN == NULL) {
- if(SSL_CONN_CONFIG(verifyhost)) {
- Curl_axtls_close(conn, sockindex);
- failf(data, "unable to obtain common name from peer certificate");
- return CURLE_PEER_FAILED_VERIFICATION;
- }
- else
- infof(data, "unable to obtain common name from peer certificate");
- }
- else {
- if(!Curl_cert_hostcheck((const char *)peer_CN, hostname)) {
- if(SSL_CONN_CONFIG(verifyhost)) {
- /* Break connection ! */
- Curl_axtls_close(conn, sockindex);
- failf(data, "\tcommon name \"%s\" does not match \"%s\"\n",
- peer_CN, dispname);
- return CURLE_PEER_FAILED_VERIFICATION;
- }
- else
- infof(data, "\tcommon name \"%s\" does not match \"%s\"\n",
- peer_CN, dispname);
- }
- }
- }
-
- /* General housekeeping */
- conn->ssl[sockindex].state = ssl_connection_complete;
- conn->recv[sockindex] = axtls_recv;
- conn->send[sockindex] = axtls_send;
-
- /* Put our freshly minted SSL session in cache */
- if(SSL_SET_OPTION(primary.sessionid)) {
- const uint8_t *ssl_sessionid = ssl_get_session_id(ssl);
- size_t ssl_idsize = ssl_get_session_id_size(ssl);
- Curl_ssl_sessionid_lock(conn);
- if(Curl_ssl_addsessionid(conn, (void *) ssl_sessionid, ssl_idsize,
- sockindex) != CURLE_OK)
- infof(data, "failed to add session to cache\n");
- Curl_ssl_sessionid_unlock(conn);
- }
-
- return CURLE_OK;
-}
-
-/*
- * Use axTLS's non-blocking connection feature to open an SSL connection.
- * This is called after a TCP connection is already established.
- */
-CURLcode Curl_axtls_connect_nonblocking(
- struct connectdata *conn,
- int sockindex,
- bool *done)
-{
- CURLcode conn_step;
- int ssl_fcn_return;
- int i;
-
- *done = FALSE;
- /* connectdata is calloc'd and connecting_state is only changed in this
- function, so this is safe, as the state is effectively initialized. */
- if(conn->ssl[sockindex].connecting_state == ssl_connect_1) {
- conn_step = connect_prep(conn, sockindex);
- if(conn_step != CURLE_OK) {
- Curl_axtls_close(conn, sockindex);
- return conn_step;
- }
- conn->ssl[sockindex].connecting_state = ssl_connect_2;
- }
-
- if(conn->ssl[sockindex].connecting_state == ssl_connect_2) {
- /* Check to make sure handshake was ok. */
- if(ssl_handshake_status(conn->ssl[sockindex].ssl) != SSL_OK) {
- /* Loop to perform more work in between sleeps. This is work around the
- fact that axtls does not expose any knowledge about when work needs
- to be performed. This can save ~25% of time on SSL handshakes. */
- for(i=0; i<5; i++) {
- ssl_fcn_return = ssl_read(conn->ssl[sockindex].ssl, NULL);
- if(ssl_fcn_return < 0) {
- Curl_axtls_close(conn, sockindex);
- ssl_display_error(ssl_fcn_return); /* goes to stdout. */
- return map_error_to_curl(ssl_fcn_return);
- }
- return CURLE_OK;
- }
- }
- infof(conn->data, "handshake completed successfully\n");
- conn->ssl[sockindex].connecting_state = ssl_connect_3;
- }
-
- if(conn->ssl[sockindex].connecting_state == ssl_connect_3) {
- conn_step = connect_finish(conn, sockindex);
- if(conn_step != CURLE_OK) {
- Curl_axtls_close(conn, sockindex);
- return conn_step;
- }
-
- /* Reset connect state */
- conn->ssl[sockindex].connecting_state = ssl_connect_1;
-
- *done = TRUE;
- return CURLE_OK;
- }
-
- /* Unrecognized state. Things are very bad. */
- conn->ssl[sockindex].state = ssl_connection_none;
- conn->ssl[sockindex].connecting_state = ssl_connect_1;
- /* Return value perhaps not strictly correct, but distinguishes the issue.*/
- return CURLE_BAD_FUNCTION_ARGUMENT;
-}
-
-
-/*
- * This function is called after the TCP connect has completed. Setup the TLS
- * layer and do all necessary magic for a blocking connect.
- */
-CURLcode
-Curl_axtls_connect(struct connectdata *conn,
- int sockindex)
-
-{
- struct Curl_easy *data = conn->data;
- CURLcode conn_step = connect_prep(conn, sockindex);
- int ssl_fcn_return;
- SSL *ssl = conn->ssl[sockindex].ssl;
- long timeout_ms;
-
- if(conn_step != CURLE_OK) {
- Curl_axtls_close(conn, sockindex);
- return conn_step;
- }
-
- /* Check to make sure handshake was ok. */
- while(ssl_handshake_status(ssl) != SSL_OK) {
- /* check allowed time left */
- timeout_ms = Curl_timeleft(data, NULL, TRUE);
-
- if(timeout_ms < 0) {
- /* no need to continue if time already is up */
- failf(data, "SSL connection timeout");
- return CURLE_OPERATION_TIMEDOUT;
- }
-
- ssl_fcn_return = ssl_read(ssl, NULL);
- if(ssl_fcn_return < 0) {
- Curl_axtls_close(conn, sockindex);
- ssl_display_error(ssl_fcn_return); /* goes to stdout. */
- return map_error_to_curl(ssl_fcn_return);
- }
- /* TODO: avoid polling */
- Curl_wait_ms(10);
- }
- infof(conn->data, "handshake completed successfully\n");
-
- conn_step = connect_finish(conn, sockindex);
- if(conn_step != CURLE_OK) {
- Curl_axtls_close(conn, sockindex);
- return conn_step;
- }
-
- return CURLE_OK;
-}
-
-/* return number of sent (non-SSL) bytes */
-static ssize_t axtls_send(struct connectdata *conn,
- int sockindex,
- const void *mem,
- size_t len,
- CURLcode *err)
-{
- /* ssl_write() returns 'int' while write() and send() returns 'size_t' */
- int rc = ssl_write(conn->ssl[sockindex].ssl, mem, (int)len);
-
- infof(conn->data, " axtls_send\n");
-
- if(rc < 0) {
- *err = map_error_to_curl(rc);
- rc = -1; /* generic error code for send failure */
- }
-
- *err = CURLE_OK;
- return rc;
-}
-
-void Curl_axtls_close(struct connectdata *conn, int sockindex)
-{
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
-
- infof(conn->data, " Curl_axtls_close\n");
-
- /* line from openssl.c: (void)SSL_shutdown(connssl->ssl);
- axTLS compat layer does nothing for SSL_shutdown */
-
- /* The following line is from openssl.c. There seems to be no axTLS
- equivalent. ssl_free and ssl_ctx_free close things.
- SSL_set_connect_state(connssl->handle); */
-
- free_ssl_structs(connssl);
-}
-
-/*
- * This function is called to shut down the SSL layer but keep the
- * socket open (CCC - Clear Command Channel)
- */
-int Curl_axtls_shutdown(struct connectdata *conn, int sockindex)
-{
- /* Outline taken from openssl.c since functions are in axTLS compat layer.
- axTLS's error set is much smaller, so a lot of error-handling was removed.
- */
- int retval = 0;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct Curl_easy *data = conn->data;
- uint8_t *buf;
- ssize_t nread;
-
- infof(conn->data, " Curl_axtls_shutdown\n");
-
- /* This has only been tested on the proftpd server, and the mod_tls code
- sends a close notify alert without waiting for a close notify alert in
- response. Thus we wait for a close notify alert from the server, but
- we do not send one. Let's hope other servers do the same... */
-
- /* axTLS compat layer does nothing for SSL_shutdown, so we do nothing too
- if(data->set.ftp_ccc == CURLFTPSSL_CCC_ACTIVE)
- (void)SSL_shutdown(connssl->ssl);
- */
-
- if(connssl->ssl) {
- int what = SOCKET_READABLE(conn->sock[sockindex], SSL_SHUTDOWN_TIMEOUT);
- if(what > 0) {
- /* Something to read, let's do it and hope that it is the close
- notify alert from the server. buf is managed internally by
- axTLS and will be released upon calling ssl_free via
- free_ssl_structs. */
- nread = (ssize_t)ssl_read(connssl->ssl, &buf);
-
- if(nread < SSL_OK) {
- failf(data, "close notify alert not received during shutdown");
- retval = -1;
- }
- }
- else if(0 == what) {
- /* timeout */
- failf(data, "SSL shutdown timeout");
- }
- else {
- /* anything that gets here is fatally bad */
- failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
- retval = -1;
- }
-
- free_ssl_structs(connssl);
- }
- return retval;
-}
-
-static ssize_t axtls_recv(struct connectdata *conn, /* connection data */
- int num, /* socketindex */
- char *buf, /* store read data here */
- size_t buffersize, /* max amount to read */
- CURLcode *err)
-{
- struct ssl_connect_data *connssl = &conn->ssl[num];
- ssize_t ret = 0;
- uint8_t *read_buf;
-
- infof(conn->data, " axtls_recv\n");
-
- *err = CURLE_OK;
- if(connssl) {
- ret = ssl_read(connssl->ssl, &read_buf);
- if(ret > SSL_OK) {
- /* ssl_read returns SSL_OK if there is more data to read, so if it is
- larger, then all data has been read already. */
- memcpy(buf, read_buf,
- (size_t)ret > buffersize ? buffersize : (size_t)ret);
- }
- else if(ret == SSL_OK) {
- /* more data to be read, signal caller to call again */
- *err = CURLE_AGAIN;
- ret = -1;
- }
- else if(ret == -3) {
- /* With patched axTLS, SSL_CLOSE_NOTIFY=-3. Hard-coding until axTLS
- team approves proposed fix. */
- Curl_axtls_close(conn, num);
- }
- else {
- failf(conn->data, "axTLS recv error (%d)", ret);
- *err = map_error_to_curl((int) ret);
- ret = -1;
- }
- }
-
- return ret;
-}
-
-/*
- * Return codes:
- * 1 means the connection is still in place
- * 0 means the connection has been closed
- * -1 means the connection status is unknown
- */
-int Curl_axtls_check_cxn(struct connectdata *conn)
-{
- /* openssl.c line: rc = SSL_peek(conn->ssl[FIRSTSOCKET].ssl, (void*)&buf, 1);
- axTLS compat layer always returns the last argument, so connection is
- always alive? */
-
- infof(conn->data, " Curl_axtls_check_cxn\n");
- return 1; /* connection still in place */
-}
-
-void Curl_axtls_session_free(void *ptr)
-{
- (void)ptr;
- /* free the ID */
- /* both openssl.c and gtls.c do something here, but axTLS's OpenSSL
- compatibility layer does nothing, so we do nothing too. */
-}
-
-size_t Curl_axtls_version(char *buffer, size_t size)
-{
- return snprintf(buffer, size, "axTLS/%s", ssl_version());
-}
-
-CURLcode Curl_axtls_random(struct Curl_easy *data,
- unsigned char *entropy,
- size_t length)
-{
- static bool ssl_seeded = FALSE;
- (void)data;
- if(!ssl_seeded) {
- ssl_seeded = TRUE;
- /* Initialize the seed if not already done. This call is not exactly thread
- * safe (and neither is the ssl_seeded check), but the worst effect of a
- * race condition is that some global resources will leak. */
- RNG_initialize();
- }
- get_random((int)length, entropy);
- return CURLE_OK;
-}
-
-#endif /* USE_AXTLS */
diff --git a/Utilities/cmcurl/lib/vtls/axtls.h b/Utilities/cmcurl/lib/vtls/axtls.h
deleted file mode 100644
index 53797eadb..000000000
--- a/Utilities/cmcurl/lib/vtls/axtls.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef HEADER_CURL_AXTLS_H
-#define HEADER_CURL_AXTLS_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2010, DirecTV, Contact: Eric Hu <ehu@directv.com>
- * Copyright (C) 2010 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.haxx.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-#ifdef USE_AXTLS
-#include "curl/curl.h"
-#include "urldata.h"
-
-int Curl_axtls_init(void);
-int Curl_axtls_cleanup(void);
-CURLcode Curl_axtls_connect(struct connectdata *conn, int sockindex);
-CURLcode Curl_axtls_connect_nonblocking(
- struct connectdata *conn,
- int sockindex,
- bool *done);
-
- /* close a SSL connection */
-void Curl_axtls_close(struct connectdata *conn, int sockindex);
-
-void Curl_axtls_session_free(void *ptr);
-size_t Curl_axtls_version(char *buffer, size_t size);
-int Curl_axtls_shutdown(struct connectdata *conn, int sockindex);
-int Curl_axtls_check_cxn(struct connectdata *conn);
-CURLcode Curl_axtls_random(struct Curl_easy *data,
- unsigned char *entropy,
- size_t length);
-
-/* Set the API backend definition to axTLS */
-#define CURL_SSL_BACKEND CURLSSLBACKEND_AXTLS
-
-/* API setup for axTLS */
-#define curlssl_init Curl_axtls_init
-#define curlssl_cleanup Curl_axtls_cleanup
-#define curlssl_connect Curl_axtls_connect
-#define curlssl_connect_nonblocking Curl_axtls_connect_nonblocking
-#define curlssl_session_free(x) Curl_axtls_session_free(x)
-#define curlssl_close_all(x) ((void)x)
-#define curlssl_close Curl_axtls_close
-#define curlssl_shutdown(x,y) Curl_axtls_shutdown(x,y)
-#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN)
-#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN)
-#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL)
-#define curlssl_version Curl_axtls_version
-#define curlssl_check_cxn(x) Curl_axtls_check_cxn(x)
-#define curlssl_data_pending(x,y) ((void)x, (void)y, 0)
-#define curlssl_random(x,y,z) Curl_axtls_random(x,y,z)
-
-#endif /* USE_AXTLS */
-#endif /* HEADER_CURL_AXTLS_H */
-
diff --git a/Utilities/cmcurl/lib/vtls/cyassl.c b/Utilities/cmcurl/lib/vtls/cyassl.c
index 01bfdabd1..44a2bdda6 100644
--- a/Utilities/cmcurl/lib/vtls/cyassl.c
+++ b/Utilities/cmcurl/lib/vtls/cyassl.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -67,18 +67,7 @@ and that's a problem since options.h hasn't been included yet. */
#endif
#endif
-/* HAVE_SUPPORTED_CURVES is wolfSSL's build time symbol for enabling the ECC
- supported curve extension in options.h. Note ECC is enabled separately. */
-#ifndef HAVE_SUPPORTED_CURVES
-#if defined(HAVE_CYASSL_CTX_USESUPPORTEDCURVE) || \
- defined(HAVE_WOLFSSL_CTX_USESUPPORTEDCURVE)
-#define HAVE_SUPPORTED_CURVES
-#endif
-#endif
-
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#include "urldata.h"
#include "sendf.h"
@@ -90,7 +79,9 @@ and that's a problem since options.h hasn't been included yet. */
#include "strcase.h"
#include "x509asn1.h"
#include "curl_printf.h"
+#include "multiif.h"
+#include <cyassl/openssl/ssl.h>
#include <cyassl/ssl.h>
#ifdef HAVE_CYASSL_ERROR_SSL_H
#include <cyassl/error-ssl.h>
@@ -110,6 +101,25 @@ and that's a problem since options.h hasn't been included yet. */
#define CYASSL_MAX_ERROR_SZ 80
#endif
+/* KEEP_PEER_CERT is a product of the presence of build time symbol
+ OPENSSL_EXTRA without NO_CERTS, depending on the version. KEEP_PEER_CERT is
+ in wolfSSL's settings.h, and the latter two are build time symbols in
+ options.h. */
+#ifndef KEEP_PEER_CERT
+#if defined(HAVE_CYASSL_GET_PEER_CERTIFICATE) || \
+ defined(HAVE_WOLFSSL_GET_PEER_CERTIFICATE) || \
+ (defined(OPENSSL_EXTRA) && !defined(NO_CERTS))
+#define KEEP_PEER_CERT
+#endif
+#endif
+
+struct ssl_backend_data {
+ SSL_CTX* ctx;
+ SSL* handle;
+};
+
+#define BACKEND connssl->backend
+
static Curl_recv cyassl_recv;
static Curl_send cyassl_send;
@@ -133,10 +143,9 @@ static CURLcode
cyassl_connect_step1(struct connectdata *conn,
int sockindex)
{
- char error_buffer[CYASSL_MAX_ERROR_SZ];
char *ciphers;
struct Curl_easy *data = conn->data;
- struct ssl_connect_data* conssl = &conn->ssl[sockindex];
+ struct ssl_connect_data* connssl = &conn->ssl[sockindex];
SSL_METHOD* req_method = NULL;
curl_socket_t sockfd = conn->sock[sockindex];
#ifdef HAVE_SNI
@@ -146,7 +155,7 @@ cyassl_connect_step1(struct connectdata *conn,
#define use_sni(x) Curl_nop_stmt
#endif
- if(conssl->state == ssl_connection_complete)
+ if(connssl->state == ssl_connection_complete)
return CURLE_OK;
if(SSL_CONN_CONFIG(version_max) != CURL_SSLVERSION_MAX_NONE) {
@@ -169,8 +178,13 @@ cyassl_connect_step1(struct connectdata *conn,
use_sni(TRUE);
break;
case CURL_SSLVERSION_TLSv1_0:
+#ifdef WOLFSSL_ALLOW_TLSV10
req_method = TLSv1_client_method();
use_sni(TRUE);
+#else
+ failf(data, "CyaSSL does not support TLS 1.0");
+ return CURLE_NOT_BUILT_IN;
+#endif
break;
case CURL_SSLVERSION_TLSv1_1:
req_method = TLSv1_1_client_method();
@@ -181,8 +195,14 @@ cyassl_connect_step1(struct connectdata *conn,
use_sni(TRUE);
break;
case CURL_SSLVERSION_TLSv1_3:
+#ifdef WOLFSSL_TLS13
+ req_method = wolfTLSv1_3_client_method();
+ use_sni(TRUE);
+ break;
+#else
failf(data, "CyaSSL: TLS 1.3 is not yet supported");
return CURLE_SSL_CONNECT_ERROR;
+#endif
case CURL_SSLVERSION_SSLv3:
#ifdef WOLFSSL_ALLOW_SSLV3
req_method = SSLv3_client_method();
@@ -205,11 +225,11 @@ cyassl_connect_step1(struct connectdata *conn,
return CURLE_OUT_OF_MEMORY;
}
- if(conssl->ctx)
- SSL_CTX_free(conssl->ctx);
- conssl->ctx = SSL_CTX_new(req_method);
+ if(BACKEND->ctx)
+ SSL_CTX_free(BACKEND->ctx);
+ BACKEND->ctx = SSL_CTX_new(req_method);
- if(!conssl->ctx) {
+ if(!BACKEND->ctx) {
failf(data, "SSL: couldn't create a context!");
return CURLE_OUT_OF_MEMORY;
}
@@ -225,9 +245,13 @@ cyassl_connect_step1(struct connectdata *conn,
version. We use wolfSSL_CTX_SetMinVersion and not CyaSSL_SetMinVersion
because only the former will work before the user's CTX callback is called.
*/
- if((wolfSSL_CTX_SetMinVersion(conssl->ctx, WOLFSSL_TLSV1) != 1) &&
- (wolfSSL_CTX_SetMinVersion(conssl->ctx, WOLFSSL_TLSV1_1) != 1) &&
- (wolfSSL_CTX_SetMinVersion(conssl->ctx, WOLFSSL_TLSV1_2) != 1)) {
+ if((wolfSSL_CTX_SetMinVersion(BACKEND->ctx, WOLFSSL_TLSV1) != 1) &&
+ (wolfSSL_CTX_SetMinVersion(BACKEND->ctx, WOLFSSL_TLSV1_1) != 1) &&
+ (wolfSSL_CTX_SetMinVersion(BACKEND->ctx, WOLFSSL_TLSV1_2) != 1)
+#ifdef WOLFSSL_TLS13
+ && (wolfSSL_CTX_SetMinVersion(BACKEND->ctx, WOLFSSL_TLSV1_3) != 1)
+#endif
+ ) {
failf(data, "SSL: couldn't set the minimum protocol version");
return CURLE_SSL_CONNECT_ERROR;
}
@@ -237,7 +261,7 @@ cyassl_connect_step1(struct connectdata *conn,
ciphers = SSL_CONN_CONFIG(cipher_list);
if(ciphers) {
- if(!SSL_CTX_set_cipher_list(conssl->ctx, ciphers)) {
+ if(!SSL_CTX_set_cipher_list(BACKEND->ctx, ciphers)) {
failf(data, "failed setting cipher list: %s", ciphers);
return CURLE_SSL_CIPHER;
}
@@ -247,7 +271,7 @@ cyassl_connect_step1(struct connectdata *conn,
#ifndef NO_FILESYSTEM
/* load trusted cacert */
if(SSL_CONN_CONFIG(CAfile)) {
- if(1 != SSL_CTX_load_verify_locations(conssl->ctx,
+ if(1 != SSL_CTX_load_verify_locations(BACKEND->ctx,
SSL_CONN_CONFIG(CAfile),
SSL_CONN_CONFIG(CApath))) {
if(SSL_CONN_CONFIG(verifypeer)) {
@@ -284,7 +308,7 @@ cyassl_connect_step1(struct connectdata *conn,
if(SSL_SET_OPTION(cert) && SSL_SET_OPTION(key)) {
int file_type = do_file_type(SSL_SET_OPTION(cert_type));
- if(SSL_CTX_use_certificate_file(conssl->ctx, SSL_SET_OPTION(cert),
+ if(SSL_CTX_use_certificate_file(BACKEND->ctx, SSL_SET_OPTION(cert),
file_type) != 1) {
failf(data, "unable to use client certificate (no key or wrong pass"
" phrase?)");
@@ -292,7 +316,7 @@ cyassl_connect_step1(struct connectdata *conn,
}
file_type = do_file_type(SSL_SET_OPTION(key_type));
- if(SSL_CTX_use_PrivateKey_file(conssl->ctx, SSL_SET_OPTION(key),
+ if(SSL_CTX_use_PrivateKey_file(BACKEND->ctx, SSL_SET_OPTION(key),
file_type) != 1) {
failf(data, "unable to set private key");
return CURLE_SSL_CONNECT_ERROR;
@@ -304,7 +328,7 @@ cyassl_connect_step1(struct connectdata *conn,
* fail to connect if the verification fails, or if it should continue
* anyway. In the latter case the result of the verification is checked with
* SSL_get_verify_result() below. */
- SSL_CTX_set_verify(conssl->ctx,
+ SSL_CTX_set_verify(BACKEND->ctx,
SSL_CONN_CONFIG(verifypeer)?SSL_VERIFY_PEER:
SSL_VERIFY_NONE,
NULL);
@@ -323,7 +347,7 @@ cyassl_connect_step1(struct connectdata *conn,
#ifdef ENABLE_IPV6
(0 == Curl_inet_pton(AF_INET6, hostname, &addr6)) &&
#endif
- (CyaSSL_CTX_UseSNI(conssl->ctx, CYASSL_SNI_HOST_NAME, hostname,
+ (CyaSSL_CTX_UseSNI(BACKEND->ctx, CYASSL_SNI_HOST_NAME, hostname,
(unsigned short)hostname_len) != 1)) {
infof(data, "WARNING: failed to configure server name indication (SNI) "
"TLS extension\n");
@@ -331,20 +355,10 @@ cyassl_connect_step1(struct connectdata *conn,
}
#endif
-#ifdef HAVE_SUPPORTED_CURVES
- /* CyaSSL/wolfSSL does not send the supported ECC curves ext automatically:
- https://github.com/wolfSSL/wolfssl/issues/366
- The supported curves below are those also supported by OpenSSL 1.0.2 and
- in the same order. */
- CyaSSL_CTX_UseSupportedCurve(conssl->ctx, 0x17); /* secp256r1 */
- CyaSSL_CTX_UseSupportedCurve(conssl->ctx, 0x19); /* secp521r1 */
- CyaSSL_CTX_UseSupportedCurve(conssl->ctx, 0x18); /* secp384r1 */
-#endif
-
/* give application a chance to interfere with SSL set up. */
if(data->set.ssl.fsslctx) {
CURLcode result = CURLE_OK;
- result = (*data->set.ssl.fsslctx)(data, conssl->ctx,
+ result = (*data->set.ssl.fsslctx)(data, BACKEND->ctx,
data->set.ssl.fsslctxp);
if(result) {
failf(data, "error signaled by ssl ctx callback");
@@ -362,10 +376,10 @@ cyassl_connect_step1(struct connectdata *conn,
#endif
/* Let's make an SSL structure */
- if(conssl->handle)
- SSL_free(conssl->handle);
- conssl->handle = SSL_new(conssl->ctx);
- if(!conssl->handle) {
+ if(BACKEND->handle)
+ SSL_free(BACKEND->handle);
+ BACKEND->handle = SSL_new(BACKEND->ctx);
+ if(!BACKEND->handle) {
failf(data, "SSL: couldn't create a context (handle)!");
return CURLE_OUT_OF_MEMORY;
}
@@ -388,7 +402,7 @@ cyassl_connect_step1(struct connectdata *conn,
strcpy(protocols + strlen(protocols), ALPN_HTTP_1_1);
infof(data, "ALPN, offering %s\n", ALPN_HTTP_1_1);
- if(wolfSSL_UseALPN(conssl->handle, protocols,
+ if(wolfSSL_UseALPN(BACKEND->handle, protocols,
(unsigned)strlen(protocols),
WOLFSSL_ALPN_CONTINUE_ON_MISMATCH) != SSL_SUCCESS) {
failf(data, "SSL: failed setting ALPN protocols");
@@ -404,10 +418,11 @@ cyassl_connect_step1(struct connectdata *conn,
Curl_ssl_sessionid_lock(conn);
if(!Curl_ssl_getsessionid(conn, &ssl_sessionid, NULL, sockindex)) {
/* we got a session id, use it! */
- if(!SSL_set_session(conssl->handle, ssl_sessionid)) {
+ if(!SSL_set_session(BACKEND->handle, ssl_sessionid)) {
+ char error_buffer[CYASSL_MAX_ERROR_SZ];
Curl_ssl_sessionid_unlock(conn);
failf(data, "SSL: SSL_set_session failed: %s",
- ERR_error_string(SSL_get_error(conssl->handle, 0),
+ ERR_error_string(SSL_get_error(BACKEND->handle, 0),
error_buffer));
return CURLE_SSL_CONNECT_ERROR;
}
@@ -418,12 +433,12 @@ cyassl_connect_step1(struct connectdata *conn,
}
/* pass the raw socket into the SSL layer */
- if(!SSL_set_fd(conssl->handle, (int)sockfd)) {
+ if(!SSL_set_fd(BACKEND->handle, (int)sockfd)) {
failf(data, "SSL: SSL_set_fd failed");
return CURLE_SSL_CONNECT_ERROR;
}
- conssl->connecting_state = ssl_connect_2;
+ connssl->connecting_state = ssl_connect_2;
return CURLE_OK;
}
@@ -434,7 +449,7 @@ cyassl_connect_step2(struct connectdata *conn,
{
int ret = -1;
struct Curl_easy *data = conn->data;
- struct ssl_connect_data* conssl = &conn->ssl[sockindex];
+ struct ssl_connect_data* connssl = &conn->ssl[sockindex];
const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
const char * const dispname = SSL_IS_PROXY() ?
@@ -448,22 +463,22 @@ cyassl_connect_step2(struct connectdata *conn,
/* Enable RFC2818 checks */
if(SSL_CONN_CONFIG(verifyhost)) {
- ret = CyaSSL_check_domain_name(conssl->handle, hostname);
+ ret = CyaSSL_check_domain_name(BACKEND->handle, hostname);
if(ret == SSL_FAILURE)
return CURLE_OUT_OF_MEMORY;
}
- ret = SSL_connect(conssl->handle);
+ ret = SSL_connect(BACKEND->handle);
if(ret != 1) {
char error_buffer[CYASSL_MAX_ERROR_SZ];
- int detail = SSL_get_error(conssl->handle, ret);
+ int detail = SSL_get_error(BACKEND->handle, ret);
if(SSL_ERROR_WANT_READ == detail) {
- conssl->connecting_state = ssl_connect_2_reading;
+ connssl->connecting_state = ssl_connect_2_reading;
return CURLE_OK;
}
else if(SSL_ERROR_WANT_WRITE == detail) {
- conssl->connecting_state = ssl_connect_2_writing;
+ connssl->connecting_state = ssl_connect_2_writing;
return CURLE_OK;
}
/* There is no easy way to override only the CN matching.
@@ -524,7 +539,7 @@ cyassl_connect_step2(struct connectdata *conn,
curl_asn1Element *pubkey;
CURLcode result;
- x509 = SSL_get_peer_certificate(conssl->handle);
+ x509 = SSL_get_peer_certificate(BACKEND->handle);
if(!x509) {
failf(data, "SSL: failed retrieving server certificate");
return CURLE_SSL_PINNEDPUBKEYNOTMATCH;
@@ -536,7 +551,7 @@ cyassl_connect_step2(struct connectdata *conn,
return CURLE_SSL_PINNEDPUBKEYNOTMATCH;
}
- memset(&x509_parsed, 0, sizeof x509_parsed);
+ memset(&x509_parsed, 0, sizeof(x509_parsed));
if(Curl_parseX509(&x509_parsed, x509_der, x509_der + x509_der_len))
return CURLE_SSL_PINNEDPUBKEYNOTMATCH;
@@ -566,7 +581,7 @@ cyassl_connect_step2(struct connectdata *conn,
char *protocol = NULL;
unsigned short protocol_len = 0;
- rc = wolfSSL_ALPN_GetProtocol(conssl->handle, &protocol, &protocol_len);
+ rc = wolfSSL_ALPN_GetProtocol(BACKEND->handle, &protocol, &protocol_len);
if(rc == SSL_SUCCESS) {
infof(data, "ALPN, server accepted to use %.*s\n", protocol_len,
@@ -585,6 +600,8 @@ cyassl_connect_step2(struct connectdata *conn,
else
infof(data, "ALPN, unrecognized protocol %.*s\n", protocol_len,
protocol);
+ Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ?
+ BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE);
}
else if(rc == SSL_ALPN_NOT_FOUND)
infof(data, "ALPN, server did not agree to a protocol\n");
@@ -595,11 +612,11 @@ cyassl_connect_step2(struct connectdata *conn,
}
#endif /* HAVE_ALPN */
- conssl->connecting_state = ssl_connect_3;
+ connssl->connecting_state = ssl_connect_3;
#if (LIBCYASSL_VERSION_HEX >= 0x03009010)
infof(data, "SSL connection using %s / %s\n",
- wolfSSL_get_version(conssl->handle),
- wolfSSL_get_cipher_name(conssl->handle));
+ wolfSSL_get_version(BACKEND->handle),
+ wolfSSL_get_cipher_name(BACKEND->handle));
#else
infof(data, "SSL connected\n");
#endif
@@ -623,7 +640,7 @@ cyassl_connect_step3(struct connectdata *conn,
SSL_SESSION *our_ssl_sessionid;
void *old_ssl_sessionid = NULL;
- our_ssl_sessionid = SSL_get_session(connssl->handle);
+ our_ssl_sessionid = SSL_get_session(BACKEND->handle);
Curl_ssl_sessionid_lock(conn);
incache = !(Curl_ssl_getsessionid(conn, &old_ssl_sessionid, NULL,
@@ -660,12 +677,13 @@ static ssize_t cyassl_send(struct connectdata *conn,
size_t len,
CURLcode *curlcode)
{
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
char error_buffer[CYASSL_MAX_ERROR_SZ];
int memlen = (len > (size_t)INT_MAX) ? INT_MAX : (int)len;
- int rc = SSL_write(conn->ssl[sockindex].handle, mem, memlen);
+ int rc = SSL_write(BACKEND->handle, mem, memlen);
if(rc < 0) {
- int err = SSL_get_error(conn->ssl[sockindex].handle, rc);
+ int err = SSL_get_error(BACKEND->handle, rc);
switch(err) {
case SSL_ERROR_WANT_READ:
@@ -684,18 +702,18 @@ static ssize_t cyassl_send(struct connectdata *conn,
return rc;
}
-void Curl_cyassl_close(struct connectdata *conn, int sockindex)
+static void Curl_cyassl_close(struct connectdata *conn, int sockindex)
{
- struct ssl_connect_data *conssl = &conn->ssl[sockindex];
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- if(conssl->handle) {
- (void)SSL_shutdown(conssl->handle);
- SSL_free(conssl->handle);
- conssl->handle = NULL;
+ if(BACKEND->handle) {
+ (void)SSL_shutdown(BACKEND->handle);
+ SSL_free(BACKEND->handle);
+ BACKEND->handle = NULL;
}
- if(conssl->ctx) {
- SSL_CTX_free(conssl->ctx);
- conssl->ctx = NULL;
+ if(BACKEND->ctx) {
+ SSL_CTX_free(BACKEND->ctx);
+ BACKEND->ctx = NULL;
}
}
@@ -705,12 +723,13 @@ static ssize_t cyassl_recv(struct connectdata *conn,
size_t buffersize,
CURLcode *curlcode)
{
+ struct ssl_connect_data *connssl = &conn->ssl[num];
char error_buffer[CYASSL_MAX_ERROR_SZ];
int buffsize = (buffersize > (size_t)INT_MAX) ? INT_MAX : (int)buffersize;
- int nread = SSL_read(conn->ssl[num].handle, buf, buffsize);
+ int nread = SSL_read(BACKEND->handle, buf, buffsize);
if(nread < 0) {
- int err = SSL_get_error(conn->ssl[num].handle, nread);
+ int err = SSL_get_error(BACKEND->handle, nread);
switch(err) {
case SSL_ERROR_ZERO_RETURN: /* no more data */
@@ -732,37 +751,45 @@ static ssize_t cyassl_recv(struct connectdata *conn,
}
-void Curl_cyassl_session_free(void *ptr)
+static void Curl_cyassl_session_free(void *ptr)
{
(void)ptr;
/* CyaSSL reuses sessions on own, no free */
}
-size_t Curl_cyassl_version(char *buffer, size_t size)
+static size_t Curl_cyassl_version(char *buffer, size_t size)
{
#if LIBCYASSL_VERSION_HEX >= 0x03006000
- return snprintf(buffer, size, "wolfSSL/%s", wolfSSL_lib_version());
+ return msnprintf(buffer, size, "wolfSSL/%s", wolfSSL_lib_version());
#elif defined(WOLFSSL_VERSION)
- return snprintf(buffer, size, "wolfSSL/%s", WOLFSSL_VERSION);
+ return msnprintf(buffer, size, "wolfSSL/%s", WOLFSSL_VERSION);
#elif defined(CYASSL_VERSION)
- return snprintf(buffer, size, "CyaSSL/%s", CYASSL_VERSION);
+ return msnprintf(buffer, size, "CyaSSL/%s", CYASSL_VERSION);
#else
- return snprintf(buffer, size, "CyaSSL/%s", "<1.8.8");
+ return msnprintf(buffer, size, "CyaSSL/%s", "<1.8.8");
#endif
}
-int Curl_cyassl_init(void)
+static int Curl_cyassl_init(void)
{
return (CyaSSL_Init() == SSL_SUCCESS);
}
-bool Curl_cyassl_data_pending(const struct connectdata* conn, int connindex)
+static void Curl_cyassl_cleanup(void)
{
- if(conn->ssl[connindex].handle) /* SSL is in use */
- return (0 != SSL_pending(conn->ssl[connindex].handle)) ? TRUE : FALSE;
+ CyaSSL_Cleanup();
+}
+
+
+static bool Curl_cyassl_data_pending(const struct connectdata* conn,
+ int connindex)
+{
+ const struct ssl_connect_data *connssl = &conn->ssl[connindex];
+ if(BACKEND->handle) /* SSL is in use */
+ return (0 != SSL_pending(BACKEND->handle)) ? TRUE : FALSE;
else
return FALSE;
}
@@ -772,14 +799,14 @@ bool Curl_cyassl_data_pending(const struct connectdata* conn, int connindex)
* This function is called to shut down the SSL layer but keep the
* socket open (CCC - Clear Command Channel)
*/
-int Curl_cyassl_shutdown(struct connectdata *conn, int sockindex)
+static int Curl_cyassl_shutdown(struct connectdata *conn, int sockindex)
{
int retval = 0;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- if(connssl->handle) {
- SSL_free(connssl->handle);
- connssl->handle = NULL;
+ if(BACKEND->handle) {
+ SSL_free(BACKEND->handle);
+ BACKEND->handle = NULL;
}
return retval;
}
@@ -804,7 +831,7 @@ cyassl_connect_common(struct connectdata *conn,
return CURLE_OK;
}
- if(ssl_connect_1==connssl->connecting_state) {
+ if(ssl_connect_1 == connssl->connecting_state) {
/* Find out how much more time we're allowed */
timeout_ms = Curl_timeleft(data, NULL, TRUE);
@@ -836,9 +863,9 @@ cyassl_connect_common(struct connectdata *conn,
if(connssl->connecting_state == ssl_connect_2_reading
|| connssl->connecting_state == ssl_connect_2_writing) {
- curl_socket_t writefd = ssl_connect_2_writing==
+ curl_socket_t writefd = ssl_connect_2_writing ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
- curl_socket_t readfd = ssl_connect_2_reading==
+ curl_socket_t readfd = ssl_connect_2_reading ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
@@ -899,18 +926,14 @@ cyassl_connect_common(struct connectdata *conn,
}
-CURLcode
-Curl_cyassl_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done)
+static CURLcode Curl_cyassl_connect_nonblocking(struct connectdata *conn,
+ int sockindex, bool *done)
{
return cyassl_connect_common(conn, sockindex, TRUE, done);
}
-CURLcode
-Curl_cyassl_connect(struct connectdata *conn,
- int sockindex)
+static CURLcode Curl_cyassl_connect(struct connectdata *conn, int sockindex)
{
CURLcode result;
bool done = FALSE;
@@ -924,9 +947,8 @@ Curl_cyassl_connect(struct connectdata *conn,
return CURLE_OK;
}
-CURLcode Curl_cyassl_random(struct Curl_easy *data,
- unsigned char *entropy,
- size_t length)
+static CURLcode Curl_cyassl_random(struct Curl_easy *data,
+ unsigned char *entropy, size_t length)
{
RNG rng;
(void)data;
@@ -936,19 +958,61 @@ CURLcode Curl_cyassl_random(struct Curl_easy *data,
return CURLE_FAILED_INIT;
if(RNG_GenerateBlock(&rng, entropy, (unsigned)length))
return CURLE_FAILED_INIT;
+ if(FreeRng(&rng))
+ return CURLE_FAILED_INIT;
return CURLE_OK;
}
-void Curl_cyassl_sha256sum(const unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *sha256sum /* output */,
- size_t unused)
+static CURLcode Curl_cyassl_sha256sum(const unsigned char *tmp, /* input */
+ size_t tmplen,
+ unsigned char *sha256sum /* output */,
+ size_t unused)
{
Sha256 SHA256pw;
(void)unused;
InitSha256(&SHA256pw);
Sha256Update(&SHA256pw, tmp, (word32)tmplen);
Sha256Final(&SHA256pw, sha256sum);
+ return CURLE_OK;
+}
+
+static void *Curl_cyassl_get_internals(struct ssl_connect_data *connssl,
+ CURLINFO info UNUSED_PARAM)
+{
+ (void)info;
+ return BACKEND->handle;
}
+const struct Curl_ssl Curl_ssl_cyassl = {
+ { CURLSSLBACKEND_WOLFSSL, "WolfSSL" }, /* info */
+
+#ifdef KEEP_PEER_CERT
+ SSLSUPP_PINNEDPUBKEY |
+#endif
+ SSLSUPP_SSL_CTX,
+
+ sizeof(struct ssl_backend_data),
+
+ Curl_cyassl_init, /* init */
+ Curl_cyassl_cleanup, /* cleanup */
+ Curl_cyassl_version, /* version */
+ Curl_none_check_cxn, /* check_cxn */
+ Curl_cyassl_shutdown, /* shutdown */
+ Curl_cyassl_data_pending, /* data_pending */
+ Curl_cyassl_random, /* random */
+ Curl_none_cert_status_request, /* cert_status_request */
+ Curl_cyassl_connect, /* connect */
+ Curl_cyassl_connect_nonblocking, /* connect_nonblocking */
+ Curl_cyassl_get_internals, /* get_internals */
+ Curl_cyassl_close, /* close_one */
+ Curl_none_close_all, /* close_all */
+ Curl_cyassl_session_free, /* session_free */
+ Curl_none_set_engine, /* set_engine */
+ Curl_none_set_engine_default, /* set_engine_default */
+ Curl_none_engines_list, /* engines_list */
+ Curl_none_false_start, /* false_start */
+ Curl_none_md5sum, /* md5sum */
+ Curl_cyassl_sha256sum /* sha256sum */
+};
+
#endif
diff --git a/Utilities/cmcurl/lib/vtls/cyassl.h b/Utilities/cmcurl/lib/vtls/cyassl.h
index f47719e4e..01e11cc23 100644
--- a/Utilities/cmcurl/lib/vtls/cyassl.h
+++ b/Utilities/cmcurl/lib/vtls/cyassl.h
@@ -25,68 +25,7 @@
#ifdef USE_CYASSL
-/* KEEP_PEER_CERT is a product of the presence of build time symbol
- OPENSSL_EXTRA without NO_CERTS, depending on the version. KEEP_PEER_CERT is
- in wolfSSL's settings.h, and the latter two are build time symbols in
- options.h. */
-#ifndef KEEP_PEER_CERT
-#if defined(HAVE_CYASSL_GET_PEER_CERTIFICATE) || \
- defined(HAVE_WOLFSSL_GET_PEER_CERTIFICATE) || \
- (defined(OPENSSL_EXTRA) && !defined(NO_CERTS))
-#define KEEP_PEER_CERT
-#endif
-#endif
-
-CURLcode Curl_cyassl_connect(struct connectdata *conn, int sockindex);
-bool Curl_cyassl_data_pending(const struct connectdata* conn, int connindex);
-int Curl_cyassl_shutdown(struct connectdata* conn, int sockindex);
-
- /* close a SSL connection */
-void Curl_cyassl_close(struct connectdata *conn, int sockindex);
-
-void Curl_cyassl_session_free(void *ptr);
-size_t Curl_cyassl_version(char *buffer, size_t size);
-int Curl_cyassl_shutdown(struct connectdata *conn, int sockindex);
-int Curl_cyassl_init(void);
-CURLcode Curl_cyassl_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done);
-CURLcode Curl_cyassl_random(struct Curl_easy *data,
- unsigned char *entropy,
- size_t length);
-void Curl_cyassl_sha256sum(const unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *sha256sum, /* output */
- size_t unused);
-
-/* Set the API backend definition to CyaSSL */
-#define CURL_SSL_BACKEND CURLSSLBACKEND_CYASSL
-
-/* this backend supports CURLOPT_SSL_CTX_* */
-#define have_curlssl_ssl_ctx 1
-
-#ifdef KEEP_PEER_CERT
-/* this backend supports CURLOPT_PINNEDPUBLICKEY */
-#define have_curlssl_pinnedpubkey 1
-#endif
-
-/* API setup for CyaSSL */
-#define curlssl_init Curl_cyassl_init
-#define curlssl_cleanup() Curl_nop_stmt
-#define curlssl_connect Curl_cyassl_connect
-#define curlssl_connect_nonblocking Curl_cyassl_connect_nonblocking
-#define curlssl_session_free(x) Curl_cyassl_session_free(x)
-#define curlssl_close_all(x) ((void)x)
-#define curlssl_close Curl_cyassl_close
-#define curlssl_shutdown(x,y) Curl_cyassl_shutdown(x,y)
-#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN)
-#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN)
-#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL)
-#define curlssl_version Curl_cyassl_version
-#define curlssl_check_cxn(x) ((void)x, -1)
-#define curlssl_data_pending(x,y) Curl_cyassl_data_pending(x,y)
-#define curlssl_random(x,y,z) Curl_cyassl_random(x,y,z)
-#define curlssl_sha256sum(a,b,c,d) Curl_cyassl_sha256sum(a,b,c,d)
+extern const struct Curl_ssl Curl_ssl_cyassl;
#endif /* USE_CYASSL */
#endif /* HEADER_CURL_CYASSL_H */
diff --git a/Utilities/cmcurl/lib/vtls/darwinssl.c b/Utilities/cmcurl/lib/vtls/darwinssl.c
deleted file mode 100644
index 041766541..000000000
--- a/Utilities/cmcurl/lib/vtls/darwinssl.c
+++ /dev/null
@@ -1,2847 +0,0 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2012 - 2014, Nick Zitzmann, <nickzman@gmail.com>.
- * Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.haxx.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-
-/*
- * Source file for all iOS and Mac OS X SecureTransport-specific code for the
- * TLS/SSL layer. No code but vtls.c should ever call or use these functions.
- */
-
-#include "curl_setup.h"
-
-#include "urldata.h" /* for the Curl_easy definition */
-#include "curl_base64.h"
-#include "strtok.h"
-
-#ifdef USE_DARWINSSL
-
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-#include <Security/Security.h>
-#include <Security/SecureTransport.h>
-#include <CoreFoundation/CoreFoundation.h>
-#include <CommonCrypto/CommonDigest.h>
-
-/* The Security framework has changed greatly between iOS and different OS X
- versions, and we will try to support as many of them as we can (back to
- Leopard and iOS 5) by using macros and weak-linking.
-
- IMPORTANT: If TLS 1.1 and 1.2 support are important for you on OS X, then
- you must build this project against the 10.8 SDK or later. */
-#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
-#error "The darwinssl back-end requires Leopard or later."
-#endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1050 */
-
-#define CURL_BUILD_IOS 0
-#define CURL_BUILD_IOS_7 0
-#define CURL_BUILD_MAC 1
-/* This is the maximum API level we are allowed to use when building: */
-#define CURL_BUILD_MAC_10_5 MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
-#define CURL_BUILD_MAC_10_6 MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
-#define CURL_BUILD_MAC_10_7 MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
-#define CURL_BUILD_MAC_10_8 MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
-#define CURL_BUILD_MAC_10_9 MAC_OS_X_VERSION_MAX_ALLOWED >= 1090
-/* These macros mean "the following code is present to allow runtime backward
- compatibility with at least this cat or earlier":
- (You set this at build-time by setting the MACOSX_DEPLOYMENT_TARGET
- environmental variable.) */
-#define CURL_SUPPORT_MAC_10_5 MAC_OS_X_VERSION_MIN_REQUIRED <= 1050
-#define CURL_SUPPORT_MAC_10_6 MAC_OS_X_VERSION_MIN_REQUIRED <= 1060
-#define CURL_SUPPORT_MAC_10_7 MAC_OS_X_VERSION_MIN_REQUIRED <= 1070
-#define CURL_SUPPORT_MAC_10_8 MAC_OS_X_VERSION_MIN_REQUIRED <= 1080
-#define CURL_SUPPORT_MAC_10_9 MAC_OS_X_VERSION_MIN_REQUIRED <= 1090
-
-#elif TARGET_OS_EMBEDDED || TARGET_OS_IPHONE
-#define CURL_BUILD_IOS 1
-#define CURL_BUILD_IOS_7 __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
-#define CURL_BUILD_MAC 0
-#define CURL_BUILD_MAC_10_5 0
-#define CURL_BUILD_MAC_10_6 0
-#define CURL_BUILD_MAC_10_7 0
-#define CURL_BUILD_MAC_10_8 0
-#define CURL_SUPPORT_MAC_10_5 0
-#define CURL_SUPPORT_MAC_10_6 0
-#define CURL_SUPPORT_MAC_10_7 0
-#define CURL_SUPPORT_MAC_10_8 0
-#define CURL_SUPPORT_MAC_10_9 0
-
-#else
-#error "The darwinssl back-end requires iOS or OS X."
-#endif /* (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) */
-
-#if CURL_BUILD_MAC
-#include <sys/sysctl.h>
-#endif /* CURL_BUILD_MAC */
-
-#include "urldata.h"
-#include "sendf.h"
-#include "inet_pton.h"
-#include "connect.h"
-#include "select.h"
-#include "vtls.h"
-#include "darwinssl.h"
-#include "curl_printf.h"
-
-#include "curl_memory.h"
-/* The last #include file should be: */
-#include "memdebug.h"
-
-/* From MacTypes.h (which we can't include because it isn't present in iOS: */
-#define ioErr -36
-#define paramErr -50
-
-#ifdef DARWIN_SSL_PINNEDPUBKEY
-/* both new and old APIs return rsa keys missing the spki header (not DER) */
-static const unsigned char rsa4096SpkiHeader[] = {
- 0x30, 0x82, 0x02, 0x22, 0x30, 0x0d,
- 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
- 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
- 0x00, 0x03, 0x82, 0x02, 0x0f, 0x00};
-
-static const unsigned char rsa2048SpkiHeader[] = {
- 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d,
- 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
- 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
- 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00};
-#ifdef DARWIN_SSL_PINNEDPUBKEY_V1
-/* the *new* version doesn't return DER encoded ecdsa certs like the old... */
-static const unsigned char ecDsaSecp256r1SpkiHeader[] = {
- 0x30, 0x59, 0x30, 0x13, 0x06, 0x07,
- 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
- 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48,
- 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03,
- 0x42, 0x00};
-
-static const unsigned char ecDsaSecp384r1SpkiHeader[] = {
- 0x30, 0x76, 0x30, 0x10, 0x06, 0x07,
- 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
- 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04,
- 0x00, 0x22, 0x03, 0x62, 0x00};
-#endif /* DARWIN_SSL_PINNEDPUBKEY_V1 */
-#endif /* DARWIN_SSL_PINNEDPUBKEY */
-
-/* The following two functions were ripped from Apple sample code,
- * with some modifications: */
-static OSStatus SocketRead(SSLConnectionRef connection,
- void *data, /* owned by
- * caller, data
- * RETURNED */
- size_t *dataLength) /* IN/OUT */
-{
- size_t bytesToGo = *dataLength;
- size_t initLen = bytesToGo;
- UInt8 *currData = (UInt8 *)data;
- /*int sock = *(int *)connection;*/
- struct ssl_connect_data *connssl = (struct ssl_connect_data *)connection;
- int sock = connssl->ssl_sockfd;
- OSStatus rtn = noErr;
- size_t bytesRead;
- ssize_t rrtn;
- int theErr;
-
- *dataLength = 0;
-
- for(;;) {
- bytesRead = 0;
- rrtn = read(sock, currData, bytesToGo);
- if(rrtn <= 0) {
- /* this is guesswork... */
- theErr = errno;
- if(rrtn == 0) { /* EOF = server hung up */
- /* the framework will turn this into errSSLClosedNoNotify */
- rtn = errSSLClosedGraceful;
- }
- else /* do the switch */
- switch(theErr) {
- case ENOENT:
- /* connection closed */
- rtn = errSSLClosedGraceful;
- break;
- case ECONNRESET:
- rtn = errSSLClosedAbort;
- break;
- case EAGAIN:
- rtn = errSSLWouldBlock;
- connssl->ssl_direction = false;
- break;
- default:
- rtn = ioErr;
- break;
- }
- break;
- }
- else {
- bytesRead = rrtn;
- }
- bytesToGo -= bytesRead;
- currData += bytesRead;
-
- if(bytesToGo == 0) {
- /* filled buffer with incoming data, done */
- break;
- }
- }
- *dataLength = initLen - bytesToGo;
-
- return rtn;
-}
-
-static OSStatus SocketWrite(SSLConnectionRef connection,
- const void *data,
- size_t *dataLength) /* IN/OUT */
-{
- size_t bytesSent = 0;
- /*int sock = *(int *)connection;*/
- struct ssl_connect_data *connssl = (struct ssl_connect_data *)connection;
- int sock = connssl->ssl_sockfd;
- ssize_t length;
- size_t dataLen = *dataLength;
- const UInt8 *dataPtr = (UInt8 *)data;
- OSStatus ortn;
- int theErr;
-
- *dataLength = 0;
-
- do {
- length = write(sock,
- (char *)dataPtr + bytesSent,
- dataLen - bytesSent);
- } while((length > 0) &&
- ( (bytesSent += length) < dataLen) );
-
- if(length <= 0) {
- theErr = errno;
- if(theErr == EAGAIN) {
- ortn = errSSLWouldBlock;
- connssl->ssl_direction = true;
- }
- else {
- ortn = ioErr;
- }
- }
- else {
- ortn = noErr;
- }
- *dataLength = bytesSent;
- return ortn;
-}
-
-#ifndef CURL_DISABLE_VERBOSE_STRINGS
-CF_INLINE const char *SSLCipherNameForNumber(SSLCipherSuite cipher)
-{
- switch(cipher) {
- /* SSL version 3.0 */
- case SSL_RSA_WITH_NULL_MD5:
- return "SSL_RSA_WITH_NULL_MD5";
- break;
- case SSL_RSA_WITH_NULL_SHA:
- return "SSL_RSA_WITH_NULL_SHA";
- break;
- case SSL_RSA_EXPORT_WITH_RC4_40_MD5:
- return "SSL_RSA_EXPORT_WITH_RC4_40_MD5";
- break;
- case SSL_RSA_WITH_RC4_128_MD5:
- return "SSL_RSA_WITH_RC4_128_MD5";
- break;
- case SSL_RSA_WITH_RC4_128_SHA:
- return "SSL_RSA_WITH_RC4_128_SHA";
- break;
- case SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5:
- return "SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5";
- break;
- case SSL_RSA_WITH_IDEA_CBC_SHA:
- return "SSL_RSA_WITH_IDEA_CBC_SHA";
- break;
- case SSL_RSA_EXPORT_WITH_DES40_CBC_SHA:
- return "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA";
- break;
- case SSL_RSA_WITH_DES_CBC_SHA:
- return "SSL_RSA_WITH_DES_CBC_SHA";
- break;
- case SSL_RSA_WITH_3DES_EDE_CBC_SHA:
- return "SSL_RSA_WITH_3DES_EDE_CBC_SHA";
- break;
- case SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA:
- return "SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA";
- break;
- case SSL_DH_DSS_WITH_DES_CBC_SHA:
- return "SSL_DH_DSS_WITH_DES_CBC_SHA";
- break;
- case SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA:
- return "SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA";
- break;
- case SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA:
- return "SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA";
- break;
- case SSL_DH_RSA_WITH_DES_CBC_SHA:
- return "SSL_DH_RSA_WITH_DES_CBC_SHA";
- break;
- case SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA:
- return "SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA";
- break;
- case SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA:
- return "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA";
- break;
- case SSL_DHE_DSS_WITH_DES_CBC_SHA:
- return "SSL_DHE_DSS_WITH_DES_CBC_SHA";
- break;
- case SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA:
- return "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA";
- break;
- case SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA:
- return "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA";
- break;
- case SSL_DHE_RSA_WITH_DES_CBC_SHA:
- return "SSL_DHE_RSA_WITH_DES_CBC_SHA";
- break;
- case SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA:
- return "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA";
- break;
- case SSL_DH_anon_EXPORT_WITH_RC4_40_MD5:
- return "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5";
- break;
- case SSL_DH_anon_WITH_RC4_128_MD5:
- return "SSL_DH_anon_WITH_RC4_128_MD5";
- break;
- case SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA:
- return "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA";
- break;
- case SSL_DH_anon_WITH_DES_CBC_SHA:
- return "SSL_DH_anon_WITH_DES_CBC_SHA";
- break;
- case SSL_DH_anon_WITH_3DES_EDE_CBC_SHA:
- return "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA";
- break;
- case SSL_FORTEZZA_DMS_WITH_NULL_SHA:
- return "SSL_FORTEZZA_DMS_WITH_NULL_SHA";
- break;
- case SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA:
- return "SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA";
- break;
- /* TLS 1.0 with AES (RFC 3268)
- (Apparently these are used in SSLv3 implementations as well.) */
- case TLS_RSA_WITH_AES_128_CBC_SHA:
- return "TLS_RSA_WITH_AES_128_CBC_SHA";
- break;
- case TLS_DH_DSS_WITH_AES_128_CBC_SHA:
- return "TLS_DH_DSS_WITH_AES_128_CBC_SHA";
- break;
- case TLS_DH_RSA_WITH_AES_128_CBC_SHA:
- return "TLS_DH_RSA_WITH_AES_128_CBC_SHA";
- break;
- case TLS_DHE_DSS_WITH_AES_128_CBC_SHA:
- return "TLS_DHE_DSS_WITH_AES_128_CBC_SHA";
- break;
- case TLS_DHE_RSA_WITH_AES_128_CBC_SHA:
- return "TLS_DHE_RSA_WITH_AES_128_CBC_SHA";
- break;
- case TLS_DH_anon_WITH_AES_128_CBC_SHA:
- return "TLS_DH_anon_WITH_AES_128_CBC_SHA";
- break;
- case TLS_RSA_WITH_AES_256_CBC_SHA:
- return "TLS_RSA_WITH_AES_256_CBC_SHA";
- break;
- case TLS_DH_DSS_WITH_AES_256_CBC_SHA:
- return "TLS_DH_DSS_WITH_AES_256_CBC_SHA";
- break;
- case TLS_DH_RSA_WITH_AES_256_CBC_SHA:
- return "TLS_DH_RSA_WITH_AES_256_CBC_SHA";
- break;
- case TLS_DHE_DSS_WITH_AES_256_CBC_SHA:
- return "TLS_DHE_DSS_WITH_AES_256_CBC_SHA";
- break;
- case TLS_DHE_RSA_WITH_AES_256_CBC_SHA:
- return "TLS_DHE_RSA_WITH_AES_256_CBC_SHA";
- break;
- case TLS_DH_anon_WITH_AES_256_CBC_SHA:
- return "TLS_DH_anon_WITH_AES_256_CBC_SHA";
- break;
- /* SSL version 2.0 */
- case SSL_RSA_WITH_RC2_CBC_MD5:
- return "SSL_RSA_WITH_RC2_CBC_MD5";
- break;
- case SSL_RSA_WITH_IDEA_CBC_MD5:
- return "SSL_RSA_WITH_IDEA_CBC_MD5";
- break;
- case SSL_RSA_WITH_DES_CBC_MD5:
- return "SSL_RSA_WITH_DES_CBC_MD5";
- break;
- case SSL_RSA_WITH_3DES_EDE_CBC_MD5:
- return "SSL_RSA_WITH_3DES_EDE_CBC_MD5";
- break;
- }
- return "SSL_NULL_WITH_NULL_NULL";
-}
-
-CF_INLINE const char *TLSCipherNameForNumber(SSLCipherSuite cipher)
-{
- switch(cipher) {
- /* TLS 1.0 with AES (RFC 3268) */
- case TLS_RSA_WITH_AES_128_CBC_SHA:
- return "TLS_RSA_WITH_AES_128_CBC_SHA";
- break;
- case TLS_DH_DSS_WITH_AES_128_CBC_SHA:
- return "TLS_DH_DSS_WITH_AES_128_CBC_SHA";
- break;
- case TLS_DH_RSA_WITH_AES_128_CBC_SHA:
- return "TLS_DH_RSA_WITH_AES_128_CBC_SHA";
- break;
- case TLS_DHE_DSS_WITH_AES_128_CBC_SHA:
- return "TLS_DHE_DSS_WITH_AES_128_CBC_SHA";
- break;
- case TLS_DHE_RSA_WITH_AES_128_CBC_SHA:
- return "TLS_DHE_RSA_WITH_AES_128_CBC_SHA";
- break;
- case TLS_DH_anon_WITH_AES_128_CBC_SHA:
- return "TLS_DH_anon_WITH_AES_128_CBC_SHA";
- break;
- case TLS_RSA_WITH_AES_256_CBC_SHA:
- return "TLS_RSA_WITH_AES_256_CBC_SHA";
- break;
- case TLS_DH_DSS_WITH_AES_256_CBC_SHA:
- return "TLS_DH_DSS_WITH_AES_256_CBC_SHA";
- break;
- case TLS_DH_RSA_WITH_AES_256_CBC_SHA:
- return "TLS_DH_RSA_WITH_AES_256_CBC_SHA";
- break;
- case TLS_DHE_DSS_WITH_AES_256_CBC_SHA:
- return "TLS_DHE_DSS_WITH_AES_256_CBC_SHA";
- break;
- case TLS_DHE_RSA_WITH_AES_256_CBC_SHA:
- return "TLS_DHE_RSA_WITH_AES_256_CBC_SHA";
- break;
- case TLS_DH_anon_WITH_AES_256_CBC_SHA:
- return "TLS_DH_anon_WITH_AES_256_CBC_SHA";
- break;
-#if CURL_BUILD_MAC_10_6 || CURL_BUILD_IOS
- /* TLS 1.0 with ECDSA (RFC 4492) */
- case TLS_ECDH_ECDSA_WITH_NULL_SHA:
- return "TLS_ECDH_ECDSA_WITH_NULL_SHA";
- break;
- case TLS_ECDH_ECDSA_WITH_RC4_128_SHA:
- return "TLS_ECDH_ECDSA_WITH_RC4_128_SHA";
- break;
- case TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA:
- return "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA:
- return "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA";
- break;
- case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA:
- return "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA";
- break;
- case TLS_ECDHE_ECDSA_WITH_NULL_SHA:
- return "TLS_ECDHE_ECDSA_WITH_NULL_SHA";
- break;
- case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA:
- return "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA";
- break;
- case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA:
- return "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA:
- return "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA";
- break;
- case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA:
- return "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA";
- break;
- case TLS_ECDH_RSA_WITH_NULL_SHA:
- return "TLS_ECDH_RSA_WITH_NULL_SHA";
- break;
- case TLS_ECDH_RSA_WITH_RC4_128_SHA:
- return "TLS_ECDH_RSA_WITH_RC4_128_SHA";
- break;
- case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA:
- return "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA:
- return "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA";
- break;
- case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA:
- return "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA";
- break;
- case TLS_ECDHE_RSA_WITH_NULL_SHA:
- return "TLS_ECDHE_RSA_WITH_NULL_SHA";
- break;
- case TLS_ECDHE_RSA_WITH_RC4_128_SHA:
- return "TLS_ECDHE_RSA_WITH_RC4_128_SHA";
- break;
- case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA:
- return "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:
- return "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA";
- break;
- case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:
- return "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA";
- break;
- case TLS_ECDH_anon_WITH_NULL_SHA:
- return "TLS_ECDH_anon_WITH_NULL_SHA";
- break;
- case TLS_ECDH_anon_WITH_RC4_128_SHA:
- return "TLS_ECDH_anon_WITH_RC4_128_SHA";
- break;
- case TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA:
- return "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_ECDH_anon_WITH_AES_128_CBC_SHA:
- return "TLS_ECDH_anon_WITH_AES_128_CBC_SHA";
- break;
- case TLS_ECDH_anon_WITH_AES_256_CBC_SHA:
- return "TLS_ECDH_anon_WITH_AES_256_CBC_SHA";
- break;
-#endif /* CURL_BUILD_MAC_10_6 || CURL_BUILD_IOS */
-#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
- /* TLS 1.2 (RFC 5246) */
- case TLS_RSA_WITH_NULL_MD5:
- return "TLS_RSA_WITH_NULL_MD5";
- break;
- case TLS_RSA_WITH_NULL_SHA:
- return "TLS_RSA_WITH_NULL_SHA";
- break;
- case TLS_RSA_WITH_RC4_128_MD5:
- return "TLS_RSA_WITH_RC4_128_MD5";
- break;
- case TLS_RSA_WITH_RC4_128_SHA:
- return "TLS_RSA_WITH_RC4_128_SHA";
- break;
- case TLS_RSA_WITH_3DES_EDE_CBC_SHA:
- return "TLS_RSA_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_RSA_WITH_NULL_SHA256:
- return "TLS_RSA_WITH_NULL_SHA256";
- break;
- case TLS_RSA_WITH_AES_128_CBC_SHA256:
- return "TLS_RSA_WITH_AES_128_CBC_SHA256";
- break;
- case TLS_RSA_WITH_AES_256_CBC_SHA256:
- return "TLS_RSA_WITH_AES_256_CBC_SHA256";
- break;
- case TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA:
- return "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA:
- return "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA:
- return "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:
- return "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_DH_DSS_WITH_AES_128_CBC_SHA256:
- return "TLS_DH_DSS_WITH_AES_128_CBC_SHA256";
- break;
- case TLS_DH_RSA_WITH_AES_128_CBC_SHA256:
- return "TLS_DH_RSA_WITH_AES_128_CBC_SHA256";
- break;
- case TLS_DHE_DSS_WITH_AES_128_CBC_SHA256:
- return "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256";
- break;
- case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256:
- return "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256";
- break;
- case TLS_DH_DSS_WITH_AES_256_CBC_SHA256:
- return "TLS_DH_DSS_WITH_AES_256_CBC_SHA256";
- break;
- case TLS_DH_RSA_WITH_AES_256_CBC_SHA256:
- return "TLS_DH_RSA_WITH_AES_256_CBC_SHA256";
- break;
- case TLS_DHE_DSS_WITH_AES_256_CBC_SHA256:
- return "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256";
- break;
- case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256:
- return "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256";
- break;
- case TLS_DH_anon_WITH_RC4_128_MD5:
- return "TLS_DH_anon_WITH_RC4_128_MD5";
- break;
- case TLS_DH_anon_WITH_3DES_EDE_CBC_SHA:
- return "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_DH_anon_WITH_AES_128_CBC_SHA256:
- return "TLS_DH_anon_WITH_AES_128_CBC_SHA256";
- break;
- case TLS_DH_anon_WITH_AES_256_CBC_SHA256:
- return "TLS_DH_anon_WITH_AES_256_CBC_SHA256";
- break;
- /* TLS 1.2 with AES GCM (RFC 5288) */
- case TLS_RSA_WITH_AES_128_GCM_SHA256:
- return "TLS_RSA_WITH_AES_128_GCM_SHA256";
- break;
- case TLS_RSA_WITH_AES_256_GCM_SHA384:
- return "TLS_RSA_WITH_AES_256_GCM_SHA384";
- break;
- case TLS_DHE_RSA_WITH_AES_128_GCM_SHA256:
- return "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256";
- break;
- case TLS_DHE_RSA_WITH_AES_256_GCM_SHA384:
- return "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384";
- break;
- case TLS_DH_RSA_WITH_AES_128_GCM_SHA256:
- return "TLS_DH_RSA_WITH_AES_128_GCM_SHA256";
- break;
- case TLS_DH_RSA_WITH_AES_256_GCM_SHA384:
- return "TLS_DH_RSA_WITH_AES_256_GCM_SHA384";
- break;
- case TLS_DHE_DSS_WITH_AES_128_GCM_SHA256:
- return "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256";
- break;
- case TLS_DHE_DSS_WITH_AES_256_GCM_SHA384:
- return "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384";
- break;
- case TLS_DH_DSS_WITH_AES_128_GCM_SHA256:
- return "TLS_DH_DSS_WITH_AES_128_GCM_SHA256";
- break;
- case TLS_DH_DSS_WITH_AES_256_GCM_SHA384:
- return "TLS_DH_DSS_WITH_AES_256_GCM_SHA384";
- break;
- case TLS_DH_anon_WITH_AES_128_GCM_SHA256:
- return "TLS_DH_anon_WITH_AES_128_GCM_SHA256";
- break;
- case TLS_DH_anon_WITH_AES_256_GCM_SHA384:
- return "TLS_DH_anon_WITH_AES_256_GCM_SHA384";
- break;
- /* TLS 1.2 with elliptic curve ciphers (RFC 5289) */
- case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256:
- return "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256";
- break;
- case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384:
- return "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384";
- break;
- case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256:
- return "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256";
- break;
- case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384:
- return "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384";
- break;
- case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:
- return "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256";
- break;
- case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:
- return "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384";
- break;
- case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256:
- return "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256";
- break;
- case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384:
- return "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384";
- break;
- case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:
- return "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256";
- break;
- case TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:
- return "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384";
- break;
- case TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256:
- return "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256";
- break;
- case TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384:
- return "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384";
- break;
- case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:
- return "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256";
- break;
- case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:
- return "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384";
- break;
- case TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256:
- return "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256";
- break;
- case TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384:
- return "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384";
- break;
- case TLS_EMPTY_RENEGOTIATION_INFO_SCSV:
- return "TLS_EMPTY_RENEGOTIATION_INFO_SCSV";
- break;
-#else
- case SSL_RSA_WITH_NULL_MD5:
- return "TLS_RSA_WITH_NULL_MD5";
- break;
- case SSL_RSA_WITH_NULL_SHA:
- return "TLS_RSA_WITH_NULL_SHA";
- break;
- case SSL_RSA_WITH_RC4_128_MD5:
- return "TLS_RSA_WITH_RC4_128_MD5";
- break;
- case SSL_RSA_WITH_RC4_128_SHA:
- return "TLS_RSA_WITH_RC4_128_SHA";
- break;
- case SSL_RSA_WITH_3DES_EDE_CBC_SHA:
- return "TLS_RSA_WITH_3DES_EDE_CBC_SHA";
- break;
- case SSL_DH_anon_WITH_RC4_128_MD5:
- return "TLS_DH_anon_WITH_RC4_128_MD5";
- break;
- case SSL_DH_anon_WITH_3DES_EDE_CBC_SHA:
- return "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA";
- break;
-#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
-#if CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7
- /* TLS PSK (RFC 4279): */
- case TLS_PSK_WITH_RC4_128_SHA:
- return "TLS_PSK_WITH_RC4_128_SHA";
- break;
- case TLS_PSK_WITH_3DES_EDE_CBC_SHA:
- return "TLS_PSK_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_PSK_WITH_AES_128_CBC_SHA:
- return "TLS_PSK_WITH_AES_128_CBC_SHA";
- break;
- case TLS_PSK_WITH_AES_256_CBC_SHA:
- return "TLS_PSK_WITH_AES_256_CBC_SHA";
- break;
- case TLS_DHE_PSK_WITH_RC4_128_SHA:
- return "TLS_DHE_PSK_WITH_RC4_128_SHA";
- break;
- case TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA:
- return "TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_DHE_PSK_WITH_AES_128_CBC_SHA:
- return "TLS_DHE_PSK_WITH_AES_128_CBC_SHA";
- break;
- case TLS_DHE_PSK_WITH_AES_256_CBC_SHA:
- return "TLS_DHE_PSK_WITH_AES_256_CBC_SHA";
- break;
- case TLS_RSA_PSK_WITH_RC4_128_SHA:
- return "TLS_RSA_PSK_WITH_RC4_128_SHA";
- break;
- case TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA:
- return "TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA";
- break;
- case TLS_RSA_PSK_WITH_AES_128_CBC_SHA:
- return "TLS_RSA_PSK_WITH_AES_128_CBC_SHA";
- break;
- case TLS_RSA_PSK_WITH_AES_256_CBC_SHA:
- return "TLS_RSA_PSK_WITH_AES_256_CBC_SHA";
- break;
- /* More TLS PSK (RFC 4785): */
- case TLS_PSK_WITH_NULL_SHA:
- return "TLS_PSK_WITH_NULL_SHA";
- break;
- case TLS_DHE_PSK_WITH_NULL_SHA:
- return "TLS_DHE_PSK_WITH_NULL_SHA";
- break;
- case TLS_RSA_PSK_WITH_NULL_SHA:
- return "TLS_RSA_PSK_WITH_NULL_SHA";
- break;
- /* Even more TLS PSK (RFC 5487): */
- case TLS_PSK_WITH_AES_128_GCM_SHA256:
- return "TLS_PSK_WITH_AES_128_GCM_SHA256";
- break;
- case TLS_PSK_WITH_AES_256_GCM_SHA384:
- return "TLS_PSK_WITH_AES_256_GCM_SHA384";
- break;
- case TLS_DHE_PSK_WITH_AES_128_GCM_SHA256:
- return "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256";
- break;
- case TLS_DHE_PSK_WITH_AES_256_GCM_SHA384:
- return "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384";
- break;
- case TLS_RSA_PSK_WITH_AES_128_GCM_SHA256:
- return "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256";
- break;
- case TLS_RSA_PSK_WITH_AES_256_GCM_SHA384:
- return "TLS_PSK_WITH_AES_256_GCM_SHA384";
- break;
- case TLS_PSK_WITH_AES_128_CBC_SHA256:
- return "TLS_PSK_WITH_AES_128_CBC_SHA256";
- break;
- case TLS_PSK_WITH_AES_256_CBC_SHA384:
- return "TLS_PSK_WITH_AES_256_CBC_SHA384";
- break;
- case TLS_PSK_WITH_NULL_SHA256:
- return "TLS_PSK_WITH_NULL_SHA256";
- break;
- case TLS_PSK_WITH_NULL_SHA384:
- return "TLS_PSK_WITH_NULL_SHA384";
- break;
- case TLS_DHE_PSK_WITH_AES_128_CBC_SHA256:
- return "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256";
- break;
- case TLS_DHE_PSK_WITH_AES_256_CBC_SHA384:
- return "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384";
- break;
- case TLS_DHE_PSK_WITH_NULL_SHA256:
- return "TLS_DHE_PSK_WITH_NULL_SHA256";
- break;
- case TLS_DHE_PSK_WITH_NULL_SHA384:
- return "TLS_RSA_PSK_WITH_NULL_SHA384";
- break;
- case TLS_RSA_PSK_WITH_AES_128_CBC_SHA256:
- return "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256";
- break;
- case TLS_RSA_PSK_WITH_AES_256_CBC_SHA384:
- return "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384";
- break;
- case TLS_RSA_PSK_WITH_NULL_SHA256:
- return "TLS_RSA_PSK_WITH_NULL_SHA256";
- break;
- case TLS_RSA_PSK_WITH_NULL_SHA384:
- return "TLS_RSA_PSK_WITH_NULL_SHA384";
- break;
-#endif /* CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7 */
- }
- return "TLS_NULL_WITH_NULL_NULL";
-}
-#endif /* !CURL_DISABLE_VERBOSE_STRINGS */
-
-#if CURL_BUILD_MAC
-CF_INLINE void GetDarwinVersionNumber(int *major, int *minor)
-{
- int mib[2];
- char *os_version;
- size_t os_version_len;
- char *os_version_major, *os_version_minor;
- char *tok_buf;
-
- /* Get the Darwin kernel version from the kernel using sysctl(): */
- mib[0] = CTL_KERN;
- mib[1] = KERN_OSRELEASE;
- if(sysctl(mib, 2, NULL, &os_version_len, NULL, 0) == -1)
- return;
- os_version = malloc(os_version_len*sizeof(char));
- if(!os_version)
- return;
- if(sysctl(mib, 2, os_version, &os_version_len, NULL, 0) == -1) {
- free(os_version);
- return;
- }
-
- /* Parse the version: */
- os_version_major = strtok_r(os_version, ".", &tok_buf);
- os_version_minor = strtok_r(NULL, ".", &tok_buf);
- *major = atoi(os_version_major);
- *minor = atoi(os_version_minor);
- free(os_version);
-}
-#endif /* CURL_BUILD_MAC */
-
-/* Apple provides a myriad of ways of getting information about a certificate
- into a string. Some aren't available under iOS or newer cats. So here's
- a unified function for getting a string describing the certificate that
- ought to work in all cats starting with Leopard. */
-CF_INLINE CFStringRef CopyCertSubject(SecCertificateRef cert)
-{
- CFStringRef server_cert_summary = CFSTR("(null)");
-
-#if CURL_BUILD_IOS
- /* iOS: There's only one way to do this. */
- server_cert_summary = SecCertificateCopySubjectSummary(cert);
-#else
-#if CURL_BUILD_MAC_10_7
- /* Lion & later: Get the long description if we can. */
- if(SecCertificateCopyLongDescription != NULL)
- server_cert_summary =
- SecCertificateCopyLongDescription(NULL, cert, NULL);
- else
-#endif /* CURL_BUILD_MAC_10_7 */
-#if CURL_BUILD_MAC_10_6
- /* Snow Leopard: Get the certificate summary. */
- if(SecCertificateCopySubjectSummary != NULL)
- server_cert_summary = SecCertificateCopySubjectSummary(cert);
- else
-#endif /* CURL_BUILD_MAC_10_6 */
- /* Leopard is as far back as we go... */
- (void)SecCertificateCopyCommonName(cert, &server_cert_summary);
-#endif /* CURL_BUILD_IOS */
- return server_cert_summary;
-}
-
-#if CURL_SUPPORT_MAC_10_6
-/* The SecKeychainSearch API was deprecated in Lion, and using it will raise
- deprecation warnings, so let's not compile this unless it's necessary: */
-static OSStatus CopyIdentityWithLabelOldSchool(char *label,
- SecIdentityRef *out_c_a_k)
-{
- OSStatus status = errSecItemNotFound;
- SecKeychainAttributeList attr_list;
- SecKeychainAttribute attr;
- SecKeychainSearchRef search = NULL;
- SecCertificateRef cert = NULL;
-
- /* Set up the attribute list: */
- attr_list.count = 1L;
- attr_list.attr = &attr;
-
- /* Set up our lone search criterion: */
- attr.tag = kSecLabelItemAttr;
- attr.data = label;
- attr.length = (UInt32)strlen(label);
-
- /* Start searching: */
- status = SecKeychainSearchCreateFromAttributes(NULL,
- kSecCertificateItemClass,
- &attr_list,
- &search);
- if(status == noErr) {
- status = SecKeychainSearchCopyNext(search,
- (SecKeychainItemRef *)&cert);
- if(status == noErr && cert) {
- /* If we found a certificate, does it have a private key? */
- status = SecIdentityCreateWithCertificate(NULL, cert, out_c_a_k);
- CFRelease(cert);
- }
- }
-
- if(search)
- CFRelease(search);
- return status;
-}
-#endif /* CURL_SUPPORT_MAC_10_6 */
-
-static OSStatus CopyIdentityWithLabel(char *label,
- SecIdentityRef *out_cert_and_key)
-{
- OSStatus status = errSecItemNotFound;
-
-#if CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS
- CFArrayRef keys_list;
- CFIndex keys_list_count;
- CFIndex i;
- CFStringRef common_name;
-
- /* SecItemCopyMatching() was introduced in iOS and Snow Leopard.
- kSecClassIdentity was introduced in Lion. If both exist, let's use them
- to find the certificate. */
- if(SecItemCopyMatching != NULL && kSecClassIdentity != NULL) {
- CFTypeRef keys[5];
- CFTypeRef values[5];
- CFDictionaryRef query_dict;
- CFStringRef label_cf = CFStringCreateWithCString(NULL, label,
- kCFStringEncodingUTF8);
-
- /* Set up our search criteria and expected results: */
- values[0] = kSecClassIdentity; /* we want a certificate and a key */
- keys[0] = kSecClass;
- values[1] = kCFBooleanTrue; /* we want a reference */
- keys[1] = kSecReturnRef;
- values[2] = kSecMatchLimitAll; /* kSecMatchLimitOne would be better if the
- * label matching below worked correctly */
- keys[2] = kSecMatchLimit;
- /* identity searches need a SecPolicyRef in order to work */
- values[3] = SecPolicyCreateSSL(false, NULL);
- keys[3] = kSecMatchPolicy;
- /* match the name of the certificate (doesn't work in macOS 10.12.1) */
- values[4] = label_cf;
- keys[4] = kSecAttrLabel;
- query_dict = CFDictionaryCreate(NULL, (const void **)keys,
- (const void **)values, 5L,
- &kCFCopyStringDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
- CFRelease(values[3]);
-
- /* Do we have a match? */
- status = SecItemCopyMatching(query_dict, (CFTypeRef *) &keys_list);
-
- /* Because kSecAttrLabel matching doesn't work with kSecClassIdentity,
- * we need to find the correct identity ourselves */
- if(status == noErr) {
- keys_list_count = CFArrayGetCount(keys_list);
- *out_cert_and_key = NULL;
- status = 1;
- for(i=0; i<keys_list_count; i++) {
- OSStatus err = noErr;
- SecCertificateRef cert = NULL;
- SecIdentityRef identity =
- (SecIdentityRef) CFArrayGetValueAtIndex(keys_list, i);
- err = SecIdentityCopyCertificate(identity, &cert);
- if(err == noErr) {
-#if CURL_BUILD_IOS
- common_name = SecCertificateCopySubjectSummary(cert);
-#elif CURL_BUILD_MAC_10_7
- SecCertificateCopyCommonName(cert, &common_name);
-#endif
- if(CFStringCompare(common_name, label_cf, 0) == kCFCompareEqualTo) {
- CFRelease(cert);
- CFRelease(common_name);
- CFRetain(identity);
- *out_cert_and_key = identity;
- status = noErr;
- break;
- }
- CFRelease(common_name);
- }
- CFRelease(cert);
- }
- }
-
- if(keys_list)
- CFRelease(keys_list);
- CFRelease(query_dict);
- CFRelease(label_cf);
- }
- else {
-#if CURL_SUPPORT_MAC_10_6
- /* On Leopard and Snow Leopard, fall back to SecKeychainSearch. */
- status = CopyIdentityWithLabelOldSchool(label, out_cert_and_key);
-#endif /* CURL_SUPPORT_MAC_10_6 */
- }
-#elif CURL_SUPPORT_MAC_10_6
- /* For developers building on older cats, we have no choice but to fall back
- to SecKeychainSearch. */
- status = CopyIdentityWithLabelOldSchool(label, out_cert_and_key);
-#endif /* CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS */
- return status;
-}
-
-static OSStatus CopyIdentityFromPKCS12File(const char *cPath,
- const char *cPassword,
- SecIdentityRef *out_cert_and_key)
-{
- OSStatus status = errSecItemNotFound;
- CFURLRef pkcs_url = CFURLCreateFromFileSystemRepresentation(NULL,
- (const UInt8 *)cPath, strlen(cPath), false);
- CFStringRef password = cPassword ? CFStringCreateWithCString(NULL,
- cPassword, kCFStringEncodingUTF8) : NULL;
- CFDataRef pkcs_data = NULL;
-
- /* We can import P12 files on iOS or OS X 10.7 or later: */
- /* These constants are documented as having first appeared in 10.6 but they
- raise linker errors when used on that cat for some reason. */
-#if CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS
- if(CFURLCreateDataAndPropertiesFromResource(NULL, pkcs_url, &pkcs_data,
- NULL, NULL, &status)) {
- const void *cKeys[] = {kSecImportExportPassphrase};
- const void *cValues[] = {password};
- CFDictionaryRef options = CFDictionaryCreate(NULL, cKeys, cValues,
- password ? 1L : 0L, NULL, NULL);
- CFArrayRef items = NULL;
-
- /* Here we go: */
- status = SecPKCS12Import(pkcs_data, options, &items);
- if(status == errSecSuccess && items && CFArrayGetCount(items)) {
- CFDictionaryRef identity_and_trust = CFArrayGetValueAtIndex(items, 0L);
- const void *temp_identity = CFDictionaryGetValue(identity_and_trust,
- kSecImportItemIdentity);
-
- /* Retain the identity; we don't care about any other data... */
- CFRetain(temp_identity);
- *out_cert_and_key = (SecIdentityRef)temp_identity;
- }
-
- if(items)
- CFRelease(items);
- CFRelease(options);
- CFRelease(pkcs_data);
- }
-#endif /* CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS */
- if(password)
- CFRelease(password);
- CFRelease(pkcs_url);
- return status;
-}
-
-/* This code was borrowed from nss.c, with some modifications:
- * Determine whether the nickname passed in is a filename that needs to
- * be loaded as a PEM or a regular NSS nickname.
- *
- * returns 1 for a file
- * returns 0 for not a file
- */
-CF_INLINE bool is_file(const char *filename)
-{
- struct_stat st;
-
- if(filename == NULL)
- return false;
-
- if(stat(filename, &st) == 0)
- return S_ISREG(st.st_mode);
- return false;
-}
-
-#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
-static CURLcode darwinssl_version_from_curl(long *darwinver, long ssl_version)
-{
- switch(ssl_version) {
- case CURL_SSLVERSION_TLSv1_0:
- *darwinver = kTLSProtocol1;
- return CURLE_OK;
- case CURL_SSLVERSION_TLSv1_1:
- *darwinver = kTLSProtocol11;
- return CURLE_OK;
- case CURL_SSLVERSION_TLSv1_2:
- *darwinver = kTLSProtocol12;
- return CURLE_OK;
- case CURL_SSLVERSION_TLSv1_3:
- break;
- }
- return CURLE_SSL_CONNECT_ERROR;
-}
-#endif
-
-static CURLcode
-set_ssl_version_min_max(struct connectdata *conn, int sockindex)
-{
- struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- long ssl_version = SSL_CONN_CONFIG(version);
- long ssl_version_max = SSL_CONN_CONFIG(version_max);
-
- switch(ssl_version) {
- case CURL_SSLVERSION_DEFAULT:
- case CURL_SSLVERSION_TLSv1:
- ssl_version = CURL_SSLVERSION_TLSv1_0;
- ssl_version_max = CURL_SSLVERSION_MAX_TLSv1_2;
- break;
- }
-
- switch(ssl_version_max) {
- case CURL_SSLVERSION_MAX_NONE:
- ssl_version_max = ssl_version << 16;
- break;
- case CURL_SSLVERSION_MAX_DEFAULT:
- ssl_version_max = CURL_SSLVERSION_MAX_TLSv1_2;
- break;
- }
-
-#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
- if(SSLSetProtocolVersionMax != NULL) {
- SSLProtocol darwin_ver_min = kTLSProtocol1;
- SSLProtocol darwin_ver_max = kTLSProtocol1;
- CURLcode result = darwinssl_version_from_curl(&darwin_ver_min,
- ssl_version);
- if(result) {
- failf(data, "unsupported min version passed via CURLOPT_SSLVERSION");
- return result;
- }
- result = darwinssl_version_from_curl(&darwin_ver_max,
- ssl_version_max >> 16);
- if(result) {
- failf(data, "unsupported max version passed via CURLOPT_SSLVERSION");
- return result;
- }
-
- (void)SSLSetProtocolVersionMin(connssl->ssl_ctx, darwin_ver_min);
- (void)SSLSetProtocolVersionMax(connssl->ssl_ctx, darwin_ver_max);
- return result;
- }
- else {
-#if CURL_SUPPORT_MAC_10_8
- long i = ssl_version;
- (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
- kSSLProtocolAll,
- false);
- for(; i <= (ssl_version_max >> 16); i++) {
- switch(i) {
- case CURL_SSLVERSION_TLSv1_0:
- (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
- kTLSProtocol1,
- true);
- break;
- case CURL_SSLVERSION_TLSv1_1:
- (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
- kTLSProtocol11,
- true);
- break;
- case CURL_SSLVERSION_TLSv1_2:
- (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
- kTLSProtocol12,
- true);
- break;
- case CURL_SSLVERSION_TLSv1_3:
- failf(data, "DarwinSSL: TLS 1.3 is not yet supported");
- return CURLE_SSL_CONNECT_ERROR;
- }
- }
- return CURLE_OK;
-#endif /* CURL_SUPPORT_MAC_10_8 */
- }
-#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
- failf(data, "DarwinSSL: cannot set SSL protocol");
- return CURLE_SSL_CONNECT_ERROR;
-}
-
-
-static CURLcode darwinssl_connect_step1(struct connectdata *conn,
- int sockindex)
-{
- struct Curl_easy *data = conn->data;
- curl_socket_t sockfd = conn->sock[sockindex];
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- const char * const ssl_cafile = SSL_CONN_CONFIG(CAfile);
- const bool verifypeer = SSL_CONN_CONFIG(verifypeer);
- char * const ssl_cert = SSL_SET_OPTION(cert);
- const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
- conn->host.name;
- const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port;
-#ifdef ENABLE_IPV6
- struct in6_addr addr;
-#else
- struct in_addr addr;
-#endif /* ENABLE_IPV6 */
- size_t all_ciphers_count = 0UL, allowed_ciphers_count = 0UL, i;
- SSLCipherSuite *all_ciphers = NULL, *allowed_ciphers = NULL;
- OSStatus err = noErr;
-#if CURL_BUILD_MAC
- int darwinver_maj = 0, darwinver_min = 0;
-
- GetDarwinVersionNumber(&darwinver_maj, &darwinver_min);
-#endif /* CURL_BUILD_MAC */
-
-#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
- if(SSLCreateContext != NULL) { /* use the newer API if avaialble */
- if(connssl->ssl_ctx)
- CFRelease(connssl->ssl_ctx);
- connssl->ssl_ctx = SSLCreateContext(NULL, kSSLClientSide, kSSLStreamType);
- if(!connssl->ssl_ctx) {
- failf(data, "SSL: couldn't create a context!");
- return CURLE_OUT_OF_MEMORY;
- }
- }
- else {
- /* The old ST API does not exist under iOS, so don't compile it: */
-#if CURL_SUPPORT_MAC_10_8
- if(connssl->ssl_ctx)
- (void)SSLDisposeContext(connssl->ssl_ctx);
- err = SSLNewContext(false, &(connssl->ssl_ctx));
- if(err != noErr) {
- failf(data, "SSL: couldn't create a context: OSStatus %d", err);
- return CURLE_OUT_OF_MEMORY;
- }
-#endif /* CURL_SUPPORT_MAC_10_8 */
- }
-#else
- if(connssl->ssl_ctx)
- (void)SSLDisposeContext(connssl->ssl_ctx);
- err = SSLNewContext(false, &(connssl->ssl_ctx));
- if(err != noErr) {
- failf(data, "SSL: couldn't create a context: OSStatus %d", err);
- return CURLE_OUT_OF_MEMORY;
- }
-#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
- connssl->ssl_write_buffered_length = 0UL; /* reset buffered write length */
-
- /* check to see if we've been told to use an explicit SSL/TLS version */
-#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
- if(SSLSetProtocolVersionMax != NULL) {
- switch(conn->ssl_config.version) {
- case CURL_SSLVERSION_DEFAULT:
- case CURL_SSLVERSION_TLSv1:
- (void)SSLSetProtocolVersionMin(connssl->ssl_ctx, kTLSProtocol1);
- (void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kTLSProtocol12);
- break;
- case CURL_SSLVERSION_TLSv1_0:
- case CURL_SSLVERSION_TLSv1_1:
- case CURL_SSLVERSION_TLSv1_2:
- case CURL_SSLVERSION_TLSv1_3:
- {
- CURLcode result = set_ssl_version_min_max(conn, sockindex);
- if(result != CURLE_OK)
- return result;
- break;
- }
- case CURL_SSLVERSION_SSLv3:
- err = SSLSetProtocolVersionMin(connssl->ssl_ctx, kSSLProtocol3);
- if(err != noErr) {
- failf(data, "Your version of the OS does not support SSLv3");
- return CURLE_SSL_CONNECT_ERROR;
- }
- (void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kSSLProtocol3);
- break;
- case CURL_SSLVERSION_SSLv2:
- err = SSLSetProtocolVersionMin(connssl->ssl_ctx, kSSLProtocol2);
- if(err != noErr) {
- failf(data, "Your version of the OS does not support SSLv2");
- return CURLE_SSL_CONNECT_ERROR;
- }
- (void)SSLSetProtocolVersionMax(connssl->ssl_ctx, kSSLProtocol2);
- break;
- default:
- failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION");
- return CURLE_SSL_CONNECT_ERROR;
- }
- }
- else {
-#if CURL_SUPPORT_MAC_10_8
- (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
- kSSLProtocolAll,
- false);
- switch(conn->ssl_config.version) {
- case CURL_SSLVERSION_DEFAULT:
- case CURL_SSLVERSION_TLSv1:
- (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
- kTLSProtocol1,
- true);
- (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
- kTLSProtocol11,
- true);
- (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
- kTLSProtocol12,
- true);
- break;
- case CURL_SSLVERSION_TLSv1_0:
- case CURL_SSLVERSION_TLSv1_1:
- case CURL_SSLVERSION_TLSv1_2:
- case CURL_SSLVERSION_TLSv1_3:
- {
- CURLcode result = set_ssl_version_min_max(conn, sockindex);
- if(result != CURLE_OK)
- return result;
- break;
- }
- case CURL_SSLVERSION_SSLv3:
- err = SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
- kSSLProtocol3,
- true);
- if(err != noErr) {
- failf(data, "Your version of the OS does not support SSLv3");
- return CURLE_SSL_CONNECT_ERROR;
- }
- break;
- case CURL_SSLVERSION_SSLv2:
- err = SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
- kSSLProtocol2,
- true);
- if(err != noErr) {
- failf(data, "Your version of the OS does not support SSLv2");
- return CURLE_SSL_CONNECT_ERROR;
- }
- break;
- default:
- failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION");
- return CURLE_SSL_CONNECT_ERROR;
- }
-#endif /* CURL_SUPPORT_MAC_10_8 */
- }
-#else
- if(conn->ssl_config.version_max != CURL_SSLVERSION_MAX_NONE) {
- failf(data, "Your version of the OS does not support to set maximum"
- " SSL/TLS version");
- return CURLE_SSL_CONNECT_ERROR;
- }
- (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx, kSSLProtocolAll, false);
- switch(conn->ssl_config.version) {
- case CURL_SSLVERSION_DEFAULT:
- case CURL_SSLVERSION_TLSv1:
- case CURL_SSLVERSION_TLSv1_0:
- (void)SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
- kTLSProtocol1,
- true);
- break;
- case CURL_SSLVERSION_TLSv1_1:
- failf(data, "Your version of the OS does not support TLSv1.1");
- return CURLE_SSL_CONNECT_ERROR;
- case CURL_SSLVERSION_TLSv1_2:
- failf(data, "Your version of the OS does not support TLSv1.2");
- return CURLE_SSL_CONNECT_ERROR;
- case CURL_SSLVERSION_TLSv1_3:
- failf(data, "Your version of the OS does not support TLSv1.3");
- return CURLE_SSL_CONNECT_ERROR;
- case CURL_SSLVERSION_SSLv2:
- err = SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
- kSSLProtocol2,
- true);
- if(err != noErr) {
- failf(data, "Your version of the OS does not support SSLv2");
- return CURLE_SSL_CONNECT_ERROR;
- }
- break;
- case CURL_SSLVERSION_SSLv3:
- err = SSLSetProtocolVersionEnabled(connssl->ssl_ctx,
- kSSLProtocol3,
- true);
- if(err != noErr) {
- failf(data, "Your version of the OS does not support SSLv3");
- return CURLE_SSL_CONNECT_ERROR;
- }
- break;
- default:
- failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION");
- return CURLE_SSL_CONNECT_ERROR;
- }
-#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
-
- if(SSL_SET_OPTION(key)) {
- infof(data, "WARNING: SSL: CURLOPT_SSLKEY is ignored by Secure "
- "Transport. The private key must be in the Keychain.\n");
- }
-
- if(ssl_cert) {
- SecIdentityRef cert_and_key = NULL;
- bool is_cert_file = is_file(ssl_cert);
-
- /* User wants to authenticate with a client cert. Look for it:
- If we detect that this is a file on disk, then let's load it.
- Otherwise, assume that the user wants to use an identity loaded
- from the Keychain. */
- if(is_cert_file) {
- if(!SSL_SET_OPTION(cert_type))
- infof(data, "WARNING: SSL: Certificate type not set, assuming "
- "PKCS#12 format.\n");
- else if(strncmp(SSL_SET_OPTION(cert_type), "P12",
- strlen(SSL_SET_OPTION(cert_type))) != 0)
- infof(data, "WARNING: SSL: The Security framework only supports "
- "loading identities that are in PKCS#12 format.\n");
-
- err = CopyIdentityFromPKCS12File(ssl_cert,
- SSL_SET_OPTION(key_passwd), &cert_and_key);
- }
- else
- err = CopyIdentityWithLabel(ssl_cert, &cert_and_key);
-
- if(err == noErr && cert_and_key) {
- SecCertificateRef cert = NULL;
- CFTypeRef certs_c[1];
- CFArrayRef certs;
-
- /* If we found one, print it out: */
- err = SecIdentityCopyCertificate(cert_and_key, &cert);
- if(err == noErr) {
- CFStringRef cert_summary = CopyCertSubject(cert);
- char cert_summary_c[128];
-
- if(cert_summary) {
- memset(cert_summary_c, 0, 128);
- if(CFStringGetCString(cert_summary,
- cert_summary_c,
- 128,
- kCFStringEncodingUTF8)) {
- infof(data, "Client certificate: %s\n", cert_summary_c);
- }
- CFRelease(cert_summary);
- CFRelease(cert);
- }
- }
- certs_c[0] = cert_and_key;
- certs = CFArrayCreate(NULL, (const void **)certs_c, 1L,
- &kCFTypeArrayCallBacks);
- err = SSLSetCertificate(connssl->ssl_ctx, certs);
- if(certs)
- CFRelease(certs);
- if(err != noErr) {
- failf(data, "SSL: SSLSetCertificate() failed: OSStatus %d", err);
- return CURLE_SSL_CERTPROBLEM;
- }
- CFRelease(cert_and_key);
- }
- else {
- switch(err) {
- case errSecAuthFailed: case -25264: /* errSecPkcs12VerifyFailure */
- failf(data, "SSL: Incorrect password for the certificate \"%s\" "
- "and its private key.", ssl_cert);
- break;
- case -26275: /* errSecDecode */ case -25257: /* errSecUnknownFormat */
- failf(data, "SSL: Couldn't make sense of the data in the "
- "certificate \"%s\" and its private key.",
- ssl_cert);
- break;
- case -25260: /* errSecPassphraseRequired */
- failf(data, "SSL The certificate \"%s\" requires a password.",
- ssl_cert);
- break;
- case errSecItemNotFound:
- failf(data, "SSL: Can't find the certificate \"%s\" and its private "
- "key in the Keychain.", ssl_cert);
- break;
- default:
- failf(data, "SSL: Can't load the certificate \"%s\" and its private "
- "key: OSStatus %d", ssl_cert, err);
- break;
- }
- return CURLE_SSL_CERTPROBLEM;
- }
- }
-
- /* SSL always tries to verify the peer, this only says whether it should
- * fail to connect if the verification fails, or if it should continue
- * anyway. In the latter case the result of the verification is checked with
- * SSL_get_verify_result() below. */
-#if CURL_BUILD_MAC_10_6 || CURL_BUILD_IOS
- /* Snow Leopard introduced the SSLSetSessionOption() function, but due to
- a library bug with the way the kSSLSessionOptionBreakOnServerAuth flag
- works, it doesn't work as expected under Snow Leopard, Lion or
- Mountain Lion.
- So we need to call SSLSetEnableCertVerify() on those older cats in order
- to disable certificate validation if the user turned that off.
- (SecureTransport will always validate the certificate chain by
- default.)
- Note:
- Darwin 11.x.x is Lion (10.7)
- Darwin 12.x.x is Mountain Lion (10.8)
- Darwin 13.x.x is Mavericks (10.9)
- Darwin 14.x.x is Yosemite (10.10)
- Darwin 15.x.x is El Capitan (10.11)
- */
-#if CURL_BUILD_MAC
- if(SSLSetSessionOption != NULL && darwinver_maj >= 13) {
-#else
- if(SSLSetSessionOption != NULL) {
-#endif /* CURL_BUILD_MAC */
- bool break_on_auth = !conn->ssl_config.verifypeer || ssl_cafile;
- err = SSLSetSessionOption(connssl->ssl_ctx,
- kSSLSessionOptionBreakOnServerAuth,
- break_on_auth);
- if(err != noErr) {
- failf(data, "SSL: SSLSetSessionOption() failed: OSStatus %d", err);
- return CURLE_SSL_CONNECT_ERROR;
- }
- }
- else {
-#if CURL_SUPPORT_MAC_10_8
- err = SSLSetEnableCertVerify(connssl->ssl_ctx,
- conn->ssl_config.verifypeer?true:false);
- if(err != noErr) {
- failf(data, "SSL: SSLSetEnableCertVerify() failed: OSStatus %d", err);
- return CURLE_SSL_CONNECT_ERROR;
- }
-#endif /* CURL_SUPPORT_MAC_10_8 */
- }
-#else
- err = SSLSetEnableCertVerify(connssl->ssl_ctx,
- conn->ssl_config.verifypeer?true:false);
- if(err != noErr) {
- failf(data, "SSL: SSLSetEnableCertVerify() failed: OSStatus %d", err);
- return CURLE_SSL_CONNECT_ERROR;
- }
-#endif /* CURL_BUILD_MAC_10_6 || CURL_BUILD_IOS */
-
- if(ssl_cafile && verifypeer) {
- bool is_cert_file = is_file(ssl_cafile);
-
- if(!is_cert_file) {
- failf(data, "SSL: can't load CA certificate file %s", ssl_cafile);
- return CURLE_SSL_CACERT_BADFILE;
- }
- }
-
- /* Configure hostname check. SNI is used if available.
- * Both hostname check and SNI require SSLSetPeerDomainName().
- * Also: the verifyhost setting influences SNI usage */
- if(conn->ssl_config.verifyhost) {
- err = SSLSetPeerDomainName(connssl->ssl_ctx, hostname,
- strlen(hostname));
-
- if(err != noErr) {
- infof(data, "WARNING: SSL: SSLSetPeerDomainName() failed: OSStatus %d\n",
- err);
- }
-
- if((Curl_inet_pton(AF_INET, hostname, &addr))
- #ifdef ENABLE_IPV6
- || (Curl_inet_pton(AF_INET6, hostname, &addr))
- #endif
- ) {
- infof(data, "WARNING: using IP address, SNI is being disabled by "
- "the OS.\n");
- }
- }
- else {
- infof(data, "WARNING: disabling hostname validation also disables SNI.\n");
- }
-
- /* Disable cipher suites that ST supports but are not safe. These ciphers
- are unlikely to be used in any case since ST gives other ciphers a much
- higher priority, but it's probably better that we not connect at all than
- to give the user a false sense of security if the server only supports
- insecure ciphers. (Note: We don't care about SSLv2-only ciphers.) */
- (void)SSLGetNumberSupportedCiphers(connssl->ssl_ctx, &all_ciphers_count);
- all_ciphers = malloc(all_ciphers_count*sizeof(SSLCipherSuite));
- allowed_ciphers = malloc(all_ciphers_count*sizeof(SSLCipherSuite));
- if(all_ciphers && allowed_ciphers &&
- SSLGetSupportedCiphers(connssl->ssl_ctx, all_ciphers,
- &all_ciphers_count) == noErr) {
- for(i = 0UL ; i < all_ciphers_count ; i++) {
-#if CURL_BUILD_MAC
- /* There's a known bug in early versions of Mountain Lion where ST's ECC
- ciphers (cipher suite 0xC001 through 0xC032) simply do not work.
- Work around the problem here by disabling those ciphers if we are
- running in an affected version of OS X. */
- if(darwinver_maj == 12 && darwinver_min <= 3 &&
- all_ciphers[i] >= 0xC001 && all_ciphers[i] <= 0xC032) {
- continue;
- }
-#endif /* CURL_BUILD_MAC */
- switch(all_ciphers[i]) {
- /* Disable NULL ciphersuites: */
- case SSL_NULL_WITH_NULL_NULL:
- case SSL_RSA_WITH_NULL_MD5:
- case SSL_RSA_WITH_NULL_SHA:
- case 0x003B: /* TLS_RSA_WITH_NULL_SHA256 */
- case SSL_FORTEZZA_DMS_WITH_NULL_SHA:
- case 0xC001: /* TLS_ECDH_ECDSA_WITH_NULL_SHA */
- case 0xC006: /* TLS_ECDHE_ECDSA_WITH_NULL_SHA */
- case 0xC00B: /* TLS_ECDH_RSA_WITH_NULL_SHA */
- case 0xC010: /* TLS_ECDHE_RSA_WITH_NULL_SHA */
- case 0x002C: /* TLS_PSK_WITH_NULL_SHA */
- case 0x002D: /* TLS_DHE_PSK_WITH_NULL_SHA */
- case 0x002E: /* TLS_RSA_PSK_WITH_NULL_SHA */
- case 0x00B0: /* TLS_PSK_WITH_NULL_SHA256 */
- case 0x00B1: /* TLS_PSK_WITH_NULL_SHA384 */
- case 0x00B4: /* TLS_DHE_PSK_WITH_NULL_SHA256 */
- case 0x00B5: /* TLS_DHE_PSK_WITH_NULL_SHA384 */
- case 0x00B8: /* TLS_RSA_PSK_WITH_NULL_SHA256 */
- case 0x00B9: /* TLS_RSA_PSK_WITH_NULL_SHA384 */
- /* Disable anonymous ciphersuites: */
- case SSL_DH_anon_EXPORT_WITH_RC4_40_MD5:
- case SSL_DH_anon_WITH_RC4_128_MD5:
- case SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA:
- case SSL_DH_anon_WITH_DES_CBC_SHA:
- case SSL_DH_anon_WITH_3DES_EDE_CBC_SHA:
- case TLS_DH_anon_WITH_AES_128_CBC_SHA:
- case TLS_DH_anon_WITH_AES_256_CBC_SHA:
- case 0xC015: /* TLS_ECDH_anon_WITH_NULL_SHA */
- case 0xC016: /* TLS_ECDH_anon_WITH_RC4_128_SHA */
- case 0xC017: /* TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA */
- case 0xC018: /* TLS_ECDH_anon_WITH_AES_128_CBC_SHA */
- case 0xC019: /* TLS_ECDH_anon_WITH_AES_256_CBC_SHA */
- case 0x006C: /* TLS_DH_anon_WITH_AES_128_CBC_SHA256 */
- case 0x006D: /* TLS_DH_anon_WITH_AES_256_CBC_SHA256 */
- case 0x00A6: /* TLS_DH_anon_WITH_AES_128_GCM_SHA256 */
- case 0x00A7: /* TLS_DH_anon_WITH_AES_256_GCM_SHA384 */
- /* Disable weak key ciphersuites: */
- case SSL_RSA_EXPORT_WITH_RC4_40_MD5:
- case SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5:
- case SSL_RSA_EXPORT_WITH_DES40_CBC_SHA:
- case SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA:
- case SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA:
- case SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA:
- case SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA:
- case SSL_RSA_WITH_DES_CBC_SHA:
- case SSL_DH_DSS_WITH_DES_CBC_SHA:
- case SSL_DH_RSA_WITH_DES_CBC_SHA:
- case SSL_DHE_DSS_WITH_DES_CBC_SHA:
- case SSL_DHE_RSA_WITH_DES_CBC_SHA:
- /* Disable IDEA: */
- case SSL_RSA_WITH_IDEA_CBC_SHA:
- case SSL_RSA_WITH_IDEA_CBC_MD5:
- /* Disable RC4: */
- case SSL_RSA_WITH_RC4_128_MD5:
- case SSL_RSA_WITH_RC4_128_SHA:
- case 0xC002: /* TLS_ECDH_ECDSA_WITH_RC4_128_SHA */
- case 0xC007: /* TLS_ECDHE_ECDSA_WITH_RC4_128_SHA*/
- case 0xC00C: /* TLS_ECDH_RSA_WITH_RC4_128_SHA */
- case 0xC011: /* TLS_ECDHE_RSA_WITH_RC4_128_SHA */
- case 0x008A: /* TLS_PSK_WITH_RC4_128_SHA */
- case 0x008E: /* TLS_DHE_PSK_WITH_RC4_128_SHA */
- case 0x0092: /* TLS_RSA_PSK_WITH_RC4_128_SHA */
- break;
- default: /* enable everything else */
- allowed_ciphers[allowed_ciphers_count++] = all_ciphers[i];
- break;
- }
- }
- err = SSLSetEnabledCiphers(connssl->ssl_ctx, allowed_ciphers,
- allowed_ciphers_count);
- if(err != noErr) {
- failf(data, "SSL: SSLSetEnabledCiphers() failed: OSStatus %d", err);
- return CURLE_SSL_CONNECT_ERROR;
- }
- }
- else {
- Curl_safefree(all_ciphers);
- Curl_safefree(allowed_ciphers);
- failf(data, "SSL: Failed to allocate memory for allowed ciphers");
- return CURLE_OUT_OF_MEMORY;
- }
- Curl_safefree(all_ciphers);
- Curl_safefree(allowed_ciphers);
-
-#if CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7
- /* We want to enable 1/n-1 when using a CBC cipher unless the user
- specifically doesn't want us doing that: */
- if(SSLSetSessionOption != NULL) {
- /* TODO s/data->set.ssl.enable_beast/SSL_SET_OPTION(enable_beast)/g */
- SSLSetSessionOption(connssl->ssl_ctx, kSSLSessionOptionSendOneByteRecord,
- !data->set.ssl.enable_beast);
- SSLSetSessionOption(connssl->ssl_ctx, kSSLSessionOptionFalseStart,
- data->set.ssl.falsestart); /* false start support */
- }
-#endif /* CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7 */
-
- /* Check if there's a cached ID we can/should use here! */
- if(SSL_SET_OPTION(primary.sessionid)) {
- char *ssl_sessionid;
- size_t ssl_sessionid_len;
-
- Curl_ssl_sessionid_lock(conn);
- if(!Curl_ssl_getsessionid(conn, (void **)&ssl_sessionid,
- &ssl_sessionid_len, sockindex)) {
- /* we got a session id, use it! */
- err = SSLSetPeerID(connssl->ssl_ctx, ssl_sessionid, ssl_sessionid_len);
- Curl_ssl_sessionid_unlock(conn);
- if(err != noErr) {
- failf(data, "SSL: SSLSetPeerID() failed: OSStatus %d", err);
- return CURLE_SSL_CONNECT_ERROR;
- }
- /* Informational message */
- infof(data, "SSL re-using session ID\n");
- }
- /* If there isn't one, then let's make one up! This has to be done prior
- to starting the handshake. */
- else {
- CURLcode result;
- ssl_sessionid =
- aprintf("%s:%d:%d:%s:%hu", ssl_cafile,
- verifypeer, SSL_CONN_CONFIG(verifyhost), hostname, port);
- ssl_sessionid_len = strlen(ssl_sessionid);
-
- err = SSLSetPeerID(connssl->ssl_ctx, ssl_sessionid, ssl_sessionid_len);
- if(err != noErr) {
- Curl_ssl_sessionid_unlock(conn);
- failf(data, "SSL: SSLSetPeerID() failed: OSStatus %d", err);
- return CURLE_SSL_CONNECT_ERROR;
- }
-
- result = Curl_ssl_addsessionid(conn, ssl_sessionid, ssl_sessionid_len,
- sockindex);
- Curl_ssl_sessionid_unlock(conn);
- if(result) {
- failf(data, "failed to store ssl session");
- return result;
- }
- }
- }
-
- err = SSLSetIOFuncs(connssl->ssl_ctx, SocketRead, SocketWrite);
- if(err != noErr) {
- failf(data, "SSL: SSLSetIOFuncs() failed: OSStatus %d", err);
- return CURLE_SSL_CONNECT_ERROR;
- }
-
- /* pass the raw socket into the SSL layers */
- /* We need to store the FD in a constant memory address, because
- * SSLSetConnection() will not copy that address. I've found that
- * conn->sock[sockindex] may change on its own. */
- connssl->ssl_sockfd = sockfd;
- err = SSLSetConnection(connssl->ssl_ctx, connssl);
- if(err != noErr) {
- failf(data, "SSL: SSLSetConnection() failed: %d", err);
- return CURLE_SSL_CONNECT_ERROR;
- }
-
- connssl->connecting_state = ssl_connect_2;
- return CURLE_OK;
-}
-
-static long pem_to_der(const char *in, unsigned char **out, size_t *outlen)
-{
- char *sep_start, *sep_end, *cert_start, *cert_end;
- size_t i, j, err;
- size_t len;
- unsigned char *b64;
-
- /* Jump through the separators at the beginning of the certificate. */
- sep_start = strstr(in, "-----");
- if(sep_start == NULL)
- return 0;
- cert_start = strstr(sep_start + 1, "-----");
- if(cert_start == NULL)
- return -1;
-
- cert_start += 5;
-
- /* Find separator after the end of the certificate. */
- cert_end = strstr(cert_start, "-----");
- if(cert_end == NULL)
- return -1;
-
- sep_end = strstr(cert_end + 1, "-----");
- if(sep_end == NULL)
- return -1;
- sep_end += 5;
-
- len = cert_end - cert_start;
- b64 = malloc(len + 1);
- if(!b64)
- return -1;
-
- /* Create base64 string without linefeeds. */
- for(i = 0, j = 0; i < len; i++) {
- if(cert_start[i] != '\r' && cert_start[i] != '\n')
- b64[j++] = cert_start[i];
- }
- b64[j] = '\0';
-
- err = Curl_base64_decode((const char *)b64, out, outlen);
- free(b64);
- if(err) {
- free(*out);
- return -1;
- }
-
- return sep_end - in;
-}
-
-static int read_cert(const char *file, unsigned char **out, size_t *outlen)
-{
- int fd;
- ssize_t n, len = 0, cap = 512;
- unsigned char buf[cap], *data;
-
- fd = open(file, 0);
- if(fd < 0)
- return -1;
-
- data = malloc(cap);
- if(!data) {
- close(fd);
- return -1;
- }
-
- for(;;) {
- n = read(fd, buf, sizeof(buf));
- if(n < 0) {
- close(fd);
- free(data);
- return -1;
- }
- else if(n == 0) {
- close(fd);
- break;
- }
-
- if(len + n >= cap) {
- cap *= 2;
- data = realloc(data, cap);
- if(!data) {
- close(fd);
- return -1;
- }
- }
-
- memcpy(data + len, buf, n);
- len += n;
- }
- data[len] = '\0';
-
- *out = data;
- *outlen = len;
-
- return 0;
-}
-
-static int sslerr_to_curlerr(struct Curl_easy *data, int err)
-{
- switch(err) {
- case errSSLXCertChainInvalid:
- failf(data, "SSL certificate problem: Invalid certificate chain");
- return CURLE_SSL_CACERT;
- case errSSLUnknownRootCert:
- failf(data, "SSL certificate problem: Untrusted root certificate");
- return CURLE_SSL_CACERT;
- case errSSLNoRootCert:
- failf(data, "SSL certificate problem: No root certificate");
- return CURLE_SSL_CACERT;
- case errSSLCertExpired:
- failf(data, "SSL certificate problem: Certificate chain had an "
- "expired certificate");
- return CURLE_SSL_CACERT;
- case errSSLBadCert:
- failf(data, "SSL certificate problem: Couldn't understand the server "
- "certificate format");
- return CURLE_SSL_CONNECT_ERROR;
- case errSSLHostNameMismatch:
- failf(data, "SSL certificate peer hostname mismatch");
- return CURLE_PEER_FAILED_VERIFICATION;
- default:
- failf(data, "SSL unexpected certificate error %d", err);
- return CURLE_SSL_CACERT;
- }
-}
-
-static int append_cert_to_array(struct Curl_easy *data,
- unsigned char *buf, size_t buflen,
- CFMutableArrayRef array)
-{
- CFDataRef certdata = CFDataCreate(kCFAllocatorDefault, buf, buflen);
- if(!certdata) {
- failf(data, "SSL: failed to allocate array for CA certificate");
- return CURLE_OUT_OF_MEMORY;
- }
-
- SecCertificateRef cacert =
- SecCertificateCreateWithData(kCFAllocatorDefault, certdata);
- CFRelease(certdata);
- if(!cacert) {
- failf(data, "SSL: failed to create SecCertificate from CA certificate");
- return CURLE_SSL_CACERT;
- }
-
- /* Check if cacert is valid. */
- CFStringRef subject = CopyCertSubject(cacert);
- if(subject) {
- char subject_cbuf[128];
- memset(subject_cbuf, 0, 128);
- if(!CFStringGetCString(subject,
- subject_cbuf,
- 128,
- kCFStringEncodingUTF8)) {
- CFRelease(cacert);
- failf(data, "SSL: invalid CA certificate subject");
- return CURLE_SSL_CACERT;
- }
- CFRelease(subject);
- }
- else {
- CFRelease(cacert);
- failf(data, "SSL: invalid CA certificate");
- return CURLE_SSL_CACERT;
- }
-
- CFArrayAppendValue(array, cacert);
- CFRelease(cacert);
-
- return CURLE_OK;
-}
-
-static int verify_cert(const char *cafile, struct Curl_easy *data,
- SSLContextRef ctx)
-{
- int n = 0, rc;
- long res;
- unsigned char *certbuf, *der;
- size_t buflen, derlen, offset = 0;
-
- if(read_cert(cafile, &certbuf, &buflen) < 0) {
- failf(data, "SSL: failed to read or invalid CA certificate");
- return CURLE_SSL_CACERT;
- }
-
- /*
- * Certbuf now contains the contents of the certificate file, which can be
- * - a single DER certificate,
- * - a single PEM certificate or
- * - a bunch of PEM certificates (certificate bundle).
- *
- * Go through certbuf, and convert any PEM certificate in it into DER
- * format.
- */
- CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0,
- &kCFTypeArrayCallBacks);
- if(array == NULL) {
- free(certbuf);
- failf(data, "SSL: out of memory creating CA certificate array");
- return CURLE_OUT_OF_MEMORY;
- }
-
- while(offset < buflen) {
- n++;
-
- /*
- * Check if the certificate is in PEM format, and convert it to DER. If
- * this fails, we assume the certificate is in DER format.
- */
- res = pem_to_der((const char *)certbuf + offset, &der, &derlen);
- if(res < 0) {
- free(certbuf);
- CFRelease(array);
- failf(data, "SSL: invalid CA certificate #%d (offset %d) in bundle",
- n, offset);
- return CURLE_SSL_CACERT;
- }
- offset += res;
-
- if(res == 0 && offset == 0) {
- /* This is not a PEM file, probably a certificate in DER format. */
- rc = append_cert_to_array(data, certbuf, buflen, array);
- free(certbuf);
- if(rc != CURLE_OK) {
- CFRelease(array);
- return rc;
- }
- break;
- }
- else if(res == 0) {
- /* No more certificates in the bundle. */
- free(certbuf);
- break;
- }
-
- rc = append_cert_to_array(data, der, derlen, array);
- free(der);
- if(rc != CURLE_OK) {
- free(certbuf);
- CFRelease(array);
- return rc;
- }
- }
-
- SecTrustRef trust;
- OSStatus ret = SSLCopyPeerTrust(ctx, &trust);
- if(trust == NULL) {
- failf(data, "SSL: error getting certificate chain");
- CFRelease(array);
- return CURLE_OUT_OF_MEMORY;
- }
- else if(ret != noErr) {
- CFRelease(array);
- return sslerr_to_curlerr(data, ret);
- }
-
- ret = SecTrustSetAnchorCertificates(trust, array);
- if(ret != noErr) {
- CFRelease(trust);
- return sslerr_to_curlerr(data, ret);
- }
- ret = SecTrustSetAnchorCertificatesOnly(trust, true);
- if(ret != noErr) {
- CFRelease(trust);
- return sslerr_to_curlerr(data, ret);
- }
-
- SecTrustResultType trust_eval = 0;
- ret = SecTrustEvaluate(trust, &trust_eval);
- CFRelease(array);
- CFRelease(trust);
- if(ret != noErr) {
- return sslerr_to_curlerr(data, ret);
- }
-
- switch(trust_eval) {
- case kSecTrustResultUnspecified:
- case kSecTrustResultProceed:
- return CURLE_OK;
-
- case kSecTrustResultRecoverableTrustFailure:
- case kSecTrustResultDeny:
- default:
- failf(data, "SSL: certificate verification failed (result: %d)",
- trust_eval);
- return CURLE_PEER_FAILED_VERIFICATION;
- }
-}
-
-#ifdef DARWIN_SSL_PINNEDPUBKEY
-static CURLcode pkp_pin_peer_pubkey(struct SessionHandle *data,
- SSLContextRef ctx,
- const char *pinnedpubkey)
-{ /* Scratch */
- size_t pubkeylen, realpubkeylen, spkiHeaderLength = 24;
- unsigned char *pubkey = NULL, *realpubkey = NULL, *spkiHeader = NULL;
- CFDataRef publicKeyBits = NULL;
-
- /* Result is returned to caller */
- CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH;
-
- /* if a path wasn't specified, don't pin */
- if(!pinnedpubkey)
- return CURLE_OK;
-
-
- if(!ctx)
- return result;
-
- do {
- SecTrustRef trust;
- OSStatus ret = SSLCopyPeerTrust(ctx, &trust);
- if(ret != noErr || trust == NULL)
- break;
-
- SecKeyRef keyRef = SecTrustCopyPublicKey(trust);
- CFRelease(trust);
- if(keyRef == NULL)
- break;
-
-#ifdef DARWIN_SSL_PINNEDPUBKEY_V1
-
- publicKeyBits = SecKeyCopyExternalRepresentation(keyRef, NULL);
- CFRelease(keyRef);
- if(publicKeyBits == NULL)
- break;
-
-#elif DARWIN_SSL_PINNEDPUBKEY_V2
-
- OSStatus success = SecItemExport(keyRef, kSecFormatOpenSSL, 0, NULL,
- &publicKeyBits);
- CFRelease(keyRef);
- if(success != errSecSuccess || publicKeyBits == NULL)
- break;
-
-#endif /* DARWIN_SSL_PINNEDPUBKEY_V2 */
-
- pubkeylen = CFDataGetLength(publicKeyBits);
- pubkey = CFDataGetBytePtr(publicKeyBits);
-
- switch(pubkeylen) {
- case 526:
- /* 4096 bit RSA pubkeylen == 526 */
- spkiHeader = rsa4096SpkiHeader;
- break;
- case 270:
- /* 2048 bit RSA pubkeylen == 270 */
- spkiHeader = rsa2048SpkiHeader;
- break;
-#ifdef DARWIN_SSL_PINNEDPUBKEY_V1
- case 65:
- /* ecDSA secp256r1 pubkeylen == 65 */
- spkiHeader = ecDsaSecp256r1SpkiHeader;
- spkiHeaderLength = 26;
- break;
- case 97:
- /* ecDSA secp384r1 pubkeylen == 97 */
- spkiHeader = ecDsaSecp384r1SpkiHeader;
- spkiHeaderLength = 23;
- break;
- default:
- infof(data, "SSL: unhandled public key length: %d\n", pubkeylen);
-#elif DARWIN_SSL_PINNEDPUBKEY_V2
- default:
- /* ecDSA secp256r1 pubkeylen == 91 header already included?
- * ecDSA secp384r1 header already included too
- * we assume rest of algorithms do same, so do nothing
- */
- result = Curl_pin_peer_pubkey(data, pinnedpubkey, pubkey,
- pubkeylen);
-#endif /* DARWIN_SSL_PINNEDPUBKEY_V2 */
- continue; /* break from loop */
- }
-
- realpubkeylen = pubkeylen + spkiHeaderLength;
- realpubkey = malloc(realpubkeylen);
- if(!realpubkey)
- break;
-
- memcpy(realpubkey, spkiHeader, spkiHeaderLength);
- memcpy(realpubkey + spkiHeaderLength, pubkey, pubkeylen);
-
- result = Curl_pin_peer_pubkey(data, pinnedpubkey, realpubkey,
- realpubkeylen);
-
- } while(0);
-
- Curl_safefree(realpubkey);
- if(publicKeyBits != NULL)
- CFRelease(publicKeyBits);
-
- return result;
-}
-#endif /* DARWIN_SSL_PINNEDPUBKEY */
-
-static CURLcode
-darwinssl_connect_step2(struct connectdata *conn, int sockindex)
-{
- struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- OSStatus err;
- SSLCipherSuite cipher;
- SSLProtocol protocol = 0;
- const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
- conn->host.name;
-
- DEBUGASSERT(ssl_connect_2 == connssl->connecting_state
- || ssl_connect_2_reading == connssl->connecting_state
- || ssl_connect_2_writing == connssl->connecting_state);
-
- /* Here goes nothing: */
- err = SSLHandshake(connssl->ssl_ctx);
-
- if(err != noErr) {
- switch(err) {
- case errSSLWouldBlock: /* they're not done with us yet */
- connssl->connecting_state = connssl->ssl_direction ?
- ssl_connect_2_writing : ssl_connect_2_reading;
- return CURLE_OK;
-
- /* The below is errSSLServerAuthCompleted; it's not defined in
- Leopard's headers */
- case -9841:
- if(SSL_CONN_CONFIG(CAfile) && SSL_CONN_CONFIG(verifypeer)) {
- int res = verify_cert(SSL_CONN_CONFIG(CAfile), data,
- connssl->ssl_ctx);
- if(res != CURLE_OK)
- return res;
- }
- /* the documentation says we need to call SSLHandshake() again */
- return darwinssl_connect_step2(conn, sockindex);
-
- /* These are all certificate problems with the server: */
- case errSSLXCertChainInvalid:
- failf(data, "SSL certificate problem: Invalid certificate chain");
- return CURLE_SSL_CACERT;
- case errSSLUnknownRootCert:
- failf(data, "SSL certificate problem: Untrusted root certificate");
- return CURLE_SSL_CACERT;
- case errSSLNoRootCert:
- failf(data, "SSL certificate problem: No root certificate");
- return CURLE_SSL_CACERT;
- case errSSLCertExpired:
- failf(data, "SSL certificate problem: Certificate chain had an "
- "expired certificate");
- return CURLE_SSL_CACERT;
- case errSSLBadCert:
- failf(data, "SSL certificate problem: Couldn't understand the server "
- "certificate format");
- return CURLE_SSL_CONNECT_ERROR;
-
- /* These are all certificate problems with the client: */
- case errSecAuthFailed:
- failf(data, "SSL authentication failed");
- return CURLE_SSL_CONNECT_ERROR;
- case errSSLPeerHandshakeFail:
- failf(data, "SSL peer handshake failed, the server most likely "
- "requires a client certificate to connect");
- return CURLE_SSL_CONNECT_ERROR;
- case errSSLPeerUnknownCA:
- failf(data, "SSL server rejected the client certificate due to "
- "the certificate being signed by an unknown certificate "
- "authority");
- return CURLE_SSL_CONNECT_ERROR;
-
- /* This error is raised if the server's cert didn't match the server's
- host name: */
- case errSSLHostNameMismatch:
- failf(data, "SSL certificate peer verification failed, the "
- "certificate did not match \"%s\"\n", conn->host.dispname);
- return CURLE_PEER_FAILED_VERIFICATION;
-
- /* Generic handshake errors: */
- case errSSLConnectionRefused:
- failf(data, "Server dropped the connection during the SSL handshake");
- return CURLE_SSL_CONNECT_ERROR;
- case errSSLClosedAbort:
- failf(data, "Server aborted the SSL handshake");
- return CURLE_SSL_CONNECT_ERROR;
- case errSSLNegotiation:
- failf(data, "Could not negotiate an SSL cipher suite with the server");
- return CURLE_SSL_CONNECT_ERROR;
- /* Sometimes paramErr happens with buggy ciphers: */
- case paramErr: case errSSLInternal:
- failf(data, "Internal SSL engine error encountered during the "
- "SSL handshake");
- return CURLE_SSL_CONNECT_ERROR;
- case errSSLFatalAlert:
- failf(data, "Fatal SSL engine error encountered during the SSL "
- "handshake");
- return CURLE_SSL_CONNECT_ERROR;
- default:
- failf(data, "Unknown SSL protocol error in connection to %s:%d",
- hostname, err);
- return CURLE_SSL_CONNECT_ERROR;
- }
- }
- else {
- /* we have been connected fine, we're not waiting for anything else. */
- connssl->connecting_state = ssl_connect_3;
-
-#ifdef DARWIN_SSL_PINNEDPUBKEY
- if(data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG]) {
- CURLcode result = pkp_pin_peer_pubkey(data, connssl->ssl_ctx,
- data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG]);
- if(result) {
- failf(data, "SSL: public key does not match pinned public key!");
- return result;
- }
- }
-#endif /* DARWIN_SSL_PINNEDPUBKEY */
-
- /* Informational message */
- (void)SSLGetNegotiatedCipher(connssl->ssl_ctx, &cipher);
- (void)SSLGetNegotiatedProtocolVersion(connssl->ssl_ctx, &protocol);
- switch(protocol) {
- case kSSLProtocol2:
- infof(data, "SSL 2.0 connection using %s\n",
- SSLCipherNameForNumber(cipher));
- break;
- case kSSLProtocol3:
- infof(data, "SSL 3.0 connection using %s\n",
- SSLCipherNameForNumber(cipher));
- break;
- case kTLSProtocol1:
- infof(data, "TLS 1.0 connection using %s\n",
- TLSCipherNameForNumber(cipher));
- break;
-#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
- case kTLSProtocol11:
- infof(data, "TLS 1.1 connection using %s\n",
- TLSCipherNameForNumber(cipher));
- break;
- case kTLSProtocol12:
- infof(data, "TLS 1.2 connection using %s\n",
- TLSCipherNameForNumber(cipher));
- break;
-#endif
- default:
- infof(data, "Unknown protocol connection\n");
- break;
- }
-
- return CURLE_OK;
- }
-}
-
-#ifndef CURL_DISABLE_VERBOSE_STRINGS
-/* This should be called during step3 of the connection at the earliest */
-static void
-show_verbose_server_cert(struct connectdata *conn,
- int sockindex)
-{
- struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- CFStringRef server_cert_summary;
- char server_cert_summary_c[128];
- CFArrayRef server_certs = NULL;
- SecCertificateRef server_cert;
- OSStatus err;
- CFIndex i, count;
- SecTrustRef trust = NULL;
-
- if(!connssl->ssl_ctx)
- return;
-
-#if CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS
-#if CURL_BUILD_IOS
-#pragma unused(server_certs)
- err = SSLCopyPeerTrust(connssl->ssl_ctx, &trust);
- /* For some reason, SSLCopyPeerTrust() can return noErr and yet return
- a null trust, so be on guard for that: */
- if(err == noErr && trust) {
- count = SecTrustGetCertificateCount(trust);
- for(i = 0L ; i < count ; i++) {
- server_cert = SecTrustGetCertificateAtIndex(trust, i);
- server_cert_summary = CopyCertSubject(server_cert);
- memset(server_cert_summary_c, 0, 128);
- if(CFStringGetCString(server_cert_summary,
- server_cert_summary_c,
- 128,
- kCFStringEncodingUTF8)) {
- infof(data, "Server certificate: %s\n", server_cert_summary_c);
- }
- CFRelease(server_cert_summary);
- }
- CFRelease(trust);
- }
-#else
- /* SSLCopyPeerCertificates() is deprecated as of Mountain Lion.
- The function SecTrustGetCertificateAtIndex() is officially present
- in Lion, but it is unfortunately also present in Snow Leopard as
- private API and doesn't work as expected. So we have to look for
- a different symbol to make sure this code is only executed under
- Lion or later. */
- if(SecTrustEvaluateAsync != NULL) {
-#pragma unused(server_certs)
- err = SSLCopyPeerTrust(connssl->ssl_ctx, &trust);
- /* For some reason, SSLCopyPeerTrust() can return noErr and yet return
- a null trust, so be on guard for that: */
- if(err == noErr && trust) {
- count = SecTrustGetCertificateCount(trust);
- for(i = 0L ; i < count ; i++) {
- server_cert = SecTrustGetCertificateAtIndex(trust, i);
- server_cert_summary = CopyCertSubject(server_cert);
- memset(server_cert_summary_c, 0, 128);
- if(CFStringGetCString(server_cert_summary,
- server_cert_summary_c,
- 128,
- kCFStringEncodingUTF8)) {
- infof(data, "Server certificate: %s\n", server_cert_summary_c);
- }
- CFRelease(server_cert_summary);
- }
- CFRelease(trust);
- }
- }
- else {
-#if CURL_SUPPORT_MAC_10_8
- err = SSLCopyPeerCertificates(connssl->ssl_ctx, &server_certs);
- /* Just in case SSLCopyPeerCertificates() returns null too... */
- if(err == noErr && server_certs) {
- count = CFArrayGetCount(server_certs);
- for(i = 0L ; i < count ; i++) {
- server_cert = (SecCertificateRef)CFArrayGetValueAtIndex(server_certs,
- i);
-
- server_cert_summary = CopyCertSubject(server_cert);
- memset(server_cert_summary_c, 0, 128);
- if(CFStringGetCString(server_cert_summary,
- server_cert_summary_c,
- 128,
- kCFStringEncodingUTF8)) {
- infof(data, "Server certificate: %s\n", server_cert_summary_c);
- }
- CFRelease(server_cert_summary);
- }
- CFRelease(server_certs);
- }
-#endif /* CURL_SUPPORT_MAC_10_8 */
- }
-#endif /* CURL_BUILD_IOS */
-#else
-#pragma unused(trust)
- err = SSLCopyPeerCertificates(connssl->ssl_ctx, &server_certs);
- if(err == noErr) {
- count = CFArrayGetCount(server_certs);
- for(i = 0L ; i < count ; i++) {
- server_cert = (SecCertificateRef)CFArrayGetValueAtIndex(server_certs, i);
- server_cert_summary = CopyCertSubject(server_cert);
- memset(server_cert_summary_c, 0, 128);
- if(CFStringGetCString(server_cert_summary,
- server_cert_summary_c,
- 128,
- kCFStringEncodingUTF8)) {
- infof(data, "Server certificate: %s\n", server_cert_summary_c);
- }
- CFRelease(server_cert_summary);
- }
- CFRelease(server_certs);
- }
-#endif /* CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS */
-}
-#endif /* !CURL_DISABLE_VERBOSE_STRINGS */
-
-static CURLcode
-darwinssl_connect_step3(struct connectdata *conn,
- int sockindex)
-{
- struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
-
- /* There is no step 3!
- * Well, okay, if verbose mode is on, let's print the details of the
- * server certificates. */
-#ifndef CURL_DISABLE_VERBOSE_STRINGS
- if(data->set.verbose)
- show_verbose_server_cert(conn, sockindex);
-#endif
-
- connssl->connecting_state = ssl_connect_done;
- return CURLE_OK;
-}
-
-static Curl_recv darwinssl_recv;
-static Curl_send darwinssl_send;
-
-static CURLcode
-darwinssl_connect_common(struct connectdata *conn,
- int sockindex,
- bool nonblocking,
- bool *done)
-{
- CURLcode result;
- struct Curl_easy *data = conn->data;
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- curl_socket_t sockfd = conn->sock[sockindex];
- long timeout_ms;
- int what;
-
- /* check if the connection has already been established */
- if(ssl_connection_complete == connssl->state) {
- *done = TRUE;
- return CURLE_OK;
- }
-
- if(ssl_connect_1==connssl->connecting_state) {
- /* Find out how much more time we're allowed */
- timeout_ms = Curl_timeleft(data, NULL, TRUE);
-
- if(timeout_ms < 0) {
- /* no need to continue if time already is up */
- failf(data, "SSL connection timeout");
- return CURLE_OPERATION_TIMEDOUT;
- }
-
- result = darwinssl_connect_step1(conn, sockindex);
- if(result)
- return result;
- }
-
- while(ssl_connect_2 == connssl->connecting_state ||
- ssl_connect_2_reading == connssl->connecting_state ||
- ssl_connect_2_writing == connssl->connecting_state) {
-
- /* check allowed time left */
- timeout_ms = Curl_timeleft(data, NULL, TRUE);
-
- if(timeout_ms < 0) {
- /* no need to continue if time already is up */
- failf(data, "SSL connection timeout");
- return CURLE_OPERATION_TIMEDOUT;
- }
-
- /* if ssl is expecting something, check if it's available. */
- if(connssl->connecting_state == ssl_connect_2_reading ||
- connssl->connecting_state == ssl_connect_2_writing) {
-
- curl_socket_t writefd = ssl_connect_2_writing ==
- connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
- curl_socket_t readfd = ssl_connect_2_reading ==
- connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
-
- what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
- nonblocking?0:timeout_ms);
- if(what < 0) {
- /* fatal error */
- failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
- return CURLE_SSL_CONNECT_ERROR;
- }
- else if(0 == what) {
- if(nonblocking) {
- *done = FALSE;
- return CURLE_OK;
- }
- else {
- /* timeout */
- failf(data, "SSL connection timeout");
- return CURLE_OPERATION_TIMEDOUT;
- }
- }
- /* socket is readable or writable */
- }
-
- /* Run transaction, and return to the caller if it failed or if this
- * connection is done nonblocking and this loop would execute again. This
- * permits the owner of a multi handle to abort a connection attempt
- * before step2 has completed while ensuring that a client using select()
- * or epoll() will always have a valid fdset to wait on.
- */
- result = darwinssl_connect_step2(conn, sockindex);
- if(result || (nonblocking &&
- (ssl_connect_2 == connssl->connecting_state ||
- ssl_connect_2_reading == connssl->connecting_state ||
- ssl_connect_2_writing == connssl->connecting_state)))
- return result;
-
- } /* repeat step2 until all transactions are done. */
-
-
- if(ssl_connect_3 == connssl->connecting_state) {
- result = darwinssl_connect_step3(conn, sockindex);
- if(result)
- return result;
- }
-
- if(ssl_connect_done == connssl->connecting_state) {
- connssl->state = ssl_connection_complete;
- conn->recv[sockindex] = darwinssl_recv;
- conn->send[sockindex] = darwinssl_send;
- *done = TRUE;
- }
- else
- *done = FALSE;
-
- /* Reset our connect state machine */
- connssl->connecting_state = ssl_connect_1;
-
- return CURLE_OK;
-}
-
-CURLcode
-Curl_darwinssl_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done)
-{
- return darwinssl_connect_common(conn, sockindex, TRUE, done);
-}
-
-CURLcode
-Curl_darwinssl_connect(struct connectdata *conn,
- int sockindex)
-{
- CURLcode result;
- bool done = FALSE;
-
- result = darwinssl_connect_common(conn, sockindex, FALSE, &done);
-
- if(result)
- return result;
-
- DEBUGASSERT(done);
-
- return CURLE_OK;
-}
-
-void Curl_darwinssl_close(struct connectdata *conn, int sockindex)
-{
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
-
- if(connssl->ssl_ctx) {
- (void)SSLClose(connssl->ssl_ctx);
-#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
- if(SSLCreateContext != NULL)
- CFRelease(connssl->ssl_ctx);
-#if CURL_SUPPORT_MAC_10_8
- else
- (void)SSLDisposeContext(connssl->ssl_ctx);
-#endif /* CURL_SUPPORT_MAC_10_8 */
-#else
- (void)SSLDisposeContext(connssl->ssl_ctx);
-#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
- connssl->ssl_ctx = NULL;
- }
- connssl->ssl_sockfd = 0;
-}
-
-int Curl_darwinssl_shutdown(struct connectdata *conn, int sockindex)
-{
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- struct Curl_easy *data = conn->data;
- ssize_t nread;
- int what;
- int rc;
- char buf[120];
-
- if(!connssl->ssl_ctx)
- return 0;
-
- if(data->set.ftp_ccc != CURLFTPSSL_CCC_ACTIVE)
- return 0;
-
- Curl_darwinssl_close(conn, sockindex);
-
- rc = 0;
-
- what = SOCKET_READABLE(conn->sock[sockindex], SSL_SHUTDOWN_TIMEOUT);
-
- for(;;) {
- if(what < 0) {
- /* anything that gets here is fatally bad */
- failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
- rc = -1;
- break;
- }
-
- if(!what) { /* timeout */
- failf(data, "SSL shutdown timeout");
- break;
- }
-
- /* Something to read, let's do it and hope that it is the close
- notify alert from the server. No way to SSL_Read now, so use read(). */
-
- nread = read(conn->sock[sockindex], buf, sizeof(buf));
-
- if(nread < 0) {
- failf(data, "read: %s", strerror(errno));
- rc = -1;
- }
-
- if(nread <= 0)
- break;
-
- what = SOCKET_READABLE(conn->sock[sockindex], 0);
- }
-
- return rc;
-}
-
-void Curl_darwinssl_session_free(void *ptr)
-{
- /* ST, as of iOS 5 and Mountain Lion, has no public method of deleting a
- cached session ID inside the Security framework. There is a private
- function that does this, but I don't want to have to explain to you why I
- got your application rejected from the App Store due to the use of a
- private API, so the best we can do is free up our own char array that we
- created way back in darwinssl_connect_step1... */
- Curl_safefree(ptr);
-}
-
-size_t Curl_darwinssl_version(char *buffer, size_t size)
-{
- return snprintf(buffer, size, "SecureTransport");
-}
-
-/*
- * This function uses SSLGetSessionState to determine connection status.
- *
- * Return codes:
- * 1 means the connection is still in place
- * 0 means the connection has been closed
- * -1 means the connection status is unknown
- */
-int Curl_darwinssl_check_cxn(struct connectdata *conn)
-{
- struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
- OSStatus err;
- SSLSessionState state;
-
- if(connssl->ssl_ctx) {
- err = SSLGetSessionState(connssl->ssl_ctx, &state);
- if(err == noErr)
- return state == kSSLConnected || state == kSSLHandshake;
- return -1;
- }
- return 0;
-}
-
-bool Curl_darwinssl_data_pending(const struct connectdata *conn,
- int connindex)
-{
- const struct ssl_connect_data *connssl = &conn->ssl[connindex];
- OSStatus err;
- size_t buffer;
-
- if(connssl->ssl_ctx) { /* SSL is in use */
- err = SSLGetBufferedReadSize(connssl->ssl_ctx, &buffer);
- if(err == noErr)
- return buffer > 0UL;
- return false;
- }
- else
- return false;
-}
-
-CURLcode Curl_darwinssl_random(unsigned char *entropy,
- size_t length)
-{
- /* arc4random_buf() isn't available on cats older than Lion, so let's
- do this manually for the benefit of the older cats. */
- size_t i;
- u_int32_t random_number = 0;
-
- for(i = 0 ; i < length ; i++) {
- if(i % sizeof(u_int32_t) == 0)
- random_number = arc4random();
- entropy[i] = random_number & 0xFF;
- random_number >>= 8;
- }
- i = random_number = 0;
- return CURLE_OK;
-}
-
-void Curl_darwinssl_md5sum(unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *md5sum, /* output */
- size_t md5len)
-{
- (void)md5len;
- (void)CC_MD5(tmp, (CC_LONG)tmplen, md5sum);
-}
-
-void Curl_darwinssl_sha256sum(unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *sha256sum, /* output */
- size_t sha256len)
-{
- assert(sha256len >= SHA256_DIGEST_LENGTH);
- (void)CC_SHA256(tmp, (CC_LONG)tmplen, sha256sum);
-}
-
-bool Curl_darwinssl_false_start(void)
-{
-#if CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7
- if(SSLSetSessionOption != NULL)
- return TRUE;
-#endif
- return FALSE;
-}
-
-static ssize_t darwinssl_send(struct connectdata *conn,
- int sockindex,
- const void *mem,
- size_t len,
- CURLcode *curlcode)
-{
- /*struct Curl_easy *data = conn->data;*/
- struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- size_t processed = 0UL;
- OSStatus err;
-
- /* The SSLWrite() function works a little differently than expected. The
- fourth argument (processed) is currently documented in Apple's
- documentation as: "On return, the length, in bytes, of the data actually
- written."
-
- Now, one could interpret that as "written to the socket," but actually,
- it returns the amount of data that was written to a buffer internal to
- the SSLContextRef instead. So it's possible for SSLWrite() to return
- errSSLWouldBlock and a number of bytes "written" because those bytes were
- encrypted and written to a buffer, not to the socket.
-
- So if this happens, then we need to keep calling SSLWrite() over and
- over again with no new data until it quits returning errSSLWouldBlock. */
-
- /* Do we have buffered data to write from the last time we were called? */
- if(connssl->ssl_write_buffered_length) {
- /* Write the buffered data: */
- err = SSLWrite(connssl->ssl_ctx, NULL, 0UL, &processed);
- switch(err) {
- case noErr:
- /* processed is always going to be 0 because we didn't write to
- the buffer, so return how much was written to the socket */
- processed = connssl->ssl_write_buffered_length;
- connssl->ssl_write_buffered_length = 0UL;
- break;
- case errSSLWouldBlock: /* argh, try again */
- *curlcode = CURLE_AGAIN;
- return -1L;
- default:
- failf(conn->data, "SSLWrite() returned error %d", err);
- *curlcode = CURLE_SEND_ERROR;
- return -1L;
- }
- }
- else {
- /* We've got new data to write: */
- err = SSLWrite(connssl->ssl_ctx, mem, len, &processed);
- if(err != noErr) {
- switch(err) {
- case errSSLWouldBlock:
- /* Data was buffered but not sent, we have to tell the caller
- to try sending again, and remember how much was buffered */
- connssl->ssl_write_buffered_length = len;
- *curlcode = CURLE_AGAIN;
- return -1L;
- default:
- failf(conn->data, "SSLWrite() returned error %d", err);
- *curlcode = CURLE_SEND_ERROR;
- return -1L;
- }
- }
- }
- return (ssize_t)processed;
-}
-
-static ssize_t darwinssl_recv(struct connectdata *conn,
- int num,
- char *buf,
- size_t buffersize,
- CURLcode *curlcode)
-{
- /*struct Curl_easy *data = conn->data;*/
- struct ssl_connect_data *connssl = &conn->ssl[num];
- size_t processed = 0UL;
- OSStatus err = SSLRead(connssl->ssl_ctx, buf, buffersize, &processed);
-
- if(err != noErr) {
- switch(err) {
- case errSSLWouldBlock: /* return how much we read (if anything) */
- if(processed)
- return (ssize_t)processed;
- *curlcode = CURLE_AGAIN;
- return -1L;
- break;
-
- /* errSSLClosedGraceful - server gracefully shut down the SSL session
- errSSLClosedNoNotify - server hung up on us instead of sending a
- closure alert notice, read() is returning 0
- Either way, inform the caller that the server disconnected. */
- case errSSLClosedGraceful:
- case errSSLClosedNoNotify:
- *curlcode = CURLE_OK;
- return -1L;
- break;
-
- default:
- failf(conn->data, "SSLRead() return error %d", err);
- *curlcode = CURLE_RECV_ERROR;
- return -1L;
- break;
- }
- }
- return (ssize_t)processed;
-}
-
-#endif /* USE_DARWINSSL */
diff --git a/Utilities/cmcurl/lib/vtls/darwinssl.h b/Utilities/cmcurl/lib/vtls/darwinssl.h
deleted file mode 100644
index fd372ffa0..000000000
--- a/Utilities/cmcurl/lib/vtls/darwinssl.h
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifndef HEADER_CURL_DARWINSSL_H
-#define HEADER_CURL_DARWINSSL_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2012 - 2014, Nick Zitzmann, <nickzman@gmail.com>.
- * Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.haxx.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ***************************************************************************/
-#include "curl_setup.h"
-
-#ifdef USE_DARWINSSL
-
-CURLcode Curl_darwinssl_connect(struct connectdata *conn, int sockindex);
-
-CURLcode Curl_darwinssl_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done);
-
-/* close a SSL connection */
-void Curl_darwinssl_close(struct connectdata *conn, int sockindex);
-
-void Curl_darwinssl_session_free(void *ptr);
-size_t Curl_darwinssl_version(char *buffer, size_t size);
-int Curl_darwinssl_shutdown(struct connectdata *conn, int sockindex);
-int Curl_darwinssl_check_cxn(struct connectdata *conn);
-bool Curl_darwinssl_data_pending(const struct connectdata *conn,
- int connindex);
-
-CURLcode Curl_darwinssl_random(unsigned char *entropy,
- size_t length);
-void Curl_darwinssl_md5sum(unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *md5sum, /* output */
- size_t md5len);
-void Curl_darwinssl_sha256sum(unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *sha256sum, /* output */
- size_t sha256len);
-bool Curl_darwinssl_false_start(void);
-
-/* Set the API backend definition to SecureTransport */
-#define CURL_SSL_BACKEND CURLSSLBACKEND_DARWINSSL
-
-/* pinned public key support tests */
-
-/* version 1 supports macOS 10.12+ and iOS 10+ */
-#if ((TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) || \
- (!TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200))
-#define DARWIN_SSL_PINNEDPUBKEY_V1 1
-#endif
-
-/* version 2 supports MacOSX 10.7+ */
-#if (!TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)
-#define DARWIN_SSL_PINNEDPUBKEY_V2 1
-#endif
-
-#if defined(DARWIN_SSL_PINNEDPUBKEY_V1) || defined(DARWIN_SSL_PINNEDPUBKEY_V2)
-/* this backend supports CURLOPT_PINNEDPUBLICKEY */
-#define DARWIN_SSL_PINNEDPUBKEY 1
-#define have_curlssl_pinnedpubkey 1
-#endif /* DARWIN_SSL_PINNEDPUBKEY */
-
-/* API setup for SecureTransport */
-#define curlssl_init() (1)
-#define curlssl_cleanup() Curl_nop_stmt
-#define curlssl_connect Curl_darwinssl_connect
-#define curlssl_connect_nonblocking Curl_darwinssl_connect_nonblocking
-#define curlssl_session_free(x) Curl_darwinssl_session_free(x)
-#define curlssl_close_all(x) ((void)x)
-#define curlssl_close Curl_darwinssl_close
-#define curlssl_shutdown(x,y) 0
-#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN)
-#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN)
-#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL)
-#define curlssl_version Curl_darwinssl_version
-#define curlssl_check_cxn Curl_darwinssl_check_cxn
-#define curlssl_data_pending(x,y) Curl_darwinssl_data_pending(x, y)
-#define curlssl_random(x,y,z) ((void)x, Curl_darwinssl_random(y,z))
-#define curlssl_md5sum(a,b,c,d) Curl_darwinssl_md5sum(a,b,c,d)
-#define curlssl_sha256sum(a,b,c,d) Curl_darwinssl_sha256sum(a,b,c,d)
-#define curlssl_false_start() Curl_darwinssl_false_start()
-
-#endif /* USE_DARWINSSL */
-#endif /* HEADER_CURL_DARWINSSL_H */
diff --git a/Utilities/cmcurl/lib/vtls/gskit.c b/Utilities/cmcurl/lib/vtls/gskit.c
index bf75bddc2..b93ff5d4f 100644
--- a/Utilities/cmcurl/lib/vtls/gskit.c
+++ b/Utilities/cmcurl/lib/vtls/gskit.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -61,9 +61,7 @@
#endif
-#ifdef HAVE_LIMITS_H
-# include <limits.h>
-#endif
+#include <limits.h>
#include <curl/curl.h>
#include "urldata.h"
@@ -98,6 +96,14 @@
#define CURL_GSKPROTO_TLSV12_MASK (1 << CURL_GSKPROTO_TLSV12)
#define CURL_GSKPROTO_LAST 5
+struct ssl_backend_data {
+ gsk_handle handle;
+ int iocport;
+ int localfd;
+ int remotefd;
+};
+
+#define BACKEND connssl->backend
/* Supported ciphers. */
typedef struct {
@@ -322,7 +328,7 @@ static CURLcode set_ciphers(struct connectdata *conn,
GSKit tokens are always shorter than their cipher names, allocated buffers
will always be large enough to accommodate the result. */
l = strlen(cipherlist) + 1;
- memset((char *) ciphers, 0, sizeof ciphers);
+ memset((char *) ciphers, 0, sizeof(ciphers));
for(i = 0; i < CURL_GSKPROTO_LAST; i++) {
ciphers[i].buf = malloc(l);
if(!ciphers[i].buf) {
@@ -427,7 +433,7 @@ static CURLcode set_ciphers(struct connectdata *conn,
}
-int Curl_gskit_init(void)
+static int Curl_gskit_init(void)
{
/* No initialisation needed. */
@@ -435,7 +441,7 @@ int Curl_gskit_init(void)
}
-void Curl_gskit_cleanup(void)
+static void Curl_gskit_cleanup(void)
{
/* Nothing to do. */
}
@@ -495,14 +501,14 @@ static void cancel_async_handshake(struct connectdata *conn, int sockindex)
Qso_OverlappedIO_t cstat;
if(QsoCancelOperation(conn->sock[sockindex], 0) > 0)
- QsoWaitForIOCompletion(connssl->iocport, &cstat, (struct timeval *) NULL);
+ QsoWaitForIOCompletion(BACKEND->iocport, &cstat, (struct timeval *) NULL);
}
static void close_async_handshake(struct ssl_connect_data *connssl)
{
- QsoDestroyIOCompletionPort(connssl->iocport);
- connssl->iocport = -1;
+ QsoDestroyIOCompletionPort(BACKEND->iocport);
+ BACKEND->iocport = -1;
}
/* SSL over SSL
@@ -530,18 +536,18 @@ inetsocketpair(int sv[2])
lfd = socket(AF_INET, SOCK_STREAM, 0);
if(lfd < 0)
return -1;
- memset((char *) &addr1, 0, sizeof addr1);
+ memset((char *) &addr1, 0, sizeof(addr1));
addr1.sin_family = AF_INET;
addr1.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
addr1.sin_port = 0;
- if(bind(lfd, (struct sockaddr *) &addr1, sizeof addr1) ||
+ if(bind(lfd, (struct sockaddr *) &addr1, sizeof(addr1)) ||
listen(lfd, 2) < 0) {
close(lfd);
return -1;
}
/* Get the allocated port. */
- len = sizeof addr1;
+ len = sizeof(addr1);
if(getsockname(lfd, (struct sockaddr *) &addr1, &len) < 0) {
close(lfd);
return -1;
@@ -556,7 +562,7 @@ inetsocketpair(int sv[2])
/* Request unblocking connection to the listening socket. */
curlx_nonblock(cfd, TRUE);
- if(connect(cfd, (struct sockaddr *) &addr1, sizeof addr1) < 0 &&
+ if(connect(cfd, (struct sockaddr *) &addr1, sizeof(addr1)) < 0 &&
errno != EINPROGRESS) {
close(lfd);
close(cfd);
@@ -564,7 +570,7 @@ inetsocketpair(int sv[2])
}
/* Get the client dynamic port for intrusion check below. */
- len = sizeof addr2;
+ len = sizeof(addr2);
if(getsockname(cfd, (struct sockaddr *) &addr2, &len) < 0) {
close(lfd);
close(cfd);
@@ -574,7 +580,7 @@ inetsocketpair(int sv[2])
/* Accept the incoming connection and get the server socket. */
curlx_nonblock(lfd, TRUE);
for(;;) {
- len = sizeof addr1;
+ len = sizeof(addr1);
sfd = accept(lfd, (struct sockaddr *) &addr1, &len);
if(sfd < 0) {
close(lfd);
@@ -620,12 +626,12 @@ static int pipe_ssloverssl(struct connectdata *conn, int sockindex,
FD_ZERO(&fds_write);
n = -1;
if(directions & SOS_READ) {
- FD_SET(connssl->remotefd, &fds_write);
- n = connssl->remotefd;
+ FD_SET(BACKEND->remotefd, &fds_write);
+ n = BACKEND->remotefd;
}
if(directions & SOS_WRITE) {
- FD_SET(connssl->remotefd, &fds_read);
- n = connssl->remotefd;
+ FD_SET(BACKEND->remotefd, &fds_read);
+ n = BACKEND->remotefd;
FD_SET(conn->sock[sockindex], &fds_write);
if(n < conn->sock[sockindex])
n = conn->sock[sockindex];
@@ -634,14 +640,15 @@ static int pipe_ssloverssl(struct connectdata *conn, int sockindex,
if(i < 0)
return -1; /* Select error. */
- if(FD_ISSET(connssl->remotefd, &fds_write)) {
+ if(FD_ISSET(BACKEND->remotefd, &fds_write)) {
/* Try getting data from HTTPS proxy and pipe it upstream. */
n = 0;
- i = gsk_secure_soc_read(connproxyssl->handle, buf, sizeof buf, &n);
+ i = gsk_secure_soc_read(connproxyssl->backend->handle,
+ buf, sizeof(buf), &n);
switch(i) {
case GSK_OK:
if(n) {
- i = write(connssl->remotefd, buf, n);
+ i = write(BACKEND->remotefd, buf, n);
if(i < 0)
return -1;
ret = 1;
@@ -655,14 +662,14 @@ static int pipe_ssloverssl(struct connectdata *conn, int sockindex,
}
}
- if(FD_ISSET(connssl->remotefd, &fds_read) &&
+ if(FD_ISSET(BACKEND->remotefd, &fds_read) &&
FD_ISSET(conn->sock[sockindex], &fds_write)) {
/* Pipe data to HTTPS proxy. */
- n = read(connssl->remotefd, buf, sizeof buf);
+ n = read(BACKEND->remotefd, buf, sizeof(buf));
if(n < 0)
return -1;
if(n) {
- i = gsk_secure_soc_write(connproxyssl->handle, buf, n, &m);
+ i = gsk_secure_soc_write(connproxyssl->backend->handle, buf, n, &m);
if(i != GSK_OK || n != m)
return -1;
ret = 1;
@@ -676,23 +683,23 @@ static int pipe_ssloverssl(struct connectdata *conn, int sockindex,
static void close_one(struct ssl_connect_data *connssl,
struct connectdata *conn, int sockindex)
{
- if(connssl->handle) {
- gskit_status(conn->data, gsk_secure_soc_close(&connssl->handle),
+ if(BACKEND->handle) {
+ gskit_status(conn->data, gsk_secure_soc_close(&BACKEND->handle),
"gsk_secure_soc_close()", 0);
/* Last chance to drain output. */
while(pipe_ssloverssl(conn, sockindex, SOS_WRITE) > 0)
;
- connssl->handle = (gsk_handle) NULL;
- if(connssl->localfd >= 0) {
- close(connssl->localfd);
- connssl->localfd = -1;
+ BACKEND->handle = (gsk_handle) NULL;
+ if(BACKEND->localfd >= 0) {
+ close(BACKEND->localfd);
+ BACKEND->localfd = -1;
}
- if(connssl->remotefd >= 0) {
- close(connssl->remotefd);
- connssl->remotefd = -1;
+ if(BACKEND->remotefd >= 0) {
+ close(BACKEND->remotefd);
+ BACKEND->remotefd = -1;
}
}
- if(connssl->iocport >= 0)
+ if(BACKEND->iocport >= 0)
close_async_handshake(connssl);
}
@@ -700,13 +707,14 @@ static void close_one(struct ssl_connect_data *connssl,
static ssize_t gskit_send(struct connectdata *conn, int sockindex,
const void *mem, size_t len, CURLcode *curlcode)
{
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
struct Curl_easy *data = conn->data;
CURLcode cc = CURLE_SEND_ERROR;
int written;
if(pipe_ssloverssl(conn, sockindex, SOS_WRITE) >= 0) {
cc = gskit_status(data,
- gsk_secure_soc_write(conn->ssl[sockindex].handle,
+ gsk_secure_soc_write(BACKEND->handle,
(char *) mem, (int) len, &written),
"gsk_secure_soc_write()", CURLE_SEND_ERROR);
if(cc == CURLE_OK)
@@ -724,14 +732,14 @@ static ssize_t gskit_send(struct connectdata *conn, int sockindex,
static ssize_t gskit_recv(struct connectdata *conn, int num, char *buf,
size_t buffersize, CURLcode *curlcode)
{
+ struct ssl_connect_data *connssl = &conn->ssl[num];
struct Curl_easy *data = conn->data;
- int buffsize;
int nread;
CURLcode cc = CURLE_RECV_ERROR;
if(pipe_ssloverssl(conn, num, SOS_READ) >= 0) {
- buffsize = buffersize > (size_t) INT_MAX? INT_MAX: (int) buffersize;
- cc = gskit_status(data, gsk_secure_soc_read(conn->ssl[num].handle,
+ int buffsize = buffersize > (size_t) INT_MAX? INT_MAX: (int) buffersize;
+ cc = gskit_status(data, gsk_secure_soc_read(BACKEND->handle,
buf, buffsize, &nread),
"gsk_secure_soc_read()", CURLE_RECV_ERROR);
}
@@ -757,8 +765,6 @@ set_ssl_version_min_max(unsigned int *protoflags, struct connectdata *conn)
long i = ssl_version;
switch(ssl_version_max) {
case CURL_SSLVERSION_MAX_NONE:
- ssl_version_max = ssl_version;
- break;
case CURL_SSLVERSION_MAX_DEFAULT:
ssl_version_max = CURL_SSLVERSION_TLSv1_2;
break;
@@ -799,17 +805,16 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex)
conn->host.name;
const char *sni;
unsigned int protoflags = 0;
- long timeout;
Qso_OverlappedIO_t commarea;
int sockpair[2];
static const int sobufsize = CURL_MAX_WRITE_SIZE;
/* Create SSL environment, start (preferably asynchronous) handshake. */
- connssl->handle = (gsk_handle) NULL;
- connssl->iocport = -1;
- connssl->localfd = -1;
- connssl->remotefd = -1;
+ BACKEND->handle = (gsk_handle) NULL;
+ BACKEND->iocport = -1;
+ BACKEND->localfd = -1;
+ BACKEND->remotefd = -1;
/* GSKit supports two ways of specifying an SSL context: either by
* application identifier (that should have been defined at the system
@@ -842,7 +847,7 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex)
}
/* Create secure session. */
- result = gskit_status(data, gsk_secure_soc_open(envir, &connssl->handle),
+ result = gskit_status(data, gsk_secure_soc_open(envir, &BACKEND->handle),
"gsk_secure_soc_open()", CURLE_SSL_CONNECT_ERROR);
gsk_environment_close(&envir);
if(result)
@@ -852,18 +857,18 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex)
if(conn->proxy_ssl[sockindex].use) {
if(inetsocketpair(sockpair))
return CURLE_SSL_CONNECT_ERROR;
- connssl->localfd = sockpair[0];
- connssl->remotefd = sockpair[1];
- setsockopt(connssl->localfd, SOL_SOCKET, SO_RCVBUF,
- (void *) sobufsize, sizeof sobufsize);
- setsockopt(connssl->remotefd, SOL_SOCKET, SO_RCVBUF,
- (void *) sobufsize, sizeof sobufsize);
- setsockopt(connssl->localfd, SOL_SOCKET, SO_SNDBUF,
- (void *) sobufsize, sizeof sobufsize);
- setsockopt(connssl->remotefd, SOL_SOCKET, SO_SNDBUF,
- (void *) sobufsize, sizeof sobufsize);
- curlx_nonblock(connssl->localfd, TRUE);
- curlx_nonblock(connssl->remotefd, TRUE);
+ BACKEND->localfd = sockpair[0];
+ BACKEND->remotefd = sockpair[1];
+ setsockopt(BACKEND->localfd, SOL_SOCKET, SO_RCVBUF,
+ (void *) sobufsize, sizeof(sobufsize));
+ setsockopt(BACKEND->remotefd, SOL_SOCKET, SO_RCVBUF,
+ (void *) sobufsize, sizeof(sobufsize));
+ setsockopt(BACKEND->localfd, SOL_SOCKET, SO_SNDBUF,
+ (void *) sobufsize, sizeof(sobufsize));
+ setsockopt(BACKEND->remotefd, SOL_SOCKET, SO_SNDBUF,
+ (void *) sobufsize, sizeof(sobufsize));
+ curlx_nonblock(BACKEND->localfd, TRUE);
+ curlx_nonblock(BACKEND->remotefd, TRUE);
}
/* Determine which SSL/TLS version should be enabled. */
@@ -897,7 +902,7 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex)
/* Process SNI. Ignore if not supported (on OS400 < V7R1). */
if(sni) {
- result = set_buffer(data, connssl->handle,
+ result = set_buffer(data, BACKEND->handle,
GSK_SSL_EXTN_SERVERNAME_REQUEST, sni, TRUE);
if(result == CURLE_UNSUPPORTED_PROTOCOL)
result = CURLE_OK;
@@ -907,38 +912,38 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex)
if(!result) {
/* Compute the handshake timeout. Since GSKit granularity is 1 second,
we round up the required value. */
- timeout = Curl_timeleft(data, NULL, TRUE);
+ long timeout = Curl_timeleft(data, NULL, TRUE);
if(timeout < 0)
result = CURLE_OPERATION_TIMEDOUT;
else
- result = set_numeric(data, connssl->handle, GSK_HANDSHAKE_TIMEOUT,
+ result = set_numeric(data, BACKEND->handle, GSK_HANDSHAKE_TIMEOUT,
(timeout + 999) / 1000);
}
if(!result)
- result = set_numeric(data, connssl->handle, GSK_OS400_READ_TIMEOUT, 1);
+ result = set_numeric(data, BACKEND->handle, GSK_OS400_READ_TIMEOUT, 1);
if(!result)
- result = set_numeric(data, connssl->handle, GSK_FD, connssl->localfd >= 0?
- connssl->localfd: conn->sock[sockindex]);
+ result = set_numeric(data, BACKEND->handle, GSK_FD, BACKEND->localfd >= 0?
+ BACKEND->localfd: conn->sock[sockindex]);
if(!result)
- result = set_ciphers(conn, connssl->handle, &protoflags);
+ result = set_ciphers(conn, BACKEND->handle, &protoflags);
if(!protoflags) {
failf(data, "No SSL protocol/cipher combination enabled");
result = CURLE_SSL_CIPHER;
}
if(!result)
- result = set_enum(data, connssl->handle, GSK_PROTOCOL_SSLV2,
+ result = set_enum(data, BACKEND->handle, GSK_PROTOCOL_SSLV2,
(protoflags & CURL_GSKPROTO_SSLV2_MASK)?
GSK_PROTOCOL_SSLV2_ON: GSK_PROTOCOL_SSLV2_OFF, FALSE);
if(!result)
- result = set_enum(data, connssl->handle, GSK_PROTOCOL_SSLV3,
+ result = set_enum(data, BACKEND->handle, GSK_PROTOCOL_SSLV3,
(protoflags & CURL_GSKPROTO_SSLV3_MASK)?
GSK_PROTOCOL_SSLV3_ON: GSK_PROTOCOL_SSLV3_OFF, FALSE);
if(!result)
- result = set_enum(data, connssl->handle, GSK_PROTOCOL_TLSV1,
+ result = set_enum(data, BACKEND->handle, GSK_PROTOCOL_TLSV1,
(protoflags & CURL_GSKPROTO_TLSV10_MASK)?
GSK_PROTOCOL_TLSV1_ON: GSK_PROTOCOL_TLSV1_OFF, FALSE);
if(!result) {
- result = set_enum(data, connssl->handle, GSK_PROTOCOL_TLSV11,
+ result = set_enum(data, BACKEND->handle, GSK_PROTOCOL_TLSV11,
(protoflags & CURL_GSKPROTO_TLSV11_MASK)?
GSK_TRUE: GSK_FALSE, TRUE);
if(result == CURLE_UNSUPPORTED_PROTOCOL) {
@@ -950,7 +955,7 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex)
}
}
if(!result) {
- result = set_enum(data, connssl->handle, GSK_PROTOCOL_TLSV12,
+ result = set_enum(data, BACKEND->handle, GSK_PROTOCOL_TLSV12,
(protoflags & CURL_GSKPROTO_TLSV12_MASK)?
GSK_TRUE: GSK_FALSE, TRUE);
if(result == CURLE_UNSUPPORTED_PROTOCOL) {
@@ -962,18 +967,18 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex)
}
}
if(!result)
- result = set_enum(data, connssl->handle, GSK_SERVER_AUTH_TYPE,
+ result = set_enum(data, BACKEND->handle, GSK_SERVER_AUTH_TYPE,
verifypeer? GSK_SERVER_AUTH_FULL:
GSK_SERVER_AUTH_PASSTHRU, FALSE);
if(!result) {
/* Start handshake. Try asynchronous first. */
- memset(&commarea, 0, sizeof commarea);
- connssl->iocport = QsoCreateIOCompletionPort();
- if(connssl->iocport != -1) {
+ memset(&commarea, 0, sizeof(commarea));
+ BACKEND->iocport = QsoCreateIOCompletionPort();
+ if(BACKEND->iocport != -1) {
result = gskit_status(data,
- gsk_secure_soc_startInit(connssl->handle,
- connssl->iocport,
+ gsk_secure_soc_startInit(BACKEND->handle,
+ BACKEND->iocport,
&commarea),
"gsk_secure_soc_startInit()",
CURLE_SSL_CONNECT_ERROR);
@@ -993,7 +998,7 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex)
}
else {
/* No more completion port available. Use synchronous IO. */
- result = gskit_status(data, gsk_secure_soc_init(connssl->handle),
+ result = gskit_status(data, gsk_secure_soc_init(BACKEND->handle),
"gsk_secure_soc_init()", CURLE_SSL_CONNECT_ERROR);
if(!result) {
connssl->connecting_state = ssl_connect_3;
@@ -1014,19 +1019,18 @@ static CURLcode gskit_connect_step2(struct connectdata *conn, int sockindex,
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
Qso_OverlappedIO_t cstat;
- long timeout_ms;
struct timeval stmv;
CURLcode result;
/* Poll or wait for end of SSL asynchronous handshake. */
for(;;) {
- timeout_ms = nonblocking? 0: Curl_timeleft(data, NULL, TRUE);
+ long timeout_ms = nonblocking? 0: Curl_timeleft(data, NULL, TRUE);
if(timeout_ms < 0)
timeout_ms = 0;
stmv.tv_sec = timeout_ms / 1000;
stmv.tv_usec = (timeout_ms - stmv.tv_sec * 1000) * 1000;
- switch(QsoWaitForIOCompletion(connssl->iocport, &cstat, &stmv)) {
+ switch(QsoWaitForIOCompletion(BACKEND->iocport, &cstat, &stmv)) {
case 1: /* Operation complete. */
break;
case -1: /* An error occurred: handshake still in progress. */
@@ -1070,16 +1074,17 @@ static CURLcode gskit_connect_step3(struct connectdata *conn, int sockindex)
const char *cert = (const char *) NULL;
const char *certend;
const char *ptr;
- int i;
CURLcode result;
/* SSL handshake done: gather certificate info and verify host. */
- if(gskit_status(data, gsk_attribute_get_cert_info(connssl->handle,
+ if(gskit_status(data, gsk_attribute_get_cert_info(BACKEND->handle,
GSK_PARTNER_CERT_INFO,
&cdev, &cdec),
"gsk_attribute_get_cert_info()", CURLE_SSL_CONNECT_ERROR) ==
CURLE_OK) {
+ int i;
+
infof(data, "Server certificate:\n");
p = cdev;
for(i = 0; i++ < cdec; p++)
@@ -1153,7 +1158,6 @@ static CURLcode gskit_connect_common(struct connectdata *conn, int sockindex,
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
long timeout_ms;
- Qso_OverlappedIO_t cstat;
CURLcode result = CURLE_OK;
*done = connssl->state == ssl_connection_complete;
@@ -1216,9 +1220,8 @@ static CURLcode gskit_connect_common(struct connectdata *conn, int sockindex,
}
-CURLcode Curl_gskit_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done)
+static CURLcode Curl_gskit_connect_nonblocking(struct connectdata *conn,
+ int sockindex, bool *done)
{
CURLcode result;
@@ -1229,7 +1232,7 @@ CURLcode Curl_gskit_connect_nonblocking(struct connectdata *conn,
}
-CURLcode Curl_gskit_connect(struct connectdata *conn, int sockindex)
+static CURLcode Curl_gskit_connect(struct connectdata *conn, int sockindex)
{
CURLcode result;
bool done;
@@ -1245,27 +1248,28 @@ CURLcode Curl_gskit_connect(struct connectdata *conn, int sockindex)
}
-void Curl_gskit_close(struct connectdata *conn, int sockindex)
+static void Curl_gskit_close(struct connectdata *conn, int sockindex)
{
close_one(&conn->ssl[sockindex], conn, sockindex);
close_one(&conn->proxy_ssl[sockindex], conn, sockindex);
}
-int Curl_gskit_shutdown(struct connectdata *conn, int sockindex)
+static int Curl_gskit_shutdown(struct connectdata *conn, int sockindex)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
struct Curl_easy *data = conn->data;
- ssize_t nread;
int what;
int rc;
char buf[120];
- if(!connssl->handle)
+ if(!BACKEND->handle)
return 0;
+#ifndef CURL_DISABLE_FTP
if(data->set.ftp_ccc != CURLFTPSSL_CCC_ACTIVE)
return 0;
+#endif
close_one(connssl, conn, sockindex);
rc = 0;
@@ -1273,6 +1277,8 @@ int Curl_gskit_shutdown(struct connectdata *conn, int sockindex)
SSL_SHUTDOWN_TIMEOUT);
for(;;) {
+ ssize_t nread;
+
if(what < 0) {
/* anything that gets here is fatally bad */
failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
@@ -1306,32 +1312,70 @@ int Curl_gskit_shutdown(struct connectdata *conn, int sockindex)
}
-size_t Curl_gskit_version(char *buffer, size_t size)
+static size_t Curl_gskit_version(char *buffer, size_t size)
{
- strncpy(buffer, "GSKit", size);
- return strlen(buffer);
+ return msnprintf(buffer, size, "GSKit");
}
-int Curl_gskit_check_cxn(struct connectdata *cxn)
+static int Curl_gskit_check_cxn(struct connectdata *cxn)
{
+ struct ssl_connect_data *connssl = &cxn->ssl[FIRSTSOCKET];
int err;
int errlen;
/* The only thing that can be tested here is at the socket level. */
- if(!cxn->ssl[FIRSTSOCKET].handle)
+ if(!BACKEND->handle)
return 0; /* connection has been closed */
err = 0;
- errlen = sizeof err;
+ errlen = sizeof(err);
if(getsockopt(cxn->sock[FIRSTSOCKET], SOL_SOCKET, SO_ERROR,
(unsigned char *) &err, &errlen) ||
- errlen != sizeof err || err)
+ errlen != sizeof(err) || err)
return 0; /* connection has been closed */
return -1; /* connection status unknown */
}
+static void *Curl_gskit_get_internals(struct ssl_connect_data *connssl,
+ CURLINFO info UNUSED_PARAM)
+{
+ (void)info;
+ return BACKEND->handle;
+}
+
+const struct Curl_ssl Curl_ssl_gskit = {
+ { CURLSSLBACKEND_GSKIT, "gskit" }, /* info */
+
+ SSLSUPP_CERTINFO |
+ SSLSUPP_PINNEDPUBKEY,
+
+ sizeof(struct ssl_backend_data),
+
+ Curl_gskit_init, /* init */
+ Curl_gskit_cleanup, /* cleanup */
+ Curl_gskit_version, /* version */
+ Curl_gskit_check_cxn, /* check_cxn */
+ Curl_gskit_shutdown, /* shutdown */
+ Curl_none_data_pending, /* data_pending */
+ Curl_none_random, /* random */
+ Curl_none_cert_status_request, /* cert_status_request */
+ Curl_gskit_connect, /* connect */
+ Curl_gskit_connect_nonblocking, /* connect_nonblocking */
+ Curl_gskit_get_internals, /* get_internals */
+ Curl_gskit_close, /* close_one */
+ Curl_none_close_all, /* close_all */
+ /* No session handling for GSKit */
+ Curl_none_session_free, /* session_free */
+ Curl_none_set_engine, /* set_engine */
+ Curl_none_set_engine_default, /* set_engine_default */
+ Curl_none_engines_list, /* engines_list */
+ Curl_none_false_start, /* false_start */
+ Curl_none_md5sum, /* md5sum */
+ NULL /* sha256sum */
+};
+
#endif /* USE_GSKIT */
diff --git a/Utilities/cmcurl/lib/vtls/gskit.h b/Utilities/cmcurl/lib/vtls/gskit.h
index 229759217..466ee4d9d 100644
--- a/Utilities/cmcurl/lib/vtls/gskit.h
+++ b/Utilities/cmcurl/lib/vtls/gskit.h
@@ -30,44 +30,8 @@
#include "urldata.h"
#ifdef USE_GSKIT
-int Curl_gskit_init(void);
-void Curl_gskit_cleanup(void);
-CURLcode Curl_gskit_connect(struct connectdata *conn, int sockindex);
-CURLcode Curl_gskit_connect_nonblocking(struct connectdata *conn,
- int sockindex, bool *done);
-void Curl_gskit_close(struct connectdata *conn, int sockindex);
-int Curl_gskit_shutdown(struct connectdata *conn, int sockindex);
-size_t Curl_gskit_version(char *buffer, size_t size);
-int Curl_gskit_check_cxn(struct connectdata *cxn);
-
-/* Support HTTPS-proxy */
-/* TODO: add '#define HTTPS_PROXY_SUPPORT 1' and fix test #1014 (if need) */
-
-/* Set the API backend definition to GSKit */
-#define CURL_SSL_BACKEND CURLSSLBACKEND_GSKIT
-
-/* this backend supports CURLOPT_CERTINFO */
-#define have_curlssl_certinfo 1
-
-/* API setup for GSKit */
-#define curlssl_init Curl_gskit_init
-#define curlssl_cleanup Curl_gskit_cleanup
-#define curlssl_connect Curl_gskit_connect
-#define curlssl_connect_nonblocking Curl_gskit_connect_nonblocking
-
-/* No session handling for GSKit */
-#define curlssl_session_free(x) Curl_nop_stmt
-#define curlssl_close_all(x) ((void)x)
-#define curlssl_close Curl_gskit_close
-#define curlssl_shutdown(x,y) Curl_gskit_shutdown(x,y)
-#define curlssl_set_engine(x,y) CURLE_NOT_BUILT_IN
-#define curlssl_set_engine_default(x) CURLE_NOT_BUILT_IN
-#define curlssl_engines_list(x) NULL
-#define curlssl_version Curl_gskit_version
-#define curlssl_check_cxn(x) Curl_gskit_check_cxn(x)
-#define curlssl_data_pending(x,y) 0
-#define curlssl_random(x,y,z) (x=x, y=y, z=z, CURLE_NOT_BUILT_IN)
+extern const struct Curl_ssl Curl_ssl_gskit;
#endif /* USE_GSKIT */
diff --git a/Utilities/cmcurl/lib/vtls/gtls.c b/Utilities/cmcurl/lib/vtls/gtls.c
index 844be2de1..8693cdce3 100644
--- a/Utilities/cmcurl/lib/vtls/gtls.c
+++ b/Utilities/cmcurl/lib/vtls/gtls.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -55,22 +55,12 @@
#include "strcase.h"
#include "warnless.h"
#include "x509asn1.h"
+#include "multiif.h"
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
-/*
- Some hackish cast macros based on:
- https://developer.gnome.org/glib/unstable/glib-Type-Conversion-Macros.html
-*/
-#ifndef GNUTLS_POINTER_TO_INT_CAST
-#define GNUTLS_POINTER_TO_INT_CAST(p) ((int) (long) (p))
-#endif
-#ifndef GNUTLS_INT_TO_POINTER_CAST
-#define GNUTLS_INT_TO_POINTER_CAST(i) ((void *) (long) (i))
-#endif
-
/* Enable GnuTLS debugging by defining GTLSDEBUG */
/*#define GTLSDEBUG */
@@ -105,10 +95,24 @@ static bool gtls_inited = FALSE;
# endif
#endif
+#if (GNUTLS_VERSION_NUMBER >= 0x030603)
+#define HAS_TLS13
+#endif
+
#ifdef HAS_OCSP
# include <gnutls/ocsp.h>
#endif
+struct ssl_backend_data {
+ gnutls_session_t session;
+ gnutls_certificate_credentials_t cred;
+#ifdef USE_TLS_SRP
+ gnutls_srp_client_credentials_t srp_client_cred;
+#endif
+};
+
+#define BACKEND connssl->backend
+
/*
* Custom push and pull callback functions used by GNU TLS to read and write
* to the socket. These functions are simple wrappers to send() and recv()
@@ -153,7 +157,8 @@ static int gtls_mapped_sockerrno(void)
static ssize_t Curl_gtls_push(void *s, const void *buf, size_t len)
{
- ssize_t ret = swrite(GNUTLS_POINTER_TO_INT_CAST(s), buf, len);
+ curl_socket_t sock = *(curl_socket_t *)s;
+ ssize_t ret = swrite(sock, buf, len);
#if defined(USE_WINSOCK) && !defined(GNUTLS_MAPS_WINSOCK_ERRORS)
if(ret < 0)
gnutls_transport_set_global_errno(gtls_mapped_sockerrno());
@@ -163,7 +168,8 @@ static ssize_t Curl_gtls_push(void *s, const void *buf, size_t len)
static ssize_t Curl_gtls_pull(void *s, void *buf, size_t len)
{
- ssize_t ret = sread(GNUTLS_POINTER_TO_INT_CAST(s), buf, len);
+ curl_socket_t sock = *(curl_socket_t *)s;
+ ssize_t ret = sread(sock, buf, len);
#if defined(USE_WINSOCK) && !defined(GNUTLS_MAPS_WINSOCK_ERRORS)
if(ret < 0)
gnutls_transport_set_global_errno(gtls_mapped_sockerrno());
@@ -188,7 +194,7 @@ static ssize_t Curl_gtls_pull_ssl(void *s, void *buf, size_t len)
* must only be called from within curl_global_init() to keep the thread
* situation under control!
*/
-int Curl_gtls_init(void)
+static int Curl_gtls_init(void)
{
int ret = 1;
if(!gtls_inited) {
@@ -202,13 +208,12 @@ int Curl_gtls_init(void)
return ret;
}
-int Curl_gtls_cleanup(void)
+static void Curl_gtls_cleanup(void)
{
if(gtls_inited) {
gnutls_global_deinit();
gtls_inited = FALSE;
}
- return 1;
}
#ifndef CURL_DISABLE_VERBOSE_STRINGS
@@ -223,17 +228,17 @@ static void showtime(struct Curl_easy *data,
if(result)
return;
- snprintf(str,
- sizeof(str),
- "\t %s: %s, %02d %s %4d %02d:%02d:%02d GMT",
- text,
- Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
- tm->tm_mday,
- Curl_month[tm->tm_mon],
- tm->tm_year + 1900,
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec);
+ msnprintf(str,
+ sizeof(str),
+ "\t %s: %s, %02d %s %4d %02d:%02d:%02d GMT",
+ text,
+ Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
+ tm->tm_mday,
+ Curl_month[tm->tm_mon],
+ tm->tm_year + 1900,
+ tm->tm_hour,
+ tm->tm_min,
+ tm->tm_sec);
infof(data, "%s\n", str);
}
#endif
@@ -279,13 +284,13 @@ static CURLcode handshake(struct connectdata *conn,
{
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- gnutls_session_t session = conn->ssl[sockindex].session;
+ gnutls_session_t session = BACKEND->session;
curl_socket_t sockfd = conn->sock[sockindex];
- time_t timeout_ms;
- int rc;
- int what;
for(;;) {
+ time_t timeout_ms;
+ int rc;
+
/* check allowed time left */
timeout_ms = Curl_timeleft(data, NULL, duringconnect);
@@ -298,10 +303,10 @@ static CURLcode handshake(struct connectdata *conn,
/* if ssl is expecting something, check if it's available. */
if(connssl->connecting_state == ssl_connect_2_reading
|| connssl->connecting_state == ssl_connect_2_writing) {
-
- curl_socket_t writefd = ssl_connect_2_writing==
+ int what;
+ curl_socket_t writefd = ssl_connect_2_writing ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
- curl_socket_t readfd = ssl_connect_2_reading==
+ curl_socket_t readfd = ssl_connect_2_reading ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
@@ -390,9 +395,10 @@ set_ssl_version_min_max(int *list, size_t list_size, struct connectdata *conn)
switch(ssl_version_max) {
case CURL_SSLVERSION_MAX_NONE:
- ssl_version_max = ssl_version << 16;
- break;
case CURL_SSLVERSION_MAX_DEFAULT:
+#ifdef HAS_TLS13
+ ssl_version_max = CURL_SSLVERSION_MAX_TLSv1_3;
+#endif
ssl_version_max = CURL_SSLVERSION_MAX_TLSv1_2;
break;
}
@@ -410,8 +416,13 @@ set_ssl_version_min_max(int *list, size_t list_size, struct connectdata *conn)
protocol_priority[protocol_priority_idx++] = GNUTLS_TLS1_2;
break;
case CURL_SSLVERSION_TLSv1_3:
+#ifdef HAS_TLS13
+ protocol_priority[protocol_priority_idx++] = GNUTLS_TLS1_3;
+ break;
+#else
failf(data, "GnuTLS: TLS 1.3 is not yet supported");
return CURLE_SSL_CONNECT_ERROR;
+#endif
}
}
return CURLE_OK;
@@ -429,13 +440,9 @@ set_ssl_version_min_max(const char **prioritylist, struct connectdata *conn)
struct Curl_easy *data = conn->data;
long ssl_version = SSL_CONN_CONFIG(version);
long ssl_version_max = SSL_CONN_CONFIG(version_max);
- if(ssl_version == CURL_SSLVERSION_TLSv1_3 ||
- ssl_version_max == CURL_SSLVERSION_MAX_TLSv1_3) {
- failf(data, "GnuTLS: TLS 1.3 is not yet supported");
- return CURLE_SSL_CONNECT_ERROR;
- }
+
if(ssl_version_max == CURL_SSLVERSION_MAX_NONE) {
- ssl_version_max = ssl_version << 16;
+ ssl_version_max = CURL_SSLVERSION_MAX_DEFAULT;
}
switch(ssl_version | ssl_version_max) {
case CURL_SSLVERSION_TLSv1_0 | CURL_SSLVERSION_MAX_TLSv1_0:
@@ -447,7 +454,6 @@ set_ssl_version_min_max(const char **prioritylist, struct connectdata *conn)
"+VERS-TLS1.0:+VERS-TLS1.1:" GNUTLS_SRP;
return CURLE_OK;
case CURL_SSLVERSION_TLSv1_0 | CURL_SSLVERSION_MAX_TLSv1_2:
- case CURL_SSLVERSION_TLSv1_0 | CURL_SSLVERSION_MAX_DEFAULT:
*prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
"+VERS-TLS1.0:+VERS-TLS1.1:+VERS-TLS1.2:" GNUTLS_SRP;
return CURLE_OK;
@@ -456,15 +462,54 @@ set_ssl_version_min_max(const char **prioritylist, struct connectdata *conn)
"+VERS-TLS1.1:" GNUTLS_SRP;
return CURLE_OK;
case CURL_SSLVERSION_TLSv1_1 | CURL_SSLVERSION_MAX_TLSv1_2:
- case CURL_SSLVERSION_TLSv1_1 | CURL_SSLVERSION_MAX_DEFAULT:
*prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
"+VERS-TLS1.1:+VERS-TLS1.2:" GNUTLS_SRP;
return CURLE_OK;
case CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_TLSv1_2:
- case CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_DEFAULT:
*prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
"+VERS-TLS1.2:" GNUTLS_SRP;
return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_3 | CURL_SSLVERSION_MAX_TLSv1_3:
+#ifdef HAS_TLS13
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.3:" GNUTLS_SRP;
+ return CURLE_OK;
+#else
+ failf(data, "GnuTLS: TLS 1.3 is not yet supported");
+ return CURLE_SSL_CONNECT_ERROR;
+#endif
+ case CURL_SSLVERSION_TLSv1_0 | CURL_SSLVERSION_MAX_DEFAULT:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.0:+VERS-TLS1.1:+VERS-TLS1.2:"
+#ifdef HAS_TLS13
+ "+VERS-TLS1.3:"
+#endif
+ GNUTLS_SRP;
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_1 | CURL_SSLVERSION_MAX_DEFAULT:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.1:+VERS-TLS1.2:"
+#ifdef HAS_TLS13
+ "+VERS-TLS1.3:"
+#endif
+ GNUTLS_SRP;
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_2 | CURL_SSLVERSION_MAX_DEFAULT:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.2:"
+#ifdef HAS_TLS13
+ "+VERS-TLS1.3:"
+#endif
+ GNUTLS_SRP;
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_3 | CURL_SSLVERSION_MAX_DEFAULT:
+ *prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:-VERS-TLS-ALL:"
+ "+VERS-TLS1.2:"
+#ifdef HAS_TLS13
+ "+VERS-TLS1.3:"
+#endif
+ GNUTLS_SRP;
+ return CURLE_OK;
}
failf(data, "GnuTLS: cannot set ssl protocol");
@@ -477,6 +522,7 @@ gtls_connect_step1(struct connectdata *conn,
int sockindex)
{
struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
unsigned int init_flags;
gnutls_session_t session;
int rc;
@@ -512,7 +558,7 @@ gtls_connect_step1(struct connectdata *conn,
const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
- if(conn->ssl[sockindex].state == ssl_connection_complete)
+ if(connssl->state == ssl_connection_complete)
/* to make us tolerant against being called more than once for the
same connection */
return CURLE_OK;
@@ -528,7 +574,7 @@ gtls_connect_step1(struct connectdata *conn,
sni = FALSE; /* SSLv3 has no SNI */
/* allocate a cred struct */
- rc = gnutls_certificate_allocate_credentials(&conn->ssl[sockindex].cred);
+ rc = gnutls_certificate_allocate_credentials(&BACKEND->cred);
if(rc != GNUTLS_E_SUCCESS) {
failf(data, "gnutls_cert_all_cred() failed: %s", gnutls_strerror(rc));
return CURLE_SSL_CONNECT_ERROR;
@@ -539,15 +585,14 @@ gtls_connect_step1(struct connectdata *conn,
infof(data, "Using TLS-SRP username: %s\n", SSL_SET_OPTION(username));
rc = gnutls_srp_allocate_client_credentials(
- &conn->ssl[sockindex].srp_client_cred);
+ &BACKEND->srp_client_cred);
if(rc != GNUTLS_E_SUCCESS) {
failf(data, "gnutls_srp_allocate_client_cred() failed: %s",
gnutls_strerror(rc));
return CURLE_OUT_OF_MEMORY;
}
- rc = gnutls_srp_set_client_credentials(conn->ssl[sockindex].
- srp_client_cred,
+ rc = gnutls_srp_set_client_credentials(BACKEND->srp_client_cred,
SSL_SET_OPTION(username),
SSL_SET_OPTION(password));
if(rc != GNUTLS_E_SUCCESS) {
@@ -560,10 +605,10 @@ gtls_connect_step1(struct connectdata *conn,
if(SSL_CONN_CONFIG(CAfile)) {
/* set the trusted CA cert bundle file */
- gnutls_certificate_set_verify_flags(conn->ssl[sockindex].cred,
+ gnutls_certificate_set_verify_flags(BACKEND->cred,
GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT);
- rc = gnutls_certificate_set_x509_trust_file(conn->ssl[sockindex].cred,
+ rc = gnutls_certificate_set_x509_trust_file(BACKEND->cred,
SSL_CONN_CONFIG(CAfile),
GNUTLS_X509_FMT_PEM);
if(rc < 0) {
@@ -580,7 +625,7 @@ gtls_connect_step1(struct connectdata *conn,
#ifdef HAS_CAPATH
if(SSL_CONN_CONFIG(CApath)) {
/* set the trusted CA cert directory */
- rc = gnutls_certificate_set_x509_trust_dir(conn->ssl[sockindex].cred,
+ rc = gnutls_certificate_set_x509_trust_dir(BACKEND->cred,
SSL_CONN_CONFIG(CApath),
GNUTLS_X509_FMT_PEM);
if(rc < 0) {
@@ -599,13 +644,13 @@ gtls_connect_step1(struct connectdata *conn,
/* use system ca certificate store as fallback */
if(SSL_CONN_CONFIG(verifypeer) &&
!(SSL_CONN_CONFIG(CAfile) || SSL_CONN_CONFIG(CApath))) {
- gnutls_certificate_set_x509_system_trust(conn->ssl[sockindex].cred);
+ gnutls_certificate_set_x509_system_trust(BACKEND->cred);
}
#endif
if(SSL_SET_OPTION(CRLfile)) {
/* set the CRL list file */
- rc = gnutls_certificate_set_x509_crl_file(conn->ssl[sockindex].cred,
+ rc = gnutls_certificate_set_x509_crl_file(BACKEND->cred,
SSL_SET_OPTION(CRLfile),
GNUTLS_X509_FMT_PEM);
if(rc < 0) {
@@ -626,14 +671,14 @@ gtls_connect_step1(struct connectdata *conn,
init_flags |= GNUTLS_NO_TICKETS;
#endif
- rc = gnutls_init(&conn->ssl[sockindex].session, init_flags);
+ rc = gnutls_init(&BACKEND->session, init_flags);
if(rc != GNUTLS_E_SUCCESS) {
failf(data, "gnutls_init() failed: %d", rc);
return CURLE_SSL_CONNECT_ERROR;
}
/* convenient assign */
- session = conn->ssl[sockindex].session;
+ session = BACKEND->session;
if((0 == Curl_inet_pton(AF_INET, hostname, &addr)) &&
#ifdef ENABLE_IPV6
@@ -677,6 +722,9 @@ gtls_connect_step1(struct connectdata *conn,
protocol_priority[0] = GNUTLS_TLS1_0;
protocol_priority[1] = GNUTLS_TLS1_1;
protocol_priority[2] = GNUTLS_TLS1_2;
+#ifdef HAS_TLS13
+ protocol_priority[3] = GNUTLS_TLS1_3;
+#endif
break;
case CURL_SSLVERSION_TLSv1_0:
case CURL_SSLVERSION_TLSv1_1:
@@ -709,11 +757,14 @@ gtls_connect_step1(struct connectdata *conn,
switch(SSL_CONN_CONFIG(version)) {
case CURL_SSLVERSION_SSLv3:
prioritylist = GNUTLS_CIPHERS ":-VERS-TLS-ALL:+VERS-SSL3.0";
- sni = false;
break;
case CURL_SSLVERSION_DEFAULT:
case CURL_SSLVERSION_TLSv1:
- prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:" GNUTLS_SRP;
+ prioritylist = GNUTLS_CIPHERS ":-VERS-SSL3.0:"
+#ifdef HAS_TLS13
+ "+VERS-TLS1.3:"
+#endif
+ GNUTLS_SRP;
break;
case CURL_SSLVERSION_TLSv1_0:
case CURL_SSLVERSION_TLSv1_1:
@@ -763,7 +814,8 @@ gtls_connect_step1(struct connectdata *conn,
gnutls_datum_t protocols[2];
#ifdef USE_NGHTTP2
- if(data->set.httpversion >= CURL_HTTP_VERSION_2) {
+ if(data->set.httpversion >= CURL_HTTP_VERSION_2 &&
+ (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)) {
protocols[cur].data = (unsigned char *)NGHTTP2_PROTO_VERSION_ID;
protocols[cur].size = NGHTTP2_PROTO_VERSION_ID_LEN;
cur++;
@@ -789,7 +841,7 @@ gtls_connect_step1(struct connectdata *conn,
GNUTLS_PKCS_USE_PBES2_AES_128 | GNUTLS_PKCS_USE_PBES2_AES_192 |
GNUTLS_PKCS_USE_PBES2_AES_256;
rc = gnutls_certificate_set_x509_key_file2(
- conn->ssl[sockindex].cred,
+ BACKEND->cred,
SSL_SET_OPTION(cert),
SSL_SET_OPTION(key) ?
SSL_SET_OPTION(key) : SSL_SET_OPTION(cert),
@@ -809,7 +861,7 @@ gtls_connect_step1(struct connectdata *conn,
}
else {
if(gnutls_certificate_set_x509_key_file(
- conn->ssl[sockindex].cred,
+ BACKEND->cred,
SSL_SET_OPTION(cert),
SSL_SET_OPTION(key) ?
SSL_SET_OPTION(key) : SSL_SET_OPTION(cert),
@@ -825,7 +877,7 @@ gtls_connect_step1(struct connectdata *conn,
/* put the credentials to the current session */
if(SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP) {
rc = gnutls_credentials_set(session, GNUTLS_CRD_SRP,
- conn->ssl[sockindex].srp_client_cred);
+ BACKEND->srp_client_cred);
if(rc != GNUTLS_E_SUCCESS) {
failf(data, "gnutls_credentials_set() failed: %s", gnutls_strerror(rc));
return CURLE_SSL_CONNECT_ERROR;
@@ -835,7 +887,7 @@ gtls_connect_step1(struct connectdata *conn,
#endif
{
rc = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE,
- conn->ssl[sockindex].cred);
+ BACKEND->cred);
if(rc != GNUTLS_E_SUCCESS) {
failf(data, "gnutls_credentials_set() failed: %s", gnutls_strerror(rc));
return CURLE_SSL_CONNECT_ERROR;
@@ -843,13 +895,13 @@ gtls_connect_step1(struct connectdata *conn,
}
if(conn->proxy_ssl[sockindex].use) {
- transport_ptr = conn->proxy_ssl[sockindex].session;
+ transport_ptr = conn->proxy_ssl[sockindex].backend->session;
gnutls_transport_push = Curl_gtls_push_ssl;
gnutls_transport_pull = Curl_gtls_pull_ssl;
}
else {
/* file descriptor for the socket */
- transport_ptr = GNUTLS_INT_TO_POINTER_CAST(conn->sock[sockindex]);
+ transport_ptr = &conn->sock[sockindex];
gnutls_transport_push = Curl_gtls_push;
gnutls_transport_pull = Curl_gtls_pull;
}
@@ -905,7 +957,6 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data,
gnutls_pubkey_t key = NULL;
/* Result is returned to caller */
- int ret = 0;
CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH;
/* if a path wasn't specified, don't pin */
@@ -916,6 +967,8 @@ static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data,
return result;
do {
+ int ret;
+
/* Begin Gyrations to get the public key */
gnutls_pubkey_init(&key);
@@ -968,7 +1021,8 @@ gtls_connect_step3(struct connectdata *conn,
time_t certclock;
const char *ptr;
struct Curl_easy *data = conn->data;
- gnutls_session_t session = conn->ssl[sockindex].session;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ gnutls_session_t session = BACKEND->session;
int rc;
#ifdef HAS_ALPN
gnutls_datum_t proto;
@@ -1058,7 +1112,7 @@ gtls_connect_step3(struct connectdata *conn,
"CRLfile: %s", SSL_CONN_CONFIG(CAfile) ? SSL_CONN_CONFIG(CAfile):
"none",
SSL_SET_OPTION(CRLfile)?SSL_SET_OPTION(CRLfile):"none");
- return CURLE_SSL_CACERT;
+ return CURLE_PEER_FAILED_VERIFICATION;
}
else
infof(data, "\t server certificate verification FAILED\n");
@@ -1100,8 +1154,8 @@ gtls_connect_step3(struct connectdata *conn,
return CURLE_SSL_INVALIDCERTSTATUS;
}
- rc = gnutls_ocsp_resp_get_single(ocsp_resp, 0, NULL, NULL, NULL, NULL,
- &status, NULL, NULL, NULL, &reason);
+ (void)gnutls_ocsp_resp_get_single(ocsp_resp, 0, NULL, NULL, NULL, NULL,
+ &status, NULL, NULL, NULL, &reason);
switch(status) {
case GNUTLS_OCSP_CERT_GOOD:
@@ -1199,7 +1253,7 @@ gtls_connect_step3(struct connectdata *conn,
SSL_SET_OPTION(issuercert)?SSL_SET_OPTION(issuercert):"none");
}
- size=sizeof(certbuf);
+ size = sizeof(certbuf);
rc = gnutls_x509_crt_get_dn_by_oid(x509_cert, GNUTLS_OID_X520_COMMON_NAME,
0, /* the first and only one */
FALSE,
@@ -1226,10 +1280,7 @@ gtls_connect_step3(struct connectdata *conn,
#define use_addr in_addr
#endif
unsigned char addrbuf[sizeof(struct use_addr)];
- unsigned char certaddr[sizeof(struct use_addr)];
- size_t addrlen = 0, certaddrlen;
- int i;
- int ret = 0;
+ size_t addrlen = 0;
if(Curl_inet_pton(AF_INET, hostname, addrbuf) > 0)
addrlen = 4;
@@ -1239,10 +1290,13 @@ gtls_connect_step3(struct connectdata *conn,
#endif
if(addrlen) {
- for(i=0; ; i++) {
- certaddrlen = sizeof(certaddr);
- ret = gnutls_x509_crt_get_subject_alt_name(x509_cert, i, certaddr,
- &certaddrlen, NULL);
+ unsigned char certaddr[sizeof(struct use_addr)];
+ int i;
+
+ for(i = 0; ; i++) {
+ size_t certaddrlen = sizeof(certaddr);
+ int ret = gnutls_x509_crt_get_subject_alt_name(x509_cert, i, certaddr,
+ &certaddrlen, NULL);
/* If this happens, it wasn't an IP address. */
if(ret == GNUTLS_E_SHORT_MEMORY_BUFFER)
continue;
@@ -1371,11 +1425,6 @@ gtls_connect_step3(struct connectdata *conn,
size = sizeof(certbuf);
gnutls_x509_crt_get_issuer_dn(x509_cert, certbuf, &size);
infof(data, "\t issuer: %s\n", certbuf);
-
- /* compression algorithm (if any) */
- ptr = gnutls_compression_get_name(gnutls_compression_get(session));
- /* the *_get_name() says "NULL" if GNUTLS_COMP_NULL is returned */
- infof(data, "\t compression: %s\n", ptr);
#endif
gnutls_x509_crt_deinit(x509_cert);
@@ -1402,6 +1451,9 @@ gtls_connect_step3(struct connectdata *conn,
}
else
infof(data, "ALPN, server did not agree to a protocol\n");
+
+ Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ?
+ BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE);
}
#endif
@@ -1414,8 +1466,6 @@ gtls_connect_step3(struct connectdata *conn,
already got it from the cache and asked to use it in the connection, it
might've been rejected and then a new one is in use now and we need to
detect that. */
- bool incache;
- void *ssl_sessionid;
void *connect_sessionid;
size_t connect_idsize = 0;
@@ -1424,6 +1474,9 @@ gtls_connect_step3(struct connectdata *conn,
connect_sessionid = malloc(connect_idsize); /* get a buffer for it */
if(connect_sessionid) {
+ bool incache;
+ void *ssl_sessionid;
+
/* extract session ID to the allocated buffer */
gnutls_session_get_data(session, connect_sessionid, &connect_idsize);
@@ -1472,7 +1525,7 @@ gtls_connect_common(struct connectdata *conn,
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
/* Initiate the connection, if not already done */
- if(ssl_connect_1==connssl->connecting_state) {
+ if(ssl_connect_1 == connssl->connecting_state) {
rc = gtls_connect_step1(conn, sockindex);
if(rc)
return rc;
@@ -1484,29 +1537,24 @@ gtls_connect_common(struct connectdata *conn,
return rc;
/* Finish connecting once the handshake is done */
- if(ssl_connect_1==connssl->connecting_state) {
+ if(ssl_connect_1 == connssl->connecting_state) {
rc = gtls_connect_step3(conn, sockindex);
if(rc)
return rc;
}
- *done = ssl_connect_1==connssl->connecting_state;
+ *done = ssl_connect_1 == connssl->connecting_state;
return CURLE_OK;
}
-CURLcode
-Curl_gtls_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done)
+static CURLcode Curl_gtls_connect_nonblocking(struct connectdata *conn,
+ int sockindex, bool *done)
{
return gtls_connect_common(conn, sockindex, TRUE, done);
}
-CURLcode
-Curl_gtls_connect(struct connectdata *conn,
- int sockindex)
-
+static CURLcode Curl_gtls_connect(struct connectdata *conn, int sockindex)
{
CURLcode result;
bool done = FALSE;
@@ -1520,15 +1568,18 @@ Curl_gtls_connect(struct connectdata *conn,
return CURLE_OK;
}
-bool Curl_gtls_data_pending(const struct connectdata *conn, int connindex)
+static bool Curl_gtls_data_pending(const struct connectdata *conn,
+ int connindex)
{
+ const struct ssl_connect_data *connssl = &conn->ssl[connindex];
bool res = FALSE;
- if(conn->ssl[connindex].session &&
- 0 != gnutls_record_check_pending(conn->ssl[connindex].session))
+ if(BACKEND->session &&
+ 0 != gnutls_record_check_pending(BACKEND->session))
res = TRUE;
- if(conn->proxy_ssl[connindex].session &&
- 0 != gnutls_record_check_pending(conn->proxy_ssl[connindex].session))
+ connssl = &conn->proxy_ssl[connindex];
+ if(BACKEND->session &&
+ 0 != gnutls_record_check_pending(BACKEND->session))
res = TRUE;
return res;
@@ -1540,7 +1591,8 @@ static ssize_t gtls_send(struct connectdata *conn,
size_t len,
CURLcode *curlcode)
{
- ssize_t rc = gnutls_record_send(conn->ssl[sockindex].session, mem, len);
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ ssize_t rc = gnutls_record_send(BACKEND->session, mem, len);
if(rc < 0) {
*curlcode = (rc == GNUTLS_E_AGAIN)
@@ -1553,26 +1605,26 @@ static ssize_t gtls_send(struct connectdata *conn,
return rc;
}
-static void close_one(struct ssl_connect_data *ssl)
+static void close_one(struct ssl_connect_data *connssl)
{
- if(ssl->session) {
- gnutls_bye(ssl->session, GNUTLS_SHUT_RDWR);
- gnutls_deinit(ssl->session);
- ssl->session = NULL;
+ if(BACKEND->session) {
+ gnutls_bye(BACKEND->session, GNUTLS_SHUT_RDWR);
+ gnutls_deinit(BACKEND->session);
+ BACKEND->session = NULL;
}
- if(ssl->cred) {
- gnutls_certificate_free_credentials(ssl->cred);
- ssl->cred = NULL;
+ if(BACKEND->cred) {
+ gnutls_certificate_free_credentials(BACKEND->cred);
+ BACKEND->cred = NULL;
}
#ifdef USE_TLS_SRP
- if(ssl->srp_client_cred) {
- gnutls_srp_free_client_credentials(ssl->srp_client_cred);
- ssl->srp_client_cred = NULL;
+ if(BACKEND->srp_client_cred) {
+ gnutls_srp_free_client_credentials(BACKEND->srp_client_cred);
+ BACKEND->srp_client_cred = NULL;
}
#endif
}
-void Curl_gtls_close(struct connectdata *conn, int sockindex)
+static void Curl_gtls_close(struct connectdata *conn, int sockindex)
{
close_one(&conn->ssl[sockindex]);
close_one(&conn->proxy_ssl[sockindex]);
@@ -1582,36 +1634,40 @@ void Curl_gtls_close(struct connectdata *conn, int sockindex)
* This function is called to shut down the SSL layer but keep the
* socket open (CCC - Clear Command Channel)
*/
-int Curl_gtls_shutdown(struct connectdata *conn, int sockindex)
+static int Curl_gtls_shutdown(struct connectdata *conn, int sockindex)
{
- ssize_t result;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
int retval = 0;
struct Curl_easy *data = conn->data;
- int done = 0;
- char buf[120];
+#ifndef CURL_DISABLE_FTP
/* This has only been tested on the proftpd server, and the mod_tls code
sends a close notify alert without waiting for a close notify alert in
response. Thus we wait for a close notify alert from the server, but
we do not send one. Let's hope other servers do the same... */
if(data->set.ftp_ccc == CURLFTPSSL_CCC_ACTIVE)
- gnutls_bye(conn->ssl[sockindex].session, GNUTLS_SHUT_WR);
+ gnutls_bye(BACKEND->session, GNUTLS_SHUT_WR);
+#endif
+
+ if(BACKEND->session) {
+ ssize_t result;
+ bool done = FALSE;
+ char buf[120];
- if(conn->ssl[sockindex].session) {
while(!done) {
int what = SOCKET_READABLE(conn->sock[sockindex],
SSL_SHUTDOWN_TIMEOUT);
if(what > 0) {
/* Something to read, let's do it and hope that it is the close
notify alert from the server */
- result = gnutls_record_recv(conn->ssl[sockindex].session,
+ result = gnutls_record_recv(BACKEND->session,
buf, sizeof(buf));
switch(result) {
case 0:
/* This is the expected response. There was no data but only
the close notify alert */
- done = 1;
+ done = TRUE;
break;
case GNUTLS_E_AGAIN:
case GNUTLS_E_INTERRUPTED:
@@ -1619,35 +1675,34 @@ int Curl_gtls_shutdown(struct connectdata *conn, int sockindex)
break;
default:
retval = -1;
- done = 1;
+ done = TRUE;
break;
}
}
else if(0 == what) {
/* timeout */
failf(data, "SSL shutdown timeout");
- done = 1;
- break;
+ done = TRUE;
}
else {
/* anything that gets here is fatally bad */
failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
retval = -1;
- done = 1;
+ done = TRUE;
}
}
- gnutls_deinit(conn->ssl[sockindex].session);
+ gnutls_deinit(BACKEND->session);
}
- gnutls_certificate_free_credentials(conn->ssl[sockindex].cred);
+ gnutls_certificate_free_credentials(BACKEND->cred);
#ifdef USE_TLS_SRP
if(SSL_SET_OPTION(authtype) == CURL_TLSAUTH_SRP
&& SSL_SET_OPTION(username) != NULL)
- gnutls_srp_free_client_credentials(conn->ssl[sockindex].srp_client_cred);
+ gnutls_srp_free_client_credentials(BACKEND->srp_client_cred);
#endif
- conn->ssl[sockindex].cred = NULL;
- conn->ssl[sockindex].session = NULL;
+ BACKEND->cred = NULL;
+ BACKEND->session = NULL;
return retval;
}
@@ -1658,9 +1713,10 @@ static ssize_t gtls_recv(struct connectdata *conn, /* connection data */
size_t buffersize, /* max amount to read */
CURLcode *curlcode)
{
+ struct ssl_connect_data *connssl = &conn->ssl[num];
ssize_t ret;
- ret = gnutls_record_recv(conn->ssl[num].session, buf, buffersize);
+ ret = gnutls_record_recv(BACKEND->session, buf, buffersize);
if((ret == GNUTLS_E_AGAIN) || (ret == GNUTLS_E_INTERRUPTED)) {
*curlcode = CURLE_AGAIN;
return -1;
@@ -1680,6 +1736,7 @@ static ssize_t gtls_recv(struct connectdata *conn, /* connection data */
if(ret < 0) {
failf(conn->data, "GnuTLS recv error (%d): %s",
+
(int)ret, gnutls_strerror((int)ret));
*curlcode = CURLE_RECV_ERROR;
return -1;
@@ -1688,14 +1745,14 @@ static ssize_t gtls_recv(struct connectdata *conn, /* connection data */
return ret;
}
-void Curl_gtls_session_free(void *ptr)
+static void Curl_gtls_session_free(void *ptr)
{
free(ptr);
}
-size_t Curl_gtls_version(char *buffer, size_t size)
+static size_t Curl_gtls_version(char *buffer, size_t size)
{
- return snprintf(buffer, size, "GnuTLS/%s", gnutls_check_version(NULL));
+ return msnprintf(buffer, size, "GnuTLS/%s", gnutls_check_version(NULL));
}
#ifndef USE_GNUTLS_NETTLE
@@ -1710,12 +1767,6 @@ static int Curl_gtls_seed(struct Curl_easy *data)
if(!ssl_seeded || data->set.str[STRING_SSL_RANDOM_FILE] ||
data->set.str[STRING_SSL_EGDSOCKET]) {
-
- /* TODO: to a good job seeding the RNG
- This may involve the gcry_control function and these options:
- GCRYCTL_SET_RANDOM_SEED_FILE
- GCRYCTL_SET_RNDEGD_SOCKET
- */
ssl_seeded = TRUE;
}
return 0;
@@ -1723,9 +1774,8 @@ static int Curl_gtls_seed(struct Curl_easy *data)
#endif
/* data might be NULL! */
-CURLcode Curl_gtls_random(struct Curl_easy *data,
- unsigned char *entropy,
- size_t length)
+static CURLcode Curl_gtls_random(struct Curl_easy *data,
+ unsigned char *entropy, size_t length)
{
#if defined(USE_GNUTLS_NETTLE)
int rc;
@@ -1740,10 +1790,10 @@ CURLcode Curl_gtls_random(struct Curl_easy *data,
return CURLE_OK;
}
-void Curl_gtls_md5sum(unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *md5sum, /* output */
- size_t md5len)
+static CURLcode Curl_gtls_md5sum(unsigned char *tmp, /* input */
+ size_t tmplen,
+ unsigned char *md5sum, /* output */
+ size_t md5len)
{
#if defined(USE_GNUTLS_NETTLE)
struct md5_ctx MD5pw;
@@ -1757,12 +1807,13 @@ void Curl_gtls_md5sum(unsigned char *tmp, /* input */
memcpy(md5sum, gcry_md_read(MD5pw, 0), md5len);
gcry_md_close(MD5pw);
#endif
+ return CURLE_OK;
}
-void Curl_gtls_sha256sum(const unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *sha256sum, /* output */
- size_t sha256len)
+static CURLcode Curl_gtls_sha256sum(const unsigned char *tmp, /* input */
+ size_t tmplen,
+ unsigned char *sha256sum, /* output */
+ size_t sha256len)
{
#if defined(USE_GNUTLS_NETTLE)
struct sha256_ctx SHA256pw;
@@ -1776,9 +1827,10 @@ void Curl_gtls_sha256sum(const unsigned char *tmp, /* input */
memcpy(sha256sum, gcry_md_read(SHA256pw, 0), sha256len);
gcry_md_close(SHA256pw);
#endif
+ return CURLE_OK;
}
-bool Curl_gtls_cert_status_request(void)
+static bool Curl_gtls_cert_status_request(void)
{
#ifdef HAS_OCSP
return TRUE;
@@ -1787,4 +1839,43 @@ bool Curl_gtls_cert_status_request(void)
#endif
}
+static void *Curl_gtls_get_internals(struct ssl_connect_data *connssl,
+ CURLINFO info UNUSED_PARAM)
+{
+ (void)info;
+ return BACKEND->session;
+}
+
+const struct Curl_ssl Curl_ssl_gnutls = {
+ { CURLSSLBACKEND_GNUTLS, "gnutls" }, /* info */
+
+ SSLSUPP_CA_PATH |
+ SSLSUPP_CERTINFO |
+ SSLSUPP_PINNEDPUBKEY |
+ SSLSUPP_HTTPS_PROXY,
+
+ sizeof(struct ssl_backend_data),
+
+ Curl_gtls_init, /* init */
+ Curl_gtls_cleanup, /* cleanup */
+ Curl_gtls_version, /* version */
+ Curl_none_check_cxn, /* check_cxn */
+ Curl_gtls_shutdown, /* shutdown */
+ Curl_gtls_data_pending, /* data_pending */
+ Curl_gtls_random, /* random */
+ Curl_gtls_cert_status_request, /* cert_status_request */
+ Curl_gtls_connect, /* connect */
+ Curl_gtls_connect_nonblocking, /* connect_nonblocking */
+ Curl_gtls_get_internals, /* get_internals */
+ Curl_gtls_close, /* close_one */
+ Curl_none_close_all, /* close_all */
+ Curl_gtls_session_free, /* session_free */
+ Curl_none_set_engine, /* set_engine */
+ Curl_none_set_engine_default, /* set_engine_default */
+ Curl_none_engines_list, /* engines_list */
+ Curl_none_false_start, /* false_start */
+ Curl_gtls_md5sum, /* md5sum */
+ Curl_gtls_sha256sum /* sha256sum */
+};
+
#endif /* USE_GNUTLS */
diff --git a/Utilities/cmcurl/lib/vtls/gtls.h b/Utilities/cmcurl/lib/vtls/gtls.h
index 462c04853..780fc109d 100644
--- a/Utilities/cmcurl/lib/vtls/gtls.h
+++ b/Utilities/cmcurl/lib/vtls/gtls.h
@@ -28,69 +28,7 @@
#include "urldata.h"
-int Curl_gtls_init(void);
-int Curl_gtls_cleanup(void);
-CURLcode Curl_gtls_connect(struct connectdata *conn, int sockindex);
-CURLcode Curl_gtls_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done);
-bool Curl_gtls_data_pending(const struct connectdata *conn,
- int connindex);
-
- /* close a SSL connection */
-void Curl_gtls_close(struct connectdata *conn, int sockindex);
-
-void Curl_gtls_session_free(void *ptr);
-size_t Curl_gtls_version(char *buffer, size_t size);
-int Curl_gtls_shutdown(struct connectdata *conn, int sockindex);
-CURLcode Curl_gtls_random(struct Curl_easy *data,
- unsigned char *entropy,
- size_t length);
-void Curl_gtls_md5sum(unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *md5sum, /* output */
- size_t md5len);
-void Curl_gtls_sha256sum(const unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *sha256sum, /* output */
- size_t sha256len);
-
-bool Curl_gtls_cert_status_request(void);
-
-/* Support HTTPS-proxy */
-#define HTTPS_PROXY_SUPPORT 1
-
-/* Set the API backend definition to GnuTLS */
-#define CURL_SSL_BACKEND CURLSSLBACKEND_GNUTLS
-
-/* this backend supports the CAPATH option */
-#define have_curlssl_ca_path 1
-
-/* this backend supports CURLOPT_CERTINFO */
-#define have_curlssl_certinfo 1
-
-/* this backend supports CURLOPT_PINNEDPUBLICKEY */
-#define have_curlssl_pinnedpubkey 1
-
-/* API setup for GnuTLS */
-#define curlssl_init Curl_gtls_init
-#define curlssl_cleanup Curl_gtls_cleanup
-#define curlssl_connect Curl_gtls_connect
-#define curlssl_connect_nonblocking Curl_gtls_connect_nonblocking
-#define curlssl_session_free(x) Curl_gtls_session_free(x)
-#define curlssl_close_all(x) ((void)x)
-#define curlssl_close Curl_gtls_close
-#define curlssl_shutdown(x,y) Curl_gtls_shutdown(x,y)
-#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN)
-#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN)
-#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL)
-#define curlssl_version Curl_gtls_version
-#define curlssl_check_cxn(x) ((void)x, -1)
-#define curlssl_data_pending(x,y) Curl_gtls_data_pending(x,y)
-#define curlssl_random(x,y,z) Curl_gtls_random(x,y,z)
-#define curlssl_md5sum(a,b,c,d) Curl_gtls_md5sum(a,b,c,d)
-#define curlssl_sha256sum(a,b,c,d) Curl_gtls_sha256sum(a,b,c,d)
-#define curlssl_cert_status_request() Curl_gtls_cert_status_request()
+extern const struct Curl_ssl Curl_ssl_gnutls;
#endif /* USE_GNUTLS */
#endif /* HEADER_CURL_GTLS_H */
diff --git a/Utilities/cmcurl/lib/vtls/mbedtls.c b/Utilities/cmcurl/lib/vtls/mbedtls.c
index 037babe38..63d1f4c81 100644
--- a/Utilities/cmcurl/lib/vtls/mbedtls.c
+++ b/Utilities/cmcurl/lib/vtls/mbedtls.c
@@ -6,7 +6,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2010 - 2011, Hoi-Ho Chan, <hoiho.chan@gmail.com>
- * Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -54,6 +54,7 @@
#include "parsedate.h"
#include "connect.h" /* for the connect timeout */
#include "select.h"
+#include "multiif.h"
#include "polarssl_threadlock.h"
/* The last 3 #include files should be in this order */
@@ -61,6 +62,21 @@
#include "curl_memory.h"
#include "memdebug.h"
+struct ssl_backend_data {
+ mbedtls_ctr_drbg_context ctr_drbg;
+ mbedtls_entropy_context entropy;
+ mbedtls_ssl_context ssl;
+ int server_fd;
+ mbedtls_x509_crt cacert;
+ mbedtls_x509_crt clicert;
+ mbedtls_x509_crl crl;
+ mbedtls_pk_context pk;
+ mbedtls_ssl_config config;
+ const char *protocols[3];
+};
+
+#define BACKEND connssl->backend
+
/* apply threading? */
#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
#define THREADING_SUPPORT
@@ -190,14 +206,11 @@ set_ssl_version_min_max(struct connectdata *conn, int sockindex)
case CURL_SSLVERSION_DEFAULT:
case CURL_SSLVERSION_TLSv1:
ssl_version = CURL_SSLVERSION_TLSv1_0;
- ssl_version_max = CURL_SSLVERSION_MAX_TLSv1_2;
break;
}
switch(ssl_version_max) {
case CURL_SSLVERSION_MAX_NONE:
- ssl_version_max = ssl_version << 16;
- break;
case CURL_SSLVERSION_MAX_DEFAULT:
ssl_version_max = CURL_SSLVERSION_MAX_TLSv1_2;
break;
@@ -214,9 +227,9 @@ set_ssl_version_min_max(struct connectdata *conn, int sockindex)
return result;
}
- mbedtls_ssl_conf_min_version(&connssl->config, MBEDTLS_SSL_MAJOR_VERSION_3,
+ mbedtls_ssl_conf_min_version(&BACKEND->config, MBEDTLS_SSL_MAJOR_VERSION_3,
mbedtls_ver_min);
- mbedtls_ssl_conf_max_version(&connssl->config, MBEDTLS_SSL_MAJOR_VERSION_3,
+ mbedtls_ssl_conf_max_version(&BACKEND->config, MBEDTLS_SSL_MAJOR_VERSION_3,
mbedtls_ver_max);
return result;
@@ -238,7 +251,7 @@ mbed_connect_step1(struct connectdata *conn,
const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port;
int ret = -1;
char errorbuf[128];
- errorbuf[0]=0;
+ errorbuf[0] = 0;
/* mbedTLS only supports SSLv3 and TLSv1 */
if(SSL_CONN_CONFIG(version) == CURL_SSLVERSION_SSLv2) {
@@ -248,9 +261,9 @@ mbed_connect_step1(struct connectdata *conn,
#ifdef THREADING_SUPPORT
entropy_init_mutex(&ts_entropy);
- mbedtls_ctr_drbg_init(&connssl->ctr_drbg);
+ mbedtls_ctr_drbg_init(&BACKEND->ctr_drbg);
- ret = mbedtls_ctr_drbg_seed(&connssl->ctr_drbg, entropy_func_mutex,
+ ret = mbedtls_ctr_drbg_seed(&BACKEND->ctr_drbg, entropy_func_mutex,
&ts_entropy, NULL, 0);
if(ret) {
#ifdef MBEDTLS_ERROR_C
@@ -260,11 +273,11 @@ mbed_connect_step1(struct connectdata *conn,
-ret, errorbuf);
}
#else
- mbedtls_entropy_init(&connssl->entropy);
- mbedtls_ctr_drbg_init(&connssl->ctr_drbg);
+ mbedtls_entropy_init(&BACKEND->entropy);
+ mbedtls_ctr_drbg_init(&BACKEND->ctr_drbg);
- ret = mbedtls_ctr_drbg_seed(&connssl->ctr_drbg, mbedtls_entropy_func,
- &connssl->entropy, NULL, 0);
+ ret = mbedtls_ctr_drbg_seed(&BACKEND->ctr_drbg, mbedtls_entropy_func,
+ &BACKEND->entropy, NULL, 0);
if(ret) {
#ifdef MBEDTLS_ERROR_C
mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
@@ -275,10 +288,10 @@ mbed_connect_step1(struct connectdata *conn,
#endif /* THREADING_SUPPORT */
/* Load the trusted CA */
- mbedtls_x509_crt_init(&connssl->cacert);
+ mbedtls_x509_crt_init(&BACKEND->cacert);
if(ssl_cafile) {
- ret = mbedtls_x509_crt_parse_file(&connssl->cacert, ssl_cafile);
+ ret = mbedtls_x509_crt_parse_file(&BACKEND->cacert, ssl_cafile);
if(ret<0) {
#ifdef MBEDTLS_ERROR_C
@@ -293,7 +306,7 @@ mbed_connect_step1(struct connectdata *conn,
}
if(ssl_capath) {
- ret = mbedtls_x509_crt_parse_path(&connssl->cacert, ssl_capath);
+ ret = mbedtls_x509_crt_parse_path(&BACKEND->cacert, ssl_capath);
if(ret<0) {
#ifdef MBEDTLS_ERROR_C
@@ -308,10 +321,10 @@ mbed_connect_step1(struct connectdata *conn,
}
/* Load the client certificate */
- mbedtls_x509_crt_init(&connssl->clicert);
+ mbedtls_x509_crt_init(&BACKEND->clicert);
if(ssl_cert) {
- ret = mbedtls_x509_crt_parse_file(&connssl->clicert, ssl_cert);
+ ret = mbedtls_x509_crt_parse_file(&BACKEND->clicert, ssl_cert);
if(ret) {
#ifdef MBEDTLS_ERROR_C
@@ -325,12 +338,13 @@ mbed_connect_step1(struct connectdata *conn,
}
/* Load the client private key */
- mbedtls_pk_init(&connssl->pk);
+ mbedtls_pk_init(&BACKEND->pk);
if(SSL_SET_OPTION(key)) {
- ret = mbedtls_pk_parse_keyfile(&connssl->pk, SSL_SET_OPTION(key),
+ ret = mbedtls_pk_parse_keyfile(&BACKEND->pk, SSL_SET_OPTION(key),
SSL_SET_OPTION(key_passwd));
- if(ret == 0 && !mbedtls_pk_can_do(&connssl->pk, MBEDTLS_PK_RSA))
+ if(ret == 0 && !(mbedtls_pk_can_do(&BACKEND->pk, MBEDTLS_PK_RSA) ||
+ mbedtls_pk_can_do(&BACKEND->pk, MBEDTLS_PK_ECKEY)))
ret = MBEDTLS_ERR_PK_TYPE_MISMATCH;
if(ret) {
@@ -345,10 +359,10 @@ mbed_connect_step1(struct connectdata *conn,
}
/* Load the CRL */
- mbedtls_x509_crl_init(&connssl->crl);
+ mbedtls_x509_crl_init(&BACKEND->crl);
if(ssl_crlfile) {
- ret = mbedtls_x509_crl_parse_file(&connssl->crl, ssl_crlfile);
+ ret = mbedtls_x509_crl_parse_file(&BACKEND->crl, ssl_crlfile);
if(ret) {
#ifdef MBEDTLS_ERROR_C
@@ -361,16 +375,16 @@ mbed_connect_step1(struct connectdata *conn,
}
}
- infof(data, "mbedTLS: Connecting to %s:%d\n", hostname, port);
+ infof(data, "mbedTLS: Connecting to %s:%ld\n", hostname, port);
- mbedtls_ssl_config_init(&connssl->config);
+ mbedtls_ssl_config_init(&BACKEND->config);
- mbedtls_ssl_init(&connssl->ssl);
- if(mbedtls_ssl_setup(&connssl->ssl, &connssl->config)) {
+ mbedtls_ssl_init(&BACKEND->ssl);
+ if(mbedtls_ssl_setup(&BACKEND->ssl, &BACKEND->config)) {
failf(data, "mbedTLS: ssl_init failed");
return CURLE_SSL_CONNECT_ERROR;
}
- ret = mbedtls_ssl_config_defaults(&connssl->config,
+ ret = mbedtls_ssl_config_defaults(&BACKEND->config,
MBEDTLS_SSL_IS_CLIENT,
MBEDTLS_SSL_TRANSPORT_STREAM,
MBEDTLS_SSL_PRESET_DEFAULT);
@@ -380,20 +394,20 @@ mbed_connect_step1(struct connectdata *conn,
}
/* new profile with RSA min key len = 1024 ... */
- mbedtls_ssl_conf_cert_profile(&connssl->config,
+ mbedtls_ssl_conf_cert_profile(&BACKEND->config,
&mbedtls_x509_crt_profile_fr);
switch(SSL_CONN_CONFIG(version)) {
case CURL_SSLVERSION_DEFAULT:
case CURL_SSLVERSION_TLSv1:
- mbedtls_ssl_conf_min_version(&connssl->config, MBEDTLS_SSL_MAJOR_VERSION_3,
+ mbedtls_ssl_conf_min_version(&BACKEND->config, MBEDTLS_SSL_MAJOR_VERSION_3,
MBEDTLS_SSL_MINOR_VERSION_1);
infof(data, "mbedTLS: Set min SSL version to TLS 1.0\n");
break;
case CURL_SSLVERSION_SSLv3:
- mbedtls_ssl_conf_min_version(&connssl->config, MBEDTLS_SSL_MAJOR_VERSION_3,
+ mbedtls_ssl_conf_min_version(&BACKEND->config, MBEDTLS_SSL_MAJOR_VERSION_3,
MBEDTLS_SSL_MINOR_VERSION_0);
- mbedtls_ssl_conf_max_version(&connssl->config, MBEDTLS_SSL_MAJOR_VERSION_3,
+ mbedtls_ssl_conf_max_version(&BACKEND->config, MBEDTLS_SSL_MAJOR_VERSION_3,
MBEDTLS_SSL_MINOR_VERSION_0);
infof(data, "mbedTLS: Set SSL version to SSLv3\n");
break;
@@ -412,25 +426,25 @@ mbed_connect_step1(struct connectdata *conn,
return CURLE_SSL_CONNECT_ERROR;
}
- mbedtls_ssl_conf_authmode(&connssl->config, MBEDTLS_SSL_VERIFY_OPTIONAL);
+ mbedtls_ssl_conf_authmode(&BACKEND->config, MBEDTLS_SSL_VERIFY_OPTIONAL);
- mbedtls_ssl_conf_rng(&connssl->config, mbedtls_ctr_drbg_random,
- &connssl->ctr_drbg);
- mbedtls_ssl_set_bio(&connssl->ssl, &conn->sock[sockindex],
+ mbedtls_ssl_conf_rng(&BACKEND->config, mbedtls_ctr_drbg_random,
+ &BACKEND->ctr_drbg);
+ mbedtls_ssl_set_bio(&BACKEND->ssl, &conn->sock[sockindex],
mbedtls_net_send,
mbedtls_net_recv,
NULL /* rev_timeout() */);
- mbedtls_ssl_conf_ciphersuites(&connssl->config,
+ mbedtls_ssl_conf_ciphersuites(&BACKEND->config,
mbedtls_ssl_list_ciphersuites());
#if defined(MBEDTLS_SSL_RENEGOTIATION)
- mbedtls_ssl_conf_renegotiation(&connssl->config,
+ mbedtls_ssl_conf_renegotiation(&BACKEND->config,
MBEDTLS_SSL_RENEGOTIATION_ENABLED);
#endif
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
- mbedtls_ssl_conf_session_tickets(&connssl->config,
+ mbedtls_ssl_conf_session_tickets(&BACKEND->config,
MBEDTLS_SSL_SESSION_TICKETS_DISABLED);
#endif
@@ -440,7 +454,7 @@ mbed_connect_step1(struct connectdata *conn,
Curl_ssl_sessionid_lock(conn);
if(!Curl_ssl_getsessionid(conn, &old_session, NULL, sockindex)) {
- ret = mbedtls_ssl_set_session(&connssl->ssl, old_session);
+ ret = mbedtls_ssl_set_session(&BACKEND->ssl, old_session);
if(ret) {
Curl_ssl_sessionid_unlock(conn);
failf(data, "mbedtls_ssl_set_session returned -0x%x", -ret);
@@ -451,15 +465,15 @@ mbed_connect_step1(struct connectdata *conn,
Curl_ssl_sessionid_unlock(conn);
}
- mbedtls_ssl_conf_ca_chain(&connssl->config,
- &connssl->cacert,
- &connssl->crl);
+ mbedtls_ssl_conf_ca_chain(&BACKEND->config,
+ &BACKEND->cacert,
+ &BACKEND->crl);
if(SSL_SET_OPTION(key)) {
- mbedtls_ssl_conf_own_cert(&connssl->config,
- &connssl->clicert, &connssl->pk);
+ mbedtls_ssl_conf_own_cert(&BACKEND->config,
+ &BACKEND->clicert, &BACKEND->pk);
}
- if(mbedtls_ssl_set_hostname(&connssl->ssl, hostname)) {
+ if(mbedtls_ssl_set_hostname(&BACKEND->ssl, hostname)) {
/* mbedtls_ssl_set_hostname() sets the name to use in CN/SAN checks *and*
the name to set in the SNI extension. So even if curl connects to a
host specified as an IP address, this function must be used. */
@@ -469,7 +483,7 @@ mbed_connect_step1(struct connectdata *conn,
#ifdef HAS_ALPN
if(conn->bits.tls_enable_alpn) {
- const char **p = &connssl->protocols[0];
+ const char **p = &BACKEND->protocols[0];
#ifdef USE_NGHTTP2
if(data->set.httpversion >= CURL_HTTP_VERSION_2)
*p++ = NGHTTP2_PROTO_VERSION_ID;
@@ -478,19 +492,19 @@ mbed_connect_step1(struct connectdata *conn,
*p = NULL;
/* this function doesn't clone the protocols array, which is why we need
to keep it around */
- if(mbedtls_ssl_conf_alpn_protocols(&connssl->config,
- &connssl->protocols[0])) {
+ if(mbedtls_ssl_conf_alpn_protocols(&BACKEND->config,
+ &BACKEND->protocols[0])) {
failf(data, "Failed setting ALPN protocols");
return CURLE_SSL_CONNECT_ERROR;
}
- for(p = &connssl->protocols[0]; *p; ++p)
+ for(p = &BACKEND->protocols[0]; *p; ++p)
infof(data, "ALPN, offering %s\n", *p);
}
#endif
#ifdef MBEDTLS_DEBUG
/* In order to make that work in mbedtls MBEDTLS_DEBUG_C must be defined. */
- mbedtls_ssl_conf_dbg(&connssl->config, mbed_debug, data);
+ mbedtls_ssl_conf_dbg(&BACKEND->config, mbed_debug, data);
/* - 0 No debug
* - 1 Error
* - 2 State change
@@ -502,7 +516,7 @@ mbed_connect_step1(struct connectdata *conn,
/* give application a chance to interfere with mbedTLS set up. */
if(data->set.ssl.fsslctx) {
- ret = (*data->set.ssl.fsslctx)(data, &connssl->config,
+ ret = (*data->set.ssl.fsslctx)(data, &BACKEND->config,
data->set.ssl.fsslctxp);
if(ret) {
failf(data, "error signaled by ssl ctx callback");
@@ -527,17 +541,10 @@ mbed_connect_step2(struct connectdata *conn,
data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
-#ifdef HAS_ALPN
- const char *next_protocol;
-#endif
-
- char errorbuf[128];
- errorbuf[0] = 0;
-
conn->recv[sockindex] = mbed_recv;
conn->send[sockindex] = mbed_send;
- ret = mbedtls_ssl_handshake(&connssl->ssl);
+ ret = mbedtls_ssl_handshake(&BACKEND->ssl);
if(ret == MBEDTLS_ERR_SSL_WANT_READ) {
connssl->connecting_state = ssl_connect_2_reading;
@@ -548,6 +555,8 @@ mbed_connect_step2(struct connectdata *conn,
return CURLE_OK;
}
else if(ret) {
+ char errorbuf[128];
+ errorbuf[0] = 0;
#ifdef MBEDTLS_ERROR_C
mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
#endif /* MBEDTLS_ERROR_C */
@@ -557,30 +566,32 @@ mbed_connect_step2(struct connectdata *conn,
}
infof(data, "mbedTLS: Handshake complete, cipher is %s\n",
- mbedtls_ssl_get_ciphersuite(&conn->ssl[sockindex].ssl)
+ mbedtls_ssl_get_ciphersuite(&BACKEND->ssl)
);
- ret = mbedtls_ssl_get_verify_result(&conn->ssl[sockindex].ssl);
+ ret = mbedtls_ssl_get_verify_result(&BACKEND->ssl);
+
+ if(!SSL_CONN_CONFIG(verifyhost))
+ /* Ignore hostname errors if verifyhost is disabled */
+ ret &= ~MBEDTLS_X509_BADCERT_CN_MISMATCH;
if(ret && SSL_CONN_CONFIG(verifypeer)) {
if(ret & MBEDTLS_X509_BADCERT_EXPIRED)
failf(data, "Cert verify failed: BADCERT_EXPIRED");
- if(ret & MBEDTLS_X509_BADCERT_REVOKED) {
+ else if(ret & MBEDTLS_X509_BADCERT_REVOKED)
failf(data, "Cert verify failed: BADCERT_REVOKED");
- return CURLE_SSL_CACERT;
- }
- if(ret & MBEDTLS_X509_BADCERT_CN_MISMATCH)
+ else if(ret & MBEDTLS_X509_BADCERT_CN_MISMATCH)
failf(data, "Cert verify failed: BADCERT_CN_MISMATCH");
- if(ret & MBEDTLS_X509_BADCERT_NOT_TRUSTED)
+ else if(ret & MBEDTLS_X509_BADCERT_NOT_TRUSTED)
failf(data, "Cert verify failed: BADCERT_NOT_TRUSTED");
return CURLE_PEER_FAILED_VERIFICATION;
}
- peercert = mbedtls_ssl_get_peer_cert(&connssl->ssl);
+ peercert = mbedtls_ssl_get_peer_cert(&BACKEND->ssl);
if(peercert && data->set.verbose) {
const size_t bufsize = 16384;
@@ -650,7 +661,7 @@ mbed_connect_step2(struct connectdata *conn,
#ifdef HAS_ALPN
if(conn->bits.tls_enable_alpn) {
- next_protocol = mbedtls_ssl_get_alpn_protocol(&connssl->ssl);
+ const char *next_protocol = mbedtls_ssl_get_alpn_protocol(&BACKEND->ssl);
if(next_protocol) {
infof(data, "ALPN, server accepted to use %s\n", next_protocol);
@@ -670,6 +681,8 @@ mbed_connect_step2(struct connectdata *conn,
else {
infof(data, "ALPN, server did not agree to a protocol\n");
}
+ Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ?
+ BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE);
}
#endif
@@ -700,8 +713,10 @@ mbed_connect_step3(struct connectdata *conn,
mbedtls_ssl_session_init(our_ssl_sessionid);
- ret = mbedtls_ssl_get_session(&connssl->ssl, our_ssl_sessionid);
+ ret = mbedtls_ssl_get_session(&BACKEND->ssl, our_ssl_sessionid);
if(ret) {
+ if(ret != MBEDTLS_ERR_SSL_ALLOC_FAILED)
+ mbedtls_ssl_session_free(our_ssl_sessionid);
free(our_ssl_sessionid);
failf(data, "mbedtls_ssl_get_session returned -0x%x", -ret);
return CURLE_SSL_CONNECT_ERROR;
@@ -715,6 +730,7 @@ mbed_connect_step3(struct connectdata *conn,
retcode = Curl_ssl_addsessionid(conn, our_ssl_sessionid, 0, sockindex);
Curl_ssl_sessionid_unlock(conn);
if(retcode) {
+ mbedtls_ssl_session_free(our_ssl_sessionid);
free(our_ssl_sessionid);
failf(data, "failed to store ssl session");
return retcode;
@@ -730,9 +746,10 @@ static ssize_t mbed_send(struct connectdata *conn, int sockindex,
const void *mem, size_t len,
CURLcode *curlcode)
{
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
int ret = -1;
- ret = mbedtls_ssl_write(&conn->ssl[sockindex].ssl,
+ ret = mbedtls_ssl_write(&BACKEND->ssl,
(unsigned char *)mem, len);
if(ret < 0) {
@@ -744,22 +761,23 @@ static ssize_t mbed_send(struct connectdata *conn, int sockindex,
return ret;
}
-void Curl_mbedtls_close_all(struct Curl_easy *data)
+static void Curl_mbedtls_close_all(struct Curl_easy *data)
{
(void)data;
}
-void Curl_mbedtls_close(struct connectdata *conn, int sockindex)
+static void Curl_mbedtls_close(struct connectdata *conn, int sockindex)
{
- mbedtls_pk_free(&conn->ssl[sockindex].pk);
- mbedtls_x509_crt_free(&conn->ssl[sockindex].clicert);
- mbedtls_x509_crt_free(&conn->ssl[sockindex].cacert);
- mbedtls_x509_crl_free(&conn->ssl[sockindex].crl);
- mbedtls_ssl_config_free(&conn->ssl[sockindex].config);
- mbedtls_ssl_free(&conn->ssl[sockindex].ssl);
- mbedtls_ctr_drbg_free(&conn->ssl[sockindex].ctr_drbg);
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ mbedtls_pk_free(&BACKEND->pk);
+ mbedtls_x509_crt_free(&BACKEND->clicert);
+ mbedtls_x509_crt_free(&BACKEND->cacert);
+ mbedtls_x509_crl_free(&BACKEND->crl);
+ mbedtls_ssl_config_free(&BACKEND->config);
+ mbedtls_ssl_free(&BACKEND->ssl);
+ mbedtls_ctr_drbg_free(&BACKEND->ctr_drbg);
#ifndef THREADING_SUPPORT
- mbedtls_entropy_free(&conn->ssl[sockindex].entropy);
+ mbedtls_entropy_free(&BACKEND->entropy);
#endif /* THREADING_SUPPORT */
}
@@ -767,11 +785,12 @@ static ssize_t mbed_recv(struct connectdata *conn, int num,
char *buf, size_t buffersize,
CURLcode *curlcode)
{
+ struct ssl_connect_data *connssl = &conn->ssl[num];
int ret = -1;
ssize_t len = -1;
memset(buf, 0, buffersize);
- ret = mbedtls_ssl_read(&conn->ssl[num].ssl, (unsigned char *)buf,
+ ret = mbedtls_ssl_read(&BACKEND->ssl, (unsigned char *)buf,
buffersize);
if(ret <= 0) {
@@ -788,21 +807,26 @@ static ssize_t mbed_recv(struct connectdata *conn, int num,
return len;
}
-void Curl_mbedtls_session_free(void *ptr)
+static void Curl_mbedtls_session_free(void *ptr)
{
mbedtls_ssl_session_free(ptr);
free(ptr);
}
-size_t Curl_mbedtls_version(char *buffer, size_t size)
+static size_t Curl_mbedtls_version(char *buffer, size_t size)
{
+#ifdef MBEDTLS_VERSION_C
+ /* if mbedtls_version_get_number() is available it is better */
unsigned int version = mbedtls_version_get_number();
- return snprintf(buffer, size, "mbedTLS/%d.%d.%d", version>>24,
- (version>>16)&0xff, (version>>8)&0xff);
+ return msnprintf(buffer, size, "mbedTLS/%u.%u.%u", version>>24,
+ (version>>16)&0xff, (version>>8)&0xff);
+#else
+ return msnprintf(buffer, size, "mbedTLS/%s", MBEDTLS_VERSION_STRING);
+#endif
}
-CURLcode Curl_mbedtls_random(struct Curl_easy *data, unsigned char *entropy,
- size_t length)
+static CURLcode Curl_mbedtls_random(struct Curl_easy *data,
+ unsigned char *entropy, size_t length)
{
#if defined(MBEDTLS_CTR_DRBG_C)
int ret = -1;
@@ -811,7 +835,7 @@ CURLcode Curl_mbedtls_random(struct Curl_easy *data, unsigned char *entropy,
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_entropy_init(&ctr_entropy);
mbedtls_ctr_drbg_init(&ctr_drbg);
- errorbuf[0]=0;
+ errorbuf[0] = 0;
ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func,
&ctr_entropy, NULL, 0);
@@ -869,7 +893,7 @@ mbed_connect_common(struct connectdata *conn,
return CURLE_OK;
}
- if(ssl_connect_1==connssl->connecting_state) {
+ if(ssl_connect_1 == connssl->connecting_state) {
/* Find out how much more time we're allowed */
timeout_ms = Curl_timeleft(data, NULL, TRUE);
@@ -900,9 +924,9 @@ mbed_connect_common(struct connectdata *conn,
if(connssl->connecting_state == ssl_connect_2_reading
|| connssl->connecting_state == ssl_connect_2_writing) {
- curl_socket_t writefd = ssl_connect_2_writing==
+ curl_socket_t writefd = ssl_connect_2_writing ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
- curl_socket_t readfd = ssl_connect_2_reading==
+ curl_socket_t readfd = ssl_connect_2_reading ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
@@ -942,13 +966,13 @@ mbed_connect_common(struct connectdata *conn,
} /* repeat step2 until all transactions are done. */
- if(ssl_connect_3==connssl->connecting_state) {
+ if(ssl_connect_3 == connssl->connecting_state) {
retcode = mbed_connect_step3(conn, sockindex);
if(retcode)
return retcode;
}
- if(ssl_connect_done==connssl->connecting_state) {
+ if(ssl_connect_done == connssl->connecting_state) {
connssl->state = ssl_connection_complete;
conn->recv[sockindex] = mbed_recv;
conn->send[sockindex] = mbed_send;
@@ -963,18 +987,14 @@ mbed_connect_common(struct connectdata *conn,
return CURLE_OK;
}
-CURLcode
-Curl_mbedtls_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done)
+static CURLcode Curl_mbedtls_connect_nonblocking(struct connectdata *conn,
+ int sockindex, bool *done)
{
return mbed_connect_common(conn, sockindex, TRUE, done);
}
-CURLcode
-Curl_mbedtls_connect(struct connectdata *conn,
- int sockindex)
+static CURLcode Curl_mbedtls_connect(struct connectdata *conn, int sockindex)
{
CURLcode retcode;
bool done = FALSE;
@@ -992,19 +1012,75 @@ Curl_mbedtls_connect(struct connectdata *conn,
* return 0 error initializing SSL
* return 1 SSL initialized successfully
*/
-int Curl_mbedtls_init(void)
+static int Curl_mbedtls_init(void)
{
return Curl_polarsslthreadlock_thread_setup();
}
-void Curl_mbedtls_cleanup(void)
+static void Curl_mbedtls_cleanup(void)
{
(void)Curl_polarsslthreadlock_thread_cleanup();
}
-int Curl_mbedtls_data_pending(const struct connectdata *conn, int sockindex)
+static bool Curl_mbedtls_data_pending(const struct connectdata *conn,
+ int sockindex)
{
- return mbedtls_ssl_get_bytes_avail(&conn->ssl[sockindex].ssl) != 0;
+ const struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ return mbedtls_ssl_get_bytes_avail(&BACKEND->ssl) != 0;
}
+static CURLcode Curl_mbedtls_sha256sum(const unsigned char *input,
+ size_t inputlen,
+ unsigned char *sha256sum,
+ size_t sha256len UNUSED_PARAM)
+{
+ (void)sha256len;
+#if MBEDTLS_VERSION_NUMBER < 0x02070000
+ mbedtls_sha256(input, inputlen, sha256sum, 0);
+#else
+ /* returns 0 on success, otherwise failure */
+ if(mbedtls_sha256_ret(input, inputlen, sha256sum, 0) != 0)
+ return CURLE_BAD_FUNCTION_ARGUMENT;
+#endif
+ return CURLE_OK;
+}
+
+static void *Curl_mbedtls_get_internals(struct ssl_connect_data *connssl,
+ CURLINFO info UNUSED_PARAM)
+{
+ (void)info;
+ return &BACKEND->ssl;
+}
+
+const struct Curl_ssl Curl_ssl_mbedtls = {
+ { CURLSSLBACKEND_MBEDTLS, "mbedtls" }, /* info */
+
+ SSLSUPP_CA_PATH |
+ SSLSUPP_PINNEDPUBKEY |
+ SSLSUPP_SSL_CTX,
+
+ sizeof(struct ssl_backend_data),
+
+ Curl_mbedtls_init, /* init */
+ Curl_mbedtls_cleanup, /* cleanup */
+ Curl_mbedtls_version, /* version */
+ Curl_none_check_cxn, /* check_cxn */
+ Curl_none_shutdown, /* shutdown */
+ Curl_mbedtls_data_pending, /* data_pending */
+ Curl_mbedtls_random, /* random */
+ Curl_none_cert_status_request, /* cert_status_request */
+ Curl_mbedtls_connect, /* connect */
+ Curl_mbedtls_connect_nonblocking, /* connect_nonblocking */
+ Curl_mbedtls_get_internals, /* get_internals */
+ Curl_mbedtls_close, /* close_one */
+ Curl_mbedtls_close_all, /* close_all */
+ Curl_mbedtls_session_free, /* session_free */
+ Curl_none_set_engine, /* set_engine */
+ Curl_none_set_engine_default, /* set_engine_default */
+ Curl_none_engines_list, /* engines_list */
+ Curl_none_false_start, /* false_start */
+ Curl_none_md5sum, /* md5sum */
+ Curl_mbedtls_sha256sum /* sha256sum */
+};
+
#endif /* USE_MBEDTLS */
diff --git a/Utilities/cmcurl/lib/vtls/mbedtls.h b/Utilities/cmcurl/lib/vtls/mbedtls.h
index 71d17a491..4a938605b 100644
--- a/Utilities/cmcurl/lib/vtls/mbedtls.h
+++ b/Utilities/cmcurl/lib/vtls/mbedtls.h
@@ -26,57 +26,7 @@
#ifdef USE_MBEDTLS
-#include <mbedtls/sha256.h>
-
-/* Called on first use mbedTLS, setup threading if supported */
-int Curl_mbedtls_init(void);
-void Curl_mbedtls_cleanup(void);
-int Curl_mbedtls_data_pending(const struct connectdata *conn, int sockindex);
-
-CURLcode Curl_mbedtls_connect(struct connectdata *conn, int sockindex);
-
-CURLcode Curl_mbedtls_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done);
-
-/* tell mbedTLS to close down all open information regarding connections (and
- thus session ID caching etc) */
-void Curl_mbedtls_close_all(struct Curl_easy *data);
-
- /* close a SSL connection */
-void Curl_mbedtls_close(struct connectdata *conn, int sockindex);
-
-void Curl_mbedtls_session_free(void *ptr);
-size_t Curl_mbedtls_version(char *buffer, size_t size);
-int Curl_mbedtls_shutdown(struct connectdata *conn, int sockindex);
-
-CURLcode Curl_mbedtls_random(struct Curl_easy *data, unsigned char *entropy,
- size_t length);
-
-/* this backends supports CURLOPT_PINNEDPUBLICKEY */
-#define have_curlssl_pinnedpubkey 1
-
-/* this backend supports CURLOPT_SSL_CTX_* */
-#define have_curlssl_ssl_ctx 1
-
-/* API setup for mbedTLS */
-#define curlssl_init() Curl_mbedtls_init()
-#define curlssl_cleanup() Curl_mbedtls_cleanup()
-#define curlssl_connect Curl_mbedtls_connect
-#define curlssl_connect_nonblocking Curl_mbedtls_connect_nonblocking
-#define curlssl_session_free(x) Curl_mbedtls_session_free(x)
-#define curlssl_close_all Curl_mbedtls_close_all
-#define curlssl_close Curl_mbedtls_close
-#define curlssl_shutdown(x,y) 0
-#define curlssl_set_engine(x,y) (x=x, y=y, CURLE_NOT_BUILT_IN)
-#define curlssl_set_engine_default(x) (x=x, CURLE_NOT_BUILT_IN)
-#define curlssl_engines_list(x) (x=x, (struct curl_slist *)NULL)
-#define curlssl_version Curl_mbedtls_version
-#define curlssl_check_cxn(x) (x=x, -1)
-#define curlssl_data_pending(x,y) Curl_mbedtls_data_pending(x, y)
-#define CURL_SSL_BACKEND CURLSSLBACKEND_MBEDTLS
-#define curlssl_sha256sum(a,b,c,d) mbedtls_sha256(a,b,c,0)
-#define curlssl_random(x,y,z) Curl_mbedtls_random(x, y, z)
+extern const struct Curl_ssl Curl_ssl_mbedtls;
#endif /* USE_MBEDTLS */
#endif /* HEADER_CURL_MBEDTLS_H */
diff --git a/Utilities/cmcurl/lib/vtls/mesalink.c b/Utilities/cmcurl/lib/vtls/mesalink.c
new file mode 100644
index 000000000..718c282ee
--- /dev/null
+++ b/Utilities/cmcurl/lib/vtls/mesalink.c
@@ -0,0 +1,627 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2017 - 2018, Yiming Jing, <jingyiming@baidu.com>
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+/*
+ * Source file for all MesaLink-specific code for the TLS/SSL layer. No code
+ * but vtls.c should ever call or use these functions.
+ *
+ */
+
+/*
+ * Based upon the CyaSSL implementation in cyassl.c and cyassl.h:
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * Thanks for code and inspiration!
+ */
+
+#include "curl_setup.h"
+
+#ifdef USE_MESALINK
+
+#include <mesalink/options.h>
+#include <mesalink/version.h>
+
+#include "urldata.h"
+#include "sendf.h"
+#include "inet_pton.h"
+#include "vtls.h"
+#include "parsedate.h"
+#include "connect.h" /* for the connect timeout */
+#include "select.h"
+#include "strcase.h"
+#include "x509asn1.h"
+#include "curl_printf.h"
+
+#include "mesalink.h"
+#include <mesalink/openssl/ssl.h>
+#include <mesalink/openssl/err.h>
+
+/* The last #include files should be: */
+#include "curl_memory.h"
+#include "memdebug.h"
+
+#define MESALINK_MAX_ERROR_SZ 80
+
+struct ssl_backend_data
+{
+ SSL_CTX *ctx;
+ SSL *handle;
+};
+
+#define BACKEND connssl->backend
+
+static Curl_recv mesalink_recv;
+static Curl_send mesalink_send;
+
+/*
+ * This function loads all the client/CA certificates and CRLs. Setup the TLS
+ * layer and do all necessary magic.
+ */
+static CURLcode
+mesalink_connect_step1(struct connectdata *conn, int sockindex)
+{
+ char *ciphers;
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ const bool verifypeer = SSL_CONN_CONFIG(verifypeer);
+ const char *const ssl_cafile = SSL_CONN_CONFIG(CAfile);
+ const char *const ssl_capath = SSL_CONN_CONFIG(CApath);
+ struct in_addr addr4;
+#ifdef ENABLE_IPV6
+ struct in6_addr addr6;
+#endif
+ const char *const hostname =
+ SSL_IS_PROXY() ? conn->http_proxy.host.name : conn->host.name;
+ size_t hostname_len = strlen(hostname);
+
+ SSL_METHOD *req_method = NULL;
+ curl_socket_t sockfd = conn->sock[sockindex];
+
+ if(connssl->state == ssl_connection_complete)
+ return CURLE_OK;
+
+ if(SSL_CONN_CONFIG(version_max) != CURL_SSLVERSION_MAX_NONE) {
+ failf(data, "MesaLink does not support to set maximum SSL/TLS version");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+
+ switch(SSL_CONN_CONFIG(version)) {
+ case CURL_SSLVERSION_SSLv3:
+ case CURL_SSLVERSION_TLSv1:
+ case CURL_SSLVERSION_TLSv1_0:
+ case CURL_SSLVERSION_TLSv1_1:
+ failf(data, "MesaLink does not support SSL 3.0, TLS 1.0, or TLS 1.1");
+ return CURLE_NOT_BUILT_IN;
+ case CURL_SSLVERSION_DEFAULT:
+ case CURL_SSLVERSION_TLSv1_2:
+ req_method = TLSv1_2_client_method();
+ break;
+ case CURL_SSLVERSION_TLSv1_3:
+ req_method = TLSv1_3_client_method();
+ break;
+ case CURL_SSLVERSION_SSLv2:
+ failf(data, "MesaLink does not support SSLv2");
+ return CURLE_SSL_CONNECT_ERROR;
+ default:
+ failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+
+ if(!req_method) {
+ failf(data, "SSL: couldn't create a method!");
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ if(BACKEND->ctx)
+ SSL_CTX_free(BACKEND->ctx);
+ BACKEND->ctx = SSL_CTX_new(req_method);
+
+ if(!BACKEND->ctx) {
+ failf(data, "SSL: couldn't create a context!");
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ SSL_CTX_set_verify(
+ BACKEND->ctx, verifypeer ? SSL_VERIFY_PEER : SSL_VERIFY_NONE, NULL);
+
+ if(ssl_cafile || ssl_capath) {
+ if(!SSL_CTX_load_verify_locations(BACKEND->ctx, ssl_cafile, ssl_capath)) {
+ if(verifypeer) {
+ failf(data,
+ "error setting certificate verify locations:\n"
+ " CAfile: %s\n CApath: %s",
+ ssl_cafile ? ssl_cafile : "none",
+ ssl_capath ? ssl_capath : "none");
+ return CURLE_SSL_CACERT_BADFILE;
+ }
+ infof(data,
+ "error setting certificate verify locations,"
+ " continuing anyway:\n");
+ }
+ else {
+ infof(data, "successfully set certificate verify locations:\n");
+ }
+ infof(data,
+ " CAfile: %s\n"
+ " CApath: %s\n",
+ ssl_cafile ? ssl_cafile : "none",
+ ssl_capath ? ssl_capath : "none");
+ }
+
+ ciphers = SSL_CONN_CONFIG(cipher_list);
+ if(ciphers) {
+#ifdef MESALINK_HAVE_CIPHER
+ if(!SSL_CTX_set_cipher_list(BACKEND->ctx, ciphers)) {
+ failf(data, "failed setting cipher list: %s", ciphers);
+ return CURLE_SSL_CIPHER;
+ }
+#endif
+ infof(data, "Cipher selection: %s\n", ciphers);
+ }
+
+ if(BACKEND->handle)
+ SSL_free(BACKEND->handle);
+ BACKEND->handle = SSL_new(BACKEND->ctx);
+ if(!BACKEND->handle) {
+ failf(data, "SSL: couldn't create a context (handle)!");
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ if((hostname_len < USHRT_MAX) &&
+ (0 == Curl_inet_pton(AF_INET, hostname, &addr4))
+#ifdef ENABLE_IPV6
+ && (0 == Curl_inet_pton(AF_INET6, hostname, &addr6))
+#endif
+ ) {
+ /* hostname is not a valid IP address */
+ if(SSL_set_tlsext_host_name(BACKEND->handle, hostname) != SSL_SUCCESS) {
+ failf(data,
+ "WARNING: failed to configure server name indication (SNI) "
+ "TLS extension\n");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ }
+ else {
+#ifdef CURLDEBUG
+ /* Check if the hostname is 127.0.0.1 or [::1];
+ * otherwise reject because MesaLink always wants a valid DNS Name
+ * specified in RFC 5280 Section 7.2 */
+ if(strncmp(hostname, "127.0.0.1", 9) == 0
+#ifdef ENABLE_IPV6
+ || strncmp(hostname, "[::1]", 5) == 0
+#endif
+ ) {
+ SSL_set_tlsext_host_name(BACKEND->handle, "localhost");
+ }
+ else
+#endif
+ {
+ failf(data,
+ "ERROR: MesaLink does not accept an IP address as a hostname\n");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ }
+
+#ifdef MESALINK_HAVE_SESSION
+ if(SSL_SET_OPTION(primary.sessionid)) {
+ void *ssl_sessionid = NULL;
+
+ Curl_ssl_sessionid_lock(conn);
+ if(!Curl_ssl_getsessionid(conn, &ssl_sessionid, NULL, sockindex)) {
+ /* we got a session id, use it! */
+ if(!SSL_set_session(BACKEND->handle, ssl_sessionid)) {
+ Curl_ssl_sessionid_unlock(conn);
+ failf(
+ data,
+ "SSL: SSL_set_session failed: %s",
+ ERR_error_string(SSL_get_error(BACKEND->handle, 0), error_buffer));
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ /* Informational message */
+ infof(data, "SSL re-using session ID\n");
+ }
+ Curl_ssl_sessionid_unlock(conn);
+ }
+#endif /* MESALINK_HAVE_SESSION */
+
+ if(SSL_set_fd(BACKEND->handle, (int)sockfd) != SSL_SUCCESS) {
+ failf(data, "SSL: SSL_set_fd failed");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+
+ connssl->connecting_state = ssl_connect_2;
+ return CURLE_OK;
+}
+
+static CURLcode
+mesalink_connect_step2(struct connectdata *conn, int sockindex)
+{
+ int ret = -1;
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+
+ conn->recv[sockindex] = mesalink_recv;
+ conn->send[sockindex] = mesalink_send;
+
+ ret = SSL_connect(BACKEND->handle);
+ if(ret != SSL_SUCCESS) {
+ char error_buffer[MESALINK_MAX_ERROR_SZ];
+ int detail = SSL_get_error(BACKEND->handle, ret);
+
+ if(SSL_ERROR_WANT_CONNECT == detail || SSL_ERROR_WANT_READ == detail) {
+ connssl->connecting_state = ssl_connect_2_reading;
+ return CURLE_OK;
+ }
+ else {
+ failf(data,
+ "SSL_connect failed with error %d: %s",
+ detail,
+ ERR_error_string_n(detail, error_buffer, sizeof(error_buffer)));
+ ERR_print_errors_fp(stderr);
+ if(detail && SSL_CONN_CONFIG(verifypeer)) {
+ detail &= ~0xFF;
+ if(detail == TLS_ERROR_WEBPKI_ERRORS) {
+ failf(data, "Cert verify failed");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ }
+ }
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ }
+
+ connssl->connecting_state = ssl_connect_3;
+ infof(data,
+ "SSL connection using %s / %s\n",
+ SSL_get_version(BACKEND->handle),
+ SSL_get_cipher_name(BACKEND->handle));
+
+ return CURLE_OK;
+}
+
+static CURLcode
+mesalink_connect_step3(struct connectdata *conn, int sockindex)
+{
+ CURLcode result = CURLE_OK;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+
+ DEBUGASSERT(ssl_connect_3 == connssl->connecting_state);
+
+#ifdef MESALINK_HAVE_SESSION
+ if(SSL_SET_OPTION(primary.sessionid)) {
+ bool incache;
+ SSL_SESSION *our_ssl_sessionid;
+ void *old_ssl_sessionid = NULL;
+
+ our_ssl_sessionid = SSL_get_session(BACKEND->handle);
+
+ Curl_ssl_sessionid_lock(conn);
+ incache =
+ !(Curl_ssl_getsessionid(conn, &old_ssl_sessionid, NULL, sockindex));
+ if(incache) {
+ if(old_ssl_sessionid != our_ssl_sessionid) {
+ infof(data, "old SSL session ID is stale, removing\n");
+ Curl_ssl_delsessionid(conn, old_ssl_sessionid);
+ incache = FALSE;
+ }
+ }
+
+ if(!incache) {
+ result = Curl_ssl_addsessionid(
+ conn, our_ssl_sessionid, 0 /* unknown size */, sockindex);
+ if(result) {
+ Curl_ssl_sessionid_unlock(conn);
+ failf(data, "failed to store ssl session");
+ return result;
+ }
+ }
+ Curl_ssl_sessionid_unlock(conn);
+ }
+#endif /* MESALINK_HAVE_SESSION */
+
+ connssl->connecting_state = ssl_connect_done;
+
+ return result;
+}
+
+static ssize_t
+mesalink_send(struct connectdata *conn, int sockindex, const void *mem,
+ size_t len, CURLcode *curlcode)
+{
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ char error_buffer[MESALINK_MAX_ERROR_SZ];
+ int memlen = (len > (size_t)INT_MAX) ? INT_MAX : (int)len;
+ int rc = SSL_write(BACKEND->handle, mem, memlen);
+
+ if(rc < 0) {
+ int err = SSL_get_error(BACKEND->handle, rc);
+ switch(err) {
+ case SSL_ERROR_WANT_READ:
+ case SSL_ERROR_WANT_WRITE:
+ /* there's data pending, re-invoke SSL_write() */
+ *curlcode = CURLE_AGAIN;
+ return -1;
+ default:
+ failf(conn->data,
+ "SSL write: %s, errno %d",
+ ERR_error_string_n(err, error_buffer, sizeof(error_buffer)),
+ SOCKERRNO);
+ *curlcode = CURLE_SEND_ERROR;
+ return -1;
+ }
+ }
+ return rc;
+}
+
+static void
+Curl_mesalink_close(struct connectdata *conn, int sockindex)
+{
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+
+ if(BACKEND->handle) {
+ (void)SSL_shutdown(BACKEND->handle);
+ SSL_free(BACKEND->handle);
+ BACKEND->handle = NULL;
+ }
+ if(BACKEND->ctx) {
+ SSL_CTX_free(BACKEND->ctx);
+ BACKEND->ctx = NULL;
+ }
+}
+
+static ssize_t
+mesalink_recv(struct connectdata *conn, int num, char *buf, size_t buffersize,
+ CURLcode *curlcode)
+{
+ struct ssl_connect_data *connssl = &conn->ssl[num];
+ char error_buffer[MESALINK_MAX_ERROR_SZ];
+ int buffsize = (buffersize > (size_t)INT_MAX) ? INT_MAX : (int)buffersize;
+ int nread = SSL_read(BACKEND->handle, buf, buffsize);
+
+ if(nread <= 0) {
+ int err = SSL_get_error(BACKEND->handle, nread);
+
+ switch(err) {
+ case SSL_ERROR_ZERO_RETURN: /* no more data */
+ case IO_ERROR_CONNECTION_ABORTED:
+ break;
+ case SSL_ERROR_WANT_READ:
+ case SSL_ERROR_WANT_WRITE:
+ /* there's data pending, re-invoke SSL_read() */
+ *curlcode = CURLE_AGAIN;
+ return -1;
+ default:
+ failf(conn->data,
+ "SSL read: %s, errno %d",
+ ERR_error_string_n(err, error_buffer, sizeof(error_buffer)),
+ SOCKERRNO);
+ *curlcode = CURLE_RECV_ERROR;
+ return -1;
+ }
+ }
+ return nread;
+}
+
+static size_t
+Curl_mesalink_version(char *buffer, size_t size)
+{
+ return msnprintf(buffer, size, "MesaLink/%s", MESALINK_VERSION_STRING);
+}
+
+static int
+Curl_mesalink_init(void)
+{
+ return (SSL_library_init() == SSL_SUCCESS);
+}
+
+/*
+ * This function is called to shut down the SSL layer but keep the
+ * socket open (CCC - Clear Command Channel)
+ */
+static int
+Curl_mesalink_shutdown(struct connectdata *conn, int sockindex)
+{
+ int retval = 0;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+
+ if(BACKEND->handle) {
+ SSL_free(BACKEND->handle);
+ BACKEND->handle = NULL;
+ }
+ return retval;
+}
+
+static CURLcode
+mesalink_connect_common(struct connectdata *conn, int sockindex,
+ bool nonblocking, bool *done)
+{
+ CURLcode result;
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ curl_socket_t sockfd = conn->sock[sockindex];
+ time_t timeout_ms;
+ int what;
+
+ /* check if the connection has already been established */
+ if(ssl_connection_complete == connssl->state) {
+ *done = TRUE;
+ return CURLE_OK;
+ }
+
+ if(ssl_connect_1 == connssl->connecting_state) {
+ /* Find out how much more time we're allowed */
+ timeout_ms = Curl_timeleft(data, NULL, TRUE);
+
+ if(timeout_ms < 0) {
+ /* no need to continue if time already is up */
+ failf(data, "SSL connection timeout");
+ return CURLE_OPERATION_TIMEDOUT;
+ }
+
+ result = mesalink_connect_step1(conn, sockindex);
+ if(result)
+ return result;
+ }
+
+ while(ssl_connect_2 == connssl->connecting_state ||
+ ssl_connect_2_reading == connssl->connecting_state ||
+ ssl_connect_2_writing == connssl->connecting_state) {
+
+ /* check allowed time left */
+ timeout_ms = Curl_timeleft(data, NULL, TRUE);
+
+ if(timeout_ms < 0) {
+ /* no need to continue if time already is up */
+ failf(data, "SSL connection timeout");
+ return CURLE_OPERATION_TIMEDOUT;
+ }
+
+ /* if ssl is expecting something, check if it's available. */
+ if(connssl->connecting_state == ssl_connect_2_reading ||
+ connssl->connecting_state == ssl_connect_2_writing) {
+
+ curl_socket_t writefd =
+ ssl_connect_2_writing == connssl->connecting_state ? sockfd
+ : CURL_SOCKET_BAD;
+ curl_socket_t readfd = ssl_connect_2_reading == connssl->connecting_state
+ ? sockfd
+ : CURL_SOCKET_BAD;
+
+ what = Curl_socket_check(
+ readfd, CURL_SOCKET_BAD, writefd, nonblocking ? 0 : timeout_ms);
+ if(what < 0) {
+ /* fatal error */
+ failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ else if(0 == what) {
+ if(nonblocking) {
+ *done = FALSE;
+ return CURLE_OK;
+ }
+ else {
+ /* timeout */
+ failf(data, "SSL connection timeout");
+ return CURLE_OPERATION_TIMEDOUT;
+ }
+ }
+ /* socket is readable or writable */
+ }
+
+ /* Run transaction, and return to the caller if it failed or if
+ * this connection is part of a multi handle and this loop would
+ * execute again. This permits the owner of a multi handle to
+ * abort a connection attempt before step2 has completed while
+ * ensuring that a client using select() or epoll() will always
+ * have a valid fdset to wait on.
+ */
+ result = mesalink_connect_step2(conn, sockindex);
+
+ if(result ||
+ (nonblocking && (ssl_connect_2 == connssl->connecting_state ||
+ ssl_connect_2_reading == connssl->connecting_state ||
+ ssl_connect_2_writing == connssl->connecting_state))) {
+ return result;
+ }
+ } /* repeat step2 until all transactions are done. */
+
+ if(ssl_connect_3 == connssl->connecting_state) {
+ result = mesalink_connect_step3(conn, sockindex);
+ if(result)
+ return result;
+ }
+
+ if(ssl_connect_done == connssl->connecting_state) {
+ connssl->state = ssl_connection_complete;
+ conn->recv[sockindex] = mesalink_recv;
+ conn->send[sockindex] = mesalink_send;
+ *done = TRUE;
+ }
+ else
+ *done = FALSE;
+
+ /* Reset our connect state machine */
+ connssl->connecting_state = ssl_connect_1;
+
+ return CURLE_OK;
+}
+
+static CURLcode
+Curl_mesalink_connect_nonblocking(struct connectdata *conn, int sockindex,
+ bool *done)
+{
+ return mesalink_connect_common(conn, sockindex, TRUE, done);
+}
+
+static CURLcode
+Curl_mesalink_connect(struct connectdata *conn, int sockindex)
+{
+ CURLcode result;
+ bool done = FALSE;
+
+ result = mesalink_connect_common(conn, sockindex, FALSE, &done);
+ if(result)
+ return result;
+
+ DEBUGASSERT(done);
+
+ return CURLE_OK;
+}
+
+static void *
+Curl_mesalink_get_internals(struct ssl_connect_data *connssl,
+ CURLINFO info UNUSED_PARAM)
+{
+ (void)info;
+ return BACKEND->handle;
+}
+
+const struct Curl_ssl Curl_ssl_mesalink = {
+ { CURLSSLBACKEND_MESALINK, "MesaLink" }, /* info */
+
+ SSLSUPP_SSL_CTX,
+
+ sizeof(struct ssl_backend_data),
+
+ Curl_mesalink_init, /* init */
+ Curl_none_cleanup, /* cleanup */
+ Curl_mesalink_version, /* version */
+ Curl_none_check_cxn, /* check_cxn */
+ Curl_mesalink_shutdown, /* shutdown */
+ Curl_none_data_pending, /* data_pending */
+ Curl_none_random, /* random */
+ Curl_none_cert_status_request, /* cert_status_request */
+ Curl_mesalink_connect, /* connect */
+ Curl_mesalink_connect_nonblocking, /* connect_nonblocking */
+ Curl_mesalink_get_internals, /* get_internals */
+ Curl_mesalink_close, /* close_one */
+ Curl_none_close_all, /* close_all */
+ Curl_none_session_free, /* session_free */
+ Curl_none_set_engine, /* set_engine */
+ Curl_none_set_engine_default, /* set_engine_default */
+ Curl_none_engines_list, /* engines_list */
+ Curl_none_false_start, /* false_start */
+ Curl_none_md5sum, /* md5sum */
+ NULL /* sha256sum */
+};
+
+#endif
diff --git a/Utilities/cmcurl/lib/vtls/mesalink.h b/Utilities/cmcurl/lib/vtls/mesalink.h
new file mode 100644
index 000000000..54cb94ad3
--- /dev/null
+++ b/Utilities/cmcurl/lib/vtls/mesalink.h
@@ -0,0 +1,32 @@
+#ifndef HEADER_CURL_MESALINK_H
+#define HEADER_CURL_MESALINK_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2017-2018, Yiming Jing, <jingyiming@baidu.com>
+ * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "curl_setup.h"
+
+#ifdef USE_MESALINK
+
+extern const struct Curl_ssl Curl_ssl_mesalink;
+
+#endif /* USE_MESALINK */
+#endif /* HEADER_CURL_MESALINK_H */
diff --git a/Utilities/cmcurl/lib/vtls/nss.c b/Utilities/cmcurl/lib/vtls/nss.c
index cd0138930..491def106 100644
--- a/Utilities/cmcurl/lib/vtls/nss.c
+++ b/Utilities/cmcurl/lib/vtls/nss.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -38,6 +38,7 @@
#include "select.h"
#include "vtls.h"
#include "llist.h"
+#include "multiif.h"
#include "curl_printf.h"
#include "nssg.h"
#include <nspr.h>
@@ -78,6 +79,16 @@
/* enough to fit the string "PEM Token #[0|1]" */
#define SLOTSIZE 13
+struct ssl_backend_data {
+ PRFileDesc *handle;
+ char *client_nickname;
+ struct Curl_easy *data;
+ struct curl_llist obj_list;
+ PK11GenericObject *obj_clicert;
+};
+
+#define BACKEND connssl->backend
+
static PRLock *nss_initlock = NULL;
static PRLock *nss_crllock = NULL;
static PRLock *nss_findslot_lock = NULL;
@@ -207,10 +218,15 @@ static const cipher_s cipherlist[] = {
#endif
};
+#ifdef WIN32
+static const char *pem_library = "nsspem.dll";
+static const char *trust_library = "nssckbi.dll";
+#else
static const char *pem_library = "libnsspem.so";
-static SECMODModule *pem_module = NULL;
-
static const char *trust_library = "libnssckbi.so";
+#endif
+
+static SECMODModule *pem_module = NULL;
static SECMODModule *trust_module = NULL;
/* NSPR I/O layer we use to detect blocking direction during SSL handshake */
@@ -231,6 +247,32 @@ static void nss_print_error_message(struct Curl_easy *data, PRUint32 err)
failf(data, "%s", PR_ErrorToString(err, PR_LANGUAGE_I_DEFAULT));
}
+static char *nss_sslver_to_name(PRUint16 nssver)
+{
+ switch(nssver) {
+ case SSL_LIBRARY_VERSION_2:
+ return strdup("SSLv2");
+ case SSL_LIBRARY_VERSION_3_0:
+ return strdup("SSLv3");
+ case SSL_LIBRARY_VERSION_TLS_1_0:
+ return strdup("TLSv1.0");
+#ifdef SSL_LIBRARY_VERSION_TLS_1_1
+ case SSL_LIBRARY_VERSION_TLS_1_1:
+ return strdup("TLSv1.1");
+#endif
+#ifdef SSL_LIBRARY_VERSION_TLS_1_2
+ case SSL_LIBRARY_VERSION_TLS_1_2:
+ return strdup("TLSv1.2");
+#endif
+#ifdef SSL_LIBRARY_VERSION_TLS_1_3
+ case SSL_LIBRARY_VERSION_TLS_1_3:
+ return strdup("TLSv1.3");
+#endif
+ default:
+ return curl_maprintf("0x%04x", nssver);
+ }
+}
+
static SECStatus set_ciphers(struct Curl_easy *data, PRFileDesc * model,
char *cipher_list)
{
@@ -271,7 +313,7 @@ static SECStatus set_ciphers(struct Curl_easy *data, PRFileDesc * model,
found = PR_FALSE;
- for(i=0; i<NUM_OF_CIPHERS; i++) {
+ for(i = 0; i<NUM_OF_CIPHERS; i++) {
if(strcasecompare(cipher, cipherlist[i].name)) {
cipher_state[i] = PR_TRUE;
found = PR_TRUE;
@@ -290,7 +332,7 @@ static SECStatus set_ciphers(struct Curl_easy *data, PRFileDesc * model,
}
/* Finally actually enable the selected ciphers */
- for(i=0; i<NUM_OF_CIPHERS; i++) {
+ for(i = 0; i<NUM_OF_CIPHERS; i++) {
if(!cipher_state[i])
continue;
@@ -311,7 +353,7 @@ static bool any_cipher_enabled(void)
{
unsigned int i;
- for(i=0; i<NUM_OF_CIPHERS; i++) {
+ for(i = 0; i<NUM_OF_CIPHERS; i++) {
PRInt32 policy = 0;
SSL_CipherPolicyGet(cipherlist[i].num, &policy);
if(policy)
@@ -336,7 +378,7 @@ static int is_file(const char *filename)
return 0;
if(stat(filename, &st) == 0)
- if(S_ISREG(st.st_mode))
+ if(S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode) || S_ISCHR(st.st_mode))
return 1;
return 0;
@@ -384,7 +426,7 @@ static PK11SlotInfo* nss_find_slot_by_name(const char *slot_name)
/* wrap 'ptr' as list node and tail-insert into 'list' */
static CURLcode insert_wrapped_ptr(struct curl_llist *list, void *ptr)
{
- struct ptr_list_wrap *wrap = malloc(sizeof *wrap);
+ struct ptr_list_wrap *wrap = malloc(sizeof(*wrap));
if(!wrap)
return CURLE_OUT_OF_MEMORY;
@@ -396,7 +438,7 @@ static CURLcode insert_wrapped_ptr(struct curl_llist *list, void *ptr)
/* Call PK11_CreateGenericObject() with the given obj_class and filename. If
* the call succeeds, append the object handle to the list of objects so that
* the object can be destroyed in Curl_nss_close(). */
-static CURLcode nss_create_object(struct ssl_connect_data *ssl,
+static CURLcode nss_create_object(struct ssl_connect_data *connssl,
CK_OBJECT_CLASS obj_class,
const char *filename, bool cacert)
{
@@ -430,19 +472,29 @@ static CURLcode nss_create_object(struct ssl_connect_data *ssl,
PK11_SETATTRS(attrs, attr_cnt, CKA_TRUST, pval, sizeof(*pval));
}
- obj = PK11_CreateGenericObject(slot, attrs, attr_cnt, PR_FALSE);
+ /* PK11_CreateManagedGenericObject() was introduced in NSS 3.34 because
+ * PK11_DestroyGenericObject() does not release resources allocated by
+ * PK11_CreateGenericObject() early enough. */
+ obj =
+#ifdef HAVE_PK11_CREATEMANAGEDGENERICOBJECT
+ PK11_CreateManagedGenericObject
+#else
+ PK11_CreateGenericObject
+#endif
+ (slot, attrs, attr_cnt, PR_FALSE);
+
PK11_FreeSlot(slot);
if(!obj)
return result;
- if(insert_wrapped_ptr(&ssl->obj_list, obj) != CURLE_OK) {
+ if(insert_wrapped_ptr(&BACKEND->obj_list, obj) != CURLE_OK) {
PK11_DestroyGenericObject(obj);
return CURLE_OUT_OF_MEMORY;
}
if(!cacert && CKO_CERTIFICATE == obj_class)
/* store reference to a client certificate */
- ssl->obj_clicert = obj;
+ BACKEND->obj_clicert = obj;
return CURLE_OK;
}
@@ -792,6 +844,8 @@ static void HandshakeCallback(PRFileDesc *sock, void *arg)
!memcmp(ALPN_HTTP_1_1, buf, ALPN_HTTP_1_1_LENGTH)) {
conn->negnpn = CURL_HTTP_VERSION_1_1;
}
+ Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ?
+ BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE);
}
}
@@ -894,11 +948,11 @@ static CURLcode display_conn_info(struct connectdata *conn, PRFileDesc *sock)
PRTime now;
int i;
- if(SSL_GetChannelInfo(sock, &channel, sizeof channel) ==
- SECSuccess && channel.length == sizeof channel &&
+ if(SSL_GetChannelInfo(sock, &channel, sizeof(channel)) ==
+ SECSuccess && channel.length == sizeof(channel) &&
channel.cipherSuite) {
if(SSL_GetCipherSuiteInfo(channel.cipherSuite,
- &suite, sizeof suite) == SECSuccess) {
+ &suite, sizeof(suite)) == SECSuccess) {
infof(conn->data, "SSL connection using %s\n", suite.cipherSuiteName);
}
}
@@ -992,7 +1046,7 @@ static SECStatus check_issuer_cert(PRFileDesc *sock,
char *issuer_nickname)
{
CERTCertificate *cert, *cert_issuer, *issuer;
- SECStatus res=SECSuccess;
+ SECStatus res = SECSuccess;
void *proto_win = NULL;
cert = SSL_PeerCertificate(sock);
@@ -1004,7 +1058,7 @@ static SECStatus check_issuer_cert(PRFileDesc *sock,
if((!cert_issuer) || (!issuer))
res = SECFailure;
else if(SECITEM_CompareItem(&cert_issuer->derCert,
- &issuer->derCert)!=SECEqual)
+ &issuer->derCert) != SECEqual)
res = SECFailure;
CERT_DestroyCertificate(cert);
@@ -1017,7 +1071,7 @@ static CURLcode cmp_peer_pubkey(struct ssl_connect_data *connssl,
const char *pinnedpubkey)
{
CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH;
- struct Curl_easy *data = connssl->data;
+ struct Curl_easy *data = BACKEND->data;
CERTCertificate *cert;
if(!pinnedpubkey)
@@ -1025,7 +1079,7 @@ static CURLcode cmp_peer_pubkey(struct ssl_connect_data *connssl,
return CURLE_OK;
/* get peer certificate */
- cert = SSL_PeerCertificate(connssl->handle);
+ cert = SSL_PeerCertificate(BACKEND->handle);
if(cert) {
/* extract public key from peer certificate */
SECKEYPublicKey *pubkey = CERT_ExtractPublicKey(cert);
@@ -1069,11 +1123,11 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
struct SECKEYPrivateKeyStr **pRetKey)
{
struct ssl_connect_data *connssl = (struct ssl_connect_data *)arg;
- struct Curl_easy *data = connssl->data;
- const char *nickname = connssl->client_nickname;
+ struct Curl_easy *data = BACKEND->data;
+ const char *nickname = BACKEND->client_nickname;
static const char pem_slotname[] = "PEM Token #1";
- if(connssl->obj_clicert) {
+ if(BACKEND->obj_clicert) {
/* use the cert/key provided by PEM reader */
SECItem cert_der = { 0, NULL, 0 };
void *proto_win = SSL_RevealPinArg(sock);
@@ -1086,7 +1140,7 @@ static SECStatus SelectClientCert(void *arg, PRFileDesc *sock,
return SECFailure;
}
- if(PK11_ReadRawAttribute(PK11_TypeGeneric, connssl->obj_clicert, CKA_VALUE,
+ if(PK11_ReadRawAttribute(PK11_TypeGeneric, BACKEND->obj_clicert, CKA_VALUE,
&cert_der) != SECSuccess) {
failf(data, "NSS: CKA_VALUE not found in PK11 generic object");
PK11_FreeSlot(slot);
@@ -1254,6 +1308,8 @@ static void nss_unload_module(SECMODModule **pmod)
static CURLcode nss_init_core(struct Curl_easy *data, const char *cert_dir)
{
NSSInitParameters initparams;
+ PRErrorCode err;
+ const char *err_name;
if(nss_context != NULL)
return CURLE_OK;
@@ -1274,7 +1330,9 @@ static CURLcode nss_init_core(struct Curl_easy *data, const char *cert_dir)
if(nss_context != NULL)
return CURLE_OK;
- infof(data, "Unable to initialize NSS database\n");
+ err = PR_GetError();
+ err_name = nss_error_to_name(err);
+ infof(data, "Unable to initialize NSS database: %d (%s)\n", err, err_name);
}
infof(data, "Initializing NSS with certpath: none\n");
@@ -1284,7 +1342,9 @@ static CURLcode nss_init_core(struct Curl_easy *data, const char *cert_dir)
if(nss_context != NULL)
return CURLE_OK;
- infof(data, "Unable to initialize NSS\n");
+ err = PR_GetError();
+ err_name = nss_error_to_name(err);
+ failf(data, "Unable to initialize NSS: %d (%s)", err, err_name);
return CURLE_SSL_CACERT_BADFILE;
}
@@ -1325,7 +1385,8 @@ static CURLcode nss_init(struct Curl_easy *data)
return CURLE_OUT_OF_MEMORY;
/* the default methods just call down to the lower I/O layer */
- memcpy(&nspr_io_methods, PR_GetDefaultIOMethods(), sizeof nspr_io_methods);
+ memcpy(&nspr_io_methods, PR_GetDefaultIOMethods(),
+ sizeof(nspr_io_methods));
/* override certain methods in the table by our wrappers */
nspr_io_methods.recv = nspr_io_recv;
@@ -1351,7 +1412,7 @@ static CURLcode nss_init(struct Curl_easy *data)
* @retval 0 error initializing SSL
* @retval 1 SSL initialized successfully
*/
-int Curl_nss_init(void)
+static int Curl_nss_init(void)
{
/* curl_global_init() is not thread-safe so this test is ok */
if(nss_initlock == NULL) {
@@ -1386,7 +1447,7 @@ CURLcode Curl_nss_force_init(struct Curl_easy *data)
}
/* Global cleanup */
-void Curl_nss_cleanup(void)
+static void Curl_nss_cleanup(void)
{
/* This function isn't required to be threadsafe and this is only done
* as a safety feature.
@@ -1426,14 +1487,14 @@ void Curl_nss_cleanup(void)
* 0 means the connection has been closed
* -1 means the connection status is unknown
*/
-int
-Curl_nss_check_cxn(struct connectdata *conn)
+static int Curl_nss_check_cxn(struct connectdata *conn)
{
+ struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
int rc;
char buf;
rc =
- PR_Recv(conn->ssl[FIRSTSOCKET].handle, (void *)&buf, 1, PR_MSG_PEEK,
+ PR_Recv(BACKEND->handle, (void *)&buf, 1, PR_MSG_PEEK,
PR_SecondsToInterval(1));
if(rc > 0)
return 1; /* connection still in place */
@@ -1447,48 +1508,49 @@ Curl_nss_check_cxn(struct connectdata *conn)
static void nss_close(struct ssl_connect_data *connssl)
{
/* before the cleanup, check whether we are using a client certificate */
- const bool client_cert = (connssl->client_nickname != NULL)
- || (connssl->obj_clicert != NULL);
+ const bool client_cert = (BACKEND->client_nickname != NULL)
+ || (BACKEND->obj_clicert != NULL);
- free(connssl->client_nickname);
- connssl->client_nickname = NULL;
+ free(BACKEND->client_nickname);
+ BACKEND->client_nickname = NULL;
/* destroy all NSS objects in order to avoid failure of NSS shutdown */
- Curl_llist_destroy(&connssl->obj_list, NULL);
- connssl->obj_clicert = NULL;
+ Curl_llist_destroy(&BACKEND->obj_list, NULL);
+ BACKEND->obj_clicert = NULL;
- if(connssl->handle) {
+ if(BACKEND->handle) {
if(client_cert)
/* A server might require different authentication based on the
* particular path being requested by the client. To support this
* scenario, we must ensure that a connection will never reuse the
* authentication data from a previous connection. */
- SSL_InvalidateSession(connssl->handle);
+ SSL_InvalidateSession(BACKEND->handle);
- PR_Close(connssl->handle);
- connssl->handle = NULL;
+ PR_Close(BACKEND->handle);
+ BACKEND->handle = NULL;
}
}
/*
* This function is called when an SSL connection is closed.
*/
-void Curl_nss_close(struct connectdata *conn, int sockindex)
+static void Curl_nss_close(struct connectdata *conn, int sockindex)
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
struct ssl_connect_data *connssl_proxy = &conn->proxy_ssl[sockindex];
- if(connssl->handle || connssl_proxy->handle) {
+ if(BACKEND->handle || connssl_proxy->backend->handle) {
/* NSS closes the socket we previously handed to it, so we must mark it
as closed to avoid double close */
fake_sclose(conn->sock[sockindex]);
conn->sock[sockindex] = CURL_SOCKET_BAD;
}
- if(connssl->handle)
- /* nss_close(connssl) will transitively close also connssl_proxy->handle
- if both are used. Clear it to avoid a double close leading to crash. */
- connssl_proxy->handle = NULL;
+ if(BACKEND->handle)
+ /* nss_close(connssl) will transitively close also
+ connssl_proxy->backend->handle if both are used. Clear it to avoid
+ a double close leading to crash. */
+ connssl_proxy->backend->handle = NULL;
nss_close(connssl);
nss_close(connssl_proxy);
@@ -1500,7 +1562,6 @@ static bool is_nss_error(CURLcode err)
{
switch(err) {
case CURLE_PEER_FAILED_VERIFICATION:
- case CURLE_SSL_CACERT:
case CURLE_SSL_CERTPROBLEM:
case CURLE_SSL_CONNECT_ERROR:
case CURLE_SSL_ISSUER_ERROR:
@@ -1557,8 +1618,9 @@ static CURLcode nss_load_ca_certificates(struct connectdata *conn,
infof(data, "%s %s\n", (result) ? "failed to load" : "loaded",
trust_library);
if(result == CURLE_FAILED_INIT)
- /* make the error non-fatal if we are not going to verify peer */
- result = CURLE_SSL_CACERT_BADFILE;
+ /* If libnssckbi.so is not available (or fails to load), one can still
+ use CA certificates stored in NSS database. Ignore the failure. */
+ result = CURLE_OK;
}
else if(!use_trust_module && trust_module) {
/* libnssckbi.so not needed but already loaded --> unload it! */
@@ -1611,17 +1673,6 @@ static CURLcode nss_load_ca_certificates(struct connectdata *conn,
static CURLcode nss_sslver_from_curl(PRUint16 *nssver, long version)
{
switch(version) {
- case CURL_SSLVERSION_TLSv1:
- /* TODO: set sslver->max to SSL_LIBRARY_VERSION_TLS_1_3 once stable */
-#ifdef SSL_LIBRARY_VERSION_TLS_1_2
- *nssver = SSL_LIBRARY_VERSION_TLS_1_2;
-#elif defined SSL_LIBRARY_VERSION_TLS_1_1
- *nssver = SSL_LIBRARY_VERSION_TLS_1_1;
-#else
- *nssver = SSL_LIBRARY_VERSION_TLS_1_0;
-#endif
- return CURLE_OK;
-
case CURL_SSLVERSION_SSLv2:
*nssver = SSL_LIBRARY_VERSION_2;
return CURLE_OK;
@@ -1682,10 +1733,8 @@ static CURLcode nss_init_sslver(SSLVersionRange *sslver,
}
switch(min) {
- case CURL_SSLVERSION_DEFAULT:
- break;
case CURL_SSLVERSION_TLSv1:
- sslver->min = SSL_LIBRARY_VERSION_TLS_1_0;
+ case CURL_SSLVERSION_DEFAULT:
break;
default:
result = nss_sslver_from_curl(&sslver->min, min);
@@ -1693,8 +1742,6 @@ static CURLcode nss_init_sslver(SSLVersionRange *sslver,
failf(data, "unsupported min version passed via CURLOPT_SSLVERSION");
return result;
}
- if(max == CURL_SSLVERSION_MAX_NONE)
- sslver->max = sslver->min;
}
switch(max) {
@@ -1732,7 +1779,7 @@ static CURLcode nss_fail_connect(struct ssl_connect_data *connssl,
}
/* cleanup on connection failure */
- Curl_llist_destroy(&connssl->obj_list, NULL);
+ Curl_llist_destroy(&BACKEND->obj_list, NULL);
return curlerr;
}
@@ -1746,7 +1793,7 @@ static CURLcode nss_set_blocking(struct ssl_connect_data *connssl,
sock_opt.option = PR_SockOpt_Nonblocking;
sock_opt.value.non_blocking = !blocking;
- if(PR_SetSocketOption(connssl->handle, &sock_opt) != PR_SUCCESS)
+ if(PR_SetSocketOption(BACKEND->handle, &sock_opt) != PR_SUCCESS)
return nss_fail_connect(connssl, data, CURLE_SSL_CONNECT_ERROR);
return CURLE_OK;
@@ -1764,18 +1811,26 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
CURLcode result;
bool second_layer = FALSE;
+ SSLVersionRange sslver_supported;
SSLVersionRange sslver = {
SSL_LIBRARY_VERSION_TLS_1_0, /* min */
- SSL_LIBRARY_VERSION_TLS_1_0 /* max */
+#ifdef SSL_LIBRARY_VERSION_TLS_1_3
+ SSL_LIBRARY_VERSION_TLS_1_3 /* max */
+#elif defined SSL_LIBRARY_VERSION_TLS_1_2
+ SSL_LIBRARY_VERSION_TLS_1_2
+#elif defined SSL_LIBRARY_VERSION_TLS_1_1
+ SSL_LIBRARY_VERSION_TLS_1_1
+#else
+ SSL_LIBRARY_VERSION_TLS_1_0
+#endif
};
- connssl->data = data;
+ BACKEND->data = data;
/* list of all NSS objects we need to destroy in Curl_nss_close() */
- Curl_llist_init(&connssl->obj_list, nss_destroy_object);
+ Curl_llist_init(&BACKEND->obj_list, nss_destroy_object);
- /* FIXME. NSS doesn't support multiple databases open at the same time. */
PR_Lock(nss_initlock);
result = nss_init(conn->data);
if(result) {
@@ -1816,6 +1871,20 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
/* enable/disable the requested SSL version(s) */
if(nss_init_sslver(&sslver, data, conn) != CURLE_OK)
goto error;
+ if(SSL_VersionRangeGetSupported(ssl_variant_stream,
+ &sslver_supported) != SECSuccess)
+ goto error;
+ if(sslver_supported.max < sslver.max && sslver_supported.max >= sslver.min) {
+ char *sslver_req_str, *sslver_supp_str;
+ sslver_req_str = nss_sslver_to_name(sslver.max);
+ sslver_supp_str = nss_sslver_to_name(sslver_supported.max);
+ if(sslver_req_str && sslver_supp_str)
+ infof(data, "Falling back from %s to max supported SSL version (%s)\n",
+ sslver_req_str, sslver_supp_str);
+ free(sslver_req_str);
+ free(sslver_supp_str);
+ sslver.max = sslver_supported.max;
+ }
if(SSL_VersionRangeSet(model, &sslver) != SECSuccess)
goto error;
@@ -1882,7 +1951,7 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
char *nickname = dup_nickname(data, SSL_SET_OPTION(cert));
if(nickname) {
/* we are not going to use libnsspem.so to read the client cert */
- connssl->obj_clicert = NULL;
+ BACKEND->obj_clicert = NULL;
}
else {
CURLcode rv = cert_stuff(conn, sockindex, SSL_SET_OPTION(cert),
@@ -1895,10 +1964,10 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
}
/* store the nickname for SelectClientCert() called during handshake */
- connssl->client_nickname = nickname;
+ BACKEND->client_nickname = nickname;
}
else
- connssl->client_nickname = NULL;
+ BACKEND->client_nickname = NULL;
if(SSL_GetClientAuthDataHook(model, SelectClientCert,
(void *)connssl) != SECSuccess) {
@@ -1908,8 +1977,8 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
if(conn->proxy_ssl[sockindex].use) {
DEBUGASSERT(ssl_connection_complete == conn->proxy_ssl[sockindex].state);
- DEBUGASSERT(conn->proxy_ssl[sockindex].handle != NULL);
- nspr_io = conn->proxy_ssl[sockindex].handle;
+ DEBUGASSERT(conn->proxy_ssl[sockindex].backend->handle != NULL);
+ nspr_io = conn->proxy_ssl[sockindex].backend->handle;
second_layer = TRUE;
}
else {
@@ -1939,8 +2008,8 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
}
/* import our model socket onto the current I/O stack */
- connssl->handle = SSL_ImportFD(model, nspr_io);
- if(!connssl->handle) {
+ BACKEND->handle = SSL_ImportFD(model, nspr_io);
+ if(!BACKEND->handle) {
if(!second_layer)
PR_Close(nspr_io);
goto error;
@@ -1951,36 +2020,36 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
/* This is the password associated with the cert that we're using */
if(SSL_SET_OPTION(key_passwd)) {
- SSL_SetPKCS11PinArg(connssl->handle, SSL_SET_OPTION(key_passwd));
+ SSL_SetPKCS11PinArg(BACKEND->handle, SSL_SET_OPTION(key_passwd));
}
#ifdef SSL_ENABLE_OCSP_STAPLING
if(SSL_CONN_CONFIG(verifystatus)) {
- if(SSL_OptionSet(connssl->handle, SSL_ENABLE_OCSP_STAPLING, PR_TRUE)
+ if(SSL_OptionSet(BACKEND->handle, SSL_ENABLE_OCSP_STAPLING, PR_TRUE)
!= SECSuccess)
goto error;
}
#endif
#ifdef SSL_ENABLE_NPN
- if(SSL_OptionSet(connssl->handle, SSL_ENABLE_NPN, conn->bits.tls_enable_npn
+ if(SSL_OptionSet(BACKEND->handle, SSL_ENABLE_NPN, conn->bits.tls_enable_npn
? PR_TRUE : PR_FALSE) != SECSuccess)
goto error;
#endif
#ifdef SSL_ENABLE_ALPN
- if(SSL_OptionSet(connssl->handle, SSL_ENABLE_ALPN, conn->bits.tls_enable_alpn
+ if(SSL_OptionSet(BACKEND->handle, SSL_ENABLE_ALPN, conn->bits.tls_enable_alpn
? PR_TRUE : PR_FALSE) != SECSuccess)
goto error;
#endif
#if NSSVERNUM >= 0x030f04 /* 3.15.4 */
if(data->set.ssl.falsestart) {
- if(SSL_OptionSet(connssl->handle, SSL_ENABLE_FALSE_START, PR_TRUE)
+ if(SSL_OptionSet(BACKEND->handle, SSL_ENABLE_FALSE_START, PR_TRUE)
!= SECSuccess)
goto error;
- if(SSL_SetCanFalseStartCallback(connssl->handle, CanFalseStartCallback,
+ if(SSL_SetCanFalseStartCallback(BACKEND->handle, CanFalseStartCallback,
conn) != SECSuccess)
goto error;
}
@@ -1992,7 +2061,8 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
unsigned char protocols[128];
#ifdef USE_NGHTTP2
- if(data->set.httpversion >= CURL_HTTP_VERSION_2) {
+ if(data->set.httpversion >= CURL_HTTP_VERSION_2 &&
+ (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)) {
protocols[cur++] = NGHTTP2_PROTO_VERSION_ID_LEN;
memcpy(&protocols[cur], NGHTTP2_PROTO_VERSION_ID,
NGHTTP2_PROTO_VERSION_ID_LEN);
@@ -2003,24 +2073,24 @@ static CURLcode nss_setup_connect(struct connectdata *conn, int sockindex)
memcpy(&protocols[cur], ALPN_HTTP_1_1, ALPN_HTTP_1_1_LENGTH);
cur += ALPN_HTTP_1_1_LENGTH;
- if(SSL_SetNextProtoNego(connssl->handle, protocols, cur) != SECSuccess)
+ if(SSL_SetNextProtoNego(BACKEND->handle, protocols, cur) != SECSuccess)
goto error;
}
#endif
/* Force handshake on next I/O */
- if(SSL_ResetHandshake(connssl->handle, /* asServer */ PR_FALSE)
+ if(SSL_ResetHandshake(BACKEND->handle, /* asServer */ PR_FALSE)
!= SECSuccess)
goto error;
/* propagate hostname to the TLS layer */
- if(SSL_SetURL(connssl->handle, SSL_IS_PROXY() ? conn->http_proxy.host.name :
+ if(SSL_SetURL(BACKEND->handle, SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name) != SECSuccess)
goto error;
/* prevent NSS from re-using the session for a different hostname */
- if(SSL_SetSockPeerID(connssl->handle, SSL_IS_PROXY() ?
+ if(SSL_SetSockPeerID(BACKEND->handle, SSL_IS_PROXY() ?
conn->http_proxy.host.name : conn->host.name)
!= SECSuccess)
goto error;
@@ -2057,18 +2127,18 @@ static CURLcode nss_do_connect(struct connectdata *conn, int sockindex)
/* Force the handshake now */
timeout = PR_MillisecondsToInterval((PRUint32) time_left);
- if(SSL_ForceHandshakeWithTimeout(connssl->handle, timeout) != SECSuccess) {
+ if(SSL_ForceHandshakeWithTimeout(BACKEND->handle, timeout) != SECSuccess) {
if(PR_GetError() == PR_WOULD_BLOCK_ERROR)
/* blocking direction is updated by nss_update_connecting_state() */
return CURLE_AGAIN;
else if(*certverifyresult == SSL_ERROR_BAD_CERT_DOMAIN)
result = CURLE_PEER_FAILED_VERIFICATION;
else if(*certverifyresult != 0)
- result = CURLE_SSL_CACERT;
+ result = CURLE_PEER_FAILED_VERIFICATION;
goto error;
}
- result = display_conn_info(conn, connssl->handle);
+ result = display_conn_info(conn, BACKEND->handle);
if(result)
goto error;
@@ -2077,7 +2147,7 @@ static CURLcode nss_do_connect(struct connectdata *conn, int sockindex)
char *nickname = dup_nickname(data, SSL_SET_OPTION(issuercert));
if(nickname) {
/* we support only nicknames in case of issuercert for now */
- ret = check_issuer_cert(connssl->handle, nickname);
+ ret = check_issuer_cert(BACKEND->handle, nickname);
free(nickname);
}
@@ -2138,7 +2208,7 @@ static CURLcode nss_connect_common(struct connectdata *conn, int sockindex,
if(!blocking)
/* CURLE_AGAIN in non-blocking mode is not an error */
return CURLE_OK;
- /* fall through */
+ /* FALLTHROUGH */
default:
return result;
}
@@ -2163,13 +2233,13 @@ static CURLcode nss_connect_common(struct connectdata *conn, int sockindex,
return CURLE_OK;
}
-CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
+static CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
{
return nss_connect_common(conn, sockindex, /* blocking */ NULL);
}
-CURLcode Curl_nss_connect_nonblocking(struct connectdata *conn,
- int sockindex, bool *done)
+static CURLcode Curl_nss_connect_nonblocking(struct connectdata *conn,
+ int sockindex, bool *done)
{
return nss_connect_common(conn, sockindex, done);
}
@@ -2180,8 +2250,14 @@ static ssize_t nss_send(struct connectdata *conn, /* connection data */
size_t len, /* amount to write */
CURLcode *curlcode)
{
- ssize_t rc = PR_Send(conn->ssl[sockindex].handle, mem, (int)len, 0,
- PR_INTERVAL_NO_WAIT);
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ ssize_t rc;
+
+ /* The SelectClientCert() hook uses this for infof() and failf() but the
+ handle stored in nss_setup_connect() could have already been freed. */
+ BACKEND->data = conn->data;
+
+ rc = PR_Send(BACKEND->handle, mem, (int)len, 0, PR_INTERVAL_NO_WAIT);
if(rc < 0) {
PRInt32 err = PR_GetError();
if(err == PR_WOULD_BLOCK_ERROR)
@@ -2205,14 +2281,21 @@ static ssize_t nss_send(struct connectdata *conn, /* connection data */
return rc; /* number of bytes */
}
-static ssize_t nss_recv(struct connectdata * conn, /* connection data */
- int num, /* socketindex */
+static ssize_t nss_recv(struct connectdata *conn, /* connection data */
+ int sockindex, /* socketindex */
char *buf, /* store read data here */
size_t buffersize, /* max amount to read */
CURLcode *curlcode)
{
- ssize_t nread = PR_Recv(conn->ssl[num].handle, buf, (int)buffersize, 0,
- PR_INTERVAL_NO_WAIT);
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ ssize_t nread;
+
+ /* The SelectClientCert() hook uses this for infof() and failf() but the
+ handle stored in nss_setup_connect() could have already been freed. */
+ BACKEND->data = conn->data;
+
+ nread = PR_Recv(BACKEND->handle, buf, (int)buffersize, 0,
+ PR_INTERVAL_NO_WAIT);
if(nread < 0) {
/* failed SSL read */
PRInt32 err = PR_GetError();
@@ -2238,22 +2321,22 @@ static ssize_t nss_recv(struct connectdata * conn, /* connection data */
return nread;
}
-size_t Curl_nss_version(char *buffer, size_t size)
+static size_t Curl_nss_version(char *buffer, size_t size)
{
- return snprintf(buffer, size, "NSS/%s", NSS_VERSION);
+ return msnprintf(buffer, size, "NSS/%s", NSS_VERSION);
}
/* data might be NULL */
-int Curl_nss_seed(struct Curl_easy *data)
+static int Curl_nss_seed(struct Curl_easy *data)
{
/* make sure that NSS is initialized */
return !!Curl_nss_force_init(data);
}
/* data might be NULL */
-CURLcode Curl_nss_random(struct Curl_easy *data,
- unsigned char *entropy,
- size_t length)
+static CURLcode Curl_nss_random(struct Curl_easy *data,
+ unsigned char *entropy,
+ size_t length)
{
Curl_nss_seed(data); /* Initiate the seed if not already done */
@@ -2264,10 +2347,10 @@ CURLcode Curl_nss_random(struct Curl_easy *data,
return CURLE_OK;
}
-void Curl_nss_md5sum(unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *md5sum, /* output */
- size_t md5len)
+static CURLcode Curl_nss_md5sum(unsigned char *tmp, /* input */
+ size_t tmplen,
+ unsigned char *md5sum, /* output */
+ size_t md5len)
{
PK11Context *MD5pw = PK11_CreateDigestContext(SEC_OID_MD5);
unsigned int MD5out;
@@ -2275,12 +2358,14 @@ void Curl_nss_md5sum(unsigned char *tmp, /* input */
PK11_DigestOp(MD5pw, tmp, curlx_uztoui(tmplen));
PK11_DigestFinal(MD5pw, md5sum, &MD5out, curlx_uztoui(md5len));
PK11_DestroyContext(MD5pw, PR_TRUE);
+
+ return CURLE_OK;
}
-void Curl_nss_sha256sum(const unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *sha256sum, /* output */
- size_t sha256len)
+static CURLcode Curl_nss_sha256sum(const unsigned char *tmp, /* input */
+ size_t tmplen,
+ unsigned char *sha256sum, /* output */
+ size_t sha256len)
{
PK11Context *SHA256pw = PK11_CreateDigestContext(SEC_OID_SHA256);
unsigned int SHA256out;
@@ -2288,9 +2373,11 @@ void Curl_nss_sha256sum(const unsigned char *tmp, /* input */
PK11_DigestOp(SHA256pw, tmp, curlx_uztoui(tmplen));
PK11_DigestFinal(SHA256pw, sha256sum, &SHA256out, curlx_uztoui(sha256len));
PK11_DestroyContext(SHA256pw, PR_TRUE);
+
+ return CURLE_OK;
}
-bool Curl_nss_cert_status_request(void)
+static bool Curl_nss_cert_status_request(void)
{
#ifdef SSL_ENABLE_OCSP_STAPLING
return TRUE;
@@ -2299,7 +2386,7 @@ bool Curl_nss_cert_status_request(void)
#endif
}
-bool Curl_nss_false_start(void)
+static bool Curl_nss_false_start(void)
{
#if NSSVERNUM >= 0x030f04 /* 3.15.4 */
return TRUE;
@@ -2308,4 +2395,45 @@ bool Curl_nss_false_start(void)
#endif
}
+static void *Curl_nss_get_internals(struct ssl_connect_data *connssl,
+ CURLINFO info UNUSED_PARAM)
+{
+ (void)info;
+ return BACKEND->handle;
+}
+
+const struct Curl_ssl Curl_ssl_nss = {
+ { CURLSSLBACKEND_NSS, "nss" }, /* info */
+
+ SSLSUPP_CA_PATH |
+ SSLSUPP_CERTINFO |
+ SSLSUPP_PINNEDPUBKEY |
+ SSLSUPP_HTTPS_PROXY,
+
+ sizeof(struct ssl_backend_data),
+
+ Curl_nss_init, /* init */
+ Curl_nss_cleanup, /* cleanup */
+ Curl_nss_version, /* version */
+ Curl_nss_check_cxn, /* check_cxn */
+ /* NSS has no shutdown function provided and thus always fail */
+ Curl_none_shutdown, /* shutdown */
+ Curl_none_data_pending, /* data_pending */
+ Curl_nss_random, /* random */
+ Curl_nss_cert_status_request, /* cert_status_request */
+ Curl_nss_connect, /* connect */
+ Curl_nss_connect_nonblocking, /* connect_nonblocking */
+ Curl_nss_get_internals, /* get_internals */
+ Curl_nss_close, /* close_one */
+ Curl_none_close_all, /* close_all */
+ /* NSS has its own session ID cache */
+ Curl_none_session_free, /* session_free */
+ Curl_none_set_engine, /* set_engine */
+ Curl_none_set_engine_default, /* set_engine_default */
+ Curl_none_engines_list, /* engines_list */
+ Curl_nss_false_start, /* false_start */
+ Curl_nss_md5sum, /* md5sum */
+ Curl_nss_sha256sum /* sha256sum */
+};
+
#endif /* USE_NSS */
diff --git a/Utilities/cmcurl/lib/vtls/nssg.h b/Utilities/cmcurl/lib/vtls/nssg.h
index 8c46929ff..41e51b021 100644
--- a/Utilities/cmcurl/lib/vtls/nssg.h
+++ b/Utilities/cmcurl/lib/vtls/nssg.h
@@ -30,79 +30,10 @@
#include "urldata.h"
-CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex);
-CURLcode Curl_nss_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done);
-/* close a SSL connection */
-void Curl_nss_close(struct connectdata *conn, int sockindex);
-
-int Curl_nss_init(void);
-void Curl_nss_cleanup(void);
-
-size_t Curl_nss_version(char *buffer, size_t size);
-int Curl_nss_check_cxn(struct connectdata *cxn);
-int Curl_nss_seed(struct Curl_easy *data);
-
/* initialize NSS library if not already */
CURLcode Curl_nss_force_init(struct Curl_easy *data);
-CURLcode Curl_nss_random(struct Curl_easy *data,
- unsigned char *entropy,
- size_t length);
-
-void Curl_nss_md5sum(unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *md5sum, /* output */
- size_t md5len);
-
-void Curl_nss_sha256sum(const unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *sha256sum, /* output */
- size_t sha256len);
-
-bool Curl_nss_cert_status_request(void);
-
-bool Curl_nss_false_start(void);
-
-/* Support HTTPS-proxy */
-#define HTTPS_PROXY_SUPPORT 1
-
-/* Set the API backend definition to NSS */
-#define CURL_SSL_BACKEND CURLSSLBACKEND_NSS
-
-/* this backend supports the CAPATH option */
-#define have_curlssl_ca_path 1
-
-/* this backend supports CURLOPT_CERTINFO */
-#define have_curlssl_certinfo 1
-
-/* this backends supports CURLOPT_PINNEDPUBLICKEY */
-#define have_curlssl_pinnedpubkey 1
-
-/* API setup for NSS */
-#define curlssl_init Curl_nss_init
-#define curlssl_cleanup Curl_nss_cleanup
-#define curlssl_connect Curl_nss_connect
-#define curlssl_connect_nonblocking Curl_nss_connect_nonblocking
-
-/* NSS has its own session ID cache */
-#define curlssl_session_free(x) Curl_nop_stmt
-#define curlssl_close_all(x) ((void)x)
-#define curlssl_close Curl_nss_close
-/* NSS has no shutdown function provided and thus always fail */
-#define curlssl_shutdown(x,y) ((void)x, (void)y, 1)
-#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN)
-#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN)
-#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL)
-#define curlssl_version Curl_nss_version
-#define curlssl_check_cxn(x) Curl_nss_check_cxn(x)
-#define curlssl_data_pending(x,y) ((void)x, (void)y, 0)
-#define curlssl_random(x,y,z) Curl_nss_random(x,y,z)
-#define curlssl_md5sum(a,b,c,d) Curl_nss_md5sum(a,b,c,d)
-#define curlssl_sha256sum(a,b,c,d) Curl_nss_sha256sum(a,b,c,d)
-#define curlssl_cert_status_request() Curl_nss_cert_status_request()
-#define curlssl_false_start() Curl_nss_false_start()
+extern const struct Curl_ssl Curl_ssl_nss;
#endif /* USE_NSS */
#endif /* HEADER_CURL_NSSG_H */
diff --git a/Utilities/cmcurl/lib/vtls/openssl.c b/Utilities/cmcurl/lib/vtls/openssl.c
index dbee36929..85e9be616 100644
--- a/Utilities/cmcurl/lib/vtls/openssl.c
+++ b/Utilities/cmcurl/lib/vtls/openssl.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -34,9 +34,7 @@
#ifdef USE_OPENSSL
-#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif
#include "urldata.h"
#include "sendf.h"
@@ -50,8 +48,8 @@
#include "vtls.h"
#include "strcase.h"
#include "hostcheck.h"
+#include "multiif.h"
#include "curl_printf.h"
-
#include <openssl/ssl.h>
#include <openssl/rand.h>
#include <openssl/x509v3.h>
@@ -64,15 +62,24 @@
#include <openssl/conf.h>
#include <openssl/bn.h>
#include <openssl/rsa.h>
-
-#ifdef HAVE_OPENSSL_PKCS12_H
+#include <openssl/bio.h>
+#include <openssl/buffer.h>
#include <openssl/pkcs12.h>
+
+#ifdef USE_AMISSL
+#include "amigaos.h"
#endif
#if (OPENSSL_VERSION_NUMBER >= 0x0090808fL) && !defined(OPENSSL_NO_OCSP)
#include <openssl/ocsp.h>
#endif
+#if (OPENSSL_VERSION_NUMBER >= 0x0090700fL) && /* 0.9.7 or later */ \
+ !defined(OPENSSL_NO_ENGINE)
+#define USE_OPENSSL_ENGINE
+#include <openssl/engine.h>
+#endif
+
#include "warnless.h"
#include "non-ascii.h" /* for Curl_convert_from_utf8 prototype */
@@ -80,11 +87,18 @@
#include "curl_memory.h"
#include "memdebug.h"
+/* Uncomment the ALLOW_RENEG line to a real #define if you want to allow TLS
+ renegotiations when built with BoringSSL. Renegotiating is non-compliant
+ with HTTP/2 and "an extremely dangerous protocol feature". Beware.
+
+#define ALLOW_RENEG 1
+ */
+
#ifndef OPENSSL_VERSION_NUMBER
#error "OPENSSL_VERSION_NUMBER not defined"
#endif
-#if defined(HAVE_OPENSSL_ENGINE_H)
+#ifdef USE_OPENSSL_ENGINE
#include <openssl/ui.h>
#endif
@@ -105,33 +119,40 @@
#endif
#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && /* OpenSSL 1.1.0+ */ \
- !defined(LIBRESSL_VERSION_NUMBER)
+ !(defined(LIBRESSL_VERSION_NUMBER) && \
+ LIBRESSL_VERSION_NUMBER < 0x20700000L)
#define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
#define HAVE_X509_GET0_EXTENSIONS 1 /* added in 1.1.0 -pre1 */
#define HAVE_OPAQUE_EVP_PKEY 1 /* since 1.1.0 -pre3 */
#define HAVE_OPAQUE_RSA_DSA_DH 1 /* since 1.1.0 -pre5 */
#define CONST_EXTS const
-#define CONST_ASN1_BIT_STRING const
#define HAVE_ERR_REMOVE_THREAD_STATE_DEPRECATED 1
+
+/* funny typecast define due to difference in API */
+#ifdef LIBRESSL_VERSION_NUMBER
+#define ARG2_X509_signature_print (X509_ALGOR *)
+#else
+#define ARG2_X509_signature_print
+#endif
+
#else
/* For OpenSSL before 1.1.0 */
#define ASN1_STRING_get0_data(x) ASN1_STRING_data(x)
#define X509_get0_notBefore(x) X509_get_notBefore(x)
#define X509_get0_notAfter(x) X509_get_notAfter(x)
#define CONST_EXTS /* nope */
-#define CONST_ASN1_BIT_STRING /* nope */
-#ifdef LIBRESSL_VERSION_NUMBER
-static unsigned long OpenSSL_version_num(void)
-{
- return LIBRESSL_VERSION_NUMBER;
-}
-#else
+#ifndef LIBRESSL_VERSION_NUMBER
#define OpenSSL_version_num() SSLeay()
#endif
#endif
+#ifdef LIBRESSL_VERSION_NUMBER
+#define OpenSSL_version_num() LIBRESSL_VERSION_NUMBER
+#endif
+
#if (OPENSSL_VERSION_NUMBER >= 0x1000200fL) && /* 1.0.2 or later */ \
- !defined(LIBRESSL_VERSION_NUMBER)
+ !(defined(LIBRESSL_VERSION_NUMBER) && \
+ LIBRESSL_VERSION_NUMBER < 0x20700000L)
#define HAVE_X509_GET0_SIGNATURE 1
#endif
@@ -146,6 +167,31 @@ static unsigned long OpenSSL_version_num(void)
#define OPENSSL_load_builtin_modules(x)
#endif
+/*
+ * Whether SSL_CTX_set_keylog_callback is available.
+ * OpenSSL: supported since 1.1.1 https://github.com/openssl/openssl/pull/2287
+ * BoringSSL: supported since d28f59c27bac (committed 2015-11-19)
+ * LibreSSL: unsupported in at least 2.7.2 (explicitly check for it since it
+ * lies and pretends to be OpenSSL 2.0.0).
+ */
+#if (OPENSSL_VERSION_NUMBER >= 0x10101000L && \
+ !defined(LIBRESSL_VERSION_NUMBER)) || \
+ defined(OPENSSL_IS_BORINGSSL)
+#define HAVE_KEYLOG_CALLBACK
+#endif
+
+/* Whether SSL_CTX_set_ciphersuites is available.
+ * OpenSSL: supported since 1.1.1 (commit a53b5be6a05)
+ * BoringSSL: no
+ * LibreSSL: no
+ */
+#if ((OPENSSL_VERSION_NUMBER >= 0x10101000L) && \
+ !defined(LIBRESSL_VERSION_NUMBER) && \
+ !defined(OPENSSL_IS_BORINGSSL))
+#define HAVE_SSL_CTX_SET_CIPHERSUITES
+#define HAVE_SSL_CTX_SET_POST_HANDSHAKE_AUTH
+#endif
+
#if defined(LIBRESSL_VERSION_NUMBER)
#define OSSL_PACKAGE "LibreSSL"
#elif defined(OPENSSL_IS_BORINGSSL)
@@ -154,6 +200,40 @@ static unsigned long OpenSSL_version_num(void)
#define OSSL_PACKAGE "OpenSSL"
#endif
+#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
+/* up2date versions of OpenSSL maintain the default reasonably secure without
+ * breaking compatibility, so it is better not to override the default by curl
+ */
+#define DEFAULT_CIPHER_SELECTION NULL
+#else
+/* ... but it is not the case with old versions of OpenSSL */
+#define DEFAULT_CIPHER_SELECTION \
+ "ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH"
+#endif
+
+#define ENABLE_SSLKEYLOGFILE
+
+#ifdef ENABLE_SSLKEYLOGFILE
+typedef struct ssl_tap_state {
+ int master_key_length;
+ unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH];
+ unsigned char client_random[SSL3_RANDOM_SIZE];
+} ssl_tap_state_t;
+#endif /* ENABLE_SSLKEYLOGFILE */
+
+struct ssl_backend_data {
+ /* these ones requires specific SSL-types */
+ SSL_CTX* ctx;
+ SSL* handle;
+ X509* server_cert;
+#ifdef ENABLE_SSLKEYLOGFILE
+ /* tap_state holds the last seen master key if we're logging them */
+ ssl_tap_state_t tap_state;
+#endif
+};
+
+#define BACKEND connssl->backend
+
/*
* Number of bytes to read from the random number seed file. This must be
* a finite value (because some entropy "files" like /dev/urandom have
@@ -162,6 +242,114 @@ static unsigned long OpenSSL_version_num(void)
*/
#define RAND_LOAD_LENGTH 1024
+#ifdef ENABLE_SSLKEYLOGFILE
+/* The fp for the open SSLKEYLOGFILE, or NULL if not open */
+static FILE *keylog_file_fp;
+
+#ifdef HAVE_KEYLOG_CALLBACK
+static void ossl_keylog_callback(const SSL *ssl, const char *line)
+{
+ (void)ssl;
+
+ /* Using fputs here instead of fprintf since libcurl's fprintf replacement
+ may not be thread-safe. */
+ if(keylog_file_fp && line && *line) {
+ char stackbuf[256];
+ char *buf;
+ size_t linelen = strlen(line);
+
+ if(linelen <= sizeof(stackbuf) - 2)
+ buf = stackbuf;
+ else {
+ buf = malloc(linelen + 2);
+ if(!buf)
+ return;
+ }
+ memcpy(buf, line, linelen);
+ buf[linelen] = '\n';
+ buf[linelen + 1] = '\0';
+
+ fputs(buf, keylog_file_fp);
+ if(buf != stackbuf)
+ free(buf);
+ }
+}
+#else
+#define KEYLOG_PREFIX "CLIENT_RANDOM "
+#define KEYLOG_PREFIX_LEN (sizeof(KEYLOG_PREFIX) - 1)
+/*
+ * tap_ssl_key is called by libcurl to make the CLIENT_RANDOMs if the OpenSSL
+ * being used doesn't have native support for doing that.
+ */
+static void tap_ssl_key(const SSL *ssl, ssl_tap_state_t *state)
+{
+ const char *hex = "0123456789ABCDEF";
+ int pos, i;
+ char line[KEYLOG_PREFIX_LEN + 2 * SSL3_RANDOM_SIZE + 1 +
+ 2 * SSL_MAX_MASTER_KEY_LENGTH + 1 + 1];
+ const SSL_SESSION *session = SSL_get_session(ssl);
+ unsigned char client_random[SSL3_RANDOM_SIZE];
+ unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH];
+ int master_key_length = 0;
+
+ if(!session || !keylog_file_fp)
+ return;
+
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L && \
+ !(defined(LIBRESSL_VERSION_NUMBER) && \
+ LIBRESSL_VERSION_NUMBER < 0x20700000L)
+ /* ssl->s3 is not checked in openssl 1.1.0-pre6, but let's assume that
+ * we have a valid SSL context if we have a non-NULL session. */
+ SSL_get_client_random(ssl, client_random, SSL3_RANDOM_SIZE);
+ master_key_length = (int)
+ SSL_SESSION_get_master_key(session, master_key, SSL_MAX_MASTER_KEY_LENGTH);
+#else
+ if(ssl->s3 && session->master_key_length > 0) {
+ master_key_length = session->master_key_length;
+ memcpy(master_key, session->master_key, session->master_key_length);
+ memcpy(client_random, ssl->s3->client_random, SSL3_RANDOM_SIZE);
+ }
+#endif
+
+ if(master_key_length <= 0)
+ return;
+
+ /* Skip writing keys if there is no key or it did not change. */
+ if(state->master_key_length == master_key_length &&
+ !memcmp(state->master_key, master_key, master_key_length) &&
+ !memcmp(state->client_random, client_random, SSL3_RANDOM_SIZE)) {
+ return;
+ }
+
+ state->master_key_length = master_key_length;
+ memcpy(state->master_key, master_key, master_key_length);
+ memcpy(state->client_random, client_random, SSL3_RANDOM_SIZE);
+
+ memcpy(line, KEYLOG_PREFIX, KEYLOG_PREFIX_LEN);
+ pos = KEYLOG_PREFIX_LEN;
+
+ /* Client Random for SSLv3/TLS */
+ for(i = 0; i < SSL3_RANDOM_SIZE; i++) {
+ line[pos++] = hex[client_random[i] >> 4];
+ line[pos++] = hex[client_random[i] & 0xF];
+ }
+ line[pos++] = ' ';
+
+ /* Master Secret (size is at most SSL_MAX_MASTER_KEY_LENGTH) */
+ for(i = 0; i < master_key_length; i++) {
+ line[pos++] = hex[master_key[i] >> 4];
+ line[pos++] = hex[master_key[i] & 0xF];
+ }
+ line[pos++] = '\n';
+ line[pos] = '\0';
+
+ /* Using fputs here instead of fprintf since libcurl's fprintf replacement
+ may not be thread-safe. */
+ fputs(line, keylog_file_fp);
+}
+#endif /* !HAVE_KEYLOG_CALLBACK */
+#endif /* ENABLE_SSLKEYLOGFILE */
+
static const char *SSL_ERROR_to_str(int err)
{
switch(err) {
@@ -208,6 +396,31 @@ static char *ossl_strerror(unsigned long error, char *buf, size_t size)
return buf;
}
+/* Return an extra data index for the connection data.
+ * This index can be used with SSL_get_ex_data() and SSL_set_ex_data().
+ */
+static int ossl_get_ssl_conn_index(void)
+{
+ static int ssl_ex_data_conn_index = -1;
+ if(ssl_ex_data_conn_index < 0) {
+ ssl_ex_data_conn_index = SSL_get_ex_new_index(0, NULL, NULL, NULL, NULL);
+ }
+ return ssl_ex_data_conn_index;
+}
+
+/* Return an extra data index for the sockindex.
+ * This index can be used with SSL_get_ex_data() and SSL_set_ex_data().
+ */
+static int ossl_get_ssl_sockindex_index(void)
+{
+ static int ssl_ex_data_sockindex_index = -1;
+ if(ssl_ex_data_sockindex_index < 0) {
+ ssl_ex_data_sockindex_index = SSL_get_ex_new_index(0, NULL, NULL, NULL,
+ NULL);
+ }
+ return ssl_ex_data_sockindex_index;
+}
+
static int passwd_callback(char *buf, int num, int encrypting,
void *global_passwd)
{
@@ -216,7 +429,7 @@ static int passwd_callback(char *buf, int num, int encrypting,
if(!encrypting) {
int klen = curlx_uztosi(strlen((char *)global_passwd));
if(num > klen) {
- memcpy(buf, global_passwd, klen+1);
+ memcpy(buf, global_passwd, klen + 1);
return klen;
}
}
@@ -236,7 +449,6 @@ static CURLcode Curl_ossl_seed(struct Curl_easy *data)
/* we have the "SSL is seeded" boolean static to prevent multiple
time-consuming seedings in vain */
static bool ssl_seeded = FALSE;
- int nread=0;
char fname[256];
if(ssl_seeded)
@@ -256,12 +468,12 @@ static CURLcode Curl_ossl_seed(struct Curl_easy *data)
#endif
{
/* let the option override the define */
- nread += RAND_load_file((data->set.str[STRING_SSL_RANDOM_FILE]?
- data->set.str[STRING_SSL_RANDOM_FILE]:
- RANDOM_FILE),
- RAND_LOAD_LENGTH);
+ RAND_load_file((data->set.str[STRING_SSL_RANDOM_FILE]?
+ data->set.str[STRING_SSL_RANDOM_FILE]:
+ RANDOM_FILE),
+ RAND_LOAD_LENGTH);
if(rand_enough())
- return nread;
+ return CURLE_OK;
}
#if defined(HAVE_RAND_EGD)
@@ -279,35 +491,47 @@ static CURLcode Curl_ossl_seed(struct Curl_easy *data)
int ret = RAND_egd(data->set.str[STRING_SSL_EGDSOCKET]?
data->set.str[STRING_SSL_EGDSOCKET]:EGD_SOCKET);
if(-1 != ret) {
- nread += ret;
if(rand_enough())
- return nread;
+ return CURLE_OK;
}
}
#endif
- /* If we get here, it means we need to seed the PRNG using a "silly"
- approach! */
+ /* fallback to a custom seeding of the PRNG using a hash based on a current
+ time */
do {
unsigned char randb[64];
- int len = sizeof(randb);
- if(!RAND_bytes(randb, len))
- break;
- RAND_add(randb, len, (len >> 1));
+ size_t len = sizeof(randb);
+ size_t i, i_max;
+ for(i = 0, i_max = len / sizeof(struct curltime); i < i_max; ++i) {
+ struct curltime tv = Curl_now();
+ Curl_wait_ms(1);
+ tv.tv_sec *= i + 1;
+ tv.tv_usec *= (unsigned int)i + 2;
+ tv.tv_sec ^= ((Curl_now().tv_sec + Curl_now().tv_usec) *
+ (i + 3)) << 8;
+ tv.tv_usec ^= (unsigned int) ((Curl_now().tv_sec +
+ Curl_now().tv_usec) *
+ (i + 4)) << 16;
+ memcpy(&randb[i * sizeof(struct curltime)], &tv,
+ sizeof(struct curltime));
+ }
+ RAND_add(randb, (int)len, (double)len/2);
} while(!rand_enough());
/* generates a default path for the random seed file */
- fname[0]=0; /* blank it first */
+ fname[0] = 0; /* blank it first */
RAND_file_name(fname, sizeof(fname));
if(fname[0]) {
/* we got a file name to try */
- nread += RAND_load_file(fname, RAND_LOAD_LENGTH);
+ RAND_load_file(fname, RAND_LOAD_LENGTH);
if(rand_enough())
- return nread;
+ return CURLE_OK;
}
infof(data, "libcurl is now using a weak random seed!\n");
- return CURLE_SSL_CONNECT_ERROR; /* confusing error code */
+ return (rand_enough() ? CURLE_OK :
+ CURLE_SSL_CONNECT_ERROR /* confusing error code */);
}
#ifndef SSL_FILETYPE_ENGINE
@@ -331,7 +555,7 @@ static int do_file_type(const char *type)
return -1;
}
-#if defined(HAVE_OPENSSL_ENGINE_H)
+#ifdef USE_OPENSSL_ENGINE
/*
* Supply default password to the engine user interface conversation.
* The password is passed by OpenSSL engine from ENGINE_load_private_key()
@@ -371,8 +595,20 @@ static int ssl_ui_writer(UI *ui, UI_STRING *uis)
}
return (UI_method_get_writer(UI_OpenSSL()))(ui, uis);
}
+
+/*
+ * Check if a given string is a PKCS#11 URI
+ */
+static bool is_pkcs11_uri(const char *string)
+{
+ return (string && strncasecompare(string, "pkcs11:", 7));
+}
+
#endif
+static CURLcode Curl_ossl_set_engine(struct Curl_easy *data,
+ const char *engine);
+
static
int cert_stuff(struct connectdata *conn,
SSL_CTX* ctx,
@@ -384,6 +620,7 @@ int cert_stuff(struct connectdata *conn,
{
struct Curl_easy *data = conn->data;
char error_buffer[256];
+ bool check_privkey = TRUE;
int file_type = do_file_type(cert_type);
@@ -432,8 +669,18 @@ int cert_stuff(struct connectdata *conn,
}
break;
case SSL_FILETYPE_ENGINE:
-#if defined(HAVE_OPENSSL_ENGINE_H) && defined(ENGINE_CTRL_GET_CMD_FROM_NAME)
+#if defined(USE_OPENSSL_ENGINE) && defined(ENGINE_CTRL_GET_CMD_FROM_NAME)
{
+ /* Implicitly use pkcs11 engine if none was provided and the
+ * cert_file is a PKCS#11 URI */
+ if(!data->state.engine) {
+ if(is_pkcs11_uri(cert_file)) {
+ if(Curl_ossl_set_engine(data, "pkcs11") != CURLE_OK) {
+ return 0;
+ }
+ }
+ }
+
if(data->state.engine) {
const char *cmd_name = "LOAD_CERT_CTRL";
struct {
@@ -487,19 +734,28 @@ int cert_stuff(struct connectdata *conn,
case SSL_FILETYPE_PKCS12:
{
-#ifdef HAVE_OPENSSL_PKCS12_H
- FILE *f;
- PKCS12 *p12;
+ BIO *fp = NULL;
+ PKCS12 *p12 = NULL;
EVP_PKEY *pri;
STACK_OF(X509) *ca = NULL;
- f = fopen(cert_file, "rb");
- if(!f) {
+ fp = BIO_new(BIO_s_file());
+ if(fp == NULL) {
+ failf(data,
+ "BIO_new return NULL, " OSSL_PACKAGE
+ " error %s",
+ ossl_strerror(ERR_get_error(), error_buffer,
+ sizeof(error_buffer)) );
+ return 0;
+ }
+
+ if(BIO_read_filename(fp, cert_file) <= 0) {
failf(data, "could not open PKCS12 file '%s'", cert_file);
+ BIO_free(fp);
return 0;
}
- p12 = d2i_PKCS12_fp(f, NULL);
- fclose(f);
+ p12 = d2i_PKCS12_bio(fp, NULL);
+ BIO_free(fp);
if(!p12) {
failf(data, "error reading PKCS12 file '%s'", cert_file);
@@ -569,30 +825,29 @@ int cert_stuff(struct connectdata *conn,
fail:
EVP_PKEY_free(pri);
X509_free(x509);
+#ifdef USE_AMISSL
+ sk_X509_pop_free(ca, Curl_amiga_X509_free);
+#else
sk_X509_pop_free(ca, X509_free);
-
+#endif
if(!cert_done)
return 0; /* failure! */
break;
-#else
- failf(data, "file type P12 for certificate not supported");
- return 0;
-#endif
}
default:
failf(data, "not supported file type '%s' for certificate", cert_type);
return 0;
}
- file_type = do_file_type(key_type);
+ if(!key_file)
+ key_file = cert_file;
+ else
+ file_type = do_file_type(key_type);
switch(file_type) {
case SSL_FILETYPE_PEM:
if(cert_done)
break;
- if(!key_file)
- /* cert & key can only be in PEM case in the same file */
- key_file=cert_file;
/* FALLTHROUGH */
case SSL_FILETYPE_ASN1:
if(SSL_CTX_use_PrivateKey_file(ctx, key_file, file_type) != 1) {
@@ -602,9 +857,20 @@ int cert_stuff(struct connectdata *conn,
}
break;
case SSL_FILETYPE_ENGINE:
-#ifdef HAVE_OPENSSL_ENGINE_H
+#ifdef USE_OPENSSL_ENGINE
{ /* XXXX still needs some work */
EVP_PKEY *priv_key = NULL;
+
+ /* Implicitly use pkcs11 engine if none was provided and the
+ * key_file is a PKCS#11 URI */
+ if(!data->state.engine) {
+ if(is_pkcs11_uri(key_file)) {
+ if(Curl_ossl_set_engine(data, "pkcs11") != CURLE_OK) {
+ return 0;
+ }
+ }
+ }
+
if(data->state.engine) {
UI_METHOD *ui_method =
UI_create_method((char *)"curl user interface");
@@ -655,13 +921,13 @@ int cert_stuff(struct connectdata *conn,
return 0;
}
- ssl=SSL_new(ctx);
+ ssl = SSL_new(ctx);
if(!ssl) {
failf(data, "unable to create an SSL structure");
return 0;
}
- x509=SSL_get_certificate(ssl);
+ x509 = SSL_get_certificate(ssl);
/* This version was provided by Evan Jordan and is supposed to not
leak memory as the previous version: */
@@ -671,17 +937,38 @@ int cert_stuff(struct connectdata *conn,
EVP_PKEY_free(pktmp);
}
+#if !defined(OPENSSL_NO_RSA) && !defined(OPENSSL_IS_BORINGSSL)
+ {
+ /* If RSA is used, don't check the private key if its flags indicate
+ * it doesn't support it. */
+ EVP_PKEY *priv_key = SSL_get_privatekey(ssl);
+ int pktype;
+#ifdef HAVE_OPAQUE_EVP_PKEY
+ pktype = EVP_PKEY_id(priv_key);
+#else
+ pktype = priv_key->type;
+#endif
+ if(pktype == EVP_PKEY_RSA) {
+ RSA *rsa = EVP_PKEY_get1_RSA(priv_key);
+ if(RSA_flags(rsa) & RSA_METHOD_FLAG_NO_CHECK)
+ check_privkey = FALSE;
+ RSA_free(rsa); /* Decrement reference count */
+ }
+ }
+#endif
+
SSL_free(ssl);
/* If we are using DSA, we can copy the parameters from
* the private key */
-
- /* Now we know that a key and cert have been set against
- * the SSL context */
- if(!SSL_CTX_check_private_key(ctx)) {
- failf(data, "Private key does not match the certificate public key");
- return 0;
+ if(check_privkey == TRUE) {
+ /* Now we know that a key and cert have been set against
+ * the SSL context */
+ if(!SSL_CTX_check_private_key(ctx)) {
+ failf(data, "Private key does not match the certificate public key");
+ return 0;
+ }
}
}
return 1;
@@ -709,7 +996,7 @@ static int x509_name_oneline(X509_NAME *a, char *buf, size_t size)
size--; /* don't overwrite the buffer end */
memcpy(buf, biomem->data, size);
- buf[size]=0;
+ buf[size] = 0;
BIO_free(bio_out);
@@ -723,11 +1010,15 @@ static int x509_name_oneline(X509_NAME *a, char *buf, size_t size)
* @retval 0 error initializing SSL
* @retval 1 SSL initialized successfully
*/
-int Curl_ossl_init(void)
+static int Curl_ossl_init(void)
{
+#ifdef ENABLE_SSLKEYLOGFILE
+ char *keylog_file_name;
+#endif
+
OPENSSL_load_builtin_modules();
-#ifdef HAVE_ENGINE_LOAD_BUILTIN_ENGINES
+#ifdef USE_OPENSSL_ENGINE
ENGINE_load_builtin_engines();
#endif
@@ -743,9 +1034,11 @@ int Curl_ossl_init(void)
#define CONF_MFLAGS_DEFAULT_SECTION 0x0
#endif
+#ifndef CURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG
CONF_modules_load_file(NULL, NULL,
CONF_MFLAGS_DEFAULT_SECTION|
CONF_MFLAGS_IGNORE_MISSING_FILE);
+#endif
#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && \
!defined(LIBRESSL_VERSION_NUMBER)
@@ -761,11 +1054,36 @@ int Curl_ossl_init(void)
OpenSSL_add_all_algorithms();
#endif
+#ifdef ENABLE_SSLKEYLOGFILE
+ if(!keylog_file_fp) {
+ keylog_file_name = curl_getenv("SSLKEYLOGFILE");
+ if(keylog_file_name) {
+ keylog_file_fp = fopen(keylog_file_name, FOPEN_APPENDTEXT);
+ if(keylog_file_fp) {
+#ifdef WIN32
+ if(setvbuf(keylog_file_fp, NULL, _IONBF, 0))
+#else
+ if(setvbuf(keylog_file_fp, NULL, _IOLBF, 4096))
+#endif
+ {
+ fclose(keylog_file_fp);
+ keylog_file_fp = NULL;
+ }
+ }
+ Curl_safefree(keylog_file_name);
+ }
+ }
+#endif
+
+ /* Initialize the extra data indexes */
+ if(ossl_get_ssl_conn_index() < 0 || ossl_get_ssl_sockindex_index() < 0)
+ return 0;
+
return 1;
}
/* Global cleanup */
-void Curl_ossl_cleanup(void)
+static void Curl_ossl_cleanup(void)
{
#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && \
!defined(LIBRESSL_VERSION_NUMBER)
@@ -775,7 +1093,7 @@ void Curl_ossl_cleanup(void)
/* Free ciphers and digests lists */
EVP_cleanup();
-#ifdef HAVE_ENGINE_CLEANUP
+#ifdef USE_OPENSSL_ENGINE
/* Free engine list */
ENGINE_cleanup();
#endif
@@ -797,6 +1115,13 @@ void Curl_ossl_cleanup(void)
SSL_COMP_free_compression_methods();
#endif
#endif
+
+#ifdef ENABLE_SSLKEYLOGFILE
+ if(keylog_file_fp) {
+ fclose(keylog_file_fp);
+ keylog_file_fp = NULL;
+ }
+#endif
}
/*
@@ -807,7 +1132,7 @@ void Curl_ossl_cleanup(void)
* 0 means the connection has been closed
* -1 means the connection status is unknown
*/
-int Curl_ossl_check_cxn(struct connectdata *conn)
+static int Curl_ossl_check_cxn(struct connectdata *conn)
{
/* SSL_peek takes data out of the raw recv buffer without peeking so we use
recv MSG_PEEK instead. Bug #795 */
@@ -853,9 +1178,10 @@ int Curl_ossl_check_cxn(struct connectdata *conn)
/* Selects an OpenSSL crypto engine
*/
-CURLcode Curl_ossl_set_engine(struct Curl_easy *data, const char *engine)
+static CURLcode Curl_ossl_set_engine(struct Curl_easy *data,
+ const char *engine)
{
-#if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H)
+#ifdef USE_OPENSSL_ENGINE
ENGINE *e;
#if OPENSSL_VERSION_NUMBER >= 0x00909000L
@@ -898,9 +1224,9 @@ CURLcode Curl_ossl_set_engine(struct Curl_easy *data, const char *engine)
/* Sets engine as default for all SSL operations
*/
-CURLcode Curl_ossl_set_engine_default(struct Curl_easy *data)
+static CURLcode Curl_ossl_set_engine_default(struct Curl_easy *data)
{
-#ifdef HAVE_OPENSSL_ENGINE_H
+#ifdef USE_OPENSSL_ENGINE
if(data->state.engine) {
if(ENGINE_set_default(data->state.engine, ENGINE_METHOD_ALL) > 0) {
infof(data, "set default crypto engine '%s'\n",
@@ -920,10 +1246,10 @@ CURLcode Curl_ossl_set_engine_default(struct Curl_easy *data)
/* Return list of OpenSSL crypto engine names.
*/
-struct curl_slist *Curl_ossl_engines_list(struct Curl_easy *data)
+static struct curl_slist *Curl_ossl_engines_list(struct Curl_easy *data)
{
struct curl_slist *list = NULL;
-#if defined(USE_OPENSSL) && defined(HAVE_OPENSSL_ENGINE_H)
+#ifdef USE_OPENSSL_ENGINE
struct curl_slist *beg;
ENGINE *e;
@@ -943,23 +1269,23 @@ struct curl_slist *Curl_ossl_engines_list(struct Curl_easy *data)
static void ossl_close(struct ssl_connect_data *connssl)
{
- if(connssl->handle) {
- (void)SSL_shutdown(connssl->handle);
- SSL_set_connect_state(connssl->handle);
+ if(BACKEND->handle) {
+ (void)SSL_shutdown(BACKEND->handle);
+ SSL_set_connect_state(BACKEND->handle);
- SSL_free(connssl->handle);
- connssl->handle = NULL;
+ SSL_free(BACKEND->handle);
+ BACKEND->handle = NULL;
}
- if(connssl->ctx) {
- SSL_CTX_free(connssl->ctx);
- connssl->ctx = NULL;
+ if(BACKEND->ctx) {
+ SSL_CTX_free(BACKEND->ctx);
+ BACKEND->ctx = NULL;
}
}
/*
* This function is called when an SSL connection is closed.
*/
-void Curl_ossl_close(struct connectdata *conn, int sockindex)
+static void Curl_ossl_close(struct connectdata *conn, int sockindex)
{
ossl_close(&conn->ssl[sockindex]);
ossl_close(&conn->proxy_ssl[sockindex]);
@@ -969,7 +1295,7 @@ void Curl_ossl_close(struct connectdata *conn, int sockindex)
* This function is called to shut down the SSL layer but keep the
* socket open (CCC - Clear Command Channel)
*/
-int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
+static int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
{
int retval = 0;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
@@ -980,17 +1306,19 @@ int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
ssize_t nread;
int buffsize;
int err;
- int done = 0;
+ bool done = FALSE;
+#ifndef CURL_DISABLE_FTP
/* This has only been tested on the proftpd server, and the mod_tls code
sends a close notify alert without waiting for a close notify alert in
response. Thus we wait for a close notify alert from the server, but
we do not send one. Let's hope other servers do the same... */
if(data->set.ftp_ccc == CURLFTPSSL_CCC_ACTIVE)
- (void)SSL_shutdown(connssl->handle);
+ (void)SSL_shutdown(BACKEND->handle);
+#endif
- if(connssl->handle) {
+ if(BACKEND->handle) {
buffsize = (int)sizeof(buf);
while(!done) {
int what = SOCKET_READABLE(conn->sock[sockindex],
@@ -1000,16 +1328,15 @@ int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
/* Something to read, let's do it and hope that it is the close
notify alert from the server */
- nread = (ssize_t)SSL_read(conn->ssl[sockindex].handle, buf,
- buffsize);
- err = SSL_get_error(conn->ssl[sockindex].handle, (int)nread);
+ nread = (ssize_t)SSL_read(BACKEND->handle, buf, buffsize);
+ err = SSL_get_error(BACKEND->handle, (int)nread);
switch(err) {
case SSL_ERROR_NONE: /* this is not an error */
case SSL_ERROR_ZERO_RETURN: /* no more data */
/* This is the expected response. There was no data but only
the close notify alert */
- done = 1;
+ done = TRUE;
break;
case SSL_ERROR_WANT_READ:
/* there's data pending, re-invoke SSL_read() */
@@ -1018,7 +1345,7 @@ int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
case SSL_ERROR_WANT_WRITE:
/* SSL wants a write. Really odd. Let's bail out. */
infof(data, "SSL_ERROR_WANT_WRITE\n");
- done = 1;
+ done = TRUE;
break;
default:
/* openssl/ssl.h says "look at error stack/return value/errno" */
@@ -1028,26 +1355,26 @@ int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
ossl_strerror(sslerror, buf, sizeof(buf)) :
SSL_ERROR_to_str(err)),
SOCKERRNO);
- done = 1;
+ done = TRUE;
break;
}
}
else if(0 == what) {
/* timeout */
failf(data, "SSL shutdown timeout");
- done = 1;
+ done = TRUE;
}
else {
/* anything that gets here is fatally bad */
failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
retval = -1;
- done = 1;
+ done = TRUE;
}
} /* while()-loop for the select() */
if(data->set.verbose) {
#ifdef HAVE_SSL_GET_SHUTDOWN
- switch(SSL_get_shutdown(connssl->handle)) {
+ switch(SSL_get_shutdown(BACKEND->handle)) {
case SSL_SENT_SHUTDOWN:
infof(data, "SSL_get_shutdown() returned SSL_SENT_SHUTDOWN\n");
break;
@@ -1062,13 +1389,13 @@ int Curl_ossl_shutdown(struct connectdata *conn, int sockindex)
#endif
}
- SSL_free(connssl->handle);
- connssl->handle = NULL;
+ SSL_free(BACKEND->handle);
+ BACKEND->handle = NULL;
}
return retval;
}
-void Curl_ossl_session_free(void *ptr)
+static void Curl_ossl_session_free(void *ptr)
{
/* free the ID */
SSL_SESSION_free(ptr);
@@ -1078,9 +1405,9 @@ void Curl_ossl_session_free(void *ptr)
* This function is called when the 'data' struct is going away. Close
* down everything and free all resources!
*/
-void Curl_ossl_close_all(struct Curl_easy *data)
+static void Curl_ossl_close_all(struct Curl_easy *data)
{
-#ifdef HAVE_OPENSSL_ENGINE_H
+#ifdef USE_OPENSSL_ENGINE
if(data->state.engine) {
ENGINE_finish(data->state.engine);
ENGINE_free(data->state.engine);
@@ -1101,6 +1428,55 @@ void Curl_ossl_close_all(struct Curl_easy *data)
/* ====================================================== */
+/*
+ * Match subjectAltName against the host name. This requires a conversion
+ * in CURL_DOES_CONVERSIONS builds.
+ */
+static bool subj_alt_hostcheck(struct Curl_easy *data,
+ const char *match_pattern, const char *hostname,
+ const char *dispname)
+#ifdef CURL_DOES_CONVERSIONS
+{
+ bool res = FALSE;
+
+ /* Curl_cert_hostcheck uses host encoding, but we get ASCII from
+ OpenSSl.
+ */
+ char *match_pattern2 = strdup(match_pattern);
+
+ if(match_pattern2) {
+ if(Curl_convert_from_network(data, match_pattern2,
+ strlen(match_pattern2)) == CURLE_OK) {
+ if(Curl_cert_hostcheck(match_pattern2, hostname)) {
+ res = TRUE;
+ infof(data,
+ " subjectAltName: host \"%s\" matched cert's \"%s\"\n",
+ dispname, match_pattern2);
+ }
+ }
+ free(match_pattern2);
+ }
+ else {
+ failf(data,
+ "SSL: out of memory when allocating temporary for subjectAltName");
+ }
+ return res;
+}
+#else
+{
+#ifdef CURL_DISABLE_VERBOSE_STRINGS
+ (void)dispname;
+ (void)data;
+#endif
+ if(Curl_cert_hostcheck(match_pattern, hostname)) {
+ infof(data, " subjectAltName: host \"%s\" matched cert's \"%s\"\n",
+ dispname, match_pattern);
+ return TRUE;
+ }
+ return FALSE;
+}
+#endif
+
/* Quote from RFC2818 section 3.1 "Server Identity"
@@ -1170,7 +1546,7 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
numalts = sk_GENERAL_NAME_num(altnames);
/* loop through all alternatives - until a dnsmatch */
- for(i=0; (i < numalts) && !dnsmatched; i++) {
+ for(i = 0; (i < numalts) && !dnsmatched; i++) {
/* get a handle to alternative name number i */
const GENERAL_NAME *check = sk_GENERAL_NAME_value(altnames, i);
@@ -1200,11 +1576,8 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
if((altlen == strlen(altptr)) &&
/* if this isn't true, there was an embedded zero in the name
string and we cannot match it. */
- Curl_cert_hostcheck(altptr, hostname)) {
+ subj_alt_hostcheck(data, altptr, hostname, dispname)) {
dnsmatched = TRUE;
- infof(data,
- " subjectAltName: host \"%s\" matched cert's \"%s\"\n",
- dispname, altptr);
}
break;
@@ -1239,7 +1612,7 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
else {
/* we have to look to the last occurrence of a commonName in the
distinguished one to get the most significant one. */
- int j, i=-1;
+ int j, i = -1;
/* The following is done because of a bug in 0.9.6b */
@@ -1248,14 +1621,14 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
X509_NAME *name = X509_get_subject_name(server_cert);
if(name)
- while((j = X509_NAME_get_index_by_NID(name, NID_commonName, i))>=0)
- i=j;
+ while((j = X509_NAME_get_index_by_NID(name, NID_commonName, i)) >= 0)
+ i = j;
/* we have the name entry and we will now convert this to a string
that we can use for comparison. Doing this we support BMPstring,
UTF8 etc. */
- if(i>=0) {
+ if(i >= 0) {
ASN1_STRING *tmp =
X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name, i));
@@ -1268,7 +1641,7 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
if(ASN1_STRING_type(tmp) == V_ASN1_UTF8STRING) {
j = ASN1_STRING_length(tmp);
if(j >= 0) {
- peer_CN = OPENSSL_malloc(j+1);
+ peer_CN = OPENSSL_malloc(j + 1);
if(peer_CN) {
memcpy(peer_CN, ASN1_STRING_get0_data(tmp), j);
peer_CN[j] = '\0';
@@ -1291,7 +1664,8 @@ static CURLcode verifyhost(struct connectdata *conn, X509 *server_cert)
peer_CN = NULL;
else {
/* convert peer_CN from UTF8 */
- CURLcode rc = Curl_convert_from_utf8(data, peer_CN, strlen(peer_CN));
+ CURLcode rc = Curl_convert_from_utf8(data, (char *)peer_CN,
+ strlen((char *)peer_CN));
/* Curl_convert_from_utf8 calls failf if unsuccessful */
if(rc) {
OPENSSL_free(peer_CN);
@@ -1328,6 +1702,7 @@ static CURLcode verifystatus(struct connectdata *conn,
struct ssl_connect_data *connssl)
{
int i, ocsp_status;
+ unsigned char *status;
const unsigned char *p;
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
@@ -1337,14 +1712,14 @@ static CURLcode verifystatus(struct connectdata *conn,
X509_STORE *st = NULL;
STACK_OF(X509) *ch = NULL;
- long len = SSL_get_tlsext_status_ocsp_resp(connssl->handle, &p);
+ long len = SSL_get_tlsext_status_ocsp_resp(BACKEND->handle, &status);
- if(!p) {
+ if(!status) {
failf(data, "No OCSP response received");
result = CURLE_SSL_INVALIDCERTSTATUS;
goto end;
}
-
+ p = status;
rsp = d2i_OCSP_RESPONSE(NULL, &p, len);
if(!rsp) {
failf(data, "Invalid OCSP response");
@@ -1367,8 +1742,8 @@ static CURLcode verifystatus(struct connectdata *conn,
goto end;
}
- ch = SSL_get_peer_cert_chain(connssl->handle);
- st = SSL_CTX_get_cert_store(connssl->ctx);
+ ch = SSL_get_peer_cert_chain(BACKEND->handle);
+ st = SSL_CTX_get_cert_store(BACKEND->ctx);
#if ((OPENSSL_VERSION_NUMBER <= 0x1000201fL) /* Fixed after 1.0.2a */ || \
(defined(LIBRESSL_VERSION_NUMBER) && \
@@ -1514,6 +1889,26 @@ static const char *ssl_msg_type(int ssl_ver, int msg)
case SSL3_MT_CERTIFICATE_STATUS:
return "Certificate Status";
#endif
+#ifdef SSL3_MT_ENCRYPTED_EXTENSIONS
+ case SSL3_MT_ENCRYPTED_EXTENSIONS:
+ return "Encrypted Extensions";
+#endif
+#ifdef SSL3_MT_END_OF_EARLY_DATA
+ case SSL3_MT_END_OF_EARLY_DATA:
+ return "End of early data";
+#endif
+#ifdef SSL3_MT_KEY_UPDATE
+ case SSL3_MT_KEY_UPDATE:
+ return "Key update";
+#endif
+#ifdef SSL3_MT_NEXT_PROTO
+ case SSL3_MT_NEXT_PROTO:
+ return "Next protocol";
+#endif
+#ifdef SSL3_MT_MESSAGE_HASH
+ case SSL3_MT_MESSAGE_HASH:
+ return "Message hash";
+#endif
}
}
return "Unknown";
@@ -1548,10 +1943,7 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type,
void *userp)
{
struct Curl_easy *data;
- const char *msg_name, *tls_rt_name;
- char ssl_buf[1024];
char unknown[32];
- int msg_type, txt_len;
const char *verstr = NULL;
struct connectdata *conn = userp;
@@ -1593,12 +1985,24 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type,
case 0:
break;
default:
- snprintf(unknown, sizeof(unknown), "(%x)", ssl_ver);
+ msnprintf(unknown, sizeof(unknown), "(%x)", ssl_ver);
verstr = unknown;
break;
}
- if(ssl_ver) {
+ /* Log progress for interesting records only (like Handshake or Alert), skip
+ * all raw record headers (content_type == SSL3_RT_HEADER or ssl_ver == 0).
+ * For TLS 1.3, skip notification of the decrypted inner Content Type.
+ */
+ if(ssl_ver
+#ifdef SSL3_RT_INNER_CONTENT_TYPE
+ && content_type != SSL3_RT_INNER_CONTENT_TYPE
+#endif
+ ) {
+ const char *msg_name, *tls_rt_name;
+ char ssl_buf[1024];
+ int msg_type, txt_len;
+
/* the info given when the version is zero is not that useful for us */
ssl_ver >>= 8; /* check the upper 8 bits only below */
@@ -1612,17 +2016,29 @@ static void ssl_tls_trace(int direction, int ssl_ver, int content_type,
else
tls_rt_name = "";
- msg_type = *(char *)buf;
- msg_name = ssl_msg_type(ssl_ver, msg_type);
+ if(content_type == SSL3_RT_CHANGE_CIPHER_SPEC) {
+ msg_type = *(char *)buf;
+ msg_name = "Change cipher spec";
+ }
+ else if(content_type == SSL3_RT_ALERT) {
+ msg_type = (((char *)buf)[0] << 8) + ((char *)buf)[1];
+ msg_name = SSL_alert_desc_string_long(msg_type);
+ }
+ else {
+ msg_type = *(char *)buf;
+ msg_name = ssl_msg_type(ssl_ver, msg_type);
+ }
- txt_len = snprintf(ssl_buf, sizeof(ssl_buf), "%s (%s), %s, %s (%d):\n",
- verstr, direction?"OUT":"IN",
- tls_rt_name, msg_name, msg_type);
- Curl_debug(data, CURLINFO_TEXT, ssl_buf, (size_t)txt_len, NULL);
+ txt_len = msnprintf(ssl_buf, sizeof(ssl_buf), "%s (%s), %s, %s (%d):\n",
+ verstr, direction?"OUT":"IN",
+ tls_rt_name, msg_name, msg_type);
+ if(0 <= txt_len && (unsigned)txt_len < sizeof(ssl_buf)) {
+ Curl_debug(data, CURLINFO_TEXT, ssl_buf, (size_t)txt_len);
+ }
}
Curl_debug(data, (direction == 1) ? CURLINFO_SSL_DATA_OUT :
- CURLINFO_SSL_DATA_IN, (char *)buf, len, NULL);
+ CURLINFO_SSL_DATA_IN, (char *)buf, len);
(void) ssl;
}
#endif
@@ -1711,6 +2127,7 @@ select_next_proto_cb(SSL *ssl,
}
#endif /* HAS_NPN */
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
static const char *
get_ssl_version_txt(SSL *ssl)
{
@@ -1737,6 +2154,7 @@ get_ssl_version_txt(SSL *ssl)
}
return "unknown";
}
+#endif
static CURLcode
set_ssl_version_min_max(long *ctx_options, struct connectdata *conn,
@@ -1750,23 +2168,21 @@ set_ssl_version_min_max(long *ctx_options, struct connectdata *conn,
long ssl_version = SSL_CONN_CONFIG(version);
long ssl_version_max = SSL_CONN_CONFIG(version_max);
- if(ssl_version_max == CURL_SSLVERSION_MAX_NONE) {
- ssl_version_max = ssl_version << 16;
- }
-
switch(ssl_version) {
case CURL_SSLVERSION_TLSv1_3:
#ifdef TLS1_3_VERSION
{
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- SSL_CTX_set_max_proto_version(connssl->ctx, TLS1_3_VERSION);
+ SSL_CTX_set_max_proto_version(BACKEND->ctx, TLS1_3_VERSION);
*ctx_options |= SSL_OP_NO_TLSv1_2;
}
#else
(void)sockindex;
+ (void)ctx_options;
failf(data, OSSL_PACKAGE " was built without TLS 1.3 support");
return CURLE_NOT_BUILT_IN;
#endif
+ /* FALLTHROUGH */
case CURL_SSLVERSION_TLSv1_2:
#if OPENSSL_VERSION_NUMBER >= 0x1000100FL
*ctx_options |= SSL_OP_NO_TLSv1_1;
@@ -1784,8 +2200,7 @@ set_ssl_version_min_max(long *ctx_options, struct connectdata *conn,
#endif
/* FALLTHROUGH */
case CURL_SSLVERSION_TLSv1_0:
- *ctx_options |= SSL_OP_NO_SSLv2;
- *ctx_options |= SSL_OP_NO_SSLv3;
+ case CURL_SSLVERSION_TLSv1:
break;
}
@@ -1801,7 +2216,6 @@ set_ssl_version_min_max(long *ctx_options, struct connectdata *conn,
#endif
/* FALLTHROUGH */
case CURL_SSLVERSION_MAX_TLSv1_2:
- case CURL_SSLVERSION_MAX_DEFAULT:
#ifdef TLS1_3_VERSION
*ctx_options |= SSL_OP_NO_TLSv1_3;
#endif
@@ -1817,6 +2231,62 @@ set_ssl_version_min_max(long *ctx_options, struct connectdata *conn,
return CURLE_OK;
}
+/* The "new session" callback must return zero if the session can be removed
+ * or non-zero if the session has been put into the session cache.
+ */
+static int ossl_new_session_cb(SSL *ssl, SSL_SESSION *ssl_sessionid)
+{
+ int res = 0;
+ struct connectdata *conn;
+ struct Curl_easy *data;
+ int sockindex;
+ curl_socket_t *sockindex_ptr;
+ int connectdata_idx = ossl_get_ssl_conn_index();
+ int sockindex_idx = ossl_get_ssl_sockindex_index();
+
+ if(connectdata_idx < 0 || sockindex_idx < 0)
+ return 0;
+
+ conn = (struct connectdata*) SSL_get_ex_data(ssl, connectdata_idx);
+ if(!conn)
+ return 0;
+
+ data = conn->data;
+
+ /* The sockindex has been stored as a pointer to an array element */
+ sockindex_ptr = (curl_socket_t*) SSL_get_ex_data(ssl, sockindex_idx);
+ sockindex = (int)(sockindex_ptr - conn->sock);
+
+ if(SSL_SET_OPTION(primary.sessionid)) {
+ bool incache;
+ void *old_ssl_sessionid = NULL;
+
+ Curl_ssl_sessionid_lock(conn);
+ incache = !(Curl_ssl_getsessionid(conn, &old_ssl_sessionid, NULL,
+ sockindex));
+ if(incache) {
+ if(old_ssl_sessionid != ssl_sessionid) {
+ infof(data, "old SSL session ID is stale, removing\n");
+ Curl_ssl_delsessionid(conn, old_ssl_sessionid);
+ incache = FALSE;
+ }
+ }
+
+ if(!incache) {
+ if(!Curl_ssl_addsessionid(conn, ssl_sessionid,
+ 0 /* unknown size */, sockindex)) {
+ /* the session has been put into the session cache */
+ res = 1;
+ }
+ else
+ failf(data, "failed to store ssl session");
+ }
+ Curl_ssl_sessionid_unlock(conn);
+ }
+
+ return res;
+}
+
static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
{
CURLcode result = CURLE_OK;
@@ -1870,8 +2340,7 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
case CURL_SSLVERSION_TLSv1_2:
case CURL_SSLVERSION_TLSv1_3:
/* it will be handled later with the context options */
-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && \
- !defined(LIBRESSL_VERSION_NUMBER)
+#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
req_method = TLS_client_method();
#else
req_method = SSLv23_client_method();
@@ -1909,25 +2378,25 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
return CURLE_SSL_CONNECT_ERROR;
}
- if(connssl->ctx)
- SSL_CTX_free(connssl->ctx);
- connssl->ctx = SSL_CTX_new(req_method);
+ if(BACKEND->ctx)
+ SSL_CTX_free(BACKEND->ctx);
+ BACKEND->ctx = SSL_CTX_new(req_method);
- if(!connssl->ctx) {
+ if(!BACKEND->ctx) {
failf(data, "SSL: couldn't create a context: %s",
ossl_strerror(ERR_peek_error(), error_buffer, sizeof(error_buffer)));
return CURLE_OUT_OF_MEMORY;
}
#ifdef SSL_MODE_RELEASE_BUFFERS
- SSL_CTX_set_mode(connssl->ctx, SSL_MODE_RELEASE_BUFFERS);
+ SSL_CTX_set_mode(BACKEND->ctx, SSL_MODE_RELEASE_BUFFERS);
#endif
#ifdef SSL_CTRL_SET_MSG_CALLBACK
if(data->set.fdebug && data->set.verbose) {
/* the SSL trace callback is only used for verbose logging */
- SSL_CTX_set_msg_callback(connssl->ctx, ssl_tls_trace);
- SSL_CTX_set_msg_callback_arg(connssl->ctx, conn);
+ SSL_CTX_set_msg_callback(BACKEND->ctx, ssl_tls_trace);
+ SSL_CTX_set_msg_callback_arg(BACKEND->ctx, conn);
}
#endif
@@ -1991,11 +2460,6 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
switch(ssl_version) {
case CURL_SSLVERSION_SSLv3:
-#ifdef USE_TLS_SRP
- if(ssl_authtype == CURL_TLSAUTH_SRP) {
- infof(data, "Set version TLSv1.x for SRP authorisation\n");
- }
-#endif
ctx_options |= SSL_OP_NO_SSLv2;
ctx_options |= SSL_OP_NO_TLSv1;
#if OPENSSL_VERSION_NUMBER >= 0x1000100FL
@@ -2009,21 +2473,20 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
case CURL_SSLVERSION_DEFAULT:
case CURL_SSLVERSION_TLSv1:
- ctx_options |= SSL_OP_NO_SSLv2;
- ctx_options |= SSL_OP_NO_SSLv3;
- break;
-
case CURL_SSLVERSION_TLSv1_0:
case CURL_SSLVERSION_TLSv1_1:
case CURL_SSLVERSION_TLSv1_2:
case CURL_SSLVERSION_TLSv1_3:
+ /* asking for any TLS version as the minimum, means no SSL versions
+ allowed */
+ ctx_options |= SSL_OP_NO_SSLv2;
+ ctx_options |= SSL_OP_NO_SSLv3;
result = set_ssl_version_min_max(&ctx_options, conn, sockindex);
if(result != CURLE_OK)
return result;
break;
case CURL_SSLVERSION_SSLv2:
-#ifndef OPENSSL_NO_SSL2
ctx_options |= SSL_OP_NO_SSLv3;
ctx_options |= SSL_OP_NO_TLSv1;
#if OPENSSL_VERSION_NUMBER >= 0x1000100FL
@@ -2034,21 +2497,17 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
#endif
#endif
break;
-#else
- failf(data, OSSL_PACKAGE " was built without SSLv2 support");
- return CURLE_NOT_BUILT_IN;
-#endif
default:
failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION");
return CURLE_SSL_CONNECT_ERROR;
}
- SSL_CTX_set_options(connssl->ctx, ctx_options);
+ SSL_CTX_set_options(BACKEND->ctx, ctx_options);
#ifdef HAS_NPN
if(conn->bits.tls_enable_npn)
- SSL_CTX_set_next_proto_select_cb(connssl->ctx, select_next_proto_cb, conn);
+ SSL_CTX_set_next_proto_select_cb(BACKEND->ctx, select_next_proto_cb, conn);
#endif
#ifdef HAS_ALPN
@@ -2057,7 +2516,8 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
unsigned char protocols[128];
#ifdef USE_NGHTTP2
- if(data->set.httpversion >= CURL_HTTP_VERSION_2) {
+ if(data->set.httpversion >= CURL_HTTP_VERSION_2 &&
+ (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)) {
protocols[cur++] = NGHTTP2_PROTO_VERSION_ID_LEN;
memcpy(&protocols[cur], NGHTTP2_PROTO_VERSION_ID,
@@ -2075,12 +2535,12 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
/* expects length prefixed preference ordered list of protocols in wire
* format
*/
- SSL_CTX_set_alpn_protos(connssl->ctx, protocols, cur);
+ SSL_CTX_set_alpn_protos(BACKEND->ctx, protocols, cur);
}
#endif
if(ssl_cert || ssl_cert_type) {
- if(!cert_stuff(conn, connssl->ctx, ssl_cert, ssl_cert_type,
+ if(!cert_stuff(conn, BACKEND->ctx, ssl_cert, ssl_cert_type,
SSL_SET_OPTION(key), SSL_SET_OPTION(key_type),
SSL_SET_OPTION(key_passwd))) {
/* failf() is already done in cert_stuff() */
@@ -2091,11 +2551,31 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
ciphers = SSL_CONN_CONFIG(cipher_list);
if(!ciphers)
ciphers = (char *)DEFAULT_CIPHER_SELECTION;
- if(!SSL_CTX_set_cipher_list(connssl->ctx, ciphers)) {
- failf(data, "failed setting cipher list: %s", ciphers);
- return CURLE_SSL_CIPHER;
+ if(ciphers) {
+ if(!SSL_CTX_set_cipher_list(BACKEND->ctx, ciphers)) {
+ failf(data, "failed setting cipher list: %s", ciphers);
+ return CURLE_SSL_CIPHER;
+ }
+ infof(data, "Cipher selection: %s\n", ciphers);
+ }
+
+#ifdef HAVE_SSL_CTX_SET_CIPHERSUITES
+ {
+ char *ciphers13 = SSL_CONN_CONFIG(cipher_list13);
+ if(ciphers13) {
+ if(!SSL_CTX_set_ciphersuites(BACKEND->ctx, ciphers13)) {
+ failf(data, "failed setting TLS 1.3 cipher suite: %s", ciphers13);
+ return CURLE_SSL_CIPHER;
+ }
+ infof(data, "TLS 1.3 cipher selection: %s\n", ciphers13);
+ }
}
- infof(data, "Cipher selection: %s\n", ciphers);
+#endif
+
+#ifdef HAVE_SSL_CTX_SET_POST_HANDSHAKE_AUTH
+ /* OpenSSL 1.1.1 requires clients to opt-in for PHA */
+ SSL_CTX_set_post_handshake_auth(BACKEND->ctx, 1);
+#endif
#ifdef USE_TLS_SRP
if(ssl_authtype == CURL_TLSAUTH_SRP) {
@@ -2103,18 +2583,18 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
infof(data, "Using TLS-SRP username: %s\n", ssl_username);
- if(!SSL_CTX_set_srp_username(connssl->ctx, ssl_username)) {
+ if(!SSL_CTX_set_srp_username(BACKEND->ctx, ssl_username)) {
failf(data, "Unable to set SRP user name");
return CURLE_BAD_FUNCTION_ARGUMENT;
}
- if(!SSL_CTX_set_srp_password(connssl->ctx, SSL_SET_OPTION(password))) {
+ if(!SSL_CTX_set_srp_password(BACKEND->ctx, SSL_SET_OPTION(password))) {
failf(data, "failed setting SRP password");
return CURLE_BAD_FUNCTION_ARGUMENT;
}
if(!SSL_CONN_CONFIG(cipher_list)) {
infof(data, "Setting cipher list SRP\n");
- if(!SSL_CTX_set_cipher_list(connssl->ctx, "SRP")) {
+ if(!SSL_CTX_set_cipher_list(BACKEND->ctx, "SRP")) {
failf(data, "failed setting SRP cipher list");
return CURLE_SSL_CIPHER;
}
@@ -2125,7 +2605,7 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
if(ssl_cafile || ssl_capath) {
/* tell SSL where to find CA certificates that are used to verify
the servers certificate. */
- if(!SSL_CTX_load_verify_locations(connssl->ctx, ssl_cafile, ssl_capath)) {
+ if(!SSL_CTX_load_verify_locations(BACKEND->ctx, ssl_cafile, ssl_capath)) {
if(verifypeer) {
/* Fail if we insist on successfully verifying the server. */
failf(data, "error setting certificate verify locations:\n"
@@ -2151,16 +2631,16 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
}
#ifdef CURL_CA_FALLBACK
else if(verifypeer) {
- /* verfying the peer without any CA certificates won't
+ /* verifying the peer without any CA certificates won't
work so use openssl's built in default as fallback */
- SSL_CTX_set_default_verify_paths(connssl->ctx);
+ SSL_CTX_set_default_verify_paths(BACKEND->ctx);
}
#endif
if(ssl_crlfile) {
/* tell SSL where to find CRL file that is used to check certificate
* revocation */
- lookup=X509_STORE_add_lookup(SSL_CTX_get_cert_store(connssl->ctx),
+ lookup = X509_STORE_add_lookup(SSL_CTX_get_cert_store(BACKEND->ctx),
X509_LOOKUP_file());
if(!lookup ||
(!X509_load_crl_file(lookup, ssl_crlfile, X509_FILETYPE_PEM)) ) {
@@ -2169,7 +2649,7 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
}
/* Everything is fine. */
infof(data, "successfully load CRL file:\n");
- X509_STORE_set_flags(SSL_CTX_get_cert_store(connssl->ctx),
+ X509_STORE_set_flags(SSL_CTX_get_cert_store(BACKEND->ctx),
X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL);
infof(data, " CRLfile: %s\n", ssl_crlfile);
@@ -2184,7 +2664,7 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
*/
#if defined(X509_V_FLAG_TRUSTED_FIRST) && !defined(X509_V_FLAG_NO_ALT_CHAINS)
if(verifypeer) {
- X509_STORE_set_flags(SSL_CTX_get_cert_store(connssl->ctx),
+ X509_STORE_set_flags(SSL_CTX_get_cert_store(BACKEND->ctx),
X509_V_FLAG_TRUSTED_FIRST);
}
#endif
@@ -2193,12 +2673,27 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
* fail to connect if the verification fails, or if it should continue
* anyway. In the latter case the result of the verification is checked with
* SSL_get_verify_result() below. */
- SSL_CTX_set_verify(connssl->ctx,
+ SSL_CTX_set_verify(BACKEND->ctx,
verifypeer ? SSL_VERIFY_PEER : SSL_VERIFY_NONE, NULL);
+ /* Enable logging of secrets to the file specified in env SSLKEYLOGFILE. */
+#if defined(ENABLE_SSLKEYLOGFILE) && defined(HAVE_KEYLOG_CALLBACK)
+ if(keylog_file_fp) {
+ SSL_CTX_set_keylog_callback(BACKEND->ctx, ossl_keylog_callback);
+ }
+#endif
+
+ /* Enable the session cache because it's a prerequisite for the "new session"
+ * callback. Use the "external storage" mode to avoid that OpenSSL creates
+ * an internal session cache.
+ */
+ SSL_CTX_set_session_cache_mode(BACKEND->ctx,
+ SSL_SESS_CACHE_CLIENT | SSL_SESS_CACHE_NO_INTERNAL);
+ SSL_CTX_sess_set_new_cb(BACKEND->ctx, ossl_new_session_cb);
+
/* give application a chance to interfere with SSL set up. */
if(data->set.ssl.fsslctx) {
- result = (*data->set.ssl.fsslctx)(data, connssl->ctx,
+ result = (*data->set.ssl.fsslctx)(data, BACKEND->ctx,
data->set.ssl.fsslctxp);
if(result) {
failf(data, "error signaled by ssl ctx callback");
@@ -2207,10 +2702,10 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
}
/* Lets make an SSL structure */
- if(connssl->handle)
- SSL_free(connssl->handle);
- connssl->handle = SSL_new(connssl->ctx);
- if(!connssl->handle) {
+ if(BACKEND->handle)
+ SSL_free(BACKEND->handle);
+ BACKEND->handle = SSL_new(BACKEND->ctx);
+ if(!BACKEND->handle) {
failf(data, "SSL: couldn't create a context (handle)!");
return CURLE_OUT_OF_MEMORY;
}
@@ -2218,19 +2713,23 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
#if (OPENSSL_VERSION_NUMBER >= 0x0090808fL) && !defined(OPENSSL_NO_TLSEXT) && \
!defined(OPENSSL_NO_OCSP)
if(SSL_CONN_CONFIG(verifystatus))
- SSL_set_tlsext_status_type(connssl->handle, TLSEXT_STATUSTYPE_ocsp);
+ SSL_set_tlsext_status_type(BACKEND->handle, TLSEXT_STATUSTYPE_ocsp);
+#endif
+
+#if defined(OPENSSL_IS_BORINGSSL) && defined(ALLOW_RENEG)
+ SSL_set_renegotiate_mode(BACKEND->handle, ssl_renegotiate_freely);
#endif
- SSL_set_connect_state(connssl->handle);
+ SSL_set_connect_state(BACKEND->handle);
- connssl->server_cert = 0x0;
+ BACKEND->server_cert = 0x0;
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
if((0 == Curl_inet_pton(AF_INET, hostname, &addr)) &&
#ifdef ENABLE_IPV6
(0 == Curl_inet_pton(AF_INET6, hostname, &addr)) &&
#endif
sni &&
- !SSL_set_tlsext_host_name(connssl->handle, hostname))
+ !SSL_set_tlsext_host_name(BACKEND->handle, hostname))
infof(data, "WARNING: failed to configure server name indication (SNI) "
"TLS extension\n");
#endif
@@ -2238,11 +2737,20 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
/* Check if there's a cached ID we can/should use here! */
if(SSL_SET_OPTION(primary.sessionid)) {
void *ssl_sessionid = NULL;
+ int connectdata_idx = ossl_get_ssl_conn_index();
+ int sockindex_idx = ossl_get_ssl_sockindex_index();
+
+ if(connectdata_idx >= 0 && sockindex_idx >= 0) {
+ /* Store the data needed for the "new session" callback.
+ * The sockindex is stored as a pointer to an array element. */
+ SSL_set_ex_data(BACKEND->handle, connectdata_idx, conn);
+ SSL_set_ex_data(BACKEND->handle, sockindex_idx, conn->sock + sockindex);
+ }
Curl_ssl_sessionid_lock(conn);
if(!Curl_ssl_getsessionid(conn, &ssl_sessionid, NULL, sockindex)) {
/* we got a session id, use it! */
- if(!SSL_set_session(connssl->handle, ssl_sessionid)) {
+ if(!SSL_set_session(BACKEND->handle, ssl_sessionid)) {
Curl_ssl_sessionid_unlock(conn);
failf(data, "SSL: SSL_set_session failed: %s",
ossl_strerror(ERR_get_error(), error_buffer,
@@ -2257,13 +2765,14 @@ static CURLcode ossl_connect_step1(struct connectdata *conn, int sockindex)
if(conn->proxy_ssl[sockindex].use) {
BIO *const bio = BIO_new(BIO_f_ssl());
+ SSL *handle = conn->proxy_ssl[sockindex].backend->handle;
DEBUGASSERT(ssl_connection_complete == conn->proxy_ssl[sockindex].state);
- DEBUGASSERT(conn->proxy_ssl[sockindex].handle != NULL);
+ DEBUGASSERT(handle != NULL);
DEBUGASSERT(bio != NULL);
- BIO_set_ssl(bio, conn->proxy_ssl[sockindex].handle, FALSE);
- SSL_set_bio(connssl->handle, bio, bio);
+ BIO_set_ssl(bio, handle, FALSE);
+ SSL_set_bio(BACKEND->handle, bio, bio);
}
- else if(!SSL_set_fd(connssl->handle, (int)sockfd)) {
+ else if(!SSL_set_fd(BACKEND->handle, (int)sockfd)) {
/* pass the raw socket into the SSL layers */
failf(data, "SSL: SSL_set_fd failed: %s",
ossl_strerror(ERR_get_error(), error_buffer, sizeof(error_buffer)));
@@ -2288,13 +2797,18 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
ERR_clear_error();
- err = SSL_connect(connssl->handle);
+ err = SSL_connect(BACKEND->handle);
+ /* If keylogging is enabled but the keylog callback is not supported then log
+ secrets here, immediately after SSL_connect by using tap_ssl_key. */
+#if defined(ENABLE_SSLKEYLOGFILE) && !defined(HAVE_KEYLOG_CALLBACK)
+ tap_ssl_key(BACKEND->handle, &BACKEND->tap_state);
+#endif
/* 1 is fine
0 is "not successful but was shut down controlled"
<0 is "handshake was not successful, because a fatal error occurred" */
if(1 != err) {
- int detail = SSL_get_error(connssl->handle, err);
+ int detail = SSL_get_error(BACKEND->handle, err);
if(SSL_ERROR_WANT_READ == detail) {
connssl->connecting_state = ssl_connect_2_reading;
@@ -2304,6 +2818,12 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
connssl->connecting_state = ssl_connect_2_writing;
return CURLE_OK;
}
+#ifdef SSL_ERROR_WANT_ASYNC
+ if(SSL_ERROR_WANT_ASYNC == detail) {
+ connssl->connecting_state = ssl_connect_2;
+ return CURLE_OK;
+ }
+#endif
else {
/* untreated error */
unsigned long errdetail;
@@ -2326,14 +2846,14 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
if((lib == ERR_LIB_SSL) &&
(reason == SSL_R_CERTIFICATE_VERIFY_FAILED)) {
- result = CURLE_SSL_CACERT;
+ result = CURLE_PEER_FAILED_VERIFICATION;
- lerr = SSL_get_verify_result(connssl->handle);
+ lerr = SSL_get_verify_result(BACKEND->handle);
if(lerr != X509_V_OK) {
*certverifyresult = lerr;
- snprintf(error_buffer, sizeof(error_buffer),
- "SSL certificate problem: %s",
- X509_verify_cert_error_string(lerr));
+ msnprintf(error_buffer, sizeof(error_buffer),
+ "SSL certificate problem: %s",
+ X509_verify_cert_error_string(lerr));
}
else
/* strcpy() is fine here as long as the string fits within
@@ -2372,8 +2892,8 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
/* Informational message */
infof(data, "SSL connection using %s / %s\n",
- get_ssl_version_txt(connssl->handle),
- SSL_get_cipher(connssl->handle));
+ get_ssl_version_txt(BACKEND->handle),
+ SSL_get_cipher(BACKEND->handle));
#ifdef HAS_ALPN
/* Sets data and len to negotiated protocol, len is 0 if no protocol was
@@ -2382,7 +2902,7 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
if(conn->bits.tls_enable_alpn) {
const unsigned char *neg_protocol;
unsigned int len;
- SSL_get0_alpn_selected(connssl->handle, &neg_protocol, &len);
+ SSL_get0_alpn_selected(BACKEND->handle, &neg_protocol, &len);
if(len != 0) {
infof(data, "ALPN, server accepted to use %.*s\n", len, neg_protocol);
@@ -2400,6 +2920,9 @@ static CURLcode ossl_connect_step2(struct connectdata *conn, int sockindex)
}
else
infof(data, "ALPN, server did not agree to a protocol\n");
+
+ Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ?
+ BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE);
}
#endif
@@ -2427,7 +2950,7 @@ static int asn1_object_dump(ASN1_OBJECT *a, char *buf, size_t len)
do { \
long info_len = BIO_get_mem_data(mem, &ptr); \
Curl_ssl_push_certinfo_len(data, _num, _label, ptr, info_len); \
- if(1!=BIO_reset(mem)) \
+ if(1 != BIO_reset(mem)) \
break; \
} WHILE_FALSE
@@ -2444,7 +2967,7 @@ static void pubkey_show(struct Curl_easy *data,
char *ptr;
char namebuf[32];
- snprintf(namebuf, sizeof(namebuf), "%s(%s)", type, name);
+ msnprintf(namebuf, sizeof(namebuf), "%s(%s)", type, name);
if(bn)
BN_print(mem, bn);
@@ -2475,12 +2998,12 @@ static int X509V3_ext(struct Curl_easy *data,
/* no extensions, bail out */
return 1;
- for(i=0; i < (int)sk_X509_EXTENSION_num(exts); i++) {
+ for(i = 0; i < (int)sk_X509_EXTENSION_num(exts); i++) {
ASN1_OBJECT *obj;
X509_EXTENSION *ext = sk_X509_EXTENSION_value(exts, i);
BUF_MEM *biomem;
char buf[512];
- char *ptr=buf;
+ char *ptr = buf;
char namebuf[128];
BIO *bio_out = BIO_new(BIO_s_mem());
@@ -2497,16 +3020,16 @@ static int X509V3_ext(struct Curl_easy *data,
BIO_get_mem_ptr(bio_out, &biomem);
for(j = 0; j < (size_t)biomem->length; j++) {
- const char *sep="";
+ const char *sep = "";
if(biomem->data[j] == '\n') {
- sep=", ";
+ sep = ", ";
j++; /* skip the newline */
};
while((j<(size_t)biomem->length) && (biomem->data[j] == ' '))
j++;
if(j<(size_t)biomem->length)
- ptr+=snprintf(ptr, sizeof(buf)-(ptr-buf), "%s%c", sep,
- biomem->data[j]);
+ ptr += msnprintf(ptr, sizeof(buf)-(ptr-buf), "%s%c", sep,
+ biomem->data[j]);
}
Curl_ssl_push_certinfo(data, certnum, namebuf, buf);
@@ -2528,7 +3051,7 @@ static CURLcode get_cert_chain(struct connectdata *conn,
int numcerts;
BIO *mem;
- sk = SSL_get_peer_cert_chain(connssl->handle);
+ sk = SSL_get_peer_cert_chain(BACKEND->handle);
if(!sk) {
return CURLE_OUT_OF_MEMORY;
}
@@ -2545,10 +3068,10 @@ static CURLcode get_cert_chain(struct connectdata *conn,
for(i = 0; i < numcerts; i++) {
ASN1_INTEGER *num;
X509 *x = sk_X509_value(sk, i);
- EVP_PKEY *pubkey=NULL;
+ EVP_PKEY *pubkey = NULL;
int j;
char *ptr;
- CONST_ASN1_BIT_STRING ASN1_BIT_STRING *psig = NULL;
+ const ASN1_BIT_STRING *psig = NULL;
X509_NAME_print_ex(mem, X509_get_subject_name(x), 0, XN_FLAG_ONELINE);
push_certinfo("Subject", i);
@@ -2572,7 +3095,7 @@ static CURLcode get_cert_chain(struct connectdata *conn,
ASN1_STRING *a = ASN1_STRING_new();
if(a) {
X509_get0_signature(&psig, &palg, x);
- X509_signature_print(mem, palg, a);
+ X509_signature_print(mem, ARG2_X509_signature_print palg, a);
ASN1_STRING_free(a);
if(palg) {
@@ -2706,11 +3229,6 @@ static CURLcode get_cert_chain(struct connectdata *conn,
#endif
break;
}
-#if 0
- case EVP_PKEY_EC: /* symbol not present in OpenSSL 0.9.6 */
- /* left TODO */
- break;
-#endif
}
EVP_PKEY_free(pubkey);
}
@@ -2804,10 +3322,11 @@ static CURLcode servercert(struct connectdata *conn,
{
CURLcode result = CURLE_OK;
int rc;
- long lerr, len;
+ long lerr;
struct Curl_easy *data = conn->data;
X509 *issuer;
- FILE *fp;
+ BIO *fp = NULL;
+ char error_buffer[256]="";
char buffer[2048];
const char *ptr;
long * const certverifyresult = SSL_IS_PROXY() ?
@@ -2818,8 +3337,8 @@ static CURLcode servercert(struct connectdata *conn,
/* we've been asked to gather certificate info! */
(void)get_cert_chain(conn, connssl);
- connssl->server_cert = SSL_get_peer_certificate(connssl->handle);
- if(!connssl->server_cert) {
+ BACKEND->server_cert = SSL_get_peer_certificate(BACKEND->handle);
+ if(!BACKEND->server_cert) {
BIO_free(mem);
if(!strict)
return CURLE_OK;
@@ -2830,37 +3349,42 @@ static CURLcode servercert(struct connectdata *conn,
infof(data, "%s certificate:\n", SSL_IS_PROXY() ? "Proxy" : "Server");
- rc = x509_name_oneline(X509_get_subject_name(connssl->server_cert),
+ rc = x509_name_oneline(X509_get_subject_name(BACKEND->server_cert),
buffer, sizeof(buffer));
infof(data, " subject: %s\n", rc?"[NONE]":buffer);
- ASN1_TIME_print(mem, X509_get0_notBefore(connssl->server_cert));
- len = BIO_get_mem_data(mem, (char **) &ptr);
- infof(data, " start date: %.*s\n", len, ptr);
- rc = BIO_reset(mem);
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
+ {
+ long len;
+ ASN1_TIME_print(mem, X509_get0_notBefore(BACKEND->server_cert));
+ len = BIO_get_mem_data(mem, (char **) &ptr);
+ infof(data, " start date: %.*s\n", len, ptr);
+ (void)BIO_reset(mem);
- ASN1_TIME_print(mem, X509_get0_notAfter(connssl->server_cert));
- len = BIO_get_mem_data(mem, (char **) &ptr);
- infof(data, " expire date: %.*s\n", len, ptr);
- rc = BIO_reset(mem);
+ ASN1_TIME_print(mem, X509_get0_notAfter(BACKEND->server_cert));
+ len = BIO_get_mem_data(mem, (char **) &ptr);
+ infof(data, " expire date: %.*s\n", len, ptr);
+ (void)BIO_reset(mem);
+ }
+#endif
BIO_free(mem);
if(SSL_CONN_CONFIG(verifyhost)) {
- result = verifyhost(conn, connssl->server_cert);
+ result = verifyhost(conn, BACKEND->server_cert);
if(result) {
- X509_free(connssl->server_cert);
- connssl->server_cert = NULL;
+ X509_free(BACKEND->server_cert);
+ BACKEND->server_cert = NULL;
return result;
}
}
- rc = x509_name_oneline(X509_get_issuer_name(connssl->server_cert),
+ rc = x509_name_oneline(X509_get_issuer_name(BACKEND->server_cert),
buffer, sizeof(buffer));
if(rc) {
if(strict)
failf(data, "SSL: couldn't get X509-issuer name!");
- result = CURLE_SSL_CONNECT_ERROR;
+ result = CURLE_PEER_FAILED_VERIFICATION;
}
else {
infof(data, " issuer: %s\n", buffer);
@@ -2870,45 +3394,58 @@ static CURLcode servercert(struct connectdata *conn,
/* e.g. match issuer name with provided issuer certificate */
if(SSL_SET_OPTION(issuercert)) {
- fp = fopen(SSL_SET_OPTION(issuercert), FOPEN_READTEXT);
- if(!fp) {
+ fp = BIO_new(BIO_s_file());
+ if(fp == NULL) {
+ failf(data,
+ "BIO_new return NULL, " OSSL_PACKAGE
+ " error %s",
+ ossl_strerror(ERR_get_error(), error_buffer,
+ sizeof(error_buffer)) );
+ X509_free(BACKEND->server_cert);
+ BACKEND->server_cert = NULL;
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ if(BIO_read_filename(fp, SSL_SET_OPTION(issuercert)) <= 0) {
if(strict)
failf(data, "SSL: Unable to open issuer cert (%s)",
SSL_SET_OPTION(issuercert));
- X509_free(connssl->server_cert);
- connssl->server_cert = NULL;
+ BIO_free(fp);
+ X509_free(BACKEND->server_cert);
+ BACKEND->server_cert = NULL;
return CURLE_SSL_ISSUER_ERROR;
}
- issuer = PEM_read_X509(fp, NULL, ZERO_NULL, NULL);
+ issuer = PEM_read_bio_X509(fp, NULL, ZERO_NULL, NULL);
if(!issuer) {
if(strict)
failf(data, "SSL: Unable to read issuer cert (%s)",
SSL_SET_OPTION(issuercert));
- X509_free(connssl->server_cert);
+ BIO_free(fp);
X509_free(issuer);
- fclose(fp);
+ X509_free(BACKEND->server_cert);
+ BACKEND->server_cert = NULL;
return CURLE_SSL_ISSUER_ERROR;
}
- fclose(fp);
-
- if(X509_check_issued(issuer, connssl->server_cert) != X509_V_OK) {
+ if(X509_check_issued(issuer, BACKEND->server_cert) != X509_V_OK) {
if(strict)
failf(data, "SSL: Certificate issuer check failed (%s)",
SSL_SET_OPTION(issuercert));
- X509_free(connssl->server_cert);
+ BIO_free(fp);
X509_free(issuer);
- connssl->server_cert = NULL;
+ X509_free(BACKEND->server_cert);
+ BACKEND->server_cert = NULL;
return CURLE_SSL_ISSUER_ERROR;
}
infof(data, " SSL certificate issuer check ok (%s)\n",
SSL_SET_OPTION(issuercert));
+ BIO_free(fp);
X509_free(issuer);
}
- lerr = *certverifyresult = SSL_get_verify_result(connssl->handle);
+ lerr = *certverifyresult = SSL_get_verify_result(BACKEND->handle);
if(*certverifyresult != X509_V_OK) {
if(SSL_CONN_CONFIG(verifypeer)) {
@@ -2933,8 +3470,8 @@ static CURLcode servercert(struct connectdata *conn,
if(SSL_CONN_CONFIG(verifystatus)) {
result = verifystatus(conn, connssl);
if(result) {
- X509_free(connssl->server_cert);
- connssl->server_cert = NULL;
+ X509_free(BACKEND->server_cert);
+ BACKEND->server_cert = NULL;
return result;
}
}
@@ -2947,13 +3484,13 @@ static CURLcode servercert(struct connectdata *conn,
ptr = SSL_IS_PROXY() ? data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
if(!result && ptr) {
- result = pkp_pin_peer_pubkey(data, connssl->server_cert, ptr);
+ result = pkp_pin_peer_pubkey(data, BACKEND->server_cert, ptr);
if(result)
failf(data, "SSL: public key does not match pinned public key!");
}
- X509_free(connssl->server_cert);
- connssl->server_cert = NULL;
+ X509_free(BACKEND->server_cert);
+ BACKEND->server_cert = NULL;
connssl->connecting_state = ssl_connect_done;
return result;
@@ -2962,52 +3499,10 @@ static CURLcode servercert(struct connectdata *conn,
static CURLcode ossl_connect_step3(struct connectdata *conn, int sockindex)
{
CURLcode result = CURLE_OK;
- struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
DEBUGASSERT(ssl_connect_3 == connssl->connecting_state);
- if(SSL_SET_OPTION(primary.sessionid)) {
- bool incache;
- SSL_SESSION *our_ssl_sessionid;
- void *old_ssl_sessionid = NULL;
-
- our_ssl_sessionid = SSL_get1_session(connssl->handle);
-
- /* SSL_get1_session() will increment the reference count and the session
- will stay in memory until explicitly freed with SSL_SESSION_free(3),
- regardless of its state. */
-
- Curl_ssl_sessionid_lock(conn);
- incache = !(Curl_ssl_getsessionid(conn, &old_ssl_sessionid, NULL,
- sockindex));
- if(incache) {
- if(old_ssl_sessionid != our_ssl_sessionid) {
- infof(data, "old SSL session ID is stale, removing\n");
- Curl_ssl_delsessionid(conn, old_ssl_sessionid);
- incache = FALSE;
- }
- }
-
- if(!incache) {
- result = Curl_ssl_addsessionid(conn, our_ssl_sessionid,
- 0 /* unknown size */, sockindex);
- if(result) {
- Curl_ssl_sessionid_unlock(conn);
- failf(data, "failed to store ssl session");
- return result;
- }
- }
- else {
- /* Session was incache, so refcount already incremented earlier.
- * Avoid further increments with each SSL_get1_session() call.
- * This does not free the session as refcount remains > 0
- */
- SSL_SESSION_free(our_ssl_sessionid);
- }
- Curl_ssl_sessionid_unlock(conn);
- }
-
/*
* We check certificates to authenticate the server; otherwise we risk
* man-in-the-middle attack; NEVERTHELESS, if we're told explicitly not to
@@ -3077,9 +3572,9 @@ static CURLcode ossl_connect_common(struct connectdata *conn,
if(connssl->connecting_state == ssl_connect_2_reading ||
connssl->connecting_state == ssl_connect_2_writing) {
- curl_socket_t writefd = ssl_connect_2_writing==
+ curl_socket_t writefd = ssl_connect_2_writing ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
- curl_socket_t readfd = ssl_connect_2_reading==
+ curl_socket_t readfd = ssl_connect_2_reading ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
@@ -3137,14 +3632,14 @@ static CURLcode ossl_connect_common(struct connectdata *conn,
return CURLE_OK;
}
-CURLcode Curl_ossl_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done)
+static CURLcode Curl_ossl_connect_nonblocking(struct connectdata *conn,
+ int sockindex,
+ bool *done)
{
return ossl_connect_common(conn, sockindex, TRUE, done);
}
-CURLcode Curl_ossl_connect(struct connectdata *conn, int sockindex)
+static CURLcode Curl_ossl_connect(struct connectdata *conn, int sockindex)
{
CURLcode result;
bool done = FALSE;
@@ -3158,17 +3653,23 @@ CURLcode Curl_ossl_connect(struct connectdata *conn, int sockindex)
return CURLE_OK;
}
-bool Curl_ossl_data_pending(const struct connectdata *conn, int connindex)
+static bool Curl_ossl_data_pending(const struct connectdata *conn,
+ int connindex)
{
- if(conn->ssl[connindex].handle)
- /* SSL is in use */
- return (0 != SSL_pending(conn->ssl[connindex].handle) ||
- (conn->proxy_ssl[connindex].handle &&
- 0 != SSL_pending(conn->proxy_ssl[connindex].handle))) ?
- TRUE : FALSE;
+ const struct ssl_connect_data *connssl = &conn->ssl[connindex];
+ const struct ssl_connect_data *proxyssl = &conn->proxy_ssl[connindex];
+
+ if(connssl->backend->handle && SSL_pending(connssl->backend->handle))
+ return TRUE;
+
+ if(proxyssl->backend->handle && SSL_pending(proxyssl->backend->handle))
+ return TRUE;
+
return FALSE;
}
+static size_t Curl_ossl_version(char *buffer, size_t size);
+
static ssize_t ossl_send(struct connectdata *conn,
int sockindex,
const void *mem,
@@ -3182,14 +3683,15 @@ static ssize_t ossl_send(struct connectdata *conn,
unsigned long sslerror;
int memlen;
int rc;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
ERR_clear_error();
memlen = (len > (size_t)INT_MAX) ? INT_MAX : (int)len;
- rc = SSL_write(conn->ssl[sockindex].handle, mem, memlen);
+ rc = SSL_write(BACKEND->handle, mem, memlen);
if(rc <= 0) {
- err = SSL_get_error(conn->ssl[sockindex].handle, rc);
+ err = SSL_get_error(BACKEND->handle, rc);
switch(err) {
case SSL_ERROR_WANT_READ:
@@ -3243,18 +3745,22 @@ static ssize_t ossl_recv(struct connectdata *conn, /* connection data */
unsigned long sslerror;
ssize_t nread;
int buffsize;
+ struct ssl_connect_data *connssl = &conn->ssl[num];
ERR_clear_error();
buffsize = (buffersize > (size_t)INT_MAX) ? INT_MAX : (int)buffersize;
- nread = (ssize_t)SSL_read(conn->ssl[num].handle, buf, buffsize);
+ nread = (ssize_t)SSL_read(BACKEND->handle, buf, buffsize);
if(nread <= 0) {
/* failed SSL_read */
- int err = SSL_get_error(conn->ssl[num].handle, (int)nread);
+ int err = SSL_get_error(BACKEND->handle, (int)nread);
switch(err) {
case SSL_ERROR_NONE: /* this is not an error */
+ break;
case SSL_ERROR_ZERO_RETURN: /* no more data */
+ /* close_notify alert */
+ connclose(conn, "TLS close_notify");
break;
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
@@ -3282,18 +3788,23 @@ static ssize_t ossl_recv(struct connectdata *conn, /* connection data */
return nread;
}
-size_t Curl_ossl_version(char *buffer, size_t size)
+static size_t Curl_ossl_version(char *buffer, size_t size)
{
#ifdef OPENSSL_IS_BORINGSSL
- return snprintf(buffer, size, OSSL_PACKAGE);
-#else /* OPENSSL_IS_BORINGSSL */
+ return msnprintf(buffer, size, OSSL_PACKAGE);
+#elif defined(HAVE_OPENSSL_VERSION) && defined(OPENSSL_VERSION_STRING)
+ return msnprintf(buffer, size, "%s/%s",
+ OSSL_PACKAGE, OpenSSL_version(OPENSSL_VERSION_STRING));
+#else
+ /* not BoringSSL and not using OpenSSL_version */
+
char sub[3];
unsigned long ssleay_value;
sub[2]='\0';
sub[1]='\0';
- ssleay_value=OpenSSL_version_num();
+ ssleay_value = OpenSSL_version_num();
if(ssleay_value < 0x906000) {
- ssleay_value=SSLEAY_VERSION_NUMBER;
+ ssleay_value = SSLEAY_VERSION_NUMBER;
sub[0]='\0';
}
else {
@@ -3312,18 +3823,22 @@ size_t Curl_ossl_version(char *buffer, size_t size)
sub[0]='\0';
}
- return snprintf(buffer, size, "%s/%lx.%lx.%lx%s",
- OSSL_PACKAGE,
- (ssleay_value>>28)&0xf,
- (ssleay_value>>20)&0xff,
- (ssleay_value>>12)&0xff,
- sub);
+ return msnprintf(buffer, size, "%s/%lx.%lx.%lx%s"
+#ifdef OPENSSL_FIPS
+ "-fips"
+#endif
+ ,
+ OSSL_PACKAGE,
+ (ssleay_value>>28)&0xf,
+ (ssleay_value>>20)&0xff,
+ (ssleay_value>>12)&0xff,
+ sub);
#endif /* OPENSSL_IS_BORINGSSL */
}
/* can be called with data == NULL */
-CURLcode Curl_ossl_random(struct Curl_easy *data, unsigned char *entropy,
- size_t length)
+static CURLcode Curl_ossl_random(struct Curl_easy *data,
+ unsigned char *entropy, size_t length)
{
int rc;
if(data) {
@@ -3339,33 +3854,43 @@ CURLcode Curl_ossl_random(struct Curl_easy *data, unsigned char *entropy,
return (rc == 1 ? CURLE_OK : CURLE_FAILED_INIT);
}
-void Curl_ossl_md5sum(unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *md5sum /* output */,
- size_t unused)
+static CURLcode Curl_ossl_md5sum(unsigned char *tmp, /* input */
+ size_t tmplen,
+ unsigned char *md5sum /* output */,
+ size_t unused)
{
- MD5_CTX MD5pw;
- (void)unused;
- MD5_Init(&MD5pw);
- MD5_Update(&MD5pw, tmp, tmplen);
- MD5_Final(md5sum, &MD5pw);
+ EVP_MD_CTX *mdctx;
+ unsigned int len = 0;
+ (void) unused;
+
+ mdctx = EVP_MD_CTX_create();
+ EVP_DigestInit_ex(mdctx, EVP_md5(), NULL);
+ EVP_DigestUpdate(mdctx, tmp, tmplen);
+ EVP_DigestFinal_ex(mdctx, md5sum, &len);
+ EVP_MD_CTX_destroy(mdctx);
+ return CURLE_OK;
}
#if (OPENSSL_VERSION_NUMBER >= 0x0090800fL) && !defined(OPENSSL_NO_SHA256)
-void Curl_ossl_sha256sum(const unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *sha256sum /* output */,
- size_t unused)
+static CURLcode Curl_ossl_sha256sum(const unsigned char *tmp, /* input */
+ size_t tmplen,
+ unsigned char *sha256sum /* output */,
+ size_t unused)
{
- SHA256_CTX SHA256pw;
- (void)unused;
- SHA256_Init(&SHA256pw);
- SHA256_Update(&SHA256pw, tmp, tmplen);
- SHA256_Final(sha256sum, &SHA256pw);
+ EVP_MD_CTX *mdctx;
+ unsigned int len = 0;
+ (void) unused;
+
+ mdctx = EVP_MD_CTX_create();
+ EVP_DigestInit_ex(mdctx, EVP_sha256(), NULL);
+ EVP_DigestUpdate(mdctx, tmp, tmplen);
+ EVP_DigestFinal_ex(mdctx, sha256sum, &len);
+ EVP_MD_CTX_destroy(mdctx);
+ return CURLE_OK;
}
#endif
-bool Curl_ossl_cert_status_request(void)
+static bool Curl_ossl_cert_status_request(void)
{
#if (OPENSSL_VERSION_NUMBER >= 0x0090808fL) && !defined(OPENSSL_NO_TLSEXT) && \
!defined(OPENSSL_NO_OCSP)
@@ -3374,4 +3899,53 @@ bool Curl_ossl_cert_status_request(void)
return FALSE;
#endif
}
+
+static void *Curl_ossl_get_internals(struct ssl_connect_data *connssl,
+ CURLINFO info)
+{
+ /* Legacy: CURLINFO_TLS_SESSION must return an SSL_CTX pointer. */
+ return info == CURLINFO_TLS_SESSION ?
+ (void *)BACKEND->ctx : (void *)BACKEND->handle;
+}
+
+const struct Curl_ssl Curl_ssl_openssl = {
+ { CURLSSLBACKEND_OPENSSL, "openssl" }, /* info */
+
+ SSLSUPP_CA_PATH |
+ SSLSUPP_CERTINFO |
+ SSLSUPP_PINNEDPUBKEY |
+ SSLSUPP_SSL_CTX |
+#ifdef HAVE_SSL_CTX_SET_CIPHERSUITES
+ SSLSUPP_TLS13_CIPHERSUITES |
+#endif
+ SSLSUPP_HTTPS_PROXY,
+
+ sizeof(struct ssl_backend_data),
+
+ Curl_ossl_init, /* init */
+ Curl_ossl_cleanup, /* cleanup */
+ Curl_ossl_version, /* version */
+ Curl_ossl_check_cxn, /* check_cxn */
+ Curl_ossl_shutdown, /* shutdown */
+ Curl_ossl_data_pending, /* data_pending */
+ Curl_ossl_random, /* random */
+ Curl_ossl_cert_status_request, /* cert_status_request */
+ Curl_ossl_connect, /* connect */
+ Curl_ossl_connect_nonblocking, /* connect_nonblocking */
+ Curl_ossl_get_internals, /* get_internals */
+ Curl_ossl_close, /* close_one */
+ Curl_ossl_close_all, /* close_all */
+ Curl_ossl_session_free, /* session_free */
+ Curl_ossl_set_engine, /* set_engine */
+ Curl_ossl_set_engine_default, /* set_engine_default */
+ Curl_ossl_engines_list, /* engines_list */
+ Curl_none_false_start, /* false_start */
+ Curl_ossl_md5sum, /* md5sum */
+#if (OPENSSL_VERSION_NUMBER >= 0x0090800fL) && !defined(OPENSSL_NO_SHA256)
+ Curl_ossl_sha256sum /* sha256sum */
+#else
+ NULL /* sha256sum */
+#endif
+};
+
#endif /* USE_OPENSSL */
diff --git a/Utilities/cmcurl/lib/vtls/openssl.h b/Utilities/cmcurl/lib/vtls/openssl.h
index b9648d514..114dc4bae 100644
--- a/Utilities/cmcurl/lib/vtls/openssl.h
+++ b/Utilities/cmcurl/lib/vtls/openssl.h
@@ -31,96 +31,7 @@
#include "urldata.h"
-CURLcode Curl_ossl_connect(struct connectdata *conn, int sockindex);
-CURLcode Curl_ossl_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done);
-
-/* close a SSL connection */
-void Curl_ossl_close(struct connectdata *conn, int sockindex);
-
-/* tell OpenSSL to close down all open information regarding connections (and
- thus session ID caching etc) */
-void Curl_ossl_close_all(struct Curl_easy *data);
-
-/* Sets an OpenSSL engine */
-CURLcode Curl_ossl_set_engine(struct Curl_easy *data, const char *engine);
-
-/* function provided for the generic SSL-layer, called when a session id
- should be freed */
-void Curl_ossl_session_free(void *ptr);
-
-/* Sets engine as default for all SSL operations */
-CURLcode Curl_ossl_set_engine_default(struct Curl_easy *data);
-
-/* Build list of OpenSSL engines */
-struct curl_slist *Curl_ossl_engines_list(struct Curl_easy *data);
-
-int Curl_ossl_init(void);
-void Curl_ossl_cleanup(void);
-
-size_t Curl_ossl_version(char *buffer, size_t size);
-int Curl_ossl_check_cxn(struct connectdata *cxn);
-int Curl_ossl_shutdown(struct connectdata *conn, int sockindex);
-bool Curl_ossl_data_pending(const struct connectdata *conn,
- int connindex);
-
-/* return 0 if a find random is filled in */
-CURLcode Curl_ossl_random(struct Curl_easy *data, unsigned char *entropy,
- size_t length);
-void Curl_ossl_md5sum(unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *md5sum /* output */,
- size_t unused);
-void Curl_ossl_sha256sum(const unsigned char *tmp, /* input */
- size_t tmplen,
- unsigned char *sha256sum /* output */,
- size_t unused);
-
-bool Curl_ossl_cert_status_request(void);
-
-/* Support HTTPS-proxy */
-#define HTTPS_PROXY_SUPPORT 1
-
-/* Set the API backend definition to OpenSSL */
-#define CURL_SSL_BACKEND CURLSSLBACKEND_OPENSSL
-
-/* this backend supports the CAPATH option */
-#define have_curlssl_ca_path 1
-
-/* this backend supports CURLOPT_CERTINFO */
-#define have_curlssl_certinfo 1
-
-/* this backend supports CURLOPT_SSL_CTX_* */
-#define have_curlssl_ssl_ctx 1
-
-/* this backend supports CURLOPT_PINNEDPUBLICKEY */
-#define have_curlssl_pinnedpubkey 1
-
-/* API setup for OpenSSL */
-#define curlssl_init Curl_ossl_init
-#define curlssl_cleanup Curl_ossl_cleanup
-#define curlssl_connect Curl_ossl_connect
-#define curlssl_connect_nonblocking Curl_ossl_connect_nonblocking
-#define curlssl_session_free(x) Curl_ossl_session_free(x)
-#define curlssl_close_all Curl_ossl_close_all
-#define curlssl_close Curl_ossl_close
-#define curlssl_shutdown(x,y) Curl_ossl_shutdown(x,y)
-#define curlssl_set_engine(x,y) Curl_ossl_set_engine(x,y)
-#define curlssl_set_engine_default(x) Curl_ossl_set_engine_default(x)
-#define curlssl_engines_list(x) Curl_ossl_engines_list(x)
-#define curlssl_version Curl_ossl_version
-#define curlssl_check_cxn Curl_ossl_check_cxn
-#define curlssl_data_pending(x,y) Curl_ossl_data_pending(x,y)
-#define curlssl_random(x,y,z) Curl_ossl_random(x,y,z)
-#define curlssl_md5sum(a,b,c,d) Curl_ossl_md5sum(a,b,c,d)
-#if (OPENSSL_VERSION_NUMBER >= 0x0090800fL) && !defined(OPENSSL_NO_SHA256)
-#define curlssl_sha256sum(a,b,c,d) Curl_ossl_sha256sum(a,b,c,d)
-#endif
-#define curlssl_cert_status_request() Curl_ossl_cert_status_request()
-
-#define DEFAULT_CIPHER_SELECTION \
- "ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH"
+extern const struct Curl_ssl Curl_ssl_openssl;
#endif /* USE_OPENSSL */
#endif /* HEADER_CURL_SSLUSE_H */
diff --git a/Utilities/cmcurl/lib/vtls/polarssl.c b/Utilities/cmcurl/lib/vtls/polarssl.c
index 669091cb5..7ea26b442 100644
--- a/Utilities/cmcurl/lib/vtls/polarssl.c
+++ b/Utilities/cmcurl/lib/vtls/polarssl.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2012 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2010 - 2011, Hoi-Ho Chan, <hoiho.chan@gmail.com>
*
* This software is licensed as described in the file COPYING, which
@@ -30,7 +30,6 @@
#include "curl_setup.h"
#ifdef USE_POLARSSL
-
#include <polarssl/net.h>
#include <polarssl/ssl.h>
#include <polarssl/certs.h>
@@ -56,6 +55,7 @@
#include "select.h"
#include "strcase.h"
#include "polarssl_threadlock.h"
+#include "multiif.h"
#include "curl_printf.h"
#include "curl_memory.h"
/* The last #include file should be: */
@@ -70,6 +70,19 @@
#define PUB_DER_MAX_BYTES (RSA_PUB_DER_MAX_BYTES > ECP_PUB_DER_MAX_BYTES ? \
RSA_PUB_DER_MAX_BYTES : ECP_PUB_DER_MAX_BYTES)
+struct ssl_backend_data {
+ ctr_drbg_context ctr_drbg;
+ entropy_context entropy;
+ ssl_context ssl;
+ int server_fd;
+ x509_crt cacert;
+ x509_crt clicert;
+ x509_crl crl;
+ rsa_context rsa;
+};
+
+#define BACKEND connssl->backend
+
/* apply threading? */
#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
#define THREADING_SUPPORT
@@ -173,14 +186,11 @@ set_ssl_version_min_max(struct connectdata *conn, int sockindex)
case CURL_SSLVERSION_DEFAULT:
case CURL_SSLVERSION_TLSv1:
ssl_version = CURL_SSLVERSION_TLSv1_0;
- ssl_version_max = CURL_SSLVERSION_MAX_TLSv1_2;
break;
}
switch(ssl_version_max) {
case CURL_SSLVERSION_MAX_NONE:
- ssl_version_max = ssl_version << 16;
- break;
case CURL_SSLVERSION_MAX_DEFAULT:
ssl_version_max = CURL_SSLVERSION_MAX_TLSv1_2;
break;
@@ -197,8 +207,8 @@ set_ssl_version_min_max(struct connectdata *conn, int sockindex)
return result;
}
- ssl_set_min_version(&connssl->ssl, SSL_MAJOR_VERSION_3, ssl_min_ver);
- ssl_set_max_version(&connssl->ssl, SSL_MAJOR_VERSION_3, ssl_max_ver);
+ ssl_set_min_version(&BACKEND->ssl, SSL_MAJOR_VERSION_3, ssl_min_ver);
+ ssl_set_max_version(&BACKEND->ssl, SSL_MAJOR_VERSION_3, ssl_max_ver);
return result;
}
@@ -215,7 +225,7 @@ polarssl_connect_step1(struct connectdata *conn,
const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port;
int ret = -1;
char errorbuf[128];
- errorbuf[0]=0;
+ errorbuf[0] = 0;
/* PolarSSL only supports SSLv3 and TLSv1 */
if(SSL_CONN_CONFIG(version) == CURL_SSLVERSION_SSLv2) {
@@ -226,16 +236,16 @@ polarssl_connect_step1(struct connectdata *conn,
#ifdef THREADING_SUPPORT
entropy_init_mutex(&entropy);
- if((ret = ctr_drbg_init(&connssl->ctr_drbg, entropy_func_mutex, &entropy,
+ if((ret = ctr_drbg_init(&BACKEND->ctr_drbg, entropy_func_mutex, &entropy,
NULL, 0)) != 0) {
error_strerror(ret, errorbuf, sizeof(errorbuf));
failf(data, "Failed - PolarSSL: ctr_drbg_init returned (-0x%04X) %s\n",
-ret, errorbuf);
}
#else
- entropy_init(&connssl->entropy);
+ entropy_init(&BACKEND->entropy);
- if((ret = ctr_drbg_init(&connssl->ctr_drbg, entropy_func, &connssl->entropy,
+ if((ret = ctr_drbg_init(&BACKEND->ctr_drbg, entropy_func, &BACKEND->entropy,
NULL, 0)) != 0) {
error_strerror(ret, errorbuf, sizeof(errorbuf));
failf(data, "Failed - PolarSSL: ctr_drbg_init returned (-0x%04X) %s\n",
@@ -244,10 +254,10 @@ polarssl_connect_step1(struct connectdata *conn,
#endif /* THREADING_SUPPORT */
/* Load the trusted CA */
- memset(&connssl->cacert, 0, sizeof(x509_crt));
+ memset(&BACKEND->cacert, 0, sizeof(x509_crt));
if(SSL_CONN_CONFIG(CAfile)) {
- ret = x509_crt_parse_file(&connssl->cacert,
+ ret = x509_crt_parse_file(&BACKEND->cacert,
SSL_CONN_CONFIG(CAfile));
if(ret<0) {
@@ -261,7 +271,7 @@ polarssl_connect_step1(struct connectdata *conn,
}
if(capath) {
- ret = x509_crt_parse_path(&connssl->cacert, capath);
+ ret = x509_crt_parse_path(&BACKEND->cacert, capath);
if(ret<0) {
error_strerror(ret, errorbuf, sizeof(errorbuf));
@@ -274,10 +284,10 @@ polarssl_connect_step1(struct connectdata *conn,
}
/* Load the client certificate */
- memset(&connssl->clicert, 0, sizeof(x509_crt));
+ memset(&BACKEND->clicert, 0, sizeof(x509_crt));
if(SSL_SET_OPTION(cert)) {
- ret = x509_crt_parse_file(&connssl->clicert,
+ ret = x509_crt_parse_file(&BACKEND->clicert,
SSL_SET_OPTION(cert));
if(ret) {
@@ -298,9 +308,9 @@ polarssl_connect_step1(struct connectdata *conn,
if(ret == 0 && !pk_can_do(&pk, POLARSSL_PK_RSA))
ret = POLARSSL_ERR_PK_TYPE_MISMATCH;
if(ret == 0)
- rsa_copy(&connssl->rsa, pk_rsa(pk));
+ rsa_copy(&BACKEND->rsa, pk_rsa(pk));
else
- rsa_free(&connssl->rsa);
+ rsa_free(&BACKEND->rsa);
pk_free(&pk);
if(ret) {
@@ -313,10 +323,10 @@ polarssl_connect_step1(struct connectdata *conn,
}
/* Load the CRL */
- memset(&connssl->crl, 0, sizeof(x509_crl));
+ memset(&BACKEND->crl, 0, sizeof(x509_crl));
if(SSL_SET_OPTION(CRLfile)) {
- ret = x509_crl_parse_file(&connssl->crl,
+ ret = x509_crl_parse_file(&BACKEND->crl,
SSL_SET_OPTION(CRLfile));
if(ret) {
@@ -330,7 +340,7 @@ polarssl_connect_step1(struct connectdata *conn,
infof(data, "PolarSSL: Connecting to %s:%d\n", hostname, port);
- if(ssl_init(&connssl->ssl)) {
+ if(ssl_init(&BACKEND->ssl)) {
failf(data, "PolarSSL: ssl_init failed");
return CURLE_SSL_CONNECT_ERROR;
}
@@ -338,13 +348,13 @@ polarssl_connect_step1(struct connectdata *conn,
switch(SSL_CONN_CONFIG(version)) {
case CURL_SSLVERSION_DEFAULT:
case CURL_SSLVERSION_TLSv1:
- ssl_set_min_version(&connssl->ssl, SSL_MAJOR_VERSION_3,
+ ssl_set_min_version(&BACKEND->ssl, SSL_MAJOR_VERSION_3,
SSL_MINOR_VERSION_1);
break;
case CURL_SSLVERSION_SSLv3:
- ssl_set_min_version(&connssl->ssl, SSL_MAJOR_VERSION_3,
+ ssl_set_min_version(&BACKEND->ssl, SSL_MAJOR_VERSION_3,
SSL_MINOR_VERSION_0);
- ssl_set_max_version(&connssl->ssl, SSL_MAJOR_VERSION_3,
+ ssl_set_max_version(&BACKEND->ssl, SSL_MAJOR_VERSION_3,
SSL_MINOR_VERSION_0);
infof(data, "PolarSSL: Forced min. SSL Version to be SSLv3\n");
break;
@@ -363,16 +373,16 @@ polarssl_connect_step1(struct connectdata *conn,
return CURLE_SSL_CONNECT_ERROR;
}
- ssl_set_endpoint(&connssl->ssl, SSL_IS_CLIENT);
- ssl_set_authmode(&connssl->ssl, SSL_VERIFY_OPTIONAL);
+ ssl_set_endpoint(&BACKEND->ssl, SSL_IS_CLIENT);
+ ssl_set_authmode(&BACKEND->ssl, SSL_VERIFY_OPTIONAL);
- ssl_set_rng(&connssl->ssl, ctr_drbg_random,
- &connssl->ctr_drbg);
- ssl_set_bio(&connssl->ssl,
+ ssl_set_rng(&BACKEND->ssl, ctr_drbg_random,
+ &BACKEND->ctr_drbg);
+ ssl_set_bio(&BACKEND->ssl,
net_recv, &conn->sock[sockindex],
net_send, &conn->sock[sockindex]);
- ssl_set_ciphersuites(&connssl->ssl, ssl_list_ciphersuites());
+ ssl_set_ciphersuites(&BACKEND->ssl, ssl_list_ciphersuites());
/* Check if there's a cached ID we can/should use here! */
if(SSL_SET_OPTION(primary.sessionid)) {
@@ -380,7 +390,7 @@ polarssl_connect_step1(struct connectdata *conn,
Curl_ssl_sessionid_lock(conn);
if(!Curl_ssl_getsessionid(conn, &old_session, NULL, sockindex)) {
- ret = ssl_set_session(&connssl->ssl, old_session);
+ ret = ssl_set_session(&BACKEND->ssl, old_session);
if(ret) {
Curl_ssl_sessionid_unlock(conn);
failf(data, "ssl_set_session returned -0x%x", -ret);
@@ -391,15 +401,15 @@ polarssl_connect_step1(struct connectdata *conn,
Curl_ssl_sessionid_unlock(conn);
}
- ssl_set_ca_chain(&connssl->ssl,
- &connssl->cacert,
- &connssl->crl,
+ ssl_set_ca_chain(&BACKEND->ssl,
+ &BACKEND->cacert,
+ &BACKEND->crl,
hostname);
- ssl_set_own_cert_rsa(&connssl->ssl,
- &connssl->clicert, &connssl->rsa);
+ ssl_set_own_cert_rsa(&BACKEND->ssl,
+ &BACKEND->clicert, &BACKEND->rsa);
- if(ssl_set_hostname(&connssl->ssl, hostname)) {
+ if(ssl_set_hostname(&BACKEND->ssl, hostname)) {
/* ssl_set_hostname() sets the name to use in CN/SAN checks *and* the name
to set in the SNI extension. So even if curl connects to a host
specified as an IP address, this function must be used. */
@@ -424,12 +434,12 @@ polarssl_connect_step1(struct connectdata *conn,
protocols[cur] = NULL;
- ssl_set_alpn_protocols(&connssl->ssl, protocols);
+ ssl_set_alpn_protocols(&BACKEND->ssl, protocols);
}
#endif
#ifdef POLARSSL_DEBUG
- ssl_set_dbg(&connssl->ssl, polarssl_debug, data);
+ ssl_set_dbg(&BACKEND->ssl, polarssl_debug, data);
#endif
connssl->connecting_state = ssl_connect_2;
@@ -456,7 +466,7 @@ polarssl_connect_step2(struct connectdata *conn,
conn->recv[sockindex] = polarssl_recv;
conn->send[sockindex] = polarssl_send;
- ret = ssl_handshake(&connssl->ssl);
+ ret = ssl_handshake(&BACKEND->ssl);
switch(ret) {
case 0:
@@ -478,9 +488,9 @@ polarssl_connect_step2(struct connectdata *conn,
}
infof(data, "PolarSSL: Handshake complete, cipher is %s\n",
- ssl_get_ciphersuite(&conn->ssl[sockindex].ssl) );
+ ssl_get_ciphersuite(&BACKEND->ssl) );
- ret = ssl_get_verify_result(&conn->ssl[sockindex].ssl);
+ ret = ssl_get_verify_result(&BACKEND->ssl);
if(ret && SSL_CONN_CONFIG(verifypeer)) {
if(ret & BADCERT_EXPIRED)
@@ -488,7 +498,7 @@ polarssl_connect_step2(struct connectdata *conn,
if(ret & BADCERT_REVOKED) {
failf(data, "Cert verify failed: BADCERT_REVOKED");
- return CURLE_SSL_CACERT;
+ return CURLE_PEER_FAILED_VERIFICATION;
}
if(ret & BADCERT_CN_MISMATCH)
@@ -500,12 +510,12 @@ polarssl_connect_step2(struct connectdata *conn,
return CURLE_PEER_FAILED_VERIFICATION;
}
- if(ssl_get_peer_cert(&(connssl->ssl))) {
+ if(ssl_get_peer_cert(&(BACKEND->ssl))) {
/* If the session was resumed, there will be no peer certs */
memset(buffer, 0, sizeof(buffer));
if(x509_crt_info(buffer, sizeof(buffer), (char *)"* ",
- ssl_get_peer_cert(&(connssl->ssl))) != -1)
+ ssl_get_peer_cert(&(BACKEND->ssl))) != -1)
infof(data, "Dumping cert info:\n%s\n", buffer);
}
@@ -517,7 +527,7 @@ polarssl_connect_step2(struct connectdata *conn,
unsigned char pubkey[PUB_DER_MAX_BYTES];
const x509_crt *peercert;
- peercert = ssl_get_peer_cert(&connssl->ssl);
+ peercert = ssl_get_peer_cert(&BACKEND->ssl);
if(!peercert || !peercert->raw.p || !peercert->raw.len) {
failf(data, "Failed due to missing peer certificate");
@@ -566,7 +576,7 @@ polarssl_connect_step2(struct connectdata *conn,
#ifdef HAS_ALPN
if(conn->bits.tls_enable_alpn) {
- const char *next_protocol = ssl_get_alpn_protocol(&connssl->ssl);
+ const char *next_protocol = ssl_get_alpn_protocol(&BACKEND->ssl);
if(next_protocol != NULL) {
infof(data, "ALPN, server accepted to use %s\n", next_protocol);
@@ -584,6 +594,8 @@ polarssl_connect_step2(struct connectdata *conn,
}
else
infof(data, "ALPN, server did not agree to a protocol\n");
+ Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ?
+ BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE);
}
#endif
@@ -608,13 +620,11 @@ polarssl_connect_step3(struct connectdata *conn,
ssl_session *our_ssl_sessionid;
void *old_ssl_sessionid = NULL;
- our_ssl_sessionid = malloc(sizeof(ssl_session));
+ our_ssl_sessionid = calloc(1, sizeof(ssl_session));
if(!our_ssl_sessionid)
return CURLE_OUT_OF_MEMORY;
- memset(our_ssl_sessionid, 0, sizeof(ssl_session));
-
- ret = ssl_get_session(&connssl->ssl, our_ssl_sessionid);
+ ret = ssl_get_session(&BACKEND->ssl, our_ssl_sessionid);
if(ret) {
failf(data, "ssl_get_session returned -0x%x", -ret);
return CURLE_SSL_CONNECT_ERROR;
@@ -645,9 +655,10 @@ static ssize_t polarssl_send(struct connectdata *conn,
size_t len,
CURLcode *curlcode)
{
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
int ret = -1;
- ret = ssl_write(&conn->ssl[sockindex].ssl,
+ ret = ssl_write(&BACKEND->ssl,
(unsigned char *)mem, len);
if(ret < 0) {
@@ -659,13 +670,14 @@ static ssize_t polarssl_send(struct connectdata *conn,
return ret;
}
-void Curl_polarssl_close(struct connectdata *conn, int sockindex)
+static void Curl_polarssl_close(struct connectdata *conn, int sockindex)
{
- rsa_free(&conn->ssl[sockindex].rsa);
- x509_crt_free(&conn->ssl[sockindex].clicert);
- x509_crt_free(&conn->ssl[sockindex].cacert);
- x509_crl_free(&conn->ssl[sockindex].crl);
- ssl_free(&conn->ssl[sockindex].ssl);
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ rsa_free(&BACKEND->rsa);
+ x509_crt_free(&BACKEND->clicert);
+ x509_crt_free(&BACKEND->cacert);
+ x509_crl_free(&BACKEND->crl);
+ ssl_free(&BACKEND->ssl);
}
static ssize_t polarssl_recv(struct connectdata *conn,
@@ -674,11 +686,12 @@ static ssize_t polarssl_recv(struct connectdata *conn,
size_t buffersize,
CURLcode *curlcode)
{
+ struct ssl_connect_data *connssl = &conn->ssl[num];
int ret = -1;
ssize_t len = -1;
memset(buf, 0, buffersize);
- ret = ssl_read(&conn->ssl[num].ssl, (unsigned char *)buf, buffersize);
+ ret = ssl_read(&BACKEND->ssl, (unsigned char *)buf, buffersize);
if(ret <= 0) {
if(ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY)
@@ -694,7 +707,7 @@ static ssize_t polarssl_recv(struct connectdata *conn,
return len;
}
-void Curl_polarssl_session_free(void *ptr)
+static void Curl_polarssl_session_free(void *ptr)
{
ssl_session_free(ptr);
free(ptr);
@@ -703,12 +716,12 @@ void Curl_polarssl_session_free(void *ptr)
/* 1.3.10 was the first rebranded version. All new releases (in 1.3 branch and
higher) will be mbed TLS branded.. */
-size_t Curl_polarssl_version(char *buffer, size_t size)
+static size_t Curl_polarssl_version(char *buffer, size_t size)
{
unsigned int version = version_get_number();
- return snprintf(buffer, size, "%s/%d.%d.%d",
- version >= 0x01030A00?"mbedTLS":"PolarSSL",
- version>>24, (version>>16)&0xff, (version>>8)&0xff);
+ return msnprintf(buffer, size, "%s/%d.%d.%d",
+ version >= 0x01030A00?"mbedTLS":"PolarSSL",
+ version>>24, (version>>16)&0xff, (version>>8)&0xff);
}
static CURLcode
@@ -762,9 +775,9 @@ polarssl_connect_common(struct connectdata *conn,
if(connssl->connecting_state == ssl_connect_2_reading ||
connssl->connecting_state == ssl_connect_2_writing) {
- curl_socket_t writefd = ssl_connect_2_writing==
+ curl_socket_t writefd = ssl_connect_2_writing ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
- curl_socket_t readfd = ssl_connect_2_reading==
+ curl_socket_t readfd = ssl_connect_2_reading ==
connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
@@ -825,18 +838,14 @@ polarssl_connect_common(struct connectdata *conn,
return CURLE_OK;
}
-CURLcode
-Curl_polarssl_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done)
+static CURLcode Curl_polarssl_connect_nonblocking(struct connectdata *conn,
+ int sockindex, bool *done)
{
return polarssl_connect_common(conn, sockindex, TRUE, done);
}
-CURLcode
-Curl_polarssl_connect(struct connectdata *conn,
- int sockindex)
+static CURLcode Curl_polarssl_connect(struct connectdata *conn, int sockindex)
{
CURLcode result;
bool done = FALSE;
@@ -854,20 +863,69 @@ Curl_polarssl_connect(struct connectdata *conn,
* return 0 error initializing SSL
* return 1 SSL initialized successfully
*/
-int Curl_polarssl_init(void)
+static int Curl_polarssl_init(void)
{
return Curl_polarsslthreadlock_thread_setup();
}
-void Curl_polarssl_cleanup(void)
+static void Curl_polarssl_cleanup(void)
{
(void)Curl_polarsslthreadlock_thread_cleanup();
}
+static bool Curl_polarssl_data_pending(const struct connectdata *conn,
+ int sockindex)
+{
+ const struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ return ssl_get_bytes_avail(&BACKEND->ssl) != 0;
+}
+
+static CURLcode Curl_polarssl_sha256sum(const unsigned char *input,
+ size_t inputlen,
+ unsigned char *sha256sum,
+ size_t sha256len UNUSED_PARAM)
+{
+ (void)sha256len;
+ sha256(input, inputlen, sha256sum, 0);
+ return CURLE_OK;
+}
-int Curl_polarssl_data_pending(const struct connectdata *conn, int sockindex)
+static void *Curl_polarssl_get_internals(struct ssl_connect_data *connssl,
+ CURLINFO info UNUSED_PARAM)
{
- return ssl_get_bytes_avail(&conn->ssl[sockindex].ssl) != 0;
+ (void)info;
+ return &BACKEND->ssl;
}
+const struct Curl_ssl Curl_ssl_polarssl = {
+ { CURLSSLBACKEND_POLARSSL, "polarssl" }, /* info */
+
+ SSLSUPP_CA_PATH |
+ SSLSUPP_PINNEDPUBKEY,
+
+ sizeof(struct ssl_backend_data),
+
+ Curl_polarssl_init, /* init */
+ Curl_polarssl_cleanup, /* cleanup */
+ Curl_polarssl_version, /* version */
+ Curl_none_check_cxn, /* check_cxn */
+ Curl_none_shutdown, /* shutdown */
+ Curl_polarssl_data_pending, /* data_pending */
+ /* This might cause libcurl to use a weeker random! */
+ Curl_none_random, /* random */
+ Curl_none_cert_status_request, /* cert_status_request */
+ Curl_polarssl_connect, /* connect */
+ Curl_polarssl_connect_nonblocking, /* connect_nonblocking */
+ Curl_polarssl_get_internals, /* get_internals */
+ Curl_polarssl_close, /* close_one */
+ Curl_none_close_all, /* close_all */
+ Curl_polarssl_session_free, /* session_free */
+ Curl_none_set_engine, /* set_engine */
+ Curl_none_set_engine_default, /* set_engine_default */
+ Curl_none_engines_list, /* engines_list */
+ Curl_none_false_start, /* false_start */
+ Curl_none_md5sum, /* md5sum */
+ Curl_polarssl_sha256sum /* sha256sum */
+};
+
#endif /* USE_POLARSSL */
diff --git a/Utilities/cmcurl/lib/vtls/polarssl.h b/Utilities/cmcurl/lib/vtls/polarssl.h
index 47af7b417..23c3636ee 100644
--- a/Utilities/cmcurl/lib/vtls/polarssl.h
+++ b/Utilities/cmcurl/lib/vtls/polarssl.h
@@ -26,57 +26,7 @@
#ifdef USE_POLARSSL
-#include <polarssl/sha256.h>
-
-/* Called on first use PolarSSL, setup threading if supported */
-int Curl_polarssl_init(void);
-void Curl_polarssl_cleanup(void);
-int Curl_polarssl_data_pending(const struct connectdata *conn, int sockindex);
-
-
-CURLcode Curl_polarssl_connect(struct connectdata *conn, int sockindex);
-
-CURLcode Curl_polarssl_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done);
-
- /* close a SSL connection */
-void Curl_polarssl_close(struct connectdata *conn, int sockindex);
-
-void Curl_polarssl_session_free(void *ptr);
-size_t Curl_polarssl_version(char *buffer, size_t size);
-int Curl_polarssl_shutdown(struct connectdata *conn, int sockindex);
-
-/* Set the API backend definition to PolarSSL */
-#define CURL_SSL_BACKEND CURLSSLBACKEND_POLARSSL
-
-/* this backend supports the CAPATH option */
-#define have_curlssl_ca_path 1
-
-/* this backends supports CURLOPT_PINNEDPUBLICKEY */
-#define have_curlssl_pinnedpubkey 1
-
-/* API setup for PolarSSL */
-#define curlssl_init() Curl_polarssl_init()
-#define curlssl_cleanup() Curl_polarssl_cleanup()
-#define curlssl_connect Curl_polarssl_connect
-#define curlssl_connect_nonblocking Curl_polarssl_connect_nonblocking
-#define curlssl_session_free(x) Curl_polarssl_session_free(x)
-#define curlssl_close_all(x) ((void)x)
-#define curlssl_close Curl_polarssl_close
-#define curlssl_shutdown(x,y) 0
-#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN)
-#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN)
-#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL)
-#define curlssl_version Curl_polarssl_version
-#define curlssl_check_cxn(x) ((void)x, -1)
-#define curlssl_data_pending(x,y) Curl_polarssl_data_pending(x, y)
-#define curlssl_sha256sum(a,b,c,d) sha256(a,b,c,0)
-
-/* This might cause libcurl to use a weeker random!
- TODO: implement proper use of Polarssl's CTR-DRBG or HMAC-DRBG and use that
-*/
-#define curlssl_random(x,y,z) ((void)x, (void)y, (void)z, CURLE_NOT_BUILT_IN)
+extern const struct Curl_ssl Curl_ssl_polarssl;
#endif /* USE_POLARSSL */
#endif /* HEADER_CURL_POLARSSL_H */
diff --git a/Utilities/cmcurl/lib/vtls/polarssl_threadlock.c b/Utilities/cmcurl/lib/vtls/polarssl_threadlock.c
index b1eb7b746..27c94b11e 100644
--- a/Utilities/cmcurl/lib/vtls/polarssl_threadlock.c
+++ b/Utilities/cmcurl/lib/vtls/polarssl_threadlock.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2013-2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2013-2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 2010, 2011, Hoi-Ho Chan, <hoiho.chan@gmail.com>
*
* This software is licensed as described in the file COPYING, which
@@ -23,16 +23,15 @@
#include "curl_setup.h"
#if (defined(USE_POLARSSL) || defined(USE_MBEDTLS)) && \
- (defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32))
-
-#if defined(USE_THREADS_POSIX)
-# ifdef HAVE_PTHREAD_H
-# include <pthread.h>
-# endif
-#elif defined(USE_THREADS_WIN32)
-# ifdef HAVE_PROCESS_H
-# include <process.h>
-# endif
+ ((defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)) || \
+ (defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)))
+
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
+# include <pthread.h>
+# define POLARSSL_MUTEX_T pthread_mutex_t
+#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
+# include <process.h>
+# define POLARSSL_MUTEX_T HANDLE
#endif
#include "polarssl_threadlock.h"
@@ -50,25 +49,23 @@ static POLARSSL_MUTEX_T *mutex_buf = NULL;
int Curl_polarsslthreadlock_thread_setup(void)
{
int i;
- int ret;
mutex_buf = calloc(NUMT * sizeof(POLARSSL_MUTEX_T), 1);
if(!mutex_buf)
return 0; /* error, no number of threads defined */
-#ifdef HAVE_PTHREAD_H
for(i = 0; i < NUMT; i++) {
+ int ret;
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
ret = pthread_mutex_init(&mutex_buf[i], NULL);
if(ret)
return 0; /* pthread_mutex_init failed */
- }
-#elif defined(HAVE_PROCESS_H)
- for(i = 0; i < NUMT; i++) {
+#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
mutex_buf[i] = CreateMutex(0, FALSE, 0);
if(mutex_buf[i] == 0)
return 0; /* CreateMutex failed */
+#endif /* USE_THREADS_POSIX && HAVE_PTHREAD_H */
}
-#endif /* HAVE_PTHREAD_H */
return 1; /* OK */
}
@@ -76,24 +73,22 @@ int Curl_polarsslthreadlock_thread_setup(void)
int Curl_polarsslthreadlock_thread_cleanup(void)
{
int i;
- int ret;
if(!mutex_buf)
return 0; /* error, no threads locks defined */
-#ifdef HAVE_PTHREAD_H
for(i = 0; i < NUMT; i++) {
+ int ret;
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
ret = pthread_mutex_destroy(&mutex_buf[i]);
if(ret)
return 0; /* pthread_mutex_destroy failed */
- }
-#elif defined(HAVE_PROCESS_H)
- for(i = 0; i < NUMT; i++) {
+#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
ret = CloseHandle(mutex_buf[i]);
if(!ret)
return 0; /* CloseHandle failed */
+#endif /* USE_THREADS_POSIX && HAVE_PTHREAD_H */
}
-#endif /* HAVE_PTHREAD_H */
free(mutex_buf);
mutex_buf = NULL;
@@ -102,51 +97,47 @@ int Curl_polarsslthreadlock_thread_cleanup(void)
int Curl_polarsslthreadlock_lock_function(int n)
{
- int ret;
-#ifdef HAVE_PTHREAD_H
if(n < NUMT) {
+ int ret;
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
ret = pthread_mutex_lock(&mutex_buf[n]);
if(ret) {
DEBUGF(fprintf(stderr,
"Error: polarsslthreadlock_lock_function failed\n"));
return 0; /* pthread_mutex_lock failed */
}
- }
-#elif defined(HAVE_PROCESS_H)
- if(n < NUMT) {
- ret = (WaitForSingleObject(mutex_buf[n], INFINITE)==WAIT_FAILED?1:0);
+#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
+ ret = (WaitForSingleObject(mutex_buf[n], INFINITE) == WAIT_FAILED?1:0);
if(ret) {
DEBUGF(fprintf(stderr,
"Error: polarsslthreadlock_lock_function failed\n"));
return 0; /* pthread_mutex_lock failed */
}
+#endif /* USE_THREADS_POSIX && HAVE_PTHREAD_H */
}
-#endif /* HAVE_PTHREAD_H */
return 1; /* OK */
}
int Curl_polarsslthreadlock_unlock_function(int n)
{
- int ret;
-#ifdef HAVE_PTHREAD_H
if(n < NUMT) {
+ int ret;
+#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
ret = pthread_mutex_unlock(&mutex_buf[n]);
if(ret) {
DEBUGF(fprintf(stderr,
"Error: polarsslthreadlock_unlock_function failed\n"));
return 0; /* pthread_mutex_unlock failed */
}
- }
-#elif defined(HAVE_PROCESS_H)
- if(n < NUMT) {
+#elif defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H)
ret = ReleaseMutex(mutex_buf[n]);
if(!ret) {
DEBUGF(fprintf(stderr,
"Error: polarsslthreadlock_unlock_function failed\n"));
return 0; /* pthread_mutex_lock failed */
}
+#endif /* USE_THREADS_POSIX && HAVE_PTHREAD_H */
}
-#endif /* HAVE_PTHREAD_H */
return 1; /* OK */
}
diff --git a/Utilities/cmcurl/lib/vtls/polarssl_threadlock.h b/Utilities/cmcurl/lib/vtls/polarssl_threadlock.h
index dda5359b8..122647528 100644
--- a/Utilities/cmcurl/lib/vtls/polarssl_threadlock.h
+++ b/Utilities/cmcurl/lib/vtls/polarssl_threadlock.h
@@ -26,13 +26,8 @@
#if (defined USE_POLARSSL) || (defined USE_MBEDTLS)
-#if defined(USE_THREADS_POSIX)
-# define POLARSSL_MUTEX_T pthread_mutex_t
-#elif defined(USE_THREADS_WIN32)
-# define POLARSSL_MUTEX_T HANDLE
-#endif
-
-#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
+#if (defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)) || \
+ (defined(USE_THREADS_WIN32) && defined(HAVE_PROCESS_H))
int Curl_polarsslthreadlock_thread_setup(void);
int Curl_polarsslthreadlock_thread_cleanup(void);
diff --git a/Utilities/cmcurl/lib/vtls/schannel.c b/Utilities/cmcurl/lib/vtls/schannel.c
index 94603018b..0f6f734fd 100644
--- a/Utilities/cmcurl/lib/vtls/schannel.c
+++ b/Utilities/cmcurl/lib/vtls/schannel.c
@@ -7,7 +7,7 @@
*
* Copyright (C) 2012 - 2016, Marc Hoersken, <info@marc-hoersken.de>
* Copyright (C) 2012, Mark Salisbury, <mark.salisbury@hp.com>
- * Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -23,9 +23,8 @@
***************************************************************************/
/*
- * Source file for all SChannel-specific code for the TLS/SSL layer. No code
+ * Source file for all Schannel-specific code for the TLS/SSL layer. No code
* but vtls.c should ever call or use these functions.
- *
*/
/*
@@ -42,11 +41,12 @@
#ifdef USE_SCHANNEL
+#define EXPOSE_SCHANNEL_INTERNAL_STRUCTS
+
#ifndef USE_WINDOWS_SSPI
# error "Can't compile SCHANNEL support without SSPI."
#endif
-#include "curl_sspi.h"
#include "schannel.h"
#include "vtls.h"
#include "sendf.h"
@@ -58,8 +58,8 @@
#include "warnless.h"
#include "x509asn1.h"
#include "curl_printf.h"
+#include "multiif.h"
#include "system_win32.h"
-#include "hostcheck.h"
/* The last #include file should be: */
#include "curl_memory.h"
@@ -74,17 +74,85 @@
# define HAS_ALPN 1
#endif
+#ifndef UNISP_NAME_A
+#define UNISP_NAME_A "Microsoft Unified Security Protocol Provider"
+#endif
+
+#ifndef UNISP_NAME_W
+#define UNISP_NAME_W L"Microsoft Unified Security Protocol Provider"
+#endif
+
+#ifndef UNISP_NAME
+#ifdef UNICODE
+#define UNISP_NAME UNISP_NAME_W
+#else
+#define UNISP_NAME UNISP_NAME_A
+#endif
+#endif
+
+#if defined(CryptStringToBinary) && defined(CRYPT_STRING_HEX)
+#define HAS_CLIENT_CERT_PATH
+#endif
+
+#ifdef HAS_CLIENT_CERT_PATH
+#ifdef UNICODE
+#define CURL_CERT_STORE_PROV_SYSTEM CERT_STORE_PROV_SYSTEM_W
+#else
+#define CURL_CERT_STORE_PROV_SYSTEM CERT_STORE_PROV_SYSTEM_A
+#endif
+#endif
+
+#ifndef SP_PROT_SSL2_CLIENT
+#define SP_PROT_SSL2_CLIENT 0x00000008
+#endif
+
+#ifndef SP_PROT_SSL3_CLIENT
+#define SP_PROT_SSL3_CLIENT 0x00000008
+#endif
+
+#ifndef SP_PROT_TLS1_CLIENT
+#define SP_PROT_TLS1_CLIENT 0x00000080
+#endif
+
+#ifndef SP_PROT_TLS1_0_CLIENT
+#define SP_PROT_TLS1_0_CLIENT SP_PROT_TLS1_CLIENT
+#endif
+
+#ifndef SP_PROT_TLS1_1_CLIENT
+#define SP_PROT_TLS1_1_CLIENT 0x00000200
+#endif
+
+#ifndef SP_PROT_TLS1_2_CLIENT
+#define SP_PROT_TLS1_2_CLIENT 0x00000800
+#endif
+
+#ifndef SECBUFFER_ALERT
+#define SECBUFFER_ALERT 17
+#endif
+
+/* Both schannel buffer sizes must be > 0 */
+#define CURL_SCHANNEL_BUFFER_INIT_SIZE 4096
+#define CURL_SCHANNEL_BUFFER_FREE_SIZE 1024
+
+#define CERT_THUMBPRINT_STR_LEN 40
+#define CERT_THUMBPRINT_DATA_LEN 20
+
/* Uncomment to force verbose output
* #define infof(x, y, ...) printf(y, __VA_ARGS__)
* #define failf(x, y, ...) printf(y, __VA_ARGS__)
*/
+#ifndef CALG_SHA_256
+# define CALG_SHA_256 0x0000800c
+#endif
+
+#define BACKEND connssl->backend
+
static Curl_recv schannel_recv;
static Curl_send schannel_send;
-#ifdef _WIN32_WCE
-static CURLcode verify_certificate(struct connectdata *conn, int sockindex);
-#endif
+static CURLcode pkp_pin_peer_pubkey(struct connectdata *conn, int sockindex,
+ const char *pinnedpubkey);
static void InitSecBuffer(SecBuffer *buffer, unsigned long BufType,
void *BufDataPtr, unsigned long BufByteSize)
@@ -112,8 +180,6 @@ set_ssl_version_min_max(SCHANNEL_CRED *schannel_cred, struct connectdata *conn)
switch(ssl_version_max) {
case CURL_SSLVERSION_MAX_NONE:
- ssl_version_max = ssl_version << 16;
- break;
case CURL_SSLVERSION_MAX_DEFAULT:
ssl_version_max = CURL_SSLVERSION_MAX_TLSv1_2;
break;
@@ -130,13 +196,221 @@ set_ssl_version_min_max(SCHANNEL_CRED *schannel_cred, struct connectdata *conn)
schannel_cred->grbitEnabledProtocols |= SP_PROT_TLS1_2_CLIENT;
break;
case CURL_SSLVERSION_TLSv1_3:
- failf(data, "Schannel: TLS 1.3 is not yet supported");
+ failf(data, "schannel: TLS 1.3 is not yet supported");
return CURLE_SSL_CONNECT_ERROR;
}
}
return CURLE_OK;
}
+/*longest is 26, buffer is slightly bigger*/
+#define LONGEST_ALG_ID 32
+#define CIPHEROPTION(X) \
+if(strcmp(#X, tmp) == 0) \
+ return X
+
+static int
+get_alg_id_by_name(char *name)
+{
+ char tmp[LONGEST_ALG_ID] = { 0 };
+ char *nameEnd = strchr(name, ':');
+ size_t n = nameEnd ? min((size_t)(nameEnd - name), LONGEST_ALG_ID - 1) : \
+ min(strlen(name), LONGEST_ALG_ID - 1);
+ strncpy(tmp, name, n);
+ tmp[n] = 0;
+ CIPHEROPTION(CALG_MD2);
+ CIPHEROPTION(CALG_MD4);
+ CIPHEROPTION(CALG_MD5);
+ CIPHEROPTION(CALG_SHA);
+ CIPHEROPTION(CALG_SHA1);
+ CIPHEROPTION(CALG_MAC);
+ CIPHEROPTION(CALG_RSA_SIGN);
+ CIPHEROPTION(CALG_DSS_SIGN);
+/*ifdefs for the options that are defined conditionally in wincrypt.h*/
+#ifdef CALG_NO_SIGN
+ CIPHEROPTION(CALG_NO_SIGN);
+#endif
+ CIPHEROPTION(CALG_RSA_KEYX);
+ CIPHEROPTION(CALG_DES);
+#ifdef CALG_3DES_112
+ CIPHEROPTION(CALG_3DES_112);
+#endif
+ CIPHEROPTION(CALG_3DES);
+ CIPHEROPTION(CALG_DESX);
+ CIPHEROPTION(CALG_RC2);
+ CIPHEROPTION(CALG_RC4);
+ CIPHEROPTION(CALG_SEAL);
+#ifdef CALG_DH_SF
+ CIPHEROPTION(CALG_DH_SF);
+#endif
+ CIPHEROPTION(CALG_DH_EPHEM);
+#ifdef CALG_AGREEDKEY_ANY
+ CIPHEROPTION(CALG_AGREEDKEY_ANY);
+#endif
+#ifdef CALG_HUGHES_MD5
+ CIPHEROPTION(CALG_HUGHES_MD5);
+#endif
+ CIPHEROPTION(CALG_SKIPJACK);
+#ifdef CALG_TEK
+ CIPHEROPTION(CALG_TEK);
+#endif
+ CIPHEROPTION(CALG_CYLINK_MEK);
+ CIPHEROPTION(CALG_SSL3_SHAMD5);
+#ifdef CALG_SSL3_MASTER
+ CIPHEROPTION(CALG_SSL3_MASTER);
+#endif
+#ifdef CALG_SCHANNEL_MASTER_HASH
+ CIPHEROPTION(CALG_SCHANNEL_MASTER_HASH);
+#endif
+#ifdef CALG_SCHANNEL_MAC_KEY
+ CIPHEROPTION(CALG_SCHANNEL_MAC_KEY);
+#endif
+#ifdef CALG_SCHANNEL_ENC_KEY
+ CIPHEROPTION(CALG_SCHANNEL_ENC_KEY);
+#endif
+#ifdef CALG_PCT1_MASTER
+ CIPHEROPTION(CALG_PCT1_MASTER);
+#endif
+#ifdef CALG_SSL2_MASTER
+ CIPHEROPTION(CALG_SSL2_MASTER);
+#endif
+#ifdef CALG_TLS1_MASTER
+ CIPHEROPTION(CALG_TLS1_MASTER);
+#endif
+#ifdef CALG_RC5
+ CIPHEROPTION(CALG_RC5);
+#endif
+#ifdef CALG_HMAC
+ CIPHEROPTION(CALG_HMAC);
+#endif
+#if !defined(__W32API_MAJOR_VERSION) || \
+ !defined(__W32API_MINOR_VERSION) || \
+ defined(__MINGW64_VERSION_MAJOR) || \
+ (__W32API_MAJOR_VERSION > 5) || \
+ ((__W32API_MAJOR_VERSION == 5) && (__W32API_MINOR_VERSION > 0))
+ /* CALG_TLS1PRF has a syntax error in MinGW's w32api up to version 5.0,
+ see https://osdn.net/projects/mingw/ticket/38391 */
+ CIPHEROPTION(CALG_TLS1PRF);
+#endif
+#ifdef CALG_HASH_REPLACE_OWF
+ CIPHEROPTION(CALG_HASH_REPLACE_OWF);
+#endif
+#ifdef CALG_AES_128
+ CIPHEROPTION(CALG_AES_128);
+#endif
+#ifdef CALG_AES_192
+ CIPHEROPTION(CALG_AES_192);
+#endif
+#ifdef CALG_AES_256
+ CIPHEROPTION(CALG_AES_256);
+#endif
+#ifdef CALG_AES
+ CIPHEROPTION(CALG_AES);
+#endif
+#ifdef CALG_SHA_256
+ CIPHEROPTION(CALG_SHA_256);
+#endif
+#ifdef CALG_SHA_384
+ CIPHEROPTION(CALG_SHA_384);
+#endif
+#ifdef CALG_SHA_512
+ CIPHEROPTION(CALG_SHA_512);
+#endif
+#ifdef CALG_ECDH
+ CIPHEROPTION(CALG_ECDH);
+#endif
+#ifdef CALG_ECMQV
+ CIPHEROPTION(CALG_ECMQV);
+#endif
+#ifdef CALG_ECDSA
+ CIPHEROPTION(CALG_ECDSA);
+#endif
+#ifdef CALG_ECDH_EPHEM
+ CIPHEROPTION(CALG_ECDH_EPHEM);
+#endif
+ return 0;
+}
+
+static CURLcode
+set_ssl_ciphers(SCHANNEL_CRED *schannel_cred, char *ciphers)
+{
+ char *startCur = ciphers;
+ int algCount = 0;
+ static ALG_ID algIds[45]; /*There are 45 listed in the MS headers*/
+ while(startCur && (0 != *startCur) && (algCount < 45)) {
+ long alg = strtol(startCur, 0, 0);
+ if(!alg)
+ alg = get_alg_id_by_name(startCur);
+ if(alg)
+ algIds[algCount++] = alg;
+ else
+ return CURLE_SSL_CIPHER;
+ startCur = strchr(startCur, ':');
+ if(startCur)
+ startCur++;
+ }
+ schannel_cred->palgSupportedAlgs = algIds;
+ schannel_cred->cSupportedAlgs = algCount;
+ return CURLE_OK;
+}
+
+#ifdef HAS_CLIENT_CERT_PATH
+static CURLcode
+get_cert_location(TCHAR *path, DWORD *store_name, TCHAR **store_path,
+ TCHAR **thumbprint)
+{
+ TCHAR *sep;
+ TCHAR *store_path_start;
+ size_t store_name_len;
+
+ sep = _tcschr(path, TEXT('\\'));
+ if(sep == NULL)
+ return CURLE_SSL_CERTPROBLEM;
+
+ store_name_len = sep - path;
+
+ if(_tcsnccmp(path, TEXT("CurrentUser"), store_name_len) == 0)
+ *store_name = CERT_SYSTEM_STORE_CURRENT_USER;
+ else if(_tcsnccmp(path, TEXT("LocalMachine"), store_name_len) == 0)
+ *store_name = CERT_SYSTEM_STORE_LOCAL_MACHINE;
+ else if(_tcsnccmp(path, TEXT("CurrentService"), store_name_len) == 0)
+ *store_name = CERT_SYSTEM_STORE_CURRENT_SERVICE;
+ else if(_tcsnccmp(path, TEXT("Services"), store_name_len) == 0)
+ *store_name = CERT_SYSTEM_STORE_SERVICES;
+ else if(_tcsnccmp(path, TEXT("Users"), store_name_len) == 0)
+ *store_name = CERT_SYSTEM_STORE_USERS;
+ else if(_tcsnccmp(path, TEXT("CurrentUserGroupPolicy"),
+ store_name_len) == 0)
+ *store_name = CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY;
+ else if(_tcsnccmp(path, TEXT("LocalMachineGroupPolicy"),
+ store_name_len) == 0)
+ *store_name = CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY;
+ else if(_tcsnccmp(path, TEXT("LocalMachineEnterprise"),
+ store_name_len) == 0)
+ *store_name = CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE;
+ else
+ return CURLE_SSL_CERTPROBLEM;
+
+ store_path_start = sep + 1;
+
+ sep = _tcschr(store_path_start, TEXT('\\'));
+ if(sep == NULL)
+ return CURLE_SSL_CERTPROBLEM;
+
+ *sep = TEXT('\0');
+ *store_path = _tcsdup(store_path_start);
+ *sep = TEXT('\\');
+ if(*store_path == NULL)
+ return CURLE_OUT_OF_MEMORY;
+
+ *thumbprint = sep + 1;
+ if(_tcslen(*thumbprint) != CERT_THUMBPRINT_STR_LEN)
+ return CURLE_SSL_CERTPROBLEM;
+
+ return CURLE_OK;
+}
+#endif
+
static CURLcode
schannel_connect_step1(struct connectdata *conn, int sockindex)
{
@@ -151,6 +425,7 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
unsigned char alpn_buffer[128];
#endif
SCHANNEL_CRED schannel_cred;
+ PCCERT_CONTEXT client_certs[1] = { NULL };
SECURITY_STATUS sspi_status = SEC_E_OK;
struct curl_schannel_cred *old_cred = NULL;
struct in_addr addr;
@@ -162,85 +437,118 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
- infof(data, "schannel: SSL/TLS connection with %s port %hu (step 1/3)\n",
- hostname, conn->remote_port);
+ DEBUGF(infof(data,
+ "schannel: SSL/TLS connection with %s port %hu (step 1/3)\n",
+ hostname, conn->remote_port));
if(Curl_verify_windows_version(5, 1, PLATFORM_WINNT,
VERSION_LESS_THAN_EQUAL)) {
- /* SChannel in Windows XP (OS version 5.1) uses legacy handshakes and
+ /* Schannel in Windows XP (OS version 5.1) uses legacy handshakes and
algorithms that may not be supported by all servers. */
- infof(data, "schannel: WinSSL version is old and may not be able to "
+ infof(data, "schannel: Windows version is old and may not be able to "
"connect to some servers due to lack of SNI, algorithms, etc.\n");
}
#ifdef HAS_ALPN
/* ALPN is only supported on Windows 8.1 / Server 2012 R2 and above.
Also it doesn't seem to be supported for Wine, see curl bug #983. */
- connssl->use_alpn = conn->bits.tls_enable_alpn &&
+ BACKEND->use_alpn = conn->bits.tls_enable_alpn &&
!GetProcAddress(GetModuleHandleA("ntdll"),
"wine_get_version") &&
Curl_verify_windows_version(6, 3, PLATFORM_WINNT,
VERSION_GREATER_THAN_EQUAL);
#else
- connssl->use_alpn = false;
+ BACKEND->use_alpn = false;
+#endif
+
+#ifdef _WIN32_WCE
+#ifdef HAS_MANUAL_VERIFY_API
+ /* certificate validation on CE doesn't seem to work right; we'll
+ * do it following a more manual process. */
+ BACKEND->use_manual_cred_validation = true;
+#else
+#error "compiler too old to support requisite manual cert verify for Win CE"
+#endif
+#else
+#ifdef HAS_MANUAL_VERIFY_API
+ if(SSL_CONN_CONFIG(CAfile)) {
+ if(Curl_verify_windows_version(6, 1, PLATFORM_WINNT,
+ VERSION_GREATER_THAN_EQUAL)) {
+ BACKEND->use_manual_cred_validation = true;
+ }
+ else {
+ failf(data, "schannel: this version of Windows is too old to support "
+ "certificate verification via CA bundle file.");
+ return CURLE_SSL_CACERT_BADFILE;
+ }
+ }
+ else
+ BACKEND->use_manual_cred_validation = false;
+#else
+ if(SSL_CONN_CONFIG(CAfile)) {
+ failf(data, "schannel: CA cert support not built in");
+ return CURLE_NOT_BUILT_IN;
+ }
+#endif
#endif
- connssl->cred = NULL;
+ BACKEND->cred = NULL;
/* check for an existing re-usable credential handle */
if(SSL_SET_OPTION(primary.sessionid)) {
Curl_ssl_sessionid_lock(conn);
if(!Curl_ssl_getsessionid(conn, (void **)&old_cred, NULL, sockindex)) {
- connssl->cred = old_cred;
- infof(data, "schannel: re-using existing credential handle\n");
+ BACKEND->cred = old_cred;
+ DEBUGF(infof(data, "schannel: re-using existing credential handle\n"));
/* increment the reference counter of the credential/session handle */
- connssl->cred->refcount++;
- infof(data, "schannel: incremented credential handle refcount = %d\n",
- connssl->cred->refcount);
+ BACKEND->cred->refcount++;
+ DEBUGF(infof(data,
+ "schannel: incremented credential handle refcount = %d\n",
+ BACKEND->cred->refcount));
}
Curl_ssl_sessionid_unlock(conn);
}
- if(!connssl->cred) {
+ if(!BACKEND->cred) {
/* setup Schannel API options */
memset(&schannel_cred, 0, sizeof(schannel_cred));
schannel_cred.dwVersion = SCHANNEL_CRED_VERSION;
if(conn->ssl_config.verifypeer) {
-#ifdef _WIN32_WCE
- /* certificate validation on CE doesn't seem to work right; we'll
- do it following a more manual process. */
- schannel_cred.dwFlags = SCH_CRED_MANUAL_CRED_VALIDATION |
- SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
- SCH_CRED_IGNORE_REVOCATION_OFFLINE;
-#else
- schannel_cred.dwFlags = SCH_CRED_AUTO_CRED_VALIDATION;
- /* TODO s/data->set.ssl.no_revoke/SSL_SET_OPTION(no_revoke)/g */
- if(data->set.ssl.no_revoke)
- schannel_cred.dwFlags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
- SCH_CRED_IGNORE_REVOCATION_OFFLINE;
+#ifdef HAS_MANUAL_VERIFY_API
+ if(BACKEND->use_manual_cred_validation)
+ schannel_cred.dwFlags = SCH_CRED_MANUAL_CRED_VALIDATION;
else
- schannel_cred.dwFlags |= SCH_CRED_REVOCATION_CHECK_CHAIN;
#endif
- if(data->set.ssl.no_revoke)
- infof(data, "schannel: disabled server certificate revocation "
- "checks\n");
- else
- infof(data, "schannel: checking server certificate revocation\n");
+ schannel_cred.dwFlags = SCH_CRED_AUTO_CRED_VALIDATION;
+
+ if(data->set.ssl.no_revoke) {
+ schannel_cred.dwFlags |= SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
+ SCH_CRED_IGNORE_REVOCATION_OFFLINE;
+
+ DEBUGF(infof(data, "schannel: disabled server certificate revocation "
+ "checks\n"));
+ }
+ else {
+ schannel_cred.dwFlags |= SCH_CRED_REVOCATION_CHECK_CHAIN;
+ DEBUGF(infof(data,
+ "schannel: checking server certificate revocation\n"));
+ }
}
else {
schannel_cred.dwFlags = SCH_CRED_MANUAL_CRED_VALIDATION |
SCH_CRED_IGNORE_NO_REVOCATION_CHECK |
SCH_CRED_IGNORE_REVOCATION_OFFLINE;
- infof(data, "schannel: disabled server certificate revocation checks\n");
+ DEBUGF(infof(data,
+ "schannel: disabled server cert revocation checks\n"));
}
if(!conn->ssl_config.verifyhost) {
schannel_cred.dwFlags |= SCH_CRED_NO_SERVERNAME_CHECK;
- infof(data, "schannel: verifyhost setting prevents Schannel from "
- "comparing the supplied target name with the subject "
- "names in server certificates.\n");
+ DEBUGF(infof(data, "schannel: verifyhost setting prevents Schannel from "
+ "comparing the supplied target name with the subject "
+ "names in server certificates.\n"));
}
switch(conn->ssl_config.version) {
@@ -271,15 +579,100 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
return CURLE_SSL_CONNECT_ERROR;
}
+ if(SSL_CONN_CONFIG(cipher_list)) {
+ result = set_ssl_ciphers(&schannel_cred, SSL_CONN_CONFIG(cipher_list));
+ if(CURLE_OK != result) {
+ failf(data, "Unable to set ciphers to passed via SSL_CONN_CONFIG");
+ return result;
+ }
+ }
+
+
+#ifdef HAS_CLIENT_CERT_PATH
+ /* client certificate */
+ if(data->set.ssl.cert) {
+ DWORD cert_store_name;
+ TCHAR *cert_store_path;
+ TCHAR *cert_thumbprint_str;
+ CRYPT_HASH_BLOB cert_thumbprint;
+ BYTE cert_thumbprint_data[CERT_THUMBPRINT_DATA_LEN];
+ HCERTSTORE cert_store;
+
+ TCHAR *cert_path = Curl_convert_UTF8_to_tchar(data->set.ssl.cert);
+ if(!cert_path)
+ return CURLE_OUT_OF_MEMORY;
+
+ result = get_cert_location(cert_path, &cert_store_name,
+ &cert_store_path, &cert_thumbprint_str);
+ if(result != CURLE_OK) {
+ failf(data, "schannel: Failed to get certificate location for %s",
+ cert_path);
+ Curl_unicodefree(cert_path);
+ return result;
+ }
+
+ cert_store =
+ CertOpenStore(CURL_CERT_STORE_PROV_SYSTEM, 0,
+ (HCRYPTPROV)NULL,
+ CERT_STORE_OPEN_EXISTING_FLAG | cert_store_name,
+ cert_store_path);
+ if(!cert_store) {
+ failf(data, "schannel: Failed to open cert store %x %s, "
+ "last error is %x",
+ cert_store_name, cert_store_path, GetLastError());
+ free(cert_store_path);
+ Curl_unicodefree(cert_path);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+ free(cert_store_path);
+
+ cert_thumbprint.pbData = cert_thumbprint_data;
+ cert_thumbprint.cbData = CERT_THUMBPRINT_DATA_LEN;
+
+ if(!CryptStringToBinary(cert_thumbprint_str, CERT_THUMBPRINT_STR_LEN,
+ CRYPT_STRING_HEX,
+ cert_thumbprint_data, &cert_thumbprint.cbData,
+ NULL, NULL)) {
+ Curl_unicodefree(cert_path);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+
+ client_certs[0] = CertFindCertificateInStore(
+ cert_store, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0,
+ CERT_FIND_HASH, &cert_thumbprint, NULL);
+
+ Curl_unicodefree(cert_path);
+
+ if(client_certs[0]) {
+ schannel_cred.cCreds = 1;
+ schannel_cred.paCred = client_certs;
+ }
+ else {
+ /* CRYPT_E_NOT_FOUND / E_INVALIDARG */
+ return CURLE_SSL_CERTPROBLEM;
+ }
+
+ CertCloseStore(cert_store, 0);
+ }
+#else
+ if(data->set.ssl.cert) {
+ failf(data, "schannel: client cert support not built in");
+ return CURLE_NOT_BUILT_IN;
+ }
+#endif
+
/* allocate memory for the re-usable credential handle */
- connssl->cred = (struct curl_schannel_cred *)
- malloc(sizeof(struct curl_schannel_cred));
- if(!connssl->cred) {
+ BACKEND->cred = (struct curl_schannel_cred *)
+ calloc(1, sizeof(struct curl_schannel_cred));
+ if(!BACKEND->cred) {
failf(data, "schannel: unable to allocate memory");
+
+ if(client_certs[0])
+ CertFreeCertificateContext(client_certs[0]);
+
return CURLE_OUT_OF_MEMORY;
}
- memset(connssl->cred, 0, sizeof(struct curl_schannel_cred));
- connssl->cred->refcount = 1;
+ BACKEND->cred->refcount = 1;
/* https://msdn.microsoft.com/en-us/library/windows/desktop/aa374716.aspx
*/
@@ -287,18 +680,28 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
s_pSecFn->AcquireCredentialsHandle(NULL, (TCHAR *)UNISP_NAME,
SECPKG_CRED_OUTBOUND, NULL,
&schannel_cred, NULL, NULL,
- &connssl->cred->cred_handle,
- &connssl->cred->time_stamp);
+ &BACKEND->cred->cred_handle,
+ &BACKEND->cred->time_stamp);
+
+ if(client_certs[0])
+ CertFreeCertificateContext(client_certs[0]);
if(sspi_status != SEC_E_OK) {
- if(sspi_status == SEC_E_WRONG_PRINCIPAL)
- failf(data, "schannel: SNI or certificate check failed: %s",
- Curl_sspi_strerror(conn, sspi_status));
- else
- failf(data, "schannel: AcquireCredentialsHandle failed: %s",
- Curl_sspi_strerror(conn, sspi_status));
- Curl_safefree(connssl->cred);
- return CURLE_SSL_CONNECT_ERROR;
+ char buffer[STRERROR_LEN];
+ failf(data, "schannel: AcquireCredentialsHandle failed: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ Curl_safefree(BACKEND->cred);
+ switch(sspi_status) {
+ case SEC_E_INSUFFICIENT_MEMORY:
+ return CURLE_OUT_OF_MEMORY;
+ case SEC_E_NO_CREDENTIALS:
+ case SEC_E_SECPKG_NOT_FOUND:
+ case SEC_E_NOT_OWNER:
+ case SEC_E_UNKNOWN_CREDENTIALS:
+ case SEC_E_INTERNAL_ERROR:
+ default:
+ return CURLE_SSL_CONNECT_ERROR;
+ }
}
}
@@ -312,7 +715,7 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
}
#ifdef HAS_ALPN
- if(connssl->use_alpn) {
+ if(BACKEND->use_alpn) {
int cur = 0;
int list_start_index = 0;
unsigned int *extension_len = NULL;
@@ -355,8 +758,7 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
InitSecBuffer(&inbuf, SECBUFFER_APPLICATION_PROTOCOLS, alpn_buffer, cur);
InitSecBufferDesc(&inbuf_desc, &inbuf, 1);
}
- else
- {
+ else {
InitSecBuffer(&inbuf, SECBUFFER_EMPTY, NULL, 0);
InitSecBufferDesc(&inbuf_desc, &inbuf, 1);
}
@@ -370,18 +772,17 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
InitSecBufferDesc(&outbuf_desc, &outbuf, 1);
/* setup request flags */
- connssl->req_flags = ISC_REQ_SEQUENCE_DETECT | ISC_REQ_REPLAY_DETECT |
+ BACKEND->req_flags = ISC_REQ_SEQUENCE_DETECT | ISC_REQ_REPLAY_DETECT |
ISC_REQ_CONFIDENTIALITY | ISC_REQ_ALLOCATE_MEMORY |
ISC_REQ_STREAM;
/* allocate memory for the security context handle */
- connssl->ctxt = (struct curl_schannel_ctxt *)
- malloc(sizeof(struct curl_schannel_ctxt));
- if(!connssl->ctxt) {
+ BACKEND->ctxt = (struct curl_schannel_ctxt *)
+ calloc(1, sizeof(struct curl_schannel_ctxt));
+ if(!BACKEND->ctxt) {
failf(data, "schannel: unable to allocate memory");
return CURLE_OUT_OF_MEMORY;
}
- memset(connssl->ctxt, 0, sizeof(struct curl_schannel_ctxt));
host_name = Curl_convert_UTF8_to_tchar(hostname);
if(!host_name)
@@ -395,26 +796,45 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
us problems with inbuf regardless. https://github.com/curl/curl/issues/983
*/
sspi_status = s_pSecFn->InitializeSecurityContext(
- &connssl->cred->cred_handle, NULL, host_name, connssl->req_flags, 0, 0,
- (connssl->use_alpn ? &inbuf_desc : NULL),
- 0, &connssl->ctxt->ctxt_handle,
- &outbuf_desc, &connssl->ret_flags, &connssl->ctxt->time_stamp);
+ &BACKEND->cred->cred_handle, NULL, host_name, BACKEND->req_flags, 0, 0,
+ (BACKEND->use_alpn ? &inbuf_desc : NULL),
+ 0, &BACKEND->ctxt->ctxt_handle,
+ &outbuf_desc, &BACKEND->ret_flags, &BACKEND->ctxt->time_stamp);
Curl_unicodefree(host_name);
if(sspi_status != SEC_I_CONTINUE_NEEDED) {
- if(sspi_status == SEC_E_WRONG_PRINCIPAL)
- failf(data, "schannel: SNI or certificate check failed: %s",
- Curl_sspi_strerror(conn, sspi_status));
- else
- failf(data, "schannel: initial InitializeSecurityContext failed: %s",
- Curl_sspi_strerror(conn, sspi_status));
- Curl_safefree(connssl->ctxt);
- return CURLE_SSL_CONNECT_ERROR;
+ char buffer[STRERROR_LEN];
+ Curl_safefree(BACKEND->ctxt);
+ switch(sspi_status) {
+ case SEC_E_INSUFFICIENT_MEMORY:
+ failf(data, "schannel: initial InitializeSecurityContext failed: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ return CURLE_OUT_OF_MEMORY;
+ case SEC_E_WRONG_PRINCIPAL:
+ failf(data, "schannel: SNI or certificate check failed: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ return CURLE_PEER_FAILED_VERIFICATION;
+ /*
+ case SEC_E_INVALID_HANDLE:
+ case SEC_E_INVALID_TOKEN:
+ case SEC_E_LOGON_DENIED:
+ case SEC_E_TARGET_UNKNOWN:
+ case SEC_E_NO_AUTHENTICATING_AUTHORITY:
+ case SEC_E_INTERNAL_ERROR:
+ case SEC_E_NO_CREDENTIALS:
+ case SEC_E_UNSUPPORTED_FUNCTION:
+ case SEC_E_APPLICATION_PROTOCOL_MISMATCH:
+ */
+ default:
+ failf(data, "schannel: initial InitializeSecurityContext failed: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ return CURLE_SSL_CONNECT_ERROR;
+ }
}
- infof(data, "schannel: sending initial handshake data: "
- "sending %lu bytes...\n", outbuf.cbBuffer);
+ DEBUGF(infof(data, "schannel: sending initial handshake data: "
+ "sending %lu bytes...\n", outbuf.cbBuffer));
/* send initial handshake data which is now stored in output buffer */
result = Curl_write_plain(conn, conn->sock[sockindex], outbuf.pvBuffer,
@@ -426,13 +846,13 @@ schannel_connect_step1(struct connectdata *conn, int sockindex)
return CURLE_SSL_CONNECT_ERROR;
}
- infof(data, "schannel: sent initial handshake data: "
- "sent %zd bytes\n", written);
+ DEBUGF(infof(data, "schannel: sent initial handshake data: "
+ "sent %zd bytes\n", written));
- connssl->recv_unrecoverable_err = CURLE_OK;
- connssl->recv_sspi_close_notify = false;
- connssl->recv_connection_closed = false;
- connssl->encdata_is_incomplete = false;
+ BACKEND->recv_unrecoverable_err = CURLE_OK;
+ BACKEND->recv_sspi_close_notify = false;
+ BACKEND->recv_connection_closed = false;
+ BACKEND->encdata_is_incomplete = false;
/* continue to second handshake step */
connssl->connecting_state = ssl_connect_2;
@@ -448,56 +868,56 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
unsigned char *reallocated_buffer;
- size_t reallocated_length;
SecBuffer outbuf[3];
SecBufferDesc outbuf_desc;
SecBuffer inbuf[2];
SecBufferDesc inbuf_desc;
SECURITY_STATUS sspi_status = SEC_E_OK;
- TCHAR *host_name;
CURLcode result;
bool doread;
char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
+ const char *pubkey_ptr;
doread = (connssl->connecting_state != ssl_connect_2_writing) ? TRUE : FALSE;
- infof(data, "schannel: SSL/TLS connection with %s port %hu (step 2/3)\n",
- hostname, conn->remote_port);
+ DEBUGF(infof(data,
+ "schannel: SSL/TLS connection with %s port %hu (step 2/3)\n",
+ hostname, conn->remote_port));
- if(!connssl->cred || !connssl->ctxt)
+ if(!BACKEND->cred || !BACKEND->ctxt)
return CURLE_SSL_CONNECT_ERROR;
/* buffer to store previously received and decrypted data */
- if(connssl->decdata_buffer == NULL) {
- connssl->decdata_offset = 0;
- connssl->decdata_length = CURL_SCHANNEL_BUFFER_INIT_SIZE;
- connssl->decdata_buffer = malloc(connssl->decdata_length);
- if(connssl->decdata_buffer == NULL) {
+ if(BACKEND->decdata_buffer == NULL) {
+ BACKEND->decdata_offset = 0;
+ BACKEND->decdata_length = CURL_SCHANNEL_BUFFER_INIT_SIZE;
+ BACKEND->decdata_buffer = malloc(BACKEND->decdata_length);
+ if(BACKEND->decdata_buffer == NULL) {
failf(data, "schannel: unable to allocate memory");
return CURLE_OUT_OF_MEMORY;
}
}
/* buffer to store previously received and encrypted data */
- if(connssl->encdata_buffer == NULL) {
- connssl->encdata_is_incomplete = false;
- connssl->encdata_offset = 0;
- connssl->encdata_length = CURL_SCHANNEL_BUFFER_INIT_SIZE;
- connssl->encdata_buffer = malloc(connssl->encdata_length);
- if(connssl->encdata_buffer == NULL) {
+ if(BACKEND->encdata_buffer == NULL) {
+ BACKEND->encdata_is_incomplete = false;
+ BACKEND->encdata_offset = 0;
+ BACKEND->encdata_length = CURL_SCHANNEL_BUFFER_INIT_SIZE;
+ BACKEND->encdata_buffer = malloc(BACKEND->encdata_length);
+ if(BACKEND->encdata_buffer == NULL) {
failf(data, "schannel: unable to allocate memory");
return CURLE_OUT_OF_MEMORY;
}
}
/* if we need a bigger buffer to read a full message, increase buffer now */
- if(connssl->encdata_length - connssl->encdata_offset <
+ if(BACKEND->encdata_length - BACKEND->encdata_offset <
CURL_SCHANNEL_BUFFER_FREE_SIZE) {
/* increase internal encrypted data buffer */
- reallocated_length = connssl->encdata_offset +
+ size_t reallocated_length = BACKEND->encdata_offset +
CURL_SCHANNEL_BUFFER_FREE_SIZE;
- reallocated_buffer = realloc(connssl->encdata_buffer,
+ reallocated_buffer = realloc(BACKEND->encdata_buffer,
reallocated_length);
if(reallocated_buffer == NULL) {
@@ -505,25 +925,26 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
return CURLE_OUT_OF_MEMORY;
}
else {
- connssl->encdata_buffer = reallocated_buffer;
- connssl->encdata_length = reallocated_length;
+ BACKEND->encdata_buffer = reallocated_buffer;
+ BACKEND->encdata_length = reallocated_length;
}
}
for(;;) {
+ TCHAR *host_name;
if(doread) {
/* read encrypted handshake data from socket */
result = Curl_read_plain(conn->sock[sockindex],
- (char *) (connssl->encdata_buffer +
- connssl->encdata_offset),
- connssl->encdata_length -
- connssl->encdata_offset,
+ (char *) (BACKEND->encdata_buffer +
+ BACKEND->encdata_offset),
+ BACKEND->encdata_length -
+ BACKEND->encdata_offset,
&nread);
if(result == CURLE_AGAIN) {
if(connssl->connecting_state != ssl_connect_2_writing)
connssl->connecting_state = ssl_connect_2_reading;
- infof(data, "schannel: failed to receive handshake, "
- "need more data\n");
+ DEBUGF(infof(data, "schannel: failed to receive handshake, "
+ "need more data\n"));
return CURLE_OK;
}
else if((result != CURLE_OK) || (nread == 0)) {
@@ -533,17 +954,18 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
}
/* increase encrypted data buffer offset */
- connssl->encdata_offset += nread;
- connssl->encdata_is_incomplete = false;
- infof(data, "schannel: encrypted data got %zd\n", nread);
+ BACKEND->encdata_offset += nread;
+ BACKEND->encdata_is_incomplete = false;
+ DEBUGF(infof(data, "schannel: encrypted data got %zd\n", nread));
}
- infof(data, "schannel: encrypted data buffer: offset %zu length %zu\n",
- connssl->encdata_offset, connssl->encdata_length);
+ DEBUGF(infof(data,
+ "schannel: encrypted data buffer: offset %zu length %zu\n",
+ BACKEND->encdata_offset, BACKEND->encdata_length));
/* setup input buffers */
- InitSecBuffer(&inbuf[0], SECBUFFER_TOKEN, malloc(connssl->encdata_offset),
- curlx_uztoul(connssl->encdata_offset));
+ InitSecBuffer(&inbuf[0], SECBUFFER_TOKEN, malloc(BACKEND->encdata_offset),
+ curlx_uztoul(BACKEND->encdata_offset));
InitSecBuffer(&inbuf[1], SECBUFFER_EMPTY, NULL, 0);
InitSecBufferDesc(&inbuf_desc, inbuf, 2);
@@ -559,8 +981,8 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
}
/* copy received handshake data into input buffer */
- memcpy(inbuf[0].pvBuffer, connssl->encdata_buffer,
- connssl->encdata_offset);
+ memcpy(inbuf[0].pvBuffer, BACKEND->encdata_buffer,
+ BACKEND->encdata_offset);
host_name = Curl_convert_UTF8_to_tchar(hostname);
if(!host_name)
@@ -569,9 +991,9 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
/* https://msdn.microsoft.com/en-us/library/windows/desktop/aa375924.aspx
*/
sspi_status = s_pSecFn->InitializeSecurityContext(
- &connssl->cred->cred_handle, &connssl->ctxt->ctxt_handle,
- host_name, connssl->req_flags, 0, 0, &inbuf_desc, 0, NULL,
- &outbuf_desc, &connssl->ret_flags, &connssl->ctxt->time_stamp);
+ &BACKEND->cred->cred_handle, &BACKEND->ctxt->ctxt_handle,
+ host_name, BACKEND->req_flags, 0, 0, &inbuf_desc, 0, NULL,
+ &outbuf_desc, &BACKEND->ret_flags, &BACKEND->ctxt->time_stamp);
Curl_unicodefree(host_name);
@@ -580,9 +1002,10 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
/* check if the handshake was incomplete */
if(sspi_status == SEC_E_INCOMPLETE_MESSAGE) {
- connssl->encdata_is_incomplete = true;
+ BACKEND->encdata_is_incomplete = true;
connssl->connecting_state = ssl_connect_2_reading;
- infof(data, "schannel: received incomplete message, need more data\n");
+ DEBUGF(infof(data,
+ "schannel: received incomplete message, need more data\n"));
return CURLE_OK;
}
@@ -590,10 +1013,11 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
the handshake without one. This will allow connections to servers which
request a client certificate but do not require it. */
if(sspi_status == SEC_I_INCOMPLETE_CREDENTIALS &&
- !(connssl->req_flags & ISC_REQ_USE_SUPPLIED_CREDS)) {
- connssl->req_flags |= ISC_REQ_USE_SUPPLIED_CREDS;
+ !(BACKEND->req_flags & ISC_REQ_USE_SUPPLIED_CREDS)) {
+ BACKEND->req_flags |= ISC_REQ_USE_SUPPLIED_CREDS;
connssl->connecting_state = ssl_connect_2_writing;
- infof(data, "schannel: a client certificate has been requested\n");
+ DEBUGF(infof(data,
+ "schannel: a client certificate has been requested\n"));
return CURLE_OK;
}
@@ -602,8 +1026,8 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
for(i = 0; i < 3; i++) {
/* search for handshake tokens that need to be send */
if(outbuf[i].BufferType == SECBUFFER_TOKEN && outbuf[i].cbBuffer > 0) {
- infof(data, "schannel: sending next handshake data: "
- "sending %lu bytes...\n", outbuf[i].cbBuffer);
+ DEBUGF(infof(data, "schannel: sending next handshake data: "
+ "sending %lu bytes...\n", outbuf[i].cbBuffer));
/* send handshake token to server */
result = Curl_write_plain(conn, conn->sock[sockindex],
@@ -624,19 +1048,38 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
}
}
else {
- if(sspi_status == SEC_E_WRONG_PRINCIPAL)
- failf(data, "schannel: SNI or certificate check failed: %s",
- Curl_sspi_strerror(conn, sspi_status));
- else
- failf(data, "schannel: next InitializeSecurityContext failed: %s",
- Curl_sspi_strerror(conn, sspi_status));
- return sspi_status == SEC_E_UNTRUSTED_ROOT ?
- CURLE_SSL_CACERT_BADFILE : CURLE_SSL_CONNECT_ERROR;
+ char buffer[STRERROR_LEN];
+ switch(sspi_status) {
+ case SEC_E_INSUFFICIENT_MEMORY:
+ failf(data, "schannel: next InitializeSecurityContext failed: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ return CURLE_OUT_OF_MEMORY;
+ case SEC_E_WRONG_PRINCIPAL:
+ failf(data, "schannel: SNI or certificate check failed: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ return CURLE_PEER_FAILED_VERIFICATION;
+ /*
+ case SEC_E_INVALID_HANDLE:
+ case SEC_E_INVALID_TOKEN:
+ case SEC_E_LOGON_DENIED:
+ case SEC_E_TARGET_UNKNOWN:
+ case SEC_E_NO_AUTHENTICATING_AUTHORITY:
+ case SEC_E_INTERNAL_ERROR:
+ case SEC_E_NO_CREDENTIALS:
+ case SEC_E_UNSUPPORTED_FUNCTION:
+ case SEC_E_APPLICATION_PROTOCOL_MISMATCH:
+ */
+ default:
+ failf(data, "schannel: next InitializeSecurityContext failed: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ return CURLE_SSL_CONNECT_ERROR;
+ }
}
/* check if there was additional remaining encrypted data */
if(inbuf[1].BufferType == SECBUFFER_EXTRA && inbuf[1].cbBuffer > 0) {
- infof(data, "schannel: encrypted data length: %lu\n", inbuf[1].cbBuffer);
+ DEBUGF(infof(data, "schannel: encrypted data length: %lu\n",
+ inbuf[1].cbBuffer));
/*
There are two cases where we could be getting extra data here:
1) If we're renegotiating a connection and the handshake is already
@@ -649,11 +1092,11 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
*/
/* check if the remaining data is less than the total amount
and therefore begins after the already processed data */
- if(connssl->encdata_offset > inbuf[1].cbBuffer) {
- memmove(connssl->encdata_buffer,
- (connssl->encdata_buffer + connssl->encdata_offset) -
+ if(BACKEND->encdata_offset > inbuf[1].cbBuffer) {
+ memmove(BACKEND->encdata_buffer,
+ (BACKEND->encdata_buffer + BACKEND->encdata_offset) -
inbuf[1].cbBuffer, inbuf[1].cbBuffer);
- connssl->encdata_offset = inbuf[1].cbBuffer;
+ BACKEND->encdata_offset = inbuf[1].cbBuffer;
if(sspi_status == SEC_I_CONTINUE_NEEDED) {
doread = FALSE;
continue;
@@ -661,7 +1104,7 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
}
}
else {
- connssl->encdata_offset = 0;
+ BACKEND->encdata_offset = 0;
}
break;
}
@@ -675,19 +1118,84 @@ schannel_connect_step2(struct connectdata *conn, int sockindex)
/* check if the handshake is complete */
if(sspi_status == SEC_E_OK) {
connssl->connecting_state = ssl_connect_3;
- infof(data, "schannel: SSL/TLS handshake complete\n");
+ DEBUGF(infof(data, "schannel: SSL/TLS handshake complete\n"));
}
-#ifdef _WIN32_WCE
- /* Windows CE doesn't do any server certificate validation.
- We have to do it manually. */
- if(conn->ssl_config.verifypeer)
- return verify_certificate(conn, sockindex);
+ pubkey_ptr = SSL_IS_PROXY() ?
+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_PROXY] :
+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG];
+ if(pubkey_ptr) {
+ result = pkp_pin_peer_pubkey(conn, sockindex, pubkey_ptr);
+ if(result) {
+ failf(data, "SSL: public key does not match pinned public key!");
+ return result;
+ }
+ }
+
+#ifdef HAS_MANUAL_VERIFY_API
+ if(conn->ssl_config.verifypeer && BACKEND->use_manual_cred_validation) {
+ return Curl_verify_certificate(conn, sockindex);
+ }
#endif
return CURLE_OK;
}
+static bool
+valid_cert_encoding(const CERT_CONTEXT *cert_context)
+{
+ return (cert_context != NULL) &&
+ ((cert_context->dwCertEncodingType & X509_ASN_ENCODING) != 0) &&
+ (cert_context->pbCertEncoded != NULL) &&
+ (cert_context->cbCertEncoded > 0);
+}
+
+typedef bool(*Read_crt_func)(const CERT_CONTEXT *ccert_context, void *arg);
+
+static void
+traverse_cert_store(const CERT_CONTEXT *context, Read_crt_func func,
+ void *arg)
+{
+ const CERT_CONTEXT *current_context = NULL;
+ bool should_continue = true;
+ while(should_continue &&
+ (current_context = CertEnumCertificatesInStore(
+ context->hCertStore,
+ current_context)) != NULL)
+ should_continue = func(current_context, arg);
+
+ if(current_context)
+ CertFreeCertificateContext(current_context);
+}
+
+static bool
+cert_counter_callback(const CERT_CONTEXT *ccert_context, void *certs_count)
+{
+ if(valid_cert_encoding(ccert_context))
+ (*(int *)certs_count)++;
+ return true;
+}
+
+struct Adder_args
+{
+ struct connectdata *conn;
+ CURLcode result;
+ int idx;
+};
+
+static bool
+add_cert_to_certinfo(const CERT_CONTEXT *ccert_context, void *raw_arg)
+{
+ struct Adder_args *args = (struct Adder_args*)raw_arg;
+ args->result = CURLE_OK;
+ if(valid_cert_encoding(ccert_context)) {
+ const char *beg = (const char *) ccert_context->pbCertEncoded;
+ const char *end = beg + ccert_context->cbCertEncoded;
+ args->result = Curl_extract_certinfo(args->conn, (args->idx)++, beg, end);
+ }
+ return args->result == CURLE_OK;
+}
+
static CURLcode
schannel_connect_step3(struct connectdata *conn, int sockindex)
{
@@ -696,7 +1204,7 @@ schannel_connect_step3(struct connectdata *conn, int sockindex)
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
SECURITY_STATUS sspi_status = SEC_E_OK;
CERT_CONTEXT *ccert_context = NULL;
-#ifndef CURL_DISABLE_VERBOSE_STRINGS
+#ifdef DEBUGBUILD
const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
#endif
@@ -706,30 +1214,31 @@ schannel_connect_step3(struct connectdata *conn, int sockindex)
DEBUGASSERT(ssl_connect_3 == connssl->connecting_state);
- infof(data, "schannel: SSL/TLS connection with %s port %hu (step 3/3)\n",
- hostname, conn->remote_port);
+ DEBUGF(infof(data,
+ "schannel: SSL/TLS connection with %s port %hu (step 3/3)\n",
+ hostname, conn->remote_port));
- if(!connssl->cred)
+ if(!BACKEND->cred)
return CURLE_SSL_CONNECT_ERROR;
/* check if the required context attributes are met */
- if(connssl->ret_flags != connssl->req_flags) {
- if(!(connssl->ret_flags & ISC_RET_SEQUENCE_DETECT))
+ if(BACKEND->ret_flags != BACKEND->req_flags) {
+ if(!(BACKEND->ret_flags & ISC_RET_SEQUENCE_DETECT))
failf(data, "schannel: failed to setup sequence detection");
- if(!(connssl->ret_flags & ISC_RET_REPLAY_DETECT))
+ if(!(BACKEND->ret_flags & ISC_RET_REPLAY_DETECT))
failf(data, "schannel: failed to setup replay detection");
- if(!(connssl->ret_flags & ISC_RET_CONFIDENTIALITY))
+ if(!(BACKEND->ret_flags & ISC_RET_CONFIDENTIALITY))
failf(data, "schannel: failed to setup confidentiality");
- if(!(connssl->ret_flags & ISC_RET_ALLOCATED_MEMORY))
+ if(!(BACKEND->ret_flags & ISC_RET_ALLOCATED_MEMORY))
failf(data, "schannel: failed to setup memory allocation");
- if(!(connssl->ret_flags & ISC_RET_STREAM))
+ if(!(BACKEND->ret_flags & ISC_RET_STREAM))
failf(data, "schannel: failed to setup stream orientation");
return CURLE_SSL_CONNECT_ERROR;
}
#ifdef HAS_ALPN
- if(connssl->use_alpn) {
- sspi_status = s_pSecFn->QueryContextAttributes(&connssl->ctxt->ctxt_handle,
+ if(BACKEND->use_alpn) {
+ sspi_status = s_pSecFn->QueryContextAttributes(&BACKEND->ctxt->ctxt_handle,
SECPKG_ATTR_APPLICATION_PROTOCOL, &alpn_result);
if(sspi_status != SEC_E_OK) {
@@ -759,6 +1268,8 @@ schannel_connect_step3(struct connectdata *conn, int sockindex)
}
else
infof(data, "ALPN, server did not agree to a protocol\n");
+ Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ?
+ BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE);
}
#endif
@@ -771,15 +1282,16 @@ schannel_connect_step3(struct connectdata *conn, int sockindex)
incache = !(Curl_ssl_getsessionid(conn, (void **)&old_cred, NULL,
sockindex));
if(incache) {
- if(old_cred != connssl->cred) {
- infof(data, "schannel: old credential handle is stale, removing\n");
+ if(old_cred != BACKEND->cred) {
+ DEBUGF(infof(data,
+ "schannel: old credential handle is stale, removing\n"));
/* we're not taking old_cred ownership here, no refcount++ is needed */
Curl_ssl_delsessionid(conn, (void *)old_cred);
incache = FALSE;
}
}
if(!incache) {
- result = Curl_ssl_addsessionid(conn, (void *)connssl->cred,
+ result = Curl_ssl_addsessionid(conn, (void *)BACKEND->cred,
sizeof(struct curl_schannel_cred),
sockindex);
if(result) {
@@ -789,31 +1301,33 @@ schannel_connect_step3(struct connectdata *conn, int sockindex)
}
else {
/* this cred session is now also referenced by sessionid cache */
- connssl->cred->refcount++;
- infof(data, "schannel: stored credential handle in session cache\n");
+ BACKEND->cred->refcount++;
+ DEBUGF(infof(data,
+ "schannel: stored credential handle in session cache\n"));
}
}
Curl_ssl_sessionid_unlock(conn);
}
if(data->set.ssl.certinfo) {
- sspi_status = s_pSecFn->QueryContextAttributes(&connssl->ctxt->ctxt_handle,
+ int certs_count = 0;
+ sspi_status = s_pSecFn->QueryContextAttributes(&BACKEND->ctxt->ctxt_handle,
SECPKG_ATTR_REMOTE_CERT_CONTEXT, &ccert_context);
if((sspi_status != SEC_E_OK) || (ccert_context == NULL)) {
failf(data, "schannel: failed to retrieve remote cert context");
- return CURLE_SSL_CONNECT_ERROR;
+ return CURLE_PEER_FAILED_VERIFICATION;
}
- result = Curl_ssl_init_certinfo(data, 1);
- if(!result) {
- if(((ccert_context->dwCertEncodingType & X509_ASN_ENCODING) != 0) &&
- (ccert_context->cbCertEncoded > 0)) {
+ traverse_cert_store(ccert_context, cert_counter_callback, &certs_count);
- const char *beg = (const char *) ccert_context->pbCertEncoded;
- const char *end = beg + ccert_context->cbCertEncoded;
- result = Curl_extract_certinfo(conn, 0, beg, end);
- }
+ result = Curl_ssl_init_certinfo(data, certs_count);
+ if(!result) {
+ struct Adder_args args;
+ args.conn = conn;
+ args.idx = 0;
+ traverse_cert_store(ccert_context, add_cert_to_certinfo, &args);
+ result = args.result;
}
CertFreeCertificateContext(ccert_context);
if(result)
@@ -926,6 +1440,16 @@ schannel_connect_common(struct connectdata *conn, int sockindex,
connssl->state = ssl_connection_complete;
conn->recv[sockindex] = schannel_recv;
conn->send[sockindex] = schannel_send;
+
+#ifdef SECPKG_ATTR_ENDPOINT_BINDINGS
+ /* When SSPI is used in combination with Schannel
+ * we need the Schannel context to create the Schannel
+ * binding to pass the IIS extended protection checks.
+ * Available on Windows 7 or later.
+ */
+ conn->sslContext = &BACKEND->ctxt->ctxt_handle;
+#endif
+
*done = TRUE;
}
else
@@ -951,11 +1475,11 @@ schannel_send(struct connectdata *conn, int sockindex,
CURLcode result;
/* check if the maximum stream sizes were queried */
- if(connssl->stream_sizes.cbMaximumMessage == 0) {
+ if(BACKEND->stream_sizes.cbMaximumMessage == 0) {
sspi_status = s_pSecFn->QueryContextAttributes(
- &connssl->ctxt->ctxt_handle,
+ &BACKEND->ctxt->ctxt_handle,
SECPKG_ATTR_STREAM_SIZES,
- &connssl->stream_sizes);
+ &BACKEND->stream_sizes);
if(sspi_status != SEC_E_OK) {
*err = CURLE_SEND_ERROR;
return -1;
@@ -963,14 +1487,13 @@ schannel_send(struct connectdata *conn, int sockindex,
}
/* check if the buffer is longer than the maximum message length */
- if(len > connssl->stream_sizes.cbMaximumMessage) {
- *err = CURLE_SEND_ERROR;
- return -1;
+ if(len > BACKEND->stream_sizes.cbMaximumMessage) {
+ len = BACKEND->stream_sizes.cbMaximumMessage;
}
/* calculate the complete message length and allocate a buffer for it */
- data_len = connssl->stream_sizes.cbHeader + len +
- connssl->stream_sizes.cbTrailer;
+ data_len = BACKEND->stream_sizes.cbHeader + len +
+ BACKEND->stream_sizes.cbTrailer;
data = (unsigned char *) malloc(data_len);
if(data == NULL) {
*err = CURLE_OUT_OF_MEMORY;
@@ -979,12 +1502,12 @@ schannel_send(struct connectdata *conn, int sockindex,
/* setup output buffers (header, data, trailer, empty) */
InitSecBuffer(&outbuf[0], SECBUFFER_STREAM_HEADER,
- data, connssl->stream_sizes.cbHeader);
+ data, BACKEND->stream_sizes.cbHeader);
InitSecBuffer(&outbuf[1], SECBUFFER_DATA,
- data + connssl->stream_sizes.cbHeader, curlx_uztoul(len));
+ data + BACKEND->stream_sizes.cbHeader, curlx_uztoul(len));
InitSecBuffer(&outbuf[2], SECBUFFER_STREAM_TRAILER,
- data + connssl->stream_sizes.cbHeader + len,
- connssl->stream_sizes.cbTrailer);
+ data + BACKEND->stream_sizes.cbHeader + len,
+ BACKEND->stream_sizes.cbTrailer);
InitSecBuffer(&outbuf[3], SECBUFFER_EMPTY, NULL, 0);
InitSecBufferDesc(&outbuf_desc, outbuf, 4);
@@ -992,7 +1515,7 @@ schannel_send(struct connectdata *conn, int sockindex,
memcpy(outbuf[1].pvBuffer, buf, len);
/* https://msdn.microsoft.com/en-us/library/windows/desktop/aa375390.aspx */
- sspi_status = s_pSecFn->EncryptMessage(&connssl->ctxt->ctxt_handle, 0,
+ sspi_status = s_pSecFn->EncryptMessage(&BACKEND->ctxt->ctxt_handle, 0,
&outbuf_desc, 0);
/* check if the message was encrypted */
@@ -1102,7 +1625,7 @@ schannel_recv(struct connectdata *conn, int sockindex,
size_t min_encdata_length = len + CURL_SCHANNEL_BUFFER_FREE_SIZE;
/****************************************************************************
- * Don't return or set connssl->recv_unrecoverable_err unless in the cleanup.
+ * Don't return or set BACKEND->recv_unrecoverable_err unless in the cleanup.
* The pattern for return error is set *err, optional infof, goto cleanup.
*
* Our priority is to always return as much decrypted data to the caller as
@@ -1111,19 +1634,19 @@ schannel_recv(struct connectdata *conn, int sockindex,
* handled in the cleanup.
*/
- infof(data, "schannel: client wants to read %zu bytes\n", len);
+ DEBUGF(infof(data, "schannel: client wants to read %zu bytes\n", len));
*err = CURLE_OK;
- if(len && len <= connssl->decdata_offset) {
+ if(len && len <= BACKEND->decdata_offset) {
infof(data, "schannel: enough decrypted data is already available\n");
goto cleanup;
}
- else if(connssl->recv_unrecoverable_err) {
- *err = connssl->recv_unrecoverable_err;
+ else if(BACKEND->recv_unrecoverable_err) {
+ *err = BACKEND->recv_unrecoverable_err;
infof(data, "schannel: an unrecoverable error occurred in a prior call\n");
goto cleanup;
}
- else if(connssl->recv_sspi_close_notify) {
+ else if(BACKEND->recv_sspi_close_notify) {
/* once a server has indicated shutdown there is no more encrypted data */
infof(data, "schannel: server indicated shutdown in a prior call\n");
goto cleanup;
@@ -1135,17 +1658,17 @@ schannel_recv(struct connectdata *conn, int sockindex,
*/
; /* do nothing */
}
- else if(!connssl->recv_connection_closed) {
+ else if(!BACKEND->recv_connection_closed) {
/* increase enc buffer in order to fit the requested amount of data */
- size = connssl->encdata_length - connssl->encdata_offset;
+ size = BACKEND->encdata_length - BACKEND->encdata_offset;
if(size < CURL_SCHANNEL_BUFFER_FREE_SIZE ||
- connssl->encdata_length < min_encdata_length) {
- reallocated_length = connssl->encdata_offset +
+ BACKEND->encdata_length < min_encdata_length) {
+ reallocated_length = BACKEND->encdata_offset +
CURL_SCHANNEL_BUFFER_FREE_SIZE;
if(reallocated_length < min_encdata_length) {
reallocated_length = min_encdata_length;
}
- reallocated_buffer = realloc(connssl->encdata_buffer,
+ reallocated_buffer = realloc(BACKEND->encdata_buffer,
reallocated_length);
if(reallocated_buffer == NULL) {
*err = CURLE_OUT_OF_MEMORY;
@@ -1153,51 +1676,54 @@ schannel_recv(struct connectdata *conn, int sockindex,
goto cleanup;
}
- connssl->encdata_buffer = reallocated_buffer;
- connssl->encdata_length = reallocated_length;
- size = connssl->encdata_length - connssl->encdata_offset;
- infof(data, "schannel: encdata_buffer resized %zu\n",
- connssl->encdata_length);
+ BACKEND->encdata_buffer = reallocated_buffer;
+ BACKEND->encdata_length = reallocated_length;
+ size = BACKEND->encdata_length - BACKEND->encdata_offset;
+ DEBUGF(infof(data, "schannel: encdata_buffer resized %zu\n",
+ BACKEND->encdata_length));
}
- infof(data, "schannel: encrypted data buffer: offset %zu length %zu\n",
- connssl->encdata_offset, connssl->encdata_length);
+ DEBUGF(infof(data,
+ "schannel: encrypted data buffer: offset %zu length %zu\n",
+ BACKEND->encdata_offset, BACKEND->encdata_length));
/* read encrypted data from socket */
*err = Curl_read_plain(conn->sock[sockindex],
- (char *)(connssl->encdata_buffer +
- connssl->encdata_offset),
+ (char *)(BACKEND->encdata_buffer +
+ BACKEND->encdata_offset),
size, &nread);
if(*err) {
nread = -1;
if(*err == CURLE_AGAIN)
- infof(data, "schannel: Curl_read_plain returned CURLE_AGAIN\n");
+ DEBUGF(infof(data,
+ "schannel: Curl_read_plain returned CURLE_AGAIN\n"));
else if(*err == CURLE_RECV_ERROR)
infof(data, "schannel: Curl_read_plain returned CURLE_RECV_ERROR\n");
else
infof(data, "schannel: Curl_read_plain returned error %d\n", *err);
}
else if(nread == 0) {
- connssl->recv_connection_closed = true;
- infof(data, "schannel: server closed the connection\n");
+ BACKEND->recv_connection_closed = true;
+ DEBUGF(infof(data, "schannel: server closed the connection\n"));
}
else if(nread > 0) {
- connssl->encdata_offset += (size_t)nread;
- connssl->encdata_is_incomplete = false;
- infof(data, "schannel: encrypted data got %zd\n", nread);
+ BACKEND->encdata_offset += (size_t)nread;
+ BACKEND->encdata_is_incomplete = false;
+ DEBUGF(infof(data, "schannel: encrypted data got %zd\n", nread));
}
}
- infof(data, "schannel: encrypted data buffer: offset %zu length %zu\n",
- connssl->encdata_offset, connssl->encdata_length);
+ DEBUGF(infof(data,
+ "schannel: encrypted data buffer: offset %zu length %zu\n",
+ BACKEND->encdata_offset, BACKEND->encdata_length));
/* decrypt loop */
- while(connssl->encdata_offset > 0 && sspi_status == SEC_E_OK &&
- (!len || connssl->decdata_offset < len ||
- connssl->recv_connection_closed)) {
+ while(BACKEND->encdata_offset > 0 && sspi_status == SEC_E_OK &&
+ (!len || BACKEND->decdata_offset < len ||
+ BACKEND->recv_connection_closed)) {
/* prepare data buffer for DecryptMessage call */
- InitSecBuffer(&inbuf[0], SECBUFFER_DATA, connssl->encdata_buffer,
- curlx_uztoul(connssl->encdata_offset));
+ InitSecBuffer(&inbuf[0], SECBUFFER_DATA, BACKEND->encdata_buffer,
+ curlx_uztoul(BACKEND->encdata_offset));
/* we need 3 more empty input buffers for possible output */
InitSecBuffer(&inbuf[1], SECBUFFER_EMPTY, NULL, 0);
@@ -1207,7 +1733,7 @@ schannel_recv(struct connectdata *conn, int sockindex,
/* https://msdn.microsoft.com/en-us/library/windows/desktop/aa375348.aspx
*/
- sspi_status = s_pSecFn->DecryptMessage(&connssl->ctxt->ctxt_handle,
+ sspi_status = s_pSecFn->DecryptMessage(&BACKEND->ctxt->ctxt_handle,
&inbuf_desc, 0, NULL);
/* check if everything went fine (server may want to renegotiate
@@ -1217,67 +1743,69 @@ schannel_recv(struct connectdata *conn, int sockindex,
/* check for successfully decrypted data, even before actual
renegotiation or shutdown of the connection context */
if(inbuf[1].BufferType == SECBUFFER_DATA) {
- infof(data, "schannel: decrypted data length: %lu\n",
- inbuf[1].cbBuffer);
+ DEBUGF(infof(data, "schannel: decrypted data length: %lu\n",
+ inbuf[1].cbBuffer));
/* increase buffer in order to fit the received amount of data */
size = inbuf[1].cbBuffer > CURL_SCHANNEL_BUFFER_FREE_SIZE ?
inbuf[1].cbBuffer : CURL_SCHANNEL_BUFFER_FREE_SIZE;
- if(connssl->decdata_length - connssl->decdata_offset < size ||
- connssl->decdata_length < len) {
+ if(BACKEND->decdata_length - BACKEND->decdata_offset < size ||
+ BACKEND->decdata_length < len) {
/* increase internal decrypted data buffer */
- reallocated_length = connssl->decdata_offset + size;
+ reallocated_length = BACKEND->decdata_offset + size;
/* make sure that the requested amount of data fits */
if(reallocated_length < len) {
reallocated_length = len;
}
- reallocated_buffer = realloc(connssl->decdata_buffer,
+ reallocated_buffer = realloc(BACKEND->decdata_buffer,
reallocated_length);
if(reallocated_buffer == NULL) {
*err = CURLE_OUT_OF_MEMORY;
failf(data, "schannel: unable to re-allocate memory");
goto cleanup;
}
- connssl->decdata_buffer = reallocated_buffer;
- connssl->decdata_length = reallocated_length;
+ BACKEND->decdata_buffer = reallocated_buffer;
+ BACKEND->decdata_length = reallocated_length;
}
/* copy decrypted data to internal buffer */
size = inbuf[1].cbBuffer;
if(size) {
- memcpy(connssl->decdata_buffer + connssl->decdata_offset,
+ memcpy(BACKEND->decdata_buffer + BACKEND->decdata_offset,
inbuf[1].pvBuffer, size);
- connssl->decdata_offset += size;
+ BACKEND->decdata_offset += size;
}
- infof(data, "schannel: decrypted data added: %zu\n", size);
- infof(data, "schannel: decrypted data cached: offset %zu length %zu\n",
- connssl->decdata_offset, connssl->decdata_length);
+ DEBUGF(infof(data, "schannel: decrypted data added: %zu\n", size));
+ DEBUGF(infof(data,
+ "schannel: decrypted cached: offset %zu length %zu\n",
+ BACKEND->decdata_offset, BACKEND->decdata_length));
}
/* check for remaining encrypted data */
if(inbuf[3].BufferType == SECBUFFER_EXTRA && inbuf[3].cbBuffer > 0) {
- infof(data, "schannel: encrypted data length: %lu\n",
- inbuf[3].cbBuffer);
+ DEBUGF(infof(data, "schannel: encrypted data length: %lu\n",
+ inbuf[3].cbBuffer));
/* check if the remaining data is less than the total amount
* and therefore begins after the already processed data
*/
- if(connssl->encdata_offset > inbuf[3].cbBuffer) {
+ if(BACKEND->encdata_offset > inbuf[3].cbBuffer) {
/* move remaining encrypted data forward to the beginning of
buffer */
- memmove(connssl->encdata_buffer,
- (connssl->encdata_buffer + connssl->encdata_offset) -
+ memmove(BACKEND->encdata_buffer,
+ (BACKEND->encdata_buffer + BACKEND->encdata_offset) -
inbuf[3].cbBuffer, inbuf[3].cbBuffer);
- connssl->encdata_offset = inbuf[3].cbBuffer;
+ BACKEND->encdata_offset = inbuf[3].cbBuffer;
}
- infof(data, "schannel: encrypted data cached: offset %zu length %zu\n",
- connssl->encdata_offset, connssl->encdata_length);
+ DEBUGF(infof(data,
+ "schannel: encrypted cached: offset %zu length %zu\n",
+ BACKEND->encdata_offset, BACKEND->encdata_length));
}
else {
/* reset encrypted buffer offset, because there is no data remaining */
- connssl->encdata_offset = 0;
+ BACKEND->encdata_offset = 0;
}
/* check if server wants to renegotiate the connection context */
@@ -1287,7 +1815,7 @@ schannel_recv(struct connectdata *conn, int sockindex,
infof(data, "schannel: can't renogotiate, an error is pending\n");
goto cleanup;
}
- if(connssl->encdata_offset) {
+ if(BACKEND->encdata_offset) {
*err = CURLE_RECV_ERROR;
infof(data, "schannel: can't renogotiate, "
"encrypted data available\n");
@@ -1311,38 +1839,41 @@ schannel_recv(struct connectdata *conn, int sockindex,
else if(sspi_status == SEC_I_CONTEXT_EXPIRED) {
/* In Windows 2000 SEC_I_CONTEXT_EXPIRED (close_notify) is not
returned so we have to work around that in cleanup. */
- connssl->recv_sspi_close_notify = true;
- if(!connssl->recv_connection_closed) {
- connssl->recv_connection_closed = true;
+ BACKEND->recv_sspi_close_notify = true;
+ if(!BACKEND->recv_connection_closed) {
+ BACKEND->recv_connection_closed = true;
infof(data, "schannel: server closed the connection\n");
}
goto cleanup;
}
}
else if(sspi_status == SEC_E_INCOMPLETE_MESSAGE) {
- connssl->encdata_is_incomplete = true;
+ BACKEND->encdata_is_incomplete = true;
if(!*err)
*err = CURLE_AGAIN;
infof(data, "schannel: failed to decrypt data, need more data\n");
goto cleanup;
}
else {
+ char buffer[STRERROR_LEN];
*err = CURLE_RECV_ERROR;
infof(data, "schannel: failed to read data from server: %s\n",
- Curl_sspi_strerror(conn, sspi_status));
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
goto cleanup;
}
}
- infof(data, "schannel: encrypted data buffer: offset %zu length %zu\n",
- connssl->encdata_offset, connssl->encdata_length);
+ DEBUGF(infof(data,
+ "schannel: encrypted data buffer: offset %zu length %zu\n",
+ BACKEND->encdata_offset, BACKEND->encdata_length));
- infof(data, "schannel: decrypted data buffer: offset %zu length %zu\n",
- connssl->decdata_offset, connssl->decdata_length);
+ DEBUGF(infof(data,
+ "schannel: decrypted data buffer: offset %zu length %zu\n",
+ BACKEND->decdata_offset, BACKEND->decdata_length));
cleanup:
/* Warning- there is no guarantee the encdata state is valid at this point */
- infof(data, "schannel: schannel_recv cleanup\n");
+ DEBUGF(infof(data, "schannel: schannel_recv cleanup\n"));
/* Error if the connection has closed without a close_notify.
Behavior here is a matter of debate. We don't want to be vulnerable to a
@@ -1352,13 +1883,13 @@ cleanup:
return close_notify. In that case if the connection was closed we assume it
was graceful (close_notify) since there doesn't seem to be a way to tell.
*/
- if(len && !connssl->decdata_offset && connssl->recv_connection_closed &&
- !connssl->recv_sspi_close_notify) {
+ if(len && !BACKEND->decdata_offset && BACKEND->recv_connection_closed &&
+ !BACKEND->recv_sspi_close_notify) {
bool isWin2k = Curl_verify_windows_version(5, 0, PLATFORM_WINNT,
VERSION_EQUAL);
if(isWin2k && sspi_status == SEC_E_OK)
- connssl->recv_sspi_close_notify = true;
+ BACKEND->recv_sspi_close_notify = true;
else {
*err = CURLE_RECV_ERROR;
infof(data, "schannel: server closed abruptly (missing close_notify)\n");
@@ -1367,23 +1898,23 @@ cleanup:
/* Any error other than CURLE_AGAIN is an unrecoverable error. */
if(*err && *err != CURLE_AGAIN)
- connssl->recv_unrecoverable_err = *err;
+ BACKEND->recv_unrecoverable_err = *err;
- size = len < connssl->decdata_offset ? len : connssl->decdata_offset;
+ size = len < BACKEND->decdata_offset ? len : BACKEND->decdata_offset;
if(size) {
- memcpy(buf, connssl->decdata_buffer, size);
- memmove(connssl->decdata_buffer, connssl->decdata_buffer + size,
- connssl->decdata_offset - size);
- connssl->decdata_offset -= size;
-
- infof(data, "schannel: decrypted data returned %zu\n", size);
- infof(data, "schannel: decrypted data buffer: offset %zu length %zu\n",
- connssl->decdata_offset, connssl->decdata_length);
+ memcpy(buf, BACKEND->decdata_buffer, size);
+ memmove(BACKEND->decdata_buffer, BACKEND->decdata_buffer + size,
+ BACKEND->decdata_offset - size);
+ BACKEND->decdata_offset -= size;
+ DEBUGF(infof(data, "schannel: decrypted data returned %zu\n", size));
+ DEBUGF(infof(data,
+ "schannel: decrypted data buffer: offset %zu length %zu\n",
+ BACKEND->decdata_offset, BACKEND->decdata_length));
*err = CURLE_OK;
return (ssize_t)size;
}
- if(!*err && !connssl->recv_connection_closed)
+ if(!*err && !BACKEND->recv_connection_closed)
*err = CURLE_AGAIN;
/* It's debatable what to return when !len. We could return whatever error we
@@ -1395,15 +1926,13 @@ cleanup:
return *err ? -1 : 0;
}
-CURLcode
-Curl_schannel_connect_nonblocking(struct connectdata *conn, int sockindex,
- bool *done)
+static CURLcode Curl_schannel_connect_nonblocking(struct connectdata *conn,
+ int sockindex, bool *done)
{
return schannel_connect_common(conn, sockindex, TRUE, done);
}
-CURLcode
-Curl_schannel_connect(struct connectdata *conn, int sockindex)
+static CURLcode Curl_schannel_connect(struct connectdata *conn, int sockindex)
{
CURLcode result;
bool done = FALSE;
@@ -1417,25 +1946,38 @@ Curl_schannel_connect(struct connectdata *conn, int sockindex)
return CURLE_OK;
}
-bool Curl_schannel_data_pending(const struct connectdata *conn, int sockindex)
+static bool Curl_schannel_data_pending(const struct connectdata *conn,
+ int sockindex)
{
const struct ssl_connect_data *connssl = &conn->ssl[sockindex];
if(connssl->use) /* SSL/TLS is in use */
- return (connssl->decdata_offset > 0 ||
- (connssl->encdata_offset > 0 && !connssl->encdata_is_incomplete));
+ return (BACKEND->decdata_offset > 0 ||
+ (BACKEND->encdata_offset > 0 && !BACKEND->encdata_is_incomplete));
else
return FALSE;
}
-void Curl_schannel_close(struct connectdata *conn, int sockindex)
+static void Curl_schannel_close(struct connectdata *conn, int sockindex)
{
if(conn->ssl[sockindex].use)
/* if the SSL/TLS channel hasn't been shut down yet, do that now. */
Curl_ssl_shutdown(conn, sockindex);
}
-int Curl_schannel_shutdown(struct connectdata *conn, int sockindex)
+static void Curl_schannel_session_free(void *ptr)
+{
+ /* this is expected to be called under sessionid lock */
+ struct curl_schannel_cred *cred = ptr;
+
+ cred->refcount--;
+ if(cred->refcount == 0) {
+ s_pSecFn->FreeCredentialsHandle(&cred->cred_handle);
+ Curl_safefree(cred);
+ }
+}
+
+static int Curl_schannel_shutdown(struct connectdata *conn, int sockindex)
{
/* See https://msdn.microsoft.com/en-us/library/windows/desktop/aa380138.aspx
* Shutting Down an Schannel Connection
@@ -1445,10 +1987,12 @@ int Curl_schannel_shutdown(struct connectdata *conn, int sockindex)
char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
conn->host.name;
+ DEBUGASSERT(data);
+
infof(data, "schannel: shutting down SSL/TLS connection with %s port %hu\n",
hostname, conn->remote_port);
- if(connssl->cred && connssl->ctxt) {
+ if(BACKEND->cred && BACKEND->ctxt) {
SecBufferDesc BuffDesc;
SecBuffer Buffer;
SECURITY_STATUS sspi_status;
@@ -1461,12 +2005,14 @@ int Curl_schannel_shutdown(struct connectdata *conn, int sockindex)
InitSecBuffer(&Buffer, SECBUFFER_TOKEN, &dwshut, sizeof(dwshut));
InitSecBufferDesc(&BuffDesc, &Buffer, 1);
- sspi_status = s_pSecFn->ApplyControlToken(&connssl->ctxt->ctxt_handle,
+ sspi_status = s_pSecFn->ApplyControlToken(&BACKEND->ctxt->ctxt_handle,
&BuffDesc);
- if(sspi_status != SEC_E_OK)
+ if(sspi_status != SEC_E_OK) {
+ char buffer[STRERROR_LEN];
failf(data, "schannel: ApplyControlToken failure: %s",
- Curl_sspi_strerror(conn, sspi_status));
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ }
host_name = Curl_convert_UTF8_to_tchar(hostname);
if(!host_name)
@@ -1477,18 +2023,18 @@ int Curl_schannel_shutdown(struct connectdata *conn, int sockindex)
InitSecBufferDesc(&outbuf_desc, &outbuf, 1);
sspi_status = s_pSecFn->InitializeSecurityContext(
- &connssl->cred->cred_handle,
- &connssl->ctxt->ctxt_handle,
+ &BACKEND->cred->cred_handle,
+ &BACKEND->ctxt->ctxt_handle,
host_name,
- connssl->req_flags,
+ BACKEND->req_flags,
0,
0,
NULL,
0,
- &connssl->ctxt->ctxt_handle,
+ &BACKEND->ctxt->ctxt_handle,
&outbuf_desc,
- &connssl->ret_flags,
- &connssl->ctxt->time_stamp);
+ &BACKEND->ret_flags,
+ &BACKEND->ctxt->time_stamp);
Curl_unicodefree(host_name);
@@ -1507,71 +2053,67 @@ int Curl_schannel_shutdown(struct connectdata *conn, int sockindex)
}
/* free SSPI Schannel API security context handle */
- if(connssl->ctxt) {
- infof(data, "schannel: clear security context handle\n");
- s_pSecFn->DeleteSecurityContext(&connssl->ctxt->ctxt_handle);
- Curl_safefree(connssl->ctxt);
+ if(BACKEND->ctxt) {
+ DEBUGF(infof(data, "schannel: clear security context handle\n"));
+ s_pSecFn->DeleteSecurityContext(&BACKEND->ctxt->ctxt_handle);
+ Curl_safefree(BACKEND->ctxt);
}
/* free SSPI Schannel API credential handle */
- if(connssl->cred) {
+ if(BACKEND->cred) {
+ /*
+ * When this function is called from Curl_schannel_close() the connection
+ * might not have an associated transfer so the check for conn->data is
+ * necessary.
+ */
Curl_ssl_sessionid_lock(conn);
- Curl_schannel_session_free(connssl->cred);
+ Curl_schannel_session_free(BACKEND->cred);
Curl_ssl_sessionid_unlock(conn);
- connssl->cred = NULL;
+ BACKEND->cred = NULL;
}
/* free internal buffer for received encrypted data */
- if(connssl->encdata_buffer != NULL) {
- Curl_safefree(connssl->encdata_buffer);
- connssl->encdata_length = 0;
- connssl->encdata_offset = 0;
- connssl->encdata_is_incomplete = false;
+ if(BACKEND->encdata_buffer != NULL) {
+ Curl_safefree(BACKEND->encdata_buffer);
+ BACKEND->encdata_length = 0;
+ BACKEND->encdata_offset = 0;
+ BACKEND->encdata_is_incomplete = false;
}
/* free internal buffer for received decrypted data */
- if(connssl->decdata_buffer != NULL) {
- Curl_safefree(connssl->decdata_buffer);
- connssl->decdata_length = 0;
- connssl->decdata_offset = 0;
+ if(BACKEND->decdata_buffer != NULL) {
+ Curl_safefree(BACKEND->decdata_buffer);
+ BACKEND->decdata_length = 0;
+ BACKEND->decdata_offset = 0;
}
return CURLE_OK;
}
-void Curl_schannel_session_free(void *ptr)
-{
- /* this is expected to be called under sessionid lock */
- struct curl_schannel_cred *cred = ptr;
-
- cred->refcount--;
- if(cred->refcount == 0) {
- s_pSecFn->FreeCredentialsHandle(&cred->cred_handle);
- Curl_safefree(cred);
- }
-}
-
-int Curl_schannel_init(void)
+static int Curl_schannel_init(void)
{
return (Curl_sspi_global_init() == CURLE_OK ? 1 : 0);
}
-void Curl_schannel_cleanup(void)
+static void Curl_schannel_cleanup(void)
{
Curl_sspi_global_cleanup();
}
-size_t Curl_schannel_version(char *buffer, size_t size)
+static size_t Curl_schannel_version(char *buffer, size_t size)
{
- size = snprintf(buffer, size, "WinSSL");
+ size = msnprintf(buffer, size, "Schannel");
return size;
}
-CURLcode Curl_schannel_random(unsigned char *entropy, size_t length)
+static CURLcode Curl_schannel_random(struct Curl_easy *data UNUSED_PARAM,
+ unsigned char *entropy, size_t length)
{
HCRYPTPROV hCryptProv = 0;
+ (void)data;
+
if(!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
return CURLE_FAILED_INIT;
@@ -1585,144 +2127,176 @@ CURLcode Curl_schannel_random(unsigned char *entropy, size_t length)
return CURLE_OK;
}
-#ifdef _WIN32_WCE
-static CURLcode verify_certificate(struct connectdata *conn, int sockindex)
+static CURLcode pkp_pin_peer_pubkey(struct connectdata *conn, int sockindex,
+ const char *pinnedpubkey)
{
- SECURITY_STATUS status;
struct Curl_easy *data = conn->data;
struct ssl_connect_data *connssl = &conn->ssl[sockindex];
- CURLcode result = CURLE_OK;
CERT_CONTEXT *pCertContextServer = NULL;
- const CERT_CHAIN_CONTEXT *pChainContext = NULL;
- const char * const conn_hostname = SSL_IS_PROXY() ?
- conn->http_proxy.host.name :
- conn->host.name;
- status = s_pSecFn->QueryContextAttributes(&connssl->ctxt->ctxt_handle,
- SECPKG_ATTR_REMOTE_CERT_CONTEXT,
- &pCertContextServer);
+ /* Result is returned to caller */
+ CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH;
- if((status != SEC_E_OK) || (pCertContextServer == NULL)) {
- failf(data, "schannel: Failed to read remote certificate context: %s",
- Curl_sspi_strerror(conn, status));
- result = CURLE_PEER_FAILED_VERIFICATION;
- }
+ /* if a path wasn't specified, don't pin */
+ if(!pinnedpubkey)
+ return CURLE_OK;
- if(result == CURLE_OK) {
- CERT_CHAIN_PARA ChainPara;
- memset(&ChainPara, 0, sizeof(ChainPara));
- ChainPara.cbSize = sizeof(ChainPara);
-
- if(!CertGetCertificateChain(NULL,
- pCertContextServer,
- NULL,
- pCertContextServer->hCertStore,
- &ChainPara,
- (data->set.ssl.no_revoke ? 0 :
- CERT_CHAIN_REVOCATION_CHECK_CHAIN),
- NULL,
- &pChainContext)) {
- failf(data, "schannel: CertGetCertificateChain failed: %s",
- Curl_sspi_strerror(conn, GetLastError()));
- pChainContext = NULL;
- result = CURLE_PEER_FAILED_VERIFICATION;
- }
+ do {
+ SECURITY_STATUS sspi_status;
+ const char *x509_der;
+ DWORD x509_der_len;
+ curl_X509certificate x509_parsed;
+ curl_asn1Element *pubkey;
- if(result == CURLE_OK) {
- CERT_SIMPLE_CHAIN *pSimpleChain = pChainContext->rgpChain[0];
- DWORD dwTrustErrorMask = ~(DWORD)(CERT_TRUST_IS_NOT_TIME_NESTED);
- dwTrustErrorMask &= pSimpleChain->TrustStatus.dwErrorStatus;
- if(dwTrustErrorMask) {
- if(dwTrustErrorMask & CERT_TRUST_IS_REVOKED)
- failf(data, "schannel: CertGetCertificateChain trust error"
- " CERT_TRUST_IS_REVOKED");
- else if(dwTrustErrorMask & CERT_TRUST_IS_PARTIAL_CHAIN)
- failf(data, "schannel: CertGetCertificateChain trust error"
- " CERT_TRUST_IS_PARTIAL_CHAIN");
- else if(dwTrustErrorMask & CERT_TRUST_IS_UNTRUSTED_ROOT)
- failf(data, "schannel: CertGetCertificateChain trust error"
- " CERT_TRUST_IS_UNTRUSTED_ROOT");
- else if(dwTrustErrorMask & CERT_TRUST_IS_NOT_TIME_VALID)
- failf(data, "schannel: CertGetCertificateChain trust error"
- " CERT_TRUST_IS_NOT_TIME_VALID");
- else
- failf(data, "schannel: CertGetCertificateChain error mask: 0x%08x",
- dwTrustErrorMask);
- result = CURLE_PEER_FAILED_VERIFICATION;
- }
+ sspi_status =
+ s_pSecFn->QueryContextAttributes(&BACKEND->ctxt->ctxt_handle,
+ SECPKG_ATTR_REMOTE_CERT_CONTEXT,
+ &pCertContextServer);
+
+ if((sspi_status != SEC_E_OK) || (pCertContextServer == NULL)) {
+ char buffer[STRERROR_LEN];
+ failf(data, "schannel: Failed to read remote certificate context: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ break; /* failed */
}
- }
- if(result == CURLE_OK) {
- if(conn->ssl_config.verifyhost) {
- TCHAR cert_hostname_buff[256];
- DWORD len;
-
- /* TODO: Fix this for certificates with multiple alternative names.
- Right now we're only asking for the first preferred alternative name.
- Instead we'd need to do all via CERT_NAME_SEARCH_ALL_NAMES_FLAG
- (if WinCE supports that?) and run this section in a loop for each.
- https://msdn.microsoft.com/en-us/library/windows/desktop/aa376086.aspx
- curl: (51) schannel: CertGetNameString() certificate hostname
- (.google.com) did not match connection (google.com)
- */
- len = CertGetNameString(pCertContextServer,
- CERT_NAME_DNS_TYPE,
- CERT_NAME_DISABLE_IE4_UTF8_FLAG,
- NULL,
- cert_hostname_buff,
- 256);
- if(len > 0) {
- const char *cert_hostname;
-
- /* Comparing the cert name and the connection hostname encoded as UTF-8
- * is acceptable since both values are assumed to use ASCII
- * (or some equivalent) encoding
- */
- cert_hostname = Curl_convert_tchar_to_UTF8(cert_hostname_buff);
- if(!cert_hostname) {
- result = CURLE_OUT_OF_MEMORY;
- }
- else{
- int match_result;
-
- match_result = Curl_cert_hostcheck(cert_hostname, conn->host.name);
- if(match_result == CURL_HOST_MATCH) {
- infof(data,
- "schannel: connection hostname (%s) validated "
- "against certificate name (%s)\n",
- conn->host.name,
- cert_hostname);
- result = CURLE_OK;
- }
- else{
- failf(data,
- "schannel: connection hostname (%s) "
- "does not match certificate name (%s)",
- conn->host.name,
- cert_hostname);
- result = CURLE_PEER_FAILED_VERIFICATION;
- }
- Curl_unicodefree(cert_hostname);
- }
- }
- else {
- failf(data,
- "schannel: CertGetNameString did not provide any "
- "certificate name information");
- result = CURLE_PEER_FAILED_VERIFICATION;
- }
+
+ if(!(((pCertContextServer->dwCertEncodingType & X509_ASN_ENCODING) != 0) &&
+ (pCertContextServer->cbCertEncoded > 0)))
+ break;
+
+ x509_der = (const char *)pCertContextServer->pbCertEncoded;
+ x509_der_len = pCertContextServer->cbCertEncoded;
+ memset(&x509_parsed, 0, sizeof(x509_parsed));
+ if(Curl_parseX509(&x509_parsed, x509_der, x509_der + x509_der_len))
+ break;
+
+ pubkey = &x509_parsed.subjectPublicKeyInfo;
+ if(!pubkey->header || pubkey->end <= pubkey->header) {
+ failf(data, "SSL: failed retrieving public key from server certificate");
+ break;
}
- }
- if(pChainContext)
- CertFreeCertificateChain(pChainContext);
+ result = Curl_pin_peer_pubkey(data,
+ pinnedpubkey,
+ (const unsigned char *)pubkey->header,
+ (size_t)(pubkey->end - pubkey->header));
+ if(result) {
+ failf(data, "SSL: public key does not match pinned public key!");
+ }
+ } while(0);
if(pCertContextServer)
CertFreeCertificateContext(pCertContextServer);
return result;
}
-#endif /* _WIN32_WCE */
+
+static void Curl_schannel_checksum(const unsigned char *input,
+ size_t inputlen,
+ unsigned char *checksum,
+ size_t checksumlen,
+ DWORD provType,
+ const unsigned int algId)
+{
+ HCRYPTPROV hProv = 0;
+ HCRYPTHASH hHash = 0;
+ DWORD cbHashSize = 0;
+ DWORD dwHashSizeLen = (DWORD)sizeof(cbHashSize);
+ DWORD dwChecksumLen = (DWORD)checksumlen;
+
+ /* since this can fail in multiple ways, zero memory first so we never
+ * return old data
+ */
+ memset(checksum, 0, checksumlen);
+
+ if(!CryptAcquireContext(&hProv, NULL, NULL, provType,
+ CRYPT_VERIFYCONTEXT))
+ return; /* failed */
+
+ do {
+ if(!CryptCreateHash(hProv, algId, 0, 0, &hHash))
+ break; /* failed */
+
+ /* workaround for original MinGW, should be (const BYTE*) */
+ if(!CryptHashData(hHash, (BYTE*)input, (DWORD)inputlen, 0))
+ break; /* failed */
+
+ /* get hash size */
+ if(!CryptGetHashParam(hHash, HP_HASHSIZE, (BYTE *)&cbHashSize,
+ &dwHashSizeLen, 0))
+ break; /* failed */
+
+ /* check hash size */
+ if(checksumlen < cbHashSize)
+ break; /* failed */
+
+ if(CryptGetHashParam(hHash, HP_HASHVAL, checksum, &dwChecksumLen, 0))
+ break; /* failed */
+ } while(0);
+
+ if(hHash)
+ CryptDestroyHash(hHash);
+
+ if(hProv)
+ CryptReleaseContext(hProv, 0);
+}
+
+static CURLcode Curl_schannel_md5sum(unsigned char *input,
+ size_t inputlen,
+ unsigned char *md5sum,
+ size_t md5len)
+{
+ Curl_schannel_checksum(input, inputlen, md5sum, md5len,
+ PROV_RSA_FULL, CALG_MD5);
+ return CURLE_OK;
+}
+
+static CURLcode Curl_schannel_sha256sum(const unsigned char *input,
+ size_t inputlen,
+ unsigned char *sha256sum,
+ size_t sha256len)
+{
+ Curl_schannel_checksum(input, inputlen, sha256sum, sha256len,
+ PROV_RSA_AES, CALG_SHA_256);
+ return CURLE_OK;
+}
+
+static void *Curl_schannel_get_internals(struct ssl_connect_data *connssl,
+ CURLINFO info UNUSED_PARAM)
+{
+ (void)info;
+ return &BACKEND->ctxt->ctxt_handle;
+}
+
+const struct Curl_ssl Curl_ssl_schannel = {
+ { CURLSSLBACKEND_SCHANNEL, "schannel" }, /* info */
+
+ SSLSUPP_CERTINFO |
+ SSLSUPP_PINNEDPUBKEY,
+
+ sizeof(struct ssl_backend_data),
+
+ Curl_schannel_init, /* init */
+ Curl_schannel_cleanup, /* cleanup */
+ Curl_schannel_version, /* version */
+ Curl_none_check_cxn, /* check_cxn */
+ Curl_schannel_shutdown, /* shutdown */
+ Curl_schannel_data_pending, /* data_pending */
+ Curl_schannel_random, /* random */
+ Curl_none_cert_status_request, /* cert_status_request */
+ Curl_schannel_connect, /* connect */
+ Curl_schannel_connect_nonblocking, /* connect_nonblocking */
+ Curl_schannel_get_internals, /* get_internals */
+ Curl_schannel_close, /* close_one */
+ Curl_none_close_all, /* close_all */
+ Curl_schannel_session_free, /* session_free */
+ Curl_none_set_engine, /* set_engine */
+ Curl_none_set_engine_default, /* set_engine_default */
+ Curl_none_engines_list, /* engines_list */
+ Curl_none_false_start, /* false_start */
+ Curl_schannel_md5sum, /* md5sum */
+ Curl_schannel_sha256sum /* sha256sum */
+};
#endif /* USE_SCHANNEL */
diff --git a/Utilities/cmcurl/lib/vtls/schannel.h b/Utilities/cmcurl/lib/vtls/schannel.h
index 8627c63c9..ee8d7d47a 100644
--- a/Utilities/cmcurl/lib/vtls/schannel.h
+++ b/Utilities/cmcurl/lib/vtls/schannel.h
@@ -8,7 +8,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2012, Marc Hoersken, <info@marc-hoersken.de>, et al.
- * Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -26,96 +26,83 @@
#ifdef USE_SCHANNEL
-#include "urldata.h"
-
-#ifndef UNISP_NAME_A
-#define UNISP_NAME_A "Microsoft Unified Security Protocol Provider"
-#endif
+#include <schnlsp.h>
+#include <schannel.h>
+#include "curl_sspi.h"
-#ifndef UNISP_NAME_W
-#define UNISP_NAME_W L"Microsoft Unified Security Protocol Provider"
-#endif
+#include "urldata.h"
-#ifndef UNISP_NAME
-#ifdef UNICODE
-#define UNISP_NAME UNISP_NAME_W
-#else
-#define UNISP_NAME UNISP_NAME_A
-#endif
+/* <wincrypt.h> has been included via the above <schnlsp.h>.
+ * Or in case of ldap.c, it was included via <winldap.h>.
+ * And since <wincrypt.h> has this:
+ * #define X509_NAME ((LPCSTR) 7)
+ *
+ * And in BoringSSL's <openssl/base.h> there is:
+ * typedef struct X509_name_st X509_NAME;
+ * etc.
+ *
+ * this will cause all kinds of C-preprocessing paste errors in
+ * BoringSSL's <openssl/x509.h>: So just undefine those defines here
+ * (and only here).
+ */
+#if defined(HAVE_BORINGSSL) || defined(OPENSSL_IS_BORINGSSL)
+# undef X509_NAME
+# undef X509_CERT_PAIR
+# undef X509_EXTENSIONS
#endif
-#ifndef SP_PROT_SSL2_CLIENT
-#define SP_PROT_SSL2_CLIENT 0x00000008
-#endif
+extern const struct Curl_ssl Curl_ssl_schannel;
-#ifndef SP_PROT_SSL3_CLIENT
-#define SP_PROT_SSL3_CLIENT 0x00000008
-#endif
+CURLcode Curl_verify_certificate(struct connectdata *conn, int sockindex);
-#ifndef SP_PROT_TLS1_CLIENT
-#define SP_PROT_TLS1_CLIENT 0x00000080
-#endif
+/* structs to expose only in schannel.c and schannel_verify.c */
+#ifdef EXPOSE_SCHANNEL_INTERNAL_STRUCTS
-#ifndef SP_PROT_TLS1_0_CLIENT
-#define SP_PROT_TLS1_0_CLIENT SP_PROT_TLS1_CLIENT
+#ifdef __MINGW32__
+#include <_mingw.h>
+#ifdef __MINGW64_VERSION_MAJOR
+#define HAS_MANUAL_VERIFY_API
#endif
-
-#ifndef SP_PROT_TLS1_1_CLIENT
-#define SP_PROT_TLS1_1_CLIENT 0x00000200
+#else
+#include <wincrypt.h>
+#ifdef CERT_CHAIN_REVOCATION_CHECK_CHAIN
+#define HAS_MANUAL_VERIFY_API
#endif
-
-#ifndef SP_PROT_TLS1_2_CLIENT
-#define SP_PROT_TLS1_2_CLIENT 0x00000800
#endif
-#ifndef SECBUFFER_ALERT
-#define SECBUFFER_ALERT 17
+struct curl_schannel_cred {
+ CredHandle cred_handle;
+ TimeStamp time_stamp;
+ int refcount;
+};
+
+struct curl_schannel_ctxt {
+ CtxtHandle ctxt_handle;
+ TimeStamp time_stamp;
+};
+
+struct ssl_backend_data {
+ struct curl_schannel_cred *cred;
+ struct curl_schannel_ctxt *ctxt;
+ SecPkgContext_StreamSizes stream_sizes;
+ size_t encdata_length, decdata_length;
+ size_t encdata_offset, decdata_offset;
+ unsigned char *encdata_buffer, *decdata_buffer;
+ /* encdata_is_incomplete: if encdata contains only a partial record that
+ can't be decrypted without another Curl_read_plain (that is, status is
+ SEC_E_INCOMPLETE_MESSAGE) then set this true. after Curl_read_plain writes
+ more bytes into encdata then set this back to false. */
+ bool encdata_is_incomplete;
+ unsigned long req_flags, ret_flags;
+ CURLcode recv_unrecoverable_err; /* schannel_recv had an unrecoverable err */
+ bool recv_sspi_close_notify; /* true if connection closed by close_notify */
+ bool recv_connection_closed; /* true if connection closed, regardless how */
+ bool use_alpn; /* true if ALPN is used for this connection */
+#ifdef HAS_MANUAL_VERIFY_API
+ bool use_manual_cred_validation; /* true if manual cred validation is used */
#endif
-
-/* Both schannel buffer sizes must be > 0 */
-#define CURL_SCHANNEL_BUFFER_INIT_SIZE 4096
-#define CURL_SCHANNEL_BUFFER_FREE_SIZE 1024
-
-
-CURLcode Curl_schannel_connect(struct connectdata *conn, int sockindex);
-
-CURLcode Curl_schannel_connect_nonblocking(struct connectdata *conn,
- int sockindex,
- bool *done);
-
-bool Curl_schannel_data_pending(const struct connectdata *conn, int sockindex);
-void Curl_schannel_close(struct connectdata *conn, int sockindex);
-int Curl_schannel_shutdown(struct connectdata *conn, int sockindex);
-void Curl_schannel_session_free(void *ptr);
-
-int Curl_schannel_init(void);
-void Curl_schannel_cleanup(void);
-size_t Curl_schannel_version(char *buffer, size_t size);
-
-CURLcode Curl_schannel_random(unsigned char *entropy, size_t length);
-
-/* Set the API backend definition to Schannel */
-#define CURL_SSL_BACKEND CURLSSLBACKEND_SCHANNEL
-
-/* this backend supports CURLOPT_CERTINFO */
-#define have_curlssl_certinfo 1
-
-/* API setup for Schannel */
-#define curlssl_init Curl_schannel_init
-#define curlssl_cleanup Curl_schannel_cleanup
-#define curlssl_connect Curl_schannel_connect
-#define curlssl_connect_nonblocking Curl_schannel_connect_nonblocking
-#define curlssl_session_free Curl_schannel_session_free
-#define curlssl_close_all(x) ((void)x)
-#define curlssl_close Curl_schannel_close
-#define curlssl_shutdown Curl_schannel_shutdown
-#define curlssl_set_engine(x,y) ((void)x, (void)y, CURLE_NOT_BUILT_IN)
-#define curlssl_set_engine_default(x) ((void)x, CURLE_NOT_BUILT_IN)
-#define curlssl_engines_list(x) ((void)x, (struct curl_slist *)NULL)
-#define curlssl_version Curl_schannel_version
-#define curlssl_check_cxn(x) ((void)x, -1)
-#define curlssl_data_pending Curl_schannel_data_pending
-#define curlssl_random(x,y,z) ((void)x, Curl_schannel_random(y,z))
+};
+#endif /* EXPOSE_SCHANNEL_INTERNAL_STRUCTS */
#endif /* USE_SCHANNEL */
#endif /* HEADER_CURL_SCHANNEL_H */
diff --git a/Utilities/cmcurl/lib/vtls/schannel_verify.c b/Utilities/cmcurl/lib/vtls/schannel_verify.c
new file mode 100644
index 000000000..5a09e969e
--- /dev/null
+++ b/Utilities/cmcurl/lib/vtls/schannel_verify.c
@@ -0,0 +1,572 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2012 - 2016, Marc Hoersken, <info@marc-hoersken.de>
+ * Copyright (C) 2012, Mark Salisbury, <mark.salisbury@hp.com>
+ * Copyright (C) 2012 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+/*
+ * Source file for Schannel-specific certificate verification. This code should
+ * only be invoked by code in schannel.c.
+ */
+
+#include "curl_setup.h"
+
+#ifdef USE_SCHANNEL
+#ifndef USE_WINDOWS_SSPI
+# error "Can't compile SCHANNEL support without SSPI."
+#endif
+
+#define EXPOSE_SCHANNEL_INTERNAL_STRUCTS
+#include "schannel.h"
+
+#ifdef HAS_MANUAL_VERIFY_API
+
+#include "vtls.h"
+#include "sendf.h"
+#include "strerror.h"
+#include "curl_multibyte.h"
+#include "curl_printf.h"
+#include "hostcheck.h"
+#include "system_win32.h"
+
+/* The last #include file should be: */
+#include "curl_memory.h"
+#include "memdebug.h"
+
+#define BACKEND connssl->backend
+
+#define MAX_CAFILE_SIZE 1048576 /* 1 MiB */
+#define BEGIN_CERT "-----BEGIN CERTIFICATE-----"
+#define END_CERT "\n-----END CERTIFICATE-----"
+
+typedef struct {
+ DWORD cbSize;
+ HCERTSTORE hRestrictedRoot;
+ HCERTSTORE hRestrictedTrust;
+ HCERTSTORE hRestrictedOther;
+ DWORD cAdditionalStore;
+ HCERTSTORE *rghAdditionalStore;
+ DWORD dwFlags;
+ DWORD dwUrlRetrievalTimeout;
+ DWORD MaximumCachedCertificates;
+ DWORD CycleDetectionModulus;
+ HCERTSTORE hExclusiveRoot;
+ HCERTSTORE hExclusiveTrustedPeople;
+} CERT_CHAIN_ENGINE_CONFIG_WIN7, *PCERT_CHAIN_ENGINE_CONFIG_WIN7;
+
+static int is_cr_or_lf(char c)
+{
+ return c == '\r' || c == '\n';
+}
+
+static CURLcode add_certs_to_store(HCERTSTORE trust_store,
+ const char *ca_file,
+ struct connectdata *conn)
+{
+ CURLcode result;
+ struct Curl_easy *data = conn->data;
+ HANDLE ca_file_handle = INVALID_HANDLE_VALUE;
+ LARGE_INTEGER file_size;
+ char *ca_file_buffer = NULL;
+ char *current_ca_file_ptr = NULL;
+ TCHAR *ca_file_tstr = NULL;
+ size_t ca_file_bufsize = 0;
+ DWORD total_bytes_read = 0;
+ bool more_certs = 0;
+ int num_certs = 0;
+ size_t END_CERT_LEN;
+
+ ca_file_tstr = Curl_convert_UTF8_to_tchar((char *)ca_file);
+ if(!ca_file_tstr) {
+ char buffer[STRERROR_LEN];
+ failf(data,
+ "schannel: invalid path name for CA file '%s': %s",
+ ca_file, Curl_strerror(GetLastError(), buffer, sizeof(buffer)));
+ result = CURLE_SSL_CACERT_BADFILE;
+ goto cleanup;
+ }
+
+ /*
+ * Read the CA file completely into memory before parsing it. This
+ * optimizes for the common case where the CA file will be relatively
+ * small ( < 1 MiB ).
+ */
+ ca_file_handle = CreateFile(ca_file_tstr,
+ GENERIC_READ,
+ 0,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if(ca_file_handle == INVALID_HANDLE_VALUE) {
+ char buffer[STRERROR_LEN];
+ failf(data,
+ "schannel: failed to open CA file '%s': %s",
+ ca_file, Curl_strerror(GetLastError(), buffer, sizeof(buffer)));
+ result = CURLE_SSL_CACERT_BADFILE;
+ goto cleanup;
+ }
+
+ if(!GetFileSizeEx(ca_file_handle, &file_size)) {
+ char buffer[STRERROR_LEN];
+ failf(data,
+ "schannel: failed to determine size of CA file '%s': %s",
+ ca_file, Curl_strerror(GetLastError(), buffer, sizeof(buffer)));
+ result = CURLE_SSL_CACERT_BADFILE;
+ goto cleanup;
+ }
+
+ if(file_size.QuadPart > MAX_CAFILE_SIZE) {
+ failf(data,
+ "schannel: CA file exceeds max size of %u bytes",
+ MAX_CAFILE_SIZE);
+ result = CURLE_SSL_CACERT_BADFILE;
+ goto cleanup;
+ }
+
+ ca_file_bufsize = (size_t)file_size.QuadPart;
+ ca_file_buffer = (char *)malloc(ca_file_bufsize + 1);
+ if(!ca_file_buffer) {
+ result = CURLE_OUT_OF_MEMORY;
+ goto cleanup;
+ }
+
+ result = CURLE_OK;
+ while(total_bytes_read < ca_file_bufsize) {
+ DWORD bytes_to_read = (DWORD)(ca_file_bufsize - total_bytes_read);
+ DWORD bytes_read = 0;
+
+ if(!ReadFile(ca_file_handle, ca_file_buffer + total_bytes_read,
+ bytes_to_read, &bytes_read, NULL)) {
+ char buffer[STRERROR_LEN];
+ failf(data,
+ "schannel: failed to read from CA file '%s': %s",
+ ca_file, Curl_strerror(GetLastError(), buffer, sizeof(buffer)));
+ result = CURLE_SSL_CACERT_BADFILE;
+ goto cleanup;
+ }
+ if(bytes_read == 0) {
+ /* Premature EOF -- adjust the bufsize to the new value */
+ ca_file_bufsize = total_bytes_read;
+ }
+ else {
+ total_bytes_read += bytes_read;
+ }
+ }
+
+ /* Null terminate the buffer */
+ ca_file_buffer[ca_file_bufsize] = '\0';
+
+ if(result != CURLE_OK) {
+ goto cleanup;
+ }
+
+ END_CERT_LEN = strlen(END_CERT);
+
+ more_certs = 1;
+ current_ca_file_ptr = ca_file_buffer;
+ while(more_certs && *current_ca_file_ptr != '\0') {
+ char *begin_cert_ptr = strstr(current_ca_file_ptr, BEGIN_CERT);
+ if(!begin_cert_ptr || !is_cr_or_lf(begin_cert_ptr[strlen(BEGIN_CERT)])) {
+ more_certs = 0;
+ }
+ else {
+ char *end_cert_ptr = strstr(begin_cert_ptr, END_CERT);
+ if(!end_cert_ptr) {
+ failf(data,
+ "schannel: CA file '%s' is not correctly formatted",
+ ca_file);
+ result = CURLE_SSL_CACERT_BADFILE;
+ more_certs = 0;
+ }
+ else {
+ CERT_BLOB cert_blob;
+ CERT_CONTEXT *cert_context = NULL;
+ BOOL add_cert_result = FALSE;
+ DWORD actual_content_type = 0;
+ DWORD cert_size = (DWORD)
+ ((end_cert_ptr + END_CERT_LEN) - begin_cert_ptr);
+
+ cert_blob.pbData = (BYTE *)begin_cert_ptr;
+ cert_blob.cbData = cert_size;
+ if(!CryptQueryObject(CERT_QUERY_OBJECT_BLOB,
+ &cert_blob,
+ CERT_QUERY_CONTENT_FLAG_CERT,
+ CERT_QUERY_FORMAT_FLAG_ALL,
+ 0,
+ NULL,
+ &actual_content_type,
+ NULL,
+ NULL,
+ NULL,
+ (const void **)&cert_context)) {
+ char buffer[STRERROR_LEN];
+ failf(data,
+ "schannel: failed to extract certificate from CA file "
+ "'%s': %s",
+ ca_file,
+ Curl_strerror(GetLastError(), buffer, sizeof(buffer)));
+ result = CURLE_SSL_CACERT_BADFILE;
+ more_certs = 0;
+ }
+ else {
+ current_ca_file_ptr = begin_cert_ptr + cert_size;
+
+ /* Sanity check that the cert_context object is the right type */
+ if(CERT_QUERY_CONTENT_CERT != actual_content_type) {
+ failf(data,
+ "schannel: unexpected content type '%d' when extracting "
+ "certificate from CA file '%s'",
+ actual_content_type, ca_file);
+ result = CURLE_SSL_CACERT_BADFILE;
+ more_certs = 0;
+ }
+ else {
+ add_cert_result =
+ CertAddCertificateContextToStore(trust_store,
+ cert_context,
+ CERT_STORE_ADD_ALWAYS,
+ NULL);
+ CertFreeCertificateContext(cert_context);
+ if(!add_cert_result) {
+ char buffer[STRERROR_LEN];
+ failf(data,
+ "schannel: failed to add certificate from CA file '%s' "
+ "to certificate store: %s",
+ ca_file,
+ Curl_strerror(GetLastError(), buffer, sizeof(buffer)));
+ result = CURLE_SSL_CACERT_BADFILE;
+ more_certs = 0;
+ }
+ else {
+ num_certs++;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if(result == CURLE_OK) {
+ if(!num_certs) {
+ infof(data,
+ "schannel: did not add any certificates from CA file '%s'\n",
+ ca_file);
+ }
+ else {
+ infof(data,
+ "schannel: added %d certificate(s) from CA file '%s'\n",
+ num_certs, ca_file);
+ }
+ }
+
+cleanup:
+ if(ca_file_handle != INVALID_HANDLE_VALUE) {
+ CloseHandle(ca_file_handle);
+ }
+ Curl_safefree(ca_file_buffer);
+ Curl_unicodefree(ca_file_tstr);
+
+ return result;
+}
+
+static CURLcode verify_host(struct Curl_easy *data,
+ CERT_CONTEXT *pCertContextServer,
+ const char * const conn_hostname)
+{
+ CURLcode result = CURLE_PEER_FAILED_VERIFICATION;
+ TCHAR *cert_hostname_buff = NULL;
+ size_t cert_hostname_buff_index = 0;
+ DWORD len = 0;
+ DWORD actual_len = 0;
+
+ /* CertGetNameString will provide the 8-bit character string without
+ * any decoding */
+ DWORD name_flags = CERT_NAME_DISABLE_IE4_UTF8_FLAG;
+
+#ifdef CERT_NAME_SEARCH_ALL_NAMES_FLAG
+ name_flags |= CERT_NAME_SEARCH_ALL_NAMES_FLAG;
+#endif
+
+ /* Determine the size of the string needed for the cert hostname */
+ len = CertGetNameString(pCertContextServer,
+ CERT_NAME_DNS_TYPE,
+ name_flags,
+ NULL,
+ NULL,
+ 0);
+ if(len == 0) {
+ failf(data,
+ "schannel: CertGetNameString() returned no "
+ "certificate name information");
+ result = CURLE_PEER_FAILED_VERIFICATION;
+ goto cleanup;
+ }
+
+ /* CertGetNameString guarantees that the returned name will not contain
+ * embedded null bytes. This appears to be undocumented behavior.
+ */
+ cert_hostname_buff = (LPTSTR)malloc(len * sizeof(TCHAR));
+ if(!cert_hostname_buff) {
+ result = CURLE_OUT_OF_MEMORY;
+ goto cleanup;
+ }
+ actual_len = CertGetNameString(pCertContextServer,
+ CERT_NAME_DNS_TYPE,
+ name_flags,
+ NULL,
+ (LPTSTR) cert_hostname_buff,
+ len);
+
+ /* Sanity check */
+ if(actual_len != len) {
+ failf(data,
+ "schannel: CertGetNameString() returned certificate "
+ "name information of unexpected size");
+ result = CURLE_PEER_FAILED_VERIFICATION;
+ goto cleanup;
+ }
+
+ /* If HAVE_CERT_NAME_SEARCH_ALL_NAMES is available, the output
+ * will contain all DNS names, where each name is null-terminated
+ * and the last DNS name is double null-terminated. Due to this
+ * encoding, use the length of the buffer to iterate over all names.
+ */
+ result = CURLE_PEER_FAILED_VERIFICATION;
+ while(cert_hostname_buff_index < len &&
+ cert_hostname_buff[cert_hostname_buff_index] != TEXT('\0') &&
+ result == CURLE_PEER_FAILED_VERIFICATION) {
+
+ char *cert_hostname;
+
+ /* Comparing the cert name and the connection hostname encoded as UTF-8
+ * is acceptable since both values are assumed to use ASCII
+ * (or some equivalent) encoding
+ */
+ cert_hostname = Curl_convert_tchar_to_UTF8(
+ &cert_hostname_buff[cert_hostname_buff_index]);
+ if(!cert_hostname) {
+ result = CURLE_OUT_OF_MEMORY;
+ }
+ else {
+ int match_result;
+
+ match_result = Curl_cert_hostcheck(cert_hostname, conn_hostname);
+ if(match_result == CURL_HOST_MATCH) {
+ infof(data,
+ "schannel: connection hostname (%s) validated "
+ "against certificate name (%s)\n",
+ conn_hostname, cert_hostname);
+ result = CURLE_OK;
+ }
+ else {
+ size_t cert_hostname_len;
+
+ infof(data,
+ "schannel: connection hostname (%s) did not match "
+ "against certificate name (%s)\n",
+ conn_hostname, cert_hostname);
+
+ cert_hostname_len = _tcslen(
+ &cert_hostname_buff[cert_hostname_buff_index]);
+
+ /* Move on to next cert name */
+ cert_hostname_buff_index += cert_hostname_len + 1;
+
+ result = CURLE_PEER_FAILED_VERIFICATION;
+ }
+ Curl_unicodefree(cert_hostname);
+ }
+ }
+
+ if(result == CURLE_PEER_FAILED_VERIFICATION) {
+ failf(data,
+ "schannel: CertGetNameString() failed to match "
+ "connection hostname (%s) against server certificate names",
+ conn_hostname);
+ }
+ else if(result != CURLE_OK)
+ failf(data, "schannel: server certificate name verification failed");
+
+cleanup:
+ Curl_unicodefree(cert_hostname_buff);
+
+ return result;
+}
+
+CURLcode Curl_verify_certificate(struct connectdata *conn, int sockindex)
+{
+ SECURITY_STATUS sspi_status;
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ CURLcode result = CURLE_OK;
+ CERT_CONTEXT *pCertContextServer = NULL;
+ const CERT_CHAIN_CONTEXT *pChainContext = NULL;
+ HCERTCHAINENGINE cert_chain_engine = NULL;
+ HCERTSTORE trust_store = NULL;
+ const char * const conn_hostname = SSL_IS_PROXY() ?
+ conn->http_proxy.host.name :
+ conn->host.name;
+
+ sspi_status =
+ s_pSecFn->QueryContextAttributes(&BACKEND->ctxt->ctxt_handle,
+ SECPKG_ATTR_REMOTE_CERT_CONTEXT,
+ &pCertContextServer);
+
+ if((sspi_status != SEC_E_OK) || (pCertContextServer == NULL)) {
+ char buffer[STRERROR_LEN];
+ failf(data, "schannel: Failed to read remote certificate context: %s",
+ Curl_sspi_strerror(sspi_status, buffer, sizeof(buffer)));
+ result = CURLE_PEER_FAILED_VERIFICATION;
+ }
+
+ if(result == CURLE_OK && SSL_CONN_CONFIG(CAfile) &&
+ BACKEND->use_manual_cred_validation) {
+ /*
+ * Create a chain engine that uses the certificates in the CA file as
+ * trusted certificates. This is only supported on Windows 7+.
+ */
+
+ if(Curl_verify_windows_version(6, 1, PLATFORM_WINNT, VERSION_LESS_THAN)) {
+ failf(data, "schannel: this version of Windows is too old to support "
+ "certificate verification via CA bundle file.");
+ result = CURLE_SSL_CACERT_BADFILE;
+ }
+ else {
+ /* Open the certificate store */
+ trust_store = CertOpenStore(CERT_STORE_PROV_MEMORY,
+ 0,
+ (HCRYPTPROV)NULL,
+ CERT_STORE_CREATE_NEW_FLAG,
+ NULL);
+ if(!trust_store) {
+ char buffer[STRERROR_LEN];
+ failf(data, "schannel: failed to create certificate store: %s",
+ Curl_strerror(GetLastError(), buffer, sizeof(buffer)));
+ result = CURLE_SSL_CACERT_BADFILE;
+ }
+ else {
+ result = add_certs_to_store(trust_store, SSL_CONN_CONFIG(CAfile),
+ conn);
+ }
+ }
+
+ if(result == CURLE_OK) {
+ CERT_CHAIN_ENGINE_CONFIG_WIN7 engine_config;
+ BOOL create_engine_result;
+
+ memset(&engine_config, 0, sizeof(engine_config));
+ engine_config.cbSize = sizeof(engine_config);
+ engine_config.hExclusiveRoot = trust_store;
+
+ /* CertCreateCertificateChainEngine will check the expected size of the
+ * CERT_CHAIN_ENGINE_CONFIG structure and fail if the specified size
+ * does not match the expected size. When this occurs, it indicates that
+ * CAINFO is not supported on the version of Windows in use.
+ */
+ create_engine_result =
+ CertCreateCertificateChainEngine(
+ (CERT_CHAIN_ENGINE_CONFIG *)&engine_config, &cert_chain_engine);
+ if(!create_engine_result) {
+ char buffer[STRERROR_LEN];
+ failf(data,
+ "schannel: failed to create certificate chain engine: %s",
+ Curl_strerror(GetLastError(), buffer, sizeof(buffer)));
+ result = CURLE_SSL_CACERT_BADFILE;
+ }
+ }
+ }
+
+ if(result == CURLE_OK) {
+ CERT_CHAIN_PARA ChainPara;
+
+ memset(&ChainPara, 0, sizeof(ChainPara));
+ ChainPara.cbSize = sizeof(ChainPara);
+
+ if(!CertGetCertificateChain(cert_chain_engine,
+ pCertContextServer,
+ NULL,
+ pCertContextServer->hCertStore,
+ &ChainPara,
+ (data->set.ssl.no_revoke ? 0 :
+ CERT_CHAIN_REVOCATION_CHECK_CHAIN),
+ NULL,
+ &pChainContext)) {
+ char buffer[STRERROR_LEN];
+ failf(data, "schannel: CertGetCertificateChain failed: %s",
+ Curl_strerror(GetLastError(), buffer, sizeof(buffer)));
+ pChainContext = NULL;
+ result = CURLE_PEER_FAILED_VERIFICATION;
+ }
+
+ if(result == CURLE_OK) {
+ CERT_SIMPLE_CHAIN *pSimpleChain = pChainContext->rgpChain[0];
+ DWORD dwTrustErrorMask = ~(DWORD)(CERT_TRUST_IS_NOT_TIME_NESTED);
+ dwTrustErrorMask &= pSimpleChain->TrustStatus.dwErrorStatus;
+ if(dwTrustErrorMask) {
+ if(dwTrustErrorMask & CERT_TRUST_IS_REVOKED)
+ failf(data, "schannel: CertGetCertificateChain trust error"
+ " CERT_TRUST_IS_REVOKED");
+ else if(dwTrustErrorMask & CERT_TRUST_IS_PARTIAL_CHAIN)
+ failf(data, "schannel: CertGetCertificateChain trust error"
+ " CERT_TRUST_IS_PARTIAL_CHAIN");
+ else if(dwTrustErrorMask & CERT_TRUST_IS_UNTRUSTED_ROOT)
+ failf(data, "schannel: CertGetCertificateChain trust error"
+ " CERT_TRUST_IS_UNTRUSTED_ROOT");
+ else if(dwTrustErrorMask & CERT_TRUST_IS_NOT_TIME_VALID)
+ failf(data, "schannel: CertGetCertificateChain trust error"
+ " CERT_TRUST_IS_NOT_TIME_VALID");
+ else if(dwTrustErrorMask & CERT_TRUST_REVOCATION_STATUS_UNKNOWN)
+ failf(data, "schannel: CertGetCertificateChain trust error"
+ " CERT_TRUST_REVOCATION_STATUS_UNKNOWN");
+ else
+ failf(data, "schannel: CertGetCertificateChain error mask: 0x%08x",
+ dwTrustErrorMask);
+ result = CURLE_PEER_FAILED_VERIFICATION;
+ }
+ }
+ }
+
+ if(result == CURLE_OK) {
+ if(SSL_CONN_CONFIG(verifyhost)) {
+ result = verify_host(conn->data, pCertContextServer, conn_hostname);
+ }
+ }
+
+ if(cert_chain_engine) {
+ CertFreeCertificateChainEngine(cert_chain_engine);
+ }
+
+ if(trust_store) {
+ CertCloseStore(trust_store, 0);
+ }
+
+ if(pChainContext)
+ CertFreeCertificateChain(pChainContext);
+
+ if(pCertContextServer)
+ CertFreeCertificateContext(pCertContextServer);
+
+ return result;
+}
+
+#endif /* HAS_MANUAL_VERIFY_API */
+#endif /* USE_SCHANNEL */
diff --git a/Utilities/cmcurl/lib/vtls/sectransp.c b/Utilities/cmcurl/lib/vtls/sectransp.c
new file mode 100644
index 000000000..2fdf662a1
--- /dev/null
+++ b/Utilities/cmcurl/lib/vtls/sectransp.c
@@ -0,0 +1,3264 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2012 - 2017, Nick Zitzmann, <nickzman@gmail.com>.
+ * Copyright (C) 2012 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+/*
+ * Source file for all iOS and macOS SecureTransport-specific code for the
+ * TLS/SSL layer. No code but vtls.c should ever call or use these functions.
+ */
+
+#include "curl_setup.h"
+
+#include "urldata.h" /* for the Curl_easy definition */
+#include "curl_base64.h"
+#include "strtok.h"
+#include "multiif.h"
+
+#ifdef USE_SECTRANSP
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-pointer-compare"
+#endif /* __clang__ */
+
+#include <limits.h>
+
+#include <Security/Security.h>
+/* For some reason, when building for iOS, the omnibus header above does
+ * not include SecureTransport.h as of iOS SDK 5.1. */
+#include <Security/SecureTransport.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include <CommonCrypto/CommonDigest.h>
+
+/* The Security framework has changed greatly between iOS and different macOS
+ versions, and we will try to support as many of them as we can (back to
+ Leopard and iOS 5) by using macros and weak-linking.
+
+ In general, you want to build this using the most recent OS SDK, since some
+ features require curl to be built against the latest SDK. TLS 1.1 and 1.2
+ support, for instance, require the macOS 10.8 SDK or later. TLS 1.3
+ requires the macOS 10.13 or iOS 11 SDK or later. */
+#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
+#error "The Secure Transport back-end requires Leopard or later."
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED < 1050 */
+
+#define CURL_BUILD_IOS 0
+#define CURL_BUILD_IOS_7 0
+#define CURL_BUILD_IOS_9 0
+#define CURL_BUILD_IOS_11 0
+#define CURL_BUILD_MAC 1
+/* This is the maximum API level we are allowed to use when building: */
+#define CURL_BUILD_MAC_10_5 MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
+#define CURL_BUILD_MAC_10_6 MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
+#define CURL_BUILD_MAC_10_7 MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+#define CURL_BUILD_MAC_10_8 MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
+#define CURL_BUILD_MAC_10_9 MAC_OS_X_VERSION_MAX_ALLOWED >= 1090
+#define CURL_BUILD_MAC_10_11 MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
+#define CURL_BUILD_MAC_10_13 MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
+/* These macros mean "the following code is present to allow runtime backward
+ compatibility with at least this cat or earlier":
+ (You set this at build-time using the compiler command line option
+ "-mmacos-version-min.") */
+#define CURL_SUPPORT_MAC_10_5 MAC_OS_X_VERSION_MIN_REQUIRED <= 1050
+#define CURL_SUPPORT_MAC_10_6 MAC_OS_X_VERSION_MIN_REQUIRED <= 1060
+#define CURL_SUPPORT_MAC_10_7 MAC_OS_X_VERSION_MIN_REQUIRED <= 1070
+#define CURL_SUPPORT_MAC_10_8 MAC_OS_X_VERSION_MIN_REQUIRED <= 1080
+#define CURL_SUPPORT_MAC_10_9 MAC_OS_X_VERSION_MIN_REQUIRED <= 1090
+
+#elif TARGET_OS_EMBEDDED || TARGET_OS_IPHONE
+#define CURL_BUILD_IOS 1
+#define CURL_BUILD_IOS_7 __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
+#define CURL_BUILD_IOS_9 __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000
+#define CURL_BUILD_IOS_11 __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
+#define CURL_BUILD_MAC 0
+#define CURL_BUILD_MAC_10_5 0
+#define CURL_BUILD_MAC_10_6 0
+#define CURL_BUILD_MAC_10_7 0
+#define CURL_BUILD_MAC_10_8 0
+#define CURL_BUILD_MAC_10_9 0
+#define CURL_BUILD_MAC_10_11 0
+#define CURL_BUILD_MAC_10_13 0
+#define CURL_SUPPORT_MAC_10_5 0
+#define CURL_SUPPORT_MAC_10_6 0
+#define CURL_SUPPORT_MAC_10_7 0
+#define CURL_SUPPORT_MAC_10_8 0
+#define CURL_SUPPORT_MAC_10_9 0
+
+#else
+#error "The Secure Transport back-end requires iOS or macOS."
+#endif /* (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) */
+
+#if CURL_BUILD_MAC
+#include <sys/sysctl.h>
+#endif /* CURL_BUILD_MAC */
+
+#include "urldata.h"
+#include "sendf.h"
+#include "inet_pton.h"
+#include "connect.h"
+#include "select.h"
+#include "vtls.h"
+#include "sectransp.h"
+#include "curl_printf.h"
+#include "strdup.h"
+
+#include "curl_memory.h"
+/* The last #include file should be: */
+#include "memdebug.h"
+
+/* From MacTypes.h (which we can't include because it isn't present in iOS: */
+#define ioErr -36
+#define paramErr -50
+
+struct ssl_backend_data {
+ SSLContextRef ssl_ctx;
+ curl_socket_t ssl_sockfd;
+ bool ssl_direction; /* true if writing, false if reading */
+ size_t ssl_write_buffered_length;
+};
+
+#define BACKEND connssl->backend
+
+/* pinned public key support tests */
+
+/* version 1 supports macOS 10.12+ and iOS 10+ */
+#if ((TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000) || \
+ (!TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200))
+#define SECTRANSP_PINNEDPUBKEY_V1 1
+#endif
+
+/* version 2 supports MacOSX 10.7+ */
+#if (!TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)
+#define SECTRANSP_PINNEDPUBKEY_V2 1
+#endif
+
+#if defined(SECTRANSP_PINNEDPUBKEY_V1) || defined(SECTRANSP_PINNEDPUBKEY_V2)
+/* this backend supports CURLOPT_PINNEDPUBLICKEY */
+#define SECTRANSP_PINNEDPUBKEY 1
+#endif /* SECTRANSP_PINNEDPUBKEY */
+
+#ifdef SECTRANSP_PINNEDPUBKEY
+/* both new and old APIs return rsa keys missing the spki header (not DER) */
+static const unsigned char rsa4096SpkiHeader[] = {
+ 0x30, 0x82, 0x02, 0x22, 0x30, 0x0d,
+ 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
+ 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
+ 0x00, 0x03, 0x82, 0x02, 0x0f, 0x00};
+
+static const unsigned char rsa2048SpkiHeader[] = {
+ 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d,
+ 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
+ 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05,
+ 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00};
+#ifdef SECTRANSP_PINNEDPUBKEY_V1
+/* the *new* version doesn't return DER encoded ecdsa certs like the old... */
+static const unsigned char ecDsaSecp256r1SpkiHeader[] = {
+ 0x30, 0x59, 0x30, 0x13, 0x06, 0x07,
+ 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
+ 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48,
+ 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03,
+ 0x42, 0x00};
+
+static const unsigned char ecDsaSecp384r1SpkiHeader[] = {
+ 0x30, 0x76, 0x30, 0x10, 0x06, 0x07,
+ 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02,
+ 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04,
+ 0x00, 0x22, 0x03, 0x62, 0x00};
+#endif /* SECTRANSP_PINNEDPUBKEY_V1 */
+#endif /* SECTRANSP_PINNEDPUBKEY */
+
+/* The following two functions were ripped from Apple sample code,
+ * with some modifications: */
+static OSStatus SocketRead(SSLConnectionRef connection,
+ void *data, /* owned by
+ * caller, data
+ * RETURNED */
+ size_t *dataLength) /* IN/OUT */
+{
+ size_t bytesToGo = *dataLength;
+ size_t initLen = bytesToGo;
+ UInt8 *currData = (UInt8 *)data;
+ /*int sock = *(int *)connection;*/
+ struct ssl_connect_data *connssl = (struct ssl_connect_data *)connection;
+ int sock = BACKEND->ssl_sockfd;
+ OSStatus rtn = noErr;
+ size_t bytesRead;
+ ssize_t rrtn;
+ int theErr;
+
+ *dataLength = 0;
+
+ for(;;) {
+ bytesRead = 0;
+ rrtn = read(sock, currData, bytesToGo);
+ if(rrtn <= 0) {
+ /* this is guesswork... */
+ theErr = errno;
+ if(rrtn == 0) { /* EOF = server hung up */
+ /* the framework will turn this into errSSLClosedNoNotify */
+ rtn = errSSLClosedGraceful;
+ }
+ else /* do the switch */
+ switch(theErr) {
+ case ENOENT:
+ /* connection closed */
+ rtn = errSSLClosedGraceful;
+ break;
+ case ECONNRESET:
+ rtn = errSSLClosedAbort;
+ break;
+ case EAGAIN:
+ rtn = errSSLWouldBlock;
+ BACKEND->ssl_direction = false;
+ break;
+ default:
+ rtn = ioErr;
+ break;
+ }
+ break;
+ }
+ else {
+ bytesRead = rrtn;
+ }
+ bytesToGo -= bytesRead;
+ currData += bytesRead;
+
+ if(bytesToGo == 0) {
+ /* filled buffer with incoming data, done */
+ break;
+ }
+ }
+ *dataLength = initLen - bytesToGo;
+
+ return rtn;
+}
+
+static OSStatus SocketWrite(SSLConnectionRef connection,
+ const void *data,
+ size_t *dataLength) /* IN/OUT */
+{
+ size_t bytesSent = 0;
+ /*int sock = *(int *)connection;*/
+ struct ssl_connect_data *connssl = (struct ssl_connect_data *)connection;
+ int sock = BACKEND->ssl_sockfd;
+ ssize_t length;
+ size_t dataLen = *dataLength;
+ const UInt8 *dataPtr = (UInt8 *)data;
+ OSStatus ortn;
+ int theErr;
+
+ *dataLength = 0;
+
+ do {
+ length = write(sock,
+ (char *)dataPtr + bytesSent,
+ dataLen - bytesSent);
+ } while((length > 0) &&
+ ( (bytesSent += length) < dataLen) );
+
+ if(length <= 0) {
+ theErr = errno;
+ if(theErr == EAGAIN) {
+ ortn = errSSLWouldBlock;
+ BACKEND->ssl_direction = true;
+ }
+ else {
+ ortn = ioErr;
+ }
+ }
+ else {
+ ortn = noErr;
+ }
+ *dataLength = bytesSent;
+ return ortn;
+}
+
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
+CF_INLINE const char *SSLCipherNameForNumber(SSLCipherSuite cipher)
+{
+ switch(cipher) {
+ /* SSL version 3.0 */
+ case SSL_RSA_WITH_NULL_MD5:
+ return "SSL_RSA_WITH_NULL_MD5";
+ break;
+ case SSL_RSA_WITH_NULL_SHA:
+ return "SSL_RSA_WITH_NULL_SHA";
+ break;
+ case SSL_RSA_EXPORT_WITH_RC4_40_MD5:
+ return "SSL_RSA_EXPORT_WITH_RC4_40_MD5";
+ break;
+ case SSL_RSA_WITH_RC4_128_MD5:
+ return "SSL_RSA_WITH_RC4_128_MD5";
+ break;
+ case SSL_RSA_WITH_RC4_128_SHA:
+ return "SSL_RSA_WITH_RC4_128_SHA";
+ break;
+ case SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5:
+ return "SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5";
+ break;
+ case SSL_RSA_WITH_IDEA_CBC_SHA:
+ return "SSL_RSA_WITH_IDEA_CBC_SHA";
+ break;
+ case SSL_RSA_EXPORT_WITH_DES40_CBC_SHA:
+ return "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA";
+ break;
+ case SSL_RSA_WITH_DES_CBC_SHA:
+ return "SSL_RSA_WITH_DES_CBC_SHA";
+ break;
+ case SSL_RSA_WITH_3DES_EDE_CBC_SHA:
+ return "SSL_RSA_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA:
+ return "SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA";
+ break;
+ case SSL_DH_DSS_WITH_DES_CBC_SHA:
+ return "SSL_DH_DSS_WITH_DES_CBC_SHA";
+ break;
+ case SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA:
+ return "SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA:
+ return "SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA";
+ break;
+ case SSL_DH_RSA_WITH_DES_CBC_SHA:
+ return "SSL_DH_RSA_WITH_DES_CBC_SHA";
+ break;
+ case SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA:
+ return "SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA:
+ return "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA";
+ break;
+ case SSL_DHE_DSS_WITH_DES_CBC_SHA:
+ return "SSL_DHE_DSS_WITH_DES_CBC_SHA";
+ break;
+ case SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA:
+ return "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA:
+ return "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA";
+ break;
+ case SSL_DHE_RSA_WITH_DES_CBC_SHA:
+ return "SSL_DHE_RSA_WITH_DES_CBC_SHA";
+ break;
+ case SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA:
+ return "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case SSL_DH_anon_EXPORT_WITH_RC4_40_MD5:
+ return "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5";
+ break;
+ case SSL_DH_anon_WITH_RC4_128_MD5:
+ return "SSL_DH_anon_WITH_RC4_128_MD5";
+ break;
+ case SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA:
+ return "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA";
+ break;
+ case SSL_DH_anon_WITH_DES_CBC_SHA:
+ return "SSL_DH_anon_WITH_DES_CBC_SHA";
+ break;
+ case SSL_DH_anon_WITH_3DES_EDE_CBC_SHA:
+ return "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case SSL_FORTEZZA_DMS_WITH_NULL_SHA:
+ return "SSL_FORTEZZA_DMS_WITH_NULL_SHA";
+ break;
+ case SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA:
+ return "SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA";
+ break;
+ /* TLS 1.0 with AES (RFC 3268)
+ (Apparently these are used in SSLv3 implementations as well.) */
+ case TLS_RSA_WITH_AES_128_CBC_SHA:
+ return "TLS_RSA_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_DH_DSS_WITH_AES_128_CBC_SHA:
+ return "TLS_DH_DSS_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_DH_RSA_WITH_AES_128_CBC_SHA:
+ return "TLS_DH_RSA_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_DHE_DSS_WITH_AES_128_CBC_SHA:
+ return "TLS_DHE_DSS_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_DHE_RSA_WITH_AES_128_CBC_SHA:
+ return "TLS_DHE_RSA_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_DH_anon_WITH_AES_128_CBC_SHA:
+ return "TLS_DH_anon_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_RSA_WITH_AES_256_CBC_SHA:
+ return "TLS_RSA_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_DH_DSS_WITH_AES_256_CBC_SHA:
+ return "TLS_DH_DSS_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_DH_RSA_WITH_AES_256_CBC_SHA:
+ return "TLS_DH_RSA_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_DHE_DSS_WITH_AES_256_CBC_SHA:
+ return "TLS_DHE_DSS_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_DHE_RSA_WITH_AES_256_CBC_SHA:
+ return "TLS_DHE_RSA_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_DH_anon_WITH_AES_256_CBC_SHA:
+ return "TLS_DH_anon_WITH_AES_256_CBC_SHA";
+ break;
+ /* SSL version 2.0 */
+ case SSL_RSA_WITH_RC2_CBC_MD5:
+ return "SSL_RSA_WITH_RC2_CBC_MD5";
+ break;
+ case SSL_RSA_WITH_IDEA_CBC_MD5:
+ return "SSL_RSA_WITH_IDEA_CBC_MD5";
+ break;
+ case SSL_RSA_WITH_DES_CBC_MD5:
+ return "SSL_RSA_WITH_DES_CBC_MD5";
+ break;
+ case SSL_RSA_WITH_3DES_EDE_CBC_MD5:
+ return "SSL_RSA_WITH_3DES_EDE_CBC_MD5";
+ break;
+ }
+ return "SSL_NULL_WITH_NULL_NULL";
+}
+
+CF_INLINE const char *TLSCipherNameForNumber(SSLCipherSuite cipher)
+{
+ switch(cipher) {
+ /* TLS 1.0 with AES (RFC 3268) */
+ case TLS_RSA_WITH_AES_128_CBC_SHA:
+ return "TLS_RSA_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_DH_DSS_WITH_AES_128_CBC_SHA:
+ return "TLS_DH_DSS_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_DH_RSA_WITH_AES_128_CBC_SHA:
+ return "TLS_DH_RSA_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_DHE_DSS_WITH_AES_128_CBC_SHA:
+ return "TLS_DHE_DSS_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_DHE_RSA_WITH_AES_128_CBC_SHA:
+ return "TLS_DHE_RSA_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_DH_anon_WITH_AES_128_CBC_SHA:
+ return "TLS_DH_anon_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_RSA_WITH_AES_256_CBC_SHA:
+ return "TLS_RSA_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_DH_DSS_WITH_AES_256_CBC_SHA:
+ return "TLS_DH_DSS_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_DH_RSA_WITH_AES_256_CBC_SHA:
+ return "TLS_DH_RSA_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_DHE_DSS_WITH_AES_256_CBC_SHA:
+ return "TLS_DHE_DSS_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_DHE_RSA_WITH_AES_256_CBC_SHA:
+ return "TLS_DHE_RSA_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_DH_anon_WITH_AES_256_CBC_SHA:
+ return "TLS_DH_anon_WITH_AES_256_CBC_SHA";
+ break;
+#if CURL_BUILD_MAC_10_6 || CURL_BUILD_IOS
+ /* TLS 1.0 with ECDSA (RFC 4492) */
+ case TLS_ECDH_ECDSA_WITH_NULL_SHA:
+ return "TLS_ECDH_ECDSA_WITH_NULL_SHA";
+ break;
+ case TLS_ECDH_ECDSA_WITH_RC4_128_SHA:
+ return "TLS_ECDH_ECDSA_WITH_RC4_128_SHA";
+ break;
+ case TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA:
+ return "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA:
+ return "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_ECDHE_ECDSA_WITH_NULL_SHA:
+ return "TLS_ECDHE_ECDSA_WITH_NULL_SHA";
+ break;
+ case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA:
+ return "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA";
+ break;
+ case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA:
+ return "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA:
+ return "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_ECDH_RSA_WITH_NULL_SHA:
+ return "TLS_ECDH_RSA_WITH_NULL_SHA";
+ break;
+ case TLS_ECDH_RSA_WITH_RC4_128_SHA:
+ return "TLS_ECDH_RSA_WITH_RC4_128_SHA";
+ break;
+ case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA:
+ return "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA:
+ return "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_ECDHE_RSA_WITH_NULL_SHA:
+ return "TLS_ECDHE_RSA_WITH_NULL_SHA";
+ break;
+ case TLS_ECDHE_RSA_WITH_RC4_128_SHA:
+ return "TLS_ECDHE_RSA_WITH_RC4_128_SHA";
+ break;
+ case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:
+ return "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:
+ return "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_ECDH_anon_WITH_NULL_SHA:
+ return "TLS_ECDH_anon_WITH_NULL_SHA";
+ break;
+ case TLS_ECDH_anon_WITH_RC4_128_SHA:
+ return "TLS_ECDH_anon_WITH_RC4_128_SHA";
+ break;
+ case TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_ECDH_anon_WITH_AES_128_CBC_SHA:
+ return "TLS_ECDH_anon_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_ECDH_anon_WITH_AES_256_CBC_SHA:
+ return "TLS_ECDH_anon_WITH_AES_256_CBC_SHA";
+ break;
+#endif /* CURL_BUILD_MAC_10_6 || CURL_BUILD_IOS */
+#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
+ /* TLS 1.2 (RFC 5246) */
+ case TLS_RSA_WITH_NULL_MD5:
+ return "TLS_RSA_WITH_NULL_MD5";
+ break;
+ case TLS_RSA_WITH_NULL_SHA:
+ return "TLS_RSA_WITH_NULL_SHA";
+ break;
+ case TLS_RSA_WITH_RC4_128_MD5:
+ return "TLS_RSA_WITH_RC4_128_MD5";
+ break;
+ case TLS_RSA_WITH_RC4_128_SHA:
+ return "TLS_RSA_WITH_RC4_128_SHA";
+ break;
+ case TLS_RSA_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_RSA_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_RSA_WITH_NULL_SHA256:
+ return "TLS_RSA_WITH_NULL_SHA256";
+ break;
+ case TLS_RSA_WITH_AES_128_CBC_SHA256:
+ return "TLS_RSA_WITH_AES_128_CBC_SHA256";
+ break;
+ case TLS_RSA_WITH_AES_256_CBC_SHA256:
+ return "TLS_RSA_WITH_AES_256_CBC_SHA256";
+ break;
+ case TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_DH_DSS_WITH_AES_128_CBC_SHA256:
+ return "TLS_DH_DSS_WITH_AES_128_CBC_SHA256";
+ break;
+ case TLS_DH_RSA_WITH_AES_128_CBC_SHA256:
+ return "TLS_DH_RSA_WITH_AES_128_CBC_SHA256";
+ break;
+ case TLS_DHE_DSS_WITH_AES_128_CBC_SHA256:
+ return "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256";
+ break;
+ case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256:
+ return "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256";
+ break;
+ case TLS_DH_DSS_WITH_AES_256_CBC_SHA256:
+ return "TLS_DH_DSS_WITH_AES_256_CBC_SHA256";
+ break;
+ case TLS_DH_RSA_WITH_AES_256_CBC_SHA256:
+ return "TLS_DH_RSA_WITH_AES_256_CBC_SHA256";
+ break;
+ case TLS_DHE_DSS_WITH_AES_256_CBC_SHA256:
+ return "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256";
+ break;
+ case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256:
+ return "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256";
+ break;
+ case TLS_DH_anon_WITH_RC4_128_MD5:
+ return "TLS_DH_anon_WITH_RC4_128_MD5";
+ break;
+ case TLS_DH_anon_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_DH_anon_WITH_AES_128_CBC_SHA256:
+ return "TLS_DH_anon_WITH_AES_128_CBC_SHA256";
+ break;
+ case TLS_DH_anon_WITH_AES_256_CBC_SHA256:
+ return "TLS_DH_anon_WITH_AES_256_CBC_SHA256";
+ break;
+ /* TLS 1.2 with AES GCM (RFC 5288) */
+ case TLS_RSA_WITH_AES_128_GCM_SHA256:
+ return "TLS_RSA_WITH_AES_128_GCM_SHA256";
+ break;
+ case TLS_RSA_WITH_AES_256_GCM_SHA384:
+ return "TLS_RSA_WITH_AES_256_GCM_SHA384";
+ break;
+ case TLS_DHE_RSA_WITH_AES_128_GCM_SHA256:
+ return "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256";
+ break;
+ case TLS_DHE_RSA_WITH_AES_256_GCM_SHA384:
+ return "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384";
+ break;
+ case TLS_DH_RSA_WITH_AES_128_GCM_SHA256:
+ return "TLS_DH_RSA_WITH_AES_128_GCM_SHA256";
+ break;
+ case TLS_DH_RSA_WITH_AES_256_GCM_SHA384:
+ return "TLS_DH_RSA_WITH_AES_256_GCM_SHA384";
+ break;
+ case TLS_DHE_DSS_WITH_AES_128_GCM_SHA256:
+ return "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256";
+ break;
+ case TLS_DHE_DSS_WITH_AES_256_GCM_SHA384:
+ return "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384";
+ break;
+ case TLS_DH_DSS_WITH_AES_128_GCM_SHA256:
+ return "TLS_DH_DSS_WITH_AES_128_GCM_SHA256";
+ break;
+ case TLS_DH_DSS_WITH_AES_256_GCM_SHA384:
+ return "TLS_DH_DSS_WITH_AES_256_GCM_SHA384";
+ break;
+ case TLS_DH_anon_WITH_AES_128_GCM_SHA256:
+ return "TLS_DH_anon_WITH_AES_128_GCM_SHA256";
+ break;
+ case TLS_DH_anon_WITH_AES_256_GCM_SHA384:
+ return "TLS_DH_anon_WITH_AES_256_GCM_SHA384";
+ break;
+ /* TLS 1.2 with elliptic curve ciphers (RFC 5289) */
+ case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256:
+ return "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256";
+ break;
+ case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384:
+ return "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384";
+ break;
+ case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256:
+ return "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256";
+ break;
+ case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384:
+ return "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384";
+ break;
+ case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:
+ return "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256";
+ break;
+ case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:
+ return "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384";
+ break;
+ case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256:
+ return "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256";
+ break;
+ case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384:
+ return "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384";
+ break;
+ case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:
+ return "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256";
+ break;
+ case TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:
+ return "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384";
+ break;
+ case TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256:
+ return "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256";
+ break;
+ case TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384:
+ return "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384";
+ break;
+ case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256:
+ return "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256";
+ break;
+ case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:
+ return "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384";
+ break;
+ case TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256:
+ return "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256";
+ break;
+ case TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384:
+ return "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384";
+ break;
+ case TLS_EMPTY_RENEGOTIATION_INFO_SCSV:
+ return "TLS_EMPTY_RENEGOTIATION_INFO_SCSV";
+ break;
+#else
+ case SSL_RSA_WITH_NULL_MD5:
+ return "TLS_RSA_WITH_NULL_MD5";
+ break;
+ case SSL_RSA_WITH_NULL_SHA:
+ return "TLS_RSA_WITH_NULL_SHA";
+ break;
+ case SSL_RSA_WITH_RC4_128_MD5:
+ return "TLS_RSA_WITH_RC4_128_MD5";
+ break;
+ case SSL_RSA_WITH_RC4_128_SHA:
+ return "TLS_RSA_WITH_RC4_128_SHA";
+ break;
+ case SSL_RSA_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_RSA_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case SSL_DH_anon_WITH_RC4_128_MD5:
+ return "TLS_DH_anon_WITH_RC4_128_MD5";
+ break;
+ case SSL_DH_anon_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA";
+ break;
+#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
+#if CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7
+ /* TLS PSK (RFC 4279): */
+ case TLS_PSK_WITH_RC4_128_SHA:
+ return "TLS_PSK_WITH_RC4_128_SHA";
+ break;
+ case TLS_PSK_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_PSK_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_PSK_WITH_AES_128_CBC_SHA:
+ return "TLS_PSK_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_PSK_WITH_AES_256_CBC_SHA:
+ return "TLS_PSK_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_DHE_PSK_WITH_RC4_128_SHA:
+ return "TLS_DHE_PSK_WITH_RC4_128_SHA";
+ break;
+ case TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_DHE_PSK_WITH_AES_128_CBC_SHA:
+ return "TLS_DHE_PSK_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_DHE_PSK_WITH_AES_256_CBC_SHA:
+ return "TLS_DHE_PSK_WITH_AES_256_CBC_SHA";
+ break;
+ case TLS_RSA_PSK_WITH_RC4_128_SHA:
+ return "TLS_RSA_PSK_WITH_RC4_128_SHA";
+ break;
+ case TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA:
+ return "TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA";
+ break;
+ case TLS_RSA_PSK_WITH_AES_128_CBC_SHA:
+ return "TLS_RSA_PSK_WITH_AES_128_CBC_SHA";
+ break;
+ case TLS_RSA_PSK_WITH_AES_256_CBC_SHA:
+ return "TLS_RSA_PSK_WITH_AES_256_CBC_SHA";
+ break;
+ /* More TLS PSK (RFC 4785): */
+ case TLS_PSK_WITH_NULL_SHA:
+ return "TLS_PSK_WITH_NULL_SHA";
+ break;
+ case TLS_DHE_PSK_WITH_NULL_SHA:
+ return "TLS_DHE_PSK_WITH_NULL_SHA";
+ break;
+ case TLS_RSA_PSK_WITH_NULL_SHA:
+ return "TLS_RSA_PSK_WITH_NULL_SHA";
+ break;
+ /* Even more TLS PSK (RFC 5487): */
+ case TLS_PSK_WITH_AES_128_GCM_SHA256:
+ return "TLS_PSK_WITH_AES_128_GCM_SHA256";
+ break;
+ case TLS_PSK_WITH_AES_256_GCM_SHA384:
+ return "TLS_PSK_WITH_AES_256_GCM_SHA384";
+ break;
+ case TLS_DHE_PSK_WITH_AES_128_GCM_SHA256:
+ return "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256";
+ break;
+ case TLS_DHE_PSK_WITH_AES_256_GCM_SHA384:
+ return "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384";
+ break;
+ case TLS_RSA_PSK_WITH_AES_128_GCM_SHA256:
+ return "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256";
+ break;
+ case TLS_RSA_PSK_WITH_AES_256_GCM_SHA384:
+ return "TLS_PSK_WITH_AES_256_GCM_SHA384";
+ break;
+ case TLS_PSK_WITH_AES_128_CBC_SHA256:
+ return "TLS_PSK_WITH_AES_128_CBC_SHA256";
+ break;
+ case TLS_PSK_WITH_AES_256_CBC_SHA384:
+ return "TLS_PSK_WITH_AES_256_CBC_SHA384";
+ break;
+ case TLS_PSK_WITH_NULL_SHA256:
+ return "TLS_PSK_WITH_NULL_SHA256";
+ break;
+ case TLS_PSK_WITH_NULL_SHA384:
+ return "TLS_PSK_WITH_NULL_SHA384";
+ break;
+ case TLS_DHE_PSK_WITH_AES_128_CBC_SHA256:
+ return "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256";
+ break;
+ case TLS_DHE_PSK_WITH_AES_256_CBC_SHA384:
+ return "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384";
+ break;
+ case TLS_DHE_PSK_WITH_NULL_SHA256:
+ return "TLS_DHE_PSK_WITH_NULL_SHA256";
+ break;
+ case TLS_DHE_PSK_WITH_NULL_SHA384:
+ return "TLS_RSA_PSK_WITH_NULL_SHA384";
+ break;
+ case TLS_RSA_PSK_WITH_AES_128_CBC_SHA256:
+ return "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256";
+ break;
+ case TLS_RSA_PSK_WITH_AES_256_CBC_SHA384:
+ return "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384";
+ break;
+ case TLS_RSA_PSK_WITH_NULL_SHA256:
+ return "TLS_RSA_PSK_WITH_NULL_SHA256";
+ break;
+ case TLS_RSA_PSK_WITH_NULL_SHA384:
+ return "TLS_RSA_PSK_WITH_NULL_SHA384";
+ break;
+#endif /* CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7 */
+#if CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11
+ /* New ChaCha20+Poly1305 cipher-suites used by TLS 1.3: */
+ case TLS_AES_128_GCM_SHA256:
+ return "TLS_AES_128_GCM_SHA256";
+ break;
+ case TLS_AES_256_GCM_SHA384:
+ return "TLS_AES_256_GCM_SHA384";
+ break;
+ case TLS_CHACHA20_POLY1305_SHA256:
+ return "TLS_CHACHA20_POLY1305_SHA256";
+ break;
+ case TLS_AES_128_CCM_SHA256:
+ return "TLS_AES_128_CCM_SHA256";
+ break;
+ case TLS_AES_128_CCM_8_SHA256:
+ return "TLS_AES_128_CCM_8_SHA256";
+ break;
+ case TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
+ return "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256";
+ break;
+ case TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:
+ return "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256";
+ break;
+#endif /* CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11 */
+ }
+ return "TLS_NULL_WITH_NULL_NULL";
+}
+#endif /* !CURL_DISABLE_VERBOSE_STRINGS */
+
+#if CURL_BUILD_MAC
+CF_INLINE void GetDarwinVersionNumber(int *major, int *minor)
+{
+ int mib[2];
+ char *os_version;
+ size_t os_version_len;
+ char *os_version_major, *os_version_minor;
+ char *tok_buf;
+
+ /* Get the Darwin kernel version from the kernel using sysctl(): */
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_OSRELEASE;
+ if(sysctl(mib, 2, NULL, &os_version_len, NULL, 0) == -1)
+ return;
+ os_version = malloc(os_version_len*sizeof(char));
+ if(!os_version)
+ return;
+ if(sysctl(mib, 2, os_version, &os_version_len, NULL, 0) == -1) {
+ free(os_version);
+ return;
+ }
+
+ /* Parse the version: */
+ os_version_major = strtok_r(os_version, ".", &tok_buf);
+ os_version_minor = strtok_r(NULL, ".", &tok_buf);
+ *major = atoi(os_version_major);
+ *minor = atoi(os_version_minor);
+ free(os_version);
+}
+#endif /* CURL_BUILD_MAC */
+
+/* Apple provides a myriad of ways of getting information about a certificate
+ into a string. Some aren't available under iOS or newer cats. So here's
+ a unified function for getting a string describing the certificate that
+ ought to work in all cats starting with Leopard. */
+CF_INLINE CFStringRef getsubject(SecCertificateRef cert)
+{
+ CFStringRef server_cert_summary = CFSTR("(null)");
+
+#if CURL_BUILD_IOS
+ /* iOS: There's only one way to do this. */
+ server_cert_summary = SecCertificateCopySubjectSummary(cert);
+#else
+#if CURL_BUILD_MAC_10_7
+ /* Lion & later: Get the long description if we can. */
+ if(SecCertificateCopyLongDescription != NULL)
+ server_cert_summary =
+ SecCertificateCopyLongDescription(NULL, cert, NULL);
+ else
+#endif /* CURL_BUILD_MAC_10_7 */
+#if CURL_BUILD_MAC_10_6
+ /* Snow Leopard: Get the certificate summary. */
+ if(SecCertificateCopySubjectSummary != NULL)
+ server_cert_summary = SecCertificateCopySubjectSummary(cert);
+ else
+#endif /* CURL_BUILD_MAC_10_6 */
+ /* Leopard is as far back as we go... */
+ (void)SecCertificateCopyCommonName(cert, &server_cert_summary);
+#endif /* CURL_BUILD_IOS */
+ return server_cert_summary;
+}
+
+static CURLcode CopyCertSubject(struct Curl_easy *data,
+ SecCertificateRef cert, char **certp)
+{
+ CFStringRef c = getsubject(cert);
+ CURLcode result = CURLE_OK;
+ const char *direct;
+ char *cbuf = NULL;
+ *certp = NULL;
+
+ if(!c) {
+ failf(data, "SSL: invalid CA certificate subject");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ }
+
+ /* If the subject is already available as UTF-8 encoded (ie 'direct') then
+ use that, else convert it. */
+ direct = CFStringGetCStringPtr(c, kCFStringEncodingUTF8);
+ if(direct) {
+ *certp = strdup(direct);
+ if(!*certp) {
+ failf(data, "SSL: out of memory");
+ result = CURLE_OUT_OF_MEMORY;
+ }
+ }
+ else {
+ size_t cbuf_size = ((size_t)CFStringGetLength(c) * 4) + 1;
+ cbuf = calloc(cbuf_size, 1);
+ if(cbuf) {
+ if(!CFStringGetCString(c, cbuf, cbuf_size,
+ kCFStringEncodingUTF8)) {
+ failf(data, "SSL: invalid CA certificate subject");
+ result = CURLE_PEER_FAILED_VERIFICATION;
+ }
+ else
+ /* pass back the buffer */
+ *certp = cbuf;
+ }
+ else {
+ failf(data, "SSL: couldn't allocate %zu bytes of memory", cbuf_size);
+ result = CURLE_OUT_OF_MEMORY;
+ }
+ }
+ if(result)
+ free(cbuf);
+ CFRelease(c);
+ return result;
+}
+
+#if CURL_SUPPORT_MAC_10_6
+/* The SecKeychainSearch API was deprecated in Lion, and using it will raise
+ deprecation warnings, so let's not compile this unless it's necessary: */
+static OSStatus CopyIdentityWithLabelOldSchool(char *label,
+ SecIdentityRef *out_c_a_k)
+{
+ OSStatus status = errSecItemNotFound;
+ SecKeychainAttributeList attr_list;
+ SecKeychainAttribute attr;
+ SecKeychainSearchRef search = NULL;
+ SecCertificateRef cert = NULL;
+
+ /* Set up the attribute list: */
+ attr_list.count = 1L;
+ attr_list.attr = &attr;
+
+ /* Set up our lone search criterion: */
+ attr.tag = kSecLabelItemAttr;
+ attr.data = label;
+ attr.length = (UInt32)strlen(label);
+
+ /* Start searching: */
+ status = SecKeychainSearchCreateFromAttributes(NULL,
+ kSecCertificateItemClass,
+ &attr_list,
+ &search);
+ if(status == noErr) {
+ status = SecKeychainSearchCopyNext(search,
+ (SecKeychainItemRef *)&cert);
+ if(status == noErr && cert) {
+ /* If we found a certificate, does it have a private key? */
+ status = SecIdentityCreateWithCertificate(NULL, cert, out_c_a_k);
+ CFRelease(cert);
+ }
+ }
+
+ if(search)
+ CFRelease(search);
+ return status;
+}
+#endif /* CURL_SUPPORT_MAC_10_6 */
+
+static OSStatus CopyIdentityWithLabel(char *label,
+ SecIdentityRef *out_cert_and_key)
+{
+ OSStatus status = errSecItemNotFound;
+
+#if CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS
+ CFArrayRef keys_list;
+ CFIndex keys_list_count;
+ CFIndex i;
+ CFStringRef common_name;
+
+ /* SecItemCopyMatching() was introduced in iOS and Snow Leopard.
+ kSecClassIdentity was introduced in Lion. If both exist, let's use them
+ to find the certificate. */
+ if(SecItemCopyMatching != NULL && kSecClassIdentity != NULL) {
+ CFTypeRef keys[5];
+ CFTypeRef values[5];
+ CFDictionaryRef query_dict;
+ CFStringRef label_cf = CFStringCreateWithCString(NULL, label,
+ kCFStringEncodingUTF8);
+
+ /* Set up our search criteria and expected results: */
+ values[0] = kSecClassIdentity; /* we want a certificate and a key */
+ keys[0] = kSecClass;
+ values[1] = kCFBooleanTrue; /* we want a reference */
+ keys[1] = kSecReturnRef;
+ values[2] = kSecMatchLimitAll; /* kSecMatchLimitOne would be better if the
+ * label matching below worked correctly */
+ keys[2] = kSecMatchLimit;
+ /* identity searches need a SecPolicyRef in order to work */
+ values[3] = SecPolicyCreateSSL(false, NULL);
+ keys[3] = kSecMatchPolicy;
+ /* match the name of the certificate (doesn't work in macOS 10.12.1) */
+ values[4] = label_cf;
+ keys[4] = kSecAttrLabel;
+ query_dict = CFDictionaryCreate(NULL, (const void **)keys,
+ (const void **)values, 5L,
+ &kCFCopyStringDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+ CFRelease(values[3]);
+
+ /* Do we have a match? */
+ status = SecItemCopyMatching(query_dict, (CFTypeRef *) &keys_list);
+
+ /* Because kSecAttrLabel matching doesn't work with kSecClassIdentity,
+ * we need to find the correct identity ourselves */
+ if(status == noErr) {
+ keys_list_count = CFArrayGetCount(keys_list);
+ *out_cert_and_key = NULL;
+ status = 1;
+ for(i = 0; i<keys_list_count; i++) {
+ OSStatus err = noErr;
+ SecCertificateRef cert = NULL;
+ SecIdentityRef identity =
+ (SecIdentityRef) CFArrayGetValueAtIndex(keys_list, i);
+ err = SecIdentityCopyCertificate(identity, &cert);
+ if(err == noErr) {
+#if CURL_BUILD_IOS
+ common_name = SecCertificateCopySubjectSummary(cert);
+#elif CURL_BUILD_MAC_10_7
+ SecCertificateCopyCommonName(cert, &common_name);
+#endif
+ if(CFStringCompare(common_name, label_cf, 0) == kCFCompareEqualTo) {
+ CFRelease(cert);
+ CFRelease(common_name);
+ CFRetain(identity);
+ *out_cert_and_key = identity;
+ status = noErr;
+ break;
+ }
+ CFRelease(common_name);
+ }
+ CFRelease(cert);
+ }
+ }
+
+ if(keys_list)
+ CFRelease(keys_list);
+ CFRelease(query_dict);
+ CFRelease(label_cf);
+ }
+ else {
+#if CURL_SUPPORT_MAC_10_6
+ /* On Leopard and Snow Leopard, fall back to SecKeychainSearch. */
+ status = CopyIdentityWithLabelOldSchool(label, out_cert_and_key);
+#endif /* CURL_SUPPORT_MAC_10_6 */
+ }
+#elif CURL_SUPPORT_MAC_10_6
+ /* For developers building on older cats, we have no choice but to fall back
+ to SecKeychainSearch. */
+ status = CopyIdentityWithLabelOldSchool(label, out_cert_and_key);
+#endif /* CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS */
+ return status;
+}
+
+static OSStatus CopyIdentityFromPKCS12File(const char *cPath,
+ const char *cPassword,
+ SecIdentityRef *out_cert_and_key)
+{
+ OSStatus status = errSecItemNotFound;
+ CFURLRef pkcs_url = CFURLCreateFromFileSystemRepresentation(NULL,
+ (const UInt8 *)cPath, strlen(cPath), false);
+ CFStringRef password = cPassword ? CFStringCreateWithCString(NULL,
+ cPassword, kCFStringEncodingUTF8) : NULL;
+ CFDataRef pkcs_data = NULL;
+
+ /* We can import P12 files on iOS or OS X 10.7 or later: */
+ /* These constants are documented as having first appeared in 10.6 but they
+ raise linker errors when used on that cat for some reason. */
+#if CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS
+ if(CFURLCreateDataAndPropertiesFromResource(NULL, pkcs_url, &pkcs_data,
+ NULL, NULL, &status)) {
+ CFArrayRef items = NULL;
+
+ /* On iOS SecPKCS12Import will never add the client certificate to the
+ * Keychain.
+ *
+ * It gives us back a SecIdentityRef that we can use directly. */
+#if CURL_BUILD_IOS
+ const void *cKeys[] = {kSecImportExportPassphrase};
+ const void *cValues[] = {password};
+ CFDictionaryRef options = CFDictionaryCreate(NULL, cKeys, cValues,
+ password ? 1L : 0L, NULL, NULL);
+
+ if(options != NULL) {
+ status = SecPKCS12Import(pkcs_data, options, &items);
+ CFRelease(options);
+ }
+
+
+ /* On macOS SecPKCS12Import will always add the client certificate to
+ * the Keychain.
+ *
+ * As this doesn't match iOS, and apps may not want to see their client
+ * certificate saved in the the user's keychain, we use SecItemImport
+ * with a NULL keychain to avoid importing it.
+ *
+ * This returns a SecCertificateRef from which we can construct a
+ * SecIdentityRef.
+ */
+#elif CURL_BUILD_MAC_10_7
+ SecItemImportExportKeyParameters keyParams;
+ SecExternalFormat inputFormat = kSecFormatPKCS12;
+ SecExternalItemType inputType = kSecItemTypeCertificate;
+
+ memset(&keyParams, 0x00, sizeof(keyParams));
+ keyParams.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION;
+ keyParams.passphrase = password;
+
+ status = SecItemImport(pkcs_data, NULL, &inputFormat, &inputType,
+ 0, &keyParams, NULL, &items);
+#endif
+
+
+ /* Extract the SecIdentityRef */
+ if(status == errSecSuccess && items && CFArrayGetCount(items)) {
+ CFIndex i, count;
+ count = CFArrayGetCount(items);
+
+ for(i = 0; i < count; i++) {
+ CFTypeRef item = (CFTypeRef) CFArrayGetValueAtIndex(items, i);
+ CFTypeID itemID = CFGetTypeID(item);
+
+ if(itemID == CFDictionaryGetTypeID()) {
+ CFTypeRef identity = (CFTypeRef) CFDictionaryGetValue(
+ (CFDictionaryRef) item,
+ kSecImportItemIdentity);
+ CFRetain(identity);
+ *out_cert_and_key = (SecIdentityRef) identity;
+ break;
+ }
+#if CURL_BUILD_MAC_10_7
+ else if(itemID == SecCertificateGetTypeID()) {
+ status = SecIdentityCreateWithCertificate(NULL,
+ (SecCertificateRef) item,
+ out_cert_and_key);
+ break;
+ }
+#endif
+ }
+ }
+
+ if(items)
+ CFRelease(items);
+ CFRelease(pkcs_data);
+ }
+#endif /* CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS */
+ if(password)
+ CFRelease(password);
+ CFRelease(pkcs_url);
+ return status;
+}
+
+/* This code was borrowed from nss.c, with some modifications:
+ * Determine whether the nickname passed in is a filename that needs to
+ * be loaded as a PEM or a regular NSS nickname.
+ *
+ * returns 1 for a file
+ * returns 0 for not a file
+ */
+CF_INLINE bool is_file(const char *filename)
+{
+ struct_stat st;
+
+ if(filename == NULL)
+ return false;
+
+ if(stat(filename, &st) == 0)
+ return S_ISREG(st.st_mode);
+ return false;
+}
+
+#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
+static CURLcode sectransp_version_from_curl(SSLProtocol *darwinver,
+ long ssl_version)
+{
+ switch(ssl_version) {
+ case CURL_SSLVERSION_TLSv1_0:
+ *darwinver = kTLSProtocol1;
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_1:
+ *darwinver = kTLSProtocol11;
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_2:
+ *darwinver = kTLSProtocol12;
+ return CURLE_OK;
+ case CURL_SSLVERSION_TLSv1_3:
+ /* TLS 1.3 support first appeared in iOS 11 and macOS 10.13 */
+#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1
+ if(__builtin_available(macOS 10.13, iOS 11.0, *)) {
+ *darwinver = kTLSProtocol13;
+ return CURLE_OK;
+ }
+#endif /* (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) &&
+ HAVE_BUILTIN_AVAILABLE == 1 */
+ break;
+ }
+ return CURLE_SSL_CONNECT_ERROR;
+}
+#endif
+
+static CURLcode
+set_ssl_version_min_max(struct connectdata *conn, int sockindex)
+{
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ long ssl_version = SSL_CONN_CONFIG(version);
+ long ssl_version_max = SSL_CONN_CONFIG(version_max);
+ long max_supported_version_by_os;
+
+ /* macOS 10.5-10.7 supported TLS 1.0 only.
+ macOS 10.8 and later, and iOS 5 and later, added TLS 1.1 and 1.2.
+ macOS 10.13 and later, and iOS 11 and later, added TLS 1.3. */
+#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1
+ if(__builtin_available(macOS 10.13, iOS 11.0, *)) {
+ max_supported_version_by_os = CURL_SSLVERSION_MAX_TLSv1_3;
+ }
+ else {
+ max_supported_version_by_os = CURL_SSLVERSION_MAX_TLSv1_2;
+ }
+#else
+ max_supported_version_by_os = CURL_SSLVERSION_MAX_TLSv1_2;
+#endif /* (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) &&
+ HAVE_BUILTIN_AVAILABLE == 1 */
+
+ switch(ssl_version) {
+ case CURL_SSLVERSION_DEFAULT:
+ case CURL_SSLVERSION_TLSv1:
+ ssl_version = CURL_SSLVERSION_TLSv1_0;
+ break;
+ }
+
+ switch(ssl_version_max) {
+ case CURL_SSLVERSION_MAX_NONE:
+ case CURL_SSLVERSION_MAX_DEFAULT:
+ ssl_version_max = max_supported_version_by_os;
+ break;
+ }
+
+#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
+ if(SSLSetProtocolVersionMax != NULL) {
+ SSLProtocol darwin_ver_min = kTLSProtocol1;
+ SSLProtocol darwin_ver_max = kTLSProtocol1;
+ CURLcode result = sectransp_version_from_curl(&darwin_ver_min,
+ ssl_version);
+ if(result) {
+ failf(data, "unsupported min version passed via CURLOPT_SSLVERSION");
+ return result;
+ }
+ result = sectransp_version_from_curl(&darwin_ver_max,
+ ssl_version_max >> 16);
+ if(result) {
+ failf(data, "unsupported max version passed via CURLOPT_SSLVERSION");
+ return result;
+ }
+
+ (void)SSLSetProtocolVersionMin(BACKEND->ssl_ctx, darwin_ver_min);
+ (void)SSLSetProtocolVersionMax(BACKEND->ssl_ctx, darwin_ver_max);
+ return result;
+ }
+ else {
+#if CURL_SUPPORT_MAC_10_8
+ long i = ssl_version;
+ (void)SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx,
+ kSSLProtocolAll,
+ false);
+ for(; i <= (ssl_version_max >> 16); i++) {
+ switch(i) {
+ case CURL_SSLVERSION_TLSv1_0:
+ (void)SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx,
+ kTLSProtocol1,
+ true);
+ break;
+ case CURL_SSLVERSION_TLSv1_1:
+ (void)SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx,
+ kTLSProtocol11,
+ true);
+ break;
+ case CURL_SSLVERSION_TLSv1_2:
+ (void)SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx,
+ kTLSProtocol12,
+ true);
+ break;
+ case CURL_SSLVERSION_TLSv1_3:
+ failf(data, "Your version of the OS does not support TLSv1.3");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ }
+ return CURLE_OK;
+#endif /* CURL_SUPPORT_MAC_10_8 */
+ }
+#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
+ failf(data, "Secure Transport: cannot set SSL protocol");
+ return CURLE_SSL_CONNECT_ERROR;
+}
+
+
+static CURLcode sectransp_connect_step1(struct connectdata *conn,
+ int sockindex)
+{
+ struct Curl_easy *data = conn->data;
+ curl_socket_t sockfd = conn->sock[sockindex];
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ const char * const ssl_cafile = SSL_CONN_CONFIG(CAfile);
+ const bool verifypeer = SSL_CONN_CONFIG(verifypeer);
+ char * const ssl_cert = SSL_SET_OPTION(cert);
+ const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
+ conn->host.name;
+ const long int port = SSL_IS_PROXY() ? conn->port : conn->remote_port;
+#ifdef ENABLE_IPV6
+ struct in6_addr addr;
+#else
+ struct in_addr addr;
+#endif /* ENABLE_IPV6 */
+ size_t all_ciphers_count = 0UL, allowed_ciphers_count = 0UL, i;
+ SSLCipherSuite *all_ciphers = NULL, *allowed_ciphers = NULL;
+ OSStatus err = noErr;
+#if CURL_BUILD_MAC
+ int darwinver_maj = 0, darwinver_min = 0;
+
+ GetDarwinVersionNumber(&darwinver_maj, &darwinver_min);
+#endif /* CURL_BUILD_MAC */
+
+#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
+ if(SSLCreateContext != NULL) { /* use the newer API if available */
+ if(BACKEND->ssl_ctx)
+ CFRelease(BACKEND->ssl_ctx);
+ BACKEND->ssl_ctx = SSLCreateContext(NULL, kSSLClientSide, kSSLStreamType);
+ if(!BACKEND->ssl_ctx) {
+ failf(data, "SSL: couldn't create a context!");
+ return CURLE_OUT_OF_MEMORY;
+ }
+ }
+ else {
+ /* The old ST API does not exist under iOS, so don't compile it: */
+#if CURL_SUPPORT_MAC_10_8
+ if(BACKEND->ssl_ctx)
+ (void)SSLDisposeContext(BACKEND->ssl_ctx);
+ err = SSLNewContext(false, &(BACKEND->ssl_ctx));
+ if(err != noErr) {
+ failf(data, "SSL: couldn't create a context: OSStatus %d", err);
+ return CURLE_OUT_OF_MEMORY;
+ }
+#endif /* CURL_SUPPORT_MAC_10_8 */
+ }
+#else
+ if(BACKEND->ssl_ctx)
+ (void)SSLDisposeContext(BACKEND->ssl_ctx);
+ err = SSLNewContext(false, &(BACKEND->ssl_ctx));
+ if(err != noErr) {
+ failf(data, "SSL: couldn't create a context: OSStatus %d", err);
+ return CURLE_OUT_OF_MEMORY;
+ }
+#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
+ BACKEND->ssl_write_buffered_length = 0UL; /* reset buffered write length */
+
+ /* check to see if we've been told to use an explicit SSL/TLS version */
+#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
+ if(SSLSetProtocolVersionMax != NULL) {
+ switch(conn->ssl_config.version) {
+ case CURL_SSLVERSION_TLSv1:
+ (void)SSLSetProtocolVersionMin(BACKEND->ssl_ctx, kTLSProtocol1);
+#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1
+ if(__builtin_available(macOS 10.13, iOS 11.0, *)) {
+ (void)SSLSetProtocolVersionMax(BACKEND->ssl_ctx, kTLSProtocol13);
+ }
+ else {
+ (void)SSLSetProtocolVersionMax(BACKEND->ssl_ctx, kTLSProtocol12);
+ }
+#else
+ (void)SSLSetProtocolVersionMax(BACKEND->ssl_ctx, kTLSProtocol12);
+#endif /* (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) &&
+ HAVE_BUILTIN_AVAILABLE == 1 */
+ break;
+ case CURL_SSLVERSION_DEFAULT:
+ case CURL_SSLVERSION_TLSv1_0:
+ case CURL_SSLVERSION_TLSv1_1:
+ case CURL_SSLVERSION_TLSv1_2:
+ case CURL_SSLVERSION_TLSv1_3:
+ {
+ CURLcode result = set_ssl_version_min_max(conn, sockindex);
+ if(result != CURLE_OK)
+ return result;
+ break;
+ }
+ case CURL_SSLVERSION_SSLv3:
+ err = SSLSetProtocolVersionMin(BACKEND->ssl_ctx, kSSLProtocol3);
+ if(err != noErr) {
+ failf(data, "Your version of the OS does not support SSLv3");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ (void)SSLSetProtocolVersionMax(BACKEND->ssl_ctx, kSSLProtocol3);
+ break;
+ case CURL_SSLVERSION_SSLv2:
+ err = SSLSetProtocolVersionMin(BACKEND->ssl_ctx, kSSLProtocol2);
+ if(err != noErr) {
+ failf(data, "Your version of the OS does not support SSLv2");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ (void)SSLSetProtocolVersionMax(BACKEND->ssl_ctx, kSSLProtocol2);
+ break;
+ default:
+ failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ }
+ else {
+#if CURL_SUPPORT_MAC_10_8
+ (void)SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx,
+ kSSLProtocolAll,
+ false);
+ switch(conn->ssl_config.version) {
+ case CURL_SSLVERSION_DEFAULT:
+ case CURL_SSLVERSION_TLSv1:
+ (void)SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx,
+ kTLSProtocol1,
+ true);
+ (void)SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx,
+ kTLSProtocol11,
+ true);
+ (void)SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx,
+ kTLSProtocol12,
+ true);
+ break;
+ case CURL_SSLVERSION_TLSv1_0:
+ case CURL_SSLVERSION_TLSv1_1:
+ case CURL_SSLVERSION_TLSv1_2:
+ case CURL_SSLVERSION_TLSv1_3:
+ {
+ CURLcode result = set_ssl_version_min_max(conn, sockindex);
+ if(result != CURLE_OK)
+ return result;
+ break;
+ }
+ case CURL_SSLVERSION_SSLv3:
+ err = SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx,
+ kSSLProtocol3,
+ true);
+ if(err != noErr) {
+ failf(data, "Your version of the OS does not support SSLv3");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ break;
+ case CURL_SSLVERSION_SSLv2:
+ err = SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx,
+ kSSLProtocol2,
+ true);
+ if(err != noErr) {
+ failf(data, "Your version of the OS does not support SSLv2");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ break;
+ default:
+ failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+#endif /* CURL_SUPPORT_MAC_10_8 */
+ }
+#else
+ if(conn->ssl_config.version_max != CURL_SSLVERSION_MAX_NONE) {
+ failf(data, "Your version of the OS does not support to set maximum"
+ " SSL/TLS version");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ (void)SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx, kSSLProtocolAll, false);
+ switch(conn->ssl_config.version) {
+ case CURL_SSLVERSION_DEFAULT:
+ case CURL_SSLVERSION_TLSv1:
+ case CURL_SSLVERSION_TLSv1_0:
+ (void)SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx,
+ kTLSProtocol1,
+ true);
+ break;
+ case CURL_SSLVERSION_TLSv1_1:
+ failf(data, "Your version of the OS does not support TLSv1.1");
+ return CURLE_SSL_CONNECT_ERROR;
+ case CURL_SSLVERSION_TLSv1_2:
+ failf(data, "Your version of the OS does not support TLSv1.2");
+ return CURLE_SSL_CONNECT_ERROR;
+ case CURL_SSLVERSION_TLSv1_3:
+ failf(data, "Your version of the OS does not support TLSv1.3");
+ return CURLE_SSL_CONNECT_ERROR;
+ case CURL_SSLVERSION_SSLv2:
+ err = SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx,
+ kSSLProtocol2,
+ true);
+ if(err != noErr) {
+ failf(data, "Your version of the OS does not support SSLv2");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ break;
+ case CURL_SSLVERSION_SSLv3:
+ err = SSLSetProtocolVersionEnabled(BACKEND->ssl_ctx,
+ kSSLProtocol3,
+ true);
+ if(err != noErr) {
+ failf(data, "Your version of the OS does not support SSLv3");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ break;
+ default:
+ failf(data, "Unrecognized parameter passed via CURLOPT_SSLVERSION");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
+
+#if (CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1
+ if(conn->bits.tls_enable_alpn) {
+ if(__builtin_available(macOS 10.13.4, iOS 11, tvOS 11, *)) {
+ CFMutableArrayRef alpnArr = CFArrayCreateMutable(NULL, 0,
+ &kCFTypeArrayCallBacks);
+
+#ifdef USE_NGHTTP2
+ if(data->set.httpversion >= CURL_HTTP_VERSION_2 &&
+ (!SSL_IS_PROXY() || !conn->bits.tunnel_proxy)) {
+ CFArrayAppendValue(alpnArr, CFSTR(NGHTTP2_PROTO_VERSION_ID));
+ infof(data, "ALPN, offering %s\n", NGHTTP2_PROTO_VERSION_ID);
+ }
+#endif
+
+ CFArrayAppendValue(alpnArr, CFSTR(ALPN_HTTP_1_1));
+ infof(data, "ALPN, offering %s\n", ALPN_HTTP_1_1);
+
+ /* expects length prefixed preference ordered list of protocols in wire
+ * format
+ */
+ err = SSLSetALPNProtocols(BACKEND->ssl_ctx, alpnArr);
+ if(err != noErr)
+ infof(data, "WARNING: failed to set ALPN protocols; OSStatus %d\n",
+ err);
+ CFRelease(alpnArr);
+ }
+ }
+#endif
+
+ if(SSL_SET_OPTION(key)) {
+ infof(data, "WARNING: SSL: CURLOPT_SSLKEY is ignored by Secure "
+ "Transport. The private key must be in the Keychain.\n");
+ }
+
+ if(ssl_cert) {
+ SecIdentityRef cert_and_key = NULL;
+ bool is_cert_file = is_file(ssl_cert);
+
+ /* User wants to authenticate with a client cert. Look for it:
+ If we detect that this is a file on disk, then let's load it.
+ Otherwise, assume that the user wants to use an identity loaded
+ from the Keychain. */
+ if(is_cert_file) {
+ if(!SSL_SET_OPTION(cert_type))
+ infof(data, "WARNING: SSL: Certificate type not set, assuming "
+ "PKCS#12 format.\n");
+ else if(strncmp(SSL_SET_OPTION(cert_type), "P12",
+ strlen(SSL_SET_OPTION(cert_type))) != 0)
+ infof(data, "WARNING: SSL: The Security framework only supports "
+ "loading identities that are in PKCS#12 format.\n");
+
+ err = CopyIdentityFromPKCS12File(ssl_cert,
+ SSL_SET_OPTION(key_passwd), &cert_and_key);
+ }
+ else
+ err = CopyIdentityWithLabel(ssl_cert, &cert_and_key);
+
+ if(err == noErr && cert_and_key) {
+ SecCertificateRef cert = NULL;
+ CFTypeRef certs_c[1];
+ CFArrayRef certs;
+
+ /* If we found one, print it out: */
+ err = SecIdentityCopyCertificate(cert_and_key, &cert);
+ if(err == noErr) {
+ char *certp;
+ CURLcode result = CopyCertSubject(data, cert, &certp);
+ if(!result) {
+ infof(data, "Client certificate: %s\n", certp);
+ free(certp);
+ }
+
+ CFRelease(cert);
+ if(result == CURLE_PEER_FAILED_VERIFICATION)
+ return CURLE_SSL_CERTPROBLEM;
+ if(result)
+ return result;
+ }
+ certs_c[0] = cert_and_key;
+ certs = CFArrayCreate(NULL, (const void **)certs_c, 1L,
+ &kCFTypeArrayCallBacks);
+ err = SSLSetCertificate(BACKEND->ssl_ctx, certs);
+ if(certs)
+ CFRelease(certs);
+ if(err != noErr) {
+ failf(data, "SSL: SSLSetCertificate() failed: OSStatus %d", err);
+ return CURLE_SSL_CERTPROBLEM;
+ }
+ CFRelease(cert_and_key);
+ }
+ else {
+ switch(err) {
+ case errSecAuthFailed: case -25264: /* errSecPkcs12VerifyFailure */
+ failf(data, "SSL: Incorrect password for the certificate \"%s\" "
+ "and its private key.", ssl_cert);
+ break;
+ case -26275: /* errSecDecode */ case -25257: /* errSecUnknownFormat */
+ failf(data, "SSL: Couldn't make sense of the data in the "
+ "certificate \"%s\" and its private key.",
+ ssl_cert);
+ break;
+ case -25260: /* errSecPassphraseRequired */
+ failf(data, "SSL The certificate \"%s\" requires a password.",
+ ssl_cert);
+ break;
+ case errSecItemNotFound:
+ failf(data, "SSL: Can't find the certificate \"%s\" and its private "
+ "key in the Keychain.", ssl_cert);
+ break;
+ default:
+ failf(data, "SSL: Can't load the certificate \"%s\" and its private "
+ "key: OSStatus %d", ssl_cert, err);
+ break;
+ }
+ return CURLE_SSL_CERTPROBLEM;
+ }
+ }
+
+ /* SSL always tries to verify the peer, this only says whether it should
+ * fail to connect if the verification fails, or if it should continue
+ * anyway. In the latter case the result of the verification is checked with
+ * SSL_get_verify_result() below. */
+#if CURL_BUILD_MAC_10_6 || CURL_BUILD_IOS
+ /* Snow Leopard introduced the SSLSetSessionOption() function, but due to
+ a library bug with the way the kSSLSessionOptionBreakOnServerAuth flag
+ works, it doesn't work as expected under Snow Leopard, Lion or
+ Mountain Lion.
+ So we need to call SSLSetEnableCertVerify() on those older cats in order
+ to disable certificate validation if the user turned that off.
+ (SecureTransport will always validate the certificate chain by
+ default.)
+ Note:
+ Darwin 11.x.x is Lion (10.7)
+ Darwin 12.x.x is Mountain Lion (10.8)
+ Darwin 13.x.x is Mavericks (10.9)
+ Darwin 14.x.x is Yosemite (10.10)
+ Darwin 15.x.x is El Capitan (10.11)
+ */
+#if CURL_BUILD_MAC
+ if(SSLSetSessionOption != NULL && darwinver_maj >= 13) {
+#else
+ if(SSLSetSessionOption != NULL) {
+#endif /* CURL_BUILD_MAC */
+ bool break_on_auth = !conn->ssl_config.verifypeer || ssl_cafile;
+ err = SSLSetSessionOption(BACKEND->ssl_ctx,
+ kSSLSessionOptionBreakOnServerAuth,
+ break_on_auth);
+ if(err != noErr) {
+ failf(data, "SSL: SSLSetSessionOption() failed: OSStatus %d", err);
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ }
+ else {
+#if CURL_SUPPORT_MAC_10_8
+ err = SSLSetEnableCertVerify(BACKEND->ssl_ctx,
+ conn->ssl_config.verifypeer?true:false);
+ if(err != noErr) {
+ failf(data, "SSL: SSLSetEnableCertVerify() failed: OSStatus %d", err);
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+#endif /* CURL_SUPPORT_MAC_10_8 */
+ }
+#else
+ err = SSLSetEnableCertVerify(BACKEND->ssl_ctx,
+ conn->ssl_config.verifypeer?true:false);
+ if(err != noErr) {
+ failf(data, "SSL: SSLSetEnableCertVerify() failed: OSStatus %d", err);
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+#endif /* CURL_BUILD_MAC_10_6 || CURL_BUILD_IOS */
+
+ if(ssl_cafile && verifypeer) {
+ bool is_cert_file = is_file(ssl_cafile);
+
+ if(!is_cert_file) {
+ failf(data, "SSL: can't load CA certificate file %s", ssl_cafile);
+ return CURLE_SSL_CACERT_BADFILE;
+ }
+ }
+
+ /* Configure hostname check. SNI is used if available.
+ * Both hostname check and SNI require SSLSetPeerDomainName().
+ * Also: the verifyhost setting influences SNI usage */
+ if(conn->ssl_config.verifyhost) {
+ err = SSLSetPeerDomainName(BACKEND->ssl_ctx, hostname,
+ strlen(hostname));
+
+ if(err != noErr) {
+ infof(data, "WARNING: SSL: SSLSetPeerDomainName() failed: OSStatus %d\n",
+ err);
+ }
+
+ if((Curl_inet_pton(AF_INET, hostname, &addr))
+ #ifdef ENABLE_IPV6
+ || (Curl_inet_pton(AF_INET6, hostname, &addr))
+ #endif
+ ) {
+ infof(data, "WARNING: using IP address, SNI is being disabled by "
+ "the OS.\n");
+ }
+ }
+ else {
+ infof(data, "WARNING: disabling hostname validation also disables SNI.\n");
+ }
+
+ /* Disable cipher suites that ST supports but are not safe. These ciphers
+ are unlikely to be used in any case since ST gives other ciphers a much
+ higher priority, but it's probably better that we not connect at all than
+ to give the user a false sense of security if the server only supports
+ insecure ciphers. (Note: We don't care about SSLv2-only ciphers.) */
+ err = SSLGetNumberSupportedCiphers(BACKEND->ssl_ctx, &all_ciphers_count);
+ if(err != noErr) {
+ failf(data, "SSL: SSLGetNumberSupportedCiphers() failed: OSStatus %d",
+ err);
+ return CURLE_SSL_CIPHER;
+ }
+ all_ciphers = malloc(all_ciphers_count*sizeof(SSLCipherSuite));
+ if(!all_ciphers) {
+ failf(data, "SSL: Failed to allocate memory for all ciphers");
+ return CURLE_OUT_OF_MEMORY;
+ }
+ allowed_ciphers = malloc(all_ciphers_count*sizeof(SSLCipherSuite));
+ if(!allowed_ciphers) {
+ Curl_safefree(all_ciphers);
+ failf(data, "SSL: Failed to allocate memory for allowed ciphers");
+ return CURLE_OUT_OF_MEMORY;
+ }
+ err = SSLGetSupportedCiphers(BACKEND->ssl_ctx, all_ciphers,
+ &all_ciphers_count);
+ if(err != noErr) {
+ Curl_safefree(all_ciphers);
+ Curl_safefree(allowed_ciphers);
+ return CURLE_SSL_CIPHER;
+ }
+ for(i = 0UL ; i < all_ciphers_count ; i++) {
+#if CURL_BUILD_MAC
+ /* There's a known bug in early versions of Mountain Lion where ST's ECC
+ ciphers (cipher suite 0xC001 through 0xC032) simply do not work.
+ Work around the problem here by disabling those ciphers if we are
+ running in an affected version of OS X. */
+ if(darwinver_maj == 12 && darwinver_min <= 3 &&
+ all_ciphers[i] >= 0xC001 && all_ciphers[i] <= 0xC032) {
+ continue;
+ }
+#endif /* CURL_BUILD_MAC */
+ switch(all_ciphers[i]) {
+ /* Disable NULL ciphersuites: */
+ case SSL_NULL_WITH_NULL_NULL:
+ case SSL_RSA_WITH_NULL_MD5:
+ case SSL_RSA_WITH_NULL_SHA:
+ case 0x003B: /* TLS_RSA_WITH_NULL_SHA256 */
+ case SSL_FORTEZZA_DMS_WITH_NULL_SHA:
+ case 0xC001: /* TLS_ECDH_ECDSA_WITH_NULL_SHA */
+ case 0xC006: /* TLS_ECDHE_ECDSA_WITH_NULL_SHA */
+ case 0xC00B: /* TLS_ECDH_RSA_WITH_NULL_SHA */
+ case 0xC010: /* TLS_ECDHE_RSA_WITH_NULL_SHA */
+ case 0x002C: /* TLS_PSK_WITH_NULL_SHA */
+ case 0x002D: /* TLS_DHE_PSK_WITH_NULL_SHA */
+ case 0x002E: /* TLS_RSA_PSK_WITH_NULL_SHA */
+ case 0x00B0: /* TLS_PSK_WITH_NULL_SHA256 */
+ case 0x00B1: /* TLS_PSK_WITH_NULL_SHA384 */
+ case 0x00B4: /* TLS_DHE_PSK_WITH_NULL_SHA256 */
+ case 0x00B5: /* TLS_DHE_PSK_WITH_NULL_SHA384 */
+ case 0x00B8: /* TLS_RSA_PSK_WITH_NULL_SHA256 */
+ case 0x00B9: /* TLS_RSA_PSK_WITH_NULL_SHA384 */
+ /* Disable anonymous ciphersuites: */
+ case SSL_DH_anon_EXPORT_WITH_RC4_40_MD5:
+ case SSL_DH_anon_WITH_RC4_128_MD5:
+ case SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA:
+ case SSL_DH_anon_WITH_DES_CBC_SHA:
+ case SSL_DH_anon_WITH_3DES_EDE_CBC_SHA:
+ case TLS_DH_anon_WITH_AES_128_CBC_SHA:
+ case TLS_DH_anon_WITH_AES_256_CBC_SHA:
+ case 0xC015: /* TLS_ECDH_anon_WITH_NULL_SHA */
+ case 0xC016: /* TLS_ECDH_anon_WITH_RC4_128_SHA */
+ case 0xC017: /* TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA */
+ case 0xC018: /* TLS_ECDH_anon_WITH_AES_128_CBC_SHA */
+ case 0xC019: /* TLS_ECDH_anon_WITH_AES_256_CBC_SHA */
+ case 0x006C: /* TLS_DH_anon_WITH_AES_128_CBC_SHA256 */
+ case 0x006D: /* TLS_DH_anon_WITH_AES_256_CBC_SHA256 */
+ case 0x00A6: /* TLS_DH_anon_WITH_AES_128_GCM_SHA256 */
+ case 0x00A7: /* TLS_DH_anon_WITH_AES_256_GCM_SHA384 */
+ /* Disable weak key ciphersuites: */
+ case SSL_RSA_EXPORT_WITH_RC4_40_MD5:
+ case SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5:
+ case SSL_RSA_EXPORT_WITH_DES40_CBC_SHA:
+ case SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA:
+ case SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA:
+ case SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA:
+ case SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA:
+ case SSL_RSA_WITH_DES_CBC_SHA:
+ case SSL_DH_DSS_WITH_DES_CBC_SHA:
+ case SSL_DH_RSA_WITH_DES_CBC_SHA:
+ case SSL_DHE_DSS_WITH_DES_CBC_SHA:
+ case SSL_DHE_RSA_WITH_DES_CBC_SHA:
+ /* Disable IDEA: */
+ case SSL_RSA_WITH_IDEA_CBC_SHA:
+ case SSL_RSA_WITH_IDEA_CBC_MD5:
+ /* Disable RC4: */
+ case SSL_RSA_WITH_RC4_128_MD5:
+ case SSL_RSA_WITH_RC4_128_SHA:
+ case 0xC002: /* TLS_ECDH_ECDSA_WITH_RC4_128_SHA */
+ case 0xC007: /* TLS_ECDHE_ECDSA_WITH_RC4_128_SHA*/
+ case 0xC00C: /* TLS_ECDH_RSA_WITH_RC4_128_SHA */
+ case 0xC011: /* TLS_ECDHE_RSA_WITH_RC4_128_SHA */
+ case 0x008A: /* TLS_PSK_WITH_RC4_128_SHA */
+ case 0x008E: /* TLS_DHE_PSK_WITH_RC4_128_SHA */
+ case 0x0092: /* TLS_RSA_PSK_WITH_RC4_128_SHA */
+ break;
+ default: /* enable everything else */
+ allowed_ciphers[allowed_ciphers_count++] = all_ciphers[i];
+ break;
+ }
+ }
+ err = SSLSetEnabledCiphers(BACKEND->ssl_ctx, allowed_ciphers,
+ allowed_ciphers_count);
+ Curl_safefree(all_ciphers);
+ Curl_safefree(allowed_ciphers);
+ if(err != noErr) {
+ failf(data, "SSL: SSLSetEnabledCiphers() failed: OSStatus %d", err);
+ return CURLE_SSL_CIPHER;
+ }
+
+#if CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7
+ /* We want to enable 1/n-1 when using a CBC cipher unless the user
+ specifically doesn't want us doing that: */
+ if(SSLSetSessionOption != NULL) {
+ SSLSetSessionOption(BACKEND->ssl_ctx, kSSLSessionOptionSendOneByteRecord,
+ !data->set.ssl.enable_beast);
+ SSLSetSessionOption(BACKEND->ssl_ctx, kSSLSessionOptionFalseStart,
+ data->set.ssl.falsestart); /* false start support */
+ }
+#endif /* CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7 */
+
+ /* Check if there's a cached ID we can/should use here! */
+ if(SSL_SET_OPTION(primary.sessionid)) {
+ char *ssl_sessionid;
+ size_t ssl_sessionid_len;
+
+ Curl_ssl_sessionid_lock(conn);
+ if(!Curl_ssl_getsessionid(conn, (void **)&ssl_sessionid,
+ &ssl_sessionid_len, sockindex)) {
+ /* we got a session id, use it! */
+ err = SSLSetPeerID(BACKEND->ssl_ctx, ssl_sessionid, ssl_sessionid_len);
+ Curl_ssl_sessionid_unlock(conn);
+ if(err != noErr) {
+ failf(data, "SSL: SSLSetPeerID() failed: OSStatus %d", err);
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ /* Informational message */
+ infof(data, "SSL re-using session ID\n");
+ }
+ /* If there isn't one, then let's make one up! This has to be done prior
+ to starting the handshake. */
+ else {
+ CURLcode result;
+ ssl_sessionid =
+ aprintf("%s:%d:%d:%s:%hu", ssl_cafile,
+ verifypeer, SSL_CONN_CONFIG(verifyhost), hostname, port);
+ ssl_sessionid_len = strlen(ssl_sessionid);
+
+ err = SSLSetPeerID(BACKEND->ssl_ctx, ssl_sessionid, ssl_sessionid_len);
+ if(err != noErr) {
+ Curl_ssl_sessionid_unlock(conn);
+ failf(data, "SSL: SSLSetPeerID() failed: OSStatus %d", err);
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+
+ result = Curl_ssl_addsessionid(conn, ssl_sessionid, ssl_sessionid_len,
+ sockindex);
+ Curl_ssl_sessionid_unlock(conn);
+ if(result) {
+ failf(data, "failed to store ssl session");
+ return result;
+ }
+ }
+ }
+
+ err = SSLSetIOFuncs(BACKEND->ssl_ctx, SocketRead, SocketWrite);
+ if(err != noErr) {
+ failf(data, "SSL: SSLSetIOFuncs() failed: OSStatus %d", err);
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+
+ /* pass the raw socket into the SSL layers */
+ /* We need to store the FD in a constant memory address, because
+ * SSLSetConnection() will not copy that address. I've found that
+ * conn->sock[sockindex] may change on its own. */
+ BACKEND->ssl_sockfd = sockfd;
+ err = SSLSetConnection(BACKEND->ssl_ctx, connssl);
+ if(err != noErr) {
+ failf(data, "SSL: SSLSetConnection() failed: %d", err);
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+
+ connssl->connecting_state = ssl_connect_2;
+ return CURLE_OK;
+}
+
+static long pem_to_der(const char *in, unsigned char **out, size_t *outlen)
+{
+ char *sep_start, *sep_end, *cert_start, *cert_end;
+ size_t i, j, err;
+ size_t len;
+ unsigned char *b64;
+
+ /* Jump through the separators at the beginning of the certificate. */
+ sep_start = strstr(in, "-----");
+ if(sep_start == NULL)
+ return 0;
+ cert_start = strstr(sep_start + 1, "-----");
+ if(cert_start == NULL)
+ return -1;
+
+ cert_start += 5;
+
+ /* Find separator after the end of the certificate. */
+ cert_end = strstr(cert_start, "-----");
+ if(cert_end == NULL)
+ return -1;
+
+ sep_end = strstr(cert_end + 1, "-----");
+ if(sep_end == NULL)
+ return -1;
+ sep_end += 5;
+
+ len = cert_end - cert_start;
+ b64 = malloc(len + 1);
+ if(!b64)
+ return -1;
+
+ /* Create base64 string without linefeeds. */
+ for(i = 0, j = 0; i < len; i++) {
+ if(cert_start[i] != '\r' && cert_start[i] != '\n')
+ b64[j++] = cert_start[i];
+ }
+ b64[j] = '\0';
+
+ err = Curl_base64_decode((const char *)b64, out, outlen);
+ free(b64);
+ if(err) {
+ free(*out);
+ return -1;
+ }
+
+ return sep_end - in;
+}
+
+static int read_cert(const char *file, unsigned char **out, size_t *outlen)
+{
+ int fd;
+ ssize_t n, len = 0, cap = 512;
+ unsigned char buf[512], *data;
+
+ fd = open(file, 0);
+ if(fd < 0)
+ return -1;
+
+ data = malloc(cap);
+ if(!data) {
+ close(fd);
+ return -1;
+ }
+
+ for(;;) {
+ n = read(fd, buf, sizeof(buf));
+ if(n < 0) {
+ close(fd);
+ free(data);
+ return -1;
+ }
+ else if(n == 0) {
+ close(fd);
+ break;
+ }
+
+ if(len + n >= cap) {
+ cap *= 2;
+ data = Curl_saferealloc(data, cap);
+ if(!data) {
+ close(fd);
+ return -1;
+ }
+ }
+
+ memcpy(data + len, buf, n);
+ len += n;
+ }
+ data[len] = '\0';
+
+ *out = data;
+ *outlen = len;
+
+ return 0;
+}
+
+static int append_cert_to_array(struct Curl_easy *data,
+ unsigned char *buf, size_t buflen,
+ CFMutableArrayRef array)
+{
+ CFDataRef certdata = CFDataCreate(kCFAllocatorDefault, buf, buflen);
+ char *certp;
+ CURLcode result;
+ if(!certdata) {
+ failf(data, "SSL: failed to allocate array for CA certificate");
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ SecCertificateRef cacert =
+ SecCertificateCreateWithData(kCFAllocatorDefault, certdata);
+ CFRelease(certdata);
+ if(!cacert) {
+ failf(data, "SSL: failed to create SecCertificate from CA certificate");
+ return CURLE_SSL_CACERT_BADFILE;
+ }
+
+ /* Check if cacert is valid. */
+ result = CopyCertSubject(data, cacert, &certp);
+ switch(result) {
+ case CURLE_OK:
+ break;
+ case CURLE_PEER_FAILED_VERIFICATION:
+ return CURLE_SSL_CACERT_BADFILE;
+ case CURLE_OUT_OF_MEMORY:
+ default:
+ return result;
+ }
+ free(certp);
+
+ CFArrayAppendValue(array, cacert);
+ CFRelease(cacert);
+
+ return CURLE_OK;
+}
+
+static int verify_cert(const char *cafile, struct Curl_easy *data,
+ SSLContextRef ctx)
+{
+ int n = 0, rc;
+ long res;
+ unsigned char *certbuf, *der;
+ size_t buflen, derlen, offset = 0;
+
+ if(read_cert(cafile, &certbuf, &buflen) < 0) {
+ failf(data, "SSL: failed to read or invalid CA certificate");
+ return CURLE_SSL_CACERT_BADFILE;
+ }
+
+ /*
+ * Certbuf now contains the contents of the certificate file, which can be
+ * - a single DER certificate,
+ * - a single PEM certificate or
+ * - a bunch of PEM certificates (certificate bundle).
+ *
+ * Go through certbuf, and convert any PEM certificate in it into DER
+ * format.
+ */
+ CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0,
+ &kCFTypeArrayCallBacks);
+ if(array == NULL) {
+ free(certbuf);
+ failf(data, "SSL: out of memory creating CA certificate array");
+ return CURLE_OUT_OF_MEMORY;
+ }
+
+ while(offset < buflen) {
+ n++;
+
+ /*
+ * Check if the certificate is in PEM format, and convert it to DER. If
+ * this fails, we assume the certificate is in DER format.
+ */
+ res = pem_to_der((const char *)certbuf + offset, &der, &derlen);
+ if(res < 0) {
+ free(certbuf);
+ CFRelease(array);
+ failf(data, "SSL: invalid CA certificate #%d (offset %d) in bundle",
+ n, offset);
+ return CURLE_SSL_CACERT_BADFILE;
+ }
+ offset += res;
+
+ if(res == 0 && offset == 0) {
+ /* This is not a PEM file, probably a certificate in DER format. */
+ rc = append_cert_to_array(data, certbuf, buflen, array);
+ free(certbuf);
+ if(rc != CURLE_OK) {
+ CFRelease(array);
+ return rc;
+ }
+ break;
+ }
+ else if(res == 0) {
+ /* No more certificates in the bundle. */
+ free(certbuf);
+ break;
+ }
+
+ rc = append_cert_to_array(data, der, derlen, array);
+ free(der);
+ if(rc != CURLE_OK) {
+ free(certbuf);
+ CFRelease(array);
+ return rc;
+ }
+ }
+
+ SecTrustRef trust;
+ OSStatus ret = SSLCopyPeerTrust(ctx, &trust);
+ if(trust == NULL) {
+ failf(data, "SSL: error getting certificate chain");
+ CFRelease(array);
+ return CURLE_PEER_FAILED_VERIFICATION;
+ }
+ else if(ret != noErr) {
+ CFRelease(array);
+ failf(data, "SSLCopyPeerTrust() returned error %d", ret);
+ return CURLE_PEER_FAILED_VERIFICATION;
+ }
+
+ ret = SecTrustSetAnchorCertificates(trust, array);
+ if(ret != noErr) {
+ CFRelease(array);
+ CFRelease(trust);
+ failf(data, "SecTrustSetAnchorCertificates() returned error %d", ret);
+ return CURLE_PEER_FAILED_VERIFICATION;
+ }
+ ret = SecTrustSetAnchorCertificatesOnly(trust, true);
+ if(ret != noErr) {
+ CFRelease(array);
+ CFRelease(trust);
+ failf(data, "SecTrustSetAnchorCertificatesOnly() returned error %d", ret);
+ return CURLE_PEER_FAILED_VERIFICATION;
+ }
+
+ SecTrustResultType trust_eval = 0;
+ ret = SecTrustEvaluate(trust, &trust_eval);
+ CFRelease(array);
+ CFRelease(trust);
+ if(ret != noErr) {
+ failf(data, "SecTrustEvaluate() returned error %d", ret);
+ return CURLE_PEER_FAILED_VERIFICATION;
+ }
+
+ switch(trust_eval) {
+ case kSecTrustResultUnspecified:
+ case kSecTrustResultProceed:
+ return CURLE_OK;
+
+ case kSecTrustResultRecoverableTrustFailure:
+ case kSecTrustResultDeny:
+ default:
+ failf(data, "SSL: certificate verification failed (result: %d)",
+ trust_eval);
+ return CURLE_PEER_FAILED_VERIFICATION;
+ }
+}
+
+#ifdef SECTRANSP_PINNEDPUBKEY
+static CURLcode pkp_pin_peer_pubkey(struct Curl_easy *data,
+ SSLContextRef ctx,
+ const char *pinnedpubkey)
+{ /* Scratch */
+ size_t pubkeylen, realpubkeylen, spkiHeaderLength = 24;
+ unsigned char *pubkey = NULL, *realpubkey = NULL;
+ const unsigned char *spkiHeader = NULL;
+ CFDataRef publicKeyBits = NULL;
+
+ /* Result is returned to caller */
+ CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH;
+
+ /* if a path wasn't specified, don't pin */
+ if(!pinnedpubkey)
+ return CURLE_OK;
+
+
+ if(!ctx)
+ return result;
+
+ do {
+ SecTrustRef trust;
+ OSStatus ret = SSLCopyPeerTrust(ctx, &trust);
+ if(ret != noErr || trust == NULL)
+ break;
+
+ SecKeyRef keyRef = SecTrustCopyPublicKey(trust);
+ CFRelease(trust);
+ if(keyRef == NULL)
+ break;
+
+#ifdef SECTRANSP_PINNEDPUBKEY_V1
+
+ publicKeyBits = SecKeyCopyExternalRepresentation(keyRef, NULL);
+ CFRelease(keyRef);
+ if(publicKeyBits == NULL)
+ break;
+
+#elif SECTRANSP_PINNEDPUBKEY_V2
+
+ OSStatus success = SecItemExport(keyRef, kSecFormatOpenSSL, 0, NULL,
+ &publicKeyBits);
+ CFRelease(keyRef);
+ if(success != errSecSuccess || publicKeyBits == NULL)
+ break;
+
+#endif /* SECTRANSP_PINNEDPUBKEY_V2 */
+
+ pubkeylen = CFDataGetLength(publicKeyBits);
+ pubkey = (unsigned char *)CFDataGetBytePtr(publicKeyBits);
+
+ switch(pubkeylen) {
+ case 526:
+ /* 4096 bit RSA pubkeylen == 526 */
+ spkiHeader = rsa4096SpkiHeader;
+ break;
+ case 270:
+ /* 2048 bit RSA pubkeylen == 270 */
+ spkiHeader = rsa2048SpkiHeader;
+ break;
+#ifdef SECTRANSP_PINNEDPUBKEY_V1
+ case 65:
+ /* ecDSA secp256r1 pubkeylen == 65 */
+ spkiHeader = ecDsaSecp256r1SpkiHeader;
+ spkiHeaderLength = 26;
+ break;
+ case 97:
+ /* ecDSA secp384r1 pubkeylen == 97 */
+ spkiHeader = ecDsaSecp384r1SpkiHeader;
+ spkiHeaderLength = 23;
+ break;
+ default:
+ infof(data, "SSL: unhandled public key length: %d\n", pubkeylen);
+#elif SECTRANSP_PINNEDPUBKEY_V2
+ default:
+ /* ecDSA secp256r1 pubkeylen == 91 header already included?
+ * ecDSA secp384r1 header already included too
+ * we assume rest of algorithms do same, so do nothing
+ */
+ result = Curl_pin_peer_pubkey(data, pinnedpubkey, pubkey,
+ pubkeylen);
+#endif /* SECTRANSP_PINNEDPUBKEY_V2 */
+ continue; /* break from loop */
+ }
+
+ realpubkeylen = pubkeylen + spkiHeaderLength;
+ realpubkey = malloc(realpubkeylen);
+ if(!realpubkey)
+ break;
+
+ memcpy(realpubkey, spkiHeader, spkiHeaderLength);
+ memcpy(realpubkey + spkiHeaderLength, pubkey, pubkeylen);
+
+ result = Curl_pin_peer_pubkey(data, pinnedpubkey, realpubkey,
+ realpubkeylen);
+
+ } while(0);
+
+ Curl_safefree(realpubkey);
+ if(publicKeyBits != NULL)
+ CFRelease(publicKeyBits);
+
+ return result;
+}
+#endif /* SECTRANSP_PINNEDPUBKEY */
+
+static CURLcode
+sectransp_connect_step2(struct connectdata *conn, int sockindex)
+{
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ OSStatus err;
+ SSLCipherSuite cipher;
+ SSLProtocol protocol = 0;
+ const char * const hostname = SSL_IS_PROXY() ? conn->http_proxy.host.name :
+ conn->host.name;
+
+ DEBUGASSERT(ssl_connect_2 == connssl->connecting_state
+ || ssl_connect_2_reading == connssl->connecting_state
+ || ssl_connect_2_writing == connssl->connecting_state);
+
+ /* Here goes nothing: */
+ err = SSLHandshake(BACKEND->ssl_ctx);
+
+ if(err != noErr) {
+ switch(err) {
+ case errSSLWouldBlock: /* they're not done with us yet */
+ connssl->connecting_state = BACKEND->ssl_direction ?
+ ssl_connect_2_writing : ssl_connect_2_reading;
+ return CURLE_OK;
+
+ /* The below is errSSLServerAuthCompleted; it's not defined in
+ Leopard's headers */
+ case -9841:
+ if(SSL_CONN_CONFIG(CAfile) && SSL_CONN_CONFIG(verifypeer)) {
+ int res = verify_cert(SSL_CONN_CONFIG(CAfile), data,
+ BACKEND->ssl_ctx);
+ if(res != CURLE_OK)
+ return res;
+ }
+ /* the documentation says we need to call SSLHandshake() again */
+ return sectransp_connect_step2(conn, sockindex);
+
+ /* Problem with encrypt / decrypt */
+ case errSSLPeerDecodeError:
+ failf(data, "Decode failed");
+ break;
+ case errSSLDecryptionFail:
+ case errSSLPeerDecryptionFail:
+ failf(data, "Decryption failed");
+ break;
+ case errSSLPeerDecryptError:
+ failf(data, "A decryption error occurred");
+ break;
+ case errSSLBadCipherSuite:
+ failf(data, "A bad SSL cipher suite was encountered");
+ break;
+ case errSSLCrypto:
+ failf(data, "An underlying cryptographic error was encountered");
+ break;
+#if CURL_BUILD_MAC_10_11 || CURL_BUILD_IOS_9
+ case errSSLWeakPeerEphemeralDHKey:
+ failf(data, "Indicates a weak ephemeral Diffie-Hellman key");
+ break;
+#endif
+
+ /* Problem with the message record validation */
+ case errSSLBadRecordMac:
+ case errSSLPeerBadRecordMac:
+ failf(data, "A record with a bad message authentication code (MAC) "
+ "was encountered");
+ break;
+ case errSSLRecordOverflow:
+ case errSSLPeerRecordOverflow:
+ failf(data, "A record overflow occurred");
+ break;
+
+ /* Problem with zlib decompression */
+ case errSSLPeerDecompressFail:
+ failf(data, "Decompression failed");
+ break;
+
+ /* Problem with access */
+ case errSSLPeerAccessDenied:
+ failf(data, "Access was denied");
+ break;
+ case errSSLPeerInsufficientSecurity:
+ failf(data, "There is insufficient security for this operation");
+ break;
+
+ /* These are all certificate problems with the server: */
+ case errSSLXCertChainInvalid:
+ failf(data, "SSL certificate problem: Invalid certificate chain");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ case errSSLUnknownRootCert:
+ failf(data, "SSL certificate problem: Untrusted root certificate");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ case errSSLNoRootCert:
+ failf(data, "SSL certificate problem: No root certificate");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ case errSSLCertNotYetValid:
+ failf(data, "SSL certificate problem: The certificate chain had a "
+ "certificate that is not yet valid");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ case errSSLCertExpired:
+ case errSSLPeerCertExpired:
+ failf(data, "SSL certificate problem: Certificate chain had an "
+ "expired certificate");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ case errSSLBadCert:
+ case errSSLPeerBadCert:
+ failf(data, "SSL certificate problem: Couldn't understand the server "
+ "certificate format");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ case errSSLPeerUnsupportedCert:
+ failf(data, "SSL certificate problem: An unsupported certificate "
+ "format was encountered");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ case errSSLPeerCertRevoked:
+ failf(data, "SSL certificate problem: The certificate was revoked");
+ return CURLE_PEER_FAILED_VERIFICATION;
+ case errSSLPeerCertUnknown:
+ failf(data, "SSL certificate problem: The certificate is unknown");
+ return CURLE_PEER_FAILED_VERIFICATION;
+
+ /* These are all certificate problems with the client: */
+ case errSecAuthFailed:
+ failf(data, "SSL authentication failed");
+ break;
+ case errSSLPeerHandshakeFail:
+ failf(data, "SSL peer handshake failed, the server most likely "
+ "requires a client certificate to connect");
+ break;
+ case errSSLPeerUnknownCA:
+ failf(data, "SSL server rejected the client certificate due to "
+ "the certificate being signed by an unknown certificate "
+ "authority");
+ break;
+
+ /* This error is raised if the server's cert didn't match the server's
+ host name: */
+ case errSSLHostNameMismatch:
+ failf(data, "SSL certificate peer verification failed, the "
+ "certificate did not match \"%s\"\n", conn->host.dispname);
+ return CURLE_PEER_FAILED_VERIFICATION;
+
+ /* Problem with SSL / TLS negotiation */
+ case errSSLNegotiation:
+ failf(data, "Could not negotiate an SSL cipher suite with the server");
+ break;
+ case errSSLBadConfiguration:
+ failf(data, "A configuration error occurred");
+ break;
+ case errSSLProtocol:
+ failf(data, "SSL protocol error");
+ break;
+ case errSSLPeerProtocolVersion:
+ failf(data, "A bad protocol version was encountered");
+ break;
+ case errSSLPeerNoRenegotiation:
+ failf(data, "No renegotiation is allowed");
+ break;
+
+ /* Generic handshake errors: */
+ case errSSLConnectionRefused:
+ failf(data, "Server dropped the connection during the SSL handshake");
+ break;
+ case errSSLClosedAbort:
+ failf(data, "Server aborted the SSL handshake");
+ break;
+ case errSSLClosedGraceful:
+ failf(data, "The connection closed gracefully");
+ break;
+ case errSSLClosedNoNotify:
+ failf(data, "The server closed the session with no notification");
+ break;
+ /* Sometimes paramErr happens with buggy ciphers: */
+ case paramErr:
+ case errSSLInternal:
+ case errSSLPeerInternalError:
+ failf(data, "Internal SSL engine error encountered during the "
+ "SSL handshake");
+ break;
+ case errSSLFatalAlert:
+ failf(data, "Fatal SSL engine error encountered during the SSL "
+ "handshake");
+ break;
+ /* Unclassified error */
+ case errSSLBufferOverflow:
+ failf(data, "An insufficient buffer was provided");
+ break;
+ case errSSLIllegalParam:
+ failf(data, "An illegal parameter was encountered");
+ break;
+ case errSSLModuleAttach:
+ failf(data, "Module attach failure");
+ break;
+ case errSSLSessionNotFound:
+ failf(data, "An attempt to restore an unknown session failed");
+ break;
+ case errSSLPeerExportRestriction:
+ failf(data, "An export restriction occurred");
+ break;
+ case errSSLPeerUserCancelled:
+ failf(data, "The user canceled the operation");
+ break;
+ case errSSLPeerUnexpectedMsg:
+ failf(data, "Peer rejected unexpected message");
+ break;
+#if CURL_BUILD_MAC_10_11 || CURL_BUILD_IOS_9
+ /* Treaing non-fatal error as fatal like before */
+ case errSSLClientHelloReceived:
+ failf(data, "A non-fatal result for providing a server name "
+ "indication");
+ break;
+#endif
+
+ /* Error codes defined in the enum but should never be returned.
+ We list them here just in case. */
+#if CURL_BUILD_MAC_10_6
+ /* Only returned when kSSLSessionOptionBreakOnCertRequested is set */
+ case errSSLClientCertRequested:
+ failf(data, "The server has requested a client certificate");
+ break;
+#endif
+#if CURL_BUILD_MAC_10_9
+ /* Alias for errSSLLast, end of error range */
+ case errSSLUnexpectedRecord:
+ failf(data, "Unexpected (skipped) record in DTLS");
+ break;
+#endif
+ default:
+ /* May also return codes listed in Security Framework Result Codes */
+ failf(data, "Unknown SSL protocol error in connection to %s:%d",
+ hostname, err);
+ break;
+ }
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ else {
+ /* we have been connected fine, we're not waiting for anything else. */
+ connssl->connecting_state = ssl_connect_3;
+
+#ifdef SECTRANSP_PINNEDPUBKEY
+ if(data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG]) {
+ CURLcode result = pkp_pin_peer_pubkey(data, BACKEND->ssl_ctx,
+ data->set.str[STRING_SSL_PINNEDPUBLICKEY_ORIG]);
+ if(result) {
+ failf(data, "SSL: public key does not match pinned public key!");
+ return result;
+ }
+ }
+#endif /* SECTRANSP_PINNEDPUBKEY */
+
+ /* Informational message */
+ (void)SSLGetNegotiatedCipher(BACKEND->ssl_ctx, &cipher);
+ (void)SSLGetNegotiatedProtocolVersion(BACKEND->ssl_ctx, &protocol);
+ switch(protocol) {
+ case kSSLProtocol2:
+ infof(data, "SSL 2.0 connection using %s\n",
+ SSLCipherNameForNumber(cipher));
+ break;
+ case kSSLProtocol3:
+ infof(data, "SSL 3.0 connection using %s\n",
+ SSLCipherNameForNumber(cipher));
+ break;
+ case kTLSProtocol1:
+ infof(data, "TLS 1.0 connection using %s\n",
+ TLSCipherNameForNumber(cipher));
+ break;
+#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
+ case kTLSProtocol11:
+ infof(data, "TLS 1.1 connection using %s\n",
+ TLSCipherNameForNumber(cipher));
+ break;
+ case kTLSProtocol12:
+ infof(data, "TLS 1.2 connection using %s\n",
+ TLSCipherNameForNumber(cipher));
+ break;
+#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
+#if CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11
+ case kTLSProtocol13:
+ infof(data, "TLS 1.3 connection using %s\n",
+ TLSCipherNameForNumber(cipher));
+ break;
+#endif /* CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11 */
+ default:
+ infof(data, "Unknown protocol connection\n");
+ break;
+ }
+
+#if(CURL_BUILD_MAC_10_13 || CURL_BUILD_IOS_11) && HAVE_BUILTIN_AVAILABLE == 1
+ if(conn->bits.tls_enable_alpn) {
+ if(__builtin_available(macOS 10.13.4, iOS 11, tvOS 11, *)) {
+ CFArrayRef alpnArr = NULL;
+ CFStringRef chosenProtocol = NULL;
+ err = SSLCopyALPNProtocols(BACKEND->ssl_ctx, &alpnArr);
+
+ if(err == noErr && alpnArr && CFArrayGetCount(alpnArr) >= 1)
+ chosenProtocol = CFArrayGetValueAtIndex(alpnArr, 0);
+
+#ifdef USE_NGHTTP2
+ if(chosenProtocol &&
+ !CFStringCompare(chosenProtocol, CFSTR(NGHTTP2_PROTO_VERSION_ID),
+ 0)) {
+ conn->negnpn = CURL_HTTP_VERSION_2;
+ }
+ else
+#endif
+ if(chosenProtocol &&
+ !CFStringCompare(chosenProtocol, CFSTR(ALPN_HTTP_1_1), 0)) {
+ conn->negnpn = CURL_HTTP_VERSION_1_1;
+ }
+ else
+ infof(data, "ALPN, server did not agree to a protocol\n");
+
+ Curl_multiuse_state(conn, conn->negnpn == CURL_HTTP_VERSION_2 ?
+ BUNDLE_MULTIPLEX : BUNDLE_NO_MULTIUSE);
+
+ /* chosenProtocol is a reference to the string within alpnArr
+ and doesn't need to be freed separately */
+ if(alpnArr)
+ CFRelease(alpnArr);
+ }
+ }
+#endif
+
+ return CURLE_OK;
+ }
+}
+
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
+/* This should be called during step3 of the connection at the earliest */
+static void
+show_verbose_server_cert(struct connectdata *conn,
+ int sockindex)
+{
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ CFArrayRef server_certs = NULL;
+ SecCertificateRef server_cert;
+ OSStatus err;
+ CFIndex i, count;
+ SecTrustRef trust = NULL;
+
+ if(!BACKEND->ssl_ctx)
+ return;
+
+#if CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS
+#if CURL_BUILD_IOS
+#pragma unused(server_certs)
+ err = SSLCopyPeerTrust(BACKEND->ssl_ctx, &trust);
+ /* For some reason, SSLCopyPeerTrust() can return noErr and yet return
+ a null trust, so be on guard for that: */
+ if(err == noErr && trust) {
+ count = SecTrustGetCertificateCount(trust);
+ for(i = 0L ; i < count ; i++) {
+ CURLcode result;
+ char *certp;
+ server_cert = SecTrustGetCertificateAtIndex(trust, i);
+ result = CopyCertSubject(data, server_cert, &certp);
+ if(!result) {
+ infof(data, "Server certificate: %s\n", certp);
+ free(certp);
+ }
+ }
+ CFRelease(trust);
+ }
+#else
+ /* SSLCopyPeerCertificates() is deprecated as of Mountain Lion.
+ The function SecTrustGetCertificateAtIndex() is officially present
+ in Lion, but it is unfortunately also present in Snow Leopard as
+ private API and doesn't work as expected. So we have to look for
+ a different symbol to make sure this code is only executed under
+ Lion or later. */
+ if(SecTrustEvaluateAsync != NULL) {
+#pragma unused(server_certs)
+ err = SSLCopyPeerTrust(BACKEND->ssl_ctx, &trust);
+ /* For some reason, SSLCopyPeerTrust() can return noErr and yet return
+ a null trust, so be on guard for that: */
+ if(err == noErr && trust) {
+ count = SecTrustGetCertificateCount(trust);
+ for(i = 0L ; i < count ; i++) {
+ char *certp;
+ CURLcode result;
+ server_cert = SecTrustGetCertificateAtIndex(trust, i);
+ result = CopyCertSubject(data, server_cert, &certp);
+ if(!result) {
+ infof(data, "Server certificate: %s\n", certp);
+ free(certp);
+ }
+ }
+ CFRelease(trust);
+ }
+ }
+ else {
+#if CURL_SUPPORT_MAC_10_8
+ err = SSLCopyPeerCertificates(BACKEND->ssl_ctx, &server_certs);
+ /* Just in case SSLCopyPeerCertificates() returns null too... */
+ if(err == noErr && server_certs) {
+ count = CFArrayGetCount(server_certs);
+ for(i = 0L ; i < count ; i++) {
+ char *certp;
+ CURLcode result;
+ server_cert = (SecCertificateRef)CFArrayGetValueAtIndex(server_certs,
+ i);
+ result = CopyCertSubject(data, server_cert, &certp);
+ if(!result) {
+ infof(data, "Server certificate: %s\n", certp);
+ free(certp);
+ }
+ }
+ CFRelease(server_certs);
+ }
+#endif /* CURL_SUPPORT_MAC_10_8 */
+ }
+#endif /* CURL_BUILD_IOS */
+#else
+#pragma unused(trust)
+ err = SSLCopyPeerCertificates(BACKEND->ssl_ctx, &server_certs);
+ if(err == noErr) {
+ count = CFArrayGetCount(server_certs);
+ for(i = 0L ; i < count ; i++) {
+ CURLcode result;
+ char *certp;
+ server_cert = (SecCertificateRef)CFArrayGetValueAtIndex(server_certs, i);
+ result = CopyCertSubject(data, server_cert, &certp);
+ if(!result) {
+ infof(data, "Server certificate: %s\n", certp);
+ free(certp);
+ }
+ }
+ CFRelease(server_certs);
+ }
+#endif /* CURL_BUILD_MAC_10_7 || CURL_BUILD_IOS */
+}
+#endif /* !CURL_DISABLE_VERBOSE_STRINGS */
+
+static CURLcode
+sectransp_connect_step3(struct connectdata *conn,
+ int sockindex)
+{
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+
+ /* There is no step 3!
+ * Well, okay, if verbose mode is on, let's print the details of the
+ * server certificates. */
+#ifndef CURL_DISABLE_VERBOSE_STRINGS
+ if(data->set.verbose)
+ show_verbose_server_cert(conn, sockindex);
+#endif
+
+ connssl->connecting_state = ssl_connect_done;
+ return CURLE_OK;
+}
+
+static Curl_recv sectransp_recv;
+static Curl_send sectransp_send;
+
+static CURLcode
+sectransp_connect_common(struct connectdata *conn,
+ int sockindex,
+ bool nonblocking,
+ bool *done)
+{
+ CURLcode result;
+ struct Curl_easy *data = conn->data;
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ curl_socket_t sockfd = conn->sock[sockindex];
+ long timeout_ms;
+ int what;
+
+ /* check if the connection has already been established */
+ if(ssl_connection_complete == connssl->state) {
+ *done = TRUE;
+ return CURLE_OK;
+ }
+
+ if(ssl_connect_1 == connssl->connecting_state) {
+ /* Find out how much more time we're allowed */
+ timeout_ms = Curl_timeleft(data, NULL, TRUE);
+
+ if(timeout_ms < 0) {
+ /* no need to continue if time already is up */
+ failf(data, "SSL connection timeout");
+ return CURLE_OPERATION_TIMEDOUT;
+ }
+
+ result = sectransp_connect_step1(conn, sockindex);
+ if(result)
+ return result;
+ }
+
+ while(ssl_connect_2 == connssl->connecting_state ||
+ ssl_connect_2_reading == connssl->connecting_state ||
+ ssl_connect_2_writing == connssl->connecting_state) {
+
+ /* check allowed time left */
+ timeout_ms = Curl_timeleft(data, NULL, TRUE);
+
+ if(timeout_ms < 0) {
+ /* no need to continue if time already is up */
+ failf(data, "SSL connection timeout");
+ return CURLE_OPERATION_TIMEDOUT;
+ }
+
+ /* if ssl is expecting something, check if it's available. */
+ if(connssl->connecting_state == ssl_connect_2_reading ||
+ connssl->connecting_state == ssl_connect_2_writing) {
+
+ curl_socket_t writefd = ssl_connect_2_writing ==
+ connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
+ curl_socket_t readfd = ssl_connect_2_reading ==
+ connssl->connecting_state?sockfd:CURL_SOCKET_BAD;
+
+ what = Curl_socket_check(readfd, CURL_SOCKET_BAD, writefd,
+ nonblocking?0:timeout_ms);
+ if(what < 0) {
+ /* fatal error */
+ failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ else if(0 == what) {
+ if(nonblocking) {
+ *done = FALSE;
+ return CURLE_OK;
+ }
+ else {
+ /* timeout */
+ failf(data, "SSL connection timeout");
+ return CURLE_OPERATION_TIMEDOUT;
+ }
+ }
+ /* socket is readable or writable */
+ }
+
+ /* Run transaction, and return to the caller if it failed or if this
+ * connection is done nonblocking and this loop would execute again. This
+ * permits the owner of a multi handle to abort a connection attempt
+ * before step2 has completed while ensuring that a client using select()
+ * or epoll() will always have a valid fdset to wait on.
+ */
+ result = sectransp_connect_step2(conn, sockindex);
+ if(result || (nonblocking &&
+ (ssl_connect_2 == connssl->connecting_state ||
+ ssl_connect_2_reading == connssl->connecting_state ||
+ ssl_connect_2_writing == connssl->connecting_state)))
+ return result;
+
+ } /* repeat step2 until all transactions are done. */
+
+
+ if(ssl_connect_3 == connssl->connecting_state) {
+ result = sectransp_connect_step3(conn, sockindex);
+ if(result)
+ return result;
+ }
+
+ if(ssl_connect_done == connssl->connecting_state) {
+ connssl->state = ssl_connection_complete;
+ conn->recv[sockindex] = sectransp_recv;
+ conn->send[sockindex] = sectransp_send;
+ *done = TRUE;
+ }
+ else
+ *done = FALSE;
+
+ /* Reset our connect state machine */
+ connssl->connecting_state = ssl_connect_1;
+
+ return CURLE_OK;
+}
+
+static CURLcode Curl_sectransp_connect_nonblocking(struct connectdata *conn,
+ int sockindex, bool *done)
+{
+ return sectransp_connect_common(conn, sockindex, TRUE, done);
+}
+
+static CURLcode Curl_sectransp_connect(struct connectdata *conn, int sockindex)
+{
+ CURLcode result;
+ bool done = FALSE;
+
+ result = sectransp_connect_common(conn, sockindex, FALSE, &done);
+
+ if(result)
+ return result;
+
+ DEBUGASSERT(done);
+
+ return CURLE_OK;
+}
+
+static void Curl_sectransp_close(struct connectdata *conn, int sockindex)
+{
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+
+ if(BACKEND->ssl_ctx) {
+ (void)SSLClose(BACKEND->ssl_ctx);
+#if CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS
+ if(SSLCreateContext != NULL)
+ CFRelease(BACKEND->ssl_ctx);
+#if CURL_SUPPORT_MAC_10_8
+ else
+ (void)SSLDisposeContext(BACKEND->ssl_ctx);
+#endif /* CURL_SUPPORT_MAC_10_8 */
+#else
+ (void)SSLDisposeContext(BACKEND->ssl_ctx);
+#endif /* CURL_BUILD_MAC_10_8 || CURL_BUILD_IOS */
+ BACKEND->ssl_ctx = NULL;
+ }
+ BACKEND->ssl_sockfd = 0;
+}
+
+static int Curl_sectransp_shutdown(struct connectdata *conn, int sockindex)
+{
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ struct Curl_easy *data = conn->data;
+ ssize_t nread;
+ int what;
+ int rc;
+ char buf[120];
+
+ if(!BACKEND->ssl_ctx)
+ return 0;
+
+#ifndef CURL_DISABLE_FTP
+ if(data->set.ftp_ccc != CURLFTPSSL_CCC_ACTIVE)
+ return 0;
+#endif
+
+ Curl_sectransp_close(conn, sockindex);
+
+ rc = 0;
+
+ what = SOCKET_READABLE(conn->sock[sockindex], SSL_SHUTDOWN_TIMEOUT);
+
+ for(;;) {
+ if(what < 0) {
+ /* anything that gets here is fatally bad */
+ failf(data, "select/poll on SSL socket, errno: %d", SOCKERRNO);
+ rc = -1;
+ break;
+ }
+
+ if(!what) { /* timeout */
+ failf(data, "SSL shutdown timeout");
+ break;
+ }
+
+ /* Something to read, let's do it and hope that it is the close
+ notify alert from the server. No way to SSL_Read now, so use read(). */
+
+ nread = read(conn->sock[sockindex], buf, sizeof(buf));
+
+ if(nread < 0) {
+ failf(data, "read: %s", strerror(errno));
+ rc = -1;
+ }
+
+ if(nread <= 0)
+ break;
+
+ what = SOCKET_READABLE(conn->sock[sockindex], 0);
+ }
+
+ return rc;
+}
+
+static void Curl_sectransp_session_free(void *ptr)
+{
+ /* ST, as of iOS 5 and Mountain Lion, has no public method of deleting a
+ cached session ID inside the Security framework. There is a private
+ function that does this, but I don't want to have to explain to you why I
+ got your application rejected from the App Store due to the use of a
+ private API, so the best we can do is free up our own char array that we
+ created way back in sectransp_connect_step1... */
+ Curl_safefree(ptr);
+}
+
+static size_t Curl_sectransp_version(char *buffer, size_t size)
+{
+ return msnprintf(buffer, size, "SecureTransport");
+}
+
+/*
+ * This function uses SSLGetSessionState to determine connection status.
+ *
+ * Return codes:
+ * 1 means the connection is still in place
+ * 0 means the connection has been closed
+ * -1 means the connection status is unknown
+ */
+static int Curl_sectransp_check_cxn(struct connectdata *conn)
+{
+ struct ssl_connect_data *connssl = &conn->ssl[FIRSTSOCKET];
+ OSStatus err;
+ SSLSessionState state;
+
+ if(BACKEND->ssl_ctx) {
+ err = SSLGetSessionState(BACKEND->ssl_ctx, &state);
+ if(err == noErr)
+ return state == kSSLConnected || state == kSSLHandshake;
+ return -1;
+ }
+ return 0;
+}
+
+static bool Curl_sectransp_data_pending(const struct connectdata *conn,
+ int connindex)
+{
+ const struct ssl_connect_data *connssl = &conn->ssl[connindex];
+ OSStatus err;
+ size_t buffer;
+
+ if(BACKEND->ssl_ctx) { /* SSL is in use */
+ err = SSLGetBufferedReadSize(BACKEND->ssl_ctx, &buffer);
+ if(err == noErr)
+ return buffer > 0UL;
+ return false;
+ }
+ else
+ return false;
+}
+
+static CURLcode Curl_sectransp_random(struct Curl_easy *data UNUSED_PARAM,
+ unsigned char *entropy, size_t length)
+{
+ /* arc4random_buf() isn't available on cats older than Lion, so let's
+ do this manually for the benefit of the older cats. */
+ size_t i;
+ u_int32_t random_number = 0;
+
+ (void)data;
+
+ for(i = 0 ; i < length ; i++) {
+ if(i % sizeof(u_int32_t) == 0)
+ random_number = arc4random();
+ entropy[i] = random_number & 0xFF;
+ random_number >>= 8;
+ }
+ i = random_number = 0;
+ return CURLE_OK;
+}
+
+static CURLcode Curl_sectransp_md5sum(unsigned char *tmp, /* input */
+ size_t tmplen,
+ unsigned char *md5sum, /* output */
+ size_t md5len)
+{
+ (void)md5len;
+ (void)CC_MD5(tmp, (CC_LONG)tmplen, md5sum);
+ return CURLE_OK;
+}
+
+static CURLcode Curl_sectransp_sha256sum(const unsigned char *tmp, /* input */
+ size_t tmplen,
+ unsigned char *sha256sum, /* output */
+ size_t sha256len)
+{
+ assert(sha256len >= CURL_SHA256_DIGEST_LENGTH);
+ (void)CC_SHA256(tmp, (CC_LONG)tmplen, sha256sum);
+ return CURLE_OK;
+}
+
+static bool Curl_sectransp_false_start(void)
+{
+#if CURL_BUILD_MAC_10_9 || CURL_BUILD_IOS_7
+ if(SSLSetSessionOption != NULL)
+ return TRUE;
+#endif
+ return FALSE;
+}
+
+static ssize_t sectransp_send(struct connectdata *conn,
+ int sockindex,
+ const void *mem,
+ size_t len,
+ CURLcode *curlcode)
+{
+ /*struct Curl_easy *data = conn->data;*/
+ struct ssl_connect_data *connssl = &conn->ssl[sockindex];
+ size_t processed = 0UL;
+ OSStatus err;
+
+ /* The SSLWrite() function works a little differently than expected. The
+ fourth argument (processed) is currently documented in Apple's
+ documentation as: "On return, the length, in bytes, of the data actually
+ written."
+
+ Now, one could interpret that as "written to the socket," but actually,
+ it returns the amount of data that was written to a buffer internal to
+ the SSLContextRef instead. So it's possible for SSLWrite() to return
+ errSSLWouldBlock and a number of bytes "written" because those bytes were
+ encrypted and written to a buffer, not to the socket.
+
+ So if this happens, then we need to keep calling SSLWrite() over and
+ over again with no new data until it quits returning errSSLWouldBlock. */
+
+ /* Do we have buffered data to write from the last time we were called? */
+ if(BACKEND->ssl_write_buffered_length) {
+ /* Write the buffered data: */
+ err = SSLWrite(BACKEND->ssl_ctx, NULL, 0UL, &processed);
+ switch(err) {
+ case noErr:
+ /* processed is always going to be 0 because we didn't write to
+ the buffer, so return how much was written to the socket */
+ processed = BACKEND->ssl_write_buffered_length;
+ BACKEND->ssl_write_buffered_length = 0UL;
+ break;
+ case errSSLWouldBlock: /* argh, try again */
+ *curlcode = CURLE_AGAIN;
+ return -1L;
+ default:
+ failf(conn->data, "SSLWrite() returned error %d", err);
+ *curlcode = CURLE_SEND_ERROR;
+ return -1L;
+ }
+ }
+ else {
+ /* We've got new data to write: */
+ err = SSLWrite(BACKEND->ssl_ctx, mem, len, &processed);
+ if(err != noErr) {
+ switch(err) {
+ case errSSLWouldBlock:
+ /* Data was buffered but not sent, we have to tell the caller
+ to try sending again, and remember how much was buffered */
+ BACKEND->ssl_write_buffered_length = len;
+ *curlcode = CURLE_AGAIN;
+ return -1L;
+ default:
+ failf(conn->data, "SSLWrite() returned error %d", err);
+ *curlcode = CURLE_SEND_ERROR;
+ return -1L;
+ }
+ }
+ }
+ return (ssize_t)processed;
+}
+
+static ssize_t sectransp_recv(struct connectdata *conn,
+ int num,
+ char *buf,
+ size_t buffersize,
+ CURLcode *curlcode)
+{
+ /*struct Curl_easy *data = conn->data;*/
+ struct ssl_connect_data *connssl = &conn->ssl[num];
+ size_t processed = 0UL;
+ OSStatus err = SSLRead(BACKEND->ssl_ctx, buf, buffersize, &processed);
+
+ if(err != noErr) {
+ switch(err) {
+ case errSSLWouldBlock: /* return how much we read (if anything) */
+ if(processed)
+ return (ssize_t)processed;
+ *curlcode = CURLE_AGAIN;
+ return -1L;
+ break;
+
+ /* errSSLClosedGraceful - server gracefully shut down the SSL session
+ errSSLClosedNoNotify - server hung up on us instead of sending a
+ closure alert notice, read() is returning 0
+ Either way, inform the caller that the server disconnected. */
+ case errSSLClosedGraceful:
+ case errSSLClosedNoNotify:
+ *curlcode = CURLE_OK;
+ return -1L;
+ break;
+
+ default:
+ failf(conn->data, "SSLRead() return error %d", err);
+ *curlcode = CURLE_RECV_ERROR;
+ return -1L;
+ break;
+ }
+ }
+ return (ssize_t)processed;
+}
+
+static void *Curl_sectransp_get_internals(struct ssl_connect_data *connssl,
+ CURLINFO info UNUSED_PARAM)
+{
+ (void)info;
+ return BACKEND->ssl_ctx;
+}
+
+const struct Curl_ssl Curl_ssl_sectransp = {
+ { CURLSSLBACKEND_SECURETRANSPORT, "secure-transport" }, /* info */
+
+#ifdef SECTRANSP_PINNEDPUBKEY
+ SSLSUPP_PINNEDPUBKEY,
+#else
+ 0,
+#endif /* SECTRANSP_PINNEDPUBKEY */
+
+ sizeof(struct ssl_backend_data),
+
+ Curl_none_init, /* init */
+ Curl_none_cleanup, /* cleanup */
+ Curl_sectransp_version, /* version */
+ Curl_sectransp_check_cxn, /* check_cxn */
+ Curl_sectransp_shutdown, /* shutdown */
+ Curl_sectransp_data_pending, /* data_pending */
+ Curl_sectransp_random, /* random */
+ Curl_none_cert_status_request, /* cert_status_request */
+ Curl_sectransp_connect, /* connect */
+ Curl_sectransp_connect_nonblocking, /* connect_nonblocking */
+ Curl_sectransp_get_internals, /* get_internals */
+ Curl_sectransp_close, /* close_one */
+ Curl_none_close_all, /* close_all */
+ Curl_sectransp_session_free, /* session_free */
+ Curl_none_set_engine, /* set_engine */
+ Curl_none_set_engine_default, /* set_engine_default */
+ Curl_none_engines_list, /* engines_list */
+ Curl_sectransp_false_start, /* false_start */
+ Curl_sectransp_md5sum, /* md5sum */
+ Curl_sectransp_sha256sum /* sha256sum */
+};
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+#endif /* USE_SECTRANSP */
diff --git a/Utilities/cmcurl/lib/vtls/sectransp.h b/Utilities/cmcurl/lib/vtls/sectransp.h
new file mode 100644
index 000000000..5cec797b3
--- /dev/null
+++ b/Utilities/cmcurl/lib/vtls/sectransp.h
@@ -0,0 +1,32 @@
+#ifndef HEADER_CURL_SECTRANSP_H
+#define HEADER_CURL_SECTRANSP_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 2012 - 2014, Nick Zitzmann, <nickzman@gmail.com>.
+ * Copyright (C) 2012 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "curl_setup.h"
+
+#ifdef USE_SECTRANSP
+
+extern const struct Curl_ssl Curl_ssl_sectransp;
+
+#endif /* USE_SECTRANSP */
+#endif /* HEADER_CURL_SECTRANSP_H */
diff --git a/Utilities/cmcurl/lib/vtls/vtls.c b/Utilities/cmcurl/lib/vtls/vtls.c
index d5d0971c4..a7452dcd5 100644
--- a/Utilities/cmcurl/lib/vtls/vtls.c
+++ b/Utilities/cmcurl/lib/vtls/vtls.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -28,17 +28,9 @@
to any specific SSL-layer.
Curl_ssl_ - prefix for generic ones
- Curl_ossl_ - prefix for OpenSSL ones
- Curl_gtls_ - prefix for GnuTLS ones
- Curl_nss_ - prefix for NSS ones
- Curl_gskit_ - prefix for GSKit ones
- Curl_polarssl_ - prefix for PolarSSL ones
- Curl_cyassl_ - prefix for CyaSSL ones
- Curl_schannel_ - prefix for Schannel SSPI ones
- Curl_darwinssl_ - prefix for SecureTransport (Darwin) ones
-
- Note that this source code uses curlssl_* functions, and they are all
- defines/macros #defined by the lib-specific header files.
+
+ Note that this source code uses the functions of the configured SSL
+ backend via the global Curl_ssl instance.
"SSL/TLS Strong Encryption: An Introduction"
https://httpd.apache.org/docs/2.0/ssl/ssl_intro.html
@@ -98,10 +90,14 @@ Curl_ssl_config_matches(struct ssl_primary_config* data,
(data->version_max == needle->version_max) &&
(data->verifypeer == needle->verifypeer) &&
(data->verifyhost == needle->verifyhost) &&
+ (data->verifystatus == needle->verifystatus) &&
Curl_safe_strcasecompare(data->CApath, needle->CApath) &&
Curl_safe_strcasecompare(data->CAfile, needle->CAfile) &&
Curl_safe_strcasecompare(data->clientcert, needle->clientcert) &&
- Curl_safe_strcasecompare(data->cipher_list, needle->cipher_list))
+ Curl_safe_strcasecompare(data->random_file, needle->random_file) &&
+ Curl_safe_strcasecompare(data->egdsocket, needle->egdsocket) &&
+ Curl_safe_strcasecompare(data->cipher_list, needle->cipher_list) &&
+ Curl_safe_strcasecompare(data->cipher_list13, needle->cipher_list13))
return TRUE;
return FALSE;
@@ -111,42 +107,53 @@ bool
Curl_clone_primary_ssl_config(struct ssl_primary_config *source,
struct ssl_primary_config *dest)
{
- dest->verifyhost = source->verifyhost;
- dest->verifypeer = source->verifypeer;
dest->version = source->version;
dest->version_max = source->version_max;
+ dest->verifypeer = source->verifypeer;
+ dest->verifyhost = source->verifyhost;
+ dest->verifystatus = source->verifystatus;
+ dest->sessionid = source->sessionid;
- CLONE_STRING(CAfile);
CLONE_STRING(CApath);
- CLONE_STRING(cipher_list);
- CLONE_STRING(egdsocket);
- CLONE_STRING(random_file);
+ CLONE_STRING(CAfile);
CLONE_STRING(clientcert);
+ CLONE_STRING(random_file);
+ CLONE_STRING(egdsocket);
+ CLONE_STRING(cipher_list);
+ CLONE_STRING(cipher_list13);
- /* Disable dest sessionid cache if a client cert is used, CVE-2016-5419. */
- dest->sessionid = (dest->clientcert ? false : source->sessionid);
return TRUE;
}
void Curl_free_primary_ssl_config(struct ssl_primary_config* sslc)
{
- Curl_safefree(sslc->CAfile);
Curl_safefree(sslc->CApath);
- Curl_safefree(sslc->cipher_list);
- Curl_safefree(sslc->egdsocket);
- Curl_safefree(sslc->random_file);
+ Curl_safefree(sslc->CAfile);
Curl_safefree(sslc->clientcert);
+ Curl_safefree(sslc->random_file);
+ Curl_safefree(sslc->egdsocket);
+ Curl_safefree(sslc->cipher_list);
+ Curl_safefree(sslc->cipher_list13);
}
+#ifdef USE_SSL
+static int multissl_init(const struct Curl_ssl *backend);
+#endif
+
int Curl_ssl_backend(void)
{
- return (int)CURL_SSL_BACKEND;
+#ifdef USE_SSL
+ multissl_init(NULL);
+ return Curl_ssl->info.id;
+#else
+ return (int)CURLSSLBACKEND_NONE;
+#endif
}
#ifdef USE_SSL
/* "global" init done? */
-static bool init_ssl=FALSE;
+static bool init_ssl = FALSE;
/**
* Global SSL init
@@ -161,7 +168,7 @@ int Curl_ssl_init(void)
return 1;
init_ssl = TRUE; /* never again */
- return curlssl_init();
+ return Curl_ssl->init();
}
@@ -170,7 +177,7 @@ void Curl_ssl_cleanup(void)
{
if(init_ssl) {
/* only cleanup if we did a previous init */
- curlssl_cleanup();
+ Curl_ssl->cleanup();
init_ssl = FALSE;
}
}
@@ -205,12 +212,20 @@ ssl_connect_init_proxy(struct connectdata *conn, int sockindex)
DEBUGASSERT(conn->bits.proxy_ssl_connected[sockindex]);
if(ssl_connection_complete == conn->ssl[sockindex].state &&
!conn->proxy_ssl[sockindex].use) {
-#if defined(HTTPS_PROXY_SUPPORT)
+ struct ssl_backend_data *pbdata;
+
+ if(!(Curl_ssl->supports & SSLSUPP_HTTPS_PROXY))
+ return CURLE_NOT_BUILT_IN;
+
+ /* The pointers to the ssl backend data, which is opaque here, are swapped
+ rather than move the contents. */
+ pbdata = conn->proxy_ssl[sockindex].backend;
conn->proxy_ssl[sockindex] = conn->ssl[sockindex];
+
memset(&conn->ssl[sockindex], 0, sizeof(conn->ssl[sockindex]));
-#else
- return CURLE_NOT_BUILT_IN;
-#endif
+ memset(pbdata, 0, Curl_ssl->sizeof_ssl_backend_data);
+
+ conn->ssl[sockindex].backend = pbdata;
}
return CURLE_OK;
}
@@ -233,7 +248,7 @@ Curl_ssl_connect(struct connectdata *conn, int sockindex)
conn->ssl[sockindex].use = TRUE;
conn->ssl[sockindex].state = ssl_connection_negotiating;
- result = curlssl_connect(conn, sockindex);
+ result = Curl_ssl->connect_blocking(conn, sockindex);
if(!result)
Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */
@@ -257,12 +272,7 @@ Curl_ssl_connect_nonblocking(struct connectdata *conn, int sockindex,
/* mark this is being ssl requested from here on. */
conn->ssl[sockindex].use = TRUE;
-#ifdef curlssl_connect_nonblocking
- result = curlssl_connect_nonblocking(conn, sockindex, done);
-#else
- *done = TRUE; /* fallback to BLOCKING */
- result = curlssl_connect(conn, sockindex);
-#endif /* non-blocking connect support */
+ result = Curl_ssl->connect_nonblocking(conn, sockindex, done);
if(!result && *done)
Curl_pgrsTime(conn->data, TIMER_APPCONNECT); /* SSL is connected */
return result;
@@ -361,7 +371,7 @@ void Curl_ssl_kill_session(struct curl_ssl_session *session)
/* defensive check */
/* free the ID the SSL-layer specific way */
- curlssl_session_free(session->sessionid);
+ Curl_ssl->session_free(session->sessionid);
session->sessionid = NULL;
session->age = 0; /* fresh */
@@ -379,7 +389,7 @@ void Curl_ssl_kill_session(struct curl_ssl_session *session)
void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid)
{
size_t i;
- struct Curl_easy *data=conn->data;
+ struct Curl_easy *data = conn->data;
for(i = 0; i < data->set.general_ssl.max_ssl_sessions; i++) {
struct curl_ssl_session *check = &data->state.session[i];
@@ -403,9 +413,9 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
int sockindex)
{
size_t i;
- struct Curl_easy *data=conn->data; /* the mother of all structs */
+ struct Curl_easy *data = conn->data; /* the mother of all structs */
struct curl_ssl_session *store = &data->state.session[0];
- long oldest_age=data->state.session[0].age; /* zero if unused */
+ long oldest_age = data->state.session[0].age; /* zero if unused */
char *clone_host;
char *clone_conn_to_host;
int conn_to_port;
@@ -488,9 +498,9 @@ CURLcode Curl_ssl_addsessionid(struct connectdata *conn,
void Curl_ssl_close_all(struct Curl_easy *data)
{
- size_t i;
/* kill the session ID cache if not shared */
if(data->state.session && !SSLSESSION_SHARED(data)) {
+ size_t i;
for(i = 0; i < data->set.general_ssl.max_ssl_sessions; i++)
/* the single-killer function handles empty table slots */
Curl_ssl_kill_session(&data->state.session[i]);
@@ -499,12 +509,12 @@ void Curl_ssl_close_all(struct Curl_easy *data)
Curl_safefree(data->state.session);
}
- curlssl_close_all(data);
+ Curl_ssl->close_all(data);
}
#if defined(USE_OPENSSL) || defined(USE_GNUTLS) || defined(USE_SCHANNEL) || \
- defined(USE_DARWINSSL) || defined(USE_POLARSSL) || defined(USE_NSS) || \
- defined(USE_MBEDTLS)
+ defined(USE_SECTRANSP) || defined(USE_POLARSSL) || defined(USE_NSS) || \
+ defined(USE_MBEDTLS) || defined(USE_CYASSL)
int Curl_ssl_getsock(struct connectdata *conn, curl_socket_t *socks,
int numsocks)
{
@@ -536,18 +546,18 @@ int Curl_ssl_getsock(struct connectdata *conn,
(void)numsocks;
return GETSOCK_BLANK;
}
-/* USE_OPENSSL || USE_GNUTLS || USE_SCHANNEL || USE_DARWINSSL || USE_NSS */
+/* USE_OPENSSL || USE_GNUTLS || USE_SCHANNEL || USE_SECTRANSP || USE_NSS */
#endif
void Curl_ssl_close(struct connectdata *conn, int sockindex)
{
DEBUGASSERT((sockindex <= 1) && (sockindex >= -1));
- curlssl_close(conn, sockindex);
+ Curl_ssl->close_one(conn, sockindex);
}
CURLcode Curl_ssl_shutdown(struct connectdata *conn, int sockindex)
{
- if(curlssl_shutdown(conn, sockindex))
+ if(Curl_ssl->shut_down(conn, sockindex))
return CURLE_SSL_SHUTDOWN_FAILED;
conn->ssl[sockindex].use = FALSE; /* get back to ordinary socket usage */
@@ -563,20 +573,20 @@ CURLcode Curl_ssl_shutdown(struct connectdata *conn, int sockindex)
*/
CURLcode Curl_ssl_set_engine(struct Curl_easy *data, const char *engine)
{
- return curlssl_set_engine(data, engine);
+ return Curl_ssl->set_engine(data, engine);
}
/* Selects the default SSL crypto engine
*/
CURLcode Curl_ssl_set_engine_default(struct Curl_easy *data)
{
- return curlssl_set_engine_default(data);
+ return Curl_ssl->set_engine_default(data);
}
/* Return list of OpenSSL crypto engine names. */
struct curl_slist *Curl_ssl_engines_list(struct Curl_easy *data)
{
- return curlssl_engines_list(data);
+ return Curl_ssl->engines_list(data);
}
/*
@@ -602,9 +612,15 @@ CURLcode Curl_ssl_initsessions(struct Curl_easy *data, size_t amount)
return CURLE_OK;
}
+static size_t Curl_multissl_version(char *buffer, size_t size);
+
size_t Curl_ssl_version(char *buffer, size_t size)
{
- return curlssl_version(buffer, size);
+#ifdef CURL_WITH_MULTI_SSL
+ return Curl_multissl_version(buffer, size);
+#else
+ return Curl_ssl->version(buffer, size);
+#endif
}
/*
@@ -617,23 +633,23 @@ size_t Curl_ssl_version(char *buffer, size_t size)
*/
int Curl_ssl_check_cxn(struct connectdata *conn)
{
- return curlssl_check_cxn(conn);
+ return Curl_ssl->check_cxn(conn);
}
bool Curl_ssl_data_pending(const struct connectdata *conn,
int connindex)
{
- return curlssl_data_pending(conn, connindex);
+ return Curl_ssl->data_pending(conn, connindex);
}
void Curl_ssl_free_certinfo(struct Curl_easy *data)
{
- int i;
struct curl_certinfo *ci = &data->info.certs;
if(ci->num_of_certs) {
/* free all individual lists used */
- for(i=0; i<ci->num_of_certs; i++) {
+ int i;
+ for(i = 0; i<ci->num_of_certs; i++) {
curl_slist_free_all(ci->certinfo[i]);
ci->certinfo[i] = NULL;
}
@@ -684,10 +700,10 @@ CURLcode Curl_ssl_push_certinfo_len(struct Curl_easy *data,
return CURLE_OUT_OF_MEMORY;
/* sprintf the label and colon */
- snprintf(output, outlen, "%s:", label);
+ msnprintf(output, outlen, "%s:", label);
/* memcpy the value (it might not be zero terminated) */
- memcpy(&output[labellen+1], value, valuelen);
+ memcpy(&output[labellen + 1], value, valuelen);
/* zero terminate the output */
output[labellen + 1 + valuelen] = 0;
@@ -721,7 +737,7 @@ CURLcode Curl_ssl_random(struct Curl_easy *data,
unsigned char *entropy,
size_t length)
{
- return curlssl_random(data, entropy, length);
+ return Curl_ssl->random(data, entropy, length);
}
/*
@@ -792,16 +808,7 @@ CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data,
{
FILE *fp;
unsigned char *buf = NULL, *pem_ptr = NULL;
- long filesize;
- size_t size, pem_len;
- CURLcode pem_read;
CURLcode result = CURLE_SSL_PINNEDPUBKEYNOTMATCH;
-#ifdef curlssl_sha256sum
- CURLcode encode;
- size_t encodedlen, pinkeylen;
- char *encoded, *pinkeycopy, *begin_pos, *end_pos;
- unsigned char *sha256sumdigest = NULL;
-#endif
/* if a path wasn't specified, don't pin */
if(!pinnedpubkey)
@@ -811,15 +818,29 @@ CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data,
/* only do this if pinnedpubkey starts with "sha256//", length 8 */
if(strncmp(pinnedpubkey, "sha256//", 8) == 0) {
-#ifdef curlssl_sha256sum
+ CURLcode encode;
+ size_t encodedlen, pinkeylen;
+ char *encoded, *pinkeycopy, *begin_pos, *end_pos;
+ unsigned char *sha256sumdigest;
+
+ if(!Curl_ssl->sha256sum) {
+ /* without sha256 support, this cannot match */
+ return result;
+ }
+
/* compute sha256sum of public key */
- sha256sumdigest = malloc(SHA256_DIGEST_LENGTH);
+ sha256sumdigest = malloc(CURL_SHA256_DIGEST_LENGTH);
if(!sha256sumdigest)
return CURLE_OUT_OF_MEMORY;
- curlssl_sha256sum(pubkey, pubkeylen,
- sha256sumdigest, SHA256_DIGEST_LENGTH);
+ encode = Curl_ssl->sha256sum(pubkey, pubkeylen,
+ sha256sumdigest, CURL_SHA256_DIGEST_LENGTH);
+
+ if(encode != CURLE_OK)
+ return encode;
+
encode = Curl_base64_encode(data, (char *)sha256sumdigest,
- SHA256_DIGEST_LENGTH, &encoded, &encodedlen);
+ CURL_SHA256_DIGEST_LENGTH, &encoded,
+ &encodedlen);
Curl_safefree(sha256sumdigest);
if(encode)
@@ -864,10 +885,6 @@ CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data,
} while(end_pos && begin_pos);
Curl_safefree(encoded);
Curl_safefree(pinkeycopy);
-#else
- /* without sha256 support, this cannot match */
- (void)data;
-#endif
return result;
}
@@ -876,6 +893,10 @@ CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data,
return result;
do {
+ long filesize;
+ size_t size, pem_len;
+ CURLcode pem_read;
+
/* Determine the file's size */
if(fseek(fp, 0, SEEK_END))
break;
@@ -943,45 +964,386 @@ CURLcode Curl_ssl_md5sum(unsigned char *tmp, /* input */
unsigned char *md5sum, /* output */
size_t md5len)
{
-#ifdef curlssl_md5sum
- curlssl_md5sum(tmp, tmplen, md5sum, md5len);
-#else
+ return Curl_ssl->md5sum(tmp, tmplen, md5sum, md5len);
+}
+#endif
+
+/*
+ * Check whether the SSL backend supports the status_request extension.
+ */
+bool Curl_ssl_cert_status_request(void)
+{
+ return Curl_ssl->cert_status_request();
+}
+
+/*
+ * Check whether the SSL backend supports false start.
+ */
+bool Curl_ssl_false_start(void)
+{
+ return Curl_ssl->false_start();
+}
+
+/*
+ * Check whether the SSL backend supports setting TLS 1.3 cipher suites
+ */
+bool Curl_ssl_tls13_ciphersuites(void)
+{
+ return Curl_ssl->supports & SSLSUPP_TLS13_CIPHERSUITES;
+}
+
+/*
+ * Default implementations for unsupported functions.
+ */
+
+int Curl_none_init(void)
+{
+ return 1;
+}
+
+void Curl_none_cleanup(void)
+{ }
+
+int Curl_none_shutdown(struct connectdata *conn UNUSED_PARAM,
+ int sockindex UNUSED_PARAM)
+{
+ (void)conn;
+ (void)sockindex;
+ return 0;
+}
+
+int Curl_none_check_cxn(struct connectdata *conn UNUSED_PARAM)
+{
+ (void)conn;
+ return -1;
+}
+
+CURLcode Curl_none_random(struct Curl_easy *data UNUSED_PARAM,
+ unsigned char *entropy UNUSED_PARAM,
+ size_t length UNUSED_PARAM)
+{
+ (void)data;
+ (void)entropy;
+ (void)length;
+ return CURLE_NOT_BUILT_IN;
+}
+
+void Curl_none_close_all(struct Curl_easy *data UNUSED_PARAM)
+{
+ (void)data;
+}
+
+void Curl_none_session_free(void *ptr UNUSED_PARAM)
+{
+ (void)ptr;
+}
+
+bool Curl_none_data_pending(const struct connectdata *conn UNUSED_PARAM,
+ int connindex UNUSED_PARAM)
+{
+ (void)conn;
+ (void)connindex;
+ return 0;
+}
+
+bool Curl_none_cert_status_request(void)
+{
+ return FALSE;
+}
+
+CURLcode Curl_none_set_engine(struct Curl_easy *data UNUSED_PARAM,
+ const char *engine UNUSED_PARAM)
+{
+ (void)data;
+ (void)engine;
+ return CURLE_NOT_BUILT_IN;
+}
+
+CURLcode Curl_none_set_engine_default(struct Curl_easy *data UNUSED_PARAM)
+{
+ (void)data;
+ return CURLE_NOT_BUILT_IN;
+}
+
+struct curl_slist *Curl_none_engines_list(struct Curl_easy *data UNUSED_PARAM)
+{
+ (void)data;
+ return (struct curl_slist *)NULL;
+}
+
+bool Curl_none_false_start(void)
+{
+ return FALSE;
+}
+
+#ifndef CURL_DISABLE_CRYPTO_AUTH
+CURLcode Curl_none_md5sum(unsigned char *input, size_t inputlen,
+ unsigned char *md5sum, size_t md5len UNUSED_PARAM)
+{
MD5_context *MD5pw;
- (void) md5len;
+ (void)md5len;
MD5pw = Curl_MD5_init(Curl_DIGEST_MD5);
if(!MD5pw)
return CURLE_OUT_OF_MEMORY;
- Curl_MD5_update(MD5pw, tmp, curlx_uztoui(tmplen));
+ Curl_MD5_update(MD5pw, input, curlx_uztoui(inputlen));
Curl_MD5_final(MD5pw, md5sum);
-#endif
return CURLE_OK;
}
+#else
+CURLcode Curl_none_md5sum(unsigned char *input UNUSED_PARAM,
+ size_t inputlen UNUSED_PARAM,
+ unsigned char *md5sum UNUSED_PARAM,
+ size_t md5len UNUSED_PARAM)
+{
+ (void)input;
+ (void)inputlen;
+ (void)md5sum;
+ (void)md5len;
+ return CURLE_NOT_BUILT_IN;
+}
#endif
-/*
- * Check whether the SSL backend supports the status_request extension.
- */
-bool Curl_ssl_cert_status_request(void)
+static int Curl_multissl_init(void)
+{
+ if(multissl_init(NULL))
+ return 1;
+ return Curl_ssl->init();
+}
+
+static CURLcode Curl_multissl_connect(struct connectdata *conn, int sockindex)
+{
+ if(multissl_init(NULL))
+ return CURLE_FAILED_INIT;
+ return Curl_ssl->connect_blocking(conn, sockindex);
+}
+
+static CURLcode Curl_multissl_connect_nonblocking(struct connectdata *conn,
+ int sockindex, bool *done)
+{
+ if(multissl_init(NULL))
+ return CURLE_FAILED_INIT;
+ return Curl_ssl->connect_nonblocking(conn, sockindex, done);
+}
+
+static void *Curl_multissl_get_internals(struct ssl_connect_data *connssl,
+ CURLINFO info)
+{
+ if(multissl_init(NULL))
+ return NULL;
+ return Curl_ssl->get_internals(connssl, info);
+}
+
+static void Curl_multissl_close(struct connectdata *conn, int sockindex)
{
-#ifdef curlssl_cert_status_request
- return curlssl_cert_status_request();
+ if(multissl_init(NULL))
+ return;
+ Curl_ssl->close_one(conn, sockindex);
+}
+
+static const struct Curl_ssl Curl_ssl_multi = {
+ { CURLSSLBACKEND_NONE, "multi" }, /* info */
+ 0, /* supports nothing */
+ (size_t)-1, /* something insanely large to be on the safe side */
+
+ Curl_multissl_init, /* init */
+ Curl_none_cleanup, /* cleanup */
+ Curl_multissl_version, /* version */
+ Curl_none_check_cxn, /* check_cxn */
+ Curl_none_shutdown, /* shutdown */
+ Curl_none_data_pending, /* data_pending */
+ Curl_none_random, /* random */
+ Curl_none_cert_status_request, /* cert_status_request */
+ Curl_multissl_connect, /* connect */
+ Curl_multissl_connect_nonblocking, /* connect_nonblocking */
+ Curl_multissl_get_internals, /* get_internals */
+ Curl_multissl_close, /* close_one */
+ Curl_none_close_all, /* close_all */
+ Curl_none_session_free, /* session_free */
+ Curl_none_set_engine, /* set_engine */
+ Curl_none_set_engine_default, /* set_engine_default */
+ Curl_none_engines_list, /* engines_list */
+ Curl_none_false_start, /* false_start */
+ Curl_none_md5sum, /* md5sum */
+ NULL /* sha256sum */
+};
+
+const struct Curl_ssl *Curl_ssl =
+#if defined(CURL_WITH_MULTI_SSL)
+ &Curl_ssl_multi;
+#elif defined(USE_CYASSL)
+ &Curl_ssl_cyassl;
+#elif defined(USE_SECTRANSP)
+ &Curl_ssl_sectransp;
+#elif defined(USE_GNUTLS)
+ &Curl_ssl_gnutls;
+#elif defined(USE_GSKIT)
+ &Curl_ssl_gskit;
+#elif defined(USE_MBEDTLS)
+ &Curl_ssl_mbedtls;
+#elif defined(USE_NSS)
+ &Curl_ssl_nss;
+#elif defined(USE_OPENSSL)
+ &Curl_ssl_openssl;
+#elif defined(USE_POLARSSL)
+ &Curl_ssl_polarssl;
+#elif defined(USE_SCHANNEL)
+ &Curl_ssl_schannel;
+#elif defined(USE_MESALINK)
+ &Curl_ssl_mesalink;
#else
- return FALSE;
+#error "Missing struct Curl_ssl for selected SSL backend"
#endif
+
+static const struct Curl_ssl *available_backends[] = {
+#if defined(USE_CYASSL)
+ &Curl_ssl_cyassl,
+#endif
+#if defined(USE_SECTRANSP)
+ &Curl_ssl_sectransp,
+#endif
+#if defined(USE_GNUTLS)
+ &Curl_ssl_gnutls,
+#endif
+#if defined(USE_GSKIT)
+ &Curl_ssl_gskit,
+#endif
+#if defined(USE_MBEDTLS)
+ &Curl_ssl_mbedtls,
+#endif
+#if defined(USE_NSS)
+ &Curl_ssl_nss,
+#endif
+#if defined(USE_OPENSSL)
+ &Curl_ssl_openssl,
+#endif
+#if defined(USE_POLARSSL)
+ &Curl_ssl_polarssl,
+#endif
+#if defined(USE_SCHANNEL)
+ &Curl_ssl_schannel,
+#endif
+#if defined(USE_MESALINK)
+ &Curl_ssl_mesalink,
+#endif
+ NULL
+};
+
+static size_t Curl_multissl_version(char *buffer, size_t size)
+{
+ static const struct Curl_ssl *selected;
+ static char backends[200];
+ static size_t total;
+ const struct Curl_ssl *current;
+
+ current = Curl_ssl == &Curl_ssl_multi ? available_backends[0] : Curl_ssl;
+
+ if(current != selected) {
+ char *p = backends;
+ char *end = backends + sizeof(backends);
+ int i;
+
+ selected = current;
+
+ for(i = 0; available_backends[i] && p < (end - 4); i++) {
+ if(i)
+ *(p++) = ' ';
+ if(selected != available_backends[i])
+ *(p++) = '(';
+ p += available_backends[i]->version(p, end - p - 2);
+ if(selected != available_backends[i])
+ *(p++) = ')';
+ }
+ *p = '\0';
+ total = p - backends;
+ }
+
+ if(size > total)
+ memcpy(buffer, backends, total + 1);
+ else {
+ memcpy(buffer, backends, size - 1);
+ buffer[size - 1] = '\0';
+ }
+
+ return CURLMIN(size - 1, total);
}
-/*
- * Check whether the SSL backend supports false start.
- */
-bool Curl_ssl_false_start(void)
+static int multissl_init(const struct Curl_ssl *backend)
+{
+ const char *env;
+ char *env_tmp;
+
+ if(Curl_ssl != &Curl_ssl_multi)
+ return 1;
+
+ if(backend) {
+ Curl_ssl = backend;
+ return 0;
+ }
+
+ if(!available_backends[0])
+ return 1;
+
+ env = env_tmp = curl_getenv("CURL_SSL_BACKEND");
+#ifdef CURL_DEFAULT_SSL_BACKEND
+ if(!env)
+ env = CURL_DEFAULT_SSL_BACKEND;
+#endif
+ if(env) {
+ int i;
+ for(i = 0; available_backends[i]; i++) {
+ if(strcasecompare(env, available_backends[i]->info.name)) {
+ Curl_ssl = available_backends[i];
+ curl_free(env_tmp);
+ return 0;
+ }
+ }
+ }
+
+ /* Fall back to first available backend */
+ Curl_ssl = available_backends[0];
+ curl_free(env_tmp);
+ return 0;
+}
+
+CURLsslset curl_global_sslset(curl_sslbackend id, const char *name,
+ const curl_ssl_backend ***avail)
{
-#ifdef curlssl_false_start
- return curlssl_false_start();
+ int i;
+
+ if(avail)
+ *avail = (const curl_ssl_backend **)&available_backends;
+
+ if(Curl_ssl != &Curl_ssl_multi)
+ return id == Curl_ssl->info.id ||
+ (name && strcasecompare(name, Curl_ssl->info.name)) ?
+ CURLSSLSET_OK :
+#if defined(CURL_WITH_MULTI_SSL)
+ CURLSSLSET_TOO_LATE;
#else
- return FALSE;
+ CURLSSLSET_UNKNOWN_BACKEND;
#endif
+
+ for(i = 0; available_backends[i]; i++) {
+ if(available_backends[i]->info.id == id ||
+ (name && strcasecompare(available_backends[i]->info.name, name))) {
+ multissl_init(available_backends[i]);
+ return CURLSSLSET_OK;
+ }
+ }
+
+ return CURLSSLSET_UNKNOWN_BACKEND;
+}
+
+#else /* USE_SSL */
+CURLsslset curl_global_sslset(curl_sslbackend id, const char *name,
+ const curl_ssl_backend ***avail)
+{
+ (void)id;
+ (void)name;
+ (void)avail;
+ return CURLSSLSET_NO_BACKENDS;
}
-#endif /* USE_SSL */
+#endif /* !USE_SSL */
diff --git a/Utilities/cmcurl/lib/vtls/vtls.h b/Utilities/cmcurl/lib/vtls/vtls.h
index 2aabeda20..2a87ca1f7 100644
--- a/Utilities/cmcurl/lib/vtls/vtls.h
+++ b/Utilities/cmcurl/lib/vtls/vtls.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -23,27 +23,104 @@
***************************************************************************/
#include "curl_setup.h"
+struct connectdata;
+struct ssl_connect_data;
+
+#define SSLSUPP_CA_PATH (1<<0) /* supports CAPATH */
+#define SSLSUPP_CERTINFO (1<<1) /* supports CURLOPT_CERTINFO */
+#define SSLSUPP_PINNEDPUBKEY (1<<2) /* supports CURLOPT_PINNEDPUBLICKEY */
+#define SSLSUPP_SSL_CTX (1<<3) /* supports CURLOPT_SSL_CTX */
+#define SSLSUPP_HTTPS_PROXY (1<<4) /* supports access via HTTPS proxies */
+#define SSLSUPP_TLS13_CIPHERSUITES (1<<5) /* supports TLS 1.3 ciphersuites */
+
+struct Curl_ssl {
+ /*
+ * This *must* be the first entry to allow returning the list of available
+ * backends in curl_global_sslset().
+ */
+ curl_ssl_backend info;
+ unsigned int supports; /* bitfield, see above */
+ size_t sizeof_ssl_backend_data;
+
+ int (*init)(void);
+ void (*cleanup)(void);
+
+ size_t (*version)(char *buffer, size_t size);
+ int (*check_cxn)(struct connectdata *cxn);
+ int (*shut_down)(struct connectdata *conn, int sockindex);
+ bool (*data_pending)(const struct connectdata *conn,
+ int connindex);
+
+ /* return 0 if a find random is filled in */
+ CURLcode (*random)(struct Curl_easy *data, unsigned char *entropy,
+ size_t length);
+ bool (*cert_status_request)(void);
+
+ CURLcode (*connect_blocking)(struct connectdata *conn, int sockindex);
+ CURLcode (*connect_nonblocking)(struct connectdata *conn, int sockindex,
+ bool *done);
+ void *(*get_internals)(struct ssl_connect_data *connssl, CURLINFO info);
+ void (*close_one)(struct connectdata *conn, int sockindex);
+ void (*close_all)(struct Curl_easy *data);
+ void (*session_free)(void *ptr);
+
+ CURLcode (*set_engine)(struct Curl_easy *data, const char *engine);
+ CURLcode (*set_engine_default)(struct Curl_easy *data);
+ struct curl_slist *(*engines_list)(struct Curl_easy *data);
+
+ bool (*false_start)(void);
+
+ CURLcode (*md5sum)(unsigned char *input, size_t inputlen,
+ unsigned char *md5sum, size_t md5sumlen);
+ CURLcode (*sha256sum)(const unsigned char *input, size_t inputlen,
+ unsigned char *sha256sum, size_t sha256sumlen);
+};
+
+#ifdef USE_SSL
+extern const struct Curl_ssl *Curl_ssl;
+#endif
+
+int Curl_none_init(void);
+void Curl_none_cleanup(void);
+int Curl_none_shutdown(struct connectdata *conn, int sockindex);
+int Curl_none_check_cxn(struct connectdata *conn);
+CURLcode Curl_none_random(struct Curl_easy *data, unsigned char *entropy,
+ size_t length);
+void Curl_none_close_all(struct Curl_easy *data);
+void Curl_none_session_free(void *ptr);
+bool Curl_none_data_pending(const struct connectdata *conn, int connindex);
+bool Curl_none_cert_status_request(void);
+CURLcode Curl_none_set_engine(struct Curl_easy *data, const char *engine);
+CURLcode Curl_none_set_engine_default(struct Curl_easy *data);
+struct curl_slist *Curl_none_engines_list(struct Curl_easy *data);
+bool Curl_none_false_start(void);
+bool Curl_ssl_tls13_ciphersuites(void);
+CURLcode Curl_none_md5sum(unsigned char *input, size_t inputlen,
+ unsigned char *md5sum, size_t md5len);
+
#include "openssl.h" /* OpenSSL versions */
#include "gtls.h" /* GnuTLS versions */
#include "nssg.h" /* NSS versions */
#include "gskit.h" /* Global Secure ToolKit versions */
#include "polarssl.h" /* PolarSSL versions */
-#include "axtls.h" /* axTLS versions */
#include "cyassl.h" /* CyaSSL versions */
#include "schannel.h" /* Schannel SSPI version */
-#include "darwinssl.h" /* SecureTransport (Darwin) version */
+#include "sectransp.h" /* SecureTransport (Darwin) version */
#include "mbedtls.h" /* mbedTLS versions */
+#include "mesalink.h" /* MesaLink versions */
#ifndef MAX_PINNED_PUBKEY_SIZE
#define MAX_PINNED_PUBKEY_SIZE 1048576 /* 1MB */
#endif
#ifndef MD5_DIGEST_LENGTH
+#ifndef LIBWOLFSSL_VERSION_HEX /* because WolfSSL borks this */
#define MD5_DIGEST_LENGTH 16 /* fixed size */
#endif
+#endif
-#ifndef SHA256_DIGEST_LENGTH
-#define SHA256_DIGEST_LENGTH 32 /* fixed size */
+#ifndef CURL_SHA256_DIGEST_LENGTH
+#define CURL_SHA256_DIGEST_LENGTH 32 /* fixed size */
#endif
/* see https://tools.ietf.org/html/draft-ietf-tls-applayerprotoneg-04 */
@@ -171,9 +248,7 @@ bool Curl_ssl_false_start(void);
#define SSL_SHUTDOWN_TIMEOUT 10000 /* ms */
-#else
-/* Set the API backend definition to none */
-#define CURL_SSL_BACKEND CURLSSLBACKEND_NONE
+#else /* if not USE_SSL */
/* When SSL support is not present, just define away these function calls */
#define Curl_ssl_init() 1
@@ -197,6 +272,7 @@ bool Curl_ssl_false_start(void);
#define Curl_ssl_random(x,y,z) ((void)x, CURLE_NOT_BUILT_IN)
#define Curl_ssl_cert_status_request() FALSE
#define Curl_ssl_false_start() FALSE
+#define Curl_ssl_tls13_ciphersuites() FALSE
#endif
#endif /* HEADER_CURL_VTLS_H */
diff --git a/Utilities/cmcurl/lib/warnless.c b/Utilities/cmcurl/lib/warnless.c
index fb085c86d..cfd5e8e14 100644
--- a/Utilities/cmcurl/lib/warnless.c
+++ b/Utilities/cmcurl/lib/warnless.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -69,36 +69,36 @@
# error "SIZEOF_INT not defined"
#endif
-#if (CURL_SIZEOF_LONG == 2)
+#if (SIZEOF_LONG == 2)
# define CURL_MASK_SLONG 0x7FFFL
# define CURL_MASK_ULONG 0xFFFFUL
-#elif (CURL_SIZEOF_LONG == 4)
+#elif (SIZEOF_LONG == 4)
# define CURL_MASK_SLONG 0x7FFFFFFFL
# define CURL_MASK_ULONG 0xFFFFFFFFUL
-#elif (CURL_SIZEOF_LONG == 8)
+#elif (SIZEOF_LONG == 8)
# define CURL_MASK_SLONG 0x7FFFFFFFFFFFFFFFL
# define CURL_MASK_ULONG 0xFFFFFFFFFFFFFFFFUL
-#elif (CURL_SIZEOF_LONG == 16)
+#elif (SIZEOF_LONG == 16)
# define CURL_MASK_SLONG 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL
# define CURL_MASK_ULONG 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFUL
#else
-# error "CURL_SIZEOF_LONG not defined"
+# error "SIZEOF_LONG not defined"
#endif
-#if (CURL_SIZEOF_CURL_OFF_T == 2)
+#if (SIZEOF_CURL_OFF_T == 2)
# define CURL_MASK_SCOFFT CURL_OFF_T_C(0x7FFF)
# define CURL_MASK_UCOFFT CURL_OFF_TU_C(0xFFFF)
-#elif (CURL_SIZEOF_CURL_OFF_T == 4)
+#elif (SIZEOF_CURL_OFF_T == 4)
# define CURL_MASK_SCOFFT CURL_OFF_T_C(0x7FFFFFFF)
# define CURL_MASK_UCOFFT CURL_OFF_TU_C(0xFFFFFFFF)
-#elif (CURL_SIZEOF_CURL_OFF_T == 8)
+#elif (SIZEOF_CURL_OFF_T == 8)
# define CURL_MASK_SCOFFT CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF)
# define CURL_MASK_UCOFFT CURL_OFF_TU_C(0xFFFFFFFFFFFFFFFF)
-#elif (CURL_SIZEOF_CURL_OFF_T == 16)
+#elif (SIZEOF_CURL_OFF_T == 16)
# define CURL_MASK_SCOFFT CURL_OFF_T_C(0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
# define CURL_MASK_UCOFFT CURL_OFF_TU_C(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
#else
-# error "CURL_SIZEOF_CURL_OFF_T not defined"
+# error "SIZEOF_CURL_OFF_T not defined"
#endif
#if (SIZEOF_SIZE_T == SIZEOF_SHORT)
@@ -107,10 +107,10 @@
#elif (SIZEOF_SIZE_T == SIZEOF_INT)
# define CURL_MASK_SSIZE_T CURL_MASK_SINT
# define CURL_MASK_USIZE_T CURL_MASK_UINT
-#elif (SIZEOF_SIZE_T == CURL_SIZEOF_LONG)
+#elif (SIZEOF_SIZE_T == SIZEOF_LONG)
# define CURL_MASK_SSIZE_T CURL_MASK_SLONG
# define CURL_MASK_USIZE_T CURL_MASK_ULONG
-#elif (SIZEOF_SIZE_T == CURL_SIZEOF_CURL_OFF_T)
+#elif (SIZEOF_SIZE_T == SIZEOF_CURL_OFF_T)
# define CURL_MASK_SSIZE_T CURL_MASK_SCOFFT
# define CURL_MASK_USIZE_T CURL_MASK_UCOFFT
#else
@@ -226,7 +226,7 @@ unsigned long curlx_uztoul(size_t uznum)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
-#if (CURL_SIZEOF_LONG < SIZEOF_SIZE_T)
+#if (SIZEOF_LONG < SIZEOF_SIZE_T)
DEBUGASSERT(uznum <= (size_t) CURL_MASK_ULONG);
#endif
return (unsigned long)(uznum & (size_t) CURL_MASK_ULONG);
@@ -269,7 +269,7 @@ int curlx_sltosi(long slnum)
#endif
DEBUGASSERT(slnum >= 0);
-#if (SIZEOF_INT < CURL_SIZEOF_LONG)
+#if (SIZEOF_INT < SIZEOF_LONG)
DEBUGASSERT((unsigned long) slnum <= (unsigned long) CURL_MASK_SINT);
#endif
return (int)(slnum & (long) CURL_MASK_SINT);
@@ -291,7 +291,7 @@ unsigned int curlx_sltoui(long slnum)
#endif
DEBUGASSERT(slnum >= 0);
-#if (SIZEOF_INT < CURL_SIZEOF_LONG)
+#if (SIZEOF_INT < SIZEOF_LONG)
DEBUGASSERT((unsigned long) slnum <= (unsigned long) CURL_MASK_UINT);
#endif
return (unsigned int)(slnum & (long) CURL_MASK_UINT);
@@ -401,44 +401,6 @@ unsigned short curlx_uitous(unsigned int uinum)
}
/*
-** unsigned int to unsigned char
-*/
-
-unsigned char curlx_uitouc(unsigned int uinum)
-{
-#ifdef __INTEL_COMPILER
-# pragma warning(push)
-# pragma warning(disable:810) /* conversion may lose significant bits */
-#endif
-
- DEBUGASSERT(uinum <= (unsigned int) CURL_MASK_UCHAR);
- return (unsigned char) (uinum & (unsigned int) CURL_MASK_UCHAR);
-
-#ifdef __INTEL_COMPILER
-# pragma warning(pop)
-#endif
-}
-
-/*
-** unsigned int to signed int
-*/
-
-int curlx_uitosi(unsigned int uinum)
-{
-#ifdef __INTEL_COMPILER
-# pragma warning(push)
-# pragma warning(disable:810) /* conversion may lose significant bits */
-#endif
-
- DEBUGASSERT(uinum <= (unsigned int) CURL_MASK_SINT);
- return (int) (uinum & (unsigned int) CURL_MASK_SINT);
-
-#ifdef __INTEL_COMPILER
-# pragma warning(pop)
-#endif
-}
-
-/*
** signed int to unsigned size_t
*/
diff --git a/Utilities/cmcurl/lib/warnless.h b/Utilities/cmcurl/lib/warnless.h
index ab6d29998..ea4c4395d 100644
--- a/Utilities/cmcurl/lib/warnless.h
+++ b/Utilities/cmcurl/lib/warnless.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -26,6 +26,9 @@
#include <curl/curl.h> /* for curl_socket_t */
#endif
+#define CURLX_FUNCTION_CAST(target_type, func) \
+ (target_type)(void (*) (void))(func)
+
unsigned short curlx_ultous(unsigned long ulnum);
unsigned char curlx_ultouc(unsigned long ulnum);
@@ -54,10 +57,6 @@ int curlx_sztosi(ssize_t sznum);
unsigned short curlx_uitous(unsigned int uinum);
-unsigned char curlx_uitouc(unsigned int uinum);
-
-int curlx_uitosi(unsigned int uinum);
-
size_t curlx_sitouz(int sinum);
#ifdef USE_WINSOCK
diff --git a/Utilities/cmcurl/lib/wildcard.c b/Utilities/cmcurl/lib/wildcard.c
index af45c79bd..e94d3c544 100644
--- a/Utilities/cmcurl/lib/wildcard.c
+++ b/Utilities/cmcurl/lib/wildcard.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,6 +22,8 @@
#include "curl_setup.h"
+#ifndef CURL_DISABLE_FTP
+
#include "wildcard.h"
#include "llist.h"
#include "fileinfo.h"
@@ -30,9 +32,15 @@
#include "curl_memory.h"
#include "memdebug.h"
+static void fileinfo_dtor(void *user, void *element)
+{
+ (void)user;
+ Curl_fileinfo_cleanup(element);
+}
+
CURLcode Curl_wildcard_init(struct WildcardData *wc)
{
- Curl_llist_init(&wc->filelist, Curl_fileinfo_dtor);
+ Curl_llist_init(&wc->filelist, fileinfo_dtor);
wc->state = CURLWC_INIT;
return CURLE_OK;
@@ -43,12 +51,12 @@ void Curl_wildcard_dtor(struct WildcardData *wc)
if(!wc)
return;
- if(wc->tmp_dtor) {
- wc->tmp_dtor(wc->tmp);
- wc->tmp_dtor = ZERO_NULL;
- wc->tmp = NULL;
+ if(wc->dtor) {
+ wc->dtor(wc->protdata);
+ wc->dtor = ZERO_NULL;
+ wc->protdata = NULL;
}
- DEBUGASSERT(wc->tmp == NULL);
+ DEBUGASSERT(wc->protdata == NULL);
Curl_llist_destroy(&wc->filelist, NULL);
@@ -61,3 +69,5 @@ void Curl_wildcard_dtor(struct WildcardData *wc)
wc->customptr = NULL;
wc->state = CURLWC_INIT;
}
+
+#endif /* if disabled */
diff --git a/Utilities/cmcurl/lib/wildcard.h b/Utilities/cmcurl/lib/wildcard.h
index 8a5e4b769..306c8c99f 100644
--- a/Utilities/cmcurl/lib/wildcard.h
+++ b/Utilities/cmcurl/lib/wildcard.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2010 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2010 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,8 +22,9 @@
*
***************************************************************************/
-#include <curl/curl.h>
+#include "curl_setup.h"
+#ifndef CURL_DISABLE_FTP
#include "llist.h"
/* list of wildcard process states */
@@ -40,7 +41,7 @@ typedef enum {
will end */
} curl_wildcard_states;
-typedef void (*curl_wildcard_tmp_dtor)(void *ptr);
+typedef void (*curl_wildcard_dtor)(void *ptr);
/* struct keeping information about wildcard download process */
struct WildcardData {
@@ -48,8 +49,8 @@ struct WildcardData {
char *path; /* path to the directory, where we trying wildcard-match */
char *pattern; /* wildcard pattern */
struct curl_llist filelist; /* llist with struct Curl_fileinfo */
- void *tmp; /* pointer to protocol specific temporary data */
- curl_wildcard_tmp_dtor tmp_dtor;
+ void *protdata; /* pointer to protocol specific temporary data */
+ curl_wildcard_dtor dtor;
void *customptr; /* for CURLOPT_CHUNK_DATA pointer */
};
@@ -58,4 +59,9 @@ void Curl_wildcard_dtor(struct WildcardData *wc);
struct Curl_easy;
+#else
+/* FTP is disabled */
+#define Curl_wildcard_dtor(x)
+#endif
+
#endif /* HEADER_CURL_WILDCARD_H */
diff --git a/Utilities/cmcurl/lib/x509asn1.c b/Utilities/cmcurl/lib/x509asn1.c
index bba20233f..0c1256ba8 100644
--- a/Utilities/cmcurl/lib/x509asn1.c
+++ b/Utilities/cmcurl/lib/x509asn1.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -40,10 +40,6 @@
#include "curl_memory.h"
#include "memdebug.h"
-/* For overflow checks. */
-#define CURL_SIZE_T_MAX ((size_t)-1)
-
-
/* ASN.1 OIDs. */
static const char cnOID[] = "2.5.4.3"; /* Common name. */
static const char sanOID[] = "2.5.29.17"; /* Subject alternative name. */
@@ -107,9 +103,12 @@ static const curl_OID OIDtable[] = {
* Please note there is no pretention here to rewrite a full SSL library.
*/
+static const char *getASN1Element(curl_asn1Element *elem,
+ const char *beg, const char *end)
+ WARN_UNUSED_RESULT;
-const char *Curl_getASN1Element(curl_asn1Element *elem,
- const char *beg, const char *end)
+static const char *getASN1Element(curl_asn1Element *elem,
+ const char *beg, const char *end)
{
unsigned char b;
unsigned long len;
@@ -121,7 +120,7 @@ const char *Curl_getASN1Element(curl_asn1Element *elem,
if an error occurs. */
if(!beg || !end || beg >= end || !*beg ||
(size_t)(end - beg) > CURL_ASN1_MAX)
- return (const char *) NULL;
+ return NULL;
/* Process header byte. */
elem->header = beg;
@@ -130,12 +129,12 @@ const char *Curl_getASN1Element(curl_asn1Element *elem,
elem->class = (b >> 6) & 3;
b &= 0x1F;
if(b == 0x1F)
- return (const char *) NULL; /* Long tag values not supported here. */
+ return NULL; /* Long tag values not supported here. */
elem->tag = b;
/* Process length. */
if(beg >= end)
- return (const char *) NULL;
+ return NULL;
b = (unsigned char) *beg++;
if(!(b & 0x80))
len = b;
@@ -143,74 +142,77 @@ const char *Curl_getASN1Element(curl_asn1Element *elem,
/* Unspecified length. Since we have all the data, we can determine the
effective length by skipping element until an end element is found. */
if(!elem->constructed)
- return (const char *) NULL;
+ return NULL;
elem->beg = beg;
while(beg < end && *beg) {
- beg = Curl_getASN1Element(&lelem, beg, end);
+ beg = getASN1Element(&lelem, beg, end);
if(!beg)
- return (const char *) NULL;
+ return NULL;
}
if(beg >= end)
- return (const char *) NULL;
+ return NULL;
elem->end = beg;
return beg + 1;
}
else if((unsigned)b > (size_t)(end - beg))
- return (const char *) NULL; /* Does not fit in source. */
+ return NULL; /* Does not fit in source. */
else {
/* Get long length. */
len = 0;
do {
if(len & 0xFF000000L)
- return (const char *) NULL; /* Lengths > 32 bits are not supported. */
+ return NULL; /* Lengths > 32 bits are not supported. */
len = (len << 8) | (unsigned char) *beg++;
} while(--b);
}
if(len > (size_t)(end - beg))
- return (const char *) NULL; /* Element data does not fit in source. */
+ return NULL; /* Element data does not fit in source. */
elem->beg = beg;
elem->end = beg + len;
return elem->end;
}
+/*
+ * Search the null terminated OID or OID identifier in local table.
+ * Return the table entry pointer or NULL if not found.
+ */
static const curl_OID * searchOID(const char *oid)
{
const curl_OID *op;
-
- /* Search the null terminated OID or OID identifier in local table.
- Return the table entry pointer or NULL if not found. */
-
for(op = OIDtable; op->numoid; op++)
if(!strcmp(op->numoid, oid) || strcasecompare(op->textoid, oid))
return op;
- return (const curl_OID *) NULL;
+ return NULL;
}
+/*
+ * Convert an ASN.1 Boolean value into its string representation. Return the
+ * dynamically allocated string, or NULL if source is not an ASN.1 Boolean
+ * value.
+ */
+
static const char *bool2str(const char *beg, const char *end)
{
- /* Convert an ASN.1 Boolean value into its string representation.
- Return the dynamically allocated string, or NULL if source is not an
- ASN.1 Boolean value. */
-
if(end - beg != 1)
- return (const char *) NULL;
+ return NULL;
return strdup(*beg? "TRUE": "FALSE");
}
+/*
+ * Convert an ASN.1 octet string to a printable string.
+ * Return the dynamically allocated string, or NULL if an error occurs.
+ */
static const char *octet2str(const char *beg, const char *end)
{
size_t n = end - beg;
char *buf = NULL;
- /* Convert an ASN.1 octet string to a printable string.
- Return the dynamically allocated string, or NULL if an error occurs. */
-
- if(n <= (CURL_SIZE_T_MAX - 1) / 3) {
+ if(n <= (SIZE_T_MAX - 1) / 3) {
buf = malloc(3 * n + 1);
if(buf)
for(n = 0; beg < end; n += 3)
- snprintf(buf + n, 4, "%02x:", *(const unsigned char *) beg++);
+ msnprintf(buf + n, 4, "%02x:", *(const unsigned char *) beg++);
}
return buf;
}
@@ -221,21 +223,22 @@ static const char *bit2str(const char *beg, const char *end)
Return the dynamically allocated string, or NULL if an error occurs. */
if(++beg > end)
- return (const char *) NULL;
+ return NULL;
return octet2str(beg, end);
}
+/*
+ * Convert an ASN.1 integer value into its string representation.
+ * Return the dynamically allocated string, or NULL if source is not an
+ * ASN.1 integer value.
+ */
static const char *int2str(const char *beg, const char *end)
{
- long val = 0;
+ unsigned long val = 0;
size_t n = end - beg;
- /* Convert an ASN.1 integer value into its string representation.
- Return the dynamically allocated string, or NULL if source is not an
- ASN.1 integer value. */
-
if(!n)
- return (const char *) NULL;
+ return NULL;
if(n > 4)
return octet2str(beg, end);
@@ -247,26 +250,25 @@ static const char *int2str(const char *beg, const char *end)
do
val = (val << 8) | *(const unsigned char *) beg++;
while(beg < end);
- return curl_maprintf("%s%lx", (val < 0 || val >= 10)? "0x": "", val);
+ return curl_maprintf("%s%lx", val >= 10? "0x": "", val);
}
+/*
+ * Perform a lazy conversion from an ASN.1 typed string to UTF8. Allocate the
+ * destination buffer dynamically. The allocation size will normally be too
+ * large: this is to avoid buffer overflows.
+ * Terminate the string with a nul byte and return the converted
+ * string length.
+ */
static ssize_t
utf8asn1str(char **to, int type, const char *from, const char *end)
{
size_t inlength = end - from;
int size = 1;
size_t outlength;
- int charsize;
- unsigned int wc;
char *buf;
- /* Perform a lazy conversion from an ASN.1 typed string to UTF8. Allocate the
- destination buffer dynamically. The allocation size will normally be too
- large: this is to avoid buffer overflows.
- Terminate the string with a nul byte and return the converted
- string length. */
-
- *to = (char *) NULL;
+ *to = NULL;
switch(type) {
case CURL_ASN1_BMP_STRING:
size = 2;
@@ -287,7 +289,7 @@ utf8asn1str(char **to, int type, const char *from, const char *end)
if(inlength % size)
return -1; /* Length inconsistent with character size. */
- if(inlength / size > (CURL_SIZE_T_MAX - 1) / 4)
+ if(inlength / size > (SIZE_T_MAX - 1) / 4)
return -1; /* Too big. */
buf = malloc(4 * (inlength / size) + 1);
if(!buf)
@@ -301,15 +303,18 @@ utf8asn1str(char **to, int type, const char *from, const char *end)
}
else {
for(outlength = 0; from < end;) {
+ int charsize;
+ unsigned int wc;
+
wc = 0;
switch(size) {
case 4:
wc = (wc << 8) | *(const unsigned char *) from++;
wc = (wc << 8) | *(const unsigned char *) from++;
- /* fallthrough */
+ /* FALLTHROUGH */
case 2:
wc = (wc << 8) | *(const unsigned char *) from++;
- /* fallthrough */
+ /* FALLTHROUGH */
default: /* case 1: */
wc = (wc << 8) | *(const unsigned char *) from++;
}
@@ -342,96 +347,105 @@ utf8asn1str(char **to, int type, const char *from, const char *end)
return outlength;
}
+/*
+ * Convert an ASN.1 String into its UTF-8 string representation.
+ * Return the dynamically allocated string, or NULL if an error occurs.
+ */
static const char *string2str(int type, const char *beg, const char *end)
{
char *buf;
-
- /* Convert an ASN.1 String into its UTF-8 string representation.
- Return the dynamically allocated string, or NULL if an error occurs. */
-
if(utf8asn1str(&buf, type, beg, end) < 0)
- return (const char *) NULL;
+ return NULL;
return buf;
}
-static int encodeUint(char *buf, int n, unsigned int x)
+/*
+ * Decimal ASCII encode unsigned integer `x' into the buflen sized buffer at
+ * buf. Return the total number of encoded digits, even if larger than
+ * `buflen'.
+ */
+static size_t encodeUint(char *buf, size_t buflen, unsigned int x)
{
- int i = 0;
+ size_t i = 0;
unsigned int y = x / 10;
- /* Decimal ASCII encode unsigned integer `x' in the `n'-byte buffer at `buf'.
- Return the total number of encoded digits, even if larger than `n'. */
-
if(y) {
- i += encodeUint(buf, n, y);
+ i = encodeUint(buf, buflen, y);
x -= y * 10;
}
- if(i < n)
+ if(i < buflen)
buf[i] = (char) ('0' + x);
i++;
- if(i < n)
+ if(i < buflen)
buf[i] = '\0'; /* Store a terminator if possible. */
return i;
}
-static int encodeOID(char *buf, int n, const char *beg, const char *end)
+/*
+ * Convert an ASN.1 OID into its dotted string representation.
+ * Store the result in th `n'-byte buffer at `buf'.
+ * Return the converted string length, or 0 on errors.
+ */
+static size_t encodeOID(char *buf, size_t buflen,
+ const char *beg, const char *end)
{
- int i = 0;
+ size_t i;
unsigned int x;
unsigned int y;
- /* Convert an ASN.1 OID into its dotted string representation.
- Store the result in th `n'-byte buffer at `buf'.
- Return the converted string length, or -1 if an error occurs. */
-
/* Process the first two numbers. */
y = *(const unsigned char *) beg++;
x = y / 40;
y -= x * 40;
- i += encodeUint(buf + i, n - i, x);
- if(i < n)
+ i = encodeUint(buf, buflen, x);
+ if(i < buflen)
buf[i] = '.';
i++;
- i += encodeUint(buf + i, n - i, y);
+ if(i >= buflen)
+ i += encodeUint(NULL, 0, y);
+ else
+ i += encodeUint(buf + i, buflen - i, y);
/* Process the trailing numbers. */
while(beg < end) {
- if(i < n)
+ if(i < buflen)
buf[i] = '.';
i++;
x = 0;
do {
if(x & 0xFF000000)
- return -1;
+ return 0;
y = *(const unsigned char *) beg++;
x = (x << 7) | (y & 0x7F);
} while(y & 0x80);
- i += encodeUint(buf + i, n - i, x);
+ if(i >= buflen)
+ i += encodeUint(NULL, 0, x);
+ else
+ i += encodeUint(buf + i, buflen - i, x);
}
- if(i < n)
+ if(i < buflen)
buf[i] = '\0';
return i;
}
+/*
+ * Convert an ASN.1 OID into its dotted or symbolic string representation.
+ * Return the dynamically allocated string, or NULL if an error occurs.
+ */
+
static const char *OID2str(const char *beg, const char *end, bool symbolic)
{
- char *buf = (char *) NULL;
- const curl_OID * op;
- int n;
-
- /* Convert an ASN.1 OID into its dotted or symbolic string representation.
- Return the dynamically allocated string, or NULL if an error occurs. */
-
+ char *buf = NULL;
if(beg < end) {
- n = encodeOID((char *) NULL, -1, beg, end);
- if(n >= 0) {
- buf = malloc(n + 1);
+ size_t buflen = encodeOID(NULL, 0, beg, end);
+ if(buflen) {
+ buf = malloc(buflen + 1); /* one extra for the zero byte */
if(buf) {
- encodeOID(buf, n, beg, end);
- buf[n] = '\0';
+ encodeOID(buf, buflen, beg, end);
+ buf[buflen] = '\0';
if(symbolic) {
- op = searchOID(buf);
+ const curl_OID *op = searchOID(buf);
if(op) {
free(buf);
buf = strdup(op->textoid);
@@ -471,7 +485,7 @@ static const char *GTime2str(const char *beg, const char *end)
sec2 = fracp[-1];
break;
default:
- return (const char *) NULL;
+ return NULL;
}
/* Scan for timezone, measure fractional seconds. */
@@ -507,15 +521,16 @@ static const char *GTime2str(const char *beg, const char *end)
sep, tzl, tzp);
}
+/*
+ * Convert an ASN.1 UTC time to a printable string.
+ * Return the dynamically allocated string, or NULL if an error occurs.
+ */
static const char *UTime2str(const char *beg, const char *end)
{
const char *tzp;
size_t tzl;
const char *sec;
- /* Convert an ASN.1 UTC time to a printable string.
- Return the dynamically allocated string, or NULL if an error occurs. */
-
for(tzp = beg; tzp < end && *tzp >= '0' && *tzp <= '9'; tzp++)
;
/* Get the seconds. */
@@ -526,12 +541,12 @@ static const char *UTime2str(const char *beg, const char *end)
case 2:
break;
default:
- return (const char *) NULL;
+ return NULL;
}
/* Process timezone. */
if(tzp >= end)
- return (const char *) NULL;
+ return NULL;
if(*tzp == 'Z') {
tzp = "GMT";
end = tzp + 3;
@@ -546,13 +561,14 @@ static const char *UTime2str(const char *beg, const char *end)
tzl, tzp);
}
-const char *Curl_ASN1tostr(curl_asn1Element *elem, int type)
+/*
+ * Convert an ASN.1 element to a printable string.
+ * Return the dynamically allocated string, or NULL if an error occurs.
+ */
+static const char *ASN1tostr(curl_asn1Element *elem, int type)
{
- /* Convert an ASN.1 element to a printable string.
- Return the dynamically allocated string, or NULL if an error occurs. */
-
if(elem->constructed)
- return (const char *) NULL; /* No conversion of structured elements. */
+ return NULL; /* No conversion of structured elements. */
if(!type)
type = elem->tag; /* Type not forced: use element tag as type. */
@@ -586,10 +602,14 @@ const char *Curl_ASN1tostr(curl_asn1Element *elem, int type)
return string2str(type, elem->beg, elem->end);
}
- return (const char *) NULL; /* Unsupported. */
+ return NULL; /* Unsupported. */
}
-static ssize_t encodeDN(char *buf, size_t n, curl_asn1Element *dn)
+/*
+ * ASCII encode distinguished name at `dn' into the `buflen'-sized buffer at
+ * `buf'. Return the total string length, even if larger than `buflen'.
+ */
+static ssize_t encodeDN(char *buf, size_t buflen, curl_asn1Element *dn)
{
curl_asn1Element rdn;
curl_asn1Element atv;
@@ -601,16 +621,20 @@ static ssize_t encodeDN(char *buf, size_t n, curl_asn1Element *dn)
const char *p3;
const char *str;
- /* ASCII encode distinguished name at `dn' into the `n'-byte buffer at `buf'.
- Return the total string length, even if larger than `n'. */
-
for(p1 = dn->beg; p1 < dn->end;) {
- p1 = Curl_getASN1Element(&rdn, p1, dn->end);
+ p1 = getASN1Element(&rdn, p1, dn->end);
+ if(!p1)
+ return -1;
for(p2 = rdn.beg; p2 < rdn.end;) {
- p2 = Curl_getASN1Element(&atv, p2, rdn.end);
- p3 = Curl_getASN1Element(&oid, atv.beg, atv.end);
- Curl_getASN1Element(&value, p3, atv.end);
- str = Curl_ASN1tostr(&oid, 0);
+ p2 = getASN1Element(&atv, p2, rdn.end);
+ if(!p2)
+ return -1;
+ p3 = getASN1Element(&oid, atv.beg, atv.end);
+ if(!p3)
+ return -1;
+ if(!getASN1Element(&value, p3, atv.end))
+ return -1;
+ str = ASN1tostr(&oid, 0);
if(!str)
return -1;
@@ -620,7 +644,7 @@ static ssize_t encodeDN(char *buf, size_t n, curl_asn1Element *dn)
for(p3 = str; isupper(*p3); p3++)
;
for(p3 = (*p3 || p3 - str > 2)? "/": ", "; *p3; p3++) {
- if(l < n)
+ if(l < buflen)
buf[l] = *p3;
l++;
}
@@ -628,23 +652,23 @@ static ssize_t encodeDN(char *buf, size_t n, curl_asn1Element *dn)
/* Encode attribute name. */
for(p3 = str; *p3; p3++) {
- if(l < n)
+ if(l < buflen)
buf[l] = *p3;
l++;
}
free((char *) str);
/* Generate equal sign. */
- if(l < n)
+ if(l < buflen)
buf[l] = '=';
l++;
/* Generate value. */
- str = Curl_ASN1tostr(&value, 0);
+ str = ASN1tostr(&value, 0);
if(!str)
return -1;
for(p3 = str; *p3; p3++) {
- if(l < n)
+ if(l < buflen)
buf[l] = *p3;
l++;
}
@@ -655,28 +679,30 @@ static ssize_t encodeDN(char *buf, size_t n, curl_asn1Element *dn)
return l;
}
-const char *Curl_DNtostr(curl_asn1Element *dn)
+/*
+ * Convert an ASN.1 distinguished name into a printable string.
+ * Return the dynamically allocated string, or NULL if an error occurs.
+ */
+static const char *DNtostr(curl_asn1Element *dn)
{
- char *buf = (char *) NULL;
- ssize_t n = encodeDN(buf, 0, dn);
-
- /* Convert an ASN.1 distinguished name into a printable string.
- Return the dynamically allocated string, or NULL if an error occurs. */
+ char *buf = NULL;
+ ssize_t buflen = encodeDN(NULL, 0, dn);
- if(n >= 0) {
- buf = malloc(n + 1);
+ if(buflen >= 0) {
+ buf = malloc(buflen + 1);
if(buf) {
- encodeDN(buf, n + 1, dn);
- buf[n] = '\0';
+ encodeDN(buf, buflen + 1, dn);
+ buf[buflen] = '\0';
}
}
- return (const char *) buf;
+ return buf;
}
/*
- * X509 parser.
+ * ASN.1 parse an X509 certificate into structure subfields.
+ * Syntax is assumed to have already been checked by the SSL backend.
+ * See RFC 5280.
*/
-
int Curl_parseX509(curl_X509certificate *cert,
const char *beg, const char *end)
{
@@ -685,26 +711,27 @@ int Curl_parseX509(curl_X509certificate *cert,
const char *ccp;
static const char defaultVersion = 0; /* v1. */
- /* ASN.1 parse an X509 certificate into structure subfields.
- Syntax is assumed to have already been checked by the SSL backend.
- See RFC 5280. */
-
cert->certificate.header = NULL;
cert->certificate.beg = beg;
cert->certificate.end = end;
/* Get the sequence content. */
- if(!Curl_getASN1Element(&elem, beg, end))
+ if(!getASN1Element(&elem, beg, end))
return -1; /* Invalid bounds/size. */
beg = elem.beg;
end = elem.end;
/* Get tbsCertificate. */
- beg = Curl_getASN1Element(&tbsCertificate, beg, end);
+ beg = getASN1Element(&tbsCertificate, beg, end);
+ if(!beg)
+ return -1;
/* Skip the signatureAlgorithm. */
- beg = Curl_getASN1Element(&cert->signatureAlgorithm, beg, end);
+ beg = getASN1Element(&cert->signatureAlgorithm, beg, end);
+ if(!beg)
+ return -1;
/* Get the signatureValue. */
- Curl_getASN1Element(&cert->signature, beg, end);
+ if(!getASN1Element(&cert->signature, beg, end))
+ return -1;
/* Parse TBSCertificate. */
beg = tbsCertificate.beg;
@@ -712,30 +739,49 @@ int Curl_parseX509(curl_X509certificate *cert,
/* Get optional version, get serialNumber. */
cert->version.header = NULL;
cert->version.beg = &defaultVersion;
- cert->version.end = &defaultVersion + sizeof defaultVersion;;
- beg = Curl_getASN1Element(&elem, beg, end);
+ cert->version.end = &defaultVersion + sizeof(defaultVersion);
+ beg = getASN1Element(&elem, beg, end);
+ if(!beg)
+ return -1;
if(elem.tag == 0) {
- Curl_getASN1Element(&cert->version, elem.beg, elem.end);
- beg = Curl_getASN1Element(&elem, beg, end);
+ if(!getASN1Element(&cert->version, elem.beg, elem.end))
+ return -1;
+ beg = getASN1Element(&elem, beg, end);
+ if(!beg)
+ return -1;
}
cert->serialNumber = elem;
/* Get signature algorithm. */
- beg = Curl_getASN1Element(&cert->signatureAlgorithm, beg, end);
+ beg = getASN1Element(&cert->signatureAlgorithm, beg, end);
/* Get issuer. */
- beg = Curl_getASN1Element(&cert->issuer, beg, end);
+ beg = getASN1Element(&cert->issuer, beg, end);
+ if(!beg)
+ return -1;
/* Get notBefore and notAfter. */
- beg = Curl_getASN1Element(&elem, beg, end);
- ccp = Curl_getASN1Element(&cert->notBefore, elem.beg, elem.end);
- Curl_getASN1Element(&cert->notAfter, ccp, elem.end);
+ beg = getASN1Element(&elem, beg, end);
+ if(!beg)
+ return -1;
+ ccp = getASN1Element(&cert->notBefore, elem.beg, elem.end);
+ if(!ccp)
+ return -1;
+ if(!getASN1Element(&cert->notAfter, ccp, elem.end))
+ return -1;
/* Get subject. */
- beg = Curl_getASN1Element(&cert->subject, beg, end);
+ beg = getASN1Element(&cert->subject, beg, end);
+ if(!beg)
+ return -1;
/* Get subjectPublicKeyAlgorithm and subjectPublicKey. */
- beg = Curl_getASN1Element(&cert->subjectPublicKeyInfo, beg, end);
- ccp = Curl_getASN1Element(&cert->subjectPublicKeyAlgorithm,
- cert->subjectPublicKeyInfo.beg,
- cert->subjectPublicKeyInfo.end);
- Curl_getASN1Element(&cert->subjectPublicKey, ccp,
- cert->subjectPublicKeyInfo.end);
+ beg = getASN1Element(&cert->subjectPublicKeyInfo, beg, end);
+ if(!beg)
+ return -1;
+ ccp = getASN1Element(&cert->subjectPublicKeyAlgorithm,
+ cert->subjectPublicKeyInfo.beg,
+ cert->subjectPublicKeyInfo.end);
+ if(!ccp)
+ return -1;
+ if(!getASN1Element(&cert->subjectPublicKey, ccp,
+ cert->subjectPublicKeyInfo.end))
+ return -1;
/* Get optional issuerUiqueID, subjectUniqueID and extensions. */
cert->issuerUniqueID.tag = cert->subjectUniqueID.tag = 0;
cert->extensions.tag = elem.tag = 0;
@@ -744,30 +790,41 @@ int Curl_parseX509(curl_X509certificate *cert,
cert->subjectUniqueID.beg = cert->subjectUniqueID.end = "";
cert->extensions.header = NULL;
cert->extensions.beg = cert->extensions.end = "";
- if(beg < end)
- beg = Curl_getASN1Element(&elem, beg, end);
+ if(beg < end) {
+ beg = getASN1Element(&elem, beg, end);
+ if(!beg)
+ return -1;
+ }
if(elem.tag == 1) {
cert->issuerUniqueID = elem;
- if(beg < end)
- beg = Curl_getASN1Element(&elem, beg, end);
+ if(beg < end) {
+ beg = getASN1Element(&elem, beg, end);
+ if(!beg)
+ return -1;
+ }
}
if(elem.tag == 2) {
cert->subjectUniqueID = elem;
- if(beg < end)
- beg = Curl_getASN1Element(&elem, beg, end);
+ if(beg < end) {
+ beg = getASN1Element(&elem, beg, end);
+ if(!beg)
+ return -1;
+ }
}
if(elem.tag == 3)
- Curl_getASN1Element(&cert->extensions, elem.beg, elem.end);
+ if(!getASN1Element(&cert->extensions, elem.beg, elem.end))
+ return -1;
return 0;
}
+
+/*
+ * Copy at most 64-characters, terminate with a newline and returns the
+ * effective number of stored characters.
+ */
static size_t copySubstring(char *to, const char *from)
{
size_t i;
-
- /* Copy at most 64-characters, terminate with a newline and returns the
- effective number of stored characters. */
-
for(i = 0; i < 64; i++) {
to[i] = *from;
if(!*from++)
@@ -785,12 +842,15 @@ static const char *dumpAlgo(curl_asn1Element *param,
/* Get algorithm parameters and return algorithm name. */
- beg = Curl_getASN1Element(&oid, beg, end);
+ beg = getASN1Element(&oid, beg, end);
+ if(!beg)
+ return NULL;
param->header = NULL;
param->tag = 0;
param->beg = param->end = end;
if(beg < end)
- Curl_getASN1Element(param, beg, end);
+ if(!getASN1Element(param, beg, end))
+ return NULL;
return OID2str(oid.beg, oid.end, TRUE);
}
@@ -801,7 +861,7 @@ static void do_pubkey_field(struct Curl_easy *data, int certnum,
/* Generate a certificate information record for the public key. */
- output = Curl_ASN1tostr(elem, 0);
+ output = ASN1tostr(elem, 0);
if(output) {
if(data->set.ssl.certinfo)
Curl_ssl_push_certinfo(data, certnum, label, output);
@@ -818,24 +878,30 @@ static void do_pubkey(struct Curl_easy *data, int certnum,
curl_asn1Element elem;
curl_asn1Element pk;
const char *p;
- const char *q;
- unsigned long len;
- unsigned int i;
/* Generate all information records for the public key. */
/* Get the public key (single element). */
- Curl_getASN1Element(&pk, pubkey->beg + 1, pubkey->end);
+ if(!getASN1Element(&pk, pubkey->beg + 1, pubkey->end))
+ return;
if(strcasecompare(algo, "rsaEncryption")) {
- p = Curl_getASN1Element(&elem, pk.beg, pk.end);
+ const char *q;
+ unsigned long len;
+
+ p = getASN1Element(&elem, pk.beg, pk.end);
+ if(!p)
+ return;
+
/* Compute key length. */
for(q = elem.beg; !*q && q < elem.end; q++)
;
len = (unsigned long)((elem.end - q) * 8);
- if(len)
+ if(len) {
+ unsigned int i;
for(i = *(unsigned char *) q; !(i & 0x80); i <<= 1)
len--;
+ }
if(len > 32)
elem.beg = q; /* Strip leading zero bytes. */
if(!certnum)
@@ -849,30 +915,34 @@ static void do_pubkey(struct Curl_easy *data, int certnum,
}
/* Generate coefficients. */
do_pubkey_field(data, certnum, "rsa(n)", &elem);
- Curl_getASN1Element(&elem, p, pk.end);
+ if(!getASN1Element(&elem, p, pk.end))
+ return;
do_pubkey_field(data, certnum, "rsa(e)", &elem);
}
else if(strcasecompare(algo, "dsa")) {
- p = Curl_getASN1Element(&elem, param->beg, param->end);
- do_pubkey_field(data, certnum, "dsa(p)", &elem);
- p = Curl_getASN1Element(&elem, p, param->end);
- do_pubkey_field(data, certnum, "dsa(q)", &elem);
- Curl_getASN1Element(&elem, p, param->end);
- do_pubkey_field(data, certnum, "dsa(g)", &elem);
- do_pubkey_field(data, certnum, "dsa(pub_key)", &pk);
+ p = getASN1Element(&elem, param->beg, param->end);
+ if(p) {
+ do_pubkey_field(data, certnum, "dsa(p)", &elem);
+ p = getASN1Element(&elem, p, param->end);
+ if(p) {
+ do_pubkey_field(data, certnum, "dsa(q)", &elem);
+ if(getASN1Element(&elem, p, param->end)) {
+ do_pubkey_field(data, certnum, "dsa(g)", &elem);
+ do_pubkey_field(data, certnum, "dsa(pub_key)", &pk);
+ }
+ }
+ }
}
else if(strcasecompare(algo, "dhpublicnumber")) {
- p = Curl_getASN1Element(&elem, param->beg, param->end);
- do_pubkey_field(data, certnum, "dh(p)", &elem);
- Curl_getASN1Element(&elem, param->beg, param->end);
- do_pubkey_field(data, certnum, "dh(g)", &elem);
- do_pubkey_field(data, certnum, "dh(pub_key)", &pk);
- }
-#if 0 /* Patent-encumbered. */
- else if(strcasecompare(algo, "ecPublicKey")) {
- /* Left TODO. */
+ p = getASN1Element(&elem, param->beg, param->end);
+ if(p) {
+ do_pubkey_field(data, certnum, "dh(p)", &elem);
+ if(getASN1Element(&elem, param->beg, param->end)) {
+ do_pubkey_field(data, certnum, "dh(g)", &elem);
+ do_pubkey_field(data, certnum, "dh(pub_key)", &pk);
+ }
+ }
}
-#endif
}
CURLcode Curl_extract_certinfo(struct connectdata *conn,
@@ -900,10 +970,10 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn,
/* Extract the certificate ASN.1 elements. */
if(Curl_parseX509(&cert, beg, end))
- return CURLE_OUT_OF_MEMORY;
+ return CURLE_PEER_FAILED_VERIFICATION;
/* Subject. */
- ccp = Curl_DNtostr(&cert.subject);
+ ccp = DNtostr(&cert.subject);
if(!ccp)
return CURLE_OUT_OF_MEMORY;
if(data->set.ssl.certinfo)
@@ -913,7 +983,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn,
free((char *) ccp);
/* Issuer. */
- ccp = Curl_DNtostr(&cert.issuer);
+ ccp = DNtostr(&cert.issuer);
if(!ccp)
return CURLE_OUT_OF_MEMORY;
if(data->set.ssl.certinfo)
@@ -937,7 +1007,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn,
infof(data, " Version: %lu (0x%lx)\n", version + 1, version);
/* Serial number. */
- ccp = Curl_ASN1tostr(&cert.serialNumber, 0);
+ ccp = ASN1tostr(&cert.serialNumber, 0);
if(!ccp)
return CURLE_OUT_OF_MEMORY;
if(data->set.ssl.certinfo)
@@ -958,7 +1028,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn,
free((char *) ccp);
/* Start Date. */
- ccp = Curl_ASN1tostr(&cert.notBefore, 0);
+ ccp = ASN1tostr(&cert.notBefore, 0);
if(!ccp)
return CURLE_OUT_OF_MEMORY;
if(data->set.ssl.certinfo)
@@ -968,7 +1038,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn,
free((char *) ccp);
/* Expire Date. */
- ccp = Curl_ASN1tostr(&cert.notAfter, 0);
+ ccp = ASN1tostr(&cert.notAfter, 0);
if(!ccp)
return CURLE_OUT_OF_MEMORY;
if(data->set.ssl.certinfo)
@@ -989,10 +1059,8 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn,
do_pubkey(data, certnum, ccp, &param, &cert.subjectPublicKey);
free((char *) ccp);
-/* TODO: extensions. */
-
/* Signature. */
- ccp = Curl_ASN1tostr(&cert.signature, 0);
+ ccp = ASN1tostr(&cert.signature, 0);
if(!ccp)
return CURLE_OUT_OF_MEMORY;
if(data->set.ssl.certinfo)
@@ -1051,17 +1119,17 @@ static const char *checkOID(const char *beg, const char *end,
/* Check if first ASN.1 element at `beg' is the given OID.
Return a pointer in the source after the OID if found, else NULL. */
- ccp = Curl_getASN1Element(&e, beg, end);
+ ccp = getASN1Element(&e, beg, end);
if(!ccp || e.tag != CURL_ASN1_OBJECT_IDENTIFIER)
- return (const char *) NULL;
+ return NULL;
p = OID2str(e.beg, e.end, FALSE);
if(!p)
- return (const char *) NULL;
+ return NULL;
matched = !strcmp(p, oid);
free((char *) p);
- return matched? ccp: (const char *) NULL;
+ return matched? ccp: NULL;
}
CURLcode Curl_verifyhost(struct connectdata *conn,
@@ -1110,19 +1178,30 @@ CURLcode Curl_verifyhost(struct connectdata *conn,
/* Process extensions. */
for(p = cert.extensions.beg; p < cert.extensions.end && matched != 1;) {
- p = Curl_getASN1Element(&ext, p, cert.extensions.end);
+ p = getASN1Element(&ext, p, cert.extensions.end);
+ if(!p)
+ return CURLE_PEER_FAILED_VERIFICATION;
+
/* Check if extension is a subjectAlternativeName. */
ext.beg = checkOID(ext.beg, ext.end, sanOID);
if(ext.beg) {
- ext.beg = Curl_getASN1Element(&elem, ext.beg, ext.end);
+ ext.beg = getASN1Element(&elem, ext.beg, ext.end);
+ if(!ext.beg)
+ return CURLE_PEER_FAILED_VERIFICATION;
/* Skip critical if present. */
- if(elem.tag == CURL_ASN1_BOOLEAN)
- ext.beg = Curl_getASN1Element(&elem, ext.beg, ext.end);
+ if(elem.tag == CURL_ASN1_BOOLEAN) {
+ ext.beg = getASN1Element(&elem, ext.beg, ext.end);
+ if(!ext.beg)
+ return CURLE_PEER_FAILED_VERIFICATION;
+ }
/* Parse the octet string contents: is a single sequence. */
- Curl_getASN1Element(&elem, elem.beg, elem.end);
+ if(!getASN1Element(&elem, elem.beg, elem.end))
+ return CURLE_PEER_FAILED_VERIFICATION;
/* Check all GeneralNames. */
for(q = elem.beg; matched != 1 && q < elem.end;) {
- q = Curl_getASN1Element(&name, q, elem.end);
+ q = getASN1Element(&name, q, elem.end);
+ if(!q)
+ break;
switch(name.tag) {
case 2: /* DNS name. */
len = utf8asn1str(&dnsname, CURL_ASN1_IA5_STRING,
@@ -1135,8 +1214,8 @@ CURLcode Curl_verifyhost(struct connectdata *conn,
break;
case 7: /* IP address. */
- matched = (size_t) (name.end - q) == addrlen &&
- !memcmp(&addr, q, addrlen);
+ matched = (size_t) (name.end - name.beg) == addrlen &&
+ !memcmp(&addr, name.beg, addrlen);
break;
}
}
@@ -1162,9 +1241,13 @@ CURLcode Curl_verifyhost(struct connectdata *conn,
/* we have to look to the last occurrence of a commonName in the
distinguished one to get the most significant one. */
while(q < cert.subject.end) {
- q = Curl_getASN1Element(&dn, q, cert.subject.end);
+ q = getASN1Element(&dn, q, cert.subject.end);
+ if(!q)
+ break;
for(p = dn.beg; p < dn.end;) {
- p = Curl_getASN1Element(&elem, p, dn.end);
+ p = getASN1Element(&elem, p, dn.end);
+ if(!p)
+ return CURLE_PEER_FAILED_VERIFICATION;
/* We have a DN's AttributeTypeAndValue: check it in case it's a CN. */
elem.beg = checkOID(elem.beg, elem.end, cnOID);
if(elem.beg)
@@ -1173,7 +1256,7 @@ CURLcode Curl_verifyhost(struct connectdata *conn,
}
/* Check the CN if found. */
- if(!Curl_getASN1Element(&elem, name.beg, name.end))
+ if(!getASN1Element(&elem, name.beg, name.end))
failf(data, "SSL: unable to obtain common name from peer certificate");
else {
len = utf8asn1str(&dnsname, elem.tag, elem.beg, elem.end);
diff --git a/Utilities/cmexpat/CMakeLists.txt b/Utilities/cmexpat/CMakeLists.txt
index 470fcba99..cf315563d 100644
--- a/Utilities/cmexpat/CMakeLists.txt
+++ b/Utilities/cmexpat/CMakeLists.txt
@@ -1,6 +1,6 @@
# Disable warnings to avoid changing 3rd party code.
IF(CMAKE_C_COMPILER_ID MATCHES
- "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
+ "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel)$")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
@@ -17,7 +17,6 @@ include_directories(
)
add_library(cmexpat STATIC
- lib/loadlibrary.c
lib/xmlparse.c
lib/xmlrole.c
lib/xmltok.c
diff --git a/Utilities/cmexpat/ConfigureChecks.cmake b/Utilities/cmexpat/ConfigureChecks.cmake
index 057cfa58d..d85e48c97 100644
--- a/Utilities/cmexpat/ConfigureChecks.cmake
+++ b/Utilities/cmexpat/ConfigureChecks.cmake
@@ -1,6 +1,7 @@
+include(CheckCCompilerFlag)
+include(CheckCSourceCompiles)
include(CheckIncludeFile)
include(CheckIncludeFiles)
-include(CheckFunctionExists)
include(CheckSymbolExists)
include(TestBigEndian)
@@ -16,10 +17,21 @@ check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
check_include_file("unistd.h" HAVE_UNISTD_H)
-check_function_exists("getpagesize" HAVE_GETPAGESIZE)
-check_function_exists("bcopy" HAVE_BCOPY)
-check_symbol_exists("memmove" "string.h" HAVE_MEMMOVE)
-check_function_exists("mmap" HAVE_MMAP)
+check_symbol_exists("getpagesize" "unistd.h" HAVE_GETPAGESIZE)
+check_symbol_exists("mmap" "sys/mman.h" HAVE_MMAP)
+check_symbol_exists("getrandom" "sys/random.h" HAVE_GETRANDOM)
+
+if(EXPAT_WITH_LIBBSD)
+ set(CMAKE_REQUIRED_LIBRARIES "${LIB_BSD}")
+ set(_bsd "bsd/")
+else()
+ set(_bsd "")
+endif()
+check_symbol_exists("arc4random_buf" "${_bsd}stdlib.h" HAVE_ARC4RANDOM_BUF)
+if(NOT HAVE_ARC4RANDOM_BUF)
+ check_symbol_exists("arc4random" "${_bsd}stdlib.h" HAVE_ARC4RANDOM)
+endif()
+set(CMAKE_REQUIRED_LIBRARIES)
#/* Define to 1 if you have the ANSI C header files. */
check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
@@ -40,5 +52,15 @@ else(HAVE_SYS_TYPES_H)
set(SIZE_T "unsigned")
endif(HAVE_SYS_TYPES_H)
-configure_file(expat_config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/expat_config.h")
-add_definitions(-DHAVE_EXPAT_CONFIG_H)
+check_c_source_compiles("
+ #include <stdlib.h> /* for NULL */
+ #include <unistd.h> /* for syscall */
+ #include <sys/syscall.h> /* for SYS_getrandom */
+ int main() {
+ syscall(SYS_getrandom, NULL, 0, 0);
+ return 0;
+ }"
+ HAVE_SYSCALL_GETRANDOM)
+
+check_c_compiler_flag("-fno-strict-aliasing" FLAG_NO_STRICT_ALIASING)
+check_c_compiler_flag("-fvisibility=hidden" FLAG_VISIBILITY)
diff --git a/Utilities/cmexpat/README.md b/Utilities/cmexpat/README.md
index 0a1777e7e..1cc52b014 100644
--- a/Utilities/cmexpat/README.md
+++ b/Utilities/cmexpat/README.md
@@ -1,4 +1,9 @@
-# Expat, Release 2.2.3
+[![Travis CI Build Status](https://travis-ci.org/libexpat/libexpat.svg?branch=master)](https://travis-ci.org/libexpat/libexpat)
+[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/libexpat/libexpat?svg=true)](https://ci.appveyor.com/project/libexpat/libexpat)
+[![Packaging status](https://repology.org/badge/tiny-repos/expat.svg)](https://repology.org/metapackage/expat/versions)
+
+
+# Expat, Release 2.2.9
This is Expat, a C library for parsing XML, started by
[James Clark](https://en.wikipedia.org/wiki/James_Clark_(programmer)) in 1997.
@@ -8,6 +13,11 @@ are called when the parser discovers the associated structures in the
document being parsed. A start tag is an example of the kind of
structures for which you may register handlers.
+Expat supports the following compilers:
+- GNU GCC >=4.5
+- LLVM Clang >=3.5
+- Microsoft Visual Studio >=8.0/2005
+
Windows users should use the
[`expat_win32` package](https://sourceforge.net/projects/expat/files/expat_win32/),
which includes both precompiled libraries and executables, and source code for
@@ -72,47 +82,43 @@ the directories into which things will be installed.
If you are interested in building Expat to provide document
information in UTF-16 encoding rather than the default UTF-8, follow
-these instructions (after having run `make distclean`):
+these instructions (after having run `make distclean`).
+Please note that we configure with `--without-xmlwf` as xmlwf does not
+support this mode of compilation (yet):
+
+1. Mass-patch `Makefile.am` files to use `libexpatw.la` for a library name:
+ <br/>
+ `find -name Makefile.am -exec sed
+ -e 's,libexpat\.la,libexpatw.la,'
+ -e 's,libexpat_la,libexpatw_la,'
+ -i {} +`
+
+1. Run `automake` to re-write `Makefile.in` files:<br/>
+ `automake`
1. For UTF-16 output as unsigned short (and version/error strings as char),
run:<br/>
- `./configure CPPFLAGS=-DXML_UNICODE`<br/>
+ `./configure CPPFLAGS=-DXML_UNICODE --without-xmlwf`<br/>
For UTF-16 output as `wchar_t` (incl. version/error strings), run:<br/>
- `./configure CFLAGS="-g -O2 -fshort-wchar" CPPFLAGS=-DXML_UNICODE_WCHAR_T`
+ `./configure CFLAGS="-g -O2 -fshort-wchar" CPPFLAGS=-DXML_UNICODE_WCHAR_T
+ --without-xmlwf`
<br/>Note: The latter requires libc compiled with `-fshort-wchar`, as well.
-1. Edit `Makefile`, changing:<br/>
- `LIBRARY = libexpat.la`<br/>
- to:<br/>
- `LIBRARY = libexpatw.la`<br/>
- (Note the additional "w" in the library name.)
-
-1. Run `make buildlib` (which builds the library only).
- Or, to save step 2, run `make buildlib LIBRARY=libexpatw.la`.
+1. Run `make` (which excludes xmlwf).
-1. Run `make installlib` (which installs the library only).
- Or, if step 2 was omitted, run `make installlib LIBRARY=libexpatw.la`.
+1. Run `make install` (again, excludes xmlwf).
-Using `DESTDIR` or `INSTALL_ROOT` is enabled, with `INSTALL_ROOT` being the
-default value for `DESTDIR`, and the rest of the make file using only
-`DESTDIR`. It works as follows:
+Using `DESTDIR` is supported. It works as follows:
```console
make install DESTDIR=/path/to/image
```
-overrides the in-makefile set `DESTDIR`, while both
+overrides the in-makefile set `DESTDIR`, because variable-setting priority is
-```console
-INSTALL_ROOT=/path/to/image make install
-make install INSTALL_ROOT=/path/to/image
-```
-
-use `DESTDIR=$(INSTALL_ROOT)`, even if `DESTDIR` eventually is defined in the
-environment, because variable-setting priority is
1. commandline
-2. in-makefile
-3. environment
+1. in-makefile
+1. environment
Note: This only applies to the Expat library itself, building UTF-16 versions
of xmlwf and the tests is currently not supported.
@@ -124,3 +130,59 @@ information.
A reference manual is available in the file `doc/reference.html` in this
distribution.
+
+
+The CMake build system is still *experimental* and will replace the primary
+build system based on GNU Autotools at some point when it is ready.
+For an idea of the available (non-advanced) options for building with CMake:
+
+```console
+# rm -f CMakeCache.txt ; cmake -D_EXPAT_HELP=ON -LH . | grep -B1 ':.*=' | sed 's,^--$,,'
+// Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ...
+CMAKE_BUILD_TYPE:STRING=
+
+// Install path prefix, prepended onto install directories.
+CMAKE_INSTALL_PREFIX:PATH=/usr/local
+
+// Path to a program.
+DOCBOOK_TO_MAN:FILEPATH=/usr/bin/docbook2x-man
+
+// build man page for xmlwf
+EXPAT_BUILD_DOCS:BOOL=ON
+
+// build the examples for expat library
+EXPAT_BUILD_EXAMPLES:BOOL=ON
+
+// build fuzzers for the expat library
+EXPAT_BUILD_FUZZERS:BOOL=OFF
+
+// build the tests for expat library
+EXPAT_BUILD_TESTS:BOOL=ON
+
+// build the xmlwf tool for expat library
+EXPAT_BUILD_TOOLS:BOOL=ON
+
+// Character type to use (char|ushort|wchar_t) [default=char]
+EXPAT_CHAR_TYPE:STRING=char
+
+// install expat files in cmake install target
+EXPAT_ENABLE_INSTALL:BOOL=ON
+
+// Use /MT flag (static CRT) when compiling in MSVC
+EXPAT_MSVC_STATIC_CRT:BOOL=OFF
+
+// build a shared expat library
+EXPAT_SHARED_LIBS:BOOL=ON
+
+// Treat all compiler warnings as errors
+EXPAT_WARNINGS_AS_ERRORS:BOOL=OFF
+
+// Make use of getrandom function (ON|OFF|AUTO) [default=AUTO]
+EXPAT_WITH_GETRANDOM:STRING=AUTO
+
+// utilize libbsd (for arc4random_buf)
+EXPAT_WITH_LIBBSD:BOOL=OFF
+
+// Make use of syscall SYS_getrandom (ON|OFF|AUTO) [default=AUTO]
+EXPAT_WITH_SYS_GETRANDOM:STRING=AUTO
+```
diff --git a/Utilities/cmexpat/expat_config.h.cmake b/Utilities/cmexpat/expat_config.h.cmake
index ad540d604..795b6078c 100644
--- a/Utilities/cmexpat/expat_config.h.cmake
+++ b/Utilities/cmexpat/expat_config.h.cmake
@@ -1,10 +1,13 @@
-/* expat_config.h.in. Generated from configure.in by autoheader. */
+/* expat_config.h.cmake. Based upon generated expat_config.h.in. */
/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
#cmakedefine BYTEORDER @BYTEORDER@
-/* Define to 1 if you have the `bcopy' function. */
-#cmakedefine HAVE_BCOPY
+/* Define to 1 if you have the `arc4random' function. */
+#cmakedefine HAVE_ARC4RANDOM
+
+/* Define to 1 if you have the `arc4random_buf' function. */
+#cmakedefine HAVE_ARC4RANDOM_BUF
/* Define to 1 if you have the <dlfcn.h> header file. */
#cmakedefine HAVE_DLFCN_H
@@ -15,11 +18,14 @@
/* Define to 1 if you have the `getpagesize' function. */
#cmakedefine HAVE_GETPAGESIZE
+/* Define to 1 if you have the `getrandom' function. */
+#cmakedefine HAVE_GETRANDOM
+
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H
-/* Define to 1 if you have the `memmove' function. */
-#cmakedefine HAVE_MEMMOVE
+/* Define to 1 if you have the `bsd' library (-lbsd). */
+#cmakedefine HAVE_LIBBSD
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H
@@ -39,6 +45,9 @@
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H
+/* Define to 1 if you have `syscall' and `SYS_getrandom'. */
+#cmakedefine HAVE_SYSCALL_GETRANDOM
+
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H
@@ -54,10 +63,19 @@
/* whether byteorder is bigendian */
#cmakedefine WORDS_BIGENDIAN
+/* Define to allow retrieving the byte offsets for attribute names and values.
+ */
+#cmakedefine XML_ATTR_INFO
+
/* Define to specify how much context to retain around the current parse
point. */
#define XML_CONTEXT_BYTES 1024
+#if ! defined(_WIN32)
+/* Define to include code reading entropy from `/dev/urandom'. */
+ #cmakedefine XML_DEV_URANDOM
+#endif
+
/* Define to make parameter entity parsing functionality available. */
/* #undef XML_DTD */
@@ -66,7 +84,7 @@
/* Define to __FUNCTION__ or "" if `__func__' does not conform to ANSI C. */
#ifdef _MSC_VER
-# define __func__ __FUNCTION__
+# define __func__ __FUNCTION__
#endif
/* Define to `long' if <sys/types.h> does not define. */
diff --git a/Utilities/cmexpat/lib/ascii.h b/Utilities/cmexpat/lib/ascii.h
index d10530b09..c3587e573 100644
--- a/Utilities/cmexpat/lib/ascii.h
+++ b/Utilities/cmexpat/lib/ascii.h
@@ -1,5 +1,33 @@
-/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
+/*
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define ASCII_A 0x41
diff --git a/Utilities/cmexpat/lib/asciitab.h b/Utilities/cmexpat/lib/asciitab.h
index 79a15c28c..63b1d1b44 100644
--- a/Utilities/cmexpat/lib/asciitab.h
+++ b/Utilities/cmexpat/lib/asciitab.h
@@ -1,36 +1,64 @@
-/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
+/*
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
-/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
-/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
-/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
-/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
-/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
-/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
-/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
-/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
-/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
-/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
-/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
-/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
-/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
-/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
-/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
-/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
-/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+ /* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
+ /* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
+ /* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+ /* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+ /* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+ /* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+ /* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
+ /* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
+ /* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
+ /* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
+ /* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
+ /* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
+ /* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
+ /* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
+ /* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
+ /* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
+ /* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
+ /* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
+ /* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
+ /* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
+ /* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
+ /* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
diff --git a/Utilities/cmexpat/lib/expat.h b/Utilities/cmexpat/lib/expat.h
index 7e5bbb7e3..48a6e2a32 100644
--- a/Utilities/cmexpat/lib/expat.h
+++ b/Utilities/cmexpat/lib/expat.h
@@ -1,19 +1,38 @@
-/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
+/*
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef Expat_INCLUDED
#define Expat_INCLUDED 1
-#ifdef __VMS
-/* 0 1 2 3 0 1 2 3
- 1234567890123456789012345678901 1234567890123456789012345678901 */
-#define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler
-#define XML_SetUnparsedEntityDeclHandler XML_SetUnparsedEntDeclHandler
-#define XML_SetStartNamespaceDeclHandler XML_SetStartNamespcDeclHandler
-#define XML_SetExternalEntityRefHandlerArg XML_SetExternalEntRefHandlerArg
-#endif
-
#include <stdlib.h>
#include "expat_external.h"
@@ -25,8 +44,8 @@ struct XML_ParserStruct;
typedef struct XML_ParserStruct *XML_Parser;
typedef unsigned char XML_Bool;
-#define XML_TRUE ((XML_Bool) 1)
-#define XML_FALSE ((XML_Bool) 0)
+#define XML_TRUE ((XML_Bool)1)
+#define XML_FALSE ((XML_Bool)0)
/* The XML_Status enum gives the possible return values for several
API functions. The preprocessor #defines are included so this
@@ -136,25 +155,23 @@ enum XML_Content_Quant {
typedef struct XML_cp XML_Content;
struct XML_cp {
- enum XML_Content_Type type;
- enum XML_Content_Quant quant;
- XML_Char * name;
- unsigned int numchildren;
- XML_Content * children;
+ enum XML_Content_Type type;
+ enum XML_Content_Quant quant;
+ XML_Char *name;
+ unsigned int numchildren;
+ XML_Content *children;
};
-
/* This is called for an element declaration. See above for
description of the model argument. It's the caller's responsibility
to free model when finished with it.
*/
-typedef void (XMLCALL *XML_ElementDeclHandler) (void *userData,
- const XML_Char *name,
- XML_Content *model);
+typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData,
+ const XML_Char *name,
+ XML_Content *model);
XMLPARSEAPI(void)
-XML_SetElementDeclHandler(XML_Parser parser,
- XML_ElementDeclHandler eldecl);
+XML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl);
/* The Attlist declaration handler is called for *each* attribute. So
a single Attlist declaration with multiple attributes declared will
@@ -164,17 +181,12 @@ XML_SetElementDeclHandler(XML_Parser parser,
value will be NULL in the case of "#REQUIRED". If "isrequired" is
true and default is non-NULL, then this is a "#FIXED" default.
*/
-typedef void (XMLCALL *XML_AttlistDeclHandler) (
- void *userData,
- const XML_Char *elname,
- const XML_Char *attname,
- const XML_Char *att_type,
- const XML_Char *dflt,
- int isrequired);
+typedef void(XMLCALL *XML_AttlistDeclHandler)(
+ void *userData, const XML_Char *elname, const XML_Char *attname,
+ const XML_Char *att_type, const XML_Char *dflt, int isrequired);
XMLPARSEAPI(void)
-XML_SetAttlistDeclHandler(XML_Parser parser,
- XML_AttlistDeclHandler attdecl);
+XML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl);
/* The XML declaration handler is called for *both* XML declarations
and text declarations. The way to distinguish is that the version
@@ -184,15 +196,13 @@ XML_SetAttlistDeclHandler(XML_Parser parser,
was no standalone parameter in the declaration, that it was given
as no, or that it was given as yes.
*/
-typedef void (XMLCALL *XML_XmlDeclHandler) (void *userData,
- const XML_Char *version,
- const XML_Char *encoding,
- int standalone);
+typedef void(XMLCALL *XML_XmlDeclHandler)(void *userData,
+ const XML_Char *version,
+ const XML_Char *encoding,
+ int standalone);
XMLPARSEAPI(void)
-XML_SetXmlDeclHandler(XML_Parser parser,
- XML_XmlDeclHandler xmldecl);
-
+XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler xmldecl);
typedef struct {
void *(*malloc_fcn)(size_t size);
@@ -220,7 +230,6 @@ XML_ParserCreate(const XML_Char *encoding);
XMLPARSEAPI(XML_Parser)
XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
-
/* Constructs a new parser using the memory management suite referred to
by memsuite. If memsuite is NULL, then use the standard library memory
suite. If namespaceSeparator is non-NULL it creates a parser with
@@ -236,7 +245,7 @@ XML_ParserCreate_MM(const XML_Char *encoding,
const XML_Char *namespaceSeparator);
/* Prepare a parser object to be re-used. This is particularly
- valuable when memory allocation overhead is disproportionatly high,
+ valuable when memory allocation overhead is disproportionately high,
such as when a large number of small documnents need to be parsed.
All handlers are cleared from the parser, except for the
unknownEncodingHandler. The parser's external state is re-initialized
@@ -250,31 +259,27 @@ XML_ParserReset(XML_Parser parser, const XML_Char *encoding);
/* atts is array of name/value pairs, terminated by 0;
names and values are 0 terminated.
*/
-typedef void (XMLCALL *XML_StartElementHandler) (void *userData,
- const XML_Char *name,
- const XML_Char **atts);
-
-typedef void (XMLCALL *XML_EndElementHandler) (void *userData,
- const XML_Char *name);
+typedef void(XMLCALL *XML_StartElementHandler)(void *userData,
+ const XML_Char *name,
+ const XML_Char **atts);
+typedef void(XMLCALL *XML_EndElementHandler)(void *userData,
+ const XML_Char *name);
/* s is not 0 terminated. */
-typedef void (XMLCALL *XML_CharacterDataHandler) (void *userData,
- const XML_Char *s,
- int len);
+typedef void(XMLCALL *XML_CharacterDataHandler)(void *userData,
+ const XML_Char *s, int len);
/* target and data are 0 terminated */
-typedef void (XMLCALL *XML_ProcessingInstructionHandler) (
- void *userData,
- const XML_Char *target,
- const XML_Char *data);
+typedef void(XMLCALL *XML_ProcessingInstructionHandler)(void *userData,
+ const XML_Char *target,
+ const XML_Char *data);
/* data is 0 terminated */
-typedef void (XMLCALL *XML_CommentHandler) (void *userData,
- const XML_Char *data);
+typedef void(XMLCALL *XML_CommentHandler)(void *userData, const XML_Char *data);
-typedef void (XMLCALL *XML_StartCdataSectionHandler) (void *userData);
-typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData);
+typedef void(XMLCALL *XML_StartCdataSectionHandler)(void *userData);
+typedef void(XMLCALL *XML_EndCdataSectionHandler)(void *userData);
/* This is called for any characters in the XML document for which
there is no applicable handler. This includes both characters that
@@ -289,25 +294,23 @@ typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData);
default handler: for example, a comment might be split between
multiple calls.
*/
-typedef void (XMLCALL *XML_DefaultHandler) (void *userData,
- const XML_Char *s,
- int len);
+typedef void(XMLCALL *XML_DefaultHandler)(void *userData, const XML_Char *s,
+ int len);
/* This is called for the start of the DOCTYPE declaration, before
any DTD or internal subset is parsed.
*/
-typedef void (XMLCALL *XML_StartDoctypeDeclHandler) (
- void *userData,
- const XML_Char *doctypeName,
- const XML_Char *sysid,
- const XML_Char *pubid,
- int has_internal_subset);
+typedef void(XMLCALL *XML_StartDoctypeDeclHandler)(void *userData,
+ const XML_Char *doctypeName,
+ const XML_Char *sysid,
+ const XML_Char *pubid,
+ int has_internal_subset);
/* This is called for the start of the DOCTYPE declaration when the
closing > is encountered, but after processing any external
subset.
*/
-typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
+typedef void(XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
/* This is called for entity declarations. The is_parameter_entity
argument will be non-zero if the entity is a parameter entity, zero
@@ -327,20 +330,14 @@ typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
Note that is_parameter_entity can't be changed to XML_Bool, since
that would break binary compatibility.
*/
-typedef void (XMLCALL *XML_EntityDeclHandler) (
- void *userData,
- const XML_Char *entityName,
- int is_parameter_entity,
- const XML_Char *value,
- int value_length,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId,
- const XML_Char *notationName);
+typedef void(XMLCALL *XML_EntityDeclHandler)(
+ void *userData, const XML_Char *entityName, int is_parameter_entity,
+ const XML_Char *value, int value_length, const XML_Char *base,
+ const XML_Char *systemId, const XML_Char *publicId,
+ const XML_Char *notationName);
XMLPARSEAPI(void)
-XML_SetEntityDeclHandler(XML_Parser parser,
- XML_EntityDeclHandler handler);
+XML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler);
/* OBSOLETE -- OBSOLETE -- OBSOLETE
This handler has been superseded by the EntityDeclHandler above.
@@ -351,24 +348,20 @@ XML_SetEntityDeclHandler(XML_Parser parser,
entityName, systemId and notationName arguments will never be
NULL. The other arguments may be.
*/
-typedef void (XMLCALL *XML_UnparsedEntityDeclHandler) (
- void *userData,
- const XML_Char *entityName,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId,
- const XML_Char *notationName);
+typedef void(XMLCALL *XML_UnparsedEntityDeclHandler)(
+ void *userData, const XML_Char *entityName, const XML_Char *base,
+ const XML_Char *systemId, const XML_Char *publicId,
+ const XML_Char *notationName);
/* This is called for a declaration of notation. The base argument is
whatever was set by XML_SetBase. The notationName will never be
NULL. The other arguments can be.
*/
-typedef void (XMLCALL *XML_NotationDeclHandler) (
- void *userData,
- const XML_Char *notationName,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId);
+typedef void(XMLCALL *XML_NotationDeclHandler)(void *userData,
+ const XML_Char *notationName,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId);
/* When namespace processing is enabled, these are called once for
each namespace declaration. The call to the start and end element
@@ -376,14 +369,12 @@ typedef void (XMLCALL *XML_NotationDeclHandler) (
declaration handlers. For an xmlns attribute, prefix will be
NULL. For an xmlns="" attribute, uri will be NULL.
*/
-typedef void (XMLCALL *XML_StartNamespaceDeclHandler) (
- void *userData,
- const XML_Char *prefix,
- const XML_Char *uri);
+typedef void(XMLCALL *XML_StartNamespaceDeclHandler)(void *userData,
+ const XML_Char *prefix,
+ const XML_Char *uri);
-typedef void (XMLCALL *XML_EndNamespaceDeclHandler) (
- void *userData,
- const XML_Char *prefix);
+typedef void(XMLCALL *XML_EndNamespaceDeclHandler)(void *userData,
+ const XML_Char *prefix);
/* This is called if the document is not standalone, that is, it has an
external subset or a reference to a parameter entity, but does not
@@ -394,7 +385,7 @@ typedef void (XMLCALL *XML_EndNamespaceDeclHandler) (
conditions above this handler will only be called if the referenced
entity was actually read.
*/
-typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData);
+typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData);
/* This is called for a reference to an external parsed general
entity. The referenced entity is not automatically parsed. The
@@ -430,12 +421,11 @@ typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData);
Note that unlike other handlers the first argument is the parser,
not userData.
*/
-typedef int (XMLCALL *XML_ExternalEntityRefHandler) (
- XML_Parser parser,
- const XML_Char *context,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId);
+typedef int(XMLCALL *XML_ExternalEntityRefHandler)(XML_Parser parser,
+ const XML_Char *context,
+ const XML_Char *base,
+ const XML_Char *systemId,
+ const XML_Char *publicId);
/* This is called in two situations:
1) An entity reference is encountered for which no declaration
@@ -447,10 +437,9 @@ typedef int (XMLCALL *XML_ExternalEntityRefHandler) (
the event would be out of sync with the reporting of the
declarations or attribute values
*/
-typedef void (XMLCALL *XML_SkippedEntityHandler) (
- void *userData,
- const XML_Char *entityName,
- int is_parameter_entity);
+typedef void(XMLCALL *XML_SkippedEntityHandler)(void *userData,
+ const XML_Char *entityName,
+ int is_parameter_entity);
/* This structure is filled in by the XML_UnknownEncodingHandler to
provide information to the parser about encodings that are unknown
@@ -507,8 +496,8 @@ typedef void (XMLCALL *XML_SkippedEntityHandler) (
typedef struct {
int map[256];
void *data;
- int (XMLCALL *convert)(void *data, const char *s);
- void (XMLCALL *release)(void *data);
+ int(XMLCALL *convert)(void *data, const char *s);
+ void(XMLCALL *release)(void *data);
} XML_Encoding;
/* This is called for an encoding that is unknown to the parser.
@@ -526,23 +515,19 @@ typedef struct {
If info does not describe a suitable encoding, then the parser will
return an XML_UNKNOWN_ENCODING error.
*/
-typedef int (XMLCALL *XML_UnknownEncodingHandler) (
- void *encodingHandlerData,
- const XML_Char *name,
- XML_Encoding *info);
+typedef int(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData,
+ const XML_Char *name,
+ XML_Encoding *info);
XMLPARSEAPI(void)
-XML_SetElementHandler(XML_Parser parser,
- XML_StartElementHandler start,
+XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start,
XML_EndElementHandler end);
XMLPARSEAPI(void)
-XML_SetStartElementHandler(XML_Parser parser,
- XML_StartElementHandler handler);
+XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler handler);
XMLPARSEAPI(void)
-XML_SetEndElementHandler(XML_Parser parser,
- XML_EndElementHandler handler);
+XML_SetEndElementHandler(XML_Parser parser, XML_EndElementHandler handler);
XMLPARSEAPI(void)
XML_SetCharacterDataHandler(XML_Parser parser,
@@ -552,8 +537,7 @@ XMLPARSEAPI(void)
XML_SetProcessingInstructionHandler(XML_Parser parser,
XML_ProcessingInstructionHandler handler);
XMLPARSEAPI(void)
-XML_SetCommentHandler(XML_Parser parser,
- XML_CommentHandler handler);
+XML_SetCommentHandler(XML_Parser parser, XML_CommentHandler handler);
XMLPARSEAPI(void)
XML_SetCdataSectionHandler(XML_Parser parser,
@@ -573,20 +557,17 @@ XML_SetEndCdataSectionHandler(XML_Parser parser,
default handler, or to the skipped entity handler, if one is set.
*/
XMLPARSEAPI(void)
-XML_SetDefaultHandler(XML_Parser parser,
- XML_DefaultHandler handler);
+XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler handler);
/* This sets the default handler but does not inhibit expansion of
internal entities. The entity reference will not be passed to the
default handler.
*/
XMLPARSEAPI(void)
-XML_SetDefaultHandlerExpand(XML_Parser parser,
- XML_DefaultHandler handler);
+XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler);
XMLPARSEAPI(void)
-XML_SetDoctypeDeclHandler(XML_Parser parser,
- XML_StartDoctypeDeclHandler start,
+XML_SetDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start,
XML_EndDoctypeDeclHandler end);
XMLPARSEAPI(void)
@@ -594,16 +575,14 @@ XML_SetStartDoctypeDeclHandler(XML_Parser parser,
XML_StartDoctypeDeclHandler start);
XMLPARSEAPI(void)
-XML_SetEndDoctypeDeclHandler(XML_Parser parser,
- XML_EndDoctypeDeclHandler end);
+XML_SetEndDoctypeDeclHandler(XML_Parser parser, XML_EndDoctypeDeclHandler end);
XMLPARSEAPI(void)
XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
XML_UnparsedEntityDeclHandler handler);
XMLPARSEAPI(void)
-XML_SetNotationDeclHandler(XML_Parser parser,
- XML_NotationDeclHandler handler);
+XML_SetNotationDeclHandler(XML_Parser parser, XML_NotationDeclHandler handler);
XMLPARSEAPI(void)
XML_SetNamespaceDeclHandler(XML_Parser parser,
@@ -631,8 +610,7 @@ XML_SetExternalEntityRefHandler(XML_Parser parser,
instead of the parser object.
*/
XMLPARSEAPI(void)
-XML_SetExternalEntityRefHandlerArg(XML_Parser parser,
- void *arg);
+XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg);
XMLPARSEAPI(void)
XML_SetSkippedEntityHandler(XML_Parser parser,
@@ -712,7 +690,6 @@ XML_UseParserAsHandlerArg(XML_Parser parser);
XMLPARSEAPI(enum XML_Error)
XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
-
/* Sets the base to be used for resolving relative URIs in system
identifiers in declarations. Resolving relative identifiers is
left to the application: this value will be passed through as the
@@ -752,10 +729,10 @@ XML_GetIdAttributeIndex(XML_Parser parser);
info->valueEnd - info->valueStart = 4 bytes.
*/
typedef struct {
- XML_Index nameStart; /* Offset to beginning of the attribute name. */
- XML_Index nameEnd; /* Offset after the attribute name's last byte. */
- XML_Index valueStart; /* Offset to beginning of the attribute value. */
- XML_Index valueEnd; /* Offset after the attribute value's last byte. */
+ XML_Index nameStart; /* Offset to beginning of the attribute name. */
+ XML_Index nameEnd; /* Offset after the attribute name's last byte. */
+ XML_Index valueStart; /* Offset to beginning of the attribute value. */
+ XML_Index valueEnd; /* Offset after the attribute value's last byte. */
} XML_AttrInfo;
/* Returns an array of XML_AttrInfo structures for the attribute/value pairs
@@ -791,20 +768,20 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
(resumable = 0) an already suspended parser. Some call-backs may
still follow because they would otherwise get lost. Examples:
- endElementHandler() for empty elements when stopped in
- startElementHandler(),
- - endNameSpaceDeclHandler() when stopped in endElementHandler(),
+ startElementHandler(),
+ - endNameSpaceDeclHandler() when stopped in endElementHandler(),
and possibly others.
Can be called from most handlers, including DTD related call-backs,
except when parsing an external parameter entity and resumable != 0.
Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise.
- Possible error codes:
+ Possible error codes:
- XML_ERROR_SUSPENDED: when suspending an already suspended parser.
- XML_ERROR_FINISHED: when the parser has already finished.
- XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE.
- When resumable != 0 (true) then parsing is suspended, that is,
- XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED.
+ When resumable != 0 (true) then parsing is suspended, that is,
+ XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED.
Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer()
return XML_STATUS_ERROR with error code XML_ERROR_ABORTED.
@@ -815,7 +792,7 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
the externalEntityRefHandler() to call XML_StopParser() on the parent
parser (recursively), if one wants to stop parsing altogether.
- When suspended, parsing can be resumed by calling XML_ResumeParser().
+ When suspended, parsing can be resumed by calling XML_ResumeParser().
*/
XMLPARSEAPI(enum XML_Status)
XML_StopParser(XML_Parser parser, XML_Bool resumable);
@@ -823,7 +800,7 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable);
/* Resumes parsing after it has been suspended with XML_StopParser().
Must not be called from within a handler call-back. Returns same
status codes as XML_Parse() or XML_ParseBuffer().
- Additional error code XML_ERROR_NOT_SUSPENDED possible.
+ Additional error code XML_ERROR_NOT_SUSPENDED possible.
*Note*:
This must be called on the most deeply nested child parser instance
@@ -835,12 +812,7 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable);
XMLPARSEAPI(enum XML_Status)
XML_ResumeParser(XML_Parser parser);
-enum XML_Parsing {
- XML_INITIALIZED,
- XML_PARSING,
- XML_FINISHED,
- XML_SUSPENDED
-};
+enum XML_Parsing { XML_INITIALIZED, XML_PARSING, XML_FINISHED, XML_SUSPENDED };
typedef struct {
enum XML_Parsing parsing;
@@ -872,8 +844,7 @@ XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status);
Otherwise returns a new XML_Parser object.
*/
XMLPARSEAPI(XML_Parser)
-XML_ExternalEntityParserCreate(XML_Parser parser,
- const XML_Char *context,
+XML_ExternalEntityParserCreate(XML_Parser parser, const XML_Char *context,
const XML_Char *encoding);
enum XML_ParamEntityParsing {
@@ -917,8 +888,7 @@ XML_SetParamEntityParsing(XML_Parser parser,
Note: If parser == NULL, the function will do nothing and return 0.
*/
XMLPARSEAPI(int)
-XML_SetHashSalt(XML_Parser parser,
- unsigned long hash_salt);
+XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt);
/* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
XML_GetErrorCode returns information about the error.
@@ -935,7 +905,7 @@ XML_GetErrorCode(XML_Parser parser);
be within the relevant markup. When called outside of the callback
functions, the position indicated will be just past the last parse
event (regardless of whether there was an associated callback).
-
+
They may also be called after returning from a call to XML_Parse
or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then
the location is the location of the character at which the error
@@ -967,14 +937,12 @@ XML_GetCurrentByteCount(XML_Parser parser);
the handler that makes the call.
*/
XMLPARSEAPI(const char *)
-XML_GetInputContext(XML_Parser parser,
- int *offset,
- int *size);
+XML_GetInputContext(XML_Parser parser, int *offset, int *size);
/* For backwards compatibility with previous versions. */
-#define XML_GetErrorLineNumber XML_GetCurrentLineNumber
+#define XML_GetErrorLineNumber XML_GetCurrentLineNumber
#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
-#define XML_GetErrorByteIndex XML_GetCurrentByteIndex
+#define XML_GetErrorByteIndex XML_GetCurrentByteIndex
/* Frees the content model passed to the element declaration handler */
XMLPARSEAPI(void)
@@ -1034,21 +1002,20 @@ enum XML_FeatureEnum {
};
typedef struct {
- enum XML_FeatureEnum feature;
- const XML_LChar *name;
- long int value;
+ enum XML_FeatureEnum feature;
+ const XML_LChar *name;
+ long int value;
} XML_Feature;
XMLPARSEAPI(const XML_Feature *)
XML_GetFeatureList(void);
-
/* Expat follows the semantic versioning convention.
See http://semver.org.
*/
#define XML_MAJOR_VERSION 2
#define XML_MINOR_VERSION 2
-#define XML_MICRO_VERSION 3
+#define XML_MICRO_VERSION 9
#ifdef __cplusplus
}
diff --git a/Utilities/cmexpat/lib/expat_external.h b/Utilities/cmexpat/lib/expat_external.h
index d60eeccfb..ec4783a9b 100644
--- a/Utilities/cmexpat/lib/expat_external.h
+++ b/Utilities/cmexpat/lib/expat_external.h
@@ -1,5 +1,33 @@
-/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
+/*
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef Expat_External_INCLUDED
@@ -7,10 +35,6 @@
/* External API definitions */
-#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
-#define XML_USE_MSC_EXTENSIONS 1
-#endif
-
/* Expat tries very hard to make the API boundary very specifically
defined. There are two macros defined to control this boundary;
each of these can be defined before including this header to
@@ -34,11 +58,11 @@
system headers may assume the cdecl convention.
*/
#ifndef XMLCALL
-#if defined(_MSC_VER)
-#define XMLCALL __cdecl
-#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
-#define XMLCALL __attribute__((cdecl))
-#else
+# if defined(_MSC_VER)
+# define XMLCALL __cdecl
+# elif defined(__GNUC__) && defined(__i386) && ! defined(__INTEL_COMPILER)
+# define XMLCALL __attribute__((cdecl))
+# else
/* For any platform which uses this definition and supports more than
one calling convention, we need to extend this definition to
declare the convention used on that platform, if it's possible to
@@ -49,43 +73,49 @@
pre-processor and how to specify the same calling convention as the
platform's malloc() implementation.
*/
-#define XMLCALL
-#endif
-#endif /* not defined XMLCALL */
+# define XMLCALL
+# endif
+#endif /* not defined XMLCALL */
/* Build within CMake hard-codes use of a static library. */
#define XML_STATIC
-#if !defined(XML_STATIC) && !defined(XMLIMPORT)
-#ifndef XML_BUILDING_EXPAT
+#if ! defined(XML_STATIC) && ! defined(XMLIMPORT)
+# ifndef XML_BUILDING_EXPAT
/* using Expat from an application */
-#ifdef XML_USE_MSC_EXTENSIONS
-#define XMLIMPORT __declspec(dllimport)
-#endif
+# if defined(_MSC_EXTENSIONS) && ! defined(__BEOS__) && ! defined(__CYGWIN__)
+# define XMLIMPORT __declspec(dllimport)
+# endif
+# endif
+#endif /* not defined XML_STATIC */
+
+#ifndef XML_ENABLE_VISIBILITY
+# define XML_ENABLE_VISIBILITY 0
#endif
-#endif /* not defined XML_STATIC */
-#if !defined(XMLIMPORT) && defined(__GNUC__) && (__GNUC__ >= 4)
-#define XMLIMPORT __attribute__ ((visibility ("default")))
+#if ! defined(XMLIMPORT) && XML_ENABLE_VISIBILITY
+# define XMLIMPORT __attribute__((visibility("default")))
#endif
/* If we didn't define it above, define it away: */
#ifndef XMLIMPORT
-#define XMLIMPORT
+# define XMLIMPORT
#endif
-#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
-#define XML_ATTR_MALLOC __attribute__((__malloc__))
+#if defined(__GNUC__) \
+ && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
+# define XML_ATTR_MALLOC __attribute__((__malloc__))
#else
-#define XML_ATTR_MALLOC
+# define XML_ATTR_MALLOC
#endif
-#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-#define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
+#if defined(__GNUC__) \
+ && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
+# define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
#else
-#define XML_ATTR_ALLOC_SIZE(x)
+# define XML_ATTR_ALLOC_SIZE(x)
#endif
#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
@@ -95,33 +125,30 @@ extern "C" {
#endif
#ifdef XML_UNICODE_WCHAR_T
-# define XML_UNICODE
-# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
-# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
-# endif
+# ifndef XML_UNICODE
+# define XML_UNICODE
+# endif
+# if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
+# error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
+# endif
#endif
-#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
-#ifdef XML_UNICODE_WCHAR_T
+#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
+# ifdef XML_UNICODE_WCHAR_T
typedef wchar_t XML_Char;
typedef wchar_t XML_LChar;
-#else
+# else
typedef unsigned short XML_Char;
typedef char XML_LChar;
-#endif /* XML_UNICODE_WCHAR_T */
-#else /* Information is UTF-8 encoded. */
+# endif /* XML_UNICODE_WCHAR_T */
+#else /* Information is UTF-8 encoded. */
typedef char XML_Char;
typedef char XML_LChar;
-#endif /* XML_UNICODE */
+#endif /* XML_UNICODE */
-#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
-#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
-typedef __int64 XML_Index;
-typedef unsigned __int64 XML_Size;
-#else
+#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
typedef long long XML_Index;
typedef unsigned long long XML_Size;
-#endif
#else
typedef long XML_Index;
typedef unsigned long XML_Size;
diff --git a/Utilities/cmexpat/lib/iasciitab.h b/Utilities/cmexpat/lib/iasciitab.h
index 24a1d5ccc..ea97cfcf6 100644
--- a/Utilities/cmexpat/lib/iasciitab.h
+++ b/Utilities/cmexpat/lib/iasciitab.h
@@ -1,37 +1,65 @@
-/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
+/*
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
-/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
-/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
-/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
-/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
-/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
-/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
-/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
-/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
-/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
-/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
-/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
-/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
-/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
-/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
-/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
-/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
-/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+ /* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
+ /* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
+ /* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+ /* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+ /* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+ /* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+ /* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
+ /* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
+ /* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
+ /* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
+ /* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
+ /* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
+ /* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
+ /* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
+ /* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
+ /* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
+ /* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
+ /* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
+ /* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
+ /* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
+ /* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
+ /* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
diff --git a/Utilities/cmexpat/lib/internal.h b/Utilities/cmexpat/lib/internal.h
index 94cb98e15..60913dab7 100644
--- a/Utilities/cmexpat/lib/internal.h
+++ b/Utilities/cmexpat/lib/internal.h
@@ -18,9 +18,38 @@
Note: Use of these macros is based on judgement, not hard rules,
and therefore subject to change.
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__)
+#if defined(__GNUC__) && defined(__i386__) && ! defined(__MINGW32__)
/* We'll use this version by default only where we know it helps.
regparm() generates warnings on Solaris boxes. See SF bug #692878.
@@ -30,8 +59,8 @@
#define FASTCALL __attribute__((stdcall, regparm(3)))
and let's try this:
*/
-#define FASTCALL __attribute__((regparm(3)))
-#define PTRFASTCALL __attribute__((regparm(3)))
+# define FASTCALL __attribute__((regparm(3)))
+# define PTRFASTCALL __attribute__((regparm(3)))
#endif
/* Using __fastcall seems to have an unexpected negative effect under
@@ -45,50 +74,49 @@
/* Make sure all of these are defined if they aren't already. */
#ifndef FASTCALL
-#define FASTCALL
+# define FASTCALL
#endif
#ifndef PTRCALL
-#define PTRCALL
+# define PTRCALL
#endif
#ifndef PTRFASTCALL
-#define PTRFASTCALL
+# define PTRFASTCALL
#endif
#ifndef XML_MIN_SIZE
-#if !defined(__cplusplus) && !defined(inline)
-#ifdef __GNUC__
-#define inline __inline
-#endif /* __GNUC__ */
-#endif
+# if ! defined(__cplusplus) && ! defined(inline)
+# ifdef __GNUC__
+# define inline __inline
+# endif /* __GNUC__ */
+# endif
#endif /* XML_MIN_SIZE */
#ifdef __cplusplus
-#define inline inline
+# define inline inline
#else
-#ifndef inline
-#define inline
-#endif
+# ifndef inline
+# define inline
+# endif
#endif
#ifndef UNUSED_P
-# ifdef __GNUC__
-# define UNUSED_P(p) UNUSED_ ## p __attribute__((__unused__))
-# else
-# define UNUSED_P(p) UNUSED_ ## p
-# endif
+# define UNUSED_P(p) (void)p
#endif
-
#ifdef __cplusplus
extern "C" {
#endif
-
+#ifdef XML_ENABLE_VISIBILITY
+# if XML_ENABLE_VISIBILITY
+__attribute__((visibility("default")))
+# endif
+#endif
void
-align_limit_to_full_utf8_characters(const char * from, const char ** fromLimRef);
-
+_INTERNAL_trim_to_complete_utf8_characters(const char *from,
+ const char **fromLimRef);
#ifdef __cplusplus
}
diff --git a/Utilities/cmexpat/lib/latin1tab.h b/Utilities/cmexpat/lib/latin1tab.h
index 53c25d76b..6f9160413 100644
--- a/Utilities/cmexpat/lib/latin1tab.h
+++ b/Utilities/cmexpat/lib/latin1tab.h
@@ -1,36 +1,64 @@
-/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
+/*
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
-/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
-/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
-/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
-/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
-/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
+ /* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
+ /* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
+ /* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
+ /* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
+ /* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
+ /* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
+ /* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
diff --git a/Utilities/cmexpat/lib/loadlibrary.c b/Utilities/cmexpat/lib/loadlibrary.c
deleted file mode 100644
index ffce86839..000000000
--- a/Utilities/cmexpat/lib/loadlibrary.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) 2016 - 2017, Steve Holme, <steve_holme@hotmail.com>.
- *
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
- * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
- * THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of a copyright holder shall
- * not be used in advertising or otherwise to promote the sale, use or other
- * dealings in this Software without prior written authorization of the
- * copyright holder.
- *
- ***************************************************************************/
-
-#if defined(_WIN32)
-
-#include <windows.h>
-#include <tchar.h>
-
-
-HMODULE _Expat_LoadLibrary(LPCTSTR filename);
-
-
-#if !defined(LOAD_WITH_ALTERED_SEARCH_PATH)
-#define LOAD_WITH_ALTERED_SEARCH_PATH 0x00000008
-#endif
-
-#if !defined(LOAD_LIBRARY_SEARCH_SYSTEM32)
-#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
-#endif
-
-/* We use our own typedef here since some headers might lack these */
-typedef HMODULE (APIENTRY *LOADLIBRARYEX_FN)(LPCTSTR, HANDLE, DWORD);
-
-/* See function definitions in winbase.h */
-#ifdef UNICODE
-# ifdef _WIN32_WCE
-# define LOADLIBARYEX L"LoadLibraryExW"
-# else
-# define LOADLIBARYEX "LoadLibraryExW"
-# endif
-#else
-# define LOADLIBARYEX "LoadLibraryExA"
-#endif
-
-
-/*
- * _Expat_LoadLibrary()
- *
- * This is used to dynamically load DLLs using the most secure method available
- * for the version of Windows that we are running on.
- *
- * Parameters:
- *
- * filename [in] - The filename or full path of the DLL to load. If only the
- * filename is passed then the DLL will be loaded from the
- * Windows system directory.
- *
- * Returns the handle of the module on success; otherwise NULL.
- */
-HMODULE _Expat_LoadLibrary(LPCTSTR filename)
-{
- HMODULE hModule = NULL;
- LOADLIBRARYEX_FN pLoadLibraryEx = NULL;
-
- /* Get a handle to kernel32 so we can access it's functions at runtime */
- HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32"));
- if(!hKernel32)
- return NULL;
-
- /* Attempt to find LoadLibraryEx() which is only available on Windows 2000
- and above */
- pLoadLibraryEx = (LOADLIBRARYEX_FN) GetProcAddress(hKernel32, LOADLIBARYEX);
-
- /* Detect if there's already a path in the filename and load the library if
- there is. Note: Both back slashes and forward slashes have been supported
- since the earlier days of DOS at an API level although they are not
- supported by command prompt */
- if(_tcspbrk(filename, TEXT("\\/"))) {
- /** !checksrc! disable BANNEDFUNC 1 **/
- hModule = pLoadLibraryEx ?
- pLoadLibraryEx(filename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) :
- LoadLibrary(filename);
- }
- /* Detect if KB2533623 is installed, as LOAD_LIBARY_SEARCH_SYSTEM32 is only
- supported on Windows Vista, Windows Server 2008, Windows 7 and Windows
- Server 2008 R2 with this patch or natively on Windows 8 and above */
- else if(pLoadLibraryEx && GetProcAddress(hKernel32, "AddDllDirectory")) {
- /* Load the DLL from the Windows system directory */
- hModule = pLoadLibraryEx(filename, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
- }
- else {
- /* Attempt to get the Windows system path */
- UINT systemdirlen = GetSystemDirectory(NULL, 0);
- if(systemdirlen) {
- /* Allocate space for the full DLL path (Room for the null terminator
- is included in systemdirlen) */
- size_t filenamelen = _tcslen(filename);
- TCHAR *path = malloc(sizeof(TCHAR) * (systemdirlen + 1 + filenamelen));
- if(path && GetSystemDirectory(path, systemdirlen)) {
- /* Calculate the full DLL path */
- _tcscpy(path + _tcslen(path), TEXT("\\"));
- _tcscpy(path + _tcslen(path), filename);
-
- /* Load the DLL from the Windows system directory */
- /** !checksrc! disable BANNEDFUNC 1 **/
- hModule = pLoadLibraryEx ?
- pLoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) :
- LoadLibrary(path);
-
- }
- free(path);
- }
- }
-
- return hModule;
-}
-
-#else /* defined(_WIN32) */
-
-/* ISO C requires a translation unit to contain at least one declaration
- [-Wempty-translation-unit] */
-typedef int _TRANSLATION_UNIT_LOAD_LIBRARY_C_NOT_EMTPY;
-
-#endif /* defined(_WIN32) */
diff --git a/Utilities/cmexpat/lib/nametab.h b/Utilities/cmexpat/lib/nametab.h
index b05e62c77..3681df348 100644
--- a/Utilities/cmexpat/lib/nametab.h
+++ b/Utilities/cmexpat/lib/nametab.h
@@ -1,150 +1,136 @@
+/*
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
static const unsigned namingBitmap[] = {
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
-0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
-0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
-0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
-0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
-0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
-0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
-0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
-0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
-0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
-0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
-0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF,
-0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
-0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
-0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
-0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
-0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
-0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
-0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
-0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
-0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
-0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
-0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
-0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
-0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
-0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
-0x40000000, 0xF580C900, 0x00000007, 0x02010800,
-0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
-0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
-0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
-0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
-0x00000000, 0x00004C40, 0x00000000, 0x00000000,
-0x00000007, 0x00000000, 0x00000000, 0x00000000,
-0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
-0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
-0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
-0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
-0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
-0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
-0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
-0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
-0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
-0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
-0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
-0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
-0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
-0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
-0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
-0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
-0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
-0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
-0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
-0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
-0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
-0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
-0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
-0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
-0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
-0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
-0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
-0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
-0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
-0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
-0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
-0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x04000000,
+ 0x87FFFFFE, 0x07FFFFFE, 0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
+ 0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+ 0xFFFFE00F, 0xFC31FFFF, 0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
+ 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, 0xFFFF0003, 0xFFFFFFFF,
+ 0xFFFF199F, 0x033FCFFF, 0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
+ 0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF, 0x00000000, 0x07FFFFFE,
+ 0x000007FE, 0xFFFE0000, 0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
+ 0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003, 0xFFF99FE0, 0x03C5FDFF,
+ 0xB0000000, 0x00030003, 0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
+ 0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001, 0xFFF99FE0, 0x23CDFDFF,
+ 0xB0000000, 0x00000003, 0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
+ 0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003, 0xFFFDDFE0, 0x03EFFDFF,
+ 0x40000000, 0x00000003, 0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFE, 0x000D7FFF,
+ 0x0000003F, 0x00000000, 0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
+ 0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF, 0x0007DAED, 0x50000000,
+ 0x82315001, 0x002C62AB, 0x40000000, 0xF580C900, 0x00000007, 0x02010800,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0FFFFFFF, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0x03FFFFFF, 0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
+ 0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF, 0x00000000, 0x00004C40,
+ 0x00000000, 0x00000000, 0x00000007, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF, 0x001FFFFF, 0xFFFFFFFE,
+ 0xFFFFFFFF, 0x07FFFFFF, 0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000000F,
+ 0x00000000, 0x00000000, 0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
+ 0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF, 0x00FFFFFF, 0x00000000,
+ 0xFFFF0000, 0xFFFFFFFF, 0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
+ 0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003, 0xFFFFD7C0, 0xFFFFFFFB,
+ 0x547F7FFF, 0x000FFFFD, 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
+ 0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, 0x00000000, 0xFFFE0000,
+ 0x027FFFFF, 0xFFFFFFFE, 0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
+ 0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF, 0xFFFFFFFF, 0x7CFFFFFF,
+ 0xFFEF7FFF, 0x03FF3DFF, 0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
+ 0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF, 0xFFF987E4, 0xD36DFDFF,
+ 0x5E003987, 0x001FFFC0, 0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
+ 0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3, 0xD63DC7EC, 0xC3BFC718,
+ 0x00803DC7, 0x0000FF80, 0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
+ 0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3, 0xFFFDDFEC, 0xC3FFFDFF,
+ 0x00803DCF, 0x0000FFC3, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000, 0xFEF02596, 0x3BFF6CAE,
+ 0x03FF3F5F, 0x00000000, 0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
+ 0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
+ 0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF, 0x661FFFFF, 0xFFFFFFFE,
+ 0xFFFFFFFF, 0x77FFFFFF,
};
static const unsigned char nmstrtPages[] = {
-0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
-0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
-0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
-0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x09, 0x0A, 0x0B,
+ 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x00, 0x14, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
};
static const unsigned char namePages[] = {
-0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
-0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
-0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
-0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00, 0x00, 0x1F, 0x20, 0x21,
+ 0x22, 0x23, 0x24, 0x25, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x26, 0x14, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
};
diff --git a/Utilities/cmexpat/lib/siphash.h b/Utilities/cmexpat/lib/siphash.h
index 1684b251d..95f78f832 100644
--- a/Utilities/cmexpat/lib/siphash.h
+++ b/Utilities/cmexpat/lib/siphash.h
@@ -11,6 +11,16 @@
* --------------------------------------------------------------------------
* HISTORY:
*
+ * 2019-08-03 (Sebastian Pipping)
+ * - Mark part of sip24_valid as to be excluded from clang-format
+ * - Re-format code using clang-format 9
+ *
+ * 2018-07-08 (Anton Maklakov)
+ * - Add "fall through" markers for GCC's -Wimplicit-fallthrough
+ *
+ * 2017-11-03 (Sebastian Pipping)
+ * - Hide sip_tobin and sip_binof unless SIPHASH_TOBIN macro is defined
+ *
* 2017-07-25 (Vadim Zeitlin)
* - Fix use of SIPHASH_MAIN macro
*
@@ -99,167 +109,178 @@
# define uint8_t KWIML_INT_uint8_t
#endif
-
/*
* Workaround to not require a C++11 compiler for using ULL suffix
* if this code is included and compiled as C++; related GCC warning is:
* warning: use of C++11 long long integer constant [-Wlong-long]
*/
-#define _SIP_ULL(high, low) (((uint64_t)high << 32) | low)
+#define _SIP_ULL(high, low) (((uint64_t)high << 32) | low)
+#define SIP_ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
-#define SIP_ROTL(x, b) (uint64_t)(((x) << (b)) | ( (x) >> (64 - (b))))
+#define SIP_U32TO8_LE(p, v) \
+ (p)[0] = (uint8_t)((v) >> 0); \
+ (p)[1] = (uint8_t)((v) >> 8); \
+ (p)[2] = (uint8_t)((v) >> 16); \
+ (p)[3] = (uint8_t)((v) >> 24);
-#define SIP_U32TO8_LE(p, v) \
- (p)[0] = (uint8_t)((v) >> 0); (p)[1] = (uint8_t)((v) >> 8); \
- (p)[2] = (uint8_t)((v) >> 16); (p)[3] = (uint8_t)((v) >> 24);
+#define SIP_U64TO8_LE(p, v) \
+ SIP_U32TO8_LE((p) + 0, (uint32_t)((v) >> 0)); \
+ SIP_U32TO8_LE((p) + 4, (uint32_t)((v) >> 32));
-#define SIP_U64TO8_LE(p, v) \
- SIP_U32TO8_LE((p) + 0, (uint32_t)((v) >> 0)); \
- SIP_U32TO8_LE((p) + 4, (uint32_t)((v) >> 32));
+#define SIP_U8TO64_LE(p) \
+ (((uint64_t)((p)[0]) << 0) | ((uint64_t)((p)[1]) << 8) \
+ | ((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) \
+ | ((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) \
+ | ((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56))
-#define SIP_U8TO64_LE(p) \
- (((uint64_t)((p)[0]) << 0) | \
- ((uint64_t)((p)[1]) << 8) | \
- ((uint64_t)((p)[2]) << 16) | \
- ((uint64_t)((p)[3]) << 24) | \
- ((uint64_t)((p)[4]) << 32) | \
- ((uint64_t)((p)[5]) << 40) | \
- ((uint64_t)((p)[6]) << 48) | \
- ((uint64_t)((p)[7]) << 56))
-
-
-#define SIPHASH_INITIALIZER { 0, 0, 0, 0, { 0 }, 0, 0 }
+#define SIPHASH_INITIALIZER \
+ { 0, 0, 0, 0, {0}, 0, 0 }
struct siphash {
- uint64_t v0, v1, v2, v3;
+ uint64_t v0, v1, v2, v3;
- unsigned char buf[8], *p;
- uint64_t c;
+ unsigned char buf[8], *p;
+ uint64_t c;
}; /* struct siphash */
-
#define SIP_KEYLEN 16
struct sipkey {
- uint64_t k[2];
+ uint64_t k[2];
}; /* struct sipkey */
-#define sip_keyof(k) sip_tokey(&(struct sipkey){ { 0 } }, (k))
+#define sip_keyof(k) sip_tokey(&(struct sipkey){{0}}, (k))
-static struct sipkey *sip_tokey(struct sipkey *key, const void *src) {
- key->k[0] = SIP_U8TO64_LE((const unsigned char *)src);
- key->k[1] = SIP_U8TO64_LE((const unsigned char *)src + 8);
- return key;
+static struct sipkey *
+sip_tokey(struct sipkey *key, const void *src) {
+ key->k[0] = SIP_U8TO64_LE((const unsigned char *)src);
+ key->k[1] = SIP_U8TO64_LE((const unsigned char *)src + 8);
+ return key;
} /* sip_tokey() */
+#ifdef SIPHASH_TOBIN
-#define sip_binof(v) sip_tobin((unsigned char[8]){ 0 }, (v))
+# define sip_binof(v) sip_tobin((unsigned char[8]){0}, (v))
-static void *sip_tobin(void *dst, uint64_t u64) {
- SIP_U64TO8_LE((unsigned char *)dst, u64);
- return dst;
+static void *
+sip_tobin(void *dst, uint64_t u64) {
+ SIP_U64TO8_LE((unsigned char *)dst, u64);
+ return dst;
} /* sip_tobin() */
+#endif /* SIPHASH_TOBIN */
-static void sip_round(struct siphash *H, const int rounds) {
- int i;
+static void
+sip_round(struct siphash *H, const int rounds) {
+ int i;
- for (i = 0; i < rounds; i++) {
- H->v0 += H->v1;
- H->v1 = SIP_ROTL(H->v1, 13);
- H->v1 ^= H->v0;
- H->v0 = SIP_ROTL(H->v0, 32);
+ for (i = 0; i < rounds; i++) {
+ H->v0 += H->v1;
+ H->v1 = SIP_ROTL(H->v1, 13);
+ H->v1 ^= H->v0;
+ H->v0 = SIP_ROTL(H->v0, 32);
- H->v2 += H->v3;
- H->v3 = SIP_ROTL(H->v3, 16);
- H->v3 ^= H->v2;
+ H->v2 += H->v3;
+ H->v3 = SIP_ROTL(H->v3, 16);
+ H->v3 ^= H->v2;
- H->v0 += H->v3;
- H->v3 = SIP_ROTL(H->v3, 21);
- H->v3 ^= H->v0;
+ H->v0 += H->v3;
+ H->v3 = SIP_ROTL(H->v3, 21);
+ H->v3 ^= H->v0;
- H->v2 += H->v1;
- H->v1 = SIP_ROTL(H->v1, 17);
- H->v1 ^= H->v2;
- H->v2 = SIP_ROTL(H->v2, 32);
- }
+ H->v2 += H->v1;
+ H->v1 = SIP_ROTL(H->v1, 17);
+ H->v1 ^= H->v2;
+ H->v2 = SIP_ROTL(H->v2, 32);
+ }
} /* sip_round() */
+static struct siphash *
+sip24_init(struct siphash *H, const struct sipkey *key) {
+ H->v0 = _SIP_ULL(0x736f6d65U, 0x70736575U) ^ key->k[0];
+ H->v1 = _SIP_ULL(0x646f7261U, 0x6e646f6dU) ^ key->k[1];
+ H->v2 = _SIP_ULL(0x6c796765U, 0x6e657261U) ^ key->k[0];
+ H->v3 = _SIP_ULL(0x74656462U, 0x79746573U) ^ key->k[1];
-static struct siphash *sip24_init(struct siphash *H,
- const struct sipkey *key) {
- H->v0 = _SIP_ULL(0x736f6d65U, 0x70736575U) ^ key->k[0];
- H->v1 = _SIP_ULL(0x646f7261U, 0x6e646f6dU) ^ key->k[1];
- H->v2 = _SIP_ULL(0x6c796765U, 0x6e657261U) ^ key->k[0];
- H->v3 = _SIP_ULL(0x74656462U, 0x79746573U) ^ key->k[1];
+ H->p = H->buf;
+ H->c = 0;
- H->p = H->buf;
- H->c = 0;
-
- return H;
+ return H;
} /* sip24_init() */
+#define sip_endof(a) (&(a)[sizeof(a) / sizeof *(a)])
-#define sip_endof(a) (&(a)[sizeof (a) / sizeof *(a)])
-
-static struct siphash *sip24_update(struct siphash *H, const void *src,
- size_t len) {
- const unsigned char *p = (const unsigned char *)src, *pe = p + len;
- uint64_t m;
+static struct siphash *
+sip24_update(struct siphash *H, const void *src, size_t len) {
+ const unsigned char *p = (const unsigned char *)src, *pe = p + len;
+ uint64_t m;
- do {
- while (p < pe && H->p < sip_endof(H->buf))
- *H->p++ = *p++;
+ do {
+ while (p < pe && H->p < sip_endof(H->buf))
+ *H->p++ = *p++;
- if (H->p < sip_endof(H->buf))
- break;
+ if (H->p < sip_endof(H->buf))
+ break;
- m = SIP_U8TO64_LE(H->buf);
- H->v3 ^= m;
- sip_round(H, 2);
- H->v0 ^= m;
+ m = SIP_U8TO64_LE(H->buf);
+ H->v3 ^= m;
+ sip_round(H, 2);
+ H->v0 ^= m;
- H->p = H->buf;
- H->c += 8;
- } while (p < pe);
+ H->p = H->buf;
+ H->c += 8;
+ } while (p < pe);
- return H;
+ return H;
} /* sip24_update() */
-
-static uint64_t sip24_final(struct siphash *H) {
- const char left = (char)(H->p - H->buf);
- uint64_t b = (H->c + left) << 56;
-
- switch (left) {
- case 7: b |= (uint64_t)H->buf[6] << 48;
- case 6: b |= (uint64_t)H->buf[5] << 40;
- case 5: b |= (uint64_t)H->buf[4] << 32;
- case 4: b |= (uint64_t)H->buf[3] << 24;
- case 3: b |= (uint64_t)H->buf[2] << 16;
- case 2: b |= (uint64_t)H->buf[1] << 8;
- case 1: b |= (uint64_t)H->buf[0] << 0;
- case 0: break;
- }
-
- H->v3 ^= b;
- sip_round(H, 2);
- H->v0 ^= b;
- H->v2 ^= 0xff;
- sip_round(H, 4);
-
- return H->v0 ^ H->v1 ^ H->v2 ^ H->v3;
+static uint64_t
+sip24_final(struct siphash *H) {
+ const char left = (char)(H->p - H->buf);
+ uint64_t b = (H->c + left) << 56;
+
+ switch (left) {
+ case 7:
+ b |= (uint64_t)H->buf[6] << 48;
+ /* fall through */
+ case 6:
+ b |= (uint64_t)H->buf[5] << 40;
+ /* fall through */
+ case 5:
+ b |= (uint64_t)H->buf[4] << 32;
+ /* fall through */
+ case 4:
+ b |= (uint64_t)H->buf[3] << 24;
+ /* fall through */
+ case 3:
+ b |= (uint64_t)H->buf[2] << 16;
+ /* fall through */
+ case 2:
+ b |= (uint64_t)H->buf[1] << 8;
+ /* fall through */
+ case 1:
+ b |= (uint64_t)H->buf[0] << 0;
+ /* fall through */
+ case 0:
+ break;
+ }
+
+ H->v3 ^= b;
+ sip_round(H, 2);
+ H->v0 ^= b;
+ H->v2 ^= 0xff;
+ sip_round(H, 4);
+
+ return H->v0 ^ H->v1 ^ H->v2 ^ H->v3;
} /* sip24_final() */
-
-static uint64_t siphash24(const void *src, size_t len,
- const struct sipkey *key) {
- struct siphash state = SIPHASH_INITIALIZER;
- return sip24_final(sip24_update(sip24_init(&state, key), src, len));
+static uint64_t
+siphash24(const void *src, size_t len, const struct sipkey *key) {
+ struct siphash state = SIPHASH_INITIALIZER;
+ return sip24_final(sip24_update(sip24_init(&state, key), src, len));
} /* siphash24() */
-
/*
* SipHash-2-4 output with
* k = 00 01 02 ...
@@ -271,107 +292,110 @@ static uint64_t siphash24(const void *src, size_t len,
* ...
* in = 00 01 02 ... 3e (63 bytes)
*/
-static int sip24_valid(void) {
- static const unsigned char vectors[64][8] = {
- { 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, },
- { 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, },
- { 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, },
- { 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, },
- { 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, },
- { 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, },
- { 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, },
- { 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, },
- { 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, },
- { 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, },
- { 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, },
- { 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, },
- { 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, },
- { 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, },
- { 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, },
- { 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, },
- { 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, },
- { 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, },
- { 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, },
- { 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, },
- { 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, },
- { 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, },
- { 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, },
- { 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, },
- { 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, },
- { 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, },
- { 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, },
- { 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, },
- { 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, },
- { 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, },
- { 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, },
- { 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, },
- { 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, },
- { 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, },
- { 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, },
- { 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, },
- { 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, },
- { 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, },
- { 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, },
- { 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, },
- { 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, },
- { 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, },
- { 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, },
- { 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, },
- { 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, },
- { 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, },
- { 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, },
- { 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, },
- { 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, },
- { 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, },
- { 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, },
- { 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, },
- { 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, },
- { 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, },
- { 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, },
- { 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, },
- { 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, },
- { 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, },
- { 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, },
- { 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, },
- { 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, },
- { 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, },
- { 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, },
- { 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, }
- };
- unsigned char in[64];
- struct sipkey k;
- size_t i;
-
- sip_tokey(&k, "\000\001\002\003\004\005\006\007\010\011"
- "\012\013\014\015\016\017");
-
- for (i = 0; i < sizeof in; ++i) {
- in[i] = (unsigned char)i;
-
- if (siphash24(in, i, &k) != SIP_U8TO64_LE(vectors[i]))
- return 0;
- }
-
- return 1;
+static int
+sip24_valid(void) {
+ /* clang-format off */
+ static const unsigned char vectors[64][8] = {
+ { 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, },
+ { 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, },
+ { 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, },
+ { 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, },
+ { 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, },
+ { 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, },
+ { 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, },
+ { 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, },
+ { 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, },
+ { 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, },
+ { 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, },
+ { 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, },
+ { 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, },
+ { 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, },
+ { 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, },
+ { 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, },
+ { 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, },
+ { 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, },
+ { 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, },
+ { 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, },
+ { 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, },
+ { 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, },
+ { 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, },
+ { 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, },
+ { 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, },
+ { 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, },
+ { 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, },
+ { 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, },
+ { 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, },
+ { 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, },
+ { 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, },
+ { 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, },
+ { 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, },
+ { 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, },
+ { 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, },
+ { 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, },
+ { 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, },
+ { 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, },
+ { 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, },
+ { 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, },
+ { 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, },
+ { 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, },
+ { 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, },
+ { 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, },
+ { 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, },
+ { 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, },
+ { 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, },
+ { 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, },
+ { 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, },
+ { 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, },
+ { 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, },
+ { 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, },
+ { 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, },
+ { 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, },
+ { 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, },
+ { 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, },
+ { 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, },
+ { 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, },
+ { 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, },
+ { 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, },
+ { 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, },
+ { 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, },
+ { 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, },
+ { 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, }
+ };
+ /* clang-format on */
+
+ unsigned char in[64];
+ struct sipkey k;
+ size_t i;
+
+ sip_tokey(&k, "\000\001\002\003\004\005\006\007\010\011"
+ "\012\013\014\015\016\017");
+
+ for (i = 0; i < sizeof in; ++i) {
+ in[i] = (unsigned char)i;
+
+ if (siphash24(in, i, &k) != SIP_U8TO64_LE(vectors[i]))
+ return 0;
+ }
+
+ return 1;
} /* sip24_valid() */
-
#ifdef SIPHASH_MAIN
-#include <stdio.h>
+# include <stdio.h>
-int main(void) {
- const int ok = sip24_valid();
+int
+main(void) {
+ const int ok = sip24_valid();
- if (ok)
- puts("OK");
- else
- puts("FAIL");
+ if (ok)
+ puts("OK");
+ else
+ puts("FAIL");
- return !ok;
+ return ! ok;
} /* main() */
#endif /* SIPHASH_MAIN */
-
#endif /* SIPHASH_H */
diff --git a/Utilities/cmexpat/lib/utf8tab.h b/Utilities/cmexpat/lib/utf8tab.h
index 7bb3e7760..a22986acb 100644
--- a/Utilities/cmexpat/lib/utf8tab.h
+++ b/Utilities/cmexpat/lib/utf8tab.h
@@ -1,37 +1,64 @@
-/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
-*/
+/*
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
-/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
-/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
-/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
-/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
-/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
+ /* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
+ /* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+ /* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+ /* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+ /* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+ /* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+ /* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+ /* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+ /* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
+ /* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
+ /* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
+ /* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
+ /* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
+ /* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
+ /* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
+ /* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
+ /* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
diff --git a/Utilities/cmexpat/lib/winconfig.h b/Utilities/cmexpat/lib/winconfig.h
index c9dbfea85..fe23035d0 100644
--- a/Utilities/cmexpat/lib/winconfig.h
+++ b/Utilities/cmexpat/lib/winconfig.h
@@ -1,10 +1,33 @@
-/*================================================================
-** Copyright 2000, Clark Cooper
-** All rights reserved.
-**
-** This is free software. You are permitted to copy, distribute, or modify
-** it under the terms of the MIT/X license (contained in the COPYING file
-** with this distribution.)
+/*
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef WINCONFIG_H
@@ -17,22 +40,16 @@
#include <memory.h>
#include <string.h>
+#if defined(HAVE_EXPAT_CONFIG_H) /* e.g. MinGW */
+# include <expat_config.h>
+#else /* !defined(HAVE_EXPAT_CONFIG_H) */
-#if defined(HAVE_EXPAT_CONFIG_H) /* e.g. MinGW */
-# include <expat_config.h>
-#else /* !defined(HAVE_EXPAT_CONFIG_H) */
-
-
-#define XML_NS 1
-#define XML_DTD 1
-#define XML_CONTEXT_BYTES 1024
+# define XML_NS 1
+# define XML_DTD 1
+# define XML_CONTEXT_BYTES 1024
/* we will assume all Windows platforms are little endian */
-#define BYTEORDER 1234
-
-/* Windows has memmove() available. */
-#define HAVE_MEMMOVE
-
+# define BYTEORDER 1234
#endif /* !defined(HAVE_EXPAT_CONFIG_H) */
diff --git a/Utilities/cmexpat/lib/xmlparse.c b/Utilities/cmexpat/lib/xmlparse.c
index b703e61a0..3aaf35b94 100644
--- a/Utilities/cmexpat/lib/xmlparse.c
+++ b/Utilities/cmexpat/lib/xmlparse.c
@@ -1,36 +1,69 @@
-/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
-
- 101bfd65d1ff3d1511cf6671e6aae65f82cd97df6f4da137d46d510731830ad9 (2.2.3+)
+/* f519f27c7c3b79fee55aeb8b1e53b7384b079d9118bf3a62eb3a60986a6742f2 (2.2.9+)
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#if !defined(_GNU_SOURCE)
-# define _GNU_SOURCE 1 /* syscall prototype */
+#if ! defined(_GNU_SOURCE)
+# define _GNU_SOURCE 1 /* syscall prototype */
+#endif
+
+#ifdef _WIN32
+/* force stdlib to define rand_s() */
+# if ! defined(_CRT_RAND_S)
+# define _CRT_RAND_S
+# endif
#endif
#include <stddef.h>
-#include <string.h> /* memset(), memcpy() */
+#include <string.h> /* memset(), memcpy() */
#include <assert.h>
-#include <limits.h> /* UINT_MAX */
-#include <stdio.h> /* fprintf */
-#include <stdlib.h> /* getenv */
+#include <limits.h> /* UINT_MAX */
+#include <stdio.h> /* fprintf */
+#include <stdlib.h> /* getenv, rand_s */
#ifdef _WIN32
-#define getpid GetCurrentProcessId
+# define getpid GetCurrentProcessId
#else
-#include <sys/time.h> /* gettimeofday() */
-#include <sys/types.h> /* getpid() */
-#include <unistd.h> /* getpid() */
-#include <fcntl.h> /* O_RDONLY */
-#include <errno.h>
+# include <sys/time.h> /* gettimeofday() */
+# include <sys/types.h> /* getpid() */
+# include <unistd.h> /* getpid() */
+# include <fcntl.h> /* O_RDONLY */
+# include <errno.h>
#endif
#define XML_BUILDING_EXPAT 1
#ifdef _WIN32
-#include "winconfig.h"
+# include "winconfig.h"
#elif defined(HAVE_EXPAT_CONFIG_H)
-#include <expat_config.h>
+# include <expat_config.h>
#endif /* ndef _WIN32 */
#include "ascii.h"
@@ -38,33 +71,31 @@
#include "siphash.h"
#if defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM)
-# if defined(HAVE_GETRANDOM)
-# include <sys/random.h> /* getrandom */
-# else
-# include <unistd.h> /* syscall */
-# include <sys/syscall.h> /* SYS_getrandom */
-# endif
-# if ! defined(GRND_NONBLOCK)
-# define GRND_NONBLOCK 0x0001
-# endif /* defined(GRND_NONBLOCK) */
-#endif /* defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) */
-
-#if defined(HAVE_LIBBSD) \
+# if defined(HAVE_GETRANDOM)
+# include <sys/random.h> /* getrandom */
+# else
+# include <unistd.h> /* syscall */
+# include <sys/syscall.h> /* SYS_getrandom */
+# endif
+# if ! defined(GRND_NONBLOCK)
+# define GRND_NONBLOCK 0x0001
+# endif /* defined(GRND_NONBLOCK) */
+#endif /* defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) */
+
+#if defined(HAVE_LIBBSD) \
&& (defined(HAVE_ARC4RANDOM_BUF) || defined(HAVE_ARC4RANDOM))
-# include <bsd/stdlib.h>
+# include <bsd/stdlib.h>
#endif
-#if defined(_WIN32) && !defined(LOAD_LIBRARY_SEARCH_SYSTEM32)
-# define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
+#if defined(_WIN32) && ! defined(LOAD_LIBRARY_SEARCH_SYSTEM32)
+# define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
#endif
-#if !defined(HAVE_GETRANDOM) && !defined(HAVE_SYSCALL_GETRANDOM) \
- && !defined(HAVE_ARC4RANDOM_BUF) && !defined(HAVE_ARC4RANDOM) \
- && !defined(XML_DEV_URANDOM) \
- && !defined(_WIN32) \
- && !defined(XML_POOR_ENTROPY)
-# error \
- You do not have support for any sources of high quality entropy \
+#if ! defined(HAVE_GETRANDOM) && ! defined(HAVE_SYSCALL_GETRANDOM) \
+ && ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) \
+ && ! defined(XML_DEV_URANDOM) && ! defined(_WIN32) \
+ && ! defined(XML_POOR_ENTROPY)
+# error You do not have support for any sources of high quality entropy \
enabled. For end user security, that is probably not what you want. \
\
Your options include: \
@@ -75,77 +106,67 @@
* libbsd (arc4random_buf): HAVE_ARC4RANDOM_BUF + HAVE_LIBBSD, \
* libbsd (arc4random): HAVE_ARC4RANDOM + HAVE_LIBBSD, \
* Linux / BSD / macOS (/dev/urandom): XML_DEV_URANDOM \
- * Windows (RtlGenRandom): _WIN32. \
+ * Windows (rand_s): _WIN32. \
\
If insist on not using any of these, bypass this error by defining \
XML_POOR_ENTROPY; you have been warned. \
\
- For CMake, one way to pass the define is: \
- cmake -DCMAKE_C_FLAGS="-pipe -O2 -DHAVE_SYSCALL_GETRANDOM" . \
- \
If you have reasons to patch this detection code away or need changes \
to the build system, please open a bug. Thank you!
#endif
-
#ifdef XML_UNICODE
-#define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX
-#define XmlConvert XmlUtf16Convert
-#define XmlGetInternalEncoding XmlGetUtf16InternalEncoding
-#define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS
-#define XmlEncode XmlUtf16Encode
+# define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX
+# define XmlConvert XmlUtf16Convert
+# define XmlGetInternalEncoding XmlGetUtf16InternalEncoding
+# define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS
+# define XmlEncode XmlUtf16Encode
/* Using pointer subtraction to convert to integer type. */
-#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1))
+# define MUST_CONVERT(enc, s) \
+ (! (enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1))
typedef unsigned short ICHAR;
#else
-#define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX
-#define XmlConvert XmlUtf8Convert
-#define XmlGetInternalEncoding XmlGetUtf8InternalEncoding
-#define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS
-#define XmlEncode XmlUtf8Encode
-#define MUST_CONVERT(enc, s) (!(enc)->isUtf8)
+# define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX
+# define XmlConvert XmlUtf8Convert
+# define XmlGetInternalEncoding XmlGetUtf8InternalEncoding
+# define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS
+# define XmlEncode XmlUtf8Encode
+# define MUST_CONVERT(enc, s) (! (enc)->isUtf8)
typedef char ICHAR;
#endif
-
#ifndef XML_NS
-#define XmlInitEncodingNS XmlInitEncoding
-#define XmlInitUnknownEncodingNS XmlInitUnknownEncoding
-#undef XmlGetInternalEncodingNS
-#define XmlGetInternalEncodingNS XmlGetInternalEncoding
-#define XmlParseXmlDeclNS XmlParseXmlDecl
+# define XmlInitEncodingNS XmlInitEncoding
+# define XmlInitUnknownEncodingNS XmlInitUnknownEncoding
+# undef XmlGetInternalEncodingNS
+# define XmlGetInternalEncodingNS XmlGetInternalEncoding
+# define XmlParseXmlDeclNS XmlParseXmlDecl
#endif
#ifdef XML_UNICODE
-#ifdef XML_UNICODE_WCHAR_T
-#define XML_T(x) (const wchar_t)x
-#define XML_L(x) L ## x
-#else
-#define XML_T(x) (const unsigned short)x
-#define XML_L(x) x
-#endif
+# ifdef XML_UNICODE_WCHAR_T
+# define XML_T(x) (const wchar_t) x
+# define XML_L(x) L##x
+# else
+# define XML_T(x) (const unsigned short)x
+# define XML_L(x) x
+# endif
#else
-#define XML_T(x) x
-#define XML_L(x) x
+# define XML_T(x) x
+# define XML_L(x) x
#endif
/* Round up n to be a multiple of sz, where sz is a power of 2. */
-#define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1))
+#define ROUND_UP(n, sz) (((n) + ((sz)-1)) & ~((sz)-1))
-/* Handle the case where memmove() doesn't exist. */
-#ifndef HAVE_MEMMOVE
-#ifdef HAVE_BCOPY
-#define memmove(d,s,l) bcopy((s),(d),(l))
-#else
-#error memmove does not exist on this platform, nor is a substitute available
-#endif /* HAVE_BCOPY */
-#endif /* HAVE_MEMMOVE */
+/* Do safe (NULL-aware) pointer arithmetic */
+#define EXPAT_SAFE_PTR_DIFF(p, q) (((p) && (q)) ? ((p) - (q)) : 0)
#include "internal.h"
#include "xmltok.h"
@@ -165,11 +186,9 @@ typedef struct {
const XML_Memory_Handling_Suite *mem;
} HASH_TABLE;
-static size_t
-keylen(KEY s);
+static size_t keylen(KEY s);
-static void
-copy_salt_to_sipkey(XML_Parser parser, struct sipkey * key);
+static void copy_salt_to_sipkey(XML_Parser parser, struct sipkey *key);
/* For probing (after a collision) we need a step size relative prime
to the hash table size, which is a power of 2. We use double-hashing,
@@ -179,9 +198,9 @@ copy_salt_to_sipkey(XML_Parser parser, struct sipkey * key);
We limit the maximum step size to table->size / 4 (mask >> 2) and make
it odd, since odd numbers are always relative prime to a power of 2.
*/
-#define SECOND_HASH(hash, mask, power) \
- ((((hash) & ~(mask)) >> ((power) - 1)) & ((mask) >> 2))
-#define PROBE_STEP(hash, mask, power) \
+#define SECOND_HASH(hash, mask, power) \
+ ((((hash) & ~(mask)) >> ((power)-1)) & ((mask) >> 2))
+#define PROBE_STEP(hash, mask, power) \
((unsigned char)((SECOND_HASH(hash, mask, power)) | 1))
typedef struct {
@@ -189,7 +208,7 @@ typedef struct {
NAMED **end;
} HASH_TABLE_ITER;
-#define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */
+#define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */
#define INIT_DATA_BUF_SIZE 1024
#define INIT_ATTS_SIZE 16
#define INIT_ATTS_VERSION 0xFFFFFFFF
@@ -236,20 +255,20 @@ typedef struct {
TAG objects in a free list.
*/
typedef struct tag {
- struct tag *parent; /* parent of this element */
- const char *rawName; /* tagName in the original encoding */
+ struct tag *parent; /* parent of this element */
+ const char *rawName; /* tagName in the original encoding */
int rawNameLength;
- TAG_NAME name; /* tagName in the API encoding */
- char *buf; /* buffer for name components */
- char *bufEnd; /* end of the buffer */
+ TAG_NAME name; /* tagName in the API encoding */
+ char *buf; /* buffer for name components */
+ char *bufEnd; /* end of the buffer */
BINDING *bindings;
} TAG;
typedef struct {
const XML_Char *name;
const XML_Char *textPtr;
- int textLen; /* length in XML_Chars */
- int processed; /* # of processed bytes - when suspended */
+ int textLen; /* length in XML_Chars */
+ int processed; /* # of processed bytes - when suspended */
const XML_Char *systemId;
const XML_Char *base;
const XML_Char *publicId;
@@ -260,13 +279,13 @@ typedef struct {
} ENTITY;
typedef struct {
- enum XML_Content_Type type;
- enum XML_Content_Quant quant;
- const XML_Char * name;
- int firstchild;
- int lastchild;
- int childcnt;
- int nextsib;
+ enum XML_Content_Type type;
+ enum XML_Content_Quant quant;
+ const XML_Char *name;
+ int firstchild;
+ int lastchild;
+ int childcnt;
+ int nextsib;
} CONTENT_SCAFFOLD;
#define INIT_SCAFFOLD_ELEMENTS 32
@@ -354,10 +373,8 @@ typedef struct open_internal_entity {
XML_Bool betweenDecl; /* WFC: PE Between Declarations */
} OPEN_INTERNAL_ENTITY;
-typedef enum XML_Error PTRCALL Processor(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr);
+typedef enum XML_Error PTRCALL Processor(XML_Parser parser, const char *start,
+ const char *end, const char **endPtr);
static Processor prologProcessor;
static Processor prologInitProcessor;
@@ -378,118 +395,101 @@ static Processor externalEntityInitProcessor3;
static Processor externalEntityContentProcessor;
static Processor internalEntityProcessor;
-static enum XML_Error
-handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName);
-static enum XML_Error
-processXmlDecl(XML_Parser parser, int isGeneralTextEntity,
- const char *s, const char *next);
-static enum XML_Error
-initializeEncoding(XML_Parser parser);
-static enum XML_Error
-doProlog(XML_Parser parser, const ENCODING *enc, const char *s,
- const char *end, int tok, const char *next, const char **nextPtr,
- XML_Bool haveMore);
-static enum XML_Error
-processInternalEntity(XML_Parser parser, ENTITY *entity,
- XML_Bool betweenDecl);
-static enum XML_Error
-doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
- const char *start, const char *end, const char **endPtr,
- XML_Bool haveMore);
-static enum XML_Error
-doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr,
- const char *end, const char **nextPtr, XML_Bool haveMore);
+static enum XML_Error handleUnknownEncoding(XML_Parser parser,
+ const XML_Char *encodingName);
+static enum XML_Error processXmlDecl(XML_Parser parser, int isGeneralTextEntity,
+ const char *s, const char *next);
+static enum XML_Error initializeEncoding(XML_Parser parser);
+static enum XML_Error doProlog(XML_Parser parser, const ENCODING *enc,
+ const char *s, const char *end, int tok,
+ const char *next, const char **nextPtr,
+ XML_Bool haveMore, XML_Bool allowClosingDoctype);
+static enum XML_Error processInternalEntity(XML_Parser parser, ENTITY *entity,
+ XML_Bool betweenDecl);
+static enum XML_Error doContent(XML_Parser parser, int startTagLevel,
+ const ENCODING *enc, const char *start,
+ const char *end, const char **endPtr,
+ XML_Bool haveMore);
+static enum XML_Error doCdataSection(XML_Parser parser, const ENCODING *,
+ const char **startPtr, const char *end,
+ const char **nextPtr, XML_Bool haveMore);
#ifdef XML_DTD
-static enum XML_Error
-doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr,
- const char *end, const char **nextPtr, XML_Bool haveMore);
+static enum XML_Error doIgnoreSection(XML_Parser parser, const ENCODING *,
+ const char **startPtr, const char *end,
+ const char **nextPtr, XML_Bool haveMore);
#endif /* XML_DTD */
-static void
-freeBindings(XML_Parser parser, BINDING *bindings);
-static enum XML_Error
-storeAtts(XML_Parser parser, const ENCODING *, const char *s,
- TAG_NAME *tagNamePtr, BINDING **bindingsPtr);
-static enum XML_Error
-addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
- const XML_Char *uri, BINDING **bindingsPtr);
-static int
-defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, XML_Bool isCdata,
- XML_Bool isId, const XML_Char *dfltValue, XML_Parser parser);
-static enum XML_Error
-storeAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata,
- const char *, const char *, STRING_POOL *);
-static enum XML_Error
-appendAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata,
- const char *, const char *, STRING_POOL *);
-static ATTRIBUTE_ID *
-getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start,
- const char *end);
-static int
-setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *);
-static enum XML_Error
-storeEntityValue(XML_Parser parser, const ENCODING *enc, const char *start,
- const char *end);
-static int
-reportProcessingInstruction(XML_Parser parser, const ENCODING *enc,
- const char *start, const char *end);
-static int
-reportComment(XML_Parser parser, const ENCODING *enc, const char *start,
- const char *end);
-static void
-reportDefault(XML_Parser parser, const ENCODING *enc, const char *start,
- const char *end);
-
-static const XML_Char * getContext(XML_Parser parser);
-static XML_Bool
-setContext(XML_Parser parser, const XML_Char *context);
+static void freeBindings(XML_Parser parser, BINDING *bindings);
+static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *,
+ const char *s, TAG_NAME *tagNamePtr,
+ BINDING **bindingsPtr);
+static enum XML_Error addBinding(XML_Parser parser, PREFIX *prefix,
+ const ATTRIBUTE_ID *attId, const XML_Char *uri,
+ BINDING **bindingsPtr);
+static int defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, XML_Bool isCdata,
+ XML_Bool isId, const XML_Char *dfltValue,
+ XML_Parser parser);
+static enum XML_Error storeAttributeValue(XML_Parser parser, const ENCODING *,
+ XML_Bool isCdata, const char *,
+ const char *, STRING_POOL *);
+static enum XML_Error appendAttributeValue(XML_Parser parser, const ENCODING *,
+ XML_Bool isCdata, const char *,
+ const char *, STRING_POOL *);
+static ATTRIBUTE_ID *getAttributeId(XML_Parser parser, const ENCODING *enc,
+ const char *start, const char *end);
+static int setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *);
+static enum XML_Error storeEntityValue(XML_Parser parser, const ENCODING *enc,
+ const char *start, const char *end);
+static int reportProcessingInstruction(XML_Parser parser, const ENCODING *enc,
+ const char *start, const char *end);
+static int reportComment(XML_Parser parser, const ENCODING *enc,
+ const char *start, const char *end);
+static void reportDefault(XML_Parser parser, const ENCODING *enc,
+ const char *start, const char *end);
+
+static const XML_Char *getContext(XML_Parser parser);
+static XML_Bool setContext(XML_Parser parser, const XML_Char *context);
static void FASTCALL normalizePublicId(XML_Char *s);
-static DTD * dtdCreate(const XML_Memory_Handling_Suite *ms);
-/* do not call if parentParser != NULL */
+static DTD *dtdCreate(const XML_Memory_Handling_Suite *ms);
+/* do not call if m_parentParser != NULL */
static void dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms);
-static void
-dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms);
-static int
-dtdCopy(XML_Parser oldParser,
- DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms);
-static int
-copyEntityTable(XML_Parser oldParser,
- HASH_TABLE *, STRING_POOL *, const HASH_TABLE *);
-static NAMED *
-lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize);
-static void FASTCALL
-hashTableInit(HASH_TABLE *, const XML_Memory_Handling_Suite *ms);
+static void dtdDestroy(DTD *p, XML_Bool isDocEntity,
+ const XML_Memory_Handling_Suite *ms);
+static int dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd,
+ const XML_Memory_Handling_Suite *ms);
+static int copyEntityTable(XML_Parser oldParser, HASH_TABLE *, STRING_POOL *,
+ const HASH_TABLE *);
+static NAMED *lookup(XML_Parser parser, HASH_TABLE *table, KEY name,
+ size_t createSize);
+static void FASTCALL hashTableInit(HASH_TABLE *,
+ const XML_Memory_Handling_Suite *ms);
static void FASTCALL hashTableClear(HASH_TABLE *);
static void FASTCALL hashTableDestroy(HASH_TABLE *);
-static void FASTCALL
-hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *);
-static NAMED * FASTCALL hashTableIterNext(HASH_TABLE_ITER *);
+static void FASTCALL hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *);
+static NAMED *FASTCALL hashTableIterNext(HASH_TABLE_ITER *);
-static void FASTCALL
-poolInit(STRING_POOL *, const XML_Memory_Handling_Suite *ms);
+static void FASTCALL poolInit(STRING_POOL *,
+ const XML_Memory_Handling_Suite *ms);
static void FASTCALL poolClear(STRING_POOL *);
static void FASTCALL poolDestroy(STRING_POOL *);
-static XML_Char *
-poolAppend(STRING_POOL *pool, const ENCODING *enc,
- const char *ptr, const char *end);
-static XML_Char *
-poolStoreString(STRING_POOL *pool, const ENCODING *enc,
- const char *ptr, const char *end);
+static XML_Char *poolAppend(STRING_POOL *pool, const ENCODING *enc,
+ const char *ptr, const char *end);
+static XML_Char *poolStoreString(STRING_POOL *pool, const ENCODING *enc,
+ const char *ptr, const char *end);
static XML_Bool FASTCALL poolGrow(STRING_POOL *pool);
-static const XML_Char * FASTCALL
-poolCopyString(STRING_POOL *pool, const XML_Char *s);
-static const XML_Char *
-poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n);
-static const XML_Char * FASTCALL
-poolAppendString(STRING_POOL *pool, const XML_Char *s);
+static const XML_Char *FASTCALL poolCopyString(STRING_POOL *pool,
+ const XML_Char *s);
+static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s,
+ int n);
+static const XML_Char *FASTCALL poolAppendString(STRING_POOL *pool,
+ const XML_Char *s);
static int FASTCALL nextScaffoldPart(XML_Parser parser);
-static XML_Content * build_model(XML_Parser parser);
-static ELEMENT_TYPE *
-getElementType(XML_Parser parser, const ENCODING *enc,
- const char *ptr, const char *end);
+static XML_Content *build_model(XML_Parser parser);
+static ELEMENT_TYPE *getElementType(XML_Parser parser, const ENCODING *enc,
+ const char *ptr, const char *end);
static XML_Char *copyString(const XML_Char *s,
const XML_Memory_Handling_Suite *memsuite);
@@ -497,14 +497,11 @@ static XML_Char *copyString(const XML_Char *s,
static unsigned long generate_hash_secret_salt(XML_Parser parser);
static XML_Bool startParsing(XML_Parser parser);
-static XML_Parser
-parserCreate(const XML_Char *encodingName,
- const XML_Memory_Handling_Suite *memsuite,
- const XML_Char *nameSep,
- DTD *dtd);
+static XML_Parser parserCreate(const XML_Char *encodingName,
+ const XML_Memory_Handling_Suite *memsuite,
+ const XML_Char *nameSep, DTD *dtd);
-static void
-parserInit(XML_Parser parser, const XML_Char *encodingName);
+static void parserInit(XML_Parser parser, const XML_Char *encodingName);
#define poolStart(pool) ((pool)->start)
#define poolEnd(pool) ((pool)->ptr)
@@ -513,13 +510,13 @@ parserInit(XML_Parser parser, const XML_Char *encodingName);
#define poolLastChar(pool) (((pool)->ptr)[-1])
#define poolDiscard(pool) ((pool)->ptr = (pool)->start)
#define poolFinish(pool) ((pool)->start = (pool)->ptr)
-#define poolAppendChar(pool, c) \
- (((pool)->ptr == (pool)->end && !poolGrow(pool)) \
- ? 0 \
- : ((*((pool)->ptr)++ = c), 1))
+#define poolAppendChar(pool, c) \
+ (((pool)->ptr == (pool)->end && ! poolGrow(pool)) \
+ ? 0 \
+ : ((*((pool)->ptr)++ = c), 1))
struct XML_ParserStruct {
- /* The first member must be userData so that the XML_GetUserData
+ /* The first member must be m_userData so that the XML_GetUserData
macro works. */
void *m_userData;
void *m_handlerArg;
@@ -529,7 +526,7 @@ struct XML_ParserStruct {
const char *m_bufferPtr;
/* past last character to be parsed */
char *m_bufferEnd;
- /* allocated end of buffer */
+ /* allocated end of m_buffer */
const char *m_bufferLim;
XML_Index m_parseEndByteIndex;
const char *m_parseEndPtr;
@@ -567,7 +564,7 @@ struct XML_ParserStruct {
void *m_unknownEncodingMem;
void *m_unknownEncodingData;
void *m_unknownEncodingHandlerData;
- void (XMLCALL *m_unknownEncodingRelease)(void *);
+ void(XMLCALL *m_unknownEncodingRelease)(void *);
PROLOG_STATE m_prologState;
Processor *m_processor;
enum XML_Error m_errorCode;
@@ -621,157 +618,55 @@ struct XML_ParserStruct {
unsigned long m_hash_secret_salt;
};
-#define MALLOC(s) (parser->m_mem.malloc_fcn((s)))
-#define REALLOC(p,s) (parser->m_mem.realloc_fcn((p),(s)))
-#define FREE(p) (parser->m_mem.free_fcn((p)))
-
-#define userData (parser->m_userData)
-#define handlerArg (parser->m_handlerArg)
-#define startElementHandler (parser->m_startElementHandler)
-#define endElementHandler (parser->m_endElementHandler)
-#define characterDataHandler (parser->m_characterDataHandler)
-#define processingInstructionHandler \
- (parser->m_processingInstructionHandler)
-#define commentHandler (parser->m_commentHandler)
-#define startCdataSectionHandler \
- (parser->m_startCdataSectionHandler)
-#define endCdataSectionHandler (parser->m_endCdataSectionHandler)
-#define defaultHandler (parser->m_defaultHandler)
-#define startDoctypeDeclHandler (parser->m_startDoctypeDeclHandler)
-#define endDoctypeDeclHandler (parser->m_endDoctypeDeclHandler)
-#define unparsedEntityDeclHandler \
- (parser->m_unparsedEntityDeclHandler)
-#define notationDeclHandler (parser->m_notationDeclHandler)
-#define startNamespaceDeclHandler \
- (parser->m_startNamespaceDeclHandler)
-#define endNamespaceDeclHandler (parser->m_endNamespaceDeclHandler)
-#define notStandaloneHandler (parser->m_notStandaloneHandler)
-#define externalEntityRefHandler \
- (parser->m_externalEntityRefHandler)
-#define externalEntityRefHandlerArg \
- (parser->m_externalEntityRefHandlerArg)
-#define internalEntityRefHandler \
- (parser->m_internalEntityRefHandler)
-#define skippedEntityHandler (parser->m_skippedEntityHandler)
-#define unknownEncodingHandler (parser->m_unknownEncodingHandler)
-#define elementDeclHandler (parser->m_elementDeclHandler)
-#define attlistDeclHandler (parser->m_attlistDeclHandler)
-#define entityDeclHandler (parser->m_entityDeclHandler)
-#define xmlDeclHandler (parser->m_xmlDeclHandler)
-#define encoding (parser->m_encoding)
-#define initEncoding (parser->m_initEncoding)
-#define internalEncoding (parser->m_internalEncoding)
-#define unknownEncodingMem (parser->m_unknownEncodingMem)
-#define unknownEncodingData (parser->m_unknownEncodingData)
-#define unknownEncodingHandlerData \
- (parser->m_unknownEncodingHandlerData)
-#define unknownEncodingRelease (parser->m_unknownEncodingRelease)
-#define protocolEncodingName (parser->m_protocolEncodingName)
-#define ns (parser->m_ns)
-#define ns_triplets (parser->m_ns_triplets)
-#define prologState (parser->m_prologState)
-#define processor (parser->m_processor)
-#define errorCode (parser->m_errorCode)
-#define eventPtr (parser->m_eventPtr)
-#define eventEndPtr (parser->m_eventEndPtr)
-#define positionPtr (parser->m_positionPtr)
-#define position (parser->m_position)
-#define openInternalEntities (parser->m_openInternalEntities)
-#define freeInternalEntities (parser->m_freeInternalEntities)
-#define defaultExpandInternalEntities \
- (parser->m_defaultExpandInternalEntities)
-#define tagLevel (parser->m_tagLevel)
-#define buffer (parser->m_buffer)
-#define bufferPtr (parser->m_bufferPtr)
-#define bufferEnd (parser->m_bufferEnd)
-#define parseEndByteIndex (parser->m_parseEndByteIndex)
-#define parseEndPtr (parser->m_parseEndPtr)
-#define bufferLim (parser->m_bufferLim)
-#define dataBuf (parser->m_dataBuf)
-#define dataBufEnd (parser->m_dataBufEnd)
-#define _dtd (parser->m_dtd)
-#define curBase (parser->m_curBase)
-#define declEntity (parser->m_declEntity)
-#define doctypeName (parser->m_doctypeName)
-#define doctypeSysid (parser->m_doctypeSysid)
-#define doctypePubid (parser->m_doctypePubid)
-#define declAttributeType (parser->m_declAttributeType)
-#define declNotationName (parser->m_declNotationName)
-#define declNotationPublicId (parser->m_declNotationPublicId)
-#define declElementType (parser->m_declElementType)
-#define declAttributeId (parser->m_declAttributeId)
-#define declAttributeIsCdata (parser->m_declAttributeIsCdata)
-#define declAttributeIsId (parser->m_declAttributeIsId)
-#define freeTagList (parser->m_freeTagList)
-#define freeBindingList (parser->m_freeBindingList)
-#define inheritedBindings (parser->m_inheritedBindings)
-#define tagStack (parser->m_tagStack)
-#define atts (parser->m_atts)
-#define attsSize (parser->m_attsSize)
-#define nSpecifiedAtts (parser->m_nSpecifiedAtts)
-#define idAttIndex (parser->m_idAttIndex)
-#define nsAtts (parser->m_nsAtts)
-#define nsAttsVersion (parser->m_nsAttsVersion)
-#define nsAttsPower (parser->m_nsAttsPower)
-#define attInfo (parser->m_attInfo)
-#define tempPool (parser->m_tempPool)
-#define temp2Pool (parser->m_temp2Pool)
-#define groupConnector (parser->m_groupConnector)
-#define groupSize (parser->m_groupSize)
-#define namespaceSeparator (parser->m_namespaceSeparator)
-#define parentParser (parser->m_parentParser)
-#define ps_parsing (parser->m_parsingStatus.parsing)
-#define ps_finalBuffer (parser->m_parsingStatus.finalBuffer)
-#ifdef XML_DTD
-#define isParamEntity (parser->m_isParamEntity)
-#define useForeignDTD (parser->m_useForeignDTD)
-#define paramEntityParsing (parser->m_paramEntityParsing)
-#endif /* XML_DTD */
-#define hash_secret_salt (parser->m_hash_secret_salt)
+#define MALLOC(parser, s) (parser->m_mem.malloc_fcn((s)))
+#define REALLOC(parser, p, s) (parser->m_mem.realloc_fcn((p), (s)))
+#define FREE(parser, p) (parser->m_mem.free_fcn((p)))
XML_Parser XMLCALL
-XML_ParserCreate(const XML_Char *encodingName)
-{
+XML_ParserCreate(const XML_Char *encodingName) {
return XML_ParserCreate_MM(encodingName, NULL, NULL);
}
XML_Parser XMLCALL
-XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep)
-{
+XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) {
XML_Char tmp[2];
*tmp = nsSep;
return XML_ParserCreate_MM(encodingName, NULL, tmp);
}
-static const XML_Char implicitContext[] = {
- ASCII_x, ASCII_m, ASCII_l, ASCII_EQUALS, ASCII_h, ASCII_t, ASCII_t, ASCII_p,
- ASCII_COLON, ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w,
- ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g,
- ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, ASCII_SLASH, ASCII_1, ASCII_9,
- ASCII_9, ASCII_8, ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, ASCII_e,
- ASCII_s, ASCII_p, ASCII_a, ASCII_c, ASCII_e, '\0'
-};
+static const XML_Char implicitContext[]
+ = {ASCII_x, ASCII_m, ASCII_l, ASCII_EQUALS, ASCII_h,
+ ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH,
+ ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD,
+ ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r,
+ ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L,
+ ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, ASCII_8,
+ ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, ASCII_e,
+ ASCII_s, ASCII_p, ASCII_a, ASCII_c, ASCII_e,
+ '\0'};
+/* To avoid warnings about unused functions: */
+#if ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM)
-#if defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM)
+# if defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM)
/* Obtain entropy on Linux 3.17+ */
static int
-writeRandomBytes_getrandom_nonblock(void * target, size_t count) {
- int success = 0; /* full count bytes written? */
+writeRandomBytes_getrandom_nonblock(void *target, size_t count) {
+ int success = 0; /* full count bytes written? */
size_t bytesWrittenTotal = 0;
const unsigned int getrandomFlags = GRND_NONBLOCK;
do {
- void * const currentTarget = (void*)((char*)target + bytesWrittenTotal);
+ void *const currentTarget = (void *)((char *)target + bytesWrittenTotal);
const size_t bytesToWrite = count - bytesWrittenTotal;
const int bytesWrittenMore =
-#if defined(HAVE_GETRANDOM)
+# if defined(HAVE_GETRANDOM)
getrandom(currentTarget, bytesToWrite, getrandomFlags);
-#else
+# else
syscall(SYS_getrandom, currentTarget, bytesToWrite, getrandomFlags);
-#endif
+# endif
if (bytesWrittenMore > 0) {
bytesWrittenTotal += bytesWrittenMore;
@@ -783,15 +678,14 @@ writeRandomBytes_getrandom_nonblock(void * target, size_t count) {
return success;
}
-#endif /* defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) */
+# endif /* defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) */
-
-#if ! defined(_WIN32) && defined(XML_DEV_URANDOM)
+# if ! defined(_WIN32) && defined(XML_DEV_URANDOM)
/* Extract entropy from /dev/urandom */
static int
-writeRandomBytes_dev_urandom(void * target, size_t count) {
- int success = 0; /* full count bytes written? */
+writeRandomBytes_dev_urandom(void *target, size_t count) {
+ int success = 0; /* full count bytes written? */
size_t bytesWrittenTotal = 0;
const int fd = open("/dev/urandom", O_RDONLY);
@@ -800,7 +694,7 @@ writeRandomBytes_dev_urandom(void * target, size_t count) {
}
do {
- void * const currentTarget = (void*)((char*)target + bytesWrittenTotal);
+ void *const currentTarget = (void *)((char *)target + bytesWrittenTotal);
const size_t bytesToWrite = count - bytesWrittenTotal;
const ssize_t bytesWrittenMore = read(fd, currentTarget, bytesToWrite);
@@ -816,13 +710,14 @@ writeRandomBytes_dev_urandom(void * target, size_t count) {
return success;
}
-#endif /* ! defined(_WIN32) && defined(XML_DEV_URANDOM) */
+# endif /* ! defined(_WIN32) && defined(XML_DEV_URANDOM) */
+#endif /* ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) */
-#if defined(HAVE_ARC4RANDOM)
+#if defined(HAVE_ARC4RANDOM) && ! defined(HAVE_ARC4RANDOM_BUF)
static void
-writeRandomBytes_arc4random(void * target, size_t count) {
+writeRandomBytes_arc4random(void *target, size_t count) {
size_t bytesWrittenTotal = 0;
while (bytesWrittenTotal < count) {
@@ -830,95 +725,86 @@ writeRandomBytes_arc4random(void * target, size_t count) {
size_t i = 0;
for (; (i < sizeof(random32)) && (bytesWrittenTotal < count);
- i++, bytesWrittenTotal++) {
+ i++, bytesWrittenTotal++) {
const uint8_t random8 = (uint8_t)(random32 >> (i * 8));
((uint8_t *)target)[bytesWrittenTotal] = random8;
}
}
}
-#endif /* defined(HAVE_ARC4RANDOM) */
-
+#endif /* defined(HAVE_ARC4RANDOM) && ! defined(HAVE_ARC4RANDOM_BUF) */
#ifdef _WIN32
-typedef BOOLEAN (APIENTRY *RTLGENRANDOM_FUNC)(PVOID, ULONG);
-HMODULE _Expat_LoadLibrary(LPCTSTR filename); /* see loadlibrary.c */
-
-/* Obtain entropy on Windows XP / Windows Server 2003 and later.
- * Hint on RtlGenRandom and the following article from libsodium.
- *
- * Michael Howard: Cryptographically Secure Random number on Windows without using CryptoAPI
- * https://blogs.msdn.microsoft.com/michael_howard/2005/01/14/cryptographically-secure-random-number-on-windows-without-using-cryptoapi/
+/* Obtain entropy on Windows using the rand_s() function which
+ * generates cryptographically secure random numbers. Internally it
+ * uses RtlGenRandom API which is present in Windows XP and later.
*/
static int
-writeRandomBytes_RtlGenRandom(void * target, size_t count) {
- int success = 0; /* full count bytes written? */
- const HMODULE advapi32 = _Expat_LoadLibrary(TEXT("ADVAPI32.DLL"));
-
- if (advapi32) {
- const RTLGENRANDOM_FUNC RtlGenRandom
- = (RTLGENRANDOM_FUNC)GetProcAddress(advapi32, "SystemFunction036");
- if (RtlGenRandom) {
- if (RtlGenRandom((PVOID)target, (ULONG)count) == TRUE) {
- success = 1;
- }
+writeRandomBytes_rand_s(void *target, size_t count) {
+ size_t bytesWrittenTotal = 0;
+
+ while (bytesWrittenTotal < count) {
+ unsigned int random32 = 0;
+ size_t i = 0;
+
+ if (rand_s(&random32))
+ return 0; /* failure */
+
+ for (; (i < sizeof(random32)) && (bytesWrittenTotal < count);
+ i++, bytesWrittenTotal++) {
+ const uint8_t random8 = (uint8_t)(random32 >> (i * 8));
+ ((uint8_t *)target)[bytesWrittenTotal] = random8;
}
- FreeLibrary(advapi32);
}
-
- return success;
+ return 1; /* success */
}
#endif /* _WIN32 */
-
#if ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM)
static unsigned long
-gather_time_entropy(void)
-{
-#ifdef _WIN32
+gather_time_entropy(void) {
+# ifdef _WIN32
FILETIME ft;
GetSystemTimeAsFileTime(&ft); /* never fails */
return ft.dwHighDateTime ^ ft.dwLowDateTime;
-#else
+# else
struct timeval tv;
int gettimeofday_res;
gettimeofday_res = gettimeofday(&tv, NULL);
-#if defined(NDEBUG)
+# if defined(NDEBUG)
(void)gettimeofday_res;
-#else
- assert (gettimeofday_res == 0);
-#endif /* defined(NDEBUG) */
+# else
+ assert(gettimeofday_res == 0);
+# endif /* defined(NDEBUG) */
/* Microseconds time is <20 bits entropy */
return tv.tv_usec;
-#endif
+# endif
}
-#endif /* ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) */
-
+#endif /* ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) */
static unsigned long
-ENTROPY_DEBUG(const char * label, unsigned long entropy) {
- const char * const EXPAT_ENTROPY_DEBUG = getenv("EXPAT_ENTROPY_DEBUG");
+ENTROPY_DEBUG(const char *label, unsigned long entropy) {
+ const char *const EXPAT_ENTROPY_DEBUG = getenv("EXPAT_ENTROPY_DEBUG");
if (EXPAT_ENTROPY_DEBUG && ! strcmp(EXPAT_ENTROPY_DEBUG, "1")) {
- fprintf(stderr, "Entropy: %s --> 0x%0*lx (%lu bytes)\n",
- label,
- (int)sizeof(entropy) * 2, entropy,
- (unsigned long)sizeof(entropy));
+ fprintf(stderr, "Entropy: %s --> 0x%0*lx (%lu bytes)\n", label,
+ (int)sizeof(entropy) * 2, entropy, (unsigned long)sizeof(entropy));
}
return entropy;
}
static unsigned long
-generate_hash_secret_salt(XML_Parser parser)
-{
+generate_hash_secret_salt(XML_Parser parser) {
unsigned long entropy;
(void)parser;
+
+ /* "Failproof" high quality providers: */
#if defined(HAVE_ARC4RANDOM_BUF)
arc4random_buf(&entropy, sizeof(entropy));
return ENTROPY_DEBUG("arc4random_buf", entropy);
@@ -927,20 +813,20 @@ generate_hash_secret_salt(XML_Parser parser)
return ENTROPY_DEBUG("arc4random", entropy);
#else
/* Try high quality providers first .. */
-#ifdef _WIN32
- if (writeRandomBytes_RtlGenRandom((void *)&entropy, sizeof(entropy))) {
- return ENTROPY_DEBUG("RtlGenRandom", entropy);
+# ifdef _WIN32
+ if (writeRandomBytes_rand_s((void *)&entropy, sizeof(entropy))) {
+ return ENTROPY_DEBUG("rand_s", entropy);
}
-#elif defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM)
+# elif defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM)
if (writeRandomBytes_getrandom_nonblock((void *)&entropy, sizeof(entropy))) {
return ENTROPY_DEBUG("getrandom", entropy);
}
-#endif
-#if ! defined(_WIN32) && defined(XML_DEV_URANDOM)
+# endif
+# if ! defined(_WIN32) && defined(XML_DEV_URANDOM)
if (writeRandomBytes_dev_urandom((void *)&entropy, sizeof(entropy))) {
return ENTROPY_DEBUG("/dev/urandom", entropy);
}
-#endif /* ! defined(_WIN32) && defined(XML_DEV_URANDOM) */
+# endif /* ! defined(_WIN32) && defined(XML_DEV_URANDOM) */
/* .. and self-made low quality for backup: */
/* Process ID is 0 bits entropy if attacker has local access */
@@ -951,7 +837,7 @@ generate_hash_secret_salt(XML_Parser parser)
return ENTROPY_DEBUG("fallback(4)", entropy * 2147483647);
} else {
return ENTROPY_DEBUG("fallback(8)",
- entropy * (unsigned long)2305843009213693951ULL);
+ entropy * (unsigned long)2305843009213693951ULL);
}
#endif
}
@@ -963,49 +849,43 @@ get_hash_secret_salt(XML_Parser parser) {
return parser->m_hash_secret_salt;
}
-static XML_Bool /* only valid for root parser */
-startParsing(XML_Parser parser)
-{
- /* hash functions must be initialized before setContext() is called */
- if (hash_secret_salt == 0)
- hash_secret_salt = generate_hash_secret_salt(parser);
- if (ns) {
- /* implicit context only set for root parser, since child
- parsers (i.e. external entity parsers) will inherit it
- */
- return setContext(parser, implicitContext);
- }
- return XML_TRUE;
+static XML_Bool /* only valid for root parser */
+startParsing(XML_Parser parser) {
+ /* hash functions must be initialized before setContext() is called */
+ if (parser->m_hash_secret_salt == 0)
+ parser->m_hash_secret_salt = generate_hash_secret_salt(parser);
+ if (parser->m_ns) {
+ /* implicit context only set for root parser, since child
+ parsers (i.e. external entity parsers) will inherit it
+ */
+ return setContext(parser, implicitContext);
+ }
+ return XML_TRUE;
}
XML_Parser XMLCALL
XML_ParserCreate_MM(const XML_Char *encodingName,
const XML_Memory_Handling_Suite *memsuite,
- const XML_Char *nameSep)
-{
+ const XML_Char *nameSep) {
return parserCreate(encodingName, memsuite, nameSep, NULL);
}
static XML_Parser
parserCreate(const XML_Char *encodingName,
- const XML_Memory_Handling_Suite *memsuite,
- const XML_Char *nameSep,
- DTD *dtd)
-{
+ const XML_Memory_Handling_Suite *memsuite, const XML_Char *nameSep,
+ DTD *dtd) {
XML_Parser parser;
if (memsuite) {
XML_Memory_Handling_Suite *mtemp;
- parser = (XML_Parser)
- memsuite->malloc_fcn(sizeof(struct XML_ParserStruct));
+ parser = (XML_Parser)memsuite->malloc_fcn(sizeof(struct XML_ParserStruct));
if (parser != NULL) {
mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem);
mtemp->malloc_fcn = memsuite->malloc_fcn;
mtemp->realloc_fcn = memsuite->realloc_fcn;
mtemp->free_fcn = memsuite->free_fcn;
}
- }
- else {
+ } else {
XML_Memory_Handling_Suite *mtemp;
parser = (XML_Parser)malloc(sizeof(struct XML_ParserStruct));
if (parser != NULL) {
@@ -1016,252 +896,249 @@ parserCreate(const XML_Char *encodingName,
}
}
- if (!parser)
+ if (! parser)
return parser;
- buffer = NULL;
- bufferLim = NULL;
+ parser->m_buffer = NULL;
+ parser->m_bufferLim = NULL;
- attsSize = INIT_ATTS_SIZE;
- atts = (ATTRIBUTE *)MALLOC(attsSize * sizeof(ATTRIBUTE));
- if (atts == NULL) {
- FREE(parser);
+ parser->m_attsSize = INIT_ATTS_SIZE;
+ parser->m_atts
+ = (ATTRIBUTE *)MALLOC(parser, parser->m_attsSize * sizeof(ATTRIBUTE));
+ if (parser->m_atts == NULL) {
+ FREE(parser, parser);
return NULL;
}
#ifdef XML_ATTR_INFO
- attInfo = (XML_AttrInfo*)MALLOC(attsSize * sizeof(XML_AttrInfo));
- if (attInfo == NULL) {
- FREE(atts);
- FREE(parser);
+ parser->m_attInfo = (XML_AttrInfo *)MALLOC(
+ parser, parser->m_attsSize * sizeof(XML_AttrInfo));
+ if (parser->m_attInfo == NULL) {
+ FREE(parser, parser->m_atts);
+ FREE(parser, parser);
return NULL;
}
#endif
- dataBuf = (XML_Char *)MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char));
- if (dataBuf == NULL) {
- FREE(atts);
+ parser->m_dataBuf
+ = (XML_Char *)MALLOC(parser, INIT_DATA_BUF_SIZE * sizeof(XML_Char));
+ if (parser->m_dataBuf == NULL) {
+ FREE(parser, parser->m_atts);
#ifdef XML_ATTR_INFO
- FREE(attInfo);
+ FREE(parser, parser->m_attInfo);
#endif
- FREE(parser);
+ FREE(parser, parser);
return NULL;
}
- dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE;
+ parser->m_dataBufEnd = parser->m_dataBuf + INIT_DATA_BUF_SIZE;
if (dtd)
- _dtd = dtd;
+ parser->m_dtd = dtd;
else {
- _dtd = dtdCreate(&parser->m_mem);
- if (_dtd == NULL) {
- FREE(dataBuf);
- FREE(atts);
+ parser->m_dtd = dtdCreate(&parser->m_mem);
+ if (parser->m_dtd == NULL) {
+ FREE(parser, parser->m_dataBuf);
+ FREE(parser, parser->m_atts);
#ifdef XML_ATTR_INFO
- FREE(attInfo);
+ FREE(parser, parser->m_attInfo);
#endif
- FREE(parser);
+ FREE(parser, parser);
return NULL;
}
}
- freeBindingList = NULL;
- freeTagList = NULL;
- freeInternalEntities = NULL;
+ parser->m_freeBindingList = NULL;
+ parser->m_freeTagList = NULL;
+ parser->m_freeInternalEntities = NULL;
- groupSize = 0;
- groupConnector = NULL;
+ parser->m_groupSize = 0;
+ parser->m_groupConnector = NULL;
- unknownEncodingHandler = NULL;
- unknownEncodingHandlerData = NULL;
+ parser->m_unknownEncodingHandler = NULL;
+ parser->m_unknownEncodingHandlerData = NULL;
- namespaceSeparator = ASCII_EXCL;
- ns = XML_FALSE;
- ns_triplets = XML_FALSE;
+ parser->m_namespaceSeparator = ASCII_EXCL;
+ parser->m_ns = XML_FALSE;
+ parser->m_ns_triplets = XML_FALSE;
- nsAtts = NULL;
- nsAttsVersion = 0;
- nsAttsPower = 0;
+ parser->m_nsAtts = NULL;
+ parser->m_nsAttsVersion = 0;
+ parser->m_nsAttsPower = 0;
- protocolEncodingName = NULL;
+ parser->m_protocolEncodingName = NULL;
- poolInit(&tempPool, &(parser->m_mem));
- poolInit(&temp2Pool, &(parser->m_mem));
+ poolInit(&parser->m_tempPool, &(parser->m_mem));
+ poolInit(&parser->m_temp2Pool, &(parser->m_mem));
parserInit(parser, encodingName);
- if (encodingName && !protocolEncodingName) {
+ if (encodingName && ! parser->m_protocolEncodingName) {
XML_ParserFree(parser);
return NULL;
}
if (nameSep) {
- ns = XML_TRUE;
- internalEncoding = XmlGetInternalEncodingNS();
- namespaceSeparator = *nameSep;
- }
- else {
- internalEncoding = XmlGetInternalEncoding();
+ parser->m_ns = XML_TRUE;
+ parser->m_internalEncoding = XmlGetInternalEncodingNS();
+ parser->m_namespaceSeparator = *nameSep;
+ } else {
+ parser->m_internalEncoding = XmlGetInternalEncoding();
}
return parser;
}
static void
-parserInit(XML_Parser parser, const XML_Char *encodingName)
-{
- processor = prologInitProcessor;
- XmlPrologStateInit(&prologState);
+parserInit(XML_Parser parser, const XML_Char *encodingName) {
+ parser->m_processor = prologInitProcessor;
+ XmlPrologStateInit(&parser->m_prologState);
if (encodingName != NULL) {
- protocolEncodingName = copyString(encodingName, &(parser->m_mem));
- }
- curBase = NULL;
- XmlInitEncoding(&initEncoding, &encoding, 0);
- userData = NULL;
- handlerArg = NULL;
- startElementHandler = NULL;
- endElementHandler = NULL;
- characterDataHandler = NULL;
- processingInstructionHandler = NULL;
- commentHandler = NULL;
- startCdataSectionHandler = NULL;
- endCdataSectionHandler = NULL;
- defaultHandler = NULL;
- startDoctypeDeclHandler = NULL;
- endDoctypeDeclHandler = NULL;
- unparsedEntityDeclHandler = NULL;
- notationDeclHandler = NULL;
- startNamespaceDeclHandler = NULL;
- endNamespaceDeclHandler = NULL;
- notStandaloneHandler = NULL;
- externalEntityRefHandler = NULL;
- externalEntityRefHandlerArg = parser;
- skippedEntityHandler = NULL;
- elementDeclHandler = NULL;
- attlistDeclHandler = NULL;
- entityDeclHandler = NULL;
- xmlDeclHandler = NULL;
- bufferPtr = buffer;
- bufferEnd = buffer;
- parseEndByteIndex = 0;
- parseEndPtr = NULL;
- declElementType = NULL;
- declAttributeId = NULL;
- declEntity = NULL;
- doctypeName = NULL;
- doctypeSysid = NULL;
- doctypePubid = NULL;
- declAttributeType = NULL;
- declNotationName = NULL;
- declNotationPublicId = NULL;
- declAttributeIsCdata = XML_FALSE;
- declAttributeIsId = XML_FALSE;
- memset(&position, 0, sizeof(POSITION));
- errorCode = XML_ERROR_NONE;
- eventPtr = NULL;
- eventEndPtr = NULL;
- positionPtr = NULL;
- openInternalEntities = NULL;
- defaultExpandInternalEntities = XML_TRUE;
- tagLevel = 0;
- tagStack = NULL;
- inheritedBindings = NULL;
- nSpecifiedAtts = 0;
- unknownEncodingMem = NULL;
- unknownEncodingRelease = NULL;
- unknownEncodingData = NULL;
- parentParser = NULL;
- ps_parsing = XML_INITIALIZED;
+ parser->m_protocolEncodingName = copyString(encodingName, &(parser->m_mem));
+ }
+ parser->m_curBase = NULL;
+ XmlInitEncoding(&parser->m_initEncoding, &parser->m_encoding, 0);
+ parser->m_userData = NULL;
+ parser->m_handlerArg = NULL;
+ parser->m_startElementHandler = NULL;
+ parser->m_endElementHandler = NULL;
+ parser->m_characterDataHandler = NULL;
+ parser->m_processingInstructionHandler = NULL;
+ parser->m_commentHandler = NULL;
+ parser->m_startCdataSectionHandler = NULL;
+ parser->m_endCdataSectionHandler = NULL;
+ parser->m_defaultHandler = NULL;
+ parser->m_startDoctypeDeclHandler = NULL;
+ parser->m_endDoctypeDeclHandler = NULL;
+ parser->m_unparsedEntityDeclHandler = NULL;
+ parser->m_notationDeclHandler = NULL;
+ parser->m_startNamespaceDeclHandler = NULL;
+ parser->m_endNamespaceDeclHandler = NULL;
+ parser->m_notStandaloneHandler = NULL;
+ parser->m_externalEntityRefHandler = NULL;
+ parser->m_externalEntityRefHandlerArg = parser;
+ parser->m_skippedEntityHandler = NULL;
+ parser->m_elementDeclHandler = NULL;
+ parser->m_attlistDeclHandler = NULL;
+ parser->m_entityDeclHandler = NULL;
+ parser->m_xmlDeclHandler = NULL;
+ parser->m_bufferPtr = parser->m_buffer;
+ parser->m_bufferEnd = parser->m_buffer;
+ parser->m_parseEndByteIndex = 0;
+ parser->m_parseEndPtr = NULL;
+ parser->m_declElementType = NULL;
+ parser->m_declAttributeId = NULL;
+ parser->m_declEntity = NULL;
+ parser->m_doctypeName = NULL;
+ parser->m_doctypeSysid = NULL;
+ parser->m_doctypePubid = NULL;
+ parser->m_declAttributeType = NULL;
+ parser->m_declNotationName = NULL;
+ parser->m_declNotationPublicId = NULL;
+ parser->m_declAttributeIsCdata = XML_FALSE;
+ parser->m_declAttributeIsId = XML_FALSE;
+ memset(&parser->m_position, 0, sizeof(POSITION));
+ parser->m_errorCode = XML_ERROR_NONE;
+ parser->m_eventPtr = NULL;
+ parser->m_eventEndPtr = NULL;
+ parser->m_positionPtr = NULL;
+ parser->m_openInternalEntities = NULL;
+ parser->m_defaultExpandInternalEntities = XML_TRUE;
+ parser->m_tagLevel = 0;
+ parser->m_tagStack = NULL;
+ parser->m_inheritedBindings = NULL;
+ parser->m_nSpecifiedAtts = 0;
+ parser->m_unknownEncodingMem = NULL;
+ parser->m_unknownEncodingRelease = NULL;
+ parser->m_unknownEncodingData = NULL;
+ parser->m_parentParser = NULL;
+ parser->m_parsingStatus.parsing = XML_INITIALIZED;
#ifdef XML_DTD
- isParamEntity = XML_FALSE;
- useForeignDTD = XML_FALSE;
- paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
+ parser->m_isParamEntity = XML_FALSE;
+ parser->m_useForeignDTD = XML_FALSE;
+ parser->m_paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
#endif
- hash_secret_salt = 0;
+ parser->m_hash_secret_salt = 0;
}
-/* moves list of bindings to freeBindingList */
+/* moves list of bindings to m_freeBindingList */
static void FASTCALL
-moveToFreeBindingList(XML_Parser parser, BINDING *bindings)
-{
+moveToFreeBindingList(XML_Parser parser, BINDING *bindings) {
while (bindings) {
BINDING *b = bindings;
bindings = bindings->nextTagBinding;
- b->nextTagBinding = freeBindingList;
- freeBindingList = b;
+ b->nextTagBinding = parser->m_freeBindingList;
+ parser->m_freeBindingList = b;
}
}
XML_Bool XMLCALL
-XML_ParserReset(XML_Parser parser, const XML_Char *encodingName)
-{
+XML_ParserReset(XML_Parser parser, const XML_Char *encodingName) {
TAG *tStk;
OPEN_INTERNAL_ENTITY *openEntityList;
if (parser == NULL)
- return XML_FALSE;
+ return XML_FALSE;
- if (parentParser)
+ if (parser->m_parentParser)
return XML_FALSE;
- /* move tagStack to freeTagList */
- tStk = tagStack;
+ /* move m_tagStack to m_freeTagList */
+ tStk = parser->m_tagStack;
while (tStk) {
TAG *tag = tStk;
tStk = tStk->parent;
- tag->parent = freeTagList;
+ tag->parent = parser->m_freeTagList;
moveToFreeBindingList(parser, tag->bindings);
tag->bindings = NULL;
- freeTagList = tag;
+ parser->m_freeTagList = tag;
}
- /* move openInternalEntities to freeInternalEntities */
- openEntityList = openInternalEntities;
+ /* move m_openInternalEntities to m_freeInternalEntities */
+ openEntityList = parser->m_openInternalEntities;
while (openEntityList) {
OPEN_INTERNAL_ENTITY *openEntity = openEntityList;
openEntityList = openEntity->next;
- openEntity->next = freeInternalEntities;
- freeInternalEntities = openEntity;
- }
- moveToFreeBindingList(parser, inheritedBindings);
- FREE(unknownEncodingMem);
- if (unknownEncodingRelease)
- unknownEncodingRelease(unknownEncodingData);
- poolClear(&tempPool);
- poolClear(&temp2Pool);
- FREE((void *)protocolEncodingName);
- protocolEncodingName = NULL;
+ openEntity->next = parser->m_freeInternalEntities;
+ parser->m_freeInternalEntities = openEntity;
+ }
+ moveToFreeBindingList(parser, parser->m_inheritedBindings);
+ FREE(parser, parser->m_unknownEncodingMem);
+ if (parser->m_unknownEncodingRelease)
+ parser->m_unknownEncodingRelease(parser->m_unknownEncodingData);
+ poolClear(&parser->m_tempPool);
+ poolClear(&parser->m_temp2Pool);
+ FREE(parser, (void *)parser->m_protocolEncodingName);
+ parser->m_protocolEncodingName = NULL;
parserInit(parser, encodingName);
- dtdReset(_dtd, &parser->m_mem);
+ dtdReset(parser->m_dtd, &parser->m_mem);
return XML_TRUE;
}
enum XML_Status XMLCALL
-XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName)
-{
+XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName) {
if (parser == NULL)
- return XML_STATUS_ERROR;
+ return XML_STATUS_ERROR;
/* Block after XML_Parse()/XML_ParseBuffer() has been called.
XXX There's no way for the caller to determine which of the
XXX possible error cases caused the XML_STATUS_ERROR return.
*/
- if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED)
+ if (parser->m_parsingStatus.parsing == XML_PARSING
+ || parser->m_parsingStatus.parsing == XML_SUSPENDED)
return XML_STATUS_ERROR;
/* Get rid of any previous encoding name */
- FREE((void *)protocolEncodingName);
+ FREE(parser, (void *)parser->m_protocolEncodingName);
if (encodingName == NULL)
/* No new encoding name */
- protocolEncodingName = NULL;
+ parser->m_protocolEncodingName = NULL;
else {
/* Copy the new encoding name into allocated memory */
- protocolEncodingName = copyString(encodingName, &(parser->m_mem));
- if (!protocolEncodingName)
+ parser->m_protocolEncodingName = copyString(encodingName, &(parser->m_mem));
+ if (! parser->m_protocolEncodingName)
return XML_STATUS_ERROR;
}
return XML_STATUS_OK;
}
XML_Parser XMLCALL
-XML_ExternalEntityParserCreate(XML_Parser oldParser,
- const XML_Char *context,
- const XML_Char *encodingName)
-{
+XML_ExternalEntityParserCreate(XML_Parser oldParser, const XML_Char *context,
+ const XML_Char *encodingName) {
XML_Parser parser = oldParser;
DTD *newDtd = NULL;
DTD *oldDtd;
@@ -1285,7 +1162,7 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser,
XML_AttlistDeclHandler oldAttlistDeclHandler;
XML_EntityDeclHandler oldEntityDeclHandler;
XML_XmlDeclHandler oldXmlDeclHandler;
- ELEMENT_TYPE * oldDeclElementType;
+ ELEMENT_TYPE *oldDeclElementType;
void *oldUserData;
void *oldHandlerArg;
@@ -1308,47 +1185,47 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser,
return NULL;
/* Stash the original parser contents on the stack */
- oldDtd = _dtd;
- oldStartElementHandler = startElementHandler;
- oldEndElementHandler = endElementHandler;
- oldCharacterDataHandler = characterDataHandler;
- oldProcessingInstructionHandler = processingInstructionHandler;
- oldCommentHandler = commentHandler;
- oldStartCdataSectionHandler = startCdataSectionHandler;
- oldEndCdataSectionHandler = endCdataSectionHandler;
- oldDefaultHandler = defaultHandler;
- oldUnparsedEntityDeclHandler = unparsedEntityDeclHandler;
- oldNotationDeclHandler = notationDeclHandler;
- oldStartNamespaceDeclHandler = startNamespaceDeclHandler;
- oldEndNamespaceDeclHandler = endNamespaceDeclHandler;
- oldNotStandaloneHandler = notStandaloneHandler;
- oldExternalEntityRefHandler = externalEntityRefHandler;
- oldSkippedEntityHandler = skippedEntityHandler;
- oldUnknownEncodingHandler = unknownEncodingHandler;
- oldElementDeclHandler = elementDeclHandler;
- oldAttlistDeclHandler = attlistDeclHandler;
- oldEntityDeclHandler = entityDeclHandler;
- oldXmlDeclHandler = xmlDeclHandler;
- oldDeclElementType = declElementType;
-
- oldUserData = userData;
- oldHandlerArg = handlerArg;
- oldDefaultExpandInternalEntities = defaultExpandInternalEntities;
- oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg;
+ oldDtd = parser->m_dtd;
+ oldStartElementHandler = parser->m_startElementHandler;
+ oldEndElementHandler = parser->m_endElementHandler;
+ oldCharacterDataHandler = parser->m_characterDataHandler;
+ oldProcessingInstructionHandler = parser->m_processingInstructionHandler;
+ oldCommentHandler = parser->m_commentHandler;
+ oldStartCdataSectionHandler = parser->m_startCdataSectionHandler;
+ oldEndCdataSectionHandler = parser->m_endCdataSectionHandler;
+ oldDefaultHandler = parser->m_defaultHandler;
+ oldUnparsedEntityDeclHandler = parser->m_unparsedEntityDeclHandler;
+ oldNotationDeclHandler = parser->m_notationDeclHandler;
+ oldStartNamespaceDeclHandler = parser->m_startNamespaceDeclHandler;
+ oldEndNamespaceDeclHandler = parser->m_endNamespaceDeclHandler;
+ oldNotStandaloneHandler = parser->m_notStandaloneHandler;
+ oldExternalEntityRefHandler = parser->m_externalEntityRefHandler;
+ oldSkippedEntityHandler = parser->m_skippedEntityHandler;
+ oldUnknownEncodingHandler = parser->m_unknownEncodingHandler;
+ oldElementDeclHandler = parser->m_elementDeclHandler;
+ oldAttlistDeclHandler = parser->m_attlistDeclHandler;
+ oldEntityDeclHandler = parser->m_entityDeclHandler;
+ oldXmlDeclHandler = parser->m_xmlDeclHandler;
+ oldDeclElementType = parser->m_declElementType;
+
+ oldUserData = parser->m_userData;
+ oldHandlerArg = parser->m_handlerArg;
+ oldDefaultExpandInternalEntities = parser->m_defaultExpandInternalEntities;
+ oldExternalEntityRefHandlerArg = parser->m_externalEntityRefHandlerArg;
#ifdef XML_DTD
- oldParamEntityParsing = paramEntityParsing;
- oldInEntityValue = prologState.inEntityValue;
+ oldParamEntityParsing = parser->m_paramEntityParsing;
+ oldInEntityValue = parser->m_prologState.inEntityValue;
#endif
- oldns_triplets = ns_triplets;
+ oldns_triplets = parser->m_ns_triplets;
/* Note that the new parser shares the same hash secret as the old
parser, so that dtdCopy and copyEntityTable can lookup values
from hash tables associated with either parser without us having
to worry which hash secrets each table has.
*/
- oldhash_secret_salt = hash_secret_salt;
+ oldhash_secret_salt = parser->m_hash_secret_salt;
#ifdef XML_DTD
- if (!context)
+ if (! context)
newDtd = oldDtd;
#endif /* XML_DTD */
@@ -1357,175 +1234,171 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser,
here. This makes this function more painful to follow than it
would be otherwise.
*/
- if (ns) {
+ if (parser->m_ns) {
XML_Char tmp[2];
- *tmp = namespaceSeparator;
+ *tmp = parser->m_namespaceSeparator;
parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd);
- }
- else {
+ } else {
parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd);
}
- if (!parser)
+ if (! parser)
return NULL;
- startElementHandler = oldStartElementHandler;
- endElementHandler = oldEndElementHandler;
- characterDataHandler = oldCharacterDataHandler;
- processingInstructionHandler = oldProcessingInstructionHandler;
- commentHandler = oldCommentHandler;
- startCdataSectionHandler = oldStartCdataSectionHandler;
- endCdataSectionHandler = oldEndCdataSectionHandler;
- defaultHandler = oldDefaultHandler;
- unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler;
- notationDeclHandler = oldNotationDeclHandler;
- startNamespaceDeclHandler = oldStartNamespaceDeclHandler;
- endNamespaceDeclHandler = oldEndNamespaceDeclHandler;
- notStandaloneHandler = oldNotStandaloneHandler;
- externalEntityRefHandler = oldExternalEntityRefHandler;
- skippedEntityHandler = oldSkippedEntityHandler;
- unknownEncodingHandler = oldUnknownEncodingHandler;
- elementDeclHandler = oldElementDeclHandler;
- attlistDeclHandler = oldAttlistDeclHandler;
- entityDeclHandler = oldEntityDeclHandler;
- xmlDeclHandler = oldXmlDeclHandler;
- declElementType = oldDeclElementType;
- userData = oldUserData;
+ parser->m_startElementHandler = oldStartElementHandler;
+ parser->m_endElementHandler = oldEndElementHandler;
+ parser->m_characterDataHandler = oldCharacterDataHandler;
+ parser->m_processingInstructionHandler = oldProcessingInstructionHandler;
+ parser->m_commentHandler = oldCommentHandler;
+ parser->m_startCdataSectionHandler = oldStartCdataSectionHandler;
+ parser->m_endCdataSectionHandler = oldEndCdataSectionHandler;
+ parser->m_defaultHandler = oldDefaultHandler;
+ parser->m_unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler;
+ parser->m_notationDeclHandler = oldNotationDeclHandler;
+ parser->m_startNamespaceDeclHandler = oldStartNamespaceDeclHandler;
+ parser->m_endNamespaceDeclHandler = oldEndNamespaceDeclHandler;
+ parser->m_notStandaloneHandler = oldNotStandaloneHandler;
+ parser->m_externalEntityRefHandler = oldExternalEntityRefHandler;
+ parser->m_skippedEntityHandler = oldSkippedEntityHandler;
+ parser->m_unknownEncodingHandler = oldUnknownEncodingHandler;
+ parser->m_elementDeclHandler = oldElementDeclHandler;
+ parser->m_attlistDeclHandler = oldAttlistDeclHandler;
+ parser->m_entityDeclHandler = oldEntityDeclHandler;
+ parser->m_xmlDeclHandler = oldXmlDeclHandler;
+ parser->m_declElementType = oldDeclElementType;
+ parser->m_userData = oldUserData;
if (oldUserData == oldHandlerArg)
- handlerArg = userData;
+ parser->m_handlerArg = parser->m_userData;
else
- handlerArg = parser;
+ parser->m_handlerArg = parser;
if (oldExternalEntityRefHandlerArg != oldParser)
- externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg;
- defaultExpandInternalEntities = oldDefaultExpandInternalEntities;
- ns_triplets = oldns_triplets;
- hash_secret_salt = oldhash_secret_salt;
- parentParser = oldParser;
+ parser->m_externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg;
+ parser->m_defaultExpandInternalEntities = oldDefaultExpandInternalEntities;
+ parser->m_ns_triplets = oldns_triplets;
+ parser->m_hash_secret_salt = oldhash_secret_salt;
+ parser->m_parentParser = oldParser;
#ifdef XML_DTD
- paramEntityParsing = oldParamEntityParsing;
- prologState.inEntityValue = oldInEntityValue;
+ parser->m_paramEntityParsing = oldParamEntityParsing;
+ parser->m_prologState.inEntityValue = oldInEntityValue;
if (context) {
#endif /* XML_DTD */
- if (!dtdCopy(oldParser, _dtd, oldDtd, &parser->m_mem)
- || !setContext(parser, context)) {
+ if (! dtdCopy(oldParser, parser->m_dtd, oldDtd, &parser->m_mem)
+ || ! setContext(parser, context)) {
XML_ParserFree(parser);
return NULL;
}
- processor = externalEntityInitProcessor;
+ parser->m_processor = externalEntityInitProcessor;
#ifdef XML_DTD
- }
- else {
- /* The DTD instance referenced by _dtd is shared between the document's
- root parser and external PE parsers, therefore one does not need to
- call setContext. In addition, one also *must* not call setContext,
- because this would overwrite existing prefix->binding pointers in
- _dtd with ones that get destroyed with the external PE parser.
- This would leave those prefixes with dangling pointers.
+ } else {
+ /* The DTD instance referenced by parser->m_dtd is shared between the
+ document's root parser and external PE parsers, therefore one does not
+ need to call setContext. In addition, one also *must* not call
+ setContext, because this would overwrite existing prefix->binding
+ pointers in parser->m_dtd with ones that get destroyed with the external
+ PE parser. This would leave those prefixes with dangling pointers.
*/
- isParamEntity = XML_TRUE;
- XmlPrologStateInitExternalEntity(&prologState);
- processor = externalParEntInitProcessor;
+ parser->m_isParamEntity = XML_TRUE;
+ XmlPrologStateInitExternalEntity(&parser->m_prologState);
+ parser->m_processor = externalParEntInitProcessor;
}
#endif /* XML_DTD */
return parser;
}
static void FASTCALL
-destroyBindings(BINDING *bindings, XML_Parser parser)
-{
+destroyBindings(BINDING *bindings, XML_Parser parser) {
for (;;) {
BINDING *b = bindings;
- if (!b)
+ if (! b)
break;
bindings = b->nextTagBinding;
- FREE(b->uri);
- FREE(b);
+ FREE(parser, b->uri);
+ FREE(parser, b);
}
}
void XMLCALL
-XML_ParserFree(XML_Parser parser)
-{
+XML_ParserFree(XML_Parser parser) {
TAG *tagList;
OPEN_INTERNAL_ENTITY *entityList;
if (parser == NULL)
return;
- /* free tagStack and freeTagList */
- tagList = tagStack;
+ /* free m_tagStack and m_freeTagList */
+ tagList = parser->m_tagStack;
for (;;) {
TAG *p;
if (tagList == NULL) {
- if (freeTagList == NULL)
+ if (parser->m_freeTagList == NULL)
break;
- tagList = freeTagList;
- freeTagList = NULL;
+ tagList = parser->m_freeTagList;
+ parser->m_freeTagList = NULL;
}
p = tagList;
tagList = tagList->parent;
- FREE(p->buf);
+ FREE(parser, p->buf);
destroyBindings(p->bindings, parser);
- FREE(p);
+ FREE(parser, p);
}
- /* free openInternalEntities and freeInternalEntities */
- entityList = openInternalEntities;
+ /* free m_openInternalEntities and m_freeInternalEntities */
+ entityList = parser->m_openInternalEntities;
for (;;) {
OPEN_INTERNAL_ENTITY *openEntity;
if (entityList == NULL) {
- if (freeInternalEntities == NULL)
+ if (parser->m_freeInternalEntities == NULL)
break;
- entityList = freeInternalEntities;
- freeInternalEntities = NULL;
+ entityList = parser->m_freeInternalEntities;
+ parser->m_freeInternalEntities = NULL;
}
openEntity = entityList;
entityList = entityList->next;
- FREE(openEntity);
+ FREE(parser, openEntity);
}
- destroyBindings(freeBindingList, parser);
- destroyBindings(inheritedBindings, parser);
- poolDestroy(&tempPool);
- poolDestroy(&temp2Pool);
- FREE((void *)protocolEncodingName);
+ destroyBindings(parser->m_freeBindingList, parser);
+ destroyBindings(parser->m_inheritedBindings, parser);
+ poolDestroy(&parser->m_tempPool);
+ poolDestroy(&parser->m_temp2Pool);
+ FREE(parser, (void *)parser->m_protocolEncodingName);
#ifdef XML_DTD
/* external parameter entity parsers share the DTD structure
parser->m_dtd with the root parser, so we must not destroy it
*/
- if (!isParamEntity && _dtd)
+ if (! parser->m_isParamEntity && parser->m_dtd)
#else
- if (_dtd)
+ if (parser->m_dtd)
#endif /* XML_DTD */
- dtdDestroy(_dtd, (XML_Bool)!parentParser, &parser->m_mem);
- FREE((void *)atts);
+ dtdDestroy(parser->m_dtd, (XML_Bool)! parser->m_parentParser,
+ &parser->m_mem);
+ FREE(parser, (void *)parser->m_atts);
#ifdef XML_ATTR_INFO
- FREE((void *)attInfo);
+ FREE(parser, (void *)parser->m_attInfo);
#endif
- FREE(groupConnector);
- FREE(buffer);
- FREE(dataBuf);
- FREE(nsAtts);
- FREE(unknownEncodingMem);
- if (unknownEncodingRelease)
- unknownEncodingRelease(unknownEncodingData);
- FREE(parser);
+ FREE(parser, parser->m_groupConnector);
+ FREE(parser, parser->m_buffer);
+ FREE(parser, parser->m_dataBuf);
+ FREE(parser, parser->m_nsAtts);
+ FREE(parser, parser->m_unknownEncodingMem);
+ if (parser->m_unknownEncodingRelease)
+ parser->m_unknownEncodingRelease(parser->m_unknownEncodingData);
+ FREE(parser, parser);
}
void XMLCALL
-XML_UseParserAsHandlerArg(XML_Parser parser)
-{
+XML_UseParserAsHandlerArg(XML_Parser parser) {
if (parser != NULL)
- handlerArg = parser;
+ parser->m_handlerArg = parser;
}
enum XML_Error XMLCALL
-XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD)
-{
+XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD) {
if (parser == NULL)
return XML_ERROR_INVALID_ARGUMENT;
#ifdef XML_DTD
/* block after XML_Parse()/XML_ParseBuffer() has been called */
- if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED)
+ if (parser->m_parsingStatus.parsing == XML_PARSING
+ || parser->m_parsingStatus.parsing == XML_SUSPENDED)
return XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING;
- useForeignDTD = useDTD;
+ parser->m_useForeignDTD = useDTD;
return XML_ERROR_NONE;
#else
return XML_ERROR_FEATURE_REQUIRES_XML_DTD;
@@ -1533,325 +1406,285 @@ XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD)
}
void XMLCALL
-XML_SetReturnNSTriplet(XML_Parser parser, int do_nst)
-{
+XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) {
if (parser == NULL)
return;
/* block after XML_Parse()/XML_ParseBuffer() has been called */
- if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED)
+ if (parser->m_parsingStatus.parsing == XML_PARSING
+ || parser->m_parsingStatus.parsing == XML_SUSPENDED)
return;
- ns_triplets = do_nst ? XML_TRUE : XML_FALSE;
+ parser->m_ns_triplets = do_nst ? XML_TRUE : XML_FALSE;
}
void XMLCALL
-XML_SetUserData(XML_Parser parser, void *p)
-{
+XML_SetUserData(XML_Parser parser, void *p) {
if (parser == NULL)
return;
- if (handlerArg == userData)
- handlerArg = userData = p;
+ if (parser->m_handlerArg == parser->m_userData)
+ parser->m_handlerArg = parser->m_userData = p;
else
- userData = p;
+ parser->m_userData = p;
}
enum XML_Status XMLCALL
-XML_SetBase(XML_Parser parser, const XML_Char *p)
-{
+XML_SetBase(XML_Parser parser, const XML_Char *p) {
if (parser == NULL)
return XML_STATUS_ERROR;
if (p) {
- p = poolCopyString(&_dtd->pool, p);
- if (!p)
+ p = poolCopyString(&parser->m_dtd->pool, p);
+ if (! p)
return XML_STATUS_ERROR;
- curBase = p;
- }
- else
- curBase = NULL;
+ parser->m_curBase = p;
+ } else
+ parser->m_curBase = NULL;
return XML_STATUS_OK;
}
-const XML_Char * XMLCALL
-XML_GetBase(XML_Parser parser)
-{
+const XML_Char *XMLCALL
+XML_GetBase(XML_Parser parser) {
if (parser == NULL)
return NULL;
- return curBase;
+ return parser->m_curBase;
}
int XMLCALL
-XML_GetSpecifiedAttributeCount(XML_Parser parser)
-{
+XML_GetSpecifiedAttributeCount(XML_Parser parser) {
if (parser == NULL)
return -1;
- return nSpecifiedAtts;
+ return parser->m_nSpecifiedAtts;
}
int XMLCALL
-XML_GetIdAttributeIndex(XML_Parser parser)
-{
+XML_GetIdAttributeIndex(XML_Parser parser) {
if (parser == NULL)
return -1;
- return idAttIndex;
+ return parser->m_idAttIndex;
}
#ifdef XML_ATTR_INFO
-const XML_AttrInfo * XMLCALL
-XML_GetAttributeInfo(XML_Parser parser)
-{
+const XML_AttrInfo *XMLCALL
+XML_GetAttributeInfo(XML_Parser parser) {
if (parser == NULL)
return NULL;
- return attInfo;
+ return parser->m_attInfo;
}
#endif
void XMLCALL
-XML_SetElementHandler(XML_Parser parser,
- XML_StartElementHandler start,
- XML_EndElementHandler end)
-{
+XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start,
+ XML_EndElementHandler end) {
if (parser == NULL)
return;
- startElementHandler = start;
- endElementHandler = end;
+ parser->m_startElementHandler = start;
+ parser->m_endElementHandler = end;
}
void XMLCALL
-XML_SetStartElementHandler(XML_Parser parser,
- XML_StartElementHandler start) {
+XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler start) {
if (parser != NULL)
- startElementHandler = start;
+ parser->m_startElementHandler = start;
}
void XMLCALL
-XML_SetEndElementHandler(XML_Parser parser,
- XML_EndElementHandler end) {
+XML_SetEndElementHandler(XML_Parser parser, XML_EndElementHandler end) {
if (parser != NULL)
- endElementHandler = end;
+ parser->m_endElementHandler = end;
}
void XMLCALL
XML_SetCharacterDataHandler(XML_Parser parser,
- XML_CharacterDataHandler handler)
-{
+ XML_CharacterDataHandler handler) {
if (parser != NULL)
- characterDataHandler = handler;
+ parser->m_characterDataHandler = handler;
}
void XMLCALL
XML_SetProcessingInstructionHandler(XML_Parser parser,
- XML_ProcessingInstructionHandler handler)
-{
+ XML_ProcessingInstructionHandler handler) {
if (parser != NULL)
- processingInstructionHandler = handler;
+ parser->m_processingInstructionHandler = handler;
}
void XMLCALL
-XML_SetCommentHandler(XML_Parser parser,
- XML_CommentHandler handler)
-{
+XML_SetCommentHandler(XML_Parser parser, XML_CommentHandler handler) {
if (parser != NULL)
- commentHandler = handler;
+ parser->m_commentHandler = handler;
}
void XMLCALL
XML_SetCdataSectionHandler(XML_Parser parser,
XML_StartCdataSectionHandler start,
- XML_EndCdataSectionHandler end)
-{
+ XML_EndCdataSectionHandler end) {
if (parser == NULL)
return;
- startCdataSectionHandler = start;
- endCdataSectionHandler = end;
+ parser->m_startCdataSectionHandler = start;
+ parser->m_endCdataSectionHandler = end;
}
void XMLCALL
XML_SetStartCdataSectionHandler(XML_Parser parser,
XML_StartCdataSectionHandler start) {
if (parser != NULL)
- startCdataSectionHandler = start;
+ parser->m_startCdataSectionHandler = start;
}
void XMLCALL
XML_SetEndCdataSectionHandler(XML_Parser parser,
XML_EndCdataSectionHandler end) {
if (parser != NULL)
- endCdataSectionHandler = end;
+ parser->m_endCdataSectionHandler = end;
}
void XMLCALL
-XML_SetDefaultHandler(XML_Parser parser,
- XML_DefaultHandler handler)
-{
+XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler handler) {
if (parser == NULL)
return;
- defaultHandler = handler;
- defaultExpandInternalEntities = XML_FALSE;
+ parser->m_defaultHandler = handler;
+ parser->m_defaultExpandInternalEntities = XML_FALSE;
}
void XMLCALL
-XML_SetDefaultHandlerExpand(XML_Parser parser,
- XML_DefaultHandler handler)
-{
+XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler) {
if (parser == NULL)
return;
- defaultHandler = handler;
- defaultExpandInternalEntities = XML_TRUE;
+ parser->m_defaultHandler = handler;
+ parser->m_defaultExpandInternalEntities = XML_TRUE;
}
void XMLCALL
-XML_SetDoctypeDeclHandler(XML_Parser parser,
- XML_StartDoctypeDeclHandler start,
- XML_EndDoctypeDeclHandler end)
-{
+XML_SetDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start,
+ XML_EndDoctypeDeclHandler end) {
if (parser == NULL)
return;
- startDoctypeDeclHandler = start;
- endDoctypeDeclHandler = end;
+ parser->m_startDoctypeDeclHandler = start;
+ parser->m_endDoctypeDeclHandler = end;
}
void XMLCALL
XML_SetStartDoctypeDeclHandler(XML_Parser parser,
XML_StartDoctypeDeclHandler start) {
if (parser != NULL)
- startDoctypeDeclHandler = start;
+ parser->m_startDoctypeDeclHandler = start;
}
void XMLCALL
-XML_SetEndDoctypeDeclHandler(XML_Parser parser,
- XML_EndDoctypeDeclHandler end) {
+XML_SetEndDoctypeDeclHandler(XML_Parser parser, XML_EndDoctypeDeclHandler end) {
if (parser != NULL)
- endDoctypeDeclHandler = end;
+ parser->m_endDoctypeDeclHandler = end;
}
void XMLCALL
XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
- XML_UnparsedEntityDeclHandler handler)
-{
+ XML_UnparsedEntityDeclHandler handler) {
if (parser != NULL)
- unparsedEntityDeclHandler = handler;
+ parser->m_unparsedEntityDeclHandler = handler;
}
void XMLCALL
-XML_SetNotationDeclHandler(XML_Parser parser,
- XML_NotationDeclHandler handler)
-{
+XML_SetNotationDeclHandler(XML_Parser parser, XML_NotationDeclHandler handler) {
if (parser != NULL)
- notationDeclHandler = handler;
+ parser->m_notationDeclHandler = handler;
}
void XMLCALL
XML_SetNamespaceDeclHandler(XML_Parser parser,
XML_StartNamespaceDeclHandler start,
- XML_EndNamespaceDeclHandler end)
-{
+ XML_EndNamespaceDeclHandler end) {
if (parser == NULL)
return;
- startNamespaceDeclHandler = start;
- endNamespaceDeclHandler = end;
+ parser->m_startNamespaceDeclHandler = start;
+ parser->m_endNamespaceDeclHandler = end;
}
void XMLCALL
XML_SetStartNamespaceDeclHandler(XML_Parser parser,
XML_StartNamespaceDeclHandler start) {
if (parser != NULL)
- startNamespaceDeclHandler = start;
+ parser->m_startNamespaceDeclHandler = start;
}
void XMLCALL
XML_SetEndNamespaceDeclHandler(XML_Parser parser,
XML_EndNamespaceDeclHandler end) {
if (parser != NULL)
- endNamespaceDeclHandler = end;
+ parser->m_endNamespaceDeclHandler = end;
}
void XMLCALL
XML_SetNotStandaloneHandler(XML_Parser parser,
- XML_NotStandaloneHandler handler)
-{
+ XML_NotStandaloneHandler handler) {
if (parser != NULL)
- notStandaloneHandler = handler;
+ parser->m_notStandaloneHandler = handler;
}
void XMLCALL
XML_SetExternalEntityRefHandler(XML_Parser parser,
- XML_ExternalEntityRefHandler handler)
-{
+ XML_ExternalEntityRefHandler handler) {
if (parser != NULL)
- externalEntityRefHandler = handler;
+ parser->m_externalEntityRefHandler = handler;
}
void XMLCALL
-XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg)
-{
+XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) {
if (parser == NULL)
return;
if (arg)
- externalEntityRefHandlerArg = (XML_Parser)arg;
+ parser->m_externalEntityRefHandlerArg = (XML_Parser)arg;
else
- externalEntityRefHandlerArg = parser;
+ parser->m_externalEntityRefHandlerArg = parser;
}
void XMLCALL
XML_SetSkippedEntityHandler(XML_Parser parser,
- XML_SkippedEntityHandler handler)
-{
+ XML_SkippedEntityHandler handler) {
if (parser != NULL)
- skippedEntityHandler = handler;
+ parser->m_skippedEntityHandler = handler;
}
void XMLCALL
XML_SetUnknownEncodingHandler(XML_Parser parser,
- XML_UnknownEncodingHandler handler,
- void *data)
-{
+ XML_UnknownEncodingHandler handler, void *data) {
if (parser == NULL)
return;
- unknownEncodingHandler = handler;
- unknownEncodingHandlerData = data;
+ parser->m_unknownEncodingHandler = handler;
+ parser->m_unknownEncodingHandlerData = data;
}
void XMLCALL
-XML_SetElementDeclHandler(XML_Parser parser,
- XML_ElementDeclHandler eldecl)
-{
+XML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl) {
if (parser != NULL)
- elementDeclHandler = eldecl;
+ parser->m_elementDeclHandler = eldecl;
}
void XMLCALL
-XML_SetAttlistDeclHandler(XML_Parser parser,
- XML_AttlistDeclHandler attdecl)
-{
+XML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl) {
if (parser != NULL)
- attlistDeclHandler = attdecl;
+ parser->m_attlistDeclHandler = attdecl;
}
void XMLCALL
-XML_SetEntityDeclHandler(XML_Parser parser,
- XML_EntityDeclHandler handler)
-{
+XML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler) {
if (parser != NULL)
- entityDeclHandler = handler;
+ parser->m_entityDeclHandler = handler;
}
void XMLCALL
-XML_SetXmlDeclHandler(XML_Parser parser,
- XML_XmlDeclHandler handler) {
+XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler handler) {
if (parser != NULL)
- xmlDeclHandler = handler;
+ parser->m_xmlDeclHandler = handler;
}
int XMLCALL
XML_SetParamEntityParsing(XML_Parser parser,
- enum XML_ParamEntityParsing peParsing)
-{
+ enum XML_ParamEntityParsing peParsing) {
if (parser == NULL)
return 0;
/* block after XML_Parse()/XML_ParseBuffer() has been called */
- if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED)
+ if (parser->m_parsingStatus.parsing == XML_PARSING
+ || parser->m_parsingStatus.parsing == XML_SUSPENDED)
return 0;
#ifdef XML_DTD
- paramEntityParsing = peParsing;
+ parser->m_paramEntityParsing = peParsing;
return 1;
#else
return peParsing == XML_PARAM_ENTITY_PARSING_NEVER;
@@ -1859,59 +1692,60 @@ XML_SetParamEntityParsing(XML_Parser parser,
}
int XMLCALL
-XML_SetHashSalt(XML_Parser parser,
- unsigned long hash_salt)
-{
+XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt) {
if (parser == NULL)
return 0;
if (parser->m_parentParser)
return XML_SetHashSalt(parser->m_parentParser, hash_salt);
/* block after XML_Parse()/XML_ParseBuffer() has been called */
- if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED)
+ if (parser->m_parsingStatus.parsing == XML_PARSING
+ || parser->m_parsingStatus.parsing == XML_SUSPENDED)
return 0;
- hash_secret_salt = hash_salt;
+ parser->m_hash_secret_salt = hash_salt;
return 1;
}
enum XML_Status XMLCALL
-XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
-{
+XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) {
if ((parser == NULL) || (len < 0) || ((s == NULL) && (len != 0))) {
if (parser != NULL)
parser->m_errorCode = XML_ERROR_INVALID_ARGUMENT;
return XML_STATUS_ERROR;
}
- switch (ps_parsing) {
+ switch (parser->m_parsingStatus.parsing) {
case XML_SUSPENDED:
- errorCode = XML_ERROR_SUSPENDED;
+ parser->m_errorCode = XML_ERROR_SUSPENDED;
return XML_STATUS_ERROR;
case XML_FINISHED:
- errorCode = XML_ERROR_FINISHED;
+ parser->m_errorCode = XML_ERROR_FINISHED;
return XML_STATUS_ERROR;
case XML_INITIALIZED:
- if (parentParser == NULL && !startParsing(parser)) {
- errorCode = XML_ERROR_NO_MEMORY;
+ if (parser->m_parentParser == NULL && ! startParsing(parser)) {
+ parser->m_errorCode = XML_ERROR_NO_MEMORY;
return XML_STATUS_ERROR;
}
+ /* fall through */
default:
- ps_parsing = XML_PARSING;
+ parser->m_parsingStatus.parsing = XML_PARSING;
}
if (len == 0) {
- ps_finalBuffer = (XML_Bool)isFinal;
- if (!isFinal)
+ parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal;
+ if (! isFinal)
return XML_STATUS_OK;
- positionPtr = bufferPtr;
- parseEndPtr = bufferEnd;
+ parser->m_positionPtr = parser->m_bufferPtr;
+ parser->m_parseEndPtr = parser->m_bufferEnd;
/* If data are left over from last buffer, and we now know that these
data are the final chunk of input, then we have to check them again
to detect errors based on that fact.
*/
- errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr);
+ parser->m_errorCode
+ = parser->m_processor(parser, parser->m_bufferPtr,
+ parser->m_parseEndPtr, &parser->m_bufferPtr);
- if (errorCode == XML_ERROR_NONE) {
- switch (ps_parsing) {
+ if (parser->m_errorCode == XML_ERROR_NONE) {
+ switch (parser->m_parsingStatus.parsing) {
case XML_SUSPENDED:
/* It is hard to be certain, but it seems that this case
* cannot occur. This code is cleaning up a previous parse
@@ -1925,54 +1759,55 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
*
* LCOV_EXCL_START
*/
- XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position);
- positionPtr = bufferPtr;
+ XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr,
+ parser->m_bufferPtr, &parser->m_position);
+ parser->m_positionPtr = parser->m_bufferPtr;
return XML_STATUS_SUSPENDED;
/* LCOV_EXCL_STOP */
case XML_INITIALIZED:
case XML_PARSING:
- ps_parsing = XML_FINISHED;
+ parser->m_parsingStatus.parsing = XML_FINISHED;
/* fall through */
default:
return XML_STATUS_OK;
}
}
- eventEndPtr = eventPtr;
- processor = errorProcessor;
+ parser->m_eventEndPtr = parser->m_eventPtr;
+ parser->m_processor = errorProcessor;
return XML_STATUS_ERROR;
}
#ifndef XML_CONTEXT_BYTES
- else if (bufferPtr == bufferEnd) {
+ else if (parser->m_bufferPtr == parser->m_bufferEnd) {
const char *end;
int nLeftOver;
enum XML_Status result;
/* Detect overflow (a+b > MAX <==> b > MAX-a) */
- if (len > ((XML_Size)-1) / 2 - parseEndByteIndex) {
- errorCode = XML_ERROR_NO_MEMORY;
- eventPtr = eventEndPtr = NULL;
- processor = errorProcessor;
- return XML_STATUS_ERROR;
+ if (len > ((XML_Size)-1) / 2 - parser->m_parseEndByteIndex) {
+ parser->m_errorCode = XML_ERROR_NO_MEMORY;
+ parser->m_eventPtr = parser->m_eventEndPtr = NULL;
+ parser->m_processor = errorProcessor;
+ return XML_STATUS_ERROR;
}
- parseEndByteIndex += len;
- positionPtr = s;
- ps_finalBuffer = (XML_Bool)isFinal;
+ parser->m_parseEndByteIndex += len;
+ parser->m_positionPtr = s;
+ parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal;
- errorCode = processor(parser, s, parseEndPtr = s + len, &end);
+ parser->m_errorCode
+ = parser->m_processor(parser, s, parser->m_parseEndPtr = s + len, &end);
- if (errorCode != XML_ERROR_NONE) {
- eventEndPtr = eventPtr;
- processor = errorProcessor;
+ if (parser->m_errorCode != XML_ERROR_NONE) {
+ parser->m_eventEndPtr = parser->m_eventPtr;
+ parser->m_processor = errorProcessor;
return XML_STATUS_ERROR;
- }
- else {
- switch (ps_parsing) {
+ } else {
+ switch (parser->m_parsingStatus.parsing) {
case XML_SUSPENDED:
result = XML_STATUS_SUSPENDED;
break;
case XML_INITIALIZED:
case XML_PARSING:
if (isFinal) {
- ps_parsing = XML_FINISHED;
+ parser->m_parsingStatus.parsing = XML_FINISHED;
return XML_STATUS_OK;
}
/* fall through */
@@ -1981,38 +1816,38 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
}
}
- XmlUpdatePosition(encoding, positionPtr, end, &position);
+ XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, end,
+ &parser->m_position);
nLeftOver = s + len - end;
if (nLeftOver) {
- if (buffer == NULL || nLeftOver > bufferLim - buffer) {
+ if (parser->m_buffer == NULL
+ || nLeftOver > parser->m_bufferLim - parser->m_buffer) {
/* avoid _signed_ integer overflow */
char *temp = NULL;
const int bytesToAllocate = (int)((unsigned)len * 2U);
if (bytesToAllocate > 0) {
- temp = (buffer == NULL
- ? (char *)MALLOC(bytesToAllocate)
- : (char *)REALLOC(buffer, bytesToAllocate));
+ temp = (char *)REALLOC(parser, parser->m_buffer, bytesToAllocate);
}
if (temp == NULL) {
- errorCode = XML_ERROR_NO_MEMORY;
- eventPtr = eventEndPtr = NULL;
- processor = errorProcessor;
+ parser->m_errorCode = XML_ERROR_NO_MEMORY;
+ parser->m_eventPtr = parser->m_eventEndPtr = NULL;
+ parser->m_processor = errorProcessor;
return XML_STATUS_ERROR;
}
- buffer = temp;
- bufferLim = buffer + bytesToAllocate;
+ parser->m_buffer = temp;
+ parser->m_bufferLim = parser->m_buffer + bytesToAllocate;
}
- memcpy(buffer, end, nLeftOver);
+ memcpy(parser->m_buffer, end, nLeftOver);
}
- bufferPtr = buffer;
- bufferEnd = buffer + nLeftOver;
- positionPtr = bufferPtr;
- parseEndPtr = bufferEnd;
- eventPtr = bufferPtr;
- eventEndPtr = bufferPtr;
+ parser->m_bufferPtr = parser->m_buffer;
+ parser->m_bufferEnd = parser->m_buffer + nLeftOver;
+ parser->m_positionPtr = parser->m_bufferPtr;
+ parser->m_parseEndPtr = parser->m_bufferEnd;
+ parser->m_eventPtr = parser->m_bufferPtr;
+ parser->m_eventEndPtr = parser->m_bufferPtr;
return result;
}
-#endif /* not defined XML_CONTEXT_BYTES */
+#endif /* not defined XML_CONTEXT_BYTES */
else {
void *buff = XML_GetBuffer(parser, len);
if (buff == NULL)
@@ -2025,236 +1860,254 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
}
enum XML_Status XMLCALL
-XML_ParseBuffer(XML_Parser parser, int len, int isFinal)
-{
+XML_ParseBuffer(XML_Parser parser, int len, int isFinal) {
const char *start;
enum XML_Status result = XML_STATUS_OK;
if (parser == NULL)
return XML_STATUS_ERROR;
- switch (ps_parsing) {
+ switch (parser->m_parsingStatus.parsing) {
case XML_SUSPENDED:
- errorCode = XML_ERROR_SUSPENDED;
+ parser->m_errorCode = XML_ERROR_SUSPENDED;
return XML_STATUS_ERROR;
case XML_FINISHED:
- errorCode = XML_ERROR_FINISHED;
+ parser->m_errorCode = XML_ERROR_FINISHED;
return XML_STATUS_ERROR;
case XML_INITIALIZED:
- if (parentParser == NULL && !startParsing(parser)) {
- errorCode = XML_ERROR_NO_MEMORY;
+ if (parser->m_parentParser == NULL && ! startParsing(parser)) {
+ parser->m_errorCode = XML_ERROR_NO_MEMORY;
return XML_STATUS_ERROR;
}
+ /* fall through */
default:
- ps_parsing = XML_PARSING;
+ parser->m_parsingStatus.parsing = XML_PARSING;
}
- start = bufferPtr;
- positionPtr = start;
- bufferEnd += len;
- parseEndPtr = bufferEnd;
- parseEndByteIndex += len;
- ps_finalBuffer = (XML_Bool)isFinal;
+ start = parser->m_bufferPtr;
+ parser->m_positionPtr = start;
+ parser->m_bufferEnd += len;
+ parser->m_parseEndPtr = parser->m_bufferEnd;
+ parser->m_parseEndByteIndex += len;
+ parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal;
- errorCode = processor(parser, start, parseEndPtr, &bufferPtr);
+ parser->m_errorCode = parser->m_processor(
+ parser, start, parser->m_parseEndPtr, &parser->m_bufferPtr);
- if (errorCode != XML_ERROR_NONE) {
- eventEndPtr = eventPtr;
- processor = errorProcessor;
+ if (parser->m_errorCode != XML_ERROR_NONE) {
+ parser->m_eventEndPtr = parser->m_eventPtr;
+ parser->m_processor = errorProcessor;
return XML_STATUS_ERROR;
- }
- else {
- switch (ps_parsing) {
+ } else {
+ switch (parser->m_parsingStatus.parsing) {
case XML_SUSPENDED:
result = XML_STATUS_SUSPENDED;
break;
case XML_INITIALIZED:
case XML_PARSING:
if (isFinal) {
- ps_parsing = XML_FINISHED;
+ parser->m_parsingStatus.parsing = XML_FINISHED;
return result;
}
- default: ; /* should not happen */
+ default:; /* should not happen */
}
}
- XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position);
- positionPtr = bufferPtr;
+ XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr,
+ parser->m_bufferPtr, &parser->m_position);
+ parser->m_positionPtr = parser->m_bufferPtr;
return result;
}
-void * XMLCALL
-XML_GetBuffer(XML_Parser parser, int len)
-{
+void *XMLCALL
+XML_GetBuffer(XML_Parser parser, int len) {
if (parser == NULL)
return NULL;
if (len < 0) {
- errorCode = XML_ERROR_NO_MEMORY;
+ parser->m_errorCode = XML_ERROR_NO_MEMORY;
return NULL;
}
- switch (ps_parsing) {
+ switch (parser->m_parsingStatus.parsing) {
case XML_SUSPENDED:
- errorCode = XML_ERROR_SUSPENDED;
+ parser->m_errorCode = XML_ERROR_SUSPENDED;
return NULL;
case XML_FINISHED:
- errorCode = XML_ERROR_FINISHED;
+ parser->m_errorCode = XML_ERROR_FINISHED;
return NULL;
- default: ;
+ default:;
}
- if (len > bufferLim - bufferEnd) {
+ if (len > EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferEnd)) {
#ifdef XML_CONTEXT_BYTES
int keep;
-#endif /* defined XML_CONTEXT_BYTES */
+#endif /* defined XML_CONTEXT_BYTES */
/* Do not invoke signed arithmetic overflow: */
- int neededSize = (int) ((unsigned)len + (unsigned)(bufferEnd - bufferPtr));
+ int neededSize = (int)((unsigned)len
+ + (unsigned)EXPAT_SAFE_PTR_DIFF(
+ parser->m_bufferEnd, parser->m_bufferPtr));
if (neededSize < 0) {
- errorCode = XML_ERROR_NO_MEMORY;
+ parser->m_errorCode = XML_ERROR_NO_MEMORY;
return NULL;
}
#ifdef XML_CONTEXT_BYTES
- keep = (int)(bufferPtr - buffer);
+ keep = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer);
if (keep > XML_CONTEXT_BYTES)
keep = XML_CONTEXT_BYTES;
neededSize += keep;
-#endif /* defined XML_CONTEXT_BYTES */
- if (neededSize <= bufferLim - buffer) {
+#endif /* defined XML_CONTEXT_BYTES */
+ if (neededSize
+ <= EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_buffer)) {
#ifdef XML_CONTEXT_BYTES
- if (keep < bufferPtr - buffer) {
- int offset = (int)(bufferPtr - buffer) - keep;
- memmove(buffer, &buffer[offset], bufferEnd - bufferPtr + keep);
- bufferEnd -= offset;
- bufferPtr -= offset;
+ if (keep < EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer)) {
+ int offset
+ = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer)
+ - keep;
+ /* The buffer pointers cannot be NULL here; we have at least some bytes
+ * in the buffer */
+ memmove(parser->m_buffer, &parser->m_buffer[offset],
+ parser->m_bufferEnd - parser->m_bufferPtr + keep);
+ parser->m_bufferEnd -= offset;
+ parser->m_bufferPtr -= offset;
}
#else
- memmove(buffer, bufferPtr, bufferEnd - bufferPtr);
- bufferEnd = buffer + (bufferEnd - bufferPtr);
- bufferPtr = buffer;
-#endif /* not defined XML_CONTEXT_BYTES */
- }
- else {
+ if (parser->m_buffer && parser->m_bufferPtr) {
+ memmove(parser->m_buffer, parser->m_bufferPtr,
+ EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr));
+ parser->m_bufferEnd
+ = parser->m_buffer
+ + EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr);
+ parser->m_bufferPtr = parser->m_buffer;
+ }
+#endif /* not defined XML_CONTEXT_BYTES */
+ } else {
char *newBuf;
- int bufferSize = (int)(bufferLim - bufferPtr);
+ int bufferSize
+ = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferPtr);
if (bufferSize == 0)
bufferSize = INIT_BUFFER_SIZE;
do {
/* Do not invoke signed arithmetic overflow: */
- bufferSize = (int) (2U * (unsigned) bufferSize);
+ bufferSize = (int)(2U * (unsigned)bufferSize);
} while (bufferSize < neededSize && bufferSize > 0);
if (bufferSize <= 0) {
- errorCode = XML_ERROR_NO_MEMORY;
+ parser->m_errorCode = XML_ERROR_NO_MEMORY;
return NULL;
}
- newBuf = (char *)MALLOC(bufferSize);
+ newBuf = (char *)MALLOC(parser, bufferSize);
if (newBuf == 0) {
- errorCode = XML_ERROR_NO_MEMORY;
+ parser->m_errorCode = XML_ERROR_NO_MEMORY;
return NULL;
}
- bufferLim = newBuf + bufferSize;
+ parser->m_bufferLim = newBuf + bufferSize;
#ifdef XML_CONTEXT_BYTES
- if (bufferPtr) {
- int keep = (int)(bufferPtr - buffer);
- if (keep > XML_CONTEXT_BYTES)
- keep = XML_CONTEXT_BYTES;
- memcpy(newBuf, &bufferPtr[-keep], bufferEnd - bufferPtr + keep);
- FREE(buffer);
- buffer = newBuf;
- bufferEnd = buffer + (bufferEnd - bufferPtr) + keep;
- bufferPtr = buffer + keep;
- }
- else {
- bufferEnd = newBuf + (bufferEnd - bufferPtr);
- bufferPtr = buffer = newBuf;
+ if (parser->m_bufferPtr) {
+ memcpy(newBuf, &parser->m_bufferPtr[-keep],
+ EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr)
+ + keep);
+ FREE(parser, parser->m_buffer);
+ parser->m_buffer = newBuf;
+ parser->m_bufferEnd
+ = parser->m_buffer
+ + EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr)
+ + keep;
+ parser->m_bufferPtr = parser->m_buffer + keep;
+ } else {
+ /* This must be a brand new buffer with no data in it yet */
+ parser->m_bufferEnd = newBuf;
+ parser->m_bufferPtr = parser->m_buffer = newBuf;
}
#else
- if (bufferPtr) {
- memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr);
- FREE(buffer);
+ if (parser->m_bufferPtr) {
+ memcpy(newBuf, parser->m_bufferPtr,
+ EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr));
+ FREE(parser, parser->m_buffer);
+ parser->m_bufferEnd
+ = newBuf
+ + EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr);
+ } else {
+ /* This must be a brand new buffer with no data in it yet */
+ parser->m_bufferEnd = newBuf;
}
- bufferEnd = newBuf + (bufferEnd - bufferPtr);
- bufferPtr = buffer = newBuf;
-#endif /* not defined XML_CONTEXT_BYTES */
+ parser->m_bufferPtr = parser->m_buffer = newBuf;
+#endif /* not defined XML_CONTEXT_BYTES */
}
- eventPtr = eventEndPtr = NULL;
- positionPtr = NULL;
+ parser->m_eventPtr = parser->m_eventEndPtr = NULL;
+ parser->m_positionPtr = NULL;
}
- return bufferEnd;
+ return parser->m_bufferEnd;
}
enum XML_Status XMLCALL
-XML_StopParser(XML_Parser parser, XML_Bool resumable)
-{
+XML_StopParser(XML_Parser parser, XML_Bool resumable) {
if (parser == NULL)
return XML_STATUS_ERROR;
- switch (ps_parsing) {
+ switch (parser->m_parsingStatus.parsing) {
case XML_SUSPENDED:
if (resumable) {
- errorCode = XML_ERROR_SUSPENDED;
+ parser->m_errorCode = XML_ERROR_SUSPENDED;
return XML_STATUS_ERROR;
}
- ps_parsing = XML_FINISHED;
+ parser->m_parsingStatus.parsing = XML_FINISHED;
break;
case XML_FINISHED:
- errorCode = XML_ERROR_FINISHED;
+ parser->m_errorCode = XML_ERROR_FINISHED;
return XML_STATUS_ERROR;
default:
if (resumable) {
#ifdef XML_DTD
- if (isParamEntity) {
- errorCode = XML_ERROR_SUSPEND_PE;
+ if (parser->m_isParamEntity) {
+ parser->m_errorCode = XML_ERROR_SUSPEND_PE;
return XML_STATUS_ERROR;
}
#endif
- ps_parsing = XML_SUSPENDED;
- }
- else
- ps_parsing = XML_FINISHED;
+ parser->m_parsingStatus.parsing = XML_SUSPENDED;
+ } else
+ parser->m_parsingStatus.parsing = XML_FINISHED;
}
return XML_STATUS_OK;
}
enum XML_Status XMLCALL
-XML_ResumeParser(XML_Parser parser)
-{
+XML_ResumeParser(XML_Parser parser) {
enum XML_Status result = XML_STATUS_OK;
if (parser == NULL)
return XML_STATUS_ERROR;
- if (ps_parsing != XML_SUSPENDED) {
- errorCode = XML_ERROR_NOT_SUSPENDED;
+ if (parser->m_parsingStatus.parsing != XML_SUSPENDED) {
+ parser->m_errorCode = XML_ERROR_NOT_SUSPENDED;
return XML_STATUS_ERROR;
}
- ps_parsing = XML_PARSING;
+ parser->m_parsingStatus.parsing = XML_PARSING;
- errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr);
+ parser->m_errorCode = parser->m_processor(
+ parser, parser->m_bufferPtr, parser->m_parseEndPtr, &parser->m_bufferPtr);
- if (errorCode != XML_ERROR_NONE) {
- eventEndPtr = eventPtr;
- processor = errorProcessor;
+ if (parser->m_errorCode != XML_ERROR_NONE) {
+ parser->m_eventEndPtr = parser->m_eventPtr;
+ parser->m_processor = errorProcessor;
return XML_STATUS_ERROR;
- }
- else {
- switch (ps_parsing) {
+ } else {
+ switch (parser->m_parsingStatus.parsing) {
case XML_SUSPENDED:
result = XML_STATUS_SUSPENDED;
break;
case XML_INITIALIZED:
case XML_PARSING:
- if (ps_finalBuffer) {
- ps_parsing = XML_FINISHED;
+ if (parser->m_parsingStatus.finalBuffer) {
+ parser->m_parsingStatus.parsing = XML_FINISHED;
return result;
}
- default: ;
+ default:;
}
}
- XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position);
- positionPtr = bufferPtr;
+ XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr,
+ parser->m_bufferPtr, &parser->m_position);
+ parser->m_positionPtr = parser->m_bufferPtr;
return result;
}
void XMLCALL
-XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status)
-{
+XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status) {
if (parser == NULL)
return;
assert(status != NULL);
@@ -2262,178 +2115,215 @@ XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status)
}
enum XML_Error XMLCALL
-XML_GetErrorCode(XML_Parser parser)
-{
+XML_GetErrorCode(XML_Parser parser) {
if (parser == NULL)
return XML_ERROR_INVALID_ARGUMENT;
- return errorCode;
+ return parser->m_errorCode;
}
XML_Index XMLCALL
-XML_GetCurrentByteIndex(XML_Parser parser)
-{
+XML_GetCurrentByteIndex(XML_Parser parser) {
if (parser == NULL)
return -1;
- if (eventPtr)
- return (XML_Index)(parseEndByteIndex - (parseEndPtr - eventPtr));
+ if (parser->m_eventPtr)
+ return (XML_Index)(parser->m_parseEndByteIndex
+ - (parser->m_parseEndPtr - parser->m_eventPtr));
return -1;
}
int XMLCALL
-XML_GetCurrentByteCount(XML_Parser parser)
-{
+XML_GetCurrentByteCount(XML_Parser parser) {
if (parser == NULL)
return 0;
- if (eventEndPtr && eventPtr)
- return (int)(eventEndPtr - eventPtr);
+ if (parser->m_eventEndPtr && parser->m_eventPtr)
+ return (int)(parser->m_eventEndPtr - parser->m_eventPtr);
return 0;
}
-const char * XMLCALL
-XML_GetInputContext(XML_Parser parser, int *offset, int *size)
-{
+const char *XMLCALL
+XML_GetInputContext(XML_Parser parser, int *offset, int *size) {
#ifdef XML_CONTEXT_BYTES
if (parser == NULL)
return NULL;
- if (eventPtr && buffer) {
+ if (parser->m_eventPtr && parser->m_buffer) {
if (offset != NULL)
- *offset = (int)(eventPtr - buffer);
+ *offset = (int)(parser->m_eventPtr - parser->m_buffer);
if (size != NULL)
- *size = (int)(bufferEnd - buffer);
- return buffer;
+ *size = (int)(parser->m_bufferEnd - parser->m_buffer);
+ return parser->m_buffer;
}
#else
(void)parser;
(void)offset;
(void)size;
#endif /* defined XML_CONTEXT_BYTES */
- return (char *) 0;
+ return (char *)0;
}
XML_Size XMLCALL
-XML_GetCurrentLineNumber(XML_Parser parser)
-{
+XML_GetCurrentLineNumber(XML_Parser parser) {
if (parser == NULL)
return 0;
- if (eventPtr && eventPtr >= positionPtr) {
- XmlUpdatePosition(encoding, positionPtr, eventPtr, &position);
- positionPtr = eventPtr;
+ if (parser->m_eventPtr && parser->m_eventPtr >= parser->m_positionPtr) {
+ XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr,
+ parser->m_eventPtr, &parser->m_position);
+ parser->m_positionPtr = parser->m_eventPtr;
}
- return position.lineNumber + 1;
+ return parser->m_position.lineNumber + 1;
}
XML_Size XMLCALL
-XML_GetCurrentColumnNumber(XML_Parser parser)
-{
+XML_GetCurrentColumnNumber(XML_Parser parser) {
if (parser == NULL)
return 0;
- if (eventPtr && eventPtr >= positionPtr) {
- XmlUpdatePosition(encoding, positionPtr, eventPtr, &position);
- positionPtr = eventPtr;
+ if (parser->m_eventPtr && parser->m_eventPtr >= parser->m_positionPtr) {
+ XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr,
+ parser->m_eventPtr, &parser->m_position);
+ parser->m_positionPtr = parser->m_eventPtr;
}
- return position.columnNumber;
+ return parser->m_position.columnNumber;
}
void XMLCALL
-XML_FreeContentModel(XML_Parser parser, XML_Content *model)
-{
+XML_FreeContentModel(XML_Parser parser, XML_Content *model) {
if (parser != NULL)
- FREE(model);
+ FREE(parser, model);
}
-void * XMLCALL
-XML_MemMalloc(XML_Parser parser, size_t size)
-{
+void *XMLCALL
+XML_MemMalloc(XML_Parser parser, size_t size) {
if (parser == NULL)
return NULL;
- return MALLOC(size);
+ return MALLOC(parser, size);
}
-void * XMLCALL
-XML_MemRealloc(XML_Parser parser, void *ptr, size_t size)
-{
+void *XMLCALL
+XML_MemRealloc(XML_Parser parser, void *ptr, size_t size) {
if (parser == NULL)
return NULL;
- return REALLOC(ptr, size);
+ return REALLOC(parser, ptr, size);
}
void XMLCALL
-XML_MemFree(XML_Parser parser, void *ptr)
-{
+XML_MemFree(XML_Parser parser, void *ptr) {
if (parser != NULL)
- FREE(ptr);
+ FREE(parser, ptr);
}
void XMLCALL
-XML_DefaultCurrent(XML_Parser parser)
-{
+XML_DefaultCurrent(XML_Parser parser) {
if (parser == NULL)
return;
- if (defaultHandler) {
- if (openInternalEntities)
- reportDefault(parser,
- internalEncoding,
- openInternalEntities->internalEventPtr,
- openInternalEntities->internalEventEndPtr);
+ if (parser->m_defaultHandler) {
+ if (parser->m_openInternalEntities)
+ reportDefault(parser, parser->m_internalEncoding,
+ parser->m_openInternalEntities->internalEventPtr,
+ parser->m_openInternalEntities->internalEventEndPtr);
else
- reportDefault(parser, encoding, eventPtr, eventEndPtr);
+ reportDefault(parser, parser->m_encoding, parser->m_eventPtr,
+ parser->m_eventEndPtr);
}
}
-const XML_LChar * XMLCALL
-XML_ErrorString(enum XML_Error code)
-{
- static const XML_LChar* const message[] = {
- 0,
- XML_L("out of memory"),
- XML_L("syntax error"),
- XML_L("no element found"),
- XML_L("not well-formed (invalid token)"),
- XML_L("unclosed token"),
- XML_L("partial character"),
- XML_L("mismatched tag"),
- XML_L("duplicate attribute"),
- XML_L("junk after document element"),
- XML_L("illegal parameter entity reference"),
- XML_L("undefined entity"),
- XML_L("recursive entity reference"),
- XML_L("asynchronous entity"),
- XML_L("reference to invalid character number"),
- XML_L("reference to binary entity"),
- XML_L("reference to external entity in attribute"),
- XML_L("XML or text declaration not at start of entity"),
- XML_L("unknown encoding"),
- XML_L("encoding specified in XML declaration is incorrect"),
- XML_L("unclosed CDATA section"),
- XML_L("error in processing external entity reference"),
- XML_L("document is not standalone"),
- XML_L("unexpected parser state - please send a bug report"),
- XML_L("entity declared in parameter entity"),
- XML_L("requested feature requires XML_DTD support in Expat"),
- XML_L("cannot change setting once parsing has begun"),
- XML_L("unbound prefix"),
- XML_L("must not undeclare prefix"),
- XML_L("incomplete markup in parameter entity"),
- XML_L("XML declaration not well-formed"),
- XML_L("text declaration not well-formed"),
- XML_L("illegal character(s) in public id"),
- XML_L("parser suspended"),
- XML_L("parser not suspended"),
- XML_L("parsing aborted"),
- XML_L("parsing finished"),
- XML_L("cannot suspend in external parameter entity"),
- XML_L("reserved prefix (xml) must not be undeclared or bound to another namespace name"),
- XML_L("reserved prefix (xmlns) must not be declared or undeclared"),
- XML_L("prefix must not be bound to one of the reserved namespace names")
- };
- if (code > 0 && code < sizeof(message)/sizeof(message[0]))
- return message[code];
+const XML_LChar *XMLCALL
+XML_ErrorString(enum XML_Error code) {
+ switch (code) {
+ case XML_ERROR_NONE:
+ return NULL;
+ case XML_ERROR_NO_MEMORY:
+ return XML_L("out of memory");
+ case XML_ERROR_SYNTAX:
+ return XML_L("syntax error");
+ case XML_ERROR_NO_ELEMENTS:
+ return XML_L("no element found");
+ case XML_ERROR_INVALID_TOKEN:
+ return XML_L("not well-formed (invalid token)");
+ case XML_ERROR_UNCLOSED_TOKEN:
+ return XML_L("unclosed token");
+ case XML_ERROR_PARTIAL_CHAR:
+ return XML_L("partial character");
+ case XML_ERROR_TAG_MISMATCH:
+ return XML_L("mismatched tag");
+ case XML_ERROR_DUPLICATE_ATTRIBUTE:
+ return XML_L("duplicate attribute");
+ case XML_ERROR_JUNK_AFTER_DOC_ELEMENT:
+ return XML_L("junk after document element");
+ case XML_ERROR_PARAM_ENTITY_REF:
+ return XML_L("illegal parameter entity reference");
+ case XML_ERROR_UNDEFINED_ENTITY:
+ return XML_L("undefined entity");
+ case XML_ERROR_RECURSIVE_ENTITY_REF:
+ return XML_L("recursive entity reference");
+ case XML_ERROR_ASYNC_ENTITY:
+ return XML_L("asynchronous entity");
+ case XML_ERROR_BAD_CHAR_REF:
+ return XML_L("reference to invalid character number");
+ case XML_ERROR_BINARY_ENTITY_REF:
+ return XML_L("reference to binary entity");
+ case XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF:
+ return XML_L("reference to external entity in attribute");
+ case XML_ERROR_MISPLACED_XML_PI:
+ return XML_L("XML or text declaration not at start of entity");
+ case XML_ERROR_UNKNOWN_ENCODING:
+ return XML_L("unknown encoding");
+ case XML_ERROR_INCORRECT_ENCODING:
+ return XML_L("encoding specified in XML declaration is incorrect");
+ case XML_ERROR_UNCLOSED_CDATA_SECTION:
+ return XML_L("unclosed CDATA section");
+ case XML_ERROR_EXTERNAL_ENTITY_HANDLING:
+ return XML_L("error in processing external entity reference");
+ case XML_ERROR_NOT_STANDALONE:
+ return XML_L("document is not standalone");
+ case XML_ERROR_UNEXPECTED_STATE:
+ return XML_L("unexpected parser state - please send a bug report");
+ case XML_ERROR_ENTITY_DECLARED_IN_PE:
+ return XML_L("entity declared in parameter entity");
+ case XML_ERROR_FEATURE_REQUIRES_XML_DTD:
+ return XML_L("requested feature requires XML_DTD support in Expat");
+ case XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING:
+ return XML_L("cannot change setting once parsing has begun");
+ /* Added in 1.95.7. */
+ case XML_ERROR_UNBOUND_PREFIX:
+ return XML_L("unbound prefix");
+ /* Added in 1.95.8. */
+ case XML_ERROR_UNDECLARING_PREFIX:
+ return XML_L("must not undeclare prefix");
+ case XML_ERROR_INCOMPLETE_PE:
+ return XML_L("incomplete markup in parameter entity");
+ case XML_ERROR_XML_DECL:
+ return XML_L("XML declaration not well-formed");
+ case XML_ERROR_TEXT_DECL:
+ return XML_L("text declaration not well-formed");
+ case XML_ERROR_PUBLICID:
+ return XML_L("illegal character(s) in public id");
+ case XML_ERROR_SUSPENDED:
+ return XML_L("parser suspended");
+ case XML_ERROR_NOT_SUSPENDED:
+ return XML_L("parser not suspended");
+ case XML_ERROR_ABORTED:
+ return XML_L("parsing aborted");
+ case XML_ERROR_FINISHED:
+ return XML_L("parsing finished");
+ case XML_ERROR_SUSPEND_PE:
+ return XML_L("cannot suspend in external parameter entity");
+ /* Added in 2.0.0. */
+ case XML_ERROR_RESERVED_PREFIX_XML:
+ return XML_L(
+ "reserved prefix (xml) must not be undeclared or bound to another namespace name");
+ case XML_ERROR_RESERVED_PREFIX_XMLNS:
+ return XML_L("reserved prefix (xmlns) must not be declared or undeclared");
+ case XML_ERROR_RESERVED_NAMESPACE_URI:
+ return XML_L(
+ "prefix must not be bound to one of the reserved namespace names");
+ /* Added in 2.2.5. */
+ case XML_ERROR_INVALID_ARGUMENT: /* Constant added in 2.2.1, already */
+ return XML_L("invalid argument");
+ }
return NULL;
}
-const XML_LChar * XMLCALL
+const XML_LChar *XMLCALL
XML_ExpatVersion(void) {
-
/* V1 is used to string-ize the version number. However, it would
string-ize the actual version macro *names* unless we get them
substituted before being passed to V1. CPP is defined to expand
@@ -2442,8 +2332,8 @@ XML_ExpatVersion(void) {
with the correct numerals. */
/* ### I'm assuming cpp is portable in this respect... */
-#define V1(a,b,c) XML_L(#a)XML_L(".")XML_L(#b)XML_L(".")XML_L(#c)
-#define V2(a,b,c) XML_L("expat_")V1(a,b,c)
+#define V1(a, b, c) XML_L(#a) XML_L(".") XML_L(#b) XML_L(".") XML_L(#c)
+#define V2(a, b, c) XML_L("expat_") V1(a, b, c)
return V2(XML_MAJOR_VERSION, XML_MINOR_VERSION, XML_MICRO_VERSION);
@@ -2452,8 +2342,7 @@ XML_ExpatVersion(void) {
}
XML_Expat_Version XMLCALL
-XML_ExpatVersionInfo(void)
-{
+XML_ExpatVersionInfo(void) {
XML_Expat_Version version;
version.major = XML_MAJOR_VERSION;
@@ -2463,41 +2352,39 @@ XML_ExpatVersionInfo(void)
return version;
}
-const XML_Feature * XMLCALL
-XML_GetFeatureList(void)
-{
- static const XML_Feature features[] = {
- {XML_FEATURE_SIZEOF_XML_CHAR, XML_L("sizeof(XML_Char)"),
- sizeof(XML_Char)},
- {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)"),
- sizeof(XML_LChar)},
+const XML_Feature *XMLCALL
+XML_GetFeatureList(void) {
+ static const XML_Feature features[]
+ = {{XML_FEATURE_SIZEOF_XML_CHAR, XML_L("sizeof(XML_Char)"),
+ sizeof(XML_Char)},
+ {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)"),
+ sizeof(XML_LChar)},
#ifdef XML_UNICODE
- {XML_FEATURE_UNICODE, XML_L("XML_UNICODE"), 0},
+ {XML_FEATURE_UNICODE, XML_L("XML_UNICODE"), 0},
#endif
#ifdef XML_UNICODE_WCHAR_T
- {XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T"), 0},
+ {XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T"), 0},
#endif
#ifdef XML_DTD
- {XML_FEATURE_DTD, XML_L("XML_DTD"), 0},
+ {XML_FEATURE_DTD, XML_L("XML_DTD"), 0},
#endif
#ifdef XML_CONTEXT_BYTES
- {XML_FEATURE_CONTEXT_BYTES, XML_L("XML_CONTEXT_BYTES"),
- XML_CONTEXT_BYTES},
+ {XML_FEATURE_CONTEXT_BYTES, XML_L("XML_CONTEXT_BYTES"),
+ XML_CONTEXT_BYTES},
#endif
#ifdef XML_MIN_SIZE
- {XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE"), 0},
+ {XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE"), 0},
#endif
#ifdef XML_NS
- {XML_FEATURE_NS, XML_L("XML_NS"), 0},
+ {XML_FEATURE_NS, XML_L("XML_NS"), 0},
#endif
#ifdef XML_LARGE_SIZE
- {XML_FEATURE_LARGE_SIZE, XML_L("XML_LARGE_SIZE"), 0},
+ {XML_FEATURE_LARGE_SIZE, XML_L("XML_LARGE_SIZE"), 0},
#endif
#ifdef XML_ATTR_INFO
- {XML_FEATURE_ATTR_INFO, XML_L("XML_ATTR_INFO"), 0},
+ {XML_FEATURE_ATTR_INFO, XML_L("XML_ATTR_INFO"), 0},
#endif
- {XML_FEATURE_END, NULL, 0}
- };
+ {XML_FEATURE_END, NULL, 0}};
return features;
}
@@ -2508,14 +2395,13 @@ XML_GetFeatureList(void)
permanent location, since the parse buffer is about to be discarded.
*/
static XML_Bool
-storeRawNames(XML_Parser parser)
-{
- TAG *tag = tagStack;
+storeRawNames(XML_Parser parser) {
+ TAG *tag = parser->m_tagStack;
while (tag) {
int bufSize;
int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1);
char *rawNameBuf = tag->buf + nameLen;
- /* Stop if already stored. Since tagStack is a stack, we can stop
+ /* Stop if already stored. Since m_tagStack is a stack, we can stop
at the first entry that has already been copied; everything
below it in the stack is already been accounted for in a
previous call to this function.
@@ -2527,7 +2413,7 @@ storeRawNames(XML_Parser parser)
*/
bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char));
if (bufSize > tag->bufEnd - tag->buf) {
- char *temp = (char *)REALLOC(tag->buf, bufSize);
+ char *temp = (char *)REALLOC(parser, tag->buf, bufSize);
if (temp == NULL)
return XML_FALSE;
/* if tag->name.str points to tag->buf (only when namespace
@@ -2539,8 +2425,8 @@ storeRawNames(XML_Parser parser)
then update it as well, since it will always point into tag->buf
*/
if (tag->name.localPart)
- tag->name.localPart = (XML_Char *)temp + (tag->name.localPart -
- (XML_Char *)tag->buf);
+ tag->name.localPart
+ = (XML_Char *)temp + (tag->name.localPart - (XML_Char *)tag->buf);
tag->buf = temp;
tag->bufEnd = temp + bufSize;
rawNameBuf = temp + nameLen;
@@ -2553,41 +2439,33 @@ storeRawNames(XML_Parser parser)
}
static enum XML_Error PTRCALL
-contentProcessor(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr)
-{
- enum XML_Error result = doContent(parser, 0, encoding, start, end,
- endPtr, (XML_Bool)!ps_finalBuffer);
+contentProcessor(XML_Parser parser, const char *start, const char *end,
+ const char **endPtr) {
+ enum XML_Error result
+ = doContent(parser, 0, parser->m_encoding, start, end, endPtr,
+ (XML_Bool)! parser->m_parsingStatus.finalBuffer);
if (result == XML_ERROR_NONE) {
- if (!storeRawNames(parser))
+ if (! storeRawNames(parser))
return XML_ERROR_NO_MEMORY;
}
return result;
}
static enum XML_Error PTRCALL
-externalEntityInitProcessor(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr)
-{
+externalEntityInitProcessor(XML_Parser parser, const char *start,
+ const char *end, const char **endPtr) {
enum XML_Error result = initializeEncoding(parser);
if (result != XML_ERROR_NONE)
return result;
- processor = externalEntityInitProcessor2;
+ parser->m_processor = externalEntityInitProcessor2;
return externalEntityInitProcessor2(parser, start, end, endPtr);
}
static enum XML_Error PTRCALL
-externalEntityInitProcessor2(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr)
-{
+externalEntityInitProcessor2(XML_Parser parser, const char *start,
+ const char *end, const char **endPtr) {
const char *next = start; /* XmlContentTok doesn't always set the last arg */
- int tok = XmlContentTok(encoding, start, end, &next);
+ int tok = XmlContentTok(parser->m_encoding, start, end, &next);
switch (tok) {
case XML_TOK_BOM:
/* If we are at the end of the buffer, this would cause the next stage,
@@ -2595,115 +2473,102 @@ externalEntityInitProcessor2(XML_Parser parser,
doContent (by detecting XML_TOK_NONE) without processing any xml text
declaration - causing the error XML_ERROR_MISPLACED_XML_PI in doContent.
*/
- if (next == end && !ps_finalBuffer) {
+ if (next == end && ! parser->m_parsingStatus.finalBuffer) {
*endPtr = next;
return XML_ERROR_NONE;
}
start = next;
break;
case XML_TOK_PARTIAL:
- if (!ps_finalBuffer) {
+ if (! parser->m_parsingStatus.finalBuffer) {
*endPtr = start;
return XML_ERROR_NONE;
}
- eventPtr = start;
+ parser->m_eventPtr = start;
return XML_ERROR_UNCLOSED_TOKEN;
case XML_TOK_PARTIAL_CHAR:
- if (!ps_finalBuffer) {
+ if (! parser->m_parsingStatus.finalBuffer) {
*endPtr = start;
return XML_ERROR_NONE;
}
- eventPtr = start;
+ parser->m_eventPtr = start;
return XML_ERROR_PARTIAL_CHAR;
}
- processor = externalEntityInitProcessor3;
+ parser->m_processor = externalEntityInitProcessor3;
return externalEntityInitProcessor3(parser, start, end, endPtr);
}
static enum XML_Error PTRCALL
-externalEntityInitProcessor3(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr)
-{
+externalEntityInitProcessor3(XML_Parser parser, const char *start,
+ const char *end, const char **endPtr) {
int tok;
const char *next = start; /* XmlContentTok doesn't always set the last arg */
- eventPtr = start;
- tok = XmlContentTok(encoding, start, end, &next);
- eventEndPtr = next;
+ parser->m_eventPtr = start;
+ tok = XmlContentTok(parser->m_encoding, start, end, &next);
+ parser->m_eventEndPtr = next;
switch (tok) {
- case XML_TOK_XML_DECL:
- {
- enum XML_Error result;
- result = processXmlDecl(parser, 1, start, next);
- if (result != XML_ERROR_NONE)
- return result;
- switch (ps_parsing) {
- case XML_SUSPENDED:
- *endPtr = next;
- return XML_ERROR_NONE;
- case XML_FINISHED:
- return XML_ERROR_ABORTED;
- default:
- start = next;
- }
+ case XML_TOK_XML_DECL: {
+ enum XML_Error result;
+ result = processXmlDecl(parser, 1, start, next);
+ if (result != XML_ERROR_NONE)
+ return result;
+ switch (parser->m_parsingStatus.parsing) {
+ case XML_SUSPENDED:
+ *endPtr = next;
+ return XML_ERROR_NONE;
+ case XML_FINISHED:
+ return XML_ERROR_ABORTED;
+ default:
+ start = next;
}
- break;
+ } break;
case XML_TOK_PARTIAL:
- if (!ps_finalBuffer) {
+ if (! parser->m_parsingStatus.finalBuffer) {
*endPtr = start;
return XML_ERROR_NONE;
}
return XML_ERROR_UNCLOSED_TOKEN;
case XML_TOK_PARTIAL_CHAR:
- if (!ps_finalBuffer) {
+ if (! parser->m_parsingStatus.finalBuffer) {
*endPtr = start;
return XML_ERROR_NONE;
}
return XML_ERROR_PARTIAL_CHAR;
}
- processor = externalEntityContentProcessor;
- tagLevel = 1;
+ parser->m_processor = externalEntityContentProcessor;
+ parser->m_tagLevel = 1;
return externalEntityContentProcessor(parser, start, end, endPtr);
}
static enum XML_Error PTRCALL
-externalEntityContentProcessor(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr)
-{
- enum XML_Error result = doContent(parser, 1, encoding, start, end,
- endPtr, (XML_Bool)!ps_finalBuffer);
+externalEntityContentProcessor(XML_Parser parser, const char *start,
+ const char *end, const char **endPtr) {
+ enum XML_Error result
+ = doContent(parser, 1, parser->m_encoding, start, end, endPtr,
+ (XML_Bool)! parser->m_parsingStatus.finalBuffer);
if (result == XML_ERROR_NONE) {
- if (!storeRawNames(parser))
+ if (! storeRawNames(parser))
return XML_ERROR_NO_MEMORY;
}
return result;
}
static enum XML_Error
-doContent(XML_Parser parser,
- int startTagLevel,
- const ENCODING *enc,
- const char *s,
- const char *end,
- const char **nextPtr,
- XML_Bool haveMore)
-{
+doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
+ const char *s, const char *end, const char **nextPtr,
+ XML_Bool haveMore) {
/* save one level of indirection */
- DTD * const dtd = _dtd;
+ DTD *const dtd = parser->m_dtd;
const char **eventPP;
const char **eventEndPP;
- if (enc == encoding) {
- eventPP = &eventPtr;
- eventEndPP = &eventEndPtr;
- }
- else {
- eventPP = &(openInternalEntities->internalEventPtr);
- eventEndPP = &(openInternalEntities->internalEventEndPtr);
+ if (enc == parser->m_encoding) {
+ eventPP = &parser->m_eventPtr;
+ eventEndPP = &parser->m_eventEndPtr;
+ } else {
+ eventPP = &(parser->m_openInternalEntities->internalEventPtr);
+ eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr);
}
*eventPP = s;
@@ -2718,18 +2583,17 @@ doContent(XML_Parser parser,
return XML_ERROR_NONE;
}
*eventEndPP = end;
- if (characterDataHandler) {
+ if (parser->m_characterDataHandler) {
XML_Char c = 0xA;
- characterDataHandler(handlerArg, &c, 1);
- }
- else if (defaultHandler)
+ parser->m_characterDataHandler(parser->m_handlerArg, &c, 1);
+ } else if (parser->m_defaultHandler)
reportDefault(parser, enc, s, end);
/* We are at the end of the final buffer, should we check for
XML_SUSPENDED, XML_FINISHED?
*/
if (startTagLevel == 0)
return XML_ERROR_NO_ELEMENTS;
- if (tagLevel != startTagLevel)
+ if (parser->m_tagLevel != startTagLevel)
return XML_ERROR_ASYNC_ENTITY;
*nextPtr = end;
return XML_ERROR_NONE;
@@ -2739,7 +2603,7 @@ doContent(XML_Parser parser,
return XML_ERROR_NONE;
}
if (startTagLevel > 0) {
- if (tagLevel != startTagLevel)
+ if (parser->m_tagLevel != startTagLevel)
return XML_ERROR_ASYNC_ENTITY;
*nextPtr = s;
return XML_ERROR_NONE;
@@ -2760,315 +2624,314 @@ doContent(XML_Parser parser,
return XML_ERROR_NONE;
}
return XML_ERROR_PARTIAL_CHAR;
- case XML_TOK_ENTITY_REF:
- {
- const XML_Char *name;
- ENTITY *entity;
- XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc,
- s + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (ch) {
- if (characterDataHandler)
- characterDataHandler(handlerArg, &ch, 1);
- else if (defaultHandler)
+ case XML_TOK_ENTITY_REF: {
+ const XML_Char *name;
+ ENTITY *entity;
+ XML_Char ch = (XML_Char)XmlPredefinedEntityName(
+ enc, s + enc->minBytesPerChar, next - enc->minBytesPerChar);
+ if (ch) {
+ if (parser->m_characterDataHandler)
+ parser->m_characterDataHandler(parser->m_handlerArg, &ch, 1);
+ else if (parser->m_defaultHandler)
+ reportDefault(parser, enc, s, next);
+ break;
+ }
+ name = poolStoreString(&dtd->pool, enc, s + enc->minBytesPerChar,
+ next - enc->minBytesPerChar);
+ if (! name)
+ return XML_ERROR_NO_MEMORY;
+ entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0);
+ poolDiscard(&dtd->pool);
+ /* First, determine if a check for an existing declaration is needed;
+ if yes, check that the entity exists, and that it is internal,
+ otherwise call the skipped entity or default handler.
+ */
+ if (! dtd->hasParamEntityRefs || dtd->standalone) {
+ if (! entity)
+ return XML_ERROR_UNDEFINED_ENTITY;
+ else if (! entity->is_internal)
+ return XML_ERROR_ENTITY_DECLARED_IN_PE;
+ } else if (! entity) {
+ if (parser->m_skippedEntityHandler)
+ parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0);
+ else if (parser->m_defaultHandler)
+ reportDefault(parser, enc, s, next);
+ break;
+ }
+ if (entity->open)
+ return XML_ERROR_RECURSIVE_ENTITY_REF;
+ if (entity->notation)
+ return XML_ERROR_BINARY_ENTITY_REF;
+ if (entity->textPtr) {
+ enum XML_Error result;
+ if (! parser->m_defaultExpandInternalEntities) {
+ if (parser->m_skippedEntityHandler)
+ parser->m_skippedEntityHandler(parser->m_handlerArg, entity->name,
+ 0);
+ else if (parser->m_defaultHandler)
reportDefault(parser, enc, s, next);
break;
}
- name = poolStoreString(&dtd->pool, enc,
- s + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (!name)
+ result = processInternalEntity(parser, entity, XML_FALSE);
+ if (result != XML_ERROR_NONE)
+ return result;
+ } else if (parser->m_externalEntityRefHandler) {
+ const XML_Char *context;
+ entity->open = XML_TRUE;
+ context = getContext(parser);
+ entity->open = XML_FALSE;
+ if (! context)
return XML_ERROR_NO_MEMORY;
- entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0);
- poolDiscard(&dtd->pool);
- /* First, determine if a check for an existing declaration is needed;
- if yes, check that the entity exists, and that it is internal,
- otherwise call the skipped entity or default handler.
- */
- if (!dtd->hasParamEntityRefs || dtd->standalone) {
- if (!entity)
- return XML_ERROR_UNDEFINED_ENTITY;
- else if (!entity->is_internal)
- return XML_ERROR_ENTITY_DECLARED_IN_PE;
- }
- else if (!entity) {
- if (skippedEntityHandler)
- skippedEntityHandler(handlerArg, name, 0);
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- break;
- }
- if (entity->open)
- return XML_ERROR_RECURSIVE_ENTITY_REF;
- if (entity->notation)
- return XML_ERROR_BINARY_ENTITY_REF;
- if (entity->textPtr) {
- enum XML_Error result;
- if (!defaultExpandInternalEntities) {
- if (skippedEntityHandler)
- skippedEntityHandler(handlerArg, entity->name, 0);
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- break;
- }
- result = processInternalEntity(parser, entity, XML_FALSE);
- if (result != XML_ERROR_NONE)
- return result;
- }
- else if (externalEntityRefHandler) {
- const XML_Char *context;
- entity->open = XML_TRUE;
- context = getContext(parser);
- entity->open = XML_FALSE;
- if (!context)
- return XML_ERROR_NO_MEMORY;
- if (!externalEntityRefHandler(externalEntityRefHandlerArg,
- context,
- entity->base,
- entity->systemId,
- entity->publicId))
- return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
- poolDiscard(&tempPool);
- }
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- break;
- }
+ if (! parser->m_externalEntityRefHandler(
+ parser->m_externalEntityRefHandlerArg, context, entity->base,
+ entity->systemId, entity->publicId))
+ return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
+ poolDiscard(&parser->m_tempPool);
+ } else if (parser->m_defaultHandler)
+ reportDefault(parser, enc, s, next);
+ break;
+ }
case XML_TOK_START_TAG_NO_ATTS:
/* fall through */
- case XML_TOK_START_TAG_WITH_ATTS:
- {
- TAG *tag;
- enum XML_Error result;
- XML_Char *toPtr;
- if (freeTagList) {
- tag = freeTagList;
- freeTagList = freeTagList->parent;
+ case XML_TOK_START_TAG_WITH_ATTS: {
+ TAG *tag;
+ enum XML_Error result;
+ XML_Char *toPtr;
+ if (parser->m_freeTagList) {
+ tag = parser->m_freeTagList;
+ parser->m_freeTagList = parser->m_freeTagList->parent;
+ } else {
+ tag = (TAG *)MALLOC(parser, sizeof(TAG));
+ if (! tag)
+ return XML_ERROR_NO_MEMORY;
+ tag->buf = (char *)MALLOC(parser, INIT_TAG_BUF_SIZE);
+ if (! tag->buf) {
+ FREE(parser, tag);
+ return XML_ERROR_NO_MEMORY;
}
- else {
- tag = (TAG *)MALLOC(sizeof(TAG));
- if (!tag)
- return XML_ERROR_NO_MEMORY;
- tag->buf = (char *)MALLOC(INIT_TAG_BUF_SIZE);
- if (!tag->buf) {
- FREE(tag);
- return XML_ERROR_NO_MEMORY;
+ tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE;
+ }
+ tag->bindings = NULL;
+ tag->parent = parser->m_tagStack;
+ parser->m_tagStack = tag;
+ tag->name.localPart = NULL;
+ tag->name.prefix = NULL;
+ tag->rawName = s + enc->minBytesPerChar;
+ tag->rawNameLength = XmlNameLength(enc, tag->rawName);
+ ++parser->m_tagLevel;
+ {
+ const char *rawNameEnd = tag->rawName + tag->rawNameLength;
+ const char *fromPtr = tag->rawName;
+ toPtr = (XML_Char *)tag->buf;
+ for (;;) {
+ int bufSize;
+ int convLen;
+ const enum XML_Convert_Result convert_res
+ = XmlConvert(enc, &fromPtr, rawNameEnd, (ICHAR **)&toPtr,
+ (ICHAR *)tag->bufEnd - 1);
+ convLen = (int)(toPtr - (XML_Char *)tag->buf);
+ if ((fromPtr >= rawNameEnd)
+ || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) {
+ tag->name.strLen = convLen;
+ break;
}
- tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE;
- }
- tag->bindings = NULL;
- tag->parent = tagStack;
- tagStack = tag;
- tag->name.localPart = NULL;
- tag->name.prefix = NULL;
- tag->rawName = s + enc->minBytesPerChar;
- tag->rawNameLength = XmlNameLength(enc, tag->rawName);
- ++tagLevel;
- {
- const char *rawNameEnd = tag->rawName + tag->rawNameLength;
- const char *fromPtr = tag->rawName;
- toPtr = (XML_Char *)tag->buf;
- for (;;) {
- int bufSize;
- int convLen;
- const enum XML_Convert_Result convert_res = XmlConvert(enc,
- &fromPtr, rawNameEnd,
- (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1);
- convLen = (int)(toPtr - (XML_Char *)tag->buf);
- if ((fromPtr >= rawNameEnd) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) {
- tag->name.strLen = convLen;
- break;
- }
- bufSize = (int)(tag->bufEnd - tag->buf) << 1;
- {
- char *temp = (char *)REALLOC(tag->buf, bufSize);
- if (temp == NULL)
- return XML_ERROR_NO_MEMORY;
- tag->buf = temp;
- tag->bufEnd = temp + bufSize;
- toPtr = (XML_Char *)temp + convLen;
- }
+ bufSize = (int)(tag->bufEnd - tag->buf) << 1;
+ {
+ char *temp = (char *)REALLOC(parser, tag->buf, bufSize);
+ if (temp == NULL)
+ return XML_ERROR_NO_MEMORY;
+ tag->buf = temp;
+ tag->bufEnd = temp + bufSize;
+ toPtr = (XML_Char *)temp + convLen;
}
}
- tag->name.str = (XML_Char *)tag->buf;
- *toPtr = XML_T('\0');
- result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings));
- if (result)
- return result;
- if (startElementHandler)
- startElementHandler(handlerArg, tag->name.str,
- (const XML_Char **)atts);
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- poolClear(&tempPool);
- break;
}
+ tag->name.str = (XML_Char *)tag->buf;
+ *toPtr = XML_T('\0');
+ result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings));
+ if (result)
+ return result;
+ if (parser->m_startElementHandler)
+ parser->m_startElementHandler(parser->m_handlerArg, tag->name.str,
+ (const XML_Char **)parser->m_atts);
+ else if (parser->m_defaultHandler)
+ reportDefault(parser, enc, s, next);
+ poolClear(&parser->m_tempPool);
+ break;
+ }
case XML_TOK_EMPTY_ELEMENT_NO_ATTS:
/* fall through */
- case XML_TOK_EMPTY_ELEMENT_WITH_ATTS:
- {
- const char *rawName = s + enc->minBytesPerChar;
- enum XML_Error result;
- BINDING *bindings = NULL;
- XML_Bool noElmHandlers = XML_TRUE;
- TAG_NAME name;
- name.str = poolStoreString(&tempPool, enc, rawName,
- rawName + XmlNameLength(enc, rawName));
- if (!name.str)
- return XML_ERROR_NO_MEMORY;
- poolFinish(&tempPool);
- result = storeAtts(parser, enc, s, &name, &bindings);
- if (result != XML_ERROR_NONE) {
- freeBindings(parser, bindings);
- return result;
- }
- poolFinish(&tempPool);
- if (startElementHandler) {
- startElementHandler(handlerArg, name.str, (const XML_Char **)atts);
- noElmHandlers = XML_FALSE;
- }
- if (endElementHandler) {
- if (startElementHandler)
- *eventPP = *eventEndPP;
- endElementHandler(handlerArg, name.str);
- noElmHandlers = XML_FALSE;
- }
- if (noElmHandlers && defaultHandler)
- reportDefault(parser, enc, s, next);
- poolClear(&tempPool);
+ case XML_TOK_EMPTY_ELEMENT_WITH_ATTS: {
+ const char *rawName = s + enc->minBytesPerChar;
+ enum XML_Error result;
+ BINDING *bindings = NULL;
+ XML_Bool noElmHandlers = XML_TRUE;
+ TAG_NAME name;
+ name.str = poolStoreString(&parser->m_tempPool, enc, rawName,
+ rawName + XmlNameLength(enc, rawName));
+ if (! name.str)
+ return XML_ERROR_NO_MEMORY;
+ poolFinish(&parser->m_tempPool);
+ result = storeAtts(parser, enc, s, &name, &bindings);
+ if (result != XML_ERROR_NONE) {
freeBindings(parser, bindings);
+ return result;
+ }
+ poolFinish(&parser->m_tempPool);
+ if (parser->m_startElementHandler) {
+ parser->m_startElementHandler(parser->m_handlerArg, name.str,
+ (const XML_Char **)parser->m_atts);
+ noElmHandlers = XML_FALSE;
+ }
+ if (parser->m_endElementHandler) {
+ if (parser->m_startElementHandler)
+ *eventPP = *eventEndPP;
+ parser->m_endElementHandler(parser->m_handlerArg, name.str);
+ noElmHandlers = XML_FALSE;
+ }
+ if (noElmHandlers && parser->m_defaultHandler)
+ reportDefault(parser, enc, s, next);
+ poolClear(&parser->m_tempPool);
+ freeBindings(parser, bindings);
+ }
+ if ((parser->m_tagLevel == 0)
+ && (parser->m_parsingStatus.parsing != XML_FINISHED)) {
+ if (parser->m_parsingStatus.parsing == XML_SUSPENDED)
+ parser->m_processor = epilogProcessor;
+ else
+ return epilogProcessor(parser, next, end, nextPtr);
}
- if (tagLevel == 0)
- return epilogProcessor(parser, next, end, nextPtr);
break;
case XML_TOK_END_TAG:
- if (tagLevel == startTagLevel)
+ if (parser->m_tagLevel == startTagLevel)
return XML_ERROR_ASYNC_ENTITY;
else {
int len;
const char *rawName;
- TAG *tag = tagStack;
- tagStack = tag->parent;
- tag->parent = freeTagList;
- freeTagList = tag;
- rawName = s + enc->minBytesPerChar*2;
+ TAG *tag = parser->m_tagStack;
+ parser->m_tagStack = tag->parent;
+ tag->parent = parser->m_freeTagList;
+ parser->m_freeTagList = tag;
+ rawName = s + enc->minBytesPerChar * 2;
len = XmlNameLength(enc, rawName);
if (len != tag->rawNameLength
|| memcmp(tag->rawName, rawName, len) != 0) {
*eventPP = rawName;
return XML_ERROR_TAG_MISMATCH;
}
- --tagLevel;
- if (endElementHandler) {
+ --parser->m_tagLevel;
+ if (parser->m_endElementHandler) {
const XML_Char *localPart;
const XML_Char *prefix;
XML_Char *uri;
localPart = tag->name.localPart;
- if (ns && localPart) {
+ if (parser->m_ns && localPart) {
/* localPart and prefix may have been overwritten in
tag->name.str, since this points to the binding->uri
buffer which gets re-used; so we have to add them again
*/
uri = (XML_Char *)tag->name.str + tag->name.uriLen;
/* don't need to check for space - already done in storeAtts() */
- while (*localPart) *uri++ = *localPart++;
+ while (*localPart)
+ *uri++ = *localPart++;
prefix = (XML_Char *)tag->name.prefix;
- if (ns_triplets && prefix) {
- *uri++ = namespaceSeparator;
- while (*prefix) *uri++ = *prefix++;
- }
+ if (parser->m_ns_triplets && prefix) {
+ *uri++ = parser->m_namespaceSeparator;
+ while (*prefix)
+ *uri++ = *prefix++;
+ }
*uri = XML_T('\0');
}
- endElementHandler(handlerArg, tag->name.str);
- }
- else if (defaultHandler)
+ parser->m_endElementHandler(parser->m_handlerArg, tag->name.str);
+ } else if (parser->m_defaultHandler)
reportDefault(parser, enc, s, next);
while (tag->bindings) {
BINDING *b = tag->bindings;
- if (endNamespaceDeclHandler)
- endNamespaceDeclHandler(handlerArg, b->prefix->name);
+ if (parser->m_endNamespaceDeclHandler)
+ parser->m_endNamespaceDeclHandler(parser->m_handlerArg,
+ b->prefix->name);
tag->bindings = tag->bindings->nextTagBinding;
- b->nextTagBinding = freeBindingList;
- freeBindingList = b;
+ b->nextTagBinding = parser->m_freeBindingList;
+ parser->m_freeBindingList = b;
b->prefix->binding = b->prevPrefixBinding;
}
- if (tagLevel == 0)
- return epilogProcessor(parser, next, end, nextPtr);
- }
- break;
- case XML_TOK_CHAR_REF:
- {
- int n = XmlCharRefNumber(enc, s);
- if (n < 0)
- return XML_ERROR_BAD_CHAR_REF;
- if (characterDataHandler) {
- XML_Char buf[XML_ENCODE_MAX];
- characterDataHandler(handlerArg, buf, XmlEncode(n, (ICHAR *)buf));
+ if ((parser->m_tagLevel == 0)
+ && (parser->m_parsingStatus.parsing != XML_FINISHED)) {
+ if (parser->m_parsingStatus.parsing == XML_SUSPENDED)
+ parser->m_processor = epilogProcessor;
+ else
+ return epilogProcessor(parser, next, end, nextPtr);
}
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
}
break;
+ case XML_TOK_CHAR_REF: {
+ int n = XmlCharRefNumber(enc, s);
+ if (n < 0)
+ return XML_ERROR_BAD_CHAR_REF;
+ if (parser->m_characterDataHandler) {
+ XML_Char buf[XML_ENCODE_MAX];
+ parser->m_characterDataHandler(parser->m_handlerArg, buf,
+ XmlEncode(n, (ICHAR *)buf));
+ } else if (parser->m_defaultHandler)
+ reportDefault(parser, enc, s, next);
+ } break;
case XML_TOK_XML_DECL:
return XML_ERROR_MISPLACED_XML_PI;
case XML_TOK_DATA_NEWLINE:
- if (characterDataHandler) {
+ if (parser->m_characterDataHandler) {
XML_Char c = 0xA;
- characterDataHandler(handlerArg, &c, 1);
- }
- else if (defaultHandler)
+ parser->m_characterDataHandler(parser->m_handlerArg, &c, 1);
+ } else if (parser->m_defaultHandler)
reportDefault(parser, enc, s, next);
break;
- case XML_TOK_CDATA_SECT_OPEN:
- {
- enum XML_Error result;
- if (startCdataSectionHandler)
- startCdataSectionHandler(handlerArg);
-#if 0
- /* Suppose you doing a transformation on a document that involves
- changing only the character data. You set up a defaultHandler
- and a characterDataHandler. The defaultHandler simply copies
- characters through. The characterDataHandler does the
- transformation and writes the characters out escaping them as
- necessary. This case will fail to work if we leave out the
- following two lines (because & and < inside CDATA sections will
- be incorrectly escaped).
-
- However, now we have a start/endCdataSectionHandler, so it seems
- easier to let the user deal with this.
- */
- else if (characterDataHandler)
- characterDataHandler(handlerArg, dataBuf, 0);
-#endif
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- result = doCdataSection(parser, enc, &next, end, nextPtr, haveMore);
- if (result != XML_ERROR_NONE)
- return result;
- else if (!next) {
- processor = cdataSectionProcessor;
- return result;
- }
+ case XML_TOK_CDATA_SECT_OPEN: {
+ enum XML_Error result;
+ if (parser->m_startCdataSectionHandler)
+ parser->m_startCdataSectionHandler(parser->m_handlerArg);
+ /* BEGIN disabled code */
+ /* Suppose you doing a transformation on a document that involves
+ changing only the character data. You set up a defaultHandler
+ and a characterDataHandler. The defaultHandler simply copies
+ characters through. The characterDataHandler does the
+ transformation and writes the characters out escaping them as
+ necessary. This case will fail to work if we leave out the
+ following two lines (because & and < inside CDATA sections will
+ be incorrectly escaped).
+
+ However, now we have a start/endCdataSectionHandler, so it seems
+ easier to let the user deal with this.
+ */
+ else if (0 && parser->m_characterDataHandler)
+ parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf,
+ 0);
+ /* END disabled code */
+ else if (parser->m_defaultHandler)
+ reportDefault(parser, enc, s, next);
+ result = doCdataSection(parser, enc, &next, end, nextPtr, haveMore);
+ if (result != XML_ERROR_NONE)
+ return result;
+ else if (! next) {
+ parser->m_processor = cdataSectionProcessor;
+ return result;
}
- break;
+ } break;
case XML_TOK_TRAILING_RSQB:
if (haveMore) {
*nextPtr = s;
return XML_ERROR_NONE;
}
- if (characterDataHandler) {
+ if (parser->m_characterDataHandler) {
if (MUST_CONVERT(enc, s)) {
- ICHAR *dataPtr = (ICHAR *)dataBuf;
- XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd);
- characterDataHandler(handlerArg, dataBuf,
- (int)(dataPtr - (ICHAR *)dataBuf));
- }
- else
- characterDataHandler(handlerArg,
- (XML_Char *)s,
- (int)((XML_Char *)end - (XML_Char *)s));
- }
- else if (defaultHandler)
+ ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf;
+ XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)parser->m_dataBufEnd);
+ parser->m_characterDataHandler(
+ parser->m_handlerArg, parser->m_dataBuf,
+ (int)(dataPtr - (ICHAR *)parser->m_dataBuf));
+ } else
+ parser->m_characterDataHandler(
+ parser->m_handlerArg, (XML_Char *)s,
+ (int)((XML_Char *)end - (XML_Char *)s));
+ } else if (parser->m_defaultHandler)
reportDefault(parser, enc, s, end);
/* We are at the end of the final buffer, should we check for
XML_SUSPENDED, XML_FINISHED?
@@ -3077,43 +2940,40 @@ doContent(XML_Parser parser,
*eventPP = end;
return XML_ERROR_NO_ELEMENTS;
}
- if (tagLevel != startTagLevel) {
+ if (parser->m_tagLevel != startTagLevel) {
*eventPP = end;
return XML_ERROR_ASYNC_ENTITY;
}
*nextPtr = end;
return XML_ERROR_NONE;
- case XML_TOK_DATA_CHARS:
- {
- XML_CharacterDataHandler charDataHandler = characterDataHandler;
- if (charDataHandler) {
- if (MUST_CONVERT(enc, s)) {
- for (;;) {
- ICHAR *dataPtr = (ICHAR *)dataBuf;
- const enum XML_Convert_Result convert_res = XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd);
- *eventEndPP = s;
- charDataHandler(handlerArg, dataBuf,
- (int)(dataPtr - (ICHAR *)dataBuf));
- if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE))
- break;
- *eventPP = s;
- }
+ case XML_TOK_DATA_CHARS: {
+ XML_CharacterDataHandler charDataHandler = parser->m_characterDataHandler;
+ if (charDataHandler) {
+ if (MUST_CONVERT(enc, s)) {
+ for (;;) {
+ ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf;
+ const enum XML_Convert_Result convert_res = XmlConvert(
+ enc, &s, next, &dataPtr, (ICHAR *)parser->m_dataBufEnd);
+ *eventEndPP = s;
+ charDataHandler(parser->m_handlerArg, parser->m_dataBuf,
+ (int)(dataPtr - (ICHAR *)parser->m_dataBuf));
+ if ((convert_res == XML_CONVERT_COMPLETED)
+ || (convert_res == XML_CONVERT_INPUT_INCOMPLETE))
+ break;
+ *eventPP = s;
}
- else
- charDataHandler(handlerArg,
- (XML_Char *)s,
- (int)((XML_Char *)next - (XML_Char *)s));
- }
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- }
- break;
+ } else
+ charDataHandler(parser->m_handlerArg, (XML_Char *)s,
+ (int)((XML_Char *)next - (XML_Char *)s));
+ } else if (parser->m_defaultHandler)
+ reportDefault(parser, enc, s, next);
+ } break;
case XML_TOK_PI:
- if (!reportProcessingInstruction(parser, enc, s, next))
+ if (! reportProcessingInstruction(parser, enc, s, next))
return XML_ERROR_NO_MEMORY;
break;
case XML_TOK_COMMENT:
- if (!reportComment(parser, enc, s, next))
+ if (! reportComment(parser, enc, s, next))
return XML_ERROR_NO_MEMORY;
break;
default:
@@ -3124,43 +2984,42 @@ doContent(XML_Parser parser,
*
* LCOV_EXCL_START
*/
- if (defaultHandler)
+ if (parser->m_defaultHandler)
reportDefault(parser, enc, s, next);
break;
/* LCOV_EXCL_STOP */
}
*eventPP = s = next;
- switch (ps_parsing) {
+ switch (parser->m_parsingStatus.parsing) {
case XML_SUSPENDED:
*nextPtr = next;
return XML_ERROR_NONE;
case XML_FINISHED:
return XML_ERROR_ABORTED;
- default: ;
+ default:;
}
}
/* not reached */
}
/* This function does not call free() on the allocated memory, merely
- * moving it to the parser's freeBindingList where it can be freed or
+ * moving it to the parser's m_freeBindingList where it can be freed or
* reused as appropriate.
*/
static void
-freeBindings(XML_Parser parser, BINDING *bindings)
-{
+freeBindings(XML_Parser parser, BINDING *bindings) {
while (bindings) {
BINDING *b = bindings;
- /* startNamespaceDeclHandler will have been called for this
+ /* m_startNamespaceDeclHandler will have been called for this
* binding in addBindings(), so call the end handler now.
*/
- if (endNamespaceDeclHandler)
- endNamespaceDeclHandler(handlerArg, b->prefix->name);
+ if (parser->m_endNamespaceDeclHandler)
+ parser->m_endNamespaceDeclHandler(parser->m_handlerArg, b->prefix->name);
bindings = bindings->nextTagBinding;
- b->nextTagBinding = freeBindingList;
- freeBindingList = b;
+ b->nextTagBinding = parser->m_freeBindingList;
+ parser->m_freeBindingList = b;
b->prefix->binding = b->prevPrefixBinding;
}
}
@@ -3176,14 +3035,12 @@ freeBindings(XML_Parser parser, BINDING *bindings)
- generate namespace aware element name (URI, prefix)
*/
static enum XML_Error
-storeAtts(XML_Parser parser, const ENCODING *enc,
- const char *attStr, TAG_NAME *tagNamePtr,
- BINDING **bindingsPtr)
-{
- DTD * const dtd = _dtd; /* save one level of indirection */
+storeAtts(XML_Parser parser, const ENCODING *enc, const char *attStr,
+ TAG_NAME *tagNamePtr, BINDING **bindingsPtr) {
+ DTD *const dtd = parser->m_dtd; /* save one level of indirection */
ELEMENT_TYPE *elementType;
int nDefaultAtts;
- const XML_Char **appAtts; /* the attribute list for the application */
+ const XML_Char **appAtts; /* the attribute list for the application */
int attIndex = 0;
int prefixLen;
int i;
@@ -3194,79 +3051,84 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
const XML_Char *localPart;
/* lookup the element type name */
- elementType = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, tagNamePtr->str,0);
- if (!elementType) {
+ elementType
+ = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, tagNamePtr->str, 0);
+ if (! elementType) {
const XML_Char *name = poolCopyString(&dtd->pool, tagNamePtr->str);
- if (!name)
+ if (! name)
return XML_ERROR_NO_MEMORY;
elementType = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, name,
sizeof(ELEMENT_TYPE));
- if (!elementType)
+ if (! elementType)
return XML_ERROR_NO_MEMORY;
- if (ns && !setElementTypePrefix(parser, elementType))
+ if (parser->m_ns && ! setElementTypePrefix(parser, elementType))
return XML_ERROR_NO_MEMORY;
}
nDefaultAtts = elementType->nDefaultAtts;
/* get the attributes from the tokenizer */
- n = XmlGetAttributes(enc, attStr, attsSize, atts);
- if (n + nDefaultAtts > attsSize) {
- int oldAttsSize = attsSize;
+ n = XmlGetAttributes(enc, attStr, parser->m_attsSize, parser->m_atts);
+ if (n + nDefaultAtts > parser->m_attsSize) {
+ int oldAttsSize = parser->m_attsSize;
ATTRIBUTE *temp;
#ifdef XML_ATTR_INFO
XML_AttrInfo *temp2;
#endif
- attsSize = n + nDefaultAtts + INIT_ATTS_SIZE;
- temp = (ATTRIBUTE *)REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE));
+ parser->m_attsSize = n + nDefaultAtts + INIT_ATTS_SIZE;
+ temp = (ATTRIBUTE *)REALLOC(parser, (void *)parser->m_atts,
+ parser->m_attsSize * sizeof(ATTRIBUTE));
if (temp == NULL) {
- attsSize = oldAttsSize;
+ parser->m_attsSize = oldAttsSize;
return XML_ERROR_NO_MEMORY;
}
- atts = temp;
+ parser->m_atts = temp;
#ifdef XML_ATTR_INFO
- temp2 = (XML_AttrInfo *)REALLOC((void *)attInfo, attsSize * sizeof(XML_AttrInfo));
+ temp2 = (XML_AttrInfo *)REALLOC(parser, (void *)parser->m_attInfo,
+ parser->m_attsSize * sizeof(XML_AttrInfo));
if (temp2 == NULL) {
- attsSize = oldAttsSize;
+ parser->m_attsSize = oldAttsSize;
return XML_ERROR_NO_MEMORY;
}
- attInfo = temp2;
+ parser->m_attInfo = temp2;
#endif
if (n > oldAttsSize)
- XmlGetAttributes(enc, attStr, n, atts);
+ XmlGetAttributes(enc, attStr, n, parser->m_atts);
}
- appAtts = (const XML_Char **)atts;
+ appAtts = (const XML_Char **)parser->m_atts;
for (i = 0; i < n; i++) {
- ATTRIBUTE *currAtt = &atts[i];
+ ATTRIBUTE *currAtt = &parser->m_atts[i];
#ifdef XML_ATTR_INFO
- XML_AttrInfo *currAttInfo = &attInfo[i];
+ XML_AttrInfo *currAttInfo = &parser->m_attInfo[i];
#endif
/* add the name and value to the attribute list */
- ATTRIBUTE_ID *attId = getAttributeId(parser, enc, currAtt->name,
- currAtt->name
- + XmlNameLength(enc, currAtt->name));
- if (!attId)
+ ATTRIBUTE_ID *attId
+ = getAttributeId(parser, enc, currAtt->name,
+ currAtt->name + XmlNameLength(enc, currAtt->name));
+ if (! attId)
return XML_ERROR_NO_MEMORY;
#ifdef XML_ATTR_INFO
- currAttInfo->nameStart = parseEndByteIndex - (parseEndPtr - currAtt->name);
- currAttInfo->nameEnd = currAttInfo->nameStart +
- XmlNameLength(enc, currAtt->name);
- currAttInfo->valueStart = parseEndByteIndex -
- (parseEndPtr - currAtt->valuePtr);
- currAttInfo->valueEnd = parseEndByteIndex - (parseEndPtr - currAtt->valueEnd);
+ currAttInfo->nameStart
+ = parser->m_parseEndByteIndex - (parser->m_parseEndPtr - currAtt->name);
+ currAttInfo->nameEnd
+ = currAttInfo->nameStart + XmlNameLength(enc, currAtt->name);
+ currAttInfo->valueStart = parser->m_parseEndByteIndex
+ - (parser->m_parseEndPtr - currAtt->valuePtr);
+ currAttInfo->valueEnd = parser->m_parseEndByteIndex
+ - (parser->m_parseEndPtr - currAtt->valueEnd);
#endif
/* Detect duplicate attributes by their QNames. This does not work when
namespace processing is turned on and different prefixes for the same
namespace are used. For this case we have a check further down.
*/
if ((attId->name)[-1]) {
- if (enc == encoding)
- eventPtr = atts[i].name;
+ if (enc == parser->m_encoding)
+ parser->m_eventPtr = parser->m_atts[i].name;
return XML_ERROR_DUPLICATE_ATTRIBUTE;
}
(attId->name)[-1] = 1;
appAtts[attIndex++] = attId->name;
- if (!atts[i].normalized) {
+ if (! parser->m_atts[i].normalized) {
enum XML_Error result;
XML_Bool isCdata = XML_TRUE;
@@ -3282,21 +3144,21 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
}
/* normalize the attribute value */
- result = storeAttributeValue(parser, enc, isCdata,
- atts[i].valuePtr, atts[i].valueEnd,
- &tempPool);
+ result = storeAttributeValue(
+ parser, enc, isCdata, parser->m_atts[i].valuePtr,
+ parser->m_atts[i].valueEnd, &parser->m_tempPool);
if (result)
return result;
- appAtts[attIndex] = poolStart(&tempPool);
- poolFinish(&tempPool);
- }
- else {
+ appAtts[attIndex] = poolStart(&parser->m_tempPool);
+ poolFinish(&parser->m_tempPool);
+ } else {
/* the value did not need normalizing */
- appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr,
- atts[i].valueEnd);
+ appAtts[attIndex] = poolStoreString(&parser->m_tempPool, enc,
+ parser->m_atts[i].valuePtr,
+ parser->m_atts[i].valueEnd);
if (appAtts[attIndex] == 0)
return XML_ERROR_NO_MEMORY;
- poolFinish(&tempPool);
+ poolFinish(&parser->m_tempPool);
}
/* handle prefixed attribute names */
if (attId->prefix) {
@@ -3307,49 +3169,44 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
if (result)
return result;
--attIndex;
- }
- else {
+ } else {
/* deal with other prefixed names later */
attIndex++;
nPrefixes++;
(attId->name)[-1] = 2;
}
- }
- else
+ } else
attIndex++;
}
/* set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex */
- nSpecifiedAtts = attIndex;
+ parser->m_nSpecifiedAtts = attIndex;
if (elementType->idAtt && (elementType->idAtt->name)[-1]) {
for (i = 0; i < attIndex; i += 2)
if (appAtts[i] == elementType->idAtt->name) {
- idAttIndex = i;
+ parser->m_idAttIndex = i;
break;
}
- }
- else
- idAttIndex = -1;
+ } else
+ parser->m_idAttIndex = -1;
/* do attribute defaulting */
for (i = 0; i < nDefaultAtts; i++) {
const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + i;
- if (!(da->id->name)[-1] && da->value) {
+ if (! (da->id->name)[-1] && da->value) {
if (da->id->prefix) {
if (da->id->xmlns) {
enum XML_Error result = addBinding(parser, da->id->prefix, da->id,
da->value, bindingsPtr);
if (result)
return result;
- }
- else {
+ } else {
(da->id->name)[-1] = 2;
nPrefixes++;
appAtts[attIndex++] = da->id->name;
appAtts[attIndex++] = da->value;
}
- }
- else {
+ } else {
(da->id->name)[-1] = 1;
appAtts[attIndex++] = da->id->name;
appAtts[attIndex++] = da->value;
@@ -3362,39 +3219,42 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
and clear flags that say whether attributes were specified */
i = 0;
if (nPrefixes) {
- int j; /* hash table index */
- unsigned long version = nsAttsVersion;
- int nsAttsSize = (int)1 << nsAttsPower;
- unsigned char oldNsAttsPower = nsAttsPower;
+ int j; /* hash table index */
+ unsigned long version = parser->m_nsAttsVersion;
+ int nsAttsSize = (int)1 << parser->m_nsAttsPower;
+ unsigned char oldNsAttsPower = parser->m_nsAttsPower;
/* size of hash table must be at least 2 * (# of prefixed attributes) */
- if ((nPrefixes << 1) >> nsAttsPower) { /* true for nsAttsPower = 0 */
+ if ((nPrefixes << 1)
+ >> parser->m_nsAttsPower) { /* true for m_nsAttsPower = 0 */
NS_ATT *temp;
/* hash table size must also be a power of 2 and >= 8 */
- while (nPrefixes >> nsAttsPower++);
- if (nsAttsPower < 3)
- nsAttsPower = 3;
- nsAttsSize = (int)1 << nsAttsPower;
- temp = (NS_ATT *)REALLOC(nsAtts, nsAttsSize * sizeof(NS_ATT));
- if (!temp) {
- /* Restore actual size of memory in nsAtts */
- nsAttsPower = oldNsAttsPower;
+ while (nPrefixes >> parser->m_nsAttsPower++)
+ ;
+ if (parser->m_nsAttsPower < 3)
+ parser->m_nsAttsPower = 3;
+ nsAttsSize = (int)1 << parser->m_nsAttsPower;
+ temp = (NS_ATT *)REALLOC(parser, parser->m_nsAtts,
+ nsAttsSize * sizeof(NS_ATT));
+ if (! temp) {
+ /* Restore actual size of memory in m_nsAtts */
+ parser->m_nsAttsPower = oldNsAttsPower;
return XML_ERROR_NO_MEMORY;
}
- nsAtts = temp;
- version = 0; /* force re-initialization of nsAtts hash table */
+ parser->m_nsAtts = temp;
+ version = 0; /* force re-initialization of m_nsAtts hash table */
}
- /* using a version flag saves us from initializing nsAtts every time */
- if (!version) { /* initialize version flags when version wraps around */
+ /* using a version flag saves us from initializing m_nsAtts every time */
+ if (! version) { /* initialize version flags when version wraps around */
version = INIT_ATTS_VERSION;
- for (j = nsAttsSize; j != 0; )
- nsAtts[--j].version = version;
+ for (j = nsAttsSize; j != 0;)
+ parser->m_nsAtts[--j].version = version;
}
- nsAttsVersion = --version;
+ parser->m_nsAttsVersion = --version;
/* expand prefixed names and check for duplicates */
for (; i < attIndex; i += 2) {
const XML_Char *s = appAtts[i];
- if (s[-1] == 2) { /* prefixed */
+ if (s[-1] == 2) { /* prefixed */
ATTRIBUTE_ID *id;
const BINDING *b;
unsigned long uriHash;
@@ -3404,9 +3264,9 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
copy_salt_to_sipkey(parser, &sip_key);
sip24_init(&sip_state, &sip_key);
- ((XML_Char *)s)[-1] = 0; /* clear flag */
+ ((XML_Char *)s)[-1] = 0; /* clear flag */
id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, s, 0);
- if (!id || !id->prefix) {
+ if (! id || ! id->prefix) {
/* This code is walking through the appAtts array, dealing
* with (in this case) a prefixed attribute name. To be in
* the array, the attribute must have already been bound, so
@@ -3424,12 +3284,12 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
return XML_ERROR_NO_MEMORY; /* LCOV_EXCL_LINE */
}
b = id->prefix->binding;
- if (!b)
+ if (! b)
return XML_ERROR_UNBOUND_PREFIX;
for (j = 0; j < b->uriLen; j++) {
const XML_Char c = b->uri[j];
- if (!poolAppendChar(&tempPool, c))
+ if (! poolAppendChar(&parser->m_tempPool, c))
return XML_ERROR_NO_MEMORY;
}
@@ -3440,8 +3300,8 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
sip24_update(&sip_state, s, keylen(s) * sizeof(XML_Char));
- do { /* copies null terminator */
- if (!poolAppendChar(&tempPool, *s))
+ do { /* copies null terminator */
+ if (! poolAppendChar(&parser->m_tempPool, *s))
return XML_ERROR_NO_MEMORY;
} while (*s++);
@@ -3452,49 +3312,49 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
*/
unsigned char step = 0;
unsigned long mask = nsAttsSize - 1;
- j = uriHash & mask; /* index into hash table */
- while (nsAtts[j].version == version) {
+ j = uriHash & mask; /* index into hash table */
+ while (parser->m_nsAtts[j].version == version) {
/* for speed we compare stored hash values first */
- if (uriHash == nsAtts[j].hash) {
- const XML_Char *s1 = poolStart(&tempPool);
- const XML_Char *s2 = nsAtts[j].uriName;
+ if (uriHash == parser->m_nsAtts[j].hash) {
+ const XML_Char *s1 = poolStart(&parser->m_tempPool);
+ const XML_Char *s2 = parser->m_nsAtts[j].uriName;
/* s1 is null terminated, but not s2 */
- for (; *s1 == *s2 && *s1 != 0; s1++, s2++);
+ for (; *s1 == *s2 && *s1 != 0; s1++, s2++)
+ ;
if (*s1 == 0)
return XML_ERROR_DUPLICATE_ATTRIBUTE;
}
- if (!step)
- step = PROBE_STEP(uriHash, mask, nsAttsPower);
+ if (! step)
+ step = PROBE_STEP(uriHash, mask, parser->m_nsAttsPower);
j < step ? (j += nsAttsSize - step) : (j -= step);
}
}
- if (ns_triplets) { /* append namespace separator and prefix */
- tempPool.ptr[-1] = namespaceSeparator;
+ if (parser->m_ns_triplets) { /* append namespace separator and prefix */
+ parser->m_tempPool.ptr[-1] = parser->m_namespaceSeparator;
s = b->prefix->name;
do {
- if (!poolAppendChar(&tempPool, *s))
+ if (! poolAppendChar(&parser->m_tempPool, *s))
return XML_ERROR_NO_MEMORY;
} while (*s++);
}
/* store expanded name in attribute list */
- s = poolStart(&tempPool);
- poolFinish(&tempPool);
+ s = poolStart(&parser->m_tempPool);
+ poolFinish(&parser->m_tempPool);
appAtts[i] = s;
/* fill empty slot with new version, uriName and hash value */
- nsAtts[j].version = version;
- nsAtts[j].hash = uriHash;
- nsAtts[j].uriName = s;
+ parser->m_nsAtts[j].version = version;
+ parser->m_nsAtts[j].hash = uriHash;
+ parser->m_nsAtts[j].uriName = s;
- if (!--nPrefixes) {
+ if (! --nPrefixes) {
i += 2;
break;
}
- }
- else /* not prefixed */
- ((XML_Char *)s)[-1] = 0; /* clear flag */
+ } else /* not prefixed */
+ ((XML_Char *)s)[-1] = 0; /* clear flag */
}
}
/* clear flags for the remaining attributes */
@@ -3503,56 +3363,54 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding)
binding->attId->name[-1] = 0;
- if (!ns)
+ if (! parser->m_ns)
return XML_ERROR_NONE;
/* expand the element type name */
if (elementType->prefix) {
binding = elementType->prefix->binding;
- if (!binding)
+ if (! binding)
return XML_ERROR_UNBOUND_PREFIX;
localPart = tagNamePtr->str;
while (*localPart++ != XML_T(ASCII_COLON))
;
- }
- else if (dtd->defaultPrefix.binding) {
+ } else if (dtd->defaultPrefix.binding) {
binding = dtd->defaultPrefix.binding;
localPart = tagNamePtr->str;
- }
- else
+ } else
return XML_ERROR_NONE;
prefixLen = 0;
- if (ns_triplets && binding->prefix->name) {
+ if (parser->m_ns_triplets && binding->prefix->name) {
for (; binding->prefix->name[prefixLen++];)
- ; /* prefixLen includes null terminator */
+ ; /* prefixLen includes null terminator */
}
tagNamePtr->localPart = localPart;
tagNamePtr->uriLen = binding->uriLen;
tagNamePtr->prefix = binding->prefix->name;
tagNamePtr->prefixLen = prefixLen;
for (i = 0; localPart[i++];)
- ; /* i includes null terminator */
+ ; /* i includes null terminator */
n = i + binding->uriLen + prefixLen;
if (n > binding->uriAlloc) {
TAG *p;
- uri = (XML_Char *)MALLOC((n + EXPAND_SPARE) * sizeof(XML_Char));
- if (!uri)
+ uri = (XML_Char *)MALLOC(parser, (n + EXPAND_SPARE) * sizeof(XML_Char));
+ if (! uri)
return XML_ERROR_NO_MEMORY;
binding->uriAlloc = n + EXPAND_SPARE;
memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char));
- for (p = tagStack; p; p = p->parent)
+ for (p = parser->m_tagStack; p; p = p->parent)
if (p->name.str == binding->uri)
p->name.str = uri;
- FREE(binding->uri);
+ FREE(parser, binding->uri);
binding->uri = uri;
}
- /* if namespaceSeparator != '\0' then uri includes it already */
+ /* if m_namespaceSeparator != '\0' then uri includes it already */
uri = binding->uri + binding->uriLen;
memcpy(uri, localPart, i * sizeof(XML_Char));
/* we always have a namespace separator between localPart and prefix */
if (prefixLen) {
uri += i - 1;
- *uri = namespaceSeparator; /* replace null terminator */
+ *uri = parser->m_namespaceSeparator; /* replace null terminator */
memcpy(uri + 1, binding->prefix->name, prefixLen * sizeof(XML_Char));
}
tagNamePtr->str = binding->uri;
@@ -3564,27 +3422,25 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
*/
static enum XML_Error
addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
- const XML_Char *uri, BINDING **bindingsPtr)
-{
- static const XML_Char xmlNamespace[] = {
- ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH,
- ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD,
- ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L,
- ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, ASCII_8, ASCII_SLASH,
- ASCII_n, ASCII_a, ASCII_m, ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c,
- ASCII_e, '\0'
- };
- static const int xmlLen =
- (int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1;
- static const XML_Char xmlnsNamespace[] = {
- ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH,
- ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD,
- ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_2, ASCII_0, ASCII_0,
- ASCII_0, ASCII_SLASH, ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s,
- ASCII_SLASH, '\0'
- };
- static const int xmlnsLen =
- (int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1;
+ const XML_Char *uri, BINDING **bindingsPtr) {
+ static const XML_Char xmlNamespace[]
+ = {ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON,
+ ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w,
+ ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o,
+ ASCII_r, ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M,
+ ASCII_L, ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9,
+ ASCII_8, ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m,
+ ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c,
+ ASCII_e, '\0'};
+ static const int xmlLen = (int)sizeof(xmlNamespace) / sizeof(XML_Char) - 1;
+ static const XML_Char xmlnsNamespace[]
+ = {ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH,
+ ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w,
+ ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH,
+ ASCII_2, ASCII_0, ASCII_0, ASCII_0, ASCII_SLASH, ASCII_x,
+ ASCII_m, ASCII_l, ASCII_n, ASCII_s, ASCII_SLASH, '\0'};
+ static const int xmlnsLen
+ = (int)sizeof(xmlnsNamespace) / sizeof(XML_Char) - 1;
XML_Bool mustBeXML = XML_FALSE;
XML_Bool isXML = XML_TRUE;
@@ -3597,14 +3453,11 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
if (*uri == XML_T('\0') && prefix->name)
return XML_ERROR_UNDECLARING_PREFIX;
- if (prefix->name
- && prefix->name[0] == XML_T(ASCII_x)
+ if (prefix->name && prefix->name[0] == XML_T(ASCII_x)
&& prefix->name[1] == XML_T(ASCII_m)
&& prefix->name[2] == XML_T(ASCII_l)) {
-
/* Not allowed to bind xmlns */
- if (prefix->name[3] == XML_T(ASCII_n)
- && prefix->name[4] == XML_T(ASCII_s)
+ if (prefix->name[3] == XML_T(ASCII_n) && prefix->name[4] == XML_T(ASCII_s)
&& prefix->name[5] == XML_T('\0'))
return XML_ERROR_RESERVED_PREFIX_XMLNS;
@@ -3616,7 +3469,7 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len]))
isXML = XML_FALSE;
- if (!mustBeXML && isXMLNS
+ if (! mustBeXML && isXMLNS
&& (len > xmlnsLen || uri[len] != xmlnsNamespace[len]))
isXMLNS = XML_FALSE;
}
@@ -3630,49 +3483,49 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
if (isXMLNS)
return XML_ERROR_RESERVED_NAMESPACE_URI;
- if (namespaceSeparator)
+ if (parser->m_namespaceSeparator)
len++;
- if (freeBindingList) {
- b = freeBindingList;
+ if (parser->m_freeBindingList) {
+ b = parser->m_freeBindingList;
if (len > b->uriAlloc) {
- XML_Char *temp = (XML_Char *)REALLOC(b->uri,
- sizeof(XML_Char) * (len + EXPAND_SPARE));
+ XML_Char *temp = (XML_Char *)REALLOC(
+ parser, b->uri, sizeof(XML_Char) * (len + EXPAND_SPARE));
if (temp == NULL)
return XML_ERROR_NO_MEMORY;
b->uri = temp;
b->uriAlloc = len + EXPAND_SPARE;
}
- freeBindingList = b->nextTagBinding;
- }
- else {
- b = (BINDING *)MALLOC(sizeof(BINDING));
- if (!b)
+ parser->m_freeBindingList = b->nextTagBinding;
+ } else {
+ b = (BINDING *)MALLOC(parser, sizeof(BINDING));
+ if (! b)
return XML_ERROR_NO_MEMORY;
- b->uri = (XML_Char *)MALLOC(sizeof(XML_Char) * (len + EXPAND_SPARE));
- if (!b->uri) {
- FREE(b);
+ b->uri
+ = (XML_Char *)MALLOC(parser, sizeof(XML_Char) * (len + EXPAND_SPARE));
+ if (! b->uri) {
+ FREE(parser, b);
return XML_ERROR_NO_MEMORY;
}
b->uriAlloc = len + EXPAND_SPARE;
}
b->uriLen = len;
memcpy(b->uri, uri, len * sizeof(XML_Char));
- if (namespaceSeparator)
- b->uri[len - 1] = namespaceSeparator;
+ if (parser->m_namespaceSeparator)
+ b->uri[len - 1] = parser->m_namespaceSeparator;
b->prefix = prefix;
b->attId = attId;
b->prevPrefixBinding = prefix->binding;
/* NULL binding when default namespace undeclared */
- if (*uri == XML_T('\0') && prefix == &_dtd->defaultPrefix)
+ if (*uri == XML_T('\0') && prefix == &parser->m_dtd->defaultPrefix)
prefix->binding = NULL;
else
prefix->binding = b;
b->nextTagBinding = *bindingsPtr;
*bindingsPtr = b;
/* if attId == NULL then we are not starting a namespace scope */
- if (attId && startNamespaceDeclHandler)
- startNamespaceDeclHandler(handlerArg, prefix->name,
- prefix->binding ? uri : 0);
+ if (attId && parser->m_startNamespaceDeclHandler)
+ parser->m_startNamespaceDeclHandler(parser->m_handlerArg, prefix->name,
+ prefix->binding ? uri : 0);
return XML_ERROR_NONE;
}
@@ -3680,22 +3533,19 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
the whole file is parsed with one call.
*/
static enum XML_Error PTRCALL
-cdataSectionProcessor(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr)
-{
- enum XML_Error result = doCdataSection(parser, encoding, &start, end,
- endPtr, (XML_Bool)!ps_finalBuffer);
+cdataSectionProcessor(XML_Parser parser, const char *start, const char *end,
+ const char **endPtr) {
+ enum XML_Error result
+ = doCdataSection(parser, parser->m_encoding, &start, end, endPtr,
+ (XML_Bool)! parser->m_parsingStatus.finalBuffer);
if (result != XML_ERROR_NONE)
return result;
if (start) {
- if (parentParser) { /* we are parsing an external entity */
- processor = externalEntityContentProcessor;
+ if (parser->m_parentParser) { /* we are parsing an external entity */
+ parser->m_processor = externalEntityContentProcessor;
return externalEntityContentProcessor(parser, start, end, endPtr);
- }
- else {
- processor = contentProcessor;
+ } else {
+ parser->m_processor = contentProcessor;
return contentProcessor(parser, start, end, endPtr);
}
}
@@ -3706,24 +3556,18 @@ cdataSectionProcessor(XML_Parser parser,
the section is not yet closed.
*/
static enum XML_Error
-doCdataSection(XML_Parser parser,
- const ENCODING *enc,
- const char **startPtr,
- const char *end,
- const char **nextPtr,
- XML_Bool haveMore)
-{
+doCdataSection(XML_Parser parser, const ENCODING *enc, const char **startPtr,
+ const char *end, const char **nextPtr, XML_Bool haveMore) {
const char *s = *startPtr;
const char **eventPP;
const char **eventEndPP;
- if (enc == encoding) {
- eventPP = &eventPtr;
+ if (enc == parser->m_encoding) {
+ eventPP = &parser->m_eventPtr;
*eventPP = s;
- eventEndPP = &eventEndPtr;
- }
- else {
- eventPP = &(openInternalEntities->internalEventPtr);
- eventEndPP = &(openInternalEntities->internalEventEndPtr);
+ eventEndPP = &parser->m_eventEndPtr;
+ } else {
+ eventPP = &(parser->m_openInternalEntities->internalEventPtr);
+ eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr);
}
*eventPP = s;
*startPtr = NULL;
@@ -3734,54 +3578,51 @@ doCdataSection(XML_Parser parser,
*eventEndPP = next;
switch (tok) {
case XML_TOK_CDATA_SECT_CLOSE:
- if (endCdataSectionHandler)
- endCdataSectionHandler(handlerArg);
-#if 0
+ if (parser->m_endCdataSectionHandler)
+ parser->m_endCdataSectionHandler(parser->m_handlerArg);
+ /* BEGIN disabled code */
/* see comment under XML_TOK_CDATA_SECT_OPEN */
- else if (characterDataHandler)
- characterDataHandler(handlerArg, dataBuf, 0);
-#endif
- else if (defaultHandler)
+ else if (0 && parser->m_characterDataHandler)
+ parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf,
+ 0);
+ /* END disabled code */
+ else if (parser->m_defaultHandler)
reportDefault(parser, enc, s, next);
*startPtr = next;
*nextPtr = next;
- if (ps_parsing == XML_FINISHED)
+ if (parser->m_parsingStatus.parsing == XML_FINISHED)
return XML_ERROR_ABORTED;
else
return XML_ERROR_NONE;
case XML_TOK_DATA_NEWLINE:
- if (characterDataHandler) {
+ if (parser->m_characterDataHandler) {
XML_Char c = 0xA;
- characterDataHandler(handlerArg, &c, 1);
- }
- else if (defaultHandler)
+ parser->m_characterDataHandler(parser->m_handlerArg, &c, 1);
+ } else if (parser->m_defaultHandler)
reportDefault(parser, enc, s, next);
break;
- case XML_TOK_DATA_CHARS:
- {
- XML_CharacterDataHandler charDataHandler = characterDataHandler;
- if (charDataHandler) {
- if (MUST_CONVERT(enc, s)) {
- for (;;) {
- ICHAR *dataPtr = (ICHAR *)dataBuf;
- const enum XML_Convert_Result convert_res = XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd);
- *eventEndPP = next;
- charDataHandler(handlerArg, dataBuf,
- (int)(dataPtr - (ICHAR *)dataBuf));
- if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE))
- break;
- *eventPP = s;
- }
+ case XML_TOK_DATA_CHARS: {
+ XML_CharacterDataHandler charDataHandler = parser->m_characterDataHandler;
+ if (charDataHandler) {
+ if (MUST_CONVERT(enc, s)) {
+ for (;;) {
+ ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf;
+ const enum XML_Convert_Result convert_res = XmlConvert(
+ enc, &s, next, &dataPtr, (ICHAR *)parser->m_dataBufEnd);
+ *eventEndPP = next;
+ charDataHandler(parser->m_handlerArg, parser->m_dataBuf,
+ (int)(dataPtr - (ICHAR *)parser->m_dataBuf));
+ if ((convert_res == XML_CONVERT_COMPLETED)
+ || (convert_res == XML_CONVERT_INPUT_INCOMPLETE))
+ break;
+ *eventPP = s;
}
- else
- charDataHandler(handlerArg,
- (XML_Char *)s,
- (int)((XML_Char *)next - (XML_Char *)s));
- }
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- }
- break;
+ } else
+ charDataHandler(parser->m_handlerArg, (XML_Char *)s,
+ (int)((XML_Char *)next - (XML_Char *)s));
+ } else if (parser->m_defaultHandler)
+ reportDefault(parser, enc, s, next);
+ } break;
case XML_TOK_INVALID:
*eventPP = next;
return XML_ERROR_INVALID_TOKEN;
@@ -3805,20 +3646,20 @@ doCdataSection(XML_Parser parser,
* statistics.
*
* LCOV_EXCL_START
- */
+ */
*eventPP = next;
return XML_ERROR_UNEXPECTED_STATE;
/* LCOV_EXCL_STOP */
}
*eventPP = s = next;
- switch (ps_parsing) {
+ switch (parser->m_parsingStatus.parsing) {
case XML_SUSPENDED:
*nextPtr = next;
return XML_ERROR_NONE;
case XML_FINISHED:
return XML_ERROR_ABORTED;
- default: ;
+ default:;
}
}
/* not reached */
@@ -3830,17 +3671,15 @@ doCdataSection(XML_Parser parser,
the whole file is parsed with one call.
*/
static enum XML_Error PTRCALL
-ignoreSectionProcessor(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr)
-{
- enum XML_Error result = doIgnoreSection(parser, encoding, &start, end,
- endPtr, (XML_Bool)!ps_finalBuffer);
+ignoreSectionProcessor(XML_Parser parser, const char *start, const char *end,
+ const char **endPtr) {
+ enum XML_Error result
+ = doIgnoreSection(parser, parser->m_encoding, &start, end, endPtr,
+ (XML_Bool)! parser->m_parsingStatus.finalBuffer);
if (result != XML_ERROR_NONE)
return result;
if (start) {
- processor = prologProcessor;
+ parser->m_processor = prologProcessor;
return prologProcessor(parser, start, end, endPtr);
}
return result;
@@ -3850,27 +3689,21 @@ ignoreSectionProcessor(XML_Parser parser,
if the section is not yet closed.
*/
static enum XML_Error
-doIgnoreSection(XML_Parser parser,
- const ENCODING *enc,
- const char **startPtr,
- const char *end,
- const char **nextPtr,
- XML_Bool haveMore)
-{
+doIgnoreSection(XML_Parser parser, const ENCODING *enc, const char **startPtr,
+ const char *end, const char **nextPtr, XML_Bool haveMore) {
const char *next;
int tok;
const char *s = *startPtr;
const char **eventPP;
const char **eventEndPP;
- if (enc == encoding) {
- eventPP = &eventPtr;
+ if (enc == parser->m_encoding) {
+ eventPP = &parser->m_eventPtr;
*eventPP = s;
- eventEndPP = &eventEndPtr;
- }
- else {
+ eventEndPP = &parser->m_eventEndPtr;
+ } else {
/* It's not entirely clear, but it seems the following two lines
* of code cannot be executed. The only occasions on which 'enc'
- * is not 'parser->m_encoding' are when this function is called
+ * is not 'encoding' are when this function is called
* from the internal entity processing, and IGNORE sections are an
* error in internal entities.
*
@@ -3879,8 +3712,8 @@ doIgnoreSection(XML_Parser parser,
*
* LCOV_EXCL_START
*/
- eventPP = &(openInternalEntities->internalEventPtr);
- eventEndPP = &(openInternalEntities->internalEventEndPtr);
+ eventPP = &(parser->m_openInternalEntities->internalEventPtr);
+ eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr);
/* LCOV_EXCL_STOP */
}
*eventPP = s;
@@ -3889,11 +3722,11 @@ doIgnoreSection(XML_Parser parser,
*eventEndPP = next;
switch (tok) {
case XML_TOK_IGNORE_SECT:
- if (defaultHandler)
+ if (parser->m_defaultHandler)
reportDefault(parser, enc, s, next);
*startPtr = next;
*nextPtr = next;
- if (ps_parsing == XML_FINISHED)
+ if (parser->m_parsingStatus.parsing == XML_FINISHED)
return XML_ERROR_ABORTED;
else
return XML_ERROR_NONE;
@@ -3931,39 +3764,38 @@ doIgnoreSection(XML_Parser parser,
#endif /* XML_DTD */
static enum XML_Error
-initializeEncoding(XML_Parser parser)
-{
+initializeEncoding(XML_Parser parser) {
const char *s;
#ifdef XML_UNICODE
char encodingBuf[128];
/* See comments abount `protoclEncodingName` in parserInit() */
- if (!protocolEncodingName)
+ if (! parser->m_protocolEncodingName)
s = NULL;
else {
int i;
- for (i = 0; protocolEncodingName[i]; i++) {
+ for (i = 0; parser->m_protocolEncodingName[i]; i++) {
if (i == sizeof(encodingBuf) - 1
- || (protocolEncodingName[i] & ~0x7f) != 0) {
+ || (parser->m_protocolEncodingName[i] & ~0x7f) != 0) {
encodingBuf[0] = '\0';
break;
}
- encodingBuf[i] = (char)protocolEncodingName[i];
+ encodingBuf[i] = (char)parser->m_protocolEncodingName[i];
}
encodingBuf[i] = '\0';
s = encodingBuf;
}
#else
- s = protocolEncodingName;
+ s = parser->m_protocolEncodingName;
#endif
- if ((ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s))
+ if ((parser->m_ns ? XmlInitEncodingNS : XmlInitEncoding)(
+ &parser->m_initEncoding, &parser->m_encoding, s))
return XML_ERROR_NONE;
- return handleUnknownEncoding(parser, protocolEncodingName);
+ return handleUnknownEncoding(parser, parser->m_protocolEncodingName);
}
static enum XML_Error
-processXmlDecl(XML_Parser parser, int isGeneralTextEntity,
- const char *s, const char *next)
-{
+processXmlDecl(XML_Parser parser, int isGeneralTextEntity, const char *s,
+ const char *next) {
const char *encodingName = NULL;
const XML_Char *storedEncName = NULL;
const ENCODING *newEncoding = NULL;
@@ -3971,95 +3803,82 @@ processXmlDecl(XML_Parser parser, int isGeneralTextEntity,
const char *versionend;
const XML_Char *storedversion = NULL;
int standalone = -1;
- if (!(ns
- ? XmlParseXmlDeclNS
- : XmlParseXmlDecl)(isGeneralTextEntity,
- encoding,
- s,
- next,
- &eventPtr,
- &version,
- &versionend,
- &encodingName,
- &newEncoding,
- &standalone)) {
+ if (! (parser->m_ns ? XmlParseXmlDeclNS : XmlParseXmlDecl)(
+ isGeneralTextEntity, parser->m_encoding, s, next, &parser->m_eventPtr,
+ &version, &versionend, &encodingName, &newEncoding, &standalone)) {
if (isGeneralTextEntity)
return XML_ERROR_TEXT_DECL;
else
return XML_ERROR_XML_DECL;
}
- if (!isGeneralTextEntity && standalone == 1) {
- _dtd->standalone = XML_TRUE;
+ if (! isGeneralTextEntity && standalone == 1) {
+ parser->m_dtd->standalone = XML_TRUE;
#ifdef XML_DTD
- if (paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE)
- paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
+ if (parser->m_paramEntityParsing
+ == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE)
+ parser->m_paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER;
#endif /* XML_DTD */
}
- if (xmlDeclHandler) {
+ if (parser->m_xmlDeclHandler) {
if (encodingName != NULL) {
- storedEncName = poolStoreString(&temp2Pool,
- encoding,
- encodingName,
- encodingName
- + XmlNameLength(encoding, encodingName));
- if (!storedEncName)
- return XML_ERROR_NO_MEMORY;
- poolFinish(&temp2Pool);
+ storedEncName = poolStoreString(
+ &parser->m_temp2Pool, parser->m_encoding, encodingName,
+ encodingName + XmlNameLength(parser->m_encoding, encodingName));
+ if (! storedEncName)
+ return XML_ERROR_NO_MEMORY;
+ poolFinish(&parser->m_temp2Pool);
}
if (version) {
- storedversion = poolStoreString(&temp2Pool,
- encoding,
- version,
- versionend - encoding->minBytesPerChar);
- if (!storedversion)
+ storedversion
+ = poolStoreString(&parser->m_temp2Pool, parser->m_encoding, version,
+ versionend - parser->m_encoding->minBytesPerChar);
+ if (! storedversion)
return XML_ERROR_NO_MEMORY;
}
- xmlDeclHandler(handlerArg, storedversion, storedEncName, standalone);
- }
- else if (defaultHandler)
- reportDefault(parser, encoding, s, next);
- if (protocolEncodingName == NULL) {
+ parser->m_xmlDeclHandler(parser->m_handlerArg, storedversion, storedEncName,
+ standalone);
+ } else if (parser->m_defaultHandler)
+ reportDefault(parser, parser->m_encoding, s, next);
+ if (parser->m_protocolEncodingName == NULL) {
if (newEncoding) {
/* Check that the specified encoding does not conflict with what
* the parser has already deduced. Do we have the same number
* of bytes in the smallest representation of a character? If
* this is UTF-16, is it the same endianness?
*/
- if (newEncoding->minBytesPerChar != encoding->minBytesPerChar
- || (newEncoding->minBytesPerChar == 2 &&
- newEncoding != encoding)) {
- eventPtr = encodingName;
+ if (newEncoding->minBytesPerChar != parser->m_encoding->minBytesPerChar
+ || (newEncoding->minBytesPerChar == 2
+ && newEncoding != parser->m_encoding)) {
+ parser->m_eventPtr = encodingName;
return XML_ERROR_INCORRECT_ENCODING;
}
- encoding = newEncoding;
- }
- else if (encodingName) {
+ parser->m_encoding = newEncoding;
+ } else if (encodingName) {
enum XML_Error result;
- if (!storedEncName) {
+ if (! storedEncName) {
storedEncName = poolStoreString(
- &temp2Pool, encoding, encodingName,
- encodingName + XmlNameLength(encoding, encodingName));
- if (!storedEncName)
+ &parser->m_temp2Pool, parser->m_encoding, encodingName,
+ encodingName + XmlNameLength(parser->m_encoding, encodingName));
+ if (! storedEncName)
return XML_ERROR_NO_MEMORY;
}
result = handleUnknownEncoding(parser, storedEncName);
- poolClear(&temp2Pool);
+ poolClear(&parser->m_temp2Pool);
if (result == XML_ERROR_UNKNOWN_ENCODING)
- eventPtr = encodingName;
+ parser->m_eventPtr = encodingName;
return result;
}
}
if (storedEncName || storedversion)
- poolClear(&temp2Pool);
+ poolClear(&parser->m_temp2Pool);
return XML_ERROR_NONE;
}
static enum XML_Error
-handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName)
-{
- if (unknownEncodingHandler) {
+handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) {
+ if (parser->m_unknownEncodingHandler) {
XML_Encoding info;
int i;
for (i = 0; i < 256; i++)
@@ -4067,25 +3886,21 @@ handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName)
info.convert = NULL;
info.data = NULL;
info.release = NULL;
- if (unknownEncodingHandler(unknownEncodingHandlerData, encodingName,
- &info)) {
+ if (parser->m_unknownEncodingHandler(parser->m_unknownEncodingHandlerData,
+ encodingName, &info)) {
ENCODING *enc;
- unknownEncodingMem = MALLOC(XmlSizeOfUnknownEncoding());
- if (!unknownEncodingMem) {
+ parser->m_unknownEncodingMem = MALLOC(parser, XmlSizeOfUnknownEncoding());
+ if (! parser->m_unknownEncodingMem) {
if (info.release)
info.release(info.data);
return XML_ERROR_NO_MEMORY;
}
- enc = (ns
- ? XmlInitUnknownEncodingNS
- : XmlInitUnknownEncoding)(unknownEncodingMem,
- info.map,
- info.convert,
- info.data);
+ enc = (parser->m_ns ? XmlInitUnknownEncodingNS : XmlInitUnknownEncoding)(
+ parser->m_unknownEncodingMem, info.map, info.convert, info.data);
if (enc) {
- unknownEncodingData = info.data;
- unknownEncodingRelease = info.release;
- encoding = enc;
+ parser->m_unknownEncodingData = info.data;
+ parser->m_unknownEncodingRelease = info.release;
+ parser->m_encoding = enc;
return XML_ERROR_NONE;
}
}
@@ -4096,60 +3911,50 @@ handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName)
}
static enum XML_Error PTRCALL
-prologInitProcessor(XML_Parser parser,
- const char *s,
- const char *end,
- const char **nextPtr)
-{
+prologInitProcessor(XML_Parser parser, const char *s, const char *end,
+ const char **nextPtr) {
enum XML_Error result = initializeEncoding(parser);
if (result != XML_ERROR_NONE)
return result;
- processor = prologProcessor;
+ parser->m_processor = prologProcessor;
return prologProcessor(parser, s, end, nextPtr);
}
#ifdef XML_DTD
static enum XML_Error PTRCALL
-externalParEntInitProcessor(XML_Parser parser,
- const char *s,
- const char *end,
- const char **nextPtr)
-{
+externalParEntInitProcessor(XML_Parser parser, const char *s, const char *end,
+ const char **nextPtr) {
enum XML_Error result = initializeEncoding(parser);
if (result != XML_ERROR_NONE)
return result;
/* we know now that XML_Parse(Buffer) has been called,
so we consider the external parameter entity read */
- _dtd->paramEntityRead = XML_TRUE;
+ parser->m_dtd->paramEntityRead = XML_TRUE;
- if (prologState.inEntityValue) {
- processor = entityValueInitProcessor;
+ if (parser->m_prologState.inEntityValue) {
+ parser->m_processor = entityValueInitProcessor;
return entityValueInitProcessor(parser, s, end, nextPtr);
- }
- else {
- processor = externalParEntProcessor;
+ } else {
+ parser->m_processor = externalParEntProcessor;
return externalParEntProcessor(parser, s, end, nextPtr);
}
}
static enum XML_Error PTRCALL
-entityValueInitProcessor(XML_Parser parser,
- const char *s,
- const char *end,
- const char **nextPtr)
-{
+entityValueInitProcessor(XML_Parser parser, const char *s, const char *end,
+ const char **nextPtr) {
int tok;
const char *start = s;
const char *next = start;
- eventPtr = start;
+ parser->m_eventPtr = start;
for (;;) {
- tok = XmlPrologTok(encoding, start, end, &next);
- eventEndPtr = next;
+ tok = XmlPrologTok(parser->m_encoding, start, end, &next);
+ parser->m_eventEndPtr = next;
if (tok <= 0) {
- if (!ps_finalBuffer && tok != XML_TOK_INVALID) {
+ if (! parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) {
*nextPtr = s;
return XML_ERROR_NONE;
}
@@ -4160,28 +3965,27 @@ entityValueInitProcessor(XML_Parser parser,
return XML_ERROR_UNCLOSED_TOKEN;
case XML_TOK_PARTIAL_CHAR:
return XML_ERROR_PARTIAL_CHAR;
- case XML_TOK_NONE: /* start == end */
+ case XML_TOK_NONE: /* start == end */
default:
break;
}
/* found end of entity value - can store it now */
- return storeEntityValue(parser, encoding, s, end);
- }
- else if (tok == XML_TOK_XML_DECL) {
+ return storeEntityValue(parser, parser->m_encoding, s, end);
+ } else if (tok == XML_TOK_XML_DECL) {
enum XML_Error result;
result = processXmlDecl(parser, 0, start, next);
if (result != XML_ERROR_NONE)
return result;
- /* At this point, ps_parsing cannot be XML_SUSPENDED. For that
- * to happen, a parameter entity parsing handler must have
- * attempted to suspend the parser, which fails and raises an
- * error. The parser can be aborted, but can't be suspended.
+ /* At this point, m_parsingStatus.parsing cannot be XML_SUSPENDED. For
+ * that to happen, a parameter entity parsing handler must have attempted
+ * to suspend the parser, which fails and raises an error. The parser can
+ * be aborted, but can't be suspended.
*/
- if (ps_parsing == XML_FINISHED)
+ if (parser->m_parsingStatus.parsing == XML_FINISHED)
return XML_ERROR_ABORTED;
*nextPtr = next;
/* stop scanning for text declaration - we found one */
- processor = entityValueProcessor;
+ parser->m_processor = entityValueProcessor;
return entityValueProcessor(parser, next, end, nextPtr);
}
/* If we are at the end of the buffer, this would cause XmlPrologTok to
@@ -4191,7 +3995,8 @@ entityValueInitProcessor(XML_Parser parser,
then, when this routine is entered the next time, XmlPrologTok will
return XML_TOK_INVALID, since the BOM is still in the buffer
*/
- else if (tok == XML_TOK_BOM && next == end && !ps_finalBuffer) {
+ else if (tok == XML_TOK_BOM && next == end
+ && ! parser->m_parsingStatus.finalBuffer) {
*nextPtr = next;
return XML_ERROR_NONE;
}
@@ -4204,22 +4009,19 @@ entityValueInitProcessor(XML_Parser parser,
return XML_ERROR_SYNTAX;
}
start = next;
- eventPtr = start;
+ parser->m_eventPtr = start;
}
}
static enum XML_Error PTRCALL
-externalParEntProcessor(XML_Parser parser,
- const char *s,
- const char *end,
- const char **nextPtr)
-{
+externalParEntProcessor(XML_Parser parser, const char *s, const char *end,
+ const char **nextPtr) {
const char *next = s;
int tok;
- tok = XmlPrologTok(encoding, s, end, &next);
+ tok = XmlPrologTok(parser->m_encoding, s, end, &next);
if (tok <= 0) {
- if (!ps_finalBuffer && tok != XML_TOK_INVALID) {
+ if (! parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) {
*nextPtr = s;
return XML_ERROR_NONE;
}
@@ -4230,7 +4032,7 @@ externalParEntProcessor(XML_Parser parser,
return XML_ERROR_UNCLOSED_TOKEN;
case XML_TOK_PARTIAL_CHAR:
return XML_ERROR_PARTIAL_CHAR;
- case XML_TOK_NONE: /* start == end */
+ case XML_TOK_NONE: /* start == end */
default:
break;
}
@@ -4241,29 +4043,26 @@ externalParEntProcessor(XML_Parser parser,
*/
else if (tok == XML_TOK_BOM) {
s = next;
- tok = XmlPrologTok(encoding, s, end, &next);
+ tok = XmlPrologTok(parser->m_encoding, s, end, &next);
}
- processor = prologProcessor;
- return doProlog(parser, encoding, s, end, tok, next,
- nextPtr, (XML_Bool)!ps_finalBuffer);
+ parser->m_processor = prologProcessor;
+ return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr,
+ (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE);
}
static enum XML_Error PTRCALL
-entityValueProcessor(XML_Parser parser,
- const char *s,
- const char *end,
- const char **nextPtr)
-{
+entityValueProcessor(XML_Parser parser, const char *s, const char *end,
+ const char **nextPtr) {
const char *start = s;
const char *next = s;
- const ENCODING *enc = encoding;
+ const ENCODING *enc = parser->m_encoding;
int tok;
for (;;) {
tok = XmlPrologTok(enc, start, end, &next);
if (tok <= 0) {
- if (!ps_finalBuffer && tok != XML_TOK_INVALID) {
+ if (! parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) {
*nextPtr = s;
return XML_ERROR_NONE;
}
@@ -4274,7 +4073,7 @@ entityValueProcessor(XML_Parser parser,
return XML_ERROR_UNCLOSED_TOKEN;
case XML_TOK_PARTIAL_CHAR:
return XML_ERROR_PARTIAL_CHAR;
- case XML_TOK_NONE: /* start == end */
+ case XML_TOK_NONE: /* start == end */
default:
break;
}
@@ -4288,64 +4087,57 @@ entityValueProcessor(XML_Parser parser,
#endif /* XML_DTD */
static enum XML_Error PTRCALL
-prologProcessor(XML_Parser parser,
- const char *s,
- const char *end,
- const char **nextPtr)
-{
+prologProcessor(XML_Parser parser, const char *s, const char *end,
+ const char **nextPtr) {
const char *next = s;
- int tok = XmlPrologTok(encoding, s, end, &next);
- return doProlog(parser, encoding, s, end, tok, next,
- nextPtr, (XML_Bool)!ps_finalBuffer);
+ int tok = XmlPrologTok(parser->m_encoding, s, end, &next);
+ return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr,
+ (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE);
}
static enum XML_Error
-doProlog(XML_Parser parser,
- const ENCODING *enc,
- const char *s,
- const char *end,
- int tok,
- const char *next,
- const char **nextPtr,
- XML_Bool haveMore)
-{
+doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
+ int tok, const char *next, const char **nextPtr, XML_Bool haveMore,
+ XML_Bool allowClosingDoctype) {
#ifdef XML_DTD
- static const XML_Char externalSubsetName[] = { ASCII_HASH , '\0' };
+ static const XML_Char externalSubsetName[] = {ASCII_HASH, '\0'};
#endif /* XML_DTD */
- static const XML_Char atypeCDATA[] =
- { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
- static const XML_Char atypeID[] = { ASCII_I, ASCII_D, '\0' };
- static const XML_Char atypeIDREF[] =
- { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' };
- static const XML_Char atypeIDREFS[] =
- { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' };
- static const XML_Char atypeENTITY[] =
- { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' };
- static const XML_Char atypeENTITIES[] = { ASCII_E, ASCII_N,
- ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, '\0' };
- static const XML_Char atypeNMTOKEN[] = {
- ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' };
- static const XML_Char atypeNMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T,
- ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' };
- static const XML_Char notationPrefix[] = { ASCII_N, ASCII_O, ASCII_T,
- ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, ASCII_LPAREN, '\0' };
- static const XML_Char enumValueSep[] = { ASCII_PIPE, '\0' };
- static const XML_Char enumValueStart[] = { ASCII_LPAREN, '\0' };
+ static const XML_Char atypeCDATA[]
+ = {ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0'};
+ static const XML_Char atypeID[] = {ASCII_I, ASCII_D, '\0'};
+ static const XML_Char atypeIDREF[]
+ = {ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0'};
+ static const XML_Char atypeIDREFS[]
+ = {ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0'};
+ static const XML_Char atypeENTITY[]
+ = {ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0'};
+ static const XML_Char atypeENTITIES[]
+ = {ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T,
+ ASCII_I, ASCII_E, ASCII_S, '\0'};
+ static const XML_Char atypeNMTOKEN[]
+ = {ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0'};
+ static const XML_Char atypeNMTOKENS[]
+ = {ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K,
+ ASCII_E, ASCII_N, ASCII_S, '\0'};
+ static const XML_Char notationPrefix[]
+ = {ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T,
+ ASCII_I, ASCII_O, ASCII_N, ASCII_LPAREN, '\0'};
+ static const XML_Char enumValueSep[] = {ASCII_PIPE, '\0'};
+ static const XML_Char enumValueStart[] = {ASCII_LPAREN, '\0'};
/* save one level of indirection */
- DTD * const dtd = _dtd;
+ DTD *const dtd = parser->m_dtd;
const char **eventPP;
const char **eventEndPP;
enum XML_Content_Quant quant;
- if (enc == encoding) {
- eventPP = &eventPtr;
- eventEndPP = &eventEndPtr;
- }
- else {
- eventPP = &(openInternalEntities->internalEventPtr);
- eventEndPP = &(openInternalEntities->internalEventEndPtr);
+ if (enc == parser->m_encoding) {
+ eventPP = &parser->m_eventPtr;
+ eventEndPP = &parser->m_eventEndPtr;
+ } else {
+ eventPP = &(parser->m_openInternalEntities->internalEventPtr);
+ eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr);
}
for (;;) {
@@ -4372,7 +4164,8 @@ doProlog(XML_Parser parser,
case XML_TOK_NONE:
#ifdef XML_DTD
/* for internal PE NOT referenced between declarations */
- if (enc != encoding && !openInternalEntities->betweenDecl) {
+ if (enc != parser->m_encoding
+ && ! parser->m_openInternalEntities->betweenDecl) {
*nextPtr = s;
return XML_ERROR_NONE;
}
@@ -4380,8 +4173,8 @@ doProlog(XML_Parser parser,
complete markup, not only for external PEs, but also for
internal PEs if the reference occurs between declarations.
*/
- if (isParamEntity || enc != encoding) {
- if (XmlTokenRole(&prologState, XML_TOK_NONE, end, end, enc)
+ if (parser->m_isParamEntity || enc != parser->m_encoding) {
+ if (XmlTokenRole(&parser->m_prologState, XML_TOK_NONE, end, end, enc)
== XML_ROLE_ERROR)
return XML_ERROR_INCOMPLETE_PE;
*nextPtr = s;
@@ -4395,114 +4188,117 @@ doProlog(XML_Parser parser,
break;
}
}
- role = XmlTokenRole(&prologState, tok, s, next, enc);
+ role = XmlTokenRole(&parser->m_prologState, tok, s, next, enc);
switch (role) {
- case XML_ROLE_XML_DECL:
- {
- enum XML_Error result = processXmlDecl(parser, 0, s, next);
- if (result != XML_ERROR_NONE)
- return result;
- enc = encoding;
- handleDefault = XML_FALSE;
- }
- break;
+ case XML_ROLE_XML_DECL: {
+ enum XML_Error result = processXmlDecl(parser, 0, s, next);
+ if (result != XML_ERROR_NONE)
+ return result;
+ enc = parser->m_encoding;
+ handleDefault = XML_FALSE;
+ } break;
case XML_ROLE_DOCTYPE_NAME:
- if (startDoctypeDeclHandler) {
- doctypeName = poolStoreString(&tempPool, enc, s, next);
- if (!doctypeName)
+ if (parser->m_startDoctypeDeclHandler) {
+ parser->m_doctypeName
+ = poolStoreString(&parser->m_tempPool, enc, s, next);
+ if (! parser->m_doctypeName)
return XML_ERROR_NO_MEMORY;
- poolFinish(&tempPool);
- doctypePubid = NULL;
+ poolFinish(&parser->m_tempPool);
+ parser->m_doctypePubid = NULL;
handleDefault = XML_FALSE;
}
- doctypeSysid = NULL; /* always initialize to NULL */
+ parser->m_doctypeSysid = NULL; /* always initialize to NULL */
break;
case XML_ROLE_DOCTYPE_INTERNAL_SUBSET:
- if (startDoctypeDeclHandler) {
- startDoctypeDeclHandler(handlerArg, doctypeName, doctypeSysid,
- doctypePubid, 1);
- doctypeName = NULL;
- poolClear(&tempPool);
+ if (parser->m_startDoctypeDeclHandler) {
+ parser->m_startDoctypeDeclHandler(
+ parser->m_handlerArg, parser->m_doctypeName, parser->m_doctypeSysid,
+ parser->m_doctypePubid, 1);
+ parser->m_doctypeName = NULL;
+ poolClear(&parser->m_tempPool);
handleDefault = XML_FALSE;
}
break;
#ifdef XML_DTD
- case XML_ROLE_TEXT_DECL:
- {
- enum XML_Error result = processXmlDecl(parser, 1, s, next);
- if (result != XML_ERROR_NONE)
- return result;
- enc = encoding;
- handleDefault = XML_FALSE;
- }
- break;
+ case XML_ROLE_TEXT_DECL: {
+ enum XML_Error result = processXmlDecl(parser, 1, s, next);
+ if (result != XML_ERROR_NONE)
+ return result;
+ enc = parser->m_encoding;
+ handleDefault = XML_FALSE;
+ } break;
#endif /* XML_DTD */
case XML_ROLE_DOCTYPE_PUBLIC_ID:
#ifdef XML_DTD
- useForeignDTD = XML_FALSE;
- declEntity = (ENTITY *)lookup(parser,
- &dtd->paramEntities,
- externalSubsetName,
- sizeof(ENTITY));
- if (!declEntity)
+ parser->m_useForeignDTD = XML_FALSE;
+ parser->m_declEntity = (ENTITY *)lookup(
+ parser, &dtd->paramEntities, externalSubsetName, sizeof(ENTITY));
+ if (! parser->m_declEntity)
return XML_ERROR_NO_MEMORY;
#endif /* XML_DTD */
dtd->hasParamEntityRefs = XML_TRUE;
- if (startDoctypeDeclHandler) {
+ if (parser->m_startDoctypeDeclHandler) {
XML_Char *pubId;
- if (!XmlIsPublicId(enc, s, next, eventPP))
+ if (! XmlIsPublicId(enc, s, next, eventPP))
return XML_ERROR_PUBLICID;
- pubId = poolStoreString(&tempPool, enc,
+ pubId = poolStoreString(&parser->m_tempPool, enc,
s + enc->minBytesPerChar,
next - enc->minBytesPerChar);
- if (!pubId)
+ if (! pubId)
return XML_ERROR_NO_MEMORY;
normalizePublicId(pubId);
- poolFinish(&tempPool);
- doctypePubid = pubId;
+ poolFinish(&parser->m_tempPool);
+ parser->m_doctypePubid = pubId;
handleDefault = XML_FALSE;
goto alreadyChecked;
}
/* fall through */
case XML_ROLE_ENTITY_PUBLIC_ID:
- if (!XmlIsPublicId(enc, s, next, eventPP))
+ if (! XmlIsPublicId(enc, s, next, eventPP))
return XML_ERROR_PUBLICID;
alreadyChecked:
- if (dtd->keepProcessing && declEntity) {
- XML_Char *tem = poolStoreString(&dtd->pool,
- enc,
- s + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (!tem)
+ if (dtd->keepProcessing && parser->m_declEntity) {
+ XML_Char *tem
+ = poolStoreString(&dtd->pool, enc, s + enc->minBytesPerChar,
+ next - enc->minBytesPerChar);
+ if (! tem)
return XML_ERROR_NO_MEMORY;
normalizePublicId(tem);
- declEntity->publicId = tem;
+ parser->m_declEntity->publicId = tem;
poolFinish(&dtd->pool);
- if (entityDeclHandler)
+ /* Don't suppress the default handler if we fell through from
+ * the XML_ROLE_DOCTYPE_PUBLIC_ID case.
+ */
+ if (parser->m_entityDeclHandler && role == XML_ROLE_ENTITY_PUBLIC_ID)
handleDefault = XML_FALSE;
}
break;
case XML_ROLE_DOCTYPE_CLOSE:
- if (doctypeName) {
- startDoctypeDeclHandler(handlerArg, doctypeName,
- doctypeSysid, doctypePubid, 0);
- poolClear(&tempPool);
+ if (allowClosingDoctype != XML_TRUE) {
+ /* Must not close doctype from within expanded parameter entities */
+ return XML_ERROR_INVALID_TOKEN;
+ }
+
+ if (parser->m_doctypeName) {
+ parser->m_startDoctypeDeclHandler(
+ parser->m_handlerArg, parser->m_doctypeName, parser->m_doctypeSysid,
+ parser->m_doctypePubid, 0);
+ poolClear(&parser->m_tempPool);
handleDefault = XML_FALSE;
}
- /* doctypeSysid will be non-NULL in the case of a previous
- XML_ROLE_DOCTYPE_SYSTEM_ID, even if startDoctypeDeclHandler
+ /* parser->m_doctypeSysid will be non-NULL in the case of a previous
+ XML_ROLE_DOCTYPE_SYSTEM_ID, even if parser->m_startDoctypeDeclHandler
was not set, indicating an external subset
*/
#ifdef XML_DTD
- if (doctypeSysid || useForeignDTD) {
+ if (parser->m_doctypeSysid || parser->m_useForeignDTD) {
XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs;
dtd->hasParamEntityRefs = XML_TRUE;
- if (paramEntityParsing && externalEntityRefHandler) {
- ENTITY *entity = (ENTITY *)lookup(parser,
- &dtd->paramEntities,
- externalSubsetName,
- sizeof(ENTITY));
- if (!entity) {
+ if (parser->m_paramEntityParsing
+ && parser->m_externalEntityRefHandler) {
+ ENTITY *entity = (ENTITY *)lookup(parser, &dtd->paramEntities,
+ externalSubsetName, sizeof(ENTITY));
+ if (! entity) {
/* The external subset name "#" will have already been
* inserted into the hash table at the start of the
* external entity parsing, so no allocation will happen
@@ -4510,33 +4306,30 @@ doProlog(XML_Parser parser,
*/
return XML_ERROR_NO_MEMORY; /* LCOV_EXCL_LINE */
}
- if (useForeignDTD)
- entity->base = curBase;
+ if (parser->m_useForeignDTD)
+ entity->base = parser->m_curBase;
dtd->paramEntityRead = XML_FALSE;
- if (!externalEntityRefHandler(externalEntityRefHandlerArg,
- 0,
- entity->base,
- entity->systemId,
- entity->publicId))
+ if (! parser->m_externalEntityRefHandler(
+ parser->m_externalEntityRefHandlerArg, 0, entity->base,
+ entity->systemId, entity->publicId))
return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
if (dtd->paramEntityRead) {
- if (!dtd->standalone &&
- notStandaloneHandler &&
- !notStandaloneHandler(handlerArg))
+ if (! dtd->standalone && parser->m_notStandaloneHandler
+ && ! parser->m_notStandaloneHandler(parser->m_handlerArg))
return XML_ERROR_NOT_STANDALONE;
}
/* if we didn't read the foreign DTD then this means that there
is no external subset and we must reset dtd->hasParamEntityRefs
*/
- else if (!doctypeSysid)
+ else if (! parser->m_doctypeSysid)
dtd->hasParamEntityRefs = hadParamEntityRefs;
/* end of DTD - no need to update dtd->keepProcessing */
}
- useForeignDTD = XML_FALSE;
+ parser->m_useForeignDTD = XML_FALSE;
}
#endif /* XML_DTD */
- if (endDoctypeDeclHandler) {
- endDoctypeDeclHandler(handlerArg);
+ if (parser->m_endDoctypeDeclHandler) {
+ parser->m_endDoctypeDeclHandler(parser->m_handlerArg);
handleDefault = XML_FALSE;
}
break;
@@ -4545,27 +4338,24 @@ doProlog(XML_Parser parser,
/* if there is no DOCTYPE declaration then now is the
last chance to read the foreign DTD
*/
- if (useForeignDTD) {
+ if (parser->m_useForeignDTD) {
XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs;
dtd->hasParamEntityRefs = XML_TRUE;
- if (paramEntityParsing && externalEntityRefHandler) {
+ if (parser->m_paramEntityParsing
+ && parser->m_externalEntityRefHandler) {
ENTITY *entity = (ENTITY *)lookup(parser, &dtd->paramEntities,
- externalSubsetName,
- sizeof(ENTITY));
- if (!entity)
+ externalSubsetName, sizeof(ENTITY));
+ if (! entity)
return XML_ERROR_NO_MEMORY;
- entity->base = curBase;
+ entity->base = parser->m_curBase;
dtd->paramEntityRead = XML_FALSE;
- if (!externalEntityRefHandler(externalEntityRefHandlerArg,
- 0,
- entity->base,
- entity->systemId,
- entity->publicId))
+ if (! parser->m_externalEntityRefHandler(
+ parser->m_externalEntityRefHandlerArg, 0, entity->base,
+ entity->systemId, entity->publicId))
return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
if (dtd->paramEntityRead) {
- if (!dtd->standalone &&
- notStandaloneHandler &&
- !notStandaloneHandler(handlerArg))
+ if (! dtd->standalone && parser->m_notStandaloneHandler
+ && ! parser->m_notStandaloneHandler(parser->m_handlerArg))
return XML_ERROR_NOT_STANDALONE;
}
/* if we didn't read the foreign DTD then this means that there
@@ -4577,93 +4367,93 @@ doProlog(XML_Parser parser,
}
}
#endif /* XML_DTD */
- processor = contentProcessor;
+ parser->m_processor = contentProcessor;
return contentProcessor(parser, s, end, nextPtr);
case XML_ROLE_ATTLIST_ELEMENT_NAME:
- declElementType = getElementType(parser, enc, s, next);
- if (!declElementType)
+ parser->m_declElementType = getElementType(parser, enc, s, next);
+ if (! parser->m_declElementType)
return XML_ERROR_NO_MEMORY;
goto checkAttListDeclHandler;
case XML_ROLE_ATTRIBUTE_NAME:
- declAttributeId = getAttributeId(parser, enc, s, next);
- if (!declAttributeId)
+ parser->m_declAttributeId = getAttributeId(parser, enc, s, next);
+ if (! parser->m_declAttributeId)
return XML_ERROR_NO_MEMORY;
- declAttributeIsCdata = XML_FALSE;
- declAttributeType = NULL;
- declAttributeIsId = XML_FALSE;
+ parser->m_declAttributeIsCdata = XML_FALSE;
+ parser->m_declAttributeType = NULL;
+ parser->m_declAttributeIsId = XML_FALSE;
goto checkAttListDeclHandler;
case XML_ROLE_ATTRIBUTE_TYPE_CDATA:
- declAttributeIsCdata = XML_TRUE;
- declAttributeType = atypeCDATA;
+ parser->m_declAttributeIsCdata = XML_TRUE;
+ parser->m_declAttributeType = atypeCDATA;
goto checkAttListDeclHandler;
case XML_ROLE_ATTRIBUTE_TYPE_ID:
- declAttributeIsId = XML_TRUE;
- declAttributeType = atypeID;
+ parser->m_declAttributeIsId = XML_TRUE;
+ parser->m_declAttributeType = atypeID;
goto checkAttListDeclHandler;
case XML_ROLE_ATTRIBUTE_TYPE_IDREF:
- declAttributeType = atypeIDREF;
+ parser->m_declAttributeType = atypeIDREF;
goto checkAttListDeclHandler;
case XML_ROLE_ATTRIBUTE_TYPE_IDREFS:
- declAttributeType = atypeIDREFS;
+ parser->m_declAttributeType = atypeIDREFS;
goto checkAttListDeclHandler;
case XML_ROLE_ATTRIBUTE_TYPE_ENTITY:
- declAttributeType = atypeENTITY;
+ parser->m_declAttributeType = atypeENTITY;
goto checkAttListDeclHandler;
case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES:
- declAttributeType = atypeENTITIES;
+ parser->m_declAttributeType = atypeENTITIES;
goto checkAttListDeclHandler;
case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN:
- declAttributeType = atypeNMTOKEN;
+ parser->m_declAttributeType = atypeNMTOKEN;
goto checkAttListDeclHandler;
case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS:
- declAttributeType = atypeNMTOKENS;
+ parser->m_declAttributeType = atypeNMTOKENS;
checkAttListDeclHandler:
- if (dtd->keepProcessing && attlistDeclHandler)
+ if (dtd->keepProcessing && parser->m_attlistDeclHandler)
handleDefault = XML_FALSE;
break;
case XML_ROLE_ATTRIBUTE_ENUM_VALUE:
case XML_ROLE_ATTRIBUTE_NOTATION_VALUE:
- if (dtd->keepProcessing && attlistDeclHandler) {
+ if (dtd->keepProcessing && parser->m_attlistDeclHandler) {
const XML_Char *prefix;
- if (declAttributeType) {
+ if (parser->m_declAttributeType) {
prefix = enumValueSep;
+ } else {
+ prefix = (role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE ? notationPrefix
+ : enumValueStart);
}
- else {
- prefix = (role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE
- ? notationPrefix
- : enumValueStart);
- }
- if (!poolAppendString(&tempPool, prefix))
+ if (! poolAppendString(&parser->m_tempPool, prefix))
return XML_ERROR_NO_MEMORY;
- if (!poolAppend(&tempPool, enc, s, next))
+ if (! poolAppend(&parser->m_tempPool, enc, s, next))
return XML_ERROR_NO_MEMORY;
- declAttributeType = tempPool.start;
+ parser->m_declAttributeType = parser->m_tempPool.start;
handleDefault = XML_FALSE;
}
break;
case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE:
case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE:
if (dtd->keepProcessing) {
- if (!defineAttribute(declElementType, declAttributeId,
- declAttributeIsCdata, declAttributeIsId,
- 0, parser))
+ if (! defineAttribute(parser->m_declElementType,
+ parser->m_declAttributeId,
+ parser->m_declAttributeIsCdata,
+ parser->m_declAttributeIsId, 0, parser))
return XML_ERROR_NO_MEMORY;
- if (attlistDeclHandler && declAttributeType) {
- if (*declAttributeType == XML_T(ASCII_LPAREN)
- || (*declAttributeType == XML_T(ASCII_N)
- && declAttributeType[1] == XML_T(ASCII_O))) {
+ if (parser->m_attlistDeclHandler && parser->m_declAttributeType) {
+ if (*parser->m_declAttributeType == XML_T(ASCII_LPAREN)
+ || (*parser->m_declAttributeType == XML_T(ASCII_N)
+ && parser->m_declAttributeType[1] == XML_T(ASCII_O))) {
/* Enumerated or Notation type */
- if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN))
- || !poolAppendChar(&tempPool, XML_T('\0')))
+ if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_RPAREN))
+ || ! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
return XML_ERROR_NO_MEMORY;
- declAttributeType = tempPool.start;
- poolFinish(&tempPool);
+ parser->m_declAttributeType = parser->m_tempPool.start;
+ poolFinish(&parser->m_tempPool);
}
*eventEndPP = s;
- attlistDeclHandler(handlerArg, declElementType->name,
- declAttributeId->name, declAttributeType,
- 0, role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE);
- poolClear(&tempPool);
+ parser->m_attlistDeclHandler(
+ parser->m_handlerArg, parser->m_declElementType->name,
+ parser->m_declAttributeId->name, parser->m_declAttributeType, 0,
+ role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE);
+ poolClear(&parser->m_tempPool);
handleDefault = XML_FALSE;
}
}
@@ -4672,61 +4462,57 @@ doProlog(XML_Parser parser,
case XML_ROLE_FIXED_ATTRIBUTE_VALUE:
if (dtd->keepProcessing) {
const XML_Char *attVal;
- enum XML_Error result =
- storeAttributeValue(parser, enc, declAttributeIsCdata,
- s + enc->minBytesPerChar,
- next - enc->minBytesPerChar,
- &dtd->pool);
+ enum XML_Error result = storeAttributeValue(
+ parser, enc, parser->m_declAttributeIsCdata,
+ s + enc->minBytesPerChar, next - enc->minBytesPerChar, &dtd->pool);
if (result)
return result;
attVal = poolStart(&dtd->pool);
poolFinish(&dtd->pool);
/* ID attributes aren't allowed to have a default */
- if (!defineAttribute(declElementType, declAttributeId,
- declAttributeIsCdata, XML_FALSE, attVal, parser))
+ if (! defineAttribute(
+ parser->m_declElementType, parser->m_declAttributeId,
+ parser->m_declAttributeIsCdata, XML_FALSE, attVal, parser))
return XML_ERROR_NO_MEMORY;
- if (attlistDeclHandler && declAttributeType) {
- if (*declAttributeType == XML_T(ASCII_LPAREN)
- || (*declAttributeType == XML_T(ASCII_N)
- && declAttributeType[1] == XML_T(ASCII_O))) {
+ if (parser->m_attlistDeclHandler && parser->m_declAttributeType) {
+ if (*parser->m_declAttributeType == XML_T(ASCII_LPAREN)
+ || (*parser->m_declAttributeType == XML_T(ASCII_N)
+ && parser->m_declAttributeType[1] == XML_T(ASCII_O))) {
/* Enumerated or Notation type */
- if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN))
- || !poolAppendChar(&tempPool, XML_T('\0')))
+ if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_RPAREN))
+ || ! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
return XML_ERROR_NO_MEMORY;
- declAttributeType = tempPool.start;
- poolFinish(&tempPool);
+ parser->m_declAttributeType = parser->m_tempPool.start;
+ poolFinish(&parser->m_tempPool);
}
*eventEndPP = s;
- attlistDeclHandler(handlerArg, declElementType->name,
- declAttributeId->name, declAttributeType,
- attVal,
- role == XML_ROLE_FIXED_ATTRIBUTE_VALUE);
- poolClear(&tempPool);
+ parser->m_attlistDeclHandler(
+ parser->m_handlerArg, parser->m_declElementType->name,
+ parser->m_declAttributeId->name, parser->m_declAttributeType,
+ attVal, role == XML_ROLE_FIXED_ATTRIBUTE_VALUE);
+ poolClear(&parser->m_tempPool);
handleDefault = XML_FALSE;
}
}
break;
case XML_ROLE_ENTITY_VALUE:
if (dtd->keepProcessing) {
- enum XML_Error result = storeEntityValue(parser, enc,
- s + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (declEntity) {
- declEntity->textPtr = poolStart(&dtd->entityValuePool);
- declEntity->textLen = (int)(poolLength(&dtd->entityValuePool));
+ enum XML_Error result = storeEntityValue(
+ parser, enc, s + enc->minBytesPerChar, next - enc->minBytesPerChar);
+ if (parser->m_declEntity) {
+ parser->m_declEntity->textPtr = poolStart(&dtd->entityValuePool);
+ parser->m_declEntity->textLen
+ = (int)(poolLength(&dtd->entityValuePool));
poolFinish(&dtd->entityValuePool);
- if (entityDeclHandler) {
+ if (parser->m_entityDeclHandler) {
*eventEndPP = s;
- entityDeclHandler(handlerArg,
- declEntity->name,
- declEntity->is_param,
- declEntity->textPtr,
- declEntity->textLen,
- curBase, 0, 0, 0);
+ parser->m_entityDeclHandler(
+ parser->m_handlerArg, parser->m_declEntity->name,
+ parser->m_declEntity->is_param, parser->m_declEntity->textPtr,
+ parser->m_declEntity->textLen, parser->m_curBase, 0, 0, 0);
handleDefault = XML_FALSE;
}
- }
- else
+ } else
poolDiscard(&dtd->entityValuePool);
if (result != XML_ERROR_NONE)
return result;
@@ -4734,227 +4520,212 @@ doProlog(XML_Parser parser,
break;
case XML_ROLE_DOCTYPE_SYSTEM_ID:
#ifdef XML_DTD
- useForeignDTD = XML_FALSE;
+ parser->m_useForeignDTD = XML_FALSE;
#endif /* XML_DTD */
dtd->hasParamEntityRefs = XML_TRUE;
- if (startDoctypeDeclHandler) {
- doctypeSysid = poolStoreString(&tempPool, enc,
- s + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (doctypeSysid == NULL)
+ if (parser->m_startDoctypeDeclHandler) {
+ parser->m_doctypeSysid = poolStoreString(&parser->m_tempPool, enc,
+ s + enc->minBytesPerChar,
+ next - enc->minBytesPerChar);
+ if (parser->m_doctypeSysid == NULL)
return XML_ERROR_NO_MEMORY;
- poolFinish(&tempPool);
+ poolFinish(&parser->m_tempPool);
handleDefault = XML_FALSE;
}
#ifdef XML_DTD
else
- /* use externalSubsetName to make doctypeSysid non-NULL
- for the case where no startDoctypeDeclHandler is set */
- doctypeSysid = externalSubsetName;
+ /* use externalSubsetName to make parser->m_doctypeSysid non-NULL
+ for the case where no parser->m_startDoctypeDeclHandler is set */
+ parser->m_doctypeSysid = externalSubsetName;
#endif /* XML_DTD */
- if (!dtd->standalone
+ if (! dtd->standalone
#ifdef XML_DTD
- && !paramEntityParsing
+ && ! parser->m_paramEntityParsing
#endif /* XML_DTD */
- && notStandaloneHandler
- && !notStandaloneHandler(handlerArg))
+ && parser->m_notStandaloneHandler
+ && ! parser->m_notStandaloneHandler(parser->m_handlerArg))
return XML_ERROR_NOT_STANDALONE;
#ifndef XML_DTD
break;
-#else /* XML_DTD */
- if (!declEntity) {
- declEntity = (ENTITY *)lookup(parser,
- &dtd->paramEntities,
- externalSubsetName,
- sizeof(ENTITY));
- if (!declEntity)
+#else /* XML_DTD */
+ if (! parser->m_declEntity) {
+ parser->m_declEntity = (ENTITY *)lookup(
+ parser, &dtd->paramEntities, externalSubsetName, sizeof(ENTITY));
+ if (! parser->m_declEntity)
return XML_ERROR_NO_MEMORY;
- declEntity->publicId = NULL;
+ parser->m_declEntity->publicId = NULL;
}
- /* fall through */
#endif /* XML_DTD */
+ /* fall through */
case XML_ROLE_ENTITY_SYSTEM_ID:
- if (dtd->keepProcessing && declEntity) {
- declEntity->systemId = poolStoreString(&dtd->pool, enc,
- s + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (!declEntity->systemId)
+ if (dtd->keepProcessing && parser->m_declEntity) {
+ parser->m_declEntity->systemId
+ = poolStoreString(&dtd->pool, enc, s + enc->minBytesPerChar,
+ next - enc->minBytesPerChar);
+ if (! parser->m_declEntity->systemId)
return XML_ERROR_NO_MEMORY;
- declEntity->base = curBase;
+ parser->m_declEntity->base = parser->m_curBase;
poolFinish(&dtd->pool);
- if (entityDeclHandler)
+ /* Don't suppress the default handler if we fell through from
+ * the XML_ROLE_DOCTYPE_SYSTEM_ID case.
+ */
+ if (parser->m_entityDeclHandler && role == XML_ROLE_ENTITY_SYSTEM_ID)
handleDefault = XML_FALSE;
}
break;
case XML_ROLE_ENTITY_COMPLETE:
- if (dtd->keepProcessing && declEntity && entityDeclHandler) {
+ if (dtd->keepProcessing && parser->m_declEntity
+ && parser->m_entityDeclHandler) {
*eventEndPP = s;
- entityDeclHandler(handlerArg,
- declEntity->name,
- declEntity->is_param,
- 0,0,
- declEntity->base,
- declEntity->systemId,
- declEntity->publicId,
- 0);
+ parser->m_entityDeclHandler(
+ parser->m_handlerArg, parser->m_declEntity->name,
+ parser->m_declEntity->is_param, 0, 0, parser->m_declEntity->base,
+ parser->m_declEntity->systemId, parser->m_declEntity->publicId, 0);
handleDefault = XML_FALSE;
}
break;
case XML_ROLE_ENTITY_NOTATION_NAME:
- if (dtd->keepProcessing && declEntity) {
- declEntity->notation = poolStoreString(&dtd->pool, enc, s, next);
- if (!declEntity->notation)
+ if (dtd->keepProcessing && parser->m_declEntity) {
+ parser->m_declEntity->notation
+ = poolStoreString(&dtd->pool, enc, s, next);
+ if (! parser->m_declEntity->notation)
return XML_ERROR_NO_MEMORY;
poolFinish(&dtd->pool);
- if (unparsedEntityDeclHandler) {
+ if (parser->m_unparsedEntityDeclHandler) {
*eventEndPP = s;
- unparsedEntityDeclHandler(handlerArg,
- declEntity->name,
- declEntity->base,
- declEntity->systemId,
- declEntity->publicId,
- declEntity->notation);
+ parser->m_unparsedEntityDeclHandler(
+ parser->m_handlerArg, parser->m_declEntity->name,
+ parser->m_declEntity->base, parser->m_declEntity->systemId,
+ parser->m_declEntity->publicId, parser->m_declEntity->notation);
handleDefault = XML_FALSE;
- }
- else if (entityDeclHandler) {
+ } else if (parser->m_entityDeclHandler) {
*eventEndPP = s;
- entityDeclHandler(handlerArg,
- declEntity->name,
- 0,0,0,
- declEntity->base,
- declEntity->systemId,
- declEntity->publicId,
- declEntity->notation);
+ parser->m_entityDeclHandler(
+ parser->m_handlerArg, parser->m_declEntity->name, 0, 0, 0,
+ parser->m_declEntity->base, parser->m_declEntity->systemId,
+ parser->m_declEntity->publicId, parser->m_declEntity->notation);
handleDefault = XML_FALSE;
}
}
break;
- case XML_ROLE_GENERAL_ENTITY_NAME:
- {
- if (XmlPredefinedEntityName(enc, s, next)) {
- declEntity = NULL;
- break;
- }
- if (dtd->keepProcessing) {
- const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next);
- if (!name)
- return XML_ERROR_NO_MEMORY;
- declEntity = (ENTITY *)lookup(parser, &dtd->generalEntities, name,
- sizeof(ENTITY));
- if (!declEntity)
- return XML_ERROR_NO_MEMORY;
- if (declEntity->name != name) {
- poolDiscard(&dtd->pool);
- declEntity = NULL;
- }
- else {
- poolFinish(&dtd->pool);
- declEntity->publicId = NULL;
- declEntity->is_param = XML_FALSE;
- /* if we have a parent parser or are reading an internal parameter
- entity, then the entity declaration is not considered "internal"
- */
- declEntity->is_internal = !(parentParser || openInternalEntities);
- if (entityDeclHandler)
- handleDefault = XML_FALSE;
- }
- }
- else {
+ case XML_ROLE_GENERAL_ENTITY_NAME: {
+ if (XmlPredefinedEntityName(enc, s, next)) {
+ parser->m_declEntity = NULL;
+ break;
+ }
+ if (dtd->keepProcessing) {
+ const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next);
+ if (! name)
+ return XML_ERROR_NO_MEMORY;
+ parser->m_declEntity = (ENTITY *)lookup(parser, &dtd->generalEntities,
+ name, sizeof(ENTITY));
+ if (! parser->m_declEntity)
+ return XML_ERROR_NO_MEMORY;
+ if (parser->m_declEntity->name != name) {
poolDiscard(&dtd->pool);
- declEntity = NULL;
+ parser->m_declEntity = NULL;
+ } else {
+ poolFinish(&dtd->pool);
+ parser->m_declEntity->publicId = NULL;
+ parser->m_declEntity->is_param = XML_FALSE;
+ /* if we have a parent parser or are reading an internal parameter
+ entity, then the entity declaration is not considered "internal"
+ */
+ parser->m_declEntity->is_internal
+ = ! (parser->m_parentParser || parser->m_openInternalEntities);
+ if (parser->m_entityDeclHandler)
+ handleDefault = XML_FALSE;
}
+ } else {
+ poolDiscard(&dtd->pool);
+ parser->m_declEntity = NULL;
}
- break;
+ } break;
case XML_ROLE_PARAM_ENTITY_NAME:
#ifdef XML_DTD
if (dtd->keepProcessing) {
const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next);
- if (!name)
+ if (! name)
return XML_ERROR_NO_MEMORY;
- declEntity = (ENTITY *)lookup(parser, &dtd->paramEntities,
- name, sizeof(ENTITY));
- if (!declEntity)
+ parser->m_declEntity = (ENTITY *)lookup(parser, &dtd->paramEntities,
+ name, sizeof(ENTITY));
+ if (! parser->m_declEntity)
return XML_ERROR_NO_MEMORY;
- if (declEntity->name != name) {
+ if (parser->m_declEntity->name != name) {
poolDiscard(&dtd->pool);
- declEntity = NULL;
- }
- else {
+ parser->m_declEntity = NULL;
+ } else {
poolFinish(&dtd->pool);
- declEntity->publicId = NULL;
- declEntity->is_param = XML_TRUE;
+ parser->m_declEntity->publicId = NULL;
+ parser->m_declEntity->is_param = XML_TRUE;
/* if we have a parent parser or are reading an internal parameter
entity, then the entity declaration is not considered "internal"
*/
- declEntity->is_internal = !(parentParser || openInternalEntities);
- if (entityDeclHandler)
+ parser->m_declEntity->is_internal
+ = ! (parser->m_parentParser || parser->m_openInternalEntities);
+ if (parser->m_entityDeclHandler)
handleDefault = XML_FALSE;
}
- }
- else {
+ } else {
poolDiscard(&dtd->pool);
- declEntity = NULL;
+ parser->m_declEntity = NULL;
}
-#else /* not XML_DTD */
- declEntity = NULL;
+#else /* not XML_DTD */
+ parser->m_declEntity = NULL;
#endif /* XML_DTD */
break;
case XML_ROLE_NOTATION_NAME:
- declNotationPublicId = NULL;
- declNotationName = NULL;
- if (notationDeclHandler) {
- declNotationName = poolStoreString(&tempPool, enc, s, next);
- if (!declNotationName)
+ parser->m_declNotationPublicId = NULL;
+ parser->m_declNotationName = NULL;
+ if (parser->m_notationDeclHandler) {
+ parser->m_declNotationName
+ = poolStoreString(&parser->m_tempPool, enc, s, next);
+ if (! parser->m_declNotationName)
return XML_ERROR_NO_MEMORY;
- poolFinish(&tempPool);
+ poolFinish(&parser->m_tempPool);
handleDefault = XML_FALSE;
}
break;
case XML_ROLE_NOTATION_PUBLIC_ID:
- if (!XmlIsPublicId(enc, s, next, eventPP))
+ if (! XmlIsPublicId(enc, s, next, eventPP))
return XML_ERROR_PUBLICID;
- if (declNotationName) { /* means notationDeclHandler != NULL */
- XML_Char *tem = poolStoreString(&tempPool,
- enc,
+ if (parser
+ ->m_declNotationName) { /* means m_notationDeclHandler != NULL */
+ XML_Char *tem = poolStoreString(&parser->m_tempPool, enc,
s + enc->minBytesPerChar,
next - enc->minBytesPerChar);
- if (!tem)
+ if (! tem)
return XML_ERROR_NO_MEMORY;
normalizePublicId(tem);
- declNotationPublicId = tem;
- poolFinish(&tempPool);
+ parser->m_declNotationPublicId = tem;
+ poolFinish(&parser->m_tempPool);
handleDefault = XML_FALSE;
}
break;
case XML_ROLE_NOTATION_SYSTEM_ID:
- if (declNotationName && notationDeclHandler) {
- const XML_Char *systemId
- = poolStoreString(&tempPool, enc,
- s + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (!systemId)
+ if (parser->m_declNotationName && parser->m_notationDeclHandler) {
+ const XML_Char *systemId = poolStoreString(&parser->m_tempPool, enc,
+ s + enc->minBytesPerChar,
+ next - enc->minBytesPerChar);
+ if (! systemId)
return XML_ERROR_NO_MEMORY;
*eventEndPP = s;
- notationDeclHandler(handlerArg,
- declNotationName,
- curBase,
- systemId,
- declNotationPublicId);
+ parser->m_notationDeclHandler(
+ parser->m_handlerArg, parser->m_declNotationName, parser->m_curBase,
+ systemId, parser->m_declNotationPublicId);
handleDefault = XML_FALSE;
}
- poolClear(&tempPool);
+ poolClear(&parser->m_tempPool);
break;
case XML_ROLE_NOTATION_NO_SYSTEM_ID:
- if (declNotationPublicId && notationDeclHandler) {
+ if (parser->m_declNotationPublicId && parser->m_notationDeclHandler) {
*eventEndPP = s;
- notationDeclHandler(handlerArg,
- declNotationName,
- curBase,
- 0,
- declNotationPublicId);
+ parser->m_notationDeclHandler(
+ parser->m_handlerArg, parser->m_declNotationName, parser->m_curBase,
+ 0, parser->m_declNotationPublicId);
handleDefault = XML_FALSE;
}
- poolClear(&tempPool);
+ poolClear(&parser->m_tempPool);
break;
case XML_ROLE_ERROR:
switch (tok) {
@@ -4968,94 +4739,95 @@ doProlog(XML_Parser parser,
return XML_ERROR_SYNTAX;
}
#ifdef XML_DTD
- case XML_ROLE_IGNORE_SECT:
- {
- enum XML_Error result;
- if (defaultHandler)
- reportDefault(parser, enc, s, next);
- handleDefault = XML_FALSE;
- result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore);
- if (result != XML_ERROR_NONE)
- return result;
- else if (!next) {
- processor = ignoreSectionProcessor;
- return result;
- }
+ case XML_ROLE_IGNORE_SECT: {
+ enum XML_Error result;
+ if (parser->m_defaultHandler)
+ reportDefault(parser, enc, s, next);
+ handleDefault = XML_FALSE;
+ result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore);
+ if (result != XML_ERROR_NONE)
+ return result;
+ else if (! next) {
+ parser->m_processor = ignoreSectionProcessor;
+ return result;
}
- break;
+ } break;
#endif /* XML_DTD */
case XML_ROLE_GROUP_OPEN:
- if (prologState.level >= groupSize) {
- if (groupSize) {
- char *temp = (char *)REALLOC(groupConnector, groupSize *= 2);
- if (temp == NULL) {
- groupSize /= 2;
- return XML_ERROR_NO_MEMORY;
+ if (parser->m_prologState.level >= parser->m_groupSize) {
+ if (parser->m_groupSize) {
+ {
+ char *const new_connector = (char *)REALLOC(
+ parser, parser->m_groupConnector, parser->m_groupSize *= 2);
+ if (new_connector == NULL) {
+ parser->m_groupSize /= 2;
+ return XML_ERROR_NO_MEMORY;
+ }
+ parser->m_groupConnector = new_connector;
}
- groupConnector = temp;
+
if (dtd->scaffIndex) {
- int *temp = (int *)REALLOC(dtd->scaffIndex,
- groupSize * sizeof(int));
- if (temp == NULL)
+ int *const new_scaff_index = (int *)REALLOC(
+ parser, dtd->scaffIndex, parser->m_groupSize * sizeof(int));
+ if (new_scaff_index == NULL)
return XML_ERROR_NO_MEMORY;
- dtd->scaffIndex = temp;
+ dtd->scaffIndex = new_scaff_index;
}
- }
- else {
- groupConnector = (char *)MALLOC(groupSize = 32);
- if (!groupConnector) {
- groupSize = 0;
+ } else {
+ parser->m_groupConnector
+ = (char *)MALLOC(parser, parser->m_groupSize = 32);
+ if (! parser->m_groupConnector) {
+ parser->m_groupSize = 0;
return XML_ERROR_NO_MEMORY;
}
}
}
- groupConnector[prologState.level] = 0;
+ parser->m_groupConnector[parser->m_prologState.level] = 0;
if (dtd->in_eldecl) {
int myindex = nextScaffoldPart(parser);
if (myindex < 0)
return XML_ERROR_NO_MEMORY;
+ assert(dtd->scaffIndex != NULL);
dtd->scaffIndex[dtd->scaffLevel] = myindex;
dtd->scaffLevel++;
dtd->scaffold[myindex].type = XML_CTYPE_SEQ;
- if (elementDeclHandler)
+ if (parser->m_elementDeclHandler)
handleDefault = XML_FALSE;
}
break;
case XML_ROLE_GROUP_SEQUENCE:
- if (groupConnector[prologState.level] == ASCII_PIPE)
+ if (parser->m_groupConnector[parser->m_prologState.level] == ASCII_PIPE)
return XML_ERROR_SYNTAX;
- groupConnector[prologState.level] = ASCII_COMMA;
- if (dtd->in_eldecl && elementDeclHandler)
+ parser->m_groupConnector[parser->m_prologState.level] = ASCII_COMMA;
+ if (dtd->in_eldecl && parser->m_elementDeclHandler)
handleDefault = XML_FALSE;
break;
case XML_ROLE_GROUP_CHOICE:
- if (groupConnector[prologState.level] == ASCII_COMMA)
+ if (parser->m_groupConnector[parser->m_prologState.level] == ASCII_COMMA)
return XML_ERROR_SYNTAX;
if (dtd->in_eldecl
- && !groupConnector[prologState.level]
+ && ! parser->m_groupConnector[parser->m_prologState.level]
&& (dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type
- != XML_CTYPE_MIXED)
- ) {
+ != XML_CTYPE_MIXED)) {
dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type
= XML_CTYPE_CHOICE;
- if (elementDeclHandler)
+ if (parser->m_elementDeclHandler)
handleDefault = XML_FALSE;
}
- groupConnector[prologState.level] = ASCII_PIPE;
+ parser->m_groupConnector[parser->m_prologState.level] = ASCII_PIPE;
break;
case XML_ROLE_PARAM_ENTITY_REF:
#ifdef XML_DTD
case XML_ROLE_INNER_PARAM_ENTITY_REF:
dtd->hasParamEntityRefs = XML_TRUE;
- if (!paramEntityParsing)
+ if (! parser->m_paramEntityParsing)
dtd->keepProcessing = dtd->standalone;
else {
const XML_Char *name;
ENTITY *entity;
- name = poolStoreString(&dtd->pool, enc,
- s + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (!name)
+ name = poolStoreString(&dtd->pool, enc, s + enc->minBytesPerChar,
+ next - enc->minBytesPerChar);
+ if (! name)
return XML_ERROR_NO_MEMORY;
entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0);
poolDiscard(&dtd->pool);
@@ -5063,13 +4835,12 @@ doProlog(XML_Parser parser,
if yes, check that the entity exists, and that it is internal,
otherwise call the skipped entity handler
*/
- if (prologState.documentEntity &&
- (dtd->standalone
- ? !openInternalEntities
- : !dtd->hasParamEntityRefs)) {
- if (!entity)
+ if (parser->m_prologState.documentEntity
+ && (dtd->standalone ? ! parser->m_openInternalEntities
+ : ! dtd->hasParamEntityRefs)) {
+ if (! entity)
return XML_ERROR_UNDEFINED_ENTITY;
- else if (!entity->is_internal) {
+ else if (! entity->is_internal) {
/* It's hard to exhaustively search the code to be sure,
* but there doesn't seem to be a way of executing the
* following line. There are two cases:
@@ -5092,12 +4863,12 @@ doProlog(XML_Parser parser,
*/
return XML_ERROR_ENTITY_DECLARED_IN_PE; /* LCOV_EXCL_LINE */
}
- }
- else if (!entity) {
+ } else if (! entity) {
dtd->keepProcessing = dtd->standalone;
/* cannot report skipped entities in declarations */
- if ((role == XML_ROLE_PARAM_ENTITY_REF) && skippedEntityHandler) {
- skippedEntityHandler(handlerArg, name, 1);
+ if ((role == XML_ROLE_PARAM_ENTITY_REF)
+ && parser->m_skippedEntityHandler) {
+ parser->m_skippedEntityHandler(parser->m_handlerArg, name, 1);
handleDefault = XML_FALSE;
}
break;
@@ -5106,50 +4877,46 @@ doProlog(XML_Parser parser,
return XML_ERROR_RECURSIVE_ENTITY_REF;
if (entity->textPtr) {
enum XML_Error result;
- XML_Bool betweenDecl =
- (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE);
+ XML_Bool betweenDecl
+ = (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE);
result = processInternalEntity(parser, entity, betweenDecl);
if (result != XML_ERROR_NONE)
return result;
handleDefault = XML_FALSE;
break;
}
- if (externalEntityRefHandler) {
+ if (parser->m_externalEntityRefHandler) {
dtd->paramEntityRead = XML_FALSE;
entity->open = XML_TRUE;
- if (!externalEntityRefHandler(externalEntityRefHandlerArg,
- 0,
- entity->base,
- entity->systemId,
- entity->publicId)) {
+ if (! parser->m_externalEntityRefHandler(
+ parser->m_externalEntityRefHandlerArg, 0, entity->base,
+ entity->systemId, entity->publicId)) {
entity->open = XML_FALSE;
return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
}
entity->open = XML_FALSE;
handleDefault = XML_FALSE;
- if (!dtd->paramEntityRead) {
+ if (! dtd->paramEntityRead) {
dtd->keepProcessing = dtd->standalone;
break;
}
- }
- else {
+ } else {
dtd->keepProcessing = dtd->standalone;
break;
}
}
#endif /* XML_DTD */
- if (!dtd->standalone &&
- notStandaloneHandler &&
- !notStandaloneHandler(handlerArg))
+ if (! dtd->standalone && parser->m_notStandaloneHandler
+ && ! parser->m_notStandaloneHandler(parser->m_handlerArg))
return XML_ERROR_NOT_STANDALONE;
break;
- /* Element declaration stuff */
+ /* Element declaration stuff */
case XML_ROLE_ELEMENT_NAME:
- if (elementDeclHandler) {
- declElementType = getElementType(parser, enc, s, next);
- if (!declElementType)
+ if (parser->m_elementDeclHandler) {
+ parser->m_declElementType = getElementType(parser, enc, s, next);
+ if (! parser->m_declElementType)
return XML_ERROR_NO_MEMORY;
dtd->scaffLevel = 0;
dtd->scaffCount = 0;
@@ -5161,19 +4928,20 @@ doProlog(XML_Parser parser,
case XML_ROLE_CONTENT_ANY:
case XML_ROLE_CONTENT_EMPTY:
if (dtd->in_eldecl) {
- if (elementDeclHandler) {
- XML_Content * content = (XML_Content *) MALLOC(sizeof(XML_Content));
- if (!content)
+ if (parser->m_elementDeclHandler) {
+ XML_Content *content
+ = (XML_Content *)MALLOC(parser, sizeof(XML_Content));
+ if (! content)
return XML_ERROR_NO_MEMORY;
content->quant = XML_CQUANT_NONE;
content->name = NULL;
content->numchildren = 0;
content->children = NULL;
- content->type = ((role == XML_ROLE_CONTENT_ANY) ?
- XML_CTYPE_ANY :
- XML_CTYPE_EMPTY);
+ content->type = ((role == XML_ROLE_CONTENT_ANY) ? XML_CTYPE_ANY
+ : XML_CTYPE_EMPTY);
*eventEndPP = s;
- elementDeclHandler(handlerArg, declElementType->name, content);
+ parser->m_elementDeclHandler(
+ parser->m_handlerArg, parser->m_declElementType->name, content);
handleDefault = XML_FALSE;
}
dtd->in_eldecl = XML_FALSE;
@@ -5184,7 +4952,7 @@ doProlog(XML_Parser parser,
if (dtd->in_eldecl) {
dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type
= XML_CTYPE_MIXED;
- if (elementDeclHandler)
+ if (parser->m_elementDeclHandler)
handleDefault = XML_FALSE;
}
break;
@@ -5205,23 +4973,23 @@ doProlog(XML_Parser parser,
ELEMENT_TYPE *el;
const XML_Char *name;
int nameLen;
- const char *nxt = (quant == XML_CQUANT_NONE
- ? next
- : next - enc->minBytesPerChar);
+ const char *nxt
+ = (quant == XML_CQUANT_NONE ? next : next - enc->minBytesPerChar);
int myindex = nextScaffoldPart(parser);
if (myindex < 0)
return XML_ERROR_NO_MEMORY;
dtd->scaffold[myindex].type = XML_CTYPE_NAME;
dtd->scaffold[myindex].quant = quant;
el = getElementType(parser, enc, s, nxt);
- if (!el)
+ if (! el)
return XML_ERROR_NO_MEMORY;
name = el->name;
dtd->scaffold[myindex].name = name;
nameLen = 0;
- for (; name[nameLen++]; );
- dtd->contentStringLen += nameLen;
- if (elementDeclHandler)
+ for (; name[nameLen++];)
+ ;
+ dtd->contentStringLen += nameLen;
+ if (parser->m_elementDeclHandler)
handleDefault = XML_FALSE;
}
break;
@@ -5239,17 +5007,18 @@ doProlog(XML_Parser parser,
quant = XML_CQUANT_PLUS;
closeGroup:
if (dtd->in_eldecl) {
- if (elementDeclHandler)
+ if (parser->m_elementDeclHandler)
handleDefault = XML_FALSE;
dtd->scaffLevel--;
dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel]].quant = quant;
if (dtd->scaffLevel == 0) {
- if (!handleDefault) {
+ if (! handleDefault) {
XML_Content *model = build_model(parser);
- if (!model)
+ if (! model)
return XML_ERROR_NO_MEMORY;
*eventEndPP = s;
- elementDeclHandler(handlerArg, declElementType->name, model);
+ parser->m_elementDeclHandler(
+ parser->m_handlerArg, parser->m_declElementType->name, model);
}
dtd->in_eldecl = XML_FALSE;
dtd->contentStringLen = 0;
@@ -5259,12 +5028,12 @@ doProlog(XML_Parser parser,
/* End element declaration stuff */
case XML_ROLE_PI:
- if (!reportProcessingInstruction(parser, enc, s, next))
+ if (! reportProcessingInstruction(parser, enc, s, next))
return XML_ERROR_NO_MEMORY;
handleDefault = XML_FALSE;
break;
case XML_ROLE_COMMENT:
- if (!reportComment(parser, enc, s, next))
+ if (! reportComment(parser, enc, s, next))
return XML_ERROR_NO_MEMORY;
handleDefault = XML_FALSE;
break;
@@ -5276,31 +5045,31 @@ doProlog(XML_Parser parser,
}
break;
case XML_ROLE_DOCTYPE_NONE:
- if (startDoctypeDeclHandler)
+ if (parser->m_startDoctypeDeclHandler)
handleDefault = XML_FALSE;
break;
case XML_ROLE_ENTITY_NONE:
- if (dtd->keepProcessing && entityDeclHandler)
+ if (dtd->keepProcessing && parser->m_entityDeclHandler)
handleDefault = XML_FALSE;
break;
case XML_ROLE_NOTATION_NONE:
- if (notationDeclHandler)
+ if (parser->m_notationDeclHandler)
handleDefault = XML_FALSE;
break;
case XML_ROLE_ATTLIST_NONE:
- if (dtd->keepProcessing && attlistDeclHandler)
+ if (dtd->keepProcessing && parser->m_attlistDeclHandler)
handleDefault = XML_FALSE;
break;
case XML_ROLE_ELEMENT_NONE:
- if (elementDeclHandler)
+ if (parser->m_elementDeclHandler)
handleDefault = XML_FALSE;
break;
} /* end of big switch */
- if (handleDefault && defaultHandler)
+ if (handleDefault && parser->m_defaultHandler)
reportDefault(parser, enc, s, next);
- switch (ps_parsing) {
+ switch (parser->m_parsingStatus.parsing) {
case XML_SUSPENDED:
*nextPtr = next;
return XML_ERROR_NONE;
@@ -5315,23 +5084,20 @@ doProlog(XML_Parser parser,
}
static enum XML_Error PTRCALL
-epilogProcessor(XML_Parser parser,
- const char *s,
- const char *end,
- const char **nextPtr)
-{
- processor = epilogProcessor;
- eventPtr = s;
+epilogProcessor(XML_Parser parser, const char *s, const char *end,
+ const char **nextPtr) {
+ parser->m_processor = epilogProcessor;
+ parser->m_eventPtr = s;
for (;;) {
const char *next = NULL;
- int tok = XmlPrologTok(encoding, s, end, &next);
- eventEndPtr = next;
+ int tok = XmlPrologTok(parser->m_encoding, s, end, &next);
+ parser->m_eventEndPtr = next;
switch (tok) {
/* report partial linebreak - it might be the last token */
case -XML_TOK_PROLOG_S:
- if (defaultHandler) {
- reportDefault(parser, encoding, s, next);
- if (ps_parsing == XML_FINISHED)
+ if (parser->m_defaultHandler) {
+ reportDefault(parser, parser->m_encoding, s, next);
+ if (parser->m_parsingStatus.parsing == XML_FINISHED)
return XML_ERROR_ABORTED;
}
*nextPtr = next;
@@ -5340,28 +5106,28 @@ epilogProcessor(XML_Parser parser,
*nextPtr = s;
return XML_ERROR_NONE;
case XML_TOK_PROLOG_S:
- if (defaultHandler)
- reportDefault(parser, encoding, s, next);
+ if (parser->m_defaultHandler)
+ reportDefault(parser, parser->m_encoding, s, next);
break;
case XML_TOK_PI:
- if (!reportProcessingInstruction(parser, encoding, s, next))
+ if (! reportProcessingInstruction(parser, parser->m_encoding, s, next))
return XML_ERROR_NO_MEMORY;
break;
case XML_TOK_COMMENT:
- if (!reportComment(parser, encoding, s, next))
+ if (! reportComment(parser, parser->m_encoding, s, next))
return XML_ERROR_NO_MEMORY;
break;
case XML_TOK_INVALID:
- eventPtr = next;
+ parser->m_eventPtr = next;
return XML_ERROR_INVALID_TOKEN;
case XML_TOK_PARTIAL:
- if (!ps_finalBuffer) {
+ if (! parser->m_parsingStatus.finalBuffer) {
*nextPtr = s;
return XML_ERROR_NONE;
}
return XML_ERROR_UNCLOSED_TOKEN;
case XML_TOK_PARTIAL_CHAR:
- if (!ps_finalBuffer) {
+ if (! parser->m_parsingStatus.finalBuffer) {
*nextPtr = s;
return XML_ERROR_NONE;
}
@@ -5369,42 +5135,40 @@ epilogProcessor(XML_Parser parser,
default:
return XML_ERROR_JUNK_AFTER_DOC_ELEMENT;
}
- eventPtr = s = next;
- switch (ps_parsing) {
+ parser->m_eventPtr = s = next;
+ switch (parser->m_parsingStatus.parsing) {
case XML_SUSPENDED:
*nextPtr = next;
return XML_ERROR_NONE;
case XML_FINISHED:
return XML_ERROR_ABORTED;
- default: ;
+ default:;
}
}
}
static enum XML_Error
-processInternalEntity(XML_Parser parser, ENTITY *entity,
- XML_Bool betweenDecl)
-{
+processInternalEntity(XML_Parser parser, ENTITY *entity, XML_Bool betweenDecl) {
const char *textStart, *textEnd;
const char *next;
enum XML_Error result;
OPEN_INTERNAL_ENTITY *openEntity;
- if (freeInternalEntities) {
- openEntity = freeInternalEntities;
- freeInternalEntities = openEntity->next;
- }
- else {
- openEntity = (OPEN_INTERNAL_ENTITY *)MALLOC(sizeof(OPEN_INTERNAL_ENTITY));
- if (!openEntity)
+ if (parser->m_freeInternalEntities) {
+ openEntity = parser->m_freeInternalEntities;
+ parser->m_freeInternalEntities = openEntity->next;
+ } else {
+ openEntity
+ = (OPEN_INTERNAL_ENTITY *)MALLOC(parser, sizeof(OPEN_INTERNAL_ENTITY));
+ if (! openEntity)
return XML_ERROR_NO_MEMORY;
}
entity->open = XML_TRUE;
entity->processed = 0;
- openEntity->next = openInternalEntities;
- openInternalEntities = openEntity;
+ openEntity->next = parser->m_openInternalEntities;
+ parser->m_openInternalEntities = openEntity;
openEntity->entity = entity;
- openEntity->startTagLevel = tagLevel;
+ openEntity->startTagLevel = parser->m_tagLevel;
openEntity->betweenDecl = betweenDecl;
openEntity->internalEventPtr = NULL;
openEntity->internalEventEndPtr = NULL;
@@ -5415,43 +5179,39 @@ processInternalEntity(XML_Parser parser, ENTITY *entity,
#ifdef XML_DTD
if (entity->is_param) {
- int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next);
- result = doProlog(parser, internalEncoding, textStart, textEnd, tok,
- next, &next, XML_FALSE);
- }
- else
+ int tok
+ = XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next);
+ result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd,
+ tok, next, &next, XML_FALSE, XML_FALSE);
+ } else
#endif /* XML_DTD */
- result = doContent(parser, tagLevel, internalEncoding, textStart,
- textEnd, &next, XML_FALSE);
+ result = doContent(parser, parser->m_tagLevel, parser->m_internalEncoding,
+ textStart, textEnd, &next, XML_FALSE);
if (result == XML_ERROR_NONE) {
- if (textEnd != next && ps_parsing == XML_SUSPENDED) {
+ if (textEnd != next && parser->m_parsingStatus.parsing == XML_SUSPENDED) {
entity->processed = (int)(next - textStart);
- processor = internalEntityProcessor;
- }
- else {
+ parser->m_processor = internalEntityProcessor;
+ } else {
entity->open = XML_FALSE;
- openInternalEntities = openEntity->next;
+ parser->m_openInternalEntities = openEntity->next;
/* put openEntity back in list of free instances */
- openEntity->next = freeInternalEntities;
- freeInternalEntities = openEntity;
+ openEntity->next = parser->m_freeInternalEntities;
+ parser->m_freeInternalEntities = openEntity;
}
}
return result;
}
static enum XML_Error PTRCALL
-internalEntityProcessor(XML_Parser parser,
- const char *s,
- const char *end,
- const char **nextPtr)
-{
+internalEntityProcessor(XML_Parser parser, const char *s, const char *end,
+ const char **nextPtr) {
ENTITY *entity;
const char *textStart, *textEnd;
const char *next;
enum XML_Error result;
- OPEN_INTERNAL_ENTITY *openEntity = openInternalEntities;
- if (!openEntity)
+ OPEN_INTERNAL_ENTITY *openEntity = parser->m_openInternalEntities;
+ if (! openEntity)
return XML_ERROR_UNEXPECTED_STATE;
entity = openEntity->entity;
@@ -5462,78 +5222,75 @@ internalEntityProcessor(XML_Parser parser,
#ifdef XML_DTD
if (entity->is_param) {
- int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next);
- result = doProlog(parser, internalEncoding, textStart, textEnd, tok,
- next, &next, XML_FALSE);
- }
- else
+ int tok
+ = XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next);
+ result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd,
+ tok, next, &next, XML_FALSE, XML_TRUE);
+ } else
#endif /* XML_DTD */
- result = doContent(parser, openEntity->startTagLevel, internalEncoding,
- textStart, textEnd, &next, XML_FALSE);
+ result = doContent(parser, openEntity->startTagLevel,
+ parser->m_internalEncoding, textStart, textEnd, &next,
+ XML_FALSE);
if (result != XML_ERROR_NONE)
return result;
- else if (textEnd != next && ps_parsing == XML_SUSPENDED) {
+ else if (textEnd != next
+ && parser->m_parsingStatus.parsing == XML_SUSPENDED) {
entity->processed = (int)(next - (char *)entity->textPtr);
return result;
- }
- else {
+ } else {
entity->open = XML_FALSE;
- openInternalEntities = openEntity->next;
+ parser->m_openInternalEntities = openEntity->next;
/* put openEntity back in list of free instances */
- openEntity->next = freeInternalEntities;
- freeInternalEntities = openEntity;
+ openEntity->next = parser->m_freeInternalEntities;
+ parser->m_freeInternalEntities = openEntity;
}
#ifdef XML_DTD
if (entity->is_param) {
int tok;
- processor = prologProcessor;
- tok = XmlPrologTok(encoding, s, end, &next);
- return doProlog(parser, encoding, s, end, tok, next, nextPtr,
- (XML_Bool)!ps_finalBuffer);
- }
- else
+ parser->m_processor = prologProcessor;
+ tok = XmlPrologTok(parser->m_encoding, s, end, &next);
+ return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr,
+ (XML_Bool)! parser->m_parsingStatus.finalBuffer, XML_TRUE);
+ } else
#endif /* XML_DTD */
{
- processor = contentProcessor;
+ parser->m_processor = contentProcessor;
/* see externalEntityContentProcessor vs contentProcessor */
- return doContent(parser, parentParser ? 1 : 0, encoding, s, end,
- nextPtr, (XML_Bool)!ps_finalBuffer);
+ return doContent(parser, parser->m_parentParser ? 1 : 0, parser->m_encoding,
+ s, end, nextPtr,
+ (XML_Bool)! parser->m_parsingStatus.finalBuffer);
}
}
static enum XML_Error PTRCALL
-errorProcessor(XML_Parser parser,
- const char *UNUSED_P(s),
- const char *UNUSED_P(end),
- const char **UNUSED_P(nextPtr))
-{
- return errorCode;
+errorProcessor(XML_Parser parser, const char *s, const char *end,
+ const char **nextPtr) {
+ UNUSED_P(s);
+ UNUSED_P(end);
+ UNUSED_P(nextPtr);
+ return parser->m_errorCode;
}
static enum XML_Error
storeAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
- const char *ptr, const char *end,
- STRING_POOL *pool)
-{
- enum XML_Error result = appendAttributeValue(parser, enc, isCdata, ptr,
- end, pool);
+ const char *ptr, const char *end, STRING_POOL *pool) {
+ enum XML_Error result
+ = appendAttributeValue(parser, enc, isCdata, ptr, end, pool);
if (result)
return result;
- if (!isCdata && poolLength(pool) && poolLastChar(pool) == 0x20)
+ if (! isCdata && poolLength(pool) && poolLastChar(pool) == 0x20)
poolChop(pool);
- if (!poolAppendChar(pool, XML_T('\0')))
+ if (! poolAppendChar(pool, XML_T('\0')))
return XML_ERROR_NO_MEMORY;
return XML_ERROR_NONE;
}
static enum XML_Error
appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
- const char *ptr, const char *end,
- STRING_POOL *pool)
-{
- DTD * const dtd = _dtd; /* save one level of indirection */
+ const char *ptr, const char *end, STRING_POOL *pool) {
+ DTD *const dtd = parser->m_dtd; /* save one level of indirection */
for (;;) {
const char *next;
int tok = XmlAttributeValueTok(enc, ptr, end, &next);
@@ -5541,45 +5298,42 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
case XML_TOK_NONE:
return XML_ERROR_NONE;
case XML_TOK_INVALID:
- if (enc == encoding)
- eventPtr = next;
+ if (enc == parser->m_encoding)
+ parser->m_eventPtr = next;
return XML_ERROR_INVALID_TOKEN;
case XML_TOK_PARTIAL:
- if (enc == encoding)
- eventPtr = ptr;
+ if (enc == parser->m_encoding)
+ parser->m_eventPtr = ptr;
return XML_ERROR_INVALID_TOKEN;
- case XML_TOK_CHAR_REF:
- {
- XML_Char buf[XML_ENCODE_MAX];
- int i;
- int n = XmlCharRefNumber(enc, ptr);
- if (n < 0) {
- if (enc == encoding)
- eventPtr = ptr;
- return XML_ERROR_BAD_CHAR_REF;
- }
- if (!isCdata
- && n == 0x20 /* space */
- && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20))
- break;
- n = XmlEncode(n, (ICHAR *)buf);
- /* The XmlEncode() functions can never return 0 here. That
- * error return happens if the code point passed in is either
- * negative or greater than or equal to 0x110000. The
- * XmlCharRefNumber() functions will all return a number
- * strictly less than 0x110000 or a negative value if an error
- * occurred. The negative value is intercepted above, so
- * XmlEncode() is never passed a value it might return an
- * error for.
- */
- for (i = 0; i < n; i++) {
- if (!poolAppendChar(pool, buf[i]))
- return XML_ERROR_NO_MEMORY;
- }
+ case XML_TOK_CHAR_REF: {
+ XML_Char buf[XML_ENCODE_MAX];
+ int i;
+ int n = XmlCharRefNumber(enc, ptr);
+ if (n < 0) {
+ if (enc == parser->m_encoding)
+ parser->m_eventPtr = ptr;
+ return XML_ERROR_BAD_CHAR_REF;
}
- break;
+ if (! isCdata && n == 0x20 /* space */
+ && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20))
+ break;
+ n = XmlEncode(n, (ICHAR *)buf);
+ /* The XmlEncode() functions can never return 0 here. That
+ * error return happens if the code point passed in is either
+ * negative or greater than or equal to 0x110000. The
+ * XmlCharRefNumber() functions will all return a number
+ * strictly less than 0x110000 or a negative value if an error
+ * occurred. The negative value is intercepted above, so
+ * XmlEncode() is never passed a value it might return an
+ * error for.
+ */
+ for (i = 0; i < n; i++) {
+ if (! poolAppendChar(pool, buf[i]))
+ return XML_ERROR_NO_MEMORY;
+ }
+ } break;
case XML_TOK_DATA_CHARS:
- if (!poolAppend(pool, enc, ptr, next))
+ if (! poolAppend(pool, enc, ptr, next))
return XML_ERROR_NO_MEMORY;
break;
case XML_TOK_TRAILING_CR:
@@ -5587,109 +5341,103 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
/* fall through */
case XML_TOK_ATTRIBUTE_VALUE_S:
case XML_TOK_DATA_NEWLINE:
- if (!isCdata && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20))
+ if (! isCdata && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20))
break;
- if (!poolAppendChar(pool, 0x20))
+ if (! poolAppendChar(pool, 0x20))
return XML_ERROR_NO_MEMORY;
break;
- case XML_TOK_ENTITY_REF:
- {
- const XML_Char *name;
- ENTITY *entity;
- char checkEntityDecl;
- XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc,
- ptr + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (ch) {
- if (!poolAppendChar(pool, ch))
- return XML_ERROR_NO_MEMORY;
- break;
- }
- name = poolStoreString(&temp2Pool, enc,
- ptr + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (!name)
+ case XML_TOK_ENTITY_REF: {
+ const XML_Char *name;
+ ENTITY *entity;
+ char checkEntityDecl;
+ XML_Char ch = (XML_Char)XmlPredefinedEntityName(
+ enc, ptr + enc->minBytesPerChar, next - enc->minBytesPerChar);
+ if (ch) {
+ if (! poolAppendChar(pool, ch))
return XML_ERROR_NO_MEMORY;
- entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0);
- poolDiscard(&temp2Pool);
- /* First, determine if a check for an existing declaration is needed;
- if yes, check that the entity exists, and that it is internal.
- */
- if (pool == &dtd->pool) /* are we called from prolog? */
- checkEntityDecl =
+ break;
+ }
+ name = poolStoreString(&parser->m_temp2Pool, enc,
+ ptr + enc->minBytesPerChar,
+ next - enc->minBytesPerChar);
+ if (! name)
+ return XML_ERROR_NO_MEMORY;
+ entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0);
+ poolDiscard(&parser->m_temp2Pool);
+ /* First, determine if a check for an existing declaration is needed;
+ if yes, check that the entity exists, and that it is internal.
+ */
+ if (pool == &dtd->pool) /* are we called from prolog? */
+ checkEntityDecl =
#ifdef XML_DTD
- prologState.documentEntity &&
+ parser->m_prologState.documentEntity &&
#endif /* XML_DTD */
- (dtd->standalone
- ? !openInternalEntities
- : !dtd->hasParamEntityRefs);
- else /* if (pool == &tempPool): we are called from content */
- checkEntityDecl = !dtd->hasParamEntityRefs || dtd->standalone;
- if (checkEntityDecl) {
- if (!entity)
- return XML_ERROR_UNDEFINED_ENTITY;
- else if (!entity->is_internal)
- return XML_ERROR_ENTITY_DECLARED_IN_PE;
- }
- else if (!entity) {
- /* Cannot report skipped entity here - see comments on
- skippedEntityHandler.
- if (skippedEntityHandler)
- skippedEntityHandler(handlerArg, name, 0);
- */
- /* Cannot call the default handler because this would be
- out of sync with the call to the startElementHandler.
- if ((pool == &tempPool) && defaultHandler)
- reportDefault(parser, enc, ptr, next);
- */
- break;
- }
- if (entity->open) {
- if (enc == encoding) {
- /* It does not appear that this line can be executed.
- *
- * The "if (entity->open)" check catches recursive entity
- * definitions. In order to be called with an open
- * entity, it must have gone through this code before and
- * been through the recursive call to
- * appendAttributeValue() some lines below. That call
- * sets the local encoding ("enc") to the parser's
- * internal encoding (internal_utf8 or internal_utf16),
- * which can never be the same as the principle encoding.
- * It doesn't appear there is another code path that gets
- * here with entity->open being TRUE.
- *
- * Since it is not certain that this logic is watertight,
- * we keep the line and merely exclude it from coverage
- * tests.
- */
- eventPtr = ptr; /* LCOV_EXCL_LINE */
- }
- return XML_ERROR_RECURSIVE_ENTITY_REF;
- }
- if (entity->notation) {
- if (enc == encoding)
- eventPtr = ptr;
- return XML_ERROR_BINARY_ENTITY_REF;
- }
- if (!entity->textPtr) {
- if (enc == encoding)
- eventPtr = ptr;
- return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF;
- }
- else {
- enum XML_Error result;
- const XML_Char *textEnd = entity->textPtr + entity->textLen;
- entity->open = XML_TRUE;
- result = appendAttributeValue(parser, internalEncoding, isCdata,
- (char *)entity->textPtr,
- (char *)textEnd, pool);
- entity->open = XML_FALSE;
- if (result)
- return result;
+ (dtd->standalone ? ! parser->m_openInternalEntities
+ : ! dtd->hasParamEntityRefs);
+ else /* if (pool == &parser->m_tempPool): we are called from content */
+ checkEntityDecl = ! dtd->hasParamEntityRefs || dtd->standalone;
+ if (checkEntityDecl) {
+ if (! entity)
+ return XML_ERROR_UNDEFINED_ENTITY;
+ else if (! entity->is_internal)
+ return XML_ERROR_ENTITY_DECLARED_IN_PE;
+ } else if (! entity) {
+ /* Cannot report skipped entity here - see comments on
+ parser->m_skippedEntityHandler.
+ if (parser->m_skippedEntityHandler)
+ parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0);
+ */
+ /* Cannot call the default handler because this would be
+ out of sync with the call to the startElementHandler.
+ if ((pool == &parser->m_tempPool) && parser->m_defaultHandler)
+ reportDefault(parser, enc, ptr, next);
+ */
+ break;
+ }
+ if (entity->open) {
+ if (enc == parser->m_encoding) {
+ /* It does not appear that this line can be executed.
+ *
+ * The "if (entity->open)" check catches recursive entity
+ * definitions. In order to be called with an open
+ * entity, it must have gone through this code before and
+ * been through the recursive call to
+ * appendAttributeValue() some lines below. That call
+ * sets the local encoding ("enc") to the parser's
+ * internal encoding (internal_utf8 or internal_utf16),
+ * which can never be the same as the principle encoding.
+ * It doesn't appear there is another code path that gets
+ * here with entity->open being TRUE.
+ *
+ * Since it is not certain that this logic is watertight,
+ * we keep the line and merely exclude it from coverage
+ * tests.
+ */
+ parser->m_eventPtr = ptr; /* LCOV_EXCL_LINE */
}
+ return XML_ERROR_RECURSIVE_ENTITY_REF;
}
- break;
+ if (entity->notation) {
+ if (enc == parser->m_encoding)
+ parser->m_eventPtr = ptr;
+ return XML_ERROR_BINARY_ENTITY_REF;
+ }
+ if (! entity->textPtr) {
+ if (enc == parser->m_encoding)
+ parser->m_eventPtr = ptr;
+ return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF;
+ } else {
+ enum XML_Error result;
+ const XML_Char *textEnd = entity->textPtr + entity->textLen;
+ entity->open = XML_TRUE;
+ result = appendAttributeValue(parser, parser->m_internalEncoding,
+ isCdata, (char *)entity->textPtr,
+ (char *)textEnd, pool);
+ entity->open = XML_FALSE;
+ if (result)
+ return result;
+ }
+ } break;
default:
/* The only token returned by XmlAttributeValueTok() that does
* not have an explicit case here is XML_TOK_PARTIAL_CHAR.
@@ -5702,8 +5450,8 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
*
* LCOV_EXCL_START
*/
- if (enc == encoding)
- eventPtr = ptr;
+ if (enc == parser->m_encoding)
+ parser->m_eventPtr = ptr;
return XML_ERROR_UNEXPECTED_STATE;
/* LCOV_EXCL_STOP */
}
@@ -5713,23 +5461,20 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
}
static enum XML_Error
-storeEntityValue(XML_Parser parser,
- const ENCODING *enc,
- const char *entityTextPtr,
- const char *entityTextEnd)
-{
- DTD * const dtd = _dtd; /* save one level of indirection */
+storeEntityValue(XML_Parser parser, const ENCODING *enc,
+ const char *entityTextPtr, const char *entityTextEnd) {
+ DTD *const dtd = parser->m_dtd; /* save one level of indirection */
STRING_POOL *pool = &(dtd->entityValuePool);
enum XML_Error result = XML_ERROR_NONE;
#ifdef XML_DTD
- int oldInEntityValue = prologState.inEntityValue;
- prologState.inEntityValue = 1;
+ int oldInEntityValue = parser->m_prologState.inEntityValue;
+ parser->m_prologState.inEntityValue = 1;
#endif /* XML_DTD */
/* never return Null for the value argument in EntityDeclHandler,
since this would indicate an external entity; therefore we
have to make sure that entityValuePool.start is not null */
- if (!pool->blocks) {
- if (!poolGrow(pool))
+ if (! pool->blocks) {
+ if (! poolGrow(pool))
return XML_ERROR_NO_MEMORY;
}
@@ -5739,61 +5484,55 @@ storeEntityValue(XML_Parser parser,
switch (tok) {
case XML_TOK_PARAM_ENTITY_REF:
#ifdef XML_DTD
- if (isParamEntity || enc != encoding) {
+ if (parser->m_isParamEntity || enc != parser->m_encoding) {
const XML_Char *name;
ENTITY *entity;
- name = poolStoreString(&tempPool, enc,
+ name = poolStoreString(&parser->m_tempPool, enc,
entityTextPtr + enc->minBytesPerChar,
next - enc->minBytesPerChar);
- if (!name) {
+ if (! name) {
result = XML_ERROR_NO_MEMORY;
goto endEntityValue;
}
entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0);
- poolDiscard(&tempPool);
- if (!entity) {
+ poolDiscard(&parser->m_tempPool);
+ if (! entity) {
/* not a well-formedness error - see XML 1.0: WFC Entity Declared */
/* cannot report skipped entity here - see comments on
- skippedEntityHandler
- if (skippedEntityHandler)
- skippedEntityHandler(handlerArg, name, 0);
+ parser->m_skippedEntityHandler
+ if (parser->m_skippedEntityHandler)
+ parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0);
*/
dtd->keepProcessing = dtd->standalone;
goto endEntityValue;
}
if (entity->open) {
- if (enc == encoding)
- eventPtr = entityTextPtr;
+ if (enc == parser->m_encoding)
+ parser->m_eventPtr = entityTextPtr;
result = XML_ERROR_RECURSIVE_ENTITY_REF;
goto endEntityValue;
}
if (entity->systemId) {
- if (externalEntityRefHandler) {
+ if (parser->m_externalEntityRefHandler) {
dtd->paramEntityRead = XML_FALSE;
entity->open = XML_TRUE;
- if (!externalEntityRefHandler(externalEntityRefHandlerArg,
- 0,
- entity->base,
- entity->systemId,
- entity->publicId)) {
+ if (! parser->m_externalEntityRefHandler(
+ parser->m_externalEntityRefHandlerArg, 0, entity->base,
+ entity->systemId, entity->publicId)) {
entity->open = XML_FALSE;
result = XML_ERROR_EXTERNAL_ENTITY_HANDLING;
goto endEntityValue;
}
entity->open = XML_FALSE;
- if (!dtd->paramEntityRead)
+ if (! dtd->paramEntityRead)
dtd->keepProcessing = dtd->standalone;
- }
- else
+ } else
dtd->keepProcessing = dtd->standalone;
- }
- else {
+ } else {
entity->open = XML_TRUE;
- result = storeEntityValue(parser,
- internalEncoding,
- (char *)entity->textPtr,
- (char *)(entity->textPtr
- + entity->textLen));
+ result = storeEntityValue(
+ parser, parser->m_internalEncoding, (char *)entity->textPtr,
+ (char *)(entity->textPtr + entity->textLen));
entity->open = XML_FALSE;
if (result)
goto endEntityValue;
@@ -5803,7 +5542,7 @@ storeEntityValue(XML_Parser parser,
#endif /* XML_DTD */
/* In the internal subset, PE references are not legal
within markup declarations, e.g entity values in this case. */
- eventPtr = entityTextPtr;
+ parser->m_eventPtr = entityTextPtr;
result = XML_ERROR_PARAM_ENTITY_REF;
goto endEntityValue;
case XML_TOK_NONE:
@@ -5811,7 +5550,7 @@ storeEntityValue(XML_Parser parser,
goto endEntityValue;
case XML_TOK_ENTITY_REF:
case XML_TOK_DATA_CHARS:
- if (!poolAppend(pool, enc, entityTextPtr, next)) {
+ if (! poolAppend(pool, enc, entityTextPtr, next)) {
result = XML_ERROR_NO_MEMORY;
goto endEntityValue;
}
@@ -5820,50 +5559,48 @@ storeEntityValue(XML_Parser parser,
next = entityTextPtr + enc->minBytesPerChar;
/* fall through */
case XML_TOK_DATA_NEWLINE:
- if (pool->end == pool->ptr && !poolGrow(pool)) {
- result = XML_ERROR_NO_MEMORY;
+ if (pool->end == pool->ptr && ! poolGrow(pool)) {
+ result = XML_ERROR_NO_MEMORY;
goto endEntityValue;
}
*(pool->ptr)++ = 0xA;
break;
- case XML_TOK_CHAR_REF:
- {
- XML_Char buf[XML_ENCODE_MAX];
- int i;
- int n = XmlCharRefNumber(enc, entityTextPtr);
- if (n < 0) {
- if (enc == encoding)
- eventPtr = entityTextPtr;
- result = XML_ERROR_BAD_CHAR_REF;
+ case XML_TOK_CHAR_REF: {
+ XML_Char buf[XML_ENCODE_MAX];
+ int i;
+ int n = XmlCharRefNumber(enc, entityTextPtr);
+ if (n < 0) {
+ if (enc == parser->m_encoding)
+ parser->m_eventPtr = entityTextPtr;
+ result = XML_ERROR_BAD_CHAR_REF;
+ goto endEntityValue;
+ }
+ n = XmlEncode(n, (ICHAR *)buf);
+ /* The XmlEncode() functions can never return 0 here. That
+ * error return happens if the code point passed in is either
+ * negative or greater than or equal to 0x110000. The
+ * XmlCharRefNumber() functions will all return a number
+ * strictly less than 0x110000 or a negative value if an error
+ * occurred. The negative value is intercepted above, so
+ * XmlEncode() is never passed a value it might return an
+ * error for.
+ */
+ for (i = 0; i < n; i++) {
+ if (pool->end == pool->ptr && ! poolGrow(pool)) {
+ result = XML_ERROR_NO_MEMORY;
goto endEntityValue;
}
- n = XmlEncode(n, (ICHAR *)buf);
- /* The XmlEncode() functions can never return 0 here. That
- * error return happens if the code point passed in is either
- * negative or greater than or equal to 0x110000. The
- * XmlCharRefNumber() functions will all return a number
- * strictly less than 0x110000 or a negative value if an error
- * occurred. The negative value is intercepted above, so
- * XmlEncode() is never passed a value it might return an
- * error for.
- */
- for (i = 0; i < n; i++) {
- if (pool->end == pool->ptr && !poolGrow(pool)) {
- result = XML_ERROR_NO_MEMORY;
- goto endEntityValue;
- }
- *(pool->ptr)++ = buf[i];
- }
+ *(pool->ptr)++ = buf[i];
}
- break;
+ } break;
case XML_TOK_PARTIAL:
- if (enc == encoding)
- eventPtr = entityTextPtr;
+ if (enc == parser->m_encoding)
+ parser->m_eventPtr = entityTextPtr;
result = XML_ERROR_INVALID_TOKEN;
goto endEntityValue;
case XML_TOK_INVALID:
- if (enc == encoding)
- eventPtr = next;
+ if (enc == parser->m_encoding)
+ parser->m_eventPtr = next;
result = XML_ERROR_INVALID_TOKEN;
goto endEntityValue;
default:
@@ -5874,8 +5611,8 @@ storeEntityValue(XML_Parser parser,
*
* LCOV_EXCL_START
*/
- if (enc == encoding)
- eventPtr = entityTextPtr;
+ if (enc == parser->m_encoding)
+ parser->m_eventPtr = entityTextPtr;
result = XML_ERROR_UNEXPECTED_STATE;
goto endEntityValue;
/* LCOV_EXCL_STOP */
@@ -5884,14 +5621,13 @@ storeEntityValue(XML_Parser parser,
}
endEntityValue:
#ifdef XML_DTD
- prologState.inEntityValue = oldInEntityValue;
+ parser->m_prologState.inEntityValue = oldInEntityValue;
#endif /* XML_DTD */
return result;
}
static void FASTCALL
-normalizeLines(XML_Char *s)
-{
+normalizeLines(XML_Char *s) {
XML_Char *p;
for (;; s++) {
if (*s == XML_T('\0'))
@@ -5905,8 +5641,7 @@ normalizeLines(XML_Char *s)
*p++ = 0xA;
if (*++s == 0xA)
s++;
- }
- else
+ } else
*p++ = *s++;
} while (*s);
*p = XML_T('\0');
@@ -5914,68 +5649,62 @@ normalizeLines(XML_Char *s)
static int
reportProcessingInstruction(XML_Parser parser, const ENCODING *enc,
- const char *start, const char *end)
-{
+ const char *start, const char *end) {
const XML_Char *target;
XML_Char *data;
const char *tem;
- if (!processingInstructionHandler) {
- if (defaultHandler)
+ if (! parser->m_processingInstructionHandler) {
+ if (parser->m_defaultHandler)
reportDefault(parser, enc, start, end);
return 1;
}
start += enc->minBytesPerChar * 2;
tem = start + XmlNameLength(enc, start);
- target = poolStoreString(&tempPool, enc, start, tem);
- if (!target)
+ target = poolStoreString(&parser->m_tempPool, enc, start, tem);
+ if (! target)
return 0;
- poolFinish(&tempPool);
- data = poolStoreString(&tempPool, enc,
- XmlSkipS(enc, tem),
- end - enc->minBytesPerChar*2);
- if (!data)
+ poolFinish(&parser->m_tempPool);
+ data = poolStoreString(&parser->m_tempPool, enc, XmlSkipS(enc, tem),
+ end - enc->minBytesPerChar * 2);
+ if (! data)
return 0;
normalizeLines(data);
- processingInstructionHandler(handlerArg, target, data);
- poolClear(&tempPool);
+ parser->m_processingInstructionHandler(parser->m_handlerArg, target, data);
+ poolClear(&parser->m_tempPool);
return 1;
}
static int
-reportComment(XML_Parser parser, const ENCODING *enc,
- const char *start, const char *end)
-{
+reportComment(XML_Parser parser, const ENCODING *enc, const char *start,
+ const char *end) {
XML_Char *data;
- if (!commentHandler) {
- if (defaultHandler)
+ if (! parser->m_commentHandler) {
+ if (parser->m_defaultHandler)
reportDefault(parser, enc, start, end);
return 1;
}
- data = poolStoreString(&tempPool,
- enc,
+ data = poolStoreString(&parser->m_tempPool, enc,
start + enc->minBytesPerChar * 4,
end - enc->minBytesPerChar * 3);
- if (!data)
+ if (! data)
return 0;
normalizeLines(data);
- commentHandler(handlerArg, data);
- poolClear(&tempPool);
+ parser->m_commentHandler(parser->m_handlerArg, data);
+ poolClear(&parser->m_tempPool);
return 1;
}
static void
-reportDefault(XML_Parser parser, const ENCODING *enc,
- const char *s, const char *end)
-{
+reportDefault(XML_Parser parser, const ENCODING *enc, const char *s,
+ const char *end) {
if (MUST_CONVERT(enc, s)) {
enum XML_Convert_Result convert_res;
const char **eventPP;
const char **eventEndPP;
- if (enc == encoding) {
- eventPP = &eventPtr;
- eventEndPP = &eventEndPtr;
- }
- else {
+ if (enc == parser->m_encoding) {
+ eventPP = &parser->m_eventPtr;
+ eventEndPP = &parser->m_eventEndPtr;
+ } else {
/* To get here, two things must be true; the parser must be
* using a character encoding that is not the same as the
* encoding passed in, and the encoding passed in must need
@@ -5992,27 +5721,28 @@ reportDefault(XML_Parser parser, const ENCODING *enc,
*
* LCOV_EXCL_START
*/
- eventPP = &(openInternalEntities->internalEventPtr);
- eventEndPP = &(openInternalEntities->internalEventEndPtr);
+ eventPP = &(parser->m_openInternalEntities->internalEventPtr);
+ eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr);
/* LCOV_EXCL_STOP */
}
do {
- ICHAR *dataPtr = (ICHAR *)dataBuf;
- convert_res = XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd);
+ ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf;
+ convert_res
+ = XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)parser->m_dataBufEnd);
*eventEndPP = s;
- defaultHandler(handlerArg, dataBuf, (int)(dataPtr - (ICHAR *)dataBuf));
+ parser->m_defaultHandler(parser->m_handlerArg, parser->m_dataBuf,
+ (int)(dataPtr - (ICHAR *)parser->m_dataBuf));
*eventPP = s;
- } while ((convert_res != XML_CONVERT_COMPLETED) && (convert_res != XML_CONVERT_INPUT_INCOMPLETE));
- }
- else
- defaultHandler(handlerArg, (XML_Char *)s, (int)((XML_Char *)end - (XML_Char *)s));
+ } while ((convert_res != XML_CONVERT_COMPLETED)
+ && (convert_res != XML_CONVERT_INPUT_INCOMPLETE));
+ } else
+ parser->m_defaultHandler(parser->m_handlerArg, (XML_Char *)s,
+ (int)((XML_Char *)end - (XML_Char *)s));
}
-
static int
defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata,
- XML_Bool isId, const XML_Char *value, XML_Parser parser)
-{
+ XML_Bool isId, const XML_Char *value, XML_Parser parser) {
DEFAULT_ATTRIBUTE *att;
if (value || isId) {
/* The handling of default attributes gets messed up if we have
@@ -6021,22 +5751,23 @@ defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata,
for (i = 0; i < type->nDefaultAtts; i++)
if (attId == type->defaultAtts[i].id)
return 1;
- if (isId && !type->idAtt && !attId->xmlns)
+ if (isId && ! type->idAtt && ! attId->xmlns)
type->idAtt = attId;
}
if (type->nDefaultAtts == type->allocDefaultAtts) {
if (type->allocDefaultAtts == 0) {
type->allocDefaultAtts = 8;
- type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(type->allocDefaultAtts
- * sizeof(DEFAULT_ATTRIBUTE));
- if (!type->defaultAtts)
+ type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(
+ parser, type->allocDefaultAtts * sizeof(DEFAULT_ATTRIBUTE));
+ if (! type->defaultAtts) {
+ type->allocDefaultAtts = 0;
return 0;
- }
- else {
+ }
+ } else {
DEFAULT_ATTRIBUTE *temp;
int count = type->allocDefaultAtts * 2;
- temp = (DEFAULT_ATTRIBUTE *)
- REALLOC(type->defaultAtts, (count * sizeof(DEFAULT_ATTRIBUTE)));
+ temp = (DEFAULT_ATTRIBUTE *)REALLOC(parser, type->defaultAtts,
+ (count * sizeof(DEFAULT_ATTRIBUTE)));
if (temp == NULL)
return 0;
type->allocDefaultAtts = count;
@@ -6047,92 +5778,89 @@ defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata,
att->id = attId;
att->value = value;
att->isCdata = isCdata;
- if (!isCdata)
+ if (! isCdata)
attId->maybeTokenized = XML_TRUE;
type->nDefaultAtts += 1;
return 1;
}
static int
-setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType)
-{
- DTD * const dtd = _dtd; /* save one level of indirection */
+setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) {
+ DTD *const dtd = parser->m_dtd; /* save one level of indirection */
const XML_Char *name;
for (name = elementType->name; *name; name++) {
if (*name == XML_T(ASCII_COLON)) {
PREFIX *prefix;
const XML_Char *s;
for (s = elementType->name; s != name; s++) {
- if (!poolAppendChar(&dtd->pool, *s))
+ if (! poolAppendChar(&dtd->pool, *s))
return 0;
}
- if (!poolAppendChar(&dtd->pool, XML_T('\0')))
+ if (! poolAppendChar(&dtd->pool, XML_T('\0')))
return 0;
prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool),
sizeof(PREFIX));
- if (!prefix)
+ if (! prefix)
return 0;
if (prefix->name == poolStart(&dtd->pool))
poolFinish(&dtd->pool);
else
poolDiscard(&dtd->pool);
elementType->prefix = prefix;
-
+ break;
}
}
return 1;
}
static ATTRIBUTE_ID *
-getAttributeId(XML_Parser parser, const ENCODING *enc,
- const char *start, const char *end)
-{
- DTD * const dtd = _dtd; /* save one level of indirection */
+getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start,
+ const char *end) {
+ DTD *const dtd = parser->m_dtd; /* save one level of indirection */
ATTRIBUTE_ID *id;
const XML_Char *name;
- if (!poolAppendChar(&dtd->pool, XML_T('\0')))
+ if (! poolAppendChar(&dtd->pool, XML_T('\0')))
return NULL;
name = poolStoreString(&dtd->pool, enc, start, end);
- if (!name)
+ if (! name)
return NULL;
/* skip quotation mark - its storage will be re-used (like in name[-1]) */
++name;
- id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, name, sizeof(ATTRIBUTE_ID));
- if (!id)
+ id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, name,
+ sizeof(ATTRIBUTE_ID));
+ if (! id)
return NULL;
if (id->name != name)
poolDiscard(&dtd->pool);
else {
poolFinish(&dtd->pool);
- if (!ns)
+ if (! parser->m_ns)
;
- else if (name[0] == XML_T(ASCII_x)
- && name[1] == XML_T(ASCII_m)
- && name[2] == XML_T(ASCII_l)
- && name[3] == XML_T(ASCII_n)
- && name[4] == XML_T(ASCII_s)
- && (name[5] == XML_T('\0') || name[5] == XML_T(ASCII_COLON))) {
+ else if (name[0] == XML_T(ASCII_x) && name[1] == XML_T(ASCII_m)
+ && name[2] == XML_T(ASCII_l) && name[3] == XML_T(ASCII_n)
+ && name[4] == XML_T(ASCII_s)
+ && (name[5] == XML_T('\0') || name[5] == XML_T(ASCII_COLON))) {
if (name[5] == XML_T('\0'))
id->prefix = &dtd->defaultPrefix;
else
- id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, name + 6, sizeof(PREFIX));
+ id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, name + 6,
+ sizeof(PREFIX));
id->xmlns = XML_TRUE;
- }
- else {
+ } else {
int i;
for (i = 0; name[i]; i++) {
/* attributes without prefix are *not* in the default namespace */
if (name[i] == XML_T(ASCII_COLON)) {
int j;
for (j = 0; j < i; j++) {
- if (!poolAppendChar(&dtd->pool, name[j]))
+ if (! poolAppendChar(&dtd->pool, name[j]))
return NULL;
}
- if (!poolAppendChar(&dtd->pool, XML_T('\0')))
+ if (! poolAppendChar(&dtd->pool, XML_T('\0')))
return NULL;
- id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool),
- sizeof(PREFIX));
- if (!id->prefix)
+ id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes,
+ poolStart(&dtd->pool), sizeof(PREFIX));
+ if (! id->prefix)
return NULL;
if (id->prefix->name == poolStart(&dtd->pool))
poolFinish(&dtd->pool);
@@ -6149,22 +5877,22 @@ getAttributeId(XML_Parser parser, const ENCODING *enc,
#define CONTEXT_SEP XML_T(ASCII_FF)
static const XML_Char *
-getContext(XML_Parser parser)
-{
- DTD * const dtd = _dtd; /* save one level of indirection */
+getContext(XML_Parser parser) {
+ DTD *const dtd = parser->m_dtd; /* save one level of indirection */
HASH_TABLE_ITER iter;
XML_Bool needSep = XML_FALSE;
if (dtd->defaultPrefix.binding) {
int i;
int len;
- if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS)))
+ if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_EQUALS)))
return NULL;
len = dtd->defaultPrefix.binding->uriLen;
- if (namespaceSeparator)
+ if (parser->m_namespaceSeparator)
len--;
for (i = 0; i < len; i++) {
- if (!poolAppendChar(&tempPool, dtd->defaultPrefix.binding->uri[i])) {
+ if (! poolAppendChar(&parser->m_tempPool,
+ dtd->defaultPrefix.binding->uri[i])) {
/* Because of memory caching, I don't believe this line can be
* executed.
*
@@ -6196,9 +5924,9 @@ getContext(XML_Parser parser)
int len;
const XML_Char *s;
PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter);
- if (!prefix)
+ if (! prefix)
break;
- if (!prefix->binding) {
+ if (! prefix->binding) {
/* This test appears to be (justifiable) paranoia. There does
* not seem to be a way of injecting a prefix without a binding
* that doesn't get errored long before this function is called.
@@ -6207,98 +5935,96 @@ getContext(XML_Parser parser)
*/
continue; /* LCOV_EXCL_LINE */
}
- if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP))
+ if (needSep && ! poolAppendChar(&parser->m_tempPool, CONTEXT_SEP))
return NULL;
for (s = prefix->name; *s; s++)
- if (!poolAppendChar(&tempPool, *s))
+ if (! poolAppendChar(&parser->m_tempPool, *s))
return NULL;
- if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS)))
+ if (! poolAppendChar(&parser->m_tempPool, XML_T(ASCII_EQUALS)))
return NULL;
len = prefix->binding->uriLen;
- if (namespaceSeparator)
+ if (parser->m_namespaceSeparator)
len--;
for (i = 0; i < len; i++)
- if (!poolAppendChar(&tempPool, prefix->binding->uri[i]))
+ if (! poolAppendChar(&parser->m_tempPool, prefix->binding->uri[i]))
return NULL;
needSep = XML_TRUE;
}
-
hashTableIterInit(&iter, &(dtd->generalEntities));
for (;;) {
const XML_Char *s;
ENTITY *e = (ENTITY *)hashTableIterNext(&iter);
- if (!e)
+ if (! e)
break;
- if (!e->open)
+ if (! e->open)
continue;
- if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP))
+ if (needSep && ! poolAppendChar(&parser->m_tempPool, CONTEXT_SEP))
return NULL;
for (s = e->name; *s; s++)
- if (!poolAppendChar(&tempPool, *s))
+ if (! poolAppendChar(&parser->m_tempPool, *s))
return 0;
needSep = XML_TRUE;
}
- if (!poolAppendChar(&tempPool, XML_T('\0')))
+ if (! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
return NULL;
- return tempPool.start;
+ return parser->m_tempPool.start;
}
static XML_Bool
-setContext(XML_Parser parser, const XML_Char *context)
-{
- DTD * const dtd = _dtd; /* save one level of indirection */
+setContext(XML_Parser parser, const XML_Char *context) {
+ DTD *const dtd = parser->m_dtd; /* save one level of indirection */
const XML_Char *s = context;
while (*context != XML_T('\0')) {
if (*s == CONTEXT_SEP || *s == XML_T('\0')) {
ENTITY *e;
- if (!poolAppendChar(&tempPool, XML_T('\0')))
+ if (! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
return XML_FALSE;
- e = (ENTITY *)lookup(parser, &dtd->generalEntities, poolStart(&tempPool), 0);
+ e = (ENTITY *)lookup(parser, &dtd->generalEntities,
+ poolStart(&parser->m_tempPool), 0);
if (e)
e->open = XML_TRUE;
if (*s != XML_T('\0'))
s++;
context = s;
- poolDiscard(&tempPool);
- }
- else if (*s == XML_T(ASCII_EQUALS)) {
+ poolDiscard(&parser->m_tempPool);
+ } else if (*s == XML_T(ASCII_EQUALS)) {
PREFIX *prefix;
- if (poolLength(&tempPool) == 0)
+ if (poolLength(&parser->m_tempPool) == 0)
prefix = &dtd->defaultPrefix;
else {
- if (!poolAppendChar(&tempPool, XML_T('\0')))
+ if (! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
return XML_FALSE;
- prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&tempPool),
- sizeof(PREFIX));
- if (!prefix)
+ prefix
+ = (PREFIX *)lookup(parser, &dtd->prefixes,
+ poolStart(&parser->m_tempPool), sizeof(PREFIX));
+ if (! prefix)
return XML_FALSE;
- if (prefix->name == poolStart(&tempPool)) {
+ if (prefix->name == poolStart(&parser->m_tempPool)) {
prefix->name = poolCopyString(&dtd->pool, prefix->name);
- if (!prefix->name)
+ if (! prefix->name)
return XML_FALSE;
}
- poolDiscard(&tempPool);
+ poolDiscard(&parser->m_tempPool);
}
- for (context = s + 1;
- *context != CONTEXT_SEP && *context != XML_T('\0');
+ for (context = s + 1; *context != CONTEXT_SEP && *context != XML_T('\0');
context++)
- if (!poolAppendChar(&tempPool, *context))
+ if (! poolAppendChar(&parser->m_tempPool, *context))
return XML_FALSE;
- if (!poolAppendChar(&tempPool, XML_T('\0')))
+ if (! poolAppendChar(&parser->m_tempPool, XML_T('\0')))
return XML_FALSE;
- if (addBinding(parser, prefix, NULL, poolStart(&tempPool),
- &inheritedBindings) != XML_ERROR_NONE)
+ if (addBinding(parser, prefix, NULL, poolStart(&parser->m_tempPool),
+ &parser->m_inheritedBindings)
+ != XML_ERROR_NONE)
return XML_FALSE;
- poolDiscard(&tempPool);
+ poolDiscard(&parser->m_tempPool);
if (*context != XML_T('\0'))
++context;
s = context;
- }
- else {
- if (!poolAppendChar(&tempPool, *s))
+ } else {
+ if (! poolAppendChar(&parser->m_tempPool, *s))
return XML_FALSE;
s++;
}
@@ -6307,8 +6033,7 @@ setContext(XML_Parser parser, const XML_Char *context)
}
static void FASTCALL
-normalizePublicId(XML_Char *publicId)
-{
+normalizePublicId(XML_Char *publicId) {
XML_Char *p = publicId;
XML_Char *s;
for (s = publicId; *s; s++) {
@@ -6329,8 +6054,7 @@ normalizePublicId(XML_Char *publicId)
}
static DTD *
-dtdCreate(const XML_Memory_Handling_Suite *ms)
-{
+dtdCreate(const XML_Memory_Handling_Suite *ms) {
DTD *p = (DTD *)ms->malloc_fcn(sizeof(DTD));
if (p == NULL)
return p;
@@ -6362,13 +6086,12 @@ dtdCreate(const XML_Memory_Handling_Suite *ms)
}
static void
-dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms)
-{
+dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms) {
HASH_TABLE_ITER iter;
hashTableIterInit(&iter, &(p->elementTypes));
for (;;) {
ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter);
- if (!e)
+ if (! e)
break;
if (e->allocDefaultAtts != 0)
ms->free_fcn(e->defaultAtts);
@@ -6404,13 +6127,12 @@ dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms)
}
static void
-dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms)
-{
+dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms) {
HASH_TABLE_ITER iter;
hashTableIterInit(&iter, &(p->elementTypes));
for (;;) {
ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter);
- if (!e)
+ if (! e)
break;
if (e->allocDefaultAtts != 0)
ms->free_fcn(e->defaultAtts);
@@ -6435,8 +6157,8 @@ dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms)
The new DTD has already been initialized.
*/
static int
-dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms)
-{
+dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd,
+ const XML_Memory_Handling_Suite *ms) {
HASH_TABLE_ITER iter;
/* Copy the prefix table. */
@@ -6445,12 +6167,12 @@ dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, const XML_Memory_H
for (;;) {
const XML_Char *name;
const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter);
- if (!oldP)
+ if (! oldP)
break;
name = poolCopyString(&(newDtd->pool), oldP->name);
- if (!name)
+ if (! name)
return 0;
- if (!lookup(oldParser, &(newDtd->prefixes), name, sizeof(PREFIX)))
+ if (! lookup(oldParser, &(newDtd->prefixes), name, sizeof(PREFIX)))
return 0;
}
@@ -6463,18 +6185,18 @@ dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, const XML_Memory_H
const XML_Char *name;
const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter);
- if (!oldA)
+ if (! oldA)
break;
/* Remember to allocate the scratch byte before the name. */
- if (!poolAppendChar(&(newDtd->pool), XML_T('\0')))
+ if (! poolAppendChar(&(newDtd->pool), XML_T('\0')))
return 0;
name = poolCopyString(&(newDtd->pool), oldA->name);
- if (!name)
+ if (! name)
return 0;
++name;
newA = (ATTRIBUTE_ID *)lookup(oldParser, &(newDtd->attributeIds), name,
sizeof(ATTRIBUTE_ID));
- if (!newA)
+ if (! newA)
return 0;
newA->maybeTokenized = oldA->maybeTokenized;
if (oldA->prefix) {
@@ -6496,57 +6218,52 @@ dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, const XML_Memory_H
ELEMENT_TYPE *newE;
const XML_Char *name;
const ELEMENT_TYPE *oldE = (ELEMENT_TYPE *)hashTableIterNext(&iter);
- if (!oldE)
+ if (! oldE)
break;
name = poolCopyString(&(newDtd->pool), oldE->name);
- if (!name)
+ if (! name)
return 0;
newE = (ELEMENT_TYPE *)lookup(oldParser, &(newDtd->elementTypes), name,
sizeof(ELEMENT_TYPE));
- if (!newE)
+ if (! newE)
return 0;
if (oldE->nDefaultAtts) {
- newE->defaultAtts = (DEFAULT_ATTRIBUTE *)
- ms->malloc_fcn(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE));
- if (!newE->defaultAtts) {
+ newE->defaultAtts = (DEFAULT_ATTRIBUTE *)ms->malloc_fcn(
+ oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE));
+ if (! newE->defaultAtts) {
return 0;
}
}
if (oldE->idAtt)
- newE->idAtt = (ATTRIBUTE_ID *)
- lookup(oldParser, &(newDtd->attributeIds), oldE->idAtt->name, 0);
+ newE->idAtt = (ATTRIBUTE_ID *)lookup(oldParser, &(newDtd->attributeIds),
+ oldE->idAtt->name, 0);
newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts;
if (oldE->prefix)
newE->prefix = (PREFIX *)lookup(oldParser, &(newDtd->prefixes),
oldE->prefix->name, 0);
for (i = 0; i < newE->nDefaultAtts; i++) {
- newE->defaultAtts[i].id = (ATTRIBUTE_ID *)
- lookup(oldParser, &(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0);
+ newE->defaultAtts[i].id = (ATTRIBUTE_ID *)lookup(
+ oldParser, &(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0);
newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata;
if (oldE->defaultAtts[i].value) {
newE->defaultAtts[i].value
= poolCopyString(&(newDtd->pool), oldE->defaultAtts[i].value);
- if (!newE->defaultAtts[i].value)
+ if (! newE->defaultAtts[i].value)
return 0;
- }
- else
+ } else
newE->defaultAtts[i].value = NULL;
}
}
/* Copy the entity tables. */
- if (!copyEntityTable(oldParser,
- &(newDtd->generalEntities),
- &(newDtd->pool),
- &(oldDtd->generalEntities)))
- return 0;
+ if (! copyEntityTable(oldParser, &(newDtd->generalEntities), &(newDtd->pool),
+ &(oldDtd->generalEntities)))
+ return 0;
#ifdef XML_DTD
- if (!copyEntityTable(oldParser,
- &(newDtd->paramEntities),
- &(newDtd->pool),
- &(oldDtd->paramEntities)))
- return 0;
+ if (! copyEntityTable(oldParser, &(newDtd->paramEntities), &(newDtd->pool),
+ &(oldDtd->paramEntities)))
+ return 0;
newDtd->paramEntityRead = oldDtd->paramEntityRead;
#endif /* XML_DTD */
@@ -6563,14 +6280,11 @@ dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, const XML_Memory_H
newDtd->scaffIndex = oldDtd->scaffIndex;
return 1;
-} /* End dtdCopy */
+} /* End dtdCopy */
static int
-copyEntityTable(XML_Parser oldParser,
- HASH_TABLE *newTable,
- STRING_POOL *newPool,
- const HASH_TABLE *oldTable)
-{
+copyEntityTable(XML_Parser oldParser, HASH_TABLE *newTable,
+ STRING_POOL *newPool, const HASH_TABLE *oldTable) {
HASH_TABLE_ITER iter;
const XML_Char *cachedOldBase = NULL;
const XML_Char *cachedNewBase = NULL;
@@ -6581,17 +6295,17 @@ copyEntityTable(XML_Parser oldParser,
ENTITY *newE;
const XML_Char *name;
const ENTITY *oldE = (ENTITY *)hashTableIterNext(&iter);
- if (!oldE)
+ if (! oldE)
break;
name = poolCopyString(newPool, oldE->name);
- if (!name)
+ if (! name)
return 0;
newE = (ENTITY *)lookup(oldParser, newTable, name, sizeof(ENTITY));
- if (!newE)
+ if (! newE)
return 0;
if (oldE->systemId) {
const XML_Char *tem = poolCopyString(newPool, oldE->systemId);
- if (!tem)
+ if (! tem)
return 0;
newE->systemId = tem;
if (oldE->base) {
@@ -6600,29 +6314,28 @@ copyEntityTable(XML_Parser oldParser,
else {
cachedOldBase = oldE->base;
tem = poolCopyString(newPool, cachedOldBase);
- if (!tem)
+ if (! tem)
return 0;
cachedNewBase = newE->base = tem;
}
}
if (oldE->publicId) {
tem = poolCopyString(newPool, oldE->publicId);
- if (!tem)
+ if (! tem)
return 0;
newE->publicId = tem;
}
- }
- else {
- const XML_Char *tem = poolCopyStringN(newPool, oldE->textPtr,
- oldE->textLen);
- if (!tem)
+ } else {
+ const XML_Char *tem
+ = poolCopyStringN(newPool, oldE->textPtr, oldE->textLen);
+ if (! tem)
return 0;
newE->textPtr = tem;
newE->textLen = oldE->textLen;
}
if (oldE->notation) {
const XML_Char *tem = poolCopyString(newPool, oldE->notation);
- if (!tem)
+ if (! tem)
return 0;
newE->notation = tem;
}
@@ -6635,8 +6348,7 @@ copyEntityTable(XML_Parser oldParser,
#define INIT_POWER 6
static XML_Bool FASTCALL
-keyeq(KEY s1, KEY s2)
-{
+keyeq(KEY s1, KEY s2) {
for (; *s1 == *s2; s1++, s2++)
if (*s1 == 0)
return XML_TRUE;
@@ -6644,26 +6356,23 @@ keyeq(KEY s1, KEY s2)
}
static size_t
-keylen(KEY s)
-{
+keylen(KEY s) {
size_t len = 0;
- for (; *s; s++, len++);
+ for (; *s; s++, len++)
+ ;
return len;
}
static void
-copy_salt_to_sipkey(XML_Parser parser, struct sipkey * key)
-{
+copy_salt_to_sipkey(XML_Parser parser, struct sipkey *key) {
key->k[0] = 0;
key->k[1] = get_hash_secret_salt(parser);
}
static unsigned long FASTCALL
-hash(XML_Parser parser, KEY s)
-{
+hash(XML_Parser parser, KEY s) {
struct siphash state;
struct sipkey key;
- (void)sip_tobin;
(void)sip24_valid;
copy_salt_to_sipkey(parser, &key);
sip24_init(&state, &key);
@@ -6672,26 +6381,24 @@ hash(XML_Parser parser, KEY s)
}
static NAMED *
-lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize)
-{
+lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) {
size_t i;
if (table->size == 0) {
size_t tsize;
- if (!createSize)
+ if (! createSize)
return NULL;
table->power = INIT_POWER;
/* table->size is a power of 2 */
table->size = (size_t)1 << INIT_POWER;
tsize = table->size * sizeof(NAMED *);
table->v = (NAMED **)table->mem->malloc_fcn(tsize);
- if (!table->v) {
+ if (! table->v) {
table->size = 0;
return NULL;
}
memset(table->v, 0, tsize);
i = hash(parser, name) & ((unsigned long)table->size - 1);
- }
- else {
+ } else {
unsigned long h = hash(parser, name);
unsigned long mask = (unsigned long)table->size - 1;
unsigned char step = 0;
@@ -6699,11 +6406,11 @@ lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize)
while (table->v[i]) {
if (keyeq(name, table->v[i]->name))
return table->v[i];
- if (!step)
+ if (! step)
step = PROBE_STEP(h, mask, table->power);
i < step ? (i += table->size - step) : (i -= step);
}
- if (!createSize)
+ if (! createSize)
return NULL;
/* check for overflow (table is half full) */
@@ -6713,7 +6420,7 @@ lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize)
unsigned long newMask = (unsigned long)newSize - 1;
size_t tsize = newSize * sizeof(NAMED *);
NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize);
- if (!newV)
+ if (! newV)
return NULL;
memset(newV, 0, tsize);
for (i = 0; i < table->size; i++)
@@ -6722,7 +6429,7 @@ lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize)
size_t j = newHash & newMask;
step = 0;
while (newV[j]) {
- if (!step)
+ if (! step)
step = PROBE_STEP(newHash, newMask, newPower);
j < step ? (j += newSize - step) : (j -= step);
}
@@ -6735,14 +6442,14 @@ lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize)
i = h & newMask;
step = 0;
while (table->v[i]) {
- if (!step)
+ if (! step)
step = PROBE_STEP(h, newMask, newPower);
i < step ? (i += newSize - step) : (i -= step);
}
}
}
table->v[i] = (NAMED *)table->mem->malloc_fcn(createSize);
- if (!table->v[i])
+ if (! table->v[i])
return NULL;
memset(table->v[i], 0, createSize);
table->v[i]->name = name;
@@ -6751,8 +6458,7 @@ lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize)
}
static void FASTCALL
-hashTableClear(HASH_TABLE *table)
-{
+hashTableClear(HASH_TABLE *table) {
size_t i;
for (i = 0; i < table->size; i++) {
table->mem->free_fcn(table->v[i]);
@@ -6762,8 +6468,7 @@ hashTableClear(HASH_TABLE *table)
}
static void FASTCALL
-hashTableDestroy(HASH_TABLE *table)
-{
+hashTableDestroy(HASH_TABLE *table) {
size_t i;
for (i = 0; i < table->size; i++)
table->mem->free_fcn(table->v[i]);
@@ -6771,8 +6476,7 @@ hashTableDestroy(HASH_TABLE *table)
}
static void FASTCALL
-hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms)
-{
+hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms) {
p->power = 0;
p->size = 0;
p->used = 0;
@@ -6781,15 +6485,13 @@ hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms)
}
static void FASTCALL
-hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table)
-{
+hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table) {
iter->p = table->v;
iter->end = iter->p + table->size;
}
-static NAMED * FASTCALL
-hashTableIterNext(HASH_TABLE_ITER *iter)
-{
+static NAMED *FASTCALL
+hashTableIterNext(HASH_TABLE_ITER *iter) {
while (iter->p != iter->end) {
NAMED *tem = *(iter->p)++;
if (tem)
@@ -6799,8 +6501,7 @@ hashTableIterNext(HASH_TABLE_ITER *iter)
}
static void FASTCALL
-poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms)
-{
+poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms) {
pool->blocks = NULL;
pool->freeBlocks = NULL;
pool->start = NULL;
@@ -6810,9 +6511,8 @@ poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms)
}
static void FASTCALL
-poolClear(STRING_POOL *pool)
-{
- if (!pool->freeBlocks)
+poolClear(STRING_POOL *pool) {
+ if (! pool->freeBlocks)
pool->freeBlocks = pool->blocks;
else {
BLOCK *p = pool->blocks;
@@ -6830,8 +6530,7 @@ poolClear(STRING_POOL *pool)
}
static void FASTCALL
-poolDestroy(STRING_POOL *pool)
-{
+poolDestroy(STRING_POOL *pool) {
BLOCK *p = pool->blocks;
while (p) {
BLOCK *tem = p->next;
@@ -6847,26 +6546,26 @@ poolDestroy(STRING_POOL *pool)
}
static XML_Char *
-poolAppend(STRING_POOL *pool, const ENCODING *enc,
- const char *ptr, const char *end)
-{
- if (!pool->ptr && !poolGrow(pool))
+poolAppend(STRING_POOL *pool, const ENCODING *enc, const char *ptr,
+ const char *end) {
+ if (! pool->ptr && ! poolGrow(pool))
return NULL;
for (;;) {
- const enum XML_Convert_Result convert_res = XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end);
- if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE))
+ const enum XML_Convert_Result convert_res = XmlConvert(
+ enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end);
+ if ((convert_res == XML_CONVERT_COMPLETED)
+ || (convert_res == XML_CONVERT_INPUT_INCOMPLETE))
break;
- if (!poolGrow(pool))
+ if (! poolGrow(pool))
return NULL;
}
return pool->start;
}
-static const XML_Char * FASTCALL
-poolCopyString(STRING_POOL *pool, const XML_Char *s)
-{
+static const XML_Char *FASTCALL
+poolCopyString(STRING_POOL *pool, const XML_Char *s) {
do {
- if (!poolAppendChar(pool, *s))
+ if (! poolAppendChar(pool, *s))
return NULL;
} while (*s++);
s = pool->start;
@@ -6875,9 +6574,8 @@ poolCopyString(STRING_POOL *pool, const XML_Char *s)
}
static const XML_Char *
-poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n)
-{
- if (!pool->ptr && !poolGrow(pool)) {
+poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) {
+ if (! pool->ptr && ! poolGrow(pool)) {
/* The following line is unreachable given the current usage of
* poolCopyStringN(). Currently it is called from exactly one
* place to copy the text of a simple general entity. By that
@@ -6892,7 +6590,7 @@ poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n)
return NULL; /* LCOV_EXCL_LINE */
}
for (; n > 0; --n, s++) {
- if (!poolAppendChar(pool, *s))
+ if (! poolAppendChar(pool, *s))
return NULL;
}
s = pool->start;
@@ -6900,11 +6598,10 @@ poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n)
return s;
}
-static const XML_Char * FASTCALL
-poolAppendString(STRING_POOL *pool, const XML_Char *s)
-{
+static const XML_Char *FASTCALL
+poolAppendString(STRING_POOL *pool, const XML_Char *s) {
while (*s) {
- if (!poolAppendChar(pool, *s))
+ if (! poolAppendChar(pool, *s))
return NULL;
s++;
}
@@ -6912,20 +6609,18 @@ poolAppendString(STRING_POOL *pool, const XML_Char *s)
}
static XML_Char *
-poolStoreString(STRING_POOL *pool, const ENCODING *enc,
- const char *ptr, const char *end)
-{
- if (!poolAppend(pool, enc, ptr, end))
+poolStoreString(STRING_POOL *pool, const ENCODING *enc, const char *ptr,
+ const char *end) {
+ if (! poolAppend(pool, enc, ptr, end))
return NULL;
- if (pool->ptr == pool->end && !poolGrow(pool))
+ if (pool->ptr == pool->end && ! poolGrow(pool))
return NULL;
*(pool->ptr)++ = 0;
return pool->start;
}
static size_t
-poolBytesToAllocateFor(int blockSize)
-{
+poolBytesToAllocateFor(int blockSize) {
/* Unprotected math would be:
** return offsetof(BLOCK, s) + blockSize * sizeof(XML_Char);
**
@@ -6933,7 +6628,7 @@ poolBytesToAllocateFor(int blockSize)
** For a + b * c we check b * c in isolation first, so that addition of a
** on top has no chance of making us accept a small non-negative number
*/
- const size_t stretch = sizeof(XML_Char); /* can be 4 bytes */
+ const size_t stretch = sizeof(XML_Char); /* can be 4 bytes */
if (blockSize <= 0)
return 0;
@@ -6943,8 +6638,8 @@ poolBytesToAllocateFor(int blockSize)
{
const int stretchedBlockSize = blockSize * (int)stretch;
- const int bytesToAllocate = (int)(
- offsetof(BLOCK, s) + (unsigned)stretchedBlockSize);
+ const int bytesToAllocate
+ = (int)(offsetof(BLOCK, s) + (unsigned)stretchedBlockSize);
if (bytesToAllocate < 0)
return 0;
@@ -6953,8 +6648,7 @@ poolBytesToAllocateFor(int blockSize)
}
static XML_Bool FASTCALL
-poolGrow(STRING_POOL *pool)
-{
+poolGrow(STRING_POOL *pool) {
if (pool->freeBlocks) {
if (pool->start == 0) {
pool->blocks = pool->freeBlocks;
@@ -6980,11 +6674,11 @@ poolGrow(STRING_POOL *pool)
}
if (pool->blocks && pool->start == pool->blocks->s) {
BLOCK *temp;
- int blockSize = (int)((unsigned)(pool->end - pool->start)*2U);
+ int blockSize = (int)((unsigned)(pool->end - pool->start) * 2U);
size_t bytesToAllocate;
- // NOTE: Needs to be calculated prior to calling `realloc`
- // to avoid dangling pointers:
+ /* NOTE: Needs to be calculated prior to calling `realloc`
+ to avoid dangling pointers: */
const ptrdiff_t offsetInsideBlock = pool->ptr - pool->start;
if (blockSize < 0) {
@@ -7001,8 +6695,8 @@ poolGrow(STRING_POOL *pool)
if (bytesToAllocate == 0)
return XML_FALSE;
- temp = (BLOCK *)
- pool->mem->realloc_fcn(pool->blocks, (unsigned)bytesToAllocate);
+ temp = (BLOCK *)pool->mem->realloc_fcn(pool->blocks,
+ (unsigned)bytesToAllocate);
if (temp == NULL)
return XML_FALSE;
pool->blocks = temp;
@@ -7010,8 +6704,7 @@ poolGrow(STRING_POOL *pool)
pool->ptr = pool->blocks->s + offsetInsideBlock;
pool->start = pool->blocks->s;
pool->end = pool->start + blockSize;
- }
- else {
+ } else {
BLOCK *tem;
int blockSize = (int)(pool->end - pool->start);
size_t bytesToAllocate;
@@ -7026,7 +6719,7 @@ poolGrow(STRING_POOL *pool)
* function). Either way it isn't readily testable, so we
* exclude it from the coverage statistics.
*/
- return XML_FALSE; /* LCOV_EXCL_LINE */
+ return XML_FALSE; /* LCOV_EXCL_LINE */
}
if (blockSize < INIT_BLOCK_SIZE)
@@ -7044,14 +6737,13 @@ poolGrow(STRING_POOL *pool)
return XML_FALSE;
tem = (BLOCK *)pool->mem->malloc_fcn(bytesToAllocate);
- if (!tem)
+ if (! tem)
return XML_FALSE;
tem->size = blockSize;
tem->next = pool->blocks;
pool->blocks = tem;
if (pool->ptr != pool->start)
- memcpy(tem->s, pool->start,
- (pool->ptr - pool->start) * sizeof(XML_Char));
+ memcpy(tem->s, pool->start, (pool->ptr - pool->start) * sizeof(XML_Char));
pool->ptr = tem->s + (pool->ptr - pool->start);
pool->start = tem->s;
pool->end = tem->s + blockSize;
@@ -7060,15 +6752,14 @@ poolGrow(STRING_POOL *pool)
}
static int FASTCALL
-nextScaffoldPart(XML_Parser parser)
-{
- DTD * const dtd = _dtd; /* save one level of indirection */
- CONTENT_SCAFFOLD * me;
+nextScaffoldPart(XML_Parser parser) {
+ DTD *const dtd = parser->m_dtd; /* save one level of indirection */
+ CONTENT_SCAFFOLD *me;
int next;
- if (!dtd->scaffIndex) {
- dtd->scaffIndex = (int *)MALLOC(groupSize * sizeof(int));
- if (!dtd->scaffIndex)
+ if (! dtd->scaffIndex) {
+ dtd->scaffIndex = (int *)MALLOC(parser, parser->m_groupSize * sizeof(int));
+ if (! dtd->scaffIndex)
return -1;
dtd->scaffIndex[0] = 0;
}
@@ -7076,15 +6767,14 @@ nextScaffoldPart(XML_Parser parser)
if (dtd->scaffCount >= dtd->scaffSize) {
CONTENT_SCAFFOLD *temp;
if (dtd->scaffold) {
- temp = (CONTENT_SCAFFOLD *)
- REALLOC(dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD));
+ temp = (CONTENT_SCAFFOLD *)REALLOC(
+ parser, dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD));
if (temp == NULL)
return -1;
dtd->scaffSize *= 2;
- }
- else {
- temp = (CONTENT_SCAFFOLD *)MALLOC(INIT_SCAFFOLD_ELEMENTS
- * sizeof(CONTENT_SCAFFOLD));
+ } else {
+ temp = (CONTENT_SCAFFOLD *)MALLOC(parser, INIT_SCAFFOLD_ELEMENTS
+ * sizeof(CONTENT_SCAFFOLD));
if (temp == NULL)
return -1;
dtd->scaffSize = INIT_SCAFFOLD_ELEMENTS;
@@ -7094,11 +6784,12 @@ nextScaffoldPart(XML_Parser parser)
next = dtd->scaffCount++;
me = &dtd->scaffold[next];
if (dtd->scaffLevel) {
- CONTENT_SCAFFOLD *parent = &dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel-1]];
+ CONTENT_SCAFFOLD *parent
+ = &dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]];
if (parent->lastchild) {
dtd->scaffold[parent->lastchild].nextsib = next;
}
- if (!parent->childcnt)
+ if (! parent->childcnt)
parent->firstchild = next;
parent->lastchild = next;
parent->childcnt++;
@@ -7108,13 +6799,9 @@ nextScaffoldPart(XML_Parser parser)
}
static void
-build_node(XML_Parser parser,
- int src_node,
- XML_Content *dest,
- XML_Content **contpos,
- XML_Char **strpos)
-{
- DTD * const dtd = _dtd; /* save one level of indirection */
+build_node(XML_Parser parser, int src_node, XML_Content *dest,
+ XML_Content **contpos, XML_Char **strpos) {
+ DTD *const dtd = parser->m_dtd; /* save one level of indirection */
dest->type = dtd->scaffold[src_node].type;
dest->quant = dtd->scaffold[src_node].quant;
if (dest->type == XML_CTYPE_NAME) {
@@ -7123,21 +6810,19 @@ build_node(XML_Parser parser,
src = dtd->scaffold[src_node].name;
for (;;) {
*(*strpos)++ = *src;
- if (!*src)
+ if (! *src)
break;
src++;
}
dest->numchildren = 0;
dest->children = NULL;
- }
- else {
+ } else {
unsigned int i;
int cn;
dest->numchildren = dtd->scaffold[src_node].childcnt;
dest->children = *contpos;
*contpos += dest->numchildren;
- for (i = 0, cn = dtd->scaffold[src_node].firstchild;
- i < dest->numchildren;
+ for (i = 0, cn = dtd->scaffold[src_node].firstchild; i < dest->numchildren;
i++, cn = dtd->scaffold[cn].nextsib) {
build_node(parser, cn, &(dest->children[i]), contpos, strpos);
}
@@ -7146,20 +6831,19 @@ build_node(XML_Parser parser,
}
static XML_Content *
-build_model (XML_Parser parser)
-{
- DTD * const dtd = _dtd; /* save one level of indirection */
+build_model(XML_Parser parser) {
+ DTD *const dtd = parser->m_dtd; /* save one level of indirection */
XML_Content *ret;
XML_Content *cpos;
- XML_Char * str;
+ XML_Char *str;
int allocsize = (dtd->scaffCount * sizeof(XML_Content)
+ (dtd->contentStringLen * sizeof(XML_Char)));
- ret = (XML_Content *)MALLOC(allocsize);
- if (!ret)
+ ret = (XML_Content *)MALLOC(parser, allocsize);
+ if (! ret)
return NULL;
- str = (XML_Char *) (&ret[dtd->scaffCount]);
+ str = (XML_Char *)(&ret[dtd->scaffCount]);
cpos = &ret[1];
build_node(parser, 0, ret, &cpos, &str);
@@ -7167,49 +6851,45 @@ build_model (XML_Parser parser)
}
static ELEMENT_TYPE *
-getElementType(XML_Parser parser,
- const ENCODING *enc,
- const char *ptr,
- const char *end)
-{
- DTD * const dtd = _dtd; /* save one level of indirection */
+getElementType(XML_Parser parser, const ENCODING *enc, const char *ptr,
+ const char *end) {
+ DTD *const dtd = parser->m_dtd; /* save one level of indirection */
const XML_Char *name = poolStoreString(&dtd->pool, enc, ptr, end);
ELEMENT_TYPE *ret;
- if (!name)
+ if (! name)
return NULL;
- ret = (ELEMENT_TYPE *) lookup(parser, &dtd->elementTypes, name, sizeof(ELEMENT_TYPE));
- if (!ret)
+ ret = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, name,
+ sizeof(ELEMENT_TYPE));
+ if (! ret)
return NULL;
if (ret->name != name)
poolDiscard(&dtd->pool);
else {
poolFinish(&dtd->pool);
- if (!setElementTypePrefix(parser, ret))
+ if (! setElementTypePrefix(parser, ret))
return NULL;
}
return ret;
}
static XML_Char *
-copyString(const XML_Char *s,
- const XML_Memory_Handling_Suite *memsuite)
-{
- int charsRequired = 0;
- XML_Char *result;
-
- /* First determine how long the string is */
- while (s[charsRequired] != 0) {
- charsRequired++;
- }
- /* Include the terminator */
+copyString(const XML_Char *s, const XML_Memory_Handling_Suite *memsuite) {
+ int charsRequired = 0;
+ XML_Char *result;
+
+ /* First determine how long the string is */
+ while (s[charsRequired] != 0) {
charsRequired++;
+ }
+ /* Include the terminator */
+ charsRequired++;
- /* Now allocate space for the copy */
- result = memsuite->malloc_fcn(charsRequired * sizeof(XML_Char));
- if (result == NULL)
- return NULL;
- /* Copy the original into place */
- memcpy(result, s, charsRequired * sizeof(XML_Char));
- return result;
+ /* Now allocate space for the copy */
+ result = memsuite->malloc_fcn(charsRequired * sizeof(XML_Char));
+ if (result == NULL)
+ return NULL;
+ /* Copy the original into place */
+ memcpy(result, s, charsRequired * sizeof(XML_Char));
+ return result;
}
diff --git a/Utilities/cmexpat/lib/xmlrole.c b/Utilities/cmexpat/lib/xmlrole.c
index c809ee514..4d3e3e86e 100644
--- a/Utilities/cmexpat/lib/xmlrole.c
+++ b/Utilities/cmexpat/lib/xmlrole.c
@@ -1,15 +1,43 @@
-/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
+/*
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stddef.h>
#ifdef _WIN32
-#include "winconfig.h"
+# include "winconfig.h"
#else
-#ifdef HAVE_EXPAT_CONFIG_H
-#include <expat_config.h>
-#endif
+# ifdef HAVE_EXPAT_CONFIG_H
+# include <expat_config.h>
+# endif
#endif /* ndef _WIN32 */
#include "expat_external.h"
@@ -24,107 +52,88 @@
*/
-static const char KW_ANY[] = {
- ASCII_A, ASCII_N, ASCII_Y, '\0' };
-static const char KW_ATTLIST[] = {
- ASCII_A, ASCII_T, ASCII_T, ASCII_L, ASCII_I, ASCII_S, ASCII_T, '\0' };
-static const char KW_CDATA[] = {
- ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
-static const char KW_DOCTYPE[] = {
- ASCII_D, ASCII_O, ASCII_C, ASCII_T, ASCII_Y, ASCII_P, ASCII_E, '\0' };
-static const char KW_ELEMENT[] = {
- ASCII_E, ASCII_L, ASCII_E, ASCII_M, ASCII_E, ASCII_N, ASCII_T, '\0' };
-static const char KW_EMPTY[] = {
- ASCII_E, ASCII_M, ASCII_P, ASCII_T, ASCII_Y, '\0' };
-static const char KW_ENTITIES[] = {
- ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S,
- '\0' };
-static const char KW_ENTITY[] = {
- ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' };
-static const char KW_FIXED[] = {
- ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\0' };
-static const char KW_ID[] = {
- ASCII_I, ASCII_D, '\0' };
-static const char KW_IDREF[] = {
- ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' };
-static const char KW_IDREFS[] = {
- ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' };
+static const char KW_ANY[] = {ASCII_A, ASCII_N, ASCII_Y, '\0'};
+static const char KW_ATTLIST[]
+ = {ASCII_A, ASCII_T, ASCII_T, ASCII_L, ASCII_I, ASCII_S, ASCII_T, '\0'};
+static const char KW_CDATA[]
+ = {ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0'};
+static const char KW_DOCTYPE[]
+ = {ASCII_D, ASCII_O, ASCII_C, ASCII_T, ASCII_Y, ASCII_P, ASCII_E, '\0'};
+static const char KW_ELEMENT[]
+ = {ASCII_E, ASCII_L, ASCII_E, ASCII_M, ASCII_E, ASCII_N, ASCII_T, '\0'};
+static const char KW_EMPTY[]
+ = {ASCII_E, ASCII_M, ASCII_P, ASCII_T, ASCII_Y, '\0'};
+static const char KW_ENTITIES[] = {ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T,
+ ASCII_I, ASCII_E, ASCII_S, '\0'};
+static const char KW_ENTITY[]
+ = {ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0'};
+static const char KW_FIXED[]
+ = {ASCII_F, ASCII_I, ASCII_X, ASCII_E, ASCII_D, '\0'};
+static const char KW_ID[] = {ASCII_I, ASCII_D, '\0'};
+static const char KW_IDREF[]
+ = {ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0'};
+static const char KW_IDREFS[]
+ = {ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0'};
#ifdef XML_DTD
-static const char KW_IGNORE[] = {
- ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0' };
+static const char KW_IGNORE[]
+ = {ASCII_I, ASCII_G, ASCII_N, ASCII_O, ASCII_R, ASCII_E, '\0'};
#endif
-static const char KW_IMPLIED[] = {
- ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0' };
+static const char KW_IMPLIED[]
+ = {ASCII_I, ASCII_M, ASCII_P, ASCII_L, ASCII_I, ASCII_E, ASCII_D, '\0'};
#ifdef XML_DTD
-static const char KW_INCLUDE[] = {
- ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0' };
+static const char KW_INCLUDE[]
+ = {ASCII_I, ASCII_N, ASCII_C, ASCII_L, ASCII_U, ASCII_D, ASCII_E, '\0'};
#endif
-static const char KW_NDATA[] = {
- ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
-static const char KW_NMTOKEN[] = {
- ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' };
-static const char KW_NMTOKENS[] = {
- ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S,
- '\0' };
-static const char KW_NOTATION[] =
- { ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N,
- '\0' };
-static const char KW_PCDATA[] = {
- ASCII_P, ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' };
-static const char KW_PUBLIC[] = {
- ASCII_P, ASCII_U, ASCII_B, ASCII_L, ASCII_I, ASCII_C, '\0' };
-static const char KW_REQUIRED[] = {
- ASCII_R, ASCII_E, ASCII_Q, ASCII_U, ASCII_I, ASCII_R, ASCII_E, ASCII_D,
- '\0' };
-static const char KW_SYSTEM[] = {
- ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, ASCII_M, '\0' };
+static const char KW_NDATA[]
+ = {ASCII_N, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0'};
+static const char KW_NMTOKEN[]
+ = {ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0'};
+static const char KW_NMTOKENS[] = {ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K,
+ ASCII_E, ASCII_N, ASCII_S, '\0'};
+static const char KW_NOTATION[] = {ASCII_N, ASCII_O, ASCII_T, ASCII_A, ASCII_T,
+ ASCII_I, ASCII_O, ASCII_N, '\0'};
+static const char KW_PCDATA[]
+ = {ASCII_P, ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0'};
+static const char KW_PUBLIC[]
+ = {ASCII_P, ASCII_U, ASCII_B, ASCII_L, ASCII_I, ASCII_C, '\0'};
+static const char KW_REQUIRED[] = {ASCII_R, ASCII_E, ASCII_Q, ASCII_U, ASCII_I,
+ ASCII_R, ASCII_E, ASCII_D, '\0'};
+static const char KW_SYSTEM[]
+ = {ASCII_S, ASCII_Y, ASCII_S, ASCII_T, ASCII_E, ASCII_M, '\0'};
#ifndef MIN_BYTES_PER_CHAR
-#define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar)
+# define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar)
#endif
#ifdef XML_DTD
-#define setTopLevel(state) \
- ((state)->handler = ((state)->documentEntity \
- ? internalSubset \
- : externalSubset1))
+# define setTopLevel(state) \
+ ((state)->handler \
+ = ((state)->documentEntity ? internalSubset : externalSubset1))
#else /* not XML_DTD */
-#define setTopLevel(state) ((state)->handler = internalSubset)
+# define setTopLevel(state) ((state)->handler = internalSubset)
#endif /* not XML_DTD */
-typedef int PTRCALL PROLOG_HANDLER(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
+typedef int PTRCALL PROLOG_HANDLER(PROLOG_STATE *state, int tok,
+ const char *ptr, const char *end,
const ENCODING *enc);
-static PROLOG_HANDLER
- prolog0, prolog1, prolog2,
- doctype0, doctype1, doctype2, doctype3, doctype4, doctype5,
- internalSubset,
- entity0, entity1, entity2, entity3, entity4, entity5, entity6,
- entity7, entity8, entity9, entity10,
- notation0, notation1, notation2, notation3, notation4,
- attlist0, attlist1, attlist2, attlist3, attlist4, attlist5, attlist6,
- attlist7, attlist8, attlist9,
- element0, element1, element2, element3, element4, element5, element6,
- element7,
+static PROLOG_HANDLER prolog0, prolog1, prolog2, doctype0, doctype1, doctype2,
+ doctype3, doctype4, doctype5, internalSubset, entity0, entity1, entity2,
+ entity3, entity4, entity5, entity6, entity7, entity8, entity9, entity10,
+ notation0, notation1, notation2, notation3, notation4, attlist0, attlist1,
+ attlist2, attlist3, attlist4, attlist5, attlist6, attlist7, attlist8,
+ attlist9, element0, element1, element2, element3, element4, element5,
+ element6, element7,
#ifdef XML_DTD
- externalSubset0, externalSubset1,
- condSect0, condSect1, condSect2,
+ externalSubset0, externalSubset1, condSect0, condSect1, condSect2,
#endif /* XML_DTD */
- declClose,
- error;
+ declClose, error;
static int FASTCALL common(PROLOG_STATE *state, int tok);
static int PTRCALL
-prolog0(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+prolog0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_PROLOG_S:
state->handler = prolog1;
@@ -141,10 +150,8 @@ prolog0(PROLOG_STATE *state,
case XML_TOK_BOM:
return XML_ROLE_NONE;
case XML_TOK_DECL_OPEN:
- if (!XmlNameMatchesAscii(enc,
- ptr + 2 * MIN_BYTES_PER_CHAR(enc),
- end,
- KW_DOCTYPE))
+ if (! XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end,
+ KW_DOCTYPE))
break;
state->handler = doctype0;
return XML_ROLE_DOCTYPE_NONE;
@@ -156,12 +163,8 @@ prolog0(PROLOG_STATE *state,
}
static int PTRCALL
-prolog1(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+prolog1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
@@ -179,10 +182,8 @@ prolog1(PROLOG_STATE *state,
*/
return XML_ROLE_NONE; /* LCOV_EXCL_LINE */
case XML_TOK_DECL_OPEN:
- if (!XmlNameMatchesAscii(enc,
- ptr + 2 * MIN_BYTES_PER_CHAR(enc),
- end,
- KW_DOCTYPE))
+ if (! XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end,
+ KW_DOCTYPE))
break;
state->handler = doctype0;
return XML_ROLE_DOCTYPE_NONE;
@@ -194,12 +195,11 @@ prolog1(PROLOG_STATE *state,
}
static int PTRCALL
-prolog2(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+prolog2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
@@ -215,12 +215,11 @@ prolog2(PROLOG_STATE *state,
}
static int PTRCALL
-doctype0(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+doctype0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_DOCTYPE_NONE;
@@ -233,12 +232,8 @@ doctype0(PROLOG_STATE *state,
}
static int PTRCALL
-doctype1(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+doctype1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_DOCTYPE_NONE;
@@ -263,12 +258,11 @@ doctype1(PROLOG_STATE *state,
}
static int PTRCALL
-doctype2(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+doctype2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_DOCTYPE_NONE;
@@ -280,12 +274,11 @@ doctype2(PROLOG_STATE *state,
}
static int PTRCALL
-doctype3(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+doctype3(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_DOCTYPE_NONE;
@@ -297,12 +290,11 @@ doctype3(PROLOG_STATE *state,
}
static int PTRCALL
-doctype4(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+doctype4(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_DOCTYPE_NONE;
@@ -317,12 +309,11 @@ doctype4(PROLOG_STATE *state,
}
static int PTRCALL
-doctype5(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+doctype5(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_DOCTYPE_NONE;
@@ -334,40 +325,28 @@ doctype5(PROLOG_STATE *state,
}
static int PTRCALL
-internalSubset(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+internalSubset(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
case XML_TOK_DECL_OPEN:
- if (XmlNameMatchesAscii(enc,
- ptr + 2 * MIN_BYTES_PER_CHAR(enc),
- end,
+ if (XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end,
KW_ENTITY)) {
state->handler = entity0;
return XML_ROLE_ENTITY_NONE;
}
- if (XmlNameMatchesAscii(enc,
- ptr + 2 * MIN_BYTES_PER_CHAR(enc),
- end,
+ if (XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end,
KW_ATTLIST)) {
state->handler = attlist0;
return XML_ROLE_ATTLIST_NONE;
}
- if (XmlNameMatchesAscii(enc,
- ptr + 2 * MIN_BYTES_PER_CHAR(enc),
- end,
+ if (XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end,
KW_ELEMENT)) {
state->handler = element0;
return XML_ROLE_ELEMENT_NONE;
}
- if (XmlNameMatchesAscii(enc,
- ptr + 2 * MIN_BYTES_PER_CHAR(enc),
- end,
+ if (XmlNameMatchesAscii(enc, ptr + 2 * MIN_BYTES_PER_CHAR(enc), end,
KW_NOTATION)) {
state->handler = notation0;
return XML_ROLE_NOTATION_NONE;
@@ -391,12 +370,8 @@ internalSubset(PROLOG_STATE *state,
#ifdef XML_DTD
static int PTRCALL
-externalSubset0(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+externalSubset0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
state->handler = externalSubset1;
if (tok == XML_TOK_XML_DECL)
return XML_ROLE_TEXT_DECL;
@@ -404,12 +379,8 @@ externalSubset0(PROLOG_STATE *state,
}
static int PTRCALL
-externalSubset1(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+externalSubset1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_COND_SECT_OPEN:
state->handler = condSect0;
@@ -436,12 +407,11 @@ externalSubset1(PROLOG_STATE *state,
#endif /* XML_DTD */
static int PTRCALL
-entity0(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+entity0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ENTITY_NONE;
@@ -456,12 +426,11 @@ entity0(PROLOG_STATE *state,
}
static int PTRCALL
-entity1(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+entity1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ENTITY_NONE;
@@ -473,12 +442,8 @@ entity1(PROLOG_STATE *state,
}
static int PTRCALL
-entity2(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+entity2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ENTITY_NONE;
@@ -501,12 +466,11 @@ entity2(PROLOG_STATE *state,
}
static int PTRCALL
-entity3(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+entity3(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ENTITY_NONE;
@@ -518,12 +482,11 @@ entity3(PROLOG_STATE *state,
}
static int PTRCALL
-entity4(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+entity4(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ENTITY_NONE;
@@ -535,12 +498,8 @@ entity4(PROLOG_STATE *state,
}
static int PTRCALL
-entity5(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+entity5(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ENTITY_NONE;
@@ -558,12 +517,11 @@ entity5(PROLOG_STATE *state,
}
static int PTRCALL
-entity6(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+entity6(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ENTITY_NONE;
@@ -576,12 +534,8 @@ entity6(PROLOG_STATE *state,
}
static int PTRCALL
-entity7(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+entity7(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ENTITY_NONE;
@@ -604,12 +558,11 @@ entity7(PROLOG_STATE *state,
}
static int PTRCALL
-entity8(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+entity8(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ENTITY_NONE;
@@ -621,12 +574,11 @@ entity8(PROLOG_STATE *state,
}
static int PTRCALL
-entity9(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+entity9(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ENTITY_NONE;
@@ -638,12 +590,11 @@ entity9(PROLOG_STATE *state,
}
static int PTRCALL
-entity10(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+entity10(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ENTITY_NONE;
@@ -655,12 +606,11 @@ entity10(PROLOG_STATE *state,
}
static int PTRCALL
-notation0(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+notation0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NOTATION_NONE;
@@ -672,12 +622,8 @@ notation0(PROLOG_STATE *state,
}
static int PTRCALL
-notation1(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+notation1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NOTATION_NONE;
@@ -696,12 +642,11 @@ notation1(PROLOG_STATE *state,
}
static int PTRCALL
-notation2(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+notation2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NOTATION_NONE;
@@ -713,12 +658,11 @@ notation2(PROLOG_STATE *state,
}
static int PTRCALL
-notation3(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+notation3(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NOTATION_NONE;
@@ -731,12 +675,11 @@ notation3(PROLOG_STATE *state,
}
static int PTRCALL
-notation4(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+notation4(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NOTATION_NONE;
@@ -752,12 +695,11 @@ notation4(PROLOG_STATE *state,
}
static int PTRCALL
-attlist0(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+attlist0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ATTLIST_NONE;
@@ -770,12 +712,11 @@ attlist0(PROLOG_STATE *state,
}
static int PTRCALL
-attlist1(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+attlist1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ATTLIST_NONE;
@@ -791,34 +732,23 @@ attlist1(PROLOG_STATE *state,
}
static int PTRCALL
-attlist2(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+attlist2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ATTLIST_NONE;
- case XML_TOK_NAME:
- {
- static const char * const types[] = {
- KW_CDATA,
- KW_ID,
- KW_IDREF,
- KW_IDREFS,
- KW_ENTITY,
- KW_ENTITIES,
- KW_NMTOKEN,
- KW_NMTOKENS,
- };
- int i;
- for (i = 0; i < (int)(sizeof(types)/sizeof(types[0])); i++)
- if (XmlNameMatchesAscii(enc, ptr, end, types[i])) {
- state->handler = attlist8;
- return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i;
- }
- }
+ case XML_TOK_NAME: {
+ static const char *const types[] = {
+ KW_CDATA, KW_ID, KW_IDREF, KW_IDREFS,
+ KW_ENTITY, KW_ENTITIES, KW_NMTOKEN, KW_NMTOKENS,
+ };
+ int i;
+ for (i = 0; i < (int)(sizeof(types) / sizeof(types[0])); i++)
+ if (XmlNameMatchesAscii(enc, ptr, end, types[i])) {
+ state->handler = attlist8;
+ return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i;
+ }
+ }
if (XmlNameMatchesAscii(enc, ptr, end, KW_NOTATION)) {
state->handler = attlist5;
return XML_ROLE_ATTLIST_NONE;
@@ -832,12 +762,11 @@ attlist2(PROLOG_STATE *state,
}
static int PTRCALL
-attlist3(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+attlist3(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ATTLIST_NONE;
@@ -851,12 +780,11 @@ attlist3(PROLOG_STATE *state,
}
static int PTRCALL
-attlist4(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+attlist4(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ATTLIST_NONE;
@@ -871,12 +799,11 @@ attlist4(PROLOG_STATE *state,
}
static int PTRCALL
-attlist5(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+attlist5(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ATTLIST_NONE;
@@ -888,12 +815,11 @@ attlist5(PROLOG_STATE *state,
}
static int PTRCALL
-attlist6(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+attlist6(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ATTLIST_NONE;
@@ -905,12 +831,11 @@ attlist6(PROLOG_STATE *state,
}
static int PTRCALL
-attlist7(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+attlist7(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ATTLIST_NONE;
@@ -926,33 +851,23 @@ attlist7(PROLOG_STATE *state,
/* default value */
static int PTRCALL
-attlist8(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+attlist8(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ATTLIST_NONE;
case XML_TOK_POUND_NAME:
- if (XmlNameMatchesAscii(enc,
- ptr + MIN_BYTES_PER_CHAR(enc),
- end,
+ if (XmlNameMatchesAscii(enc, ptr + MIN_BYTES_PER_CHAR(enc), end,
KW_IMPLIED)) {
state->handler = attlist1;
return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE;
}
- if (XmlNameMatchesAscii(enc,
- ptr + MIN_BYTES_PER_CHAR(enc),
- end,
+ if (XmlNameMatchesAscii(enc, ptr + MIN_BYTES_PER_CHAR(enc), end,
KW_REQUIRED)) {
state->handler = attlist1;
return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE;
}
- if (XmlNameMatchesAscii(enc,
- ptr + MIN_BYTES_PER_CHAR(enc),
- end,
+ if (XmlNameMatchesAscii(enc, ptr + MIN_BYTES_PER_CHAR(enc), end,
KW_FIXED)) {
state->handler = attlist9;
return XML_ROLE_ATTLIST_NONE;
@@ -966,12 +881,11 @@ attlist8(PROLOG_STATE *state,
}
static int PTRCALL
-attlist9(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+attlist9(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ATTLIST_NONE;
@@ -983,12 +897,11 @@ attlist9(PROLOG_STATE *state,
}
static int PTRCALL
-element0(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+element0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ELEMENT_NONE;
@@ -1001,12 +914,8 @@ element0(PROLOG_STATE *state,
}
static int PTRCALL
-element1(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+element1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ELEMENT_NONE;
@@ -1031,19 +940,13 @@ element1(PROLOG_STATE *state,
}
static int PTRCALL
-element2(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+element2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ELEMENT_NONE;
case XML_TOK_POUND_NAME:
- if (XmlNameMatchesAscii(enc,
- ptr + MIN_BYTES_PER_CHAR(enc),
- end,
+ if (XmlNameMatchesAscii(enc, ptr + MIN_BYTES_PER_CHAR(enc), end,
KW_PCDATA)) {
state->handler = element3;
return XML_ROLE_CONTENT_PCDATA;
@@ -1071,12 +974,11 @@ element2(PROLOG_STATE *state,
}
static int PTRCALL
-element3(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+element3(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ELEMENT_NONE;
@@ -1096,12 +998,11 @@ element3(PROLOG_STATE *state,
}
static int PTRCALL
-element4(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+element4(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ELEMENT_NONE;
@@ -1114,12 +1015,11 @@ element4(PROLOG_STATE *state,
}
static int PTRCALL
-element5(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+element5(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ELEMENT_NONE;
@@ -1135,12 +1035,11 @@ element5(PROLOG_STATE *state,
}
static int PTRCALL
-element6(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+element6(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ELEMENT_NONE;
@@ -1165,12 +1064,11 @@ element6(PROLOG_STATE *state,
}
static int PTRCALL
-element7(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+element7(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_ELEMENT_NONE;
@@ -1215,12 +1113,8 @@ element7(PROLOG_STATE *state,
#ifdef XML_DTD
static int PTRCALL
-condSect0(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
+condSect0(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
@@ -1239,12 +1133,11 @@ condSect0(PROLOG_STATE *state,
}
static int PTRCALL
-condSect1(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+condSect1(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
@@ -1257,12 +1150,11 @@ condSect1(PROLOG_STATE *state,
}
static int PTRCALL
-condSect2(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+condSect2(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return XML_ROLE_NONE;
@@ -1276,12 +1168,11 @@ condSect2(PROLOG_STATE *state,
#endif /* XML_DTD */
static int PTRCALL
-declClose(PROLOG_STATE *state,
- int tok,
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+declClose(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
switch (tok) {
case XML_TOK_PROLOG_S:
return state->role_none;
@@ -1313,21 +1204,21 @@ declClose(PROLOG_STATE *state,
* LCOV_EXCL_START
*/
static int PTRCALL
-error(PROLOG_STATE *UNUSED_P(state),
- int UNUSED_P(tok),
- const char *UNUSED_P(ptr),
- const char *UNUSED_P(end),
- const ENCODING *UNUSED_P(enc))
-{
+error(PROLOG_STATE *state, int tok, const char *ptr, const char *end,
+ const ENCODING *enc) {
+ UNUSED_P(state);
+ UNUSED_P(tok);
+ UNUSED_P(ptr);
+ UNUSED_P(end);
+ UNUSED_P(enc);
return XML_ROLE_NONE;
}
/* LCOV_EXCL_STOP */
static int FASTCALL
-common(PROLOG_STATE *state, int tok)
-{
+common(PROLOG_STATE *state, int tok) {
#ifdef XML_DTD
- if (!state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF)
+ if (! state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF)
return XML_ROLE_INNER_PARAM_ENTITY_REF;
#endif
state->handler = error;
@@ -1335,8 +1226,7 @@ common(PROLOG_STATE *state, int tok)
}
void
-XmlPrologStateInit(PROLOG_STATE *state)
-{
+XmlPrologStateInit(PROLOG_STATE *state) {
state->handler = prolog0;
#ifdef XML_DTD
state->documentEntity = 1;
@@ -1348,8 +1238,7 @@ XmlPrologStateInit(PROLOG_STATE *state)
#ifdef XML_DTD
void
-XmlPrologStateInitExternalEntity(PROLOG_STATE *state)
-{
+XmlPrologStateInitExternalEntity(PROLOG_STATE *state) {
state->handler = externalSubset0;
state->documentEntity = 0;
state->includeLevel = 0;
diff --git a/Utilities/cmexpat/lib/xmlrole.h b/Utilities/cmexpat/lib/xmlrole.h
index 4dd9f06f9..036aba64f 100644
--- a/Utilities/cmexpat/lib/xmlrole.h
+++ b/Utilities/cmexpat/lib/xmlrole.h
@@ -1,5 +1,33 @@
-/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
+/*
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef XmlRole_INCLUDED
@@ -8,7 +36,7 @@
#ifdef __VMS
/* 0 1 2 3 0 1 2 3
1234567890123456789012345678901 1234567890123456789012345678901 */
-#define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt
+# define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt
#endif
#include "xmltok.h"
@@ -85,11 +113,8 @@ enum {
};
typedef struct prolog_state {
- int (PTRCALL *handler) (struct prolog_state *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc);
+ int(PTRCALL *handler)(struct prolog_state *state, int tok, const char *ptr,
+ const char *end, const ENCODING *enc);
unsigned level;
int role_none;
#ifdef XML_DTD
@@ -104,8 +129,8 @@ void XmlPrologStateInit(PROLOG_STATE *);
void XmlPrologStateInitExternalEntity(PROLOG_STATE *);
#endif /* XML_DTD */
-#define XmlTokenRole(state, tok, ptr, end, enc) \
- (((state)->handler)(state, tok, ptr, end, enc))
+#define XmlTokenRole(state, tok, ptr, end, enc) \
+ (((state)->handler)(state, tok, ptr, end, enc))
#ifdef __cplusplus
}
diff --git a/Utilities/cmexpat/lib/xmltok.c b/Utilities/cmexpat/lib/xmltok.c
index db4a5c8ca..11e9d1ccd 100644
--- a/Utilities/cmexpat/lib/xmltok.c
+++ b/Utilities/cmexpat/lib/xmltok.c
@@ -1,15 +1,53 @@
-/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
+/*
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stddef.h>
+#include <string.h> /* memcpy */
-#ifdef _WIN32
-#include "winconfig.h"
+#if defined(_MSC_VER) && (_MSC_VER <= 1700)
+/* for vs2012/11.0/1700 and earlier Visual Studio compilers */
+# define bool int
+# define false 0
+# define true 1
#else
-#ifdef HAVE_EXPAT_CONFIG_H
-#include <expat_config.h>
+# include <stdbool.h>
#endif
+
+#ifdef _WIN32
+# include "winconfig.h"
+#else
+# ifdef HAVE_EXPAT_CONFIG_H
+# include <expat_config.h>
+# endif
#endif /* ndef _WIN32 */
#include "expat_external.h"
@@ -18,59 +56,49 @@
#include "nametab.h"
#ifdef XML_DTD
-#define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok)
+# define IGNORE_SECTION_TOK_VTABLE , PREFIX(ignoreSectionTok)
#else
-#define IGNORE_SECTION_TOK_VTABLE /* as nothing */
+# define IGNORE_SECTION_TOK_VTABLE /* as nothing */
#endif
-#define VTABLE1 \
- { PREFIX(prologTok), PREFIX(contentTok), \
- PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \
- { PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \
- PREFIX(sameName), \
- PREFIX(nameMatchesAscii), \
- PREFIX(nameLength), \
- PREFIX(skipS), \
- PREFIX(getAtts), \
- PREFIX(charRefNumber), \
- PREFIX(predefinedEntityName), \
- PREFIX(updatePosition), \
- PREFIX(isPublicId)
+#define VTABLE1 \
+ {PREFIX(prologTok), PREFIX(contentTok), \
+ PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE}, \
+ {PREFIX(attributeValueTok), PREFIX(entityValueTok)}, \
+ PREFIX(nameMatchesAscii), PREFIX(nameLength), PREFIX(skipS), \
+ PREFIX(getAtts), PREFIX(charRefNumber), PREFIX(predefinedEntityName), \
+ PREFIX(updatePosition), PREFIX(isPublicId)
#define VTABLE VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16)
-#define UCS2_GET_NAMING(pages, hi, lo) \
- (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1u << ((lo) & 0x1F)))
+#define UCS2_GET_NAMING(pages, hi, lo) \
+ (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1u << ((lo)&0x1F)))
/* A 2 byte UTF-8 representation splits the characters 11 bits between
the bottom 5 and 6 bits of the bytes. We need 8 bits to index into
pages, 3 bits to add to that index and 5 bits to generate the mask.
*/
-#define UTF8_GET_NAMING2(pages, byte) \
- (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \
- + ((((byte)[0]) & 3) << 1) \
- + ((((byte)[1]) >> 5) & 1)] \
- & (1u << (((byte)[1]) & 0x1F)))
+#define UTF8_GET_NAMING2(pages, byte) \
+ (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \
+ + ((((byte)[0]) & 3) << 1) + ((((byte)[1]) >> 5) & 1)] \
+ & (1u << (((byte)[1]) & 0x1F)))
/* A 3 byte UTF-8 representation splits the characters 16 bits between
the bottom 4, 6 and 6 bits of the bytes. We need 8 bits to index
into pages, 3 bits to add to that index and 5 bits to generate the
mask.
*/
-#define UTF8_GET_NAMING3(pages, byte) \
- (namingBitmap[((pages)[((((byte)[0]) & 0xF) << 4) \
- + ((((byte)[1]) >> 2) & 0xF)] \
- << 3) \
- + ((((byte)[1]) & 3) << 1) \
- + ((((byte)[2]) >> 5) & 1)] \
- & (1u << (((byte)[2]) & 0x1F)))
-
-#define UTF8_GET_NAMING(pages, p, n) \
- ((n) == 2 \
- ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \
- : ((n) == 3 \
- ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \
- : 0))
+#define UTF8_GET_NAMING3(pages, byte) \
+ (namingBitmap \
+ [((pages)[((((byte)[0]) & 0xF) << 4) + ((((byte)[1]) >> 2) & 0xF)] \
+ << 3) \
+ + ((((byte)[1]) & 3) << 1) + ((((byte)[2]) >> 5) & 1)] \
+ & (1u << (((byte)[2]) & 0x1F)))
+
+#define UTF8_GET_NAMING(pages, p, n) \
+ ((n) == 2 \
+ ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \
+ : ((n) == 3 ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) : 0))
/* Detection of invalid UTF-8 sequences is based on Table 3.1B
of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/
@@ -82,88 +110,76 @@
(A & 0xC0) == 0xC0 means A > 0xBF
*/
-#define UTF8_INVALID2(p) \
+#define UTF8_INVALID2(p) \
((*p) < 0xC2 || ((p)[1] & 0x80) == 0 || ((p)[1] & 0xC0) == 0xC0)
-#define UTF8_INVALID3(p) \
- (((p)[2] & 0x80) == 0 \
- || \
- ((*p) == 0xEF && (p)[1] == 0xBF \
- ? \
- (p)[2] > 0xBD \
- : \
- ((p)[2] & 0xC0) == 0xC0) \
- || \
- ((*p) == 0xE0 \
- ? \
- (p)[1] < 0xA0 || ((p)[1] & 0xC0) == 0xC0 \
- : \
- ((p)[1] & 0x80) == 0 \
- || \
- ((*p) == 0xED ? (p)[1] > 0x9F : ((p)[1] & 0xC0) == 0xC0)))
-
-#define UTF8_INVALID4(p) \
- (((p)[3] & 0x80) == 0 || ((p)[3] & 0xC0) == 0xC0 \
- || \
- ((p)[2] & 0x80) == 0 || ((p)[2] & 0xC0) == 0xC0 \
- || \
- ((*p) == 0xF0 \
- ? \
- (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \
- : \
- ((p)[1] & 0x80) == 0 \
- || \
- ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0)))
+#define UTF8_INVALID3(p) \
+ (((p)[2] & 0x80) == 0 \
+ || ((*p) == 0xEF && (p)[1] == 0xBF ? (p)[2] > 0xBD \
+ : ((p)[2] & 0xC0) == 0xC0) \
+ || ((*p) == 0xE0 \
+ ? (p)[1] < 0xA0 || ((p)[1] & 0xC0) == 0xC0 \
+ : ((p)[1] & 0x80) == 0 \
+ || ((*p) == 0xED ? (p)[1] > 0x9F : ((p)[1] & 0xC0) == 0xC0)))
+
+#define UTF8_INVALID4(p) \
+ (((p)[3] & 0x80) == 0 || ((p)[3] & 0xC0) == 0xC0 || ((p)[2] & 0x80) == 0 \
+ || ((p)[2] & 0xC0) == 0xC0 \
+ || ((*p) == 0xF0 \
+ ? (p)[1] < 0x90 || ((p)[1] & 0xC0) == 0xC0 \
+ : ((p)[1] & 0x80) == 0 \
+ || ((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0)))
static int PTRFASTCALL
-isNever(const ENCODING *UNUSED_P(enc), const char *UNUSED_P(p))
-{
+isNever(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
+ UNUSED_P(p);
return 0;
}
static int PTRFASTCALL
-utf8_isName2(const ENCODING *UNUSED_P(enc), const char *p)
-{
+utf8_isName2(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
return UTF8_GET_NAMING2(namePages, (const unsigned char *)p);
}
static int PTRFASTCALL
-utf8_isName3(const ENCODING *UNUSED_P(enc), const char *p)
-{
+utf8_isName3(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
return UTF8_GET_NAMING3(namePages, (const unsigned char *)p);
}
#define utf8_isName4 isNever
static int PTRFASTCALL
-utf8_isNmstrt2(const ENCODING *UNUSED_P(enc), const char *p)
-{
+utf8_isNmstrt2(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p);
}
static int PTRFASTCALL
-utf8_isNmstrt3(const ENCODING *UNUSED_P(enc), const char *p)
-{
+utf8_isNmstrt3(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p);
}
#define utf8_isNmstrt4 isNever
static int PTRFASTCALL
-utf8_isInvalid2(const ENCODING *UNUSED_P(enc), const char *p)
-{
+utf8_isInvalid2(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
return UTF8_INVALID2((const unsigned char *)p);
}
static int PTRFASTCALL
-utf8_isInvalid3(const ENCODING *UNUSED_P(enc), const char *p)
-{
+utf8_isInvalid3(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
return UTF8_INVALID3((const unsigned char *)p);
}
static int PTRFASTCALL
-utf8_isInvalid4(const ENCODING *UNUSED_P(enc), const char *p)
-{
+utf8_isInvalid4(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
return UTF8_INVALID4((const unsigned char *)p);
}
@@ -171,61 +187,44 @@ struct normal_encoding {
ENCODING enc;
unsigned char type[256];
#ifdef XML_MIN_SIZE
- int (PTRFASTCALL *byteType)(const ENCODING *, const char *);
- int (PTRFASTCALL *isNameMin)(const ENCODING *, const char *);
- int (PTRFASTCALL *isNmstrtMin)(const ENCODING *, const char *);
- int (PTRFASTCALL *byteToAscii)(const ENCODING *, const char *);
- int (PTRCALL *charMatches)(const ENCODING *, const char *, int);
+ int(PTRFASTCALL *byteType)(const ENCODING *, const char *);
+ int(PTRFASTCALL *isNameMin)(const ENCODING *, const char *);
+ int(PTRFASTCALL *isNmstrtMin)(const ENCODING *, const char *);
+ int(PTRFASTCALL *byteToAscii)(const ENCODING *, const char *);
+ int(PTRCALL *charMatches)(const ENCODING *, const char *, int);
#endif /* XML_MIN_SIZE */
- int (PTRFASTCALL *isName2)(const ENCODING *, const char *);
- int (PTRFASTCALL *isName3)(const ENCODING *, const char *);
- int (PTRFASTCALL *isName4)(const ENCODING *, const char *);
- int (PTRFASTCALL *isNmstrt2)(const ENCODING *, const char *);
- int (PTRFASTCALL *isNmstrt3)(const ENCODING *, const char *);
- int (PTRFASTCALL *isNmstrt4)(const ENCODING *, const char *);
- int (PTRFASTCALL *isInvalid2)(const ENCODING *, const char *);
- int (PTRFASTCALL *isInvalid3)(const ENCODING *, const char *);
- int (PTRFASTCALL *isInvalid4)(const ENCODING *, const char *);
+ int(PTRFASTCALL *isName2)(const ENCODING *, const char *);
+ int(PTRFASTCALL *isName3)(const ENCODING *, const char *);
+ int(PTRFASTCALL *isName4)(const ENCODING *, const char *);
+ int(PTRFASTCALL *isNmstrt2)(const ENCODING *, const char *);
+ int(PTRFASTCALL *isNmstrt3)(const ENCODING *, const char *);
+ int(PTRFASTCALL *isNmstrt4)(const ENCODING *, const char *);
+ int(PTRFASTCALL *isInvalid2)(const ENCODING *, const char *);
+ int(PTRFASTCALL *isInvalid3)(const ENCODING *, const char *);
+ int(PTRFASTCALL *isInvalid4)(const ENCODING *, const char *);
};
-#define AS_NORMAL_ENCODING(enc) ((const struct normal_encoding *) (enc))
+#define AS_NORMAL_ENCODING(enc) ((const struct normal_encoding *)(enc))
#ifdef XML_MIN_SIZE
-#define STANDARD_VTABLE(E) \
- E ## byteType, \
- E ## isNameMin, \
- E ## isNmstrtMin, \
- E ## byteToAscii, \
- E ## charMatches,
+# define STANDARD_VTABLE(E) \
+ E##byteType, E##isNameMin, E##isNmstrtMin, E##byteToAscii, E##charMatches,
#else
-#define STANDARD_VTABLE(E) /* as nothing */
+# define STANDARD_VTABLE(E) /* as nothing */
#endif
-#define NORMAL_VTABLE(E) \
- E ## isName2, \
- E ## isName3, \
- E ## isName4, \
- E ## isNmstrt2, \
- E ## isNmstrt3, \
- E ## isNmstrt4, \
- E ## isInvalid2, \
- E ## isInvalid3, \
- E ## isInvalid4
-
-#define NULL_VTABLE \
- /* isName2 */ NULL, \
- /* isName3 */ NULL, \
- /* isName4 */ NULL, \
- /* isNmstrt2 */ NULL, \
- /* isNmstrt3 */ NULL, \
- /* isNmstrt4 */ NULL, \
- /* isInvalid2 */ NULL, \
- /* isInvalid3 */ NULL, \
- /* isInvalid4 */ NULL
+#define NORMAL_VTABLE(E) \
+ E##isName2, E##isName3, E##isName4, E##isNmstrt2, E##isNmstrt3, \
+ E##isNmstrt4, E##isInvalid2, E##isInvalid3, E##isInvalid4
+
+#define NULL_VTABLE \
+ /* isName2 */ NULL, /* isName3 */ NULL, /* isName4 */ NULL, \
+ /* isNmstrt2 */ NULL, /* isNmstrt3 */ NULL, /* isNmstrt4 */ NULL, \
+ /* isInvalid2 */ NULL, /* isInvalid3 */ NULL, /* isInvalid4 */ NULL
static int FASTCALL checkCharRefNumber(int);
@@ -233,75 +232,70 @@ static int FASTCALL checkCharRefNumber(int);
#include "ascii.h"
#ifdef XML_MIN_SIZE
-#define sb_isNameMin isNever
-#define sb_isNmstrtMin isNever
+# define sb_isNameMin isNever
+# define sb_isNmstrtMin isNever
#endif
#ifdef XML_MIN_SIZE
-#define MINBPC(enc) ((enc)->minBytesPerChar)
+# define MINBPC(enc) ((enc)->minBytesPerChar)
#else
/* minimum bytes per character */
-#define MINBPC(enc) 1
+# define MINBPC(enc) 1
#endif
-#define SB_BYTE_TYPE(enc, p) \
+#define SB_BYTE_TYPE(enc, p) \
(((struct normal_encoding *)(enc))->type[(unsigned char)*(p)])
#ifdef XML_MIN_SIZE
static int PTRFASTCALL
-sb_byteType(const ENCODING *enc, const char *p)
-{
+sb_byteType(const ENCODING *enc, const char *p) {
return SB_BYTE_TYPE(enc, p);
}
-#define BYTE_TYPE(enc, p) \
- (AS_NORMAL_ENCODING(enc)->byteType(enc, p))
+# define BYTE_TYPE(enc, p) (AS_NORMAL_ENCODING(enc)->byteType(enc, p))
#else
-#define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p)
+# define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p)
#endif
#ifdef XML_MIN_SIZE
-#define BYTE_TO_ASCII(enc, p) \
- (AS_NORMAL_ENCODING(enc)->byteToAscii(enc, p))
+# define BYTE_TO_ASCII(enc, p) (AS_NORMAL_ENCODING(enc)->byteToAscii(enc, p))
static int PTRFASTCALL
-sb_byteToAscii(const ENCODING *enc, const char *p)
-{
+sb_byteToAscii(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
return *p;
}
#else
-#define BYTE_TO_ASCII(enc, p) (*(p))
+# define BYTE_TO_ASCII(enc, p) (*(p))
#endif
-#define IS_NAME_CHAR(enc, p, n) \
- (AS_NORMAL_ENCODING(enc)->isName ## n(enc, p))
-#define IS_NMSTRT_CHAR(enc, p, n) \
- (AS_NORMAL_ENCODING(enc)->isNmstrt ## n(enc, p))
-#define IS_INVALID_CHAR(enc, p, n) \
- (AS_NORMAL_ENCODING(enc)->isInvalid ## n(enc, p))
+#define IS_NAME_CHAR(enc, p, n) (AS_NORMAL_ENCODING(enc)->isName##n(enc, p))
+#define IS_NMSTRT_CHAR(enc, p, n) (AS_NORMAL_ENCODING(enc)->isNmstrt##n(enc, p))
+#define IS_INVALID_CHAR(enc, p, n) \
+ (AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))
#ifdef XML_MIN_SIZE
-#define IS_NAME_CHAR_MINBPC(enc, p) \
- (AS_NORMAL_ENCODING(enc)->isNameMin(enc, p))
-#define IS_NMSTRT_CHAR_MINBPC(enc, p) \
- (AS_NORMAL_ENCODING(enc)->isNmstrtMin(enc, p))
+# define IS_NAME_CHAR_MINBPC(enc, p) \
+ (AS_NORMAL_ENCODING(enc)->isNameMin(enc, p))
+# define IS_NMSTRT_CHAR_MINBPC(enc, p) \
+ (AS_NORMAL_ENCODING(enc)->isNmstrtMin(enc, p))
#else
-#define IS_NAME_CHAR_MINBPC(enc, p) (0)
-#define IS_NMSTRT_CHAR_MINBPC(enc, p) (0)
+# define IS_NAME_CHAR_MINBPC(enc, p) (0)
+# define IS_NMSTRT_CHAR_MINBPC(enc, p) (0)
#endif
#ifdef XML_MIN_SIZE
-#define CHAR_MATCHES(enc, p, c) \
- (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c))
+# define CHAR_MATCHES(enc, p, c) \
+ (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c))
static int PTRCALL
-sb_charMatches(const ENCODING *enc, const char *p, int c)
-{
+sb_charMatches(const ENCODING *enc, const char *p, int c) {
+ UNUSED_P(enc);
return *p == c;
}
#else
/* c is an ASCII character */
-#define CHAR_MATCHES(enc, p, c) (*(p) == c)
+# define CHAR_MATCHES(enc, p, c) (*(p) == c)
#endif
-#define PREFIX(ident) normal_ ## ident
+#define PREFIX(ident) normal_##ident
#define XML_TOK_IMPL_C
#include "xmltok_impl.c"
#undef XML_TOK_IMPL_C
@@ -316,42 +310,46 @@ sb_charMatches(const ENCODING *enc, const char *p, int c)
#undef IS_NMSTRT_CHAR_MINBPC
#undef IS_INVALID_CHAR
-enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */
- UTF8_cval1 = 0x00,
- UTF8_cval2 = 0xc0,
- UTF8_cval3 = 0xe0,
- UTF8_cval4 = 0xf0
+enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */
+ UTF8_cval1 = 0x00,
+ UTF8_cval2 = 0xc0,
+ UTF8_cval3 = 0xe0,
+ UTF8_cval4 = 0xf0
};
void
-align_limit_to_full_utf8_characters(const char * from, const char ** fromLimRef)
-{
- const char * fromLim = *fromLimRef;
+_INTERNAL_trim_to_complete_utf8_characters(const char *from,
+ const char **fromLimRef) {
+ const char *fromLim = *fromLimRef;
size_t walked = 0;
for (; fromLim > from; fromLim--, walked++) {
const unsigned char prev = (unsigned char)fromLim[-1];
- if ((prev & 0xf8u) == 0xf0u) { /* 4-byte character, lead by 0b11110xxx byte */
+ if ((prev & 0xf8u)
+ == 0xf0u) { /* 4-byte character, lead by 0b11110xxx byte */
if (walked + 1 >= 4) {
fromLim += 4 - 1;
break;
} else {
walked = 0;
}
- } else if ((prev & 0xf0u) == 0xe0u) { /* 3-byte character, lead by 0b1110xxxx byte */
+ } else if ((prev & 0xf0u)
+ == 0xe0u) { /* 3-byte character, lead by 0b1110xxxx byte */
if (walked + 1 >= 3) {
fromLim += 3 - 1;
break;
} else {
walked = 0;
}
- } else if ((prev & 0xe0u) == 0xc0u) { /* 2-byte character, lead by 0b110xxxxx byte */
+ } else if ((prev & 0xe0u)
+ == 0xc0u) { /* 2-byte character, lead by 0b110xxxxx byte */
if (walked + 1 >= 2) {
fromLim += 2 - 1;
break;
} else {
walked = 0;
}
- } else if ((prev & 0x80u) == 0x00u) { /* 1-byte character, matching 0b0xxxxxxx */
+ } else if ((prev & 0x80u)
+ == 0x00u) { /* 1-byte character, matching 0b0xxxxxxx */
break;
}
}
@@ -359,35 +357,47 @@ align_limit_to_full_utf8_characters(const char * from, const char ** fromLimRef)
}
static enum XML_Convert_Result PTRCALL
-utf8_toUtf8(const ENCODING *UNUSED_P(enc),
- const char **fromP, const char *fromLim,
- char **toP, const char *toLim)
-{
- char *to;
- const char *from;
- const char *fromLimInitial = fromLim;
-
- /* Avoid copying partial characters. */
- align_limit_to_full_utf8_characters(*fromP, &fromLim);
-
- for (to = *toP, from = *fromP; (from < fromLim) && (to < toLim); from++, to++)
- *to = *from;
- *fromP = from;
- *toP = to;
+utf8_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim,
+ char **toP, const char *toLim) {
+ bool input_incomplete = false;
+ bool output_exhausted = false;
+
+ /* Avoid copying partial characters (due to limited space). */
+ const ptrdiff_t bytesAvailable = fromLim - *fromP;
+ const ptrdiff_t bytesStorable = toLim - *toP;
+ UNUSED_P(enc);
+ if (bytesAvailable > bytesStorable) {
+ fromLim = *fromP + bytesStorable;
+ output_exhausted = true;
+ }
- if (fromLim < fromLimInitial)
- return XML_CONVERT_INPUT_INCOMPLETE;
- else if ((to == toLim) && (from < fromLim))
+ /* Avoid copying partial characters (from incomplete input). */
+ {
+ const char *const fromLimBefore = fromLim;
+ _INTERNAL_trim_to_complete_utf8_characters(*fromP, &fromLim);
+ if (fromLim < fromLimBefore) {
+ input_incomplete = true;
+ }
+ }
+
+ {
+ const ptrdiff_t bytesToCopy = fromLim - *fromP;
+ memcpy(*toP, *fromP, bytesToCopy);
+ *fromP += bytesToCopy;
+ *toP += bytesToCopy;
+ }
+
+ if (output_exhausted) /* needs to go first */
return XML_CONVERT_OUTPUT_EXHAUSTED;
+ else if (input_incomplete)
+ return XML_CONVERT_INPUT_INCOMPLETE;
else
return XML_CONVERT_COMPLETED;
}
static enum XML_Convert_Result PTRCALL
-utf8_toUtf16(const ENCODING *enc,
- const char **fromP, const char *fromLim,
- unsigned short **toP, const unsigned short *toLim)
-{
+utf8_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim,
+ unsigned short **toP, const unsigned short *toLim) {
enum XML_Convert_Result res = XML_CONVERT_COMPLETED;
unsigned short *to = *toP;
const char *from = *fromP;
@@ -406,30 +416,28 @@ utf8_toUtf16(const ENCODING *enc,
res = XML_CONVERT_INPUT_INCOMPLETE;
goto after;
}
- *to++ = (unsigned short)(((from[0] & 0xf) << 12)
- | ((from[1] & 0x3f) << 6) | (from[2] & 0x3f));
+ *to++ = (unsigned short)(((from[0] & 0xf) << 12) | ((from[1] & 0x3f) << 6)
+ | (from[2] & 0x3f));
from += 3;
break;
- case BT_LEAD4:
- {
- unsigned long n;
- if (toLim - to < 2) {
- res = XML_CONVERT_OUTPUT_EXHAUSTED;
- goto after;
- }
- if (fromLim - from < 4) {
- res = XML_CONVERT_INPUT_INCOMPLETE;
- goto after;
- }
- n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12)
- | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f);
- n -= 0x10000;
- to[0] = (unsigned short)((n >> 10) | 0xD800);
- to[1] = (unsigned short)((n & 0x3FF) | 0xDC00);
- to += 2;
- from += 4;
+ case BT_LEAD4: {
+ unsigned long n;
+ if (toLim - to < 2) {
+ res = XML_CONVERT_OUTPUT_EXHAUSTED;
+ goto after;
}
- break;
+ if (fromLim - from < 4) {
+ res = XML_CONVERT_INPUT_INCOMPLETE;
+ goto after;
+ }
+ n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12)
+ | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f);
+ n -= 0x10000;
+ to[0] = (unsigned short)((n >> 10) | 0xD800);
+ to[1] = (unsigned short)((n & 0x3FF) | 0xDC00);
+ to += 2;
+ from += 4;
+ } break;
default:
*to++ = *from++;
break;
@@ -444,56 +452,51 @@ after:
}
#ifdef XML_NS
-static const struct normal_encoding utf8_encoding_ns = {
- { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
- {
-#include "asciitab.h"
-#include "utf8tab.h"
- },
- STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
-};
+static const struct normal_encoding utf8_encoding_ns
+ = {{VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0},
+ {
+# include "asciitab.h"
+# include "utf8tab.h"
+ },
+ STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)};
#endif
-static const struct normal_encoding utf8_encoding = {
- { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
- {
+static const struct normal_encoding utf8_encoding
+ = {{VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0},
+ {
#define BT_COLON BT_NMSTRT
#include "asciitab.h"
#undef BT_COLON
#include "utf8tab.h"
- },
- STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
-};
+ },
+ STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)};
#ifdef XML_NS
-static const struct normal_encoding internal_utf8_encoding_ns = {
- { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
- {
-#include "iasciitab.h"
-#include "utf8tab.h"
- },
- STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
-};
+static const struct normal_encoding internal_utf8_encoding_ns
+ = {{VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0},
+ {
+# include "iasciitab.h"
+# include "utf8tab.h"
+ },
+ STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)};
#endif
-static const struct normal_encoding internal_utf8_encoding = {
- { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
- {
+static const struct normal_encoding internal_utf8_encoding
+ = {{VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0},
+ {
#define BT_COLON BT_NMSTRT
#include "iasciitab.h"
#undef BT_COLON
#include "utf8tab.h"
- },
- STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
-};
+ },
+ STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)};
static enum XML_Convert_Result PTRCALL
-latin1_toUtf8(const ENCODING *UNUSED_P(enc),
- const char **fromP, const char *fromLim,
- char **toP, const char *toLim)
-{
+latin1_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim,
+ char **toP, const char *toLim) {
+ UNUSED_P(enc);
for (;;) {
unsigned char c;
if (*fromP == fromLim)
@@ -505,8 +508,7 @@ latin1_toUtf8(const ENCODING *UNUSED_P(enc),
*(*toP)++ = (char)((c >> 6) | UTF8_cval2);
*(*toP)++ = (char)((c & 0x3f) | 0x80);
(*fromP)++;
- }
- else {
+ } else {
if (*toP == toLim)
return XML_CONVERT_OUTPUT_EXHAUSTED;
*(*toP)++ = *(*fromP)++;
@@ -515,10 +517,9 @@ latin1_toUtf8(const ENCODING *UNUSED_P(enc),
}
static enum XML_Convert_Result PTRCALL
-latin1_toUtf16(const ENCODING *UNUSED_P(enc),
- const char **fromP, const char *fromLim,
- unsigned short **toP, const unsigned short *toLim)
-{
+latin1_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim,
+ unsigned short **toP, const unsigned short *toLim) {
+ UNUSED_P(enc);
while (*fromP < fromLim && *toP < toLim)
*(*toP)++ = (unsigned char)*(*fromP)++;
@@ -530,33 +531,30 @@ latin1_toUtf16(const ENCODING *UNUSED_P(enc),
#ifdef XML_NS
-static const struct normal_encoding latin1_encoding_ns = {
- { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 },
- {
-#include "asciitab.h"
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(sb_) NULL_VTABLE
-};
+static const struct normal_encoding latin1_encoding_ns
+ = {{VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0},
+ {
+# include "asciitab.h"
+# include "latin1tab.h"
+ },
+ STANDARD_VTABLE(sb_) NULL_VTABLE};
#endif
-static const struct normal_encoding latin1_encoding = {
- { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 },
- {
+static const struct normal_encoding latin1_encoding
+ = {{VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0},
+ {
#define BT_COLON BT_NMSTRT
#include "asciitab.h"
#undef BT_COLON
#include "latin1tab.h"
- },
- STANDARD_VTABLE(sb_) NULL_VTABLE
-};
+ },
+ STANDARD_VTABLE(sb_) NULL_VTABLE};
static enum XML_Convert_Result PTRCALL
-ascii_toUtf8(const ENCODING *UNUSED_P(enc),
- const char **fromP, const char *fromLim,
- char **toP, const char *toLim)
-{
+ascii_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim,
+ char **toP, const char *toLim) {
+ UNUSED_P(enc);
while (*fromP < fromLim && *toP < toLim)
*(*toP)++ = *(*fromP)++;
@@ -568,40 +566,45 @@ ascii_toUtf8(const ENCODING *UNUSED_P(enc),
#ifdef XML_NS
-static const struct normal_encoding ascii_encoding_ns = {
- { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 },
- {
-#include "asciitab.h"
-/* BT_NONXML == 0 */
- },
- STANDARD_VTABLE(sb_) NULL_VTABLE
-};
+static const struct normal_encoding ascii_encoding_ns
+ = {{VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0},
+ {
+# include "asciitab.h"
+ /* BT_NONXML == 0 */
+ },
+ STANDARD_VTABLE(sb_) NULL_VTABLE};
#endif
-static const struct normal_encoding ascii_encoding = {
- { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 },
- {
+static const struct normal_encoding ascii_encoding
+ = {{VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0},
+ {
#define BT_COLON BT_NMSTRT
#include "asciitab.h"
#undef BT_COLON
-/* BT_NONXML == 0 */
- },
- STANDARD_VTABLE(sb_) NULL_VTABLE
-};
+ /* BT_NONXML == 0 */
+ },
+ STANDARD_VTABLE(sb_) NULL_VTABLE};
static int PTRFASTCALL
-unicode_byte_type(char hi, char lo)
-{
+unicode_byte_type(char hi, char lo) {
switch ((unsigned char)hi) {
- case 0xD8: case 0xD9: case 0xDA: case 0xDB:
+ /* 0xD800–0xDBFF first 16-bit code unit or high surrogate (W1) */
+ case 0xD8:
+ case 0xD9:
+ case 0xDA:
+ case 0xDB:
return BT_LEAD4;
- case 0xDC: case 0xDD: case 0xDE: case 0xDF:
+ /* 0xDC00–0xDFFF second 16-bit code unit or low surrogate (W2) */
+ case 0xDC:
+ case 0xDD:
+ case 0xDE:
+ case 0xDF:
return BT_TRAIL;
case 0xFF:
switch ((unsigned char)lo) {
- case 0xFF:
- case 0xFE:
+ case 0xFF: /* noncharacter-FFFF */
+ case 0xFE: /* noncharacter-FFFE */
return BT_NONXML;
}
break;
@@ -609,102 +612,105 @@ unicode_byte_type(char hi, char lo)
return BT_NONASCII;
}
-#define DEFINE_UTF16_TO_UTF8(E) \
-static enum XML_Convert_Result PTRCALL \
-E ## toUtf8(const ENCODING *UNUSED_P(enc), \
- const char **fromP, const char *fromLim, \
- char **toP, const char *toLim) \
-{ \
- const char *from = *fromP; \
- fromLim = from + (((fromLim - from) >> 1) << 1); /* shrink to even */ \
- for (; from < fromLim; from += 2) { \
- int plane; \
- unsigned char lo2; \
- unsigned char lo = GET_LO(from); \
- unsigned char hi = GET_HI(from); \
- switch (hi) { \
- case 0: \
- if (lo < 0x80) { \
- if (*toP == toLim) { \
- *fromP = from; \
- return XML_CONVERT_OUTPUT_EXHAUSTED; \
- } \
- *(*toP)++ = lo; \
- break; \
- } \
- /* fall through */ \
- case 0x1: case 0x2: case 0x3: \
- case 0x4: case 0x5: case 0x6: case 0x7: \
- if (toLim - *toP < 2) { \
- *fromP = from; \
- return XML_CONVERT_OUTPUT_EXHAUSTED; \
- } \
- *(*toP)++ = ((lo >> 6) | (hi << 2) | UTF8_cval2); \
- *(*toP)++ = ((lo & 0x3f) | 0x80); \
- break; \
- default: \
- if (toLim - *toP < 3) { \
- *fromP = from; \
- return XML_CONVERT_OUTPUT_EXHAUSTED; \
- } \
- /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \
- *(*toP)++ = ((hi >> 4) | UTF8_cval3); \
- *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \
- *(*toP)++ = ((lo & 0x3f) | 0x80); \
- break; \
- case 0xD8: case 0xD9: case 0xDA: case 0xDB: \
- if (toLim - *toP < 4) { \
- *fromP = from; \
- return XML_CONVERT_OUTPUT_EXHAUSTED; \
- } \
- if (fromLim - from < 4) { \
- *fromP = from; \
- return XML_CONVERT_INPUT_INCOMPLETE; \
- } \
- plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \
- *(*toP)++ = ((plane >> 2) | UTF8_cval4); \
- *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \
- from += 2; \
- lo2 = GET_LO(from); \
- *(*toP)++ = (((lo & 0x3) << 4) \
- | ((GET_HI(from) & 0x3) << 2) \
- | (lo2 >> 6) \
- | 0x80); \
- *(*toP)++ = ((lo2 & 0x3f) | 0x80); \
- break; \
- } \
- } \
- *fromP = from; \
- if (from < fromLim) \
- return XML_CONVERT_INPUT_INCOMPLETE; \
- else \
- return XML_CONVERT_COMPLETED; \
-}
+#define DEFINE_UTF16_TO_UTF8(E) \
+ static enum XML_Convert_Result PTRCALL E##toUtf8( \
+ const ENCODING *enc, const char **fromP, const char *fromLim, \
+ char **toP, const char *toLim) { \
+ const char *from = *fromP; \
+ UNUSED_P(enc); \
+ fromLim = from + (((fromLim - from) >> 1) << 1); /* shrink to even */ \
+ for (; from < fromLim; from += 2) { \
+ int plane; \
+ unsigned char lo2; \
+ unsigned char lo = GET_LO(from); \
+ unsigned char hi = GET_HI(from); \
+ switch (hi) { \
+ case 0: \
+ if (lo < 0x80) { \
+ if (*toP == toLim) { \
+ *fromP = from; \
+ return XML_CONVERT_OUTPUT_EXHAUSTED; \
+ } \
+ *(*toP)++ = lo; \
+ break; \
+ } \
+ /* fall through */ \
+ case 0x1: \
+ case 0x2: \
+ case 0x3: \
+ case 0x4: \
+ case 0x5: \
+ case 0x6: \
+ case 0x7: \
+ if (toLim - *toP < 2) { \
+ *fromP = from; \
+ return XML_CONVERT_OUTPUT_EXHAUSTED; \
+ } \
+ *(*toP)++ = ((lo >> 6) | (hi << 2) | UTF8_cval2); \
+ *(*toP)++ = ((lo & 0x3f) | 0x80); \
+ break; \
+ default: \
+ if (toLim - *toP < 3) { \
+ *fromP = from; \
+ return XML_CONVERT_OUTPUT_EXHAUSTED; \
+ } \
+ /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \
+ *(*toP)++ = ((hi >> 4) | UTF8_cval3); \
+ *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \
+ *(*toP)++ = ((lo & 0x3f) | 0x80); \
+ break; \
+ case 0xD8: \
+ case 0xD9: \
+ case 0xDA: \
+ case 0xDB: \
+ if (toLim - *toP < 4) { \
+ *fromP = from; \
+ return XML_CONVERT_OUTPUT_EXHAUSTED; \
+ } \
+ if (fromLim - from < 4) { \
+ *fromP = from; \
+ return XML_CONVERT_INPUT_INCOMPLETE; \
+ } \
+ plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \
+ *(*toP)++ = (char)((plane >> 2) | UTF8_cval4); \
+ *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \
+ from += 2; \
+ lo2 = GET_LO(from); \
+ *(*toP)++ = (((lo & 0x3) << 4) | ((GET_HI(from) & 0x3) << 2) \
+ | (lo2 >> 6) | 0x80); \
+ *(*toP)++ = ((lo2 & 0x3f) | 0x80); \
+ break; \
+ } \
+ } \
+ *fromP = from; \
+ if (from < fromLim) \
+ return XML_CONVERT_INPUT_INCOMPLETE; \
+ else \
+ return XML_CONVERT_COMPLETED; \
+ }
-#define DEFINE_UTF16_TO_UTF16(E) \
-static enum XML_Convert_Result PTRCALL \
-E ## toUtf16(const ENCODING *UNUSED_P(enc), \
- const char **fromP, const char *fromLim, \
- unsigned short **toP, const unsigned short *toLim) \
-{ \
- enum XML_Convert_Result res = XML_CONVERT_COMPLETED; \
- fromLim = *fromP + (((fromLim - *fromP) >> 1) << 1); /* shrink to even */ \
- /* Avoid copying first half only of surrogate */ \
- if (fromLim - *fromP > ((toLim - *toP) << 1) \
- && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) { \
- fromLim -= 2; \
- res = XML_CONVERT_INPUT_INCOMPLETE; \
- } \
- for (; *fromP < fromLim && *toP < toLim; *fromP += 2) \
- *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \
- if ((*toP == toLim) && (*fromP < fromLim)) \
- return XML_CONVERT_OUTPUT_EXHAUSTED; \
- else \
- return res; \
-}
+#define DEFINE_UTF16_TO_UTF16(E) \
+ static enum XML_Convert_Result PTRCALL E##toUtf16( \
+ const ENCODING *enc, const char **fromP, const char *fromLim, \
+ unsigned short **toP, const unsigned short *toLim) { \
+ enum XML_Convert_Result res = XML_CONVERT_COMPLETED; \
+ UNUSED_P(enc); \
+ fromLim = *fromP + (((fromLim - *fromP) >> 1) << 1); /* shrink to even */ \
+ /* Avoid copying first half only of surrogate */ \
+ if (fromLim - *fromP > ((toLim - *toP) << 1) \
+ && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) { \
+ fromLim -= 2; \
+ res = XML_CONVERT_INPUT_INCOMPLETE; \
+ } \
+ for (; *fromP < fromLim && *toP < toLim; *fromP += 2) \
+ *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \
+ if ((*toP == toLim) && (*fromP < fromLim)) \
+ return XML_CONVERT_OUTPUT_EXHAUSTED; \
+ else \
+ return res; \
+ }
-#define SET2(ptr, ch) \
- (((ptr)[0] = ((ch) & 0xff)), ((ptr)[1] = ((ch) >> 8)))
+#define SET2(ptr, ch) (((ptr)[0] = ((ch)&0xff)), ((ptr)[1] = ((ch) >> 8)))
#define GET_LO(ptr) ((unsigned char)(ptr)[0])
#define GET_HI(ptr) ((unsigned char)(ptr)[1])
@@ -715,8 +721,7 @@ DEFINE_UTF16_TO_UTF16(little2_)
#undef GET_LO
#undef GET_HI
-#define SET2(ptr, ch) \
- (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch) & 0xFF)))
+#define SET2(ptr, ch) (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch)&0xFF)))
#define GET_LO(ptr) ((unsigned char)(ptr)[1])
#define GET_HI(ptr) ((unsigned char)(ptr)[0])
@@ -727,292 +732,279 @@ DEFINE_UTF16_TO_UTF16(big2_)
#undef GET_LO
#undef GET_HI
-#define LITTLE2_BYTE_TYPE(enc, p) \
- ((p)[1] == 0 \
- ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \
- : unicode_byte_type((p)[1], (p)[0]))
-#define LITTLE2_BYTE_TO_ASCII(enc, p) ((p)[1] == 0 ? (p)[0] : -1)
-#define LITTLE2_CHAR_MATCHES(enc, p, c) ((p)[1] == 0 && (p)[0] == c)
-#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) \
+#define LITTLE2_BYTE_TYPE(enc, p) \
+ ((p)[1] == 0 ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \
+ : unicode_byte_type((p)[1], (p)[0]))
+#define LITTLE2_BYTE_TO_ASCII(p) ((p)[1] == 0 ? (p)[0] : -1)
+#define LITTLE2_CHAR_MATCHES(p, c) ((p)[1] == 0 && (p)[0] == c)
+#define LITTLE2_IS_NAME_CHAR_MINBPC(p) \
UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])
-#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) \
+#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(p) \
UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0])
#ifdef XML_MIN_SIZE
static int PTRFASTCALL
-little2_byteType(const ENCODING *enc, const char *p)
-{
+little2_byteType(const ENCODING *enc, const char *p) {
return LITTLE2_BYTE_TYPE(enc, p);
}
static int PTRFASTCALL
-little2_byteToAscii(const ENCODING *enc, const char *p)
-{
- return LITTLE2_BYTE_TO_ASCII(enc, p);
+little2_byteToAscii(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
+ return LITTLE2_BYTE_TO_ASCII(p);
}
static int PTRCALL
-little2_charMatches(const ENCODING *enc, const char *p, int c)
-{
- return LITTLE2_CHAR_MATCHES(enc, p, c);
+little2_charMatches(const ENCODING *enc, const char *p, int c) {
+ UNUSED_P(enc);
+ return LITTLE2_CHAR_MATCHES(p, c);
}
static int PTRFASTCALL
-little2_isNameMin(const ENCODING *enc, const char *p)
-{
- return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p);
+little2_isNameMin(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
+ return LITTLE2_IS_NAME_CHAR_MINBPC(p);
}
static int PTRFASTCALL
-little2_isNmstrtMin(const ENCODING *enc, const char *p)
-{
- return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p);
+little2_isNmstrtMin(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
+ return LITTLE2_IS_NMSTRT_CHAR_MINBPC(p);
}
-#undef VTABLE
-#define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16
+# undef VTABLE
+# define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16
#else /* not XML_MIN_SIZE */
-#undef PREFIX
-#define PREFIX(ident) little2_ ## ident
-#define MINBPC(enc) 2
+# undef PREFIX
+# define PREFIX(ident) little2_##ident
+# define MINBPC(enc) 2
/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
-#define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p)
-#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p)
-#define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c)
-#define IS_NAME_CHAR(enc, p, n) 0
-#define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)
-#define IS_NMSTRT_CHAR(enc, p, n) (0)
-#define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)
-
-#define XML_TOK_IMPL_C
-#include "xmltok_impl.c"
-#undef XML_TOK_IMPL_C
-
-#undef MINBPC
-#undef BYTE_TYPE
-#undef BYTE_TO_ASCII
-#undef CHAR_MATCHES
-#undef IS_NAME_CHAR
-#undef IS_NAME_CHAR_MINBPC
-#undef IS_NMSTRT_CHAR
-#undef IS_NMSTRT_CHAR_MINBPC
-#undef IS_INVALID_CHAR
+# define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p)
+# define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(p)
+# define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(p, c)
+# define IS_NAME_CHAR(enc, p, n) 0
+# define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(p)
+# define IS_NMSTRT_CHAR(enc, p, n) (0)
+# define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(p)
+
+# define XML_TOK_IMPL_C
+# include "xmltok_impl.c"
+# undef XML_TOK_IMPL_C
+
+# undef MINBPC
+# undef BYTE_TYPE
+# undef BYTE_TO_ASCII
+# undef CHAR_MATCHES
+# undef IS_NAME_CHAR
+# undef IS_NAME_CHAR_MINBPC
+# undef IS_NMSTRT_CHAR
+# undef IS_NMSTRT_CHAR_MINBPC
+# undef IS_INVALID_CHAR
#endif /* not XML_MIN_SIZE */
#ifdef XML_NS
-static const struct normal_encoding little2_encoding_ns = {
- { VTABLE, 2, 0,
-#if BYTEORDER == 1234
- 1
-#else
- 0
-#endif
- },
- {
-#include "asciitab.h"
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(little2_) NULL_VTABLE
-};
+static const struct normal_encoding little2_encoding_ns
+ = {{VTABLE, 2, 0,
+# if BYTEORDER == 1234
+ 1
+# else
+ 0
+# endif
+ },
+ {
+# include "asciitab.h"
+# include "latin1tab.h"
+ },
+ STANDARD_VTABLE(little2_) NULL_VTABLE};
#endif
-static const struct normal_encoding little2_encoding = {
- { VTABLE, 2, 0,
+static const struct normal_encoding little2_encoding
+ = {{VTABLE, 2, 0,
#if BYTEORDER == 1234
- 1
+ 1
#else
- 0
+ 0
#endif
- },
- {
+ },
+ {
#define BT_COLON BT_NMSTRT
#include "asciitab.h"
#undef BT_COLON
#include "latin1tab.h"
- },
- STANDARD_VTABLE(little2_) NULL_VTABLE
-};
+ },
+ STANDARD_VTABLE(little2_) NULL_VTABLE};
#if BYTEORDER != 4321
-#ifdef XML_NS
+# ifdef XML_NS
-static const struct normal_encoding internal_little2_encoding_ns = {
- { VTABLE, 2, 0, 1 },
- {
-#include "iasciitab.h"
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(little2_) NULL_VTABLE
-};
+static const struct normal_encoding internal_little2_encoding_ns
+ = {{VTABLE, 2, 0, 1},
+ {
+# include "iasciitab.h"
+# include "latin1tab.h"
+ },
+ STANDARD_VTABLE(little2_) NULL_VTABLE};
-#endif
+# endif
-static const struct normal_encoding internal_little2_encoding = {
- { VTABLE, 2, 0, 1 },
- {
-#define BT_COLON BT_NMSTRT
-#include "iasciitab.h"
-#undef BT_COLON
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(little2_) NULL_VTABLE
-};
+static const struct normal_encoding internal_little2_encoding
+ = {{VTABLE, 2, 0, 1},
+ {
+# define BT_COLON BT_NMSTRT
+# include "iasciitab.h"
+# undef BT_COLON
+# include "latin1tab.h"
+ },
+ STANDARD_VTABLE(little2_) NULL_VTABLE};
#endif
-
-#define BIG2_BYTE_TYPE(enc, p) \
- ((p)[0] == 0 \
- ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \
- : unicode_byte_type((p)[0], (p)[1]))
-#define BIG2_BYTE_TO_ASCII(enc, p) ((p)[0] == 0 ? (p)[1] : -1)
-#define BIG2_CHAR_MATCHES(enc, p, c) ((p)[0] == 0 && (p)[1] == c)
-#define BIG2_IS_NAME_CHAR_MINBPC(enc, p) \
+#define BIG2_BYTE_TYPE(enc, p) \
+ ((p)[0] == 0 \
+ ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \
+ : unicode_byte_type((p)[0], (p)[1]))
+#define BIG2_BYTE_TO_ASCII(p) ((p)[0] == 0 ? (p)[1] : -1)
+#define BIG2_CHAR_MATCHES(p, c) ((p)[0] == 0 && (p)[1] == c)
+#define BIG2_IS_NAME_CHAR_MINBPC(p) \
UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])
-#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) \
+#define BIG2_IS_NMSTRT_CHAR_MINBPC(p) \
UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1])
#ifdef XML_MIN_SIZE
static int PTRFASTCALL
-big2_byteType(const ENCODING *enc, const char *p)
-{
+big2_byteType(const ENCODING *enc, const char *p) {
return BIG2_BYTE_TYPE(enc, p);
}
static int PTRFASTCALL
-big2_byteToAscii(const ENCODING *enc, const char *p)
-{
- return BIG2_BYTE_TO_ASCII(enc, p);
+big2_byteToAscii(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
+ return BIG2_BYTE_TO_ASCII(p);
}
static int PTRCALL
-big2_charMatches(const ENCODING *enc, const char *p, int c)
-{
- return BIG2_CHAR_MATCHES(enc, p, c);
+big2_charMatches(const ENCODING *enc, const char *p, int c) {
+ UNUSED_P(enc);
+ return BIG2_CHAR_MATCHES(p, c);
}
static int PTRFASTCALL
-big2_isNameMin(const ENCODING *enc, const char *p)
-{
- return BIG2_IS_NAME_CHAR_MINBPC(enc, p);
+big2_isNameMin(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
+ return BIG2_IS_NAME_CHAR_MINBPC(p);
}
static int PTRFASTCALL
-big2_isNmstrtMin(const ENCODING *enc, const char *p)
-{
- return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p);
+big2_isNmstrtMin(const ENCODING *enc, const char *p) {
+ UNUSED_P(enc);
+ return BIG2_IS_NMSTRT_CHAR_MINBPC(p);
}
-#undef VTABLE
-#define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16
+# undef VTABLE
+# define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16
#else /* not XML_MIN_SIZE */
-#undef PREFIX
-#define PREFIX(ident) big2_ ## ident
-#define MINBPC(enc) 2
+# undef PREFIX
+# define PREFIX(ident) big2_##ident
+# define MINBPC(enc) 2
/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
-#define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p)
-#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p)
-#define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c)
-#define IS_NAME_CHAR(enc, p, n) 0
-#define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p)
-#define IS_NMSTRT_CHAR(enc, p, n) (0)
-#define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)
-
-#define XML_TOK_IMPL_C
-#include "xmltok_impl.c"
-#undef XML_TOK_IMPL_C
-
-#undef MINBPC
-#undef BYTE_TYPE
-#undef BYTE_TO_ASCII
-#undef CHAR_MATCHES
-#undef IS_NAME_CHAR
-#undef IS_NAME_CHAR_MINBPC
-#undef IS_NMSTRT_CHAR
-#undef IS_NMSTRT_CHAR_MINBPC
-#undef IS_INVALID_CHAR
+# define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p)
+# define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(p)
+# define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(p, c)
+# define IS_NAME_CHAR(enc, p, n) 0
+# define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(p)
+# define IS_NMSTRT_CHAR(enc, p, n) (0)
+# define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(p)
+
+# define XML_TOK_IMPL_C
+# include "xmltok_impl.c"
+# undef XML_TOK_IMPL_C
+
+# undef MINBPC
+# undef BYTE_TYPE
+# undef BYTE_TO_ASCII
+# undef CHAR_MATCHES
+# undef IS_NAME_CHAR
+# undef IS_NAME_CHAR_MINBPC
+# undef IS_NMSTRT_CHAR
+# undef IS_NMSTRT_CHAR_MINBPC
+# undef IS_INVALID_CHAR
#endif /* not XML_MIN_SIZE */
#ifdef XML_NS
-static const struct normal_encoding big2_encoding_ns = {
- { VTABLE, 2, 0,
-#if BYTEORDER == 4321
- 1
-#else
- 0
-#endif
- },
- {
-#include "asciitab.h"
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(big2_) NULL_VTABLE
-};
+static const struct normal_encoding big2_encoding_ns
+ = {{VTABLE, 2, 0,
+# if BYTEORDER == 4321
+ 1
+# else
+ 0
+# endif
+ },
+ {
+# include "asciitab.h"
+# include "latin1tab.h"
+ },
+ STANDARD_VTABLE(big2_) NULL_VTABLE};
#endif
-static const struct normal_encoding big2_encoding = {
- { VTABLE, 2, 0,
+static const struct normal_encoding big2_encoding
+ = {{VTABLE, 2, 0,
#if BYTEORDER == 4321
- 1
+ 1
#else
- 0
+ 0
#endif
- },
- {
+ },
+ {
#define BT_COLON BT_NMSTRT
#include "asciitab.h"
#undef BT_COLON
#include "latin1tab.h"
- },
- STANDARD_VTABLE(big2_) NULL_VTABLE
-};
+ },
+ STANDARD_VTABLE(big2_) NULL_VTABLE};
#if BYTEORDER != 1234
-#ifdef XML_NS
+# ifdef XML_NS
-static const struct normal_encoding internal_big2_encoding_ns = {
- { VTABLE, 2, 0, 1 },
- {
-#include "iasciitab.h"
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(big2_) NULL_VTABLE
-};
+static const struct normal_encoding internal_big2_encoding_ns
+ = {{VTABLE, 2, 0, 1},
+ {
+# include "iasciitab.h"
+# include "latin1tab.h"
+ },
+ STANDARD_VTABLE(big2_) NULL_VTABLE};
-#endif
+# endif
-static const struct normal_encoding internal_big2_encoding = {
- { VTABLE, 2, 0, 1 },
- {
-#define BT_COLON BT_NMSTRT
-#include "iasciitab.h"
-#undef BT_COLON
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(big2_) NULL_VTABLE
-};
+static const struct normal_encoding internal_big2_encoding
+ = {{VTABLE, 2, 0, 1},
+ {
+# define BT_COLON BT_NMSTRT
+# include "iasciitab.h"
+# undef BT_COLON
+# include "latin1tab.h"
+ },
+ STANDARD_VTABLE(big2_) NULL_VTABLE};
#endif
#undef PREFIX
static int FASTCALL
-streqci(const char *s1, const char *s2)
-{
+streqci(const char *s1, const char *s2) {
for (;;) {
char c1 = *s1++;
char c2 = *s2++;
@@ -1026,22 +1018,21 @@ streqci(const char *s1, const char *s2)
c2 += ASCII_A - ASCII_a; /* LCOV_EXCL_LINE */
if (c1 != c2)
return 0;
- if (!c1)
+ if (! c1)
break;
}
return 1;
}
static void PTRCALL
-initUpdatePosition(const ENCODING *UNUSED_P(enc), const char *ptr,
- const char *end, POSITION *pos)
-{
+initUpdatePosition(const ENCODING *enc, const char *ptr, const char *end,
+ POSITION *pos) {
+ UNUSED_P(enc);
normal_updatePosition(&utf8_encoding.enc, ptr, end, pos);
}
static int
-toAscii(const ENCODING *enc, const char *ptr, const char *end)
-{
+toAscii(const ENCODING *enc, const char *ptr, const char *end) {
char buf[1];
char *p = buf;
XmlUtf8Convert(enc, &ptr, end, &p, p + 1);
@@ -1052,8 +1043,7 @@ toAscii(const ENCODING *enc, const char *ptr, const char *end)
}
static int FASTCALL
-isSpace(int c)
-{
+isSpace(int c) {
switch (c) {
case 0x20:
case 0xD:
@@ -1068,21 +1058,16 @@ isSpace(int c)
followed by name=val.
*/
static int
-parsePseudoAttribute(const ENCODING *enc,
- const char *ptr,
- const char *end,
- const char **namePtr,
- const char **nameEndPtr,
- const char **valPtr,
- const char **nextTokPtr)
-{
+parsePseudoAttribute(const ENCODING *enc, const char *ptr, const char *end,
+ const char **namePtr, const char **nameEndPtr,
+ const char **valPtr, const char **nextTokPtr) {
int c;
char open;
if (ptr == end) {
*namePtr = NULL;
return 1;
}
- if (!isSpace(toAscii(enc, ptr, end))) {
+ if (! isSpace(toAscii(enc, ptr, end))) {
*nextTokPtr = ptr;
return 0;
}
@@ -1138,12 +1123,9 @@ parsePseudoAttribute(const ENCODING *enc,
c = toAscii(enc, ptr, end);
if (c == open)
break;
- if (!(ASCII_a <= c && c <= ASCII_z)
- && !(ASCII_A <= c && c <= ASCII_Z)
- && !(ASCII_0 <= c && c <= ASCII_9)
- && c != ASCII_PERIOD
- && c != ASCII_MINUS
- && c != ASCII_UNDERSCORE) {
+ if (! (ASCII_a <= c && c <= ASCII_z) && ! (ASCII_A <= c && c <= ASCII_Z)
+ && ! (ASCII_0 <= c && c <= ASCII_9) && c != ASCII_PERIOD
+ && c != ASCII_MINUS && c != ASCII_UNDERSCORE) {
*nextTokPtr = ptr;
return 0;
}
@@ -1152,68 +1134,52 @@ parsePseudoAttribute(const ENCODING *enc,
return 1;
}
-static const char KW_version[] = {
- ASCII_v, ASCII_e, ASCII_r, ASCII_s, ASCII_i, ASCII_o, ASCII_n, '\0'
-};
+static const char KW_version[]
+ = {ASCII_v, ASCII_e, ASCII_r, ASCII_s, ASCII_i, ASCII_o, ASCII_n, '\0'};
-static const char KW_encoding[] = {
- ASCII_e, ASCII_n, ASCII_c, ASCII_o, ASCII_d, ASCII_i, ASCII_n, ASCII_g, '\0'
-};
+static const char KW_encoding[] = {ASCII_e, ASCII_n, ASCII_c, ASCII_o, ASCII_d,
+ ASCII_i, ASCII_n, ASCII_g, '\0'};
-static const char KW_standalone[] = {
- ASCII_s, ASCII_t, ASCII_a, ASCII_n, ASCII_d, ASCII_a, ASCII_l, ASCII_o,
- ASCII_n, ASCII_e, '\0'
-};
+static const char KW_standalone[]
+ = {ASCII_s, ASCII_t, ASCII_a, ASCII_n, ASCII_d, ASCII_a,
+ ASCII_l, ASCII_o, ASCII_n, ASCII_e, '\0'};
-static const char KW_yes[] = {
- ASCII_y, ASCII_e, ASCII_s, '\0'
-};
+static const char KW_yes[] = {ASCII_y, ASCII_e, ASCII_s, '\0'};
-static const char KW_no[] = {
- ASCII_n, ASCII_o, '\0'
-};
+static const char KW_no[] = {ASCII_n, ASCII_o, '\0'};
static int
-doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *,
- const char *,
+doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *, const char *,
const char *),
- int isGeneralTextEntity,
- const ENCODING *enc,
- const char *ptr,
- const char *end,
- const char **badPtr,
- const char **versionPtr,
- const char **versionEndPtr,
- const char **encodingName,
- const ENCODING **encoding,
- int *standalone)
-{
+ int isGeneralTextEntity, const ENCODING *enc, const char *ptr,
+ const char *end, const char **badPtr, const char **versionPtr,
+ const char **versionEndPtr, const char **encodingName,
+ const ENCODING **encoding, int *standalone) {
const char *val = NULL;
const char *name = NULL;
const char *nameEnd = NULL;
ptr += 5 * enc->minBytesPerChar;
end -= 2 * enc->minBytesPerChar;
- if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)
- || !name) {
+ if (! parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)
+ || ! name) {
*badPtr = ptr;
return 0;
}
- if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_version)) {
- if (!isGeneralTextEntity) {
+ if (! XmlNameMatchesAscii(enc, name, nameEnd, KW_version)) {
+ if (! isGeneralTextEntity) {
*badPtr = name;
return 0;
}
- }
- else {
+ } else {
if (versionPtr)
*versionPtr = val;
if (versionEndPtr)
*versionEndPtr = ptr;
- if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) {
+ if (! parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) {
*badPtr = ptr;
return 0;
}
- if (!name) {
+ if (! name) {
if (isGeneralTextEntity) {
/* a TextDecl must have an EncodingDecl */
*badPtr = ptr;
@@ -1224,7 +1190,7 @@ doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *,
}
if (XmlNameMatchesAscii(enc, name, nameEnd, KW_encoding)) {
int c = toAscii(enc, val, end);
- if (!(ASCII_a <= c && c <= ASCII_z) && !(ASCII_A <= c && c <= ASCII_Z)) {
+ if (! (ASCII_a <= c && c <= ASCII_z) && ! (ASCII_A <= c && c <= ASCII_Z)) {
*badPtr = val;
return 0;
}
@@ -1232,14 +1198,14 @@ doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *,
*encodingName = val;
if (encoding)
*encoding = encodingFinder(enc, val, ptr - enc->minBytesPerChar);
- if (!parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) {
+ if (! parsePseudoAttribute(enc, ptr, end, &name, &nameEnd, &val, &ptr)) {
*badPtr = ptr;
return 0;
}
- if (!name)
+ if (! name)
return 1;
}
- if (!XmlNameMatchesAscii(enc, name, nameEnd, KW_standalone)
+ if (! XmlNameMatchesAscii(enc, name, nameEnd, KW_standalone)
|| isGeneralTextEntity) {
*badPtr = name;
return 0;
@@ -1247,12 +1213,10 @@ doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *,
if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_yes)) {
if (standalone)
*standalone = 1;
- }
- else if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_no)) {
+ } else if (XmlNameMatchesAscii(enc, val, ptr - enc->minBytesPerChar, KW_no)) {
if (standalone)
*standalone = 0;
- }
- else {
+ } else {
*badPtr = val;
return 0;
}
@@ -1266,11 +1230,16 @@ doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *,
}
static int FASTCALL
-checkCharRefNumber(int result)
-{
+checkCharRefNumber(int result) {
switch (result >> 8) {
- case 0xD8: case 0xD9: case 0xDA: case 0xDB:
- case 0xDC: case 0xDD: case 0xDE: case 0xDF:
+ case 0xD8:
+ case 0xD9:
+ case 0xDA:
+ case 0xDB:
+ case 0xDC:
+ case 0xDD:
+ case 0xDE:
+ case 0xDF:
return -1;
case 0:
if (latin1_encoding.type[result] == BT_NONXML)
@@ -1285,8 +1254,7 @@ checkCharRefNumber(int result)
}
int FASTCALL
-XmlUtf8Encode(int c, char *buf)
-{
+XmlUtf8Encode(int c, char *buf) {
enum {
/* minN is minimum legal resulting value for N byte sequence */
min2 = 0x80,
@@ -1322,8 +1290,7 @@ XmlUtf8Encode(int c, char *buf)
}
int FASTCALL
-XmlUtf16Encode(int charNum, unsigned short *buf)
-{
+XmlUtf16Encode(int charNum, unsigned short *buf) {
if (charNum < 0)
return 0;
if (charNum < 0x10000) {
@@ -1347,17 +1314,15 @@ struct unknown_encoding {
char utf8[256][4];
};
-#define AS_UNKNOWN_ENCODING(enc) ((const struct unknown_encoding *) (enc))
+#define AS_UNKNOWN_ENCODING(enc) ((const struct unknown_encoding *)(enc))
int
-XmlSizeOfUnknownEncoding(void)
-{
+XmlSizeOfUnknownEncoding(void) {
return sizeof(struct unknown_encoding);
}
static int PTRFASTCALL
-unknown_isName(const ENCODING *enc, const char *p)
-{
+unknown_isName(const ENCODING *enc, const char *p) {
const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
int c = uenc->convert(uenc->userData, p);
if (c & ~0xFFFF)
@@ -1366,8 +1331,7 @@ unknown_isName(const ENCODING *enc, const char *p)
}
static int PTRFASTCALL
-unknown_isNmstrt(const ENCODING *enc, const char *p)
-{
+unknown_isNmstrt(const ENCODING *enc, const char *p) {
const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
int c = uenc->convert(uenc->userData, p);
if (c & ~0xFFFF)
@@ -1376,18 +1340,15 @@ unknown_isNmstrt(const ENCODING *enc, const char *p)
}
static int PTRFASTCALL
-unknown_isInvalid(const ENCODING *enc, const char *p)
-{
+unknown_isInvalid(const ENCODING *enc, const char *p) {
const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
int c = uenc->convert(uenc->userData, p);
return (c & ~0xFFFF) || checkCharRefNumber(c) < 0;
}
static enum XML_Convert_Result PTRCALL
-unknown_toUtf8(const ENCODING *enc,
- const char **fromP, const char *fromLim,
- char **toP, const char *toLim)
-{
+unknown_toUtf8(const ENCODING *enc, const char **fromP, const char *fromLim,
+ char **toP, const char *toLim) {
const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
char buf[XML_UTF8_ENCODE_MAX];
for (;;) {
@@ -1405,33 +1366,27 @@ unknown_toUtf8(const ENCODING *enc,
utf8 = buf;
*fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP]
- (BT_LEAD2 - 2));
- }
- else {
+ } else {
if (n > toLim - *toP)
return XML_CONVERT_OUTPUT_EXHAUSTED;
(*fromP)++;
}
- do {
- *(*toP)++ = *utf8++;
- } while (--n != 0);
+ memcpy(*toP, utf8, n);
+ *toP += n;
}
}
static enum XML_Convert_Result PTRCALL
-unknown_toUtf16(const ENCODING *enc,
- const char **fromP, const char *fromLim,
- unsigned short **toP, const unsigned short *toLim)
-{
+unknown_toUtf16(const ENCODING *enc, const char **fromP, const char *fromLim,
+ unsigned short **toP, const unsigned short *toLim) {
const struct unknown_encoding *uenc = AS_UNKNOWN_ENCODING(enc);
while (*fromP < fromLim && *toP < toLim) {
unsigned short c = uenc->utf16[(unsigned char)**fromP];
if (c == 0) {
- c = (unsigned short)
- uenc->convert(uenc->userData, *fromP);
+ c = (unsigned short)uenc->convert(uenc->userData, *fromP);
*fromP += (AS_NORMAL_ENCODING(enc)->type[(unsigned char)**fromP]
- (BT_LEAD2 - 2));
- }
- else
+ } else
(*fromP)++;
*(*toP)++ = c;
}
@@ -1443,19 +1398,14 @@ unknown_toUtf16(const ENCODING *enc,
}
ENCODING *
-XmlInitUnknownEncoding(void *mem,
- int *table,
- CONVERTER convert,
- void *userData)
-{
+XmlInitUnknownEncoding(void *mem, int *table, CONVERTER convert,
+ void *userData) {
int i;
struct unknown_encoding *e = (struct unknown_encoding *)mem;
- for (i = 0; i < (int)sizeof(struct normal_encoding); i++)
- ((char *)mem)[i] = ((char *)&latin1_encoding)[i];
+ memcpy(mem, &latin1_encoding, sizeof(struct normal_encoding));
for (i = 0; i < 128; i++)
if (latin1_encoding.type[i] != BT_OTHER
- && latin1_encoding.type[i] != BT_NONXML
- && table[i] != i)
+ && latin1_encoding.type[i] != BT_NONXML && table[i] != i)
return 0;
for (i = 0; i < 256; i++) {
int c = table[i];
@@ -1465,35 +1415,30 @@ XmlInitUnknownEncoding(void *mem,
e->utf16[i] = 0xFFFF;
e->utf8[i][0] = 1;
e->utf8[i][1] = 0;
- }
- else if (c < 0) {
+ } else if (c < 0) {
if (c < -4)
return 0;
/* Multi-byte sequences need a converter function */
- if (!convert)
+ if (! convert)
return 0;
e->normal.type[i] = (unsigned char)(BT_LEAD2 - (c + 2));
e->utf8[i][0] = 0;
e->utf16[i] = 0;
- }
- else if (c < 0x80) {
+ } else if (c < 0x80) {
if (latin1_encoding.type[c] != BT_OTHER
- && latin1_encoding.type[c] != BT_NONXML
- && c != i)
+ && latin1_encoding.type[c] != BT_NONXML && c != i)
return 0;
e->normal.type[i] = latin1_encoding.type[c];
e->utf8[i][0] = 1;
e->utf8[i][1] = (char)c;
e->utf16[i] = (unsigned short)(c == 0 ? 0xFFFF : c);
- }
- else if (checkCharRefNumber(c) < 0) {
+ } else if (checkCharRefNumber(c) < 0) {
e->normal.type[i] = BT_NONXML;
/* This shouldn't really get used. */
e->utf16[i] = 0xFFFF;
e->utf8[i][0] = 1;
e->utf8[i][1] = 0;
- }
- else {
+ } else {
if (c > 0xFFFF)
return 0;
if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff))
@@ -1538,44 +1483,32 @@ enum {
NO_ENC
};
-static const char KW_ISO_8859_1[] = {
- ASCII_I, ASCII_S, ASCII_O, ASCII_MINUS, ASCII_8, ASCII_8, ASCII_5, ASCII_9,
- ASCII_MINUS, ASCII_1, '\0'
-};
-static const char KW_US_ASCII[] = {
- ASCII_U, ASCII_S, ASCII_MINUS, ASCII_A, ASCII_S, ASCII_C, ASCII_I, ASCII_I,
- '\0'
-};
-static const char KW_UTF_8[] = {
- ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_8, '\0'
-};
-static const char KW_UTF_16[] = {
- ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, '\0'
-};
-static const char KW_UTF_16BE[] = {
- ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_B, ASCII_E,
- '\0'
-};
-static const char KW_UTF_16LE[] = {
- ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, ASCII_L, ASCII_E,
- '\0'
-};
+static const char KW_ISO_8859_1[]
+ = {ASCII_I, ASCII_S, ASCII_O, ASCII_MINUS, ASCII_8, ASCII_8,
+ ASCII_5, ASCII_9, ASCII_MINUS, ASCII_1, '\0'};
+static const char KW_US_ASCII[]
+ = {ASCII_U, ASCII_S, ASCII_MINUS, ASCII_A, ASCII_S,
+ ASCII_C, ASCII_I, ASCII_I, '\0'};
+static const char KW_UTF_8[]
+ = {ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_8, '\0'};
+static const char KW_UTF_16[]
+ = {ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1, ASCII_6, '\0'};
+static const char KW_UTF_16BE[]
+ = {ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1,
+ ASCII_6, ASCII_B, ASCII_E, '\0'};
+static const char KW_UTF_16LE[]
+ = {ASCII_U, ASCII_T, ASCII_F, ASCII_MINUS, ASCII_1,
+ ASCII_6, ASCII_L, ASCII_E, '\0'};
static int FASTCALL
-getEncodingIndex(const char *name)
-{
- static const char * const encodingNames[] = {
- KW_ISO_8859_1,
- KW_US_ASCII,
- KW_UTF_8,
- KW_UTF_16,
- KW_UTF_16BE,
- KW_UTF_16LE,
+getEncodingIndex(const char *name) {
+ static const char *const encodingNames[] = {
+ KW_ISO_8859_1, KW_US_ASCII, KW_UTF_8, KW_UTF_16, KW_UTF_16BE, KW_UTF_16LE,
};
int i;
if (name == NULL)
return NO_ENC;
- for (i = 0; i < (int)(sizeof(encodingNames)/sizeof(encodingNames[0])); i++)
+ for (i = 0; i < (int)(sizeof(encodingNames) / sizeof(encodingNames[0])); i++)
if (streqci(name, encodingNames[i]))
return i;
return UNKNOWN_ENC;
@@ -1595,15 +1528,9 @@ getEncodingIndex(const char *name)
XML_PROLOG_STATE otherwise.
*/
-
static int
-initScan(const ENCODING * const *encodingTable,
- const INIT_ENCODING *enc,
- int state,
- const char *ptr,
- const char *end,
- const char **nextTokPtr)
-{
+initScan(const ENCODING *const *encodingTable, const INIT_ENCODING *enc,
+ int state, const char *ptr, const char *end, const char **nextTokPtr) {
const ENCODING **encPtr;
if (ptr >= end)
@@ -1628,20 +1555,17 @@ initScan(const ENCODING * const *encodingTable,
case 0xFE:
case 0xFF:
case 0xEF: /* possibly first byte of UTF-8 BOM */
- if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
- && state == XML_CONTENT_STATE)
+ if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC && state == XML_CONTENT_STATE)
break;
/* fall through */
case 0x00:
case 0x3C:
return XML_TOK_PARTIAL;
}
- }
- else {
+ } else {
switch (((unsigned char)ptr[0] << 8) | (unsigned char)ptr[1]) {
case 0xFEFF:
- if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
- && state == XML_CONTENT_STATE)
+ if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC && state == XML_CONTENT_STATE)
break;
*nextTokPtr = ptr + 2;
*encPtr = encodingTable[UTF_16BE_ENC];
@@ -1655,8 +1579,7 @@ initScan(const ENCODING * const *encodingTable,
*encPtr = encodingTable[UTF_16LE_ENC];
return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
case 0xFFFE:
- if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
- && state == XML_CONTENT_STATE)
+ if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC && state == XML_CONTENT_STATE)
break;
*nextTokPtr = ptr + 2;
*encPtr = encodingTable[UTF_16LE_ENC];
@@ -1671,8 +1594,8 @@ initScan(const ENCODING * const *encodingTable,
*/
if (state == XML_CONTENT_STATE) {
int e = INIT_ENC_INDEX(enc);
- if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC
- || e == UTF_16LE_ENC || e == UTF_16_ENC)
+ if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC || e == UTF_16LE_ENC
+ || e == UTF_16_ENC)
break;
}
if (ptr + 2 == end)
@@ -1695,8 +1618,7 @@ initScan(const ENCODING * const *encodingTable,
break;
*encPtr = encodingTable[UTF_16BE_ENC];
return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
- }
- else if (ptr[1] == '\0') {
+ } else if (ptr[1] == '\0') {
/* We could recover here in the case:
- parsing an external entity
- second byte is 0
@@ -1718,7 +1640,6 @@ initScan(const ENCODING * const *encodingTable,
return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
}
-
#define NS(x) x
#define ns(x) x
#define XML_TOK_NS_C
@@ -1729,22 +1650,19 @@ initScan(const ENCODING * const *encodingTable,
#ifdef XML_NS
-#define NS(x) x ## NS
-#define ns(x) x ## _ns
+# define NS(x) x##NS
+# define ns(x) x##_ns
-#define XML_TOK_NS_C
-#include "xmltok_ns.c"
-#undef XML_TOK_NS_C
+# define XML_TOK_NS_C
+# include "xmltok_ns.c"
+# undef XML_TOK_NS_C
-#undef NS
-#undef ns
+# undef NS
+# undef ns
ENCODING *
-XmlInitUnknownEncodingNS(void *mem,
- int *table,
- CONVERTER convert,
- void *userData)
-{
+XmlInitUnknownEncodingNS(void *mem, int *table, CONVERTER convert,
+ void *userData) {
ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData);
if (enc)
((struct normal_encoding *)enc)->type[ASCII_COLON] = BT_COLON;
diff --git a/Utilities/cmexpat/lib/xmltok.h b/Utilities/cmexpat/lib/xmltok.h
index 752007e8b..2adbf5307 100644
--- a/Utilities/cmexpat/lib/xmltok.h
+++ b/Utilities/cmexpat/lib/xmltok.h
@@ -1,5 +1,33 @@
-/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
+/*
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef XmlTok_INCLUDED
@@ -10,16 +38,18 @@ extern "C" {
#endif
/* The following token may be returned by XmlContentTok */
-#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be
- start of illegal ]]> sequence */
+#define XML_TOK_TRAILING_RSQB \
+ -5 /* ] or ]] at the end of the scan; might be \
+ start of illegal ]]> sequence */
/* The following tokens may be returned by both XmlPrologTok and
XmlContentTok.
*/
-#define XML_TOK_NONE -4 /* The string to be scanned is empty */
-#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan;
- might be part of CRLF sequence */
-#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
-#define XML_TOK_PARTIAL -1 /* only part of a token */
+#define XML_TOK_NONE -4 /* The string to be scanned is empty */
+#define XML_TOK_TRAILING_CR \
+ -3 /* A CR at the end of the scan; \
+ might be part of CRLF sequence */
+#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
+#define XML_TOK_PARTIAL -1 /* only part of a token */
#define XML_TOK_INVALID 0
/* The following tokens are returned by XmlContentTok; some are also
@@ -34,24 +64,24 @@ extern "C" {
#define XML_TOK_DATA_NEWLINE 7
#define XML_TOK_CDATA_SECT_OPEN 8
#define XML_TOK_ENTITY_REF 9
-#define XML_TOK_CHAR_REF 10 /* numeric character reference */
+#define XML_TOK_CHAR_REF 10 /* numeric character reference */
/* The following tokens may be returned by both XmlPrologTok and
XmlContentTok.
*/
-#define XML_TOK_PI 11 /* processing instruction */
-#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
+#define XML_TOK_PI 11 /* processing instruction */
+#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
#define XML_TOK_COMMENT 13
-#define XML_TOK_BOM 14 /* Byte order mark */
+#define XML_TOK_BOM 14 /* Byte order mark */
/* The following tokens are returned only by XmlPrologTok */
#define XML_TOK_PROLOG_S 15
-#define XML_TOK_DECL_OPEN 16 /* <!foo */
-#define XML_TOK_DECL_CLOSE 17 /* > */
+#define XML_TOK_DECL_OPEN 16 /* <!foo */
+#define XML_TOK_DECL_CLOSE 17 /* > */
#define XML_TOK_NAME 18
#define XML_TOK_NMTOKEN 19
-#define XML_TOK_POUND_NAME 20 /* #name */
-#define XML_TOK_OR 21 /* | */
+#define XML_TOK_POUND_NAME 20 /* #name */
+#define XML_TOK_OR 21 /* | */
#define XML_TOK_PERCENT 22
#define XML_TOK_OPEN_PAREN 23
#define XML_TOK_CLOSE_PAREN 24
@@ -62,14 +92,14 @@ extern "C" {
#define XML_TOK_INSTANCE_START 29
/* The following occur only in element type declarations */
-#define XML_TOK_NAME_QUESTION 30 /* name? */
-#define XML_TOK_NAME_ASTERISK 31 /* name* */
-#define XML_TOK_NAME_PLUS 32 /* name+ */
-#define XML_TOK_COND_SECT_OPEN 33 /* <![ */
-#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
-#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
-#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
-#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
+#define XML_TOK_NAME_QUESTION 30 /* name? */
+#define XML_TOK_NAME_ASTERISK 31 /* name* */
+#define XML_TOK_NAME_PLUS 32 /* name+ */
+#define XML_TOK_COND_SECT_OPEN 33 /* <![ */
+#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
+#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
+#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
+#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
#define XML_TOK_COMMA 38
/* The following token is returned only by XmlAttributeValueTok */
@@ -84,20 +114,20 @@ extern "C" {
#define XML_TOK_PREFIXED_NAME 41
#ifdef XML_DTD
-#define XML_TOK_IGNORE_SECT 42
+# define XML_TOK_IGNORE_SECT 42
#endif /* XML_DTD */
#ifdef XML_DTD
-#define XML_N_STATES 4
+# define XML_N_STATES 4
#else /* not XML_DTD */
-#define XML_N_STATES 3
+# define XML_N_STATES 3
#endif /* not XML_DTD */
#define XML_PROLOG_STATE 0
#define XML_CONTENT_STATE 1
#define XML_CDATA_SECTION_STATE 2
#ifdef XML_DTD
-#define XML_IGNORE_SECTION_STATE 3
+# define XML_IGNORE_SECTION_STATE 3
#endif /* XML_DTD */
#define XML_N_LITERAL_TYPES 2
@@ -125,55 +155,41 @@ typedef struct {
struct encoding;
typedef struct encoding ENCODING;
-typedef int (PTRCALL *SCANNER)(const ENCODING *,
- const char *,
- const char *,
- const char **);
+typedef int(PTRCALL *SCANNER)(const ENCODING *, const char *, const char *,
+ const char **);
enum XML_Convert_Result {
XML_CONVERT_COMPLETED = 0,
XML_CONVERT_INPUT_INCOMPLETE = 1,
- XML_CONVERT_OUTPUT_EXHAUSTED = 2 /* and therefore potentially input remaining as well */
+ XML_CONVERT_OUTPUT_EXHAUSTED
+ = 2 /* and therefore potentially input remaining as well */
};
struct encoding {
SCANNER scanners[XML_N_STATES];
SCANNER literalScanners[XML_N_LITERAL_TYPES];
- int (PTRCALL *sameName)(const ENCODING *,
- const char *,
- const char *);
- int (PTRCALL *nameMatchesAscii)(const ENCODING *,
- const char *,
- const char *,
- const char *);
- int (PTRFASTCALL *nameLength)(const ENCODING *, const char *);
+ int(PTRCALL *nameMatchesAscii)(const ENCODING *, const char *, const char *,
+ const char *);
+ int(PTRFASTCALL *nameLength)(const ENCODING *, const char *);
const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *);
- int (PTRCALL *getAtts)(const ENCODING *enc,
- const char *ptr,
- int attsMax,
- ATTRIBUTE *atts);
- int (PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
- int (PTRCALL *predefinedEntityName)(const ENCODING *,
- const char *,
- const char *);
- void (PTRCALL *updatePosition)(const ENCODING *,
- const char *ptr,
- const char *end,
- POSITION *);
- int (PTRCALL *isPublicId)(const ENCODING *enc,
- const char *ptr,
- const char *end,
- const char **badPtr);
- enum XML_Convert_Result (PTRCALL *utf8Convert)(const ENCODING *enc,
- const char **fromP,
- const char *fromLim,
- char **toP,
- const char *toLim);
- enum XML_Convert_Result (PTRCALL *utf16Convert)(const ENCODING *enc,
- const char **fromP,
- const char *fromLim,
- unsigned short **toP,
- const unsigned short *toLim);
+ int(PTRCALL *getAtts)(const ENCODING *enc, const char *ptr, int attsMax,
+ ATTRIBUTE *atts);
+ int(PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
+ int(PTRCALL *predefinedEntityName)(const ENCODING *, const char *,
+ const char *);
+ void(PTRCALL *updatePosition)(const ENCODING *, const char *ptr,
+ const char *end, POSITION *);
+ int(PTRCALL *isPublicId)(const ENCODING *enc, const char *ptr,
+ const char *end, const char **badPtr);
+ enum XML_Convert_Result(PTRCALL *utf8Convert)(const ENCODING *enc,
+ const char **fromP,
+ const char *fromLim, char **toP,
+ const char *toLim);
+ enum XML_Convert_Result(PTRCALL *utf16Convert)(const ENCODING *enc,
+ const char **fromP,
+ const char *fromLim,
+ unsigned short **toP,
+ const unsigned short *toLim);
int minBytesPerChar;
char isUtf8;
char isUtf16;
@@ -200,68 +216,62 @@ struct encoding {
the prolog outside literals, comments and processing instructions.
*/
-
-#define XmlTok(enc, state, ptr, end, nextTokPtr) \
+#define XmlTok(enc, state, ptr, end, nextTokPtr) \
(((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
-#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
- XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
+#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
+ XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
-#define XmlContentTok(enc, ptr, end, nextTokPtr) \
- XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
+#define XmlContentTok(enc, ptr, end, nextTokPtr) \
+ XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
-#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
- XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
+#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
+ XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
#ifdef XML_DTD
-#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \
- XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
+# define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \
+ XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
#endif /* XML_DTD */
/* This is used for performing a 2nd-level tokenization on the content
of a literal that has already been returned by XmlTok.
*/
-#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
+#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
(((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
-#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
- XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
-
-#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
- XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
+#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
+ XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
-#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
+#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
+ XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
-#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
+#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
(((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
-#define XmlNameLength(enc, ptr) \
- (((enc)->nameLength)(enc, ptr))
+#define XmlNameLength(enc, ptr) (((enc)->nameLength)(enc, ptr))
-#define XmlSkipS(enc, ptr) \
- (((enc)->skipS)(enc, ptr))
+#define XmlSkipS(enc, ptr) (((enc)->skipS)(enc, ptr))
-#define XmlGetAttributes(enc, ptr, attsMax, atts) \
+#define XmlGetAttributes(enc, ptr, attsMax, atts) \
(((enc)->getAtts)(enc, ptr, attsMax, atts))
-#define XmlCharRefNumber(enc, ptr) \
- (((enc)->charRefNumber)(enc, ptr))
+#define XmlCharRefNumber(enc, ptr) (((enc)->charRefNumber)(enc, ptr))
-#define XmlPredefinedEntityName(enc, ptr, end) \
+#define XmlPredefinedEntityName(enc, ptr, end) \
(((enc)->predefinedEntityName)(enc, ptr, end))
-#define XmlUpdatePosition(enc, ptr, end, pos) \
+#define XmlUpdatePosition(enc, ptr, end, pos) \
(((enc)->updatePosition)(enc, ptr, end, pos))
-#define XmlIsPublicId(enc, ptr, end, badPtr) \
+#define XmlIsPublicId(enc, ptr, end, badPtr) \
(((enc)->isPublicId)(enc, ptr, end, badPtr))
-#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
+#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
-#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
+#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
typedef struct {
@@ -269,16 +279,11 @@ typedef struct {
const ENCODING **encPtr;
} INIT_ENCODING;
-int XmlParseXmlDecl(int isGeneralTextEntity,
- const ENCODING *enc,
- const char *ptr,
- const char *end,
- const char **badPtr,
- const char **versionPtr,
- const char **versionEndPtr,
+int XmlParseXmlDecl(int isGeneralTextEntity, const ENCODING *enc,
+ const char *ptr, const char *end, const char **badPtr,
+ const char **versionPtr, const char **versionEndPtr,
const char **encodingNamePtr,
- const ENCODING **namedEncodingPtr,
- int *standalonePtr);
+ const ENCODING **namedEncodingPtr, int *standalonePtr);
int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
const ENCODING *XmlGetUtf8InternalEncoding(void);
@@ -287,34 +292,22 @@ int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf);
int XmlSizeOfUnknownEncoding(void);
+typedef int(XMLCALL *CONVERTER)(void *userData, const char *p);
-typedef int (XMLCALL *CONVERTER) (void *userData, const char *p);
-
-ENCODING *
-XmlInitUnknownEncoding(void *mem,
- int *table,
- CONVERTER convert,
- void *userData);
+ENCODING *XmlInitUnknownEncoding(void *mem, int *table, CONVERTER convert,
+ void *userData);
-int XmlParseXmlDeclNS(int isGeneralTextEntity,
- const ENCODING *enc,
- const char *ptr,
- const char *end,
- const char **badPtr,
- const char **versionPtr,
- const char **versionEndPtr,
+int XmlParseXmlDeclNS(int isGeneralTextEntity, const ENCODING *enc,
+ const char *ptr, const char *end, const char **badPtr,
+ const char **versionPtr, const char **versionEndPtr,
const char **encodingNamePtr,
- const ENCODING **namedEncodingPtr,
- int *standalonePtr);
+ const ENCODING **namedEncodingPtr, int *standalonePtr);
int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
const ENCODING *XmlGetUtf8InternalEncodingNS(void);
const ENCODING *XmlGetUtf16InternalEncodingNS(void);
-ENCODING *
-XmlInitUnknownEncodingNS(void *mem,
- int *table,
- CONVERTER convert,
- void *userData);
+ENCODING *XmlInitUnknownEncodingNS(void *mem, int *table, CONVERTER convert,
+ void *userData);
#ifdef __cplusplus
}
#endif
diff --git a/Utilities/cmexpat/lib/xmltok_impl.c b/Utilities/cmexpat/lib/xmltok_impl.c
index 4fa1ff679..c209221cd 100644
--- a/Utilities/cmexpat/lib/xmltok_impl.c
+++ b/Utilities/cmexpat/lib/xmltok_impl.c
@@ -1,132 +1,155 @@
-/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
+/* This file is included!
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/* This file is included! */
#ifdef XML_TOK_IMPL_C
-#ifndef IS_INVALID_CHAR
-#define IS_INVALID_CHAR(enc, ptr, n) (0)
-#endif
+# ifndef IS_INVALID_CHAR
+# define IS_INVALID_CHAR(enc, ptr, n) (0)
+# endif
-#define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \
- case BT_LEAD ## n: \
- if (end - ptr < n) \
- return XML_TOK_PARTIAL_CHAR; \
- if (IS_INVALID_CHAR(enc, ptr, n)) { \
- *(nextTokPtr) = (ptr); \
- return XML_TOK_INVALID; \
- } \
- ptr += n; \
- break;
+# define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \
+ case BT_LEAD##n: \
+ if (end - ptr < n) \
+ return XML_TOK_PARTIAL_CHAR; \
+ if (IS_INVALID_CHAR(enc, ptr, n)) { \
+ *(nextTokPtr) = (ptr); \
+ return XML_TOK_INVALID; \
+ } \
+ ptr += n; \
+ break;
-#define INVALID_CASES(ptr, nextTokPtr) \
- INVALID_LEAD_CASE(2, ptr, nextTokPtr) \
- INVALID_LEAD_CASE(3, ptr, nextTokPtr) \
- INVALID_LEAD_CASE(4, ptr, nextTokPtr) \
- case BT_NONXML: \
- case BT_MALFORM: \
- case BT_TRAIL: \
- *(nextTokPtr) = (ptr); \
+# define INVALID_CASES(ptr, nextTokPtr) \
+ INVALID_LEAD_CASE(2, ptr, nextTokPtr) \
+ INVALID_LEAD_CASE(3, ptr, nextTokPtr) \
+ INVALID_LEAD_CASE(4, ptr, nextTokPtr) \
+ case BT_NONXML: \
+ case BT_MALFORM: \
+ case BT_TRAIL: \
+ *(nextTokPtr) = (ptr); \
return XML_TOK_INVALID;
-#define CHECK_NAME_CASE(n, enc, ptr, end, nextTokPtr) \
- case BT_LEAD ## n: \
- if (end - ptr < n) \
- return XML_TOK_PARTIAL_CHAR; \
- if (!IS_NAME_CHAR(enc, ptr, n)) { \
- *nextTokPtr = ptr; \
- return XML_TOK_INVALID; \
- } \
- ptr += n; \
- break;
-
-#define CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) \
- case BT_NONASCII: \
- if (!IS_NAME_CHAR_MINBPC(enc, ptr)) { \
- *nextTokPtr = ptr; \
- return XML_TOK_INVALID; \
- } \
- case BT_NMSTRT: \
- case BT_HEX: \
- case BT_DIGIT: \
- case BT_NAME: \
- case BT_MINUS: \
- ptr += MINBPC(enc); \
- break; \
- CHECK_NAME_CASE(2, enc, ptr, end, nextTokPtr) \
- CHECK_NAME_CASE(3, enc, ptr, end, nextTokPtr) \
- CHECK_NAME_CASE(4, enc, ptr, end, nextTokPtr)
+# define CHECK_NAME_CASE(n, enc, ptr, end, nextTokPtr) \
+ case BT_LEAD##n: \
+ if (end - ptr < n) \
+ return XML_TOK_PARTIAL_CHAR; \
+ if (! IS_NAME_CHAR(enc, ptr, n)) { \
+ *nextTokPtr = ptr; \
+ return XML_TOK_INVALID; \
+ } \
+ ptr += n; \
+ break;
-#define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \
- case BT_LEAD ## n: \
- if (end - ptr < n) \
- return XML_TOK_PARTIAL_CHAR; \
- if (!IS_NMSTRT_CHAR(enc, ptr, n)) { \
- *nextTokPtr = ptr; \
- return XML_TOK_INVALID; \
- } \
- ptr += n; \
- break;
+# define CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) \
+ case BT_NONASCII: \
+ if (! IS_NAME_CHAR_MINBPC(enc, ptr)) { \
+ *nextTokPtr = ptr; \
+ return XML_TOK_INVALID; \
+ } \
+ /* fall through */ \
+ case BT_NMSTRT: \
+ case BT_HEX: \
+ case BT_DIGIT: \
+ case BT_NAME: \
+ case BT_MINUS: \
+ ptr += MINBPC(enc); \
+ break; \
+ CHECK_NAME_CASE(2, enc, ptr, end, nextTokPtr) \
+ CHECK_NAME_CASE(3, enc, ptr, end, nextTokPtr) \
+ CHECK_NAME_CASE(4, enc, ptr, end, nextTokPtr)
-#define CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) \
- case BT_NONASCII: \
- if (!IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { \
- *nextTokPtr = ptr; \
- return XML_TOK_INVALID; \
- } \
- case BT_NMSTRT: \
- case BT_HEX: \
- ptr += MINBPC(enc); \
- break; \
- CHECK_NMSTRT_CASE(2, enc, ptr, end, nextTokPtr) \
- CHECK_NMSTRT_CASE(3, enc, ptr, end, nextTokPtr) \
- CHECK_NMSTRT_CASE(4, enc, ptr, end, nextTokPtr)
+# define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \
+ case BT_LEAD##n: \
+ if (end - ptr < n) \
+ return XML_TOK_PARTIAL_CHAR; \
+ if (! IS_NMSTRT_CHAR(enc, ptr, n)) { \
+ *nextTokPtr = ptr; \
+ return XML_TOK_INVALID; \
+ } \
+ ptr += n; \
+ break;
-#ifndef PREFIX
-#define PREFIX(ident) ident
-#endif
+# define CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) \
+ case BT_NONASCII: \
+ if (! IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { \
+ *nextTokPtr = ptr; \
+ return XML_TOK_INVALID; \
+ } \
+ /* fall through */ \
+ case BT_NMSTRT: \
+ case BT_HEX: \
+ ptr += MINBPC(enc); \
+ break; \
+ CHECK_NMSTRT_CASE(2, enc, ptr, end, nextTokPtr) \
+ CHECK_NMSTRT_CASE(3, enc, ptr, end, nextTokPtr) \
+ CHECK_NMSTRT_CASE(4, enc, ptr, end, nextTokPtr)
+# ifndef PREFIX
+# define PREFIX(ident) ident
+# endif
-#define HAS_CHARS(enc, ptr, end, count) \
- (end - ptr >= count * MINBPC(enc))
+# define HAS_CHARS(enc, ptr, end, count) (end - ptr >= count * MINBPC(enc))
-#define HAS_CHAR(enc, ptr, end) \
- HAS_CHARS(enc, ptr, end, 1)
+# define HAS_CHAR(enc, ptr, end) HAS_CHARS(enc, ptr, end, 1)
-#define REQUIRE_CHARS(enc, ptr, end, count) \
- { \
- if (! HAS_CHARS(enc, ptr, end, count)) { \
- return XML_TOK_PARTIAL; \
- } \
+# define REQUIRE_CHARS(enc, ptr, end, count) \
+ { \
+ if (! HAS_CHARS(enc, ptr, end, count)) { \
+ return XML_TOK_PARTIAL; \
+ } \
}
-#define REQUIRE_CHAR(enc, ptr, end) \
- REQUIRE_CHARS(enc, ptr, end, 1)
-
+# define REQUIRE_CHAR(enc, ptr, end) REQUIRE_CHARS(enc, ptr, end, 1)
/* ptr points to character following "<!-" */
static int PTRCALL
-PREFIX(scanComment)(const ENCODING *enc, const char *ptr,
- const char *end, const char **nextTokPtr)
-{
+PREFIX(scanComment)(const ENCODING *enc, const char *ptr, const char *end,
+ const char **nextTokPtr) {
if (HAS_CHAR(enc, ptr, end)) {
- if (!CHAR_MATCHES(enc, ptr, ASCII_MINUS)) {
+ if (! CHAR_MATCHES(enc, ptr, ASCII_MINUS)) {
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
ptr += MINBPC(enc);
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
- INVALID_CASES(ptr, nextTokPtr)
+ INVALID_CASES(ptr, nextTokPtr)
case BT_MINUS:
ptr += MINBPC(enc);
REQUIRE_CHAR(enc, ptr, end);
if (CHAR_MATCHES(enc, ptr, ASCII_MINUS)) {
ptr += MINBPC(enc);
REQUIRE_CHAR(enc, ptr, end);
- if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
+ if (! CHAR_MATCHES(enc, ptr, ASCII_GT)) {
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
@@ -146,9 +169,8 @@ PREFIX(scanComment)(const ENCODING *enc, const char *ptr,
/* ptr points to character following "<!" */
static int PTRCALL
-PREFIX(scanDecl)(const ENCODING *enc, const char *ptr,
- const char *end, const char **nextTokPtr)
-{
+PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, const char *end,
+ const char **nextTokPtr) {
REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) {
case BT_MINUS:
@@ -170,12 +192,17 @@ PREFIX(scanDecl)(const ENCODING *enc, const char *ptr,
REQUIRE_CHARS(enc, ptr, end, 2);
/* don't allow <!ENTITY% foo "whatever"> */
switch (BYTE_TYPE(enc, ptr + MINBPC(enc))) {
- case BT_S: case BT_CR: case BT_LF: case BT_PERCNT:
+ case BT_S:
+ case BT_CR:
+ case BT_LF:
+ case BT_PERCNT:
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
/* fall through */
- case BT_S: case BT_CR: case BT_LF:
+ case BT_S:
+ case BT_CR:
+ case BT_LF:
*nextTokPtr = ptr;
return XML_TOK_DECL_OPEN;
case BT_NMSTRT:
@@ -191,12 +218,12 @@ PREFIX(scanDecl)(const ENCODING *enc, const char *ptr,
}
static int PTRCALL
-PREFIX(checkPiTarget)(const ENCODING *UNUSED_P(enc), const char *ptr,
- const char *end, int *tokPtr)
-{
+PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, const char *end,
+ int *tokPtr) {
int upper = 0;
+ UNUSED_P(enc);
*tokPtr = XML_TOK_PI;
- if (end - ptr != MINBPC(enc)*3)
+ if (end - ptr != MINBPC(enc) * 3)
return 1;
switch (BYTE_TO_ASCII(enc, ptr)) {
case ASCII_x:
@@ -236,30 +263,31 @@ PREFIX(checkPiTarget)(const ENCODING *UNUSED_P(enc), const char *ptr,
/* ptr points to character following "<?" */
static int PTRCALL
-PREFIX(scanPi)(const ENCODING *enc, const char *ptr,
- const char *end, const char **nextTokPtr)
-{
+PREFIX(scanPi)(const ENCODING *enc, const char *ptr, const char *end,
+ const char **nextTokPtr) {
int tok;
const char *target = ptr;
REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+ CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
default:
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
- case BT_S: case BT_CR: case BT_LF:
- if (!PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
+ CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+ case BT_S:
+ case BT_CR:
+ case BT_LF:
+ if (! PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
ptr += MINBPC(enc);
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
- INVALID_CASES(ptr, nextTokPtr)
+ INVALID_CASES(ptr, nextTokPtr)
case BT_QUEST:
ptr += MINBPC(enc);
REQUIRE_CHAR(enc, ptr, end);
@@ -275,7 +303,7 @@ PREFIX(scanPi)(const ENCODING *enc, const char *ptr,
}
return XML_TOK_PARTIAL;
case BT_QUEST:
- if (!PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
+ if (! PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
@@ -295,16 +323,16 @@ PREFIX(scanPi)(const ENCODING *enc, const char *ptr,
}
static int PTRCALL
-PREFIX(scanCdataSection)(const ENCODING *UNUSED_P(enc), const char *ptr,
- const char *end, const char **nextTokPtr)
-{
- static const char CDATA_LSQB[] = { ASCII_C, ASCII_D, ASCII_A,
- ASCII_T, ASCII_A, ASCII_LSQB };
+PREFIX(scanCdataSection)(const ENCODING *enc, const char *ptr, const char *end,
+ const char **nextTokPtr) {
+ static const char CDATA_LSQB[]
+ = {ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, ASCII_LSQB};
int i;
+ UNUSED_P(enc);
/* CDATA[ */
REQUIRE_CHARS(enc, ptr, end, 6);
for (i = 0; i < 6; i++, ptr += MINBPC(enc)) {
- if (!CHAR_MATCHES(enc, ptr, CDATA_LSQB[i])) {
+ if (! CHAR_MATCHES(enc, ptr, CDATA_LSQB[i])) {
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
@@ -314,9 +342,8 @@ PREFIX(scanCdataSection)(const ENCODING *UNUSED_P(enc), const char *ptr,
}
static int PTRCALL
-PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr,
- const char *end, const char **nextTokPtr)
-{
+PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *end,
+ const char **nextTokPtr) {
if (ptr >= end)
return XML_TOK_NONE;
if (MINBPC(enc) > 1) {
@@ -332,11 +359,11 @@ PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr,
case BT_RSQB:
ptr += MINBPC(enc);
REQUIRE_CHAR(enc, ptr, end);
- if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB))
+ if (! CHAR_MATCHES(enc, ptr, ASCII_RSQB))
break;
ptr += MINBPC(enc);
REQUIRE_CHAR(enc, ptr, end);
- if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
+ if (! CHAR_MATCHES(enc, ptr, ASCII_GT)) {
ptr -= MINBPC(enc);
break;
}
@@ -352,23 +379,25 @@ PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr,
case BT_LF:
*nextTokPtr = ptr + MINBPC(enc);
return XML_TOK_DATA_NEWLINE;
- INVALID_CASES(ptr, nextTokPtr)
+ INVALID_CASES(ptr, nextTokPtr)
default:
ptr += MINBPC(enc);
break;
}
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: \
- if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \
- *nextTokPtr = ptr; \
- return XML_TOK_DATA_CHARS; \
- } \
- ptr += n; \
- break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
+# define LEAD_CASE(n) \
+ case BT_LEAD##n: \
+ if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \
+ *nextTokPtr = ptr; \
+ return XML_TOK_DATA_CHARS; \
+ } \
+ ptr += n; \
+ break;
+ LEAD_CASE(2)
+ LEAD_CASE(3)
+ LEAD_CASE(4)
+# undef LEAD_CASE
case BT_NONXML:
case BT_MALFORM:
case BT_TRAIL:
@@ -389,23 +418,26 @@ PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr,
/* ptr points to character following "</" */
static int PTRCALL
-PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr,
- const char *end, const char **nextTokPtr)
-{
+PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, const char *end,
+ const char **nextTokPtr) {
REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+ CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
default:
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
- case BT_S: case BT_CR: case BT_LF:
+ CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+ case BT_S:
+ case BT_CR:
+ case BT_LF:
for (ptr += MINBPC(enc); HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) {
switch (BYTE_TYPE(enc, ptr)) {
- case BT_S: case BT_CR: case BT_LF:
+ case BT_S:
+ case BT_CR:
+ case BT_LF:
break;
case BT_GT:
*nextTokPtr = ptr + MINBPC(enc);
@@ -416,13 +448,13 @@ PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr,
}
}
return XML_TOK_PARTIAL;
-#ifdef XML_NS
+# ifdef XML_NS
case BT_COLON:
/* no need to check qname syntax here,
since end-tag must match exactly */
ptr += MINBPC(enc);
break;
-#endif
+# endif
case BT_GT:
*nextTokPtr = ptr + MINBPC(enc);
return XML_TOK_END_TAG;
@@ -437,9 +469,8 @@ PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr,
/* ptr points to character following "&#X" */
static int PTRCALL
-PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr,
- const char *end, const char **nextTokPtr)
-{
+PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, const char *end,
+ const char **nextTokPtr) {
if (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
case BT_DIGIT:
@@ -469,9 +500,8 @@ PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr,
/* ptr points to character following "&#" */
static int PTRCALL
-PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr,
- const char *end, const char **nextTokPtr)
-{
+PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, const char *end,
+ const char **nextTokPtr) {
if (HAS_CHAR(enc, ptr, end)) {
if (CHAR_MATCHES(enc, ptr, ASCII_x))
return PREFIX(scanHexCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
@@ -502,11 +532,10 @@ PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr,
static int PTRCALL
PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
+ const char **nextTokPtr) {
REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+ CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
case BT_NUM:
return PREFIX(scanCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
default:
@@ -515,7 +544,7 @@ PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end,
}
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+ CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
case BT_SEMI:
*nextTokPtr = ptr + MINBPC(enc);
return XML_TOK_ENTITY_REF;
@@ -531,15 +560,14 @@ PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end,
static int PTRCALL
PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
-#ifdef XML_NS
+ const char **nextTokPtr) {
+# ifdef XML_NS
int hadColon = 0;
-#endif
+# endif
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
-#ifdef XML_NS
+ CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+# ifdef XML_NS
case BT_COLON:
if (hadColon) {
*nextTokPtr = ptr;
@@ -549,14 +577,16 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
ptr += MINBPC(enc);
REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+ CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
default:
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
break;
-#endif
- case BT_S: case BT_CR: case BT_LF:
+# endif
+ case BT_S:
+ case BT_CR:
+ case BT_LF:
for (;;) {
int t;
@@ -575,102 +605,102 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
return XML_TOK_INVALID;
}
}
- /* fall through */
- case BT_EQUALS:
- {
- int open;
-#ifdef XML_NS
- hadColon = 0;
-#endif
- for (;;) {
- ptr += MINBPC(enc);
- REQUIRE_CHAR(enc, ptr, end);
- open = BYTE_TYPE(enc, ptr);
- if (open == BT_QUOT || open == BT_APOS)
- break;
- switch (open) {
- case BT_S:
- case BT_LF:
- case BT_CR:
- break;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
+ /* fall through */
+ case BT_EQUALS: {
+ int open;
+# ifdef XML_NS
+ hadColon = 0;
+# endif
+ for (;;) {
ptr += MINBPC(enc);
- /* in attribute value */
- for (;;) {
- int t;
- REQUIRE_CHAR(enc, ptr, end);
- t = BYTE_TYPE(enc, ptr);
- if (t == open)
- break;
- switch (t) {
+ REQUIRE_CHAR(enc, ptr, end);
+ open = BYTE_TYPE(enc, ptr);
+ if (open == BT_QUOT || open == BT_APOS)
+ break;
+ switch (open) {
+ case BT_S:
+ case BT_LF:
+ case BT_CR:
+ break;
+ default:
+ *nextTokPtr = ptr;
+ return XML_TOK_INVALID;
+ }
+ }
+ ptr += MINBPC(enc);
+ /* in attribute value */
+ for (;;) {
+ int t;
+ REQUIRE_CHAR(enc, ptr, end);
+ t = BYTE_TYPE(enc, ptr);
+ if (t == open)
+ break;
+ switch (t) {
INVALID_CASES(ptr, nextTokPtr)
- case BT_AMP:
- {
- int tok = PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, &ptr);
- if (tok <= 0) {
- if (tok == XML_TOK_INVALID)
- *nextTokPtr = ptr;
- return tok;
- }
- break;
- }
- case BT_LT:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- default:
- ptr += MINBPC(enc);
- break;
+ case BT_AMP: {
+ int tok = PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, &ptr);
+ if (tok <= 0) {
+ if (tok == XML_TOK_INVALID)
+ *nextTokPtr = ptr;
+ return tok;
}
+ break;
+ }
+ case BT_LT:
+ *nextTokPtr = ptr;
+ return XML_TOK_INVALID;
+ default:
+ ptr += MINBPC(enc);
+ break;
}
+ }
+ ptr += MINBPC(enc);
+ REQUIRE_CHAR(enc, ptr, end);
+ switch (BYTE_TYPE(enc, ptr)) {
+ case BT_S:
+ case BT_CR:
+ case BT_LF:
+ break;
+ case BT_SOL:
+ goto sol;
+ case BT_GT:
+ goto gt;
+ default:
+ *nextTokPtr = ptr;
+ return XML_TOK_INVALID;
+ }
+ /* ptr points to closing quote */
+ for (;;) {
ptr += MINBPC(enc);
REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) {
+ CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
case BT_S:
case BT_CR:
case BT_LF:
- break;
- case BT_SOL:
- goto sol;
+ continue;
case BT_GT:
- goto gt;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- /* ptr points to closing quote */
- for (;;) {
+ gt:
+ *nextTokPtr = ptr + MINBPC(enc);
+ return XML_TOK_START_TAG_WITH_ATTS;
+ case BT_SOL:
+ sol:
ptr += MINBPC(enc);
REQUIRE_CHAR(enc, ptr, end);
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
- case BT_S: case BT_CR: case BT_LF:
- continue;
- case BT_GT:
- gt:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_START_TAG_WITH_ATTS;
- case BT_SOL:
- sol:
- ptr += MINBPC(enc);
- REQUIRE_CHAR(enc, ptr, end);
- if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_EMPTY_ELEMENT_WITH_ATTS;
- default:
+ if (! CHAR_MATCHES(enc, ptr, ASCII_GT)) {
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
- break;
+ *nextTokPtr = ptr + MINBPC(enc);
+ return XML_TOK_EMPTY_ELEMENT_WITH_ATTS;
+ default:
+ *nextTokPtr = ptr;
+ return XML_TOK_INVALID;
}
break;
}
+ break;
+ }
default:
*nextTokPtr = ptr;
return XML_TOK_INVALID;
@@ -683,14 +713,13 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
static int PTRCALL
PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
-#ifdef XML_NS
+ const char **nextTokPtr) {
+# ifdef XML_NS
int hadColon;
-#endif
+# endif
REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+ CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
case BT_EXCL:
ptr += MINBPC(enc);
REQUIRE_CHAR(enc, ptr, end);
@@ -698,8 +727,7 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
case BT_MINUS:
return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr);
case BT_LSQB:
- return PREFIX(scanCdataSection)(enc, ptr + MINBPC(enc),
- end, nextTokPtr);
+ return PREFIX(scanCdataSection)(enc, ptr + MINBPC(enc), end, nextTokPtr);
}
*nextTokPtr = ptr;
return XML_TOK_INVALID;
@@ -711,14 +739,14 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
-#ifdef XML_NS
+# ifdef XML_NS
hadColon = 0;
-#endif
+# endif
/* we have a start-tag */
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
-#ifdef XML_NS
+ CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+# ifdef XML_NS
case BT_COLON:
if (hadColon) {
*nextTokPtr = ptr;
@@ -728,34 +756,37 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
ptr += MINBPC(enc);
REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+ CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
default:
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
break;
-#endif
- case BT_S: case BT_CR: case BT_LF:
- {
- ptr += MINBPC(enc);
- while (HAS_CHAR(enc, ptr, end)) {
- switch (BYTE_TYPE(enc, ptr)) {
+# endif
+ case BT_S:
+ case BT_CR:
+ case BT_LF: {
+ ptr += MINBPC(enc);
+ while (HAS_CHAR(enc, ptr, end)) {
+ switch (BYTE_TYPE(enc, ptr)) {
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
- case BT_GT:
- goto gt;
- case BT_SOL:
- goto sol;
- case BT_S: case BT_CR: case BT_LF:
- ptr += MINBPC(enc);
- continue;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- return PREFIX(scanAtts)(enc, ptr, end, nextTokPtr);
+ case BT_GT:
+ goto gt;
+ case BT_SOL:
+ goto sol;
+ case BT_S:
+ case BT_CR:
+ case BT_LF:
+ ptr += MINBPC(enc);
+ continue;
+ default:
+ *nextTokPtr = ptr;
+ return XML_TOK_INVALID;
}
- return XML_TOK_PARTIAL;
+ return PREFIX(scanAtts)(enc, ptr, end, nextTokPtr);
}
+ return XML_TOK_PARTIAL;
+ }
case BT_GT:
gt:
*nextTokPtr = ptr + MINBPC(enc);
@@ -764,7 +795,7 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
sol:
ptr += MINBPC(enc);
REQUIRE_CHAR(enc, ptr, end);
- if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
+ if (! CHAR_MATCHES(enc, ptr, ASCII_GT)) {
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
@@ -780,8 +811,7 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
static int PTRCALL
PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
+ const char **nextTokPtr) {
if (ptr >= end)
return XML_TOK_NONE;
if (MINBPC(enc) > 1) {
@@ -813,48 +843,50 @@ PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
ptr += MINBPC(enc);
if (! HAS_CHAR(enc, ptr, end))
return XML_TOK_TRAILING_RSQB;
- if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB))
+ if (! CHAR_MATCHES(enc, ptr, ASCII_RSQB))
break;
ptr += MINBPC(enc);
if (! HAS_CHAR(enc, ptr, end))
return XML_TOK_TRAILING_RSQB;
- if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
+ if (! CHAR_MATCHES(enc, ptr, ASCII_GT)) {
ptr -= MINBPC(enc);
break;
}
*nextTokPtr = ptr;
return XML_TOK_INVALID;
- INVALID_CASES(ptr, nextTokPtr)
+ INVALID_CASES(ptr, nextTokPtr)
default:
ptr += MINBPC(enc);
break;
}
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: \
- if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \
- *nextTokPtr = ptr; \
- return XML_TOK_DATA_CHARS; \
- } \
- ptr += n; \
- break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
+# define LEAD_CASE(n) \
+ case BT_LEAD##n: \
+ if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \
+ *nextTokPtr = ptr; \
+ return XML_TOK_DATA_CHARS; \
+ } \
+ ptr += n; \
+ break;
+ LEAD_CASE(2)
+ LEAD_CASE(3)
+ LEAD_CASE(4)
+# undef LEAD_CASE
case BT_RSQB:
if (HAS_CHARS(enc, ptr, end, 2)) {
- if (!CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_RSQB)) {
- ptr += MINBPC(enc);
- break;
- }
- if (HAS_CHARS(enc, ptr, end, 3)) {
- if (!CHAR_MATCHES(enc, ptr + 2*MINBPC(enc), ASCII_GT)) {
- ptr += MINBPC(enc);
- break;
- }
- *nextTokPtr = ptr + 2*MINBPC(enc);
- return XML_TOK_INVALID;
- }
+ if (! CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_RSQB)) {
+ ptr += MINBPC(enc);
+ break;
+ }
+ if (HAS_CHARS(enc, ptr, end, 3)) {
+ if (! CHAR_MATCHES(enc, ptr + 2 * MINBPC(enc), ASCII_GT)) {
+ ptr += MINBPC(enc);
+ break;
+ }
+ *nextTokPtr = ptr + 2 * MINBPC(enc);
+ return XML_TOK_INVALID;
+ }
}
/* fall through */
case BT_AMP:
@@ -879,12 +911,14 @@ PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
static int PTRCALL
PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
+ const char **nextTokPtr) {
REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
- case BT_S: case BT_LF: case BT_CR: case BT_PERCNT:
+ CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+ case BT_S:
+ case BT_LF:
+ case BT_CR:
+ case BT_PERCNT:
*nextTokPtr = ptr;
return XML_TOK_PERCENT;
default:
@@ -893,7 +927,7 @@ PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
}
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+ CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
case BT_SEMI:
*nextTokPtr = ptr + MINBPC(enc);
return XML_TOK_PARAM_ENTITY_REF;
@@ -907,20 +941,24 @@ PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
static int PTRCALL
PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
+ const char **nextTokPtr) {
REQUIRE_CHAR(enc, ptr, end);
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
+ CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
default:
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
- case BT_CR: case BT_LF: case BT_S:
- case BT_RPAR: case BT_GT: case BT_PERCNT: case BT_VERBAR:
+ CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+ case BT_CR:
+ case BT_LF:
+ case BT_S:
+ case BT_RPAR:
+ case BT_GT:
+ case BT_PERCNT:
+ case BT_VERBAR:
*nextTokPtr = ptr;
return XML_TOK_POUND_NAME;
default:
@@ -932,14 +970,12 @@ PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end,
}
static int PTRCALL
-PREFIX(scanLit)(int open, const ENCODING *enc,
- const char *ptr, const char *end,
- const char **nextTokPtr)
-{
+PREFIX(scanLit)(int open, const ENCODING *enc, const char *ptr, const char *end,
+ const char **nextTokPtr) {
while (HAS_CHAR(enc, ptr, end)) {
int t = BYTE_TYPE(enc, ptr);
switch (t) {
- INVALID_CASES(ptr, nextTokPtr)
+ INVALID_CASES(ptr, nextTokPtr)
case BT_QUOT:
case BT_APOS:
ptr += MINBPC(enc);
@@ -949,8 +985,12 @@ PREFIX(scanLit)(int open, const ENCODING *enc,
return -XML_TOK_LITERAL;
*nextTokPtr = ptr;
switch (BYTE_TYPE(enc, ptr)) {
- case BT_S: case BT_CR: case BT_LF:
- case BT_GT: case BT_PERCNT: case BT_LSQB:
+ case BT_S:
+ case BT_CR:
+ case BT_LF:
+ case BT_GT:
+ case BT_PERCNT:
+ case BT_LSQB:
return XML_TOK_LITERAL;
default:
return XML_TOK_INVALID;
@@ -965,8 +1005,7 @@ PREFIX(scanLit)(int open, const ENCODING *enc,
static int PTRCALL
PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
+ const char **nextTokPtr) {
int tok;
if (ptr >= end)
return XML_TOK_NONE;
@@ -984,27 +1023,26 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC(enc), end, nextTokPtr);
case BT_APOS:
return PREFIX(scanLit)(BT_APOS, enc, ptr + MINBPC(enc), end, nextTokPtr);
- case BT_LT:
- {
- ptr += MINBPC(enc);
- REQUIRE_CHAR(enc, ptr, end);
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_EXCL:
- return PREFIX(scanDecl)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- case BT_QUEST:
- return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- case BT_NMSTRT:
- case BT_HEX:
- case BT_NONASCII:
- case BT_LEAD2:
- case BT_LEAD3:
- case BT_LEAD4:
- *nextTokPtr = ptr - MINBPC(enc);
- return XML_TOK_INSTANCE_START;
- }
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
+ case BT_LT: {
+ ptr += MINBPC(enc);
+ REQUIRE_CHAR(enc, ptr, end);
+ switch (BYTE_TYPE(enc, ptr)) {
+ case BT_EXCL:
+ return PREFIX(scanDecl)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+ case BT_QUEST:
+ return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr);
+ case BT_NMSTRT:
+ case BT_HEX:
+ case BT_NONASCII:
+ case BT_LEAD2:
+ case BT_LEAD3:
+ case BT_LEAD4:
+ *nextTokPtr = ptr - MINBPC(enc);
+ return XML_TOK_INSTANCE_START;
}
+ *nextTokPtr = ptr;
+ return XML_TOK_INVALID;
+ }
case BT_CR:
if (ptr + MINBPC(enc) == end) {
*nextTokPtr = end;
@@ -1012,13 +1050,15 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
return -XML_TOK_PROLOG_S;
}
/* fall through */
- case BT_S: case BT_LF:
+ case BT_S:
+ case BT_LF:
for (;;) {
ptr += MINBPC(enc);
if (! HAS_CHAR(enc, ptr, end))
break;
switch (BYTE_TYPE(enc, ptr)) {
- case BT_S: case BT_LF:
+ case BT_S:
+ case BT_LF:
break;
case BT_CR:
/* don't split CR/LF pair */
@@ -1047,7 +1087,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) {
REQUIRE_CHARS(enc, ptr, end, 2);
if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_GT)) {
- *nextTokPtr = ptr + 2*MINBPC(enc);
+ *nextTokPtr = ptr + 2 * MINBPC(enc);
return XML_TOK_COND_SECT_CLOSE;
}
}
@@ -1070,8 +1110,12 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
case BT_PLUS:
*nextTokPtr = ptr + MINBPC(enc);
return XML_TOK_CLOSE_PAREN_PLUS;
- case BT_CR: case BT_LF: case BT_S:
- case BT_GT: case BT_COMMA: case BT_VERBAR:
+ case BT_CR:
+ case BT_LF:
+ case BT_S:
+ case BT_GT:
+ case BT_COMMA:
+ case BT_VERBAR:
case BT_RPAR:
*nextTokPtr = ptr;
return XML_TOK_CLOSE_PAREN;
@@ -1086,24 +1130,26 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
return XML_TOK_DECL_CLOSE;
case BT_NUM:
return PREFIX(scanPoundName)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: \
- if (end - ptr < n) \
- return XML_TOK_PARTIAL_CHAR; \
- if (IS_NMSTRT_CHAR(enc, ptr, n)) { \
- ptr += n; \
- tok = XML_TOK_NAME; \
- break; \
- } \
- if (IS_NAME_CHAR(enc, ptr, n)) { \
- ptr += n; \
- tok = XML_TOK_NMTOKEN; \
- break; \
- } \
- *nextTokPtr = ptr; \
+# define LEAD_CASE(n) \
+ case BT_LEAD##n: \
+ if (end - ptr < n) \
+ return XML_TOK_PARTIAL_CHAR; \
+ if (IS_NMSTRT_CHAR(enc, ptr, n)) { \
+ ptr += n; \
+ tok = XML_TOK_NAME; \
+ break; \
+ } \
+ if (IS_NAME_CHAR(enc, ptr, n)) { \
+ ptr += n; \
+ tok = XML_TOK_NMTOKEN; \
+ break; \
+ } \
+ *nextTokPtr = ptr; \
return XML_TOK_INVALID;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
+ LEAD_CASE(2)
+ LEAD_CASE(3)
+ LEAD_CASE(4)
+# undef LEAD_CASE
case BT_NMSTRT:
case BT_HEX:
tok = XML_TOK_NAME;
@@ -1112,9 +1158,9 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
case BT_DIGIT:
case BT_NAME:
case BT_MINUS:
-#ifdef XML_NS
+# ifdef XML_NS
case BT_COLON:
-#endif
+# endif
tok = XML_TOK_NMTOKEN;
ptr += MINBPC(enc);
break;
@@ -1136,13 +1182,19 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
}
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
- case BT_GT: case BT_RPAR: case BT_COMMA:
- case BT_VERBAR: case BT_LSQB: case BT_PERCNT:
- case BT_S: case BT_CR: case BT_LF:
+ CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+ case BT_GT:
+ case BT_RPAR:
+ case BT_COMMA:
+ case BT_VERBAR:
+ case BT_LSQB:
+ case BT_PERCNT:
+ case BT_S:
+ case BT_CR:
+ case BT_LF:
*nextTokPtr = ptr;
return tok;
-#ifdef XML_NS
+# ifdef XML_NS
case BT_COLON:
ptr += MINBPC(enc);
switch (tok) {
@@ -1150,7 +1202,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
REQUIRE_CHAR(enc, ptr, end);
tok = XML_TOK_PREFIXED_NAME;
switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
+ CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
default:
tok = XML_TOK_NMTOKEN;
break;
@@ -1161,23 +1213,23 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
break;
}
break;
-#endif
+# endif
case BT_PLUS:
- if (tok == XML_TOK_NMTOKEN) {
+ if (tok == XML_TOK_NMTOKEN) {
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
*nextTokPtr = ptr + MINBPC(enc);
return XML_TOK_NAME_PLUS;
case BT_AST:
- if (tok == XML_TOK_NMTOKEN) {
+ if (tok == XML_TOK_NMTOKEN) {
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
*nextTokPtr = ptr + MINBPC(enc);
return XML_TOK_NAME_ASTERISK;
case BT_QUEST:
- if (tok == XML_TOK_NMTOKEN) {
+ if (tok == XML_TOK_NMTOKEN) {
*nextTokPtr = ptr;
return XML_TOK_INVALID;
}
@@ -1192,9 +1244,8 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
}
static int PTRCALL
-PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr,
- const char *end, const char **nextTokPtr)
-{
+PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end,
+ const char **nextTokPtr) {
const char *start;
if (ptr >= end)
return XML_TOK_NONE;
@@ -1209,10 +1260,14 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr,
start = ptr;
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: ptr += n; break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
+# define LEAD_CASE(n) \
+ case BT_LEAD##n: \
+ ptr += n; \
+ break;
+ LEAD_CASE(2)
+ LEAD_CASE(3)
+ LEAD_CASE(4)
+# undef LEAD_CASE
case BT_AMP:
if (ptr == start)
return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
@@ -1258,9 +1313,8 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr,
}
static int PTRCALL
-PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr,
- const char *end, const char **nextTokPtr)
-{
+PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end,
+ const char **nextTokPtr) {
const char *start;
if (ptr >= end)
return XML_TOK_NONE;
@@ -1275,10 +1329,14 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr,
start = ptr;
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: ptr += n; break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
+# define LEAD_CASE(n) \
+ case BT_LEAD##n: \
+ ptr += n; \
+ break;
+ LEAD_CASE(2)
+ LEAD_CASE(3)
+ LEAD_CASE(4)
+# undef LEAD_CASE
case BT_AMP:
if (ptr == start)
return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
@@ -1286,8 +1344,7 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr,
return XML_TOK_DATA_CHARS;
case BT_PERCNT:
if (ptr == start) {
- int tok = PREFIX(scanPercent)(enc, ptr + MINBPC(enc),
- end, nextTokPtr);
+ int tok = PREFIX(scanPercent)(enc, ptr + MINBPC(enc), end, nextTokPtr);
return (tok == XML_TOK_PERCENT) ? XML_TOK_INVALID : tok;
}
*nextTokPtr = ptr;
@@ -1320,12 +1377,11 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr,
return XML_TOK_DATA_CHARS;
}
-#ifdef XML_DTD
+# ifdef XML_DTD
static int PTRCALL
-PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr,
- const char *end, const char **nextTokPtr)
-{
+PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr, const char *end,
+ const char **nextTokPtr) {
int level = 0;
if (MINBPC(enc) > 1) {
size_t n = end - ptr;
@@ -1336,7 +1392,7 @@ PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr,
}
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
- INVALID_CASES(ptr, nextTokPtr)
+ INVALID_CASES(ptr, nextTokPtr)
case BT_LT:
ptr += MINBPC(enc);
REQUIRE_CHAR(enc, ptr, end);
@@ -1373,12 +1429,11 @@ PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr,
return XML_TOK_PARTIAL;
}
-#endif /* XML_DTD */
+# endif /* XML_DTD */
static int PTRCALL
PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
- const char **badPtr)
-{
+ const char **badPtr) {
ptr += MINBPC(enc);
end -= MINBPC(enc);
for (; HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) {
@@ -1401,9 +1456,9 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
case BT_AST:
case BT_PERCNT:
case BT_NUM:
-#ifdef XML_NS
+# ifdef XML_NS
case BT_COLON:
-#endif
+# endif
break;
case BT_S:
if (CHAR_MATCHES(enc, ptr, ASCII_TAB)) {
@@ -1413,8 +1468,9 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
break;
case BT_NAME:
case BT_NMSTRT:
- if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f))
+ if (! (BYTE_TO_ASCII(enc, ptr) & ~0x7f))
break;
+ /* fall through */
default:
switch (BYTE_TO_ASCII(enc, ptr)) {
case 0x24: /* $ */
@@ -1436,9 +1492,8 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
*/
static int PTRCALL
-PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
- int attsMax, ATTRIBUTE *atts)
-{
+PREFIX(getAtts)(const ENCODING *enc, const char *ptr, int attsMax,
+ ATTRIBUTE *atts) {
enum { other, inName, inValue } state = inName;
int nAtts = 0;
int open = 0; /* defined when state == inValue;
@@ -1446,32 +1501,35 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
for (ptr += MINBPC(enc);; ptr += MINBPC(enc)) {
switch (BYTE_TYPE(enc, ptr)) {
-#define START_NAME \
- if (state == other) { \
- if (nAtts < attsMax) { \
- atts[nAtts].name = ptr; \
- atts[nAtts].normalized = 1; \
- } \
- state = inName; \
- }
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: START_NAME ptr += (n - MINBPC(enc)); break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
+# define START_NAME \
+ if (state == other) { \
+ if (nAtts < attsMax) { \
+ atts[nAtts].name = ptr; \
+ atts[nAtts].normalized = 1; \
+ } \
+ state = inName; \
+ }
+# define LEAD_CASE(n) \
+ case BT_LEAD##n: \
+ START_NAME ptr += (n - MINBPC(enc)); \
+ break;
+ LEAD_CASE(2)
+ LEAD_CASE(3)
+ LEAD_CASE(4)
+# undef LEAD_CASE
case BT_NONASCII:
case BT_NMSTRT:
case BT_HEX:
START_NAME
break;
-#undef START_NAME
+# undef START_NAME
case BT_QUOT:
if (state != inValue) {
if (nAtts < attsMax)
atts[nAtts].valuePtr = ptr + MINBPC(enc);
state = inValue;
open = BT_QUOT;
- }
- else if (open == BT_QUOT) {
+ } else if (open == BT_QUOT) {
state = other;
if (nAtts < attsMax)
atts[nAtts].valueEnd = ptr;
@@ -1484,8 +1542,7 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
atts[nAtts].valuePtr = ptr + MINBPC(enc);
state = inValue;
open = BT_APOS;
- }
- else if (open == BT_APOS) {
+ } else if (open == BT_APOS) {
state = other;
if (nAtts < attsMax)
atts[nAtts].valueEnd = ptr;
@@ -1499,16 +1556,15 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
case BT_S:
if (state == inName)
state = other;
- else if (state == inValue
- && nAtts < attsMax
- && atts[nAtts].normalized
+ else if (state == inValue && nAtts < attsMax && atts[nAtts].normalized
&& (ptr == atts[nAtts].valuePtr
|| BYTE_TO_ASCII(enc, ptr) != ASCII_SPACE
|| BYTE_TO_ASCII(enc, ptr + MINBPC(enc)) == ASCII_SPACE
|| BYTE_TYPE(enc, ptr + MINBPC(enc)) == open))
atts[nAtts].normalized = 0;
break;
- case BT_CR: case BT_LF:
+ case BT_CR:
+ case BT_LF:
/* This case ensures that the first attribute name is counted
Apart from that we could just change state on the quote. */
if (state == inName)
@@ -1529,29 +1585,44 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
}
static int PTRFASTCALL
-PREFIX(charRefNumber)(const ENCODING *UNUSED_P(enc), const char *ptr)
-{
+PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr) {
int result = 0;
/* skip &# */
- ptr += 2*MINBPC(enc);
+ UNUSED_P(enc);
+ ptr += 2 * MINBPC(enc);
if (CHAR_MATCHES(enc, ptr, ASCII_x)) {
- for (ptr += MINBPC(enc);
- !CHAR_MATCHES(enc, ptr, ASCII_SEMI);
+ for (ptr += MINBPC(enc); ! CHAR_MATCHES(enc, ptr, ASCII_SEMI);
ptr += MINBPC(enc)) {
int c = BYTE_TO_ASCII(enc, ptr);
switch (c) {
- case ASCII_0: case ASCII_1: case ASCII_2: case ASCII_3: case ASCII_4:
- case ASCII_5: case ASCII_6: case ASCII_7: case ASCII_8: case ASCII_9:
+ case ASCII_0:
+ case ASCII_1:
+ case ASCII_2:
+ case ASCII_3:
+ case ASCII_4:
+ case ASCII_5:
+ case ASCII_6:
+ case ASCII_7:
+ case ASCII_8:
+ case ASCII_9:
result <<= 4;
result |= (c - ASCII_0);
break;
- case ASCII_A: case ASCII_B: case ASCII_C:
- case ASCII_D: case ASCII_E: case ASCII_F:
+ case ASCII_A:
+ case ASCII_B:
+ case ASCII_C:
+ case ASCII_D:
+ case ASCII_E:
+ case ASCII_F:
result <<= 4;
result += 10 + (c - ASCII_A);
break;
- case ASCII_a: case ASCII_b: case ASCII_c:
- case ASCII_d: case ASCII_e: case ASCII_f:
+ case ASCII_a:
+ case ASCII_b:
+ case ASCII_c:
+ case ASCII_d:
+ case ASCII_e:
+ case ASCII_f:
result <<= 4;
result += 10 + (c - ASCII_a);
break;
@@ -1559,9 +1630,8 @@ PREFIX(charRefNumber)(const ENCODING *UNUSED_P(enc), const char *ptr)
if (result >= 0x110000)
return -1;
}
- }
- else {
- for (; !CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) {
+ } else {
+ for (; ! CHAR_MATCHES(enc, ptr, ASCII_SEMI); ptr += MINBPC(enc)) {
int c = BYTE_TO_ASCII(enc, ptr);
result *= 10;
result += (c - ASCII_0);
@@ -1573,10 +1643,10 @@ PREFIX(charRefNumber)(const ENCODING *UNUSED_P(enc), const char *ptr)
}
static int PTRCALL
-PREFIX(predefinedEntityName)(const ENCODING *UNUSED_P(enc), const char *ptr,
- const char *end)
-{
- switch ((end - ptr)/MINBPC(enc)) {
+PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr,
+ const char *end) {
+ UNUSED_P(enc);
+ switch ((end - ptr) / MINBPC(enc)) {
case 2:
if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_t)) {
switch (BYTE_TO_ASCII(enc, ptr)) {
@@ -1626,113 +1696,43 @@ PREFIX(predefinedEntityName)(const ENCODING *UNUSED_P(enc), const char *ptr,
return 0;
}
-/* This function does not appear to be called from anywhere within the
- * library code. It is used via the macro XmlSameName(), which is
- * defined but never used. Since it appears in the encoding function
- * table, removing it is not a thing to be undertaken lightly. For
- * the moment, we simply exclude it from coverage tests.
- *
- * LCOV_EXCL_START
- */
static int PTRCALL
-PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2)
-{
- for (;;) {
- switch (BYTE_TYPE(enc, ptr1)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: \
- if (*ptr1++ != *ptr2++) \
- return 0;
- LEAD_CASE(4) LEAD_CASE(3) LEAD_CASE(2)
-#undef LEAD_CASE
- /* fall through */
- if (*ptr1++ != *ptr2++)
- return 0;
- break;
- case BT_NONASCII:
- case BT_NMSTRT:
-#ifdef XML_NS
- case BT_COLON:
-#endif
- case BT_HEX:
- case BT_DIGIT:
- case BT_NAME:
- case BT_MINUS:
- if (*ptr2++ != *ptr1++)
- return 0;
- if (MINBPC(enc) > 1) {
- if (*ptr2++ != *ptr1++)
- return 0;
- if (MINBPC(enc) > 2) {
- if (*ptr2++ != *ptr1++)
- return 0;
- if (MINBPC(enc) > 3) {
- if (*ptr2++ != *ptr1++)
- return 0;
- }
- }
- }
- break;
- default:
- if (MINBPC(enc) == 1 && *ptr1 == *ptr2)
- return 1;
- switch (BYTE_TYPE(enc, ptr2)) {
- case BT_LEAD2:
- case BT_LEAD3:
- case BT_LEAD4:
- case BT_NONASCII:
- case BT_NMSTRT:
-#ifdef XML_NS
- case BT_COLON:
-#endif
- case BT_HEX:
- case BT_DIGIT:
- case BT_NAME:
- case BT_MINUS:
- return 0;
- default:
- return 1;
- }
- }
- }
- /* not reached */
-}
-/* LCOV_EXCL_STOP */
-
-static int PTRCALL
-PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1,
- const char *end1, const char *ptr2)
-{
+PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1,
+ const char *end1, const char *ptr2) {
+ UNUSED_P(enc);
for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) {
if (end1 - ptr1 < MINBPC(enc)) {
- /* This line cannot be executed. THe incoming data has already
- * been tokenized once, so imcomplete characters like this have
+ /* This line cannot be executed. The incoming data has already
+ * been tokenized once, so incomplete characters like this have
* already been eliminated from the input. Retaining the
* paranoia check is still valuable, however.
*/
return 0; /* LCOV_EXCL_LINE */
}
- if (!CHAR_MATCHES(enc, ptr1, *ptr2))
+ if (! CHAR_MATCHES(enc, ptr1, *ptr2))
return 0;
}
return ptr1 == end1;
}
static int PTRFASTCALL
-PREFIX(nameLength)(const ENCODING *enc, const char *ptr)
-{
+PREFIX(nameLength)(const ENCODING *enc, const char *ptr) {
const char *start = ptr;
for (;;) {
switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: ptr += n; break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
+# define LEAD_CASE(n) \
+ case BT_LEAD##n: \
+ ptr += n; \
+ break;
+ LEAD_CASE(2)
+ LEAD_CASE(3)
+ LEAD_CASE(4)
+# undef LEAD_CASE
case BT_NONASCII:
case BT_NMSTRT:
-#ifdef XML_NS
+# ifdef XML_NS
case BT_COLON:
-#endif
+# endif
case BT_HEX:
case BT_DIGIT:
case BT_NAME:
@@ -1745,9 +1745,8 @@ PREFIX(nameLength)(const ENCODING *enc, const char *ptr)
}
}
-static const char * PTRFASTCALL
-PREFIX(skipS)(const ENCODING *enc, const char *ptr)
-{
+static const char *PTRFASTCALL
+PREFIX(skipS)(const ENCODING *enc, const char *ptr) {
for (;;) {
switch (BYTE_TYPE(enc, ptr)) {
case BT_LF:
@@ -1762,19 +1761,18 @@ PREFIX(skipS)(const ENCODING *enc, const char *ptr)
}
static void PTRCALL
-PREFIX(updatePosition)(const ENCODING *enc,
- const char *ptr,
- const char *end,
- POSITION *pos)
-{
+PREFIX(updatePosition)(const ENCODING *enc, const char *ptr, const char *end,
+ POSITION *pos) {
while (HAS_CHAR(enc, ptr, end)) {
switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: \
- ptr += n; \
- break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
+# define LEAD_CASE(n) \
+ case BT_LEAD##n: \
+ ptr += n; \
+ break;
+ LEAD_CASE(2)
+ LEAD_CASE(3)
+ LEAD_CASE(4)
+# undef LEAD_CASE
case BT_LF:
pos->columnNumber = (XML_Size)-1;
pos->lineNumber++;
@@ -1795,12 +1793,12 @@ PREFIX(updatePosition)(const ENCODING *enc,
}
}
-#undef DO_LEAD_CASE
-#undef MULTIBYTE_CASES
-#undef INVALID_CASES
-#undef CHECK_NAME_CASE
-#undef CHECK_NAME_CASES
-#undef CHECK_NMSTRT_CASE
-#undef CHECK_NMSTRT_CASES
+# undef DO_LEAD_CASE
+# undef MULTIBYTE_CASES
+# undef INVALID_CASES
+# undef CHECK_NAME_CASE
+# undef CHECK_NAME_CASES
+# undef CHECK_NMSTRT_CASE
+# undef CHECK_NMSTRT_CASES
#endif /* XML_TOK_IMPL_C */
diff --git a/Utilities/cmexpat/lib/xmltok_impl.h b/Utilities/cmexpat/lib/xmltok_impl.h
index da0ea60a6..e925dbc7e 100644
--- a/Utilities/cmexpat/lib/xmltok_impl.h
+++ b/Utilities/cmexpat/lib/xmltok_impl.h
@@ -1,46 +1,73 @@
/*
-Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
-See the file COPYING for copying permission.
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
enum {
- BT_NONXML,
- BT_MALFORM,
- BT_LT,
- BT_AMP,
- BT_RSQB,
- BT_LEAD2,
- BT_LEAD3,
- BT_LEAD4,
- BT_TRAIL,
- BT_CR,
- BT_LF,
- BT_GT,
- BT_QUOT,
- BT_APOS,
- BT_EQUALS,
- BT_QUEST,
- BT_EXCL,
- BT_SOL,
- BT_SEMI,
- BT_NUM,
- BT_LSQB,
- BT_S,
- BT_NMSTRT,
- BT_COLON,
- BT_HEX,
- BT_DIGIT,
- BT_NAME,
- BT_MINUS,
- BT_OTHER, /* known not to be a name or name start character */
+ BT_NONXML, /* e.g. noncharacter-FFFF */
+ BT_MALFORM, /* illegal, with regard to encoding */
+ BT_LT, /* less than = "<" */
+ BT_AMP, /* ampersand = "&" */
+ BT_RSQB, /* right square bracket = "[" */
+ BT_LEAD2, /* lead byte of a 2-byte UTF-8 character */
+ BT_LEAD3, /* lead byte of a 3-byte UTF-8 character */
+ BT_LEAD4, /* lead byte of a 4-byte UTF-8 character */
+ BT_TRAIL, /* trailing unit, e.g. second 16-bit unit of a 4-byte char. */
+ BT_CR, /* carriage return = "\r" */
+ BT_LF, /* line feed = "\n" */
+ BT_GT, /* greater than = ">" */
+ BT_QUOT, /* quotation character = "\"" */
+ BT_APOS, /* aposthrophe = "'" */
+ BT_EQUALS, /* equal sign = "=" */
+ BT_QUEST, /* question mark = "?" */
+ BT_EXCL, /* exclamation mark = "!" */
+ BT_SOL, /* solidus, slash = "/" */
+ BT_SEMI, /* semicolon = ";" */
+ BT_NUM, /* number sign = "#" */
+ BT_LSQB, /* left square bracket = "[" */
+ BT_S, /* white space, e.g. "\t", " "[, "\r"] */
+ BT_NMSTRT, /* non-hex name start letter = "G".."Z" + "g".."z" + "_" */
+ BT_COLON, /* colon = ":" */
+ BT_HEX, /* hex letter = "A".."F" + "a".."f" */
+ BT_DIGIT, /* digit = "0".."9" */
+ BT_NAME, /* dot and middle dot = "." + chr(0xb7) */
+ BT_MINUS, /* minus = "-" */
+ BT_OTHER, /* known not to be a name or name start character */
BT_NONASCII, /* might be a name or name start character */
- BT_PERCNT,
- BT_LPAR,
- BT_RPAR,
- BT_AST,
- BT_PLUS,
- BT_COMMA,
- BT_VERBAR
+ BT_PERCNT, /* percent sign = "%" */
+ BT_LPAR, /* left parenthesis = "(" */
+ BT_RPAR, /* right parenthesis = "(" */
+ BT_AST, /* asterisk = "*" */
+ BT_PLUS, /* plus sign = "+" */
+ BT_COMMA, /* comma = "," */
+ BT_VERBAR /* vertical bar = "|" */
};
#include <stddef.h>
diff --git a/Utilities/cmexpat/lib/xmltok_ns.c b/Utilities/cmexpat/lib/xmltok_ns.c
index c3b88fdf4..919c74e9f 100644
--- a/Utilities/cmexpat/lib/xmltok_ns.c
+++ b/Utilities/cmexpat/lib/xmltok_ns.c
@@ -1,61 +1,79 @@
-/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
- See the file COPYING for copying permission.
+/* This file is included!
+ __ __ _
+ ___\ \/ /_ __ __ _| |_
+ / _ \\ /| '_ \ / _` | __|
+ | __// \| |_) | (_| | |_
+ \___/_/\_\ .__/ \__,_|\__|
+ |_| XML parser
+
+ Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
+ Copyright (c) 2000-2017 Expat development team
+ Licensed under the MIT license:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/* This file is included! */
#ifdef XML_TOK_NS_C
const ENCODING *
-NS(XmlGetUtf8InternalEncoding)(void)
-{
+NS(XmlGetUtf8InternalEncoding)(void) {
return &ns(internal_utf8_encoding).enc;
}
const ENCODING *
-NS(XmlGetUtf16InternalEncoding)(void)
-{
-#if BYTEORDER == 1234
+NS(XmlGetUtf16InternalEncoding)(void) {
+# if BYTEORDER == 1234
return &ns(internal_little2_encoding).enc;
-#elif BYTEORDER == 4321
+# elif BYTEORDER == 4321
return &ns(internal_big2_encoding).enc;
-#else
+# else
const short n = 1;
- return (*(const char *)&n
- ? &ns(internal_little2_encoding).enc
- : &ns(internal_big2_encoding).enc);
-#endif
+ return (*(const char *)&n ? &ns(internal_little2_encoding).enc
+ : &ns(internal_big2_encoding).enc);
+# endif
}
-static const ENCODING * const NS(encodings)[] = {
- &ns(latin1_encoding).enc,
- &ns(ascii_encoding).enc,
- &ns(utf8_encoding).enc,
- &ns(big2_encoding).enc,
- &ns(big2_encoding).enc,
- &ns(little2_encoding).enc,
- &ns(utf8_encoding).enc /* NO_ENC */
+static const ENCODING *const NS(encodings)[] = {
+ &ns(latin1_encoding).enc, &ns(ascii_encoding).enc,
+ &ns(utf8_encoding).enc, &ns(big2_encoding).enc,
+ &ns(big2_encoding).enc, &ns(little2_encoding).enc,
+ &ns(utf8_encoding).enc /* NO_ENC */
};
static int PTRCALL
NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- return initScan(NS(encodings), (const INIT_ENCODING *)enc,
- XML_PROLOG_STATE, ptr, end, nextTokPtr);
+ const char **nextTokPtr) {
+ return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE,
+ ptr, end, nextTokPtr);
}
static int PTRCALL
NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- return initScan(NS(encodings), (const INIT_ENCODING *)enc,
- XML_CONTENT_STATE, ptr, end, nextTokPtr);
+ const char **nextTokPtr) {
+ return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE,
+ ptr, end, nextTokPtr);
}
int
NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
- const char *name)
-{
+ const char *name) {
int i = getEncodingIndex(name);
if (i == UNKNOWN_ENC)
return 0;
@@ -69,9 +87,8 @@ NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
}
static const ENCODING *
-NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
-{
-#define ENCODING_MAX 128
+NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) {
+# define ENCODING_MAX 128
char buf[ENCODING_MAX];
char *p = buf;
int i;
@@ -88,28 +105,14 @@ NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
}
int
-NS(XmlParseXmlDecl)(int isGeneralTextEntity,
- const ENCODING *enc,
- const char *ptr,
- const char *end,
- const char **badPtr,
- const char **versionPtr,
- const char **versionEndPtr,
- const char **encodingName,
- const ENCODING **encoding,
- int *standalone)
-{
- return doParseXmlDecl(NS(findEncoding),
- isGeneralTextEntity,
- enc,
- ptr,
- end,
- badPtr,
- versionPtr,
- versionEndPtr,
- encodingName,
- encoding,
- standalone);
+NS(XmlParseXmlDecl)(int isGeneralTextEntity, const ENCODING *enc,
+ const char *ptr, const char *end, const char **badPtr,
+ const char **versionPtr, const char **versionEndPtr,
+ const char **encodingName, const ENCODING **encoding,
+ int *standalone) {
+ return doParseXmlDecl(NS(findEncoding), isGeneralTextEntity, enc, ptr, end,
+ badPtr, versionPtr, versionEndPtr, encodingName,
+ encoding, standalone);
}
#endif /* XML_TOK_NS_C */
diff --git a/Utilities/cmjsoncpp/CMakeLists.txt b/Utilities/cmjsoncpp/CMakeLists.txt
index bc9076e8e..764be8d55 100644
--- a/Utilities/cmjsoncpp/CMakeLists.txt
+++ b/Utilities/cmjsoncpp/CMakeLists.txt
@@ -2,18 +2,16 @@ project(JsonCpp CXX)
# Disable warnings to avoid changing 3rd party code.
if(CMAKE_CXX_COMPILER_ID MATCHES
- "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
+ "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel)$")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "PathScale")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -woffall")
endif()
set(JSONCPP_SOURCES
- src/lib_json/json_batchallocator.h
src/lib_json/json_reader.cpp
src/lib_json/json_tool.h
src/lib_json/json_value.cpp
- src/lib_json/json_valueiterator.inl
src/lib_json/json_writer.cpp
)
diff --git a/Utilities/cmjsoncpp/LICENSE b/Utilities/cmjsoncpp/LICENSE
index ca2bfe1a0..89280a6c4 100644
--- a/Utilities/cmjsoncpp/LICENSE
+++ b/Utilities/cmjsoncpp/LICENSE
@@ -2,13 +2,13 @@ The JsonCpp library's source code, including accompanying documentation,
tests and demonstration applications, are licensed under the following
conditions...
-The author (Baptiste Lepilleur) explicitly disclaims copyright in all
+Baptiste Lepilleur and The JsonCpp Authors explicitly disclaim copyright in all
jurisdictions which recognize such a disclaimer. In such jurisdictions,
this software is released into the Public Domain.
In jurisdictions which do not recognize Public Domain property (e.g. Germany as of
-2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is
-released under the terms of the MIT License (see below).
+2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur and
+The JsonCpp Authors, and is released under the terms of the MIT License (see below).
In jurisdictions which recognize Public Domain property, the user of this
software may choose to accept it either as 1) Public Domain, 2) under the
@@ -23,7 +23,7 @@ described in clear, concise terms at:
The full text of the MIT License follows:
========================================================================
-Copyright (c) 2007-2010 Baptiste Lepilleur
+Copyright (c) 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
diff --git a/Utilities/cmjsoncpp/include/json/allocator.h b/Utilities/cmjsoncpp/include/json/allocator.h
new file mode 100644
index 000000000..9562436c6
--- /dev/null
+++ b/Utilities/cmjsoncpp/include/json/allocator.h
@@ -0,0 +1,102 @@
+// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
+// Distributed under MIT license, or public domain if desired and
+// recognized in your jurisdiction.
+// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
+
+#ifndef CPPTL_JSON_ALLOCATOR_H_INCLUDED
+#define CPPTL_JSON_ALLOCATOR_H_INCLUDED
+
+#include <cstring>
+#include <memory>
+
+#if !defined(__SUNPRO_CC)
+#pragma pack(push, 8)
+#endif
+
+namespace Json {
+template<typename T>
+class SecureAllocator {
+ public:
+ // Type definitions
+ using value_type = T;
+ using pointer = T*;
+ using const_pointer = const T*;
+ using reference = T&;
+ using const_reference = const T&;
+ using size_type = std::size_t;
+ using difference_type = std::ptrdiff_t;
+
+ /**
+ * Allocate memory for N items using the standard allocator.
+ */
+ pointer allocate(size_type n) {
+ // allocate using "global operator new"
+ return static_cast<pointer>(::operator new(n * sizeof(T)));
+ }
+
+ /**
+ * Release memory which was allocated for N items at pointer P.
+ *
+ * The memory block is filled with zeroes before being released.
+ * The pointer argument is tagged as "volatile" to prevent the
+ * compiler optimizing out this critical step.
+ */
+ void deallocate(volatile pointer p, size_type n) {
+ std::memset(p, 0, n * sizeof(T));
+ // free using "global operator delete"
+ ::operator delete(p);
+ }
+
+ /**
+ * Construct an item in-place at pointer P.
+ */
+ template<typename... Args>
+ void construct(pointer p, Args&&... args) {
+ // construct using "placement new" and "perfect forwarding"
+ ::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
+ }
+
+ size_type max_size() const {
+ return size_t(-1) / sizeof(T);
+ }
+
+ pointer address( reference x ) const {
+ return std::addressof(x);
+ }
+
+ const_pointer address( const_reference x ) const {
+ return std::addressof(x);
+ }
+
+ /**
+ * Destroy an item in-place at pointer P.
+ */
+ void destroy(pointer p) {
+ // destroy using "explicit destructor"
+ p->~T();
+ }
+
+ // Boilerplate
+ SecureAllocator() {}
+ template<typename U> SecureAllocator(const SecureAllocator<U>&) {}
+ template<typename U> struct rebind { using other = SecureAllocator<U>; };
+};
+
+
+template<typename T, typename U>
+bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
+ return true;
+}
+
+template<typename T, typename U>
+bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
+ return false;
+}
+
+} //namespace Json
+
+#if !defined(__SUNPRO_CC)
+#pragma pack(pop)
+#endif
+
+#endif // CPPTL_JSON_ALLOCATOR_H_INCLUDED
diff --git a/Utilities/cmjsoncpp/include/json/assertions.h b/Utilities/cmjsoncpp/include/json/assertions.h
index 37a3ff553..f64913fbe 100644
--- a/Utilities/cmjsoncpp/include/json/assertions.h
+++ b/Utilities/cmjsoncpp/include/json/assertions.h
@@ -1,4 +1,4 @@
-// Copyright 2007-2010 Baptiste Lepilleur
+// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -11,31 +11,44 @@
#endif // if !defined(JSON_IS_AMALGAMATION)
#include <stdlib.h>
+#include <sstream>
+/** It should not be possible for a maliciously designed file to
+ * cause an abort() or seg-fault, so these macros are used only
+ * for pre-condition violations and internal logic errors.
+ */
#if JSON_USE_EXCEPTION
-#include <stdexcept>
-#define JSON_ASSERT(condition) \
- assert(condition); // @todo <= change this into an exception throw
-#define JSON_FAIL_MESSAGE(message) throw std::runtime_error(message);
+
+// @todo <= add detail about condition in exception
+# define JSON_ASSERT(condition) \
+ {if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
+
+# define JSON_FAIL_MESSAGE(message) \
+ { \
+ JSONCPP_OSTRINGSTREAM oss; oss << message; \
+ Json::throwLogicError(oss.str()); \
+ abort(); \
+ }
+
#else // JSON_USE_EXCEPTION
-#define JSON_ASSERT(condition) assert(condition);
+
+# define JSON_ASSERT(condition) assert(condition)
// The call to assert() will show the failure message in debug builds. In
-// release bugs we write to invalid memory in order to crash hard, so that a
-// debugger or crash reporter gets the chance to take over. We still call exit()
-// afterward in order to tell the compiler that this macro doesn't return.
-#define JSON_FAIL_MESSAGE(message) \
+// release builds we abort, for a core-dump or debugger.
+# define JSON_FAIL_MESSAGE(message) \
{ \
- assert(false&& message); \
- strcpy(reinterpret_cast<char*>(666), message); \
- exit(123); \
+ JSONCPP_OSTRINGSTREAM oss; oss << message; \
+ assert(false && oss.str().c_str()); \
+ abort(); \
}
+
#endif
#define JSON_ASSERT_MESSAGE(condition, message) \
if (!(condition)) { \
- JSON_FAIL_MESSAGE(message) \
+ JSON_FAIL_MESSAGE(message); \
}
#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED
diff --git a/Utilities/cmjsoncpp/include/json/config.h b/Utilities/cmjsoncpp/include/json/config.h
index 6847ceba8..2cc8462b3 100644
--- a/Utilities/cmjsoncpp/include/json/config.h
+++ b/Utilities/cmjsoncpp/include/json/config.h
@@ -1,4 +1,4 @@
-// Copyright 2007-2010 Baptiste Lepilleur
+// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -9,6 +9,10 @@
// Include KWSys Large File Support configuration.
#include <cmsys/Configure.h>
+#include <stddef.h>
+#include <string> //typedef String
+#include <stdint.h> //typedef int64_t, uint64_t
+
#if defined(_MSC_VER)
# pragma warning(push,1)
#endif
@@ -22,17 +26,6 @@
/// std::map
/// as Value container.
//# define JSON_USE_CPPTL_SMALLMAP 1
-/// If defined, indicates that Json specific container should be used
-/// (hash table & simple deque container with customizable allocator).
-/// THIS FEATURE IS STILL EXPERIMENTAL! There is know bugs: See #3177332
-//# define JSON_VALUE_USE_INTERNAL_MAP 1
-/// Force usage of standard new/malloc based allocator instead of memory pool
-/// based allocator.
-/// The memory pools allocator used optimization (initializing Value and
-/// ValueInternalLink
-/// as if it was a POD) that may cause some validation tool to report errors.
-/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.
-//# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1
// If non-zero, the library uses exceptions to report bad input instead of C
// assertion macros. The default is to use exceptions.
@@ -55,12 +48,12 @@
#ifdef JSON_IN_CPPTL
#define JSON_API CPPTL_API
#elif defined(JSON_DLL_BUILD)
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || defined(__MINGW32__)
#define JSON_API __declspec(dllexport)
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
#endif // if defined(_MSC_VER)
#elif defined(JSON_DLL)
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) || defined(__MINGW32__)
#define JSON_API __declspec(dllimport)
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
#endif // if defined(_MSC_VER)
@@ -74,26 +67,95 @@
// Storages, and 64 bits integer support is disabled.
// #define JSON_NO_INT64 1
-#if defined(_MSC_VER) && _MSC_VER <= 1200 // MSVC 6
-// Microsoft Visual Studio 6 only support conversion from __int64 to double
-// (no conversion from unsigned __int64).
-#define JSON_USE_INT64_DOUBLE_CONVERSION 1
-// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
-// characters in the debug information)
-// All projects I've ever seen with VS6 were using this globally (not bothering
-// with pragma push/pop).
-#pragma warning(disable : 4786)
-#endif // if defined(_MSC_VER) && _MSC_VER < 1200 // MSVC 6
-
-#if defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
-/// Indicates that the following function is deprecated.
-#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
+#if defined(_MSC_VER) // MSVC
+# if _MSC_VER <= 1200 // MSVC 6
+ // Microsoft Visual Studio 6 only support conversion from __int64 to double
+ // (no conversion from unsigned __int64).
+# define JSON_USE_INT64_DOUBLE_CONVERSION 1
+ // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
+ // characters in the debug information)
+ // All projects I've ever seen with VS6 were using this globally (not bothering
+ // with pragma push/pop).
+# pragma warning(disable : 4786)
+# endif // MSVC 6
+
+#endif // defined(_MSC_VER)
+
+// In c++11 the override keyword allows you to explicity define that a function
+// is intended to override the base-class version. This makes the code more
+// managable and fixes a set of common hard-to-find bugs.
+#if __cplusplus >= 201103L
+# define JSONCPP_OVERRIDE override
+# define JSONCPP_NOEXCEPT noexcept
+#elif defined(_MSC_VER) && _MSC_VER > 1600 && _MSC_VER < 1900
+# define JSONCPP_OVERRIDE override
+# define JSONCPP_NOEXCEPT throw()
+#elif defined(_MSC_VER) && _MSC_VER >= 1900
+# define JSONCPP_OVERRIDE override
+# define JSONCPP_NOEXCEPT noexcept
+#else
+# define JSONCPP_OVERRIDE
+# define JSONCPP_NOEXCEPT throw()
+#endif
+
+#ifndef JSON_HAS_RVALUE_REFERENCES
+
+#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
+#define JSON_HAS_RVALUE_REFERENCES 1
+#endif // MSVC >= 2010
+
+#ifdef __clang__
+#if __has_feature(cxx_rvalue_references)
+#define JSON_HAS_RVALUE_REFERENCES 1
+#endif // has_feature
+
+#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
+#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
+#define JSON_HAS_RVALUE_REFERENCES 1
+#endif // GXX_EXPERIMENTAL
+
+#endif // __clang__ || __GNUC__
+
+#endif // not defined JSON_HAS_RVALUE_REFERENCES
+
+#ifndef JSON_HAS_RVALUE_REFERENCES
+#define JSON_HAS_RVALUE_REFERENCES 0
#endif
+#ifdef __clang__
+# if __has_extension(attribute_deprecated_with_message)
+# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
+# endif
+#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
+# if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
+# define JSONCPP_DEPRECATED(message) __attribute__ ((deprecated(message)))
+# elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
+# define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
+# endif // GNUC version
+#elif defined(_MSC_VER) && _MSC_VER >= 1500 // MSVC 2008
+ /// Indicates that the following function is deprecated.
+# define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
+#endif // __clang__ || __GNUC__ || _MSC_VER
+
+#undef JSONCPP_DEPRECATED // no deprecations in CMake copy
#if !defined(JSONCPP_DEPRECATED)
#define JSONCPP_DEPRECATED(message)
#endif // if !defined(JSONCPP_DEPRECATED)
+#if __GNUC__ >= 6
+# define JSON_USE_INT64_DOUBLE_CONVERSION 1
+#endif
+
+#if !defined(JSON_IS_AMALGAMATION)
+
+# include "version.h"
+
+# if JSONCPP_USING_SECURE_MEMORY
+# include "allocator.h" //typedef Allocator
+# endif
+
+#endif // if !defined(JSON_IS_AMALGAMATION)
+
namespace Json {
typedef int Int;
typedef unsigned int UInt;
@@ -107,13 +169,26 @@ typedef unsigned int LargestUInt;
typedef __int64 Int64;
typedef unsigned __int64 UInt64;
#else // if defined(_MSC_VER) // Other platforms, use long long
-typedef long long int Int64;
-typedef unsigned long long int UInt64;
+typedef int64_t Int64;
+typedef uint64_t UInt64;
#endif // if defined(_MSC_VER)
typedef Int64 LargestInt;
typedef UInt64 LargestUInt;
#define JSON_HAS_INT64
#endif // if defined(JSON_NO_INT64)
+#if JSONCPP_USING_SECURE_MEMORY
+#define JSONCPP_STRING std::basic_string<char, std::char_traits<char>, Json::SecureAllocator<char> >
+#define JSONCPP_OSTRINGSTREAM std::basic_ostringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
+#define JSONCPP_OSTREAM std::basic_ostream<char, std::char_traits<char>>
+#define JSONCPP_ISTRINGSTREAM std::basic_istringstream<char, std::char_traits<char>, Json::SecureAllocator<char> >
+#define JSONCPP_ISTREAM std::istream
+#else
+#define JSONCPP_STRING std::string
+#define JSONCPP_OSTRINGSTREAM std::ostringstream
+#define JSONCPP_OSTREAM std::ostream
+#define JSONCPP_ISTRINGSTREAM std::istringstream
+#define JSONCPP_ISTREAM std::istream
+#endif // if JSONCPP_USING_SECURE_MEMORY
} // end namespace Json
#endif // JSON_CONFIG_H_INCLUDED
diff --git a/Utilities/cmjsoncpp/include/json/features.h b/Utilities/cmjsoncpp/include/json/features.h
index 1bb7bb614..365abb356 100644
--- a/Utilities/cmjsoncpp/include/json/features.h
+++ b/Utilities/cmjsoncpp/include/json/features.h
@@ -1,4 +1,4 @@
-// Copyright 2007-2010 Baptiste Lepilleur
+// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -10,6 +10,10 @@
#include "forwards.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
+#if !defined(__SUNPRO_CC)
+#pragma pack(push, 8)
+#endif
+
namespace Json {
/** \brief Configuration passed to reader and writer.
@@ -54,4 +58,8 @@ public:
} // namespace Json
+#if !defined(__SUNPRO_CC)
+#pragma pack(pop)
+#endif
+
#endif // CPPTL_JSON_FEATURES_H_INCLUDED
diff --git a/Utilities/cmjsoncpp/include/json/forwards.h b/Utilities/cmjsoncpp/include/json/forwards.h
index 84a26cd2f..70bbe191c 100644
--- a/Utilities/cmjsoncpp/include/json/forwards.h
+++ b/Utilities/cmjsoncpp/include/json/forwards.h
@@ -1,4 +1,4 @@
-// Copyright 2007-2010 Baptiste Lepilleur
+// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -31,12 +31,6 @@ class Value;
class ValueIteratorBase;
class ValueIterator;
class ValueConstIterator;
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
-class ValueMapAllocator;
-class ValueInternalLink;
-class ValueInternalArray;
-class ValueInternalMap;
-#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
} // namespace Json
diff --git a/Utilities/cmjsoncpp/include/json/json.h b/Utilities/cmjsoncpp/include/json/json.h
index f89bc6270..59646723b 100644
--- a/Utilities/cmjsoncpp/include/json/json.h
+++ b/Utilities/cmjsoncpp/include/json/json.h
@@ -1,4 +1,4 @@
-// Copyright 2007-2010 Baptiste Lepilleur
+// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
diff --git a/Utilities/cmjsoncpp/include/json/reader.h b/Utilities/cmjsoncpp/include/json/reader.h
index 95237d168..667246a0b 100644
--- a/Utilities/cmjsoncpp/include/json/reader.h
+++ b/Utilities/cmjsoncpp/include/json/reader.h
@@ -1,4 +1,4 @@
-// Copyright 2007-2010 Baptiste Lepilleur
+// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -14,6 +14,7 @@
#include <iosfwd>
#include <stack>
#include <string>
+#include <istream>
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
// be used by...
@@ -22,13 +23,18 @@
#pragma warning(disable : 4251)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
+#if !defined(__SUNPRO_CC)
+#pragma pack(push, 8)
+#endif
+
namespace Json {
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
*Value.
*
+ * deprecated Use CharReader and CharReaderBuilder.
*/
-class JSON_API Reader {
+class JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead") JSON_API Reader {
public:
typedef char Char;
typedef const Char* Location;
@@ -40,9 +46,9 @@ public:
*
*/
struct StructuredError {
- size_t offset_start;
- size_t offset_limit;
- std::string message;
+ ptrdiff_t offset_start;
+ ptrdiff_t offset_limit;
+ JSONCPP_STRING message;
};
/** \brief Constructs a Reader allowing all features
@@ -78,7 +84,7 @@ public:
document to read.
* \param endDoc Pointer on the end of the UTF-8 encoded string of the
document to read.
- \ Must be >= beginDoc.
+ * Must be >= beginDoc.
* \param root [out] Contains the root value of the document if it was
* successfully parsed.
* \param collectComments \c true to collect comment and allow writing them
@@ -97,7 +103,7 @@ public:
/// \brief Parse from input stream.
/// \see Json::operator>>(std::istream&, Json::Value&).
- bool parse(std::istream& is, Value& root, bool collectComments = true);
+ bool parse(JSONCPP_ISTREAM& is, Value& root, bool collectComments = true);
/** \brief Returns a user friendly string that list errors in the parsed
* document.
@@ -106,8 +112,10 @@ public:
* the parsed document. An empty string is returned if no error
* occurred
* during parsing.
+ * deprecated Use getFormattedErrorMessages() instead (typo fix).
*/
- std::string getFormatedErrorMessages() const;
+ JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
+ JSONCPP_STRING getFormatedErrorMessages() const;
/** \brief Returns a user friendly string that list errors in the parsed
* document.
@@ -117,7 +125,7 @@ public:
* occurred
* during parsing.
*/
- std::string getFormattedErrorMessages() const;
+ JSONCPP_STRING getFormattedErrorMessages() const;
/** \brief Returns a vector of structured erros encounted while parsing.
* \return A (possibly empty) vector of StructuredError objects. Currently
@@ -134,7 +142,7 @@ public:
* \return \c true if the error was successfully added, \c false if the
* Value offset exceeds the document size.
*/
- bool pushError(const Value& value, const std::string& message);
+ bool pushError(const Value& value, const JSONCPP_STRING& message);
/** \brief Add a semantic error message with extra context.
* \param value JSON Value location associated with the error
@@ -143,7 +151,7 @@ public:
* \return \c true if the error was successfully added, \c false if either
* Value offset exceeds the document size.
*/
- bool pushError(const Value& value, const std::string& message, const Value& extra);
+ bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra);
/** \brief Return whether there are any errors.
* \return \c true if there are no errors to report \c false if
@@ -179,13 +187,12 @@ private:
class ErrorInfo {
public:
Token token_;
- std::string message_;
+ JSONCPP_STRING message_;
Location extra_;
};
typedef std::deque<ErrorInfo> Errors;
- bool expectToken(TokenType type, Token& token, const char* message);
bool readToken(Token& token);
void skipSpaces();
bool match(Location pattern, int patternLength);
@@ -200,7 +207,7 @@ private:
bool decodeNumber(Token& token);
bool decodeNumber(Token& token, Value& decoded);
bool decodeString(Token& token);
- bool decodeString(Token& token, std::string& decoded);
+ bool decodeString(Token& token, JSONCPP_STRING& decoded);
bool decodeDouble(Token& token);
bool decodeDouble(Token& token, Value& decoded);
bool decodeUnicodeCodePoint(Token& token,
@@ -211,9 +218,9 @@ private:
Location& current,
Location end,
unsigned int& unicode);
- bool addError(const std::string& message, Token& token, Location extra = 0);
+ bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0);
bool recoverFromError(TokenType skipUntilToken);
- bool addErrorAndRecover(const std::string& message,
+ bool addErrorAndRecover(const JSONCPP_STRING& message,
Token& token,
TokenType skipUntilToken);
void skipUntilSpace();
@@ -221,24 +228,154 @@ private:
Char getNextChar();
void
getLocationLineAndColumn(Location location, int& line, int& column) const;
- std::string getLocationLineAndColumn(Location location) const;
+ JSONCPP_STRING getLocationLineAndColumn(Location location) const;
void addComment(Location begin, Location end, CommentPlacement placement);
void skipCommentTokens(Token& token);
+ static bool containsNewLine(Location begin, Location end);
+ static JSONCPP_STRING normalizeEOL(Location begin, Location end);
+
typedef std::stack<Value*> Nodes;
Nodes nodes_;
Errors errors_;
- std::string document_;
+ JSONCPP_STRING document_;
Location begin_;
Location end_;
Location current_;
Location lastValueEnd_;
Value* lastValue_;
- std::string commentsBefore_;
+ JSONCPP_STRING commentsBefore_;
Features features_;
bool collectComments_;
+}; // Reader
+
+/** Interface for reading JSON from a char array.
+ */
+class JSON_API CharReader {
+public:
+ virtual ~CharReader() {}
+ /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
+ document.
+ * The document must be a UTF-8 encoded string containing the document to read.
+ *
+ * \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the
+ document to read.
+ * \param endDoc Pointer on the end of the UTF-8 encoded string of the
+ document to read.
+ * Must be >= beginDoc.
+ * \param root [out] Contains the root value of the document if it was
+ * successfully parsed.
+ * \param errs [out] Formatted error messages (if not NULL)
+ * a user friendly string that lists errors in the parsed
+ * document.
+ * \return \c true if the document was successfully parsed, \c false if an
+ error occurred.
+ */
+ virtual bool parse(
+ char const* beginDoc, char const* endDoc,
+ Value* root, JSONCPP_STRING* errs) = 0;
+
+ class JSON_API Factory {
+ public:
+ virtual ~Factory() {}
+ /** \brief Allocate a CharReader via operator new().
+ * \throw std::exception if something goes wrong (e.g. invalid settings)
+ */
+ virtual CharReader* newCharReader() const = 0;
+ }; // Factory
+}; // CharReader
+
+/** \brief Build a CharReader implementation.
+
+Usage:
+\code
+ using namespace Json;
+ CharReaderBuilder builder;
+ builder["collectComments"] = false;
+ Value value;
+ JSONCPP_STRING errs;
+ bool ok = parseFromStream(builder, std::cin, &value, &errs);
+\endcode
+*/
+class JSON_API CharReaderBuilder : public CharReader::Factory {
+public:
+ // Note: We use a Json::Value so that we can add data-members to this class
+ // without a major version bump.
+ /** Configuration of this builder.
+ These are case-sensitive.
+ Available settings (case-sensitive):
+ - `"collectComments": false or true`
+ - true to collect comment and allow writing them
+ back during serialization, false to discard comments.
+ This parameter is ignored if allowComments is false.
+ - `"allowComments": false or true`
+ - true if comments are allowed.
+ - `"strictRoot": false or true`
+ - true if root must be either an array or an object value
+ - `"allowDroppedNullPlaceholders": false or true`
+ - true if dropped null placeholders are allowed. (See StreamWriterBuilder.)
+ - `"allowNumericKeys": false or true`
+ - true if numeric object keys are allowed.
+ - `"allowSingleQuotes": false or true`
+ - true if '' are allowed for strings (both keys and values)
+ - `"stackLimit": integer`
+ - Exceeding stackLimit (recursive depth of `readValue()`) will
+ cause an exception.
+ - This is a security issue (seg-faults caused by deeply nested JSON),
+ so the default is low.
+ - `"failIfExtra": false or true`
+ - If true, `parse()` returns false when extra non-whitespace trails
+ the JSON value in the input string.
+ - `"rejectDupKeys": false or true`
+ - If true, `parse()` returns false when a key is duplicated within an object.
+ - `"allowSpecialFloats": false or true`
+ - If true, special float values (NaNs and infinities) are allowed
+ and their values are lossfree restorable.
+
+ You can examine 'settings_` yourself
+ to see the defaults. You can also write and read them just like any
+ JSON Value.
+ \sa setDefaults()
+ */
+ Json::Value settings_;
+
+ CharReaderBuilder();
+ ~CharReaderBuilder() JSONCPP_OVERRIDE;
+
+ CharReader* newCharReader() const JSONCPP_OVERRIDE;
+
+ /** \return true if 'settings' are legal and consistent;
+ * otherwise, indicate bad settings via 'invalid'.
+ */
+ bool validate(Json::Value* invalid) const;
+
+ /** A simple way to update a specific setting.
+ */
+ Value& operator[](JSONCPP_STRING key);
+
+ /** Called by ctor, but you can use this to reset settings_.
+ * \pre 'settings' != NULL (but Json::null is fine)
+ * \remark Defaults:
+ * snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
+ */
+ static void setDefaults(Json::Value* settings);
+ /** Same as old Features::strictMode().
+ * \pre 'settings' != NULL (but Json::null is fine)
+ * \remark Defaults:
+ * snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
+ */
+ static void strictMode(Json::Value* settings);
};
+/** Consume entire stream and use its begin/end.
+ * Someday we might have a real StreamReader, but for now this
+ * is convenient.
+ */
+bool JSON_API parseFromStream(
+ CharReader::Factory const&,
+ JSONCPP_ISTREAM&,
+ Value* root, std::string* errs);
+
/** \brief Read from 'sin' into 'root'.
Always keep comments from the input JSON.
@@ -263,10 +400,14 @@ private:
\throw std::exception on parse error.
\see Json::operator<<()
*/
-JSON_API std::istream& operator>>(std::istream&, Value&);
+JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
} // namespace Json
+#if !defined(__SUNPRO_CC)
+#pragma pack(pop)
+#endif
+
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(pop)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
diff --git a/Utilities/cmjsoncpp/include/json/value.h b/Utilities/cmjsoncpp/include/json/value.h
index 197a85614..7b90c5a1a 100644
--- a/Utilities/cmjsoncpp/include/json/value.h
+++ b/Utilities/cmjsoncpp/include/json/value.h
@@ -1,4 +1,4 @@
-// Copyright 2007-2010 Baptiste Lepilleur
+// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -11,6 +11,7 @@
#endif // if !defined(JSON_IS_AMALGAMATION)
#include <string>
#include <vector>
+#include <exception>
#ifndef JSON_USE_CPPTL_SMALLMAP
#include <map>
@@ -21,6 +22,19 @@
#include <cpptl/forwards.h>
#endif
+//Conditional NORETURN attribute on the throw functions would:
+// a) suppress false positives from static code analysis
+// b) possibly improve optimization opportunities.
+#if !defined(JSONCPP_NORETURN)
+# if defined(_MSC_VER)
+# define JSONCPP_NORETURN __declspec(noreturn)
+# elif defined(__GNUC__)
+# define JSONCPP_NORETURN __attribute__ ((__noreturn__))
+# else
+# define JSONCPP_NORETURN
+# endif
+#endif
+
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
// be used by...
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
@@ -28,10 +42,54 @@
#pragma warning(disable : 4251)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
+#if !defined(__SUNPRO_CC)
+#pragma pack(push, 8)
+#endif
+
/** \brief JSON (JavaScript Object Notation).
*/
namespace Json {
+/** Base class for all exceptions we throw.
+ *
+ * We use nothing but these internally. Of course, STL can throw others.
+ */
+class JSON_API Exception : public std::exception {
+public:
+ Exception(JSONCPP_STRING const& msg);
+ ~Exception() JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
+ char const* what() const JSONCPP_NOEXCEPT JSONCPP_OVERRIDE;
+protected:
+ JSONCPP_STRING msg_;
+};
+
+/** Exceptions which the user cannot easily avoid.
+ *
+ * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
+ *
+ * \remark derived from Json::Exception
+ */
+class JSON_API RuntimeError : public Exception {
+public:
+ RuntimeError(JSONCPP_STRING const& msg);
+};
+
+/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
+ *
+ * These are precondition-violations (user bugs) and internal errors (our bugs).
+ *
+ * \remark derived from Json::Exception
+ */
+class JSON_API LogicError : public Exception {
+public:
+ LogicError(JSONCPP_STRING const& msg);
+};
+
+/// used internally
+JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg);
+/// used internally
+JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg);
+
/** \brief Type of the value held by a Value object.
*/
enum ValueType {
@@ -74,14 +132,14 @@ enum CommentPlacement {
*/
class JSON_API StaticString {
public:
- explicit StaticString(const char* czstring) : str_(czstring) {}
+ explicit StaticString(const char* czstring) : c_str_(czstring) {}
- operator const char*() const { return str_; }
+ operator const char*() const { return c_str_; }
- const char* c_str() const { return str_; }
+ const char* c_str() const { return c_str_; }
private:
- const char* str_;
+ const char* c_str_;
};
/** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
@@ -99,28 +157,29 @@ private:
* The type of the held value is represented by a #ValueType and
* can be obtained using type().
*
- * values of an #objectValue or #arrayValue can be accessed using operator[]()
- *methods.
- * Non const methods will automatically create the a #nullValue element
+ * Values of an #objectValue or #arrayValue can be accessed using operator[]()
+ * methods.
+ * Non-const methods will automatically create the a #nullValue element
* if it does not exist.
- * The sequence of an #arrayValue will be automatically resize and initialized
+ * The sequence of an #arrayValue will be automatically resized and initialized
* with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
*
- * The get() methods can be used to obtanis default value in the case the
- *required element
- * does not exist.
+ * The get() methods can be used to obtain default value in the case the
+ * required element does not exist.
*
* It is possible to iterate over the list of a #objectValue values using
* the getMemberNames() method.
+ *
+ * \note #Value string-length fit in size_t, but keys must be < 2^30.
+ * (The reason is an implementation detail.) A #CharReader will raise an
+ * exception if a bound is exceeded to avoid security holes in your app,
+ * but the Value API does *not* check bounds. That is the responsibility
+ * of the caller.
*/
class JSON_API Value {
friend class ValueIteratorBase;
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- friend class ValueInternalLink;
- friend class ValueInternalMap;
-#endif
public:
- typedef std::vector<std::string> Members;
+ typedef std::vector<JSONCPP_STRING> Members;
typedef ValueIterator iterator;
typedef ValueConstIterator const_iterator;
typedef Json::UInt UInt;
@@ -133,7 +192,10 @@ public:
typedef Json::LargestUInt LargestUInt;
typedef Json::ArrayIndex ArrayIndex;
- static const Value& null;
+ static const Value& null; ///< We regret this reference to a global instance; prefer the simpler Value().
+ static const Value& nullRef; ///< just a kludge for binary-compatibility; same as null
+ static Value const& nullSingleton(); ///< Prefer this to null or nullRef.
+
/// Minimum signed integer value that can be stored in a Json::Value.
static const LargestInt minLargestInt;
/// Maximum signed integer value that can be stored in a Json::Value.
@@ -159,7 +221,6 @@ public:
private:
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
class CZString {
public:
enum DuplicationPolicy {
@@ -168,20 +229,39 @@ private:
duplicateOnCopy
};
CZString(ArrayIndex index);
- CZString(const char* cstr, DuplicationPolicy allocate);
- CZString(const CZString& other);
+ CZString(char const* str, unsigned length, DuplicationPolicy allocate);
+ CZString(CZString const& other);
+#if JSON_HAS_RVALUE_REFERENCES
+ CZString(CZString&& other);
+#endif
~CZString();
- CZString& operator=(CZString other);
- bool operator<(const CZString& other) const;
- bool operator==(const CZString& other) const;
+ CZString& operator=(const CZString& other);
+
+#if JSON_HAS_RVALUE_REFERENCES
+ CZString& operator=(CZString&& other);
+#endif
+
+ bool operator<(CZString const& other) const;
+ bool operator==(CZString const& other) const;
ArrayIndex index() const;
- const char* c_str() const;
+ //const char* c_str() const; ///< deprecated
+ char const* data() const;
+ unsigned length() const;
bool isStaticString() const;
private:
void swap(CZString& other);
- const char* cstr_;
- ArrayIndex index_;
+
+ struct StringStorage {
+ unsigned policy_: 2;
+ unsigned length_: 30; // 1GB max
+ };
+
+ char const* cstr_; // actually, a prefixed string, unless policy is noDup
+ union {
+ ArrayIndex index_;
+ StringStorage storage_;
+ };
};
public:
@@ -190,7 +270,6 @@ public:
#else
typedef CppTL::SmallMap<CZString, Value> ObjectValues;
#endif // ifndef JSON_USE_CPPTL_SMALLMAP
-#endif // ifndef JSON_VALUE_USE_INTERNAL_MAP
#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
public:
@@ -217,47 +296,72 @@ Json::Value obj_value(Json::objectValue); // {}
Value(UInt64 value);
#endif // if defined(JSON_HAS_INT64)
Value(double value);
- Value(const char* value);
- Value(const char* beginValue, const char* endValue);
+ Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
+ Value(const char* begin, const char* end); ///< Copy all, incl zeroes.
/** \brief Constructs a value from a static string.
* Like other value string constructor but do not duplicate the string for
* internal storage. The given string must remain alive after the call to this
* constructor.
+ * \note This works only for null-terminated strings. (We cannot change the
+ * size of this class, so we have nowhere to store the length,
+ * which might be computed later for various operations.)
+ *
* Example of usage:
* \code
- * Json::Value aValue( StaticString("some text") );
+ * static StaticString foo("some text");
+ * Json::Value aValue(foo);
* \endcode
*/
Value(const StaticString& value);
- Value(const std::string& value);
+ Value(const JSONCPP_STRING& value); ///< Copy data() til size(). Embedded zeroes too.
#ifdef JSON_USE_CPPTL
Value(const CppTL::ConstString& value);
#endif
Value(bool value);
+ /// Deep copy.
Value(const Value& other);
+#if JSON_HAS_RVALUE_REFERENCES
+ /// Move constructor
+ Value(Value&& other);
+#endif
~Value();
+ /// Deep copy, then swap(other).
+ /// \note Over-write existing comments. To preserve comments, use #swapPayload().
Value& operator=(Value other);
- /// Swap values.
- /// \note Currently, comments are intentionally not swapped, for
- /// both logic and efficiency.
+
+ /// Swap everything.
void swap(Value& other);
+ /// Swap values but leave comments and source offsets in place.
+ void swapPayload(Value& other);
+
+ /// copy everything.
+ void copy(const Value& other);
+ /// copy values but leave comments and source offsets in place.
+ void copyPayload(const Value& other);
ValueType type() const;
+ /// Compare payload only, not comments etc.
bool operator<(const Value& other) const;
bool operator<=(const Value& other) const;
bool operator>=(const Value& other) const;
bool operator>(const Value& other) const;
-
bool operator==(const Value& other) const;
bool operator!=(const Value& other) const;
-
int compare(const Value& other) const;
- const char* asCString() const;
- std::string asString() const;
+ const char* asCString() const; ///< Embedded zeroes could cause you trouble!
+#if JSONCPP_USING_SECURE_MEMORY
+ unsigned getCStringLength() const; //Allows you to understand the length of the CString
+#endif
+ JSONCPP_STRING asString() const; ///< Embedded zeroes are possible.
+ /** Get raw char* of string-value.
+ * \return false if !string. (Seg-fault if str or end are NULL.)
+ */
+ bool getString(
+ char const** begin, char const** end) const;
#ifdef JSON_USE_CPPTL
CppTL::ConstString asConstString() const;
#endif
@@ -347,20 +451,28 @@ Json::Value obj_value(Json::objectValue); // {}
/// Equivalent to jsonvalue[jsonvalue.size()] = value;
Value& append(const Value& value);
+#if JSON_HAS_RVALUE_REFERENCES
+ Value& append(Value&& value);
+#endif
+
/// Access an object value by name, create a null member if it does not exist.
+ /// \note Because of our implementation, keys are limited to 2^30 -1 chars.
+ /// Exceeding that will cause an exception.
Value& operator[](const char* key);
/// Access an object value by name, returns null if there is no member with
/// that name.
const Value& operator[](const char* key) const;
/// Access an object value by name, create a null member if it does not exist.
- Value& operator[](const std::string& key);
+ /// \param key may contain embedded nulls.
+ Value& operator[](const JSONCPP_STRING& key);
/// Access an object value by name, returns null if there is no member with
/// that name.
- const Value& operator[](const std::string& key) const;
+ /// \param key may contain embedded nulls.
+ const Value& operator[](const JSONCPP_STRING& key) const;
/** \brief Access an object value by name, create a null member if it does not
exist.
- * If the object as no entry for that name, then the member name used to store
+ * If the object has no entry for that name, then the member name used to store
* the new entry is not duplicated.
* Example of use:
* \code
@@ -378,27 +490,71 @@ Json::Value obj_value(Json::objectValue); // {}
const Value& operator[](const CppTL::ConstString& key) const;
#endif
/// Return the member named key if it exist, defaultValue otherwise.
+ /// \note deep copy
Value get(const char* key, const Value& defaultValue) const;
/// Return the member named key if it exist, defaultValue otherwise.
- Value get(const std::string& key, const Value& defaultValue) const;
+ /// \note deep copy
+ /// \note key may contain embedded nulls.
+ Value get(const char* begin, const char* end, const Value& defaultValue) const;
+ /// Return the member named key if it exist, defaultValue otherwise.
+ /// \note deep copy
+ /// \param key may contain embedded nulls.
+ Value get(const JSONCPP_STRING& key, const Value& defaultValue) const;
#ifdef JSON_USE_CPPTL
/// Return the member named key if it exist, defaultValue otherwise.
+ /// \note deep copy
Value get(const CppTL::ConstString& key, const Value& defaultValue) const;
#endif
+ /// Most general and efficient version of isMember()const, get()const,
+ /// and operator[]const
+ /// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
+ Value const* find(char const* begin, char const* end) const;
+ /// Most general and efficient version of object-mutators.
+ /// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
+ /// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
+ Value const* demand(char const* begin, char const* end);
/// \brief Remove and return the named member.
///
/// Do nothing if it did not exist.
/// \return the removed Value, or null.
/// \pre type() is objectValue or nullValue
/// \post type() is unchanged
+ /// deprecated
+ JSONCPP_DEPRECATED("")
Value removeMember(const char* key);
/// Same as removeMember(const char*)
- Value removeMember(const std::string& key);
+ /// \param key may contain embedded nulls.
+ /// deprecated
+ JSONCPP_DEPRECATED("")
+ Value removeMember(const JSONCPP_STRING& key);
+ /// Same as removeMember(const char* begin, const char* end, Value* removed),
+ /// but 'key' is null-terminated.
+ bool removeMember(const char* key, Value* removed);
+ /** \brief Remove the named map member.
+
+ Update 'removed' iff removed.
+ \param key may contain embedded nulls.
+ \return true iff removed (no exceptions)
+ */
+ bool removeMember(JSONCPP_STRING const& key, Value* removed);
+ /// Same as removeMember(JSONCPP_STRING const& key, Value* removed)
+ bool removeMember(const char* begin, const char* end, Value* removed);
+ /** \brief Remove the indexed array element.
+
+ O(n) expensive operations.
+ Update 'removed' iff removed.
+ \return true iff removed (no exceptions)
+ */
+ bool removeIndex(ArrayIndex i, Value* removed);
/// Return true if the object has a member named key.
+ /// \note 'key' must be null-terminated.
bool isMember(const char* key) const;
/// Return true if the object has a member named key.
- bool isMember(const std::string& key) const;
+ /// \param key may contain embedded nulls.
+ bool isMember(const JSONCPP_STRING& key) const;
+ /// Same as isMember(JSONCPP_STRING const& key)const
+ bool isMember(const char* begin, const char* end) const;
#ifdef JSON_USE_CPPTL
/// Return true if the object has a member named key.
bool isMember(const CppTL::ConstString& key) const;
@@ -416,15 +572,18 @@ Json::Value obj_value(Json::objectValue); // {}
// EnumValues enumValues() const;
//# endif
- /// Comments must be //... or /* ... */
+ /// deprecated Always pass len.
+ JSONCPP_DEPRECATED("Use setComment(JSONCPP_STRING const&) instead.")
void setComment(const char* comment, CommentPlacement placement);
/// Comments must be //... or /* ... */
- void setComment(const std::string& comment, CommentPlacement placement);
+ void setComment(const char* comment, size_t len, CommentPlacement placement);
+ /// Comments must be //... or /* ... */
+ void setComment(const JSONCPP_STRING& comment, CommentPlacement placement);
bool hasComment(CommentPlacement placement) const;
/// Include delimiters and embedded newlines.
- std::string getComment(CommentPlacement placement) const;
+ JSONCPP_STRING getComment(CommentPlacement placement) const;
- std::string toStyledString() const;
+ JSONCPP_STRING toStyledString() const;
const_iterator begin() const;
const_iterator end() const;
@@ -434,34 +593,22 @@ Json::Value obj_value(Json::objectValue); // {}
// Accessors for the [start, limit) range of bytes within the JSON text from
// which this value was parsed, if any.
- void setOffsetStart(size_t start);
- void setOffsetLimit(size_t limit);
- size_t getOffsetStart() const;
- size_t getOffsetLimit() const;
+ void setOffsetStart(ptrdiff_t start);
+ void setOffsetLimit(ptrdiff_t limit);
+ ptrdiff_t getOffsetStart() const;
+ ptrdiff_t getOffsetLimit() const;
private:
void initBasic(ValueType type, bool allocated = false);
- Value& resolveReference(const char* key, bool isStatic);
-
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- inline bool isItemAvailable() const { return itemIsUsed_ == 0; }
+ Value& resolveReference(const char* key);
+ Value& resolveReference(const char* key, const char* end);
- inline void setItemUsed(bool isUsed = true) { itemIsUsed_ = isUsed ? 1 : 0; }
-
- inline bool isMemberNameStatic() const { return memberNameIsStatic_ == 0; }
-
- inline void setMemberNameIsStatic(bool isStatic) {
- memberNameIsStatic_ = isStatic ? 1 : 0;
- }
-#endif // # ifdef JSON_VALUE_USE_INTERNAL_MAP
-
-private:
struct CommentInfo {
CommentInfo();
~CommentInfo();
- void setComment(const char* text);
+ void setComment(const char* text, size_t len);
char* comment_;
};
@@ -480,26 +627,18 @@ private:
LargestUInt uint_;
double real_;
bool bool_;
- char* string_;
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- ValueInternalArray* array_;
- ValueInternalMap* map_;
-#else
+ char* string_; // actually ptr to unsigned, followed by str, unless !allocated_
ObjectValues* map_;
-#endif
} value_;
ValueType type_ : 8;
- int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- unsigned int itemIsUsed_ : 1; // used by the ValueInternalMap container.
- int memberNameIsStatic_ : 1; // used by the ValueInternalMap container.
-#endif
+ unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
+ // If not allocated_, string_ must be null-terminated.
CommentInfo* comments_;
// [start, limit) byte offsets in the source JSON text from which this Value
// was extracted.
- size_t start_;
- size_t limit_;
+ ptrdiff_t start_;
+ ptrdiff_t limit_;
};
/** \brief Experimental and untested: represents an element of the "path" to
@@ -512,7 +651,7 @@ public:
PathArgument();
PathArgument(ArrayIndex index);
PathArgument(const char* key);
- PathArgument(const std::string& key);
+ PathArgument(const JSONCPP_STRING& key);
private:
enum Kind {
@@ -520,7 +659,7 @@ private:
kindIndex,
kindKey
};
- std::string key_;
+ JSONCPP_STRING key_;
ArrayIndex index_;
Kind kind_;
};
@@ -538,7 +677,7 @@ private:
*/
class JSON_API Path {
public:
- Path(const std::string& path,
+ Path(const JSONCPP_STRING& path,
const PathArgument& a1 = PathArgument(),
const PathArgument& a2 = PathArgument(),
const PathArgument& a3 = PathArgument(),
@@ -555,355 +694,16 @@ private:
typedef std::vector<const PathArgument*> InArgs;
typedef std::vector<PathArgument> Args;
- void makePath(const std::string& path, const InArgs& in);
- void addPathInArg(const std::string& path,
+ void makePath(const JSONCPP_STRING& path, const InArgs& in);
+ void addPathInArg(const JSONCPP_STRING& path,
const InArgs& in,
InArgs::const_iterator& itInArg,
PathArgument::Kind kind);
- void invalidPath(const std::string& path, int location);
+ void invalidPath(const JSONCPP_STRING& path, int location);
Args args_;
};
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
-/** \brief Allocator to customize Value internal map.
- * Below is an example of a simple implementation (default implementation
- actually
- * use memory pool for speed).
- * \code
- class DefaultValueMapAllocator : public ValueMapAllocator
- {
- public: // overridden from ValueMapAllocator
- virtual ValueInternalMap *newMap()
- {
- return new ValueInternalMap();
- }
-
- virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
- {
- return new ValueInternalMap( other );
- }
-
- virtual void destructMap( ValueInternalMap *map )
- {
- delete map;
- }
-
- virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
- {
- return new ValueInternalLink[size];
- }
-
- virtual void releaseMapBuckets( ValueInternalLink *links )
- {
- delete [] links;
- }
-
- virtual ValueInternalLink *allocateMapLink()
- {
- return new ValueInternalLink();
- }
-
- virtual void releaseMapLink( ValueInternalLink *link )
- {
- delete link;
- }
- };
- * \endcode
- */
-class JSON_API ValueMapAllocator {
-public:
- virtual ~ValueMapAllocator();
- virtual ValueInternalMap* newMap() = 0;
- virtual ValueInternalMap* newMapCopy(const ValueInternalMap& other) = 0;
- virtual void destructMap(ValueInternalMap* map) = 0;
- virtual ValueInternalLink* allocateMapBuckets(unsigned int size) = 0;
- virtual void releaseMapBuckets(ValueInternalLink* links) = 0;
- virtual ValueInternalLink* allocateMapLink() = 0;
- virtual void releaseMapLink(ValueInternalLink* link) = 0;
-};
-
-/** \brief ValueInternalMap hash-map bucket chain link (for internal use only).
- * \internal previous_ & next_ allows for bidirectional traversal.
- */
-class JSON_API ValueInternalLink {
-public:
- enum {
- itemPerLink = 6
- }; // sizeof(ValueInternalLink) = 128 on 32 bits architecture.
- enum InternalFlags {
- flagAvailable = 0,
- flagUsed = 1
- };
-
- ValueInternalLink();
-
- ~ValueInternalLink();
-
- Value items_[itemPerLink];
- char* keys_[itemPerLink];
- ValueInternalLink* previous_;
- ValueInternalLink* next_;
-};
-
-/** \brief A linked page based hash-table implementation used internally by
- *Value.
- * \internal ValueInternalMap is a tradional bucket based hash-table, with a
- *linked
- * list in each bucket to handle collision. There is an addional twist in that
- * each node of the collision linked list is a page containing a fixed amount of
- * value. This provides a better compromise between memory usage and speed.
- *
- * Each bucket is made up of a chained list of ValueInternalLink. The last
- * link of a given bucket can be found in the 'previous_' field of the following
- *bucket.
- * The last link of the last bucket is stored in tailLink_ as it has no
- *following bucket.
- * Only the last link of a bucket may contains 'available' item. The last link
- *always
- * contains at least one element unless is it the bucket one very first link.
- */
-class JSON_API ValueInternalMap {
- friend class ValueIteratorBase;
- friend class Value;
-
-public:
- typedef unsigned int HashKey;
- typedef unsigned int BucketIndex;
-
-#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
- struct IteratorState {
- IteratorState() : map_(0), link_(0), itemIndex_(0), bucketIndex_(0) {}
- ValueInternalMap* map_;
- ValueInternalLink* link_;
- BucketIndex itemIndex_;
- BucketIndex bucketIndex_;
- };
-#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-
- ValueInternalMap();
- ValueInternalMap(const ValueInternalMap& other);
- ValueInternalMap& operator=(ValueInternalMap other);
- ~ValueInternalMap();
-
- void swap(ValueInternalMap& other);
-
- BucketIndex size() const;
-
- void clear();
-
- bool reserveDelta(BucketIndex growth);
-
- bool reserve(BucketIndex newItemCount);
-
- const Value* find(const char* key) const;
-
- Value* find(const char* key);
-
- Value& resolveReference(const char* key, bool isStatic);
-
- void remove(const char* key);
-
- void doActualRemove(ValueInternalLink* link,
- BucketIndex index,
- BucketIndex bucketIndex);
-
- ValueInternalLink*& getLastLinkInBucket(BucketIndex bucketIndex);
-
- Value& setNewItem(const char* key,
- bool isStatic,
- ValueInternalLink* link,
- BucketIndex index);
-
- Value& unsafeAdd(const char* key, bool isStatic, HashKey hashedKey);
-
- HashKey hash(const char* key) const;
-
- int compare(const ValueInternalMap& other) const;
-
-private:
- void makeBeginIterator(IteratorState& it) const;
- void makeEndIterator(IteratorState& it) const;
- static bool equals(const IteratorState& x, const IteratorState& other);
- static void increment(IteratorState& iterator);
- static void incrementBucket(IteratorState& iterator);
- static void decrement(IteratorState& iterator);
- static const char* key(const IteratorState& iterator);
- static const char* key(const IteratorState& iterator, bool& isStatic);
- static Value& value(const IteratorState& iterator);
- static int distance(const IteratorState& x, const IteratorState& y);
-
-private:
- ValueInternalLink* buckets_;
- ValueInternalLink* tailLink_;
- BucketIndex bucketsSize_;
- BucketIndex itemCount_;
-};
-
-/** \brief A simplified deque implementation used internally by Value.
-* \internal
-* It is based on a list of fixed "page", each page contains a fixed number of
-*items.
-* Instead of using a linked-list, a array of pointer is used for fast item
-*look-up.
-* Look-up for an element is as follow:
-* - compute page index: pageIndex = itemIndex / itemsPerPage
-* - look-up item in page: pages_[pageIndex][itemIndex % itemsPerPage]
-*
-* Insertion is amortized constant time (only the array containing the index of
-*pointers
-* need to be reallocated when items are appended).
-*/
-class JSON_API ValueInternalArray {
- friend class Value;
- friend class ValueIteratorBase;
-
-public:
- enum {
- itemsPerPage = 8
- }; // should be a power of 2 for fast divide and modulo.
- typedef Value::ArrayIndex ArrayIndex;
- typedef unsigned int PageIndex;
-
-#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
- struct IteratorState // Must be a POD
- {
- IteratorState() : array_(0), currentPageIndex_(0), currentItemIndex_(0) {}
- ValueInternalArray* array_;
- Value** currentPageIndex_;
- unsigned int currentItemIndex_;
- };
-#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-
- ValueInternalArray();
- ValueInternalArray(const ValueInternalArray& other);
- ValueInternalArray& operator=(ValueInternalArray other);
- ~ValueInternalArray();
- void swap(ValueInternalArray& other);
-
- void clear();
- void resize(ArrayIndex newSize);
-
- Value& resolveReference(ArrayIndex index);
-
- Value* find(ArrayIndex index) const;
-
- ArrayIndex size() const;
-
- int compare(const ValueInternalArray& other) const;
-
-private:
- static bool equals(const IteratorState& x, const IteratorState& other);
- static void increment(IteratorState& iterator);
- static void decrement(IteratorState& iterator);
- static Value& dereference(const IteratorState& iterator);
- static Value& unsafeDereference(const IteratorState& iterator);
- static int distance(const IteratorState& x, const IteratorState& y);
- static ArrayIndex indexOf(const IteratorState& iterator);
- void makeBeginIterator(IteratorState& it) const;
- void makeEndIterator(IteratorState& it) const;
- void makeIterator(IteratorState& it, ArrayIndex index) const;
-
- void makeIndexValid(ArrayIndex index);
-
- Value** pages_;
- ArrayIndex size_;
- PageIndex pageCount_;
-};
-
-/** \brief Experimental: do not use. Allocator to customize Value internal
-array.
- * Below is an example of a simple implementation (actual implementation use
- * memory pool).
- \code
-class DefaultValueArrayAllocator : public ValueArrayAllocator
-{
-public: // overridden from ValueArrayAllocator
-virtual ~DefaultValueArrayAllocator()
-{
-}
-
-virtual ValueInternalArray *newArray()
-{
- return new ValueInternalArray();
-}
-
-virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )
-{
- return new ValueInternalArray( other );
-}
-
-virtual void destruct( ValueInternalArray *array )
-{
- delete array;
-}
-
-virtual void reallocateArrayPageIndex( Value **&indexes,
- ValueInternalArray::PageIndex
-&indexCount,
- ValueInternalArray::PageIndex
-minNewIndexCount )
-{
- ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;
- if ( minNewIndexCount > newIndexCount )
- newIndexCount = minNewIndexCount;
- void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );
- if ( !newIndexes )
- throw std::bad_alloc();
- indexCount = newIndexCount;
- indexes = static_cast<Value **>( newIndexes );
-}
-virtual void releaseArrayPageIndex( Value **indexes,
- ValueInternalArray::PageIndex indexCount )
-{
- if ( indexes )
- free( indexes );
-}
-
-virtual Value *allocateArrayPage()
-{
- return static_cast<Value *>( malloc( sizeof(Value) *
-ValueInternalArray::itemsPerPage ) );
-}
-
-virtual void releaseArrayPage( Value *value )
-{
- if ( value )
- free( value );
-}
-};
- \endcode
- */
-class JSON_API ValueArrayAllocator {
-public:
- virtual ~ValueArrayAllocator();
- virtual ValueInternalArray* newArray() = 0;
- virtual ValueInternalArray* newArrayCopy(const ValueInternalArray& other) = 0;
- virtual void destructArray(ValueInternalArray* array) = 0;
- /** \brief Reallocate array page index.
- * Reallocates an array of pointer on each page.
- * \param indexes [input] pointer on the current index. May be \c NULL.
- * [output] pointer on the new index of at least
- * \a minNewIndexCount pages.
- * \param indexCount [input] current number of pages in the index.
- * [output] number of page the reallocated index can handle.
- * \b MUST be >= \a minNewIndexCount.
- * \param minNewIndexCount Minimum number of page the new index must be able
- * to
- * handle.
- */
- virtual void
- reallocateArrayPageIndex(Value**& indexes,
- ValueInternalArray::PageIndex& indexCount,
- ValueInternalArray::PageIndex minNewIndexCount) = 0;
- virtual void
- releaseArrayPageIndex(Value** indexes,
- ValueInternalArray::PageIndex indexCount) = 0;
- virtual Value* allocateArrayPage() = 0;
- virtual void releaseArrayPage(Value* value) = 0;
-};
-#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
-
/** \brief base class for Value iterators.
*
*/
@@ -914,32 +714,35 @@ public:
typedef int difference_type;
typedef ValueIteratorBase SelfType;
- ValueIteratorBase();
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
- explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
-#else
- ValueIteratorBase(const ValueInternalArray::IteratorState& state);
- ValueIteratorBase(const ValueInternalMap::IteratorState& state);
-#endif
-
bool operator==(const SelfType& other) const { return isEqual(other); }
bool operator!=(const SelfType& other) const { return !isEqual(other); }
difference_type operator-(const SelfType& other) const {
- return computeDistance(other);
+ return other.computeDistance(*this);
}
/// Return either the index or the member name of the referenced value as a
/// Value.
Value key() const;
- /// Return the index of the referenced Value. -1 if it is not an arrayValue.
+ /// Return the index of the referenced Value, or -1 if it is not an arrayValue.
UInt index() const;
+ /// Return the member name of the referenced Value, or "" if it is not an
+ /// objectValue.
+ /// \note Avoid `c_str()` on result, as embedded zeroes are possible.
+ JSONCPP_STRING name() const;
+
/// Return the member name of the referenced Value. "" if it is not an
/// objectValue.
- const char* memberName() const;
+ /// deprecated This cannot be used for UTF-8 strings, since there can be embedded nulls.
+ JSONCPP_DEPRECATED("Use `key = name();` instead.")
+ char const* memberName() const;
+ /// Return the member name of the referenced Value, or NULL if it is not an
+ /// objectValue.
+ /// \note Better version than memberName(). Allows embedded nulls.
+ char const* memberName(char const** end) const;
protected:
Value& deref() const;
@@ -955,17 +758,15 @@ protected:
void copy(const SelfType& other);
private:
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
Value::ObjectValues::iterator current_;
// Indicates that iterator is for a null value.
bool isNull_;
-#else
- union {
- ValueInternalArray::IteratorState array_;
- ValueInternalMap::IteratorState map_;
- } iterator_;
- bool isArray_;
-#endif
+
+public:
+ // For some reason, BORLAND needs these at the end, rather
+ // than earlier. No idea why.
+ ValueIteratorBase();
+ explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
};
/** \brief const iterator for object and array value.
@@ -976,23 +777,19 @@ class JSON_API ValueConstIterator : public ValueIteratorBase {
public:
typedef const Value value_type;
- typedef unsigned int size_t;
- typedef int difference_type;
+ //typedef unsigned int size_t;
+ //typedef int difference_type;
typedef const Value& reference;
typedef const Value* pointer;
typedef ValueConstIterator SelfType;
ValueConstIterator();
+ ValueConstIterator(ValueIterator const& other);
private:
-/*! \internal Use by Value to create an iterator.
+/*! internal Use by Value to create an iterator.
*/
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
-#else
- ValueConstIterator(const ValueInternalArray::IteratorState& state);
- ValueConstIterator(const ValueInternalMap::IteratorState& state);
-#endif
public:
SelfType& operator=(const ValueIteratorBase& other);
@@ -1037,18 +834,13 @@ public:
typedef ValueIterator SelfType;
ValueIterator();
- ValueIterator(const ValueConstIterator& other);
+ explicit ValueIterator(const ValueConstIterator& other);
ValueIterator(const ValueIterator& other);
private:
-/*! \internal Use by Value to create an iterator.
+/*! internal Use by Value to create an iterator.
*/
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
explicit ValueIterator(const Value::ObjectValues::iterator& current);
-#else
- ValueIterator(const ValueInternalArray::IteratorState& state);
- ValueIterator(const ValueInternalMap::IteratorState& state);
-#endif
public:
SelfType& operator=(const SelfType& other);
@@ -1081,6 +873,17 @@ public:
} // namespace Json
+
+namespace std {
+/// Specialize std::swap() for Json::Value.
+template<>
+inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
+}
+
+#if !defined(__SUNPRO_CC)
+#pragma pack(pop)
+#endif
+
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(pop)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
diff --git a/Utilities/cmjsoncpp/include/json/version.h b/Utilities/cmjsoncpp/include/json/version.h
index 6fe06824d..d95396189 100644
--- a/Utilities/cmjsoncpp/include/json/version.h
+++ b/Utilities/cmjsoncpp/include/json/version.h
@@ -1,14 +1,20 @@
-// DO NOT EDIT. This file is generated by CMake from "version"
-// and "version.h.in" files.
+// DO NOT EDIT. This file (and "version") is generated by CMake.
// Run CMake configure step to update it.
#ifndef JSON_VERSION_H_INCLUDED
# define JSON_VERSION_H_INCLUDED
-# define JSONCPP_VERSION_STRING "1.0.0"
+# define JSONCPP_VERSION_STRING "1.8.2"
# define JSONCPP_VERSION_MAJOR 1
-# define JSONCPP_VERSION_MINOR 0
-# define JSONCPP_VERSION_PATCH 0
+# define JSONCPP_VERSION_MINOR 8
+# define JSONCPP_VERSION_PATCH 2
# define JSONCPP_VERSION_QUALIFIER
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
+#ifdef JSONCPP_USING_SECURE_MEMORY
+#undef JSONCPP_USING_SECURE_MEMORY
+#endif
+#define JSONCPP_USING_SECURE_MEMORY 0
+// If non-zero, the library zeroes any memory that it has allocated before
+// it frees its memory.
+
#endif // JSON_VERSION_H_INCLUDED
diff --git a/Utilities/cmjsoncpp/include/json/writer.h b/Utilities/cmjsoncpp/include/json/writer.h
index 10863b078..d3ae62b28 100644
--- a/Utilities/cmjsoncpp/include/json/writer.h
+++ b/Utilities/cmjsoncpp/include/json/writer.h
@@ -1,4 +1,4 @@
-// Copyright 2007-2010 Baptiste Lepilleur
+// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -12,6 +12,7 @@
#include <iosfwd>
#include <vector>
#include <string>
+#include <ostream>
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
// be used by...
@@ -20,17 +21,133 @@
#pragma warning(disable : 4251)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
+#if !defined(__SUNPRO_CC)
+#pragma pack(push, 8)
+#endif
+
namespace Json {
class Value;
+/**
+
+Usage:
+\code
+ using namespace Json;
+ void writeToStdout(StreamWriter::Factory const& factory, Value const& value) {
+ std::unique_ptr<StreamWriter> const writer(
+ factory.newStreamWriter());
+ writer->write(value, &std::cout);
+ std::cout << std::endl; // add lf and flush
+ }
+\endcode
+*/
+class JSON_API StreamWriter {
+protected:
+ JSONCPP_OSTREAM* sout_; // not owned; will not delete
+public:
+ StreamWriter();
+ virtual ~StreamWriter();
+ /** Write Value into document as configured in sub-class.
+ Do not take ownership of sout, but maintain a reference during function.
+ \pre sout != NULL
+ \return zero on success (For now, we always return zero, so check the stream instead.)
+ \throw std::exception possibly, depending on configuration
+ */
+ virtual int write(Value const& root, JSONCPP_OSTREAM* sout) = 0;
+
+ /** \brief A simple abstract factory.
+ */
+ class JSON_API Factory {
+ public:
+ virtual ~Factory();
+ /** \brief Allocate a CharReader via operator new().
+ * \throw std::exception if something goes wrong (e.g. invalid settings)
+ */
+ virtual StreamWriter* newStreamWriter() const = 0;
+ }; // Factory
+}; // StreamWriter
+
+/** \brief Write into stringstream, then return string, for convenience.
+ * A StreamWriter will be created from the factory, used, and then deleted.
+ */
+JSONCPP_STRING JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
+
+
+/** \brief Build a StreamWriter implementation.
+
+Usage:
+\code
+ using namespace Json;
+ Value value = ...;
+ StreamWriterBuilder builder;
+ builder["commentStyle"] = "None";
+ builder["indentation"] = " "; // or whatever you like
+ std::unique_ptr<Json::StreamWriter> writer(
+ builder.newStreamWriter());
+ writer->write(value, &std::cout);
+ std::cout << std::endl; // add lf and flush
+\endcode
+*/
+class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
+public:
+ // Note: We use a Json::Value so that we can add data-members to this class
+ // without a major version bump.
+ /** Configuration of this builder.
+ Available settings (case-sensitive):
+ - "commentStyle": "None" or "All"
+ - "indentation": "<anything>"
+ - "enableYAMLCompatibility": false or true
+ - slightly change the whitespace around colons
+ - "dropNullPlaceholders": false or true
+ - Drop the "null" string from the writer's output for nullValues.
+ Strictly speaking, this is not valid JSON. But when the output is being
+ fed to a browser's Javascript, it makes for smaller output and the
+ browser can handle the output just fine.
+ - "useSpecialFloats": false or true
+ - If true, outputs non-finite floating point values in the following way:
+ NaN values as "NaN", positive infinity as "Infinity", and negative infinity
+ as "-Infinity".
+
+ You can examine 'settings_` yourself
+ to see the defaults. You can also write and read them just like any
+ JSON Value.
+ \sa setDefaults()
+ */
+ Json::Value settings_;
+
+ StreamWriterBuilder();
+ ~StreamWriterBuilder() JSONCPP_OVERRIDE;
+
+ /**
+ * \throw std::exception if something goes wrong (e.g. invalid settings)
+ */
+ StreamWriter* newStreamWriter() const JSONCPP_OVERRIDE;
+
+ /** \return true if 'settings' are legal and consistent;
+ * otherwise, indicate bad settings via 'invalid'.
+ */
+ bool validate(Json::Value* invalid) const;
+ /** A simple way to update a specific setting.
+ */
+ Value& operator[](JSONCPP_STRING key);
+
+ /** Called by ctor, but you can use this to reset settings_.
+ * \pre 'settings' != NULL (but Json::null is fine)
+ * \remark Defaults:
+ * snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
+ */
+ static void setDefaults(Json::Value* settings);
+};
+
/** \brief Abstract class for writers.
+ * deprecated Use StreamWriter. (And really, this is an implementation detail.)
*/
-class JSON_API Writer {
+class JSONCPP_DEPRECATED("Use StreamWriter instead") JSON_API Writer {
public:
virtual ~Writer();
- virtual std::string write(const Value& root) = 0;
+ virtual JSONCPP_STRING write(const Value& root) = 0;
};
/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
@@ -40,11 +157,13 @@ public:
*consumption,
* but may be usefull to support feature such as RPC where bandwith is limited.
* \sa Reader, Value
+ * deprecated Use StreamWriterBuilder.
*/
-class JSON_API FastWriter : public Writer {
+class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API FastWriter : public Writer {
+
public:
FastWriter();
- virtual ~FastWriter() {}
+ ~FastWriter() JSONCPP_OVERRIDE {}
void enableYAMLCompatibility();
@@ -58,12 +177,12 @@ public:
void omitEndingLineFeed();
public: // overridden from Writer
- virtual std::string write(const Value& root);
+ JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
private:
void writeValue(const Value& value);
- std::string document_;
+ JSONCPP_STRING document_;
bool yamlCompatiblityEnabled_;
bool dropNullPlaceholders_;
bool omitEndingLineFeed_;
@@ -91,40 +210,41 @@ private:
*#CommentPlacement.
*
* \sa Reader, Value, Value::setComment()
+ * deprecated Use StreamWriterBuilder.
*/
-class JSON_API StyledWriter : public Writer {
+class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledWriter : public Writer {
public:
StyledWriter();
- virtual ~StyledWriter() {}
+ ~StyledWriter() JSONCPP_OVERRIDE {}
public: // overridden from Writer
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
* \param root Value to serialize.
* \return String containing the JSON document that represents the root value.
*/
- virtual std::string write(const Value& root);
+ JSONCPP_STRING write(const Value& root) JSONCPP_OVERRIDE;
private:
void writeValue(const Value& value);
void writeArrayValue(const Value& value);
bool isMultineArray(const Value& value);
- void pushValue(const std::string& value);
+ void pushValue(const JSONCPP_STRING& value);
void writeIndent();
- void writeWithIndent(const std::string& value);
+ void writeWithIndent(const JSONCPP_STRING& value);
void indent();
void unindent();
void writeCommentBeforeValue(const Value& root);
void writeCommentAfterValueOnSameLine(const Value& root);
bool hasCommentForValue(const Value& value);
- static std::string normalizeEOL(const std::string& text);
+ static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
- typedef std::vector<std::string> ChildValues;
+ typedef std::vector<JSONCPP_STRING> ChildValues;
ChildValues childValues_;
- std::string document_;
- std::string indentString_;
- int rightMargin_;
- int indentSize_;
+ JSONCPP_STRING document_;
+ JSONCPP_STRING indentString_;
+ unsigned int rightMargin_;
+ unsigned int indentSize_;
bool addChildValues_;
};
@@ -151,10 +271,14 @@ private:
#CommentPlacement.
*
* \sa Reader, Value, Value::setComment()
+ * deprecated Use StreamWriterBuilder.
*/
-class JSON_API StyledStreamWriter {
+class JSONCPP_DEPRECATED("Use StreamWriterBuilder instead") JSON_API StyledStreamWriter {
public:
- StyledStreamWriter(std::string indentation = "\t");
+/**
+ * \param indentation Each level will be indented by this amount extra.
+ */
+ StyledStreamWriter(JSONCPP_STRING indentation = "\t");
~StyledStreamWriter() {}
public:
@@ -164,48 +288,53 @@ public:
* \note There is no point in deriving from Writer, since write() should not
* return a value.
*/
- void write(std::ostream& out, const Value& root);
+ void write(JSONCPP_OSTREAM& out, const Value& root);
private:
void writeValue(const Value& value);
void writeArrayValue(const Value& value);
bool isMultineArray(const Value& value);
- void pushValue(const std::string& value);
+ void pushValue(const JSONCPP_STRING& value);
void writeIndent();
- void writeWithIndent(const std::string& value);
+ void writeWithIndent(const JSONCPP_STRING& value);
void indent();
void unindent();
void writeCommentBeforeValue(const Value& root);
void writeCommentAfterValueOnSameLine(const Value& root);
bool hasCommentForValue(const Value& value);
- static std::string normalizeEOL(const std::string& text);
+ static JSONCPP_STRING normalizeEOL(const JSONCPP_STRING& text);
- typedef std::vector<std::string> ChildValues;
+ typedef std::vector<JSONCPP_STRING> ChildValues;
ChildValues childValues_;
- std::ostream* document_;
- std::string indentString_;
- int rightMargin_;
- std::string indentation_;
- bool addChildValues_;
+ JSONCPP_OSTREAM* document_;
+ JSONCPP_STRING indentString_;
+ unsigned int rightMargin_;
+ JSONCPP_STRING indentation_;
+ bool addChildValues_ : 1;
+ bool indented_ : 1;
};
#if defined(JSON_HAS_INT64)
-std::string JSON_API valueToString(Int value);
-std::string JSON_API valueToString(UInt value);
+JSONCPP_STRING JSON_API valueToString(Int value);
+JSONCPP_STRING JSON_API valueToString(UInt value);
#endif // if defined(JSON_HAS_INT64)
-std::string JSON_API valueToString(LargestInt value);
-std::string JSON_API valueToString(LargestUInt value);
-std::string JSON_API valueToString(double value);
-std::string JSON_API valueToString(bool value);
-std::string JSON_API valueToQuotedString(const char* value);
+JSONCPP_STRING JSON_API valueToString(LargestInt value);
+JSONCPP_STRING JSON_API valueToString(LargestUInt value);
+JSONCPP_STRING JSON_API valueToString(double value);
+JSONCPP_STRING JSON_API valueToString(bool value);
+JSONCPP_STRING JSON_API valueToQuotedString(const char* value);
/// \brief Output using the StyledStreamWriter.
/// \see Json::operator>>()
-JSON_API std::ostream& operator<<(std::ostream&, const Value& root);
+JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
} // namespace Json
+#if !defined(__SUNPRO_CC)
+#pragma pack(pop)
+#endif
+
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
#pragma warning(pop)
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_batchallocator.h b/Utilities/cmjsoncpp/src/lib_json/json_batchallocator.h
deleted file mode 100644
index 2fbef7a86..000000000
--- a/Utilities/cmjsoncpp/src/lib_json/json_batchallocator.h
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-#ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED
-#define JSONCPP_BATCHALLOCATOR_H_INCLUDED
-
-#include <stdlib.h>
-#include <assert.h>
-
-#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-
-namespace Json {
-
-/* Fast memory allocator.
- *
- * This memory allocator allocates memory for a batch of object (specified by
- * the page size, the number of object in each page).
- *
- * It does not allow the destruction of a single object. All the allocated
- * objects can be destroyed at once. The memory can be either released or reused
- * for future allocation.
- *
- * The in-place new operator must be used to construct the object using the
- * pointer returned by allocate.
- */
-template <typename AllocatedType, const unsigned int objectPerAllocation>
-class BatchAllocator {
-public:
- BatchAllocator(unsigned int objectsPerPage = 255)
- : freeHead_(0), objectsPerPage_(objectsPerPage) {
- // printf( "Size: %d => %s\n", sizeof(AllocatedType),
- // typeid(AllocatedType).name() );
- assert(sizeof(AllocatedType) * objectPerAllocation >=
- sizeof(AllocatedType*)); // We must be able to store a slist in the
- // object free space.
- assert(objectsPerPage >= 16);
- batches_ = allocateBatch(0); // allocated a dummy page
- currentBatch_ = batches_;
- }
-
- ~BatchAllocator() {
- for (BatchInfo* batch = batches_; batch;) {
- BatchInfo* nextBatch = batch->next_;
- free(batch);
- batch = nextBatch;
- }
- }
-
- /// allocate space for an array of objectPerAllocation object.
- /// @warning it is the responsability of the caller to call objects
- /// constructors.
- AllocatedType* allocate() {
- if (freeHead_) // returns node from free list.
- {
- AllocatedType* object = freeHead_;
- freeHead_ = *(AllocatedType**)object;
- return object;
- }
- if (currentBatch_->used_ == currentBatch_->end_) {
- currentBatch_ = currentBatch_->next_;
- while (currentBatch_ && currentBatch_->used_ == currentBatch_->end_)
- currentBatch_ = currentBatch_->next_;
-
- if (!currentBatch_) // no free batch found, allocate a new one
- {
- currentBatch_ = allocateBatch(objectsPerPage_);
- currentBatch_->next_ = batches_; // insert at the head of the list
- batches_ = currentBatch_;
- }
- }
- AllocatedType* allocated = currentBatch_->used_;
- currentBatch_->used_ += objectPerAllocation;
- return allocated;
- }
-
- /// Release the object.
- /// @warning it is the responsability of the caller to actually destruct the
- /// object.
- void release(AllocatedType* object) {
- assert(object != 0);
- *(AllocatedType**)object = freeHead_;
- freeHead_ = object;
- }
-
-private:
- struct BatchInfo {
- BatchInfo* next_;
- AllocatedType* used_;
- AllocatedType* end_;
- AllocatedType buffer_[objectPerAllocation];
- };
-
- // disabled copy constructor and assignement operator.
- BatchAllocator(const BatchAllocator&);
- void operator=(const BatchAllocator&);
-
- static BatchInfo* allocateBatch(unsigned int objectsPerPage) {
- const unsigned int mallocSize =
- sizeof(BatchInfo) - sizeof(AllocatedType) * objectPerAllocation +
- sizeof(AllocatedType) * objectPerAllocation * objectsPerPage;
- BatchInfo* batch = static_cast<BatchInfo*>(malloc(mallocSize));
- batch->next_ = 0;
- batch->used_ = batch->buffer_;
- batch->end_ = batch->buffer_ + objectsPerPage;
- return batch;
- }
-
- BatchInfo* batches_;
- BatchInfo* currentBatch_;
- /// Head of a single linked list within the allocated space of freeed object
- AllocatedType* freeHead_;
- unsigned int objectsPerPage_;
-};
-
-} // namespace Json
-
-#endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION
-
-#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_internalarray.inl b/Utilities/cmjsoncpp/src/lib_json/json_internalarray.inl
deleted file mode 100644
index 9ee15e9db..000000000
--- a/Utilities/cmjsoncpp/src/lib_json/json_internalarray.inl
+++ /dev/null
@@ -1,360 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-// included by json_value.cpp
-
-namespace Json {
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueInternalArray
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueArrayAllocator::~ValueArrayAllocator() {}
-
-// //////////////////////////////////////////////////////////////////
-// class DefaultValueArrayAllocator
-// //////////////////////////////////////////////////////////////////
-#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
-class DefaultValueArrayAllocator : public ValueArrayAllocator {
-public: // overridden from ValueArrayAllocator
- virtual ~DefaultValueArrayAllocator() {}
-
- virtual ValueInternalArray* newArray() { return new ValueInternalArray(); }
-
- virtual ValueInternalArray* newArrayCopy(const ValueInternalArray& other) {
- return new ValueInternalArray(other);
- }
-
- virtual void destructArray(ValueInternalArray* array) { delete array; }
-
- virtual void
- reallocateArrayPageIndex(Value**& indexes,
- ValueInternalArray::PageIndex& indexCount,
- ValueInternalArray::PageIndex minNewIndexCount) {
- ValueInternalArray::PageIndex newIndexCount = (indexCount * 3) / 2 + 1;
- if (minNewIndexCount > newIndexCount)
- newIndexCount = minNewIndexCount;
- void* newIndexes = realloc(indexes, sizeof(Value*) * newIndexCount);
- JSON_ASSERT_MESSAGE(newIndexes, "Couldn't realloc.");
- indexCount = newIndexCount;
- indexes = static_cast<Value**>(newIndexes);
- }
- virtual void releaseArrayPageIndex(Value** indexes,
- ValueInternalArray::PageIndex indexCount) {
- if (indexes)
- free(indexes);
- }
-
- virtual Value* allocateArrayPage() {
- return static_cast<Value*>(
- malloc(sizeof(Value) * ValueInternalArray::itemsPerPage));
- }
-
- virtual void releaseArrayPage(Value* value) {
- if (value)
- free(value);
- }
-};
-
-#else // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
-/// @todo make this thread-safe (lock when accessign batch allocator)
-class DefaultValueArrayAllocator : public ValueArrayAllocator {
-public: // overridden from ValueArrayAllocator
- virtual ~DefaultValueArrayAllocator() {}
-
- virtual ValueInternalArray* newArray() {
- ValueInternalArray* array = arraysAllocator_.allocate();
- new (array) ValueInternalArray(); // placement new
- return array;
- }
-
- virtual ValueInternalArray* newArrayCopy(const ValueInternalArray& other) {
- ValueInternalArray* array = arraysAllocator_.allocate();
- new (array) ValueInternalArray(other); // placement new
- return array;
- }
-
- virtual void destructArray(ValueInternalArray* array) {
- if (array) {
- array->~ValueInternalArray();
- arraysAllocator_.release(array);
- }
- }
-
- virtual void
- reallocateArrayPageIndex(Value**& indexes,
- ValueInternalArray::PageIndex& indexCount,
- ValueInternalArray::PageIndex minNewIndexCount) {
- ValueInternalArray::PageIndex newIndexCount = (indexCount * 3) / 2 + 1;
- if (minNewIndexCount > newIndexCount)
- newIndexCount = minNewIndexCount;
- void* newIndexes = realloc(indexes, sizeof(Value*) * newIndexCount);
- JSON_ASSERT_MESSAGE(newIndexes, "Couldn't realloc.");
- indexCount = newIndexCount;
- indexes = static_cast<Value**>(newIndexes);
- }
- virtual void releaseArrayPageIndex(Value** indexes,
- ValueInternalArray::PageIndex indexCount) {
- if (indexes)
- free(indexes);
- }
-
- virtual Value* allocateArrayPage() {
- return static_cast<Value*>(pagesAllocator_.allocate());
- }
-
- virtual void releaseArrayPage(Value* value) {
- if (value)
- pagesAllocator_.release(value);
- }
-
-private:
- BatchAllocator<ValueInternalArray, 1> arraysAllocator_;
- BatchAllocator<Value, ValueInternalArray::itemsPerPage> pagesAllocator_;
-};
-#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
-
-static ValueArrayAllocator*& arrayAllocator() {
- static DefaultValueArrayAllocator defaultAllocator;
- static ValueArrayAllocator* arrayAllocator = &defaultAllocator;
- return arrayAllocator;
-}
-
-static struct DummyArrayAllocatorInitializer {
- DummyArrayAllocatorInitializer() {
- arrayAllocator(); // ensure arrayAllocator() statics are initialized before
- // main().
- }
-} dummyArrayAllocatorInitializer;
-
-// //////////////////////////////////////////////////////////////////
-// class ValueInternalArray
-// //////////////////////////////////////////////////////////////////
-bool ValueInternalArray::equals(const IteratorState& x,
- const IteratorState& other) {
- return x.array_ == other.array_ &&
- x.currentItemIndex_ == other.currentItemIndex_ &&
- x.currentPageIndex_ == other.currentPageIndex_;
-}
-
-void ValueInternalArray::increment(IteratorState& it) {
- JSON_ASSERT_MESSAGE(
- it.array_ && (it.currentPageIndex_ - it.array_->pages_) * itemsPerPage +
- it.currentItemIndex_ !=
- it.array_->size_,
- "ValueInternalArray::increment(): moving iterator beyond end");
- ++(it.currentItemIndex_);
- if (it.currentItemIndex_ == itemsPerPage) {
- it.currentItemIndex_ = 0;
- ++(it.currentPageIndex_);
- }
-}
-
-void ValueInternalArray::decrement(IteratorState& it) {
- JSON_ASSERT_MESSAGE(
- it.array_ && it.currentPageIndex_ == it.array_->pages_ &&
- it.currentItemIndex_ == 0,
- "ValueInternalArray::decrement(): moving iterator beyond end");
- if (it.currentItemIndex_ == 0) {
- it.currentItemIndex_ = itemsPerPage - 1;
- --(it.currentPageIndex_);
- } else {
- --(it.currentItemIndex_);
- }
-}
-
-Value& ValueInternalArray::unsafeDereference(const IteratorState& it) {
- return (*(it.currentPageIndex_))[it.currentItemIndex_];
-}
-
-Value& ValueInternalArray::dereference(const IteratorState& it) {
- JSON_ASSERT_MESSAGE(
- it.array_ && (it.currentPageIndex_ - it.array_->pages_) * itemsPerPage +
- it.currentItemIndex_ <
- it.array_->size_,
- "ValueInternalArray::dereference(): dereferencing invalid iterator");
- return unsafeDereference(it);
-}
-
-void ValueInternalArray::makeBeginIterator(IteratorState& it) const {
- it.array_ = const_cast<ValueInternalArray*>(this);
- it.currentItemIndex_ = 0;
- it.currentPageIndex_ = pages_;
-}
-
-void ValueInternalArray::makeIterator(IteratorState& it,
- ArrayIndex index) const {
- it.array_ = const_cast<ValueInternalArray*>(this);
- it.currentItemIndex_ = index % itemsPerPage;
- it.currentPageIndex_ = pages_ + index / itemsPerPage;
-}
-
-void ValueInternalArray::makeEndIterator(IteratorState& it) const {
- makeIterator(it, size_);
-}
-
-ValueInternalArray::ValueInternalArray() : pages_(0), size_(0), pageCount_(0) {}
-
-ValueInternalArray::ValueInternalArray(const ValueInternalArray& other)
- : pages_(0), size_(other.size_), pageCount_(0) {
- PageIndex minNewPages = other.size_ / itemsPerPage;
- arrayAllocator()->reallocateArrayPageIndex(pages_, pageCount_, minNewPages);
- JSON_ASSERT_MESSAGE(pageCount_ >= minNewPages,
- "ValueInternalArray::reserve(): bad reallocation");
- IteratorState itOther;
- other.makeBeginIterator(itOther);
- Value* value;
- for (ArrayIndex index = 0; index < size_; ++index, increment(itOther)) {
- if (index % itemsPerPage == 0) {
- PageIndex pageIndex = index / itemsPerPage;
- value = arrayAllocator()->allocateArrayPage();
- pages_[pageIndex] = value;
- }
- new (value) Value(dereference(itOther));
- }
-}
-
-ValueInternalArray& ValueInternalArray::operator=(ValueInternalArray other) {
- swap(other);
- return *this;
-}
-
-ValueInternalArray::~ValueInternalArray() {
- // destroy all constructed items
- IteratorState it;
- IteratorState itEnd;
- makeBeginIterator(it);
- makeEndIterator(itEnd);
- for (; !equals(it, itEnd); increment(it)) {
- Value* value = &dereference(it);
- value->~Value();
- }
- // release all pages
- PageIndex lastPageIndex = size_ / itemsPerPage;
- for (PageIndex pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex)
- arrayAllocator()->releaseArrayPage(pages_[pageIndex]);
- // release pages index
- arrayAllocator()->releaseArrayPageIndex(pages_, pageCount_);
-}
-
-void ValueInternalArray::swap(ValueInternalArray& other) {
- Value** tempPages = pages_;
- pages_ = other.pages_;
- other.pages_ = tempPages;
- ArrayIndex tempSize = size_;
- size_ = other.size_;
- other.size_ = tempSize;
- PageIndex tempPageCount = pageCount_;
- pageCount_ = other.pageCount_;
- other.pageCount_ = tempPageCount;
-}
-
-void ValueInternalArray::clear() {
- ValueInternalArray dummy;
- swap(dummy);
-}
-
-void ValueInternalArray::resize(ArrayIndex newSize) {
- if (newSize == 0)
- clear();
- else if (newSize < size_) {
- IteratorState it;
- IteratorState itEnd;
- makeIterator(it, newSize);
- makeIterator(itEnd, size_);
- for (; !equals(it, itEnd); increment(it)) {
- Value* value = &dereference(it);
- value->~Value();
- }
- PageIndex pageIndex = (newSize + itemsPerPage - 1) / itemsPerPage;
- PageIndex lastPageIndex = size_ / itemsPerPage;
- for (; pageIndex < lastPageIndex; ++pageIndex)
- arrayAllocator()->releaseArrayPage(pages_[pageIndex]);
- size_ = newSize;
- } else if (newSize > size_)
- resolveReference(newSize);
-}
-
-void ValueInternalArray::makeIndexValid(ArrayIndex index) {
- // Need to enlarge page index ?
- if (index >= pageCount_ * itemsPerPage) {
- PageIndex minNewPages = (index + 1) / itemsPerPage;
- arrayAllocator()->reallocateArrayPageIndex(pages_, pageCount_, minNewPages);
- JSON_ASSERT_MESSAGE(pageCount_ >= minNewPages,
- "ValueInternalArray::reserve(): bad reallocation");
- }
-
- // Need to allocate new pages ?
- ArrayIndex nextPageIndex = (size_ % itemsPerPage) != 0
- ? size_ - (size_ % itemsPerPage) + itemsPerPage
- : size_;
- if (nextPageIndex <= index) {
- PageIndex pageIndex = nextPageIndex / itemsPerPage;
- PageIndex pageToAllocate = (index - nextPageIndex) / itemsPerPage + 1;
- for (; pageToAllocate-- > 0; ++pageIndex)
- pages_[pageIndex] = arrayAllocator()->allocateArrayPage();
- }
-
- // Initialize all new entries
- IteratorState it;
- IteratorState itEnd;
- makeIterator(it, size_);
- size_ = index + 1;
- makeIterator(itEnd, size_);
- for (; !equals(it, itEnd); increment(it)) {
- Value* value = &dereference(it);
- new (value) Value(); // Construct a default value using placement new
- }
-}
-
-Value& ValueInternalArray::resolveReference(ArrayIndex index) {
- if (index >= size_)
- makeIndexValid(index);
- return pages_[index / itemsPerPage][index % itemsPerPage];
-}
-
-Value* ValueInternalArray::find(ArrayIndex index) const {
- if (index >= size_)
- return 0;
- return &(pages_[index / itemsPerPage][index % itemsPerPage]);
-}
-
-ValueInternalArray::ArrayIndex ValueInternalArray::size() const {
- return size_;
-}
-
-int ValueInternalArray::distance(const IteratorState& x,
- const IteratorState& y) {
- return indexOf(y) - indexOf(x);
-}
-
-ValueInternalArray::ArrayIndex
-ValueInternalArray::indexOf(const IteratorState& iterator) {
- if (!iterator.array_)
- return ArrayIndex(-1);
- return ArrayIndex((iterator.currentPageIndex_ - iterator.array_->pages_) *
- itemsPerPage +
- iterator.currentItemIndex_);
-}
-
-int ValueInternalArray::compare(const ValueInternalArray& other) const {
- int sizeDiff(size_ - other.size_);
- if (sizeDiff != 0)
- return sizeDiff;
-
- for (ArrayIndex index = 0; index < size_; ++index) {
- int diff = pages_[index / itemsPerPage][index % itemsPerPage].compare(
- other.pages_[index / itemsPerPage][index % itemsPerPage]);
- if (diff != 0)
- return diff;
- }
- return 0;
-}
-
-} // namespace Json
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_internalmap.inl b/Utilities/cmjsoncpp/src/lib_json/json_internalmap.inl
deleted file mode 100644
index ef3f3302d..000000000
--- a/Utilities/cmjsoncpp/src/lib_json/json_internalmap.inl
+++ /dev/null
@@ -1,473 +0,0 @@
-// Copyright 2007-2010 Baptiste Lepilleur
-// Distributed under MIT license, or public domain if desired and
-// recognized in your jurisdiction.
-// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
-
-// included by json_value.cpp
-
-namespace Json {
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueInternalMap
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-/** \internal MUST be safely initialized using memset( this, 0,
- * sizeof(ValueInternalLink) );
- * This optimization is used by the fast allocator.
- */
-ValueInternalLink::ValueInternalLink() : previous_(0), next_(0) {}
-
-ValueInternalLink::~ValueInternalLink() {
- for (int index = 0; index < itemPerLink; ++index) {
- if (!items_[index].isItemAvailable()) {
- if (!items_[index].isMemberNameStatic())
- free(keys_[index]);
- } else
- break;
- }
-}
-
-ValueMapAllocator::~ValueMapAllocator() {}
-
-#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
-class DefaultValueMapAllocator : public ValueMapAllocator {
-public: // overridden from ValueMapAllocator
- virtual ValueInternalMap* newMap() { return new ValueInternalMap(); }
-
- virtual ValueInternalMap* newMapCopy(const ValueInternalMap& other) {
- return new ValueInternalMap(other);
- }
-
- virtual void destructMap(ValueInternalMap* map) { delete map; }
-
- virtual ValueInternalLink* allocateMapBuckets(unsigned int size) {
- return new ValueInternalLink[size];
- }
-
- virtual void releaseMapBuckets(ValueInternalLink* links) { delete[] links; }
-
- virtual ValueInternalLink* allocateMapLink() {
- return new ValueInternalLink();
- }
-
- virtual void releaseMapLink(ValueInternalLink* link) { delete link; }
-};
-#else
-/// @todo make this thread-safe (lock when accessign batch allocator)
-class DefaultValueMapAllocator : public ValueMapAllocator {
-public: // overridden from ValueMapAllocator
- virtual ValueInternalMap* newMap() {
- ValueInternalMap* map = mapsAllocator_.allocate();
- new (map) ValueInternalMap(); // placement new
- return map;
- }
-
- virtual ValueInternalMap* newMapCopy(const ValueInternalMap& other) {
- ValueInternalMap* map = mapsAllocator_.allocate();
- new (map) ValueInternalMap(other); // placement new
- return map;
- }
-
- virtual void destructMap(ValueInternalMap* map) {
- if (map) {
- map->~ValueInternalMap();
- mapsAllocator_.release(map);
- }
- }
-
- virtual ValueInternalLink* allocateMapBuckets(unsigned int size) {
- return new ValueInternalLink[size];
- }
-
- virtual void releaseMapBuckets(ValueInternalLink* links) { delete[] links; }
-
- virtual ValueInternalLink* allocateMapLink() {
- ValueInternalLink* link = linksAllocator_.allocate();
- memset(link, 0, sizeof(ValueInternalLink));
- return link;
- }
-
- virtual void releaseMapLink(ValueInternalLink* link) {
- link->~ValueInternalLink();
- linksAllocator_.release(link);
- }
-
-private:
- BatchAllocator<ValueInternalMap, 1> mapsAllocator_;
- BatchAllocator<ValueInternalLink, 1> linksAllocator_;
-};
-#endif
-
-static ValueMapAllocator*& mapAllocator() {
- static DefaultValueMapAllocator defaultAllocator;
- static ValueMapAllocator* mapAllocator = &defaultAllocator;
- return mapAllocator;
-}
-
-static struct DummyMapAllocatorInitializer {
- DummyMapAllocatorInitializer() {
- mapAllocator(); // ensure mapAllocator() statics are initialized before
- // main().
- }
-} dummyMapAllocatorInitializer;
-
-// h(K) = value * K >> w ; with w = 32 & K prime w.r.t. 2^32.
-
-/*
-use linked list hash map.
-buckets array is a container.
-linked list element contains 6 key/values. (memory = (16+4) * 6 + 4 = 124)
-value have extra state: valid, available, deleted
-*/
-
-ValueInternalMap::ValueInternalMap()
- : buckets_(0), tailLink_(0), bucketsSize_(0), itemCount_(0) {}
-
-ValueInternalMap::ValueInternalMap(const ValueInternalMap& other)
- : buckets_(0), tailLink_(0), bucketsSize_(0), itemCount_(0) {
- reserve(other.itemCount_);
- IteratorState it;
- IteratorState itEnd;
- other.makeBeginIterator(it);
- other.makeEndIterator(itEnd);
- for (; !equals(it, itEnd); increment(it)) {
- bool isStatic;
- const char* memberName = key(it, isStatic);
- const Value& aValue = value(it);
- resolveReference(memberName, isStatic) = aValue;
- }
-}
-
-ValueInternalMap& ValueInternalMap::operator=(ValueInternalMap other) {
- swap(other);
- return *this;
-}
-
-ValueInternalMap::~ValueInternalMap() {
- if (buckets_) {
- for (BucketIndex bucketIndex = 0; bucketIndex < bucketsSize_;
- ++bucketIndex) {
- ValueInternalLink* link = buckets_[bucketIndex].next_;
- while (link) {
- ValueInternalLink* linkToRelease = link;
- link = link->next_;
- mapAllocator()->releaseMapLink(linkToRelease);
- }
- }
- mapAllocator()->releaseMapBuckets(buckets_);
- }
-}
-
-void ValueInternalMap::swap(ValueInternalMap& other) {
- ValueInternalLink* tempBuckets = buckets_;
- buckets_ = other.buckets_;
- other.buckets_ = tempBuckets;
- ValueInternalLink* tempTailLink = tailLink_;
- tailLink_ = other.tailLink_;
- other.tailLink_ = tempTailLink;
- BucketIndex tempBucketsSize = bucketsSize_;
- bucketsSize_ = other.bucketsSize_;
- other.bucketsSize_ = tempBucketsSize;
- BucketIndex tempItemCount = itemCount_;
- itemCount_ = other.itemCount_;
- other.itemCount_ = tempItemCount;
-}
-
-void ValueInternalMap::clear() {
- ValueInternalMap dummy;
- swap(dummy);
-}
-
-ValueInternalMap::BucketIndex ValueInternalMap::size() const {
- return itemCount_;
-}
-
-bool ValueInternalMap::reserveDelta(BucketIndex growth) {
- return reserve(itemCount_ + growth);
-}
-
-bool ValueInternalMap::reserve(BucketIndex newItemCount) {
- if (!buckets_ && newItemCount > 0) {
- buckets_ = mapAllocator()->allocateMapBuckets(1);
- bucketsSize_ = 1;
- tailLink_ = &buckets_[0];
- }
- // BucketIndex idealBucketCount = (newItemCount +
- // ValueInternalLink::itemPerLink) / ValueInternalLink::itemPerLink;
- return true;
-}
-
-const Value* ValueInternalMap::find(const char* key) const {
- if (!bucketsSize_)
- return 0;
- HashKey hashedKey = hash(key);
- BucketIndex bucketIndex = hashedKey % bucketsSize_;
- for (const ValueInternalLink* current = &buckets_[bucketIndex]; current != 0;
- current = current->next_) {
- for (BucketIndex index = 0; index < ValueInternalLink::itemPerLink;
- ++index) {
- if (current->items_[index].isItemAvailable())
- return 0;
- if (strcmp(key, current->keys_[index]) == 0)
- return &current->items_[index];
- }
- }
- return 0;
-}
-
-Value* ValueInternalMap::find(const char* key) {
- const ValueInternalMap* constThis = this;
- return const_cast<Value*>(constThis->find(key));
-}
-
-Value& ValueInternalMap::resolveReference(const char* key, bool isStatic) {
- HashKey hashedKey = hash(key);
- if (bucketsSize_) {
- BucketIndex bucketIndex = hashedKey % bucketsSize_;
- ValueInternalLink** previous = 0;
- BucketIndex index;
- for (ValueInternalLink* current = &buckets_[bucketIndex]; current != 0;
- previous = &current->next_, current = current->next_) {
- for (index = 0; index < ValueInternalLink::itemPerLink; ++index) {
- if (current->items_[index].isItemAvailable())
- return setNewItem(key, isStatic, current, index);
- if (strcmp(key, current->keys_[index]) == 0)
- return current->items_[index];
- }
- }
- }
-
- reserveDelta(1);
- return unsafeAdd(key, isStatic, hashedKey);
-}
-
-void ValueInternalMap::remove(const char* key) {
- HashKey hashedKey = hash(key);
- if (!bucketsSize_)
- return;
- BucketIndex bucketIndex = hashedKey % bucketsSize_;
- for (ValueInternalLink* link = &buckets_[bucketIndex]; link != 0;
- link = link->next_) {
- BucketIndex index;
- for (index = 0; index < ValueInternalLink::itemPerLink; ++index) {
- if (link->items_[index].isItemAvailable())
- return;
- if (strcmp(key, link->keys_[index]) == 0) {
- doActualRemove(link, index, bucketIndex);
- return;
- }
- }
- }
-}
-
-void ValueInternalMap::doActualRemove(ValueInternalLink* link,
- BucketIndex index,
- BucketIndex bucketIndex) {
- // find last item of the bucket and swap it with the 'removed' one.
- // set removed items flags to 'available'.
- // if last page only contains 'available' items, then desallocate it (it's
- // empty)
- ValueInternalLink*& lastLink = getLastLinkInBucket(index);
- BucketIndex lastItemIndex = 1; // a link can never be empty, so start at 1
- for (; lastItemIndex < ValueInternalLink::itemPerLink;
- ++lastItemIndex) // may be optimized with dicotomic search
- {
- if (lastLink->items_[lastItemIndex].isItemAvailable())
- break;
- }
-
- BucketIndex lastUsedIndex = lastItemIndex - 1;
- Value* valueToDelete = &link->items_[index];
- Value* valueToPreserve = &lastLink->items_[lastUsedIndex];
- if (valueToDelete != valueToPreserve)
- valueToDelete->swap(*valueToPreserve);
- if (lastUsedIndex == 0) // page is now empty
- { // remove it from bucket linked list and delete it.
- ValueInternalLink* linkPreviousToLast = lastLink->previous_;
- if (linkPreviousToLast != 0) // can not deleted bucket link.
- {
- mapAllocator()->releaseMapLink(lastLink);
- linkPreviousToLast->next_ = 0;
- lastLink = linkPreviousToLast;
- }
- } else {
- Value dummy;
- valueToPreserve->swap(dummy); // restore deleted to default Value.
- valueToPreserve->setItemUsed(false);
- }
- --itemCount_;
-}
-
-ValueInternalLink*&
-ValueInternalMap::getLastLinkInBucket(BucketIndex bucketIndex) {
- if (bucketIndex == bucketsSize_ - 1)
- return tailLink_;
- ValueInternalLink*& previous = buckets_[bucketIndex + 1].previous_;
- if (!previous)
- previous = &buckets_[bucketIndex];
- return previous;
-}
-
-Value& ValueInternalMap::setNewItem(const char* key,
- bool isStatic,
- ValueInternalLink* link,
- BucketIndex index) {
- char* duplicatedKey = makeMemberName(key);
- ++itemCount_;
- link->keys_[index] = duplicatedKey;
- link->items_[index].setItemUsed();
- link->items_[index].setMemberNameIsStatic(isStatic);
- return link->items_[index]; // items already default constructed.
-}
-
-Value&
-ValueInternalMap::unsafeAdd(const char* key, bool isStatic, HashKey hashedKey) {
- JSON_ASSERT_MESSAGE(bucketsSize_ > 0,
- "ValueInternalMap::unsafeAdd(): internal logic error.");
- BucketIndex bucketIndex = hashedKey % bucketsSize_;
- ValueInternalLink*& previousLink = getLastLinkInBucket(bucketIndex);
- ValueInternalLink* link = previousLink;
- BucketIndex index;
- for (index = 0; index < ValueInternalLink::itemPerLink; ++index) {
- if (link->items_[index].isItemAvailable())
- break;
- }
- if (index == ValueInternalLink::itemPerLink) // need to add a new page
- {
- ValueInternalLink* newLink = mapAllocator()->allocateMapLink();
- index = 0;
- link->next_ = newLink;
- previousLink = newLink;
- link = newLink;
- }
- return setNewItem(key, isStatic, link, index);
-}
-
-ValueInternalMap::HashKey ValueInternalMap::hash(const char* key) const {
- HashKey hash = 0;
- while (*key)
- hash += *key++ * 37;
- return hash;
-}
-
-int ValueInternalMap::compare(const ValueInternalMap& other) const {
- int sizeDiff(itemCount_ - other.itemCount_);
- if (sizeDiff != 0)
- return sizeDiff;
- // Strict order guaranty is required. Compare all keys FIRST, then compare
- // values.
- IteratorState it;
- IteratorState itEnd;
- makeBeginIterator(it);
- makeEndIterator(itEnd);
- for (; !equals(it, itEnd); increment(it)) {
- if (!other.find(key(it)))
- return 1;
- }
-
- // All keys are equals, let's compare values
- makeBeginIterator(it);
- for (; !equals(it, itEnd); increment(it)) {
- const Value* otherValue = other.find(key(it));
- int valueDiff = value(it).compare(*otherValue);
- if (valueDiff != 0)
- return valueDiff;
- }
- return 0;
-}
-
-void ValueInternalMap::makeBeginIterator(IteratorState& it) const {
- it.map_ = const_cast<ValueInternalMap*>(this);
- it.bucketIndex_ = 0;
- it.itemIndex_ = 0;
- it.link_ = buckets_;
-}
-
-void ValueInternalMap::makeEndIterator(IteratorState& it) const {
- it.map_ = const_cast<ValueInternalMap*>(this);
- it.bucketIndex_ = bucketsSize_;
- it.itemIndex_ = 0;
- it.link_ = 0;
-}
-
-bool ValueInternalMap::equals(const IteratorState& x,
- const IteratorState& other) {
- return x.map_ == other.map_ && x.bucketIndex_ == other.bucketIndex_ &&
- x.link_ == other.link_ && x.itemIndex_ == other.itemIndex_;
-}
-
-void ValueInternalMap::incrementBucket(IteratorState& iterator) {
- ++iterator.bucketIndex_;
- JSON_ASSERT_MESSAGE(
- iterator.bucketIndex_ <= iterator.map_->bucketsSize_,
- "ValueInternalMap::increment(): attempting to iterate beyond end.");
- if (iterator.bucketIndex_ == iterator.map_->bucketsSize_)
- iterator.link_ = 0;
- else
- iterator.link_ = &(iterator.map_->buckets_[iterator.bucketIndex_]);
- iterator.itemIndex_ = 0;
-}
-
-void ValueInternalMap::increment(IteratorState& iterator) {
- JSON_ASSERT_MESSAGE(iterator.map_,
- "Attempting to iterator using invalid iterator.");
- ++iterator.itemIndex_;
- if (iterator.itemIndex_ == ValueInternalLink::itemPerLink) {
- JSON_ASSERT_MESSAGE(
- iterator.link_ != 0,
- "ValueInternalMap::increment(): attempting to iterate beyond end.");
- iterator.link_ = iterator.link_->next_;
- if (iterator.link_ == 0)
- incrementBucket(iterator);
- } else if (iterator.link_->items_[iterator.itemIndex_].isItemAvailable()) {
- incrementBucket(iterator);
- }
-}
-
-void ValueInternalMap::decrement(IteratorState& iterator) {
- if (iterator.itemIndex_ == 0) {
- JSON_ASSERT_MESSAGE(iterator.map_,
- "Attempting to iterate using invalid iterator.");
- if (iterator.link_ == &iterator.map_->buckets_[iterator.bucketIndex_]) {
- JSON_ASSERT_MESSAGE(iterator.bucketIndex_ > 0,
- "Attempting to iterate beyond beginning.");
- --(iterator.bucketIndex_);
- }
- iterator.link_ = iterator.link_->previous_;
- iterator.itemIndex_ = ValueInternalLink::itemPerLink - 1;
- }
-}
-
-const char* ValueInternalMap::key(const IteratorState& iterator) {
- JSON_ASSERT_MESSAGE(iterator.link_,
- "Attempting to iterate using invalid iterator.");
- return iterator.link_->keys_[iterator.itemIndex_];
-}
-
-const char* ValueInternalMap::key(const IteratorState& iterator,
- bool& isStatic) {
- JSON_ASSERT_MESSAGE(iterator.link_,
- "Attempting to iterate using invalid iterator.");
- isStatic = iterator.link_->items_[iterator.itemIndex_].isMemberNameStatic();
- return iterator.link_->keys_[iterator.itemIndex_];
-}
-
-Value& ValueInternalMap::value(const IteratorState& iterator) {
- JSON_ASSERT_MESSAGE(iterator.link_,
- "Attempting to iterate using invalid iterator.");
- return iterator.link_->items_[iterator.itemIndex_];
-}
-
-int ValueInternalMap::distance(const IteratorState& x, const IteratorState& y) {
- int offset = 0;
- IteratorState it = x;
- while (!equals(it, y))
- increment(it);
- return offset;
-}
-
-} // namespace Json
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp b/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp
index 7b338285c..6eeba0e65 100644
--- a/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp
+++ b/Utilities/cmjsoncpp/src/lib_json/json_reader.cpp
@@ -1,4 +1,5 @@
-// Copyright 2007-2011 Baptiste Lepilleur
+// Copyright 2007-2011 Baptiste Lepilleur and The JsonCpp Authors
+// Copyright (C) 2016 InfoTeCS JSC. All rights reserved.
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -14,18 +15,51 @@
#include <assert.h>
#include <string.h>
#include <istream>
-
-#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below
+#include <sstream>
+#include <memory>
+#include <set>
+#include <limits>
+
+#if defined(_MSC_VER)
+#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
+#define snprintf sprintf_s
+#elif _MSC_VER >= 1900 // VC++ 14.0 and above
+#define snprintf std::snprintf
+#else
#define snprintf _snprintf
#endif
+#elif defined(__ANDROID__) || defined(__QNXNTO__)
+#define snprintf snprintf
+#elif __cplusplus >= 201103L
+#if !defined(__MINGW32__) && !defined(__CYGWIN__)
+#define snprintf std::snprintf
+#endif
+#endif
+
+#if defined(__QNXNTO__)
+#define sscanf std::sscanf
+#endif
#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
// Disable warning about strdup being deprecated.
#pragma warning(disable : 4996)
#endif
+// Define JSONCPP_DEPRECATED_STACK_LIMIT as an appropriate integer at compile time to change the stack limit
+#if !defined(JSONCPP_DEPRECATED_STACK_LIMIT)
+#define JSONCPP_DEPRECATED_STACK_LIMIT 1000
+#endif
+
+static size_t const stackLimit_g = JSONCPP_DEPRECATED_STACK_LIMIT; // see readValue()
+
namespace Json {
+#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
+typedef std::unique_ptr<CharReader> CharReaderPtr;
+#else
+typedef std::auto_ptr<CharReader> CharReaderPtr;
+#endif
+
// Implementation of class Features
// ////////////////////////////////
@@ -47,24 +81,7 @@ Features Features::strictMode() {
// Implementation of class Reader
// ////////////////////////////////
-static inline bool in(Reader::Char c,
- Reader::Char c1,
- Reader::Char c2,
- Reader::Char c3,
- Reader::Char c4) {
- return c == c1 || c == c2 || c == c3 || c == c4;
-}
-
-static inline bool in(Reader::Char c,
- Reader::Char c1,
- Reader::Char c2,
- Reader::Char c3,
- Reader::Char c4,
- Reader::Char c5) {
- return c == c1 || c == c2 || c == c3 || c == c4 || c == c5;
-}
-
-static bool containsNewLine(Reader::Location begin, Reader::Location end) {
+bool Reader::containsNewLine(Reader::Location begin, Reader::Location end) {
for (; begin < end; ++begin)
if (*begin == '\n' || *begin == '\r')
return true;
@@ -86,7 +103,7 @@ Reader::Reader(const Features& features)
bool
Reader::parse(const std::string& document, Value& root, bool collectComments) {
- document_ = document;
+ document_.assign(document.begin(), document.end());
const char* begin = document_.c_str();
const char* end = begin + document_.length();
return parse(begin, end, root, collectComments);
@@ -98,11 +115,11 @@ bool Reader::parse(std::istream& sin, Value& root, bool collectComments) {
// Those would allow streamed input from a file, if parse() were a
// template function.
- // Since std::string is reference-counted, this at least does not
+ // Since JSONCPP_STRING is reference-counted, this at least does not
// create an extra copy.
- std::string doc;
+ JSONCPP_STRING doc;
std::getline(sin, doc, (char)EOF);
- return parse(doc, root, collectComments);
+ return parse(doc.data(), doc.data() + doc.size(), root, collectComments);
}
bool Reader::parse(const char* beginDoc,
@@ -119,7 +136,7 @@ bool Reader::parse(const char* beginDoc,
current_ = begin_;
lastValueEnd_ = 0;
lastValue_ = 0;
- commentsBefore_ = "";
+ commentsBefore_.clear();
errors_.clear();
while (!nodes_.empty())
nodes_.pop();
@@ -147,21 +164,18 @@ bool Reader::parse(const char* beginDoc,
}
bool Reader::readValue() {
+ // readValue() may call itself only if it calls readObject() or ReadArray().
+ // These methods execute nodes_.push() just before and nodes_.pop)() just after calling readValue().
+ // parse() executes one nodes_.push(), so > instead of >=.
+ if (nodes_.size() > stackLimit_g) throwRuntimeError("Exceeded stackLimit in readValue().");
+
Token token;
skipCommentTokens(token);
bool successful = true;
if (collectComments_ && !commentsBefore_.empty()) {
- // Remove newline characters at the end of the comments
- size_t lastNonNewline = commentsBefore_.find_last_not_of("\r\n");
- if (lastNonNewline != std::string::npos) {
- commentsBefore_.erase(lastNonNewline + 1);
- } else {
- commentsBefore_.clear();
- }
-
currentValue().setComment(commentsBefore_, commentBefore);
- commentsBefore_ = "";
+ commentsBefore_.clear();
}
switch (token.type_) {
@@ -180,31 +194,42 @@ bool Reader::readValue() {
successful = decodeString(token);
break;
case tokenTrue:
- currentValue() = true;
+ {
+ Value v(true);
+ currentValue().swapPayload(v);
currentValue().setOffsetStart(token.start_ - begin_);
currentValue().setOffsetLimit(token.end_ - begin_);
+ }
break;
case tokenFalse:
- currentValue() = false;
+ {
+ Value v(false);
+ currentValue().swapPayload(v);
currentValue().setOffsetStart(token.start_ - begin_);
currentValue().setOffsetLimit(token.end_ - begin_);
+ }
break;
case tokenNull:
- currentValue() = Value();
+ {
+ Value v;
+ currentValue().swapPayload(v);
currentValue().setOffsetStart(token.start_ - begin_);
currentValue().setOffsetLimit(token.end_ - begin_);
+ }
break;
case tokenArraySeparator:
+ case tokenObjectEnd:
+ case tokenArrayEnd:
if (features_.allowDroppedNullPlaceholders_) {
// "Un-read" the current token and mark the current value as a null
// token.
current_--;
- currentValue() = Value();
+ Value v;
+ currentValue().swapPayload(v);
currentValue().setOffsetStart(current_ - begin_ - 1);
currentValue().setOffsetLimit(current_ - begin_);
break;
- }
- // Else, fall through...
+ } // Else, fall through...
default:
currentValue().setOffsetStart(token.start_ - begin_);
currentValue().setOffsetLimit(token.end_ - begin_);
@@ -229,13 +254,6 @@ void Reader::skipCommentTokens(Token& token) {
}
}
-bool Reader::expectToken(TokenType type, Token& token, const char* message) {
- readToken(token);
- if (token.type_ != type)
- return addError(message, token);
- return true;
-}
-
bool Reader::readToken(Token& token) {
skipSpaces();
token.start_ = current_;
@@ -351,19 +369,39 @@ bool Reader::readComment() {
return true;
}
+JSONCPP_STRING Reader::normalizeEOL(Reader::Location begin, Reader::Location end) {
+ JSONCPP_STRING normalized;
+ normalized.reserve(static_cast<size_t>(end - begin));
+ Reader::Location current = begin;
+ while (current != end) {
+ char c = *current++;
+ if (c == '\r') {
+ if (current != end && *current == '\n')
+ // convert dos EOL
+ ++current;
+ // convert Mac EOL
+ normalized += '\n';
+ } else {
+ normalized += c;
+ }
+ }
+ return normalized;
+}
+
void
Reader::addComment(Location begin, Location end, CommentPlacement placement) {
assert(collectComments_);
+ const JSONCPP_STRING& normalized = normalizeEOL(begin, end);
if (placement == commentAfterOnSameLine) {
assert(lastValue_ != 0);
- lastValue_->setComment(std::string(begin, end), placement);
+ lastValue_->setComment(normalized, placement);
} else {
- commentsBefore_ += std::string(begin, end);
+ commentsBefore_ += normalized;
}
}
bool Reader::readCStyleComment() {
- while (current_ != end_) {
+ while ((current_ + 1) < end_) {
Char c = getNextChar();
if (c == '*' && *current_ == '/')
break;
@@ -374,23 +412,43 @@ bool Reader::readCStyleComment() {
bool Reader::readCppStyleComment() {
while (current_ != end_) {
Char c = getNextChar();
- if (c == '\r' || c == '\n')
+ if (c == '\n')
break;
+ if (c == '\r') {
+ // Consume DOS EOL. It will be normalized in addComment.
+ if (current_ != end_ && *current_ == '\n')
+ getNextChar();
+ // Break on Moc OS 9 EOL.
+ break;
+ }
}
return true;
}
void Reader::readNumber() {
- while (current_ != end_) {
- if (!(*current_ >= '0' && *current_ <= '9') &&
- !in(*current_, '.', 'e', 'E', '+', '-'))
- break;
- ++current_;
+ const char *p = current_;
+ char c = '0'; // stopgap for already consumed character
+ // integral part
+ while (c >= '0' && c <= '9')
+ c = (current_ = p) < end_ ? *p++ : '\0';
+ // fractional part
+ if (c == '.') {
+ c = (current_ = p) < end_ ? *p++ : '\0';
+ while (c >= '0' && c <= '9')
+ c = (current_ = p) < end_ ? *p++ : '\0';
+ }
+ // exponential part
+ if (c == 'e' || c == 'E') {
+ c = (current_ = p) < end_ ? *p++ : '\0';
+ if (c == '+' || c == '-')
+ c = (current_ = p) < end_ ? *p++ : '\0';
+ while (c >= '0' && c <= '9')
+ c = (current_ = p) < end_ ? *p++ : '\0';
}
}
bool Reader::readString() {
- Char c = 0;
+ Char c = '\0';
while (current_ != end_) {
c = getNextChar();
if (c == '\\')
@@ -403,8 +461,9 @@ bool Reader::readString() {
bool Reader::readObject(Token& tokenStart) {
Token tokenName;
- std::string name;
- currentValue() = Value(objectValue);
+ JSONCPP_STRING name;
+ Value init(objectValue);
+ currentValue().swapPayload(init);
currentValue().setOffsetStart(tokenStart.start_ - begin_);
while (readToken(tokenName)) {
bool initialTokenOk = true;
@@ -414,7 +473,7 @@ bool Reader::readObject(Token& tokenStart) {
break;
if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
return true;
- name = "";
+ name.clear();
if (tokenName.type_ == tokenString) {
if (!decodeString(tokenName, name))
return recoverFromError(tokenObjectEnd);
@@ -422,7 +481,7 @@ bool Reader::readObject(Token& tokenStart) {
Value numberName;
if (!decodeNumber(tokenName, numberName))
return recoverFromError(tokenObjectEnd);
- name = numberName.asString();
+ name = JSONCPP_STRING(numberName.asCString());
} else {
break;
}
@@ -457,10 +516,11 @@ bool Reader::readObject(Token& tokenStart) {
}
bool Reader::readArray(Token& tokenStart) {
- currentValue() = Value(arrayValue);
+ Value init(arrayValue);
+ currentValue().swapPayload(init);
currentValue().setOffsetStart(tokenStart.start_ - begin_);
skipSpaces();
- if (*current_ == ']') // empty array
+ if (current_ != end_ && *current_ == ']') // empty array
{
Token endArray;
readToken(endArray);
@@ -497,20 +557,13 @@ bool Reader::decodeNumber(Token& token) {
Value decoded;
if (!decodeNumber(token, decoded))
return false;
- currentValue() = decoded;
+ currentValue().swapPayload(decoded);
currentValue().setOffsetStart(token.start_ - begin_);
currentValue().setOffsetLimit(token.end_ - begin_);
return true;
}
bool Reader::decodeNumber(Token& token, Value& decoded) {
- bool isDouble = false;
- for (Location inspect = token.start_; inspect != token.end_; ++inspect) {
- isDouble = isDouble || in(*inspect, '.', 'e', 'E', '+') ||
- (*inspect == '-' && inspect != token.start_);
- }
- if (isDouble)
- return decodeDouble(token, decoded);
// Attempts to parse the number as an integer. If the number is
// larger than the maximum supported value of an integer then
// we decode the number as a double.
@@ -518,17 +571,16 @@ bool Reader::decodeNumber(Token& token, Value& decoded) {
bool isNegative = *current == '-';
if (isNegative)
++current;
+ // TODO: Help the compiler do the div and mod at compile time or get rid of them.
Value::LargestUInt maxIntegerValue =
- isNegative ? Value::LargestUInt(-Value::minLargestInt)
+ isNegative ? Value::LargestUInt(Value::maxLargestInt) + 1
: Value::maxLargestUInt;
Value::LargestUInt threshold = maxIntegerValue / 10;
Value::LargestUInt value = 0;
while (current < token.end_) {
Char c = *current++;
if (c < '0' || c > '9')
- return addError("'" + std::string(token.start_, token.end_) +
- "' is not a number.",
- token);
+ return decodeDouble(token, decoded);
Value::UInt digit(static_cast<Value::UInt>(c - '0'));
if (value >= threshold) {
// We've hit or exceeded the max value divided by 10 (rounded down). If
@@ -542,7 +594,9 @@ bool Reader::decodeNumber(Token& token, Value& decoded) {
}
value = value * 10 + digit;
}
- if (isNegative)
+ if (isNegative && value == maxIntegerValue)
+ decoded = Value::minLargestInt;
+ else if (isNegative)
decoded = -Value::LargestInt(value);
else if (value <= Value::LargestUInt(Value::maxInt))
decoded = Value::LargestInt(value);
@@ -555,7 +609,7 @@ bool Reader::decodeDouble(Token& token) {
Value decoded;
if (!decodeDouble(token, decoded))
return false;
- currentValue() = decoded;
+ currentValue().swapPayload(decoded);
currentValue().setOffsetStart(token.start_ - begin_);
currentValue().setOffsetLimit(token.end_ - begin_);
return true;
@@ -563,14 +617,1021 @@ bool Reader::decodeDouble(Token& token) {
bool Reader::decodeDouble(Token& token, Value& decoded) {
double value = 0;
+ JSONCPP_STRING buffer(token.start_, token.end_);
+ JSONCPP_ISTRINGSTREAM is(buffer);
+ if (!(is >> value))
+ return addError("'" + JSONCPP_STRING(token.start_, token.end_) +
+ "' is not a number.",
+ token);
+ decoded = value;
+ return true;
+}
+
+bool Reader::decodeString(Token& token) {
+ JSONCPP_STRING decoded_string;
+ if (!decodeString(token, decoded_string))
+ return false;
+ Value decoded(decoded_string);
+ currentValue().swapPayload(decoded);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ return true;
+}
+
+bool Reader::decodeString(Token& token, JSONCPP_STRING& decoded) {
+ decoded.reserve(static_cast<size_t>(token.end_ - token.start_ - 2));
+ Location current = token.start_ + 1; // skip '"'
+ Location end = token.end_ - 1; // do not include '"'
+ while (current != end) {
+ Char c = *current++;
+ if (c == '"')
+ break;
+ else if (c == '\\') {
+ if (current == end)
+ return addError("Empty escape sequence in string", token, current);
+ Char escape = *current++;
+ switch (escape) {
+ case '"':
+ decoded += '"';
+ break;
+ case '/':
+ decoded += '/';
+ break;
+ case '\\':
+ decoded += '\\';
+ break;
+ case 'b':
+ decoded += '\b';
+ break;
+ case 'f':
+ decoded += '\f';
+ break;
+ case 'n':
+ decoded += '\n';
+ break;
+ case 'r':
+ decoded += '\r';
+ break;
+ case 't':
+ decoded += '\t';
+ break;
+ case 'u': {
+ unsigned int unicode;
+ if (!decodeUnicodeCodePoint(token, current, end, unicode))
+ return false;
+ decoded += codePointToUTF8(unicode);
+ } break;
+ default:
+ return addError("Bad escape sequence in string", token, current);
+ }
+ } else {
+ decoded += c;
+ }
+ }
+ return true;
+}
+
+bool Reader::decodeUnicodeCodePoint(Token& token,
+ Location& current,
+ Location end,
+ unsigned int& unicode) {
+
+ if (!decodeUnicodeEscapeSequence(token, current, end, unicode))
+ return false;
+ if (unicode >= 0xD800 && unicode <= 0xDBFF) {
+ // surrogate pairs
+ if (end - current < 6)
+ return addError(
+ "additional six characters expected to parse unicode surrogate pair.",
+ token,
+ current);
+ unsigned int surrogatePair;
+ if (*(current++) == '\\' && *(current++) == 'u') {
+ if (decodeUnicodeEscapeSequence(token, current, end, surrogatePair)) {
+ unicode = 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF);
+ } else
+ return false;
+ } else
+ return addError("expecting another \\u token to begin the second half of "
+ "a unicode surrogate pair",
+ token,
+ current);
+ }
+ return true;
+}
+
+bool Reader::decodeUnicodeEscapeSequence(Token& token,
+ Location& current,
+ Location end,
+ unsigned int& ret_unicode) {
+ if (end - current < 4)
+ return addError(
+ "Bad unicode escape sequence in string: four digits expected.",
+ token,
+ current);
+ int unicode = 0;
+ for (int index = 0; index < 4; ++index) {
+ Char c = *current++;
+ unicode *= 16;
+ if (c >= '0' && c <= '9')
+ unicode += c - '0';
+ else if (c >= 'a' && c <= 'f')
+ unicode += c - 'a' + 10;
+ else if (c >= 'A' && c <= 'F')
+ unicode += c - 'A' + 10;
+ else
+ return addError(
+ "Bad unicode escape sequence in string: hexadecimal digit expected.",
+ token,
+ current);
+ }
+ ret_unicode = static_cast<unsigned int>(unicode);
+ return true;
+}
+
+bool
+Reader::addError(const JSONCPP_STRING& message, Token& token, Location extra) {
+ ErrorInfo info;
+ info.token_ = token;
+ info.message_ = message;
+ info.extra_ = extra;
+ errors_.push_back(info);
+ return false;
+}
+
+bool Reader::recoverFromError(TokenType skipUntilToken) {
+ size_t const errorCount = errors_.size();
+ Token skip;
+ for (;;) {
+ if (!readToken(skip))
+ errors_.resize(errorCount); // discard errors caused by recovery
+ if (skip.type_ == skipUntilToken || skip.type_ == tokenEndOfStream)
+ break;
+ }
+ errors_.resize(errorCount);
+ return false;
+}
+
+bool Reader::addErrorAndRecover(const JSONCPP_STRING& message,
+ Token& token,
+ TokenType skipUntilToken) {
+ addError(message, token);
+ return recoverFromError(skipUntilToken);
+}
+
+Value& Reader::currentValue() { return *(nodes_.top()); }
+
+Reader::Char Reader::getNextChar() {
+ if (current_ == end_)
+ return 0;
+ return *current_++;
+}
+
+void Reader::getLocationLineAndColumn(Location location,
+ int& line,
+ int& column) const {
+ Location current = begin_;
+ Location lastLineStart = current;
+ line = 0;
+ while (current < location && current != end_) {
+ Char c = *current++;
+ if (c == '\r') {
+ if (*current == '\n')
+ ++current;
+ lastLineStart = current;
+ ++line;
+ } else if (c == '\n') {
+ lastLineStart = current;
+ ++line;
+ }
+ }
+ // column & line start at 1
+ column = int(location - lastLineStart) + 1;
+ ++line;
+}
+
+JSONCPP_STRING Reader::getLocationLineAndColumn(Location location) const {
+ int line, column;
+ getLocationLineAndColumn(location, line, column);
+ char buffer[18 + 16 + 16 + 1];
+ snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
+ return buffer;
+}
+
+// Deprecated. Preserved for backward compatibility
+JSONCPP_STRING Reader::getFormatedErrorMessages() const {
+ return getFormattedErrorMessages();
+}
+
+JSONCPP_STRING Reader::getFormattedErrorMessages() const {
+ JSONCPP_STRING formattedMessage;
+ for (Errors::const_iterator itError = errors_.begin();
+ itError != errors_.end();
+ ++itError) {
+ const ErrorInfo& error = *itError;
+ formattedMessage +=
+ "* " + getLocationLineAndColumn(error.token_.start_) + "\n";
+ formattedMessage += " " + error.message_ + "\n";
+ if (error.extra_)
+ formattedMessage +=
+ "See " + getLocationLineAndColumn(error.extra_) + " for detail.\n";
+ }
+ return formattedMessage;
+}
+
+std::vector<Reader::StructuredError> Reader::getStructuredErrors() const {
+ std::vector<Reader::StructuredError> allErrors;
+ for (Errors::const_iterator itError = errors_.begin();
+ itError != errors_.end();
+ ++itError) {
+ const ErrorInfo& error = *itError;
+ Reader::StructuredError structured;
+ structured.offset_start = error.token_.start_ - begin_;
+ structured.offset_limit = error.token_.end_ - begin_;
+ structured.message = error.message_;
+ allErrors.push_back(structured);
+ }
+ return allErrors;
+}
+
+bool Reader::pushError(const Value& value, const JSONCPP_STRING& message) {
+ ptrdiff_t const length = end_ - begin_;
+ if(value.getOffsetStart() > length
+ || value.getOffsetLimit() > length)
+ return false;
+ Token token;
+ token.type_ = tokenError;
+ token.start_ = begin_ + value.getOffsetStart();
+ token.end_ = end_ + value.getOffsetLimit();
+ ErrorInfo info;
+ info.token_ = token;
+ info.message_ = message;
+ info.extra_ = 0;
+ errors_.push_back(info);
+ return true;
+}
+
+bool Reader::pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra) {
+ ptrdiff_t const length = end_ - begin_;
+ if(value.getOffsetStart() > length
+ || value.getOffsetLimit() > length
+ || extra.getOffsetLimit() > length)
+ return false;
+ Token token;
+ token.type_ = tokenError;
+ token.start_ = begin_ + value.getOffsetStart();
+ token.end_ = begin_ + value.getOffsetLimit();
+ ErrorInfo info;
+ info.token_ = token;
+ info.message_ = message;
+ info.extra_ = begin_ + extra.getOffsetStart();
+ errors_.push_back(info);
+ return true;
+}
+
+bool Reader::good() const {
+ return !errors_.size();
+}
+
+// exact copy of Features
+class OurFeatures {
+public:
+ static OurFeatures all();
+ bool allowComments_;
+ bool strictRoot_;
+ bool allowDroppedNullPlaceholders_;
+ bool allowNumericKeys_;
+ bool allowSingleQuotes_;
+ bool failIfExtra_;
+ bool rejectDupKeys_;
+ bool allowSpecialFloats_;
+ int stackLimit_;
+}; // OurFeatures
+
+// exact copy of Implementation of class Features
+// ////////////////////////////////
+
+OurFeatures OurFeatures::all() { return OurFeatures(); }
+
+// Implementation of class Reader
+// ////////////////////////////////
+
+// exact copy of Reader, renamed to OurReader
+class OurReader {
+public:
+ typedef char Char;
+ typedef const Char* Location;
+ struct StructuredError {
+ ptrdiff_t offset_start;
+ ptrdiff_t offset_limit;
+ JSONCPP_STRING message;
+ };
+
+ OurReader(OurFeatures const& features);
+ bool parse(const char* beginDoc,
+ const char* endDoc,
+ Value& root,
+ bool collectComments = true);
+ JSONCPP_STRING getFormattedErrorMessages() const;
+ std::vector<StructuredError> getStructuredErrors() const;
+ bool pushError(const Value& value, const JSONCPP_STRING& message);
+ bool pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra);
+ bool good() const;
+
+private:
+ OurReader(OurReader const&); // no impl
+ void operator=(OurReader const&); // no impl
+
+ enum TokenType {
+ tokenEndOfStream = 0,
+ tokenObjectBegin,
+ tokenObjectEnd,
+ tokenArrayBegin,
+ tokenArrayEnd,
+ tokenString,
+ tokenNumber,
+ tokenTrue,
+ tokenFalse,
+ tokenNull,
+ tokenNaN,
+ tokenPosInf,
+ tokenNegInf,
+ tokenArraySeparator,
+ tokenMemberSeparator,
+ tokenComment,
+ tokenError
+ };
+
+ class Token {
+ public:
+ TokenType type_;
+ Location start_;
+ Location end_;
+ };
+
+ class ErrorInfo {
+ public:
+ Token token_;
+ JSONCPP_STRING message_;
+ Location extra_;
+ };
+
+ typedef std::deque<ErrorInfo> Errors;
+
+ bool readToken(Token& token);
+ void skipSpaces();
+ bool match(Location pattern, int patternLength);
+ bool readComment();
+ bool readCStyleComment();
+ bool readCppStyleComment();
+ bool readString();
+ bool readStringSingleQuote();
+ bool readNumber(bool checkInf);
+ bool readValue();
+ bool readObject(Token& token);
+ bool readArray(Token& token);
+ bool decodeNumber(Token& token);
+ bool decodeNumber(Token& token, Value& decoded);
+ bool decodeString(Token& token);
+ bool decodeString(Token& token, JSONCPP_STRING& decoded);
+ bool decodeDouble(Token& token);
+ bool decodeDouble(Token& token, Value& decoded);
+ bool decodeUnicodeCodePoint(Token& token,
+ Location& current,
+ Location end,
+ unsigned int& unicode);
+ bool decodeUnicodeEscapeSequence(Token& token,
+ Location& current,
+ Location end,
+ unsigned int& unicode);
+ bool addError(const JSONCPP_STRING& message, Token& token, Location extra = 0);
+ bool recoverFromError(TokenType skipUntilToken);
+ bool addErrorAndRecover(const JSONCPP_STRING& message,
+ Token& token,
+ TokenType skipUntilToken);
+ void skipUntilSpace();
+ Value& currentValue();
+ Char getNextChar();
+ void
+ getLocationLineAndColumn(Location location, int& line, int& column) const;
+ JSONCPP_STRING getLocationLineAndColumn(Location location) const;
+ void addComment(Location begin, Location end, CommentPlacement placement);
+ void skipCommentTokens(Token& token);
+
+ static JSONCPP_STRING normalizeEOL(Location begin, Location end);
+ static bool containsNewLine(Location begin, Location end);
+
+ typedef std::stack<Value*> Nodes;
+ Nodes nodes_;
+ Errors errors_;
+ JSONCPP_STRING document_;
+ Location begin_;
+ Location end_;
+ Location current_;
+ Location lastValueEnd_;
+ Value* lastValue_;
+ JSONCPP_STRING commentsBefore_;
+
+ OurFeatures const features_;
+ bool collectComments_;
+}; // OurReader
+
+// complete copy of Read impl, for OurReader
+
+bool OurReader::containsNewLine(OurReader::Location begin, OurReader::Location end) {
+ for (; begin < end; ++begin)
+ if (*begin == '\n' || *begin == '\r')
+ return true;
+ return false;
+}
+
+OurReader::OurReader(OurFeatures const& features)
+ : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
+ lastValue_(), commentsBefore_(),
+ features_(features), collectComments_() {
+}
+
+bool OurReader::parse(const char* beginDoc,
+ const char* endDoc,
+ Value& root,
+ bool collectComments) {
+ if (!features_.allowComments_) {
+ collectComments = false;
+ }
+
+ begin_ = beginDoc;
+ end_ = endDoc;
+ collectComments_ = collectComments;
+ current_ = begin_;
+ lastValueEnd_ = 0;
+ lastValue_ = 0;
+ commentsBefore_.clear();
+ errors_.clear();
+ while (!nodes_.empty())
+ nodes_.pop();
+ nodes_.push(&root);
+
+ bool successful = readValue();
+ Token token;
+ skipCommentTokens(token);
+ if (features_.failIfExtra_) {
+ if ((features_.strictRoot_ || token.type_ != tokenError) && token.type_ != tokenEndOfStream) {
+ addError("Extra non-whitespace after JSON value.", token);
+ return false;
+ }
+ }
+ if (collectComments_ && !commentsBefore_.empty())
+ root.setComment(commentsBefore_, commentAfter);
+ if (features_.strictRoot_) {
+ if (!root.isArray() && !root.isObject()) {
+ // Set error location to start of doc, ideally should be first token found
+ // in doc
+ token.type_ = tokenError;
+ token.start_ = beginDoc;
+ token.end_ = endDoc;
+ addError(
+ "A valid JSON document must be either an array or an object value.",
+ token);
+ return false;
+ }
+ }
+ return successful;
+}
+
+bool OurReader::readValue() {
+ // To preserve the old behaviour we cast size_t to int.
+ if (static_cast<int>(nodes_.size()) > features_.stackLimit_) throwRuntimeError("Exceeded stackLimit in readValue().");
+ Token token;
+ skipCommentTokens(token);
+ bool successful = true;
+
+ if (collectComments_ && !commentsBefore_.empty()) {
+ currentValue().setComment(commentsBefore_, commentBefore);
+ commentsBefore_.clear();
+ }
+
+ switch (token.type_) {
+ case tokenObjectBegin:
+ successful = readObject(token);
+ currentValue().setOffsetLimit(current_ - begin_);
+ break;
+ case tokenArrayBegin:
+ successful = readArray(token);
+ currentValue().setOffsetLimit(current_ - begin_);
+ break;
+ case tokenNumber:
+ successful = decodeNumber(token);
+ break;
+ case tokenString:
+ successful = decodeString(token);
+ break;
+ case tokenTrue:
+ {
+ Value v(true);
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenFalse:
+ {
+ Value v(false);
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenNull:
+ {
+ Value v;
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenNaN:
+ {
+ Value v(std::numeric_limits<double>::quiet_NaN());
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenPosInf:
+ {
+ Value v(std::numeric_limits<double>::infinity());
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenNegInf:
+ {
+ Value v(-std::numeric_limits<double>::infinity());
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ }
+ break;
+ case tokenArraySeparator:
+ case tokenObjectEnd:
+ case tokenArrayEnd:
+ if (features_.allowDroppedNullPlaceholders_) {
+ // "Un-read" the current token and mark the current value as a null
+ // token.
+ current_--;
+ Value v;
+ currentValue().swapPayload(v);
+ currentValue().setOffsetStart(current_ - begin_ - 1);
+ currentValue().setOffsetLimit(current_ - begin_);
+ break;
+ } // else, fall through ...
+ default:
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ return addError("Syntax error: value, object or array expected.", token);
+ }
+
+ if (collectComments_) {
+ lastValueEnd_ = current_;
+ lastValue_ = &currentValue();
+ }
+
+ return successful;
+}
+
+void OurReader::skipCommentTokens(Token& token) {
+ if (features_.allowComments_) {
+ do {
+ readToken(token);
+ } while (token.type_ == tokenComment);
+ } else {
+ readToken(token);
+ }
+}
+
+bool OurReader::readToken(Token& token) {
+ skipSpaces();
+ token.start_ = current_;
+ Char c = getNextChar();
+ bool ok = true;
+ switch (c) {
+ case '{':
+ token.type_ = tokenObjectBegin;
+ break;
+ case '}':
+ token.type_ = tokenObjectEnd;
+ break;
+ case '[':
+ token.type_ = tokenArrayBegin;
+ break;
+ case ']':
+ token.type_ = tokenArrayEnd;
+ break;
+ case '"':
+ token.type_ = tokenString;
+ ok = readString();
+ break;
+ case '\'':
+ if (features_.allowSingleQuotes_) {
+ token.type_ = tokenString;
+ ok = readStringSingleQuote();
+ break;
+ } // else continue
+ case '/':
+ token.type_ = tokenComment;
+ ok = readComment();
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ token.type_ = tokenNumber;
+ readNumber(false);
+ break;
+ case '-':
+ if (readNumber(true)) {
+ token.type_ = tokenNumber;
+ } else {
+ token.type_ = tokenNegInf;
+ ok = features_.allowSpecialFloats_ && match("nfinity", 7);
+ }
+ break;
+ case 't':
+ token.type_ = tokenTrue;
+ ok = match("rue", 3);
+ break;
+ case 'f':
+ token.type_ = tokenFalse;
+ ok = match("alse", 4);
+ break;
+ case 'n':
+ token.type_ = tokenNull;
+ ok = match("ull", 3);
+ break;
+ case 'N':
+ if (features_.allowSpecialFloats_) {
+ token.type_ = tokenNaN;
+ ok = match("aN", 2);
+ } else {
+ ok = false;
+ }
+ break;
+ case 'I':
+ if (features_.allowSpecialFloats_) {
+ token.type_ = tokenPosInf;
+ ok = match("nfinity", 7);
+ } else {
+ ok = false;
+ }
+ break;
+ case ',':
+ token.type_ = tokenArraySeparator;
+ break;
+ case ':':
+ token.type_ = tokenMemberSeparator;
+ break;
+ case 0:
+ token.type_ = tokenEndOfStream;
+ break;
+ default:
+ ok = false;
+ break;
+ }
+ if (!ok)
+ token.type_ = tokenError;
+ token.end_ = current_;
+ return true;
+}
+
+void OurReader::skipSpaces() {
+ while (current_ != end_) {
+ Char c = *current_;
+ if (c == ' ' || c == '\t' || c == '\r' || c == '\n')
+ ++current_;
+ else
+ break;
+ }
+}
+
+bool OurReader::match(Location pattern, int patternLength) {
+ if (end_ - current_ < patternLength)
+ return false;
+ int index = patternLength;
+ while (index--)
+ if (current_[index] != pattern[index])
+ return false;
+ current_ += patternLength;
+ return true;
+}
+
+bool OurReader::readComment() {
+ Location commentBegin = current_ - 1;
+ Char c = getNextChar();
+ bool successful = false;
+ if (c == '*')
+ successful = readCStyleComment();
+ else if (c == '/')
+ successful = readCppStyleComment();
+ if (!successful)
+ return false;
+
+ if (collectComments_) {
+ CommentPlacement placement = commentBefore;
+ if (lastValueEnd_ && !containsNewLine(lastValueEnd_, commentBegin)) {
+ if (c != '*' || !containsNewLine(commentBegin, current_))
+ placement = commentAfterOnSameLine;
+ }
+
+ addComment(commentBegin, current_, placement);
+ }
+ return true;
+}
+
+JSONCPP_STRING OurReader::normalizeEOL(OurReader::Location begin, OurReader::Location end) {
+ JSONCPP_STRING normalized;
+ normalized.reserve(static_cast<size_t>(end - begin));
+ OurReader::Location current = begin;
+ while (current != end) {
+ char c = *current++;
+ if (c == '\r') {
+ if (current != end && *current == '\n')
+ // convert dos EOL
+ ++current;
+ // convert Mac EOL
+ normalized += '\n';
+ } else {
+ normalized += c;
+ }
+ }
+ return normalized;
+}
+
+void
+OurReader::addComment(Location begin, Location end, CommentPlacement placement) {
+ assert(collectComments_);
+ const JSONCPP_STRING& normalized = normalizeEOL(begin, end);
+ if (placement == commentAfterOnSameLine) {
+ assert(lastValue_ != 0);
+ lastValue_->setComment(normalized, placement);
+ } else {
+ commentsBefore_ += normalized;
+ }
+}
+
+bool OurReader::readCStyleComment() {
+ while ((current_ + 1) < end_) {
+ Char c = getNextChar();
+ if (c == '*' && *current_ == '/')
+ break;
+ }
+ return getNextChar() == '/';
+}
+
+bool OurReader::readCppStyleComment() {
+ while (current_ != end_) {
+ Char c = getNextChar();
+ if (c == '\n')
+ break;
+ if (c == '\r') {
+ // Consume DOS EOL. It will be normalized in addComment.
+ if (current_ != end_ && *current_ == '\n')
+ getNextChar();
+ // Break on Moc OS 9 EOL.
+ break;
+ }
+ }
+ return true;
+}
+
+bool OurReader::readNumber(bool checkInf) {
+ const char *p = current_;
+ if (checkInf && p != end_ && *p == 'I') {
+ current_ = ++p;
+ return false;
+ }
+ char c = '0'; // stopgap for already consumed character
+ // integral part
+ while (c >= '0' && c <= '9')
+ c = (current_ = p) < end_ ? *p++ : '\0';
+ // fractional part
+ if (c == '.') {
+ c = (current_ = p) < end_ ? *p++ : '\0';
+ while (c >= '0' && c <= '9')
+ c = (current_ = p) < end_ ? *p++ : '\0';
+ }
+ // exponential part
+ if (c == 'e' || c == 'E') {
+ c = (current_ = p) < end_ ? *p++ : '\0';
+ if (c == '+' || c == '-')
+ c = (current_ = p) < end_ ? *p++ : '\0';
+ while (c >= '0' && c <= '9')
+ c = (current_ = p) < end_ ? *p++ : '\0';
+ }
+ return true;
+}
+bool OurReader::readString() {
+ Char c = 0;
+ while (current_ != end_) {
+ c = getNextChar();
+ if (c == '\\')
+ getNextChar();
+ else if (c == '"')
+ break;
+ }
+ return c == '"';
+}
+
+
+bool OurReader::readStringSingleQuote() {
+ Char c = 0;
+ while (current_ != end_) {
+ c = getNextChar();
+ if (c == '\\')
+ getNextChar();
+ else if (c == '\'')
+ break;
+ }
+ return c == '\'';
+}
+
+bool OurReader::readObject(Token& tokenStart) {
+ Token tokenName;
+ JSONCPP_STRING name;
+ Value init(objectValue);
+ currentValue().swapPayload(init);
+ currentValue().setOffsetStart(tokenStart.start_ - begin_);
+ while (readToken(tokenName)) {
+ bool initialTokenOk = true;
+ while (tokenName.type_ == tokenComment && initialTokenOk)
+ initialTokenOk = readToken(tokenName);
+ if (!initialTokenOk)
+ break;
+ if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object
+ return true;
+ name.clear();
+ if (tokenName.type_ == tokenString) {
+ if (!decodeString(tokenName, name))
+ return recoverFromError(tokenObjectEnd);
+ } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
+ Value numberName;
+ if (!decodeNumber(tokenName, numberName))
+ return recoverFromError(tokenObjectEnd);
+ name = numberName.asString();
+ } else {
+ break;
+ }
+
+ Token colon;
+ if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {
+ return addErrorAndRecover(
+ "Missing ':' after object member name", colon, tokenObjectEnd);
+ }
+ if (name.length() >= (1U<<30)) throwRuntimeError("keylength >= 2^30");
+ if (features_.rejectDupKeys_ && currentValue().isMember(name)) {
+ JSONCPP_STRING msg = "Duplicate key: '" + name + "'";
+ return addErrorAndRecover(
+ msg, tokenName, tokenObjectEnd);
+ }
+ Value& value = currentValue()[name];
+ nodes_.push(&value);
+ bool ok = readValue();
+ nodes_.pop();
+ if (!ok) // error already set
+ return recoverFromError(tokenObjectEnd);
+
+ Token comma;
+ if (!readToken(comma) ||
+ (comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&
+ comma.type_ != tokenComment)) {
+ return addErrorAndRecover(
+ "Missing ',' or '}' in object declaration", comma, tokenObjectEnd);
+ }
+ bool finalizeTokenOk = true;
+ while (comma.type_ == tokenComment && finalizeTokenOk)
+ finalizeTokenOk = readToken(comma);
+ if (comma.type_ == tokenObjectEnd)
+ return true;
+ }
+ return addErrorAndRecover(
+ "Missing '}' or object member name", tokenName, tokenObjectEnd);
+}
+
+bool OurReader::readArray(Token& tokenStart) {
+ Value init(arrayValue);
+ currentValue().swapPayload(init);
+ currentValue().setOffsetStart(tokenStart.start_ - begin_);
+ skipSpaces();
+ if (current_ != end_ && *current_ == ']') // empty array
+ {
+ Token endArray;
+ readToken(endArray);
+ return true;
+ }
+ int index = 0;
+ for (;;) {
+ Value& value = currentValue()[index++];
+ nodes_.push(&value);
+ bool ok = readValue();
+ nodes_.pop();
+ if (!ok) // error already set
+ return recoverFromError(tokenArrayEnd);
+
+ Token token;
+ // Accept Comment after last item in the array.
+ ok = readToken(token);
+ while (token.type_ == tokenComment && ok) {
+ ok = readToken(token);
+ }
+ bool badTokenType =
+ (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);
+ if (!ok || badTokenType) {
+ return addErrorAndRecover(
+ "Missing ',' or ']' in array declaration", token, tokenArrayEnd);
+ }
+ if (token.type_ == tokenArrayEnd)
+ break;
+ }
+ return true;
+}
+
+bool OurReader::decodeNumber(Token& token) {
+ Value decoded;
+ if (!decodeNumber(token, decoded))
+ return false;
+ currentValue().swapPayload(decoded);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ return true;
+}
+
+bool OurReader::decodeNumber(Token& token, Value& decoded) {
+ // Attempts to parse the number as an integer. If the number is
+ // larger than the maximum supported value of an integer then
+ // we decode the number as a double.
+ Location current = token.start_;
+ bool isNegative = *current == '-';
+ if (isNegative)
+ ++current;
+ // TODO: Help the compiler do the div and mod at compile time or get rid of them.
+ Value::LargestUInt maxIntegerValue =
+ isNegative ? Value::LargestUInt(Value::minLargestInt)
+ : Value::maxLargestUInt;
+ Value::LargestUInt threshold = maxIntegerValue / 10;
+ Value::LargestUInt value = 0;
+ while (current < token.end_) {
+ Char c = *current++;
+ if (c < '0' || c > '9')
+ return decodeDouble(token, decoded);
+ Value::UInt digit(static_cast<Value::UInt>(c - '0'));
+ if (value >= threshold) {
+ // We've hit or exceeded the max value divided by 10 (rounded down). If
+ // a) we've only just touched the limit, b) this is the last digit, and
+ // c) it's small enough to fit in that rounding delta, we're okay.
+ // Otherwise treat this number as a double to avoid overflow.
+ if (value > threshold || current != token.end_ ||
+ digit > maxIntegerValue % 10) {
+ return decodeDouble(token, decoded);
+ }
+ }
+ value = value * 10 + digit;
+ }
+ if (isNegative)
+ decoded = -Value::LargestInt(value);
+ else if (value <= Value::LargestUInt(Value::maxInt))
+ decoded = Value::LargestInt(value);
+ else
+ decoded = value;
+ return true;
+}
+
+bool OurReader::decodeDouble(Token& token) {
+ Value decoded;
+ if (!decodeDouble(token, decoded))
+ return false;
+ currentValue().swapPayload(decoded);
+ currentValue().setOffsetStart(token.start_ - begin_);
+ currentValue().setOffsetLimit(token.end_ - begin_);
+ return true;
+}
+
+bool OurReader::decodeDouble(Token& token, Value& decoded) {
+ double value = 0;
const int bufferSize = 32;
int count;
- int length = int(token.end_ - token.start_);
+ ptrdiff_t const length = token.end_ - token.start_;
// Sanity check to avoid buffer overflow exploits.
if (length < 0) {
return addError("Unable to parse token length", token);
}
+ size_t const ulength = static_cast<size_t>(length);
// Avoid using a string constant for the format control string given to
// sscanf, as this can cause hard to debug crashes on OS X. See here for more
@@ -581,34 +1642,36 @@ bool Reader::decodeDouble(Token& token, Value& decoded) {
if (length <= bufferSize) {
Char buffer[bufferSize + 1];
- memcpy(buffer, token.start_, length);
+ memcpy(buffer, token.start_, ulength);
buffer[length] = 0;
+ fixNumericLocaleInput(buffer, buffer + length);
count = sscanf(buffer, format, &value);
} else {
- std::string buffer(token.start_, token.end_);
+ JSONCPP_STRING buffer(token.start_, token.end_);
count = sscanf(buffer.c_str(), format, &value);
}
if (count != 1)
- return addError("'" + std::string(token.start_, token.end_) +
+ return addError("'" + JSONCPP_STRING(token.start_, token.end_) +
"' is not a number.",
token);
decoded = value;
return true;
}
-bool Reader::decodeString(Token& token) {
- std::string decoded;
- if (!decodeString(token, decoded))
+bool OurReader::decodeString(Token& token) {
+ JSONCPP_STRING decoded_string;
+ if (!decodeString(token, decoded_string))
return false;
- currentValue() = decoded;
+ Value decoded(decoded_string);
+ currentValue().swapPayload(decoded);
currentValue().setOffsetStart(token.start_ - begin_);
currentValue().setOffsetLimit(token.end_ - begin_);
return true;
}
-bool Reader::decodeString(Token& token, std::string& decoded) {
- decoded.reserve(token.end_ - token.start_ - 2);
+bool OurReader::decodeString(Token& token, JSONCPP_STRING& decoded) {
+ decoded.reserve(static_cast<size_t>(token.end_ - token.start_ - 2));
Location current = token.start_ + 1; // skip '"'
Location end = token.end_ - 1; // do not include '"'
while (current != end) {
@@ -660,11 +1723,12 @@ bool Reader::decodeString(Token& token, std::string& decoded) {
return true;
}
-bool Reader::decodeUnicodeCodePoint(Token& token,
+bool OurReader::decodeUnicodeCodePoint(Token& token,
Location& current,
Location end,
unsigned int& unicode) {
+ unicode = 0; // Convince scanbuild this is always initialized before use.
if (!decodeUnicodeEscapeSequence(token, current, end, unicode))
return false;
if (unicode >= 0xD800 && unicode <= 0xDBFF) {
@@ -689,16 +1753,16 @@ bool Reader::decodeUnicodeCodePoint(Token& token,
return true;
}
-bool Reader::decodeUnicodeEscapeSequence(Token& token,
+bool OurReader::decodeUnicodeEscapeSequence(Token& token,
Location& current,
Location end,
- unsigned int& unicode) {
+ unsigned int& ret_unicode) {
if (end - current < 4)
return addError(
"Bad unicode escape sequence in string: four digits expected.",
token,
current);
- unicode = 0;
+ int unicode = 0;
for (int index = 0; index < 4; ++index) {
Char c = *current++;
unicode *= 16;
@@ -714,11 +1778,12 @@ bool Reader::decodeUnicodeEscapeSequence(Token& token,
token,
current);
}
+ ret_unicode = static_cast<unsigned int>(unicode);
return true;
}
bool
-Reader::addError(const std::string& message, Token& token, Location extra) {
+OurReader::addError(const JSONCPP_STRING& message, Token& token, Location extra) {
ErrorInfo info;
info.token_ = token;
info.message_ = message;
@@ -727,8 +1792,8 @@ Reader::addError(const std::string& message, Token& token, Location extra) {
return false;
}
-bool Reader::recoverFromError(TokenType skipUntilToken) {
- int errorCount = int(errors_.size());
+bool OurReader::recoverFromError(TokenType skipUntilToken) {
+ size_t errorCount = errors_.size();
Token skip;
for (;;) {
if (!readToken(skip))
@@ -740,22 +1805,22 @@ bool Reader::recoverFromError(TokenType skipUntilToken) {
return false;
}
-bool Reader::addErrorAndRecover(const std::string& message,
+bool OurReader::addErrorAndRecover(const JSONCPP_STRING& message,
Token& token,
TokenType skipUntilToken) {
addError(message, token);
return recoverFromError(skipUntilToken);
}
-Value& Reader::currentValue() { return *(nodes_.top()); }
+Value& OurReader::currentValue() { return *(nodes_.top()); }
-Reader::Char Reader::getNextChar() {
+OurReader::Char OurReader::getNextChar() {
if (current_ == end_)
return 0;
return *current_++;
}
-void Reader::getLocationLineAndColumn(Location location,
+void OurReader::getLocationLineAndColumn(Location location,
int& line,
int& column) const {
Location current = begin_;
@@ -778,29 +1843,16 @@ void Reader::getLocationLineAndColumn(Location location,
++line;
}
-std::string Reader::getLocationLineAndColumn(Location location) const {
+JSONCPP_STRING OurReader::getLocationLineAndColumn(Location location) const {
int line, column;
getLocationLineAndColumn(location, line, column);
char buffer[18 + 16 + 16 + 1];
-#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__)
-#if defined(WINCE)
- _snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
-#else
- sprintf_s(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
-#endif
-#else
snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
-#endif
return buffer;
}
-// Deprecated. Preserved for backward compatibility
-std::string Reader::getFormatedErrorMessages() const {
- return getFormattedErrorMessages();
-}
-
-std::string Reader::getFormattedErrorMessages() const {
- std::string formattedMessage;
+JSONCPP_STRING OurReader::getFormattedErrorMessages() const {
+ JSONCPP_STRING formattedMessage;
for (Errors::const_iterator itError = errors_.begin();
itError != errors_.end();
++itError) {
@@ -815,13 +1867,13 @@ std::string Reader::getFormattedErrorMessages() const {
return formattedMessage;
}
-std::vector<Reader::StructuredError> Reader::getStructuredErrors() const {
- std::vector<Reader::StructuredError> allErrors;
+std::vector<OurReader::StructuredError> OurReader::getStructuredErrors() const {
+ std::vector<OurReader::StructuredError> allErrors;
for (Errors::const_iterator itError = errors_.begin();
itError != errors_.end();
++itError) {
const ErrorInfo& error = *itError;
- Reader::StructuredError structured;
+ OurReader::StructuredError structured;
structured.offset_start = error.token_.start_ - begin_;
structured.offset_limit = error.token_.end_ - begin_;
structured.message = error.message_;
@@ -830,8 +1882,8 @@ std::vector<Reader::StructuredError> Reader::getStructuredErrors() const {
return allErrors;
}
-bool Reader::pushError(const Value& value, const std::string& message) {
- size_t length = end_ - begin_;
+bool OurReader::pushError(const Value& value, const JSONCPP_STRING& message) {
+ ptrdiff_t length = end_ - begin_;
if(value.getOffsetStart() > length
|| value.getOffsetLimit() > length)
return false;
@@ -847,8 +1899,8 @@ bool Reader::pushError(const Value& value, const std::string& message) {
return true;
}
-bool Reader::pushError(const Value& value, const std::string& message, const Value& extra) {
- size_t length = end_ - begin_;
+bool OurReader::pushError(const Value& value, const JSONCPP_STRING& message, const Value& extra) {
+ ptrdiff_t length = end_ - begin_;
if(value.getOffsetStart() > length
|| value.getOffsetLimit() > length
|| extra.getOffsetLimit() > length)
@@ -865,19 +1917,147 @@ bool Reader::pushError(const Value& value, const std::string& message, const Val
return true;
}
-bool Reader::good() const {
+bool OurReader::good() const {
return !errors_.size();
}
-std::istream& operator>>(std::istream& sin, Value& root) {
- Json::Reader reader;
- bool ok = reader.parse(sin, root, true);
+
+class OurCharReader : public CharReader {
+ bool const collectComments_;
+ OurReader reader_;
+public:
+ OurCharReader(
+ bool collectComments,
+ OurFeatures const& features)
+ : collectComments_(collectComments)
+ , reader_(features)
+ {}
+ bool parse(
+ char const* beginDoc, char const* endDoc,
+ Value* root, JSONCPP_STRING* errs) JSONCPP_OVERRIDE {
+ bool ok = reader_.parse(beginDoc, endDoc, *root, collectComments_);
+ if (errs) {
+ *errs = reader_.getFormattedErrorMessages();
+ }
+ return ok;
+ }
+};
+
+CharReaderBuilder::CharReaderBuilder()
+{
+ setDefaults(&settings_);
+}
+CharReaderBuilder::~CharReaderBuilder()
+{}
+CharReader* CharReaderBuilder::newCharReader() const
+{
+ bool collectComments = settings_["collectComments"].asBool();
+ OurFeatures features = OurFeatures::all();
+ features.allowComments_ = settings_["allowComments"].asBool();
+ features.strictRoot_ = settings_["strictRoot"].asBool();
+ features.allowDroppedNullPlaceholders_ = settings_["allowDroppedNullPlaceholders"].asBool();
+ features.allowNumericKeys_ = settings_["allowNumericKeys"].asBool();
+ features.allowSingleQuotes_ = settings_["allowSingleQuotes"].asBool();
+ features.stackLimit_ = settings_["stackLimit"].asInt();
+ features.failIfExtra_ = settings_["failIfExtra"].asBool();
+ features.rejectDupKeys_ = settings_["rejectDupKeys"].asBool();
+ features.allowSpecialFloats_ = settings_["allowSpecialFloats"].asBool();
+ return new OurCharReader(collectComments, features);
+}
+static void getValidReaderKeys(std::set<JSONCPP_STRING>* valid_keys)
+{
+ valid_keys->clear();
+ valid_keys->insert("collectComments");
+ valid_keys->insert("allowComments");
+ valid_keys->insert("strictRoot");
+ valid_keys->insert("allowDroppedNullPlaceholders");
+ valid_keys->insert("allowNumericKeys");
+ valid_keys->insert("allowSingleQuotes");
+ valid_keys->insert("stackLimit");
+ valid_keys->insert("failIfExtra");
+ valid_keys->insert("rejectDupKeys");
+ valid_keys->insert("allowSpecialFloats");
+}
+bool CharReaderBuilder::validate(Json::Value* invalid) const
+{
+ Json::Value my_invalid;
+ if (!invalid) invalid = &my_invalid; // so we do not need to test for NULL
+ Json::Value& inv = *invalid;
+ std::set<JSONCPP_STRING> valid_keys;
+ getValidReaderKeys(&valid_keys);
+ Value::Members keys = settings_.getMemberNames();
+ size_t n = keys.size();
+ for (size_t i = 0; i < n; ++i) {
+ JSONCPP_STRING const& key = keys[i];
+ if (valid_keys.find(key) == valid_keys.end()) {
+ inv[key] = settings_[key];
+ }
+ }
+ return 0u == inv.size();
+}
+Value& CharReaderBuilder::operator[](JSONCPP_STRING key)
+{
+ return settings_[key];
+}
+// static
+void CharReaderBuilder::strictMode(Json::Value* settings)
+{
+//! [CharReaderBuilderStrictMode]
+ (*settings)["allowComments"] = false;
+ (*settings)["strictRoot"] = true;
+ (*settings)["allowDroppedNullPlaceholders"] = false;
+ (*settings)["allowNumericKeys"] = false;
+ (*settings)["allowSingleQuotes"] = false;
+ (*settings)["stackLimit"] = 1000;
+ (*settings)["failIfExtra"] = true;
+ (*settings)["rejectDupKeys"] = true;
+ (*settings)["allowSpecialFloats"] = false;
+//! [CharReaderBuilderStrictMode]
+}
+// static
+void CharReaderBuilder::setDefaults(Json::Value* settings)
+{
+//! [CharReaderBuilderDefaults]
+ (*settings)["collectComments"] = true;
+ (*settings)["allowComments"] = true;
+ (*settings)["strictRoot"] = false;
+ (*settings)["allowDroppedNullPlaceholders"] = false;
+ (*settings)["allowNumericKeys"] = false;
+ (*settings)["allowSingleQuotes"] = false;
+ (*settings)["stackLimit"] = 1000;
+ (*settings)["failIfExtra"] = false;
+ (*settings)["rejectDupKeys"] = false;
+ (*settings)["allowSpecialFloats"] = false;
+//! [CharReaderBuilderDefaults]
+}
+
+//////////////////////////////////
+// global functions
+
+bool parseFromStream(
+ CharReader::Factory const& fact, JSONCPP_ISTREAM& sin,
+ Value* root, JSONCPP_STRING* errs)
+{
+ JSONCPP_OSTRINGSTREAM ssin;
+ ssin << sin.rdbuf();
+ JSONCPP_STRING doc = ssin.str();
+ char const* begin = doc.data();
+ char const* end = begin + doc.size();
+ // Note that we do not actually need a null-terminator.
+ CharReaderPtr const reader(fact.newCharReader());
+ return reader->parse(begin, end, root, errs);
+}
+
+JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM& sin, Value& root) {
+ CharReaderBuilder b;
+ JSONCPP_STRING errs;
+ bool ok = parseFromStream(b, sin, &root, &errs);
if (!ok) {
fprintf(stderr,
"Error from reader: %s",
- reader.getFormattedErrorMessages().c_str());
+ errs.c_str());
- JSON_FAIL_MESSAGE("reader error");
+ throwRuntimeError(errs);
}
return sin;
}
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_tool.h b/Utilities/cmjsoncpp/src/lib_json/json_tool.h
index f9b61c38c..431617830 100644
--- a/Utilities/cmjsoncpp/src/lib_json/json_tool.h
+++ b/Utilities/cmjsoncpp/src/lib_json/json_tool.h
@@ -1,4 +1,4 @@
-// Copyright 2007-2010 Baptiste Lepilleur
+// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -6,6 +6,16 @@
#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED
#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED
+
+// Also support old flag NO_LOCALE_SUPPORT
+#ifdef NO_LOCALE_SUPPORT
+#define JSONCPP_NO_LOCALE_SUPPORT
+#endif
+
+#ifndef JSONCPP_NO_LOCALE_SUPPORT
+#include <clocale>
+#endif
+
/* This header provides common string manipulation support, such as UTF-8,
* portable conversion from/to string...
*
@@ -13,10 +23,18 @@
*/
namespace Json {
+static char getDecimalPoint() {
+#ifdef JSONCPP_NO_LOCALE_SUPPORT
+ return '\0';
+#else
+ struct lconv* lc = localeconv();
+ return lc ? *(lc->decimal_point) : '\0';
+#endif
+}
/// Converts a unicode code-point to UTF-8.
-static inline std::string codePointToUTF8(unsigned int cp) {
- std::string result;
+static inline JSONCPP_STRING codePointToUTF8(unsigned int cp) {
+ JSONCPP_STRING result;
// based on description from http://en.wikipedia.org/wiki/UTF-8
@@ -30,8 +48,8 @@ static inline std::string codePointToUTF8(unsigned int cp) {
} else if (cp <= 0xFFFF) {
result.resize(3);
result[2] = static_cast<char>(0x80 | (0x3f & cp));
- result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));
- result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));
+ result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
+ result[0] = static_cast<char>(0xE0 | (0xf & (cp >> 12)));
} else if (cp <= 0x10FFFF) {
result.resize(4);
result[3] = static_cast<char>(0x80 | (0x3f & cp));
@@ -43,7 +61,7 @@ static inline std::string codePointToUTF8(unsigned int cp) {
return result;
}
-/// Returns true if ch is a control character (in range [0,32[).
+/// Returns true if ch is a control character (in range [1,31]).
static inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }
enum {
@@ -63,7 +81,7 @@ typedef char UIntToStringBuffer[uintToStringBufferSize];
static inline void uintToString(LargestUInt value, char*& current) {
*--current = 0;
do {
- *--current = char(value % 10) + '0';
+ *--current = static_cast<char>(value % 10U + static_cast<unsigned>('0'));
value /= 10;
} while (value != 0);
}
@@ -82,6 +100,18 @@ static inline void fixNumericLocale(char* begin, char* end) {
}
}
+static inline void fixNumericLocaleInput(char* begin, char* end) {
+ char decimalPoint = getDecimalPoint();
+ if (decimalPoint != '\0' && decimalPoint != '.') {
+ while (begin < end) {
+ if (*begin == '.') {
+ *begin = decimalPoint;
+ }
+ ++begin;
+ }
+ }
+}
+
} // namespace Json {
#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_value.cpp b/Utilities/cmjsoncpp/src/lib_json/json_value.cpp
index 478afe102..f271e5731 100644
--- a/Utilities/cmjsoncpp/src/lib_json/json_value.cpp
+++ b/Utilities/cmjsoncpp/src/lib_json/json_value.cpp
@@ -1,4 +1,4 @@
-// Copyright 2011 Baptiste Lepilleur
+// Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -7,9 +7,6 @@
#include <json/assertions.h>
#include <json/value.h>
#include <json/writer.h>
-#ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
-#include "json_batchallocator.h"
-#endif // #ifndef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
#endif // if !defined(JSON_IS_AMALGAMATION)
#include <math.h>
#include <sstream>
@@ -20,6 +17,7 @@
#include <cpptl/conststring.h>
#endif
#include <cstddef> // size_t
+#include <algorithm> // min()
#define JSON_ASSERT_UNREACHABLE assert(false)
@@ -33,9 +31,22 @@ namespace Json {
#else
#define ALIGNAS(byte_alignment)
#endif
-static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
-const unsigned char& kNullRef = kNull[0];
-const Value& Value::null = reinterpret_cast<const Value&>(kNullRef);
+//static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
+//const unsigned char& kNullRef = kNull[0];
+//const Value& Value::null = reinterpret_cast<const Value&>(kNullRef);
+//const Value& Value::nullRef = null;
+
+// static
+Value const& Value::nullSingleton()
+{
+ static Value const nullStatic;
+ return nullStatic;
+}
+
+// for backwards compatibility, we'll leave these global references around, but DO NOT
+// use them in JSONCPP library code any more!
+Value const& Value::null = Value::nullSingleton();
+Value const& Value::nullRef = Value::nullSingleton();
const Int Value::minInt = Int(~(UInt(-1) / 2));
const Int Value::maxInt = Int(UInt(-1) / 2);
@@ -53,17 +64,17 @@ const LargestInt Value::minLargestInt = LargestInt(~(LargestUInt(-1) / 2));
const LargestInt Value::maxLargestInt = LargestInt(LargestUInt(-1) / 2);
const LargestUInt Value::maxLargestUInt = LargestUInt(-1);
-/// Unknown size marker
-static const unsigned int unknown = (unsigned)-1;
-
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
template <typename T, typename U>
static inline bool InRange(double d, T min, U max) {
+ // The casts can lose precision, but we are looking only for
+ // an approximate range. Might fail on edge cases though. ~cdunn
+ //return d >= static_cast<double>(min) && d <= static_cast<double>(max);
return d >= min && d <= max;
}
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
static inline double integerToDouble(Json::UInt64 value) {
- return static_cast<double>(Int64(value / 2)) * 2.0 + Int64(value & 1);
+ return static_cast<double>(Int64(value / 2)) * 2.0 + static_cast<double>(Int64(value & 1));
}
template <typename T> static inline double integerToDouble(T value) {
@@ -84,27 +95,84 @@ static inline bool InRange(double d, T min, U max) {
* @return Pointer on the duplicate instance of string.
*/
static inline char* duplicateStringValue(const char* value,
- unsigned int length = unknown) {
- if (length == unknown)
- length = (unsigned int)strlen(value);
-
+ size_t length)
+{
// Avoid an integer overflow in the call to malloc below by limiting length
// to a sane value.
- if (length >= (unsigned)Value::maxInt)
+ if (length >= static_cast<size_t>(Value::maxInt))
length = Value::maxInt - 1;
char* newString = static_cast<char*>(malloc(length + 1));
- JSON_ASSERT_MESSAGE(newString != 0,
- "in Json::Value::duplicateStringValue(): "
- "Failed to allocate string value buffer");
+ if (newString == NULL) {
+ throwRuntimeError(
+ "in Json::Value::duplicateStringValue(): "
+ "Failed to allocate string value buffer");
+ }
memcpy(newString, value, length);
newString[length] = 0;
return newString;
}
-/** Free the string duplicated by duplicateStringValue().
+/* Record the length as a prefix.
+ */
+static inline char* duplicateAndPrefixStringValue(
+ const char* value,
+ unsigned int length)
+{
+ // Avoid an integer overflow in the call to malloc below by limiting length
+ // to a sane value.
+ JSON_ASSERT_MESSAGE(length <= static_cast<unsigned>(Value::maxInt) - sizeof(unsigned) - 1U,
+ "in Json::Value::duplicateAndPrefixStringValue(): "
+ "length too big for prefixing");
+ unsigned actualLength = length + static_cast<unsigned>(sizeof(unsigned)) + 1U;
+ char* newString = static_cast<char*>(malloc(actualLength));
+ if (newString == 0) {
+ throwRuntimeError(
+ "in Json::Value::duplicateAndPrefixStringValue(): "
+ "Failed to allocate string value buffer");
+ }
+ *reinterpret_cast<unsigned*>(newString) = length;
+ memcpy(newString + sizeof(unsigned), value, length);
+ newString[actualLength - 1U] = 0; // to avoid buffer over-run accidents by users later
+ return newString;
+}
+inline static void decodePrefixedString(
+ bool isPrefixed, char const* prefixed,
+ unsigned* length, char const** value)
+{
+ if (!isPrefixed) {
+ *length = static_cast<unsigned>(strlen(prefixed));
+ *value = prefixed;
+ } else {
+ *length = *reinterpret_cast<unsigned const*>(prefixed);
+ *value = prefixed + sizeof(unsigned);
+ }
+}
+/** Free the string duplicated by duplicateStringValue()/duplicateAndPrefixStringValue().
*/
-static inline void releaseStringValue(char* value) { free(value); }
+#if JSONCPP_USING_SECURE_MEMORY
+static inline void releasePrefixedStringValue(char* value) {
+ unsigned length = 0;
+ char const* valueDecoded;
+ decodePrefixedString(true, value, &length, &valueDecoded);
+ size_t const size = sizeof(unsigned) + length + 1U;
+ memset(value, 0, size);
+ free(value);
+}
+static inline void releaseStringValue(char* value, unsigned length) {
+ // length==0 => we allocated the strings memory
+ size_t size = (length==0) ? strlen(value) : length;
+ memset(value, 0, size);
+ free(value);
+}
+#else // !JSONCPP_USING_SECURE_MEMORY
+static inline void releasePrefixedStringValue(char* value) {
+ free(value);
+}
+static inline void releaseStringValue(char* value, unsigned) {
+ free(value);
+}
+#endif // JSONCPP_USING_SECURE_MEMORY
} // namespace Json
@@ -116,16 +184,36 @@ static inline void releaseStringValue(char* value) { free(value); }
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
#if !defined(JSON_IS_AMALGAMATION)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
-#include "json_internalarray.inl"
-#include "json_internalmap.inl"
-#endif // JSON_VALUE_USE_INTERNAL_MAP
#include "json_valueiterator.inl"
#endif // if !defined(JSON_IS_AMALGAMATION)
namespace Json {
+Exception::Exception(JSONCPP_STRING const& msg)
+ : msg_(msg)
+{}
+Exception::~Exception() JSONCPP_NOEXCEPT
+{}
+char const* Exception::what() const JSONCPP_NOEXCEPT
+{
+ return msg_.c_str();
+}
+RuntimeError::RuntimeError(JSONCPP_STRING const& msg)
+ : Exception(msg)
+{}
+LogicError::LogicError(JSONCPP_STRING const& msg)
+ : Exception(msg)
+{}
+JSONCPP_NORETURN void throwRuntimeError(JSONCPP_STRING const& msg)
+{
+ throw RuntimeError(msg);
+}
+JSONCPP_NORETURN void throwLogicError(JSONCPP_STRING const& msg)
+{
+ throw LogicError(msg);
+}
+
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
@@ -134,22 +222,25 @@ namespace Json {
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
-Value::CommentInfo::CommentInfo() : comment_(0) {}
+Value::CommentInfo::CommentInfo() : comment_(0)
+{}
Value::CommentInfo::~CommentInfo() {
if (comment_)
- releaseStringValue(comment_);
+ releaseStringValue(comment_, 0u);
}
-void Value::CommentInfo::setComment(const char* text) {
- if (comment_)
- releaseStringValue(comment_);
+void Value::CommentInfo::setComment(const char* text, size_t len) {
+ if (comment_) {
+ releaseStringValue(comment_, 0u);
+ comment_ = 0;
+ }
JSON_ASSERT(text != 0);
JSON_ASSERT_MESSAGE(
text[0] == '\0' || text[0] == '/',
"in Json::Value::setComment(): Comments must start with /");
// It seems that /**/ style comments are acceptable as well.
- comment_ = duplicateStringValue(text);
+ comment_ = duplicateStringValue(text, len);
}
// //////////////////////////////////////////////////////////////////
@@ -159,29 +250,41 @@ void Value::CommentInfo::setComment(const char* text) {
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
-// Notes: index_ indicates if the string was allocated when
+// Notes: policy_ indicates if the string was allocated when
// a string is stored.
-Value::CZString::CZString(ArrayIndex index) : cstr_(0), index_(index) {}
+Value::CZString::CZString(ArrayIndex aindex) : cstr_(0), index_(aindex) {}
-Value::CZString::CZString(const char* cstr, DuplicationPolicy allocate)
- : cstr_(allocate == duplicate ? duplicateStringValue(cstr) : cstr),
- index_(allocate) {}
+Value::CZString::CZString(char const* str, unsigned ulength, DuplicationPolicy allocate)
+ : cstr_(str) {
+ // allocate != duplicate
+ storage_.policy_ = allocate & 0x3;
+ storage_.length_ = ulength & 0x3FFFFFFF;
+}
-Value::CZString::CZString(const CZString& other)
- : cstr_(other.index_ != noDuplication && other.cstr_ != 0
- ? duplicateStringValue(other.cstr_)
- : other.cstr_),
- index_(other.cstr_
- ? static_cast<ArrayIndex>(other.index_ == noDuplication
+Value::CZString::CZString(const CZString& other) {
+ cstr_ = (other.storage_.policy_ != noDuplication && other.cstr_ != 0
+ ? duplicateStringValue(other.cstr_, other.storage_.length_)
+ : other.cstr_);
+ storage_.policy_ = static_cast<unsigned>(other.cstr_
+ ? (static_cast<DuplicationPolicy>(other.storage_.policy_) == noDuplication
? noDuplication : duplicate)
- : other.index_) {}
+ : static_cast<DuplicationPolicy>(other.storage_.policy_)) & 3U;
+ storage_.length_ = other.storage_.length_;
+}
+
+#if JSON_HAS_RVALUE_REFERENCES
+Value::CZString::CZString(CZString&& other)
+ : cstr_(other.cstr_), index_(other.index_) {
+ other.cstr_ = nullptr;
+}
+#endif
Value::CZString::~CZString() {
- if (cstr_ && index_ == duplicate)
- releaseStringValue(const_cast<char*>(cstr_));
+ if (cstr_ && storage_.policy_ == duplicate) {
+ releaseStringValue(const_cast<char*>(cstr_), storage_.length_ + 1u); //+1 for null terminating character for sake of completeness but not actually necessary
+ }
}
void Value::CZString::swap(CZString& other) {
@@ -189,34 +292,53 @@ void Value::CZString::swap(CZString& other) {
std::swap(index_, other.index_);
}
-Value::CZString& Value::CZString::operator=(CZString other) {
- swap(other);
+Value::CZString& Value::CZString::operator=(const CZString& other) {
+ cstr_ = other.cstr_;
+ index_ = other.index_;
return *this;
}
+#if JSON_HAS_RVALUE_REFERENCES
+Value::CZString& Value::CZString::operator=(CZString&& other) {
+ cstr_ = other.cstr_;
+ index_ = other.index_;
+ other.cstr_ = nullptr;
+ return *this;
+}
+#endif
+
bool Value::CZString::operator<(const CZString& other) const {
- if (cstr_) {
- assert(other.cstr_);
- return strcmp(cstr_, other.cstr_) < 0;
- }
- return index_ < other.index_;
+ if (!cstr_) return index_ < other.index_;
+ //return strcmp(cstr_, other.cstr_) < 0;
+ // Assume both are strings.
+ unsigned this_len = this->storage_.length_;
+ unsigned other_len = other.storage_.length_;
+ unsigned min_len = std::min<unsigned>(this_len, other_len);
+ JSON_ASSERT(this->cstr_ && other.cstr_);
+ int comp = memcmp(this->cstr_, other.cstr_, min_len);
+ if (comp < 0) return true;
+ if (comp > 0) return false;
+ return (this_len < other_len);
}
bool Value::CZString::operator==(const CZString& other) const {
- if (cstr_) {
- assert(other.cstr_);
- return strcmp(cstr_, other.cstr_) == 0;
- }
- return index_ == other.index_;
+ if (!cstr_) return index_ == other.index_;
+ //return strcmp(cstr_, other.cstr_) == 0;
+ // Assume both are strings.
+ unsigned this_len = this->storage_.length_;
+ unsigned other_len = other.storage_.length_;
+ if (this_len != other_len) return false;
+ JSON_ASSERT(this->cstr_ && other.cstr_);
+ int comp = memcmp(this->cstr_, other.cstr_, this_len);
+ return comp == 0;
}
ArrayIndex Value::CZString::index() const { return index_; }
-const char* Value::CZString::c_str() const { return cstr_; }
-
-bool Value::CZString::isStaticString() const { return index_ == noDuplication; }
-
-#endif // ifndef JSON_VALUE_USE_INTERNAL_MAP
+//const char* Value::CZString::c_str() const { return cstr_; }
+const char* Value::CZString::data() const { return cstr_; }
+unsigned Value::CZString::length() const { return storage_.length_; }
+bool Value::CZString::isStaticString() const { return storage_.policy_ == noDuplication; }
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
@@ -226,13 +348,14 @@ bool Value::CZString::isStaticString() const { return index_ == noDuplication; }
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
-/*! \internal Default constructor initialization must be equivalent to:
+/*! internal Default constructor initialization must be equivalent to:
* memset( this, 0, sizeof(Value) )
* This optimization is used in ValueInternalMap fast allocator.
*/
-Value::Value(ValueType type) {
- initBasic(type);
- switch (type) {
+Value::Value(ValueType vtype) {
+ static char const emptyString[] = "";
+ initBasic(vtype);
+ switch (vtype) {
case nullValue:
break;
case intValue:
@@ -243,21 +366,13 @@ Value::Value(ValueType type) {
value_.real_ = 0.0;
break;
case stringValue:
- value_.string_ = 0;
+ // allocated_ == false, so this is safe.
+ value_.string_ = const_cast<char*>(static_cast<char const*>(emptyString));
break;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
case arrayValue:
case objectValue:
value_.map_ = new ObjectValues();
break;
-#else
- case arrayValue:
- value_.array_ = arrayAllocator()->newArray();
- break;
- case objectValue:
- value_.map_ = mapAllocator()->newMap();
- break;
-#endif
case booleanValue:
value_.bool_ = false;
break;
@@ -293,19 +408,20 @@ Value::Value(double value) {
Value::Value(const char* value) {
initBasic(stringValue, true);
- value_.string_ = duplicateStringValue(value);
+ JSON_ASSERT_MESSAGE(value != NULL, "Null Value Passed to Value Constructor");
+ value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));
}
Value::Value(const char* beginValue, const char* endValue) {
initBasic(stringValue, true);
value_.string_ =
- duplicateStringValue(beginValue, (unsigned int)(endValue - beginValue));
+ duplicateAndPrefixStringValue(beginValue, static_cast<unsigned>(endValue - beginValue));
}
-Value::Value(const std::string& value) {
+Value::Value(const JSONCPP_STRING& value) {
initBasic(stringValue, true);
value_.string_ =
- duplicateStringValue(value.c_str(), (unsigned int)value.length());
+ duplicateAndPrefixStringValue(value.data(), static_cast<unsigned>(value.length()));
}
Value::Value(const StaticString& value) {
@@ -316,7 +432,7 @@ Value::Value(const StaticString& value) {
#ifdef JSON_USE_CPPTL
Value::Value(const CppTL::ConstString& value) {
initBasic(stringValue, true);
- value_.string_ = duplicateStringValue(value, value.length());
+ value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(value.length()));
}
#endif
@@ -325,14 +441,11 @@ Value::Value(bool value) {
value_.bool_ = value;
}
-Value::Value(const Value& other)
+Value::Value(Value const& other)
: type_(other.type_), allocated_(false)
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
,
- itemIsUsed_(0)
-#endif
- ,
- comments_(0), start_(other.start_), limit_(other.limit_) {
+ comments_(0), start_(other.start_), limit_(other.limit_)
+{
switch (type_) {
case nullValue:
case intValue:
@@ -342,27 +455,22 @@ Value::Value(const Value& other)
value_ = other.value_;
break;
case stringValue:
- if (other.value_.string_) {
- value_.string_ = duplicateStringValue(other.value_.string_);
+ if (other.value_.string_ && other.allocated_) {
+ unsigned len;
+ char const* str;
+ decodePrefixedString(other.allocated_, other.value_.string_,
+ &len, &str);
+ value_.string_ = duplicateAndPrefixStringValue(str, len);
allocated_ = true;
} else {
- value_.string_ = 0;
+ value_.string_ = other.value_.string_;
allocated_ = false;
}
break;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
case arrayValue:
case objectValue:
value_.map_ = new ObjectValues(*other.value_.map_);
break;
-#else
- case arrayValue:
- value_.array_ = arrayAllocator()->newArrayCopy(*other.value_.array_);
- break;
- case objectValue:
- value_.map_ = mapAllocator()->newMapCopy(*other.value_.map_);
- break;
-#endif
default:
JSON_ASSERT_UNREACHABLE;
}
@@ -371,11 +479,20 @@ Value::Value(const Value& other)
for (int comment = 0; comment < numberOfCommentPlacement; ++comment) {
const CommentInfo& otherComment = other.comments_[comment];
if (otherComment.comment_)
- comments_[comment].setComment(otherComment.comment_);
+ comments_[comment].setComment(
+ otherComment.comment_, strlen(otherComment.comment_));
}
}
}
+#if JSON_HAS_RVALUE_REFERENCES
+// Move constructor
+Value::Value(Value&& other) {
+ initBasic(nullValue);
+ swap(other);
+}
+#endif
+
Value::~Value() {
switch (type_) {
case nullValue:
@@ -386,27 +503,19 @@ Value::~Value() {
break;
case stringValue:
if (allocated_)
- releaseStringValue(value_.string_);
+ releasePrefixedStringValue(value_.string_);
break;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
case arrayValue:
case objectValue:
delete value_.map_;
break;
-#else
- case arrayValue:
- arrayAllocator()->destructArray(value_.array_);
- break;
- case objectValue:
- mapAllocator()->destructMap(value_.map_);
- break;
-#endif
default:
JSON_ASSERT_UNREACHABLE;
}
- if (comments_)
- delete[] comments_;
+ delete[] comments_;
+
+ value_.uint_ = 0;
}
Value& Value::operator=(Value other) {
@@ -414,18 +523,36 @@ Value& Value::operator=(Value other) {
return *this;
}
-void Value::swap(Value& other) {
+void Value::swapPayload(Value& other) {
ValueType temp = type_;
type_ = other.type_;
other.type_ = temp;
std::swap(value_, other.value_);
int temp2 = allocated_;
allocated_ = other.allocated_;
- other.allocated_ = temp2;
+ other.allocated_ = temp2 & 0x1;
+}
+
+void Value::copyPayload(const Value& other) {
+ type_ = other.type_;
+ value_ = other.value_;
+ allocated_ = other.allocated_;
+}
+
+void Value::swap(Value& other) {
+ swapPayload(other);
+ std::swap(comments_, other.comments_);
std::swap(start_, other.start_);
std::swap(limit_, other.limit_);
}
+void Value::copy(const Value& other) {
+ copyPayload(other);
+ comments_ = other.comments_;
+ start_ = other.start_;
+ limit_ = other.limit_;
+}
+
ValueType Value::type() const { return type_; }
int Value::compare(const Value& other) const {
@@ -452,10 +579,24 @@ bool Value::operator<(const Value& other) const {
case booleanValue:
return value_.bool_ < other.value_.bool_;
case stringValue:
- return (value_.string_ == 0 && other.value_.string_) ||
- (other.value_.string_ && value_.string_ &&
- strcmp(value_.string_, other.value_.string_) < 0);
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
+ {
+ if ((value_.string_ == 0) || (other.value_.string_ == 0)) {
+ if (other.value_.string_) return true;
+ else return false;
+ }
+ unsigned this_len;
+ unsigned other_len;
+ char const* this_str;
+ char const* other_str;
+ decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
+ decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str);
+ unsigned min_len = std::min<unsigned>(this_len, other_len);
+ JSON_ASSERT(this_str && other_str);
+ int comp = memcmp(this_str, other_str, min_len);
+ if (comp < 0) return true;
+ if (comp > 0) return false;
+ return (this_len < other_len);
+ }
case arrayValue:
case objectValue: {
int delta = int(value_.map_->size() - other.value_.map_->size());
@@ -463,12 +604,6 @@ bool Value::operator<(const Value& other) const {
return delta < 0;
return (*value_.map_) < (*other.value_.map_);
}
-#else
- case arrayValue:
- return value_.array_->compare(*(other.value_.array_)) < 0;
- case objectValue:
- return value_.map_->compare(*(other.value_.map_)) < 0;
-#endif
default:
JSON_ASSERT_UNREACHABLE;
}
@@ -501,20 +636,25 @@ bool Value::operator==(const Value& other) const {
case booleanValue:
return value_.bool_ == other.value_.bool_;
case stringValue:
- return (value_.string_ == other.value_.string_) ||
- (other.value_.string_ && value_.string_ &&
- strcmp(value_.string_, other.value_.string_) == 0);
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
+ {
+ if ((value_.string_ == 0) || (other.value_.string_ == 0)) {
+ return (value_.string_ == other.value_.string_);
+ }
+ unsigned this_len;
+ unsigned other_len;
+ char const* this_str;
+ char const* other_str;
+ decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
+ decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str);
+ if (this_len != other_len) return false;
+ JSON_ASSERT(this_str && other_str);
+ int comp = memcmp(this_str, other_str, this_len);
+ return comp == 0;
+ }
case arrayValue:
case objectValue:
return value_.map_->size() == other.value_.map_->size() &&
(*value_.map_) == (*other.value_.map_);
-#else
- case arrayValue:
- return value_.array_->compare(*(other.value_.array_)) == 0;
- case objectValue:
- return value_.map_->compare(*(other.value_.map_)) == 0;
-#endif
default:
JSON_ASSERT_UNREACHABLE;
}
@@ -526,15 +666,46 @@ bool Value::operator!=(const Value& other) const { return !(*this == other); }
const char* Value::asCString() const {
JSON_ASSERT_MESSAGE(type_ == stringValue,
"in Json::Value::asCString(): requires stringValue");
- return value_.string_;
+ if (value_.string_ == 0) return 0;
+ unsigned this_len;
+ char const* this_str;
+ decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
+ return this_str;
+}
+
+#if JSONCPP_USING_SECURE_MEMORY
+unsigned Value::getCStringLength() const {
+ JSON_ASSERT_MESSAGE(type_ == stringValue,
+ "in Json::Value::asCString(): requires stringValue");
+ if (value_.string_ == 0) return 0;
+ unsigned this_len;
+ char const* this_str;
+ decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
+ return this_len;
+}
+#endif
+
+bool Value::getString(char const** str, char const** cend) const {
+ if (type_ != stringValue) return false;
+ if (value_.string_ == 0) return false;
+ unsigned length;
+ decodePrefixedString(this->allocated_, this->value_.string_, &length, str);
+ *cend = *str + length;
+ return true;
}
-std::string Value::asString() const {
+JSONCPP_STRING Value::asString() const {
switch (type_) {
case nullValue:
return "";
case stringValue:
- return value_.string_ ? value_.string_ : "";
+ {
+ if (value_.string_ == 0) return "";
+ unsigned this_len;
+ char const* this_str;
+ decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
+ return JSONCPP_STRING(this_str, this_len);
+ }
case booleanValue:
return value_.bool_ ? "true" : "false";
case intValue:
@@ -550,7 +721,11 @@ std::string Value::asString() const {
#ifdef JSON_USE_CPPTL
CppTL::ConstString Value::asConstString() const {
- return CppTL::ConstString(asString().c_str());
+ unsigned len;
+ char const* str;
+ decodePrefixedString(allocated_, value_.string_,
+ &len, &str);
+ return CppTL::ConstString(str, len);
}
#endif
@@ -689,7 +864,8 @@ float Value::asFloat() const {
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
return static_cast<float>(value_.uint_);
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
- return integerToDouble(value_.uint_);
+ // This can fail (silently?) if the value is bigger than MAX_FLOAT.
+ return static_cast<float>(integerToDouble(value_.uint_));
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
case realValue:
return static_cast<float>(value_.real_);
@@ -714,7 +890,8 @@ bool Value::asBool() const {
case uintValue:
return value_.uint_ ? true : false;
case realValue:
- return value_.real_ ? true : false;
+ // This is kind of strange. Not recommended.
+ return (value_.real_ != 0.0) ? true : false;
default:
break;
}
@@ -726,7 +903,7 @@ bool Value::isConvertibleTo(ValueType other) const {
case nullValue:
return (isNumeric() && asDouble() == 0.0) ||
(type_ == booleanValue && value_.bool_ == false) ||
- (type_ == stringValue && asString() == "") ||
+ (type_ == stringValue && asString().empty()) ||
(type_ == arrayValue && value_.map_->size() == 0) ||
(type_ == objectValue && value_.map_->size() == 0) ||
type_ == nullValue;
@@ -764,7 +941,6 @@ ArrayIndex Value::size() const {
case booleanValue:
case stringValue:
return 0;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
case arrayValue: // size of the array is highest index + 1
if (!value_.map_->empty()) {
ObjectValues::const_iterator itLast = value_.map_->end();
@@ -774,12 +950,6 @@ ArrayIndex Value::size() const {
return 0;
case objectValue:
return ArrayIndex(value_.map_->size());
-#else
- case arrayValue:
- return Int(value_.array_->size());
- case objectValue:
- return Int(value_.map_->size());
-#endif
}
JSON_ASSERT_UNREACHABLE;
return 0; // unreachable;
@@ -801,19 +971,10 @@ void Value::clear() {
start_ = 0;
limit_ = 0;
switch (type_) {
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
case arrayValue:
case objectValue:
value_.map_->clear();
break;
-#else
- case arrayValue:
- value_.array_->clear();
- break;
- case objectValue:
- value_.map_->clear();
- break;
-#endif
default:
break;
}
@@ -824,7 +985,6 @@ void Value::resize(ArrayIndex newSize) {
"in Json::Value::resize(): requires arrayValue");
if (type_ == nullValue)
*this = Value(arrayValue);
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
ArrayIndex oldSize = size();
if (newSize == 0)
clear();
@@ -834,11 +994,8 @@ void Value::resize(ArrayIndex newSize) {
for (ArrayIndex index = newSize; index < oldSize; ++index) {
value_.map_->erase(index);
}
- assert(size() == newSize);
+ JSON_ASSERT(size() == newSize);
}
-#else
- value_.array_->resize(newSize);
-#endif
}
Value& Value::operator[](ArrayIndex index) {
@@ -847,18 +1004,14 @@ Value& Value::operator[](ArrayIndex index) {
"in Json::Value::operator[](ArrayIndex): requires arrayValue");
if (type_ == nullValue)
*this = Value(arrayValue);
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
CZString key(index);
ObjectValues::iterator it = value_.map_->lower_bound(key);
if (it != value_.map_->end() && (*it).first == key)
return (*it).second;
- ObjectValues::value_type defaultValue(key, null);
+ ObjectValues::value_type defaultValue(key, nullSingleton());
it = value_.map_->insert(it, defaultValue);
return (*it).second;
-#else
- return value_.array_->resolveReference(index);
-#endif
}
Value& Value::operator[](int index) {
@@ -873,17 +1026,12 @@ const Value& Value::operator[](ArrayIndex index) const {
type_ == nullValue || type_ == arrayValue,
"in Json::Value::operator[](ArrayIndex)const: requires arrayValue");
if (type_ == nullValue)
- return null;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
+ return nullSingleton();
CZString key(index);
ObjectValues::const_iterator it = value_.map_->find(key);
if (it == value_.map_->end())
- return null;
+ return nullSingleton();
return (*it).second;
-#else
- Value* value = value_.array_->find(index);
- return value ? *value : null;
-#endif
}
const Value& Value::operator[](int index) const {
@@ -893,149 +1041,215 @@ const Value& Value::operator[](int index) const {
return (*this)[ArrayIndex(index)];
}
-Value& Value::operator[](const char* key) {
- return resolveReference(key, false);
-}
-
-void Value::initBasic(ValueType type, bool allocated) {
- type_ = type;
+void Value::initBasic(ValueType vtype, bool allocated) {
+ type_ = vtype;
allocated_ = allocated;
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- itemIsUsed_ = 0;
-#endif
comments_ = 0;
start_ = 0;
limit_ = 0;
}
-Value& Value::resolveReference(const char* key, bool isStatic) {
+// Access an object value by name, create a null member if it does not exist.
+// @pre Type of '*this' is object or null.
+// @param key is null-terminated.
+Value& Value::resolveReference(const char* key) {
JSON_ASSERT_MESSAGE(
type_ == nullValue || type_ == objectValue,
"in Json::Value::resolveReference(): requires objectValue");
if (type_ == nullValue)
*this = Value(objectValue);
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
CZString actualKey(
- key, isStatic ? CZString::noDuplication : CZString::duplicateOnCopy);
+ key, static_cast<unsigned>(strlen(key)), CZString::noDuplication); // NOTE!
ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
if (it != value_.map_->end() && (*it).first == actualKey)
return (*it).second;
- ObjectValues::value_type defaultValue(actualKey, null);
+ ObjectValues::value_type defaultValue(actualKey, nullSingleton());
+ it = value_.map_->insert(it, defaultValue);
+ Value& value = (*it).second;
+ return value;
+}
+
+// @param key is not null-terminated.
+Value& Value::resolveReference(char const* key, char const* cend)
+{
+ JSON_ASSERT_MESSAGE(
+ type_ == nullValue || type_ == objectValue,
+ "in Json::Value::resolveReference(key, end): requires objectValue");
+ if (type_ == nullValue)
+ *this = Value(objectValue);
+ CZString actualKey(
+ key, static_cast<unsigned>(cend-key), CZString::duplicateOnCopy);
+ ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
+ if (it != value_.map_->end() && (*it).first == actualKey)
+ return (*it).second;
+
+ ObjectValues::value_type defaultValue(actualKey, nullSingleton());
it = value_.map_->insert(it, defaultValue);
Value& value = (*it).second;
return value;
-#else
- return value_.map_->resolveReference(key, isStatic);
-#endif
}
Value Value::get(ArrayIndex index, const Value& defaultValue) const {
const Value* value = &((*this)[index]);
- return value == &null ? defaultValue : *value;
+ return value == &nullSingleton() ? defaultValue : *value;
}
bool Value::isValidIndex(ArrayIndex index) const { return index < size(); }
-const Value& Value::operator[](const char* key) const {
+Value const* Value::find(char const* key, char const* cend) const
+{
JSON_ASSERT_MESSAGE(
type_ == nullValue || type_ == objectValue,
- "in Json::Value::operator[](char const*)const: requires objectValue");
- if (type_ == nullValue)
- return null;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
- CZString actualKey(key, CZString::noDuplication);
+ "in Json::Value::find(key, end, found): requires objectValue or nullValue");
+ if (type_ == nullValue) return NULL;
+ CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
ObjectValues::const_iterator it = value_.map_->find(actualKey);
- if (it == value_.map_->end())
- return null;
- return (*it).second;
-#else
- const Value* value = value_.map_->find(key);
- return value ? *value : null;
-#endif
+ if (it == value_.map_->end()) return NULL;
+ return &(*it).second;
+}
+const Value& Value::operator[](const char* key) const
+{
+ Value const* found = find(key, key + strlen(key));
+ if (!found) return nullSingleton();
+ return *found;
+}
+Value const& Value::operator[](JSONCPP_STRING const& key) const
+{
+ Value const* found = find(key.data(), key.data() + key.length());
+ if (!found) return nullSingleton();
+ return *found;
}
-Value& Value::operator[](const std::string& key) {
- return (*this)[key.c_str()];
+Value& Value::operator[](const char* key) {
+ return resolveReference(key, key + strlen(key));
}
-const Value& Value::operator[](const std::string& key) const {
- return (*this)[key.c_str()];
+Value& Value::operator[](const JSONCPP_STRING& key) {
+ return resolveReference(key.data(), key.data() + key.length());
}
Value& Value::operator[](const StaticString& key) {
- return resolveReference(key, true);
+ return resolveReference(key.c_str());
}
#ifdef JSON_USE_CPPTL
Value& Value::operator[](const CppTL::ConstString& key) {
- return (*this)[key.c_str()];
+ return resolveReference(key.c_str(), key.end_c_str());
}
-
-const Value& Value::operator[](const CppTL::ConstString& key) const {
- return (*this)[key.c_str()];
+Value const& Value::operator[](CppTL::ConstString const& key) const
+{
+ Value const* found = find(key.c_str(), key.end_c_str());
+ if (!found) return nullSingleton();
+ return *found;
}
#endif
Value& Value::append(const Value& value) { return (*this)[size()] = value; }
-Value Value::get(const char* key, const Value& defaultValue) const {
- const Value* value = &((*this)[key]);
- return value == &null ? defaultValue : *value;
-}
+#if JSON_HAS_RVALUE_REFERENCES
+ Value& Value::append(Value&& value) { return (*this)[size()] = value; }
+#endif
-Value Value::get(const std::string& key, const Value& defaultValue) const {
- return get(key.c_str(), defaultValue);
+Value Value::get(char const* key, char const* cend, Value const& defaultValue) const
+{
+ Value const* found = find(key, cend);
+ return !found ? defaultValue : *found;
+}
+Value Value::get(char const* key, Value const& defaultValue) const
+{
+ return get(key, key + strlen(key), defaultValue);
+}
+Value Value::get(JSONCPP_STRING const& key, Value const& defaultValue) const
+{
+ return get(key.data(), key.data() + key.length(), defaultValue);
}
-Value Value::removeMember(const char* key) {
- JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
- "in Json::Value::removeMember(): requires objectValue");
- if (type_ == nullValue)
- return null;
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
- CZString actualKey(key, CZString::noDuplication);
+
+bool Value::removeMember(const char* key, const char* cend, Value* removed)
+{
+ if (type_ != objectValue) {
+ return false;
+ }
+ CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
ObjectValues::iterator it = value_.map_->find(actualKey);
if (it == value_.map_->end())
- return null;
- Value old(it->second);
+ return false;
+ *removed = it->second;
value_.map_->erase(it);
- return old;
-#else
- Value* value = value_.map_->find(key);
- if (value) {
- Value old(*value);
- value_.map_.remove(key);
- return old;
- } else {
- return null;
- }
-#endif
+ return true;
+}
+bool Value::removeMember(const char* key, Value* removed)
+{
+ return removeMember(key, key + strlen(key), removed);
}
+bool Value::removeMember(JSONCPP_STRING const& key, Value* removed)
+{
+ return removeMember(key.data(), key.data() + key.length(), removed);
+}
+Value Value::removeMember(const char* key)
+{
+ JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
+ "in Json::Value::removeMember(): requires objectValue");
+ if (type_ == nullValue)
+ return nullSingleton();
-Value Value::removeMember(const std::string& key) {
+ Value removed; // null
+ removeMember(key, key + strlen(key), &removed);
+ return removed; // still null if removeMember() did nothing
+}
+Value Value::removeMember(const JSONCPP_STRING& key)
+{
return removeMember(key.c_str());
}
+bool Value::removeIndex(ArrayIndex index, Value* removed) {
+ if (type_ != arrayValue) {
+ return false;
+ }
+ CZString key(index);
+ ObjectValues::iterator it = value_.map_->find(key);
+ if (it == value_.map_->end()) {
+ return false;
+ }
+ *removed = it->second;
+ ArrayIndex oldSize = size();
+ // shift left all items left, into the place of the "removed"
+ for (ArrayIndex i = index; i < (oldSize - 1); ++i){
+ CZString keey(i);
+ (*value_.map_)[keey] = (*this)[i + 1];
+ }
+ // erase the last one ("leftover")
+ CZString keyLast(oldSize - 1);
+ ObjectValues::iterator itLast = value_.map_->find(keyLast);
+ value_.map_->erase(itLast);
+ return true;
+}
+
#ifdef JSON_USE_CPPTL
Value Value::get(const CppTL::ConstString& key,
const Value& defaultValue) const {
- return get(key.c_str(), defaultValue);
+ return get(key.c_str(), key.end_c_str(), defaultValue);
}
#endif
-bool Value::isMember(const char* key) const {
- const Value* value = &((*this)[key]);
- return value != &null;
+bool Value::isMember(char const* key, char const* cend) const
+{
+ Value const* value = find(key, cend);
+ return NULL != value;
}
-
-bool Value::isMember(const std::string& key) const {
- return isMember(key.c_str());
+bool Value::isMember(char const* key) const
+{
+ return isMember(key, key + strlen(key));
+}
+bool Value::isMember(JSONCPP_STRING const& key) const
+{
+ return isMember(key.data(), key.data() + key.length());
}
#ifdef JSON_USE_CPPTL
bool Value::isMember(const CppTL::ConstString& key) const {
- return isMember(key.c_str());
+ return isMember(key.c_str(), key.end_c_str());
}
#endif
@@ -1047,19 +1261,12 @@ Value::Members Value::getMemberNames() const {
return Value::Members();
Members members;
members.reserve(value_.map_->size());
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
ObjectValues::const_iterator it = value_.map_->begin();
ObjectValues::const_iterator itEnd = value_.map_->end();
- for (; it != itEnd; ++it)
- members.push_back(std::string((*it).first.c_str()));
-#else
- ValueInternalMap::IteratorState it;
- ValueInternalMap::IteratorState itEnd;
- value_.map_->makeBeginIterator(it);
- value_.map_->makeEndIterator(itEnd);
- for (; !ValueInternalMap::equals(it, itEnd); ValueInternalMap::increment(it))
- members.push_back(std::string(ValueInternalMap::key(it)));
-#endif
+ for (; it != itEnd; ++it) {
+ members.push_back(JSONCPP_STRING((*it).first.data(),
+ (*it).first.length()));
+ }
return members;
}
//
@@ -1100,7 +1307,11 @@ bool Value::isBool() const { return type_ == booleanValue; }
bool Value::isInt() const {
switch (type_) {
case intValue:
+#if defined(JSON_HAS_INT64)
return value_.int_ >= minInt && value_.int_ <= maxInt;
+#else
+ return true;
+#endif
case uintValue:
return value_.uint_ <= UInt(maxInt);
case realValue:
@@ -1115,9 +1326,17 @@ bool Value::isInt() const {
bool Value::isUInt() const {
switch (type_) {
case intValue:
+#if defined(JSON_HAS_INT64)
return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);
+#else
+ return value_.int_ >= 0;
+#endif
case uintValue:
+#if defined(JSON_HAS_INT64)
return value_.uint_ <= maxUInt;
+#else
+ return true;
+#endif
case realValue:
return value_.real_ >= 0 && value_.real_ <= maxUInt &&
IsIntegral(value_.real_);
@@ -1168,16 +1387,28 @@ bool Value::isUInt64() const {
}
bool Value::isIntegral() const {
+ switch (type_) {
+ case intValue:
+ case uintValue:
+ return true;
+ case realValue:
#if defined(JSON_HAS_INT64)
- return isInt64() || isUInt64();
+ // Note that maxUInt64 (= 2^64 - 1) is not exactly representable as a
+ // double, so double(maxUInt64) will be rounded up to 2^64. Therefore we
+ // require the value to be strictly less than the limit.
+ return value_.real_ >= double(minInt64) && value_.real_ < maxUInt64AsDouble && IsIntegral(value_.real_);
#else
- return isInt() || isUInt();
-#endif
+ return value_.real_ >= minInt && value_.real_ <= maxUInt && IsIntegral(value_.real_);
+#endif // JSON_HAS_INT64
+ default:
+ break;
+ }
+ return false;
}
-bool Value::isDouble() const { return type_ == realValue || isIntegral(); }
+bool Value::isDouble() const { return type_ == intValue || type_ == uintValue || type_ == realValue; }
-bool Value::isNumeric() const { return isIntegral() || isDouble(); }
+bool Value::isNumeric() const { return isDouble(); }
bool Value::isString() const { return type_ == stringValue; }
@@ -1185,63 +1416,59 @@ bool Value::isArray() const { return type_ == arrayValue; }
bool Value::isObject() const { return type_ == objectValue; }
-void Value::setComment(const char* comment, CommentPlacement placement) {
+void Value::setComment(const char* comment, size_t len, CommentPlacement placement) {
if (!comments_)
comments_ = new CommentInfo[numberOfCommentPlacement];
- comments_[placement].setComment(comment);
+ if ((len > 0) && (comment[len-1] == '\n')) {
+ // Always discard trailing newline, to aid indentation.
+ len -= 1;
+ }
+ comments_[placement].setComment(comment, len);
+}
+
+void Value::setComment(const char* comment, CommentPlacement placement) {
+ setComment(comment, strlen(comment), placement);
}
-void Value::setComment(const std::string& comment, CommentPlacement placement) {
- setComment(comment.c_str(), placement);
+void Value::setComment(const JSONCPP_STRING& comment, CommentPlacement placement) {
+ setComment(comment.c_str(), comment.length(), placement);
}
bool Value::hasComment(CommentPlacement placement) const {
return comments_ != 0 && comments_[placement].comment_ != 0;
}
-std::string Value::getComment(CommentPlacement placement) const {
+JSONCPP_STRING Value::getComment(CommentPlacement placement) const {
if (hasComment(placement))
return comments_[placement].comment_;
return "";
}
-void Value::setOffsetStart(size_t start) { start_ = start; }
+void Value::setOffsetStart(ptrdiff_t start) { start_ = start; }
+
+void Value::setOffsetLimit(ptrdiff_t limit) { limit_ = limit; }
-void Value::setOffsetLimit(size_t limit) { limit_ = limit; }
+ptrdiff_t Value::getOffsetStart() const { return start_; }
-size_t Value::getOffsetStart() const { return start_; }
+ptrdiff_t Value::getOffsetLimit() const { return limit_; }
-size_t Value::getOffsetLimit() const { return limit_; }
+JSONCPP_STRING Value::toStyledString() const {
+ StreamWriterBuilder builder;
-std::string Value::toStyledString() const {
- StyledWriter writer;
- return writer.write(*this);
+ JSONCPP_STRING out = this->hasComment(commentBefore) ? "\n" : "";
+ out += Json::writeString(builder, *this);
+ out += "\n";
+
+ return out;
}
Value::const_iterator Value::begin() const {
switch (type_) {
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- case arrayValue:
- if (value_.array_) {
- ValueInternalArray::IteratorState it;
- value_.array_->makeBeginIterator(it);
- return const_iterator(it);
- }
- break;
- case objectValue:
- if (value_.map_) {
- ValueInternalMap::IteratorState it;
- value_.map_->makeBeginIterator(it);
- return const_iterator(it);
- }
- break;
-#else
case arrayValue:
case objectValue:
if (value_.map_)
return const_iterator(value_.map_->begin());
break;
-#endif
default:
break;
}
@@ -1250,28 +1477,11 @@ Value::const_iterator Value::begin() const {
Value::const_iterator Value::end() const {
switch (type_) {
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- case arrayValue:
- if (value_.array_) {
- ValueInternalArray::IteratorState it;
- value_.array_->makeEndIterator(it);
- return const_iterator(it);
- }
- break;
- case objectValue:
- if (value_.map_) {
- ValueInternalMap::IteratorState it;
- value_.map_->makeEndIterator(it);
- return const_iterator(it);
- }
- break;
-#else
case arrayValue:
case objectValue:
if (value_.map_)
return const_iterator(value_.map_->end());
break;
-#endif
default:
break;
}
@@ -1280,28 +1490,11 @@ Value::const_iterator Value::end() const {
Value::iterator Value::begin() {
switch (type_) {
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- case arrayValue:
- if (value_.array_) {
- ValueInternalArray::IteratorState it;
- value_.array_->makeBeginIterator(it);
- return iterator(it);
- }
- break;
- case objectValue:
- if (value_.map_) {
- ValueInternalMap::IteratorState it;
- value_.map_->makeBeginIterator(it);
- return iterator(it);
- }
- break;
-#else
case arrayValue:
case objectValue:
if (value_.map_)
return iterator(value_.map_->begin());
break;
-#endif
default:
break;
}
@@ -1310,28 +1503,11 @@ Value::iterator Value::begin() {
Value::iterator Value::end() {
switch (type_) {
-#ifdef JSON_VALUE_USE_INTERNAL_MAP
- case arrayValue:
- if (value_.array_) {
- ValueInternalArray::IteratorState it;
- value_.array_->makeEndIterator(it);
- return iterator(it);
- }
- break;
- case objectValue:
- if (value_.map_) {
- ValueInternalMap::IteratorState it;
- value_.map_->makeEndIterator(it);
- return iterator(it);
- }
- break;
-#else
case arrayValue:
case objectValue:
if (value_.map_)
return iterator(value_.map_->end());
break;
-#endif
default:
break;
}
@@ -1349,19 +1525,20 @@ PathArgument::PathArgument(ArrayIndex index)
PathArgument::PathArgument(const char* key)
: key_(key), index_(), kind_(kindKey) {}
-PathArgument::PathArgument(const std::string& key)
+PathArgument::PathArgument(const JSONCPP_STRING& key)
: key_(key.c_str()), index_(), kind_(kindKey) {}
// class Path
// //////////////////////////////////////////////////////////////////
-Path::Path(const std::string& path,
+Path::Path(const JSONCPP_STRING& path,
const PathArgument& a1,
const PathArgument& a2,
const PathArgument& a3,
const PathArgument& a4,
const PathArgument& a5) {
InArgs in;
+ in.reserve(5);
in.push_back(&a1);
in.push_back(&a2);
in.push_back(&a3);
@@ -1370,7 +1547,7 @@ Path::Path(const std::string& path,
makePath(path, in);
}
-void Path::makePath(const std::string& path, const InArgs& in) {
+void Path::makePath(const JSONCPP_STRING& path, const InArgs& in) {
const char* current = path.c_str();
const char* end = current + path.length();
InArgs::const_iterator itInArg = in.begin();
@@ -1385,23 +1562,23 @@ void Path::makePath(const std::string& path, const InArgs& in) {
index = index * 10 + ArrayIndex(*current - '0');
args_.push_back(index);
}
- if (current == end || *current++ != ']')
+ if (current == end || *++current != ']')
invalidPath(path, int(current - path.c_str()));
} else if (*current == '%') {
addPathInArg(path, in, itInArg, PathArgument::kindKey);
++current;
- } else if (*current == '.') {
+ } else if (*current == '.' || *current == ']') {
++current;
} else {
const char* beginName = current;
while (current != end && !strchr("[.", *current))
++current;
- args_.push_back(std::string(beginName, current));
+ args_.push_back(JSONCPP_STRING(beginName, current));
}
}
}
-void Path::addPathInArg(const std::string& /*path*/,
+void Path::addPathInArg(const JSONCPP_STRING& /*path*/,
const InArgs& in,
InArgs::const_iterator& itInArg,
PathArgument::Kind kind) {
@@ -1410,11 +1587,11 @@ void Path::addPathInArg(const std::string& /*path*/,
} else if ((*itInArg)->kind_ != kind) {
// Error: bad argument type
} else {
- args_.push_back(**itInArg);
+ args_.push_back(**itInArg++);
}
}
-void Path::invalidPath(const std::string& /*path*/, int /*location*/) {
+void Path::invalidPath(const JSONCPP_STRING& /*path*/, int /*location*/) {
// Error: invalid path.
}
@@ -1425,16 +1602,19 @@ const Value& Path::resolve(const Value& root) const {
if (arg.kind_ == PathArgument::kindIndex) {
if (!node->isArray() || !node->isValidIndex(arg.index_)) {
// Error: unable to resolve path (array value expected at position...
+ return Value::null;
}
node = &((*node)[arg.index_]);
} else if (arg.kind_ == PathArgument::kindKey) {
if (!node->isObject()) {
// Error: unable to resolve path (object value expected at position...)
+ return Value::null;
}
node = &((*node)[arg.key_]);
- if (node == &Value::null) {
+ if (node == &Value::nullSingleton()) {
// Error: unable to resolve path (object has no member named '' at
// position...)
+ return Value::null;
}
}
}
@@ -1453,7 +1633,7 @@ Value Path::resolve(const Value& root, const Value& defaultValue) const {
if (!node->isObject())
return defaultValue;
node = &((*node)[arg.key_]);
- if (node == &Value::null)
+ if (node == &Value::nullSingleton())
return defaultValue;
}
}
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_valueiterator.inl b/Utilities/cmjsoncpp/src/lib_json/json_valueiterator.inl
index a9f7df63a..5243bfe4b 100644
--- a/Utilities/cmjsoncpp/src/lib_json/json_valueiterator.inl
+++ b/Utilities/cmjsoncpp/src/lib_json/json_valueiterator.inl
@@ -1,4 +1,4 @@
-// Copyright 2007-2010 Baptiste Lepilleur
+// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -16,68 +16,29 @@ namespace Json {
// //////////////////////////////////////////////////////////////////
ValueIteratorBase::ValueIteratorBase()
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
: current_(), isNull_(true) {
}
-#else
- : isArray_(true), isNull_(true) {
- iterator_.array_ = ValueInternalArray::IteratorState();
-}
-#endif
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
ValueIteratorBase::ValueIteratorBase(
const Value::ObjectValues::iterator& current)
: current_(current), isNull_(false) {}
-#else
-ValueIteratorBase::ValueIteratorBase(
- const ValueInternalArray::IteratorState& state)
- : isArray_(true) {
- iterator_.array_ = state;
-}
-
-ValueIteratorBase::ValueIteratorBase(
- const ValueInternalMap::IteratorState& state)
- : isArray_(false) {
- iterator_.map_ = state;
-}
-#endif
Value& ValueIteratorBase::deref() const {
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
return current_->second;
-#else
- if (isArray_)
- return ValueInternalArray::dereference(iterator_.array_);
- return ValueInternalMap::value(iterator_.map_);
-#endif
}
void ValueIteratorBase::increment() {
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
++current_;
-#else
- if (isArray_)
- ValueInternalArray::increment(iterator_.array_);
- ValueInternalMap::increment(iterator_.map_);
-#endif
}
void ValueIteratorBase::decrement() {
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
--current_;
-#else
- if (isArray_)
- ValueInternalArray::decrement(iterator_.array_);
- ValueInternalMap::decrement(iterator_.map_);
-#endif
}
ValueIteratorBase::difference_type
ValueIteratorBase::computeDistance(const SelfType& other) const {
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
#ifdef JSON_USE_CPPTL_SMALLMAP
- return current_ - other.current_;
+ return other.current_ - current_;
#else
// Iterator for null value are initialized using the default
// constructor, which initialize current_ to the default
@@ -100,80 +61,58 @@ ValueIteratorBase::computeDistance(const SelfType& other) const {
}
return myDistance;
#endif
-#else
- if (isArray_)
- return ValueInternalArray::distance(iterator_.array_,
- other.iterator_.array_);
- return ValueInternalMap::distance(iterator_.map_, other.iterator_.map_);
-#endif
}
bool ValueIteratorBase::isEqual(const SelfType& other) const {
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
if (isNull_) {
return other.isNull_;
}
return current_ == other.current_;
-#else
- if (isArray_)
- return ValueInternalArray::equals(iterator_.array_, other.iterator_.array_);
- return ValueInternalMap::equals(iterator_.map_, other.iterator_.map_);
-#endif
}
void ValueIteratorBase::copy(const SelfType& other) {
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
current_ = other.current_;
isNull_ = other.isNull_;
-#else
- if (isArray_)
- iterator_.array_ = other.iterator_.array_;
- iterator_.map_ = other.iterator_.map_;
-#endif
}
Value ValueIteratorBase::key() const {
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
const Value::CZString czstring = (*current_).first;
- if (czstring.c_str()) {
+ if (czstring.data()) {
if (czstring.isStaticString())
- return Value(StaticString(czstring.c_str()));
- return Value(czstring.c_str());
+ return Value(StaticString(czstring.data()));
+ return Value(czstring.data(), czstring.data() + czstring.length());
}
return Value(czstring.index());
-#else
- if (isArray_)
- return Value(ValueInternalArray::indexOf(iterator_.array_));
- bool isStatic;
- const char* memberName = ValueInternalMap::key(iterator_.map_, isStatic);
- if (isStatic)
- return Value(StaticString(memberName));
- return Value(memberName);
-#endif
}
UInt ValueIteratorBase::index() const {
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
const Value::CZString czstring = (*current_).first;
- if (!czstring.c_str())
+ if (!czstring.data())
return czstring.index();
return Value::UInt(-1);
-#else
- if (isArray_)
- return Value::UInt(ValueInternalArray::indexOf(iterator_.array_));
- return Value::UInt(-1);
-#endif
}
-const char* ValueIteratorBase::memberName() const {
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
- const char* name = (*current_).first.c_str();
- return name ? name : "";
-#else
- if (!isArray_)
- return ValueInternalMap::key(iterator_.map_);
- return "";
-#endif
+JSONCPP_STRING ValueIteratorBase::name() const {
+ char const* keey;
+ char const* end;
+ keey = memberName(&end);
+ if (!keey) return JSONCPP_STRING();
+ return JSONCPP_STRING(keey, end);
+}
+
+char const* ValueIteratorBase::memberName() const {
+ const char* cname = (*current_).first.data();
+ return cname ? cname : "";
+}
+
+char const* ValueIteratorBase::memberName(char const** end) const {
+ const char* cname = (*current_).first.data();
+ if (!cname) {
+ *end = NULL;
+ return NULL;
+ }
+ *end = cname + (*current_).first.length();
+ return cname;
}
// //////////////////////////////////////////////////////////////////
@@ -186,19 +125,12 @@ const char* ValueIteratorBase::memberName() const {
ValueConstIterator::ValueConstIterator() {}
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
ValueConstIterator::ValueConstIterator(
const Value::ObjectValues::iterator& current)
: ValueIteratorBase(current) {}
-#else
-ValueConstIterator::ValueConstIterator(
- const ValueInternalArray::IteratorState& state)
- : ValueIteratorBase(state) {}
-ValueConstIterator::ValueConstIterator(
- const ValueInternalMap::IteratorState& state)
- : ValueIteratorBase(state) {}
-#endif
+ValueConstIterator::ValueConstIterator(ValueIterator const& other)
+ : ValueIteratorBase(other) {}
ValueConstIterator& ValueConstIterator::
operator=(const ValueIteratorBase& other) {
@@ -216,19 +148,13 @@ operator=(const ValueIteratorBase& other) {
ValueIterator::ValueIterator() {}
-#ifndef JSON_VALUE_USE_INTERNAL_MAP
ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)
: ValueIteratorBase(current) {}
-#else
-ValueIterator::ValueIterator(const ValueInternalArray::IteratorState& state)
- : ValueIteratorBase(state) {}
-
-ValueIterator::ValueIterator(const ValueInternalMap::IteratorState& state)
- : ValueIteratorBase(state) {}
-#endif
ValueIterator::ValueIterator(const ValueConstIterator& other)
- : ValueIteratorBase(other) {}
+ : ValueIteratorBase(other) {
+ throwRuntimeError("ConstIterator to Iterator should never be allowed.");
+}
ValueIterator::ValueIterator(const ValueIterator& other)
: ValueIteratorBase(other) {}
diff --git a/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp b/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp
index e3f4e53cf..fc8650598 100644
--- a/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp
+++ b/Utilities/cmjsoncpp/src/lib_json/json_writer.cpp
@@ -1,4 +1,4 @@
-// Copyright 2011 Baptiste Lepilleur
+// Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors
// Distributed under MIT license, or public domain if desired and
// recognized in your jurisdiction.
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
@@ -7,15 +7,62 @@
#include <json/writer.h>
#include "json_tool.h"
#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <utility>
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include <sstream>
#include <iomanip>
+#include <memory>
+#include <sstream>
+#include <utility>
+#include <set>
+#include <cassert>
+#include <cstring>
+#include <cstdio>
+
+#if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1800 // Between VC++ 6.0 and VC++ 11.0
+#include <float.h>
+#define isfinite _finite
+#elif defined(__sun) && defined(__SVR4) //Solaris
+#if !defined(isfinite)
+#include <ieeefp.h>
+#define isfinite finite
+#endif
+#elif defined(_AIX)
+#if !defined(isfinite)
#include <math.h>
+#define isfinite finite
+#endif
+#elif defined(__hpux)
+#if !defined(isfinite) && !defined(__GNUC__)
+#if defined(__ia64) && !defined(finite)
+#define isfinite(x) ((sizeof(x) == sizeof(float) ? \
+ _Isfinitef(x) : _IsFinite(x)))
+#else
+#include <math.h>
+#define isfinite finite
+#endif
+#endif
+#else
+#include <cmath>
+#if !(defined(__QNXNTO__)) // QNX already defines isfinite
+#define isfinite std::isfinite
+#endif
+#endif
+
+#if defined(_MSC_VER)
+#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
+#define snprintf sprintf_s
+#elif _MSC_VER >= 1900 // VC++ 14.0 and above
+#define snprintf std::snprintf
+#else
+#define snprintf _snprintf
+#endif
+#elif defined(__ANDROID__) || defined(__QNXNTO__)
+#define snprintf snprintf
+#elif __cplusplus >= 201103L
+#if !defined(__MINGW32__) && !defined(__CYGWIN__)
+#define snprintf std::snprintf
+#endif
+#endif
-#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below
+#if defined(__BORLANDC__)
#include <float.h>
#define isfinite _finite
#define snprintf _snprintf
@@ -39,10 +86,11 @@
// HP-UX
#if defined(__hpux)
# if !defined(isfinite)
-# if defined(__ia64) && !defined(finite)
+# if defined(__ia64) && !defined(finite) && !defined(__GNUC__)
# define isfinite(x) ((sizeof(x) == sizeof(float) ? \
_Isfinitef(x) : _Isfinite(x)))
# else
+# include <math.h>
# define isfinite finite
# endif
# endif
@@ -62,6 +110,12 @@
namespace Json {
+#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
+typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
+#else
+typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
+#endif
+
static bool containsControlCharacter(const char* str) {
while (*str) {
if (isControlCharacter(*(str++)))
@@ -70,20 +124,33 @@ static bool containsControlCharacter(const char* str) {
return false;
}
-std::string valueToString(LargestInt value) {
+static bool containsControlCharacter0(const char* str, unsigned len) {
+ char const* end = str + len;
+ while (end != str) {
+ if (isControlCharacter(*str) || 0==*str)
+ return true;
+ ++str;
+ }
+ return false;
+}
+
+JSONCPP_STRING valueToString(LargestInt value) {
UIntToStringBuffer buffer;
char* current = buffer + sizeof(buffer);
- bool isNegative = value < 0;
- if (isNegative)
- value = -value;
- uintToString(LargestUInt(value), current);
- if (isNegative)
+ if (value == Value::minLargestInt) {
+ uintToString(LargestUInt(Value::maxLargestInt) + 1, current);
*--current = '-';
+ } else if (value < 0) {
+ uintToString(LargestUInt(-value), current);
+ *--current = '-';
+ } else {
+ uintToString(LargestUInt(value), current);
+ }
assert(current >= buffer);
return current;
}
-std::string valueToString(LargestUInt value) {
+JSONCPP_STRING valueToString(LargestUInt value) {
UIntToStringBuffer buffer;
char* current = buffer + sizeof(buffer);
uintToString(value, current);
@@ -93,68 +160,70 @@ std::string valueToString(LargestUInt value) {
#if defined(JSON_HAS_INT64)
-std::string valueToString(Int value) {
+JSONCPP_STRING valueToString(Int value) {
return valueToString(LargestInt(value));
}
-std::string valueToString(UInt value) {
+JSONCPP_STRING valueToString(UInt value) {
return valueToString(LargestUInt(value));
}
#endif // # if defined(JSON_HAS_INT64)
-std::string valueToString(double value) {
+namespace {
+JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int precision) {
// Allocate a buffer that is more than large enough to store the 16 digits of
// precision requested below.
- char buffer[32];
+ char buffer[36];
int len = -1;
-// Print into the buffer. We need not request the alternative representation
-// that always has a decimal point because JSON doesn't distingish the
-// concepts of reals and integers.
-#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with
- // visual studio 2005 to
- // avoid warning.
-#if defined(WINCE)
- len = _snprintf(buffer, sizeof(buffer), "%.16g", value);
-#else
- len = sprintf_s(buffer, sizeof(buffer), "%.16g", value);
-#endif
-#else
+ char formatString[15];
+ snprintf(formatString, sizeof(formatString), "%%.%dg", precision);
+
+ // Print into the buffer. We need not request the alternative representation
+ // that always has a decimal point because JSON doesn't distingish the
+ // concepts of reals and integers.
if (isfinite(value)) {
- len = snprintf(buffer, sizeof(buffer), "%.16g", value);
+ len = snprintf(buffer, sizeof(buffer), formatString, value);
+ fixNumericLocale(buffer, buffer + len);
+
+ // try to ensure we preserve the fact that this was given to us as a double on input
+ if (!strchr(buffer, '.') && !strchr(buffer, 'e')) {
+ strcat(buffer, ".0");
+ }
+
} else {
// IEEE standard states that NaN values will not compare to themselves
if (value != value) {
- len = snprintf(buffer, sizeof(buffer), "null");
+ len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "NaN" : "null");
} else if (value < 0) {
- len = snprintf(buffer, sizeof(buffer), "-1e+9999");
+ len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "-Infinity" : "-1e+9999");
} else {
- len = snprintf(buffer, sizeof(buffer), "1e+9999");
+ len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "Infinity" : "1e+9999");
}
- // For those, we do not need to call fixNumLoc, but it is fast.
}
-#endif
assert(len >= 0);
- fixNumericLocale(buffer, buffer + len);
return buffer;
}
+}
+
+JSONCPP_STRING valueToString(double value) { return valueToString(value, false, 17); }
-std::string valueToString(bool value) { return value ? "true" : "false"; }
+JSONCPP_STRING valueToString(bool value) { return value ? "true" : "false"; }
-std::string valueToQuotedString(const char* value) {
+JSONCPP_STRING valueToQuotedString(const char* value) {
if (value == NULL)
return "";
// Not sure how to handle unicode...
if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL &&
!containsControlCharacter(value))
- return std::string("\"") + value + "\"";
+ return JSONCPP_STRING("\"") + value + "\"";
// We have to walk value and escape any special characters.
- // Appending to std::string is not efficient, but this should be rare.
+ // Appending to JSONCPP_STRING is not efficient, but this should be rare.
// (Note: forward slashes are *not* rare, but I am not escaping them.)
- std::string::size_type maxsize =
+ JSONCPP_STRING::size_type maxsize =
strlen(value) * 2 + 3; // allescaped+quotes+NULL
- std::string result;
+ JSONCPP_STRING result;
result.reserve(maxsize); // to avoid lots of mallocs
result += "\"";
for (const char* c = value; *c != 0; ++c) {
@@ -190,7 +259,85 @@ std::string valueToQuotedString(const char* value) {
// sequence from occurring.
default:
if (isControlCharacter(*c)) {
- std::ostringstream oss;
+ JSONCPP_OSTRINGSTREAM oss;
+ oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
+ << std::setw(4) << static_cast<int>(*c);
+ result += oss.str();
+ } else {
+ result += *c;
+ }
+ break;
+ }
+ }
+ result += "\"";
+ return result;
+}
+
+// https://github.com/upcaste/upcaste/blob/master/src/upcore/src/cstring/strnpbrk.cpp
+static char const* strnpbrk(char const* s, char const* accept, size_t n) {
+ assert((s || !n) && accept);
+
+ char const* const end = s + n;
+ for (char const* cur = s; cur < end; ++cur) {
+ int const c = *cur;
+ for (char const* a = accept; *a; ++a) {
+ if (*a == c) {
+ return cur;
+ }
+ }
+ }
+ return NULL;
+}
+static JSONCPP_STRING valueToQuotedStringN(const char* value, unsigned length) {
+ if (value == NULL)
+ return "";
+ // Not sure how to handle unicode...
+ if (strnpbrk(value, "\"\\\b\f\n\r\t", length) == NULL &&
+ !containsControlCharacter0(value, length))
+ return JSONCPP_STRING("\"") + value + "\"";
+ // We have to walk value and escape any special characters.
+ // Appending to JSONCPP_STRING is not efficient, but this should be rare.
+ // (Note: forward slashes are *not* rare, but I am not escaping them.)
+ JSONCPP_STRING::size_type maxsize =
+ length * 2 + 3; // allescaped+quotes+NULL
+ JSONCPP_STRING result;
+ result.reserve(maxsize); // to avoid lots of mallocs
+ result += "\"";
+ char const* end = value + length;
+ for (const char* c = value; c != end; ++c) {
+ switch (*c) {
+ case '\"':
+ result += "\\\"";
+ break;
+ case '\\':
+ result += "\\\\";
+ break;
+ case '\b':
+ result += "\\b";
+ break;
+ case '\f':
+ result += "\\f";
+ break;
+ case '\n':
+ result += "\\n";
+ break;
+ case '\r':
+ result += "\\r";
+ break;
+ case '\t':
+ result += "\\t";
+ break;
+ // case '/':
+ // Even though \/ is considered a legal escape in JSON, a bare
+ // slash is also legal, so I see no reason to escape it.
+ // (I hope I am not misunderstanding something.)
+ // blep notes: actually escaping \/ may be useful in javascript to avoid </
+ // sequence.
+ // Should add a flag to allow this compatibility mode and prevent this
+ // sequence from occurring.
+ default:
+ if ((isControlCharacter(*c)) || (*c == 0)) {
+ JSONCPP_OSTRINGSTREAM oss;
oss << "\\u" << std::hex << std::uppercase << std::setfill('0')
<< std::setw(4) << static_cast<int>(*c);
result += oss.str();
@@ -221,8 +368,8 @@ void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
-std::string FastWriter::write(const Value& root) {
- document_ = "";
+JSONCPP_STRING FastWriter::write(const Value& root) {
+ document_.clear();
writeValue(root);
if (!omitEndingLineFeed_)
document_ += "\n";
@@ -245,15 +392,21 @@ void FastWriter::writeValue(const Value& value) {
document_ += valueToString(value.asDouble());
break;
case stringValue:
- document_ += valueToQuotedString(value.asCString());
+ {
+ // Is NULL possible for value.string_? No.
+ char const* str;
+ char const* end;
+ bool ok = value.getString(&str, &end);
+ if (ok) document_ += valueToQuotedStringN(str, static_cast<unsigned>(end-str));
break;
+ }
case booleanValue:
document_ += valueToString(value.asBool());
break;
case arrayValue: {
document_ += '[';
- int size = value.size();
- for (int index = 0; index < size; ++index) {
+ ArrayIndex size = value.size();
+ for (ArrayIndex index = 0; index < size; ++index) {
if (index > 0)
document_ += ',';
writeValue(value[index]);
@@ -265,10 +418,10 @@ void FastWriter::writeValue(const Value& value) {
document_ += '{';
for (Value::Members::iterator it = members.begin(); it != members.end();
++it) {
- const std::string& name = *it;
+ const JSONCPP_STRING& name = *it;
if (it != members.begin())
document_ += ',';
- document_ += valueToQuotedString(name.c_str());
+ document_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length()));
document_ += yamlCompatiblityEnabled_ ? ": " : ":";
writeValue(value[name]);
}
@@ -283,10 +436,10 @@ void FastWriter::writeValue(const Value& value) {
StyledWriter::StyledWriter()
: rightMargin_(74), indentSize_(3), addChildValues_() {}
-std::string StyledWriter::write(const Value& root) {
- document_ = "";
+JSONCPP_STRING StyledWriter::write(const Value& root) {
+ document_.clear();
addChildValues_ = false;
- indentString_ = "";
+ indentString_.clear();
writeCommentBeforeValue(root);
writeValue(root);
writeCommentAfterValueOnSameLine(root);
@@ -309,8 +462,15 @@ void StyledWriter::writeValue(const Value& value) {
pushValue(valueToString(value.asDouble()));
break;
case stringValue:
- pushValue(valueToQuotedString(value.asCString()));
+ {
+ // Is NULL possible for value.string_? No.
+ char const* str;
+ char const* end;
+ bool ok = value.getString(&str, &end);
+ if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
+ else pushValue("");
break;
+ }
case booleanValue:
pushValue(valueToString(value.asBool()));
break;
@@ -326,7 +486,7 @@ void StyledWriter::writeValue(const Value& value) {
indent();
Value::Members::iterator it = members.begin();
for (;;) {
- const std::string& name = *it;
+ const JSONCPP_STRING& name = *it;
const Value& childValue = value[name];
writeCommentBeforeValue(childValue);
writeWithIndent(valueToQuotedString(name.c_str()));
@@ -390,23 +550,25 @@ void StyledWriter::writeArrayValue(const Value& value) {
}
bool StyledWriter::isMultineArray(const Value& value) {
- int size = value.size();
+ ArrayIndex const size = value.size();
bool isMultiLine = size * 3 >= rightMargin_;
childValues_.clear();
- for (int index = 0; index < size && !isMultiLine; ++index) {
+ for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
const Value& childValue = value[index];
- isMultiLine =
- isMultiLine || ((childValue.isArray() || childValue.isObject()) &&
+ isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
childValue.size() > 0);
}
if (!isMultiLine) // check if line length > max line length
{
childValues_.reserve(size);
addChildValues_ = true;
- int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
- for (int index = 0; index < size; ++index) {
+ ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
+ for (ArrayIndex index = 0; index < size; ++index) {
+ if (hasCommentForValue(value[index])) {
+ isMultiLine = true;
+ }
writeValue(value[index]);
- lineLength += int(childValues_[index].length());
+ lineLength += static_cast<ArrayIndex>(childValues_[index].length());
}
addChildValues_ = false;
isMultiLine = isMultiLine || lineLength >= rightMargin_;
@@ -414,7 +576,7 @@ bool StyledWriter::isMultineArray(const Value& value) {
return isMultiLine;
}
-void StyledWriter::pushValue(const std::string& value) {
+void StyledWriter::pushValue(const JSONCPP_STRING& value) {
if (addChildValues_)
childValues_.push_back(value);
else
@@ -432,15 +594,15 @@ void StyledWriter::writeIndent() {
document_ += indentString_;
}
-void StyledWriter::writeWithIndent(const std::string& value) {
+void StyledWriter::writeWithIndent(const JSONCPP_STRING& value) {
writeIndent();
document_ += value;
}
-void StyledWriter::indent() { indentString_ += std::string(indentSize_, ' '); }
+void StyledWriter::indent() { indentString_ += JSONCPP_STRING(indentSize_, ' '); }
void StyledWriter::unindent() {
- assert(int(indentString_.size()) >= indentSize_);
+ assert(indentString_.size() >= indentSize_);
indentString_.resize(indentString_.size() - indentSize_);
}
@@ -450,26 +612,27 @@ void StyledWriter::writeCommentBeforeValue(const Value& root) {
document_ += "\n";
writeIndent();
- std::string normalizedComment = normalizeEOL(root.getComment(commentBefore));
- std::string::const_iterator iter = normalizedComment.begin();
- while (iter != normalizedComment.end()) {
+ const JSONCPP_STRING& comment = root.getComment(commentBefore);
+ JSONCPP_STRING::const_iterator iter = comment.begin();
+ while (iter != comment.end()) {
document_ += *iter;
- if (*iter == '\n' && *(iter + 1) == '/')
+ if (*iter == '\n' &&
+ (iter != comment.end() && *(iter + 1) == '/'))
writeIndent();
++iter;
}
- // Comments are stripped of newlines, so add one here
+ // Comments are stripped of trailing newlines, so add one here
document_ += "\n";
}
void StyledWriter::writeCommentAfterValueOnSameLine(const Value& root) {
if (root.hasComment(commentAfterOnSameLine))
- document_ += " " + normalizeEOL(root.getComment(commentAfterOnSameLine));
+ document_ += " " + root.getComment(commentAfterOnSameLine);
if (root.hasComment(commentAfter)) {
document_ += "\n";
- document_ += normalizeEOL(root.getComment(commentAfter));
+ document_ += root.getComment(commentAfter);
document_ += "\n";
}
}
@@ -480,37 +643,21 @@ bool StyledWriter::hasCommentForValue(const Value& value) {
value.hasComment(commentAfter);
}
-std::string StyledWriter::normalizeEOL(const std::string& text) {
- std::string normalized;
- normalized.reserve(text.length());
- const char* begin = text.c_str();
- const char* end = begin + text.length();
- const char* current = begin;
- while (current != end) {
- char c = *current++;
- if (c == '\r') // mac or dos EOL
- {
- if (*current == '\n') // convert dos EOL
- ++current;
- normalized += '\n';
- } else // handle unix EOL & other char
- normalized += c;
- }
- return normalized;
-}
-
// Class StyledStreamWriter
// //////////////////////////////////////////////////////////////////
-StyledStreamWriter::StyledStreamWriter(std::string indentation)
+StyledStreamWriter::StyledStreamWriter(JSONCPP_STRING indentation)
: document_(NULL), rightMargin_(74), indentation_(indentation),
addChildValues_() {}
-void StyledStreamWriter::write(std::ostream& out, const Value& root) {
+void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
document_ = &out;
addChildValues_ = false;
- indentString_ = "";
+ indentString_.clear();
+ indented_ = true;
writeCommentBeforeValue(root);
+ if (!indented_) writeIndent();
+ indented_ = true;
writeValue(root);
writeCommentAfterValueOnSameLine(root);
*document_ << "\n";
@@ -532,8 +679,15 @@ void StyledStreamWriter::writeValue(const Value& value) {
pushValue(valueToString(value.asDouble()));
break;
case stringValue:
- pushValue(valueToQuotedString(value.asCString()));
+ {
+ // Is NULL possible for value.string_? No.
+ char const* str;
+ char const* end;
+ bool ok = value.getString(&str, &end);
+ if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
+ else pushValue("");
break;
+ }
case booleanValue:
pushValue(valueToString(value.asBool()));
break;
@@ -549,7 +703,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
indent();
Value::Members::iterator it = members.begin();
for (;;) {
- const std::string& name = *it;
+ const JSONCPP_STRING& name = *it;
const Value& childValue = value[name];
writeCommentBeforeValue(childValue);
writeWithIndent(valueToQuotedString(name.c_str()));
@@ -586,8 +740,10 @@ void StyledStreamWriter::writeArrayValue(const Value& value) {
if (hasChildValue)
writeWithIndent(childValues_[index]);
else {
- writeIndent();
+ if (!indented_) writeIndent();
+ indented_ = true;
writeValue(childValue);
+ indented_ = false;
}
if (++index == size) {
writeCommentAfterValueOnSameLine(childValue);
@@ -613,23 +769,25 @@ void StyledStreamWriter::writeArrayValue(const Value& value) {
}
bool StyledStreamWriter::isMultineArray(const Value& value) {
- int size = value.size();
+ ArrayIndex const size = value.size();
bool isMultiLine = size * 3 >= rightMargin_;
childValues_.clear();
- for (int index = 0; index < size && !isMultiLine; ++index) {
+ for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
const Value& childValue = value[index];
- isMultiLine =
- isMultiLine || ((childValue.isArray() || childValue.isObject()) &&
+ isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
childValue.size() > 0);
}
if (!isMultiLine) // check if line length > max line length
{
childValues_.reserve(size);
addChildValues_ = true;
- int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
- for (int index = 0; index < size; ++index) {
+ ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
+ for (ArrayIndex index = 0; index < size; ++index) {
+ if (hasCommentForValue(value[index])) {
+ isMultiLine = true;
+ }
writeValue(value[index]);
- lineLength += int(childValues_[index].length());
+ lineLength += static_cast<ArrayIndex>(childValues_[index].length());
}
addChildValues_ = false;
isMultiLine = isMultiLine || lineLength >= rightMargin_;
@@ -637,7 +795,7 @@ bool StyledStreamWriter::isMultineArray(const Value& value) {
return isMultiLine;
}
-void StyledStreamWriter::pushValue(const std::string& value) {
+void StyledStreamWriter::pushValue(const JSONCPP_STRING& value) {
if (addChildValues_)
childValues_.push_back(value);
else
@@ -645,24 +803,17 @@ void StyledStreamWriter::pushValue(const std::string& value) {
}
void StyledStreamWriter::writeIndent() {
- /*
- Some comments in this method would have been nice. ;-)
-
- if ( !document_.empty() )
- {
- char last = document_[document_.length()-1];
- if ( last == ' ' ) // already indented
- return;
- if ( last != '\n' ) // Comments may add new-line
- *document_ << '\n';
- }
- */
+ // blep intended this to look at the so-far-written string
+ // to determine whether we are already indented, but
+ // with a stream we cannot do that. So we rely on some saved state.
+ // The caller checks indented_.
*document_ << '\n' << indentString_;
}
-void StyledStreamWriter::writeWithIndent(const std::string& value) {
- writeIndent();
+void StyledStreamWriter::writeWithIndent(const JSONCPP_STRING& value) {
+ if (!indented_) writeIndent();
*document_ << value;
+ indented_ = false;
}
void StyledStreamWriter::indent() { indentString_ += indentation_; }
@@ -675,19 +826,30 @@ void StyledStreamWriter::unindent() {
void StyledStreamWriter::writeCommentBeforeValue(const Value& root) {
if (!root.hasComment(commentBefore))
return;
- *document_ << normalizeEOL(root.getComment(commentBefore));
- *document_ << "\n";
+
+ if (!indented_) writeIndent();
+ const JSONCPP_STRING& comment = root.getComment(commentBefore);
+ JSONCPP_STRING::const_iterator iter = comment.begin();
+ while (iter != comment.end()) {
+ *document_ << *iter;
+ if (*iter == '\n' &&
+ (iter != comment.end() && *(iter + 1) == '/'))
+ // writeIndent(); // would include newline
+ *document_ << indentString_;
+ ++iter;
+ }
+ indented_ = false;
}
void StyledStreamWriter::writeCommentAfterValueOnSameLine(const Value& root) {
if (root.hasComment(commentAfterOnSameLine))
- *document_ << " " + normalizeEOL(root.getComment(commentAfterOnSameLine));
+ *document_ << ' ' << root.getComment(commentAfterOnSameLine);
if (root.hasComment(commentAfter)) {
- *document_ << "\n";
- *document_ << normalizeEOL(root.getComment(commentAfter));
- *document_ << "\n";
+ writeIndent();
+ *document_ << root.getComment(commentAfter);
}
+ indented_ = false;
}
bool StyledStreamWriter::hasCommentForValue(const Value& value) {
@@ -696,28 +858,400 @@ bool StyledStreamWriter::hasCommentForValue(const Value& value) {
value.hasComment(commentAfter);
}
-std::string StyledStreamWriter::normalizeEOL(const std::string& text) {
- std::string normalized;
- normalized.reserve(text.length());
- const char* begin = text.c_str();
- const char* end = begin + text.length();
- const char* current = begin;
- while (current != end) {
- char c = *current++;
- if (c == '\r') // mac or dos EOL
+//////////////////////////
+// BuiltStyledStreamWriter
+
+/// Scoped enums are not available until C++11.
+struct CommentStyle {
+ /// Decide whether to write comments.
+ enum Enum {
+ None, ///< Drop all comments.
+ Most, ///< Recover odd behavior of previous versions (not implemented yet).
+ All ///< Keep all comments.
+ };
+};
+
+struct BuiltStyledStreamWriter : public StreamWriter
+{
+ BuiltStyledStreamWriter(
+ JSONCPP_STRING const& indentation,
+ CommentStyle::Enum cs,
+ JSONCPP_STRING const& colonSymbol,
+ JSONCPP_STRING const& nullSymbol,
+ JSONCPP_STRING const& endingLineFeedSymbol,
+ bool useSpecialFloats,
+ unsigned int precision);
+ int write(Value const& root, JSONCPP_OSTREAM* sout) JSONCPP_OVERRIDE;
+private:
+ void writeValue(Value const& value);
+ void writeArrayValue(Value const& value);
+ bool isMultineArray(Value const& value);
+ void pushValue(JSONCPP_STRING const& value);
+ void writeIndent();
+ void writeWithIndent(JSONCPP_STRING const& value);
+ void indent();
+ void unindent();
+ void writeCommentBeforeValue(Value const& root);
+ void writeCommentAfterValueOnSameLine(Value const& root);
+ static bool hasCommentForValue(const Value& value);
+
+ typedef std::vector<JSONCPP_STRING> ChildValues;
+
+ ChildValues childValues_;
+ JSONCPP_STRING indentString_;
+ unsigned int rightMargin_;
+ JSONCPP_STRING indentation_;
+ CommentStyle::Enum cs_;
+ JSONCPP_STRING colonSymbol_;
+ JSONCPP_STRING nullSymbol_;
+ JSONCPP_STRING endingLineFeedSymbol_;
+ bool addChildValues_ : 1;
+ bool indented_ : 1;
+ bool useSpecialFloats_ : 1;
+ unsigned int precision_;
+};
+BuiltStyledStreamWriter::BuiltStyledStreamWriter(
+ JSONCPP_STRING const& indentation,
+ CommentStyle::Enum cs,
+ JSONCPP_STRING const& colonSymbol,
+ JSONCPP_STRING const& nullSymbol,
+ JSONCPP_STRING const& endingLineFeedSymbol,
+ bool useSpecialFloats,
+ unsigned int precision)
+ : rightMargin_(74)
+ , indentation_(indentation)
+ , cs_(cs)
+ , colonSymbol_(colonSymbol)
+ , nullSymbol_(nullSymbol)
+ , endingLineFeedSymbol_(endingLineFeedSymbol)
+ , addChildValues_(false)
+ , indented_(false)
+ , useSpecialFloats_(useSpecialFloats)
+ , precision_(precision)
+{
+}
+int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout)
+{
+ sout_ = sout;
+ addChildValues_ = false;
+ indented_ = true;
+ indentString_.clear();
+ writeCommentBeforeValue(root);
+ if (!indented_) writeIndent();
+ indented_ = true;
+ writeValue(root);
+ writeCommentAfterValueOnSameLine(root);
+ *sout_ << endingLineFeedSymbol_;
+ sout_ = NULL;
+ return 0;
+}
+void BuiltStyledStreamWriter::writeValue(Value const& value) {
+ switch (value.type()) {
+ case nullValue:
+ pushValue(nullSymbol_);
+ break;
+ case intValue:
+ pushValue(valueToString(value.asLargestInt()));
+ break;
+ case uintValue:
+ pushValue(valueToString(value.asLargestUInt()));
+ break;
+ case realValue:
+ pushValue(valueToString(value.asDouble(), useSpecialFloats_, precision_));
+ break;
+ case stringValue:
+ {
+ // Is NULL is possible for value.string_? No.
+ char const* str;
+ char const* end;
+ bool ok = value.getString(&str, &end);
+ if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
+ else pushValue("");
+ break;
+ }
+ case booleanValue:
+ pushValue(valueToString(value.asBool()));
+ break;
+ case arrayValue:
+ writeArrayValue(value);
+ break;
+ case objectValue: {
+ Value::Members members(value.getMemberNames());
+ if (members.empty())
+ pushValue("{}");
+ else {
+ writeWithIndent("{");
+ indent();
+ Value::Members::iterator it = members.begin();
+ for (;;) {
+ JSONCPP_STRING const& name = *it;
+ Value const& childValue = value[name];
+ writeCommentBeforeValue(childValue);
+ writeWithIndent(valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length())));
+ *sout_ << colonSymbol_;
+ writeValue(childValue);
+ if (++it == members.end()) {
+ writeCommentAfterValueOnSameLine(childValue);
+ break;
+ }
+ *sout_ << ",";
+ writeCommentAfterValueOnSameLine(childValue);
+ }
+ unindent();
+ writeWithIndent("}");
+ }
+ } break;
+ }
+}
+
+void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
+ unsigned size = value.size();
+ if (size == 0)
+ pushValue("[]");
+ else {
+ bool isMultiLine = (cs_ == CommentStyle::All) || isMultineArray(value);
+ if (isMultiLine) {
+ writeWithIndent("[");
+ indent();
+ bool hasChildValue = !childValues_.empty();
+ unsigned index = 0;
+ for (;;) {
+ Value const& childValue = value[index];
+ writeCommentBeforeValue(childValue);
+ if (hasChildValue)
+ writeWithIndent(childValues_[index]);
+ else {
+ if (!indented_) writeIndent();
+ indented_ = true;
+ writeValue(childValue);
+ indented_ = false;
+ }
+ if (++index == size) {
+ writeCommentAfterValueOnSameLine(childValue);
+ break;
+ }
+ *sout_ << ",";
+ writeCommentAfterValueOnSameLine(childValue);
+ }
+ unindent();
+ writeWithIndent("]");
+ } else // output on a single line
{
- if (*current == '\n') // convert dos EOL
- ++current;
- normalized += '\n';
- } else // handle unix EOL & other char
- normalized += c;
+ assert(childValues_.size() == size);
+ *sout_ << "[";
+ if (!indentation_.empty()) *sout_ << " ";
+ for (unsigned index = 0; index < size; ++index) {
+ if (index > 0)
+ *sout_ << ((!indentation_.empty()) ? ", " : ",");
+ *sout_ << childValues_[index];
+ }
+ if (!indentation_.empty()) *sout_ << " ";
+ *sout_ << "]";
+ }
+ }
+}
+
+bool BuiltStyledStreamWriter::isMultineArray(Value const& value) {
+ ArrayIndex const size = value.size();
+ bool isMultiLine = size * 3 >= rightMargin_;
+ childValues_.clear();
+ for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
+ Value const& childValue = value[index];
+ isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
+ childValue.size() > 0);
+ }
+ if (!isMultiLine) // check if line length > max line length
+ {
+ childValues_.reserve(size);
+ addChildValues_ = true;
+ ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
+ for (ArrayIndex index = 0; index < size; ++index) {
+ if (hasCommentForValue(value[index])) {
+ isMultiLine = true;
+ }
+ writeValue(value[index]);
+ lineLength += static_cast<ArrayIndex>(childValues_[index].length());
+ }
+ addChildValues_ = false;
+ isMultiLine = isMultiLine || lineLength >= rightMargin_;
+ }
+ return isMultiLine;
+}
+
+void BuiltStyledStreamWriter::pushValue(JSONCPP_STRING const& value) {
+ if (addChildValues_)
+ childValues_.push_back(value);
+ else
+ *sout_ << value;
+}
+
+void BuiltStyledStreamWriter::writeIndent() {
+ // blep intended this to look at the so-far-written string
+ // to determine whether we are already indented, but
+ // with a stream we cannot do that. So we rely on some saved state.
+ // The caller checks indented_.
+
+ if (!indentation_.empty()) {
+ // In this case, drop newlines too.
+ *sout_ << '\n' << indentString_;
+ }
+}
+
+void BuiltStyledStreamWriter::writeWithIndent(JSONCPP_STRING const& value) {
+ if (!indented_) writeIndent();
+ *sout_ << value;
+ indented_ = false;
+}
+
+void BuiltStyledStreamWriter::indent() { indentString_ += indentation_; }
+
+void BuiltStyledStreamWriter::unindent() {
+ assert(indentString_.size() >= indentation_.size());
+ indentString_.resize(indentString_.size() - indentation_.size());
+}
+
+void BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root) {
+ if (cs_ == CommentStyle::None) return;
+ if (!root.hasComment(commentBefore))
+ return;
+
+ if (!indented_) writeIndent();
+ const JSONCPP_STRING& comment = root.getComment(commentBefore);
+ JSONCPP_STRING::const_iterator iter = comment.begin();
+ while (iter != comment.end()) {
+ *sout_ << *iter;
+ if (*iter == '\n' &&
+ (iter != comment.end() && *(iter + 1) == '/'))
+ // writeIndent(); // would write extra newline
+ *sout_ << indentString_;
+ ++iter;
}
- return normalized;
+ indented_ = false;
+}
+
+void BuiltStyledStreamWriter::writeCommentAfterValueOnSameLine(Value const& root) {
+ if (cs_ == CommentStyle::None) return;
+ if (root.hasComment(commentAfterOnSameLine))
+ *sout_ << " " + root.getComment(commentAfterOnSameLine);
+
+ if (root.hasComment(commentAfter)) {
+ writeIndent();
+ *sout_ << root.getComment(commentAfter);
+ }
+}
+
+// static
+bool BuiltStyledStreamWriter::hasCommentForValue(const Value& value) {
+ return value.hasComment(commentBefore) ||
+ value.hasComment(commentAfterOnSameLine) ||
+ value.hasComment(commentAfter);
+}
+
+///////////////
+// StreamWriter
+
+StreamWriter::StreamWriter()
+ : sout_(NULL)
+{
+}
+StreamWriter::~StreamWriter()
+{
+}
+StreamWriter::Factory::~Factory()
+{}
+StreamWriterBuilder::StreamWriterBuilder()
+{
+ setDefaults(&settings_);
+}
+StreamWriterBuilder::~StreamWriterBuilder()
+{}
+StreamWriter* StreamWriterBuilder::newStreamWriter() const
+{
+ JSONCPP_STRING indentation = settings_["indentation"].asString();
+ JSONCPP_STRING cs_str = settings_["commentStyle"].asString();
+ bool eyc = settings_["enableYAMLCompatibility"].asBool();
+ bool dnp = settings_["dropNullPlaceholders"].asBool();
+ bool usf = settings_["useSpecialFloats"].asBool();
+ unsigned int pre = settings_["precision"].asUInt();
+ CommentStyle::Enum cs = CommentStyle::All;
+ if (cs_str == "All") {
+ cs = CommentStyle::All;
+ } else if (cs_str == "None") {
+ cs = CommentStyle::None;
+ } else {
+ throwRuntimeError("commentStyle must be 'All' or 'None'");
+ }
+ JSONCPP_STRING colonSymbol = " : ";
+ if (eyc) {
+ colonSymbol = ": ";
+ } else if (indentation.empty()) {
+ colonSymbol = ":";
+ }
+ JSONCPP_STRING nullSymbol = "null";
+ if (dnp) {
+ nullSymbol.clear();
+ }
+ if (pre > 17) pre = 17;
+ JSONCPP_STRING endingLineFeedSymbol;
+ return new BuiltStyledStreamWriter(
+ indentation, cs,
+ colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);
+}
+static void getValidWriterKeys(std::set<JSONCPP_STRING>* valid_keys)
+{
+ valid_keys->clear();
+ valid_keys->insert("indentation");
+ valid_keys->insert("commentStyle");
+ valid_keys->insert("enableYAMLCompatibility");
+ valid_keys->insert("dropNullPlaceholders");
+ valid_keys->insert("useSpecialFloats");
+ valid_keys->insert("precision");
+}
+bool StreamWriterBuilder::validate(Json::Value* invalid) const
+{
+ Json::Value my_invalid;
+ if (!invalid) invalid = &my_invalid; // so we do not need to test for NULL
+ Json::Value& inv = *invalid;
+ std::set<JSONCPP_STRING> valid_keys;
+ getValidWriterKeys(&valid_keys);
+ Value::Members keys = settings_.getMemberNames();
+ size_t n = keys.size();
+ for (size_t i = 0; i < n; ++i) {
+ JSONCPP_STRING const& key = keys[i];
+ if (valid_keys.find(key) == valid_keys.end()) {
+ inv[key] = settings_[key];
+ }
+ }
+ return 0u == inv.size();
+}
+Value& StreamWriterBuilder::operator[](JSONCPP_STRING key)
+{
+ return settings_[key];
+}
+// static
+void StreamWriterBuilder::setDefaults(Json::Value* settings)
+{
+ //! [StreamWriterBuilderDefaults]
+ (*settings)["commentStyle"] = "All";
+ (*settings)["indentation"] = "\t";
+ (*settings)["enableYAMLCompatibility"] = false;
+ (*settings)["dropNullPlaceholders"] = false;
+ (*settings)["useSpecialFloats"] = false;
+ (*settings)["precision"] = 17;
+ //! [StreamWriterBuilderDefaults]
+}
+
+JSONCPP_STRING writeString(StreamWriter::Factory const& builder, Value const& root) {
+ JSONCPP_OSTRINGSTREAM sout;
+ StreamWriterPtr const writer(builder.newStreamWriter());
+ writer->write(root, &sout);
+ return sout.str();
}
-std::ostream& operator<<(std::ostream& sout, const Value& root) {
- Json::StyledStreamWriter writer;
- writer.write(sout, root);
+JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM& sout, Value const& root) {
+ StreamWriterBuilder builder;
+ StreamWriterPtr const writer(builder.newStreamWriter());
+ writer->write(root, &sout);
return sout;
}
diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt
index bfe6b131e..60c8316e3 100644
--- a/Utilities/cmlibarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/CMakeLists.txt
@@ -60,7 +60,7 @@ SET(CMAKE_REQUIRED_FLAGS)
# Disable warnings to avoid changing 3rd party code.
IF(CMAKE_C_COMPILER_ID MATCHES
- "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
+ "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel)$")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
@@ -71,6 +71,7 @@ include(CTest)
OPTION(ENABLE_NETTLE "Enable use of Nettle" ON)
OPTION(ENABLE_OPENSSL "Enable use of OpenSSL" ON)
+OPTION(ENABLE_LZ4 "Enable the use of the system LZ4 library if found" ON)
OPTION(ENABLE_LZO "Enable the use of the system LZO library if found" OFF)
OPTION(ENABLE_LZMA "Enable the use of the system LZMA library if found" ON)
@@ -328,7 +329,7 @@ IF(ENABLE_LZO)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZO2 DEFAULT_MSG LZO2_LIBRARY LZO2_INCLUDE_DIR)
ELSE(ENABLE_LZO)
- SET(LIBZMA_FOUND FALSE) # Override cached value
+ SET(LZO2_FOUND FALSE) # Override cached value
ENDIF(ENABLE_LZO)
IF(LZO2_FOUND)
SET(HAVE_LIBLZO2 1)
@@ -347,15 +348,19 @@ IF(0) # CMake does not need LZ4 support in libarchive
#
# Find LZ4
#
-IF (LZ4_INCLUDE_DIR)
- # Already in cache, be silent
- SET(LZ4_FIND_QUIETLY TRUE)
-ENDIF (LZ4_INCLUDE_DIR)
+IF(ENABLE_LZ4)
+ IF (LZ4_INCLUDE_DIR)
+ # Already in cache, be silent
+ SET(LZ4_FIND_QUIETLY TRUE)
+ ENDIF (LZ4_INCLUDE_DIR)
-FIND_PATH(LZ4_INCLUDE_DIR lz4.h)
-FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4)
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR)
+ FIND_PATH(LZ4_INCLUDE_DIR lz4.h)
+ FIND_LIBRARY(LZ4_LIBRARY NAMES lz4 liblz4)
+ INCLUDE(FindPackageHandleStandardArgs)
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZ4 DEFAULT_MSG LZ4_LIBRARY LZ4_INCLUDE_DIR)
+ELSE(ENABLE_LZ4)
+ SET(LZ4_FOUND FALSE) # Override cached value
+ENDIF(ENABLE_LZ4)
IF(LZ4_FOUND)
SET(HAVE_LIBLZ4 1)
SET(HAVE_LZ4_H 1)
@@ -372,6 +377,29 @@ ENDIF(LZ4_FOUND)
MARK_AS_ADVANCED(CLEAR LZ4_INCLUDE_DIR)
MARK_AS_ADVANCED(CLEAR LZ4_LIBRARY)
ENDIF()
+#
+# Find Zstd
+#
+IF (ZSTD_INCLUDE_DIR)
+ # Already in cache, be silent
+ SET(ZSTD_FIND_QUIETLY TRUE)
+ENDIF (ZSTD_INCLUDE_DIR)
+
+FIND_PATH(ZSTD_INCLUDE_DIR zstd.h)
+FIND_LIBRARY(ZSTD_LIBRARY NAMES zstd libzstd)
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZSTD DEFAULT_MSG ZSTD_LIBRARY ZSTD_INCLUDE_DIR)
+IF(ZSTD_FOUND)
+ SET(HAVE_ZSTD_H 1)
+ INCLUDE_DIRECTORIES(${ZSTD_INCLUDE_DIR})
+ LIST(APPEND ADDITIONAL_LIBS ${ZSTD_LIBRARY})
+ SET(HAVE_LIBZSTD 1)
+ #
+ # TODO: test for static library.
+ #
+ENDIF(ZSTD_FOUND)
+MARK_AS_ADVANCED(CLEAR ZSTD_INCLUDE_DIR)
+MARK_AS_ADVANCED(CLEAR ZSTD_LIBRARY)
#
# Check headers
@@ -422,6 +450,7 @@ int main(void) { return FS_IOC_GETFLAGS; }" HAVE_WORKING_FS_IOC_GETFLAGS)
LA_CHECK_INCLUDE_FILE("linux/magic.h" HAVE_LINUX_MAGIC_H)
LA_CHECK_INCLUDE_FILE("locale.h" HAVE_LOCALE_H)
+LA_CHECK_INCLUDE_FILE("membership.h" HAVE_MEMBERSHIP_H)
LA_CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H)
LA_CHECK_INCLUDE_FILE("paths.h" HAVE_PATHS_H)
LA_CHECK_INCLUDE_FILE("poll.h" HAVE_POLL_H)
@@ -439,20 +468,24 @@ LA_CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H)
LA_CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
LA_CHECK_INCLUDE_FILE("sys/acl.h" HAVE_SYS_ACL_H)
LA_CHECK_INCLUDE_FILE("sys/cdefs.h" HAVE_SYS_CDEFS_H)
+LA_CHECK_INCLUDE_FILE("sys/extattr.h" HAVE_SYS_EXTATTR_H)
LA_CHECK_INCLUDE_FILE("sys/ioctl.h" HAVE_SYS_IOCTL_H)
LA_CHECK_INCLUDE_FILE("sys/mkdev.h" HAVE_SYS_MKDEV_H)
LA_CHECK_INCLUDE_FILE("sys/mount.h" HAVE_SYS_MOUNT_H)
LA_CHECK_INCLUDE_FILE("sys/param.h" HAVE_SYS_PARAM_H)
LA_CHECK_INCLUDE_FILE("sys/poll.h" HAVE_SYS_POLL_H)
+LA_CHECK_INCLUDE_FILE("sys/richacl.h" HAVE_SYS_RICHACL_H)
LA_CHECK_INCLUDE_FILE("sys/select.h" HAVE_SYS_SELECT_H)
LA_CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
LA_CHECK_INCLUDE_FILE("sys/statfs.h" HAVE_SYS_STATFS_H)
LA_CHECK_INCLUDE_FILE("sys/statvfs.h" HAVE_SYS_STATVFS_H)
+LA_CHECK_INCLUDE_FILE("sys/sysmacros.h" HAVE_SYS_SYSMACROS_H)
LA_CHECK_INCLUDE_FILE("sys/time.h" HAVE_SYS_TIME_H)
LA_CHECK_INCLUDE_FILE("sys/utime.h" HAVE_SYS_UTIME_H)
LA_CHECK_INCLUDE_FILE("sys/utsname.h" HAVE_SYS_UTSNAME_H)
LA_CHECK_INCLUDE_FILE("sys/vfs.h" HAVE_SYS_VFS_H)
LA_CHECK_INCLUDE_FILE("sys/wait.h" HAVE_SYS_WAIT_H)
+LA_CHECK_INCLUDE_FILE("sys/xattr.h" HAVE_SYS_XATTR_H)
LA_CHECK_INCLUDE_FILE("time.h" HAVE_TIME_H)
LA_CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
LA_CHECK_INCLUDE_FILE("utime.h" HAVE_UTIME_H)
@@ -461,6 +494,9 @@ LA_CHECK_INCLUDE_FILE("wctype.h" HAVE_WCTYPE_H)
LA_CHECK_INCLUDE_FILE("windows.h" HAVE_WINDOWS_H)
IF(ENABLE_CNG)
LA_CHECK_INCLUDE_FILE("Bcrypt.h" HAVE_BCRYPT_H)
+ IF(HAVE_BCRYPT_H)
+ LIST(APPEND ADDITIONAL_LIBS "Bcrypt")
+ ENDIF(HAVE_BCRYPT_H)
ELSE(ENABLE_CNG)
UNSET(HAVE_BCRYPT_H CACHE)
ENDIF(ENABLE_CNG)
@@ -924,7 +960,6 @@ CHECK_FUNCTION_EXISTS_GLIBC(chflags HAVE_CHFLAGS)
CHECK_FUNCTION_EXISTS_GLIBC(chown HAVE_CHOWN)
CHECK_FUNCTION_EXISTS_GLIBC(chroot HAVE_CHROOT)
CHECK_FUNCTION_EXISTS_GLIBC(ctime_r HAVE_CTIME_R)
-CHECK_FUNCTION_EXISTS_GLIBC(dirfd HAVE_DIRFD)
CHECK_FUNCTION_EXISTS_GLIBC(fchdir HAVE_FCHDIR)
CHECK_FUNCTION_EXISTS_GLIBC(fchflags HAVE_FCHFLAGS)
CHECK_FUNCTION_EXISTS_GLIBC(fchmod HAVE_FCHMOD)
@@ -1024,6 +1059,10 @@ CHECK_C_SOURCE_COMPILES(
"#include <dirent.h>\nint main() {DIR *d = opendir(\".\"); struct dirent e,*r; return readdir_r(d,&e,&r);}"
HAVE_READDIR_R)
+# dirfd can be either a function or a macro.
+CHECK_C_SOURCE_COMPILES(
+ "#include <dirent.h>\nint main() {DIR *d = opendir(\".\"); return dirfd(d);}"
+ HAVE_DIRFD)
# Only detect readlinkat() if we also have AT_FDCWD in unistd.h.
# NOTE: linux requires fcntl.h for AT_FDCWD.
@@ -1256,60 +1295,105 @@ CHECK_FILE_OFFSET_BITS()
# Check for Extended Attribute libraries, headers, and functions
#
IF(ENABLE_XATTR)
- LA_CHECK_INCLUDE_FILE(attr/xattr.h HAVE_ATTR_XATTR_H)
- LA_CHECK_INCLUDE_FILE(sys/xattr.h HAVE_SYS_XATTR_H)
- LA_CHECK_INCLUDE_FILE(sys/extattr.h HAVE_SYS_EXTATTR_H)
CHECK_LIBRARY_EXISTS(attr "setxattr" "" HAVE_LIBATTR)
IF(HAVE_LIBATTR)
SET(CMAKE_REQUIRED_LIBRARIES "attr")
ENDIF(HAVE_LIBATTR)
CHECK_SYMBOL_EXISTS(EXTATTR_NAMESPACE_USER "sys/types.h;sys/extattr.h" HAVE_DECL_EXTATTR_NAMESPACE_USER)
- CHECK_FUNCTION_EXISTS_GLIBC(extattr_get_file HAVE_EXTATTR_GET_FILE)
- CHECK_FUNCTION_EXISTS_GLIBC(extattr_list_file HAVE_EXTATTR_LIST_FILE)
- CHECK_FUNCTION_EXISTS_GLIBC(extattr_set_fd HAVE_EXTATTR_SET_FD)
- CHECK_FUNCTION_EXISTS_GLIBC(extattr_set_file HAVE_EXTATTR_SET_FILE)
- CHECK_FUNCTION_EXISTS_GLIBC(fgetxattr HAVE_FGETXATTR)
- CHECK_FUNCTION_EXISTS_GLIBC(flistxattr HAVE_FLISTXATTR)
- CHECK_FUNCTION_EXISTS_GLIBC(fsetxattr HAVE_FSETXATTR)
- CHECK_FUNCTION_EXISTS_GLIBC(getxattr HAVE_GETXATTR)
- CHECK_FUNCTION_EXISTS_GLIBC(lgetxattr HAVE_LGETXATTR)
- CHECK_FUNCTION_EXISTS_GLIBC(listxattr HAVE_LISTXATTR)
- CHECK_FUNCTION_EXISTS_GLIBC(llistxattr HAVE_LLISTXATTR)
- CHECK_FUNCTION_EXISTS_GLIBC(lsetxattr HAVE_LSETXATTR)
- CHECK_FUNCTION_EXISTS_GLIBC(fgetea HAVE_FGETEA)
- CHECK_FUNCTION_EXISTS_GLIBC(flistea HAVE_FLISTEA)
- CHECK_FUNCTION_EXISTS_GLIBC(fsetea HAVE_FSETEA)
- CHECK_FUNCTION_EXISTS_GLIBC(getea HAVE_GETEA)
- CHECK_FUNCTION_EXISTS_GLIBC(lgetea HAVE_LGETEA)
- CHECK_FUNCTION_EXISTS_GLIBC(listea HAVE_LISTEA)
- CHECK_FUNCTION_EXISTS_GLIBC(llistea HAVE_LLISTEA)
- CHECK_FUNCTION_EXISTS_GLIBC(lsetea HAVE_LSETEA)
+ CHECK_SYMBOL_EXISTS(XATTR_NOFOLLOW "sys/xattr.h" HAVE_DECL_XATTR_NOFOLLOW)
+ IF(HAVE_SYS_XATTR_H AND HAVE_DECL_XATTR_NOFOLLOW)
+ CHECK_FUNCTION_EXISTS(fgetxattr HAVE_FGETXATTR)
+ CHECK_FUNCTION_EXISTS(flistxattr HAVE_FLISTXATTR)
+ CHECK_FUNCTION_EXISTS(fsetxattr HAVE_FSETXATTR)
+ CHECK_FUNCTION_EXISTS(getxattr HAVE_GETXATTR)
+ CHECK_FUNCTION_EXISTS(listxattr HAVE_LISTXATTR)
+ CHECK_FUNCTION_EXISTS(setxattr HAVE_SETXATTR)
+ IF(HAVE_FGETXATTR AND
+ HAVE_FLISTXATTR AND
+ HAVE_FSETXATTR AND
+ HAVE_GETXATTR AND
+ HAVE_LISTXATTR AND
+ HAVE_SETXATTR)
+ SET(ARCHIVE_XATTR_DARWIN TRUE)
+ ENDIF()
+ ELSEIF(HAVE_SYS_EXTATTR_H AND HAVE_DECL_EXTATTR_NAMESPACE_USER)
+ # FreeBSD xattr support
+ CHECK_FUNCTION_EXISTS(extattr_get_fd HAVE_EXTATTR_GET_FD)
+ CHECK_FUNCTION_EXISTS(extattr_get_file HAVE_EXTATTR_GET_FILE)
+ CHECK_FUNCTION_EXISTS(extattr_get_link HAVE_EXTATTR_GET_LINK)
+ CHECK_FUNCTION_EXISTS(extattr_list_fd HAVE_EXTATTR_LIST_FD)
+ CHECK_FUNCTION_EXISTS(extattr_list_file HAVE_EXTATTR_LIST_FILE)
+ CHECK_FUNCTION_EXISTS(extattr_list_link HAVE_EXTATTR_LIST_LINK)
+ CHECK_FUNCTION_EXISTS(extattr_set_fd HAVE_EXTATTR_SET_FD)
+ CHECK_FUNCTION_EXISTS(extattr_set_link HAVE_EXTATTR_SET_LINK)
+ IF(HAVE_EXTATTR_GET_FD AND
+ HAVE_EXTATTR_GET_FILE AND
+ HAVE_EXTATTR_GET_LINK AND
+ HAVE_EXTATTR_LIST_FD AND
+ HAVE_EXTATTR_LIST_FILE AND
+ HAVE_EXTATTR_LIST_LINK AND
+ HAVE_EXTATTR_SET_FD AND
+ HAVE_EXTATTR_SET_LINK)
+ SET(ARCHIVE_XATTR_FREEBSD TRUE)
+ ENDIF()
+ ELSEIF(HAVE_SYS_XATTR_H OR HAVE_ATTR_XATTR_H)
+ # Linux xattr support
+ CHECK_FUNCTION_EXISTS_GLIBC(fgetxattr HAVE_FGETXATTR)
+ CHECK_FUNCTION_EXISTS_GLIBC(flistxattr HAVE_FLISTXATTR)
+ CHECK_FUNCTION_EXISTS_GLIBC(fsetxattr HAVE_FSETXATTR)
+ CHECK_FUNCTION_EXISTS_GLIBC(getxattr HAVE_GETXATTR)
+ CHECK_FUNCTION_EXISTS_GLIBC(lgetxattr HAVE_LGETXATTR)
+ CHECK_FUNCTION_EXISTS_GLIBC(listxattr HAVE_LISTXATTR)
+ CHECK_FUNCTION_EXISTS_GLIBC(llistxattr HAVE_LLISTXATTR)
+ CHECK_FUNCTION_EXISTS_GLIBC(lsetxattr HAVE_LSETXATTR)
+ IF(HAVE_FGETXATTR AND
+ HAVE_FLISTXATTR AND
+ HAVE_FSETXATTR AND
+ HAVE_GETXATTR AND
+ HAVE_LGETXATTR AND
+ HAVE_LISTXATTR AND
+ HAVE_LLISTXATTR AND
+ HAVE_LSETXATTR)
+ SET(ARCHIVE_XATTR_LINUX TRUE)
+ ENDIF()
+ ELSEIF(HAVE_SYS_EA_H)
+ # AIX xattr support
+ CHECK_FUNCTION_EXISTS(fgetea HAVE_FGETEA)
+ CHECK_FUNCTION_EXISTS(flistea HAVE_FLISTEA)
+ CHECK_FUNCTION_EXISTS(fsetea HAVE_FSETEA)
+ CHECK_FUNCTION_EXISTS(getea HAVE_GETEA)
+ CHECK_FUNCTION_EXISTS(lgetea HAVE_LGETEA)
+ CHECK_FUNCTION_EXISTS(listea HAVE_LISTEA)
+ CHECK_FUNCTION_EXISTS(llistea HAVE_LLISTEA)
+ CHECK_FUNCTION_EXISTS(lsetea HAVE_LSETEA)
+ IF(HAVE_FGETEA AND
+ HAVE_FLISTEA AND
+ HAVE_FSETEA AND
+ HAVE_GETEA AND
+ HAVE_LGETEA AND
+ HAVE_LISTEA AND
+ HAVE_LLISTEA AND
+ HAVE_LSETEA)
+ SET(ARCHIVE_XATTR_AIX TRUE)
+ ENDIF()
+ ENDIF()
+
+ IF(ARCHIVE_XATTR_DARWIN)
+ MESSAGE(STATUS "Extended attributes support: Darwin")
+ ELSEIF(ARCHIVE_XATTR_FREEBSD)
+ MESSAGE(STATUS "Extended attributes support: FreeBSD")
+ ELSEIF(ARCHIVE_XATTR_LINUX)
+ MESSAGE(STATUS "Extended attributes support: Linux")
+ ELSEIF(ARCHIVE_XATTR_AIX)
+ MESSAGE(STATUS "Extended attributes support: AIX")
+ ELSE()
+ MESSAGE(STATUS "Extended attributes support: none")
+ ENDIF()
ELSE(ENABLE_XATTR)
- SET(HAVE_ATTR_LIB FALSE)
- SET(HAVE_ATTR_XATTR_H FALSE)
- SET(HAVE_DECL_EXTATTR_NAMESPACE_USER FALSE)
- SET(HAVE_EXTATTR_GET_FILE FALSE)
- SET(HAVE_EXTATTR_LIST_FILE FALSE)
- SET(HAVE_EXTATTR_SET_FD FALSE)
- SET(HAVE_EXTATTR_SET_FILE FALSE)
- SET(HAVE_FGETEA FALSE)
- SET(HAVE_FGETXATTR FALSE)
- SET(HAVE_FLISTEA FALSE)
- SET(HAVE_FLISTXATTR FALSE)
- SET(HAVE_FSETEA FALSE)
- SET(HAVE_FSETXATTR FALSE)
- SET(HAVE_GETEA FALSE)
- SET(HAVE_GETXATTR FALSE)
- SET(HAVE_LGETEA FALSE)
- SET(HAVE_LGETXATTR FALSE)
- SET(HAVE_LISTEA FALSE)
- SET(HAVE_LISTXATTR FALSE)
- SET(HAVE_LLISTEA FALSE)
- SET(HAVE_LLISTXATTR FALSE)
- SET(HAVE_LSETEA FALSE)
- SET(HAVE_LSETXATTR FALSE)
- SET(HAVE_SYS_EXTATTR_H FALSE)
- SET(HAVE_SYS_XATTR_H FALSE)
+ SET(ARCHIVE_XATTR_DARWIN FALSE)
+ SET(ARCHIVE_XATTR_FREEBSD FALSE)
+ SET(ARCHIVE_XATTR_LINUX FALSE)
+ SET(ARCHIVE_XATTR_AIX FALSE)
ENDIF(ENABLE_XATTR)
#
@@ -1321,78 +1405,212 @@ ENDIF(ENABLE_XATTR)
# which makes the following checks rather more complex than I would like.
#
IF(ENABLE_ACL)
+ # Solaris and derivates ACLs
+ CHECK_FUNCTION_EXISTS(acl HAVE_ACL)
+ CHECK_FUNCTION_EXISTS(facl HAVE_FACL)
+
+ # Libacl
CHECK_LIBRARY_EXISTS(acl "acl_get_file" "" HAVE_LIBACL)
IF(HAVE_LIBACL)
SET(CMAKE_REQUIRED_LIBRARIES "acl")
FIND_LIBRARY(ACL_LIBRARY NAMES acl)
LIST(APPEND ADDITIONAL_LIBS ${ACL_LIBRARY})
ENDIF(HAVE_LIBACL)
- #
- CHECK_FUNCTION_EXISTS_GLIBC(acl_create_entry HAVE_ACL_CREATE_ENTRY)
- CHECK_FUNCTION_EXISTS_GLIBC(acl_init HAVE_ACL_INIT)
- CHECK_FUNCTION_EXISTS_GLIBC(acl_set_fd HAVE_ACL_SET_FD)
- CHECK_FUNCTION_EXISTS_GLIBC(acl_set_fd_np HAVE_ACL_SET_FD_NP)
- CHECK_FUNCTION_EXISTS_GLIBC(acl_set_file HAVE_ACL_SET_FILE)
- CHECK_TYPE_EXISTS(acl_permset_t "${INCLUDES}" HAVE_ACL_PERMSET_T)
-
- # The "acl_get_perm()" function was omitted from the POSIX draft.
- # (It's a pretty obvious oversight; otherwise, there's no way to
- # test for specific permissions in a permset.) Linux uses the obvious
- # name, FreeBSD adds _np to mark it as "non-Posix extension."
- # Test for both as a double-check that we really have POSIX-style ACL support.
- CHECK_FUNCTION_EXISTS(acl_get_fd_np HAVE_ACL_GET_FD_NP)
- CHECK_FUNCTION_EXISTS(acl_get_perm HAVE_ACL_GET_PERM)
- CHECK_FUNCTION_EXISTS(acl_get_perm_np HAVE_ACL_GET_PERM_NP)
- CHECK_FUNCTION_EXISTS(acl_get_link HAVE_ACL_GET_LINK)
- CHECK_FUNCTION_EXISTS(acl_get_link_np HAVE_ACL_GET_LINK_NP)
- CHECK_FUNCTION_EXISTS(acl_is_trivial_np HAVE_ACL_IS_TRIVIAL_NP)
- CHECK_FUNCTION_EXISTS(acl_set_link_np HAVE_ACL_SET_LINK_NP)
- CHECK_SYMBOL_EXISTS(ACL_TYPE_NFS4 "${INCLUDES}" HAVE_ACL_TYPE_NFS4)
-
- # MacOS has an acl.h that isn't POSIX. It can be detected by
- # checking for ACL_USER
- CHECK_SYMBOL_EXISTS(ACL_USER "${INCLUDES}" HAVE_ACL_USER)
- CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
+
+ CHECK_TYPE_EXISTS(acl_t "sys/types.h;sys/acl.h" HAVE_ACL_T)
+ CHECK_TYPE_EXISTS(acl_entry_t "sys/types.h;sys/acl.h" HAVE_ACL_ENTRY_T)
+ CHECK_TYPE_EXISTS(acl_permset_t "sys/types.h;sys/acl.h" HAVE_ACL_PERMSET_T)
+ CHECK_TYPE_EXISTS(acl_tag_t "sys/types.h;sys/acl.h" HAVE_ACL_TAG_T)
+
+ IF(HAVE_ACL AND HAVE_FACL)
+ CHECK_TYPE_EXISTS(aclent_t "sys/acl.h" HAVE_ACLENT_T)
+ IF(HAVE_ACLENT_T)
+ CHECK_SYMBOL_EXISTS(GETACL "sys/acl.h" HAVE_DECL_GETACL)
+ CHECK_SYMBOL_EXISTS(GETACLCNT "sys/acl.h" HAVE_DECL_GETACLCNT)
+ CHECK_SYMBOL_EXISTS(SETACL "sys/acl.h" HAVE_DECL_SETACL)
+ IF(HAVE_DECL_GETACL AND
+ HAVE_DECL_GETACLCNT AND
+ HAVE_DECL_SETACL)
+ SET(ARCHIVE_ACL_SUNOS TRUE)
+ ENDIF()
+ CHECK_TYPE_EXISTS(ace_t "sys/acl.h" HAVE_ACE_T)
+ IF(HAVE_ACE_T)
+ CHECK_SYMBOL_EXISTS(ACE_GETACL "sys/acl.h" HAVE_DECL_ACE_GETACL)
+ CHECK_SYMBOL_EXISTS(ACE_GETACLCNT "sys/acl.h" HAVE_DECL_ACE_GETACLCNT)
+ CHECK_SYMBOL_EXISTS(ACE_SETACL "sys/acl.h" HAVE_DECL_ACE_SETACL)
+ IF(HAVE_DECL_ACE_GETACL AND
+ HAVE_DECL_ACE_GETACLCNT AND
+ HAVE_DECL_ACE_SETACL)
+ SET(ARCHIVE_ACL_SUNOS_NFS4 TRUE)
+ ENDIF()
+ ENDIF(HAVE_ACE_T)
+ ENDIF(HAVE_ACLENT_T)
+ ENDIF(HAVE_ACL AND HAVE_FACL)
+
+ IF(HAVE_ACL_T AND HAVE_ACL_ENTRY_T AND HAVE_ACL_PERMSET_T AND HAVE_ACL_TAG_T)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_add_perm HAVE_ACL_ADD_PERM)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_clear_perms HAVE_ACL_CLEAR_PERMS)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_create_entry HAVE_ACL_CREATE_ENTRY)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_delete_def_file HAVE_ACL_DELETE_DEF_FILE)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_free HAVE_ACL_FREE)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_get_entry HAVE_ACL_GET_ENTRY)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_get_fd HAVE_ACL_GET_FD)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_get_file HAVE_ACL_GET_FILE)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_get_permset HAVE_ACL_GET_PERMSET)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_get_qualifier HAVE_ACL_GET_QUALIFIER)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_get_tag_type HAVE_ACL_GET_TAG_TYPE)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_init HAVE_ACL_INIT)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_set_fd HAVE_ACL_SET_FD)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_set_file HAVE_ACL_SET_FILE)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_set_qualifier HAVE_ACL_SET_QUALIFIER)
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_set_tag_type HAVE_ACL_SET_TAG_TYPE)
+ IF(HAVE_ACL_ADD_PERM AND
+ HAVE_ACL_CLEAR_PERMS AND
+ HAVE_ACL_CREATE_ENTRY AND
+ HAVE_ACL_DELETE_DEF_FILE AND
+ HAVE_ACL_FREE AND
+ HAVE_ACL_GET_ENTRY AND
+ HAVE_ACL_GET_FD AND
+ HAVE_ACL_GET_FILE AND
+ HAVE_ACL_GET_PERMSET AND
+ HAVE_ACL_GET_QUALIFIER AND
+ HAVE_ACL_GET_TAG_TYPE AND
+ HAVE_ACL_INIT AND
+ HAVE_ACL_SET_FD AND
+ HAVE_ACL_SET_FILE AND
+ HAVE_ACL_SET_QUALIFIER AND
+ HAVE_ACL_SET_TAG_TYPE)
+ SET(HAVE_POSIX_ACL_FUNCS 1)
+ ENDIF()
+
+ CHECK_FUNCTION_EXISTS_GLIBC(acl_get_perm HAVE_ACL_GET_PERM)
+
+ IF(HAVE_POSIX_ACL_FUNCS AND HAVE_ACL_LIBACL_H AND HAVE_LIBACL AND
+ HAVE_ACL_GET_PERM)
+ SET(ARCHIVE_ACL_LIBACL TRUE)
+ ELSE()
+ CHECK_FUNCTION_EXISTS(acl_add_flag_np HAVE_ACL_ADD_FLAG_NP)
+ CHECK_FUNCTION_EXISTS(acl_clear_flags_np HAVE_ACL_CLEAR_FLAGS_NP)
+ CHECK_FUNCTION_EXISTS(acl_get_brand_np HAVE_ACL_GET_BRAND_NP)
+ CHECK_FUNCTION_EXISTS(acl_get_entry_type_np HAVE_ACL_GET_ENTRY_TYPE_NP)
+ CHECK_FUNCTION_EXISTS(acl_get_flag_np HAVE_ACL_GET_FLAG_NP)
+ CHECK_FUNCTION_EXISTS(acl_get_flagset_np HAVE_ACL_GET_FLAGSET_NP)
+ CHECK_FUNCTION_EXISTS(acl_get_fd_np HAVE_ACL_GET_FD_NP)
+ CHECK_FUNCTION_EXISTS(acl_get_link_np HAVE_ACL_GET_LINK_NP)
+ CHECK_FUNCTION_EXISTS(acl_get_perm_np HAVE_ACL_GET_PERM_NP)
+ CHECK_FUNCTION_EXISTS(acl_is_trivial_np HAVE_ACL_IS_TRIVIAL_NP)
+ CHECK_FUNCTION_EXISTS(acl_set_entry_type_np HAVE_ACL_SET_ENTRY_TYPE_NP)
+ CHECK_FUNCTION_EXISTS(acl_set_fd_np HAVE_ACL_SET_FD_NP)
+ CHECK_FUNCTION_EXISTS(acl_set_link_np HAVE_ACL_SET_LINK_NP)
+ CHECK_FUNCTION_EXISTS(mbr_gid_to_uuid HAVE_MBR_GID_TO_UUID)
+ CHECK_FUNCTION_EXISTS(mbr_uid_to_uuid HAVE_MBR_UID_TO_UUID)
+ CHECK_FUNCTION_EXISTS(mbr_uuid_to_id HAVE_MBR_UUID_TO_ID)
+
+ CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
+#include <sys/acl.h>
+int main(void) { return ACL_TYPE_EXTENDED; }" HAVE_DECL_ACL_TYPE_EXTENDED)
+ CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
#include <sys/acl.h>
-int main(void) { return ACL_TYPE_EXTENDED; }" HAVE_ACL_TYPE_EXTENDED)
+int main(void) { return ACL_SYNCHRONIZE; }" HAVE_DECL_ACL_SYNCHRONIZE)
+ CHECK_SYMBOL_EXISTS(ACL_TYPE_NFS4 "sys/acl.h" HAVE_DECL_ACL_TYPE_NFS4)
+ CHECK_SYMBOL_EXISTS(ACL_USER "sys/acl.h" HAVE_DECL_ACL_USER)
+
+ IF(HAVE_POSIX_ACL_FUNCS AND
+ HAVE_ACL_GET_FD_NP AND
+ HAVE_ACL_GET_PERM_NP AND
+ NOT HAVE_ACL_GET_PERM AND
+ HAVE_ACL_SET_FD_NP)
+ IF(HAVE_DECL_ACL_USER)
+ SET(ARCHIVE_ACL_FREEBSD TRUE)
+ IF(HAVE_DECL_ACL_TYPE_NFS4 AND
+ HAVE_ACL_ADD_FLAG_NP AND
+ HAVE_ACL_CLEAR_FLAGS_NP AND
+ HAVE_ACL_GET_BRAND_NP AND
+ HAVE_ACL_GET_ENTRY_TYPE_NP AND
+ HAVE_ACL_GET_FLAGSET_NP AND
+ HAVE_ACL_SET_ENTRY_TYPE_NP)
+ SET(ARCHIVE_ACL_FREEBSD_NFS4 TRUE)
+ ENDIF()
+ ELSEIF(HAVE_DECL_ACL_TYPE_EXTENDED AND
+ HAVE_MEMBERSHIP_H AND
+ HAVE_ACL_ADD_FLAG_NP AND
+ HAVE_ACL_CLEAR_FLAGS_NP AND
+ HAVE_ACL_GET_FLAGSET_NP AND
+ HAVE_ACL_GET_LINK_NP AND
+ HAVE_ACL_SET_LINK_NP AND
+ HAVE_MBR_UID_TO_UUID AND
+ HAVE_MBR_GID_TO_UUID AND
+ HAVE_MBR_UUID_TO_ID)
+ SET(ARCHIVE_ACL_DARWIN TRUE)
+ ENDIF()
+ ENDIF()
+ ENDIF()
+ ENDIF(HAVE_ACL_T AND HAVE_ACL_ENTRY_T AND HAVE_ACL_PERMSET_T AND
+ HAVE_ACL_TAG_T)
+
+ # Richacl
+ CHECK_LIBRARY_EXISTS(richacl "richacl_get_file" "" HAVE_LIBRICHACL)
+ IF(HAVE_LIBRICHACL)
+ SET(CMAKE_REQUIRED_LIBRARIES "richacl")
+ FIND_LIBRARY(RICHACL_LIBRARY NAMES richacl)
+ LIST(APPEND ADDITIONAL_LIBS ${RICHACL_LIBRARY})
+ ENDIF(HAVE_LIBRICHACL)
+
+ CHECK_STRUCT_HAS_MEMBER("struct richace" e_type "sys/richacl.h"
+ HAVE_STRUCT_RICHACE)
+ CHECK_STRUCT_HAS_MEMBER("struct richacl" a_flags "sys/richacl.h"
+ HAVE_STRUCT_RICHACL)
+
+ IF(HAVE_LIBRICHACL AND HAVE_STRUCT_RICHACL AND HAVE_STRUCT_RICHACE)
+ CHECK_FUNCTION_EXISTS_GLIBC(richacl_alloc HAVE_RICHACL_ALLOC)
+ CHECK_FUNCTION_EXISTS_GLIBC(richacl_equiv_mode HAVE_RICHACL_EQUIV_MODE)
+ CHECK_FUNCTION_EXISTS_GLIBC(richacl_free HAVE_RICHACL_FREE)
+ CHECK_FUNCTION_EXISTS_GLIBC(richacl_get_fd HAVE_RICHACL_GET_FD)
+ CHECK_FUNCTION_EXISTS_GLIBC(richacl_get_file HAVE_RICHACL_GET_FILE)
+ CHECK_FUNCTION_EXISTS_GLIBC(richacl_set_fd HAVE_RICHACL_SET_FD)
+ CHECK_FUNCTION_EXISTS_GLIBC(richacl_set_file HAVE_RICHACL_SET_FILE)
+ IF(HAVE_RICHACL_ALLOC AND
+ HAVE_RICHACL_EQUIV_MODE AND
+ HAVE_RICHACL_FREE AND
+ HAVE_RICHACL_GET_FD AND
+ HAVE_RICHACL_GET_FILE AND
+ HAVE_RICHACL_SET_FD AND
+ HAVE_RICHACL_SET_FILE)
+ SET(ARCHIVE_ACL_LIBRICHACL TRUE)
+ ENDIF()
+ ENDIF(HAVE_LIBRICHACL AND HAVE_STRUCT_RICHACL AND HAVE_STRUCT_RICHACE)
+
+ IF(ARCHIVE_ACL_DARWIN)
+ MESSAGE(STATUS "ACL support: Darwin (limited NFSv4)")
+ ELSEIF(ARCHIVE_ACL_FREEBSD_NFS4)
+ MESSAGE(STATUS "ACL support: FreeBSD (POSIX.1e and NFSv4)")
+ ELSEIF(ARCHIVE_ACL_FREEBSD)
+ MESSAGE(STATUS "ACL support: FreeBSD (POSIX.1e)")
+ ELSEIF(ARCHIVE_ACL_LIBACL OR ARCHIVE_ACL_LIBRICHACL)
+ IF(ARCHIVE_ACL_LIBACL AND ARCHIVE_ACL_LIBRICHACL)
+ MESSAGE(STATUS "ACL support: libacl (POSIX.1e) + librichacl (NFSv4)")
+ ELSEIF(ARCHIVE_ACL_LIBRICHACL)
+ MESSAGE(STATUS "ACL support: librichacl (NFSv4)")
+ ELSE()
+ MESSAGE(STATUS "ACL support: libacl (POSIX.1e)")
+ ENDIF()
+ ELSEIF(ARCHIVE_ACL_SUNOS_NFS4)
+ MESSAGE(STATUS "ACL support: Solaris (POSIX.1e and NFSv4)")
+ ELSEIF(ARCHIVE_ACL_SUNOS)
+ MESSAGE(STATUS "ACL support: Solaris (POSIX.1e)")
+ ELSE()
+ MESSAGE(STATUS "ACL support: none")
+ ENDIF()
- # Solaris and derivates ACLs
- CHECK_LIBRARY_EXISTS(sec "acl_get" "" HAVE_LIBSEC)
- IF(HAVE_LIBSEC)
- SET(CMAKE_REQUIRED_LIBRARIES "sec")
- FIND_LIBRARY(SEC_LIBRARY NAMES sec)
- LIST(APPEND ADDITIONAL_LIBS ${SEC_LIBRARY})
- ENDIF(HAVE_LIBSEC)
- #
- CHECK_TYPE_EXISTS(aclent_t "${INCLUDES}" HAVE_ACLENT_T)
- CHECK_TYPE_EXISTS(ace_t "${INCLUDES}" HAVE_ACE_T)
- CHECK_FUNCTION_EXISTS(acl_get HAVE_FACL_GET)
- CHECK_FUNCTION_EXISTS(facl_get HAVE_FACL_GET)
- CHECK_FUNCTION_EXISTS(acl_set HAVE_FACL_SET)
- CHECK_FUNCTION_EXISTS(facl_set HAVE_FACL_SET)
ELSE(ENABLE_ACL)
# If someone runs cmake, then disables ACL support, we need
# to forcibly override the cached values for these.
- SET(HAVE_ACL_CREATE_ENTRY FALSE)
- SET(HAVE_ACL_GET_LINK FALSE)
- SET(HAVE_ACL_GET_LINK_NP FALSE)
- SET(HAVE_ACL_GET_PERM FALSE)
- SET(HAVE_ACL_GET_PERM_NP FALSE)
- SET(HAVE_ACL_INIT FALSE)
- SET(HAVE_ACL_LIB FALSE)
- SET(HAVE_ACL_PERMSET_T FALSE)
- SET(HAVE_ACL_SET_FD FALSE)
- SET(HAVE_ACL_SET_FD_NP FALSE)
- SET(HAVE_ACL_SET_FILE FALSE)
- SET(HAVE_ACL_TYPE_NFS4 FALSE)
- SET(HAVE_ACL_USER FALSE)
- SET(HAVE_ACL_TYPE_EXTENDED FALSE)
- SET(HAVE_ACL_GET FALSE)
- SET(HAVE_ACLENT_T FALSE)
- SET(HAVE_ACE_T FALSE)
- SET(HAVE_FACL_GET FALSE)
- SET(HAVE_ACL_SET FALSE)
- SET(HAVE_FACL_SET FALSE)
+ SET(ARCHIVE_ACL_DARWIN FALSE)
+ SET(ARCHIVE_ACL_FREEBSD FALSE)
+ SET(ARCHIVE_ACL_FREEBSD_NFS4 FALSE)
+ SET(ARCHIVE_ACL_LIBACL FALSE)
+ SET(ARCHIVE_ACL_SUNOS FALSE)
+ SET(ARCHIVE_ACL_SUNOS_NFS4 FALSE)
ENDIF(ENABLE_ACL)
#
diff --git a/Utilities/cmlibarchive/build/cmake/config.h.in b/Utilities/cmlibarchive/build/cmake/config.h.in
index 55e04b9af..1851d81d0 100644
--- a/Utilities/cmlibarchive/build/cmake/config.h.in
+++ b/Utilities/cmlibarchive/build/cmake/config.h.in
@@ -182,6 +182,27 @@ typedef uint64_t uintmax_t;
/* Define ZLIB_WINAPI if zlib was built on Visual Studio. */
#cmakedefine ZLIB_WINAPI 1
+/* Darwin ACL support */
+#cmakedefine ARCHIVE_ACL_DARWIN 1
+
+/* FreeBSD ACL support */
+#cmakedefine ARCHIVE_ACL_FREEBSD 1
+
+/* FreeBSD NFSv4 ACL support */
+#cmakedefine ARCHIVE_ACL_FREEBSD_NFS4 1
+
+/* Linux POSIX.1e ACL support via libacl */
+#cmakedefine ARCHIVE_ACL_LIBACL 1
+
+/* Linux NFSv4 ACL support via librichacl */
+#cmakedefine ARCHIVE_ACL_LIBRICHACL 1
+
+/* Solaris ACL support */
+#cmakedefine ARCHIVE_ACL_SUNOS 1
+
+/* Solaris NFSv4 ACL support */
+#cmakedefine ARCHIVE_ACL_SUNOS_NFS4 1
+
/* MD5 via ARCHIVE_CRYPTO_MD5_LIBC supported. */
#cmakedefine ARCHIVE_CRYPTO_MD5_LIBC 1
@@ -284,6 +305,18 @@ typedef uint64_t uintmax_t;
/* SHA512 via ARCHIVE_CRYPTO_SHA512_WIN supported. */
#cmakedefine ARCHIVE_CRYPTO_SHA512_WIN 1
+/* AIX xattr support */
+#cmakedefine ARCHIVE_XATTR_AIX 1
+
+/* Darwin xattr support */
+#cmakedefine ARCHIVE_XATTR_DARWIN 1
+
+/* FreeBSD xattr support */
+#cmakedefine ARCHIVE_XATTR_FREEBSD 1
+
+/* Linux xattr support */
+#cmakedefine ARCHIVE_XATTR_LINUX 1
+
/* Version number of bsdcpio */
#cmakedefine BSDCPIO_VERSION_STRING "${BSDCPIO_VERSION_STRING}"
@@ -329,15 +362,6 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `acl_set_file' function. */
#cmakedefine HAVE_ACL_SET_FILE 1
-/* True for FreeBSD with NFSv4 ACL support */
-#cmakedefine HAVE_ACL_TYPE_NFS4 1
-
-/* True for MacOS ACL support */
-#cmakedefine HAVE_ACL_TYPE_EXTENDED 1
-
-/* True for systems with POSIX ACL support */
-#cmakedefine HAVE_ACL_USER 1
-
/* Define to 1 if you have the `arc4random_buf' function. */
#cmakedefine HAVE_ARC4RANDOM_BUF 1
@@ -374,6 +398,34 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `cygwin_conv_path' function. */
#cmakedefine HAVE_CYGWIN_CONV_PATH 1
+/* Define to 1 if you have the declaration of `ACE_GETACL', and to 0 if you
+ don't. */
+#cmakedefine HAVE_DECL_ACE_GETACL 1
+
+/* Define to 1 if you have the declaration of `ACE_GETACLCNT', and to 0 if you
+ don't. */
+#cmakedefine HAVE_DECL_ACE_GETACLCNT 1
+
+/* Define to 1 if you have the declaration of `ACE_SETACL', and to 0 if you
+ don't. */
+#cmakedefine HAVE_DECL_ACE_SETACL 1
+
+/* Define to 1 if you have the declaration of `ACL_SYNCHRONIZE', and to 0 if
+ you don't. */
+#cmakedefine HAVE_DECL_ACL_SYNCHRONIZE 1
+
+/* Define to 1 if you have the declaration of `ACL_TYPE_EXTENDED', and to 0 if
+ you don't. */
+#cmakedefine HAVE_DECL_ACL_TYPE_EXTENDED 1
+
+/* Define to 1 if you have the declaration of `ACL_TYPE_NFS4', and to 0 if you
+ don't. */
+#cmakedefine HAVE_DECL_ACL_TYPE_NFS4 1
+
+/* Define to 1 if you have the declaration of `ACL_USER', and to 0 if you
+ don't. */
+#cmakedefine HAVE_DECL_ACL_USER 1
+
/* Define to 1 if you have the declaration of `INT32_MAX', and to 0 if you
don't. */
#cmakedefine HAVE_DECL_INT32_MAX 1
@@ -398,6 +450,10 @@ typedef uint64_t uintmax_t;
don't. */
#cmakedefine HAVE_DECL_INTMAX_MIN 1
+/* Define to 1 if you have the declaration of `SETACL', and to 0 if you don't.
+ */
+#cmakedefine HAVE_DECL_SETACL 1
+
/* Define to 1 if you have the declaration of `SIZE_MAX', and to 0 if you
don't. */
#cmakedefine HAVE_DECL_SIZE_MAX 1
@@ -422,6 +478,10 @@ typedef uint64_t uintmax_t;
don't. */
#cmakedefine HAVE_DECL_UINTMAX_MAX 1
+/* Define to 1 if you have the declaration of `XATTR_NOFOLLOW', and to 0 if
+ you don't. */
+#cmakedefine HAVE_DECL_XATTR_NOFOLLOW 1
+
/* Define to 1 if you have the <direct.h> header file. */
#cmakedefine HAVE_DIRECT_H 1
@@ -471,6 +531,14 @@ typedef uint64_t uintmax_t;
/* Define to 1 if EXTATTR_NAMESPACE_USER is defined in sys/extattr.h. */
#cmakedefine HAVE_DECL_EXTATTR_NAMESPACE_USER 1
+/* Define to 1 if you have the declaration of `GETACL', and to 0 if you don't.
+ */
+#cmakedefine HAVE_DECL_GETACL 1
+
+/* Define to 1 if you have the declaration of `GETACLCNT', and to 0 if you
+ don't. */
+#cmakedefine HAVE_DECL_GETACLCNT 1
+
/* Define to 1 if you have the `fchdir' function. */
#cmakedefine HAVE_FCHDIR 1
@@ -660,6 +728,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `z' library (-lz). */
#cmakedefine HAVE_LIBZ 1
+/* Define to 1 if you have the `zstd' library (-lzstd). */
+#cmakedefine HAVE_LIBZSTD 1
+
/* Define to 1 if you have the <limits.h> header file. */
#cmakedefine HAVE_LIMITS_H 1
@@ -748,6 +819,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `mbrtowc' function. */
#cmakedefine HAVE_MBRTOWC 1
+/* Define to 1 if you have the <membership.h> header file. */
+#cmakedefine HAVE_MEMBERSHIP_H 1
+
/* Define to 1 if you have the `memmove' function. */
#cmakedefine HAVE_MEMMOVE 1
@@ -985,6 +1059,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <sys/poll.h> header file. */
#cmakedefine HAVE_SYS_POLL_H 1
+/* Define to 1 if you have the <sys/richacl.h> header file. */
+#cmakedefine HAVE_SYS_RICHACL_H 1
+
/* Define to 1 if you have the <sys/select.h> header file. */
#cmakedefine HAVE_SYS_SELECT_H 1
@@ -997,6 +1074,10 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/sysmacros.h> header file. */
+#cmakedefine HAVE_SYS_SYSMACROS_H 1
+
/* Define to 1 if you have the <sys/time.h> header file. */
#cmakedefine HAVE_SYS_TIME_H 1
@@ -1111,6 +1192,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <zlib.h> header file. */
#cmakedefine HAVE_ZLIB_H 1
+/* Define to 1 if you have the <zstd.h> header file. */
+#cmakedefine HAVE_ZSTD_H 1
+
/* Define to 1 if you have the `_ctime64_s' function. */
#cmakedefine HAVE__CTIME64_S 1
diff --git a/Utilities/cmlibarchive/build/pkgconfig/libarchive.pc.in b/Utilities/cmlibarchive/build/pkgconfig/libarchive.pc.in
index 95d715951..4b631e635 100644
--- a/Utilities/cmlibarchive/build/pkgconfig/libarchive.pc.in
+++ b/Utilities/cmlibarchive/build/pkgconfig/libarchive.pc.in
@@ -7,5 +7,6 @@ Name: libarchive
Description: library that can create and read several streaming archive formats
Version: @VERSION@
Cflags: -I${includedir}
+Cflags.private: -DLIBARCHIVE_STATIC
Libs: -L${libdir} -larchive
Libs.private: @LIBS@
diff --git a/Utilities/cmlibarchive/build/version b/Utilities/cmlibarchive/build/version
index ef8345726..2427eab0f 100644
--- a/Utilities/cmlibarchive/build/version
+++ b/Utilities/cmlibarchive/build/version
@@ -1 +1 @@
-3003001
+3003003
diff --git a/Utilities/cmlibarchive/libarchive/CMakeLists.txt b/Utilities/cmlibarchive/libarchive/CMakeLists.txt
index d412c80dc..e38d66453 100644
--- a/Utilities/cmlibarchive/libarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/libarchive/CMakeLists.txt
@@ -14,6 +14,7 @@ SET(include_HEADERS
# Sources and private headers
SET(libarchive_SOURCES
archive_acl.c
+ archive_acl_private.h
archive_check_magic.c
archive_cmdline.c
archive_cmdline_private.h
@@ -47,6 +48,8 @@ SET(libarchive_SOURCES
archive_pathmatch.c
archive_pathmatch.h
archive_platform.h
+ archive_platform_acl.h
+ archive_platform_xattr.h
archive_ppmd_private.h
archive_ppmd7.c
archive_ppmd7_private.h
@@ -85,6 +88,7 @@ SET(libarchive_SOURCES
archive_read_support_filter_rpm.c
archive_read_support_filter_uu.c
archive_read_support_filter_xz.c
+ archive_read_support_filter_zstd.c
archive_read_support_format_7zip.c
archive_read_support_format_all.c
archive_read_support_format_ar.c
@@ -106,9 +110,9 @@ SET(libarchive_SOURCES
archive_string_composition.h
archive_string_sprintf.c
archive_util.c
+ archive_version_details.c
archive_virtual.c
archive_write.c
- archive_write_disk_acl.c
archive_write_disk_posix.c
archive_write_disk_private.h
archive_write_disk_set_standard_lookup.c
@@ -131,6 +135,7 @@ SET(libarchive_SOURCES
archive_write_add_filter_program.c
archive_write_add_filter_uuencode.c
archive_write_add_filter_xz.c
+ archive_write_add_filter_zstd.c
archive_write_set_format.c
archive_write_set_format_7zip.c
archive_write_set_format_ar.c
@@ -210,6 +215,16 @@ IF(WIN32 AND NOT CYGWIN)
LIST(APPEND libarchive_SOURCES filter_fork_windows.c)
ENDIF(WIN32 AND NOT CYGWIN)
+IF(ARCHIVE_ACL_DARWIN)
+ LIST(APPEND libarchive_SOURCES archive_disk_acl_darwin.c)
+ELSEIF(ARCHIVE_ACL_FREEBSD)
+ LIST(APPEND libarchive_SOURCES archive_disk_acl_freebsd.c)
+ELSEIF(ARCHIVE_ACL_LIBACL)
+ LIST(APPEND libarchive_SOURCES archive_disk_acl_linux.c)
+ELSEIF(ARCHIVE_ACL_SUNOS)
+ LIST(APPEND libarchive_SOURCES archive_disk_acl_sunos.c)
+ENDIF()
+
# CMake needs just one static "cmlibarchive" library.
ADD_LIBRARY(cmlibarchive STATIC ${libarchive_SOURCES} ${include_HEADERS})
TARGET_LINK_LIBRARIES(cmlibarchive ${ADDITIONAL_LIBS})
diff --git a/Utilities/cmlibarchive/libarchive/archive.h b/Utilities/cmlibarchive/libarchive/archive.h
index cfb5c48b2..f3ebbfe42 100644
--- a/Utilities/cmlibarchive/libarchive/archive.h
+++ b/Utilities/cmlibarchive/libarchive/archive.h
@@ -36,7 +36,7 @@
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
*/
/* Note: Compiler will complain if this does not match archive_entry.h! */
-#define ARCHIVE_VERSION_NUMBER 3003001
+#define ARCHIVE_VERSION_NUMBER 3003003
#include <sys/stat.h>
#include <stddef.h> /* for wchar_t */
@@ -152,7 +152,7 @@ __LA_DECL int archive_version_number(void);
/*
* Textual name/version of the library, useful for version displays.
*/
-#define ARCHIVE_VERSION_ONLY_STRING "3.3.1"
+#define ARCHIVE_VERSION_ONLY_STRING "3.3.3"
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
__LA_DECL const char * archive_version_string(void);
@@ -174,6 +174,7 @@ __LA_DECL const char * archive_zlib_version(void);
__LA_DECL const char * archive_liblzma_version(void);
__LA_DECL const char * archive_bzlib_version(void);
__LA_DECL const char * archive_liblz4_version(void);
+__LA_DECL const char * archive_libzstd_version(void);
/* Declare our basic types. */
struct archive;
@@ -273,6 +274,7 @@ typedef const char *archive_passphrase_callback(struct archive *,
#define ARCHIVE_FILTER_LZOP 11
#define ARCHIVE_FILTER_GRZIP 12
#define ARCHIVE_FILTER_LZ4 13
+#define ARCHIVE_FILTER_ZSTD 14
#if ARCHIVE_VERSION_NUMBER < 4000000
#define ARCHIVE_COMPRESSION_NONE ARCHIVE_FILTER_NONE
@@ -430,6 +432,7 @@ __LA_DECL int archive_read_support_filter_program_signature
__LA_DECL int archive_read_support_filter_rpm(struct archive *);
__LA_DECL int archive_read_support_filter_uu(struct archive *);
__LA_DECL int archive_read_support_filter_xz(struct archive *);
+__LA_DECL int archive_read_support_filter_zstd(struct archive *);
__LA_DECL int archive_read_support_format_7zip(struct archive *);
__LA_DECL int archive_read_support_format_all(struct archive *);
@@ -775,6 +778,7 @@ __LA_DECL int archive_write_add_filter_program(struct archive *,
const char *cmd);
__LA_DECL int archive_write_add_filter_uuencode(struct archive *);
__LA_DECL int archive_write_add_filter_xz(struct archive *);
+__LA_DECL int archive_write_add_filter_zstd(struct archive *);
/* A convenience function to set the format based on the code or name. */
diff --git a/Utilities/cmlibarchive/libarchive/archive_acl.c b/Utilities/cmlibarchive/libarchive/archive_acl.c
index b8b6b6364..4736531af 100644
--- a/Utilities/cmlibarchive/libarchive/archive_acl.c
+++ b/Utilities/cmlibarchive/libarchive/archive_acl.c
@@ -1159,6 +1159,7 @@ archive_acl_from_text_w(struct archive_acl *acl, const wchar_t *text,
switch (want_type) {
case ARCHIVE_ENTRY_ACL_TYPE_POSIX1E:
want_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
+ __LA_FALLTHROUGH;
case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
numfields = 5;
@@ -1626,6 +1627,7 @@ archive_acl_from_text_l(struct archive_acl *acl, const char *text,
switch (want_type) {
case ARCHIVE_ENTRY_ACL_TYPE_POSIX1E:
want_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
+ __LA_FALLTHROUGH;
case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
numfields = 5;
diff --git a/Utilities/cmlibarchive/libarchive/archive_check_magic.c b/Utilities/cmlibarchive/libarchive/archive_check_magic.c
index c695e582a..288ce2338 100644
--- a/Utilities/cmlibarchive/libarchive/archive_check_magic.c
+++ b/Utilities/cmlibarchive/libarchive/archive_check_magic.c
@@ -62,7 +62,7 @@ errmsg(const char *m)
}
}
-static void
+static __LA_DEAD void
diediedie(void)
{
#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
diff --git a/Utilities/cmlibarchive/libarchive/archive_cmdline.c b/Utilities/cmlibarchive/libarchive/archive_cmdline.c
index 7d3bac53b..5c519cd17 100644
--- a/Utilities/cmlibarchive/libarchive/archive_cmdline.c
+++ b/Utilities/cmlibarchive/libarchive/archive_cmdline.c
@@ -100,10 +100,10 @@ get_argument(struct archive_string *as, const char *p)
/*
* Set up command line arguments.
- * Returns ARChIVE_OK if everything okey.
- * Returns ARChIVE_FAILED if there is a lack of the `"' terminator or an
+ * Returns ARCHIVE_OK if everything okey.
+ * Returns ARCHIVE_FAILED if there is a lack of the `"' terminator or an
* empty command line.
- * Returns ARChIVE_FATAL if no memory.
+ * Returns ARCHIVE_FATAL if no memory.
*/
int
__archive_cmdline_parse(struct archive_cmdline *data, const char *cmd)
diff --git a/Utilities/cmlibarchive/libarchive/archive_cryptor.c b/Utilities/cmlibarchive/libarchive/archive_cryptor.c
index ced52fd70..71967c9d4 100644
--- a/Utilities/cmlibarchive/libarchive/archive_cryptor.c
+++ b/Utilities/cmlibarchive/libarchive/archive_cryptor.c
@@ -153,7 +153,7 @@ aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
CCCryptorStatus r;
r = CCCryptorReset(ref, NULL);
- if (r != kCCSuccess)
+ if (r != kCCSuccess && r != kCCUnimplemented)
return -1;
r = CCCryptorUpdate(ref, ctx->nonce, AES_BLOCK_SIZE, ctx->encr_buf,
AES_BLOCK_SIZE, NULL);
diff --git a/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h b/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h
index 0ca544b57..b9759220d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h
@@ -64,7 +64,7 @@ typedef struct {
} archive_crypto_ctx;
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H)
-#include <Bcrypt.h>
+#include <bcrypt.h>
/* Common in other bcrypt implementations, but missing from VS2008. */
#ifndef BCRYPT_SUCCESS
diff --git a/Utilities/cmlibarchive/libarchive/archive_disk_acl_darwin.c b/Utilities/cmlibarchive/libarchive/archive_disk_acl_darwin.c
new file mode 100644
index 000000000..48ad01651
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_disk_acl_darwin.c
@@ -0,0 +1,559 @@
+/*-
+ * Copyright (c) 2017 Martin Matuska
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+
+#if ARCHIVE_ACL_DARWIN
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#if HAVE_MEMBERSHIP_H
+#include <membership.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_ACL_H
+#define _ACL_PRIVATE /* For debugging */
+#include <sys/acl.h>
+#endif
+
+#include "archive_entry.h"
+#include "archive_private.h"
+#include "archive_read_disk_private.h"
+#include "archive_write_disk_private.h"
+
+typedef struct {
+ const int a_perm; /* Libarchive permission or flag */
+ const int p_perm; /* Platform permission or flag */
+} acl_perm_map_t;
+
+static const acl_perm_map_t acl_nfs4_perm_map[] = {
+ {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
+ {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
+ {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE},
+ {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
+ {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE},
+ {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY},
+ {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD},
+ {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_EXTATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_EXTATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_SECURITY},
+ {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_SECURITY},
+ {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_CHANGE_OWNER},
+#if HAVE_DECL_ACL_SYNCHRONIZE
+ {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
+#endif
+};
+
+static const int acl_nfs4_perm_map_size =
+ (int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));
+
+static const acl_perm_map_t acl_nfs4_flag_map[] = {
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED},
+ {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
+ {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT},
+ {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_LIMIT_INHERIT},
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_ONLY_INHERIT}
+};
+
+static const int acl_nfs4_flag_map_size =
+ (int)(sizeof(acl_nfs4_flag_map)/sizeof(acl_nfs4_flag_map[0]));
+
+static int translate_guid(struct archive *a, acl_entry_t acl_entry,
+ int *ae_id, int *ae_tag, const char **ae_name)
+{
+ void *q;
+ uid_t ugid;
+ int r, idtype;
+
+ q = acl_get_qualifier(acl_entry);
+ if (q == NULL)
+ return (1);
+ r = mbr_uuid_to_id((const unsigned char *)q, &ugid, &idtype);
+ if (r != 0) {
+ acl_free(q);
+ return (1);
+ }
+ if (idtype == ID_TYPE_UID) {
+ *ae_tag = ARCHIVE_ENTRY_ACL_USER;
+ *ae_id = ugid;
+ *ae_name = archive_read_disk_uname(a, *ae_id);
+ } else if (idtype == ID_TYPE_GID) {
+ *ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
+ *ae_id = ugid;
+ *ae_name = archive_read_disk_gname(a, *ae_id);
+ } else
+ r = 1;
+
+ acl_free(q);
+ return (r);
+}
+
+static void
+add_trivial_nfs4_acl(struct archive_entry *entry)
+{
+ mode_t mode;
+ int i;
+ const int rperm = ARCHIVE_ENTRY_ACL_READ_DATA;
+ const int wperm = ARCHIVE_ENTRY_ACL_WRITE_DATA |
+ ARCHIVE_ENTRY_ACL_APPEND_DATA;
+ const int eperm = ARCHIVE_ENTRY_ACL_EXECUTE;
+ const int pubset = ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_READ_ACL |
+ ARCHIVE_ENTRY_ACL_SYNCHRONIZE;
+ const int ownset = pubset | ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
+ ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
+ ARCHIVE_ENTRY_ACL_WRITE_ACL |
+ ARCHIVE_ENTRY_ACL_WRITE_OWNER;
+
+ struct {
+ const int type;
+ const int tag;
+ int permset;
+ } tacl_entry[] = {
+ {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_USER_OBJ, 0},
+ {ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_USER_OBJ, 0},
+ {ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0},
+ {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_USER_OBJ, ownset},
+ {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_GROUP_OBJ, pubset},
+ {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EVERYONE, pubset}
+ };
+
+ mode = archive_entry_mode(entry);
+
+ /* Permissions for everyone@ */
+ if (mode & 0004)
+ tacl_entry[5].permset |= rperm;
+ if (mode & 0002)
+ tacl_entry[5].permset |= wperm;
+ if (mode & 0001)
+ tacl_entry[5].permset |= eperm;
+
+ /* Permissions for group@ */
+ if (mode & 0040)
+ tacl_entry[4].permset |= rperm;
+ else if (mode & 0004)
+ tacl_entry[2].permset |= rperm;
+ if (mode & 0020)
+ tacl_entry[4].permset |= wperm;
+ else if (mode & 0002)
+ tacl_entry[2].permset |= wperm;
+ if (mode & 0010)
+ tacl_entry[4].permset |= eperm;
+ else if (mode & 0001)
+ tacl_entry[2].permset |= eperm;
+
+ /* Permissions for owner@ */
+ if (mode & 0400) {
+ tacl_entry[3].permset |= rperm;
+ if (!(mode & 0040) && (mode & 0004))
+ tacl_entry[0].permset |= rperm;
+ } else if ((mode & 0040) || (mode & 0004))
+ tacl_entry[1].permset |= rperm;
+ if (mode & 0200) {
+ tacl_entry[3].permset |= wperm;
+ if (!(mode & 0020) && (mode & 0002))
+ tacl_entry[0].permset |= wperm;
+ } else if ((mode & 0020) || (mode & 0002))
+ tacl_entry[1].permset |= wperm;
+ if (mode & 0100) {
+ tacl_entry[3].permset |= eperm;
+ if (!(mode & 0010) && (mode & 0001))
+ tacl_entry[0].permset |= eperm;
+ } else if ((mode & 0010) || (mode & 0001))
+ tacl_entry[1].permset |= eperm;
+
+ for (i = 0; i < 6; i++) {
+ if (tacl_entry[i].permset != 0) {
+ archive_entry_acl_add_entry(entry,
+ tacl_entry[i].type, tacl_entry[i].permset,
+ tacl_entry[i].tag, -1, NULL);
+ }
+ }
+
+ return;
+}
+
+static int
+translate_acl(struct archive_read_disk *a,
+ struct archive_entry *entry, acl_t acl)
+{
+ acl_tag_t acl_tag;
+ acl_flagset_t acl_flagset;
+ acl_entry_t acl_entry;
+ acl_permset_t acl_permset;
+ int i, entry_acl_type;
+ int r, s, ae_id, ae_tag, ae_perm;
+ const char *ae_name;
+
+ s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
+ if (s == -1) {
+ archive_set_error(&a->archive, errno,
+ "Failed to get first ACL entry");
+ return (ARCHIVE_WARN);
+ }
+
+ while (s == 0) {
+ ae_id = -1;
+ ae_name = NULL;
+ ae_perm = 0;
+
+ if (acl_get_tag_type(acl_entry, &acl_tag) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Failed to get ACL tag type");
+ return (ARCHIVE_WARN);
+ }
+ switch (acl_tag) {
+ case ACL_EXTENDED_ALLOW:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
+ r = translate_guid(&a->archive, acl_entry,
+ &ae_id, &ae_tag, &ae_name);
+ break;
+ case ACL_EXTENDED_DENY:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
+ r = translate_guid(&a->archive, acl_entry,
+ &ae_id, &ae_tag, &ae_name);
+ break;
+ default:
+ /* Skip types that libarchive can't support. */
+ s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
+ continue;
+ }
+
+ /* Skip if translate_guid() above failed */
+ if (r != 0) {
+ s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
+ continue;
+ }
+
+ /*
+ * Libarchive stores "flag" (NFSv4 inheritance bits)
+ * in the ae_perm bitmap.
+ *
+ * acl_get_flagset_np() fails with non-NFSv4 ACLs
+ */
+ if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Failed to get flagset from a NFSv4 ACL entry");
+ return (ARCHIVE_WARN);
+ }
+ for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
+ r = acl_get_flag_np(acl_flagset,
+ acl_nfs4_flag_map[i].p_perm);
+ if (r == -1) {
+ archive_set_error(&a->archive, errno,
+ "Failed to check flag in a NFSv4 "
+ "ACL flagset");
+ return (ARCHIVE_WARN);
+ } else if (r)
+ ae_perm |= acl_nfs4_flag_map[i].a_perm;
+ }
+
+ if (acl_get_permset(acl_entry, &acl_permset) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Failed to get ACL permission set");
+ return (ARCHIVE_WARN);
+ }
+
+ for (i = 0; i < acl_nfs4_perm_map_size; ++i) {
+ /*
+ * acl_get_perm() is spelled differently on different
+ * platforms; see above.
+ */
+ r = acl_get_perm_np(acl_permset,
+ acl_nfs4_perm_map[i].p_perm);
+ if (r == -1) {
+ archive_set_error(&a->archive, errno,
+ "Failed to check permission in an ACL "
+ "permission set");
+ return (ARCHIVE_WARN);
+ } else if (r)
+ ae_perm |= acl_nfs4_perm_map[i].a_perm;
+ }
+
+#if !HAVE_DECL_ACL_SYNCHRONIZE
+ /* On Mac OS X without ACL_SYNCHRONIZE assume it is set */
+ ae_perm |= ARCHIVE_ENTRY_ACL_SYNCHRONIZE;
+#endif
+
+ archive_entry_acl_add_entry(entry, entry_acl_type,
+ ae_perm, ae_tag,
+ ae_id, ae_name);
+
+ s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
+ }
+ return (ARCHIVE_OK);
+}
+
+static int
+set_acl(struct archive *a, int fd, const char *name,
+ struct archive_acl *abstract_acl,
+ int ae_requested_type, const char *tname)
+{
+ acl_t acl;
+ acl_entry_t acl_entry;
+ acl_permset_t acl_permset;
+ acl_flagset_t acl_flagset;
+ int ret;
+ int ae_type, ae_permset, ae_tag, ae_id;
+ uuid_t ae_uuid;
+ uid_t ae_uid;
+ gid_t ae_gid;
+ const char *ae_name;
+ int entries;
+ int i;
+
+ ret = ARCHIVE_OK;
+ entries = archive_acl_reset(abstract_acl, ae_requested_type);
+ if (entries == 0)
+ return (ARCHIVE_OK);
+
+ if (ae_requested_type != ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ errno = ENOENT;
+ archive_set_error(a, errno, "Unsupported ACL type");
+ return (ARCHIVE_FAILED);
+ }
+
+ acl = acl_init(entries);
+ if (acl == (acl_t)NULL) {
+ archive_set_error(a, errno,
+ "Failed to initialize ACL working storage");
+ return (ARCHIVE_FAILED);
+ }
+
+ while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
+ &ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
+ /*
+ * Mac OS doesn't support NFSv4 ACLs for
+ * owner@, group@ and everyone@.
+ * We skip any of these ACLs found.
+ */
+ if (ae_tag == ARCHIVE_ENTRY_ACL_USER_OBJ ||
+ ae_tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ ||
+ ae_tag == ARCHIVE_ENTRY_ACL_EVERYONE)
+ continue;
+
+ if (acl_create_entry(&acl, &acl_entry) != 0) {
+ archive_set_error(a, errno,
+ "Failed to create a new ACL entry");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+ switch (ae_type) {
+ case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
+ acl_set_tag_type(acl_entry, ACL_EXTENDED_ALLOW);
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_DENY:
+ acl_set_tag_type(acl_entry, ACL_EXTENDED_DENY);
+ break;
+ default:
+ /* We don't support any other types on MacOS */
+ continue;
+ }
+
+ switch (ae_tag) {
+ case ARCHIVE_ENTRY_ACL_USER:
+ ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
+ if (mbr_uid_to_uuid(ae_uid, ae_uuid) != 0)
+ continue;
+ if (acl_set_qualifier(acl_entry, &ae_uuid) != 0)
+ continue;
+ break;
+ case ARCHIVE_ENTRY_ACL_GROUP:
+ ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
+ if (mbr_gid_to_uuid(ae_gid, ae_uuid) != 0)
+ continue;
+ if (acl_set_qualifier(acl_entry, &ae_uuid) != 0)
+ continue;
+ break;
+ default:
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "Unsupported ACL tag");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+ if (acl_get_permset(acl_entry, &acl_permset) != 0) {
+ archive_set_error(a, errno,
+ "Failed to get ACL permission set");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+ if (acl_clear_perms(acl_permset) != 0) {
+ archive_set_error(a, errno,
+ "Failed to clear ACL permissions");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+ for (i = 0; i < acl_nfs4_perm_map_size; ++i) {
+ if (ae_permset & acl_nfs4_perm_map[i].a_perm) {
+ if (acl_add_perm(acl_permset,
+ acl_nfs4_perm_map[i].p_perm) != 0) {
+ archive_set_error(a, errno,
+ "Failed to add ACL permission");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+ }
+ }
+
+ /*
+ * acl_get_flagset_np() fails with non-NFSv4 ACLs
+ */
+ if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
+ archive_set_error(a, errno,
+ "Failed to get flagset from an NFSv4 ACL entry");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+ if (acl_clear_flags_np(acl_flagset) != 0) {
+ archive_set_error(a, errno,
+ "Failed to clear flags from an NFSv4 ACL flagset");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+ for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
+ if (ae_permset & acl_nfs4_flag_map[i].a_perm) {
+ if (acl_add_flag_np(acl_flagset,
+ acl_nfs4_flag_map[i].p_perm) != 0) {
+ archive_set_error(a, errno,
+ "Failed to add flag to "
+ "NFSv4 ACL flagset");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+ }
+ }
+ }
+
+ if (fd >= 0) {
+ if (acl_set_fd_np(fd, acl, ACL_TYPE_EXTENDED) == 0)
+ ret = ARCHIVE_OK;
+ else {
+ if (errno == EOPNOTSUPP) {
+ /* Filesystem doesn't support ACLs */
+ ret = ARCHIVE_OK;
+ } else {
+ archive_set_error(a, errno,
+ "Failed to set acl on fd: %s", tname);
+ ret = ARCHIVE_WARN;
+ }
+ }
+ } else if (acl_set_link_np(name, ACL_TYPE_EXTENDED, acl) != 0) {
+ if (errno == EOPNOTSUPP) {
+ /* Filesystem doesn't support ACLs */
+ ret = ARCHIVE_OK;
+ } else {
+ archive_set_error(a, errno, "Failed to set acl: %s",
+ tname);
+ ret = ARCHIVE_WARN;
+ }
+ }
+exit_free:
+ acl_free(acl);
+ return (ret);
+}
+
+int
+archive_read_disk_entry_setup_acls(struct archive_read_disk *a,
+ struct archive_entry *entry, int *fd)
+{
+ const char *accpath;
+ acl_t acl;
+ int r;
+
+ accpath = NULL;
+
+ if (*fd < 0) {
+ accpath = archive_read_disk_entry_setup_path(a, entry, fd);
+ if (accpath == NULL)
+ return (ARCHIVE_WARN);
+ }
+
+ archive_entry_acl_clear(entry);
+
+ acl = NULL;
+
+ if (*fd >= 0)
+ acl = acl_get_fd_np(*fd, ACL_TYPE_EXTENDED);
+ else if (!a->follow_symlinks)
+ acl = acl_get_link_np(accpath, ACL_TYPE_EXTENDED);
+ else
+ acl = acl_get_file(accpath, ACL_TYPE_EXTENDED);
+
+ if (acl != NULL) {
+ r = translate_acl(a, entry, acl);
+ acl_free(acl);
+ acl = NULL;
+
+ if (r != ARCHIVE_OK) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't translate NFSv4 ACLs");
+ }
+
+ /*
+ * Because Mac OS doesn't support owner@, group@ and everyone@
+ * ACLs we need to add NFSv4 ACLs mirroring the file mode to
+ * the archive entry. Otherwise extraction on non-Mac platforms
+ * would lead to an invalid file mode.
+ */
+ if ((archive_entry_acl_types(entry) &
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0)
+ add_trivial_nfs4_acl(entry);
+
+ return (r);
+ }
+ return (ARCHIVE_OK);
+}
+
+int
+archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
+ struct archive_acl *abstract_acl, __LA_MODE_T mode)
+{
+ int ret = ARCHIVE_OK;
+
+ (void)mode; /* UNUSED */
+
+ if ((archive_acl_types(abstract_acl) &
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
+ ret = set_acl(a, fd, name, abstract_acl,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
+ }
+ return (ret);
+}
+#endif /* ARCHIVE_ACL_DARWIN */
diff --git a/Utilities/cmlibarchive/libarchive/archive_disk_acl_freebsd.c b/Utilities/cmlibarchive/libarchive/archive_disk_acl_freebsd.c
new file mode 100644
index 000000000..aba41e5da
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_disk_acl_freebsd.c
@@ -0,0 +1,702 @@
+/*-
+ * Copyright (c) 2003-2009 Tim Kientzle
+ * Copyright (c) 2010-2012 Michihiro NAKAJIMA
+ * Copyright (c) 2017 Martin Matuska
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+
+#if ARCHIVE_ACL_FREEBSD
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_ACL_H
+#define _ACL_PRIVATE /* For debugging */
+#include <sys/acl.h>
+#endif
+
+#include "archive_entry.h"
+#include "archive_private.h"
+#include "archive_read_disk_private.h"
+#include "archive_write_disk_private.h"
+
+typedef struct {
+ const int a_perm; /* Libarchive permission or flag */
+ const int p_perm; /* Platform permission or flag */
+} acl_perm_map_t;
+
+static const acl_perm_map_t acl_posix_perm_map[] = {
+ {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
+ {ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
+ {ARCHIVE_ENTRY_ACL_READ, ACL_READ},
+};
+
+static const int acl_posix_perm_map_size =
+ (int)(sizeof(acl_posix_perm_map)/sizeof(acl_posix_perm_map[0]));
+
+#if ARCHIVE_ACL_FREEBSD_NFS4
+static const acl_perm_map_t acl_nfs4_perm_map[] = {
+ {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
+ {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
+ {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
+ {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE},
+ {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY},
+ {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_NAMED_ATTRS},
+ {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_NAMED_ATTRS},
+ {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD},
+ {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE},
+ {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_ACL},
+ {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL},
+ {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER},
+ {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
+};
+
+static const int acl_nfs4_perm_map_size =
+ (int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));
+
+static const acl_perm_map_t acl_nfs4_flag_map[] = {
+ {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
+ {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT},
+ {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT},
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY},
+ {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACL_ENTRY_SUCCESSFUL_ACCESS},
+ {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACL_ENTRY_FAILED_ACCESS},
+#ifdef ACL_ENTRY_INHERITED
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED}
+#endif
+};
+
+static const int acl_nfs4_flag_map_size =
+ (int)(sizeof(acl_nfs4_flag_map)/sizeof(acl_nfs4_flag_map[0]));
+#endif /* ARCHIVE_ACL_FREEBSD_NFS4 */
+
+static int
+translate_acl(struct archive_read_disk *a,
+ struct archive_entry *entry, acl_t acl, int default_entry_acl_type)
+{
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ int brand;
+ acl_flagset_t acl_flagset;
+ acl_entry_type_t acl_type;
+#endif
+ acl_tag_t acl_tag;
+ acl_entry_t acl_entry;
+ acl_permset_t acl_permset;
+ int i, entry_acl_type, perm_map_size;
+ const acl_perm_map_t *perm_map;
+ int r, s, ae_id, ae_tag, ae_perm;
+ void *q;
+ const char *ae_name;
+
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ // FreeBSD "brands" ACLs as POSIX.1e or NFSv4
+ // Make sure the "brand" on this ACL is consistent
+ // with the default_entry_acl_type bits provided.
+ if (acl_get_brand_np(acl, &brand) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Failed to read ACL brand");
+ return (ARCHIVE_WARN);
+ }
+ switch (brand) {
+ case ACL_BRAND_POSIX:
+ switch (default_entry_acl_type) {
+ case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
+ case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
+ break;
+ default:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Invalid ACL entry type for POSIX.1e ACL");
+ return (ARCHIVE_WARN);
+ }
+ break;
+ case ACL_BRAND_NFS4:
+ if (default_entry_acl_type & ~ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Invalid ACL entry type for NFSv4 ACL");
+ return (ARCHIVE_WARN);
+ }
+ break;
+ default:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Unknown ACL brand");
+ return (ARCHIVE_WARN);
+ }
+#endif
+
+ s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
+ if (s == -1) {
+ archive_set_error(&a->archive, errno,
+ "Failed to get first ACL entry");
+ return (ARCHIVE_WARN);
+ }
+
+ while (s == 1) {
+ ae_id = -1;
+ ae_name = NULL;
+ ae_perm = 0;
+
+ if (acl_get_tag_type(acl_entry, &acl_tag) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Failed to get ACL tag type");
+ return (ARCHIVE_WARN);
+ }
+ switch (acl_tag) {
+ case ACL_USER:
+ q = acl_get_qualifier(acl_entry);
+ if (q != NULL) {
+ ae_id = (int)*(uid_t *)q;
+ acl_free(q);
+ ae_name = archive_read_disk_uname(&a->archive,
+ ae_id);
+ }
+ ae_tag = ARCHIVE_ENTRY_ACL_USER;
+ break;
+ case ACL_GROUP:
+ q = acl_get_qualifier(acl_entry);
+ if (q != NULL) {
+ ae_id = (int)*(gid_t *)q;
+ acl_free(q);
+ ae_name = archive_read_disk_gname(&a->archive,
+ ae_id);
+ }
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
+ break;
+ case ACL_MASK:
+ ae_tag = ARCHIVE_ENTRY_ACL_MASK;
+ break;
+ case ACL_USER_OBJ:
+ ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+ break;
+ case ACL_GROUP_OBJ:
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+ break;
+ case ACL_OTHER:
+ ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
+ break;
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ case ACL_EVERYONE:
+ ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE;
+ break;
+#endif
+ default:
+ /* Skip types that libarchive can't support. */
+ s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
+ continue;
+ }
+
+ // XXX acl_type maps to allow/deny/audit/YYYY bits
+ entry_acl_type = default_entry_acl_type;
+
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ /*
+ * acl_get_entry_type_np() fails with non-NFSv4 ACLs
+ */
+ if (acl_get_entry_type_np(acl_entry, &acl_type) != 0) {
+ archive_set_error(&a->archive, errno, "Failed "
+ "to get ACL type from a NFSv4 ACL entry");
+ return (ARCHIVE_WARN);
+ }
+ switch (acl_type) {
+ case ACL_ENTRY_TYPE_ALLOW:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
+ break;
+ case ACL_ENTRY_TYPE_DENY:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
+ break;
+ case ACL_ENTRY_TYPE_AUDIT:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_AUDIT;
+ break;
+ case ACL_ENTRY_TYPE_ALARM:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALARM;
+ break;
+ default:
+ archive_set_error(&a->archive, errno,
+ "Invalid NFSv4 ACL entry type");
+ return (ARCHIVE_WARN);
+ }
+
+ /*
+ * Libarchive stores "flag" (NFSv4 inheritance bits)
+ * in the ae_perm bitmap.
+ *
+ * acl_get_flagset_np() fails with non-NFSv4 ACLs
+ */
+ if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Failed to get flagset from a NFSv4 "
+ "ACL entry");
+ return (ARCHIVE_WARN);
+ }
+ for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
+ r = acl_get_flag_np(acl_flagset,
+ acl_nfs4_flag_map[i].p_perm);
+ if (r == -1) {
+ archive_set_error(&a->archive, errno,
+ "Failed to check flag in a NFSv4 "
+ "ACL flagset");
+ return (ARCHIVE_WARN);
+ } else if (r)
+ ae_perm |= acl_nfs4_flag_map[i].a_perm;
+ }
+ }
+#endif
+
+ if (acl_get_permset(acl_entry, &acl_permset) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Failed to get ACL permission set");
+ return (ARCHIVE_WARN);
+ }
+
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ perm_map_size = acl_nfs4_perm_map_size;
+ perm_map = acl_nfs4_perm_map;
+ } else {
+#endif
+ perm_map_size = acl_posix_perm_map_size;
+ perm_map = acl_posix_perm_map;
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ }
+#endif
+
+ for (i = 0; i < perm_map_size; ++i) {
+ r = acl_get_perm_np(acl_permset, perm_map[i].p_perm);
+ if (r == -1) {
+ archive_set_error(&a->archive, errno,
+ "Failed to check permission in an ACL "
+ "permission set");
+ return (ARCHIVE_WARN);
+ } else if (r)
+ ae_perm |= perm_map[i].a_perm;
+ }
+
+ archive_entry_acl_add_entry(entry, entry_acl_type,
+ ae_perm, ae_tag,
+ ae_id, ae_name);
+
+ s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
+ if (s == -1) {
+ archive_set_error(&a->archive, errno,
+ "Failed to get next ACL entry");
+ return (ARCHIVE_WARN);
+ }
+ }
+ return (ARCHIVE_OK);
+}
+
+static int
+set_acl(struct archive *a, int fd, const char *name,
+ struct archive_acl *abstract_acl,
+ int ae_requested_type, const char *tname)
+{
+ int acl_type = 0;
+ acl_t acl;
+ acl_entry_t acl_entry;
+ acl_permset_t acl_permset;
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ acl_flagset_t acl_flagset;
+ int r;
+#endif
+ int ret;
+ int ae_type, ae_permset, ae_tag, ae_id;
+ int perm_map_size;
+ const acl_perm_map_t *perm_map;
+ uid_t ae_uid;
+ gid_t ae_gid;
+ const char *ae_name;
+ int entries;
+ int i;
+
+ ret = ARCHIVE_OK;
+ entries = archive_acl_reset(abstract_acl, ae_requested_type);
+ if (entries == 0)
+ return (ARCHIVE_OK);
+
+
+ switch (ae_requested_type) {
+ case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
+ acl_type = ACL_TYPE_ACCESS;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
+ acl_type = ACL_TYPE_DEFAULT;
+ break;
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ case ARCHIVE_ENTRY_ACL_TYPE_NFS4:
+ acl_type = ACL_TYPE_NFS4;
+ break;
+#endif
+ default:
+ errno = ENOENT;
+ archive_set_error(a, errno, "Unsupported ACL type");
+ return (ARCHIVE_FAILED);
+ }
+
+ acl = acl_init(entries);
+ if (acl == (acl_t)NULL) {
+ archive_set_error(a, errno,
+ "Failed to initialize ACL working storage");
+ return (ARCHIVE_FAILED);
+ }
+
+ while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
+ &ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
+ if (acl_create_entry(&acl, &acl_entry) != 0) {
+ archive_set_error(a, errno,
+ "Failed to create a new ACL entry");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+ switch (ae_tag) {
+ case ARCHIVE_ENTRY_ACL_USER:
+ ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
+ acl_set_tag_type(acl_entry, ACL_USER);
+ acl_set_qualifier(acl_entry, &ae_uid);
+ break;
+ case ARCHIVE_ENTRY_ACL_GROUP:
+ ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
+ acl_set_tag_type(acl_entry, ACL_GROUP);
+ acl_set_qualifier(acl_entry, &ae_gid);
+ break;
+ case ARCHIVE_ENTRY_ACL_USER_OBJ:
+ acl_set_tag_type(acl_entry, ACL_USER_OBJ);
+ break;
+ case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
+ acl_set_tag_type(acl_entry, ACL_GROUP_OBJ);
+ break;
+ case ARCHIVE_ENTRY_ACL_MASK:
+ acl_set_tag_type(acl_entry, ACL_MASK);
+ break;
+ case ARCHIVE_ENTRY_ACL_OTHER:
+ acl_set_tag_type(acl_entry, ACL_OTHER);
+ break;
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ case ARCHIVE_ENTRY_ACL_EVERYONE:
+ acl_set_tag_type(acl_entry, ACL_EVERYONE);
+ break;
+#endif
+ default:
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "Unsupported ACL tag");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ r = 0;
+ switch (ae_type) {
+ case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
+ r = acl_set_entry_type_np(acl_entry,
+ ACL_ENTRY_TYPE_ALLOW);
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_DENY:
+ r = acl_set_entry_type_np(acl_entry,
+ ACL_ENTRY_TYPE_DENY);
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
+ r = acl_set_entry_type_np(acl_entry,
+ ACL_ENTRY_TYPE_AUDIT);
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
+ r = acl_set_entry_type_np(acl_entry,
+ ACL_ENTRY_TYPE_ALARM);
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
+ case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
+ // These don't translate directly into the system ACL.
+ break;
+ default:
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "Unsupported ACL entry type");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+ if (r != 0) {
+ archive_set_error(a, errno,
+ "Failed to set ACL entry type");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+#endif
+
+ if (acl_get_permset(acl_entry, &acl_permset) != 0) {
+ archive_set_error(a, errno,
+ "Failed to get ACL permission set");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+ if (acl_clear_perms(acl_permset) != 0) {
+ archive_set_error(a, errno,
+ "Failed to clear ACL permissions");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ if (ae_requested_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ perm_map_size = acl_nfs4_perm_map_size;
+ perm_map = acl_nfs4_perm_map;
+ } else {
+#endif
+ perm_map_size = acl_posix_perm_map_size;
+ perm_map = acl_posix_perm_map;
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ }
+#endif
+
+ for (i = 0; i < perm_map_size; ++i) {
+ if (ae_permset & perm_map[i].a_perm) {
+ if (acl_add_perm(acl_permset,
+ perm_map[i].p_perm) != 0) {
+ archive_set_error(a, errno,
+ "Failed to add ACL permission");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+ }
+ }
+
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ if (ae_requested_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ /*
+ * acl_get_flagset_np() fails with non-NFSv4 ACLs
+ */
+ if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
+ archive_set_error(a, errno,
+ "Failed to get flagset from an NFSv4 "
+ "ACL entry");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+ if (acl_clear_flags_np(acl_flagset) != 0) {
+ archive_set_error(a, errno,
+ "Failed to clear flags from an NFSv4 "
+ "ACL flagset");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+ for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
+ if (ae_permset & acl_nfs4_flag_map[i].a_perm) {
+ if (acl_add_flag_np(acl_flagset,
+ acl_nfs4_flag_map[i].p_perm) != 0) {
+ archive_set_error(a, errno,
+ "Failed to add flag to "
+ "NFSv4 ACL flagset");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+ }
+ }
+ }
+#endif
+ }
+
+ /* Try restoring the ACL through 'fd' if we can. */
+ if (fd >= 0) {
+ if (acl_set_fd_np(fd, acl, acl_type) == 0)
+ ret = ARCHIVE_OK;
+ else {
+ if (errno == EOPNOTSUPP) {
+ /* Filesystem doesn't support ACLs */
+ ret = ARCHIVE_OK;
+ } else {
+ archive_set_error(a, errno,
+ "Failed to set acl on fd: %s", tname);
+ ret = ARCHIVE_WARN;
+ }
+ }
+ }
+#if HAVE_ACL_SET_LINK_NP
+ else if (acl_set_link_np(name, acl_type, acl) != 0)
+#else
+ /* FreeBSD older than 8.0 */
+ else if (acl_set_file(name, acl_type, acl) != 0)
+#endif
+ {
+ if (errno == EOPNOTSUPP) {
+ /* Filesystem doesn't support ACLs */
+ ret = ARCHIVE_OK;
+ } else {
+ archive_set_error(a, errno, "Failed to set acl: %s",
+ tname);
+ ret = ARCHIVE_WARN;
+ }
+ }
+exit_free:
+ acl_free(acl);
+ return (ret);
+}
+
+int
+archive_read_disk_entry_setup_acls(struct archive_read_disk *a,
+ struct archive_entry *entry, int *fd)
+{
+ const char *accpath;
+ acl_t acl;
+ int r;
+
+ accpath = NULL;
+
+ if (*fd < 0) {
+ accpath = archive_read_disk_entry_setup_path(a, entry, fd);
+ if (accpath == NULL)
+ return (ARCHIVE_WARN);
+ }
+
+ archive_entry_acl_clear(entry);
+
+ acl = NULL;
+
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ /* Try NFSv4 ACL first. */
+ if (*fd >= 0)
+ acl = acl_get_fd_np(*fd, ACL_TYPE_NFS4);
+ else if (!a->follow_symlinks)
+ acl = acl_get_link_np(accpath, ACL_TYPE_NFS4);
+ else
+ acl = acl_get_file(accpath, ACL_TYPE_NFS4);
+
+ /* Ignore "trivial" ACLs that just mirror the file mode. */
+ if (acl != NULL && acl_is_trivial_np(acl, &r) == 0 && r == 1) {
+ acl_free(acl);
+ acl = NULL;
+ return (ARCHIVE_OK);
+ }
+
+ if (acl != NULL) {
+ r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
+ acl_free(acl);
+ acl = NULL;
+
+ if (r != ARCHIVE_OK) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't translate NFSv4 ACLs");
+ }
+
+ return (r);
+ }
+#endif
+
+ /* Retrieve access ACL from file. */
+ if (*fd >= 0)
+ acl = acl_get_fd_np(*fd, ACL_TYPE_ACCESS);
+#if HAVE_ACL_GET_LINK_NP
+ else if (!a->follow_symlinks)
+ acl = acl_get_link_np(accpath, ACL_TYPE_ACCESS);
+#else
+ else if ((!a->follow_symlinks)
+ && (archive_entry_filetype(entry) == AE_IFLNK))
+ /* We can't get the ACL of a symlink, so we assume it can't
+ have one. */
+ acl = NULL;
+#endif
+ else
+ acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
+
+#if HAVE_ACL_IS_TRIVIAL_NP
+ /* Ignore "trivial" ACLs that just mirror the file mode. */
+ if (acl != NULL && acl_is_trivial_np(acl, &r) == 0 && r == 1) {
+ acl_free(acl);
+ acl = NULL;
+ }
+#endif
+
+ if (acl != NULL) {
+ r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
+ acl_free(acl);
+ acl = NULL;
+
+ if (r != ARCHIVE_OK) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't translate access ACLs");
+ return (r);
+ }
+ }
+
+ /* Only directories can have default ACLs. */
+ if (S_ISDIR(archive_entry_mode(entry))) {
+ if (*fd >= 0)
+ acl = acl_get_fd_np(*fd, ACL_TYPE_DEFAULT);
+ else
+ acl = acl_get_file(accpath, ACL_TYPE_DEFAULT);
+ if (acl != NULL) {
+ r = translate_acl(a, entry, acl,
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
+ acl_free(acl);
+ if (r != ARCHIVE_OK) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't translate default ACLs");
+ return (r);
+ }
+ }
+ }
+ return (ARCHIVE_OK);
+}
+
+int
+archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
+ struct archive_acl *abstract_acl, __LA_MODE_T mode)
+{
+ int ret = ARCHIVE_OK;
+
+ (void)mode; /* UNUSED */
+
+ if ((archive_acl_types(abstract_acl)
+ & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
+ if ((archive_acl_types(abstract_acl)
+ & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
+ ret = set_acl(a, fd, name, abstract_acl,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, "access");
+ if (ret != ARCHIVE_OK)
+ return (ret);
+ }
+ if ((archive_acl_types(abstract_acl)
+ & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0)
+ ret = set_acl(a, fd, name, abstract_acl,
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default");
+
+ /* Simultaneous POSIX.1e and NFSv4 is not supported */
+ return (ret);
+ }
+#if ARCHIVE_ACL_FREEBSD_NFS4
+ else if ((archive_acl_types(abstract_acl) &
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
+ ret = set_acl(a, fd, name, abstract_acl,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
+ }
+#endif
+ return (ret);
+}
+#endif /* ARCHIVE_ACL_FREEBSD */
diff --git a/Utilities/cmlibarchive/libarchive/archive_disk_acl_linux.c b/Utilities/cmlibarchive/libarchive/archive_disk_acl_linux.c
new file mode 100644
index 000000000..3928f3d6f
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_disk_acl_linux.c
@@ -0,0 +1,743 @@
+/*-
+ * Copyright (c) 2003-2009 Tim Kientzle
+ * Copyright (c) 2010-2012 Michihiro NAKAJIMA
+ * Copyright (c) 2017 Martin Matuska
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+
+#if ARCHIVE_ACL_LIBACL || ARCHIVE_ACL_LIBRICHACL
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#if HAVE_ACL_LIBACL_H
+#include <acl/libacl.h>
+#endif
+#ifdef HAVE_SYS_ACL_H
+#include <sys/acl.h>
+#endif
+#ifdef HAVE_SYS_RICHACL_H
+#include <sys/richacl.h>
+#endif
+
+#include "archive_entry.h"
+#include "archive_private.h"
+#include "archive_read_disk_private.h"
+#include "archive_write_disk_private.h"
+
+typedef struct {
+ const int a_perm; /* Libarchive permission or flag */
+ const int p_perm; /* Platform permission or flag */
+} acl_perm_map_t;
+
+#if ARCHIVE_ACL_LIBACL
+static const acl_perm_map_t acl_posix_perm_map[] = {
+ {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
+ {ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
+ {ARCHIVE_ENTRY_ACL_READ, ACL_READ},
+};
+
+static const int acl_posix_perm_map_size =
+ (int)(sizeof(acl_posix_perm_map)/sizeof(acl_posix_perm_map[0]));
+#endif /* ARCHIVE_ACL_LIBACL */
+
+#if ARCHIVE_ACL_LIBRICHACL
+static const acl_perm_map_t acl_nfs4_perm_map[] = {
+ {ARCHIVE_ENTRY_ACL_EXECUTE, RICHACE_EXECUTE},
+ {ARCHIVE_ENTRY_ACL_READ_DATA, RICHACE_READ_DATA},
+ {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, RICHACE_LIST_DIRECTORY},
+ {ARCHIVE_ENTRY_ACL_WRITE_DATA, RICHACE_WRITE_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_FILE, RICHACE_ADD_FILE},
+ {ARCHIVE_ENTRY_ACL_APPEND_DATA, RICHACE_APPEND_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, RICHACE_ADD_SUBDIRECTORY},
+ {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, RICHACE_READ_NAMED_ATTRS},
+ {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, RICHACE_WRITE_NAMED_ATTRS},
+ {ARCHIVE_ENTRY_ACL_DELETE_CHILD, RICHACE_DELETE_CHILD},
+ {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, RICHACE_READ_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, RICHACE_WRITE_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_DELETE, RICHACE_DELETE},
+ {ARCHIVE_ENTRY_ACL_READ_ACL, RICHACE_READ_ACL},
+ {ARCHIVE_ENTRY_ACL_WRITE_ACL, RICHACE_WRITE_ACL},
+ {ARCHIVE_ENTRY_ACL_WRITE_OWNER, RICHACE_WRITE_OWNER},
+ {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, RICHACE_SYNCHRONIZE}
+};
+
+static const int acl_nfs4_perm_map_size =
+ (int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));
+
+static const acl_perm_map_t acl_nfs4_flag_map[] = {
+ {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, RICHACE_FILE_INHERIT_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, RICHACE_DIRECTORY_INHERIT_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, RICHACE_NO_PROPAGATE_INHERIT_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, RICHACE_INHERIT_ONLY_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, RICHACE_INHERITED_ACE}
+};
+
+static const int acl_nfs4_flag_map_size =
+ (int)(sizeof(acl_nfs4_flag_map)/sizeof(acl_nfs4_flag_map[0]));
+#endif /* ARCHIVE_ACL_LIBRICHACL */
+
+#if ARCHIVE_ACL_LIBACL
+/*
+ * Translate POSIX.1e ACLs into libarchive internal structure
+ */
+static int
+translate_acl(struct archive_read_disk *a,
+ struct archive_entry *entry, acl_t acl, int default_entry_acl_type)
+{
+ acl_tag_t acl_tag;
+ acl_entry_t acl_entry;
+ acl_permset_t acl_permset;
+ int i, entry_acl_type;
+ int r, s, ae_id, ae_tag, ae_perm;
+ void *q;
+ const char *ae_name;
+
+ s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
+ if (s == -1) {
+ archive_set_error(&a->archive, errno,
+ "Failed to get first ACL entry");
+ return (ARCHIVE_WARN);
+ }
+
+ while (s == 1) {
+ ae_id = -1;
+ ae_name = NULL;
+ ae_perm = 0;
+
+ if (acl_get_tag_type(acl_entry, &acl_tag) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Failed to get ACL tag type");
+ return (ARCHIVE_WARN);
+ }
+ switch (acl_tag) {
+ case ACL_USER:
+ q = acl_get_qualifier(acl_entry);
+ if (q != NULL) {
+ ae_id = (int)*(uid_t *)q;
+ acl_free(q);
+ ae_name = archive_read_disk_uname(&a->archive,
+ ae_id);
+ }
+ ae_tag = ARCHIVE_ENTRY_ACL_USER;
+ break;
+ case ACL_GROUP:
+ q = acl_get_qualifier(acl_entry);
+ if (q != NULL) {
+ ae_id = (int)*(gid_t *)q;
+ acl_free(q);
+ ae_name = archive_read_disk_gname(&a->archive,
+ ae_id);
+ }
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
+ break;
+ case ACL_MASK:
+ ae_tag = ARCHIVE_ENTRY_ACL_MASK;
+ break;
+ case ACL_USER_OBJ:
+ ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+ break;
+ case ACL_GROUP_OBJ:
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+ break;
+ case ACL_OTHER:
+ ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
+ break;
+ default:
+ /* Skip types that libarchive can't support. */
+ s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
+ continue;
+ }
+
+ // XXX acl_type maps to allow/deny/audit/YYYY bits
+ entry_acl_type = default_entry_acl_type;
+
+ if (acl_get_permset(acl_entry, &acl_permset) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Failed to get ACL permission set");
+ return (ARCHIVE_WARN);
+ }
+
+ for (i = 0; i < acl_posix_perm_map_size; ++i) {
+ r = acl_get_perm(acl_permset,
+ acl_posix_perm_map[i].p_perm);
+ if (r == -1) {
+ archive_set_error(&a->archive, errno,
+ "Failed to check permission in an ACL "
+ "permission set");
+ return (ARCHIVE_WARN);
+ } else if (r)
+ ae_perm |= acl_posix_perm_map[i].a_perm;
+ }
+
+ archive_entry_acl_add_entry(entry, entry_acl_type,
+ ae_perm, ae_tag,
+ ae_id, ae_name);
+
+ s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
+ if (s == -1) {
+ archive_set_error(&a->archive, errno,
+ "Failed to get next ACL entry");
+ return (ARCHIVE_WARN);
+ }
+ }
+ return (ARCHIVE_OK);
+}
+#endif /* ARCHIVE_ACL_LIBACL */
+
+#if ARCHIVE_ACL_LIBRICHACL
+/*
+ * Translate RichACL into libarchive internal ACL
+ */
+static int
+translate_richacl(struct archive_read_disk *a, struct archive_entry *entry,
+ struct richacl *richacl)
+{
+ int ae_id, ae_tag, ae_perm;
+ int entry_acl_type, i;
+ const char *ae_name;
+
+ struct richace *richace;
+
+ richacl_for_each_entry(richace, richacl) {
+ ae_name = NULL;
+ ae_tag = 0;
+ ae_perm = 0;
+ ae_id = -1;
+
+ switch (richace->e_type) {
+ case RICHACE_ACCESS_ALLOWED_ACE_TYPE:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
+ break;
+ case RICHACE_ACCESS_DENIED_ACE_TYPE:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
+ break;
+ default: /* Unknown entry type, skip */
+ continue;
+ }
+
+ /* Unsupported */
+ if (richace->e_flags & RICHACE_UNMAPPED_WHO)
+ continue;
+
+ if (richace->e_flags & RICHACE_SPECIAL_WHO) {
+ switch (richace->e_id) {
+ case RICHACE_OWNER_SPECIAL_ID:
+ ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+ break;
+ case RICHACE_GROUP_SPECIAL_ID:
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+ break;
+ case RICHACE_EVERYONE_SPECIAL_ID:
+ ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE;
+ break;
+ default: /* Unknown special ID type */
+ continue;
+ }
+ } else {
+ ae_id = richace->e_id;
+ if (richace->e_flags & RICHACE_IDENTIFIER_GROUP) {
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
+ ae_name = archive_read_disk_gname(&a->archive,
+ (gid_t)(richace->e_id));
+ } else {
+ ae_tag = ARCHIVE_ENTRY_ACL_USER;
+ ae_name = archive_read_disk_uname(&a->archive,
+ (uid_t)(richace->e_id));
+ }
+ }
+ for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
+ if ((richace->e_flags &
+ acl_nfs4_flag_map[i].p_perm) != 0)
+ ae_perm |= acl_nfs4_flag_map[i].a_perm;
+ }
+ for (i = 0; i < acl_nfs4_perm_map_size; ++i) {
+ if ((richace->e_mask &
+ acl_nfs4_perm_map[i].p_perm) != 0)
+ ae_perm |=
+ acl_nfs4_perm_map[i].a_perm;
+ }
+
+ archive_entry_acl_add_entry(entry, entry_acl_type,
+ ae_perm, ae_tag, ae_id, ae_name);
+ }
+ return (ARCHIVE_OK);
+}
+#endif /* ARCHIVE_ACL_LIBRICHACL */
+
+#if ARCHIVE_ACL_LIBRICHACL
+static int
+_richacl_mode_to_mask(short mode)
+{
+ int mask = 0;
+
+ if (mode & S_IROTH)
+ mask |= RICHACE_POSIX_MODE_READ;
+ if (mode & S_IWOTH)
+ mask |= RICHACE_POSIX_MODE_WRITE;
+ if (mode & S_IXOTH)
+ mask |= RICHACE_POSIX_MODE_EXEC;
+
+ return (mask);
+}
+
+static void
+_richacl_mode_to_masks(struct richacl *richacl, __LA_MODE_T mode)
+{
+ richacl->a_owner_mask = _richacl_mode_to_mask((mode & 0700) >> 6);
+ richacl->a_group_mask = _richacl_mode_to_mask((mode & 0070) >> 3);
+ richacl->a_other_mask = _richacl_mode_to_mask(mode & 0007);
+}
+#endif /* ARCHIVE_ACL_LIBRICHACL */
+
+#if ARCHIVE_ACL_LIBRICHACL
+static int
+set_richacl(struct archive *a, int fd, const char *name,
+ struct archive_acl *abstract_acl, __LA_MODE_T mode,
+ int ae_requested_type, const char *tname)
+{
+ int ae_type, ae_permset, ae_tag, ae_id;
+ uid_t ae_uid;
+ gid_t ae_gid;
+ const char *ae_name;
+ int entries;
+ int i;
+ int ret;
+ int e = 0;
+ struct richacl *richacl = NULL;
+ struct richace *richace;
+
+ ret = ARCHIVE_OK;
+ entries = archive_acl_reset(abstract_acl, ae_requested_type);
+ if (entries == 0)
+ return (ARCHIVE_OK);
+
+ if (ae_requested_type != ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ errno = ENOENT;
+ archive_set_error(a, errno, "Unsupported ACL type");
+ return (ARCHIVE_FAILED);
+ }
+
+ richacl = richacl_alloc(entries);
+ if (richacl == NULL) {
+ archive_set_error(a, errno,
+ "Failed to initialize RichACL working storage");
+ return (ARCHIVE_FAILED);
+ }
+
+ e = 0;
+
+ while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
+ &ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
+ richace = &(richacl->a_entries[e]);
+
+ richace->e_flags = 0;
+ richace->e_mask = 0;
+
+ switch (ae_tag) {
+ case ARCHIVE_ENTRY_ACL_USER:
+ ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
+ richace->e_id = ae_uid;
+ break;
+ case ARCHIVE_ENTRY_ACL_GROUP:
+ ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
+ richace->e_id = ae_gid;
+ richace->e_flags |= RICHACE_IDENTIFIER_GROUP;
+ break;
+ case ARCHIVE_ENTRY_ACL_USER_OBJ:
+ richace->e_flags |= RICHACE_SPECIAL_WHO;
+ richace->e_id = RICHACE_OWNER_SPECIAL_ID;
+ break;
+ case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
+ richace->e_flags |= RICHACE_SPECIAL_WHO;
+ richace->e_id = RICHACE_GROUP_SPECIAL_ID;
+ break;
+ case ARCHIVE_ENTRY_ACL_EVERYONE:
+ richace->e_flags |= RICHACE_SPECIAL_WHO;
+ richace->e_id = RICHACE_EVERYONE_SPECIAL_ID;
+ break;
+ default:
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "Unsupported ACL tag");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+ switch (ae_type) {
+ case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
+ richace->e_type =
+ RICHACE_ACCESS_ALLOWED_ACE_TYPE;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_DENY:
+ richace->e_type =
+ RICHACE_ACCESS_DENIED_ACE_TYPE;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
+ case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
+ break;
+ default:
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "Unsupported ACL entry type");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+ for (i = 0; i < acl_nfs4_perm_map_size; ++i) {
+ if (ae_permset & acl_nfs4_perm_map[i].a_perm)
+ richace->e_mask |= acl_nfs4_perm_map[i].p_perm;
+ }
+
+ for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
+ if (ae_permset &
+ acl_nfs4_flag_map[i].a_perm)
+ richace->e_flags |= acl_nfs4_flag_map[i].p_perm;
+ }
+ e++;
+ }
+
+ /* Fill RichACL masks */
+ _richacl_mode_to_masks(richacl, mode);
+
+ if (fd >= 0) {
+ if (richacl_set_fd(fd, richacl) == 0)
+ ret = ARCHIVE_OK;
+ else {
+ if (errno == EOPNOTSUPP) {
+ /* Filesystem doesn't support ACLs */
+ ret = ARCHIVE_OK;
+ } else {
+ archive_set_error(a, errno,
+ "Failed to set richacl on fd: %s", tname);
+ ret = ARCHIVE_WARN;
+ }
+ }
+ } else if (richacl_set_file(name, richacl) != 0) {
+ if (errno == EOPNOTSUPP) {
+ /* Filesystem doesn't support ACLs */
+ ret = ARCHIVE_OK;
+ } else {
+ archive_set_error(a, errno, "Failed to set richacl: %s",
+ tname);
+ ret = ARCHIVE_WARN;
+ }
+ }
+exit_free:
+ richacl_free(richacl);
+ return (ret);
+}
+#endif /* ARCHIVE_ACL_RICHACL */
+
+#if ARCHIVE_ACL_LIBACL
+static int
+set_acl(struct archive *a, int fd, const char *name,
+ struct archive_acl *abstract_acl,
+ int ae_requested_type, const char *tname)
+{
+ int acl_type = 0;
+ int ae_type, ae_permset, ae_tag, ae_id;
+ uid_t ae_uid;
+ gid_t ae_gid;
+ const char *ae_name;
+ int entries;
+ int i;
+ int ret;
+ acl_t acl = NULL;
+ acl_entry_t acl_entry;
+ acl_permset_t acl_permset;
+
+ ret = ARCHIVE_OK;
+ entries = archive_acl_reset(abstract_acl, ae_requested_type);
+ if (entries == 0)
+ return (ARCHIVE_OK);
+
+ switch (ae_requested_type) {
+ case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
+ acl_type = ACL_TYPE_ACCESS;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
+ acl_type = ACL_TYPE_DEFAULT;
+ break;
+ default:
+ errno = ENOENT;
+ archive_set_error(a, errno, "Unsupported ACL type");
+ return (ARCHIVE_FAILED);
+ }
+
+ acl = acl_init(entries);
+ if (acl == (acl_t)NULL) {
+ archive_set_error(a, errno,
+ "Failed to initialize ACL working storage");
+ return (ARCHIVE_FAILED);
+ }
+
+ while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
+ &ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
+
+ if (acl_create_entry(&acl, &acl_entry) != 0) {
+ archive_set_error(a, errno,
+ "Failed to create a new ACL entry");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+ switch (ae_tag) {
+ case ARCHIVE_ENTRY_ACL_USER:
+ ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
+ acl_set_tag_type(acl_entry, ACL_USER);
+ acl_set_qualifier(acl_entry, &ae_uid);
+ break;
+ case ARCHIVE_ENTRY_ACL_GROUP:
+ ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
+ acl_set_tag_type(acl_entry, ACL_GROUP);
+ acl_set_qualifier(acl_entry, &ae_gid);
+ break;
+ case ARCHIVE_ENTRY_ACL_USER_OBJ:
+ acl_set_tag_type(acl_entry, ACL_USER_OBJ);
+ break;
+ case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
+ acl_set_tag_type(acl_entry, ACL_GROUP_OBJ);
+ break;
+ case ARCHIVE_ENTRY_ACL_MASK:
+ acl_set_tag_type(acl_entry, ACL_MASK);
+ break;
+ case ARCHIVE_ENTRY_ACL_OTHER:
+ acl_set_tag_type(acl_entry, ACL_OTHER);
+ break;
+ default:
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "Unsupported ACL tag");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+ if (acl_get_permset(acl_entry, &acl_permset) != 0) {
+ archive_set_error(a, errno,
+ "Failed to get ACL permission set");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+ if (acl_clear_perms(acl_permset) != 0) {
+ archive_set_error(a, errno,
+ "Failed to clear ACL permissions");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+ for (i = 0; i < acl_posix_perm_map_size; ++i) {
+ if (ae_permset & acl_posix_perm_map[i].a_perm) {
+ if (acl_add_perm(acl_permset,
+ acl_posix_perm_map[i].p_perm) != 0) {
+ archive_set_error(a, errno,
+ "Failed to add ACL permission");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+ }
+ }
+
+ }
+
+ if (fd >= 0 && ae_requested_type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) {
+ if (acl_set_fd(fd, acl) == 0)
+ ret = ARCHIVE_OK;
+ else {
+ if (errno == EOPNOTSUPP) {
+ /* Filesystem doesn't support ACLs */
+ ret = ARCHIVE_OK;
+ } else {
+ archive_set_error(a, errno,
+ "Failed to set acl on fd: %s", tname);
+ ret = ARCHIVE_WARN;
+ }
+ }
+ } else if (acl_set_file(name, acl_type, acl) != 0) {
+ if (errno == EOPNOTSUPP) {
+ /* Filesystem doesn't support ACLs */
+ ret = ARCHIVE_OK;
+ } else {
+ archive_set_error(a, errno, "Failed to set acl: %s",
+ tname);
+ ret = ARCHIVE_WARN;
+ }
+ }
+exit_free:
+ acl_free(acl);
+ return (ret);
+}
+#endif /* ARCHIVE_ACL_LIBACL */
+
+int
+archive_read_disk_entry_setup_acls(struct archive_read_disk *a,
+ struct archive_entry *entry, int *fd)
+{
+ const char *accpath;
+ int r;
+#if ARCHIVE_ACL_LIBACL
+ acl_t acl;
+#endif
+#if ARCHIVE_ACL_LIBRICHACL
+ struct richacl *richacl;
+ mode_t mode;
+#endif
+
+ accpath = NULL;
+ r = ARCHIVE_OK;
+
+ /* For default ACLs we need reachable accpath */
+ if (*fd < 0 || S_ISDIR(archive_entry_mode(entry))) {
+ accpath = archive_read_disk_entry_setup_path(a, entry, fd);
+ if (accpath == NULL)
+ return (ARCHIVE_WARN);
+ }
+
+ archive_entry_acl_clear(entry);
+
+#if ARCHIVE_ACL_LIBACL
+ acl = NULL;
+#endif
+#if ARCHIVE_ACL_LIBRICHACL
+ richacl = NULL;
+#endif
+
+#if ARCHIVE_ACL_LIBRICHACL
+ /* Try NFSv4 ACL first. */
+ if (*fd >= 0)
+ richacl = richacl_get_fd(*fd);
+ else if ((!a->follow_symlinks)
+ && (archive_entry_filetype(entry) == AE_IFLNK))
+ /* We can't get the ACL of a symlink, so we assume it can't
+ have one */
+ richacl = NULL;
+ else
+ richacl = richacl_get_file(accpath);
+
+ /* Ignore "trivial" ACLs that just mirror the file mode. */
+ if (richacl != NULL) {
+ mode = archive_entry_mode(entry);
+ if (richacl_equiv_mode(richacl, &mode) == 0) {
+ richacl_free(richacl);
+ richacl = NULL;
+ return (ARCHIVE_OK);
+ }
+ }
+
+ if (richacl != NULL) {
+ r = translate_richacl(a, entry, richacl);
+ richacl_free(richacl);
+ richacl = NULL;
+
+ if (r != ARCHIVE_OK) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't translate NFSv4 ACLs");
+ }
+
+ return (r);
+ }
+#endif /* ARCHIVE_ACL_LIBRICHACL */
+
+#if ARCHIVE_ACL_LIBACL
+ /* Retrieve access ACL from file. */
+ if (*fd >= 0)
+ acl = acl_get_fd(*fd);
+ else if ((!a->follow_symlinks)
+ && (archive_entry_filetype(entry) == AE_IFLNK))
+ /* We can't get the ACL of a symlink, so we assume it can't
+ have one. */
+ acl = NULL;
+ else
+ acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
+
+ if (acl != NULL) {
+ r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
+ acl_free(acl);
+ acl = NULL;
+
+ if (r != ARCHIVE_OK) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't translate access ACLs");
+ return (r);
+ }
+ }
+
+ /* Only directories can have default ACLs. */
+ if (S_ISDIR(archive_entry_mode(entry))) {
+ acl = acl_get_file(accpath, ACL_TYPE_DEFAULT);
+ if (acl != NULL) {
+ r = translate_acl(a, entry, acl,
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
+ acl_free(acl);
+ if (r != ARCHIVE_OK) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't translate default ACLs");
+ return (r);
+ }
+ }
+ }
+#endif /* ARCHIVE_ACL_LIBACL */
+ return (r);
+}
+
+int
+archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
+ struct archive_acl *abstract_acl, __LA_MODE_T mode)
+{
+ int ret = ARCHIVE_OK;
+
+#if !ARCHIVE_ACL_LIBRICHACL
+ (void)mode; /* UNUSED */
+#endif
+
+#if ARCHIVE_ACL_LIBRICHACL
+ if ((archive_acl_types(abstract_acl)
+ & ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
+ ret = set_richacl(a, fd, name, abstract_acl, mode,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
+ }
+#if ARCHIVE_ACL_LIBACL
+ else
+#endif
+#endif /* ARCHIVE_ACL_LIBRICHACL */
+#if ARCHIVE_ACL_LIBACL
+ if ((archive_acl_types(abstract_acl)
+ & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
+ if ((archive_acl_types(abstract_acl)
+ & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
+ ret = set_acl(a, fd, name, abstract_acl,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, "access");
+ if (ret != ARCHIVE_OK)
+ return (ret);
+ }
+ if ((archive_acl_types(abstract_acl)
+ & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0)
+ ret = set_acl(a, fd, name, abstract_acl,
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default");
+ }
+#endif /* ARCHIVE_ACL_LIBACL */
+ return (ret);
+}
+#endif /* ARCHIVE_ACL_LIBACL || ARCHIVE_ACL_LIBRICHACL */
diff --git a/Utilities/cmlibarchive/libarchive/archive_disk_acl_sunos.c b/Utilities/cmlibarchive/libarchive/archive_disk_acl_sunos.c
new file mode 100644
index 000000000..bc84fd678
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_disk_acl_sunos.c
@@ -0,0 +1,821 @@
+/*-
+ * Copyright (c) 2017 Martin Matuska
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+
+#if ARCHIVE_ACL_SUNOS
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_ACL_H
+#define _ACL_PRIVATE /* For debugging */
+#include <sys/acl.h>
+#endif
+
+#include "archive_entry.h"
+#include "archive_private.h"
+#include "archive_read_disk_private.h"
+#include "archive_write_disk_private.h"
+
+typedef struct {
+ const int a_perm; /* Libarchive permission or flag */
+ const int p_perm; /* Platform permission or flag */
+} acl_perm_map_t;
+
+static const acl_perm_map_t acl_posix_perm_map[] = {
+ {ARCHIVE_ENTRY_ACL_EXECUTE, S_IXOTH },
+ {ARCHIVE_ENTRY_ACL_WRITE, S_IWOTH },
+ {ARCHIVE_ENTRY_ACL_READ, S_IROTH }
+};
+
+static const int acl_posix_perm_map_size =
+ (int)(sizeof(acl_posix_perm_map)/sizeof(acl_posix_perm_map[0]));
+
+#if ARCHIVE_ACL_SUNOS_NFS4
+static const acl_perm_map_t acl_nfs4_perm_map[] = {
+ {ARCHIVE_ENTRY_ACL_EXECUTE, ACE_EXECUTE},
+ {ARCHIVE_ENTRY_ACL_READ_DATA, ACE_READ_DATA},
+ {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACE_LIST_DIRECTORY},
+ {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACE_WRITE_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_FILE, ACE_ADD_FILE},
+ {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACE_APPEND_DATA},
+ {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACE_ADD_SUBDIRECTORY},
+ {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACE_READ_NAMED_ATTRS},
+ {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACE_WRITE_NAMED_ATTRS},
+ {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACE_DELETE_CHILD},
+ {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACE_READ_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACE_WRITE_ATTRIBUTES},
+ {ARCHIVE_ENTRY_ACL_DELETE, ACE_DELETE},
+ {ARCHIVE_ENTRY_ACL_READ_ACL, ACE_READ_ACL},
+ {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACE_WRITE_ACL},
+ {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACE_WRITE_OWNER},
+ {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACE_SYNCHRONIZE}
+};
+
+static const int acl_nfs4_perm_map_size =
+ (int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));
+
+static const acl_perm_map_t acl_nfs4_flag_map[] = {
+ {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACE_FILE_INHERIT_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACE_DIRECTORY_INHERIT_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACE_NO_PROPAGATE_INHERIT_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACE_INHERIT_ONLY_ACE},
+ {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACE_SUCCESSFUL_ACCESS_ACE_FLAG},
+ {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACE_FAILED_ACCESS_ACE_FLAG},
+#ifdef ACE_INHERITED_ACE
+ {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACE_INHERITED_ACE}
+#endif
+};
+
+const int acl_nfs4_flag_map_size =
+ (int)(sizeof(acl_nfs4_flag_map)/sizeof(acl_nfs4_flag_map[0]));
+
+#endif /* ARCHIVE_ACL_SUNOS_NFS4 */
+
+static void *
+sunacl_get(int cmd, int *aclcnt, int fd, const char *path)
+{
+ int cnt, cntcmd;
+ size_t size;
+ void *aclp;
+
+ if (cmd == GETACL) {
+ cntcmd = GETACLCNT;
+ size = sizeof(aclent_t);
+ }
+#if ARCHIVE_ACL_SUNOS_NFS4
+ else if (cmd == ACE_GETACL) {
+ cntcmd = ACE_GETACLCNT;
+ size = sizeof(ace_t);
+ }
+#endif
+ else {
+ errno = EINVAL;
+ *aclcnt = -1;
+ return (NULL);
+ }
+
+ aclp = NULL;
+ cnt = -2;
+
+ while (cnt == -2 || (cnt == -1 && errno == ENOSPC)) {
+ if (path != NULL)
+ cnt = acl(path, cntcmd, 0, NULL);
+ else
+ cnt = facl(fd, cntcmd, 0, NULL);
+
+ if (cnt > 0) {
+ if (aclp == NULL)
+ aclp = malloc(cnt * size);
+ else
+ aclp = realloc(NULL, cnt * size);
+ if (aclp != NULL) {
+ if (path != NULL)
+ cnt = acl(path, cmd, cnt, aclp);
+ else
+ cnt = facl(fd, cmd, cnt, aclp);
+ }
+ } else {
+ if (aclp != NULL) {
+ free(aclp);
+ aclp = NULL;
+ }
+ break;
+ }
+ }
+
+ *aclcnt = cnt;
+ return (aclp);
+}
+
+/*
+ * Check if acl is trivial
+ * This is a FreeBSD acl_is_trivial_np() implementation for Solaris
+ */
+static int
+sun_acl_is_trivial(void *aclp, int aclcnt, mode_t mode, int is_nfs4,
+ int is_dir, int *trivialp)
+{
+#if ARCHIVE_ACL_SUNOS_NFS4
+ int i, p;
+ const uint32_t rperm = ACE_READ_DATA;
+ const uint32_t wperm = ACE_WRITE_DATA | ACE_APPEND_DATA;
+ const uint32_t eperm = ACE_EXECUTE;
+ const uint32_t pubset = ACE_READ_ATTRIBUTES | ACE_READ_NAMED_ATTRS |
+ ACE_READ_ACL | ACE_SYNCHRONIZE;
+ const uint32_t ownset = pubset | ACE_WRITE_ATTRIBUTES |
+ ACE_WRITE_NAMED_ATTRS | ACE_WRITE_ACL | ACE_WRITE_OWNER;
+
+ ace_t *ace;
+ ace_t tace[6];
+#endif
+
+ if (aclp == NULL || trivialp == NULL)
+ return (-1);
+
+ *trivialp = 0;
+
+ /*
+ * POSIX.1e ACLs marked with ACL_IS_TRIVIAL are compatible with
+ * FreeBSD acl_is_trivial_np(). On Solaris they have 4 entries,
+ * including mask.
+ */
+ if (!is_nfs4) {
+ if (aclcnt == 4)
+ *trivialp = 1;
+ return (0);
+ }
+
+#if ARCHIVE_ACL_SUNOS_NFS4
+ /*
+ * Continue with checking NFSv4 ACLs
+ *
+ * Create list of trivial ace's to be compared
+ */
+
+ /* owner@ allow pre */
+ tace[0].a_flags = ACE_OWNER;
+ tace[0].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
+ tace[0].a_access_mask = 0;
+
+ /* owner@ deny */
+ tace[1].a_flags = ACE_OWNER;
+ tace[1].a_type = ACE_ACCESS_DENIED_ACE_TYPE;
+ tace[1].a_access_mask = 0;
+
+ /* group@ deny */
+ tace[2].a_flags = ACE_GROUP | ACE_IDENTIFIER_GROUP;
+ tace[2].a_type = ACE_ACCESS_DENIED_ACE_TYPE;
+ tace[2].a_access_mask = 0;
+
+ /* owner@ allow */
+ tace[3].a_flags = ACE_OWNER;
+ tace[3].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
+ tace[3].a_access_mask = ownset;
+
+ /* group@ allow */
+ tace[4].a_flags = ACE_GROUP | ACE_IDENTIFIER_GROUP;
+ tace[4].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
+ tace[4].a_access_mask = pubset;
+
+ /* everyone@ allow */
+ tace[5].a_flags = ACE_EVERYONE;
+ tace[5].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
+ tace[5].a_access_mask = pubset;
+
+ /* Permissions for everyone@ */
+ if (mode & 0004)
+ tace[5].a_access_mask |= rperm;
+ if (mode & 0002)
+ tace[5].a_access_mask |= wperm;
+ if (mode & 0001)
+ tace[5].a_access_mask |= eperm;
+
+ /* Permissions for group@ */
+ if (mode & 0040)
+ tace[4].a_access_mask |= rperm;
+ else if (mode & 0004)
+ tace[2].a_access_mask |= rperm;
+ if (mode & 0020)
+ tace[4].a_access_mask |= wperm;
+ else if (mode & 0002)
+ tace[2].a_access_mask |= wperm;
+ if (mode & 0010)
+ tace[4].a_access_mask |= eperm;
+ else if (mode & 0001)
+ tace[2].a_access_mask |= eperm;
+
+ /* Permissions for owner@ */
+ if (mode & 0400) {
+ tace[3].a_access_mask |= rperm;
+ if (!(mode & 0040) && (mode & 0004))
+ tace[0].a_access_mask |= rperm;
+ } else if ((mode & 0040) || (mode & 0004))
+ tace[1].a_access_mask |= rperm;
+ if (mode & 0200) {
+ tace[3].a_access_mask |= wperm;
+ if (!(mode & 0020) && (mode & 0002))
+ tace[0].a_access_mask |= wperm;
+ } else if ((mode & 0020) || (mode & 0002))
+ tace[1].a_access_mask |= wperm;
+ if (mode & 0100) {
+ tace[3].a_access_mask |= eperm;
+ if (!(mode & 0010) && (mode & 0001))
+ tace[0].a_access_mask |= eperm;
+ } else if ((mode & 0010) || (mode & 0001))
+ tace[1].a_access_mask |= eperm;
+
+ /* Check if the acl count matches */
+ p = 3;
+ for (i = 0; i < 3; i++) {
+ if (tace[i].a_access_mask != 0)
+ p++;
+ }
+ if (aclcnt != p)
+ return (0);
+
+ p = 0;
+ for (i = 0; i < 6; i++) {
+ if (tace[i].a_access_mask != 0) {
+ ace = &((ace_t *)aclp)[p];
+ /*
+ * Illumos added ACE_DELETE_CHILD to write perms for
+ * directories. We have to check against that, too.
+ */
+ if (ace->a_flags != tace[i].a_flags ||
+ ace->a_type != tace[i].a_type ||
+ (ace->a_access_mask != tace[i].a_access_mask &&
+ (!is_dir || (tace[i].a_access_mask & wperm) == 0 ||
+ ace->a_access_mask !=
+ (tace[i].a_access_mask | ACE_DELETE_CHILD))))
+ return (0);
+ p++;
+ }
+ }
+
+ *trivialp = 1;
+#else /* !ARCHIVE_ACL_SUNOS_NFS4 */
+ (void)is_dir; /* UNUSED */
+ (void)aclp; /* UNUSED */
+#endif /* !ARCHIVE_ACL_SUNOS_NFS4 */
+ return (0);
+}
+
+/*
+ * Translate Solaris POSIX.1e and NFSv4 ACLs into libarchive internal ACL
+ */
+static int
+translate_acl(struct archive_read_disk *a,
+ struct archive_entry *entry, void *aclp, int aclcnt,
+ int default_entry_acl_type)
+{
+ int e, i;
+ int ae_id, ae_tag, ae_perm;
+ int entry_acl_type;
+ const char *ae_name;
+ aclent_t *aclent;
+#if ARCHIVE_ACL_SUNOS_NFS4
+ ace_t *ace;
+#endif
+
+ if (aclcnt <= 0)
+ return (ARCHIVE_OK);
+
+ for (e = 0; e < aclcnt; e++) {
+ ae_name = NULL;
+ ae_tag = 0;
+ ae_perm = 0;
+
+#if ARCHIVE_ACL_SUNOS_NFS4
+ if (default_entry_acl_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ ace = &((ace_t *)aclp)[e];
+ ae_id = ace->a_who;
+
+ switch(ace->a_type) {
+ case ACE_ACCESS_ALLOWED_ACE_TYPE:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
+ break;
+ case ACE_ACCESS_DENIED_ACE_TYPE:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
+ break;
+ case ACE_SYSTEM_AUDIT_ACE_TYPE:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
+ break;
+ case ACE_SYSTEM_ALARM_ACE_TYPE:
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALARM;
+ break;
+ default:
+ /* Unknown entry type, skip */
+ continue;
+ }
+
+ if ((ace->a_flags & ACE_OWNER) != 0)
+ ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+ else if ((ace->a_flags & ACE_GROUP) != 0)
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+ else if ((ace->a_flags & ACE_EVERYONE) != 0)
+ ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE;
+ else if ((ace->a_flags & ACE_IDENTIFIER_GROUP) != 0) {
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
+ ae_name = archive_read_disk_gname(&a->archive,
+ ae_id);
+ } else {
+ ae_tag = ARCHIVE_ENTRY_ACL_USER;
+ ae_name = archive_read_disk_uname(&a->archive,
+ ae_id);
+ }
+
+ for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
+ if ((ace->a_flags &
+ acl_nfs4_flag_map[i].p_perm) != 0)
+ ae_perm |= acl_nfs4_flag_map[i].a_perm;
+ }
+
+ for (i = 0; i < acl_nfs4_perm_map_size; ++i) {
+ if ((ace->a_access_mask &
+ acl_nfs4_perm_map[i].p_perm) != 0)
+ ae_perm |= acl_nfs4_perm_map[i].a_perm;
+ }
+ } else
+#endif /* ARCHIVE_ACL_SUNOS_NFS4 */
+ if (default_entry_acl_type == ARCHIVE_ENTRY_ACL_TYPE_ACCESS) {
+ aclent = &((aclent_t *)aclp)[e];
+ if ((aclent->a_type & ACL_DEFAULT) != 0)
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
+ else
+ entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
+ ae_id = aclent->a_id;
+
+ switch(aclent->a_type) {
+ case DEF_USER:
+ case USER:
+ ae_name = archive_read_disk_uname(&a->archive,
+ ae_id);
+ ae_tag = ARCHIVE_ENTRY_ACL_USER;
+ break;
+ case DEF_GROUP:
+ case GROUP:
+ ae_name = archive_read_disk_gname(&a->archive,
+ ae_id);
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
+ break;
+ case DEF_CLASS_OBJ:
+ case CLASS_OBJ:
+ ae_tag = ARCHIVE_ENTRY_ACL_MASK;
+ break;
+ case DEF_USER_OBJ:
+ case USER_OBJ:
+ ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+ break;
+ case DEF_GROUP_OBJ:
+ case GROUP_OBJ:
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+ break;
+ case DEF_OTHER_OBJ:
+ case OTHER_OBJ:
+ ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
+ break;
+ default:
+ /* Unknown tag type, skip */
+ continue;
+ }
+
+ for (i = 0; i < acl_posix_perm_map_size; ++i) {
+ if ((aclent->a_perm &
+ acl_posix_perm_map[i].p_perm) != 0)
+ ae_perm |= acl_posix_perm_map[i].a_perm;
+ }
+ } else
+ return (ARCHIVE_WARN);
+
+ archive_entry_acl_add_entry(entry, entry_acl_type,
+ ae_perm, ae_tag, ae_id, ae_name);
+ }
+ return (ARCHIVE_OK);
+}
+
+static int
+set_acl(struct archive *a, int fd, const char *name,
+ struct archive_acl *abstract_acl,
+ int ae_requested_type, const char *tname)
+{
+ aclent_t *aclent;
+#if ARCHIVE_ACL_SUNOS_NFS4
+ ace_t *ace;
+#endif
+ int cmd, e, r;
+ void *aclp;
+ int ret;
+ int ae_type, ae_permset, ae_tag, ae_id;
+ int perm_map_size;
+ const acl_perm_map_t *perm_map;
+ uid_t ae_uid;
+ gid_t ae_gid;
+ const char *ae_name;
+ int entries;
+ int i;
+
+ ret = ARCHIVE_OK;
+ entries = archive_acl_reset(abstract_acl, ae_requested_type);
+ if (entries == 0)
+ return (ARCHIVE_OK);
+
+
+ switch (ae_requested_type) {
+ case ARCHIVE_ENTRY_ACL_TYPE_POSIX1E:
+ cmd = SETACL;
+ aclp = malloc(entries * sizeof(aclent_t));
+ break;
+#if ARCHIVE_ACL_SUNOS_NFS4
+ case ARCHIVE_ENTRY_ACL_TYPE_NFS4:
+ cmd = ACE_SETACL;
+ aclp = malloc(entries * sizeof(ace_t));
+
+ break;
+#endif
+ default:
+ errno = ENOENT;
+ archive_set_error(a, errno, "Unsupported ACL type");
+ return (ARCHIVE_FAILED);
+ }
+
+ if (aclp == NULL) {
+ archive_set_error(a, errno,
+ "Can't allocate memory for acl buffer");
+ return (ARCHIVE_FAILED);
+ }
+
+ e = 0;
+
+ while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
+ &ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
+ aclent = NULL;
+#if ARCHIVE_ACL_SUNOS_NFS4
+ ace = NULL;
+#endif
+ if (cmd == SETACL) {
+ aclent = &((aclent_t *)aclp)[e];
+ aclent->a_id = -1;
+ aclent->a_type = 0;
+ aclent->a_perm = 0;
+ }
+#if ARCHIVE_ACL_SUNOS_NFS4
+ else { /* cmd == ACE_SETACL */
+ ace = &((ace_t *)aclp)[e];
+ ace->a_who = -1;
+ ace->a_access_mask = 0;
+ ace->a_flags = 0;
+ }
+#endif /* ARCHIVE_ACL_SUNOS_NFS4 */
+
+ switch (ae_tag) {
+ case ARCHIVE_ENTRY_ACL_USER:
+ ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
+ if (aclent != NULL) {
+ aclent->a_id = ae_uid;
+ aclent->a_type |= USER;
+ }
+#if ARCHIVE_ACL_SUNOS_NFS4
+ else {
+ ace->a_who = ae_uid;
+ }
+#endif
+ break;
+ case ARCHIVE_ENTRY_ACL_GROUP:
+ ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
+ if (aclent != NULL) {
+ aclent->a_id = ae_gid;
+ aclent->a_type |= GROUP;
+ }
+#if ARCHIVE_ACL_SUNOS_NFS4
+ else {
+ ace->a_who = ae_gid;
+ ace->a_flags |= ACE_IDENTIFIER_GROUP;
+ }
+#endif
+ break;
+ case ARCHIVE_ENTRY_ACL_USER_OBJ:
+ if (aclent != NULL)
+ aclent->a_type |= USER_OBJ;
+#if ARCHIVE_ACL_SUNOS_NFS4
+ else {
+ ace->a_flags |= ACE_OWNER;
+ }
+#endif
+ break;
+ case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
+ if (aclent != NULL)
+ aclent->a_type |= GROUP_OBJ;
+#if ARCHIVE_ACL_SUNOS_NFS4
+ else {
+ ace->a_flags |= ACE_GROUP;
+ ace->a_flags |= ACE_IDENTIFIER_GROUP;
+ }
+#endif
+ break;
+ case ARCHIVE_ENTRY_ACL_MASK:
+ if (aclent != NULL)
+ aclent->a_type |= CLASS_OBJ;
+ break;
+ case ARCHIVE_ENTRY_ACL_OTHER:
+ if (aclent != NULL)
+ aclent->a_type |= OTHER_OBJ;
+ break;
+#if ARCHIVE_ACL_SUNOS_NFS4
+ case ARCHIVE_ENTRY_ACL_EVERYONE:
+ if (ace != NULL)
+ ace->a_flags |= ACE_EVERYONE;
+ break;
+#endif
+ default:
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "Unsupported ACL tag");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+ r = 0;
+ switch (ae_type) {
+#if ARCHIVE_ACL_SUNOS_NFS4
+ case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
+ if (ace != NULL)
+ ace->a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
+ else
+ r = -1;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_DENY:
+ if (ace != NULL)
+ ace->a_type = ACE_ACCESS_DENIED_ACE_TYPE;
+ else
+ r = -1;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
+ if (ace != NULL)
+ ace->a_type = ACE_SYSTEM_AUDIT_ACE_TYPE;
+ else
+ r = -1;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
+ if (ace != NULL)
+ ace->a_type = ACE_SYSTEM_ALARM_ACE_TYPE;
+ else
+ r = -1;
+ break;
+#endif
+ case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
+ if (aclent == NULL)
+ r = -1;
+ break;
+ case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
+ if (aclent != NULL)
+ aclent->a_type |= ACL_DEFAULT;
+ else
+ r = -1;
+ break;
+ default:
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "Unsupported ACL entry type");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+ if (r != 0) {
+ errno = EINVAL;
+ archive_set_error(a, errno,
+ "Failed to set ACL entry type");
+ ret = ARCHIVE_FAILED;
+ goto exit_free;
+ }
+
+#if ARCHIVE_ACL_SUNOS_NFS4
+ if (ae_requested_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ perm_map_size = acl_nfs4_perm_map_size;
+ perm_map = acl_nfs4_perm_map;
+ } else {
+#endif
+ perm_map_size = acl_posix_perm_map_size;
+ perm_map = acl_posix_perm_map;
+#if ARCHIVE_ACL_SUNOS_NFS4
+ }
+#endif
+ for (i = 0; i < perm_map_size; ++i) {
+ if (ae_permset & perm_map[i].a_perm) {
+#if ARCHIVE_ACL_SUNOS_NFS4
+ if (ae_requested_type ==
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4)
+ ace->a_access_mask |=
+ perm_map[i].p_perm;
+ else
+#endif
+ aclent->a_perm |= perm_map[i].p_perm;
+ }
+ }
+
+#if ARCHIVE_ACL_SUNOS_NFS4
+ if (ae_requested_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+ for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
+ if (ae_permset & acl_nfs4_flag_map[i].a_perm) {
+ ace->a_flags |=
+ acl_nfs4_flag_map[i].p_perm;
+ }
+ }
+ }
+#endif
+ e++;
+ }
+
+ /* Try restoring the ACL through 'fd' if we can. */
+ if (fd >= 0) {
+ if (facl(fd, cmd, entries, aclp) == 0)
+ ret = ARCHIVE_OK;
+ else {
+ if (errno == EOPNOTSUPP) {
+ /* Filesystem doesn't support ACLs */
+ ret = ARCHIVE_OK;
+ } else {
+ archive_set_error(a, errno,
+ "Failed to set acl on fd: %s", tname);
+ ret = ARCHIVE_WARN;
+ }
+ }
+ } else if (acl(name, cmd, entries, aclp) != 0) {
+ if (errno == EOPNOTSUPP) {
+ /* Filesystem doesn't support ACLs */
+ ret = ARCHIVE_OK;
+ } else {
+ archive_set_error(a, errno, "Failed to set acl: %s",
+ tname);
+ ret = ARCHIVE_WARN;
+ }
+ }
+exit_free:
+ free(aclp);
+ return (ret);
+}
+
+int
+archive_read_disk_entry_setup_acls(struct archive_read_disk *a,
+ struct archive_entry *entry, int *fd)
+{
+ const char *accpath;
+ void *aclp;
+ int aclcnt;
+ int r;
+
+ accpath = NULL;
+
+ if (*fd < 0) {
+ accpath = archive_read_disk_entry_setup_path(a, entry, fd);
+ if (accpath == NULL)
+ return (ARCHIVE_WARN);
+ }
+
+ archive_entry_acl_clear(entry);
+
+ aclp = NULL;
+
+#if ARCHIVE_ACL_SUNOS_NFS4
+ if (*fd >= 0)
+ aclp = sunacl_get(ACE_GETACL, &aclcnt, *fd, NULL);
+ else if ((!a->follow_symlinks)
+ && (archive_entry_filetype(entry) == AE_IFLNK))
+ /* We can't get the ACL of a symlink, so we assume it can't
+ have one. */
+ aclp = NULL;
+ else
+ aclp = sunacl_get(ACE_GETACL, &aclcnt, 0, accpath);
+
+ if (aclp != NULL && sun_acl_is_trivial(aclp, aclcnt,
+ archive_entry_mode(entry), 1, S_ISDIR(archive_entry_mode(entry)),
+ &r) == 0 && r == 1) {
+ free(aclp);
+ aclp = NULL;
+ return (ARCHIVE_OK);
+ }
+
+ if (aclp != NULL) {
+ r = translate_acl(a, entry, aclp, aclcnt,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4);
+ free(aclp);
+ aclp = NULL;
+
+ if (r != ARCHIVE_OK) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't translate NFSv4 ACLs");
+ }
+ return (r);
+ }
+#endif /* ARCHIVE_ACL_SUNOS_NFS4 */
+
+ /* Retrieve POSIX.1e ACLs from file. */
+ if (*fd >= 0)
+ aclp = sunacl_get(GETACL, &aclcnt, *fd, NULL);
+ else if ((!a->follow_symlinks)
+ && (archive_entry_filetype(entry) == AE_IFLNK))
+ /* We can't get the ACL of a symlink, so we assume it can't
+ have one. */
+ aclp = NULL;
+ else
+ aclp = sunacl_get(GETACL, &aclcnt, 0, accpath);
+
+ /* Ignore "trivial" ACLs that just mirror the file mode. */
+ if (aclp != NULL && sun_acl_is_trivial(aclp, aclcnt,
+ archive_entry_mode(entry), 0, S_ISDIR(archive_entry_mode(entry)),
+ &r) == 0 && r == 1) {
+ free(aclp);
+ aclp = NULL;
+ }
+
+ if (aclp != NULL)
+ {
+ r = translate_acl(a, entry, aclp, aclcnt,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
+ free(aclp);
+ aclp = NULL;
+
+ if (r != ARCHIVE_OK) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't translate access ACLs");
+ return (r);
+ }
+ }
+
+ return (ARCHIVE_OK);
+}
+
+int
+archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
+ struct archive_acl *abstract_acl, __LA_MODE_T mode)
+{
+ int ret = ARCHIVE_OK;
+
+ (void)mode; /* UNUSED */
+
+ if ((archive_acl_types(abstract_acl)
+ & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
+ /* Solaris writes POSIX.1e access and default ACLs together */
+ ret = set_acl(a, fd, name, abstract_acl,
+ ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, "posix1e");
+
+ /* Simultaneous POSIX.1e and NFSv4 is not supported */
+ return (ret);
+ }
+#if ARCHIVE_ACL_SUNOS_NFS4
+ else if ((archive_acl_types(abstract_acl) &
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
+ ret = set_acl(a, fd, name, abstract_acl,
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
+ }
+#endif
+ return (ret);
+}
+#endif /* ARCHIVE_ACL_SUNOS */
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.3 b/Utilities/cmlibarchive/libarchive/archive_entry.3
index f5e22af85..f75916c9e 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry.3
+++ b/Utilities/cmlibarchive/libarchive/archive_entry.3
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd Feburary 2, 2012
+.Dd February 2, 2012
.Dt ARCHIVE_ENTRY 3
.Os
.Sh NAME
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.c b/Utilities/cmlibarchive/libarchive/archive_entry.c
index 10eff11b2..f722bbe85 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry.c
+++ b/Utilities/cmlibarchive/libarchive/archive_entry.c
@@ -401,7 +401,7 @@ archive_entry_fflags_text(struct archive_entry *entry)
return (NULL);
}
-int64_t
+la_int64_t
archive_entry_gid(struct archive_entry *entry)
{
return (entry->ae_stat.aest_gid);
@@ -502,7 +502,7 @@ _archive_entry_hardlink_l(struct archive_entry *entry,
return (archive_mstring_get_mbs_l(&entry->ae_hardlink, p, len, sc));
}
-int64_t
+la_int64_t
archive_entry_ino(struct archive_entry *entry)
{
return (entry->ae_stat.aest_ino);
@@ -514,7 +514,7 @@ archive_entry_ino_is_set(struct archive_entry *entry)
return (entry->ae_set & AE_SET_INO);
}
-int64_t
+la_int64_t
archive_entry_ino64(struct archive_entry *entry)
{
return (entry->ae_stat.aest_ino);
@@ -627,7 +627,7 @@ archive_entry_rdevminor(struct archive_entry *entry)
return minor(entry->ae_stat.aest_rdev);
}
-int64_t
+la_int64_t
archive_entry_size(struct archive_entry *entry)
{
return (entry->ae_stat.aest_size);
@@ -715,7 +715,7 @@ _archive_entry_symlink_l(struct archive_entry *entry,
return (archive_mstring_get_mbs_l( &entry->ae_symlink, p, len, sc));
}
-int64_t
+la_int64_t
archive_entry_uid(struct archive_entry *entry)
{
return (entry->ae_stat.aest_uid);
@@ -819,7 +819,7 @@ archive_entry_copy_fflags_text_w(struct archive_entry *entry,
}
void
-archive_entry_set_gid(struct archive_entry *entry, int64_t g)
+archive_entry_set_gid(struct archive_entry *entry, la_int64_t g)
{
entry->stat_valid = 0;
entry->ae_stat.aest_gid = g;
@@ -868,7 +868,7 @@ _archive_entry_copy_gname_l(struct archive_entry *entry,
}
void
-archive_entry_set_ino(struct archive_entry *entry, int64_t ino)
+archive_entry_set_ino(struct archive_entry *entry, la_int64_t ino)
{
entry->stat_valid = 0;
entry->ae_set |= AE_SET_INO;
@@ -876,7 +876,7 @@ archive_entry_set_ino(struct archive_entry *entry, int64_t ino)
}
void
-archive_entry_set_ino64(struct archive_entry *entry, int64_t ino)
+archive_entry_set_ino64(struct archive_entry *entry, la_int64_t ino)
{
entry->stat_valid = 0;
entry->ae_set |= AE_SET_INO;
@@ -1209,7 +1209,7 @@ archive_entry_set_rdevminor(struct archive_entry *entry, dev_t m)
}
void
-archive_entry_set_size(struct archive_entry *entry, int64_t s)
+archive_entry_set_size(struct archive_entry *entry, la_int64_t s)
{
entry->stat_valid = 0;
entry->ae_stat.aest_size = s;
@@ -1306,7 +1306,7 @@ _archive_entry_copy_symlink_l(struct archive_entry *entry,
}
void
-archive_entry_set_uid(struct archive_entry *entry, int64_t u)
+archive_entry_set_uid(struct archive_entry *entry, la_int64_t u)
{
entry->stat_valid = 0;
entry->ae_stat.aest_uid = u;
@@ -1491,7 +1491,7 @@ archive_entry_acl_next(struct archive_entry *entry, int want_type, int *type,
* the style of the generated ACL.
*/
wchar_t *
-archive_entry_acl_to_text_w(struct archive_entry *entry, ssize_t *len,
+archive_entry_acl_to_text_w(struct archive_entry *entry, la_ssize_t *len,
int flags)
{
return (archive_acl_to_text_w(&entry->acl, len, flags,
@@ -1499,7 +1499,7 @@ archive_entry_acl_to_text_w(struct archive_entry *entry, ssize_t *len,
}
char *
-archive_entry_acl_to_text(struct archive_entry *entry, ssize_t *len,
+archive_entry_acl_to_text(struct archive_entry *entry, la_ssize_t *len,
int flags)
{
return (archive_acl_to_text_l(&entry->acl, len, flags, NULL));
@@ -1638,7 +1638,7 @@ _archive_entry_acl_text_l(struct archive_entry *entry, int flags,
* SUCH DAMAGE.
*/
-static struct flag {
+static const struct flag {
const char *name;
const wchar_t *wname;
unsigned long set;
@@ -1708,6 +1708,9 @@ static struct flag {
#ifdef UF_COMPRESSED
{ "nocompressed",L"nocompressed", UF_COMPRESSED, 0 },
#endif
+#ifdef UF_HIDDEN
+ { "nohidden", L"nohidden", UF_HIDDEN, 0 },
+#endif
#if defined(FS_UNRM_FL)
{ "nouunlink", L"nouunlink", FS_UNRM_FL, 0},
#elif defined(EXT2_UNRM_FL)
@@ -1840,7 +1843,7 @@ ae_fflagstostr(unsigned long bitset, unsigned long bitclear)
char *string, *dp;
const char *sp;
unsigned long bits;
- struct flag *flag;
+ const struct flag *flag;
size_t length;
bits = bitset | bitclear;
@@ -1892,7 +1895,7 @@ static const char *
ae_strtofflags(const char *s, unsigned long *setp, unsigned long *clrp)
{
const char *start, *end;
- struct flag *flag;
+ const struct flag *flag;
unsigned long set, clear;
const char *failed;
@@ -1960,7 +1963,7 @@ static const wchar_t *
ae_wcstofflags(const wchar_t *s, unsigned long *setp, unsigned long *clrp)
{
const wchar_t *start, *end;
- struct flag *flag;
+ const struct flag *flag;
unsigned long set, clear;
const wchar_t *failed;
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.h b/Utilities/cmlibarchive/libarchive/archive_entry.h
index 6e0225b04..a9134f6b6 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry.h
+++ b/Utilities/cmlibarchive/libarchive/archive_entry.h
@@ -30,7 +30,7 @@
#define ARCHIVE_ENTRY_H_INCLUDED
/* Note: Compiler will complain if this does not match archive.h! */
-#define ARCHIVE_VERSION_NUMBER 3003001
+#define ARCHIVE_VERSION_NUMBER 3003003
/*
* Note: archive_entry.h is for use outside of libarchive; the
@@ -42,6 +42,7 @@
#include <sys/types.h>
#include <stddef.h> /* for wchar_t */
+#include <stdint.h>
#include <time.h>
#if defined(_WIN32) && !defined(__CYGWIN__)
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry_acl.3 b/Utilities/cmlibarchive/libarchive/archive_entry_acl.3
index c5115f727..534dbfac6 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry_acl.3
+++ b/Utilities/cmlibarchive/libarchive/archive_entry_acl.3
@@ -32,7 +32,7 @@
.Nm archive_entry_acl_clear ,
.Nm archive_entry_acl_count ,
.Nm archive_entry_acl_from_text ,
-.Nm archive_entry_acl_from_text_w,
+.Nm archive_entry_acl_from_text_w ,
.Nm archive_entry_acl_next ,
.Nm archive_entry_acl_next_w ,
.Nm archive_entry_acl_reset ,
@@ -267,7 +267,7 @@ Only inherit, do not apply the permission on the directory itself.
.It Dv ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT ( Sy n )
Do not propagate inherit flags. Only first-level entries inherit ACLs.
.It Dv ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS ( Sy S )
-Trigger alarm or audit on succesful access.
+Trigger alarm or audit on successful access.
.It Dv ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS ( Sy F )
Trigger alarm or audit on failed access.
.It Dv ARCHIVE_ENTRY_ACL_ENTRY_INHERITED ( Sy I )
@@ -279,7 +279,7 @@ and
.Fn archive_entry_acl_add_entry_w
add a single ACL entry.
For the access ACL and non-extended principals, the classic Unix permissions
-are updated. An archive enry cannot contain both POSIX.1e and NFSv4 ACL
+are updated. An archive entry cannot contain both POSIX.1e and NFSv4 ACL
entries.
.Pp
.Fn archive_entry_acl_clear
@@ -303,7 +303,7 @@ for POSIX.1e ACLs and
for NFSv4 ACLs. For POSIX.1e ACLs if
.Dv ARCHIVE_ENTRY_ACL_TYPE_ACCESS
is included and at least one extended ACL entry is found,
-the three non-extened ACLs are added.
+the three non-extended ACLs are added.
.Pp
.Fn archive_entry_acl_from_text
and
@@ -367,7 +367,7 @@ and
.Fn archive_entry_acl_to_text_w
convert the ACL entries for the given type into a
.Pq wide
-string of ACL entries separated by newline. If the the pointer
+string of ACL entries separated by newline. If the pointer
.Fa len_p
is not NULL, then the function shall return the length of the string
.Pq not including the NULL terminator
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry_paths.3 b/Utilities/cmlibarchive/libarchive/archive_entry_paths.3
index fd22cf7e2..f647212a9 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry_paths.3
+++ b/Utilities/cmlibarchive/libarchive/archive_entry_paths.3
@@ -31,25 +31,25 @@
.Nm archive_entry_set_hardlink ,
.Nm archive_entry_copy_hardlink ,
.Nm archive_entry_copy_hardlink_w ,
-.Nm archve_entry_update_hardlink_utf8 ,
+.Nm archive_entry_update_hardlink_utf8 ,
.Nm archive_entry_set_link ,
.Nm archive_entry_copy_link ,
.Nm archive_entry_copy_link_w ,
-.Nm archve_entry_update_link_utf8 ,
+.Nm archive_entry_update_link_utf8 ,
.Nm archive_entry_pathname ,
.Nm archive_entry_pathname_w ,
.Nm archive_entry_set_pathname ,
.Nm archive_entry_copy_pathname ,
.Nm archive_entry_copy_pathname_w ,
-.Nm archve_entry_update_pathname_utf8 ,
+.Nm archive_entry_update_pathname_utf8 ,
.Nm archive_entry_sourcepath ,
.Nm archive_entry_copy_sourcepath ,
-.Nm archive_entry_symlink,
-.Nm archive_entry_symlink_w,
+.Nm archive_entry_symlink ,
+.Nm archive_entry_symlink_w ,
.Nm archive_entry_set_symlink ,
.Nm archive_entry_copy_symlink ,
.Nm archive_entry_copy_symlink_w ,
-.Nm archve_entry_update_symlink_utf8
+.Nm archive_entry_update_symlink_utf8
.Nd functions for manipulating path names in archive entry descriptions
.Sh LIBRARY
Streaming Archive Library (libarchive, -larchive)
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry_perms.3 b/Utilities/cmlibarchive/libarchive/archive_entry_perms.3
index 340c5ea72..aae3648bb 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry_perms.3
+++ b/Utilities/cmlibarchive/libarchive/archive_entry_perms.3
@@ -34,8 +34,8 @@
.Nm archive_entry_perm ,
.Nm archive_entry_set_perm ,
.Nm archive_entry_strmode ,
-.Nm archive_entry_uname
-.Nm archive_entry_uname_w
+.Nm archive_entry_uname ,
+.Nm archive_entry_uname_w ,
.Nm archive_entry_set_uname ,
.Nm archive_entry_copy_uname ,
.Nm archive_entry_copy_uname_w ,
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c b/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c
index fed74f512..74917b37b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c
+++ b/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c
@@ -51,7 +51,7 @@ archive_entry_sparse_clear(struct archive_entry *entry)
void
archive_entry_sparse_add_entry(struct archive_entry *entry,
- int64_t offset, int64_t length)
+ la_int64_t offset, la_int64_t length)
{
struct ae_sparse *sp;
@@ -135,7 +135,7 @@ archive_entry_sparse_reset(struct archive_entry * entry)
int
archive_entry_sparse_next(struct archive_entry * entry,
- int64_t *offset, int64_t *length)
+ la_int64_t *offset, la_int64_t *length)
{
if (entry->sparse_p) {
*offset = entry->sparse_p->offset;
diff --git a/Utilities/cmlibarchive/libarchive/archive_getdate.c b/Utilities/cmlibarchive/libarchive/archive_getdate.c
index beb0cba2e..030c083ce 100644
--- a/Utilities/cmlibarchive/libarchive/archive_getdate.c
+++ b/Utilities/cmlibarchive/libarchive/archive_getdate.c
@@ -691,7 +691,7 @@ Convert(time_t Month, time_t Day, time_t Year,
time_t Hours, time_t Minutes, time_t Seconds,
time_t Timezone, enum DSTMODE DSTmode)
{
- static int DaysInMonth[12] = {
+ signed char DaysInMonth[12] = {
31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
time_t Julian;
diff --git a/Utilities/cmlibarchive/libarchive/archive_match.c b/Utilities/cmlibarchive/libarchive/archive_match.c
index be72066ea..f150e8224 100644
--- a/Utilities/cmlibarchive/libarchive/archive_match.c
+++ b/Utilities/cmlibarchive/libarchive/archive_match.c
@@ -1582,7 +1582,7 @@ time_excluded(struct archive_match *a, struct archive_entry *entry)
*/
int
-archive_match_include_uid(struct archive *_a, int64_t uid)
+archive_match_include_uid(struct archive *_a, la_int64_t uid)
{
struct archive_match *a;
@@ -1593,7 +1593,7 @@ archive_match_include_uid(struct archive *_a, int64_t uid)
}
int
-archive_match_include_gid(struct archive *_a, int64_t gid)
+archive_match_include_gid(struct archive *_a, la_int64_t gid)
{
struct archive_match *a;
diff --git a/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h b/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h
index 2deeb5f55..921249bb9 100644
--- a/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_openssl_hmac_private.h
@@ -28,7 +28,8 @@
#include <openssl/hmac.h>
#include <openssl/opensslv.h>
-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
#include <stdlib.h> /* malloc, free */
#include <string.h> /* memset */
static inline HMAC_CTX *HMAC_CTX_new(void)
diff --git a/Utilities/cmlibarchive/libarchive/archive_pack_dev.c b/Utilities/cmlibarchive/libarchive/archive_pack_dev.c
index 6b7b4726d..53bddd790 100644
--- a/Utilities/cmlibarchive/libarchive/archive_pack_dev.c
+++ b/Utilities/cmlibarchive/libarchive/archive_pack_dev.c
@@ -57,6 +57,9 @@ __RCSID("$NetBSD$");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
+#ifdef HAVE_SYS_SYSMACROS_H
+#include <sys/sysmacros.h>
+#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -280,7 +283,7 @@ pack_bsdos(int n, unsigned long numbers[], const char **error)
/* list of formats and pack functions */
/* this list must be sorted lexically */
-static struct format {
+static const struct format {
const char *name;
pack_t *pack;
} formats[] = {
diff --git a/Utilities/cmlibarchive/libarchive/archive_platform.h b/Utilities/cmlibarchive/libarchive/archive_platform.h
index 47d144b05..e161e6406 100644
--- a/Utilities/cmlibarchive/libarchive/archive_platform.h
+++ b/Utilities/cmlibarchive/libarchive/archive_platform.h
@@ -52,6 +52,17 @@
#error Oops: No config.h and no pre-built configuration in archive_platform.h.
#endif
+/* On macOS check for some symbols based on the deployment target version. */
+#if defined(__APPLE__)
+# undef HAVE_FUTIMENS
+# undef HAVE_UTIMENSAT
+# include <AvailabilityMacros.h>
+# if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
+# define HAVE_FUTIMENS 1
+# define HAVE_UTIMENSAT 1
+# endif
+#endif
+
/* It should be possible to get rid of this by extending the feature-test
* macros to cover Windows API functions, probably along with non-trivial
* refactoring of code to find structures that sit more cleanly on top of
@@ -148,32 +159,6 @@
#endif
/*
- * If this platform has <sys/acl.h>, acl_create(), acl_init(),
- * acl_set_file(), and ACL_USER, we assume it has the rest of the
- * POSIX.1e draft functions used in archive_read_extract.c.
- */
-#if HAVE_SYS_ACL_H && HAVE_ACL_CREATE_ENTRY && HAVE_ACL_INIT && HAVE_ACL_SET_FILE
-#if HAVE_ACL_USER
-#define HAVE_POSIX_ACL 1
-#elif HAVE_ACL_TYPE_EXTENDED
-#define HAVE_DARWIN_ACL 1
-#endif
-#endif
-
-/*
- * If this platform has <sys/acl.h>, acl_get(), facl_get(), acl_set(),
- * facl_set() and types aclent_t and ace_t it uses Solaris-style ACL functions
- */
-#if HAVE_SYS_ACL_H && HAVE_ACL_GET && HAVE_FACL_GET && HAVE_ACL_SET && HAVE_FACL_SET && HAVE_ACLENT_T && HAVE_ACE_T
-#define HAVE_SUN_ACL 1
-#endif
-
-/* Define if platform supports NFSv4 ACLs */
-#if (HAVE_POSIX_ACL && HAVE_ACL_TYPE_NFS4) || HAVE_SUN_ACL || HAVE_DARWIN_ACL
-#define HAVE_NFS4_ACL 1
-#endif
-
-/*
* If we can't restore metadata using a file descriptor, then
* for compatibility's sake, close files before trying to restore metadata.
*/
@@ -211,4 +196,10 @@
#define ARCHIVE_ERRNO_MISC (-1)
#endif
+#if defined(__GNUC__) && (__GNUC__ >= 7)
+#define __LA_FALLTHROUGH __attribute__((fallthrough))
+#else
+#define __LA_FALLTHROUGH
+#endif
+
#endif /* !ARCHIVE_PLATFORM_H_INCLUDED */
diff --git a/Utilities/cmlibarchive/libarchive/archive_platform_acl.h b/Utilities/cmlibarchive/libarchive/archive_platform_acl.h
new file mode 100644
index 000000000..3498f78b3
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_platform_acl.h
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 2017 Martin Matuska
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/* !!ONLY FOR USE INTERNALLY TO LIBARCHIVE!! */
+
+#ifndef ARCHIVE_PLATFORM_ACL_H_INCLUDED
+#define ARCHIVE_PLATFORM_ACL_H_INCLUDED
+
+/*
+ * Determine what ACL types are supported
+ */
+#if ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_SUNOS || ARCHIVE_ACL_LIBACL
+#define ARCHIVE_ACL_POSIX1E 1
+#endif
+
+#if ARCHIVE_ACL_FREEBSD_NFS4 || ARCHIVE_ACL_SUNOS_NFS4 || \
+ ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_LIBRICHACL
+#define ARCHIVE_ACL_NFS4 1
+#endif
+
+#if ARCHIVE_ACL_POSIX1E || ARCHIVE_ACL_NFS4
+#define ARCHIVE_ACL_SUPPORT 1
+#endif
+
+#endif /* ARCHIVE_PLATFORM_ACL_H_INCLUDED */
diff --git a/Utilities/cmlibarchive/libarchive/archive_platform_xattr.h b/Utilities/cmlibarchive/libarchive/archive_platform_xattr.h
new file mode 100644
index 000000000..4edfecfdb
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_platform_xattr.h
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 2017 Martin Matuska
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/* !!ONLY FOR USE INTERNALLY TO LIBARCHIVE!! */
+
+#ifndef ARCHIVE_PLATFORM_XATTR_H_INCLUDED
+#define ARCHIVE_PLATFORM_XATTR_H_INCLUDED
+
+/*
+ * Determine if we support extended attributes
+ */
+#if ARCHIVE_XATTR_LINUX || ARCHIVE_XATTR_DARWIN || ARCHIVE_XATTR_FREEBSD || \
+ ARCHIVE_XATTR_AIX
+#define ARCHIVE_XATTR_SUPPORT 1
+#endif
+
+#endif /* ARCHIVE_PLATFORM_XATTR_H_INCLUDED */
diff --git a/Utilities/cmlibarchive/libarchive/archive_ppmd7.c b/Utilities/cmlibarchive/libarchive/archive_ppmd7.c
index 1aed922db..d0bacc68c 100644
--- a/Utilities/cmlibarchive/libarchive/archive_ppmd7.c
+++ b/Utilities/cmlibarchive/libarchive/archive_ppmd7.c
@@ -115,14 +115,14 @@ static void Ppmd7_Construct(CPpmd7 *p)
memset(p->HB2Flag + 0x40, 8, 0x100 - 0x40);
}
-static void Ppmd7_Free(CPpmd7 *p, ISzAlloc *alloc)
+static void Ppmd7_Free(CPpmd7 *p)
{
- alloc->Free(alloc, p->Base);
+ free(p->Base);
p->Size = 0;
p->Base = 0;
}
-static Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAlloc *alloc)
+static Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size)
{
if (p->Base == 0 || p->Size != size)
{
@@ -131,14 +131,14 @@ static Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAlloc *alloc)
if (size < UNIT_SIZE) {
return False;
}
- Ppmd7_Free(p, alloc);
+ Ppmd7_Free(p);
p->AlignOffset =
#ifdef PPMD_32BIT
(4 - size) & 3;
#else
4 - (size & 3);
#endif
- if ((p->Base = (Byte *)alloc->Alloc(alloc, p->AlignOffset + size
+ if ((p->Base = (Byte *)malloc(p->AlignOffset + size
#ifndef PPMD_32BIT
+ UNIT_SIZE
#endif
diff --git a/Utilities/cmlibarchive/libarchive/archive_ppmd7_private.h b/Utilities/cmlibarchive/libarchive/archive_ppmd7_private.h
index 06c99e828..577d6fb43 100644
--- a/Utilities/cmlibarchive/libarchive/archive_ppmd7_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_ppmd7_private.h
@@ -95,8 +95,8 @@ typedef struct
{
/* Base Functions */
void (*Ppmd7_Construct)(CPpmd7 *p);
- Bool (*Ppmd7_Alloc)(CPpmd7 *p, UInt32 size, ISzAlloc *alloc);
- void (*Ppmd7_Free)(CPpmd7 *p, ISzAlloc *alloc);
+ Bool (*Ppmd7_Alloc)(CPpmd7 *p, UInt32 size);
+ void (*Ppmd7_Free)(CPpmd7 *p);
void (*Ppmd7_Init)(CPpmd7 *p, unsigned maxOrder);
#define Ppmd7_WasAllocated(p) ((p)->Base != NULL)
diff --git a/Utilities/cmlibarchive/libarchive/archive_ppmd_private.h b/Utilities/cmlibarchive/libarchive/archive_ppmd_private.h
index e78bde594..a83b8514d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_ppmd_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_ppmd_private.h
@@ -69,13 +69,6 @@ typedef struct
void (*Write)(void *p, Byte b);
} IByteOut;
-
-typedef struct
-{
- void *(*Alloc)(void *p, size_t size);
- void (*Free)(void *p, void *address); /* address can be 0 */
-} ISzAlloc;
-
/*** End defined in Types.h ***/
/*** Begin defined in CpuArch.h ***/
diff --git a/Utilities/cmlibarchive/libarchive/archive_random.c b/Utilities/cmlibarchive/libarchive/archive_random.c
index 90ee7c626..65ea69157 100644
--- a/Utilities/cmlibarchive/libarchive/archive_random.c
+++ b/Utilities/cmlibarchive/libarchive/archive_random.c
@@ -221,7 +221,10 @@ arc4_stir(void)
/*
* Discard early keystream, as per recommendations in:
* "(Not So) Random Shuffles of RC4" by Ilya Mironov.
+ * As per the Network Operations Division, cryptographic requirements
+ * published on wikileaks on March 2017.
*/
+
for (i = 0; i < 3072; i++)
(void)arc4_getbyte();
arc4_count = 1600000;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read.c b/Utilities/cmlibarchive/libarchive/archive_read.c
index d1fecebfd..0e56e76e7 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read.c
@@ -120,7 +120,8 @@ archive_read_new(void)
* Record the do-not-extract-to file. This belongs in archive_read_extract.c.
*/
void
-archive_read_extract_set_skip_file(struct archive *_a, int64_t d, int64_t i)
+archive_read_extract_set_skip_file(struct archive *_a, la_int64_t d,
+ la_int64_t i)
{
struct archive_read *a = (struct archive_read *)_a;
@@ -747,7 +748,7 @@ choose_format(struct archive_read *a)
* Return the file offset (within the uncompressed data stream) where
* the last header started.
*/
-int64_t
+la_int64_t
archive_read_header_position(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
@@ -820,7 +821,7 @@ archive_read_format_capabilities(struct archive *_a)
* DO NOT intermingle calls to this function and archive_read_data_block
* to read a single entry body.
*/
-ssize_t
+la_ssize_t
archive_read_data(struct archive *_a, void *buff, size_t s)
{
struct archive *a = (struct archive *)_a;
@@ -881,7 +882,8 @@ archive_read_data(struct archive *_a, void *buff, size_t s)
len = a->read_data_remaining;
if (len > s)
len = s;
- memcpy(dest, a->read_data_block, len);
+ if (len)
+ memcpy(dest, a->read_data_block, len);
s -= len;
a->read_data_block += len;
a->read_data_remaining -= len;
@@ -942,7 +944,7 @@ archive_read_data_skip(struct archive *_a)
return (r);
}
-int64_t
+la_int64_t
archive_seek_data(struct archive *_a, int64_t offset, int whence)
{
struct archive_read *a = (struct archive_read *)_a;
@@ -1625,7 +1627,8 @@ __archive_read_filter_seek(struct archive_read_filter *filter, int64_t offset,
switch (whence) {
case SEEK_CUR:
/* Adjust the offset and use SEEK_SET instead */
- offset += filter->position;
+ offset += filter->position;
+ __LA_FALLTHROUGH;
case SEEK_SET:
cursor = 0;
while (1)
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_append_filter.c b/Utilities/cmlibarchive/libarchive/archive_read_append_filter.c
index 5e4d16307..da7c55b9b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_append_filter.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_append_filter.c
@@ -89,6 +89,10 @@ archive_read_append_filter(struct archive *_a, int code)
strcpy(str, "lz4");
r1 = archive_read_support_filter_lz4(_a);
break;
+ case ARCHIVE_FILTER_ZSTD:
+ strcpy(str, "zstd");
+ r1 = archive_read_support_filter_zstd(_a);
+ break;
case ARCHIVE_FILTER_LZIP:
strcpy(str, "lzip");
r1 = archive_read_support_filter_lzip(_a);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk.3 b/Utilities/cmlibarchive/libarchive/archive_read_disk.3
index 2a5c1305e..027f63cb6 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk.3
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk.3
@@ -24,11 +24,12 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 30, 2016
+.Dd April 3, 2017
.Dt ARCHIVE_READ_DISK 3
.Os
.Sh NAME
.Nm archive_read_disk_new ,
+.Nm archive_read_disk_set_behavior ,
.Nm archive_read_disk_set_symlink_logical ,
.Nm archive_read_disk_set_symlink_physical ,
.Nm archive_read_disk_set_symlink_hybrid ,
@@ -37,10 +38,7 @@
.Nm archive_read_disk_uname ,
.Nm archive_read_disk_set_uname_lookup ,
.Nm archive_read_disk_set_gname_lookup ,
-.Nm archive_read_disk_set_standard_lookup ,
-.Nm archive_read_close ,
-.Nm archive_read_finish ,
-.Nm archive_read_free
+.Nm archive_read_disk_set_standard_lookup
.Nd functions for reading objects from disk
.Sh LIBRARY
Streaming Archive Library (libarchive, -larchive)
@@ -49,6 +47,8 @@ Streaming Archive Library (libarchive, -larchive)
.Ft struct archive *
.Fn archive_read_disk_new "void"
.Ft int
+.Fn archive_read_disk_set_behavior "struct archive *" "int"
+.Ft int
.Fn archive_read_disk_set_symlink_logical "struct archive *"
.Ft int
.Fn archive_read_disk_set_symlink_physical "struct archive *"
@@ -81,12 +81,6 @@ Streaming Archive Library (libarchive, -larchive)
.Fa "int fd"
.Fa "const struct stat *"
.Fc
-.Ft int
-.Fn archive_read_close "struct archive *"
-.Ft int
-.Fn archive_read_finish "struct archive *"
-.Ft int
-.Fn archive_read_free "struct archive *"
.Sh DESCRIPTION
These functions provide an API for reading information about
objects on disk.
@@ -98,6 +92,51 @@ objects.
Allocates and initializes a
.Tn struct archive
object suitable for reading object information from disk.
+.It Fn archive_read_disk_set_behavior
+Configures various behavior options when reading entries from disk.
+The flags field consists of a bitwise OR of one or more of the
+following values:
+.Bl -tag -compact -width "indent"
+.It Cm ARCHIVE_READDISK_HONOR_NODUMP
+Skip files and directories with the nodump file attribute (file flag) set.
+By default, the nodump file atrribute is ignored.
+.It Cm ARCHIVE_READDISK_MAC_COPYFILE
+Mac OS X specific. Read metadata (ACLs and extended attributes) with
+.Xr copyfile 3 .
+By default, metadata is read using
+.Xr copyfile 3 .
+.It Cm ARCHIVE_READDISK_NO_ACL
+Do not read Access Control Lists.
+By default, ACLs are read from disk.
+.It Cm ARCHIVE_READDISK_NO_FFLAGS
+Do not read file attributes (file flags).
+By default, file attributes are read from disk.
+See
+.Xr chattr 1
+.Pq Linux
+or
+.Xr chflags 1
+.Pq FreeBSD, Mac OS X
+for more information on file attributes.
+.It Cm ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS
+Do not traverse mount points.
+By defaut, moint points are traversed.
+.It Cm ARCHIVE_READDISK_NO_XATTR
+Do not read extended file attributes (xattrs).
+By default, extended file attributes are read from disk.
+See
+.Xr xattr 7
+.Pq Linux ,
+.Xr xattr 2
+.Pq Mac OS X ,
+or
+.Xr getextattr 8
+.Pq FreeBSD
+for more information on extended file attributes.
+.It Cm ARCHIVE_READDISK_RESTORE_ATIME
+Restore access time of traversed files.
+By default, access time of traversed files is not restored.
+.El
.It Xo
.Fn archive_read_disk_set_symlink_logical ,
.Fn archive_read_disk_set_symlink_physical ,
@@ -181,17 +220,6 @@ using the currently registered lookup functions above.
This affects the file ownership fields and ACL values in the
.Tn struct archive_entry
object.
-.It Fn archive_read_close
-Does nothing for
-.Tn archive_read_disk
-handles.
-.It Fn archive_read_finish
-This is a deprecated synonym for
-.Fn archive_read_free .
-.It Fn archive_read_free
-Invokes
-.Fn archive_read_close
-if it was not invoked manually, then releases all resources.
.El
More information about the
.Va struct archive
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
index b2f1d17d9..1786cff38 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
@@ -26,23 +26,14 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_disk_entry_from_file.c 201084 2009-12-28 02:14:09Z kientzle $");
+__FBSDID("$FreeBSD");
/* This is the tree-walking code for POSIX systems. */
#if !defined(_WIN32) || defined(__CYGWIN__)
#ifdef HAVE_SYS_TYPES_H
-/* Mac OSX requires sys/types.h before sys/acl.h. */
#include <sys/types.h>
#endif
-#ifdef HAVE_SYS_ACL_H
-#include <sys/acl.h>
-#endif
-#ifdef HAVE_DARWIN_ACL
-#include <membership.h>
-#include <grp.h>
-#include <pwd.h>
-#endif
#ifdef HAVE_SYS_EXTATTR_H
#include <sys/extattr.h>
#endif
@@ -63,9 +54,6 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_disk_entry_from_file.c 2010
#ifdef HAVE_SYS_EA_H
#include <sys/ea.h>
#endif
-#ifdef HAVE_ACL_LIBACL_H
-#include <acl/libacl.h>
-#endif
#ifdef HAVE_COPYFILE_H
#include <copyfile.h>
#endif
@@ -113,27 +101,6 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_disk_entry_from_file.c 2010
#define O_CLOEXEC 0
#endif
-/*
- * Linux and FreeBSD plug this obvious hole in POSIX.1e in
- * different ways.
- */
-#if HAVE_ACL_GET_PERM
-#define ACL_GET_PERM acl_get_perm
-#elif HAVE_ACL_GET_PERM_NP
-#define ACL_GET_PERM acl_get_perm_np
-#endif
-
-/* NFSv4 platform ACL type */
-#if HAVE_SUN_ACL
-#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACE_T
-#elif HAVE_DARWIN_ACL
-#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACL_TYPE_EXTENDED
-#elif HAVE_ACL_TYPE_NFS4
-#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACL_TYPE_NFS4
-#endif
-
-static int setup_acls(struct archive_read_disk *,
- struct archive_entry *, int *fd);
static int setup_mac_metadata(struct archive_read_disk *,
struct archive_entry *, int *fd);
static int setup_xattrs(struct archive_read_disk *,
@@ -145,6 +112,45 @@ static int setup_sparse_fiemap(struct archive_read_disk *,
struct archive_entry *, int *fd);
#endif
+#if !ARCHIVE_ACL_SUPPORT
+int
+archive_read_disk_entry_setup_acls(struct archive_read_disk *a,
+ struct archive_entry *entry, int *fd)
+{
+ (void)a; /* UNUSED */
+ (void)entry; /* UNUSED */
+ (void)fd; /* UNUSED */
+ return (ARCHIVE_OK);
+}
+#endif
+
+/*
+ * Enter working directory and return working pathname of archive_entry.
+ * If a pointer to an integer is provided and its value is below zero
+ * open a file descriptor on this pathname.
+ */
+const char *
+archive_read_disk_entry_setup_path(struct archive_read_disk *a,
+ struct archive_entry *entry, int *fd)
+{
+ const char *path;
+
+ path = archive_entry_sourcepath(entry);
+
+ if (path == NULL || (a->tree != NULL &&
+ a->tree_enter_working_dir(a->tree) != 0))
+ path = archive_entry_pathname(entry);
+ if (path == NULL) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Couldn't determine path");
+ } else if (fd != NULL && *fd < 0 && a->tree != NULL &&
+ (a->follow_symlinks || archive_entry_filetype(entry) != AE_IFLNK)) {
+ *fd = a->open_on_current_dir(a->tree, path,
+ O_RDONLY | O_NONBLOCK);
+ }
+ return (path);
+}
+
int
archive_read_disk_entry_from_file(struct archive *_a,
struct archive_entry *entry,
@@ -279,7 +285,7 @@ archive_read_disk_entry_from_file(struct archive *_a,
r = 0;
if ((a->flags & ARCHIVE_READDISK_NO_ACL) == 0)
- r = setup_acls(a, entry, &fd);
+ r = archive_read_disk_entry_setup_acls(a, entry, &fd);
if ((a->flags & ARCHIVE_READDISK_NO_XATTR) == 0) {
r1 = setup_xattrs(a, entry, &fd);
if (r1 < r)
@@ -328,19 +334,10 @@ setup_mac_metadata(struct archive_read_disk *a,
struct archive_string tempfile;
(void)fd; /* UNUSED */
- name = archive_entry_sourcepath(entry);
+
+ name = archive_read_disk_entry_setup_path(a, entry, NULL);
if (name == NULL)
- name = archive_entry_pathname(entry);
- else if (a->tree != NULL && a->tree_enter_working_dir(a->tree) != 0) {
- archive_set_error(&a->archive, errno,
- "Can't change dir to read extended attributes");
- return (ARCHIVE_FAILED);
- }
- if (name == NULL) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Can't open file to read extended attributes: No name");
return (ARCHIVE_WARN);
- }
/* Short-circuit if there's nothing to do. */
have_attrs = copyfile(name, NULL, 0, copyfile_flags | COPYFILE_CHECK);
@@ -426,996 +423,10 @@ setup_mac_metadata(struct archive_read_disk *a,
}
#endif
-#if HAVE_DARWIN_ACL
-static int translate_guid(struct archive *, acl_entry_t,
- int *, int *, const char **);
-
-static void add_trivial_nfs4_acl(struct archive_entry *);
-#endif
-
-#if HAVE_SUN_ACL
-static int
-sun_acl_is_trivial(acl_t *, mode_t, int *trivialp);
-#endif
-
-#if HAVE_POSIX_ACL || HAVE_NFS4_ACL
-static int translate_acl(struct archive_read_disk *a,
- struct archive_entry *entry,
-#if HAVE_SUN_ACL
- acl_t *acl,
-#else
- acl_t acl,
-#endif
- int archive_entry_acl_type);
-
-static int
-setup_acls(struct archive_read_disk *a,
- struct archive_entry *entry, int *fd)
-{
- const char *accpath;
-#if HAVE_SUN_ACL
- acl_t *acl;
-#else
- acl_t acl;
-#endif
- int r;
-
- accpath = NULL;
-
-#if HAVE_SUN_ACL || HAVE_DARWIN_ACL || HAVE_ACL_GET_FD_NP
- if (*fd < 0)
-#else
- /* For default ACLs on Linux we need reachable accpath */
- if (*fd < 0 || S_ISDIR(archive_entry_mode(entry)))
-#endif
- {
- accpath = archive_entry_sourcepath(entry);
- if (accpath == NULL || (a->tree != NULL &&
- a->tree_enter_working_dir(a->tree) != 0))
- accpath = archive_entry_pathname(entry);
- if (accpath == NULL) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Couldn't determine file path to read ACLs");
- return (ARCHIVE_WARN);
- }
- if (a->tree != NULL &&
-#if !HAVE_SUN_ACL && !HAVE_DARWIN_ACL && !HAVE_ACL_GET_FD_NP
- *fd < 0 &&
-#endif
- (a->follow_symlinks ||
- archive_entry_filetype(entry) != AE_IFLNK)) {
- *fd = a->open_on_current_dir(a->tree,
- accpath, O_RDONLY | O_NONBLOCK);
- }
- }
-
- archive_entry_acl_clear(entry);
-
- acl = NULL;
-
-#if HAVE_NFS4_ACL
- /* Try NFSv4 ACL first. */
- if (*fd >= 0)
-#if HAVE_SUN_ACL
- /* Solaris reads both POSIX.1e and NFSv4 ACL here */
- facl_get(*fd, 0, &acl);
-#elif HAVE_ACL_GET_FD_NP
- acl = acl_get_fd_np(*fd, ARCHIVE_PLATFORM_ACL_TYPE_NFS4);
-#else
- acl = acl_get_fd(*fd);
-#endif
-#if HAVE_ACL_GET_LINK_NP
- else if (!a->follow_symlinks)
- acl = acl_get_link_np(accpath, ARCHIVE_PLATFORM_ACL_TYPE_NFS4);
-#else
- else if ((!a->follow_symlinks)
- && (archive_entry_filetype(entry) == AE_IFLNK))
- /* We can't get the ACL of a symlink, so we assume it can't
- have one. */
- acl = NULL;
-#endif
- else
-#if HAVE_SUN_ACL
- /* Solaris reads both POSIX.1e and NFSv4 ACLs here */
- acl_get(accpath, 0, &acl);
-#else
- acl = acl_get_file(accpath, ARCHIVE_PLATFORM_ACL_TYPE_NFS4);
-#endif
-
-
-#if HAVE_ACL_IS_TRIVIAL_NP || HAVE_SUN_ACL
- /* Ignore "trivial" ACLs that just mirror the file mode. */
- if (acl != NULL) {
-#if HAVE_SUN_ACL
- if (sun_acl_is_trivial(acl, archive_entry_mode(entry),
- &r) == 0 && r == 1)
-#elif HAVE_ACL_IS_TRIVIAL_NP
- if (acl_is_trivial_np(acl, &r) == 0 && r == 1)
-#endif
- {
- acl_free(acl);
- acl = NULL;
- /*
- * Simultaneous NFSv4 and POSIX.1e ACLs for the same
- * entry are not allowed, so we should return here
- */
- return (ARCHIVE_OK);
- }
- }
-#endif /* HAVE_ACL_IS_TRIVIAL_NP || HAVE_SUN_ACL */
- if (acl != NULL) {
- r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
- acl_free(acl);
- if (r != ARCHIVE_OK) {
- archive_set_error(&a->archive, errno,
- "Couldn't translate "
-#if !HAVE_SUN_ACL
- "NFSv4 "
-#endif
- "ACLs");
- }
-#if HAVE_DARWIN_ACL
- /*
- * Because Mac OS doesn't support owner@, group@ and everyone@
- * ACLs we need to add NFSv4 ACLs mirroring the file mode to
- * the archive entry. Otherwise extraction on non-Mac platforms
- * would lead to an invalid file mode.
- */
- if ((archive_entry_acl_types(entry) &
- ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0)
- add_trivial_nfs4_acl(entry);
-#endif
- return (r);
- }
-#endif /* HAVE_NFS4_ACL */
-
-#if HAVE_POSIX_ACL
- /* This code path is skipped on MacOS and Solaris */
+#if ARCHIVE_XATTR_LINUX || ARCHIVE_XATTR_DARWIN || ARCHIVE_XATTR_AIX
- /* Retrieve access ACL from file. */
- if (*fd >= 0)
- acl = acl_get_fd(*fd);
-#if HAVE_ACL_GET_LINK_NP
- else if (!a->follow_symlinks)
- acl = acl_get_link_np(accpath, ACL_TYPE_ACCESS);
-#else
- else if ((!a->follow_symlinks)
- && (archive_entry_filetype(entry) == AE_IFLNK))
- /* We can't get the ACL of a symlink, so we assume it can't
- have one. */
- acl = NULL;
-#endif
- else
- acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
-
-#if HAVE_ACL_IS_TRIVIAL_NP
- /* Ignore "trivial" ACLs that just mirror the file mode. */
- if (acl != NULL && acl_is_trivial_np(acl, &r) == 0) {
- if (r) {
- acl_free(acl);
- acl = NULL;
- }
- }
-#endif
-
- if (acl != NULL) {
- r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
- acl_free(acl);
- acl = NULL;
- if (r != ARCHIVE_OK) {
- archive_set_error(&a->archive, errno,
- "Couldn't translate access ACLs");
- return (r);
- }
- }
-
- /* Only directories can have default ACLs. */
- if (S_ISDIR(archive_entry_mode(entry))) {
-#if HAVE_ACL_GET_FD_NP
- if (*fd >= 0)
- acl = acl_get_fd_np(*fd, ACL_TYPE_DEFAULT);
- else
-#endif
- acl = acl_get_file(accpath, ACL_TYPE_DEFAULT);
- if (acl != NULL) {
- r = translate_acl(a, entry, acl,
- ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
- acl_free(acl);
- if (r != ARCHIVE_OK) {
- archive_set_error(&a->archive, errno,
- "Couldn't translate default ACLs");
- return (r);
- }
- }
- }
-#endif /* HAVE_POSIX_ACL */
- return (ARCHIVE_OK);
-}
-
-/*
- * Translate system ACL permissions into libarchive internal structure
- */
-static const struct {
- const int archive_perm;
- const int platform_perm;
-} acl_perm_map[] = {
-#if HAVE_SUN_ACL /* Solaris NFSv4 ACL permissions */
- {ARCHIVE_ENTRY_ACL_EXECUTE, ACE_EXECUTE},
- {ARCHIVE_ENTRY_ACL_READ_DATA, ACE_READ_DATA},
- {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACE_LIST_DIRECTORY},
- {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACE_WRITE_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_FILE, ACE_ADD_FILE},
- {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACE_APPEND_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACE_ADD_SUBDIRECTORY},
- {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACE_READ_NAMED_ATTRS},
- {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACE_WRITE_NAMED_ATTRS},
- {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACE_DELETE_CHILD},
- {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACE_READ_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACE_WRITE_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_DELETE, ACE_DELETE},
- {ARCHIVE_ENTRY_ACL_READ_ACL, ACE_READ_ACL},
- {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACE_WRITE_ACL},
- {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACE_WRITE_OWNER},
- {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACE_SYNCHRONIZE}
-#elif HAVE_DARWIN_ACL /* MacOS ACL permissions */
- {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
- {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
- {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE},
- {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
- {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE},
- {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY},
- {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD},
- {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_EXTATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_EXTATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_SECURITY},
- {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_SECURITY},
- {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_CHANGE_OWNER},
- {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
-#else /* POSIX.1e ACL permissions */
- {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
- {ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
- {ARCHIVE_ENTRY_ACL_READ, ACL_READ},
-#if HAVE_ACL_TYPE_NFS4 /* FreeBSD NFSv4 ACL permissions */
- {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
- {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
- {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE},
- {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY},
- {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_NAMED_ATTRS},
- {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_NAMED_ATTRS},
- {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD},
- {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE},
- {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_ACL},
- {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL},
- {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER},
- {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
-#endif
-#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */
-};
-
-#if HAVE_NFS4_ACL
-/*
- * Translate system NFSv4 inheritance flags into libarchive internal structure
- */
-static const struct {
- const int archive_inherit;
- const int platform_inherit;
-} acl_inherit_map[] = {
-#if HAVE_SUN_ACL /* Solaris ACL inheritance flags */
- {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACE_FILE_INHERIT_ACE},
- {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACE_DIRECTORY_INHERIT_ACE},
- {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACE_NO_PROPAGATE_INHERIT_ACE},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACE_INHERIT_ONLY_ACE},
- {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACE_SUCCESSFUL_ACCESS_ACE_FLAG},
- {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACE_FAILED_ACCESS_ACE_FLAG},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACE_INHERITED_ACE}
-#elif HAVE_DARWIN_ACL /* MacOS NFSv4 inheritance flags */
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED},
- {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_LIMIT_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_ONLY_INHERIT}
-#else /* FreeBSD NFSv4 ACL inheritance flags */
- {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY},
- {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACL_ENTRY_SUCCESSFUL_ACCESS},
- {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACL_ENTRY_FAILED_ACCESS},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED}
-#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */
-};
-#endif /* HAVE_NFS4_ACL */
-
-#if HAVE_DARWIN_ACL
-static int translate_guid(struct archive *a, acl_entry_t acl_entry,
- int *ae_id, int *ae_tag, const char **ae_name)
-{
- void *q;
- uid_t ugid;
- int r, idtype;
- struct passwd *pwd;
- struct group *grp;
-
- q = acl_get_qualifier(acl_entry);
- if (q == NULL)
- return (1);
- r = mbr_uuid_to_id((const unsigned char *)q, &ugid, &idtype);
- if (r != 0) {
- acl_free(q);
- return (1);
- }
- if (idtype == ID_TYPE_UID) {
- *ae_tag = ARCHIVE_ENTRY_ACL_USER;
- pwd = getpwuuid(q);
- if (pwd == NULL) {
- *ae_id = ugid;
- *ae_name = NULL;
- } else {
- *ae_id = pwd->pw_uid;
- *ae_name = archive_read_disk_uname(a, *ae_id);
- }
- } else if (idtype == ID_TYPE_GID) {
- *ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
- grp = getgruuid(q);
- if (grp == NULL) {
- *ae_id = ugid;
- *ae_name = NULL;
- } else {
- *ae_id = grp->gr_gid;
- *ae_name = archive_read_disk_gname(a, *ae_id);
- }
- } else
- r = 1;
-
- acl_free(q);
- return (r);
-}
-
-/*
- * Add trivial NFSv4 ACL entries from mode
- */
-static void
-add_trivial_nfs4_acl(struct archive_entry *entry)
-{
- mode_t mode;
- int i;
- const int rperm = ARCHIVE_ENTRY_ACL_READ_DATA;
- const int wperm = ARCHIVE_ENTRY_ACL_WRITE_DATA |
- ARCHIVE_ENTRY_ACL_APPEND_DATA;
- const int eperm = ARCHIVE_ENTRY_ACL_EXECUTE;
- const int pubset = ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES |
- ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS |
- ARCHIVE_ENTRY_ACL_READ_ACL |
- ARCHIVE_ENTRY_ACL_SYNCHRONIZE;
- const int ownset = pubset | ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES |
- ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS |
- ARCHIVE_ENTRY_ACL_WRITE_ACL |
- ARCHIVE_ENTRY_ACL_WRITE_OWNER;
-
- struct {
- const int type;
- const int tag;
- int permset;
- } tacl_entry[] = {
- {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_USER_OBJ, 0},
- {ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_USER_OBJ, 0},
- {ARCHIVE_ENTRY_ACL_TYPE_DENY, ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0},
- {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_USER_OBJ, ownset},
- {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_GROUP_OBJ, pubset},
- {ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_EVERYONE, pubset}
- };
-
- mode = archive_entry_mode(entry);
-
- /* Permissions for everyone@ */
- if (mode & 0004)
- tacl_entry[5].permset |= rperm;
- if (mode & 0002)
- tacl_entry[5].permset |= wperm;
- if (mode & 0001)
- tacl_entry[5].permset |= eperm;
-
- /* Permissions for group@ */
- if (mode & 0040)
- tacl_entry[4].permset |= rperm;
- else if (mode & 0004)
- tacl_entry[2].permset |= rperm;
- if (mode & 0020)
- tacl_entry[4].permset |= wperm;
- else if (mode & 0002)
- tacl_entry[2].permset |= wperm;
- if (mode & 0010)
- tacl_entry[4].permset |= eperm;
- else if (mode & 0001)
- tacl_entry[2].permset |= eperm;
-
- /* Permissions for owner@ */
- if (mode & 0400) {
- tacl_entry[3].permset |= rperm;
- if (!(mode & 0040) && (mode & 0004))
- tacl_entry[0].permset |= rperm;
- } else if ((mode & 0040) || (mode & 0004))
- tacl_entry[1].permset |= rperm;
- if (mode & 0200) {
- tacl_entry[3].permset |= wperm;
- if (!(mode & 0020) && (mode & 0002))
- tacl_entry[0].permset |= wperm;
- } else if ((mode & 0020) || (mode & 0002))
- tacl_entry[1].permset |= wperm;
- if (mode & 0100) {
- tacl_entry[3].permset |= eperm;
- if (!(mode & 0010) && (mode & 0001))
- tacl_entry[0].permset |= eperm;
- } else if ((mode & 0010) || (mode & 0001))
- tacl_entry[1].permset |= eperm;
-
- for (i = 0; i < 6; i++) {
- if (tacl_entry[i].permset != 0) {
- archive_entry_acl_add_entry(entry,
- tacl_entry[i].type, tacl_entry[i].permset,
- tacl_entry[i].tag, -1, NULL);
- }
- }
-
- return;
-}
-#elif HAVE_SUN_ACL
-/*
- * Check if acl is trivial
- * This is a FreeBSD acl_is_trivial_np() implementation for Solaris
- */
-static int
-sun_acl_is_trivial(acl_t *acl, mode_t mode, int *trivialp)
-{
- int i, p;
- const uint32_t rperm = ACE_READ_DATA;
- const uint32_t wperm = ACE_WRITE_DATA | ACE_APPEND_DATA;
- const uint32_t eperm = ACE_EXECUTE;
- const uint32_t pubset = ACE_READ_ATTRIBUTES | ACE_READ_NAMED_ATTRS |
- ACE_READ_ACL | ACE_SYNCHRONIZE;
- const uint32_t ownset = pubset | ACE_WRITE_ATTRIBUTES |
- ACE_WRITE_NAMED_ATTRS | ACE_WRITE_ACL | ACE_WRITE_OWNER;
-
- ace_t *ace;
- ace_t tace[6];
-
- if (acl == NULL || trivialp == NULL)
- return (-1);
-
- *trivialp = 0;
-
- /* ACL_IS_TRIVIAL flag must be set for both POSIX.1e and NFSv4 ACLs */
- if ((acl->acl_flags & ACL_IS_TRIVIAL) == 0)
- return (0);
-
- /*
- * POSIX.1e ACLs marked with ACL_IS_TRIVIAL are compatible with
- * FreeBSD acl_is_trivial_np(). On Solaris they have 4 entries,
- * including mask.
- */
- if (acl->acl_type == ACLENT_T) {
- if (acl->acl_cnt == 4)
- *trivialp = 1;
- return (0);
- }
-
- if (acl->acl_type != ACE_T || acl->acl_entry_size != sizeof(ace_t))
- return (-1);
-
- /*
- * Continue with checking NFSv4 ACLs
- *
- * Create list of trivial ace's to be compared
- */
-
- /* owner@ allow pre */
- tace[0].a_flags = ACE_OWNER;
- tace[0].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
- tace[0].a_access_mask = 0;
-
- /* owner@ deny */
- tace[1].a_flags = ACE_OWNER;
- tace[1].a_type = ACE_ACCESS_DENIED_ACE_TYPE;
- tace[1].a_access_mask = 0;
-
- /* group@ deny */
- tace[2].a_flags = ACE_GROUP | ACE_IDENTIFIER_GROUP;
- tace[2].a_type = ACE_ACCESS_DENIED_ACE_TYPE;
- tace[2].a_access_mask = 0;
-
- /* owner@ allow */
- tace[3].a_flags = ACE_OWNER;
- tace[3].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
- tace[3].a_access_mask = ownset;
-
- /* group@ allow */
- tace[4].a_flags = ACE_GROUP | ACE_IDENTIFIER_GROUP;
- tace[4].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
- tace[4].a_access_mask = pubset;
-
- /* everyone@ allow */
- tace[5].a_flags = ACE_EVERYONE;
- tace[5].a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
- tace[5].a_access_mask = pubset;
-
- /* Permissions for everyone@ */
- if (mode & 0004)
- tace[5].a_access_mask |= rperm;
- if (mode & 0002)
- tace[5].a_access_mask |= wperm;
- if (mode & 0001)
- tace[5].a_access_mask |= eperm;
-
- /* Permissions for group@ */
- if (mode & 0040)
- tace[4].a_access_mask |= rperm;
- else if (mode & 0004)
- tace[2].a_access_mask |= rperm;
- if (mode & 0020)
- tace[4].a_access_mask |= wperm;
- else if (mode & 0002)
- tace[2].a_access_mask |= wperm;
- if (mode & 0010)
- tace[4].a_access_mask |= eperm;
- else if (mode & 0001)
- tace[2].a_access_mask |= eperm;
-
- /* Permissions for owner@ */
- if (mode & 0400) {
- tace[3].a_access_mask |= rperm;
- if (!(mode & 0040) && (mode & 0004))
- tace[0].a_access_mask |= rperm;
- } else if ((mode & 0040) || (mode & 0004))
- tace[1].a_access_mask |= rperm;
- if (mode & 0200) {
- tace[3].a_access_mask |= wperm;
- if (!(mode & 0020) && (mode & 0002))
- tace[0].a_access_mask |= wperm;
- } else if ((mode & 0020) || (mode & 0002))
- tace[1].a_access_mask |= wperm;
- if (mode & 0100) {
- tace[3].a_access_mask |= eperm;
- if (!(mode & 0010) && (mode & 0001))
- tace[0].a_access_mask |= eperm;
- } else if ((mode & 0010) || (mode & 0001))
- tace[1].a_access_mask |= eperm;
-
- /* Check if the acl count matches */
- p = 3;
- for (i = 0; i < 3; i++) {
- if (tace[i].a_access_mask != 0)
- p++;
- }
- if (acl->acl_cnt != p)
- return (0);
-
- p = 0;
- for (i = 0; i < 6; i++) {
- if (tace[i].a_access_mask != 0) {
- ace = &((ace_t *)acl->acl_aclp)[p];
- /*
- * Illumos added ACE_DELETE_CHILD to write perms for
- * directories. We have to check against that, too.
- */
- if (ace->a_flags != tace[i].a_flags ||
- ace->a_type != tace[i].a_type ||
- (ace->a_access_mask != tace[i].a_access_mask &&
- ((acl->acl_flags & ACL_IS_DIR) == 0 ||
- (tace[i].a_access_mask & wperm) == 0 ||
- ace->a_access_mask !=
- (tace[i].a_access_mask | ACE_DELETE_CHILD))))
- return (0);
- p++;
- }
- }
-
- *trivialp = 1;
- return (0);
-}
-#endif /* HAVE_SUN_ACL */
-
-#if HAVE_SUN_ACL
/*
- * Translate Solaris POSIX.1e and NFSv4 ACLs into libarchive internal ACL
- */
-static int
-translate_acl(struct archive_read_disk *a,
- struct archive_entry *entry, acl_t *acl, int default_entry_acl_type)
-{
- int e, i;
- int ae_id, ae_tag, ae_perm;
- int entry_acl_type;
- const char *ae_name;
- aclent_t *aclent;
- ace_t *ace;
-
- (void)default_entry_acl_type;
-
- if (acl->acl_cnt <= 0)
- return (ARCHIVE_OK);
-
- for (e = 0; e < acl->acl_cnt; e++) {
- ae_name = NULL;
- ae_tag = 0;
- ae_perm = 0;
-
- if (acl->acl_type == ACE_T) {
- ace = &((ace_t *)acl->acl_aclp)[e];
- ae_id = ace->a_who;
-
- switch(ace->a_type) {
- case ACE_ACCESS_ALLOWED_ACE_TYPE:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
- break;
- case ACE_ACCESS_DENIED_ACE_TYPE:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
- break;
- case ACE_SYSTEM_AUDIT_ACE_TYPE:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
- break;
- case ACE_SYSTEM_ALARM_ACE_TYPE:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALARM;
- break;
- default:
- /* Unknown entry type, skip */
- continue;
- }
-
- if ((ace->a_flags & ACE_OWNER) != 0)
- ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
- else if ((ace->a_flags & ACE_GROUP) != 0)
- ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
- else if ((ace->a_flags & ACE_EVERYONE) != 0)
- ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE;
- else if ((ace->a_flags & ACE_IDENTIFIER_GROUP) != 0) {
- ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
- ae_name = archive_read_disk_gname(&a->archive,
- ae_id);
- } else {
- ae_tag = ARCHIVE_ENTRY_ACL_USER;
- ae_name = archive_read_disk_uname(&a->archive,
- ae_id);
- }
-
- for (i = 0; i < (int)(sizeof(acl_inherit_map) /
- sizeof(acl_inherit_map[0])); ++i) {
- if ((ace->a_flags &
- acl_inherit_map[i].platform_inherit) != 0)
- ae_perm |=
- acl_inherit_map[i].archive_inherit;
- }
-
- for (i = 0; i < (int)(sizeof(acl_perm_map) /
- sizeof(acl_perm_map[0])); ++i) {
- if ((ace->a_access_mask &
- acl_perm_map[i].platform_perm) != 0)
- ae_perm |=
- acl_perm_map[i].archive_perm;
- }
- } else {
- aclent = &((aclent_t *)acl->acl_aclp)[e];
- if ((aclent->a_type & ACL_DEFAULT) != 0)
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
- else
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
- ae_id = aclent->a_id;
-
- switch(aclent->a_type) {
- case DEF_USER:
- case USER:
- ae_name = archive_read_disk_uname(&a->archive,
- ae_id);
- ae_tag = ARCHIVE_ENTRY_ACL_USER;
- break;
- case DEF_GROUP:
- case GROUP:
- ae_name = archive_read_disk_gname(&a->archive,
- ae_id);
- ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
- break;
- case DEF_CLASS_OBJ:
- case CLASS_OBJ:
- ae_tag = ARCHIVE_ENTRY_ACL_MASK;
- break;
- case DEF_USER_OBJ:
- case USER_OBJ:
- ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
- break;
- case DEF_GROUP_OBJ:
- case GROUP_OBJ:
- ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
- break;
- case DEF_OTHER_OBJ:
- case OTHER_OBJ:
- ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
- break;
- default:
- /* Unknown tag type, skip */
- continue;
- }
-
- if ((aclent->a_perm & 1) != 0)
- ae_perm |= ARCHIVE_ENTRY_ACL_EXECUTE;
- if ((aclent->a_perm & 2) != 0)
- ae_perm |= ARCHIVE_ENTRY_ACL_WRITE;
- if ((aclent->a_perm & 4) != 0)
- ae_perm |= ARCHIVE_ENTRY_ACL_READ;
- } /* default_entry_acl_type != ARCHIVE_ENTRY_ACL_TYPE_NFS4 */
-
- archive_entry_acl_add_entry(entry, entry_acl_type,
- ae_perm, ae_tag, ae_id, ae_name);
- }
- return (ARCHIVE_OK);
-}
-#else /* !HAVE_SUN_ACL */
-/*
- * Translate POSIX.1e (Linux), FreeBSD (both POSIX.1e and NFSv4) and
- * MacOS (NFSv4 only) ACLs into libarchive internal structure
- */
-static int
-translate_acl(struct archive_read_disk *a,
- struct archive_entry *entry, acl_t acl, int default_entry_acl_type)
-{
- acl_tag_t acl_tag;
-#if HAVE_ACL_TYPE_NFS4
- acl_entry_type_t acl_type;
- int brand;
-#endif
-#if HAVE_ACL_TYPE_NFS4 || HAVE_DARWIN_ACL
- acl_flagset_t acl_flagset;
-#endif
- acl_entry_t acl_entry;
- acl_permset_t acl_permset;
- int i, entry_acl_type;
- int r, s, ae_id, ae_tag, ae_perm;
-#if !HAVE_DARWIN_ACL
- void *q;
-#endif
- const char *ae_name;
-
-#if HAVE_ACL_TYPE_NFS4
- // FreeBSD "brands" ACLs as POSIX.1e or NFSv4
- // Make sure the "brand" on this ACL is consistent
- // with the default_entry_acl_type bits provided.
- if (acl_get_brand_np(acl, &brand) != 0) {
- archive_set_error(&a->archive, errno,
- "Failed to read ACL brand");
- return (ARCHIVE_WARN);
- }
- switch (brand) {
- case ACL_BRAND_POSIX:
- switch (default_entry_acl_type) {
- case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
- case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
- break;
- default:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Invalid ACL entry type for POSIX.1e ACL");
- return (ARCHIVE_WARN);
- }
- break;
- case ACL_BRAND_NFS4:
- if (default_entry_acl_type & ~ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Invalid ACL entry type for NFSv4 ACL");
- return (ARCHIVE_WARN);
- }
- break;
- default:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Unknown ACL brand");
- return (ARCHIVE_WARN);
- }
-#endif
-
- s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
- if (s == -1) {
- archive_set_error(&a->archive, errno,
- "Failed to get first ACL entry");
- return (ARCHIVE_WARN);
- }
-
-#if HAVE_DARWIN_ACL
- while (s == 0)
-#else /* FreeBSD, Linux */
- while (s == 1)
-#endif
- {
- ae_id = -1;
- ae_name = NULL;
- ae_perm = 0;
-
- if (acl_get_tag_type(acl_entry, &acl_tag) != 0) {
- archive_set_error(&a->archive, errno,
- "Failed to get ACL tag type");
- return (ARCHIVE_WARN);
- }
- switch (acl_tag) {
-#if !HAVE_DARWIN_ACL /* FreeBSD, Linux */
- case ACL_USER:
- q = acl_get_qualifier(acl_entry);
- if (q != NULL) {
- ae_id = (int)*(uid_t *)q;
- acl_free(q);
- ae_name = archive_read_disk_uname(&a->archive,
- ae_id);
- }
- ae_tag = ARCHIVE_ENTRY_ACL_USER;
- break;
- case ACL_GROUP:
- q = acl_get_qualifier(acl_entry);
- if (q != NULL) {
- ae_id = (int)*(gid_t *)q;
- acl_free(q);
- ae_name = archive_read_disk_gname(&a->archive,
- ae_id);
- }
- ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
- break;
- case ACL_MASK:
- ae_tag = ARCHIVE_ENTRY_ACL_MASK;
- break;
- case ACL_USER_OBJ:
- ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
- break;
- case ACL_GROUP_OBJ:
- ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
- break;
- case ACL_OTHER:
- ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
- break;
-#if HAVE_ACL_TYPE_NFS4
- case ACL_EVERYONE:
- ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE;
- break;
-#endif
-#else /* HAVE_DARWIN_ACL */
- case ACL_EXTENDED_ALLOW:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
- r = translate_guid(&a->archive, acl_entry, &ae_id,
- &ae_tag, &ae_name);
- break;
- case ACL_EXTENDED_DENY:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
- r = translate_guid(&a->archive, acl_entry, &ae_id,
- &ae_tag, &ae_name);
- break;
-#endif /* HAVE_DARWIN_ACL */
- default:
- /* Skip types that libarchive can't support. */
- s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
- continue;
- }
-
-#if HAVE_DARWIN_ACL
- /* Skip if translate_guid() above failed */
- if (r != 0) {
- s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
- continue;
- }
-#endif
-
-#if !HAVE_DARWIN_ACL
- // XXX acl_type maps to allow/deny/audit/YYYY bits
- entry_acl_type = default_entry_acl_type;
-#endif
-#if HAVE_ACL_TYPE_NFS4 || HAVE_DARWIN_ACL
- if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
-#if HAVE_ACL_TYPE_NFS4
- /*
- * acl_get_entry_type_np() fails with non-NFSv4 ACLs
- */
- if (acl_get_entry_type_np(acl_entry, &acl_type) != 0) {
- archive_set_error(&a->archive, errno, "Failed "
- "to get ACL type from a NFSv4 ACL entry");
- return (ARCHIVE_WARN);
- }
- switch (acl_type) {
- case ACL_ENTRY_TYPE_ALLOW:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
- break;
- case ACL_ENTRY_TYPE_DENY:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
- break;
- case ACL_ENTRY_TYPE_AUDIT:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_AUDIT;
- break;
- case ACL_ENTRY_TYPE_ALARM:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALARM;
- break;
- default:
- archive_set_error(&a->archive, errno,
- "Invalid NFSv4 ACL entry type");
- return (ARCHIVE_WARN);
- }
-#endif /* HAVE_ACL_TYPE_NFS4 */
-
- /*
- * Libarchive stores "flag" (NFSv4 inheritance bits)
- * in the ae_perm bitmap.
- *
- * acl_get_flagset_np() fails with non-NFSv4 ACLs
- */
- if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
- archive_set_error(&a->archive, errno,
- "Failed to get flagset from a NFSv4 ACL entry");
- return (ARCHIVE_WARN);
- }
- for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
- r = acl_get_flag_np(acl_flagset,
- acl_inherit_map[i].platform_inherit);
- if (r == -1) {
- archive_set_error(&a->archive, errno,
- "Failed to check flag in a NFSv4 "
- "ACL flagset");
- return (ARCHIVE_WARN);
- } else if (r)
- ae_perm |= acl_inherit_map[i].archive_inherit;
- }
- }
-#endif /* HAVE_ACL_TYPE_NFS4 || HAVE_DARWIN_ACL */
-
- if (acl_get_permset(acl_entry, &acl_permset) != 0) {
- archive_set_error(&a->archive, errno,
- "Failed to get ACL permission set");
- return (ARCHIVE_WARN);
- }
- for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) {
- /*
- * acl_get_perm() is spelled differently on different
- * platforms; see above.
- */
- r = ACL_GET_PERM(acl_permset, acl_perm_map[i].platform_perm);
- if (r == -1) {
- archive_set_error(&a->archive, errno,
- "Failed to check permission in an ACL permission set");
- return (ARCHIVE_WARN);
- } else if (r)
- ae_perm |= acl_perm_map[i].archive_perm;
- }
-
- archive_entry_acl_add_entry(entry, entry_acl_type,
- ae_perm, ae_tag,
- ae_id, ae_name);
-
- s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
-#if !HAVE_DARWIN_ACL
- if (s == -1) {
- archive_set_error(&a->archive, errno,
- "Failed to get next ACL entry");
- return (ARCHIVE_WARN);
- }
-#endif
- }
- return (ARCHIVE_OK);
-}
-#endif /* !HAVE_SUN_ACL */
-#else /* !HAVE_POSIX_ACL && !HAVE_NFS4_ACL */
-static int
-setup_acls(struct archive_read_disk *a,
- struct archive_entry *entry, int *fd)
-{
- (void)a; /* UNUSED */
- (void)entry; /* UNUSED */
- (void)fd; /* UNUSED */
- return (ARCHIVE_OK);
-}
-#endif /* !HAVE_POSIX_ACL && !HAVE_NFS4_ACL */
-
-#if (HAVE_FGETXATTR && HAVE_FLISTXATTR && HAVE_LISTXATTR && \
- HAVE_LLISTXATTR && HAVE_GETXATTR && HAVE_LGETXATTR) || \
- (HAVE_FGETEA && HAVE_FLISTEA && HAVE_LISTEA)
-
-/*
- * Linux and AIX extended attribute support.
+ * Linux, Darwin and AIX extended attribute support.
*
* TODO: By using a stack-allocated buffer for the first
* call to getxattr(), we might be able to avoid the second
@@ -1433,21 +444,32 @@ setup_xattr(struct archive_read_disk *a,
ssize_t size;
void *value = NULL;
-#if HAVE_FGETXATTR
- if (fd >= 0)
+
+ if (fd >= 0) {
+#if ARCHIVE_XATTR_LINUX
size = fgetxattr(fd, name, NULL, 0);
- else if (!a->follow_symlinks)
- size = lgetxattr(accpath, name, NULL, 0);
- else
- size = getxattr(accpath, name, NULL, 0);
-#elif HAVE_FGETEA
- if (fd >= 0)
+#elif ARCHIVE_XATTR_DARWIN
+ size = fgetxattr(fd, name, NULL, 0, 0, 0);
+#elif ARCHIVE_XATTR_AIX
size = fgetea(fd, name, NULL, 0);
- else if (!a->follow_symlinks)
+#endif
+ } else if (!a->follow_symlinks) {
+#if ARCHIVE_XATTR_LINUX
+ size = lgetxattr(accpath, name, NULL, 0);
+#elif ARCHIVE_XATTR_DARWIN
+ size = getxattr(accpath, name, NULL, 0, 0, XATTR_NOFOLLOW);
+#elif ARCHIVE_XATTR_AIX
size = lgetea(accpath, name, NULL, 0);
- else
+#endif
+ } else {
+#if ARCHIVE_XATTR_LINUX
+ size = getxattr(accpath, name, NULL, 0);
+#elif ARCHIVE_XATTR_DARWIN
+ size = getxattr(accpath, name, NULL, 0, 0, 0);
+#elif ARCHIVE_XATTR_AIX
size = getea(accpath, name, NULL, 0);
#endif
+ }
if (size == -1) {
archive_set_error(&a->archive, errno,
@@ -1460,21 +482,32 @@ setup_xattr(struct archive_read_disk *a,
return (ARCHIVE_FATAL);
}
-#if HAVE_FGETXATTR
- if (fd >= 0)
+
+ if (fd >= 0) {
+#if ARCHIVE_XATTR_LINUX
size = fgetxattr(fd, name, value, size);
- else if (!a->follow_symlinks)
- size = lgetxattr(accpath, name, value, size);
- else
- size = getxattr(accpath, name, value, size);
-#elif HAVE_FGETEA
- if (fd >= 0)
+#elif ARCHIVE_XATTR_DARWIN
+ size = fgetxattr(fd, name, value, size, 0, 0);
+#elif ARCHIVE_XATTR_AIX
size = fgetea(fd, name, value, size);
- else if (!a->follow_symlinks)
+#endif
+ } else if (!a->follow_symlinks) {
+#if ARCHIVE_XATTR_LINUX
+ size = lgetxattr(accpath, name, value, size);
+#elif ARCHIVE_XATTR_DARWIN
+ size = getxattr(accpath, name, value, size, 0, XATTR_NOFOLLOW);
+#elif ARCHIVE_XATTR_AIX
size = lgetea(accpath, name, value, size);
- else
+#endif
+ } else {
+#if ARCHIVE_XATTR_LINUX
+ size = getxattr(accpath, name, value, size);
+#elif ARCHIVE_XATTR_DARWIN
+ size = getxattr(accpath, name, value, size, 0, 0);
+#elif ARCHIVE_XATTR_AIX
size = getea(accpath, name, value, size);
#endif
+ }
if (size == -1) {
archive_set_error(&a->archive, errno,
@@ -1499,38 +532,36 @@ setup_xattrs(struct archive_read_disk *a,
path = NULL;
if (*fd < 0) {
- path = archive_entry_sourcepath(entry);
- if (path == NULL || (a->tree != NULL &&
- a->tree_enter_working_dir(a->tree) != 0))
- path = archive_entry_pathname(entry);
- if (path == NULL) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Couldn't determine file path to read "
- "extended attributes");
+ path = archive_read_disk_entry_setup_path(a, entry, fd);
+ if (path == NULL)
return (ARCHIVE_WARN);
- }
- if (a->tree != NULL && (a->follow_symlinks ||
- archive_entry_filetype(entry) != AE_IFLNK)) {
- *fd = a->open_on_current_dir(a->tree,
- path, O_RDONLY | O_NONBLOCK);
- }
}
-#if HAVE_FLISTXATTR
- if (*fd >= 0)
+ if (*fd >= 0) {
+#if ARCHIVE_XATTR_LINUX
list_size = flistxattr(*fd, NULL, 0);
- else if (!a->follow_symlinks)
- list_size = llistxattr(path, NULL, 0);
- else
- list_size = listxattr(path, NULL, 0);
-#elif HAVE_FLISTEA
- if (*fd >= 0)
+#elif ARCHIVE_XATTR_DARWIN
+ list_size = flistxattr(*fd, NULL, 0, 0);
+#elif ARCHIVE_XATTR_AIX
list_size = flistea(*fd, NULL, 0);
- else if (!a->follow_symlinks)
+#endif
+ } else if (!a->follow_symlinks) {
+#if ARCHIVE_XATTR_LINUX
+ list_size = llistxattr(path, NULL, 0);
+#elif ARCHIVE_XATTR_DARWIN
+ list_size = listxattr(path, NULL, 0, XATTR_NOFOLLOW);
+#elif ARCHIVE_XATTR_AIX
list_size = llistea(path, NULL, 0);
- else
+#endif
+ } else {
+#if ARCHIVE_XATTR_LINUX
+ list_size = listxattr(path, NULL, 0);
+#elif ARCHIVE_XATTR_DARWIN
+ list_size = listxattr(path, NULL, 0, 0);
+#elif ARCHIVE_XATTR_AIX
list_size = listea(path, NULL, 0);
#endif
+ }
if (list_size == -1) {
if (errno == ENOTSUP || errno == ENOSYS)
@@ -1548,21 +579,31 @@ setup_xattrs(struct archive_read_disk *a,
return (ARCHIVE_FATAL);
}
-#if HAVE_FLISTXATTR
- if (*fd >= 0)
+ if (*fd >= 0) {
+#if ARCHIVE_XATTR_LINUX
list_size = flistxattr(*fd, list, list_size);
- else if (!a->follow_symlinks)
- list_size = llistxattr(path, list, list_size);
- else
- list_size = listxattr(path, list, list_size);
-#elif HAVE_FLISTEA
- if (*fd >= 0)
+#elif ARCHIVE_XATTR_DARWIN
+ list_size = flistxattr(*fd, list, list_size, 0);
+#elif ARCHIVE_XATTR_AIX
list_size = flistea(*fd, list, list_size);
- else if (!a->follow_symlinks)
+#endif
+ } else if (!a->follow_symlinks) {
+#if ARCHIVE_XATTR_LINUX
+ list_size = llistxattr(path, list, list_size);
+#elif ARCHIVE_XATTR_DARWIN
+ list_size = listxattr(path, list, list_size, XATTR_NOFOLLOW);
+#elif ARCHIVE_XATTR_AIX
list_size = llistea(path, list, list_size);
- else
+#endif
+ } else {
+#if ARCHIVE_XATTR_LINUX
+ list_size = listxattr(path, list, list_size);
+#elif ARCHIVE_XATTR_DARWIN
+ list_size = listxattr(path, list, list_size, 0);
+#elif ARCHIVE_XATTR_AIX
list_size = listea(path, list, list_size);
#endif
+ }
if (list_size == -1) {
archive_set_error(&a->archive, errno,
@@ -1572,9 +613,21 @@ setup_xattrs(struct archive_read_disk *a,
}
for (p = list; (p - list) < list_size; p += strlen(p) + 1) {
- if (strncmp(p, "system.", 7) == 0 ||
- strncmp(p, "xfsroot.", 8) == 0)
+#if ARCHIVE_XATTR_LINUX
+ /* Linux: skip POSIX.1e ACL extended attributes */
+ if (strncmp(p, "system.", 7) == 0 &&
+ (strcmp(p + 7, "posix_acl_access") == 0 ||
+ strcmp(p + 7, "posix_acl_default") == 0))
+ continue;
+ if (strncmp(p, "trusted.SGI_", 12) == 0 &&
+ (strcmp(p + 12, "ACL_DEFAULT") == 0 ||
+ strcmp(p + 12, "ACL_FILE") == 0))
+ continue;
+
+ /* Linux: xfsroot namespace is obsolete and unsupported */
+ if (strncmp(p, "xfsroot.", 8) == 0)
continue;
+#endif
setup_xattr(a, entry, p, *fd, path);
}
@@ -1582,8 +635,7 @@ setup_xattrs(struct archive_read_disk *a,
return (ARCHIVE_OK);
}
-#elif HAVE_EXTATTR_GET_FILE && HAVE_EXTATTR_LIST_FILE && \
- HAVE_DECL_EXTATTR_NAMESPACE_USER
+#elif ARCHIVE_XATTR_FREEBSD
/*
* FreeBSD extattr interface.
@@ -1658,21 +710,9 @@ setup_xattrs(struct archive_read_disk *a,
path = NULL;
if (*fd < 0) {
- path = archive_entry_sourcepath(entry);
- if (path == NULL || (a->tree != NULL &&
- a->tree_enter_working_dir(a->tree) != 0))
- path = archive_entry_pathname(entry);
- if (path == NULL) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Couldn't determine file path to read "
- "extended attributes");
+ path = archive_read_disk_entry_setup_path(a, entry, fd);
+ if (path == NULL)
return (ARCHIVE_WARN);
- }
- if (a->tree != NULL && (a->follow_symlinks ||
- archive_entry_filetype(entry) != AE_IFLNK)) {
- *fd = a->open_on_current_dir(a->tree,
- path, O_RDONLY | O_NONBLOCK);
- }
}
if (*fd >= 0)
@@ -1773,6 +813,7 @@ setup_sparse_fiemap(struct archive_read_disk *a,
int64_t size;
int count, do_fiemap, iters;
int exit_sts = ARCHIVE_OK;
+ const char *path;
if (archive_entry_filetype(entry) != AE_IFREG
|| archive_entry_size(entry) <= 0
@@ -1780,11 +821,10 @@ setup_sparse_fiemap(struct archive_read_disk *a,
return (ARCHIVE_OK);
if (*fd < 0) {
- const char *path;
-
- path = archive_entry_sourcepath(entry);
+ path = archive_read_disk_entry_setup_path(a, entry, NULL);
if (path == NULL)
- path = archive_entry_pathname(entry);
+ return (ARCHIVE_FAILED);
+
if (a->tree != NULL)
*fd = a->open_on_current_dir(a->tree, path,
O_RDONLY | O_NONBLOCK | O_CLOEXEC);
@@ -1880,6 +920,7 @@ setup_sparse(struct archive_read_disk *a,
off_t off_s, off_e;
int exit_sts = ARCHIVE_OK;
int check_fully_sparse = 0;
+ const char *path;
if (archive_entry_filetype(entry) != AE_IFREG
|| archive_entry_size(entry) <= 0
@@ -1887,20 +928,10 @@ setup_sparse(struct archive_read_disk *a,
return (ARCHIVE_OK);
/* Does filesystem support the reporting of hole ? */
- if (*fd < 0 && a->tree != NULL) {
- const char *path;
-
- path = archive_entry_sourcepath(entry);
- if (path == NULL)
- path = archive_entry_pathname(entry);
- *fd = a->open_on_current_dir(a->tree, path,
- O_RDONLY | O_NONBLOCK);
- if (*fd < 0) {
- archive_set_error(&a->archive, errno,
- "Can't open `%s'", path);
- return (ARCHIVE_FAILED);
- }
- }
+ if (*fd < 0)
+ path = archive_read_disk_entry_setup_path(a, entry, fd);
+ else
+ path = NULL;
if (*fd >= 0) {
#ifdef _PC_MIN_HOLE_SIZE
@@ -1911,12 +942,8 @@ setup_sparse(struct archive_read_disk *a,
if (initial_off != 0)
lseek(*fd, 0, SEEK_SET);
} else {
- const char *path;
-
- path = archive_entry_sourcepath(entry);
if (path == NULL)
- path = archive_entry_pathname(entry);
-
+ return (ARCHIVE_FAILED);
#ifdef _PC_MIN_HOLE_SIZE
if (pathconf(path, _PC_MIN_HOLE_SIZE) <= 0)
return (ARCHIVE_OK);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
index 6961ae6a4..cdf754123 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
@@ -387,7 +387,7 @@ archive_read_disk_vtable(void)
}
const char *
-archive_read_disk_gname(struct archive *_a, int64_t gid)
+archive_read_disk_gname(struct archive *_a, la_int64_t gid)
{
struct archive_read_disk *a = (struct archive_read_disk *)_a;
if (ARCHIVE_OK != __archive_check_magic(_a, ARCHIVE_READ_DISK_MAGIC,
@@ -399,7 +399,7 @@ archive_read_disk_gname(struct archive *_a, int64_t gid)
}
const char *
-archive_read_disk_uname(struct archive *_a, int64_t uid)
+archive_read_disk_uname(struct archive *_a, la_int64_t uid)
{
struct archive_read_disk *a = (struct archive_read_disk *)_a;
if (ARCHIVE_OK != __archive_check_magic(_a, ARCHIVE_READ_DISK_MAGIC,
@@ -413,7 +413,7 @@ archive_read_disk_uname(struct archive *_a, int64_t uid)
int
archive_read_disk_set_gname_lookup(struct archive *_a,
void *private_data,
- const char * (*lookup_gname)(void *private, int64_t gid),
+ const char * (*lookup_gname)(void *private, la_int64_t gid),
void (*cleanup_gname)(void *private))
{
struct archive_read_disk *a = (struct archive_read_disk *)_a;
@@ -432,7 +432,7 @@ archive_read_disk_set_gname_lookup(struct archive *_a,
int
archive_read_disk_set_uname_lookup(struct archive *_a,
void *private_data,
- const char * (*lookup_uname)(void *private, int64_t uid),
+ const char * (*lookup_uname)(void *private, la_int64_t uid),
void (*cleanup_uname)(void *private))
{
struct archive_read_disk *a = (struct archive_read_disk *)_a;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_private.h b/Utilities/cmlibarchive/libarchive/archive_read_disk_private.h
index b5a8328b7..f03a0a9cc 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_private.h
@@ -33,6 +33,8 @@
#ifndef ARCHIVE_READ_DISK_PRIVATE_H_INCLUDED
#define ARCHIVE_READ_DISK_PRIVATE_H_INCLUDED
+#include "archive_platform_acl.h"
+
struct tree;
struct archive_entry;
@@ -86,4 +88,11 @@ struct archive_read_disk {
void *excluded_cb_data;
};
+const char *
+archive_read_disk_entry_setup_path(struct archive_read_disk *,
+ struct archive_entry *, int *);
+
+int
+archive_read_disk_entry_setup_acls(struct archive_read_disk *,
+ struct archive_entry *, int *);
#endif
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
index 3b903304f..d82048de2 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
@@ -117,7 +117,7 @@ struct filesystem {
*/
#define MAX_OVERLAPPED 8
-#define BUFFER_SIZE (1024 * 8)
+#define READ_BUFFER_SIZE (1024 * 64) /* Default to 64KB per https://technet.microsoft.com/en-us/library/cc938632.aspx */
#define DIRECT_IO 0/* Disabled */
#define ASYNC_IO 1/* Enabled */
@@ -320,7 +320,7 @@ archive_read_disk_vtable(void)
}
const char *
-archive_read_disk_gname(struct archive *_a, int64_t gid)
+archive_read_disk_gname(struct archive *_a, la_int64_t gid)
{
struct archive_read_disk *a = (struct archive_read_disk *)_a;
if (ARCHIVE_OK != __archive_check_magic(_a, ARCHIVE_READ_DISK_MAGIC,
@@ -332,7 +332,7 @@ archive_read_disk_gname(struct archive *_a, int64_t gid)
}
const char *
-archive_read_disk_uname(struct archive *_a, int64_t uid)
+archive_read_disk_uname(struct archive *_a, la_int64_t uid)
{
struct archive_read_disk *a = (struct archive_read_disk *)_a;
if (ARCHIVE_OK != __archive_check_magic(_a, ARCHIVE_READ_DISK_MAGIC,
@@ -346,7 +346,7 @@ archive_read_disk_uname(struct archive *_a, int64_t uid)
int
archive_read_disk_set_gname_lookup(struct archive *_a,
void *private_data,
- const char * (*lookup_gname)(void *private, int64_t gid),
+ const char * (*lookup_gname)(void *private, la_int64_t gid),
void (*cleanup_gname)(void *private))
{
struct archive_read_disk *a = (struct archive_read_disk *)_a;
@@ -567,7 +567,7 @@ start_next_async_read(struct archive_read_disk *a, struct tree *t)
/* Allocate read buffer. */
if (olp->buff == NULL) {
void *p;
- size_t s = (size_t)align_num_per_sector(t, BUFFER_SIZE);
+ size_t s = (size_t)align_num_per_sector(t, READ_BUFFER_SIZE);
p = VirtualAlloc(NULL, s, MEM_COMMIT, PAGE_READWRITE);
if (p == NULL) {
archive_set_error(&a->archive, ENOMEM,
@@ -683,7 +683,7 @@ _archive_read_data_block(struct archive *_a, const void **buff,
break;
} while (r == ARCHIVE_OK && t->ol_num_doing < MAX_OVERLAPPED);
} else {
- if (start_next_async_read(a, t) == ARCHIVE_FATAL)
+ if ((r = start_next_async_read(a, t)) == ARCHIVE_FATAL)
goto abort_read_data;
}
@@ -923,6 +923,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
t->entry_fh = CreateFileW(tree_current_access_path(t),
GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, flags, NULL);
if (t->entry_fh == INVALID_HANDLE_VALUE) {
+ la_dosmaperr(GetLastError());
archive_set_error(&a->archive, errno,
"Couldn't open %ls", tree_current_path(a->tree));
return (ARCHIVE_FAILED);
@@ -2275,10 +2276,10 @@ setup_sparse_from_disk(struct archive_read_disk *a,
if (range.Length.QuadPart > 0)
continue;
} else {
- /* The remaining data is hole. */
+ /* The entire file is a hole. Add one data block of size 0 at the end. */
archive_entry_sparse_add_entry(entry,
- range.FileOffset.QuadPart,
- range.Length.QuadPart);
+ entry_size,
+ 0);
}
break;
} else {
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_filter.3 b/Utilities/cmlibarchive/libarchive/archive_read_filter.3
index 7f020e373..ef0a70175 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_filter.3
+++ b/Utilities/cmlibarchive/libarchive/archive_read_filter.3
@@ -38,6 +38,7 @@
.Nm archive_read_support_filter_rpm ,
.Nm archive_read_support_filter_uu ,
.Nm archive_read_support_filter_xz ,
+.Nm archive_read_support_filter_zstd ,
.Nm archive_read_support_filter_program ,
.Nm archive_read_support_filter_program_signature
.Nd functions for reading streaming archives
@@ -73,6 +74,8 @@ Streaming Archive Library (libarchive, -larchive)
.Ft int
.Fn archive_read_support_filter_xz "struct archive *"
.Ft int
+.Fn archive_read_support_filter_zstd "struct archive *"
+.Ft int
.Fo archive_read_support_filter_program
.Fa "struct archive *"
.Fa "const char *cmd"
@@ -99,7 +102,8 @@ Streaming Archive Library (libarchive, -larchive)
.Fn archive_read_support_filter_none ,
.Fn archive_read_support_filter_rpm ,
.Fn archive_read_support_filter_uu ,
-.Fn archive_read_support_filter_xz
+.Fn archive_read_support_filter_xz ,
+.Fn archive_read_support_filter_zstd ,
.Xc
Enables auto-detection code and decompression support for the
specified compression.
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_format.3 b/Utilities/cmlibarchive/libarchive/archive_read_format.3
index 53b9a7e0e..91c5d2cfd 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_format.3
+++ b/Utilities/cmlibarchive/libarchive/archive_read_format.3
@@ -37,9 +37,9 @@
.Nm archive_read_support_format_empty ,
.Nm archive_read_support_format_iso9660 ,
.Nm archive_read_support_format_lha ,
-.Nm archive_read_support_format_mtree,
-.Nm archive_read_support_format_rar,
-.Nm archive_read_support_format_raw,
+.Nm archive_read_support_format_mtree ,
+.Nm archive_read_support_format_rar ,
+.Nm archive_read_support_format_raw ,
.Nm archive_read_support_format_tar ,
.Nm archive_read_support_format_xar ,
.Nm archive_read_support_format_zip
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_open.3 b/Utilities/cmlibarchive/libarchive/archive_read_open.3
index 4d8272cac..2278ebc33 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_open.3
+++ b/Utilities/cmlibarchive/libarchive/archive_read_open.3
@@ -33,7 +33,7 @@
.Nm archive_read_open_fd ,
.Nm archive_read_open_FILE ,
.Nm archive_read_open_filename ,
-.Nm archive_read_open_memory ,
+.Nm archive_read_open_memory
.Nd functions for reading streaming archives
.Sh LIBRARY
Streaming Archive Library (libarchive, -larchive)
@@ -67,7 +67,7 @@ Streaming Archive Library (libarchive, -larchive)
.Fa "size_t block_size"
.Fc
.Ft int
-.Fn archive_read_open_memory "struct archive *" "void *buff" "size_t size"
+.Fn archive_read_open_memory "struct archive *" "const void *buff" "size_t size"
.Sh DESCRIPTION
.Bl -tag -compact -width indent
.It Fn archive_read_open
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_all.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_all.c
index 68c53de41..edb508c1d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_all.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_all.c
@@ -71,6 +71,8 @@ archive_read_support_filter_all(struct archive *a)
archive_read_support_filter_grzip(a);
/* Lz4 falls back to "lz4 -d" command-line program. */
archive_read_support_filter_lz4(a);
+ /* Zstd falls back to "zstd -d" command-line program. */
+ archive_read_support_filter_zstd(a);
/* Note: We always return ARCHIVE_OK here, even if some of the
* above return ARCHIVE_WARN. The intent here is to enable
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c
index 663e2d3d6..147f5027f 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c
@@ -494,7 +494,7 @@ lz4_filter_read_data_block(struct archive_read_filter *self, const void **p)
if (read_buf == NULL)
goto truncated_error;
compressed_size = archive_le32dec(read_buf);
- if ((compressed_size & ~(1 << 31)) > state->flags.block_maximum_size)
+ if ((compressed_size & 0x7fffffff) > state->flags.block_maximum_size)
goto malformed_error;
/* A compressed size == 0 means the end of stream blocks. */
if (compressed_size == 0) {
@@ -504,8 +504,8 @@ lz4_filter_read_data_block(struct archive_read_filter *self, const void **p)
checksum_size = state->flags.block_checksum;
/* Check if the block is uncompressed. */
- if (compressed_size & (1 << 31)) {
- compressed_size &= ~(1 << 31);
+ if (compressed_size & 0x80000000U) {
+ compressed_size &= 0x7fffffff;
uncompressed_size = compressed_size;
} else
uncompressed_size = 0;/* Unknown yet. */
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_zstd.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_zstd.c
new file mode 100644
index 000000000..451370693
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_zstd.c
@@ -0,0 +1,292 @@
+/*-
+ * Copyright (c) 2009-2011 Sean Purcell
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+
+__FBSDID("$FreeBSD$");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_ZSTD_H
+#include <cm_zstd.h>
+#endif
+
+#include "archive.h"
+#include "archive_endian.h"
+#include "archive_private.h"
+#include "archive_read_private.h"
+
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+
+struct private_data {
+ ZSTD_DStream *dstream;
+ unsigned char *out_block;
+ size_t out_block_size;
+ int64_t total_out;
+ char in_frame; /* True = in the middle of a zstd frame. */
+ char eof; /* True = found end of compressed data. */
+};
+
+/* Zstd Filter. */
+static ssize_t zstd_filter_read(struct archive_read_filter *, const void**);
+static int zstd_filter_close(struct archive_read_filter *);
+#endif
+
+/*
+ * Note that we can detect zstd compressed files even if we can't decompress
+ * them. (In fact, we like detecting them because we can give better error
+ * messages.) So the bid framework here gets compiled even if no zstd library
+ * is available.
+ */
+static int zstd_bidder_bid(struct archive_read_filter_bidder *,
+ struct archive_read_filter *);
+static int zstd_bidder_init(struct archive_read_filter *);
+
+int
+archive_read_support_filter_zstd(struct archive *_a)
+{
+ struct archive_read *a = (struct archive_read *)_a;
+ struct archive_read_filter_bidder *bidder;
+
+ archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+ ARCHIVE_STATE_NEW, "archive_read_support_filter_zstd");
+
+ if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+
+ bidder->data = NULL;
+ bidder->name = "zstd";
+ bidder->bid = zstd_bidder_bid;
+ bidder->init = zstd_bidder_init;
+ bidder->options = NULL;
+ bidder->free = NULL;
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+ return (ARCHIVE_OK);
+#else
+ archive_set_error(_a, ARCHIVE_ERRNO_MISC,
+ "Using external zstd program for zstd decompression");
+ return (ARCHIVE_WARN);
+#endif
+}
+
+/*
+ * Test whether we can handle this data.
+ */
+static int
+zstd_bidder_bid(struct archive_read_filter_bidder *self,
+ struct archive_read_filter *filter)
+{
+ const unsigned char *buffer;
+ ssize_t avail;
+ unsigned prefix;
+
+ /* Zstd frame magic values */
+ const unsigned zstd_magic = 0xFD2FB528U;
+
+ (void) self; /* UNUSED */
+
+ buffer = __archive_read_filter_ahead(filter, 4, &avail);
+ if (buffer == NULL)
+ return (0);
+
+ prefix = archive_le32dec(buffer);
+ if (prefix == zstd_magic)
+ return (32);
+
+ return (0);
+}
+
+#if !(HAVE_ZSTD_H && HAVE_LIBZSTD)
+
+/*
+ * If we don't have the library on this system, we can't do the
+ * decompression directly. We can, however, try to run "zstd -d"
+ * in case that's available.
+ */
+static int
+zstd_bidder_init(struct archive_read_filter *self)
+{
+ int r;
+
+ r = __archive_read_program(self, "zstd -d -qq");
+ /* Note: We set the format here even if __archive_read_program()
+ * above fails. We do, after all, know what the format is
+ * even if we weren't able to read it. */
+ self->code = ARCHIVE_FILTER_ZSTD;
+ self->name = "zstd";
+ return (r);
+}
+
+#else
+
+/*
+ * Initialize the filter object
+ */
+static int
+zstd_bidder_init(struct archive_read_filter *self)
+{
+ struct private_data *state;
+ const size_t out_block_size = ZSTD_DStreamOutSize();
+ void *out_block;
+ ZSTD_DStream *dstream;
+
+ self->code = ARCHIVE_FILTER_ZSTD;
+ self->name = "zstd";
+
+ state = (struct private_data *)calloc(sizeof(*state), 1);
+ out_block = (unsigned char *)malloc(out_block_size);
+ dstream = ZSTD_createDStream();
+
+ if (state == NULL || out_block == NULL || dstream == NULL) {
+ free(out_block);
+ free(state);
+ ZSTD_freeDStream(dstream); /* supports free on NULL */
+ archive_set_error(&self->archive->archive, ENOMEM,
+ "Can't allocate data for zstd decompression");
+ return (ARCHIVE_FATAL);
+ }
+
+ self->data = state;
+
+ state->out_block_size = out_block_size;
+ state->out_block = out_block;
+ state->dstream = dstream;
+ self->read = zstd_filter_read;
+ self->skip = NULL; /* not supported */
+ self->close = zstd_filter_close;
+
+ state->eof = 0;
+ state->in_frame = 0;
+
+ return (ARCHIVE_OK);
+}
+
+static ssize_t
+zstd_filter_read(struct archive_read_filter *self, const void **p)
+{
+ struct private_data *state;
+ size_t decompressed;
+ ssize_t avail_in;
+ ZSTD_outBuffer out;
+ ZSTD_inBuffer in;
+
+ state = (struct private_data *)self->data;
+
+ out = (ZSTD_outBuffer) { state->out_block, state->out_block_size, 0 };
+
+ /* Try to fill the output buffer. */
+ while (out.pos < out.size && !state->eof) {
+ if (!state->in_frame) {
+ const size_t ret = ZSTD_initDStream(state->dstream);
+ if (ZSTD_isError(ret)) {
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Error initializing zstd decompressor: %s",
+ ZSTD_getErrorName(ret));
+ return (ARCHIVE_FATAL);
+ }
+ }
+ in.src = __archive_read_filter_ahead(self->upstream, 1,
+ &avail_in);
+ if (avail_in < 0) {
+ return avail_in;
+ }
+ if (in.src == NULL && avail_in == 0) {
+ if (!state->in_frame) {
+ /* end of stream */
+ state->eof = 1;
+ break;
+ } else {
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Truncated zstd input");
+ return (ARCHIVE_FATAL);
+ }
+ }
+ in.size = avail_in;
+ in.pos = 0;
+
+ {
+ const size_t ret =
+ ZSTD_decompressStream(state->dstream, &out, &in);
+
+ if (ZSTD_isError(ret)) {
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Zstd decompression failed: %s",
+ ZSTD_getErrorName(ret));
+ return (ARCHIVE_FATAL);
+ }
+
+ /* Decompressor made some progress */
+ __archive_read_filter_consume(self->upstream, in.pos);
+
+ /* ret guaranteed to be > 0 if frame isn't done yet */
+ state->in_frame = (ret != 0);
+ }
+ }
+
+ decompressed = out.pos;
+ state->total_out += decompressed;
+ if (decompressed == 0)
+ *p = NULL;
+ else
+ *p = state->out_block;
+ return (decompressed);
+}
+
+/*
+ * Clean up the decompressor.
+ */
+static int
+zstd_filter_close(struct archive_read_filter *self)
+{
+ struct private_data *state;
+
+ state = (struct private_data *)self->data;
+
+ ZSTD_freeDStream(state->dstream);
+ free(state->out_block);
+ free(state);
+
+ return (ARCHIVE_OK);
+}
+
+#endif /* HAVE_ZLIB_H && HAVE_LIBZSTD */
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
index 96774f4e3..a885a4c45 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
@@ -975,18 +975,6 @@ decode_codec_id(const unsigned char *codecId, size_t id_size)
return (id);
}
-static void *
-ppmd_alloc(void *p, size_t size)
-{
- (void)p;
- return malloc(size);
-}
-static void
-ppmd_free(void *p, void *address)
-{
- (void)p;
- free(address);
-}
static Byte
ppmd_read(void *p)
{
@@ -1006,8 +994,6 @@ ppmd_read(void *p)
return (b);
}
-static ISzAlloc g_szalloc = { ppmd_alloc, ppmd_free };
-
static int
init_decompression(struct archive_read *a, struct _7zip *zip,
const struct _7z_coder *coder1, const struct _7z_coder *coder2)
@@ -1237,7 +1223,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
if (zip->ppmd7_valid) {
__archive_ppmd7_functions.Ppmd7_Free(
- &zip->ppmd7_context, &g_szalloc);
+ &zip->ppmd7_context);
zip->ppmd7_valid = 0;
}
@@ -1256,7 +1242,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
}
__archive_ppmd7_functions.Ppmd7_Construct(&zip->ppmd7_context);
r = __archive_ppmd7_functions.Ppmd7_Alloc(
- &zip->ppmd7_context, msize, &g_szalloc);
+ &zip->ppmd7_context, msize);
if (r == 0) {
archive_set_error(&a->archive, ENOMEM,
"Coludn't allocate memory for PPMd");
@@ -1636,7 +1622,7 @@ free_decompression(struct archive_read *a, struct _7zip *zip)
#endif
if (zip->ppmd7_valid) {
__archive_ppmd7_functions.Ppmd7_Free(
- &zip->ppmd7_context, &g_szalloc);
+ &zip->ppmd7_context);
zip->ppmd7_valid = 0;
}
return (r);
@@ -2569,6 +2555,7 @@ read_Header(struct archive_read *a, struct _7z_header_info *h,
case kDummy:
if (ll == 0)
break;
+ __LA_FALLTHROUGH;
default:
if (header_bytes(a, ll) == NULL)
return (-1);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c
index 20eb157f2..51f79fa6b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c
@@ -116,19 +116,11 @@ struct lzx_dec {
* coding tree, which is a binary tree. But a use of a large
* index table causes L1 cache read miss many times.
*/
-#define HTBL_BITS 10
int max_bits;
- int shift_bits;
int tbl_bits;
int tree_used;
- int tree_avail;
/* Direct access table. */
uint16_t *tbl;
- /* Binary tree table for extra bits over the direct access. */
- struct htree_t {
- uint16_t left;
- uint16_t right;
- } *tree;
} at, lt, mt, pt;
int loop;
@@ -187,7 +179,7 @@ struct lzx_stream {
#define CFDATA_cbData 4
#define CFDATA_cbUncomp 6
-static const char *compression_name[] = {
+static const char * const compression_name[] = {
"NONE",
"MSZIP",
"Quantum",
@@ -352,7 +344,6 @@ static int lzx_huffman_init(struct huffman *, size_t, int);
static void lzx_huffman_free(struct huffman *);
static int lzx_make_huffman_table(struct huffman *);
static inline int lzx_decode_huffman(struct huffman *, unsigned);
-static int lzx_decode_huffman_tree(struct huffman *, unsigned, int);
int
@@ -3127,7 +3118,6 @@ getdata:
static int
lzx_huffman_init(struct huffman *hf, size_t len_size, int tbl_bits)
{
- int bits;
if (hf->bitlen == NULL || hf->len_size != (int)len_size) {
free(hf->bitlen);
@@ -3138,21 +3128,11 @@ lzx_huffman_init(struct huffman *hf, size_t len_size, int tbl_bits)
} else
memset(hf->bitlen, 0, len_size * sizeof(hf->bitlen[0]));
if (hf->tbl == NULL) {
- if (tbl_bits < HTBL_BITS)
- bits = tbl_bits;
- else
- bits = HTBL_BITS;
- hf->tbl = malloc(((size_t)1 << bits) * sizeof(hf->tbl[0]));
+ hf->tbl = malloc(((size_t)1 << tbl_bits) * sizeof(hf->tbl[0]));
if (hf->tbl == NULL)
return (ARCHIVE_FATAL);
hf->tbl_bits = tbl_bits;
}
- if (hf->tree == NULL && tbl_bits > HTBL_BITS) {
- hf->tree_avail = 1 << (tbl_bits - HTBL_BITS + 4);
- hf->tree = malloc(hf->tree_avail * sizeof(hf->tree[0]));
- if (hf->tree == NULL)
- return (ARCHIVE_FATAL);
- }
return (ARCHIVE_OK);
}
@@ -3161,7 +3141,6 @@ lzx_huffman_free(struct huffman *hf)
{
free(hf->bitlen);
free(hf->tbl);
- free(hf->tree);
}
/*
@@ -3174,7 +3153,7 @@ lzx_make_huffman_table(struct huffman *hf)
const unsigned char *bitlen;
int bitptn[17], weight[17];
int i, maxbits = 0, ptn, tbl_size, w;
- int diffbits, len_avail;
+ int len_avail;
/*
* Initialize bit patterns.
@@ -3205,28 +3184,11 @@ lzx_make_huffman_table(struct huffman *hf)
weight[i] >>= ebits;
}
}
- if (maxbits > HTBL_BITS) {
- int htbl_max;
- uint16_t *p;
-
- diffbits = maxbits - HTBL_BITS;
- for (i = 1; i <= HTBL_BITS; i++) {
- bitptn[i] >>= diffbits;
- weight[i] >>= diffbits;
- }
- htbl_max = bitptn[HTBL_BITS] +
- weight[HTBL_BITS] * hf->freq[HTBL_BITS];
- p = &(hf->tbl[htbl_max]);
- while (p < &hf->tbl[1U<<HTBL_BITS])
- *p++ = 0;
- } else
- diffbits = 0;
- hf->shift_bits = diffbits;
/*
* Make the table.
*/
- tbl_size = 1 << HTBL_BITS;
+ tbl_size = 1 << hf->tbl_bits;
tbl = hf->tbl;
bitlen = hf->bitlen;
len_avail = hf->len_size;
@@ -3234,120 +3196,32 @@ lzx_make_huffman_table(struct huffman *hf)
for (i = 0; i < len_avail; i++) {
uint16_t *p;
int len, cnt;
- uint16_t bit;
- int extlen;
- struct htree_t *ht;
if (bitlen[i] == 0)
continue;
/* Get a bit pattern */
len = bitlen[i];
+ if (len > tbl_size)
+ return (0);
ptn = bitptn[len];
cnt = weight[len];
- if (len <= HTBL_BITS) {
- /* Calculate next bit pattern */
- if ((bitptn[len] = ptn + cnt) > tbl_size)
- return (0);/* Invalid */
- /* Update the table */
- p = &(tbl[ptn]);
- while (--cnt >= 0)
- p[cnt] = (uint16_t)i;
- continue;
- }
-
- /*
- * A bit length is too big to be housed to a direct table,
- * so we use a tree model for its extra bits.
- */
- bitptn[len] = ptn + cnt;
- bit = 1U << (diffbits -1);
- extlen = len - HTBL_BITS;
-
- p = &(tbl[ptn >> diffbits]);
- if (*p == 0) {
- *p = len_avail + hf->tree_used;
- ht = &(hf->tree[hf->tree_used++]);
- if (hf->tree_used > hf->tree_avail)
- return (0);/* Invalid */
- ht->left = 0;
- ht->right = 0;
- } else {
- if (*p < len_avail ||
- *p >= (len_avail + hf->tree_used))
- return (0);/* Invalid */
- ht = &(hf->tree[*p - len_avail]);
- }
- while (--extlen > 0) {
- if (ptn & bit) {
- if (ht->left < len_avail) {
- ht->left = len_avail + hf->tree_used;
- ht = &(hf->tree[hf->tree_used++]);
- if (hf->tree_used > hf->tree_avail)
- return (0);/* Invalid */
- ht->left = 0;
- ht->right = 0;
- } else {
- ht = &(hf->tree[ht->left - len_avail]);
- }
- } else {
- if (ht->right < len_avail) {
- ht->right = len_avail + hf->tree_used;
- ht = &(hf->tree[hf->tree_used++]);
- if (hf->tree_used > hf->tree_avail)
- return (0);/* Invalid */
- ht->left = 0;
- ht->right = 0;
- } else {
- ht = &(hf->tree[ht->right - len_avail]);
- }
- }
- bit >>= 1;
- }
- if (ptn & bit) {
- if (ht->left != 0)
- return (0);/* Invalid */
- ht->left = (uint16_t)i;
- } else {
- if (ht->right != 0)
- return (0);/* Invalid */
- ht->right = (uint16_t)i;
- }
+ /* Calculate next bit pattern */
+ if ((bitptn[len] = ptn + cnt) > tbl_size)
+ return (0);/* Invalid */
+ /* Update the table */
+ p = &(tbl[ptn]);
+ while (--cnt >= 0)
+ p[cnt] = (uint16_t)i;
}
return (1);
}
-static int
-lzx_decode_huffman_tree(struct huffman *hf, unsigned rbits, int c)
-{
- struct htree_t *ht;
- int extlen;
-
- ht = hf->tree;
- extlen = hf->shift_bits;
- while (c >= hf->len_size) {
- c -= hf->len_size;
- if (extlen-- <= 0 || c >= hf->tree_used)
- return (0);
- if (rbits & (1U << extlen))
- c = ht[c].left;
- else
- c = ht[c].right;
- }
- return (c);
-}
-
static inline int
lzx_decode_huffman(struct huffman *hf, unsigned rbits)
{
int c;
- /*
- * At first search an index table for a bit pattern.
- * If it fails, search a huffman tree for.
- */
- c = hf->tbl[rbits >> hf->shift_bits];
+ c = hf->tbl[rbits];
if (c < hf->len_size)
return (c);
- /* This bit pattern needs to be found out at a huffman tree. */
- return (lzx_decode_huffman_tree(hf, rbits, c));
+ return (0);
}
-
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
index ffd4a8580..67d5b21ee 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
@@ -165,7 +165,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_cpio.c 20116
struct links_entry {
struct links_entry *next;
struct links_entry *previous;
- int links;
+ unsigned int links;
dev_t dev;
int64_t ino;
char *name;
@@ -633,6 +633,13 @@ header_newc(struct archive_read *a, struct cpio *cpio,
/* Pad name to 2 more than a multiple of 4. */
*name_pad = (2 - *namelength) & 3;
+ /* Make sure that the padded name length fits into size_t. */
+ if (*name_pad > SIZE_MAX - *namelength) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "cpio archive has invalid namelength");
+ return (ARCHIVE_FATAL);
+ }
+
/*
* Note: entry_bytes_remaining is at least 64 bits and
* therefore guaranteed to be big enough for a 33-bit file
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
index 354133005..93649f862 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
@@ -409,7 +409,8 @@ static int next_entry_seek(struct archive_read *, struct iso9660 *,
struct file_info **);
static struct file_info *
parse_file_info(struct archive_read *a,
- struct file_info *parent, const unsigned char *isodirrec);
+ struct file_info *parent, const unsigned char *isodirrec,
+ size_t reclen);
static int parse_rockridge(struct archive_read *a,
struct file_info *file, const unsigned char *start,
const unsigned char *end);
@@ -1022,7 +1023,7 @@ read_children(struct archive_read *a, struct file_info *parent)
if (*(p + DR_name_len_offset) == 1
&& *(p + DR_name_offset) == '\001')
continue;
- child = parse_file_info(a, parent, p);
+ child = parse_file_info(a, parent, p, b - p);
if (child == NULL) {
__archive_read_consume(a, skip_size);
return (ARCHIVE_FATAL);
@@ -1112,7 +1113,7 @@ choose_volume(struct archive_read *a, struct iso9660 *iso9660)
*/
seenJoliet = iso9660->seenJoliet;/* Save flag. */
iso9660->seenJoliet = 0;
- file = parse_file_info(a, NULL, block);
+ file = parse_file_info(a, NULL, block, vd->size);
if (file == NULL)
return (ARCHIVE_FATAL);
iso9660->seenJoliet = seenJoliet;
@@ -1144,7 +1145,7 @@ choose_volume(struct archive_read *a, struct iso9660 *iso9660)
return (ARCHIVE_FATAL);
}
iso9660->seenJoliet = 0;
- file = parse_file_info(a, NULL, block);
+ file = parse_file_info(a, NULL, block, vd->size);
if (file == NULL)
return (ARCHIVE_FATAL);
iso9660->seenJoliet = seenJoliet;
@@ -1749,7 +1750,7 @@ archive_read_format_iso9660_cleanup(struct archive_read *a)
*/
static struct file_info *
parse_file_info(struct archive_read *a, struct file_info *parent,
- const unsigned char *isodirrec)
+ const unsigned char *isodirrec, size_t reclen)
{
struct iso9660 *iso9660;
struct file_info *file, *filep;
@@ -1763,16 +1764,20 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
iso9660 = (struct iso9660 *)(a->format->data);
- dr_len = (size_t)isodirrec[DR_length_offset];
- name_len = (size_t)isodirrec[DR_name_len_offset];
- location = archive_le32dec(isodirrec + DR_extent_offset);
- fsize = toi(isodirrec + DR_size_offset, DR_size_size);
- /* Sanity check that dr_len needs at least 34. */
- if (dr_len < 34) {
+ if (reclen != 0)
+ dr_len = (size_t)isodirrec[DR_length_offset];
+ /*
+ * Sanity check that reclen is not zero and dr_len is greater than
+ * reclen but at least 34
+ */
+ if (reclen == 0 || reclen < dr_len || dr_len < 34) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Invalid length of directory record");
+ "Invalid length of directory record");
return (NULL);
}
+ name_len = (size_t)isodirrec[DR_name_len_offset];
+ location = archive_le32dec(isodirrec + DR_extent_offset);
+ fsize = toi(isodirrec + DR_size_offset, DR_size_size);
/* Sanity check that name_len doesn't exceed dr_len. */
if (dr_len - 33 < name_len || name_len == 0) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
@@ -3021,8 +3026,9 @@ heap_add_entry(struct archive_read *a, struct heap_queue *heap,
ENOMEM, "Out of memory");
return (ARCHIVE_FATAL);
}
- memcpy(new_pending_files, heap->files,
- heap->allocated * sizeof(new_pending_files[0]));
+ if (heap->allocated)
+ memcpy(new_pending_files, heap->files,
+ heap->allocated * sizeof(new_pending_files[0]));
if (heap->files != NULL)
free(heap->files);
heap->files = new_pending_files;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c
index ebd7f2ccb..98d02c62d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c
@@ -701,6 +701,12 @@ archive_read_format_lha_read_header(struct archive_read *a,
* Prepare variables used to read a file content.
*/
lha->entry_bytes_remaining = lha->compsize;
+ if (lha->entry_bytes_remaining < 0) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Invalid LHa entry size");
+ return (ARCHIVE_FATAL);
+ }
lha->entry_offset = 0;
lha->entry_crc_calculated = 0;
@@ -2480,7 +2486,7 @@ lzh_huffman_free(struct huffman *hf)
free(hf->tree);
}
-static char bitlen_tbl[0x400] = {
+static const char bitlen_tbl[0x400] = {
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
index 4231ff500..5b0eadc08 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_mtree.c 2011
#include "archive.h"
#include "archive_entry.h"
#include "archive_private.h"
+#include "archive_rb.h"
#include "archive_read_private.h"
#include "archive_string.h"
#include "archive_pack_dev.h"
@@ -75,7 +76,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_mtree.c 2011
#define MTREE_HAS_OPTIONAL 0x0800
#define MTREE_HAS_NOCHANGE 0x1000 /* FreeBSD specific */
-#define MTREE_HASHTABLE_SIZE 1024
+#define MAX_LINE_LEN (1024 * 1024)
struct mtree_option {
struct mtree_option *next;
@@ -83,13 +84,13 @@ struct mtree_option {
};
struct mtree_entry {
+ struct archive_rb_node rbnode;
+ struct mtree_entry *next_dup;
struct mtree_entry *next;
struct mtree_option *options;
char *name;
char full;
char used;
- unsigned int name_hash;
- struct mtree_entry *hashtable_next;
};
struct mtree {
@@ -102,11 +103,12 @@ struct mtree {
const char *archive_format_name;
struct mtree_entry *entries;
struct mtree_entry *this_entry;
- struct mtree_entry *entry_hashtable[MTREE_HASHTABLE_SIZE];
+ struct archive_rb_tree entry_rbtree;
struct archive_string current_dir;
struct archive_string contents_name;
struct archive_entry_linkresolver *resolver;
+ struct archive_rb_tree rbtree;
int64_t cur_size;
char checkfs;
@@ -115,7 +117,6 @@ struct mtree {
static int bid_keycmp(const char *, const char *, ssize_t);
static int cleanup(struct archive_read *);
static int detect_form(struct archive_read *, int *);
-static unsigned int hash(const char *);
static int mtree_bid(struct archive_read *, int);
static int parse_file(struct archive_read *, struct archive_entry *,
struct mtree *, struct mtree_entry *, int *);
@@ -130,9 +131,7 @@ static ssize_t readline(struct archive_read *, struct mtree *, char **, ssize_t)
static int skip(struct archive_read *a);
static int read_header(struct archive_read *,
struct archive_entry *);
-static int64_t mtree_atol10(char **);
-static int64_t mtree_atol8(char **);
-static int64_t mtree_atol(char **);
+static int64_t mtree_atol(char **, int base);
/*
* There's no standard for TIME_T_MAX/TIME_T_MIN. So we compute them
@@ -219,9 +218,30 @@ free_options(struct mtree_option *head)
}
}
+static int
+mtree_cmp_node(const struct archive_rb_node *n1,
+ const struct archive_rb_node *n2)
+{
+ const struct mtree_entry *e1 = (const struct mtree_entry *)n1;
+ const struct mtree_entry *e2 = (const struct mtree_entry *)n2;
+
+ return (strcmp(e1->name, e2->name));
+}
+
+static int
+mtree_cmp_key(const struct archive_rb_node *n, const void *key)
+{
+ const struct mtree_entry *e = (const struct mtree_entry *)n;
+
+ return (strcmp(e->name, key));
+}
+
int
archive_read_support_format_mtree(struct archive *_a)
{
+ static const struct archive_rb_tree_ops rb_ops = {
+ mtree_cmp_node, mtree_cmp_key,
+ };
struct archive_read *a = (struct archive_read *)_a;
struct mtree *mtree;
int r;
@@ -237,6 +257,8 @@ archive_read_support_format_mtree(struct archive *_a)
}
mtree->fd = -1;
+ __archive_rb_tree_init(&mtree->rbtree, &rb_ops);
+
r = __archive_read_register_format(a, mtree, "mtree",
mtree_bid, archive_read_format_mtree_options, read_header, read_data, skip, NULL, cleanup, NULL, NULL);
@@ -336,6 +358,14 @@ next_line(struct archive_read *a,
size_t nbytes_req = (*ravail+1023) & ~1023U;
ssize_t tested;
+ /*
+ * Place an arbitrary limit on the line length.
+ * mtree is almost free-form input and without line length limits,
+ * it can consume a lot of memory.
+ */
+ if (len >= MAX_LINE_LEN)
+ return (-1);
+
/* Increase reading bytes if it is not enough to at least
* new two lines. */
if (nbytes_req < (size_t)*ravail + 160)
@@ -399,41 +429,41 @@ bid_keycmp(const char *p, const char *key, ssize_t len)
static int
bid_keyword(const char *p, ssize_t len)
{
- static const char *keys_c[] = {
+ static const char * const keys_c[] = {
"content", "contents", "cksum", NULL
};
- static const char *keys_df[] = {
+ static const char * const keys_df[] = {
"device", "flags", NULL
};
- static const char *keys_g[] = {
+ static const char * const keys_g[] = {
"gid", "gname", NULL
};
- static const char *keys_il[] = {
+ static const char * const keys_il[] = {
"ignore", "inode", "link", NULL
};
- static const char *keys_m[] = {
+ static const char * const keys_m[] = {
"md5", "md5digest", "mode", NULL
};
- static const char *keys_no[] = {
+ static const char * const keys_no[] = {
"nlink", "nochange", "optional", NULL
};
- static const char *keys_r[] = {
+ static const char * const keys_r[] = {
"resdevice", "rmd160", "rmd160digest", NULL
};
- static const char *keys_s[] = {
+ static const char * const keys_s[] = {
"sha1", "sha1digest",
"sha256", "sha256digest",
"sha384", "sha384digest",
"sha512", "sha512digest",
"size", NULL
};
- static const char *keys_t[] = {
+ static const char * const keys_t[] = {
"tags", "time", "type", NULL
};
- static const char *keys_u[] = {
+ static const char * const keys_u[] = {
"uid", "uname", NULL
};
- const char **keys;
+ const char * const *keys;
int i;
switch (*p) {
@@ -867,12 +897,11 @@ process_add_entry(struct archive_read *a, struct mtree *mtree,
struct mtree_option **global, const char *line, ssize_t line_len,
struct mtree_entry **last_entry, int is_form_d)
{
- struct mtree_entry *entry, *ht_iter;
+ struct mtree_entry *entry;
struct mtree_option *iter;
const char *next, *eq, *name, *end;
size_t name_len, len;
int r, i;
- unsigned int ht_idx;
if ((entry = malloc(sizeof(*entry))) == NULL) {
archive_set_error(&a->archive, errno, "Can't allocate memory");
@@ -883,8 +912,6 @@ process_add_entry(struct archive_read *a, struct mtree *mtree,
entry->name = NULL;
entry->used = 0;
entry->full = 0;
- entry->name_hash = 0;
- entry->hashtable_next = NULL;
/* Add this entry to list. */
if (*last_entry == NULL)
@@ -937,15 +964,17 @@ process_add_entry(struct archive_read *a, struct mtree *mtree,
memcpy(entry->name, name, name_len);
entry->name[name_len] = '\0';
parse_escapes(entry->name, entry);
- entry->name_hash = hash(entry->name);
- ht_idx = entry->name_hash % MTREE_HASHTABLE_SIZE;
- if ((ht_iter = mtree->entry_hashtable[ht_idx]) != NULL) {
- while (ht_iter->hashtable_next)
- ht_iter = ht_iter->hashtable_next;
- ht_iter->hashtable_next = entry;
- } else {
- mtree->entry_hashtable[ht_idx] = entry;
+ entry->next_dup = NULL;
+ if (entry->full) {
+ if (!__archive_rb_tree_insert_node(&mtree->rbtree, &entry->rbnode)) {
+ struct mtree_entry *alt;
+ alt = (struct mtree_entry *)__archive_rb_tree_find_node(
+ &mtree->rbtree, entry->name);
+ while (alt->next_dup)
+ alt = alt->next_dup;
+ alt->next_dup = entry;
+ }
}
for (iter = *global; iter != NULL; iter = iter->next) {
@@ -1140,14 +1169,13 @@ parse_file(struct archive_read *a, struct archive_entry *entry,
* with pathname canonicalization, which is a very
* tricky subject.)
*/
- for (mp = mentry->hashtable_next; mp != NULL; mp = mp->hashtable_next) {
- if (mp->full && !mp->used
- && mentry->name_hash == mp->name_hash
- && strcmp(mentry->name, mp->name) == 0) {
+ mp = (struct mtree_entry *)__archive_rb_tree_find_node(
+ &mtree->rbtree, mentry->name);
+ for (; mp; mp = mp->next_dup) {
+ if (mp->full && !mp->used) {
/* Later lines override earlier ones. */
mp->used = 1;
- r1 = parse_line(a, entry, mtree, mp,
- &parsed_kws);
+ r1 = parse_line(a, entry, mtree, mp, &parsed_kws);
if (r1 < r)
r = r1;
}
@@ -1418,7 +1446,7 @@ parse_device(dev_t *pdev, struct archive *a, char *val)
"Too many arguments");
return ARCHIVE_WARN;
}
- numbers[argc++] = (unsigned long)mtree_atol(&p);
+ numbers[argc++] = (unsigned long)mtree_atol(&p, 0);
}
if (argc < 2) {
archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
@@ -1433,7 +1461,7 @@ parse_device(dev_t *pdev, struct archive *a, char *val)
}
} else {
/* file system raw value. */
- result = (dev_t)mtree_atol(&val);
+ result = (dev_t)mtree_atol(&val, 0);
}
*pdev = result;
return ARCHIVE_OK;
@@ -1491,6 +1519,7 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
}
if (strcmp(key, "cksum") == 0)
break;
+ __LA_FALLTHROUGH;
case 'd':
if (strcmp(key, "device") == 0) {
/* stat(2) st_rdev field, e.g. the major/minor IDs
@@ -1504,16 +1533,18 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
archive_entry_set_rdev(entry, dev);
return r;
}
+ __LA_FALLTHROUGH;
case 'f':
if (strcmp(key, "flags") == 0) {
*parsed_kws |= MTREE_HAS_FFLAGS;
archive_entry_copy_fflags_text(entry, val);
break;
}
+ __LA_FALLTHROUGH;
case 'g':
if (strcmp(key, "gid") == 0) {
*parsed_kws |= MTREE_HAS_GID;
- archive_entry_set_gid(entry, mtree_atol10(&val));
+ archive_entry_set_gid(entry, mtree_atol(&val, 10));
break;
}
if (strcmp(key, "gname") == 0) {
@@ -1521,39 +1552,44 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
archive_entry_copy_gname(entry, val);
break;
}
+ __LA_FALLTHROUGH;
case 'i':
if (strcmp(key, "inode") == 0) {
- archive_entry_set_ino(entry, mtree_atol10(&val));
+ archive_entry_set_ino(entry, mtree_atol(&val, 10));
break;
}
+ __LA_FALLTHROUGH;
case 'l':
if (strcmp(key, "link") == 0) {
archive_entry_copy_symlink(entry, val);
break;
}
+ __LA_FALLTHROUGH;
case 'm':
if (strcmp(key, "md5") == 0 || strcmp(key, "md5digest") == 0)
break;
if (strcmp(key, "mode") == 0) {
- if (val[0] >= '0' && val[0] <= '9') {
+ if (val[0] >= '0' && val[0] <= '7') {
*parsed_kws |= MTREE_HAS_PERM;
archive_entry_set_perm(entry,
- (mode_t)mtree_atol8(&val));
+ (mode_t)mtree_atol(&val, 8));
} else {
archive_set_error(&a->archive,
ARCHIVE_ERRNO_FILE_FORMAT,
- "Symbolic mode \"%s\" unsupported", val);
+ "Symbolic or non-octal mode \"%s\" unsupported", val);
return ARCHIVE_WARN;
}
break;
}
+ __LA_FALLTHROUGH;
case 'n':
if (strcmp(key, "nlink") == 0) {
*parsed_kws |= MTREE_HAS_NLINK;
archive_entry_set_nlink(entry,
- (unsigned int)mtree_atol10(&val));
+ (unsigned int)mtree_atol(&val, 10));
break;
}
+ __LA_FALLTHROUGH;
case 'r':
if (strcmp(key, "resdevice") == 0) {
/* stat(2) st_dev field, e.g. the device ID where the
@@ -1569,6 +1605,7 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
if (strcmp(key, "rmd160") == 0 ||
strcmp(key, "rmd160digest") == 0)
break;
+ __LA_FALLTHROUGH;
case 's':
if (strcmp(key, "sha1") == 0 || strcmp(key, "sha1digest") == 0)
break;
@@ -1582,9 +1619,10 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
strcmp(key, "sha512digest") == 0)
break;
if (strcmp(key, "size") == 0) {
- archive_entry_set_size(entry, mtree_atol10(&val));
+ archive_entry_set_size(entry, mtree_atol(&val, 10));
break;
}
+ __LA_FALLTHROUGH;
case 't':
if (strcmp(key, "tags") == 0) {
/*
@@ -1601,13 +1639,13 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
long ns = 0;
*parsed_kws |= MTREE_HAS_MTIME;
- m = mtree_atol10(&val);
+ m = mtree_atol(&val, 10);
/* Replicate an old mtree bug:
* 123456789.1 represents 123456789
* seconds and 1 nanosecond. */
if (*val == '.') {
++val;
- ns = (long)mtree_atol10(&val);
+ ns = (long)mtree_atol(&val, 10);
if (ns < 0)
ns = 0;
else if (ns > 999999999)
@@ -1627,18 +1665,21 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
archive_entry_set_filetype(entry, AE_IFBLK);
break;
}
+ __LA_FALLTHROUGH;
case 'c':
if (strcmp(val, "char") == 0) {
archive_entry_set_filetype(entry,
AE_IFCHR);
break;
}
+ __LA_FALLTHROUGH;
case 'd':
if (strcmp(val, "dir") == 0) {
archive_entry_set_filetype(entry,
AE_IFDIR);
break;
}
+ __LA_FALLTHROUGH;
case 'f':
if (strcmp(val, "fifo") == 0) {
archive_entry_set_filetype(entry,
@@ -1650,12 +1691,14 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
AE_IFREG);
break;
}
+ __LA_FALLTHROUGH;
case 'l':
if (strcmp(val, "link") == 0) {
archive_entry_set_filetype(entry,
AE_IFLNK);
break;
}
+ __LA_FALLTHROUGH;
default:
archive_set_error(&a->archive,
ARCHIVE_ERRNO_FILE_FORMAT,
@@ -1667,10 +1710,11 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
*parsed_kws |= MTREE_HAS_TYPE;
break;
}
+ __LA_FALLTHROUGH;
case 'u':
if (strcmp(key, "uid") == 0) {
*parsed_kws |= MTREE_HAS_UID;
- archive_entry_set_uid(entry, mtree_atol10(&val));
+ archive_entry_set_uid(entry, mtree_atol(&val, 10));
break;
}
if (strcmp(key, "uname") == 0) {
@@ -1678,6 +1722,7 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
archive_entry_copy_uname(entry, val);
break;
}
+ __LA_FALLTHROUGH;
default:
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Unrecognized key %s=%s", key, val);
@@ -1825,72 +1870,9 @@ parse_escapes(char *src, struct mtree_entry *mentry)
*dest = '\0';
}
-/*
- * Note that this implementation does not (and should not!) obey
- * locale settings; you cannot simply substitute strtol here, since
- * it does obey locale.
- */
-static int64_t
-mtree_atol8(char **p)
-{
- int64_t l, limit, last_digit_limit;
- int digit, base;
-
- base = 8;
- limit = INT64_MAX / base;
- last_digit_limit = INT64_MAX % base;
-
- l = 0;
- digit = **p - '0';
- while (digit >= 0 && digit < base) {
- if (l>limit || (l == limit && digit > last_digit_limit)) {
- l = INT64_MAX; /* Truncate on overflow. */
- break;
- }
- l = (l * base) + digit;
- digit = *++(*p) - '0';
- }
- return (l);
-}
-
-/*
- * Note that this implementation does not (and should not!) obey
- * locale settings; you cannot simply substitute strtol here, since
- * it does obey locale.
- */
-static int64_t
-mtree_atol10(char **p)
-{
- int64_t l, limit, last_digit_limit;
- int base, digit, sign;
-
- base = 10;
-
- if (**p == '-') {
- sign = -1;
- limit = ((uint64_t)(INT64_MAX) + 1) / base;
- last_digit_limit = ((uint64_t)(INT64_MAX) + 1) % base;
- ++(*p);
- } else {
- sign = 1;
- limit = INT64_MAX / base;
- last_digit_limit = INT64_MAX % base;
- }
-
- l = 0;
- digit = **p - '0';
- while (digit >= 0 && digit < base) {
- if (l > limit || (l == limit && digit > last_digit_limit))
- return (sign < 0) ? INT64_MIN : INT64_MAX;
- l = (l * base) + digit;
- digit = *++(*p) - '0';
- }
- return (sign < 0) ? -l : l;
-}
-
/* Parse a hex digit. */
static int
-parsehex(char c)
+parsedigit(char c)
{
if (c >= '0' && c <= '9')
return c - '0';
@@ -1908,45 +1890,50 @@ parsehex(char c)
* it does obey locale.
*/
static int64_t
-mtree_atol16(char **p)
+mtree_atol(char **p, int base)
{
- int64_t l, limit, last_digit_limit;
- int base, digit, sign;
-
- base = 16;
+ int64_t l, limit;
+ int digit, last_digit_limit;
+
+ if (base == 0) {
+ if (**p != '0')
+ base = 10;
+ else if ((*p)[1] == 'x' || (*p)[1] == 'X') {
+ *p += 2;
+ base = 16;
+ } else {
+ base = 8;
+ }
+ }
if (**p == '-') {
- sign = -1;
- limit = ((uint64_t)(INT64_MAX) + 1) / base;
- last_digit_limit = ((uint64_t)(INT64_MAX) + 1) % base;
+ limit = INT64_MIN / base;
+ last_digit_limit = INT64_MIN % base;
++(*p);
+
+ l = 0;
+ digit = parsedigit(**p);
+ while (digit >= 0 && digit < base) {
+ if (l < limit || (l == limit && digit > last_digit_limit))
+ return INT64_MIN;
+ l = (l * base) - digit;
+ digit = parsedigit(*++(*p));
+ }
+ return l;
} else {
- sign = 1;
limit = INT64_MAX / base;
last_digit_limit = INT64_MAX % base;
- }
-
- l = 0;
- digit = parsehex(**p);
- while (digit >= 0 && digit < base) {
- if (l > limit || (l == limit && digit > last_digit_limit))
- return (sign < 0) ? INT64_MIN : INT64_MAX;
- l = (l * base) + digit;
- digit = parsehex(*++(*p));
- }
- return (sign < 0) ? -l : l;
-}
-static int64_t
-mtree_atol(char **p)
-{
- if (**p != '0')
- return mtree_atol10(p);
- if ((*p)[1] == 'x' || (*p)[1] == 'X') {
- *p += 2;
- return mtree_atol16(p);
+ l = 0;
+ digit = parsedigit(**p);
+ while (digit >= 0 && digit < base) {
+ if (l > limit || (l == limit && digit > last_digit_limit))
+ return INT64_MAX;
+ l = (l * base) + digit;
+ digit = parsedigit(*++(*p));
+ }
+ return l;
}
- return mtree_atol8(p);
}
/*
@@ -2022,19 +2009,3 @@ readline(struct archive_read *a, struct mtree *mtree, char **start,
find_off = u - mtree->line.s;
}
}
-
-static unsigned int
-hash(const char *p)
-{
- /* A 32-bit version of Peter Weinberger's (PJW) hash algorithm,
- as used by ELF for hashing function names. */
- unsigned g, h = 0;
- while (*p != '\0') {
- h = (h << 4) + *p++;
- if ((g = h & 0xF0000000) != 0) {
- h ^= g >> 24;
- h &= 0x0FFFFFFF;
- }
- }
- return h;
-}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
index 658d49d50..c68d77b49 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
@@ -604,20 +604,6 @@ lzss_emit_match(struct rar *rar, int offset, int length)
rar->lzss.position += length;
}
-static void *
-ppmd_alloc(void *p, size_t size)
-{
- (void)p;
- return malloc(size);
-}
-static void
-ppmd_free(void *p, void *address)
-{
- (void)p;
- free(address);
-}
-static ISzAlloc g_szalloc = { ppmd_alloc, ppmd_free };
-
static Byte
ppmd_read(void *p)
{
@@ -1038,7 +1024,7 @@ archive_read_format_rar_read_data(struct archive_read *a, const void **buff,
case COMPRESS_METHOD_BEST:
ret = read_data_compressed(a, buff, size, offset);
if (ret != ARCHIVE_OK && ret != ARCHIVE_WARN)
- __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context, &g_szalloc);
+ __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context);
break;
default:
@@ -1253,7 +1239,7 @@ archive_read_format_rar_cleanup(struct archive_read *a)
free(rar->dbo);
free(rar->unp_buffer);
free(rar->lzss.window);
- __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context, &g_szalloc);
+ __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context);
free(rar);
(a->format->data) = NULL;
return (ARCHIVE_OK);
@@ -1496,7 +1482,11 @@ read_header(struct archive_read *a, struct archive_entry *entry,
return (ARCHIVE_FATAL);
}
filename[filename_size++] = '\0';
- filename[filename_size++] = '\0';
+ /*
+ * Do not increment filename_size here as the computations below
+ * add the space for the terminating NUL explicitly.
+ */
+ filename[filename_size] = '\0';
/* Decoded unicode form is UTF-16BE, so we have to update a string
* conversion object for it. */
@@ -1654,7 +1644,7 @@ read_header(struct archive_read *a, struct archive_entry *entry,
rar->unp_offset = 0;
rar->unp_buffer_size = UNP_BUFFER_SIZE;
memset(rar->lengthtable, 0, sizeof(rar->lengthtable));
- __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context, &g_szalloc);
+ __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context);
rar->ppmd_valid = rar->ppmd_eod = 0;
/* Don't set any archive entries for non-file header types */
@@ -1750,7 +1740,7 @@ read_exttime(const char *p, struct rar *rar, const char *endp)
return (-1);
for (j = 0; j < count; j++)
{
- rem = ((*p) << 16) | (rem >> 8);
+ rem = (((unsigned)(unsigned char)*p) << 16) | (rem >> 8);
p++;
}
tm = localtime(&t);
@@ -2118,7 +2108,7 @@ parse_codes(struct archive_read *a)
/* Make sure ppmd7_contest is freed before Ppmd7_Construct
* because reading a broken file cause this abnormal sequence. */
- __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context, &g_szalloc);
+ __archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context);
rar->bytein.a = a;
rar->bytein.Read = &ppmd_read;
@@ -2133,7 +2123,7 @@ parse_codes(struct archive_read *a)
}
if (!__archive_ppmd7_functions.Ppmd7_Alloc(&rar->ppmd7_context,
- rar->dictionary_size, &g_szalloc))
+ rar->dictionary_size))
{
archive_set_error(&a->archive, ENOMEM,
"Out of memory");
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
index bd7f13d52..60800bb81 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
@@ -155,6 +155,7 @@ struct tar {
int compat_2x;
int process_mac_extensions;
int read_concatenated_archives;
+ int realsize_override;
};
static int archive_block_is_null(const char *p);
@@ -250,15 +251,15 @@ archive_read_support_format_tar(struct archive *_a)
ARCHIVE_STATE_NEW, "archive_read_support_format_tar");
tar = (struct tar *)calloc(1, sizeof(*tar));
-#ifdef HAVE_COPYFILE_H
- /* Set this by default on Mac OS. */
- tar->process_mac_extensions = 1;
-#endif
if (tar == NULL) {
archive_set_error(&a->archive, ENOMEM,
"Can't allocate tar data");
return (ARCHIVE_FATAL);
}
+#ifdef HAVE_COPYFILE_H
+ /* Set this by default on Mac OS. */
+ tar->process_mac_extensions = 1;
+#endif
r = __archive_read_register_format(a, tar, "tar",
archive_read_format_tar_bid,
@@ -527,6 +528,7 @@ archive_read_format_tar_read_header(struct archive_read *a,
tar->entry_offset = 0;
gnu_clear_sparse_list(tar);
tar->realsize = -1; /* Mark this as "unset" */
+ tar->realsize_override = 0;
/* Setup default string conversion. */
tar->sconv = tar->opt_sconv;
@@ -1894,6 +1896,7 @@ pax_attribute(struct archive_read *a, struct tar *tar,
if (strcmp(key, "GNU.sparse.size") == 0) {
tar->realsize = tar_atol10(value, strlen(value));
archive_entry_set_size(entry, tar->realsize);
+ tar->realsize_override = 1;
}
/* GNU "0.1" sparse pax format. */
@@ -1925,6 +1928,7 @@ pax_attribute(struct archive_read *a, struct tar *tar,
if (strcmp(key, "GNU.sparse.realsize") == 0) {
tar->realsize = tar_atol10(value, strlen(value));
archive_entry_set_size(entry, tar->realsize);
+ tar->realsize_override = 1;
}
break;
case 'L':
@@ -1977,6 +1981,7 @@ pax_attribute(struct archive_read *a, struct tar *tar,
tar_atol10(value, strlen(value)));
} else if (strcmp(key, "SCHILY.realsize") == 0) {
tar->realsize = tar_atol10(value, strlen(value));
+ tar->realsize_override = 1;
archive_entry_set_size(entry, tar->realsize);
} else if (strncmp(key, "SCHILY.xattr.", 13) == 0) {
pax_attribute_schily_xattr(entry, key, value,
@@ -2055,14 +2060,12 @@ pax_attribute(struct archive_read *a, struct tar *tar,
tar->entry_bytes_remaining
= tar_atol10(value, strlen(value));
/*
- * But, "size" is not necessarily the size of
- * the file on disk; if this is a sparse file,
- * the disk size may have already been set from
- * GNU.sparse.realsize or GNU.sparse.size or
- * an old GNU header field or SCHILY.realsize
- * or ....
+ * The "size" pax header keyword always overrides the
+ * "size" field in the tar header.
+ * GNU.sparse.realsize, GNU.sparse.size and
+ * SCHILY.realsize override this value.
*/
- if (tar->realsize < 0) {
+ if (!tar->realsize_override) {
archive_entry_set_size(entry,
tar->entry_bytes_remaining);
tar->realsize
@@ -2206,6 +2209,7 @@ header_gnutar(struct archive_read *a, struct tar *tar,
tar->realsize
= tar_atol(header->realsize, sizeof(header->realsize));
archive_entry_set_size(entry, tar->realsize);
+ tar->realsize_override = 1;
}
if (header->sparse[0].offset[0] != 0) {
@@ -2237,7 +2241,7 @@ gnu_add_sparse_entry(struct archive_read *a, struct tar *tar,
else
tar->sparse_list = p;
tar->sparse_last = p;
- if (remaining < 0 || offset < 0) {
+ if (remaining < 0 || offset < 0 || offset > INT64_MAX - remaining) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Malformed sparse map data");
return (ARCHIVE_FATAL);
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_warc.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_warc.c
index b16246514..e8753853f 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_warc.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_warc.c
@@ -600,9 +600,10 @@ _warc_rdver(const char *buf, size_t bsz)
/* looks good so far, read the version number for a laugh */
buf += sizeof(magic) - 1U;
- if (isdigit(buf[0U]) && (buf[1U] == '.') && isdigit(buf[2U])) {
+ if (isdigit((unsigned char)buf[0U]) && (buf[1U] == '.') &&
+ isdigit((unsigned char)buf[2U])) {
/* we support a maximum of 2 digits in the minor version */
- if (isdigit(buf[3U]))
+ if (isdigit((unsigned char)buf[3U]))
end = 1U;
/* set up major version */
ver = (buf[0U] - '0') * 10000U;
@@ -686,7 +687,7 @@ _warc_rduri(const char *buf, size_t bsz)
/* spaces inside uri are not allowed, CRLF should follow */
for (p = val; p < eol; p++) {
- if (isspace(*p))
+ if (isspace((unsigned char)*p))
return res;
}
@@ -736,7 +737,7 @@ _warc_rdlen(const char *buf, size_t bsz)
while (val < eol && (*val == ' ' || *val == '\t'))
val++;
/* there must be at least one digit */
- if (!isdigit(*val))
+ if (!isdigit((unsigned char)*val))
return -1;
len = strtol(val, &on, 10);
if (on != eol) {
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c
index eeac1c888..9292ed784 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c
@@ -1040,6 +1040,9 @@ atol10(const char *p, size_t char_cnt)
uint64_t l;
int digit;
+ if (char_cnt == 0)
+ return (0);
+
l = 0;
digit = *p - '0';
while (digit >= 0 && digit < 10 && char_cnt-- > 0) {
@@ -1054,7 +1057,10 @@ atol8(const char *p, size_t char_cnt)
{
int64_t l;
int digit;
-
+
+ if (char_cnt == 0)
+ return (0);
+
l = 0;
while (char_cnt-- > 0) {
if (*p >= '0' && *p <= '7')
@@ -2623,6 +2629,14 @@ strappend_base64(struct xar *xar,
archive_strncat(as, (const char *)buff, len);
}
+static int
+is_string(const char *known, const char *data, size_t len)
+{
+ if (strlen(known) != len)
+ return -1;
+ return memcmp(data, known, len);
+}
+
static void
xml_data(void *userData, const char *s, int len)
{
@@ -2674,26 +2688,26 @@ xml_data(void *userData, const char *s, int len)
archive_strncpy(&(xar->file->symlink), s, len);
break;
case FILE_TYPE:
- if (strncmp("file", s, len) == 0 ||
- strncmp("hardlink", s, len) == 0)
+ if (is_string("file", s, len) == 0 ||
+ is_string("hardlink", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFREG;
- if (strncmp("directory", s, len) == 0)
+ if (is_string("directory", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFDIR;
- if (strncmp("symlink", s, len) == 0)
+ if (is_string("symlink", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFLNK;
- if (strncmp("character special", s, len) == 0)
+ if (is_string("character special", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFCHR;
- if (strncmp("block special", s, len) == 0)
+ if (is_string("block special", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFBLK;
- if (strncmp("socket", s, len) == 0)
+ if (is_string("socket", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFSOCK;
- if (strncmp("fifo", s, len) == 0)
+ if (is_string("fifo", s, len) == 0)
xar->file->mode =
(xar->file->mode & ~AE_IFMT) | AE_IFIFO;
xar->file->has |= HAS_TYPE;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
index e56bd63ac..7e99b1275 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
@@ -347,7 +347,7 @@ fake_crc32(unsigned long crc, const void *buff, size_t len)
return 0;
}
-static struct {
+static const struct {
int id;
const char * name;
} compression_methods[] = {
@@ -511,7 +511,13 @@ process_extra(struct archive_read *a, const char *p, size_t extra_length, struct
case 0x5455:
{
/* Extended time field "UT". */
- int flags = p[offset];
+ int flags;
+ if (datasize == 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Incomplete extended time field");
+ return ARCHIVE_FAILED;
+ }
+ flags = p[offset];
offset++;
datasize--;
/* Flag bits indicate which dates are present. */
@@ -723,6 +729,11 @@ process_extra(struct archive_read *a, const char *p, size_t extra_length, struct
}
case 0x9901:
/* WinZip AES extra data field. */
+ if (datasize < 6) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Incomplete AES field");
+ return ARCHIVE_FAILED;
+ }
if (p[offset + 2] == 'A' && p[offset + 3] == 'E') {
/* Vendor version. */
zip_entry->aes_extra.vendor =
@@ -881,6 +892,24 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
zip_entry->mode |= 0664;
}
+ /* Windows archivers sometimes use backslash as the directory separator.
+ Normalize to slash. */
+ if (zip_entry->system == 0 &&
+ (wp = archive_entry_pathname_w(entry)) != NULL) {
+ if (wcschr(wp, L'/') == NULL && wcschr(wp, L'\\') != NULL) {
+ size_t i;
+ struct archive_wstring s;
+ archive_string_init(&s);
+ archive_wstrcpy(&s, wp);
+ for (i = 0; i < archive_strlen(&s); i++) {
+ if (s.s[i] == '\\')
+ s.s[i] = '/';
+ }
+ archive_entry_copy_pathname_w(entry, s.s);
+ archive_wstring_free(&s);
+ }
+ }
+
/* Make sure that entries with a trailing '/' are marked as directories
* even if the External File Attributes contains bogus values. If this
* is not a directory and there is no type, assume regularfile. */
@@ -1056,6 +1085,7 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
zip->end_of_entry = 1;
/* Set up a more descriptive format name. */
+ archive_string_empty(&zip->format_name);
archive_string_sprintf(&zip->format_name, "ZIP %d.%d (%s)",
version / 10, version % 10,
compression_name(zip->entry->compression));
@@ -2407,7 +2437,7 @@ read_eocd(struct zip *zip, const char *p, int64_t current_offset)
* Examine Zip64 EOCD locator: If it's valid, store the information
* from it.
*/
-static void
+static int
read_zip64_eocd(struct archive_read *a, struct zip *zip, const char *p)
{
int64_t eocd64_offset;
@@ -2417,35 +2447,37 @@ read_zip64_eocd(struct archive_read *a, struct zip *zip, const char *p)
/* Central dir must be on first volume. */
if (archive_le32dec(p + 4) != 0)
- return;
+ return 0;
/* Must be only a single volume. */
if (archive_le32dec(p + 16) != 1)
- return;
+ return 0;
/* Find the Zip64 EOCD record. */
eocd64_offset = archive_le64dec(p + 8);
if (__archive_read_seek(a, eocd64_offset, SEEK_SET) < 0)
- return;
+ return 0;
if ((p = __archive_read_ahead(a, 56, NULL)) == NULL)
- return;
+ return 0;
/* Make sure we can read all of it. */
eocd64_size = archive_le64dec(p + 4) + 12;
if (eocd64_size < 56 || eocd64_size > 16384)
- return;
+ return 0;
if ((p = __archive_read_ahead(a, (size_t)eocd64_size, NULL)) == NULL)
- return;
+ return 0;
/* Sanity-check the EOCD64 */
if (archive_le32dec(p + 16) != 0) /* Must be disk #0 */
- return;
+ return 0;
if (archive_le32dec(p + 20) != 0) /* CD must be on disk #0 */
- return;
+ return 0;
/* CD can't be split. */
if (archive_le64dec(p + 24) != archive_le64dec(p + 32))
- return;
+ return 0;
/* Save the central directory offset for later use. */
zip->central_directory_offset = archive_le64dec(p + 48);
+
+ return 32;
}
static int
@@ -2483,15 +2515,14 @@ archive_read_format_zip_seekable_bid(struct archive_read *a, int best_bid)
if (memcmp(p + i, "PK\005\006", 4) == 0) {
int ret = read_eocd(zip, p + i,
current_offset + i);
- if (ret > 0) {
- /* Zip64 EOCD locator precedes
- * regular EOCD if present. */
- if (i >= 20
- && memcmp(p + i - 20, "PK\006\007", 4) == 0) {
- read_zip64_eocd(a, zip, p + i - 20);
- }
- return (ret);
+ /* Zip64 EOCD locator precedes
+ * regular EOCD if present. */
+ if (i >= 20 && memcmp(p + i - 20, "PK\006\007", 4) == 0) {
+ int ret_zip64 = read_zip64_eocd(a, zip, p + i - 20);
+ if (ret_zip64 > ret)
+ ret = ret_zip64;
}
+ return (ret);
}
i -= 4;
break;
diff --git a/Utilities/cmlibarchive/libarchive/archive_string.c b/Utilities/cmlibarchive/libarchive/archive_string.c
index 592ead2bd..554533ecb 100644
--- a/Utilities/cmlibarchive/libarchive/archive_string.c
+++ b/Utilities/cmlibarchive/libarchive/archive_string.c
@@ -202,7 +202,8 @@ archive_string_append(struct archive_string *as, const char *p, size_t s)
{
if (archive_string_ensure(as, as->length + s + 1) == NULL)
return (NULL);
- memmove(as->s + as->length, p, s);
+ if (s)
+ memmove(as->s + as->length, p, s);
as->length += s;
as->s[as->length] = 0;
return (as);
@@ -213,7 +214,8 @@ archive_wstring_append(struct archive_wstring *as, const wchar_t *p, size_t s)
{
if (archive_wstring_ensure(as, as->length + s + 1) == NULL)
return (NULL);
- wmemmove(as->s + as->length, p, s);
+ if (s)
+ wmemmove(as->s + as->length, p, s);
as->length += s;
as->s[as->length] = 0;
return (as);
diff --git a/Utilities/cmlibarchive/libarchive/archive_string_sprintf.c b/Utilities/cmlibarchive/libarchive/archive_string_sprintf.c
index 964ea2bea..969a5603a 100644
--- a/Utilities/cmlibarchive/libarchive/archive_string_sprintf.c
+++ b/Utilities/cmlibarchive/libarchive/archive_string_sprintf.c
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_string_sprintf.c 189435 2009-03-
static void
append_uint(struct archive_string *as, uintmax_t d, unsigned base)
{
- static const char *digits = "0123456789abcdef";
+ static const char digits[] = "0123456789abcdef";
if (d >= base)
append_uint(as, d/base, base);
archive_strappend_char(as, digits[d % base]);
diff --git a/Utilities/cmlibarchive/libarchive/archive_util.c b/Utilities/cmlibarchive/libarchive/archive_util.c
index f56ca332d..e5c6e3bff 100644
--- a/Utilities/cmlibarchive/libarchive/archive_util.c
+++ b/Utilities/cmlibarchive/libarchive/archive_util.c
@@ -89,88 +89,6 @@ archive_version_string(void)
return (ARCHIVE_VERSION_STRING);
}
-const char *
-archive_version_details(void)
-{
- static struct archive_string str;
- static int init = 0;
- const char *zlib = archive_zlib_version();
- const char *liblzma = archive_liblzma_version();
- const char *bzlib = archive_bzlib_version();
- const char *liblz4 = archive_liblz4_version();
-
- if (!init) {
- archive_string_init(&str);
-
- archive_strcat(&str, ARCHIVE_VERSION_STRING);
- if (zlib != NULL) {
- archive_strcat(&str, " zlib/");
- archive_strcat(&str, zlib);
- }
- if (liblzma) {
- archive_strcat(&str, " liblzma/");
- archive_strcat(&str, liblzma);
- }
- if (bzlib) {
- const char *p = bzlib;
- const char *sep = strchr(p, ',');
- if (sep == NULL)
- sep = p + strlen(p);
- archive_strcat(&str, " bz2lib/");
- archive_strncat(&str, p, sep - p);
- }
- if (liblz4) {
- archive_strcat(&str, " liblz4/");
- archive_strcat(&str, liblz4);
- }
- }
- return str.s;
-}
-
-const char *
-archive_zlib_version(void)
-{
-#ifdef HAVE_ZLIB_H
- return ZLIB_VERSION;
-#else
- return NULL;
-#endif
-}
-
-const char *
-archive_liblzma_version(void)
-{
-#ifdef HAVE_LZMA_H
- return LZMA_VERSION_STRING;
-#else
- return NULL;
-#endif
-}
-
-const char *
-archive_bzlib_version(void)
-{
-#ifdef HAVE_BZLIB_H
- return BZ2_bzlibVersion();
-#else
- return NULL;
-#endif
-}
-
-const char *
-archive_liblz4_version(void)
-{
-#if defined(HAVE_LZ4_H) && defined(HAVE_LIBLZ4)
-#define str(s) #s
-#define NUMBER(x) str(x)
- return NUMBER(LZ4_VERSION_MAJOR) "." NUMBER(LZ4_VERSION_MINOR) "." NUMBER(LZ4_VERSION_RELEASE);
-#undef NUMBER
-#undef str
-#else
- return NULL;
-#endif
-}
-
int
archive_errno(struct archive *a)
{
@@ -222,7 +140,7 @@ archive_compression_name(struct archive *a)
/*
* Return a count of the number of compressed bytes processed.
*/
-int64_t
+la_int64_t
archive_position_compressed(struct archive *a)
{
return archive_filter_bytes(a, -1);
@@ -231,7 +149,7 @@ archive_position_compressed(struct archive *a)
/*
* Return a count of the number of uncompressed bytes processed.
*/
-int64_t
+la_int64_t
archive_position_uncompressed(struct archive *a)
{
return archive_filter_bytes(a, 0);
@@ -275,7 +193,7 @@ archive_copy_error(struct archive *dest, struct archive *src)
void
__archive_errx(int retvalue, const char *msg)
{
- static const char *msg1 = "Fatal Internal Error in libarchive: ";
+ static const char msg1[] = "Fatal Internal Error in libarchive: ";
size_t s;
s = write(2, msg1, strlen(msg1));
@@ -303,8 +221,8 @@ __archive_errx(int retvalue, const char *msg)
int
__archive_mktemp(const char *tmpdir)
{
- static const wchar_t *prefix = L"libarchive_";
- static const wchar_t *suffix = L"XXXXXXXXXX";
+ static const wchar_t prefix[] = L"libarchive_";
+ static const wchar_t suffix[] = L"XXXXXXXXXX";
static const wchar_t num[] = {
L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7',
L'8', L'9', L'A', L'B', L'C', L'D', L'E', L'F',
diff --git a/Utilities/cmlibarchive/libarchive/archive_version_details.c b/Utilities/cmlibarchive/libarchive/archive_version_details.c
new file mode 100644
index 000000000..b9af6d781
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_version_details.c
@@ -0,0 +1,151 @@
+/*-
+ * Copyright (c) 2009-2012,2014 Michihiro NAKAJIMA
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_util.c 201098 2009-12-28 02:58:14Z kientzle $");
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_ZLIB_H
+#include <cm_zlib.h>
+#endif
+#ifdef HAVE_LZMA_H
+#include <cm_lzma.h>
+#endif
+#ifdef HAVE_BZLIB_H
+#include <cm_bzlib.h>
+#endif
+#ifdef HAVE_LZ4_H
+#include <lz4.h>
+#endif
+#ifdef HAVE_ZSTD_H
+#include <cm_zstd.h>
+#endif
+
+#include "archive.h"
+#include "archive_private.h"
+#include "archive_string.h"
+
+const char *
+archive_version_details(void)
+{
+ static struct archive_string str;
+ static int init = 0;
+ const char *zlib = archive_zlib_version();
+ const char *liblzma = archive_liblzma_version();
+ const char *bzlib = archive_bzlib_version();
+ const char *liblz4 = archive_liblz4_version();
+ const char *libzstd = archive_libzstd_version();
+
+ if (!init) {
+ archive_string_init(&str);
+
+ archive_strcat(&str, ARCHIVE_VERSION_STRING);
+ if (zlib != NULL) {
+ archive_strcat(&str, " zlib/");
+ archive_strcat(&str, zlib);
+ }
+ if (liblzma) {
+ archive_strcat(&str, " liblzma/");
+ archive_strcat(&str, liblzma);
+ }
+ if (bzlib) {
+ const char *p = bzlib;
+ const char *sep = strchr(p, ',');
+ if (sep == NULL)
+ sep = p + strlen(p);
+ archive_strcat(&str, " bz2lib/");
+ archive_strncat(&str, p, sep - p);
+ }
+ if (liblz4) {
+ archive_strcat(&str, " liblz4/");
+ archive_strcat(&str, liblz4);
+ }
+ if (libzstd) {
+ archive_strcat(&str, " libzstd/");
+ archive_strcat(&str, libzstd);
+ }
+ }
+ return str.s;
+}
+
+const char *
+archive_zlib_version(void)
+{
+#ifdef HAVE_ZLIB_H
+ return ZLIB_VERSION;
+#else
+ return NULL;
+#endif
+}
+
+const char *
+archive_liblzma_version(void)
+{
+#ifdef HAVE_LZMA_H
+ return LZMA_VERSION_STRING;
+#else
+ return NULL;
+#endif
+}
+
+const char *
+archive_bzlib_version(void)
+{
+#ifdef HAVE_BZLIB_H
+ return BZ2_bzlibVersion();
+#else
+ return NULL;
+#endif
+}
+
+const char *
+archive_liblz4_version(void)
+{
+#if defined(HAVE_LZ4_H) && defined(HAVE_LIBLZ4)
+#define str(s) #s
+#define NUMBER(x) str(x)
+ return NUMBER(LZ4_VERSION_MAJOR) "." NUMBER(LZ4_VERSION_MINOR) "." NUMBER(LZ4_VERSION_RELEASE);
+#undef NUMBER
+#undef str
+#else
+ return NULL;
+#endif
+}
+
+const char *
+archive_libzstd_version(void)
+{
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+ return ZSTD_VERSION_STRING;
+#else
+ return NULL;
+#endif
+}
diff --git a/Utilities/cmlibarchive/libarchive/archive_virtual.c b/Utilities/cmlibarchive/libarchive/archive_virtual.c
index de2595a9e..f509ee5c6 100644
--- a/Utilities/cmlibarchive/libarchive/archive_virtual.c
+++ b/Utilities/cmlibarchive/libarchive/archive_virtual.c
@@ -48,7 +48,7 @@ archive_filter_name(struct archive *a, int n)
return ((a->vtable->archive_filter_name)(a, n));
}
-int64_t
+la_int64_t
archive_filter_bytes(struct archive *a, int n)
{
return ((a->vtable->archive_filter_bytes)(a, n));
@@ -124,14 +124,15 @@ archive_write_finish_entry(struct archive *a)
return ((a->vtable->archive_write_finish_entry)(a));
}
-ssize_t
+la_ssize_t
archive_write_data(struct archive *a, const void *buff, size_t s)
{
return ((a->vtable->archive_write_data)(a, buff, s));
}
-ssize_t
-archive_write_data_block(struct archive *a, const void *buff, size_t s, int64_t o)
+la_ssize_t
+archive_write_data_block(struct archive *a, const void *buff, size_t s,
+ la_int64_t o)
{
if (a->vtable->archive_write_data_block == NULL) {
archive_set_error(a, ARCHIVE_ERRNO_MISC,
@@ -156,7 +157,7 @@ archive_read_next_header2(struct archive *a, struct archive_entry *entry)
int
archive_read_data_block(struct archive *a,
- const void **buff, size_t *s, int64_t *o)
+ const void **buff, size_t *s, la_int64_t *o)
{
return ((a->vtable->archive_read_data_block)(a, buff, s, o));
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write.3 b/Utilities/cmlibarchive/libarchive/archive_write.3
index 376d71dee..c1164f5b5 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write.3
@@ -71,7 +71,7 @@ support.
.\"
.Ss Set options
See
-.Xr archive_read_set_options 3 .
+.Xr archive_write_set_options 3 .
.\"
.Ss Open archive
See
diff --git a/Utilities/cmlibarchive/libarchive/archive_write.c b/Utilities/cmlibarchive/libarchive/archive_write.c
index 0634a2296..e8daf530d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write.c
@@ -190,7 +190,7 @@ archive_write_get_bytes_in_last_block(struct archive *_a)
* an archive to itself recursively.
*/
int
-archive_write_set_skip_file(struct archive *_a, int64_t d, int64_t i)
+archive_write_set_skip_file(struct archive *_a, la_int64_t d, la_int64_t i)
{
struct archive_write *a = (struct archive_write *)_a;
archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter.c
index ad5dc832f..203f4142b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter.c
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");
#include "archive_private.h"
/* A table that maps filter codes to functions. */
-static
+static const
struct { int code; int (*setter)(struct archive *); } codes[] =
{
{ ARCHIVE_FILTER_NONE, archive_write_add_filter_none },
@@ -53,6 +53,7 @@ struct { int code; int (*setter)(struct archive *); } codes[] =
{ ARCHIVE_FILTER_LZOP, archive_write_add_filter_lzip },
{ ARCHIVE_FILTER_UU, archive_write_add_filter_uuencode },
{ ARCHIVE_FILTER_XZ, archive_write_add_filter_xz },
+ { ARCHIVE_FILTER_ZSTD, archive_write_add_filter_zstd },
{ -1, NULL }
};
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_b64encode.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_b64encode.c
index 85eb087b0..b46b19a0c 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_b64encode.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_b64encode.c
@@ -60,7 +60,7 @@ static int archive_filter_b64encode_write(struct archive_write_filter *,
const void *, size_t);
static int archive_filter_b64encode_close(struct archive_write_filter *);
static int archive_filter_b64encode_free(struct archive_write_filter *);
-static void b64_encode(struct archive_string *, const unsigned char *, size_t);
+static void la_b64_encode(struct archive_string *, const unsigned char *, size_t);
static int64_t atol8(const char *, size_t);
static const char base64[] = {
@@ -180,7 +180,7 @@ archive_filter_b64encode_open(struct archive_write_filter *f)
}
static void
-b64_encode(struct archive_string *as, const unsigned char *p, size_t len)
+la_b64_encode(struct archive_string *as, const unsigned char *p, size_t len)
{
int c;
@@ -234,12 +234,12 @@ archive_filter_b64encode_write(struct archive_write_filter *f, const void *buff,
}
if (state->hold_len < LBYTES)
return (ret);
- b64_encode(&state->encoded_buff, state->hold, LBYTES);
+ la_b64_encode(&state->encoded_buff, state->hold, LBYTES);
state->hold_len = 0;
}
for (; length >= LBYTES; length -= LBYTES, p += LBYTES)
- b64_encode(&state->encoded_buff, p, LBYTES);
+ la_b64_encode(&state->encoded_buff, p, LBYTES);
/* Save remaining bytes. */
if (length > 0) {
@@ -270,7 +270,7 @@ archive_filter_b64encode_close(struct archive_write_filter *f)
/* Flush remaining bytes. */
if (state->hold_len != 0)
- b64_encode(&state->encoded_buff, state->hold, state->hold_len);
+ la_b64_encode(&state->encoded_buff, state->hold, state->hold_len);
archive_string_sprintf(&state->encoded_buff, "====\n");
/* Write the last block */
archive_write_set_bytes_in_last_block(f->archive, 1);
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_by_name.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_by_name.c
index eac4011cb..ffa633c96 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_by_name.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_by_name.c
@@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$");
#include "archive_private.h"
/* A table that maps names to functions. */
-static
+static const
struct { const char *name; int (*setter)(struct archive *); } names[] =
{
{ "b64encode", archive_write_add_filter_b64encode },
@@ -57,6 +57,7 @@ struct { const char *name; int (*setter)(struct archive *); } names[] =
{ "lzop", archive_write_add_filter_lzop },
{ "uuencode", archive_write_add_filter_uuencode },
{ "xz", archive_write_add_filter_xz },
+ { "zstd", archive_write_add_filter_zstd },
{ NULL, NULL }
};
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_gzip.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_gzip.c
index bbcc1789a..986123ad8 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_gzip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_gzip.c
@@ -226,7 +226,12 @@ archive_compressor_gzip_open(struct archive_write_filter *f)
data->compressed[7] = (uint8_t)(t>>24)&0xff;
} else
memset(&data->compressed[4], 0, 4);
- data->compressed[8] = 0; /* No deflate options */
+ if (data->compression_level == 9)
+ data->compressed[8] = 2;
+ else if(data->compression_level == 1)
+ data->compressed[8] = 4;
+ else
+ data->compressed[8] = 0;
data->compressed[9] = 3; /* OS=Unix */
data->stream.next_out += 10;
data->stream.avail_out -= 10;
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lz4.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lz4.c
index e6551859c..15fd494a4 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lz4.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lz4.c
@@ -225,7 +225,7 @@ archive_filter_lz4_open(struct archive_write_filter *f)
struct private_data *data = (struct private_data *)f->data;
int ret;
size_t required_size;
- static size_t bkmap[] = { 64 * 1024, 256 * 1024, 1 * 1024 * 1024,
+ static size_t const bkmap[] = { 64 * 1024, 256 * 1024, 1 * 1024 * 1024,
4 * 1024 * 1024 };
size_t pre_block_size;
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_program.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_program.c
index 55b5e8ecd..660f693f2 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_program.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_program.c
@@ -92,7 +92,7 @@ archive_write_add_filter_program(struct archive *_a, const char *cmd)
{
struct archive_write_filter *f = __archive_write_allocate_filter(_a);
struct private_data *data;
- static const char *prefix = "Program: ";
+ static const char prefix[] = "Program: ";
archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
ARCHIVE_STATE_NEW, "archive_write_add_filter_program");
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_zstd.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_zstd.c
new file mode 100644
index 000000000..251b17da5
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_zstd.c
@@ -0,0 +1,335 @@
+/*-
+ * Copyright (c) 2017 Sean Purcell
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+
+__FBSDID("$FreeBSD$");
+
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_ZSTD_H
+#include <cm_zstd.h>
+#endif
+
+#include "archive.h"
+#include "archive_private.h"
+#include "archive_string.h"
+#include "archive_write_private.h"
+
+/* Don't compile this if we don't have zstd.h */
+
+struct private_data {
+ int compression_level;
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+ ZSTD_CStream *cstream;
+ int64_t total_in;
+ ZSTD_outBuffer out;
+#else
+ struct archive_write_program_data *pdata;
+#endif
+};
+
+static int archive_compressor_zstd_options(struct archive_write_filter *,
+ const char *, const char *);
+static int archive_compressor_zstd_open(struct archive_write_filter *);
+static int archive_compressor_zstd_write(struct archive_write_filter *,
+ const void *, size_t);
+static int archive_compressor_zstd_close(struct archive_write_filter *);
+static int archive_compressor_zstd_free(struct archive_write_filter *);
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+static int drive_compressor(struct archive_write_filter *,
+ struct private_data *, int, const void *, size_t);
+#endif
+
+
+/*
+ * Add a zstd compression filter to this write handle.
+ */
+int
+archive_write_add_filter_zstd(struct archive *_a)
+{
+ struct archive_write *a = (struct archive_write *)_a;
+ struct archive_write_filter *f = __archive_write_allocate_filter(_a);
+ struct private_data *data;
+ archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+ ARCHIVE_STATE_NEW, "archive_write_add_filter_zstd");
+
+ data = calloc(1, sizeof(*data));
+ if (data == NULL) {
+ archive_set_error(&a->archive, ENOMEM, "Out of memory");
+ return (ARCHIVE_FATAL);
+ }
+ f->data = data;
+ f->open = &archive_compressor_zstd_open;
+ f->options = &archive_compressor_zstd_options;
+ f->close = &archive_compressor_zstd_close;
+ f->free = &archive_compressor_zstd_free;
+ f->code = ARCHIVE_FILTER_ZSTD;
+ f->name = "zstd";
+ data->compression_level = 3; /* Default level used by the zstd CLI */
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+ data->cstream = ZSTD_createCStream();
+ if (data->cstream == NULL) {
+ free(data);
+ archive_set_error(&a->archive, ENOMEM,
+ "Failed to allocate zstd compressor object");
+ return (ARCHIVE_FATAL);
+ }
+
+ return (ARCHIVE_OK);
+#else
+ data->pdata = __archive_write_program_allocate("zstd");
+ if (data->pdata == NULL) {
+ free(data);
+ archive_set_error(&a->archive, ENOMEM, "Out of memory");
+ return (ARCHIVE_FATAL);
+ }
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Using external zstd program");
+ return (ARCHIVE_WARN);
+#endif
+}
+
+static int
+archive_compressor_zstd_free(struct archive_write_filter *f)
+{
+ struct private_data *data = (struct private_data *)f->data;
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+ ZSTD_freeCStream(data->cstream);
+ free(data->out.dst);
+#else
+ __archive_write_program_free(data->pdata);
+#endif
+ free(data);
+ f->data = NULL;
+ return (ARCHIVE_OK);
+}
+
+/*
+ * Set write options.
+ */
+static int
+archive_compressor_zstd_options(struct archive_write_filter *f, const char *key,
+ const char *value)
+{
+ struct private_data *data = (struct private_data *)f->data;
+
+ if (strcmp(key, "compression-level") == 0) {
+ int level = atoi(value);
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+ if (level < 1 || level > ZSTD_maxCLevel()) {
+#else
+ /* If we don't have the library, hard-code the max level */
+ if (level < 1 || level > 22) {
+#endif
+ return (ARCHIVE_WARN);
+ }
+ data->compression_level = level;
+ return (ARCHIVE_OK);
+ }
+
+ /* Note: The "warn" return is just to inform the options
+ * supervisor that we didn't handle it. It will generate
+ * a suitable error if no one used this option. */
+ return (ARCHIVE_WARN);
+}
+
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+/*
+ * Setup callback.
+ */
+static int
+archive_compressor_zstd_open(struct archive_write_filter *f)
+{
+ struct private_data *data = (struct private_data *)f->data;
+ int ret;
+
+ ret = __archive_write_open_filter(f->next_filter);
+ if (ret != ARCHIVE_OK)
+ return (ret);
+
+ if (data->out.dst == NULL) {
+ size_t bs = ZSTD_CStreamOutSize(), bpb;
+ if (f->archive->magic == ARCHIVE_WRITE_MAGIC) {
+ /* Buffer size should be a multiple number of
+ * the of bytes per block for performance. */
+ bpb = archive_write_get_bytes_per_block(f->archive);
+ if (bpb > bs)
+ bs = bpb;
+ else if (bpb != 0)
+ bs -= bs % bpb;
+ }
+ data->out.size = bs;
+ data->out.pos = 0;
+ data->out.dst
+ = (unsigned char *)malloc(data->out.size);
+ if (data->out.dst == NULL) {
+ archive_set_error(f->archive, ENOMEM,
+ "Can't allocate data for compression buffer");
+ return (ARCHIVE_FATAL);
+ }
+ }
+
+ f->write = archive_compressor_zstd_write;
+
+ if (ZSTD_isError(ZSTD_initCStream(data->cstream,
+ data->compression_level))) {
+ archive_set_error(f->archive, ARCHIVE_ERRNO_MISC,
+ "Internal error initializing zstd compressor object");
+ return (ARCHIVE_FATAL);
+ }
+
+ return (ARCHIVE_OK);
+}
+
+/*
+ * Write data to the compressed stream.
+ */
+static int
+archive_compressor_zstd_write(struct archive_write_filter *f, const void *buff,
+ size_t length)
+{
+ struct private_data *data = (struct private_data *)f->data;
+ int ret;
+
+ /* Update statistics */
+ data->total_in += length;
+
+ if ((ret = drive_compressor(f, data, 0, buff, length)) != ARCHIVE_OK)
+ return (ret);
+
+ return (ARCHIVE_OK);
+}
+
+/*
+ * Finish the compression...
+ */
+static int
+archive_compressor_zstd_close(struct archive_write_filter *f)
+{
+ struct private_data *data = (struct private_data *)f->data;
+ int r1, r2;
+
+ /* Finish zstd frame */
+ r1 = drive_compressor(f, data, 1, NULL, 0);
+
+ r2 = __archive_write_close_filter(f->next_filter);
+
+ return r1 < r2 ? r1 : r2;
+}
+
+/*
+ * Utility function to push input data through compressor,
+ * writing full output blocks as necessary.
+ *
+ * Note that this handles both the regular write case (finishing ==
+ * false) and the end-of-archive case (finishing == true).
+ */
+static int
+drive_compressor(struct archive_write_filter *f,
+ struct private_data *data, int finishing, const void *src, size_t length)
+{
+ ZSTD_inBuffer in = (ZSTD_inBuffer) { src, length, 0 };
+
+ for (;;) {
+ if (data->out.pos == data->out.size) {
+ const int ret = __archive_write_filter(f->next_filter,
+ data->out.dst, data->out.size);
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ data->out.pos = 0;
+ }
+
+ /* If there's nothing to do, we're done. */
+ if (!finishing && in.pos == in.size)
+ return (ARCHIVE_OK);
+
+ {
+ const size_t zstdret = !finishing ?
+ ZSTD_compressStream(data->cstream, &data->out, &in)
+ : ZSTD_endStream(data->cstream, &data->out);
+
+ if (ZSTD_isError(zstdret)) {
+ archive_set_error(f->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Zstd compression failed: %s",
+ ZSTD_getErrorName(zstdret));
+ return (ARCHIVE_FATAL);
+ }
+
+ /* If we're finishing, 0 means nothing left to flush */
+ if (finishing && zstdret == 0) {
+ const int ret = __archive_write_filter(f->next_filter,
+ data->out.dst, data->out.pos);
+ return (ret);
+ }
+ }
+ }
+}
+
+#else /* HAVE_ZSTD_H && HAVE_LIBZSTD */
+
+static int
+archive_compressor_zstd_open(struct archive_write_filter *f)
+{
+ struct private_data *data = (struct private_data *)f->data;
+ struct archive_string as;
+ int r;
+
+ archive_string_init(&as);
+ archive_string_sprintf(&as, "zstd -%d", data->compression_level);
+
+ f->write = archive_compressor_zstd_write;
+ r = __archive_write_program_open(f, data->pdata, as.s);
+ archive_string_free(&as);
+ return (r);
+}
+
+static int
+archive_compressor_zstd_write(struct archive_write_filter *f, const void *buff,
+ size_t length)
+{
+ struct private_data *data = (struct private_data *)f->data;
+
+ return __archive_write_program_write(f, data->pdata, buff, length);
+}
+
+static int
+archive_compressor_zstd_close(struct archive_write_filter *f)
+{
+ struct private_data *data = (struct private_data *)f->data;
+
+ return __archive_write_program_close(f, data->pdata);
+}
+
+#endif /* HAVE_ZSTD_H && HAVE_LIBZSTD */
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_data.3 b/Utilities/cmlibarchive/libarchive/archive_write_data.3
index 0cdd25f1f..9c16cd9b4 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_data.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write_data.3
@@ -24,11 +24,12 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 2, 2012
+.Dd February 28, 2017
.Dt ARCHIVE_WRITE_DATA 3
.Os
.Sh NAME
-.Nm archive_write_data
+.Nm archive_write_data ,
+.Nm archive_write_data_block
.Nd functions for creating archives
.Sh LIBRARY
Streaming Archive Library (libarchive, -larchive)
@@ -36,8 +37,27 @@ Streaming Archive Library (libarchive, -larchive)
.In archive.h
.Ft la_ssize_t
.Fn archive_write_data "struct archive *" "const void *" "size_t"
+.Ft la_ssize_t
+.Fn archive_write_data_block "struct archive *" "const void *" "size_t size" "int64_t offset"
.Sh DESCRIPTION
+.Bl -tag -width indent
+.It Fn archive_write_data
+Write data corresponding to the header just written.
+.It Fn archive_write_data_block
Write data corresponding to the header just written.
+This is like
+.Fn archive_write_data
+except that it performs a seek on the file being
+written to the specified offset before writing the data.
+This is useful when restoring sparse files from archive
+formats that support sparse files.
+Returns number of bytes written or -1 on error.
+(Note: This is currently not supported for
+.Tn archive_write
+handles, only for
+.Tn archive_write_disk
+handles.
+.El
.\" .Sh EXAMPLE
.\"
.Sh RETURN VALUES
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk.3 b/Utilities/cmlibarchive/libarchive/archive_write_disk.3
index ba6c9706e..949c9ef10 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 2, 2012
+.Dd April 3, 2017
.Dt ARCHIVE_WRITE_DISK 3
.Os
.Sh NAME
@@ -33,14 +33,7 @@
.Nm archive_write_disk_set_skip_file ,
.Nm archive_write_disk_set_group_lookup ,
.Nm archive_write_disk_set_standard_lookup ,
-.Nm archive_write_disk_set_user_lookup ,
-.Nm archive_write_header ,
-.Nm archive_write_data ,
-.Nm archive_write_data_block ,
-.Nm archive_write_finish_entry ,
-.Nm archive_write_close ,
-.Nm archive_write_finish
-.Nm archive_write_free
+.Nm archive_write_disk_set_user_lookup
.Nd functions for creating objects on disk
.Sh LIBRARY
Streaming Archive Library (libarchive, -larchive)
@@ -68,20 +61,6 @@ Streaming Archive Library (libarchive, -larchive)
.Fa "uid_t (*)(void *, const char *uname, uid_t uid)"
.Fa "void (*cleanup)(void *)"
.Fc
-.Ft int
-.Fn archive_write_header "struct archive *" "struct archive_entry *"
-.Ft la_ssize_t
-.Fn archive_write_data "struct archive *" "const void *" "size_t"
-.Ft la_ssize_t
-.Fn archive_write_data_block "struct archive *" "const void *" "size_t size" "int64_t offset"
-.Ft int
-.Fn archive_write_finish_entry "struct archive *"
-.Ft int
-.Fn archive_write_close "struct archive *"
-.Ft int
-.Fn archive_write_finish "struct archive *"
-.Ft int
-.Fn archive_write_free "struct archive *"
.Sh DESCRIPTION
These functions provide a complete API for creating objects on
disk from
@@ -117,6 +96,33 @@ performance optimization in practice.
The options field consists of a bitwise OR of one or more of the
following values:
.Bl -tag -compact -width "indent"
+.It Cm ARCHIVE_EXTRACT_ACL
+Attempt to restore Access Control Lists.
+By default, extended ACLs are ignored.
+.It Cm ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS
+Before removing a file system object prior to replacing it, clear
+platform-specific file flags which might prevent its removal.
+.It Cm ARCHIVE_EXTRACT_FFLAGS
+Attempt to restore file attributes (file flags).
+By default, file attributes are ignored.
+See
+.Xr chattr 1
+.Pq Linux
+or
+.Xr chflags 1
+.Pq FreeBSD, Mac OS X
+for more information on file attributes.
+.It Cm ARCHIVE_EXTRACT_MAC_METADATA
+Mac OS X specific. Restore metadata using
+.Xr copyfile 3 .
+By default,
+.Xr copyfile 3
+metadata is ignored.
+.It Cm ARCHIVE_EXTRACT_NO_OVERWRITE
+Existing files on disk will not be overwritten.
+By default, existing regular files are truncated and overwritten;
+existing directories will have their permissions updated;
+other pre-existing objects are unlinked and recreated from scratch.
.It Cm ARCHIVE_EXTRACT_OWNER
The user and group IDs should be set on the restored file.
By default, the user and group IDs are not restored.
@@ -132,15 +138,37 @@ is not specified, then SUID and SGID bits will only be restored
if the default user and group IDs of newly-created objects on disk
happen to match those specified in the archive entry.
By default, only basic permissions are restored, and umask is obeyed.
+.It Cm ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS
+Refuse to extract an absolute path.
+The default is to not refuse such paths.
+.It Cm ARCHIVE_EXTRACT_SECURE_NODOTDOT
+Refuse to extract a path that contains a
+.Pa ..
+element anywhere within it.
+The default is to not refuse such paths.
+Note that paths ending in
+.Pa ..
+always cause an error, regardless of this flag.
+.It Cm ARCHIVE_EXTRACT_SECURE_SYMLINKS
+Refuse to extract any object whose final location would be altered
+by a symlink on disk.
+This is intended to help guard against a variety of mischief
+caused by archives that (deliberately or otherwise) extract
+files outside of the current directory.
+The default is not to perform this check.
+If
+.It Cm ARCHIVE_EXTRACT_SPARSE
+Scan data for blocks of NUL bytes and try to recreate them with holes.
+This results in sparse files, independent of whether the archive format
+supports or uses them.
+.Cm ARCHIVE_EXTRACT_UNLINK
+is specified together with this option, the library will
+remove any intermediate symlinks it finds and return an
+error only if such symlink could not be removed.
.It Cm ARCHIVE_EXTRACT_TIME
The timestamps (mtime, ctime, and atime) should be restored.
By default, they are ignored.
Note that restoring of atime is not currently supported.
-.It Cm ARCHIVE_EXTRACT_NO_OVERWRITE
-Existing files on disk will not be overwritten.
-By default, existing regular files are truncated and overwritten;
-existing directories will have their permissions updated;
-other pre-existing objects are unlinked and recreated from scratch.
.It Cm ARCHIVE_EXTRACT_UNLINK
Existing files on disk will be unlinked before any attempt to
create them.
@@ -148,45 +176,18 @@ In some cases, this can prove to be a significant performance improvement.
By default, existing files are truncated and rewritten, but
the file is not recreated.
In particular, the default behavior does not break existing hard links.
-.It Cm ARCHIVE_EXTRACT_ACL
-Attempt to restore ACLs.
-By default, extended ACLs are ignored.
-.It Cm ARCHIVE_EXTRACT_FFLAGS
-Attempt to restore extended file flags.
-By default, file flags are ignored.
.It Cm ARCHIVE_EXTRACT_XATTR
-Attempt to restore POSIX.1e extended attributes.
+Attempt to restore extended file attributes.
By default, they are ignored.
-.It Cm ARCHIVE_EXTRACT_SECURE_SYMLINKS
-Refuse to extract any object whose final location would be altered
-by a symlink on disk.
-This is intended to help guard against a variety of mischief
-caused by archives that (deliberately or otherwise) extract
-files outside of the current directory.
-The default is not to perform this check.
-If
-.Cm ARCHIVE_EXTRACT_UNLINK
-is specified together with this option, the library will
-remove any intermediate symlinks it finds and return an
-error only if such symlink could not be removed.
-.It Cm ARCHIVE_EXTRACT_SECURE_NODOTDOT
-Refuse to extract a path that contains a
-.Pa ..
-element anywhere within it.
-The default is to not refuse such paths.
-Note that paths ending in
-.Pa ..
-always cause an error, regardless of this flag.
-.It Cm ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS
-Refuse to extract an absolute path.
-The default is to not refuse such paths.
-.It Cm ARCHIVE_EXTRACT_SPARSE
-Scan data for blocks of NUL bytes and try to recreate them with holes.
-This results in sparse files, independent of whether the archive format
-supports or uses them.
-.It Cm ARCHIVE_EXTRACT_CLEAR_NOCHANGE_FFLAGS
-Before removing a file system object prior to replacing it, clear
-platform-specific file flags which might prevent its removal.
+See
+.Xr xattr 7
+.Pq Linux ,
+.Xr xattr 2
+.Pq Mac OS X ,
+or
+.Xr getextattr 8
+.Pq FreeBSD
+for more information on extended file attributes.
.El
.It Xo
.Fn archive_write_disk_set_group_lookup ,
@@ -223,60 +224,6 @@ the number of calls to
.Xr getpwnam 3
and
.Xr getgrnam 3 .
-.It Fn archive_write_header
-Build and write a header using the data in the provided
-.Tn struct archive_entry
-structure.
-See
-.Xr archive_entry 3
-for information on creating and populating
-.Tn struct archive_entry
-objects.
-.It Fn archive_write_data
-Write data corresponding to the header just written.
-Returns number of bytes written or -1 on error.
-.It Fn archive_write_data_block
-Write data corresponding to the header just written.
-This is like
-.Fn archive_write_data
-except that it performs a seek on the file being
-written to the specified offset before writing the data.
-This is useful when restoring sparse files from archive
-formats that support sparse files.
-Returns number of bytes written or -1 on error.
-(Note: This is currently not supported for
-.Tn archive_write
-handles, only for
-.Tn archive_write_disk
-handles.)
-.It Fn archive_write_finish_entry
-Close out the entry just written.
-Ordinarily, clients never need to call this, as it
-is called automatically by
-.Fn archive_write_next_header
-and
-.Fn archive_write_close
-as needed.
-However, some file attributes are written to disk only
-after the file is closed, so this can be necessary
-if you need to work with the file on disk right away.
-.It Fn archive_write_close
-Set any attributes that could not be set during the initial restore.
-For example, directory timestamps are not restored initially because
-restoring a subsequent file would alter that timestamp.
-Similarly, non-writable directories are initially created with
-write permissions (so that their contents can be restored).
-The
-.Nm
-library maintains a list of all such deferred attributes and
-sets them when this function is invoked.
-.It Fn archive_write_finish
-This is a deprecated synonym for
-.Fn archive_write_free .
-.It Fn archive_write_free
-Invokes
-.Fn archive_write_close
-if it was not invoked manually, then releases all resources.
.El
More information about the
.Va struct archive
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_acl.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_acl.c
deleted file mode 100644
index 144ab7e72..000000000
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_acl.c
+++ /dev/null
@@ -1,654 +0,0 @@
-/*-
- * Copyright (c) 2003-2010 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer
- * in this position and unchanged.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "archive_platform.h"
-__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_disk.c 201159 2009-12-29 05:35:40Z kientzle $");
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_ACL_H
-#define _ACL_PRIVATE /* For debugging */
-#include <sys/acl.h>
-#endif
-#if HAVE_DARWIN_ACL
-#include <membership.h>
-#endif
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-
-#include "archive.h"
-#include "archive_entry.h"
-#include "archive_acl_private.h"
-#include "archive_write_disk_private.h"
-
-#if !HAVE_POSIX_ACL && !HAVE_NFS4_ACL
-/* Default empty function body to satisfy mainline code. */
-int
-archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
- struct archive_acl *abstract_acl)
-{
- (void)a; /* UNUSED */
- (void)fd; /* UNUSED */
- (void)name; /* UNUSED */
- (void)abstract_acl; /* UNUSED */
- return (ARCHIVE_OK);
-}
-
-#else /* HAVE_POSIX_ACL || HAVE_NFS4_ACL */
-
-#if HAVE_SUN_ACL
-#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACE_T
-#elif HAVE_DARWIN_ACL
-#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACL_TYPE_EXTENDED
-#elif HAVE_ACL_TYPE_NFS4
-#define ARCHIVE_PLATFORM_ACL_TYPE_NFS4 ACL_TYPE_NFS4
-#endif
-
-static int set_acl(struct archive *, int fd, const char *,
- struct archive_acl *,
- acl_type_t, int archive_entry_acl_type, const char *tn);
-
-int
-archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
- struct archive_acl *abstract_acl)
-{
- int ret = ARCHIVE_OK;
-
-#if !HAVE_DARWIN_ACL
- if ((archive_acl_types(abstract_acl)
- & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
-#if HAVE_SUN_ACL
- /* Solaris writes POSIX.1e access and default ACLs together */
- ret = set_acl(a, fd, name, abstract_acl, ACLENT_T,
- ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, "posix1e");
-#else /* HAVE_POSIX_ACL */
- if ((archive_acl_types(abstract_acl)
- & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
- ret = set_acl(a, fd, name, abstract_acl,
- ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
- "access");
- if (ret != ARCHIVE_OK)
- return (ret);
- }
- if ((archive_acl_types(abstract_acl)
- & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0)
- ret = set_acl(a, fd, name, abstract_acl,
- ACL_TYPE_DEFAULT, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT,
- "default");
-#endif /* !HAVE_SUN_ACL */
- /* Simultaneous POSIX.1e and NFSv4 is not supported */
- return (ret);
- }
-#endif /* !HAVE_DARWIN_ACL */
-#if HAVE_NFS4_ACL
- if ((archive_acl_types(abstract_acl) &
- ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
- ret = set_acl(a, fd, name, abstract_acl,
- ARCHIVE_PLATFORM_ACL_TYPE_NFS4,
- ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
- }
-#endif /* HAVE_NFS4_ACL */
- return (ret);
-}
-
-/*
- * Translate system ACL permissions into libarchive internal structure
- */
-static const struct {
- const int archive_perm;
- const int platform_perm;
-} acl_perm_map[] = {
-#if HAVE_SUN_ACL /* Solaris NFSv4 ACL permissions */
- {ARCHIVE_ENTRY_ACL_EXECUTE, ACE_EXECUTE},
- {ARCHIVE_ENTRY_ACL_READ_DATA, ACE_READ_DATA},
- {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACE_LIST_DIRECTORY},
- {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACE_WRITE_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_FILE, ACE_ADD_FILE},
- {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACE_APPEND_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACE_ADD_SUBDIRECTORY},
- {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACE_READ_NAMED_ATTRS},
- {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACE_WRITE_NAMED_ATTRS},
- {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACE_DELETE_CHILD},
- {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACE_READ_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACE_WRITE_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_DELETE, ACE_DELETE},
- {ARCHIVE_ENTRY_ACL_READ_ACL, ACE_READ_ACL},
- {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACE_WRITE_ACL},
- {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACE_WRITE_OWNER},
- {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACE_SYNCHRONIZE}
-#elif HAVE_DARWIN_ACL /* MacOS ACL permissions */
- {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
- {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
- {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE},
- {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
- {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE},
- {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY},
- {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD},
- {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_EXTATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_EXTATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_SECURITY},
- {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_SECURITY},
- {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_CHANGE_OWNER},
- {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
-#else /* POSIX.1e ACL permissions */
- {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
- {ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
- {ARCHIVE_ENTRY_ACL_READ, ACL_READ},
-#if HAVE_ACL_TYPE_NFS4 /* FreeBSD NFSv4 ACL permissions */
- {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
- {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
- {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE},
- {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY},
- {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_NAMED_ATTRS},
- {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_NAMED_ATTRS},
- {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD},
- {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE},
- {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_ACL},
- {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL},
- {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER},
- {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
-#endif
-#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */
-};
-
-#if HAVE_NFS4_ACL
-/*
- * Translate system NFSv4 inheritance flags into libarchive internal structure
- */
-static const struct {
- const int archive_inherit;
- const int platform_inherit;
-} acl_inherit_map[] = {
-#if HAVE_SUN_ACL /* Solaris NFSv4 inheritance flags */
- {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACE_FILE_INHERIT_ACE},
- {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACE_DIRECTORY_INHERIT_ACE},
- {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACE_NO_PROPAGATE_INHERIT_ACE},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACE_INHERIT_ONLY_ACE},
- {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACE_SUCCESSFUL_ACCESS_ACE_FLAG},
- {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACE_FAILED_ACCESS_ACE_FLAG},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACE_INHERITED_ACE}
-#elif HAVE_DARWIN_ACL /* MacOS NFSv4 inheritance flags */
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED},
- {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_LIMIT_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_ONLY_INHERIT}
-#else /* FreeBSD NFSv4 ACL inheritance flags */
- {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY},
- {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACL_ENTRY_SUCCESSFUL_ACCESS},
- {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACL_ENTRY_FAILED_ACCESS},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED}
-#endif /* !HAVE_SUN_ACL && !HAVE_DARWIN_ACL */
-};
-#endif /* HAVE_NFS4_ACL */
-
-static int
-set_acl(struct archive *a, int fd, const char *name,
- struct archive_acl *abstract_acl,
- acl_type_t acl_type, int ae_requested_type, const char *tname)
-{
-#if HAVE_SUN_ACL
- aclent_t *aclent;
- ace_t *ace;
- int e, r;
- acl_t *acl;
-#else
- acl_t acl;
- acl_entry_t acl_entry;
- acl_permset_t acl_permset;
-#if HAVE_ACL_TYPE_NFS4 || HAVE_DARWIN_ACL
- acl_flagset_t acl_flagset;
-#endif
-#endif /* HAVE_SUN_ACL */
-#if HAVE_ACL_TYPE_NFS4
- int r;
-#endif
- int ret;
- int ae_type, ae_permset, ae_tag, ae_id;
-#if HAVE_DARWIN_ACL
- uuid_t ae_uuid;
-#endif
- uid_t ae_uid;
- gid_t ae_gid;
- const char *ae_name;
- int entries;
- int i;
-
- ret = ARCHIVE_OK;
- entries = archive_acl_reset(abstract_acl, ae_requested_type);
- if (entries == 0)
- return (ARCHIVE_OK);
-
-#if HAVE_SUN_ACL
- acl = NULL;
- acl = malloc(sizeof(acl_t));
- if (acl == NULL) {
- archive_set_error(a, ARCHIVE_ERRNO_MISC,
- "Invalid ACL type");
- return (ARCHIVE_FAILED);
- }
- if (acl_type == ACE_T)
- acl->acl_entry_size = sizeof(ace_t);
- else if (acl_type == ACLENT_T)
- acl->acl_entry_size = sizeof(aclent_t);
- else {
- archive_set_error(a, ARCHIVE_ERRNO_MISC,
- "Invalid ACL type");
- acl_free(acl);
- return (ARCHIVE_FAILED);
- }
- acl->acl_type = acl_type;
- acl->acl_cnt = entries;
-
- acl->acl_aclp = malloc(entries * acl->acl_entry_size);
- if (acl->acl_aclp == NULL) {
- archive_set_error(a, errno,
- "Can't allocate memory for acl buffer");
- acl_free(acl);
- return (ARCHIVE_FAILED);
- }
-#else /* !HAVE_SUN_ACL */
- acl = acl_init(entries);
- if (acl == (acl_t)NULL) {
- archive_set_error(a, errno,
- "Failed to initialize ACL working storage");
- return (ARCHIVE_FAILED);
- }
-#endif /* !HAVE_SUN_ACL */
-#if HAVE_SUN_ACL
- e = 0;
-#endif
- while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
- &ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
-#if HAVE_SUN_ACL
- ace = NULL;
- aclent = NULL;
- if (acl->acl_type == ACE_T) {
- ace = &((ace_t *)acl->acl_aclp)[e];
- ace->a_who = -1;
- ace->a_access_mask = 0;
- ace->a_flags = 0;
- } else {
- aclent = &((aclent_t *)acl->acl_aclp)[e];
- aclent->a_id = -1;
- aclent->a_type = 0;
- aclent->a_perm = 0;
- }
-#else /* !HAVE_SUN_ACL */
-#if HAVE_DARWIN_ACL
- /*
- * Mac OS doesn't support NFSv4 ACLs for
- * owner@, group@ and everyone@.
- * We skip any of these ACLs found.
- */
- if (ae_tag == ARCHIVE_ENTRY_ACL_USER_OBJ ||
- ae_tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ ||
- ae_tag == ARCHIVE_ENTRY_ACL_EVERYONE)
- continue;
-#endif
- if (acl_create_entry(&acl, &acl_entry) != 0) {
- archive_set_error(a, errno,
- "Failed to create a new ACL entry");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
-#endif /* !HAVE_SUN_ACL */
-#if HAVE_DARWIN_ACL
- switch (ae_type) {
- case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
- acl_set_tag_type(acl_entry, ACL_EXTENDED_ALLOW);
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_DENY:
- acl_set_tag_type(acl_entry, ACL_EXTENDED_DENY);
- break;
- default:
- /* We don't support any other types on MacOS */
- continue;
- }
-#endif
- switch (ae_tag) {
-#if HAVE_SUN_ACL
- case ARCHIVE_ENTRY_ACL_USER:
- ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
- if (acl->acl_type == ACE_T)
- ace->a_who = ae_uid;
- else {
- aclent->a_id = ae_uid;
- aclent->a_type |= USER;
- }
- break;
- case ARCHIVE_ENTRY_ACL_GROUP:
- ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
- if (acl->acl_type == ACE_T) {
- ace->a_who = ae_gid;
- ace->a_flags |= ACE_IDENTIFIER_GROUP;
- } else {
- aclent->a_id = ae_gid;
- aclent->a_type |= GROUP;
- }
- break;
- case ARCHIVE_ENTRY_ACL_USER_OBJ:
- if (acl->acl_type == ACE_T)
- ace->a_flags |= ACE_OWNER;
- else
- aclent->a_type |= USER_OBJ;
- break;
- case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
- if (acl->acl_type == ACE_T) {
- ace->a_flags |= ACE_GROUP;
- ace->a_flags |= ACE_IDENTIFIER_GROUP;
- } else
- aclent->a_type |= GROUP_OBJ;
- break;
- case ARCHIVE_ENTRY_ACL_MASK:
- aclent->a_type |= CLASS_OBJ;
- break;
- case ARCHIVE_ENTRY_ACL_OTHER:
- aclent->a_type |= OTHER_OBJ;
- break;
- case ARCHIVE_ENTRY_ACL_EVERYONE:
- ace->a_flags |= ACE_EVERYONE;
- break;
-#else /* !HAVE_SUN_ACL */
- case ARCHIVE_ENTRY_ACL_USER:
- ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
-#if !HAVE_DARWIN_ACL /* FreeBSD, Linux */
- acl_set_tag_type(acl_entry, ACL_USER);
- acl_set_qualifier(acl_entry, &ae_uid);
-#else /* MacOS */
- if (mbr_identifier_to_uuid(ID_TYPE_UID, &ae_uid,
- sizeof(uid_t), ae_uuid) != 0)
- continue;
- if (acl_set_qualifier(acl_entry, &ae_uuid) != 0)
- continue;
-#endif /* HAVE_DARWIN_ACL */
- break;
- case ARCHIVE_ENTRY_ACL_GROUP:
- ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
-#if !HAVE_DARWIN_ACL /* FreeBSD, Linux */
- acl_set_tag_type(acl_entry, ACL_GROUP);
- acl_set_qualifier(acl_entry, &ae_gid);
-#else /* MacOS */
- if (mbr_identifier_to_uuid(ID_TYPE_GID, &ae_gid,
- sizeof(gid_t), ae_uuid) != 0)
- continue;
- if (acl_set_qualifier(acl_entry, &ae_uuid) != 0)
- continue;
-#endif /* HAVE_DARWIN_ACL */
- break;
-#if !HAVE_DARWIN_ACL /* FreeBSD, Linux */
- case ARCHIVE_ENTRY_ACL_USER_OBJ:
- acl_set_tag_type(acl_entry, ACL_USER_OBJ);
- break;
- case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
- acl_set_tag_type(acl_entry, ACL_GROUP_OBJ);
- break;
- case ARCHIVE_ENTRY_ACL_MASK:
- acl_set_tag_type(acl_entry, ACL_MASK);
- break;
- case ARCHIVE_ENTRY_ACL_OTHER:
- acl_set_tag_type(acl_entry, ACL_OTHER);
- break;
-#if HAVE_ACL_TYPE_NFS4 /* FreeBSD only */
- case ARCHIVE_ENTRY_ACL_EVERYONE:
- acl_set_tag_type(acl_entry, ACL_EVERYONE);
- break;
-#endif
-#endif /* !HAVE_DARWIN_ACL */
-#endif /* !HAVE_SUN_ACL */
- default:
- archive_set_error(a, ARCHIVE_ERRNO_MISC,
- "Unknown ACL tag");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
-
-#if HAVE_ACL_TYPE_NFS4 || HAVE_SUN_ACL
- r = 0;
- switch (ae_type) {
-#if HAVE_SUN_ACL
- case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
- if (ace != NULL)
- ace->a_type = ACE_ACCESS_ALLOWED_ACE_TYPE;
- else
- r = -1;
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_DENY:
- if (ace != NULL)
- ace->a_type = ACE_ACCESS_DENIED_ACE_TYPE;
- else
- r = -1;
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
- if (ace != NULL)
- ace->a_type = ACE_SYSTEM_AUDIT_ACE_TYPE;
- else
- r = -1;
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
- if (ace != NULL)
- ace->a_type = ACE_SYSTEM_ALARM_ACE_TYPE;
- else
- r = -1;
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
- if (aclent == NULL)
- r = -1;
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
- if (aclent != NULL)
- aclent->a_type |= ACL_DEFAULT;
- else
- r = -1;
- break;
-#else /* !HAVE_SUN_ACL */
- case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
- r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW);
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_DENY:
- r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_DENY);
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
- r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_AUDIT);
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
- r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALARM);
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
- case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
- // These don't translate directly into the system ACL.
- break;
-#endif /* !HAVE_SUN_ACL */
- default:
- archive_set_error(a, ARCHIVE_ERRNO_MISC,
- "Unknown ACL entry type");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
-
- if (r != 0) {
-#if HAVE_SUN_ACL
- errno = EINVAL;
-#endif
- archive_set_error(a, errno,
- "Failed to set ACL entry type");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
-#endif /* HAVE_ACL_TYPE_NFS4 || HAVE_SUN_ACL */
-
-#if HAVE_SUN_ACL
- if (acl->acl_type == ACLENT_T) {
- if (ae_permset & ARCHIVE_ENTRY_ACL_EXECUTE)
- aclent->a_perm |= 1;
- if (ae_permset & ARCHIVE_ENTRY_ACL_WRITE)
- aclent->a_perm |= 2;
- if (ae_permset & ARCHIVE_ENTRY_ACL_READ)
- aclent->a_perm |= 4;
- } else
-#else
- if (acl_get_permset(acl_entry, &acl_permset) != 0) {
- archive_set_error(a, errno,
- "Failed to get ACL permission set");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
- if (acl_clear_perms(acl_permset) != 0) {
- archive_set_error(a, errno,
- "Failed to clear ACL permissions");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
-#endif /* !HAVE_SUN_ACL */
- for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) {
- if (ae_permset & acl_perm_map[i].archive_perm) {
-#if HAVE_SUN_ACL
- ace->a_access_mask |=
- acl_perm_map[i].platform_perm;
-#else
- if (acl_add_perm(acl_permset,
- acl_perm_map[i].platform_perm) != 0) {
- archive_set_error(a, errno,
- "Failed to add ACL permission");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
-#endif
- }
- }
-
-#if HAVE_NFS4_ACL
-#if HAVE_SUN_ACL
- if (acl_type == ACE_T)
-#elif HAVE_DARWIN_ACL
- if (acl_type == ACL_TYPE_EXTENDED)
-#else /* FreeBSD */
- if (acl_type == ACL_TYPE_NFS4)
-#endif
- {
-#if HAVE_POSIX_ACL || HAVE_DARWIN_ACL
- /*
- * acl_get_flagset_np() fails with non-NFSv4 ACLs
- */
- if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
- archive_set_error(a, errno,
- "Failed to get flagset from an NFSv4 ACL entry");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
- if (acl_clear_flags_np(acl_flagset) != 0) {
- archive_set_error(a, errno,
- "Failed to clear flags from an NFSv4 ACL flagset");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
-#endif /* HAVE_POSIX_ACL || HAVE_DARWIN_ACL */
- for (i = 0; i < (int)(sizeof(acl_inherit_map) /sizeof(acl_inherit_map[0])); ++i) {
- if (ae_permset & acl_inherit_map[i].archive_inherit) {
-#if HAVE_SUN_ACL
- ace->a_flags |=
- acl_inherit_map[i].platform_inherit;
-#else /* !HAVE_SUN_ACL */
- if (acl_add_flag_np(acl_flagset,
- acl_inherit_map[i].platform_inherit) != 0) {
- archive_set_error(a, errno,
- "Failed to add flag to NFSv4 ACL flagset");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
-#endif /* HAVE_SUN_ACL */
- }
- }
- }
-#endif /* HAVE_NFS4_ACL */
-#if HAVE_SUN_ACL
- e++;
-#endif
- }
-
-#if HAVE_ACL_SET_FD_NP || HAVE_ACL_SET_FD || HAVE_SUN_ACL
- /* Try restoring the ACL through 'fd' if we can. */
-#if HAVE_SUN_ACL || HAVE_ACL_SET_FD_NP
- if (fd >= 0)
-#else /* !HAVE_SUN_ACL && !HAVE_ACL_SET_FD_NP */
- if (fd >= 0 && acl_type == ACL_TYPE_ACCESS)
-#endif
- {
-#if HAVE_SUN_ACL
- if (facl_set(fd, acl) == 0)
-#elif HAVE_ACL_SET_FD_NP
- if (acl_set_fd_np(fd, acl, acl_type) == 0)
-#else /* !HAVE_SUN_ACL && !HAVE_ACL_SET_FD_NP */
- if (acl_set_fd(fd, acl) == 0)
-#endif
- ret = ARCHIVE_OK;
- else {
- if (errno == EOPNOTSUPP) {
- /* Filesystem doesn't support ACLs */
- ret = ARCHIVE_OK;
- } else {
- archive_set_error(a, errno,
- "Failed to set %s acl on fd", tname);
- }
- }
- } else
-#endif /* HAVE_ACL_SET_FD_NP || HAVE_ACL_SET_FD || HAVE_SUN_ACL */
-#if HAVE_SUN_ACL
- if (acl_set(name, acl) != 0)
-#elif HAVE_ACL_SET_LINK_NP
- if (acl_set_link_np(name, acl_type, acl) != 0)
-#else
- /* TODO: Skip this if 'name' is a symlink. */
- if (acl_set_file(name, acl_type, acl) != 0)
-#endif
- {
- if (errno == EOPNOTSUPP) {
- /* Filesystem doesn't support ACLs */
- ret = ARCHIVE_OK;
- } else {
- archive_set_error(a, errno, "Failed to set %s acl",
- tname);
- ret = ARCHIVE_WARN;
- }
- }
-exit_free:
- acl_free(acl);
- return (ret);
-}
-#endif /* HAVE_POSIX_ACL || HAVE_NFS4_ACL */
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
index a5f30671a..affa50381 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
@@ -39,9 +39,9 @@ __FBSDID("$FreeBSD$");
#ifdef HAVE_SYS_EXTATTR_H
#include <sys/extattr.h>
#endif
-#if defined(HAVE_SYS_XATTR_H)
+#if HAVE_SYS_XATTR_H
#include <sys/xattr.h>
-#elif defined(HAVE_ATTR_XATTR_H)
+#elif HAVE_ATTR_XATTR_H
#include <attr/xattr.h>
#endif
#ifdef HAVE_SYS_EA_H
@@ -575,10 +575,55 @@ _archive_write_disk_header(struct archive *_a, struct archive_entry *entry)
if (a->flags & ARCHIVE_EXTRACT_TIME)
a->todo |= TODO_TIMES;
if (a->flags & ARCHIVE_EXTRACT_ACL) {
+#if ARCHIVE_ACL_DARWIN
+ /*
+ * On MacOS, platform ACLs get stored in mac_metadata, too.
+ * If we intend to extract mac_metadata and it is present
+ * we skip extracting libarchive NFSv4 ACLs.
+ */
+ size_t metadata_size;
+
+ if ((a->flags & ARCHIVE_EXTRACT_MAC_METADATA) == 0 ||
+ archive_entry_mac_metadata(a->entry,
+ &metadata_size) == NULL || metadata_size == 0)
+#endif
+#if ARCHIVE_ACL_LIBRICHACL
+ /*
+ * RichACLs are stored in an extended attribute.
+ * If we intend to extract extended attributes and have this
+ * attribute we skip extracting libarchive NFSv4 ACLs.
+ */
+ short extract_acls = 1;
+ if (a->flags & ARCHIVE_EXTRACT_XATTR && (
+ archive_entry_acl_types(a->entry) &
+ ARCHIVE_ENTRY_ACL_TYPE_NFS4)) {
+ const char *attr_name;
+ const void *attr_value;
+ size_t attr_size;
+ int i = archive_entry_xattr_reset(a->entry);
+ while (i--) {
+ archive_entry_xattr_next(a->entry, &attr_name,
+ &attr_value, &attr_size);
+ if (attr_name != NULL && attr_value != NULL &&
+ attr_size > 0 && strcmp(attr_name,
+ "trusted.richacl") == 0) {
+ extract_acls = 0;
+ break;
+ }
+ }
+ }
+ if (extract_acls)
+#endif
+#if ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_LIBRICHACL
+ {
+#endif
if (archive_entry_filetype(a->entry) == AE_IFDIR)
a->deferred |= TODO_ACLS;
else
a->todo |= TODO_ACLS;
+#if ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_LIBRICHACL
+ }
+#endif
}
if (a->flags & ARCHIVE_EXTRACT_MAC_METADATA) {
if (archive_entry_filetype(a->entry) == AE_IFDIR)
@@ -619,8 +664,21 @@ _archive_write_disk_header(struct archive *_a, struct archive_entry *entry)
}
#endif
- if (a->flags & ARCHIVE_EXTRACT_XATTR)
+ if (a->flags & ARCHIVE_EXTRACT_XATTR) {
+#if ARCHIVE_XATTR_DARWIN
+ /*
+ * On MacOS, extended attributes get stored in mac_metadata,
+ * too. If we intend to extract mac_metadata and it is present
+ * we skip extracting extended attributes.
+ */
+ size_t metadata_size;
+
+ if ((a->flags & ARCHIVE_EXTRACT_MAC_METADATA) == 0 ||
+ archive_entry_mac_metadata(a->entry,
+ &metadata_size) == NULL || metadata_size == 0)
+#endif
a->todo |= TODO_XATTR;
+ }
if (a->flags & ARCHIVE_EXTRACT_FFLAGS)
a->todo |= TODO_FFLAGS;
if (a->flags & ARCHIVE_EXTRACT_SECURE_SYMLINKS) {
@@ -777,7 +835,7 @@ _archive_write_disk_header(struct archive *_a, struct archive_entry *entry)
}
int
-archive_write_disk_set_skip_file(struct archive *_a, int64_t d, int64_t i)
+archive_write_disk_set_skip_file(struct archive *_a, la_int64_t d, la_int64_t i)
{
struct archive_write_disk *a = (struct archive_write_disk *)_a;
archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
@@ -1703,25 +1761,11 @@ _archive_write_disk_finish_entry(struct archive *_a)
*/
if (a->todo & TODO_ACLS) {
int r2;
-#ifdef HAVE_DARWIN_ACL
- /*
- * On Mac OS, platform ACLs are stored also in mac_metadata by
- * the operating system. If mac_metadata is present it takes
- * precedence and we skip extracting libarchive NFSv4 ACLs
- */
- const void *metadata;
- size_t metadata_size;
- metadata = archive_entry_mac_metadata(a->entry, &metadata_size);
- if ((a->todo & TODO_MAC_METADATA) == 0 ||
- metadata == NULL || metadata_size == 0) {
-#endif
r2 = archive_write_disk_set_acls(&a->archive, a->fd,
archive_entry_pathname(a->entry),
- archive_entry_acl(a->entry));
+ archive_entry_acl(a->entry),
+ archive_entry_mode(a->entry));
if (r2 < ret) ret = r2;
-#ifdef HAVE_DARWIN_ACL
- }
-#endif
}
finish_metadata:
@@ -1742,7 +1786,7 @@ finish_metadata:
int
archive_write_disk_set_group_lookup(struct archive *_a,
void *private_data,
- int64_t (*lookup_gid)(void *private, const char *gname, int64_t gid),
+ la_int64_t (*lookup_gid)(void *private, const char *gname, la_int64_t gid),
void (*cleanup_gid)(void *private))
{
struct archive_write_disk *a = (struct archive_write_disk *)_a;
@@ -1778,7 +1822,7 @@ archive_write_disk_set_user_lookup(struct archive *_a,
}
int64_t
-archive_write_disk_gid(struct archive *_a, const char *name, int64_t id)
+archive_write_disk_gid(struct archive *_a, const char *name, la_int64_t id)
{
struct archive_write_disk *a = (struct archive_write_disk *)_a;
archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
@@ -1789,7 +1833,7 @@ archive_write_disk_gid(struct archive *_a, const char *name, int64_t id)
}
int64_t
-archive_write_disk_uid(struct archive *_a, const char *name, int64_t id)
+archive_write_disk_uid(struct archive *_a, const char *name, la_int64_t id)
{
struct archive_write_disk *a = (struct archive_write_disk *)_a;
archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
@@ -1937,6 +1981,10 @@ restore_entry(struct archive_write_disk *a)
if ((en == EISDIR || en == EEXIST)
&& (a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE)) {
/* If we're not overwriting, we're done. */
+ if (S_ISDIR(a->mode)) {
+ /* Don't overwrite any settings on existing directories. */
+ a->todo = 0;
+ }
archive_entry_unset_size(a->entry);
return (ARCHIVE_OK);
}
@@ -2293,13 +2341,8 @@ _archive_write_disk_close(struct archive *_a)
if (p->fixup & TODO_MODE_BASE)
chmod(p->name, p->mode);
if (p->fixup & TODO_ACLS)
-#ifdef HAVE_DARWIN_ACL
- if ((p->fixup & TODO_MAC_METADATA) == 0 ||
- p->mac_metadata == NULL ||
- p->mac_metadata_size == 0)
-#endif
- archive_write_disk_set_acls(&a->archive,
- -1, p->name, &p->acl);
+ archive_write_disk_set_acls(&a->archive, -1, p->name,
+ &p->acl, p->mode);
if (p->fixup & TODO_FFLAGS)
set_fflags_platform(a, -1, p->name,
p->mode, p->fflags_set, 0);
@@ -2467,7 +2510,7 @@ fsobj_error(int *a_eno, struct archive_string *a_estr,
if (a_eno)
*a_eno = err;
if (a_estr)
- archive_string_sprintf(a_estr, errstr, path);
+ archive_string_sprintf(a_estr, "%s%s", errstr, path);
}
/*
@@ -2573,7 +2616,7 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
* with the deep-directory editing.
*/
fsobj_error(a_eno, a_estr, errno,
- "Could not stat %s", path);
+ "Could not stat ", path);
res = ARCHIVE_FAILED;
break;
}
@@ -2582,7 +2625,7 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
if (chdir(head) != 0) {
tail[0] = c;
fsobj_error(a_eno, a_estr, errno,
- "Could not chdir %s", path);
+ "Could not chdir ", path);
res = (ARCHIVE_FATAL);
break;
}
@@ -2599,7 +2642,7 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
if (unlink(head)) {
tail[0] = c;
fsobj_error(a_eno, a_estr, errno,
- "Could not remove symlink %s",
+ "Could not remove symlink ",
path);
res = ARCHIVE_FAILED;
break;
@@ -2618,7 +2661,7 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
/*
if (!S_ISLNK(path)) {
fsobj_error(a_eno, a_estr, 0,
- "Removing symlink %s", path);
+ "Removing symlink ", path);
}
*/
/* Symlink gone. No more problem! */
@@ -2630,7 +2673,7 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
tail[0] = c;
fsobj_error(a_eno, a_estr, 0,
"Cannot remove intervening "
- "symlink %s", path);
+ "symlink ", path);
res = ARCHIVE_FAILED;
break;
}
@@ -2652,7 +2695,7 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
} else {
fsobj_error(a_eno, a_estr,
errno,
- "Could not stat %s", path);
+ "Could not stat ", path);
res = (ARCHIVE_FAILED);
break;
}
@@ -2661,7 +2704,7 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
tail[0] = c;
fsobj_error(a_eno, a_estr,
errno,
- "Could not chdir %s", path);
+ "Could not chdir ", path);
res = (ARCHIVE_FATAL);
break;
}
@@ -2674,14 +2717,14 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
tail[0] = c;
fsobj_error(a_eno, a_estr, 0,
"Cannot extract through "
- "symlink %s", path);
+ "symlink ", path);
res = ARCHIVE_FAILED;
break;
}
} else {
tail[0] = c;
fsobj_error(a_eno, a_estr, 0,
- "Cannot extract through symlink %s", path);
+ "Cannot extract through symlink ", path);
res = ARCHIVE_FAILED;
break;
}
@@ -4044,71 +4087,98 @@ skip_appledouble:
}
#endif
-#if HAVE_LSETXATTR || HAVE_LSETEA
+#if ARCHIVE_XATTR_LINUX || ARCHIVE_XATTR_DARWIN || ARCHIVE_XATTR_AIX
/*
- * Restore extended attributes - Linux and AIX implementations:
+ * Restore extended attributes - Linux, Darwin and AIX implementations:
* AIX' ea interface is syntaxwise identical to the Linux xattr interface.
*/
static int
set_xattrs(struct archive_write_disk *a)
{
struct archive_entry *entry = a->entry;
- static int warning_done = 0;
+ struct archive_string errlist;
int ret = ARCHIVE_OK;
int i = archive_entry_xattr_reset(entry);
+ short fail = 0;
+
+ archive_string_init(&errlist);
while (i--) {
const char *name;
const void *value;
size_t size;
+ int e;
+
archive_entry_xattr_next(entry, &name, &value, &size);
- if (name != NULL &&
- strncmp(name, "xfsroot.", 8) != 0 &&
- strncmp(name, "system.", 7) != 0) {
- int e;
-#if HAVE_FSETXATTR
- if (a->fd >= 0)
- e = fsetxattr(a->fd, name, value, size, 0);
- else
-#elif HAVE_FSETEA
- if (a->fd >= 0)
- e = fsetea(a->fd, name, value, size, 0);
- else
+
+ if (name == NULL)
+ continue;
+#if ARCHIVE_XATTR_LINUX
+ /* Linux: quietly skip POSIX.1e ACL extended attributes */
+ if (strncmp(name, "system.", 7) == 0 &&
+ (strcmp(name + 7, "posix_acl_access") == 0 ||
+ strcmp(name + 7, "posix_acl_default") == 0))
+ continue;
+ if (strncmp(name, "trusted.SGI_", 12) == 0 &&
+ (strcmp(name + 12, "ACL_DEFAULT") == 0 ||
+ strcmp(name + 12, "ACL_FILE") == 0))
+ continue;
+
+ /* Linux: xfsroot namespace is obsolete and unsupported */
+ if (strncmp(name, "xfsroot.", 8) == 0) {
+ fail = 1;
+ archive_strcat(&errlist, name);
+ archive_strappend_char(&errlist, ' ');
+ continue;
+ }
#endif
- {
-#if HAVE_LSETXATTR
- e = lsetxattr(archive_entry_pathname(entry),
- name, value, size, 0);
-#elif HAVE_LSETEA
- e = lsetea(archive_entry_pathname(entry),
- name, value, size, 0);
+
+ if (a->fd >= 0) {
+#if ARCHIVE_XATTR_LINUX
+ e = fsetxattr(a->fd, name, value, size, 0);
+#elif ARCHIVE_XATTR_DARWIN
+ e = fsetxattr(a->fd, name, value, size, 0, 0);
+#elif ARCHIVE_XATTR_AIX
+ e = fsetea(a->fd, name, value, size, 0);
#endif
- }
- if (e == -1) {
- if (errno == ENOTSUP || errno == ENOSYS) {
- if (!warning_done) {
- warning_done = 1;
- archive_set_error(&a->archive,
- errno,
- "Cannot restore extended "
- "attributes on this file "
- "system");
- }
- } else
- archive_set_error(&a->archive, errno,
- "Failed to set extended attribute");
- ret = ARCHIVE_WARN;
- }
} else {
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_FILE_FORMAT,
- "Invalid extended attribute encountered");
+#if ARCHIVE_XATTR_LINUX
+ e = lsetxattr(archive_entry_pathname(entry),
+ name, value, size, 0);
+#elif ARCHIVE_XATTR_DARWIN
+ e = setxattr(archive_entry_pathname(entry),
+ name, value, size, 0, XATTR_NOFOLLOW);
+#elif ARCHIVE_XATTR_AIX
+ e = lsetea(archive_entry_pathname(entry),
+ name, value, size, 0);
+#endif
+ }
+ if (e == -1) {
ret = ARCHIVE_WARN;
+ archive_strcat(&errlist, name);
+ archive_strappend_char(&errlist, ' ');
+ if (errno != ENOTSUP && errno != ENOSYS)
+ fail = 1;
}
}
+
+ if (ret == ARCHIVE_WARN) {
+ if (fail && errlist.length > 0) {
+ errlist.length--;
+ errlist.s[errlist.length] = '\0';
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Cannot restore extended attributes: %s",
+ errlist.s);
+ } else
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Cannot restore extended "
+ "attributes on this file system.");
+ }
+
+ archive_string_free(&errlist);
return (ret);
}
-#elif HAVE_EXTATTR_SET_FILE && HAVE_DECL_EXTATTR_NAMESPACE_USER
+#elif ARCHIVE_XATTR_FREEBSD
/*
* Restore extended attributes - FreeBSD implementation
*/
@@ -4116,9 +4186,12 @@ static int
set_xattrs(struct archive_write_disk *a)
{
struct archive_entry *entry = a->entry;
- static int warning_done = 0;
+ struct archive_string errlist;
int ret = ARCHIVE_OK;
int i = archive_entry_xattr_reset(entry);
+ short fail = 0;
+
+ archive_string_init(&errlist);
while (i--) {
const char *name;
@@ -4134,46 +4207,47 @@ set_xattrs(struct archive_write_disk *a)
name += 5;
namespace = EXTATTR_NAMESPACE_USER;
} else {
- /* Warn about other extended attributes. */
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_FILE_FORMAT,
- "Can't restore extended attribute ``%s''",
- name);
+ /* Other namespaces are unsupported */
+ archive_strcat(&errlist, name);
+ archive_strappend_char(&errlist, ' ');
+ fail = 1;
ret = ARCHIVE_WARN;
continue;
}
- errno = 0;
-#if HAVE_EXTATTR_SET_FD
- if (a->fd >= 0)
+
+ if (a->fd >= 0) {
e = extattr_set_fd(a->fd, namespace, name,
value, size);
- else
-#endif
- /* TODO: should we use extattr_set_link() instead? */
- {
- e = extattr_set_file(
+ } else {
+ e = extattr_set_link(
archive_entry_pathname(entry), namespace,
name, value, size);
}
if (e != (int)size) {
- if (errno == ENOTSUP || errno == ENOSYS) {
- if (!warning_done) {
- warning_done = 1;
- archive_set_error(&a->archive,
- errno,
- "Cannot restore extended "
- "attributes on this file "
- "system");
- }
- } else {
- archive_set_error(&a->archive, errno,
- "Failed to set extended attribute");
- }
-
+ archive_strcat(&errlist, name);
+ archive_strappend_char(&errlist, ' ');
ret = ARCHIVE_WARN;
+ if (errno != ENOTSUP && errno != ENOSYS)
+ fail = 1;
}
}
}
+
+ if (ret == ARCHIVE_WARN) {
+ if (fail && errlist.length > 0) {
+ errlist.length--;
+ errlist.s[errlist.length] = '\0';
+
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Cannot restore extended attributes: %s",
+ errlist.s);
+ } else
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Cannot restore extended "
+ "attributes on this file system.");
+ }
+
+ archive_string_free(&errlist);
return (ret);
}
#else
@@ -4239,5 +4313,19 @@ older(struct stat *st, struct archive_entry *entry)
return (0);
}
+#ifndef ARCHIVE_ACL_SUPPORT
+int
+archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
+ struct archive_acl *abstract_acl, __LA_MODE_T mode)
+{
+ (void)a; /* UNUSED */
+ (void)fd; /* UNUSED */
+ (void)name; /* UNUSED */
+ (void)abstract_acl; /* UNUSED */
+ (void)mode; /* UNUSED */
+ return (ARCHIVE_OK);
+}
+#endif
+
#endif /* !_WIN32 || __CYGWIN__ */
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_private.h b/Utilities/cmlibarchive/libarchive/archive_write_disk_private.h
index d84e7e1cd..b655dea2b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_private.h
@@ -33,11 +33,13 @@
#ifndef ARCHIVE_WRITE_DISK_PRIVATE_H_INCLUDED
#define ARCHIVE_WRITE_DISK_PRIVATE_H_INCLUDED
+#include "archive_platform_acl.h"
#include "archive_acl_private.h"
+#include "archive_entry.h"
struct archive_write_disk;
-int
-archive_write_disk_set_acls(struct archive *, int /* fd */, const char * /* pathname */, struct archive_acl *);
+int archive_write_disk_set_acls(struct archive *, int, const char *,
+ struct archive_acl *, __LA_MODE_T);
#endif
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
index 94b016edf..78eda4abc 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
@@ -906,7 +906,7 @@ _archive_write_disk_header(struct archive *_a, struct archive_entry *entry)
}
int
-archive_write_disk_set_skip_file(struct archive *_a, int64_t d, int64_t i)
+archive_write_disk_set_skip_file(struct archive *_a, la_int64_t d, la_int64_t i)
{
struct archive_write_disk *a = (struct archive_write_disk *)_a;
archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
@@ -1156,7 +1156,7 @@ _archive_write_disk_finish_entry(struct archive *_a)
int
archive_write_disk_set_group_lookup(struct archive *_a,
void *private_data,
- int64_t (*lookup_gid)(void *private, const char *gname, int64_t gid),
+ la_int64_t (*lookup_gid)(void *private, const char *gname, la_int64_t gid),
void (*cleanup_gid)(void *private))
{
struct archive_write_disk *a = (struct archive_write_disk *)_a;
@@ -1192,7 +1192,7 @@ archive_write_disk_set_user_lookup(struct archive *_a,
}
int64_t
-archive_write_disk_gid(struct archive *_a, const char *name, int64_t id)
+archive_write_disk_gid(struct archive *_a, const char *name, la_int64_t id)
{
struct archive_write_disk *a = (struct archive_write_disk *)_a;
archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
@@ -1203,7 +1203,7 @@ archive_write_disk_gid(struct archive *_a, const char *name, int64_t id)
}
int64_t
-archive_write_disk_uid(struct archive *_a, const char *name, int64_t id)
+archive_write_disk_uid(struct archive *_a, const char *name, la_int64_t id)
{
struct archive_write_disk *a = (struct archive_write_disk *)_a;
archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
@@ -1322,9 +1322,20 @@ restore_entry(struct archive_write_disk *a)
}
}
+ if ((en == ENOENT) && (archive_entry_hardlink(a->entry) != NULL)) {
+ archive_set_error(&a->archive, en,
+ "Hard-link target '%s' does not exist.",
+ archive_entry_hardlink(a->entry));
+ return (ARCHIVE_FAILED);
+ }
+
if ((en == EISDIR || en == EEXIST)
&& (a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE)) {
/* If we're not overwriting, we're done. */
+ if (S_ISDIR(a->mode)) {
+ /* Don't overwrite any settings on existing directories. */
+ a->todo = 0;
+ }
archive_entry_unset_size(a->entry);
return (ARCHIVE_OK);
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_filter.3 b/Utilities/cmlibarchive/libarchive/archive_write_filter.3
index e1d189150..d6fa07131 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_filter.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write_filter.3
@@ -42,7 +42,8 @@
.Nm archive_write_add_filter_none ,
.Nm archive_write_add_filter_program ,
.Nm archive_write_add_filter_uuencode ,
-.Nm archive_write_add_filter_xz
+.Nm archive_write_add_filter_xz ,
+.Nm archive_write_add_filter_zstd ,
.Nd functions enabling output filters
.Sh LIBRARY
Streaming Archive Library (libarchive, -larchive)
@@ -76,6 +77,8 @@ Streaming Archive Library (libarchive, -larchive)
.Fn archive_write_add_filter_uuencode "struct archive *"
.Ft int
.Fn archive_write_add_filter_xz "struct archive *"
+.Ft int
+.Fn archive_write_add_filter_zstd "struct archive *"
.Sh DESCRIPTION
.Bl -tag -width indent
.It Xo
@@ -89,6 +92,7 @@ Streaming Archive Library (libarchive, -larchive)
.Fn archive_write_add_filter_lzma ,
.Fn archive_write_add_filter_lzop ,
.Fn archive_write_add_filter_xz ,
+.Fn archive_write_add_filter_zstd ,
.Xc
The resulting archive will be compressed as specified.
Note that the compressed output is always properly blocked.
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_finish_entry.3 b/Utilities/cmlibarchive/libarchive/archive_write_finish_entry.3
index c5ef69ebc..dc1b94b82 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_finish_entry.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write_finish_entry.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 2, 2012
+.Dd February 28, 2017
.Dt ARCHIVE_WRITE_FINISH_ENTRY 3
.Os
.Sh NAME
@@ -45,6 +45,9 @@ is called automatically by
and
.Fn archive_write_close
as needed.
+For
+.Tn archive_write_disk
+handles, this flushes pending file attribute changes like modification time.
.\" .Sh EXAMPLE
.Sh RETURN VALUES
This function returns
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_format.3 b/Utilities/cmlibarchive/libarchive/archive_write_format.3
index d4ba6abff..aaafb0a86 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_format.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write_format.3
@@ -108,7 +108,6 @@ Streaming Archive Library (libarchive, -larchive)
These functions set the format that will be used for the archive.
.Pp
The library can write a variety of common archive formats.
-
.Bl -tag -width indent
.It Fn archive_write_set_format
Sets the format based on the format code (see
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format.c
index 744302d06..0f706231a 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format.c
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format.c 201168 2009-1
#include "archive_private.h"
/* A table that maps format codes to functions. */
-static
+static const
struct { int code; int (*setter)(struct archive *); } codes[] =
{
{ ARCHIVE_FORMAT_7ZIP, archive_write_set_format_7zip },
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c
index 3fc5a07d7..2bd4ec41f 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c
@@ -2095,19 +2095,6 @@ compression_init_encoder_lzma2(struct archive *a,
/*
* _7_PPMD compressor.
*/
-static void *
-ppmd_alloc(void *p, size_t size)
-{
- (void)p;
- return malloc(size);
-}
-static void
-ppmd_free(void *p, void *address)
-{
- (void)p;
- free(address);
-}
-static ISzAlloc g_szalloc = { ppmd_alloc, ppmd_free };
static void
ppmd_write(void *p, Byte b)
{
@@ -2167,7 +2154,7 @@ compression_init_encoder_ppmd(struct archive *a,
archive_le32enc(props+1, msize);
__archive_ppmd7_functions.Ppmd7_Construct(&strm->ppmd7_context);
r = __archive_ppmd7_functions.Ppmd7_Alloc(
- &strm->ppmd7_context, msize, &g_szalloc);
+ &strm->ppmd7_context, msize);
if (r == 0) {
free(strm->buff);
free(strm);
@@ -2243,7 +2230,7 @@ compression_end_ppmd(struct archive *a, struct la_zstream *lastrm)
(void)a; /* UNUSED */
strm = (struct ppmd_stream *)lastrm->real_stream;
- __archive_ppmd7_functions.Ppmd7_Free(&strm->ppmd7_context, &g_szalloc);
+ __archive_ppmd7_functions.Ppmd7_Free(&strm->ppmd7_context);
free(strm->buff);
free(strm);
lastrm->real_stream = NULL;
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_ar.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_ar.c
index c9771d81a..50305ccbe 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_ar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_ar.c
@@ -180,7 +180,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
}
memset(buff, ' ', 60);
- strncpy(&buff[AR_fmag_offset], "`\n", 2);
+ memcpy(&buff[AR_fmag_offset], "`\n", 2);
if (strcmp(pathname, "/") == 0 ) {
/* Entry is archive symbol table in GNU format */
@@ -189,7 +189,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
}
if (strcmp(pathname, "__.SYMDEF") == 0) {
/* Entry is archive symbol table in BSD format */
- strncpy(buff + AR_name_offset, "__.SYMDEF", 9);
+ memcpy(buff + AR_name_offset, "__.SYMDEF", 9);
goto stat;
}
if (strcmp(pathname, "//") == 0) {
@@ -225,7 +225,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
* actually 15 bytes.
*/
if (strlen(filename) <= 15) {
- strncpy(&buff[AR_name_offset],
+ memcpy(&buff[AR_name_offset],
filename, strlen(filename));
buff[AR_name_offset + strlen(filename)] = '/';
} else {
@@ -248,7 +248,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
return (ARCHIVE_FATAL);
}
- strncpy(se, filename, strlen(filename));
+ memcpy(se, filename, strlen(filename));
strcpy(se + strlen(filename), "/\n");
ss = strstr(ar->strtab, se);
@@ -285,11 +285,11 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
* archive header.
*/
if (strlen(filename) <= 16 && strchr(filename, ' ') == NULL) {
- strncpy(&buff[AR_name_offset], filename, strlen(filename));
+ memcpy(&buff[AR_name_offset], filename, strlen(filename));
buff[AR_name_offset + strlen(filename)] = ' ';
}
else {
- strncpy(buff + AR_name_offset, "#1/", 3);
+ memcpy(buff + AR_name_offset, "#1/", 3);
if (format_decimal(strlen(filename),
buff + AR_name_offset + 3,
AR_name_size - 3)) {
@@ -374,13 +374,14 @@ archive_write_ar_data(struct archive_write *a, const void *buff, size_t s)
return (ARCHIVE_WARN);
}
- ar->strtab = (char *)malloc(s);
+ ar->strtab = (char *)malloc(s + 1);
if (ar->strtab == NULL) {
archive_set_error(&a->archive, ENOMEM,
"Can't allocate strtab buffer");
return (ARCHIVE_FATAL);
}
- strncpy(ar->strtab, buff, s);
+ memcpy(ar->strtab, buff, s);
+ ar->strtab[s] = '\0';
ar->has_strtab = 1;
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c
index a2ce7c6cd..86e8621ef 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c
@@ -41,7 +41,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_by_name.c 20116
#include "archive_private.h"
/* A table that maps names to functions. */
-static
+static const
struct { const char *name; int (*setter)(struct archive *); } names[] =
{
{ "7zip", archive_write_set_format_7zip },
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_filter_by_ext.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_filter_by_ext.c
index adec9b265..9fe21e454 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_filter_by_ext.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_filter_by_ext.c
@@ -42,7 +42,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_by_name.c 20116
#include "archive_private.h"
/* A table that maps names to functions. */
-static
+static const
struct { const char *name; int (*format)(struct archive *); int (*filter)(struct archive *); } names[] =
{
{ ".7z", archive_write_set_format_7zip, archive_write_add_filter_none},
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c
index 6a301ac2d..3cebeae18 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c
@@ -1196,8 +1196,12 @@ archive_write_pax_header(struct archive_write *a,
"GNU.sparse.major", 1);
add_pax_attr_int(&(pax->pax_header),
"GNU.sparse.minor", 0);
+ /*
+ * Make sure to store the original path, since
+ * truncation to ustar limit happened already.
+ */
add_pax_attr(&(pax->pax_header),
- "GNU.sparse.name", entry_name.s);
+ "GNU.sparse.name", path);
add_pax_attr_int(&(pax->pax_header),
"GNU.sparse.realsize",
archive_entry_size(entry_main));
@@ -1650,13 +1654,14 @@ build_pax_attribute_name(char *dest, const char *src)
* GNU PAX Format 1.0 requires the special name, which pattern is:
* <dir>/GNUSparseFile.<pid>/<original file name>
*
+ * Since reproducible archives are more important, use 0 as pid.
+ *
* This function is used for only Sparse file, a file type of which
* is regular file.
*/
static char *
build_gnu_sparse_name(char *dest, const char *src)
{
- char buff[64];
const char *p;
/* Handle the null filename case. */
@@ -1682,15 +1687,9 @@ build_gnu_sparse_name(char *dest, const char *src)
break;
}
-#if HAVE_GETPID && 0 /* Disable this as pax attribute name. */
- sprintf(buff, "GNUSparseFile.%d", getpid());
-#else
- /* If the platform can't fetch the pid, don't include it. */
- strcpy(buff, "GNUSparseFile");
-#endif
/* General case: build a ustar-compatible name adding
* "/GNUSparseFile/". */
- build_ustar_entry_name(dest, src, p - src, buff);
+ build_ustar_entry_name(dest, src, p - src, "GNUSparseFile.0");
return (dest);
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_warc.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_warc.c
index 8b6daf942..edad072cf 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_warc.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_warc.c
@@ -354,7 +354,7 @@ static ssize_t
_popul_ehdr(struct archive_string *tgt, size_t tsz, warc_essential_hdr_t hdr)
{
static const char _ver[] = "WARC/1.0\r\n";
- static const char *_typ[LAST_WT] = {
+ static const char * const _typ[LAST_WT] = {
NULL, "warcinfo", "metadata", "resource", NULL
};
char std_uuid[48U];
diff --git a/Utilities/cmlibarchive/libarchive/config_freebsd.h b/Utilities/cmlibarchive/libarchive/config_freebsd.h
index 215e886be..be25258f9 100644
--- a/Utilities/cmlibarchive/libarchive/config_freebsd.h
+++ b/Utilities/cmlibarchive/libarchive/config_freebsd.h
@@ -22,141 +22,238 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: head/lib/libarchive/config_freebsd.h 201079 2009-12-28 02:01:42Z kientzle $
+ * $FreeBSD$
*/
-/* FreeBSD 5.0 and later have ACL and extattr support. */
+#include <osreldate.h>
+
+/* FreeBSD 5.0 and later has ACL and extattr support. */
#if __FreeBSD__ > 4
-#define HAVE_ACL_CREATE_ENTRY 1
-#define HAVE_ACL_GET_FD_NP 1
-#define HAVE_ACL_GET_LINK_NP 1
-#define HAVE_ACL_GET_PERM_NP 1
-#define HAVE_ACL_INIT 1
-#define HAVE_ACL_SET_FD 1
-#define HAVE_ACL_SET_FD_NP 1
-#define HAVE_ACL_SET_FILE 1
-#define HAVE_ACL_USER 1
-#define HAVE_EXTATTR_GET_FILE 1
-#define HAVE_EXTATTR_LIST_FILE 1
-#define HAVE_EXTATTR_SET_FD 1
-#define HAVE_EXTATTR_SET_FILE 1
-#define HAVE_STRUCT_XVFSCONF 1
-#define HAVE_SYS_ACL_H 1
-#define HAVE_SYS_EXTATTR_H 1
-#endif
+#define ARCHIVE_ACL_FREEBSD 1
+#define HAVE_ACL_GET_PERM_NP 1
+#define HAVE_ARC4RANDOM_BUF 1
+#define HAVE_EXTATTR_GET_FILE 1
+#define HAVE_EXTATTR_LIST_FILE 1
+#define HAVE_EXTATTR_SET_FD 1
+#define HAVE_EXTATTR_SET_FILE 1
+#define HAVE_STRUCT_XVFSCONF 1
+#define HAVE_SYS_ACL_H 1
+#define HAVE_SYS_EXTATTR_H 1
+#if __FreeBSD__ > 7
+/* FreeBSD 8.0 and later has NFSv4 ACL support */
+#define ARCHIVE_ACL_FREEBSD_NFS4 1
+#define HAVE_ACL_GET_LINK_NP 1
+#define HAVE_ACL_IS_TRIVIAL_NP 1
+#define HAVE_ACL_SET_LINK_NP 1
+#endif /* __FreeBSD__ > 7 */
+#endif /* __FreeBSD__ > 4 */
#ifdef WITH_OPENSSL
-#define HAVE_OPENSSL_MD5_H 1
-#define HAVE_OPENSSL_RIPEMD_H 1
-#define HAVE_OPENSSL_SHA_H 1
-#define HAVE_SHA384 1
-#define HAVE_SHA512 1
+#define HAVE_LIBCRYPTO 1
+#define HAVE_OPENSSL_EVP_H 1
+#define HAVE_OPENSSL_MD5_H 1
+#define HAVE_OPENSSL_RIPEMD_H 1
+#define HAVE_OPENSSL_SHA_H 1
+#define HAVE_OPENSSL_SHA256_INIT 1
+#define HAVE_OPENSSL_SHA384_INIT 1
+#define HAVE_OPENSSL_SHA512_INIT 1
+#define HAVE_PKCS5_PBKDF2_HMAC_SHA1 1
+#define HAVE_SHA256 1
+#define HAVE_SHA384 1
+#define HAVE_SHA512 1
+#else
+#define HAVE_LIBMD 1
+#define HAVE_MD5_H 1
+#define HAVE_MD5INIT 1
+#define HAVE_RIPEMD_H 1
+#define HAVE_SHA_H 1
+#define HAVE_SHA1 1
+#define HAVE_SHA1_INIT 1
+#define HAVE_SHA256 1
+#define HAVE_SHA256_H 1
+#define HAVE_SHA256_INIT 1
+#define HAVE_SHA512 1
+#define HAVE_SHA512_H 1
+#define HAVE_SHA512_INIT 1
#endif
-#define HAVE_BSDXML_H 1
-#define HAVE_BZLIB_H 1
-#define HAVE_CHFLAGS 1
-#define HAVE_CHOWN 1
-#define HAVE_DECL_INT64_MAX 1
-#define HAVE_DECL_INT64_MIN 1
-#define HAVE_DECL_SIZE_MAX 1
-#define HAVE_DECL_SSIZE_MAX 1
-#define HAVE_DECL_STRERROR_R 1
-#define HAVE_DECL_UINT32_MAX 1
-#define HAVE_DECL_UINT64_MAX 1
-#define HAVE_DIRENT_H 1
-#define HAVE_EFTYPE 1
-#define HAVE_EILSEQ 1
-#define HAVE_ERRNO_H 1
-#define HAVE_FCHDIR 1
-#define HAVE_FCHFLAGS 1
-#define HAVE_FCHMOD 1
-#define HAVE_FCHOWN 1
-#define HAVE_FCNTL 1
-#define HAVE_FCNTL_H 1
-#define HAVE_FSEEKO 1
-#define HAVE_FSTAT 1
-#define HAVE_FTRUNCATE 1
-#define HAVE_FUTIMES 1
-#define HAVE_GETEUID 1
-#define HAVE_GETGRGID_R 1
-#define HAVE_GETPID 1
-#define HAVE_GETPWUID_R 1
-#define HAVE_GRP_H 1
-#define HAVE_INTTYPES_H 1
-#define HAVE_LCHFLAGS 1
-#define HAVE_LCHMOD 1
-#define HAVE_LCHOWN 1
-#define HAVE_LIMITS_H 1
-#define HAVE_LINK 1
-#define HAVE_LSTAT 1
-#define HAVE_LUTIMES 1
-#define HAVE_MALLOC 1
-#define HAVE_MD5 1
-#define HAVE_MD5_H 1
-#define HAVE_MEMMOVE 1
-#define HAVE_MKDIR 1
-#define HAVE_MKFIFO 1
-#define HAVE_MKNOD 1
-#define HAVE_PIPE 1
-#define HAVE_POLL 1
-#define HAVE_POLL_H 1
-#define HAVE_PWD_H 1
-#define HAVE_READLINK 1
-#define HAVE_RMD160 1
-#define HAVE_SELECT 1
-#define HAVE_SETENV 1
-#define HAVE_SHA_H 1
-#define HAVE_SHA1 1
-#define HAVE_SHA256 1
-#define HAVE_SHA256_H 1
-#define HAVE_SIGNAL_H 1
-#define HAVE_STDINT_H 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STRCHR 1
-#define HAVE_STRDUP 1
-#define HAVE_STRERROR 1
-#define HAVE_STRERROR_R 1
-#define HAVE_STRINGS_H 1
-#define HAVE_STRING_H 1
-#define HAVE_STRRCHR 1
-#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
-#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
-#define HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 1
-#define HAVE_STRUCT_STAT_ST_FLAGS 1
-#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
-#define HAVE_STRUCT_TM_TM_GMTOFF 1
-#define HAVE_SYMLINK 1
-#define HAVE_SYS_CDEFS_H 1
-#define HAVE_SYS_IOCTL_H 1
-#define HAVE_SYS_MOUNT_H 1
-#define HAVE_SYS_PARAM_H 1
-#define HAVE_SYS_SELECT_H 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TIME_H 1
-#define HAVE_SYS_TYPES_H 1
-#undef HAVE_SYS_UTIME_H
-#define HAVE_SYS_UTSNAME_H 1
-#define HAVE_SYS_WAIT_H 1
-#define HAVE_TIMEGM 1
-#define HAVE_TZSET 1
-#define HAVE_UNISTD_H 1
-#define HAVE_UNSETENV 1
-#define HAVE_UTIME 1
-#define HAVE_UTIMES 1
-#define HAVE_UTIME_H 1
-#define HAVE_VFORK 1
-#define HAVE_WCHAR_H 1
-#define HAVE_WCSCPY 1
-#define HAVE_WCSLEN 1
-#define HAVE_WCTOMB 1
-#define HAVE_WMEMCMP 1
-#define HAVE_WMEMCPY 1
-#define HAVE_ZLIB_H 1
-#define TIME_WITH_SYS_TIME 1
+#define HAVE_BSDXML_H 1
+#define HAVE_BZLIB_H 1
+#define HAVE_CHFLAGS 1
+#define HAVE_CHOWN 1
+#define HAVE_CHROOT 1
+#define HAVE_CTIME_R 1
+#define HAVE_CTYPE_H 1
+#define HAVE_DECL_EXTATTR_NAMESPACE_USER 1
+#define HAVE_DECL_INT32_MAX 1
+#define HAVE_DECL_INT32_MIN 1
+#define HAVE_DECL_INT64_MAX 1
+#define HAVE_DECL_INT64_MIN 1
+#define HAVE_DECL_INTMAX_MAX 1
+#define HAVE_DECL_INTMAX_MIN 1
+#define HAVE_DECL_SIZE_MAX 1
+#define HAVE_DECL_SSIZE_MAX 1
+#define HAVE_DECL_STRERROR_R 1
+#define HAVE_DECL_UINT32_MAX 1
+#define HAVE_DECL_UINT64_MAX 1
+#define HAVE_DECL_UINTMAX_MAX 1
+#define HAVE_DIRENT_H 1
+#define HAVE_DLFCN_H 1
+#define HAVE_D_MD_ORDER 1
+#define HAVE_EFTYPE 1
+#define HAVE_EILSEQ 1
+#define HAVE_ERRNO_H 1
+#define HAVE_FCHDIR 1
+#define HAVE_FCHFLAGS 1
+#define HAVE_FCHMOD 1
+#define HAVE_FCHOWN 1
+#define HAVE_FCNTL 1
+#define HAVE_FCNTL_H 1
+#define HAVE_FDOPENDIR 1
+#define HAVE_FORK 1
+#define HAVE_FSEEKO 1
+#define HAVE_FSTAT 1
+#define HAVE_FSTATAT 1
+#define HAVE_FSTATFS 1
+#define HAVE_FSTATVFS 1
+#define HAVE_FTRUNCATE 1
+#define HAVE_FUTIMES 1
+#define HAVE_FUTIMESAT 1
+#define HAVE_GETEUID 1
+#define HAVE_GETGRGID_R 1
+#define HAVE_GETGRNAM_R 1
+#define HAVE_GETPID 1
+#define HAVE_GETPWNAM_R 1
+#define HAVE_GETPWUID_R 1
+#define HAVE_GETVFSBYNAME 1
+#define HAVE_GMTIME_R 1
+#define HAVE_GRP_H 1
+#define HAVE_INTMAX_T 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_LANGINFO_H 1
+#define HAVE_LCHFLAGS 1
+#define HAVE_LCHMOD 1
+#define HAVE_LCHOWN 1
+#define HAVE_LIBZ 1
+#define HAVE_LIMITS_H 1
+#define HAVE_LINK 1
+#define HAVE_LOCALE_H 1
+#define HAVE_LOCALTIME_R 1
+#define HAVE_LONG_LONG_INT 1
+#define HAVE_LSTAT 1
+#define HAVE_LUTIMES 1
+#define HAVE_MBRTOWC 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMORY_H 1
+#define HAVE_MEMSET 1
+#define HAVE_MKDIR 1
+#define HAVE_MKFIFO 1
+#define HAVE_MKNOD 1
+#define HAVE_MKSTEMP 1
+#define HAVE_NL_LANGINFO 1
+#define HAVE_OPENAT 1
+#define HAVE_PATHS_H 1
+#define HAVE_PIPE 1
+#define HAVE_POLL 1
+#define HAVE_POLL_H 1
+#define HAVE_POSIX_SPAWNP 1
+#define HAVE_PTHREAD_H 1
+#define HAVE_PWD_H 1
+#define HAVE_READDIR_R 1
+#define HAVE_READLINK 1
+#define HAVE_READLINKAT 1
+#define HAVE_READPASSPHRASE 1
+#define HAVE_READPASSPHRASE_H 1
+#define HAVE_REGEX_H 1
+#define HAVE_SELECT 1
+#define HAVE_SETENV 1
+#define HAVE_SETLOCALE 1
+#define HAVE_SIGACTION 1
+#define HAVE_SIGNAL_H 1
+#define HAVE_SPAWN_H 1
+#define HAVE_STATFS 1
+#define HAVE_STATVFS 1
+#define HAVE_STDARG_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRCHR 1
+#define HAVE_STRDUP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRERROR_R 1
+#define HAVE_STRFTIME 1
+#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRUCT_STATFS_F_NAMEMAX 1
+#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
+#define HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 1
+#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
+#define HAVE_STRUCT_STAT_ST_FLAGS 1
+#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
+#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1
+#define HAVE_STRUCT_TM_TM_GMTOFF 1
+#define HAVE_SYMLINK 1
+#define HAVE_SYS_CDEFS_H 1
+#define HAVE_SYS_IOCTL_H 1
+#define HAVE_SYS_MOUNT_H 1
+#define HAVE_SYS_PARAM_H 1
+#define HAVE_SYS_POLL_H 1
+#define HAVE_SYS_SELECT_H 1
+#define HAVE_SYS_STATVFS_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TIME_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_UTSNAME_H 1
+#define HAVE_SYS_WAIT_H 1
+#define HAVE_TIMEGM 1
+#define HAVE_TIME_H 1
+#define HAVE_TZSET 1
+#define HAVE_UINTMAX_T 1
+#define HAVE_UNISTD_H 1
+#define HAVE_UNSETENV 1
+#define HAVE_UNSIGNED_LONG_LONG 1
+#define HAVE_UNSIGNED_LONG_LONG_INT 1
+#define HAVE_UTIME 1
+#define HAVE_UTIMES 1
+#define HAVE_UTIME_H 1
+#define HAVE_VFORK 1
+#define HAVE_VPRINTF 1
+#define HAVE_WCHAR_H 1
+#define HAVE_WCHAR_T 1
+#define HAVE_WCRTOMB 1
+#define HAVE_WCSCMP 1
+#define HAVE_WCSCPY 1
+#define HAVE_WCSLEN 1
+#define HAVE_WCTOMB 1
+#define HAVE_WCTYPE_H 1
+#define HAVE_WMEMCMP 1
+#define HAVE_WMEMCPY 1
+#define HAVE_WMEMMOVE 1
+#define HAVE_ZLIB_H 1
+#define TIME_WITH_SYS_TIME 1
+
+#if __FreeBSD_version >= 1100056
+#define HAVE_FUTIMENS 1
+#define HAVE_UTIMENSAT 1
+#endif
/* FreeBSD 4 and earlier lack intmax_t/uintmax_t */
#if __FreeBSD__ < 5
-#define intmax_t int64_t
-#define uintmax_t uint64_t
+#define intmax_t int64_t
+#define uintmax_t uint64_t
+#endif
+
+/* FreeBSD defines for archive_hash.h */
+#ifdef WITH_OPENSSL
+#define ARCHIVE_CRYPTO_MD5_OPENSSL 1
+#define ARCHIVE_CRYPTO_RMD160_OPENSSL 1
+#define ARCHIVE_CRYPTO_SHA1_OPENSSL
+#define ARCHIVE_CRYPTO_SHA256_OPENSSL 1
+#define ARCHIVE_CRYPTO_SHA384_OPENSSL 1
+#define ARCHIVE_CRYPTO_SHA512_OPENSSL 1
+#else
+#define ARCHIVE_CRYPTO_MD5_LIBMD 1
+#define ARCHIVE_CRYPTO_SHA1_LIBMD 1
+#define ARCHIVE_CRYPTO_SHA256_LIBMD 1
+#define ARCHIVE_CRYPTO_SHA512_LIBMD 1
#endif
diff --git a/Utilities/cmlibarchive/libarchive/libarchive_changes.3 b/Utilities/cmlibarchive/libarchive/libarchive_changes.3
index 881a67cdd..adc87febd 100644
--- a/Utilities/cmlibarchive/libarchive/libarchive_changes.3
+++ b/Utilities/cmlibarchive/libarchive/libarchive_changes.3
@@ -28,6 +28,7 @@
.Dt LIBARCHIVE_CHANGES 3
.Os
.Sh NAME
+.Nm libarchive_changes
.Nd changes in libarchive interface
.\"
.Sh CHANGES IN LIBARCHIVE 3
diff --git a/Utilities/cmlibarchive/libarchive/mtree.5 b/Utilities/cmlibarchive/libarchive/mtree.5
index 16c8abec4..e607e4a81 100644
--- a/Utilities/cmlibarchive/libarchive/mtree.5
+++ b/Utilities/cmlibarchive/libarchive/mtree.5
@@ -48,7 +48,7 @@ Leading whitespace is always ignored.
.Pp
When encoding file or pathnames, any backslash character or
character outside of the 95 printable ASCII characters must be
-encoded as a a backslash followed by three
+encoded as a backslash followed by three
octal digits.
When reading mtree files, any appearance of a backslash
followed by three octal digits should be converted into the
diff --git a/Utilities/cmlibarchive/libarchive/xxhash.c b/Utilities/cmlibarchive/libarchive/xxhash.c
index 6f5ba52fa..70750bae0 100644
--- a/Utilities/cmlibarchive/libarchive/xxhash.c
+++ b/Utilities/cmlibarchive/libarchive/xxhash.c
@@ -141,13 +141,19 @@ typedef struct _U32_S { U32 v; } _PACKED U32_S;
# pragma pack(pop)
#endif
-#define A32(x) (((const U32_S *)(x))->v)
-
/****************************************
** Compiler-specific Functions and Macros
*****************************************/
-#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+#define GCC_VERSION ((__GNUC__-0) * 100 + (__GNUC_MINOR__ - 0))
+
+#if GCC_VERSION >= 409
+__attribute__((__no_sanitize_undefined__))
+#endif
+static inline U32 A32(const void * x)
+{
+ return (((const U32_S *)(x))->v);
+}
/* Note : although _rotl exists for minGW (GCC under windows), performance seems poor */
#if defined(_MSC_VER)
diff --git a/Utilities/cmliblzma/CMakeLists.txt b/Utilities/cmliblzma/CMakeLists.txt
index bb3b8a71f..b443fd6bc 100644
--- a/Utilities/cmliblzma/CMakeLists.txt
+++ b/Utilities/cmliblzma/CMakeLists.txt
@@ -6,22 +6,6 @@ include(CheckSymbolExists)
include(CheckTypeSize)
include(TestBigEndian)
-CHECK_C_SOURCE_COMPILES(
- "int test (void *restrict x);\nint main (void) {return 0;}"
- HAVE_RESTRICT)
-
-CHECK_C_SOURCE_COMPILES(
-"typedef struct abc *d;\nint test (d __restrict x);\nint main (void) {return 0;}"
- HAVE___RESTRICT)
-
-CHECK_C_SOURCE_COMPILES(
- "static inline int test (void) {return 0;}\nint main (void) {return test();}"
- HAVE_INLINE)
-
-CHECK_C_SOURCE_COMPILES (
- "static __inline int test (void) {return 0;}\nint main (void) {return test();}"
- HAVE___INLINE)
-
CHECK_INCLUDE_FILE(byteswap.h HAVE_BYTESWAP_H)
CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
CHECK_INCLUDE_FILE(limits.h HAVE_LIMITS_H)
@@ -95,7 +79,7 @@ CHECK_TYPE_SIZE("unsigned short" SIZE_OF_UNSIGNED_SHORT)
CHECK_TYPE_SIZE("unsigned" SIZE_OF_UNSIGNED)
CHECK_TYPE_SIZE("unsigned long" SIZE_OF_UNSIGNED_LONG)
CHECK_TYPE_SIZE("unsigned long long" SIZE_OF_UNSIGNED_LONG_LONG)
-CHECK_TYPE_SIZE("size_t" SIZE_OF_SIZE_T)
+CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T)
CHECK_TYPE_SIZE("__int64" __INT64)
CHECK_TYPE_SIZE("unsigned __int64" UNSIGNED___INT64)
@@ -199,7 +183,7 @@ INCLUDE_DIRECTORIES(
# Disable warnings to avoid changing 3rd party code.
IF(CMAKE_C_COMPILER_ID MATCHES
- "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
+ "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel)$")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
diff --git a/Utilities/cmliblzma/COPYING b/Utilities/cmliblzma/COPYING
index 43c90d059..20e60d5b2 100644
--- a/Utilities/cmliblzma/COPYING
+++ b/Utilities/cmliblzma/COPYING
@@ -47,7 +47,7 @@ XZ Utils Licensing
naturally it is not legally required. Here is an example of a good
notice to put into "about box" or into documentation:
- This software includes code from XZ Utils <http://tukaani.org/xz/>.
+ This software includes code from XZ Utils <https://tukaani.org/xz/>.
The following license texts are included in the following files:
- COPYING.LGPLv2.1: GNU Lesser General Public License version 2.1
diff --git a/Utilities/cmliblzma/common/common_w32res.rc b/Utilities/cmliblzma/common/common_w32res.rc
index fdb88d184..a70de3432 100644
--- a/Utilities/cmliblzma/common/common_w32res.rc
+++ b/Utilities/cmliblzma/common/common_w32res.rc
@@ -17,7 +17,7 @@
#define MY_VERSION LZMA_VERSION_MAJOR,LZMA_VERSION_MINOR,LZMA_VERSION_PATCH,MY_BUILD
#define MY_FILENAME MY_NAME MY_SUFFIX
-#define MY_COMPANY "The Tukaani Project <http://tukaani.org/>"
+#define MY_COMPANY "The Tukaani Project <https://tukaani.org/>"
#define MY_PRODUCT PACKAGE_NAME " <" PACKAGE_URL ">"
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
diff --git a/Utilities/cmliblzma/common/sysdefs.h b/Utilities/cmliblzma/common/sysdefs.h
index a6edea8b0..22f487b9e 100644
--- a/Utilities/cmliblzma/common/sysdefs.h
+++ b/Utilities/cmliblzma/common/sysdefs.h
@@ -18,6 +18,7 @@
#if defined(_MSC_VER)
# pragma warning(push,1)
+# pragma warning(disable: 4028) /* formal parameter different from decl */
# pragma warning(disable: 4142) /* benign redefinition of type */
# pragma warning(disable: 4761) /* integral size mismatch in argument */
#endif
@@ -124,9 +125,9 @@
// The code currently assumes that size_t is either 32-bit or 64-bit.
#ifndef SIZE_MAX
-# if SIZE_OF_SIZE_T == 4
+# if SIZEOF_SIZE_T == 4
# define SIZE_MAX UINT32_MAX
-# elif SIZE_OF_SIZE_T == 8
+# elif SIZEOF_SIZE_T == 8
# define SIZE_MAX UINT64_MAX
# else
# error size_t is not 32-bit or 64-bit
@@ -175,6 +176,16 @@ typedef unsigned char _Bool;
# include <memory.h>
#endif
+// As of MSVC 2013, inline and restrict are supported with
+// non-standard keywords.
+#if defined(_WIN32) && defined(_MSC_VER)
+# ifndef inline
+# define inline __inline
+# endif
+# ifndef restrict
+# define restrict __restrict
+# endif
+#endif
////////////
// Macros //
diff --git a/Utilities/cmliblzma/common/tuklib_integer.h b/Utilities/cmliblzma/common/tuklib_integer.h
index 5e8262a11..5d8268580 100644
--- a/Utilities/cmliblzma/common/tuklib_integer.h
+++ b/Utilities/cmliblzma/common/tuklib_integer.h
@@ -106,6 +106,17 @@
#endif
+////////////////////////////////
+// Compiler-specific features //
+////////////////////////////////
+
+// Newer Intel C compilers require immintrin.h for _bit_scan_reverse()
+// and such functions.
+#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1500)
+# include <immintrin.h>
+#endif
+
+
///////////////////
// Byte swapping //
///////////////////
@@ -329,8 +340,8 @@ unaligned_read32le(const uint8_t *buf)
static inline void
unaligned_write16be(uint8_t *buf, uint16_t num)
{
- buf[0] = num >> 8;
- buf[1] = num;
+ buf[0] = (uint8_t)(num >> 8);
+ buf[1] = (uint8_t)num;
return;
}
@@ -338,8 +349,8 @@ unaligned_write16be(uint8_t *buf, uint16_t num)
static inline void
unaligned_write16le(uint8_t *buf, uint16_t num)
{
- buf[0] = num;
- buf[1] = num >> 8;
+ buf[0] = (uint8_t)num;
+ buf[1] = (uint8_t)(num >> 8);
return;
}
@@ -347,10 +358,10 @@ unaligned_write16le(uint8_t *buf, uint16_t num)
static inline void
unaligned_write32be(uint8_t *buf, uint32_t num)
{
- buf[0] = num >> 24;
- buf[1] = num >> 16;
- buf[2] = num >> 8;
- buf[3] = num;
+ buf[0] = (uint8_t)(num >> 24);
+ buf[1] = (uint8_t)(num >> 16);
+ buf[2] = (uint8_t)(num >> 8);
+ buf[3] = (uint8_t)num;
return;
}
@@ -358,10 +369,10 @@ unaligned_write32be(uint8_t *buf, uint32_t num)
static inline void
unaligned_write32le(uint8_t *buf, uint32_t num)
{
- buf[0] = num;
- buf[1] = num >> 8;
- buf[2] = num >> 16;
- buf[3] = num >> 24;
+ buf[0] = (uint8_t)num;
+ buf[1] = (uint8_t)(num >> 8);
+ buf[2] = (uint8_t)(num >> 16);
+ buf[3] = (uint8_t)(num >> 24);
return;
}
diff --git a/Utilities/cmliblzma/config.h.in b/Utilities/cmliblzma/config.h.in
index 9c53150bf..06f7fcb37 100644
--- a/Utilities/cmliblzma/config.h.in
+++ b/Utilities/cmliblzma/config.h.in
@@ -29,7 +29,7 @@
@SIZE_OF_UNSIGNED_CODE@
@SIZE_OF_UNSIGNED_LONG_CODE@
@SIZE_OF_UNSIGNED_LONG_LONG_CODE@
-@SIZE_OF_SIZE_T_CODE@
+@SIZEOF_SIZE_T_CODE@
/*
* If we lack int64_t, define it to the first of __int64, int, long, and long long
@@ -180,32 +180,6 @@ typedef uint64_t uintmax_t;
#cmakedefine uintptr_t @uintptr_t@
-
-#cmakedefine HAVE_RESTRICT
-#cmakedefine HAVE___RESTRICT
-
-#cmakedefine HAVE_INLINE
-#cmakedefine HAVE___INLINE
-
-#ifndef HAVE_RESTRICT
-# ifdef HAVE___RESTRICT
-# define LZMA_RESTRICT __restrict
-# else
-# define LZMA_RESTRICT
-# endif
-#else
-# define LZMA_RESTRICT restrict
-#endif /* HAVE_RESTRICT */
-
-#ifndef HAVE_INLINE
-# ifdef HAVE___INLINE
-# define inline __inline
-# else
-# define inline
-# endif
-#endif /* HAVE_INLINE */
-
-
#cmakedefine WORDS_BIGENDIAN 1
#cmakedefine HAVE_BYTESWAP_H 1
diff --git a/Utilities/cmliblzma/liblzma/api/lzma.h b/Utilities/cmliblzma/liblzma/api/lzma.h
index fb874c3e1..aa88e4243 100644
--- a/Utilities/cmliblzma/liblzma/api/lzma.h
+++ b/Utilities/cmliblzma/liblzma/api/lzma.h
@@ -82,12 +82,20 @@
# if !defined(UINT32_C) || !defined(UINT64_C) \
|| !defined(UINT32_MAX) || !defined(UINT64_MAX)
/*
- * MSVC has no C99 support, and thus it cannot be used to
- * compile liblzma. The liblzma API has to still be usable
- * from MSVC, so we need to define the required standard
- * integer types here.
+ * MSVC versions older than 2013 have no C99 support, and
+ * thus they cannot be used to compile liblzma. Using an
+ * existing liblzma.dll with old MSVC can work though(*),
+ * but we need to define the required standard integer
+ * types here in a MSVC-specific way.
+ *
+ * (*) If you do this, the existing liblzma.dll probably uses
+ * a different runtime library than your MSVC-built
+ * application. Mixing runtimes is generally bad, but
+ * in this case it should work as long as you avoid
+ * the few rarely-needed liblzma functions that allocate
+ * memory and expect the caller to free it using free().
*/
-# if defined(_WIN32) && defined(_MSC_VER)
+# if defined(_WIN32) && defined(_MSC_VER) && _MSC_VER < 1800
typedef unsigned __int8 uint8_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
@@ -211,7 +219,11 @@
*/
#ifndef lzma_nothrow
# if defined(__cplusplus)
-# define lzma_nothrow throw()
+# if __cplusplus >= 201103L
+# define lzma_nothrow noexcept
+# else
+# define lzma_nothrow throw()
+# endif
# elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
# define lzma_nothrow __attribute__((__nothrow__))
# else
@@ -286,7 +298,7 @@ extern "C" {
#include "lzma/filter.h"
#include "lzma/bcj.h"
#include "lzma/delta.h"
-#include "lzma/lzma.h"
+#include "lzma/lzma12.h"
/* Container formats */
#include "lzma/container.h"
diff --git a/Utilities/cmliblzma/liblzma/api/lzma/base.h b/Utilities/cmliblzma/liblzma/api/lzma/base.h
index 43dde8d60..a6005accc 100644
--- a/Utilities/cmliblzma/liblzma/api/lzma/base.h
+++ b/Utilities/cmliblzma/liblzma/api/lzma/base.h
@@ -240,12 +240,12 @@ typedef enum {
/**
* \brief The `action' argument for lzma_code()
*
- * After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or LZMA_FINISH,
- * the same `action' must is used until lzma_code() returns LZMA_STREAM_END.
- * Also, the amount of input (that is, strm->avail_in) must not be modified
- * by the application until lzma_code() returns LZMA_STREAM_END. Changing the
- * `action' or modifying the amount of input will make lzma_code() return
- * LZMA_PROG_ERROR.
+ * After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, LZMA_FULL_BARRIER,
+ * or LZMA_FINISH, the same `action' must is used until lzma_code() returns
+ * LZMA_STREAM_END. Also, the amount of input (that is, strm->avail_in) must
+ * not be modified by the application until lzma_code() returns
+ * LZMA_STREAM_END. Changing the `action' or modifying the amount of input
+ * will make lzma_code() return LZMA_PROG_ERROR.
*/
typedef enum {
LZMA_RUN = 0,
@@ -293,7 +293,7 @@ typedef enum {
*
* All the input data going to the current Block must have
* been given to the encoder (the last bytes can still be
- * pending in* next_in). Call lzma_code() with LZMA_FULL_FLUSH
+ * pending in *next_in). Call lzma_code() with LZMA_FULL_FLUSH
* until it returns LZMA_STREAM_END. Then continue normally
* with LZMA_RUN or finish the Stream with LZMA_FINISH.
*
@@ -302,6 +302,29 @@ typedef enum {
* no unfinished Block, no empty Block is created.
*/
+ LZMA_FULL_BARRIER = 4,
+ /**<
+ * \brief Finish encoding of the current Block
+ *
+ * This is like LZMA_FULL_FLUSH except that this doesn't
+ * necessarily wait until all the input has been made
+ * available via the output buffer. That is, lzma_code()
+ * might return LZMA_STREAM_END as soon as all the input
+ * has been consumed (avail_in == 0).
+ *
+ * LZMA_FULL_BARRIER is useful with a threaded encoder if
+ * one wants to split the .xz Stream into Blocks at specific
+ * offsets but doesn't care if the output isn't flushed
+ * immediately. Using LZMA_FULL_BARRIER allows keeping
+ * the threads busy while LZMA_FULL_FLUSH would make
+ * lzma_code() wait until all the threads have finished
+ * until more data could be passed to the encoder.
+ *
+ * With a lzma_stream initialized with the single-threaded
+ * lzma_stream_encoder() or lzma_easy_encoder(),
+ * LZMA_FULL_BARRIER is an alias for LZMA_FULL_FLUSH.
+ */
+
LZMA_FINISH = 3
/**<
* \brief Finish the coding operation
@@ -332,11 +355,19 @@ typedef enum {
* malloc() and free(). C++ users should note that the custom memory
* handling functions must not throw exceptions.
*
- * liblzma doesn't make an internal copy of lzma_allocator. Thus, it is
- * OK to change these function pointers in the middle of the coding
- * process, but obviously it must be done carefully to make sure that the
- * replacement `free' can deallocate memory allocated by the earlier
- * `alloc' function(s).
+ * Single-threaded mode only: liblzma doesn't make an internal copy of
+ * lzma_allocator. Thus, it is OK to change these function pointers in
+ * the middle of the coding process, but obviously it must be done
+ * carefully to make sure that the replacement `free' can deallocate
+ * memory allocated by the earlier `alloc' function(s).
+ *
+ * Multithreaded mode: liblzma might internally store pointers to the
+ * lzma_allocator given via the lzma_stream structure. The application
+ * must not change the allocator pointer in lzma_stream or the contents
+ * of the pointed lzma_allocator structure until lzma_end() has been used
+ * to free the memory associated with that lzma_stream. The allocation
+ * functions might be called simultaneously from multiple threads, and
+ * thus they must be thread safe.
*/
typedef struct {
/**
@@ -448,7 +479,8 @@ typedef struct lzma_internal_s lzma_internal;
*
* Application may modify the values of total_in and total_out as it wants.
* They are updated by liblzma to match the amount of data read and
- * written, but aren't used for anything else.
+ * written but aren't used for anything else except as a possible return
+ * values from lzma_get_progress().
*/
typedef struct {
const uint8_t *next_in; /**< Pointer to the next input byte. */
@@ -464,8 +496,10 @@ typedef struct {
*
* In most cases this is NULL which makes liblzma use
* the standard malloc() and free().
+ *
+ * \note In 5.0.x this is not a const pointer.
*/
- lzma_allocator *allocator;
+ const lzma_allocator *allocator;
/** Internal state is not visible to applications. */
lzma_internal *internal;
@@ -547,6 +581,25 @@ extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow;
/**
+ * \brief Get progress information
+ *
+ * In single-threaded mode, applications can get progress information from
+ * strm->total_in and strm->total_out. In multi-threaded mode this is less
+ * useful because a significant amount of both input and output data gets
+ * buffered internally by liblzma. This makes total_in and total_out give
+ * misleading information and also makes the progress indicator updates
+ * non-smooth.
+ *
+ * This function gives realistic progress information also in multi-threaded
+ * mode by taking into account the progress made by each thread. In
+ * single-threaded mode *progress_in and *progress_out are set to
+ * strm->total_in and strm->total_out, respectively.
+ */
+extern LZMA_API(void) lzma_get_progress(lzma_stream *strm,
+ uint64_t *progress_in, uint64_t *progress_out) lzma_nothrow;
+
+
+/**
* \brief Get the memory usage of decoder filter chain
*
* This function is currently supported only when *strm has been initialized
@@ -591,11 +644,16 @@ extern LZMA_API(uint64_t) lzma_memlimit_get(const lzma_stream *strm)
* This function is supported only when *strm has been initialized with
* a function that takes a memlimit argument.
*
+ * liblzma 5.2.3 and earlier has a bug where memlimit value of 0 causes
+ * this function to do nothing (leaving the limit unchanged) and still
+ * return LZMA_OK. Later versions treat 0 as if 1 had been specified (so
+ * lzma_memlimit_get() will return 1 even if you specify 0 here).
+ *
* \return - LZMA_OK: New memory usage limit successfully set.
* - LZMA_MEMLIMIT_ERROR: The new limit is too small.
* The limit was not changed.
* - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't
- * support memory usage limit or memlimit was zero.
+ * support memory usage limit.
*/
extern LZMA_API(lzma_ret) lzma_memlimit_set(
lzma_stream *strm, uint64_t memlimit) lzma_nothrow;
diff --git a/Utilities/cmliblzma/liblzma/api/lzma/block.h b/Utilities/cmliblzma/liblzma/api/lzma/block.h
index e6710a7bc..7bdcfd7cb 100644
--- a/Utilities/cmliblzma/liblzma/api/lzma/block.h
+++ b/Utilities/cmliblzma/liblzma/api/lzma/block.h
@@ -31,11 +31,16 @@ typedef struct {
/**
* \brief Block format version
*
- * To prevent API and ABI breakages if new features are needed in
- * the Block field, a version number is used to indicate which
- * fields in this structure are in use. For now, version must always
- * be zero. With non-zero version, most Block related functions will
- * return LZMA_OPTIONS_ERROR.
+ * To prevent API and ABI breakages when new features are needed,
+ * a version number is used to indicate which fields in this
+ * structure are in use:
+ * - liblzma >= 5.0.0: version = 0 is supported.
+ * - liblzma >= 5.1.4beta: Support for version = 1 was added,
+ * which adds the ignore_check field.
+ *
+ * If version is greater than one, most Block related functions
+ * will return LZMA_OPTIONS_ERROR (lzma_block_header_decode() works
+ * with any version value).
*
* Read by:
* - All functions that take pointer to lzma_block as argument,
@@ -233,7 +238,28 @@ typedef struct {
lzma_reserved_enum reserved_enum2;
lzma_reserved_enum reserved_enum3;
lzma_reserved_enum reserved_enum4;
- lzma_bool reserved_bool1;
+
+ /**
+ * \brief A flag to Block decoder to not verify the Check field
+ *
+ * This field is supported by liblzma >= 5.1.4beta if .version >= 1.
+ *
+ * If this is set to true, the integrity check won't be calculated
+ * and verified. Unless you know what you are doing, you should
+ * leave this to false. (A reason to set this to true is when the
+ * file integrity is verified externally anyway and you want to
+ * speed up the decompression, which matters mostly when using
+ * SHA-256 as the integrity check.)
+ *
+ * If .version >= 1, read by:
+ * - lzma_block_decoder()
+ * - lzma_block_buffer_decode()
+ *
+ * Written by (.version is ignored):
+ * - lzma_block_header_decode() always sets this to false
+ */
+ lzma_bool ignore_check;
+
lzma_bool reserved_bool2;
lzma_bool reserved_bool3;
lzma_bool reserved_bool4;
@@ -310,10 +336,14 @@ extern LZMA_API(lzma_ret) lzma_block_header_encode(
/**
* \brief Decode Block Header
*
- * block->version should be set to the highest value supported by the
- * application; currently the only possible version is zero. This function
- * will set version to the lowest value that still supports all the features
- * required by the Block Header.
+ * block->version should (usually) be set to the highest value supported
+ * by the application. If the application sets block->version to a value
+ * higher than supported by the current liblzma version, this function will
+ * downgrade block->version to the highest value supported by it. Thus one
+ * should check the value of block->version after calling this function if
+ * block->version was set to a non-zero value and the application doesn't
+ * otherwise know that the liblzma version being used is new enough to
+ * support the specified block->version.
*
* The size of the Block Header must have already been decoded with
* lzma_block_header_size_decode() macro and stored to block->header_size.
@@ -344,7 +374,7 @@ extern LZMA_API(lzma_ret) lzma_block_header_encode(
* block->header_size is invalid or block->filters is NULL.
*/
extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block,
- lzma_allocator *allocator, const uint8_t *in)
+ const lzma_allocator *allocator, const uint8_t *in)
lzma_nothrow lzma_attr_warn_unused_result;
@@ -493,7 +523,25 @@ extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size)
* - LZMA_PROG_ERROR
*/
extern LZMA_API(lzma_ret) lzma_block_buffer_encode(
- lzma_block *block, lzma_allocator *allocator,
+ lzma_block *block, const lzma_allocator *allocator,
+ const uint8_t *in, size_t in_size,
+ uint8_t *out, size_t *out_pos, size_t out_size)
+ lzma_nothrow lzma_attr_warn_unused_result;
+
+
+/**
+ * \brief Single-call uncompressed .xz Block encoder
+ *
+ * This is like lzma_block_buffer_encode() except this doesn't try to
+ * compress the data and instead encodes the data using LZMA2 uncompressed
+ * chunks. The required output buffer size can be determined with
+ * lzma_block_buffer_bound().
+ *
+ * Since the data won't be compressed, this function ignores block->filters.
+ * This function doesn't take lzma_allocator because this function doesn't
+ * allocate any memory from the heap.
+ */
+extern LZMA_API(lzma_ret) lzma_block_uncomp_encode(lzma_block *block,
const uint8_t *in, size_t in_size,
uint8_t *out, size_t *out_pos, size_t out_size)
lzma_nothrow lzma_attr_warn_unused_result;
@@ -527,7 +575,7 @@ extern LZMA_API(lzma_ret) lzma_block_buffer_encode(
* - LZMA_PROG_ERROR
*/
extern LZMA_API(lzma_ret) lzma_block_buffer_decode(
- lzma_block *block, lzma_allocator *allocator,
+ lzma_block *block, const lzma_allocator *allocator,
const uint8_t *in, size_t *in_pos, size_t in_size,
uint8_t *out, size_t *out_pos, size_t out_size)
lzma_nothrow;
diff --git a/Utilities/cmliblzma/liblzma/api/lzma/container.h b/Utilities/cmliblzma/liblzma/api/lzma/container.h
index 7a9ffc645..9fbf4df06 100644
--- a/Utilities/cmliblzma/liblzma/api/lzma/container.h
+++ b/Utilities/cmliblzma/liblzma/api/lzma/container.h
@@ -61,6 +61,131 @@
/**
+ * \brief Multithreading options
+ */
+typedef struct {
+ /**
+ * \brief Flags
+ *
+ * Set this to zero if no flags are wanted.
+ *
+ * No flags are currently supported.
+ */
+ uint32_t flags;
+
+ /**
+ * \brief Number of worker threads to use
+ */
+ uint32_t threads;
+
+ /**
+ * \brief Maximum uncompressed size of a Block
+ *
+ * The encoder will start a new .xz Block every block_size bytes.
+ * Using LZMA_FULL_FLUSH or LZMA_FULL_BARRIER with lzma_code()
+ * the caller may tell liblzma to start a new Block earlier.
+ *
+ * With LZMA2, a recommended block size is 2-4 times the LZMA2
+ * dictionary size. With very small dictionaries, it is recommended
+ * to use at least 1 MiB block size for good compression ratio, even
+ * if this is more than four times the dictionary size. Note that
+ * these are only recommendations for typical use cases; feel free
+ * to use other values. Just keep in mind that using a block size
+ * less than the LZMA2 dictionary size is waste of RAM.
+ *
+ * Set this to 0 to let liblzma choose the block size depending
+ * on the compression options. For LZMA2 it will be 3*dict_size
+ * or 1 MiB, whichever is more.
+ *
+ * For each thread, about 3 * block_size bytes of memory will be
+ * allocated. This may change in later liblzma versions. If so,
+ * the memory usage will probably be reduced, not increased.
+ */
+ uint64_t block_size;
+
+ /**
+ * \brief Timeout to allow lzma_code() to return early
+ *
+ * Multithreading can make liblzma to consume input and produce
+ * output in a very bursty way: it may first read a lot of input
+ * to fill internal buffers, then no input or output occurs for
+ * a while.
+ *
+ * In single-threaded mode, lzma_code() won't return until it has
+ * either consumed all the input or filled the output buffer. If
+ * this is done in multithreaded mode, it may cause a call
+ * lzma_code() to take even tens of seconds, which isn't acceptable
+ * in all applications.
+ *
+ * To avoid very long blocking times in lzma_code(), a timeout
+ * (in milliseconds) may be set here. If lzma_code() would block
+ * longer than this number of milliseconds, it will return with
+ * LZMA_OK. Reasonable values are 100 ms or more. The xz command
+ * line tool uses 300 ms.
+ *
+ * If long blocking times are fine for you, set timeout to a special
+ * value of 0, which will disable the timeout mechanism and will make
+ * lzma_code() block until all the input is consumed or the output
+ * buffer has been filled.
+ *
+ * \note Even with a timeout, lzma_code() might sometimes take
+ * somewhat long time to return. No timing guarantees
+ * are made.
+ */
+ uint32_t timeout;
+
+ /**
+ * \brief Compression preset (level and possible flags)
+ *
+ * The preset is set just like with lzma_easy_encoder().
+ * The preset is ignored if filters below is non-NULL.
+ */
+ uint32_t preset;
+
+ /**
+ * \brief Filter chain (alternative to a preset)
+ *
+ * If this is NULL, the preset above is used. Otherwise the preset
+ * is ignored and the filter chain specified here is used.
+ */
+ const lzma_filter *filters;
+
+ /**
+ * \brief Integrity check type
+ *
+ * See check.h for available checks. The xz command line tool
+ * defaults to LZMA_CHECK_CRC64, which is a good choice if you
+ * are unsure.
+ */
+ lzma_check check;
+
+ /*
+ * Reserved space to allow possible future extensions without
+ * breaking the ABI. You should not touch these, because the names
+ * of these variables may change. These are and will never be used
+ * with the currently supported options, so it is safe to leave these
+ * uninitialized.
+ */
+ lzma_reserved_enum reserved_enum1;
+ lzma_reserved_enum reserved_enum2;
+ lzma_reserved_enum reserved_enum3;
+ uint32_t reserved_int1;
+ uint32_t reserved_int2;
+ uint32_t reserved_int3;
+ uint32_t reserved_int4;
+ uint64_t reserved_int5;
+ uint64_t reserved_int6;
+ uint64_t reserved_int7;
+ uint64_t reserved_int8;
+ void *reserved_ptr1;
+ void *reserved_ptr2;
+ void *reserved_ptr3;
+ void *reserved_ptr4;
+
+} lzma_mt;
+
+
+/**
* \brief Calculate approximate memory usage of easy encoder
*
* This function is a wrapper for lzma_raw_encoder_memusage().
@@ -165,7 +290,8 @@ extern LZMA_API(lzma_ret) lzma_easy_encoder(
*/
extern LZMA_API(lzma_ret) lzma_easy_buffer_encode(
uint32_t preset, lzma_check check,
- lzma_allocator *allocator, const uint8_t *in, size_t in_size,
+ const lzma_allocator *allocator,
+ const uint8_t *in, size_t in_size,
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
@@ -191,6 +317,49 @@ extern LZMA_API(lzma_ret) lzma_stream_encoder(lzma_stream *strm,
/**
+ * \brief Calculate approximate memory usage of multithreaded .xz encoder
+ *
+ * Since doing the encoding in threaded mode doesn't affect the memory
+ * requirements of single-threaded decompressor, you can use
+ * lzma_easy_decoder_memusage(options->preset) or
+ * lzma_raw_decoder_memusage(options->filters) to calculate
+ * the decompressor memory requirements.
+ *
+ * \param options Compression options
+ *
+ * \return Number of bytes of memory required for encoding with the
+ * given options. If an error occurs, for example due to
+ * unsupported preset or filter chain, UINT64_MAX is returned.
+ */
+extern LZMA_API(uint64_t) lzma_stream_encoder_mt_memusage(
+ const lzma_mt *options) lzma_nothrow lzma_attr_pure;
+
+
+/**
+ * \brief Initialize multithreaded .xz Stream encoder
+ *
+ * This provides the functionality of lzma_easy_encoder() and
+ * lzma_stream_encoder() as a single function for multithreaded use.
+ *
+ * The supported actions for lzma_code() are LZMA_RUN, LZMA_FULL_FLUSH,
+ * LZMA_FULL_BARRIER, and LZMA_FINISH. Support for LZMA_SYNC_FLUSH might be
+ * added in the future.
+ *
+ * \param strm Pointer to properly prepared lzma_stream
+ * \param options Pointer to multithreaded compression options
+ *
+ * \return - LZMA_OK
+ * - LZMA_MEM_ERROR
+ * - LZMA_UNSUPPORTED_CHECK
+ * - LZMA_OPTIONS_ERROR
+ * - LZMA_PROG_ERROR
+ */
+extern LZMA_API(lzma_ret) lzma_stream_encoder_mt(
+ lzma_stream *strm, const lzma_mt *options)
+ lzma_nothrow lzma_attr_warn_unused_result;
+
+
+/**
* \brief Initialize .lzma encoder (legacy file format)
*
* The .lzma format is sometimes called the LZMA_Alone format, which is the
@@ -269,7 +438,8 @@ extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size)
*/
extern LZMA_API(lzma_ret) lzma_stream_buffer_encode(
lzma_filter *filters, lzma_check check,
- lzma_allocator *allocator, const uint8_t *in, size_t in_size,
+ const lzma_allocator *allocator,
+ const uint8_t *in, size_t in_size,
uint8_t *out, size_t *out_pos, size_t out_size)
lzma_nothrow lzma_attr_warn_unused_result;
@@ -305,6 +475,30 @@ extern LZMA_API(lzma_ret) lzma_stream_buffer_encode(
/**
+ * This flag makes lzma_code() not calculate and verify the integrity check
+ * of the compressed data in .xz files. This means that invalid integrity
+ * check values won't be detected and LZMA_DATA_ERROR won't be returned in
+ * such cases.
+ *
+ * This flag only affects the checks of the compressed data itself; the CRC32
+ * values in the .xz headers will still be verified normally.
+ *
+ * Don't use this flag unless you know what you are doing. Possible reasons
+ * to use this flag:
+ *
+ * - Trying to recover data from a corrupt .xz file.
+ *
+ * - Speeding up decompression, which matters mostly with SHA-256
+ * or with files that have compressed extremely well. It's recommended
+ * to not use this flag for this purpose unless the file integrity is
+ * verified externally in some other way.
+ *
+ * Support for this flag was added in liblzma 5.1.4beta.
+ */
+#define LZMA_IGNORE_CHECK UINT32_C(0x10)
+
+
+/**
* This flag enables decoding of concatenated files with file formats that
* allow concatenating compressed files as is. From the formats currently
* supported by liblzma, only the .xz format allows concatenated files.
@@ -326,7 +520,10 @@ extern LZMA_API(lzma_ret) lzma_stream_buffer_encode(
*
* \param strm Pointer to properly prepared lzma_stream
* \param memlimit Memory usage limit as bytes. Use UINT64_MAX
- * to effectively disable the limiter.
+ * to effectively disable the limiter. liblzma
+ * 5.2.3 and earlier don't allow 0 here and return
+ * LZMA_PROG_ERROR; later versions treat 0 as if 1
+ * had been specified.
* \param flags Bitwise-or of zero or more of the decoder flags:
* LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
* LZMA_TELL_ANY_CHECK, LZMA_CONCATENATED
@@ -350,7 +547,10 @@ extern LZMA_API(lzma_ret) lzma_stream_decoder(
*
* \param strm Pointer to properly prepared lzma_stream
* \param memlimit Memory usage limit as bytes. Use UINT64_MAX
- * to effectively disable the limiter.
+ * to effectively disable the limiter. liblzma
+ * 5.2.3 and earlier don't allow 0 here and return
+ * LZMA_PROG_ERROR; later versions treat 0 as if 1
+ * had been specified.
* \param flags Bitwise-or of flags, or zero for no flags.
*
* \return - LZMA_OK: Initialization was successful.
@@ -366,9 +566,16 @@ extern LZMA_API(lzma_ret) lzma_auto_decoder(
/**
* \brief Initialize .lzma decoder (legacy file format)
*
+ * \param strm Pointer to properly prepared lzma_stream
+ * \param memlimit Memory usage limit as bytes. Use UINT64_MAX
+ * to effectively disable the limiter. liblzma
+ * 5.2.3 and earlier don't allow 0 here and return
+ * LZMA_PROG_ERROR; later versions treat 0 as if 1
+ * had been specified.
+ *
* Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.
- * There is no need to use LZMA_FINISH, but allowing it may simplify
- * certain types of applications.
+ * There is no need to use LZMA_FINISH, but it's allowed because it may
+ * simplify certain types of applications.
*
* \return - LZMA_OK
* - LZMA_MEM_ERROR
@@ -418,7 +625,8 @@ extern LZMA_API(lzma_ret) lzma_alone_decoder(
* - LZMA_PROG_ERROR
*/
extern LZMA_API(lzma_ret) lzma_stream_buffer_decode(
- uint64_t *memlimit, uint32_t flags, lzma_allocator *allocator,
+ uint64_t *memlimit, uint32_t flags,
+ const lzma_allocator *allocator,
const uint8_t *in, size_t *in_pos, size_t in_size,
uint8_t *out, size_t *out_pos, size_t out_size)
lzma_nothrow lzma_attr_warn_unused_result;
diff --git a/Utilities/cmliblzma/liblzma/api/lzma/filter.h b/Utilities/cmliblzma/liblzma/api/lzma/filter.h
index e0bc163ad..4e78752b8 100644
--- a/Utilities/cmliblzma/liblzma/api/lzma/filter.h
+++ b/Utilities/cmliblzma/liblzma/api/lzma/filter.h
@@ -116,8 +116,9 @@ extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id)
* is not NULL.
* - LZMA_PROG_ERROR: src or dest is NULL.
*/
-extern LZMA_API(lzma_ret) lzma_filters_copy(const lzma_filter *src,
- lzma_filter *dest, lzma_allocator *allocator) lzma_nothrow;
+extern LZMA_API(lzma_ret) lzma_filters_copy(
+ const lzma_filter *src, lzma_filter *dest,
+ const lzma_allocator *allocator) lzma_nothrow;
/**
@@ -256,7 +257,7 @@ extern LZMA_API(lzma_ret) lzma_filters_update(
* won't necessarily meet that bound.)
*/
extern LZMA_API(lzma_ret) lzma_raw_buffer_encode(
- const lzma_filter *filters, lzma_allocator *allocator,
+ const lzma_filter *filters, const lzma_allocator *allocator,
const uint8_t *in, size_t in_size, uint8_t *out,
size_t *out_pos, size_t out_size) lzma_nothrow;
@@ -280,7 +281,7 @@ extern LZMA_API(lzma_ret) lzma_raw_buffer_encode(
* which no data is written to is out[out_size].
*/
extern LZMA_API(lzma_ret) lzma_raw_buffer_decode(
- const lzma_filter *filters, lzma_allocator *allocator,
+ const lzma_filter *filters, const lzma_allocator *allocator,
const uint8_t *in, size_t *in_pos, size_t in_size,
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
@@ -356,7 +357,7 @@ extern LZMA_API(lzma_ret) lzma_properties_encode(
* - LZMA_MEM_ERROR
*/
extern LZMA_API(lzma_ret) lzma_properties_decode(
- lzma_filter *filter, lzma_allocator *allocator,
+ lzma_filter *filter, const lzma_allocator *allocator,
const uint8_t *props, size_t props_size) lzma_nothrow;
@@ -419,6 +420,6 @@ extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filter,
* - LZMA_PROG_ERROR
*/
extern LZMA_API(lzma_ret) lzma_filter_flags_decode(
- lzma_filter *filter, lzma_allocator *allocator,
+ lzma_filter *filter, const lzma_allocator *allocator,
const uint8_t *in, size_t *in_pos, size_t in_size)
lzma_nothrow lzma_attr_warn_unused_result;
diff --git a/Utilities/cmliblzma/liblzma/api/lzma/hardware.h b/Utilities/cmliblzma/liblzma/api/lzma/hardware.h
index e7dd03c3e..5321d9af8 100644
--- a/Utilities/cmliblzma/liblzma/api/lzma/hardware.h
+++ b/Utilities/cmliblzma/liblzma/api/lzma/hardware.h
@@ -48,3 +48,17 @@
* of RAM on the specific operating system.
*/
extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow;
+
+
+/**
+ * \brief Get the number of processor cores or threads
+ *
+ * This function may be useful when determining how many threads to use.
+ * If the hardware supports more than one thread per CPU core, the number
+ * of hardware threads is returned if that information is available.
+ *
+ * \brief On success, the number of available CPU threads or cores is
+ * returned. If this information isn't available or an error
+ * occurs, zero is returned.
+ */
+extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow;
diff --git a/Utilities/cmliblzma/liblzma/api/lzma/index.h b/Utilities/cmliblzma/liblzma/api/lzma/index.h
index 16bacc287..3dac6fb85 100644
--- a/Utilities/cmliblzma/liblzma/api/lzma/index.h
+++ b/Utilities/cmliblzma/liblzma/api/lzma/index.h
@@ -303,7 +303,7 @@ extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i)
* \return On success, a pointer to an empty initialized lzma_index is
* returned. If allocation fails, NULL is returned.
*/
-extern LZMA_API(lzma_index *) lzma_index_init(lzma_allocator *allocator)
+extern LZMA_API(lzma_index *) lzma_index_init(const lzma_allocator *allocator)
lzma_nothrow;
@@ -312,8 +312,8 @@ extern LZMA_API(lzma_index *) lzma_index_init(lzma_allocator *allocator)
*
* If i is NULL, this does nothing.
*/
-extern LZMA_API(void) lzma_index_end(lzma_index *i, lzma_allocator *allocator)
- lzma_nothrow;
+extern LZMA_API(void) lzma_index_end(
+ lzma_index *i, const lzma_allocator *allocator) lzma_nothrow;
/**
@@ -341,7 +341,7 @@ extern LZMA_API(void) lzma_index_end(lzma_index *i, lzma_allocator *allocator)
* - LZMA_PROG_ERROR
*/
extern LZMA_API(lzma_ret) lzma_index_append(
- lzma_index *i, lzma_allocator *allocator,
+ lzma_index *i, const lzma_allocator *allocator,
lzma_vli unpadded_size, lzma_vli uncompressed_size)
lzma_nothrow lzma_attr_warn_unused_result;
@@ -564,8 +564,8 @@ extern LZMA_API(lzma_bool) lzma_index_iter_locate(
* - LZMA_MEM_ERROR
* - LZMA_PROG_ERROR
*/
-extern LZMA_API(lzma_ret) lzma_index_cat(
- lzma_index *dest, lzma_index *src, lzma_allocator *allocator)
+extern LZMA_API(lzma_ret) lzma_index_cat(lzma_index *dest, lzma_index *src,
+ const lzma_allocator *allocator)
lzma_nothrow lzma_attr_warn_unused_result;
@@ -575,7 +575,7 @@ extern LZMA_API(lzma_ret) lzma_index_cat(
* \return A copy of the lzma_index, or NULL if memory allocation failed.
*/
extern LZMA_API(lzma_index *) lzma_index_dup(
- const lzma_index *i, lzma_allocator *allocator)
+ const lzma_index *i, const lzma_allocator *allocator)
lzma_nothrow lzma_attr_warn_unused_result;
@@ -586,8 +586,7 @@ extern LZMA_API(lzma_index *) lzma_index_dup(
* \param i Pointer to lzma_index which should be encoded.
*
* The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.
- * It is enough to use only one of them (you can choose freely; use LZMA_RUN
- * to support liblzma versions older than 5.0.0).
+ * It is enough to use only one of them (you can choose freely).
*
* \return - LZMA_OK: Initialization succeeded, continue with lzma_code().
* - LZMA_MEM_ERROR
@@ -610,16 +609,21 @@ extern LZMA_API(lzma_ret) lzma_index_encoder(
* to a new lzma_index, which the application
* has to later free with lzma_index_end().
* \param memlimit How much memory the resulting lzma_index is
- * allowed to require.
+ * allowed to require. liblzma 5.2.3 and earlier
+ * don't allow 0 here and return LZMA_PROG_ERROR;
+ * later versions treat 0 as if 1 had been specified.
*
- * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.
- * It is enough to use only one of them (you can choose freely; use LZMA_RUN
- * to support liblzma versions older than 5.0.0).
+ * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.
+ * There is no need to use LZMA_FINISH, but it's allowed because it may
+ * simplify certain types of applications.
*
* \return - LZMA_OK: Initialization succeeded, continue with lzma_code().
* - LZMA_MEM_ERROR
- * - LZMA_MEMLIMIT_ERROR
* - LZMA_PROG_ERROR
+ *
+ * liblzma 5.2.3 and older list also LZMA_MEMLIMIT_ERROR here
+ * but that error code has never been possible from this
+ * initialization function.
*/
extern LZMA_API(lzma_ret) lzma_index_decoder(
lzma_stream *strm, lzma_index **i, uint64_t memlimit)
@@ -677,6 +681,6 @@ extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i,
* - LZMA_PROG_ERROR
*/
extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i,
- uint64_t *memlimit, lzma_allocator *allocator,
+ uint64_t *memlimit, const lzma_allocator *allocator,
const uint8_t *in, size_t *in_pos, size_t in_size)
lzma_nothrow;
diff --git a/Utilities/cmliblzma/liblzma/api/lzma/index_hash.h b/Utilities/cmliblzma/liblzma/api/lzma/index_hash.h
index fa2e048d5..9287f1dfd 100644
--- a/Utilities/cmliblzma/liblzma/api/lzma/index_hash.h
+++ b/Utilities/cmliblzma/liblzma/api/lzma/index_hash.h
@@ -37,7 +37,7 @@ typedef struct lzma_index_hash_s lzma_index_hash;
* pointer than the index_hash that was given as an argument.
*/
extern LZMA_API(lzma_index_hash *) lzma_index_hash_init(
- lzma_index_hash *index_hash, lzma_allocator *allocator)
+ lzma_index_hash *index_hash, const lzma_allocator *allocator)
lzma_nothrow lzma_attr_warn_unused_result;
@@ -45,7 +45,7 @@ extern LZMA_API(lzma_index_hash *) lzma_index_hash_init(
* \brief Deallocate lzma_index_hash structure
*/
extern LZMA_API(void) lzma_index_hash_end(
- lzma_index_hash *index_hash, lzma_allocator *allocator)
+ lzma_index_hash *index_hash, const lzma_allocator *allocator)
lzma_nothrow;
diff --git a/Utilities/cmliblzma/liblzma/api/lzma/lzma.h b/Utilities/cmliblzma/liblzma/api/lzma/lzma.h
deleted file mode 100644
index 3f8e095f7..000000000
--- a/Utilities/cmliblzma/liblzma/api/lzma/lzma.h
+++ /dev/null
@@ -1,420 +0,0 @@
-/**
- * \file lzma/lzma.h
- * \brief LZMA1 and LZMA2 filters
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use <lzma.h> instead.
-#endif
-
-
-/**
- * \brief LZMA1 Filter ID
- *
- * LZMA1 is the very same thing as what was called just LZMA in LZMA Utils,
- * 7-Zip, and LZMA SDK. It's called LZMA1 here to prevent developers from
- * accidentally using LZMA when they actually want LZMA2.
- *
- * LZMA1 shouldn't be used for new applications unless you _really_ know
- * what you are doing. LZMA2 is almost always a better choice.
- */
-#define LZMA_FILTER_LZMA1 LZMA_VLI_C(0x4000000000000001)
-
-/**
- * \brief LZMA2 Filter ID
- *
- * Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds
- * support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion
- * when trying to compress uncompressible data), possibility to change
- * lc/lp/pb in the middle of encoding, and some other internal improvements.
- */
-#define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21)
-
-
-/**
- * \brief Match finders
- *
- * Match finder has major effect on both speed and compression ratio.
- * Usually hash chains are faster than binary trees.
- *
- * If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better
- * choice, because binary trees get much higher compression ratio penalty
- * with LZMA_SYNC_FLUSH.
- *
- * The memory usage formulas are only rough estimates, which are closest to
- * reality when dict_size is a power of two. The formulas are more complex
- * in reality, and can also change a little between liblzma versions. Use
- * lzma_raw_encoder_memusage() to get more accurate estimate of memory usage.
- */
-typedef enum {
- LZMA_MF_HC3 = 0x03,
- /**<
- * \brief Hash Chain with 2- and 3-byte hashing
- *
- * Minimum nice_len: 3
- *
- * Memory usage:
- * - dict_size <= 16 MiB: dict_size * 7.5
- * - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB
- */
-
- LZMA_MF_HC4 = 0x04,
- /**<
- * \brief Hash Chain with 2-, 3-, and 4-byte hashing
- *
- * Minimum nice_len: 4
- *
- * Memory usage:
- * - dict_size <= 32 MiB: dict_size * 7.5
- * - dict_size > 32 MiB: dict_size * 6.5
- */
-
- LZMA_MF_BT2 = 0x12,
- /**<
- * \brief Binary Tree with 2-byte hashing
- *
- * Minimum nice_len: 2
- *
- * Memory usage: dict_size * 9.5
- */
-
- LZMA_MF_BT3 = 0x13,
- /**<
- * \brief Binary Tree with 2- and 3-byte hashing
- *
- * Minimum nice_len: 3
- *
- * Memory usage:
- * - dict_size <= 16 MiB: dict_size * 11.5
- * - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB
- */
-
- LZMA_MF_BT4 = 0x14
- /**<
- * \brief Binary Tree with 2-, 3-, and 4-byte hashing
- *
- * Minimum nice_len: 4
- *
- * Memory usage:
- * - dict_size <= 32 MiB: dict_size * 11.5
- * - dict_size > 32 MiB: dict_size * 10.5
- */
-} lzma_match_finder;
-
-
-/**
- * \brief Test if given match finder is supported
- *
- * Return true if the given match finder is supported by this liblzma build.
- * Otherwise false is returned. It is safe to call this with a value that
- * isn't listed in lzma_match_finder enumeration; the return value will be
- * false.
- *
- * There is no way to list which match finders are available in this
- * particular liblzma version and build. It would be useless, because
- * a new match finder, which the application developer wasn't aware,
- * could require giving additional options to the encoder that the older
- * match finders don't need.
- */
-extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder)
- lzma_nothrow lzma_attr_const;
-
-
-/**
- * \brief Compression modes
- *
- * This selects the function used to analyze the data produced by the match
- * finder.
- */
-typedef enum {
- LZMA_MODE_FAST = 1,
- /**<
- * \brief Fast compression
- *
- * Fast mode is usually at its best when combined with
- * a hash chain match finder.
- */
-
- LZMA_MODE_NORMAL = 2
- /**<
- * \brief Normal compression
- *
- * This is usually notably slower than fast mode. Use this
- * together with binary tree match finders to expose the
- * full potential of the LZMA1 or LZMA2 encoder.
- */
-} lzma_mode;
-
-
-/**
- * \brief Test if given compression mode is supported
- *
- * Return true if the given compression mode is supported by this liblzma
- * build. Otherwise false is returned. It is safe to call this with a value
- * that isn't listed in lzma_mode enumeration; the return value will be false.
- *
- * There is no way to list which modes are available in this particular
- * liblzma version and build. It would be useless, because a new compression
- * mode, which the application developer wasn't aware, could require giving
- * additional options to the encoder that the older modes don't need.
- */
-extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode)
- lzma_nothrow lzma_attr_const;
-
-
-/**
- * \brief Options specific to the LZMA1 and LZMA2 filters
- *
- * Since LZMA1 and LZMA2 share most of the code, it's simplest to share
- * the options structure too. For encoding, all but the reserved variables
- * need to be initialized unless specifically mentioned otherwise.
- * lzma_lzma_preset() can be used to get a good starting point.
- *
- * For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and
- * preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb.
- */
-typedef struct {
- /**
- * \brief Dictionary size in bytes
- *
- * Dictionary size indicates how many bytes of the recently processed
- * uncompressed data is kept in memory. One method to reduce size of
- * the uncompressed data is to store distance-length pairs, which
- * indicate what data to repeat from the dictionary buffer. Thus,
- * the bigger the dictionary, the better the compression ratio
- * usually is.
- *
- * Maximum size of the dictionary depends on multiple things:
- * - Memory usage limit
- * - Available address space (not a problem on 64-bit systems)
- * - Selected match finder (encoder only)
- *
- * Currently the maximum dictionary size for encoding is 1.5 GiB
- * (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit
- * systems for certain match finder implementation reasons. In the
- * future, there may be match finders that support bigger
- * dictionaries.
- *
- * Decoder already supports dictionaries up to 4 GiB - 1 B (i.e.
- * UINT32_MAX), so increasing the maximum dictionary size of the
- * encoder won't cause problems for old decoders.
- *
- * Because extremely small dictionaries sizes would have unneeded
- * overhead in the decoder, the minimum dictionary size is 4096 bytes.
- *
- * \note When decoding, too big dictionary does no other harm
- * than wasting memory.
- */
- uint32_t dict_size;
-# define LZMA_DICT_SIZE_MIN UINT32_C(4096)
-# define LZMA_DICT_SIZE_DEFAULT (UINT32_C(1) << 23)
-
- /**
- * \brief Pointer to an initial dictionary
- *
- * It is possible to initialize the LZ77 history window using
- * a preset dictionary. It is useful when compressing many
- * similar, relatively small chunks of data independently from
- * each other. The preset dictionary should contain typical
- * strings that occur in the files being compressed. The most
- * probable strings should be near the end of the preset dictionary.
- *
- * This feature should be used only in special situations. For
- * now, it works correctly only with raw encoding and decoding.
- * Currently none of the container formats supported by
- * liblzma allow preset dictionary when decoding, thus if
- * you create a .xz or .lzma file with preset dictionary, it
- * cannot be decoded with the regular decoder functions. In the
- * future, the .xz format will likely get support for preset
- * dictionary though.
- */
- const uint8_t *preset_dict;
-
- /**
- * \brief Size of the preset dictionary
- *
- * Specifies the size of the preset dictionary. If the size is
- * bigger than dict_size, only the last dict_size bytes are
- * processed.
- *
- * This variable is read only when preset_dict is not NULL.
- * If preset_dict is not NULL but preset_dict_size is zero,
- * no preset dictionary is used (identical to only setting
- * preset_dict to NULL).
- */
- uint32_t preset_dict_size;
-
- /**
- * \brief Number of literal context bits
- *
- * How many of the highest bits of the previous uncompressed
- * eight-bit byte (also known as `literal') are taken into
- * account when predicting the bits of the next literal.
- *
- * E.g. in typical English text, an upper-case letter is
- * often followed by a lower-case letter, and a lower-case
- * letter is usually followed by another lower-case letter.
- * In the US-ASCII character set, the highest three bits are 010
- * for upper-case letters and 011 for lower-case letters.
- * When lc is at least 3, the literal coding can take advantage of
- * this property in the uncompressed data.
- *
- * There is a limit that applies to literal context bits and literal
- * position bits together: lc + lp <= 4. Without this limit the
- * decoding could become very slow, which could have security related
- * results in some cases like email servers doing virus scanning.
- * This limit also simplifies the internal implementation in liblzma.
- *
- * There may be LZMA1 streams that have lc + lp > 4 (maximum possible
- * lc would be 8). It is not possible to decode such streams with
- * liblzma.
- */
- uint32_t lc;
-# define LZMA_LCLP_MIN 0
-# define LZMA_LCLP_MAX 4
-# define LZMA_LC_DEFAULT 3
-
- /**
- * \brief Number of literal position bits
- *
- * lp affects what kind of alignment in the uncompressed data is
- * assumed when encoding literals. A literal is a single 8-bit byte.
- * See pb below for more information about alignment.
- */
- uint32_t lp;
-# define LZMA_LP_DEFAULT 0
-
- /**
- * \brief Number of position bits
- *
- * pb affects what kind of alignment in the uncompressed data is
- * assumed in general. The default means four-byte alignment
- * (2^ pb =2^2=4), which is often a good choice when there's
- * no better guess.
- *
- * When the aligment is known, setting pb accordingly may reduce
- * the file size a little. E.g. with text files having one-byte
- * alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can
- * improve compression slightly. For UTF-16 text, pb=1 is a good
- * choice. If the alignment is an odd number like 3 bytes, pb=0
- * might be the best choice.
- *
- * Even though the assumed alignment can be adjusted with pb and
- * lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment.
- * It might be worth taking into account when designing file formats
- * that are likely to be often compressed with LZMA1 or LZMA2.
- */
- uint32_t pb;
-# define LZMA_PB_MIN 0
-# define LZMA_PB_MAX 4
-# define LZMA_PB_DEFAULT 2
-
- /** Compression mode */
- lzma_mode mode;
-
- /**
- * \brief Nice length of a match
- *
- * This determines how many bytes the encoder compares from the match
- * candidates when looking for the best match. Once a match of at
- * least nice_len bytes long is found, the encoder stops looking for
- * better candidates and encodes the match. (Naturally, if the found
- * match is actually longer than nice_len, the actual length is
- * encoded; it's not truncated to nice_len.)
- *
- * Bigger values usually increase the compression ratio and
- * compression time. For most files, 32 to 128 is a good value,
- * which gives very good compression ratio at good speed.
- *
- * The exact minimum value depends on the match finder. The maximum
- * is 273, which is the maximum length of a match that LZMA1 and
- * LZMA2 can encode.
- */
- uint32_t nice_len;
-
- /** Match finder ID */
- lzma_match_finder mf;
-
- /**
- * \brief Maximum search depth in the match finder
- *
- * For every input byte, match finder searches through the hash chain
- * or binary tree in a loop, each iteration going one step deeper in
- * the chain or tree. The searching stops if
- * - a match of at least nice_len bytes long is found;
- * - all match candidates from the hash chain or binary tree have
- * been checked; or
- * - maximum search depth is reached.
- *
- * Maximum search depth is needed to prevent the match finder from
- * wasting too much time in case there are lots of short match
- * candidates. On the other hand, stopping the search before all
- * candidates have been checked can reduce compression ratio.
- *
- * Setting depth to zero tells liblzma to use an automatic default
- * value, that depends on the selected match finder and nice_len.
- * The default is in the range [4, 200] or so (it may vary between
- * liblzma versions).
- *
- * Using a bigger depth value than the default can increase
- * compression ratio in some cases. There is no strict maximum value,
- * but high values (thousands or millions) should be used with care:
- * the encoder could remain fast enough with typical input, but
- * malicious input could cause the match finder to slow down
- * dramatically, possibly creating a denial of service attack.
- */
- uint32_t depth;
-
- /*
- * Reserved space to allow possible future extensions without
- * breaking the ABI. You should not touch these, because the names
- * of these variables may change. These are and will never be used
- * with the currently supported options, so it is safe to leave these
- * uninitialized.
- */
- uint32_t reserved_int1;
- uint32_t reserved_int2;
- uint32_t reserved_int3;
- uint32_t reserved_int4;
- uint32_t reserved_int5;
- uint32_t reserved_int6;
- uint32_t reserved_int7;
- uint32_t reserved_int8;
- lzma_reserved_enum reserved_enum1;
- lzma_reserved_enum reserved_enum2;
- lzma_reserved_enum reserved_enum3;
- lzma_reserved_enum reserved_enum4;
- void *reserved_ptr1;
- void *reserved_ptr2;
-
-} lzma_options_lzma;
-
-
-/**
- * \brief Set a compression preset to lzma_options_lzma structure
- *
- * 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9
- * of the xz command line tool. In addition, it is possible to bitwise-or
- * flags to the preset. Currently only LZMA_PRESET_EXTREME is supported.
- * The flags are defined in container.h, because the flags are used also
- * with lzma_easy_encoder().
- *
- * The preset values are subject to changes between liblzma versions.
- *
- * This function is available only if LZMA1 or LZMA2 encoder has been enabled
- * when building liblzma.
- *
- * \return On success, false is returned. If the preset is not
- * supported, true is returned.
- */
-extern LZMA_API(lzma_bool) lzma_lzma_preset(
- lzma_options_lzma *options, uint32_t preset) lzma_nothrow;
diff --git a/Utilities/cmliblzma/liblzma/api/lzma/lzma12.h b/Utilities/cmliblzma/liblzma/api/lzma/lzma12.h
new file mode 100644
index 000000000..4e32fa3a2
--- /dev/null
+++ b/Utilities/cmliblzma/liblzma/api/lzma/lzma12.h
@@ -0,0 +1,420 @@
+/**
+ * \file lzma/lzma12.h
+ * \brief LZMA1 and LZMA2 filters
+ */
+
+/*
+ * Author: Lasse Collin
+ *
+ * This file has been put into the public domain.
+ * You can do whatever you want with this file.
+ *
+ * See ../lzma.h for information about liblzma as a whole.
+ */
+
+#ifndef LZMA_H_INTERNAL
+# error Never include this file directly. Use <lzma.h> instead.
+#endif
+
+
+/**
+ * \brief LZMA1 Filter ID
+ *
+ * LZMA1 is the very same thing as what was called just LZMA in LZMA Utils,
+ * 7-Zip, and LZMA SDK. It's called LZMA1 here to prevent developers from
+ * accidentally using LZMA when they actually want LZMA2.
+ *
+ * LZMA1 shouldn't be used for new applications unless you _really_ know
+ * what you are doing. LZMA2 is almost always a better choice.
+ */
+#define LZMA_FILTER_LZMA1 LZMA_VLI_C(0x4000000000000001)
+
+/**
+ * \brief LZMA2 Filter ID
+ *
+ * Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds
+ * support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion
+ * when trying to compress uncompressible data), possibility to change
+ * lc/lp/pb in the middle of encoding, and some other internal improvements.
+ */
+#define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21)
+
+
+/**
+ * \brief Match finders
+ *
+ * Match finder has major effect on both speed and compression ratio.
+ * Usually hash chains are faster than binary trees.
+ *
+ * If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better
+ * choice, because binary trees get much higher compression ratio penalty
+ * with LZMA_SYNC_FLUSH.
+ *
+ * The memory usage formulas are only rough estimates, which are closest to
+ * reality when dict_size is a power of two. The formulas are more complex
+ * in reality, and can also change a little between liblzma versions. Use
+ * lzma_raw_encoder_memusage() to get more accurate estimate of memory usage.
+ */
+typedef enum {
+ LZMA_MF_HC3 = 0x03,
+ /**<
+ * \brief Hash Chain with 2- and 3-byte hashing
+ *
+ * Minimum nice_len: 3
+ *
+ * Memory usage:
+ * - dict_size <= 16 MiB: dict_size * 7.5
+ * - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB
+ */
+
+ LZMA_MF_HC4 = 0x04,
+ /**<
+ * \brief Hash Chain with 2-, 3-, and 4-byte hashing
+ *
+ * Minimum nice_len: 4
+ *
+ * Memory usage:
+ * - dict_size <= 32 MiB: dict_size * 7.5
+ * - dict_size > 32 MiB: dict_size * 6.5
+ */
+
+ LZMA_MF_BT2 = 0x12,
+ /**<
+ * \brief Binary Tree with 2-byte hashing
+ *
+ * Minimum nice_len: 2
+ *
+ * Memory usage: dict_size * 9.5
+ */
+
+ LZMA_MF_BT3 = 0x13,
+ /**<
+ * \brief Binary Tree with 2- and 3-byte hashing
+ *
+ * Minimum nice_len: 3
+ *
+ * Memory usage:
+ * - dict_size <= 16 MiB: dict_size * 11.5
+ * - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB
+ */
+
+ LZMA_MF_BT4 = 0x14
+ /**<
+ * \brief Binary Tree with 2-, 3-, and 4-byte hashing
+ *
+ * Minimum nice_len: 4
+ *
+ * Memory usage:
+ * - dict_size <= 32 MiB: dict_size * 11.5
+ * - dict_size > 32 MiB: dict_size * 10.5
+ */
+} lzma_match_finder;
+
+
+/**
+ * \brief Test if given match finder is supported
+ *
+ * Return true if the given match finder is supported by this liblzma build.
+ * Otherwise false is returned. It is safe to call this with a value that
+ * isn't listed in lzma_match_finder enumeration; the return value will be
+ * false.
+ *
+ * There is no way to list which match finders are available in this
+ * particular liblzma version and build. It would be useless, because
+ * a new match finder, which the application developer wasn't aware,
+ * could require giving additional options to the encoder that the older
+ * match finders don't need.
+ */
+extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder)
+ lzma_nothrow lzma_attr_const;
+
+
+/**
+ * \brief Compression modes
+ *
+ * This selects the function used to analyze the data produced by the match
+ * finder.
+ */
+typedef enum {
+ LZMA_MODE_FAST = 1,
+ /**<
+ * \brief Fast compression
+ *
+ * Fast mode is usually at its best when combined with
+ * a hash chain match finder.
+ */
+
+ LZMA_MODE_NORMAL = 2
+ /**<
+ * \brief Normal compression
+ *
+ * This is usually notably slower than fast mode. Use this
+ * together with binary tree match finders to expose the
+ * full potential of the LZMA1 or LZMA2 encoder.
+ */
+} lzma_mode;
+
+
+/**
+ * \brief Test if given compression mode is supported
+ *
+ * Return true if the given compression mode is supported by this liblzma
+ * build. Otherwise false is returned. It is safe to call this with a value
+ * that isn't listed in lzma_mode enumeration; the return value will be false.
+ *
+ * There is no way to list which modes are available in this particular
+ * liblzma version and build. It would be useless, because a new compression
+ * mode, which the application developer wasn't aware, could require giving
+ * additional options to the encoder that the older modes don't need.
+ */
+extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode)
+ lzma_nothrow lzma_attr_const;
+
+
+/**
+ * \brief Options specific to the LZMA1 and LZMA2 filters
+ *
+ * Since LZMA1 and LZMA2 share most of the code, it's simplest to share
+ * the options structure too. For encoding, all but the reserved variables
+ * need to be initialized unless specifically mentioned otherwise.
+ * lzma_lzma_preset() can be used to get a good starting point.
+ *
+ * For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and
+ * preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb.
+ */
+typedef struct {
+ /**
+ * \brief Dictionary size in bytes
+ *
+ * Dictionary size indicates how many bytes of the recently processed
+ * uncompressed data is kept in memory. One method to reduce size of
+ * the uncompressed data is to store distance-length pairs, which
+ * indicate what data to repeat from the dictionary buffer. Thus,
+ * the bigger the dictionary, the better the compression ratio
+ * usually is.
+ *
+ * Maximum size of the dictionary depends on multiple things:
+ * - Memory usage limit
+ * - Available address space (not a problem on 64-bit systems)
+ * - Selected match finder (encoder only)
+ *
+ * Currently the maximum dictionary size for encoding is 1.5 GiB
+ * (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit
+ * systems for certain match finder implementation reasons. In the
+ * future, there may be match finders that support bigger
+ * dictionaries.
+ *
+ * Decoder already supports dictionaries up to 4 GiB - 1 B (i.e.
+ * UINT32_MAX), so increasing the maximum dictionary size of the
+ * encoder won't cause problems for old decoders.
+ *
+ * Because extremely small dictionaries sizes would have unneeded
+ * overhead in the decoder, the minimum dictionary size is 4096 bytes.
+ *
+ * \note When decoding, too big dictionary does no other harm
+ * than wasting memory.
+ */
+ uint32_t dict_size;
+# define LZMA_DICT_SIZE_MIN UINT32_C(4096)
+# define LZMA_DICT_SIZE_DEFAULT (UINT32_C(1) << 23)
+
+ /**
+ * \brief Pointer to an initial dictionary
+ *
+ * It is possible to initialize the LZ77 history window using
+ * a preset dictionary. It is useful when compressing many
+ * similar, relatively small chunks of data independently from
+ * each other. The preset dictionary should contain typical
+ * strings that occur in the files being compressed. The most
+ * probable strings should be near the end of the preset dictionary.
+ *
+ * This feature should be used only in special situations. For
+ * now, it works correctly only with raw encoding and decoding.
+ * Currently none of the container formats supported by
+ * liblzma allow preset dictionary when decoding, thus if
+ * you create a .xz or .lzma file with preset dictionary, it
+ * cannot be decoded with the regular decoder functions. In the
+ * future, the .xz format will likely get support for preset
+ * dictionary though.
+ */
+ const uint8_t *preset_dict;
+
+ /**
+ * \brief Size of the preset dictionary
+ *
+ * Specifies the size of the preset dictionary. If the size is
+ * bigger than dict_size, only the last dict_size bytes are
+ * processed.
+ *
+ * This variable is read only when preset_dict is not NULL.
+ * If preset_dict is not NULL but preset_dict_size is zero,
+ * no preset dictionary is used (identical to only setting
+ * preset_dict to NULL).
+ */
+ uint32_t preset_dict_size;
+
+ /**
+ * \brief Number of literal context bits
+ *
+ * How many of the highest bits of the previous uncompressed
+ * eight-bit byte (also known as `literal') are taken into
+ * account when predicting the bits of the next literal.
+ *
+ * E.g. in typical English text, an upper-case letter is
+ * often followed by a lower-case letter, and a lower-case
+ * letter is usually followed by another lower-case letter.
+ * In the US-ASCII character set, the highest three bits are 010
+ * for upper-case letters and 011 for lower-case letters.
+ * When lc is at least 3, the literal coding can take advantage of
+ * this property in the uncompressed data.
+ *
+ * There is a limit that applies to literal context bits and literal
+ * position bits together: lc + lp <= 4. Without this limit the
+ * decoding could become very slow, which could have security related
+ * results in some cases like email servers doing virus scanning.
+ * This limit also simplifies the internal implementation in liblzma.
+ *
+ * There may be LZMA1 streams that have lc + lp > 4 (maximum possible
+ * lc would be 8). It is not possible to decode such streams with
+ * liblzma.
+ */
+ uint32_t lc;
+# define LZMA_LCLP_MIN 0
+# define LZMA_LCLP_MAX 4
+# define LZMA_LC_DEFAULT 3
+
+ /**
+ * \brief Number of literal position bits
+ *
+ * lp affects what kind of alignment in the uncompressed data is
+ * assumed when encoding literals. A literal is a single 8-bit byte.
+ * See pb below for more information about alignment.
+ */
+ uint32_t lp;
+# define LZMA_LP_DEFAULT 0
+
+ /**
+ * \brief Number of position bits
+ *
+ * pb affects what kind of alignment in the uncompressed data is
+ * assumed in general. The default means four-byte alignment
+ * (2^ pb =2^2=4), which is often a good choice when there's
+ * no better guess.
+ *
+ * When the aligment is known, setting pb accordingly may reduce
+ * the file size a little. E.g. with text files having one-byte
+ * alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can
+ * improve compression slightly. For UTF-16 text, pb=1 is a good
+ * choice. If the alignment is an odd number like 3 bytes, pb=0
+ * might be the best choice.
+ *
+ * Even though the assumed alignment can be adjusted with pb and
+ * lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment.
+ * It might be worth taking into account when designing file formats
+ * that are likely to be often compressed with LZMA1 or LZMA2.
+ */
+ uint32_t pb;
+# define LZMA_PB_MIN 0
+# define LZMA_PB_MAX 4
+# define LZMA_PB_DEFAULT 2
+
+ /** Compression mode */
+ lzma_mode mode;
+
+ /**
+ * \brief Nice length of a match
+ *
+ * This determines how many bytes the encoder compares from the match
+ * candidates when looking for the best match. Once a match of at
+ * least nice_len bytes long is found, the encoder stops looking for
+ * better candidates and encodes the match. (Naturally, if the found
+ * match is actually longer than nice_len, the actual length is
+ * encoded; it's not truncated to nice_len.)
+ *
+ * Bigger values usually increase the compression ratio and
+ * compression time. For most files, 32 to 128 is a good value,
+ * which gives very good compression ratio at good speed.
+ *
+ * The exact minimum value depends on the match finder. The maximum
+ * is 273, which is the maximum length of a match that LZMA1 and
+ * LZMA2 can encode.
+ */
+ uint32_t nice_len;
+
+ /** Match finder ID */
+ lzma_match_finder mf;
+
+ /**
+ * \brief Maximum search depth in the match finder
+ *
+ * For every input byte, match finder searches through the hash chain
+ * or binary tree in a loop, each iteration going one step deeper in
+ * the chain or tree. The searching stops if
+ * - a match of at least nice_len bytes long is found;
+ * - all match candidates from the hash chain or binary tree have
+ * been checked; or
+ * - maximum search depth is reached.
+ *
+ * Maximum search depth is needed to prevent the match finder from
+ * wasting too much time in case there are lots of short match
+ * candidates. On the other hand, stopping the search before all
+ * candidates have been checked can reduce compression ratio.
+ *
+ * Setting depth to zero tells liblzma to use an automatic default
+ * value, that depends on the selected match finder and nice_len.
+ * The default is in the range [4, 200] or so (it may vary between
+ * liblzma versions).
+ *
+ * Using a bigger depth value than the default can increase
+ * compression ratio in some cases. There is no strict maximum value,
+ * but high values (thousands or millions) should be used with care:
+ * the encoder could remain fast enough with typical input, but
+ * malicious input could cause the match finder to slow down
+ * dramatically, possibly creating a denial of service attack.
+ */
+ uint32_t depth;
+
+ /*
+ * Reserved space to allow possible future extensions without
+ * breaking the ABI. You should not touch these, because the names
+ * of these variables may change. These are and will never be used
+ * with the currently supported options, so it is safe to leave these
+ * uninitialized.
+ */
+ uint32_t reserved_int1;
+ uint32_t reserved_int2;
+ uint32_t reserved_int3;
+ uint32_t reserved_int4;
+ uint32_t reserved_int5;
+ uint32_t reserved_int6;
+ uint32_t reserved_int7;
+ uint32_t reserved_int8;
+ lzma_reserved_enum reserved_enum1;
+ lzma_reserved_enum reserved_enum2;
+ lzma_reserved_enum reserved_enum3;
+ lzma_reserved_enum reserved_enum4;
+ void *reserved_ptr1;
+ void *reserved_ptr2;
+
+} lzma_options_lzma;
+
+
+/**
+ * \brief Set a compression preset to lzma_options_lzma structure
+ *
+ * 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9
+ * of the xz command line tool. In addition, it is possible to bitwise-or
+ * flags to the preset. Currently only LZMA_PRESET_EXTREME is supported.
+ * The flags are defined in container.h, because the flags are used also
+ * with lzma_easy_encoder().
+ *
+ * The preset values are subject to changes between liblzma versions.
+ *
+ * This function is available only if LZMA1 or LZMA2 encoder has been enabled
+ * when building liblzma.
+ *
+ * \return On success, false is returned. If the preset is not
+ * supported, true is returned.
+ */
+extern LZMA_API(lzma_bool) lzma_lzma_preset(
+ lzma_options_lzma *options, uint32_t preset) lzma_nothrow;
diff --git a/Utilities/cmliblzma/liblzma/api/lzma/version.h b/Utilities/cmliblzma/liblzma/api/lzma/version.h
index 09866b982..143c7dea6 100644
--- a/Utilities/cmliblzma/liblzma/api/lzma/version.h
+++ b/Utilities/cmliblzma/liblzma/api/lzma/version.h
@@ -21,8 +21,8 @@
* Version number split into components
*/
#define LZMA_VERSION_MAJOR 5
-#define LZMA_VERSION_MINOR 0
-#define LZMA_VERSION_PATCH 8
+#define LZMA_VERSION_MINOR 2
+#define LZMA_VERSION_PATCH 4
#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE
#ifndef LZMA_VERSION_COMMIT
diff --git a/Utilities/cmliblzma/liblzma/check/check.c b/Utilities/cmliblzma/liblzma/check/check.c
index 979b0a818..428ddaeb7 100644
--- a/Utilities/cmliblzma/liblzma/check/check.c
+++ b/Utilities/cmliblzma/liblzma/check/check.c
@@ -16,6 +16,9 @@
extern LZMA_API(lzma_bool)
lzma_check_is_supported(lzma_check type)
{
+ if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
+ return false;
+
static const lzma_bool available_checks[LZMA_CHECK_ID_MAX + 1] = {
true, // LZMA_CHECK_NONE
@@ -53,9 +56,6 @@ lzma_check_is_supported(lzma_check type)
false, // Reserved
};
- if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
- return false;
-
return available_checks[(unsigned int)(type)];
}
@@ -63,6 +63,9 @@ lzma_check_is_supported(lzma_check type)
extern LZMA_API(uint32_t)
lzma_check_size(lzma_check type)
{
+ if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
+ return UINT32_MAX;
+
// See file-format.txt section 2.1.1.2.
static const uint8_t check_sizes[LZMA_CHECK_ID_MAX + 1] = {
0,
@@ -73,9 +76,6 @@ lzma_check_size(lzma_check type)
64, 64, 64
};
- if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
- return UINT32_MAX;
-
return check_sizes[(unsigned int)(type)];
}
diff --git a/Utilities/cmliblzma/liblzma/check/check.h b/Utilities/cmliblzma/liblzma/check/check.h
index e100d2b85..3007d889b 100644
--- a/Utilities/cmliblzma/liblzma/check/check.h
+++ b/Utilities/cmliblzma/liblzma/check/check.h
@@ -15,6 +15,53 @@
#include "common.h"
+// If the function for external SHA-256 is missing, use the internal SHA-256
+// code. Due to how configure works, these defines can only get defined when
+// both a usable header and a type have already been found.
+#if !(defined(HAVE_CC_SHA256_INIT) \
+ || defined(HAVE_SHA256_INIT) \
+ || defined(HAVE_SHA256INIT))
+# define HAVE_INTERNAL_SHA256 1
+#endif
+
+#if defined(HAVE_INTERNAL_SHA256)
+// Nothing
+#elif defined(HAVE_COMMONCRYPTO_COMMONDIGEST_H)
+# include <CommonCrypto/CommonDigest.h>
+#elif defined(HAVE_SHA256_H)
+# include <sys/types.h>
+# include <sha256.h>
+#elif defined(HAVE_SHA2_H)
+# include <sys/types.h>
+# include <sha2.h>
+#endif
+
+#if defined(HAVE_INTERNAL_SHA256)
+/// State for the internal SHA-256 implementation
+typedef struct {
+ /// Internal state
+ uint32_t state[8];
+
+ /// Size of the message excluding padding
+ uint64_t size;
+} lzma_sha256_state;
+#elif defined(HAVE_CC_SHA256_CTX)
+typedef CC_SHA256_CTX lzma_sha256_state;
+#elif defined(HAVE_SHA256_CTX)
+typedef SHA256_CTX lzma_sha256_state;
+#elif defined(HAVE_SHA2_CTX)
+typedef SHA2_CTX lzma_sha256_state;
+#endif
+
+#if defined(HAVE_INTERNAL_SHA256)
+// Nothing
+#elif defined(HAVE_CC_SHA256_INIT)
+# define LZMA_SHA256FUNC(x) CC_SHA256_ ## x
+#elif defined(HAVE_SHA256_INIT)
+# define LZMA_SHA256FUNC(x) SHA256_ ## x
+#elif defined(HAVE_SHA256INIT)
+# define LZMA_SHA256FUNC(x) SHA256 ## x
+#endif
// Index hashing needs the best possible hash function (preferably
// a cryptographic hash) for maximum reliability.
@@ -43,14 +90,7 @@ typedef struct {
union {
uint32_t crc32;
uint64_t crc64;
-
- struct {
- /// Internal state
- uint32_t state[8];
-
- /// Size of the message excluding padding
- uint64_t size;
- } sha256;
+ lzma_sha256_state sha256;
} state;
} lzma_check_state;
@@ -82,6 +122,8 @@ extern void lzma_check_update(lzma_check_state *check, lzma_check type,
extern void lzma_check_finish(lzma_check_state *check, lzma_check type);
+#ifndef LZMA_SHA256FUNC
+
/// Prepare SHA-256 state for new input.
extern void lzma_sha256_init(lzma_check_state *check);
@@ -92,4 +134,39 @@ extern void lzma_sha256_update(
/// Finish the SHA-256 calculation and store the result to check->buffer.u8.
extern void lzma_sha256_finish(lzma_check_state *check);
+
+#else
+
+static inline void
+lzma_sha256_init(lzma_check_state *check)
+{
+ LZMA_SHA256FUNC(Init)(&check->state.sha256);
+}
+
+
+static inline void
+lzma_sha256_update(const uint8_t *buf, size_t size, lzma_check_state *check)
+{
+#if defined(HAVE_CC_SHA256_INIT) && SIZE_MAX > UINT32_MAX
+ // Darwin's CC_SHA256_Update takes uint32_t as the buffer size,
+ // so use a loop to support size_t.
+ while (size > UINT32_MAX) {
+ LZMA_SHA256FUNC(Update)(&check->state.sha256, buf, UINT32_MAX);
+ buf += UINT32_MAX;
+ size -= UINT32_MAX;
+ }
+#endif
+
+ LZMA_SHA256FUNC(Update)(&check->state.sha256, buf, size);
+}
+
+
+static inline void
+lzma_sha256_finish(lzma_check_state *check)
+{
+ LZMA_SHA256FUNC(Final)(check->buffer.u8, &check->state.sha256);
+}
+
+#endif
+
#endif
diff --git a/Utilities/cmliblzma/liblzma/check/crc32_fast.c b/Utilities/cmliblzma/liblzma/check/crc32_fast.c
index c2c3cb79b..3de02638d 100644
--- a/Utilities/cmliblzma/liblzma/check/crc32_fast.c
+++ b/Utilities/cmliblzma/liblzma/check/crc32_fast.c
@@ -33,8 +33,6 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
#endif
if (size > 8) {
- const uint8_t * limit;
-
// Fix the alignment, if needed. The if statement above
// ensures that this won't read past the end of buf[].
while ((uintptr_t)(buf) & 7) {
@@ -43,7 +41,7 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
}
// Calculate the position where to stop.
- limit = buf + (size & ~(size_t)(7));
+ const uint8_t *const limit = buf + (size & ~(size_t)(7));
// Calculate how many bytes must be calculated separately
// before returning the result.
@@ -51,8 +49,6 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
// Calculate the CRC32 using the slice-by-eight algorithm.
while (buf < limit) {
- uint32_t tmp;
-
crc ^= *(const uint32_t *)(buf);
buf += 4;
@@ -61,7 +57,7 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
^ lzma_crc32_table[5][C(crc)]
^ lzma_crc32_table[4][D(crc)];
- tmp = *(const uint32_t *)(buf);
+ const uint32_t tmp = *(const uint32_t *)(buf);
buf += 4;
// At least with some compilers, it is critical for
diff --git a/Utilities/cmliblzma/liblzma/check/crc64_fast.c b/Utilities/cmliblzma/liblzma/check/crc64_fast.c
index 1436557af..52af29ed4 100644
--- a/Utilities/cmliblzma/liblzma/check/crc64_fast.c
+++ b/Utilities/cmliblzma/liblzma/check/crc64_fast.c
@@ -36,14 +36,12 @@ lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
#endif
if (size > 4) {
- const uint8_t *limit;
-
while ((uintptr_t)(buf) & 3) {
crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);
--size;
}
- limit = buf + (size & ~(size_t)(3));
+ const uint8_t *const limit = buf + (size & ~(size_t)(3));
size &= (size_t)(3);
while (buf < limit) {
diff --git a/Utilities/cmliblzma/liblzma/check/sha256.c b/Utilities/cmliblzma/liblzma/check/sha256.c
index 3af6aa67d..5eede5ce0 100644
--- a/Utilities/cmliblzma/liblzma/check/sha256.c
+++ b/Utilities/cmliblzma/liblzma/check/sha256.c
@@ -21,22 +21,22 @@
//
///////////////////////////////////////////////////////////////////////////////
-// Avoid bogus warnings in transform().
-#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) || __GNUC__ > 4
-# pragma GCC diagnostic ignored "-Wuninitialized"
-#endif
-
#include "check.h"
-// At least on x86, GCC is able to optimize this to a rotate instruction.
-#define rotr_32(num, amount) ((num) >> (amount) | (num) << (32 - (amount)))
+// Rotate a uint32_t. GCC can optimize this to a rotate instruction
+// at least on x86.
+static inline uint32_t
+rotr_32(uint32_t num, unsigned amount)
+{
+ return (num >> amount) | (num << (32 - amount));
+}
-#define blk0(i) (W[i] = data[i])
+#define blk0(i) (W[i] = conv32be(data[i]))
#define blk2(i) (W[i & 15] += s1(W[(i - 2) & 15]) + W[(i - 7) & 15] \
+ s0(W[(i - 15) & 15]))
#define Ch(x, y, z) (z ^ (x & (y ^ z)))
-#define Maj(x, y, z) ((x & y) | (z & (x | y)))
+#define Maj(x, y, z) ((x & (y ^ z)) + (y & z))
#define a(i) T[(0 - i) & 7]
#define b(i) T[(1 - i) & 7]
@@ -47,16 +47,17 @@
#define g(i) T[(6 - i) & 7]
#define h(i) T[(7 - i) & 7]
-#define R(i) \
- h(i) += S1(e(i)) + Ch(e(i), f(i), g(i)) + SHA256_K[i + j] \
- + (j ? blk2(i) : blk0(i)); \
+#define R(i, j, blk) \
+ h(i) += S1(e(i)) + Ch(e(i), f(i), g(i)) + SHA256_K[i + j] + blk; \
d(i) += h(i); \
h(i) += S0(a(i)) + Maj(a(i), b(i), c(i))
+#define R0(i) R(i, 0, blk0(i))
+#define R2(i) R(i, j, blk2(i))
-#define S0(x) (rotr_32(x, 2) ^ rotr_32(x, 13) ^ rotr_32(x, 22))
-#define S1(x) (rotr_32(x, 6) ^ rotr_32(x, 11) ^ rotr_32(x, 25))
-#define s0(x) (rotr_32(x, 7) ^ rotr_32(x, 18) ^ (x >> 3))
-#define s1(x) (rotr_32(x, 17) ^ rotr_32(x, 19) ^ (x >> 10))
+#define S0(x) rotr_32(x ^ rotr_32(x ^ rotr_32(x, 9), 11), 2)
+#define S1(x) rotr_32(x ^ rotr_32(x ^ rotr_32(x, 14), 5), 6)
+#define s0(x) (rotr_32(x ^ rotr_32(x, 11), 7) ^ (x >> 3))
+#define s1(x) (rotr_32(x ^ rotr_32(x, 2), 17) ^ (x >> 10))
static const uint32_t SHA256_K[64] = {
@@ -84,17 +85,22 @@ transform(uint32_t state[8], const uint32_t data[16])
{
uint32_t W[16];
uint32_t T[8];
- unsigned int j;
// Copy state[] to working vars.
memcpy(T, state, sizeof(T));
- // 64 operations, partially loop unrolled
- for (j = 0; j < 64; j += 16) {
- R( 0); R( 1); R( 2); R( 3);
- R( 4); R( 5); R( 6); R( 7);
- R( 8); R( 9); R(10); R(11);
- R(12); R(13); R(14); R(15);
+ // The first 16 operations unrolled
+ R0( 0); R0( 1); R0( 2); R0( 3);
+ R0( 4); R0( 5); R0( 6); R0( 7);
+ R0( 8); R0( 9); R0(10); R0(11);
+ R0(12); R0(13); R0(14); R0(15);
+
+ // The remaining 48 operations partially unrolled
+ for (unsigned int j = 16; j < 64; j += 16) {
+ R2( 0); R2( 1); R2( 2); R2( 3);
+ R2( 4); R2( 5); R2( 6); R2( 7);
+ R2( 8); R2( 9); R2(10); R2(11);
+ R2(12); R2(13); R2(14); R2(15);
}
// Add the working vars back into state[].
@@ -112,19 +118,7 @@ transform(uint32_t state[8], const uint32_t data[16])
static void
process(lzma_check_state *check)
{
-#ifdef WORDS_BIGENDIAN
transform(check->state.sha256.state, check->buffer.u32);
-
-#else
- uint32_t data[16];
- size_t i;
-
- for (i = 0; i < 16; ++i)
- data[i] = bswap32(check->buffer.u32[i]);
-
- transform(check->state.sha256.state, data);
-#endif
-
return;
}
@@ -174,8 +168,6 @@ lzma_sha256_update(const uint8_t *buf, size_t size, lzma_check_state *check)
extern void
lzma_sha256_finish(lzma_check_state *check)
{
- size_t i;
-
// Add padding as described in RFC 3174 (it describes SHA-1 but
// the same padding style is used for SHA-256 too).
size_t pos = check->state.sha256.size & 0x3F;
@@ -197,7 +189,7 @@ lzma_sha256_finish(lzma_check_state *check)
process(check);
- for (i = 0; i < 8; ++i)
+ for (size_t i = 0; i < 8; ++i)
check->buffer.u32[i] = conv32be(check->state.sha256.state[i]);
return;
diff --git a/Utilities/cmliblzma/liblzma/common/alone_decoder.c b/Utilities/cmliblzma/liblzma/common/alone_decoder.c
index 5f5e564ab..77d0a9b10 100644
--- a/Utilities/cmliblzma/liblzma/common/alone_decoder.c
+++ b/Utilities/cmliblzma/liblzma/common/alone_decoder.c
@@ -15,7 +15,7 @@
#include "lz_decoder.h"
-struct lzma_coder_s {
+typedef struct {
lzma_next_coder next;
enum {
@@ -46,17 +46,19 @@ struct lzma_coder_s {
/// Options decoded from the header needed to initialize
/// the LZMA decoder
lzma_options_lzma options;
-};
+} lzma_alone_coder;
static lzma_ret
-alone_decode(lzma_coder *coder,
- lzma_allocator *allocator lzma_attribute((__unused__)),
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size,
+alone_decode(void *coder_ptr,
+ const lzma_allocator *allocator lzma_attribute((__unused__)),
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size,
lzma_action action)
{
+ lzma_alone_coder *coder = coder_ptr;
+
while (*out_pos < out_size
&& (coder->sequence == SEQ_CODE || *in_pos < in_size))
switch (coder->sequence) {
@@ -126,17 +128,19 @@ alone_decode(lzma_coder *coder,
// Fall through
case SEQ_CODER_INIT: {
- lzma_ret ret;
+ if (coder->memusage > coder->memlimit)
+ return LZMA_MEMLIMIT_ERROR;
lzma_filter_info filters[2] = {
- { 0, &lzma_lzma_decoder_init, &coder->options },
- { 0, NULL, NULL }
+ {
+ .init = &lzma_lzma_decoder_init,
+ .options = &coder->options,
+ }, {
+ .init = NULL,
+ }
};
- if (coder->memusage > coder->memlimit)
- return LZMA_MEMLIMIT_ERROR;
-
- ret = lzma_next_filter_init(&coder->next,
+ const lzma_ret ret = lzma_next_filter_init(&coder->next,
allocator, filters);
if (ret != LZMA_OK)
return ret;
@@ -164,8 +168,9 @@ alone_decode(lzma_coder *coder,
static void
-alone_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
+alone_decoder_end(void *coder_ptr, const lzma_allocator *allocator)
{
+ lzma_alone_coder *coder = coder_ptr;
lzma_next_end(&coder->next, allocator);
lzma_free(coder, allocator);
return;
@@ -173,9 +178,11 @@ alone_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
-alone_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
+alone_decoder_memconfig(void *coder_ptr, uint64_t *memusage,
uint64_t *old_memlimit, uint64_t new_memlimit)
{
+ lzma_alone_coder *coder = coder_ptr;
+
*memusage = coder->memusage;
*old_memlimit = coder->memlimit;
@@ -191,34 +198,34 @@ alone_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
extern lzma_ret
-lzma_alone_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_alone_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
uint64_t memlimit, bool picky)
{
lzma_next_coder_init(&lzma_alone_decoder_init, next, allocator);
- if (memlimit == 0)
- return LZMA_PROG_ERROR;
+ lzma_alone_coder *coder = next->coder;
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_alone_coder), allocator);
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ next->coder = coder;
next->code = &alone_decode;
next->end = &alone_decoder_end;
next->memconfig = &alone_decoder_memconfig;
- next->coder->next = LZMA_NEXT_CODER_INIT;
+ coder->next = LZMA_NEXT_CODER_INIT;
}
- next->coder->sequence = SEQ_PROPERTIES;
- next->coder->picky = picky;
- next->coder->pos = 0;
- next->coder->options.dict_size = 0;
- next->coder->options.preset_dict = NULL;
- next->coder->options.preset_dict_size = 0;
- next->coder->uncompressed_size = 0;
- next->coder->memlimit = memlimit;
- next->coder->memusage = LZMA_MEMUSAGE_BASE;
+ coder->sequence = SEQ_PROPERTIES;
+ coder->picky = picky;
+ coder->pos = 0;
+ coder->options.dict_size = 0;
+ coder->options.preset_dict = NULL;
+ coder->options.preset_dict_size = 0;
+ coder->uncompressed_size = 0;
+ coder->memlimit = my_max(1, memlimit);
+ coder->memusage = LZMA_MEMUSAGE_BASE;
return LZMA_OK;
}
@@ -227,7 +234,7 @@ lzma_alone_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern LZMA_API(lzma_ret)
lzma_alone_decoder(lzma_stream *strm, uint64_t memlimit)
{
- lzma_next_strm_init2(lzma_alone_decoder_init, strm, memlimit, false);
+ lzma_next_strm_init(lzma_alone_decoder_init, strm, memlimit, false);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff --git a/Utilities/cmliblzma/liblzma/common/alone_decoder.h b/Utilities/cmliblzma/liblzma/common/alone_decoder.h
index f666fc382..dfa031aa7 100644
--- a/Utilities/cmliblzma/liblzma/common/alone_decoder.h
+++ b/Utilities/cmliblzma/liblzma/common/alone_decoder.h
@@ -17,7 +17,7 @@
extern lzma_ret lzma_alone_decoder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
+ lzma_next_coder *next, const lzma_allocator *allocator,
uint64_t memlimit, bool picky);
#endif
diff --git a/Utilities/cmliblzma/liblzma/common/alone_encoder.c b/Utilities/cmliblzma/liblzma/common/alone_encoder.c
index 4207b4a52..4853cfd1d 100644
--- a/Utilities/cmliblzma/liblzma/common/alone_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/alone_encoder.c
@@ -17,7 +17,7 @@
#define ALONE_HEADER_SIZE (1 + 4 + 8)
-struct lzma_coder_s {
+typedef struct {
lzma_next_coder next;
enum {
@@ -27,17 +27,19 @@ struct lzma_coder_s {
size_t header_pos;
uint8_t header[ALONE_HEADER_SIZE];
-};
+} lzma_alone_coder;
static lzma_ret
-alone_encode(lzma_coder *coder,
- lzma_allocator *allocator lzma_attribute((__unused__)),
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size,
+alone_encode(void *coder_ptr,
+ const lzma_allocator *allocator lzma_attribute((__unused__)),
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size,
lzma_action action)
{
+ lzma_alone_coder *coder = coder_ptr;
+
while (*out_pos < out_size)
switch (coder->sequence) {
case SEQ_HEADER:
@@ -65,8 +67,9 @@ alone_encode(lzma_coder *coder,
static void
-alone_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
+alone_encoder_end(void *coder_ptr, const lzma_allocator *allocator)
{
+ lzma_alone_coder *coder = coder_ptr;
lzma_next_end(&coder->next, allocator);
lzma_free(coder, allocator);
return;
@@ -75,36 +78,31 @@ alone_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
// At least for now, this is not used by any internal function.
static lzma_ret
-alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+alone_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_options_lzma *options)
{
- uint32_t d;
-
- // Initialize the LZMA encoder.
- const lzma_filter_info filters[2] = {
- { 0, &lzma_lzma_encoder_init, (void *)(options) },
- { 0, NULL, NULL }
- };
-
lzma_next_coder_init(&alone_encoder_init, next, allocator);
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
+ lzma_alone_coder *coder = next->coder;
+
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_alone_coder), allocator);
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ next->coder = coder;
next->code = &alone_encode;
next->end = &alone_encoder_end;
- next->coder->next = LZMA_NEXT_CODER_INIT;
+ coder->next = LZMA_NEXT_CODER_INIT;
}
// Basic initializations
- next->coder->sequence = SEQ_HEADER;
- next->coder->header_pos = 0;
+ coder->sequence = SEQ_HEADER;
+ coder->header_pos = 0;
// Encode the header:
// - Properties (1 byte)
- if (lzma_lzma_lclppb_encode(options, next->coder->header))
+ if (lzma_lzma_lclppb_encode(options, coder->header))
return LZMA_OPTIONS_ERROR;
// - Dictionary size (4 bytes)
@@ -115,7 +113,7 @@ alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
// one is the next unless it is UINT32_MAX. While the header would
// allow any 32-bit integer, we do this to keep the decoder of liblzma
// accepting the resulting files.
- d = options->dict_size - 1;
+ uint32_t d = options->dict_size - 1;
d |= d >> 2;
d |= d >> 3;
d |= d >> 4;
@@ -124,18 +122,28 @@ alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
if (d != UINT32_MAX)
++d;
- unaligned_write32le(next->coder->header + 1, d);
+ unaligned_write32le(coder->header + 1, d);
// - Uncompressed size (always unknown and using EOPM)
- memset(next->coder->header + 1 + 4, 0xFF, 8);
+ memset(coder->header + 1 + 4, 0xFF, 8);
+
+ // Initialize the LZMA encoder.
+ const lzma_filter_info filters[2] = {
+ {
+ .init = &lzma_lzma_encoder_init,
+ .options = (void *)(options),
+ }, {
+ .init = NULL,
+ }
+ };
- return lzma_next_filter_init(&next->coder->next, allocator, filters);
+ return lzma_next_filter_init(&coder->next, allocator, filters);
}
/*
extern lzma_ret
-lzma_alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_alone_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_options_alone *options)
{
lzma_next_coder_init(&alone_encoder_init, next, allocator, options);
@@ -146,7 +154,7 @@ lzma_alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern LZMA_API(lzma_ret)
lzma_alone_encoder(lzma_stream *strm, const lzma_options_lzma *options)
{
- lzma_next_strm_init1(alone_encoder_init, strm, options);
+ lzma_next_strm_init(alone_encoder_init, strm, options);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff --git a/Utilities/cmliblzma/liblzma/common/auto_decoder.c b/Utilities/cmliblzma/liblzma/common/auto_decoder.c
index 24cf48905..6895c7ccf 100644
--- a/Utilities/cmliblzma/liblzma/common/auto_decoder.c
+++ b/Utilities/cmliblzma/liblzma/common/auto_decoder.c
@@ -14,7 +14,7 @@
#include "alone_decoder.h"
-struct lzma_coder_s {
+typedef struct {
/// Stream decoder or LZMA_Alone decoder
lzma_next_coder next;
@@ -26,15 +26,17 @@ struct lzma_coder_s {
SEQ_CODE,
SEQ_FINISH,
} sequence;
-};
+} lzma_auto_coder;
static lzma_ret
-auto_decode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size, lzma_action action)
+auto_decode(void *coder_ptr, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size, lzma_action action)
{
+ lzma_auto_coder *coder = coder_ptr;
+
switch (coder->sequence) {
case SEQ_INIT:
if (*in_pos >= in_size)
@@ -100,8 +102,9 @@ auto_decode(lzma_coder *coder, lzma_allocator *allocator,
static void
-auto_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
+auto_decoder_end(void *coder_ptr, const lzma_allocator *allocator)
{
+ lzma_auto_coder *coder = coder_ptr;
lzma_next_end(&coder->next, allocator);
lzma_free(coder, allocator);
return;
@@ -109,8 +112,10 @@ auto_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_check
-auto_decoder_get_check(const lzma_coder *coder)
+auto_decoder_get_check(const void *coder_ptr)
{
+ const lzma_auto_coder *coder = coder_ptr;
+
// It is LZMA_Alone if get_check is NULL.
return coder->next.get_check == NULL ? LZMA_CHECK_NONE
: coder->next.get_check(coder->next.coder);
@@ -118,9 +123,11 @@ auto_decoder_get_check(const lzma_coder *coder)
static lzma_ret
-auto_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
+auto_decoder_memconfig(void *coder_ptr, uint64_t *memusage,
uint64_t *old_memlimit, uint64_t new_memlimit)
{
+ lzma_auto_coder *coder = coder_ptr;
+
lzma_ret ret;
if (coder->next.memconfig != NULL) {
@@ -132,7 +139,10 @@ auto_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
// the current memory usage.
*memusage = LZMA_MEMUSAGE_BASE;
*old_memlimit = coder->memlimit;
+
ret = LZMA_OK;
+ if (new_memlimit != 0 && new_memlimit < *memusage)
+ ret = LZMA_MEMLIMIT_ERROR;
}
if (ret == LZMA_OK && new_memlimit != 0)
@@ -143,32 +153,31 @@ auto_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
static lzma_ret
-auto_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+auto_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
uint64_t memlimit, uint32_t flags)
{
lzma_next_coder_init(&auto_decoder_init, next, allocator);
- if (memlimit == 0)
- return LZMA_PROG_ERROR;
-
if (flags & ~LZMA_SUPPORTED_FLAGS)
return LZMA_OPTIONS_ERROR;
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
+ lzma_auto_coder *coder = next->coder;
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_auto_coder), allocator);
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ next->coder = coder;
next->code = &auto_decode;
next->end = &auto_decoder_end;
next->get_check = &auto_decoder_get_check;
next->memconfig = &auto_decoder_memconfig;
- next->coder->next = LZMA_NEXT_CODER_INIT;
+ coder->next = LZMA_NEXT_CODER_INIT;
}
- next->coder->memlimit = memlimit;
- next->coder->flags = flags;
- next->coder->sequence = SEQ_INIT;
+ coder->memlimit = my_max(1, memlimit);
+ coder->flags = flags;
+ coder->sequence = SEQ_INIT;
return LZMA_OK;
}
@@ -177,7 +186,7 @@ auto_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern LZMA_API(lzma_ret)
lzma_auto_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags)
{
- lzma_next_strm_init2(auto_decoder_init, strm, memlimit, flags);
+ lzma_next_strm_init(auto_decoder_init, strm, memlimit, flags);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff --git a/Utilities/cmliblzma/liblzma/common/block_buffer_decoder.c b/Utilities/cmliblzma/liblzma/common/block_buffer_decoder.c
index b4bd388eb..b0ded90dd 100644
--- a/Utilities/cmliblzma/liblzma/common/block_buffer_decoder.c
+++ b/Utilities/cmliblzma/liblzma/common/block_buffer_decoder.c
@@ -14,13 +14,10 @@
extern LZMA_API(lzma_ret)
-lzma_block_buffer_decode(lzma_block *block, lzma_allocator *allocator,
+lzma_block_buffer_decode(lzma_block *block, const lzma_allocator *allocator,
const uint8_t *in, size_t *in_pos, size_t in_size,
uint8_t *out, size_t *out_pos, size_t out_size)
{
- lzma_next_coder block_decoder;
- lzma_ret ret;
-
if (in_pos == NULL || (in == NULL && *in_pos != in_size)
|| *in_pos > in_size || out_pos == NULL
|| (out == NULL && *out_pos != out_size)
@@ -28,8 +25,9 @@ lzma_block_buffer_decode(lzma_block *block, lzma_allocator *allocator,
return LZMA_PROG_ERROR;
// Initialize the Block decoder.
- block_decoder = LZMA_NEXT_CODER_INIT;
- ret = lzma_block_decoder_init(&block_decoder, allocator, block);
+ lzma_next_coder block_decoder = LZMA_NEXT_CODER_INIT;
+ lzma_ret ret = lzma_block_decoder_init(
+ &block_decoder, allocator, block);
if (ret == LZMA_OK) {
// Save the positions so that we can restore them in case
diff --git a/Utilities/cmliblzma/liblzma/common/block_buffer_encoder.c b/Utilities/cmliblzma/liblzma/common/block_buffer_encoder.c
index 136f7f573..39e263aa4 100644
--- a/Utilities/cmliblzma/liblzma/common/block_buffer_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/block_buffer_encoder.c
@@ -10,6 +10,7 @@
//
///////////////////////////////////////////////////////////////////////////////
+#include "block_buffer_encoder.h"
#include "block_encoder.h"
#include "filter_encoder.h"
#include "lzma2_encoder.h"
@@ -28,11 +29,9 @@
+ LZMA_CHECK_SIZE_MAX + 3) & ~3)
-static lzma_vli
-lzma2_bound(lzma_vli uncompressed_size)
+static uint64_t
+lzma2_bound(uint64_t uncompressed_size)
{
- lzma_vli overhead;
-
// Prevent integer overflow in overhead calculation.
if (uncompressed_size > COMPRESSED_SIZE_MAX)
return 0;
@@ -41,7 +40,7 @@ lzma2_bound(lzma_vli uncompressed_size)
// uncompressed_size up to the next multiple of LZMA2_CHUNK_MAX,
// multiply by the size of per-chunk header, and add one byte for
// the end marker.
- overhead = ((uncompressed_size + LZMA2_CHUNK_MAX - 1)
+ const uint64_t overhead = ((uncompressed_size + LZMA2_CHUNK_MAX - 1)
/ LZMA2_CHUNK_MAX)
* LZMA2_HEADER_UNCOMPRESSED + 1;
@@ -53,30 +52,36 @@ lzma2_bound(lzma_vli uncompressed_size)
}
-extern LZMA_API(size_t)
-lzma_block_buffer_bound(size_t uncompressed_size)
+extern uint64_t
+lzma_block_buffer_bound64(uint64_t uncompressed_size)
{
- // For now, if the data doesn't compress, we always use uncompressed
- // chunks of LZMA2. In future we may use Subblock filter too, but
- // but for simplicity we probably will still use the same bound
- // calculation even though Subblock filter would have slightly less
- // overhead.
- lzma_vli lzma2_size = lzma2_bound(uncompressed_size);
+ // If the data doesn't compress, we always use uncompressed
+ // LZMA2 chunks.
+ uint64_t lzma2_size = lzma2_bound(uncompressed_size);
if (lzma2_size == 0)
return 0;
// Take Block Padding into account.
- lzma2_size = (lzma2_size + 3) & ~LZMA_VLI_C(3);
+ lzma2_size = (lzma2_size + 3) & ~UINT64_C(3);
-#if SIZE_MAX < LZMA_VLI_MAX
- // Catch the possible integer overflow on 32-bit systems. There's no
- // overflow on 64-bit systems, because lzma2_bound() already takes
+ // No risk of integer overflow because lzma2_bound() already takes
// into account the size of the headers in the Block.
- if (SIZE_MAX - HEADERS_BOUND < lzma2_size)
+ return HEADERS_BOUND + lzma2_size;
+}
+
+
+extern LZMA_API(size_t)
+lzma_block_buffer_bound(size_t uncompressed_size)
+{
+ uint64_t ret = lzma_block_buffer_bound64(uncompressed_size);
+
+#if SIZE_MAX < UINT64_MAX
+ // Catch the possible integer overflow on 32-bit systems.
+ if (ret > SIZE_MAX)
return 0;
#endif
- return HEADERS_BOUND + lzma2_size;
+ return ret;
}
@@ -84,17 +89,12 @@ static lzma_ret
block_encode_uncompressed(lzma_block *block, const uint8_t *in, size_t in_size,
uint8_t *out, size_t *out_pos, size_t out_size)
{
- size_t in_pos = 0;
- uint8_t control = 0x01; // Dictionary reset
- lzma_filter *filters_orig;
-
- // TODO: Figure out if the last filter is LZMA2 or Subblock and use
- // that filter to encode the uncompressed chunks.
-
// Use LZMA2 uncompressed chunks. We wouldn't need a dictionary at
// all, but LZMA2 always requires a dictionary, so use the minimum
// value to minimize memory usage of the decoder.
- lzma_options_lzma lzma2 = { LZMA_DICT_SIZE_MIN };
+ lzma_options_lzma lzma2 = {
+ .dict_size = LZMA_DICT_SIZE_MIN,
+ };
lzma_filter filters[2];
filters[0].id = LZMA_FILTER_LZMA2;
@@ -103,7 +103,7 @@ block_encode_uncompressed(lzma_block *block, const uint8_t *in, size_t in_size,
// Set the above filter options to *block temporarily so that we can
// encode the Block Header.
- filters_orig = block->filters;
+ lzma_filter *filters_orig = block->filters;
block->filters = filters;
if (lzma_block_header_size(block) != LZMA_OK) {
@@ -132,17 +132,18 @@ block_encode_uncompressed(lzma_block *block, const uint8_t *in, size_t in_size,
*out_pos += block->header_size;
// Encode the data using LZMA2 uncompressed chunks.
+ size_t in_pos = 0;
+ uint8_t control = 0x01; // Dictionary reset
while (in_pos < in_size) {
- size_t copy_size;
-
// Control byte: Indicate uncompressed chunk, of which
// the first resets the dictionary.
out[(*out_pos)++] = control;
control = 0x02; // No dictionary reset
// Size of the uncompressed chunk
- copy_size = my_min(in_size - in_pos, LZMA2_CHUNK_MAX);
+ const size_t copy_size
+ = my_min(in_size - in_pos, LZMA2_CHUNK_MAX);
out[(*out_pos)++] = (copy_size - 1) >> 8;
out[(*out_pos)++] = (copy_size - 1) & 0xFF;
@@ -163,27 +164,18 @@ block_encode_uncompressed(lzma_block *block, const uint8_t *in, size_t in_size,
static lzma_ret
-block_encode_normal(lzma_block *block, lzma_allocator *allocator,
+block_encode_normal(lzma_block *block, const lzma_allocator *allocator,
const uint8_t *in, size_t in_size,
uint8_t *out, size_t *out_pos, size_t out_size)
{
- size_t out_start;
- lzma_next_coder raw_encoder = LZMA_NEXT_CODER_INIT;
- lzma_ret ret;
-
// Find out the size of the Block Header.
- block->compressed_size = lzma2_bound(in_size);
- if (block->compressed_size == 0)
- return LZMA_DATA_ERROR;
-
- block->uncompressed_size = in_size;
return_if_error(lzma_block_header_size(block));
// Reserve space for the Block Header and skip it for now.
if (out_size - *out_pos <= block->header_size)
return LZMA_BUF_ERROR;
- out_start = *out_pos;
+ const size_t out_start = *out_pos;
*out_pos += block->header_size;
// Limit out_size so that we stop encoding if the output would grow
@@ -193,7 +185,8 @@ block_encode_normal(lzma_block *block, lzma_allocator *allocator,
// TODO: In many common cases this could be optimized to use
// significantly less memory.
- ret = lzma_raw_encoder_init(
+ lzma_next_coder raw_encoder = LZMA_NEXT_CODER_INIT;
+ lzma_ret ret = lzma_raw_encoder_init(
&raw_encoder, allocator, block->filters);
if (ret == LZMA_OK) {
@@ -227,15 +220,12 @@ block_encode_normal(lzma_block *block, lzma_allocator *allocator,
}
-extern LZMA_API(lzma_ret)
-lzma_block_buffer_encode(lzma_block *block, lzma_allocator *allocator,
+static lzma_ret
+block_buffer_encode(lzma_block *block, const lzma_allocator *allocator,
const uint8_t *in, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size)
+ uint8_t *out, size_t *out_pos, size_t out_size,
+ bool try_to_compress)
{
- size_t check_size;
- lzma_ret ret;
- size_t i;
-
// Validate the arguments.
if (block == NULL || (in == NULL && in_size != 0) || out == NULL
|| out_pos == NULL || *out_pos > out_size)
@@ -243,11 +233,11 @@ lzma_block_buffer_encode(lzma_block *block, lzma_allocator *allocator,
// The contents of the structure may depend on the version so
// check the version before validating the contents of *block.
- if (block->version != 0)
+ if (block->version > 1)
return LZMA_OPTIONS_ERROR;
if ((unsigned int)(block->check) > LZMA_CHECK_ID_MAX
- || block->filters == NULL)
+ || (try_to_compress && block->filters == NULL))
return LZMA_PROG_ERROR;
if (!lzma_check_is_supported(block->check))
@@ -259,7 +249,7 @@ lzma_block_buffer_encode(lzma_block *block, lzma_allocator *allocator,
out_size -= (out_size - *out_pos) & 3;
// Get the size of the Check field.
- check_size = lzma_check_size(block->check);
+ const size_t check_size = lzma_check_size(block->check);
assert(check_size != UINT32_MAX);
// Reserve space for the Check field.
@@ -268,9 +258,19 @@ lzma_block_buffer_encode(lzma_block *block, lzma_allocator *allocator,
out_size -= check_size;
+ // Initialize block->uncompressed_size and calculate the worst-case
+ // value for block->compressed_size.
+ block->uncompressed_size = in_size;
+ block->compressed_size = lzma2_bound(in_size);
+ if (block->compressed_size == 0)
+ return LZMA_DATA_ERROR;
+
// Do the actual compression.
- ret = block_encode_normal(block, allocator,
- in, in_size, out, out_pos, out_size);
+ lzma_ret ret = LZMA_BUF_ERROR;
+ if (try_to_compress)
+ ret = block_encode_normal(block, allocator,
+ in, in_size, out, out_pos, out_size);
+
if (ret != LZMA_OK) {
// If the error was something else than output buffer
// becoming full, return the error now.
@@ -291,7 +291,7 @@ lzma_block_buffer_encode(lzma_block *block, lzma_allocator *allocator,
// Block Padding. No buffer overflow here, because we already adjusted
// out_size so that (out_size - out_start) is a multiple of four.
// Thus, if the buffer is full, the loop body can never run.
- for (i = (size_t)(block->compressed_size); i & 3; ++i) {
+ for (size_t i = (size_t)(block->compressed_size); i & 3; ++i) {
assert(*out_pos < out_size);
out[(*out_pos)++] = 0x00;
}
@@ -313,3 +313,25 @@ lzma_block_buffer_encode(lzma_block *block, lzma_allocator *allocator,
return LZMA_OK;
}
+
+
+extern LZMA_API(lzma_ret)
+lzma_block_buffer_encode(lzma_block *block, const lzma_allocator *allocator,
+ const uint8_t *in, size_t in_size,
+ uint8_t *out, size_t *out_pos, size_t out_size)
+{
+ return block_buffer_encode(block, allocator,
+ in, in_size, out, out_pos, out_size, true);
+}
+
+
+extern LZMA_API(lzma_ret)
+lzma_block_uncomp_encode(lzma_block *block,
+ const uint8_t *in, size_t in_size,
+ uint8_t *out, size_t *out_pos, size_t out_size)
+{
+ // It won't allocate any memory from heap so no need
+ // for lzma_allocator.
+ return block_buffer_encode(block, NULL,
+ in, in_size, out, out_pos, out_size, false);
+}
diff --git a/Utilities/cmliblzma/liblzma/common/block_buffer_encoder.h b/Utilities/cmliblzma/liblzma/common/block_buffer_encoder.h
new file mode 100644
index 000000000..653207f73
--- /dev/null
+++ b/Utilities/cmliblzma/liblzma/common/block_buffer_encoder.h
@@ -0,0 +1,24 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+/// \file block_buffer_encoder.h
+/// \brief Single-call .xz Block encoder
+//
+// Author: Lasse Collin
+//
+// This file has been put into the public domain.
+// You can do whatever you want with this file.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef LZMA_BLOCK_BUFFER_ENCODER_H
+#define LZMA_BLOCK_BUFFER_ENCODER_H
+
+#include "common.h"
+
+
+/// uint64_t version of lzma_block_buffer_bound(). It is used by
+/// stream_encoder_mt.c. Probably the original lzma_block_buffer_bound()
+/// should have been 64-bit, but fixing it would break the ABI.
+extern uint64_t lzma_block_buffer_bound64(uint64_t uncompressed_size);
+
+#endif
diff --git a/Utilities/cmliblzma/liblzma/common/block_decoder.c b/Utilities/cmliblzma/liblzma/common/block_decoder.c
index 35996e7cf..075bd279f 100644
--- a/Utilities/cmliblzma/liblzma/common/block_decoder.c
+++ b/Utilities/cmliblzma/liblzma/common/block_decoder.c
@@ -15,7 +15,7 @@
#include "check.h"
-struct lzma_coder_s {
+typedef struct {
enum {
SEQ_CODE,
SEQ_PADDING,
@@ -45,7 +45,10 @@ struct lzma_coder_s {
/// Check of the uncompressed data
lzma_check_state check;
-};
+
+ /// True if the integrity check won't be calculated and verified.
+ bool ignore_check;
+} lzma_block_coder;
static inline bool
@@ -71,11 +74,13 @@ is_size_valid(lzma_vli size, lzma_vli reference)
static lzma_ret
-block_decode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size, lzma_action action)
+block_decode(void *coder_ptr, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size, lzma_action action)
{
+ lzma_block_coder *coder = coder_ptr;
+
switch (coder->sequence) {
case SEQ_CODE: {
const size_t in_start = *in_pos;
@@ -97,8 +102,9 @@ block_decode(lzma_coder *coder, lzma_allocator *allocator,
coder->block->uncompressed_size))
return LZMA_DATA_ERROR;
- lzma_check_update(&coder->check, coder->block->check,
- out + out_start, out_used);
+ if (!coder->ignore_check)
+ lzma_check_update(&coder->check, coder->block->check,
+ out + out_start, out_used);
if (ret != LZMA_STREAM_END)
return ret;
@@ -140,7 +146,9 @@ block_decode(lzma_coder *coder, lzma_allocator *allocator,
if (coder->block->check == LZMA_CHECK_NONE)
return LZMA_STREAM_END;
- lzma_check_finish(&coder->check, coder->block->check);
+ if (!coder->ignore_check)
+ lzma_check_finish(&coder->check, coder->block->check);
+
coder->sequence = SEQ_CHECK;
// Fall through
@@ -155,7 +163,8 @@ block_decode(lzma_coder *coder, lzma_allocator *allocator,
// Validate the Check only if we support it.
// coder->check.buffer may be uninitialized
// when the Check ID is not supported.
- if (lzma_check_is_supported(coder->block->check)
+ if (!coder->ignore_check
+ && lzma_check_is_supported(coder->block->check)
&& memcmp(coder->block->raw_check,
coder->check.buffer.u8,
check_size) != 0)
@@ -170,8 +179,9 @@ block_decode(lzma_coder *coder, lzma_allocator *allocator,
static void
-block_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
+block_decoder_end(void *coder_ptr, const lzma_allocator *allocator)
{
+ lzma_block_coder *coder = coder_ptr;
lzma_next_end(&coder->next, allocator);
lzma_free(coder, allocator);
return;
@@ -179,7 +189,7 @@ block_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
extern lzma_ret
-lzma_block_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_block_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
lzma_block *block)
{
lzma_next_coder_init(&lzma_block_decoder_init, next, allocator);
@@ -191,27 +201,29 @@ lzma_block_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
|| !lzma_vli_is_valid(block->uncompressed_size))
return LZMA_PROG_ERROR;
- // Allocate and initialize *next->coder if needed.
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
+ // Allocate *next->coder if needed.
+ lzma_block_coder *coder = next->coder;
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_block_coder), allocator);
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ next->coder = coder;
next->code = &block_decode;
next->end = &block_decoder_end;
- next->coder->next = LZMA_NEXT_CODER_INIT;
+ coder->next = LZMA_NEXT_CODER_INIT;
}
// Basic initializations
- next->coder->sequence = SEQ_CODE;
- next->coder->block = block;
- next->coder->compressed_size = 0;
- next->coder->uncompressed_size = 0;
+ coder->sequence = SEQ_CODE;
+ coder->block = block;
+ coder->compressed_size = 0;
+ coder->uncompressed_size = 0;
// If Compressed Size is not known, we calculate the maximum allowed
// value so that encoded size of the Block (including Block Padding)
// is still a valid VLI and a multiple of four.
- next->coder->compressed_limit
+ coder->compressed_limit
= block->compressed_size == LZMA_VLI_UNKNOWN
? (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
- block->header_size
@@ -221,11 +233,14 @@ lzma_block_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
// Initialize the check. It's caller's problem if the Check ID is not
// supported, and the Block decoder cannot verify the Check field.
// Caller can test lzma_check_is_supported(block->check).
- next->coder->check_pos = 0;
- lzma_check_init(&next->coder->check, block->check);
+ coder->check_pos = 0;
+ lzma_check_init(&coder->check, block->check);
+
+ coder->ignore_check = block->version >= 1
+ ? block->ignore_check : false;
// Initialize the filter chain.
- return lzma_raw_decoder_init(&next->coder->next, allocator,
+ return lzma_raw_decoder_init(&coder->next, allocator,
block->filters);
}
@@ -233,7 +248,7 @@ lzma_block_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern LZMA_API(lzma_ret)
lzma_block_decoder(lzma_stream *strm, lzma_block *block)
{
- lzma_next_strm_init1(lzma_block_decoder_init, strm, block);
+ lzma_next_strm_init(lzma_block_decoder_init, strm, block);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff --git a/Utilities/cmliblzma/liblzma/common/block_decoder.h b/Utilities/cmliblzma/liblzma/common/block_decoder.h
index 7da9df63f..718c5ced8 100644
--- a/Utilities/cmliblzma/liblzma/common/block_decoder.h
+++ b/Utilities/cmliblzma/liblzma/common/block_decoder.h
@@ -17,6 +17,6 @@
extern lzma_ret lzma_block_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, lzma_block *block);
+ const lzma_allocator *allocator, lzma_block *block);
#endif
diff --git a/Utilities/cmliblzma/liblzma/common/block_encoder.c b/Utilities/cmliblzma/liblzma/common/block_encoder.c
index ed748273e..168846ad6 100644
--- a/Utilities/cmliblzma/liblzma/common/block_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/block_encoder.c
@@ -15,7 +15,7 @@
#include "check.h"
-struct lzma_coder_s {
+typedef struct {
/// The filters in the chain; initialized with lzma_raw_decoder_init().
lzma_next_coder next;
@@ -41,15 +41,17 @@ struct lzma_coder_s {
/// Check of the uncompressed data
lzma_check_state check;
-};
+} lzma_block_coder;
static lzma_ret
-block_encode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size, lzma_action action)
+block_encode(void *coder_ptr, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size, lzma_action action)
{
+ lzma_block_coder *coder = coder_ptr;
+
// Check that our amount of input stays in proper limits.
if (LZMA_VLI_MAX - coder->uncompressed_size < in_size - *in_pos)
return LZMA_DATA_ERROR;
@@ -134,8 +136,9 @@ block_encode(lzma_coder *coder, lzma_allocator *allocator,
static void
-block_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
+block_encoder_end(void *coder_ptr, const lzma_allocator *allocator)
{
+ lzma_block_coder *coder = coder_ptr;
lzma_next_end(&coder->next, allocator);
lzma_free(coder, allocator);
return;
@@ -143,10 +146,12 @@ block_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
-block_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
+block_encoder_update(void *coder_ptr, const lzma_allocator *allocator,
const lzma_filter *filters lzma_attribute((__unused__)),
const lzma_filter *reversed_filters)
{
+ lzma_block_coder *coder = coder_ptr;
+
if (coder->sequence != SEQ_CODE)
return LZMA_PROG_ERROR;
@@ -156,7 +161,7 @@ block_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
extern lzma_ret
-lzma_block_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_block_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
lzma_block *block)
{
lzma_next_coder_init(&lzma_block_encoder_init, next, allocator);
@@ -166,7 +171,7 @@ lzma_block_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
// The contents of the structure may depend on the version so
// check the version first.
- if (block->version != 0)
+ if (block->version > 1)
return LZMA_OPTIONS_ERROR;
// If the Check ID is not supported, we cannot calculate the check and
@@ -178,37 +183,38 @@ lzma_block_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
return LZMA_UNSUPPORTED_CHECK;
// Allocate and initialize *next->coder if needed.
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
+ lzma_block_coder *coder = next->coder;
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_block_coder), allocator);
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ next->coder = coder;
next->code = &block_encode;
next->end = &block_encoder_end;
next->update = &block_encoder_update;
- next->coder->next = LZMA_NEXT_CODER_INIT;
+ coder->next = LZMA_NEXT_CODER_INIT;
}
// Basic initializations
- next->coder->sequence = SEQ_CODE;
- next->coder->block = block;
- next->coder->compressed_size = 0;
- next->coder->uncompressed_size = 0;
- next->coder->pos = 0;
+ coder->sequence = SEQ_CODE;
+ coder->block = block;
+ coder->compressed_size = 0;
+ coder->uncompressed_size = 0;
+ coder->pos = 0;
// Initialize the check
- lzma_check_init(&next->coder->check, block->check);
+ lzma_check_init(&coder->check, block->check);
// Initialize the requested filters.
- return lzma_raw_encoder_init(&next->coder->next, allocator,
- block->filters);
+ return lzma_raw_encoder_init(&coder->next, allocator, block->filters);
}
extern LZMA_API(lzma_ret)
lzma_block_encoder(lzma_stream *strm, lzma_block *block)
{
- lzma_next_strm_init1(lzma_block_encoder_init, strm, block);
+ lzma_next_strm_init(lzma_block_encoder_init, strm, block);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff --git a/Utilities/cmliblzma/liblzma/common/block_encoder.h b/Utilities/cmliblzma/liblzma/common/block_encoder.h
index b9eff0be2..bd97c186e 100644
--- a/Utilities/cmliblzma/liblzma/common/block_encoder.h
+++ b/Utilities/cmliblzma/liblzma/common/block_encoder.h
@@ -42,6 +42,6 @@
extern lzma_ret lzma_block_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, lzma_block *block);
+ const lzma_allocator *allocator, lzma_block *block);
#endif
diff --git a/Utilities/cmliblzma/liblzma/common/block_header_decoder.c b/Utilities/cmliblzma/liblzma/common/block_header_decoder.c
index f6e470e69..1dd982f6b 100644
--- a/Utilities/cmliblzma/liblzma/common/block_header_decoder.c
+++ b/Utilities/cmliblzma/liblzma/common/block_header_decoder.c
@@ -15,14 +15,12 @@
static void
-free_properties(lzma_block *block, lzma_allocator *allocator)
+free_properties(lzma_block *block, const lzma_allocator *allocator)
{
- size_t i;
-
// Free allocated filter options. The last array member is not
// touched after the initialization in the beginning of
// lzma_block_header_decode(), so we don't need to touch that here.
- for (i = 0; i < LZMA_FILTERS_MAX; ++i) {
+ for (size_t i = 0; i < LZMA_FILTERS_MAX; ++i) {
lzma_free(block->filters[i].options, allocator);
block->filters[i].id = LZMA_VLI_UNKNOWN;
block->filters[i].options = NULL;
@@ -34,15 +32,8 @@ free_properties(lzma_block *block, lzma_allocator *allocator)
extern LZMA_API(lzma_ret)
lzma_block_header_decode(lzma_block *block,
- lzma_allocator *allocator, const uint8_t *in)
+ const lzma_allocator *allocator, const uint8_t *in)
{
- const size_t filter_count = (in[1] & 3) + 1;
- size_t in_size;
- size_t i;
-
- // Start after the Block Header Size and Block Flags fields.
- size_t in_pos = 2;
-
// NOTE: We consider the header to be corrupt not only when the
// CRC32 doesn't match, but also when variable-length integers
// are invalid or over 63 bits, or if the header is too small
@@ -50,13 +41,21 @@ lzma_block_header_decode(lzma_block *block,
// Initialize the filter options array. This way the caller can
// safely free() the options even if an error occurs in this function.
- for (i = 0; i <= LZMA_FILTERS_MAX; ++i) {
+ for (size_t i = 0; i <= LZMA_FILTERS_MAX; ++i) {
block->filters[i].id = LZMA_VLI_UNKNOWN;
block->filters[i].options = NULL;
}
- // Always zero for now.
- block->version = 0;
+ // Versions 0 and 1 are supported. If a newer version was specified,
+ // we need to downgrade it.
+ if (block->version > 1)
+ block->version = 1;
+
+ // This isn't a Block Header option, but since the decompressor will
+ // read it if version >= 1, it's better to initialize it here than
+ // to expect the caller to do it since in almost all cases this
+ // should be false.
+ block->ignore_check = false;
// Validate Block Header Size and Check type. The caller must have
// already set these, so it is a programming error if this test fails.
@@ -65,7 +64,7 @@ lzma_block_header_decode(lzma_block *block,
return LZMA_PROG_ERROR;
// Exclude the CRC32 field.
- in_size = block->header_size - 4;
+ const size_t in_size = block->header_size - 4;
// Verify CRC32
if (lzma_crc32(in, in_size, 0) != unaligned_read32le(in + in_size))
@@ -75,6 +74,9 @@ lzma_block_header_decode(lzma_block *block,
if (in[1] & 0x3C)
return LZMA_OPTIONS_ERROR;
+ // Start after the Block Header Size and Block Flags fields.
+ size_t in_pos = 2;
+
// Compressed Size
if (in[1] & 0x40) {
return_if_error(lzma_vli_decode(&block->compressed_size,
@@ -96,7 +98,8 @@ lzma_block_header_decode(lzma_block *block,
block->uncompressed_size = LZMA_VLI_UNKNOWN;
// Filter Flags
- for (i = 0; i < filter_count; ++i) {
+ const size_t filter_count = (in[1] & 3) + 1;
+ for (size_t i = 0; i < filter_count; ++i) {
const lzma_ret ret = lzma_filter_flags_decode(
&block->filters[i], allocator,
in, &in_pos, in_size);
diff --git a/Utilities/cmliblzma/liblzma/common/block_header_encoder.c b/Utilities/cmliblzma/liblzma/common/block_header_encoder.c
index 650295c00..5c5f5424a 100644
--- a/Utilities/cmliblzma/liblzma/common/block_header_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/block_header_encoder.c
@@ -17,14 +17,12 @@
extern LZMA_API(lzma_ret)
lzma_block_header_size(lzma_block *block)
{
- size_t i;
+ if (block->version > 1)
+ return LZMA_OPTIONS_ERROR;
// Block Header Size + Block Flags + CRC32.
uint32_t size = 1 + 1 + 4;
- if (block->version != 0)
- return LZMA_OPTIONS_ERROR;
-
// Compressed Size
if (block->compressed_size != LZMA_VLI_UNKNOWN) {
const uint32_t add = lzma_vli_size(block->compressed_size);
@@ -47,13 +45,12 @@ lzma_block_header_size(lzma_block *block)
if (block->filters == NULL || block->filters[0].id == LZMA_VLI_UNKNOWN)
return LZMA_PROG_ERROR;
- for (i = 0; block->filters[i].id != LZMA_VLI_UNKNOWN; ++i) {
- uint32_t add;
-
+ for (size_t i = 0; block->filters[i].id != LZMA_VLI_UNKNOWN; ++i) {
// Don't allow too many filters.
if (i == LZMA_FILTERS_MAX)
return LZMA_PROG_ERROR;
+ uint32_t add;
return_if_error(lzma_filter_flags_size(&add,
block->filters + i));
@@ -76,23 +73,20 @@ lzma_block_header_size(lzma_block *block)
extern LZMA_API(lzma_ret)
lzma_block_header_encode(const lzma_block *block, uint8_t *out)
{
- size_t out_size;
- size_t out_pos = 2;
- size_t filter_count = 0;
-
// Validate everything but filters.
if (lzma_block_unpadded_size(block) == 0
|| !lzma_vli_is_valid(block->uncompressed_size))
return LZMA_PROG_ERROR;
// Indicate the size of the buffer _excluding_ the CRC32 field.
- out_size = block->header_size - 4;
+ const size_t out_size = block->header_size - 4;
// Store the Block Header Size.
out[0] = out_size / 4;
// We write Block Flags in pieces.
out[1] = 0x00;
+ size_t out_pos = 2;
// Compressed Size
if (block->compressed_size != LZMA_VLI_UNKNOWN) {
@@ -114,6 +108,7 @@ lzma_block_header_encode(const lzma_block *block, uint8_t *out)
if (block->filters == NULL || block->filters[0].id == LZMA_VLI_UNKNOWN)
return LZMA_PROG_ERROR;
+ size_t filter_count = 0;
do {
// There can be a maximum of four filters.
if (filter_count == LZMA_FILTERS_MAX)
diff --git a/Utilities/cmliblzma/liblzma/common/block_util.c b/Utilities/cmliblzma/liblzma/common/block_util.c
index 4cd34d100..00c7fe8d5 100644
--- a/Utilities/cmliblzma/liblzma/common/block_util.c
+++ b/Utilities/cmliblzma/liblzma/common/block_util.c
@@ -17,14 +17,11 @@
extern LZMA_API(lzma_ret)
lzma_block_compressed_size(lzma_block *block, lzma_vli unpadded_size)
{
- uint32_t container_size;
- lzma_vli compressed_size;
-
// Validate everything but Uncompressed Size and filters.
if (lzma_block_unpadded_size(block) == 0)
return LZMA_PROG_ERROR;
- container_size = block->header_size
+ const uint32_t container_size = block->header_size
+ lzma_check_size(block->check);
// Validate that Compressed Size will be greater than zero.
@@ -34,7 +31,7 @@ lzma_block_compressed_size(lzma_block *block, lzma_vli unpadded_size)
// Calculate what Compressed Size is supposed to be.
// If Compressed Size was present in Block Header,
// compare that the new value matches it.
- compressed_size = unpadded_size - container_size;
+ const lzma_vli compressed_size = unpadded_size - container_size;
if (block->compressed_size != LZMA_VLI_UNKNOWN
&& block->compressed_size != compressed_size)
return LZMA_DATA_ERROR;
@@ -48,15 +45,13 @@ lzma_block_compressed_size(lzma_block *block, lzma_vli unpadded_size)
extern LZMA_API(lzma_vli)
lzma_block_unpadded_size(const lzma_block *block)
{
- lzma_vli unpadded_size;
-
// Validate the values that we are interested in i.e. all but
// Uncompressed Size and the filters.
//
// NOTE: This function is used for validation too, so it is
// essential that these checks are always done even if
// Compressed Size is unknown.
- if (block == NULL || block->version != 0
+ if (block == NULL || block->version > 1
|| block->header_size < LZMA_BLOCK_HEADER_SIZE_MIN
|| block->header_size > LZMA_BLOCK_HEADER_SIZE_MAX
|| (block->header_size & 3)
@@ -71,7 +66,7 @@ lzma_block_unpadded_size(const lzma_block *block)
return LZMA_VLI_UNKNOWN;
// Calculate Unpadded Size and validate it.
- unpadded_size = block->compressed_size
+ const lzma_vli unpadded_size = block->compressed_size
+ block->header_size
+ lzma_check_size(block->check);
diff --git a/Utilities/cmliblzma/liblzma/common/common.c b/Utilities/cmliblzma/liblzma/common/common.c
index 2e723c8fe..57e3f8ebd 100644
--- a/Utilities/cmliblzma/liblzma/common/common.c
+++ b/Utilities/cmliblzma/liblzma/common/common.c
@@ -36,14 +36,14 @@ lzma_version_string(void)
///////////////////////
extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
-lzma_alloc(size_t size, lzma_allocator *allocator)
+lzma_alloc(size_t size, const lzma_allocator *allocator)
{
- void *ptr;
-
// Some malloc() variants return NULL if called with size == 0.
if (size == 0)
size = 1;
+ void *ptr;
+
if (allocator != NULL && allocator->alloc != NULL)
ptr = allocator->alloc(allocator->opaque, 1, size);
else
@@ -53,8 +53,29 @@ lzma_alloc(size_t size, lzma_allocator *allocator)
}
+extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
+lzma_alloc_zero(size_t size, const lzma_allocator *allocator)
+{
+ // Some calloc() variants return NULL if called with size == 0.
+ if (size == 0)
+ size = 1;
+
+ void *ptr;
+
+ if (allocator != NULL && allocator->alloc != NULL) {
+ ptr = allocator->alloc(allocator->opaque, 1, size);
+ if (ptr != NULL)
+ memzero(ptr, size);
+ } else {
+ ptr = calloc(1, size);
+ }
+
+ return ptr;
+}
+
+
extern void
-lzma_free(void *ptr, lzma_allocator *allocator)
+lzma_free(void *ptr, const lzma_allocator *allocator)
{
if (allocator != NULL && allocator->free != NULL)
allocator->free(allocator->opaque, ptr);
@@ -70,9 +91,9 @@ lzma_free(void *ptr, lzma_allocator *allocator)
//////////
extern size_t
-lzma_bufcpy(const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size)
+lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size)
{
const size_t in_avail = in_size - *in_pos;
const size_t out_avail = out_size - *out_pos;
@@ -88,7 +109,7 @@ lzma_bufcpy(const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
extern lzma_ret
-lzma_next_filter_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_next_filter_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters)
{
lzma_next_coder_init(filters[0].init, next, allocator);
@@ -99,7 +120,7 @@ lzma_next_filter_init(lzma_next_coder *next, lzma_allocator *allocator,
extern lzma_ret
-lzma_next_filter_update(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_next_filter_update(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter *reversed_filters)
{
// Check that the application isn't trying to change the Filter ID.
@@ -117,7 +138,7 @@ lzma_next_filter_update(lzma_next_coder *next, lzma_allocator *allocator,
extern void
-lzma_next_end(lzma_next_coder *next, lzma_allocator *allocator)
+lzma_next_end(lzma_next_coder *next, const lzma_allocator *allocator)
{
if (next->init != (uintptr_t)(NULL)) {
// To avoid tiny end functions that simply call
@@ -156,10 +177,8 @@ lzma_strm_init(lzma_stream *strm)
strm->internal->next = LZMA_NEXT_CODER_INIT;
}
- strm->internal->supported_actions[LZMA_RUN] = false;
- strm->internal->supported_actions[LZMA_SYNC_FLUSH] = false;
- strm->internal->supported_actions[LZMA_FULL_FLUSH] = false;
- strm->internal->supported_actions[LZMA_FINISH] = false;
+ memzero(strm->internal->supported_actions,
+ sizeof(strm->internal->supported_actions));
strm->internal->sequence = ISEQ_RUN;
strm->internal->allow_buf_error = false;
@@ -173,16 +192,12 @@ lzma_strm_init(lzma_stream *strm)
extern LZMA_API(lzma_ret)
lzma_code(lzma_stream *strm, lzma_action action)
{
- size_t in_pos = 0;
- size_t out_pos = 0;
- lzma_ret ret;
-
// Sanity checks
if ((strm->next_in == NULL && strm->avail_in != 0)
|| (strm->next_out == NULL && strm->avail_out != 0)
|| strm->internal == NULL
|| strm->internal->next.code == NULL
- || (unsigned int)(action) > LZMA_FINISH
+ || (unsigned int)(action) > LZMA_ACTION_MAX
|| !strm->internal->supported_actions[action])
return LZMA_PROG_ERROR;
@@ -217,6 +232,10 @@ lzma_code(lzma_stream *strm, lzma_action action)
case LZMA_FINISH:
strm->internal->sequence = ISEQ_FINISH;
break;
+
+ case LZMA_FULL_BARRIER:
+ strm->internal->sequence = ISEQ_FULL_BARRIER;
+ break;
}
break;
@@ -244,6 +263,13 @@ lzma_code(lzma_stream *strm, lzma_action action)
break;
+ case ISEQ_FULL_BARRIER:
+ if (action != LZMA_FULL_BARRIER
+ || strm->internal->avail_in != strm->avail_in)
+ return LZMA_PROG_ERROR;
+
+ break;
+
case ISEQ_END:
return LZMA_STREAM_END;
@@ -252,7 +278,9 @@ lzma_code(lzma_stream *strm, lzma_action action)
return LZMA_PROG_ERROR;
}
- ret = strm->internal->next.code(
+ size_t in_pos = 0;
+ size_t out_pos = 0;
+ lzma_ret ret = strm->internal->next.code(
strm->internal->next.coder, strm->allocator,
strm->next_in, &in_pos, strm->avail_in,
strm->next_out, &out_pos, strm->avail_out, action);
@@ -267,7 +295,9 @@ lzma_code(lzma_stream *strm, lzma_action action)
strm->internal->avail_in = strm->avail_in;
- switch (ret) {
+ // Cast is needed to silence a warning about LZMA_TIMED_OUT, which
+ // isn't part of lzma_ret enumeration.
+ switch ((unsigned int)(ret)) {
case LZMA_OK:
// Don't return LZMA_BUF_ERROR when it happens the first time.
// This is to avoid returning LZMA_BUF_ERROR when avail_out
@@ -283,9 +313,16 @@ lzma_code(lzma_stream *strm, lzma_action action)
}
break;
+ case LZMA_TIMED_OUT:
+ strm->internal->allow_buf_error = false;
+ ret = LZMA_OK;
+ break;
+
case LZMA_STREAM_END:
if (strm->internal->sequence == ISEQ_SYNC_FLUSH
- || strm->internal->sequence == ISEQ_FULL_FLUSH)
+ || strm->internal->sequence == ISEQ_FULL_FLUSH
+ || strm->internal->sequence
+ == ISEQ_FULL_BARRIER)
strm->internal->sequence = ISEQ_RUN;
else
strm->internal->sequence = ISEQ_END;
@@ -325,6 +362,22 @@ lzma_end(lzma_stream *strm)
}
+extern LZMA_API(void)
+lzma_get_progress(lzma_stream *strm,
+ uint64_t *progress_in, uint64_t *progress_out)
+{
+ if (strm->internal->next.get_progress != NULL) {
+ strm->internal->next.get_progress(strm->internal->next.coder,
+ progress_in, progress_out);
+ } else {
+ *progress_in = strm->total_in;
+ *progress_out = strm->total_out;
+ }
+
+ return;
+}
+
+
extern LZMA_API(lzma_check)
lzma_get_check(const lzma_stream *strm)
{
@@ -382,8 +435,10 @@ lzma_memlimit_set(lzma_stream *strm, uint64_t new_memlimit)
|| strm->internal->next.memconfig == NULL)
return LZMA_PROG_ERROR;
- if (new_memlimit != 0 && new_memlimit < LZMA_MEMUSAGE_BASE)
- return LZMA_MEMLIMIT_ERROR;
+ // Zero is a special value that cannot be used as an actual limit.
+ // If 0 was specified, use 1 instead.
+ if (new_memlimit == 0)
+ new_memlimit = 1;
return strm->internal->next.memconfig(strm->internal->next.coder,
&memusage, &old_memlimit, new_memlimit);
diff --git a/Utilities/cmliblzma/liblzma/common/common.h b/Utilities/cmliblzma/liblzma/common/common.h
index a6a28189e..dde3ae0ec 100644
--- a/Utilities/cmliblzma/liblzma/common/common.h
+++ b/Utilities/cmliblzma/liblzma/common/common.h
@@ -48,6 +48,13 @@
#define LZMA_BUFFER_SIZE 4096
+/// Maximum number of worker threads within one multithreaded component.
+/// The limit exists solely to make it simpler to prevent integer overflows
+/// when allocating structures etc. This should be big enough for now...
+/// the code won't scale anywhere close to this number anyway.
+#define LZMA_THREADS_MAX 16384
+
+
/// Starting value for memory usage estimates. Instead of calculating size
/// of _every_ structure and taking into account malloc() overhead etc., we
/// add a base size to all memory usage estimates. It's not very accurate
@@ -65,12 +72,20 @@
( LZMA_TELL_NO_CHECK \
| LZMA_TELL_UNSUPPORTED_CHECK \
| LZMA_TELL_ANY_CHECK \
+ | LZMA_IGNORE_CHECK \
| LZMA_CONCATENATED )
-/// Type of encoder/decoder specific data; the actual structure is defined
-/// differently in different coders.
-typedef struct lzma_coder_s lzma_coder;
+/// Largest valid lzma_action value as unsigned integer.
+#define LZMA_ACTION_MAX ((unsigned int)(LZMA_FULL_BARRIER))
+
+
+/// Special return value (lzma_ret) to indicate that a timeout was reached
+/// and lzma_code() must not return LZMA_BUF_ERROR. This is converted to
+/// LZMA_OK in lzma_code(). This is not in the lzma_ret enumeration because
+/// there's no need to have it in the public API.
+#define LZMA_TIMED_OUT 32
+
typedef struct lzma_next_coder_s lzma_next_coder;
@@ -79,7 +94,7 @@ typedef struct lzma_filter_info_s lzma_filter_info;
/// Type of a function used to initialize a filter encoder or decoder
typedef lzma_ret (*lzma_init_function)(
- lzma_next_coder *next, lzma_allocator *allocator,
+ lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters);
/// Type of a function to do some kind of coding work (filters, Stream,
@@ -87,15 +102,15 @@ typedef lzma_ret (*lzma_init_function)(
/// input and output buffers, but for simplicity they still use this same
/// function prototype.
typedef lzma_ret (*lzma_code_function)(
- lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size,
+ void *coder, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size,
lzma_action action);
/// Type of a function to free the memory allocated for the coder
typedef void (*lzma_end_function)(
- lzma_coder *coder, lzma_allocator *allocator);
+ void *coder, const lzma_allocator *allocator);
/// Raw coder validates and converts an array of lzma_filter structures to
@@ -118,7 +133,7 @@ struct lzma_filter_info_s {
/// Hold data and function pointers of the next filter in the chain.
struct lzma_next_coder_s {
/// Pointer to coder-specific data
- lzma_coder *coder;
+ void *coder;
/// Filter ID. This is LZMA_VLI_UNKNOWN when this structure doesn't
/// point to a filter coder.
@@ -138,35 +153,41 @@ struct lzma_next_coder_s {
/// lzma_next_coder.coder.
lzma_end_function end;
+ /// Pointer to a function to get progress information. If this is NULL,
+ /// lzma_stream.total_in and .total_out are used instead.
+ void (*get_progress)(void *coder,
+ uint64_t *progress_in, uint64_t *progress_out);
+
/// Pointer to function to return the type of the integrity check.
/// Most coders won't support this.
- lzma_check (*get_check)(const lzma_coder *coder);
+ lzma_check (*get_check)(const void *coder);
/// Pointer to function to get and/or change the memory usage limit.
/// If new_memlimit == 0, the limit is not changed.
- lzma_ret (*memconfig)(lzma_coder *coder, uint64_t *memusage,
+ lzma_ret (*memconfig)(void *coder, uint64_t *memusage,
uint64_t *old_memlimit, uint64_t new_memlimit);
/// Update the filter-specific options or the whole filter chain
/// in the encoder.
- lzma_ret (*update)(lzma_coder *coder, lzma_allocator *allocator,
+ lzma_ret (*update)(void *coder, const lzma_allocator *allocator,
const lzma_filter *filters,
const lzma_filter *reversed_filters);
};
-/// Constant to initialize lzma_next_coder structure
-static const lzma_next_coder LZMA_NEXT_CODER_INIT =
- {
- NULL,
- LZMA_VLI_UNKNOWN,
- (uintptr_t)(NULL),
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- };
+/// Macro to initialize lzma_next_coder structure
+#define LZMA_NEXT_CODER_INIT \
+ (lzma_next_coder){ \
+ .coder = NULL, \
+ .init = (uintptr_t)(NULL), \
+ .id = LZMA_VLI_UNKNOWN, \
+ .code = NULL, \
+ .end = NULL, \
+ .get_progress = NULL, \
+ .get_check = NULL, \
+ .memconfig = NULL, \
+ .update = NULL, \
+ }
/// Internal data for lzma_strm_init, lzma_code, and lzma_end. A pointer to
@@ -184,6 +205,7 @@ struct lzma_internal_s {
ISEQ_SYNC_FLUSH,
ISEQ_FULL_FLUSH,
ISEQ_FINISH,
+ ISEQ_FULL_BARRIER,
ISEQ_END,
ISEQ_ERROR,
} sequence;
@@ -194,7 +216,7 @@ struct lzma_internal_s {
size_t avail_in;
/// Indicates which lzma_action values are allowed by next.code.
- bool supported_actions[4];
+ bool supported_actions[LZMA_ACTION_MAX + 1];
/// If true, lzma_code will return LZMA_BUF_ERROR if no progress was
/// made (no input consumed and no output produced by next.code).
@@ -203,15 +225,21 @@ struct lzma_internal_s {
/// Allocates memory
-extern void *lzma_alloc(size_t size, lzma_allocator *allocator)
+extern void *lzma_alloc(size_t size, const lzma_allocator *allocator)
lzma_attribute((__malloc__)) lzma_attr_alloc_size(1);
+/// Allocates memory and zeroes it (like calloc()). This can be faster
+/// than lzma_alloc() + memzero() while being backward compatible with
+/// custom allocators.
+extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
+ lzma_alloc_zero(size_t size, const lzma_allocator *allocator);
+
/// Frees memory
-extern void lzma_free(void *ptr, lzma_allocator *allocator);
+extern void lzma_free(void *ptr, const lzma_allocator *allocator);
/// Allocates strm->internal if it is NULL, and initializes *strm and
-/// strm->internal. This function is only called via lzma_next_strm_init2 macro.
+/// strm->internal. This function is only called via lzma_next_strm_init macro.
extern lzma_ret lzma_strm_init(lzma_stream *strm);
/// Initializes the next filter in the chain, if any. This takes care of
@@ -219,24 +247,26 @@ extern lzma_ret lzma_strm_init(lzma_stream *strm);
/// than the filter being initialized now. This way the actual filter
/// initialization functions don't need to use lzma_next_coder_init macro.
extern lzma_ret lzma_next_filter_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
/// Update the next filter in the chain, if any. This checks that
/// the application is not trying to change the Filter IDs.
extern lzma_ret lzma_next_filter_update(
- lzma_next_coder *next, lzma_allocator *allocator,
+ lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter *reversed_filters);
/// Frees the memory allocated for next->coder either using next->end or,
/// if next->end is NULL, using lzma_free.
-extern void lzma_next_end(lzma_next_coder *next, lzma_allocator *allocator);
+extern void lzma_next_end(lzma_next_coder *next,
+ const lzma_allocator *allocator);
/// Copy as much data as possible from in[] to out[] and update *in_pos
/// and *out_pos accordingly. Returns the number of bytes copied.
-extern size_t lzma_bufcpy(const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size);
+extern size_t lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size);
/// \brief Return if expression doesn't evaluate to LZMA_OK
@@ -269,37 +299,15 @@ do { \
/// (The function being called will use lzma_next_coder_init()). If
/// initialization fails, memory that wasn't freed by func() is freed
/// along strm->internal.
-#define lzma_next_strm_init1(func, strm, arg1) \
+#define lzma_next_strm_init(func, strm, ...) \
do { \
- lzma_ret ret_; \
- return_if_error(lzma_strm_init(strm)); \
- ret_ = func(&(strm)->internal->next, (strm)->allocator, arg1); \
- if (ret_ != LZMA_OK) { \
- lzma_end(strm); \
- return ret_; \
- } \
-} while (0)
-
-#define lzma_next_strm_init2(func, strm, arg1, arg2) \
-do { \
- lzma_ret ret_; \
- return_if_error(lzma_strm_init(strm)); \
- ret_ = func(&(strm)->internal->next, (strm)->allocator, arg1, arg2); \
- if (ret_ != LZMA_OK) { \
- lzma_end(strm); \
- return ret_; \
- } \
-} while (0)
-
-#define lzma_next_strm_init3(func, strm, arg1, arg2, arg3) \
-do { \
- lzma_ret ret_; \
- return_if_error(lzma_strm_init(strm)); \
- ret_ = func(&(strm)->internal->next, (strm)->allocator, arg1, arg2, arg3); \
- if (ret_ != LZMA_OK) { \
- lzma_end(strm); \
- return ret_; \
- } \
+ return_if_error(lzma_strm_init(strm)); \
+ const lzma_ret ret_ = func(&(strm)->internal->next, \
+ (strm)->allocator, __VA_ARGS__); \
+ if (ret_ != LZMA_OK) { \
+ lzma_end(strm); \
+ return ret_; \
+ } \
} while (0)
#endif
diff --git a/Utilities/cmliblzma/liblzma/common/easy_buffer_encoder.c b/Utilities/cmliblzma/liblzma/common/easy_buffer_encoder.c
index c4be34ccf..48eb56f5c 100644
--- a/Utilities/cmliblzma/liblzma/common/easy_buffer_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/easy_buffer_encoder.c
@@ -15,8 +15,8 @@
extern LZMA_API(lzma_ret)
lzma_easy_buffer_encode(uint32_t preset, lzma_check check,
- lzma_allocator *allocator, const uint8_t *in, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size)
+ const lzma_allocator *allocator, const uint8_t *in,
+ size_t in_size, uint8_t *out, size_t *out_pos, size_t out_size)
{
lzma_options_easy opt_easy;
if (lzma_easy_preset(&opt_easy, preset))
diff --git a/Utilities/cmliblzma/liblzma/common/easy_encoder.c b/Utilities/cmliblzma/liblzma/common/easy_encoder.c
index d13ccd735..5cb492dd0 100644
--- a/Utilities/cmliblzma/liblzma/common/easy_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/easy_encoder.c
@@ -11,7 +11,6 @@
///////////////////////////////////////////////////////////////////////////////
#include "easy_preset.h"
-#include "stream_encoder.h"
extern LZMA_API(lzma_ret)
diff --git a/Utilities/cmliblzma/liblzma/common/filter_buffer_decoder.c b/Utilities/cmliblzma/liblzma/common/filter_buffer_decoder.c
index 65665c17d..6620986ee 100644
--- a/Utilities/cmliblzma/liblzma/common/filter_buffer_decoder.c
+++ b/Utilities/cmliblzma/liblzma/common/filter_buffer_decoder.c
@@ -14,30 +14,27 @@
extern LZMA_API(lzma_ret)
-lzma_raw_buffer_decode(const lzma_filter *filters, lzma_allocator *allocator,
+lzma_raw_buffer_decode(
+ const lzma_filter *filters, const lzma_allocator *allocator,
const uint8_t *in, size_t *in_pos, size_t in_size,
uint8_t *out, size_t *out_pos, size_t out_size)
{
- lzma_next_coder next = LZMA_NEXT_CODER_INIT;
- size_t in_start;
- size_t out_start;
- lzma_ret ret;
-
// Validate what isn't validated later in filter_common.c.
if (in == NULL || in_pos == NULL || *in_pos > in_size || out == NULL
|| out_pos == NULL || *out_pos > out_size)
return LZMA_PROG_ERROR;
// Initialize the decoer.
+ lzma_next_coder next = LZMA_NEXT_CODER_INIT;
return_if_error(lzma_raw_decoder_init(&next, allocator, filters));
// Store the positions so that we can restore them if something
// goes wrong.
- in_start = *in_pos;
- out_start = *out_pos;
+ const size_t in_start = *in_pos;
+ const size_t out_start = *out_pos;
// Do the actual decoding and free decoder's memory.
- ret = next.code(next.coder, allocator, in, in_pos, in_size,
+ lzma_ret ret = next.code(next.coder, allocator, in, in_pos, in_size,
out, out_pos, out_size, LZMA_FINISH);
if (ret == LZMA_STREAM_END) {
diff --git a/Utilities/cmliblzma/liblzma/common/filter_buffer_encoder.c b/Utilities/cmliblzma/liblzma/common/filter_buffer_encoder.c
index b23329f3e..dda18e3d8 100644
--- a/Utilities/cmliblzma/liblzma/common/filter_buffer_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/filter_buffer_encoder.c
@@ -14,29 +14,27 @@
extern LZMA_API(lzma_ret)
-lzma_raw_buffer_encode(const lzma_filter *filters, lzma_allocator *allocator,
- const uint8_t *in, size_t in_size, uint8_t *out,
- size_t *out_pos, size_t out_size)
+lzma_raw_buffer_encode(
+ const lzma_filter *filters, const lzma_allocator *allocator,
+ const uint8_t *in, size_t in_size,
+ uint8_t *out, size_t *out_pos, size_t out_size)
{
- lzma_next_coder next = LZMA_NEXT_CODER_INIT;
- size_t out_start;
- size_t in_pos = 0;
- lzma_ret ret;
-
// Validate what isn't validated later in filter_common.c.
if ((in == NULL && in_size != 0) || out == NULL
|| out_pos == NULL || *out_pos > out_size)
return LZMA_PROG_ERROR;
// Initialize the encoder
+ lzma_next_coder next = LZMA_NEXT_CODER_INIT;
return_if_error(lzma_raw_encoder_init(&next, allocator, filters));
// Store the output position so that we can restore it if
// something goes wrong.
- out_start = *out_pos;
+ const size_t out_start = *out_pos;
// Do the actual encoding and free coder's memory.
- ret = next.code(next.coder, allocator, in, &in_pos, in_size,
+ size_t in_pos = 0;
+ lzma_ret ret = next.code(next.coder, allocator, in, &in_pos, in_size,
out, out_pos, out_size, LZMA_FINISH);
lzma_next_end(&next, allocator);
diff --git a/Utilities/cmliblzma/liblzma/common/filter_common.c b/Utilities/cmliblzma/liblzma/common/filter_common.c
index d2b9e086e..9ad5d5d8e 100644
--- a/Utilities/cmliblzma/liblzma/common/filter_common.c
+++ b/Utilities/cmliblzma/liblzma/common/filter_common.c
@@ -36,101 +36,100 @@ static const struct {
} features[] = {
#if defined (HAVE_ENCODER_LZMA1) || defined(HAVE_DECODER_LZMA1)
{
- LZMA_FILTER_LZMA1,
- sizeof(lzma_options_lzma),
- false,
- true,
- true,
+ .id = LZMA_FILTER_LZMA1,
+ .options_size = sizeof(lzma_options_lzma),
+ .non_last_ok = false,
+ .last_ok = true,
+ .changes_size = true,
},
#endif
#if defined(HAVE_ENCODER_LZMA2) || defined(HAVE_DECODER_LZMA2)
{
- LZMA_FILTER_LZMA2,
- sizeof(lzma_options_lzma),
- false,
- true,
- true,
+ .id = LZMA_FILTER_LZMA2,
+ .options_size = sizeof(lzma_options_lzma),
+ .non_last_ok = false,
+ .last_ok = true,
+ .changes_size = true,
},
#endif
#if defined(HAVE_ENCODER_X86) || defined(HAVE_DECODER_X86)
{
- LZMA_FILTER_X86,
- sizeof(lzma_options_bcj),
- true,
- false,
- false,
+ .id = LZMA_FILTER_X86,
+ .options_size = sizeof(lzma_options_bcj),
+ .non_last_ok = true,
+ .last_ok = false,
+ .changes_size = false,
},
#endif
#if defined(HAVE_ENCODER_POWERPC) || defined(HAVE_DECODER_POWERPC)
{
- LZMA_FILTER_POWERPC,
- sizeof(lzma_options_bcj),
- true,
- false,
- false,
+ .id = LZMA_FILTER_POWERPC,
+ .options_size = sizeof(lzma_options_bcj),
+ .non_last_ok = true,
+ .last_ok = false,
+ .changes_size = false,
},
#endif
#if defined(HAVE_ENCODER_IA64) || defined(HAVE_DECODER_IA64)
{
- LZMA_FILTER_IA64,
- sizeof(lzma_options_bcj),
- true,
- false,
- false,
+ .id = LZMA_FILTER_IA64,
+ .options_size = sizeof(lzma_options_bcj),
+ .non_last_ok = true,
+ .last_ok = false,
+ .changes_size = false,
},
#endif
#if defined(HAVE_ENCODER_ARM) || defined(HAVE_DECODER_ARM)
{
- LZMA_FILTER_ARM,
- sizeof(lzma_options_bcj),
- true,
- false,
- false,
+ .id = LZMA_FILTER_ARM,
+ .options_size = sizeof(lzma_options_bcj),
+ .non_last_ok = true,
+ .last_ok = false,
+ .changes_size = false,
},
#endif
#if defined(HAVE_ENCODER_ARMTHUMB) || defined(HAVE_DECODER_ARMTHUMB)
{
- LZMA_FILTER_ARMTHUMB,
- sizeof(lzma_options_bcj),
- true,
- false,
- false,
+ .id = LZMA_FILTER_ARMTHUMB,
+ .options_size = sizeof(lzma_options_bcj),
+ .non_last_ok = true,
+ .last_ok = false,
+ .changes_size = false,
},
#endif
#if defined(HAVE_ENCODER_SPARC) || defined(HAVE_DECODER_SPARC)
{
- LZMA_FILTER_SPARC,
- sizeof(lzma_options_bcj),
- true,
- false,
- false,
+ .id = LZMA_FILTER_SPARC,
+ .options_size = sizeof(lzma_options_bcj),
+ .non_last_ok = true,
+ .last_ok = false,
+ .changes_size = false,
},
#endif
#if defined(HAVE_ENCODER_DELTA) || defined(HAVE_DECODER_DELTA)
{
- LZMA_FILTER_DELTA,
- sizeof(lzma_options_delta),
- true,
- false,
- false,
+ .id = LZMA_FILTER_DELTA,
+ .options_size = sizeof(lzma_options_delta),
+ .non_last_ok = true,
+ .last_ok = false,
+ .changes_size = false,
},
#endif
{
- LZMA_VLI_UNKNOWN
+ .id = LZMA_VLI_UNKNOWN
}
};
extern LZMA_API(lzma_ret)
lzma_filters_copy(const lzma_filter *src, lzma_filter *dest,
- lzma_allocator *allocator)
+ const lzma_allocator *allocator)
{
- size_t i;
- lzma_ret ret;
-
if (src == NULL || dest == NULL)
return LZMA_PROG_ERROR;
+ lzma_ret ret;
+ size_t i;
for (i = 0; src[i].id != LZMA_VLI_UNKNOWN; ++i) {
// There must be a maximum of four filters plus
// the array terminator.
@@ -194,6 +193,10 @@ error:
static lzma_ret
validate_chain(const lzma_filter *filters, size_t *count)
{
+ // There must be at least one filter.
+ if (filters == NULL || filters[0].id == LZMA_VLI_UNKNOWN)
+ return LZMA_PROG_ERROR;
+
// Number of non-last filters that may change the size of the data
// significantly (that is, more than 1-2 % or so).
size_t changes_size_count = 0;
@@ -207,11 +210,6 @@ validate_chain(const lzma_filter *filters, size_t *count)
bool last_ok = false;
size_t i = 0;
-
- // There must be at least one filter.
- if (filters == NULL || filters[0].id == LZMA_VLI_UNKNOWN)
- return LZMA_PROG_ERROR;
-
do {
size_t j;
for (j = 0; filters[i].id != features[j].id; ++j)
@@ -241,21 +239,18 @@ validate_chain(const lzma_filter *filters, size_t *count)
extern lzma_ret
-lzma_raw_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_raw_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter *options,
lzma_filter_find coder_find, bool is_encoder)
{
- lzma_filter_info filters[LZMA_FILTERS_MAX + 1];
- size_t count;
- size_t i;
- lzma_ret ret;
-
// Do some basic validation and get the number of filters.
+ size_t count;
return_if_error(validate_chain(options, &count));
// Set the filter functions and copy the options pointer.
+ lzma_filter_info filters[LZMA_FILTERS_MAX + 1];
if (is_encoder) {
- for (i = 0; i < count; ++i) {
+ for (size_t i = 0; i < count; ++i) {
// The order of the filters is reversed in the
// encoder. It allows more efficient handling
// of the uncompressed data.
@@ -271,7 +266,7 @@ lzma_raw_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
filters[j].options = options[i].options;
}
} else {
- for (i = 0; i < count; ++i) {
+ for (size_t i = 0; i < count; ++i) {
const lzma_filter_coder *const fc
= coder_find(options[i].id);
if (fc == NULL || fc->init == NULL)
@@ -288,7 +283,7 @@ lzma_raw_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
filters[count].init = NULL;
// Initialize the filters.
- ret = lzma_next_filter_init(next, allocator, filters);
+ const lzma_ret ret = lzma_next_filter_init(next, allocator, filters);
if (ret != LZMA_OK)
lzma_next_end(next, allocator);
@@ -300,9 +295,6 @@ extern uint64_t
lzma_raw_coder_memusage(lzma_filter_find coder_find,
const lzma_filter *filters)
{
- uint64_t total = 0;
- size_t i = 0;
-
// The chain has to have at least one filter.
{
size_t tmp;
@@ -310,6 +302,9 @@ lzma_raw_coder_memusage(lzma_filter_find coder_find,
return UINT64_MAX;
}
+ uint64_t total = 0;
+ size_t i = 0;
+
do {
const lzma_filter_coder *const fc
= coder_find(filters[i].id);
diff --git a/Utilities/cmliblzma/liblzma/common/filter_common.h b/Utilities/cmliblzma/liblzma/common/filter_common.h
index cd61fc072..42a26a24a 100644
--- a/Utilities/cmliblzma/liblzma/common/filter_common.h
+++ b/Utilities/cmliblzma/liblzma/common/filter_common.h
@@ -36,7 +36,7 @@ typedef const lzma_filter_coder *(*lzma_filter_find)(lzma_vli id);
extern lzma_ret lzma_raw_coder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
+ lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter *filters,
lzma_filter_find coder_find, bool is_encoder);
diff --git a/Utilities/cmliblzma/liblzma/common/filter_decoder.c b/Utilities/cmliblzma/liblzma/common/filter_decoder.c
index cce2b30ea..c75b0a89c 100644
--- a/Utilities/cmliblzma/liblzma/common/filter_decoder.c
+++ b/Utilities/cmliblzma/liblzma/common/filter_decoder.c
@@ -35,7 +35,8 @@ typedef struct {
/// \return - LZMA_OK: Properties decoded successfully.
/// - LZMA_OPTIONS_ERROR: Unsupported properties
/// - LZMA_MEM_ERROR: Memory allocation failed.
- lzma_ret (*props_decode)(void **options, lzma_allocator *allocator,
+ lzma_ret (*props_decode)(
+ void **options, const lzma_allocator *allocator,
const uint8_t *props, size_t props_size);
} lzma_filter_decoder;
@@ -44,74 +45,74 @@ typedef struct {
static const lzma_filter_decoder decoders[] = {
#ifdef HAVE_DECODER_LZMA1
{
- LZMA_FILTER_LZMA1,
- &lzma_lzma_decoder_init,
- &lzma_lzma_decoder_memusage,
- &lzma_lzma_props_decode,
+ .id = LZMA_FILTER_LZMA1,
+ .init = &lzma_lzma_decoder_init,
+ .memusage = &lzma_lzma_decoder_memusage,
+ .props_decode = &lzma_lzma_props_decode,
},
#endif
#ifdef HAVE_DECODER_LZMA2
{
- LZMA_FILTER_LZMA2,
- &lzma_lzma2_decoder_init,
- &lzma_lzma2_decoder_memusage,
- &lzma_lzma2_props_decode,
+ .id = LZMA_FILTER_LZMA2,
+ .init = &lzma_lzma2_decoder_init,
+ .memusage = &lzma_lzma2_decoder_memusage,
+ .props_decode = &lzma_lzma2_props_decode,
},
#endif
#ifdef HAVE_DECODER_X86
{
- LZMA_FILTER_X86,
- &lzma_simple_x86_decoder_init,
- NULL,
- &lzma_simple_props_decode,
+ .id = LZMA_FILTER_X86,
+ .init = &lzma_simple_x86_decoder_init,
+ .memusage = NULL,
+ .props_decode = &lzma_simple_props_decode,
},
#endif
#ifdef HAVE_DECODER_POWERPC
{
- LZMA_FILTER_POWERPC,
- &lzma_simple_powerpc_decoder_init,
- NULL,
- &lzma_simple_props_decode,
+ .id = LZMA_FILTER_POWERPC,
+ .init = &lzma_simple_powerpc_decoder_init,
+ .memusage = NULL,
+ .props_decode = &lzma_simple_props_decode,
},
#endif
#ifdef HAVE_DECODER_IA64
{
- LZMA_FILTER_IA64,
- &lzma_simple_ia64_decoder_init,
- NULL,
- &lzma_simple_props_decode,
+ .id = LZMA_FILTER_IA64,
+ .init = &lzma_simple_ia64_decoder_init,
+ .memusage = NULL,
+ .props_decode = &lzma_simple_props_decode,
},
#endif
#ifdef HAVE_DECODER_ARM
{
- LZMA_FILTER_ARM,
- &lzma_simple_arm_decoder_init,
- NULL,
- &lzma_simple_props_decode,
+ .id = LZMA_FILTER_ARM,
+ .init = &lzma_simple_arm_decoder_init,
+ .memusage = NULL,
+ .props_decode = &lzma_simple_props_decode,
},
#endif
#ifdef HAVE_DECODER_ARMTHUMB
{
- LZMA_FILTER_ARMTHUMB,
- &lzma_simple_armthumb_decoder_init,
- NULL,
- &lzma_simple_props_decode,
+ .id = LZMA_FILTER_ARMTHUMB,
+ .init = &lzma_simple_armthumb_decoder_init,
+ .memusage = NULL,
+ .props_decode = &lzma_simple_props_decode,
},
#endif
#ifdef HAVE_DECODER_SPARC
{
- LZMA_FILTER_SPARC,
- &lzma_simple_sparc_decoder_init,
- NULL,
- &lzma_simple_props_decode,
+ .id = LZMA_FILTER_SPARC,
+ .init = &lzma_simple_sparc_decoder_init,
+ .memusage = NULL,
+ .props_decode = &lzma_simple_props_decode,
},
#endif
#ifdef HAVE_DECODER_DELTA
{
- LZMA_FILTER_DELTA,
- &lzma_delta_decoder_init,
- &lzma_delta_coder_memusage,
- &lzma_delta_props_decode,
+ .id = LZMA_FILTER_DELTA,
+ .init = &lzma_delta_decoder_init,
+ .memusage = &lzma_delta_coder_memusage,
+ .props_decode = &lzma_delta_props_decode,
},
#endif
};
@@ -120,8 +121,7 @@ static const lzma_filter_decoder decoders[] = {
static const lzma_filter_decoder *
decoder_find(lzma_vli id)
{
- size_t i;
- for (i = 0; i < ARRAY_SIZE(decoders); ++i)
+ for (size_t i = 0; i < ARRAY_SIZE(decoders); ++i)
if (decoders[i].id == id)
return decoders + i;
@@ -137,7 +137,7 @@ lzma_filter_decoder_is_supported(lzma_vli id)
extern lzma_ret
-lzma_raw_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_raw_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter *options)
{
return lzma_raw_coder_init(next, allocator,
@@ -148,7 +148,7 @@ lzma_raw_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern LZMA_API(lzma_ret)
lzma_raw_decoder(lzma_stream *strm, const lzma_filter *options)
{
- lzma_next_strm_init1(lzma_raw_decoder_init, strm, options);
+ lzma_next_strm_init(lzma_raw_decoder_init, strm, options);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
@@ -166,14 +166,13 @@ lzma_raw_decoder_memusage(const lzma_filter *filters)
extern LZMA_API(lzma_ret)
-lzma_properties_decode(lzma_filter *filter, lzma_allocator *allocator,
+lzma_properties_decode(lzma_filter *filter, const lzma_allocator *allocator,
const uint8_t *props, size_t props_size)
{
- const lzma_filter_decoder *const fd = decoder_find(filter->id);
-
// Make it always NULL so that the caller can always safely free() it.
filter->options = NULL;
+ const lzma_filter_decoder *const fd = decoder_find(filter->id);
if (fd == NULL)
return LZMA_OPTIONS_ERROR;
diff --git a/Utilities/cmliblzma/liblzma/common/filter_decoder.h b/Utilities/cmliblzma/liblzma/common/filter_decoder.h
index d5c68bdd4..a2e255fe5 100644
--- a/Utilities/cmliblzma/liblzma/common/filter_decoder.h
+++ b/Utilities/cmliblzma/liblzma/common/filter_decoder.h
@@ -17,7 +17,7 @@
extern lzma_ret lzma_raw_decoder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
+ lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter *options);
#endif
diff --git a/Utilities/cmliblzma/liblzma/common/filter_encoder.c b/Utilities/cmliblzma/liblzma/common/filter_encoder.c
index 9fdb10008..c5d8f3972 100644
--- a/Utilities/cmliblzma/liblzma/common/filter_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/filter_encoder.c
@@ -30,11 +30,11 @@ typedef struct {
/// invalid, UINT64_MAX is returned.
uint64_t (*memusage)(const void *options);
- /// Calculates the minimum sane size for Blocks (or other types of
- /// chunks) to which the input data can be split to make
- /// multithreaded encoding possible. If this is NULL, it is assumed
- /// that the encoder is fast enough with single thread.
- lzma_vli (*chunk_size)(const void *options);
+ /// Calculates the recommended Uncompressed Size for .xz Blocks to
+ /// which the input data can be split to make multithreaded
+ /// encoding possible. If this is NULL, it is assumed that
+ /// the encoder is fast enough with single thread.
+ uint64_t (*block_size)(const void *options);
/// Tells the size of the Filter Properties field. If options are
/// invalid, UINT32_MAX is returned. If this is NULL, props_size_fixed
@@ -56,101 +56,95 @@ typedef struct {
static const lzma_filter_encoder encoders[] = {
#ifdef HAVE_ENCODER_LZMA1
{
- LZMA_FILTER_LZMA1,
- &lzma_lzma_encoder_init,
- &lzma_lzma_encoder_memusage,
- NULL, // FIXME
- NULL,
- 5,
- &lzma_lzma_props_encode,
+ .id = LZMA_FILTER_LZMA1,
+ .init = &lzma_lzma_encoder_init,
+ .memusage = &lzma_lzma_encoder_memusage,
+ .block_size = NULL, // FIXME
+ .props_size_get = NULL,
+ .props_size_fixed = 5,
+ .props_encode = &lzma_lzma_props_encode,
},
#endif
#ifdef HAVE_ENCODER_LZMA2
{
- LZMA_FILTER_LZMA2,
- &lzma_lzma2_encoder_init,
- &lzma_lzma2_encoder_memusage,
- NULL, // FIXME
- NULL,
- 1,
- &lzma_lzma2_props_encode,
+ .id = LZMA_FILTER_LZMA2,
+ .init = &lzma_lzma2_encoder_init,
+ .memusage = &lzma_lzma2_encoder_memusage,
+ .block_size = &lzma_lzma2_block_size, // FIXME
+ .props_size_get = NULL,
+ .props_size_fixed = 1,
+ .props_encode = &lzma_lzma2_props_encode,
},
#endif
#ifdef HAVE_ENCODER_X86
{
- LZMA_FILTER_X86,
- &lzma_simple_x86_encoder_init,
- NULL,
- NULL,
- &lzma_simple_props_size,
- 0,
- &lzma_simple_props_encode,
+ .id = LZMA_FILTER_X86,
+ .init = &lzma_simple_x86_encoder_init,
+ .memusage = NULL,
+ .block_size = NULL,
+ .props_size_get = &lzma_simple_props_size,
+ .props_encode = &lzma_simple_props_encode,
},
#endif
#ifdef HAVE_ENCODER_POWERPC
{
- LZMA_FILTER_POWERPC,
- &lzma_simple_powerpc_encoder_init,
- NULL,
- NULL,
- &lzma_simple_props_size,
- 0,
- &lzma_simple_props_encode,
+ .id = LZMA_FILTER_POWERPC,
+ .init = &lzma_simple_powerpc_encoder_init,
+ .memusage = NULL,
+ .block_size = NULL,
+ .props_size_get = &lzma_simple_props_size,
+ .props_encode = &lzma_simple_props_encode,
},
#endif
#ifdef HAVE_ENCODER_IA64
{
- LZMA_FILTER_IA64,
- &lzma_simple_ia64_encoder_init,
- NULL,
- NULL,
- &lzma_simple_props_size,
- 0,
- &lzma_simple_props_encode,
+ .id = LZMA_FILTER_IA64,
+ .init = &lzma_simple_ia64_encoder_init,
+ .memusage = NULL,
+ .block_size = NULL,
+ .props_size_get = &lzma_simple_props_size,
+ .props_encode = &lzma_simple_props_encode,
},
#endif
#ifdef HAVE_ENCODER_ARM
{
- LZMA_FILTER_ARM,
- &lzma_simple_arm_encoder_init,
- NULL,
- NULL,
- &lzma_simple_props_size,
- 0,
- &lzma_simple_props_encode,
+ .id = LZMA_FILTER_ARM,
+ .init = &lzma_simple_arm_encoder_init,
+ .memusage = NULL,
+ .block_size = NULL,
+ .props_size_get = &lzma_simple_props_size,
+ .props_encode = &lzma_simple_props_encode,
},
#endif
#ifdef HAVE_ENCODER_ARMTHUMB
{
- LZMA_FILTER_ARMTHUMB,
- &lzma_simple_armthumb_encoder_init,
- NULL,
- NULL,
- &lzma_simple_props_size,
- 0,
- &lzma_simple_props_encode,
+ .id = LZMA_FILTER_ARMTHUMB,
+ .init = &lzma_simple_armthumb_encoder_init,
+ .memusage = NULL,
+ .block_size = NULL,
+ .props_size_get = &lzma_simple_props_size,
+ .props_encode = &lzma_simple_props_encode,
},
#endif
#ifdef HAVE_ENCODER_SPARC
{
- LZMA_FILTER_SPARC,
- &lzma_simple_sparc_encoder_init,
- NULL,
- NULL,
- &lzma_simple_props_size,
- 0,
- &lzma_simple_props_encode,
+ .id = LZMA_FILTER_SPARC,
+ .init = &lzma_simple_sparc_encoder_init,
+ .memusage = NULL,
+ .block_size = NULL,
+ .props_size_get = &lzma_simple_props_size,
+ .props_encode = &lzma_simple_props_encode,
},
#endif
#ifdef HAVE_ENCODER_DELTA
{
- LZMA_FILTER_DELTA,
- &lzma_delta_encoder_init,
- &lzma_delta_coder_memusage,
- NULL,
- NULL,
- 1,
- &lzma_delta_props_encode,
+ .id = LZMA_FILTER_DELTA,
+ .init = &lzma_delta_encoder_init,
+ .memusage = &lzma_delta_coder_memusage,
+ .block_size = NULL,
+ .props_size_get = NULL,
+ .props_size_fixed = 1,
+ .props_encode = &lzma_delta_props_encode,
},
#endif
};
@@ -159,8 +153,7 @@ static const lzma_filter_encoder encoders[] = {
static const lzma_filter_encoder *
encoder_find(lzma_vli id)
{
- size_t i;
- for (i = 0; i < ARRAY_SIZE(encoders); ++i)
+ for (size_t i = 0; i < ARRAY_SIZE(encoders); ++i)
if (encoders[i].id == id)
return encoders + i;
@@ -178,10 +171,6 @@ lzma_filter_encoder_is_supported(lzma_vli id)
extern LZMA_API(lzma_ret)
lzma_filters_update(lzma_stream *strm, const lzma_filter *filters)
{
- size_t i;
- size_t count = 1;
- lzma_filter reversed_filters[LZMA_FILTERS_MAX + 1];
-
if (strm->internal->next.update == NULL)
return LZMA_PROG_ERROR;
@@ -191,10 +180,12 @@ lzma_filters_update(lzma_stream *strm, const lzma_filter *filters)
// The actual filter chain in the encoder is reversed. Some things
// still want the normal order chain, so we provide both.
+ size_t count = 1;
while (filters[count].id != LZMA_VLI_UNKNOWN)
++count;
- for (i = 0; i < count; ++i)
+ lzma_filter reversed_filters[LZMA_FILTERS_MAX + 1];
+ for (size_t i = 0; i < count; ++i)
reversed_filters[count - i - 1] = filters[i];
reversed_filters[count].id = LZMA_VLI_UNKNOWN;
@@ -205,7 +196,7 @@ lzma_filters_update(lzma_stream *strm, const lzma_filter *filters)
extern lzma_ret
-lzma_raw_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_raw_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter *options)
{
return lzma_raw_coder_init(next, allocator,
@@ -216,7 +207,7 @@ lzma_raw_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern LZMA_API(lzma_ret)
lzma_raw_encoder(lzma_stream *strm, const lzma_filter *options)
{
- lzma_next_strm_init3(lzma_raw_coder_init, strm, options,
+ lzma_next_strm_init(lzma_raw_coder_init, strm, options,
(lzma_filter_find)(&encoder_find), true);
strm->internal->supported_actions[LZMA_RUN] = true;
@@ -235,20 +226,19 @@ lzma_raw_encoder_memusage(const lzma_filter *filters)
}
-/*
-extern LZMA_API(lzma_vli)
-lzma_chunk_size(const lzma_filter *filters)
+extern uint64_t
+lzma_mt_block_size(const lzma_filter *filters)
{
- lzma_vli max = 0;
+ uint64_t max = 0;
for (size_t i = 0; filters[i].id != LZMA_VLI_UNKNOWN; ++i) {
const lzma_filter_encoder *const fe
= encoder_find(filters[i].id);
- if (fe->chunk_size != NULL) {
- const lzma_vli size
- = fe->chunk_size(filters[i].options);
- if (size == LZMA_VLI_UNKNOWN)
- return LZMA_VLI_UNKNOWN;
+ if (fe->block_size != NULL) {
+ const uint64_t size
+ = fe->block_size(filters[i].options);
+ if (size == 0)
+ return 0;
if (size > max)
max = size;
@@ -257,7 +247,6 @@ lzma_chunk_size(const lzma_filter *filters)
return max;
}
-*/
extern LZMA_API(lzma_ret)
diff --git a/Utilities/cmliblzma/liblzma/common/filter_encoder.h b/Utilities/cmliblzma/liblzma/common/filter_encoder.h
index 5bc137f64..f1d5683fe 100644
--- a/Utilities/cmliblzma/liblzma/common/filter_encoder.h
+++ b/Utilities/cmliblzma/liblzma/common/filter_encoder.h
@@ -16,12 +16,12 @@
#include "common.h"
-// FIXME: Might become a part of the public API once finished.
-// extern lzma_vli lzma_chunk_size(const lzma_filter *filters);
+// FIXME: Might become a part of the public API.
+extern uint64_t lzma_mt_block_size(const lzma_filter *filters);
extern lzma_ret lzma_raw_encoder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
+ lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter *filters);
#endif
diff --git a/Utilities/cmliblzma/liblzma/common/filter_flags_decoder.c b/Utilities/cmliblzma/liblzma/common/filter_flags_decoder.c
index aa2dbd560..ddfb08594 100644
--- a/Utilities/cmliblzma/liblzma/common/filter_flags_decoder.c
+++ b/Utilities/cmliblzma/liblzma/common/filter_flags_decoder.c
@@ -15,12 +15,9 @@
extern LZMA_API(lzma_ret)
lzma_filter_flags_decode(
- lzma_filter *filter, lzma_allocator *allocator,
+ lzma_filter *filter, const lzma_allocator *allocator,
const uint8_t *in, size_t *in_pos, size_t in_size)
{
- lzma_vli props_size;
- lzma_ret ret;
-
// Set the pointer to NULL so the caller can always safely free it.
filter->options = NULL;
@@ -32,6 +29,7 @@ lzma_filter_flags_decode(
return LZMA_DATA_ERROR;
// Size of Properties
+ lzma_vli props_size;
return_if_error(lzma_vli_decode(&props_size, NULL,
in, in_pos, in_size));
@@ -39,7 +37,7 @@ lzma_filter_flags_decode(
if (in_size - *in_pos < props_size)
return LZMA_DATA_ERROR;
- ret = lzma_properties_decode(
+ const lzma_ret ret = lzma_properties_decode(
filter, allocator, in + *in_pos, props_size);
*in_pos += props_size;
diff --git a/Utilities/cmliblzma/liblzma/common/filter_flags_encoder.c b/Utilities/cmliblzma/liblzma/common/filter_flags_encoder.c
index 755c407f6..d110566de 100644
--- a/Utilities/cmliblzma/liblzma/common/filter_flags_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/filter_flags_encoder.c
@@ -31,8 +31,6 @@ extern LZMA_API(lzma_ret)
lzma_filter_flags_encode(const lzma_filter *filter,
uint8_t *out, size_t *out_pos, size_t out_size)
{
- uint32_t props_size;
-
// Filter ID
if (filter->id >= LZMA_FILTER_RESERVED_START)
return LZMA_PROG_ERROR;
@@ -41,6 +39,7 @@ lzma_filter_flags_encode(const lzma_filter *filter,
out, out_pos, out_size));
// Size of Properties
+ uint32_t props_size;
return_if_error(lzma_properties_size(&props_size, filter));
return_if_error(lzma_vli_encode(props_size, NULL,
out, out_pos, out_size));
diff --git a/Utilities/cmliblzma/liblzma/common/hardware_cputhreads.c b/Utilities/cmliblzma/liblzma/common/hardware_cputhreads.c
new file mode 100644
index 000000000..f468366a6
--- /dev/null
+++ b/Utilities/cmliblzma/liblzma/common/hardware_cputhreads.c
@@ -0,0 +1,22 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+/// \file hardware_cputhreads.c
+/// \brief Get the number of CPU threads or cores
+//
+// Author: Lasse Collin
+//
+// This file has been put into the public domain.
+// You can do whatever you want with this file.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include "common.h"
+
+#include "tuklib_cpucores.h"
+
+
+extern LZMA_API(uint32_t)
+lzma_cputhreads(void)
+{
+ return tuklib_cpucores();
+}
diff --git a/Utilities/cmliblzma/liblzma/common/index.c b/Utilities/cmliblzma/liblzma/common/index.c
index 26135d22c..26e4e519b 100644
--- a/Utilities/cmliblzma/liblzma/common/index.c
+++ b/Utilities/cmliblzma/liblzma/common/index.c
@@ -191,8 +191,8 @@ index_tree_init(index_tree *tree)
/// Helper for index_tree_end()
static void
-index_tree_node_end(index_tree_node *node, lzma_allocator *allocator,
- void (*free_func)(void *node, lzma_allocator *allocator))
+index_tree_node_end(index_tree_node *node, const lzma_allocator *allocator,
+ void (*free_func)(void *node, const lzma_allocator *allocator))
{
// The tree won't ever be very huge, so recursion should be fine.
// 20 levels in the tree is likely quite a lot already in practice.
@@ -202,22 +202,21 @@ index_tree_node_end(index_tree_node *node, lzma_allocator *allocator,
if (node->right != NULL)
index_tree_node_end(node->right, allocator, free_func);
- if (free_func != NULL)
- free_func(node, allocator);
-
- lzma_free(node, allocator);
+ free_func(node, allocator);
return;
}
-/// Free the meory allocated for a tree. If free_func is not NULL,
-/// it is called on each node before freeing the node. This is used
-/// to free the Record groups from each index_stream before freeing
-/// the index_stream itself.
+/// Free the memory allocated for a tree. Each node is freed using the
+/// given free_func which is either &lzma_free or &index_stream_end.
+/// The latter is used to free the Record groups from each index_stream
+/// before freeing the index_stream itself.
static void
-index_tree_end(index_tree *tree, lzma_allocator *allocator,
- void (*free_func)(void *node, lzma_allocator *allocator))
+index_tree_end(index_tree *tree, const lzma_allocator *allocator,
+ void (*free_func)(void *node, const lzma_allocator *allocator))
{
+ assert(free_func != NULL);
+
if (tree->root != NULL)
index_tree_node_end(tree->root, allocator, free_func);
@@ -230,7 +229,6 @@ index_tree_end(index_tree *tree, lzma_allocator *allocator,
static void
index_tree_append(index_tree *tree, index_tree_node *node)
{
- uint32_t up;
node->parent = tree->rightmost;
node->left = NULL;
node->right = NULL;
@@ -259,10 +257,8 @@ index_tree_append(index_tree *tree, index_tree_node *node)
// and thus know the state of the tree just by looking at the node
// count. From the node count we can calculate how many steps to go
// up in the tree to find the rotation root.
- up = tree->count ^ (UINT32_C(1) << bsr32(tree->count));
+ uint32_t up = tree->count ^ (UINT32_C(1) << bsr32(tree->count));
if (up != 0) {
- index_tree_node *pivot;
-
// Locate the root node for the rotation.
up = ctz32(tree->count) + 2;
do {
@@ -270,7 +266,7 @@ index_tree_append(index_tree *tree, index_tree_node *node)
} while (--up > 0);
// Rotate left using node as the rotation root.
- pivot = node->right;
+ index_tree_node *pivot = node->right;
if (node->parent == NULL) {
tree->root = pivot;
@@ -342,8 +338,8 @@ index_tree_locate(const index_tree *tree, lzma_vli target)
/// Allocate and initialize a new Stream using the given base offsets.
static index_stream *
index_stream_init(lzma_vli compressed_base, lzma_vli uncompressed_base,
- lzma_vli stream_number, lzma_vli block_number_base,
- lzma_allocator *allocator)
+ uint32_t stream_number, lzma_vli block_number_base,
+ const lzma_allocator *allocator)
{
index_stream *s = lzma_alloc(sizeof(index_stream), allocator);
if (s == NULL)
@@ -371,16 +367,17 @@ index_stream_init(lzma_vli compressed_base, lzma_vli uncompressed_base,
/// Free the memory allocated for a Stream and its Record groups.
static void
-index_stream_end(void *node, lzma_allocator *allocator)
+index_stream_end(void *node, const lzma_allocator *allocator)
{
index_stream *s = node;
- index_tree_end(&s->groups, allocator, NULL);
+ index_tree_end(&s->groups, allocator, &lzma_free);
+ lzma_free(s, allocator);
return;
}
static lzma_index *
-index_init_plain(lzma_allocator *allocator)
+index_init_plain(const lzma_allocator *allocator)
{
lzma_index *i = lzma_alloc(sizeof(lzma_index), allocator);
if (i != NULL) {
@@ -398,15 +395,13 @@ index_init_plain(lzma_allocator *allocator)
extern LZMA_API(lzma_index *)
-lzma_index_init(lzma_allocator *allocator)
+lzma_index_init(const lzma_allocator *allocator)
{
- index_stream *s;
-
lzma_index *i = index_init_plain(allocator);
if (i == NULL)
return NULL;
- s = index_stream_init(0, 0, 1, 0, allocator);
+ index_stream *s = index_stream_init(0, 0, 1, 0, allocator);
if (s == NULL) {
lzma_free(i, allocator);
return NULL;
@@ -419,7 +414,7 @@ lzma_index_init(lzma_allocator *allocator)
extern LZMA_API(void)
-lzma_index_end(lzma_index *i, lzma_allocator *allocator)
+lzma_index_end(lzma_index *i, const lzma_allocator *allocator)
{
// NOTE: If you modify this function, check also the bottom
// of lzma_index_cat().
@@ -605,8 +600,6 @@ lzma_index_padding_size(const lzma_index *i)
extern LZMA_API(lzma_ret)
lzma_index_stream_flags(lzma_index *i, const lzma_stream_flags *stream_flags)
{
- index_stream *s;
-
if (i == NULL || stream_flags == NULL)
return LZMA_PROG_ERROR;
@@ -614,7 +607,7 @@ lzma_index_stream_flags(lzma_index *i, const lzma_stream_flags *stream_flags)
return_if_error(lzma_stream_flags_compare(
stream_flags, stream_flags));
- s = (index_stream *)(i->streams.rightmost);
+ index_stream *s = (index_stream *)(i->streams.rightmost);
s->stream_flags = *stream_flags;
return LZMA_OK;
@@ -624,17 +617,14 @@ lzma_index_stream_flags(lzma_index *i, const lzma_stream_flags *stream_flags)
extern LZMA_API(lzma_ret)
lzma_index_stream_padding(lzma_index *i, lzma_vli stream_padding)
{
- index_stream *s;
- lzma_vli old_stream_padding;
-
if (i == NULL || stream_padding > LZMA_VLI_MAX
|| (stream_padding & 3) != 0)
return LZMA_PROG_ERROR;
- s = (index_stream *)(i->streams.rightmost);
+ index_stream *s = (index_stream *)(i->streams.rightmost);
// Check that the new value won't make the file grow too big.
- old_stream_padding = s->stream_padding;
+ const lzma_vli old_stream_padding = s->stream_padding;
s->stream_padding = 0;
if (lzma_index_file_size(i) + stream_padding > LZMA_VLI_MAX) {
s->stream_padding = old_stream_padding;
@@ -647,29 +637,23 @@ lzma_index_stream_padding(lzma_index *i, lzma_vli stream_padding)
extern LZMA_API(lzma_ret)
-lzma_index_append(lzma_index *i, lzma_allocator *allocator,
+lzma_index_append(lzma_index *i, const lzma_allocator *allocator,
lzma_vli unpadded_size, lzma_vli uncompressed_size)
{
- index_stream *s;
- index_group *g;
- lzma_vli compressed_base;
- lzma_vli uncompressed_base;
- uint32_t index_list_size_add;
-
// Validate.
if (i == NULL || unpadded_size < UNPADDED_SIZE_MIN
|| unpadded_size > UNPADDED_SIZE_MAX
|| uncompressed_size > LZMA_VLI_MAX)
return LZMA_PROG_ERROR;
- s = (index_stream *)(i->streams.rightmost);
- g = (index_group *)(s->groups.rightmost);
+ index_stream *s = (index_stream *)(i->streams.rightmost);
+ index_group *g = (index_group *)(s->groups.rightmost);
- compressed_base = g == NULL ? 0
+ const lzma_vli compressed_base = g == NULL ? 0
: vli_ceil4(g->records[g->last].unpadded_sum);
- uncompressed_base = g == NULL ? 0
+ const lzma_vli uncompressed_base = g == NULL ? 0
: g->records[g->last].uncompressed_sum;
- index_list_size_add = lzma_vli_size(unpadded_size)
+ const uint32_t index_list_size_add = lzma_vli_size(unpadded_size)
+ lzma_vli_size(uncompressed_size);
// Check that the file size will stay within limits.
@@ -780,10 +764,9 @@ index_cat_helper(const index_cat_info *info, index_stream *this)
extern LZMA_API(lzma_ret)
-lzma_index_cat(lzma_index *LZMA_RESTRICT dest, lzma_index *LZMA_RESTRICT src,
- lzma_allocator *allocator)
+lzma_index_cat(lzma_index *restrict dest, lzma_index *restrict src,
+ const lzma_allocator *allocator)
{
- index_cat_info info;
const lzma_vli dest_file_size = lzma_index_file_size(dest);
// Check that we don't exceed the file size limits.
@@ -813,12 +796,10 @@ lzma_index_cat(lzma_index *LZMA_RESTRICT dest, lzma_index *LZMA_RESTRICT src,
index_stream *s = (index_stream *)(dest->streams.rightmost);
index_group *g = (index_group *)(s->groups.rightmost);
if (g != NULL && g->last + 1 < g->allocated) {
- index_group *newg;
-
assert(g->node.left == NULL);
assert(g->node.right == NULL);
- newg = lzma_alloc(sizeof(index_group)
+ index_group *newg = lzma_alloc(sizeof(index_group)
+ (g->last + 1)
* sizeof(index_record),
allocator);
@@ -848,17 +829,21 @@ lzma_index_cat(lzma_index *LZMA_RESTRICT dest, lzma_index *LZMA_RESTRICT src,
s->groups.rightmost = &newg->node;
lzma_free(g, allocator);
+
+ // NOTE: newg isn't leaked here because
+ // newg == (void *)&newg->node.
}
}
// Add all the Streams from src to dest. Update the base offsets
// of each Stream from src.
- info.uncompressed_size = dest->uncompressed_size;
- info.file_size = dest_file_size;
- info.stream_number_add = dest->streams.count;
- info.block_number_add = dest->record_count;
- info.streams = &dest->streams;
-
+ const index_cat_info info = {
+ .uncompressed_size = dest->uncompressed_size,
+ .file_size = dest_file_size,
+ .stream_number_add = dest->streams.count,
+ .block_number_add = dest->record_count,
+ .streams = &dest->streams,
+ };
index_cat_helper(&info, (index_stream *)(src->streams.root));
// Update info about all the combined Streams.
@@ -877,26 +862,18 @@ lzma_index_cat(lzma_index *LZMA_RESTRICT dest, lzma_index *LZMA_RESTRICT src,
/// Duplicate an index_stream.
static index_stream *
-index_dup_stream(const index_stream *src, lzma_allocator *allocator)
+index_dup_stream(const index_stream *src, const lzma_allocator *allocator)
{
- index_stream *dest;
- index_group *destg;
- index_group *srcg;
- size_t i = 0;
-
// Catch a somewhat theoretical integer overflow.
if (src->record_count > PREALLOC_MAX)
return NULL;
// Allocate and initialize a new Stream.
- dest = index_stream_init(src->node.compressed_base,
+ index_stream *dest = index_stream_init(src->node.compressed_base,
src->node.uncompressed_base, src->number,
src->block_number_base, allocator);
-
- // Return immediately if allocation failed or if there are
- // no groups to duplicate.
- if (dest == NULL || src->groups.leftmost == NULL)
- return dest;
+ if (dest == NULL)
+ return NULL;
// Copy the overall information.
dest->record_count = src->record_count;
@@ -904,10 +881,14 @@ index_dup_stream(const index_stream *src, lzma_allocator *allocator)
dest->stream_flags = src->stream_flags;
dest->stream_padding = src->stream_padding;
+ // Return if there are no groups to duplicate.
+ if (src->groups.leftmost == NULL)
+ return dest;
+
// Allocate memory for the Records. We put all the Records into
// a single group. It's simplest and also tends to make
// lzma_index_locate() a little bit faster with very big Indexes.
- destg = lzma_alloc(sizeof(index_group)
+ index_group *destg = lzma_alloc(sizeof(index_group)
+ src->record_count * sizeof(index_record),
allocator);
if (destg == NULL) {
@@ -923,7 +904,8 @@ index_dup_stream(const index_stream *src, lzma_allocator *allocator)
destg->last = src->record_count - 1;
// Go through all the groups in src and copy the Records into destg.
- srcg = (index_group *)(src->groups.leftmost);
+ const index_group *srcg = (const index_group *)(src->groups.leftmost);
+ size_t i = 0;
do {
memcpy(destg->records + i, srcg->records,
(srcg->last + 1) * sizeof(index_record));
@@ -941,11 +923,8 @@ index_dup_stream(const index_stream *src, lzma_allocator *allocator)
extern LZMA_API(lzma_index *)
-lzma_index_dup(const lzma_index *src, lzma_allocator *allocator)
+lzma_index_dup(const lzma_index *src, const lzma_allocator *allocator)
{
- index_stream *srcstream;
- index_stream *deststream;
-
// Allocate the base structure (no initial Stream).
lzma_index *dest = index_init_plain(allocator);
if (dest == NULL)
@@ -958,9 +937,11 @@ lzma_index_dup(const lzma_index *src, lzma_allocator *allocator)
dest->index_list_size = src->index_list_size;
// Copy the Streams and the groups in them.
- srcstream = (index_stream *)(src->streams.leftmost);
+ const index_stream *srcstream
+ = (const index_stream *)(src->streams.leftmost);
do {
- deststream = index_dup_stream(srcstream, allocator);
+ index_stream *deststream = index_dup_stream(
+ srcstream, allocator);
if (deststream == NULL) {
lzma_index_end(dest, allocator);
return NULL;
@@ -1031,6 +1012,8 @@ iter_set_info(lzma_index_iter *iter)
iter->internal[ITER_GROUP].p = NULL;
}
+ // NOTE: lzma_index_iter.stream.number is lzma_vli but we use uint32_t
+ // internally.
iter->stream.number = stream->number;
iter->stream.block_count = stream->record_count;
iter->stream.compressed_offset = stream->node.compressed_base;
@@ -1119,19 +1102,14 @@ lzma_index_iter_rewind(lzma_index_iter *iter)
extern LZMA_API(lzma_bool)
lzma_index_iter_next(lzma_index_iter *iter, lzma_index_iter_mode mode)
{
- const lzma_index *i;
- const index_stream *stream;
- const index_group *group;
- size_t record;
-
// Catch unsupported mode values.
if ((unsigned int)(mode) > LZMA_INDEX_ITER_NONEMPTY_BLOCK)
return true;
- i = iter->internal[ITER_INDEX].p;
- stream = iter->internal[ITER_STREAM].p;
- group = NULL;
- record = iter->internal[ITER_RECORD].s;
+ const lzma_index *i = iter->internal[ITER_INDEX].p;
+ const index_stream *stream = iter->internal[ITER_STREAM].p;
+ const index_group *group = NULL;
+ size_t record = iter->internal[ITER_RECORD].s;
// If we are being asked for the next Stream, leave group to NULL
// so that the rest of the this function thinks that this Stream
@@ -1231,10 +1209,6 @@ again:
extern LZMA_API(lzma_bool)
lzma_index_iter_locate(lzma_index_iter *iter, lzma_vli target)
{
- const index_stream *stream;
- const index_group *group;
- size_t left, right;
-
const lzma_index *i = iter->internal[ITER_INDEX].p;
// If the target is past the end of the file, return immediately.
@@ -1242,12 +1216,12 @@ lzma_index_iter_locate(lzma_index_iter *iter, lzma_vli target)
return true;
// Locate the Stream containing the target offset.
- stream = index_tree_locate(&i->streams, target);
+ const index_stream *stream = index_tree_locate(&i->streams, target);
assert(stream != NULL);
target -= stream->node.uncompressed_base;
// Locate the group containing the target offset.
- group = index_tree_locate(&stream->groups, target);
+ const index_group *group = index_tree_locate(&stream->groups, target);
assert(group != NULL);
// Use binary search to locate the exact Record. It is the first
@@ -1255,8 +1229,8 @@ lzma_index_iter_locate(lzma_index_iter *iter, lzma_vli target)
// This is because we want the rightmost Record that fullfills the
// search criterion. It is possible that there are empty Blocks;
// we don't want to return them.
- left = 0;
- right = group->last;
+ size_t left = 0;
+ size_t right = group->last;
while (left < right) {
const size_t pos = left + (right - left) / 2;
diff --git a/Utilities/cmliblzma/liblzma/common/index_decoder.c b/Utilities/cmliblzma/liblzma/common/index_decoder.c
index 943cfd58a..cc07a1b8c 100644
--- a/Utilities/cmliblzma/liblzma/common/index_decoder.c
+++ b/Utilities/cmliblzma/liblzma/common/index_decoder.c
@@ -14,7 +14,7 @@
#include "check.h"
-struct lzma_coder_s {
+typedef struct {
enum {
SEQ_INDICATOR,
SEQ_COUNT,
@@ -50,18 +50,20 @@ struct lzma_coder_s {
/// CRC32 of the List of Records field
uint32_t crc32;
-};
+} lzma_index_coder;
static lzma_ret
-index_decode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
+index_decode(void *coder_ptr, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
size_t in_size,
- uint8_t *LZMA_RESTRICT out lzma_attribute((__unused__)),
- size_t *LZMA_RESTRICT out_pos lzma_attribute((__unused__)),
+ uint8_t *restrict out lzma_attribute((__unused__)),
+ size_t *restrict out_pos lzma_attribute((__unused__)),
size_t out_size lzma_attribute((__unused__)),
lzma_action action lzma_attribute((__unused__)))
{
+ lzma_index_coder *coder = coder_ptr;
+
// Similar optimization as in index_encoder.c
const size_t in_start = *in_pos;
lzma_ret ret = LZMA_OK;
@@ -207,8 +209,9 @@ out:
static void
-index_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
+index_decoder_end(void *coder_ptr, const lzma_allocator *allocator)
{
+ lzma_index_coder *coder = coder_ptr;
lzma_index_end(coder->index, allocator);
lzma_free(coder, allocator);
return;
@@ -216,9 +219,11 @@ index_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
-index_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
+index_decoder_memconfig(void *coder_ptr, uint64_t *memusage,
uint64_t *old_memlimit, uint64_t new_memlimit)
{
+ lzma_index_coder *coder = coder_ptr;
+
*memusage = lzma_index_memusage(1, coder->count);
*old_memlimit = coder->memlimit;
@@ -234,7 +239,7 @@ index_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
static lzma_ret
-index_decoder_reset(lzma_coder *coder, lzma_allocator *allocator,
+index_decoder_reset(lzma_index_coder *coder, const lzma_allocator *allocator,
lzma_index **i, uint64_t memlimit)
{
// Remember the pointer given by the application. We will set it
@@ -251,7 +256,7 @@ index_decoder_reset(lzma_coder *coder, lzma_allocator *allocator,
// Initialize the rest.
coder->sequence = SEQ_INDICATOR;
- coder->memlimit = memlimit;
+ coder->memlimit = my_max(1, memlimit);
coder->count = 0; // Needs to be initialized due to _memconfig().
coder->pos = 0;
coder->crc32 = 0;
@@ -261,35 +266,37 @@ index_decoder_reset(lzma_coder *coder, lzma_allocator *allocator,
static lzma_ret
-index_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+index_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
lzma_index **i, uint64_t memlimit)
{
lzma_next_coder_init(&index_decoder_init, next, allocator);
- if (i == NULL || memlimit == 0)
+ if (i == NULL)
return LZMA_PROG_ERROR;
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
+ lzma_index_coder *coder = next->coder;
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_index_coder), allocator);
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ next->coder = coder;
next->code = &index_decode;
next->end = &index_decoder_end;
next->memconfig = &index_decoder_memconfig;
- next->coder->index = NULL;
+ coder->index = NULL;
} else {
- lzma_index_end(next->coder->index, allocator);
+ lzma_index_end(coder->index, allocator);
}
- return index_decoder_reset(next->coder, allocator, i, memlimit);
+ return index_decoder_reset(coder, allocator, i, memlimit);
}
extern LZMA_API(lzma_ret)
lzma_index_decoder(lzma_stream *strm, lzma_index **i, uint64_t memlimit)
{
- lzma_next_strm_init2(index_decoder_init, strm, i, memlimit);
+ lzma_next_strm_init(index_decoder_init, strm, i, memlimit);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
@@ -299,27 +306,25 @@ lzma_index_decoder(lzma_stream *strm, lzma_index **i, uint64_t memlimit)
extern LZMA_API(lzma_ret)
-lzma_index_buffer_decode(
- lzma_index **i, uint64_t *memlimit, lzma_allocator *allocator,
+lzma_index_buffer_decode(lzma_index **i, uint64_t *memlimit,
+ const lzma_allocator *allocator,
const uint8_t *in, size_t *in_pos, size_t in_size)
{
- lzma_coder coder;
- lzma_ret ret;
-
- // Store the input start position so that we can restore it in case
- // of an error.
- const size_t in_start = *in_pos;
-
// Sanity checks
if (i == NULL || memlimit == NULL
|| in == NULL || in_pos == NULL || *in_pos > in_size)
return LZMA_PROG_ERROR;
// Initialize the decoder.
+ lzma_index_coder coder;
return_if_error(index_decoder_reset(&coder, allocator, i, *memlimit));
+ // Store the input start position so that we can restore it in case
+ // of an error.
+ const size_t in_start = *in_pos;
+
// Do the actual decoding.
- ret = index_decode(&coder, allocator, in, in_pos, in_size,
+ lzma_ret ret = index_decode(&coder, allocator, in, in_pos, in_size,
NULL, NULL, 0, LZMA_RUN);
if (ret == LZMA_STREAM_END) {
diff --git a/Utilities/cmliblzma/liblzma/common/index_encoder.c b/Utilities/cmliblzma/liblzma/common/index_encoder.c
index 194bf2113..ac97d0ceb 100644
--- a/Utilities/cmliblzma/liblzma/common/index_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/index_encoder.c
@@ -15,7 +15,7 @@
#include "check.h"
-struct lzma_coder_s {
+typedef struct {
enum {
SEQ_INDICATOR,
SEQ_COUNT,
@@ -37,19 +37,21 @@ struct lzma_coder_s {
/// CRC32 of the List of Records field
uint32_t crc32;
-};
+} lzma_index_coder;
static lzma_ret
-index_encode(lzma_coder *coder,
- lzma_allocator *allocator lzma_attribute((__unused__)),
- const uint8_t *LZMA_RESTRICT in lzma_attribute((__unused__)),
- size_t *LZMA_RESTRICT in_pos lzma_attribute((__unused__)),
+index_encode(void *coder_ptr,
+ const lzma_allocator *allocator lzma_attribute((__unused__)),
+ const uint8_t *restrict in lzma_attribute((__unused__)),
+ size_t *restrict in_pos lzma_attribute((__unused__)),
size_t in_size lzma_attribute((__unused__)),
- uint8_t *LZMA_RESTRICT out, size_t *LZMA_RESTRICT out_pos,
+ uint8_t *restrict out, size_t *restrict out_pos,
size_t out_size,
lzma_action action lzma_attribute((__unused__)))
{
+ lzma_index_coder *coder = coder_ptr;
+
// Position where to start calculating CRC32. The idea is that we
// need to call lzma_crc32() only once per call to index_encode().
const size_t out_start = *out_pos;
@@ -159,7 +161,7 @@ out:
static void
-index_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
+index_encoder_end(void *coder, const lzma_allocator *allocator)
{
lzma_free(coder, allocator);
return;
@@ -167,7 +169,7 @@ index_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
static void
-index_encoder_reset(lzma_coder *coder, const lzma_index *i)
+index_encoder_reset(lzma_index_coder *coder, const lzma_index *i)
{
lzma_index_iter_init(&coder->iter, i);
@@ -181,7 +183,7 @@ index_encoder_reset(lzma_coder *coder, const lzma_index *i)
extern lzma_ret
-lzma_index_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_index_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_index *i)
{
lzma_next_coder_init(&lzma_index_encoder_init, next, allocator);
@@ -190,7 +192,7 @@ lzma_index_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
return LZMA_PROG_ERROR;
if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ next->coder = lzma_alloc(sizeof(lzma_index_coder), allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
@@ -207,7 +209,7 @@ lzma_index_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern LZMA_API(lzma_ret)
lzma_index_encoder(lzma_stream *strm, const lzma_index *i)
{
- lzma_next_strm_init1(lzma_index_encoder_init, strm, i);
+ lzma_next_strm_init(lzma_index_encoder_init, strm, i);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
@@ -220,10 +222,6 @@ extern LZMA_API(lzma_ret)
lzma_index_buffer_encode(const lzma_index *i,
uint8_t *out, size_t *out_pos, size_t out_size)
{
- lzma_coder coder;
- size_t out_start;
- lzma_ret ret;
-
// Validate the arguments.
if (i == NULL || out == NULL || out_pos == NULL || *out_pos > out_size)
return LZMA_PROG_ERROR;
@@ -234,12 +232,13 @@ lzma_index_buffer_encode(const lzma_index *i,
// The Index encoder needs just one small data structure so we can
// allocate it on stack.
+ lzma_index_coder coder;
index_encoder_reset(&coder, i);
// Do the actual encoding. This should never fail, but store
// the original *out_pos just in case.
- out_start = *out_pos;
- ret = index_encode(&coder, NULL, NULL, NULL, 0,
+ const size_t out_start = *out_pos;
+ lzma_ret ret = index_encode(&coder, NULL, NULL, NULL, 0,
out, out_pos, out_size, LZMA_RUN);
if (ret == LZMA_STREAM_END) {
diff --git a/Utilities/cmliblzma/liblzma/common/index_encoder.h b/Utilities/cmliblzma/liblzma/common/index_encoder.h
index a13c94dcd..4d55cd104 100644
--- a/Utilities/cmliblzma/liblzma/common/index_encoder.h
+++ b/Utilities/cmliblzma/liblzma/common/index_encoder.h
@@ -17,7 +17,7 @@
extern lzma_ret lzma_index_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_index *i);
+ const lzma_allocator *allocator, const lzma_index *i);
#endif
diff --git a/Utilities/cmliblzma/liblzma/common/index_hash.c b/Utilities/cmliblzma/liblzma/common/index_hash.c
index 0cf86b307..d7a0344b7 100644
--- a/Utilities/cmliblzma/liblzma/common/index_hash.c
+++ b/Utilities/cmliblzma/liblzma/common/index_hash.c
@@ -70,7 +70,8 @@ struct lzma_index_hash_s {
extern LZMA_API(lzma_index_hash *)
-lzma_index_hash_init(lzma_index_hash *index_hash, lzma_allocator *allocator)
+lzma_index_hash_init(lzma_index_hash *index_hash,
+ const lzma_allocator *allocator)
{
if (index_hash == NULL) {
index_hash = lzma_alloc(sizeof(lzma_index_hash), allocator);
@@ -101,7 +102,8 @@ lzma_index_hash_init(lzma_index_hash *index_hash, lzma_allocator *allocator)
extern LZMA_API(void)
-lzma_index_hash_end(lzma_index_hash *index_hash, lzma_allocator *allocator)
+lzma_index_hash_end(lzma_index_hash *index_hash,
+ const lzma_allocator *allocator)
{
lzma_free(index_hash, allocator);
return;
@@ -124,14 +126,13 @@ static lzma_ret
hash_append(lzma_index_hash_info *info, lzma_vli unpadded_size,
lzma_vli uncompressed_size)
{
- const lzma_vli sizes[2] = { unpadded_size, uncompressed_size };
-
info->blocks_size += vli_ceil4(unpadded_size);
info->uncompressed_size += uncompressed_size;
info->index_list_size += lzma_vli_size(unpadded_size)
+ lzma_vli_size(uncompressed_size);
++info->count;
+ const lzma_vli sizes[2] = { unpadded_size, uncompressed_size };
lzma_check_update(&info->check, LZMA_CHECK_BEST,
(const uint8_t *)(sizes), sizeof(sizes));
@@ -174,9 +175,6 @@ extern LZMA_API(lzma_ret)
lzma_index_hash_decode(lzma_index_hash *index_hash, const uint8_t *in,
size_t *in_pos, size_t in_size)
{
- size_t in_start;
- lzma_ret ret;
-
// Catch zero input buffer here, because in contrast to Index encoder
// and decoder functions, applications call this function directly
// instead of via lzma_code(), which does the buffer checking.
@@ -186,8 +184,8 @@ lzma_index_hash_decode(lzma_index_hash *index_hash, const uint8_t *in,
// NOTE: This function has many similarities to index_encode() and
// index_decode() functions found from index_encoder.c and
// index_decoder.c. See the comments especially in index_encoder.c.
- in_start = *in_pos;
- ret = LZMA_OK;
+ const size_t in_start = *in_pos;
+ lzma_ret ret = LZMA_OK;
while (*in_pos < in_size)
switch (index_hash->sequence) {
diff --git a/Utilities/cmliblzma/liblzma/common/memcmplen.h b/Utilities/cmliblzma/liblzma/common/memcmplen.h
new file mode 100644
index 000000000..c1efc9e28
--- /dev/null
+++ b/Utilities/cmliblzma/liblzma/common/memcmplen.h
@@ -0,0 +1,175 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+/// \file memcmplen.h
+/// \brief Optimized comparison of two buffers
+//
+// Author: Lasse Collin
+//
+// This file has been put into the public domain.
+// You can do whatever you want with this file.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef LZMA_MEMCMPLEN_H
+#define LZMA_MEMCMPLEN_H
+
+#include "common.h"
+
+#ifdef HAVE_IMMINTRIN_H
+# include <immintrin.h>
+#endif
+
+
+/// Find out how many equal bytes the two buffers have.
+///
+/// \param buf1 First buffer
+/// \param buf2 Second buffer
+/// \param len How many bytes have already been compared and will
+/// be assumed to match
+/// \param limit How many bytes to compare at most, including the
+/// already-compared bytes. This must be significantly
+/// smaller than UINT32_MAX to avoid integer overflows.
+/// Up to LZMA_MEMCMPLEN_EXTRA bytes may be read past
+/// the specified limit from both buf1 and buf2.
+///
+/// \return Number of equal bytes in the buffers is returned.
+/// This is always at least len and at most limit.
+///
+/// \note LZMA_MEMCMPLEN_EXTRA defines how many extra bytes may be read.
+/// It's rounded up to 2^n. This extra amount needs to be
+/// allocated in the buffers being used. It needs to be
+/// initialized too to keep Valgrind quiet.
+static inline uint32_t lzma_attribute((__always_inline__))
+lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2,
+ uint32_t len, uint32_t limit)
+{
+ assert(len <= limit);
+ assert(limit <= UINT32_MAX / 2);
+
+#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \
+ && ((TUKLIB_GNUC_REQ(3, 4) && defined(__x86_64__)) \
+ || (defined(__INTEL_COMPILER) && defined(__x86_64__)) \
+ || (defined(__INTEL_COMPILER) && defined(_M_X64)) \
+ || (defined(_MSC_VER) && defined(_M_X64)))
+ // NOTE: This will use 64-bit unaligned access which
+ // TUKLIB_FAST_UNALIGNED_ACCESS wasn't meant to permit, but
+ // it's convenient here at least as long as it's x86-64 only.
+ //
+ // I keep this x86-64 only for now since that's where I know this
+ // to be a good method. This may be fine on other 64-bit CPUs too.
+ // On big endian one should use xor instead of subtraction and switch
+ // to __builtin_clzll().
+#define LZMA_MEMCMPLEN_EXTRA 8
+ while (len < limit) {
+ const uint64_t x = *(const uint64_t *)(buf1 + len)
+ - *(const uint64_t *)(buf2 + len);
+ if (x != 0) {
+# if defined(_M_X64) // MSVC or Intel C compiler on Windows
+ unsigned long tmp;
+ _BitScanForward64(&tmp, x);
+ len += (uint32_t)tmp >> 3;
+# else // GCC, clang, or Intel C compiler
+ len += (uint32_t)__builtin_ctzll(x) >> 3;
+# endif
+ return my_min(len, limit);
+ }
+
+ len += 8;
+ }
+
+ return limit;
+
+#elif defined(TUKLIB_FAST_UNALIGNED_ACCESS) \
+ && defined(HAVE__MM_MOVEMASK_EPI8) \
+ && ((defined(__GNUC__) && defined(__SSE2_MATH__)) \
+ || (defined(__INTEL_COMPILER) && defined(__SSE2__)) \
+ || (defined(_MSC_VER) && defined(_M_IX86_FP) \
+ && _M_IX86_FP >= 2))
+ // NOTE: Like above, this will use 128-bit unaligned access which
+ // TUKLIB_FAST_UNALIGNED_ACCESS wasn't meant to permit.
+ //
+ // SSE2 version for 32-bit and 64-bit x86. On x86-64 the above
+ // version is sometimes significantly faster and sometimes
+ // slightly slower than this SSE2 version, so this SSE2
+ // version isn't used on x86-64.
+# define LZMA_MEMCMPLEN_EXTRA 16
+ while (len < limit) {
+ const uint32_t x = 0xFFFF ^ _mm_movemask_epi8(_mm_cmpeq_epi8(
+ _mm_loadu_si128((const __m128i *)(buf1 + len)),
+ _mm_loadu_si128((const __m128i *)(buf2 + len))));
+
+ if (x != 0) {
+# if defined(__INTEL_COMPILER)
+ len += _bit_scan_forward(x);
+# elif defined(_MSC_VER)
+ unsigned long tmp;
+ _BitScanForward(&tmp, x);
+ len += tmp;
+# else
+ len += __builtin_ctz(x);
+# endif
+ return my_min(len, limit);
+ }
+
+ len += 16;
+ }
+
+ return limit;
+
+#elif defined(TUKLIB_FAST_UNALIGNED_ACCESS) && !defined(WORDS_BIGENDIAN)
+ // Generic 32-bit little endian method
+# define LZMA_MEMCMPLEN_EXTRA 4
+ while (len < limit) {
+ uint32_t x = *(const uint32_t *)(buf1 + len)
+ - *(const uint32_t *)(buf2 + len);
+ if (x != 0) {
+ if ((x & 0xFFFF) == 0) {
+ len += 2;
+ x >>= 16;
+ }
+
+ if ((x & 0xFF) == 0)
+ ++len;
+
+ return my_min(len, limit);
+ }
+
+ len += 4;
+ }
+
+ return limit;
+
+#elif defined(TUKLIB_FAST_UNALIGNED_ACCESS) && defined(WORDS_BIGENDIAN)
+ // Generic 32-bit big endian method
+# define LZMA_MEMCMPLEN_EXTRA 4
+ while (len < limit) {
+ uint32_t x = *(const uint32_t *)(buf1 + len)
+ ^ *(const uint32_t *)(buf2 + len);
+ if (x != 0) {
+ if ((x & 0xFFFF0000) == 0) {
+ len += 2;
+ x <<= 16;
+ }
+
+ if ((x & 0xFF000000) == 0)
+ ++len;
+
+ return my_min(len, limit);
+ }
+
+ len += 4;
+ }
+
+ return limit;
+
+#else
+ // Simple portable version that doesn't use unaligned access.
+# define LZMA_MEMCMPLEN_EXTRA 0
+ while (len < limit && buf1[len] == buf2[len])
+ ++len;
+
+ return len;
+#endif
+}
+
+#endif
diff --git a/Utilities/cmliblzma/liblzma/common/outqueue.c b/Utilities/cmliblzma/liblzma/common/outqueue.c
new file mode 100644
index 000000000..2dc8a38d1
--- /dev/null
+++ b/Utilities/cmliblzma/liblzma/common/outqueue.c
@@ -0,0 +1,184 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+/// \file outqueue.c
+/// \brief Output queue handling in multithreaded coding
+//
+// Author: Lasse Collin
+//
+// This file has been put into the public domain.
+// You can do whatever you want with this file.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include "outqueue.h"
+
+
+/// This is to ease integer overflow checking: We may allocate up to
+/// 2 * LZMA_THREADS_MAX buffers and we need some extra memory for other
+/// data structures (that's the second /2).
+#define BUF_SIZE_MAX (UINT64_MAX / LZMA_THREADS_MAX / 2 / 2)
+
+
+static lzma_ret
+get_options(uint64_t *bufs_alloc_size, uint32_t *bufs_count,
+ uint64_t buf_size_max, uint32_t threads)
+{
+ if (threads > LZMA_THREADS_MAX || buf_size_max > BUF_SIZE_MAX)
+ return LZMA_OPTIONS_ERROR;
+
+ // The number of buffers is twice the number of threads.
+ // This wastes RAM but keeps the threads busy when buffers
+ // finish out of order.
+ //
+ // NOTE: If this is changed, update BUF_SIZE_MAX too.
+ *bufs_count = threads * 2;
+ *bufs_alloc_size = *bufs_count * buf_size_max;
+
+ return LZMA_OK;
+}
+
+
+extern uint64_t
+lzma_outq_memusage(uint64_t buf_size_max, uint32_t threads)
+{
+ uint64_t bufs_alloc_size;
+ uint32_t bufs_count;
+
+ if (get_options(&bufs_alloc_size, &bufs_count, buf_size_max, threads)
+ != LZMA_OK)
+ return UINT64_MAX;
+
+ return sizeof(lzma_outq) + bufs_count * sizeof(lzma_outbuf)
+ + bufs_alloc_size;
+}
+
+
+extern lzma_ret
+lzma_outq_init(lzma_outq *outq, const lzma_allocator *allocator,
+ uint64_t buf_size_max, uint32_t threads)
+{
+ uint64_t bufs_alloc_size;
+ uint32_t bufs_count;
+
+ // Set bufs_count and bufs_alloc_size.
+ return_if_error(get_options(&bufs_alloc_size, &bufs_count,
+ buf_size_max, threads));
+
+ // Allocate memory if needed.
+ if (outq->buf_size_max != buf_size_max
+ || outq->bufs_allocated != bufs_count) {
+ lzma_outq_end(outq, allocator);
+
+#if SIZE_MAX < UINT64_MAX
+ if (bufs_alloc_size > SIZE_MAX)
+ return LZMA_MEM_ERROR;
+#endif
+
+ outq->bufs = lzma_alloc(bufs_count * sizeof(lzma_outbuf),
+ allocator);
+ outq->bufs_mem = lzma_alloc((size_t)(bufs_alloc_size),
+ allocator);
+
+ if (outq->bufs == NULL || outq->bufs_mem == NULL) {
+ lzma_outq_end(outq, allocator);
+ return LZMA_MEM_ERROR;
+ }
+ }
+
+ // Initialize the rest of the main structure. Initialization of
+ // outq->bufs[] is done when they are actually needed.
+ outq->buf_size_max = (size_t)(buf_size_max);
+ outq->bufs_allocated = bufs_count;
+ outq->bufs_pos = 0;
+ outq->bufs_used = 0;
+ outq->read_pos = 0;
+
+ return LZMA_OK;
+}
+
+
+extern void
+lzma_outq_end(lzma_outq *outq, const lzma_allocator *allocator)
+{
+ lzma_free(outq->bufs, allocator);
+ outq->bufs = NULL;
+
+ lzma_free(outq->bufs_mem, allocator);
+ outq->bufs_mem = NULL;
+
+ return;
+}
+
+
+extern lzma_outbuf *
+lzma_outq_get_buf(lzma_outq *outq)
+{
+ // Caller must have checked it with lzma_outq_has_buf().
+ assert(outq->bufs_used < outq->bufs_allocated);
+
+ // Initialize the new buffer.
+ lzma_outbuf *buf = &outq->bufs[outq->bufs_pos];
+ buf->buf = outq->bufs_mem + outq->bufs_pos * outq->buf_size_max;
+ buf->size = 0;
+ buf->finished = false;
+
+ // Update the queue state.
+ if (++outq->bufs_pos == outq->bufs_allocated)
+ outq->bufs_pos = 0;
+
+ ++outq->bufs_used;
+
+ return buf;
+}
+
+
+extern bool
+lzma_outq_is_readable(const lzma_outq *outq)
+{
+ uint32_t i = outq->bufs_pos - outq->bufs_used;
+ if (outq->bufs_pos < outq->bufs_used)
+ i += outq->bufs_allocated;
+
+ return outq->bufs[i].finished;
+}
+
+
+extern lzma_ret
+lzma_outq_read(lzma_outq *restrict outq, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size,
+ lzma_vli *restrict unpadded_size,
+ lzma_vli *restrict uncompressed_size)
+{
+ // There must be at least one buffer from which to read.
+ if (outq->bufs_used == 0)
+ return LZMA_OK;
+
+ // Get the buffer.
+ uint32_t i = outq->bufs_pos - outq->bufs_used;
+ if (outq->bufs_pos < outq->bufs_used)
+ i += outq->bufs_allocated;
+
+ lzma_outbuf *buf = &outq->bufs[i];
+
+ // If it isn't finished yet, we cannot read from it.
+ if (!buf->finished)
+ return LZMA_OK;
+
+ // Copy from the buffer to output.
+ lzma_bufcpy(buf->buf, &outq->read_pos, buf->size,
+ out, out_pos, out_size);
+
+ // Return if we didn't get all the data from the buffer.
+ if (outq->read_pos < buf->size)
+ return LZMA_OK;
+
+ // The buffer was finished. Tell the caller its size information.
+ *unpadded_size = buf->unpadded_size;
+ *uncompressed_size = buf->uncompressed_size;
+
+ // Free this buffer for further use.
+ --outq->bufs_used;
+ outq->read_pos = 0;
+
+ return LZMA_STREAM_END;
+}
diff --git a/Utilities/cmliblzma/liblzma/common/outqueue.h b/Utilities/cmliblzma/liblzma/common/outqueue.h
new file mode 100644
index 000000000..079634de4
--- /dev/null
+++ b/Utilities/cmliblzma/liblzma/common/outqueue.h
@@ -0,0 +1,156 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+/// \file outqueue.h
+/// \brief Output queue handling in multithreaded coding
+//
+// Author: Lasse Collin
+//
+// This file has been put into the public domain.
+// You can do whatever you want with this file.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include "common.h"
+
+
+/// Output buffer for a single thread
+typedef struct {
+ /// Pointer to the output buffer of lzma_outq.buf_size_max bytes
+ uint8_t *buf;
+
+ /// Amount of data written to buf
+ size_t size;
+
+ /// Additional size information
+ lzma_vli unpadded_size;
+ lzma_vli uncompressed_size;
+
+ /// True when no more data will be written into this buffer.
+ ///
+ /// \note This is read by another thread and thus access
+ /// to this variable needs a mutex.
+ bool finished;
+
+} lzma_outbuf;
+
+
+typedef struct {
+ /// Array of buffers that are used cyclically.
+ lzma_outbuf *bufs;
+
+ /// Memory allocated for all the buffers
+ uint8_t *bufs_mem;
+
+ /// Amount of buffer space available in each buffer
+ size_t buf_size_max;
+
+ /// Number of buffers allocated
+ uint32_t bufs_allocated;
+
+ /// Position in the bufs array. The next buffer to be taken
+ /// into use is bufs[bufs_pos].
+ uint32_t bufs_pos;
+
+ /// Number of buffers in use
+ uint32_t bufs_used;
+
+ /// Position in the buffer in lzma_outq_read()
+ size_t read_pos;
+
+} lzma_outq;
+
+
+/**
+ * \brief Calculate the memory usage of an output queue
+ *
+ * \return Approximate memory usage in bytes or UINT64_MAX on error.
+ */
+extern uint64_t lzma_outq_memusage(uint64_t buf_size_max, uint32_t threads);
+
+
+/// \brief Initialize an output queue
+///
+/// \param outq Pointer to an output queue. Before calling
+/// this function the first time, *outq should
+/// have been zeroed with memzero() so that this
+/// function knows that there are no previous
+/// allocations to free.
+/// \param allocator Pointer to allocator or NULL
+/// \param buf_size_max Maximum amount of data that a single buffer
+/// in the queue may need to store.
+/// \param threads Number of buffers that may be in use
+/// concurrently. Note that more than this number
+/// of buffers will actually get allocated to
+/// improve performance when buffers finish
+/// out of order.
+///
+/// \return - LZMA_OK
+/// - LZMA_MEM_ERROR
+///
+extern lzma_ret lzma_outq_init(
+ lzma_outq *outq, const lzma_allocator *allocator,
+ uint64_t buf_size_max, uint32_t threads);
+
+
+/// \brief Free the memory associated with the output queue
+extern void lzma_outq_end(lzma_outq *outq, const lzma_allocator *allocator);
+
+
+/// \brief Get a new buffer
+///
+/// lzma_outq_has_buf() must be used to check that there is a buffer
+/// available before calling lzma_outq_get_buf().
+///
+extern lzma_outbuf *lzma_outq_get_buf(lzma_outq *outq);
+
+
+/// \brief Test if there is data ready to be read
+///
+/// Call to this function must be protected with the same mutex that
+/// is used to protect lzma_outbuf.finished.
+///
+extern bool lzma_outq_is_readable(const lzma_outq *outq);
+
+
+/// \brief Read finished data
+///
+/// \param outq Pointer to an output queue
+/// \param out Beginning of the output buffer
+/// \param out_pos The next byte will be written to
+/// out[*out_pos].
+/// \param out_size Size of the out buffer; the first byte into
+/// which no data is written to is out[out_size].
+/// \param unpadded_size Unpadded Size from the Block encoder
+/// \param uncompressed_size Uncompressed Size from the Block encoder
+///
+/// \return - LZMA: All OK. Either no data was available or the buffer
+/// being read didn't become empty yet.
+/// - LZMA_STREAM_END: The buffer being read was finished.
+/// *unpadded_size and *uncompressed_size were set.
+///
+/// \note This reads lzma_outbuf.finished variables and thus call
+/// to this function needs to be protected with a mutex.
+///
+extern lzma_ret lzma_outq_read(lzma_outq *restrict outq,
+ uint8_t *restrict out, size_t *restrict out_pos,
+ size_t out_size, lzma_vli *restrict unpadded_size,
+ lzma_vli *restrict uncompressed_size);
+
+
+/// \brief Test if there is at least one buffer free
+///
+/// This must be used before getting a new buffer with lzma_outq_get_buf().
+///
+static inline bool
+lzma_outq_has_buf(const lzma_outq *outq)
+{
+ return outq->bufs_used < outq->bufs_allocated;
+}
+
+
+/// \brief Test if the queue is completely empty
+static inline bool
+lzma_outq_is_empty(const lzma_outq *outq)
+{
+ return outq->bufs_used == 0;
+}
diff --git a/Utilities/cmliblzma/liblzma/common/stream_buffer_decoder.c b/Utilities/cmliblzma/liblzma/common/stream_buffer_decoder.c
index 9e2e1da83..b9745b5db 100644
--- a/Utilities/cmliblzma/liblzma/common/stream_buffer_decoder.c
+++ b/Utilities/cmliblzma/liblzma/common/stream_buffer_decoder.c
@@ -15,13 +15,10 @@
extern LZMA_API(lzma_ret)
lzma_stream_buffer_decode(uint64_t *memlimit, uint32_t flags,
- lzma_allocator *allocator,
+ const lzma_allocator *allocator,
const uint8_t *in, size_t *in_pos, size_t in_size,
uint8_t *out, size_t *out_pos, size_t out_size)
{
- lzma_next_coder stream_decoder = LZMA_NEXT_CODER_INIT;
- lzma_ret ret;
-
// Sanity checks
if (in_pos == NULL || (in == NULL && *in_pos != in_size)
|| *in_pos > in_size || out_pos == NULL
@@ -36,7 +33,8 @@ lzma_stream_buffer_decode(uint64_t *memlimit, uint32_t flags,
// Initialize the Stream decoder.
// TODO: We need something to tell the decoder that it can use the
// output buffer as workspace, and thus save significant amount of RAM.
- ret = lzma_stream_decoder_init(
+ lzma_next_coder stream_decoder = LZMA_NEXT_CODER_INIT;
+ lzma_ret ret = lzma_stream_decoder_init(
&stream_decoder, allocator, *memlimit, flags);
if (ret == LZMA_OK) {
diff --git a/Utilities/cmliblzma/liblzma/common/stream_buffer_encoder.c b/Utilities/cmliblzma/liblzma/common/stream_buffer_encoder.c
index 8bca87f47..af49554a6 100644
--- a/Utilities/cmliblzma/liblzma/common/stream_buffer_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/stream_buffer_encoder.c
@@ -42,13 +42,10 @@ lzma_stream_buffer_bound(size_t uncompressed_size)
extern LZMA_API(lzma_ret)
lzma_stream_buffer_encode(lzma_filter *filters, lzma_check check,
- lzma_allocator *allocator, const uint8_t *in, size_t in_size,
+ const lzma_allocator *allocator,
+ const uint8_t *in, size_t in_size,
uint8_t *out, size_t *out_pos_ptr, size_t out_size)
{
- lzma_stream_flags stream_flags = { 0 };
- lzma_block block = { 0 };
- size_t out_pos;
-
// Sanity checks
if (filters == NULL || (unsigned int)(check) > LZMA_CHECK_ID_MAX
|| (in == NULL && in_size != 0) || out == NULL
@@ -65,7 +62,7 @@ lzma_stream_buffer_encode(lzma_filter *filters, lzma_check check,
// Use a local copy. We update *out_pos_ptr only if everything
// succeeds.
- out_pos = *out_pos_ptr;
+ size_t out_pos = *out_pos_ptr;
// Check that there's enough space for both Stream Header and
// Stream Footer.
@@ -77,7 +74,10 @@ lzma_stream_buffer_encode(lzma_filter *filters, lzma_check check,
out_size -= LZMA_STREAM_HEADER_SIZE;
// Encode the Stream Header.
- stream_flags.check = check;
+ lzma_stream_flags stream_flags = {
+ .version = 0,
+ .check = check,
+ };
if (lzma_stream_header_encode(&stream_flags, out + out_pos)
!= LZMA_OK)
@@ -86,8 +86,11 @@ lzma_stream_buffer_encode(lzma_filter *filters, lzma_check check,
out_pos += LZMA_STREAM_HEADER_SIZE;
// Encode a Block but only if there is at least one byte of input.
- block.check = check;
- block.filters = filters;
+ lzma_block block = {
+ .version = 0,
+ .check = check,
+ .filters = filters,
+ };
if (in_size > 0)
return_if_error(lzma_block_buffer_encode(&block, allocator,
@@ -95,8 +98,6 @@ lzma_stream_buffer_encode(lzma_filter *filters, lzma_check check,
// Index
{
- lzma_ret ret;
-
// Create an Index. It will have one Record if there was
// at least one byte of input to encode. Otherwise the
// Index will be empty.
@@ -104,7 +105,7 @@ lzma_stream_buffer_encode(lzma_filter *filters, lzma_check check,
if (i == NULL)
return LZMA_MEM_ERROR;
- ret = LZMA_OK;
+ lzma_ret ret = LZMA_OK;
if (in_size > 0)
ret = lzma_index_append(i, allocator,
diff --git a/Utilities/cmliblzma/liblzma/common/stream_decoder.c b/Utilities/cmliblzma/liblzma/common/stream_decoder.c
index 5e9a22069..fdd8ff2f9 100644
--- a/Utilities/cmliblzma/liblzma/common/stream_decoder.c
+++ b/Utilities/cmliblzma/liblzma/common/stream_decoder.c
@@ -14,7 +14,7 @@
#include "block_decoder.h"
-struct lzma_coder_s {
+typedef struct {
enum {
SEQ_STREAM_HEADER,
SEQ_BLOCK_HEADER,
@@ -57,6 +57,10 @@ struct lzma_coder_s {
/// If true, LZMA_GET_CHECK is returned after decoding Stream Header.
bool tell_any_check;
+ /// If true, we will tell the Block decoder to skip calculating
+ /// and verifying the integrity check.
+ bool ignore_check;
+
/// If true, we will decode concatenated Streams that possibly have
/// Stream Padding between or after them. LZMA_STREAM_END is returned
/// once the application isn't giving us any new input, and we aren't
@@ -76,11 +80,11 @@ struct lzma_coder_s {
/// Buffer to hold Stream Header, Block Header, and Stream Footer.
/// Block Header has biggest maximum size.
uint8_t buffer[LZMA_BLOCK_HEADER_SIZE_MAX];
-};
+} lzma_stream_coder;
static lzma_ret
-stream_decoder_reset(lzma_coder *coder, lzma_allocator *allocator)
+stream_decoder_reset(lzma_stream_coder *coder, const lzma_allocator *allocator)
{
// Initialize the Index hash used to verify the Index.
coder->index_hash = lzma_index_hash_init(coder->index_hash, allocator);
@@ -96,18 +100,18 @@ stream_decoder_reset(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
-stream_decode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size, lzma_action action)
+stream_decode(void *coder_ptr, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size, lzma_action action)
{
+ lzma_stream_coder *coder = coder_ptr;
+
// When decoding the actual Block, it may be able to produce more
// output even if we don't give it any new input.
while (true)
switch (coder->sequence) {
case SEQ_STREAM_HEADER: {
- lzma_ret ret;
-
// Copy the Stream Header to the internal buffer.
lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,
LZMA_STREAM_HEADER_SIZE);
@@ -119,7 +123,7 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator,
coder->pos = 0;
// Decode the Stream Header.
- ret = lzma_stream_header_decode(
+ const lzma_ret ret = lzma_stream_header_decode(
&coder->stream_flags, coder->buffer);
if (ret != LZMA_OK)
return ret == LZMA_FORMAT_ERROR && !coder->first_stream
@@ -156,11 +160,6 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator,
// Fall through
case SEQ_BLOCK_HEADER: {
- lzma_filter filters[LZMA_FILTERS_MAX + 1];
- uint64_t memusage;
- lzma_ret ret;
- size_t i;
-
if (*in_pos >= in_size)
return LZMA_OK;
@@ -189,20 +188,28 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator,
coder->pos = 0;
- // Version 0 is currently the only possible version.
- coder->block_options.version = 0;
+ // Version 1 is needed to support the .ignore_check option.
+ coder->block_options.version = 1;
// Set up a buffer to hold the filter chain. Block Header
// decoder will initialize all members of this array so
// we don't need to do it here.
+ lzma_filter filters[LZMA_FILTERS_MAX + 1];
coder->block_options.filters = filters;
// Decode the Block Header.
return_if_error(lzma_block_header_decode(&coder->block_options,
allocator, coder->buffer));
+ // If LZMA_IGNORE_CHECK was used, this flag needs to be set.
+ // It has to be set after lzma_block_header_decode() because
+ // it always resets this to false.
+ coder->block_options.ignore_check = coder->ignore_check;
+
// Check the memory usage limit.
- memusage = lzma_raw_decoder_memusage(filters);
+ const uint64_t memusage = lzma_raw_decoder_memusage(filters);
+ lzma_ret ret;
+
if (memusage == UINT64_MAX) {
// One or more unknown Filter IDs.
ret = LZMA_OPTIONS_ERROR;
@@ -228,7 +235,7 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator,
// Free the allocated filter options since they are needed
// only to initialize the Block decoder.
- for (i = 0; i < LZMA_FILTERS_MAX; ++i)
+ for (size_t i = 0; i < LZMA_FILTERS_MAX; ++i)
lzma_free(filters[i].options, allocator);
coder->block_options.filters = NULL;
@@ -264,8 +271,6 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator,
}
case SEQ_INDEX: {
- lzma_ret ret;
-
// If we don't have any input, don't call
// lzma_index_hash_decode() since it would return
// LZMA_BUF_ERROR, which we must not do here.
@@ -274,7 +279,7 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator,
// Decode the Index and compare it to the hash calculated
// from the sizes of the Blocks (if any).
- ret = lzma_index_hash_decode(coder->index_hash,
+ const lzma_ret ret = lzma_index_hash_decode(coder->index_hash,
in, in_pos, in_size);
if (ret != LZMA_STREAM_END)
return ret;
@@ -285,9 +290,6 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator,
// Fall through
case SEQ_STREAM_FOOTER: {
- lzma_stream_flags footer_flags;
- lzma_ret ret;
-
// Copy the Stream Footer to the internal buffer.
lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,
LZMA_STREAM_HEADER_SIZE);
@@ -301,7 +303,8 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator,
// Decode the Stream Footer. The decoder gives
// LZMA_FORMAT_ERROR if the magic bytes don't match,
// so convert that return code to LZMA_DATA_ERROR.
- ret = lzma_stream_footer_decode(
+ lzma_stream_flags footer_flags;
+ const lzma_ret ret = lzma_stream_footer_decode(
&footer_flags, coder->buffer);
if (ret != LZMA_OK)
return ret == LZMA_FORMAT_ERROR
@@ -374,8 +377,9 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator,
static void
-stream_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
+stream_decoder_end(void *coder_ptr, const lzma_allocator *allocator)
{
+ lzma_stream_coder *coder = coder_ptr;
lzma_next_end(&coder->block_decoder, allocator);
lzma_index_hash_end(coder->index_hash, allocator);
lzma_free(coder, allocator);
@@ -384,16 +388,19 @@ stream_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_check
-stream_decoder_get_check(const lzma_coder *coder)
+stream_decoder_get_check(const void *coder_ptr)
{
+ const lzma_stream_coder *coder = coder_ptr;
return coder->stream_flags.check;
}
static lzma_ret
-stream_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
+stream_decoder_memconfig(void *coder_ptr, uint64_t *memusage,
uint64_t *old_memlimit, uint64_t new_memlimit)
{
+ lzma_stream_coder *coder = coder_ptr;
+
*memusage = coder->memusage;
*old_memlimit = coder->memlimit;
@@ -409,48 +416,49 @@ stream_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
extern lzma_ret
-lzma_stream_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_stream_decoder_init(
+ lzma_next_coder *next, const lzma_allocator *allocator,
uint64_t memlimit, uint32_t flags)
{
lzma_next_coder_init(&lzma_stream_decoder_init, next, allocator);
- if (memlimit == 0)
- return LZMA_PROG_ERROR;
-
if (flags & ~LZMA_SUPPORTED_FLAGS)
return LZMA_OPTIONS_ERROR;
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
+ lzma_stream_coder *coder = next->coder;
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_stream_coder), allocator);
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ next->coder = coder;
next->code = &stream_decode;
next->end = &stream_decoder_end;
next->get_check = &stream_decoder_get_check;
next->memconfig = &stream_decoder_memconfig;
- next->coder->block_decoder = LZMA_NEXT_CODER_INIT;
- next->coder->index_hash = NULL;
+ coder->block_decoder = LZMA_NEXT_CODER_INIT;
+ coder->index_hash = NULL;
}
- next->coder->memlimit = memlimit;
- next->coder->memusage = LZMA_MEMUSAGE_BASE;
- next->coder->tell_no_check = (flags & LZMA_TELL_NO_CHECK) != 0;
- next->coder->tell_unsupported_check
+ coder->memlimit = my_max(1, memlimit);
+ coder->memusage = LZMA_MEMUSAGE_BASE;
+ coder->tell_no_check = (flags & LZMA_TELL_NO_CHECK) != 0;
+ coder->tell_unsupported_check
= (flags & LZMA_TELL_UNSUPPORTED_CHECK) != 0;
- next->coder->tell_any_check = (flags & LZMA_TELL_ANY_CHECK) != 0;
- next->coder->concatenated = (flags & LZMA_CONCATENATED) != 0;
- next->coder->first_stream = true;
+ coder->tell_any_check = (flags & LZMA_TELL_ANY_CHECK) != 0;
+ coder->ignore_check = (flags & LZMA_IGNORE_CHECK) != 0;
+ coder->concatenated = (flags & LZMA_CONCATENATED) != 0;
+ coder->first_stream = true;
- return stream_decoder_reset(next->coder, allocator);
+ return stream_decoder_reset(coder, allocator);
}
extern LZMA_API(lzma_ret)
lzma_stream_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags)
{
- lzma_next_strm_init2(lzma_stream_decoder_init, strm, memlimit, flags);
+ lzma_next_strm_init(lzma_stream_decoder_init, strm, memlimit, flags);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff --git a/Utilities/cmliblzma/liblzma/common/stream_decoder.h b/Utilities/cmliblzma/liblzma/common/stream_decoder.h
index e54ac28f4..c13c6ba12 100644
--- a/Utilities/cmliblzma/liblzma/common/stream_decoder.h
+++ b/Utilities/cmliblzma/liblzma/common/stream_decoder.h
@@ -15,7 +15,8 @@
#include "common.h"
-extern lzma_ret lzma_stream_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, uint64_t memlimit, uint32_t flags);
+extern lzma_ret lzma_stream_decoder_init(
+ lzma_next_coder *next, const lzma_allocator *allocator,
+ uint64_t memlimit, uint32_t flags);
#endif
diff --git a/Utilities/cmliblzma/liblzma/common/stream_encoder.c b/Utilities/cmliblzma/liblzma/common/stream_encoder.c
index 1ba45acec..858cba473 100644
--- a/Utilities/cmliblzma/liblzma/common/stream_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/stream_encoder.c
@@ -10,12 +10,11 @@
//
///////////////////////////////////////////////////////////////////////////////
-#include "stream_encoder.h"
#include "block_encoder.h"
#include "index_encoder.h"
-struct lzma_coder_s {
+typedef struct {
enum {
SEQ_STREAM_HEADER,
SEQ_BLOCK_INIT,
@@ -26,7 +25,7 @@ struct lzma_coder_s {
} sequence;
/// True if Block encoder has been initialized by
- /// lzma_stream_encoder_init() or stream_encoder_update()
+ /// stream_encoder_init() or stream_encoder_update()
/// and thus doesn't need to be initialized in stream_encode().
bool block_encoder_is_initialized;
@@ -56,11 +55,11 @@ struct lzma_coder_s {
/// Buffer to hold Stream Header, Block Header, and Stream Footer.
/// Block Header has biggest maximum size.
uint8_t buffer[LZMA_BLOCK_HEADER_SIZE_MAX];
-};
+} lzma_stream_coder;
static lzma_ret
-block_encoder_init(lzma_coder *coder, lzma_allocator *allocator)
+block_encoder_init(lzma_stream_coder *coder, const lzma_allocator *allocator)
{
// Prepare the Block options. Even though Block encoder doesn't need
// compressed_size, uncompressed_size, and header_size to be
@@ -79,11 +78,13 @@ block_encoder_init(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
-stream_encode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size, lzma_action action)
+stream_encode(void *coder_ptr, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size, lzma_action action)
{
+ lzma_stream_coder *coder = coder_ptr;
+
// Main loop
while (*out_pos < out_size)
switch (coder->sequence) {
@@ -126,7 +127,7 @@ stream_encode(lzma_coder *coder, lzma_allocator *allocator,
}
// Initialize the Block encoder unless it was already
- // initialized by lzma_stream_encoder_init() or
+ // initialized by stream_encoder_init() or
// stream_encoder_update().
if (!coder->block_encoder_is_initialized)
return_if_error(block_encoder_init(coder, allocator));
@@ -147,13 +148,12 @@ stream_encode(lzma_coder *coder, lzma_allocator *allocator,
}
case SEQ_BLOCK_ENCODE: {
- lzma_vli unpadded_size;
-
- static const lzma_action convert[4] = {
+ static const lzma_action convert[LZMA_ACTION_MAX + 1] = {
LZMA_RUN,
LZMA_SYNC_FLUSH,
LZMA_FINISH,
LZMA_FINISH,
+ LZMA_FINISH,
};
const lzma_ret ret = coder->block_encoder.code(
@@ -164,7 +164,7 @@ stream_encode(lzma_coder *coder, lzma_allocator *allocator,
return ret;
// Add a new Index Record.
- unpadded_size = lzma_block_unpadded_size(
+ const lzma_vli unpadded_size = lzma_block_unpadded_size(
&coder->block_options);
assert(unpadded_size != 0);
return_if_error(lzma_index_append(coder->index, allocator,
@@ -176,12 +176,6 @@ stream_encode(lzma_coder *coder, lzma_allocator *allocator,
}
case SEQ_INDEX_ENCODE: {
- const lzma_stream_flags stream_flags = {
- 0,
- lzma_index_size(coder->index),
- coder->block_options.check,
- };
-
// Call the Index encoder. It doesn't take any input, so
// those pointers can be NULL.
const lzma_ret ret = coder->index_encoder.code(
@@ -192,6 +186,11 @@ stream_encode(lzma_coder *coder, lzma_allocator *allocator,
return ret;
// Encode the Stream Footer into coder->buffer.
+ const lzma_stream_flags stream_flags = {
+ .version = 0,
+ .backward_size = lzma_index_size(coder->index),
+ .check = coder->block_options.check,
+ };
if (lzma_stream_footer_encode(&stream_flags, coder->buffer)
!= LZMA_OK)
@@ -212,15 +211,15 @@ stream_encode(lzma_coder *coder, lzma_allocator *allocator,
static void
-stream_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
+stream_encoder_end(void *coder_ptr, const lzma_allocator *allocator)
{
- size_t i;
+ lzma_stream_coder *coder = coder_ptr;
lzma_next_end(&coder->block_encoder, allocator);
lzma_next_end(&coder->index_encoder, allocator);
lzma_index_end(coder->index, allocator);
- for (i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
+ for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
lzma_free(coder->filters[i].options, allocator);
lzma_free(coder, allocator);
@@ -229,22 +228,20 @@ stream_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
-stream_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
+stream_encoder_update(void *coder_ptr, const lzma_allocator *allocator,
const lzma_filter *filters,
const lzma_filter *reversed_filters)
{
- size_t i;
+ lzma_stream_coder *coder = coder_ptr;
if (coder->sequence <= SEQ_BLOCK_INIT) {
- lzma_ret ret;
-
// There is no incomplete Block waiting to be finished,
// thus we can change the whole filter chain. Start by
// trying to initialize the Block encoder with the new
// chain. This way we detect if the chain is valid.
coder->block_encoder_is_initialized = false;
coder->block_options.filters = (lzma_filter *)(filters);
- ret = block_encoder_init(coder, allocator);
+ const lzma_ret ret = block_encoder_init(coder, allocator);
coder->block_options.filters = coder->filters;
if (ret != LZMA_OK)
return ret;
@@ -264,62 +261,66 @@ stream_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
}
// Free the copy of the old chain and make a copy of the new chain.
- for (i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
+ for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
lzma_free(coder->filters[i].options, allocator);
return lzma_filters_copy(filters, coder->filters, allocator);
}
-extern lzma_ret
-lzma_stream_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+static lzma_ret
+stream_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter *filters, lzma_check check)
{
- lzma_stream_flags stream_flags = { 0, 0, check };
-
- lzma_next_coder_init(&lzma_stream_encoder_init, next, allocator);
+ lzma_next_coder_init(&stream_encoder_init, next, allocator);
if (filters == NULL)
return LZMA_PROG_ERROR;
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
+ lzma_stream_coder *coder = next->coder;
+
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_stream_coder), allocator);
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ next->coder = coder;
next->code = &stream_encode;
next->end = &stream_encoder_end;
next->update = &stream_encoder_update;
- next->coder->filters[0].id = LZMA_VLI_UNKNOWN;
- next->coder->block_encoder = LZMA_NEXT_CODER_INIT;
- next->coder->index_encoder = LZMA_NEXT_CODER_INIT;
- next->coder->index = NULL;
+ coder->filters[0].id = LZMA_VLI_UNKNOWN;
+ coder->block_encoder = LZMA_NEXT_CODER_INIT;
+ coder->index_encoder = LZMA_NEXT_CODER_INIT;
+ coder->index = NULL;
}
// Basic initializations
- next->coder->sequence = SEQ_STREAM_HEADER;
- next->coder->block_options.version = 0;
- next->coder->block_options.check = check;
+ coder->sequence = SEQ_STREAM_HEADER;
+ coder->block_options.version = 0;
+ coder->block_options.check = check;
// Initialize the Index
- lzma_index_end(next->coder->index, allocator);
- next->coder->index = lzma_index_init(allocator);
- if (next->coder->index == NULL)
+ lzma_index_end(coder->index, allocator);
+ coder->index = lzma_index_init(allocator);
+ if (coder->index == NULL)
return LZMA_MEM_ERROR;
// Encode the Stream Header
+ lzma_stream_flags stream_flags = {
+ .version = 0,
+ .check = check,
+ };
return_if_error(lzma_stream_header_encode(
- &stream_flags, next->coder->buffer));
+ &stream_flags, coder->buffer));
- next->coder->buffer_pos = 0;
- next->coder->buffer_size = LZMA_STREAM_HEADER_SIZE;
+ coder->buffer_pos = 0;
+ coder->buffer_size = LZMA_STREAM_HEADER_SIZE;
// Initialize the Block encoder. This way we detect unsupported
// filter chains when initializing the Stream encoder instead of
// giving an error after Stream Header has already written out.
- return stream_encoder_update(
- next->coder, allocator, filters, NULL);
+ return stream_encoder_update(coder, allocator, filters, NULL);
}
@@ -327,11 +328,12 @@ extern LZMA_API(lzma_ret)
lzma_stream_encoder(lzma_stream *strm,
const lzma_filter *filters, lzma_check check)
{
- lzma_next_strm_init2(lzma_stream_encoder_init, strm, filters, check);
+ lzma_next_strm_init(stream_encoder_init, strm, filters, check);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;
strm->internal->supported_actions[LZMA_FULL_FLUSH] = true;
+ strm->internal->supported_actions[LZMA_FULL_BARRIER] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
return LZMA_OK;
diff --git a/Utilities/cmliblzma/liblzma/common/stream_encoder.h b/Utilities/cmliblzma/liblzma/common/stream_encoder.h
deleted file mode 100644
index 46a7aed72..000000000
--- a/Utilities/cmliblzma/liblzma/common/stream_encoder.h
+++ /dev/null
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file stream_encoder.h
-/// \brief Encodes .xz Streams
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_STREAM_ENCODER_H
-#define LZMA_STREAM_ENCODER_H
-
-#include "common.h"
-
-
-extern lzma_ret lzma_stream_encoder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter *filters, lzma_check check);
-
-#endif
diff --git a/Utilities/cmliblzma/liblzma/common/stream_encoder_mt.c b/Utilities/cmliblzma/liblzma/common/stream_encoder_mt.c
new file mode 100644
index 000000000..2efe44c25
--- /dev/null
+++ b/Utilities/cmliblzma/liblzma/common/stream_encoder_mt.c
@@ -0,0 +1,1143 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+/// \file stream_encoder_mt.c
+/// \brief Multithreaded .xz Stream encoder
+//
+// Author: Lasse Collin
+//
+// This file has been put into the public domain.
+// You can do whatever you want with this file.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include "filter_encoder.h"
+#include "easy_preset.h"
+#include "block_encoder.h"
+#include "block_buffer_encoder.h"
+#include "index_encoder.h"
+#include "outqueue.h"
+
+
+/// Maximum supported block size. This makes it simpler to prevent integer
+/// overflows if we are given unusually large block size.
+#define BLOCK_SIZE_MAX (UINT64_MAX / LZMA_THREADS_MAX)
+
+
+typedef enum {
+ /// Waiting for work.
+ THR_IDLE,
+
+ /// Encoding is in progress.
+ THR_RUN,
+
+ /// Encoding is in progress but no more input data will
+ /// be read.
+ THR_FINISH,
+
+ /// The main thread wants the thread to stop whatever it was doing
+ /// but not exit.
+ THR_STOP,
+
+ /// The main thread wants the thread to exit. We could use
+ /// cancellation but since there's stopped anyway, this is lazier.
+ THR_EXIT,
+
+} worker_state;
+
+typedef struct lzma_stream_coder_s lzma_stream_coder;
+
+typedef struct worker_thread_s worker_thread;
+struct worker_thread_s {
+ worker_state state;
+
+ /// Input buffer of coder->block_size bytes. The main thread will
+ /// put new input into this and update in_size accordingly. Once
+ /// no more input is coming, state will be set to THR_FINISH.
+ uint8_t *in;
+
+ /// Amount of data available in the input buffer. This is modified
+ /// only by the main thread.
+ size_t in_size;
+
+ /// Output buffer for this thread. This is set by the main
+ /// thread every time a new Block is started with this thread
+ /// structure.
+ lzma_outbuf *outbuf;
+
+ /// Pointer to the main structure is needed when putting this
+ /// thread back to the stack of free threads.
+ lzma_stream_coder *coder;
+
+ /// The allocator is set by the main thread. Since a copy of the
+ /// pointer is kept here, the application must not change the
+ /// allocator before calling lzma_end().
+ const lzma_allocator *allocator;
+
+ /// Amount of uncompressed data that has already been compressed.
+ uint64_t progress_in;
+
+ /// Amount of compressed data that is ready.
+ uint64_t progress_out;
+
+ /// Block encoder
+ lzma_next_coder block_encoder;
+
+ /// Compression options for this Block
+ lzma_block block_options;
+
+ /// Next structure in the stack of free worker threads.
+ worker_thread *next;
+
+ mythread_mutex mutex;
+ mythread_cond cond;
+
+ /// The ID of this thread is used to join the thread
+ /// when it's not needed anymore.
+ mythread thread_id;
+};
+
+
+struct lzma_stream_coder_s {
+ enum {
+ SEQ_STREAM_HEADER,
+ SEQ_BLOCK,
+ SEQ_INDEX,
+ SEQ_STREAM_FOOTER,
+ } sequence;
+
+ /// Start a new Block every block_size bytes of input unless
+ /// LZMA_FULL_FLUSH or LZMA_FULL_BARRIER is used earlier.
+ size_t block_size;
+
+ /// The filter chain currently in use
+ lzma_filter filters[LZMA_FILTERS_MAX + 1];
+
+
+ /// Index to hold sizes of the Blocks
+ lzma_index *index;
+
+ /// Index encoder
+ lzma_next_coder index_encoder;
+
+
+ /// Stream Flags for encoding the Stream Header and Stream Footer.
+ lzma_stream_flags stream_flags;
+
+ /// Buffer to hold Stream Header and Stream Footer.
+ uint8_t header[LZMA_STREAM_HEADER_SIZE];
+
+ /// Read position in header[]
+ size_t header_pos;
+
+
+ /// Output buffer queue for compressed data
+ lzma_outq outq;
+
+
+ /// Maximum wait time if cannot use all the input and cannot
+ /// fill the output buffer. This is in milliseconds.
+ uint32_t timeout;
+
+
+ /// Error code from a worker thread
+ lzma_ret thread_error;
+
+ /// Array of allocated thread-specific structures
+ worker_thread *threads;
+
+ /// Number of structures in "threads" above. This is also the
+ /// number of threads that will be created at maximum.
+ uint32_t threads_max;
+
+ /// Number of thread structures that have been initialized, and
+ /// thus the number of worker threads actually created so far.
+ uint32_t threads_initialized;
+
+ /// Stack of free threads. When a thread finishes, it puts itself
+ /// back into this stack. This starts as empty because threads
+ /// are created only when actually needed.
+ worker_thread *threads_free;
+
+ /// The most recent worker thread to which the main thread writes
+ /// the new input from the application.
+ worker_thread *thr;
+
+
+ /// Amount of uncompressed data in Blocks that have already
+ /// been finished.
+ uint64_t progress_in;
+
+ /// Amount of compressed data in Stream Header + Blocks that
+ /// have already been finished.
+ uint64_t progress_out;
+
+
+ mythread_mutex mutex;
+ mythread_cond cond;
+};
+
+
+/// Tell the main thread that something has gone wrong.
+static void
+worker_error(worker_thread *thr, lzma_ret ret)
+{
+ assert(ret != LZMA_OK);
+ assert(ret != LZMA_STREAM_END);
+
+ mythread_sync(thr->coder->mutex) {
+ if (thr->coder->thread_error == LZMA_OK)
+ thr->coder->thread_error = ret;
+
+ mythread_cond_signal(&thr->coder->cond);
+ }
+
+ return;
+}
+
+
+static worker_state
+worker_encode(worker_thread *thr, worker_state state)
+{
+ assert(thr->progress_in == 0);
+ assert(thr->progress_out == 0);
+
+ // Set the Block options.
+ thr->block_options = (lzma_block){
+ .version = 0,
+ .check = thr->coder->stream_flags.check,
+ .compressed_size = thr->coder->outq.buf_size_max,
+ .uncompressed_size = thr->coder->block_size,
+
+ // TODO: To allow changing the filter chain, the filters
+ // array must be copied to each worker_thread.
+ .filters = thr->coder->filters,
+ };
+
+ // Calculate maximum size of the Block Header. This amount is
+ // reserved in the beginning of the buffer so that Block Header
+ // along with Compressed Size and Uncompressed Size can be
+ // written there.
+ lzma_ret ret = lzma_block_header_size(&thr->block_options);
+ if (ret != LZMA_OK) {
+ worker_error(thr, ret);
+ return THR_STOP;
+ }
+
+ // Initialize the Block encoder.
+ ret = lzma_block_encoder_init(&thr->block_encoder,
+ thr->allocator, &thr->block_options);
+ if (ret != LZMA_OK) {
+ worker_error(thr, ret);
+ return THR_STOP;
+ }
+
+ size_t in_pos = 0;
+ size_t in_size = 0;
+
+ thr->outbuf->size = thr->block_options.header_size;
+ const size_t out_size = thr->coder->outq.buf_size_max;
+
+ do {
+ mythread_sync(thr->mutex) {
+ // Store in_pos and out_pos into *thr so that
+ // an application may read them via
+ // lzma_get_progress() to get progress information.
+ //
+ // NOTE: These aren't updated when the encoding
+ // finishes. Instead, the final values are taken
+ // later from thr->outbuf.
+ thr->progress_in = in_pos;
+ thr->progress_out = thr->outbuf->size;
+
+ while (in_size == thr->in_size
+ && thr->state == THR_RUN)
+ mythread_cond_wait(&thr->cond, &thr->mutex);
+
+ state = thr->state;
+ in_size = thr->in_size;
+ }
+
+ // Return if we were asked to stop or exit.
+ if (state >= THR_STOP)
+ return state;
+
+ lzma_action action = state == THR_FINISH
+ ? LZMA_FINISH : LZMA_RUN;
+
+ // Limit the amount of input given to the Block encoder
+ // at once. This way this thread can react fairly quickly
+ // if the main thread wants us to stop or exit.
+ static const size_t in_chunk_max = 16384;
+ size_t in_limit = in_size;
+ if (in_size - in_pos > in_chunk_max) {
+ in_limit = in_pos + in_chunk_max;
+ action = LZMA_RUN;
+ }
+
+ ret = thr->block_encoder.code(
+ thr->block_encoder.coder, thr->allocator,
+ thr->in, &in_pos, in_limit, thr->outbuf->buf,
+ &thr->outbuf->size, out_size, action);
+ } while (ret == LZMA_OK && thr->outbuf->size < out_size);
+
+ switch (ret) {
+ case LZMA_STREAM_END:
+ assert(state == THR_FINISH);
+
+ // Encode the Block Header. By doing it after
+ // the compression, we can store the Compressed Size
+ // and Uncompressed Size fields.
+ ret = lzma_block_header_encode(&thr->block_options,
+ thr->outbuf->buf);
+ if (ret != LZMA_OK) {
+ worker_error(thr, ret);
+ return THR_STOP;
+ }
+
+ break;
+
+ case LZMA_OK:
+ // The data was incompressible. Encode it using uncompressed
+ // LZMA2 chunks.
+ //
+ // First wait that we have gotten all the input.
+ mythread_sync(thr->mutex) {
+ while (thr->state == THR_RUN)
+ mythread_cond_wait(&thr->cond, &thr->mutex);
+
+ state = thr->state;
+ in_size = thr->in_size;
+ }
+
+ if (state >= THR_STOP)
+ return state;
+
+ // Do the encoding. This takes care of the Block Header too.
+ thr->outbuf->size = 0;
+ ret = lzma_block_uncomp_encode(&thr->block_options,
+ thr->in, in_size, thr->outbuf->buf,
+ &thr->outbuf->size, out_size);
+
+ // It shouldn't fail.
+ if (ret != LZMA_OK) {
+ worker_error(thr, LZMA_PROG_ERROR);
+ return THR_STOP;
+ }
+
+ break;
+
+ default:
+ worker_error(thr, ret);
+ return THR_STOP;
+ }
+
+ // Set the size information that will be read by the main thread
+ // to write the Index field.
+ thr->outbuf->unpadded_size
+ = lzma_block_unpadded_size(&thr->block_options);
+ assert(thr->outbuf->unpadded_size != 0);
+ thr->outbuf->uncompressed_size = thr->block_options.uncompressed_size;
+
+ return THR_FINISH;
+}
+
+
+static MYTHREAD_RET_TYPE
+worker_start(void *thr_ptr)
+{
+ worker_thread *thr = thr_ptr;
+ worker_state state = THR_IDLE; // Init to silence a warning
+
+ while (true) {
+ // Wait for work.
+ mythread_sync(thr->mutex) {
+ while (true) {
+ // The thread is already idle so if we are
+ // requested to stop, just set the state.
+ if (thr->state == THR_STOP) {
+ thr->state = THR_IDLE;
+ mythread_cond_signal(&thr->cond);
+ }
+
+ state = thr->state;
+ if (state != THR_IDLE)
+ break;
+
+ mythread_cond_wait(&thr->cond, &thr->mutex);
+ }
+ }
+
+ assert(state != THR_IDLE);
+ assert(state != THR_STOP);
+
+ if (state <= THR_FINISH)
+ state = worker_encode(thr, state);
+
+ if (state == THR_EXIT)
+ break;
+
+ // Mark the thread as idle unless the main thread has
+ // told us to exit. Signal is needed for the case
+ // where the main thread is waiting for the threads to stop.
+ mythread_sync(thr->mutex) {
+ if (thr->state != THR_EXIT) {
+ thr->state = THR_IDLE;
+ mythread_cond_signal(&thr->cond);
+ }
+ }
+
+ mythread_sync(thr->coder->mutex) {
+ // Mark the output buffer as finished if
+ // no errors occurred.
+ thr->outbuf->finished = state == THR_FINISH;
+
+ // Update the main progress info.
+ thr->coder->progress_in
+ += thr->outbuf->uncompressed_size;
+ thr->coder->progress_out += thr->outbuf->size;
+ thr->progress_in = 0;
+ thr->progress_out = 0;
+
+ // Return this thread to the stack of free threads.
+ thr->next = thr->coder->threads_free;
+ thr->coder->threads_free = thr;
+
+ mythread_cond_signal(&thr->coder->cond);
+ }
+ }
+
+ // Exiting, free the resources.
+ mythread_mutex_destroy(&thr->mutex);
+ mythread_cond_destroy(&thr->cond);
+
+ lzma_next_end(&thr->block_encoder, thr->allocator);
+ lzma_free(thr->in, thr->allocator);
+ return MYTHREAD_RET_VALUE;
+}
+
+
+/// Make the threads stop but not exit. Optionally wait for them to stop.
+static void
+threads_stop(lzma_stream_coder *coder, bool wait_for_threads)
+{
+ // Tell the threads to stop.
+ for (uint32_t i = 0; i < coder->threads_initialized; ++i) {
+ mythread_sync(coder->threads[i].mutex) {
+ coder->threads[i].state = THR_STOP;
+ mythread_cond_signal(&coder->threads[i].cond);
+ }
+ }
+
+ if (!wait_for_threads)
+ return;
+
+ // Wait for the threads to settle in the idle state.
+ for (uint32_t i = 0; i < coder->threads_initialized; ++i) {
+ mythread_sync(coder->threads[i].mutex) {
+ while (coder->threads[i].state != THR_IDLE)
+ mythread_cond_wait(&coder->threads[i].cond,
+ &coder->threads[i].mutex);
+ }
+ }
+
+ return;
+}
+
+
+/// Stop the threads and free the resources associated with them.
+/// Wait until the threads have exited.
+static void
+threads_end(lzma_stream_coder *coder, const lzma_allocator *allocator)
+{
+ for (uint32_t i = 0; i < coder->threads_initialized; ++i) {
+ mythread_sync(coder->threads[i].mutex) {
+ coder->threads[i].state = THR_EXIT;
+ mythread_cond_signal(&coder->threads[i].cond);
+ }
+ }
+
+ for (uint32_t i = 0; i < coder->threads_initialized; ++i) {
+ int ret = mythread_join(coder->threads[i].thread_id);
+ assert(ret == 0);
+ (void)ret;
+ }
+
+ lzma_free(coder->threads, allocator);
+ return;
+}
+
+
+/// Initialize a new worker_thread structure and create a new thread.
+static lzma_ret
+initialize_new_thread(lzma_stream_coder *coder,
+ const lzma_allocator *allocator)
+{
+ worker_thread *thr = &coder->threads[coder->threads_initialized];
+
+ thr->in = lzma_alloc(coder->block_size, allocator);
+ if (thr->in == NULL)
+ return LZMA_MEM_ERROR;
+
+ if (mythread_mutex_init(&thr->mutex))
+ goto error_mutex;
+
+ if (mythread_cond_init(&thr->cond))
+ goto error_cond;
+
+ thr->state = THR_IDLE;
+ thr->allocator = allocator;
+ thr->coder = coder;
+ thr->progress_in = 0;
+ thr->progress_out = 0;
+ thr->block_encoder = LZMA_NEXT_CODER_INIT;
+
+ if (mythread_create(&thr->thread_id, &worker_start, thr))
+ goto error_thread;
+
+ ++coder->threads_initialized;
+ coder->thr = thr;
+
+ return LZMA_OK;
+
+error_thread:
+ mythread_cond_destroy(&thr->cond);
+
+error_cond:
+ mythread_mutex_destroy(&thr->mutex);
+
+error_mutex:
+ lzma_free(thr->in, allocator);
+ return LZMA_MEM_ERROR;
+}
+
+
+static lzma_ret
+get_thread(lzma_stream_coder *coder, const lzma_allocator *allocator)
+{
+ // If there are no free output subqueues, there is no
+ // point to try getting a thread.
+ if (!lzma_outq_has_buf(&coder->outq))
+ return LZMA_OK;
+
+ // If there is a free structure on the stack, use it.
+ mythread_sync(coder->mutex) {
+ if (coder->threads_free != NULL) {
+ coder->thr = coder->threads_free;
+ coder->threads_free = coder->threads_free->next;
+ }
+ }
+
+ if (coder->thr == NULL) {
+ // If there are no uninitialized structures left, return.
+ if (coder->threads_initialized == coder->threads_max)
+ return LZMA_OK;
+
+ // Initialize a new thread.
+ return_if_error(initialize_new_thread(coder, allocator));
+ }
+
+ // Reset the parts of the thread state that have to be done
+ // in the main thread.
+ mythread_sync(coder->thr->mutex) {
+ coder->thr->state = THR_RUN;
+ coder->thr->in_size = 0;
+ coder->thr->outbuf = lzma_outq_get_buf(&coder->outq);
+ mythread_cond_signal(&coder->thr->cond);
+ }
+
+ return LZMA_OK;
+}
+
+
+static lzma_ret
+stream_encode_in(lzma_stream_coder *coder, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, lzma_action action)
+{
+ while (*in_pos < in_size
+ || (coder->thr != NULL && action != LZMA_RUN)) {
+ if (coder->thr == NULL) {
+ // Get a new thread.
+ const lzma_ret ret = get_thread(coder, allocator);
+ if (coder->thr == NULL)
+ return ret;
+ }
+
+ // Copy the input data to thread's buffer.
+ size_t thr_in_size = coder->thr->in_size;
+ lzma_bufcpy(in, in_pos, in_size, coder->thr->in,
+ &thr_in_size, coder->block_size);
+
+ // Tell the Block encoder to finish if
+ // - it has got block_size bytes of input; or
+ // - all input was used and LZMA_FINISH, LZMA_FULL_FLUSH,
+ // or LZMA_FULL_BARRIER was used.
+ //
+ // TODO: LZMA_SYNC_FLUSH and LZMA_SYNC_BARRIER.
+ const bool finish = thr_in_size == coder->block_size
+ || (*in_pos == in_size && action != LZMA_RUN);
+
+ bool block_error = false;
+
+ mythread_sync(coder->thr->mutex) {
+ if (coder->thr->state == THR_IDLE) {
+ // Something has gone wrong with the Block
+ // encoder. It has set coder->thread_error
+ // which we will read a few lines later.
+ block_error = true;
+ } else {
+ // Tell the Block encoder its new amount
+ // of input and update the state if needed.
+ coder->thr->in_size = thr_in_size;
+
+ if (finish)
+ coder->thr->state = THR_FINISH;
+
+ mythread_cond_signal(&coder->thr->cond);
+ }
+ }
+
+ if (block_error) {
+ lzma_ret ret;
+
+ mythread_sync(coder->mutex) {
+ ret = coder->thread_error;
+ }
+
+ return ret;
+ }
+
+ if (finish)
+ coder->thr = NULL;
+ }
+
+ return LZMA_OK;
+}
+
+
+/// Wait until more input can be consumed, more output can be read, or
+/// an optional timeout is reached.
+static bool
+wait_for_work(lzma_stream_coder *coder, mythread_condtime *wait_abs,
+ bool *has_blocked, bool has_input)
+{
+ if (coder->timeout != 0 && !*has_blocked) {
+ // Every time when stream_encode_mt() is called via
+ // lzma_code(), *has_blocked starts as false. We set it
+ // to true here and calculate the absolute time when
+ // we must return if there's nothing to do.
+ //
+ // The idea of *has_blocked is to avoid unneeded calls
+ // to mythread_condtime_set(), which may do a syscall
+ // depending on the operating system.
+ *has_blocked = true;
+ mythread_condtime_set(wait_abs, &coder->cond, coder->timeout);
+ }
+
+ bool timed_out = false;
+
+ mythread_sync(coder->mutex) {
+ // There are four things that we wait. If one of them
+ // becomes possible, we return.
+ // - If there is input left, we need to get a free
+ // worker thread and an output buffer for it.
+ // - Data ready to be read from the output queue.
+ // - A worker thread indicates an error.
+ // - Time out occurs.
+ while ((!has_input || coder->threads_free == NULL
+ || !lzma_outq_has_buf(&coder->outq))
+ && !lzma_outq_is_readable(&coder->outq)
+ && coder->thread_error == LZMA_OK
+ && !timed_out) {
+ if (coder->timeout != 0)
+ timed_out = mythread_cond_timedwait(
+ &coder->cond, &coder->mutex,
+ wait_abs) != 0;
+ else
+ mythread_cond_wait(&coder->cond,
+ &coder->mutex);
+ }
+ }
+
+ return timed_out;
+}
+
+
+static lzma_ret
+stream_encode_mt(void *coder_ptr, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size, lzma_action action)
+{
+ lzma_stream_coder *coder = coder_ptr;
+
+ switch (coder->sequence) {
+ case SEQ_STREAM_HEADER:
+ lzma_bufcpy(coder->header, &coder->header_pos,
+ sizeof(coder->header),
+ out, out_pos, out_size);
+ if (coder->header_pos < sizeof(coder->header))
+ return LZMA_OK;
+
+ coder->header_pos = 0;
+ coder->sequence = SEQ_BLOCK;
+
+ // Fall through
+
+ case SEQ_BLOCK: {
+ // Initialized to silence warnings.
+ lzma_vli unpadded_size = 0;
+ lzma_vli uncompressed_size = 0;
+ lzma_ret ret = LZMA_OK;
+
+ // These are for wait_for_work().
+ bool has_blocked = false;
+ mythread_condtime wait_abs;
+
+ while (true) {
+ mythread_sync(coder->mutex) {
+ // Check for Block encoder errors.
+ ret = coder->thread_error;
+ if (ret != LZMA_OK) {
+ assert(ret != LZMA_STREAM_END);
+ break;
+ }
+
+ // Try to read compressed data to out[].
+ ret = lzma_outq_read(&coder->outq,
+ out, out_pos, out_size,
+ &unpadded_size,
+ &uncompressed_size);
+ }
+
+ if (ret == LZMA_STREAM_END) {
+ // End of Block. Add it to the Index.
+ ret = lzma_index_append(coder->index,
+ allocator, unpadded_size,
+ uncompressed_size);
+
+ // If we didn't fill the output buffer yet,
+ // try to read more data. Maybe the next
+ // outbuf has been finished already too.
+ if (*out_pos < out_size)
+ continue;
+ }
+
+ if (ret != LZMA_OK) {
+ // coder->thread_error was set or
+ // lzma_index_append() failed.
+ threads_stop(coder, false);
+ return ret;
+ }
+
+ // Try to give uncompressed data to a worker thread.
+ ret = stream_encode_in(coder, allocator,
+ in, in_pos, in_size, action);
+ if (ret != LZMA_OK) {
+ threads_stop(coder, false);
+ return ret;
+ }
+
+ // See if we should wait or return.
+ //
+ // TODO: LZMA_SYNC_FLUSH and LZMA_SYNC_BARRIER.
+ if (*in_pos == in_size) {
+ // LZMA_RUN: More data is probably coming
+ // so return to let the caller fill the
+ // input buffer.
+ if (action == LZMA_RUN)
+ return LZMA_OK;
+
+ // LZMA_FULL_BARRIER: The same as with
+ // LZMA_RUN but tell the caller that the
+ // barrier was completed.
+ if (action == LZMA_FULL_BARRIER)
+ return LZMA_STREAM_END;
+
+ // Finishing or flushing isn't completed until
+ // all input data has been encoded and copied
+ // to the output buffer.
+ if (lzma_outq_is_empty(&coder->outq)) {
+ // LZMA_FINISH: Continue to encode
+ // the Index field.
+ if (action == LZMA_FINISH)
+ break;
+
+ // LZMA_FULL_FLUSH: Return to tell
+ // the caller that flushing was
+ // completed.
+ if (action == LZMA_FULL_FLUSH)
+ return LZMA_STREAM_END;
+ }
+ }
+
+ // Return if there is no output space left.
+ // This check must be done after testing the input
+ // buffer, because we might want to use a different
+ // return code.
+ if (*out_pos == out_size)
+ return LZMA_OK;
+
+ // Neither in nor out has been used completely.
+ // Wait until there's something we can do.
+ if (wait_for_work(coder, &wait_abs, &has_blocked,
+ *in_pos < in_size))
+ return LZMA_TIMED_OUT;
+ }
+
+ // All Blocks have been encoded and the threads have stopped.
+ // Prepare to encode the Index field.
+ return_if_error(lzma_index_encoder_init(
+ &coder->index_encoder, allocator,
+ coder->index));
+ coder->sequence = SEQ_INDEX;
+
+ // Update the progress info to take the Index and
+ // Stream Footer into account. Those are very fast to encode
+ // so in terms of progress information they can be thought
+ // to be ready to be copied out.
+ coder->progress_out += lzma_index_size(coder->index)
+ + LZMA_STREAM_HEADER_SIZE;
+ }
+
+ // Fall through
+
+ case SEQ_INDEX: {
+ // Call the Index encoder. It doesn't take any input, so
+ // those pointers can be NULL.
+ const lzma_ret ret = coder->index_encoder.code(
+ coder->index_encoder.coder, allocator,
+ NULL, NULL, 0,
+ out, out_pos, out_size, LZMA_RUN);
+ if (ret != LZMA_STREAM_END)
+ return ret;
+
+ // Encode the Stream Footer into coder->buffer.
+ coder->stream_flags.backward_size
+ = lzma_index_size(coder->index);
+ if (lzma_stream_footer_encode(&coder->stream_flags,
+ coder->header) != LZMA_OK)
+ return LZMA_PROG_ERROR;
+
+ coder->sequence = SEQ_STREAM_FOOTER;
+ }
+
+ // Fall through
+
+ case SEQ_STREAM_FOOTER:
+ lzma_bufcpy(coder->header, &coder->header_pos,
+ sizeof(coder->header),
+ out, out_pos, out_size);
+ return coder->header_pos < sizeof(coder->header)
+ ? LZMA_OK : LZMA_STREAM_END;
+ }
+
+ assert(0);
+ return LZMA_PROG_ERROR;
+}
+
+
+static void
+stream_encoder_mt_end(void *coder_ptr, const lzma_allocator *allocator)
+{
+ lzma_stream_coder *coder = coder_ptr;
+
+ // Threads must be killed before the output queue can be freed.
+ threads_end(coder, allocator);
+ lzma_outq_end(&coder->outq, allocator);
+
+ for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
+ lzma_free(coder->filters[i].options, allocator);
+
+ lzma_next_end(&coder->index_encoder, allocator);
+ lzma_index_end(coder->index, allocator);
+
+ mythread_cond_destroy(&coder->cond);
+ mythread_mutex_destroy(&coder->mutex);
+
+ lzma_free(coder, allocator);
+ return;
+}
+
+
+/// Options handling for lzma_stream_encoder_mt_init() and
+/// lzma_stream_encoder_mt_memusage()
+static lzma_ret
+get_options(const lzma_mt *options, lzma_options_easy *opt_easy,
+ const lzma_filter **filters, uint64_t *block_size,
+ uint64_t *outbuf_size_max)
+{
+ // Validate some of the options.
+ if (options == NULL)
+ return LZMA_PROG_ERROR;
+
+ if (options->flags != 0 || options->threads == 0
+ || options->threads > LZMA_THREADS_MAX)
+ return LZMA_OPTIONS_ERROR;
+
+ if (options->filters != NULL) {
+ // Filter chain was given, use it as is.
+ *filters = options->filters;
+ } else {
+ // Use a preset.
+ if (lzma_easy_preset(opt_easy, options->preset))
+ return LZMA_OPTIONS_ERROR;
+
+ *filters = opt_easy->filters;
+ }
+
+ // Block size
+ if (options->block_size > 0) {
+ if (options->block_size > BLOCK_SIZE_MAX)
+ return LZMA_OPTIONS_ERROR;
+
+ *block_size = options->block_size;
+ } else {
+ // Determine the Block size from the filter chain.
+ *block_size = lzma_mt_block_size(*filters);
+ if (*block_size == 0)
+ return LZMA_OPTIONS_ERROR;
+
+ assert(*block_size <= BLOCK_SIZE_MAX);
+ }
+
+ // Calculate the maximum amount output that a single output buffer
+ // may need to hold. This is the same as the maximum total size of
+ // a Block.
+ *outbuf_size_max = lzma_block_buffer_bound64(*block_size);
+ if (*outbuf_size_max == 0)
+ return LZMA_MEM_ERROR;
+
+ return LZMA_OK;
+}
+
+
+static void
+get_progress(void *coder_ptr, uint64_t *progress_in, uint64_t *progress_out)
+{
+ lzma_stream_coder *coder = coder_ptr;
+
+ // Lock coder->mutex to prevent finishing threads from moving their
+ // progress info from the worker_thread structure to lzma_stream_coder.
+ mythread_sync(coder->mutex) {
+ *progress_in = coder->progress_in;
+ *progress_out = coder->progress_out;
+
+ for (size_t i = 0; i < coder->threads_initialized; ++i) {
+ mythread_sync(coder->threads[i].mutex) {
+ *progress_in += coder->threads[i].progress_in;
+ *progress_out += coder->threads[i]
+ .progress_out;
+ }
+ }
+ }
+
+ return;
+}
+
+
+static lzma_ret
+stream_encoder_mt_init(lzma_next_coder *next, const lzma_allocator *allocator,
+ const lzma_mt *options)
+{
+ lzma_next_coder_init(&stream_encoder_mt_init, next, allocator);
+
+ // Get the filter chain.
+ lzma_options_easy easy;
+ const lzma_filter *filters;
+ uint64_t block_size;
+ uint64_t outbuf_size_max;
+ return_if_error(get_options(options, &easy, &filters,
+ &block_size, &outbuf_size_max));
+
+#if SIZE_MAX < UINT64_MAX
+ if (block_size > SIZE_MAX)
+ return LZMA_MEM_ERROR;
+#endif
+
+ // Validate the filter chain so that we can give an error in this
+ // function instead of delaying it to the first call to lzma_code().
+ // The memory usage calculation verifies the filter chain as
+ // a side effect so we take advatange of that.
+ if (lzma_raw_encoder_memusage(filters) == UINT64_MAX)
+ return LZMA_OPTIONS_ERROR;
+
+ // Validate the Check ID.
+ if ((unsigned int)(options->check) > LZMA_CHECK_ID_MAX)
+ return LZMA_PROG_ERROR;
+
+ if (!lzma_check_is_supported(options->check))
+ return LZMA_UNSUPPORTED_CHECK;
+
+ // Allocate and initialize the base structure if needed.
+ lzma_stream_coder *coder = next->coder;
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_stream_coder), allocator);
+ if (coder == NULL)
+ return LZMA_MEM_ERROR;
+
+ next->coder = coder;
+
+ // For the mutex and condition variable initializations
+ // the error handling has to be done here because
+ // stream_encoder_mt_end() doesn't know if they have
+ // already been initialized or not.
+ if (mythread_mutex_init(&coder->mutex)) {
+ lzma_free(coder, allocator);
+ next->coder = NULL;
+ return LZMA_MEM_ERROR;
+ }
+
+ if (mythread_cond_init(&coder->cond)) {
+ mythread_mutex_destroy(&coder->mutex);
+ lzma_free(coder, allocator);
+ next->coder = NULL;
+ return LZMA_MEM_ERROR;
+ }
+
+ next->code = &stream_encode_mt;
+ next->end = &stream_encoder_mt_end;
+ next->get_progress = &get_progress;
+// next->update = &stream_encoder_mt_update;
+
+ coder->filters[0].id = LZMA_VLI_UNKNOWN;
+ coder->index_encoder = LZMA_NEXT_CODER_INIT;
+ coder->index = NULL;
+ memzero(&coder->outq, sizeof(coder->outq));
+ coder->threads = NULL;
+ coder->threads_max = 0;
+ coder->threads_initialized = 0;
+ }
+
+ // Basic initializations
+ coder->sequence = SEQ_STREAM_HEADER;
+ coder->block_size = (size_t)(block_size);
+ coder->thread_error = LZMA_OK;
+ coder->thr = NULL;
+
+ // Allocate the thread-specific base structures.
+ assert(options->threads > 0);
+ if (coder->threads_max != options->threads) {
+ threads_end(coder, allocator);
+
+ coder->threads = NULL;
+ coder->threads_max = 0;
+
+ coder->threads_initialized = 0;
+ coder->threads_free = NULL;
+
+ coder->threads = lzma_alloc(
+ options->threads * sizeof(worker_thread),
+ allocator);
+ if (coder->threads == NULL)
+ return LZMA_MEM_ERROR;
+
+ coder->threads_max = options->threads;
+ } else {
+ // Reuse the old structures and threads. Tell the running
+ // threads to stop and wait until they have stopped.
+ threads_stop(coder, true);
+ }
+
+ // Output queue
+ return_if_error(lzma_outq_init(&coder->outq, allocator,
+ outbuf_size_max, options->threads));
+
+ // Timeout
+ coder->timeout = options->timeout;
+
+ // Free the old filter chain and copy the new one.
+ for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
+ lzma_free(coder->filters[i].options, allocator);
+
+ return_if_error(lzma_filters_copy(
+ filters, coder->filters, allocator));
+
+ // Index
+ lzma_index_end(coder->index, allocator);
+ coder->index = lzma_index_init(allocator);
+ if (coder->index == NULL)
+ return LZMA_MEM_ERROR;
+
+ // Stream Header
+ coder->stream_flags.version = 0;
+ coder->stream_flags.check = options->check;
+ return_if_error(lzma_stream_header_encode(
+ &coder->stream_flags, coder->header));
+
+ coder->header_pos = 0;
+
+ // Progress info
+ coder->progress_in = 0;
+ coder->progress_out = LZMA_STREAM_HEADER_SIZE;
+
+ return LZMA_OK;
+}
+
+
+extern LZMA_API(lzma_ret)
+lzma_stream_encoder_mt(lzma_stream *strm, const lzma_mt *options)
+{
+ lzma_next_strm_init(stream_encoder_mt_init, strm, options);
+
+ strm->internal->supported_actions[LZMA_RUN] = true;
+// strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;
+ strm->internal->supported_actions[LZMA_FULL_FLUSH] = true;
+ strm->internal->supported_actions[LZMA_FULL_BARRIER] = true;
+ strm->internal->supported_actions[LZMA_FINISH] = true;
+
+ return LZMA_OK;
+}
+
+
+// This function name is a monster but it's consistent with the older
+// monster names. :-( 31 chars is the max that C99 requires so in that
+// sense it's not too long. ;-)
+extern LZMA_API(uint64_t)
+lzma_stream_encoder_mt_memusage(const lzma_mt *options)
+{
+ lzma_options_easy easy;
+ const lzma_filter *filters;
+ uint64_t block_size;
+ uint64_t outbuf_size_max;
+
+ if (get_options(options, &easy, &filters, &block_size,
+ &outbuf_size_max) != LZMA_OK)
+ return UINT64_MAX;
+
+ // Memory usage of the input buffers
+ const uint64_t inbuf_memusage = options->threads * block_size;
+
+ // Memory usage of the filter encoders
+ uint64_t filters_memusage = lzma_raw_encoder_memusage(filters);
+ if (filters_memusage == UINT64_MAX)
+ return UINT64_MAX;
+
+ filters_memusage *= options->threads;
+
+ // Memory usage of the output queue
+ const uint64_t outq_memusage = lzma_outq_memusage(
+ outbuf_size_max, options->threads);
+ if (outq_memusage == UINT64_MAX)
+ return UINT64_MAX;
+
+ // Sum them with overflow checking.
+ uint64_t total_memusage = LZMA_MEMUSAGE_BASE
+ + sizeof(lzma_stream_coder)
+ + options->threads * sizeof(worker_thread);
+
+ if (UINT64_MAX - total_memusage < inbuf_memusage)
+ return UINT64_MAX;
+
+ total_memusage += inbuf_memusage;
+
+ if (UINT64_MAX - total_memusage < filters_memusage)
+ return UINT64_MAX;
+
+ total_memusage += filters_memusage;
+
+ if (UINT64_MAX - total_memusage < outq_memusage)
+ return UINT64_MAX;
+
+ return total_memusage + outq_memusage;
+}
diff --git a/Utilities/cmliblzma/liblzma/common/stream_flags_decoder.c b/Utilities/cmliblzma/liblzma/common/stream_flags_decoder.c
index 8cf48a4ca..1bc2f97c5 100644
--- a/Utilities/cmliblzma/liblzma/common/stream_flags_decoder.c
+++ b/Utilities/cmliblzma/liblzma/common/stream_flags_decoder.c
@@ -30,15 +30,13 @@ stream_flags_decode(lzma_stream_flags *options, const uint8_t *in)
extern LZMA_API(lzma_ret)
lzma_stream_header_decode(lzma_stream_flags *options, const uint8_t *in)
{
- uint32_t crc;
-
// Magic
if (memcmp(in, lzma_header_magic, sizeof(lzma_header_magic)) != 0)
return LZMA_FORMAT_ERROR;
// Verify the CRC32 so we can distinguish between corrupt
// and unsupported files.
- crc = lzma_crc32(in + sizeof(lzma_header_magic),
+ const uint32_t crc = lzma_crc32(in + sizeof(lzma_header_magic),
LZMA_STREAM_FLAGS_SIZE, 0);
if (crc != unaligned_read32le(in + sizeof(lzma_header_magic)
+ LZMA_STREAM_FLAGS_SIZE))
@@ -61,15 +59,13 @@ lzma_stream_header_decode(lzma_stream_flags *options, const uint8_t *in)
extern LZMA_API(lzma_ret)
lzma_stream_footer_decode(lzma_stream_flags *options, const uint8_t *in)
{
- uint32_t crc;
-
// Magic
if (memcmp(in + sizeof(uint32_t) * 2 + LZMA_STREAM_FLAGS_SIZE,
lzma_footer_magic, sizeof(lzma_footer_magic)) != 0)
return LZMA_FORMAT_ERROR;
// CRC32
- crc = lzma_crc32(in + sizeof(uint32_t),
+ const uint32_t crc = lzma_crc32(in + sizeof(uint32_t),
sizeof(uint32_t) + LZMA_STREAM_FLAGS_SIZE, 0);
if (crc != unaligned_read32le(in))
return LZMA_DATA_ERROR;
diff --git a/Utilities/cmliblzma/liblzma/common/stream_flags_encoder.c b/Utilities/cmliblzma/liblzma/common/stream_flags_encoder.c
index 290339e08..4e717159f 100644
--- a/Utilities/cmliblzma/liblzma/common/stream_flags_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/stream_flags_encoder.c
@@ -29,8 +29,6 @@ stream_flags_encode(const lzma_stream_flags *options, uint8_t *out)
extern LZMA_API(lzma_ret)
lzma_stream_header_encode(const lzma_stream_flags *options, uint8_t *out)
{
- uint32_t crc;
-
assert(sizeof(lzma_header_magic) + LZMA_STREAM_FLAGS_SIZE
+ 4 == LZMA_STREAM_HEADER_SIZE);
@@ -45,7 +43,7 @@ lzma_stream_header_encode(const lzma_stream_flags *options, uint8_t *out)
return LZMA_PROG_ERROR;
// CRC32 of the Stream Header
- crc = lzma_crc32(out + sizeof(lzma_header_magic),
+ const uint32_t crc = lzma_crc32(out + sizeof(lzma_header_magic),
LZMA_STREAM_FLAGS_SIZE, 0);
unaligned_write32le(out + sizeof(lzma_header_magic)
@@ -58,8 +56,6 @@ lzma_stream_header_encode(const lzma_stream_flags *options, uint8_t *out)
extern LZMA_API(lzma_ret)
lzma_stream_footer_encode(const lzma_stream_flags *options, uint8_t *out)
{
- uint32_t crc;
-
assert(2 * 4 + LZMA_STREAM_FLAGS_SIZE + sizeof(lzma_footer_magic)
== LZMA_STREAM_HEADER_SIZE);
@@ -77,7 +73,7 @@ lzma_stream_footer_encode(const lzma_stream_flags *options, uint8_t *out)
return LZMA_PROG_ERROR;
// CRC32
- crc = lzma_crc32(
+ const uint32_t crc = lzma_crc32(
out + 4, 4 + LZMA_STREAM_FLAGS_SIZE, 0);
unaligned_write32le(out, crc);
diff --git a/Utilities/cmliblzma/liblzma/common/vli_decoder.c b/Utilities/cmliblzma/liblzma/common/vli_decoder.c
index 1c663844f..c181828bf 100644
--- a/Utilities/cmliblzma/liblzma/common/vli_decoder.c
+++ b/Utilities/cmliblzma/liblzma/common/vli_decoder.c
@@ -14,8 +14,8 @@
extern LZMA_API(lzma_ret)
-lzma_vli_decode(lzma_vli *LZMA_RESTRICT vli, size_t *vli_pos,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
+lzma_vli_decode(lzma_vli *restrict vli, size_t *vli_pos,
+ const uint8_t *restrict in, size_t *restrict in_pos,
size_t in_size)
{
// If we haven't been given vli_pos, work in single-call mode.
diff --git a/Utilities/cmliblzma/liblzma/common/vli_encoder.c b/Utilities/cmliblzma/liblzma/common/vli_encoder.c
index 09e90cbd7..f8642694e 100644
--- a/Utilities/cmliblzma/liblzma/common/vli_encoder.c
+++ b/Utilities/cmliblzma/liblzma/common/vli_encoder.c
@@ -15,7 +15,7 @@
extern LZMA_API(lzma_ret)
lzma_vli_encode(lzma_vli vli, size_t *vli_pos,
- uint8_t *LZMA_RESTRICT out, size_t *LZMA_RESTRICT out_pos,
+ uint8_t *restrict out, size_t *restrict out_pos,
size_t out_size)
{
// If we haven't been given vli_pos, work in single-call mode.
diff --git a/Utilities/cmliblzma/liblzma/common/vli_size.c b/Utilities/cmliblzma/liblzma/common/vli_size.c
index 8b931e40b..ec1b4fa48 100644
--- a/Utilities/cmliblzma/liblzma/common/vli_size.c
+++ b/Utilities/cmliblzma/liblzma/common/vli_size.c
@@ -16,11 +16,10 @@
extern LZMA_API(uint32_t)
lzma_vli_size(lzma_vli vli)
{
- uint32_t i = 0;
-
if (vli > LZMA_VLI_MAX)
return 0;
+ uint32_t i = 0;
do {
vli >>= 7;
++i;
diff --git a/Utilities/cmliblzma/liblzma/delta/delta_common.c b/Utilities/cmliblzma/liblzma/delta/delta_common.c
index 803e674a1..4768201d1 100644
--- a/Utilities/cmliblzma/liblzma/delta/delta_common.c
+++ b/Utilities/cmliblzma/liblzma/delta/delta_common.c
@@ -15,8 +15,9 @@
static void
-delta_coder_end(lzma_coder *coder, lzma_allocator *allocator)
+delta_coder_end(void *coder_ptr, const lzma_allocator *allocator)
{
+ lzma_delta_coder *coder = coder_ptr;
lzma_next_end(&coder->next, allocator);
lzma_free(coder, allocator);
return;
@@ -24,20 +25,21 @@ delta_coder_end(lzma_coder *coder, lzma_allocator *allocator)
extern lzma_ret
-lzma_delta_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_delta_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters)
{
- const lzma_options_delta *opt;
-
// Allocate memory for the decoder if needed.
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
+ lzma_delta_coder *coder = next->coder;
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_delta_coder), allocator);
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ next->coder = coder;
+
// End function is the same for encoder and decoder.
next->end = &delta_coder_end;
- next->coder->next = LZMA_NEXT_CODER_INIT;
+ coder->next = LZMA_NEXT_CODER_INIT;
}
// Validate the options.
@@ -45,16 +47,15 @@ lzma_delta_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
return LZMA_OPTIONS_ERROR;
// Set the delta distance.
- opt = filters[0].options;
- next->coder->distance = opt->dist;
+ const lzma_options_delta *opt = filters[0].options;
+ coder->distance = opt->dist;
// Initialize the rest of the variables.
- next->coder->pos = 0;
- memzero(next->coder->history, LZMA_DELTA_DIST_MAX);
+ coder->pos = 0;
+ memzero(coder->history, LZMA_DELTA_DIST_MAX);
// Initialize the next decoder in the chain, if any.
- return lzma_next_filter_init(&next->coder->next,
- allocator, filters + 1);
+ return lzma_next_filter_init(&coder->next, allocator, filters + 1);
}
@@ -68,5 +69,5 @@ lzma_delta_coder_memusage(const void *options)
|| opt->dist > LZMA_DELTA_DIST_MAX)
return UINT64_MAX;
- return sizeof(lzma_coder);
+ return sizeof(lzma_delta_coder);
}
diff --git a/Utilities/cmliblzma/liblzma/delta/delta_decoder.c b/Utilities/cmliblzma/liblzma/delta/delta_decoder.c
index 28df72735..6859afa5c 100644
--- a/Utilities/cmliblzma/liblzma/delta/delta_decoder.c
+++ b/Utilities/cmliblzma/liblzma/delta/delta_decoder.c
@@ -15,12 +15,11 @@
static void
-decode_buffer(lzma_coder *coder, uint8_t *buffer, size_t size)
+decode_buffer(lzma_delta_coder *coder, uint8_t *buffer, size_t size)
{
- size_t i;
const size_t distance = coder->distance;
- for (i = 0; i < size; ++i) {
+ for (size_t i = 0; i < size; ++i) {
buffer[i] += coder->history[(distance + coder->pos) & 0xFF];
coder->history[coder->pos-- & 0xFF] = buffer[i];
}
@@ -28,17 +27,18 @@ decode_buffer(lzma_coder *coder, uint8_t *buffer, size_t size)
static lzma_ret
-delta_decode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size, lzma_action action)
+delta_decode(void *coder_ptr, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size, lzma_action action)
{
- const size_t out_start = *out_pos;
- lzma_ret ret;
+ lzma_delta_coder *coder = coder_ptr;
assert(coder->next.code != NULL);
- ret = coder->next.code(coder->next.coder, allocator,
+ const size_t out_start = *out_pos;
+
+ const lzma_ret ret = coder->next.code(coder->next.coder, allocator,
in, in_pos, in_size, out, out_pos, out_size,
action);
@@ -49,7 +49,7 @@ delta_decode(lzma_coder *coder, lzma_allocator *allocator,
extern lzma_ret
-lzma_delta_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_delta_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters)
{
next->code = &delta_decode;
@@ -58,15 +58,14 @@ lzma_delta_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern lzma_ret
-lzma_delta_props_decode(void **options, lzma_allocator *allocator,
+lzma_delta_props_decode(void **options, const lzma_allocator *allocator,
const uint8_t *props, size_t props_size)
{
- lzma_options_delta *opt;
-
if (props_size != 1)
return LZMA_OPTIONS_ERROR;
- opt = lzma_alloc(sizeof(lzma_options_delta), allocator);
+ lzma_options_delta *opt
+ = lzma_alloc(sizeof(lzma_options_delta), allocator);
if (opt == NULL)
return LZMA_MEM_ERROR;
diff --git a/Utilities/cmliblzma/liblzma/delta/delta_decoder.h b/Utilities/cmliblzma/liblzma/delta/delta_decoder.h
index ae89acc59..ad89cc659 100644
--- a/Utilities/cmliblzma/liblzma/delta/delta_decoder.h
+++ b/Utilities/cmliblzma/liblzma/delta/delta_decoder.h
@@ -16,10 +16,11 @@
#include "delta_common.h"
extern lzma_ret lzma_delta_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern lzma_ret lzma_delta_props_decode(
- void **options, lzma_allocator *allocator,
+ void **options, const lzma_allocator *allocator,
const uint8_t *props, size_t props_size);
#endif
diff --git a/Utilities/cmliblzma/liblzma/delta/delta_encoder.c b/Utilities/cmliblzma/liblzma/delta/delta_encoder.c
index a39c154f1..384165151 100644
--- a/Utilities/cmliblzma/liblzma/delta/delta_encoder.c
+++ b/Utilities/cmliblzma/liblzma/delta/delta_encoder.c
@@ -18,13 +18,12 @@
/// is the first filter in the chain (and thus the last filter in the
/// encoder's filter stack).
static void
-copy_and_encode(lzma_coder *coder,
- const uint8_t *LZMA_RESTRICT in, uint8_t *LZMA_RESTRICT out, size_t size)
+copy_and_encode(lzma_delta_coder *coder,
+ const uint8_t *restrict in, uint8_t *restrict out, size_t size)
{
- size_t i;
const size_t distance = coder->distance;
- for (i = 0; i < size; ++i) {
+ for (size_t i = 0; i < size; ++i) {
const uint8_t tmp = coder->history[
(distance + coder->pos) & 0xFF];
coder->history[coder->pos-- & 0xFF] = in[i];
@@ -36,12 +35,11 @@ copy_and_encode(lzma_coder *coder,
/// Encodes the data in place. This is used when we are the last filter
/// in the chain (and thus non-last filter in the encoder's filter stack).
static void
-encode_in_place(lzma_coder *coder, uint8_t *buffer, size_t size)
+encode_in_place(lzma_delta_coder *coder, uint8_t *buffer, size_t size)
{
- size_t i;
const size_t distance = coder->distance;
- for (i = 0; i < size; ++i) {
+ for (size_t i = 0; i < size; ++i) {
const uint8_t tmp = coder->history[
(distance + coder->pos) & 0xFF];
coder->history[coder->pos-- & 0xFF] = buffer[i];
@@ -51,11 +49,13 @@ encode_in_place(lzma_coder *coder, uint8_t *buffer, size_t size)
static lzma_ret
-delta_encode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size, lzma_action action)
+delta_encode(void *coder_ptr, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size, lzma_action action)
{
+ lzma_delta_coder *coder = coder_ptr;
+
lzma_ret ret;
if (coder->next.code == NULL) {
@@ -86,10 +86,12 @@ delta_encode(lzma_coder *coder, lzma_allocator *allocator,
static lzma_ret
-delta_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
+delta_encoder_update(void *coder_ptr, const lzma_allocator *allocator,
const lzma_filter *filters_null lzma_attribute((__unused__)),
const lzma_filter *reversed_filters)
{
+ lzma_delta_coder *coder = coder_ptr;
+
// Delta doesn't and will never support changing the options in
// the middle of encoding. If the app tries to change them, we
// simply ignore them.
@@ -99,7 +101,7 @@ delta_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
extern lzma_ret
-lzma_delta_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_delta_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters)
{
next->code = &delta_encode;
@@ -111,13 +113,12 @@ lzma_delta_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern lzma_ret
lzma_delta_props_encode(const void *options, uint8_t *out)
{
- const lzma_options_delta *opt = options;
-
// The caller must have already validated the options, so it's
// LZMA_PROG_ERROR if they are invalid.
if (lzma_delta_coder_memusage(options) == UINT64_MAX)
return LZMA_PROG_ERROR;
+ const lzma_options_delta *opt = options;
out[0] = opt->dist - LZMA_DELTA_DIST_MIN;
return LZMA_OK;
diff --git a/Utilities/cmliblzma/liblzma/delta/delta_encoder.h b/Utilities/cmliblzma/liblzma/delta/delta_encoder.h
index a447862f2..4ab984785 100644
--- a/Utilities/cmliblzma/liblzma/delta/delta_encoder.h
+++ b/Utilities/cmliblzma/liblzma/delta/delta_encoder.h
@@ -16,7 +16,8 @@
#include "delta_common.h"
extern lzma_ret lzma_delta_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern lzma_ret lzma_delta_props_encode(const void *options, uint8_t *out);
diff --git a/Utilities/cmliblzma/liblzma/delta/delta_private.h b/Utilities/cmliblzma/liblzma/delta/delta_private.h
index 62b7fed86..0d6cb3866 100644
--- a/Utilities/cmliblzma/liblzma/delta/delta_private.h
+++ b/Utilities/cmliblzma/liblzma/delta/delta_private.h
@@ -15,7 +15,7 @@
#include "delta_common.h"
-struct lzma_coder_s {
+typedef struct {
/// Next coder in the chain
lzma_next_coder next;
@@ -27,11 +27,11 @@ struct lzma_coder_s {
/// Buffer to hold history of the original data
uint8_t history[LZMA_DELTA_DIST_MAX];
-};
+} lzma_delta_coder;
extern lzma_ret lzma_delta_coder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
+ lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters);
#endif
diff --git a/Utilities/cmliblzma/liblzma/liblzma.pc.in b/Utilities/cmliblzma/liblzma/liblzma.pc.in
index 7f11f1a20..9fa489115 100644
--- a/Utilities/cmliblzma/liblzma/liblzma.pc.in
+++ b/Utilities/cmliblzma/liblzma/liblzma.pc.in
@@ -16,4 +16,4 @@ URL: @PACKAGE_URL@
Version: @PACKAGE_VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -llzma
-Libs.private: @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
+Libs.private: @PTHREAD_CFLAGS@ @LIBS@
diff --git a/Utilities/cmliblzma/liblzma/lz/lz_decoder.c b/Utilities/cmliblzma/liblzma/lz/lz_decoder.c
index 9fa1bdc3a..c7086440b 100644
--- a/Utilities/cmliblzma/liblzma/lz/lz_decoder.c
+++ b/Utilities/cmliblzma/liblzma/lz/lz_decoder.c
@@ -20,7 +20,7 @@
#include "lz_decoder.h"
-struct lzma_coder_s {
+typedef struct {
/// Dictionary (history buffer)
lzma_dict dict;
@@ -48,7 +48,7 @@ struct lzma_coder_s {
size_t size;
uint8_t buffer[LZMA_BUFFER_SIZE];
} temp;
-};
+} lzma_coder;
static void
@@ -64,22 +64,18 @@ lz_decoder_reset(lzma_coder *coder)
static lzma_ret
decode_buffer(lzma_coder *coder,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size)
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size)
{
while (true) {
- size_t copy_size;
- size_t dict_start;
- lzma_ret ret;
-
// Wrap the dictionary if needed.
if (coder->dict.pos == coder->dict.size)
coder->dict.pos = 0;
// Store the current dictionary position. It is needed to know
// where to start copying to the out[] buffer.
- dict_start = coder->dict.pos;
+ const size_t dict_start = coder->dict.pos;
// Calculate how much we allow coder->lz.code() to decode.
// It must not decode past the end of the dictionary
@@ -90,13 +86,13 @@ decode_buffer(lzma_coder *coder,
coder->dict.size - coder->dict.pos);
// Call the coder->lz.code() to do the actual decoding.
- ret = coder->lz.code(
+ const lzma_ret ret = coder->lz.code(
coder->lz.coder, &coder->dict,
in, in_pos, in_size);
// Copy the decoded data from the dictionary to the out[]
// buffer.
- copy_size = coder->dict.pos - dict_start;
+ const size_t copy_size = coder->dict.pos - dict_start;
assert(copy_size <= out_size - *out_pos);
memcpy(out + *out_pos, coder->dict.buf + dict_start,
copy_size);
@@ -129,13 +125,15 @@ decode_buffer(lzma_coder *coder,
static lzma_ret
-lz_decode(lzma_coder *coder,
- lzma_allocator *allocator lzma_attribute((__unused__)),
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size,
+lz_decode(void *coder_ptr,
+ const lzma_allocator *allocator lzma_attribute((__unused__)),
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size,
lzma_action action)
{
+ lzma_coder *coder = coder_ptr;
+
if (coder->next.code == NULL)
return decode_buffer(coder, in, in_pos, in_size,
out, out_pos, out_size);
@@ -143,15 +141,13 @@ lz_decode(lzma_coder *coder,
// We aren't the last coder in the chain, we need to decode
// our input to a temporary buffer.
while (*out_pos < out_size) {
- lzma_ret ret;
-
// Fill the temporary buffer if it is empty.
if (!coder->next_finished
&& coder->temp.pos == coder->temp.size) {
coder->temp.pos = 0;
coder->temp.size = 0;
- ret = coder->next.code(
+ const lzma_ret ret = coder->next.code(
coder->next.coder,
allocator, in, in_pos, in_size,
coder->temp.buffer, &coder->temp.size,
@@ -173,7 +169,7 @@ lz_decode(lzma_coder *coder,
return LZMA_OK;
}
- ret = decode_buffer(coder, coder->temp.buffer,
+ const lzma_ret ret = decode_buffer(coder, coder->temp.buffer,
&coder->temp.pos, coder->temp.size,
out, out_pos, out_size);
@@ -190,8 +186,10 @@ lz_decode(lzma_coder *coder,
static void
-lz_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
+lz_decoder_end(void *coder_ptr, const lzma_allocator *allocator)
{
+ lzma_coder *coder = coder_ptr;
+
lzma_next_end(&coder->next, allocator);
lzma_free(coder->dict.buf, allocator);
@@ -206,32 +204,33 @@ lz_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
extern lzma_ret
-lzma_lz_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_lz_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters,
lzma_ret (*lz_init)(lzma_lz_decoder *lz,
- lzma_allocator *allocator, const void *options,
+ const lzma_allocator *allocator, const void *options,
lzma_lz_options *lz_options))
{
- lzma_lz_options lz_options;
-
// Allocate the base structure if it isn't already allocated.
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
+ lzma_coder *coder = next->coder;
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ next->coder = coder;
next->code = &lz_decode;
next->end = &lz_decoder_end;
- next->coder->dict.buf = NULL;
- next->coder->dict.size = 0;
- next->coder->lz = LZMA_LZ_DECODER_INIT;
- next->coder->next = LZMA_NEXT_CODER_INIT;
+ coder->dict.buf = NULL;
+ coder->dict.size = 0;
+ coder->lz = LZMA_LZ_DECODER_INIT;
+ coder->next = LZMA_NEXT_CODER_INIT;
}
// Allocate and initialize the LZ-based decoder. It will also give
// us the dictionary size.
- return_if_error(lz_init(&next->coder->lz, allocator,
+ lzma_lz_options lz_options;
+ return_if_error(lz_init(&coder->lz, allocator,
filters[0].options, &lz_options));
// If the dictionary size is very small, increase it to 4096 bytes.
@@ -255,14 +254,14 @@ lzma_lz_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
lz_options.dict_size = (lz_options.dict_size + 15) & ~((size_t)(15));
// Allocate and initialize the dictionary.
- if (next->coder->dict.size != lz_options.dict_size) {
- lzma_free(next->coder->dict.buf, allocator);
- next->coder->dict.buf
+ if (coder->dict.size != lz_options.dict_size) {
+ lzma_free(coder->dict.buf, allocator);
+ coder->dict.buf
= lzma_alloc(lz_options.dict_size, allocator);
- if (next->coder->dict.buf == NULL)
+ if (coder->dict.buf == NULL)
return LZMA_MEM_ERROR;
- next->coder->dict.size = lz_options.dict_size;
+ coder->dict.size = lz_options.dict_size;
}
lz_decoder_reset(next->coder);
@@ -275,21 +274,20 @@ lzma_lz_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
const size_t copy_size = my_min(lz_options.preset_dict_size,
lz_options.dict_size);
const size_t offset = lz_options.preset_dict_size - copy_size;
- memcpy(next->coder->dict.buf, lz_options.preset_dict + offset,
+ memcpy(coder->dict.buf, lz_options.preset_dict + offset,
copy_size);
- next->coder->dict.pos = copy_size;
- next->coder->dict.full = copy_size;
+ coder->dict.pos = copy_size;
+ coder->dict.full = copy_size;
}
// Miscellaneous initializations
- next->coder->next_finished = false;
- next->coder->this_finished = false;
- next->coder->temp.pos = 0;
- next->coder->temp.size = 0;
+ coder->next_finished = false;
+ coder->this_finished = false;
+ coder->temp.pos = 0;
+ coder->temp.size = 0;
// Initialize the next filter in the chain, if any.
- return lzma_next_filter_init(&next->coder->next, allocator,
- filters + 1);
+ return lzma_next_filter_init(&coder->next, allocator, filters + 1);
}
@@ -301,7 +299,8 @@ lzma_lz_decoder_memusage(size_t dictionary_size)
extern void
-lzma_lz_decoder_uncompressed(lzma_coder *coder, lzma_vli uncompressed_size)
+lzma_lz_decoder_uncompressed(void *coder_ptr, lzma_vli uncompressed_size)
{
+ lzma_coder *coder = coder_ptr;
coder->lz.set_uncompressed(coder->lz.coder, uncompressed_size);
}
diff --git a/Utilities/cmliblzma/liblzma/lz/lz_decoder.h b/Utilities/cmliblzma/liblzma/lz/lz_decoder.h
index 76011f2ad..754ccf37c 100644
--- a/Utilities/cmliblzma/liblzma/lz/lz_decoder.h
+++ b/Utilities/cmliblzma/liblzma/lz/lz_decoder.h
@@ -53,45 +53,45 @@ typedef struct {
typedef struct {
/// Data specific to the LZ-based decoder
- lzma_coder *coder;
+ void *coder;
/// Function to decode from in[] to *dict
- lzma_ret (*code)(lzma_coder *LZMA_RESTRICT coder,
- lzma_dict *LZMA_RESTRICT dict, const uint8_t *LZMA_RESTRICT in,
- size_t *LZMA_RESTRICT in_pos, size_t in_size);
+ lzma_ret (*code)(void *coder,
+ lzma_dict *restrict dict, const uint8_t *restrict in,
+ size_t *restrict in_pos, size_t in_size);
- void (*reset)(lzma_coder *coder, const void *options);
+ void (*reset)(void *coder, const void *options);
/// Set the uncompressed size
- void (*set_uncompressed)(lzma_coder *coder,
- lzma_vli uncompressed_size);
+ void (*set_uncompressed)(void *coder, lzma_vli uncompressed_size);
/// Free allocated resources
- void (*end)(lzma_coder *coder, lzma_allocator *allocator);
+ void (*end)(void *coder, const lzma_allocator *allocator);
} lzma_lz_decoder;
-static const lzma_lz_decoder LZMA_LZ_DECODER_INIT =
- {
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- };
+#define LZMA_LZ_DECODER_INIT \
+ (lzma_lz_decoder){ \
+ .coder = NULL, \
+ .code = NULL, \
+ .reset = NULL, \
+ .set_uncompressed = NULL, \
+ .end = NULL, \
+ }
extern lzma_ret lzma_lz_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters,
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters,
lzma_ret (*lz_init)(lzma_lz_decoder *lz,
- lzma_allocator *allocator, const void *options,
+ const lzma_allocator *allocator, const void *options,
lzma_lz_options *lz_options));
extern uint64_t lzma_lz_decoder_memusage(size_t dictionary_size);
extern void lzma_lz_decoder_uncompressed(
- lzma_coder *coder, lzma_vli uncompressed_size);
+ void *coder, lzma_vli uncompressed_size);
//////////////////////
@@ -151,15 +151,13 @@ dict_repeat(lzma_dict *dict, uint32_t distance, uint32_t *len)
dict->pos += left;
} else {
- uint32_t copy_pos;
- uint32_t copy_size;
-
// The bigger the dictionary, the more rare this
// case occurs. We need to "wrap" the dict, thus
// we might need two memcpy() to copy all the data.
assert(dict->full == dict->size);
- copy_pos = dict->pos - distance - 1 + dict->size;
- copy_size = dict->size - copy_pos;
+ const uint32_t copy_pos
+ = dict->pos - distance - 1 + dict->size;
+ uint32_t copy_size = dict->size - copy_pos;
if (copy_size < left) {
memmove(dict->buf + dict->pos, dict->buf + copy_pos,
@@ -202,9 +200,9 @@ dict_put(lzma_dict *dict, uint8_t byte)
/// Copies arbitrary amount of data into the dictionary.
static inline void
-dict_write(lzma_dict *LZMA_RESTRICT dict, const uint8_t *LZMA_RESTRICT in,
- size_t *LZMA_RESTRICT in_pos, size_t in_size,
- size_t *LZMA_RESTRICT left)
+dict_write(lzma_dict *restrict dict, const uint8_t *restrict in,
+ size_t *restrict in_pos, size_t in_size,
+ size_t *restrict left)
{
// NOTE: If we are being given more data than the size of the
// dictionary, it could be possible to optimize the LZ decoder
diff --git a/Utilities/cmliblzma/liblzma/lz/lz_encoder.c b/Utilities/cmliblzma/liblzma/lz/lz_encoder.c
index 1dae924b4..9a74b7c47 100644
--- a/Utilities/cmliblzma/liblzma/lz/lz_encoder.c
+++ b/Utilities/cmliblzma/liblzma/lz/lz_encoder.c
@@ -20,8 +20,10 @@
# include "lz_encoder_hash_table.h"
#endif
+#include "memcmplen.h"
-struct lzma_coder_s {
+
+typedef struct {
/// LZ-based encoder e.g. LZMA
lzma_lz_encoder lz;
@@ -30,7 +32,7 @@ struct lzma_coder_s {
/// Next coder in the chain
lzma_next_coder next;
-};
+} lzma_coder;
/// \brief Moves the data in the input window to free space for new data
@@ -43,18 +45,16 @@ struct lzma_coder_s {
static void
move_window(lzma_mf *mf)
{
- uint32_t move_offset;
- size_t move_size;
-
// Align the move to a multiple of 16 bytes. Some LZ-based encoders
// like LZMA use the lowest bits of mf->read_pos to know the
// alignment of the uncompressed data. We also get better speed
// for memmove() with aligned buffers.
assert(mf->read_pos > mf->keep_size_before);
- move_offset = (mf->read_pos - mf->keep_size_before) & ~UINT32_C(15);
+ const uint32_t move_offset
+ = (mf->read_pos - mf->keep_size_before) & ~UINT32_C(15);
assert(mf->write_pos > move_offset);
- move_size = mf->write_pos - move_offset;
+ const size_t move_size = mf->write_pos - move_offset;
assert(move_offset + move_size <= mf->size);
@@ -78,12 +78,10 @@ move_window(lzma_mf *mf)
/// This function must not be called once it has returned LZMA_STREAM_END.
///
static lzma_ret
-fill_window(lzma_coder *coder, lzma_allocator *allocator, const uint8_t *in,
- size_t *in_pos, size_t in_size, lzma_action action)
+fill_window(lzma_coder *coder, const lzma_allocator *allocator,
+ const uint8_t *in, size_t *in_pos, size_t in_size,
+ lzma_action action)
{
- size_t write_pos;
- lzma_ret ret;
-
assert(coder->mf.read_pos <= coder->mf.write_pos);
// Move the sliding window if needed.
@@ -93,7 +91,8 @@ fill_window(lzma_coder *coder, lzma_allocator *allocator, const uint8_t *in,
// Maybe this is ugly, but lzma_mf uses uint32_t for most things
// (which I find cleanest), but we need size_t here when filling
// the history window.
- write_pos = coder->mf.write_pos;
+ size_t write_pos = coder->mf.write_pos;
+ lzma_ret ret;
if (coder->next.code == NULL) {
// Not using a filter, simply memcpy() as much as possible.
lzma_bufcpy(in, in_pos, in_size, coder->mf.buffer,
@@ -111,6 +110,12 @@ fill_window(lzma_coder *coder, lzma_allocator *allocator, const uint8_t *in,
coder->mf.write_pos = write_pos;
+ // Silence Valgrind. lzma_memcmplen() can read extra bytes
+ // and Valgrind will give warnings if those bytes are uninitialized
+ // because Valgrind cannot see that the values of the uninitialized
+ // bytes are eventually ignored.
+ memzero(coder->mf.buffer + write_pos, LZMA_MEMCMPLEN_EXTRA);
+
// If end of stream has been reached or flushing completed, we allow
// the encoder to process all the input (that is, read_pos is allowed
// to reach write_pos). Otherwise we keep keep_size_after bytes
@@ -134,7 +139,7 @@ fill_window(lzma_coder *coder, lzma_allocator *allocator, const uint8_t *in,
&& coder->mf.read_pos < coder->mf.read_limit) {
// Match finder may update coder->pending and expects it to
// start from zero, so use a temporary variable.
- const size_t pending = coder->mf.pending;
+ const uint32_t pending = coder->mf.pending;
coder->mf.pending = 0;
// Rewind read_pos so that the match finder can hash
@@ -152,16 +157,16 @@ fill_window(lzma_coder *coder, lzma_allocator *allocator, const uint8_t *in,
static lzma_ret
-lz_encode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
+lz_encode(void *coder_ptr, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
size_t in_size,
- uint8_t *LZMA_RESTRICT out, size_t *LZMA_RESTRICT out_pos,
+ uint8_t *restrict out, size_t *restrict out_pos,
size_t out_size, lzma_action action)
{
+ lzma_coder *coder = coder_ptr;
+
while (*out_pos < out_size
&& (*in_pos < in_size || action != LZMA_RUN)) {
- lzma_ret ret;
-
// Read more data to coder->mf.buffer if needed.
if (coder->mf.action == LZMA_RUN && coder->mf.read_pos
>= coder->mf.read_limit)
@@ -169,7 +174,7 @@ lz_encode(lzma_coder *coder, lzma_allocator *allocator,
in, in_pos, in_size, action));
// Encode
- ret = coder->lz.code(coder->lz.coder,
+ const lzma_ret ret = coder->lz.code(coder->lz.coder,
&coder->mf, out, out_pos, out_size);
if (ret != LZMA_OK) {
// Setting this to LZMA_RUN for cases when we are
@@ -185,17 +190,9 @@ lz_encode(lzma_coder *coder, lzma_allocator *allocator,
static bool
-lz_encoder_prepare(lzma_mf *mf, lzma_allocator *allocator,
+lz_encoder_prepare(lzma_mf *mf, const lzma_allocator *allocator,
const lzma_lz_options *lz_options)
{
- bool is_bt;
- uint32_t new_count;
- uint32_t reserve;
- uint32_t old_size;
- uint32_t hash_bytes;
- uint32_t hs;
- uint32_t old_count;
-
// For now, the dictionary size is limited to 1.5 GiB. This may grow
// in the future if needed, but it needs a little more work than just
// changing this check.
@@ -221,14 +218,14 @@ lz_encoder_prepare(lzma_mf *mf, lzma_allocator *allocator,
// to size_t.
// - Memory usage calculation needs something too, e.g. use uint64_t
// for mf->size.
- reserve = lz_options->dict_size / 2;
+ uint32_t reserve = lz_options->dict_size / 2;
if (reserve > (UINT32_C(1) << 30))
reserve /= 2;
reserve += (lz_options->before_size + lz_options->match_len_max
+ lz_options->after_size) / 2 + (UINT32_C(1) << 19);
- old_size = mf->size;
+ const uint32_t old_size = mf->size;
mf->size = mf->keep_size_before + reserve + mf->keep_size_after;
// Deallocate the old history buffer if it exists but has different
@@ -298,11 +295,12 @@ lz_encoder_prepare(lzma_mf *mf, lzma_allocator *allocator,
// Calculate the sizes of mf->hash and mf->son and check that
// nice_len is big enough for the selected match finder.
- hash_bytes = lz_options->match_finder & 0x0F;
+ const uint32_t hash_bytes = lz_options->match_finder & 0x0F;
if (hash_bytes > mf->nice_len)
return true;
- is_bt = (lz_options->match_finder & 0x10) != 0;
+ const bool is_bt = (lz_options->match_finder & 0x10) != 0;
+ uint32_t hs;
if (hash_bytes == 2) {
hs = 0xFFFF;
@@ -338,25 +336,22 @@ lz_encoder_prepare(lzma_mf *mf, lzma_allocator *allocator,
hs += HASH_4_SIZE;
*/
- // If the above code calculating hs is modified, make sure that
- // this assertion stays valid (UINT32_MAX / 5 is not strictly the
- // exact limit). If it doesn't, you need to calculate that
- // hash_size_sum + sons_count cannot overflow.
- assert(hs < UINT32_MAX / 5);
-
- old_count = mf->hash_size_sum + mf->sons_count;
- mf->hash_size_sum = hs;
+ const uint32_t old_hash_count = mf->hash_count;
+ const uint32_t old_sons_count = mf->sons_count;
+ mf->hash_count = hs;
mf->sons_count = mf->cyclic_size;
if (is_bt)
mf->sons_count *= 2;
- new_count = mf->hash_size_sum + mf->sons_count;
-
// Deallocate the old hash array if it exists and has different size
// than what is needed now.
- if (old_count != new_count) {
+ if (old_hash_count != mf->hash_count
+ || old_sons_count != mf->sons_count) {
lzma_free(mf->hash, allocator);
mf->hash = NULL;
+
+ lzma_free(mf->son, allocator);
+ mf->son = NULL;
}
// Maximum number of match finder cycles
@@ -373,16 +368,23 @@ lz_encoder_prepare(lzma_mf *mf, lzma_allocator *allocator,
static bool
-lz_encoder_init(lzma_mf *mf, lzma_allocator *allocator,
+lz_encoder_init(lzma_mf *mf, const lzma_allocator *allocator,
const lzma_lz_options *lz_options)
{
- size_t alloc_count;
-
// Allocate the history buffer.
if (mf->buffer == NULL) {
- mf->buffer = lzma_alloc(mf->size, allocator);
+ // lzma_memcmplen() is used for the dictionary buffer
+ // so we need to allocate a few extra bytes to prevent
+ // it from reading past the end of the buffer.
+ mf->buffer = lzma_alloc(mf->size + LZMA_MEMCMPLEN_EXTRA,
+ allocator);
if (mf->buffer == NULL)
return true;
+
+ // Keep Valgrind happy with lzma_memcmplen() and initialize
+ // the extra bytes whose value may get read but which will
+ // effectively get ignored.
+ memzero(mf->buffer + mf->size, LZMA_MEMCMPLEN_EXTRA);
}
// Use cyclic_size as initial mf->offset. This allows
@@ -396,43 +398,48 @@ lz_encoder_init(lzma_mf *mf, lzma_allocator *allocator,
mf->write_pos = 0;
mf->pending = 0;
- // Allocate match finder's hash array.
- alloc_count = mf->hash_size_sum + mf->sons_count;
-
#if UINT32_MAX >= SIZE_MAX / 4
// Check for integer overflow. (Huge dictionaries are not
// possible on 32-bit CPU.)
- if (alloc_count > SIZE_MAX / sizeof(uint32_t))
+ if (mf->hash_count > SIZE_MAX / sizeof(uint32_t)
+ || mf->sons_count > SIZE_MAX / sizeof(uint32_t))
return true;
#endif
+ // Allocate and initialize the hash table. Since EMPTY_HASH_VALUE
+ // is zero, we can use lzma_alloc_zero() or memzero() for mf->hash.
+ //
+ // We don't need to initialize mf->son, but not doing that may
+ // make Valgrind complain in normalization (see normalize() in
+ // lz_encoder_mf.c). Skipping the initialization is *very* good
+ // when big dictionary is used but only small amount of data gets
+ // actually compressed: most of the mf->son won't get actually
+ // allocated by the kernel, so we avoid wasting RAM and improve
+ // initialization speed a lot.
if (mf->hash == NULL) {
- mf->hash = lzma_alloc(alloc_count * sizeof(uint32_t),
+ mf->hash = lzma_alloc_zero(mf->hash_count * sizeof(uint32_t),
+ allocator);
+ mf->son = lzma_alloc(mf->sons_count * sizeof(uint32_t),
allocator);
- if (mf->hash == NULL)
- return true;
- }
- mf->son = mf->hash + mf->hash_size_sum;
- mf->cyclic_pos = 0;
+ if (mf->hash == NULL || mf->son == NULL) {
+ lzma_free(mf->hash, allocator);
+ mf->hash = NULL;
+
+ lzma_free(mf->son, allocator);
+ mf->son = NULL;
- // Initialize the hash table. Since EMPTY_HASH_VALUE is zero, we
- // can use memset().
+ return true;
+ }
+ } else {
/*
- for (uint32_t i = 0; i < hash_size_sum; ++i)
- mf->hash[i] = EMPTY_HASH_VALUE;
+ for (uint32_t i = 0; i < mf->hash_count; ++i)
+ mf->hash[i] = EMPTY_HASH_VALUE;
*/
- memzero(mf->hash, (size_t)(mf->hash_size_sum) * sizeof(uint32_t));
+ memzero(mf->hash, mf->hash_count * sizeof(uint32_t));
+ }
- // We don't need to initialize mf->son, but not doing that will
- // make Valgrind complain in normalization (see normalize() in
- // lz_encoder_mf.c).
- //
- // Skipping this initialization is *very* good when big dictionary is
- // used but only small amount of data gets actually compressed: most
- // of the mf->hash won't get actually allocated by the kernel, so
- // we avoid wasting RAM and improve initialization speed a lot.
- //memzero(mf->son, (size_t)(mf->sons_count) * sizeof(uint32_t));
+ mf->cyclic_pos = 0;
// Handle preset dictionary.
if (lz_options->preset_dict != NULL
@@ -457,24 +464,32 @@ extern uint64_t
lzma_lz_encoder_memusage(const lzma_lz_options *lz_options)
{
// Old buffers must not exist when calling lz_encoder_prepare().
- lzma_mf mf = { NULL };
+ lzma_mf mf = {
+ .buffer = NULL,
+ .hash = NULL,
+ .son = NULL,
+ .hash_count = 0,
+ .sons_count = 0,
+ };
// Setup the size information into mf.
if (lz_encoder_prepare(&mf, NULL, lz_options))
return UINT64_MAX;
// Calculate the memory usage.
- return (uint64_t)(mf.hash_size_sum + mf.sons_count)
- * sizeof(uint32_t)
- + (uint64_t)(mf.size) + sizeof(lzma_coder);
+ return ((uint64_t)(mf.hash_count) + mf.sons_count) * sizeof(uint32_t)
+ + mf.size + sizeof(lzma_coder);
}
static void
-lz_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
+lz_encoder_end(void *coder_ptr, const lzma_allocator *allocator)
{
+ lzma_coder *coder = coder_ptr;
+
lzma_next_end(&coder->next, allocator);
+ lzma_free(coder->mf.son, allocator);
lzma_free(coder->mf.hash, allocator);
lzma_free(coder->mf.buffer, allocator);
@@ -489,10 +504,12 @@ lz_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
-lz_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
+lz_encoder_update(void *coder_ptr, const lzma_allocator *allocator,
const lzma_filter *filters_null lzma_attribute((__unused__)),
const lzma_filter *reversed_filters)
{
+ lzma_coder *coder = coder_ptr;
+
if (coder->lz.options_update == NULL)
return LZMA_PROG_ERROR;
@@ -505,58 +522,63 @@ lz_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
extern lzma_ret
-lzma_lz_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_lz_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters,
lzma_ret (*lz_init)(lzma_lz_encoder *lz,
- lzma_allocator *allocator, const void *options,
+ const lzma_allocator *allocator, const void *options,
lzma_lz_options *lz_options))
{
- lzma_lz_options lz_options;
-
#ifdef HAVE_SMALL
// We need that the CRC32 table has been initialized.
lzma_crc32_init();
#endif
// Allocate and initialize the base data structure.
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
+ lzma_coder *coder = next->coder;
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ next->coder = coder;
next->code = &lz_encode;
next->end = &lz_encoder_end;
next->update = &lz_encoder_update;
- next->coder->lz.coder = NULL;
- next->coder->lz.code = NULL;
- next->coder->lz.end = NULL;
-
- next->coder->mf.buffer = NULL;
- next->coder->mf.hash = NULL;
- next->coder->mf.hash_size_sum = 0;
- next->coder->mf.sons_count = 0;
-
- next->coder->next = LZMA_NEXT_CODER_INIT;
+ coder->lz.coder = NULL;
+ coder->lz.code = NULL;
+ coder->lz.end = NULL;
+
+ // mf.size is initialized to silence Valgrind
+ // when used on optimized binaries (GCC may reorder
+ // code in a way that Valgrind gets unhappy).
+ coder->mf.buffer = NULL;
+ coder->mf.size = 0;
+ coder->mf.hash = NULL;
+ coder->mf.son = NULL;
+ coder->mf.hash_count = 0;
+ coder->mf.sons_count = 0;
+
+ coder->next = LZMA_NEXT_CODER_INIT;
}
// Initialize the LZ-based encoder.
- return_if_error(lz_init(&next->coder->lz, allocator,
+ lzma_lz_options lz_options;
+ return_if_error(lz_init(&coder->lz, allocator,
filters[0].options, &lz_options));
- // Setup the size information into next->coder->mf and deallocate
+ // Setup the size information into coder->mf and deallocate
// old buffers if they have wrong size.
- if (lz_encoder_prepare(&next->coder->mf, allocator, &lz_options))
+ if (lz_encoder_prepare(&coder->mf, allocator, &lz_options))
return LZMA_OPTIONS_ERROR;
// Allocate new buffers if needed, and do the rest of
// the initialization.
- if (lz_encoder_init(&next->coder->mf, allocator, &lz_options))
+ if (lz_encoder_init(&coder->mf, allocator, &lz_options))
return LZMA_MEM_ERROR;
// Initialize the next filter in the chain, if any.
- return lzma_next_filter_init(&next->coder->next, allocator,
- filters + 1);
+ return lzma_next_filter_init(&coder->next, allocator, filters + 1);
}
diff --git a/Utilities/cmliblzma/liblzma/lz/lz_encoder.h b/Utilities/cmliblzma/liblzma/lz/lz_encoder.h
index dcb4b2c5b..426dcd8a3 100644
--- a/Utilities/cmliblzma/liblzma/lz/lz_encoder.h
+++ b/Utilities/cmliblzma/liblzma/lz/lz_encoder.h
@@ -119,7 +119,7 @@ struct lzma_mf_s {
lzma_action action;
/// Number of elements in hash[]
- uint32_t hash_size_sum;
+ uint32_t hash_count;
/// Number of elements in son[]
uint32_t sons_count;
@@ -191,19 +191,18 @@ typedef struct {
typedef struct {
/// Data specific to the LZ-based encoder
- lzma_coder *coder;
+ void *coder;
/// Function to encode from *dict to out[]
- lzma_ret (*code)(lzma_coder *LZMA_RESTRICT coder,
- lzma_mf *LZMA_RESTRICT mf, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size);
+ lzma_ret (*code)(void *coder,
+ lzma_mf *restrict mf, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size);
/// Free allocated resources
- void (*end)(lzma_coder *coder, lzma_allocator *allocator);
+ void (*end)(void *coder, const lzma_allocator *allocator);
/// Update the options in the middle of the encoding.
- lzma_ret (*options_update)(lzma_coder *coder,
- const lzma_filter *filter);
+ lzma_ret (*options_update)(void *coder, const lzma_filter *filter);
} lzma_lz_encoder;
@@ -218,7 +217,7 @@ typedef struct {
/// Get pointer to the first byte not ran through the match finder
-static inline uint8_t *
+static inline const uint8_t *
mf_ptr(const lzma_mf *mf)
{
return mf->buffer + mf->read_pos;
@@ -296,10 +295,10 @@ mf_read(lzma_mf *mf, uint8_t *out, size_t *out_pos, size_t out_size,
extern lzma_ret lzma_lz_encoder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
+ lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters,
lzma_ret (*lz_init)(lzma_lz_encoder *lz,
- lzma_allocator *allocator, const void *options,
+ const lzma_allocator *allocator, const void *options,
lzma_lz_options *lz_options));
diff --git a/Utilities/cmliblzma/liblzma/lz/lz_encoder_hash.h b/Utilities/cmliblzma/liblzma/lz/lz_encoder_hash.h
index de17c54fc..342a333d1 100644
--- a/Utilities/cmliblzma/liblzma/lz/lz_encoder_hash.h
+++ b/Utilities/cmliblzma/liblzma/lz/lz_encoder_hash.h
@@ -39,22 +39,25 @@
// Endianness doesn't matter in hash_2_calc() (no effect on the output).
#ifdef TUKLIB_FAST_UNALIGNED_ACCESS
# define hash_2_calc() \
- hash_value = *(const uint16_t *)(cur)
+ const uint32_t hash_value = *(const uint16_t *)(cur)
#else
# define hash_2_calc() \
- hash_value = (uint32_t)(cur[0]) | ((uint32_t)(cur[1]) << 8)
+ const uint32_t hash_value \
+ = (uint32_t)(cur[0]) | ((uint32_t)(cur[1]) << 8)
#endif
#define hash_3_calc() \
- temp = hash_table[cur[0]] ^ cur[1]; \
- hash_2_value = temp & HASH_2_MASK; \
- hash_value = (temp ^ ((uint32_t)(cur[2]) << 8)) & mf->hash_mask
+ const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \
+ const uint32_t hash_2_value = temp & HASH_2_MASK; \
+ const uint32_t hash_value \
+ = (temp ^ ((uint32_t)(cur[2]) << 8)) & mf->hash_mask
#define hash_4_calc() \
- temp = hash_table[cur[0]] ^ cur[1]; \
- hash_2_value = temp & HASH_2_MASK; \
- hash_3_value = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \
- hash_value = (temp ^ ((uint32_t)(cur[2]) << 8) \
+ const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \
+ const uint32_t hash_2_value = temp & HASH_2_MASK; \
+ const uint32_t hash_3_value \
+ = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \
+ const uint32_t hash_value = (temp ^ ((uint32_t)(cur[2]) << 8) \
^ (hash_table[cur[3]] << 5)) & mf->hash_mask
diff --git a/Utilities/cmliblzma/liblzma/lz/lz_encoder_mf.c b/Utilities/cmliblzma/liblzma/lz/lz_encoder_mf.c
index 50c3459aa..78520779f 100644
--- a/Utilities/cmliblzma/liblzma/lz/lz_encoder_mf.c
+++ b/Utilities/cmliblzma/liblzma/lz/lz_encoder_mf.c
@@ -13,6 +13,7 @@
#include "lz_encoder.h"
#include "lz_encoder_hash.h"
+#include "memcmplen.h"
/// \brief Find matches starting from the current byte
@@ -32,9 +33,8 @@ lzma_mf_find(lzma_mf *mf, uint32_t *count_ptr, lzma_match *matches)
if (count > 0) {
#ifndef NDEBUG
- uint32_t i;
// Validate the matches.
- for (i = 0; i < count; ++i) {
+ for (uint32_t i = 0; i < count; ++i) {
assert(matches[i].len <= mf->nice_len);
assert(matches[i].dist < mf->read_pos);
assert(memcmp(mf_ptr(mf) - 1,
@@ -50,9 +50,6 @@ lzma_mf_find(lzma_mf *mf, uint32_t *count_ptr, lzma_match *matches)
// If a match of maximum search length was found, try to
// extend the match to maximum possible length.
if (len_best == mf->nice_len) {
- uint8_t *p1;
- uint8_t *p2;
-
// The limit for the match length is either the
// maximum match length supported by the LZ-based
// encoder or the number of bytes left in the
@@ -63,15 +60,13 @@ lzma_mf_find(lzma_mf *mf, uint32_t *count_ptr, lzma_match *matches)
// Pointer to the byte we just ran through
// the match finder.
- p1 = mf_ptr(mf) - 1;
+ const uint8_t *p1 = mf_ptr(mf) - 1;
// Pointer to the beginning of the match. We need -1
// here because the match distances are zero based.
- p2 = p1 - matches[count - 1].dist - 1;
+ const uint8_t *p2 = p1 - matches[count - 1].dist - 1;
- while (len_best < limit
- && p1[len_best] == p2[len_best])
- ++len_best;
+ len_best = lzma_memcmplen(p1, p2, len_best, limit);
}
}
@@ -112,36 +107,35 @@ lzma_mf_find(lzma_mf *mf, uint32_t *count_ptr, lzma_match *matches)
static void
normalize(lzma_mf *mf)
{
- uint32_t i;
- uint32_t subvalue;
- uint32_t count;
- uint32_t *hash;
-
assert(mf->read_pos + mf->offset == MUST_NORMALIZE_POS);
// In future we may not want to touch the lowest bits, because there
// may be match finders that use larger resolution than one byte.
- subvalue = (MUST_NORMALIZE_POS - mf->cyclic_size);
+ const uint32_t subvalue
+ = (MUST_NORMALIZE_POS - mf->cyclic_size);
// & (~(UINT32_C(1) << 10) - 1);
- count = mf->hash_size_sum + mf->sons_count;
- hash = mf->hash;
-
- for (i = 0; i < count; ++i) {
+ for (uint32_t i = 0; i < mf->hash_count; ++i) {
// If the distance is greater than the dictionary size,
// we can simply mark the hash element as empty.
+ if (mf->hash[i] <= subvalue)
+ mf->hash[i] = EMPTY_HASH_VALUE;
+ else
+ mf->hash[i] -= subvalue;
+ }
+
+ for (uint32_t i = 0; i < mf->sons_count; ++i) {
+ // Do the same for mf->son.
//
- // NOTE: Only the first mf->hash_size_sum elements are
- // initialized for sure. There may be uninitialized elements
- // in mf->son. Since we go through both mf->hash and
- // mf->son here in normalization, Valgrind may complain
- // that the "if" below depends on uninitialized value. In
- // this case it is safe to ignore the warning. See also the
- // comments in lz_encoder_init() in lz_encoder.c.
- if (hash[i] <= subvalue)
- hash[i] = EMPTY_HASH_VALUE;
+ // NOTE: There may be uninitialized elements in mf->son.
+ // Valgrind may complain that the "if" below depends on
+ // an uninitialized value. In this case it is safe to ignore
+ // the warning. See also the comments in lz_encoder_init()
+ // in lz_encoder.c.
+ if (mf->son[i] <= subvalue)
+ mf->son[i] = EMPTY_HASH_VALUE;
else
- hash[i] -= subvalue;
+ mf->son[i] -= subvalue;
}
// Update offset to match the new locations.
@@ -204,14 +198,15 @@ move_pending(lzma_mf *mf)
move_pending(mf); \
ret_op; \
} \
- cur = mf_ptr(mf); \
- pos = mf->read_pos + mf->offset
+ const uint8_t *cur = mf_ptr(mf); \
+ const uint32_t pos = mf->read_pos + mf->offset
/// Header for find functions. "return 0" indicates that zero matches
/// were found.
#define header_find(is_bt, len_min) \
- header(is_bt, len_min, return 0)
+ header(is_bt, len_min, return 0); \
+ uint32_t matches_count = 0
/// Header for a loop in a skip function. "continue" tells to skip the rest
@@ -268,19 +263,15 @@ hc_find_func(
while (true) {
const uint32_t delta = pos - cur_match;
- const uint8_t *pb;
if (depth-- == 0 || delta >= cyclic_size)
return matches;
- pb = cur - delta;
+ const uint8_t *const pb = cur - delta;
cur_match = son[cyclic_pos - delta
+ (delta > cyclic_pos ? cyclic_size : 0)];
if (pb[len_best] == cur[len_best] && pb[0] == cur[0]) {
- uint32_t len = 0;
- while (++len != len_limit)
- if (pb[len] != cur[len])
- break;
+ uint32_t len = lzma_memcmplen(pb, cur, 1, len_limit);
if (len_best < len) {
len_best = len;
@@ -313,27 +304,21 @@ do { \
extern uint32_t
lzma_mf_hc3_find(lzma_mf *mf, lzma_match *matches)
{
- const uint8_t *cur;
- uint32_t pos;
- uint32_t temp, hash_value, hash_2_value; /* hash_3_calc */
- uint32_t delta2, cur_match;
- uint32_t len_best = 2;
- uint32_t matches_count = 0;
-
header_find(false, 3);
hash_3_calc();
- delta2 = pos - mf->hash[hash_2_value];
- cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value];
+ const uint32_t delta2 = pos - mf->hash[hash_2_value];
+ const uint32_t cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value];
mf->hash[hash_2_value] = pos;
mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;
+ uint32_t len_best = 2;
+
if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
- for ( ; len_best != len_limit; ++len_best)
- if (*(cur + len_best - delta2) != cur[len_best])
- break;
+ len_best = lzma_memcmplen(cur - delta2, cur,
+ len_best, len_limit);
matches[0].len = len_best;
matches[0].dist = delta2 - 1;
@@ -353,22 +338,18 @@ extern void
lzma_mf_hc3_skip(lzma_mf *mf, uint32_t amount)
{
do {
- const uint8_t *cur;
- uint32_t pos;
- uint32_t temp, hash_value, hash_2_value; /* hash_3_calc */
- uint32_t cur_match;
-
if (mf_avail(mf) < 3) {
move_pending(mf);
continue;
}
- cur = mf_ptr(mf);
- pos = mf->read_pos + mf->offset;
+ const uint8_t *cur = mf_ptr(mf);
+ const uint32_t pos = mf->read_pos + mf->offset;
hash_3_calc();
- cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value];
+ const uint32_t cur_match
+ = mf->hash[FIX_3_HASH_SIZE + hash_value];
mf->hash[hash_2_value] = pos;
mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;
@@ -384,25 +365,21 @@ lzma_mf_hc3_skip(lzma_mf *mf, uint32_t amount)
extern uint32_t
lzma_mf_hc4_find(lzma_mf *mf, lzma_match *matches)
{
- const uint8_t *cur;
- uint32_t pos;
- uint32_t temp, hash_value, hash_2_value, hash_3_value; /* hash_4_calc */
- uint32_t delta2, delta3, cur_match;
- uint32_t len_best = 1;
- uint32_t matches_count = 0;
-
header_find(false, 4);
hash_4_calc();
- delta2 = pos - mf->hash[hash_2_value];
- delta3 = pos - mf->hash[FIX_3_HASH_SIZE + hash_3_value];
- cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value];
+ uint32_t delta2 = pos - mf->hash[hash_2_value];
+ const uint32_t delta3
+ = pos - mf->hash[FIX_3_HASH_SIZE + hash_3_value];
+ const uint32_t cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value];
mf->hash[hash_2_value ] = pos;
mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;
mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;
+ uint32_t len_best = 1;
+
if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
len_best = 2;
matches[0].len = 2;
@@ -418,9 +395,8 @@ lzma_mf_hc4_find(lzma_mf *mf, lzma_match *matches)
}
if (matches_count != 0) {
- for ( ; len_best != len_limit; ++len_best)
- if (*(cur + len_best - delta2) != cur[len_best])
- break;
+ len_best = lzma_memcmplen(cur - delta2, cur,
+ len_best, len_limit);
matches[matches_count - 1].len = len_best;
@@ -441,22 +417,18 @@ extern void
lzma_mf_hc4_skip(lzma_mf *mf, uint32_t amount)
{
do {
- const uint8_t *cur;
- uint32_t pos;
- uint32_t temp, hash_value, hash_2_value, hash_3_value; /* hash_4_calc */
- uint32_t cur_match;
-
if (mf_avail(mf) < 4) {
move_pending(mf);
continue;
}
- cur = mf_ptr(mf);
- pos = mf->read_pos + mf->offset;
+ const uint8_t *cur = mf_ptr(mf);
+ const uint32_t pos = mf->read_pos + mf->offset;
hash_4_calc();
- cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value];
+ const uint32_t cur_match
+ = mf->hash[FIX_4_HASH_SIZE + hash_value];
mf->hash[hash_2_value] = pos;
mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;
@@ -494,10 +466,6 @@ bt_find_func(
uint32_t len1 = 0;
while (true) {
- uint32_t *pair;
- const uint8_t *pb;
- uint32_t len;
-
const uint32_t delta = pos - cur_match;
if (depth-- == 0 || delta >= cyclic_size) {
*ptr0 = EMPTY_HASH_VALUE;
@@ -505,17 +473,15 @@ bt_find_func(
return matches;
}
- pair = son + ((cyclic_pos - delta
+ uint32_t *const pair = son + ((cyclic_pos - delta
+ (delta > cyclic_pos ? cyclic_size : 0))
<< 1);
- pb = cur - delta;
- len = my_min(len0, len1);
+ const uint8_t *const pb = cur - delta;
+ uint32_t len = my_min(len0, len1);
if (pb[len] == cur[len]) {
- while (++len != len_limit)
- if (pb[len] != cur[len])
- break;
+ len = lzma_memcmplen(pb, cur, len + 1, len_limit);
if (len_best < len) {
len_best = len;
@@ -564,10 +530,6 @@ bt_skip_func(
uint32_t len1 = 0;
while (true) {
- uint32_t *pair;
- const uint8_t *pb;
- uint32_t len;
-
const uint32_t delta = pos - cur_match;
if (depth-- == 0 || delta >= cyclic_size) {
*ptr0 = EMPTY_HASH_VALUE;
@@ -575,16 +537,14 @@ bt_skip_func(
return;
}
- pair = son + ((cyclic_pos - delta
+ uint32_t *pair = son + ((cyclic_pos - delta
+ (delta > cyclic_pos ? cyclic_size : 0))
<< 1);
- pb = cur - delta;
- len = my_min(len0, len1);
+ const uint8_t *pb = cur - delta;
+ uint32_t len = my_min(len0, len1);
if (pb[len] == cur[len]) {
- while (++len != len_limit)
- if (pb[len] != cur[len])
- break;
+ len = lzma_memcmplen(pb, cur, len + 1, len_limit);
if (len == len_limit) {
*ptr1 = pair[0];
@@ -626,17 +586,11 @@ do { \
extern uint32_t
lzma_mf_bt2_find(lzma_mf *mf, lzma_match *matches)
{
- const uint8_t *cur;
- uint32_t pos;
- uint32_t hash_value; /* hash_2_calc */
- uint32_t cur_match;
- uint32_t matches_count = 0;
-
header_find(true, 2);
hash_2_calc();
- cur_match = mf->hash[hash_value];
+ const uint32_t cur_match = mf->hash[hash_value];
mf->hash[hash_value] = pos;
bt_find(1);
@@ -647,16 +601,11 @@ extern void
lzma_mf_bt2_skip(lzma_mf *mf, uint32_t amount)
{
do {
- const uint8_t *cur;
- uint32_t pos;
- uint32_t hash_value; /* hash_2_calc */
- uint32_t cur_match;
-
header_skip(true, 2);
hash_2_calc();
- cur_match = mf->hash[hash_value];
+ const uint32_t cur_match = mf->hash[hash_value];
mf->hash[hash_value] = pos;
bt_skip();
@@ -670,27 +619,21 @@ lzma_mf_bt2_skip(lzma_mf *mf, uint32_t amount)
extern uint32_t
lzma_mf_bt3_find(lzma_mf *mf, lzma_match *matches)
{
- const uint8_t *cur;
- uint32_t pos;
- uint32_t temp, hash_value, hash_2_value; /* hash_3_calc */
- uint32_t delta2, cur_match;
- uint32_t len_best = 2;
- uint32_t matches_count = 0;
-
header_find(true, 3);
hash_3_calc();
- delta2 = pos - mf->hash[hash_2_value];
- cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value];
+ const uint32_t delta2 = pos - mf->hash[hash_2_value];
+ const uint32_t cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value];
mf->hash[hash_2_value] = pos;
mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;
+ uint32_t len_best = 2;
+
if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
- for ( ; len_best != len_limit; ++len_best)
- if (*(cur + len_best - delta2) != cur[len_best])
- break;
+ len_best = lzma_memcmplen(
+ cur, cur - delta2, len_best, len_limit);
matches[0].len = len_best;
matches[0].dist = delta2 - 1;
@@ -710,16 +653,12 @@ extern void
lzma_mf_bt3_skip(lzma_mf *mf, uint32_t amount)
{
do {
- const uint8_t *cur;
- uint32_t pos;
- uint32_t temp, hash_value, hash_2_value; /* hash_3_calc */
- uint32_t cur_match;
-
header_skip(true, 3);
hash_3_calc();
- cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value];
+ const uint32_t cur_match
+ = mf->hash[FIX_3_HASH_SIZE + hash_value];
mf->hash[hash_2_value] = pos;
mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;
@@ -735,25 +674,21 @@ lzma_mf_bt3_skip(lzma_mf *mf, uint32_t amount)
extern uint32_t
lzma_mf_bt4_find(lzma_mf *mf, lzma_match *matches)
{
- const uint8_t *cur;
- uint32_t pos;
- uint32_t temp, hash_value, hash_2_value, hash_3_value; /* hash_4_calc */
- uint32_t delta2, delta3, cur_match;
- uint32_t len_best = 1;
- uint32_t matches_count = 0;
-
header_find(true, 4);
hash_4_calc();
- delta2 = pos - mf->hash[hash_2_value];
- delta3 = pos - mf->hash[FIX_3_HASH_SIZE + hash_3_value];
- cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value];
+ uint32_t delta2 = pos - mf->hash[hash_2_value];
+ const uint32_t delta3
+ = pos - mf->hash[FIX_3_HASH_SIZE + hash_3_value];
+ const uint32_t cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value];
mf->hash[hash_2_value] = pos;
mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;
mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;
+ uint32_t len_best = 1;
+
if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
len_best = 2;
matches[0].len = 2;
@@ -769,9 +704,8 @@ lzma_mf_bt4_find(lzma_mf *mf, lzma_match *matches)
}
if (matches_count != 0) {
- for ( ; len_best != len_limit; ++len_best)
- if (*(cur + len_best - delta2) != cur[len_best])
- break;
+ len_best = lzma_memcmplen(
+ cur, cur - delta2, len_best, len_limit);
matches[matches_count - 1].len = len_best;
@@ -792,16 +726,12 @@ extern void
lzma_mf_bt4_skip(lzma_mf *mf, uint32_t amount)
{
do {
- const uint8_t *cur;
- uint32_t pos;
- uint32_t temp, hash_value, hash_2_value, hash_3_value; /* hash_4_calc */
- uint32_t cur_match;
-
header_skip(true, 4);
hash_4_calc();
- cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value];
+ const uint32_t cur_match
+ = mf->hash[FIX_4_HASH_SIZE + hash_value];
mf->hash[hash_2_value] = pos;
mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;
diff --git a/Utilities/cmliblzma/liblzma/lzma/fastpos.h b/Utilities/cmliblzma/liblzma/lzma/fastpos.h
index 5a834d68d..a3feea58d 100644
--- a/Utilities/cmliblzma/liblzma/lzma/fastpos.h
+++ b/Utilities/cmliblzma/liblzma/lzma/fastpos.h
@@ -14,15 +14,15 @@
#ifndef LZMA_FASTPOS_H
#define LZMA_FASTPOS_H
-// LZMA encodes match distances (positions) by storing the highest two
-// bits using a six-bit value [0, 63], and then the missing lower bits.
-// Dictionary size is also stored using this encoding in the new .lzma
+// LZMA encodes match distances by storing the highest two bits using
+// a six-bit value [0, 63], and then the missing lower bits.
+// Dictionary size is also stored using this encoding in the .xz
// file format header.
//
// fastpos.h provides a way to quickly find out the correct six-bit
// values. The following table gives some examples of this encoding:
//
-// pos return
+// dist return
// 0 0
// 1 1
// 2 2
@@ -48,10 +48,10 @@
// Provided functions or macros
// ----------------------------
//
-// get_pos_slot(pos) is the basic version. get_pos_slot_2(pos)
-// assumes that pos >= FULL_DISTANCES, thus the result is at least
-// FULL_DISTANCES_BITS * 2. Using get_pos_slot(pos) instead of
-// get_pos_slot_2(pos) would give the same result, but get_pos_slot_2(pos)
+// get_dist_slot(dist) is the basic version. get_dist_slot_2(dist)
+// assumes that dist >= FULL_DISTANCES, thus the result is at least
+// FULL_DISTANCES_BITS * 2. Using get_dist_slot(dist) instead of
+// get_dist_slot_2(dist) would give the same result, but get_dist_slot_2(dist)
// should be tiny bit faster due to the assumption being made.
//
//
@@ -75,16 +75,15 @@
// on all systems I have tried. The size optimized version is sometimes
// slightly faster, but sometimes it is a lot slower.
-#include "config.h"
-
#ifdef HAVE_SMALL
-# define get_pos_slot(pos) ((pos) <= 4 ? (pos) : get_pos_slot_2(pos))
+# define get_dist_slot(dist) \
+ ((dist) <= 4 ? (dist) : get_dist_slot_2(dist))
static inline uint32_t
-get_pos_slot_2(uint32_t pos)
+get_dist_slot_2(uint32_t dist)
{
- const uint32_t i = bsr32(pos);
- return (i + i) + ((pos >> (i - 1)) & 1);
+ const uint32_t i = bsr32(dist);
+ return (i + i) + ((dist >> (i - 1)) & 1);
}
@@ -101,39 +100,39 @@ extern const uint8_t lzma_fastpos[1 << FASTPOS_BITS];
#define fastpos_limit(extra, n) \
(UINT32_C(1) << (FASTPOS_BITS + fastpos_shift(extra, n)))
-#define fastpos_result(pos, extra, n) \
- lzma_fastpos[(pos) >> fastpos_shift(extra, n)] \
+#define fastpos_result(dist, extra, n) \
+ lzma_fastpos[(dist) >> fastpos_shift(extra, n)] \
+ 2 * fastpos_shift(extra, n)
static inline uint32_t
-get_pos_slot(uint32_t pos)
+get_dist_slot(uint32_t dist)
{
// If it is small enough, we can pick the result directly from
// the precalculated table.
- if (pos < fastpos_limit(0, 0))
- return lzma_fastpos[pos];
+ if (dist < fastpos_limit(0, 0))
+ return lzma_fastpos[dist];
- if (pos < fastpos_limit(0, 1))
- return fastpos_result(pos, 0, 1);
+ if (dist < fastpos_limit(0, 1))
+ return fastpos_result(dist, 0, 1);
- return fastpos_result(pos, 0, 2);
+ return fastpos_result(dist, 0, 2);
}
#ifdef FULL_DISTANCES_BITS
static inline uint32_t
-get_pos_slot_2(uint32_t pos)
+get_dist_slot_2(uint32_t dist)
{
- assert(pos >= FULL_DISTANCES);
+ assert(dist >= FULL_DISTANCES);
- if (pos < fastpos_limit(FULL_DISTANCES_BITS - 1, 0))
- return fastpos_result(pos, FULL_DISTANCES_BITS - 1, 0);
+ if (dist < fastpos_limit(FULL_DISTANCES_BITS - 1, 0))
+ return fastpos_result(dist, FULL_DISTANCES_BITS - 1, 0);
- if (pos < fastpos_limit(FULL_DISTANCES_BITS - 1, 1))
- return fastpos_result(pos, FULL_DISTANCES_BITS - 1, 1);
+ if (dist < fastpos_limit(FULL_DISTANCES_BITS - 1, 1))
+ return fastpos_result(dist, FULL_DISTANCES_BITS - 1, 1);
- return fastpos_result(pos, FULL_DISTANCES_BITS - 1, 2);
+ return fastpos_result(dist, FULL_DISTANCES_BITS - 1, 2);
}
#endif
diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma2_decoder.c b/Utilities/cmliblzma/liblzma/lzma/lzma2_decoder.c
index bd2a73782..878c870ae 100644
--- a/Utilities/cmliblzma/liblzma/lzma/lzma2_decoder.c
+++ b/Utilities/cmliblzma/liblzma/lzma/lzma2_decoder.c
@@ -16,7 +16,7 @@
#include "lzma_decoder.h"
-struct lzma_coder_s {
+typedef struct {
enum sequence {
SEQ_CONTROL,
SEQ_UNCOMPRESSED_1,
@@ -50,14 +50,16 @@ struct lzma_coder_s {
bool need_dictionary_reset;
lzma_options_lzma options;
-};
+} lzma_lzma2_coder;
static lzma_ret
-lzma2_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dict,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
+lzma2_decode(void *coder_ptr, lzma_dict *restrict dict,
+ const uint8_t *restrict in, size_t *restrict in_pos,
size_t in_size)
{
+ lzma_lzma2_coder *restrict coder = coder_ptr;
+
// With SEQ_LZMA it is possible that no new input is needed to do
// some progress. The rest of the sequences assume that there is
// at least one byte of input.
@@ -209,8 +211,10 @@ lzma2_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dict,
static void
-lzma2_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
+lzma2_decoder_end(void *coder_ptr, const lzma_allocator *allocator)
{
+ lzma_lzma2_coder *coder = coder_ptr;
+
assert(coder->lzma.end == NULL);
lzma_free(coder->lzma.coder, allocator);
@@ -221,34 +225,36 @@ lzma2_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
-lzma2_decoder_init(lzma_lz_decoder *lz, lzma_allocator *allocator,
+lzma2_decoder_init(lzma_lz_decoder *lz, const lzma_allocator *allocator,
const void *opt, lzma_lz_options *lz_options)
{
- const lzma_options_lzma *options = opt;
-
- if (lz->coder == NULL) {
- lz->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (lz->coder == NULL)
+ lzma_lzma2_coder *coder = lz->coder;
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_lzma2_coder), allocator);
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ lz->coder = coder;
lz->code = &lzma2_decode;
lz->end = &lzma2_decoder_end;
- lz->coder->lzma = LZMA_LZ_DECODER_INIT;
+ coder->lzma = LZMA_LZ_DECODER_INIT;
}
- lz->coder->sequence = SEQ_CONTROL;
- lz->coder->need_properties = true;
- lz->coder->need_dictionary_reset = options->preset_dict == NULL
+ const lzma_options_lzma *options = opt;
+
+ coder->sequence = SEQ_CONTROL;
+ coder->need_properties = true;
+ coder->need_dictionary_reset = options->preset_dict == NULL
|| options->preset_dict_size == 0;
- return lzma_lzma_decoder_create(&lz->coder->lzma,
+ return lzma_lzma_decoder_create(&coder->lzma,
allocator, options, lz_options);
}
extern lzma_ret
-lzma_lzma2_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_lzma2_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters)
{
// LZMA2 can only be the last filter in the chain. This is enforced
@@ -263,17 +269,15 @@ lzma_lzma2_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern uint64_t
lzma_lzma2_decoder_memusage(const void *options)
{
- return sizeof(lzma_coder)
+ return sizeof(lzma_lzma2_coder)
+ lzma_lzma_decoder_memusage_nocheck(options);
}
extern lzma_ret
-lzma_lzma2_props_decode(void **options, lzma_allocator *allocator,
+lzma_lzma2_props_decode(void **options, const lzma_allocator *allocator,
const uint8_t *props, size_t props_size)
{
- lzma_options_lzma *opt;
-
if (props_size != 1)
return LZMA_OPTIONS_ERROR;
@@ -285,7 +289,8 @@ lzma_lzma2_props_decode(void **options, lzma_allocator *allocator,
if (props[0] > 40)
return LZMA_OPTIONS_ERROR;
- opt = lzma_alloc(sizeof(lzma_options_lzma), allocator);
+ lzma_options_lzma *opt = lzma_alloc(
+ sizeof(lzma_options_lzma), allocator);
if (opt == NULL)
return LZMA_MEM_ERROR;
diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma2_decoder.h b/Utilities/cmliblzma/liblzma/lzma/lzma2_decoder.h
index fac4ac487..ef2dcbfa7 100644
--- a/Utilities/cmliblzma/liblzma/lzma/lzma2_decoder.h
+++ b/Utilities/cmliblzma/liblzma/lzma/lzma2_decoder.h
@@ -17,12 +17,13 @@
#include "common.h"
extern lzma_ret lzma_lzma2_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern uint64_t lzma_lzma2_decoder_memusage(const void *options);
extern lzma_ret lzma_lzma2_props_decode(
- void **options, lzma_allocator *allocator,
+ void **options, const lzma_allocator *allocator,
const uint8_t *props, size_t props_size);
#endif
diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma2_encoder.c b/Utilities/cmliblzma/liblzma/lzma/lzma2_encoder.c
index a3651a7c6..63588ee30 100644
--- a/Utilities/cmliblzma/liblzma/lzma/lzma2_encoder.c
+++ b/Utilities/cmliblzma/liblzma/lzma/lzma2_encoder.c
@@ -17,7 +17,7 @@
#include "lzma2_encoder.h"
-struct lzma_coder_s {
+typedef struct {
enum {
SEQ_INIT,
SEQ_LZMA_ENCODE,
@@ -27,7 +27,7 @@ struct lzma_coder_s {
} sequence;
/// LZMA encoder
- lzma_coder *lzma;
+ void *lzma;
/// LZMA options currently in use.
lzma_options_lzma opt_cur;
@@ -48,20 +48,19 @@ struct lzma_coder_s {
/// Buffer to hold the chunk header and LZMA compressed data
uint8_t buf[LZMA2_HEADER_MAX + LZMA2_CHUNK_MAX];
-};
+} lzma_lzma2_coder;
static void
-lzma2_header_lzma(lzma_coder *coder)
+lzma2_header_lzma(lzma_lzma2_coder *coder)
{
- size_t pos;
- size_t size;
-
assert(coder->uncompressed_size > 0);
assert(coder->uncompressed_size <= LZMA2_UNCOMPRESSED_MAX);
assert(coder->compressed_size > 0);
assert(coder->compressed_size <= LZMA2_CHUNK_MAX);
+ size_t pos;
+
if (coder->need_properties) {
pos = 0;
@@ -82,7 +81,7 @@ lzma2_header_lzma(lzma_coder *coder)
coder->buf_pos = pos;
// Uncompressed size
- size = coder->uncompressed_size - 1;
+ size_t size = coder->uncompressed_size - 1;
coder->buf[pos++] += size >> 16;
coder->buf[pos++] = (size >> 8) & 0xFF;
coder->buf[pos++] = size & 0xFF;
@@ -109,7 +108,7 @@ lzma2_header_lzma(lzma_coder *coder)
static void
-lzma2_header_uncompressed(lzma_coder *coder)
+lzma2_header_uncompressed(lzma_lzma2_coder *coder)
{
assert(coder->uncompressed_size > 0);
assert(coder->uncompressed_size <= LZMA2_CHUNK_MAX);
@@ -134,10 +133,12 @@ lzma2_header_uncompressed(lzma_coder *coder)
static lzma_ret
-lzma2_encode(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
- uint8_t *LZMA_RESTRICT out, size_t *LZMA_RESTRICT out_pos,
+lzma2_encode(void *coder_ptr, lzma_mf *restrict mf,
+ uint8_t *restrict out, size_t *restrict out_pos,
size_t out_size)
{
+ lzma_lzma2_coder *restrict coder = coder_ptr;
+
while (*out_pos < out_size)
switch (coder->sequence) {
case SEQ_INIT:
@@ -163,9 +164,6 @@ lzma2_encode(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
// Fall through
case SEQ_LZMA_ENCODE: {
- uint32_t read_start;
- lzma_ret ret;
-
// Calculate how much more uncompressed data this chunk
// could accept.
const uint32_t left = LZMA2_UNCOMPRESSED_MAX
@@ -186,10 +184,10 @@ lzma2_encode(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
// Save the start position so that we can update
// coder->uncompressed_size.
- read_start = mf->read_pos - mf->read_ahead;
+ const uint32_t read_start = mf->read_pos - mf->read_ahead;
// Call the LZMA encoder until the chunk is finished.
- ret = lzma_lzma_encode(coder->lzma, mf,
+ const lzma_ret ret = lzma_lzma_encode(coder->lzma, mf,
coder->buf + LZMA2_HEADER_MAX,
&coder->compressed_size,
LZMA2_CHUNK_MAX, limit);
@@ -266,8 +264,9 @@ lzma2_encode(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
static void
-lzma2_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
+lzma2_encoder_end(void *coder_ptr, const lzma_allocator *allocator)
{
+ lzma_lzma2_coder *coder = coder_ptr;
lzma_free(coder->lzma, allocator);
lzma_free(coder, allocator);
return;
@@ -275,9 +274,9 @@ lzma2_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
-lzma2_encoder_options_update(lzma_coder *coder, const lzma_filter *filter)
+lzma2_encoder_options_update(void *coder_ptr, const lzma_filter *filter)
{
- lzma_options_lzma *opt;
+ lzma_lzma2_coder *coder = coder_ptr;
// New options can be set only when there is no incomplete chunk.
// This is the case at the beginning of the raw stream and right
@@ -287,7 +286,7 @@ lzma2_encoder_options_update(lzma_coder *coder, const lzma_filter *filter)
// Look if there are new options. At least for now,
// only lc/lp/pb can be changed.
- opt = filter->options;
+ const lzma_options_lzma *opt = filter->options;
if (coder->opt_cur.lc != opt->lc || coder->opt_cur.lp != opt->lp
|| coder->opt_cur.pb != opt->pb) {
// Validate the options.
@@ -310,36 +309,38 @@ lzma2_encoder_options_update(lzma_coder *coder, const lzma_filter *filter)
static lzma_ret
-lzma2_encoder_init(lzma_lz_encoder *lz, lzma_allocator *allocator,
+lzma2_encoder_init(lzma_lz_encoder *lz, const lzma_allocator *allocator,
const void *options, lzma_lz_options *lz_options)
{
if (options == NULL)
return LZMA_PROG_ERROR;
- if (lz->coder == NULL) {
- lz->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (lz->coder == NULL)
+ lzma_lzma2_coder *coder = lz->coder;
+ if (coder == NULL) {
+ coder = lzma_alloc(sizeof(lzma_lzma2_coder), allocator);
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ lz->coder = coder;
lz->code = &lzma2_encode;
lz->end = &lzma2_encoder_end;
lz->options_update = &lzma2_encoder_options_update;
- lz->coder->lzma = NULL;
+ coder->lzma = NULL;
}
- lz->coder->opt_cur = *(const lzma_options_lzma *)(options);
+ coder->opt_cur = *(const lzma_options_lzma *)(options);
- lz->coder->sequence = SEQ_INIT;
- lz->coder->need_properties = true;
- lz->coder->need_state_reset = false;
- lz->coder->need_dictionary_reset
- = lz->coder->opt_cur.preset_dict == NULL
- || lz->coder->opt_cur.preset_dict_size == 0;
+ coder->sequence = SEQ_INIT;
+ coder->need_properties = true;
+ coder->need_state_reset = false;
+ coder->need_dictionary_reset
+ = coder->opt_cur.preset_dict == NULL
+ || coder->opt_cur.preset_dict_size == 0;
// Initialize LZMA encoder
- return_if_error(lzma_lzma_encoder_create(&lz->coder->lzma, allocator,
- &lz->coder->opt_cur, lz_options));
+ return_if_error(lzma_lzma_encoder_create(&coder->lzma, allocator,
+ &coder->opt_cur, lz_options));
// Make sure that we will always have enough history available in
// case we need to use uncompressed chunks. They are used when the
@@ -355,7 +356,7 @@ lzma2_encoder_init(lzma_lz_encoder *lz, lzma_allocator *allocator,
extern lzma_ret
-lzma_lzma2_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_lzma2_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters)
{
return lzma_lz_encoder_init(
@@ -370,7 +371,7 @@ lzma_lzma2_encoder_memusage(const void *options)
if (lzma_mem == UINT64_MAX)
return UINT64_MAX;
- return sizeof(lzma_coder) + lzma_mem;
+ return sizeof(lzma_lzma2_coder) + lzma_mem;
}
@@ -393,7 +394,17 @@ lzma_lzma2_props_encode(const void *options, uint8_t *out)
if (d == UINT32_MAX)
out[0] = 40;
else
- out[0] = get_pos_slot(d + 1) - 24;
+ out[0] = get_dist_slot(d + 1) - 24;
return LZMA_OK;
}
+
+
+extern uint64_t
+lzma_lzma2_block_size(const void *options)
+{
+ const lzma_options_lzma *const opt = options;
+
+ // Use at least 1 MiB to keep compression ratio better.
+ return my_max((uint64_t)(opt->dict_size) * 3, UINT64_C(1) << 20);
+}
diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma2_encoder.h b/Utilities/cmliblzma/liblzma/lzma/lzma2_encoder.h
index ca19ef469..515f18393 100644
--- a/Utilities/cmliblzma/liblzma/lzma/lzma2_encoder.h
+++ b/Utilities/cmliblzma/liblzma/lzma/lzma2_encoder.h
@@ -31,11 +31,13 @@
extern lzma_ret lzma_lzma2_encoder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
+ lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters);
extern uint64_t lzma_lzma2_encoder_memusage(const void *options);
extern lzma_ret lzma_lzma2_props_encode(const void *options, uint8_t *out);
+extern uint64_t lzma_lzma2_block_size(const void *options);
+
#endif
diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma_common.h b/Utilities/cmliblzma/liblzma/lzma/lzma_common.h
index 36267dc88..09efd3872 100644
--- a/Utilities/cmliblzma/liblzma/lzma/lzma_common.h
+++ b/Utilities/cmliblzma/liblzma/lzma/lzma_common.h
@@ -129,15 +129,12 @@ static inline void
literal_init(probability (*probs)[LITERAL_CODER_SIZE],
uint32_t lc, uint32_t lp)
{
- uint32_t coders;
- uint32_t i, j;
-
assert(lc + lp <= LZMA_LCLP_MAX);
- coders = 1U << (lc + lp);
+ const uint32_t coders = 1U << (lc + lp);
- for (i = 0; i < coders; ++i)
- for (j = 0; j < LITERAL_CODER_SIZE; ++j)
+ for (uint32_t i = 0; i < coders; ++i)
+ for (uint32_t j = 0; j < LITERAL_CODER_SIZE; ++j)
bit_reset(probs[i][j]);
return;
@@ -174,53 +171,54 @@ literal_init(probability (*probs)[LITERAL_CODER_SIZE],
// Match distance //
////////////////////
-// Different set of probabilities is used for match distances that have very
+// Different sets of probabilities are used for match distances that have very
// short match length: Lengths of 2, 3, and 4 bytes have a separate set of
// probabilities for each length. The matches with longer length use a shared
// set of probabilities.
-#define LEN_TO_POS_STATES 4
+#define DIST_STATES 4
// Macro to get the index of the appropriate probability array.
-#define get_len_to_pos_state(len) \
- ((len) < LEN_TO_POS_STATES + MATCH_LEN_MIN \
+#define get_dist_state(len) \
+ ((len) < DIST_STATES + MATCH_LEN_MIN \
? (len) - MATCH_LEN_MIN \
- : LEN_TO_POS_STATES - 1)
+ : DIST_STATES - 1)
-// The highest two bits of a match distance (pos slot) are encoded using six
-// bits. See fastpos.h for more explanation.
-#define POS_SLOT_BITS 6
-#define POS_SLOTS (1 << POS_SLOT_BITS)
+// The highest two bits of a match distance (distance slot) are encoded
+// using six bits. See fastpos.h for more explanation.
+#define DIST_SLOT_BITS 6
+#define DIST_SLOTS (1 << DIST_SLOT_BITS)
// Match distances up to 127 are fully encoded using probabilities. Since
-// the highest two bits (pos slot) are always encoded using six bits, the
-// distances 0-3 don't need any additional bits to encode, since the pos
-// slot itself is the same as the actual distance. START_POS_MODEL_INDEX
-// indicates the first pos slot where at least one additional bit is needed.
-#define START_POS_MODEL_INDEX 4
+// the highest two bits (distance slot) are always encoded using six bits,
+// the distances 0-3 don't need any additional bits to encode, since the
+// distance slot itself is the same as the actual distance. DIST_MODEL_START
+// indicates the first distance slot where at least one additional bit is
+// needed.
+#define DIST_MODEL_START 4
// Match distances greater than 127 are encoded in three pieces:
-// - pos slot: the highest two bits
+// - distance slot: the highest two bits
// - direct bits: 2-26 bits below the highest two bits
// - alignment bits: four lowest bits
//
// Direct bits don't use any probabilities.
//
-// The pos slot value of 14 is for distances 128-191 (see the table in
+// The distance slot value of 14 is for distances 128-191 (see the table in
// fastpos.h to understand why).
-#define END_POS_MODEL_INDEX 14
+#define DIST_MODEL_END 14
-// Pos slots that indicate a distance <= 127.
-#define FULL_DISTANCES_BITS (END_POS_MODEL_INDEX / 2)
+// Distance slots that indicate a distance <= 127.
+#define FULL_DISTANCES_BITS (DIST_MODEL_END / 2)
#define FULL_DISTANCES (1 << FULL_DISTANCES_BITS)
// For match distances greater than 127, only the highest two bits and the
// lowest four bits (alignment) is encoded using probabilities.
#define ALIGN_BITS 4
-#define ALIGN_TABLE_SIZE (1 << ALIGN_BITS)
-#define ALIGN_MASK (ALIGN_TABLE_SIZE - 1)
+#define ALIGN_SIZE (1 << ALIGN_BITS)
+#define ALIGN_MASK (ALIGN_SIZE - 1)
// LZMA remembers the four most recent match distances. Reusing these distances
// tends to take less space than re-encoding the actual distance value.
-#define REP_DISTANCES 4
+#define REPS 4
#endif
diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma_decoder.c b/Utilities/cmliblzma/liblzma/lzma/lzma_decoder.c
index 3c0f39331..d0f29b763 100644
--- a/Utilities/cmliblzma/liblzma/lzma/lzma_decoder.c
+++ b/Utilities/cmliblzma/liblzma/lzma/lzma_decoder.c
@@ -16,6 +16,12 @@
#include "lzma_decoder.h"
#include "range_decoder.h"
+// The macros unroll loops with switch statements.
+// Silence warnings about missing fall-through comments.
+#if TUKLIB_GNUC_REQ(7, 0)
+# pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#endif
+
#ifdef HAVE_SMALL
@@ -114,33 +120,33 @@ do { \
case seq ## _CHOICE: \
rc_if_0(ld.choice, seq ## _CHOICE) { \
rc_update_0(ld.choice); \
- rc_bit_case(ld.low[pos_state][symbol], 0, 0, seq ## _LOW0); \
- rc_bit_case(ld.low[pos_state][symbol], 0, 0, seq ## _LOW1); \
- rc_bit_case(ld.low[pos_state][symbol], 0, 0, seq ## _LOW2); \
+ rc_bit_case(ld.low[pos_state][symbol], , , seq ## _LOW0); \
+ rc_bit_case(ld.low[pos_state][symbol], , , seq ## _LOW1); \
+ rc_bit_case(ld.low[pos_state][symbol], , , seq ## _LOW2); \
target = symbol - LEN_LOW_SYMBOLS + MATCH_LEN_MIN; \
} else { \
rc_update_1(ld.choice); \
case seq ## _CHOICE2: \
rc_if_0(ld.choice2, seq ## _CHOICE2) { \
rc_update_0(ld.choice2); \
- rc_bit_case(ld.mid[pos_state][symbol], 0, 0, \
+ rc_bit_case(ld.mid[pos_state][symbol], , , \
seq ## _MID0); \
- rc_bit_case(ld.mid[pos_state][symbol], 0, 0, \
+ rc_bit_case(ld.mid[pos_state][symbol], , , \
seq ## _MID1); \
- rc_bit_case(ld.mid[pos_state][symbol], 0, 0, \
+ rc_bit_case(ld.mid[pos_state][symbol], , , \
seq ## _MID2); \
target = symbol - LEN_MID_SYMBOLS \
+ MATCH_LEN_MIN + LEN_LOW_SYMBOLS; \
} else { \
rc_update_1(ld.choice2); \
- rc_bit_case(ld.high[symbol], 0, 0, seq ## _HIGH0); \
- rc_bit_case(ld.high[symbol], 0, 0, seq ## _HIGH1); \
- rc_bit_case(ld.high[symbol], 0, 0, seq ## _HIGH2); \
- rc_bit_case(ld.high[symbol], 0, 0, seq ## _HIGH3); \
- rc_bit_case(ld.high[symbol], 0, 0, seq ## _HIGH4); \
- rc_bit_case(ld.high[symbol], 0, 0, seq ## _HIGH5); \
- rc_bit_case(ld.high[symbol], 0, 0, seq ## _HIGH6); \
- rc_bit_case(ld.high[symbol], 0, 0, seq ## _HIGH7); \
+ rc_bit_case(ld.high[symbol], , , seq ## _HIGH0); \
+ rc_bit_case(ld.high[symbol], , , seq ## _HIGH1); \
+ rc_bit_case(ld.high[symbol], , , seq ## _HIGH2); \
+ rc_bit_case(ld.high[symbol], , , seq ## _HIGH3); \
+ rc_bit_case(ld.high[symbol], , , seq ## _HIGH4); \
+ rc_bit_case(ld.high[symbol], , , seq ## _HIGH5); \
+ rc_bit_case(ld.high[symbol], , , seq ## _HIGH6); \
+ rc_bit_case(ld.high[symbol], , , seq ## _HIGH7); \
target = symbol - LEN_HIGH_SYMBOLS \
+ MATCH_LEN_MIN \
+ LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS; \
@@ -161,7 +167,7 @@ typedef struct {
} lzma_length_decoder;
-struct lzma_coder_s {
+typedef struct {
///////////////////
// Probabilities //
///////////////////
@@ -193,15 +199,15 @@ struct lzma_coder_s {
/// Probability tree for the highest two bits of the match distance.
/// There is a separate probability tree for match lengths of
/// 2 (i.e. MATCH_LEN_MIN), 3, 4, and [5, 273].
- probability pos_slot[LEN_TO_POS_STATES][POS_SLOTS];
+ probability dist_slot[DIST_STATES][DIST_SLOTS];
/// Probability trees for additional bits for match distance when the
/// distance is in the range [4, 127].
- probability pos_special[FULL_DISTANCES - END_POS_MODEL_INDEX];
+ probability pos_special[FULL_DISTANCES - DIST_MODEL_END];
/// Probability tree for the lowest four bits of a match distance
/// that is equal to or greater than 128.
- probability pos_align[ALIGN_TABLE_SIZE];
+ probability pos_align[ALIGN_SIZE];
/// Length of a normal match
lzma_length_decoder match_len_decoder;
@@ -245,8 +251,8 @@ struct lzma_coder_s {
SEQ_LITERAL_WRITE,
SEQ_IS_REP,
seq_len(SEQ_MATCH_LEN),
- seq_6(SEQ_POS_SLOT),
- SEQ_POS_MODEL,
+ seq_6(SEQ_DIST_SLOT),
+ SEQ_DIST_MODEL,
SEQ_DIRECT,
seq_4(SEQ_ALIGN),
SEQ_EOPM,
@@ -277,14 +283,27 @@ struct lzma_coder_s {
/// If decoding a literal: match byte.
/// If decoding a match: length of the match.
uint32_t len;
-};
+} lzma_lzma1_decoder;
static lzma_ret
-lzma_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dictptr,
- const uint8_t *LZMA_RESTRICT in,
- size_t *LZMA_RESTRICT in_pos, size_t in_size)
+lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr,
+ const uint8_t *restrict in,
+ size_t *restrict in_pos, size_t in_size)
{
+ lzma_lzma1_decoder *restrict coder = coder_ptr;
+
+ ////////////////////
+ // Initialization //
+ ////////////////////
+
+ {
+ const lzma_ret ret = rc_read_init(
+ &coder->rc, in, in_pos, in_size);
+ if (ret != LZMA_STREAM_END)
+ return ret;
+ }
+
///////////////
// Variables //
///////////////
@@ -331,16 +350,6 @@ lzma_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dictptr,
if (no_eopm && coder->uncompressed_size < dict.limit - dict.pos)
dict.limit = dict.pos + (size_t)(coder->uncompressed_size);
- ////////////////////
- // Initialization //
- ////////////////////
-
- if (!rc_read_init(&coder->rc, in, in_pos, in_size))
- return LZMA_OK;
-
- rc = coder->rc;
- rc_in_pos = *in_pos;
-
// The main decoder loop. The "switch" is used to restart the decoder at
// correct location. Once restarted, the "switch" is no longer used.
switch (coder->sequence)
@@ -356,21 +365,6 @@ lzma_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dictptr,
break;
rc_if_0(coder->is_match[state][pos_state], SEQ_IS_MATCH) {
- static const lzma_lzma_state next_state[] = {
- STATE_LIT_LIT,
- STATE_LIT_LIT,
- STATE_LIT_LIT,
- STATE_LIT_LIT,
- STATE_MATCH_LIT_LIT,
- STATE_REP_LIT_LIT,
- STATE_SHORTREP_LIT_LIT,
- STATE_MATCH_LIT,
- STATE_REP_LIT,
- STATE_SHORTREP_LIT,
- STATE_MATCH_LIT,
- STATE_REP_LIT
- };
-
rc_update_0(coder->is_match[state][pos_state]);
// It's a literal i.e. a single 8-bit byte.
@@ -388,21 +382,16 @@ lzma_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dictptr,
rc_bit(probs[symbol], , , SEQ_LITERAL);
} while (symbol < (1 << 8));
#else
- rc_bit_case(probs[symbol], 0, 0, SEQ_LITERAL0);
- rc_bit_case(probs[symbol], 0, 0, SEQ_LITERAL1);
- rc_bit_case(probs[symbol], 0, 0, SEQ_LITERAL2);
- rc_bit_case(probs[symbol], 0, 0, SEQ_LITERAL3);
- rc_bit_case(probs[symbol], 0, 0, SEQ_LITERAL4);
- rc_bit_case(probs[symbol], 0, 0, SEQ_LITERAL5);
- rc_bit_case(probs[symbol], 0, 0, SEQ_LITERAL6);
- rc_bit_case(probs[symbol], 0, 0, SEQ_LITERAL7);
+ rc_bit_case(probs[symbol], , , SEQ_LITERAL0);
+ rc_bit_case(probs[symbol], , , SEQ_LITERAL1);
+ rc_bit_case(probs[symbol], , , SEQ_LITERAL2);
+ rc_bit_case(probs[symbol], , , SEQ_LITERAL3);
+ rc_bit_case(probs[symbol], , , SEQ_LITERAL4);
+ rc_bit_case(probs[symbol], , , SEQ_LITERAL5);
+ rc_bit_case(probs[symbol], , , SEQ_LITERAL6);
+ rc_bit_case(probs[symbol], , , SEQ_LITERAL7);
#endif
} else {
-#ifndef HAVE_SMALL
- uint32_t match_bit;
- uint32_t subcoder_index;
-#endif
-
// Decode literal with match byte.
//
// We store the byte we compare against
@@ -441,6 +430,8 @@ lzma_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dictptr,
} while (symbol < (1 << 8));
#else
// Unroll the loop.
+ uint32_t match_bit;
+ uint32_t subcoder_index;
# define d(seq) \
case seq: \
@@ -474,6 +465,20 @@ lzma_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dictptr,
// Use a lookup table to update to literal state,
// since compared to other state updates, this would
// need two branches.
+ static const lzma_lzma_state next_state[] = {
+ STATE_LIT_LIT,
+ STATE_LIT_LIT,
+ STATE_LIT_LIT,
+ STATE_LIT_LIT,
+ STATE_MATCH_LIT_LIT,
+ STATE_REP_LIT_LIT,
+ STATE_SHORTREP_LIT_LIT,
+ STATE_MATCH_LIT,
+ STATE_REP_LIT,
+ STATE_SHORTREP_LIT,
+ STATE_MATCH_LIT,
+ STATE_REP_LIT
+ };
state = next_state[state];
case SEQ_LITERAL_WRITE:
@@ -509,28 +514,28 @@ lzma_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dictptr,
// Prepare to decode the highest two bits of the
// match distance.
- probs = coder->pos_slot[get_len_to_pos_state(len)];
+ probs = coder->dist_slot[get_dist_state(len)];
symbol = 1;
#ifdef HAVE_SMALL
- case SEQ_POS_SLOT:
+ case SEQ_DIST_SLOT:
do {
- rc_bit(probs[symbol], , , SEQ_POS_SLOT);
- } while (symbol < POS_SLOTS);
+ rc_bit(probs[symbol], , , SEQ_DIST_SLOT);
+ } while (symbol < DIST_SLOTS);
#else
- rc_bit_case(probs[symbol], 0, 0, SEQ_POS_SLOT0);
- rc_bit_case(probs[symbol], 0, 0, SEQ_POS_SLOT1);
- rc_bit_case(probs[symbol], 0, 0, SEQ_POS_SLOT2);
- rc_bit_case(probs[symbol], 0, 0, SEQ_POS_SLOT3);
- rc_bit_case(probs[symbol], 0, 0, SEQ_POS_SLOT4);
- rc_bit_case(probs[symbol], 0, 0, SEQ_POS_SLOT5);
+ rc_bit_case(probs[symbol], , , SEQ_DIST_SLOT0);
+ rc_bit_case(probs[symbol], , , SEQ_DIST_SLOT1);
+ rc_bit_case(probs[symbol], , , SEQ_DIST_SLOT2);
+ rc_bit_case(probs[symbol], , , SEQ_DIST_SLOT3);
+ rc_bit_case(probs[symbol], , , SEQ_DIST_SLOT4);
+ rc_bit_case(probs[symbol], , , SEQ_DIST_SLOT5);
#endif
// Get rid of the highest bit that was needed for
// indexing of the probability array.
- symbol -= POS_SLOTS;
+ symbol -= DIST_SLOTS;
assert(symbol <= 63);
- if (symbol < START_POS_MODEL_INDEX) {
+ if (symbol < DIST_MODEL_START) {
// Match distances [0, 3] have only two bits.
rep0 = symbol;
} else {
@@ -540,7 +545,7 @@ lzma_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dictptr,
assert(limit >= 1 && limit <= 30);
rep0 = 2 + (symbol & 1);
- if (symbol < END_POS_MODEL_INDEX) {
+ if (symbol < DIST_MODEL_END) {
// Prepare to decode the low bits for
// a distance of [4, 127].
assert(limit <= 5);
@@ -560,38 +565,38 @@ lzma_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dictptr,
- symbol - 1;
symbol = 1;
offset = 0;
- case SEQ_POS_MODEL:
+ case SEQ_DIST_MODEL:
#ifdef HAVE_SMALL
do {
rc_bit(probs[symbol], ,
rep0 += 1 << offset,
- SEQ_POS_MODEL);
+ SEQ_DIST_MODEL);
} while (++offset < limit);
#else
switch (limit) {
case 5:
assert(offset == 0);
- rc_bit(probs[symbol], 0,
+ rc_bit(probs[symbol], ,
rep0 += 1,
- SEQ_POS_MODEL);
+ SEQ_DIST_MODEL);
++offset;
--limit;
case 4:
- rc_bit(probs[symbol], 0,
+ rc_bit(probs[symbol], ,
rep0 += 1 << offset,
- SEQ_POS_MODEL);
+ SEQ_DIST_MODEL);
++offset;
--limit;
case 3:
- rc_bit(probs[symbol], 0,
+ rc_bit(probs[symbol], ,
rep0 += 1 << offset,
- SEQ_POS_MODEL);
+ SEQ_DIST_MODEL);
++offset;
--limit;
case 2:
- rc_bit(probs[symbol], 0,
+ rc_bit(probs[symbol], ,
rep0 += 1 << offset,
- SEQ_POS_MODEL);
+ SEQ_DIST_MODEL);
++offset;
--limit;
case 1:
@@ -601,9 +606,9 @@ lzma_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dictptr,
// rc_bit_last() here to omit
// the unneeded updating of
// "symbol".
- rc_bit_last(probs[symbol], 0,
+ rc_bit_last(probs[symbol], ,
rep0 += 1 << offset,
- SEQ_POS_MODEL);
+ SEQ_DIST_MODEL);
}
#endif
} else {
@@ -635,19 +640,19 @@ lzma_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dictptr,
} while (++offset < ALIGN_BITS);
#else
case SEQ_ALIGN0:
- rc_bit(coder->pos_align[symbol], 0,
+ rc_bit(coder->pos_align[symbol], ,
rep0 += 1, SEQ_ALIGN0);
case SEQ_ALIGN1:
- rc_bit(coder->pos_align[symbol], 0,
+ rc_bit(coder->pos_align[symbol], ,
rep0 += 2, SEQ_ALIGN1);
case SEQ_ALIGN2:
- rc_bit(coder->pos_align[symbol], 0,
+ rc_bit(coder->pos_align[symbol], ,
rep0 += 4, SEQ_ALIGN2);
case SEQ_ALIGN3:
- // Like in SEQ_POS_MODEL, we don't
+ // Like in SEQ_DIST_MODEL, we don't
// need "symbol" for anything else
// than indexing the probability array.
- rc_bit_last(coder->pos_align[symbol], 0,
+ rc_bit_last(coder->pos_align[symbol], ,
rep0 += 8, SEQ_ALIGN3);
#endif
@@ -732,11 +737,9 @@ lzma_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dictptr,
// is stored to rep0 and rep1, rep2 and rep3
// are updated accordingly.
rc_if_0(coder->is_rep1[state], SEQ_IS_REP1) {
- uint32_t distance;
-
rc_update_0(coder->is_rep1[state]);
- distance = rep1;
+ const uint32_t distance = rep1;
rep1 = rep0;
rep0 = distance;
@@ -745,23 +748,19 @@ lzma_decode(lzma_coder *LZMA_RESTRICT coder, lzma_dict *LZMA_RESTRICT dictptr,
case SEQ_IS_REP2:
rc_if_0(coder->is_rep2[state],
SEQ_IS_REP2) {
- uint32_t distance;
-
rc_update_0(coder->is_rep2[
state]);
- distance = rep2;
+ const uint32_t distance = rep2;
rep2 = rep1;
rep1 = rep0;
rep0 = distance;
} else {
- uint32_t distance;
-
rc_update_1(coder->is_rep2[
state]);
- distance = rep3;
+ const uint32_t distance = rep3;
rep3 = rep2;
rep2 = rep1;
rep1 = rep0;
@@ -849,26 +848,17 @@ out:
static void
-lzma_decoder_uncompressed(lzma_coder *coder, lzma_vli uncompressed_size)
+lzma_decoder_uncompressed(void *coder_ptr, lzma_vli uncompressed_size)
{
+ lzma_lzma1_decoder *coder = coder_ptr;
coder->uncompressed_size = uncompressed_size;
}
-/*
-extern void
-lzma_lzma_decoder_uncompressed(void *coder_ptr, lzma_vli uncompressed_size)
-{
- // This is hack.
- (*(lzma_coder **)(coder))->uncompressed_size = uncompressed_size;
-}
-*/
static void
-lzma_decoder_reset(lzma_coder *coder, const void *opt)
+lzma_decoder_reset(void *coder_ptr, const void *opt)
{
- uint32_t i, j, pos_state;
- uint32_t num_pos_states;
-
+ lzma_lzma1_decoder *coder = coder_ptr;
const lzma_options_lzma *options = opt;
// NOTE: We assume that lc/lp/pb are valid since they were
@@ -895,8 +885,8 @@ lzma_decoder_reset(lzma_coder *coder, const void *opt)
rc_reset(coder->rc);
// Bit and bittree decoders
- for (i = 0; i < STATES; ++i) {
- for (j = 0; j <= coder->pos_mask; ++j) {
+ for (uint32_t i = 0; i < STATES; ++i) {
+ for (uint32_t j = 0; j <= coder->pos_mask; ++j) {
bit_reset(coder->is_match[i][j]);
bit_reset(coder->is_rep0_long[i][j]);
}
@@ -907,22 +897,22 @@ lzma_decoder_reset(lzma_coder *coder, const void *opt)
bit_reset(coder->is_rep2[i]);
}
- for (i = 0; i < LEN_TO_POS_STATES; ++i)
- bittree_reset(coder->pos_slot[i], POS_SLOT_BITS);
+ for (uint32_t i = 0; i < DIST_STATES; ++i)
+ bittree_reset(coder->dist_slot[i], DIST_SLOT_BITS);
- for (i = 0; i < FULL_DISTANCES - END_POS_MODEL_INDEX; ++i)
+ for (uint32_t i = 0; i < FULL_DISTANCES - DIST_MODEL_END; ++i)
bit_reset(coder->pos_special[i]);
bittree_reset(coder->pos_align, ALIGN_BITS);
// Len decoders (also bit/bittree)
- num_pos_states = 1U << options->pb;
+ const uint32_t num_pos_states = 1U << options->pb;
bit_reset(coder->match_len_decoder.choice);
bit_reset(coder->match_len_decoder.choice2);
bit_reset(coder->rep_len_decoder.choice);
bit_reset(coder->rep_len_decoder.choice2);
- for (pos_state = 0; pos_state < num_pos_states; ++pos_state) {
+ for (uint32_t pos_state = 0; pos_state < num_pos_states; ++pos_state) {
bittree_reset(coder->match_len_decoder.low[pos_state],
LEN_LOW_BITS);
bittree_reset(coder->match_len_decoder.mid[pos_state],
@@ -949,13 +939,11 @@ lzma_decoder_reset(lzma_coder *coder, const void *opt)
extern lzma_ret
-lzma_lzma_decoder_create(lzma_lz_decoder *lz, lzma_allocator *allocator,
+lzma_lzma_decoder_create(lzma_lz_decoder *lz, const lzma_allocator *allocator,
const void *opt, lzma_lz_options *lz_options)
{
- const lzma_options_lzma *options = opt;
-
if (lz->coder == NULL) {
- lz->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ lz->coder = lzma_alloc(sizeof(lzma_lzma1_decoder), allocator);
if (lz->coder == NULL)
return LZMA_MEM_ERROR;
@@ -966,6 +954,7 @@ lzma_lzma_decoder_create(lzma_lz_decoder *lz, lzma_allocator *allocator,
// All dictionary sizes are OK here. LZ decoder will take care of
// the special cases.
+ const lzma_options_lzma *options = opt;
lz_options->dict_size = options->dict_size;
lz_options->preset_dict = options->preset_dict;
lz_options->preset_dict_size = options->preset_dict_size;
@@ -978,7 +967,7 @@ lzma_lzma_decoder_create(lzma_lz_decoder *lz, lzma_allocator *allocator,
/// initialization (lzma_lzma_decoder_init() passes function pointer to
/// the LZ initialization).
static lzma_ret
-lzma_decoder_init(lzma_lz_decoder *lz, lzma_allocator *allocator,
+lzma_decoder_init(lzma_lz_decoder *lz, const lzma_allocator *allocator,
const void *options, lzma_lz_options *lz_options)
{
if (!is_lclppb_valid(options))
@@ -995,7 +984,7 @@ lzma_decoder_init(lzma_lz_decoder *lz, lzma_allocator *allocator,
extern lzma_ret
-lzma_lzma_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_lzma_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters)
{
// LZMA can only be the last filter in the chain. This is enforced
@@ -1027,7 +1016,8 @@ extern uint64_t
lzma_lzma_decoder_memusage_nocheck(const void *options)
{
const lzma_options_lzma *const opt = options;
- return sizeof(lzma_coder) + lzma_lz_decoder_memusage(opt->dict_size);
+ return sizeof(lzma_lzma1_decoder)
+ + lzma_lz_decoder_memusage(opt->dict_size);
}
@@ -1042,15 +1032,14 @@ lzma_lzma_decoder_memusage(const void *options)
extern lzma_ret
-lzma_lzma_props_decode(void **options, lzma_allocator *allocator,
+lzma_lzma_props_decode(void **options, const lzma_allocator *allocator,
const uint8_t *props, size_t props_size)
{
- lzma_options_lzma *opt;
-
if (props_size != 5)
return LZMA_OPTIONS_ERROR;
- opt = lzma_alloc(sizeof(lzma_options_lzma), allocator);
+ lzma_options_lzma *opt
+ = lzma_alloc(sizeof(lzma_options_lzma), allocator);
if (opt == NULL)
return LZMA_MEM_ERROR;
diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma_decoder.h b/Utilities/cmliblzma/liblzma/lzma/lzma_decoder.h
index a463a76fc..fa8ecb23e 100644
--- a/Utilities/cmliblzma/liblzma/lzma/lzma_decoder.h
+++ b/Utilities/cmliblzma/liblzma/lzma/lzma_decoder.h
@@ -19,12 +19,13 @@
/// Allocates and initializes LZMA decoder
extern lzma_ret lzma_lzma_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern uint64_t lzma_lzma_decoder_memusage(const void *options);
extern lzma_ret lzma_lzma_props_decode(
- void **options, lzma_allocator *allocator,
+ void **options, const lzma_allocator *allocator,
const uint8_t *props, size_t props_size);
@@ -40,7 +41,7 @@ extern bool lzma_lzma_lclppb_decode(
/// Allocate and setup function pointers only. This is used by LZMA1 and
/// LZMA2 decoders.
extern lzma_ret lzma_lzma_decoder_create(
- lzma_lz_decoder *lz, lzma_allocator *allocator,
+ lzma_lz_decoder *lz, const lzma_allocator *allocator,
const void *opt, lzma_lz_options *lz_options);
/// Gets memory usage without validating lc/lp/pb. This is used by LZMA2
diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder.c b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder.c
index e8738f411..ba9ce6989 100644
--- a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder.c
+++ b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder.c
@@ -28,14 +28,11 @@ literal_matched(lzma_range_encoder *rc, probability *subcoder,
symbol += UINT32_C(1) << 8;
do {
- uint32_t match_bit;
- uint32_t subcoder_index;
- uint32_t bit;
-
match_byte <<= 1;
- match_bit = match_byte & offset;
- subcoder_index = offset + match_bit + (symbol >> 8);
- bit = (symbol >> 7) & 1;
+ const uint32_t match_bit = match_byte & offset;
+ const uint32_t subcoder_index
+ = offset + match_bit + (symbol >> 8);
+ const uint32_t bit = (symbol >> 7) & 1;
rc_bit(rc, &subcoder[subcoder_index], bit);
symbol <<= 1;
@@ -46,7 +43,7 @@ literal_matched(lzma_range_encoder *rc, probability *subcoder,
static inline void
-literal(lzma_coder *coder, lzma_mf *mf, uint32_t position)
+literal(lzma_lzma1_encoder *coder, lzma_mf *mf, uint32_t position)
{
// Locate the literal byte to be encoded and the subcoder.
const uint8_t cur_byte = mf->buffer[
@@ -80,19 +77,16 @@ literal(lzma_coder *coder, lzma_mf *mf, uint32_t position)
static void
length_update_prices(lzma_length_encoder *lc, const uint32_t pos_state)
{
- uint32_t a0, a1, b0, b1;
- uint32_t *prices;
- uint32_t i;
-
const uint32_t table_size = lc->table_size;
lc->counters[pos_state] = table_size;
- a0 = rc_bit_0_price(lc->choice);
- a1 = rc_bit_1_price(lc->choice);
- b0 = a1 + rc_bit_0_price(lc->choice2);
- b1 = a1 + rc_bit_1_price(lc->choice2);
- prices = lc->prices[pos_state];
+ const uint32_t a0 = rc_bit_0_price(lc->choice);
+ const uint32_t a1 = rc_bit_1_price(lc->choice);
+ const uint32_t b0 = a1 + rc_bit_0_price(lc->choice2);
+ const uint32_t b1 = a1 + rc_bit_1_price(lc->choice2);
+ uint32_t *const prices = lc->prices[pos_state];
+ uint32_t i;
for (i = 0; i < table_size && i < LEN_LOW_SYMBOLS; ++i)
prices[i] = a0 + rc_bittree_price(lc->low[pos_state],
LEN_LOW_BITS, i);
@@ -146,39 +140,36 @@ length(lzma_range_encoder *rc, lzma_length_encoder *lc,
///////////
static inline void
-match(lzma_coder *coder, const uint32_t pos_state,
+match(lzma_lzma1_encoder *coder, const uint32_t pos_state,
const uint32_t distance, const uint32_t len)
{
- uint32_t pos_slot;
- uint32_t len_to_pos_state;
-
update_match(coder->state);
length(&coder->rc, &coder->match_len_encoder, pos_state, len,
coder->fast_mode);
- pos_slot = get_pos_slot(distance);
- len_to_pos_state = get_len_to_pos_state(len);
- rc_bittree(&coder->rc, coder->pos_slot[len_to_pos_state],
- POS_SLOT_BITS, pos_slot);
+ const uint32_t dist_slot = get_dist_slot(distance);
+ const uint32_t dist_state = get_dist_state(len);
+ rc_bittree(&coder->rc, coder->dist_slot[dist_state],
+ DIST_SLOT_BITS, dist_slot);
- if (pos_slot >= START_POS_MODEL_INDEX) {
- const uint32_t footer_bits = (pos_slot >> 1) - 1;
- const uint32_t base = (2 | (pos_slot & 1)) << footer_bits;
- const uint32_t pos_reduced = distance - base;
+ if (dist_slot >= DIST_MODEL_START) {
+ const uint32_t footer_bits = (dist_slot >> 1) - 1;
+ const uint32_t base = (2 | (dist_slot & 1)) << footer_bits;
+ const uint32_t dist_reduced = distance - base;
- if (pos_slot < END_POS_MODEL_INDEX) {
- // Careful here: base - pos_slot - 1 can be -1, but
+ if (dist_slot < DIST_MODEL_END) {
+ // Careful here: base - dist_slot - 1 can be -1, but
// rc_bittree_reverse starts at probs[1], not probs[0].
rc_bittree_reverse(&coder->rc,
- coder->pos_special + base - pos_slot - 1,
- footer_bits, pos_reduced);
+ coder->dist_special + base - dist_slot - 1,
+ footer_bits, dist_reduced);
} else {
- rc_direct(&coder->rc, pos_reduced >> ALIGN_BITS,
+ rc_direct(&coder->rc, dist_reduced >> ALIGN_BITS,
footer_bits - ALIGN_BITS);
rc_bittree_reverse(
- &coder->rc, coder->pos_align,
- ALIGN_BITS, pos_reduced & ALIGN_MASK);
+ &coder->rc, coder->dist_align,
+ ALIGN_BITS, dist_reduced & ALIGN_MASK);
++coder->align_price_count;
}
}
@@ -196,7 +187,7 @@ match(lzma_coder *coder, const uint32_t pos_state,
////////////////////
static inline void
-rep_match(lzma_coder *coder, const uint32_t pos_state,
+rep_match(lzma_lzma1_encoder *coder, const uint32_t pos_state,
const uint32_t rep, const uint32_t len)
{
if (rep == 0) {
@@ -240,7 +231,7 @@ rep_match(lzma_coder *coder, const uint32_t pos_state,
//////////
static void
-encode_symbol(lzma_coder *coder, lzma_mf *mf,
+encode_symbol(lzma_lzma1_encoder *coder, lzma_mf *mf,
uint32_t back, uint32_t len, uint32_t position)
{
const uint32_t pos_state = position & coder->pos_mask;
@@ -256,7 +247,7 @@ encode_symbol(lzma_coder *coder, lzma_mf *mf,
rc_bit(&coder->rc,
&coder->is_match[coder->state][pos_state], 1);
- if (back < REP_DISTANCES) {
+ if (back < REPS) {
// It's a repeated match i.e. the same distance
// has been used earlier.
rc_bit(&coder->rc, &coder->is_rep[coder->state], 1);
@@ -264,7 +255,7 @@ encode_symbol(lzma_coder *coder, lzma_mf *mf,
} else {
// Normal match
rc_bit(&coder->rc, &coder->is_rep[coder->state], 0);
- match(coder, pos_state, back - REP_DISTANCES, len);
+ match(coder, pos_state, back - REPS, len);
}
}
@@ -274,7 +265,7 @@ encode_symbol(lzma_coder *coder, lzma_mf *mf,
static bool
-encode_init(lzma_coder *coder, lzma_mf *mf)
+encode_init(lzma_lzma1_encoder *coder, lzma_mf *mf)
{
assert(mf_position(mf) == 0);
@@ -302,7 +293,7 @@ encode_init(lzma_coder *coder, lzma_mf *mf)
static void
-encode_eopm(lzma_coder *coder, uint32_t position)
+encode_eopm(lzma_lzma1_encoder *coder, uint32_t position)
{
const uint32_t pos_state = position & coder->pos_mask;
rc_bit(&coder->rc, &coder->is_match[coder->state][pos_state], 1);
@@ -318,23 +309,18 @@ encode_eopm(lzma_coder *coder, uint32_t position)
extern lzma_ret
-lzma_lzma_encode(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
- uint8_t *LZMA_RESTRICT out, size_t *LZMA_RESTRICT out_pos,
+lzma_lzma_encode(lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf,
+ uint8_t *restrict out, size_t *restrict out_pos,
size_t out_size, uint32_t limit)
{
- uint32_t position;
-
// Initialize the stream if no data has been encoded yet.
if (!coder->is_initialized && !encode_init(coder, mf))
return LZMA_OK;
// Get the lowest bits of the uncompressed offset from the LZ layer.
- position = mf_position(mf);
+ uint32_t position = mf_position(mf);
while (true) {
- uint32_t len;
- uint32_t back;
-
// Encode pending bits, if any. Calling this before encoding
// the next symbol is needed only with plain LZMA, since
// LZMA2 always provides big enough buffer to flush
@@ -367,12 +353,14 @@ lzma_lzma_encode(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
// Get optimal match (repeat position and length).
// Value ranges for pos:
- // - [0, REP_DISTANCES): repeated match
- // - [REP_DISTANCES, UINT32_MAX):
- // match at (pos - REP_DISTANCES)
+ // - [0, REPS): repeated match
+ // - [REPS, UINT32_MAX):
+ // match at (pos - REPS)
// - UINT32_MAX: not a match but a literal
// Value ranges for len:
// - [MATCH_LEN_MIN, MATCH_LEN_MAX]
+ uint32_t len;
+ uint32_t back;
if (coder->fast_mode)
lzma_lzma_optimum_fast(coder, mf, &back, &len);
@@ -414,8 +402,8 @@ lzma_lzma_encode(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
static lzma_ret
-lzma_encode(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
- uint8_t *LZMA_RESTRICT out, size_t *LZMA_RESTRICT out_pos,
+lzma_encode(void *coder, lzma_mf *restrict mf,
+ uint8_t *restrict out, size_t *restrict out_pos,
size_t out_size)
{
// Plain LZMA has no support for sync-flushing.
@@ -465,12 +453,10 @@ static void
length_encoder_reset(lzma_length_encoder *lencoder,
const uint32_t num_pos_states, const bool fast_mode)
{
- size_t pos_state;
-
bit_reset(lencoder->choice);
bit_reset(lencoder->choice2);
- for (pos_state = 0; pos_state < num_pos_states; ++pos_state) {
+ for (size_t pos_state = 0; pos_state < num_pos_states; ++pos_state) {
bittree_reset(lencoder->low[pos_state], LEN_LOW_BITS);
bittree_reset(lencoder->mid[pos_state], LEN_MID_BITS);
}
@@ -478,7 +464,7 @@ length_encoder_reset(lzma_length_encoder *lencoder,
bittree_reset(lencoder->high, LEN_HIGH_BITS);
if (!fast_mode)
- for (pos_state = 0; pos_state < num_pos_states;
+ for (uint32_t pos_state = 0; pos_state < num_pos_states;
++pos_state)
length_update_prices(lencoder, pos_state);
@@ -487,10 +473,9 @@ length_encoder_reset(lzma_length_encoder *lencoder,
extern lzma_ret
-lzma_lzma_encoder_reset(lzma_coder *coder, const lzma_options_lzma *options)
+lzma_lzma_encoder_reset(lzma_lzma1_encoder *coder,
+ const lzma_options_lzma *options)
{
- size_t i, j;
-
if (!is_options_valid(options))
return LZMA_OPTIONS_ERROR;
@@ -503,14 +488,14 @@ lzma_lzma_encoder_reset(lzma_coder *coder, const lzma_options_lzma *options)
// State
coder->state = STATE_LIT_LIT;
- for (i = 0; i < REP_DISTANCES; ++i)
+ for (size_t i = 0; i < REPS; ++i)
coder->reps[i] = 0;
literal_init(coder->literal, options->lc, options->lp);
// Bit encoders
- for (i = 0; i < STATES; ++i) {
- for (j = 0; j <= coder->pos_mask; ++j) {
+ for (size_t i = 0; i < STATES; ++i) {
+ for (size_t j = 0; j <= coder->pos_mask; ++j) {
bit_reset(coder->is_match[i][j]);
bit_reset(coder->is_rep0_long[i][j]);
}
@@ -521,14 +506,14 @@ lzma_lzma_encoder_reset(lzma_coder *coder, const lzma_options_lzma *options)
bit_reset(coder->is_rep2[i]);
}
- for (i = 0; i < FULL_DISTANCES - END_POS_MODEL_INDEX; ++i)
- bit_reset(coder->pos_special[i]);
+ for (size_t i = 0; i < FULL_DISTANCES - DIST_MODEL_END; ++i)
+ bit_reset(coder->dist_special[i]);
// Bit tree encoders
- for (i = 0; i < LEN_TO_POS_STATES; ++i)
- bittree_reset(coder->pos_slot[i], POS_SLOT_BITS);
+ for (size_t i = 0; i < DIST_STATES; ++i)
+ bittree_reset(coder->dist_slot[i], DIST_SLOT_BITS);
- bittree_reset(coder->pos_align, ALIGN_BITS);
+ bittree_reset(coder->dist_align, ALIGN_BITS);
// Length encoders
length_encoder_reset(&coder->match_len_encoder,
@@ -561,20 +546,18 @@ lzma_lzma_encoder_reset(lzma_coder *coder, const lzma_options_lzma *options)
extern lzma_ret
-lzma_lzma_encoder_create(lzma_coder **coder_ptr, lzma_allocator *allocator,
+lzma_lzma_encoder_create(void **coder_ptr,
+ const lzma_allocator *allocator,
const lzma_options_lzma *options, lzma_lz_options *lz_options)
{
- lzma_coder *coder;
- uint32_t log_size = 0;
-
- // Allocate lzma_coder if it wasn't already allocated.
+ // Allocate lzma_lzma1_encoder if it wasn't already allocated.
if (*coder_ptr == NULL) {
- *coder_ptr = lzma_alloc(sizeof(lzma_coder), allocator);
+ *coder_ptr = lzma_alloc(sizeof(lzma_lzma1_encoder), allocator);
if (*coder_ptr == NULL)
return LZMA_MEM_ERROR;
}
- coder = *coder_ptr;
+ lzma_lzma1_encoder *coder = *coder_ptr;
// Set compression mode. We haven't validates the options yet,
// but it's OK here, since nothing bad happens with invalid
@@ -590,6 +573,7 @@ lzma_lzma_encoder_create(lzma_coder **coder_ptr, lzma_allocator *allocator,
// Set dist_table_size.
// Round the dictionary size up to next 2^n.
+ uint32_t log_size = 0;
while ((UINT32_C(1) << log_size) < options->dict_size)
++log_size;
@@ -622,7 +606,7 @@ lzma_lzma_encoder_create(lzma_coder **coder_ptr, lzma_allocator *allocator,
static lzma_ret
-lzma_encoder_init(lzma_lz_encoder *lz, lzma_allocator *allocator,
+lzma_encoder_init(lzma_lz_encoder *lz, const lzma_allocator *allocator,
const void *options, lzma_lz_options *lz_options)
{
lz->code = &lzma_encode;
@@ -632,7 +616,7 @@ lzma_encoder_init(lzma_lz_encoder *lz, lzma_allocator *allocator,
extern lzma_ret
-lzma_lzma_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_lzma_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters)
{
return lzma_lz_encoder_init(
@@ -643,19 +627,17 @@ lzma_lzma_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern uint64_t
lzma_lzma_encoder_memusage(const void *options)
{
- lzma_lz_options lz_options;
- uint64_t lz_memusage;
-
if (!is_options_valid(options))
return UINT64_MAX;
+ lzma_lz_options lz_options;
set_lz_options(&lz_options, options);
- lz_memusage = lzma_lz_encoder_memusage(&lz_options);
+ const uint64_t lz_memusage = lzma_lz_encoder_memusage(&lz_options);
if (lz_memusage == UINT64_MAX)
return UINT64_MAX;
- return (uint64_t)(sizeof(lzma_coder)) + lz_memusage;
+ return (uint64_t)(sizeof(lzma_lzma1_encoder)) + lz_memusage;
}
diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder.h b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder.h
index abb8d8b46..6cfdf228b 100644
--- a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder.h
+++ b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder.h
@@ -17,8 +17,12 @@
#include "common.h"
+typedef struct lzma_lzma1_encoder_s lzma_lzma1_encoder;
+
+
extern lzma_ret lzma_lzma_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern uint64_t lzma_lzma_encoder_memusage(const void *options);
@@ -35,18 +39,18 @@ extern bool lzma_lzma_lclppb_encode(
/// Initializes raw LZMA encoder; this is used by LZMA2.
extern lzma_ret lzma_lzma_encoder_create(
- lzma_coder **coder_ptr, lzma_allocator *allocator,
+ void **coder_ptr, const lzma_allocator *allocator,
const lzma_options_lzma *options, lzma_lz_options *lz_options);
/// Resets an already initialized LZMA encoder; this is used by LZMA2.
extern lzma_ret lzma_lzma_encoder_reset(
- lzma_coder *coder, const lzma_options_lzma *options);
+ lzma_lzma1_encoder *coder, const lzma_options_lzma *options);
-extern lzma_ret lzma_lzma_encode(lzma_coder *LZMA_RESTRICT coder,
- lzma_mf *LZMA_RESTRICT mf, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size,
+extern lzma_ret lzma_lzma_encode(lzma_lzma1_encoder *restrict coder,
+ lzma_mf *restrict mf, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size,
uint32_t read_limit);
#endif
diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_fast.c b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_fast.c
index f98312643..6c53d2bd0 100644
--- a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_fast.c
+++ b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_fast.c
@@ -10,6 +10,7 @@
///////////////////////////////////////////////////////////////////////////////
#include "lzma_encoder_private.h"
+#include "memcmplen.h"
#define change_pair(small_dist, big_dist) \
@@ -17,17 +18,10 @@
extern void
-lzma_lzma_optimum_fast(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
- uint32_t *LZMA_RESTRICT back_res, uint32_t *LZMA_RESTRICT len_res)
+lzma_lzma_optimum_fast(lzma_lzma1_encoder *restrict coder,
+ lzma_mf *restrict mf,
+ uint32_t *restrict back_res, uint32_t *restrict len_res)
{
- const uint8_t *buf;
- uint32_t buf_avail;
- uint32_t i;
- uint32_t rep_len = 0;
- uint32_t rep_index = 0;
- uint32_t back_main = 0;
- uint32_t limit;
-
const uint32_t nice_len = mf->nice_len;
uint32_t len_main;
@@ -40,8 +34,8 @@ lzma_lzma_optimum_fast(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT m
matches_count = coder->matches_count;
}
- buf = mf_ptr(mf) - 1;
- buf_avail = my_min(mf_avail(mf) + 1, MATCH_LEN_MAX);
+ const uint8_t *buf = mf_ptr(mf) - 1;
+ const uint32_t buf_avail = my_min(mf_avail(mf) + 1, MATCH_LEN_MAX);
if (buf_avail < 2) {
// There's not enough input left to encode a match.
@@ -51,9 +45,10 @@ lzma_lzma_optimum_fast(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT m
}
// Look for repeated matches; scan the previous four match distances
- for (i = 0; i < REP_DISTANCES; ++i) {
- uint32_t len;
+ uint32_t rep_len = 0;
+ uint32_t rep_index = 0;
+ for (uint32_t i = 0; i < REPS; ++i) {
// Pointer to the beginning of the match candidate
const uint8_t *const buf_back = buf - coder->reps[i] - 1;
@@ -64,8 +59,8 @@ lzma_lzma_optimum_fast(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT m
// The first two bytes matched.
// Calculate the length of the match.
- for (len = 2; len < buf_avail
- && buf[len] == buf_back[len]; ++len) ;
+ const uint32_t len = lzma_memcmplen(
+ buf, buf_back, 2, buf_avail);
// If we have found a repeated match that is at least
// nice_len long, return it immediately.
@@ -85,13 +80,13 @@ lzma_lzma_optimum_fast(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT m
// We didn't find a long enough repeated match. Encode it as a normal
// match if the match length is at least nice_len.
if (len_main >= nice_len) {
- *back_res = coder->matches[matches_count - 1].dist
- + REP_DISTANCES;
+ *back_res = coder->matches[matches_count - 1].dist + REPS;
*len_res = len_main;
mf_skip(mf, len_main - 1);
return;
}
+ uint32_t back_main = 0;
if (len_main >= 2) {
back_main = coder->matches[matches_count - 1].dist;
@@ -158,27 +153,17 @@ lzma_lzma_optimum_fast(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT m
// the old buf pointer instead of recalculating it with mf_ptr().
++buf;
- limit = len_main - 1;
-
- for (i = 0; i < REP_DISTANCES; ++i) {
- uint32_t len;
-
- const uint8_t *const buf_back = buf - coder->reps[i] - 1;
-
- if (not_equal_16(buf, buf_back))
- continue;
-
- for (len = 2; len < limit
- && buf[len] == buf_back[len]; ++len) ;
+ const uint32_t limit = my_max(2, len_main - 1);
- if (len >= limit) {
+ for (uint32_t i = 0; i < REPS; ++i) {
+ if (memcmp(buf, buf - coder->reps[i] - 1, limit) == 0) {
*back_res = UINT32_MAX;
*len_res = 1;
return;
}
}
- *back_res = back_main + REP_DISTANCES;
+ *back_res = back_main + REPS;
*len_res = len_main;
mf_skip(mf, len_main - 2);
return;
diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_normal.c b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_normal.c
index d3a63485c..59f77343e 100644
--- a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_normal.c
+++ b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_optimum_normal.c
@@ -11,6 +11,7 @@
#include "lzma_encoder_private.h"
#include "fastpos.h"
+#include "memcmplen.h"
////////////
@@ -18,7 +19,7 @@
////////////
static uint32_t
-get_literal_price(const lzma_coder *const coder, const uint32_t pos,
+get_literal_price(const lzma_lzma1_encoder *const coder, const uint32_t pos,
const uint32_t prev_byte, const bool match_mode,
uint32_t match_byte, uint32_t symbol)
{
@@ -35,15 +36,12 @@ get_literal_price(const lzma_coder *const coder, const uint32_t pos,
symbol += UINT32_C(1) << 8;
do {
- uint32_t match_bit;
- uint32_t subcoder_index;
- uint32_t bit;
-
match_byte <<= 1;
- match_bit = match_byte & offset;
- subcoder_index = offset + match_bit + (symbol >> 8);
- bit = (symbol >> 7) & 1;
+ const uint32_t match_bit = match_byte & offset;
+ const uint32_t subcoder_index
+ = offset + match_bit + (symbol >> 8);
+ const uint32_t bit = (symbol >> 7) & 1;
price += rc_bit_price(subcoder[subcoder_index], bit);
symbol <<= 1;
@@ -67,7 +65,7 @@ get_len_price(const lzma_length_encoder *const lencoder,
static inline uint32_t
-get_short_rep_price(const lzma_coder *const coder,
+get_short_rep_price(const lzma_lzma1_encoder *const coder,
const lzma_lzma_state state, const uint32_t pos_state)
{
return rc_bit_0_price(coder->is_rep0[state])
@@ -76,7 +74,7 @@ get_short_rep_price(const lzma_coder *const coder,
static inline uint32_t
-get_pure_rep_price(const lzma_coder *const coder, const uint32_t rep_index,
+get_pure_rep_price(const lzma_lzma1_encoder *const coder, const uint32_t rep_index,
const lzma_lzma_state state, uint32_t pos_state)
{
uint32_t price;
@@ -101,7 +99,7 @@ get_pure_rep_price(const lzma_coder *const coder, const uint32_t rep_index,
static inline uint32_t
-get_rep_price(const lzma_coder *const coder, const uint32_t rep_index,
+get_rep_price(const lzma_lzma1_encoder *const coder, const uint32_t rep_index,
const uint32_t len, const lzma_lzma_state state,
const uint32_t pos_state)
{
@@ -111,18 +109,18 @@ get_rep_price(const lzma_coder *const coder, const uint32_t rep_index,
static inline uint32_t
-get_pos_len_price(const lzma_coder *const coder, const uint32_t pos,
+get_dist_len_price(const lzma_lzma1_encoder *const coder, const uint32_t dist,
const uint32_t len, const uint32_t pos_state)
{
- const uint32_t len_to_pos_state = get_len_to_pos_state(len);
+ const uint32_t dist_state = get_dist_state(len);
uint32_t price;
- if (pos < FULL_DISTANCES) {
- price = coder->distances_prices[len_to_pos_state][pos];
+ if (dist < FULL_DISTANCES) {
+ price = coder->dist_prices[dist_state][dist];
} else {
- const uint32_t pos_slot = get_pos_slot_2(pos);
- price = coder->pos_slot_prices[len_to_pos_state][pos_slot]
- + coder->align_prices[pos & ALIGN_MASK];
+ const uint32_t dist_slot = get_dist_slot_2(dist);
+ price = coder->dist_slot_prices[dist_state][dist_slot]
+ + coder->align_prices[dist & ALIGN_MASK];
}
price += get_len_price(&coder->match_len_encoder, len, pos_state);
@@ -132,59 +130,53 @@ get_pos_len_price(const lzma_coder *const coder, const uint32_t pos,
static void
-fill_distances_prices(lzma_coder *coder)
+fill_dist_prices(lzma_lzma1_encoder *coder)
{
- uint32_t len_to_pos_state;
- uint32_t pos_slot;
- uint32_t i;
-
- for (len_to_pos_state = 0;
- len_to_pos_state < LEN_TO_POS_STATES;
- ++len_to_pos_state) {
+ for (uint32_t dist_state = 0; dist_state < DIST_STATES; ++dist_state) {
- uint32_t *const pos_slot_prices
- = coder->pos_slot_prices[len_to_pos_state];
+ uint32_t *const dist_slot_prices
+ = coder->dist_slot_prices[dist_state];
- // Price to encode the pos_slot.
- for (pos_slot = 0;
- pos_slot < coder->dist_table_size; ++pos_slot)
- pos_slot_prices[pos_slot] = rc_bittree_price(
- coder->pos_slot[len_to_pos_state],
- POS_SLOT_BITS, pos_slot);
+ // Price to encode the dist_slot.
+ for (uint32_t dist_slot = 0;
+ dist_slot < coder->dist_table_size; ++dist_slot)
+ dist_slot_prices[dist_slot] = rc_bittree_price(
+ coder->dist_slot[dist_state],
+ DIST_SLOT_BITS, dist_slot);
// For matches with distance >= FULL_DISTANCES, add the price
// of the direct bits part of the match distance. (Align bits
// are handled by fill_align_prices()).
- for (pos_slot = END_POS_MODEL_INDEX;
- pos_slot < coder->dist_table_size; ++pos_slot)
- pos_slot_prices[pos_slot] += rc_direct_price(
- ((pos_slot >> 1) - 1) - ALIGN_BITS);
+ for (uint32_t dist_slot = DIST_MODEL_END;
+ dist_slot < coder->dist_table_size;
+ ++dist_slot)
+ dist_slot_prices[dist_slot] += rc_direct_price(
+ ((dist_slot >> 1) - 1) - ALIGN_BITS);
// Distances in the range [0, 3] are fully encoded with
- // pos_slot, so they are used for coder->distances_prices
+ // dist_slot, so they are used for coder->dist_prices
// as is.
- for (i = 0; i < START_POS_MODEL_INDEX; ++i)
- coder->distances_prices[len_to_pos_state][i]
- = pos_slot_prices[i];
+ for (uint32_t i = 0; i < DIST_MODEL_START; ++i)
+ coder->dist_prices[dist_state][i]
+ = dist_slot_prices[i];
}
- // Distances in the range [4, 127] depend on pos_slot and pos_special.
- // We do this in a loop separate from the above loop to avoid
- // redundant calls to get_pos_slot().
- for (i = START_POS_MODEL_INDEX; i < FULL_DISTANCES; ++i) {
- const uint32_t pos_slot = get_pos_slot(i);
- const uint32_t footer_bits = ((pos_slot >> 1) - 1);
- const uint32_t base = (2 | (pos_slot & 1)) << footer_bits;
+ // Distances in the range [4, 127] depend on dist_slot and
+ // dist_special. We do this in a loop separate from the above
+ // loop to avoid redundant calls to get_dist_slot().
+ for (uint32_t i = DIST_MODEL_START; i < FULL_DISTANCES; ++i) {
+ const uint32_t dist_slot = get_dist_slot(i);
+ const uint32_t footer_bits = ((dist_slot >> 1) - 1);
+ const uint32_t base = (2 | (dist_slot & 1)) << footer_bits;
const uint32_t price = rc_bittree_reverse_price(
- coder->pos_special + base - pos_slot - 1,
+ coder->dist_special + base - dist_slot - 1,
footer_bits, i - base);
- for (len_to_pos_state = 0;
- len_to_pos_state < LEN_TO_POS_STATES;
- ++len_to_pos_state)
- coder->distances_prices[len_to_pos_state][i]
- = price + coder->pos_slot_prices[
- len_to_pos_state][pos_slot];
+ for (uint32_t dist_state = 0; dist_state < DIST_STATES;
+ ++dist_state)
+ coder->dist_prices[dist_state][i]
+ = price + coder->dist_slot_prices[
+ dist_state][dist_slot];
}
coder->match_price_count = 0;
@@ -193,12 +185,11 @@ fill_distances_prices(lzma_coder *coder)
static void
-fill_align_prices(lzma_coder *coder)
+fill_align_prices(lzma_lzma1_encoder *coder)
{
- uint32_t i;
- for (i = 0; i < ALIGN_TABLE_SIZE; ++i)
+ for (uint32_t i = 0; i < ALIGN_SIZE; ++i)
coder->align_prices[i] = rc_bittree_reverse_price(
- coder->pos_align, ALIGN_BITS, i);
+ coder->dist_align, ALIGN_BITS, i);
coder->align_price_count = 0;
return;
@@ -230,18 +221,15 @@ make_short_rep(lzma_optimal *optimal)
static void
-backward(lzma_coder *LZMA_RESTRICT coder, uint32_t *LZMA_RESTRICT len_res,
- uint32_t *LZMA_RESTRICT back_res, uint32_t cur)
+backward(lzma_lzma1_encoder *restrict coder, uint32_t *restrict len_res,
+ uint32_t *restrict back_res, uint32_t cur)
{
+ coder->opts_end_index = cur;
+
uint32_t pos_mem = coder->opts[cur].pos_prev;
uint32_t back_mem = coder->opts[cur].back_prev;
- coder->opts_end_index = cur;
-
do {
- const uint32_t pos_prev = pos_mem;
- const uint32_t back_cur = back_mem;
-
if (coder->opts[cur].prev_1_is_literal) {
make_literal(&coder->opts[pos_mem]);
coder->opts[pos_mem].pos_prev = pos_mem - 1;
@@ -256,6 +244,9 @@ backward(lzma_coder *LZMA_RESTRICT coder, uint32_t *LZMA_RESTRICT len_res,
}
}
+ const uint32_t pos_prev = pos_mem;
+ const uint32_t back_cur = back_mem;
+
back_mem = coder->opts[pos_prev].back_prev;
pos_mem = coder->opts[pos_prev].pos_prev;
@@ -278,27 +269,10 @@ backward(lzma_coder *LZMA_RESTRICT coder, uint32_t *LZMA_RESTRICT len_res,
//////////
static inline uint32_t
-helper1(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
- uint32_t *LZMA_RESTRICT back_res, uint32_t *LZMA_RESTRICT len_res,
+helper1(lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf,
+ uint32_t *restrict back_res, uint32_t *restrict len_res,
uint32_t position)
{
- uint32_t buf_avail;
- const uint8_t *buf;
- uint32_t rep_lens[REP_DISTANCES];
- uint32_t rep_max_index = 0;
- uint32_t i;
-
- uint8_t current_byte;
- uint8_t match_byte;
-
- uint32_t pos_state;
- uint32_t match_price;
- uint32_t rep_match_price;
- uint32_t len_end;
- uint32_t len;
-
- uint32_t normal_match_price;
-
const uint32_t nice_len = mf->nice_len;
uint32_t len_main;
@@ -312,18 +286,19 @@ helper1(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
matches_count = coder->matches_count;
}
- buf_avail = my_min(mf_avail(mf) + 1, MATCH_LEN_MAX);
+ const uint32_t buf_avail = my_min(mf_avail(mf) + 1, MATCH_LEN_MAX);
if (buf_avail < 2) {
*back_res = UINT32_MAX;
*len_res = 1;
return UINT32_MAX;
}
- buf = mf_ptr(mf) - 1;
+ const uint8_t *const buf = mf_ptr(mf) - 1;
- for (i = 0; i < REP_DISTANCES; ++i) {
- uint32_t len_test;
+ uint32_t rep_lens[REPS];
+ uint32_t rep_max_index = 0;
+ for (uint32_t i = 0; i < REPS; ++i) {
const uint8_t *const buf_back = buf - coder->reps[i] - 1;
if (not_equal_16(buf, buf_back)) {
@@ -331,12 +306,9 @@ helper1(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
continue;
}
- for (len_test = 2; len_test < buf_avail
- && buf[len_test] == buf_back[len_test];
- ++len_test) ;
+ rep_lens[i] = lzma_memcmplen(buf, buf_back, 2, buf_avail);
- rep_lens[i] = len_test;
- if (len_test > rep_lens[rep_max_index])
+ if (rep_lens[i] > rep_lens[rep_max_index])
rep_max_index = i;
}
@@ -349,15 +321,14 @@ helper1(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
if (len_main >= nice_len) {
- *back_res = coder->matches[matches_count - 1].dist
- + REP_DISTANCES;
+ *back_res = coder->matches[matches_count - 1].dist + REPS;
*len_res = len_main;
mf_skip(mf, len_main - 1);
return UINT32_MAX;
}
- current_byte = *buf;
- match_byte = *(buf - coder->reps[0] - 1);
+ const uint8_t current_byte = *buf;
+ const uint8_t match_byte = *(buf - coder->reps[0] - 1);
if (len_main < 2 && current_byte != match_byte
&& rep_lens[rep_max_index] < 2) {
@@ -368,7 +339,7 @@ helper1(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
coder->opts[0].state = coder->state;
- pos_state = position & coder->pos_mask;
+ const uint32_t pos_state = position & coder->pos_mask;
coder->opts[1].price = rc_bit_0_price(
coder->is_match[coder->state][pos_state])
@@ -378,9 +349,9 @@ helper1(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
make_literal(&coder->opts[1]);
- match_price = rc_bit_1_price(
+ const uint32_t match_price = rc_bit_1_price(
coder->is_match[coder->state][pos_state]);
- rep_match_price = match_price
+ const uint32_t rep_match_price = match_price
+ rc_bit_1_price(coder->is_rep[coder->state]);
if (match_byte == current_byte) {
@@ -394,7 +365,7 @@ helper1(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
}
}
- len_end = my_max(len_main, rep_lens[rep_max_index]);
+ const uint32_t len_end = my_max(len_main, rep_lens[rep_max_index]);
if (len_end < 2) {
*back_res = coder->opts[1].back_prev;
@@ -404,23 +375,21 @@ helper1(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
coder->opts[1].pos_prev = 0;
- for (i = 0; i < REP_DISTANCES; ++i)
+ for (uint32_t i = 0; i < REPS; ++i)
coder->opts[0].backs[i] = coder->reps[i];
- len = len_end;
+ uint32_t len = len_end;
do {
coder->opts[len].price = RC_INFINITY_PRICE;
} while (--len >= 2);
- for (i = 0; i < REP_DISTANCES; ++i) {
- uint32_t price;
-
+ for (uint32_t i = 0; i < REPS; ++i) {
uint32_t rep_len = rep_lens[i];
if (rep_len < 2)
continue;
- price = rep_match_price + get_pure_rep_price(
+ const uint32_t price = rep_match_price + get_pure_rep_price(
coder, i, coder->state, pos_state);
do {
@@ -439,7 +408,7 @@ helper1(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
}
- normal_match_price = match_price
+ const uint32_t normal_match_price = match_price
+ rc_bit_0_price(coder->is_rep[coder->state]);
len = rep_lens[0] >= 2 ? rep_lens[0] + 1 : 2;
@@ -451,14 +420,13 @@ helper1(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
for(; ; ++len) {
const uint32_t dist = coder->matches[i].dist;
const uint32_t cur_and_len_price = normal_match_price
- + get_pos_len_price(coder,
+ + get_dist_len_price(coder,
dist, len, pos_state);
if (cur_and_len_price < coder->opts[len].price) {
coder->opts[len].price = cur_and_len_price;
coder->opts[len].pos_prev = 0;
- coder->opts[len].back_prev
- = dist + REP_DISTANCES;
+ coder->opts[len].back_prev = dist + REPS;
coder->opts[len].prev_1_is_literal = false;
}
@@ -473,7 +441,7 @@ helper1(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
static inline uint32_t
-helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
+helper2(lzma_lzma1_encoder *coder, uint32_t *reps, const uint8_t *buf,
uint32_t len_end, uint32_t position, const uint32_t cur,
const uint32_t nice_len, const uint32_t buf_avail_full)
{
@@ -481,19 +449,6 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
uint32_t new_len = coder->longest_match_length;
uint32_t pos_prev = coder->opts[cur].pos_prev;
lzma_lzma_state state;
- uint32_t buf_avail;
- uint32_t rep_index;
- uint32_t i;
-
- uint32_t cur_price;
- uint8_t current_byte;
- uint8_t match_byte;
- uint32_t pos_state;
- uint32_t cur_and_1_price;
- bool next_is_literal = false;
- uint32_t match_price;
- uint32_t rep_match_price;
- uint32_t start_len = 2;
if (coder->opts[cur].prev_1_is_literal) {
--pos_prev;
@@ -501,7 +456,7 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
if (coder->opts[cur].prev_2) {
state = coder->opts[coder->opts[cur].pos_prev_2].state;
- if (coder->opts[cur].back_prev_2 < REP_DISTANCES)
+ if (coder->opts[cur].back_prev_2 < REPS)
update_long_rep(state);
else
update_match(state);
@@ -530,48 +485,49 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
update_long_rep(state);
} else {
pos = coder->opts[cur].back_prev;
- if (pos < REP_DISTANCES)
+ if (pos < REPS)
update_long_rep(state);
else
update_match(state);
}
- if (pos < REP_DISTANCES) {
- uint32_t i;
-
+ if (pos < REPS) {
reps[0] = coder->opts[pos_prev].backs[pos];
+ uint32_t i;
for (i = 1; i <= pos; ++i)
reps[i] = coder->opts[pos_prev].backs[i - 1];
- for (; i < REP_DISTANCES; ++i)
+ for (; i < REPS; ++i)
reps[i] = coder->opts[pos_prev].backs[i];
} else {
- reps[0] = pos - REP_DISTANCES;
+ reps[0] = pos - REPS;
- for (i = 1; i < REP_DISTANCES; ++i)
+ for (uint32_t i = 1; i < REPS; ++i)
reps[i] = coder->opts[pos_prev].backs[i - 1];
}
}
coder->opts[cur].state = state;
- for (i = 0; i < REP_DISTANCES; ++i)
+ for (uint32_t i = 0; i < REPS; ++i)
coder->opts[cur].backs[i] = reps[i];
- cur_price = coder->opts[cur].price;
+ const uint32_t cur_price = coder->opts[cur].price;
- current_byte = *buf;
- match_byte = *(buf - reps[0] - 1);
+ const uint8_t current_byte = *buf;
+ const uint8_t match_byte = *(buf - reps[0] - 1);
- pos_state = position & coder->pos_mask;
+ const uint32_t pos_state = position & coder->pos_mask;
- cur_and_1_price = cur_price
+ const uint32_t cur_and_1_price = cur_price
+ rc_bit_0_price(coder->is_match[state][pos_state])
+ get_literal_price(coder, position, buf[-1],
!is_literal_state(state), match_byte, current_byte);
+ bool next_is_literal = false;
+
if (cur_and_1_price < coder->opts[cur + 1].price) {
coder->opts[cur + 1].price = cur_and_1_price;
coder->opts[cur + 1].pos_prev = cur;
@@ -579,9 +535,9 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
next_is_literal = true;
}
- match_price = cur_price
+ const uint32_t match_price = cur_price
+ rc_bit_1_price(coder->is_match[state][pos_state]);
- rep_match_price = match_price
+ const uint32_t rep_match_price = match_price
+ rc_bit_1_price(coder->is_rep[state]);
if (match_byte == current_byte
@@ -602,40 +558,31 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
if (buf_avail_full < 2)
return len_end;
- buf_avail = my_min(buf_avail_full, nice_len);
+ const uint32_t buf_avail = my_min(buf_avail_full, nice_len);
if (!next_is_literal && match_byte != current_byte) { // speed optimization
// try literal + rep0
const uint8_t *const buf_back = buf - reps[0] - 1;
const uint32_t limit = my_min(buf_avail_full, nice_len + 1);
- uint32_t len_test = 1;
- while (len_test < limit && buf[len_test] == buf_back[len_test])
- ++len_test;
-
- --len_test;
+ const uint32_t len_test = lzma_memcmplen(buf, buf_back, 1, limit) - 1;
if (len_test >= 2) {
- uint32_t pos_state_next;
- uint32_t next_rep_match_price;
- uint32_t offset;
- uint32_t cur_and_len_price;
-
lzma_lzma_state state_2 = state;
update_literal(state_2);
- pos_state_next = (position + 1) & coder->pos_mask;
- next_rep_match_price = cur_and_1_price
+ const uint32_t pos_state_next = (position + 1) & coder->pos_mask;
+ const uint32_t next_rep_match_price = cur_and_1_price
+ rc_bit_1_price(coder->is_match[state_2][pos_state_next])
+ rc_bit_1_price(coder->is_rep[state_2]);
//for (; len_test >= 2; --len_test) {
- offset = cur + 1 + len_test;
+ const uint32_t offset = cur + 1 + len_test;
while (len_end < offset)
coder->opts[++len_end].price = RC_INFINITY_PRICE;
- cur_and_len_price = next_rep_match_price
+ const uint32_t cur_and_len_price = next_rep_match_price
+ get_rep_price(coder, 0, len_test,
state_2, pos_state_next);
@@ -651,23 +598,20 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
}
- for (rep_index = 0; rep_index < REP_DISTANCES; ++rep_index) {
- uint32_t len_test, len_test_2, len_test_temp;
- uint32_t price, limit;
+ uint32_t start_len = 2; // speed optimization
+ for (uint32_t rep_index = 0; rep_index < REPS; ++rep_index) {
const uint8_t *const buf_back = buf - reps[rep_index] - 1;
if (not_equal_16(buf, buf_back))
continue;
- for (len_test = 2; len_test < buf_avail
- && buf[len_test] == buf_back[len_test];
- ++len_test) ;
+ uint32_t len_test = lzma_memcmplen(buf, buf_back, 2, buf_avail);
while (len_end < cur + len_test)
coder->opts[++len_end].price = RC_INFINITY_PRICE;
- len_test_temp = len_test;
- price = rep_match_price + get_pure_rep_price(
+ const uint32_t len_test_temp = len_test;
+ const uint32_t price = rep_match_price + get_pure_rep_price(
coder, rep_index, state, pos_state);
do {
@@ -689,8 +633,8 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
start_len = len_test + 1;
- len_test_2 = len_test + 1;
- limit = my_min(buf_avail_full,
+ uint32_t len_test_2 = len_test + 1;
+ const uint32_t limit = my_min(buf_avail_full,
len_test_2 + nice_len);
for (; len_test_2 < limit
&& buf[len_test_2] == buf_back[len_test_2];
@@ -699,18 +643,12 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
len_test_2 -= len_test + 1;
if (len_test_2 >= 2) {
- uint32_t pos_state_next;
- uint32_t cur_and_len_literal_price;
- uint32_t next_rep_match_price;
- uint32_t offset;
- uint32_t cur_and_len_price;
-
lzma_lzma_state state_2 = state;
update_long_rep(state_2);
- pos_state_next = (position + len_test) & coder->pos_mask;
+ uint32_t pos_state_next = (position + len_test) & coder->pos_mask;
- cur_and_len_literal_price = price
+ const uint32_t cur_and_len_literal_price = price
+ get_len_price(&coder->rep_len_encoder,
len_test, pos_state)
+ rc_bit_0_price(coder->is_match[state_2][pos_state_next])
@@ -722,17 +660,17 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
pos_state_next = (position + len_test + 1) & coder->pos_mask;
- next_rep_match_price = cur_and_len_literal_price
+ const uint32_t next_rep_match_price = cur_and_len_literal_price
+ rc_bit_1_price(coder->is_match[state_2][pos_state_next])
+ rc_bit_1_price(coder->is_rep[state_2]);
//for(; len_test_2 >= 2; len_test_2--) {
- offset = cur + len_test + 1 + len_test_2;
+ const uint32_t offset = cur + len_test + 1 + len_test_2;
while (len_end < offset)
coder->opts[++len_end].price = RC_INFINITY_PRICE;
- cur_and_len_price = next_rep_match_price
+ const uint32_t cur_and_len_price = next_rep_match_price
+ get_rep_price(coder, 0, len_test_2,
state_2, pos_state_next);
@@ -763,29 +701,27 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
if (new_len >= start_len) {
- uint32_t len_test;
- uint32_t i = 0;
-
const uint32_t normal_match_price = match_price
+ rc_bit_0_price(coder->is_rep[state]);
while (len_end < cur + new_len)
coder->opts[++len_end].price = RC_INFINITY_PRICE;
+ uint32_t i = 0;
while (start_len > coder->matches[i].len)
++i;
- for (len_test = start_len; ; ++len_test) {
+ for (uint32_t len_test = start_len; ; ++len_test) {
const uint32_t cur_back = coder->matches[i].dist;
uint32_t cur_and_len_price = normal_match_price
- + get_pos_len_price(coder,
+ + get_dist_len_price(coder,
cur_back, len_test, pos_state);
if (cur_and_len_price < coder->opts[cur + len_test].price) {
coder->opts[cur + len_test].price = cur_and_len_price;
coder->opts[cur + len_test].pos_prev = cur;
coder->opts[cur + len_test].back_prev
- = cur_back + REP_DISTANCES;
+ = cur_back + REPS;
coder->opts[cur + len_test].prev_1_is_literal = false;
}
@@ -803,16 +739,12 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
len_test_2 -= len_test + 1;
if (len_test_2 >= 2) {
- uint32_t pos_state_next;
- uint32_t cur_and_len_literal_price;
- uint32_t next_rep_match_price;
- uint32_t offset;
-
lzma_lzma_state state_2 = state;
update_match(state_2);
- pos_state_next = (position + len_test) & coder->pos_mask;
+ uint32_t pos_state_next
+ = (position + len_test) & coder->pos_mask;
- cur_and_len_literal_price = cur_and_len_price
+ const uint32_t cur_and_len_literal_price = cur_and_len_price
+ rc_bit_0_price(
coder->is_match[state_2][pos_state_next])
+ get_literal_price(coder,
@@ -825,14 +757,14 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
update_literal(state_2);
pos_state_next = (pos_state_next + 1) & coder->pos_mask;
- next_rep_match_price
+ const uint32_t next_rep_match_price
= cur_and_len_literal_price
+ rc_bit_1_price(
coder->is_match[state_2][pos_state_next])
+ rc_bit_1_price(coder->is_rep[state_2]);
// for(; len_test_2 >= 2; --len_test_2) {
- offset = cur + len_test + 1 + len_test_2;
+ const uint32_t offset = cur + len_test + 1 + len_test_2;
while (len_end < offset)
coder->opts[++len_end].price = RC_INFINITY_PRICE;
@@ -849,7 +781,7 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
coder->opts[offset].prev_2 = true;
coder->opts[offset].pos_prev_2 = cur;
coder->opts[offset].back_prev_2
- = cur_back + REP_DISTANCES;
+ = cur_back + REPS;
}
//}
}
@@ -865,14 +797,11 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
extern void
-lzma_lzma_optimum_normal(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
- uint32_t *LZMA_RESTRICT back_res, uint32_t *LZMA_RESTRICT len_res,
+lzma_lzma_optimum_normal(lzma_lzma1_encoder *restrict coder,
+ lzma_mf *restrict mf,
+ uint32_t *restrict back_res, uint32_t *restrict len_res,
uint32_t position)
{
- uint32_t reps[REP_DISTANCES];
- uint32_t len_end;
- uint32_t cur;
-
// If we have symbols pending, return the next pending symbol.
if (coder->opts_end_index != coder->opts_current_index) {
assert(mf->read_ahead > 0);
@@ -889,9 +818,9 @@ lzma_lzma_optimum_normal(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT
// In liblzma they were moved into this single place.
if (mf->read_ahead == 0) {
if (coder->match_price_count >= (1 << 7))
- fill_distances_prices(coder);
+ fill_dist_prices(coder);
- if (coder->align_price_count >= ALIGN_TABLE_SIZE)
+ if (coder->align_price_count >= ALIGN_SIZE)
fill_align_prices(coder);
}
@@ -899,13 +828,14 @@ lzma_lzma_optimum_normal(lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT
// the original function into two pieces makes it at least a little
// more readable, since those two parts don't share many variables.
- len_end = helper1(coder, mf, back_res, len_res, position);
+ uint32_t len_end = helper1(coder, mf, back_res, len_res, position);
if (len_end == UINT32_MAX)
return;
-
+ uint32_t reps[REPS];
memcpy(reps, coder->reps, sizeof(reps));
+ uint32_t cur;
for (cur = 1; cur < len_end; ++cur) {
assert(cur < OPTS);
diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_presets.c b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_presets.c
index 9332abfa5..711df0255 100644
--- a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_presets.c
+++ b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_presets.c
@@ -2,6 +2,7 @@
//
/// \file lzma_encoder_presets.c
/// \brief Encoder presets
+/// \note xz needs this even when only decoding is enabled.
//
// Author: Lasse Collin
//
@@ -16,10 +17,6 @@
extern LZMA_API(lzma_bool)
lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset)
{
- static const uint8_t dict_pow2[]
- = { 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 };
- static const uint8_t depths[] = { 4, 8, 24, 48 };
-
const uint32_t level = preset & LZMA_PRESET_LEVEL_MASK;
const uint32_t flags = preset & ~LZMA_PRESET_LEVEL_MASK;
const uint32_t supported_flags = LZMA_PRESET_EXTREME;
@@ -34,12 +31,15 @@ lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset)
options->lp = LZMA_LP_DEFAULT;
options->pb = LZMA_PB_DEFAULT;
+ static const uint8_t dict_pow2[]
+ = { 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 };
options->dict_size = UINT32_C(1) << dict_pow2[level];
if (level <= 3) {
options->mode = LZMA_MODE_FAST;
options->mf = level == 0 ? LZMA_MF_HC3 : LZMA_MF_HC4;
options->nice_len = level <= 1 ? 128 : 273;
+ static const uint8_t depths[] = { 4, 8, 24, 48 };
options->depth = depths[level];
} else {
options->mode = LZMA_MODE_NORMAL;
diff --git a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_private.h b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_private.h
index 04fb29e90..a2da969f4 100644
--- a/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_private.h
+++ b/Utilities/cmliblzma/liblzma/lzma/lzma_encoder_private.h
@@ -64,12 +64,12 @@ typedef struct {
uint32_t pos_prev; // pos_next;
uint32_t back_prev;
- uint32_t backs[REP_DISTANCES];
+ uint32_t backs[REPS];
} lzma_optimal;
-struct lzma_coder_s {
+struct lzma_lzma1_encoder_s {
/// Range encoder
lzma_range_encoder rc;
@@ -77,7 +77,7 @@ struct lzma_coder_s {
lzma_lzma_state state;
/// The four most recent match distances
- uint32_t reps[REP_DISTANCES];
+ uint32_t reps[REPS];
/// Array of match candidates
lzma_match matches[MATCH_LEN_MAX + 1];
@@ -112,9 +112,9 @@ struct lzma_coder_s {
probability is_rep1[STATES];
probability is_rep2[STATES];
probability is_rep0_long[STATES][POS_STATES_MAX];
- probability pos_slot[LEN_TO_POS_STATES][POS_SLOTS];
- probability pos_special[FULL_DISTANCES - END_POS_MODEL_INDEX];
- probability pos_align[ALIGN_TABLE_SIZE];
+ probability dist_slot[DIST_STATES][DIST_SLOTS];
+ probability dist_special[FULL_DISTANCES - DIST_MODEL_END];
+ probability dist_align[ALIGN_SIZE];
// These are the same as in lzma_decoder.c except that the encoders
// include also price tables.
@@ -122,12 +122,12 @@ struct lzma_coder_s {
lzma_length_encoder rep_len_encoder;
// Price tables
- uint32_t pos_slot_prices[LEN_TO_POS_STATES][POS_SLOTS];
- uint32_t distances_prices[LEN_TO_POS_STATES][FULL_DISTANCES];
+ uint32_t dist_slot_prices[DIST_STATES][DIST_SLOTS];
+ uint32_t dist_prices[DIST_STATES][FULL_DISTANCES];
uint32_t dist_table_size;
uint32_t match_price_count;
- uint32_t align_prices[ALIGN_TABLE_SIZE];
+ uint32_t align_prices[ALIGN_SIZE];
uint32_t align_price_count;
// Optimal
@@ -138,11 +138,11 @@ struct lzma_coder_s {
extern void lzma_lzma_optimum_fast(
- lzma_coder *LZMA_RESTRICT coder, lzma_mf *LZMA_RESTRICT mf,
- uint32_t *LZMA_RESTRICT back_res, uint32_t *LZMA_RESTRICT len_res);
+ lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf,
+ uint32_t *restrict back_res, uint32_t *restrict len_res);
-extern void lzma_lzma_optimum_normal(lzma_coder *LZMA_RESTRICT coder,
- lzma_mf *LZMA_RESTRICT mf, uint32_t *LZMA_RESTRICT back_res,
- uint32_t *LZMA_RESTRICT len_res, uint32_t position);
+extern void lzma_lzma_optimum_normal(lzma_lzma1_encoder *restrict coder,
+ lzma_mf *restrict mf, uint32_t *restrict back_res,
+ uint32_t *restrict len_res, uint32_t position);
#endif
diff --git a/Utilities/cmliblzma/liblzma/rangecoder/range_common.h b/Utilities/cmliblzma/liblzma/rangecoder/range_common.h
index f15623ea6..2c74dc153 100644
--- a/Utilities/cmliblzma/liblzma/rangecoder/range_common.h
+++ b/Utilities/cmliblzma/liblzma/rangecoder/range_common.h
@@ -40,11 +40,8 @@
// This does the same for a complete bit tree.
// (A tree represented as an array.)
#define bittree_reset(probs, bit_levels) \
- do { \
- uint32_t bt_i; \
- for (bt_i = 0; bt_i < (1 << (bit_levels)); ++bt_i) \
- bit_reset((probs)[bt_i]); \
- } while (0)
+ for (uint32_t bt_i = 0; bt_i < (1 << (bit_levels)); ++bt_i) \
+ bit_reset((probs)[bt_i])
//////////////////////
diff --git a/Utilities/cmliblzma/liblzma/rangecoder/range_decoder.h b/Utilities/cmliblzma/liblzma/rangecoder/range_decoder.h
index 199e7b5a6..e0b051fac 100644
--- a/Utilities/cmliblzma/liblzma/rangecoder/range_decoder.h
+++ b/Utilities/cmliblzma/liblzma/rangecoder/range_decoder.h
@@ -25,20 +25,26 @@ typedef struct {
/// Reads the first five bytes to initialize the range decoder.
-static inline bool
-rc_read_init(lzma_range_decoder *rc, const uint8_t *LZMA_RESTRICT in,
- size_t *LZMA_RESTRICT in_pos, size_t in_size)
+static inline lzma_ret
+rc_read_init(lzma_range_decoder *rc, const uint8_t *restrict in,
+ size_t *restrict in_pos, size_t in_size)
{
while (rc->init_bytes_left > 0) {
if (*in_pos == in_size)
- return false;
+ return LZMA_OK;
+
+ // The first byte is always 0x00. It could have been omitted
+ // in LZMA2 but it wasn't, so one byte is wasted in every
+ // LZMA2 chunk.
+ if (rc->init_bytes_left == 5 && in[*in_pos] != 0x00)
+ return LZMA_DATA_ERROR;
rc->code = (rc->code << 8) | in[*in_pos];
++*in_pos;
--rc->init_bytes_left;
}
- return true;
+ return LZMA_STREAM_END;
}
diff --git a/Utilities/cmliblzma/liblzma/rangecoder/range_encoder.h b/Utilities/cmliblzma/liblzma/rangecoder/range_encoder.h
index e9614f252..1e1c36995 100644
--- a/Utilities/cmliblzma/liblzma/rangecoder/range_encoder.h
+++ b/Utilities/cmliblzma/liblzma/rangecoder/range_encoder.h
@@ -115,8 +115,7 @@ rc_direct(lzma_range_encoder *rc,
static inline void
rc_flush(lzma_range_encoder *rc)
{
- size_t i;
- for (i = 0; i < 5; ++i)
+ for (size_t i = 0; i < 5; ++i)
rc->symbols[rc->count++] = RC_FLUSH;
}
diff --git a/Utilities/cmliblzma/liblzma/simple/arm.c b/Utilities/cmliblzma/liblzma/simple/arm.c
index 8dcba39fd..181d0e3b2 100644
--- a/Utilities/cmliblzma/liblzma/simple/arm.c
+++ b/Utilities/cmliblzma/liblzma/simple/arm.c
@@ -15,19 +15,19 @@
static size_t
-arm_code(lzma_simple *simple lzma_attribute((__unused__)),
+arm_code(void *simple lzma_attribute((__unused__)),
uint32_t now_pos, bool is_encoder,
uint8_t *buffer, size_t size)
{
size_t i;
for (i = 0; i + 4 <= size; i += 4) {
if (buffer[i + 3] == 0xEB) {
- uint32_t dest;
uint32_t src = (buffer[i + 2] << 16)
| (buffer[i + 1] << 8)
| (buffer[i + 0]);
src <<= 2;
+ uint32_t dest;
if (is_encoder)
dest = now_pos + (uint32_t)(i) + 8 + src;
else
@@ -45,7 +45,7 @@ arm_code(lzma_simple *simple lzma_attribute((__unused__)),
static lzma_ret
-arm_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
+arm_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters, bool is_encoder)
{
return lzma_simple_coder_init(next, allocator, filters,
@@ -54,7 +54,8 @@ arm_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern lzma_ret
-lzma_simple_arm_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_simple_arm_encoder_init(lzma_next_coder *next,
+ const lzma_allocator *allocator,
const lzma_filter_info *filters)
{
return arm_coder_init(next, allocator, filters, true);
@@ -62,7 +63,8 @@ lzma_simple_arm_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern lzma_ret
-lzma_simple_arm_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_simple_arm_decoder_init(lzma_next_coder *next,
+ const lzma_allocator *allocator,
const lzma_filter_info *filters)
{
return arm_coder_init(next, allocator, filters, false);
diff --git a/Utilities/cmliblzma/liblzma/simple/armthumb.c b/Utilities/cmliblzma/liblzma/simple/armthumb.c
index 4b890a395..eab4862dd 100644
--- a/Utilities/cmliblzma/liblzma/simple/armthumb.c
+++ b/Utilities/cmliblzma/liblzma/simple/armthumb.c
@@ -15,7 +15,7 @@
static size_t
-armthumb_code(lzma_simple *simple lzma_attribute((__unused__)),
+armthumb_code(void *simple lzma_attribute((__unused__)),
uint32_t now_pos, bool is_encoder,
uint8_t *buffer, size_t size)
{
@@ -23,7 +23,6 @@ armthumb_code(lzma_simple *simple lzma_attribute((__unused__)),
for (i = 0; i + 4 <= size; i += 2) {
if ((buffer[i + 1] & 0xF8) == 0xF0
&& (buffer[i + 3] & 0xF8) == 0xF8) {
- uint32_t dest;
uint32_t src = ((buffer[i + 1] & 0x7) << 19)
| (buffer[i + 0] << 11)
| ((buffer[i + 3] & 0x7) << 8)
@@ -31,6 +30,7 @@ armthumb_code(lzma_simple *simple lzma_attribute((__unused__)),
src <<= 1;
+ uint32_t dest;
if (is_encoder)
dest = now_pos + (uint32_t)(i) + 4 + src;
else
@@ -50,7 +50,7 @@ armthumb_code(lzma_simple *simple lzma_attribute((__unused__)),
static lzma_ret
-armthumb_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
+armthumb_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters, bool is_encoder)
{
return lzma_simple_coder_init(next, allocator, filters,
@@ -60,7 +60,8 @@ armthumb_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern lzma_ret
lzma_simple_armthumb_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters)
{
return armthumb_coder_init(next, allocator, filters, true);
}
@@ -68,7 +69,8 @@ lzma_simple_armthumb_encoder_init(lzma_next_coder *next,
extern lzma_ret
lzma_simple_armthumb_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters)
{
return armthumb_coder_init(next, allocator, filters, false);
}
diff --git a/Utilities/cmliblzma/liblzma/simple/ia64.c b/Utilities/cmliblzma/liblzma/simple/ia64.c
index c537caca1..580529e80 100644
--- a/Utilities/cmliblzma/liblzma/simple/ia64.c
+++ b/Utilities/cmliblzma/liblzma/simple/ia64.c
@@ -15,7 +15,7 @@
static size_t
-ia64_code(lzma_simple *simple lzma_attribute((__unused__)),
+ia64_code(void *simple lzma_attribute((__unused__)),
uint32_t now_pos, bool is_encoder,
uint8_t *buffer, size_t size)
{
@@ -28,42 +28,36 @@ ia64_code(lzma_simple *simple lzma_attribute((__unused__)),
size_t i;
for (i = 0; i + 16 <= size; i += 16) {
- size_t slot;
-
const uint32_t instr_template = buffer[i] & 0x1F;
const uint32_t mask = BRANCH_TABLE[instr_template];
uint32_t bit_pos = 5;
- for (slot = 0; slot < 3; ++slot, bit_pos += 41) {
+ for (size_t slot = 0; slot < 3; ++slot, bit_pos += 41) {
+ if (((mask >> slot) & 1) == 0)
+ continue;
+
const size_t byte_pos = (bit_pos >> 3);
const uint32_t bit_res = bit_pos & 0x7;
uint64_t instruction = 0;
- uint64_t inst_norm;
- size_t j;
-
- if (((mask >> slot) & 1) == 0)
- continue;
- for (j = 0; j < 6; ++j)
+ for (size_t j = 0; j < 6; ++j)
instruction += (uint64_t)(
buffer[i + j + byte_pos])
<< (8 * j);
- inst_norm = instruction >> bit_res;
+ uint64_t inst_norm = instruction >> bit_res;
if (((inst_norm >> 37) & 0xF) == 0x5
&& ((inst_norm >> 9) & 0x7) == 0
/* && (inst_norm & 0x3F)== 0 */
) {
- uint32_t dest;
- size_t j;
-
uint32_t src = (uint32_t)(
(inst_norm >> 13) & 0xFFFFF);
src |= ((inst_norm >> 36) & 1) << 20;
src <<= 4;
+ uint32_t dest;
if (is_encoder)
dest = now_pos + (uint32_t)(i) + src;
else
@@ -79,7 +73,7 @@ ia64_code(lzma_simple *simple lzma_attribute((__unused__)),
instruction &= (1 << bit_res) - 1;
instruction |= (inst_norm << bit_res);
- for (j = 0; j < 6; j++)
+ for (size_t j = 0; j < 6; j++)
buffer[i + j + byte_pos] = (uint8_t)(
instruction
>> (8 * j));
@@ -92,7 +86,7 @@ ia64_code(lzma_simple *simple lzma_attribute((__unused__)),
static lzma_ret
-ia64_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
+ia64_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters, bool is_encoder)
{
return lzma_simple_coder_init(next, allocator, filters,
@@ -102,7 +96,8 @@ ia64_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern lzma_ret
lzma_simple_ia64_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters)
{
return ia64_coder_init(next, allocator, filters, true);
}
@@ -110,7 +105,8 @@ lzma_simple_ia64_encoder_init(lzma_next_coder *next,
extern lzma_ret
lzma_simple_ia64_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters)
{
return ia64_coder_init(next, allocator, filters, false);
}
diff --git a/Utilities/cmliblzma/liblzma/simple/powerpc.c b/Utilities/cmliblzma/liblzma/simple/powerpc.c
index 6f8351176..54dfbf102 100644
--- a/Utilities/cmliblzma/liblzma/simple/powerpc.c
+++ b/Utilities/cmliblzma/liblzma/simple/powerpc.c
@@ -15,7 +15,7 @@
static size_t
-powerpc_code(lzma_simple *simple lzma_attribute((__unused__)),
+powerpc_code(void *simple lzma_attribute((__unused__)),
uint32_t now_pos, bool is_encoder,
uint8_t *buffer, size_t size)
{
@@ -49,7 +49,7 @@ powerpc_code(lzma_simple *simple lzma_attribute((__unused__)),
static lzma_ret
-powerpc_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
+powerpc_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters, bool is_encoder)
{
return lzma_simple_coder_init(next, allocator, filters,
@@ -59,7 +59,8 @@ powerpc_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern lzma_ret
lzma_simple_powerpc_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters)
{
return powerpc_coder_init(next, allocator, filters, true);
}
@@ -67,7 +68,8 @@ lzma_simple_powerpc_encoder_init(lzma_next_coder *next,
extern lzma_ret
lzma_simple_powerpc_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters)
{
return powerpc_coder_init(next, allocator, filters, false);
}
diff --git a/Utilities/cmliblzma/liblzma/simple/simple_coder.c b/Utilities/cmliblzma/liblzma/simple/simple_coder.c
index f3bbdd7a7..13ebabc76 100644
--- a/Utilities/cmliblzma/liblzma/simple/simple_coder.c
+++ b/Utilities/cmliblzma/liblzma/simple/simple_coder.c
@@ -18,10 +18,10 @@
/// Copied or encodes/decodes more data to out[].
static lzma_ret
-copy_or_code(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size, lzma_action action)
+copy_or_code(lzma_simple_coder *coder, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size, lzma_action action)
{
assert(!coder->end_was_reached);
@@ -55,7 +55,7 @@ copy_or_code(lzma_coder *coder, lzma_allocator *allocator,
static size_t
-call_filter(lzma_coder *coder, uint8_t *buffer, size_t size)
+call_filter(lzma_simple_coder *coder, uint8_t *buffer, size_t size)
{
const size_t filtered = coder->filter(coder->simple,
coder->now_pos, coder->is_encoder,
@@ -66,13 +66,12 @@ call_filter(lzma_coder *coder, uint8_t *buffer, size_t size)
static lzma_ret
-simple_code(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *LZMA_RESTRICT in, size_t *LZMA_RESTRICT in_pos,
- size_t in_size, uint8_t *LZMA_RESTRICT out,
- size_t *LZMA_RESTRICT out_pos, size_t out_size, lzma_action action)
+simple_code(void *coder_ptr, const lzma_allocator *allocator,
+ const uint8_t *restrict in, size_t *restrict in_pos,
+ size_t in_size, uint8_t *restrict out,
+ size_t *restrict out_pos, size_t out_size, lzma_action action)
{
- size_t out_avail;
- size_t buf_avail;
+ lzma_simple_coder *coder = coder_ptr;
// TODO: Add partial support for LZMA_SYNC_FLUSH. We can support it
// in cases when the filter is able to filter everything. With most
@@ -108,13 +107,9 @@ simple_code(lzma_coder *coder, lzma_allocator *allocator,
// more data to out[] hopefully filling it completely. Then filter
// the data in out[]. This step is where most of the data gets
// filtered if the buffer sizes used by the application are reasonable.
- out_avail = out_size - *out_pos;
- buf_avail = coder->size - coder->pos;
+ const size_t out_avail = out_size - *out_pos;
+ const size_t buf_avail = coder->size - coder->pos;
if (out_avail > buf_avail || buf_avail == 0) {
- size_t size;
- size_t filtered;
- size_t unfiltered;
-
// Store the old position so that we know from which byte
// to start filtering.
const size_t out_start = *out_pos;
@@ -137,10 +132,11 @@ simple_code(lzma_coder *coder, lzma_allocator *allocator,
}
// Filter out[].
- size = *out_pos - out_start;
- filtered = call_filter(coder, out + out_start, size);
+ const size_t size = *out_pos - out_start;
+ const size_t filtered = call_filter(
+ coder, out + out_start, size);
- unfiltered = size - filtered;
+ const size_t unfiltered = size - filtered;
assert(unfiltered <= coder->allocated / 2);
// Now we can update coder->pos and coder->size, because
@@ -204,8 +200,9 @@ simple_code(lzma_coder *coder, lzma_allocator *allocator,
static void
-simple_coder_end(lzma_coder *coder, lzma_allocator *allocator)
+simple_coder_end(void *coder_ptr, const lzma_allocator *allocator)
{
+ lzma_simple_coder *coder = coder_ptr;
lzma_next_end(&coder->next, allocator);
lzma_free(coder->simple, allocator);
lzma_free(coder, allocator);
@@ -214,10 +211,12 @@ simple_coder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
-simple_coder_update(lzma_coder *coder, lzma_allocator *allocator,
+simple_coder_update(void *coder_ptr, const lzma_allocator *allocator,
const lzma_filter *filters_null lzma_attribute((__unused__)),
const lzma_filter *reversed_filters)
{
+ lzma_simple_coder *coder = coder_ptr;
+
// No update support, just call the next filter in the chain.
return lzma_next_filter_update(
&coder->next, allocator, reversed_filters + 1);
@@ -225,59 +224,59 @@ simple_coder_update(lzma_coder *coder, lzma_allocator *allocator,
extern lzma_ret
-lzma_simple_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_simple_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters,
- size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
+ size_t (*filter)(void *simple, uint32_t now_pos,
bool is_encoder, uint8_t *buffer, size_t size),
size_t simple_size, size_t unfiltered_max,
uint32_t alignment, bool is_encoder)
{
- // Allocate memory for the lzma_coder structure if needed.
- if (next->coder == NULL) {
+ // Allocate memory for the lzma_simple_coder structure if needed.
+ lzma_simple_coder *coder = next->coder;
+ if (coder == NULL) {
// Here we allocate space also for the temporary buffer. We
// need twice the size of unfiltered_max, because then it
// is always possible to filter at least unfiltered_max bytes
// more data in coder->buffer[] if it can be filled completely.
- next->coder = lzma_alloc(sizeof(lzma_coder)
+ coder = lzma_alloc(sizeof(lzma_simple_coder)
+ 2 * unfiltered_max, allocator);
- if (next->coder == NULL)
+ if (coder == NULL)
return LZMA_MEM_ERROR;
+ next->coder = coder;
next->code = &simple_code;
next->end = &simple_coder_end;
next->update = &simple_coder_update;
- next->coder->next = LZMA_NEXT_CODER_INIT;
- next->coder->filter = filter;
- next->coder->allocated = 2 * unfiltered_max;
+ coder->next = LZMA_NEXT_CODER_INIT;
+ coder->filter = filter;
+ coder->allocated = 2 * unfiltered_max;
// Allocate memory for filter-specific data structure.
if (simple_size > 0) {
- next->coder->simple = lzma_alloc(
- simple_size, allocator);
- if (next->coder->simple == NULL)
+ coder->simple = lzma_alloc(simple_size, allocator);
+ if (coder->simple == NULL)
return LZMA_MEM_ERROR;
} else {
- next->coder->simple = NULL;
+ coder->simple = NULL;
}
}
if (filters[0].options != NULL) {
const lzma_options_bcj *simple = filters[0].options;
- next->coder->now_pos = simple->start_offset;
- if (next->coder->now_pos & (alignment - 1))
+ coder->now_pos = simple->start_offset;
+ if (coder->now_pos & (alignment - 1))
return LZMA_OPTIONS_ERROR;
} else {
- next->coder->now_pos = 0;
+ coder->now_pos = 0;
}
// Reset variables.
- next->coder->is_encoder = is_encoder;
- next->coder->end_was_reached = false;
- next->coder->pos = 0;
- next->coder->filtered = 0;
- next->coder->size = 0;
-
- return lzma_next_filter_init(
- &next->coder->next, allocator, filters + 1);
+ coder->is_encoder = is_encoder;
+ coder->end_was_reached = false;
+ coder->pos = 0;
+ coder->filtered = 0;
+ coder->size = 0;
+
+ return lzma_next_filter_init(&coder->next, allocator, filters + 1);
}
diff --git a/Utilities/cmliblzma/liblzma/simple/simple_coder.h b/Utilities/cmliblzma/liblzma/simple/simple_coder.h
index 0952fad33..19c2ee03a 100644
--- a/Utilities/cmliblzma/liblzma/simple/simple_coder.h
+++ b/Utilities/cmliblzma/liblzma/simple/simple_coder.h
@@ -17,44 +17,56 @@
extern lzma_ret lzma_simple_x86_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern lzma_ret lzma_simple_x86_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern lzma_ret lzma_simple_powerpc_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern lzma_ret lzma_simple_powerpc_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern lzma_ret lzma_simple_ia64_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern lzma_ret lzma_simple_ia64_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern lzma_ret lzma_simple_arm_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern lzma_ret lzma_simple_arm_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern lzma_ret lzma_simple_armthumb_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern lzma_ret lzma_simple_armthumb_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern lzma_ret lzma_simple_sparc_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
extern lzma_ret lzma_simple_sparc_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters);
#endif
diff --git a/Utilities/cmliblzma/liblzma/simple/simple_decoder.c b/Utilities/cmliblzma/liblzma/simple/simple_decoder.c
index 034e158ff..1d864f2bf 100644
--- a/Utilities/cmliblzma/liblzma/simple/simple_decoder.c
+++ b/Utilities/cmliblzma/liblzma/simple/simple_decoder.c
@@ -14,18 +14,17 @@
extern lzma_ret
-lzma_simple_props_decode(void **options, lzma_allocator *allocator,
+lzma_simple_props_decode(void **options, const lzma_allocator *allocator,
const uint8_t *props, size_t props_size)
{
- lzma_options_bcj *opt;
-
if (props_size == 0)
return LZMA_OK;
if (props_size != 4)
return LZMA_OPTIONS_ERROR;
- opt = lzma_alloc(sizeof(lzma_options_bcj), allocator);
+ lzma_options_bcj *opt = lzma_alloc(
+ sizeof(lzma_options_bcj), allocator);
if (opt == NULL)
return LZMA_MEM_ERROR;
diff --git a/Utilities/cmliblzma/liblzma/simple/simple_decoder.h b/Utilities/cmliblzma/liblzma/simple/simple_decoder.h
index b8bf590f7..bed8d37a9 100644
--- a/Utilities/cmliblzma/liblzma/simple/simple_decoder.h
+++ b/Utilities/cmliblzma/liblzma/simple/simple_decoder.h
@@ -16,7 +16,7 @@
#include "simple_coder.h"
extern lzma_ret lzma_simple_props_decode(
- void **options, lzma_allocator *allocator,
+ void **options, const lzma_allocator *allocator,
const uint8_t *props, size_t props_size);
#endif
diff --git a/Utilities/cmliblzma/liblzma/simple/simple_private.h b/Utilities/cmliblzma/liblzma/simple/simple_private.h
index fcf9f7c19..9d2c0fdd7 100644
--- a/Utilities/cmliblzma/liblzma/simple/simple_private.h
+++ b/Utilities/cmliblzma/liblzma/simple/simple_private.h
@@ -16,9 +16,7 @@
#include "simple_coder.h"
-typedef struct lzma_simple_s lzma_simple;
-
-struct lzma_coder_s {
+typedef struct {
/// Next filter in the chain
lzma_next_coder next;
@@ -33,12 +31,12 @@ struct lzma_coder_s {
/// Pointer to filter-specific function, which does
/// the actual filtering.
- size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
+ size_t (*filter)(void *simple, uint32_t now_pos,
bool is_encoder, uint8_t *buffer, size_t size);
/// Pointer to filter-specific data, or NULL if filter doesn't need
/// any extra data.
- lzma_simple *simple;
+ void *simple;
/// The lowest 32 bits of the current position in the data. Most
/// filters need this to do conversions between absolute and relative
@@ -62,12 +60,13 @@ struct lzma_coder_s {
/// Temporary buffer
uint8_t buffer[];
-};
+} lzma_simple_coder;
extern lzma_ret lzma_simple_coder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters,
- size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters,
+ size_t (*filter)(void *simple, uint32_t now_pos,
bool is_encoder, uint8_t *buffer, size_t size),
size_t simple_size, size_t unfiltered_max,
uint32_t alignment, bool is_encoder);
diff --git a/Utilities/cmliblzma/liblzma/simple/sparc.c b/Utilities/cmliblzma/liblzma/simple/sparc.c
index 0ddd2ac9d..74b2655f3 100644
--- a/Utilities/cmliblzma/liblzma/simple/sparc.c
+++ b/Utilities/cmliblzma/liblzma/simple/sparc.c
@@ -15,7 +15,7 @@
static size_t
-sparc_code(lzma_simple *simple lzma_attribute((__unused__)),
+sparc_code(void *simple lzma_attribute((__unused__)),
uint32_t now_pos, bool is_encoder,
uint8_t *buffer, size_t size)
{
@@ -26,8 +26,6 @@ sparc_code(lzma_simple *simple lzma_attribute((__unused__)),
|| (buffer[i] == 0x7F
&& (buffer[i + 1] & 0xC0) == 0xC0)) {
- uint32_t dest;
-
uint32_t src = ((uint32_t)buffer[i + 0] << 24)
| ((uint32_t)buffer[i + 1] << 16)
| ((uint32_t)buffer[i + 2] << 8)
@@ -35,6 +33,7 @@ sparc_code(lzma_simple *simple lzma_attribute((__unused__)),
src <<= 2;
+ uint32_t dest;
if (is_encoder)
dest = now_pos + (uint32_t)(i) + src;
else
@@ -58,7 +57,7 @@ sparc_code(lzma_simple *simple lzma_attribute((__unused__)),
static lzma_ret
-sparc_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
+sparc_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters, bool is_encoder)
{
return lzma_simple_coder_init(next, allocator, filters,
@@ -68,7 +67,8 @@ sparc_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern lzma_ret
lzma_simple_sparc_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters)
{
return sparc_coder_init(next, allocator, filters, true);
}
@@ -76,7 +76,8 @@ lzma_simple_sparc_encoder_init(lzma_next_coder *next,
extern lzma_ret
lzma_simple_sparc_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
+ const lzma_allocator *allocator,
+ const lzma_filter_info *filters)
{
return sparc_coder_init(next, allocator, filters, false);
}
diff --git a/Utilities/cmliblzma/liblzma/simple/x86.c b/Utilities/cmliblzma/liblzma/simple/x86.c
index 95858e51e..b38cebfd5 100644
--- a/Utilities/cmliblzma/liblzma/simple/x86.c
+++ b/Utilities/cmliblzma/liblzma/simple/x86.c
@@ -17,14 +17,14 @@
#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF)
-struct lzma_simple_s {
+typedef struct {
uint32_t prev_mask;
uint32_t prev_pos;
-};
+} lzma_simple_x86;
static size_t
-x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder,
+x86_code(void *simple_ptr, uint32_t now_pos, bool is_encoder,
uint8_t *buffer, size_t size)
{
static const bool MASK_TO_ALLOWED_STATUS[8]
@@ -33,39 +33,34 @@ x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder,
static const uint32_t MASK_TO_BIT_NUMBER[8]
= { 0, 1, 2, 2, 3, 3, 3, 3 };
+ lzma_simple_x86 *simple = simple_ptr;
uint32_t prev_mask = simple->prev_mask;
uint32_t prev_pos = simple->prev_pos;
- size_t limit;
- size_t buffer_pos;
-
if (size < 5)
return 0;
if (now_pos - prev_pos > 5)
prev_pos = now_pos - 5;
- limit = size - 5;
- buffer_pos = 0;
+ const size_t limit = size - 5;
+ size_t buffer_pos = 0;
while (buffer_pos <= limit) {
- uint32_t offset;
- uint32_t i;
-
uint8_t b = buffer[buffer_pos];
if (b != 0xE8 && b != 0xE9) {
++buffer_pos;
continue;
}
- offset = now_pos + (uint32_t)(buffer_pos)
+ const uint32_t offset = now_pos + (uint32_t)(buffer_pos)
- prev_pos;
prev_pos = now_pos + (uint32_t)(buffer_pos);
if (offset > 5) {
prev_mask = 0;
} else {
- for (i = 0; i < offset; ++i) {
+ for (uint32_t i = 0; i < offset; ++i) {
prev_mask &= 0x77;
prev_mask <<= 1;
}
@@ -84,8 +79,6 @@ x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder,
uint32_t dest;
while (true) {
- uint32_t i;
-
if (is_encoder)
dest = src + (now_pos + (uint32_t)(
buffer_pos) + 5);
@@ -96,14 +89,15 @@ x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder,
if (prev_mask == 0)
break;
- i = MASK_TO_BIT_NUMBER[prev_mask >> 1];
+ const uint32_t i = MASK_TO_BIT_NUMBER[
+ prev_mask >> 1];
b = (uint8_t)(dest >> (24 - i * 8));
if (!Test86MSByte(b))
break;
- src = dest ^ ((1u << (32 - i * 8)) - 1);
+ src = dest ^ ((1ull << (32 - i * 8)) - 1);
}
buffer[buffer_pos + 4]
@@ -130,15 +124,17 @@ x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder,
static lzma_ret
-x86_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
+x86_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,
const lzma_filter_info *filters, bool is_encoder)
{
const lzma_ret ret = lzma_simple_coder_init(next, allocator, filters,
- &x86_code, sizeof(lzma_simple), 5, 1, is_encoder);
+ &x86_code, sizeof(lzma_simple_x86), 5, 1, is_encoder);
if (ret == LZMA_OK) {
- next->coder->simple->prev_mask = 0;
- next->coder->simple->prev_pos = (uint32_t)(-5);
+ lzma_simple_coder *coder = next->coder;
+ lzma_simple_x86 *simple = coder->simple;
+ simple->prev_mask = 0;
+ simple->prev_pos = (uint32_t)(-5);
}
return ret;
@@ -146,7 +142,8 @@ x86_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern lzma_ret
-lzma_simple_x86_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_simple_x86_encoder_init(lzma_next_coder *next,
+ const lzma_allocator *allocator,
const lzma_filter_info *filters)
{
return x86_coder_init(next, allocator, filters, true);
@@ -154,7 +151,8 @@ lzma_simple_x86_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
extern lzma_ret
-lzma_simple_x86_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
+lzma_simple_x86_decoder_init(lzma_next_coder *next,
+ const lzma_allocator *allocator,
const lzma_filter_info *filters)
{
return x86_coder_init(next, allocator, filters, false);
diff --git a/Utilities/cmlibrhash/CMakeLists.txt b/Utilities/cmlibrhash/CMakeLists.txt
index aa280554c..6067b7dcb 100644
--- a/Utilities/cmlibrhash/CMakeLists.txt
+++ b/Utilities/cmlibrhash/CMakeLists.txt
@@ -2,7 +2,7 @@ project(librhash C)
# Disable warnings to avoid changing 3rd party code.
if(CMAKE_C_COMPILER_ID MATCHES
- "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
+ "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel)$")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
diff --git a/Utilities/cmlibrhash/librhash/rhash.c b/Utilities/cmlibrhash/librhash/rhash.c
index ad6249b17..34e1eb305 100644
--- a/Utilities/cmlibrhash/librhash/rhash.c
+++ b/Utilities/cmlibrhash/librhash/rhash.c
@@ -18,6 +18,8 @@
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
+#include "ustd.h" /* Need this first within CMake. */
+
#include <string.h> /* memset() */
#include <stdlib.h> /* free() */
#include <stddef.h> /* ptrdiff_t */
diff --git a/Utilities/cmlibuv/CMakeLists.txt b/Utilities/cmlibuv/CMakeLists.txt
index 4c8e2289d..fe2ef756c 100644
--- a/Utilities/cmlibuv/CMakeLists.txt
+++ b/Utilities/cmlibuv/CMakeLists.txt
@@ -2,7 +2,7 @@ project(libuv C)
# Disable warnings to avoid changing 3rd party code.
if(CMAKE_C_COMPILER_ID MATCHES
- "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
+ "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel)$")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
@@ -14,18 +14,24 @@ set(uv_libraries ${CMAKE_THREAD_LIBS_INIT})
set(uv_includes include src)
set(uv_headers
include/uv.h
- include/uv-errno.h
- include/uv-threadpool.h
- include/uv-version.h
+ include/uv/errno.h
+ include/uv/threadpool.h
+ include/uv/version.h
)
set(uv_sources
src/fs-poll.c
src/heap-inl.h
+ src/idna.c
+ src/idna.h
src/inet.c
src/queue.h
+ src/strscpy.c
+ src/strscpy.h
src/threadpool.c
+ src/timer.c
src/uv-common.c
src/uv-common.h
+ src/uv-data-getter-setters.c
src/version.c
)
if(WIN32)
@@ -44,7 +50,7 @@ if(WIN32)
_WIN32_WINNT=0x0600
)
list(APPEND uv_headers
- include/uv-win.h
+ include/uv/win.h
include/tree.h
)
list(APPEND uv_sources
@@ -66,7 +72,6 @@ if(WIN32)
src/win/poll.c
src/win/process-stdio.c
src/win/process.c
- src/win/req.c
src/win/req-inl.h
src/win/signal.c
src/win/snprintf.c
@@ -74,7 +79,6 @@ if(WIN32)
src/win/stream-inl.h
src/win/tcp.c
src/win/thread.c
- src/win/timer.c
src/win/tty.c
src/win/udp.c
src/win/util.c
@@ -88,7 +92,7 @@ else()
src/unix
)
list(APPEND uv_headers
- include/uv-unix.h
+ include/uv/unix.h
)
list(APPEND uv_sources
src/unix/async.c
@@ -109,7 +113,6 @@ else()
src/unix/stream.c
src/unix/tcp.c
src/unix/thread.c
- src/unix/timer.c
src/unix/tty.c
src/unix/udp.c
)
@@ -120,7 +123,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
perfstat
)
list(APPEND uv_headers
- include/uv-aix.h
+ include/uv/aix.h
)
list(APPEND uv_defines
_ALL_SOURCE
@@ -130,6 +133,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
)
list(APPEND uv_sources
src/unix/aix.c
+ src/unix/aix-common.c
)
endif()
@@ -137,7 +141,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
list(APPEND uv_libraries
)
list(APPEND uv_headers
- include/uv-posix.h
+ include/uv/posix.h
)
list(APPEND uv_defines
)
@@ -156,8 +160,7 @@ endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
list(APPEND uv_headers
- include/uv-darwin.h
- include/pthread-barrier.h
+ include/uv/darwin.h
)
list(APPEND uv_defines
_DARWIN_USE_64_BIT_INODE=1
@@ -170,14 +173,13 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
src/unix/fsevents.c
src/unix/kqueue.c
src/unix/proctitle.c
- src/unix/pthread-barrier.c
)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND uv_libraries dl rt)
list(APPEND uv_headers
- include/uv-linux.h
+ include/uv/linux.h
)
list(APPEND uv_defines _GNU_SOURCE)
list(APPEND uv_sources
@@ -197,10 +199,28 @@ if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
kvm
)
list(APPEND uv_headers
- include/uv-bsd.h
+ include/uv/bsd.h
)
list(APPEND uv_sources
src/unix/bsd-ifaddrs.c
+ src/unix/bsd-proctitle.c
+ src/unix/freebsd.c
+ src/unix/kqueue.c
+ src/unix/posix-hrtime.c
+ )
+endif()
+
+if(CMAKE_SYSTEM_NAME STREQUAL "kFreeBSD")
+ list(APPEND uv_libraries
+ freebsd-glue
+ kvm
+ )
+ list(APPEND uv_headers
+ include/uv/bsd.h
+ )
+ list(APPEND uv_sources
+ src/unix/bsd-ifaddrs.c
+ src/unix/bsd-proctitle.c
src/unix/freebsd.c
src/unix/kqueue.c
src/unix/posix-hrtime.c
@@ -212,10 +232,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
kvm
)
list(APPEND uv_headers
- include/uv-bsd.h
+ include/uv/bsd.h
)
list(APPEND uv_sources
src/unix/bsd-ifaddrs.c
+ src/unix/bsd-proctitle.c
src/unix/netbsd.c
src/unix/kqueue.c
src/unix/posix-hrtime.c
@@ -227,10 +248,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
kvm
)
list(APPEND uv_headers
- include/uv-bsd.h
+ include/uv/bsd.h
)
list(APPEND uv_sources
src/unix/bsd-ifaddrs.c
+ src/unix/bsd-proctitle.c
src/unix/openbsd.c
src/unix/kqueue.c
src/unix/posix-hrtime.c
@@ -246,7 +268,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
rt
)
list(APPEND uv_headers
- include/uv-sunos.h
+ include/uv/sunos.h
)
list(APPEND uv_defines
__EXTENSIONS__
@@ -278,6 +300,23 @@ if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
)
endif()
+if(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
+ list(APPEND uv_libraries
+ rt
+ )
+ list(APPEND uv_headers
+ include/uv/posix.h
+ )
+ list(APPEND uv_defines
+ _XOPEN_SOURCE_EXTENDED
+ )
+ list(APPEND uv_sources
+ src/unix/hpux.c
+ src/unix/no-fsevents.c
+ src/unix/posix-poll.c
+ )
+endif()
+
include_directories(
${uv_includes}
${KWSYS_HEADER_ROOT}
diff --git a/Utilities/cmlibuv/LICENSE b/Utilities/cmlibuv/LICENSE
index 41ba44c28..28f17339e 100644
--- a/Utilities/cmlibuv/LICENSE
+++ b/Utilities/cmlibuv/LICENSE
@@ -62,8 +62,8 @@ The externally maintained libraries used by libuv are:
- stdint-msvc2008.h (from msinttypes), copyright Alexander Chemeris. Three
clause BSD license.
- - pthread-fixes.h, pthread-fixes.c, copyright Google Inc. and Sony Mobile
- Communications AB. Three clause BSD license.
+ - pthread-fixes.c, copyright Google Inc. and Sony Mobile Communications AB.
+ Three clause BSD license.
- android-ifaddrs.h, android-ifaddrs.c, copyright Berkeley Software Design
Inc, Kenneth MacKay and Emergya (Cloud4all, FP7/2007-2013, grant agreement
diff --git a/Utilities/cmlibuv/include/pthread-barrier.h b/Utilities/cmlibuv/include/pthread-barrier.h
deleted file mode 100644
index 900ebedd3..000000000
--- a/Utilities/cmlibuv/include/pthread-barrier.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-Copyright (c) 2016, Kari Tristan Helgason <kthelgason@gmail.com>
-
-Permission to use, copy, modify, and/or distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-
-#ifndef _UV_PTHREAD_BARRIER_
-#define _UV_PTHREAD_BARRIER_
-#include <errno.h>
-#include <pthread.h>
-#if !defined(__MVS__)
-#include <semaphore.h> /* sem_t */
-#endif
-
-#define PTHREAD_BARRIER_SERIAL_THREAD 0x12345
-
-/*
- * To maintain ABI compatibility with
- * libuv v1.x struct is padded according
- * to target platform
- */
-#if defined(__ANDROID__)
-# define UV_BARRIER_STRUCT_PADDING \
- sizeof(pthread_mutex_t) + \
- sizeof(pthread_cond_t) + \
- sizeof(unsigned int) - \
- sizeof(void *)
-#elif defined(__APPLE__)
-# define UV_BARRIER_STRUCT_PADDING \
- sizeof(pthread_mutex_t) + \
- 2 * sizeof(sem_t) + \
- 2 * sizeof(unsigned int) - \
- sizeof(void *)
-#else
-# define UV_BARRIER_STRUCT_PADDING 0
-#endif
-
-typedef struct {
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- unsigned threshold;
- unsigned in;
- unsigned out;
-} _uv_barrier;
-
-typedef struct {
- _uv_barrier* b;
- char _pad[UV_BARRIER_STRUCT_PADDING];
-} pthread_barrier_t;
-
-int pthread_barrier_init(pthread_barrier_t* barrier,
- const void* barrier_attr,
- unsigned count);
-
-int pthread_barrier_wait(pthread_barrier_t* barrier);
-int pthread_barrier_destroy(pthread_barrier_t *barrier);
-
-#endif /* _UV_PTHREAD_BARRIER_ */
diff --git a/Utilities/cmlibuv/include/uv-errno.h b/Utilities/cmlibuv/include/uv-errno.h
deleted file mode 100644
index f1371517c..000000000
--- a/Utilities/cmlibuv/include/uv-errno.h
+++ /dev/null
@@ -1,419 +0,0 @@
-/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#ifndef UV_ERRNO_H_
-#define UV_ERRNO_H_
-
-#include <errno.h>
-
-#define UV__EOF (-4095)
-#define UV__UNKNOWN (-4094)
-
-#define UV__EAI_ADDRFAMILY (-3000)
-#define UV__EAI_AGAIN (-3001)
-#define UV__EAI_BADFLAGS (-3002)
-#define UV__EAI_CANCELED (-3003)
-#define UV__EAI_FAIL (-3004)
-#define UV__EAI_FAMILY (-3005)
-#define UV__EAI_MEMORY (-3006)
-#define UV__EAI_NODATA (-3007)
-#define UV__EAI_NONAME (-3008)
-#define UV__EAI_OVERFLOW (-3009)
-#define UV__EAI_SERVICE (-3010)
-#define UV__EAI_SOCKTYPE (-3011)
-#define UV__EAI_BADHINTS (-3013)
-#define UV__EAI_PROTOCOL (-3014)
-
-/* Only map to the system errno on non-Windows platforms. It's apparently
- * a fairly common practice for Windows programmers to redefine errno codes.
- */
-#if defined(E2BIG) && !defined(_WIN32)
-# define UV__E2BIG (-E2BIG)
-#else
-# define UV__E2BIG (-4093)
-#endif
-
-#if defined(EACCES) && !defined(_WIN32)
-# define UV__EACCES (-EACCES)
-#else
-# define UV__EACCES (-4092)
-#endif
-
-#if defined(EADDRINUSE) && !defined(_WIN32)
-# define UV__EADDRINUSE (-EADDRINUSE)
-#else
-# define UV__EADDRINUSE (-4091)
-#endif
-
-#if defined(EADDRNOTAVAIL) && !defined(_WIN32)
-# define UV__EADDRNOTAVAIL (-EADDRNOTAVAIL)
-#else
-# define UV__EADDRNOTAVAIL (-4090)
-#endif
-
-#if defined(EAFNOSUPPORT) && !defined(_WIN32)
-# define UV__EAFNOSUPPORT (-EAFNOSUPPORT)
-#else
-# define UV__EAFNOSUPPORT (-4089)
-#endif
-
-#if defined(EAGAIN) && !defined(_WIN32)
-# define UV__EAGAIN (-EAGAIN)
-#else
-# define UV__EAGAIN (-4088)
-#endif
-
-#if defined(EALREADY) && !defined(_WIN32)
-# define UV__EALREADY (-EALREADY)
-#else
-# define UV__EALREADY (-4084)
-#endif
-
-#if defined(EBADF) && !defined(_WIN32)
-# define UV__EBADF (-EBADF)
-#else
-# define UV__EBADF (-4083)
-#endif
-
-#if defined(EBUSY) && !defined(_WIN32)
-# define UV__EBUSY (-EBUSY)
-#else
-# define UV__EBUSY (-4082)
-#endif
-
-#if defined(ECANCELED) && !defined(_WIN32)
-# define UV__ECANCELED (-ECANCELED)
-#else
-# define UV__ECANCELED (-4081)
-#endif
-
-#if defined(ECHARSET) && !defined(_WIN32)
-# define UV__ECHARSET (-ECHARSET)
-#else
-# define UV__ECHARSET (-4080)
-#endif
-
-#if defined(ECONNABORTED) && !defined(_WIN32)
-# define UV__ECONNABORTED (-ECONNABORTED)
-#else
-# define UV__ECONNABORTED (-4079)
-#endif
-
-#if defined(ECONNREFUSED) && !defined(_WIN32)
-# define UV__ECONNREFUSED (-ECONNREFUSED)
-#else
-# define UV__ECONNREFUSED (-4078)
-#endif
-
-#if defined(ECONNRESET) && !defined(_WIN32)
-# define UV__ECONNRESET (-ECONNRESET)
-#else
-# define UV__ECONNRESET (-4077)
-#endif
-
-#if defined(EDESTADDRREQ) && !defined(_WIN32)
-# define UV__EDESTADDRREQ (-EDESTADDRREQ)
-#else
-# define UV__EDESTADDRREQ (-4076)
-#endif
-
-#if defined(EEXIST) && !defined(_WIN32)
-# define UV__EEXIST (-EEXIST)
-#else
-# define UV__EEXIST (-4075)
-#endif
-
-#if defined(EFAULT) && !defined(_WIN32)
-# define UV__EFAULT (-EFAULT)
-#else
-# define UV__EFAULT (-4074)
-#endif
-
-#if defined(EHOSTUNREACH) && !defined(_WIN32)
-# define UV__EHOSTUNREACH (-EHOSTUNREACH)
-#else
-# define UV__EHOSTUNREACH (-4073)
-#endif
-
-#if defined(EINTR) && !defined(_WIN32)
-# define UV__EINTR (-EINTR)
-#else
-# define UV__EINTR (-4072)
-#endif
-
-#if defined(EINVAL) && !defined(_WIN32)
-# define UV__EINVAL (-EINVAL)
-#else
-# define UV__EINVAL (-4071)
-#endif
-
-#if defined(EIO) && !defined(_WIN32)
-# define UV__EIO (-EIO)
-#else
-# define UV__EIO (-4070)
-#endif
-
-#if defined(EISCONN) && !defined(_WIN32)
-# define UV__EISCONN (-EISCONN)
-#else
-# define UV__EISCONN (-4069)
-#endif
-
-#if defined(EISDIR) && !defined(_WIN32)
-# define UV__EISDIR (-EISDIR)
-#else
-# define UV__EISDIR (-4068)
-#endif
-
-#if defined(ELOOP) && !defined(_WIN32)
-# define UV__ELOOP (-ELOOP)
-#else
-# define UV__ELOOP (-4067)
-#endif
-
-#if defined(EMFILE) && !defined(_WIN32)
-# define UV__EMFILE (-EMFILE)
-#else
-# define UV__EMFILE (-4066)
-#endif
-
-#if defined(EMSGSIZE) && !defined(_WIN32)
-# define UV__EMSGSIZE (-EMSGSIZE)
-#else
-# define UV__EMSGSIZE (-4065)
-#endif
-
-#if defined(ENAMETOOLONG) && !defined(_WIN32)
-# define UV__ENAMETOOLONG (-ENAMETOOLONG)
-#else
-# define UV__ENAMETOOLONG (-4064)
-#endif
-
-#if defined(ENETDOWN) && !defined(_WIN32)
-# define UV__ENETDOWN (-ENETDOWN)
-#else
-# define UV__ENETDOWN (-4063)
-#endif
-
-#if defined(ENETUNREACH) && !defined(_WIN32)
-# define UV__ENETUNREACH (-ENETUNREACH)
-#else
-# define UV__ENETUNREACH (-4062)
-#endif
-
-#if defined(ENFILE) && !defined(_WIN32)
-# define UV__ENFILE (-ENFILE)
-#else
-# define UV__ENFILE (-4061)
-#endif
-
-#if defined(ENOBUFS) && !defined(_WIN32)
-# define UV__ENOBUFS (-ENOBUFS)
-#else
-# define UV__ENOBUFS (-4060)
-#endif
-
-#if defined(ENODEV) && !defined(_WIN32)
-# define UV__ENODEV (-ENODEV)
-#else
-# define UV__ENODEV (-4059)
-#endif
-
-#if defined(ENOENT) && !defined(_WIN32)
-# define UV__ENOENT (-ENOENT)
-#else
-# define UV__ENOENT (-4058)
-#endif
-
-#if defined(ENOMEM) && !defined(_WIN32)
-# define UV__ENOMEM (-ENOMEM)
-#else
-# define UV__ENOMEM (-4057)
-#endif
-
-#if defined(ENONET) && !defined(_WIN32)
-# define UV__ENONET (-ENONET)
-#else
-# define UV__ENONET (-4056)
-#endif
-
-#if defined(ENOSPC) && !defined(_WIN32)
-# define UV__ENOSPC (-ENOSPC)
-#else
-# define UV__ENOSPC (-4055)
-#endif
-
-#if defined(ENOSYS) && !defined(_WIN32)
-# define UV__ENOSYS (-ENOSYS)
-#else
-# define UV__ENOSYS (-4054)
-#endif
-
-#if defined(ENOTCONN) && !defined(_WIN32)
-# define UV__ENOTCONN (-ENOTCONN)
-#else
-# define UV__ENOTCONN (-4053)
-#endif
-
-#if defined(ENOTDIR) && !defined(_WIN32)
-# define UV__ENOTDIR (-ENOTDIR)
-#else
-# define UV__ENOTDIR (-4052)
-#endif
-
-#if defined(ENOTEMPTY) && !defined(_WIN32)
-# define UV__ENOTEMPTY (-ENOTEMPTY)
-#else
-# define UV__ENOTEMPTY (-4051)
-#endif
-
-#if defined(ENOTSOCK) && !defined(_WIN32)
-# define UV__ENOTSOCK (-ENOTSOCK)
-#else
-# define UV__ENOTSOCK (-4050)
-#endif
-
-#if defined(ENOTSUP) && !defined(_WIN32)
-# define UV__ENOTSUP (-ENOTSUP)
-#else
-# define UV__ENOTSUP (-4049)
-#endif
-
-#if defined(EPERM) && !defined(_WIN32)
-# define UV__EPERM (-EPERM)
-#else
-# define UV__EPERM (-4048)
-#endif
-
-#if defined(EPIPE) && !defined(_WIN32)
-# define UV__EPIPE (-EPIPE)
-#else
-# define UV__EPIPE (-4047)
-#endif
-
-#if defined(EPROTO) && !defined(_WIN32)
-# define UV__EPROTO (-EPROTO)
-#else
-# define UV__EPROTO (-4046)
-#endif
-
-#if defined(EPROTONOSUPPORT) && !defined(_WIN32)
-# define UV__EPROTONOSUPPORT (-EPROTONOSUPPORT)
-#else
-# define UV__EPROTONOSUPPORT (-4045)
-#endif
-
-#if defined(EPROTOTYPE) && !defined(_WIN32)
-# define UV__EPROTOTYPE (-EPROTOTYPE)
-#else
-# define UV__EPROTOTYPE (-4044)
-#endif
-
-#if defined(EROFS) && !defined(_WIN32)
-# define UV__EROFS (-EROFS)
-#else
-# define UV__EROFS (-4043)
-#endif
-
-#if defined(ESHUTDOWN) && !defined(_WIN32)
-# define UV__ESHUTDOWN (-ESHUTDOWN)
-#else
-# define UV__ESHUTDOWN (-4042)
-#endif
-
-#if defined(ESPIPE) && !defined(_WIN32)
-# define UV__ESPIPE (-ESPIPE)
-#else
-# define UV__ESPIPE (-4041)
-#endif
-
-#if defined(ESRCH) && !defined(_WIN32)
-# define UV__ESRCH (-ESRCH)
-#else
-# define UV__ESRCH (-4040)
-#endif
-
-#if defined(ETIMEDOUT) && !defined(_WIN32)
-# define UV__ETIMEDOUT (-ETIMEDOUT)
-#else
-# define UV__ETIMEDOUT (-4039)
-#endif
-
-#if defined(ETXTBSY) && !defined(_WIN32)
-# define UV__ETXTBSY (-ETXTBSY)
-#else
-# define UV__ETXTBSY (-4038)
-#endif
-
-#if defined(EXDEV) && !defined(_WIN32)
-# define UV__EXDEV (-EXDEV)
-#else
-# define UV__EXDEV (-4037)
-#endif
-
-#if defined(EFBIG) && !defined(_WIN32)
-# define UV__EFBIG (-EFBIG)
-#else
-# define UV__EFBIG (-4036)
-#endif
-
-#if defined(ENOPROTOOPT) && !defined(_WIN32)
-# define UV__ENOPROTOOPT (-ENOPROTOOPT)
-#else
-# define UV__ENOPROTOOPT (-4035)
-#endif
-
-#if defined(ERANGE) && !defined(_WIN32)
-# define UV__ERANGE (-ERANGE)
-#else
-# define UV__ERANGE (-4034)
-#endif
-
-#if defined(ENXIO) && !defined(_WIN32)
-# define UV__ENXIO (-ENXIO)
-#else
-# define UV__ENXIO (-4033)
-#endif
-
-#if defined(EMLINK) && !defined(_WIN32)
-# define UV__EMLINK (-EMLINK)
-#else
-# define UV__EMLINK (-4032)
-#endif
-
-/* EHOSTDOWN is not visible on BSD-like systems when _POSIX_C_SOURCE is
- * defined. Fortunately, its value is always 64 so it's possible albeit
- * icky to hard-code it.
- */
-#if defined(EHOSTDOWN) && !defined(_WIN32)
-# define UV__EHOSTDOWN (-EHOSTDOWN)
-#elif defined(__APPLE__) || \
- defined(__DragonFly__) || \
- defined(__FreeBSD__) || \
- defined(__FreeBSD_kernel__) || \
- defined(__NetBSD__) || \
- defined(__OpenBSD__)
-# define UV__EHOSTDOWN (-64)
-#else
-# define UV__EHOSTDOWN (-4031)
-#endif
-
-#endif /* UV_ERRNO_H_ */
diff --git a/Utilities/cmlibuv/include/uv-os390.h b/Utilities/cmlibuv/include/uv-os390.h
deleted file mode 100644
index 58f926111..000000000
--- a/Utilities/cmlibuv/include/uv-os390.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright libuv project contributors. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#ifndef UV_MVS_H
-#define UV_MVS_H
-
-#define UV_PLATFORM_SEM_T int
-
-#define UV_PLATFORM_LOOP_FIELDS \
- void* ep; \
-
-#endif /* UV_MVS_H */
diff --git a/Utilities/cmlibuv/include/uv-unix.h b/Utilities/cmlibuv/include/uv-unix.h
deleted file mode 100644
index d7754509b..000000000
--- a/Utilities/cmlibuv/include/uv-unix.h
+++ /dev/null
@@ -1,368 +0,0 @@
-/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#ifndef UV_UNIX_H
-#define UV_UNIX_H
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dirent.h>
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
-#include <termios.h>
-#include <pwd.h>
-
-#if !defined(__MVS__)
-#include <semaphore.h>
-#endif
-#include <pthread.h>
-#include <signal.h>
-
-#include "uv-threadpool.h"
-
-#if defined(__linux__)
-# include "uv-linux.h"
-#elif defined (__MVS__)
-# include "uv-os390.h"
-#elif defined(_AIX)
-# include "uv-aix.h"
-#elif defined(__sun)
-# include "uv-sunos.h"
-#elif defined(__APPLE__)
-# include "uv-darwin.h"
-#elif defined(__DragonFly__) || \
- defined(__FreeBSD__) || \
- defined(__FreeBSD_kernel__) || \
- defined(__OpenBSD__) || \
- defined(__NetBSD__)
-# include "uv-bsd.h"
-#elif defined(__CYGWIN__) || defined(__MSYS__)
-# include "uv-posix.h"
-#endif
-
-#ifndef PTHREAD_BARRIER_SERIAL_THREAD
-# include "pthread-barrier.h"
-#endif
-
-#ifndef NI_MAXHOST
-# define NI_MAXHOST 1025
-#endif
-
-#ifndef NI_MAXSERV
-# define NI_MAXSERV 32
-#endif
-
-#ifndef UV_IO_PRIVATE_PLATFORM_FIELDS
-# define UV_IO_PRIVATE_PLATFORM_FIELDS /* empty */
-#endif
-
-struct uv__io_s;
-struct uv_loop_s;
-
-typedef void (*uv__io_cb)(struct uv_loop_s* loop,
- struct uv__io_s* w,
- unsigned int events);
-typedef struct uv__io_s uv__io_t;
-
-struct uv__io_s {
- uv__io_cb cb;
- void* pending_queue[2];
- void* watcher_queue[2];
- unsigned int pevents; /* Pending event mask i.e. mask at next tick. */
- unsigned int events; /* Current event mask. */
- int fd;
- UV_IO_PRIVATE_PLATFORM_FIELDS
-};
-
-#ifndef UV_PLATFORM_SEM_T
-# define UV_PLATFORM_SEM_T sem_t
-#endif
-
-#ifndef UV_PLATFORM_LOOP_FIELDS
-# define UV_PLATFORM_LOOP_FIELDS /* empty */
-#endif
-
-#ifndef UV_PLATFORM_FS_EVENT_FIELDS
-# define UV_PLATFORM_FS_EVENT_FIELDS /* empty */
-#endif
-
-#ifndef UV_STREAM_PRIVATE_PLATFORM_FIELDS
-# define UV_STREAM_PRIVATE_PLATFORM_FIELDS /* empty */
-#endif
-
-/* Note: May be cast to struct iovec. See writev(2). */
-typedef struct uv_buf_t {
- char* base;
- size_t len;
-} uv_buf_t;
-
-typedef int uv_file;
-typedef int uv_os_sock_t;
-typedef int uv_os_fd_t;
-
-#define UV_ONCE_INIT PTHREAD_ONCE_INIT
-
-typedef pthread_once_t uv_once_t;
-typedef pthread_t uv_thread_t;
-typedef pthread_mutex_t uv_mutex_t;
-typedef pthread_rwlock_t uv_rwlock_t;
-typedef UV_PLATFORM_SEM_T uv_sem_t;
-typedef pthread_cond_t uv_cond_t;
-typedef pthread_key_t uv_key_t;
-typedef pthread_barrier_t uv_barrier_t;
-
-
-/* Platform-specific definitions for uv_spawn support. */
-typedef gid_t uv_gid_t;
-typedef uid_t uv_uid_t;
-
-typedef struct dirent uv__dirent_t;
-
-#if defined(DT_UNKNOWN)
-# define HAVE_DIRENT_TYPES
-# if defined(DT_REG)
-# define UV__DT_FILE DT_REG
-# else
-# define UV__DT_FILE -1
-# endif
-# if defined(DT_DIR)
-# define UV__DT_DIR DT_DIR
-# else
-# define UV__DT_DIR -2
-# endif
-# if defined(DT_LNK)
-# define UV__DT_LINK DT_LNK
-# else
-# define UV__DT_LINK -3
-# endif
-# if defined(DT_FIFO)
-# define UV__DT_FIFO DT_FIFO
-# else
-# define UV__DT_FIFO -4
-# endif
-# if defined(DT_SOCK)
-# define UV__DT_SOCKET DT_SOCK
-# else
-# define UV__DT_SOCKET -5
-# endif
-# if defined(DT_CHR)
-# define UV__DT_CHAR DT_CHR
-# else
-# define UV__DT_CHAR -6
-# endif
-# if defined(DT_BLK)
-# define UV__DT_BLOCK DT_BLK
-# else
-# define UV__DT_BLOCK -7
-# endif
-#endif
-
-/* Platform-specific definitions for uv_dlopen support. */
-#define UV_DYNAMIC /* empty */
-
-typedef struct {
- void* handle;
- char* errmsg;
-} uv_lib_t;
-
-#define UV_LOOP_PRIVATE_FIELDS \
- unsigned long flags; \
- int backend_fd; \
- void* pending_queue[2]; \
- void* watcher_queue[2]; \
- uv__io_t** watchers; \
- unsigned int nwatchers; \
- unsigned int nfds; \
- void* wq[2]; \
- uv_mutex_t wq_mutex; \
- uv_async_t wq_async; \
- uv_rwlock_t cloexec_lock; \
- uv_handle_t* closing_handles; \
- void* process_handles[2]; \
- void* prepare_handles[2]; \
- void* check_handles[2]; \
- void* idle_handles[2]; \
- void* async_handles[2]; \
- void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \
- uv__io_t async_io_watcher; \
- int async_wfd; \
- struct { \
- void* min; \
- unsigned int nelts; \
- } timer_heap; \
- uint64_t timer_counter; \
- uint64_t time; \
- int signal_pipefd[2]; \
- uv__io_t signal_io_watcher; \
- uv_signal_t child_watcher; \
- int emfile_fd; \
- UV_PLATFORM_LOOP_FIELDS \
-
-#define UV_REQ_TYPE_PRIVATE /* empty */
-
-#define UV_REQ_PRIVATE_FIELDS /* empty */
-
-#define UV_PRIVATE_REQ_TYPES /* empty */
-
-#define UV_WRITE_PRIVATE_FIELDS \
- void* queue[2]; \
- unsigned int write_index; \
- uv_buf_t* bufs; \
- unsigned int nbufs; \
- int error; \
- uv_buf_t bufsml[4]; \
-
-#define UV_CONNECT_PRIVATE_FIELDS \
- void* queue[2]; \
-
-#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */
-
-#define UV_UDP_SEND_PRIVATE_FIELDS \
- void* queue[2]; \
- struct sockaddr_storage addr; \
- unsigned int nbufs; \
- uv_buf_t* bufs; \
- ssize_t status; \
- uv_udp_send_cb send_cb; \
- uv_buf_t bufsml[4]; \
-
-#define UV_HANDLE_PRIVATE_FIELDS \
- uv_handle_t* next_closing; \
- unsigned int flags; \
-
-#define UV_STREAM_PRIVATE_FIELDS \
- uv_connect_t *connect_req; \
- uv_shutdown_t *shutdown_req; \
- uv__io_t io_watcher; \
- void* write_queue[2]; \
- void* write_completed_queue[2]; \
- uv_connection_cb connection_cb; \
- int delayed_error; \
- int accepted_fd; \
- void* queued_fds; \
- UV_STREAM_PRIVATE_PLATFORM_FIELDS \
-
-#define UV_TCP_PRIVATE_FIELDS /* empty */
-
-#define UV_UDP_PRIVATE_FIELDS \
- uv_alloc_cb alloc_cb; \
- uv_udp_recv_cb recv_cb; \
- uv__io_t io_watcher; \
- void* write_queue[2]; \
- void* write_completed_queue[2]; \
-
-#define UV_PIPE_PRIVATE_FIELDS \
- const char* pipe_fname; /* strdup'ed */
-
-#define UV_POLL_PRIVATE_FIELDS \
- uv__io_t io_watcher;
-
-#define UV_PREPARE_PRIVATE_FIELDS \
- uv_prepare_cb prepare_cb; \
- void* queue[2]; \
-
-#define UV_CHECK_PRIVATE_FIELDS \
- uv_check_cb check_cb; \
- void* queue[2]; \
-
-#define UV_IDLE_PRIVATE_FIELDS \
- uv_idle_cb idle_cb; \
- void* queue[2]; \
-
-#define UV_ASYNC_PRIVATE_FIELDS \
- uv_async_cb async_cb; \
- void* queue[2]; \
- int pending; \
-
-#define UV_TIMER_PRIVATE_FIELDS \
- uv_timer_cb timer_cb; \
- void* heap_node[3]; \
- uint64_t timeout; \
- uint64_t repeat; \
- uint64_t start_id;
-
-#define UV_GETADDRINFO_PRIVATE_FIELDS \
- struct uv__work work_req; \
- uv_getaddrinfo_cb cb; \
- struct addrinfo* hints; \
- char* hostname; \
- char* service; \
- struct addrinfo* addrinfo; \
- int retcode;
-
-#define UV_GETNAMEINFO_PRIVATE_FIELDS \
- struct uv__work work_req; \
- uv_getnameinfo_cb getnameinfo_cb; \
- struct sockaddr_storage storage; \
- int flags; \
- char host[NI_MAXHOST]; \
- char service[NI_MAXSERV]; \
- int retcode;
-
-#define UV_PROCESS_PRIVATE_FIELDS \
- void* queue[2]; \
- int status; \
-
-#define UV_FS_PRIVATE_FIELDS \
- const char *new_path; \
- uv_file file; \
- int flags; \
- mode_t mode; \
- unsigned int nbufs; \
- uv_buf_t* bufs; \
- off_t off; \
- uv_uid_t uid; \
- uv_gid_t gid; \
- double atime; \
- double mtime; \
- struct uv__work work_req; \
- uv_buf_t bufsml[4]; \
-
-#define UV_WORK_PRIVATE_FIELDS \
- struct uv__work work_req;
-
-#define UV_TTY_PRIVATE_FIELDS \
- struct termios orig_termios; \
- int mode;
-
-#define UV_SIGNAL_PRIVATE_FIELDS \
- /* RB_ENTRY(uv_signal_s) tree_entry; */ \
- struct { \
- struct uv_signal_s* rbe_left; \
- struct uv_signal_s* rbe_right; \
- struct uv_signal_s* rbe_parent; \
- int rbe_color; \
- } tree_entry; \
- /* Use two counters here so we don have to fiddle with atomics. */ \
- unsigned int caught_signals; \
- unsigned int dispatched_signals;
-
-#define UV_FS_EVENT_PRIVATE_FIELDS \
- uv_fs_event_cb cb; \
- UV_PLATFORM_FS_EVENT_FIELDS \
-
-#endif /* UV_UNIX_H */
diff --git a/Utilities/cmlibuv/include/uv-version.h b/Utilities/cmlibuv/include/uv-version.h
deleted file mode 100644
index e16580903..000000000
--- a/Utilities/cmlibuv/include/uv-version.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#ifndef UV_VERSION_H
-#define UV_VERSION_H
-
- /*
- * Versions with the same major number are ABI stable. API is allowed to
- * evolve between minor releases, but only in a backwards compatible way.
- * Make sure you update the -soname directives in configure.ac
- * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but
- * not UV_VERSION_PATCH.)
- */
-
-#define UV_VERSION_MAJOR 1
-#define UV_VERSION_MINOR 11
-#define UV_VERSION_PATCH 1
-#define UV_VERSION_IS_RELEASE 0
-#define UV_VERSION_SUFFIX "dev"
-
-#define UV_VERSION_HEX ((UV_VERSION_MAJOR << 16) | \
- (UV_VERSION_MINOR << 8) | \
- (UV_VERSION_PATCH))
-
-#endif /* UV_VERSION_H */
diff --git a/Utilities/cmlibuv/include/uv-win.h b/Utilities/cmlibuv/include/uv-win.h
deleted file mode 100644
index d3e32a508..000000000
--- a/Utilities/cmlibuv/include/uv-win.h
+++ /dev/null
@@ -1,661 +0,0 @@
-/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#ifndef _WIN32_WINNT
-# define _WIN32_WINNT 0x0502
-#endif
-
-#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
-typedef intptr_t ssize_t;
-# define _SSIZE_T_
-# define _SSIZE_T_DEFINED
-#endif
-
-#include <winsock2.h>
-
-#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
-typedef struct pollfd {
- SOCKET fd;
- short events;
- short revents;
-} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
-#endif
-
-#ifndef LOCALE_INVARIANT
-# define LOCALE_INVARIANT 0x007f
-#endif
-
-#include <mswsock.h>
-#include <ws2tcpip.h>
-#include <windows.h>
-
-#include <process.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-#if defined(_MSC_VER) && _MSC_VER < 1600
-# include "stdint-msvc2008.h"
-#else
-# include <stdint.h>
-#endif
-
-#include "tree.h"
-#include "uv-threadpool.h"
-
-#define MAX_PIPENAME_LEN 256
-
-#ifndef S_IFLNK
-# define S_IFLNK 0xA000
-#endif
-
-/* Additional signals supported by uv_signal and or uv_kill. The CRT defines
- * the following signals already:
- *
- * #define SIGINT 2
- * #define SIGILL 4
- * #define SIGABRT_COMPAT 6
- * #define SIGFPE 8
- * #define SIGSEGV 11
- * #define SIGTERM 15
- * #define SIGBREAK 21
- * #define SIGABRT 22
- *
- * The additional signals have values that are common on other Unix
- * variants (Linux and Darwin)
- */
-#define SIGHUP 1
-#define SIGKILL 9
-#define SIGWINCH 28
-
-/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many */
-/* unix-like platforms. However MinGW doesn't define it, so we do. */
-#ifndef SIGABRT_COMPAT
-# define SIGABRT_COMPAT 6
-#endif
-
-/*
- * Guids and typedefs for winsock extension functions
- * Mingw32 doesn't have these :-(
- */
-#ifndef WSAID_ACCEPTEX
-# define WSAID_ACCEPTEX \
- {0xb5367df1, 0xcbac, 0x11cf, \
- {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
-#endif
-
-#ifndef WSAID_CONNECTEX
-# define WSAID_CONNECTEX \
- {0x25a207b9, 0xddf3, 0x4660, \
- {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}}
-#endif
-
-#ifndef WSAID_GETACCEPTEXSOCKADDRS
-# define WSAID_GETACCEPTEXSOCKADDRS \
- {0xb5367df2, 0xcbac, 0x11cf, \
- {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
-#endif
-
-#ifndef WSAID_DISCONNECTEX
-# define WSAID_DISCONNECTEX \
- {0x7fda2e11, 0x8630, 0x436f, \
- {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}
-#endif
-
-#ifndef WSAID_TRANSMITFILE
-# define WSAID_TRANSMITFILE \
- {0xb5367df0, 0xcbac, 0x11cf, \
- {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
-#endif
-
-#if (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)) \
- || (defined(_MSC_VER) && _MSC_VER < 1500)
- typedef BOOL (PASCAL *LPFN_ACCEPTEX)
- (SOCKET sListenSocket,
- SOCKET sAcceptSocket,
- PVOID lpOutputBuffer,
- DWORD dwReceiveDataLength,
- DWORD dwLocalAddressLength,
- DWORD dwRemoteAddressLength,
- LPDWORD lpdwBytesReceived,
- LPOVERLAPPED lpOverlapped);
-
- typedef BOOL (PASCAL *LPFN_CONNECTEX)
- (SOCKET s,
- const struct sockaddr* name,
- int namelen,
- PVOID lpSendBuffer,
- DWORD dwSendDataLength,
- LPDWORD lpdwBytesSent,
- LPOVERLAPPED lpOverlapped);
-
- typedef void (PASCAL *LPFN_GETACCEPTEXSOCKADDRS)
- (PVOID lpOutputBuffer,
- DWORD dwReceiveDataLength,
- DWORD dwLocalAddressLength,
- DWORD dwRemoteAddressLength,
- LPSOCKADDR* LocalSockaddr,
- LPINT LocalSockaddrLength,
- LPSOCKADDR* RemoteSockaddr,
- LPINT RemoteSockaddrLength);
-
- typedef BOOL (PASCAL *LPFN_DISCONNECTEX)
- (SOCKET hSocket,
- LPOVERLAPPED lpOverlapped,
- DWORD dwFlags,
- DWORD reserved);
-
- typedef BOOL (PASCAL *LPFN_TRANSMITFILE)
- (SOCKET hSocket,
- HANDLE hFile,
- DWORD nNumberOfBytesToWrite,
- DWORD nNumberOfBytesPerSend,
- LPOVERLAPPED lpOverlapped,
- LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
- DWORD dwFlags);
-
- typedef PVOID RTL_SRWLOCK;
- typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
-#endif
-
-typedef int (WSAAPI* LPFN_WSARECV)
- (SOCKET socket,
- LPWSABUF buffers,
- DWORD buffer_count,
- LPDWORD bytes,
- LPDWORD flags,
- LPWSAOVERLAPPED overlapped,
- LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
-
-typedef int (WSAAPI* LPFN_WSARECVFROM)
- (SOCKET socket,
- LPWSABUF buffers,
- DWORD buffer_count,
- LPDWORD bytes,
- LPDWORD flags,
- struct sockaddr* addr,
- LPINT addr_len,
- LPWSAOVERLAPPED overlapped,
- LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
-
-#ifndef _NTDEF_
- typedef LONG NTSTATUS;
- typedef NTSTATUS *PNTSTATUS;
-#endif
-
-#ifndef RTL_CONDITION_VARIABLE_INIT
- typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE;
-#endif
-
-typedef struct _AFD_POLL_HANDLE_INFO {
- HANDLE Handle;
- ULONG Events;
- NTSTATUS Status;
-} AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO;
-
-typedef struct _AFD_POLL_INFO {
- LARGE_INTEGER Timeout;
- ULONG NumberOfHandles;
- ULONG Exclusive;
- AFD_POLL_HANDLE_INFO Handles[1];
-} AFD_POLL_INFO, *PAFD_POLL_INFO;
-
-#define UV_MSAFD_PROVIDER_COUNT 3
-
-
-/**
- * It should be possible to cast uv_buf_t[] to WSABUF[]
- * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
- */
-typedef struct uv_buf_t {
- ULONG len;
- char* base;
-} uv_buf_t;
-
-typedef int uv_file;
-typedef SOCKET uv_os_sock_t;
-typedef HANDLE uv_os_fd_t;
-
-typedef HANDLE uv_thread_t;
-
-typedef HANDLE uv_sem_t;
-
-typedef CRITICAL_SECTION uv_mutex_t;
-
-/* This condition variable implementation is based on the SetEvent solution
- * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
- * We could not use the SignalObjectAndWait solution (section 3.4) because
- * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and
- * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs.
- */
-
-typedef union {
- CONDITION_VARIABLE cond_var;
- struct {
- unsigned int waiters_count;
- CRITICAL_SECTION waiters_count_lock;
- HANDLE signal_event;
- HANDLE broadcast_event;
- } fallback;
-} uv_cond_t;
-
-typedef union {
- struct {
- unsigned int num_readers_;
- CRITICAL_SECTION num_readers_lock_;
- HANDLE write_semaphore_;
- } state_;
- /* TODO: remove me in v2.x. */
- struct {
- SRWLOCK unused_;
- } unused1_;
- /* TODO: remove me in v2.x. */
- struct {
- uv_mutex_t unused1_;
- uv_mutex_t unused2_;
- } unused2_;
-} uv_rwlock_t;
-
-typedef struct {
- unsigned int n;
- unsigned int count;
- uv_mutex_t mutex;
- uv_sem_t turnstile1;
- uv_sem_t turnstile2;
-} uv_barrier_t;
-
-typedef struct {
- DWORD tls_index;
-} uv_key_t;
-
-#define UV_ONCE_INIT { 0, NULL }
-
-typedef struct uv_once_s {
- unsigned char ran;
- HANDLE event;
-} uv_once_t;
-
-/* Platform-specific definitions for uv_spawn support. */
-typedef unsigned char uv_uid_t;
-typedef unsigned char uv_gid_t;
-
-typedef struct uv__dirent_s {
- int d_type;
- char d_name[1];
-} uv__dirent_t;
-
-#define HAVE_DIRENT_TYPES
-#define UV__DT_DIR UV_DIRENT_DIR
-#define UV__DT_FILE UV_DIRENT_FILE
-#define UV__DT_LINK UV_DIRENT_LINK
-#define UV__DT_FIFO UV_DIRENT_FIFO
-#define UV__DT_SOCKET UV_DIRENT_SOCKET
-#define UV__DT_CHAR UV_DIRENT_CHAR
-#define UV__DT_BLOCK UV_DIRENT_BLOCK
-
-/* Platform-specific definitions for uv_dlopen support. */
-#define UV_DYNAMIC FAR WINAPI
-typedef struct {
- HMODULE handle;
- char* errmsg;
-} uv_lib_t;
-
-RB_HEAD(uv_timer_tree_s, uv_timer_s);
-
-#define UV_LOOP_PRIVATE_FIELDS \
- /* The loop's I/O completion port */ \
- HANDLE iocp; \
- /* The current time according to the event loop. in msecs. */ \
- uint64_t time; \
- /* Tail of a single-linked circular queue of pending reqs. If the queue */ \
- /* is empty, tail_ is NULL. If there is only one item, */ \
- /* tail_->next_req == tail_ */ \
- uv_req_t* pending_reqs_tail; \
- /* Head of a single-linked list of closed handles */ \
- uv_handle_t* endgame_handles; \
- /* The head of the timers tree */ \
- struct uv_timer_tree_s timers; \
- /* Lists of active loop (prepare / check / idle) watchers */ \
- uv_prepare_t* prepare_handles; \
- uv_check_t* check_handles; \
- uv_idle_t* idle_handles; \
- /* This pointer will refer to the prepare/check/idle handle whose */ \
- /* callback is scheduled to be called next. This is needed to allow */ \
- /* safe removal from one of the lists above while that list being */ \
- /* iterated over. */ \
- uv_prepare_t* next_prepare_handle; \
- uv_check_t* next_check_handle; \
- uv_idle_t* next_idle_handle; \
- /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \
- SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \
- /* Counter to keep track of active tcp streams */ \
- unsigned int active_tcp_streams; \
- /* Counter to keep track of active udp streams */ \
- unsigned int active_udp_streams; \
- /* Counter to started timer */ \
- uint64_t timer_counter; \
- /* Threadpool */ \
- void* wq[2]; \
- uv_mutex_t wq_mutex; \
- uv_async_t wq_async;
-
-#define UV_REQ_TYPE_PRIVATE \
- /* TODO: remove the req suffix */ \
- UV_ACCEPT, \
- UV_FS_EVENT_REQ, \
- UV_POLL_REQ, \
- UV_PROCESS_EXIT, \
- UV_READ, \
- UV_UDP_RECV, \
- UV_WAKEUP, \
- UV_SIGNAL_REQ,
-
-#define UV_REQ_PRIVATE_FIELDS \
- union { \
- /* Used by I/O operations */ \
- struct { \
- OVERLAPPED overlapped; \
- size_t queued_bytes; \
- } io; \
- } u; \
- struct uv_req_s* next_req;
-
-#define UV_WRITE_PRIVATE_FIELDS \
- int ipc_header; \
- uv_buf_t write_buffer; \
- HANDLE event_handle; \
- HANDLE wait_handle;
-
-#define UV_CONNECT_PRIVATE_FIELDS \
- /* empty */
-
-#define UV_SHUTDOWN_PRIVATE_FIELDS \
- /* empty */
-
-#define UV_UDP_SEND_PRIVATE_FIELDS \
- /* empty */
-
-#define UV_PRIVATE_REQ_TYPES \
- typedef struct uv_pipe_accept_s { \
- UV_REQ_FIELDS \
- HANDLE pipeHandle; \
- struct uv_pipe_accept_s* next_pending; \
- } uv_pipe_accept_t; \
- \
- typedef struct uv_tcp_accept_s { \
- UV_REQ_FIELDS \
- SOCKET accept_socket; \
- char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \
- HANDLE event_handle; \
- HANDLE wait_handle; \
- struct uv_tcp_accept_s* next_pending; \
- } uv_tcp_accept_t; \
- \
- typedef struct uv_read_s { \
- UV_REQ_FIELDS \
- HANDLE event_handle; \
- HANDLE wait_handle; \
- } uv_read_t;
-
-#define uv_stream_connection_fields \
- unsigned int write_reqs_pending; \
- uv_shutdown_t* shutdown_req;
-
-#define uv_stream_server_fields \
- uv_connection_cb connection_cb;
-
-#define UV_STREAM_PRIVATE_FIELDS \
- unsigned int reqs_pending; \
- int activecnt; \
- uv_read_t read_req; \
- union { \
- struct { uv_stream_connection_fields } conn; \
- struct { uv_stream_server_fields } serv; \
- } stream;
-
-#define uv_tcp_server_fields \
- uv_tcp_accept_t* accept_reqs; \
- unsigned int processed_accepts; \
- uv_tcp_accept_t* pending_accepts; \
- LPFN_ACCEPTEX func_acceptex;
-
-#define uv_tcp_connection_fields \
- uv_buf_t read_buffer; \
- LPFN_CONNECTEX func_connectex;
-
-#define UV_TCP_PRIVATE_FIELDS \
- SOCKET socket; \
- int delayed_error; \
- union { \
- struct { uv_tcp_server_fields } serv; \
- struct { uv_tcp_connection_fields } conn; \
- } tcp;
-
-#define UV_UDP_PRIVATE_FIELDS \
- SOCKET socket; \
- unsigned int reqs_pending; \
- int activecnt; \
- uv_req_t recv_req; \
- uv_buf_t recv_buffer; \
- struct sockaddr_storage recv_from; \
- int recv_from_len; \
- uv_udp_recv_cb recv_cb; \
- uv_alloc_cb alloc_cb; \
- LPFN_WSARECV func_wsarecv; \
- LPFN_WSARECVFROM func_wsarecvfrom;
-
-#define uv_pipe_server_fields \
- int pending_instances; \
- uv_pipe_accept_t* accept_reqs; \
- uv_pipe_accept_t* pending_accepts;
-
-#define uv_pipe_connection_fields \
- uv_timer_t* eof_timer; \
- uv_write_t ipc_header_write_req; \
- int ipc_pid; \
- uint64_t remaining_ipc_rawdata_bytes; \
- struct { \
- void* queue[2]; \
- int queue_len; \
- } pending_ipc_info; \
- uv_write_t* non_overlapped_writes_tail; \
- uv_mutex_t readfile_mutex; \
- volatile HANDLE readfile_thread;
-
-#define UV_PIPE_PRIVATE_FIELDS \
- HANDLE handle; \
- WCHAR* name; \
- union { \
- struct { uv_pipe_server_fields } serv; \
- struct { uv_pipe_connection_fields } conn; \
- } pipe;
-
-/* TODO: put the parser states in an union - TTY handles are always */
-/* half-duplex so read-state can safely overlap write-state. */
-#define UV_TTY_PRIVATE_FIELDS \
- HANDLE handle; \
- union { \
- struct { \
- /* Used for readable TTY handles */ \
- /* TODO: remove me in v2.x. */ \
- HANDLE unused_; \
- uv_buf_t read_line_buffer; \
- HANDLE read_raw_wait; \
- /* Fields used for translating win keystrokes into vt100 characters */ \
- char last_key[8]; \
- unsigned char last_key_offset; \
- unsigned char last_key_len; \
- WCHAR last_utf16_high_surrogate; \
- INPUT_RECORD last_input_record; \
- } rd; \
- struct { \
- /* Used for writable TTY handles */ \
- /* utf8-to-utf16 conversion state */ \
- unsigned int utf8_codepoint; \
- unsigned char utf8_bytes_left; \
- /* eol conversion state */ \
- unsigned char previous_eol; \
- /* ansi parser state */ \
- unsigned char ansi_parser_state; \
- unsigned char ansi_csi_argc; \
- unsigned short ansi_csi_argv[4]; \
- COORD saved_position; \
- WORD saved_attributes; \
- } wr; \
- } tty;
-
-#define UV_POLL_PRIVATE_FIELDS \
- SOCKET socket; \
- /* Used in fast mode */ \
- SOCKET peer_socket; \
- AFD_POLL_INFO afd_poll_info_1; \
- AFD_POLL_INFO afd_poll_info_2; \
- /* Used in fast and slow mode. */ \
- uv_req_t poll_req_1; \
- uv_req_t poll_req_2; \
- unsigned char submitted_events_1; \
- unsigned char submitted_events_2; \
- unsigned char mask_events_1; \
- unsigned char mask_events_2; \
- unsigned char events;
-
-#define UV_TIMER_PRIVATE_FIELDS \
- RB_ENTRY(uv_timer_s) tree_entry; \
- uint64_t due; \
- uint64_t repeat; \
- uint64_t start_id; \
- uv_timer_cb timer_cb;
-
-#define UV_ASYNC_PRIVATE_FIELDS \
- struct uv_req_s async_req; \
- uv_async_cb async_cb; \
- /* char to avoid alignment issues */ \
- char volatile async_sent;
-
-#define UV_PREPARE_PRIVATE_FIELDS \
- uv_prepare_t* prepare_prev; \
- uv_prepare_t* prepare_next; \
- uv_prepare_cb prepare_cb;
-
-#define UV_CHECK_PRIVATE_FIELDS \
- uv_check_t* check_prev; \
- uv_check_t* check_next; \
- uv_check_cb check_cb;
-
-#define UV_IDLE_PRIVATE_FIELDS \
- uv_idle_t* idle_prev; \
- uv_idle_t* idle_next; \
- uv_idle_cb idle_cb;
-
-#define UV_HANDLE_PRIVATE_FIELDS \
- uv_handle_t* endgame_next; \
- unsigned int flags;
-
-#define UV_GETADDRINFO_PRIVATE_FIELDS \
- struct uv__work work_req; \
- uv_getaddrinfo_cb getaddrinfo_cb; \
- void* alloc; \
- WCHAR* node; \
- WCHAR* service; \
- /* The addrinfoW field is used to store a pointer to the hints, and */ \
- /* later on to store the result of GetAddrInfoW. The final result will */ \
- /* be converted to struct addrinfo* and stored in the addrinfo field. */ \
- struct addrinfoW* addrinfow; \
- struct addrinfo* addrinfo; \
- int retcode;
-
-#define UV_GETNAMEINFO_PRIVATE_FIELDS \
- struct uv__work work_req; \
- uv_getnameinfo_cb getnameinfo_cb; \
- struct sockaddr_storage storage; \
- int flags; \
- char host[NI_MAXHOST]; \
- char service[NI_MAXSERV]; \
- int retcode;
-
-#define UV_PROCESS_PRIVATE_FIELDS \
- struct uv_process_exit_s { \
- UV_REQ_FIELDS \
- } exit_req; \
- BYTE* child_stdio_buffer; \
- int exit_signal; \
- HANDLE wait_handle; \
- HANDLE process_handle; \
- volatile char exit_cb_pending;
-
-#define UV_FS_PRIVATE_FIELDS \
- struct uv__work work_req; \
- int flags; \
- DWORD sys_errno_; \
- union { \
- /* TODO: remove me in 0.9. */ \
- WCHAR* pathw; \
- int fd; \
- } file; \
- union { \
- struct { \
- int mode; \
- WCHAR* new_pathw; \
- int file_flags; \
- int fd_out; \
- unsigned int nbufs; \
- uv_buf_t* bufs; \
- int64_t offset; \
- uv_buf_t bufsml[4]; \
- } info; \
- struct { \
- double atime; \
- double mtime; \
- } time; \
- } fs;
-
-#define UV_WORK_PRIVATE_FIELDS \
- struct uv__work work_req;
-
-#define UV_FS_EVENT_PRIVATE_FIELDS \
- struct uv_fs_event_req_s { \
- UV_REQ_FIELDS \
- } req; \
- HANDLE dir_handle; \
- int req_pending; \
- uv_fs_event_cb cb; \
- WCHAR* filew; \
- WCHAR* short_filew; \
- WCHAR* dirw; \
- char* buffer;
-
-#define UV_SIGNAL_PRIVATE_FIELDS \
- RB_ENTRY(uv_signal_s) tree_entry; \
- struct uv_req_s signal_req; \
- unsigned long pending_signum;
-
-#ifndef F_OK
-#define F_OK 0
-#endif
-#ifndef R_OK
-#define R_OK 4
-#endif
-#ifndef W_OK
-#define W_OK 2
-#endif
-#ifndef X_OK
-#define X_OK 1
-#endif
diff --git a/Utilities/cmlibuv/include/uv.h b/Utilities/cmlibuv/include/uv.h
index 38f567644..eb80bfbc2 100644
--- a/Utilities/cmlibuv/include/uv.h
+++ b/Utilities/cmlibuv/include/uv.h
@@ -49,21 +49,21 @@ extern "C" {
# define UV_EXTERN /* nothing */
#endif
-#include "uv-errno.h"
-#include "uv-version.h"
+#include "uv/errno.h"
+#include "uv/version.h"
#include <stddef.h>
#include <stdio.h>
#if defined(_MSC_VER) && _MSC_VER < 1600
-# include "stdint-msvc2008.h"
+# include "uv/stdint-msvc2008.h"
#else
# include <stdint.h>
#endif
#if defined(_WIN32)
-# include "uv-win.h"
+# include "uv/win.h"
#else
-# include "uv-unix.h"
+# include "uv/unix.h"
#endif
/* Expand this list if necessary. */
@@ -144,6 +144,9 @@ extern "C" {
XX(ENXIO, "no such device or address") \
XX(EMLINK, "too many links") \
XX(EHOSTDOWN, "host is down") \
+ XX(EREMOTEIO, "remote I/O error") \
+ XX(ENOTTY, "inappropriate ioctl for device") \
+ XX(EFTYPE, "inappropriate file type or format") \
#define UV_HANDLE_TYPE_MAP(XX) \
XX(ASYNC, async) \
@@ -203,6 +206,7 @@ typedef enum {
/* Handle types. */
typedef struct uv_loop_s uv_loop_t;
typedef struct uv_handle_s uv_handle_t;
+typedef struct uv_dir_s uv_dir_t;
typedef struct uv_stream_s uv_stream_t;
typedef struct uv_tcp_s uv_tcp_t;
typedef struct uv_udp_s uv_udp_t;
@@ -235,6 +239,7 @@ typedef struct uv_cpu_info_s uv_cpu_info_t;
typedef struct uv_interface_address_s uv_interface_address_t;
typedef struct uv_dirent_s uv_dirent_t;
typedef struct uv_passwd_s uv_passwd_t;
+typedef struct uv_utsname_s uv_utsname_t;
typedef enum {
UV_LOOP_BLOCK_SIGNAL
@@ -371,7 +376,10 @@ typedef enum {
UV_EXTERN int uv_translate_sys_error(int sys_errno);
UV_EXTERN const char* uv_strerror(int err);
+UV_EXTERN char* uv_strerror_r(int err, char* buf, size_t buflen);
+
UV_EXTERN const char* uv_err_name(int err);
+UV_EXTERN char* uv_err_name_r(int err, char* buf, size_t buflen);
#define UV_REQ_FIELDS \
@@ -380,8 +388,7 @@ UV_EXTERN const char* uv_err_name(int err);
/* read-only */ \
uv_req_type type; \
/* private */ \
- void* active_queue[2]; \
- void* reserved[4]; \
+ void* reserved[6]; \
UV_REQ_PRIVATE_FIELDS \
/* Abstract base class of all requests. */
@@ -427,7 +434,17 @@ struct uv_handle_s {
};
UV_EXTERN size_t uv_handle_size(uv_handle_type type);
+UV_EXTERN uv_handle_type uv_handle_get_type(const uv_handle_t* handle);
+UV_EXTERN const char* uv_handle_type_name(uv_handle_type type);
+UV_EXTERN void* uv_handle_get_data(const uv_handle_t* handle);
+UV_EXTERN uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle);
+UV_EXTERN void uv_handle_set_data(uv_handle_t* handle, void* data);
+
UV_EXTERN size_t uv_req_size(uv_req_type type);
+UV_EXTERN void* uv_req_get_data(const uv_req_t* req);
+UV_EXTERN void uv_req_set_data(uv_req_t* req, void* data);
+UV_EXTERN uv_req_type uv_req_get_type(const uv_req_t* req);
+UV_EXTERN const char* uv_req_type_name(uv_req_type type);
UV_EXTERN int uv_is_active(const uv_handle_t* handle);
@@ -467,6 +484,8 @@ struct uv_stream_s {
UV_STREAM_FIELDS
};
+UV_EXTERN size_t uv_stream_get_write_queue_size(const uv_stream_t* stream);
+
UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb);
UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client);
@@ -494,7 +513,7 @@ UV_EXTERN int uv_try_write(uv_stream_t* handle,
struct uv_write_s {
UV_REQ_FIELDS
uv_write_cb cb;
- uv_stream_t* send_handle;
+ uv_stream_t* send_handle; /* TODO: make private and unix-only in v2.x. */
uv_stream_t* handle;
UV_WRITE_PRIVATE_FIELDS
};
@@ -616,7 +635,11 @@ UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock);
UV_EXTERN int uv_udp_bind(uv_udp_t* handle,
const struct sockaddr* addr,
unsigned int flags);
+UV_EXTERN int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr);
+UV_EXTERN int uv_udp_getpeername(const uv_udp_t* handle,
+ struct sockaddr* name,
+ int* namelen);
UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle,
struct sockaddr* name,
int* namelen);
@@ -644,6 +667,8 @@ UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle,
uv_alloc_cb alloc_cb,
uv_udp_recv_cb recv_cb);
UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle);
+UV_EXTERN size_t uv_udp_get_send_queue_size(const uv_udp_t* handle);
+UV_EXTERN size_t uv_udp_get_send_queue_count(const uv_udp_t* handle);
/*
@@ -712,6 +737,7 @@ UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle,
UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count);
UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle);
UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle);
+UV_EXTERN int uv_pipe_chmod(uv_pipe_t* handle, int flags);
struct uv_poll_s {
@@ -723,7 +749,8 @@ struct uv_poll_s {
enum uv_poll_event {
UV_READABLE = 1,
UV_WRITABLE = 2,
- UV_DISCONNECT = 4
+ UV_DISCONNECT = 4,
+ UV_PRIORITIZED = 8
};
UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd);
@@ -852,7 +879,13 @@ typedef enum {
* flags may be specified to create a duplex data stream.
*/
UV_READABLE_PIPE = 0x10,
- UV_WRITABLE_PIPE = 0x20
+ UV_WRITABLE_PIPE = 0x20,
+
+ /*
+ * Open the child pipe handle in overlapped mode on Windows.
+ * On Unix it is silently ignored.
+ */
+ UV_OVERLAPPED_PIPE = 0x40
} uv_stdio_flags;
typedef struct uv_stdio_container_s {
@@ -907,6 +940,19 @@ typedef struct uv_process_options_s {
*/
uv_uid_t uid;
uv_gid_t gid;
+ /*
+ Libuv can set the child process' CPU affinity mask. This happens when
+ `cpumask` is non-NULL. It must point to an array of char values
+ of length `cpumask_size`, whose value must be at least that returned by
+ uv_cpumask_size(). Each byte in the mask can be either zero (false)
+ or non-zero (true) to indicate whether the corresponding processor at
+ that index is included.
+
+ If enabled on an unsupported platform, uv_spawn() will fail with
+ UV_ENOTSUP.
+ */
+ char* cpumask;
+ size_t cpumask_size;
} uv_process_options_t;
/*
@@ -940,11 +986,22 @@ enum uv_process_flags {
*/
UV_PROCESS_DETACHED = (1 << 3),
/*
+ * Hide the subprocess window that would normally be created. This option is
+ * only meaningful on Windows systems. On Unix it is silently ignored.
+ */
+ UV_PROCESS_WINDOWS_HIDE = (1 << 4),
+ /*
* Hide the subprocess console window that would normally be created. This
* option is only meaningful on Windows systems. On Unix it is silently
* ignored.
*/
- UV_PROCESS_WINDOWS_HIDE = (1 << 4)
+ UV_PROCESS_WINDOWS_HIDE_CONSOLE = (1 << 5),
+ /*
+ * Hide the subprocess GUI window that would normally be created. This
+ * option is only meaningful on Windows systems. On Unix it is silently
+ * ignored.
+ */
+ UV_PROCESS_WINDOWS_HIDE_GUI = (1 << 6)
};
/*
@@ -962,6 +1019,7 @@ UV_EXTERN int uv_spawn(uv_loop_t* loop,
const uv_process_options_t* options);
UV_EXTERN int uv_process_kill(uv_process_t*, int signum);
UV_EXTERN int uv_kill(int pid, int signum);
+UV_EXTERN uv_pid_t uv_process_get_pid(const uv_process_t*);
/*
@@ -983,16 +1041,18 @@ UV_EXTERN int uv_queue_work(uv_loop_t* loop,
UV_EXTERN int uv_cancel(uv_req_t* req);
+struct uv_cpu_times_s {
+ uint64_t user;
+ uint64_t nice;
+ uint64_t sys;
+ uint64_t idle;
+ uint64_t irq;
+};
+
struct uv_cpu_info_s {
char* model;
int speed;
- struct uv_cpu_times_s {
- uint64_t user;
- uint64_t nice;
- uint64_t sys;
- uint64_t idle;
- uint64_t irq;
- } cpu_times;
+ struct uv_cpu_times_s cpu_times;
};
struct uv_interface_address_s {
@@ -1017,6 +1077,16 @@ struct uv_passwd_s {
char* homedir;
};
+struct uv_utsname_s {
+ char sysname[256];
+ char release[256];
+ char version[256];
+ char machine[256];
+ /* This struct does not contain the nodename and domainname fields present in
+ the utsname type. domainname is a GNU extension. Both fields are referred
+ to as meaningless in the docs. */
+};
+
typedef enum {
UV_DIRENT_UNKNOWN,
UV_DIRENT_FILE,
@@ -1038,6 +1108,8 @@ UV_EXTERN int uv_get_process_title(char* buffer, size_t size);
UV_EXTERN int uv_set_process_title(const char* title);
UV_EXTERN int uv_resident_set_memory(size_t* rss);
UV_EXTERN int uv_uptime(double* uptime);
+UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd);
+UV_EXTERN int uv_open_osfhandle(uv_os_fd_t os_fd);
typedef struct {
long tv_sec;
@@ -1045,6 +1117,11 @@ typedef struct {
} uv_timeval_t;
typedef struct {
+ int64_t tv_sec;
+ int32_t tv_usec;
+} uv_timeval64_t;
+
+typedef struct {
uv_timeval_t ru_utime; /* user CPU time used */
uv_timeval_t ru_stime; /* system CPU time used */
uint64_t ru_maxrss; /* maximum resident set size */
@@ -1069,9 +1146,22 @@ UV_EXTERN int uv_os_homedir(char* buffer, size_t* size);
UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size);
UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd);
UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd);
+UV_EXTERN uv_pid_t uv_os_getpid(void);
+UV_EXTERN uv_pid_t uv_os_getppid(void);
+
+#define UV_PRIORITY_LOW 19
+#define UV_PRIORITY_BELOW_NORMAL 10
+#define UV_PRIORITY_NORMAL 0
+#define UV_PRIORITY_ABOVE_NORMAL -7
+#define UV_PRIORITY_HIGH -14
+#define UV_PRIORITY_HIGHEST -20
+
+UV_EXTERN int uv_os_getpriority(uv_pid_t pid, int* priority);
+UV_EXTERN int uv_os_setpriority(uv_pid_t pid, int priority);
UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count);
UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count);
+UV_EXTERN int uv_cpumask_size(void);
UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses,
int* count);
@@ -1082,8 +1172,21 @@ UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size);
UV_EXTERN int uv_os_setenv(const char* name, const char* value);
UV_EXTERN int uv_os_unsetenv(const char* name);
+#ifdef MAXHOSTNAMELEN
+# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1)
+#else
+ /*
+ Fallback for the maximum hostname size, including the null terminator. The
+ Windows gethostname() documentation states that 256 bytes will always be
+ large enough to hold the null-terminated hostname.
+ */
+# define UV_MAXHOSTNAMESIZE 256
+#endif
+
UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size);
+UV_EXTERN int uv_os_uname(uv_utsname_t* buffer);
+
typedef enum {
UV_FS_UNKNOWN = -1,
@@ -1115,9 +1218,21 @@ typedef enum {
UV_FS_READLINK,
UV_FS_CHOWN,
UV_FS_FCHOWN,
- UV_FS_REALPATH
+ UV_FS_REALPATH,
+ UV_FS_COPYFILE,
+ UV_FS_LCHOWN,
+ UV_FS_OPENDIR,
+ UV_FS_READDIR,
+ UV_FS_CLOSEDIR
} uv_fs_type;
+struct uv_dir_s {
+ uv_dirent_t* dirents;
+ size_t nentries;
+ void* reserved[4];
+ UV_DIR_PRIVATE_FIELDS
+};
+
/* uv_fs_t is a subclass of uv_req_t. */
struct uv_fs_s {
UV_REQ_FIELDS
@@ -1131,6 +1246,12 @@ struct uv_fs_s {
UV_FS_PRIVATE_FIELDS
};
+UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*);
+UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*);
+UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*);
+UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*);
+UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*);
+
UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req);
UV_EXTERN int uv_fs_close(uv_loop_t* loop,
uv_fs_t* req,
@@ -1160,6 +1281,30 @@ UV_EXTERN int uv_fs_write(uv_loop_t* loop,
unsigned int nbufs,
int64_t offset,
uv_fs_cb cb);
+/*
+ * This flag can be used with uv_fs_copyfile() to return an error if the
+ * destination already exists.
+ */
+#define UV_FS_COPYFILE_EXCL 0x0001
+
+/*
+ * This flag can be used with uv_fs_copyfile() to attempt to create a reflink.
+ * If copy-on-write is not supported, a fallback copy mechanism is used.
+ */
+#define UV_FS_COPYFILE_FICLONE 0x0002
+
+/*
+ * This flag can be used with uv_fs_copyfile() to attempt to create a reflink.
+ * If copy-on-write is not supported, an error is returned.
+ */
+#define UV_FS_COPYFILE_FICLONE_FORCE 0x0004
+
+UV_EXTERN int uv_fs_copyfile(uv_loop_t* loop,
+ uv_fs_t* req,
+ const char* path,
+ const char* new_path,
+ int flags,
+ uv_fs_cb cb);
UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
@@ -1180,6 +1325,18 @@ UV_EXTERN int uv_fs_scandir(uv_loop_t* loop,
uv_fs_cb cb);
UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req,
uv_dirent_t* ent);
+UV_EXTERN int uv_fs_opendir(uv_loop_t* loop,
+ uv_fs_t* req,
+ const char* path,
+ uv_fs_cb cb);
+UV_EXTERN int uv_fs_readdir(uv_loop_t* loop,
+ uv_fs_t* req,
+ uv_dir_t* dir,
+ uv_fs_cb cb);
+UV_EXTERN int uv_fs_closedir(uv_loop_t* loop,
+ uv_fs_t* req,
+ uv_dir_t* dir,
+ uv_fs_cb cb);
UV_EXTERN int uv_fs_stat(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
@@ -1288,6 +1445,12 @@ UV_EXTERN int uv_fs_fchown(uv_loop_t* loop,
uv_uid_t uid,
uv_gid_t gid,
uv_fs_cb cb);
+UV_EXTERN int uv_fs_lchown(uv_loop_t* loop,
+ uv_fs_t* req,
+ const char* path,
+ uv_uid_t uid,
+ uv_gid_t gid,
+ uv_fs_cb cb);
enum uv_fs_event {
@@ -1393,6 +1556,21 @@ UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size
UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size);
UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst);
+#if defined(IF_NAMESIZE)
+# define UV_IF_NAMESIZE (IF_NAMESIZE + 1)
+#elif defined(IFNAMSIZ)
+# define UV_IF_NAMESIZE (IFNAMSIZ + 1)
+#else
+# define UV_IF_NAMESIZE (16 + 1)
+#endif
+
+UV_EXTERN int uv_if_indextoname(unsigned int ifindex,
+ char* buffer,
+ size_t* size);
+UV_EXTERN int uv_if_indextoiid(unsigned int ifindex,
+ char* buffer,
+ size_t* size);
+
UV_EXTERN int uv_exepath(char* buffer, size_t* size);
UV_EXTERN int uv_cwd(char* buffer, size_t* size);
@@ -1401,6 +1579,7 @@ UV_EXTERN int uv_chdir(const char* dir);
UV_EXTERN uint64_t uv_get_free_memory(void);
UV_EXTERN uint64_t uv_get_total_memory(void);
+UV_EXTERN uint64_t uv_get_constrained_memory(void);
UV_EXTERN uint64_t uv_hrtime(void);
@@ -1412,6 +1591,7 @@ UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr);
UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib);
UV_EXTERN int uv_mutex_init(uv_mutex_t* handle);
+UV_EXTERN int uv_mutex_init_recursive(uv_mutex_t* handle);
UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle);
UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle);
UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle);
@@ -1453,9 +1633,29 @@ UV_EXTERN void uv_key_delete(uv_key_t* key);
UV_EXTERN void* uv_key_get(uv_key_t* key);
UV_EXTERN void uv_key_set(uv_key_t* key, void* value);
+UV_EXTERN int uv_gettimeofday(uv_timeval64_t* tv);
+
typedef void (*uv_thread_cb)(void* arg);
UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg);
+
+typedef enum {
+ UV_THREAD_NO_FLAGS = 0x00,
+ UV_THREAD_HAS_STACK_SIZE = 0x01
+} uv_thread_create_flags;
+
+struct uv_thread_options_s {
+ unsigned int flags;
+ size_t stack_size;
+ /* More fields may be added at any time. */
+};
+
+typedef struct uv_thread_options_s uv_thread_options_t;
+
+UV_EXTERN int uv_thread_create_ex(uv_thread_t* tid,
+ const uv_thread_options_t* params,
+ uv_thread_cb entry,
+ void* arg);
UV_EXTERN uv_thread_t uv_thread_self(void);
UV_EXTERN int uv_thread_join(uv_thread_t *tid);
UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2);
@@ -1478,12 +1678,17 @@ struct uv_loop_s {
/* Loop reference counting. */
unsigned int active_handles;
void* handle_queue[2];
- void* active_reqs[2];
+ union {
+ void* unused[2];
+ unsigned int count;
+ } active_reqs;
/* Internal flag to signal loop stop. */
unsigned int stop_flag;
UV_LOOP_PRIVATE_FIELDS
};
+UV_EXTERN void* uv_loop_get_data(const uv_loop_t*);
+UV_EXTERN void uv_loop_set_data(uv_loop_t*, void* data);
/* Don't export the private CPP symbols. */
#undef UV_HANDLE_TYPE_PRIVATE
@@ -1504,6 +1709,7 @@ struct uv_loop_s {
#undef UV_SIGNAL_PRIVATE_FIELDS
#undef UV_LOOP_PRIVATE_FIELDS
#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS
+#undef UV__ERR
#ifdef __cplusplus
}
diff --git a/Utilities/cmlibuv/include/uv-aix.h b/Utilities/cmlibuv/include/uv/aix.h
index 7dc992fa6..7dc992fa6 100644
--- a/Utilities/cmlibuv/include/uv-aix.h
+++ b/Utilities/cmlibuv/include/uv/aix.h
diff --git a/Utilities/cmlibuv/include/android-ifaddrs.h b/Utilities/cmlibuv/include/uv/android-ifaddrs.h
index 9cd19fec1..9cd19fec1 100644
--- a/Utilities/cmlibuv/include/android-ifaddrs.h
+++ b/Utilities/cmlibuv/include/uv/android-ifaddrs.h
diff --git a/Utilities/cmlibuv/include/uv-bsd.h b/Utilities/cmlibuv/include/uv/bsd.h
index 2d72b3d77..2d72b3d77 100644
--- a/Utilities/cmlibuv/include/uv-bsd.h
+++ b/Utilities/cmlibuv/include/uv/bsd.h
diff --git a/Utilities/cmlibuv/include/uv-darwin.h b/Utilities/cmlibuv/include/uv/darwin.h
index d22641582..d22641582 100644
--- a/Utilities/cmlibuv/include/uv-darwin.h
+++ b/Utilities/cmlibuv/include/uv/darwin.h
diff --git a/Utilities/cmlibuv/include/uv/errno.h b/Utilities/cmlibuv/include/uv/errno.h
new file mode 100644
index 000000000..8eeb95de3
--- /dev/null
+++ b/Utilities/cmlibuv/include/uv/errno.h
@@ -0,0 +1,443 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef UV_ERRNO_H_
+#define UV_ERRNO_H_
+
+#include <errno.h>
+#if EDOM > 0
+# define UV__ERR(x) (-(x))
+#else
+# define UV__ERR(x) (x)
+#endif
+
+#define UV__EOF (-4095)
+#define UV__UNKNOWN (-4094)
+
+#define UV__EAI_ADDRFAMILY (-3000)
+#define UV__EAI_AGAIN (-3001)
+#define UV__EAI_BADFLAGS (-3002)
+#define UV__EAI_CANCELED (-3003)
+#define UV__EAI_FAIL (-3004)
+#define UV__EAI_FAMILY (-3005)
+#define UV__EAI_MEMORY (-3006)
+#define UV__EAI_NODATA (-3007)
+#define UV__EAI_NONAME (-3008)
+#define UV__EAI_OVERFLOW (-3009)
+#define UV__EAI_SERVICE (-3010)
+#define UV__EAI_SOCKTYPE (-3011)
+#define UV__EAI_BADHINTS (-3013)
+#define UV__EAI_PROTOCOL (-3014)
+
+/* Only map to the system errno on non-Windows platforms. It's apparently
+ * a fairly common practice for Windows programmers to redefine errno codes.
+ */
+#if defined(E2BIG) && !defined(_WIN32)
+# define UV__E2BIG UV__ERR(E2BIG)
+#else
+# define UV__E2BIG (-4093)
+#endif
+
+#if defined(EACCES) && !defined(_WIN32)
+# define UV__EACCES UV__ERR(EACCES)
+#else
+# define UV__EACCES (-4092)
+#endif
+
+#if defined(EADDRINUSE) && !defined(_WIN32)
+# define UV__EADDRINUSE UV__ERR(EADDRINUSE)
+#else
+# define UV__EADDRINUSE (-4091)
+#endif
+
+#if defined(EADDRNOTAVAIL) && !defined(_WIN32)
+# define UV__EADDRNOTAVAIL UV__ERR(EADDRNOTAVAIL)
+#else
+# define UV__EADDRNOTAVAIL (-4090)
+#endif
+
+#if defined(EAFNOSUPPORT) && !defined(_WIN32)
+# define UV__EAFNOSUPPORT UV__ERR(EAFNOSUPPORT)
+#else
+# define UV__EAFNOSUPPORT (-4089)
+#endif
+
+#if defined(EAGAIN) && !defined(_WIN32)
+# define UV__EAGAIN UV__ERR(EAGAIN)
+#else
+# define UV__EAGAIN (-4088)
+#endif
+
+#if defined(EALREADY) && !defined(_WIN32)
+# define UV__EALREADY UV__ERR(EALREADY)
+#else
+# define UV__EALREADY (-4084)
+#endif
+
+#if defined(EBADF) && !defined(_WIN32)
+# define UV__EBADF UV__ERR(EBADF)
+#else
+# define UV__EBADF (-4083)
+#endif
+
+#if defined(EBUSY) && !defined(_WIN32)
+# define UV__EBUSY UV__ERR(EBUSY)
+#else
+# define UV__EBUSY (-4082)
+#endif
+
+#if defined(ECANCELED) && !defined(_WIN32)
+# define UV__ECANCELED UV__ERR(ECANCELED)
+#else
+# define UV__ECANCELED (-4081)
+#endif
+
+#if defined(ECHARSET) && !defined(_WIN32)
+# define UV__ECHARSET UV__ERR(ECHARSET)
+#else
+# define UV__ECHARSET (-4080)
+#endif
+
+#if defined(ECONNABORTED) && !defined(_WIN32)
+# define UV__ECONNABORTED UV__ERR(ECONNABORTED)
+#else
+# define UV__ECONNABORTED (-4079)
+#endif
+
+#if defined(ECONNREFUSED) && !defined(_WIN32)
+# define UV__ECONNREFUSED UV__ERR(ECONNREFUSED)
+#else
+# define UV__ECONNREFUSED (-4078)
+#endif
+
+#if defined(ECONNRESET) && !defined(_WIN32)
+# define UV__ECONNRESET UV__ERR(ECONNRESET)
+#else
+# define UV__ECONNRESET (-4077)
+#endif
+
+#if defined(EDESTADDRREQ) && !defined(_WIN32)
+# define UV__EDESTADDRREQ UV__ERR(EDESTADDRREQ)
+#else
+# define UV__EDESTADDRREQ (-4076)
+#endif
+
+#if defined(EEXIST) && !defined(_WIN32)
+# define UV__EEXIST UV__ERR(EEXIST)
+#else
+# define UV__EEXIST (-4075)
+#endif
+
+#if defined(EFAULT) && !defined(_WIN32)
+# define UV__EFAULT UV__ERR(EFAULT)
+#else
+# define UV__EFAULT (-4074)
+#endif
+
+#if defined(EHOSTUNREACH) && !defined(_WIN32)
+# define UV__EHOSTUNREACH UV__ERR(EHOSTUNREACH)
+#else
+# define UV__EHOSTUNREACH (-4073)
+#endif
+
+#if defined(EINTR) && !defined(_WIN32)
+# define UV__EINTR UV__ERR(EINTR)
+#else
+# define UV__EINTR (-4072)
+#endif
+
+#if defined(EINVAL) && !defined(_WIN32)
+# define UV__EINVAL UV__ERR(EINVAL)
+#else
+# define UV__EINVAL (-4071)
+#endif
+
+#if defined(EIO) && !defined(_WIN32)
+# define UV__EIO UV__ERR(EIO)
+#else
+# define UV__EIO (-4070)
+#endif
+
+#if defined(EISCONN) && !defined(_WIN32)
+# define UV__EISCONN UV__ERR(EISCONN)
+#else
+# define UV__EISCONN (-4069)
+#endif
+
+#if defined(EISDIR) && !defined(_WIN32)
+# define UV__EISDIR UV__ERR(EISDIR)
+#else
+# define UV__EISDIR (-4068)
+#endif
+
+#if defined(ELOOP) && !defined(_WIN32)
+# define UV__ELOOP UV__ERR(ELOOP)
+#else
+# define UV__ELOOP (-4067)
+#endif
+
+#if defined(EMFILE) && !defined(_WIN32)
+# define UV__EMFILE UV__ERR(EMFILE)
+#else
+# define UV__EMFILE (-4066)
+#endif
+
+#if defined(EMSGSIZE) && !defined(_WIN32)
+# define UV__EMSGSIZE UV__ERR(EMSGSIZE)
+#else
+# define UV__EMSGSIZE (-4065)
+#endif
+
+#if defined(ENAMETOOLONG) && !defined(_WIN32)
+# define UV__ENAMETOOLONG UV__ERR(ENAMETOOLONG)
+#else
+# define UV__ENAMETOOLONG (-4064)
+#endif
+
+#if defined(ENETDOWN) && !defined(_WIN32)
+# define UV__ENETDOWN UV__ERR(ENETDOWN)
+#else
+# define UV__ENETDOWN (-4063)
+#endif
+
+#if defined(ENETUNREACH) && !defined(_WIN32)
+# define UV__ENETUNREACH UV__ERR(ENETUNREACH)
+#else
+# define UV__ENETUNREACH (-4062)
+#endif
+
+#if defined(ENFILE) && !defined(_WIN32)
+# define UV__ENFILE UV__ERR(ENFILE)
+#else
+# define UV__ENFILE (-4061)
+#endif
+
+#if defined(ENOBUFS) && !defined(_WIN32)
+# define UV__ENOBUFS UV__ERR(ENOBUFS)
+#else
+# define UV__ENOBUFS (-4060)
+#endif
+
+#if defined(ENODEV) && !defined(_WIN32)
+# define UV__ENODEV UV__ERR(ENODEV)
+#else
+# define UV__ENODEV (-4059)
+#endif
+
+#if defined(ENOENT) && !defined(_WIN32)
+# define UV__ENOENT UV__ERR(ENOENT)
+#else
+# define UV__ENOENT (-4058)
+#endif
+
+#if defined(ENOMEM) && !defined(_WIN32)
+# define UV__ENOMEM UV__ERR(ENOMEM)
+#else
+# define UV__ENOMEM (-4057)
+#endif
+
+#if defined(ENONET) && !defined(_WIN32)
+# define UV__ENONET UV__ERR(ENONET)
+#else
+# define UV__ENONET (-4056)
+#endif
+
+#if defined(ENOSPC) && !defined(_WIN32)
+# define UV__ENOSPC UV__ERR(ENOSPC)
+#else
+# define UV__ENOSPC (-4055)
+#endif
+
+#if defined(ENOSYS) && !defined(_WIN32)
+# define UV__ENOSYS UV__ERR(ENOSYS)
+#else
+# define UV__ENOSYS (-4054)
+#endif
+
+#if defined(ENOTCONN) && !defined(_WIN32)
+# define UV__ENOTCONN UV__ERR(ENOTCONN)
+#else
+# define UV__ENOTCONN (-4053)
+#endif
+
+#if defined(ENOTDIR) && !defined(_WIN32)
+# define UV__ENOTDIR UV__ERR(ENOTDIR)
+#else
+# define UV__ENOTDIR (-4052)
+#endif
+
+#if defined(ENOTEMPTY) && !defined(_WIN32)
+# define UV__ENOTEMPTY UV__ERR(ENOTEMPTY)
+#else
+# define UV__ENOTEMPTY (-4051)
+#endif
+
+#if defined(ENOTSOCK) && !defined(_WIN32)
+# define UV__ENOTSOCK UV__ERR(ENOTSOCK)
+#else
+# define UV__ENOTSOCK (-4050)
+#endif
+
+#if defined(ENOTSUP) && !defined(_WIN32)
+# define UV__ENOTSUP UV__ERR(ENOTSUP)
+#else
+# define UV__ENOTSUP (-4049)
+#endif
+
+#if defined(EPERM) && !defined(_WIN32)
+# define UV__EPERM UV__ERR(EPERM)
+#else
+# define UV__EPERM (-4048)
+#endif
+
+#if defined(EPIPE) && !defined(_WIN32)
+# define UV__EPIPE UV__ERR(EPIPE)
+#else
+# define UV__EPIPE (-4047)
+#endif
+
+#if defined(EPROTO) && !defined(_WIN32)
+# define UV__EPROTO UV__ERR(EPROTO)
+#else
+# define UV__EPROTO UV__ERR(4046)
+#endif
+
+#if defined(EPROTONOSUPPORT) && !defined(_WIN32)
+# define UV__EPROTONOSUPPORT UV__ERR(EPROTONOSUPPORT)
+#else
+# define UV__EPROTONOSUPPORT (-4045)
+#endif
+
+#if defined(EPROTOTYPE) && !defined(_WIN32)
+# define UV__EPROTOTYPE UV__ERR(EPROTOTYPE)
+#else
+# define UV__EPROTOTYPE (-4044)
+#endif
+
+#if defined(EROFS) && !defined(_WIN32)
+# define UV__EROFS UV__ERR(EROFS)
+#else
+# define UV__EROFS (-4043)
+#endif
+
+#if defined(ESHUTDOWN) && !defined(_WIN32)
+# define UV__ESHUTDOWN UV__ERR(ESHUTDOWN)
+#else
+# define UV__ESHUTDOWN (-4042)
+#endif
+
+#if defined(ESPIPE) && !defined(_WIN32)
+# define UV__ESPIPE UV__ERR(ESPIPE)
+#else
+# define UV__ESPIPE (-4041)
+#endif
+
+#if defined(ESRCH) && !defined(_WIN32)
+# define UV__ESRCH UV__ERR(ESRCH)
+#else
+# define UV__ESRCH (-4040)
+#endif
+
+#if defined(ETIMEDOUT) && !defined(_WIN32)
+# define UV__ETIMEDOUT UV__ERR(ETIMEDOUT)
+#else
+# define UV__ETIMEDOUT (-4039)
+#endif
+
+#if defined(ETXTBSY) && !defined(_WIN32)
+# define UV__ETXTBSY UV__ERR(ETXTBSY)
+#else
+# define UV__ETXTBSY (-4038)
+#endif
+
+#if defined(EXDEV) && !defined(_WIN32)
+# define UV__EXDEV UV__ERR(EXDEV)
+#else
+# define UV__EXDEV (-4037)
+#endif
+
+#if defined(EFBIG) && !defined(_WIN32)
+# define UV__EFBIG UV__ERR(EFBIG)
+#else
+# define UV__EFBIG (-4036)
+#endif
+
+#if defined(ENOPROTOOPT) && !defined(_WIN32)
+# define UV__ENOPROTOOPT UV__ERR(ENOPROTOOPT)
+#else
+# define UV__ENOPROTOOPT (-4035)
+#endif
+
+#if defined(ERANGE) && !defined(_WIN32)
+# define UV__ERANGE UV__ERR(ERANGE)
+#else
+# define UV__ERANGE (-4034)
+#endif
+
+#if defined(ENXIO) && !defined(_WIN32)
+# define UV__ENXIO UV__ERR(ENXIO)
+#else
+# define UV__ENXIO (-4033)
+#endif
+
+#if defined(EMLINK) && !defined(_WIN32)
+# define UV__EMLINK UV__ERR(EMLINK)
+#else
+# define UV__EMLINK (-4032)
+#endif
+
+/* EHOSTDOWN is not visible on BSD-like systems when _POSIX_C_SOURCE is
+ * defined. Fortunately, its value is always 64 so it's possible albeit
+ * icky to hard-code it.
+ */
+#if defined(EHOSTDOWN) && !defined(_WIN32)
+# define UV__EHOSTDOWN UV__ERR(EHOSTDOWN)
+#elif defined(__APPLE__) || \
+ defined(__DragonFly__) || \
+ defined(__FreeBSD__) || \
+ defined(__FreeBSD_kernel__) || \
+ defined(__NetBSD__) || \
+ defined(__OpenBSD__)
+# define UV__EHOSTDOWN (-64)
+#else
+# define UV__EHOSTDOWN (-4031)
+#endif
+
+#if defined(EREMOTEIO) && !defined(_WIN32)
+# define UV__EREMOTEIO UV__ERR(EREMOTEIO)
+#else
+# define UV__EREMOTEIO (-4030)
+#endif
+
+#if defined(ENOTTY) && !defined(_WIN32)
+# define UV__ENOTTY UV__ERR(ENOTTY)
+#else
+# define UV__ENOTTY (-4029)
+#endif
+
+#if defined(EFTYPE) && !defined(_WIN32)
+# define UV__EFTYPE UV__ERR(EFTYPE)
+#else
+# define UV__EFTYPE (-4028)
+#endif
+
+
+#endif /* UV_ERRNO_H_ */
diff --git a/Utilities/cmlibuv/include/uv-linux.h b/Utilities/cmlibuv/include/uv/linux.h
index 9b38405a1..9b38405a1 100644
--- a/Utilities/cmlibuv/include/uv-linux.h
+++ b/Utilities/cmlibuv/include/uv/linux.h
diff --git a/Utilities/cmlibuv/include/uv/os390.h b/Utilities/cmlibuv/include/uv/os390.h
new file mode 100644
index 000000000..0267d74cb
--- /dev/null
+++ b/Utilities/cmlibuv/include/uv/os390.h
@@ -0,0 +1,33 @@
+/* Copyright libuv project contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef UV_MVS_H
+#define UV_MVS_H
+
+#define UV_PLATFORM_SEM_T long
+
+#define UV_PLATFORM_LOOP_FIELDS \
+ void* ep; \
+
+#define UV_PLATFORM_FS_EVENT_FIELDS \
+ char rfis_rftok[8]; \
+
+#endif /* UV_MVS_H */
diff --git a/Utilities/cmlibuv/include/uv-posix.h b/Utilities/cmlibuv/include/uv/posix.h
index 9a96634db..9a96634db 100644
--- a/Utilities/cmlibuv/include/uv-posix.h
+++ b/Utilities/cmlibuv/include/uv/posix.h
diff --git a/Utilities/cmlibuv/include/stdint-msvc2008.h b/Utilities/cmlibuv/include/uv/stdint-msvc2008.h
index d02608a59..d02608a59 100644
--- a/Utilities/cmlibuv/include/stdint-msvc2008.h
+++ b/Utilities/cmlibuv/include/uv/stdint-msvc2008.h
diff --git a/Utilities/cmlibuv/include/uv-sunos.h b/Utilities/cmlibuv/include/uv/sunos.h
index 042166424..042166424 100644
--- a/Utilities/cmlibuv/include/uv-sunos.h
+++ b/Utilities/cmlibuv/include/uv/sunos.h
diff --git a/Utilities/cmlibuv/include/uv-threadpool.h b/Utilities/cmlibuv/include/uv/threadpool.h
index 9708ebdd5..9708ebdd5 100644
--- a/Utilities/cmlibuv/include/uv-threadpool.h
+++ b/Utilities/cmlibuv/include/uv/threadpool.h
diff --git a/Utilities/cmlibuv/include/tree.h b/Utilities/cmlibuv/include/uv/tree.h
index f936416e3..f936416e3 100644
--- a/Utilities/cmlibuv/include/tree.h
+++ b/Utilities/cmlibuv/include/uv/tree.h
diff --git a/Utilities/cmlibuv/include/uv/unix.h b/Utilities/cmlibuv/include/uv/unix.h
new file mode 100644
index 000000000..4e261081b
--- /dev/null
+++ b/Utilities/cmlibuv/include/uv/unix.h
@@ -0,0 +1,506 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef UV_UNIX_H
+#define UV_UNIX_H
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <netdb.h> /* MAXHOSTNAMELEN on Solaris */
+
+#include <termios.h>
+#include <pwd.h>
+
+#if !defined(__MVS__)
+#include <semaphore.h>
+#include <sys/param.h> /* MAXHOSTNAMELEN on Linux and the BSDs */
+#endif
+#include <pthread.h>
+#include <signal.h>
+
+#include "threadpool.h"
+
+#ifdef CMAKE_BOOTSTRAP
+# include "posix.h"
+#elif defined(__linux__)
+# include "linux.h"
+#elif defined (__MVS__)
+# include "os390.h"
+#elif defined(_AIX)
+# include "aix.h"
+#elif defined(__sun)
+# include "sunos.h"
+#elif defined(__hpux)
+# include "posix.h"
+#elif defined(__APPLE__)
+# include "darwin.h"
+#elif defined(__DragonFly__) || \
+ defined(__FreeBSD__) || \
+ defined(__FreeBSD_kernel__) || \
+ defined(__OpenBSD__) || \
+ defined(__NetBSD__)
+# include "bsd.h"
+#elif defined(__PASE__) || \
+ defined(__CYGWIN__) || \
+ defined(__MSYS__) || \
+ defined(__GNU__)
+# include "posix.h"
+#elif defined(__HAIKU__)
+# include "posix.h"
+#endif
+
+#ifndef NI_MAXHOST
+# define NI_MAXHOST 1025
+#endif
+
+#ifndef NI_MAXSERV
+# define NI_MAXSERV 32
+#endif
+
+#ifndef UV_IO_PRIVATE_PLATFORM_FIELDS
+# define UV_IO_PRIVATE_PLATFORM_FIELDS /* empty */
+#endif
+
+struct uv__io_s;
+struct uv_loop_s;
+
+typedef void (*uv__io_cb)(struct uv_loop_s* loop,
+ struct uv__io_s* w,
+ unsigned int events);
+typedef struct uv__io_s uv__io_t;
+
+struct uv__io_s {
+ uv__io_cb cb;
+ void* pending_queue[2];
+ void* watcher_queue[2];
+ unsigned int pevents; /* Pending event mask i.e. mask at next tick. */
+ unsigned int events; /* Current event mask. */
+ int fd;
+ UV_IO_PRIVATE_PLATFORM_FIELDS
+};
+
+#ifndef UV_PLATFORM_SEM_T
+# define UV_PLATFORM_SEM_T sem_t
+#endif
+
+#ifndef UV_PLATFORM_LOOP_FIELDS
+# define UV_PLATFORM_LOOP_FIELDS /* empty */
+#endif
+
+#ifndef UV_PLATFORM_FS_EVENT_FIELDS
+# define UV_PLATFORM_FS_EVENT_FIELDS /* empty */
+#endif
+
+#ifndef UV_STREAM_PRIVATE_PLATFORM_FIELDS
+# define UV_STREAM_PRIVATE_PLATFORM_FIELDS /* empty */
+#endif
+
+/* Note: May be cast to struct iovec. See writev(2). */
+typedef struct uv_buf_t {
+ char* base;
+ size_t len;
+} uv_buf_t;
+
+typedef int uv_file;
+typedef int uv_os_sock_t;
+typedef int uv_os_fd_t;
+typedef pid_t uv_pid_t;
+
+#ifdef CMAKE_BOOTSTRAP
+#define UV_ONCE_INIT 0
+typedef int uv_once_t;
+typedef int uv_thread_t;
+typedef int uv_mutex_t;
+typedef int uv_rwlock_t;
+typedef int uv_sem_t;
+typedef int uv_cond_t;
+typedef int uv_key_t;
+typedef int uv_barrier_t;
+#else
+#define UV_ONCE_INIT PTHREAD_ONCE_INIT
+
+typedef pthread_once_t uv_once_t;
+typedef pthread_t uv_thread_t;
+typedef pthread_mutex_t uv_mutex_t;
+typedef pthread_rwlock_t uv_rwlock_t;
+typedef UV_PLATFORM_SEM_T uv_sem_t;
+typedef pthread_cond_t uv_cond_t;
+typedef pthread_key_t uv_key_t;
+
+/* Note: guard clauses should match uv_barrier_init's in src/unix/thread.c. */
+#if defined(_AIX) || \
+ defined(__OpenBSD__) || \
+ !defined(PTHREAD_BARRIER_SERIAL_THREAD)
+/* TODO(bnoordhuis) Merge into uv_barrier_t in v2. */
+struct _uv_barrier {
+ uv_mutex_t mutex;
+ uv_cond_t cond;
+ unsigned threshold;
+ unsigned in;
+ unsigned out;
+};
+
+typedef struct {
+ struct _uv_barrier* b;
+# if defined(PTHREAD_BARRIER_SERIAL_THREAD)
+ /* TODO(bnoordhuis) Remove padding in v2. */
+ char pad[sizeof(pthread_barrier_t) - sizeof(struct _uv_barrier*)];
+# endif
+} uv_barrier_t;
+#else
+typedef pthread_barrier_t uv_barrier_t;
+#endif
+
+#endif
+
+/* Platform-specific definitions for uv_spawn support. */
+typedef gid_t uv_gid_t;
+typedef uid_t uv_uid_t;
+
+typedef struct dirent uv__dirent_t;
+
+#define UV_DIR_PRIVATE_FIELDS \
+ DIR* dir;
+
+#if defined(DT_UNKNOWN)
+# define HAVE_DIRENT_TYPES
+# if defined(DT_REG)
+# define UV__DT_FILE DT_REG
+# else
+# define UV__DT_FILE -1
+# endif
+# if defined(DT_DIR)
+# define UV__DT_DIR DT_DIR
+# else
+# define UV__DT_DIR -2
+# endif
+# if defined(DT_LNK)
+# define UV__DT_LINK DT_LNK
+# else
+# define UV__DT_LINK -3
+# endif
+# if defined(DT_FIFO)
+# define UV__DT_FIFO DT_FIFO
+# else
+# define UV__DT_FIFO -4
+# endif
+# if defined(DT_SOCK)
+# define UV__DT_SOCKET DT_SOCK
+# else
+# define UV__DT_SOCKET -5
+# endif
+# if defined(DT_CHR)
+# define UV__DT_CHAR DT_CHR
+# else
+# define UV__DT_CHAR -6
+# endif
+# if defined(DT_BLK)
+# define UV__DT_BLOCK DT_BLK
+# else
+# define UV__DT_BLOCK -7
+# endif
+#endif
+
+/* Platform-specific definitions for uv_dlopen support. */
+#define UV_DYNAMIC /* empty */
+
+typedef struct {
+ void* handle;
+ char* errmsg;
+} uv_lib_t;
+
+#define UV_LOOP_PRIVATE_FIELDS \
+ unsigned long flags; \
+ int backend_fd; \
+ void* pending_queue[2]; \
+ void* watcher_queue[2]; \
+ uv__io_t** watchers; \
+ unsigned int nwatchers; \
+ unsigned int nfds; \
+ void* wq[2]; \
+ uv_mutex_t wq_mutex; \
+ uv_async_t wq_async; \
+ uv_rwlock_t cloexec_lock; \
+ uv_handle_t* closing_handles; \
+ void* process_handles[2]; \
+ void* prepare_handles[2]; \
+ void* check_handles[2]; \
+ void* idle_handles[2]; \
+ void* async_handles[2]; \
+ void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \
+ uv__io_t async_io_watcher; \
+ int async_wfd; \
+ struct { \
+ void* min; \
+ unsigned int nelts; \
+ } timer_heap; \
+ uint64_t timer_counter; \
+ uint64_t time; \
+ int signal_pipefd[2]; \
+ uv__io_t signal_io_watcher; \
+ uv_signal_t child_watcher; \
+ int emfile_fd; \
+ UV_PLATFORM_LOOP_FIELDS \
+
+#define UV_REQ_TYPE_PRIVATE /* empty */
+
+#define UV_REQ_PRIVATE_FIELDS /* empty */
+
+#define UV_PRIVATE_REQ_TYPES /* empty */
+
+#define UV_WRITE_PRIVATE_FIELDS \
+ void* queue[2]; \
+ unsigned int write_index; \
+ uv_buf_t* bufs; \
+ unsigned int nbufs; \
+ int error; \
+ uv_buf_t bufsml[4]; \
+
+#define UV_CONNECT_PRIVATE_FIELDS \
+ void* queue[2]; \
+
+#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */
+
+#define UV_UDP_SEND_PRIVATE_FIELDS \
+ void* queue[2]; \
+ struct sockaddr_storage addr; \
+ unsigned int nbufs; \
+ uv_buf_t* bufs; \
+ ssize_t status; \
+ uv_udp_send_cb send_cb; \
+ uv_buf_t bufsml[4]; \
+
+#define UV_HANDLE_PRIVATE_FIELDS \
+ uv_handle_t* next_closing; \
+ unsigned int flags; \
+
+#define UV_STREAM_PRIVATE_FIELDS \
+ uv_connect_t *connect_req; \
+ uv_shutdown_t *shutdown_req; \
+ uv__io_t io_watcher; \
+ void* write_queue[2]; \
+ void* write_completed_queue[2]; \
+ uv_connection_cb connection_cb; \
+ int delayed_error; \
+ int accepted_fd; \
+ void* queued_fds; \
+ UV_STREAM_PRIVATE_PLATFORM_FIELDS \
+
+#define UV_TCP_PRIVATE_FIELDS /* empty */
+
+#define UV_UDP_PRIVATE_FIELDS \
+ uv_alloc_cb alloc_cb; \
+ uv_udp_recv_cb recv_cb; \
+ uv__io_t io_watcher; \
+ void* write_queue[2]; \
+ void* write_completed_queue[2]; \
+
+#define UV_PIPE_PRIVATE_FIELDS \
+ const char* pipe_fname; /* strdup'ed */
+
+#define UV_POLL_PRIVATE_FIELDS \
+ uv__io_t io_watcher;
+
+#define UV_PREPARE_PRIVATE_FIELDS \
+ uv_prepare_cb prepare_cb; \
+ void* queue[2]; \
+
+#define UV_CHECK_PRIVATE_FIELDS \
+ uv_check_cb check_cb; \
+ void* queue[2]; \
+
+#define UV_IDLE_PRIVATE_FIELDS \
+ uv_idle_cb idle_cb; \
+ void* queue[2]; \
+
+#define UV_ASYNC_PRIVATE_FIELDS \
+ uv_async_cb async_cb; \
+ void* queue[2]; \
+ int pending; \
+
+#define UV_TIMER_PRIVATE_FIELDS \
+ uv_timer_cb timer_cb; \
+ void* heap_node[3]; \
+ uint64_t timeout; \
+ uint64_t repeat; \
+ uint64_t start_id;
+
+#define UV_GETADDRINFO_PRIVATE_FIELDS \
+ struct uv__work work_req; \
+ uv_getaddrinfo_cb cb; \
+ struct addrinfo* hints; \
+ char* hostname; \
+ char* service; \
+ struct addrinfo* addrinfo; \
+ int retcode;
+
+#define UV_GETNAMEINFO_PRIVATE_FIELDS \
+ struct uv__work work_req; \
+ uv_getnameinfo_cb getnameinfo_cb; \
+ struct sockaddr_storage storage; \
+ int flags; \
+ char host[NI_MAXHOST]; \
+ char service[NI_MAXSERV]; \
+ int retcode;
+
+#define UV_PROCESS_PRIVATE_FIELDS \
+ void* queue[2]; \
+ int status; \
+
+#define UV_FS_PRIVATE_FIELDS \
+ const char *new_path; \
+ uv_file file; \
+ int flags; \
+ mode_t mode; \
+ unsigned int nbufs; \
+ uv_buf_t* bufs; \
+ off_t off; \
+ uv_uid_t uid; \
+ uv_gid_t gid; \
+ double atime; \
+ double mtime; \
+ struct uv__work work_req; \
+ uv_buf_t bufsml[4]; \
+
+#define UV_WORK_PRIVATE_FIELDS \
+ struct uv__work work_req;
+
+#define UV_TTY_PRIVATE_FIELDS \
+ struct termios orig_termios; \
+ int mode;
+
+#define UV_SIGNAL_PRIVATE_FIELDS \
+ /* RB_ENTRY(uv_signal_s) tree_entry; */ \
+ struct { \
+ struct uv_signal_s* rbe_left; \
+ struct uv_signal_s* rbe_right; \
+ struct uv_signal_s* rbe_parent; \
+ int rbe_color; \
+ } tree_entry; \
+ /* Use two counters here so we don have to fiddle with atomics. */ \
+ unsigned int caught_signals; \
+ unsigned int dispatched_signals;
+
+#define UV_FS_EVENT_PRIVATE_FIELDS \
+ uv_fs_event_cb cb; \
+ UV_PLATFORM_FS_EVENT_FIELDS \
+
+/* fs open() flags supported on this platform: */
+#if defined(O_APPEND)
+# define UV_FS_O_APPEND O_APPEND
+#else
+# define UV_FS_O_APPEND 0
+#endif
+#if defined(O_CREAT)
+# define UV_FS_O_CREAT O_CREAT
+#else
+# define UV_FS_O_CREAT 0
+#endif
+#if defined(O_DIRECT)
+# define UV_FS_O_DIRECT O_DIRECT
+#else
+# define UV_FS_O_DIRECT 0
+#endif
+#if defined(O_DIRECTORY)
+# define UV_FS_O_DIRECTORY O_DIRECTORY
+#else
+# define UV_FS_O_DIRECTORY 0
+#endif
+#if defined(O_DSYNC)
+# define UV_FS_O_DSYNC O_DSYNC
+#else
+# define UV_FS_O_DSYNC 0
+#endif
+#if defined(O_EXCL)
+# define UV_FS_O_EXCL O_EXCL
+#else
+# define UV_FS_O_EXCL 0
+#endif
+#if defined(O_EXLOCK)
+# define UV_FS_O_EXLOCK O_EXLOCK
+#else
+# define UV_FS_O_EXLOCK 0
+#endif
+#if defined(O_NOATIME)
+# define UV_FS_O_NOATIME O_NOATIME
+#else
+# define UV_FS_O_NOATIME 0
+#endif
+#if defined(O_NOCTTY)
+# define UV_FS_O_NOCTTY O_NOCTTY
+#else
+# define UV_FS_O_NOCTTY 0
+#endif
+#if defined(O_NOFOLLOW)
+# define UV_FS_O_NOFOLLOW O_NOFOLLOW
+#else
+# define UV_FS_O_NOFOLLOW 0
+#endif
+#if defined(O_NONBLOCK)
+# define UV_FS_O_NONBLOCK O_NONBLOCK
+#else
+# define UV_FS_O_NONBLOCK 0
+#endif
+#if defined(O_RDONLY)
+# define UV_FS_O_RDONLY O_RDONLY
+#else
+# define UV_FS_O_RDONLY 0
+#endif
+#if defined(O_RDWR)
+# define UV_FS_O_RDWR O_RDWR
+#else
+# define UV_FS_O_RDWR 0
+#endif
+#if defined(O_SYMLINK)
+# define UV_FS_O_SYMLINK O_SYMLINK
+#else
+# define UV_FS_O_SYMLINK 0
+#endif
+#if defined(O_SYNC)
+# define UV_FS_O_SYNC O_SYNC
+#else
+# define UV_FS_O_SYNC 0
+#endif
+#if defined(O_TRUNC)
+# define UV_FS_O_TRUNC O_TRUNC
+#else
+# define UV_FS_O_TRUNC 0
+#endif
+#if defined(O_WRONLY)
+# define UV_FS_O_WRONLY O_WRONLY
+#else
+# define UV_FS_O_WRONLY 0
+#endif
+
+/* fs open() flags supported on other platforms: */
+#define UV_FS_O_RANDOM 0
+#define UV_FS_O_SHORT_LIVED 0
+#define UV_FS_O_SEQUENTIAL 0
+#define UV_FS_O_TEMPORARY 0
+
+#endif /* UV_UNIX_H */
diff --git a/Utilities/cmlibuv/include/uv/version.h b/Utilities/cmlibuv/include/uv/version.h
new file mode 100644
index 000000000..97f0bc245
--- /dev/null
+++ b/Utilities/cmlibuv/include/uv/version.h
@@ -0,0 +1,43 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef UV_VERSION_H
+#define UV_VERSION_H
+
+ /*
+ * Versions with the same major number are ABI stable. API is allowed to
+ * evolve between minor releases, but only in a backwards compatible way.
+ * Make sure you update the -soname directives in configure.ac
+ * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but
+ * not UV_VERSION_PATCH.)
+ */
+
+#define UV_VERSION_MAJOR 1
+#define UV_VERSION_MINOR 29
+#define UV_VERSION_PATCH 2
+#define UV_VERSION_IS_RELEASE 0
+#define UV_VERSION_SUFFIX "dev"
+
+#define UV_VERSION_HEX ((UV_VERSION_MAJOR << 16) | \
+ (UV_VERSION_MINOR << 8) | \
+ (UV_VERSION_PATCH))
+
+#endif /* UV_VERSION_H */
diff --git a/Utilities/cmlibuv/include/uv/win.h b/Utilities/cmlibuv/include/uv/win.h
new file mode 100644
index 000000000..7f77cc238
--- /dev/null
+++ b/Utilities/cmlibuv/include/uv/win.h
@@ -0,0 +1,701 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef _WIN32_WINNT
+# define _WIN32_WINNT 0x0600
+#endif
+
+#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
+typedef intptr_t ssize_t;
+# define SSIZE_MAX INTPTR_MAX
+# define _SSIZE_T_
+# define _SSIZE_T_DEFINED
+#endif
+
+#include <winsock2.h>
+
+#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
+typedef struct pollfd {
+ SOCKET fd;
+ short events;
+ short revents;
+} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
+#endif
+
+#ifndef LOCALE_INVARIANT
+# define LOCALE_INVARIANT 0x007f
+#endif
+
+#include <mswsock.h>
+#include <ws2tcpip.h>
+#include <windows.h>
+
+#include <process.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#if defined(_MSC_VER) && _MSC_VER < 1600
+# include "stdint-msvc2008.h"
+#else
+# include <stdint.h>
+#endif
+
+#include "tree.h"
+#include "threadpool.h"
+
+#define MAX_PIPENAME_LEN 256
+
+#ifndef S_IFLNK
+# define S_IFLNK 0xA000
+#endif
+
+/* Additional signals supported by uv_signal and or uv_kill. The CRT defines
+ * the following signals already:
+ *
+ * #define SIGINT 2
+ * #define SIGILL 4
+ * #define SIGABRT_COMPAT 6
+ * #define SIGFPE 8
+ * #define SIGSEGV 11
+ * #define SIGTERM 15
+ * #define SIGBREAK 21
+ * #define SIGABRT 22
+ *
+ * The additional signals have values that are common on other Unix
+ * variants (Linux and Darwin)
+ */
+#define SIGHUP 1
+#define SIGKILL 9
+#define SIGWINCH 28
+
+/* Redefine NSIG to take SIGWINCH into consideration */
+#if defined(NSIG) && NSIG <= SIGWINCH
+# undef NSIG
+#endif
+#ifndef NSIG
+# define NSIG SIGWINCH + 1
+#endif
+
+/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many unix-like
+ * platforms. However MinGW doesn't define it, so we do. */
+#ifndef SIGABRT_COMPAT
+# define SIGABRT_COMPAT 6
+#endif
+
+/*
+ * Guids and typedefs for winsock extension functions
+ * Mingw32 doesn't have these :-(
+ */
+#ifndef WSAID_ACCEPTEX
+# define WSAID_ACCEPTEX \
+ {0xb5367df1, 0xcbac, 0x11cf, \
+ {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
+#endif
+
+#ifndef WSAID_CONNECTEX
+# define WSAID_CONNECTEX \
+ {0x25a207b9, 0xddf3, 0x4660, \
+ {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}}
+#endif
+
+#ifndef WSAID_GETACCEPTEXSOCKADDRS
+# define WSAID_GETACCEPTEXSOCKADDRS \
+ {0xb5367df2, 0xcbac, 0x11cf, \
+ {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
+#endif
+
+#ifndef WSAID_DISCONNECTEX
+# define WSAID_DISCONNECTEX \
+ {0x7fda2e11, 0x8630, 0x436f, \
+ {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}
+#endif
+
+#ifndef WSAID_TRANSMITFILE
+# define WSAID_TRANSMITFILE \
+ {0xb5367df0, 0xcbac, 0x11cf, \
+ {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}}
+#endif
+
+#if (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)) \
+ || (defined(_MSC_VER) && _MSC_VER < 1500)
+ typedef BOOL (PASCAL *LPFN_ACCEPTEX)
+ (SOCKET sListenSocket,
+ SOCKET sAcceptSocket,
+ PVOID lpOutputBuffer,
+ DWORD dwReceiveDataLength,
+ DWORD dwLocalAddressLength,
+ DWORD dwRemoteAddressLength,
+ LPDWORD lpdwBytesReceived,
+ LPOVERLAPPED lpOverlapped);
+
+ typedef BOOL (PASCAL *LPFN_CONNECTEX)
+ (SOCKET s,
+ const struct sockaddr* name,
+ int namelen,
+ PVOID lpSendBuffer,
+ DWORD dwSendDataLength,
+ LPDWORD lpdwBytesSent,
+ LPOVERLAPPED lpOverlapped);
+
+ typedef void (PASCAL *LPFN_GETACCEPTEXSOCKADDRS)
+ (PVOID lpOutputBuffer,
+ DWORD dwReceiveDataLength,
+ DWORD dwLocalAddressLength,
+ DWORD dwRemoteAddressLength,
+ LPSOCKADDR* LocalSockaddr,
+ LPINT LocalSockaddrLength,
+ LPSOCKADDR* RemoteSockaddr,
+ LPINT RemoteSockaddrLength);
+
+ typedef BOOL (PASCAL *LPFN_DISCONNECTEX)
+ (SOCKET hSocket,
+ LPOVERLAPPED lpOverlapped,
+ DWORD dwFlags,
+ DWORD reserved);
+
+ typedef BOOL (PASCAL *LPFN_TRANSMITFILE)
+ (SOCKET hSocket,
+ HANDLE hFile,
+ DWORD nNumberOfBytesToWrite,
+ DWORD nNumberOfBytesPerSend,
+ LPOVERLAPPED lpOverlapped,
+ LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers,
+ DWORD dwFlags);
+
+ typedef PVOID RTL_SRWLOCK;
+ typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK;
+#endif
+
+typedef int (WSAAPI* LPFN_WSARECV)
+ (SOCKET socket,
+ LPWSABUF buffers,
+ DWORD buffer_count,
+ LPDWORD bytes,
+ LPDWORD flags,
+ LPWSAOVERLAPPED overlapped,
+ LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
+
+typedef int (WSAAPI* LPFN_WSARECVFROM)
+ (SOCKET socket,
+ LPWSABUF buffers,
+ DWORD buffer_count,
+ LPDWORD bytes,
+ LPDWORD flags,
+ struct sockaddr* addr,
+ LPINT addr_len,
+ LPWSAOVERLAPPED overlapped,
+ LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine);
+
+#ifndef _NTDEF_
+ typedef LONG NTSTATUS;
+ typedef NTSTATUS *PNTSTATUS;
+#endif
+
+#ifndef RTL_CONDITION_VARIABLE_INIT
+ typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE;
+#endif
+
+typedef struct _AFD_POLL_HANDLE_INFO {
+ HANDLE Handle;
+ ULONG Events;
+ NTSTATUS Status;
+} AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO;
+
+typedef struct _AFD_POLL_INFO {
+ LARGE_INTEGER Timeout;
+ ULONG NumberOfHandles;
+ ULONG Exclusive;
+ AFD_POLL_HANDLE_INFO Handles[1];
+} AFD_POLL_INFO, *PAFD_POLL_INFO;
+
+#define UV_MSAFD_PROVIDER_COUNT 3
+
+
+/**
+ * It should be possible to cast uv_buf_t[] to WSABUF[]
+ * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx
+ */
+typedef struct uv_buf_t {
+ ULONG len;
+ char* base;
+} uv_buf_t;
+
+typedef int uv_file;
+typedef SOCKET uv_os_sock_t;
+typedef HANDLE uv_os_fd_t;
+typedef int uv_pid_t;
+
+typedef HANDLE uv_thread_t;
+
+typedef HANDLE uv_sem_t;
+
+typedef CRITICAL_SECTION uv_mutex_t;
+
+/* This condition variable implementation is based on the SetEvent solution
+ * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
+ * We could not use the SignalObjectAndWait solution (section 3.4) because
+ * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and
+ * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs.
+ */
+
+typedef union {
+ CONDITION_VARIABLE cond_var;
+ struct {
+ unsigned int waiters_count;
+ CRITICAL_SECTION waiters_count_lock;
+ HANDLE signal_event;
+ HANDLE broadcast_event;
+ } unused_; /* TODO: retained for ABI compatibility; remove me in v2.x. */
+} uv_cond_t;
+
+typedef union {
+ struct {
+ unsigned int num_readers_;
+ CRITICAL_SECTION num_readers_lock_;
+ HANDLE write_semaphore_;
+ } state_;
+ /* TODO: remove me in v2.x. */
+ struct {
+ SRWLOCK unused_;
+ } unused1_;
+ /* TODO: remove me in v2.x. */
+ struct {
+ uv_mutex_t unused1_;
+ uv_mutex_t unused2_;
+ } unused2_;
+} uv_rwlock_t;
+
+typedef struct {
+ unsigned int n;
+ unsigned int count;
+ uv_mutex_t mutex;
+ uv_sem_t turnstile1;
+ uv_sem_t turnstile2;
+} uv_barrier_t;
+
+typedef struct {
+ DWORD tls_index;
+} uv_key_t;
+
+#define UV_ONCE_INIT { 0, NULL }
+
+typedef struct uv_once_s {
+ unsigned char ran;
+ HANDLE event;
+} uv_once_t;
+
+/* Platform-specific definitions for uv_spawn support. */
+typedef unsigned char uv_uid_t;
+typedef unsigned char uv_gid_t;
+
+typedef struct uv__dirent_s {
+ int d_type;
+ char d_name[1];
+} uv__dirent_t;
+
+#define UV_DIR_PRIVATE_FIELDS \
+ HANDLE dir_handle; \
+ WIN32_FIND_DATAW find_data; \
+ BOOL need_find_call;
+
+#define HAVE_DIRENT_TYPES
+#define UV__DT_DIR UV_DIRENT_DIR
+#define UV__DT_FILE UV_DIRENT_FILE
+#define UV__DT_LINK UV_DIRENT_LINK
+#define UV__DT_FIFO UV_DIRENT_FIFO
+#define UV__DT_SOCKET UV_DIRENT_SOCKET
+#define UV__DT_CHAR UV_DIRENT_CHAR
+#define UV__DT_BLOCK UV_DIRENT_BLOCK
+
+/* Platform-specific definitions for uv_dlopen support. */
+#define UV_DYNAMIC FAR WINAPI
+typedef struct {
+ HMODULE handle;
+ char* errmsg;
+} uv_lib_t;
+
+#define UV_LOOP_PRIVATE_FIELDS \
+ /* The loop's I/O completion port */ \
+ HANDLE iocp; \
+ /* The current time according to the event loop. in msecs. */ \
+ uint64_t time; \
+ /* Tail of a single-linked circular queue of pending reqs. If the queue */ \
+ /* is empty, tail_ is NULL. If there is only one item, */ \
+ /* tail_->next_req == tail_ */ \
+ uv_req_t* pending_reqs_tail; \
+ /* Head of a single-linked list of closed handles */ \
+ uv_handle_t* endgame_handles; \
+ /* TODO(bnoordhuis) Stop heap-allocating |timer_heap| in libuv v2.x. */ \
+ void* timer_heap; \
+ /* Lists of active loop (prepare / check / idle) watchers */ \
+ uv_prepare_t* prepare_handles; \
+ uv_check_t* check_handles; \
+ uv_idle_t* idle_handles; \
+ /* This pointer will refer to the prepare/check/idle handle whose */ \
+ /* callback is scheduled to be called next. This is needed to allow */ \
+ /* safe removal from one of the lists above while that list being */ \
+ /* iterated over. */ \
+ uv_prepare_t* next_prepare_handle; \
+ uv_check_t* next_check_handle; \
+ uv_idle_t* next_idle_handle; \
+ /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \
+ SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \
+ /* Counter to keep track of active tcp streams */ \
+ unsigned int active_tcp_streams; \
+ /* Counter to keep track of active udp streams */ \
+ unsigned int active_udp_streams; \
+ /* Counter to started timer */ \
+ uint64_t timer_counter; \
+ /* Threadpool */ \
+ void* wq[2]; \
+ uv_mutex_t wq_mutex; \
+ uv_async_t wq_async;
+
+#define UV_REQ_TYPE_PRIVATE \
+ /* TODO: remove the req suffix */ \
+ UV_ACCEPT, \
+ UV_FS_EVENT_REQ, \
+ UV_POLL_REQ, \
+ UV_PROCESS_EXIT, \
+ UV_READ, \
+ UV_UDP_RECV, \
+ UV_WAKEUP, \
+ UV_SIGNAL_REQ,
+
+#define UV_REQ_PRIVATE_FIELDS \
+ union { \
+ /* Used by I/O operations */ \
+ struct { \
+ OVERLAPPED overlapped; \
+ size_t queued_bytes; \
+ } io; \
+ } u; \
+ struct uv_req_s* next_req;
+
+#define UV_WRITE_PRIVATE_FIELDS \
+ int coalesced; \
+ uv_buf_t write_buffer; \
+ HANDLE event_handle; \
+ HANDLE wait_handle;
+
+#define UV_CONNECT_PRIVATE_FIELDS \
+ /* empty */
+
+#define UV_SHUTDOWN_PRIVATE_FIELDS \
+ /* empty */
+
+#define UV_UDP_SEND_PRIVATE_FIELDS \
+ /* empty */
+
+#define UV_PRIVATE_REQ_TYPES \
+ typedef struct uv_pipe_accept_s { \
+ UV_REQ_FIELDS \
+ HANDLE pipeHandle; \
+ struct uv_pipe_accept_s* next_pending; \
+ } uv_pipe_accept_t; \
+ \
+ typedef struct uv_tcp_accept_s { \
+ UV_REQ_FIELDS \
+ SOCKET accept_socket; \
+ char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \
+ HANDLE event_handle; \
+ HANDLE wait_handle; \
+ struct uv_tcp_accept_s* next_pending; \
+ } uv_tcp_accept_t; \
+ \
+ typedef struct uv_read_s { \
+ UV_REQ_FIELDS \
+ HANDLE event_handle; \
+ HANDLE wait_handle; \
+ } uv_read_t;
+
+#define uv_stream_connection_fields \
+ unsigned int write_reqs_pending; \
+ uv_shutdown_t* shutdown_req;
+
+#define uv_stream_server_fields \
+ uv_connection_cb connection_cb;
+
+#define UV_STREAM_PRIVATE_FIELDS \
+ unsigned int reqs_pending; \
+ int activecnt; \
+ uv_read_t read_req; \
+ union { \
+ struct { uv_stream_connection_fields } conn; \
+ struct { uv_stream_server_fields } serv; \
+ } stream;
+
+#define uv_tcp_server_fields \
+ uv_tcp_accept_t* accept_reqs; \
+ unsigned int processed_accepts; \
+ uv_tcp_accept_t* pending_accepts; \
+ LPFN_ACCEPTEX func_acceptex;
+
+#define uv_tcp_connection_fields \
+ uv_buf_t read_buffer; \
+ LPFN_CONNECTEX func_connectex;
+
+#define UV_TCP_PRIVATE_FIELDS \
+ SOCKET socket; \
+ int delayed_error; \
+ union { \
+ struct { uv_tcp_server_fields } serv; \
+ struct { uv_tcp_connection_fields } conn; \
+ } tcp;
+
+#define UV_UDP_PRIVATE_FIELDS \
+ SOCKET socket; \
+ unsigned int reqs_pending; \
+ int activecnt; \
+ uv_req_t recv_req; \
+ uv_buf_t recv_buffer; \
+ struct sockaddr_storage recv_from; \
+ int recv_from_len; \
+ uv_udp_recv_cb recv_cb; \
+ uv_alloc_cb alloc_cb; \
+ LPFN_WSARECV func_wsarecv; \
+ LPFN_WSARECVFROM func_wsarecvfrom;
+
+#define uv_pipe_server_fields \
+ int pending_instances; \
+ uv_pipe_accept_t* accept_reqs; \
+ uv_pipe_accept_t* pending_accepts;
+
+#define uv_pipe_connection_fields \
+ uv_timer_t* eof_timer; \
+ uv_write_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \
+ DWORD ipc_remote_pid; \
+ union { \
+ uint32_t payload_remaining; \
+ uint64_t dummy; /* TODO: retained for ABI compat; remove this in v2.x. */ \
+ } ipc_data_frame; \
+ void* ipc_xfer_queue[2]; \
+ int ipc_xfer_queue_length; \
+ uv_write_t* non_overlapped_writes_tail; \
+ CRITICAL_SECTION readfile_thread_lock; \
+ volatile HANDLE readfile_thread_handle;
+
+#define UV_PIPE_PRIVATE_FIELDS \
+ HANDLE handle; \
+ WCHAR* name; \
+ union { \
+ struct { uv_pipe_server_fields } serv; \
+ struct { uv_pipe_connection_fields } conn; \
+ } pipe;
+
+/* TODO: put the parser states in an union - TTY handles are always half-duplex
+ * so read-state can safely overlap write-state. */
+#define UV_TTY_PRIVATE_FIELDS \
+ HANDLE handle; \
+ union { \
+ struct { \
+ /* Used for readable TTY handles */ \
+ /* TODO: remove me in v2.x. */ \
+ HANDLE unused_; \
+ uv_buf_t read_line_buffer; \
+ HANDLE read_raw_wait; \
+ /* Fields used for translating win keystrokes into vt100 characters */ \
+ char last_key[8]; \
+ unsigned char last_key_offset; \
+ unsigned char last_key_len; \
+ WCHAR last_utf16_high_surrogate; \
+ INPUT_RECORD last_input_record; \
+ } rd; \
+ struct { \
+ /* Used for writable TTY handles */ \
+ /* utf8-to-utf16 conversion state */ \
+ unsigned int utf8_codepoint; \
+ unsigned char utf8_bytes_left; \
+ /* eol conversion state */ \
+ unsigned char previous_eol; \
+ /* ansi parser state */ \
+ unsigned char ansi_parser_state; \
+ unsigned char ansi_csi_argc; \
+ unsigned short ansi_csi_argv[4]; \
+ COORD saved_position; \
+ WORD saved_attributes; \
+ } wr; \
+ } tty;
+
+#define UV_POLL_PRIVATE_FIELDS \
+ SOCKET socket; \
+ /* Used in fast mode */ \
+ SOCKET peer_socket; \
+ AFD_POLL_INFO afd_poll_info_1; \
+ AFD_POLL_INFO afd_poll_info_2; \
+ /* Used in fast and slow mode. */ \
+ uv_req_t poll_req_1; \
+ uv_req_t poll_req_2; \
+ unsigned char submitted_events_1; \
+ unsigned char submitted_events_2; \
+ unsigned char mask_events_1; \
+ unsigned char mask_events_2; \
+ unsigned char events;
+
+#define UV_TIMER_PRIVATE_FIELDS \
+ void* heap_node[3]; \
+ int unused; \
+ uint64_t timeout; \
+ uint64_t repeat; \
+ uint64_t start_id; \
+ uv_timer_cb timer_cb;
+
+#define UV_ASYNC_PRIVATE_FIELDS \
+ struct uv_req_s async_req; \
+ uv_async_cb async_cb; \
+ /* char to avoid alignment issues */ \
+ char volatile async_sent;
+
+#define UV_PREPARE_PRIVATE_FIELDS \
+ uv_prepare_t* prepare_prev; \
+ uv_prepare_t* prepare_next; \
+ uv_prepare_cb prepare_cb;
+
+#define UV_CHECK_PRIVATE_FIELDS \
+ uv_check_t* check_prev; \
+ uv_check_t* check_next; \
+ uv_check_cb check_cb;
+
+#define UV_IDLE_PRIVATE_FIELDS \
+ uv_idle_t* idle_prev; \
+ uv_idle_t* idle_next; \
+ uv_idle_cb idle_cb;
+
+#define UV_HANDLE_PRIVATE_FIELDS \
+ uv_handle_t* endgame_next; \
+ unsigned int flags;
+
+#define UV_GETADDRINFO_PRIVATE_FIELDS \
+ struct uv__work work_req; \
+ uv_getaddrinfo_cb getaddrinfo_cb; \
+ void* alloc; \
+ WCHAR* node; \
+ WCHAR* service; \
+ /* The addrinfoW field is used to store a pointer to the hints, and */ \
+ /* later on to store the result of GetAddrInfoW. The final result will */ \
+ /* be converted to struct addrinfo* and stored in the addrinfo field. */ \
+ struct addrinfoW* addrinfow; \
+ struct addrinfo* addrinfo; \
+ int retcode;
+
+#define UV_GETNAMEINFO_PRIVATE_FIELDS \
+ struct uv__work work_req; \
+ uv_getnameinfo_cb getnameinfo_cb; \
+ struct sockaddr_storage storage; \
+ int flags; \
+ char host[NI_MAXHOST]; \
+ char service[NI_MAXSERV]; \
+ int retcode;
+
+#define UV_PROCESS_PRIVATE_FIELDS \
+ struct uv_process_exit_s { \
+ UV_REQ_FIELDS \
+ } exit_req; \
+ BYTE* child_stdio_buffer; \
+ int exit_signal; \
+ HANDLE wait_handle; \
+ HANDLE process_handle; \
+ volatile char exit_cb_pending;
+
+#define UV_FS_PRIVATE_FIELDS \
+ struct uv__work work_req; \
+ int flags; \
+ DWORD sys_errno_; \
+ union { \
+ /* TODO: remove me in 0.9. */ \
+ WCHAR* pathw; \
+ int fd; \
+ } file; \
+ union { \
+ struct { \
+ int mode; \
+ WCHAR* new_pathw; \
+ int file_flags; \
+ int fd_out; \
+ unsigned int nbufs; \
+ uv_buf_t* bufs; \
+ int64_t offset; \
+ uv_buf_t bufsml[4]; \
+ } info; \
+ struct { \
+ double atime; \
+ double mtime; \
+ } time; \
+ } fs;
+
+#define UV_WORK_PRIVATE_FIELDS \
+ struct uv__work work_req;
+
+#define UV_FS_EVENT_PRIVATE_FIELDS \
+ struct uv_fs_event_req_s { \
+ UV_REQ_FIELDS \
+ } req; \
+ HANDLE dir_handle; \
+ int req_pending; \
+ uv_fs_event_cb cb; \
+ WCHAR* filew; \
+ WCHAR* short_filew; \
+ WCHAR* dirw; \
+ char* buffer;
+
+#define UV_SIGNAL_PRIVATE_FIELDS \
+ RB_ENTRY(uv_signal_s) tree_entry; \
+ struct uv_req_s signal_req; \
+ unsigned long pending_signum;
+
+#ifndef F_OK
+#define F_OK 0
+#endif
+#ifndef R_OK
+#define R_OK 4
+#endif
+#ifndef W_OK
+#define W_OK 2
+#endif
+#ifndef X_OK
+#define X_OK 1
+#endif
+
+/* fs open() flags supported on this platform: */
+#define UV_FS_O_APPEND _O_APPEND
+#define UV_FS_O_CREAT _O_CREAT
+#define UV_FS_O_EXCL _O_EXCL
+#define UV_FS_O_RANDOM _O_RANDOM
+#define UV_FS_O_RDONLY _O_RDONLY
+#define UV_FS_O_RDWR _O_RDWR
+#define UV_FS_O_SEQUENTIAL _O_SEQUENTIAL
+#define UV_FS_O_SHORT_LIVED _O_SHORT_LIVED
+#define UV_FS_O_TEMPORARY _O_TEMPORARY
+#define UV_FS_O_TRUNC _O_TRUNC
+#define UV_FS_O_WRONLY _O_WRONLY
+
+/* fs open() flags supported on other platforms (or mapped on this platform): */
+#define UV_FS_O_DIRECT 0x02000000 /* FILE_FLAG_NO_BUFFERING */
+#define UV_FS_O_DIRECTORY 0
+#define UV_FS_O_DSYNC 0x04000000 /* FILE_FLAG_WRITE_THROUGH */
+#define UV_FS_O_EXLOCK 0x10000000 /* EXCLUSIVE SHARING MODE */
+#define UV_FS_O_NOATIME 0
+#define UV_FS_O_NOCTTY 0
+#define UV_FS_O_NOFOLLOW 0
+#define UV_FS_O_NONBLOCK 0
+#define UV_FS_O_SYMLINK 0
+#define UV_FS_O_SYNC 0x08000000 /* FILE_FLAG_WRITE_THROUGH */
diff --git a/Utilities/cmlibuv/src/fs-poll.c b/Utilities/cmlibuv/src/fs-poll.c
index ee73d5a2e..89864e23f 100644
--- a/Utilities/cmlibuv/src/fs-poll.c
+++ b/Utilities/cmlibuv/src/fs-poll.c
@@ -22,12 +22,20 @@
#include "uv.h"
#include "uv-common.h"
+#ifdef _WIN32
+#include "win/internal.h"
+#include "win/handle-inl.h"
+#define uv__make_close_pending(h) uv_want_endgame((h)->loop, (h))
+#else
+#include "unix/internal.h"
+#endif
+
#include <assert.h>
#include <stdlib.h>
#include <string.h>
struct poll_ctx {
- uv_fs_poll_t* parent_handle; /* NULL if parent has been stopped or closed */
+ uv_fs_poll_t* parent_handle;
int busy_polling;
unsigned int interval;
uint64_t start_time;
@@ -36,6 +44,7 @@ struct poll_ctx {
uv_timer_t timer_handle;
uv_fs_t fs_req; /* TODO(bnoordhuis) mark fs_req internal */
uv_stat_t statbuf;
+ struct poll_ctx* previous; /* context from previous start()..stop() period */
char path[1]; /* variable length */
};
@@ -49,6 +58,7 @@ static uv_stat_t zero_statbuf;
int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle) {
uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_POLL);
+ handle->poll_ctx = NULL;
return 0;
}
@@ -62,7 +72,7 @@ int uv_fs_poll_start(uv_fs_poll_t* handle,
size_t len;
int err;
- if (uv__is_active(handle))
+ if (uv_is_active((uv_handle_t*)handle))
return 0;
loop = handle->loop;
@@ -83,13 +93,15 @@ int uv_fs_poll_start(uv_fs_poll_t* handle,
if (err < 0)
goto error;
- ctx->timer_handle.flags |= UV__HANDLE_INTERNAL;
+ ctx->timer_handle.flags |= UV_HANDLE_INTERNAL;
uv__handle_unref(&ctx->timer_handle);
err = uv_fs_stat(loop, &ctx->fs_req, ctx->path, poll_cb);
if (err < 0)
goto error;
+ if (handle->poll_ctx != NULL)
+ ctx->previous = handle->poll_ctx;
handle->poll_ctx = ctx;
uv__handle_start(handle);
@@ -104,19 +116,17 @@ error:
int uv_fs_poll_stop(uv_fs_poll_t* handle) {
struct poll_ctx* ctx;
- if (!uv__is_active(handle))
+ if (!uv_is_active((uv_handle_t*)handle))
return 0;
ctx = handle->poll_ctx;
assert(ctx != NULL);
- assert(ctx->parent_handle != NULL);
- ctx->parent_handle = NULL;
- handle->poll_ctx = NULL;
+ assert(ctx->parent_handle == handle);
/* Close the timer if it's active. If it's inactive, there's a stat request
* in progress and poll_cb will take care of the cleanup.
*/
- if (uv__is_active(&ctx->timer_handle))
+ if (uv_is_active((uv_handle_t*)&ctx->timer_handle))
uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb);
uv__handle_stop(handle);
@@ -129,7 +139,7 @@ int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buffer, size_t* size) {
struct poll_ctx* ctx;
size_t required_len;
- if (!uv__is_active(handle)) {
+ if (!uv_is_active((uv_handle_t*)handle)) {
*size = 0;
return UV_EINVAL;
}
@@ -153,6 +163,9 @@ int uv_fs_poll_getpath(uv_fs_poll_t* handle, char* buffer, size_t* size) {
void uv__fs_poll_close(uv_fs_poll_t* handle) {
uv_fs_poll_stop(handle);
+
+ if (handle->poll_ctx == NULL)
+ uv__make_close_pending((uv_handle_t*)handle);
}
@@ -173,14 +186,13 @@ static void poll_cb(uv_fs_t* req) {
uv_stat_t* statbuf;
struct poll_ctx* ctx;
uint64_t interval;
+ uv_fs_poll_t* handle;
ctx = container_of(req, struct poll_ctx, fs_req);
+ handle = ctx->parent_handle;
- if (ctx->parent_handle == NULL) { /* handle has been stopped or closed */
- uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb);
- uv_fs_req_cleanup(req);
- return;
- }
+ if (!uv_is_active((uv_handle_t*)handle) || uv__is_closing(handle))
+ goto out;
if (req->result != 0) {
if (ctx->busy_polling != req->result) {
@@ -205,7 +217,7 @@ static void poll_cb(uv_fs_t* req) {
out:
uv_fs_req_cleanup(req);
- if (ctx->parent_handle == NULL) { /* handle has been stopped by callback */
+ if (!uv_is_active((uv_handle_t*)handle) || uv__is_closing(handle)) {
uv_close((uv_handle_t*)&ctx->timer_handle, timer_close_cb);
return;
}
@@ -219,8 +231,27 @@ out:
}
-static void timer_close_cb(uv_handle_t* handle) {
- uv__free(container_of(handle, struct poll_ctx, timer_handle));
+static void timer_close_cb(uv_handle_t* timer) {
+ struct poll_ctx* ctx;
+ struct poll_ctx* it;
+ struct poll_ctx* last;
+ uv_fs_poll_t* handle;
+
+ ctx = container_of(timer, struct poll_ctx, timer_handle);
+ handle = ctx->parent_handle;
+ if (ctx == handle->poll_ctx) {
+ handle->poll_ctx = ctx->previous;
+ if (handle->poll_ctx == NULL && uv__is_closing(handle))
+ uv__make_close_pending((uv_handle_t*)handle);
+ } else {
+ for (last = handle->poll_ctx, it = last->previous;
+ it != ctx;
+ last = it, it = it->previous) {
+ assert(last->previous != NULL);
+ }
+ last->previous = ctx->previous;
+ }
+ uv__free(ctx);
}
@@ -248,7 +279,7 @@ static int statbuf_eq(const uv_stat_t* a, const uv_stat_t* b) {
#include "win/handle-inl.h"
void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle) {
- assert(handle->flags & UV__HANDLE_CLOSING);
+ assert(handle->flags & UV_HANDLE_CLOSING);
assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_close(handle);
}
diff --git a/Utilities/cmlibuv/src/idna.c b/Utilities/cmlibuv/src/idna.c
new file mode 100644
index 000000000..13ffac6be
--- /dev/null
+++ b/Utilities/cmlibuv/src/idna.c
@@ -0,0 +1,291 @@
+/* Copyright (c) 2011, 2018 Ben Noordhuis <info@bnoordhuis.nl>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Derived from https://github.com/bnoordhuis/punycode
+ * but updated to support IDNA 2008.
+ */
+
+#include "uv.h"
+#include "idna.h"
+#include <string.h>
+
+static unsigned uv__utf8_decode1_slow(const char** p,
+ const char* pe,
+ unsigned a) {
+ unsigned b;
+ unsigned c;
+ unsigned d;
+ unsigned min;
+
+ if (a > 0xF7)
+ return -1;
+
+ switch (*p - pe) {
+ default:
+ if (a > 0xEF) {
+ min = 0x10000;
+ a = a & 7;
+ b = (unsigned char) *(*p)++;
+ c = (unsigned char) *(*p)++;
+ d = (unsigned char) *(*p)++;
+ break;
+ }
+ /* Fall through. */
+ case 2:
+ if (a > 0xDF) {
+ min = 0x800;
+ b = 0x80 | (a & 15);
+ c = (unsigned char) *(*p)++;
+ d = (unsigned char) *(*p)++;
+ a = 0;
+ break;
+ }
+ /* Fall through. */
+ case 1:
+ if (a > 0xBF) {
+ min = 0x80;
+ b = 0x80;
+ c = 0x80 | (a & 31);
+ d = (unsigned char) *(*p)++;
+ a = 0;
+ break;
+ }
+ return -1; /* Invalid continuation byte. */
+ }
+
+ if (0x80 != (0xC0 & (b ^ c ^ d)))
+ return -1; /* Invalid sequence. */
+
+ b &= 63;
+ c &= 63;
+ d &= 63;
+ a = (a << 18) | (b << 12) | (c << 6) | d;
+
+ if (a < min)
+ return -1; /* Overlong sequence. */
+
+ if (a > 0x10FFFF)
+ return -1; /* Four-byte sequence > U+10FFFF. */
+
+ if (a >= 0xD800 && a <= 0xDFFF)
+ return -1; /* Surrogate pair. */
+
+ return a;
+}
+
+unsigned uv__utf8_decode1(const char** p, const char* pe) {
+ unsigned a;
+
+ a = (unsigned char) *(*p)++;
+
+ if (a < 128)
+ return a; /* ASCII, common case. */
+
+ return uv__utf8_decode1_slow(p, pe, a);
+}
+
+#define foreach_codepoint(c, p, pe) \
+ for (; (void) (*p <= pe && (c = uv__utf8_decode1(p, pe))), *p <= pe;)
+
+static int uv__idna_toascii_label(const char* s, const char* se,
+ char** d, char* de) {
+ static const char alphabet[] = "abcdefghijklmnopqrstuvwxyz0123456789";
+ const char* ss;
+ unsigned c;
+ unsigned h;
+ unsigned k;
+ unsigned n;
+ unsigned m;
+ unsigned q;
+ unsigned t;
+ unsigned x;
+ unsigned y;
+ unsigned bias;
+ unsigned delta;
+ unsigned todo;
+ int first;
+
+ h = 0;
+ ss = s;
+ todo = 0;
+
+ foreach_codepoint(c, &s, se) {
+ if (c < 128)
+ h++;
+ else if (c == (unsigned) -1)
+ return UV_EINVAL;
+ else
+ todo++;
+ }
+
+ if (todo > 0) {
+ if (*d < de) *(*d)++ = 'x';
+ if (*d < de) *(*d)++ = 'n';
+ if (*d < de) *(*d)++ = '-';
+ if (*d < de) *(*d)++ = '-';
+ }
+
+ x = 0;
+ s = ss;
+ foreach_codepoint(c, &s, se) {
+ if (c > 127)
+ continue;
+
+ if (*d < de)
+ *(*d)++ = c;
+
+ if (++x == h)
+ break; /* Visited all ASCII characters. */
+ }
+
+ if (todo == 0)
+ return h;
+
+ /* Only write separator when we've written ASCII characters first. */
+ if (h > 0)
+ if (*d < de)
+ *(*d)++ = '-';
+
+ n = 128;
+ bias = 72;
+ delta = 0;
+ first = 1;
+
+ while (todo > 0) {
+ m = -1;
+ s = ss;
+ foreach_codepoint(c, &s, se)
+ if (c >= n)
+ if (c < m)
+ m = c;
+
+ x = m - n;
+ y = h + 1;
+
+ if (x > ~delta / y)
+ return UV_E2BIG; /* Overflow. */
+
+ delta += x * y;
+ n = m;
+
+ s = ss;
+ foreach_codepoint(c, &s, se) {
+ if (c < n)
+ if (++delta == 0)
+ return UV_E2BIG; /* Overflow. */
+
+ if (c != n)
+ continue;
+
+ for (k = 36, q = delta; /* empty */; k += 36) {
+ t = 1;
+
+ if (k > bias)
+ t = k - bias;
+
+ if (t > 26)
+ t = 26;
+
+ if (q < t)
+ break;
+
+ /* TODO(bnoordhuis) Since 1 <= t <= 26 and therefore
+ * 10 <= y <= 35, we can optimize the long division
+ * into a table-based reciprocal multiplication.
+ */
+ x = q - t;
+ y = 36 - t; /* 10 <= y <= 35 since 1 <= t <= 26. */
+ q = x / y;
+ t = t + x % y; /* 1 <= t <= 35 because of y. */
+
+ if (*d < de)
+ *(*d)++ = alphabet[t];
+ }
+
+ if (*d < de)
+ *(*d)++ = alphabet[q];
+
+ delta /= 2;
+
+ if (first) {
+ delta /= 350;
+ first = 0;
+ }
+
+ /* No overflow check is needed because |delta| was just
+ * divided by 2 and |delta+delta >= delta + delta/h|.
+ */
+ h++;
+ delta += delta / h;
+
+ for (bias = 0; delta > 35 * 26 / 2; bias += 36)
+ delta /= 35;
+
+ bias += 36 * delta / (delta + 38);
+ delta = 0;
+ todo--;
+ }
+
+ delta++;
+ n++;
+ }
+
+ return 0;
+}
+
+#undef foreach_codepoint
+
+long uv__idna_toascii(const char* s, const char* se, char* d, char* de) {
+ const char* si;
+ const char* st;
+ unsigned c;
+ char* ds;
+ int rc;
+
+ ds = d;
+
+ for (si = s; si < se; /* empty */) {
+ st = si;
+ c = uv__utf8_decode1(&si, se);
+
+ if (c != '.')
+ if (c != 0x3002) /* 。 */
+ if (c != 0xFF0E) /* . */
+ if (c != 0xFF61) /* 。 */
+ continue;
+
+ rc = uv__idna_toascii_label(s, st, &d, de);
+
+ if (rc < 0)
+ return rc;
+
+ if (d < de)
+ *d++ = '.';
+
+ s = si;
+ }
+
+ if (s < se) {
+ rc = uv__idna_toascii_label(s, se, &d, de);
+
+ if (rc < 0)
+ return rc;
+ }
+
+ if (d < de)
+ *d++ = '\0';
+
+ return d - ds; /* Number of bytes written. */
+}
diff --git a/Utilities/cmlibuv/src/idna.h b/Utilities/cmlibuv/src/idna.h
new file mode 100644
index 000000000..8e0c592fe
--- /dev/null
+++ b/Utilities/cmlibuv/src/idna.h
@@ -0,0 +1,31 @@
+/* Copyright (c) 2011, 2018 Ben Noordhuis <info@bnoordhuis.nl>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef UV_SRC_IDNA_H_
+#define UV_SRC_IDNA_H_
+
+/* Decode a single codepoint. Returns the codepoint or UINT32_MAX on error.
+ * |p| is updated on success _and_ error, i.e., bad multi-byte sequences are
+ * skipped in their entirety, not just the first bad byte.
+ */
+unsigned uv__utf8_decode1(const char** p, const char* pe);
+
+/* Convert a UTF-8 domain name to IDNA 2008 / Punycode. A return value >= 0
+ * is the number of bytes written to |d|, including the trailing nul byte.
+ * A return value < 0 is a libuv error code. |s| and |d| can not overlap.
+ */
+long uv__idna_toascii(const char* s, const char* se, char* d, char* de);
+
+#endif /* UV_SRC_IDNA_H_ */
diff --git a/Utilities/cmlibuv/src/inet.c b/Utilities/cmlibuv/src/inet.c
index 7c75e4373..58238dcbb 100644
--- a/Utilities/cmlibuv/src/inet.c
+++ b/Utilities/cmlibuv/src/inet.c
@@ -22,7 +22,7 @@
#include <string.h>
#if defined(_MSC_VER) && _MSC_VER < 1600
-# include "stdint-msvc2008.h"
+# include "uv/stdint-msvc2008.h"
#else
# include <stdint.h>
#endif
@@ -59,8 +59,7 @@ static int inet_ntop4(const unsigned char *src, char *dst, size_t size) {
if (l <= 0 || (size_t) l >= size) {
return UV_ENOSPC;
}
- strncpy(dst, tmp, size);
- dst[size - 1] = '\0';
+ uv__strscpy(dst, tmp, size);
return 0;
}
@@ -142,14 +141,8 @@ static int inet_ntop6(const unsigned char *src, char *dst, size_t size) {
if (best.base != -1 && (best.base + best.len) == ARRAY_SIZE(words))
*tp++ = ':';
*tp++ = '\0';
-
- /*
- * Check for overflow, copy, and we're done.
- */
- if ((size_t)(tp - tmp) > size) {
+ if (UV_E2BIG == uv__strscpy(dst, tmp, size))
return UV_ENOSPC;
- }
- strcpy(dst, tmp);
return 0;
}
diff --git a/Utilities/cmlibuv/src/strscpy.c b/Utilities/cmlibuv/src/strscpy.c
new file mode 100644
index 000000000..2a2bdce74
--- /dev/null
+++ b/Utilities/cmlibuv/src/strscpy.c
@@ -0,0 +1,17 @@
+#include "strscpy.h"
+#include <limits.h> /* SSIZE_MAX */
+
+ssize_t uv__strscpy(char* d, const char* s, size_t n) {
+ size_t i;
+
+ for (i = 0; i < n; i++)
+ if ('\0' == (d[i] = s[i]))
+ return i > SSIZE_MAX ? UV_E2BIG : (ssize_t) i;
+
+ if (i == 0)
+ return 0;
+
+ d[--i] = '\0';
+
+ return UV_E2BIG;
+}
diff --git a/Utilities/cmlibuv/src/strscpy.h b/Utilities/cmlibuv/src/strscpy.h
new file mode 100644
index 000000000..fbe0a393f
--- /dev/null
+++ b/Utilities/cmlibuv/src/strscpy.h
@@ -0,0 +1,18 @@
+#ifndef UV_STRSCPY_H_
+#define UV_STRSCPY_H_
+
+/* Include uv.h for its definitions of size_t and ssize_t.
+ * size_t can be obtained directly from <stddef.h> but ssize_t requires
+ * some hoop jumping on Windows that I didn't want to duplicate here.
+ */
+#include "uv.h"
+
+/* Copies up to |n-1| bytes from |d| to |s| and always zero-terminates
+ * the result, except when |n==0|. Returns the number of bytes copied
+ * or UV_E2BIG if |d| is too small.
+ *
+ * See https://www.kernel.org/doc/htmldocs/kernel-api/API-strscpy.html
+ */
+ssize_t uv__strscpy(char* d, const char* s, size_t n);
+
+#endif /* UV_STRSCPY_H_ */
diff --git a/Utilities/cmlibuv/src/threadpool.c b/Utilities/cmlibuv/src/threadpool.c
index 108934112..7aa575508 100644
--- a/Utilities/cmlibuv/src/threadpool.c
+++ b/Utilities/cmlibuv/src/threadpool.c
@@ -27,19 +27,24 @@
#include <stdlib.h>
-#define MAX_THREADPOOL_SIZE 128
+#define MAX_THREADPOOL_SIZE 1024
static uv_once_t once = UV_ONCE_INIT;
static uv_cond_t cond;
static uv_mutex_t mutex;
static unsigned int idle_threads;
+static unsigned int slow_io_work_running;
static unsigned int nthreads;
static uv_thread_t* threads;
static uv_thread_t default_threads[4];
static QUEUE exit_message;
static QUEUE wq;
-static volatile int initialized;
+static QUEUE run_slow_work_message;
+static QUEUE slow_io_pending_wq;
+static unsigned int slow_work_thread_threshold(void) {
+ return (nthreads + 1) / 2;
+}
static void uv__cancelled(struct uv__work* w) {
abort();
@@ -52,33 +57,67 @@ static void uv__cancelled(struct uv__work* w) {
static void worker(void* arg) {
struct uv__work* w;
QUEUE* q;
+ int is_slow_work;
- (void) arg;
+ uv_sem_post((uv_sem_t*) arg);
+ arg = NULL;
+ uv_mutex_lock(&mutex);
for (;;) {
- uv_mutex_lock(&mutex);
-
- while (QUEUE_EMPTY(&wq)) {
+ /* `mutex` should always be locked at this point. */
+
+ /* Keep waiting while either no work is present or only slow I/O
+ and we're at the threshold for that. */
+ while (QUEUE_EMPTY(&wq) ||
+ (QUEUE_HEAD(&wq) == &run_slow_work_message &&
+ QUEUE_NEXT(&run_slow_work_message) == &wq &&
+ slow_io_work_running >= slow_work_thread_threshold())) {
idle_threads += 1;
uv_cond_wait(&cond, &mutex);
idle_threads -= 1;
}
q = QUEUE_HEAD(&wq);
-
- if (q == &exit_message)
+ if (q == &exit_message) {
uv_cond_signal(&cond);
- else {
+ uv_mutex_unlock(&mutex);
+ break;
+ }
+
+ QUEUE_REMOVE(q);
+ QUEUE_INIT(q); /* Signal uv_cancel() that the work req is executing. */
+
+ is_slow_work = 0;
+ if (q == &run_slow_work_message) {
+ /* If we're at the slow I/O threshold, re-schedule until after all
+ other work in the queue is done. */
+ if (slow_io_work_running >= slow_work_thread_threshold()) {
+ QUEUE_INSERT_TAIL(&wq, q);
+ continue;
+ }
+
+ /* If we encountered a request to run slow I/O work but there is none
+ to run, that means it's cancelled => Start over. */
+ if (QUEUE_EMPTY(&slow_io_pending_wq))
+ continue;
+
+ is_slow_work = 1;
+ slow_io_work_running++;
+
+ q = QUEUE_HEAD(&slow_io_pending_wq);
QUEUE_REMOVE(q);
- QUEUE_INIT(q); /* Signal uv_cancel() that the work req is
- executing. */
+ QUEUE_INIT(q);
+
+ /* If there is more slow I/O work, schedule it to be run as well. */
+ if (!QUEUE_EMPTY(&slow_io_pending_wq)) {
+ QUEUE_INSERT_TAIL(&wq, &run_slow_work_message);
+ if (idle_threads > 0)
+ uv_cond_signal(&cond);
+ }
}
uv_mutex_unlock(&mutex);
- if (q == &exit_message)
- break;
-
w = QUEUE_DATA(q, struct uv__work, wq);
w->work(w);
@@ -88,12 +127,32 @@ static void worker(void* arg) {
QUEUE_INSERT_TAIL(&w->loop->wq, &w->wq);
uv_async_send(&w->loop->wq_async);
uv_mutex_unlock(&w->loop->wq_mutex);
+
+ /* Lock `mutex` since that is expected at the start of the next
+ * iteration. */
+ uv_mutex_lock(&mutex);
+ if (is_slow_work) {
+ /* `slow_io_work_running` is protected by `mutex`. */
+ slow_io_work_running--;
+ }
}
}
-static void post(QUEUE* q) {
+static void post(QUEUE* q, enum uv__work_kind kind) {
uv_mutex_lock(&mutex);
+ if (kind == UV__WORK_SLOW_IO) {
+ /* Insert into a separate queue. */
+ QUEUE_INSERT_TAIL(&slow_io_pending_wq, q);
+ if (!QUEUE_EMPTY(&run_slow_work_message)) {
+ /* Running slow I/O tasks is already scheduled => Nothing to do here.
+ The worker that runs said other task will schedule this one as well. */
+ uv_mutex_unlock(&mutex);
+ return;
+ }
+ q = &run_slow_work_message;
+ }
+
QUEUE_INSERT_TAIL(&wq, q);
if (idle_threads > 0)
uv_cond_signal(&cond);
@@ -105,10 +164,10 @@ static void post(QUEUE* q) {
UV_DESTRUCTOR(static void cleanup(void)) {
unsigned int i;
- if (initialized == 0)
+ if (nthreads == 0)
return;
- post(&exit_message);
+ post(&exit_message, UV__WORK_CPU);
for (i = 0; i < nthreads; i++)
if (uv_thread_join(threads + i))
@@ -122,7 +181,6 @@ UV_DESTRUCTOR(static void cleanup(void)) {
threads = NULL;
nthreads = 0;
- initialized = 0;
}
#endif
@@ -130,6 +188,7 @@ UV_DESTRUCTOR(static void cleanup(void)) {
static void init_threads(void) {
unsigned int i;
const char* val;
+ uv_sem_t sem;
nthreads = ARRAY_SIZE(default_threads);
val = getenv("UV_THREADPOOL_SIZE");
@@ -156,12 +215,20 @@ static void init_threads(void) {
abort();
QUEUE_INIT(&wq);
+ QUEUE_INIT(&slow_io_pending_wq);
+ QUEUE_INIT(&run_slow_work_message);
+
+ if (uv_sem_init(&sem, 0))
+ abort();
for (i = 0; i < nthreads; i++)
- if (uv_thread_create(threads + i, worker, NULL))
+ if (uv_thread_create(threads + i, worker, &sem))
abort();
- initialized = 1;
+ for (i = 0; i < nthreads; i++)
+ uv_sem_wait(&sem);
+
+ uv_sem_destroy(&sem);
}
@@ -188,13 +255,14 @@ static void init_once(void) {
void uv__work_submit(uv_loop_t* loop,
struct uv__work* w,
+ enum uv__work_kind kind,
void (*work)(struct uv__work* w),
void (*done)(struct uv__work* w, int status)) {
uv_once(&once, init_once);
w->loop = loop;
w->work = work;
w->done = done;
- post(&w->wq);
+ post(&w->wq, kind);
}
@@ -278,7 +346,11 @@ int uv_queue_work(uv_loop_t* loop,
req->loop = loop;
req->work_cb = work_cb;
req->after_work_cb = after_work_cb;
- uv__work_submit(loop, &req->work_req, uv__queue_work, uv__queue_done);
+ uv__work_submit(loop,
+ &req->work_req,
+ UV__WORK_CPU,
+ uv__queue_work,
+ uv__queue_done);
return 0;
}
diff --git a/Utilities/cmlibuv/src/timer.c b/Utilities/cmlibuv/src/timer.c
new file mode 100644
index 000000000..dd78bcbad
--- /dev/null
+++ b/Utilities/cmlibuv/src/timer.c
@@ -0,0 +1,181 @@
+/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "uv.h"
+#include "uv-common.h"
+#include "heap-inl.h"
+
+#include <assert.h>
+#include <limits.h>
+
+
+static struct heap *timer_heap(const uv_loop_t* loop) {
+#ifdef _WIN32
+ return (struct heap*) loop->timer_heap;
+#else
+ return (struct heap*) &loop->timer_heap;
+#endif
+}
+
+
+static int timer_less_than(const struct heap_node* ha,
+ const struct heap_node* hb) {
+ const uv_timer_t* a;
+ const uv_timer_t* b;
+
+ a = container_of(ha, uv_timer_t, heap_node);
+ b = container_of(hb, uv_timer_t, heap_node);
+
+ if (a->timeout < b->timeout)
+ return 1;
+ if (b->timeout < a->timeout)
+ return 0;
+
+ /* Compare start_id when both have the same timeout. start_id is
+ * allocated with loop->timer_counter in uv_timer_start().
+ */
+ if (a->start_id < b->start_id)
+ return 1;
+ if (b->start_id < a->start_id)
+ return 0;
+
+ return 0;
+}
+
+
+int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) {
+ uv__handle_init(loop, (uv_handle_t*)handle, UV_TIMER);
+ handle->timer_cb = NULL;
+ handle->repeat = 0;
+ return 0;
+}
+
+
+int uv_timer_start(uv_timer_t* handle,
+ uv_timer_cb cb,
+ uint64_t timeout,
+ uint64_t repeat) {
+ uint64_t clamped_timeout;
+
+ if (cb == NULL)
+ return UV_EINVAL;
+
+ if (uv__is_active(handle))
+ uv_timer_stop(handle);
+
+ clamped_timeout = handle->loop->time + timeout;
+ if (clamped_timeout < timeout)
+ clamped_timeout = (uint64_t) -1;
+
+ handle->timer_cb = cb;
+ handle->timeout = clamped_timeout;
+ handle->repeat = repeat;
+ /* start_id is the second index to be compared in uv__timer_cmp() */
+ handle->start_id = handle->loop->timer_counter++;
+
+ heap_insert(timer_heap(handle->loop),
+ (struct heap_node*) &handle->heap_node,
+ timer_less_than);
+ uv__handle_start(handle);
+
+ return 0;
+}
+
+
+int uv_timer_stop(uv_timer_t* handle) {
+ if (!uv__is_active(handle))
+ return 0;
+
+ heap_remove(timer_heap(handle->loop),
+ (struct heap_node*) &handle->heap_node,
+ timer_less_than);
+ uv__handle_stop(handle);
+
+ return 0;
+}
+
+
+int uv_timer_again(uv_timer_t* handle) {
+ if (handle->timer_cb == NULL)
+ return UV_EINVAL;
+
+ if (handle->repeat) {
+ uv_timer_stop(handle);
+ uv_timer_start(handle, handle->timer_cb, handle->repeat, handle->repeat);
+ }
+
+ return 0;
+}
+
+
+void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat) {
+ handle->repeat = repeat;
+}
+
+
+uint64_t uv_timer_get_repeat(const uv_timer_t* handle) {
+ return handle->repeat;
+}
+
+
+int uv__next_timeout(const uv_loop_t* loop) {
+ const struct heap_node* heap_node;
+ const uv_timer_t* handle;
+ uint64_t diff;
+
+ heap_node = heap_min(timer_heap(loop));
+ if (heap_node == NULL)
+ return -1; /* block indefinitely */
+
+ handle = container_of(heap_node, uv_timer_t, heap_node);
+ if (handle->timeout <= loop->time)
+ return 0;
+
+ diff = handle->timeout - loop->time;
+ if (diff > INT_MAX)
+ diff = INT_MAX;
+
+ return (int) diff;
+}
+
+
+void uv__run_timers(uv_loop_t* loop) {
+ struct heap_node* heap_node;
+ uv_timer_t* handle;
+
+ for (;;) {
+ heap_node = heap_min(timer_heap(loop));
+ if (heap_node == NULL)
+ break;
+
+ handle = container_of(heap_node, uv_timer_t, heap_node);
+ if (handle->timeout > loop->time)
+ break;
+
+ uv_timer_stop(handle);
+ uv_timer_again(handle);
+ handle->timer_cb(handle);
+ }
+}
+
+
+void uv__timer_close(uv_timer_t* handle) {
+ uv_timer_stop(handle);
+}
diff --git a/Utilities/cmlibuv/src/unix/aix-common.c b/Utilities/cmlibuv/src/unix/aix-common.c
new file mode 100644
index 000000000..e9697e9c2
--- /dev/null
+++ b/Utilities/cmlibuv/src/unix/aix-common.c
@@ -0,0 +1,298 @@
+/* Copyright libuv project contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "uv.h"
+#include "internal.h"
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <utmp.h>
+#include <libgen.h>
+
+#include <sys/protosw.h>
+#include <procinfo.h>
+#include <sys/proc.h>
+#include <sys/procfs.h>
+
+#include <sys/poll.h>
+
+#include <sys/pollset.h>
+#include <ctype.h>
+
+#include <sys/mntctl.h>
+#include <sys/vmount.h>
+#include <limits.h>
+#include <strings.h>
+#include <sys/vnode.h>
+
+uint64_t uv__hrtime(uv_clocktype_t type) {
+ uint64_t G = 1000000000;
+ timebasestruct_t t;
+ read_wall_time(&t, TIMEBASE_SZ);
+ time_base_to_time(&t, TIMEBASE_SZ);
+ return (uint64_t) t.tb_high * G + t.tb_low;
+}
+
+
+/*
+ * We could use a static buffer for the path manipulations that we need outside
+ * of the function, but this function could be called by multiple consumers and
+ * we don't want to potentially create a race condition in the use of snprintf.
+ * There is no direct way of getting the exe path in AIX - either through /procfs
+ * or through some libc APIs. The below approach is to parse the argv[0]'s pattern
+ * and use it in conjunction with PATH environment variable to craft one.
+ */
+int uv_exepath(char* buffer, size_t* size) {
+ int res;
+ char args[PATH_MAX];
+ char abspath[PATH_MAX];
+ size_t abspath_size;
+ struct procsinfo pi;
+
+ if (buffer == NULL || size == NULL || *size == 0)
+ return UV_EINVAL;
+
+ pi.pi_pid = getpid();
+ res = getargs(&pi, sizeof(pi), args, sizeof(args));
+ if (res < 0)
+ return UV_EINVAL;
+
+ /*
+ * Possibilities for args:
+ * i) an absolute path such as: /home/user/myprojects/nodejs/node
+ * ii) a relative path such as: ./node or ../myprojects/nodejs/node
+ * iii) a bare filename such as "node", after exporting PATH variable
+ * to its location.
+ */
+
+ /* Case i) and ii) absolute or relative paths */
+ if (strchr(args, '/') != NULL) {
+ if (realpath(args, abspath) != abspath)
+ return UV__ERR(errno);
+
+ abspath_size = strlen(abspath);
+
+ *size -= 1;
+ if (*size > abspath_size)
+ *size = abspath_size;
+
+ memcpy(buffer, abspath, *size);
+ buffer[*size] = '\0';
+
+ return 0;
+ } else {
+ /* Case iii). Search PATH environment variable */
+ char trypath[PATH_MAX];
+ char *clonedpath = NULL;
+ char *token = NULL;
+ char *path = getenv("PATH");
+
+ if (path == NULL)
+ return UV_EINVAL;
+
+ clonedpath = uv__strdup(path);
+ if (clonedpath == NULL)
+ return UV_ENOMEM;
+
+ token = strtok(clonedpath, ":");
+ while (token != NULL) {
+ snprintf(trypath, sizeof(trypath) - 1, "%s/%s", token, args);
+ if (realpath(trypath, abspath) == abspath) {
+ /* Check the match is executable */
+ if (access(abspath, X_OK) == 0) {
+ abspath_size = strlen(abspath);
+
+ *size -= 1;
+ if (*size > abspath_size)
+ *size = abspath_size;
+
+ memcpy(buffer, abspath, *size);
+ buffer[*size] = '\0';
+
+ uv__free(clonedpath);
+ return 0;
+ }
+ }
+ token = strtok(NULL, ":");
+ }
+ uv__free(clonedpath);
+
+ /* Out of tokens (path entries), and no match found */
+ return UV_EINVAL;
+ }
+}
+
+void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
+ int i;
+
+ for (i = 0; i < count; ++i) {
+ uv__free(cpu_infos[i].model);
+ }
+
+ uv__free(cpu_infos);
+}
+
+
+int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
+ uv_interface_address_t* address;
+ int sockfd, inet6, size = 1;
+ struct ifconf ifc;
+ struct ifreq *ifr, *p, flg;
+ struct sockaddr_dl* sa_addr;
+
+ *count = 0;
+ *addresses = NULL;
+
+ if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) {
+ return UV__ERR(errno);
+ }
+
+ if (ioctl(sockfd, SIOCGSIZIFCONF, &size) == -1) {
+ uv__close(sockfd);
+ return UV__ERR(errno);
+ }
+
+ ifc.ifc_req = (struct ifreq*)uv__malloc(size);
+ ifc.ifc_len = size;
+ if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) {
+ uv__close(sockfd);
+ return UV__ERR(errno);
+ }
+
+#define ADDR_SIZE(p) MAX((p).sa_len, sizeof(p))
+
+ /* Count all up and running ipv4/ipv6 addresses */
+ ifr = ifc.ifc_req;
+ while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
+ p = ifr;
+ ifr = (struct ifreq*)
+ ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
+
+ if (!(p->ifr_addr.sa_family == AF_INET6 ||
+ p->ifr_addr.sa_family == AF_INET))
+ continue;
+
+ memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
+ if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
+ uv__close(sockfd);
+ return UV__ERR(errno);
+ }
+
+ if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
+ continue;
+
+ (*count)++;
+ }
+
+ if (*count == 0) {
+ uv__close(sockfd);
+ return 0;
+ }
+
+ /* Alloc the return interface structs */
+ *addresses = uv__malloc(*count * sizeof(uv_interface_address_t));
+ if (!(*addresses)) {
+ uv__close(sockfd);
+ return UV_ENOMEM;
+ }
+ address = *addresses;
+
+ ifr = ifc.ifc_req;
+ while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
+ p = ifr;
+ ifr = (struct ifreq*)
+ ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
+
+ if (!(p->ifr_addr.sa_family == AF_INET6 ||
+ p->ifr_addr.sa_family == AF_INET))
+ continue;
+
+ inet6 = (p->ifr_addr.sa_family == AF_INET6);
+
+ memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
+ if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
+ uv__close(sockfd);
+ return UV_ENOSYS;
+ }
+
+ if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
+ continue;
+
+ /* All conditions above must match count loop */
+
+ address->name = uv__strdup(p->ifr_name);
+
+ if (inet6)
+ address->address.address6 = *((struct sockaddr_in6*) &p->ifr_addr);
+ else
+ address->address.address4 = *((struct sockaddr_in*) &p->ifr_addr);
+
+ sa_addr = (struct sockaddr_dl*) &p->ifr_addr;
+ memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
+
+ if (ioctl(sockfd, SIOCGIFNETMASK, p) == -1) {
+ uv__close(sockfd);
+ return UV_ENOSYS;
+ }
+
+ if (inet6)
+ address->netmask.netmask6 = *((struct sockaddr_in6*) &p->ifr_addr);
+ else
+ address->netmask.netmask4 = *((struct sockaddr_in*) &p->ifr_addr);
+
+ address->is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0;
+
+ address++;
+ }
+
+#undef ADDR_SIZE
+
+ uv__close(sockfd);
+ return 0;
+}
+
+
+void uv_free_interface_addresses(uv_interface_address_t* addresses,
+ int count) {
+ int i;
+
+ for (i = 0; i < count; ++i) {
+ uv__free(addresses[i].name);
+ }
+
+ uv__free(addresses);
+}
+
diff --git a/Utilities/cmlibuv/src/unix/aix.c b/Utilities/cmlibuv/src/unix/aix.c
index 388c9cca9..1f36926c0 100644
--- a/Utilities/cmlibuv/src/unix/aix.c
+++ b/Utilities/cmlibuv/src/unix/aix.c
@@ -1,4 +1,5 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
+ *
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
@@ -64,11 +65,18 @@
#define RDWR_BUF_SIZE 4096
#define EQ(a,b) (strcmp(a,b) == 0)
+static uv_mutex_t process_title_mutex;
+static uv_once_t process_title_mutex_once = UV_ONCE_INIT;
static void* args_mem = NULL;
static char** process_argv = NULL;
static int process_argc = 0;
static char* process_title_ptr = NULL;
+static void init_process_title_mutex_once(void) {
+ uv_mutex_init(&process_title_mutex);
+}
+
+
int uv__platform_loop_init(uv_loop_t* loop) {
loop->fs_fd = -1;
@@ -111,7 +119,7 @@ int uv__io_check_fd(uv_loop_t* loop, int fd) {
pc.fd = fd;
if (pollset_ctl(loop->backend_fd, &pc, 1))
- return -errno;
+ return UV__ERR(errno);
pc.cmd = PS_DELETE;
if (pollset_ctl(loop->backend_fd, &pc, 1))
@@ -316,104 +324,6 @@ update_timeout:
}
-uint64_t uv__hrtime(uv_clocktype_t type) {
- uint64_t G = 1000000000;
- timebasestruct_t t;
- read_wall_time(&t, TIMEBASE_SZ);
- time_base_to_time(&t, TIMEBASE_SZ);
- return (uint64_t) t.tb_high * G + t.tb_low;
-}
-
-
-/*
- * We could use a static buffer for the path manipulations that we need outside
- * of the function, but this function could be called by multiple consumers and
- * we don't want to potentially create a race condition in the use of snprintf.
- * There is no direct way of getting the exe path in AIX - either through /procfs
- * or through some libc APIs. The below approach is to parse the argv[0]'s pattern
- * and use it in conjunction with PATH environment variable to craft one.
- */
-int uv_exepath(char* buffer, size_t* size) {
- int res;
- char args[PATH_MAX];
- char abspath[PATH_MAX];
- size_t abspath_size;
- struct procsinfo pi;
-
- if (buffer == NULL || size == NULL || *size == 0)
- return -EINVAL;
-
- pi.pi_pid = getpid();
- res = getargs(&pi, sizeof(pi), args, sizeof(args));
- if (res < 0)
- return -EINVAL;
-
- /*
- * Possibilities for args:
- * i) an absolute path such as: /home/user/myprojects/nodejs/node
- * ii) a relative path such as: ./node or ../myprojects/nodejs/node
- * iii) a bare filename such as "node", after exporting PATH variable
- * to its location.
- */
-
- /* Case i) and ii) absolute or relative paths */
- if (strchr(args, '/') != NULL) {
- if (realpath(args, abspath) != abspath)
- return -errno;
-
- abspath_size = strlen(abspath);
-
- *size -= 1;
- if (*size > abspath_size)
- *size = abspath_size;
-
- memcpy(buffer, abspath, *size);
- buffer[*size] = '\0';
-
- return 0;
- } else {
- /* Case iii). Search PATH environment variable */
- char trypath[PATH_MAX];
- char *clonedpath = NULL;
- char *token = NULL;
- char *path = getenv("PATH");
-
- if (path == NULL)
- return -EINVAL;
-
- clonedpath = uv__strdup(path);
- if (clonedpath == NULL)
- return -ENOMEM;
-
- token = strtok(clonedpath, ":");
- while (token != NULL) {
- snprintf(trypath, sizeof(trypath) - 1, "%s/%s", token, args);
- if (realpath(trypath, abspath) == abspath) {
- /* Check the match is executable */
- if (access(abspath, X_OK) == 0) {
- abspath_size = strlen(abspath);
-
- *size -= 1;
- if (*size > abspath_size)
- *size = abspath_size;
-
- memcpy(buffer, abspath, *size);
- buffer[*size] = '\0';
-
- uv__free(clonedpath);
- return 0;
- }
- }
- token = strtok(NULL, ":");
- }
- uv__free(clonedpath);
-
- /* Out of tokens (path entries), and no match found */
- return -EINVAL;
- }
-}
-
-
uint64_t uv_get_free_memory(void) {
perfstat_memory_total_t mem_total;
int result = perfstat_memory_total(NULL, &mem_total, sizeof(mem_total), 1);
@@ -434,6 +344,11 @@ uint64_t uv_get_total_memory(void) {
}
+uint64_t uv_get_constrained_memory(void) {
+ return 0; /* Memory constraints are unknown. */
+}
+
+
void uv_loadavg(double avg[3]) {
perfstat_cpu_total_t ps_total;
int result = perfstat_cpu_total(NULL, &ps_total, sizeof(ps_total), 1);
@@ -448,19 +363,15 @@ void uv_loadavg(double avg[3]) {
#ifdef HAVE_SYS_AHAFS_EVPRODS_H
-static char *uv__rawname(char *cp) {
- static char rawbuf[FILENAME_MAX+1];
- char *dp = rindex(cp, '/');
+static char* uv__rawname(const char* cp, char (*dst)[FILENAME_MAX+1]) {
+ char* dp;
+ dp = rindex(cp, '/');
if (dp == 0)
return 0;
- *dp = 0;
- strcpy(rawbuf, cp);
- *dp = '/';
- strcat(rawbuf, "/r");
- strcat(rawbuf, dp+1);
- return rawbuf;
+ snprintf(*dst, sizeof(*dst), "%.*s/r%s", (int) (dp - cp), cp, dp + 1);
+ return *dst;
}
@@ -489,6 +400,7 @@ static int uv__path_is_a_directory(char* filename) {
* Returns 0 if AHAFS is mounted, or an error code < 0 on failure
*/
static int uv__is_ahafs_mounted(void){
+ char rawbuf[FILENAME_MAX+1];
int rv, i = 2;
struct vmount *p;
int size_multiplier = 10;
@@ -499,22 +411,22 @@ static int uv__is_ahafs_mounted(void){
p = uv__malloc(siz);
if (p == NULL)
- return -errno;
+ return UV__ERR(errno);
/* Retrieve all mounted filesystems */
rv = mntctl(MCTL_QUERY, siz, (char*)p);
if (rv < 0)
- return -errno;
+ return UV__ERR(errno);
if (rv == 0) {
/* buffer was not large enough, reallocate to correct size */
siz = *(int*)p;
uv__free(p);
p = uv__malloc(siz);
if (p == NULL)
- return -errno;
+ return UV__ERR(errno);
rv = mntctl(MCTL_QUERY, siz, (char*)p);
if (rv < 0)
- return -errno;
+ return UV__ERR(errno);
}
/* Look for dev in filesystems mount info */
@@ -522,7 +434,7 @@ static int uv__is_ahafs_mounted(void){
obj = vmt2dataptr(vmt, VMT_OBJECT); /* device */
stub = vmt2dataptr(vmt, VMT_STUB); /* mount point */
- if (EQ(obj, dev) || EQ(uv__rawname(obj), dev) || EQ(stub, dev)) {
+ if (EQ(obj, dev) || EQ(uv__rawname(obj, &rawbuf), dev) || EQ(stub, dev)) {
uv__free(p); /* Found a match */
return 0;
}
@@ -543,7 +455,8 @@ static int uv__makedir_p(const char *dir) {
size_t len;
int err;
- snprintf(tmp, sizeof(tmp),"%s",dir);
+ /* TODO(bnoordhuis) Check uv__strscpy() return value. */
+ uv__strscpy(tmp, dir, sizeof(tmp));
len = strlen(tmp);
if (tmp[len - 1] == '/')
tmp[len - 1] = 0;
@@ -585,7 +498,7 @@ static int uv__make_subdirs_p(const char *filename) {
rc = uv__makedir_p(cmd);
if (rc == -1 && errno != EEXIST){
- return -errno;
+ return UV__ERR(errno);
}
return rc;
@@ -612,7 +525,7 @@ static int uv__setup_ahafs(const char* filename, int *fd) {
sprintf(mon_file, "/aha/fs/modFile.monFactory");
if ((strlen(mon_file) + strlen(filename) + 5) > PATH_MAX)
- return -ENAMETOOLONG;
+ return UV_ENAMETOOLONG;
/* Make the necessary subdirectories for the monitor file */
rc = uv__make_subdirs_p(filename);
@@ -627,7 +540,7 @@ static int uv__setup_ahafs(const char* filename, int *fd) {
/* Open the monitor file, creating it if necessary */
*fd = open(mon_file, O_CREAT|O_RDWR);
if (*fd < 0)
- return -errno;
+ return UV__ERR(errno);
/* Write out the monitoring specifications.
* In this case, we are monitoring for a state change event type
@@ -647,8 +560,8 @@ static int uv__setup_ahafs(const char* filename, int *fd) {
sprintf(mon_file_write_string, "CHANGED=YES;WAIT_TYPE=WAIT_IN_SELECT;INFO_LVL=1");
rc = write(*fd, mon_file_write_string, strlen(mon_file_write_string)+1);
- if (rc < 0)
- return -errno;
+ if (rc < 0 && errno != EBUSY)
+ return UV__ERR(errno);
return 0;
}
@@ -792,9 +705,9 @@ static void uv__ahafs_event(uv_loop_t* loop, uv__io_t* event_watch, unsigned int
else
p++;
}
- strncpy(fname, p, sizeof(fname) - 1);
- /* Just in case */
- fname[sizeof(fname) - 1] = '\0';
+
+ /* TODO(bnoordhuis) Check uv__strscpy() return value. */
+ uv__strscpy(fname, p, sizeof(fname));
handle->cb(handle, fname, events, 0);
}
@@ -806,7 +719,7 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) {
uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT);
return 0;
#else
- return -ENOSYS;
+ return UV_ENOSYS;
#endif
}
@@ -820,12 +733,19 @@ int uv_fs_event_start(uv_fs_event_t* handle,
char cwd[PATH_MAX];
char absolute_path[PATH_MAX];
char readlink_cwd[PATH_MAX];
+ struct timeval zt;
+ fd_set pollfd;
/* Figure out whether filename is absolute or not */
- if (filename[0] == '/') {
+ if (filename[0] == '\0') {
+ /* Missing a pathname */
+ return UV_ENOENT;
+ }
+ else if (filename[0] == '/') {
/* We have absolute pathname */
- snprintf(absolute_path, sizeof(absolute_path), "%s", filename);
+ /* TODO(bnoordhuis) Check uv__strscpy() return value. */
+ uv__strscpy(absolute_path, filename, sizeof(absolute_path));
} else {
/* We have a relative pathname, compose the absolute pathname */
snprintf(cwd, sizeof(cwd), "/proc/%lu/cwd", (unsigned long) getpid());
@@ -855,12 +775,22 @@ int uv_fs_event_start(uv_fs_event_t* handle,
uv__io_init(&handle->event_watcher, uv__ahafs_event, fd);
handle->path = uv__strdup(filename);
handle->cb = cb;
+ handle->dir_filename = NULL;
uv__io_start(handle->loop, &handle->event_watcher, POLLIN);
+ /* AHAFS wants someone to poll for it to start mointoring.
+ * so kick-start it so that we don't miss an event in the
+ * eventuality of an event that occurs in the current loop. */
+ do {
+ memset(&zt, 0, sizeof(zt));
+ FD_ZERO(&pollfd);
+ FD_SET(fd, &pollfd);
+ rc = select(fd + 1, &pollfd, NULL, NULL, &zt);
+ } while (rc == -1 && errno == EINTR);
return 0;
#else
- return -ENOSYS;
+ return UV_ENOSYS;
#endif
}
@@ -885,7 +815,7 @@ int uv_fs_event_stop(uv_fs_event_t* handle) {
return 0;
#else
- return -ENOSYS;
+ return UV_ENOSYS;
#endif
}
@@ -950,7 +880,10 @@ int uv_set_process_title(const char* title) {
*/
new_title = uv__strdup(title);
if (new_title == NULL)
- return -ENOMEM;
+ return UV_ENOMEM;
+
+ uv_once(&process_title_mutex_once, init_process_title_mutex_once);
+ uv_mutex_lock(&process_title_mutex);
/* If this is the first time this is set,
* don't free and set argv[1] to NULL.
@@ -964,19 +897,30 @@ int uv_set_process_title(const char* title) {
if (process_argc > 1)
process_argv[1] = NULL;
+ uv_mutex_unlock(&process_title_mutex);
+
return 0;
}
int uv_get_process_title(char* buffer, size_t size) {
size_t len;
- len = strlen(process_argv[0]);
if (buffer == NULL || size == 0)
- return -EINVAL;
- else if (size <= len)
- return -ENOBUFS;
+ return UV_EINVAL;
+
+ uv_once(&process_title_mutex_once, init_process_title_mutex_once);
+ uv_mutex_lock(&process_title_mutex);
+
+ len = strlen(process_argv[0]);
+ if (size <= len) {
+ uv_mutex_unlock(&process_title_mutex);
+ return UV_ENOBUFS;
+ }
+
+ memcpy(buffer, process_argv[0], len);
+ buffer[len] = '\0';
- memcpy(buffer, process_argv[0], len + 1);
+ uv_mutex_unlock(&process_title_mutex);
return 0;
}
@@ -998,10 +942,10 @@ int uv_resident_set_memory(size_t* rss) {
fd = open(pp, O_RDONLY);
if (fd == -1)
- return -errno;
+ return UV__ERR(errno);
/* FIXME(bnoordhuis) Handle EINTR. */
- err = -EINVAL;
+ err = UV_EINVAL;
if (read(fd, &psinfo, sizeof(psinfo)) == sizeof(psinfo)) {
*rss = (size_t)psinfo.pr_rssize * 1024;
err = 0;
@@ -1017,6 +961,7 @@ int uv_uptime(double* uptime) {
size_t entries = 0;
time_t boot_time;
+ boot_time = 0;
utmpname(UTMP_FILE);
setutent();
@@ -1031,7 +976,7 @@ int uv_uptime(double* uptime) {
endutent();
if (boot_time == 0)
- return -ENOSYS;
+ return UV_ENOSYS;
*uptime = time(NULL) - boot_time;
return 0;
@@ -1047,30 +992,31 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
result = perfstat_cpu_total(NULL, &ps_total, sizeof(ps_total), 1);
if (result == -1) {
- return -ENOSYS;
+ return UV_ENOSYS;
}
ncpus = result = perfstat_cpu(NULL, NULL, sizeof(perfstat_cpu_t), 0);
if (result == -1) {
- return -ENOSYS;
+ return UV_ENOSYS;
}
ps_cpus = (perfstat_cpu_t*) uv__malloc(ncpus * sizeof(perfstat_cpu_t));
if (!ps_cpus) {
- return -ENOMEM;
+ return UV_ENOMEM;
}
- strcpy(cpu_id.name, FIRST_CPU);
+ /* TODO(bnoordhuis) Check uv__strscpy() return value. */
+ uv__strscpy(cpu_id.name, FIRST_CPU, sizeof(cpu_id.name));
result = perfstat_cpu(&cpu_id, ps_cpus, sizeof(perfstat_cpu_t), ncpus);
if (result == -1) {
uv__free(ps_cpus);
- return -ENOSYS;
+ return UV_ENOSYS;
}
*cpu_infos = (uv_cpu_info_t*) uv__malloc(ncpus * sizeof(uv_cpu_info_t));
if (!*cpu_infos) {
uv__free(ps_cpus);
- return -ENOMEM;
+ return UV_ENOMEM;
}
*count = ncpus;
@@ -1093,130 +1039,6 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
}
-void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
- int i;
-
- for (i = 0; i < count; ++i) {
- uv__free(cpu_infos[i].model);
- }
-
- uv__free(cpu_infos);
-}
-
-
-int uv_interface_addresses(uv_interface_address_t** addresses,
- int* count) {
- uv_interface_address_t* address;
- int sockfd, size = 1;
- struct ifconf ifc;
- struct ifreq *ifr, *p, flg;
-
- *count = 0;
-
- if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) {
- return -errno;
- }
-
- if (ioctl(sockfd, SIOCGSIZIFCONF, &size) == -1) {
- uv__close(sockfd);
- return -errno;
- }
-
- ifc.ifc_req = (struct ifreq*)uv__malloc(size);
- ifc.ifc_len = size;
- if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) {
- uv__close(sockfd);
- return -errno;
- }
-
-#define ADDR_SIZE(p) MAX((p).sa_len, sizeof(p))
-
- /* Count all up and running ipv4/ipv6 addresses */
- ifr = ifc.ifc_req;
- while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
- p = ifr;
- ifr = (struct ifreq*)
- ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
-
- if (!(p->ifr_addr.sa_family == AF_INET6 ||
- p->ifr_addr.sa_family == AF_INET))
- continue;
-
- memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
- if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
- uv__close(sockfd);
- return -errno;
- }
-
- if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
- continue;
-
- (*count)++;
- }
-
- /* Alloc the return interface structs */
- *addresses = (uv_interface_address_t*)
- uv__malloc(*count * sizeof(uv_interface_address_t));
- if (!(*addresses)) {
- uv__close(sockfd);
- return -ENOMEM;
- }
- address = *addresses;
-
- ifr = ifc.ifc_req;
- while ((char*)ifr < (char*)ifc.ifc_req + ifc.ifc_len) {
- p = ifr;
- ifr = (struct ifreq*)
- ((char*)ifr + sizeof(ifr->ifr_name) + ADDR_SIZE(ifr->ifr_addr));
-
- if (!(p->ifr_addr.sa_family == AF_INET6 ||
- p->ifr_addr.sa_family == AF_INET))
- continue;
-
- memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
- if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
- uv__close(sockfd);
- return -ENOSYS;
- }
-
- if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
- continue;
-
- /* All conditions above must match count loop */
-
- address->name = uv__strdup(p->ifr_name);
-
- if (p->ifr_addr.sa_family == AF_INET6) {
- address->address.address6 = *((struct sockaddr_in6*) &p->ifr_addr);
- } else {
- address->address.address4 = *((struct sockaddr_in*) &p->ifr_addr);
- }
-
- /* TODO: Retrieve netmask using SIOCGIFNETMASK ioctl */
-
- address->is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0;
-
- address++;
- }
-
-#undef ADDR_SIZE
-
- uv__close(sockfd);
- return 0;
-}
-
-
-void uv_free_interface_addresses(uv_interface_address_t* addresses,
- int count) {
- int i;
-
- for (i = 0; i < count; ++i) {
- uv__free(addresses[i].name);
- }
-
- uv__free(addresses);
-}
-
void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
struct pollfd* events;
uintptr_t i;
@@ -1224,6 +1046,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
struct poll_ctl pc;
assert(loop->watchers != NULL);
+ assert(fd >= 0);
events = (struct pollfd*) loop->watchers[loop->nwatchers];
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
diff --git a/Utilities/cmlibuv/src/unix/android-ifaddrs.c b/Utilities/cmlibuv/src/unix/android-ifaddrs.c
index 30f681b7d..99fb25a43 100644
--- a/Utilities/cmlibuv/src/unix/android-ifaddrs.c
+++ b/Utilities/cmlibuv/src/unix/android-ifaddrs.c
@@ -23,7 +23,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "android-ifaddrs.h"
+#include "uv/android-ifaddrs.h"
#include "uv-common.h"
#include <string.h>
@@ -43,9 +43,10 @@ typedef struct NetlinkList
unsigned int m_size;
} NetlinkList;
-static int netlink_socket(void)
+static int netlink_socket(pid_t *p_pid)
{
struct sockaddr_nl l_addr;
+ socklen_t l_len;
int l_socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if(l_socket < 0)
@@ -61,6 +62,14 @@ static int netlink_socket(void)
return -1;
}
+ l_len = sizeof(l_addr);
+ if(getsockname(l_socket, (struct sockaddr *)&l_addr, &l_len) < 0)
+ {
+ close(l_socket);
+ return -1;
+ }
+ *p_pid = l_addr.nl_pid;
+
return l_socket;
}
@@ -128,7 +137,7 @@ static int netlink_recv(int p_socket, void *p_buffer, size_t p_len)
}
}
-static struct nlmsghdr *getNetlinkResponse(int p_socket, int *p_size, int *p_done)
+static struct nlmsghdr *getNetlinkResponse(int p_socket, pid_t p_pid, int *p_size, int *p_done)
{
size_t l_size = 4096;
void *l_buffer = NULL;
@@ -153,11 +162,10 @@ static struct nlmsghdr *getNetlinkResponse(int p_socket, int *p_size, int *p_don
}
if(l_read >= 0)
{
- pid_t l_pid = getpid();
struct nlmsghdr *l_hdr;
for(l_hdr = (struct nlmsghdr *)l_buffer; NLMSG_OK(l_hdr, (unsigned int)l_read); l_hdr = (struct nlmsghdr *)NLMSG_NEXT(l_hdr, l_read))
{
- if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket)
+ if((pid_t)l_hdr->nlmsg_pid != p_pid || (int)l_hdr->nlmsg_seq != p_socket)
{
continue;
}
@@ -207,7 +215,7 @@ static void freeResultList(NetlinkList *p_list)
}
}
-static NetlinkList *getResultList(int p_socket, int p_request)
+static NetlinkList *getResultList(int p_socket, int p_request, pid_t p_pid)
{
int l_size;
int l_done;
@@ -227,7 +235,7 @@ static NetlinkList *getResultList(int p_socket, int p_request)
{
NetlinkList *l_item;
- struct nlmsghdr *l_hdr = getNetlinkResponse(p_socket, &l_size, &l_done);
+ struct nlmsghdr *l_hdr = getNetlinkResponse(p_socket, p_pid, &l_size, &l_done);
/* Error */
if(!l_hdr)
{
@@ -449,7 +457,7 @@ static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList,
char *l_name;
char *l_addr;
- for(l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize))
+ for(l_rta = IFA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize))
{
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta);
if(l_info->ifa_family == AF_PACKET)
@@ -471,7 +479,7 @@ static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList,
l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize));
break;
case IFA_LABEL:
- l_nameSize += NLMSG_ALIGN(l_rtaSize + 1);
+ l_nameSize += NLMSG_ALIGN(l_rtaDataSize + 1);
break;
default:
break;
@@ -496,7 +504,7 @@ static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList,
}
l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg));
- for(l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize))
+ for(l_rta = IFA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize))
{
void *l_rtaData = RTA_DATA(l_rta);
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta);
@@ -559,7 +567,7 @@ static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList,
{
unsigned l_maxPrefix = (l_entry->ifa_addr->sa_family == AF_INET ? 32 : 128);
unsigned l_prefix = (l_info->ifa_prefixlen > l_maxPrefix ? l_maxPrefix : l_info->ifa_prefixlen);
- char l_mask[16] = {0};
+ unsigned char l_mask[16] = {0};
unsigned i;
for(i=0; i<(l_prefix/8); ++i)
{
@@ -578,18 +586,17 @@ static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList,
return 0;
}
-static int interpretLinks(int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList)
+static int interpretLinks(int p_socket, pid_t p_pid, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList)
{
int l_numLinks = 0;
- pid_t l_pid = getpid();
for(; p_netlinkList; p_netlinkList = p_netlinkList->m_next)
{
unsigned int l_nlsize = p_netlinkList->m_size;
struct nlmsghdr *l_hdr;
for(l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize))
{
- if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket)
+ if((pid_t)l_hdr->nlmsg_pid != p_pid || (int)l_hdr->nlmsg_seq != p_socket)
{
continue;
}
@@ -612,16 +619,15 @@ static int interpretLinks(int p_socket, NetlinkList *p_netlinkList, struct ifadd
return l_numLinks;
}
-static int interpretAddrs(int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList, int p_numLinks)
+static int interpretAddrs(int p_socket, pid_t p_pid, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList, int p_numLinks)
{
- pid_t l_pid = getpid();
for(; p_netlinkList; p_netlinkList = p_netlinkList->m_next)
{
unsigned int l_nlsize = p_netlinkList->m_size;
struct nlmsghdr *l_hdr;
for(l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize))
{
- if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket)
+ if((pid_t)l_hdr->nlmsg_pid != p_pid || (int)l_hdr->nlmsg_seq != p_socket)
{
continue;
}
@@ -648,6 +654,7 @@ int getifaddrs(struct ifaddrs **ifap)
int l_socket;
int l_result;
int l_numLinks;
+ pid_t l_pid;
NetlinkList *l_linkResults;
NetlinkList *l_addrResults;
@@ -657,20 +664,20 @@ int getifaddrs(struct ifaddrs **ifap)
}
*ifap = NULL;
- l_socket = netlink_socket();
+ l_socket = netlink_socket(&l_pid);
if(l_socket < 0)
{
return -1;
}
- l_linkResults = getResultList(l_socket, RTM_GETLINK);
+ l_linkResults = getResultList(l_socket, RTM_GETLINK, l_pid);
if(!l_linkResults)
{
close(l_socket);
return -1;
}
- l_addrResults = getResultList(l_socket, RTM_GETADDR);
+ l_addrResults = getResultList(l_socket, RTM_GETADDR, l_pid);
if(!l_addrResults)
{
close(l_socket);
@@ -679,8 +686,8 @@ int getifaddrs(struct ifaddrs **ifap)
}
l_result = 0;
- l_numLinks = interpretLinks(l_socket, l_linkResults, ifap);
- if(l_numLinks == -1 || interpretAddrs(l_socket, l_addrResults, ifap, l_numLinks) == -1)
+ l_numLinks = interpretLinks(l_socket, l_pid, l_linkResults, ifap);
+ if(l_numLinks == -1 || interpretAddrs(l_socket, l_pid, l_addrResults, ifap, l_numLinks) == -1)
{
l_result = -1;
}
diff --git a/Utilities/cmlibuv/src/unix/async.c b/Utilities/cmlibuv/src/unix/async.c
index 45c088ea1..a5c47bca0 100644
--- a/Utilities/cmlibuv/src/unix/async.c
+++ b/Utilities/cmlibuv/src/unix/async.c
@@ -61,14 +61,43 @@ int uv_async_send(uv_async_t* handle) {
if (ACCESS_ONCE(int, handle->pending) != 0)
return 0;
- if (cmpxchgi(&handle->pending, 0, 1) == 0)
- uv__async_send(handle->loop);
+ /* Tell the other thread we're busy with the handle. */
+ if (cmpxchgi(&handle->pending, 0, 1) != 0)
+ return 0;
+
+ /* Wake up the other thread's event loop. */
+ uv__async_send(handle->loop);
+
+ /* Tell the other thread we're done. */
+ if (cmpxchgi(&handle->pending, 1, 2) != 1)
+ abort();
return 0;
}
+/* Only call this from the event loop thread. */
+static int uv__async_spin(uv_async_t* handle) {
+ int rc;
+
+ for (;;) {
+ /* rc=0 -- handle is not pending.
+ * rc=1 -- handle is pending, other thread is still working with it.
+ * rc=2 -- handle is pending, other thread is done.
+ */
+ rc = cmpxchgi(&handle->pending, 2, 0);
+
+ if (rc != 1)
+ return rc;
+
+ /* Other thread is busy with this handle, spin until it's done. */
+ cpu_relax();
+ }
+}
+
+
void uv__async_close(uv_async_t* handle) {
+ uv__async_spin(handle);
QUEUE_REMOVE(&handle->queue);
uv__handle_stop(handle);
}
@@ -109,8 +138,8 @@ static void uv__async_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
QUEUE_REMOVE(q);
QUEUE_INSERT_TAIL(&loop->async_handles, q);
- if (cmpxchgi(&h->pending, 1, 0) == 0)
- continue;
+ if (0 == uv__async_spin(h))
+ continue; /* Not pending. */
if (h->async_cb == NULL)
continue;
@@ -166,7 +195,7 @@ static int uv__async_start(uv_loop_t* loop) {
pipefd[0] = err;
pipefd[1] = -1;
}
- else if (err == -ENOSYS) {
+ else if (err == UV_ENOSYS) {
err = uv__make_pipe(pipefd, UV__F_NONBLOCK);
#if defined(__linux__)
/* Save a file descriptor by opening one of the pipe descriptors as
@@ -240,7 +269,7 @@ static int uv__async_eventfd(void) {
return fd;
if (errno != ENOSYS)
- return -errno;
+ return UV__ERR(errno);
no_eventfd2 = 1;
@@ -257,7 +286,7 @@ skip_eventfd2:
}
if (errno != ENOSYS)
- return -errno;
+ return UV__ERR(errno);
no_eventfd = 1;
@@ -265,5 +294,5 @@ skip_eventfd:
#endif
- return -ENOSYS;
+ return UV_ENOSYS;
}
diff --git a/Utilities/cmlibuv/src/unix/atomic-ops.h b/Utilities/cmlibuv/src/unix/atomic-ops.h
index 9dac2557f..995aca63a 100644
--- a/Utilities/cmlibuv/src/unix/atomic-ops.h
+++ b/Utilities/cmlibuv/src/unix/atomic-ops.h
@@ -20,11 +20,9 @@
#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
#include <atomic.h>
-#define __sync_val_compare_and_swap(p, o, n) atomic_cas_ptr(p, o, n)
#endif
UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval));
-UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval));
UV_UNUSED(static void cpu_relax(void));
/* Prefer hand-rolled assembly over the gcc builtins because the latter also
@@ -38,7 +36,7 @@ UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) {
: "r" (newval), "0" (oldval)
: "memory");
return out;
-#elif defined(_AIX) && defined(__xlC__)
+#elif defined(_AIX) && (defined(__xlC__) || defined(__ibmxl__))
const int out = (*(volatile int*) ptr);
__compare_and_swap(ptr, &oldval, newval);
return out;
@@ -49,40 +47,8 @@ UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) {
return oldval;
else
return op4;
-#else
- return __sync_val_compare_and_swap(ptr, oldval, newval);
-#endif
-}
-
-UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)) {
-#if defined(__i386__) || defined(__x86_64__)
- long out;
- __asm__ __volatile__ ("lock; cmpxchg %2, %1;"
- : "=a" (out), "+m" (*(volatile long*) ptr)
- : "r" (newval), "0" (oldval)
- : "memory");
- return out;
-#elif defined(_AIX) && defined(__xlC__)
- const long out = (*(volatile int*) ptr);
-# if defined(__64BIT__)
- __compare_and_swaplp(ptr, &oldval, newval);
-# else
- __compare_and_swap(ptr, &oldval, newval);
-# endif /* if defined(__64BIT__) */
- return out;
-#elif defined (__MVS__)
-#ifdef _LP64
- unsigned long long op4;
- if (__plo_CSSTGR(ptr, (unsigned long long*) &oldval, newval,
- (unsigned long long*) ptr, *ptr, &op4))
-#else
- unsigned long op4;
- if (__plo_CSST(ptr, (unsigned int*) &oldval, newval,
- (unsigned int*) ptr, *ptr, &op4))
-#endif
- return oldval;
- else
- return op4;
+#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+ return atomic_cas_uint((uint_t *)ptr, (uint_t)oldval, (uint_t)newval);
#else
return __sync_val_compare_and_swap(ptr, oldval, newval);
#endif
diff --git a/Utilities/cmlibuv/src/unix/bsd-ifaddrs.c b/Utilities/cmlibuv/src/unix/bsd-ifaddrs.c
index 414789451..0d7bbe662 100644
--- a/Utilities/cmlibuv/src/unix/bsd-ifaddrs.c
+++ b/Utilities/cmlibuv/src/unix/bsd-ifaddrs.c
@@ -31,12 +31,26 @@
#include <net/if_dl.h>
#endif
-static int uv__ifaddr_exclude(struct ifaddrs *ent) {
+#if defined(__HAIKU__)
+#define IFF_RUNNING IFF_LINK
+#endif
+
+static int uv__ifaddr_exclude(struct ifaddrs *ent, int exclude_type) {
if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)))
return 1;
if (ent->ifa_addr == NULL)
return 1;
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)
+#if !defined(__CYGWIN__) && !defined(__MSYS__)
+ /*
+ * If `exclude_type` is `UV__EXCLUDE_IFPHYS`, just see whether `sa_family`
+ * equals to `AF_LINK` or not. Otherwise, the result depends on the operation
+ * system with `AF_LINK` or `PF_INET`.
+ */
+ if (exclude_type == UV__EXCLUDE_IFPHYS)
+ return (ent->ifa_addr->sa_family != AF_LINK);
+#endif
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || \
+ defined(__HAIKU__)
/*
* On BSD getifaddrs returns information related to the raw underlying
* devices. We're not interested in this information.
@@ -44,7 +58,8 @@ static int uv__ifaddr_exclude(struct ifaddrs *ent) {
if (ent->ifa_addr->sa_family == AF_LINK)
return 1;
#elif defined(__NetBSD__) || defined(__OpenBSD__)
- if (ent->ifa_addr->sa_family != PF_INET)
+ if (ent->ifa_addr->sa_family != PF_INET &&
+ ent->ifa_addr->sa_family != PF_INET6)
return 1;
#endif
return 0;
@@ -56,29 +71,36 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
uv_interface_address_t* address;
int i;
- if (getifaddrs(&addrs) != 0)
- return -errno;
-
*count = 0;
+ *addresses = NULL;
+
+ if (getifaddrs(&addrs) != 0)
+ return UV__ERR(errno);
/* Count the number of interfaces */
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (uv__ifaddr_exclude(ent))
+ if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR))
continue;
(*count)++;
}
- *addresses = uv__malloc(*count * sizeof(**addresses));
+ if (*count == 0) {
+ freeifaddrs(addrs);
+ return 0;
+ }
+
+ /* Make sure the memory is initiallized to zero using calloc() */
+ *addresses = uv__calloc(*count, sizeof(**addresses));
if (*addresses == NULL) {
freeifaddrs(addrs);
- return -ENOMEM;
+ return UV_ENOMEM;
}
address = *addresses;
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (uv__ifaddr_exclude(ent))
+ if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR))
continue;
address->name = uv__strdup(ent->ifa_name);
@@ -100,26 +122,24 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
address++;
}
+#if !(defined(__CYGWIN__) || defined(__MSYS__))
/* Fill in physical addresses for each interface */
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (uv__ifaddr_exclude(ent))
+ if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFPHYS))
continue;
address = *addresses;
for (i = 0; i < *count; i++) {
if (strcmp(address->name, ent->ifa_name) == 0) {
-#if defined(__CYGWIN__) || defined(__MSYS__)
- memset(address->phys_addr, 0, sizeof(address->phys_addr));
-#else
struct sockaddr_dl* sa_addr;
sa_addr = (struct sockaddr_dl*)(ent->ifa_addr);
memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
-#endif
}
address++;
}
}
+#endif
freeifaddrs(addrs);
diff --git a/Utilities/cmlibuv/src/unix/bsd-proctitle.c b/Utilities/cmlibuv/src/unix/bsd-proctitle.c
new file mode 100644
index 000000000..0ce47c8f6
--- /dev/null
+++ b/Utilities/cmlibuv/src/unix/bsd-proctitle.c
@@ -0,0 +1,93 @@
+/* Copyright libuv project contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "uv.h"
+#include "internal.h"
+
+#include <sys/types.h>
+#include <unistd.h>
+
+
+static uv_mutex_t process_title_mutex;
+static uv_once_t process_title_mutex_once = UV_ONCE_INIT;
+static char* process_title;
+
+
+static void init_process_title_mutex_once(void) {
+ if (uv_mutex_init(&process_title_mutex))
+ abort();
+}
+
+
+char** uv_setup_args(int argc, char** argv) {
+ process_title = argc > 0 ? uv__strdup(argv[0]) : NULL;
+ return argv;
+}
+
+
+int uv_set_process_title(const char* title) {
+ char* new_title;
+
+ new_title = uv__strdup(title);
+ if (new_title == NULL)
+ return UV_ENOMEM;
+
+ uv_once(&process_title_mutex_once, init_process_title_mutex_once);
+ uv_mutex_lock(&process_title_mutex);
+
+ uv__free(process_title);
+ process_title = new_title;
+ setproctitle("%s", title);
+
+ uv_mutex_unlock(&process_title_mutex);
+
+ return 0;
+}
+
+
+int uv_get_process_title(char* buffer, size_t size) {
+ size_t len;
+
+ if (buffer == NULL || size == 0)
+ return UV_EINVAL;
+
+ uv_once(&process_title_mutex_once, init_process_title_mutex_once);
+ uv_mutex_lock(&process_title_mutex);
+
+ if (process_title != NULL) {
+ len = strlen(process_title) + 1;
+
+ if (size < len) {
+ uv_mutex_unlock(&process_title_mutex);
+ return UV_ENOBUFS;
+ }
+
+ memcpy(buffer, process_title, len);
+ } else {
+ len = 0;
+ }
+
+ uv_mutex_unlock(&process_title_mutex);
+
+ buffer[len] = '\0';
+
+ return 0;
+}
diff --git a/Utilities/cmlibuv/src/unix/cmake-bootstrap.c b/Utilities/cmlibuv/src/unix/cmake-bootstrap.c
new file mode 100644
index 000000000..d42ff05c5
--- /dev/null
+++ b/Utilities/cmlibuv/src/unix/cmake-bootstrap.c
@@ -0,0 +1,149 @@
+#include "uv.h"
+#include "internal.h"
+
+int uv__tcp_nodelay(int fd, int on) {
+ errno = EINVAL;
+ return -1;
+}
+
+int uv__tcp_keepalive(int fd, int on, unsigned int delay) {
+ errno = EINVAL;
+ return -1;
+}
+
+int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
+ return -EINVAL;
+}
+
+int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) {
+ return -EINVAL;
+}
+
+void uv__tcp_close(uv_tcp_t* handle) {
+}
+
+void uv__udp_close(uv_udp_t* handle) {
+}
+
+void uv__udp_finish_close(uv_udp_t* handle) {
+}
+
+void uv__fs_poll_close(uv_fs_poll_t* handle) {
+}
+
+int uv_async_init(uv_loop_t* loop, uv_async_t* handle, uv_async_cb async_cb) {
+ return 0;
+}
+
+void uv__async_close(uv_async_t* handle) {
+}
+
+int uv__async_fork(uv_loop_t* loop) {
+ return 0;
+}
+
+void uv__async_stop(uv_loop_t* loop) {
+}
+
+void uv__work_submit(uv_loop_t* loop, struct uv__work* w,
+ enum uv__work_kind kind,
+ void (*work)(struct uv__work* w),
+ void (*done)(struct uv__work* w, int status)) {
+ abort();
+}
+
+void uv__work_done(uv_async_t* handle) {
+}
+
+int uv__pthread_atfork(void (*prepare)(void), void (*parent)(void),
+ void (*child)(void)) {
+ return 0;
+}
+
+int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset) {
+ return 0;
+}
+
+int uv_mutex_init(uv_mutex_t* mutex) {
+ return 0;
+}
+
+void uv_mutex_destroy(uv_mutex_t* mutex) {
+}
+
+void uv_mutex_lock(uv_mutex_t* mutex) {
+}
+
+void uv_mutex_unlock(uv_mutex_t* mutex) {
+}
+
+int uv_rwlock_init(uv_rwlock_t* rwlock) {
+ return 0;
+}
+
+void uv_rwlock_destroy(uv_rwlock_t* rwlock) {
+}
+
+void uv_rwlock_wrlock(uv_rwlock_t* rwlock) {
+}
+
+void uv_rwlock_wrunlock(uv_rwlock_t* rwlock) {
+}
+
+void uv_rwlock_rdlock(uv_rwlock_t* rwlock) {
+}
+
+void uv_rwlock_rdunlock(uv_rwlock_t* rwlock) {
+}
+
+void uv_once(uv_once_t* guard, void (*callback)(void)) {
+ if (*guard) {
+ return;
+ }
+ *guard = 1;
+ callback();
+}
+
+#if defined(__linux__)
+int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags) {
+ errno = ENOSYS;
+ return -1;
+}
+
+int uv__dup3(int oldfd, int newfd, int flags) {
+ errno = ENOSYS;
+ return -1;
+}
+
+int uv__pipe2(int pipefd[2], int flags) {
+ errno = ENOSYS;
+ return -1;
+}
+
+ssize_t uv__preadv(int fd, const struct iovec *iov, int iovcnt,
+ int64_t offset) {
+ errno = ENOSYS;
+ return -1;
+}
+
+ssize_t uv__pwritev(int fd, const struct iovec *iov, int iovcnt,
+ int64_t offset) {
+ errno = ENOSYS;
+ return -1;
+}
+
+int uv__utimesat(int dirfd, const char* path, const struct timespec times[2],
+ int flags) {
+ errno = ENOSYS;
+ return -1;
+}
+
+int uv__statx(int dirfd,
+ const char* path,
+ int flags,
+ unsigned int mask,
+ struct uv__statx* statxbuf) {
+ errno = ENOSYS;
+ return -1;
+}
+#endif
diff --git a/Utilities/cmlibuv/src/unix/core.c b/Utilities/cmlibuv/src/unix/core.c
index 30cdaef7b..cf7dea050 100644
--- a/Utilities/cmlibuv/src/unix/core.c
+++ b/Utilities/cmlibuv/src/unix/core.c
@@ -28,7 +28,6 @@
#include <errno.h>
#include <assert.h>
#include <unistd.h>
-#include <sys/param.h> /* MAXHOSTNAMELEN on Linux and the BSDs */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -41,9 +40,11 @@
#include <sys/uio.h> /* writev */
#include <sys/resource.h> /* getrusage */
#include <pwd.h>
+#include <sched.h>
+#include <sys/utsname.h>
+#include <sys/time.h>
#ifdef __sun
-# include <netdb.h> /* MAXHOSTNAMELEN on Solaris */
# include <sys/filio.h>
# include <sys/types.h>
# include <sys/wait.h>
@@ -59,13 +60,21 @@
#if defined(__DragonFly__) || \
defined(__FreeBSD__) || \
- defined(__FreeBSD_kernel__)
+ defined(__FreeBSD_kernel__) || \
+ defined(__NetBSD__)
# include <sys/sysctl.h>
# include <sys/filio.h>
# include <sys/wait.h>
+# include <sys/param.h>
+# include <sys/cpuset.h>
# define UV__O_CLOEXEC O_CLOEXEC
# if defined(__FreeBSD__) && __FreeBSD__ >= 10
# define uv__accept4 accept4
+# endif
+# if defined(__NetBSD__)
+# define uv__accept4(a, b, c, d) paccept((a), (b), (c), NULL, (d))
+# endif
+# if (defined(__FreeBSD__) && __FreeBSD__ >= 10) || defined(__NetBSD__)
# define UV__SOCK_NONBLOCK SOCK_NONBLOCK
# define UV__SOCK_CLOEXEC SOCK_CLOEXEC
# endif
@@ -82,9 +91,8 @@
#include <sys/ioctl.h>
#endif
-/* Fallback for the maximum hostname length */
-#ifndef MAXHOSTNAMELEN
-# define MAXHOSTNAMELEN 256
+#if defined(__linux__)
+#include <sys/syscall.h>
#endif
static int uv__run_pending(uv_loop_t* loop);
@@ -107,7 +115,7 @@ uint64_t uv_hrtime(void) {
void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
assert(!uv__is_closing(handle));
- handle->flags |= UV_CLOSING;
+ handle->flags |= UV_HANDLE_CLOSING;
handle->close_cb = close_cb;
switch (handle->type) {
@@ -161,12 +169,14 @@ void uv_close(uv_handle_t* handle, uv_close_cb close_cb) {
case UV_FS_POLL:
uv__fs_poll_close((uv_fs_poll_t*)handle);
- break;
+ /* Poll handles use file system requests, and one of them may still be
+ * running. The poll code will call uv__make_close_pending() for us. */
+ return;
case UV_SIGNAL:
uv__signal_close((uv_signal_t*) handle);
- /* Signal handles may not be closed immediately. The signal code will */
- /* itself close uv__make_close_pending whenever appropriate. */
+ /* Signal handles may not be closed immediately. The signal code will
+ * itself close uv__make_close_pending whenever appropriate. */
return;
default:
@@ -182,14 +192,14 @@ int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value) {
socklen_t len;
if (handle == NULL || value == NULL)
- return -EINVAL;
+ return UV_EINVAL;
if (handle->type == UV_TCP || handle->type == UV_NAMED_PIPE)
fd = uv__stream_fd((uv_stream_t*) handle);
else if (handle->type == UV_UDP)
fd = ((uv_udp_t *) handle)->io_watcher.fd;
else
- return -ENOTSUP;
+ return UV_ENOTSUP;
len = sizeof(*value);
@@ -199,14 +209,14 @@ int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value) {
r = setsockopt(fd, SOL_SOCKET, optname, (const void*) value, len);
if (r < 0)
- return -errno;
+ return UV__ERR(errno);
return 0;
}
void uv__make_close_pending(uv_handle_t* handle) {
- assert(handle->flags & UV_CLOSING);
- assert(!(handle->flags & UV_CLOSED));
+ assert(handle->flags & UV_HANDLE_CLOSING);
+ assert(!(handle->flags & UV_HANDLE_CLOSED));
handle->next_closing = handle->loop->closing_handles;
handle->loop->closing_handles = handle;
}
@@ -232,15 +242,17 @@ int uv__getiovmax(void) {
static void uv__finish_close(uv_handle_t* handle) {
- /* Note: while the handle is in the UV_CLOSING state now, it's still possible
- * for it to be active in the sense that uv__is_active() returns true.
+ /* Note: while the handle is in the UV_HANDLE_CLOSING state now, it's still
+ * possible for it to be active in the sense that uv__is_active() returns
+ * true.
+ *
* A good example is when the user calls uv_shutdown(), immediately followed
* by uv_close(). The handle is considered active at this point because the
* completion of the shutdown req is still pending.
*/
- assert(handle->flags & UV_CLOSING);
- assert(!(handle->flags & UV_CLOSED));
- handle->flags |= UV_CLOSED;
+ assert(handle->flags & UV_HANDLE_CLOSING);
+ assert(!(handle->flags & UV_HANDLE_CLOSED));
+ handle->flags |= UV_HANDLE_CLOSED;
switch (handle->type) {
case UV_PREPARE:
@@ -409,12 +421,12 @@ int uv__socket(int domain, int type, int protocol) {
return sockfd;
if (errno != EINVAL)
- return -errno;
+ return UV__ERR(errno);
#endif
sockfd = socket(domain, type, protocol);
if (sockfd == -1)
- return -errno;
+ return UV__ERR(errno);
err = uv__nonblock(sockfd, 1);
if (err == 0)
@@ -459,7 +471,9 @@ int uv__accept(int sockfd) {
assert(sockfd >= 0);
while (1) {
-#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 10)
+#if defined(__linux__) || \
+ (defined(__FreeBSD__) && __FreeBSD__ >= 10) || \
+ defined(__NetBSD__)
static int no_accept4;
if (no_accept4)
@@ -476,7 +490,7 @@ int uv__accept(int sockfd) {
continue;
if (errno != ENOSYS)
- return -errno;
+ return UV__ERR(errno);
no_accept4 = 1;
skip:
@@ -486,7 +500,7 @@ skip:
if (peerfd == -1) {
if (errno == EINTR)
continue;
- return -errno;
+ return UV__ERR(errno);
}
err = uv__cloexec(peerfd, 1);
@@ -503,6 +517,34 @@ skip:
}
+/* close() on macos has the "interesting" quirk that it fails with EINTR
+ * without closing the file descriptor when a thread is in the cancel state.
+ * That's why libuv calls close$NOCANCEL() instead.
+ *
+ * glibc on linux has a similar issue: close() is a cancellation point and
+ * will unwind the thread when it's in the cancel state. Work around that
+ * by making the system call directly. Musl libc is unaffected.
+ */
+int uv__close_nocancel(int fd) {
+#if defined(__APPLE__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
+#if defined(__LP64__)
+ extern int close$NOCANCEL(int);
+ return close$NOCANCEL(fd);
+#else
+ extern int close$NOCANCEL$UNIX2003(int);
+ return close$NOCANCEL$UNIX2003(fd);
+#endif
+#pragma GCC diagnostic pop
+#elif defined(__linux__)
+ return syscall(SYS_close, fd);
+#else
+ return close(fd);
+#endif
+}
+
+
int uv__close_nocheckstdio(int fd) {
int saved_errno;
int rc;
@@ -510,10 +552,10 @@ int uv__close_nocheckstdio(int fd) {
assert(fd > -1); /* Catch uninitialized io_watcher.fd bugs. */
saved_errno = errno;
- rc = close(fd);
+ rc = uv__close_nocancel(fd);
if (rc == -1) {
- rc = -errno;
- if (rc == -EINTR || rc == -EINPROGRESS)
+ rc = UV__ERR(errno);
+ if (rc == UV_EINTR || rc == UV__ERR(EINPROGRESS))
rc = 0; /* The close is in progress, not an error. */
errno = saved_errno;
}
@@ -525,7 +567,7 @@ int uv__close_nocheckstdio(int fd) {
int uv__close(int fd) {
assert(fd > STDERR_FILENO); /* Catch stdio close bugs. */
#if defined(__MVS__)
- epoll_file_close(fd);
+ SAVE_ERRNO(epoll_file_close(fd));
#endif
return uv__close_nocheckstdio(fd);
}
@@ -539,13 +581,13 @@ int uv__nonblock_ioctl(int fd, int set) {
while (r == -1 && errno == EINTR);
if (r)
- return -errno;
+ return UV__ERR(errno);
return 0;
}
-#if !defined(__CYGWIN__) && !defined(__MSYS__)
+#if !defined(__hpux) && !defined(__CYGWIN__) && !defined(__MSYS__) && !defined(__HAIKU__)
int uv__cloexec_ioctl(int fd, int set) {
int r;
@@ -554,7 +596,7 @@ int uv__cloexec_ioctl(int fd, int set) {
while (r == -1 && errno == EINTR);
if (r)
- return -errno;
+ return UV__ERR(errno);
return 0;
}
@@ -570,7 +612,7 @@ int uv__nonblock_fcntl(int fd, int set) {
while (r == -1 && errno == EINTR);
if (r == -1)
- return -errno;
+ return UV__ERR(errno);
/* Bail out now if already set/clear. */
if (!!(r & O_NONBLOCK) == !!set)
@@ -586,7 +628,7 @@ int uv__nonblock_fcntl(int fd, int set) {
while (r == -1 && errno == EINTR);
if (r)
- return -errno;
+ return UV__ERR(errno);
return 0;
}
@@ -601,7 +643,7 @@ int uv__cloexec_fcntl(int fd, int set) {
while (r == -1 && errno == EINTR);
if (r == -1)
- return -errno;
+ return UV__ERR(errno);
/* Bail out now if already set/clear. */
if (!!(r & FD_CLOEXEC) == !!set)
@@ -617,33 +659,12 @@ int uv__cloexec_fcntl(int fd, int set) {
while (r == -1 && errno == EINTR);
if (r)
- return -errno;
+ return UV__ERR(errno);
return 0;
}
-/* This function is not execve-safe, there is a race window
- * between the call to dup() and fcntl(FD_CLOEXEC).
- */
-int uv__dup(int fd) {
- int err;
-
- fd = dup(fd);
-
- if (fd == -1)
- return -errno;
-
- err = uv__cloexec(fd, 1);
- if (err) {
- uv__close(fd);
- return err;
- }
-
- return fd;
-}
-
-
ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) {
struct cmsghdr* cmsg;
ssize_t rc;
@@ -656,10 +677,10 @@ ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) {
if (rc != -1)
return rc;
if (errno != EINVAL)
- return -errno;
+ return UV__ERR(errno);
rc = recvmsg(fd, msg, flags);
if (rc == -1)
- return -errno;
+ return UV__ERR(errno);
no_msg_cmsg_cloexec = 1;
} else {
rc = recvmsg(fd, msg, flags);
@@ -668,7 +689,7 @@ ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) {
rc = recvmsg(fd, msg, flags);
#endif
if (rc == -1)
- return -errno;
+ return UV__ERR(errno);
if (msg->msg_controllen == 0)
return rc;
for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg))
@@ -684,10 +705,10 @@ ssize_t uv__recvmsg(int fd, struct msghdr* msg, int flags) {
int uv_cwd(char* buffer, size_t* size) {
if (buffer == NULL || size == NULL)
- return -EINVAL;
+ return UV_EINVAL;
if (getcwd(buffer, *size) == NULL)
- return -errno;
+ return UV__ERR(errno);
*size = strlen(buffer);
if (*size > 1 && buffer[*size - 1] == '/') {
@@ -701,7 +722,7 @@ int uv_cwd(char* buffer, size_t* size) {
int uv_chdir(const char* dir) {
if (chdir(dir))
- return -errno;
+ return UV__ERR(errno);
return 0;
}
@@ -738,11 +759,11 @@ int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd) {
break;
default:
- return -EINVAL;
+ return UV_EINVAL;
}
if (uv__is_closing(handle) || fd_out == -1)
- return -EBADF;
+ return UV_EBADF;
*fd = fd_out;
return 0;
@@ -835,7 +856,7 @@ void uv__io_init(uv__io_t* w, uv__io_cb cb, int fd) {
void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
- assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP)));
+ assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI)));
assert(0 != events);
assert(w->fd >= 0);
assert(w->fd < INT_MAX);
@@ -863,7 +884,7 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
- assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP)));
+ assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI)));
assert(0 != events);
if (w->fd == -1)
@@ -895,11 +916,12 @@ void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
void uv__io_close(uv_loop_t* loop, uv__io_t* w) {
- uv__io_stop(loop, w, POLLIN | POLLOUT | UV__POLLRDHUP);
+ uv__io_stop(loop, w, POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI);
QUEUE_REMOVE(&w->pending_queue);
/* Remove stale events for this file descriptor */
- uv__platform_invalidate_fd(loop, w->fd);
+ if (w->fd != -1)
+ uv__platform_invalidate_fd(loop, w->fd);
}
@@ -910,17 +932,22 @@ void uv__io_feed(uv_loop_t* loop, uv__io_t* w) {
int uv__io_active(const uv__io_t* w, unsigned int events) {
- assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP)));
+ assert(0 == (events & ~(POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI)));
assert(0 != events);
return 0 != (w->pevents & events);
}
+int uv__fd_exists(uv_loop_t* loop, int fd) {
+ return (unsigned) fd < loop->nwatchers && loop->watchers[fd] != NULL;
+}
+
+
int uv_getrusage(uv_rusage_t* rusage) {
struct rusage usage;
if (getrusage(RUSAGE_SELF, &usage))
- return -errno;
+ return UV__ERR(errno);
rusage->ru_utime.tv_sec = usage.ru_utime.tv_sec;
rusage->ru_utime.tv_usec = usage.ru_utime.tv_usec;
@@ -928,7 +955,7 @@ int uv_getrusage(uv_rusage_t* rusage) {
rusage->ru_stime.tv_sec = usage.ru_stime.tv_sec;
rusage->ru_stime.tv_usec = usage.ru_stime.tv_usec;
-#if !defined(__MVS__)
+#if !defined(__MVS__) && !defined(__HAIKU__)
rusage->ru_maxrss = usage.ru_maxrss;
rusage->ru_ixrss = usage.ru_ixrss;
rusage->ru_idrss = usage.ru_idrss;
@@ -962,7 +989,7 @@ int uv__open_cloexec(const char* path, int flags) {
return fd;
if (errno != EINVAL)
- return -errno;
+ return UV__ERR(errno);
/* O_CLOEXEC not supported. */
no_cloexec = 1;
@@ -971,7 +998,7 @@ int uv__open_cloexec(const char* path, int flags) {
fd = open(path, flags);
if (fd == -1)
- return -errno;
+ return UV__ERR(errno);
err = uv__cloexec(fd, 1);
if (err) {
@@ -985,17 +1012,17 @@ int uv__open_cloexec(const char* path, int flags) {
int uv__dup2_cloexec(int oldfd, int newfd) {
int r;
-#if defined(__FreeBSD__) && __FreeBSD__ >= 10
+#if (defined(__FreeBSD__) && __FreeBSD__ >= 10) || defined(__NetBSD__)
r = dup3(oldfd, newfd, O_CLOEXEC);
if (r == -1)
- return -errno;
+ return UV__ERR(errno);
return r;
#elif defined(__FreeBSD__) && defined(F_DUP2FD_CLOEXEC)
r = fcntl(oldfd, F_DUP2FD_CLOEXEC, newfd);
if (r != -1)
return r;
if (errno != EINVAL)
- return -errno;
+ return UV__ERR(errno);
/* Fall through. */
#elif defined(__linux__)
static int no_dup3;
@@ -1006,7 +1033,7 @@ int uv__dup2_cloexec(int oldfd, int newfd) {
if (r != -1)
return r;
if (errno != ENOSYS)
- return -errno;
+ return UV__ERR(errno);
/* Fall through. */
no_dup3 = 1;
}
@@ -1022,7 +1049,7 @@ int uv__dup2_cloexec(int oldfd, int newfd) {
#endif
if (r == -1)
- return -errno;
+ return UV__ERR(errno);
err = uv__cloexec(newfd, 1);
if (err) {
@@ -1037,29 +1064,16 @@ int uv__dup2_cloexec(int oldfd, int newfd) {
int uv_os_homedir(char* buffer, size_t* size) {
uv_passwd_t pwd;
- char* buf;
size_t len;
int r;
- if (buffer == NULL || size == NULL || *size == 0)
- return -EINVAL;
-
- /* Check if the HOME environment variable is set first */
- buf = getenv("HOME");
+ /* Check if the HOME environment variable is set first. The task of
+ performing input validation on buffer and size is taken care of by
+ uv_os_getenv(). */
+ r = uv_os_getenv("HOME", buffer, size);
- if (buf != NULL) {
- len = strlen(buf);
-
- if (len >= *size) {
- *size = len + 1;
- return -ENOBUFS;
- }
-
- memcpy(buffer, buf, len + 1);
- *size = len;
-
- return 0;
- }
+ if (r != UV_ENOENT)
+ return r;
/* HOME is not set, so call uv__getpwuid_r() */
r = uv__getpwuid_r(&pwd);
@@ -1073,7 +1087,7 @@ int uv_os_homedir(char* buffer, size_t* size) {
if (len >= *size) {
*size = len + 1;
uv_os_free_passwd(&pwd);
- return -ENOBUFS;
+ return UV_ENOBUFS;
}
memcpy(buffer, pwd.homedir, len + 1);
@@ -1089,7 +1103,7 @@ int uv_os_tmpdir(char* buffer, size_t* size) {
size_t len;
if (buffer == NULL || size == NULL || *size == 0)
- return -EINVAL;
+ return UV_EINVAL;
#define CHECK_ENV_VAR(name) \
do { \
@@ -1119,7 +1133,7 @@ return_buffer:
if (len >= *size) {
*size = len + 1;
- return -ENOBUFS;
+ return UV_ENOBUFS;
}
/* The returned directory should not have a trailing slash. */
@@ -1151,11 +1165,11 @@ int uv__getpwuid_r(uv_passwd_t* pwd) {
getpwuid_r = dlsym(RTLD_DEFAULT, "getpwuid_r");
if (getpwuid_r == NULL)
- return -ENOSYS;
+ return UV_ENOSYS;
#endif
if (pwd == NULL)
- return -EINVAL;
+ return UV_EINVAL;
initsize = sysconf(_SC_GETPW_R_SIZE_MAX);
@@ -1172,7 +1186,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) {
buf = uv__malloc(bufsize);
if (buf == NULL)
- return -ENOMEM;
+ return UV_ENOMEM;
r = getpwuid_r(uid, &pw, buf, bufsize, &result);
@@ -1189,7 +1203,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) {
if (result == NULL) {
uv__free(buf);
- return -ENOENT;
+ return UV_ENOENT;
}
/* Allocate memory for the username, shell, and home directory */
@@ -1200,7 +1214,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) {
if (pwd->username == NULL) {
uv__free(buf);
- return -ENOMEM;
+ return UV_ENOMEM;
}
/* Copy the username */
@@ -1256,18 +1270,18 @@ int uv_os_getenv(const char* name, char* buffer, size_t* size) {
size_t len;
if (name == NULL || buffer == NULL || size == NULL || *size == 0)
- return -EINVAL;
+ return UV_EINVAL;
var = getenv(name);
if (var == NULL)
- return -ENOENT;
+ return UV_ENOENT;
len = strlen(var);
if (len >= *size) {
*size = len + 1;
- return -ENOBUFS;
+ return UV_ENOBUFS;
}
memcpy(buffer, var, len + 1);
@@ -1279,18 +1293,21 @@ int uv_os_getenv(const char* name, char* buffer, size_t* size) {
int uv_os_setenv(const char* name, const char* value) {
if (name == NULL || value == NULL)
- return -EINVAL;
+ return UV_EINVAL;
if (setenv(name, value, 1) != 0)
- return -errno;
+ return UV__ERR(errno);
return 0;
}
int uv_os_unsetenv(const char* name) {
+ if (name == NULL)
+ return UV_EINVAL;
+
if (unsetenv(name) != 0)
- return -errno;
+ return UV__ERR(errno);
return 0;
}
@@ -1303,24 +1320,171 @@ int uv_os_gethostname(char* buffer, size_t* size) {
instead by creating a large enough buffer and comparing the hostname length
to the size input.
*/
- char buf[MAXHOSTNAMELEN + 1];
+ char buf[UV_MAXHOSTNAMESIZE];
size_t len;
if (buffer == NULL || size == NULL || *size == 0)
- return -EINVAL;
+ return UV_EINVAL;
if (gethostname(buf, sizeof(buf)) != 0)
- return -errno;
+ return UV__ERR(errno);
buf[sizeof(buf) - 1] = '\0'; /* Null terminate, just to be safe. */
len = strlen(buf);
if (len >= *size) {
*size = len + 1;
- return -ENOBUFS;
+ return UV_ENOBUFS;
}
memcpy(buffer, buf, len + 1);
*size = len;
return 0;
}
+
+
+int uv_cpumask_size(void) {
+#if defined(__linux__) || defined(__FreeBSD__)
+ return CPU_SETSIZE;
+#else
+ return UV_ENOTSUP;
+#endif
+}
+
+
+uv_os_fd_t uv_get_osfhandle(int fd) {
+ return fd;
+}
+
+int uv_open_osfhandle(uv_os_fd_t os_fd) {
+ return os_fd;
+}
+
+uv_pid_t uv_os_getpid(void) {
+ return getpid();
+}
+
+
+uv_pid_t uv_os_getppid(void) {
+ return getppid();
+}
+
+
+int uv_os_getpriority(uv_pid_t pid, int* priority) {
+ int r;
+
+ if (priority == NULL)
+ return UV_EINVAL;
+
+ errno = 0;
+ r = getpriority(PRIO_PROCESS, (int) pid);
+
+ if (r == -1 && errno != 0)
+ return UV__ERR(errno);
+
+ *priority = r;
+ return 0;
+}
+
+
+int uv_os_setpriority(uv_pid_t pid, int priority) {
+ if (priority < UV_PRIORITY_HIGHEST || priority > UV_PRIORITY_LOW)
+ return UV_EINVAL;
+
+ if (setpriority(PRIO_PROCESS, (int) pid, priority) != 0)
+ return UV__ERR(errno);
+
+ return 0;
+}
+
+
+int uv_os_uname(uv_utsname_t* buffer) {
+ struct utsname buf;
+ int r;
+
+ if (buffer == NULL)
+ return UV_EINVAL;
+
+ if (uname(&buf) == -1) {
+ r = UV__ERR(errno);
+ goto error;
+ }
+
+ r = uv__strscpy(buffer->sysname, buf.sysname, sizeof(buffer->sysname));
+ if (r == UV_E2BIG)
+ goto error;
+
+#ifdef _AIX
+ r = snprintf(buffer->release,
+ sizeof(buffer->release),
+ "%s.%s",
+ buf.version,
+ buf.release);
+ if (r >= sizeof(buffer->release)) {
+ r = UV_E2BIG;
+ goto error;
+ }
+#else
+ r = uv__strscpy(buffer->release, buf.release, sizeof(buffer->release));
+ if (r == UV_E2BIG)
+ goto error;
+#endif
+
+ r = uv__strscpy(buffer->version, buf.version, sizeof(buffer->version));
+ if (r == UV_E2BIG)
+ goto error;
+
+#if defined(_AIX) || defined(__PASE__)
+ r = uv__strscpy(buffer->machine, "ppc64", sizeof(buffer->machine));
+#else
+ r = uv__strscpy(buffer->machine, buf.machine, sizeof(buffer->machine));
+#endif
+
+ if (r == UV_E2BIG)
+ goto error;
+
+ return 0;
+
+error:
+ buffer->sysname[0] = '\0';
+ buffer->release[0] = '\0';
+ buffer->version[0] = '\0';
+ buffer->machine[0] = '\0';
+ return r;
+}
+
+int uv__getsockpeername(const uv_handle_t* handle,
+ uv__peersockfunc func,
+ struct sockaddr* name,
+ int* namelen) {
+ socklen_t socklen;
+ uv_os_fd_t fd;
+ int r;
+
+ r = uv_fileno(handle, &fd);
+ if (r < 0)
+ return r;
+
+ /* sizeof(socklen_t) != sizeof(int) on some systems. */
+ socklen = (socklen_t) *namelen;
+
+ if (func(fd, name, &socklen))
+ return UV__ERR(errno);
+
+ *namelen = (int) socklen;
+ return 0;
+}
+
+int uv_gettimeofday(uv_timeval64_t* tv) {
+ struct timeval time;
+
+ if (tv == NULL)
+ return UV_EINVAL;
+
+ if (gettimeofday(&time, NULL) != 0)
+ return UV__ERR(errno);
+
+ tv->tv_sec = (int64_t) time.tv_sec;
+ tv->tv_usec = (int32_t) time.tv_usec;
+ return 0;
+}
diff --git a/Utilities/cmlibuv/src/unix/cygwin.c b/Utilities/cmlibuv/src/unix/cygwin.c
index 5a887dd4c..9da20e203 100644
--- a/Utilities/cmlibuv/src/unix/cygwin.c
+++ b/Utilities/cmlibuv/src/unix/cygwin.c
@@ -29,7 +29,7 @@ int uv_uptime(double* uptime) {
struct sysinfo info;
if (sysinfo(&info) < 0)
- return -errno;
+ return UV__ERR(errno);
*uptime = info.uptime;
return 0;
@@ -38,7 +38,7 @@ int uv_uptime(double* uptime) {
int uv_resident_set_memory(size_t* rss) {
/* FIXME: read /proc/meminfo? */
*rss = 0;
- return UV_ENOSYS;
+ return 0;
}
int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
diff --git a/Utilities/cmlibuv/src/unix/darwin-proctitle.c b/Utilities/cmlibuv/src/unix/darwin-proctitle.c
index 114231160..e505bdd23 100644
--- a/Utilities/cmlibuv/src/unix/darwin-proctitle.c
+++ b/Utilities/cmlibuv/src/unix/darwin-proctitle.c
@@ -18,6 +18,9 @@
* IN THE SOFTWARE.
*/
+#include "uv.h"
+#include "internal.h"
+
#include <dlfcn.h>
#include <errno.h>
#include <stdlib.h>
@@ -30,61 +33,56 @@
# include <ApplicationServices/ApplicationServices.h>
#endif
+#define S(s) pCFStringCreateWithCString(NULL, (s), kCFStringEncodingUTF8)
-static int uv__pthread_setname_np(const char* name) {
- int (*dynamic_pthread_setname_np)(const char* name);
- char namebuf[64]; /* MAXTHREADNAMESIZE */
- int err;
-
- /* pthread_setname_np() first appeared in OS X 10.6 and iOS 3.2. */
- *(void **)(&dynamic_pthread_setname_np) =
- dlsym(RTLD_DEFAULT, "pthread_setname_np");
-
- if (dynamic_pthread_setname_np == NULL)
- return -ENOSYS;
-
- strncpy(namebuf, name, sizeof(namebuf) - 1);
- namebuf[sizeof(namebuf) - 1] = '\0';
- err = dynamic_pthread_setname_np(namebuf);
- if (err)
- return -err;
+static int (*dynamic_pthread_setname_np)(const char* name);
+#if !TARGET_OS_IPHONE
+static CFStringRef (*pCFStringCreateWithCString)(CFAllocatorRef,
+ const char*,
+ CFStringEncoding);
+static CFBundleRef (*pCFBundleGetBundleWithIdentifier)(CFStringRef);
+static void *(*pCFBundleGetDataPointerForName)(CFBundleRef, CFStringRef);
+static void *(*pCFBundleGetFunctionPointerForName)(CFBundleRef, CFStringRef);
+static CFTypeRef (*pLSGetCurrentApplicationASN)(void);
+static OSStatus (*pLSSetApplicationInformationItem)(int,
+ CFTypeRef,
+ CFStringRef,
+ CFStringRef,
+ CFDictionaryRef*);
+static void* application_services_handle;
+static void* core_foundation_handle;
+static CFBundleRef launch_services_bundle;
+static CFStringRef* display_name_key;
+static CFDictionaryRef (*pCFBundleGetInfoDictionary)(CFBundleRef);
+static CFBundleRef (*pCFBundleGetMainBundle)(void);
+static CFBundleRef hi_services_bundle;
+static OSStatus (*pSetApplicationIsDaemon)(int);
+static CFDictionaryRef (*pLSApplicationCheckIn)(int, CFDictionaryRef);
+static void (*pLSSetApplicationLaunchServicesServerConnectionStatus)(uint64_t,
+ void*);
+
+
+UV_DESTRUCTOR(static void uv__set_process_title_platform_fini(void)) {
+ if (core_foundation_handle != NULL) {
+ dlclose(core_foundation_handle);
+ core_foundation_handle = NULL;
+ }
- return 0;
+ if (application_services_handle != NULL) {
+ dlclose(application_services_handle);
+ application_services_handle = NULL;
+ }
}
+#endif /* !TARGET_OS_IPHONE */
+
+void uv__set_process_title_platform_init(void) {
+ /* pthread_setname_np() first appeared in OS X 10.6 and iOS 3.2. */
+ *(void **)(&dynamic_pthread_setname_np) =
+ dlsym(RTLD_DEFAULT, "pthread_setname_np");
-int uv__set_process_title(const char* title) {
-#if TARGET_OS_IPHONE
- return uv__pthread_setname_np(title);
-#else
- CFStringRef (*pCFStringCreateWithCString)(CFAllocatorRef,
- const char*,
- CFStringEncoding);
- CFBundleRef (*pCFBundleGetBundleWithIdentifier)(CFStringRef);
- void *(*pCFBundleGetDataPointerForName)(CFBundleRef, CFStringRef);
- void *(*pCFBundleGetFunctionPointerForName)(CFBundleRef, CFStringRef);
- CFTypeRef (*pLSGetCurrentApplicationASN)(void);
- OSStatus (*pLSSetApplicationInformationItem)(int,
- CFTypeRef,
- CFStringRef,
- CFStringRef,
- CFDictionaryRef*);
- void* application_services_handle;
- void* core_foundation_handle;
- CFBundleRef launch_services_bundle;
- CFStringRef* display_name_key;
- CFDictionaryRef (*pCFBundleGetInfoDictionary)(CFBundleRef);
- CFBundleRef (*pCFBundleGetMainBundle)(void);
- CFBundleRef hi_services_bundle;
- OSStatus (*pSetApplicationIsDaemon)(int);
- CFDictionaryRef (*pLSApplicationCheckIn)(int, CFDictionaryRef);
- void (*pLSSetApplicationLaunchServicesServerConnectionStatus)(uint64_t,
- void*);
- CFTypeRef asn;
- int err;
-
- err = -ENOENT;
+#if !TARGET_OS_IPHONE
application_services_handle = dlopen("/System/Library/Frameworks/"
"ApplicationServices.framework/"
"Versions/A/ApplicationServices",
@@ -113,8 +111,6 @@ int uv__set_process_title(const char* title) {
goto out;
}
-#define S(s) pCFStringCreateWithCString(NULL, (s), kCFStringEncodingUTF8)
-
launch_services_bundle =
pCFBundleGetBundleWithIdentifier(S("com.apple.LaunchServices"));
@@ -145,13 +141,14 @@ int uv__set_process_title(const char* title) {
"CFBundleGetInfoDictionary");
*(void **)(&pCFBundleGetMainBundle) = dlsym(core_foundation_handle,
"CFBundleGetMainBundle");
+
if (pCFBundleGetInfoDictionary == NULL || pCFBundleGetMainBundle == NULL)
goto out;
/* Black 10.9 magic, to remove (Not responding) mark in Activity Monitor */
hi_services_bundle =
pCFBundleGetBundleWithIdentifier(S("com.apple.HIServices"));
- err = -ENOENT;
+
if (hi_services_bundle == NULL)
goto out;
@@ -165,42 +162,37 @@ int uv__set_process_title(const char* title) {
pCFBundleGetFunctionPointerForName(
launch_services_bundle,
S("_LSSetApplicationLaunchServicesServerConnectionStatus"));
+
if (pSetApplicationIsDaemon == NULL ||
pLSApplicationCheckIn == NULL ||
pLSSetApplicationLaunchServicesServerConnectionStatus == NULL) {
goto out;
}
- if (pSetApplicationIsDaemon(1) != noErr)
- goto out;
-
- pLSSetApplicationLaunchServicesServerConnectionStatus(0, NULL);
-
- /* Check into process manager?! */
- pLSApplicationCheckIn(-2,
- pCFBundleGetInfoDictionary(pCFBundleGetMainBundle()));
-
- asn = pLSGetCurrentApplicationASN();
-
- err = -EINVAL;
- if (pLSSetApplicationInformationItem(-2, /* Magic value. */
- asn,
- *display_name_key,
- S(title),
- NULL) != noErr) {
- goto out;
- }
-
- uv__pthread_setname_np(title); /* Don't care if it fails. */
- err = 0;
+ return;
out:
- if (core_foundation_handle != NULL)
- dlclose(core_foundation_handle);
+ uv__set_process_title_platform_fini();
+#endif /* !TARGET_OS_IPHONE */
+}
- if (application_services_handle != NULL)
- dlclose(application_services_handle);
- return err;
+void uv__set_process_title(const char* title) {
+#if !TARGET_OS_IPHONE
+ if (core_foundation_handle != NULL && pSetApplicationIsDaemon(1) != noErr) {
+ CFTypeRef asn;
+ pLSSetApplicationLaunchServicesServerConnectionStatus(0, NULL);
+ pLSApplicationCheckIn(/* Magic value */ -2,
+ pCFBundleGetInfoDictionary(pCFBundleGetMainBundle()));
+ asn = pLSGetCurrentApplicationASN();
+ pLSSetApplicationInformationItem(/* Magic value */ -2, asn,
+ *display_name_key, S(title), NULL);
+ }
#endif /* !TARGET_OS_IPHONE */
+
+ if (dynamic_pthread_setname_np != NULL) {
+ char namebuf[64]; /* MAXTHREADNAMESIZE */
+ uv__strscpy(namebuf, title, sizeof(namebuf));
+ dynamic_pthread_setname_np(namebuf);
+ }
}
diff --git a/Utilities/cmlibuv/src/unix/darwin.c b/Utilities/cmlibuv/src/unix/darwin.c
index df6dd1c61..e4cd8ff7e 100644
--- a/Utilities/cmlibuv/src/unix/darwin.c
+++ b/Utilities/cmlibuv/src/unix/darwin.c
@@ -37,7 +37,7 @@ int uv__platform_loop_init(uv_loop_t* loop) {
loop->cf_state = NULL;
if (uv__kqueue_init(loop))
- return -errno;
+ return UV__ERR(errno);
return 0;
}
@@ -68,18 +68,18 @@ int uv_exepath(char* buffer, size_t* size) {
size_t abspath_size;
if (buffer == NULL || size == NULL || *size == 0)
- return -EINVAL;
+ return UV_EINVAL;
exepath_size = sizeof(exepath);
if (_NSGetExecutablePath(exepath, &exepath_size))
- return -EIO;
+ return UV_EIO;
if (realpath(exepath, abspath) != abspath)
- return -errno;
+ return UV__ERR(errno);
abspath_size = strlen(abspath);
if (abspath_size == 0)
- return -EIO;
+ return UV_EIO;
*size -= 1;
if (*size > abspath_size)
@@ -98,7 +98,7 @@ uint64_t uv_get_free_memory(void) {
if (host_statistics(mach_host_self(), HOST_VM_INFO,
(host_info_t)&info, &count) != KERN_SUCCESS) {
- return -EINVAL; /* FIXME(bnoordhuis) Translate error. */
+ return UV_EINVAL; /* FIXME(bnoordhuis) Translate error. */
}
return (uint64_t) info.free_count * sysconf(_SC_PAGESIZE);
@@ -111,12 +111,17 @@ uint64_t uv_get_total_memory(void) {
size_t size = sizeof(info);
if (sysctl(which, 2, &info, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
return (uint64_t) info;
}
+uint64_t uv_get_constrained_memory(void) {
+ return 0; /* Memory constraints are unknown. */
+}
+
+
void uv_loadavg(double avg[3]) {
struct loadavg info;
size_t size = sizeof(info);
@@ -158,7 +163,7 @@ int uv_uptime(double* uptime) {
static int which[] = {CTL_KERN, KERN_BOOTTIME};
if (sysctl(which, 2, &info, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
now = time(NULL);
*uptime = now - info.tv_sec;
@@ -181,23 +186,23 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
size = sizeof(model);
if (sysctlbyname("machdep.cpu.brand_string", &model, &size, NULL, 0) &&
sysctlbyname("hw.model", &model, &size, NULL, 0)) {
- return -errno;
+ return UV__ERR(errno);
}
size = sizeof(cpuspeed);
if (sysctlbyname("hw.cpufrequency", &cpuspeed, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
if (host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &numcpus,
(processor_info_array_t*)&info,
&msg_type) != KERN_SUCCESS) {
- return -EINVAL; /* FIXME(bnoordhuis) Translate error. */
+ return UV_EINVAL; /* FIXME(bnoordhuis) Translate error. */
}
*cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos));
if (!(*cpu_infos)) {
vm_deallocate(mach_task_self(), (vm_address_t)info, msg_type);
- return -ENOMEM;
+ return UV_ENOMEM;
}
*count = numcpus;
diff --git a/Utilities/cmlibuv/src/unix/freebsd.c b/Utilities/cmlibuv/src/unix/freebsd.c
index e52ae99db..7de88d6a5 100644
--- a/Utilities/cmlibuv/src/unix/freebsd.c
+++ b/Utilities/cmlibuv/src/unix/freebsd.c
@@ -25,7 +25,6 @@
#include <string.h>
#include <errno.h>
-#include <kvm.h>
#include <paths.h>
#include <sys/user.h>
#include <sys/types.h>
@@ -48,8 +47,6 @@
# define CP_INTR 4
#endif
-static char *process_title;
-
int uv__platform_loop_init(uv_loop_t* loop) {
return uv__kqueue_init(loop);
@@ -66,11 +63,11 @@ int uv_exepath(char* buffer, size_t* size) {
ssize_t abspath_size;
if (buffer == NULL || size == NULL || *size == 0)
- return -EINVAL;
+ return UV_EINVAL;
abspath_size = readlink("/proc/curproc/file", abspath, sizeof(abspath));
if (abspath_size < 0)
- return -errno;
+ return UV__ERR(errno);
assert(abspath_size > 0);
*size -= 1;
@@ -90,7 +87,7 @@ int uv_exepath(char* buffer, size_t* size) {
size_t abspath_size;
if (buffer == NULL || size == NULL || *size == 0)
- return -EINVAL;
+ return UV_EINVAL;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
@@ -99,7 +96,7 @@ int uv_exepath(char* buffer, size_t* size) {
abspath_size = sizeof abspath;
if (sysctl(mib, 4, abspath, &abspath_size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
assert(abspath_size > 0);
abspath_size -= 1;
@@ -120,7 +117,7 @@ uint64_t uv_get_free_memory(void) {
size_t size = sizeof(freecount);
if (sysctlbyname("vm.stats.vm.v_free_count", &freecount, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
return (uint64_t) freecount * sysconf(_SC_PAGESIZE);
@@ -134,12 +131,17 @@ uint64_t uv_get_total_memory(void) {
size_t size = sizeof(info);
if (sysctl(which, 2, &info, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
return (uint64_t) info;
}
+uint64_t uv_get_constrained_memory(void) {
+ return 0; /* Memory constraints are unknown. */
+}
+
+
void uv_loadavg(double avg[3]) {
struct loadavg info;
size_t size = sizeof(info);
@@ -153,85 +155,31 @@ void uv_loadavg(double avg[3]) {
}
-char** uv_setup_args(int argc, char** argv) {
- process_title = argc ? uv__strdup(argv[0]) : NULL;
- return argv;
-}
-
-
-int uv_set_process_title(const char* title) {
- int oid[4];
-
- uv__free(process_title);
- process_title = uv__strdup(title);
-
- oid[0] = CTL_KERN;
- oid[1] = KERN_PROC;
- oid[2] = KERN_PROC_ARGS;
- oid[3] = getpid();
-
- sysctl(oid,
- ARRAY_SIZE(oid),
- NULL,
- NULL,
- process_title,
- strlen(process_title) + 1);
-
- return 0;
-}
-
-
-int uv_get_process_title(char* buffer, size_t size) {
- size_t len;
-
- if (buffer == NULL || size == 0)
- return -EINVAL;
-
- if (process_title) {
- len = strlen(process_title) + 1;
-
- if (size < len)
- return -ENOBUFS;
-
- memcpy(buffer, process_title, len);
- } else {
- len = 0;
- }
-
- buffer[len] = '\0';
-
- return 0;
-}
-
-
int uv_resident_set_memory(size_t* rss) {
- kvm_t *kd = NULL;
- struct kinfo_proc *kinfo = NULL;
- pid_t pid;
- int nprocs;
- size_t page_size = getpagesize();
+ struct kinfo_proc kinfo;
+ size_t page_size;
+ size_t kinfo_size;
+ int mib[4];
- pid = getpid();
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_PID;
+ mib[3] = getpid();
- kd = kvm_open(NULL, _PATH_DEVNULL, NULL, O_RDONLY, "kvm_open");
- if (kd == NULL) goto error;
+ kinfo_size = sizeof(kinfo);
- kinfo = kvm_getprocs(kd, KERN_PROC_PID, pid, &nprocs);
- if (kinfo == NULL) goto error;
+ if (sysctl(mib, 4, &kinfo, &kinfo_size, NULL, 0))
+ return UV__ERR(errno);
+
+ page_size = getpagesize();
#ifdef __DragonFly__
- *rss = kinfo->kp_vm_rssize * page_size;
+ *rss = kinfo.kp_vm_rssize * page_size;
#else
- *rss = kinfo->ki_rssize * page_size;
+ *rss = kinfo.ki_rssize * page_size;
#endif
- kvm_close(kd);
-
return 0;
-
-error:
- if (kd) kvm_close(kd);
- return -EPERM;
}
@@ -240,7 +188,7 @@ int uv_uptime(double* uptime) {
struct timespec sp;
r = clock_gettime(CLOCK_MONOTONIC, &sp);
if (r)
- return -errno;
+ return UV__ERR(errno);
*uptime = sp.tv_sec;
return 0;
@@ -254,6 +202,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
uv_cpu_info_t* cpu_info;
const char* maxcpus_key;
const char* cptimes_key;
+ const char* model_key;
char model[512];
long* cp_times;
int numcpus;
@@ -272,33 +221,39 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
cptimes_key = "kern.cp_times";
#endif
- size = sizeof(model);
- if (sysctlbyname("hw.model", &model, &size, NULL, 0))
+#if defined(__arm__) || defined(__aarch64__)
+ /* The key hw.model and hw.clockrate are not available on FreeBSD ARM. */
+ model_key = "hw.machine";
+ cpuspeed = 0;
+#else
+ model_key = "hw.model";
+
+ size = sizeof(cpuspeed);
+ if (sysctlbyname("hw.clockrate", &cpuspeed, &size, NULL, 0))
return -errno;
+#endif
+
+ size = sizeof(model);
+ if (sysctlbyname(model_key, &model, &size, NULL, 0))
+ return UV__ERR(errno);
size = sizeof(numcpus);
if (sysctlbyname("hw.ncpu", &numcpus, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
*cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos));
if (!(*cpu_infos))
- return -ENOMEM;
+ return UV_ENOMEM;
*count = numcpus;
- size = sizeof(cpuspeed);
- if (sysctlbyname("hw.clockrate", &cpuspeed, &size, NULL, 0)) {
- uv__free(*cpu_infos);
- return -errno;
- }
-
/* kern.cp_times on FreeBSD i386 gives an array up to maxcpus instead of
* ncpu.
*/
size = sizeof(maxcpus);
if (sysctlbyname(maxcpus_key, &maxcpus, &size, NULL, 0)) {
uv__free(*cpu_infos);
- return -errno;
+ return UV__ERR(errno);
}
size = maxcpus * CPUSTATES * sizeof(long);
@@ -306,13 +261,13 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
cp_times = uv__malloc(size);
if (cp_times == NULL) {
uv__free(*cpu_infos);
- return -ENOMEM;
+ return UV_ENOMEM;
}
if (sysctlbyname(cptimes_key, cp_times, &size, NULL, 0)) {
uv__free(cp_times);
uv__free(*cpu_infos);
- return -errno;
+ return UV__ERR(errno);
}
for (i = 0; i < numcpus; i++) {
diff --git a/Utilities/cmlibuv/src/unix/fs.c b/Utilities/cmlibuv/src/unix/fs.c
index 8a4ba7a2f..5fb34f1be 100644
--- a/Utilities/cmlibuv/src/unix/fs.c
+++ b/Utilities/cmlibuv/src/unix/fs.c
@@ -43,12 +43,11 @@
#include <pthread.h>
#include <unistd.h>
#include <fcntl.h>
-#include <utime.h>
#include <poll.h>
#if defined(__DragonFly__) || \
defined(__FreeBSD__) || \
- defined(__FreeBSD_kernel_) || \
+ defined(__FreeBSD_kernel__) || \
defined(__OpenBSD__) || \
defined(__NetBSD__)
# define HAVE_PREADV 1
@@ -60,17 +59,33 @@
# include <sys/sendfile.h>
#endif
+#if defined(__APPLE__)
+# include <sys/sysctl.h>
+#elif defined(__linux__) && !defined(FICLONE)
+# include <sys/ioctl.h>
+# define FICLONE _IOW(0x94, 9, int)
+#endif
+
+#if defined(_AIX) && !defined(_AIX71)
+# include <utime.h>
+#endif
+
+#if defined(_AIX) && _XOPEN_SOURCE <= 600
+extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */
+#endif
+
#define INIT(subtype) \
do { \
- req->type = UV_FS; \
- if (cb != NULL) \
- uv__req_init(loop, req, UV_FS); \
+ if (req == NULL) \
+ return UV_EINVAL; \
+ UV_REQ_INIT(req, UV_FS); \
req->fs_type = UV_FS_ ## subtype; \
req->result = 0; \
req->ptr = NULL; \
req->loop = loop; \
req->path = NULL; \
req->new_path = NULL; \
+ req->bufs = NULL; \
req->cb = cb; \
} \
while (0)
@@ -82,10 +97,8 @@
req->path = path; \
} else { \
req->path = uv__strdup(path); \
- if (req->path == NULL) { \
- uv__req_unregister(loop, req); \
- return -ENOMEM; \
- } \
+ if (req->path == NULL) \
+ return UV_ENOMEM; \
} \
} \
while (0)
@@ -101,10 +114,8 @@
path_len = strlen(path) + 1; \
new_path_len = strlen(new_path) + 1; \
req->path = uv__malloc(path_len + new_path_len); \
- if (req->path == NULL) { \
- uv__req_unregister(loop, req); \
- return -ENOMEM; \
- } \
+ if (req->path == NULL) \
+ return UV_ENOMEM; \
req->new_path = req->path + path_len; \
memcpy((void*) req->path, path, path_len); \
memcpy((void*) req->new_path, new_path, new_path_len); \
@@ -115,7 +126,12 @@
#define POST \
do { \
if (cb != NULL) { \
- uv__work_submit(loop, &req->work_req, uv__fs_work, uv__fs_done); \
+ uv__req_register(loop, req); \
+ uv__work_submit(loop, \
+ &req->work_req, \
+ UV__WORK_FAST_IO, \
+ uv__fs_work, \
+ uv__fs_done); \
return 0; \
} \
else { \
@@ -126,26 +142,48 @@
while (0)
-static ssize_t uv__fs_fdatasync(uv_fs_t* req) {
-#if defined(__linux__) || defined(__sun) || defined(__NetBSD__)
- return fdatasync(req->file);
-#elif defined(__APPLE__)
+static int uv__fs_close(int fd) {
+ int rc;
+
+ rc = uv__close_nocancel(fd);
+ if (rc == -1)
+ if (errno == EINTR || errno == EINPROGRESS)
+ rc = 0; /* The close is in progress, not an error. */
+
+ return rc;
+}
+
+
+static ssize_t uv__fs_fsync(uv_fs_t* req) {
+#if defined(__APPLE__)
/* Apple's fdatasync and fsync explicitly do NOT flush the drive write cache
* to the drive platters. This is in contrast to Linux's fdatasync and fsync
* which do, according to recent man pages. F_FULLFSYNC is Apple's equivalent
- * for flushing buffered data to permanent storage.
+ * for flushing buffered data to permanent storage. If F_FULLFSYNC is not
+ * supported by the file system we fall back to F_BARRIERFSYNC or fsync().
+ * This is the same approach taken by sqlite, except sqlite does not issue
+ * an F_BARRIERFSYNC call.
*/
- return fcntl(req->file, F_FULLFSYNC);
+ int r;
+
+ r = fcntl(req->file, F_FULLFSYNC);
+ if (r != 0)
+ r = fcntl(req->file, 85 /* F_BARRIERFSYNC */); /* fsync + barrier */
+ if (r != 0)
+ r = fsync(req->file);
+ return r;
#else
return fsync(req->file);
#endif
}
-static ssize_t uv__fs_fsync(uv_fs_t* req) {
-#if defined(__APPLE__)
- /* See the comment in uv__fs_fdatasync. */
- return fcntl(req->file, F_FULLFSYNC);
+static ssize_t uv__fs_fdatasync(uv_fs_t* req) {
+#if defined(__linux__) || defined(__sun) || defined(__NetBSD__)
+ return fdatasync(req->file);
+#elif defined(__APPLE__)
+ /* See the comment in uv__fs_fsync. */
+ return uv__fs_fsync(req);
#else
return fsync(req->file);
#endif
@@ -153,59 +191,18 @@ static ssize_t uv__fs_fsync(uv_fs_t* req) {
static ssize_t uv__fs_futime(uv_fs_t* req) {
-#if defined(__linux__)
+#if defined(__linux__) \
+ || defined(_AIX71) \
+ || defined(__HAIKU__)
/* utimesat() has nanosecond resolution but we stick to microseconds
* for the sake of consistency with other platforms.
*/
- static int no_utimesat;
struct timespec ts[2];
- struct timeval tv[2];
- char path[sizeof("/proc/self/fd/") + 3 * sizeof(int)];
- int r;
-
- if (no_utimesat)
- goto skip;
-
ts[0].tv_sec = req->atime;
ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000;
ts[1].tv_sec = req->mtime;
ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000;
-
- r = uv__utimesat(req->file, NULL, ts, 0);
- if (r == 0)
- return r;
-
- if (errno != ENOSYS)
- return r;
-
- no_utimesat = 1;
-
-skip:
-
- tv[0].tv_sec = req->atime;
- tv[0].tv_usec = (uint64_t)(req->atime * 1000000) % 1000000;
- tv[1].tv_sec = req->mtime;
- tv[1].tv_usec = (uint64_t)(req->mtime * 1000000) % 1000000;
- snprintf(path, sizeof(path), "/proc/self/fd/%d", (int) req->file);
-
- r = utimes(path, tv);
- if (r == 0)
- return r;
-
- switch (errno) {
- case ENOENT:
- if (fcntl(req->file, F_GETFL) == -1 && errno == EBADF)
- break;
- /* Fall through. */
-
- case EACCES:
- case ENOTDIR:
- errno = ENOSYS;
- break;
- }
-
- return r;
-
+ return futimens(req->file, ts);
#elif defined(__APPLE__) \
|| defined(__DragonFly__) \
|| defined(__FreeBSD__) \
@@ -223,13 +220,6 @@ skip:
# else
return futimes(req->file, tv);
# endif
-#elif defined(_AIX71)
- struct timespec ts[2];
- ts[0].tv_sec = req->atime;
- ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000;
- ts[1].tv_sec = req->mtime;
- ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000;
- return futimens(req->file, ts);
#elif defined(__MVS__)
attrib_t atr;
memset(&atr, 0, sizeof(atr));
@@ -244,7 +234,7 @@ skip:
#endif
}
-#if defined(__sun) && _XOPEN_SOURCE < 600
+#if (defined(__sun) || defined(__hpux)) && (_XOPEN_SOURCE < 600 || defined(CMAKE_BOOTSTRAP))
static char* uv__mkdtemp(char *template)
{
if (!mktemp(template) || mkdir(template, 0700))
@@ -302,17 +292,13 @@ static ssize_t uv__fs_read(uv_fs_t* req) {
#if defined(__linux__)
static int no_preadv;
#endif
+ unsigned int iovmax;
ssize_t result;
-#if defined(_AIX)
- struct stat buf;
- if(fstat(req->file, &buf))
- return -1;
- if(S_ISDIR(buf.st_mode)) {
- errno = EISDIR;
- return -1;
- }
-#endif /* defined(_AIX) */
+ iovmax = uv__getiovmax();
+ if (req->nbufs > iovmax)
+ req->nbufs = iovmax;
+
if (req->off < 0) {
if (req->nbufs == 1)
result = read(req->file, req->bufs[0].base, req->bufs[0].len);
@@ -331,25 +317,7 @@ static ssize_t uv__fs_read(uv_fs_t* req) {
if (no_preadv) retry:
# endif
{
- off_t nread;
- size_t index;
-
- nread = 0;
- index = 0;
- result = 1;
- do {
- if (req->bufs[index].len > 0) {
- result = pread(req->file,
- req->bufs[index].base,
- req->bufs[index].len,
- req->off + nread);
- if (result > 0)
- nread += result;
- }
- index++;
- } while (index < req->nbufs && result > 0);
- if (nread > 0)
- result = nread;
+ result = pread(req->file, req->bufs[0].base, req->bufs[0].len, req->off);
}
# if defined(__linux__)
else {
@@ -367,6 +335,25 @@ static ssize_t uv__fs_read(uv_fs_t* req) {
}
done:
+ /* Early cleanup of bufs allocation, since we're done with it. */
+ if (req->bufs != req->bufsml)
+ uv__free(req->bufs);
+
+ req->bufs = NULL;
+ req->nbufs = 0;
+
+#ifdef __PASE__
+ /* PASE returns EOPNOTSUPP when reading a directory, convert to EISDIR */
+ if (result == -1 && errno == EOPNOTSUPP) {
+ struct stat buf;
+ ssize_t rc;
+ rc = fstat(req->file, &buf);
+ if (rc == 0 && S_ISDIR(buf.st_mode)) {
+ errno = EISDIR;
+ }
+ }
+#endif
+
return result;
}
@@ -389,7 +376,7 @@ static int uv__fs_scandir_sort(UV_CONST_DIRENT** a, UV_CONST_DIRENT** b) {
static ssize_t uv__fs_scandir(uv_fs_t* req) {
- uv__dirent_t **dents;
+ uv__dirent_t** dents;
int n;
dents = NULL;
@@ -413,42 +400,165 @@ static ssize_t uv__fs_scandir(uv_fs_t* req) {
return n;
}
+static int uv__fs_opendir(uv_fs_t* req) {
+ uv_dir_t* dir;
+
+ dir = uv__malloc(sizeof(*dir));
+ if (dir == NULL)
+ goto error;
+
+ dir->dir = opendir(req->path);
+ if (dir->dir == NULL)
+ goto error;
+
+ req->ptr = dir;
+ return 0;
+
+error:
+ uv__free(dir);
+ req->ptr = NULL;
+ return -1;
+}
+
+static int uv__fs_readdir(uv_fs_t* req) {
+ uv_dir_t* dir;
+ uv_dirent_t* dirent;
+ struct dirent* res;
+ unsigned int dirent_idx;
+ unsigned int i;
+
+ dir = req->ptr;
+ dirent_idx = 0;
+
+ while (dirent_idx < dir->nentries) {
+ /* readdir() returns NULL on end of directory, as well as on error. errno
+ is used to differentiate between the two conditions. */
+ errno = 0;
+ res = readdir(dir->dir);
+
+ if (res == NULL) {
+ if (errno != 0)
+ goto error;
+ break;
+ }
+
+ if (strcmp(res->d_name, ".") == 0 || strcmp(res->d_name, "..") == 0)
+ continue;
+
+ dirent = &dir->dirents[dirent_idx];
+ dirent->name = uv__strdup(res->d_name);
+
+ if (dirent->name == NULL)
+ goto error;
+
+ dirent->type = uv__fs_get_dirent_type(res);
+ ++dirent_idx;
+ }
+
+ return dirent_idx;
+
+error:
+ for (i = 0; i < dirent_idx; ++i) {
+ uv__free((char*) dir->dirents[i].name);
+ dir->dirents[i].name = NULL;
+ }
+
+ return -1;
+}
+
+static int uv__fs_closedir(uv_fs_t* req) {
+ uv_dir_t* dir;
+
+ dir = req->ptr;
+
+ if (dir->dir != NULL) {
+ closedir(dir->dir);
+ dir->dir = NULL;
+ }
+
+ uv__free(req->ptr);
+ req->ptr = NULL;
+ return 0;
+}
+
+#if defined(_POSIX_PATH_MAX)
+# define UV__FS_PATH_MAX _POSIX_PATH_MAX
+#elif defined(PATH_MAX)
+# define UV__FS_PATH_MAX PATH_MAX
+#else
+# define UV__FS_PATH_MAX_FALLBACK 8192
+# define UV__FS_PATH_MAX UV__FS_PATH_MAX_FALLBACK
+#endif
static ssize_t uv__fs_pathmax_size(const char* path) {
ssize_t pathmax;
pathmax = pathconf(path, _PC_PATH_MAX);
- if (pathmax == -1) {
-#if defined(PATH_MAX)
- return PATH_MAX;
-#else
-#error "PATH_MAX undefined in the current platform"
-#endif
- }
+ if (pathmax == -1)
+ pathmax = UV__FS_PATH_MAX;
return pathmax;
}
static ssize_t uv__fs_readlink(uv_fs_t* req) {
+ ssize_t maxlen;
ssize_t len;
char* buf;
+ char* newbuf;
- len = uv__fs_pathmax_size(req->path);
- buf = uv__malloc(len + 1);
+#if defined(UV__FS_PATH_MAX_FALLBACK)
+ /* We may not have a real PATH_MAX. Read size of link. */
+ struct stat st;
+ int ret;
+ ret = lstat(req->path, &st);
+ if (ret != 0)
+ return -1;
+ if (!S_ISLNK(st.st_mode)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ maxlen = st.st_size;
+
+ /* According to readlink(2) lstat can report st_size == 0
+ for some symlinks, such as those in /proc or /sys. */
+ if (maxlen == 0)
+ maxlen = uv__fs_pathmax_size(req->path);
+#else
+ maxlen = uv__fs_pathmax_size(req->path);
+#endif
+
+ buf = uv__malloc(maxlen);
if (buf == NULL) {
errno = ENOMEM;
return -1;
}
- len = readlink(req->path, buf, len);
+#if defined(__MVS__)
+ len = os390_readlink(req->path, buf, maxlen);
+#else
+ len = readlink(req->path, buf, maxlen);
+#endif
if (len == -1) {
uv__free(buf);
return -1;
}
+ /* Uncommon case: resize to make room for the trailing nul byte. */
+ if (len == maxlen) {
+ newbuf = uv__realloc(buf, len + 1);
+
+ if (newbuf == NULL) {
+ uv__free(buf);
+ return -1;
+ }
+
+ buf = newbuf;
+ }
+
buf[len] = '\0';
req->ptr = buf;
@@ -456,9 +566,15 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) {
}
static ssize_t uv__fs_realpath(uv_fs_t* req) {
- ssize_t len;
char* buf;
+#if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L
+ buf = realpath(req->path, NULL);
+ if (buf == NULL)
+ return -1;
+#else
+ ssize_t len;
+
len = uv__fs_pathmax_size(req->path);
buf = uv__malloc(len + 1);
@@ -471,6 +587,7 @@ static ssize_t uv__fs_realpath(uv_fs_t* req) {
uv__free(buf);
return -1;
}
+#endif
req->ptr = buf;
@@ -691,10 +808,49 @@ static ssize_t uv__fs_sendfile(uv_fs_t* req) {
static ssize_t uv__fs_utime(uv_fs_t* req) {
+#if defined(__linux__) \
+ || defined(_AIX71) \
+ || defined(__sun) \
+ || defined(__HAIKU__)
+ /* utimesat() has nanosecond resolution but we stick to microseconds
+ * for the sake of consistency with other platforms.
+ */
+ struct timespec ts[2];
+ ts[0].tv_sec = req->atime;
+ ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000;
+ ts[1].tv_sec = req->mtime;
+ ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000;
+ return utimensat(AT_FDCWD, req->path, ts, 0);
+#elif defined(__APPLE__) \
+ || defined(__DragonFly__) \
+ || defined(__FreeBSD__) \
+ || defined(__FreeBSD_kernel__) \
+ || defined(__NetBSD__) \
+ || defined(__OpenBSD__)
+ struct timeval tv[2];
+ tv[0].tv_sec = req->atime;
+ tv[0].tv_usec = (uint64_t)(req->atime * 1000000) % 1000000;
+ tv[1].tv_sec = req->mtime;
+ tv[1].tv_usec = (uint64_t)(req->mtime * 1000000) % 1000000;
+ return utimes(req->path, tv);
+#elif defined(_AIX) \
+ && !defined(_AIX71)
struct utimbuf buf;
buf.actime = req->atime;
buf.modtime = req->mtime;
- return utime(req->path, &buf); /* TODO use utimes() where available */
+ return utime(req->path, &buf);
+#elif defined(__MVS__)
+ attrib_t atr;
+ memset(&atr, 0, sizeof(atr));
+ atr.att_mtimechg = 1;
+ atr.att_atimechg = 1;
+ atr.att_mtime = req->mtime;
+ atr.att_atime = req->atime;
+ return __lchattr((char*) req->path, &atr, sizeof(atr));
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
}
@@ -732,25 +888,7 @@ static ssize_t uv__fs_write(uv_fs_t* req) {
if (no_pwritev) retry:
# endif
{
- off_t written;
- size_t index;
-
- written = 0;
- index = 0;
- r = 0;
- do {
- if (req->bufs[index].len > 0) {
- r = pwrite(req->file,
- req->bufs[index].base,
- req->bufs[index].len,
- req->off + written);
- if (r > 0)
- written += r;
- }
- index++;
- } while (index < req->nbufs && r >= 0);
- if (written > 0)
- r = written;
+ r = pwrite(req->file, req->bufs[0].base, req->bufs[0].len, req->off);
}
# if defined(__linux__)
else {
@@ -776,6 +914,135 @@ done:
return r;
}
+static ssize_t uv__fs_copyfile(uv_fs_t* req) {
+ uv_fs_t fs_req;
+ uv_file srcfd;
+ uv_file dstfd;
+ struct stat statsbuf;
+ int dst_flags;
+ int result;
+ int err;
+ size_t bytes_to_send;
+ int64_t in_offset;
+
+ dstfd = -1;
+ err = 0;
+
+ /* Open the source file. */
+ srcfd = uv_fs_open(NULL, &fs_req, req->path, O_RDONLY, 0, NULL);
+ uv_fs_req_cleanup(&fs_req);
+
+ if (srcfd < 0)
+ return srcfd;
+
+ /* Get the source file's mode. */
+ if (fstat(srcfd, &statsbuf)) {
+ err = UV__ERR(errno);
+ goto out;
+ }
+
+ dst_flags = O_WRONLY | O_CREAT | O_TRUNC;
+
+ if (req->flags & UV_FS_COPYFILE_EXCL)
+ dst_flags |= O_EXCL;
+
+ /* Open the destination file. */
+ dstfd = uv_fs_open(NULL,
+ &fs_req,
+ req->new_path,
+ dst_flags,
+ statsbuf.st_mode,
+ NULL);
+ uv_fs_req_cleanup(&fs_req);
+
+ if (dstfd < 0) {
+ err = dstfd;
+ goto out;
+ }
+
+ if (fchmod(dstfd, statsbuf.st_mode) == -1) {
+ err = UV__ERR(errno);
+ goto out;
+ }
+
+#ifdef FICLONE
+ if (req->flags & UV_FS_COPYFILE_FICLONE ||
+ req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
+ if (ioctl(dstfd, FICLONE, srcfd) == -1) {
+ /* If an error occurred that the sendfile fallback also won't handle, or
+ this is a force clone then exit. Otherwise, fall through to try using
+ sendfile(). */
+ if (errno != ENOTTY && errno != EOPNOTSUPP && errno != EXDEV) {
+ err = UV__ERR(errno);
+ goto out;
+ } else if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
+ err = UV_ENOTSUP;
+ goto out;
+ }
+ } else {
+ goto out;
+ }
+ }
+#else
+ if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
+ err = UV_ENOSYS;
+ goto out;
+ }
+#endif
+
+ bytes_to_send = statsbuf.st_size;
+ in_offset = 0;
+ while (bytes_to_send != 0) {
+ err = uv_fs_sendfile(NULL,
+ &fs_req,
+ dstfd,
+ srcfd,
+ in_offset,
+ bytes_to_send,
+ NULL);
+ uv_fs_req_cleanup(&fs_req);
+ if (err < 0)
+ break;
+ bytes_to_send -= fs_req.result;
+ in_offset += fs_req.result;
+ }
+
+out:
+ if (err < 0)
+ result = err;
+ else
+ result = 0;
+
+ /* Close the source file. */
+ err = uv__close_nocheckstdio(srcfd);
+
+ /* Don't overwrite any existing errors. */
+ if (err != 0 && result == 0)
+ result = err;
+
+ /* Close the destination file if it is open. */
+ if (dstfd >= 0) {
+ err = uv__close_nocheckstdio(dstfd);
+
+ /* Don't overwrite any existing errors. */
+ if (err != 0 && result == 0)
+ result = err;
+
+ /* Remove the destination file if something went wrong. */
+ if (result != 0) {
+ uv_fs_unlink(NULL, &fs_req, req->new_path, NULL);
+ /* Ignore the unlink return value, as an error already happened. */
+ uv_fs_req_cleanup(&fs_req);
+ }
+ }
+
+ if (result == 0)
+ return 0;
+
+ errno = UV__ERR(result);
+ return -1;
+}
+
static void uv__to_stat(struct stat* src, uv_stat_t* dst) {
dst->st_dev = src->st_dev;
dst->st_mode = src->st_mode;
@@ -853,10 +1120,84 @@ static void uv__to_stat(struct stat* src, uv_stat_t* dst) {
}
+static int uv__fs_statx(int fd,
+ const char* path,
+ int is_fstat,
+ int is_lstat,
+ uv_stat_t* buf) {
+ STATIC_ASSERT(UV_ENOSYS != -1);
+#ifdef __linux__
+ static int no_statx;
+ struct uv__statx statxbuf;
+ int dirfd;
+ int flags;
+ int mode;
+ int rc;
+
+ if (no_statx)
+ return UV_ENOSYS;
+
+ dirfd = AT_FDCWD;
+ flags = 0; /* AT_STATX_SYNC_AS_STAT */
+ mode = 0xFFF; /* STATX_BASIC_STATS + STATX_BTIME */
+
+ if (is_fstat) {
+ dirfd = fd;
+ flags |= 0x1000; /* AT_EMPTY_PATH */
+ }
+
+ if (is_lstat)
+ flags |= AT_SYMLINK_NOFOLLOW;
+
+ rc = uv__statx(dirfd, path, flags, mode, &statxbuf);
+
+ if (rc == -1) {
+ /* EPERM happens when a seccomp filter rejects the system call.
+ * Has been observed with libseccomp < 2.3.3 and docker < 18.04.
+ */
+ if (errno != EINVAL && errno != EPERM && errno != ENOSYS)
+ return -1;
+
+ no_statx = 1;
+ return UV_ENOSYS;
+ }
+
+ buf->st_dev = 256 * statxbuf.stx_dev_major + statxbuf.stx_dev_minor;
+ buf->st_mode = statxbuf.stx_mode;
+ buf->st_nlink = statxbuf.stx_nlink;
+ buf->st_uid = statxbuf.stx_uid;
+ buf->st_gid = statxbuf.stx_gid;
+ buf->st_rdev = statxbuf.stx_rdev_major;
+ buf->st_ino = statxbuf.stx_ino;
+ buf->st_size = statxbuf.stx_size;
+ buf->st_blksize = statxbuf.stx_blksize;
+ buf->st_blocks = statxbuf.stx_blocks;
+ buf->st_atim.tv_sec = statxbuf.stx_atime.tv_sec;
+ buf->st_atim.tv_nsec = statxbuf.stx_atime.tv_nsec;
+ buf->st_mtim.tv_sec = statxbuf.stx_mtime.tv_sec;
+ buf->st_mtim.tv_nsec = statxbuf.stx_mtime.tv_nsec;
+ buf->st_ctim.tv_sec = statxbuf.stx_ctime.tv_sec;
+ buf->st_ctim.tv_nsec = statxbuf.stx_ctime.tv_nsec;
+ buf->st_birthtim.tv_sec = statxbuf.stx_btime.tv_sec;
+ buf->st_birthtim.tv_nsec = statxbuf.stx_btime.tv_nsec;
+ buf->st_flags = 0;
+ buf->st_gen = 0;
+
+ return 0;
+#else
+ return UV_ENOSYS;
+#endif /* __linux__ */
+}
+
+
static int uv__fs_stat(const char *path, uv_stat_t *buf) {
struct stat pbuf;
int ret;
+ ret = uv__fs_statx(-1, path, /* is_fstat */ 0, /* is_lstat */ 0, buf);
+ if (ret != UV_ENOSYS)
+ return ret;
+
ret = stat(path, &pbuf);
if (ret == 0)
uv__to_stat(&pbuf, buf);
@@ -869,6 +1210,10 @@ static int uv__fs_lstat(const char *path, uv_stat_t *buf) {
struct stat pbuf;
int ret;
+ ret = uv__fs_statx(-1, path, /* is_fstat */ 0, /* is_lstat */ 1, buf);
+ if (ret != UV_ENOSYS)
+ return ret;
+
ret = lstat(path, &pbuf);
if (ret == 0)
uv__to_stat(&pbuf, buf);
@@ -881,6 +1226,10 @@ static int uv__fs_fstat(int fd, uv_stat_t *buf) {
struct stat pbuf;
int ret;
+ ret = uv__fs_statx(fd, "", /* is_fstat */ 1, /* is_lstat */ 0, buf);
+ if (ret != UV_ENOSYS)
+ return ret;
+
ret = fstat(fd, &pbuf);
if (ret == 0)
uv__to_stat(&pbuf, buf);
@@ -888,9 +1237,21 @@ static int uv__fs_fstat(int fd, uv_stat_t *buf) {
return ret;
}
+static size_t uv__fs_buf_offset(uv_buf_t* bufs, size_t size) {
+ size_t offset;
+ /* Figure out which bufs are done */
+ for (offset = 0; size > 0 && bufs[offset].len <= size; ++offset)
+ size -= bufs[offset].len;
+
+ /* Fix a partial read/write */
+ if (size > 0) {
+ bufs[offset].base += size;
+ bufs[offset].len -= size;
+ }
+ return offset;
+}
-typedef ssize_t (*uv__fs_buf_iter_processor)(uv_fs_t* req);
-static ssize_t uv__fs_buf_iter(uv_fs_t* req, uv__fs_buf_iter_processor process) {
+static ssize_t uv__fs_write_all(uv_fs_t* req) {
unsigned int iovmax;
unsigned int nbufs;
uv_buf_t* bufs;
@@ -907,7 +1268,10 @@ static ssize_t uv__fs_buf_iter(uv_fs_t* req, uv__fs_buf_iter_processor process)
if (req->nbufs > iovmax)
req->nbufs = iovmax;
- result = process(req);
+ do
+ result = uv__fs_write(req);
+ while (result < 0 && errno == EINTR);
+
if (result <= 0) {
if (total == 0)
total = result;
@@ -917,14 +1281,12 @@ static ssize_t uv__fs_buf_iter(uv_fs_t* req, uv__fs_buf_iter_processor process)
if (req->off >= 0)
req->off += result;
+ req->nbufs = uv__fs_buf_offset(req->bufs, result);
req->bufs += req->nbufs;
nbufs -= req->nbufs;
total += result;
}
- if (errno == EINTR && total == -1)
- return total;
-
if (bufs != req->bufsml)
uv__free(bufs);
@@ -941,7 +1303,8 @@ static void uv__fs_work(struct uv__work* w) {
ssize_t r;
req = container_of(w, uv_fs_t, work_req);
- retry_on_eintr = !(req->fs_type == UV_FS_CLOSE);
+ retry_on_eintr = !(req->fs_type == UV_FS_CLOSE ||
+ req->fs_type == UV_FS_READ);
do {
errno = 0;
@@ -955,9 +1318,11 @@ static void uv__fs_work(struct uv__work* w) {
X(ACCESS, access(req->path, req->flags));
X(CHMOD, chmod(req->path, req->mode));
X(CHOWN, chown(req->path, req->uid, req->gid));
- X(CLOSE, close(req->file));
+ X(CLOSE, uv__fs_close(req->file));
+ X(COPYFILE, uv__fs_copyfile(req));
X(FCHMOD, fchmod(req->file, req->mode));
X(FCHOWN, fchown(req->file, req->uid, req->gid));
+ X(LCHOWN, lchown(req->path, req->uid, req->gid));
X(FDATASYNC, uv__fs_fdatasync(req));
X(FSTAT, uv__fs_fstat(req->file, &req->statbuf));
X(FSYNC, uv__fs_fsync(req));
@@ -968,8 +1333,11 @@ static void uv__fs_work(struct uv__work* w) {
X(MKDIR, mkdir(req->path, req->mode));
X(MKDTEMP, uv__fs_mkdtemp(req));
X(OPEN, uv__fs_open(req));
- X(READ, uv__fs_buf_iter(req, uv__fs_read));
+ X(READ, uv__fs_read(req));
X(SCANDIR, uv__fs_scandir(req));
+ X(OPENDIR, uv__fs_opendir(req));
+ X(READDIR, uv__fs_readdir(req));
+ X(CLOSEDIR, uv__fs_closedir(req));
X(READLINK, uv__fs_readlink(req));
X(REALPATH, uv__fs_realpath(req));
X(RENAME, rename(req->path, req->new_path));
@@ -979,14 +1347,14 @@ static void uv__fs_work(struct uv__work* w) {
X(SYMLINK, symlink(req->path, req->new_path));
X(UNLINK, unlink(req->path));
X(UTIME, uv__fs_utime(req));
- X(WRITE, uv__fs_buf_iter(req, uv__fs_write));
+ X(WRITE, uv__fs_write_all(req));
default: abort();
}
#undef X
} while (r == -1 && errno == EINTR && retry_on_eintr);
if (r == -1)
- req->result = -errno;
+ req->result = UV__ERR(errno);
else
req->result = r;
@@ -1004,9 +1372,9 @@ static void uv__fs_done(struct uv__work* w, int status) {
req = container_of(w, uv_fs_t, work_req);
uv__req_unregister(req->loop, req);
- if (status == -ECANCELED) {
+ if (status == UV_ECANCELED) {
assert(req->result == 0);
- req->result = -ECANCELED;
+ req->result = UV_ECANCELED;
}
req->cb(req);
@@ -1084,6 +1452,20 @@ int uv_fs_fchown(uv_loop_t* loop,
}
+int uv_fs_lchown(uv_loop_t* loop,
+ uv_fs_t* req,
+ const char* path,
+ uv_uid_t uid,
+ uv_gid_t gid,
+ uv_fs_cb cb) {
+ INIT(LCHOWN);
+ PATH;
+ req->uid = uid;
+ req->gid = gid;
+ POST;
+}
+
+
int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb) {
INIT(FDATASYNC);
req->file = file;
@@ -1167,11 +1549,8 @@ int uv_fs_mkdtemp(uv_loop_t* loop,
uv_fs_cb cb) {
INIT(MKDTEMP);
req->path = uv__strdup(tpl);
- if (req->path == NULL) {
- if (cb != NULL)
- uv__req_unregister(loop, req);
- return -ENOMEM;
- }
+ if (req->path == NULL)
+ return UV_ENOMEM;
POST;
}
@@ -1196,10 +1575,11 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req,
unsigned int nbufs,
int64_t off,
uv_fs_cb cb) {
+ INIT(READ);
+
if (bufs == NULL || nbufs == 0)
- return -EINVAL;
+ return UV_EINVAL;
- INIT(READ);
req->file = file;
req->nbufs = nbufs;
@@ -1207,11 +1587,8 @@ int uv_fs_read(uv_loop_t* loop, uv_fs_t* req,
if (nbufs > ARRAY_SIZE(req->bufsml))
req->bufs = uv__malloc(nbufs * sizeof(*bufs));
- if (req->bufs == NULL) {
- if (cb != NULL)
- uv__req_unregister(loop, req);
- return -ENOMEM;
- }
+ if (req->bufs == NULL)
+ return UV_ENOMEM;
memcpy(req->bufs, bufs, nbufs * sizeof(*bufs));
@@ -1231,6 +1608,40 @@ int uv_fs_scandir(uv_loop_t* loop,
POST;
}
+int uv_fs_opendir(uv_loop_t* loop,
+ uv_fs_t* req,
+ const char* path,
+ uv_fs_cb cb) {
+ INIT(OPENDIR);
+ PATH;
+ POST;
+}
+
+int uv_fs_readdir(uv_loop_t* loop,
+ uv_fs_t* req,
+ uv_dir_t* dir,
+ uv_fs_cb cb) {
+ INIT(READDIR);
+
+ if (dir == NULL || dir->dir == NULL || dir->dirents == NULL)
+ return UV_EINVAL;
+
+ req->ptr = dir;
+ POST;
+}
+
+int uv_fs_closedir(uv_loop_t* loop,
+ uv_fs_t* req,
+ uv_dir_t* dir,
+ uv_fs_cb cb) {
+ INIT(CLOSEDIR);
+
+ if (dir == NULL)
+ return UV_EINVAL;
+
+ req->ptr = dir;
+ POST;
+}
int uv_fs_readlink(uv_loop_t* loop,
uv_fs_t* req,
@@ -1334,10 +1745,11 @@ int uv_fs_write(uv_loop_t* loop,
unsigned int nbufs,
int64_t off,
uv_fs_cb cb) {
+ INIT(WRITE);
+
if (bufs == NULL || nbufs == 0)
- return -EINVAL;
+ return UV_EINVAL;
- INIT(WRITE);
req->file = file;
req->nbufs = nbufs;
@@ -1345,11 +1757,8 @@ int uv_fs_write(uv_loop_t* loop,
if (nbufs > ARRAY_SIZE(req->bufsml))
req->bufs = uv__malloc(nbufs * sizeof(*bufs));
- if (req->bufs == NULL) {
- if (cb != NULL)
- uv__req_unregister(loop, req);
- return -ENOMEM;
- }
+ if (req->bufs == NULL)
+ return UV_ENOMEM;
memcpy(req->bufs, bufs, nbufs * sizeof(*bufs));
@@ -1359,6 +1768,9 @@ int uv_fs_write(uv_loop_t* loop,
void uv_fs_req_cleanup(uv_fs_t* req) {
+ if (req == NULL)
+ return;
+
/* Only necessary for asychronous requests, i.e., requests with a callback.
* Synchronous ones don't copy their arguments and have req->path and
* req->new_path pointing to user-owned memory. UV_FS_MKDTEMP is the
@@ -1370,10 +1782,37 @@ void uv_fs_req_cleanup(uv_fs_t* req) {
req->path = NULL;
req->new_path = NULL;
+ if (req->fs_type == UV_FS_READDIR && req->ptr != NULL)
+ uv__fs_readdir_cleanup(req);
+
if (req->fs_type == UV_FS_SCANDIR && req->ptr != NULL)
uv__fs_scandir_cleanup(req);
- if (req->ptr != &req->statbuf)
+ if (req->bufs != req->bufsml)
+ uv__free(req->bufs);
+ req->bufs = NULL;
+
+ if (req->fs_type != UV_FS_OPENDIR && req->ptr != &req->statbuf)
uv__free(req->ptr);
req->ptr = NULL;
}
+
+
+int uv_fs_copyfile(uv_loop_t* loop,
+ uv_fs_t* req,
+ const char* path,
+ const char* new_path,
+ int flags,
+ uv_fs_cb cb) {
+ INIT(COPYFILE);
+
+ if (flags & ~(UV_FS_COPYFILE_EXCL |
+ UV_FS_COPYFILE_FICLONE |
+ UV_FS_COPYFILE_FICLONE_FORCE)) {
+ return UV_EINVAL;
+ }
+
+ PATH2;
+ req->flags = flags;
+ POST;
+}
diff --git a/Utilities/cmlibuv/src/unix/fsevents.c b/Utilities/cmlibuv/src/unix/fsevents.c
index 643e233cf..ddacda31f 100644
--- a/Utilities/cmlibuv/src/unix/fsevents.c
+++ b/Utilities/cmlibuv/src/unix/fsevents.c
@@ -21,9 +21,10 @@
#include "uv.h"
#include "internal.h"
-#if TARGET_OS_IPHONE
+#if TARGET_OS_IPHONE || MAC_OS_X_VERSION_MAX_ALLOWED < 1070
/* iOS (currently) doesn't provide the FSEvents-API (nor CoreServices) */
+/* macOS prior to 10.7 doesn't provide the full FSEvents API so use kqueue */
int uv__fsevents_init(uv_fs_event_t* handle) {
return 0;
@@ -230,6 +231,7 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
uv_loop_t* loop;
uv__cf_loop_state_t* state;
uv__fsevents_event_t* event;
+ FSEventStreamEventFlags flags;
QUEUE head;
loop = info;
@@ -245,58 +247,77 @@ static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
/* Process and filter out events */
for (i = 0; i < numEvents; i++) {
+ flags = eventFlags[i];
+
/* Ignore system events */
- if (eventFlags[i] & kFSEventsSystem)
+ if (flags & kFSEventsSystem)
continue;
path = paths[i];
len = strlen(path);
+ if (handle->realpath_len == 0)
+ continue; /* This should be unreachable */
+
/* Filter out paths that are outside handle's request */
- if (strncmp(path, handle->realpath, handle->realpath_len) != 0)
+ if (len < handle->realpath_len)
+ continue;
+
+ if (handle->realpath_len != len &&
+ path[handle->realpath_len] != '/')
+ /* Make sure that realpath actually named a directory,
+ * or that we matched the whole string */
+ continue;
+
+ if (memcmp(path, handle->realpath, handle->realpath_len) != 0)
continue;
- if (handle->realpath_len > 1 || *handle->realpath != '/') {
+ if (!(handle->realpath_len == 1 && handle->realpath[0] == '/')) {
+ /* Remove common prefix, unless the watched folder is "/" */
path += handle->realpath_len;
len -= handle->realpath_len;
- /* Skip forward slash */
- if (*path != '\0') {
+ /* Ignore events with path equal to directory itself */
+ if (len <= 1 && (flags & kFSEventStreamEventFlagItemIsDir))
+ continue;
+
+ if (len == 0) {
+ /* Since we're using fsevents to watch the file itself,
+ * realpath == path, and we now need to get the basename of the file back
+ * (for commonality with other codepaths and platforms). */
+ while (len < handle->realpath_len && path[-1] != '/') {
+ path--;
+ len++;
+ }
+ /* Created and Removed seem to be always set, but don't make sense */
+ flags &= ~kFSEventsRenamed;
+ } else {
+ /* Skip forward slash */
path++;
len--;
}
}
-#ifdef MAC_OS_X_VERSION_10_7
- /* Ignore events with path equal to directory itself */
- if (len == 0)
- continue;
-#endif /* MAC_OS_X_VERSION_10_7 */
-
/* Do not emit events from subdirectories (without option set) */
- if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0 && *path != 0) {
+ if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0 && *path != '\0') {
pos = strchr(path + 1, '/');
if (pos != NULL)
continue;
}
-#ifndef MAC_OS_X_VERSION_10_7
- path = "";
- len = 0;
-#endif /* MAC_OS_X_VERSION_10_7 */
-
event = uv__malloc(sizeof(*event) + len);
if (event == NULL)
break;
memset(event, 0, sizeof(*event));
memcpy(event->path, path, len + 1);
+ event->events = UV_RENAME;
- if ((eventFlags[i] & kFSEventsModified) != 0 &&
- (eventFlags[i] & kFSEventsRenamed) == 0)
- event->events = UV_CHANGE;
- else
- event->events = UV_RENAME;
+ if (0 == (flags & kFSEventsRenamed)) {
+ if (0 != (flags & kFSEventsModified) ||
+ 0 == (flags & kFSEventStreamEventFlagItemIsDir))
+ event->events = UV_CHANGE;
+ }
QUEUE_INSERT_TAIL(&head, &event->member);
}
@@ -361,7 +382,7 @@ static int uv__fsevents_create_stream(uv_loop_t* loop, CFArrayRef paths) {
if (!pFSEventStreamStart(ref)) {
pFSEventStreamInvalidate(ref);
pFSEventStreamRelease(ref);
- return -EMFILE;
+ return UV_EMFILE;
}
state->fsevent_stream = ref;
@@ -422,7 +443,7 @@ static void uv__fsevents_reschedule(uv_fs_event_t* handle,
uv__fsevents_destroy_stream(handle->loop);
/* Any failure below will be a memory failure */
- err = -ENOMEM;
+ err = UV_ENOMEM;
/* Create list of all watched paths */
uv_mutex_lock(&state->fsevent_mutex);
@@ -456,7 +477,7 @@ static void uv__fsevents_reschedule(uv_fs_event_t* handle,
/* Create new FSEventStream */
cf_paths = pCFArrayCreate(NULL, (const void**) paths, path_count, NULL);
if (cf_paths == NULL) {
- err = -ENOMEM;
+ err = UV_ENOMEM;
goto final;
}
err = uv__fsevents_create_stream(handle->loop, cf_paths);
@@ -510,7 +531,7 @@ static int uv__fsevents_global_init(void) {
* but if it ever becomes one, we can turn the dynamic library handles into
* per-event loop properties and have the dynamic linker keep track for us.
*/
- err = -ENOSYS;
+ err = UV_ENOSYS;
core_foundation_handle = dlopen("/System/Library/Frameworks/"
"CoreFoundation.framework/"
"Versions/A/CoreFoundation",
@@ -525,7 +546,7 @@ static int uv__fsevents_global_init(void) {
if (core_services_handle == NULL)
goto out;
- err = -ENOENT;
+ err = UV_ENOENT;
#define V(handle, symbol) \
do { \
*(void **)(&p ## symbol) = dlsym((handle), #symbol); \
@@ -589,7 +610,7 @@ static int uv__fsevents_loop_init(uv_loop_t* loop) {
state = uv__calloc(1, sizeof(*state));
if (state == NULL)
- return -ENOMEM;
+ return UV_ENOMEM;
err = uv_mutex_init(&loop->cf_mutex);
if (err)
@@ -618,7 +639,7 @@ static int uv__fsevents_loop_init(uv_loop_t* loop) {
ctx.perform = uv__cf_loop_cb;
state->signal_source = pCFRunLoopSourceCreate(NULL, 0, &ctx);
if (state->signal_source == NULL) {
- err = -ENOMEM;
+ err = UV_ENOMEM;
goto fail_signal_source_create;
}
@@ -637,7 +658,7 @@ static int uv__fsevents_loop_init(uv_loop_t* loop) {
loop->cf_state = state;
/* uv_thread_t is an alias for pthread_t. */
- err = -pthread_create(&loop->cf_thread, attr, uv__cf_loop_runner, loop);
+ err = UV__ERR(pthread_create(&loop->cf_thread, attr, uv__cf_loop_runner, loop));
if (attr != NULL)
pthread_attr_destroy(attr);
@@ -769,7 +790,7 @@ int uv__cf_loop_signal(uv_loop_t* loop,
item = uv__malloc(sizeof(*item));
if (item == NULL)
- return -ENOMEM;
+ return UV_ENOMEM;
item->handle = handle;
item->type = type;
@@ -799,7 +820,7 @@ int uv__fsevents_init(uv_fs_event_t* handle) {
/* Get absolute path to file */
handle->realpath = realpath(handle->path, NULL);
if (handle->realpath == NULL)
- return -errno;
+ return UV__ERR(errno);
handle->realpath_len = strlen(handle->realpath);
/* Initialize event queue */
@@ -812,13 +833,13 @@ int uv__fsevents_init(uv_fs_event_t* handle) {
*/
handle->cf_cb = uv__malloc(sizeof(*handle->cf_cb));
if (handle->cf_cb == NULL) {
- err = -ENOMEM;
+ err = UV_ENOMEM;
goto fail_cf_cb_malloc;
}
handle->cf_cb->data = handle;
uv_async_init(handle->loop, handle->cf_cb, uv__fsevents_cb);
- handle->cf_cb->flags |= UV__HANDLE_INTERNAL;
+ handle->cf_cb->flags |= UV_HANDLE_INTERNAL;
uv_unref((uv_handle_t*) handle->cf_cb);
err = uv_mutex_init(&handle->cf_mutex);
@@ -863,7 +884,7 @@ int uv__fsevents_close(uv_fs_event_t* handle) {
uv__cf_loop_state_t* state;
if (handle->cf_cb == NULL)
- return -EINVAL;
+ return UV_EINVAL;
/* Remove handle from the list */
state = handle->loop->cf_state;
@@ -877,7 +898,7 @@ int uv__fsevents_close(uv_fs_event_t* handle) {
assert(handle != NULL);
err = uv__cf_loop_signal(handle->loop, handle, kUVCFLoopSignalClosing);
if (err)
- return -err;
+ return UV__ERR(err);
/* Wait for deinitialization */
uv_sem_wait(&state->fsevent_sem);
diff --git a/Utilities/cmlibuv/src/unix/getaddrinfo.c b/Utilities/cmlibuv/src/unix/getaddrinfo.c
index 2049aea2f..d7ca7d1a4 100644
--- a/Utilities/cmlibuv/src/unix/getaddrinfo.c
+++ b/Utilities/cmlibuv/src/unix/getaddrinfo.c
@@ -27,11 +27,13 @@
#include "uv.h"
#include "internal.h"
+#include "idna.h"
#include <errno.h>
#include <stddef.h> /* NULL */
#include <stdlib.h>
#include <string.h>
+#include <net/if.h> /* if_indextoname() */
/* EAI_* constants. */
#include <netdb.h>
@@ -85,12 +87,14 @@ int uv__getaddrinfo_translate_error(int sys_err) {
case EAI_SOCKTYPE: return UV_EAI_SOCKTYPE;
#endif
#if defined(EAI_SYSTEM)
- case EAI_SYSTEM: return -errno;
+ case EAI_SYSTEM: return UV__ERR(errno);
#endif
}
assert(!"unknown EAI_* error code");
abort();
+#ifndef __SUNPRO_C
return 0; /* Pacify compiler. */
+#endif
}
@@ -124,7 +128,7 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) {
req->service = NULL;
req->hostname = NULL;
- if (status == -ECANCELED) {
+ if (status == UV_ECANCELED) {
assert(req->retcode == 0);
req->retcode = UV_EAI_CANCELED;
}
@@ -140,14 +144,33 @@ int uv_getaddrinfo(uv_loop_t* loop,
const char* hostname,
const char* service,
const struct addrinfo* hints) {
+ char hostname_ascii[256];
size_t hostname_len;
size_t service_len;
size_t hints_len;
size_t len;
char* buf;
+ long rc;
if (req == NULL || (hostname == NULL && service == NULL))
- return -EINVAL;
+ return UV_EINVAL;
+
+ /* FIXME(bnoordhuis) IDNA does not seem to work z/OS,
+ * probably because it uses EBCDIC rather than ASCII.
+ */
+#ifdef __MVS__
+ (void) &hostname_ascii;
+#else
+ if (hostname != NULL) {
+ rc = uv__idna_toascii(hostname,
+ hostname + strlen(hostname),
+ hostname_ascii,
+ hostname_ascii + sizeof(hostname_ascii));
+ if (rc < 0)
+ return rc;
+ hostname = hostname_ascii;
+ }
+#endif
hostname_len = hostname ? strlen(hostname) + 1 : 0;
service_len = service ? strlen(service) + 1 : 0;
@@ -155,7 +178,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
buf = uv__malloc(hostname_len + service_len + hints_len);
if (buf == NULL)
- return -ENOMEM;
+ return UV_ENOMEM;
uv__req_init(loop, req, UV_GETADDRINFO);
req->loop = loop;
@@ -185,6 +208,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
if (cb) {
uv__work_submit(loop,
&req->work_req,
+ UV__WORK_SLOW_IO,
uv__getaddrinfo_work,
uv__getaddrinfo_done);
return 0;
@@ -200,3 +224,32 @@ void uv_freeaddrinfo(struct addrinfo* ai) {
if (ai)
freeaddrinfo(ai);
}
+
+
+int uv_if_indextoname(unsigned int ifindex, char* buffer, size_t* size) {
+ char ifname_buf[UV_IF_NAMESIZE];
+ size_t len;
+
+ if (buffer == NULL || size == NULL || *size == 0)
+ return UV_EINVAL;
+
+ if (if_indextoname(ifindex, ifname_buf) == NULL)
+ return UV__ERR(errno);
+
+ len = strnlen(ifname_buf, sizeof(ifname_buf));
+
+ if (*size <= len) {
+ *size = len + 1;
+ return UV_ENOBUFS;
+ }
+
+ memcpy(buffer, ifname_buf, len);
+ buffer[len] = '\0';
+ *size = len;
+
+ return 0;
+}
+
+int uv_if_indextoiid(unsigned int ifindex, char* buffer, size_t* size) {
+ return uv_if_indextoname(ifindex, buffer, size);
+}
diff --git a/Utilities/cmlibuv/src/unix/getnameinfo.c b/Utilities/cmlibuv/src/unix/getnameinfo.c
index b2879d69b..b695081b4 100644
--- a/Utilities/cmlibuv/src/unix/getnameinfo.c
+++ b/Utilities/cmlibuv/src/unix/getnameinfo.c
@@ -61,7 +61,7 @@ static void uv__getnameinfo_done(struct uv__work* w, int status) {
uv__req_unregister(req->loop, req);
host = service = NULL;
- if (status == -ECANCELED) {
+ if (status == UV_ECANCELED) {
assert(req->retcode == 0);
req->retcode = UV_EAI_CANCELED;
} else if (req->retcode == 0) {
@@ -109,6 +109,7 @@ int uv_getnameinfo(uv_loop_t* loop,
if (getnameinfo_cb) {
uv__work_submit(loop,
&req->work_req,
+ UV__WORK_SLOW_IO,
uv__getnameinfo_work,
uv__getnameinfo_done);
return 0;
diff --git a/Utilities/cmlibuv/src/unix/haiku.c b/Utilities/cmlibuv/src/unix/haiku.c
new file mode 100644
index 000000000..7708851c2
--- /dev/null
+++ b/Utilities/cmlibuv/src/unix/haiku.c
@@ -0,0 +1,176 @@
+/* Copyright libuv project contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "uv.h"
+#include "internal.h"
+
+#include <FindDirectory.h> /* find_path() */
+#include <OS.h>
+
+
+void uv_loadavg(double avg[3]) {
+ avg[0] = 0;
+ avg[1] = 0;
+ avg[2] = 0;
+}
+
+
+int uv_exepath(char* buffer, size_t* size) {
+ char abspath[B_PATH_NAME_LENGTH];
+ status_t status;
+ ssize_t abspath_len;
+
+ if (buffer == NULL || size == NULL || *size == 0)
+ return UV_EINVAL;
+
+ status = find_path(B_APP_IMAGE_SYMBOL, B_FIND_PATH_IMAGE_PATH, NULL, abspath,
+ sizeof(abspath));
+ if (status != B_OK)
+ return UV__ERR(status);
+
+ abspath_len = uv__strscpy(buffer, abspath, *size);
+ *size -= 1;
+ if (abspath_len >= 0 && *size > (size_t)abspath_len)
+ *size = (size_t)abspath_len;
+
+ return 0;
+}
+
+
+uint64_t uv_get_free_memory(void) {
+ status_t status;
+ system_info sinfo;
+
+ status = get_system_info(&sinfo);
+ if (status != B_OK)
+ return 0;
+
+ return (sinfo.max_pages - sinfo.used_pages) * B_PAGE_SIZE;
+}
+
+
+uint64_t uv_get_total_memory(void) {
+ status_t status;
+ system_info sinfo;
+
+ status = get_system_info(&sinfo);
+ if (status != B_OK)
+ return 0;
+
+ return sinfo.max_pages * B_PAGE_SIZE;
+}
+
+
+uint64_t uv_get_constrained_memory(void) {
+ return 0; /* Memory constraints are unknown. */
+}
+
+
+int uv_resident_set_memory(size_t* rss) {
+ area_info area;
+ ssize_t cookie;
+ status_t status;
+ thread_info thread;
+
+ status = get_thread_info(find_thread(NULL), &thread);
+ if (status != B_OK)
+ return UV__ERR(status);
+
+ cookie = 0;
+ *rss = 0;
+ while (get_next_area_info(thread.team, &cookie, &area) == B_OK)
+ *rss += area.ram_size;
+
+ return 0;
+}
+
+
+int uv_uptime(double* uptime) {
+ /* system_time() returns time since booting in microseconds */
+ *uptime = (double)system_time() / 1000000;
+ return 0;
+}
+
+
+int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
+ cpu_topology_node_info* topology_infos;
+ int i;
+ status_t status;
+ system_info system;
+ uint32_t topology_count;
+ uint64_t cpuspeed;
+ uv_cpu_info_t* cpu_info;
+
+ if (cpu_infos == NULL || count == NULL)
+ return UV_EINVAL;
+
+ status = get_cpu_topology_info(NULL, &topology_count);
+ if (status != B_OK)
+ return UV__ERR(status);
+
+ topology_infos = uv__malloc(topology_count * sizeof(*topology_infos));
+ if (topology_infos == NULL)
+ return UV_ENOMEM;
+
+ status = get_cpu_topology_info(topology_infos, &topology_count);
+ if (status != B_OK) {
+ uv__free(topology_infos);
+ return UV__ERR(status);
+ }
+
+ cpuspeed = 0;
+ for (i = 0; i < (int)topology_count; i++) {
+ if (topology_infos[i].type == B_TOPOLOGY_CORE) {
+ cpuspeed = topology_infos[i].data.core.default_frequency;
+ break;
+ }
+ }
+
+ uv__free(topology_infos);
+
+ status = get_system_info(&system);
+ if (status != B_OK)
+ return UV__ERR(status);
+
+ *cpu_infos = uv__calloc(system.cpu_count, sizeof(**cpu_infos));
+ if (*cpu_infos == NULL)
+ return UV_ENOMEM;
+
+ /* CPU time and model are not exposed by Haiku. */
+ cpu_info = *cpu_infos;
+ for (i = 0; i < (int)system.cpu_count; i++) {
+ cpu_info->model = uv__strdup("unknown");
+ cpu_info->speed = (int)(cpuspeed / 1000000);
+ cpu_info++;
+ }
+ *count = system.cpu_count;
+
+ return 0;
+}
+
+void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
+ int i;
+
+ for (i = 0; i < count; i++)
+ uv__free(cpu_infos[i].model);
+
+ uv__free(cpu_infos);
+}
diff --git a/Utilities/cmlibuv/src/unix/hpux.c b/Utilities/cmlibuv/src/unix/hpux.c
new file mode 100644
index 000000000..4d3f628b7
--- /dev/null
+++ b/Utilities/cmlibuv/src/unix/hpux.c
@@ -0,0 +1,30 @@
+/* Copyright libuv project contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "uv.h"
+#include "internal.h"
+
+#include <stdint.h>
+#include <time.h>
+
+uint64_t uv__hrtime(uv_clocktype_t type) {
+ return (uint64_t) gethrtime();
+}
diff --git a/Utilities/cmlibuv/src/unix/ibmi.c b/Utilities/cmlibuv/src/unix/ibmi.c
new file mode 100644
index 000000000..c7e105136
--- /dev/null
+++ b/Utilities/cmlibuv/src/unix/ibmi.c
@@ -0,0 +1,250 @@
+/* Copyright libuv project contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "uv.h"
+#include "internal.h"
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <utmp.h>
+#include <libgen.h>
+
+#include <sys/protosw.h>
+#include <procinfo.h>
+#include <sys/proc.h>
+#include <sys/procfs.h>
+
+#include <ctype.h>
+
+#include <sys/mntctl.h>
+#include <sys/vmount.h>
+#include <limits.h>
+#include <strings.h>
+#include <sys/vnode.h>
+
+#include <as400_protos.h>
+
+
+typedef struct {
+ int bytes_available;
+ int bytes_returned;
+ char current_date_and_time[8];
+ char system_name[8];
+ char elapsed_time[6];
+ char restricted_state_flag;
+ char reserved;
+ int percent_processing_unit_used;
+ int jobs_in_system;
+ int percent_permanent_addresses;
+ int percent_temporary_addresses;
+ int system_asp;
+ int percent_system_asp_used;
+ int total_auxiliary_storage;
+ int current_unprotected_storage_used;
+ int maximum_unprotected_storage_used;
+ int percent_db_capability;
+ int main_storage_size;
+ int number_of_partitions;
+ int partition_identifier;
+ int reserved1;
+ int current_processing_capacity;
+ char processor_sharing_attribute;
+ char reserved2[3];
+ int number_of_processors;
+ int active_jobs_in_system;
+ int active_threads_in_system;
+ int maximum_jobs_in_system;
+ int percent_temporary_256mb_segments_used;
+ int percent_temporary_4gb_segments_used;
+ int percent_permanent_256mb_segments_used;
+ int percent_permanent_4gb_segments_used;
+ int percent_current_interactive_performance;
+ int percent_uncapped_cpu_capacity_used;
+ int percent_shared_processor_pool_used;
+ long main_storage_size_long;
+} SSTS0200;
+
+
+static int get_ibmi_system_status(SSTS0200* rcvr) {
+ /* rcvrlen is input parameter 2 to QWCRSSTS */
+ unsigned int rcvrlen = sizeof(*rcvr);
+
+ /* format is input parameter 3 to QWCRSSTS ("SSTS0200" in EBCDIC) */
+ unsigned char format[] = {0xE2, 0xE2, 0xE3, 0xE2, 0xF0, 0xF2, 0xF0, 0xF0};
+
+ /* reset_status is input parameter 4 to QWCRSSTS ("*NO " in EBCDIC) */
+ unsigned char reset_status[] = {
+ 0x5C, 0xD5, 0xD6, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40
+ };
+
+ /* errcode is input parameter 5 to QWCRSSTS */
+ struct _errcode {
+ int bytes_provided;
+ int bytes_available;
+ char msgid[7];
+ } errcode;
+
+ /* qwcrssts_pointer is the 16-byte tagged system pointer to QWCRSSTS */
+ ILEpointer __attribute__((aligned(16))) qwcrssts_pointer;
+
+ /* qwcrssts_argv is the array of argument pointers to QWCRSSTS */
+ void* qwcrssts_argv[6];
+
+ /* Set the IBM i pointer to the QSYS/QWCRSSTS *PGM object */
+ int rc = _RSLOBJ2(&qwcrssts_pointer, RSLOBJ_TS_PGM, "QWCRSSTS", "QSYS");
+
+ if (rc != 0)
+ return rc;
+
+ /* initialize the QWCRSSTS returned info structure */
+ memset(rcvr, 0, sizeof(*rcvr));
+
+ /* initialize the QWCRSSTS error code structure */
+ memset(&errcode, 0, sizeof(errcode));
+ errcode.bytes_provided = sizeof(errcode);
+
+ /* initialize the array of argument pointers for the QWCRSSTS API */
+ qwcrssts_argv[0] = rcvr;
+ qwcrssts_argv[1] = &rcvrlen;
+ qwcrssts_argv[2] = &format;
+ qwcrssts_argv[3] = &reset_status;
+ qwcrssts_argv[4] = &errcode;
+ qwcrssts_argv[5] = NULL;
+
+ /* Call the IBM i QWCRSSTS API from PASE */
+ rc = _PGMCALL(&qwcrssts_pointer, (void**)&qwcrssts_argv, 0);
+
+ return rc;
+}
+
+
+uint64_t uv_get_free_memory(void) {
+ SSTS0200 rcvr;
+
+ if (get_ibmi_system_status(&rcvr))
+ return 0;
+
+ /* The amount of main storage, in kilobytes, in the system. */
+ uint64_t main_storage_size = rcvr.main_storage_size;
+
+ /* The current amount of storage in use for temporary objects.
+ * in millions (M) of bytes.
+ */
+ uint64_t current_unprotected_storage_used =
+ rcvr.current_unprotected_storage_used * 1024ULL;
+
+ uint64_t free_storage_size =
+ (main_storage_size - current_unprotected_storage_used) * 1024ULL;
+
+ return free_storage_size < 0 ? 0 : free_storage_size;
+}
+
+
+uint64_t uv_get_total_memory(void) {
+ SSTS0200 rcvr;
+
+ if (get_ibmi_system_status(&rcvr))
+ return 0;
+
+ return (uint64_t)rcvr.main_storage_size * 1024ULL;
+}
+
+
+uint64_t uv_get_constrained_memory(void) {
+ return 0; /* Memory constraints are unknown. */
+}
+
+
+void uv_loadavg(double avg[3]) {
+ SSTS0200 rcvr;
+
+ if (get_ibmi_system_status(&rcvr)) {
+ avg[0] = avg[1] = avg[2] = 0;
+ return;
+ }
+
+ /* The average (in tenths) of the elapsed time during which the processing
+ * units were in use. For example, a value of 411 in binary would be 41.1%.
+ * This percentage could be greater than 100% for an uncapped partition.
+ */
+ double processing_unit_used_percent =
+ rcvr.percent_processing_unit_used / 1000.0;
+
+ avg[0] = avg[1] = avg[2] = processing_unit_used_percent;
+}
+
+
+int uv_resident_set_memory(size_t* rss) {
+ *rss = 0;
+ return 0;
+}
+
+
+int uv_uptime(double* uptime) {
+ return UV_ENOSYS;
+}
+
+
+int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
+ unsigned int numcpus, idx = 0;
+ uv_cpu_info_t* cpu_info;
+
+ *cpu_infos = NULL;
+ *count = 0;
+
+ numcpus = sysconf(_SC_NPROCESSORS_ONLN);
+
+ *cpu_infos = uv__malloc(numcpus * sizeof(uv_cpu_info_t));
+ if (!*cpu_infos) {
+ return UV_ENOMEM;
+ }
+
+ cpu_info = *cpu_infos;
+ for (idx = 0; idx < numcpus; idx++) {
+ cpu_info->speed = 0;
+ cpu_info->model = uv__strdup("unknown");
+ cpu_info->cpu_times.user = 0;
+ cpu_info->cpu_times.sys = 0;
+ cpu_info->cpu_times.idle = 0;
+ cpu_info->cpu_times.irq = 0;
+ cpu_info->cpu_times.nice = 0;
+ cpu_info++;
+ }
+ *count = numcpus;
+
+ return 0;
+}
+
diff --git a/Utilities/cmlibuv/src/unix/internal.h b/Utilities/cmlibuv/src/unix/internal.h
index 2e3afa6c8..b43c0b190 100644
--- a/Utilities/cmlibuv/src/unix/internal.h
+++ b/Utilities/cmlibuv/src/unix/internal.h
@@ -29,6 +29,7 @@
#include <string.h> /* strrchr */
#include <fcntl.h> /* O_CLOEXEC, may be */
#include <stdio.h>
+#include <errno.h>
#if defined(__STRICT_ANSI__)
# define inline __inline
@@ -59,7 +60,17 @@
# include <AvailabilityMacros.h>
#endif
-#if defined(__ANDROID__)
+#if defined(CMAKE_BOOTSTRAP)
+# undef pthread_atfork
+# define pthread_atfork(prepare, parent, child) \
+ uv__pthread_atfork(prepare, parent, child)
+int uv__pthread_atfork(void (*prepare)(void), void (*parent)(void),
+ void (*child)(void));
+# undef pthread_sigmask
+# define pthread_sigmask(how, set, oldset) \
+ uv__pthread_sigmask(how, set, oldset)
+int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset);
+#elif defined(__ANDROID__)
int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset);
# ifdef pthread_sigmask
# undef pthread_sigmask
@@ -94,8 +105,7 @@ int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset);
*/
#if defined(__clang__) || \
defined(__GNUC__) || \
- defined(__INTEL_COMPILER) || \
- defined(__SUNPRO_C)
+ defined(__INTEL_COMPILER)
# define UV_DESTRUCTOR(declaration) __attribute__((destructor)) declaration
# define UV_UNUSED(declaration) __attribute__((unused)) declaration
#else
@@ -110,6 +120,12 @@ int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset);
# define UV__POLLRDHUP 0x2000
#endif
+#ifdef POLLPRI
+# define UV__POLLPRI POLLPRI
+#else
+# define UV__POLLPRI 0
+#endif
+
#if !defined(O_CLOEXEC) && defined(__FreeBSD__)
/*
* It may be that we are just missing `__POSIX_VISIBLE >= 200809`.
@@ -120,29 +136,15 @@ int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset);
typedef struct uv__stream_queued_fds_s uv__stream_queued_fds_t;
-/* handle flags */
+/* loop flags */
enum {
- UV_CLOSING = 0x01, /* uv_close() called but not finished. */
- UV_CLOSED = 0x02, /* close(2) finished. */
- UV_STREAM_READING = 0x04, /* uv_read_start() called. */
- UV_STREAM_SHUTTING = 0x08, /* uv_shutdown() called but not complete. */
- UV_STREAM_SHUT = 0x10, /* Write side closed. */
- UV_STREAM_READABLE = 0x20, /* The stream is readable */
- UV_STREAM_WRITABLE = 0x40, /* The stream is writable */
- UV_STREAM_BLOCKING = 0x80, /* Synchronous writes. */
- UV_STREAM_READ_PARTIAL = 0x100, /* read(2) read less than requested. */
- UV_STREAM_READ_EOF = 0x200, /* read(2) read EOF. */
- UV_TCP_NODELAY = 0x400, /* Disable Nagle. */
- UV_TCP_KEEPALIVE = 0x800, /* Turn on keep-alive. */
- UV_TCP_SINGLE_ACCEPT = 0x1000, /* Only accept() when idle. */
- UV_HANDLE_IPV6 = 0x10000, /* Handle is bound to a IPv6 socket. */
- UV_UDP_PROCESSING = 0x20000, /* Handle is running the send callback queue. */
- UV_HANDLE_BOUND = 0x40000 /* Handle is bound to an address and port */
+ UV_LOOP_BLOCK_SIGPROF = 1
};
-/* loop flags */
+/* flags of excluding ifaddr */
enum {
- UV_LOOP_BLOCK_SIGPROF = 1
+ UV__EXCLUDE_IFPHYS,
+ UV__EXCLUDE_IFADDR
};
typedef enum {
@@ -163,7 +165,8 @@ struct uv__stream_queued_fds_s {
defined(__FreeBSD__) || \
defined(__FreeBSD_kernel__) || \
defined(__linux__) || \
- defined(__OpenBSD__)
+ defined(__OpenBSD__) || \
+ defined(__NetBSD__)
#define uv__cloexec uv__cloexec_ioctl
#define uv__nonblock uv__nonblock_ioctl
#else
@@ -171,15 +174,27 @@ struct uv__stream_queued_fds_s {
#define uv__nonblock uv__nonblock_fcntl
#endif
+/* On Linux, uv__nonblock_fcntl() and uv__nonblock_ioctl() do not commute
+ * when O_NDELAY is not equal to O_NONBLOCK. Case in point: linux/sparc32
+ * and linux/sparc64, where O_NDELAY is O_NONBLOCK + another bit.
+ *
+ * Libuv uses uv__nonblock_fcntl() directly sometimes so ensure that it
+ * commutes with uv__nonblock().
+ */
+#if defined(__linux__) && O_NDELAY != O_NONBLOCK
+#undef uv__nonblock
+#define uv__nonblock uv__nonblock_fcntl
+#endif
+
/* core */
int uv__cloexec_ioctl(int fd, int set);
int uv__cloexec_fcntl(int fd, int set);
int uv__nonblock_ioctl(int fd, int set);
int uv__nonblock_fcntl(int fd, int set);
-int uv__close(int fd);
+int uv__close(int fd); /* preserves errno */
int uv__close_nocheckstdio(int fd);
+int uv__close_nocancel(int fd);
int uv__socket(int domain, int type, int protocol);
-int uv__dup(int fd);
ssize_t uv__recvmsg(int fd, struct msghdr *msg, int flags);
void uv__make_close_pending(uv_handle_t* handle);
int uv__getiovmax(void);
@@ -193,6 +208,7 @@ int uv__io_active(const uv__io_t* w, unsigned int events);
int uv__io_check_fd(uv_loop_t* loop, int fd);
void uv__io_poll(uv_loop_t* loop, int timeout); /* in milliseconds or -1 */
int uv__io_fork(uv_loop_t* loop);
+int uv__fd_exists(uv_loop_t* loop, int fd);
/* async */
void uv__async_stop(uv_loop_t* loop);
@@ -225,10 +241,6 @@ int uv__tcp_keepalive(int fd, int on, unsigned int delay);
/* pipe */
int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb);
-/* timer */
-void uv__run_timers(uv_loop_t* loop);
-int uv__next_timeout(const uv_loop_t* loop);
-
/* signal */
void uv__signal_close(uv_signal_t* handle);
void uv__signal_global_once_init(void);
@@ -253,7 +265,6 @@ void uv__prepare_close(uv_prepare_t* handle);
void uv__process_close(uv_process_t* handle);
void uv__stream_close(uv_stream_t* handle);
void uv__tcp_close(uv_tcp_t* handle);
-void uv__timer_close(uv_timer_t* handle);
void uv__udp_close(uv_udp_t* handle);
void uv__udp_finish_close(uv_udp_t* handle);
uv_handle_type uv__handle_type(int fd);
@@ -261,7 +272,7 @@ FILE* uv__open_file(const char* path);
int uv__getpwuid_r(uv_passwd_t* pwd);
-#if defined(__APPLE__)
+#if defined(__APPLE__) && !defined(CMAKE_BOOTSTRAP)
int uv___stream_fd(const uv_stream_t* handle);
#define uv__stream_fd(handle) (uv___stream_fd((const uv_stream_t*) (handle)))
#else
@@ -283,24 +294,6 @@ int uv__fsevents_init(uv_fs_event_t* handle);
int uv__fsevents_close(uv_fs_event_t* handle);
void uv__fsevents_loop_delete(uv_loop_t* loop);
-/* OSX < 10.7 has no file events, polyfill them */
-#ifndef MAC_OS_X_VERSION_10_7
-
-static const int kFSEventStreamCreateFlagFileEvents = 0x00000010;
-static const int kFSEventStreamEventFlagItemCreated = 0x00000100;
-static const int kFSEventStreamEventFlagItemRemoved = 0x00000200;
-static const int kFSEventStreamEventFlagItemInodeMetaMod = 0x00000400;
-static const int kFSEventStreamEventFlagItemRenamed = 0x00000800;
-static const int kFSEventStreamEventFlagItemModified = 0x00001000;
-static const int kFSEventStreamEventFlagItemFinderInfoMod = 0x00002000;
-static const int kFSEventStreamEventFlagItemChangeOwner = 0x00004000;
-static const int kFSEventStreamEventFlagItemXattrMod = 0x00008000;
-static const int kFSEventStreamEventFlagItemIsFile = 0x00010000;
-static const int kFSEventStreamEventFlagItemIsDir = 0x00020000;
-static const int kFSEventStreamEventFlagItemIsSymlink = 0x00040000;
-
-#endif /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070 */
-
#endif /* defined(__APPLE__) */
UV_UNUSED(static void uv__update_time(uv_loop_t* loop)) {
@@ -323,4 +316,11 @@ UV_UNUSED(static char* uv__basename_r(const char* path)) {
int uv__inotify_fork(uv_loop_t* loop, void* old_watchers);
#endif
+typedef int (*uv__peersockfunc)(int, struct sockaddr*, socklen_t*);
+
+int uv__getsockpeername(const uv_handle_t* handle,
+ uv__peersockfunc func,
+ struct sockaddr* name,
+ int* namelen);
+
#endif /* UV_UNIX_INTERNAL_H_ */
diff --git a/Utilities/cmlibuv/src/unix/kqueue.c b/Utilities/cmlibuv/src/unix/kqueue.c
index 6bc60bbe4..c04e7a485 100644
--- a/Utilities/cmlibuv/src/unix/kqueue.c
+++ b/Utilities/cmlibuv/src/unix/kqueue.c
@@ -34,13 +34,24 @@
#include <fcntl.h>
#include <time.h>
+/*
+ * Required on
+ * - Until at least FreeBSD 11.0
+ * - Older versions of Mac OS X
+ *
+ * http://www.boost.org/doc/libs/1_61_0/boost/asio/detail/kqueue_reactor.hpp
+ */
+#ifndef EV_OOBAND
+#define EV_OOBAND EV_FLAG1
+#endif
+
static void uv__fs_event(uv_loop_t* loop, uv__io_t* w, unsigned int fflags);
int uv__kqueue_init(uv_loop_t* loop) {
loop->backend_fd = kqueue();
if (loop->backend_fd == -1)
- return -errno;
+ return UV__ERR(errno);
uv__cloexec(loop->backend_fd, 1);
@@ -48,17 +59,18 @@ int uv__kqueue_init(uv_loop_t* loop) {
}
+#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
static int uv__has_forked_with_cfrunloop;
+#endif
int uv__io_fork(uv_loop_t* loop) {
int err;
- uv__close(loop->backend_fd);
loop->backend_fd = -1;
err = uv__kqueue_init(loop);
if (err)
return err;
-#if defined(__APPLE__)
+#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if (loop->cf_state != NULL) {
/* We cannot start another CFRunloop and/or thread in the child
process; CF aborts if you try or if you try to touch the thread
@@ -74,7 +86,7 @@ int uv__io_fork(uv_loop_t* loop) {
uv__free(loop->cf_state);
loop->cf_state = NULL;
}
-#endif
+#endif /* #if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 */
return err;
}
@@ -86,7 +98,7 @@ int uv__io_check_fd(uv_loop_t* loop, int fd) {
rc = 0;
EV_SET(&ev, fd, EVFILT_READ, EV_ADD, 0, 0, 0);
if (kevent(loop->backend_fd, &ev, 1, NULL, 0, NULL))
- rc = -errno;
+ rc = UV__ERR(errno);
EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, 0);
if (rc == 0)
@@ -166,6 +178,16 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
}
}
+ if ((w->events & UV__POLLPRI) == 0 && (w->pevents & UV__POLLPRI) != 0) {
+ EV_SET(events + nevents, w->fd, EV_OOBAND, EV_ADD, 0, 0, 0);
+
+ if (++nevents == ARRAY_SIZE(events)) {
+ if (kevent(loop->backend_fd, events, nevents, NULL, 0, NULL))
+ abort();
+ nevents = 0;
+ }
+ }
+
w->events = w->pevents;
}
@@ -239,8 +261,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
w = loop->watchers[fd];
if (w == NULL) {
- /* File descriptor that we've stopped watching, disarm it. */
- /* TODO batch up */
+ /* File descriptor that we've stopped watching, disarm it.
+ * TODO: batch up. */
struct kevent events[1];
EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0);
@@ -275,6 +297,20 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
}
}
+ if (ev->filter == EV_OOBAND) {
+ if (w->pevents & UV__POLLPRI) {
+ revents |= UV__POLLPRI;
+ w->rcount = ev->data;
+ } else {
+ /* TODO batch up */
+ struct kevent events[1];
+ EV_SET(events + 0, fd, ev->filter, EV_DELETE, 0, 0, 0);
+ if (kevent(loop->backend_fd, events, 1, NULL, 0, NULL))
+ if (errno != ENOENT)
+ abort();
+ }
+ }
+
if (ev->filter == EVFILT_WRITE) {
if (w->pevents & POLLOUT) {
revents |= POLLOUT;
@@ -351,6 +387,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
uintptr_t nfds;
assert(loop->watchers != NULL);
+ assert(fd >= 0);
events = (struct kevent*) loop->watchers[loop->nwatchers];
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
@@ -416,49 +453,51 @@ int uv_fs_event_start(uv_fs_event_t* handle,
uv_fs_event_cb cb,
const char* path,
unsigned int flags) {
-#if defined(__APPLE__)
- struct stat statbuf;
-#endif /* defined(__APPLE__) */
int fd;
if (uv__is_active(handle))
- return -EINVAL;
-
- /* TODO open asynchronously - but how do we report back errors? */
- fd = open(path, O_RDONLY);
- if (fd == -1)
- return -errno;
-
- uv__handle_start(handle);
- uv__io_init(&handle->event_watcher, uv__fs_event, fd);
- handle->path = uv__strdup(path);
- handle->cb = cb;
-
-#if defined(__APPLE__)
- if (uv__has_forked_with_cfrunloop)
- goto fallback;
+ return UV_EINVAL;
+#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
/* Nullify field to perform checks later */
handle->cf_cb = NULL;
handle->realpath = NULL;
handle->realpath_len = 0;
handle->cf_flags = flags;
- if (fstat(fd, &statbuf))
- goto fallback;
- /* FSEvents works only with directories */
- if (!(statbuf.st_mode & S_IFDIR))
- goto fallback;
-
- /* The fallback fd is no longer needed */
- uv__close(fd);
- handle->event_watcher.fd = -1;
+ if (!uv__has_forked_with_cfrunloop) {
+ int r;
+ /* The fallback fd is not used */
+ handle->event_watcher.fd = -1;
+ handle->path = uv__strdup(path);
+ if (handle->path == NULL)
+ return UV_ENOMEM;
+ handle->cb = cb;
+ r = uv__fsevents_init(handle);
+ if (r == 0) {
+ uv__handle_start(handle);
+ } else {
+ uv__free(handle->path);
+ handle->path = NULL;
+ }
+ return r;
+ }
+#endif /* #if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 */
- return uv__fsevents_init(handle);
+ /* TODO open asynchronously - but how do we report back errors? */
+ fd = open(path, O_RDONLY);
+ if (fd == -1)
+ return UV__ERR(errno);
-fallback:
-#endif /* defined(__APPLE__) */
+ handle->path = uv__strdup(path);
+ if (handle->path == NULL) {
+ uv__close_nocheckstdio(fd);
+ return UV_ENOMEM;
+ }
+ handle->cb = cb;
+ uv__handle_start(handle);
+ uv__io_init(&handle->event_watcher, uv__fs_event, fd);
uv__io_start(handle->loop, &handle->event_watcher, POLLIN);
return 0;
@@ -466,29 +505,29 @@ fallback:
int uv_fs_event_stop(uv_fs_event_t* handle) {
+ int r;
+ r = 0;
+
if (!uv__is_active(handle))
return 0;
uv__handle_stop(handle);
-#if defined(__APPLE__)
- if (uv__has_forked_with_cfrunloop || uv__fsevents_close(handle))
-#endif /* defined(__APPLE__) */
- {
- uv__io_close(handle->loop, &handle->event_watcher);
- }
-
- uv__free(handle->path);
- handle->path = NULL;
+#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
+ if (!uv__has_forked_with_cfrunloop)
+ r = uv__fsevents_close(handle);
+#endif
if (handle->event_watcher.fd != -1) {
- /* When FSEvents is used, we don't use the event_watcher's fd under certain
- * confitions. (see uv_fs_event_start) */
+ uv__io_close(handle->loop, &handle->event_watcher);
uv__close(handle->event_watcher.fd);
handle->event_watcher.fd = -1;
}
- return 0;
+ uv__free(handle->path);
+ handle->path = NULL;
+
+ return r;
}
diff --git a/Utilities/cmlibuv/src/unix/linux-core.c b/Utilities/cmlibuv/src/unix/linux-core.c
index 2866e9385..b539beb86 100644
--- a/Utilities/cmlibuv/src/unix/linux-core.c
+++ b/Utilities/cmlibuv/src/unix/linux-core.c
@@ -20,12 +20,13 @@
/* We lean on the fact that POLL{IN,OUT,ERR,HUP} correspond with their
* EPOLL* counterparts. We use the POLL* variants in this file because that
- * is what libuv uses elsewhere and it avoids a dependency on <sys/epoll.h>.
+ * is what libuv uses elsewhere.
*/
#include "uv.h"
#include "internal.h"
+#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -34,6 +35,7 @@
#include <errno.h>
#include <net/if.h>
+#include <sys/epoll.h>
#include <sys/param.h>
#include <sys/prctl.h>
#include <sys/sysinfo.h>
@@ -51,7 +53,7 @@
#ifdef HAVE_IFADDRS_H
# if defined(__ANDROID__)
-# include "android-ifaddrs.h"
+# include "uv/android-ifaddrs.h"
# else
# include <ifaddrs.h>
# endif
@@ -78,19 +80,23 @@ static int read_times(FILE* statfile_fp,
unsigned int numcpus,
uv_cpu_info_t* ci);
static void read_speeds(unsigned int numcpus, uv_cpu_info_t* ci);
-static unsigned long read_cpufreq(unsigned int cpunum);
+static uint64_t read_cpufreq(unsigned int cpunum);
int uv__platform_loop_init(uv_loop_t* loop) {
int fd;
- fd = uv__epoll_create1(UV__EPOLL_CLOEXEC);
+ /* It was reported that EPOLL_CLOEXEC is not defined on Android API < 21,
+ * a.k.a. Lollipop. Since EPOLL_CLOEXEC is an alias for O_CLOEXEC on all
+ * architectures, we just use that instead.
+ */
+ fd = epoll_create1(O_CLOEXEC);
/* epoll_create1() can fail either because it's not implemented (old kernel)
- * or because it doesn't understand the EPOLL_CLOEXEC flag.
+ * or because it doesn't understand the O_CLOEXEC flag.
*/
if (fd == -1 && (errno == ENOSYS || errno == EINVAL)) {
- fd = uv__epoll_create(256);
+ fd = epoll_create(256);
if (fd != -1)
uv__cloexec(fd, 1);
@@ -101,7 +107,7 @@ int uv__platform_loop_init(uv_loop_t* loop) {
loop->inotify_watchers = NULL;
if (fd == -1)
- return -errno;
+ return UV__ERR(errno);
return 0;
}
@@ -134,20 +140,21 @@ void uv__platform_loop_delete(uv_loop_t* loop) {
void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
- struct uv__epoll_event* events;
- struct uv__epoll_event dummy;
+ struct epoll_event* events;
+ struct epoll_event dummy;
uintptr_t i;
uintptr_t nfds;
assert(loop->watchers != NULL);
+ assert(fd >= 0);
- events = (struct uv__epoll_event*) loop->watchers[loop->nwatchers];
+ events = (struct epoll_event*) loop->watchers[loop->nwatchers];
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
if (events != NULL)
/* Invalidate events with same file descriptor */
for (i = 0; i < nfds; i++)
- if ((int) events[i].data == fd)
- events[i].data = -1;
+ if (events[i].data.fd == fd)
+ events[i].data.fd = -1;
/* Remove the file descriptor from the epoll.
* This avoids a problem where the same file description remains open
@@ -160,25 +167,26 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
* has the EPOLLWAKEUP flag set generates spurious audit syslog warnings.
*/
memset(&dummy, 0, sizeof(dummy));
- uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, &dummy);
+ epoll_ctl(loop->backend_fd, EPOLL_CTL_DEL, fd, &dummy);
}
}
int uv__io_check_fd(uv_loop_t* loop, int fd) {
- struct uv__epoll_event e;
+ struct epoll_event e;
int rc;
+ memset(&e, 0, sizeof(e));
e.events = POLLIN;
- e.data = -1;
+ e.data.fd = -1;
rc = 0;
- if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_ADD, fd, &e))
+ if (epoll_ctl(loop->backend_fd, EPOLL_CTL_ADD, fd, &e))
if (errno != EEXIST)
- rc = -errno;
+ rc = UV__ERR(errno);
if (rc == 0)
- if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, &e))
+ if (epoll_ctl(loop->backend_fd, EPOLL_CTL_DEL, fd, &e))
abort();
return rc;
@@ -195,16 +203,14 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
* that being the largest value I have seen in the wild (and only once.)
*/
static const int max_safe_timeout = 1789569;
- static int no_epoll_pwait;
- static int no_epoll_wait;
- struct uv__epoll_event events[1024];
- struct uv__epoll_event* pe;
- struct uv__epoll_event e;
+ struct epoll_event events[1024];
+ struct epoll_event* pe;
+ struct epoll_event e;
int real_timeout;
QUEUE* q;
uv__io_t* w;
sigset_t sigset;
- uint64_t sigmask;
+ sigset_t* psigset;
uint64_t base;
int have_signals;
int nevents;
@@ -219,6 +225,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
return;
}
+ memset(&e, 0, sizeof(e));
+
while (!QUEUE_EMPTY(&loop->watcher_queue)) {
q = QUEUE_HEAD(&loop->watcher_queue);
QUEUE_REMOVE(q);
@@ -230,35 +238,35 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
assert(w->fd < (int) loop->nwatchers);
e.events = w->pevents;
- e.data = w->fd;
+ e.data.fd = w->fd;
if (w->events == 0)
- op = UV__EPOLL_CTL_ADD;
+ op = EPOLL_CTL_ADD;
else
- op = UV__EPOLL_CTL_MOD;
+ op = EPOLL_CTL_MOD;
/* XXX Future optimization: do EPOLL_CTL_MOD lazily if we stop watching
* events, skip the syscall and squelch the events after epoll_wait().
*/
- if (uv__epoll_ctl(loop->backend_fd, op, w->fd, &e)) {
+ if (epoll_ctl(loop->backend_fd, op, w->fd, &e)) {
if (errno != EEXIST)
abort();
- assert(op == UV__EPOLL_CTL_ADD);
+ assert(op == EPOLL_CTL_ADD);
/* We've reactivated a file descriptor that's been watched before. */
- if (uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_MOD, w->fd, &e))
+ if (epoll_ctl(loop->backend_fd, EPOLL_CTL_MOD, w->fd, &e))
abort();
}
w->events = w->pevents;
}
- sigmask = 0;
+ psigset = NULL;
if (loop->flags & UV_LOOP_BLOCK_SIGPROF) {
sigemptyset(&sigset);
sigaddset(&sigset, SIGPROF);
- sigmask |= 1 << (SIGPROF - 1);
+ psigset = &sigset;
}
assert(timeout >= -1);
@@ -273,30 +281,11 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
if (sizeof(int32_t) == sizeof(long) && timeout >= max_safe_timeout)
timeout = max_safe_timeout;
- if (sigmask != 0 && no_epoll_pwait != 0)
- if (pthread_sigmask(SIG_BLOCK, &sigset, NULL))
- abort();
-
- if (no_epoll_wait != 0 || (sigmask != 0 && no_epoll_pwait == 0)) {
- nfds = uv__epoll_pwait(loop->backend_fd,
- events,
- ARRAY_SIZE(events),
- timeout,
- sigmask);
- if (nfds == -1 && errno == ENOSYS)
- no_epoll_pwait = 1;
- } else {
- nfds = uv__epoll_wait(loop->backend_fd,
- events,
- ARRAY_SIZE(events),
- timeout);
- if (nfds == -1 && errno == ENOSYS)
- no_epoll_wait = 1;
- }
-
- if (sigmask != 0 && no_epoll_pwait != 0)
- if (pthread_sigmask(SIG_UNBLOCK, &sigset, NULL))
- abort();
+ nfds = epoll_pwait(loop->backend_fd,
+ events,
+ ARRAY_SIZE(events),
+ timeout,
+ psigset);
/* Update loop->time unconditionally. It's tempting to skip the update when
* timeout == 0 (i.e. non-blocking poll) but there is no guarantee that the
@@ -317,12 +306,6 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
}
if (nfds == -1) {
- if (errno == ENOSYS) {
- /* epoll_wait() or epoll_pwait() failed, try the other system call. */
- assert(no_epoll_wait == 0 || no_epoll_pwait == 0);
- continue;
- }
-
if (errno != EINTR)
abort();
@@ -344,7 +327,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
loop->watchers[loop->nwatchers + 1] = (void*) (uintptr_t) nfds;
for (i = 0; i < nfds; i++) {
pe = events + i;
- fd = pe->data;
+ fd = pe->data.fd;
/* Skip invalidated events, see uv__platform_invalidate_fd */
if (fd == -1)
@@ -361,7 +344,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
* Ignore all errors because we may be racing with another thread
* when the file descriptor is closed.
*/
- uv__epoll_ctl(loop->backend_fd, UV__EPOLL_CTL_DEL, fd, pe);
+ epoll_ctl(loop->backend_fd, EPOLL_CTL_DEL, fd, pe);
continue;
}
@@ -388,7 +371,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
* free when we switch over to edge-triggered I/O.
*/
if (pe->events == POLLERR || pe->events == POLLHUP)
- pe->events |= w->pevents & (POLLIN | POLLOUT);
+ pe->events |=
+ w->pevents & (POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI);
if (pe->events != 0) {
/* Run signal watchers last. This also affects child process watchers
@@ -485,7 +469,7 @@ int uv_resident_set_memory(size_t* rss) {
while (fd == -1 && errno == EINTR);
if (fd == -1)
- return -errno;
+ return UV__ERR(errno);
do
n = read(fd, buf, sizeof(buf) - 1);
@@ -493,7 +477,7 @@ int uv_resident_set_memory(size_t* rss) {
uv__close(fd);
if (n == -1)
- return -errno;
+ return UV__ERR(errno);
buf[n] = '\0';
s = strchr(buf, ' ');
@@ -525,7 +509,7 @@ int uv_resident_set_memory(size_t* rss) {
return 0;
err:
- return -EINVAL;
+ return UV_EINVAL;
}
@@ -547,7 +531,7 @@ int uv_uptime(double* uptime) {
}
if (r)
- return -errno;
+ return UV__ERR(errno);
*uptime = now.tv_sec;
return 0;
@@ -559,7 +543,7 @@ static int uv__cpu_num(FILE* statfile_fp, unsigned int* numcpus) {
char buf[1024];
if (!fgets(buf, sizeof(buf), statfile_fp))
- return -EIO;
+ return UV_EIO;
num = 0;
while (fgets(buf, sizeof(buf), statfile_fp)) {
@@ -569,7 +553,7 @@ static int uv__cpu_num(FILE* statfile_fp, unsigned int* numcpus) {
}
if (num == 0)
- return -EIO;
+ return UV_EIO;
*numcpus = num;
return 0;
@@ -587,13 +571,13 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
statfile_fp = uv__open_file("/proc/stat");
if (statfile_fp == NULL)
- return -errno;
+ return UV__ERR(errno);
err = uv__cpu_num(statfile_fp, &numcpus);
if (err < 0)
goto out;
- err = -ENOMEM;
+ err = UV_ENOMEM;
ci = uv__calloc(numcpus, sizeof(*ci));
if (ci == NULL)
goto out;
@@ -667,7 +651,7 @@ static int read_models(unsigned int numcpus, uv_cpu_info_t* ci) {
defined(__x86_64__)
fp = uv__open_file("/proc/cpuinfo");
if (fp == NULL)
- return -errno;
+ return UV__ERR(errno);
while (fgets(buf, sizeof(buf), fp)) {
if (model_idx < numcpus) {
@@ -676,7 +660,7 @@ static int read_models(unsigned int numcpus, uv_cpu_info_t* ci) {
model = uv__strndup(model, strlen(model) - 1); /* Strip newline. */
if (model == NULL) {
fclose(fp);
- return -ENOMEM;
+ return UV_ENOMEM;
}
ci[model_idx++].model = model;
continue;
@@ -695,7 +679,7 @@ static int read_models(unsigned int numcpus, uv_cpu_info_t* ci) {
model = uv__strndup(model, strlen(model) - 1); /* Strip newline. */
if (model == NULL) {
fclose(fp);
- return -ENOMEM;
+ return UV_ENOMEM;
}
ci[model_idx++].model = model;
continue;
@@ -725,7 +709,7 @@ static int read_models(unsigned int numcpus, uv_cpu_info_t* ci) {
while (model_idx < numcpus) {
model = uv__strndup(inferred_model, strlen(inferred_model));
if (model == NULL)
- return -ENOMEM;
+ return UV_ENOMEM;
ci[model_idx++].model = model;
}
@@ -736,20 +720,20 @@ static int read_models(unsigned int numcpus, uv_cpu_info_t* ci) {
static int read_times(FILE* statfile_fp,
unsigned int numcpus,
uv_cpu_info_t* ci) {
- unsigned long clock_ticks;
struct uv_cpu_times_s ts;
- unsigned long user;
- unsigned long nice;
- unsigned long sys;
- unsigned long idle;
- unsigned long dummy;
- unsigned long irq;
- unsigned int num;
- unsigned int len;
+ uint64_t clock_ticks;
+ uint64_t user;
+ uint64_t nice;
+ uint64_t sys;
+ uint64_t idle;
+ uint64_t dummy;
+ uint64_t irq;
+ uint64_t num;
+ uint64_t len;
char buf[1024];
clock_ticks = sysconf(_SC_CLK_TCK);
- assert(clock_ticks != (unsigned long) -1);
+ assert(clock_ticks != (uint64_t) -1);
assert(clock_ticks != 0);
rewind(statfile_fp);
@@ -782,7 +766,8 @@ static int read_times(FILE* statfile_fp,
* fields, they're not allowed in C89 mode.
*/
if (6 != sscanf(buf + len,
- "%lu %lu %lu %lu %lu %lu",
+ "%" PRIu64 " %" PRIu64 " %" PRIu64
+ "%" PRIu64 " %" PRIu64 " %" PRIu64,
&user,
&nice,
&sys,
@@ -804,8 +789,8 @@ static int read_times(FILE* statfile_fp,
}
-static unsigned long read_cpufreq(unsigned int cpunum) {
- unsigned long val;
+static uint64_t read_cpufreq(unsigned int cpunum) {
+ uint64_t val;
char buf[1024];
FILE* fp;
@@ -818,7 +803,7 @@ static unsigned long read_cpufreq(unsigned int cpunum) {
if (fp == NULL)
return 0;
- if (fscanf(fp, "%lu", &val) != 1)
+ if (fscanf(fp, "%" PRIu64, &val) != 1)
val = 0;
fclose(fp);
@@ -837,7 +822,7 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
uv__free(cpu_infos);
}
-static int uv__ifaddr_exclude(struct ifaddrs *ent) {
+static int uv__ifaddr_exclude(struct ifaddrs *ent, int exclude_type) {
if (!((ent->ifa_flags & IFF_UP) && (ent->ifa_flags & IFF_RUNNING)))
return 1;
if (ent->ifa_addr == NULL)
@@ -847,47 +832,51 @@ static int uv__ifaddr_exclude(struct ifaddrs *ent) {
* devices. We're not interested in this information yet.
*/
if (ent->ifa_addr->sa_family == PF_PACKET)
- return 1;
- return 0;
+ return exclude_type;
+ return !exclude_type;
}
-int uv_interface_addresses(uv_interface_address_t** addresses,
- int* count) {
+int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
#ifndef HAVE_IFADDRS_H
- return -ENOSYS;
+ *count = 0;
+ *addresses = NULL;
+ return UV_ENOSYS;
#else
struct ifaddrs *addrs, *ent;
uv_interface_address_t* address;
int i;
struct sockaddr_ll *sll;
- if (getifaddrs(&addrs))
- return -errno;
-
*count = 0;
*addresses = NULL;
+ if (getifaddrs(&addrs))
+ return UV__ERR(errno);
+
/* Count the number of interfaces */
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (uv__ifaddr_exclude(ent))
+ if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR))
continue;
(*count)++;
}
- if (*count == 0)
+ if (*count == 0) {
+ freeifaddrs(addrs);
return 0;
+ }
- *addresses = uv__malloc(*count * sizeof(**addresses));
+ /* Make sure the memory is initiallized to zero using calloc() */
+ *addresses = uv__calloc(*count, sizeof(**addresses));
if (!(*addresses)) {
freeifaddrs(addrs);
- return -ENOMEM;
+ return UV_ENOMEM;
}
address = *addresses;
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (uv__ifaddr_exclude(ent))
+ if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFADDR))
continue;
address->name = uv__strdup(ent->ifa_name);
@@ -911,13 +900,16 @@ int uv_interface_addresses(uv_interface_address_t** addresses,
/* Fill in physical addresses for each interface */
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
- if (uv__ifaddr_exclude(ent))
+ if (uv__ifaddr_exclude(ent, UV__EXCLUDE_IFPHYS))
continue;
address = *addresses;
for (i = 0; i < (*count); i++) {
- if (strcmp(address->name, ent->ifa_name) == 0) {
+ size_t namelen = strlen(ent->ifa_name);
+ /* Alias interface share the same physical address */
+ if (strncmp(address->name, ent->ifa_name, namelen) == 0 &&
+ (address->name[namelen] == 0 || address->name[namelen] == ':')) {
sll = (struct sockaddr_ll*)ent->ifa_addr;
memcpy(address->phys_addr, sll->sll_addr, sizeof(address->phys_addr));
}
@@ -949,3 +941,114 @@ void uv__set_process_title(const char* title) {
prctl(PR_SET_NAME, title); /* Only copies first 16 characters. */
#endif
}
+
+
+static uint64_t uv__read_proc_meminfo(const char* what) {
+ uint64_t rc;
+ ssize_t n;
+ char* p;
+ int fd;
+ char buf[4096]; /* Large enough to hold all of /proc/meminfo. */
+
+ rc = 0;
+ fd = uv__open_cloexec("/proc/meminfo", O_RDONLY);
+
+ if (fd == -1)
+ return 0;
+
+ n = read(fd, buf, sizeof(buf) - 1);
+
+ if (n <= 0)
+ goto out;
+
+ buf[n] = '\0';
+ p = strstr(buf, what);
+
+ if (p == NULL)
+ goto out;
+
+ p += strlen(what);
+
+ if (1 != sscanf(p, "%" PRIu64 " kB", &rc))
+ goto out;
+
+ rc *= 1024;
+
+out:
+
+ if (uv__close_nocheckstdio(fd))
+ abort();
+
+ return rc;
+}
+
+
+uint64_t uv_get_free_memory(void) {
+ struct sysinfo info;
+ uint64_t rc;
+
+ rc = uv__read_proc_meminfo("MemFree:");
+
+ if (rc != 0)
+ return rc;
+
+ if (0 == sysinfo(&info))
+ return (uint64_t) info.freeram * info.mem_unit;
+
+ return 0;
+}
+
+
+uint64_t uv_get_total_memory(void) {
+ struct sysinfo info;
+ uint64_t rc;
+
+ rc = uv__read_proc_meminfo("MemTotal:");
+
+ if (rc != 0)
+ return rc;
+
+ if (0 == sysinfo(&info))
+ return (uint64_t) info.totalram * info.mem_unit;
+
+ return 0;
+}
+
+
+static uint64_t uv__read_cgroups_uint64(const char* cgroup, const char* param) {
+ char filename[256];
+ uint64_t rc;
+ int fd;
+ ssize_t n;
+ char buf[32]; /* Large enough to hold an encoded uint64_t. */
+
+ snprintf(filename, 256, "/sys/fs/cgroup/%s/%s", cgroup, param);
+
+ rc = 0;
+ fd = uv__open_cloexec(filename, O_RDONLY);
+
+ if (fd < 0)
+ return 0;
+
+ n = read(fd, buf, sizeof(buf) - 1);
+
+ if (n > 0) {
+ buf[n] = '\0';
+ sscanf(buf, "%" PRIu64, &rc);
+ }
+
+ if (uv__close_nocheckstdio(fd))
+ abort();
+
+ return rc;
+}
+
+
+uint64_t uv_get_constrained_memory(void) {
+ /*
+ * This might return 0 if there was a problem getting the memory limit from
+ * cgroups. This is OK because a return value of 0 signifies that the memory
+ * limit is unknown.
+ */
+ return uv__read_cgroups_uint64("memory", "memory.limit_in_bytes");
+}
diff --git a/Utilities/cmlibuv/src/unix/linux-inotify.c b/Utilities/cmlibuv/src/unix/linux-inotify.c
index 5934c5d8c..9b26202fb 100644
--- a/Utilities/cmlibuv/src/unix/linux-inotify.c
+++ b/Utilities/cmlibuv/src/unix/linux-inotify.c
@@ -19,7 +19,7 @@
*/
#include "uv.h"
-#include "tree.h"
+#include "uv/tree.h"
#include "internal.h"
#include <stdint.h>
@@ -73,11 +73,11 @@ static int new_inotify_fd(void) {
return fd;
if (errno != ENOSYS)
- return -errno;
+ return UV__ERR(errno);
fd = uv__inotify_init();
if (fd == -1)
- return -errno;
+ return UV__ERR(errno);
err = uv__cloexec(fd, 1);
if (err == 0)
@@ -278,12 +278,13 @@ int uv_fs_event_start(uv_fs_event_t* handle,
const char* path,
unsigned int flags) {
struct watcher_list* w;
+ size_t len;
int events;
int err;
int wd;
if (uv__is_active(handle))
- return -EINVAL;
+ return UV_EINVAL;
err = init_inotify(handle->loop);
if (err)
@@ -300,18 +301,19 @@ int uv_fs_event_start(uv_fs_event_t* handle,
wd = uv__inotify_add_watch(handle->loop->inotify_fd, path, events);
if (wd == -1)
- return -errno;
+ return UV__ERR(errno);
w = find_watcher(handle->loop, wd);
if (w)
goto no_insert;
- w = uv__malloc(sizeof(*w) + strlen(path) + 1);
+ len = strlen(path) + 1;
+ w = uv__malloc(sizeof(*w) + len);
if (w == NULL)
- return -ENOMEM;
+ return UV_ENOMEM;
w->wd = wd;
- w->path = strcpy((char*)(w + 1), path);
+ w->path = memcpy(w + 1, path, len);
QUEUE_INIT(&w->watchers);
w->iterating = 0;
RB_INSERT(watcher_root, CAST(&handle->loop->inotify_watchers), w);
diff --git a/Utilities/cmlibuv/src/unix/linux-syscalls.c b/Utilities/cmlibuv/src/unix/linux-syscalls.c
index 89998ded2..5637cf98a 100644
--- a/Utilities/cmlibuv/src/unix/linux-syscalls.c
+++ b/Utilities/cmlibuv/src/unix/linux-syscalls.c
@@ -77,56 +77,6 @@
# endif
#endif /* __NR_eventfd2 */
-#ifndef __NR_epoll_create
-# if defined(__x86_64__)
-# define __NR_epoll_create 213
-# elif defined(__i386__)
-# define __NR_epoll_create 254
-# elif defined(__arm__)
-# define __NR_epoll_create (UV_SYSCALL_BASE + 250)
-# endif
-#endif /* __NR_epoll_create */
-
-#ifndef __NR_epoll_create1
-# if defined(__x86_64__)
-# define __NR_epoll_create1 291
-# elif defined(__i386__)
-# define __NR_epoll_create1 329
-# elif defined(__arm__)
-# define __NR_epoll_create1 (UV_SYSCALL_BASE + 357)
-# endif
-#endif /* __NR_epoll_create1 */
-
-#ifndef __NR_epoll_ctl
-# if defined(__x86_64__)
-# define __NR_epoll_ctl 233 /* used to be 214 */
-# elif defined(__i386__)
-# define __NR_epoll_ctl 255
-# elif defined(__arm__)
-# define __NR_epoll_ctl (UV_SYSCALL_BASE + 251)
-# endif
-#endif /* __NR_epoll_ctl */
-
-#ifndef __NR_epoll_wait
-# if defined(__x86_64__)
-# define __NR_epoll_wait 232 /* used to be 215 */
-# elif defined(__i386__)
-# define __NR_epoll_wait 256
-# elif defined(__arm__)
-# define __NR_epoll_wait (UV_SYSCALL_BASE + 252)
-# endif
-#endif /* __NR_epoll_wait */
-
-#ifndef __NR_epoll_pwait
-# if defined(__x86_64__)
-# define __NR_epoll_pwait 281
-# elif defined(__i386__)
-# define __NR_epoll_pwait 319
-# elif defined(__arm__)
-# define __NR_epoll_pwait (UV_SYSCALL_BASE + 346)
-# endif
-#endif /* __NR_epoll_pwait */
-
#ifndef __NR_inotify_init
# if defined(__x86_64__)
# define __NR_inotify_init 253
@@ -237,6 +187,21 @@
# endif
#endif /* __NR_pwritev */
+#ifndef __NR_statx
+# if defined(__x86_64__)
+# define __NR_statx 332
+# elif defined(__i386__)
+# define __NR_statx 383
+# elif defined(__aarch64__)
+# define __NR_statx 397
+# elif defined(__arm__)
+# define __NR_statx (UV_SYSCALL_BASE + 397)
+# elif defined(__ppc__)
+# define __NR_statx 383
+# elif defined(__s390__)
+# define __NR_statx 379
+# endif
+#endif /* __NR_statx */
int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags) {
#if defined(__i386__)
@@ -285,76 +250,6 @@ int uv__eventfd2(unsigned int count, int flags) {
}
-int uv__epoll_create(int size) {
-#if defined(__NR_epoll_create)
- return syscall(__NR_epoll_create, size);
-#else
- return errno = ENOSYS, -1;
-#endif
-}
-
-
-int uv__epoll_create1(int flags) {
-#if defined(__NR_epoll_create1)
- return syscall(__NR_epoll_create1, flags);
-#else
- return errno = ENOSYS, -1;
-#endif
-}
-
-
-int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event* events) {
-#if defined(__NR_epoll_ctl)
- return syscall(__NR_epoll_ctl, epfd, op, fd, events);
-#else
- return errno = ENOSYS, -1;
-#endif
-}
-
-
-int uv__epoll_wait(int epfd,
- struct uv__epoll_event* events,
- int nevents,
- int timeout) {
-#if defined(__NR_epoll_wait)
- int result;
- result = syscall(__NR_epoll_wait, epfd, events, nevents, timeout);
-#if MSAN_ACTIVE
- if (result > 0)
- __msan_unpoison(events, sizeof(events[0]) * result);
-#endif
- return result;
-#else
- return errno = ENOSYS, -1;
-#endif
-}
-
-
-int uv__epoll_pwait(int epfd,
- struct uv__epoll_event* events,
- int nevents,
- int timeout,
- uint64_t sigmask) {
-#if defined(__NR_epoll_pwait)
- int result;
- result = syscall(__NR_epoll_pwait,
- epfd,
- events,
- nevents,
- timeout,
- &sigmask,
- sizeof(sigmask));
-#if MSAN_ACTIVE
- if (result > 0)
- __msan_unpoison(events, sizeof(events[0]) * result);
-#endif
- return result;
-#else
- return errno = ENOSYS, -1;
-#endif
-}
-
-
int uv__inotify_init(void) {
#if defined(__NR_inotify_init)
return syscall(__NR_inotify_init);
@@ -431,19 +326,6 @@ int uv__recvmmsg(int fd,
}
-int uv__utimesat(int dirfd,
- const char* path,
- const struct timespec times[2],
- int flags)
-{
-#if defined(__NR_utimensat)
- return syscall(__NR_utimensat, dirfd, path, times, flags);
-#else
- return errno = ENOSYS, -1;
-#endif
-}
-
-
ssize_t uv__preadv(int fd, const struct iovec *iov, int iovcnt, int64_t offset) {
#if defined(__NR_preadv)
return syscall(__NR_preadv, fd, iov, iovcnt, (long)offset, (long)(offset >> 32));
@@ -469,3 +351,19 @@ int uv__dup3(int oldfd, int newfd, int flags) {
return errno = ENOSYS, -1;
#endif
}
+
+
+int uv__statx(int dirfd,
+ const char* path,
+ int flags,
+ unsigned int mask,
+ struct uv__statx* statxbuf) {
+ /* __NR_statx make Android box killed by SIGSYS.
+ * That looks like a seccomp2 sandbox filter rejecting the system call.
+ */
+#if defined(__NR_statx) && !defined(__ANDROID__)
+ return syscall(__NR_statx, dirfd, path, flags, mask, statxbuf);
+#else
+ return errno = ENOSYS, -1;
+#endif
+}
diff --git a/Utilities/cmlibuv/src/unix/linux-syscalls.h b/Utilities/cmlibuv/src/unix/linux-syscalls.h
index 4c095e9b5..7e58bfa21 100644
--- a/Utilities/cmlibuv/src/unix/linux-syscalls.h
+++ b/Utilities/cmlibuv/src/unix/linux-syscalls.h
@@ -66,12 +66,6 @@
# define UV__SOCK_NONBLOCK UV__O_NONBLOCK
#endif
-/* epoll flags */
-#define UV__EPOLL_CLOEXEC UV__O_CLOEXEC
-#define UV__EPOLL_CTL_ADD 1
-#define UV__EPOLL_CTL_DEL 2
-#define UV__EPOLL_CTL_MOD 3
-
/* inotify flags */
#define UV__IN_ACCESS 0x001
#define UV__IN_MODIFY 0x002
@@ -86,17 +80,35 @@
#define UV__IN_DELETE_SELF 0x400
#define UV__IN_MOVE_SELF 0x800
-#if defined(__x86_64__)
-struct uv__epoll_event {
- uint32_t events;
- uint64_t data;
-} __attribute__((packed));
-#else
-struct uv__epoll_event {
- uint32_t events;
- uint64_t data;
+struct uv__statx_timestamp {
+ int64_t tv_sec;
+ uint32_t tv_nsec;
+ int32_t unused0;
+};
+
+struct uv__statx {
+ uint32_t stx_mask;
+ uint32_t stx_blksize;
+ uint64_t stx_attributes;
+ uint32_t stx_nlink;
+ uint32_t stx_uid;
+ uint32_t stx_gid;
+ uint16_t stx_mode;
+ uint16_t unused0;
+ uint64_t stx_ino;
+ uint64_t stx_size;
+ uint64_t stx_blocks;
+ uint64_t stx_attributes_mask;
+ struct uv__statx_timestamp stx_atime;
+ struct uv__statx_timestamp stx_btime;
+ struct uv__statx_timestamp stx_ctime;
+ struct uv__statx_timestamp stx_mtime;
+ uint32_t stx_rdev_major;
+ uint32_t stx_rdev_minor;
+ uint32_t stx_dev_major;
+ uint32_t stx_dev_minor;
+ uint64_t unused1[14];
};
-#endif
struct uv__inotify_event {
int32_t wd;
@@ -113,18 +125,6 @@ struct uv__mmsghdr {
int uv__accept4(int fd, struct sockaddr* addr, socklen_t* addrlen, int flags);
int uv__eventfd(unsigned int count);
-int uv__epoll_create(int size);
-int uv__epoll_create1(int flags);
-int uv__epoll_ctl(int epfd, int op, int fd, struct uv__epoll_event *ev);
-int uv__epoll_wait(int epfd,
- struct uv__epoll_event* events,
- int nevents,
- int timeout);
-int uv__epoll_pwait(int epfd,
- struct uv__epoll_event* events,
- int nevents,
- int timeout,
- uint64_t sigmask);
int uv__eventfd2(unsigned int count, int flags);
int uv__inotify_init(void);
int uv__inotify_init1(int flags);
@@ -140,12 +140,13 @@ int uv__sendmmsg(int fd,
struct uv__mmsghdr* mmsg,
unsigned int vlen,
unsigned int flags);
-int uv__utimesat(int dirfd,
- const char* path,
- const struct timespec times[2],
- int flags);
ssize_t uv__preadv(int fd, const struct iovec *iov, int iovcnt, int64_t offset);
ssize_t uv__pwritev(int fd, const struct iovec *iov, int iovcnt, int64_t offset);
int uv__dup3(int oldfd, int newfd, int flags);
+int uv__statx(int dirfd,
+ const char* path,
+ int flags,
+ unsigned int mask,
+ struct uv__statx* statxbuf);
#endif /* UV_LINUX_SYSCALL_H_ */
diff --git a/Utilities/cmlibuv/src/unix/loop-watcher.c b/Utilities/cmlibuv/src/unix/loop-watcher.c
index 340bb0dfa..b8c1c2a71 100644
--- a/Utilities/cmlibuv/src/unix/loop-watcher.c
+++ b/Utilities/cmlibuv/src/unix/loop-watcher.c
@@ -31,7 +31,7 @@
\
int uv_##name##_start(uv_##name##_t* handle, uv_##name##_cb cb) { \
if (uv__is_active(handle)) return 0; \
- if (cb == NULL) return -EINVAL; \
+ if (cb == NULL) return UV_EINVAL; \
QUEUE_INSERT_HEAD(&handle->loop->name##_handles, &handle->queue); \
handle->name##_cb = cb; \
uv__handle_start(handle); \
diff --git a/Utilities/cmlibuv/src/unix/loop.c b/Utilities/cmlibuv/src/unix/loop.c
index bcd49242c..c2a03d770 100644
--- a/Utilities/cmlibuv/src/unix/loop.c
+++ b/Utilities/cmlibuv/src/unix/loop.c
@@ -20,7 +20,7 @@
*/
#include "uv.h"
-#include "tree.h"
+#include "uv/tree.h"
#include "internal.h"
#include "heap-inl.h"
#include <stdlib.h>
@@ -31,7 +31,6 @@ int uv_loop_init(uv_loop_t* loop) {
void* saved_data;
int err;
- uv__signal_global_once_init();
saved_data = loop->data;
memset(loop, 0, sizeof(*loop));
@@ -39,13 +38,14 @@ int uv_loop_init(uv_loop_t* loop) {
heap_init((struct heap*) &loop->timer_heap);
QUEUE_INIT(&loop->wq);
- QUEUE_INIT(&loop->active_reqs);
QUEUE_INIT(&loop->idle_handles);
QUEUE_INIT(&loop->async_handles);
QUEUE_INIT(&loop->check_handles);
QUEUE_INIT(&loop->prepare_handles);
QUEUE_INIT(&loop->handle_queue);
+ loop->active_handles = 0;
+ loop->active_reqs.count = 0;
loop->nfds = 0;
loop->watchers = NULL;
loop->nwatchers = 0;
@@ -68,12 +68,13 @@ int uv_loop_init(uv_loop_t* loop) {
if (err)
return err;
+ uv__signal_global_once_init();
err = uv_signal_init(loop, &loop->child_watcher);
if (err)
goto fail_signal_init;
uv__handle_unref(&loop->child_watcher);
- loop->child_watcher.flags |= UV__HANDLE_INTERNAL;
+ loop->child_watcher.flags |= UV_HANDLE_INTERNAL;
QUEUE_INIT(&loop->process_handles);
err = uv_rwlock_init(&loop->cloexec_lock);
@@ -89,7 +90,7 @@ int uv_loop_init(uv_loop_t* loop) {
goto fail_async_init;
uv__handle_unref(&loop->wq_async);
- loop->wq_async.flags |= UV__HANDLE_INTERNAL;
+ loop->wq_async.flags |= UV_HANDLE_INTERNAL;
return 0;
diff --git a/Utilities/cmlibuv/src/unix/netbsd.c b/Utilities/cmlibuv/src/unix/netbsd.c
index 9b5546b7e..c649bb375 100644
--- a/Utilities/cmlibuv/src/unix/netbsd.c
+++ b/Utilities/cmlibuv/src/unix/netbsd.c
@@ -40,8 +40,6 @@
#include <unistd.h>
#include <time.h>
-static char *process_title;
-
int uv__platform_loop_init(uv_loop_t* loop) {
return uv__kqueue_init(loop);
@@ -66,22 +64,33 @@ void uv_loadavg(double avg[3]) {
int uv_exepath(char* buffer, size_t* size) {
+ /* Intermediate buffer, retrieving partial path name does not work
+ * As of NetBSD-8(beta), vnode->path translator does not handle files
+ * with longer names than 31 characters.
+ */
+ char int_buf[PATH_MAX];
+ size_t int_size;
int mib[4];
- size_t cb;
- pid_t mypid;
if (buffer == NULL || size == NULL || *size == 0)
- return -EINVAL;
+ return UV_EINVAL;
- mypid = getpid();
mib[0] = CTL_KERN;
mib[1] = KERN_PROC_ARGS;
- mib[2] = mypid;
- mib[3] = KERN_PROC_ARGV;
+ mib[2] = -1;
+ mib[3] = KERN_PROC_PATHNAME;
+ int_size = ARRAY_SIZE(int_buf);
+
+ if (sysctl(mib, 4, int_buf, &int_size, NULL, 0))
+ return UV__ERR(errno);
+
+ /* Copy string from the intermediate buffer to outer one with appropriate
+ * length.
+ */
+ /* TODO(bnoordhuis) Check uv__strscpy() return value. */
+ uv__strscpy(buffer, int_buf, *size);
- cb = *size;
- if (sysctl(mib, 4, buffer, &cb, NULL, 0))
- return -errno;
+ /* Set new size. */
*size = strlen(buffer);
return 0;
@@ -94,7 +103,7 @@ uint64_t uv_get_free_memory(void) {
int which[] = {CTL_VM, VM_UVMEXP};
if (sysctl(which, 2, &info, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
return (uint64_t) info.free * sysconf(_SC_PAGESIZE);
}
@@ -111,48 +120,14 @@ uint64_t uv_get_total_memory(void) {
size_t size = sizeof(info);
if (sysctl(which, 2, &info, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
return (uint64_t) info;
}
-char** uv_setup_args(int argc, char** argv) {
- process_title = argc ? uv__strdup(argv[0]) : NULL;
- return argv;
-}
-
-
-int uv_set_process_title(const char* title) {
- if (process_title) uv__free(process_title);
-
- process_title = uv__strdup(title);
- setproctitle("%s", title);
-
- return 0;
-}
-
-
-int uv_get_process_title(char* buffer, size_t size) {
- size_t len;
-
- if (buffer == NULL || size == 0)
- return -EINVAL;
-
- if (process_title) {
- len = strlen(process_title) + 1;
-
- if (size < len)
- return -ENOBUFS;
-
- memcpy(buffer, process_title, len);
- } else {
- len = 0;
- }
-
- buffer[len] = '\0';
-
- return 0;
+uint64_t uv_get_constrained_memory(void) {
+ return 0; /* Memory constraints are unknown. */
}
@@ -182,7 +157,7 @@ int uv_resident_set_memory(size_t* rss) {
error:
if (kd) kvm_close(kd);
- return -EPERM;
+ return UV_EPERM;
}
@@ -193,7 +168,7 @@ int uv_uptime(double* uptime) {
static int which[] = {CTL_KERN, KERN_BOOTTIME};
if (sysctl(which, 2, &info, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
now = time(NULL);
@@ -217,12 +192,12 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
size = sizeof(model);
if (sysctlbyname("machdep.cpu_brand", &model, &size, NULL, 0) &&
sysctlbyname("hw.model", &model, &size, NULL, 0)) {
- return -errno;
+ return UV__ERR(errno);
}
size = sizeof(numcpus);
if (sysctlbyname("hw.ncpu", &numcpus, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
*count = numcpus;
/* Only i386 and amd64 have machdep.tsc_freq */
@@ -233,16 +208,16 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
size = numcpus * CPUSTATES * sizeof(*cp_times);
cp_times = uv__malloc(size);
if (cp_times == NULL)
- return -ENOMEM;
+ return UV_ENOMEM;
if (sysctlbyname("kern.cp_time", cp_times, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
*cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos));
if (!(*cpu_infos)) {
uv__free(cp_times);
uv__free(*cpu_infos);
- return -ENOMEM;
+ return UV_ENOMEM;
}
for (i = 0; i < numcpus; i++) {
diff --git a/Utilities/cmlibuv/src/unix/no-fsevents.c b/Utilities/cmlibuv/src/unix/no-fsevents.c
index 38fb6ab0b..158643af1 100644
--- a/Utilities/cmlibuv/src/unix/no-fsevents.c
+++ b/Utilities/cmlibuv/src/unix/no-fsevents.c
@@ -25,16 +25,16 @@
#include <errno.h>
int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) {
- return -ENOSYS;
+ return UV_ENOSYS;
}
int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb,
const char* filename, unsigned int flags) {
- return -ENOSYS;
+ return UV_ENOSYS;
}
int uv_fs_event_stop(uv_fs_event_t* handle) {
- return -ENOSYS;
+ return UV_ENOSYS;
}
void uv__fs_event_close(uv_fs_event_t* handle) {
diff --git a/Utilities/cmlibuv/src/unix/no-proctitle.c b/Utilities/cmlibuv/src/unix/no-proctitle.c
index a5c19fbff..165740ca3 100644
--- a/Utilities/cmlibuv/src/unix/no-proctitle.c
+++ b/Utilities/cmlibuv/src/unix/no-proctitle.c
@@ -35,7 +35,7 @@ int uv_set_process_title(const char* title) {
int uv_get_process_title(char* buffer, size_t size) {
if (buffer == NULL || size == 0)
- return -EINVAL;
+ return UV_EINVAL;
buffer[0] = '\0';
return 0;
diff --git a/Utilities/cmlibuv/src/unix/openbsd.c b/Utilities/cmlibuv/src/unix/openbsd.c
index 56f0af15c..ffae7683d 100644
--- a/Utilities/cmlibuv/src/unix/openbsd.c
+++ b/Utilities/cmlibuv/src/unix/openbsd.c
@@ -36,9 +36,6 @@
#include <unistd.h>
-static char *process_title;
-
-
int uv__platform_loop_init(uv_loop_t* loop) {
return uv__kqueue_init(loop);
}
@@ -71,11 +68,11 @@ int uv_exepath(char* buffer, size_t* size) {
int err;
if (buffer == NULL || size == NULL || *size == 0)
- return -EINVAL;
+ return UV_EINVAL;
mypid = getpid();
for (;;) {
- err = -ENOMEM;
+ err = UV_ENOMEM;
argsbuf_tmp = uv__realloc(argsbuf, argsbuf_size);
if (argsbuf_tmp == NULL)
goto out;
@@ -88,14 +85,14 @@ int uv_exepath(char* buffer, size_t* size) {
break;
}
if (errno != ENOMEM) {
- err = -errno;
+ err = UV__ERR(errno);
goto out;
}
argsbuf_size *= 2U;
}
if (argsbuf[0] == NULL) {
- err = -EINVAL; /* FIXME(bnoordhuis) More appropriate error. */
+ err = UV_EINVAL; /* FIXME(bnoordhuis) More appropriate error. */
goto out;
}
@@ -121,7 +118,7 @@ uint64_t uv_get_free_memory(void) {
int which[] = {CTL_VM, VM_UVMEXP};
if (sysctl(which, 2, &info, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
return (uint64_t) info.free * sysconf(_SC_PAGESIZE);
}
@@ -133,46 +130,14 @@ uint64_t uv_get_total_memory(void) {
size_t size = sizeof(info);
if (sysctl(which, 2, &info, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
return (uint64_t) info;
}
-char** uv_setup_args(int argc, char** argv) {
- process_title = argc ? uv__strdup(argv[0]) : NULL;
- return argv;
-}
-
-
-int uv_set_process_title(const char* title) {
- uv__free(process_title);
- process_title = uv__strdup(title);
- setproctitle("%s", title);
- return 0;
-}
-
-
-int uv_get_process_title(char* buffer, size_t size) {
- size_t len;
-
- if (buffer == NULL || size == 0)
- return -EINVAL;
-
- if (process_title) {
- len = strlen(process_title) + 1;
-
- if (size < len)
- return -ENOBUFS;
-
- memcpy(buffer, process_title, len);
- } else {
- len = 0;
- }
-
- buffer[len] = '\0';
-
- return 0;
+uint64_t uv_get_constrained_memory(void) {
+ return 0; /* Memory constraints are unknown. */
}
@@ -190,7 +155,7 @@ int uv_resident_set_memory(size_t* rss) {
mib[5] = 1;
if (sysctl(mib, 6, &kinfo, &size, NULL, 0) < 0)
- return -errno;
+ return UV__ERR(errno);
*rss = kinfo.p_vm_rssize * page_size;
return 0;
@@ -204,7 +169,7 @@ int uv_uptime(double* uptime) {
static int which[] = {CTL_KERN, KERN_BOOTTIME};
if (sysctl(which, 2, &info, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
now = time(NULL);
@@ -226,16 +191,16 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
size = sizeof(model);
if (sysctl(which, 2, &model, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
which[1] = HW_NCPU;
size = sizeof(numcpus);
if (sysctl(which, 2, &numcpus, &size, NULL, 0))
- return -errno;
+ return UV__ERR(errno);
*cpu_infos = uv__malloc(numcpus * sizeof(**cpu_infos));
if (!(*cpu_infos))
- return -ENOMEM;
+ return UV_ENOMEM;
*count = numcpus;
@@ -243,7 +208,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
size = sizeof(cpuspeed);
if (sysctl(which, 2, &cpuspeed, &size, NULL, 0)) {
uv__free(*cpu_infos);
- return -errno;
+ return UV__ERR(errno);
}
size = sizeof(info);
@@ -254,7 +219,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
size = sizeof(info);
if (sysctl(which, 3, &info, &size, NULL, 0)) {
uv__free(*cpu_infos);
- return -errno;
+ return UV__ERR(errno);
}
cpu_info = &(*cpu_infos)[i];
diff --git a/Utilities/cmlibuv/src/unix/os390-syscalls.c b/Utilities/cmlibuv/src/unix/os390-syscalls.c
index 7edf2358d..1040d6697 100644
--- a/Utilities/cmlibuv/src/unix/os390-syscalls.c
+++ b/Utilities/cmlibuv/src/unix/os390-syscalls.c
@@ -25,6 +25,8 @@
#include <stdlib.h>
#include <assert.h>
#include <search.h>
+#include <termios.h>
+#include <sys/msg.h>
#define CW_CONDVAR 32
@@ -103,10 +105,19 @@ static void maybe_resize(uv__os390_epoll* lst, unsigned int len) {
unsigned int newsize;
unsigned int i;
struct pollfd* newlst;
+ struct pollfd event;
if (len <= lst->size)
return;
+ if (lst->size == 0)
+ event.fd = -1;
+ else {
+ /* Extract the message queue at the end. */
+ event = lst->items[lst->size - 1];
+ lst->items[lst->size - 1].fd = -1;
+ }
+
newsize = next_power_of_two(len);
newlst = uv__realloc(lst->items, newsize * sizeof(lst->items[0]));
@@ -115,32 +126,102 @@ static void maybe_resize(uv__os390_epoll* lst, unsigned int len) {
for (i = lst->size; i < newsize; ++i)
newlst[i].fd = -1;
+ /* Restore the message queue at the end */
+ newlst[newsize - 1] = event;
+
lst->items = newlst;
lst->size = newsize;
}
+static void init_message_queue(uv__os390_epoll* lst) {
+ struct {
+ long int header;
+ char body;
+ } msg;
+
+ /* initialize message queue */
+ lst->msg_queue = msgget(IPC_PRIVATE, 0600 | IPC_CREAT);
+ if (lst->msg_queue == -1)
+ abort();
+
+ /*
+ On z/OS, the message queue will be affiliated with the process only
+ when a send is performed on it. Once this is done, the system
+ can be queried for all message queues belonging to our process id.
+ */
+ msg.header = 1;
+ if (msgsnd(lst->msg_queue, &msg, sizeof(msg.body), 0) != 0)
+ abort();
+
+ /* Clean up the dummy message sent above */
+ if (msgrcv(lst->msg_queue, &msg, sizeof(msg.body), 0, 0) != sizeof(msg.body))
+ abort();
+}
+
+
+static void before_fork(void) {
+ uv_mutex_lock(&global_epoll_lock);
+}
+
+
+static void after_fork(void) {
+ uv_mutex_unlock(&global_epoll_lock);
+}
+
+
+static void child_fork(void) {
+ QUEUE* q;
+ uv_once_t child_once = UV_ONCE_INIT;
+
+ /* reset once */
+ memcpy(&once, &child_once, sizeof(child_once));
+
+ /* reset epoll list */
+ while (!QUEUE_EMPTY(&global_epoll_queue)) {
+ uv__os390_epoll* lst;
+ q = QUEUE_HEAD(&global_epoll_queue);
+ QUEUE_REMOVE(q);
+ lst = QUEUE_DATA(q, uv__os390_epoll, member);
+ uv__free(lst->items);
+ lst->items = NULL;
+ lst->size = 0;
+ }
+
+ uv_mutex_unlock(&global_epoll_lock);
+ uv_mutex_destroy(&global_epoll_lock);
+}
+
+
static void epoll_init(void) {
QUEUE_INIT(&global_epoll_queue);
if (uv_mutex_init(&global_epoll_lock))
abort();
+
+ if (pthread_atfork(&before_fork, &after_fork, &child_fork))
+ abort();
}
uv__os390_epoll* epoll_create1(int flags) {
uv__os390_epoll* lst;
- uv_once(&once, epoll_init);
- uv_mutex_lock(&global_epoll_lock);
lst = uv__malloc(sizeof(*lst));
- if (lst == -1)
- return NULL;
- QUEUE_INSERT_TAIL(&global_epoll_queue, &lst->member);
- uv_mutex_unlock(&global_epoll_lock);
+ if (lst != NULL) {
+ /* initialize list */
+ lst->size = 0;
+ lst->items = NULL;
+ init_message_queue(lst);
+ maybe_resize(lst, 1);
+ lst->items[lst->size - 1].fd = lst->msg_queue;
+ lst->items[lst->size - 1].events = POLLIN;
+ lst->items[lst->size - 1].revents = 0;
+ uv_once(&once, epoll_init);
+ uv_mutex_lock(&global_epoll_lock);
+ QUEUE_INSERT_TAIL(&global_epoll_queue, &lst->member);
+ uv_mutex_unlock(&global_epoll_lock);
+ }
- /* initialize list */
- lst->size = 0;
- lst->items = NULL;
return lst;
}
@@ -149,71 +230,85 @@ int epoll_ctl(uv__os390_epoll* lst,
int op,
int fd,
struct epoll_event *event) {
- if(op == EPOLL_CTL_DEL) {
+ uv_mutex_lock(&global_epoll_lock);
+
+ if (op == EPOLL_CTL_DEL) {
if (fd >= lst->size || lst->items[fd].fd == -1) {
+ uv_mutex_unlock(&global_epoll_lock);
errno = ENOENT;
return -1;
}
lst->items[fd].fd = -1;
- } else if(op == EPOLL_CTL_ADD) {
- maybe_resize(lst, fd + 1);
+ } else if (op == EPOLL_CTL_ADD) {
+
+ /* Resizing to 'fd + 1' would expand the list to contain at least
+ * 'fd'. But we need to guarantee that the last index on the list
+ * is reserved for the message queue. So specify 'fd + 2' instead.
+ */
+ maybe_resize(lst, fd + 2);
if (lst->items[fd].fd != -1) {
+ uv_mutex_unlock(&global_epoll_lock);
errno = EEXIST;
return -1;
}
lst->items[fd].fd = fd;
lst->items[fd].events = event->events;
- } else if(op == EPOLL_CTL_MOD) {
- if (fd >= lst->size || lst->items[fd].fd == -1) {
+ lst->items[fd].revents = 0;
+ } else if (op == EPOLL_CTL_MOD) {
+ if (fd >= lst->size - 1 || lst->items[fd].fd == -1) {
+ uv_mutex_unlock(&global_epoll_lock);
errno = ENOENT;
return -1;
}
lst->items[fd].events = event->events;
+ lst->items[fd].revents = 0;
} else
abort();
+ uv_mutex_unlock(&global_epoll_lock);
return 0;
}
int epoll_wait(uv__os390_epoll* lst, struct epoll_event* events,
int maxevents, int timeout) {
- size_t size;
+ nmsgsfds_t size;
struct pollfd* pfds;
int pollret;
int reventcount;
+ int nevents;
- uv_mutex_lock(&global_epoll_lock);
- uv_mutex_unlock(&global_epoll_lock);
- size = lst->size;
+ _SET_FDS_MSGS(size, 1, lst->size - 1);
pfds = lst->items;
pollret = poll(pfds, size, timeout);
- if(pollret == -1)
+ if (pollret <= 0)
return pollret;
+ pollret = _NFDS(pollret) + _NMSGS(pollret);
+
reventcount = 0;
- for (int i = 0; i < lst->size && i < maxevents; ++i) {
+ nevents = 0;
+ for (int i = 0;
+ i < lst->size && i < maxevents && reventcount < pollret; ++i) {
struct epoll_event ev;
+ struct pollfd* pfd;
- ev.events = 0;
- ev.fd = pfds[i].fd;
- if(!pfds[i].revents)
+ pfd = &pfds[i];
+ if (pfd->fd == -1 || pfd->revents == 0)
continue;
- if(pfds[i].revents & POLLRDNORM)
- ev.events = ev.events | POLLIN;
-
- if(pfds[i].revents & POLLWRNORM)
- ev.events = ev.events | POLLOUT;
+ ev.fd = pfd->fd;
+ ev.events = pfd->revents;
+ if (pfd->revents & POLLIN && pfd->revents & POLLOUT)
+ reventcount += 2;
+ else if (pfd->revents & (POLLIN | POLLOUT))
+ ++reventcount;
- if(pfds[i].revents & POLLHUP)
- ev.events = ev.events | POLLHUP;
-
- pfds[i].revents = 0;
- events[reventcount++] = ev;
+ pfd->revents = 0;
+ events[nevents++] = ev;
}
- return reventcount;
+ return nevents;
}
@@ -235,9 +330,14 @@ int epoll_file_close(int fd) {
}
void epoll_queue_close(uv__os390_epoll* lst) {
+ /* Remove epoll instance from global queue */
uv_mutex_lock(&global_epoll_lock);
QUEUE_REMOVE(&lst->member);
uv_mutex_unlock(&global_epoll_lock);
+
+ /* Free resources */
+ msgctl(lst->msg_queue, IPC_RMID, NULL);
+ lst->msg_queue = -1;
uv__free(lst->items);
lst->items = NULL;
}
@@ -332,3 +432,81 @@ char* mkdtemp(char* path) {
return path;
}
+
+
+ssize_t os390_readlink(const char* path, char* buf, size_t len) {
+ ssize_t rlen;
+ ssize_t vlen;
+ ssize_t plen;
+ char* delimiter;
+ char old_delim;
+ char* tmpbuf;
+ char realpathstr[PATH_MAX + 1];
+
+ tmpbuf = uv__malloc(len + 1);
+ if (tmpbuf == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ rlen = readlink(path, tmpbuf, len);
+ if (rlen < 0) {
+ uv__free(tmpbuf);
+ return rlen;
+ }
+
+ if (rlen < 3 || strncmp("/$", tmpbuf, 2) != 0) {
+ /* Straightforward readlink. */
+ memcpy(buf, tmpbuf, rlen);
+ uv__free(tmpbuf);
+ return rlen;
+ }
+
+ /*
+ * There is a parmlib variable at the beginning
+ * which needs interpretation.
+ */
+ tmpbuf[rlen] = '\0';
+ delimiter = strchr(tmpbuf + 2, '/');
+ if (delimiter == NULL)
+ /* No slash at the end */
+ delimiter = strchr(tmpbuf + 2, '\0');
+
+ /* Read real path of the variable. */
+ old_delim = *delimiter;
+ *delimiter = '\0';
+ if (realpath(tmpbuf, realpathstr) == NULL) {
+ uv__free(tmpbuf);
+ return -1;
+ }
+
+ /* realpathstr is not guaranteed to end with null byte.*/
+ realpathstr[PATH_MAX] = '\0';
+
+ /* Reset the delimiter and fill up the buffer. */
+ *delimiter = old_delim;
+ plen = strlen(delimiter);
+ vlen = strlen(realpathstr);
+ rlen = plen + vlen;
+ if (rlen > len) {
+ uv__free(tmpbuf);
+ errno = ENAMETOOLONG;
+ return -1;
+ }
+ memcpy(buf, realpathstr, vlen);
+ memcpy(buf + vlen, delimiter, plen);
+
+ /* Done using temporary buffer. */
+ uv__free(tmpbuf);
+
+ return rlen;
+}
+
+
+size_t strnlen(const char* str, size_t maxlen) {
+ char* p = memchr(str, 0, maxlen);
+ if (p == NULL)
+ return maxlen;
+ else
+ return p - str;
+}
diff --git a/Utilities/cmlibuv/src/unix/os390-syscalls.h b/Utilities/cmlibuv/src/unix/os390-syscalls.h
index 61a7cee83..ea599107b 100644
--- a/Utilities/cmlibuv/src/unix/os390-syscalls.h
+++ b/Utilities/cmlibuv/src/unix/os390-syscalls.h
@@ -36,10 +36,6 @@
#define MAX_ITEMS_PER_EPOLL 1024
#define UV__O_CLOEXEC 0x80000
-#define UV__EPOLL_CLOEXEC UV__O_CLOEXEC
-#define UV__EPOLL_CTL_ADD EPOLL_CTL_ADD
-#define UV__EPOLL_CTL_DEL EPOLL_CTL_DEL
-#define UV__EPOLL_CTL_MOD EPOLL_CTL_MOD
struct epoll_event {
int events;
@@ -50,6 +46,7 @@ typedef struct {
QUEUE member;
struct pollfd* items;
unsigned long size;
+ int msg_queue;
} uv__os390_epoll;
/* epoll api */
@@ -65,5 +62,7 @@ int scandir(const char* maindir, struct dirent*** namelist,
int (*compar)(const struct dirent **,
const struct dirent **));
char *mkdtemp(char* path);
+ssize_t os390_readlink(const char* path, char* buf, size_t len);
+size_t strnlen(const char* str, size_t maxlen);
#endif /* UV_OS390_SYSCALL_H_ */
diff --git a/Utilities/cmlibuv/src/unix/os390.c b/Utilities/cmlibuv/src/unix/os390.c
index 2ba5abf35..273ded7ca 100644
--- a/Utilities/cmlibuv/src/unix/os390.c
+++ b/Utilities/cmlibuv/src/unix/os390.c
@@ -25,6 +25,9 @@
#include <utmpx.h>
#include <unistd.h>
#include <sys/ps.h>
+#include <builtins.h>
+#include <termios.h>
+#include <sys/msg.h>
#if defined(__clang__)
#include "csrsic.h"
#else
@@ -32,6 +35,7 @@
#endif
#define CVT_PTR 0x10
+#define PSA_PTR 0x00
#define CSD_OFFSET 0x294
/*
@@ -69,6 +73,18 @@
/* CPC model length from the CSRSI Service. */
#define CPCMODEL_LENGTH 16
+/* Pointer to the home (current) ASCB. */
+#define PSAAOLD 0x224
+
+/* Pointer to rsm address space block extension. */
+#define ASCBRSME 0x16C
+
+/*
+ NUMBER OF FRAMES CURRENTLY IN USE BY THIS ADDRESS SPACE.
+ It does not include 2G frames.
+*/
+#define RAXFMCT 0x2C
+
/* Thread Entry constants */
#define PGTH_CURRENT 1
#define PGTH_LEN 26
@@ -76,6 +92,9 @@
#pragma linkage(BPX4GTH, OS)
#pragma linkage(BPX1GTH, OS)
+/* TOD Clock resolution in nanoseconds */
+#define TOD_RES 4.096
+
typedef unsigned data_area_ptr_assign_type;
typedef union {
@@ -100,10 +119,10 @@ void uv_loadavg(double avg[3]) {
int uv__platform_loop_init(uv_loop_t* loop) {
uv__os390_epoll* ep;
- ep = epoll_create1(UV__EPOLL_CLOEXEC);
+ ep = epoll_create1(0);
loop->ep = ep;
if (ep == NULL)
- return -errno;
+ return UV__ERR(errno);
return 0;
}
@@ -118,9 +137,10 @@ void uv__platform_loop_delete(uv_loop_t* loop) {
uint64_t uv__hrtime(uv_clocktype_t type) {
- struct timeval time;
- gettimeofday(&time, NULL);
- return (uint64_t) time.tv_sec * 1e9 + time.tv_usec * 1e3;
+ unsigned long long timestamp;
+ __stckf(&timestamp);
+ /* Convert to nanoseconds */
+ return timestamp / TOD_RES;
}
@@ -209,15 +229,15 @@ static int getexe(const int pid, char* buf, size_t len) {
assert(((Output_buf.Output_data.offsetPath >>24) & 0xFF) == 'A');
/* Get the offset from the lowest 3 bytes */
- Output_path = (char*)(&Output_buf) +
- (Output_buf.Output_data.offsetPath & 0x00FFFFFF);
+ Output_path = (struct Output_path_type*) ((char*) (&Output_buf) +
+ (Output_buf.Output_data.offsetPath & 0x00FFFFFF));
if (Output_path->len >= len) {
errno = ENOBUFS;
return -1;
}
- strncpy(buf, Output_path->path, len);
+ uv__strscpy(buf, Output_path->path, len);
return 0;
}
@@ -239,12 +259,12 @@ int uv_exepath(char* buffer, size_t* size) {
int pid;
if (buffer == NULL || size == NULL || *size == 0)
- return -EINVAL;
+ return UV_EINVAL;
pid = getpid();
res = getexe(pid, args, sizeof(args));
if (res < 0)
- return -EINVAL;
+ return UV_EINVAL;
/*
* Possibilities for args:
@@ -257,7 +277,7 @@ int uv_exepath(char* buffer, size_t* size) {
/* Case i) and ii) absolute or relative paths */
if (strchr(args, '/') != NULL) {
if (realpath(args, abspath) != abspath)
- return -errno;
+ return UV__ERR(errno);
abspath_size = strlen(abspath);
@@ -277,11 +297,11 @@ int uv_exepath(char* buffer, size_t* size) {
char* path = getenv("PATH");
if (path == NULL)
- return -EINVAL;
+ return UV_EINVAL;
clonedpath = uv__strdup(path);
if (clonedpath == NULL)
- return -ENOMEM;
+ return UV_ENOMEM;
token = strtok(clonedpath, ":");
while (token != NULL) {
@@ -307,7 +327,7 @@ int uv_exepath(char* buffer, size_t* size) {
uv__free(clonedpath);
/* Out of tokens (path entries), and no match found */
- return -EINVAL;
+ return UV_EINVAL;
}
}
@@ -336,14 +356,21 @@ uint64_t uv_get_total_memory(void) {
}
+uint64_t uv_get_constrained_memory(void) {
+ return 0; /* Memory constraints are unknown. */
+}
+
+
int uv_resident_set_memory(size_t* rss) {
- W_PSPROC buf;
+ char* ascb;
+ char* rax;
+ size_t nframes;
- memset(&buf, 0, sizeof(buf));
- if (w_getpsent(0, &buf, sizeof(W_PSPROC)) == -1)
- return -EINVAL;
+ ascb = *(char* __ptr32 *)(PSA_PTR + PSAAOLD);
+ rax = *(char* __ptr32 *)(ascb + ASCBRSME);
+ nframes = *(unsigned int*)(rax + RAXFMCT);
- *rss = buf.ps_size;
+ *rss = nframes * sysconf(_SC_PAGESIZE);
return 0;
}
@@ -364,7 +391,6 @@ int uv_uptime(double* uptime) {
int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
uv_cpu_info_t* cpu_info;
- int result;
int idx;
siv1v2 info;
data_area_ptr cvt = {0};
@@ -384,7 +410,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
*cpu_infos = uv__malloc(*count * sizeof(uv_cpu_info_t));
if (!*cpu_infos)
- return -ENOMEM;
+ return UV_ENOMEM;
cpu_info = *cpu_infos;
idx = 0;
@@ -429,7 +455,7 @@ static int uv__interface_addresses_v6(uv_interface_address_t** addresses,
maxsize = 16384;
if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)))
- return -errno;
+ return UV__ERR(errno);
ifc.__nif6h_version = 1;
ifc.__nif6h_buflen = maxsize;
@@ -437,7 +463,7 @@ static int uv__interface_addresses_v6(uv_interface_address_t** addresses,
if (ioctl(sockfd, SIOCGIFCONF6, &ifc) == -1) {
uv__close(sockfd);
- return -errno;
+ return UV__ERR(errno);
}
@@ -461,7 +487,7 @@ static int uv__interface_addresses_v6(uv_interface_address_t** addresses,
*addresses = uv__malloc(*count * sizeof(uv_interface_address_t));
if (!(*addresses)) {
uv__close(sockfd);
- return -ENOMEM;
+ return UV_ENOMEM;
}
address = *addresses;
@@ -489,7 +515,7 @@ static int uv__interface_addresses_v6(uv_interface_address_t** addresses,
/* TODO: Retrieve netmask using SIOCGIFNETMASK ioctl */
address->is_internal = flg.__nif6e_flags & _NIF6E_FLAGS_LOOPBACK ? 1 : 0;
-
+ memset(address->phys_addr, 0, sizeof(address->phys_addr));
address++;
}
@@ -508,25 +534,27 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
struct ifreq* p;
int count_v6;
+ *count = 0;
+ *addresses = NULL;
+
/* get the ipv6 addresses first */
uv_interface_address_t* addresses_v6;
uv__interface_addresses_v6(&addresses_v6, &count_v6);
/* now get the ipv4 addresses */
- *count = 0;
/* Assume maximum buffer size allowable */
maxsize = 16384;
sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
if (0 > sockfd)
- return -errno;
+ return UV__ERR(errno);
ifc.ifc_req = uv__calloc(1, maxsize);
ifc.ifc_len = maxsize;
if (ioctl(sockfd, SIOCGIFCONF, &ifc) == -1) {
uv__close(sockfd);
- return -errno;
+ return UV__ERR(errno);
}
#define MAX(a,b) (((a)>(b))?(a):(b))
@@ -546,7 +574,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
uv__close(sockfd);
- return -errno;
+ return UV__ERR(errno);
}
if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
@@ -555,13 +583,18 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
(*count)++;
}
+ if (*count == 0) {
+ uv__close(sockfd);
+ return 0;
+ }
+
/* Alloc the return interface structs */
*addresses = uv__malloc((*count + count_v6) *
sizeof(uv_interface_address_t));
if (!(*addresses)) {
uv__close(sockfd);
- return -ENOMEM;
+ return UV_ENOMEM;
}
address = *addresses;
@@ -584,7 +617,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
memcpy(flg.ifr_name, p->ifr_name, sizeof(flg.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &flg) == -1) {
uv__close(sockfd);
- return -ENOSYS;
+ return UV_ENOSYS;
}
if (!(flg.ifr_flags & IFF_UP && flg.ifr_flags & IFF_RUNNING))
@@ -601,6 +634,7 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
}
address->is_internal = flg.ifr_flags & IFF_LOOPBACK ? 1 : 0;
+ memset(address->phys_addr, 0, sizeof(address->phys_addr));
address++;
}
@@ -628,6 +662,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
uintptr_t nfds;
assert(loop->watchers != NULL);
+ assert(fd >= 0);
events = (struct epoll_event*) loop->watchers[loop->nwatchers];
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
@@ -639,7 +674,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
/* Remove the file descriptor from the epoll. */
if (loop->ep != NULL)
- epoll_ctl(loop->ep, UV__EPOLL_CTL_DEL, fd, &dummy);
+ epoll_ctl(loop->ep, EPOLL_CTL_DEL, fd, &dummy);
}
@@ -663,11 +698,124 @@ int uv__io_check_fd(uv_loop_t* loop, int fd) {
return 0;
}
+
+void uv__fs_event_close(uv_fs_event_t* handle) {
+ uv_fs_event_stop(handle);
+}
+
+
+int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) {
+ uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT);
+ return 0;
+}
+
+
+int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb,
+ const char* filename, unsigned int flags) {
+ uv__os390_epoll* ep;
+ _RFIS reg_struct;
+ char* path;
+ int rc;
+
+ if (uv__is_active(handle))
+ return UV_EINVAL;
+
+ ep = handle->loop->ep;
+ assert(ep->msg_queue != -1);
+
+ reg_struct.__rfis_cmd = _RFIS_REG;
+ reg_struct.__rfis_qid = ep->msg_queue;
+ reg_struct.__rfis_type = 1;
+ memcpy(reg_struct.__rfis_utok, &handle, sizeof(handle));
+
+ path = uv__strdup(filename);
+ if (path == NULL)
+ return UV_ENOMEM;
+
+ rc = __w_pioctl(path, _IOCC_REGFILEINT, sizeof(reg_struct), &reg_struct);
+ if (rc != 0)
+ return UV__ERR(errno);
+
+ uv__handle_start(handle);
+ handle->path = path;
+ handle->cb = cb;
+ memcpy(handle->rfis_rftok, reg_struct.__rfis_rftok,
+ sizeof(handle->rfis_rftok));
+
+ return 0;
+}
+
+
+int uv_fs_event_stop(uv_fs_event_t* handle) {
+ uv__os390_epoll* ep;
+ _RFIS reg_struct;
+ int rc;
+
+ if (!uv__is_active(handle))
+ return 0;
+
+ ep = handle->loop->ep;
+ assert(ep->msg_queue != -1);
+
+ reg_struct.__rfis_cmd = _RFIS_UNREG;
+ reg_struct.__rfis_qid = ep->msg_queue;
+ reg_struct.__rfis_type = 1;
+ memcpy(reg_struct.__rfis_rftok, handle->rfis_rftok,
+ sizeof(handle->rfis_rftok));
+
+ /*
+ * This call will take "/" as the path argument in case we
+ * don't care to supply the correct path. The system will simply
+ * ignore it.
+ */
+ rc = __w_pioctl("/", _IOCC_REGFILEINT, sizeof(reg_struct), &reg_struct);
+ if (rc != 0 && errno != EALREADY && errno != ENOENT)
+ abort();
+
+ uv__handle_stop(handle);
+
+ return 0;
+}
+
+
+static int os390_message_queue_handler(uv__os390_epoll* ep) {
+ uv_fs_event_t* handle;
+ int msglen;
+ int events;
+ _RFIM msg;
+
+ if (ep->msg_queue == -1)
+ return 0;
+
+ msglen = msgrcv(ep->msg_queue, &msg, sizeof(msg), 0, IPC_NOWAIT);
+
+ if (msglen == -1 && errno == ENOMSG)
+ return 0;
+
+ if (msglen == -1)
+ abort();
+
+ events = 0;
+ if (msg.__rfim_event == _RFIM_ATTR || msg.__rfim_event == _RFIM_WRITE)
+ events = UV_CHANGE;
+ else if (msg.__rfim_event == _RFIM_RENAME)
+ events = UV_RENAME;
+ else
+ /* Some event that we are not interested in. */
+ return 0;
+
+ handle = *(uv_fs_event_t**)(msg.__rfim_utok);
+ handle->cb(handle, uv__basename_r(handle->path), events, 0);
+ return 1;
+}
+
+
void uv__io_poll(uv_loop_t* loop, int timeout) {
static const int max_safe_timeout = 1789569;
struct epoll_event events[1024];
struct epoll_event* pe;
struct epoll_event e;
+ uv__os390_epoll* ep;
int real_timeout;
QUEUE* q;
uv__io_t* w;
@@ -702,9 +850,9 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
e.fd = w->fd;
if (w->events == 0)
- op = UV__EPOLL_CTL_ADD;
+ op = EPOLL_CTL_ADD;
else
- op = UV__EPOLL_CTL_MOD;
+ op = EPOLL_CTL_MOD;
/* XXX Future optimization: do EPOLL_CTL_MOD lazily if we stop watching
* events, skip the syscall and squelch the events after epoll_wait().
@@ -713,10 +861,10 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
if (errno != EEXIST)
abort();
- assert(op == UV__EPOLL_CTL_ADD);
+ assert(op == EPOLL_CTL_ADD);
/* We've reactivated a file descriptor that's been watched before. */
- if (epoll_ctl(loop->ep, UV__EPOLL_CTL_MOD, w->fd, &e))
+ if (epoll_ctl(loop->ep, EPOLL_CTL_MOD, w->fd, &e))
abort();
}
@@ -745,9 +893,11 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
SAVE_ERRNO(uv__update_time(loop));
if (nfds == 0) {
assert(timeout != -1);
- timeout = real_timeout - timeout;
- if (timeout > 0)
+
+ if (timeout > 0) {
+ timeout = real_timeout - timeout;
continue;
+ }
return;
}
@@ -779,6 +929,12 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
if (fd == -1)
continue;
+ ep = loop->ep;
+ if (fd == ep->msg_queue) {
+ os390_message_queue_handler(ep);
+ continue;
+ }
+
assert(fd >= 0);
assert((unsigned) fd < loop->nwatchers);
@@ -790,7 +946,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
* Ignore all errors because we may be racing with another thread
* when the file descriptor is closed.
*/
- epoll_ctl(loop->ep, UV__EPOLL_CTL_DEL, fd, pe);
+ epoll_ctl(loop->ep, EPOLL_CTL_DEL, fd, pe);
continue;
}
@@ -843,7 +999,12 @@ void uv__set_process_title(const char* title) {
}
int uv__io_fork(uv_loop_t* loop) {
- uv__platform_loop_delete(loop);
+ /*
+ Nullify the msg queue but don't close it because
+ it is still being used by the parent.
+ */
+ loop->ep = NULL;
+ uv__platform_loop_delete(loop);
return uv__platform_loop_init(loop);
}
diff --git a/Utilities/cmlibuv/src/unix/pipe.c b/Utilities/cmlibuv/src/unix/pipe.c
index 7ba1bf879..7d97550ae 100644
--- a/Utilities/cmlibuv/src/unix/pipe.c
+++ b/Utilities/cmlibuv/src/unix/pipe.c
@@ -48,12 +48,12 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
/* Already bound? */
if (uv__stream_fd(handle) >= 0)
- return -EINVAL;
+ return UV_EINVAL;
/* Make a copy of the file name, it outlives this function's scope. */
pipe_fname = uv__strdup(name);
if (pipe_fname == NULL)
- return -ENOMEM;
+ return UV_ENOMEM;
/* We've got a copy, don't touch the original any more. */
name = NULL;
@@ -64,15 +64,14 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
sockfd = err;
memset(&saddr, 0, sizeof saddr);
- strncpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path) - 1);
- saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0';
+ uv__strscpy(saddr.sun_path, pipe_fname, sizeof(saddr.sun_path));
saddr.sun_family = AF_UNIX;
if (bind(sockfd, (struct sockaddr*)&saddr, sizeof saddr)) {
- err = -errno;
+ err = UV__ERR(errno);
/* Convert ENOENT to EACCES for compatibility with Windows. */
- if (err == -ENOENT)
- err = -EACCES;
+ if (err == UV_ENOENT)
+ err = UV_EACCES;
uv__close(sockfd);
goto err_socket;
@@ -92,7 +91,7 @@ err_socket:
int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
if (uv__stream_fd(handle) == -1)
- return -EINVAL;
+ return UV_EINVAL;
#if defined(__MVS__)
/* On zOS, backlog=0 has undefined behaviour */
@@ -103,7 +102,7 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
#endif
if (listen(uv__stream_fd(handle), backlog))
- return -errno;
+ return UV__ERR(errno);
handle->connection_cb = cb;
handle->io_watcher.cb = uv__server_io;
@@ -130,21 +129,38 @@ void uv__pipe_close(uv_pipe_t* handle) {
int uv_pipe_open(uv_pipe_t* handle, uv_file fd) {
+ int flags;
+ int mode;
int err;
+ flags = 0;
+
+ if (uv__fd_exists(handle->loop, fd))
+ return UV_EEXIST;
+
+ do
+ mode = fcntl(fd, F_GETFL);
+ while (mode == -1 && errno == EINTR);
+
+ if (mode == -1)
+ return UV__ERR(errno); /* according to docs, must be EBADF */
err = uv__nonblock(fd, 1);
if (err)
return err;
-#if defined(__APPLE__)
+#if defined(__APPLE__) && !defined(CMAKE_BOOTSTRAP)
err = uv__stream_try_select((uv_stream_t*) handle, &fd);
if (err)
return err;
#endif /* defined(__APPLE__) */
- return uv__stream_open((uv_stream_t*)handle,
- fd,
- UV_STREAM_READABLE | UV_STREAM_WRITABLE);
+ mode &= O_ACCMODE;
+ if (mode != O_WRONLY)
+ flags |= UV_HANDLE_READABLE;
+ if (mode != O_RDONLY)
+ flags |= UV_HANDLE_WRITABLE;
+
+ return uv__stream_open((uv_stream_t*)handle, fd, flags);
}
@@ -167,8 +183,7 @@ void uv_pipe_connect(uv_connect_t* req,
}
memset(&saddr, 0, sizeof saddr);
- strncpy(saddr.sun_path, name, sizeof(saddr.sun_path) - 1);
- saddr.sun_path[sizeof(saddr.sun_path) - 1] = '\0';
+ uv__strscpy(saddr.sun_path, name, sizeof(saddr.sun_path));
saddr.sun_family = AF_UNIX;
do {
@@ -178,14 +193,14 @@ void uv_pipe_connect(uv_connect_t* req,
while (r == -1 && errno == EINTR);
if (r == -1 && errno != EINPROGRESS) {
- err = -errno;
+ err = UV__ERR(errno);
#if defined(__CYGWIN__) || defined(__MSYS__)
/* EBADF is supposed to mean that the socket fd is bad, but
Cygwin reports EBADF instead of ENOTSOCK when the file is
not a socket. We do not expect to see a bad fd here
(e.g. due to new_sock), so translate the error. */
- if (err == -EBADF)
- err = -ENOTSOCK;
+ if (err == UV_EBADF)
+ err = UV_ENOTSOCK;
#endif
goto out;
}
@@ -194,11 +209,11 @@ void uv_pipe_connect(uv_connect_t* req,
if (new_sock) {
err = uv__stream_open((uv_stream_t*)handle,
uv__stream_fd(handle),
- UV_STREAM_READABLE | UV_STREAM_WRITABLE);
+ UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);
}
if (err == 0)
- uv__io_start(handle->loop, &handle->io_watcher, POLLIN | POLLOUT);
+ uv__io_start(handle->loop, &handle->io_watcher, POLLOUT);
out:
handle->delayed_error = err;
@@ -216,9 +231,6 @@ out:
}
-typedef int (*uv__peersockfunc)(int, struct sockaddr*, socklen_t*);
-
-
static int uv__pipe_getsockpeername(const uv_pipe_t* handle,
uv__peersockfunc func,
char* buffer,
@@ -229,10 +241,13 @@ static int uv__pipe_getsockpeername(const uv_pipe_t* handle,
addrlen = sizeof(sa);
memset(&sa, 0, addrlen);
- err = func(uv__stream_fd(handle), (struct sockaddr*) &sa, &addrlen);
+ err = uv__getsockpeername((const uv_handle_t*) handle,
+ func,
+ (struct sockaddr*) &sa,
+ (int*) &addrlen);
if (err < 0) {
*size = 0;
- return -errno;
+ return err;
}
#if defined(__linux__)
@@ -300,3 +315,61 @@ uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle) {
else
return uv__handle_type(handle->accepted_fd);
}
+
+
+int uv_pipe_chmod(uv_pipe_t* handle, int mode) {
+ unsigned desired_mode;
+ struct stat pipe_stat;
+ char* name_buffer;
+ size_t name_len;
+ int r;
+
+ if (handle == NULL || uv__stream_fd(handle) == -1)
+ return UV_EBADF;
+
+ if (mode != UV_READABLE &&
+ mode != UV_WRITABLE &&
+ mode != (UV_WRITABLE | UV_READABLE))
+ return UV_EINVAL;
+
+ /* Unfortunately fchmod does not work on all platforms, we will use chmod. */
+ name_len = 0;
+ r = uv_pipe_getsockname(handle, NULL, &name_len);
+ if (r != UV_ENOBUFS)
+ return r;
+
+ name_buffer = uv__malloc(name_len);
+ if (name_buffer == NULL)
+ return UV_ENOMEM;
+
+ r = uv_pipe_getsockname(handle, name_buffer, &name_len);
+ if (r != 0) {
+ uv__free(name_buffer);
+ return r;
+ }
+
+ /* stat must be used as fstat has a bug on Darwin */
+ if (stat(name_buffer, &pipe_stat) == -1) {
+ uv__free(name_buffer);
+ return -errno;
+ }
+
+ desired_mode = 0;
+ if (mode & UV_READABLE)
+ desired_mode |= S_IRUSR | S_IRGRP | S_IROTH;
+ if (mode & UV_WRITABLE)
+ desired_mode |= S_IWUSR | S_IWGRP | S_IWOTH;
+
+ /* Exit early if pipe already has desired mode. */
+ if ((pipe_stat.st_mode & desired_mode) == desired_mode) {
+ uv__free(name_buffer);
+ return 0;
+ }
+
+ pipe_stat.st_mode |= desired_mode;
+
+ r = chmod(name_buffer, pipe_stat.st_mode);
+ uv__free(name_buffer);
+
+ return r != -1 ? 0 : UV__ERR(errno);
+}
diff --git a/Utilities/cmlibuv/src/unix/poll.c b/Utilities/cmlibuv/src/unix/poll.c
index 370994bd5..3d5022b22 100644
--- a/Utilities/cmlibuv/src/unix/poll.c
+++ b/Utilities/cmlibuv/src/unix/poll.c
@@ -33,16 +33,29 @@ static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
handle = container_of(w, uv_poll_t, io_watcher);
- if (events & POLLERR) {
- uv__io_stop(loop, w, POLLIN | POLLOUT | UV__POLLRDHUP);
+ /*
+ * As documented in the kernel source fs/kernfs/file.c #780
+ * poll will return POLLERR|POLLPRI in case of sysfs
+ * polling. This does not happen in case of out-of-band
+ * TCP messages.
+ *
+ * The above is the case on (at least) FreeBSD and Linux.
+ *
+ * So to properly determine a POLLPRI or a POLLERR we need
+ * to check for both.
+ */
+ if ((events & POLLERR) && !(events & UV__POLLPRI)) {
+ uv__io_stop(loop, w, POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI);
uv__handle_stop(handle);
- handle->poll_cb(handle, -EBADF, 0);
+ handle->poll_cb(handle, UV_EBADF, 0);
return;
}
pevents = 0;
if (events & POLLIN)
pevents |= UV_READABLE;
+ if (events & UV__POLLPRI)
+ pevents |= UV_PRIORITIZED;
if (events & POLLOUT)
pevents |= UV_WRITABLE;
if (events & UV__POLLRDHUP)
@@ -55,6 +68,9 @@ static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) {
int err;
+ if (uv__fd_exists(loop, fd))
+ return UV_EEXIST;
+
err = uv__io_check_fd(loop, fd);
if (err)
return err;
@@ -63,7 +79,7 @@ int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) {
* Workaround for e.g. kqueue fds not supporting ioctls.
*/
err = uv__nonblock(fd, 1);
- if (err == -ENOTTY)
+ if (err == UV_ENOTTY)
if (uv__nonblock == uv__nonblock_ioctl)
err = uv__nonblock_fcntl(fd, 1);
@@ -86,8 +102,9 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle,
static void uv__poll_stop(uv_poll_t* handle) {
uv__io_stop(handle->loop,
&handle->io_watcher,
- POLLIN | POLLOUT | UV__POLLRDHUP);
+ POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI);
uv__handle_stop(handle);
+ uv__platform_invalidate_fd(handle->loop, handle->io_watcher.fd);
}
@@ -101,7 +118,8 @@ int uv_poll_stop(uv_poll_t* handle) {
int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) {
int events;
- assert((pevents & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT)) == 0);
+ assert((pevents & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT |
+ UV_PRIORITIZED)) == 0);
assert(!uv__is_closing(handle));
uv__poll_stop(handle);
@@ -112,6 +130,8 @@ int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) {
events = 0;
if (pevents & UV_READABLE)
events |= POLLIN;
+ if (pevents & UV_PRIORITIZED)
+ events |= UV__POLLPRI;
if (pevents & UV_WRITABLE)
events |= POLLOUT;
if (pevents & UV_DISCONNECT)
diff --git a/Utilities/cmlibuv/src/unix/posix-hrtime.c b/Utilities/cmlibuv/src/unix/posix-hrtime.c
index 323dfc203..870b45c76 100644
--- a/Utilities/cmlibuv/src/unix/posix-hrtime.c
+++ b/Utilities/cmlibuv/src/unix/posix-hrtime.c
@@ -22,6 +22,43 @@
#include "uv.h"
#include "internal.h"
+#if defined(__APPLE__)
+/* Special case for CMake bootstrap: no clock_gettime on macOS < 10.12 */
+
+#ifndef CMAKE_BOOTSTRAP
+#error "This code path meant only for use during CMake bootstrap."
+#endif
+
+#include <mach/mach.h>
+#include <mach/mach_time.h>
+
+uint64_t uv__hrtime(uv_clocktype_t type) {
+ static mach_timebase_info_data_t info;
+
+ if ((ACCESS_ONCE(uint32_t, info.numer) == 0 ||
+ ACCESS_ONCE(uint32_t, info.denom) == 0) &&
+ mach_timebase_info(&info) != KERN_SUCCESS)
+ abort();
+
+ return mach_absolute_time() * info.numer / info.denom;
+}
+
+#elif defined(__hpux)
+/* Special case for CMake bootstrap: no CLOCK_MONOTONIC on HP-UX */
+
+#ifndef CMAKE_BOOTSTRAP
+#error "This code path meant only for use during CMake bootstrap."
+#endif
+
+#include <stdint.h>
+#include <time.h>
+
+uint64_t uv__hrtime(uv_clocktype_t type) {
+ return (uint64_t) gethrtime();
+}
+
+#else
+
#include <stdint.h>
#include <time.h>
@@ -33,3 +70,5 @@ uint64_t uv__hrtime(uv_clocktype_t type) {
clock_gettime(CLOCK_MONOTONIC, &ts);
return (((uint64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec);
}
+
+#endif
diff --git a/Utilities/cmlibuv/src/unix/posix-poll.c b/Utilities/cmlibuv/src/unix/posix-poll.c
index 3fba96e1b..a3b9f2196 100644
--- a/Utilities/cmlibuv/src/unix/posix-poll.c
+++ b/Utilities/cmlibuv/src/unix/posix-poll.c
@@ -107,7 +107,7 @@ static void uv__pollfds_add(uv_loop_t* loop, uv__io_t* w) {
static void uv__pollfds_del(uv_loop_t* loop, int fd) {
size_t i;
assert(!loop->poll_fds_iterating);
- for (i = 0; i < loop->poll_fds_used; ++i) {
+ for (i = 0; i < loop->poll_fds_used;) {
if (loop->poll_fds[i].fd == fd) {
/* swap to last position and remove */
--loop->poll_fds_used;
@@ -115,7 +115,17 @@ static void uv__pollfds_del(uv_loop_t* loop, int fd) {
loop->poll_fds[loop->poll_fds_used].fd = -1;
loop->poll_fds[loop->poll_fds_used].events = 0;
loop->poll_fds[loop->poll_fds_used].revents = 0;
- return;
+ /* This method is called with an fd of -1 to purge the invalidated fds,
+ * so we may possibly have multiples to remove.
+ */
+ if (-1 != fd)
+ return;
+ } else {
+ /* We must only increment the loop counter when the fds do not match.
+ * Otherwise, when we are purging an invalidated fd, the value just
+ * swapped here from the previous end of the array will be skipped.
+ */
+ ++i;
}
}
}
@@ -288,6 +298,8 @@ update_timeout:
void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
size_t i;
+ assert(fd >= 0);
+
if (loop->poll_fds_iterating) {
/* uv__io_poll is currently iterating. Just invalidate fd. */
for (i = 0; i < loop->poll_fds_used; i++)
@@ -315,10 +327,10 @@ int uv__io_check_fd(uv_loop_t* loop, int fd) {
while (rv == -1 && (errno == EINTR || errno == EAGAIN));
if (rv == -1)
- return -errno;
+ return UV__ERR(errno);
if (p[0].revents & POLLNVAL)
- return -EINVAL;
+ return UV_EINVAL;
return 0;
}
diff --git a/Utilities/cmlibuv/src/unix/process.c b/Utilities/cmlibuv/src/unix/process.c
index f2fe30521..f4826bf62 100644
--- a/Utilities/cmlibuv/src/unix/process.c
+++ b/Utilities/cmlibuv/src/unix/process.c
@@ -32,6 +32,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <poll.h>
+#include <sched.h>
#if defined(__APPLE__) && !TARGET_OS_IPHONE
# include <crt_externs.h>
@@ -44,6 +45,16 @@ extern char **environ;
# include <grp.h>
#endif
+#ifndef CMAKE_BOOTSTRAP
+#if defined(__linux__)
+# define uv__cpu_set_t cpu_set_t
+#elif defined(__FreeBSD__)
+# include <sys/param.h>
+# include <sys/cpuset.h>
+# include <pthread_np.h>
+# define uv__cpu_set_t cpuset_t
+#endif
+#endif
static void uv__chld(uv_signal_t* handle, int signum) {
uv_process_t* process;
@@ -126,7 +137,7 @@ int uv__make_socketpair(int fds[2], int flags) {
* Anything else is a genuine error.
*/
if (errno != EINVAL)
- return -errno;
+ return UV__ERR(errno);
no_cloexec = 1;
@@ -134,7 +145,7 @@ skip:
#endif
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds))
- return -errno;
+ return UV__ERR(errno);
uv__cloexec(fds[0], 1);
uv__cloexec(fds[1], 1);
@@ -159,7 +170,7 @@ int uv__make_pipe(int fds[2], int flags) {
return 0;
if (errno != ENOSYS)
- return -errno;
+ return UV__ERR(errno);
no_pipe2 = 1;
@@ -167,7 +178,7 @@ skip:
#endif
if (pipe(fds))
- return -errno;
+ return UV__ERR(errno);
uv__cloexec(fds[0], 1);
uv__cloexec(fds[1], 1);
@@ -198,7 +209,7 @@ static int uv__process_init_stdio(uv_stdio_container_t* container, int fds[2]) {
case UV_CREATE_PIPE:
assert(container->data.stream != NULL);
if (container->data.stream->type != UV_NAMED_PIPE)
- return -EINVAL;
+ return UV_EINVAL;
else
return uv__make_socketpair(fds, 0);
@@ -210,21 +221,20 @@ static int uv__process_init_stdio(uv_stdio_container_t* container, int fds[2]) {
fd = uv__stream_fd(container->data.stream);
if (fd == -1)
- return -EINVAL;
+ return UV_EINVAL;
fds[1] = fd;
return 0;
default:
assert(0 && "Unexpected flags");
- return -EINVAL;
+ return UV_EINVAL;
}
}
static int uv__process_open_stream(uv_stdio_container_t* container,
- int pipefds[2],
- int writable) {
+ int pipefds[2]) {
int flags;
int err;
@@ -238,13 +248,11 @@ static int uv__process_open_stream(uv_stdio_container_t* container,
pipefds[1] = -1;
uv__nonblock(pipefds[0], 1);
- if (container->data.stream->type == UV_NAMED_PIPE &&
- ((uv_pipe_t*)container->data.stream)->ipc)
- flags = UV_STREAM_READABLE | UV_STREAM_WRITABLE;
- else if (writable)
- flags = UV_STREAM_WRITABLE;
- else
- flags = UV_STREAM_READABLE;
+ flags = 0;
+ if (container->flags & UV_WRITABLE_PIPE)
+ flags |= UV_HANDLE_READABLE;
+ if (container->flags & UV_READABLE_PIPE)
+ flags |= UV_HANDLE_WRITABLE;
return uv__stream_open(container->data.stream, pipefds[0], flags);
}
@@ -279,9 +287,20 @@ static void uv__process_child_init(const uv_process_options_t* options,
int stdio_count,
int (*pipes)[2],
int error_fd) {
+ sigset_t set;
int close_fd;
int use_fd;
+ int err;
int fd;
+ int n;
+#ifndef CMAKE_BOOTSTRAP
+#if defined(__linux__) || defined(__FreeBSD__)
+ int r;
+ int i;
+ int cpumask_size;
+ uv__cpu_set_t cpuset;
+#endif
+#endif
if (options->flags & UV_PROCESS_DETACHED)
setsid();
@@ -296,7 +315,7 @@ static void uv__process_child_init(const uv_process_options_t* options,
continue;
pipes[fd][1] = fcntl(use_fd, F_DUPFD, stdio_count);
if (pipes[fd][1] == -1) {
- uv__write_int(error_fd, -errno);
+ uv__write_int(error_fd, UV__ERR(errno));
_exit(127);
}
}
@@ -315,8 +334,8 @@ static void uv__process_child_init(const uv_process_options_t* options,
use_fd = open("/dev/null", fd == 0 ? O_RDONLY : O_RDWR);
close_fd = use_fd;
- if (use_fd == -1) {
- uv__write_int(error_fd, -errno);
+ if (use_fd < 0) {
+ uv__write_int(error_fd, UV__ERR(errno));
_exit(127);
}
}
@@ -328,7 +347,7 @@ static void uv__process_child_init(const uv_process_options_t* options,
fd = dup2(use_fd, fd);
if (fd == -1) {
- uv__write_int(error_fd, -errno);
+ uv__write_int(error_fd, UV__ERR(errno));
_exit(127);
}
@@ -347,7 +366,7 @@ static void uv__process_child_init(const uv_process_options_t* options,
}
if (options->cwd != NULL && chdir(options->cwd)) {
- uv__write_int(error_fd, -errno);
+ uv__write_int(error_fd, UV__ERR(errno));
_exit(127);
}
@@ -363,21 +382,73 @@ static void uv__process_child_init(const uv_process_options_t* options,
}
if ((options->flags & UV_PROCESS_SETGID) && setgid(options->gid)) {
- uv__write_int(error_fd, -errno);
+ uv__write_int(error_fd, UV__ERR(errno));
_exit(127);
}
if ((options->flags & UV_PROCESS_SETUID) && setuid(options->uid)) {
- uv__write_int(error_fd, -errno);
+ uv__write_int(error_fd, UV__ERR(errno));
_exit(127);
}
+#ifndef CMAKE_BOOTSTRAP
+#if defined(__linux__) || defined(__FreeBSD__)
+ if (options->cpumask != NULL) {
+ cpumask_size = uv_cpumask_size();
+ assert(options->cpumask_size >= (size_t)cpumask_size);
+
+ CPU_ZERO(&cpuset);
+ for (i = 0; i < cpumask_size; ++i) {
+ if (options->cpumask[i]) {
+ CPU_SET(i, &cpuset);
+ }
+ }
+
+ r = -pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
+ if (r != 0) {
+ uv__write_int(error_fd, r);
+ _exit(127);
+ }
+ }
+#endif
+#endif
+
if (options->env != NULL) {
environ = options->env;
}
+ /* Reset signal disposition. Use a hard-coded limit because NSIG
+ * is not fixed on Linux: it's either 32, 34 or 64, depending on
+ * whether RT signals are enabled. We are not allowed to touch
+ * RT signal handlers, glibc uses them internally.
+ */
+ for (n = 1; n < 32; n += 1) {
+ if (n == SIGKILL || n == SIGSTOP)
+ continue; /* Can't be changed. */
+
+#if defined(__HAIKU__)
+ if (n == SIGKILLTHR)
+ continue; /* Can't be changed. */
+#endif
+
+ if (SIG_ERR != signal(n, SIG_DFL))
+ continue;
+
+ uv__write_int(error_fd, UV__ERR(errno));
+ _exit(127);
+ }
+
+ /* Reset signal mask. */
+ sigemptyset(&set);
+ err = pthread_sigmask(SIG_SETMASK, &set, NULL);
+
+ if (err != 0) {
+ uv__write_int(error_fd, UV__ERR(err));
+ _exit(127);
+ }
+
execvp(options->file, options->args);
- uv__write_int(error_fd, -errno);
+ uv__write_int(error_fd, UV__ERR(errno));
_exit(127);
}
#endif
@@ -388,9 +459,10 @@ int uv_spawn(uv_loop_t* loop,
const uv_process_options_t* options) {
#if defined(__APPLE__) && (TARGET_OS_TV || TARGET_OS_WATCH)
/* fork is marked __WATCHOS_PROHIBITED __TVOS_PROHIBITED. */
- return -ENOSYS;
+ return UV_ENOSYS;
#else
int signal_pipe[2] = { -1, -1 };
+ int pipes_storage[8][2];
int (*pipes)[2];
int stdio_count;
ssize_t r;
@@ -400,11 +472,27 @@ int uv_spawn(uv_loop_t* loop,
int i;
int status;
+ if (options->cpumask != NULL) {
+#ifndef CMAKE_BOOTSTRAP
+#if defined(__linux__) || defined(__FreeBSD__)
+ if (options->cpumask_size < (size_t)uv_cpumask_size()) {
+ return UV_EINVAL;
+ }
+#else
+ return UV_ENOTSUP;
+#endif
+#else
+ return UV_ENOTSUP;
+#endif
+ }
+
assert(options->file != NULL);
assert(!(options->flags & ~(UV_PROCESS_DETACHED |
UV_PROCESS_SETGID |
UV_PROCESS_SETUID |
UV_PROCESS_WINDOWS_HIDE |
+ UV_PROCESS_WINDOWS_HIDE_CONSOLE |
+ UV_PROCESS_WINDOWS_HIDE_GUI |
UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS)));
uv__handle_init(loop, (uv_handle_t*)process, UV_PROCESS);
@@ -414,8 +502,11 @@ int uv_spawn(uv_loop_t* loop,
if (stdio_count < 3)
stdio_count = 3;
- err = -ENOMEM;
- pipes = uv__malloc(stdio_count * sizeof(*pipes));
+ err = UV_ENOMEM;
+ pipes = pipes_storage;
+ if (stdio_count > (int) ARRAY_SIZE(pipes_storage))
+ pipes = uv__malloc(stdio_count * sizeof(*pipes));
+
if (pipes == NULL)
goto error;
@@ -461,7 +552,7 @@ int uv_spawn(uv_loop_t* loop,
pid = fork();
if (pid == -1) {
- err = -errno;
+ err = UV__ERR(errno);
uv_rwlock_wrunlock(&loop->cloexec_lock);
uv__close(signal_pipe[0]);
uv__close(signal_pipe[1]);
@@ -501,7 +592,7 @@ int uv_spawn(uv_loop_t* loop,
uv__close_nocheckstdio(signal_pipe[0]);
for (i = 0; i < options->stdio_count; i++) {
- err = uv__process_open_stream(options->stdio + i, pipes[i], i == 0);
+ err = uv__process_open_stream(options->stdio + i, pipes[i]);
if (err == 0)
continue;
@@ -520,7 +611,9 @@ int uv_spawn(uv_loop_t* loop,
process->pid = pid;
process->exit_cb = options->exit_cb;
- uv__free(pipes);
+ if (pipes != pipes_storage)
+ uv__free(pipes);
+
return exec_errorno;
error:
@@ -534,7 +627,9 @@ error:
if (pipes[i][1] != -1)
uv__close_nocheckstdio(pipes[i][1]);
}
- uv__free(pipes);
+
+ if (pipes != pipes_storage)
+ uv__free(pipes);
}
return err;
@@ -549,7 +644,7 @@ int uv_process_kill(uv_process_t* process, int signum) {
int uv_kill(int pid, int signum) {
if (kill(pid, signum))
- return -errno;
+ return UV__ERR(errno);
else
return 0;
}
diff --git a/Utilities/cmlibuv/src/unix/procfs-exepath.c b/Utilities/cmlibuv/src/unix/procfs-exepath.c
index 5fdb61155..00dc021f2 100644
--- a/Utilities/cmlibuv/src/unix/procfs-exepath.c
+++ b/Utilities/cmlibuv/src/unix/procfs-exepath.c
@@ -29,14 +29,14 @@ int uv_exepath(char* buffer, size_t* size) {
ssize_t n;
if (buffer == NULL || size == NULL || *size == 0)
- return -EINVAL;
+ return UV_EINVAL;
n = *size - 1;
if (n > 0)
n = readlink("/proc/self/exe", buffer, n);
if (n == -1)
- return -errno;
+ return UV__ERR(errno);
buffer[n] = '\0';
*size = n;
diff --git a/Utilities/cmlibuv/src/unix/proctitle.c b/Utilities/cmlibuv/src/unix/proctitle.c
index 9160f7eaf..a5ce2030c 100644
--- a/Utilities/cmlibuv/src/unix/proctitle.c
+++ b/Utilities/cmlibuv/src/unix/proctitle.c
@@ -24,8 +24,11 @@
#include <stdlib.h>
#include <string.h>
+extern void uv__set_process_title_platform_init(void);
extern void uv__set_process_title(const char* title);
+static uv_mutex_t process_title_mutex;
+static uv_once_t process_title_mutex_once = UV_ONCE_INIT;
static void* args_mem;
static struct {
@@ -34,6 +37,14 @@ static struct {
} process_title;
+static void init_process_title_mutex_once(void) {
+ uv_mutex_init(&process_title_mutex);
+#ifdef __APPLE__
+ uv__set_process_title_platform_init();
+#endif
+}
+
+
char** uv_setup_args(int argc, char** argv) {
char** new_argv;
size_t size;
@@ -81,12 +92,16 @@ char** uv_setup_args(int argc, char** argv) {
int uv_set_process_title(const char* title) {
- if (process_title.len == 0)
- return 0;
+ uv_once(&process_title_mutex_once, init_process_title_mutex_once);
+ uv_mutex_lock(&process_title_mutex);
+
+ if (process_title.len != 0) {
+ /* No need to terminate, byte after is always '\0'. */
+ strncpy(process_title.str, title, process_title.len);
+ uv__set_process_title(title);
+ }
- /* No need to terminate, byte after is always '\0'. */
- strncpy(process_title.str, title, process_title.len);
- uv__set_process_title(title);
+ uv_mutex_unlock(&process_title_mutex);
return 0;
}
@@ -94,13 +109,23 @@ int uv_set_process_title(const char* title) {
int uv_get_process_title(char* buffer, size_t size) {
if (buffer == NULL || size == 0)
- return -EINVAL;
- else if (size <= process_title.len)
- return -ENOBUFS;
+ return UV_EINVAL;
+
+ uv_once(&process_title_mutex_once, init_process_title_mutex_once);
+ uv_mutex_lock(&process_title_mutex);
+
+ if (size <= process_title.len) {
+ uv_mutex_unlock(&process_title_mutex);
+ return UV_ENOBUFS;
+ }
+
+ if (process_title.len != 0)
+ memcpy(buffer, process_title.str, process_title.len + 1);
- memcpy(buffer, process_title.str, process_title.len + 1);
buffer[process_title.len] = '\0';
+ uv_mutex_unlock(&process_title_mutex);
+
return 0;
}
diff --git a/Utilities/cmlibuv/src/unix/pthread-barrier.c b/Utilities/cmlibuv/src/unix/pthread-barrier.c
deleted file mode 100644
index b6e604d46..000000000
--- a/Utilities/cmlibuv/src/unix/pthread-barrier.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-Copyright (c) 2016, Kari Tristan Helgason <kthelgason@gmail.com>
-
-Permission to use, copy, modify, and/or distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-#include "uv-common.h"
-#include "pthread-barrier.h"
-
-#include <stdlib.h>
-#include <assert.h>
-
-/* TODO: support barrier_attr */
-int pthread_barrier_init(pthread_barrier_t* barrier,
- const void* barrier_attr,
- unsigned count) {
- int rc;
- _uv_barrier* b;
-
- if (barrier == NULL || count == 0)
- return EINVAL;
-
- if (barrier_attr != NULL)
- return ENOTSUP;
-
- b = uv__malloc(sizeof(*b));
- if (b == NULL)
- return ENOMEM;
-
- b->in = 0;
- b->out = 0;
- b->threshold = count;
-
- if ((rc = pthread_mutex_init(&b->mutex, NULL)) != 0)
- goto error2;
- if ((rc = pthread_cond_init(&b->cond, NULL)) != 0)
- goto error;
-
- barrier->b = b;
- return 0;
-
-error:
- pthread_mutex_destroy(&b->mutex);
-error2:
- uv__free(b);
- return rc;
-}
-
-int pthread_barrier_wait(pthread_barrier_t* barrier) {
- int rc;
- _uv_barrier* b;
-
- if (barrier == NULL || barrier->b == NULL)
- return EINVAL;
-
- b = barrier->b;
- /* Lock the mutex*/
- if ((rc = pthread_mutex_lock(&b->mutex)) != 0)
- return rc;
-
- /* Increment the count. If this is the first thread to reach the threshold,
- wake up waiters, unlock the mutex, then return
- PTHREAD_BARRIER_SERIAL_THREAD. */
- if (++b->in == b->threshold) {
- b->in = 0;
- b->out = b->threshold - 1;
- rc = pthread_cond_signal(&b->cond);
- assert(rc == 0);
-
- pthread_mutex_unlock(&b->mutex);
- return PTHREAD_BARRIER_SERIAL_THREAD;
- }
- /* Otherwise, wait for other threads until in is set to 0,
- then return 0 to indicate this is not the first thread. */
- do {
- if ((rc = pthread_cond_wait(&b->cond, &b->mutex)) != 0)
- break;
- } while (b->in != 0);
-
- /* mark thread exit */
- b->out--;
- pthread_cond_signal(&b->cond);
- pthread_mutex_unlock(&b->mutex);
- return rc;
-}
-
-int pthread_barrier_destroy(pthread_barrier_t* barrier) {
- int rc;
- _uv_barrier* b;
-
- if (barrier == NULL || barrier->b == NULL)
- return EINVAL;
-
- b = barrier->b;
-
- if ((rc = pthread_mutex_lock(&b->mutex)) != 0)
- return rc;
-
- if (b->in > 0 || b->out > 0)
- rc = EBUSY;
-
- pthread_mutex_unlock(&b->mutex);
-
- if (rc)
- return rc;
-
- pthread_cond_destroy(&b->cond);
- pthread_mutex_destroy(&b->mutex);
- uv__free(barrier->b);
- barrier->b = NULL;
- return 0;
-}
diff --git a/Utilities/cmlibuv/src/unix/signal.c b/Utilities/cmlibuv/src/unix/signal.c
index cb09ead50..01aa55f3f 100644
--- a/Utilities/cmlibuv/src/unix/signal.c
+++ b/Utilities/cmlibuv/src/unix/signal.c
@@ -28,6 +28,9 @@
#include <string.h>
#include <unistd.h>
+#ifndef SA_RESTART
+# define SA_RESTART 0
+#endif
typedef struct {
uv_signal_t* handle;
@@ -51,8 +54,7 @@ static void uv__signal_unregister_handler(int signum);
static uv_once_t uv__signal_global_init_guard = UV_ONCE_INIT;
static struct uv__signal_tree_s uv__signal_tree =
RB_INITIALIZER(uv__signal_tree);
-static int uv__signal_lock_pipefd[2];
-
+static int uv__signal_lock_pipefd[2] = { -1, -1 };
RB_GENERATE_STATIC(uv__signal_tree_s,
uv_signal_s, tree_entry,
@@ -61,7 +63,7 @@ RB_GENERATE_STATIC(uv__signal_tree_s,
static void uv__signal_global_reinit(void);
static void uv__signal_global_init(void) {
- if (!uv__signal_lock_pipefd[0])
+ if (uv__signal_lock_pipefd[0] == -1)
/* pthread_atfork can register before and after handlers, one
* for each child. This only registers one for the child. That
* state is both persistent and cumulative, so if we keep doing
@@ -71,15 +73,11 @@ static void uv__signal_global_init(void) {
if (pthread_atfork(NULL, NULL, &uv__signal_global_reinit))
abort();
- if (uv__make_pipe(uv__signal_lock_pipefd, 0))
- abort();
-
- if (uv__signal_unlock())
- abort();
+ uv__signal_global_reinit();
}
-static void uv__signal_global_reinit(void) {
+UV_DESTRUCTOR(static void uv__signal_global_fini(void)) {
/* We can only use signal-safe functions here.
* That includes read/write and close, fortunately.
* We do all of this directly here instead of resetting
@@ -87,11 +85,26 @@ static void uv__signal_global_reinit(void) {
* uv__signal_global_once_init is only called from uv_loop_init
* and this needs to function in existing loops.
*/
- uv__close(uv__signal_lock_pipefd[0]);
- uv__signal_lock_pipefd[0] = -1;
- uv__close(uv__signal_lock_pipefd[1]);
- uv__signal_lock_pipefd[1] = -1;
- uv__signal_global_init();
+ if (uv__signal_lock_pipefd[0] != -1) {
+ uv__close(uv__signal_lock_pipefd[0]);
+ uv__signal_lock_pipefd[0] = -1;
+ }
+
+ if (uv__signal_lock_pipefd[1] != -1) {
+ uv__close(uv__signal_lock_pipefd[1]);
+ uv__signal_lock_pipefd[1] = -1;
+ }
+}
+
+
+static void uv__signal_global_reinit(void) {
+ uv__signal_global_fini();
+
+ if (uv__make_pipe(uv__signal_lock_pipefd, 0))
+ abort();
+
+ if (uv__signal_unlock())
+ abort();
}
@@ -100,7 +113,6 @@ void uv__signal_global_once_init(void) {
}
-
static int uv__signal_lock(void) {
int r;
char data;
@@ -216,11 +228,13 @@ static int uv__signal_register_handler(int signum, int oneshot) {
if (sigfillset(&sa.sa_mask))
abort();
sa.sa_handler = uv__signal_handler;
- sa.sa_flags = oneshot ? SA_RESETHAND : 0;
+ sa.sa_flags = SA_RESTART;
+ if (oneshot)
+ sa.sa_flags |= SA_RESETHAND;
/* XXX save old action so we can restore it later on? */
if (sigaction(signum, &sa, NULL))
- return -errno;
+ return UV__ERR(errno);
return 0;
}
@@ -357,7 +371,7 @@ static int uv__signal_start(uv_signal_t* handle,
* eventually.
*/
if (signum == 0)
- return -EINVAL;
+ return UV_EINVAL;
/* Short circuit: if the signal watcher is already watching {signum} don't
* go through the process of deregistering and registering the handler.
@@ -382,7 +396,7 @@ static int uv__signal_start(uv_signal_t* handle,
*/
first_handle = uv__signal_first_handle(signum);
if (first_handle == NULL ||
- (!oneshot && (first_handle->flags & UV__SIGNAL_ONE_SHOT))) {
+ (!oneshot && (first_handle->flags & UV_SIGNAL_ONE_SHOT))) {
err = uv__signal_register_handler(signum, oneshot);
if (err) {
/* Registering the signal handler failed. Must be an invalid signal. */
@@ -393,7 +407,7 @@ static int uv__signal_start(uv_signal_t* handle,
handle->signum = signum;
if (oneshot)
- handle->flags |= UV__SIGNAL_ONE_SHOT;
+ handle->flags |= UV_SIGNAL_ONE_SHOT;
RB_INSERT(uv__signal_tree_s, &uv__signal_tree, handle);
@@ -450,20 +464,20 @@ static void uv__signal_event(uv_loop_t* loop,
handle = msg->handle;
if (msg->signum == handle->signum) {
- assert(!(handle->flags & UV_CLOSING));
+ assert(!(handle->flags & UV_HANDLE_CLOSING));
handle->signal_cb(handle, handle->signum);
}
handle->dispatched_signals++;
- if (handle->flags & UV__SIGNAL_ONE_SHOT)
+ if (handle->flags & UV_SIGNAL_ONE_SHOT)
uv__signal_stop(handle);
/* If uv_close was called while there were caught signals that were not
* yet dispatched, the uv__finish_close was deferred. Make close pending
* now if this has happened.
*/
- if ((handle->flags & UV_CLOSING) &&
+ if ((handle->flags & UV_HANDLE_CLOSING) &&
(handle->caught_signals == handle->dispatched_signals)) {
uv__make_close_pending((uv_handle_t*) handle);
}
@@ -491,11 +505,11 @@ static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2) {
if (w1->signum < w2->signum) return -1;
if (w1->signum > w2->signum) return 1;
- /* Handlers without UV__SIGNAL_ONE_SHOT set will come first, so if the first
+ /* Handlers without UV_SIGNAL_ONE_SHOT set will come first, so if the first
* handler returned is a one-shot handler, the rest will be too.
*/
- f1 = w1->flags & UV__SIGNAL_ONE_SHOT;
- f2 = w2->flags & UV__SIGNAL_ONE_SHOT;
+ f1 = w1->flags & UV_SIGNAL_ONE_SHOT;
+ f2 = w2->flags & UV_SIGNAL_ONE_SHOT;
if (f1 < f2) return -1;
if (f1 > f2) return 1;
@@ -544,8 +558,8 @@ static void uv__signal_stop(uv_signal_t* handle) {
if (first_handle == NULL) {
uv__signal_unregister_handler(handle->signum);
} else {
- rem_oneshot = handle->flags & UV__SIGNAL_ONE_SHOT;
- first_oneshot = first_handle->flags & UV__SIGNAL_ONE_SHOT;
+ rem_oneshot = handle->flags & UV_SIGNAL_ONE_SHOT;
+ first_oneshot = first_handle->flags & UV_SIGNAL_ONE_SHOT;
if (first_oneshot && !rem_oneshot) {
ret = uv__signal_register_handler(handle->signum, 1);
assert(ret == 0);
diff --git a/Utilities/cmlibuv/src/unix/stream.c b/Utilities/cmlibuv/src/unix/stream.c
index 7b23d16ec..8121f6464 100644
--- a/Utilities/cmlibuv/src/unix/stream.c
+++ b/Utilities/cmlibuv/src/unix/stream.c
@@ -58,6 +58,20 @@ struct uv__stream_select_s {
fd_set* swrite;
size_t swrite_sz;
};
+
+/* Due to a possible kernel bug at least in OS X 10.10 "Yosemite",
+ * EPROTOTYPE can be returned while trying to write to a socket that is
+ * shutting down. If we retry the write, we should get the expected EPIPE
+ * instead.
+ */
+# define RETRY_ON_WRITE_ERROR(errno) (errno == EINTR || errno == EPROTOTYPE)
+# define IS_TRANSIENT_WRITE_ERROR(errno, send_handle) \
+ (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS || \
+ (errno == EMSGSIZE && send_handle != NULL))
+#else
+# define RETRY_ON_WRITE_ERROR(errno) (errno == EINTR)
+# define IS_TRANSIENT_WRITE_ERROR(errno, send_handle) \
+ (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS)
#endif /* defined(__APPLE__) */
static void uv__stream_connect(uv_stream_t*);
@@ -98,7 +112,7 @@ void uv__stream_init(uv_loop_t* loop,
loop->emfile_fd = err;
}
-#if defined(__APPLE__)
+#if defined(__APPLE__) && !defined(CMAKE_BOOTSTRAP)
stream->select = NULL;
#endif /* defined(__APPLE_) */
@@ -107,7 +121,7 @@ void uv__stream_init(uv_loop_t* loop,
static void uv__stream_osx_interrupt_select(uv_stream_t* stream) {
-#if defined(__APPLE__)
+#if defined(__APPLE__) && !defined(CMAKE_BOOTSTRAP)
/* Notify select() thread about state change */
uv__stream_select_t* s;
int r;
@@ -131,7 +145,7 @@ static void uv__stream_osx_interrupt_select(uv_stream_t* stream) {
}
-#if defined(__APPLE__)
+#if defined(__APPLE__) && !defined(CMAKE_BOOTSTRAP)
static void uv__stream_osx_select(void* arg) {
uv_stream_t* stream;
uv__stream_select_t* s;
@@ -214,7 +228,7 @@ static void uv__stream_osx_select(void* arg) {
uv_sem_wait(&s->async_sem);
/* Should be processed at this stage */
- assert((s->events == 0) || (stream->flags & UV_CLOSING));
+ assert((s->events == 0) || (stream->flags & UV_HANDLE_CLOSING));
}
}
}
@@ -242,7 +256,7 @@ static void uv__stream_osx_select_cb(uv_async_t* handle) {
if ((events & POLLOUT) && uv__io_active(&stream->io_watcher, POLLOUT))
uv__stream_io(stream->loop, &stream->io_watcher, POLLOUT);
- if (stream->flags & UV_CLOSING)
+ if (stream->flags & UV_HANDLE_CLOSING)
return;
/* NOTE: It is important to do it here, otherwise `select()` might be called
@@ -282,7 +296,7 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) {
kq = kqueue();
if (kq == -1) {
perror("(libuv) kqueue()");
- return -errno;
+ return UV__ERR(errno);
}
EV_SET(&filter[0], *fd, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, 0);
@@ -298,7 +312,7 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) {
uv__close(kq);
if (ret == -1)
- return -errno;
+ return UV__ERR(errno);
if (ret == 0 || (events[0].flags & EV_ERROR) == 0 || events[0].data != EINVAL)
return 0;
@@ -310,7 +324,7 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) {
* NOTE: do it ahead of malloc below to allocate enough space for fd_sets
*/
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds))
- return -errno;
+ return UV__ERR(errno);
max_fd = *fd;
if (fds[1] > max_fd)
@@ -321,7 +335,7 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) {
s = uv__malloc(sizeof(*s) + sread_sz + swrite_sz);
if (s == NULL) {
- err = -ENOMEM;
+ err = UV_ENOMEM;
goto failed_malloc;
}
@@ -336,7 +350,7 @@ int uv__stream_try_select(uv_stream_t* stream, int* fd) {
if (err)
goto failed_async_init;
- s->async.flags |= UV__HANDLE_INTERNAL;
+ s->async.flags |= UV_HANDLE_INTERNAL;
uv__handle_unref(&s->async);
err = uv_sem_init(&s->close_sem, 0);
@@ -395,18 +409,20 @@ int uv__stream_open(uv_stream_t* stream, int fd, int flags) {
#endif
if (!(stream->io_watcher.fd == -1 || stream->io_watcher.fd == fd))
- return -EBUSY;
+ return UV_EBUSY;
assert(fd >= 0);
stream->flags |= flags;
if (stream->type == UV_TCP) {
- if ((stream->flags & UV_TCP_NODELAY) && uv__tcp_nodelay(fd, 1))
- return -errno;
+ if ((stream->flags & UV_HANDLE_TCP_NODELAY) && uv__tcp_nodelay(fd, 1))
+ return UV__ERR(errno);
/* TODO Use delay the user passed in. */
- if ((stream->flags & UV_TCP_KEEPALIVE) && uv__tcp_keepalive(fd, 1, 60))
- return -errno;
+ if ((stream->flags & UV_HANDLE_TCP_KEEPALIVE) &&
+ uv__tcp_keepalive(fd, 1, 60)) {
+ return UV__ERR(errno);
+ }
}
#if defined(__APPLE__)
@@ -414,7 +430,7 @@ int uv__stream_open(uv_stream_t* stream, int fd, int flags) {
if (setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, &enable, sizeof(enable)) &&
errno != ENOTSOCK &&
errno != EINVAL) {
- return -errno;
+ return UV__ERR(errno);
}
#endif
@@ -441,15 +457,15 @@ void uv__stream_flush_write_queue(uv_stream_t* stream, int error) {
void uv__stream_destroy(uv_stream_t* stream) {
assert(!uv__io_active(&stream->io_watcher, POLLIN | POLLOUT));
- assert(stream->flags & UV_CLOSED);
+ assert(stream->flags & UV_HANDLE_CLOSED);
if (stream->connect_req) {
uv__req_unregister(stream->loop, stream->connect_req);
- stream->connect_req->cb(stream->connect_req, -ECANCELED);
+ stream->connect_req->cb(stream->connect_req, UV_ECANCELED);
stream->connect_req = NULL;
}
- uv__stream_flush_write_queue(stream, -ECANCELED);
+ uv__stream_flush_write_queue(stream, UV_ECANCELED);
uv__write_callbacks(stream);
if (stream->shutdown_req) {
@@ -459,7 +475,7 @@ void uv__stream_destroy(uv_stream_t* stream) {
* callee that the handle has been destroyed.
*/
uv__req_unregister(stream->loop, stream->shutdown_req);
- stream->shutdown_req->cb(stream->shutdown_req, -ECANCELED);
+ stream->shutdown_req->cb(stream->shutdown_req, UV_ECANCELED);
stream->shutdown_req = NULL;
}
@@ -483,7 +499,7 @@ static int uv__emfile_trick(uv_loop_t* loop, int accept_fd) {
int emfile_fd;
if (loop->emfile_fd == -1)
- return -EMFILE;
+ return UV_EMFILE;
uv__close(loop->emfile_fd);
loop->emfile_fd = -1;
@@ -492,7 +508,7 @@ static int uv__emfile_trick(uv_loop_t* loop, int accept_fd) {
err = uv__accept(accept_fd);
if (err >= 0)
uv__close(err);
- } while (err >= 0 || err == -EINTR);
+ } while (err >= 0 || err == UV_EINTR);
emfile_fd = uv__open_cloexec("/", O_RDONLY);
if (emfile_fd >= 0)
@@ -514,9 +530,9 @@ void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
int err;
stream = container_of(w, uv_stream_t, io_watcher);
- assert(events == POLLIN);
+ assert(events & POLLIN);
assert(stream->accepted_fd == -1);
- assert(!(stream->flags & UV_CLOSING));
+ assert(!(stream->flags & UV_HANDLE_CLOSING));
uv__io_start(stream->loop, &stream->io_watcher, POLLIN);
@@ -533,15 +549,15 @@ void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
err = uv__accept(uv__stream_fd(stream));
if (err < 0) {
- if (err == -EAGAIN || err == -EWOULDBLOCK)
+ if (err == UV_EAGAIN || err == UV__ERR(EWOULDBLOCK))
return; /* Not an error. */
- if (err == -ECONNABORTED)
+ if (err == UV_ECONNABORTED)
continue; /* Ignore. Nothing we can do about that. */
- if (err == -EMFILE || err == -ENFILE) {
+ if (err == UV_EMFILE || err == UV_ENFILE) {
err = uv__emfile_trick(loop, uv__stream_fd(stream));
- if (err == -EAGAIN || err == -EWOULDBLOCK)
+ if (err == UV_EAGAIN || err == UV__ERR(EWOULDBLOCK))
break;
}
@@ -559,7 +575,8 @@ void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
return;
}
- if (stream->type == UV_TCP && (stream->flags & UV_TCP_SINGLE_ACCEPT)) {
+ if (stream->type == UV_TCP &&
+ (stream->flags & UV_HANDLE_TCP_SINGLE_ACCEPT)) {
/* Give other processes a chance to accept connections. */
struct timespec timeout = { 0, 1 };
nanosleep(&timeout, NULL);
@@ -577,14 +594,14 @@ int uv_accept(uv_stream_t* server, uv_stream_t* client) {
assert(server->loop == client->loop);
if (server->accepted_fd == -1)
- return -EAGAIN;
+ return UV_EAGAIN;
switch (client->type) {
case UV_NAMED_PIPE:
case UV_TCP:
err = uv__stream_open(client,
server->accepted_fd,
- UV_STREAM_READABLE | UV_STREAM_WRITABLE);
+ UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);
if (err) {
/* TODO handle error */
uv__close(server->accepted_fd);
@@ -601,7 +618,7 @@ int uv_accept(uv_stream_t* server, uv_stream_t* client) {
break;
default:
- return -EINVAL;
+ return UV_EINVAL;
}
client->flags |= UV_HANDLE_BOUND;
@@ -649,7 +666,7 @@ int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb) {
break;
default:
- err = -EINVAL;
+ err = UV_EINVAL;
}
if (err == 0)
@@ -668,22 +685,22 @@ static void uv__drain(uv_stream_t* stream) {
uv__stream_osx_interrupt_select(stream);
/* Shutdown? */
- if ((stream->flags & UV_STREAM_SHUTTING) &&
- !(stream->flags & UV_CLOSING) &&
- !(stream->flags & UV_STREAM_SHUT)) {
+ if ((stream->flags & UV_HANDLE_SHUTTING) &&
+ !(stream->flags & UV_HANDLE_CLOSING) &&
+ !(stream->flags & UV_HANDLE_SHUT)) {
assert(stream->shutdown_req);
req = stream->shutdown_req;
stream->shutdown_req = NULL;
- stream->flags &= ~UV_STREAM_SHUTTING;
+ stream->flags &= ~UV_HANDLE_SHUTTING;
uv__req_unregister(stream->loop, req);
err = 0;
if (shutdown(uv__stream_fd(stream), SHUT_WR))
- err = -errno;
+ err = UV__ERR(errno);
if (err == 0)
- stream->flags |= UV_STREAM_SHUT;
+ stream->flags |= UV_HANDLE_SHUT;
if (req->cb != NULL)
req->cb(req, err);
@@ -691,6 +708,14 @@ static void uv__drain(uv_stream_t* stream) {
}
+static ssize_t uv__writev(int fd, struct iovec* vec, size_t n) {
+ if (n == 1)
+ return write(fd, vec->iov_base, vec->iov_len);
+ else
+ return writev(fd, vec, n);
+}
+
+
static size_t uv__write_req_size(uv_write_t* req) {
size_t size;
@@ -703,6 +728,37 @@ static size_t uv__write_req_size(uv_write_t* req) {
}
+/* Returns 1 if all write request data has been written, or 0 if there is still
+ * more data to write.
+ *
+ * Note: the return value only says something about the *current* request.
+ * There may still be other write requests sitting in the queue.
+ */
+static int uv__write_req_update(uv_stream_t* stream,
+ uv_write_t* req,
+ size_t n) {
+ uv_buf_t* buf;
+ size_t len;
+
+ assert(n <= stream->write_queue_size);
+ stream->write_queue_size -= n;
+
+ buf = req->bufs + req->write_index;
+
+ do {
+ len = n < buf->len ? n : buf->len;
+ buf->base += len;
+ buf->len -= len;
+ buf += (buf->len == 0); /* Advance to next buffer if this one is empty. */
+ n -= len;
+ } while (n > 0);
+
+ req->write_index = buf - req->bufs;
+
+ return req->write_index == req->nbufs;
+}
+
+
static void uv__write_req_finish(uv_write_t* req) {
uv_stream_t* stream = req->handle;
@@ -750,6 +806,7 @@ static void uv__write(uv_stream_t* stream) {
int iovmax;
int iovcnt;
ssize_t n;
+ int err;
start:
@@ -782,14 +839,21 @@ start:
*/
if (req->send_handle) {
+ int fd_to_send;
struct msghdr msg;
struct cmsghdr *cmsg;
- int fd_to_send = uv__handle_fd((uv_handle_t*) req->send_handle);
union {
char data[64];
struct cmsghdr alias;
} scratch;
+ if (uv__is_closing(req->send_handle)) {
+ err = UV_EBADF;
+ goto error;
+ }
+
+ fd_to_send = uv__handle_fd((uv_handle_t*) req->send_handle);
+
memset(&scratch, 0, sizeof(scratch));
assert(fd_to_send >= 0);
@@ -815,124 +879,64 @@ start:
*pi = fd_to_send;
}
- do {
+ do
n = sendmsg(uv__stream_fd(stream), &msg, 0);
- }
-#if defined(__APPLE__)
- /*
- * Due to a possible kernel bug at least in OS X 10.10 "Yosemite",
- * EPROTOTYPE can be returned while trying to write to a socket that is
- * shutting down. If we retry the write, we should get the expected EPIPE
- * instead.
- */
- while (n == -1 && (errno == EINTR || errno == EPROTOTYPE));
-#else
- while (n == -1 && errno == EINTR);
-#endif
- } else {
- do {
- if (iovcnt == 1) {
- n = write(uv__stream_fd(stream), iov[0].iov_base, iov[0].iov_len);
- } else {
- n = writev(uv__stream_fd(stream), iov, iovcnt);
- }
- }
-#if defined(__APPLE__)
- /*
- * Due to a possible kernel bug at least in OS X 10.10 "Yosemite",
- * EPROTOTYPE can be returned while trying to write to a socket that is
- * shutting down. If we retry the write, we should get the expected EPIPE
- * instead.
- */
- while (n == -1 && (errno == EINTR || errno == EPROTOTYPE));
-#else
- while (n == -1 && errno == EINTR);
-#endif
- }
+ while (n == -1 && RETRY_ON_WRITE_ERROR(errno));
- if (n < 0) {
- if (errno != EAGAIN && errno != EWOULDBLOCK) {
- /* Error */
- req->error = -errno;
- uv__write_req_finish(req);
- uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT);
- if (!uv__io_active(&stream->io_watcher, POLLIN))
- uv__handle_stop(stream);
- uv__stream_osx_interrupt_select(stream);
- return;
- } else if (stream->flags & UV_STREAM_BLOCKING) {
- /* If this is a blocking stream, try again. */
- goto start;
- }
+ /* Ensure the handle isn't sent again in case this is a partial write. */
+ if (n >= 0)
+ req->send_handle = NULL;
} else {
- /* Successful write */
-
- while (n >= 0) {
- uv_buf_t* buf = &(req->bufs[req->write_index]);
- size_t len = buf->len;
-
- assert(req->write_index < req->nbufs);
-
- if ((size_t)n < len) {
- buf->base += n;
- buf->len -= n;
- stream->write_queue_size -= n;
- n = 0;
-
- /* There is more to write. */
- if (stream->flags & UV_STREAM_BLOCKING) {
- /*
- * If we're blocking then we should not be enabling the write
- * watcher - instead we need to try again.
- */
- goto start;
- } else {
- /* Break loop and ensure the watcher is pending. */
- break;
- }
-
- } else {
- /* Finished writing the buf at index req->write_index. */
- req->write_index++;
-
- assert((size_t)n >= len);
- n -= len;
-
- assert(stream->write_queue_size >= len);
- stream->write_queue_size -= len;
+ do
+ n = uv__writev(uv__stream_fd(stream), iov, iovcnt);
+ while (n == -1 && RETRY_ON_WRITE_ERROR(errno));
+ }
- if (req->write_index == req->nbufs) {
- /* Then we're done! */
- assert(n == 0);
- uv__write_req_finish(req);
- /* TODO: start trying to write the next request. */
- return;
- }
- }
- }
+ if (n == -1 && !IS_TRANSIENT_WRITE_ERROR(errno, req->send_handle)) {
+ err = UV__ERR(errno);
+ goto error;
}
- /* Either we've counted n down to zero or we've got EAGAIN. */
- assert(n == 0 || n == -1);
+ if (n >= 0 && uv__write_req_update(stream, req, n)) {
+ uv__write_req_finish(req);
+ return; /* TODO(bnoordhuis) Start trying to write the next request. */
+ }
- /* Only non-blocking streams should use the write_watcher. */
- assert(!(stream->flags & UV_STREAM_BLOCKING));
+ /* If this is a blocking stream, try again. */
+ if (stream->flags & UV_HANDLE_BLOCKING_WRITES)
+ goto start;
/* We're not done. */
uv__io_start(stream->loop, &stream->io_watcher, POLLOUT);
/* Notify select() thread about state change */
uv__stream_osx_interrupt_select(stream);
+
+ return;
+
+error:
+ req->error = err;
+ uv__write_req_finish(req);
+ uv__io_stop(stream->loop, &stream->io_watcher, POLLOUT);
+ if (!uv__io_active(&stream->io_watcher, POLLIN))
+ uv__handle_stop(stream);
+ uv__stream_osx_interrupt_select(stream);
}
static void uv__write_callbacks(uv_stream_t* stream) {
uv_write_t* req;
QUEUE* q;
+ QUEUE pq;
+
+ if (QUEUE_EMPTY(&stream->write_completed_queue))
+ return;
- while (!QUEUE_EMPTY(&stream->write_completed_queue)) {
+ QUEUE_MOVE(&stream->write_completed_queue, &pq);
+
+ while (!QUEUE_EMPTY(&pq)) {
/* Pop a req off write_completed_queue. */
- q = QUEUE_HEAD(&stream->write_completed_queue);
+ q = QUEUE_HEAD(&pq);
req = QUEUE_DATA(q, uv_write_t, queue);
QUEUE_REMOVE(q);
uv__req_unregister(stream->loop, req);
@@ -948,8 +952,6 @@ static void uv__write_callbacks(uv_stream_t* stream) {
if (req->cb)
req->cb(req, req->error);
}
-
- assert(QUEUE_EMPTY(&stream->write_completed_queue));
}
@@ -997,13 +999,13 @@ uv_handle_type uv__handle_type(int fd) {
static void uv__stream_eof(uv_stream_t* stream, const uv_buf_t* buf) {
- stream->flags |= UV_STREAM_READ_EOF;
+ stream->flags |= UV_HANDLE_READ_EOF;
uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
if (!uv__io_active(&stream->io_watcher, POLLOUT))
uv__handle_stop(stream);
uv__stream_osx_interrupt_select(stream);
stream->read_cb(stream, UV_EOF, buf);
- stream->flags &= ~UV_STREAM_READING;
+ stream->flags &= ~UV_HANDLE_READING;
}
@@ -1017,7 +1019,7 @@ static int uv__stream_queue_fd(uv_stream_t* stream, int fd) {
queued_fds = uv__malloc((queue_size - 1) * sizeof(*queued_fds->fds) +
sizeof(*queued_fds));
if (queued_fds == NULL)
- return -ENOMEM;
+ return UV_ENOMEM;
queued_fds->size = queue_size;
queued_fds->offset = 0;
stream->queued_fds = queued_fds;
@@ -1034,7 +1036,7 @@ static int uv__stream_queue_fd(uv_stream_t* stream, int fd) {
* NOTE: if it is fatal - sockets will be closed in uv__stream_close
*/
if (queued_fds == NULL)
- return -ENOMEM;
+ return UV_ENOMEM;
queued_fds->size = queue_size;
stream->queued_fds = queued_fds;
}
@@ -1103,6 +1105,7 @@ static int uv__stream_recv_cmsg(uv_stream_t* stream, struct msghdr* msg) {
#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wgnu-folding-constant"
+# pragma clang diagnostic ignored "-Wvla-extension"
#endif
static void uv__read(uv_stream_t* stream) {
@@ -1114,7 +1117,7 @@ static void uv__read(uv_stream_t* stream) {
int err;
int is_ipc;
- stream->flags &= ~UV_STREAM_READ_PARTIAL;
+ stream->flags &= ~UV_HANDLE_READ_PARTIAL;
/* Prevent loop starvation when the data comes in as fast as (or faster than)
* we can read it. XXX Need to rearm fd if we switch to edge-triggered I/O.
@@ -1123,11 +1126,11 @@ static void uv__read(uv_stream_t* stream) {
is_ipc = stream->type == UV_NAMED_PIPE && ((uv_pipe_t*) stream)->ipc;
- /* XXX: Maybe instead of having UV_STREAM_READING we just test if
+ /* XXX: Maybe instead of having UV_HANDLE_READING we just test if
* tcp->read_cb is NULL or not?
*/
while (stream->read_cb
- && (stream->flags & UV_STREAM_READING)
+ && (stream->flags & UV_HANDLE_READING)
&& (count-- > 0)) {
assert(stream->alloc_cb != NULL);
@@ -1168,7 +1171,7 @@ static void uv__read(uv_stream_t* stream) {
/* Error */
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* Wait for the next one. */
- if (stream->flags & UV_STREAM_READING) {
+ if (stream->flags & UV_HANDLE_READING) {
uv__io_start(stream->loop, &stream->io_watcher, POLLIN);
uv__stream_osx_interrupt_select(stream);
}
@@ -1180,9 +1183,9 @@ static void uv__read(uv_stream_t* stream) {
#endif
} else {
/* Error. User should call uv_close(). */
- stream->read_cb(stream, -errno, &buf);
- if (stream->flags & UV_STREAM_READING) {
- stream->flags &= ~UV_STREAM_READING;
+ stream->read_cb(stream, UV__ERR(errno), &buf);
+ if (stream->flags & UV_HANDLE_READING) {
+ stream->flags &= ~UV_HANDLE_READING;
uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
if (!uv__io_active(&stream->io_watcher, POLLOUT))
uv__handle_stop(stream);
@@ -1232,7 +1235,7 @@ static void uv__read(uv_stream_t* stream) {
/* Return if we didn't fill the buffer, there is no more data to read. */
if (nread < buflen) {
- stream->flags |= UV_STREAM_READ_PARTIAL;
+ stream->flags |= UV_HANDLE_READ_PARTIAL;
return;
}
}
@@ -1249,14 +1252,15 @@ static void uv__read(uv_stream_t* stream) {
int uv_shutdown(uv_shutdown_t* req, uv_stream_t* stream, uv_shutdown_cb cb) {
- assert((stream->type == UV_TCP || stream->type == UV_NAMED_PIPE) &&
- "uv_shutdown (unix) only supports uv_handle_t right now");
+ assert(stream->type == UV_TCP ||
+ stream->type == UV_TTY ||
+ stream->type == UV_NAMED_PIPE);
- if (!(stream->flags & UV_STREAM_WRITABLE) ||
- stream->flags & UV_STREAM_SHUT ||
- stream->flags & UV_STREAM_SHUTTING ||
+ if (!(stream->flags & UV_HANDLE_WRITABLE) ||
+ stream->flags & UV_HANDLE_SHUT ||
+ stream->flags & UV_HANDLE_SHUTTING ||
uv__is_closing(stream)) {
- return -ENOTCONN;
+ return UV_ENOTCONN;
}
assert(uv__stream_fd(stream) >= 0);
@@ -1266,7 +1270,7 @@ int uv_shutdown(uv_shutdown_t* req, uv_stream_t* stream, uv_shutdown_cb cb) {
req->handle = stream;
req->cb = cb;
stream->shutdown_req = req;
- stream->flags |= UV_STREAM_SHUTTING;
+ stream->flags |= UV_HANDLE_SHUTTING;
uv__io_start(stream->loop, &stream->io_watcher, POLLOUT);
uv__stream_osx_interrupt_select(stream);
@@ -1283,7 +1287,7 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
assert(stream->type == UV_TCP ||
stream->type == UV_NAMED_PIPE ||
stream->type == UV_TTY);
- assert(!(stream->flags & UV_CLOSING));
+ assert(!(stream->flags & UV_HANDLE_CLOSING));
if (stream->connect_req) {
uv__stream_connect(stream);
@@ -1292,7 +1296,7 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
assert(uv__stream_fd(stream) >= 0);
- /* Ignore POLLHUP here. Even it it's set, there may still be data to read. */
+ /* Ignore POLLHUP here. Even if it's set, there may still be data to read. */
if (events & (POLLIN | POLLERR | POLLHUP))
uv__read(stream);
@@ -1306,9 +1310,9 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
* report the EOF yet because there is still data to read.
*/
if ((events & POLLHUP) &&
- (stream->flags & UV_STREAM_READING) &&
- (stream->flags & UV_STREAM_READ_PARTIAL) &&
- !(stream->flags & UV_STREAM_READ_EOF)) {
+ (stream->flags & UV_HANDLE_READING) &&
+ (stream->flags & UV_HANDLE_READ_PARTIAL) &&
+ !(stream->flags & UV_HANDLE_READ_EOF)) {
uv_buf_t buf = { NULL, 0 };
uv__stream_eof(stream, &buf);
}
@@ -1355,10 +1359,10 @@ static void uv__stream_connect(uv_stream_t* stream) {
SO_ERROR,
&error,
&errorsize);
- error = -error;
+ error = UV__ERR(error);
}
- if (error == -EINPROGRESS)
+ if (error == UV__ERR(EINPROGRESS))
return;
stream->connect_req = NULL;
@@ -1375,7 +1379,7 @@ static void uv__stream_connect(uv_stream_t* stream) {
return;
if (error < 0) {
- uv__stream_flush_write_queue(stream, -ECANCELED);
+ uv__stream_flush_write_queue(stream, UV_ECANCELED);
uv__write_callbacks(stream);
}
}
@@ -1396,11 +1400,14 @@ int uv_write2(uv_write_t* req,
"uv_write (unix) does not yet support other types of streams");
if (uv__stream_fd(stream) < 0)
- return -EBADF;
+ return UV_EBADF;
+
+ if (!(stream->flags & UV_HANDLE_WRITABLE))
+ return -EPIPE;
if (send_handle) {
if (stream->type != UV_NAMED_PIPE || !((uv_pipe_t*)stream)->ipc)
- return -EINVAL;
+ return UV_EINVAL;
/* XXX We abuse uv_write2() to send over UDP handles to child processes.
* Don't call uv__stream_fd() on those handles, it's a macro that on OS X
@@ -1409,12 +1416,12 @@ int uv_write2(uv_write_t* req,
* which works but only by accident.
*/
if (uv__handle_fd((uv_handle_t*) send_handle) < 0)
- return -EBADF;
+ return UV_EBADF;
#if defined(__CYGWIN__) || defined(__MSYS__)
/* Cygwin recvmsg always sets msg_controllen to zero, so we cannot send it.
See https://github.com/mirror/newlib-cygwin/blob/86fc4bf0/winsup/cygwin/fhandler_socket.cc#L1736-L1743 */
- return -ENOSYS;
+ return UV_ENOSYS;
#endif
}
@@ -1439,7 +1446,7 @@ int uv_write2(uv_write_t* req,
req->bufs = uv__malloc(nbufs * sizeof(bufs[0]));
if (req->bufs == NULL)
- return -ENOMEM;
+ return UV_ENOMEM;
memcpy(req->bufs, bufs, nbufs * sizeof(bufs[0]));
req->nbufs = nbufs;
@@ -1465,7 +1472,7 @@ int uv_write2(uv_write_t* req,
* if this assert fires then somehow the blocking stream isn't being
* sufficiently flushed in uv__write.
*/
- assert(!(stream->flags & UV_STREAM_BLOCKING));
+ assert(!(stream->flags & UV_HANDLE_BLOCKING_WRITES));
uv__io_start(stream->loop, &stream->io_watcher, POLLOUT);
uv__stream_osx_interrupt_select(stream);
}
@@ -1503,7 +1510,7 @@ int uv_try_write(uv_stream_t* stream,
/* Connecting or already writing some data */
if (stream->connect_req != NULL || stream->write_queue_size != 0)
- return -EAGAIN;
+ return UV_EAGAIN;
has_pollout = uv__io_active(&stream->io_watcher, POLLOUT);
@@ -1534,7 +1541,7 @@ int uv_try_write(uv_stream_t* stream,
}
if (written == 0 && req_size != 0)
- return -EAGAIN;
+ return req.error < 0 ? req.error : UV_EAGAIN;
else
return written;
}
@@ -1546,13 +1553,16 @@ int uv_read_start(uv_stream_t* stream,
assert(stream->type == UV_TCP || stream->type == UV_NAMED_PIPE ||
stream->type == UV_TTY);
- if (stream->flags & UV_CLOSING)
- return -EINVAL;
+ if (stream->flags & UV_HANDLE_CLOSING)
+ return UV_EINVAL;
- /* The UV_STREAM_READING flag is irrelevant of the state of the tcp - it just
+ if (!(stream->flags & UV_HANDLE_READABLE))
+ return -ENOTCONN;
+
+ /* The UV_HANDLE_READING flag is irrelevant of the state of the tcp - it just
* expresses the desired state of the user.
*/
- stream->flags |= UV_STREAM_READING;
+ stream->flags |= UV_HANDLE_READING;
/* TODO: try to do the read inline? */
/* TODO: keep track of tcp state. If we've gotten a EOF then we should
@@ -1573,10 +1583,10 @@ int uv_read_start(uv_stream_t* stream,
int uv_read_stop(uv_stream_t* stream) {
- if (!(stream->flags & UV_STREAM_READING))
+ if (!(stream->flags & UV_HANDLE_READING))
return 0;
- stream->flags &= ~UV_STREAM_READING;
+ stream->flags &= ~UV_HANDLE_READING;
uv__io_stop(stream->loop, &stream->io_watcher, POLLIN);
if (!uv__io_active(&stream->io_watcher, POLLOUT))
uv__handle_stop(stream);
@@ -1589,16 +1599,16 @@ int uv_read_stop(uv_stream_t* stream) {
int uv_is_readable(const uv_stream_t* stream) {
- return !!(stream->flags & UV_STREAM_READABLE);
+ return !!(stream->flags & UV_HANDLE_READABLE);
}
int uv_is_writable(const uv_stream_t* stream) {
- return !!(stream->flags & UV_STREAM_WRITABLE);
+ return !!(stream->flags & UV_HANDLE_WRITABLE);
}
-#if defined(__APPLE__)
+#if defined(__APPLE__) && !defined(CMAKE_BOOTSTRAP)
int uv___stream_fd(const uv_stream_t* handle) {
const uv__stream_select_t* s;
@@ -1619,7 +1629,7 @@ void uv__stream_close(uv_stream_t* handle) {
unsigned int i;
uv__stream_queued_fds_t* queued_fds;
-#if defined(__APPLE__)
+#if defined(__APPLE__) && !defined(CMAKE_BOOTSTRAP)
/* Terminate select loop first */
if (handle->select != NULL) {
uv__stream_select_t* s;
@@ -1643,6 +1653,7 @@ void uv__stream_close(uv_stream_t* handle) {
uv__io_close(handle->loop, &handle->io_watcher);
uv_read_stop(handle);
uv__handle_stop(handle);
+ handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);
if (handle->io_watcher.fd != -1) {
/* Don't close stdio file descriptors. Nothing good comes from it. */
diff --git a/Utilities/cmlibuv/src/unix/sunos.c b/Utilities/cmlibuv/src/unix/sunos.c
index 041f3f336..0cd25c10a 100644
--- a/Utilities/cmlibuv/src/unix/sunos.c
+++ b/Utilities/cmlibuv/src/unix/sunos.c
@@ -77,7 +77,7 @@ int uv__platform_loop_init(uv_loop_t* loop) {
fd = port_create();
if (fd == -1)
- return -errno;
+ return UV__ERR(errno);
err = uv__cloexec(fd, 1);
if (err) {
@@ -121,6 +121,7 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
uintptr_t nfds;
assert(loop->watchers != NULL);
+ assert(fd >= 0);
events = (struct port_event*) loop->watchers[loop->nwatchers];
nfds = (uintptr_t) loop->watchers[loop->nwatchers + 1];
@@ -136,10 +137,12 @@ void uv__platform_invalidate_fd(uv_loop_t* loop, int fd) {
int uv__io_check_fd(uv_loop_t* loop, int fd) {
if (port_associate(loop->backend_fd, PORT_SOURCE_FD, fd, POLLIN, 0))
- return -errno;
+ return UV__ERR(errno);
- if (port_dissociate(loop->backend_fd, PORT_SOURCE_FD, fd))
+ if (port_dissociate(loop->backend_fd, PORT_SOURCE_FD, fd)) {
+ perror("(libuv) port_dissociate()");
abort();
+ }
return 0;
}
@@ -177,8 +180,14 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
w = QUEUE_DATA(q, uv__io_t, watcher_queue);
assert(w->pevents != 0);
- if (port_associate(loop->backend_fd, PORT_SOURCE_FD, w->fd, w->pevents, 0))
+ if (port_associate(loop->backend_fd,
+ PORT_SOURCE_FD,
+ w->fd,
+ w->pevents,
+ 0)) {
+ perror("(libuv) port_associate()");
abort();
+ }
w->events = w->pevents;
}
@@ -222,10 +231,12 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
/* Work around another kernel bug: port_getn() may return events even
* on error.
*/
- if (errno == EINTR || errno == ETIME)
+ if (errno == EINTR || errno == ETIME) {
saved_errno = errno;
- else
+ } else {
+ perror("(libuv) port_getn()");
abort();
+ }
}
/* Update loop->time unconditionally. It's tempting to skip the update when
@@ -346,7 +357,7 @@ int uv_exepath(char* buffer, size_t* size) {
char buf[128];
if (buffer == NULL || size == NULL || *size == 0)
- return -EINVAL;
+ return UV_EINVAL;
snprintf(buf, sizeof(buf), "/proc/%lu/path/a.out", (unsigned long) getpid());
@@ -355,7 +366,7 @@ int uv_exepath(char* buffer, size_t* size) {
res = readlink(buf, buffer, res);
if (res == -1)
- return -errno;
+ return UV__ERR(errno);
buffer[res] = '\0';
*size = res;
@@ -373,6 +384,11 @@ uint64_t uv_get_total_memory(void) {
}
+uint64_t uv_get_constrained_memory(void) {
+ return 0; /* Memory constraints are unknown. */
+}
+
+
void uv_loadavg(double avg[3]) {
(void) getloadavg(avg, 3);
}
@@ -382,14 +398,14 @@ void uv_loadavg(double avg[3]) {
static int uv__fs_event_rearm(uv_fs_event_t *handle) {
if (handle->fd == -1)
- return -EBADF;
+ return UV_EBADF;
if (port_associate(handle->loop->fs_fd,
PORT_SOURCE_FILE,
(uintptr_t) &handle->fo,
FILE_ATTRIB | FILE_MODIFIED,
handle) == -1) {
- return -errno;
+ return UV__ERR(errno);
}
handle->fd = PORT_LOADED;
@@ -466,13 +482,13 @@ int uv_fs_event_start(uv_fs_event_t* handle,
int err;
if (uv__is_active(handle))
- return -EINVAL;
+ return UV_EINVAL;
first_run = 0;
if (handle->loop->fs_fd == -1) {
portfd = port_create();
if (portfd == -1)
- return -errno;
+ return UV__ERR(errno);
handle->loop->fs_fd = portfd;
first_run = 1;
}
@@ -525,7 +541,7 @@ void uv__fs_event_close(uv_fs_event_t* handle) {
#else /* !defined(PORT_SOURCE_FILE) */
int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) {
- return -ENOSYS;
+ return UV_ENOSYS;
}
@@ -533,12 +549,12 @@ int uv_fs_event_start(uv_fs_event_t* handle,
uv_fs_event_cb cb,
const char* filename,
unsigned int flags) {
- return -ENOSYS;
+ return UV_ENOSYS;
}
int uv_fs_event_stop(uv_fs_event_t* handle) {
- return -ENOSYS;
+ return UV_ENOSYS;
}
@@ -556,10 +572,10 @@ int uv_resident_set_memory(size_t* rss) {
fd = open("/proc/self/psinfo", O_RDONLY);
if (fd == -1)
- return -errno;
+ return UV__ERR(errno);
/* FIXME(bnoordhuis) Handle EINTR. */
- err = -EINVAL;
+ err = UV_EINVAL;
if (read(fd, &psinfo, sizeof(psinfo)) == sizeof(psinfo)) {
*rss = (size_t)psinfo.pr_rssize * 1024;
err = 0;
@@ -579,7 +595,7 @@ int uv_uptime(double* uptime) {
kc = kstat_open();
if (kc == NULL)
- return -EPERM;
+ return UV_EPERM;
ksp = kstat_lookup(kc, (char*) "unix", 0, (char*) "system_misc");
if (kstat_read(kc, ksp, NULL) == -1) {
@@ -603,7 +619,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
kc = kstat_open();
if (kc == NULL)
- return -EPERM;
+ return UV_EPERM;
/* Get count of cpus */
lookup_instance = 0;
@@ -614,7 +630,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
*cpu_infos = uv__malloc(lookup_instance * sizeof(**cpu_infos));
if (!(*cpu_infos)) {
kstat_close(kc);
- return -ENOMEM;
+ return UV_ENOMEM;
}
*count = lookup_instance;
@@ -696,7 +712,9 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
#ifdef SUNOS_NO_IFADDRS
int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
- return -ENOSYS;
+ *count = 0;
+ *addresses = NULL;
+ return UV_ENOSYS;
}
#else /* SUNOS_NO_IFADDRS */
/*
@@ -709,13 +727,14 @@ static int uv__set_phys_addr(uv_interface_address_t* address,
struct sockaddr_dl* sa_addr;
int sockfd;
- int i;
+ size_t i;
struct arpreq arpreq;
/* This appears to only work as root */
sa_addr = (struct sockaddr_dl*)(ent->ifa_addr);
memcpy(address->phys_addr, LLADDR(sa_addr), sizeof(address->phys_addr));
for (i = 0; i < sizeof(address->phys_addr); i++) {
+ /* Check that all bytes of phys_addr are zero. */
if (address->phys_addr[i] != 0)
return 0;
}
@@ -734,11 +753,11 @@ static int uv__set_phys_addr(uv_interface_address_t* address,
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd < 0)
- return -errno;
+ return UV__ERR(errno);
if (ioctl(sockfd, SIOCGARP, (char*)&arpreq) == -1) {
uv__close(sockfd);
- return -errno;
+ return UV__ERR(errno);
}
memcpy(address->phys_addr, arpreq.arp_ha.sa_data, sizeof(address->phys_addr));
uv__close(sockfd);
@@ -751,7 +770,8 @@ static int uv__ifaddr_exclude(struct ifaddrs *ent) {
return 1;
if (ent->ifa_addr == NULL)
return 1;
- if (ent->ifa_addr->sa_family == PF_PACKET)
+ if (ent->ifa_addr->sa_family != AF_INET &&
+ ent->ifa_addr->sa_family != AF_INET6)
return 1;
return 0;
}
@@ -760,12 +780,12 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
uv_interface_address_t* address;
struct ifaddrs* addrs;
struct ifaddrs* ent;
- int i;
-
- if (getifaddrs(&addrs))
- return -errno;
*count = 0;
+ *addresses = NULL;
+
+ if (getifaddrs(&addrs))
+ return UV__ERR(errno);
/* Count the number of interfaces */
for (ent = addrs; ent != NULL; ent = ent->ifa_next) {
@@ -774,10 +794,15 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
(*count)++;
}
+ if (*count == 0) {
+ freeifaddrs(addrs);
+ return 0;
+ }
+
*addresses = uv__malloc(*count * sizeof(**addresses));
if (!(*addresses)) {
freeifaddrs(addrs);
- return -ENOMEM;
+ return UV_ENOMEM;
}
address = *addresses;
diff --git a/Utilities/cmlibuv/src/unix/tcp.c b/Utilities/cmlibuv/src/unix/tcp.c
index c423dcb15..8cedcd602 100644
--- a/Utilities/cmlibuv/src/unix/tcp.c
+++ b/Utilities/cmlibuv/src/unix/tcp.c
@@ -28,15 +28,12 @@
#include <errno.h>
-static int maybe_new_socket(uv_tcp_t* handle, int domain, int flags) {
+static int new_socket(uv_tcp_t* handle, int domain, unsigned long flags) {
+ struct sockaddr_storage saddr;
+ socklen_t slen;
int sockfd;
int err;
- if (domain == AF_UNSPEC || uv__stream_fd(handle) != -1) {
- handle->flags |= flags;
- return 0;
- }
-
err = uv__socket(domain, SOCK_STREAM, 0);
if (err < 0)
return err;
@@ -48,20 +45,82 @@ static int maybe_new_socket(uv_tcp_t* handle, int domain, int flags) {
return err;
}
+ if (flags & UV_HANDLE_BOUND) {
+ /* Bind this new socket to an arbitrary port */
+ slen = sizeof(saddr);
+ memset(&saddr, 0, sizeof(saddr));
+ if (getsockname(uv__stream_fd(handle), (struct sockaddr*) &saddr, &slen)) {
+ uv__close(sockfd);
+ return UV__ERR(errno);
+ }
+
+ if (bind(uv__stream_fd(handle), (struct sockaddr*) &saddr, slen)) {
+ uv__close(sockfd);
+ return UV__ERR(errno);
+ }
+ }
+
return 0;
}
+static int maybe_new_socket(uv_tcp_t* handle, int domain, unsigned long flags) {
+ struct sockaddr_storage saddr;
+ socklen_t slen;
+
+ if (domain == AF_UNSPEC) {
+ handle->flags |= flags;
+ return 0;
+ }
+
+ if (uv__stream_fd(handle) != -1) {
+
+ if (flags & UV_HANDLE_BOUND) {
+
+ if (handle->flags & UV_HANDLE_BOUND) {
+ /* It is already bound to a port. */
+ handle->flags |= flags;
+ return 0;
+ }
+
+ /* Query to see if tcp socket is bound. */
+ slen = sizeof(saddr);
+ memset(&saddr, 0, sizeof(saddr));
+ if (getsockname(uv__stream_fd(handle), (struct sockaddr*) &saddr, &slen))
+ return UV__ERR(errno);
+
+ if ((saddr.ss_family == AF_INET6 &&
+ ((struct sockaddr_in6*) &saddr)->sin6_port != 0) ||
+ (saddr.ss_family == AF_INET &&
+ ((struct sockaddr_in*) &saddr)->sin_port != 0)) {
+ /* Handle is already bound to a port. */
+ handle->flags |= flags;
+ return 0;
+ }
+
+ /* Bind to arbitrary port */
+ if (bind(uv__stream_fd(handle), (struct sockaddr*) &saddr, slen))
+ return UV__ERR(errno);
+ }
+
+ handle->flags |= flags;
+ return 0;
+ }
+
+ return new_socket(handle, domain, flags);
+}
+
+
int uv_tcp_init_ex(uv_loop_t* loop, uv_tcp_t* tcp, unsigned int flags) {
int domain;
/* Use the lower 8 bits for the domain */
domain = flags & 0xFF;
if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC)
- return -EINVAL;
+ return UV_EINVAL;
if (flags & ~0xFF)
- return -EINVAL;
+ return UV_EINVAL;
uv__stream_init(loop, (uv_stream_t*)tcp, UV_TCP);
@@ -95,18 +154,17 @@ int uv__tcp_bind(uv_tcp_t* tcp,
/* Cannot set IPv6-only mode on non-IPv6 socket. */
if ((flags & UV_TCP_IPV6ONLY) && addr->sa_family != AF_INET6)
- return -EINVAL;
+ return UV_EINVAL;
- err = maybe_new_socket(tcp,
- addr->sa_family,
- UV_STREAM_READABLE | UV_STREAM_WRITABLE);
+ err = maybe_new_socket(tcp, addr->sa_family, 0);
if (err)
return err;
on = 1;
if (setsockopt(tcp->io_watcher.fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)))
- return -errno;
+ return UV__ERR(errno);
+#ifndef __OpenBSD__
#ifdef IPV6_V6ONLY
if (addr->sa_family == AF_INET6) {
on = (flags & UV_TCP_IPV6ONLY) != 0;
@@ -117,22 +175,23 @@ int uv__tcp_bind(uv_tcp_t* tcp,
sizeof on) == -1) {
#if defined(__MVS__)
if (errno == EOPNOTSUPP)
- return -EINVAL;
+ return UV_EINVAL;
#endif
- return -errno;
+ return UV__ERR(errno);
}
}
#endif
+#endif
errno = 0;
if (bind(tcp->io_watcher.fd, addr, addrlen) && errno != EADDRINUSE) {
if (errno == EAFNOSUPPORT)
/* OSX, other BSDs and SunoS fail with EAFNOSUPPORT when binding a
* socket created with AF_INET to an AF_INET6 address or vice versa. */
- return -EINVAL;
- return -errno;
+ return UV_EINVAL;
+ return UV__ERR(errno);
}
- tcp->delayed_error = -errno;
+ tcp->delayed_error = UV__ERR(errno);
tcp->flags |= UV_HANDLE_BOUND;
if (addr->sa_family == AF_INET6)
@@ -153,11 +212,11 @@ int uv__tcp_connect(uv_connect_t* req,
assert(handle->type == UV_TCP);
if (handle->connect_req != NULL)
- return -EALREADY; /* FIXME(bnoordhuis) -EINVAL or maybe -EBUSY. */
+ return UV_EALREADY; /* FIXME(bnoordhuis) UV_EINVAL or maybe UV_EBUSY. */
err = maybe_new_socket(handle,
addr->sa_family,
- UV_STREAM_READABLE | UV_STREAM_WRITABLE);
+ UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);
if (err)
return err;
@@ -176,14 +235,18 @@ int uv__tcp_connect(uv_connect_t* req,
if (r == -1 && errno != 0) {
if (errno == EINPROGRESS)
; /* not an error */
- else if (errno == ECONNREFUSED)
- /* If we get a ECONNREFUSED wait until the next tick to report the
- * error. Solaris wants to report immediately--other unixes want to
- * wait.
+ else if (errno == ECONNREFUSED
+#if defined(__OpenBSD__)
+ || errno == EINVAL
+#endif
+ )
+ /* If we get ECONNREFUSED (Solaris) or EINVAL (OpenBSD) wait until the
+ * next tick to report the error. Solaris and OpenBSD wants to report
+ * immediately -- other unixes want to wait.
*/
- handle->delayed_error = -errno;
+ handle->delayed_error = UV__ERR(ECONNREFUSED);
else
- return -errno;
+ return UV__ERR(errno);
}
uv__req_init(handle->loop, req, UV_CONNECT);
@@ -204,62 +267,50 @@ int uv__tcp_connect(uv_connect_t* req,
int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock) {
int err;
+ if (uv__fd_exists(handle->loop, sock))
+ return UV_EEXIST;
+
err = uv__nonblock(sock, 1);
if (err)
return err;
return uv__stream_open((uv_stream_t*)handle,
sock,
- UV_STREAM_READABLE | UV_STREAM_WRITABLE);
+ UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);
}
int uv_tcp_getsockname(const uv_tcp_t* handle,
struct sockaddr* name,
int* namelen) {
- socklen_t socklen;
if (handle->delayed_error)
return handle->delayed_error;
- if (uv__stream_fd(handle) < 0)
- return -EINVAL; /* FIXME(bnoordhuis) -EBADF */
-
- /* sizeof(socklen_t) != sizeof(int) on some systems. */
- socklen = (socklen_t) *namelen;
-
- if (getsockname(uv__stream_fd(handle), name, &socklen))
- return -errno;
-
- *namelen = (int) socklen;
- return 0;
+ return uv__getsockpeername((const uv_handle_t*) handle,
+ getsockname,
+ name,
+ namelen);
}
int uv_tcp_getpeername(const uv_tcp_t* handle,
struct sockaddr* name,
int* namelen) {
- socklen_t socklen;
if (handle->delayed_error)
return handle->delayed_error;
- if (uv__stream_fd(handle) < 0)
- return -EINVAL; /* FIXME(bnoordhuis) -EBADF */
-
- /* sizeof(socklen_t) != sizeof(int) on some systems. */
- socklen = (socklen_t) *namelen;
-
- if (getpeername(uv__stream_fd(handle), name, &socklen))
- return -errno;
-
- *namelen = (int) socklen;
- return 0;
+ return uv__getsockpeername((const uv_handle_t*) handle,
+ getpeername,
+ name,
+ namelen);
}
int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
static int single_accept = -1;
+ unsigned long flags;
int err;
if (tcp->delayed_error)
@@ -271,35 +322,22 @@ int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
}
if (single_accept)
- tcp->flags |= UV_TCP_SINGLE_ACCEPT;
+ tcp->flags |= UV_HANDLE_TCP_SINGLE_ACCEPT;
- err = maybe_new_socket(tcp, AF_INET, UV_STREAM_READABLE);
- if (err)
- return err;
-
-#ifdef __MVS__
+ flags = 0;
+#if defined(__MVS__)
/* on zOS the listen call does not bind automatically
if the socket is unbound. Hence the manual binding to
an arbitrary port is required to be done manually
*/
-
- if (!(tcp->flags & UV_HANDLE_BOUND)) {
- struct sockaddr_storage saddr;
- socklen_t slen = sizeof(saddr);
- memset(&saddr, 0, sizeof(saddr));
-
- if (getsockname(tcp->io_watcher.fd, (struct sockaddr*) &saddr, &slen))
- return -errno;
-
- if (bind(tcp->io_watcher.fd, (struct sockaddr*) &saddr, slen))
- return -errno;
-
- tcp->flags |= UV_HANDLE_BOUND;
- }
+ flags |= UV_HANDLE_BOUND;
#endif
+ err = maybe_new_socket(tcp, AF_INET, flags);
+ if (err)
+ return err;
if (listen(tcp->io_watcher.fd, backlog))
- return -errno;
+ return UV__ERR(errno);
tcp->connection_cb = cb;
tcp->flags |= UV_HANDLE_BOUND;
@@ -314,18 +352,18 @@ int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
int uv__tcp_nodelay(int fd, int on) {
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)))
- return -errno;
+ return UV__ERR(errno);
return 0;
}
int uv__tcp_keepalive(int fd, int on, unsigned int delay) {
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)))
- return -errno;
+ return UV__ERR(errno);
#ifdef TCP_KEEPIDLE
if (on && setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &delay, sizeof(delay)))
- return -errno;
+ return UV__ERR(errno);
#endif
/* Solaris/SmartOS, if you don't support keep-alive,
@@ -334,7 +372,7 @@ int uv__tcp_keepalive(int fd, int on, unsigned int delay) {
/* FIXME(bnoordhuis) That's possibly because sizeof(delay) should be 1. */
#if defined(TCP_KEEPALIVE) && !defined(__sun)
if (on && setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &delay, sizeof(delay)))
- return -errno;
+ return UV__ERR(errno);
#endif
return 0;
@@ -351,9 +389,9 @@ int uv_tcp_nodelay(uv_tcp_t* handle, int on) {
}
if (on)
- handle->flags |= UV_TCP_NODELAY;
+ handle->flags |= UV_HANDLE_TCP_NODELAY;
else
- handle->flags &= ~UV_TCP_NODELAY;
+ handle->flags &= ~UV_HANDLE_TCP_NODELAY;
return 0;
}
@@ -369,9 +407,9 @@ int uv_tcp_keepalive(uv_tcp_t* handle, int on, unsigned int delay) {
}
if (on)
- handle->flags |= UV_TCP_KEEPALIVE;
+ handle->flags |= UV_HANDLE_TCP_KEEPALIVE;
else
- handle->flags &= ~UV_TCP_KEEPALIVE;
+ handle->flags &= ~UV_HANDLE_TCP_KEEPALIVE;
/* TODO Store delay if uv__stream_fd(handle) == -1 but don't want to enlarge
* uv_tcp_t with an int that's almost never used...
@@ -383,9 +421,9 @@ int uv_tcp_keepalive(uv_tcp_t* handle, int on, unsigned int delay) {
int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) {
if (enable)
- handle->flags &= ~UV_TCP_SINGLE_ACCEPT;
+ handle->flags &= ~UV_HANDLE_TCP_SINGLE_ACCEPT;
else
- handle->flags |= UV_TCP_SINGLE_ACCEPT;
+ handle->flags |= UV_HANDLE_TCP_SINGLE_ACCEPT;
return 0;
}
diff --git a/Utilities/cmlibuv/src/unix/thread.c b/Utilities/cmlibuv/src/unix/thread.c
index a9b5e4c02..045322170 100644
--- a/Utilities/cmlibuv/src/unix/thread.c
+++ b/Utilities/cmlibuv/src/unix/thread.c
@@ -37,47 +37,223 @@
#include <sys/sem.h>
#endif
+#ifdef __GLIBC__
+#include <gnu/libc-version.h> /* gnu_get_libc_version() */
+#endif
+
#undef NANOSEC
#define NANOSEC ((uint64_t) 1e9)
-
-int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) {
- int err;
- pthread_attr_t* attr;
-#if defined(__APPLE__)
- pthread_attr_t attr_storage;
- struct rlimit lim;
+#if defined(PTHREAD_BARRIER_SERIAL_THREAD)
+STATIC_ASSERT(sizeof(uv_barrier_t) == sizeof(pthread_barrier_t));
#endif
- /* On OSX threads other than the main thread are created with a reduced stack
- * size by default, adjust it to RLIMIT_STACK.
- */
-#if defined(__APPLE__)
- if (getrlimit(RLIMIT_STACK, &lim))
+/* Note: guard clauses should match uv_barrier_t's in include/uv/unix.h. */
+#if defined(_AIX) || \
+ defined(__OpenBSD__) || \
+ !defined(PTHREAD_BARRIER_SERIAL_THREAD)
+int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) {
+ struct _uv_barrier* b;
+ int rc;
+
+ if (barrier == NULL || count == 0)
+ return UV_EINVAL;
+
+ b = uv__malloc(sizeof(*b));
+ if (b == NULL)
+ return UV_ENOMEM;
+
+ b->in = 0;
+ b->out = 0;
+ b->threshold = count;
+
+ rc = uv_mutex_init(&b->mutex);
+ if (rc != 0)
+ goto error2;
+
+ rc = uv_cond_init(&b->cond);
+ if (rc != 0)
+ goto error;
+
+ barrier->b = b;
+ return 0;
+
+error:
+ uv_mutex_destroy(&b->mutex);
+error2:
+ uv__free(b);
+ return rc;
+}
+
+
+int uv_barrier_wait(uv_barrier_t* barrier) {
+ struct _uv_barrier* b;
+ int last;
+
+ if (barrier == NULL || barrier->b == NULL)
+ return UV_EINVAL;
+
+ b = barrier->b;
+ uv_mutex_lock(&b->mutex);
+
+ if (++b->in == b->threshold) {
+ b->in = 0;
+ b->out = b->threshold;
+ uv_cond_signal(&b->cond);
+ } else {
+ do
+ uv_cond_wait(&b->cond, &b->mutex);
+ while (b->in != 0);
+ }
+
+ last = (--b->out == 0);
+ if (!last)
+ uv_cond_signal(&b->cond); /* Not needed for last thread. */
+
+ uv_mutex_unlock(&b->mutex);
+ return last;
+}
+
+
+void uv_barrier_destroy(uv_barrier_t* barrier) {
+ struct _uv_barrier* b;
+
+ b = barrier->b;
+ uv_mutex_lock(&b->mutex);
+
+ assert(b->in == 0);
+ assert(b->out == 0);
+
+ if (b->in != 0 || b->out != 0)
+ abort();
+
+ uv_mutex_unlock(&b->mutex);
+ uv_mutex_destroy(&b->mutex);
+ uv_cond_destroy(&b->cond);
+
+ uv__free(barrier->b);
+ barrier->b = NULL;
+}
+
+#else
+
+int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) {
+ return UV__ERR(pthread_barrier_init(barrier, NULL, count));
+}
+
+
+int uv_barrier_wait(uv_barrier_t* barrier) {
+ int rc;
+
+ rc = pthread_barrier_wait(barrier);
+ if (rc != 0)
+ if (rc != PTHREAD_BARRIER_SERIAL_THREAD)
+ abort();
+
+ return rc == PTHREAD_BARRIER_SERIAL_THREAD;
+}
+
+
+void uv_barrier_destroy(uv_barrier_t* barrier) {
+ if (pthread_barrier_destroy(barrier))
abort();
+}
+
+#endif
+
+
+/* On MacOS, threads other than the main thread are created with a reduced
+ * stack size by default. Adjust to RLIMIT_STACK aligned to the page size.
+ *
+ * On Linux, threads created by musl have a much smaller stack than threads
+ * created by glibc (80 vs. 2048 or 4096 kB.) Follow glibc for consistency.
+ */
+static size_t thread_stack_size(void) {
+#if defined(__APPLE__) || defined(__linux__)
+ struct rlimit lim;
- attr = &attr_storage;
- if (pthread_attr_init(attr))
+ if (getrlimit(RLIMIT_STACK, &lim))
abort();
if (lim.rlim_cur != RLIM_INFINITY) {
/* pthread_attr_setstacksize() expects page-aligned values. */
lim.rlim_cur -= lim.rlim_cur % (rlim_t) getpagesize();
- if (lim.rlim_cur >= PTHREAD_STACK_MIN)
- if (pthread_attr_setstacksize(attr, lim.rlim_cur))
- abort();
+ /* Musl's PTHREAD_STACK_MIN is 2 KB on all architectures, which is
+ * too small to safely receive signals on.
+ *
+ * Musl's PTHREAD_STACK_MIN + MINSIGSTKSZ == 8192 on arm64 (which has
+ * the largest MINSIGSTKSZ of the architectures that musl supports) so
+ * let's use that as a lower bound.
+ *
+ * We use a hardcoded value because PTHREAD_STACK_MIN + MINSIGSTKSZ
+ * is between 28 and 133 KB when compiling against glibc, depending
+ * on the architecture.
+ */
+ if (lim.rlim_cur >= 8192)
+ if (lim.rlim_cur >= PTHREAD_STACK_MIN)
+ return lim.rlim_cur;
}
+#endif
+
+#if !defined(__linux__)
+ return 0;
+#elif defined(__PPC__) || defined(__ppc__) || defined(__powerpc__)
+ return 4 << 20; /* glibc default. */
#else
+ return 2 << 20; /* glibc default. */
+#endif
+}
+
+
+int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) {
+ uv_thread_options_t params;
+ params.flags = UV_THREAD_NO_FLAGS;
+ return uv_thread_create_ex(tid, &params, entry, arg);
+}
+
+int uv_thread_create_ex(uv_thread_t* tid,
+ const uv_thread_options_t* params,
+ void (*entry)(void *arg),
+ void *arg) {
+ int err;
+ pthread_attr_t* attr;
+ pthread_attr_t attr_storage;
+ size_t pagesize;
+ size_t stack_size;
+
+ stack_size =
+ params->flags & UV_THREAD_HAS_STACK_SIZE ? params->stack_size : 0;
+
attr = NULL;
+ if (stack_size == 0) {
+ stack_size = thread_stack_size();
+ } else {
+ pagesize = (size_t)getpagesize();
+ /* Round up to the nearest page boundary. */
+ stack_size = (stack_size + pagesize - 1) &~ (pagesize - 1);
+#ifdef PTHREAD_STACK_MIN
+ if (stack_size < PTHREAD_STACK_MIN)
+ stack_size = PTHREAD_STACK_MIN;
#endif
+ }
+
+ if (stack_size > 0) {
+ attr = &attr_storage;
+
+ if (pthread_attr_init(attr))
+ abort();
+
+ if (pthread_attr_setstacksize(attr, stack_size))
+ abort();
+ }
err = pthread_create(tid, attr, (void*(*)(void*)) entry, arg);
if (attr != NULL)
pthread_attr_destroy(attr);
- return -err;
+ return UV__ERR(err);
}
@@ -86,7 +262,7 @@ uv_thread_t uv_thread_self(void) {
}
int uv_thread_join(uv_thread_t *tid) {
- return -pthread_join(*tid, NULL);
+ return UV__ERR(pthread_join(*tid, NULL));
}
@@ -97,7 +273,7 @@ int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2) {
int uv_mutex_init(uv_mutex_t* mutex) {
#if defined(NDEBUG) || !defined(PTHREAD_MUTEX_ERRORCHECK)
- return -pthread_mutex_init(mutex, NULL);
+ return UV__ERR(pthread_mutex_init(mutex, NULL));
#else
pthread_mutexattr_t attr;
int err;
@@ -113,11 +289,30 @@ int uv_mutex_init(uv_mutex_t* mutex) {
if (pthread_mutexattr_destroy(&attr))
abort();
- return -err;
+ return UV__ERR(err);
#endif
}
+int uv_mutex_init_recursive(uv_mutex_t* mutex) {
+ pthread_mutexattr_t attr;
+ int err;
+
+ if (pthread_mutexattr_init(&attr))
+ abort();
+
+ if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE))
+ abort();
+
+ err = pthread_mutex_init(mutex, &attr);
+
+ if (pthread_mutexattr_destroy(&attr))
+ abort();
+
+ return UV__ERR(err);
+}
+
+
void uv_mutex_destroy(uv_mutex_t* mutex) {
if (pthread_mutex_destroy(mutex))
abort();
@@ -137,7 +332,7 @@ int uv_mutex_trylock(uv_mutex_t* mutex) {
if (err) {
if (err != EBUSY && err != EAGAIN)
abort();
- return -EBUSY;
+ return UV_EBUSY;
}
return 0;
@@ -151,7 +346,7 @@ void uv_mutex_unlock(uv_mutex_t* mutex) {
int uv_rwlock_init(uv_rwlock_t* rwlock) {
- return -pthread_rwlock_init(rwlock, NULL);
+ return UV__ERR(pthread_rwlock_init(rwlock, NULL));
}
@@ -174,7 +369,7 @@ int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock) {
if (err) {
if (err != EBUSY && err != EAGAIN)
abort();
- return -EBUSY;
+ return UV_EBUSY;
}
return 0;
@@ -200,7 +395,7 @@ int uv_rwlock_trywrlock(uv_rwlock_t* rwlock) {
if (err) {
if (err != EBUSY && err != EAGAIN)
abort();
- return -EBUSY;
+ return UV_EBUSY;
}
return 0;
@@ -227,12 +422,12 @@ int uv_sem_init(uv_sem_t* sem, unsigned int value) {
if (err == KERN_SUCCESS)
return 0;
if (err == KERN_INVALID_ARGUMENT)
- return -EINVAL;
+ return UV_EINVAL;
if (err == KERN_RESOURCE_SHORTAGE)
- return -ENOMEM;
+ return UV_ENOMEM;
abort();
- return -EINVAL; /* Satisfy the compiler. */
+ return UV_EINVAL; /* Satisfy the compiler. */
}
@@ -271,113 +466,151 @@ int uv_sem_trywait(uv_sem_t* sem) {
if (err == KERN_SUCCESS)
return 0;
if (err == KERN_OPERATION_TIMED_OUT)
- return -EAGAIN;
+ return UV_EAGAIN;
abort();
- return -EINVAL; /* Satisfy the compiler. */
+ return UV_EINVAL; /* Satisfy the compiler. */
+}
+
+#else /* !(defined(__APPLE__) && defined(__MACH__)) */
+
+#ifdef __GLIBC__
+
+/* Hack around https://sourceware.org/bugzilla/show_bug.cgi?id=12674
+ * by providing a custom implementation for glibc < 2.21 in terms of other
+ * concurrency primitives.
+ * Refs: https://github.com/nodejs/node/issues/19903 */
+
+/* To preserve ABI compatibility, we treat the uv_sem_t as storage for
+ * a pointer to the actual struct we're using underneath. */
+
+static uv_once_t glibc_version_check_once = UV_ONCE_INIT;
+static int platform_needs_custom_semaphore = 0;
+
+static void glibc_version_check(void) {
+ const char* version = gnu_get_libc_version();
+ platform_needs_custom_semaphore =
+ version[0] == '2' && version[1] == '.' &&
+ atoi(version + 2) < 21;
}
#elif defined(__MVS__)
-int uv_sem_init(uv_sem_t* sem, unsigned int value) {
- uv_sem_t semid;
- struct sembuf buf;
+#define platform_needs_custom_semaphore 1
+
+#else /* !defined(__GLIBC__) && !defined(__MVS__) */
+
+#define platform_needs_custom_semaphore 0
+
+#endif
+
+typedef struct uv_semaphore_s {
+ uv_mutex_t mutex;
+ uv_cond_t cond;
+ unsigned int value;
+} uv_semaphore_t;
+
+#if defined(__GLIBC__) || platform_needs_custom_semaphore
+STATIC_ASSERT(sizeof(uv_sem_t) >= sizeof(uv_semaphore_t*));
+#endif
+
+static int uv__custom_sem_init(uv_sem_t* sem_, unsigned int value) {
int err;
+ uv_semaphore_t* sem;
- buf.sem_num = 0;
- buf.sem_op = value;
- buf.sem_flg = 0;
+ sem = uv__malloc(sizeof(*sem));
+ if (sem == NULL)
+ return UV_ENOMEM;
- semid = semget(IPC_PRIVATE, 1, S_IRUSR | S_IWUSR);
- if (semid == -1)
- return -errno;
+ if ((err = uv_mutex_init(&sem->mutex)) != 0) {
+ uv__free(sem);
+ return err;
+ }
- if (-1 == semop(semid, &buf, 1)) {
- err = errno;
- if (-1 == semctl(*sem, 0, IPC_RMID))
- abort();
- return -err;
+ if ((err = uv_cond_init(&sem->cond)) != 0) {
+ uv_mutex_destroy(&sem->mutex);
+ uv__free(sem);
+ return err;
}
- *sem = semid;
+ sem->value = value;
+ *(uv_semaphore_t**)sem_ = sem;
return 0;
}
-void uv_sem_destroy(uv_sem_t* sem) {
- if (-1 == semctl(*sem, 0, IPC_RMID))
- abort();
+
+static void uv__custom_sem_destroy(uv_sem_t* sem_) {
+ uv_semaphore_t* sem;
+
+ sem = *(uv_semaphore_t**)sem_;
+ uv_cond_destroy(&sem->cond);
+ uv_mutex_destroy(&sem->mutex);
+ uv__free(sem);
}
-void uv_sem_post(uv_sem_t* sem) {
- struct sembuf buf;
- buf.sem_num = 0;
- buf.sem_op = 1;
- buf.sem_flg = 0;
+static void uv__custom_sem_post(uv_sem_t* sem_) {
+ uv_semaphore_t* sem;
- if (-1 == semop(*sem, &buf, 1))
- abort();
+ sem = *(uv_semaphore_t**)sem_;
+ uv_mutex_lock(&sem->mutex);
+ sem->value++;
+ if (sem->value == 1)
+ uv_cond_signal(&sem->cond);
+ uv_mutex_unlock(&sem->mutex);
}
-void uv_sem_wait(uv_sem_t* sem) {
- struct sembuf buf;
- int op_status;
- buf.sem_num = 0;
- buf.sem_op = -1;
- buf.sem_flg = 0;
+static void uv__custom_sem_wait(uv_sem_t* sem_) {
+ uv_semaphore_t* sem;
- do
- op_status = semop(*sem, &buf, 1);
- while (op_status == -1 && errno == EINTR);
-
- if (op_status)
- abort();
+ sem = *(uv_semaphore_t**)sem_;
+ uv_mutex_lock(&sem->mutex);
+ while (sem->value == 0)
+ uv_cond_wait(&sem->cond, &sem->mutex);
+ sem->value--;
+ uv_mutex_unlock(&sem->mutex);
}
-int uv_sem_trywait(uv_sem_t* sem) {
- struct sembuf buf;
- int op_status;
- buf.sem_num = 0;
- buf.sem_op = -1;
- buf.sem_flg = IPC_NOWAIT;
+static int uv__custom_sem_trywait(uv_sem_t* sem_) {
+ uv_semaphore_t* sem;
- do
- op_status = semop(*sem, &buf, 1);
- while (op_status == -1 && errno == EINTR);
+ sem = *(uv_semaphore_t**)sem_;
+ if (uv_mutex_trylock(&sem->mutex) != 0)
+ return UV_EAGAIN;
- if (op_status) {
- if (errno == EAGAIN)
- return -EAGAIN;
- abort();
+ if (sem->value == 0) {
+ uv_mutex_unlock(&sem->mutex);
+ return UV_EAGAIN;
}
+ sem->value--;
+ uv_mutex_unlock(&sem->mutex);
+
return 0;
}
-#else /* !(defined(__APPLE__) && defined(__MACH__)) */
-
-int uv_sem_init(uv_sem_t* sem, unsigned int value) {
+static int uv__sem_init(uv_sem_t* sem, unsigned int value) {
if (sem_init(sem, 0, value))
- return -errno;
+ return UV__ERR(errno);
return 0;
}
-void uv_sem_destroy(uv_sem_t* sem) {
+static void uv__sem_destroy(uv_sem_t* sem) {
if (sem_destroy(sem))
abort();
}
-void uv_sem_post(uv_sem_t* sem) {
+static void uv__sem_post(uv_sem_t* sem) {
if (sem_post(sem))
abort();
}
-void uv_sem_wait(uv_sem_t* sem) {
+static void uv__sem_wait(uv_sem_t* sem) {
int r;
do
@@ -389,7 +622,7 @@ void uv_sem_wait(uv_sem_t* sem) {
}
-int uv_sem_trywait(uv_sem_t* sem) {
+static int uv__sem_trywait(uv_sem_t* sem) {
int r;
do
@@ -398,20 +631,63 @@ int uv_sem_trywait(uv_sem_t* sem) {
if (r) {
if (errno == EAGAIN)
- return -EAGAIN;
+ return UV_EAGAIN;
abort();
}
return 0;
}
+int uv_sem_init(uv_sem_t* sem, unsigned int value) {
+#ifdef __GLIBC__
+ uv_once(&glibc_version_check_once, glibc_version_check);
+#endif
+
+ if (platform_needs_custom_semaphore)
+ return uv__custom_sem_init(sem, value);
+ else
+ return uv__sem_init(sem, value);
+}
+
+
+void uv_sem_destroy(uv_sem_t* sem) {
+ if (platform_needs_custom_semaphore)
+ uv__custom_sem_destroy(sem);
+ else
+ uv__sem_destroy(sem);
+}
+
+
+void uv_sem_post(uv_sem_t* sem) {
+ if (platform_needs_custom_semaphore)
+ uv__custom_sem_post(sem);
+ else
+ uv__sem_post(sem);
+}
+
+
+void uv_sem_wait(uv_sem_t* sem) {
+ if (platform_needs_custom_semaphore)
+ uv__custom_sem_wait(sem);
+ else
+ uv__sem_wait(sem);
+}
+
+
+int uv_sem_trywait(uv_sem_t* sem) {
+ if (platform_needs_custom_semaphore)
+ return uv__custom_sem_trywait(sem);
+ else
+ return uv__sem_trywait(sem);
+}
+
#endif /* defined(__APPLE__) && defined(__MACH__) */
#if defined(__APPLE__) && defined(__MACH__) || defined(__MVS__)
int uv_cond_init(uv_cond_t* cond) {
- return -pthread_cond_init(cond, NULL);
+ return UV__ERR(pthread_cond_init(cond, NULL));
}
#else /* !(defined(__APPLE__) && defined(__MACH__)) */
@@ -422,9 +698,9 @@ int uv_cond_init(uv_cond_t* cond) {
err = pthread_condattr_init(&attr);
if (err)
- return -err;
+ return UV__ERR(err);
-#if !(defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC))
+#if !(defined(__ANDROID_API__) && __ANDROID_API__ < 21) && !defined(__hpux)
err = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
if (err)
goto error2;
@@ -444,7 +720,7 @@ error:
pthread_cond_destroy(cond);
error2:
pthread_condattr_destroy(&attr);
- return -err;
+ return UV__ERR(err);
}
#endif /* defined(__APPLE__) && defined(__MACH__) */
@@ -502,16 +778,26 @@ void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
int r;
struct timespec ts;
+#if defined(__MVS__)
+ struct timeval tv;
+#endif
#if defined(__APPLE__) && defined(__MACH__)
ts.tv_sec = timeout / NANOSEC;
ts.tv_nsec = timeout % NANOSEC;
r = pthread_cond_timedwait_relative_np(cond, mutex, &ts);
#else
+#if defined(__MVS__)
+ if (gettimeofday(&tv, NULL))
+ abort();
+ timeout += tv.tv_sec * NANOSEC + tv.tv_usec * 1e3;
+#else
timeout += uv__hrtime(UV_CLOCK_PRECISE);
+#endif
ts.tv_sec = timeout / NANOSEC;
ts.tv_nsec = timeout % NANOSEC;
-#if defined(__ANDROID__) && defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
+#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
+
/*
* The bionic pthread implementation doesn't support CLOCK_MONOTONIC,
* but has this alternative function instead.
@@ -519,7 +805,7 @@ int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
r = pthread_cond_timedwait_monotonic_np(cond, mutex, &ts);
#else
r = pthread_cond_timedwait(cond, mutex, &ts);
-#endif /* __ANDROID__ */
+#endif /* __ANDROID_API__ */
#endif
@@ -527,34 +813,17 @@ int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
return 0;
if (r == ETIMEDOUT)
- return -ETIMEDOUT;
+ return UV_ETIMEDOUT;
abort();
- return -EINVAL; /* Satisfy the compiler. */
-}
-
-
-int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) {
- return -pthread_barrier_init(barrier, NULL, count);
-}
-
-
-void uv_barrier_destroy(uv_barrier_t* barrier) {
- if (pthread_barrier_destroy(barrier))
- abort();
-}
-
-
-int uv_barrier_wait(uv_barrier_t* barrier) {
- int r = pthread_barrier_wait(barrier);
- if (r && r != PTHREAD_BARRIER_SERIAL_THREAD)
- abort();
- return r == PTHREAD_BARRIER_SERIAL_THREAD;
+#ifndef __SUNPRO_C
+ return UV_EINVAL; /* Satisfy the compiler. */
+#endif
}
int uv_key_create(uv_key_t* key) {
- return -pthread_key_create(key, NULL);
+ return UV__ERR(pthread_key_create(key, NULL));
}
diff --git a/Utilities/cmlibuv/src/unix/timer.c b/Utilities/cmlibuv/src/unix/timer.c
deleted file mode 100644
index f46bdf4bf..000000000
--- a/Utilities/cmlibuv/src/unix/timer.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#include "uv.h"
-#include "internal.h"
-#include "heap-inl.h"
-
-#include <assert.h>
-#include <limits.h>
-
-
-static int timer_less_than(const struct heap_node* ha,
- const struct heap_node* hb) {
- const uv_timer_t* a;
- const uv_timer_t* b;
-
- a = container_of(ha, uv_timer_t, heap_node);
- b = container_of(hb, uv_timer_t, heap_node);
-
- if (a->timeout < b->timeout)
- return 1;
- if (b->timeout < a->timeout)
- return 0;
-
- /* Compare start_id when both have the same timeout. start_id is
- * allocated with loop->timer_counter in uv_timer_start().
- */
- if (a->start_id < b->start_id)
- return 1;
- if (b->start_id < a->start_id)
- return 0;
-
- return 0;
-}
-
-
-int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) {
- uv__handle_init(loop, (uv_handle_t*)handle, UV_TIMER);
- handle->timer_cb = NULL;
- handle->repeat = 0;
- return 0;
-}
-
-
-int uv_timer_start(uv_timer_t* handle,
- uv_timer_cb cb,
- uint64_t timeout,
- uint64_t repeat) {
- uint64_t clamped_timeout;
-
- if (cb == NULL)
- return -EINVAL;
-
- if (uv__is_active(handle))
- uv_timer_stop(handle);
-
- clamped_timeout = handle->loop->time + timeout;
- if (clamped_timeout < timeout)
- clamped_timeout = (uint64_t) -1;
-
- handle->timer_cb = cb;
- handle->timeout = clamped_timeout;
- handle->repeat = repeat;
- /* start_id is the second index to be compared in uv__timer_cmp() */
- handle->start_id = handle->loop->timer_counter++;
-
- heap_insert((struct heap*) &handle->loop->timer_heap,
- (struct heap_node*) &handle->heap_node,
- timer_less_than);
- uv__handle_start(handle);
-
- return 0;
-}
-
-
-int uv_timer_stop(uv_timer_t* handle) {
- if (!uv__is_active(handle))
- return 0;
-
- heap_remove((struct heap*) &handle->loop->timer_heap,
- (struct heap_node*) &handle->heap_node,
- timer_less_than);
- uv__handle_stop(handle);
-
- return 0;
-}
-
-
-int uv_timer_again(uv_timer_t* handle) {
- if (handle->timer_cb == NULL)
- return -EINVAL;
-
- if (handle->repeat) {
- uv_timer_stop(handle);
- uv_timer_start(handle, handle->timer_cb, handle->repeat, handle->repeat);
- }
-
- return 0;
-}
-
-
-void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat) {
- handle->repeat = repeat;
-}
-
-
-uint64_t uv_timer_get_repeat(const uv_timer_t* handle) {
- return handle->repeat;
-}
-
-
-int uv__next_timeout(const uv_loop_t* loop) {
- const struct heap_node* heap_node;
- const uv_timer_t* handle;
- uint64_t diff;
-
- heap_node = heap_min((const struct heap*) &loop->timer_heap);
- if (heap_node == NULL)
- return -1; /* block indefinitely */
-
- handle = container_of(heap_node, uv_timer_t, heap_node);
- if (handle->timeout <= loop->time)
- return 0;
-
- diff = handle->timeout - loop->time;
- if (diff > INT_MAX)
- diff = INT_MAX;
-
- return diff;
-}
-
-
-void uv__run_timers(uv_loop_t* loop) {
- struct heap_node* heap_node;
- uv_timer_t* handle;
-
- for (;;) {
- heap_node = heap_min((struct heap*) &loop->timer_heap);
- if (heap_node == NULL)
- break;
-
- handle = container_of(heap_node, uv_timer_t, heap_node);
- if (handle->timeout > loop->time)
- break;
-
- uv_timer_stop(handle);
- uv_timer_again(handle);
- handle->timer_cb(handle);
- }
-}
-
-
-void uv__timer_close(uv_timer_t* handle) {
- uv_timer_stop(handle);
-}
diff --git a/Utilities/cmlibuv/src/unix/tty.c b/Utilities/cmlibuv/src/unix/tty.c
index ae1018fc4..db479d61b 100644
--- a/Utilities/cmlibuv/src/unix/tty.c
+++ b/Utilities/cmlibuv/src/unix/tty.c
@@ -48,6 +48,42 @@ static int uv__tty_is_slave(const int fd) {
char dummy[256];
result = ioctl(fd, TIOCPTYGNAME, &dummy) != 0;
+#elif defined(__NetBSD__)
+ /*
+ * NetBSD as an extension returns with ptsname(3) and ptsname_r(3) the slave
+ * device name for both descriptors, the master one and slave one.
+ *
+ * Implement function to compare major device number with pts devices.
+ *
+ * The major numbers are machine-dependent, on NetBSD/amd64 they are
+ * respectively:
+ * - master tty: ptc - major 6
+ * - slave tty: pts - major 5
+ */
+
+ struct stat sb;
+ /* Lookup device's major for the pts driver and cache it. */
+ static devmajor_t pts = NODEVMAJOR;
+
+ if (pts == NODEVMAJOR) {
+ pts = getdevmajor("pts", S_IFCHR);
+ if (pts == NODEVMAJOR)
+ abort();
+ }
+
+ /* Lookup stat structure behind the file descriptor. */
+ if (fstat(fd, &sb) != 0)
+ abort();
+
+ /* Assert character device. */
+ if (!S_ISCHR(sb.st_mode))
+ abort();
+
+ /* Assert valid major. */
+ if (major(sb.st_rdev) == NODEVMAJOR)
+ abort();
+
+ result = (pts == major(sb.st_rdev));
#else
/* Fallback to ptsname
*/
@@ -56,13 +92,15 @@ static int uv__tty_is_slave(const int fd) {
return result;
}
-int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) {
+int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int unused) {
uv_handle_type type;
int flags = 0;
int newfd = -1;
int r;
int saved_flags;
+ int mode;
char path[256];
+ (void)unused; /* deprecated parameter is no longer needed */
/* File descriptors that refer to files cannot be monitored with epoll.
* That restriction also applies to character devices like /dev/random
@@ -70,7 +108,16 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) {
*/
type = uv_guess_handle(fd);
if (type == UV_FILE || type == UV_UNKNOWN_HANDLE)
- return -EINVAL;
+ return UV_EINVAL;
+
+ /* Save the fd flags in case we need to restore them due to an error. */
+ do
+ saved_flags = fcntl(fd, F_GETFL);
+ while (saved_flags == -1 && errno == EINTR);
+
+ if (saved_flags == -1)
+ return UV__ERR(errno);
+ mode = saved_flags & O_ACCMODE;
/* Reopen the file descriptor when it refers to a tty. This lets us put the
* tty in non-blocking mode without affecting other processes that share it
@@ -89,21 +136,21 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) {
* slave device.
*/
if (uv__tty_is_slave(fd) && ttyname_r(fd, path, sizeof(path)) == 0)
- r = uv__open_cloexec(path, O_RDWR);
+ r = uv__open_cloexec(path, mode);
else
r = -1;
if (r < 0) {
/* fallback to using blocking writes */
- if (!readable)
- flags |= UV_STREAM_BLOCKING;
+ if (mode != O_RDONLY)
+ flags |= UV_HANDLE_BLOCKING_WRITES;
goto skip;
}
newfd = r;
r = uv__dup2_cloexec(newfd, fd);
- if (r < 0 && r != -EINVAL) {
+ if (r < 0 && r != UV_EINVAL) {
/* EINVAL means newfd == fd which could conceivably happen if another
* thread called close(fd) between our calls to isatty() and open().
* That's a rather unlikely event but let's handle it anyway.
@@ -115,22 +162,6 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, int fd, int readable) {
fd = newfd;
}
-#if defined(__APPLE__)
- /* Save the fd flags in case we need to restore them due to an error. */
- do
- saved_flags = fcntl(fd, F_GETFL);
- while (saved_flags == -1 && errno == EINTR);
-
- if (saved_flags == -1) {
- if (newfd != -1)
- uv__close(newfd);
- return -errno;
- }
-#endif
-
- /* Pacify the compiler. */
- (void) &saved_flags;
-
skip:
uv__stream_init(loop, (uv_stream_t*) tty, UV_TTY);
@@ -138,7 +169,7 @@ skip:
* the handle queue, since it was added by uv__handle_init in uv_stream_init.
*/
- if (!(flags & UV_STREAM_BLOCKING))
+ if (!(flags & UV_HANDLE_BLOCKING_WRITES))
uv__nonblock(fd, 1);
#if defined(__APPLE__)
@@ -155,10 +186,10 @@ skip:
}
#endif
- if (readable)
- flags |= UV_STREAM_READABLE;
- else
- flags |= UV_STREAM_WRITABLE;
+ if (mode != O_WRONLY)
+ flags |= UV_HANDLE_READABLE;
+ if (mode != O_RDONLY)
+ flags |= UV_HANDLE_WRITABLE;
uv__stream_open((uv_stream_t*) tty, fd, flags);
tty->mode = UV_TTY_MODE_NORMAL;
@@ -169,7 +200,7 @@ skip:
static void uv__tty_make_raw(struct termios* tio) {
assert(tio != NULL);
-#if defined __sun || defined __MVS__
+#if defined __sun || defined __MVS__ || defined __hpux
/*
* This implementation of cfmakeraw for Solaris and derivatives is taken from
* http://www.perkin.org.uk/posts/solaris-portability-cfmakeraw.html.
@@ -195,7 +226,7 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) {
fd = uv__stream_fd(tty);
if (tty->mode == UV_TTY_MODE_NORMAL && mode != UV_TTY_MODE_NORMAL) {
if (tcgetattr(fd, &tty->orig_termios))
- return -errno;
+ return UV__ERR(errno);
/* This is used for uv_tty_reset_mode() */
uv_spinlock_lock(&termios_spinlock);
@@ -225,7 +256,7 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) {
/* Apply changes after draining */
if (tcsetattr(fd, TCSADRAIN, &tmp))
- return -errno;
+ return UV__ERR(errno);
tty->mode = mode;
return 0;
@@ -241,7 +272,7 @@ int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) {
while (err == -1 && errno == EINTR);
if (err == -1)
- return -errno;
+ return UV__ERR(errno);
*width = ws.ws_col;
*height = ws.ws_row;
@@ -319,12 +350,12 @@ int uv_tty_reset_mode(void) {
saved_errno = errno;
if (!uv_spinlock_trylock(&termios_spinlock))
- return -EBUSY; /* In uv_tty_set_mode(). */
+ return UV_EBUSY; /* In uv_tty_set_mode(). */
err = 0;
if (orig_termios_fd != -1)
if (tcsetattr(orig_termios_fd, TCSANOW, &orig_termios))
- err = -errno;
+ err = UV__ERR(errno);
uv_spinlock_unlock(&termios_spinlock);
errno = saved_errno;
diff --git a/Utilities/cmlibuv/src/unix/udp.c b/Utilities/cmlibuv/src/unix/udp.c
index c556325de..b578e7bc1 100644
--- a/Utilities/cmlibuv/src/unix/udp.c
+++ b/Utilities/cmlibuv/src/unix/udp.c
@@ -30,6 +30,7 @@
#if defined(__MVS__)
#include <xti.h>
#endif
+#include <sys/un.h>
#if defined(IPV6_JOIN_GROUP) && !defined(IPV6_ADD_MEMBERSHIP)
# define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
@@ -72,7 +73,7 @@ void uv__udp_finish_close(uv_udp_t* handle) {
QUEUE_REMOVE(q);
req = QUEUE_DATA(q, uv_udp_send_t, queue);
- req->status = -ECANCELED;
+ req->status = UV_ECANCELED;
QUEUE_INSERT_TAIL(&handle->write_completed_queue, &req->queue);
}
@@ -92,8 +93,8 @@ static void uv__udp_run_completed(uv_udp_t* handle) {
uv_udp_send_t* req;
QUEUE* q;
- assert(!(handle->flags & UV_UDP_PROCESSING));
- handle->flags |= UV_UDP_PROCESSING;
+ assert(!(handle->flags & UV_HANDLE_UDP_PROCESSING));
+ handle->flags |= UV_HANDLE_UDP_PROCESSING;
while (!QUEUE_EMPTY(&handle->write_completed_queue)) {
q = QUEUE_HEAD(&handle->write_completed_queue);
@@ -128,7 +129,7 @@ static void uv__udp_run_completed(uv_udp_t* handle) {
uv__handle_stop(handle);
}
- handle->flags &= ~UV_UDP_PROCESSING;
+ handle->flags &= ~UV_HANDLE_UDP_PROCESSING;
}
@@ -189,7 +190,7 @@ static void uv__udp_recvmsg(uv_udp_t* handle) {
if (errno == EAGAIN || errno == EWOULDBLOCK)
handle->recv_cb(handle, 0, &buf, NULL, 0);
else
- handle->recv_cb(handle, -errno, &buf, NULL, 0);
+ handle->recv_cb(handle, UV__ERR(errno), &buf, NULL, 0);
}
else {
const struct sockaddr *addr;
@@ -227,9 +228,22 @@ static void uv__udp_sendmsg(uv_udp_t* handle) {
assert(req != NULL);
memset(&h, 0, sizeof h);
- h.msg_name = &req->addr;
- h.msg_namelen = (req->addr.ss_family == AF_INET6 ?
- sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in));
+ if (req->addr.ss_family == AF_UNSPEC) {
+ h.msg_name = NULL;
+ h.msg_namelen = 0;
+ } else {
+ h.msg_name = &req->addr;
+ if (req->addr.ss_family == AF_INET6)
+ h.msg_namelen = sizeof(struct sockaddr_in6);
+ else if (req->addr.ss_family == AF_INET)
+ h.msg_namelen = sizeof(struct sockaddr_in);
+ else if (req->addr.ss_family == AF_UNIX)
+ h.msg_namelen = sizeof(struct sockaddr_un);
+ else {
+ assert(0 && "unsupported address family");
+ abort();
+ }
+ }
h.msg_iov = (struct iovec*) req->bufs;
h.msg_iovlen = req->nbufs;
@@ -237,10 +251,12 @@ static void uv__udp_sendmsg(uv_udp_t* handle) {
size = sendmsg(handle->io_watcher.fd, &h, 0);
} while (size == -1 && errno == EINTR);
- if (size == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
- break;
+ if (size == -1) {
+ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS)
+ break;
+ }
- req->status = (size == -1 ? -errno : size);
+ req->status = (size == -1 ? UV__ERR(errno) : size);
/* Sending a datagram is an atomic operation: either all data
* is written or nothing is (and EMSGSIZE is raised). That is
@@ -261,18 +277,32 @@ static void uv__udp_sendmsg(uv_udp_t* handle) {
* are different from the BSDs: it _shares_ the port rather than steal it
* from the current listener. While useful, it's not something we can emulate
* on other platforms so we don't enable it.
+ *
+ * zOS does not support getsockname with SO_REUSEPORT option when using
+ * AF_UNIX.
*/
static int uv__set_reuse(int fd) {
int yes;
-
-#if defined(SO_REUSEPORT) && !defined(__linux__)
yes = 1;
+
+#if defined(SO_REUSEPORT) && defined(__MVS__)
+ struct sockaddr_in sockfd;
+ unsigned int sockfd_len = sizeof(sockfd);
+ if (getsockname(fd, (struct sockaddr*) &sockfd, &sockfd_len) == -1)
+ return UV__ERR(errno);
+ if (sockfd.sin_family == AF_UNIX) {
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)))
+ return UV__ERR(errno);
+ } else {
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)))
+ return UV__ERR(errno);
+ }
+#elif defined(SO_REUSEPORT) && !defined(__linux__)
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes)))
- return -errno;
+ return UV__ERR(errno);
#else
- yes = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)))
- return -errno;
+ return UV__ERR(errno);
#endif
return 0;
@@ -289,11 +319,11 @@ int uv__udp_bind(uv_udp_t* handle,
/* Check for bad flags. */
if (flags & ~(UV_UDP_IPV6ONLY | UV_UDP_REUSEADDR))
- return -EINVAL;
+ return UV_EINVAL;
/* Cannot set IPv6-only mode on non-IPv6 socket. */
if ((flags & UV_UDP_IPV6ONLY) && addr->sa_family != AF_INET6)
- return -EINVAL;
+ return UV_EINVAL;
fd = handle->io_watcher.fd;
if (fd == -1) {
@@ -314,21 +344,21 @@ int uv__udp_bind(uv_udp_t* handle,
#ifdef IPV6_V6ONLY
yes = 1;
if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &yes, sizeof yes) == -1) {
- err = -errno;
+ err = UV__ERR(errno);
return err;
}
#else
- err = -ENOTSUP;
+ err = UV_ENOTSUP;
return err;
#endif
}
if (bind(fd, addr, addrlen)) {
- err = -errno;
+ err = UV__ERR(errno);
if (errno == EAFNOSUPPORT)
/* OSX, other BSDs and SunoS fail with EAFNOSUPPORT when binding a
* socket created with AF_INET to an AF_INET6 address or vice versa. */
- err = -EINVAL;
+ err = UV_EINVAL;
return err;
}
@@ -381,6 +411,50 @@ static int uv__udp_maybe_deferred_bind(uv_udp_t* handle,
}
+int uv__udp_connect(uv_udp_t* handle,
+ const struct sockaddr* addr,
+ unsigned int addrlen) {
+ int err;
+
+ err = uv__udp_maybe_deferred_bind(handle, addr->sa_family, 0);
+ if (err)
+ return err;
+
+ do {
+ errno = 0;
+ err = connect(handle->io_watcher.fd, addr, addrlen);
+ } while (err == -1 && errno == EINTR);
+
+ if (err)
+ return UV__ERR(errno);
+
+ handle->flags |= UV_HANDLE_UDP_CONNECTED;
+
+ return 0;
+}
+
+
+int uv__udp_disconnect(uv_udp_t* handle) {
+ int r;
+ struct sockaddr addr;
+
+ memset(&addr, 0, sizeof(addr));
+
+ addr.sa_family = AF_UNSPEC;
+
+ do {
+ errno = 0;
+ r = connect(handle->io_watcher.fd, &addr, sizeof(addr));
+ } while (r == -1 && errno == EINTR);
+
+ if (r == -1 && errno != EAFNOSUPPORT)
+ return UV__ERR(errno);
+
+ handle->flags &= ~UV_HANDLE_UDP_CONNECTED;
+ return 0;
+}
+
+
int uv__udp_send(uv_udp_send_t* req,
uv_udp_t* handle,
const uv_buf_t bufs[],
@@ -393,9 +467,11 @@ int uv__udp_send(uv_udp_send_t* req,
assert(nbufs > 0);
- err = uv__udp_maybe_deferred_bind(handle, addr->sa_family, 0);
- if (err)
- return err;
+ if (addr) {
+ err = uv__udp_maybe_deferred_bind(handle, addr->sa_family, 0);
+ if (err)
+ return err;
+ }
/* It's legal for send_queue_count > 0 even when the write_queue is empty;
* it means there are error-state requests in the write_completed_queue that
@@ -405,7 +481,10 @@ int uv__udp_send(uv_udp_send_t* req,
uv__req_init(handle->loop, req, UV_UDP_SEND);
assert(addrlen <= sizeof(req->addr));
- memcpy(&req->addr, addr, addrlen);
+ if (addr == NULL)
+ req->addr.ss_family = AF_UNSPEC;
+ else
+ memcpy(&req->addr, addr, addrlen);
req->send_cb = send_cb;
req->handle = handle;
req->nbufs = nbufs;
@@ -416,7 +495,7 @@ int uv__udp_send(uv_udp_send_t* req,
if (req->bufs == NULL) {
uv__req_unregister(handle->loop, req);
- return -ENOMEM;
+ return UV_ENOMEM;
}
memcpy(req->bufs, bufs, nbufs * sizeof(bufs[0]));
@@ -425,7 +504,7 @@ int uv__udp_send(uv_udp_send_t* req,
QUEUE_INSERT_TAIL(&handle->write_queue, &req->queue);
uv__handle_start(handle);
- if (empty_queue && !(handle->flags & UV_UDP_PROCESSING)) {
+ if (empty_queue && !(handle->flags & UV_HANDLE_UDP_PROCESSING)) {
uv__udp_sendmsg(handle);
/* `uv__udp_sendmsg` may not be able to do non-blocking write straight
@@ -455,11 +534,15 @@ int uv__udp_try_send(uv_udp_t* handle,
/* already sending a message */
if (handle->send_queue_count != 0)
- return -EAGAIN;
+ return UV_EAGAIN;
- err = uv__udp_maybe_deferred_bind(handle, addr->sa_family, 0);
- if (err)
- return err;
+ if (addr) {
+ err = uv__udp_maybe_deferred_bind(handle, addr->sa_family, 0);
+ if (err)
+ return err;
+ } else {
+ assert(handle->flags & UV_HANDLE_UDP_CONNECTED);
+ }
memset(&h, 0, sizeof h);
h.msg_name = (struct sockaddr*) addr;
@@ -472,10 +555,10 @@ int uv__udp_try_send(uv_udp_t* handle,
} while (size == -1 && errno == EINTR);
if (size == -1) {
- if (errno == EAGAIN || errno == EWOULDBLOCK)
- return -EAGAIN;
+ if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS)
+ return UV_EAGAIN;
else
- return -errno;
+ return UV__ERR(errno);
}
return size;
@@ -510,7 +593,7 @@ static int uv__udp_set_membership4(uv_udp_t* handle,
optname = IP_DROP_MEMBERSHIP;
break;
default:
- return -EINVAL;
+ return UV_EINVAL;
}
if (setsockopt(handle->io_watcher.fd,
@@ -520,9 +603,9 @@ static int uv__udp_set_membership4(uv_udp_t* handle,
sizeof(mreq))) {
#if defined(__MVS__)
if (errno == ENXIO)
- return -ENODEV;
+ return UV_ENODEV;
#endif
- return -errno;
+ return UV__ERR(errno);
}
return 0;
@@ -541,7 +624,7 @@ static int uv__udp_set_membership6(uv_udp_t* handle,
if (interface_addr) {
if (uv_ip6_addr(interface_addr, 0, &addr6))
- return -EINVAL;
+ return UV_EINVAL;
mreq.ipv6mr_interface = addr6.sin6_scope_id;
} else {
mreq.ipv6mr_interface = 0;
@@ -557,7 +640,7 @@ static int uv__udp_set_membership6(uv_udp_t* handle,
optname = IPV6_DROP_MEMBERSHIP;
break;
default:
- return -EINVAL;
+ return UV_EINVAL;
}
if (setsockopt(handle->io_watcher.fd,
@@ -567,9 +650,9 @@ static int uv__udp_set_membership6(uv_udp_t* handle,
sizeof(mreq))) {
#if defined(__MVS__)
if (errno == ENXIO)
- return -ENODEV;
+ return UV_ENODEV;
#endif
- return -errno;
+ return UV__ERR(errno);
}
return 0;
@@ -584,10 +667,10 @@ int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) {
/* Use the lower 8 bits for the domain */
domain = flags & 0xFF;
if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC)
- return -EINVAL;
+ return UV_EINVAL;
if (flags & ~0xFF)
- return -EINVAL;
+ return UV_EINVAL;
if (domain != AF_UNSPEC) {
err = uv__socket(domain, SOCK_DGRAM, 0);
@@ -606,6 +689,7 @@ int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) {
uv__io_init(&handle->io_watcher, uv__udp_io, fd);
QUEUE_INIT(&handle->write_queue);
QUEUE_INIT(&handle->write_completed_queue);
+
return 0;
}
@@ -620,7 +704,10 @@ int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) {
/* Check for already active socket. */
if (handle->io_watcher.fd != -1)
- return -EBUSY;
+ return UV_EBUSY;
+
+ if (uv__fd_exists(handle->loop, sock))
+ return UV_EEXIST;
err = uv__nonblock(sock, 1);
if (err)
@@ -631,6 +718,9 @@ int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) {
return err;
handle->io_watcher.fd = sock;
+ if (uv__udp_is_connected(handle))
+ handle->flags |= UV_HANDLE_UDP_CONNECTED;
+
return 0;
}
@@ -654,7 +744,7 @@ int uv_udp_set_membership(uv_udp_t* handle,
return err;
return uv__udp_set_membership6(handle, &addr6, interface_addr, membership);
} else {
- return -EINVAL;
+ return UV_EINVAL;
}
}
@@ -678,7 +768,7 @@ static int uv__setsockopt(uv_udp_t* handle,
val,
size);
if (r)
- return -errno;
+ return UV__ERR(errno);
return 0;
}
@@ -696,7 +786,7 @@ static int uv__setsockopt_maybe_char(uv_udp_t* handle,
#endif
if (val < 0 || val > 255)
- return -EINVAL;
+ return UV_EINVAL;
return uv__setsockopt(handle, option4, option6, &arg, sizeof(arg));
}
@@ -708,7 +798,7 @@ int uv_udp_set_broadcast(uv_udp_t* handle, int on) {
SO_BROADCAST,
&on,
sizeof(on))) {
- return -errno;
+ return UV__ERR(errno);
}
return 0;
@@ -717,11 +807,11 @@ int uv_udp_set_broadcast(uv_udp_t* handle, int on) {
int uv_udp_set_ttl(uv_udp_t* handle, int ttl) {
if (ttl < 1 || ttl > 255)
- return -EINVAL;
+ return UV_EINVAL;
#if defined(__MVS__)
if (!(handle->flags & UV_HANDLE_IPV6))
- return -ENOTSUP; /* zOS does not support setting ttl for IPv4 */
+ return UV_ENOTSUP; /* zOS does not support setting ttl for IPv4 */
#endif
/*
@@ -738,13 +828,17 @@ int uv_udp_set_ttl(uv_udp_t* handle, int ttl) {
IPV6_UNICAST_HOPS,
&ttl,
sizeof(ttl));
-#endif /* defined(__sun) || defined(_AIX) || defined (__OpenBSD__) ||
- defined(__MVS__) */
+
+#else /* !(defined(__sun) || defined(_AIX) || defined (__OpenBSD__) ||
+ defined(__MVS__)) */
return uv__setsockopt_maybe_char(handle,
IP_TTL,
IPV6_UNICAST_HOPS,
ttl);
+
+#endif /* defined(__sun) || defined(_AIX) || defined (__OpenBSD__) ||
+ defined(__MVS__) */
}
@@ -755,14 +849,16 @@ int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl) {
* IP_MULTICAST_TTL, so hardcode the size of the option in the IPv6 case,
* and use the general uv__setsockopt_maybe_char call otherwise.
*/
-#if defined(__sun) || defined(_AIX) || defined(__MVS__)
+#if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \
+ defined(__MVS__)
if (handle->flags & UV_HANDLE_IPV6)
return uv__setsockopt(handle,
IP_MULTICAST_TTL,
IPV6_MULTICAST_HOPS,
&ttl,
sizeof(ttl));
-#endif /* defined(__sun) || defined(_AIX) || defined(__MVS__) */
+#endif /* defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \
+ defined(__MVS__) */
return uv__setsockopt_maybe_char(handle,
IP_MULTICAST_TTL,
@@ -778,14 +874,16 @@ int uv_udp_set_multicast_loop(uv_udp_t* handle, int on) {
* IP_MULTICAST_LOOP, so hardcode the size of the option in the IPv6 case,
* and use the general uv__setsockopt_maybe_char call otherwise.
*/
-#if defined(__sun) || defined(_AIX) || defined(__MVS__)
+#if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \
+ defined(__MVS__)
if (handle->flags & UV_HANDLE_IPV6)
return uv__setsockopt(handle,
IP_MULTICAST_LOOP,
IPV6_MULTICAST_LOOP,
&on,
sizeof(on));
-#endif /* defined(__sun) || defined(_AIX) || defined(__MVS__) */
+#endif /* defined(__sun) || defined(_AIX) ||defined(__OpenBSD__) ||
+ defined(__MVS__) */
return uv__setsockopt_maybe_char(handle,
IP_MULTICAST_LOOP,
@@ -815,7 +913,7 @@ int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr)
} else if (uv_ip6_addr(interface_addr, 0, addr6) == 0) {
/* nothing, address was parsed */
} else {
- return -EINVAL;
+ return UV_EINVAL;
}
if (addr_st.ss_family == AF_INET) {
@@ -824,7 +922,7 @@ int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr)
IP_MULTICAST_IF,
(void*) &addr4->sin_addr,
sizeof(addr4->sin_addr)) == -1) {
- return -errno;
+ return UV__ERR(errno);
}
} else if (addr_st.ss_family == AF_INET6) {
if (setsockopt(handle->io_watcher.fd,
@@ -832,7 +930,7 @@ int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr)
IPV6_MULTICAST_IF,
&addr6->sin6_scope_id,
sizeof(addr6->sin6_scope_id)) == -1) {
- return -errno;
+ return UV__ERR(errno);
}
} else {
assert(0 && "unexpected address family");
@@ -842,23 +940,24 @@ int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr)
return 0;
}
-
-int uv_udp_getsockname(const uv_udp_t* handle,
+int uv_udp_getpeername(const uv_udp_t* handle,
struct sockaddr* name,
int* namelen) {
- socklen_t socklen;
- if (handle->io_watcher.fd == -1)
- return -EINVAL; /* FIXME(bnoordhuis) -EBADF */
-
- /* sizeof(socklen_t) != sizeof(int) on some systems. */
- socklen = (socklen_t) *namelen;
+ return uv__getsockpeername((const uv_handle_t*) handle,
+ getpeername,
+ name,
+ namelen);
+}
- if (getsockname(handle->io_watcher.fd, name, &socklen))
- return -errno;
+int uv_udp_getsockname(const uv_udp_t* handle,
+ struct sockaddr* name,
+ int* namelen) {
- *namelen = (int) socklen;
- return 0;
+ return uv__getsockpeername((const uv_handle_t*) handle,
+ getsockname,
+ name,
+ namelen);
}
@@ -868,10 +967,10 @@ int uv__udp_recv_start(uv_udp_t* handle,
int err;
if (alloc_cb == NULL || recv_cb == NULL)
- return -EINVAL;
+ return UV_EINVAL;
if (uv__io_active(&handle->io_watcher, POLLIN))
- return -EALREADY; /* FIXME(bnoordhuis) Should be -EBUSY. */
+ return UV_EALREADY; /* FIXME(bnoordhuis) Should be UV_EBUSY. */
err = uv__udp_maybe_deferred_bind(handle, AF_INET, 0);
if (err)
diff --git a/Utilities/cmlibuv/src/uv-common.c b/Utilities/cmlibuv/src/uv-common.c
index bc7d1379d..f4853d60f 100644
--- a/Utilities/cmlibuv/src/uv-common.c
+++ b/Utilities/cmlibuv/src/uv-common.c
@@ -34,6 +34,7 @@
# include <malloc.h> /* malloc */
#else
# include <net/if.h> /* if_nametoindex */
+# include <sys/un.h> /* AF_UNIX, sockaddr_un */
#endif
@@ -72,7 +73,9 @@ char* uv__strndup(const char* s, size_t n) {
}
void* uv__malloc(size_t size) {
- return uv__allocator.local_malloc(size);
+ if (size > 0)
+ return uv__allocator.local_malloc(size);
+ return NULL;
}
void uv__free(void* ptr) {
@@ -91,7 +94,10 @@ void* uv__calloc(size_t count, size_t size) {
}
void* uv__realloc(void* ptr, size_t size) {
- return uv__allocator.local_realloc(ptr, size);
+ if (size > 0)
+ return uv__allocator.local_realloc(ptr, size);
+ uv__free(ptr);
+ return NULL;
}
int uv_replace_allocator(uv_malloc_func malloc_func,
@@ -155,6 +161,18 @@ static const char* uv__unknown_err_code(int err) {
return copy != NULL ? copy : "Unknown system error";
}
+#define UV_ERR_NAME_GEN_R(name, _) \
+case UV_## name: \
+ uv__strscpy(buf, #name, buflen); break;
+char* uv_err_name_r(int err, char* buf, size_t buflen) {
+ switch (err) {
+ UV_ERRNO_MAP(UV_ERR_NAME_GEN_R)
+ default: snprintf(buf, buflen, "Unknown system error %d", err);
+ }
+ return buf;
+}
+#undef UV_ERR_NAME_GEN_R
+
#define UV_ERR_NAME_GEN(name, _) case UV_ ## name: return #name;
const char* uv_err_name(int err) {
@@ -166,6 +184,19 @@ const char* uv_err_name(int err) {
#undef UV_ERR_NAME_GEN
+#define UV_STRERROR_GEN_R(name, msg) \
+case UV_ ## name: \
+ snprintf(buf, buflen, "%s", msg); break;
+char* uv_strerror_r(int err, char* buf, size_t buflen) {
+ switch (err) {
+ UV_ERRNO_MAP(UV_STRERROR_GEN_R)
+ default: snprintf(buf, buflen, "Unknown system error %d", err);
+ }
+ return buf;
+}
+#undef UV_STRERROR_GEN_R
+
+
#define UV_STRERROR_GEN(name, msg) case UV_ ## name: return msg;
const char* uv_strerror(int err) {
switch (err) {
@@ -175,6 +206,7 @@ const char* uv_strerror(int err) {
}
#undef UV_STRERROR_GEN
+#if !defined(CMAKE_BOOTSTRAP) || defined(_WIN32)
int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr) {
memset(addr, 0, sizeof(*addr));
@@ -192,6 +224,9 @@ int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr) {
memset(addr, 0, sizeof(*addr));
addr->sin6_family = AF_INET6;
addr->sin6_port = htons(port);
+#ifdef SIN6_LEN
+ addr->sin6_len = sizeof(*addr);
+#endif
zone_index = strchr(ip, '%');
if (zone_index != NULL) {
@@ -284,17 +319,20 @@ int uv_tcp_connect(uv_connect_t* req,
}
-int uv_udp_send(uv_udp_send_t* req,
- uv_udp_t* handle,
- const uv_buf_t bufs[],
- unsigned int nbufs,
- const struct sockaddr* addr,
- uv_udp_send_cb send_cb) {
+int uv_udp_connect(uv_udp_t* handle, const struct sockaddr* addr) {
unsigned int addrlen;
if (handle->type != UV_UDP)
return UV_EINVAL;
+ /* Disconnect the handle */
+ if (addr == NULL) {
+ if (!(handle->flags & UV_HANDLE_UDP_CONNECTED))
+ return UV_ENOTCONN;
+
+ return uv__udp_disconnect(handle);
+ }
+
if (addr->sa_family == AF_INET)
addrlen = sizeof(struct sockaddr_in);
else if (addr->sa_family == AF_INET6)
@@ -302,6 +340,70 @@ int uv_udp_send(uv_udp_send_t* req,
else
return UV_EINVAL;
+ if (handle->flags & UV_HANDLE_UDP_CONNECTED)
+ return UV_EISCONN;
+
+ return uv__udp_connect(handle, addr, addrlen);
+}
+
+
+int uv__udp_is_connected(uv_udp_t* handle) {
+ struct sockaddr_storage addr;
+ int addrlen;
+ if (handle->type != UV_UDP)
+ return 0;
+
+ addrlen = sizeof(addr);
+ if (uv_udp_getpeername(handle, (struct sockaddr*) &addr, &addrlen) != 0)
+ return 0;
+
+ return addrlen > 0;
+}
+
+
+int uv__udp_check_before_send(uv_udp_t* handle, const struct sockaddr* addr) {
+ unsigned int addrlen;
+
+ if (handle->type != UV_UDP)
+ return UV_EINVAL;
+
+ if (addr != NULL && (handle->flags & UV_HANDLE_UDP_CONNECTED))
+ return UV_EISCONN;
+
+ if (addr == NULL && !(handle->flags & UV_HANDLE_UDP_CONNECTED))
+ return UV_EDESTADDRREQ;
+
+ if (addr != NULL) {
+ if (addr->sa_family == AF_INET)
+ addrlen = sizeof(struct sockaddr_in);
+ else if (addr->sa_family == AF_INET6)
+ addrlen = sizeof(struct sockaddr_in6);
+#if defined(AF_UNIX) && !defined(_WIN32)
+ else if (addr->sa_family == AF_UNIX)
+ addrlen = sizeof(struct sockaddr_un);
+#endif
+ else
+ return UV_EINVAL;
+ } else {
+ addrlen = 0;
+ }
+
+ return addrlen;
+}
+
+
+int uv_udp_send(uv_udp_send_t* req,
+ uv_udp_t* handle,
+ const uv_buf_t bufs[],
+ unsigned int nbufs,
+ const struct sockaddr* addr,
+ uv_udp_send_cb send_cb) {
+ int addrlen;
+
+ addrlen = uv__udp_check_before_send(handle, addr);
+ if (addrlen < 0)
+ return addrlen;
+
return uv__udp_send(req, handle, bufs, nbufs, addr, addrlen, send_cb);
}
@@ -310,17 +412,11 @@ int uv_udp_try_send(uv_udp_t* handle,
const uv_buf_t bufs[],
unsigned int nbufs,
const struct sockaddr* addr) {
- unsigned int addrlen;
+ int addrlen;
- if (handle->type != UV_UDP)
- return UV_EINVAL;
-
- if (addr->sa_family == AF_INET)
- addrlen = sizeof(struct sockaddr_in);
- else if (addr->sa_family == AF_INET6)
- addrlen = sizeof(struct sockaddr_in6);
- else
- return UV_EINVAL;
+ addrlen = uv__udp_check_before_send(handle, addr);
+ if (addrlen < 0)
+ return addrlen;
return uv__udp_try_send(handle, bufs, nbufs, addr, addrlen);
}
@@ -343,6 +439,7 @@ int uv_udp_recv_stop(uv_udp_t* handle) {
return uv__udp_recv_stop(handle);
}
+#endif
void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) {
QUEUE queue;
@@ -357,7 +454,7 @@ void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) {
QUEUE_REMOVE(q);
QUEUE_INSERT_TAIL(&loop->handle_queue, q);
- if (h->flags & UV__HANDLE_INTERNAL) continue;
+ if (h->flags & UV_HANDLE_INTERNAL) continue;
walk_cb(h, arg);
}
}
@@ -386,9 +483,9 @@ static void uv__print_handles(uv_loop_t* loop, int only_active, FILE* stream) {
fprintf(stream,
"[%c%c%c] %-8s %p\n",
- "R-"[!(h->flags & UV__HANDLE_REF)],
- "A-"[!(h->flags & UV__HANDLE_ACTIVE)],
- "I-"[!(h->flags & UV__HANDLE_INTERNAL)],
+ "R-"[!(h->flags & UV_HANDLE_REF)],
+ "A-"[!(h->flags & UV_HANDLE_ACTIVE)],
+ "I-"[!(h->flags & UV_HANDLE_INTERNAL)],
type,
(void*)h);
}
@@ -541,37 +638,66 @@ int uv_fs_scandir_next(uv_fs_t* req, uv_dirent_t* ent) {
dent = dents[(*nbufs)++];
ent->name = dent->d_name;
+ ent->type = uv__fs_get_dirent_type(dent);
+
+ return 0;
+}
+
+uv_dirent_type_t uv__fs_get_dirent_type(uv__dirent_t* dent) {
+ uv_dirent_type_t type;
+
#ifdef HAVE_DIRENT_TYPES
switch (dent->d_type) {
case UV__DT_DIR:
- ent->type = UV_DIRENT_DIR;
+ type = UV_DIRENT_DIR;
break;
case UV__DT_FILE:
- ent->type = UV_DIRENT_FILE;
+ type = UV_DIRENT_FILE;
break;
case UV__DT_LINK:
- ent->type = UV_DIRENT_LINK;
+ type = UV_DIRENT_LINK;
break;
case UV__DT_FIFO:
- ent->type = UV_DIRENT_FIFO;
+ type = UV_DIRENT_FIFO;
break;
case UV__DT_SOCKET:
- ent->type = UV_DIRENT_SOCKET;
+ type = UV_DIRENT_SOCKET;
break;
case UV__DT_CHAR:
- ent->type = UV_DIRENT_CHAR;
+ type = UV_DIRENT_CHAR;
break;
case UV__DT_BLOCK:
- ent->type = UV_DIRENT_BLOCK;
+ type = UV_DIRENT_BLOCK;
break;
default:
- ent->type = UV_DIRENT_UNKNOWN;
+ type = UV_DIRENT_UNKNOWN;
}
#else
- ent->type = UV_DIRENT_UNKNOWN;
+ type = UV_DIRENT_UNKNOWN;
#endif
- return 0;
+ return type;
+}
+
+void uv__fs_readdir_cleanup(uv_fs_t* req) {
+ uv_dir_t* dir;
+ uv_dirent_t* dirents;
+ int i;
+
+ if (req->ptr == NULL)
+ return;
+
+ dir = req->ptr;
+ dirents = dir->dirents;
+ req->ptr = NULL;
+
+ if (dirents == NULL)
+ return;
+
+ for (i = 0; i < req->result; ++i) {
+ uv__free((char*) dirents[i].name);
+ dirents[i].name = NULL;
+ }
}
@@ -627,12 +753,12 @@ int uv_loop_close(uv_loop_t* loop) {
void* saved_data;
#endif
- if (!QUEUE_EMPTY(&(loop)->active_reqs))
+ if (uv__has_active_reqs(loop))
return UV_EBUSY;
QUEUE_FOREACH(q, &loop->handle_queue) {
h = QUEUE_DATA(q, uv_handle_t, handle_queue);
- if (!(h->flags & UV__HANDLE_INTERNAL))
+ if (!(h->flags & UV_HANDLE_INTERNAL))
return UV_EBUSY;
}
diff --git a/Utilities/cmlibuv/src/uv-common.h b/Utilities/cmlibuv/src/uv-common.h
index 781a8559d..f788161c3 100644
--- a/Utilities/cmlibuv/src/uv-common.h
+++ b/Utilities/cmlibuv/src/uv-common.h
@@ -32,14 +32,21 @@
#include <stddef.h>
#if defined(_MSC_VER) && _MSC_VER < 1600
-# include "stdint-msvc2008.h"
+# include "uv/stdint-msvc2008.h"
#else
# include <stdint.h>
#endif
#include "uv.h"
-#include "tree.h"
+#include "uv/tree.h"
#include "queue.h"
+#include "strscpy.h"
+
+#if EDOM > 0
+# define UV__ERR(x) (-(x))
+#else
+# define UV__ERR(x) (x)
+#endif
#if !defined(snprintf) && defined(_MSC_VER) && _MSC_VER < 1900
extern int snprintf(char*, size_t, const char*, ...);
@@ -53,22 +60,68 @@ extern int snprintf(char*, size_t, const char*, ...);
#define STATIC_ASSERT(expr) \
void uv__static_assert(int static_assert_failed[1 - 2 * !(expr)])
-#ifndef _WIN32
+/* Handle flags. Some flags are specific to Windows or UNIX. */
enum {
- UV__SIGNAL_ONE_SHOT = 0x80000, /* On signal reception remove sighandler */
- UV__HANDLE_INTERNAL = 0x8000,
- UV__HANDLE_ACTIVE = 0x4000,
- UV__HANDLE_REF = 0x2000,
- UV__HANDLE_CLOSING = 0 /* no-op on unix */
+ /* Used by all handles. */
+ UV_HANDLE_CLOSING = 0x00000001,
+ UV_HANDLE_CLOSED = 0x00000002,
+ UV_HANDLE_ACTIVE = 0x00000004,
+ UV_HANDLE_REF = 0x00000008,
+ UV_HANDLE_INTERNAL = 0x00000010,
+ UV_HANDLE_ENDGAME_QUEUED = 0x00000020,
+
+ /* Used by streams. */
+ UV_HANDLE_LISTENING = 0x00000040,
+ UV_HANDLE_CONNECTION = 0x00000080,
+ UV_HANDLE_SHUTTING = 0x00000100,
+ UV_HANDLE_SHUT = 0x00000200,
+ UV_HANDLE_READ_PARTIAL = 0x00000400,
+ UV_HANDLE_READ_EOF = 0x00000800,
+
+ /* Used by streams and UDP handles. */
+ UV_HANDLE_READING = 0x00001000,
+ UV_HANDLE_BOUND = 0x00002000,
+ UV_HANDLE_READABLE = 0x00004000,
+ UV_HANDLE_WRITABLE = 0x00008000,
+ UV_HANDLE_READ_PENDING = 0x00010000,
+ UV_HANDLE_SYNC_BYPASS_IOCP = 0x00020000,
+ UV_HANDLE_ZERO_READ = 0x00040000,
+ UV_HANDLE_EMULATE_IOCP = 0x00080000,
+ UV_HANDLE_BLOCKING_WRITES = 0x00100000,
+ UV_HANDLE_CANCELLATION_PENDING = 0x00200000,
+
+ /* Used by uv_tcp_t and uv_udp_t handles */
+ UV_HANDLE_IPV6 = 0x00400000,
+
+ /* Only used by uv_tcp_t handles. */
+ UV_HANDLE_TCP_NODELAY = 0x01000000,
+ UV_HANDLE_TCP_KEEPALIVE = 0x02000000,
+ UV_HANDLE_TCP_SINGLE_ACCEPT = 0x04000000,
+ UV_HANDLE_TCP_ACCEPT_STATE_CHANGING = 0x08000000,
+ UV_HANDLE_TCP_SOCKET_CLOSED = 0x10000000,
+ UV_HANDLE_SHARED_TCP_SOCKET = 0x20000000,
+
+ /* Only used by uv_udp_t handles. */
+ UV_HANDLE_UDP_PROCESSING = 0x01000000,
+ UV_HANDLE_UDP_CONNECTED = 0x02000000,
+
+ /* Only used by uv_pipe_t handles. */
+ UV_HANDLE_NON_OVERLAPPED_PIPE = 0x01000000,
+ UV_HANDLE_PIPESERVER = 0x02000000,
+
+ /* Only used by uv_tty_t handles. */
+ UV_HANDLE_TTY_READABLE = 0x01000000,
+ UV_HANDLE_TTY_RAW = 0x02000000,
+ UV_HANDLE_TTY_SAVED_POSITION = 0x04000000,
+ UV_HANDLE_TTY_SAVED_ATTRIBUTES = 0x08000000,
+
+ /* Only used by uv_signal_t handles. */
+ UV_SIGNAL_ONE_SHOT_DISPATCHED = 0x01000000,
+ UV_SIGNAL_ONE_SHOT = 0x02000000,
+
+ /* Only used by uv_poll_t handles. */
+ UV_HANDLE_POLL_SLOW = 0x01000000
};
-#else
-# define UV__SIGNAL_ONE_SHOT_DISPATCHED 0x200
-# define UV__SIGNAL_ONE_SHOT 0x100
-# define UV__HANDLE_INTERNAL 0x80
-# define UV__HANDLE_ACTIVE 0x40
-# define UV__HANDLE_REF 0x20
-# define UV__HANDLE_CLOSING 0x01
-#endif
int uv__loop_configure(uv_loop_t* loop, uv_loop_option option, va_list ap);
@@ -90,6 +143,14 @@ int uv__udp_bind(uv_udp_t* handle,
unsigned int addrlen,
unsigned int flags);
+int uv__udp_connect(uv_udp_t* handle,
+ const struct sockaddr* addr,
+ unsigned int addrlen);
+
+int uv__udp_disconnect(uv_udp_t* handle);
+
+int uv__udp_is_connected(uv_udp_t* handle);
+
int uv__udp_send(uv_udp_send_t* req,
uv_udp_t* handle,
const uv_buf_t bufs[],
@@ -113,8 +174,15 @@ void uv__fs_poll_close(uv_fs_poll_t* handle);
int uv__getaddrinfo_translate_error(int sys_err); /* EAI_* error. */
+enum uv__work_kind {
+ UV__WORK_CPU,
+ UV__WORK_FAST_IO,
+ UV__WORK_SLOW_IO
+};
+
void uv__work_submit(uv_loop_t* loop,
struct uv__work *w,
+ enum uv__work_kind kind,
void (*work)(struct uv__work *w),
void (*done)(struct uv__work *w, int status));
@@ -125,20 +193,26 @@ size_t uv__count_bufs(const uv_buf_t bufs[], unsigned int nbufs);
int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value);
void uv__fs_scandir_cleanup(uv_fs_t* req);
+void uv__fs_readdir_cleanup(uv_fs_t* req);
+uv_dirent_type_t uv__fs_get_dirent_type(uv__dirent_t* dent);
+
+int uv__next_timeout(const uv_loop_t* loop);
+void uv__run_timers(uv_loop_t* loop);
+void uv__timer_close(uv_timer_t* handle);
#define uv__has_active_reqs(loop) \
- (QUEUE_EMPTY(&(loop)->active_reqs) == 0)
+ ((loop)->active_reqs.count > 0)
#define uv__req_register(loop, req) \
do { \
- QUEUE_INSERT_TAIL(&(loop)->active_reqs, &(req)->active_queue); \
+ (loop)->active_reqs.count++; \
} \
while (0)
#define uv__req_unregister(loop, req) \
do { \
assert(uv__has_active_reqs(loop)); \
- QUEUE_REMOVE(&(req)->active_queue); \
+ (loop)->active_reqs.count--; \
} \
while (0)
@@ -158,49 +232,47 @@ void uv__fs_scandir_cleanup(uv_fs_t* req);
while (0)
#define uv__is_active(h) \
- (((h)->flags & UV__HANDLE_ACTIVE) != 0)
+ (((h)->flags & UV_HANDLE_ACTIVE) != 0)
#define uv__is_closing(h) \
- (((h)->flags & (UV_CLOSING | UV_CLOSED)) != 0)
+ (((h)->flags & (UV_HANDLE_CLOSING | UV_HANDLE_CLOSED)) != 0)
#define uv__handle_start(h) \
do { \
- assert(((h)->flags & UV__HANDLE_CLOSING) == 0); \
- if (((h)->flags & UV__HANDLE_ACTIVE) != 0) break; \
- (h)->flags |= UV__HANDLE_ACTIVE; \
- if (((h)->flags & UV__HANDLE_REF) != 0) uv__active_handle_add(h); \
+ if (((h)->flags & UV_HANDLE_ACTIVE) != 0) break; \
+ (h)->flags |= UV_HANDLE_ACTIVE; \
+ if (((h)->flags & UV_HANDLE_REF) != 0) uv__active_handle_add(h); \
} \
while (0)
#define uv__handle_stop(h) \
do { \
- assert(((h)->flags & UV__HANDLE_CLOSING) == 0); \
- if (((h)->flags & UV__HANDLE_ACTIVE) == 0) break; \
- (h)->flags &= ~UV__HANDLE_ACTIVE; \
- if (((h)->flags & UV__HANDLE_REF) != 0) uv__active_handle_rm(h); \
+ if (((h)->flags & UV_HANDLE_ACTIVE) == 0) break; \
+ (h)->flags &= ~UV_HANDLE_ACTIVE; \
+ if (((h)->flags & UV_HANDLE_REF) != 0) uv__active_handle_rm(h); \
} \
while (0)
#define uv__handle_ref(h) \
do { \
- if (((h)->flags & UV__HANDLE_REF) != 0) break; \
- (h)->flags |= UV__HANDLE_REF; \
- if (((h)->flags & UV__HANDLE_CLOSING) != 0) break; \
- if (((h)->flags & UV__HANDLE_ACTIVE) != 0) uv__active_handle_add(h); \
+ if (((h)->flags & UV_HANDLE_REF) != 0) break; \
+ (h)->flags |= UV_HANDLE_REF; \
+ if (((h)->flags & UV_HANDLE_CLOSING) != 0) break; \
+ if (((h)->flags & UV_HANDLE_ACTIVE) != 0) uv__active_handle_add(h); \
} \
while (0)
#define uv__handle_unref(h) \
do { \
- if (((h)->flags & UV__HANDLE_REF) == 0) break; \
- (h)->flags &= ~UV__HANDLE_REF; \
- if (((h)->flags & UV__HANDLE_CLOSING) != 0) break; \
- if (((h)->flags & UV__HANDLE_ACTIVE) != 0) uv__active_handle_rm(h); \
+ if (((h)->flags & UV_HANDLE_REF) == 0) break; \
+ (h)->flags &= ~UV_HANDLE_REF; \
+ if (((h)->flags & UV_HANDLE_CLOSING) != 0) break; \
+ if (((h)->flags & UV_HANDLE_ACTIVE) != 0) uv__active_handle_rm(h); \
} \
while (0)
#define uv__has_ref(h) \
- (((h)->flags & UV__HANDLE_REF) != 0)
+ (((h)->flags & UV_HANDLE_REF) != 0)
#if defined(_WIN32)
# define uv__handle_platform_init(h) ((h)->u.fd = -1)
@@ -212,7 +284,7 @@ void uv__fs_scandir_cleanup(uv_fs_t* req);
do { \
(h)->loop = (loop_); \
(h)->type = (type_); \
- (h)->flags = UV__HANDLE_REF; /* Ref the loop when active. */ \
+ (h)->flags = UV_HANDLE_REF; /* Ref the loop when active. */ \
QUEUE_INSERT_TAIL(&(loop_)->handle_queue, &(h)->handle_queue); \
uv__handle_platform_init(h); \
} \
diff --git a/Utilities/cmlibuv/src/uv-data-getter-setters.c b/Utilities/cmlibuv/src/uv-data-getter-setters.c
new file mode 100644
index 000000000..c3025662f
--- /dev/null
+++ b/Utilities/cmlibuv/src/uv-data-getter-setters.c
@@ -0,0 +1,98 @@
+#include "uv.h"
+
+const char* uv_handle_type_name(uv_handle_type type) {
+ switch (type) {
+#define XX(uc,lc) case UV_##uc: return #lc;
+ UV_HANDLE_TYPE_MAP(XX)
+#undef XX
+ case UV_FILE: return "file";
+ case UV_HANDLE_TYPE_MAX:
+ case UV_UNKNOWN_HANDLE: return NULL;
+ }
+ return NULL;
+}
+
+uv_handle_type uv_handle_get_type(const uv_handle_t* handle) {
+ return handle->type;
+}
+
+void* uv_handle_get_data(const uv_handle_t* handle) {
+ return handle->data;
+}
+
+uv_loop_t* uv_handle_get_loop(const uv_handle_t* handle) {
+ return handle->loop;
+}
+
+void uv_handle_set_data(uv_handle_t* handle, void* data) {
+ handle->data = data;
+}
+
+const char* uv_req_type_name(uv_req_type type) {
+ switch (type) {
+#define XX(uc,lc) case UV_##uc: return #lc;
+ UV_REQ_TYPE_MAP(XX)
+#undef XX
+ case UV_REQ_TYPE_MAX:
+ case UV_UNKNOWN_REQ:
+ default: /* UV_REQ_TYPE_PRIVATE */
+ break;
+ }
+ return NULL;
+}
+
+uv_req_type uv_req_get_type(const uv_req_t* req) {
+ return req->type;
+}
+
+void* uv_req_get_data(const uv_req_t* req) {
+ return req->data;
+}
+
+void uv_req_set_data(uv_req_t* req, void* data) {
+ req->data = data;
+}
+
+size_t uv_stream_get_write_queue_size(const uv_stream_t* stream) {
+ return stream->write_queue_size;
+}
+
+size_t uv_udp_get_send_queue_size(const uv_udp_t* handle) {
+ return handle->send_queue_size;
+}
+
+size_t uv_udp_get_send_queue_count(const uv_udp_t* handle) {
+ return handle->send_queue_count;
+}
+
+uv_pid_t uv_process_get_pid(const uv_process_t* proc) {
+ return proc->pid;
+}
+
+uv_fs_type uv_fs_get_type(const uv_fs_t* req) {
+ return req->fs_type;
+}
+
+ssize_t uv_fs_get_result(const uv_fs_t* req) {
+ return req->result;
+}
+
+void* uv_fs_get_ptr(const uv_fs_t* req) {
+ return req->ptr;
+}
+
+const char* uv_fs_get_path(const uv_fs_t* req) {
+ return req->path;
+}
+
+uv_stat_t* uv_fs_get_statbuf(uv_fs_t* req) {
+ return &req->statbuf;
+}
+
+void* uv_loop_get_data(const uv_loop_t* loop) {
+ return loop->data;
+}
+
+void uv_loop_set_data(uv_loop_t* loop, void* data) {
+ loop->data = data;
+}
diff --git a/Utilities/cmlibuv/src/win/async.c b/Utilities/cmlibuv/src/win/async.c
index 0b636ed1e..d787f6604 100644
--- a/Utilities/cmlibuv/src/win/async.c
+++ b/Utilities/cmlibuv/src/win/async.c
@@ -29,7 +29,7 @@
void uv_async_endgame(uv_loop_t* loop, uv_async_t* handle) {
- if (handle->flags & UV__HANDLE_CLOSING &&
+ if (handle->flags & UV_HANDLE_CLOSING &&
!handle->async_sent) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_close(handle);
@@ -71,9 +71,9 @@ int uv_async_send(uv_async_t* handle) {
return -1;
}
- /* The user should make sure never to call uv_async_send to a closing */
- /* or closed handle. */
- assert(!(handle->flags & UV__HANDLE_CLOSING));
+ /* The user should make sure never to call uv_async_send to a closing or
+ * closed handle. */
+ assert(!(handle->flags & UV_HANDLE_CLOSING));
if (!uv__atomic_exchange_set(&handle->async_sent)) {
POST_COMPLETION_FOR_REQ(loop, &handle->async_req);
@@ -90,7 +90,7 @@ void uv_process_async_wakeup_req(uv_loop_t* loop, uv_async_t* handle,
handle->async_sent = 0;
- if (handle->flags & UV__HANDLE_CLOSING) {
+ if (handle->flags & UV_HANDLE_CLOSING) {
uv_want_endgame(loop, (uv_handle_t*)handle);
} else if (handle->async_cb != NULL) {
handle->async_cb(handle);
diff --git a/Utilities/cmlibuv/src/win/atomicops-inl.h b/Utilities/cmlibuv/src/win/atomicops-inl.h
index 6d8126f69..52713cf30 100644
--- a/Utilities/cmlibuv/src/win/atomicops-inl.h
+++ b/Utilities/cmlibuv/src/win/atomicops-inl.h
@@ -29,10 +29,10 @@
/* Atomic set operation on char */
#ifdef _MSC_VER /* MSVC */
-/* _InterlockedOr8 is supported by MSVC on x32 and x64. It is slightly less */
-/* efficient than InterlockedExchange, but InterlockedExchange8 does not */
-/* exist, and interlocked operations on larger targets might require the */
-/* target to be aligned. */
+/* _InterlockedOr8 is supported by MSVC on x32 and x64. It is slightly less
+ * efficient than InterlockedExchange, but InterlockedExchange8 does not exist,
+ * and interlocked operations on larger targets might require the target to be
+ * aligned. */
#pragma intrinsic(_InterlockedOr8)
static char INLINE uv__atomic_exchange_set(char volatile* target) {
diff --git a/Utilities/cmlibuv/src/win/core.c b/Utilities/cmlibuv/src/win/core.c
index 9ed4e824c..e9d0a5815 100644
--- a/Utilities/cmlibuv/src/win/core.c
+++ b/Utilities/cmlibuv/src/win/core.c
@@ -33,6 +33,7 @@
#include "internal.h"
#include "queue.h"
#include "handle-inl.h"
+#include "heap-inl.h"
#include "req-inl.h"
/* uv_once initialization guards */
@@ -221,6 +222,7 @@ static void uv_init(void) {
int uv_loop_init(uv_loop_t* loop) {
+ struct heap* timer_heap;
int err;
/* Initialize libuv itself first */
@@ -239,14 +241,20 @@ int uv_loop_init(uv_loop_t* loop) {
QUEUE_INIT(&loop->wq);
QUEUE_INIT(&loop->handle_queue);
- QUEUE_INIT(&loop->active_reqs);
+ loop->active_reqs.count = 0;
loop->active_handles = 0;
loop->pending_reqs_tail = NULL;
loop->endgame_handles = NULL;
- RB_INIT(&loop->timers);
+ loop->timer_heap = timer_heap = uv__malloc(sizeof(*timer_heap));
+ if (timer_heap == NULL) {
+ err = UV_ENOMEM;
+ goto fail_timers_alloc;
+ }
+
+ heap_init(timer_heap);
loop->check_handles = NULL;
loop->prepare_handles = NULL;
@@ -273,7 +281,7 @@ int uv_loop_init(uv_loop_t* loop) {
goto fail_async_init;
uv__handle_unref(&loop->wq_async);
- loop->wq_async.flags |= UV__HANDLE_INTERNAL;
+ loop->wq_async.flags |= UV_HANDLE_INTERNAL;
err = uv__loops_add(loop);
if (err)
@@ -285,6 +293,10 @@ fail_async_init:
uv_mutex_destroy(&loop->wq_mutex);
fail_mutex_init:
+ uv__free(timer_heap);
+ loop->timer_heap = NULL;
+
+fail_timers_alloc:
CloseHandle(loop->iocp);
loop->iocp = INVALID_HANDLE_VALUE;
@@ -292,6 +304,13 @@ fail_mutex_init:
}
+void uv_update_time(uv_loop_t* loop) {
+ uint64_t new_time = uv__hrtime(1000);
+ assert(new_time >= loop->time);
+ loop->time = new_time;
+}
+
+
void uv__once_init(void) {
uv_once(&uv_init_guard_, uv_init);
}
@@ -320,6 +339,9 @@ void uv__loop_close(uv_loop_t* loop) {
uv_mutex_unlock(&loop->wq_mutex);
uv_mutex_destroy(&loop->wq_mutex);
+ uv__free(loop->timer_heap);
+ loop->timer_heap = NULL;
+
CloseHandle(loop->iocp);
}
@@ -359,7 +381,7 @@ int uv_backend_timeout(const uv_loop_t* loop) {
}
-static void uv_poll(uv_loop_t* loop, DWORD timeout) {
+static void uv__poll_wine(uv_loop_t* loop, DWORD timeout) {
DWORD bytes;
ULONG_PTR key;
OVERLAPPED* overlapped;
@@ -410,7 +432,7 @@ static void uv_poll(uv_loop_t* loop, DWORD timeout) {
}
-static void uv_poll_ex(uv_loop_t* loop, DWORD timeout) {
+static void uv__poll(uv_loop_t* loop, DWORD timeout) {
BOOL success;
uv_req_t* req;
OVERLAPPED_ENTRY overlappeds[128];
@@ -422,12 +444,12 @@ static void uv_poll_ex(uv_loop_t* loop, DWORD timeout) {
timeout_time = loop->time + timeout;
for (repeat = 0; ; repeat++) {
- success = pGetQueuedCompletionStatusEx(loop->iocp,
- overlappeds,
- ARRAY_SIZE(overlappeds),
- &count,
- timeout,
- FALSE);
+ success = GetQueuedCompletionStatusEx(loop->iocp,
+ overlappeds,
+ ARRAY_SIZE(overlappeds),
+ &count,
+ timeout,
+ FALSE);
if (success) {
for (i = 0; i < count; i++) {
@@ -470,8 +492,8 @@ static void uv_poll_ex(uv_loop_t* loop, DWORD timeout) {
static int uv__loop_alive(const uv_loop_t* loop) {
- return loop->active_handles > 0 ||
- !QUEUE_EMPTY(&loop->active_reqs) ||
+ return uv__has_active_handles(loop) ||
+ uv__has_active_reqs(loop) ||
loop->endgame_handles != NULL;
}
@@ -485,12 +507,6 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) {
DWORD timeout;
int r;
int ran_pending;
- void (*poll)(uv_loop_t* loop, DWORD timeout);
-
- if (pGetQueuedCompletionStatusEx)
- poll = &uv_poll_ex;
- else
- poll = &uv_poll;
r = uv__loop_alive(loop);
if (!r)
@@ -498,7 +514,7 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) {
while (r != 0 && loop->stop_flag == 0) {
uv_update_time(loop);
- uv_process_timers(loop);
+ uv__run_timers(loop);
ran_pending = uv_process_reqs(loop);
uv_idle_invoke(loop);
@@ -508,7 +524,11 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) {
if ((mode == UV_RUN_ONCE && !ran_pending) || mode == UV_RUN_DEFAULT)
timeout = uv_backend_timeout(loop);
- (*poll)(loop, timeout);
+ if (pGetQueuedCompletionStatusEx)
+ uv__poll(loop, timeout);
+ else
+ uv__poll_wine(loop, timeout);
+
uv_check_invoke(loop);
uv_process_endgames(loop);
@@ -522,7 +542,7 @@ int uv_run(uv_loop_t *loop, uv_run_mode mode) {
* UV_RUN_NOWAIT makes no guarantees about progress so it's omitted from
* the check.
*/
- uv_process_timers(loop);
+ uv__run_timers(loop);
}
r = uv__loop_alive(loop);
@@ -603,3 +623,30 @@ int uv__socket_sockopt(uv_handle_t* handle, int optname, int* value) {
return 0;
}
+
+int uv_cpumask_size(void) {
+ return (int)(sizeof(DWORD_PTR) * 8);
+}
+
+int uv__getsockpeername(const uv_handle_t* handle,
+ uv__peersockfunc func,
+ struct sockaddr* name,
+ int* namelen,
+ int delayed_error) {
+
+ int result;
+ uv_os_fd_t fd;
+
+ result = uv_fileno(handle, &fd);
+ if (result != 0)
+ return result;
+
+ if (delayed_error)
+ return uv_translate_sys_error(delayed_error);
+
+ result = func((SOCKET) fd, name, namelen);
+ if (result != 0)
+ return uv_translate_sys_error(WSAGetLastError());
+
+ return 0;
+}
diff --git a/Utilities/cmlibuv/src/win/dl.c b/Utilities/cmlibuv/src/win/dl.c
index 39e400ab2..676be4dc7 100644
--- a/Utilities/cmlibuv/src/win/dl.c
+++ b/Utilities/cmlibuv/src/win/dl.c
@@ -22,7 +22,7 @@
#include "uv.h"
#include "internal.h"
-static int uv__dlerror(uv_lib_t* lib, int errorno);
+static int uv__dlerror(uv_lib_t* lib, const char* filename, DWORD errorno);
int uv_dlopen(const char* filename, uv_lib_t* lib) {
@@ -37,12 +37,12 @@ int uv_dlopen(const char* filename, uv_lib_t* lib) {
-1,
filename_w,
ARRAY_SIZE(filename_w))) {
- return uv__dlerror(lib, GetLastError());
+ return uv__dlerror(lib, filename, GetLastError());
}
lib->handle = LoadLibraryExW(filename_w, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (lib->handle == NULL) {
- return uv__dlerror(lib, GetLastError());
+ return uv__dlerror(lib, filename, GetLastError());
}
return 0;
@@ -64,8 +64,9 @@ void uv_dlclose(uv_lib_t* lib) {
int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr) {
- *ptr = (void*) GetProcAddress(lib->handle, name);
- return uv__dlerror(lib, *ptr ? 0 : GetLastError());
+ /* Cast though integer to suppress pedantic warning about forbidden cast. */
+ *ptr = (void*)(uintptr_t) GetProcAddress(lib->handle, name);
+ return uv__dlerror(lib, "", *ptr ? 0 : GetLastError());
}
@@ -75,8 +76,9 @@ const char* uv_dlerror(const uv_lib_t* lib) {
static void uv__format_fallback_error(uv_lib_t* lib, int errorno){
- DWORD_PTR args[1] = { (DWORD_PTR) errorno };
- LPSTR fallback_error = "error: %1!d!";
+ static const CHAR fallback_error[] = "error: %1!d!";
+ DWORD_PTR args[1];
+ args[0] = (DWORD_PTR) errorno;
FormatMessageA(FORMAT_MESSAGE_FROM_STRING |
FORMAT_MESSAGE_ARGUMENT_ARRAY |
@@ -88,31 +90,47 @@ static void uv__format_fallback_error(uv_lib_t* lib, int errorno){
-static int uv__dlerror(uv_lib_t* lib, int errorno) {
+static int uv__dlerror(uv_lib_t* lib, const char* filename, DWORD errorno) {
+ DWORD_PTR arg;
DWORD res;
+ char* msg;
if (lib->errmsg) {
- LocalFree((void*)lib->errmsg);
+ LocalFree(lib->errmsg);
lib->errmsg = NULL;
}
- if (errorno) {
+ if (errorno == 0)
+ return 0;
+
+ res = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno,
+ MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
+ (LPSTR) &lib->errmsg, 0, NULL);
+
+ if (!res && (GetLastError() == ERROR_MUI_FILE_NOT_FOUND ||
+ GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND)) {
res = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno,
- MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
- (LPSTR) &lib->errmsg, 0, NULL);
- if (!res && GetLastError() == ERROR_MUI_FILE_NOT_FOUND) {
- res = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno,
- 0, (LPSTR) &lib->errmsg, 0, NULL);
- }
-
- if (!res) {
- uv__format_fallback_error(lib, errorno);
- }
+ 0, (LPSTR) &lib->errmsg, 0, NULL);
+ }
+
+ if (res && errorno == ERROR_BAD_EXE_FORMAT && strstr(lib->errmsg, "%1")) {
+ msg = lib->errmsg;
+ lib->errmsg = NULL;
+ arg = (DWORD_PTR) filename;
+ res = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_ARGUMENT_ARRAY |
+ FORMAT_MESSAGE_FROM_STRING,
+ msg,
+ 0, 0, (LPSTR) &lib->errmsg, 0, (va_list*) &arg);
+ LocalFree(msg);
}
- return errorno ? -1 : 0;
+ if (!res)
+ uv__format_fallback_error(lib, errorno);
+
+ return -1;
}
diff --git a/Utilities/cmlibuv/src/win/error.c b/Utilities/cmlibuv/src/win/error.c
index 642d1112e..24924ba81 100644
--- a/Utilities/cmlibuv/src/win/error.c
+++ b/Utilities/cmlibuv/src/win/error.c
@@ -46,8 +46,8 @@ void uv_fatal_error(const int errorno, const char* syscall) {
errmsg = "Unknown error";
}
- /* FormatMessage messages include a newline character already, */
- /* so don't add another. */
+ /* FormatMessage messages include a newline character already, so don't add
+ * another. */
if (syscall) {
fprintf(stderr, "%s: (%d) %s", syscall, errorno, errmsg);
} else {
@@ -58,7 +58,7 @@ void uv_fatal_error(const int errorno, const char* syscall) {
LocalFree(buf);
}
- *((char*)NULL) = 0xff; /* Force debug break */
+ DebugBreak();
abort();
}
diff --git a/Utilities/cmlibuv/src/win/fs-event.c b/Utilities/cmlibuv/src/win/fs-event.c
index 95f843ad0..acf8e1107 100644
--- a/Utilities/cmlibuv/src/win/fs-event.c
+++ b/Utilities/cmlibuv/src/win/fs-event.c
@@ -69,6 +69,7 @@ static void uv_relative_path(const WCHAR* filename,
size_t relpathlen;
size_t filenamelen = wcslen(filename);
size_t dirlen = wcslen(dir);
+ assert(!_wcsnicmp(filename, dir, dirlen));
if (dirlen > 0 && dir[dirlen - 1] == '\\')
dirlen--;
relpathlen = filenamelen - dirlen - 1;
@@ -82,7 +83,7 @@ static void uv_relative_path(const WCHAR* filename,
static int uv_split_path(const WCHAR* filename, WCHAR** dir,
WCHAR** file) {
size_t len, i;
-
+
if (filename == NULL) {
if (dir != NULL)
*dir = NULL;
@@ -151,11 +152,11 @@ int uv_fs_event_start(uv_fs_event_t* handle,
uv_fs_event_cb cb,
const char* path,
unsigned int flags) {
- int name_size, is_path_dir;
+ int name_size, is_path_dir, size;
DWORD attr, last_error;
WCHAR* dir = NULL, *dir_to_watch, *pathw = NULL;
WCHAR short_path_buffer[MAX_PATH];
- WCHAR* short_path;
+ WCHAR* short_path, *long_path;
if (uv__is_active(handle))
return UV_EINVAL;
@@ -197,6 +198,30 @@ int uv_fs_event_start(uv_fs_event_t* handle,
if (is_path_dir) {
/* path is a directory, so that's the directory that we will watch. */
+
+ /* Convert to long path. */
+ size = GetLongPathNameW(pathw, NULL, 0);
+
+ if (size) {
+ long_path = (WCHAR*)uv__malloc(size * sizeof(WCHAR));
+ if (!long_path) {
+ uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc");
+ }
+
+ size = GetLongPathNameW(pathw, long_path, size);
+ if (size) {
+ long_path[size] = '\0';
+ } else {
+ uv__free(long_path);
+ long_path = NULL;
+ }
+
+ if (long_path) {
+ uv__free(pathw);
+ pathw = long_path;
+ }
+ }
+
dir_to_watch = pathw;
} else {
/*
@@ -205,8 +230,11 @@ int uv_fs_event_start(uv_fs_event_t* handle,
*/
/* Convert to short path. */
- short_path = short_path_buffer;
- if (!GetShortPathNameW(pathw, short_path, ARRAY_SIZE(short_path))) {
+ if (GetShortPathNameW(pathw,
+ short_path_buffer,
+ ARRAY_SIZE(short_path_buffer))) {
+ short_path = short_path_buffer;
+ } else {
short_path = NULL;
}
@@ -394,7 +422,7 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
* - We are not active, just ignore the callback
*/
if (!uv__is_active(handle)) {
- if (handle->flags & UV__HANDLE_CLOSING) {
+ if (handle->flags & UV_HANDLE_CLOSING) {
uv_want_endgame(loop, (uv_handle_t*) handle);
}
return;
@@ -518,7 +546,7 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
}
offset = file_info->NextEntryOffset;
- } while (offset && !(handle->flags & UV__HANDLE_CLOSING));
+ } while (offset && !(handle->flags & UV_HANDLE_CLOSING));
} else {
handle->cb(handle, NULL, UV_CHANGE, 0);
}
@@ -527,7 +555,7 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
handle->cb(handle, NULL, 0, uv_translate_sys_error(err));
}
- if (!(handle->flags & UV__HANDLE_CLOSING)) {
+ if (!(handle->flags & UV_HANDLE_CLOSING)) {
uv_fs_event_queue_readdirchanges(loop, handle);
} else {
uv_want_endgame(loop, (uv_handle_t*)handle);
@@ -548,7 +576,7 @@ void uv_fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle) {
void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle) {
- if ((handle->flags & UV__HANDLE_CLOSING) && !handle->req_pending) {
+ if ((handle->flags & UV_HANDLE_CLOSING) && !handle->req_pending) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
if (handle->buffer) {
diff --git a/Utilities/cmlibuv/src/win/fs.c b/Utilities/cmlibuv/src/win/fs.c
index 2d72cdc70..9e2f084c8 100644
--- a/Utilities/cmlibuv/src/win/fs.c
+++ b/Utilities/cmlibuv/src/win/fs.c
@@ -43,11 +43,30 @@
#define UV_FS_CLEANEDUP 0x0010
-#define QUEUE_FS_TP_JOB(loop, req) \
- do { \
- uv__req_register(loop, req); \
- uv__work_submit((loop), &(req)->work_req, uv__fs_work, uv__fs_done); \
- } while (0)
+#define INIT(subtype) \
+ do { \
+ if (req == NULL) \
+ return UV_EINVAL; \
+ uv_fs_req_init(loop, req, subtype, cb); \
+ } \
+ while (0)
+
+#define POST \
+ do { \
+ if (cb != NULL) { \
+ uv__req_register(loop, req); \
+ uv__work_submit(loop, \
+ &req->work_req, \
+ UV__WORK_FAST_IO, \
+ uv__fs_work, \
+ uv__fs_done); \
+ return 0; \
+ } else { \
+ uv__fs_work(&req->work_req); \
+ return req->result; \
+ } \
+ } \
+ while (0)
#define SET_REQ_RESULT(req, result_value) \
do { \
@@ -77,14 +96,17 @@
return; \
}
+#define MILLIONu (1000U * 1000U)
+#define BILLIONu (1000U * 1000U * 1000U)
+
#define FILETIME_TO_UINT(filetime) \
- (*((uint64_t*) &(filetime)) - 116444736000000000ULL)
+ (*((uint64_t*) &(filetime)) - (uint64_t) 116444736 * BILLIONu)
#define FILETIME_TO_TIME_T(filetime) \
- (FILETIME_TO_UINT(filetime) / 10000000ULL)
+ (FILETIME_TO_UINT(filetime) / (10u * MILLIONu))
#define FILETIME_TO_TIME_NS(filetime, secs) \
- ((FILETIME_TO_UINT(filetime) - (secs * 10000000ULL)) * 100)
+ ((FILETIME_TO_UINT(filetime) - (secs * (uint64_t) 10 * MILLIONu)) * 100U)
#define FILETIME_TO_TIMESPEC(ts, filetime) \
do { \
@@ -94,8 +116,8 @@
#define TIME_T_TO_FILETIME(time, filetime_ptr) \
do { \
- uint64_t bigtime = ((uint64_t) ((time) * 10000000ULL)) + \
- 116444736000000000ULL; \
+ uint64_t bigtime = ((uint64_t) ((time) * (uint64_t) 10 * MILLIONu)) + \
+ (uint64_t) 116444736 * BILLIONu; \
(filetime_ptr)->dwLowDateTime = bigtime & 0xFFFFFFFF; \
(filetime_ptr)->dwHighDateTime = bigtime >> 32; \
} while(0)
@@ -113,6 +135,7 @@ const WCHAR LONG_PATH_PREFIX_LEN = 4;
const WCHAR UNC_PATH_PREFIX[] = L"\\\\?\\UNC\\";
const WCHAR UNC_PATH_PREFIX_LEN = 8;
+static int uv__file_symlink_usermode_flag = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;
void uv_fs_init(void) {
_fmode = _O_BINARY;
@@ -220,6 +243,7 @@ INLINE static int fs__capture_path(uv_fs_t* req, const char* path,
INLINE static void uv_fs_req_init(uv_loop_t* loop, uv_fs_t* req,
uv_fs_type fs_type, const uv_fs_cb cb) {
+ uv__once_init();
UV_REQ_INIT(req, UV_FS);
req->loop = loop;
req->flags = 0;
@@ -309,12 +333,11 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr,
reparse_data->SymbolicLinkReparseBuffer.SubstituteNameLength /
sizeof(WCHAR);
- /* Real symlinks can contain pretty much everything, but the only thing */
- /* we really care about is undoing the implicit conversion to an NT */
- /* namespaced path that CreateSymbolicLink will perform on absolute */
- /* paths. If the path is win32-namespaced then the user must have */
- /* explicitly made it so, and we better just return the unmodified */
- /* reparse data. */
+ /* Real symlinks can contain pretty much everything, but the only thing we
+ * really care about is undoing the implicit conversion to an NT namespaced
+ * path that CreateSymbolicLink will perform on absolute paths. If the path
+ * is win32-namespaced then the user must have explicitly made it so, and
+ * we better just return the unmodified reparse data. */
if (w_target_len >= 4 &&
w_target[0] == L'\\' &&
w_target[1] == L'?' &&
@@ -335,8 +358,8 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr,
(w_target[5] == L'N' || w_target[5] == L'n') &&
(w_target[6] == L'C' || w_target[6] == L'c') &&
w_target[7] == L'\\') {
- /* \??\UNC\<server>\<share>\ - make sure the final path looks like */
- /* \\<server>\<share>\ */
+ /* \??\UNC\<server>\<share>\ - make sure the final path looks like
+ * \\<server>\<share>\ */
w_target += 6;
w_target[0] = L'\\';
w_target_len -= 6;
@@ -351,11 +374,11 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr,
w_target_len = reparse_data->MountPointReparseBuffer.SubstituteNameLength /
sizeof(WCHAR);
- /* Only treat junctions that look like \??\<drive>:\ as symlink. */
- /* Junctions can also be used as mount points, like \??\Volume{<guid>}, */
- /* but that's confusing for programs since they wouldn't be able to */
- /* actually understand such a path when returned by uv_readlink(). */
- /* UNC paths are never valid for junctions so we don't care about them. */
+ /* Only treat junctions that look like \??\<drive>:\ as symlink. Junctions
+ * can also be used as mount points, like \??\Volume{<guid>}, but that's
+ * confusing for programs since they wouldn't be able to actually
+ * understand such a path when returned by uv_readlink(). UNC paths are
+ * never valid for junctions so we don't care about them. */
if (!(w_target_len >= 6 &&
w_target[0] == L'\\' &&
w_target[1] == L'?' &&
@@ -392,27 +415,27 @@ void fs__open(uv_fs_t* req) {
int fd, current_umask;
int flags = req->fs.info.file_flags;
- /* Obtain the active umask. umask() never fails and returns the previous */
- /* umask. */
+ /* Obtain the active umask. umask() never fails and returns the previous
+ * umask. */
current_umask = umask(0);
umask(current_umask);
/* convert flags and mode to CreateFile parameters */
- switch (flags & (_O_RDONLY | _O_WRONLY | _O_RDWR)) {
- case _O_RDONLY:
+ switch (flags & (UV_FS_O_RDONLY | UV_FS_O_WRONLY | UV_FS_O_RDWR)) {
+ case UV_FS_O_RDONLY:
access = FILE_GENERIC_READ;
break;
- case _O_WRONLY:
+ case UV_FS_O_WRONLY:
access = FILE_GENERIC_WRITE;
break;
- case _O_RDWR:
+ case UV_FS_O_RDWR:
access = FILE_GENERIC_READ | FILE_GENERIC_WRITE;
break;
default:
goto einval;
}
- if (flags & _O_APPEND) {
+ if (flags & UV_FS_O_APPEND) {
access &= ~FILE_WRITE_DATA;
access |= FILE_APPEND_DATA;
}
@@ -422,26 +445,33 @@ void fs__open(uv_fs_t* req) {
* does. We indiscriminately use all the sharing modes, to match
* UNIX semantics. In particular, this ensures that the file can
* be deleted even whilst it's open, fixing issue #1449.
+ * We still support exclusive sharing mode, since it is necessary
+ * for opening raw block devices, otherwise Windows will prevent
+ * any attempt to write past the master boot record.
*/
- share = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
+ if (flags & UV_FS_O_EXLOCK) {
+ share = 0;
+ } else {
+ share = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
+ }
- switch (flags & (_O_CREAT | _O_EXCL | _O_TRUNC)) {
+ switch (flags & (UV_FS_O_CREAT | UV_FS_O_EXCL | UV_FS_O_TRUNC)) {
case 0:
- case _O_EXCL:
+ case UV_FS_O_EXCL:
disposition = OPEN_EXISTING;
break;
- case _O_CREAT:
+ case UV_FS_O_CREAT:
disposition = OPEN_ALWAYS;
break;
- case _O_CREAT | _O_EXCL:
- case _O_CREAT | _O_TRUNC | _O_EXCL:
+ case UV_FS_O_CREAT | UV_FS_O_EXCL:
+ case UV_FS_O_CREAT | UV_FS_O_TRUNC | UV_FS_O_EXCL:
disposition = CREATE_NEW;
break;
- case _O_TRUNC:
- case _O_TRUNC | _O_EXCL:
+ case UV_FS_O_TRUNC:
+ case UV_FS_O_TRUNC | UV_FS_O_EXCL:
disposition = TRUNCATE_EXISTING;
break;
- case _O_CREAT | _O_TRUNC:
+ case UV_FS_O_CREAT | UV_FS_O_TRUNC:
disposition = CREATE_ALWAYS;
break;
default:
@@ -449,34 +479,76 @@ void fs__open(uv_fs_t* req) {
}
attributes |= FILE_ATTRIBUTE_NORMAL;
- if (flags & _O_CREAT) {
+ if (flags & UV_FS_O_CREAT) {
if (!((req->fs.info.mode & ~current_umask) & _S_IWRITE)) {
attributes |= FILE_ATTRIBUTE_READONLY;
}
}
- if (flags & _O_TEMPORARY ) {
+ if (flags & UV_FS_O_TEMPORARY ) {
attributes |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY;
access |= DELETE;
}
- if (flags & _O_SHORT_LIVED) {
+ if (flags & UV_FS_O_SHORT_LIVED) {
attributes |= FILE_ATTRIBUTE_TEMPORARY;
}
- switch (flags & (_O_SEQUENTIAL | _O_RANDOM)) {
+ switch (flags & (UV_FS_O_SEQUENTIAL | UV_FS_O_RANDOM)) {
case 0:
break;
- case _O_SEQUENTIAL:
+ case UV_FS_O_SEQUENTIAL:
attributes |= FILE_FLAG_SEQUENTIAL_SCAN;
break;
- case _O_RANDOM:
+ case UV_FS_O_RANDOM:
attributes |= FILE_FLAG_RANDOM_ACCESS;
break;
default:
goto einval;
}
+ if (flags & UV_FS_O_DIRECT) {
+ /*
+ * FILE_APPEND_DATA and FILE_FLAG_NO_BUFFERING are mutually exclusive.
+ * Windows returns 87, ERROR_INVALID_PARAMETER if these are combined.
+ *
+ * FILE_APPEND_DATA is included in FILE_GENERIC_WRITE:
+ *
+ * FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE |
+ * FILE_WRITE_DATA |
+ * FILE_WRITE_ATTRIBUTES |
+ * FILE_WRITE_EA |
+ * FILE_APPEND_DATA |
+ * SYNCHRONIZE
+ *
+ * Note: Appends are also permitted by FILE_WRITE_DATA.
+ *
+ * In order for direct writes and direct appends to succeed, we therefore
+ * exclude FILE_APPEND_DATA if FILE_WRITE_DATA is specified, and otherwise
+ * fail if the user's sole permission is a direct append, since this
+ * particular combination is invalid.
+ */
+ if (access & FILE_APPEND_DATA) {
+ if (access & FILE_WRITE_DATA) {
+ access &= ~FILE_APPEND_DATA;
+ } else {
+ goto einval;
+ }
+ }
+ attributes |= FILE_FLAG_NO_BUFFERING;
+ }
+
+ switch (flags & (UV_FS_O_DSYNC | UV_FS_O_SYNC)) {
+ case 0:
+ break;
+ case UV_FS_O_DSYNC:
+ case UV_FS_O_SYNC:
+ attributes |= FILE_FLAG_WRITE_THROUGH;
+ break;
+ default:
+ goto einval;
+ }
+
/* Setting this flag makes it possible to open a directory. */
attributes |= FILE_FLAG_BACKUP_SEMANTICS;
@@ -489,10 +561,10 @@ void fs__open(uv_fs_t* req) {
NULL);
if (file == INVALID_HANDLE_VALUE) {
DWORD error = GetLastError();
- if (error == ERROR_FILE_EXISTS && (flags & _O_CREAT) &&
- !(flags & _O_EXCL)) {
- /* Special case: when ERROR_FILE_EXISTS happens and O_CREAT was */
- /* specified, it means the path referred to a directory. */
+ if (error == ERROR_FILE_EXISTS && (flags & UV_FS_O_CREAT) &&
+ !(flags & UV_FS_O_EXCL)) {
+ /* Special case: when ERROR_FILE_EXISTS happens and UV_FS_O_CREAT was
+ * specified, it means the path referred to a directory. */
SET_REQ_UV_ERROR(req, UV_EISDIR, error);
} else {
SET_REQ_WIN32_ERROR(req, GetLastError());
@@ -556,9 +628,14 @@ void fs__read(uv_fs_t* req) {
DWORD error;
int result;
unsigned int index;
+ LARGE_INTEGER original_position;
+ LARGE_INTEGER zero_offset;
+ int restore_position;
VERIFY_FD(fd, req);
+ zero_offset.QuadPart = 0;
+ restore_position = 0;
handle = uv__get_osfhandle(fd);
if (handle == INVALID_HANDLE_VALUE) {
@@ -569,6 +646,10 @@ void fs__read(uv_fs_t* req) {
if (offset != -1) {
memset(&overlapped, 0, sizeof overlapped);
overlapped_ptr = &overlapped;
+ if (SetFilePointerEx(handle, zero_offset, &original_position,
+ FILE_CURRENT)) {
+ restore_position = 1;
+ }
} else {
overlapped_ptr = NULL;
}
@@ -593,6 +674,9 @@ void fs__read(uv_fs_t* req) {
++index;
} while (result && index < req->fs.info.nbufs);
+ if (restore_position)
+ SetFilePointerEx(handle, original_position, NULL, FILE_BEGIN);
+
if (result || bytes > 0) {
SET_REQ_RESULT(req, bytes);
} else {
@@ -615,9 +699,14 @@ void fs__write(uv_fs_t* req) {
DWORD bytes;
int result;
unsigned int index;
+ LARGE_INTEGER original_position;
+ LARGE_INTEGER zero_offset;
+ int restore_position;
VERIFY_FD(fd, req);
+ zero_offset.QuadPart = 0;
+ restore_position = 0;
handle = uv__get_osfhandle(fd);
if (handle == INVALID_HANDLE_VALUE) {
SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE);
@@ -627,6 +716,10 @@ void fs__write(uv_fs_t* req) {
if (offset != -1) {
memset(&overlapped, 0, sizeof overlapped);
overlapped_ptr = &overlapped;
+ if (SetFilePointerEx(handle, zero_offset, &original_position,
+ FILE_CURRENT)) {
+ restore_position = 1;
+ }
} else {
overlapped_ptr = NULL;
}
@@ -651,6 +744,9 @@ void fs__write(uv_fs_t* req) {
++index;
} while (result && index < req->fs.info.nbufs);
+ if (restore_position)
+ SetFilePointerEx(handle, original_position, NULL, FILE_BEGIN);
+
if (result || bytes > 0) {
SET_REQ_RESULT(req, bytes);
} else {
@@ -693,9 +789,9 @@ void fs__unlink(uv_fs_t* req) {
}
if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- /* Do not allow deletion of directories, unless it is a symlink. When */
- /* the path refers to a non-symlink directory, report EPERM as mandated */
- /* by POSIX.1. */
+ /* Do not allow deletion of directories, unless it is a symlink. When the
+ * path refers to a non-symlink directory, report EPERM as mandated by
+ * POSIX.1. */
/* Check if it is a reparse point. If it's not, it's a normal directory. */
if (!(info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
@@ -704,8 +800,8 @@ void fs__unlink(uv_fs_t* req) {
return;
}
- /* Read the reparse point and check if it is a valid symlink. */
- /* If not, don't unlink. */
+ /* Read the reparse point and check if it is a valid symlink. If not, don't
+ * unlink. */
if (fs__readlink_handle(handle, NULL, NULL) < 0) {
DWORD error = GetLastError();
if (error == ERROR_SYMLINK_NOT_SUPPORTED)
@@ -720,7 +816,8 @@ void fs__unlink(uv_fs_t* req) {
/* Remove read-only attribute */
FILE_BASIC_INFORMATION basic = { 0 };
- basic.FileAttributes = info.dwFileAttributes & ~(FILE_ATTRIBUTE_READONLY);
+ basic.FileAttributes = (info.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY) |
+ FILE_ATTRIBUTE_ARCHIVE;
status = pNtSetInformationFile(handle,
&iosb,
@@ -1028,8 +1125,140 @@ cleanup:
uv__free(dirents);
}
+void fs__opendir(uv_fs_t* req) {
+ WCHAR* pathw;
+ size_t len;
+ const WCHAR* fmt;
+ WCHAR* find_path;
+ uv_dir_t* dir;
+
+ pathw = req->file.pathw;
+ dir = NULL;
+ find_path = NULL;
+
+ /* Figure out whether path is a file or a directory. */
+ if (!(GetFileAttributesW(pathw) & FILE_ATTRIBUTE_DIRECTORY)) {
+ SET_REQ_UV_ERROR(req, UV_ENOTDIR, ERROR_DIRECTORY);
+ goto error;
+ }
+
+ dir = uv__malloc(sizeof(*dir));
+ if (dir == NULL) {
+ SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY);
+ goto error;
+ }
+
+ len = wcslen(pathw);
+
+ if (len == 0)
+ fmt = L"./*";
+ else if (IS_SLASH(pathw[len - 1]))
+ fmt = L"%s*";
+ else
+ fmt = L"%s\\*";
-INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf) {
+ find_path = uv__malloc(sizeof(WCHAR) * (len + 4));
+ if (find_path == NULL) {
+ SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY);
+ goto error;
+ }
+
+ _snwprintf(find_path, len + 3, fmt, pathw);
+ dir->dir_handle = FindFirstFileW(find_path, &dir->find_data);
+ uv__free(find_path);
+ find_path = NULL;
+ if (dir->dir_handle == INVALID_HANDLE_VALUE &&
+ GetLastError() != ERROR_FILE_NOT_FOUND) {
+ SET_REQ_WIN32_ERROR(req, GetLastError());
+ goto error;
+ }
+
+ dir->need_find_call = FALSE;
+ req->ptr = dir;
+ SET_REQ_RESULT(req, 0);
+ return;
+
+error:
+ uv__free(dir);
+ uv__free(find_path);
+ req->ptr = NULL;
+}
+
+void fs__readdir(uv_fs_t* req) {
+ uv_dir_t* dir;
+ uv_dirent_t* dirents;
+ uv__dirent_t dent;
+ unsigned int dirent_idx;
+ PWIN32_FIND_DATAW find_data;
+ unsigned int i;
+ int r;
+
+ req->flags |= UV_FS_FREE_PTR;
+ dir = req->ptr;
+ dirents = dir->dirents;
+ memset(dirents, 0, dir->nentries * sizeof(*dir->dirents));
+ find_data = &dir->find_data;
+ dirent_idx = 0;
+
+ while (dirent_idx < dir->nentries) {
+ if (dir->need_find_call && FindNextFileW(dir->dir_handle, find_data) == 0) {
+ if (GetLastError() == ERROR_NO_MORE_FILES)
+ break;
+ goto error;
+ }
+
+ /* Skip "." and ".." entries. */
+ if (find_data->cFileName[0] == L'.' &&
+ (find_data->cFileName[1] == L'\0' ||
+ (find_data->cFileName[1] == L'.' &&
+ find_data->cFileName[2] == L'\0'))) {
+ dir->need_find_call = TRUE;
+ continue;
+ }
+
+ r = uv__convert_utf16_to_utf8((const WCHAR*) &find_data->cFileName,
+ -1,
+ (char**) &dirents[dirent_idx].name);
+ if (r != 0)
+ goto error;
+
+ /* Copy file type. */
+ if ((find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
+ dent.d_type = UV__DT_DIR;
+ else if ((find_data->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0)
+ dent.d_type = UV__DT_LINK;
+ else if ((find_data->dwFileAttributes & FILE_ATTRIBUTE_DEVICE) != 0)
+ dent.d_type = UV__DT_CHAR;
+ else
+ dent.d_type = UV__DT_FILE;
+
+ dirents[dirent_idx].type = uv__fs_get_dirent_type(&dent);
+ dir->need_find_call = TRUE;
+ ++dirent_idx;
+ }
+
+ SET_REQ_RESULT(req, dirent_idx);
+ return;
+
+error:
+ SET_REQ_WIN32_ERROR(req, GetLastError());
+ for (i = 0; i < dirent_idx; ++i) {
+ uv__free((char*) dirents[i].name);
+ dirents[i].name = NULL;
+ }
+}
+
+void fs__closedir(uv_fs_t* req) {
+ uv_dir_t* dir;
+
+ dir = req->ptr;
+ FindClose(dir->dir_handle);
+ uv__free(req->ptr);
+ SET_REQ_RESULT(req, 0);
+}
+
+INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf,
+ int do_lstat) {
FILE_ALL_INFORMATION file_info;
FILE_FS_VOLUME_INFORMATION volume_info;
NTSTATUS nt_status;
@@ -1084,19 +1313,25 @@ INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf) {
*/
statbuf->st_mode = 0;
- if (file_info.BasicInformation.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
+ /*
+ * On Windows, FILE_ATTRIBUTE_REPARSE_POINT is a general purpose mechanism
+ * by which filesystem drivers can intercept and alter file system requests.
+ *
+ * The only reparse points we care about are symlinks and mount points, both
+ * of which are treated as POSIX symlinks. Further, we only care when
+ * invoked via lstat, which seeks information about the link instead of its
+ * target. Otherwise, reparse points must be treated as regular files.
+ */
+ if (do_lstat &&
+ (file_info.BasicInformation.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
/*
- * It is possible for a file to have FILE_ATTRIBUTE_REPARSE_POINT but not have
- * any link data. In that case DeviceIoControl() in fs__readlink_handle() sets
- * the last error to ERROR_NOT_A_REPARSE_POINT. Then the stat result mode
- * calculated below will indicate a normal directory or file, as if
- * FILE_ATTRIBUTE_REPARSE_POINT was not present.
+ * If reading the link fails, the reparse point is not a symlink and needs
+ * to be treated as a regular file. The higher level lstat function will
+ * detect this failure and retry without do_lstat if appropriate.
*/
- if (fs__readlink_handle(handle, NULL, &statbuf->st_size) == 0) {
- statbuf->st_mode |= S_IFLNK;
- } else if (GetLastError() != ERROR_NOT_A_REPARSE_POINT) {
+ if (fs__readlink_handle(handle, NULL, &statbuf->st_size) != 0)
return -1;
- }
+ statbuf->st_mode |= S_IFLNK;
}
if (statbuf->st_mode == 0) {
@@ -1124,7 +1359,7 @@ INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf) {
/* st_blocks contains the on-disk allocation size in 512-byte units. */
statbuf->st_blocks =
- file_info.StandardInformation.AllocationSize.QuadPart >> 9ULL;
+ (uint64_t) file_info.StandardInformation.AllocationSize.QuadPart >> 9;
statbuf->st_nlink = file_info.StandardInformation.NumberOfLinks;
@@ -1139,8 +1374,12 @@ INLINE static int fs__stat_handle(HANDLE handle, uv_stat_t* statbuf) {
*
* Therefore we'll just report a sensible value that's quite commonly okay
* on modern hardware.
+ *
+ * 4096 is the minimum required to be compatible with newer Advanced Format
+ * drives (which have 4096 bytes per physical sector), and to be backwards
+ * compatible with older drives (which have 512 bytes per physical sector).
*/
- statbuf->st_blksize = 2048;
+ statbuf->st_blksize = 4096;
/* Todo: set st_flags to something meaningful. Also provide a wrapper for
* chattr(2).
@@ -1191,9 +1430,11 @@ INLINE static void fs__stat_impl(uv_fs_t* req, int do_lstat) {
return;
}
- if (fs__stat_handle(handle, &req->statbuf) != 0) {
+ if (fs__stat_handle(handle, &req->statbuf, do_lstat) != 0) {
DWORD error = GetLastError();
- if (do_lstat && error == ERROR_SYMLINK_NOT_SUPPORTED) {
+ if (do_lstat &&
+ (error == ERROR_SYMLINK_NOT_SUPPORTED ||
+ error == ERROR_NOT_A_REPARSE_POINT)) {
/* We opened a reparse point but it was not a symlink. Try again. */
fs__stat_impl(req, 0);
@@ -1237,7 +1478,7 @@ static void fs__fstat(uv_fs_t* req) {
return;
}
- if (fs__stat_handle(handle, &req->statbuf) != 0) {
+ if (fs__stat_handle(handle, &req->statbuf, 0) != 0) {
SET_REQ_WIN32_ERROR(req, GetLastError());
return;
}
@@ -1309,6 +1550,28 @@ static void fs__ftruncate(uv_fs_t* req) {
}
+static void fs__copyfile(uv_fs_t* req) {
+ int flags;
+ int overwrite;
+
+ flags = req->fs.info.file_flags;
+
+ if (flags & UV_FS_COPYFILE_FICLONE_FORCE) {
+ SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED);
+ return;
+ }
+
+ overwrite = flags & UV_FS_COPYFILE_EXCL;
+
+ if (CopyFileW(req->file.pathw, req->fs.info.new_pathw, overwrite) == 0) {
+ SET_REQ_WIN32_ERROR(req, GetLastError());
+ return;
+ }
+
+ SET_REQ_RESULT(req, 0);
+}
+
+
static void fs__sendfile(uv_fs_t* req) {
int fd_in = req->file.fd, fd_out = req->fs.info.fd_out;
size_t length = req->fs.info.bufsml[0].len;
@@ -1390,6 +1653,7 @@ static void fs__chmod(uv_fs_t* req) {
static void fs__fchmod(uv_fs_t* req) {
int fd = req->file.fd;
+ int clear_archive_flag;
HANDLE handle;
NTSTATUS nt_status;
IO_STATUS_BLOCK io_status;
@@ -1397,7 +1661,11 @@ static void fs__fchmod(uv_fs_t* req) {
VERIFY_FD(fd, req);
- handle = uv__get_osfhandle(fd);
+ handle = ReOpenFile(uv__get_osfhandle(fd), FILE_WRITE_ATTRIBUTES, 0, 0);
+ if (handle == INVALID_HANDLE_VALUE) {
+ SET_REQ_WIN32_ERROR(req, GetLastError());
+ return;
+ }
nt_status = pNtQueryInformationFile(handle,
&io_status,
@@ -1407,7 +1675,27 @@ static void fs__fchmod(uv_fs_t* req) {
if (!NT_SUCCESS(nt_status)) {
SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status));
- return;
+ goto fchmod_cleanup;
+ }
+
+ /* Test if the Archive attribute is cleared */
+ if ((file_info.FileAttributes & FILE_ATTRIBUTE_ARCHIVE) == 0) {
+ /* Set Archive flag, otherwise setting or clearing the read-only
+ flag will not work */
+ file_info.FileAttributes |= FILE_ATTRIBUTE_ARCHIVE;
+ nt_status = pNtSetInformationFile(handle,
+ &io_status,
+ &file_info,
+ sizeof file_info,
+ FileBasicInformation);
+ if (!NT_SUCCESS(nt_status)) {
+ SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status));
+ goto fchmod_cleanup;
+ }
+ /* Remeber to clear the flag later on */
+ clear_archive_flag = 1;
+ } else {
+ clear_archive_flag = 0;
}
if (req->fs.info.mode & _S_IWRITE) {
@@ -1424,10 +1712,28 @@ static void fs__fchmod(uv_fs_t* req) {
if (!NT_SUCCESS(nt_status)) {
SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status));
- return;
+ goto fchmod_cleanup;
+ }
+
+ if (clear_archive_flag) {
+ file_info.FileAttributes &= ~FILE_ATTRIBUTE_ARCHIVE;
+ if (file_info.FileAttributes == 0) {
+ file_info.FileAttributes = FILE_ATTRIBUTE_NORMAL;
+ }
+ nt_status = pNtSetInformationFile(handle,
+ &io_status,
+ &file_info,
+ sizeof file_info,
+ FileBasicInformation);
+ if (!NT_SUCCESS(nt_status)) {
+ SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status));
+ goto fchmod_cleanup;
+ }
}
SET_REQ_SUCCESS(req);
+fchmod_cleanup:
+ CloseHandle(handle);
}
@@ -1675,25 +1981,42 @@ error:
static void fs__symlink(uv_fs_t* req) {
- WCHAR* pathw = req->file.pathw;
- WCHAR* new_pathw = req->fs.info.new_pathw;
- int flags = req->fs.info.file_flags;
- int result;
+ WCHAR* pathw;
+ WCHAR* new_pathw;
+ int flags;
+ int err;
+ pathw = req->file.pathw;
+ new_pathw = req->fs.info.new_pathw;
- if (flags & UV_FS_SYMLINK_JUNCTION) {
+ if (req->fs.info.file_flags & UV_FS_SYMLINK_JUNCTION) {
fs__create_junction(req, pathw, new_pathw);
- } else if (pCreateSymbolicLinkW) {
- result = pCreateSymbolicLinkW(new_pathw,
- pathw,
- flags & UV_FS_SYMLINK_DIR ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0) ? 0 : -1;
- if (result == -1) {
- SET_REQ_WIN32_ERROR(req, GetLastError());
- } else {
- SET_REQ_RESULT(req, result);
- }
+ return;
+ }
+
+ if (req->fs.info.file_flags & UV_FS_SYMLINK_DIR)
+ flags = SYMBOLIC_LINK_FLAG_DIRECTORY | uv__file_symlink_usermode_flag;
+ else
+ flags = uv__file_symlink_usermode_flag;
+
+ if (CreateSymbolicLinkW(new_pathw, pathw, flags)) {
+ SET_REQ_RESULT(req, 0);
+ return;
+ }
+
+ /* Something went wrong. We will test if it is because of user-mode
+ * symlinks.
+ */
+ err = GetLastError();
+ if (err == ERROR_INVALID_PARAMETER &&
+ flags & SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE) {
+ /* This system does not support user-mode symlinks. We will clear the
+ * unsupported flag and retry.
+ */
+ uv__file_symlink_usermode_flag = 0;
+ fs__symlink(req);
} else {
- SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED);
+ SET_REQ_WIN32_ERROR(req, err);
}
}
@@ -1727,13 +2050,13 @@ static void fs__readlink(uv_fs_t* req) {
}
-static size_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) {
+static ssize_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) {
int r;
DWORD w_realpath_len;
WCHAR* w_realpath_ptr = NULL;
WCHAR* w_realpath_buf;
- w_realpath_len = pGetFinalPathNameByHandleW(handle, NULL, 0, VOLUME_NAME_DOS);
+ w_realpath_len = GetFinalPathNameByHandleW(handle, NULL, 0, VOLUME_NAME_DOS);
if (w_realpath_len == 0) {
return -1;
}
@@ -1745,10 +2068,8 @@ static size_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) {
}
w_realpath_ptr = w_realpath_buf;
- if (pGetFinalPathNameByHandleW(handle,
- w_realpath_ptr,
- w_realpath_len,
- VOLUME_NAME_DOS) == 0) {
+ if (GetFinalPathNameByHandleW(
+ handle, w_realpath_ptr, w_realpath_len, VOLUME_NAME_DOS) == 0) {
uv__free(w_realpath_buf);
SetLastError(ERROR_INVALID_HANDLE);
return -1;
@@ -1780,11 +2101,6 @@ static size_t fs__realpath_handle(HANDLE handle, char** realpath_ptr) {
static void fs__realpath(uv_fs_t* req) {
HANDLE handle;
- if (!pGetFinalPathNameByHandleW) {
- SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED);
- return;
- }
-
handle = CreateFileW(req->file.pathw,
0,
0,
@@ -1819,6 +2135,10 @@ static void fs__fchown(uv_fs_t* req) {
}
+static void fs__lchown(uv_fs_t* req) {
+ req->result = 0;
+}
+
static void uv__fs_work(struct uv__work* w) {
uv_fs_t* req;
@@ -1831,6 +2151,7 @@ static void uv__fs_work(struct uv__work* w) {
XX(CLOSE, close)
XX(READ, read)
XX(WRITE, write)
+ XX(COPYFILE, copyfile)
XX(SENDFILE, sendfile)
XX(STAT, stat)
XX(LSTAT, lstat)
@@ -1849,12 +2170,16 @@ static void uv__fs_work(struct uv__work* w) {
XX(MKDTEMP, mkdtemp)
XX(RENAME, rename)
XX(SCANDIR, scandir)
+ XX(READDIR, readdir)
+ XX(OPENDIR, opendir)
+ XX(CLOSEDIR, closedir)
XX(LINK, link)
XX(SYMLINK, symlink)
XX(READLINK, readlink)
XX(REALPATH, realpath)
XX(CHOWN, chown)
XX(FCHOWN, fchown);
+ XX(LCHOWN, lchown);
default:
assert(!"bad uv_fs_type");
}
@@ -1877,6 +2202,9 @@ static void uv__fs_done(struct uv__work* w, int status) {
void uv_fs_req_cleanup(uv_fs_t* req) {
+ if (req == NULL)
+ return;
+
if (req->flags & UV_FS_CLEANEDUP)
return;
@@ -1886,6 +2214,8 @@ void uv_fs_req_cleanup(uv_fs_t* req) {
if (req->flags & UV_FS_FREE_PTR) {
if (req->fs_type == UV_FS_SCANDIR && req->ptr != NULL)
uv__fs_scandir_cleanup(req);
+ else if (req->fs_type == UV_FS_READDIR)
+ uv__fs_readdir_cleanup(req);
else
uv__free(req->ptr);
}
@@ -1907,8 +2237,7 @@ int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
int mode, uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_OPEN, cb);
-
+ INIT(UV_FS_OPEN);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
@@ -1916,28 +2245,14 @@ int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
req->fs.info.file_flags = flags;
req->fs.info.mode = mode;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__open(req);
- return req->result;
- }
+ POST;
}
int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) {
- uv_fs_req_init(loop, req, UV_FS_CLOSE, cb);
+ INIT(UV_FS_CLOSE);
req->file.fd = fd;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__close(req);
- return req->result;
- }
+ POST;
}
@@ -1948,11 +2263,11 @@ int uv_fs_read(uv_loop_t* loop,
unsigned int nbufs,
int64_t offset,
uv_fs_cb cb) {
+ INIT(UV_FS_READ);
+
if (bufs == NULL || nbufs == 0)
return UV_EINVAL;
- uv_fs_req_init(loop, req, UV_FS_READ, cb);
-
req->file.fd = fd;
req->fs.info.nbufs = nbufs;
@@ -1966,14 +2281,7 @@ int uv_fs_read(uv_loop_t* loop,
memcpy(req->fs.info.bufs, bufs, nbufs * sizeof(*bufs));
req->fs.info.offset = offset;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__read(req);
- return req->result;
- }
+ POST;
}
@@ -1984,11 +2292,11 @@ int uv_fs_write(uv_loop_t* loop,
unsigned int nbufs,
int64_t offset,
uv_fs_cb cb) {
+ INIT(UV_FS_WRITE);
+
if (bufs == NULL || nbufs == 0)
return UV_EINVAL;
- uv_fs_req_init(loop, req, UV_FS_WRITE, cb);
-
req->file.fd = fd;
req->fs.info.nbufs = nbufs;
@@ -2002,14 +2310,7 @@ int uv_fs_write(uv_loop_t* loop,
memcpy(req->fs.info.bufs, bufs, nbufs * sizeof(*bufs));
req->fs.info.offset = offset;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__write(req);
- return req->result;
- }
+ POST;
}
@@ -2017,20 +2318,13 @@ int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_UNLINK, cb);
-
+ INIT(UV_FS_UNLINK);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
}
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__unlink(req);
- return req->result;
- }
+ POST;
}
@@ -2038,22 +2332,14 @@ int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode,
uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_MKDIR, cb);
-
+ INIT(UV_FS_MKDIR);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
}
req->fs.info.mode = mode;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__mkdir(req);
- return req->result;
- }
+ POST;
}
@@ -2061,39 +2347,25 @@ int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl,
uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_MKDTEMP, cb);
-
+ INIT(UV_FS_MKDTEMP);
err = fs__capture_path(req, tpl, NULL, TRUE);
if (err)
return uv_translate_sys_error(err);
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__mkdtemp(req);
- return req->result;
- }
+ POST;
}
int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_RMDIR, cb);
-
+ INIT(UV_FS_RMDIR);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
}
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__rmdir(req);
- return req->result;
- }
+ POST;
}
@@ -2101,43 +2373,67 @@ int uv_fs_scandir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_SCANDIR, cb);
-
+ INIT(UV_FS_SCANDIR);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
}
req->fs.info.file_flags = flags;
+ POST;
+}
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__scandir(req);
- return req->result;
+int uv_fs_opendir(uv_loop_t* loop,
+ uv_fs_t* req,
+ const char* path,
+ uv_fs_cb cb) {
+ int err;
+
+ INIT(UV_FS_OPENDIR);
+ err = fs__capture_path(req, path, NULL, cb != NULL);
+ if (err)
+ return uv_translate_sys_error(err);
+ POST;
+}
+
+int uv_fs_readdir(uv_loop_t* loop,
+ uv_fs_t* req,
+ uv_dir_t* dir,
+ uv_fs_cb cb) {
+ INIT(UV_FS_READDIR);
+
+ if (dir == NULL ||
+ dir->dirents == NULL ||
+ dir->dir_handle == INVALID_HANDLE_VALUE) {
+ return UV_EINVAL;
}
+
+ req->ptr = dir;
+ POST;
}
+int uv_fs_closedir(uv_loop_t* loop,
+ uv_fs_t* req,
+ uv_dir_t* dir,
+ uv_fs_cb cb) {
+ INIT(UV_FS_CLOSEDIR);
+ if (dir == NULL)
+ return UV_EINVAL;
+ req->ptr = dir;
+ POST;
+}
int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path,
const char* new_path, uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_LINK, cb);
-
+ INIT(UV_FS_LINK);
err = fs__capture_path(req, path, new_path, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
}
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__link(req);
- return req->result;
- }
+ POST;
}
@@ -2145,22 +2441,14 @@ int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
const char* new_path, int flags, uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_SYMLINK, cb);
-
+ INIT(UV_FS_SYMLINK);
err = fs__capture_path(req, path, new_path, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
}
req->fs.info.file_flags = flags;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__symlink(req);
- return req->result;
- }
+ POST;
}
@@ -2168,20 +2456,13 @@ int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_READLINK, cb);
-
+ INIT(UV_FS_READLINK);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
}
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__readlink(req);
- return req->result;
- }
+ POST;
}
@@ -2189,24 +2470,18 @@ int uv_fs_realpath(uv_loop_t* loop, uv_fs_t* req, const char* path,
uv_fs_cb cb) {
int err;
- if (!req || !path) {
+ INIT(UV_FS_REALPATH);
+
+ if (!path) {
return UV_EINVAL;
}
- uv_fs_req_init(loop, req, UV_FS_REALPATH, cb);
-
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
}
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__realpath(req);
- return req->result;
- }
+ POST;
}
@@ -2214,88 +2489,66 @@ int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid,
uv_gid_t gid, uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_CHOWN, cb);
-
+ INIT(UV_FS_CHOWN);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
}
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__chown(req);
- return req->result;
- }
+ POST;
}
int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_uid_t uid,
uv_gid_t gid, uv_fs_cb cb) {
- uv_fs_req_init(loop, req, UV_FS_FCHOWN, cb);
+ INIT(UV_FS_FCHOWN);
+ POST;
+}
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__fchown(req);
- return req->result;
+
+int uv_fs_lchown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid,
+ uv_gid_t gid, uv_fs_cb cb) {
+ int err;
+
+ INIT(UV_FS_LCHOWN);
+ err = fs__capture_path(req, path, NULL, cb != NULL);
+ if (err) {
+ return uv_translate_sys_error(err);
}
+ POST;
}
int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_STAT, cb);
-
+ INIT(UV_FS_STAT);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
}
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__stat(req);
- return req->result;
- }
+ POST;
}
int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_LSTAT, cb);
-
+ INIT(UV_FS_LSTAT);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
}
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__lstat(req);
- return req->result;
- }
+ POST;
}
int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) {
- uv_fs_req_init(loop, req, UV_FS_FSTAT, cb);
+ INIT(UV_FS_FSTAT);
req->file.fd = fd;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__fstat(req);
- return req->result;
- }
+ POST;
}
@@ -2303,85 +2556,73 @@ int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path,
const char* new_path, uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_RENAME, cb);
-
+ INIT(UV_FS_RENAME);
err = fs__capture_path(req, path, new_path, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
}
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__rename(req);
- return req->result;
- }
+ POST;
}
int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) {
- uv_fs_req_init(loop, req, UV_FS_FSYNC, cb);
+ INIT(UV_FS_FSYNC);
req->file.fd = fd;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__fsync(req);
- return req->result;
- }
+ POST;
}
int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) {
- uv_fs_req_init(loop, req, UV_FS_FDATASYNC, cb);
+ INIT(UV_FS_FDATASYNC);
req->file.fd = fd;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__fdatasync(req);
- return req->result;
- }
+ POST;
}
int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file fd,
int64_t offset, uv_fs_cb cb) {
- uv_fs_req_init(loop, req, UV_FS_FTRUNCATE, cb);
-
+ INIT(UV_FS_FTRUNCATE);
req->file.fd = fd;
req->fs.info.offset = offset;
+ POST;
+}
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__ftruncate(req);
- return req->result;
+
+int uv_fs_copyfile(uv_loop_t* loop,
+ uv_fs_t* req,
+ const char* path,
+ const char* new_path,
+ int flags,
+ uv_fs_cb cb) {
+ int err;
+
+ INIT(UV_FS_COPYFILE);
+
+ if (flags & ~(UV_FS_COPYFILE_EXCL |
+ UV_FS_COPYFILE_FICLONE |
+ UV_FS_COPYFILE_FICLONE_FORCE)) {
+ return UV_EINVAL;
}
-}
+ err = fs__capture_path(req, path, new_path, cb != NULL);
+
+ if (err)
+ return uv_translate_sys_error(err);
+
+ req->fs.info.file_flags = flags;
+ POST;
+}
int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file fd_out,
uv_file fd_in, int64_t in_offset, size_t length, uv_fs_cb cb) {
- uv_fs_req_init(loop, req, UV_FS_SENDFILE, cb);
-
+ INIT(UV_FS_SENDFILE);
req->file.fd = fd_in;
req->fs.info.fd_out = fd_out;
req->fs.info.offset = in_offset;
req->fs.info.bufsml[0].len = length;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__sendfile(req);
- return req->result;
- }
+ POST;
}
@@ -2392,21 +2633,13 @@ int uv_fs_access(uv_loop_t* loop,
uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_ACCESS, cb);
-
+ INIT(UV_FS_ACCESS);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err)
return uv_translate_sys_error(err);
req->fs.info.mode = flags;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- }
-
- fs__access(req);
- return req->result;
+ POST;
}
@@ -2414,39 +2647,23 @@ int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode,
uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_CHMOD, cb);
-
+ INIT(UV_FS_CHMOD);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
}
req->fs.info.mode = mode;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__chmod(req);
- return req->result;
- }
+ POST;
}
int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file fd, int mode,
uv_fs_cb cb) {
- uv_fs_req_init(loop, req, UV_FS_FCHMOD, cb);
-
+ INIT(UV_FS_FCHMOD);
req->file.fd = fd;
req->fs.info.mode = mode;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__fchmod(req);
- return req->result;
- }
+ POST;
}
@@ -2454,8 +2671,7 @@ int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime,
double mtime, uv_fs_cb cb) {
int err;
- uv_fs_req_init(loop, req, UV_FS_UTIME, cb);
-
+ INIT(UV_FS_UTIME);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
return uv_translate_sys_error(err);
@@ -2463,30 +2679,15 @@ int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime,
req->fs.time.atime = atime;
req->fs.time.mtime = mtime;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__utime(req);
- return req->result;
- }
+ POST;
}
int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file fd, double atime,
double mtime, uv_fs_cb cb) {
- uv_fs_req_init(loop, req, UV_FS_FUTIME, cb);
-
+ INIT(UV_FS_FUTIME);
req->file.fd = fd;
req->fs.time.atime = atime;
req->fs.time.mtime = mtime;
-
- if (cb) {
- QUEUE_FS_TP_JOB(loop, req);
- return 0;
- } else {
- fs__futime(req);
- return req->result;
- }
+ POST;
}
diff --git a/Utilities/cmlibuv/src/win/getaddrinfo.c b/Utilities/cmlibuv/src/win/getaddrinfo.c
index baab83889..dfab860a7 100644
--- a/Utilities/cmlibuv/src/win/getaddrinfo.c
+++ b/Utilities/cmlibuv/src/win/getaddrinfo.c
@@ -24,10 +24,13 @@
#include "uv.h"
#include "internal.h"
#include "req-inl.h"
+#include "idna.h"
/* EAI_* constants. */
#include <winsock2.h>
+/* Needed for ConvertInterfaceIndexToLuid and ConvertInterfaceLuidToNameA */
+#include <iphlpapi.h>
int uv__getaddrinfo_translate_error(int sys_err) {
switch (sys_err) {
@@ -69,10 +72,13 @@ int uv__getaddrinfo_translate_error(int sys_err) {
#endif
-/* adjust size value to be multiple of 4. Use to keep pointer aligned */
-/* Do we need different versions of this for different architectures? */
+/* Adjust size value to be multiple of 4. Use to keep pointer aligned.
+ * Do we need different versions of this for different architectures? */
#define ALIGNED_SIZE(X) ((((X) + 3) >> 2) << 2)
+#ifndef NDIS_IF_MAX_STRING_SIZE
+#define NDIS_IF_MAX_STRING_SIZE IF_MAX_STRING_SIZE
+#endif
static void uv__getaddrinfo_work(struct uv__work* w) {
uv_getaddrinfo_t* req;
@@ -119,8 +125,7 @@ static void uv__getaddrinfo_done(struct uv__work* w, int status) {
}
if (req->retcode == 0) {
- /* convert addrinfoW to addrinfo */
- /* first calculate required length */
+ /* Convert addrinfoW to addrinfo. First calculate required length. */
addrinfow_ptr = req->addrinfow;
while (addrinfow_ptr != NULL) {
addrinfo_len += addrinfo_struct_len +
@@ -255,11 +260,13 @@ int uv_getaddrinfo(uv_loop_t* loop,
const char* node,
const char* service,
const struct addrinfo* hints) {
+ char hostname_ascii[256];
int nodesize = 0;
int servicesize = 0;
int hintssize = 0;
char* alloc_ptr = NULL;
int err;
+ long rc;
if (req == NULL || (node == NULL && service == NULL)) {
return UV_EINVAL;
@@ -273,12 +280,19 @@ int uv_getaddrinfo(uv_loop_t* loop,
/* calculate required memory size for all input values */
if (node != NULL) {
- nodesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, 0, node, -1, NULL, 0) *
- sizeof(WCHAR));
+ rc = uv__idna_toascii(node,
+ node + strlen(node),
+ hostname_ascii,
+ hostname_ascii + sizeof(hostname_ascii));
+ if (rc < 0)
+ return rc;
+ nodesize = ALIGNED_SIZE(MultiByteToWideChar(CP_UTF8, 0, hostname_ascii,
+ -1, NULL, 0) * sizeof(WCHAR));
if (nodesize == 0) {
err = GetLastError();
goto error;
}
+ node = hostname_ascii;
}
if (service != NULL) {
@@ -308,8 +322,8 @@ int uv_getaddrinfo(uv_loop_t* loop,
/* save alloc_ptr now so we can free if error */
req->alloc = (void*)alloc_ptr;
- /* convert node string to UTF16 into allocated memory and save pointer in */
- /* the request. */
+ /* Convert node string to UTF16 into allocated memory and save pointer in the
+ * request. */
if (node != NULL) {
req->node = (WCHAR*)alloc_ptr;
if (MultiByteToWideChar(CP_UTF8,
@@ -326,8 +340,8 @@ int uv_getaddrinfo(uv_loop_t* loop,
req->node = NULL;
}
- /* convert service string to UTF16 into allocated memory and save pointer */
- /* in the req. */
+ /* Convert service string to UTF16 into allocated memory and save pointer in
+ * the req. */
if (service != NULL) {
req->service = (WCHAR*)alloc_ptr;
if (MultiByteToWideChar(CP_UTF8,
@@ -364,6 +378,7 @@ int uv_getaddrinfo(uv_loop_t* loop,
if (getaddrinfo_cb) {
uv__work_submit(loop,
&req->work_req,
+ UV__WORK_SLOW_IO,
uv__getaddrinfo_work,
uv__getaddrinfo_done);
return 0;
@@ -380,3 +395,69 @@ error:
}
return uv_translate_sys_error(err);
}
+
+int uv_if_indextoname(unsigned int ifindex, char* buffer, size_t* size) {
+ NET_LUID luid;
+ wchar_t wname[NDIS_IF_MAX_STRING_SIZE + 1]; /* Add one for the NUL. */
+ DWORD bufsize;
+ int r;
+
+ if (buffer == NULL || size == NULL || *size == 0)
+ return UV_EINVAL;
+
+ r = ConvertInterfaceIndexToLuid(ifindex, &luid);
+
+ if (r != 0)
+ return uv_translate_sys_error(r);
+
+ r = ConvertInterfaceLuidToNameW(&luid, wname, ARRAY_SIZE(wname));
+
+ if (r != 0)
+ return uv_translate_sys_error(r);
+
+ /* Check how much space we need */
+ bufsize = WideCharToMultiByte(CP_UTF8, 0, wname, -1, NULL, 0, NULL, NULL);
+
+ if (bufsize == 0) {
+ return uv_translate_sys_error(GetLastError());
+ } else if (bufsize > *size) {
+ *size = bufsize;
+ return UV_ENOBUFS;
+ }
+
+ /* Convert to UTF-8 */
+ bufsize = WideCharToMultiByte(CP_UTF8,
+ 0,
+ wname,
+ -1,
+ buffer,
+ *size,
+ NULL,
+ NULL);
+
+ if (bufsize == 0)
+ return uv_translate_sys_error(GetLastError());
+
+ *size = bufsize - 1;
+ return 0;
+}
+
+int uv_if_indextoiid(unsigned int ifindex, char* buffer, size_t* size) {
+ int r;
+
+ if (buffer == NULL || size == NULL || *size == 0)
+ return UV_EINVAL;
+
+ r = snprintf(buffer, *size, "%d", ifindex);
+
+ if (r < 0)
+ return uv_translate_sys_error(r);
+
+ if (r >= (int) *size) {
+ *size = r + 1;
+ return UV_ENOBUFS;
+ }
+
+ *size = r;
+ return 0;
+}
diff --git a/Utilities/cmlibuv/src/win/getnameinfo.c b/Utilities/cmlibuv/src/win/getnameinfo.c
index 9f10cd2a5..b3773380c 100644
--- a/Utilities/cmlibuv/src/win/getnameinfo.c
+++ b/Utilities/cmlibuv/src/win/getnameinfo.c
@@ -42,7 +42,7 @@ static void uv__getnameinfo_work(struct uv__work* w) {
uv_getnameinfo_t* req;
WCHAR host[NI_MAXHOST];
WCHAR service[NI_MAXSERV];
- int ret = 0;
+ int ret;
req = container_of(w, uv_getnameinfo_t, work_req);
if (GetNameInfoW((struct sockaddr*)&req->storage,
@@ -53,27 +53,34 @@ static void uv__getnameinfo_work(struct uv__work* w) {
ARRAY_SIZE(service),
req->flags)) {
ret = WSAGetLastError();
+ req->retcode = uv__getaddrinfo_translate_error(ret);
+ return;
+ }
+
+ ret = WideCharToMultiByte(CP_UTF8,
+ 0,
+ host,
+ -1,
+ req->host,
+ sizeof(req->host),
+ NULL,
+ NULL);
+ if (ret == 0) {
+ req->retcode = uv_translate_sys_error(GetLastError());
+ return;
+ }
+
+ ret = WideCharToMultiByte(CP_UTF8,
+ 0,
+ service,
+ -1,
+ req->service,
+ sizeof(req->service),
+ NULL,
+ NULL);
+ if (ret == 0) {
+ req->retcode = uv_translate_sys_error(GetLastError());
}
- req->retcode = uv__getaddrinfo_translate_error(ret);
-
- /* convert results to UTF-8 */
- WideCharToMultiByte(CP_UTF8,
- 0,
- host,
- -1,
- req->host,
- sizeof(req->host),
- NULL,
- NULL);
-
- WideCharToMultiByte(CP_UTF8,
- 0,
- service,
- -1,
- req->service,
- sizeof(req->service),
- NULL,
- NULL);
}
@@ -138,6 +145,7 @@ int uv_getnameinfo(uv_loop_t* loop,
if (getnameinfo_cb) {
uv__work_submit(loop,
&req->work_req,
+ UV__WORK_SLOW_IO,
uv__getnameinfo_work,
uv__getnameinfo_done);
return 0;
diff --git a/Utilities/cmlibuv/src/win/handle-inl.h b/Utilities/cmlibuv/src/win/handle-inl.h
index 8d0334cc5..82c657d57 100644
--- a/Utilities/cmlibuv/src/win/handle-inl.h
+++ b/Utilities/cmlibuv/src/win/handle-inl.h
@@ -32,7 +32,7 @@
#define DECREASE_ACTIVE_COUNT(loop, handle) \
do { \
if (--(handle)->activecnt == 0 && \
- !((handle)->flags & UV__HANDLE_CLOSING)) { \
+ !((handle)->flags & UV_HANDLE_CLOSING)) { \
uv__handle_stop((handle)); \
} \
assert((handle)->activecnt >= 0); \
@@ -53,7 +53,7 @@
assert(handle->reqs_pending > 0); \
handle->reqs_pending--; \
\
- if (handle->flags & UV__HANDLE_CLOSING && \
+ if (handle->flags & UV_HANDLE_CLOSING && \
handle->reqs_pending == 0) { \
uv_want_endgame(loop, (uv_handle_t*)handle); \
} \
@@ -62,14 +62,14 @@
#define uv__handle_closing(handle) \
do { \
- assert(!((handle)->flags & UV__HANDLE_CLOSING)); \
+ assert(!((handle)->flags & UV_HANDLE_CLOSING)); \
\
- if (!(((handle)->flags & UV__HANDLE_ACTIVE) && \
- ((handle)->flags & UV__HANDLE_REF))) \
+ if (!(((handle)->flags & UV_HANDLE_ACTIVE) && \
+ ((handle)->flags & UV_HANDLE_REF))) \
uv__active_handle_add((uv_handle_t*) (handle)); \
\
- (handle)->flags |= UV__HANDLE_CLOSING; \
- (handle)->flags &= ~UV__HANDLE_ACTIVE; \
+ (handle)->flags |= UV_HANDLE_CLOSING; \
+ (handle)->flags &= ~UV_HANDLE_ACTIVE; \
} while (0)
@@ -126,7 +126,8 @@ INLINE static void uv_process_endgames(uv_loop_t* loop) {
break;
case UV_TIMER:
- uv_timer_endgame(loop, (uv_timer_t*) handle);
+ uv__timer_close((uv_timer_t*) handle);
+ uv__handle_close(handle);
break;
case UV_PREPARE:
@@ -164,10 +165,10 @@ INLINE static void uv_process_endgames(uv_loop_t* loop) {
INLINE static HANDLE uv__get_osfhandle(int fd)
{
- /* _get_osfhandle() raises an assert in debug builds if the FD is invalid. */
- /* But it also correctly checks the FD and returns INVALID_HANDLE_VALUE */
- /* for invalid FDs in release builds (or if you let the assert continue). */
- /* So this wrapper function disables asserts when calling _get_osfhandle. */
+ /* _get_osfhandle() raises an assert in debug builds if the FD is invalid.
+ * But it also correctly checks the FD and returns INVALID_HANDLE_VALUE for
+ * invalid FDs in release builds (or if you let the assert continue). So this
+ * wrapper function disables asserts when calling _get_osfhandle. */
HANDLE handle;
UV_BEGIN_DISABLE_CRT_ASSERT();
diff --git a/Utilities/cmlibuv/src/win/handle.c b/Utilities/cmlibuv/src/win/handle.c
index 72b49d979..61e4df61b 100644
--- a/Utilities/cmlibuv/src/win/handle.c
+++ b/Utilities/cmlibuv/src/win/handle.c
@@ -59,15 +59,15 @@ uv_handle_type uv_guess_handle(uv_file file) {
int uv_is_active(const uv_handle_t* handle) {
- return (handle->flags & UV__HANDLE_ACTIVE) &&
- !(handle->flags & UV__HANDLE_CLOSING);
+ return (handle->flags & UV_HANDLE_ACTIVE) &&
+ !(handle->flags & UV_HANDLE_CLOSING);
}
void uv_close(uv_handle_t* handle, uv_close_cb cb) {
uv_loop_t* loop = handle->loop;
- if (handle->flags & UV__HANDLE_CLOSING) {
+ if (handle->flags & UV_HANDLE_CLOSING) {
assert(0);
return;
}
@@ -139,7 +139,6 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) {
case UV_FS_POLL:
uv__fs_poll_close((uv_fs_poll_t*) handle);
uv__handle_closing(handle);
- uv_want_endgame(loop, handle);
return;
default:
@@ -150,5 +149,14 @@ void uv_close(uv_handle_t* handle, uv_close_cb cb) {
int uv_is_closing(const uv_handle_t* handle) {
- return !!(handle->flags & (UV__HANDLE_CLOSING | UV_HANDLE_CLOSED));
+ return !!(handle->flags & (UV_HANDLE_CLOSING | UV_HANDLE_CLOSED));
+}
+
+
+uv_os_fd_t uv_get_osfhandle(int fd) {
+ return uv__get_osfhandle(fd);
+}
+
+int uv_open_osfhandle(uv_os_fd_t os_fd) {
+ return _open_osfhandle((intptr_t) os_fd, 0);
}
diff --git a/Utilities/cmlibuv/src/win/internal.h b/Utilities/cmlibuv/src/win/internal.h
index 83601d57a..f7d8ccfd9 100644
--- a/Utilities/cmlibuv/src/win/internal.h
+++ b/Utilities/cmlibuv/src/win/internal.h
@@ -29,7 +29,7 @@
#include "uv.h"
#include "../uv-common.h"
-#include "tree.h"
+#include "uv/tree.h"
#include "winapi.h"
#include "winsock.h"
@@ -62,77 +62,19 @@ extern UV_THREAD_LOCAL int uv__crt_assert_enabled;
#endif
/*
- * Handles
- * (also see handle-inl.h)
- */
-
-/* Used by all handles. */
-#define UV_HANDLE_CLOSED 0x00000002
-#define UV_HANDLE_ENDGAME_QUEUED 0x00000008
-
-/* uv-common.h: #define UV__HANDLE_CLOSING 0x00000001 */
-/* uv-common.h: #define UV__HANDLE_ACTIVE 0x00000040 */
-/* uv-common.h: #define UV__HANDLE_REF 0x00000020 */
-/* uv-common.h: #define UV_HANDLE_INTERNAL 0x00000080 */
-
-/* Used by streams and UDP handles. */
-#define UV_HANDLE_READING 0x00000100
-#define UV_HANDLE_BOUND 0x00000200
-#define UV_HANDLE_LISTENING 0x00000800
-#define UV_HANDLE_CONNECTION 0x00001000
-#define UV_HANDLE_READABLE 0x00008000
-#define UV_HANDLE_WRITABLE 0x00010000
-#define UV_HANDLE_READ_PENDING 0x00020000
-#define UV_HANDLE_SYNC_BYPASS_IOCP 0x00040000
-#define UV_HANDLE_ZERO_READ 0x00080000
-#define UV_HANDLE_EMULATE_IOCP 0x00100000
-#define UV_HANDLE_BLOCKING_WRITES 0x00200000
-#define UV_HANDLE_CANCELLATION_PENDING 0x00400000
-
-/* Used by uv_tcp_t and uv_udp_t handles */
-#define UV_HANDLE_IPV6 0x01000000
-
-/* Only used by uv_tcp_t handles. */
-#define UV_HANDLE_TCP_NODELAY 0x02000000
-#define UV_HANDLE_TCP_KEEPALIVE 0x04000000
-#define UV_HANDLE_TCP_SINGLE_ACCEPT 0x08000000
-#define UV_HANDLE_TCP_ACCEPT_STATE_CHANGING 0x10000000
-#define UV_HANDLE_TCP_SOCKET_CLOSED 0x20000000
-#define UV_HANDLE_SHARED_TCP_SOCKET 0x40000000
-
-/* Only used by uv_pipe_t handles. */
-#define UV_HANDLE_NON_OVERLAPPED_PIPE 0x01000000
-#define UV_HANDLE_PIPESERVER 0x02000000
-#define UV_HANDLE_PIPE_READ_CANCELABLE 0x04000000
-
-/* Only used by uv_tty_t handles. */
-#define UV_HANDLE_TTY_READABLE 0x01000000
-#define UV_HANDLE_TTY_RAW 0x02000000
-#define UV_HANDLE_TTY_SAVED_POSITION 0x04000000
-#define UV_HANDLE_TTY_SAVED_ATTRIBUTES 0x08000000
-
-/* Only used by uv_poll_t handles. */
-#define UV_HANDLE_POLL_SLOW 0x02000000
-
-
-/*
- * Requests: see req-inl.h
- */
-
-
-/*
- * Streams: see stream-inl.h
- */
-
-
-/*
* TCP
*/
+typedef enum {
+ UV__IPC_SOCKET_XFER_NONE = 0,
+ UV__IPC_SOCKET_XFER_TCP_CONNECTION,
+ UV__IPC_SOCKET_XFER_TCP_SERVER
+} uv__ipc_socket_xfer_type_t;
+
typedef struct {
WSAPROTOCOL_INFOW socket_info;
- int delayed_error;
-} uv__ipc_socket_info_ex;
+ uint32_t delayed_error;
+} uv__ipc_socket_xfer_info_t;
int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb);
int uv_tcp_accept(uv_tcp_t* server, uv_tcp_t* client);
@@ -154,11 +96,13 @@ void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle,
void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp);
void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle);
-int uv_tcp_import(uv_tcp_t* tcp, uv__ipc_socket_info_ex* socket_info_ex,
- int tcp_connection);
-
-int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid,
- LPWSAPROTOCOL_INFOW protocol_info);
+int uv__tcp_xfer_export(uv_tcp_t* handle,
+ int pid,
+ uv__ipc_socket_xfer_type_t* xfer_type,
+ uv__ipc_socket_xfer_info_t* xfer_info);
+int uv__tcp_xfer_import(uv_tcp_t* tcp,
+ uv__ipc_socket_xfer_type_t xfer_type,
+ uv__ipc_socket_xfer_info_t* xfer_info);
/*
@@ -182,14 +126,14 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb);
int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client);
int uv_pipe_read_start(uv_pipe_t* handle, uv_alloc_cb alloc_cb,
uv_read_cb read_cb);
-int uv_pipe_write(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle,
- const uv_buf_t bufs[], unsigned int nbufs, uv_write_cb cb);
-int uv_pipe_write2(uv_loop_t* loop, uv_write_t* req, uv_pipe_t* handle,
- const uv_buf_t bufs[], unsigned int nbufs, uv_stream_t* send_handle,
- uv_write_cb cb);
-void uv__pipe_pause_read(uv_pipe_t* handle);
-void uv__pipe_unpause_read(uv_pipe_t* handle);
-void uv__pipe_stop_read(uv_pipe_t* handle);
+void uv__pipe_read_stop(uv_pipe_t* handle);
+int uv__pipe_write(uv_loop_t* loop,
+ uv_write_t* req,
+ uv_pipe_t* handle,
+ const uv_buf_t bufs[],
+ size_t nbufs,
+ uv_stream_t* send_handle,
+ uv_write_cb cb);
void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle,
uv_req_t* req);
@@ -225,10 +169,16 @@ void uv_process_tty_read_req(uv_loop_t* loop, uv_tty_t* handle,
uv_req_t* req);
void uv_process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle,
uv_write_t* req);
-/* TODO: remove me */
+/*
+ * uv_process_tty_accept_req() is a stub to keep DELEGATE_STREAM_REQ working
+ * TODO: find a way to remove it
+ */
void uv_process_tty_accept_req(uv_loop_t* loop, uv_tty_t* handle,
uv_req_t* raw_req);
-/* TODO: remove me */
+/*
+ * uv_process_tty_connect_req() is a stub to keep DELEGATE_STREAM_REQ working
+ * TODO: find a way to remove it
+ */
void uv_process_tty_connect_req(uv_loop_t* loop, uv_tty_t* handle,
uv_connect_t* req);
@@ -246,15 +196,6 @@ void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle);
/*
- * Timers
- */
-void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle);
-
-DWORD uv__next_timeout(const uv_loop_t* loop);
-void uv_process_timers(uv_loop_t* loop);
-
-
-/*
* Loop watchers
*/
void uv_loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle);
@@ -330,13 +271,19 @@ void uv__fs_poll_endgame(uv_loop_t* loop, uv_fs_poll_t* handle);
void uv__util_init(void);
uint64_t uv__hrtime(double scale);
-int uv_parent_pid(void);
-int uv_current_pid(void);
__declspec(noreturn) void uv_fatal_error(const int errorno, const char* syscall);
int uv__getpwuid_r(uv_passwd_t* pwd);
int uv__convert_utf16_to_utf8(const WCHAR* utf16, int utf16len, char** utf8);
int uv__convert_utf8_to_utf16(const char* utf8, int utf8len, WCHAR** utf16);
+typedef int (WINAPI *uv__peersockfunc)(SOCKET, struct sockaddr*, int*);
+
+int uv__getsockpeername(const uv_handle_t* handle,
+ uv__peersockfunc func,
+ struct sockaddr* name,
+ int* namelen,
+ int delayed_error);
+
/*
* Process stdio handles.
diff --git a/Utilities/cmlibuv/src/win/loop-watcher.c b/Utilities/cmlibuv/src/win/loop-watcher.c
index 20e4509f8..ad7fbea16 100644
--- a/Utilities/cmlibuv/src/win/loop-watcher.c
+++ b/Utilities/cmlibuv/src/win/loop-watcher.c
@@ -27,7 +27,7 @@
void uv_loop_watcher_endgame(uv_loop_t* loop, uv_handle_t* handle) {
- if (handle->flags & UV__HANDLE_CLOSING) {
+ if (handle->flags & UV_HANDLE_CLOSING) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
handle->flags |= UV_HANDLE_CLOSED;
uv__handle_close(handle);
diff --git a/Utilities/cmlibuv/src/win/pipe.c b/Utilities/cmlibuv/src/win/pipe.c
index edf300212..277f6497a 100644
--- a/Utilities/cmlibuv/src/win/pipe.c
+++ b/Utilities/cmlibuv/src/win/pipe.c
@@ -21,27 +21,19 @@
#include <assert.h>
#include <io.h>
-#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
-#include "uv.h"
-#include "internal.h"
#include "handle-inl.h"
-#include "stream-inl.h"
+#include "internal.h"
#include "req-inl.h"
+#include "stream-inl.h"
+#include "uv-common.h"
+#include "uv.h"
-typedef struct uv__ipc_queue_item_s uv__ipc_queue_item_t;
-
-struct uv__ipc_queue_item_s {
- /*
- * NOTE: It is important for socket_info_ex to be the first field,
- * because we will we assigning it to the pending_ipc_info.socket_info
- */
- uv__ipc_socket_info_ex socket_info_ex;
- QUEUE member;
- int tcp_connection;
-};
+#include <aclapi.h>
+#include <accctrl.h>
/* A zero-size buffer for use by uv_pipe_read */
static char uv_zero_[] = "";
@@ -49,8 +41,8 @@ static char uv_zero_[] = "";
/* Null uv_buf_t */
static const uv_buf_t uv_null_buf_ = { 0, NULL };
-/* The timeout that the pipe will wait for the remote end to write data */
-/* when the local ends wants to shut it down. */
+/* The timeout that the pipe will wait for the remote end to write data when
+ * the local ends wants to shut it down. */
static const int64_t eof_timeout = 50; /* ms */
static const int default_pending_pipe_instances = 4;
@@ -59,22 +51,44 @@ static const int default_pending_pipe_instances = 4;
static char pipe_prefix[] = "\\\\?\\pipe";
static const int pipe_prefix_len = sizeof(pipe_prefix) - 1;
-/* IPC protocol flags. */
-#define UV_IPC_RAW_DATA 0x0001
-#define UV_IPC_TCP_SERVER 0x0002
-#define UV_IPC_TCP_CONNECTION 0x0004
+/* IPC incoming xfer queue item. */
+typedef struct {
+ uv__ipc_socket_xfer_type_t xfer_type;
+ uv__ipc_socket_xfer_info_t xfer_info;
+ QUEUE member;
+} uv__ipc_xfer_queue_item_t;
+
+/* IPC frame header flags. */
+/* clang-format off */
+enum {
+ UV__IPC_FRAME_HAS_DATA = 0x01,
+ UV__IPC_FRAME_HAS_SOCKET_XFER = 0x02,
+ UV__IPC_FRAME_XFER_IS_TCP_CONNECTION = 0x04,
+ /* These are combinations of the flags above. */
+ UV__IPC_FRAME_XFER_FLAGS = 0x06,
+ UV__IPC_FRAME_VALID_FLAGS = 0x07
+};
+/* clang-format on */
/* IPC frame header. */
typedef struct {
- int flags;
- uint64_t raw_data_length;
-} uv_ipc_frame_header_t;
-
-/* IPC frame, which contains an imported TCP socket stream. */
+ uint32_t flags;
+ uint32_t reserved1; /* Ignored. */
+ uint32_t data_length; /* Must be zero if there is no data. */
+ uint32_t reserved2; /* Must be zero. */
+} uv__ipc_frame_header_t;
+
+/* To implement the IPC protocol correctly, these structures must have exactly
+ * the right size. */
+STATIC_ASSERT(sizeof(uv__ipc_frame_header_t) == 16);
+STATIC_ASSERT(sizeof(uv__ipc_socket_xfer_info_t) == 632);
+
+/* Coalesced write request. */
typedef struct {
- uv_ipc_frame_header_t header;
- uv__ipc_socket_info_ex socket_info_ex;
-} uv_ipc_frame_uv_stream;
+ uv_write_t req; /* Internal heap-allocated write request. */
+ uv_write_t* user_req; /* Pointer to user-specified uv_write_t. */
+} uv__coalesced_write_t;
+
static void eof_timer_init(uv_pipe_t* pipe);
static void eof_timer_start(uv_pipe_t* pipe);
@@ -95,15 +109,12 @@ int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) {
handle->reqs_pending = 0;
handle->handle = INVALID_HANDLE_VALUE;
handle->name = NULL;
- handle->pipe.conn.ipc_pid = 0;
- handle->pipe.conn.remaining_ipc_rawdata_bytes = 0;
- QUEUE_INIT(&handle->pipe.conn.pending_ipc_info.queue);
- handle->pipe.conn.pending_ipc_info.queue_len = 0;
+ handle->pipe.conn.ipc_remote_pid = 0;
+ handle->pipe.conn.ipc_data_frame.payload_remaining = 0;
+ QUEUE_INIT(&handle->pipe.conn.ipc_xfer_queue);
+ handle->pipe.conn.ipc_xfer_queue_length = 0;
handle->ipc = ipc;
handle->pipe.conn.non_overlapped_writes_tail = NULL;
- handle->pipe.conn.readfile_thread = NULL;
-
- UV_REQ_INIT(&handle->pipe.conn.ipc_header_write_req, UV_UNKNOWN_REQ);
return 0;
}
@@ -114,10 +125,9 @@ static void uv_pipe_connection_init(uv_pipe_t* handle) {
handle->read_req.data = handle;
handle->pipe.conn.eof_timer = NULL;
assert(!(handle->flags & UV_HANDLE_PIPESERVER));
- if (pCancelSynchronousIo &&
- handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) {
- uv_mutex_init(&handle->pipe.conn.readfile_mutex);
- handle->flags |= UV_HANDLE_PIPE_READ_CANCELABLE;
+ if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) {
+ handle->pipe.conn.readfile_thread_handle = NULL;
+ InitializeCriticalSection(&handle->pipe.conn.readfile_thread_lock);
}
}
@@ -202,7 +212,7 @@ int uv_stdio_pipe_server(uv_loop_t* loop, uv_pipe_t* handle, DWORD access,
uv_unique_pipe_name(ptr, name, nameSize);
pipeHandle = CreateNamedPipeA(name,
- access | FILE_FLAG_OVERLAPPED | FILE_FLAG_FIRST_PIPE_INSTANCE,
+ access | FILE_FLAG_OVERLAPPED | FILE_FLAG_FIRST_PIPE_INSTANCE | WRITE_DAC,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, 1, 65536, 65536, 0,
NULL);
@@ -344,12 +354,7 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) {
NTSTATUS nt_status;
IO_STATUS_BLOCK io_status;
FILE_PIPE_LOCAL_INFORMATION pipe_info;
- uv__ipc_queue_item_t* item;
-
- if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) {
- handle->flags &= ~UV_HANDLE_PIPE_READ_CANCELABLE;
- uv_mutex_destroy(&handle->pipe.conn.readfile_mutex);
- }
+ uv__ipc_xfer_queue_item_t* xfer_queue_item;
if ((handle->flags & UV_HANDLE_CONNECTION) &&
handle->stream.conn.shutdown_req != NULL &&
@@ -359,7 +364,7 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) {
/* Clear the shutdown_req field so we don't go here again. */
handle->stream.conn.shutdown_req = NULL;
- if (handle->flags & UV__HANDLE_CLOSING) {
+ if (handle->flags & UV_HANDLE_CLOSING) {
UNREGISTER_HANDLE_REQ(loop, handle, req);
/* Already closing. Cancel the shutdown. */
@@ -420,33 +425,33 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) {
}
}
- if (handle->flags & UV__HANDLE_CLOSING &&
+ if (handle->flags & UV_HANDLE_CLOSING &&
handle->reqs_pending == 0) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
if (handle->flags & UV_HANDLE_CONNECTION) {
/* Free pending sockets */
- while (!QUEUE_EMPTY(&handle->pipe.conn.pending_ipc_info.queue)) {
+ while (!QUEUE_EMPTY(&handle->pipe.conn.ipc_xfer_queue)) {
QUEUE* q;
SOCKET socket;
- q = QUEUE_HEAD(&handle->pipe.conn.pending_ipc_info.queue);
+ q = QUEUE_HEAD(&handle->pipe.conn.ipc_xfer_queue);
QUEUE_REMOVE(q);
- item = QUEUE_DATA(q, uv__ipc_queue_item_t, member);
+ xfer_queue_item = QUEUE_DATA(q, uv__ipc_xfer_queue_item_t, member);
/* Materialize socket and close it */
socket = WSASocketW(FROM_PROTOCOL_INFO,
FROM_PROTOCOL_INFO,
FROM_PROTOCOL_INFO,
- &item->socket_info_ex.socket_info,
+ &xfer_queue_item->xfer_info.socket_info,
0,
WSA_FLAG_OVERLAPPED);
- uv__free(item);
+ uv__free(xfer_queue_item);
if (socket != INVALID_SOCKET)
closesocket(socket);
}
- handle->pipe.conn.pending_ipc_info.queue_len = 0;
+ handle->pipe.conn.ipc_xfer_queue_length = 0;
if (handle->flags & UV_HANDLE_EMULATE_IOCP) {
if (handle->read_req.wait_handle != INVALID_HANDLE_VALUE) {
@@ -458,6 +463,9 @@ void uv_pipe_endgame(uv_loop_t* loop, uv_pipe_t* handle) {
handle->read_req.event_handle = NULL;
}
}
+
+ if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE)
+ DeleteCriticalSection(&handle->pipe.conn.readfile_thread_lock);
}
if (handle->flags & UV_HANDLE_PIPESERVER) {
@@ -534,7 +542,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
*/
handle->pipe.serv.accept_reqs[0].pipeHandle = CreateNamedPipeW(handle->name,
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED |
- FILE_FLAG_FIRST_PIPE_INSTANCE,
+ FILE_FLAG_FIRST_PIPE_INSTANCE | WRITE_DAC,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES, 65536, 65536, 0, NULL);
@@ -592,8 +600,8 @@ static DWORD WINAPI pipe_connect_thread_proc(void* parameter) {
loop = handle->loop;
assert(loop);
- /* We're here because CreateFile on a pipe returned ERROR_PIPE_BUSY. */
- /* We wait for the pipe to become available with WaitNamedPipe. */
+ /* We're here because CreateFile on a pipe returned ERROR_PIPE_BUSY. We wait
+ * for the pipe to become available with WaitNamedPipe. */
while (WaitNamedPipeW(handle->name, 30000)) {
/* The pipe is now available, try to connect. */
pipeHandle = open_named_pipe(handle->name, &duplex_flags);
@@ -703,48 +711,68 @@ error:
}
-void uv__pipe_pause_read(uv_pipe_t* handle) {
- if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) {
- /* Pause the ReadFile task briefly, to work
- around the Windows kernel bug that causes
- any access to a NamedPipe to deadlock if
- any process has called ReadFile */
- HANDLE h;
- uv_mutex_lock(&handle->pipe.conn.readfile_mutex);
- h = handle->pipe.conn.readfile_thread;
- while (h) {
- /* spinlock: we expect this to finish quickly,
- or we are probably about to deadlock anyways
- (in the kernel), so it doesn't matter */
- pCancelSynchronousIo(h);
- SwitchToThread(); /* yield thread control briefly */
- h = handle->pipe.conn.readfile_thread;
- }
- }
-}
+void uv__pipe_interrupt_read(uv_pipe_t* handle) {
+ BOOL r;
+ if (!(handle->flags & UV_HANDLE_READ_PENDING))
+ return; /* No pending reads. */
+ if (handle->flags & UV_HANDLE_CANCELLATION_PENDING)
+ return; /* Already cancelled. */
+ if (handle->handle == INVALID_HANDLE_VALUE)
+ return; /* Pipe handle closed. */
+
+ if (!(handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE)) {
+ /* Cancel asynchronous read. */
+ r = CancelIoEx(handle->handle, &handle->read_req.u.io.overlapped);
+ assert(r || GetLastError() == ERROR_NOT_FOUND);
+
+ } else {
+ /* Cancel synchronous read (which is happening in the thread pool). */
+ HANDLE thread;
+ volatile HANDLE* thread_ptr = &handle->pipe.conn.readfile_thread_handle;
-void uv__pipe_unpause_read(uv_pipe_t* handle) {
- if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) {
- uv_mutex_unlock(&handle->pipe.conn.readfile_mutex);
+ EnterCriticalSection(&handle->pipe.conn.readfile_thread_lock);
+
+ thread = *thread_ptr;
+ if (thread == NULL) {
+ /* The thread pool thread has not yet reached the point of blocking, we
+ * can pre-empt it by setting thread_handle to INVALID_HANDLE_VALUE. */
+ *thread_ptr = INVALID_HANDLE_VALUE;
+
+ } else {
+ /* Spin until the thread has acknowledged (by setting the thread to
+ * INVALID_HANDLE_VALUE) that it is past the point of blocking. */
+ while (thread != INVALID_HANDLE_VALUE) {
+ r = CancelSynchronousIo(thread);
+ assert(r || GetLastError() == ERROR_NOT_FOUND);
+ SwitchToThread(); /* Yield thread. */
+ thread = *thread_ptr;
+ }
+ }
+
+ LeaveCriticalSection(&handle->pipe.conn.readfile_thread_lock);
}
+
+ /* Set flag to indicate that read has been cancelled. */
+ handle->flags |= UV_HANDLE_CANCELLATION_PENDING;
}
-void uv__pipe_stop_read(uv_pipe_t* handle) {
+void uv__pipe_read_stop(uv_pipe_t* handle) {
handle->flags &= ~UV_HANDLE_READING;
- uv__pipe_pause_read((uv_pipe_t*)handle);
- uv__pipe_unpause_read((uv_pipe_t*)handle);
+ DECREASE_ACTIVE_COUNT(handle->loop, handle);
+
+ uv__pipe_interrupt_read(handle);
}
-/* Cleans up uv_pipe_t (server or connection) and all resources associated */
-/* with it. */
+/* Cleans up uv_pipe_t (server or connection) and all resources associated with
+ * it. */
void uv_pipe_cleanup(uv_loop_t* loop, uv_pipe_t* handle) {
int i;
HANDLE pipeHandle;
- uv__pipe_stop_read(handle);
+ uv__pipe_interrupt_read(handle);
if (handle->name) {
uv__free(handle->name);
@@ -803,7 +831,7 @@ static void uv_pipe_queue_accept(uv_loop_t* loop, uv_pipe_t* handle,
assert(req->pipeHandle == INVALID_HANDLE_VALUE);
req->pipeHandle = CreateNamedPipeW(handle->name,
- PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
+ PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | WRITE_DAC,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
PIPE_UNLIMITED_INSTANCES, 65536, 65536, 0, NULL);
@@ -844,6 +872,7 @@ static void uv_pipe_queue_accept(uv_loop_t* loop, uv_pipe_t* handle,
return;
}
+ /* Wait for completion via IOCP */
handle->reqs_pending++;
}
@@ -853,23 +882,22 @@ int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client) {
uv_pipe_t* pipe_client;
uv_pipe_accept_t* req;
QUEUE* q;
- uv__ipc_queue_item_t* item;
+ uv__ipc_xfer_queue_item_t* item;
int err;
if (server->ipc) {
- if (QUEUE_EMPTY(&server->pipe.conn.pending_ipc_info.queue)) {
+ if (QUEUE_EMPTY(&server->pipe.conn.ipc_xfer_queue)) {
/* No valid pending sockets. */
return WSAEWOULDBLOCK;
}
- q = QUEUE_HEAD(&server->pipe.conn.pending_ipc_info.queue);
+ q = QUEUE_HEAD(&server->pipe.conn.ipc_xfer_queue);
QUEUE_REMOVE(q);
- server->pipe.conn.pending_ipc_info.queue_len--;
- item = QUEUE_DATA(q, uv__ipc_queue_item_t, member);
+ server->pipe.conn.ipc_xfer_queue_length--;
+ item = QUEUE_DATA(q, uv__ipc_xfer_queue_item_t, member);
- err = uv_tcp_import((uv_tcp_t*)client,
- &item->socket_info_ex,
- item->tcp_connection);
+ err = uv__tcp_xfer_import(
+ (uv_tcp_t*) client, item->xfer_type, &item->xfer_info);
if (err != 0)
return err;
@@ -878,8 +906,8 @@ int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client) {
} else {
pipe_client = (uv_pipe_t*)client;
- /* Find a connection instance that has been connected, but not yet */
- /* accepted. */
+ /* Find a connection instance that has been connected, but not yet
+ * accepted. */
req = server->pipe.serv.pending_accepts;
if (!req) {
@@ -897,7 +925,7 @@ int uv_pipe_accept(uv_pipe_t* server, uv_stream_t* client) {
req->next_pending = NULL;
req->pipeHandle = INVALID_HANDLE_VALUE;
- if (!(server->flags & UV__HANDLE_CLOSING)) {
+ if (!(server->flags & UV_HANDLE_CLOSING)) {
uv_pipe_queue_accept(loop, server, req, FALSE);
}
}
@@ -942,70 +970,75 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
}
-static DWORD WINAPI uv_pipe_zero_readfile_thread_proc(void* parameter) {
- int result;
- DWORD bytes;
- uv_read_t* req = (uv_read_t*) parameter;
+static DWORD WINAPI uv_pipe_zero_readfile_thread_proc(void* arg) {
+ uv_read_t* req = (uv_read_t*) arg;
uv_pipe_t* handle = (uv_pipe_t*) req->data;
uv_loop_t* loop = handle->loop;
- HANDLE hThread = NULL;
+ volatile HANDLE* thread_ptr = &handle->pipe.conn.readfile_thread_handle;
+ CRITICAL_SECTION* lock = &handle->pipe.conn.readfile_thread_lock;
+ HANDLE thread;
+ DWORD bytes;
DWORD err;
- uv_mutex_t *m = &handle->pipe.conn.readfile_mutex;
- assert(req != NULL);
assert(req->type == UV_READ);
assert(handle->type == UV_NAMED_PIPE);
- if (handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) {
- uv_mutex_lock(m); /* mutex controls *setting* of readfile_thread */
- if (DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
- GetCurrentProcess(), &hThread,
- 0, FALSE, DUPLICATE_SAME_ACCESS)) {
- handle->pipe.conn.readfile_thread = hThread;
- } else {
- hThread = NULL;
- }
- uv_mutex_unlock(m);
- }
-restart_readfile:
- result = ReadFile(handle->handle,
- &uv_zero_,
- 0,
- &bytes,
- NULL);
- if (!result) {
+ err = 0;
+
+ /* Create a handle to the current thread. */
+ if (!DuplicateHandle(GetCurrentProcess(),
+ GetCurrentThread(),
+ GetCurrentProcess(),
+ &thread,
+ 0,
+ FALSE,
+ DUPLICATE_SAME_ACCESS)) {
err = GetLastError();
- if (err == ERROR_OPERATION_ABORTED &&
- handle->flags & UV_HANDLE_PIPE_READ_CANCELABLE) {
- if (handle->flags & UV_HANDLE_READING) {
- /* just a brief break to do something else */
- handle->pipe.conn.readfile_thread = NULL;
- /* resume after it is finished */
- uv_mutex_lock(m);
- handle->pipe.conn.readfile_thread = hThread;
- uv_mutex_unlock(m);
- goto restart_readfile;
- } else {
- result = 1; /* successfully stopped reading */
- }
- }
- }
- if (hThread) {
- assert(hThread == handle->pipe.conn.readfile_thread);
- /* mutex does not control clearing readfile_thread */
- handle->pipe.conn.readfile_thread = NULL;
- uv_mutex_lock(m);
- /* only when we hold the mutex lock is it safe to
- open or close the handle */
- CloseHandle(hThread);
- uv_mutex_unlock(m);
+ goto out1;
}
- if (!result) {
- SET_REQ_ERROR(req, err);
+ /* The lock needs to be held when thread handle is modified. */
+ EnterCriticalSection(lock);
+ if (*thread_ptr == INVALID_HANDLE_VALUE) {
+ /* uv__pipe_interrupt_read() cancelled reading before we got here. */
+ err = ERROR_OPERATION_ABORTED;
+ } else {
+ /* Let main thread know which worker thread is doing the blocking read. */
+ assert(*thread_ptr == NULL);
+ *thread_ptr = thread;
}
+ LeaveCriticalSection(lock);
+ if (err)
+ goto out2;
+
+ /* Block the thread until data is available on the pipe, or the read is
+ * cancelled. */
+ if (!ReadFile(handle->handle, &uv_zero_, 0, &bytes, NULL))
+ err = GetLastError();
+
+ /* Let the main thread know the worker is past the point of blocking. */
+ assert(thread == *thread_ptr);
+ *thread_ptr = INVALID_HANDLE_VALUE;
+
+ /* Briefly acquire the mutex. Since the main thread holds the lock while it
+ * is spinning trying to cancel this thread's I/O, we will block here until
+ * it stops doing that. */
+ EnterCriticalSection(lock);
+ LeaveCriticalSection(lock);
+
+out2:
+ /* Close the handle to the current thread. */
+ CloseHandle(thread);
+
+out1:
+ /* Set request status and post a completion record to the IOCP. */
+ if (err)
+ SET_REQ_ERROR(req, err);
+ else
+ SET_REQ_SUCCESS(req);
POST_COMPLETION_FOR_REQ(loop, req);
+
return 0;
}
@@ -1087,6 +1120,7 @@ static void uv_pipe_queue_read(uv_loop_t* loop, uv_pipe_t* handle) {
req = &handle->read_req;
if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) {
+ handle->pipe.conn.readfile_thread_handle = NULL; /* Reset cancellation. */
if (!QueueUserWorkItem(&uv_pipe_zero_readfile_thread_proc,
req,
WT_EXECUTELONGFUNCTION)) {
@@ -1154,8 +1188,8 @@ int uv_pipe_read_start(uv_pipe_t* handle,
handle->read_cb = read_cb;
handle->alloc_cb = alloc_cb;
- /* If reading was stopped and then started again, there could still be a */
- /* read request pending. */
+ /* If reading was stopped and then started again, there could still be a read
+ * request pending. */
if (!(handle->flags & UV_HANDLE_READ_PENDING))
uv_pipe_queue_read(loop, handle);
@@ -1211,154 +1245,110 @@ static void uv_queue_non_overlapped_write(uv_pipe_t* handle) {
}
-static int uv_pipe_write_impl(uv_loop_t* loop,
- uv_write_t* req,
- uv_pipe_t* handle,
- const uv_buf_t bufs[],
- unsigned int nbufs,
- uv_stream_t* send_handle,
- uv_write_cb cb) {
- int err;
- int result;
- uv_tcp_t* tcp_send_handle;
- uv_write_t* ipc_header_req = NULL;
- uv_ipc_frame_uv_stream ipc_frame;
+static int uv__build_coalesced_write_req(uv_write_t* user_req,
+ const uv_buf_t bufs[],
+ size_t nbufs,
+ uv_write_t** req_out,
+ uv_buf_t* write_buf_out) {
+ /* Pack into a single heap-allocated buffer:
+ * (a) a uv_write_t structure where libuv stores the actual state.
+ * (b) a pointer to the original uv_write_t.
+ * (c) data from all `bufs` entries.
+ */
+ char* heap_buffer;
+ size_t heap_buffer_length, heap_buffer_offset;
+ uv__coalesced_write_t* coalesced_write_req; /* (a) + (b) */
+ char* data_start; /* (c) */
+ size_t data_length;
+ unsigned int i;
+
+ /* Compute combined size of all combined buffers from `bufs`. */
+ data_length = 0;
+ for (i = 0; i < nbufs; i++)
+ data_length += bufs[i].len;
+
+ /* The total combined size of data buffers should not exceed UINT32_MAX,
+ * because WriteFile() won't accept buffers larger than that. */
+ if (data_length > UINT32_MAX)
+ return WSAENOBUFS; /* Maps to UV_ENOBUFS. */
+
+ /* Compute heap buffer size. */
+ heap_buffer_length = sizeof *coalesced_write_req + /* (a) + (b) */
+ data_length; /* (c) */
+
+ /* Allocate buffer. */
+ heap_buffer = uv__malloc(heap_buffer_length);
+ if (heap_buffer == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY; /* Maps to UV_ENOMEM. */
+
+ /* Copy uv_write_t information to the buffer. */
+ coalesced_write_req = (uv__coalesced_write_t*) heap_buffer;
+ coalesced_write_req->req = *user_req; /* copy (a) */
+ coalesced_write_req->req.coalesced = 1;
+ coalesced_write_req->user_req = user_req; /* copy (b) */
+ heap_buffer_offset = sizeof *coalesced_write_req; /* offset (a) + (b) */
+
+ /* Copy data buffers to the heap buffer. */
+ data_start = &heap_buffer[heap_buffer_offset];
+ for (i = 0; i < nbufs; i++) {
+ memcpy(&heap_buffer[heap_buffer_offset],
+ bufs[i].base,
+ bufs[i].len); /* copy (c) */
+ heap_buffer_offset += bufs[i].len; /* offset (c) */
+ }
+ assert(heap_buffer_offset == heap_buffer_length);
+
+ /* Set out arguments and return. */
+ *req_out = &coalesced_write_req->req;
+ *write_buf_out = uv_buf_init(data_start, (unsigned int) data_length);
+ return 0;
+}
- if (nbufs != 1 && (nbufs != 0 || !send_handle)) {
- return ERROR_NOT_SUPPORTED;
- }
- /* Only TCP handles are supported for sharing. */
- if (send_handle && ((send_handle->type != UV_TCP) ||
- (!(send_handle->flags & UV_HANDLE_BOUND) &&
- !(send_handle->flags & UV_HANDLE_CONNECTION)))) {
- return ERROR_NOT_SUPPORTED;
- }
+static int uv__pipe_write_data(uv_loop_t* loop,
+ uv_write_t* req,
+ uv_pipe_t* handle,
+ const uv_buf_t bufs[],
+ size_t nbufs,
+ uv_write_cb cb,
+ int copy_always) {
+ int err;
+ int result;
+ uv_buf_t write_buf;
assert(handle->handle != INVALID_HANDLE_VALUE);
UV_REQ_INIT(req, UV_WRITE);
req->handle = (uv_stream_t*) handle;
+ req->send_handle = NULL;
req->cb = cb;
- req->ipc_header = 0;
+ /* Private fields. */
+ req->coalesced = 0;
req->event_handle = NULL;
req->wait_handle = INVALID_HANDLE_VALUE;
memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped));
-
- if (handle->ipc) {
- assert(!(handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE));
- ipc_frame.header.flags = 0;
-
- /* Use the IPC framing protocol. */
- if (send_handle) {
- tcp_send_handle = (uv_tcp_t*)send_handle;
-
- if (handle->pipe.conn.ipc_pid == 0) {
- handle->pipe.conn.ipc_pid = uv_current_pid();
- }
-
- err = uv_tcp_duplicate_socket(tcp_send_handle, handle->pipe.conn.ipc_pid,
- &ipc_frame.socket_info_ex.socket_info);
- if (err) {
- return err;
- }
-
- ipc_frame.socket_info_ex.delayed_error = tcp_send_handle->delayed_error;
-
- ipc_frame.header.flags |= UV_IPC_TCP_SERVER;
-
- if (tcp_send_handle->flags & UV_HANDLE_CONNECTION) {
- ipc_frame.header.flags |= UV_IPC_TCP_CONNECTION;
- }
- }
-
- if (nbufs == 1) {
- ipc_frame.header.flags |= UV_IPC_RAW_DATA;
- ipc_frame.header.raw_data_length = bufs[0].len;
- }
-
- /*
- * Use the provided req if we're only doing a single write.
- * If we're doing multiple writes, use ipc_header_write_req to do
- * the first write, and then use the provided req for the second write.
- */
- if (!(ipc_frame.header.flags & UV_IPC_RAW_DATA)) {
- ipc_header_req = req;
- } else {
- /*
- * Try to use the preallocated write req if it's available.
- * Otherwise allocate a new one.
- */
- if (handle->pipe.conn.ipc_header_write_req.type != UV_WRITE) {
- ipc_header_req = (uv_write_t*)&handle->pipe.conn.ipc_header_write_req;
- } else {
- ipc_header_req = (uv_write_t*)uv__malloc(sizeof(uv_write_t));
- if (!ipc_header_req) {
- uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc");
- }
- }
-
- UV_REQ_INIT(ipc_header_req, UV_WRITE);
- ipc_header_req->handle = (uv_stream_t*) handle;
- ipc_header_req->cb = NULL;
- ipc_header_req->ipc_header = 1;
- }
-
- /* Write the header or the whole frame. */
- memset(&ipc_header_req->u.io.overlapped, 0,
- sizeof(ipc_header_req->u.io.overlapped));
-
- /* Using overlapped IO, but wait for completion before returning.
- This write is blocking because ipc_frame is on stack. */
- ipc_header_req->u.io.overlapped.hEvent = CreateEvent(NULL, 1, 0, NULL);
- if (!ipc_header_req->u.io.overlapped.hEvent) {
- uv_fatal_error(GetLastError(), "CreateEvent");
- }
-
- result = WriteFile(handle->handle,
- &ipc_frame,
- ipc_frame.header.flags & UV_IPC_TCP_SERVER ?
- sizeof(ipc_frame) : sizeof(ipc_frame.header),
- NULL,
- &ipc_header_req->u.io.overlapped);
- if (!result && GetLastError() != ERROR_IO_PENDING) {
- err = GetLastError();
- CloseHandle(ipc_header_req->u.io.overlapped.hEvent);
+ req->write_buffer = uv_null_buf_;
+
+ if (nbufs == 0) {
+ /* Write empty buffer. */
+ write_buf = uv_null_buf_;
+ } else if (nbufs == 1 && !copy_always) {
+ /* Write directly from bufs[0]. */
+ write_buf = bufs[0];
+ } else {
+ /* Coalesce all `bufs` into one big buffer. This also creates a new
+ * write-request structure that replaces the old one. */
+ err = uv__build_coalesced_write_req(req, bufs, nbufs, &req, &write_buf);
+ if (err != 0)
return err;
- }
-
- if (!result) {
- /* Request not completed immediately. Wait for it.*/
- if (WaitForSingleObject(ipc_header_req->u.io.overlapped.hEvent, INFINITE) !=
- WAIT_OBJECT_0) {
- err = GetLastError();
- CloseHandle(ipc_header_req->u.io.overlapped.hEvent);
- return err;
- }
- }
- ipc_header_req->u.io.queued_bytes = 0;
- CloseHandle(ipc_header_req->u.io.overlapped.hEvent);
- ipc_header_req->u.io.overlapped.hEvent = NULL;
-
- REGISTER_HANDLE_REQ(loop, handle, ipc_header_req);
- handle->reqs_pending++;
- handle->stream.conn.write_reqs_pending++;
-
- /* If we don't have any raw data to write - we're done. */
- if (!(ipc_frame.header.flags & UV_IPC_RAW_DATA)) {
- return 0;
- }
}
if ((handle->flags &
(UV_HANDLE_BLOCKING_WRITES | UV_HANDLE_NON_OVERLAPPED_PIPE)) ==
(UV_HANDLE_BLOCKING_WRITES | UV_HANDLE_NON_OVERLAPPED_PIPE)) {
DWORD bytes;
- result = WriteFile(handle->handle,
- bufs[0].base,
- bufs[0].len,
- &bytes,
- NULL);
+ result =
+ WriteFile(handle->handle, write_buf.base, write_buf.len, &bytes, NULL);
if (!result) {
err = GetLastError();
@@ -1374,14 +1364,14 @@ static int uv_pipe_write_impl(uv_loop_t* loop,
POST_COMPLETION_FOR_REQ(loop, req);
return 0;
} else if (handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) {
- req->write_buffer = bufs[0];
+ req->write_buffer = write_buf;
uv_insert_non_overlapped_write_req(handle, req);
if (handle->stream.conn.write_reqs_pending == 0) {
uv_queue_non_overlapped_write(handle);
}
/* Request queued by the kernel. */
- req->u.io.queued_bytes = bufs[0].len;
+ req->u.io.queued_bytes = write_buf.len;
handle->write_queue_size += req->u.io.queued_bytes;
} else if (handle->flags & UV_HANDLE_BLOCKING_WRITES) {
/* Using overlapped IO, but wait for completion before returning */
@@ -1391,8 +1381,8 @@ static int uv_pipe_write_impl(uv_loop_t* loop,
}
result = WriteFile(handle->handle,
- bufs[0].base,
- bufs[0].len,
+ write_buf.base,
+ write_buf.len,
NULL,
&req->u.io.overlapped);
@@ -1407,13 +1397,13 @@ static int uv_pipe_write_impl(uv_loop_t* loop,
req->u.io.queued_bytes = 0;
} else {
/* Request queued by the kernel. */
- req->u.io.queued_bytes = bufs[0].len;
+ req->u.io.queued_bytes = write_buf.len;
handle->write_queue_size += req->u.io.queued_bytes;
if (WaitForSingleObject(req->u.io.overlapped.hEvent, INFINITE) !=
WAIT_OBJECT_0) {
err = GetLastError();
CloseHandle(req->u.io.overlapped.hEvent);
- return uv_translate_sys_error(err);
+ return err;
}
}
CloseHandle(req->u.io.overlapped.hEvent);
@@ -1424,8 +1414,8 @@ static int uv_pipe_write_impl(uv_loop_t* loop,
return 0;
} else {
result = WriteFile(handle->handle,
- bufs[0].base,
- bufs[0].len,
+ write_buf.base,
+ write_buf.len,
NULL,
&req->u.io.overlapped);
@@ -1438,7 +1428,7 @@ static int uv_pipe_write_impl(uv_loop_t* loop,
req->u.io.queued_bytes = 0;
} else {
/* Request queued by the kernel. */
- req->u.io.queued_bytes = bufs[0].len;
+ req->u.io.queued_bytes = write_buf.len;
handle->write_queue_size += req->u.io.queued_bytes;
}
@@ -1463,35 +1453,143 @@ static int uv_pipe_write_impl(uv_loop_t* loop,
}
-int uv_pipe_write(uv_loop_t* loop,
- uv_write_t* req,
- uv_pipe_t* handle,
- const uv_buf_t bufs[],
- unsigned int nbufs,
- uv_write_cb cb) {
- return uv_pipe_write_impl(loop, req, handle, bufs, nbufs, NULL, cb);
+static DWORD uv__pipe_get_ipc_remote_pid(uv_pipe_t* handle) {
+ DWORD* pid = &handle->pipe.conn.ipc_remote_pid;
+
+ /* If the both ends of the IPC pipe are owned by the same process,
+ * the remote end pid may not yet be set. If so, do it here.
+ * TODO: this is weird; it'd probably better to use a handshake. */
+ if (*pid == 0)
+ *pid = GetCurrentProcessId();
+
+ return *pid;
}
-int uv_pipe_write2(uv_loop_t* loop,
+int uv__pipe_write_ipc(uv_loop_t* loop,
+ uv_write_t* req,
+ uv_pipe_t* handle,
+ const uv_buf_t data_bufs[],
+ size_t data_buf_count,
+ uv_stream_t* send_handle,
+ uv_write_cb cb) {
+ uv_buf_t stack_bufs[6];
+ uv_buf_t* bufs;
+ size_t buf_count, buf_index;
+ uv__ipc_frame_header_t frame_header;
+ uv__ipc_socket_xfer_type_t xfer_type = UV__IPC_SOCKET_XFER_NONE;
+ uv__ipc_socket_xfer_info_t xfer_info;
+ uint64_t data_length;
+ size_t i;
+ int err;
+
+ /* Compute the combined size of data buffers. */
+ data_length = 0;
+ for (i = 0; i < data_buf_count; i++)
+ data_length += data_bufs[i].len;
+ if (data_length > UINT32_MAX)
+ return WSAENOBUFS; /* Maps to UV_ENOBUFS. */
+
+ /* Prepare the frame's socket xfer payload. */
+ if (send_handle != NULL) {
+ uv_tcp_t* send_tcp_handle = (uv_tcp_t*) send_handle;
+
+ /* Verify that `send_handle` it is indeed a tcp handle. */
+ if (send_tcp_handle->type != UV_TCP)
+ return ERROR_NOT_SUPPORTED;
+
+ /* Export the tcp handle. */
+ err = uv__tcp_xfer_export(send_tcp_handle,
+ uv__pipe_get_ipc_remote_pid(handle),
+ &xfer_type,
+ &xfer_info);
+ if (err != 0)
+ return err;
+ }
+
+ /* Compute the number of uv_buf_t's required. */
+ buf_count = 1 + data_buf_count; /* Frame header and data buffers. */
+ if (send_handle != NULL)
+ buf_count += 1; /* One extra for the socket xfer information. */
+
+ /* Use the on-stack buffer array if it is big enough; otherwise allocate
+ * space for it on the heap. */
+ if (buf_count < ARRAY_SIZE(stack_bufs)) {
+ /* Use on-stack buffer array. */
+ bufs = stack_bufs;
+ } else {
+ /* Use heap-allocated buffer array. */
+ bufs = uv__calloc(buf_count, sizeof(uv_buf_t));
+ if (bufs == NULL)
+ return ERROR_NOT_ENOUGH_MEMORY; /* Maps to UV_ENOMEM. */
+ }
+ buf_index = 0;
+
+ /* Initialize frame header and add it to the buffers list. */
+ memset(&frame_header, 0, sizeof frame_header);
+ bufs[buf_index++] = uv_buf_init((char*) &frame_header, sizeof frame_header);
+
+ if (send_handle != NULL) {
+ /* Add frame header flags. */
+ switch (xfer_type) {
+ case UV__IPC_SOCKET_XFER_TCP_CONNECTION:
+ frame_header.flags |= UV__IPC_FRAME_HAS_SOCKET_XFER |
+ UV__IPC_FRAME_XFER_IS_TCP_CONNECTION;
+ break;
+ case UV__IPC_SOCKET_XFER_TCP_SERVER:
+ frame_header.flags |= UV__IPC_FRAME_HAS_SOCKET_XFER;
+ break;
+ default:
+ assert(0); /* Unreachable. */
+ }
+ /* Add xfer info buffer. */
+ bufs[buf_index++] = uv_buf_init((char*) &xfer_info, sizeof xfer_info);
+ }
+
+ if (data_length > 0) {
+ /* Update frame header. */
+ frame_header.flags |= UV__IPC_FRAME_HAS_DATA;
+ frame_header.data_length = (uint32_t) data_length;
+ /* Add data buffers to buffers list. */
+ for (i = 0; i < data_buf_count; i++)
+ bufs[buf_index++] = data_bufs[i];
+ }
+
+ /* Write buffers. We set the `always_copy` flag, so it is not a problem that
+ * some of the written data lives on the stack. */
+ err = uv__pipe_write_data(loop, req, handle, bufs, buf_count, cb, 1);
+
+ /* If we had to heap-allocate the bufs array, free it now. */
+ if (bufs != stack_bufs) {
+ uv__free(bufs);
+ }
+
+ return err;
+}
+
+
+int uv__pipe_write(uv_loop_t* loop,
uv_write_t* req,
uv_pipe_t* handle,
const uv_buf_t bufs[],
- unsigned int nbufs,
+ size_t nbufs,
uv_stream_t* send_handle,
uv_write_cb cb) {
- if (!handle->ipc) {
- return WSAEINVAL;
+ if (handle->ipc) {
+ /* IPC pipe write: use framing protocol. */
+ return uv__pipe_write_ipc(loop, req, handle, bufs, nbufs, send_handle, cb);
+ } else {
+ /* Non-IPC pipe write: put data on the wire directly. */
+ assert(send_handle == NULL);
+ return uv__pipe_write_data(loop, req, handle, bufs, nbufs, cb, 0);
}
-
- return uv_pipe_write_impl(loop, req, handle, bufs, nbufs, send_handle, cb);
}
static void uv_pipe_read_eof(uv_loop_t* loop, uv_pipe_t* handle,
uv_buf_t buf) {
- /* If there is an eof timer running, we don't need it any more, */
- /* so discard it. */
+ /* If there is an eof timer running, we don't need it any more, so discard
+ * it. */
eof_timer_destroy(handle);
handle->flags &= ~UV_HANDLE_READABLE;
@@ -1503,8 +1601,8 @@ static void uv_pipe_read_eof(uv_loop_t* loop, uv_pipe_t* handle,
static void uv_pipe_read_error(uv_loop_t* loop, uv_pipe_t* handle, int error,
uv_buf_t buf) {
- /* If there is an eof timer running, we don't need it any more, */
- /* so discard it. */
+ /* If there is an eof timer running, we don't need it any more, so discard
+ * it. */
eof_timer_destroy(handle);
uv_read_stop((uv_stream_t*) handle);
@@ -1523,152 +1621,228 @@ static void uv_pipe_read_error_or_eof(uv_loop_t* loop, uv_pipe_t* handle,
}
-void uv__pipe_insert_pending_socket(uv_pipe_t* handle,
- uv__ipc_socket_info_ex* info,
- int tcp_connection) {
- uv__ipc_queue_item_t* item;
+static void uv__pipe_queue_ipc_xfer_info(
+ uv_pipe_t* handle,
+ uv__ipc_socket_xfer_type_t xfer_type,
+ uv__ipc_socket_xfer_info_t* xfer_info) {
+ uv__ipc_xfer_queue_item_t* item;
- item = (uv__ipc_queue_item_t*) uv__malloc(sizeof(*item));
+ item = (uv__ipc_xfer_queue_item_t*) uv__malloc(sizeof(*item));
if (item == NULL)
uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc");
- memcpy(&item->socket_info_ex, info, sizeof(item->socket_info_ex));
- item->tcp_connection = tcp_connection;
- QUEUE_INSERT_TAIL(&handle->pipe.conn.pending_ipc_info.queue, &item->member);
- handle->pipe.conn.pending_ipc_info.queue_len++;
+ item->xfer_type = xfer_type;
+ item->xfer_info = *xfer_info;
+
+ QUEUE_INSERT_TAIL(&handle->pipe.conn.ipc_xfer_queue, &item->member);
+ handle->pipe.conn.ipc_xfer_queue_length++;
}
-void uv_process_pipe_read_req(uv_loop_t* loop, uv_pipe_t* handle,
- uv_req_t* req) {
- DWORD bytes, avail;
+/* Read an exact number of bytes from a pipe. If an error or end-of-file is
+ * encountered before the requested number of bytes are read, an error is
+ * returned. */
+static int uv__pipe_read_exactly(HANDLE h, void* buffer, DWORD count) {
+ DWORD bytes_read, bytes_read_now;
+
+ bytes_read = 0;
+ while (bytes_read < count) {
+ if (!ReadFile(h,
+ (char*) buffer + bytes_read,
+ count - bytes_read,
+ &bytes_read_now,
+ NULL)) {
+ return GetLastError();
+ }
+
+ bytes_read += bytes_read_now;
+ }
+
+ assert(bytes_read == count);
+ return 0;
+}
+
+
+static DWORD uv__pipe_read_data(uv_loop_t* loop,
+ uv_pipe_t* handle,
+ DWORD suggested_bytes,
+ DWORD max_bytes) {
+ DWORD bytes_read;
uv_buf_t buf;
- uv_ipc_frame_uv_stream ipc_frame;
+ /* Ask the user for a buffer to read data into. */
+ buf = uv_buf_init(NULL, 0);
+ handle->alloc_cb((uv_handle_t*) handle, suggested_bytes, &buf);
+ if (buf.base == NULL || buf.len == 0) {
+ handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &buf);
+ return 0; /* Break out of read loop. */
+ }
+
+ /* Ensure we read at most the smaller of:
+ * (a) the length of the user-allocated buffer.
+ * (b) the maximum data length as specified by the `max_bytes` argument.
+ */
+ if (max_bytes > buf.len)
+ max_bytes = buf.len;
+
+ /* Read into the user buffer. */
+ if (!ReadFile(handle->handle, buf.base, max_bytes, &bytes_read, NULL)) {
+ uv_pipe_read_error_or_eof(loop, handle, GetLastError(), buf);
+ return 0; /* Break out of read loop. */
+ }
+
+ /* Call the read callback. */
+ handle->read_cb((uv_stream_t*) handle, bytes_read, &buf);
+
+ return bytes_read;
+}
+
+
+static DWORD uv__pipe_read_ipc(uv_loop_t* loop, uv_pipe_t* handle) {
+ uint32_t* data_remaining = &handle->pipe.conn.ipc_data_frame.payload_remaining;
+ int err;
+
+ if (*data_remaining > 0) {
+ /* Read frame data payload. */
+ DWORD bytes_read =
+ uv__pipe_read_data(loop, handle, *data_remaining, *data_remaining);
+ *data_remaining -= bytes_read;
+ return bytes_read;
+
+ } else {
+ /* Start of a new IPC frame. */
+ uv__ipc_frame_header_t frame_header;
+ uint32_t xfer_flags;
+ uv__ipc_socket_xfer_type_t xfer_type;
+ uv__ipc_socket_xfer_info_t xfer_info;
+
+ /* Read the IPC frame header. */
+ err = uv__pipe_read_exactly(
+ handle->handle, &frame_header, sizeof frame_header);
+ if (err)
+ goto error;
+
+ /* Validate that flags are valid. */
+ if ((frame_header.flags & ~UV__IPC_FRAME_VALID_FLAGS) != 0)
+ goto invalid;
+ /* Validate that reserved2 is zero. */
+ if (frame_header.reserved2 != 0)
+ goto invalid;
+
+ /* Parse xfer flags. */
+ xfer_flags = frame_header.flags & UV__IPC_FRAME_XFER_FLAGS;
+ if (xfer_flags & UV__IPC_FRAME_HAS_SOCKET_XFER) {
+ /* Socket coming -- determine the type. */
+ xfer_type = xfer_flags & UV__IPC_FRAME_XFER_IS_TCP_CONNECTION
+ ? UV__IPC_SOCKET_XFER_TCP_CONNECTION
+ : UV__IPC_SOCKET_XFER_TCP_SERVER;
+ } else if (xfer_flags == 0) {
+ /* No socket. */
+ xfer_type = UV__IPC_SOCKET_XFER_NONE;
+ } else {
+ /* Invalid flags. */
+ goto invalid;
+ }
+
+ /* Parse data frame information. */
+ if (frame_header.flags & UV__IPC_FRAME_HAS_DATA) {
+ *data_remaining = frame_header.data_length;
+ } else if (frame_header.data_length != 0) {
+ /* Data length greater than zero but data flag not set -- invalid. */
+ goto invalid;
+ }
+
+ /* If no socket xfer info follows, return here. Data will be read in a
+ * subsequent invocation of uv__pipe_read_ipc(). */
+ if (xfer_type == UV__IPC_SOCKET_XFER_NONE)
+ return sizeof frame_header; /* Number of bytes read. */
+
+ /* Read transferred socket information. */
+ err = uv__pipe_read_exactly(handle->handle, &xfer_info, sizeof xfer_info);
+ if (err)
+ goto error;
+
+ /* Store the pending socket info. */
+ uv__pipe_queue_ipc_xfer_info(handle, xfer_type, &xfer_info);
+
+ /* Return number of bytes read. */
+ return sizeof frame_header + sizeof xfer_info;
+ }
+
+invalid:
+ /* Invalid frame. */
+ err = WSAECONNABORTED; /* Maps to UV_ECONNABORTED. */
+
+error:
+ uv_pipe_read_error_or_eof(loop, handle, err, uv_null_buf_);
+ return 0; /* Break out of read loop. */
+}
+
+
+void uv_process_pipe_read_req(uv_loop_t* loop,
+ uv_pipe_t* handle,
+ uv_req_t* req) {
assert(handle->type == UV_NAMED_PIPE);
- handle->flags &= ~UV_HANDLE_READ_PENDING;
+ handle->flags &= ~(UV_HANDLE_READ_PENDING | UV_HANDLE_CANCELLATION_PENDING);
+ DECREASE_PENDING_REQ_COUNT(handle);
eof_timer_stop(handle);
- if (!REQ_SUCCESS(req)) {
- /* An error occurred doing the 0-read. */
- if (handle->flags & UV_HANDLE_READING) {
- uv_pipe_read_error_or_eof(loop,
- handle,
- GET_REQ_ERROR(req),
- uv_null_buf_);
- }
- } else {
- /* Do non-blocking reads until the buffer is empty */
- while (handle->flags & UV_HANDLE_READING) {
- if (!PeekNamedPipe(handle->handle,
- NULL,
- 0,
- NULL,
- &avail,
- NULL)) {
- uv_pipe_read_error_or_eof(loop, handle, GetLastError(), uv_null_buf_);
- break;
- }
+ /* At this point, we're done with bookkeeping. If the user has stopped
+ * reading the pipe in the meantime, there is nothing left to do, since there
+ * is no callback that we can call. */
+ if (!(handle->flags & UV_HANDLE_READING))
+ return;
- if (avail == 0) {
- /* There is nothing to read after all. */
- break;
- }
+ if (!REQ_SUCCESS(req)) {
+ /* An error occurred doing the zero-read. */
+ DWORD err = GET_REQ_ERROR(req);
- if (handle->ipc) {
- /* Use the IPC framing protocol to read the incoming data. */
- if (handle->pipe.conn.remaining_ipc_rawdata_bytes == 0) {
- /* We're reading a new frame. First, read the header. */
- assert(avail >= sizeof(ipc_frame.header));
-
- if (!ReadFile(handle->handle,
- &ipc_frame.header,
- sizeof(ipc_frame.header),
- &bytes,
- NULL)) {
- uv_pipe_read_error_or_eof(loop, handle, GetLastError(),
- uv_null_buf_);
- break;
- }
-
- assert(bytes == sizeof(ipc_frame.header));
- assert(ipc_frame.header.flags <= (UV_IPC_TCP_SERVER | UV_IPC_RAW_DATA |
- UV_IPC_TCP_CONNECTION));
-
- if (ipc_frame.header.flags & UV_IPC_TCP_SERVER) {
- assert(avail - sizeof(ipc_frame.header) >=
- sizeof(ipc_frame.socket_info_ex));
-
- /* Read the TCP socket info. */
- if (!ReadFile(handle->handle,
- &ipc_frame.socket_info_ex,
- sizeof(ipc_frame) - sizeof(ipc_frame.header),
- &bytes,
- NULL)) {
- uv_pipe_read_error_or_eof(loop, handle, GetLastError(),
- uv_null_buf_);
- break;
- }
-
- assert(bytes == sizeof(ipc_frame) - sizeof(ipc_frame.header));
-
- /* Store the pending socket info. */
- uv__pipe_insert_pending_socket(
- handle,
- &ipc_frame.socket_info_ex,
- ipc_frame.header.flags & UV_IPC_TCP_CONNECTION);
- }
-
- if (ipc_frame.header.flags & UV_IPC_RAW_DATA) {
- handle->pipe.conn.remaining_ipc_rawdata_bytes =
- ipc_frame.header.raw_data_length;
- continue;
- }
- } else {
- avail = min(avail, (DWORD)handle->pipe.conn.remaining_ipc_rawdata_bytes);
- }
- }
+ /* If the read was cancelled by uv__pipe_interrupt_read(), the request may
+ * indicate an ERROR_OPERATION_ABORTED error. This error isn't relevant to
+ * the user; we'll start a new zero-read at the end of this function. */
+ if (err != ERROR_OPERATION_ABORTED)
+ uv_pipe_read_error_or_eof(loop, handle, err, uv_null_buf_);
- buf = uv_buf_init(NULL, 0);
- handle->alloc_cb((uv_handle_t*) handle, avail, &buf);
- if (buf.base == NULL || buf.len == 0) {
- handle->read_cb((uv_stream_t*) handle, UV_ENOBUFS, &buf);
+ } else {
+ /* The zero-read completed without error, indicating there is data
+ * available in the kernel buffer. */
+ DWORD avail;
+
+ /* Get the number of bytes available. */
+ avail = 0;
+ if (!PeekNamedPipe(handle->handle, NULL, 0, NULL, &avail, NULL))
+ uv_pipe_read_error_or_eof(loop, handle, GetLastError(), uv_null_buf_);
+
+ /* Read until we've either read all the bytes available, or the 'reading'
+ * flag is cleared. */
+ while (avail > 0 && handle->flags & UV_HANDLE_READING) {
+ /* Depending on the type of pipe, read either IPC frames or raw data. */
+ DWORD bytes_read =
+ handle->ipc ? uv__pipe_read_ipc(loop, handle)
+ : uv__pipe_read_data(loop, handle, avail, (DWORD) -1);
+
+ /* If no bytes were read, treat this as an indication that an error
+ * occurred, and break out of the read loop. */
+ if (bytes_read == 0)
break;
- }
- assert(buf.base != NULL);
-
- if (ReadFile(handle->handle,
- buf.base,
- min(buf.len, avail),
- &bytes,
- NULL)) {
- /* Successful read */
- if (handle->ipc) {
- assert(handle->pipe.conn.remaining_ipc_rawdata_bytes >= bytes);
- handle->pipe.conn.remaining_ipc_rawdata_bytes =
- handle->pipe.conn.remaining_ipc_rawdata_bytes - bytes;
- }
- handle->read_cb((uv_stream_t*)handle, bytes, &buf);
- /* Read again only if bytes == buf.len */
- if (bytes <= buf.len) {
- break;
- }
- } else {
- uv_pipe_read_error_or_eof(loop, handle, GetLastError(), buf);
+ /* It is possible that more bytes were read than we thought were
+ * available. To prevent `avail` from underflowing, break out of the loop
+ * if this is the case. */
+ if (bytes_read > avail)
break;
- }
- }
- /* Post another 0-read if still reading and not closing. */
- if ((handle->flags & UV_HANDLE_READING) &&
- !(handle->flags & UV_HANDLE_READ_PENDING)) {
- uv_pipe_queue_read(loop, handle);
+ /* Recompute the number of bytes available. */
+ avail -= bytes_read;
}
}
- DECREASE_PENDING_REQ_COUNT(handle);
+ /* Start another zero-read request if necessary. */
+ if ((handle->flags & UV_HANDLE_READING) &&
+ !(handle->flags & UV_HANDLE_READ_PENDING)) {
+ uv_pipe_queue_read(loop, handle);
+ }
}
@@ -1694,17 +1868,19 @@ void uv_process_pipe_write_req(uv_loop_t* loop, uv_pipe_t* handle,
}
}
- if (req->ipc_header) {
- if (req == &handle->pipe.conn.ipc_header_write_req) {
- req->type = UV_UNKNOWN_REQ;
- } else {
- uv__free(req);
- }
- } else {
- if (req->cb) {
- err = GET_REQ_ERROR(req);
- req->cb(req, uv_translate_sys_error(err));
- }
+ err = GET_REQ_ERROR(req);
+
+ /* If this was a coalesced write, extract pointer to the user_provided
+ * uv_write_t structure so we can pass the expected pointer to the callback,
+ * then free the heap-allocated write req. */
+ if (req->coalesced) {
+ uv__coalesced_write_t* coalesced_write =
+ container_of(req, uv__coalesced_write_t, req);
+ req = coalesced_write->user_req;
+ uv__free(coalesced_write);
+ }
+ if (req->cb) {
+ req->cb(req, uv_translate_sys_error(err));
}
handle->stream.conn.write_reqs_pending--;
@@ -1730,7 +1906,7 @@ void uv_process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle,
assert(handle->type == UV_NAMED_PIPE);
- if (handle->flags & UV__HANDLE_CLOSING) {
+ if (handle->flags & UV_HANDLE_CLOSING) {
/* The req->pipeHandle should be freed already in uv_pipe_cleanup(). */
assert(req->pipeHandle == INVALID_HANDLE_VALUE);
DECREASE_PENDING_REQ_COUNT(handle);
@@ -1750,7 +1926,7 @@ void uv_process_pipe_accept_req(uv_loop_t* loop, uv_pipe_t* handle,
CloseHandle(req->pipeHandle);
req->pipeHandle = INVALID_HANDLE_VALUE;
}
- if (!(handle->flags & UV__HANDLE_CLOSING)) {
+ if (!(handle->flags & UV_HANDLE_CLOSING)) {
uv_pipe_queue_accept(loop, handle, req, FALSE);
}
}
@@ -1788,19 +1964,19 @@ void uv_process_pipe_shutdown_req(uv_loop_t* loop, uv_pipe_t* handle,
UNREGISTER_HANDLE_REQ(loop, handle, req);
if (handle->flags & UV_HANDLE_READABLE) {
- /* Initialize and optionally start the eof timer. Only do this if the */
- /* pipe is readable and we haven't seen EOF come in ourselves. */
+ /* Initialize and optionally start the eof timer. Only do this if the pipe
+ * is readable and we haven't seen EOF come in ourselves. */
eof_timer_init(handle);
- /* If reading start the timer right now. */
- /* Otherwise uv_pipe_queue_read will start it. */
+ /* If reading start the timer right now. Otherwise uv_pipe_queue_read will
+ * start it. */
if (handle->flags & UV_HANDLE_READ_PENDING) {
eof_timer_start(handle);
}
} else {
- /* This pipe is not readable. We can just close it to let the other end */
- /* know that we're done writing. */
+ /* This pipe is not readable. We can just close it to let the other end
+ * know that we're done writing. */
close_pipe(handle);
}
@@ -1851,17 +2027,16 @@ static void eof_timer_cb(uv_timer_t* timer) {
assert(pipe->type == UV_NAMED_PIPE);
- /* This should always be true, since we start the timer only */
- /* in uv_pipe_queue_read after successfully calling ReadFile, */
- /* or in uv_process_pipe_shutdown_req if a read is pending, */
- /* and we always immediately stop the timer in */
- /* uv_process_pipe_read_req. */
+ /* This should always be true, since we start the timer only in
+ * uv_pipe_queue_read after successfully calling ReadFile, or in
+ * uv_process_pipe_shutdown_req if a read is pending, and we always
+ * immediately stop the timer in uv_process_pipe_read_req. */
assert(pipe->flags & UV_HANDLE_READ_PENDING);
- /* If there are many packets coming off the iocp then the timer callback */
- /* may be called before the read request is coming off the queue. */
- /* Therefore we check here if the read request has completed but will */
- /* be processed later. */
+ /* If there are many packets coming off the iocp then the timer callback may
+ * be called before the read request is coming off the queue. Therefore we
+ * check here if the read request has completed but will be processed later.
+ */
if ((pipe->flags & UV_HANDLE_READ_PENDING) &&
HasOverlappedIoCompleted(&pipe->read_req.u.io.overlapped)) {
return;
@@ -1870,12 +2045,12 @@ static void eof_timer_cb(uv_timer_t* timer) {
/* Force both ends off the pipe. */
close_pipe(pipe);
- /* Stop reading, so the pending read that is going to fail will */
- /* not be reported to the user. */
+ /* Stop reading, so the pending read that is going to fail will not be
+ * reported to the user. */
uv_read_stop((uv_stream_t*) pipe);
- /* Report the eof and update flags. This will get reported even if the */
- /* user stopped reading in the meantime. TODO: is that okay? */
+ /* Report the eof and update flags. This will get reported even if the user
+ * stopped reading in the meantime. TODO: is that okay? */
uv_pipe_read_eof(loop, pipe, uv_null_buf_);
}
@@ -1906,6 +2081,7 @@ int uv_pipe_open(uv_pipe_t* pipe, uv_file file) {
if (os_handle == INVALID_HANDLE_VALUE)
return UV_EBADF;
+ uv__once_init();
/* In order to avoid closing a stdio file descriptor 0-2, duplicate the
* underlying OS handle and forget about the original fd.
* We could also opt to use the original OS handle and just never close it,
@@ -1961,8 +2137,8 @@ int uv_pipe_open(uv_pipe_t* pipe, uv_file file) {
if (pipe->ipc) {
assert(!(pipe->flags & UV_HANDLE_NON_OVERLAPPED_PIPE));
- pipe->pipe.conn.ipc_pid = uv_parent_pid();
- assert(pipe->pipe.conn.ipc_pid != -1);
+ pipe->pipe.conn.ipc_remote_pid = uv_os_getppid();
+ assert(pipe->pipe.conn.ipc_remote_pid != (DWORD) -1);
}
return 0;
}
@@ -1979,6 +2155,7 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size)
unsigned int name_len;
int err;
+ uv__once_init();
name_info = NULL;
if (handle->handle == INVALID_HANDLE_VALUE) {
@@ -1986,7 +2163,15 @@ static int uv__pipe_getname(const uv_pipe_t* handle, char* buffer, size_t* size)
return UV_EINVAL;
}
- uv__pipe_pause_read((uv_pipe_t*)handle); /* cast away const warning */
+ /* NtQueryInformationFile will block if another thread is performing a
+ * blocking operation on the queried handle. If the pipe handle is
+ * synchronous, there may be a worker thread currently calling ReadFile() on
+ * the pipe handle, which could cause a deadlock. To avoid this, interrupt
+ * the read. */
+ if (handle->flags & UV_HANDLE_CONNECTION &&
+ handle->flags & UV_HANDLE_NON_OVERLAPPED_PIPE) {
+ uv__pipe_interrupt_read((uv_pipe_t*) handle); /* cast away const warning */
+ }
nt_status = pNtQueryInformationFile(handle->handle,
&io_status,
@@ -2077,7 +2262,6 @@ error:
uv__free(name_info);
cleanup:
- uv__pipe_unpause_read((uv_pipe_t*)handle); /* cast away const warning */
return err;
}
@@ -2085,7 +2269,7 @@ cleanup:
int uv_pipe_pending_count(uv_pipe_t* handle) {
if (!handle->ipc)
return 0;
- return handle->pipe.conn.pending_ipc_info.queue_len;
+ return handle->pipe.conn.ipc_xfer_queue_length;
}
@@ -2118,8 +2302,85 @@ int uv_pipe_getpeername(const uv_pipe_t* handle, char* buffer, size_t* size) {
uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle) {
if (!handle->ipc)
return UV_UNKNOWN_HANDLE;
- if (handle->pipe.conn.pending_ipc_info.queue_len == 0)
+ if (handle->pipe.conn.ipc_xfer_queue_length == 0)
return UV_UNKNOWN_HANDLE;
else
return UV_TCP;
}
+
+int uv_pipe_chmod(uv_pipe_t* handle, int mode) {
+ SID_IDENTIFIER_AUTHORITY sid_world = { SECURITY_WORLD_SID_AUTHORITY };
+ PACL old_dacl, new_dacl;
+ PSECURITY_DESCRIPTOR sd;
+ EXPLICIT_ACCESS ea;
+ PSID everyone;
+ int error;
+
+ if (handle == NULL || handle->handle == INVALID_HANDLE_VALUE)
+ return UV_EBADF;
+
+ if (mode != UV_READABLE &&
+ mode != UV_WRITABLE &&
+ mode != (UV_WRITABLE | UV_READABLE))
+ return UV_EINVAL;
+
+ if (!AllocateAndInitializeSid(&sid_world,
+ 1,
+ SECURITY_WORLD_RID,
+ 0, 0, 0, 0, 0, 0, 0,
+ &everyone)) {
+ error = GetLastError();
+ goto done;
+ }
+
+ if (GetSecurityInfo(handle->handle,
+ SE_KERNEL_OBJECT,
+ DACL_SECURITY_INFORMATION,
+ NULL,
+ NULL,
+ &old_dacl,
+ NULL,
+ &sd)) {
+ error = GetLastError();
+ goto clean_sid;
+ }
+
+ memset(&ea, 0, sizeof(EXPLICIT_ACCESS));
+ if (mode & UV_READABLE)
+ ea.grfAccessPermissions |= GENERIC_READ | FILE_WRITE_ATTRIBUTES;
+ if (mode & UV_WRITABLE)
+ ea.grfAccessPermissions |= GENERIC_WRITE | FILE_READ_ATTRIBUTES;
+ ea.grfAccessPermissions |= SYNCHRONIZE;
+ ea.grfAccessMode = SET_ACCESS;
+ ea.grfInheritance = NO_INHERITANCE;
+ ea.Trustee.TrusteeForm = TRUSTEE_IS_SID;
+ ea.Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
+ ea.Trustee.ptstrName = (LPTSTR)everyone;
+
+ if (SetEntriesInAcl(1, &ea, old_dacl, &new_dacl)) {
+ error = GetLastError();
+ goto clean_sd;
+ }
+
+ if (SetSecurityInfo(handle->handle,
+ SE_KERNEL_OBJECT,
+ DACL_SECURITY_INFORMATION,
+ NULL,
+ NULL,
+ new_dacl,
+ NULL)) {
+ error = GetLastError();
+ goto clean_dacl;
+ }
+
+ error = 0;
+
+clean_dacl:
+ LocalFree((HLOCAL) new_dacl);
+clean_sd:
+ LocalFree((HLOCAL) sd);
+clean_sid:
+ FreeSid(everyone);
+done:
+ return uv_translate_sys_error(error);
+}
diff --git a/Utilities/cmlibuv/src/win/poll.c b/Utilities/cmlibuv/src/win/poll.c
index a648ba711..3c6678600 100644
--- a/Utilities/cmlibuv/src/win/poll.c
+++ b/Utilities/cmlibuv/src/win/poll.c
@@ -75,7 +75,7 @@ static AFD_POLL_INFO* uv__get_afd_poll_info_dummy(void) {
static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
uv_req_t* req;
AFD_POLL_INFO* afd_poll_info;
- DWORD result;
+ int result;
/* Find a yet unsubmitted req to submit. */
if (handle->submitted_events_1 == 0) {
@@ -91,16 +91,16 @@ static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
handle->mask_events_1 = handle->events;
handle->mask_events_2 = 0;
} else {
- /* Just wait until there's an unsubmitted req. */
- /* This will happen almost immediately as one of the 2 outstanding */
- /* requests is about to return. When this happens, */
- /* uv__fast_poll_process_poll_req will be called, and the pending */
- /* events, if needed, will be processed in a subsequent request. */
+ /* Just wait until there's an unsubmitted req. This will happen almost
+ * immediately as one of the 2 outstanding requests is about to return.
+ * When this happens, uv__fast_poll_process_poll_req will be called, and
+ * the pending events, if needed, will be processed in a subsequent
+ * request. */
return;
}
- /* Setting Exclusive to TRUE makes the other poll request return if there */
- /* is any. */
+ /* Setting Exclusive to TRUE makes the other poll request return if there is
+ * any. */
afd_poll_info->Exclusive = TRUE;
afd_poll_info->NumberOfHandles = 1;
afd_poll_info->Timeout.QuadPart = INT64_MAX;
@@ -136,7 +136,7 @@ static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
static int uv__fast_poll_cancel_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
AFD_POLL_INFO afd_poll_info;
- DWORD result;
+ int result;
afd_poll_info.Exclusive = TRUE;
afd_poll_info.NumberOfHandles = 1;
@@ -218,7 +218,7 @@ static void uv__fast_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle,
if ((handle->events & ~(handle->submitted_events_1 |
handle->submitted_events_2)) != 0) {
uv__fast_poll_submit_poll_req(loop, handle);
- } else if ((handle->flags & UV__HANDLE_CLOSING) &&
+ } else if ((handle->flags & UV_HANDLE_CLOSING) &&
handle->submitted_events_1 == 0 &&
handle->submitted_events_2 == 0) {
uv_want_endgame(loop, (uv_handle_t*) handle);
@@ -228,7 +228,7 @@ static void uv__fast_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle,
static int uv__fast_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) {
assert(handle->type == UV_POLL);
- assert(!(handle->flags & UV__HANDLE_CLOSING));
+ assert(!(handle->flags & UV_HANDLE_CLOSING));
assert((events & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT)) == 0);
handle->events = events;
@@ -257,8 +257,8 @@ static int uv__fast_poll_close(uv_loop_t* loop, uv_poll_t* handle) {
uv_want_endgame(loop, (uv_handle_t*) handle);
return 0;
} else {
- /* Cancel outstanding poll requests by executing another, unique poll */
- /* request that forces the outstanding ones to return. */
+ /* Cancel outstanding poll requests by executing another, unique poll
+ * request that forces the outstanding ones to return. */
return uv__fast_poll_cancel_poll_req(loop, handle);
}
}
@@ -316,9 +316,8 @@ static SOCKET uv__fast_poll_get_peer_socket(uv_loop_t* loop,
return INVALID_SOCKET;
}
- /* If we didn't (try) to create a peer socket yet, try to make one. Don't */
- /* try again if the peer socket creation failed earlier for the same */
- /* protocol. */
+ /* If we didn't (try) to create a peer socket yet, try to make one. Don't try
+ * again if the peer socket creation failed earlier for the same protocol. */
peer_socket = loop->poll_peer_sockets[index];
if (peer_socket == 0) {
peer_socket = uv__fast_poll_create_peer_socket(loop->iocp, protocol_info);
@@ -357,8 +356,8 @@ static DWORD WINAPI uv__slow_poll_thread_proc(void* arg) {
efds.fd_count = 0;
}
- /* Make the select() time out after 3 minutes. If select() hangs because */
- /* the user closed the socket, we will at least not hang indefinitely. */
+ /* Make the select() time out after 3 minutes. If select() hangs because the
+ * user closed the socket, we will at least not hang indefinitely. */
timeout.tv_sec = 3 * 60;
timeout.tv_usec = 0;
@@ -462,7 +461,7 @@ static void uv__slow_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle,
if ((handle->events & ~(handle->submitted_events_1 |
handle->submitted_events_2)) != 0) {
uv__slow_poll_submit_poll_req(loop, handle);
- } else if ((handle->flags & UV__HANDLE_CLOSING) &&
+ } else if ((handle->flags & UV_HANDLE_CLOSING) &&
handle->submitted_events_1 == 0 &&
handle->submitted_events_2 == 0) {
uv_want_endgame(loop, (uv_handle_t*) handle);
@@ -472,7 +471,7 @@ static void uv__slow_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle,
static int uv__slow_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) {
assert(handle->type == UV_POLL);
- assert(!(handle->flags & UV__HANDLE_CLOSING));
+ assert(!(handle->flags & UV_HANDLE_CLOSING));
assert((events & ~(UV_READABLE | UV_WRITABLE)) == 0);
handle->events = events;
@@ -522,10 +521,10 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle,
if (ioctlsocket(socket, FIONBIO, &yes) == SOCKET_ERROR)
return uv_translate_sys_error(WSAGetLastError());
- /* Try to obtain a base handle for the socket. This increases this chances */
- /* that we find an AFD handle and are able to use the fast poll mechanism. */
- /* This will always fail on windows XP/2k3, since they don't support the */
- /* SIO_BASE_HANDLE ioctl. */
+/* Try to obtain a base handle for the socket. This increases this chances that
+ * we find an AFD handle and are able to use the fast poll mechanism. This will
+ * always fail on windows XP/2k3, since they don't support the. SIO_BASE_HANDLE
+ * ioctl. */
#ifndef NDEBUG
base_socket = INVALID_SOCKET;
#endif
@@ -557,9 +556,9 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle,
return uv_translate_sys_error(WSAGetLastError());
}
- /* Get the peer socket that is needed to enable fast poll. If the returned */
- /* value is NULL, the protocol is not implemented by MSAFD and we'll have */
- /* to use slow mode. */
+ /* Get the peer socket that is needed to enable fast poll. If the returned
+ * value is NULL, the protocol is not implemented by MSAFD and we'll have to
+ * use slow mode. */
peer_socket = uv__fast_poll_get_peer_socket(loop, &protocol_info);
if (peer_socket != INVALID_SOCKET) {
@@ -634,7 +633,7 @@ int uv_poll_close(uv_loop_t* loop, uv_poll_t* handle) {
void uv_poll_endgame(uv_loop_t* loop, uv_poll_t* handle) {
- assert(handle->flags & UV__HANDLE_CLOSING);
+ assert(handle->flags & UV_HANDLE_CLOSING);
assert(!(handle->flags & UV_HANDLE_CLOSED));
assert(handle->submitted_events_1 == 0);
diff --git a/Utilities/cmlibuv/src/win/process-stdio.c b/Utilities/cmlibuv/src/win/process-stdio.c
index 032e30935..355d61880 100644
--- a/Utilities/cmlibuv/src/win/process-stdio.c
+++ b/Utilities/cmlibuv/src/win/process-stdio.c
@@ -103,12 +103,12 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop,
DWORD client_access = 0;
HANDLE child_pipe = INVALID_HANDLE_VALUE;
int err;
+ int overlap;
if (flags & UV_READABLE_PIPE) {
- /* The server needs inbound access too, otherwise CreateNamedPipe() */
- /* won't give us the FILE_READ_ATTRIBUTES permission. We need that to */
- /* probe the state of the write buffer when we're trying to shutdown */
- /* the pipe. */
+ /* The server needs inbound access too, otherwise CreateNamedPipe() won't
+ * give us the FILE_READ_ATTRIBUTES permission. We need that to probe the
+ * state of the write buffer when we're trying to shutdown the pipe. */
server_access |= PIPE_ACCESS_OUTBOUND | PIPE_ACCESS_INBOUND;
client_access |= GENERIC_READ | FILE_WRITE_ATTRIBUTES;
}
@@ -131,12 +131,13 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop,
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
+ overlap = server_pipe->ipc || (flags & UV_OVERLAPPED_PIPE);
child_pipe = CreateFileA(pipe_name,
client_access,
0,
&sa,
OPEN_EXISTING,
- server_pipe->ipc ? FILE_FLAG_OVERLAPPED : 0,
+ overlap ? FILE_FLAG_OVERLAPPED : 0,
NULL);
if (child_pipe == INVALID_HANDLE_VALUE) {
err = GetLastError();
@@ -159,8 +160,8 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop,
}
#endif
- /* Do a blocking ConnectNamedPipe. This should not block because we have */
- /* both ends of the pipe created. */
+ /* Do a blocking ConnectNamedPipe. This should not block because we have both
+ * ends of the pipe created. */
if (!ConnectNamedPipe(server_pipe->handle, NULL)) {
if (GetLastError() != ERROR_PIPE_CONNECTED) {
err = GetLastError();
@@ -194,11 +195,11 @@ static int uv__duplicate_handle(uv_loop_t* loop, HANDLE handle, HANDLE* dup) {
HANDLE current_process;
- /* _get_osfhandle will sometimes return -2 in case of an error. This seems */
- /* to happen when fd <= 2 and the process' corresponding stdio handle is */
- /* set to NULL. Unfortunately DuplicateHandle will happily duplicate */
- /* (HANDLE) -2, so this situation goes unnoticed until someone tries to */
- /* use the duplicate. Therefore we filter out known-invalid handles here. */
+ /* _get_osfhandle will sometimes return -2 in case of an error. This seems to
+ * happen when fd <= 2 and the process' corresponding stdio handle is set to
+ * NULL. Unfortunately DuplicateHandle will happily duplicate (HANDLE) -2, so
+ * this situation goes unnoticed until someone tries to use the duplicate.
+ * Therefore we filter out known-invalid handles here. */
if (handle == INVALID_HANDLE_VALUE ||
handle == NULL ||
handle == (HANDLE) -2) {
@@ -284,8 +285,8 @@ int uv__stdio_create(uv_loop_t* loop,
return ERROR_OUTOFMEMORY;
}
- /* Prepopulate the buffer with INVALID_HANDLE_VALUE handles so we can */
- /* clean up on failure. */
+ /* Prepopulate the buffer with INVALID_HANDLE_VALUE handles so we can clean
+ * up on failure. */
CHILD_STDIO_COUNT(buffer) = count;
for (i = 0; i < count; i++) {
CHILD_STDIO_CRT_FLAGS(buffer, i) = 0;
@@ -303,12 +304,12 @@ int uv__stdio_create(uv_loop_t* loop,
switch (fdopt.flags & (UV_IGNORE | UV_CREATE_PIPE | UV_INHERIT_FD |
UV_INHERIT_STREAM)) {
case UV_IGNORE:
- /* Starting a process with no stdin/stout/stderr can confuse it. */
- /* So no matter what the user specified, we make sure the first */
- /* three FDs are always open in their typical modes, e.g. stdin */
- /* be readable and stdout/err should be writable. For FDs > 2, don't */
- /* do anything - all handles in the stdio buffer are initialized with */
- /* INVALID_HANDLE_VALUE, which should be okay. */
+ /* Starting a process with no stdin/stout/stderr can confuse it. So no
+ * matter what the user specified, we make sure the first three FDs are
+ * always open in their typical modes, e. g. stdin be readable and
+ * stdout/err should be writable. For FDs > 2, don't do anything - all
+ * handles in the stdio buffer are initialized with.
+ * INVALID_HANDLE_VALUE, which should be okay. */
if (i <= 2) {
DWORD access = (i == 0) ? FILE_GENERIC_READ :
FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES;
@@ -323,14 +324,14 @@ int uv__stdio_create(uv_loop_t* loop,
break;
case UV_CREATE_PIPE: {
- /* Create a pair of two connected pipe ends; one end is turned into */
- /* an uv_pipe_t for use by the parent. The other one is given to */
- /* the child. */
+ /* Create a pair of two connected pipe ends; one end is turned into an
+ * uv_pipe_t for use by the parent. The other one is given to the
+ * child. */
uv_pipe_t* parent_pipe = (uv_pipe_t*) fdopt.data.stream;
HANDLE child_pipe = INVALID_HANDLE_VALUE;
- /* Create a new, connected pipe pair. stdio[i].stream should point */
- /* to an uninitialized, but not connected pipe handle. */
+ /* Create a new, connected pipe pair. stdio[i]. stream should point to
+ * an uninitialized, but not connected pipe handle. */
assert(fdopt.data.stream->type == UV_NAMED_PIPE);
assert(!(fdopt.data.stream->flags & UV_HANDLE_CONNECTION));
assert(!(fdopt.data.stream->flags & UV_HANDLE_PIPESERVER));
@@ -354,8 +355,8 @@ int uv__stdio_create(uv_loop_t* loop,
/* Make an inheritable duplicate of the handle. */
err = uv__duplicate_fd(loop, fdopt.data.fd, &child_handle);
if (err) {
- /* If fdopt.data.fd is not valid and fd fd <= 2, then ignore the */
- /* error. */
+ /* If fdopt. data. fd is not valid and fd <= 2, then ignore the
+ * error. */
if (fdopt.data.fd <= 2 && err == ERROR_INVALID_HANDLE) {
CHILD_STDIO_CRT_FLAGS(buffer, i) = 0;
CHILD_STDIO_HANDLE(buffer, i) = INVALID_HANDLE_VALUE;
@@ -418,8 +419,8 @@ int uv__stdio_create(uv_loop_t* loop,
if (stream_handle == NULL ||
stream_handle == INVALID_HANDLE_VALUE) {
- /* The handle is already closed, or not yet created, or the */
- /* stream type is not supported. */
+ /* The handle is already closed, or not yet created, or the stream
+ * type is not supported. */
err = ERROR_NOT_SUPPORTED;
goto error;
}
diff --git a/Utilities/cmlibuv/src/win/process.c b/Utilities/cmlibuv/src/win/process.c
index d14160160..24037b302 100644
--- a/Utilities/cmlibuv/src/win/process.c
+++ b/Utilities/cmlibuv/src/win/process.c
@@ -360,8 +360,8 @@ static WCHAR* search_path(const WCHAR *file,
return NULL;
}
- /* Find the start of the filename so we can split the directory from the */
- /* name. */
+ /* Find the start of the filename so we can split the directory from the
+ * name. */
for (file_name_start = (WCHAR*)file + file_len;
file_name_start > file
&& file_name_start[-1] != L'\\'
@@ -405,8 +405,15 @@ static WCHAR* search_path(const WCHAR *file,
/* Next slice starts just after where the previous one ended */
dir_start = dir_end;
+ /* If path is quoted, find quote end */
+ if (*dir_start == L'"' || *dir_start == L'\'') {
+ dir_end = wcschr(dir_start + 1, *dir_start);
+ if (dir_end == NULL) {
+ dir_end = wcschr(dir_start, L'\0');
+ }
+ }
/* Slice until the next ; or \0 is found */
- dir_end = wcschr(dir_start, L';');
+ dir_end = wcschr(dir_end, L';');
if (dir_end == NULL) {
dir_end = wcschr(dir_start, L'\0');
}
@@ -549,8 +556,8 @@ int make_program_args(char** args, int verbatim_arguments, WCHAR** dst_ptr) {
arg_count++;
}
- /* Adjust for potential quotes. Also assume the worst-case scenario */
- /* that every character needs escaping, so we need twice as much space. */
+ /* Adjust for potential quotes. Also assume the worst-case scenario that
+ * every character needs escaping, so we need twice as much space. */
dst_len = dst_len * 2 + arg_count * 2;
/* Allocate buffer for the final command line. */
@@ -732,7 +739,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
}
}
*ptr_copy = NULL;
- assert(env_len == ptr - dst_copy);
+ assert(env_len == (size_t) (ptr - dst_copy));
/* sort our (UTF-16) copy */
qsort(env_copy, env_block_count-1, sizeof(wchar_t*), qsort_wcscmp);
@@ -792,7 +799,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
var_size = GetEnvironmentVariableW(required_vars[i].wide,
ptr,
(int) (env_len - (ptr - dst)));
- if (var_size != len-1) { /* race condition? */
+ if (var_size != (DWORD) (len - 1)) { /* TODO: handle race condition? */
uv_fatal_error(GetLastError(), "GetEnvironmentVariableW");
}
}
@@ -808,7 +815,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
}
/* Terminate with an extra NULL. */
- assert(env_len == (ptr - dst));
+ assert(env_len == (size_t) (ptr - dst));
*ptr = L'\0';
uv__free(dst_copy);
@@ -824,8 +831,13 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
*/
static WCHAR* find_path(WCHAR *env) {
for (; env != NULL && *env != 0; env += wcslen(env) + 1) {
- if (wcsncmp(env, L"PATH=", 5) == 0)
+ if ((env[0] == L'P' || env[0] == L'p') &&
+ (env[1] == L'A' || env[1] == L'a') &&
+ (env[2] == L'T' || env[2] == L't') &&
+ (env[3] == L'H' || env[3] == L'h') &&
+ (env[4] == L'=')) {
return &env[5];
+ }
}
return NULL;
@@ -858,9 +870,9 @@ void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle) {
assert(handle->exit_cb_pending);
handle->exit_cb_pending = 0;
- /* If we're closing, don't call the exit callback. Just schedule a close */
- /* callback now. */
- if (handle->flags & UV__HANDLE_CLOSING) {
+ /* If we're closing, don't call the exit callback. Just schedule a close
+ * callback now. */
+ if (handle->flags & UV_HANDLE_CLOSING) {
uv_want_endgame(loop, (uv_handle_t*) handle);
return;
}
@@ -871,14 +883,14 @@ void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle) {
handle->wait_handle = INVALID_HANDLE_VALUE;
}
- /* Set the handle to inactive: no callbacks will be made after the exit */
- /* callback.*/
+ /* Set the handle to inactive: no callbacks will be made after the exit
+ * callback. */
uv__handle_stop(handle);
if (GetExitCodeProcess(handle->process_handle, &status)) {
exit_code = status;
} else {
- /* Unable to to obtain the exit code. This should never happen. */
+ /* Unable to obtain the exit code. This should never happen. */
exit_code = uv_translate_sys_error(GetLastError());
}
@@ -893,8 +905,8 @@ void uv_process_close(uv_loop_t* loop, uv_process_t* handle) {
uv__handle_closing(handle);
if (handle->wait_handle != INVALID_HANDLE_VALUE) {
- /* This blocks until either the wait was cancelled, or the callback has */
- /* completed. */
+ /* This blocks until either the wait was cancelled, or the callback has
+ * completed. */
BOOL r = UnregisterWaitEx(handle->wait_handle, INVALID_HANDLE_VALUE);
if (!r) {
/* This should never happen, and if it happens, we can't recover... */
@@ -912,7 +924,7 @@ void uv_process_close(uv_loop_t* loop, uv_process_t* handle) {
void uv_process_endgame(uv_loop_t* loop, uv_process_t* handle) {
assert(!handle->exit_cb_pending);
- assert(handle->flags & UV__HANDLE_CLOSING);
+ assert(handle->flags & UV_HANDLE_CLOSING);
assert(!(handle->flags & UV_HANDLE_CLOSED));
/* Clean-up the process handle. */
@@ -947,11 +959,19 @@ int uv_spawn(uv_loop_t* loop,
return UV_EINVAL;
}
+ if (options->cpumask != NULL) {
+ if (options->cpumask_size < (size_t)uv_cpumask_size()) {
+ return UV_EINVAL;
+ }
+ }
+
assert(options->file != NULL);
assert(!(options->flags & ~(UV_PROCESS_DETACHED |
UV_PROCESS_SETGID |
UV_PROCESS_SETUID |
UV_PROCESS_WINDOWS_HIDE |
+ UV_PROCESS_WINDOWS_HIDE_CONSOLE |
+ UV_PROCESS_WINDOWS_HIDE_GUI |
UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS)));
err = uv_utf8_to_utf16_alloc(options->file, &application);
@@ -1051,15 +1071,26 @@ int uv_spawn(uv_loop_t* loop,
startup.hStdOutput = uv__stdio_handle(process->child_stdio_buffer, 1);
startup.hStdError = uv__stdio_handle(process->child_stdio_buffer, 2);
- if (options->flags & UV_PROCESS_WINDOWS_HIDE) {
+ process_flags = CREATE_UNICODE_ENVIRONMENT;
+
+ if ((options->flags & UV_PROCESS_WINDOWS_HIDE_CONSOLE) ||
+ (options->flags & UV_PROCESS_WINDOWS_HIDE)) {
+ /* Avoid creating console window if stdio is not inherited. */
+ for (i = 0; i < options->stdio_count; i++) {
+ if (options->stdio[i].flags & UV_INHERIT_FD)
+ break;
+ if (i == options->stdio_count - 1)
+ process_flags |= CREATE_NO_WINDOW;
+ }
+ }
+ if ((options->flags & UV_PROCESS_WINDOWS_HIDE_GUI) ||
+ (options->flags & UV_PROCESS_WINDOWS_HIDE)) {
/* Use SW_HIDE to avoid any potential process window. */
startup.wShowWindow = SW_HIDE;
} else {
startup.wShowWindow = SW_SHOWDEFAULT;
}
- process_flags = CREATE_UNICODE_ENVIRONMENT;
-
if (options->flags & UV_PROCESS_DETACHED) {
/* Note that we're not setting the CREATE_BREAKAWAY_FROM_JOB flag. That
* means that libuv might not let you create a fully daemonized process
@@ -1074,6 +1105,12 @@ int uv_spawn(uv_loop_t* loop,
process_flags |= DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP;
}
+ if (options->cpumask != NULL) {
+ /* Create the child in a suspended state so we have a chance to set
+ its process affinity before it runs. */
+ process_flags |= CREATE_SUSPENDED;
+ }
+
if (!CreateProcessW(application_path,
arguments,
NULL,
@@ -1089,14 +1126,57 @@ int uv_spawn(uv_loop_t* loop,
goto done;
}
- /* Spawn succeeded */
- /* Beyond this point, failure is reported asynchronously. */
+ if (options->cpumask != NULL) {
+ /* The child is currently suspended. Set its process affinity
+ or terminate it if we can't. */
+ int i;
+ int cpumasksize;
+ DWORD_PTR sysmask;
+ DWORD_PTR oldmask;
+ DWORD_PTR newmask;
+
+ cpumasksize = uv_cpumask_size();
+
+ if (!GetProcessAffinityMask(info.hProcess, &oldmask, &sysmask)) {
+ err = GetLastError();
+ TerminateProcess(info.hProcess, 1);
+ goto done;
+ }
+
+ newmask = 0;
+ for (i = 0; i < cpumasksize; i++) {
+ if (options->cpumask[i]) {
+ if (oldmask & (((DWORD_PTR)1) << i)) {
+ newmask |= ((DWORD_PTR)1) << i;
+ } else {
+ err = UV_EINVAL;
+ TerminateProcess(info.hProcess, 1);
+ goto done;
+ }
+ }
+ }
+
+ if (!SetProcessAffinityMask(info.hProcess, newmask)) {
+ err = GetLastError();
+ TerminateProcess(info.hProcess, 1);
+ goto done;
+ }
+
+ /* The process affinity of the child is set. Let it run. */
+ if (ResumeThread(info.hThread) == ((DWORD)-1)) {
+ err = GetLastError();
+ TerminateProcess(info.hProcess, 1);
+ goto done;
+ }
+ }
+
+ /* Spawn succeeded. Beyond this point, failure is reported asynchronously. */
process->process_handle = info.hProcess;
process->pid = info.dwProcessId;
- /* If the process isn't spawned as detached, assign to the global job */
- /* object so windows will kill it when the parent process dies. */
+ /* If the process isn't spawned as detached, assign to the global job object
+ * so windows will kill it when the parent process dies. */
if (!(options->flags & UV_PROCESS_DETACHED)) {
uv_once(&uv_global_job_handle_init_guard_, uv__init_global_job_handle);
@@ -1123,7 +1203,8 @@ int uv_spawn(uv_loop_t* loop,
if (fdopt->flags & UV_CREATE_PIPE &&
fdopt->data.stream->type == UV_NAMED_PIPE &&
((uv_pipe_t*) fdopt->data.stream)->ipc) {
- ((uv_pipe_t*) fdopt->data.stream)->pipe.conn.ipc_pid = info.dwProcessId;
+ ((uv_pipe_t*) fdopt->data.stream)->pipe.conn.ipc_remote_pid =
+ info.dwProcessId;
}
}
@@ -1139,8 +1220,8 @@ int uv_spawn(uv_loop_t* loop,
assert(!err);
- /* Make the handle active. It will remain active until the exit callback */
- /* is made or the handle is closed, whichever happens first. */
+ /* Make the handle active. It will remain active until the exit callback is
+ * made or the handle is closed, whichever happens first. */
uv__handle_start(process);
/* Cleanup, whether we succeeded or failed. */
@@ -1163,20 +1244,24 @@ int uv_spawn(uv_loop_t* loop,
static int uv__kill(HANDLE process_handle, int signum) {
+ if (signum < 0 || signum >= NSIG) {
+ return UV_EINVAL;
+ }
+
switch (signum) {
case SIGTERM:
case SIGKILL:
case SIGINT: {
- /* Unconditionally terminate the process. On Windows, killed processes */
- /* normally return 1. */
+ /* Unconditionally terminate the process. On Windows, killed processes
+ * normally return 1. */
DWORD status;
int err;
if (TerminateProcess(process_handle, 1))
return 0;
- /* If the process already exited before TerminateProcess was called, */
- /* TerminateProcess will fail with ERROR_ACCESS_DENIED. */
+ /* If the process already exited before TerminateProcess was called,.
+ * TerminateProcess will fail with ERROR_ACCESS_DENIED. */
err = GetLastError();
if (err == ERROR_ACCESS_DENIED &&
GetExitCodeProcess(process_handle, &status) &&
@@ -1227,8 +1312,15 @@ int uv_process_kill(uv_process_t* process, int signum) {
int uv_kill(int pid, int signum) {
int err;
- HANDLE process_handle = OpenProcess(PROCESS_TERMINATE |
- PROCESS_QUERY_INFORMATION, FALSE, pid);
+ HANDLE process_handle;
+
+ if (pid == 0) {
+ process_handle = GetCurrentProcess();
+ } else {
+ process_handle = OpenProcess(PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION,
+ FALSE,
+ pid);
+ }
if (process_handle == NULL) {
err = GetLastError();
diff --git a/Utilities/cmlibuv/src/win/req.c b/Utilities/cmlibuv/src/win/req.c
deleted file mode 100644
index 111cc5e28..000000000
--- a/Utilities/cmlibuv/src/win/req.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#include <assert.h>
-
-#include "uv.h"
-#include "internal.h"
diff --git a/Utilities/cmlibuv/src/win/signal.c b/Utilities/cmlibuv/src/win/signal.c
index 7b42dd992..276dc6097 100644
--- a/Utilities/cmlibuv/src/win/signal.c
+++ b/Utilities/cmlibuv/src/win/signal.c
@@ -47,13 +47,13 @@ void uv_signals_init(void) {
static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2) {
- /* Compare signums first so all watchers with the same signnum end up */
- /* adjacent. */
+ /* Compare signums first so all watchers with the same signnum end up
+ * adjacent. */
if (w1->signum < w2->signum) return -1;
if (w1->signum > w2->signum) return 1;
- /* Sort by loop pointer, so we can easily look up the first item after */
- /* { .signum = x, .loop = NULL } */
+ /* Sort by loop pointer, so we can easily look up the first item after
+ * { .signum = x, .loop = NULL }. */
if ((uintptr_t) w1->loop < (uintptr_t) w2->loop) return -1;
if ((uintptr_t) w1->loop > (uintptr_t) w2->loop) return 1;
@@ -64,7 +64,7 @@ static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2) {
}
-RB_GENERATE_STATIC(uv_signal_tree_s, uv_signal_s, tree_entry, uv__signal_compare);
+RB_GENERATE_STATIC(uv_signal_tree_s, uv_signal_s, tree_entry, uv__signal_compare)
/*
@@ -90,7 +90,7 @@ int uv__signal_dispatch(int signum) {
unsigned long previous = InterlockedExchange(
(volatile LONG*) &handle->pending_signum, signum);
- if (handle->flags & UV__SIGNAL_ONE_SHOT_DISPATCHED)
+ if (handle->flags & UV_SIGNAL_ONE_SHOT_DISPATCHED)
continue;
if (!previous) {
@@ -98,8 +98,8 @@ int uv__signal_dispatch(int signum) {
}
dispatched = 1;
- if (handle->flags & UV__SIGNAL_ONE_SHOT)
- handle->flags |= UV__SIGNAL_ONE_SHOT_DISPATCHED;
+ if (handle->flags & UV_SIGNAL_ONE_SHOT)
+ handle->flags |= UV_SIGNAL_ONE_SHOT_DISPATCHED;
}
LeaveCriticalSection(&uv__signal_lock);
@@ -118,10 +118,10 @@ static BOOL WINAPI uv__signal_control_handler(DWORD type) {
case CTRL_CLOSE_EVENT:
if (uv__signal_dispatch(SIGHUP)) {
- /* Windows will terminate the process after the control handler */
- /* returns. After that it will just terminate our process. Therefore */
- /* block the signal handler so the main loop has some time to pick */
- /* up the signal and do something for a few seconds. */
+ /* Windows will terminate the process after the control handler
+ * returns. After that it will just terminate our process. Therefore
+ * block the signal handler so the main loop has some time to pick up
+ * the signal and do something for a few seconds. */
Sleep(INFINITE);
return TRUE;
}
@@ -129,8 +129,8 @@ static BOOL WINAPI uv__signal_control_handler(DWORD type) {
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
- /* These signals are only sent to services. Services have their own */
- /* notification mechanism, so there's no point in handling these. */
+ /* These signals are only sent to services. Services have their own
+ * notification mechanism, so there's no point in handling these. */
default:
/* We don't handle these. */
@@ -190,13 +190,13 @@ int uv__signal_start(uv_signal_t* handle,
int signum,
int oneshot) {
/* Test for invalid signal values. */
- if (signum != SIGWINCH && (signum <= 0 || signum >= NSIG))
+ if (signum <= 0 || signum >= NSIG)
return UV_EINVAL;
- /* Short circuit: if the signal watcher is already watching {signum} don't */
- /* go through the process of deregistering and registering the handler. */
- /* Additionally, this avoids pending signals getting lost in the (small) */
- /* time frame that handle->signum == 0. */
+ /* Short circuit: if the signal watcher is already watching {signum} don't go
+ * through the process of deregistering and registering the handler.
+ * Additionally, this avoids pending signals getting lost in the (small) time
+ * frame that handle->signum == 0. */
if (signum == handle->signum) {
handle->signal_cb = signal_cb;
return 0;
@@ -213,7 +213,7 @@ int uv__signal_start(uv_signal_t* handle,
handle->signum = signum;
if (oneshot)
- handle->flags |= UV__SIGNAL_ONE_SHOT;
+ handle->flags |= UV_SIGNAL_ONE_SHOT;
RB_INSERT(uv_signal_tree_s, &uv__signal_tree, handle);
@@ -237,16 +237,16 @@ void uv_process_signal_req(uv_loop_t* loop, uv_signal_t* handle,
(volatile LONG*) &handle->pending_signum, 0);
assert(dispatched_signum != 0);
- /* Check if the pending signal equals the signum that we are watching for. */
- /* These can get out of sync when the handler is stopped and restarted */
- /* while the signal_req is pending. */
+ /* Check if the pending signal equals the signum that we are watching for.
+ * These can get out of sync when the handler is stopped and restarted while
+ * the signal_req is pending. */
if (dispatched_signum == handle->signum)
handle->signal_cb(handle, dispatched_signum);
- if (handle->flags & UV__SIGNAL_ONE_SHOT)
+ if (handle->flags & UV_SIGNAL_ONE_SHOT)
uv_signal_stop(handle);
- if (handle->flags & UV__HANDLE_CLOSING) {
+ if (handle->flags & UV_HANDLE_CLOSING) {
/* When it is closing, it must be stopped at this point. */
assert(handle->signum == 0);
uv_want_endgame(loop, (uv_handle_t*) handle);
@@ -265,7 +265,7 @@ void uv_signal_close(uv_loop_t* loop, uv_signal_t* handle) {
void uv_signal_endgame(uv_loop_t* loop, uv_signal_t* handle) {
- assert(handle->flags & UV__HANDLE_CLOSING);
+ assert(handle->flags & UV_HANDLE_CLOSING);
assert(!(handle->flags & UV_HANDLE_CLOSED));
assert(handle->signum == 0);
diff --git a/Utilities/cmlibuv/src/win/stream-inl.h b/Utilities/cmlibuv/src/win/stream-inl.h
index bf12148af..40f5ddd51 100644
--- a/Utilities/cmlibuv/src/win/stream-inl.h
+++ b/Utilities/cmlibuv/src/win/stream-inl.h
@@ -36,19 +36,18 @@ INLINE static void uv_stream_init(uv_loop_t* loop,
uv__handle_init(loop, (uv_handle_t*) handle, type);
handle->write_queue_size = 0;
handle->activecnt = 0;
-}
-
-
-INLINE static void uv_connection_init(uv_stream_t* handle) {
- handle->flags |= UV_HANDLE_CONNECTION;
+ handle->stream.conn.shutdown_req = NULL;
handle->stream.conn.write_reqs_pending = 0;
UV_REQ_INIT(&handle->read_req, UV_READ);
handle->read_req.event_handle = NULL;
handle->read_req.wait_handle = INVALID_HANDLE_VALUE;
handle->read_req.data = handle;
+}
- handle->stream.conn.shutdown_req = NULL;
+
+INLINE static void uv_connection_init(uv_stream_t* handle) {
+ handle->flags |= UV_HANDLE_CONNECTION;
}
diff --git a/Utilities/cmlibuv/src/win/stream.c b/Utilities/cmlibuv/src/win/stream.c
index 13cbfdcb9..7656627e9 100644
--- a/Utilities/cmlibuv/src/win/stream.c
+++ b/Utilities/cmlibuv/src/win/stream.c
@@ -105,12 +105,10 @@ int uv_read_stop(uv_stream_t* handle) {
err = 0;
if (handle->type == UV_TTY) {
err = uv_tty_read_stop((uv_tty_t*) handle);
+ } else if (handle->type == UV_NAMED_PIPE) {
+ uv__pipe_read_stop((uv_pipe_t*) handle);
} else {
- if (handle->type == UV_NAMED_PIPE) {
- uv__pipe_stop_read((uv_pipe_t*) handle);
- } else {
- handle->flags &= ~UV_HANDLE_READING;
- }
+ handle->flags &= ~UV_HANDLE_READING;
DECREASE_ACTIVE_COUNT(handle->loop, handle);
}
@@ -136,7 +134,8 @@ int uv_write(uv_write_t* req,
err = uv_tcp_write(loop, req, (uv_tcp_t*) handle, bufs, nbufs, cb);
break;
case UV_NAMED_PIPE:
- err = uv_pipe_write(loop, req, (uv_pipe_t*) handle, bufs, nbufs, cb);
+ err = uv__pipe_write(
+ loop, req, (uv_pipe_t*) handle, bufs, nbufs, NULL, cb);
break;
case UV_TTY:
err = uv_tty_write(loop, req, (uv_tty_t*) handle, bufs, nbufs, cb);
@@ -158,25 +157,18 @@ int uv_write2(uv_write_t* req,
uv_loop_t* loop = handle->loop;
int err;
- if (!(handle->flags & UV_HANDLE_WRITABLE)) {
- return UV_EPIPE;
+ if (send_handle == NULL) {
+ return uv_write(req, handle, bufs, nbufs, cb);
}
- err = ERROR_INVALID_PARAMETER;
- switch (handle->type) {
- case UV_NAMED_PIPE:
- err = uv_pipe_write2(loop,
- req,
- (uv_pipe_t*) handle,
- bufs,
- nbufs,
- send_handle,
- cb);
- break;
- default:
- assert(0);
+ if (handle->type != UV_NAMED_PIPE || !((uv_pipe_t*) handle)->ipc) {
+ return UV_EINVAL;
+ } else if (!(handle->flags & UV_HANDLE_WRITABLE)) {
+ return UV_EPIPE;
}
+ err = uv__pipe_write(
+ loop, req, (uv_pipe_t*) handle, bufs, nbufs, send_handle, cb);
return uv_translate_sys_error(err);
}
@@ -184,7 +176,7 @@ int uv_write2(uv_write_t* req,
int uv_try_write(uv_stream_t* stream,
const uv_buf_t bufs[],
unsigned int nbufs) {
- if (stream->flags & UV__HANDLE_CLOSING)
+ if (stream->flags & UV_HANDLE_CLOSING)
return UV_EBADF;
if (!(stream->flags & UV_HANDLE_WRITABLE))
return UV_EPIPE;
diff --git a/Utilities/cmlibuv/src/win/tcp.c b/Utilities/cmlibuv/src/win/tcp.c
index 972539f4d..f2cb5271b 100644
--- a/Utilities/cmlibuv/src/win/tcp.c
+++ b/Utilities/cmlibuv/src/win/tcp.c
@@ -99,8 +99,8 @@ static int uv_tcp_set_socket(uv_loop_t* loop,
if (!SetHandleInformation((HANDLE) socket, HANDLE_FLAG_INHERIT, 0))
return GetLastError();
- /* Associate it with the I/O completion port. */
- /* Use uv_handle_t pointer as completion key. */
+ /* Associate it with the I/O completion port. Use uv_handle_t pointer as
+ * completion key. */
if (CreateIoCompletionPort((HANDLE)socket,
loop->iocp,
(ULONG_PTR)socket,
@@ -118,15 +118,12 @@ static int uv_tcp_set_socket(uv_loop_t* loop,
non_ifs_lsp = uv_tcp_non_ifs_lsp_ipv4;
}
- if (pSetFileCompletionNotificationModes &&
- !(handle->flags & UV_HANDLE_EMULATE_IOCP) && !non_ifs_lsp) {
- if (pSetFileCompletionNotificationModes((HANDLE) socket,
- FILE_SKIP_SET_EVENT_ON_HANDLE |
- FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) {
- handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP;
- } else if (GetLastError() != ERROR_INVALID_FUNCTION) {
+ if (!(handle->flags & UV_HANDLE_EMULATE_IOCP) && !non_ifs_lsp) {
+ UCHAR sfcnm_flags =
+ FILE_SKIP_SET_EVENT_ON_HANDLE | FILE_SKIP_COMPLETION_PORT_ON_SUCCESS;
+ if (!SetFileCompletionNotificationModes((HANDLE) socket, sfcnm_flags))
return GetLastError();
- }
+ handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP;
}
if (handle->flags & UV_HANDLE_TCP_NODELAY) {
@@ -220,7 +217,7 @@ void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) {
UNREGISTER_HANDLE_REQ(loop, handle, handle->stream.conn.shutdown_req);
err = 0;
- if (handle->flags & UV__HANDLE_CLOSING) {
+ if (handle->flags & UV_HANDLE_CLOSING) {
err = ERROR_OPERATION_ABORTED;
} else if (shutdown(handle->socket, SD_SEND) == SOCKET_ERROR) {
err = WSAGetLastError();
@@ -236,7 +233,7 @@ void uv_tcp_endgame(uv_loop_t* loop, uv_tcp_t* handle) {
return;
}
- if (handle->flags & UV__HANDLE_CLOSING &&
+ if (handle->flags & UV_HANDLE_CLOSING &&
handle->reqs_pending == 0) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
@@ -326,9 +323,9 @@ static int uv_tcp_try_bind(uv_tcp_t* handle,
on = (flags & UV_TCP_IPV6ONLY) != 0;
- /* TODO: how to handle errors? This may fail if there is no ipv4 stack */
- /* available, or when run on XP/2003 which have no support for dualstack */
- /* sockets. For now we're silently ignoring the error. */
+ /* TODO: how to handle errors? This may fail if there is no ipv4 stack
+ * available, or when run on XP/2003 which have no support for dualstack
+ * sockets. For now we're silently ignoring the error. */
setsockopt(handle->socket,
IPPROTO_IPV6,
IPV6_V6ONLY,
@@ -459,8 +456,6 @@ static void uv_tcp_queue_accept(uv_tcp_t* handle, uv_tcp_accept_t* req) {
INFINITE, WT_EXECUTEINWAITTHREAD)) {
SET_REQ_ERROR(req, GetLastError());
uv_insert_pending_req(loop, (uv_req_t*)req);
- handle->reqs_pending++;
- return;
}
} else {
/* Make this req pending reporting an error. */
@@ -628,9 +623,9 @@ int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) {
uv_tcp_queue_accept(handle, req);
}
- /* Initialize other unused requests too, because uv_tcp_endgame */
- /* doesn't know how how many requests were initialized, so it will */
- /* try to clean up {uv_simultaneous_server_accepts} requests. */
+ /* Initialize other unused requests too, because uv_tcp_endgame doesn't
+ * know how many requests were initialized, so it will try to clean up
+ * {uv_simultaneous_server_accepts} requests. */
for (i = simultaneous_accepts; i < uv_simultaneous_server_accepts; i++) {
req = &handle->tcp.serv.accept_reqs[i];
UV_REQ_INIT(req, UV_ACCEPT);
@@ -685,7 +680,7 @@ int uv_tcp_accept(uv_tcp_t* server, uv_tcp_t* client) {
req->next_pending = NULL;
req->accept_socket = INVALID_SOCKET;
- if (!(server->flags & UV__HANDLE_CLOSING)) {
+ if (!(server->flags & UV_HANDLE_CLOSING)) {
/* Check if we're in a middle of changing the number of pending accepts. */
if (!(server->flags & UV_HANDLE_TCP_ACCEPT_STATE_CHANGING)) {
uv_tcp_queue_accept(server, req);
@@ -723,8 +718,8 @@ int uv_tcp_read_start(uv_tcp_t* handle, uv_alloc_cb alloc_cb,
handle->alloc_cb = alloc_cb;
INCREASE_ACTIVE_COUNT(loop, handle);
- /* If reading was stopped and then started again, there could still be a */
- /* read request pending. */
+ /* If reading was stopped and then started again, there could still be a read
+ * request pending. */
if (!(handle->flags & UV_HANDLE_READ_PENDING)) {
if (handle->flags & UV_HANDLE_EMULATE_IOCP &&
!handle->read_req.event_handle) {
@@ -747,10 +742,15 @@ static int uv_tcp_try_connect(uv_connect_t* req,
uv_connect_cb cb) {
uv_loop_t* loop = handle->loop;
const struct sockaddr* bind_addr;
+ struct sockaddr_storage converted;
BOOL success;
DWORD bytes;
int err;
+ err = uv__convert_to_localhost_if_unspecified(addr, &converted);
+ if (err)
+ return err;
+
if (handle->delayed_error) {
return handle->delayed_error;
}
@@ -782,12 +782,12 @@ static int uv_tcp_try_connect(uv_connect_t* req,
memset(&req->u.io.overlapped, 0, sizeof(req->u.io.overlapped));
success = handle->tcp.conn.func_connectex(handle->socket,
- addr,
- addrlen,
- NULL,
- 0,
- &bytes,
- &req->u.io.overlapped);
+ (const struct sockaddr*) &converted,
+ addrlen,
+ NULL,
+ 0,
+ &bytes,
+ &req->u.io.overlapped);
if (UV_SUCCEEDED_WITHOUT_IOCP(success)) {
/* Process the req without IOCP. */
@@ -809,44 +809,24 @@ static int uv_tcp_try_connect(uv_connect_t* req,
int uv_tcp_getsockname(const uv_tcp_t* handle,
struct sockaddr* name,
int* namelen) {
- int result;
-
- if (handle->socket == INVALID_SOCKET) {
- return UV_EINVAL;
- }
- if (handle->delayed_error) {
- return uv_translate_sys_error(handle->delayed_error);
- }
-
- result = getsockname(handle->socket, name, namelen);
- if (result != 0) {
- return uv_translate_sys_error(WSAGetLastError());
- }
-
- return 0;
+ return uv__getsockpeername((const uv_handle_t*) handle,
+ getsockname,
+ name,
+ namelen,
+ handle->delayed_error);
}
int uv_tcp_getpeername(const uv_tcp_t* handle,
struct sockaddr* name,
int* namelen) {
- int result;
- if (handle->socket == INVALID_SOCKET) {
- return UV_EINVAL;
- }
-
- if (handle->delayed_error) {
- return uv_translate_sys_error(handle->delayed_error);
- }
-
- result = getpeername(handle->socket, name, namelen);
- if (result != 0) {
- return uv_translate_sys_error(WSAGetLastError());
- }
-
- return 0;
+ return uv__getsockpeername((const uv_handle_t*) handle,
+ getpeername,
+ name,
+ namelen,
+ handle->delayed_error);
}
@@ -945,6 +925,7 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
uv_req_t* req) {
DWORD bytes, flags, err;
uv_buf_t buf;
+ int count;
assert(handle->type == UV_TCP);
@@ -962,8 +943,7 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
err = GET_REQ_SOCK_ERROR(req);
if (err == WSAECONNABORTED) {
- /*
- * Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with Unix.
+ /* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with Unix.
*/
err = WSAECONNRESET;
}
@@ -1000,7 +980,8 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
}
/* Do nonblocking reads until the buffer is empty */
- while (handle->flags & UV_HANDLE_READING) {
+ count = 32;
+ while ((handle->flags & UV_HANDLE_READING) && (count-- > 0)) {
buf = uv_buf_init(NULL, 0);
handle->alloc_cb((uv_handle_t*) handle, 65536, &buf);
if (buf.base == NULL || buf.len == 0) {
@@ -1043,8 +1024,8 @@ void uv_process_tcp_read_req(uv_loop_t* loop, uv_tcp_t* handle,
DECREASE_ACTIVE_COUNT(loop, handle);
if (err == WSAECONNABORTED) {
- /* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with */
- /* Unix. */
+ /* Turn WSAECONNABORTED into UV_ECONNRESET to be consistent with
+ * Unix. */
err = WSAECONNRESET;
}
@@ -1116,10 +1097,9 @@ void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle,
assert(handle->type == UV_TCP);
- /* If handle->accepted_socket is not a valid socket, then */
- /* uv_queue_accept must have failed. This is a serious error. We stop */
- /* accepting connections and report this error to the connection */
- /* callback. */
+ /* If handle->accepted_socket is not a valid socket, then uv_queue_accept
+ * must have failed. This is a serious error. We stop accepting connections
+ * and report this error to the connection callback. */
if (req->accept_socket == INVALID_SOCKET) {
if (handle->flags & UV_HANDLE_LISTENING) {
handle->flags &= ~UV_HANDLE_LISTENING;
@@ -1144,9 +1124,9 @@ void uv_process_tcp_accept_req(uv_loop_t* loop, uv_tcp_t* handle,
handle->stream.serv.connection_cb((uv_stream_t*)handle, 0);
}
} else {
- /* Error related to accepted socket is ignored because the server */
- /* socket may still be healthy. If the server socket is broken */
- /* uv_queue_accept will detect it. */
+ /* Error related to accepted socket is ignored because the server socket
+ * may still be healthy. If the server socket is broken uv_queue_accept
+ * will detect it. */
closesocket(req->accept_socket);
req->accept_socket = INVALID_SOCKET;
if (handle->flags & UV_HANDLE_LISTENING) {
@@ -1168,11 +1148,14 @@ void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle,
err = 0;
if (REQ_SUCCESS(req)) {
- if (setsockopt(handle->socket,
- SOL_SOCKET,
- SO_UPDATE_CONNECT_CONTEXT,
- NULL,
- 0) == 0) {
+ if (handle->flags & UV_HANDLE_CLOSING) {
+ /* use UV_ECANCELED for consistency with Unix */
+ err = ERROR_OPERATION_ABORTED;
+ } else if (setsockopt(handle->socket,
+ SOL_SOCKET,
+ SO_UPDATE_CONNECT_CONTEXT,
+ NULL,
+ 0) == 0) {
uv_connection_init((uv_stream_t*)handle);
handle->flags |= UV_HANDLE_READABLE | UV_HANDLE_WRITABLE;
loop->active_tcp_streams++;
@@ -1188,40 +1171,76 @@ void uv_process_tcp_connect_req(uv_loop_t* loop, uv_tcp_t* handle,
}
-int uv_tcp_import(uv_tcp_t* tcp, uv__ipc_socket_info_ex* socket_info_ex,
- int tcp_connection) {
+int uv__tcp_xfer_export(uv_tcp_t* handle,
+ int target_pid,
+ uv__ipc_socket_xfer_type_t* xfer_type,
+ uv__ipc_socket_xfer_info_t* xfer_info) {
+ if (handle->flags & UV_HANDLE_CONNECTION) {
+ *xfer_type = UV__IPC_SOCKET_XFER_TCP_CONNECTION;
+ } else {
+ *xfer_type = UV__IPC_SOCKET_XFER_TCP_SERVER;
+ /* We're about to share the socket with another process. Because this is a
+ * listening socket, we assume that the other process will be accepting
+ * connections on it. Thus, before sharing the socket with another process,
+ * we call listen here in the parent process. */
+ if (!(handle->flags & UV_HANDLE_LISTENING)) {
+ if (!(handle->flags & UV_HANDLE_BOUND)) {
+ return ERROR_NOT_SUPPORTED;
+ }
+ if (handle->delayed_error == 0 &&
+ listen(handle->socket, SOMAXCONN) == SOCKET_ERROR) {
+ handle->delayed_error = WSAGetLastError();
+ }
+ }
+ }
+
+ if (WSADuplicateSocketW(handle->socket, target_pid, &xfer_info->socket_info))
+ return WSAGetLastError();
+ xfer_info->delayed_error = handle->delayed_error;
+
+ /* Mark the local copy of the handle as 'shared' so we behave in a way that's
+ * friendly to the process(es) that we share the socket with. */
+ handle->flags |= UV_HANDLE_SHARED_TCP_SOCKET;
+
+ return 0;
+}
+
+
+int uv__tcp_xfer_import(uv_tcp_t* tcp,
+ uv__ipc_socket_xfer_type_t xfer_type,
+ uv__ipc_socket_xfer_info_t* xfer_info) {
int err;
- SOCKET socket = WSASocketW(FROM_PROTOCOL_INFO,
- FROM_PROTOCOL_INFO,
- FROM_PROTOCOL_INFO,
- &socket_info_ex->socket_info,
- 0,
- WSA_FLAG_OVERLAPPED);
+ SOCKET socket;
+
+ assert(xfer_type == UV__IPC_SOCKET_XFER_TCP_SERVER ||
+ xfer_type == UV__IPC_SOCKET_XFER_TCP_CONNECTION);
+
+ socket = WSASocketW(FROM_PROTOCOL_INFO,
+ FROM_PROTOCOL_INFO,
+ FROM_PROTOCOL_INFO,
+ &xfer_info->socket_info,
+ 0,
+ WSA_FLAG_OVERLAPPED);
if (socket == INVALID_SOCKET) {
return WSAGetLastError();
}
- err = uv_tcp_set_socket(tcp->loop,
- tcp,
- socket,
- socket_info_ex->socket_info.iAddressFamily,
- 1);
+ err = uv_tcp_set_socket(
+ tcp->loop, tcp, socket, xfer_info->socket_info.iAddressFamily, 1);
if (err) {
closesocket(socket);
return err;
}
- if (tcp_connection) {
+ tcp->delayed_error = xfer_info->delayed_error;
+ tcp->flags |= UV_HANDLE_BOUND | UV_HANDLE_SHARED_TCP_SOCKET;
+
+ if (xfer_type == UV__IPC_SOCKET_XFER_TCP_CONNECTION) {
uv_connection_init((uv_stream_t*)tcp);
tcp->flags |= UV_HANDLE_READABLE | UV_HANDLE_WRITABLE;
}
- tcp->flags |= UV_HANDLE_BOUND;
- tcp->flags |= UV_HANDLE_SHARED_TCP_SOCKET;
-
- tcp->delayed_error = socket_info_ex->delayed_error;
-
tcp->loop->active_tcp_streams++;
return 0;
}
@@ -1267,39 +1286,6 @@ int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) {
}
-int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid,
- LPWSAPROTOCOL_INFOW protocol_info) {
- if (!(handle->flags & UV_HANDLE_CONNECTION)) {
- /*
- * We're about to share the socket with another process. Because
- * this is a listening socket, we assume that the other process will
- * be accepting connections on it. So, before sharing the socket
- * with another process, we call listen here in the parent process.
- */
-
- if (!(handle->flags & UV_HANDLE_LISTENING)) {
- if (!(handle->flags & UV_HANDLE_BOUND)) {
- return ERROR_INVALID_PARAMETER;
- }
-
- if (!(handle->delayed_error)) {
- if (listen(handle->socket, SOMAXCONN) == SOCKET_ERROR) {
- handle->delayed_error = WSAGetLastError();
- }
- }
- }
- }
-
- if (WSADuplicateSocketW(handle->socket, pid, protocol_info)) {
- return WSAGetLastError();
- }
-
- handle->flags |= UV_HANDLE_SHARED_TCP_SOCKET;
-
- return 0;
-}
-
-
int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) {
if (handle->flags & UV_HANDLE_CONNECTION) {
return UV_EINVAL;
@@ -1340,8 +1326,8 @@ static int uv_tcp_try_cancel_io(uv_tcp_t* tcp) {
non_ifs_lsp = (tcp->flags & UV_HANDLE_IPV6) ? uv_tcp_non_ifs_lsp_ipv6 :
uv_tcp_non_ifs_lsp_ipv4;
- /* If there are non-ifs LSPs then try to obtain a base handle for the */
- /* socket. This will always fail on Windows XP/3k. */
+ /* If there are non-ifs LSPs then try to obtain a base handle for the socket.
+ * This will always fail on Windows XP/3k. */
if (non_ifs_lsp) {
DWORD bytes;
if (WSAIoctl(socket,
@@ -1373,38 +1359,37 @@ void uv_tcp_close(uv_loop_t* loop, uv_tcp_t* tcp) {
int close_socket = 1;
if (tcp->flags & UV_HANDLE_READ_PENDING) {
- /* In order for winsock to do a graceful close there must not be any */
- /* any pending reads, or the socket must be shut down for writing */
+ /* In order for winsock to do a graceful close there must not be any any
+ * pending reads, or the socket must be shut down for writing */
if (!(tcp->flags & UV_HANDLE_SHARED_TCP_SOCKET)) {
/* Just do shutdown on non-shared sockets, which ensures graceful close. */
shutdown(tcp->socket, SD_SEND);
} else if (uv_tcp_try_cancel_io(tcp) == 0) {
- /* In case of a shared socket, we try to cancel all outstanding I/O, */
- /* If that works, don't close the socket yet - wait for the read req to */
- /* return and close the socket in uv_tcp_endgame. */
+ /* In case of a shared socket, we try to cancel all outstanding I/O,. If
+ * that works, don't close the socket yet - wait for the read req to
+ * return and close the socket in uv_tcp_endgame. */
close_socket = 0;
} else {
- /* When cancelling isn't possible - which could happen when an LSP is */
- /* present on an old Windows version, we will have to close the socket */
- /* with a read pending. That is not nice because trailing sent bytes */
- /* may not make it to the other side. */
+ /* When cancelling isn't possible - which could happen when an LSP is
+ * present on an old Windows version, we will have to close the socket
+ * with a read pending. That is not nice because trailing sent bytes may
+ * not make it to the other side. */
}
} else if ((tcp->flags & UV_HANDLE_SHARED_TCP_SOCKET) &&
tcp->tcp.serv.accept_reqs != NULL) {
- /* Under normal circumstances closesocket() will ensure that all pending */
- /* accept reqs are canceled. However, when the socket is shared the */
- /* presence of another reference to the socket in another process will */
- /* keep the accept reqs going, so we have to ensure that these are */
- /* canceled. */
+ /* Under normal circumstances closesocket() will ensure that all pending
+ * accept reqs are canceled. However, when the socket is shared the
+ * presence of another reference to the socket in another process will keep
+ * the accept reqs going, so we have to ensure that these are canceled. */
if (uv_tcp_try_cancel_io(tcp) != 0) {
- /* When cancellation is not possible, there is another option: we can */
- /* close the incoming sockets, which will also cancel the accept */
- /* operations. However this is not cool because we might inadvertently */
- /* close a socket that just accepted a new connection, which will */
- /* cause the connection to be aborted. */
+ /* When cancellation is not possible, there is another option: we can
+ * close the incoming sockets, which will also cancel the accept
+ * operations. However this is not cool because we might inadvertently
+ * close a socket that just accepted a new connection, which will cause
+ * the connection to be aborted. */
unsigned int i;
for (i = 0; i < uv_simultaneous_server_accepts; i++) {
uv_tcp_accept_t* req = &tcp->tcp.serv.accept_reqs[i];
@@ -1446,6 +1431,8 @@ int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock) {
WSAPROTOCOL_INFOW protocol_info;
int opt_len;
int err;
+ struct sockaddr_storage saddr;
+ int saddr_len;
/* Detect the address family of the socket. */
opt_len = (int) sizeof protocol_info;
@@ -1466,6 +1453,19 @@ int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock) {
return uv_translate_sys_error(err);
}
+ /* Support already active socket. */
+ saddr_len = sizeof(saddr);
+ if (!uv_tcp_getsockname(handle, (struct sockaddr*) &saddr, &saddr_len)) {
+ /* Socket is already bound. */
+ handle->flags |= UV_HANDLE_BOUND;
+ saddr_len = sizeof(saddr);
+ if (!uv_tcp_getpeername(handle, (struct sockaddr*) &saddr, &saddr_len)) {
+ /* Socket is already connected. */
+ uv_connection_init((uv_stream_t*) handle);
+ handle->flags |= UV_HANDLE_READABLE | UV_HANDLE_WRITABLE;
+ }
+ }
+
return 0;
}
diff --git a/Utilities/cmlibuv/src/win/thread.c b/Utilities/cmlibuv/src/win/thread.c
index 91684e938..89c53ada7 100644
--- a/Utilities/cmlibuv/src/win/thread.c
+++ b/Utilities/cmlibuv/src/win/thread.c
@@ -23,29 +23,15 @@
#include <limits.h>
#include <stdlib.h>
+#if defined(__MINGW64_VERSION_MAJOR)
+/* MemoryBarrier expands to __mm_mfence in some cases (x86+sse2), which may
+ * require this header in some versions of mingw64. */
+#include <intrin.h>
+#endif
+
#include "uv.h"
#include "internal.h"
-
-#define HAVE_CONDVAR_API() (pInitializeConditionVariable != NULL)
-
-static int uv_cond_fallback_init(uv_cond_t* cond);
-static void uv_cond_fallback_destroy(uv_cond_t* cond);
-static void uv_cond_fallback_signal(uv_cond_t* cond);
-static void uv_cond_fallback_broadcast(uv_cond_t* cond);
-static void uv_cond_fallback_wait(uv_cond_t* cond, uv_mutex_t* mutex);
-static int uv_cond_fallback_timedwait(uv_cond_t* cond,
- uv_mutex_t* mutex, uint64_t timeout);
-
-static int uv_cond_condvar_init(uv_cond_t* cond);
-static void uv_cond_condvar_destroy(uv_cond_t* cond);
-static void uv_cond_condvar_signal(uv_cond_t* cond);
-static void uv_cond_condvar_broadcast(uv_cond_t* cond);
-static void uv_cond_condvar_wait(uv_cond_t* cond, uv_mutex_t* mutex);
-static int uv_cond_condvar_timedwait(uv_cond_t* cond,
- uv_mutex_t* mutex, uint64_t timeout);
-
-
static void uv__once_inner(uv_once_t* guard, void (*callback)(void)) {
DWORD result;
HANDLE existing_event, created_event;
@@ -69,8 +55,8 @@ static void uv__once_inner(uv_once_t* guard, void (*callback)(void)) {
guard->ran = 1;
} else {
- /* We lost the race. Destroy the event we created and wait for the */
- /* existing one to become signaled. */
+ /* We lost the race. Destroy the event we created and wait for the existing
+ * one to become signaled. */
CloseHandle(created_event);
result = WaitForSingleObject(existing_event, INFINITE);
assert(result == WAIT_OBJECT_0);
@@ -126,9 +112,34 @@ static UINT __stdcall uv__thread_start(void* arg) {
int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) {
+ uv_thread_options_t params;
+ params.flags = UV_THREAD_NO_FLAGS;
+ return uv_thread_create_ex(tid, &params, entry, arg);
+}
+
+int uv_thread_create_ex(uv_thread_t* tid,
+ const uv_thread_options_t* params,
+ void (*entry)(void *arg),
+ void *arg) {
struct thread_ctx* ctx;
int err;
HANDLE thread;
+ SYSTEM_INFO sysinfo;
+ size_t stack_size;
+ size_t pagesize;
+
+ stack_size =
+ params->flags & UV_THREAD_HAS_STACK_SIZE ? params->stack_size : 0;
+
+ if (stack_size != 0) {
+ GetNativeSystemInfo(&sysinfo);
+ pagesize = (size_t)sysinfo.dwPageSize;
+ /* Round up to the nearest page boundary. */
+ stack_size = (stack_size + pagesize - 1) &~ (pagesize - 1);
+
+ if ((unsigned)stack_size != stack_size)
+ return UV_EINVAL;
+ }
ctx = uv__malloc(sizeof(*ctx));
if (ctx == NULL)
@@ -138,9 +149,9 @@ int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) {
ctx->arg = arg;
/* Create the thread in suspended state so we have a chance to pass
- * its own creation handle to it */
+ * its own creation handle to it */
thread = (HANDLE) _beginthreadex(NULL,
- 0,
+ (unsigned)stack_size,
uv__thread_start,
ctx,
CREATE_SUSPENDED,
@@ -182,6 +193,7 @@ int uv_thread_join(uv_thread_t *tid) {
else {
CloseHandle(*tid);
*tid = 0;
+ MemoryBarrier(); /* For feature parity with pthread_join(). */
return 0;
}
}
@@ -198,6 +210,11 @@ int uv_mutex_init(uv_mutex_t* mutex) {
}
+int uv_mutex_init_recursive(uv_mutex_t* mutex) {
+ return uv_mutex_init(mutex);
+}
+
+
void uv_mutex_destroy(uv_mutex_t* mutex) {
DeleteCriticalSection(mutex);
}
@@ -371,220 +388,35 @@ int uv_sem_trywait(uv_sem_t* sem) {
}
-/* This condition variable implementation is based on the SetEvent solution
- * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
- * We could not use the SignalObjectAndWait solution (section 3.4) because
- * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and
- * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs.
- */
-
-static int uv_cond_fallback_init(uv_cond_t* cond) {
- int err;
-
- /* Initialize the count to 0. */
- cond->fallback.waiters_count = 0;
-
- InitializeCriticalSection(&cond->fallback.waiters_count_lock);
-
- /* Create an auto-reset event. */
- cond->fallback.signal_event = CreateEvent(NULL, /* no security */
- FALSE, /* auto-reset event */
- FALSE, /* non-signaled initially */
- NULL); /* unnamed */
- if (!cond->fallback.signal_event) {
- err = GetLastError();
- goto error2;
- }
-
- /* Create a manual-reset event. */
- cond->fallback.broadcast_event = CreateEvent(NULL, /* no security */
- TRUE, /* manual-reset */
- FALSE, /* non-signaled */
- NULL); /* unnamed */
- if (!cond->fallback.broadcast_event) {
- err = GetLastError();
- goto error;
- }
-
- return 0;
-
-error:
- CloseHandle(cond->fallback.signal_event);
-error2:
- DeleteCriticalSection(&cond->fallback.waiters_count_lock);
- return uv_translate_sys_error(err);
-}
-
-
-static int uv_cond_condvar_init(uv_cond_t* cond) {
- pInitializeConditionVariable(&cond->cond_var);
- return 0;
-}
-
-
int uv_cond_init(uv_cond_t* cond) {
- uv__once_init();
-
- if (HAVE_CONDVAR_API())
- return uv_cond_condvar_init(cond);
- else
- return uv_cond_fallback_init(cond);
-}
-
-
-static void uv_cond_fallback_destroy(uv_cond_t* cond) {
- if (!CloseHandle(cond->fallback.broadcast_event))
- abort();
- if (!CloseHandle(cond->fallback.signal_event))
- abort();
- DeleteCriticalSection(&cond->fallback.waiters_count_lock);
-}
-
-
-static void uv_cond_condvar_destroy(uv_cond_t* cond) {
- /* nothing to do */
+ InitializeConditionVariable(&cond->cond_var);
+ return 0;
}
void uv_cond_destroy(uv_cond_t* cond) {
- if (HAVE_CONDVAR_API())
- uv_cond_condvar_destroy(cond);
- else
- uv_cond_fallback_destroy(cond);
-}
-
-
-static void uv_cond_fallback_signal(uv_cond_t* cond) {
- int have_waiters;
-
- /* Avoid race conditions. */
- EnterCriticalSection(&cond->fallback.waiters_count_lock);
- have_waiters = cond->fallback.waiters_count > 0;
- LeaveCriticalSection(&cond->fallback.waiters_count_lock);
-
- if (have_waiters)
- SetEvent(cond->fallback.signal_event);
-}
-
-
-static void uv_cond_condvar_signal(uv_cond_t* cond) {
- pWakeConditionVariable(&cond->cond_var);
+ /* nothing to do */
+ (void) &cond;
}
void uv_cond_signal(uv_cond_t* cond) {
- if (HAVE_CONDVAR_API())
- uv_cond_condvar_signal(cond);
- else
- uv_cond_fallback_signal(cond);
-}
-
-
-static void uv_cond_fallback_broadcast(uv_cond_t* cond) {
- int have_waiters;
-
- /* Avoid race conditions. */
- EnterCriticalSection(&cond->fallback.waiters_count_lock);
- have_waiters = cond->fallback.waiters_count > 0;
- LeaveCriticalSection(&cond->fallback.waiters_count_lock);
-
- if (have_waiters)
- SetEvent(cond->fallback.broadcast_event);
-}
-
-
-static void uv_cond_condvar_broadcast(uv_cond_t* cond) {
- pWakeAllConditionVariable(&cond->cond_var);
+ WakeConditionVariable(&cond->cond_var);
}
void uv_cond_broadcast(uv_cond_t* cond) {
- if (HAVE_CONDVAR_API())
- uv_cond_condvar_broadcast(cond);
- else
- uv_cond_fallback_broadcast(cond);
-}
-
-
-static int uv_cond_wait_helper(uv_cond_t* cond, uv_mutex_t* mutex,
- DWORD dwMilliseconds) {
- DWORD result;
- int last_waiter;
- HANDLE handles[2] = {
- cond->fallback.signal_event,
- cond->fallback.broadcast_event
- };
-
- /* Avoid race conditions. */
- EnterCriticalSection(&cond->fallback.waiters_count_lock);
- cond->fallback.waiters_count++;
- LeaveCriticalSection(&cond->fallback.waiters_count_lock);
-
- /* It's ok to release the <mutex> here since Win32 manual-reset events */
- /* maintain state when used with <SetEvent>. This avoids the "lost wakeup" */
- /* bug. */
- uv_mutex_unlock(mutex);
-
- /* Wait for either event to become signaled due to <uv_cond_signal> being */
- /* called or <uv_cond_broadcast> being called. */
- result = WaitForMultipleObjects(2, handles, FALSE, dwMilliseconds);
-
- EnterCriticalSection(&cond->fallback.waiters_count_lock);
- cond->fallback.waiters_count--;
- last_waiter = result == WAIT_OBJECT_0 + 1
- && cond->fallback.waiters_count == 0;
- LeaveCriticalSection(&cond->fallback.waiters_count_lock);
-
- /* Some thread called <pthread_cond_broadcast>. */
- if (last_waiter) {
- /* We're the last waiter to be notified or to stop waiting, so reset the */
- /* the manual-reset event. */
- ResetEvent(cond->fallback.broadcast_event);
- }
-
- /* Reacquire the <mutex>. */
- uv_mutex_lock(mutex);
-
- if (result == WAIT_OBJECT_0 || result == WAIT_OBJECT_0 + 1)
- return 0;
-
- if (result == WAIT_TIMEOUT)
- return UV_ETIMEDOUT;
-
- abort();
- return -1; /* Satisfy the compiler. */
-}
-
-
-static void uv_cond_fallback_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
- if (uv_cond_wait_helper(cond, mutex, INFINITE))
- abort();
-}
-
-
-static void uv_cond_condvar_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
- if (!pSleepConditionVariableCS(&cond->cond_var, mutex, INFINITE))
- abort();
+ WakeAllConditionVariable(&cond->cond_var);
}
void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
- if (HAVE_CONDVAR_API())
- uv_cond_condvar_wait(cond, mutex);
- else
- uv_cond_fallback_wait(cond, mutex);
-}
-
-
-static int uv_cond_fallback_timedwait(uv_cond_t* cond,
- uv_mutex_t* mutex, uint64_t timeout) {
- return uv_cond_wait_helper(cond, mutex, (DWORD)(timeout / 1e6));
+ if (!SleepConditionVariableCS(&cond->cond_var, mutex, INFINITE))
+ abort();
}
-
-static int uv_cond_condvar_timedwait(uv_cond_t* cond,
- uv_mutex_t* mutex, uint64_t timeout) {
- if (pSleepConditionVariableCS(&cond->cond_var, mutex, (DWORD)(timeout / 1e6)))
+int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
+ if (SleepConditionVariableCS(&cond->cond_var, mutex, (DWORD)(timeout / 1e6)))
return 0;
if (GetLastError() != ERROR_TIMEOUT)
abort();
@@ -592,15 +424,6 @@ static int uv_cond_condvar_timedwait(uv_cond_t* cond,
}
-int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex,
- uint64_t timeout) {
- if (HAVE_CONDVAR_API())
- return uv_cond_condvar_timedwait(cond, mutex, timeout);
- else
- return uv_cond_fallback_timedwait(cond, mutex, timeout);
-}
-
-
int uv_barrier_init(uv_barrier_t* barrier, unsigned int count) {
int err;
diff --git a/Utilities/cmlibuv/src/win/timer.c b/Utilities/cmlibuv/src/win/timer.c
deleted file mode 100644
index 27ca7716a..000000000
--- a/Utilities/cmlibuv/src/win/timer.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#include <assert.h>
-#include <limits.h>
-
-#include "uv.h"
-#include "internal.h"
-#include "tree.h"
-#include "handle-inl.h"
-
-
-/* The number of milliseconds in one second. */
-#define UV__MILLISEC 1000
-
-
-void uv_update_time(uv_loop_t* loop) {
- uint64_t new_time = uv__hrtime(UV__MILLISEC);
- assert(new_time >= loop->time);
- loop->time = new_time;
-}
-
-
-static int uv_timer_compare(uv_timer_t* a, uv_timer_t* b) {
- if (a->due < b->due)
- return -1;
- if (a->due > b->due)
- return 1;
- /*
- * compare start_id when both has the same due. start_id is
- * allocated with loop->timer_counter in uv_timer_start().
- */
- if (a->start_id < b->start_id)
- return -1;
- if (a->start_id > b->start_id)
- return 1;
- return 0;
-}
-
-
-RB_GENERATE_STATIC(uv_timer_tree_s, uv_timer_s, tree_entry, uv_timer_compare);
-
-
-int uv_timer_init(uv_loop_t* loop, uv_timer_t* handle) {
- uv__handle_init(loop, (uv_handle_t*) handle, UV_TIMER);
- handle->timer_cb = NULL;
- handle->repeat = 0;
-
- return 0;
-}
-
-
-void uv_timer_endgame(uv_loop_t* loop, uv_timer_t* handle) {
- if (handle->flags & UV__HANDLE_CLOSING) {
- assert(!(handle->flags & UV_HANDLE_CLOSED));
- uv__handle_close(handle);
- }
-}
-
-
-static uint64_t get_clamped_due_time(uint64_t loop_time, uint64_t timeout) {
- uint64_t clamped_timeout;
-
- clamped_timeout = loop_time + timeout;
- if (clamped_timeout < timeout)
- clamped_timeout = (uint64_t) -1;
-
- return clamped_timeout;
-}
-
-
-int uv_timer_start(uv_timer_t* handle, uv_timer_cb timer_cb, uint64_t timeout,
- uint64_t repeat) {
- uv_loop_t* loop = handle->loop;
- uv_timer_t* old;
-
- if (timer_cb == NULL)
- return UV_EINVAL;
-
- if (uv__is_active(handle))
- uv_timer_stop(handle);
-
- handle->timer_cb = timer_cb;
- handle->due = get_clamped_due_time(loop->time, timeout);
- handle->repeat = repeat;
- uv__handle_start(handle);
-
- /* start_id is the second index to be compared in uv__timer_cmp() */
- handle->start_id = handle->loop->timer_counter++;
-
- old = RB_INSERT(uv_timer_tree_s, &loop->timers, handle);
- assert(old == NULL);
-
- return 0;
-}
-
-
-int uv_timer_stop(uv_timer_t* handle) {
- uv_loop_t* loop = handle->loop;
-
- if (!uv__is_active(handle))
- return 0;
-
- RB_REMOVE(uv_timer_tree_s, &loop->timers, handle);
- uv__handle_stop(handle);
-
- return 0;
-}
-
-
-int uv_timer_again(uv_timer_t* handle) {
- /* If timer_cb is NULL that means that the timer was never started. */
- if (!handle->timer_cb) {
- return UV_EINVAL;
- }
-
- if (handle->repeat) {
- uv_timer_stop(handle);
- uv_timer_start(handle, handle->timer_cb, handle->repeat, handle->repeat);
- }
-
- return 0;
-}
-
-
-void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat) {
- assert(handle->type == UV_TIMER);
- handle->repeat = repeat;
-}
-
-
-uint64_t uv_timer_get_repeat(const uv_timer_t* handle) {
- assert(handle->type == UV_TIMER);
- return handle->repeat;
-}
-
-
-DWORD uv__next_timeout(const uv_loop_t* loop) {
- uv_timer_t* timer;
- int64_t delta;
-
- /* Check if there are any running timers
- * Need to cast away const first, since RB_MIN doesn't know what we are
- * going to do with this return value, it can't be marked const
- */
- timer = RB_MIN(uv_timer_tree_s, &((uv_loop_t*)loop)->timers);
- if (timer) {
- delta = timer->due - loop->time;
- if (delta >= UINT_MAX - 1) {
- /* A timeout value of UINT_MAX means infinite, so that's no good. */
- return UINT_MAX - 1;
- } else if (delta < 0) {
- /* Negative timeout values are not allowed */
- return 0;
- } else {
- return (DWORD)delta;
- }
- } else {
- /* No timers */
- return INFINITE;
- }
-}
-
-
-void uv_process_timers(uv_loop_t* loop) {
- uv_timer_t* timer;
-
- /* Call timer callbacks */
- for (timer = RB_MIN(uv_timer_tree_s, &loop->timers);
- timer != NULL && timer->due <= loop->time;
- timer = RB_MIN(uv_timer_tree_s, &loop->timers)) {
-
- uv_timer_stop(timer);
- uv_timer_again(timer);
- timer->timer_cb((uv_timer_t*) timer);
- }
-}
diff --git a/Utilities/cmlibuv/src/win/tty.c b/Utilities/cmlibuv/src/win/tty.c
index a6f583956..a98fe2633 100644
--- a/Utilities/cmlibuv/src/win/tty.c
+++ b/Utilities/cmlibuv/src/win/tty.c
@@ -25,7 +25,7 @@
#include <stdlib.h>
#if defined(_MSC_VER) && _MSC_VER < 1600
-# include "stdint-msvc2008.h"
+# include "uv/stdint-msvc2008.h"
#else
# include <stdint.h>
#endif
@@ -112,14 +112,30 @@ static int uv_tty_virtual_offset = -1;
static int uv_tty_virtual_height = -1;
static int uv_tty_virtual_width = -1;
+/* The console window size
+ * We keep this separate from uv_tty_virtual_*. We use those values to only
+ * handle signalling SIGWINCH
+ */
+
+static HANDLE uv__tty_console_handle = INVALID_HANDLE_VALUE;
+static int uv__tty_console_height = -1;
+static int uv__tty_console_width = -1;
+
+static DWORD WINAPI uv__tty_console_resize_message_loop_thread(void* param);
+static void CALLBACK uv__tty_console_resize_event(HWINEVENTHOOK hWinEventHook,
+ DWORD event,
+ HWND hwnd,
+ LONG idObject,
+ LONG idChild,
+ DWORD dwEventThread,
+ DWORD dwmsEventTime);
+
/* We use a semaphore rather than a mutex or critical section because in some
cases (uv__cancel_read_console) we need take the lock in the main thread and
release it in another thread. Using a semaphore ensures that in such
scenario the main thread will still block when trying to acquire the lock. */
static uv_sem_t uv_tty_output_lock;
-static HANDLE uv_tty_output_handle = INVALID_HANDLE_VALUE;
-
static WORD uv_tty_default_text_attributes =
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
@@ -141,13 +157,29 @@ static void uv__determine_vterm_state(HANDLE handle);
void uv_console_init(void) {
if (uv_sem_init(&uv_tty_output_lock, 1))
abort();
+ uv__tty_console_handle = CreateFileW(L"CONOUT$",
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_WRITE,
+ 0,
+ OPEN_EXISTING,
+ 0,
+ 0);
+ if (uv__tty_console_handle != INVALID_HANDLE_VALUE) {
+ QueueUserWorkItem(uv__tty_console_resize_message_loop_thread,
+ NULL,
+ WT_EXECUTELONGFUNCTION);
+ }
}
-int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) {
+int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int unused) {
+ BOOL readable;
+ DWORD NumberOfEvents;
HANDLE handle;
CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
+ (void)unused;
+ uv__once_init();
handle = (HANDLE) uv__get_osfhandle(fd);
if (handle == INVALID_HANDLE_VALUE)
return UV_EBADF;
@@ -170,24 +202,20 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) {
fd = -1;
}
+ readable = GetNumberOfConsoleInputEvents(handle, &NumberOfEvents);
if (!readable) {
/* Obtain the screen buffer info with the output handle. */
if (!GetConsoleScreenBufferInfo(handle, &screen_buffer_info)) {
return uv_translate_sys_error(GetLastError());
}
- /* Obtain the the tty_output_lock because the virtual window state is */
- /* shared between all uv_tty_t handles. */
+ /* Obtain the tty_output_lock because the virtual window state is shared
+ * between all uv_tty_t handles. */
uv_sem_wait(&uv_tty_output_lock);
if (uv__vterm_state == UV_UNCHECKED)
uv__determine_vterm_state(handle);
- /* Store the global tty output handle. This handle is used by TTY read */
- /* streams to update the virtual window when a CONSOLE_BUFFER_SIZE_EVENT */
- /* is received. */
- uv_tty_output_handle = handle;
-
/* Remember the original console text attributes. */
uv_tty_capture_initial_style(&screen_buffer_info);
@@ -332,6 +360,8 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) {
}
} else {
was_reading = 0;
+ alloc_cb = NULL;
+ read_cb = NULL;
}
uv_sem_wait(&uv_tty_output_lock);
@@ -358,12 +388,6 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) {
}
-int uv_is_tty(uv_file file) {
- DWORD result;
- return GetConsoleMode((HANDLE) _get_osfhandle(file), &result) != 0;
-}
-
-
int uv_tty_get_winsize(uv_tty_t* tty, int* width, int* height) {
CONSOLE_SCREEN_BUFFER_INFO info;
@@ -460,8 +484,8 @@ static DWORD CALLBACK uv_tty_line_read_thread(void* data) {
bytes = MAX_INPUT_BUFFER_LENGTH;
}
- /* At last, unicode! */
- /* One utf-16 codeunit never takes more than 3 utf-8 codeunits to encode */
+ /* At last, unicode! One utf-16 codeunit never takes more than 3 utf-8
+ * codeunits to encode. */
chars = bytes / 3;
status = InterlockedExchange(&uv__read_console_status, IN_PROGRESS);
@@ -596,10 +620,10 @@ static const char* get_vt100_fn_key(DWORD code, char shift, char ctrl,
}
switch (code) {
- /* These mappings are the same as Cygwin's. Unmodified and alt-modified */
- /* keypad keys comply with linux console, modifiers comply with xterm */
- /* modifier usage. F1..f12 and shift-f1..f10 comply with linux console, */
- /* f6..f12 with and without modifiers comply with rxvt. */
+ /* These mappings are the same as Cygwin's. Unmodified and alt-modified
+ * keypad keys comply with linux console, modifiers comply with xterm
+ * modifier usage. F1. f12 and shift-f1. f10 comply with linux console, f6.
+ * f12 with and without modifiers comply with rxvt. */
VK_CASE(VK_INSERT, "[2~", "[2;2~", "[2;5~", "[2;6~")
VK_CASE(VK_END, "[4~", "[4;2~", "[4;5~", "[4;6~")
VK_CASE(VK_DOWN, "[B", "[1;2B", "[1;5B", "[1;6B")
@@ -682,8 +706,8 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
goto out;
}
- /* Windows sends a lot of events that we're not interested in, so buf */
- /* will be allocated on demand, when there's actually something to emit. */
+ /* Windows sends a lot of events that we're not interested in, so buf will be
+ * allocated on demand, when there's actually something to emit. */
buf = uv_null_buf_;
buf_used = 0;
@@ -704,39 +728,22 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
}
records_left--;
- /* If the window was resized, recompute the virtual window size. This */
- /* will trigger a SIGWINCH signal if the window size changed in an */
- /* way that matters to libuv. */
- if (handle->tty.rd.last_input_record.EventType == WINDOW_BUFFER_SIZE_EVENT) {
- CONSOLE_SCREEN_BUFFER_INFO info;
-
- uv_sem_wait(&uv_tty_output_lock);
-
- if (uv_tty_output_handle != INVALID_HANDLE_VALUE &&
- GetConsoleScreenBufferInfo(uv_tty_output_handle, &info)) {
- uv_tty_update_virtual_window(&info);
- }
-
- uv_sem_post(&uv_tty_output_lock);
-
- continue;
- }
-
- /* Ignore other events that are not key or resize events. */
+ /* Ignore other events that are not key events. */
if (handle->tty.rd.last_input_record.EventType != KEY_EVENT) {
continue;
}
- /* Ignore keyup events, unless the left alt key was held and a valid */
- /* unicode character was emitted. */
- if (!KEV.bKeyDown && !(((KEV.dwControlKeyState & LEFT_ALT_PRESSED) ||
- KEV.wVirtualKeyCode==VK_MENU) && KEV.uChar.UnicodeChar != 0)) {
+ /* Ignore keyup events, unless the left alt key was held and a valid
+ * unicode character was emitted. */
+ if (!KEV.bKeyDown &&
+ (KEV.wVirtualKeyCode != VK_MENU ||
+ KEV.uChar.UnicodeChar == 0)) {
continue;
}
- /* Ignore keypresses to numpad number keys if the left alt is held */
- /* because the user is composing a character, or windows simulating */
- /* this. */
+ /* Ignore keypresses to numpad number keys if the left alt is held
+ * because the user is composing a character, or windows simulating this.
+ */
if ((KEV.dwControlKeyState & LEFT_ALT_PRESSED) &&
!(KEV.dwControlKeyState & ENHANCED_KEY) &&
(KEV.wVirtualKeyCode == VK_INSERT ||
@@ -773,8 +780,8 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
continue;
}
- /* Prefix with \u033 if alt was held, but alt was not used as part */
- /* a compose sequence. */
+ /* Prefix with \u033 if alt was held, but alt was not used as part a
+ * compose sequence. */
if ((KEV.dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED))
&& !(KEV.dwControlKeyState & (LEFT_CTRL_PRESSED |
RIGHT_CTRL_PRESSED)) && KEV.bKeyDown) {
@@ -787,8 +794,9 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
if (KEV.uChar.UnicodeChar >= 0xDC00 &&
KEV.uChar.UnicodeChar < 0xE000) {
/* UTF-16 surrogate pair */
- WCHAR utf16_buffer[2] = { handle->tty.rd.last_utf16_high_surrogate,
- KEV.uChar.UnicodeChar};
+ WCHAR utf16_buffer[2];
+ utf16_buffer[0] = handle->tty.rd.last_utf16_high_surrogate;
+ utf16_buffer[1] = KEV.uChar.UnicodeChar;
char_len = WideCharToMultiByte(CP_UTF8,
0,
utf16_buffer,
@@ -812,8 +820,8 @@ void uv_process_tty_read_raw_req(uv_loop_t* loop, uv_tty_t* handle,
/* Whatever happened, the last character wasn't a high surrogate. */
handle->tty.rd.last_utf16_high_surrogate = 0;
- /* If the utf16 character(s) couldn't be converted something must */
- /* be wrong. */
+ /* If the utf16 character(s) couldn't be converted something must be
+ * wrong. */
if (!char_len) {
handle->flags &= ~UV_HANDLE_READING;
DECREASE_ACTIVE_COUNT(loop, handle);
@@ -937,21 +945,15 @@ void uv_process_tty_read_line_req(uv_loop_t* loop, uv_tty_t* handle,
handle->read_cb((uv_stream_t*) handle,
uv_translate_sys_error(GET_REQ_ERROR(req)),
&buf);
- } else {
- /* The read was cancelled, or whatever we don't care */
- handle->read_cb((uv_stream_t*) handle, 0, &buf);
}
-
} else {
- if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING)) {
- /* Read successful */
- /* TODO: read unicode, convert to utf-8 */
+ if (!(handle->flags & UV_HANDLE_CANCELLATION_PENDING) &&
+ req->u.io.overlapped.InternalHigh != 0) {
+ /* Read successful. TODO: read unicode, convert to utf-8 */
DWORD bytes = req->u.io.overlapped.InternalHigh;
handle->read_cb((uv_stream_t*) handle, bytes, &buf);
- } else {
- handle->flags &= ~UV_HANDLE_CANCELLATION_PENDING;
- handle->read_cb((uv_stream_t*) handle, 0, &buf);
}
+ handle->flags &= ~UV_HANDLE_CANCELLATION_PENDING;
}
/* Wait for more input events. */
@@ -969,9 +971,9 @@ void uv_process_tty_read_req(uv_loop_t* loop, uv_tty_t* handle,
assert(handle->type == UV_TTY);
assert(handle->flags & UV_HANDLE_TTY_READABLE);
- /* If the read_line_buffer member is zero, it must have been an raw read. */
- /* Otherwise it was a line-buffered read. */
- /* FIXME: This is quite obscure. Use a flag or something. */
+ /* If the read_line_buffer member is zero, it must have been an raw read.
+ * Otherwise it was a line-buffered read. FIXME: This is quite obscure. Use a
+ * flag or something. */
if (handle->tty.rd.read_line_buffer.len == 0) {
uv_process_tty_read_raw_req(loop, handle, req);
} else {
@@ -993,14 +995,14 @@ int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb,
handle->read_cb = read_cb;
handle->alloc_cb = alloc_cb;
- /* If reading was stopped and then started again, there could still be a */
- /* read request pending. */
+ /* If reading was stopped and then started again, there could still be a read
+ * request pending. */
if (handle->flags & UV_HANDLE_READ_PENDING) {
return 0;
}
- /* Maybe the user stopped reading half-way while processing key events. */
- /* Short-circuit if this could be the case. */
+ /* Maybe the user stopped reading half-way while processing key events.
+ * Short-circuit if this could be the case. */
if (handle->tty.rd.last_key_len > 0) {
SET_REQ_SUCCESS(&handle->read_req);
uv_insert_pending_req(handle->loop, (uv_req_t*) &handle->read_req);
@@ -1027,9 +1029,10 @@ int uv_tty_read_stop(uv_tty_t* handle) {
return 0;
if (handle->flags & UV_HANDLE_TTY_RAW) {
- /* Cancel raw read */
- /* Write some bullshit event to force the console wait to return. */
+ /* Cancel raw read. Write some bullshit event to force the console wait to
+ * return. */
memset(&record, 0, sizeof record);
+ record.EventType = FOCUS_EVENT;
if (!WriteConsoleInputW(handle->handle, &record, 1, &written)) {
return GetLastError();
}
@@ -1102,9 +1105,6 @@ static int uv__cancel_read_console(uv_tty_t* handle) {
static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info) {
- int old_virtual_width = uv_tty_virtual_width;
- int old_virtual_height = uv_tty_virtual_height;
-
uv_tty_virtual_width = info->dwSize.X;
uv_tty_virtual_height = info->srWindow.Bottom - info->srWindow.Top + 1;
@@ -1113,8 +1113,8 @@ static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info) {
uv_tty_virtual_offset = info->dwCursorPosition.Y;
} else if (uv_tty_virtual_offset < info->dwCursorPosition.Y -
uv_tty_virtual_height + 1) {
- /* If suddenly find the cursor outside of the virtual window, it must */
- /* have somehow scrolled. Update the virtual window offset. */
+ /* If suddenly find the cursor outside of the virtual window, it must have
+ * somehow scrolled. Update the virtual window offset. */
uv_tty_virtual_offset = info->dwCursorPosition.Y -
uv_tty_virtual_height + 1;
}
@@ -1124,14 +1124,6 @@ static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info) {
if (uv_tty_virtual_offset < 0) {
uv_tty_virtual_offset = 0;
}
-
- /* If the virtual window size changed, emit a SIGWINCH signal. Don't emit */
- /* if this was the first time the virtual window size was computed. */
- if (old_virtual_width != -1 && old_virtual_height != -1 &&
- (uv_tty_virtual_width != old_virtual_width ||
- uv_tty_virtual_height != old_virtual_height)) {
- uv__signal_dispatch(SIGWINCH);
- }
}
@@ -1309,8 +1301,8 @@ static int uv_tty_clear(uv_tty_t* handle, int dir, char entire_screen,
x2 = 0;
x2r = 1;
} else {
- /* Clear to end of row. We pretend the console is 65536 characters wide, */
- /* uv_tty_make_real_coord will clip it to the actual console width. */
+ /* Clear to end of row. We pretend the console is 65536 characters wide,
+ * uv_tty_make_real_coord will clip it to the actual console width. */
x2 = 0xffff;
x2r = 0;
}
@@ -1618,8 +1610,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
const uv_buf_t bufs[],
unsigned int nbufs,
DWORD* error) {
- /* We can only write 8k characters at a time. Windows can't handle */
- /* much more characters in a single console write anyway. */
+ /* We can only write 8k characters at a time. Windows can't handle much more
+ * characters in a single console write anyway. */
WCHAR utf16_buf[MAX_CONSOLE_CHAR];
WCHAR* utf16_buffer;
DWORD utf16_buf_used = 0;
@@ -1655,9 +1647,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
unsigned char previous_eol = handle->tty.wr.previous_eol;
unsigned char ansi_parser_state = handle->tty.wr.ansi_parser_state;
- /* Store the error here. If we encounter an error, stop trying to do i/o */
- /* but keep parsing the buffer so we leave the parser in a consistent */
- /* state. */
+ /* Store the error here. If we encounter an error, stop trying to do i/o but
+ * keep parsing the buffer so we leave the parser in a consistent state. */
*error = ERROR_SUCCESS;
utf16_buffer = utf16_buf;
@@ -1705,9 +1696,9 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
for (j = 0; j < buf.len; j++) {
unsigned char c = buf.base[j];
- /* Run the character through the utf8 decoder We happily accept non */
- /* shortest form encodings and invalid code points - there's no real */
- /* harm that can be done. */
+ /* Run the character through the utf8 decoder We happily accept non
+ * shortest form encodings and invalid code points - there's no real harm
+ * that can be done. */
if (utf8_bytes_left == 0) {
/* Read utf-8 start byte */
DWORD first_zero_bit;
@@ -1747,8 +1738,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
/* Start byte where continuation was expected. */
utf8_bytes_left = 0;
utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER;
- /* Patch buf offset so this character will be parsed again as a */
- /* start byte. */
+ /* Patch buf offset so this character will be parsed again as a start
+ * byte. */
j--;
}
@@ -1781,8 +1772,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
case '_':
case 'P':
case ']':
- /* Not supported, but we'll have to parse until we see a stop */
- /* code, e.g. ESC \ or BEL. */
+ /* Not supported, but we'll have to parse until we see a stop code,
+ * e. g. ESC \ or BEL. */
ansi_parser_state = ANSI_ST_CONTROL;
continue;
@@ -1864,8 +1855,9 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
continue;
} else {
- /* If ANSI_IN_ARG is not set, add another argument and */
- /* default it to 0. */
+ /* If ANSI_IN_ARG is not set, add another argument and default it
+ * to 0. */
+
/* Check for too many arguments */
if (handle->tty.wr.ansi_csi_argc >= ARRAY_SIZE(handle->tty.wr.ansi_csi_argv)) {
ansi_parser_state |= ANSI_IGNORE;
@@ -1879,9 +1871,9 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
} else if (utf8_codepoint == '?' && !(ansi_parser_state & ANSI_IN_ARG) &&
handle->tty.wr.ansi_csi_argc == 0) {
- /* Ignores '?' if it is the first character after CSI[ */
- /* This is an extension character from the VT100 codeset */
- /* that is supported and used by most ANSI terminals today. */
+ /* Ignores '?' if it is the first character after CSI[. This is an
+ * extension character from the VT100 codeset that is supported and
+ * used by most ANSI terminals today. */
continue;
} else if (utf8_codepoint >= '@' && utf8_codepoint <= '~' &&
@@ -2011,8 +2003,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
continue;
} else {
- /* We don't support commands that use private mode characters or */
- /* intermediaries. Ignore the rest of the sequence. */
+ /* We don't support commands that use private mode characters or
+ * intermediaries. Ignore the rest of the sequence. */
ansi_parser_state |= ANSI_IGNORE;
continue;
}
@@ -2025,8 +2017,8 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
}
} else if (ansi_parser_state & ANSI_ST_CONTROL) {
- /* Unsupported control code */
- /* Ignore everything until we see BEL or ESC \ */
+ /* Unsupported control code.
+ * Ignore everything until we see `BEL` or `ESC \`. */
if (ansi_parser_state & ANSI_IN_STRING) {
if (!(ansi_parser_state & ANSI_BACKSLASH_SEEN)) {
if (utf8_codepoint == '"') {
@@ -2060,9 +2052,9 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
abort();
}
- /* We wouldn't mind emitting utf-16 surrogate pairs. Too bad, the */
- /* windows console doesn't really support UTF-16, so just emit the */
- /* replacement character. */
+ /* We wouldn't mind emitting utf-16 surrogate pairs. Too bad, the windows
+ * console doesn't really support UTF-16, so just emit the replacement
+ * character. */
if (utf8_codepoint > 0xffff) {
utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER;
}
@@ -2076,10 +2068,10 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
utf16_buf[utf16_buf_used++] = L'\r';
utf16_buf[utf16_buf_used++] = L'\n';
} else if (utf8_codepoint == 0x0d && previous_eol == 0x0a) {
- /* \n was followed by \r; do not print the \r, since */
- /* the source was either \r\n\r (so the second \r is */
- /* redundant) or was \n\r (so the \n was processed */
- /* by the last case and an \r automatically inserted). */
+ /* \n was followed by \r; do not print the \r, since the source was
+ * either \r\n\r (so the second \r is redundant) or was \n\r (so the
+ * \n was processed by the last case and an \r automatically
+ * inserted). */
} else {
/* \r without \n; print \r as-is. */
ENSURE_BUFFER_SPACE(1);
@@ -2187,14 +2179,14 @@ void uv_process_tty_write_req(uv_loop_t* loop, uv_tty_t* handle,
void uv_tty_close(uv_tty_t* handle) {
assert(handle->u.fd == -1 || handle->u.fd > 2);
+ if (handle->flags & UV_HANDLE_READING)
+ uv_tty_read_stop(handle);
+
if (handle->u.fd == -1)
CloseHandle(handle->handle);
else
close(handle->u.fd);
- if (handle->flags & UV_HANDLE_READING)
- uv_tty_read_stop(handle);
-
handle->u.fd = -1;
handle->handle = INVALID_HANDLE_VALUE;
handle->flags &= ~(UV_HANDLE_READABLE | UV_HANDLE_WRITABLE);
@@ -2214,7 +2206,7 @@ void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle) {
/* TTY shutdown is really just a no-op */
if (handle->stream.conn.shutdown_req->cb) {
- if (handle->flags & UV__HANDLE_CLOSING) {
+ if (handle->flags & UV_HANDLE_CLOSING) {
handle->stream.conn.shutdown_req->cb(handle->stream.conn.shutdown_req, UV_ECANCELED);
} else {
handle->stream.conn.shutdown_req->cb(handle->stream.conn.shutdown_req, 0);
@@ -2227,10 +2219,10 @@ void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle) {
return;
}
- if (handle->flags & UV__HANDLE_CLOSING &&
+ if (handle->flags & UV_HANDLE_CLOSING &&
handle->reqs_pending == 0) {
- /* The wait handle used for raw reading should be unregistered when the */
- /* wait callback runs. */
+ /* The wait handle used for raw reading should be unregistered when the
+ * wait callback runs. */
assert(!(handle->flags & UV_HANDLE_TTY_READABLE) ||
handle->tty.rd.read_raw_wait == NULL);
@@ -2240,14 +2232,20 @@ void uv_tty_endgame(uv_loop_t* loop, uv_tty_t* handle) {
}
-/* TODO: remove me */
+/*
+ * uv_process_tty_accept_req() is a stub to keep DELEGATE_STREAM_REQ working
+ * TODO: find a way to remove it
+ */
void uv_process_tty_accept_req(uv_loop_t* loop, uv_tty_t* handle,
uv_req_t* raw_req) {
abort();
}
-/* TODO: remove me */
+/*
+ * uv_process_tty_connect_req() is a stub to keep DELEGATE_STREAM_REQ working
+ * TODO: find a way to remove it
+ */
void uv_process_tty_connect_req(uv_loop_t* loop, uv_tty_t* handle,
uv_connect_t* req) {
abort();
@@ -2279,3 +2277,55 @@ static void uv__determine_vterm_state(HANDLE handle) {
uv__vterm_state = UV_SUPPORTED;
}
+
+static DWORD WINAPI uv__tty_console_resize_message_loop_thread(void* param) {
+ CONSOLE_SCREEN_BUFFER_INFO sb_info;
+ MSG msg;
+
+ if (!GetConsoleScreenBufferInfo(uv__tty_console_handle, &sb_info))
+ return 0;
+
+ uv__tty_console_width = sb_info.dwSize.X;
+ uv__tty_console_height = sb_info.srWindow.Bottom - sb_info.srWindow.Top + 1;
+
+ if (pSetWinEventHook == NULL)
+ return 0;
+
+ if (!pSetWinEventHook(EVENT_CONSOLE_LAYOUT,
+ EVENT_CONSOLE_LAYOUT,
+ NULL,
+ uv__tty_console_resize_event,
+ 0,
+ 0,
+ WINEVENT_OUTOFCONTEXT))
+ return 0;
+
+ while (GetMessage(&msg, NULL, 0, 0)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ return 0;
+}
+
+static void CALLBACK uv__tty_console_resize_event(HWINEVENTHOOK hWinEventHook,
+ DWORD event,
+ HWND hwnd,
+ LONG idObject,
+ LONG idChild,
+ DWORD dwEventThread,
+ DWORD dwmsEventTime) {
+ CONSOLE_SCREEN_BUFFER_INFO sb_info;
+ int width, height;
+
+ if (!GetConsoleScreenBufferInfo(uv__tty_console_handle, &sb_info))
+ return;
+
+ width = sb_info.dwSize.X;
+ height = sb_info.srWindow.Bottom - sb_info.srWindow.Top + 1;
+
+ if (width != uv__tty_console_width || height != uv__tty_console_height) {
+ uv__tty_console_width = width;
+ uv__tty_console_height = height;
+ uv__signal_dispatch(SIGWINCH);
+ }
+}
diff --git a/Utilities/cmlibuv/src/win/udp.c b/Utilities/cmlibuv/src/win/udp.c
index 2fd15cfa9..8aeeab3b4 100644
--- a/Utilities/cmlibuv/src/win/udp.c
+++ b/Utilities/cmlibuv/src/win/udp.c
@@ -36,22 +36,27 @@ const unsigned int uv_active_udp_streams_threshold = 0;
/* A zero-size buffer for use by uv_udp_read */
static char uv_zero_[] = "";
-
-int uv_udp_getsockname(const uv_udp_t* handle,
+int uv_udp_getpeername(const uv_udp_t* handle,
struct sockaddr* name,
int* namelen) {
- int result;
- if (handle->socket == INVALID_SOCKET) {
- return UV_EINVAL;
- }
+ return uv__getsockpeername((const uv_handle_t*) handle,
+ getpeername,
+ name,
+ namelen,
+ 0);
+}
- result = getsockname(handle->socket, name, namelen);
- if (result != 0) {
- return uv_translate_sys_error(WSAGetLastError());
- }
- return 0;
+int uv_udp_getsockname(const uv_udp_t* handle,
+ struct sockaddr* name,
+ int* namelen) {
+
+ return uv__getsockpeername((const uv_handle_t*) handle,
+ getsockname,
+ name,
+ namelen,
+ 0);
}
@@ -74,8 +79,8 @@ static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle, SOCKET socket,
return GetLastError();
}
- /* Associate it with the I/O completion port. */
- /* Use uv_handle_t pointer as completion key. */
+ /* Associate it with the I/O completion port. Use uv_handle_t pointer as
+ * completion key. */
if (CreateIoCompletionPort((HANDLE)socket,
loop->iocp,
(ULONG_PTR)socket,
@@ -83,31 +88,28 @@ static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle, SOCKET socket,
return GetLastError();
}
- if (pSetFileCompletionNotificationModes) {
- /* All known Windows that support SetFileCompletionNotificationModes */
- /* have a bug that makes it impossible to use this function in */
- /* conjunction with datagram sockets. We can work around that but only */
- /* if the user is using the default UDP driver (AFD) and has no other */
- /* LSPs stacked on top. Here we check whether that is the case. */
- opt_len = (int) sizeof info;
- if (getsockopt(socket,
- SOL_SOCKET,
- SO_PROTOCOL_INFOW,
- (char*) &info,
- &opt_len) == SOCKET_ERROR) {
- return GetLastError();
- }
+ /* All known Windows that support SetFileCompletionNotificationModes have a
+ * bug that makes it impossible to use this function in conjunction with
+ * datagram sockets. We can work around that but only if the user is using
+ * the default UDP driver (AFD) and has no other. LSPs stacked on top. Here
+ * we check whether that is the case. */
+ opt_len = (int) sizeof info;
+ if (getsockopt(
+ socket, SOL_SOCKET, SO_PROTOCOL_INFOW, (char*) &info, &opt_len) ==
+ SOCKET_ERROR) {
+ return GetLastError();
+ }
- if (info.ProtocolChain.ChainLen == 1) {
- if (pSetFileCompletionNotificationModes((HANDLE)socket,
- FILE_SKIP_SET_EVENT_ON_HANDLE |
- FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) {
- handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP;
- handle->func_wsarecv = uv_wsarecv_workaround;
- handle->func_wsarecvfrom = uv_wsarecvfrom_workaround;
- } else if (GetLastError() != ERROR_INVALID_FUNCTION) {
- return GetLastError();
- }
+ if (info.ProtocolChain.ChainLen == 1) {
+ if (SetFileCompletionNotificationModes(
+ (HANDLE) socket,
+ FILE_SKIP_SET_EVENT_ON_HANDLE |
+ FILE_SKIP_COMPLETION_PORT_ON_SUCCESS)) {
+ handle->flags |= UV_HANDLE_SYNC_BYPASS_IOCP;
+ handle->func_wsarecv = uv_wsarecv_workaround;
+ handle->func_wsarecvfrom = uv_wsarecvfrom_workaround;
+ } else if (GetLastError() != ERROR_INVALID_FUNCTION) {
+ return GetLastError();
}
}
@@ -191,7 +193,7 @@ void uv_udp_close(uv_loop_t* loop, uv_udp_t* handle) {
void uv_udp_endgame(uv_loop_t* loop, uv_udp_t* handle) {
- if (handle->flags & UV__HANDLE_CLOSING &&
+ if (handle->flags & UV_HANDLE_CLOSING &&
handle->reqs_pending == 0) {
assert(!(handle->flags & UV_HANDLE_CLOSED));
uv__handle_close(handle);
@@ -245,12 +247,12 @@ static int uv_udp_maybe_bind(uv_udp_t* handle,
handle->flags |= UV_HANDLE_IPV6;
if (addr->sa_family == AF_INET6 && !(flags & UV_UDP_IPV6ONLY)) {
- /* On windows IPV6ONLY is on by default. */
- /* If the user doesn't specify it libuv turns it off. */
+ /* On windows IPV6ONLY is on by default. If the user doesn't specify it
+ * libuv turns it off. */
- /* TODO: how to handle errors? This may fail if there is no ipv4 stack */
- /* available, or when run on XP/2003 which have no support for dualstack */
- /* sockets. For now we're silently ignoring the error. */
+ /* TODO: how to handle errors? This may fail if there is no ipv4 stack
+ * available, or when run on XP/2003 which have no support for dualstack
+ * sockets. For now we're silently ignoring the error. */
setsockopt(handle->socket,
IPPROTO_IPV6,
IPV6_V6ONLY,
@@ -369,7 +371,7 @@ int uv__udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb,
int err;
if (handle->flags & UV_HANDLE_READING) {
- return WSAEALREADY;
+ return UV_EALREADY;
}
err = uv_udp_maybe_bind(handle,
@@ -377,7 +379,7 @@ int uv__udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb,
sizeof(uv_addr_ip4_any_),
0);
if (err)
- return err;
+ return uv_translate_sys_error(err);
handle->flags |= UV_HANDLE_READING;
INCREASE_ACTIVE_COUNT(loop, handle);
@@ -386,8 +388,8 @@ int uv__udp_recv_start(uv_udp_t* handle, uv_alloc_cb alloc_cb,
handle->recv_cb = recv_cb;
handle->alloc_cb = alloc_cb;
- /* If reading was stopped and then started again, there could still be a */
- /* recv request pending. */
+ /* If reading was stopped and then started again, there could still be a recv
+ * request pending. */
if (!(handle->flags & UV_HANDLE_READ_PENDING))
uv_udp_queue_recv(loop, handle);
@@ -467,19 +469,19 @@ void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle,
if (!REQ_SUCCESS(req)) {
DWORD err = GET_REQ_SOCK_ERROR(req);
if (err == WSAEMSGSIZE) {
- /* Not a real error, it just indicates that the received packet */
- /* was bigger than the receive buffer. */
+ /* Not a real error, it just indicates that the received packet was
+ * bigger than the receive buffer. */
} else if (err == WSAECONNRESET || err == WSAENETRESET) {
- /* A previous sendto operation failed; ignore this error. If */
- /* zero-reading we need to call WSARecv/WSARecvFrom _without_ the */
- /* MSG_PEEK flag to clear out the error queue. For nonzero reads, */
- /* immediately queue a new receive. */
+ /* A previous sendto operation failed; ignore this error. If zero-reading
+ * we need to call WSARecv/WSARecvFrom _without_ the. MSG_PEEK flag to
+ * clear out the error queue. For nonzero reads, immediately queue a new
+ * receive. */
if (!(handle->flags & UV_HANDLE_ZERO_READ)) {
goto done;
}
} else {
- /* A real error occurred. Report the error to the user only if we're */
- /* currently reading. */
+ /* A real error occurred. Report the error to the user only if we're
+ * currently reading. */
if (handle->flags & UV_HANDLE_READING) {
uv_udp_recv_stop(handle);
buf = (handle->flags & UV_HANDLE_ZERO_READ) ?
@@ -503,8 +505,8 @@ void uv_process_udp_recv_req(uv_loop_t* loop, uv_udp_t* handle,
struct sockaddr_storage from;
int from_len;
- /* Do a nonblocking receive */
- /* TODO: try to read multiple datagrams at once. FIONREAD maybe? */
+ /* Do a nonblocking receive.
+ * TODO: try to read multiple datagrams at once. FIONREAD maybe? */
buf = uv_buf_init(NULL, 0);
handle->alloc_cb((uv_handle_t*) handle, 65536, &buf);
if (buf.base == NULL || buf.len == 0) {
@@ -741,7 +743,7 @@ int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr)
return UV_EINVAL;
}
- if (!(handle->flags & UV_HANDLE_BOUND))
+ if (handle->socket == INVALID_SOCKET)
return UV_EBADF;
if (addr_st.ss_family == AF_INET) {
@@ -772,7 +774,7 @@ int uv_udp_set_multicast_interface(uv_udp_t* handle, const char* interface_addr)
int uv_udp_set_broadcast(uv_udp_t* handle, int value) {
BOOL optval = (BOOL) value;
- if (!(handle->flags & UV_HANDLE_BOUND))
+ if (handle->socket == INVALID_SOCKET)
return UV_EBADF;
if (setsockopt(handle->socket,
@@ -787,6 +789,18 @@ int uv_udp_set_broadcast(uv_udp_t* handle, int value) {
}
+int uv__udp_is_bound(uv_udp_t* handle) {
+ struct sockaddr_storage addr;
+ int addrlen;
+
+ addrlen = sizeof(addr);
+ if (uv_udp_getsockname(handle, (struct sockaddr*) &addr, &addrlen) != 0)
+ return 0;
+
+ return addrlen > 0;
+}
+
+
int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) {
WSAPROTOCOL_INFOW protocol_info;
int opt_len;
@@ -806,7 +820,16 @@ int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) {
handle,
sock,
protocol_info.iAddressFamily);
- return uv_translate_sys_error(err);
+ if (err)
+ return uv_translate_sys_error(err);
+
+ if (uv__udp_is_bound(handle))
+ handle->flags |= UV_HANDLE_BOUND;
+
+ if (uv__udp_is_connected(handle))
+ handle->flags |= UV_HANDLE_UDP_CONNECTED;
+
+ return 0;
}
@@ -818,7 +841,7 @@ int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) {
return UV_EINVAL; \
} \
\
- if (!(handle->flags & UV_HANDLE_BOUND)) \
+ if (handle->socket == INVALID_SOCKET) \
return UV_EBADF; \
\
if (!(handle->flags & UV_HANDLE_IPV6)) { \
@@ -883,6 +906,50 @@ int uv__udp_bind(uv_udp_t* handle,
}
+int uv__udp_connect(uv_udp_t* handle,
+ const struct sockaddr* addr,
+ unsigned int addrlen) {
+ const struct sockaddr* bind_addr;
+ int err;
+
+ if (!(handle->flags & UV_HANDLE_BOUND)) {
+ if (addrlen == sizeof(uv_addr_ip4_any_))
+ bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_;
+ else if (addrlen == sizeof(uv_addr_ip6_any_))
+ bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_;
+ else
+ return UV_EINVAL;
+
+ err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0);
+ if (err)
+ return uv_translate_sys_error(err);
+ }
+
+ err = connect(handle->socket, addr, addrlen);
+ if (err)
+ return uv_translate_sys_error(err);
+
+ handle->flags |= UV_HANDLE_UDP_CONNECTED;
+
+ return 0;
+}
+
+
+int uv__udp_disconnect(uv_udp_t* handle) {
+ int err;
+ struct sockaddr addr;
+
+ memset(&addr, 0, sizeof(addr));
+
+ err = connect(handle->socket, &addr, sizeof(addr));
+ if (err)
+ return uv_translate_sys_error(err);
+
+ handle->flags &= ~UV_HANDLE_UDP_CONNECTED;
+ return 0;
+}
+
+
/* This function is an egress point, i.e. it returns libuv errors rather than
* system errors.
*/
@@ -897,13 +964,13 @@ int uv__udp_send(uv_udp_send_t* req,
int err;
if (!(handle->flags & UV_HANDLE_BOUND)) {
- if (addrlen == sizeof(uv_addr_ip4_any_)) {
+ if (addrlen == sizeof(uv_addr_ip4_any_))
bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_;
- } else if (addrlen == sizeof(uv_addr_ip6_any_)) {
+ else if (addrlen == sizeof(uv_addr_ip6_any_))
bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_;
- } else {
- abort();
- }
+ else
+ return UV_EINVAL;
+
err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0);
if (err)
return uv_translate_sys_error(err);
@@ -922,5 +989,47 @@ int uv__udp_try_send(uv_udp_t* handle,
unsigned int nbufs,
const struct sockaddr* addr,
unsigned int addrlen) {
- return UV_ENOSYS;
+ DWORD bytes;
+ const struct sockaddr* bind_addr;
+ struct sockaddr_storage converted;
+ int err;
+
+ assert(nbufs > 0);
+
+ if (addr != NULL) {
+ err = uv__convert_to_localhost_if_unspecified(addr, &converted);
+ if (err)
+ return err;
+ }
+
+ /* Already sending a message.*/
+ if (handle->send_queue_count != 0)
+ return UV_EAGAIN;
+
+ if (!(handle->flags & UV_HANDLE_BOUND)) {
+ if (addrlen == sizeof(uv_addr_ip4_any_))
+ bind_addr = (const struct sockaddr*) &uv_addr_ip4_any_;
+ else if (addrlen == sizeof(uv_addr_ip6_any_))
+ bind_addr = (const struct sockaddr*) &uv_addr_ip6_any_;
+ else
+ return UV_EINVAL;
+ err = uv_udp_maybe_bind(handle, bind_addr, addrlen, 0);
+ if (err)
+ return uv_translate_sys_error(err);
+ }
+
+ err = WSASendTo(handle->socket,
+ (WSABUF*)bufs,
+ nbufs,
+ &bytes,
+ 0,
+ (const struct sockaddr*) &converted,
+ addrlen,
+ NULL,
+ NULL);
+
+ if (err)
+ return uv_translate_sys_error(WSAGetLastError());
+
+ return bytes;
}
diff --git a/Utilities/cmlibuv/src/win/util.c b/Utilities/cmlibuv/src/win/util.c
index d2e7f772c..7ca83213a 100644
--- a/Utilities/cmlibuv/src/win/util.c
+++ b/Utilities/cmlibuv/src/win/util.c
@@ -37,7 +37,7 @@
#include <tlhelp32.h>
#include <windows.h>
#include <userenv.h>
-
+#include <math.h>
/*
* Max title length; the only thing MSDN tells us about the maximum length
@@ -59,13 +59,6 @@
# define UNLEN 256
#endif
-/*
- Max hostname length. The Windows gethostname() documentation states that 256
- bytes will always be large enough to hold the null-terminated hostname.
-*/
-#ifndef MAXHOSTNAMELEN
-# define MAXHOSTNAMELEN 256
-#endif
/* Maximum environment variable size, including the terminating null */
#define MAX_ENV_VAR_LENGTH 32767
@@ -74,10 +67,6 @@
static char *process_title;
static CRITICAL_SECTION process_title_lock;
-/* Cached copy of the process id, written once. */
-static DWORD current_pid = 0;
-
-
/* Interval (in seconds) of the high-resolution clock. */
static double hrtime_interval_ = 0;
@@ -149,8 +138,8 @@ int uv_exepath(char* buffer, size_t* size_ptr) {
uv__free(utf16_buffer);
- /* utf8_len *does* include the terminating null at this point, but the */
- /* returned size shouldn't. */
+ /* utf8_len *does* include the terminating null at this point, but the
+ * returned size shouldn't. */
*size_ptr = utf8_len - 1;
return 0;
@@ -173,16 +162,16 @@ int uv_cwd(char* buffer, size_t* size) {
if (utf16_len == 0) {
return uv_translate_sys_error(GetLastError());
} else if (utf16_len > MAX_PATH) {
- /* This should be impossible; however the CRT has a code path to deal */
- /* with this scenario, so I added a check anyway. */
+ /* This should be impossible; however the CRT has a code path to deal with
+ * this scenario, so I added a check anyway. */
return UV_EIO;
}
/* utf16_len contains the length, *not* including the terminating null. */
utf16_buffer[utf16_len] = L'\0';
- /* The returned directory should not have a trailing slash, unless it */
- /* points at a drive root, like c:\. Remove it if needed.*/
+ /* The returned directory should not have a trailing slash, unless it points
+ * at a drive root, like c:\. Remove it if needed. */
if (utf16_buffer[utf16_len - 1] == L'\\' &&
!(utf16_len == 3 && utf16_buffer[1] == L':')) {
utf16_len--;
@@ -239,9 +228,9 @@ int uv_chdir(const char* dir) {
utf16_buffer,
MAX_PATH) == 0) {
DWORD error = GetLastError();
- /* The maximum length of the current working directory is 260 chars, */
- /* including terminating null. If it doesn't fit, the path name must be */
- /* too long. */
+ /* The maximum length of the current working directory is 260 chars,
+ * including terminating null. If it doesn't fit, the path name must be too
+ * long. */
if (error == ERROR_INSUFFICIENT_BUFFER) {
return UV_ENAMETOOLONG;
} else {
@@ -253,9 +242,9 @@ int uv_chdir(const char* dir) {
return uv_translate_sys_error(GetLastError());
}
- /* Windows stores the drive-local path in an "hidden" environment variable, */
- /* which has the form "=C:=C:\Windows". SetCurrentDirectory does not */
- /* update this, so we'll have to do it. */
+ /* Windows stores the drive-local path in an "hidden" environment variable,
+ * which has the form "=C:=C:\Windows". SetCurrentDirectory does not update
+ * this, so we'll have to do it. */
utf16_len = GetCurrentDirectoryW(MAX_PATH, utf16_buffer);
if (utf16_len == 0) {
return uv_translate_sys_error(GetLastError());
@@ -263,8 +252,8 @@ int uv_chdir(const char* dir) {
return UV_EIO;
}
- /* The returned directory should not have a trailing slash, unless it */
- /* points at a drive root, like c:\. Remove it if needed. */
+ /* The returned directory should not have a trailing slash, unless it points
+ * at a drive root, like c:\. Remove it if needed. */
if (utf16_buffer[utf16_len - 1] == L'\\' &&
!(utf16_len == 3 && utf16_buffer[1] == L':')) {
utf16_len--;
@@ -272,8 +261,8 @@ int uv_chdir(const char* dir) {
}
if (utf16_len < 2 || utf16_buffer[1] != L':') {
- /* Doesn't look like a drive letter could be there - probably an UNC */
- /* path. TODO: Need to handle win32 namespaces like \\?\C:\ ? */
+ /* Doesn't look like a drive letter could be there - probably an UNC path.
+ * TODO: Need to handle win32 namespaces like \\?\C:\ ? */
drive_letter = 0;
} else if (utf16_buffer[0] >= L'A' && utf16_buffer[0] <= L'Z') {
drive_letter = utf16_buffer[0];
@@ -331,7 +320,17 @@ uint64_t uv_get_total_memory(void) {
}
-int uv_parent_pid(void) {
+uint64_t uv_get_constrained_memory(void) {
+ return 0; /* Memory constraints are unknown. */
+}
+
+
+uv_pid_t uv_os_getpid(void) {
+ return GetCurrentProcessId();
+}
+
+
+uv_pid_t uv_os_getppid(void) {
int parent_pid = -1;
HANDLE handle;
PROCESSENTRY32 pe;
@@ -354,14 +353,6 @@ int uv_parent_pid(void) {
}
-int uv_current_pid(void) {
- if (current_pid == 0) {
- current_pid = GetCurrentProcessId();
- }
- return current_pid;
-}
-
-
char** uv_setup_args(int argc, char** argv) {
return argv;
}
@@ -582,8 +573,8 @@ int uv_uptime(double* uptime) {
BYTE* address = (BYTE*) object_type + object_type->DefinitionLength +
counter_definition->CounterOffset;
uint64_t value = *((uint64_t*) address);
- *uptime = (double) (object_type->PerfTime.QuadPart - value) /
- (double) object_type->PerfFreq.QuadPart;
+ *uptime = floor((double) (object_type->PerfTime.QuadPart - value) /
+ (double) object_type->PerfFreq.QuadPart);
uv__free(malloced_buffer);
return 0;
}
@@ -610,7 +601,7 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos_ptr, int* cpu_count_ptr) {
SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* sppi;
DWORD sppi_size;
SYSTEM_INFO system_info;
- DWORD cpu_count, r, i;
+ DWORD cpu_count, i;
NTSTATUS status;
ULONG result_size;
int err;
@@ -665,39 +656,35 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos_ptr, int* cpu_count_ptr) {
assert(len > 0 && len < ARRAY_SIZE(key_name));
- r = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
- key_name,
- 0,
- KEY_QUERY_VALUE,
- &processor_key);
- if (r != ERROR_SUCCESS) {
- err = GetLastError();
+ err = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ key_name,
+ 0,
+ KEY_QUERY_VALUE,
+ &processor_key);
+ if (err != ERROR_SUCCESS) {
goto error;
}
- if (RegQueryValueExW(processor_key,
- L"~MHz",
- NULL,
- NULL,
- (BYTE*) &cpu_speed,
- &cpu_speed_size) != ERROR_SUCCESS) {
- err = GetLastError();
- RegCloseKey(processor_key);
- goto error;
- }
-
- if (RegQueryValueExW(processor_key,
- L"ProcessorNameString",
- NULL,
- NULL,
- (BYTE*) &cpu_brand,
- &cpu_brand_size) != ERROR_SUCCESS) {
- err = GetLastError();
+ err = RegQueryValueExW(processor_key,
+ L"~MHz",
+ NULL,
+ NULL,
+ (BYTE*)&cpu_speed,
+ &cpu_speed_size);
+ if (err != ERROR_SUCCESS) {
RegCloseKey(processor_key);
goto error;
}
+ err = RegQueryValueExW(processor_key,
+ L"ProcessorNameString",
+ NULL,
+ NULL,
+ (BYTE*)&cpu_brand,
+ &cpu_brand_size);
RegCloseKey(processor_key);
+ if (err != ERROR_SUCCESS)
+ goto error;
cpu_info = &cpu_infos[i];
cpu_info->speed = cpu_speed;
@@ -721,9 +708,11 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos_ptr, int* cpu_count_ptr) {
return 0;
error:
- /* This is safe because the cpu_infos array is zeroed on allocation. */
- for (i = 0; i < cpu_count; i++)
- uv__free(cpu_infos[i].model);
+ if (cpu_infos != NULL) {
+ /* This is safe because the cpu_infos array is zeroed on allocation. */
+ for (i = 0; i < cpu_count; i++)
+ uv__free(cpu_infos[i].model);
+ }
uv__free(cpu_infos);
uv__free(sppi);
@@ -824,6 +813,9 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
int is_vista_or_greater;
ULONG flags;
+ *addresses_ptr = NULL;
+ *count_ptr = 0;
+
is_vista_or_greater = is_windows_version_or_greater(6, 0, 0, 0);
if (is_vista_or_greater) {
flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST |
@@ -838,17 +830,17 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
}
- /* Fetch the size of the adapters reported by windows, and then get the */
- /* list itself. */
+ /* Fetch the size of the adapters reported by windows, and then get the list
+ * itself. */
win_address_buf_size = 0;
win_address_buf = NULL;
for (;;) {
ULONG r;
- /* If win_address_buf is 0, then GetAdaptersAddresses will fail with */
- /* ERROR_BUFFER_OVERFLOW, and the required buffer size will be stored in */
- /* win_address_buf_size. */
+ /* If win_address_buf is 0, then GetAdaptersAddresses will fail with.
+ * ERROR_BUFFER_OVERFLOW, and the required buffer size will be stored in
+ * win_address_buf_size. */
r = GetAdaptersAddresses(AF_UNSPEC,
flags,
NULL,
@@ -862,8 +854,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
switch (r) {
case ERROR_BUFFER_OVERFLOW:
- /* This happens when win_address_buf is NULL or too small to hold */
- /* all adapters. */
+ /* This happens when win_address_buf is NULL or too small to hold all
+ * adapters. */
win_address_buf = uv__malloc(win_address_buf_size);
if (win_address_buf == NULL)
return UV_ENOMEM;
@@ -897,15 +889,15 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
return UV_ENOBUFS;
default:
- /* Other (unspecified) errors can happen, but we don't have any */
- /* special meaning for them. */
+ /* Other (unspecified) errors can happen, but we don't have any special
+ * meaning for them. */
assert(r != ERROR_SUCCESS);
return uv_translate_sys_error(r);
}
}
- /* Count the number of enabled interfaces and compute how much space is */
- /* needed to store their info. */
+ /* Count the number of enabled interfaces and compute how much space is
+ * needed to store their info. */
count = 0;
uv_address_buf_size = 0;
@@ -915,9 +907,9 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
IP_ADAPTER_UNICAST_ADDRESS* unicast_address;
int name_size;
- /* Interfaces that are not 'up' should not be reported. Also skip */
- /* interfaces that have no associated unicast address, as to avoid */
- /* allocating space for the name for this interface. */
+ /* Interfaces that are not 'up' should not be reported. Also skip
+ * interfaces that have no associated unicast address, as to avoid
+ * allocating space for the name for this interface. */
if (adapter->OperStatus != IfOperStatusUp ||
adapter->FirstUnicastAddress == NULL)
continue;
@@ -937,8 +929,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
}
uv_address_buf_size += name_size;
- /* Count the number of addresses associated with this interface, and */
- /* compute the size. */
+ /* Count the number of addresses associated with this interface, and
+ * compute the size. */
for (unicast_address = (IP_ADAPTER_UNICAST_ADDRESS*)
adapter->FirstUnicastAddress;
unicast_address != NULL;
@@ -955,8 +947,8 @@ int uv_interface_addresses(uv_interface_address_t** addresses_ptr,
return UV_ENOMEM;
}
- /* Compute the start of the uv_interface_address_t array, and the place in */
- /* the buffer where the interface names will be stored. */
+ /* Compute the start of the uv_interface_address_t array, and the place in
+ * the buffer where the interface names will be stored. */
uv_address = uv_address_buf;
name_buf = (char*) (uv_address_buf + count);
@@ -1143,53 +1135,17 @@ int uv_getrusage(uv_rusage_t *uv_rusage) {
int uv_os_homedir(char* buffer, size_t* size) {
uv_passwd_t pwd;
- wchar_t path[MAX_PATH];
- DWORD bufsize;
size_t len;
int r;
- if (buffer == NULL || size == NULL || *size == 0)
- return UV_EINVAL;
+ /* Check if the USERPROFILE environment variable is set first. The task of
+ performing input validation on buffer and size is taken care of by
+ uv_os_getenv(). */
+ r = uv_os_getenv("USERPROFILE", buffer, size);
- /* Check if the USERPROFILE environment variable is set first */
- len = GetEnvironmentVariableW(L"USERPROFILE", path, MAX_PATH);
-
- if (len == 0) {
- r = GetLastError();
-
- /* Don't return an error if USERPROFILE was not found */
- if (r != ERROR_ENVVAR_NOT_FOUND)
- return uv_translate_sys_error(r);
- } else if (len > MAX_PATH) {
- /* This should not be possible */
- return UV_EIO;
- } else {
- /* Check how much space we need */
- bufsize = WideCharToMultiByte(CP_UTF8, 0, path, -1, NULL, 0, NULL, NULL);
-
- if (bufsize == 0) {
- return uv_translate_sys_error(GetLastError());
- } else if (bufsize > *size) {
- *size = bufsize;
- return UV_ENOBUFS;
- }
-
- /* Convert to UTF-8 */
- bufsize = WideCharToMultiByte(CP_UTF8,
- 0,
- path,
- -1,
- buffer,
- *size,
- NULL,
- NULL);
-
- if (bufsize == 0)
- return uv_translate_sys_error(GetLastError());
-
- *size = bufsize - 1;
- return 0;
- }
+ /* Don't return an error if USERPROFILE was not found. */
+ if (r != UV_ENOENT)
+ return r;
/* USERPROFILE is not set, so call uv__getpwuid_r() */
r = uv__getpwuid_r(&pwd);
@@ -1231,8 +1187,8 @@ int uv_os_tmpdir(char* buffer, size_t* size) {
return UV_EIO;
}
- /* The returned directory should not have a trailing slash, unless it */
- /* points at a drive root, like c:\. Remove it if needed.*/
+ /* The returned directory should not have a trailing slash, unless it points
+ * at a drive root, like c:\. Remove it if needed. */
if (path[len - 1] == L'\\' &&
!(len == 3 && path[1] == L':')) {
len--;
@@ -1388,7 +1344,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) {
if (OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token) == 0)
return uv_translate_sys_error(GetLastError());
- bufsize = sizeof(path);
+ bufsize = ARRAY_SIZE(path);
if (!GetUserProfileDirectoryW(token, path, &bufsize)) {
r = GetLastError();
CloseHandle(token);
@@ -1403,7 +1359,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) {
CloseHandle(token);
/* Get the username using GetUserNameW() */
- bufsize = sizeof(username);
+ bufsize = ARRAY_SIZE(username);
if (!GetUserNameW(username, &bufsize)) {
r = GetLastError();
@@ -1551,7 +1507,7 @@ int uv_os_unsetenv(const char* name) {
int uv_os_gethostname(char* buffer, size_t* size) {
- char buf[MAXHOSTNAMELEN + 1];
+ char buf[UV_MAXHOSTNAMESIZE];
size_t len;
if (buffer == NULL || size == NULL || *size == 0)
@@ -1574,3 +1530,275 @@ int uv_os_gethostname(char* buffer, size_t* size) {
*size = len;
return 0;
}
+
+
+static int uv__get_handle(uv_pid_t pid, int access, HANDLE* handle) {
+ int r;
+
+ if (pid == 0)
+ *handle = GetCurrentProcess();
+ else
+ *handle = OpenProcess(access, FALSE, pid);
+
+ if (*handle == NULL) {
+ r = GetLastError();
+
+ if (r == ERROR_INVALID_PARAMETER)
+ return UV_ESRCH;
+ else
+ return uv_translate_sys_error(r);
+ }
+
+ return 0;
+}
+
+
+int uv_os_getpriority(uv_pid_t pid, int* priority) {
+ HANDLE handle;
+ int r;
+
+ if (priority == NULL)
+ return UV_EINVAL;
+
+ r = uv__get_handle(pid, PROCESS_QUERY_LIMITED_INFORMATION, &handle);
+
+ if (r != 0)
+ return r;
+
+ r = GetPriorityClass(handle);
+
+ if (r == 0) {
+ r = uv_translate_sys_error(GetLastError());
+ } else {
+ /* Map Windows priority classes to Unix nice values. */
+ if (r == REALTIME_PRIORITY_CLASS)
+ *priority = UV_PRIORITY_HIGHEST;
+ else if (r == HIGH_PRIORITY_CLASS)
+ *priority = UV_PRIORITY_HIGH;
+ else if (r == ABOVE_NORMAL_PRIORITY_CLASS)
+ *priority = UV_PRIORITY_ABOVE_NORMAL;
+ else if (r == NORMAL_PRIORITY_CLASS)
+ *priority = UV_PRIORITY_NORMAL;
+ else if (r == BELOW_NORMAL_PRIORITY_CLASS)
+ *priority = UV_PRIORITY_BELOW_NORMAL;
+ else /* IDLE_PRIORITY_CLASS */
+ *priority = UV_PRIORITY_LOW;
+
+ r = 0;
+ }
+
+ CloseHandle(handle);
+ return r;
+}
+
+
+int uv_os_setpriority(uv_pid_t pid, int priority) {
+ HANDLE handle;
+ int priority_class;
+ int r;
+
+ /* Map Unix nice values to Windows priority classes. */
+ if (priority < UV_PRIORITY_HIGHEST || priority > UV_PRIORITY_LOW)
+ return UV_EINVAL;
+ else if (priority < UV_PRIORITY_HIGH)
+ priority_class = REALTIME_PRIORITY_CLASS;
+ else if (priority < UV_PRIORITY_ABOVE_NORMAL)
+ priority_class = HIGH_PRIORITY_CLASS;
+ else if (priority < UV_PRIORITY_NORMAL)
+ priority_class = ABOVE_NORMAL_PRIORITY_CLASS;
+ else if (priority < UV_PRIORITY_BELOW_NORMAL)
+ priority_class = NORMAL_PRIORITY_CLASS;
+ else if (priority < UV_PRIORITY_LOW)
+ priority_class = BELOW_NORMAL_PRIORITY_CLASS;
+ else
+ priority_class = IDLE_PRIORITY_CLASS;
+
+ r = uv__get_handle(pid, PROCESS_SET_INFORMATION, &handle);
+
+ if (r != 0)
+ return r;
+
+ if (SetPriorityClass(handle, priority_class) == 0)
+ r = uv_translate_sys_error(GetLastError());
+
+ CloseHandle(handle);
+ return r;
+}
+
+
+int uv_os_uname(uv_utsname_t* buffer) {
+ /* Implementation loosely based on
+ https://github.com/gagern/gnulib/blob/master/lib/uname.c */
+ OSVERSIONINFOW os_info;
+ SYSTEM_INFO system_info;
+ HKEY registry_key;
+ WCHAR product_name_w[256];
+ DWORD product_name_w_size;
+ int version_size;
+ int processor_level;
+ int r;
+
+ if (buffer == NULL)
+ return UV_EINVAL;
+
+ uv__once_init();
+ os_info.dwOSVersionInfoSize = sizeof(os_info);
+ os_info.szCSDVersion[0] = L'\0';
+
+ /* Try calling RtlGetVersion(), and fall back to the deprecated GetVersionEx()
+ if RtlGetVersion() is not available. */
+ if (pRtlGetVersion) {
+ pRtlGetVersion(&os_info);
+ } else {
+ /* Silence GetVersionEx() deprecation warning. */
+ #pragma warning(suppress : 4996)
+ if (GetVersionExW(&os_info) == 0) {
+ r = uv_translate_sys_error(GetLastError());
+ goto error;
+ }
+ }
+
+ /* Populate the version field. */
+ version_size = 0;
+ r = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
+ 0,
+ KEY_QUERY_VALUE,
+ &registry_key);
+
+ if (r == ERROR_SUCCESS) {
+ product_name_w_size = sizeof(product_name_w);
+ r = RegGetValueW(registry_key,
+ NULL,
+ L"ProductName",
+ RRF_RT_REG_SZ,
+ NULL,
+ (PVOID) product_name_w,
+ &product_name_w_size);
+ RegCloseKey(registry_key);
+
+ if (r == ERROR_SUCCESS) {
+ version_size = WideCharToMultiByte(CP_UTF8,
+ 0,
+ product_name_w,
+ -1,
+ buffer->version,
+ sizeof(buffer->version),
+ NULL,
+ NULL);
+ if (version_size == 0) {
+ r = uv_translate_sys_error(GetLastError());
+ goto error;
+ }
+ }
+ }
+
+ /* Append service pack information to the version if present. */
+ if (os_info.szCSDVersion[0] != L'\0') {
+ if (version_size > 0)
+ buffer->version[version_size - 1] = ' ';
+
+ if (WideCharToMultiByte(CP_UTF8,
+ 0,
+ os_info.szCSDVersion,
+ -1,
+ buffer->version + version_size,
+ sizeof(buffer->version) - version_size,
+ NULL,
+ NULL) == 0) {
+ r = uv_translate_sys_error(GetLastError());
+ goto error;
+ }
+ }
+
+ /* Populate the sysname field. */
+#ifdef __MINGW32__
+ r = snprintf(buffer->sysname,
+ sizeof(buffer->sysname),
+ "MINGW32_NT-%u.%u",
+ (unsigned int) os_info.dwMajorVersion,
+ (unsigned int) os_info.dwMinorVersion);
+ assert(r < sizeof(buffer->sysname));
+#else
+ uv__strscpy(buffer->sysname, "Windows_NT", sizeof(buffer->sysname));
+#endif
+
+ /* Populate the release field. */
+ r = snprintf(buffer->release,
+ sizeof(buffer->release),
+ "%d.%d.%d",
+ (unsigned int) os_info.dwMajorVersion,
+ (unsigned int) os_info.dwMinorVersion,
+ (unsigned int) os_info.dwBuildNumber);
+ assert(r < sizeof(buffer->release));
+
+ /* Populate the machine field. */
+ GetSystemInfo(&system_info);
+
+ switch (system_info.wProcessorArchitecture) {
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ uv__strscpy(buffer->machine, "x86_64", sizeof(buffer->machine));
+ break;
+ case PROCESSOR_ARCHITECTURE_IA64:
+ uv__strscpy(buffer->machine, "ia64", sizeof(buffer->machine));
+ break;
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ uv__strscpy(buffer->machine, "i386", sizeof(buffer->machine));
+
+ if (system_info.wProcessorLevel > 3) {
+ processor_level = system_info.wProcessorLevel < 6 ?
+ system_info.wProcessorLevel : 6;
+ buffer->machine[1] = '0' + processor_level;
+ }
+
+ break;
+ case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
+ uv__strscpy(buffer->machine, "i686", sizeof(buffer->machine));
+ break;
+ case PROCESSOR_ARCHITECTURE_MIPS:
+ uv__strscpy(buffer->machine, "mips", sizeof(buffer->machine));
+ break;
+ case PROCESSOR_ARCHITECTURE_ALPHA:
+ case PROCESSOR_ARCHITECTURE_ALPHA64:
+ uv__strscpy(buffer->machine, "alpha", sizeof(buffer->machine));
+ break;
+ case PROCESSOR_ARCHITECTURE_PPC:
+ uv__strscpy(buffer->machine, "powerpc", sizeof(buffer->machine));
+ break;
+ case PROCESSOR_ARCHITECTURE_SHX:
+ uv__strscpy(buffer->machine, "sh", sizeof(buffer->machine));
+ break;
+ case PROCESSOR_ARCHITECTURE_ARM:
+ uv__strscpy(buffer->machine, "arm", sizeof(buffer->machine));
+ break;
+ default:
+ uv__strscpy(buffer->machine, "unknown", sizeof(buffer->machine));
+ break;
+ }
+
+ return 0;
+
+error:
+ buffer->sysname[0] = '\0';
+ buffer->release[0] = '\0';
+ buffer->version[0] = '\0';
+ buffer->machine[0] = '\0';
+ return r;
+}
+
+int uv_gettimeofday(uv_timeval64_t* tv) {
+ /* Based on https://doxygen.postgresql.org/gettimeofday_8c_source.html */
+ const uint64_t epoch = (uint64_t) 116444736000000000ULL;
+ FILETIME file_time;
+ ULARGE_INTEGER ularge;
+
+ if (tv == NULL)
+ return UV_EINVAL;
+
+ GetSystemTimeAsFileTime(&file_time);
+ ularge.LowPart = file_time.dwLowDateTime;
+ ularge.HighPart = file_time.dwHighDateTime;
+ tv->tv_sec = (int64_t) ((ularge.QuadPart - epoch) / 10000000L);
+ tv->tv_usec = (int32_t) (((ularge.QuadPart - epoch) % 10000000L) / 10);
+ return 0;
+}
diff --git a/Utilities/cmlibuv/src/win/winapi.c b/Utilities/cmlibuv/src/win/winapi.c
index aa5d719fb..fbbbceed9 100644
--- a/Utilities/cmlibuv/src/win/winapi.c
+++ b/Utilities/cmlibuv/src/win/winapi.c
@@ -26,6 +26,7 @@
/* Ntdll function pointers */
+sRtlGetVersion pRtlGetVersion;
sRtlNtStatusToDosError pRtlNtStatusToDosError;
sNtDeviceIoControlFile pNtDeviceIoControlFile;
sNtQueryInformationFile pNtQueryInformationFile;
@@ -34,35 +35,30 @@ sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile;
sNtQueryDirectoryFile pNtQueryDirectoryFile;
sNtQuerySystemInformation pNtQuerySystemInformation;
-
/* Kernel32 function pointers */
sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx;
-sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes;
-sCreateSymbolicLinkW pCreateSymbolicLinkW;
-sCancelIoEx pCancelIoEx;
-sInitializeConditionVariable pInitializeConditionVariable;
-sSleepConditionVariableCS pSleepConditionVariableCS;
-sSleepConditionVariableSRW pSleepConditionVariableSRW;
-sWakeAllConditionVariable pWakeAllConditionVariable;
-sWakeConditionVariable pWakeConditionVariable;
-sCancelSynchronousIo pCancelSynchronousIo;
-sGetFinalPathNameByHandleW pGetFinalPathNameByHandleW;
-
/* Powrprof.dll function pointer */
sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification;
+/* User32.dll function pointer */
+sSetWinEventHook pSetWinEventHook;
+
void uv_winapi_init(void) {
HMODULE ntdll_module;
- HMODULE kernel32_module;
HMODULE powrprof_module;
+ HMODULE user32_module;
+ HMODULE kernel32_module;
ntdll_module = GetModuleHandleA("ntdll.dll");
if (ntdll_module == NULL) {
uv_fatal_error(GetLastError(), "GetModuleHandleA");
}
+ pRtlGetVersion = (sRtlGetVersion) GetProcAddress(ntdll_module,
+ "RtlGetVersion");
+
pRtlNtStatusToDosError = (sRtlNtStatusToDosError) GetProcAddress(
ntdll_module,
"RtlNtStatusToDosError");
@@ -119,41 +115,16 @@ void uv_winapi_init(void) {
kernel32_module,
"GetQueuedCompletionStatusEx");
- pSetFileCompletionNotificationModes = (sSetFileCompletionNotificationModes)
- GetProcAddress(kernel32_module, "SetFileCompletionNotificationModes");
-
- pCreateSymbolicLinkW = (sCreateSymbolicLinkW)
- GetProcAddress(kernel32_module, "CreateSymbolicLinkW");
-
- pCancelIoEx = (sCancelIoEx)
- GetProcAddress(kernel32_module, "CancelIoEx");
-
- pInitializeConditionVariable = (sInitializeConditionVariable)
- GetProcAddress(kernel32_module, "InitializeConditionVariable");
-
- pSleepConditionVariableCS = (sSleepConditionVariableCS)
- GetProcAddress(kernel32_module, "SleepConditionVariableCS");
-
- pSleepConditionVariableSRW = (sSleepConditionVariableSRW)
- GetProcAddress(kernel32_module, "SleepConditionVariableSRW");
-
- pWakeAllConditionVariable = (sWakeAllConditionVariable)
- GetProcAddress(kernel32_module, "WakeAllConditionVariable");
-
- pWakeConditionVariable = (sWakeConditionVariable)
- GetProcAddress(kernel32_module, "WakeConditionVariable");
-
- pCancelSynchronousIo = (sCancelSynchronousIo)
- GetProcAddress(kernel32_module, "CancelSynchronousIo");
-
- pGetFinalPathNameByHandleW = (sGetFinalPathNameByHandleW)
- GetProcAddress(kernel32_module, "GetFinalPathNameByHandleW");
-
-
powrprof_module = LoadLibraryA("powrprof.dll");
if (powrprof_module != NULL) {
pPowerRegisterSuspendResumeNotification = (sPowerRegisterSuspendResumeNotification)
GetProcAddress(powrprof_module, "PowerRegisterSuspendResumeNotification");
}
+ user32_module = LoadLibraryA("user32.dll");
+ if (user32_module != NULL) {
+ pSetWinEventHook = (sSetWinEventHook)
+ GetProcAddress(user32_module, "SetWinEventHook");
+ }
+
}
diff --git a/Utilities/cmlibuv/src/win/winapi.h b/Utilities/cmlibuv/src/win/winapi.h
index 4b0eeca15..1e49b5787 100644
--- a/Utilities/cmlibuv/src/win/winapi.h
+++ b/Utilities/cmlibuv/src/win/winapi.h
@@ -4076,8 +4076,8 @@
# define STATUS_HASH_NOT_PRESENT ((NTSTATUS) 0xC000A101L)
#endif
-/* This is not the NTSTATUS_FROM_WIN32 that the DDK provides, because the */
-/* DDK got it wrong! */
+/* This is not the NTSTATUS_FROM_WIN32 that the DDK provides, because the DDK
+ * got it wrong! */
#ifdef NTSTATUS_FROM_WIN32
# undef NTSTATUS_FROM_WIN32
#endif
@@ -4104,7 +4104,14 @@
# define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
#endif
+#ifndef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
+# define SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE 0x00000002
+#endif
+
/* from winternl.h */
+#if !defined(__UNICODE_STRING_DEFINED) && defined(__MINGW32_)
+#define __UNICODE_STRING_DEFINED
+#endif
typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
@@ -4520,6 +4527,9 @@ typedef VOID (NTAPI *PIO_APC_ROUTINE)
PIO_STATUS_BLOCK IoStatusBlock,
ULONG Reserved);
+typedef NTSTATUS (NTAPI *sRtlGetVersion)
+ (PRTL_OSVERSIONINFOW lpVersionInformation);
+
typedef ULONG (NTAPI *sRtlNtStatusToDosError)
(NTSTATUS Status);
@@ -4655,48 +4665,6 @@ typedef BOOL (WINAPI *sGetQueuedCompletionStatusEx)
DWORD dwMilliseconds,
BOOL fAlertable);
-typedef BOOL (WINAPI* sSetFileCompletionNotificationModes)
- (HANDLE FileHandle,
- UCHAR Flags);
-
-typedef BOOLEAN (WINAPI* sCreateSymbolicLinkW)
- (LPCWSTR lpSymlinkFileName,
- LPCWSTR lpTargetFileName,
- DWORD dwFlags);
-
-typedef BOOL (WINAPI* sCancelIoEx)
- (HANDLE hFile,
- LPOVERLAPPED lpOverlapped);
-
-typedef VOID (WINAPI* sInitializeConditionVariable)
- (PCONDITION_VARIABLE ConditionVariable);
-
-typedef BOOL (WINAPI* sSleepConditionVariableCS)
- (PCONDITION_VARIABLE ConditionVariable,
- PCRITICAL_SECTION CriticalSection,
- DWORD dwMilliseconds);
-
-typedef BOOL (WINAPI* sSleepConditionVariableSRW)
- (PCONDITION_VARIABLE ConditionVariable,
- PSRWLOCK SRWLock,
- DWORD dwMilliseconds,
- ULONG Flags);
-
-typedef VOID (WINAPI* sWakeAllConditionVariable)
- (PCONDITION_VARIABLE ConditionVariable);
-
-typedef VOID (WINAPI* sWakeConditionVariable)
- (PCONDITION_VARIABLE ConditionVariable);
-
-typedef BOOL (WINAPI* sCancelSynchronousIo)
- (HANDLE hThread);
-
-typedef DWORD (WINAPI* sGetFinalPathNameByHandleW)
- (HANDLE hFile,
- LPWSTR lpszFilePath,
- DWORD cchFilePath,
- DWORD dwFlags);
-
/* from powerbase.h */
#ifndef DEVICE_NOTIFY_CALLBACK
# define DEVICE_NOTIFY_CALLBACK 2
@@ -4730,8 +4698,28 @@ typedef DWORD (WINAPI *sPowerRegisterSuspendResumeNotification)
HANDLE Recipient,
_PHPOWERNOTIFY RegistrationHandle);
+/* from Winuser.h */
+typedef VOID (CALLBACK* WINEVENTPROC)
+ (HWINEVENTHOOK hWinEventHook,
+ DWORD event,
+ HWND hwnd,
+ LONG idObject,
+ LONG idChild,
+ DWORD idEventThread,
+ DWORD dwmsEventTime);
+
+typedef HWINEVENTHOOK (WINAPI *sSetWinEventHook)
+ (UINT eventMin,
+ UINT eventMax,
+ HMODULE hmodWinEventProc,
+ WINEVENTPROC lpfnWinEventProc,
+ DWORD idProcess,
+ DWORD idThread,
+ UINT dwflags);
+
/* Ntdll function pointers */
+extern sRtlGetVersion pRtlGetVersion;
extern sRtlNtStatusToDosError pRtlNtStatusToDosError;
extern sNtDeviceIoControlFile pNtDeviceIoControlFile;
extern sNtQueryInformationFile pNtQueryInformationFile;
@@ -4740,22 +4728,13 @@ extern sNtQueryVolumeInformationFile pNtQueryVolumeInformationFile;
extern sNtQueryDirectoryFile pNtQueryDirectoryFile;
extern sNtQuerySystemInformation pNtQuerySystemInformation;
-
/* Kernel32 function pointers */
extern sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx;
-extern sSetFileCompletionNotificationModes pSetFileCompletionNotificationModes;
-extern sCreateSymbolicLinkW pCreateSymbolicLinkW;
-extern sCancelIoEx pCancelIoEx;
-extern sInitializeConditionVariable pInitializeConditionVariable;
-extern sSleepConditionVariableCS pSleepConditionVariableCS;
-extern sSleepConditionVariableSRW pSleepConditionVariableSRW;
-extern sWakeAllConditionVariable pWakeAllConditionVariable;
-extern sWakeConditionVariable pWakeConditionVariable;
-extern sCancelSynchronousIo pCancelSynchronousIo;
-extern sGetFinalPathNameByHandleW pGetFinalPathNameByHandleW;
-
/* Powrprof.dll function pointer */
extern sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification;
+/* User32.dll function pointer */
+extern sSetWinEventHook pSetWinEventHook;
+
#endif /* UV_WIN_WINAPI_H_ */
diff --git a/Utilities/cmlibuv/src/win/winsock.c b/Utilities/cmlibuv/src/win/winsock.c
index e86d76b13..5820ba9c6 100644
--- a/Utilities/cmlibuv/src/win/winsock.c
+++ b/Utilities/cmlibuv/src/win/winsock.c
@@ -87,12 +87,6 @@ void uv_winsock_init(void) {
WSAPROTOCOL_INFOW protocol_info;
int opt_len;
- /* Initialize winsock */
- errorno = WSAStartup(MAKEWORD(2, 2), &wsa_data);
- if (errorno != 0) {
- uv_fatal_error(errorno, "WSAStartup");
- }
-
/* Set implicit binding address used by connectEx */
if (uv_ip4_addr("0.0.0.0", 0, &uv_addr_ip4_any_)) {
abort();
@@ -102,6 +96,15 @@ void uv_winsock_init(void) {
abort();
}
+ /* Skip initialization in safe mode without network support */
+ if (1 == GetSystemMetrics(SM_CLEANBOOT)) return;
+
+ /* Initialize winsock */
+ errorno = WSAStartup(MAKEWORD(2, 2), &wsa_data);
+ if (errorno != 0) {
+ uv_fatal_error(errorno, "WSAStartup");
+ }
+
/* Detect non-IFS LSPs */
dummy = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
@@ -256,8 +259,8 @@ int uv_ntstatus_to_winsock_error(NTSTATUS status) {
default:
if ((status & (FACILITY_NTWIN32 << 16)) == (FACILITY_NTWIN32 << 16) &&
(status & (ERROR_SEVERITY_ERROR | ERROR_SEVERITY_WARNING))) {
- /* It's a windows error that has been previously mapped to an */
- /* ntstatus code. */
+ /* It's a windows error that has been previously mapped to an ntstatus
+ * code. */
return (DWORD) (status & 0xffff);
} else {
/* The default fallback for unmappable ntstatus codes. */
@@ -519,8 +522,8 @@ int WSAAPI uv_msafd_poll(SOCKET socket, AFD_POLL_INFO* info_in,
sizeof *info_out);
if (overlapped == NULL) {
- /* If this is a blocking operation, wait for the event to become */
- /* signaled, and then grab the real status from the io status block. */
+ /* If this is a blocking operation, wait for the event to become signaled,
+ * and then grab the real status from the io status block. */
if (status == STATUS_PENDING) {
DWORD r = WaitForSingleObject(event, INFINITE);
@@ -559,3 +562,33 @@ int WSAAPI uv_msafd_poll(SOCKET socket, AFD_POLL_INFO* info_in,
return SOCKET_ERROR;
}
}
+
+int uv__convert_to_localhost_if_unspecified(const struct sockaddr* addr,
+ struct sockaddr_storage* storage) {
+ struct sockaddr_in* dest4;
+ struct sockaddr_in6* dest6;
+
+ if (addr == NULL)
+ return UV_EINVAL;
+
+ switch (addr->sa_family) {
+ case AF_INET:
+ dest4 = (struct sockaddr_in*) storage;
+ memcpy(dest4, addr, sizeof(*dest4));
+ if (dest4->sin_addr.s_addr == 0)
+ dest4->sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ return 0;
+ case AF_INET6:
+ dest6 = (struct sockaddr_in6*) storage;
+ memcpy(dest6, addr, sizeof(*dest6));
+ if (memcmp(&dest6->sin6_addr,
+ &uv_addr_ip6_any_.sin6_addr,
+ sizeof(uv_addr_ip6_any_.sin6_addr)) == 0) {
+ struct in6_addr init_sin6_addr = IN6ADDR_LOOPBACK_INIT;
+ dest6->sin6_addr = init_sin6_addr;
+ }
+ return 0;
+ default:
+ return UV_EINVAL;
+ }
+}
diff --git a/Utilities/cmlibuv/src/win/winsock.h b/Utilities/cmlibuv/src/win/winsock.h
index 3115fe3d2..e8b274e1b 100644
--- a/Utilities/cmlibuv/src/win/winsock.h
+++ b/Utilities/cmlibuv/src/win/winsock.h
@@ -188,4 +188,7 @@ typedef struct _IP_ADAPTER_UNICAST_ADDRESS_LH {
#endif
+int uv__convert_to_localhost_if_unspecified(const struct sockaddr* addr,
+ struct sockaddr_storage* storage);
+
#endif /* UV_WIN_WINSOCK_H_ */
diff --git a/Utilities/cmzlib/CMakeLists.txt b/Utilities/cmzlib/CMakeLists.txt
index 0be48f107..888c3ff77 100644
--- a/Utilities/cmzlib/CMakeLists.txt
+++ b/Utilities/cmzlib/CMakeLists.txt
@@ -2,7 +2,7 @@ PROJECT(CMZLIB)
# Disable warnings to avoid changing 3rd party code.
if(CMAKE_C_COMPILER_ID MATCHES
- "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
+ "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel)$")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
diff --git a/Utilities/cmzstd/.gitattributes b/Utilities/cmzstd/.gitattributes
new file mode 100644
index 000000000..562b12e16
--- /dev/null
+++ b/Utilities/cmzstd/.gitattributes
@@ -0,0 +1 @@
+* -whitespace
diff --git a/Utilities/cmzstd/CMakeLists.txt b/Utilities/cmzstd/CMakeLists.txt
new file mode 100644
index 000000000..8ed04d8d1
--- /dev/null
+++ b/Utilities/cmzstd/CMakeLists.txt
@@ -0,0 +1,47 @@
+project(zstd C)
+
+# Disable warnings to avoid changing 3rd party code.
+if(CMAKE_C_COMPILER_ID MATCHES
+ "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel)$")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
+elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
+endif()
+
+include_directories(lib lib/common)
+
+add_library(cmzstd STATIC
+ lib/common/entropy_common.c
+ lib/common/error_private.c
+ lib/common/fse_decompress.c
+ lib/common/pool.c
+ lib/common/threading.c
+ lib/common/xxhash.c
+ lib/common/zstd_common.c
+ lib/compress/fse_compress.c
+ lib/compress/hist.c
+ lib/compress/huf_compress.c
+ lib/compress/zstd_compress.c
+ lib/compress/zstd_double_fast.c
+ lib/compress/zstd_fast.c
+ lib/compress/zstd_lazy.c
+ lib/compress/zstd_ldm.c
+ lib/compress/zstdmt_compress.c
+ lib/compress/zstd_opt.c
+ lib/decompress/huf_decompress.c
+ lib/decompress/zstd_ddict.c
+ lib/decompress/zstd_decompress_block.c
+ lib/decompress/zstd_decompress.c
+ lib/deprecated/zbuff_common.c
+ lib/deprecated/zbuff_compress.c
+ lib/deprecated/zbuff_decompress.c
+ lib/dictBuilder/cover.c
+ lib/dictBuilder/divsufsort.c
+ lib/dictBuilder/fastcover.c
+ lib/dictBuilder/zdict.c
+ )
+
+# BMI2 instructions are not supported in older environments.
+set_property(TARGET cmzstd PROPERTY COMPILE_DEFINITIONS DYNAMIC_BMI2=0)
+
+install(FILES LICENSE DESTINATION ${CMAKE_DOC_DIR}/cmzstd)
diff --git a/Utilities/cmzstd/LICENSE b/Utilities/cmzstd/LICENSE
new file mode 100644
index 000000000..a793a8028
--- /dev/null
+++ b/Utilities/cmzstd/LICENSE
@@ -0,0 +1,30 @@
+BSD License
+
+For Zstandard software
+
+Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name Facebook nor the names of its contributors may be used to
+ endorse or promote products derived from this software without specific
+ prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Utilities/cmzstd/README.md b/Utilities/cmzstd/README.md
new file mode 100644
index 000000000..4b6d19e7e
--- /dev/null
+++ b/Utilities/cmzstd/README.md
@@ -0,0 +1,167 @@
+<p align="center"><img src="https://raw.githubusercontent.com/facebook/zstd/dev/doc/images/zstd_logo86.png" alt="Zstandard"></p>
+
+__Zstandard__, or `zstd` as short version, is a fast lossless compression algorithm,
+targeting real-time compression scenarios at zlib-level and better compression ratios.
+It's backed by a very fast entropy stage, provided by [Huff0 and FSE library](https://github.com/Cyan4973/FiniteStateEntropy).
+
+The project is provided as an open-source dual [BSD](LICENSE) and [GPLv2](COPYING) licensed **C** library,
+and a command line utility producing and decoding `.zst`, `.gz`, `.xz` and `.lz4` files.
+Should your project require another programming language,
+a list of known ports and bindings is provided on [Zstandard homepage](http://www.zstd.net/#other-languages).
+
+**Development branch status:**
+
+[![Build Status][travisDevBadge]][travisLink]
+[![Build status][AppveyorDevBadge]][AppveyorLink]
+[![Build status][CircleDevBadge]][CircleLink]
+
+[travisDevBadge]: https://travis-ci.org/facebook/zstd.svg?branch=dev "Continuous Integration test suite"
+[travisLink]: https://travis-ci.org/facebook/zstd
+[AppveyorDevBadge]: https://ci.appveyor.com/api/projects/status/xt38wbdxjk5mrbem/branch/dev?svg=true "Windows test suite"
+[AppveyorLink]: https://ci.appveyor.com/project/YannCollet/zstd-p0yf0
+[CircleDevBadge]: https://circleci.com/gh/facebook/zstd/tree/dev.svg?style=shield "Short test suite"
+[CircleLink]: https://circleci.com/gh/facebook/zstd
+
+## Benchmarks
+
+For reference, several fast compression algorithms were tested and compared
+on a server running Linux Debian (`Linux version 4.14.0-3-amd64`),
+with a Core i7-6700K CPU @ 4.0GHz,
+using [lzbench], an open-source in-memory benchmark by @inikep
+compiled with [gcc] 7.3.0,
+on the [Silesia compression corpus].
+
+[lzbench]: https://github.com/inikep/lzbench
+[Silesia compression corpus]: http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia
+[gcc]: https://gcc.gnu.org/
+
+| Compressor name | Ratio | Compression| Decompress.|
+| --------------- | ------| -----------| ---------- |
+| **zstd 1.3.4 -1** | 2.877 | 470 MB/s | 1380 MB/s |
+| zlib 1.2.11 -1 | 2.743 | 110 MB/s | 400 MB/s |
+| brotli 1.0.2 -0 | 2.701 | 410 MB/s | 430 MB/s |
+| quicklz 1.5.0 -1 | 2.238 | 550 MB/s | 710 MB/s |
+| lzo1x 2.09 -1 | 2.108 | 650 MB/s | 830 MB/s |
+| lz4 1.8.1 | 2.101 | 750 MB/s | 3700 MB/s |
+| snappy 1.1.4 | 2.091 | 530 MB/s | 1800 MB/s |
+| lzf 3.6 -1 | 2.077 | 400 MB/s | 860 MB/s |
+
+[zlib]: http://www.zlib.net/
+[LZ4]: http://www.lz4.org/
+
+Zstd can also offer stronger compression ratios at the cost of compression speed.
+Speed vs Compression trade-off is configurable by small increments.
+Decompression speed is preserved and remains roughly the same at all settings,
+a property shared by most LZ compression algorithms, such as [zlib] or lzma.
+
+The following tests were run
+on a server running Linux Debian (`Linux version 4.14.0-3-amd64`)
+with a Core i7-6700K CPU @ 4.0GHz,
+using [lzbench], an open-source in-memory benchmark by @inikep
+compiled with [gcc] 7.3.0,
+on the [Silesia compression corpus].
+
+Compression Speed vs Ratio | Decompression Speed
+---------------------------|--------------------
+![Compression Speed vs Ratio](doc/images/CSpeed2.png "Compression Speed vs Ratio") | ![Decompression Speed](doc/images/DSpeed3.png "Decompression Speed")
+
+A few other algorithms can produce higher compression ratios at slower speeds, falling outside of the graph.
+For a larger picture including slow modes, [click on this link](doc/images/DCspeed5.png).
+
+
+## The case for Small Data compression
+
+Previous charts provide results applicable to typical file and stream scenarios (several MB). Small data comes with different perspectives.
+
+The smaller the amount of data to compress, the more difficult it is to compress. This problem is common to all compression algorithms, and reason is, compression algorithms learn from past data how to compress future data. But at the beginning of a new data set, there is no "past" to build upon.
+
+To solve this situation, Zstd offers a __training mode__, which can be used to tune the algorithm for a selected type of data.
+Training Zstandard is achieved by providing it with a few samples (one file per sample). The result of this training is stored in a file called "dictionary", which must be loaded before compression and decompression.
+Using this dictionary, the compression ratio achievable on small data improves dramatically.
+
+The following example uses the `github-users` [sample set](https://github.com/facebook/zstd/releases/tag/v1.1.3), created from [github public API](https://developer.github.com/v3/users/#get-all-users).
+It consists of roughly 10K records weighing about 1KB each.
+
+Compression Ratio | Compression Speed | Decompression Speed
+------------------|-------------------|--------------------
+![Compression Ratio](doc/images/dict-cr.png "Compression Ratio") | ![Compression Speed](doc/images/dict-cs.png "Compression Speed") | ![Decompression Speed](doc/images/dict-ds.png "Decompression Speed")
+
+
+These compression gains are achieved while simultaneously providing _faster_ compression and decompression speeds.
+
+Training works if there is some correlation in a family of small data samples. The more data-specific a dictionary is, the more efficient it is (there is no _universal dictionary_).
+Hence, deploying one dictionary per type of data will provide the greatest benefits.
+Dictionary gains are mostly effective in the first few KB. Then, the compression algorithm will gradually use previously decoded content to better compress the rest of the file.
+
+### Dictionary compression How To:
+
+1. Create the dictionary
+
+ `zstd --train FullPathToTrainingSet/* -o dictionaryName`
+
+2. Compress with dictionary
+
+ `zstd -D dictionaryName FILE`
+
+3. Decompress with dictionary
+
+ `zstd -D dictionaryName --decompress FILE.zst`
+
+
+## Build instructions
+
+### Makefile
+
+If your system is compatible with standard `make` (or `gmake`),
+invoking `make` in root directory will generate `zstd` cli in root directory.
+
+Other available options include:
+- `make install` : create and install zstd cli, library and man pages
+- `make check` : create and run `zstd`, tests its behavior on local platform
+
+### cmake
+
+A `cmake` project generator is provided within `build/cmake`.
+It can generate Makefiles or other build scripts
+to create `zstd` binary, and `libzstd` dynamic and static libraries.
+
+By default, `CMAKE_BUILD_TYPE` is set to `Release`.
+
+### Meson
+
+A Meson project is provided within [`build/meson`](build/meson). Follow
+build instructions in that directory.
+
+You can also take a look at [`.travis.yml`](.travis.yml) file for an
+example about how Meson is used to build this project.
+
+Note that default build type is **release**.
+
+### Visual Studio (Windows)
+
+Going into `build` directory, you will find additional possibilities:
+- Projects for Visual Studio 2005, 2008 and 2010.
+ + VS2010 project is compatible with VS2012, VS2013, VS2015 and VS2017.
+- Automated build scripts for Visual compiler by [@KrzysFR](https://github.com/KrzysFR), in `build/VS_scripts`,
+ which will build `zstd` cli and `libzstd` library without any need to open Visual Studio solution.
+
+### Buck
+
+You can build the zstd binary via buck by executing: `buck build programs:zstd` from the root of the repo.
+The output binary will be in `buck-out/gen/programs/`.
+
+## Status
+
+Zstandard is currently deployed within Facebook. It is used continuously to compress large amounts of data in multiple formats and use cases.
+Zstandard is considered safe for production environments.
+
+## License
+
+Zstandard is dual-licensed under [BSD](LICENSE) and [GPLv2](COPYING).
+
+## Contributing
+
+The "dev" branch is the one where all contributions are merged before reaching "master".
+If you plan to propose a patch, please commit into the "dev" branch, or its own feature branch.
+Direct commit to "master" are not permitted.
+For more information, please read [CONTRIBUTING](CONTRIBUTING.md).
diff --git a/Utilities/cmzstd/lib/common/bitstream.h b/Utilities/cmzstd/lib/common/bitstream.h
new file mode 100644
index 000000000..d955bd677
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/bitstream.h
@@ -0,0 +1,455 @@
+/* ******************************************************************
+ bitstream
+ Part of FSE library
+ Copyright (C) 2013-present, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
+****************************************************************** */
+#ifndef BITSTREAM_H_MODULE
+#define BITSTREAM_H_MODULE
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/*
+* This API consists of small unitary functions, which must be inlined for best performance.
+* Since link-time-optimization is not available for all compilers,
+* these functions are defined into a .h to be included.
+*/
+
+/*-****************************************
+* Dependencies
+******************************************/
+#include "mem.h" /* unaligned access routines */
+#include "debug.h" /* assert(), DEBUGLOG(), RAWLOG() */
+#include "error_private.h" /* error codes and messages */
+
+
+/*=========================================
+* Target specific
+=========================================*/
+#if defined(__BMI__) && defined(__GNUC__)
+# include <immintrin.h> /* support for bextr (experimental) */
+#endif
+
+#define STREAM_ACCUMULATOR_MIN_32 25
+#define STREAM_ACCUMULATOR_MIN_64 57
+#define STREAM_ACCUMULATOR_MIN ((U32)(MEM_32bits() ? STREAM_ACCUMULATOR_MIN_32 : STREAM_ACCUMULATOR_MIN_64))
+
+
+/*-******************************************
+* bitStream encoding API (write forward)
+********************************************/
+/* bitStream can mix input from multiple sources.
+ * A critical property of these streams is that they encode and decode in **reverse** direction.
+ * So the first bit sequence you add will be the last to be read, like a LIFO stack.
+ */
+typedef struct {
+ size_t bitContainer;
+ unsigned bitPos;
+ char* startPtr;
+ char* ptr;
+ char* endPtr;
+} BIT_CStream_t;
+
+MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, void* dstBuffer, size_t dstCapacity);
+MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC, size_t value, unsigned nbBits);
+MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC);
+MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC);
+
+/* Start with initCStream, providing the size of buffer to write into.
+* bitStream will never write outside of this buffer.
+* `dstCapacity` must be >= sizeof(bitD->bitContainer), otherwise @return will be an error code.
+*
+* bits are first added to a local register.
+* Local register is size_t, hence 64-bits on 64-bits systems, or 32-bits on 32-bits systems.
+* Writing data into memory is an explicit operation, performed by the flushBits function.
+* Hence keep track how many bits are potentially stored into local register to avoid register overflow.
+* After a flushBits, a maximum of 7 bits might still be stored into local register.
+*
+* Avoid storing elements of more than 24 bits if you want compatibility with 32-bits bitstream readers.
+*
+* Last operation is to close the bitStream.
+* The function returns the final size of CStream in bytes.
+* If data couldn't fit into `dstBuffer`, it will return a 0 ( == not storable)
+*/
+
+
+/*-********************************************
+* bitStream decoding API (read backward)
+**********************************************/
+typedef struct {
+ size_t bitContainer;
+ unsigned bitsConsumed;
+ const char* ptr;
+ const char* start;
+ const char* limitPtr;
+} BIT_DStream_t;
+
+typedef enum { BIT_DStream_unfinished = 0,
+ BIT_DStream_endOfBuffer = 1,
+ BIT_DStream_completed = 2,
+ BIT_DStream_overflow = 3 } BIT_DStream_status; /* result of BIT_reloadDStream() */
+ /* 1,2,4,8 would be better for bitmap combinations, but slows down performance a bit ... :( */
+
+MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize);
+MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits);
+MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD);
+MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* bitD);
+
+
+/* Start by invoking BIT_initDStream().
+* A chunk of the bitStream is then stored into a local register.
+* Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t).
+* You can then retrieve bitFields stored into the local register, **in reverse order**.
+* Local register is explicitly reloaded from memory by the BIT_reloadDStream() method.
+* A reload guarantee a minimum of ((8*sizeof(bitD->bitContainer))-7) bits when its result is BIT_DStream_unfinished.
+* Otherwise, it can be less than that, so proceed accordingly.
+* Checking if DStream has reached its end can be performed with BIT_endOfDStream().
+*/
+
+
+/*-****************************************
+* unsafe API
+******************************************/
+MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC, size_t value, unsigned nbBits);
+/* faster, but works only if value is "clean", meaning all high bits above nbBits are 0 */
+
+MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC);
+/* unsafe version; does not check buffer overflow */
+
+MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits);
+/* faster, but works only if nbBits >= 1 */
+
+
+
+/*-**************************************************************
+* Internal functions
+****************************************************************/
+MEM_STATIC unsigned BIT_highbit32 (U32 val)
+{
+ assert(val != 0);
+ {
+# if defined(_MSC_VER) /* Visual */
+ unsigned long r=0;
+ _BitScanReverse ( &r, val );
+ return (unsigned) r;
+# elif defined(__GNUC__) && (__GNUC__ >= 3) /* Use GCC Intrinsic */
+ return 31 - __builtin_clz (val);
+# else /* Software version */
+ static const unsigned DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29,
+ 11, 14, 16, 18, 22, 25, 3, 30,
+ 8, 12, 20, 28, 15, 17, 24, 7,
+ 19, 27, 23, 6, 26, 5, 4, 31 };
+ U32 v = val;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ return DeBruijnClz[ (U32) (v * 0x07C4ACDDU) >> 27];
+# endif
+ }
+}
+
+/*===== Local Constants =====*/
+static const unsigned BIT_mask[] = {
+ 0, 1, 3, 7, 0xF, 0x1F,
+ 0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF,
+ 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, 0x1FFFF,
+ 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, 0x7FFFFF,
+ 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, 0xFFFFFFF, 0x1FFFFFFF,
+ 0x3FFFFFFF, 0x7FFFFFFF}; /* up to 31 bits */
+#define BIT_MASK_SIZE (sizeof(BIT_mask) / sizeof(BIT_mask[0]))
+
+/*-**************************************************************
+* bitStream encoding
+****************************************************************/
+/*! BIT_initCStream() :
+ * `dstCapacity` must be > sizeof(size_t)
+ * @return : 0 if success,
+ * otherwise an error code (can be tested using ERR_isError()) */
+MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC,
+ void* startPtr, size_t dstCapacity)
+{
+ bitC->bitContainer = 0;
+ bitC->bitPos = 0;
+ bitC->startPtr = (char*)startPtr;
+ bitC->ptr = bitC->startPtr;
+ bitC->endPtr = bitC->startPtr + dstCapacity - sizeof(bitC->bitContainer);
+ if (dstCapacity <= sizeof(bitC->bitContainer)) return ERROR(dstSize_tooSmall);
+ return 0;
+}
+
+/*! BIT_addBits() :
+ * can add up to 31 bits into `bitC`.
+ * Note : does not check for register overflow ! */
+MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC,
+ size_t value, unsigned nbBits)
+{
+ MEM_STATIC_ASSERT(BIT_MASK_SIZE == 32);
+ assert(nbBits < BIT_MASK_SIZE);
+ assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8);
+ bitC->bitContainer |= (value & BIT_mask[nbBits]) << bitC->bitPos;
+ bitC->bitPos += nbBits;
+}
+
+/*! BIT_addBitsFast() :
+ * works only if `value` is _clean_,
+ * meaning all high bits above nbBits are 0 */
+MEM_STATIC void BIT_addBitsFast(BIT_CStream_t* bitC,
+ size_t value, unsigned nbBits)
+{
+ assert((value>>nbBits) == 0);
+ assert(nbBits + bitC->bitPos < sizeof(bitC->bitContainer) * 8);
+ bitC->bitContainer |= value << bitC->bitPos;
+ bitC->bitPos += nbBits;
+}
+
+/*! BIT_flushBitsFast() :
+ * assumption : bitContainer has not overflowed
+ * unsafe version; does not check buffer overflow */
+MEM_STATIC void BIT_flushBitsFast(BIT_CStream_t* bitC)
+{
+ size_t const nbBytes = bitC->bitPos >> 3;
+ assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8);
+ MEM_writeLEST(bitC->ptr, bitC->bitContainer);
+ bitC->ptr += nbBytes;
+ assert(bitC->ptr <= bitC->endPtr);
+ bitC->bitPos &= 7;
+ bitC->bitContainer >>= nbBytes*8;
+}
+
+/*! BIT_flushBits() :
+ * assumption : bitContainer has not overflowed
+ * safe version; check for buffer overflow, and prevents it.
+ * note : does not signal buffer overflow.
+ * overflow will be revealed later on using BIT_closeCStream() */
+MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC)
+{
+ size_t const nbBytes = bitC->bitPos >> 3;
+ assert(bitC->bitPos < sizeof(bitC->bitContainer) * 8);
+ MEM_writeLEST(bitC->ptr, bitC->bitContainer);
+ bitC->ptr += nbBytes;
+ if (bitC->ptr > bitC->endPtr) bitC->ptr = bitC->endPtr;
+ bitC->bitPos &= 7;
+ bitC->bitContainer >>= nbBytes*8;
+}
+
+/*! BIT_closeCStream() :
+ * @return : size of CStream, in bytes,
+ * or 0 if it could not fit into dstBuffer */
+MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC)
+{
+ BIT_addBitsFast(bitC, 1, 1); /* endMark */
+ BIT_flushBits(bitC);
+ if (bitC->ptr >= bitC->endPtr) return 0; /* overflow detected */
+ return (bitC->ptr - bitC->startPtr) + (bitC->bitPos > 0);
+}
+
+
+/*-********************************************************
+* bitStream decoding
+**********************************************************/
+/*! BIT_initDStream() :
+ * Initialize a BIT_DStream_t.
+ * `bitD` : a pointer to an already allocated BIT_DStream_t structure.
+ * `srcSize` must be the *exact* size of the bitStream, in bytes.
+ * @return : size of stream (== srcSize), or an errorCode if a problem is detected
+ */
+MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize)
+{
+ if (srcSize < 1) { memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); }
+
+ bitD->start = (const char*)srcBuffer;
+ bitD->limitPtr = bitD->start + sizeof(bitD->bitContainer);
+
+ if (srcSize >= sizeof(bitD->bitContainer)) { /* normal case */
+ bitD->ptr = (const char*)srcBuffer + srcSize - sizeof(bitD->bitContainer);
+ bitD->bitContainer = MEM_readLEST(bitD->ptr);
+ { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
+ bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; /* ensures bitsConsumed is always set */
+ if (lastByte == 0) return ERROR(GENERIC); /* endMark not present */ }
+ } else {
+ bitD->ptr = bitD->start;
+ bitD->bitContainer = *(const BYTE*)(bitD->start);
+ switch(srcSize)
+ {
+ case 7: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16);
+ /* fall-through */
+
+ case 6: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24);
+ /* fall-through */
+
+ case 5: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32);
+ /* fall-through */
+
+ case 4: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[3]) << 24;
+ /* fall-through */
+
+ case 3: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[2]) << 16;
+ /* fall-through */
+
+ case 2: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[1]) << 8;
+ /* fall-through */
+
+ default: break;
+ }
+ { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1];
+ bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0;
+ if (lastByte == 0) return ERROR(corruption_detected); /* endMark not present */
+ }
+ bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize)*8;
+ }
+
+ return srcSize;
+}
+
+MEM_STATIC size_t BIT_getUpperBits(size_t bitContainer, U32 const start)
+{
+ return bitContainer >> start;
+}
+
+MEM_STATIC size_t BIT_getMiddleBits(size_t bitContainer, U32 const start, U32 const nbBits)
+{
+ U32 const regMask = sizeof(bitContainer)*8 - 1;
+ /* if start > regMask, bitstream is corrupted, and result is undefined */
+ assert(nbBits < BIT_MASK_SIZE);
+ return (bitContainer >> (start & regMask)) & BIT_mask[nbBits];
+}
+
+MEM_STATIC size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits)
+{
+ assert(nbBits < BIT_MASK_SIZE);
+ return bitContainer & BIT_mask[nbBits];
+}
+
+/*! BIT_lookBits() :
+ * Provides next n bits from local register.
+ * local register is not modified.
+ * On 32-bits, maxNbBits==24.
+ * On 64-bits, maxNbBits==56.
+ * @return : value extracted */
+MEM_STATIC size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits)
+{
+ /* arbitrate between double-shift and shift+mask */
+#if 1
+ /* if bitD->bitsConsumed + nbBits > sizeof(bitD->bitContainer)*8,
+ * bitstream is likely corrupted, and result is undefined */
+ return BIT_getMiddleBits(bitD->bitContainer, (sizeof(bitD->bitContainer)*8) - bitD->bitsConsumed - nbBits, nbBits);
+#else
+ /* this code path is slower on my os-x laptop */
+ U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
+ return ((bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> 1) >> ((regMask-nbBits) & regMask);
+#endif
+}
+
+/*! BIT_lookBitsFast() :
+ * unsafe version; only works if nbBits >= 1 */
+MEM_STATIC size_t BIT_lookBitsFast(const BIT_DStream_t* bitD, U32 nbBits)
+{
+ U32 const regMask = sizeof(bitD->bitContainer)*8 - 1;
+ assert(nbBits >= 1);
+ return (bitD->bitContainer << (bitD->bitsConsumed & regMask)) >> (((regMask+1)-nbBits) & regMask);
+}
+
+MEM_STATIC void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits)
+{
+ bitD->bitsConsumed += nbBits;
+}
+
+/*! BIT_readBits() :
+ * Read (consume) next n bits from local register and update.
+ * Pay attention to not read more than nbBits contained into local register.
+ * @return : extracted value. */
+MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, unsigned nbBits)
+{
+ size_t const value = BIT_lookBits(bitD, nbBits);
+ BIT_skipBits(bitD, nbBits);
+ return value;
+}
+
+/*! BIT_readBitsFast() :
+ * unsafe version; only works only if nbBits >= 1 */
+MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, unsigned nbBits)
+{
+ size_t const value = BIT_lookBitsFast(bitD, nbBits);
+ assert(nbBits >= 1);
+ BIT_skipBits(bitD, nbBits);
+ return value;
+}
+
+/*! BIT_reloadDStream() :
+ * Refill `bitD` from buffer previously set in BIT_initDStream() .
+ * This function is safe, it guarantees it will not read beyond src buffer.
+ * @return : status of `BIT_DStream_t` internal register.
+ * when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits */
+MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
+{
+ if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* overflow detected, like end of stream */
+ return BIT_DStream_overflow;
+
+ if (bitD->ptr >= bitD->limitPtr) {
+ bitD->ptr -= bitD->bitsConsumed >> 3;
+ bitD->bitsConsumed &= 7;
+ bitD->bitContainer = MEM_readLEST(bitD->ptr);
+ return BIT_DStream_unfinished;
+ }
+ if (bitD->ptr == bitD->start) {
+ if (bitD->bitsConsumed < sizeof(bitD->bitContainer)*8) return BIT_DStream_endOfBuffer;
+ return BIT_DStream_completed;
+ }
+ /* start < ptr < limitPtr */
+ { U32 nbBytes = bitD->bitsConsumed >> 3;
+ BIT_DStream_status result = BIT_DStream_unfinished;
+ if (bitD->ptr - nbBytes < bitD->start) {
+ nbBytes = (U32)(bitD->ptr - bitD->start); /* ptr > start */
+ result = BIT_DStream_endOfBuffer;
+ }
+ bitD->ptr -= nbBytes;
+ bitD->bitsConsumed -= nbBytes*8;
+ bitD->bitContainer = MEM_readLEST(bitD->ptr); /* reminder : srcSize > sizeof(bitD->bitContainer), otherwise bitD->ptr == bitD->start */
+ return result;
+ }
+}
+
+/*! BIT_endOfDStream() :
+ * @return : 1 if DStream has _exactly_ reached its end (all bits consumed).
+ */
+MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream)
+{
+ return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8));
+}
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* BITSTREAM_H_MODULE */
diff --git a/Utilities/cmzstd/lib/common/compiler.h b/Utilities/cmzstd/lib/common/compiler.h
new file mode 100644
index 000000000..7f561282c
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/compiler.h
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef ZSTD_COMPILER_H
+#define ZSTD_COMPILER_H
+
+/*-*******************************************************
+* Compiler specifics
+*********************************************************/
+/* force inlining */
+
+#if !defined(ZSTD_NO_INLINE)
+#if defined (__GNUC__) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
+# define INLINE_KEYWORD inline
+#else
+# define INLINE_KEYWORD
+#endif
+
+#if defined(__GNUC__)
+# define FORCE_INLINE_ATTR __attribute__((always_inline))
+#elif defined(_MSC_VER)
+# define FORCE_INLINE_ATTR __forceinline
+#else
+# define FORCE_INLINE_ATTR
+#endif
+
+#else
+
+#define INLINE_KEYWORD
+#define FORCE_INLINE_ATTR
+
+#endif
+
+/**
+ * FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant
+ * parameters. They must be inlined for the compiler to elimininate the constant
+ * branches.
+ */
+#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR
+/**
+ * HINT_INLINE is used to help the compiler generate better code. It is *not*
+ * used for "templates", so it can be tweaked based on the compilers
+ * performance.
+ *
+ * gcc-4.8 and gcc-4.9 have been shown to benefit from leaving off the
+ * always_inline attribute.
+ *
+ * clang up to 5.0.0 (trunk) benefit tremendously from the always_inline
+ * attribute.
+ */
+#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8 && __GNUC__ < 5
+# define HINT_INLINE static INLINE_KEYWORD
+#else
+# define HINT_INLINE static INLINE_KEYWORD FORCE_INLINE_ATTR
+#endif
+
+/* force no inlining */
+#ifdef _MSC_VER
+# define FORCE_NOINLINE static __declspec(noinline)
+#else
+# ifdef __GNUC__
+# define FORCE_NOINLINE static __attribute__((__noinline__))
+# else
+# define FORCE_NOINLINE static
+# endif
+#endif
+
+/* target attribute */
+#ifndef __has_attribute
+ #define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
+#endif
+#if defined(__GNUC__)
+# define TARGET_ATTRIBUTE(target) __attribute__((__target__(target)))
+#else
+# define TARGET_ATTRIBUTE(target)
+#endif
+
+/* Enable runtime BMI2 dispatch based on the CPU.
+ * Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default.
+ */
+#ifndef DYNAMIC_BMI2
+ #if ((defined(__clang__) && __has_attribute(__target__)) \
+ || (defined(__GNUC__) \
+ && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))) \
+ && (defined(__x86_64__) || defined(_M_X86)) \
+ && !defined(__BMI2__)
+ # define DYNAMIC_BMI2 1
+ #else
+ # define DYNAMIC_BMI2 0
+ #endif
+#endif
+
+/* prefetch
+ * can be disabled, by declaring NO_PREFETCH build macro */
+#if defined(NO_PREFETCH)
+# define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
+# define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
+#else
+# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */
+# include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */
+# define PREFETCH_L1(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0)
+# define PREFETCH_L2(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1)
+# elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) )
+# define PREFETCH_L1(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */)
+# define PREFETCH_L2(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */)
+# else
+# define PREFETCH_L1(ptr) (void)(ptr) /* disabled */
+# define PREFETCH_L2(ptr) (void)(ptr) /* disabled */
+# endif
+#endif /* NO_PREFETCH */
+
+#define CACHELINE_SIZE 64
+
+#define PREFETCH_AREA(p, s) { \
+ const char* const _ptr = (const char*)(p); \
+ size_t const _size = (size_t)(s); \
+ size_t _pos; \
+ for (_pos=0; _pos<_size; _pos+=CACHELINE_SIZE) { \
+ PREFETCH_L2(_ptr + _pos); \
+ } \
+}
+
+/* disable warnings */
+#ifdef _MSC_VER /* Visual Studio */
+# include <intrin.h> /* For Visual 2005 */
+# pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */
+# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
+# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */
+# pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */
+# pragma warning(disable : 4324) /* disable: C4324: padded structure */
+#endif
+
+#endif /* ZSTD_COMPILER_H */
diff --git a/Utilities/cmzstd/lib/common/cpu.h b/Utilities/cmzstd/lib/common/cpu.h
new file mode 100644
index 000000000..5f0923fc9
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/cpu.h
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2018-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef ZSTD_COMMON_CPU_H
+#define ZSTD_COMMON_CPU_H
+
+/**
+ * Implementation taken from folly/CpuId.h
+ * https://github.com/facebook/folly/blob/master/folly/CpuId.h
+ */
+
+#include <string.h>
+
+#include "mem.h"
+
+#ifdef _MSC_VER
+#include <intrin.h>
+#endif
+
+typedef struct {
+ U32 f1c;
+ U32 f1d;
+ U32 f7b;
+ U32 f7c;
+} ZSTD_cpuid_t;
+
+MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) {
+ U32 f1c = 0;
+ U32 f1d = 0;
+ U32 f7b = 0;
+ U32 f7c = 0;
+#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))
+ int reg[4];
+ __cpuid((int*)reg, 0);
+ {
+ int const n = reg[0];
+ if (n >= 1) {
+ __cpuid((int*)reg, 1);
+ f1c = (U32)reg[2];
+ f1d = (U32)reg[3];
+ }
+ if (n >= 7) {
+ __cpuidex((int*)reg, 7, 0);
+ f7b = (U32)reg[1];
+ f7c = (U32)reg[2];
+ }
+ }
+#elif defined(__i386__) && defined(__PIC__) && !defined(__clang__) && defined(__GNUC__)
+ /* The following block like the normal cpuid branch below, but gcc
+ * reserves ebx for use of its pic register so we must specially
+ * handle the save and restore to avoid clobbering the register
+ */
+ U32 n;
+ __asm__(
+ "pushl %%ebx\n\t"
+ "cpuid\n\t"
+ "popl %%ebx\n\t"
+ : "=a"(n)
+ : "a"(0)
+ : "ecx", "edx");
+ if (n >= 1) {
+ U32 f1a;
+ __asm__(
+ "pushl %%ebx\n\t"
+ "cpuid\n\t"
+ "popl %%ebx\n\t"
+ : "=a"(f1a), "=c"(f1c), "=d"(f1d)
+ : "a"(1));
+ }
+ if (n >= 7) {
+ __asm__(
+ "pushl %%ebx\n\t"
+ "cpuid\n\t"
+ "movl %%ebx, %%eax\n\t"
+ "popl %%ebx"
+ : "=a"(f7b), "=c"(f7c)
+ : "a"(7), "c"(0)
+ : "edx");
+ }
+#elif defined(__x86_64__) || defined(_M_X64) || defined(__i386__)
+ U32 n;
+ __asm__("cpuid" : "=a"(n) : "a"(0) : "ebx", "ecx", "edx");
+ if (n >= 1) {
+ U32 f1a;
+ __asm__("cpuid" : "=a"(f1a), "=c"(f1c), "=d"(f1d) : "a"(1) : "ebx");
+ }
+ if (n >= 7) {
+ U32 f7a;
+ __asm__("cpuid"
+ : "=a"(f7a), "=b"(f7b), "=c"(f7c)
+ : "a"(7), "c"(0)
+ : "edx");
+ }
+#endif
+ {
+ ZSTD_cpuid_t cpuid;
+ cpuid.f1c = f1c;
+ cpuid.f1d = f1d;
+ cpuid.f7b = f7b;
+ cpuid.f7c = f7c;
+ return cpuid;
+ }
+}
+
+#define X(name, r, bit) \
+ MEM_STATIC int ZSTD_cpuid_##name(ZSTD_cpuid_t const cpuid) { \
+ return ((cpuid.r) & (1U << bit)) != 0; \
+ }
+
+/* cpuid(1): Processor Info and Feature Bits. */
+#define C(name, bit) X(name, f1c, bit)
+ C(sse3, 0)
+ C(pclmuldq, 1)
+ C(dtes64, 2)
+ C(monitor, 3)
+ C(dscpl, 4)
+ C(vmx, 5)
+ C(smx, 6)
+ C(eist, 7)
+ C(tm2, 8)
+ C(ssse3, 9)
+ C(cnxtid, 10)
+ C(fma, 12)
+ C(cx16, 13)
+ C(xtpr, 14)
+ C(pdcm, 15)
+ C(pcid, 17)
+ C(dca, 18)
+ C(sse41, 19)
+ C(sse42, 20)
+ C(x2apic, 21)
+ C(movbe, 22)
+ C(popcnt, 23)
+ C(tscdeadline, 24)
+ C(aes, 25)
+ C(xsave, 26)
+ C(osxsave, 27)
+ C(avx, 28)
+ C(f16c, 29)
+ C(rdrand, 30)
+#undef C
+#define D(name, bit) X(name, f1d, bit)
+ D(fpu, 0)
+ D(vme, 1)
+ D(de, 2)
+ D(pse, 3)
+ D(tsc, 4)
+ D(msr, 5)
+ D(pae, 6)
+ D(mce, 7)
+ D(cx8, 8)
+ D(apic, 9)
+ D(sep, 11)
+ D(mtrr, 12)
+ D(pge, 13)
+ D(mca, 14)
+ D(cmov, 15)
+ D(pat, 16)
+ D(pse36, 17)
+ D(psn, 18)
+ D(clfsh, 19)
+ D(ds, 21)
+ D(acpi, 22)
+ D(mmx, 23)
+ D(fxsr, 24)
+ D(sse, 25)
+ D(sse2, 26)
+ D(ss, 27)
+ D(htt, 28)
+ D(tm, 29)
+ D(pbe, 31)
+#undef D
+
+/* cpuid(7): Extended Features. */
+#define B(name, bit) X(name, f7b, bit)
+ B(bmi1, 3)
+ B(hle, 4)
+ B(avx2, 5)
+ B(smep, 7)
+ B(bmi2, 8)
+ B(erms, 9)
+ B(invpcid, 10)
+ B(rtm, 11)
+ B(mpx, 14)
+ B(avx512f, 16)
+ B(avx512dq, 17)
+ B(rdseed, 18)
+ B(adx, 19)
+ B(smap, 20)
+ B(avx512ifma, 21)
+ B(pcommit, 22)
+ B(clflushopt, 23)
+ B(clwb, 24)
+ B(avx512pf, 26)
+ B(avx512er, 27)
+ B(avx512cd, 28)
+ B(sha, 29)
+ B(avx512bw, 30)
+ B(avx512vl, 31)
+#undef B
+#define C(name, bit) X(name, f7c, bit)
+ C(prefetchwt1, 0)
+ C(avx512vbmi, 1)
+#undef C
+
+#undef X
+
+#endif /* ZSTD_COMMON_CPU_H */
diff --git a/Utilities/cmzstd/lib/common/debug.c b/Utilities/cmzstd/lib/common/debug.c
new file mode 100644
index 000000000..3ebdd1cb1
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/debug.c
@@ -0,0 +1,44 @@
+/* ******************************************************************
+ debug
+ Part of FSE library
+ Copyright (C) 2013-present, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
+****************************************************************** */
+
+
+/*
+ * This module only hosts one global variable
+ * which can be used to dynamically influence the verbosity of traces,
+ * such as DEBUGLOG and RAWLOG
+ */
+
+#include "debug.h"
+
+int g_debuglevel = DEBUGLEVEL;
diff --git a/Utilities/cmzstd/lib/common/debug.h b/Utilities/cmzstd/lib/common/debug.h
new file mode 100644
index 000000000..b4fc89d49
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/debug.h
@@ -0,0 +1,134 @@
+/* ******************************************************************
+ debug
+ Part of FSE library
+ Copyright (C) 2013-present, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
+****************************************************************** */
+
+
+/*
+ * The purpose of this header is to enable debug functions.
+ * They regroup assert(), DEBUGLOG() and RAWLOG() for run-time,
+ * and DEBUG_STATIC_ASSERT() for compile-time.
+ *
+ * By default, DEBUGLEVEL==0, which means run-time debug is disabled.
+ *
+ * Level 1 enables assert() only.
+ * Starting level 2, traces can be generated and pushed to stderr.
+ * The higher the level, the more verbose the traces.
+ *
+ * It's possible to dynamically adjust level using variable g_debug_level,
+ * which is only declared if DEBUGLEVEL>=2,
+ * and is a global variable, not multi-thread protected (use with care)
+ */
+
+#ifndef DEBUG_H_12987983217
+#define DEBUG_H_12987983217
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/* static assert is triggered at compile time, leaving no runtime artefact.
+ * static assert only works with compile-time constants.
+ * Also, this variant can only be used inside a function. */
+#define DEBUG_STATIC_ASSERT(c) (void)sizeof(char[(c) ? 1 : -1])
+
+
+/* DEBUGLEVEL is expected to be defined externally,
+ * typically through compiler command line.
+ * Value must be a number. */
+#ifndef DEBUGLEVEL
+# define DEBUGLEVEL 0
+#endif
+
+
+/* DEBUGFILE can be defined externally,
+ * typically through compiler command line.
+ * note : currently useless.
+ * Value must be stderr or stdout */
+#ifndef DEBUGFILE
+# define DEBUGFILE stderr
+#endif
+
+
+/* recommended values for DEBUGLEVEL :
+ * 0 : release mode, no debug, all run-time checks disabled
+ * 1 : enables assert() only, no display
+ * 2 : reserved, for currently active debug path
+ * 3 : events once per object lifetime (CCtx, CDict, etc.)
+ * 4 : events once per frame
+ * 5 : events once per block
+ * 6 : events once per sequence (verbose)
+ * 7+: events at every position (*very* verbose)
+ *
+ * It's generally inconvenient to output traces > 5.
+ * In which case, it's possible to selectively trigger high verbosity levels
+ * by modifying g_debug_level.
+ */
+
+#if (DEBUGLEVEL>=1)
+# include <assert.h>
+#else
+# ifndef assert /* assert may be already defined, due to prior #include <assert.h> */
+# define assert(condition) ((void)0) /* disable assert (default) */
+# endif
+#endif
+
+#if (DEBUGLEVEL>=2)
+# include <stdio.h>
+extern int g_debuglevel; /* the variable is only declared,
+ it actually lives in debug.c,
+ and is shared by the whole process.
+ It's not thread-safe.
+ It's useful when enabling very verbose levels
+ on selective conditions (such as position in src) */
+
+# define RAWLOG(l, ...) { \
+ if (l<=g_debuglevel) { \
+ fprintf(stderr, __VA_ARGS__); \
+ } }
+# define DEBUGLOG(l, ...) { \
+ if (l<=g_debuglevel) { \
+ fprintf(stderr, __FILE__ ": " __VA_ARGS__); \
+ fprintf(stderr, " \n"); \
+ } }
+#else
+# define RAWLOG(l, ...) {} /* disabled */
+# define DEBUGLOG(l, ...) {} /* disabled */
+#endif
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* DEBUG_H_12987983217 */
diff --git a/Utilities/cmzstd/lib/common/entropy_common.c b/Utilities/cmzstd/lib/common/entropy_common.c
new file mode 100644
index 000000000..b12944e1d
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/entropy_common.c
@@ -0,0 +1,236 @@
+/*
+ Common functions of New Generation Entropy library
+ Copyright (C) 2016, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - FSE+HUF source repository : https://github.com/Cyan4973/FiniteStateEntropy
+ - Public forum : https://groups.google.com/forum/#!forum/lz4c
+*************************************************************************** */
+
+/* *************************************
+* Dependencies
+***************************************/
+#include "mem.h"
+#include "error_private.h" /* ERR_*, ERROR */
+#define FSE_STATIC_LINKING_ONLY /* FSE_MIN_TABLELOG */
+#include "fse.h"
+#define HUF_STATIC_LINKING_ONLY /* HUF_TABLELOG_ABSOLUTEMAX */
+#include "huf.h"
+
+
+/*=== Version ===*/
+unsigned FSE_versionNumber(void) { return FSE_VERSION_NUMBER; }
+
+
+/*=== Error Management ===*/
+unsigned FSE_isError(size_t code) { return ERR_isError(code); }
+const char* FSE_getErrorName(size_t code) { return ERR_getErrorName(code); }
+
+unsigned HUF_isError(size_t code) { return ERR_isError(code); }
+const char* HUF_getErrorName(size_t code) { return ERR_getErrorName(code); }
+
+
+/*-**************************************************************
+* FSE NCount encoding-decoding
+****************************************************************/
+size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* tableLogPtr,
+ const void* headerBuffer, size_t hbSize)
+{
+ const BYTE* const istart = (const BYTE*) headerBuffer;
+ const BYTE* const iend = istart + hbSize;
+ const BYTE* ip = istart;
+ int nbBits;
+ int remaining;
+ int threshold;
+ U32 bitStream;
+ int bitCount;
+ unsigned charnum = 0;
+ int previous0 = 0;
+
+ if (hbSize < 4) {
+ /* This function only works when hbSize >= 4 */
+ char buffer[4];
+ memset(buffer, 0, sizeof(buffer));
+ memcpy(buffer, headerBuffer, hbSize);
+ { size_t const countSize = FSE_readNCount(normalizedCounter, maxSVPtr, tableLogPtr,
+ buffer, sizeof(buffer));
+ if (FSE_isError(countSize)) return countSize;
+ if (countSize > hbSize) return ERROR(corruption_detected);
+ return countSize;
+ } }
+ assert(hbSize >= 4);
+
+ /* init */
+ memset(normalizedCounter, 0, (*maxSVPtr+1) * sizeof(normalizedCounter[0])); /* all symbols not present in NCount have a frequency of 0 */
+ bitStream = MEM_readLE32(ip);
+ nbBits = (bitStream & 0xF) + FSE_MIN_TABLELOG; /* extract tableLog */
+ if (nbBits > FSE_TABLELOG_ABSOLUTE_MAX) return ERROR(tableLog_tooLarge);
+ bitStream >>= 4;
+ bitCount = 4;
+ *tableLogPtr = nbBits;
+ remaining = (1<<nbBits)+1;
+ threshold = 1<<nbBits;
+ nbBits++;
+
+ while ((remaining>1) & (charnum<=*maxSVPtr)) {
+ if (previous0) {
+ unsigned n0 = charnum;
+ while ((bitStream & 0xFFFF) == 0xFFFF) {
+ n0 += 24;
+ if (ip < iend-5) {
+ ip += 2;
+ bitStream = MEM_readLE32(ip) >> bitCount;
+ } else {
+ bitStream >>= 16;
+ bitCount += 16;
+ } }
+ while ((bitStream & 3) == 3) {
+ n0 += 3;
+ bitStream >>= 2;
+ bitCount += 2;
+ }
+ n0 += bitStream & 3;
+ bitCount += 2;
+ if (n0 > *maxSVPtr) return ERROR(maxSymbolValue_tooSmall);
+ while (charnum < n0) normalizedCounter[charnum++] = 0;
+ if ((ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) {
+ assert((bitCount >> 3) <= 3); /* For first condition to work */
+ ip += bitCount>>3;
+ bitCount &= 7;
+ bitStream = MEM_readLE32(ip) >> bitCount;
+ } else {
+ bitStream >>= 2;
+ } }
+ { int const max = (2*threshold-1) - remaining;
+ int count;
+
+ if ((bitStream & (threshold-1)) < (U32)max) {
+ count = bitStream & (threshold-1);
+ bitCount += nbBits-1;
+ } else {
+ count = bitStream & (2*threshold-1);
+ if (count >= threshold) count -= max;
+ bitCount += nbBits;
+ }
+
+ count--; /* extra accuracy */
+ remaining -= count < 0 ? -count : count; /* -1 means +1 */
+ normalizedCounter[charnum++] = (short)count;
+ previous0 = !count;
+ while (remaining < threshold) {
+ nbBits--;
+ threshold >>= 1;
+ }
+
+ if ((ip <= iend-7) || (ip + (bitCount>>3) <= iend-4)) {
+ ip += bitCount>>3;
+ bitCount &= 7;
+ } else {
+ bitCount -= (int)(8 * (iend - 4 - ip));
+ ip = iend - 4;
+ }
+ bitStream = MEM_readLE32(ip) >> (bitCount & 31);
+ } } /* while ((remaining>1) & (charnum<=*maxSVPtr)) */
+ if (remaining != 1) return ERROR(corruption_detected);
+ if (bitCount > 32) return ERROR(corruption_detected);
+ *maxSVPtr = charnum-1;
+
+ ip += (bitCount+7)>>3;
+ return ip-istart;
+}
+
+
+/*! HUF_readStats() :
+ Read compact Huffman tree, saved by HUF_writeCTable().
+ `huffWeight` is destination buffer.
+ `rankStats` is assumed to be a table of at least HUF_TABLELOG_MAX U32.
+ @return : size read from `src` , or an error Code .
+ Note : Needed by HUF_readCTable() and HUF_readDTableX?() .
+*/
+size_t HUF_readStats(BYTE* huffWeight, size_t hwSize, U32* rankStats,
+ U32* nbSymbolsPtr, U32* tableLogPtr,
+ const void* src, size_t srcSize)
+{
+ U32 weightTotal;
+ const BYTE* ip = (const BYTE*) src;
+ size_t iSize;
+ size_t oSize;
+
+ if (!srcSize) return ERROR(srcSize_wrong);
+ iSize = ip[0];
+ /* memset(huffWeight, 0, hwSize); *//* is not necessary, even though some analyzer complain ... */
+
+ if (iSize >= 128) { /* special header */
+ oSize = iSize - 127;
+ iSize = ((oSize+1)/2);
+ if (iSize+1 > srcSize) return ERROR(srcSize_wrong);
+ if (oSize >= hwSize) return ERROR(corruption_detected);
+ ip += 1;
+ { U32 n;
+ for (n=0; n<oSize; n+=2) {
+ huffWeight[n] = ip[n/2] >> 4;
+ huffWeight[n+1] = ip[n/2] & 15;
+ } } }
+ else { /* header compressed with FSE (normal case) */
+ FSE_DTable fseWorkspace[FSE_DTABLE_SIZE_U32(6)]; /* 6 is max possible tableLog for HUF header (maybe even 5, to be tested) */
+ if (iSize+1 > srcSize) return ERROR(srcSize_wrong);
+ oSize = FSE_decompress_wksp(huffWeight, hwSize-1, ip+1, iSize, fseWorkspace, 6); /* max (hwSize-1) values decoded, as last one is implied */
+ if (FSE_isError(oSize)) return oSize;
+ }
+
+ /* collect weight stats */
+ memset(rankStats, 0, (HUF_TABLELOG_MAX + 1) * sizeof(U32));
+ weightTotal = 0;
+ { U32 n; for (n=0; n<oSize; n++) {
+ if (huffWeight[n] >= HUF_TABLELOG_MAX) return ERROR(corruption_detected);
+ rankStats[huffWeight[n]]++;
+ weightTotal += (1 << huffWeight[n]) >> 1;
+ } }
+ if (weightTotal == 0) return ERROR(corruption_detected);
+
+ /* get last non-null symbol weight (implied, total must be 2^n) */
+ { U32 const tableLog = BIT_highbit32(weightTotal) + 1;
+ if (tableLog > HUF_TABLELOG_MAX) return ERROR(corruption_detected);
+ *tableLogPtr = tableLog;
+ /* determine last weight */
+ { U32 const total = 1 << tableLog;
+ U32 const rest = total - weightTotal;
+ U32 const verif = 1 << BIT_highbit32(rest);
+ U32 const lastWeight = BIT_highbit32(rest) + 1;
+ if (verif != rest) return ERROR(corruption_detected); /* last value must be a clean power of 2 */
+ huffWeight[oSize] = (BYTE)lastWeight;
+ rankStats[lastWeight]++;
+ } }
+
+ /* check tree construction validity */
+ if ((rankStats[1] < 2) || (rankStats[1] & 1)) return ERROR(corruption_detected); /* by construction : at least 2 elts of rank 1, must be even */
+
+ /* results */
+ *nbSymbolsPtr = (U32)(oSize+1);
+ return iSize+1;
+}
diff --git a/Utilities/cmzstd/lib/common/error_private.c b/Utilities/cmzstd/lib/common/error_private.c
new file mode 100644
index 000000000..7c1bb67a2
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/error_private.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+/* The purpose of this file is to have a single list of error strings embedded in binary */
+
+#include "error_private.h"
+
+const char* ERR_getErrorString(ERR_enum code)
+{
+#ifdef ZSTD_STRIP_ERROR_STRINGS
+ (void)code;
+ return "Error strings stripped";
+#else
+ static const char* const notErrorCode = "Unspecified error code";
+ switch( code )
+ {
+ case PREFIX(no_error): return "No error detected";
+ case PREFIX(GENERIC): return "Error (generic)";
+ case PREFIX(prefix_unknown): return "Unknown frame descriptor";
+ case PREFIX(version_unsupported): return "Version not supported";
+ case PREFIX(frameParameter_unsupported): return "Unsupported frame parameter";
+ case PREFIX(frameParameter_windowTooLarge): return "Frame requires too much memory for decoding";
+ case PREFIX(corruption_detected): return "Corrupted block detected";
+ case PREFIX(checksum_wrong): return "Restored data doesn't match checksum";
+ case PREFIX(parameter_unsupported): return "Unsupported parameter";
+ case PREFIX(parameter_outOfBound): return "Parameter is out of bound";
+ case PREFIX(init_missing): return "Context should be init first";
+ case PREFIX(memory_allocation): return "Allocation error : not enough memory";
+ case PREFIX(workSpace_tooSmall): return "workSpace buffer is not large enough";
+ case PREFIX(stage_wrong): return "Operation not authorized at current processing stage";
+ case PREFIX(tableLog_tooLarge): return "tableLog requires too much memory : unsupported";
+ case PREFIX(maxSymbolValue_tooLarge): return "Unsupported max Symbol Value : too large";
+ case PREFIX(maxSymbolValue_tooSmall): return "Specified maxSymbolValue is too small";
+ case PREFIX(dictionary_corrupted): return "Dictionary is corrupted";
+ case PREFIX(dictionary_wrong): return "Dictionary mismatch";
+ case PREFIX(dictionaryCreation_failed): return "Cannot create Dictionary from provided samples";
+ case PREFIX(dstSize_tooSmall): return "Destination buffer is too small";
+ case PREFIX(srcSize_wrong): return "Src size is incorrect";
+ case PREFIX(dstBuffer_null): return "Operation on NULL destination buffer";
+ /* following error codes are not stable and may be removed or changed in a future version */
+ case PREFIX(frameIndex_tooLarge): return "Frame index is too large";
+ case PREFIX(seekableIO): return "An I/O error occurred when reading/seeking";
+ case PREFIX(maxCode):
+ default: return notErrorCode;
+ }
+#endif
+}
diff --git a/Utilities/cmzstd/lib/common/error_private.h b/Utilities/cmzstd/lib/common/error_private.h
new file mode 100644
index 000000000..0d2fa7e34
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/error_private.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+/* Note : this module is expected to remain private, do not expose it */
+
+#ifndef ERROR_H_MODULE
+#define ERROR_H_MODULE
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/* ****************************************
+* Dependencies
+******************************************/
+#include <stddef.h> /* size_t */
+#include "zstd_errors.h" /* enum list */
+
+
+/* ****************************************
+* Compiler-specific
+******************************************/
+#if defined(__GNUC__)
+# define ERR_STATIC static __attribute__((unused))
+#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
+# define ERR_STATIC static inline
+#elif defined(_MSC_VER)
+# define ERR_STATIC static __inline
+#else
+# define ERR_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
+#endif
+
+
+/*-****************************************
+* Customization (error_public.h)
+******************************************/
+typedef ZSTD_ErrorCode ERR_enum;
+#define PREFIX(name) ZSTD_error_##name
+
+
+/*-****************************************
+* Error codes handling
+******************************************/
+#undef ERROR /* reported already defined on VS 2015 (Rich Geldreich) */
+#define ERROR(name) ZSTD_ERROR(name)
+#define ZSTD_ERROR(name) ((size_t)-PREFIX(name))
+
+ERR_STATIC unsigned ERR_isError(size_t code) { return (code > ERROR(maxCode)); }
+
+ERR_STATIC ERR_enum ERR_getErrorCode(size_t code) { if (!ERR_isError(code)) return (ERR_enum)0; return (ERR_enum) (0-code); }
+
+
+/*-****************************************
+* Error Strings
+******************************************/
+
+const char* ERR_getErrorString(ERR_enum code); /* error_private.c */
+
+ERR_STATIC const char* ERR_getErrorName(size_t code)
+{
+ return ERR_getErrorString(ERR_getErrorCode(code));
+}
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* ERROR_H_MODULE */
diff --git a/Utilities/cmzstd/lib/common/fse.h b/Utilities/cmzstd/lib/common/fse.h
new file mode 100644
index 000000000..f72c519b2
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/fse.h
@@ -0,0 +1,708 @@
+/* ******************************************************************
+ FSE : Finite State Entropy codec
+ Public Prototypes declaration
+ Copyright (C) 2013-2016, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
+****************************************************************** */
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#ifndef FSE_H
+#define FSE_H
+
+
+/*-*****************************************
+* Dependencies
+******************************************/
+#include <stddef.h> /* size_t, ptrdiff_t */
+
+
+/*-*****************************************
+* FSE_PUBLIC_API : control library symbols visibility
+******************************************/
+#if defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) && defined(__GNUC__) && (__GNUC__ >= 4)
+# define FSE_PUBLIC_API __attribute__ ((visibility ("default")))
+#elif defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) /* Visual expected */
+# define FSE_PUBLIC_API __declspec(dllexport)
+#elif defined(FSE_DLL_IMPORT) && (FSE_DLL_IMPORT==1)
+# define FSE_PUBLIC_API __declspec(dllimport) /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
+#else
+# define FSE_PUBLIC_API
+#endif
+
+/*------ Version ------*/
+#define FSE_VERSION_MAJOR 0
+#define FSE_VERSION_MINOR 9
+#define FSE_VERSION_RELEASE 0
+
+#define FSE_LIB_VERSION FSE_VERSION_MAJOR.FSE_VERSION_MINOR.FSE_VERSION_RELEASE
+#define FSE_QUOTE(str) #str
+#define FSE_EXPAND_AND_QUOTE(str) FSE_QUOTE(str)
+#define FSE_VERSION_STRING FSE_EXPAND_AND_QUOTE(FSE_LIB_VERSION)
+
+#define FSE_VERSION_NUMBER (FSE_VERSION_MAJOR *100*100 + FSE_VERSION_MINOR *100 + FSE_VERSION_RELEASE)
+FSE_PUBLIC_API unsigned FSE_versionNumber(void); /**< library version number; to be used when checking dll version */
+
+
+/*-****************************************
+* FSE simple functions
+******************************************/
+/*! FSE_compress() :
+ Compress content of buffer 'src', of size 'srcSize', into destination buffer 'dst'.
+ 'dst' buffer must be already allocated. Compression runs faster is dstCapacity >= FSE_compressBound(srcSize).
+ @return : size of compressed data (<= dstCapacity).
+ Special values : if return == 0, srcData is not compressible => Nothing is stored within dst !!!
+ if return == 1, srcData is a single byte symbol * srcSize times. Use RLE compression instead.
+ if FSE_isError(return), compression failed (more details using FSE_getErrorName())
+*/
+FSE_PUBLIC_API size_t FSE_compress(void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize);
+
+/*! FSE_decompress():
+ Decompress FSE data from buffer 'cSrc', of size 'cSrcSize',
+ into already allocated destination buffer 'dst', of size 'dstCapacity'.
+ @return : size of regenerated data (<= maxDstSize),
+ or an error code, which can be tested using FSE_isError() .
+
+ ** Important ** : FSE_decompress() does not decompress non-compressible nor RLE data !!!
+ Why ? : making this distinction requires a header.
+ Header management is intentionally delegated to the user layer, which can better manage special cases.
+*/
+FSE_PUBLIC_API size_t FSE_decompress(void* dst, size_t dstCapacity,
+ const void* cSrc, size_t cSrcSize);
+
+
+/*-*****************************************
+* Tool functions
+******************************************/
+FSE_PUBLIC_API size_t FSE_compressBound(size_t size); /* maximum compressed size */
+
+/* Error Management */
+FSE_PUBLIC_API unsigned FSE_isError(size_t code); /* tells if a return value is an error code */
+FSE_PUBLIC_API const char* FSE_getErrorName(size_t code); /* provides error code string (useful for debugging) */
+
+
+/*-*****************************************
+* FSE advanced functions
+******************************************/
+/*! FSE_compress2() :
+ Same as FSE_compress(), but allows the selection of 'maxSymbolValue' and 'tableLog'
+ Both parameters can be defined as '0' to mean : use default value
+ @return : size of compressed data
+ Special values : if return == 0, srcData is not compressible => Nothing is stored within cSrc !!!
+ if return == 1, srcData is a single byte symbol * srcSize times. Use RLE compression.
+ if FSE_isError(return), it's an error code.
+*/
+FSE_PUBLIC_API size_t FSE_compress2 (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog);
+
+
+/*-*****************************************
+* FSE detailed API
+******************************************/
+/*!
+FSE_compress() does the following:
+1. count symbol occurrence from source[] into table count[] (see hist.h)
+2. normalize counters so that sum(count[]) == Power_of_2 (2^tableLog)
+3. save normalized counters to memory buffer using writeNCount()
+4. build encoding table 'CTable' from normalized counters
+5. encode the data stream using encoding table 'CTable'
+
+FSE_decompress() does the following:
+1. read normalized counters with readNCount()
+2. build decoding table 'DTable' from normalized counters
+3. decode the data stream using decoding table 'DTable'
+
+The following API allows targeting specific sub-functions for advanced tasks.
+For example, it's possible to compress several blocks using the same 'CTable',
+or to save and provide normalized distribution using external method.
+*/
+
+/* *** COMPRESSION *** */
+
+/*! FSE_optimalTableLog():
+ dynamically downsize 'tableLog' when conditions are met.
+ It saves CPU time, by using smaller tables, while preserving or even improving compression ratio.
+ @return : recommended tableLog (necessarily <= 'maxTableLog') */
+FSE_PUBLIC_API unsigned FSE_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue);
+
+/*! FSE_normalizeCount():
+ normalize counts so that sum(count[]) == Power_of_2 (2^tableLog)
+ 'normalizedCounter' is a table of short, of minimum size (maxSymbolValue+1).
+ @return : tableLog,
+ or an errorCode, which can be tested using FSE_isError() */
+FSE_PUBLIC_API size_t FSE_normalizeCount(short* normalizedCounter, unsigned tableLog,
+ const unsigned* count, size_t srcSize, unsigned maxSymbolValue);
+
+/*! FSE_NCountWriteBound():
+ Provides the maximum possible size of an FSE normalized table, given 'maxSymbolValue' and 'tableLog'.
+ Typically useful for allocation purpose. */
+FSE_PUBLIC_API size_t FSE_NCountWriteBound(unsigned maxSymbolValue, unsigned tableLog);
+
+/*! FSE_writeNCount():
+ Compactly save 'normalizedCounter' into 'buffer'.
+ @return : size of the compressed table,
+ or an errorCode, which can be tested using FSE_isError(). */
+FSE_PUBLIC_API size_t FSE_writeNCount (void* buffer, size_t bufferSize,
+ const short* normalizedCounter,
+ unsigned maxSymbolValue, unsigned tableLog);
+
+/*! Constructor and Destructor of FSE_CTable.
+ Note that FSE_CTable size depends on 'tableLog' and 'maxSymbolValue' */
+typedef unsigned FSE_CTable; /* don't allocate that. It's only meant to be more restrictive than void* */
+FSE_PUBLIC_API FSE_CTable* FSE_createCTable (unsigned maxSymbolValue, unsigned tableLog);
+FSE_PUBLIC_API void FSE_freeCTable (FSE_CTable* ct);
+
+/*! FSE_buildCTable():
+ Builds `ct`, which must be already allocated, using FSE_createCTable().
+ @return : 0, or an errorCode, which can be tested using FSE_isError() */
+FSE_PUBLIC_API size_t FSE_buildCTable(FSE_CTable* ct, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog);
+
+/*! FSE_compress_usingCTable():
+ Compress `src` using `ct` into `dst` which must be already allocated.
+ @return : size of compressed data (<= `dstCapacity`),
+ or 0 if compressed data could not fit into `dst`,
+ or an errorCode, which can be tested using FSE_isError() */
+FSE_PUBLIC_API size_t FSE_compress_usingCTable (void* dst, size_t dstCapacity, const void* src, size_t srcSize, const FSE_CTable* ct);
+
+/*!
+Tutorial :
+----------
+The first step is to count all symbols. FSE_count() does this job very fast.
+Result will be saved into 'count', a table of unsigned int, which must be already allocated, and have 'maxSymbolValuePtr[0]+1' cells.
+'src' is a table of bytes of size 'srcSize'. All values within 'src' MUST be <= maxSymbolValuePtr[0]
+maxSymbolValuePtr[0] will be updated, with its real value (necessarily <= original value)
+FSE_count() will return the number of occurrence of the most frequent symbol.
+This can be used to know if there is a single symbol within 'src', and to quickly evaluate its compressibility.
+If there is an error, the function will return an ErrorCode (which can be tested using FSE_isError()).
+
+The next step is to normalize the frequencies.
+FSE_normalizeCount() will ensure that sum of frequencies is == 2 ^'tableLog'.
+It also guarantees a minimum of 1 to any Symbol with frequency >= 1.
+You can use 'tableLog'==0 to mean "use default tableLog value".
+If you are unsure of which tableLog value to use, you can ask FSE_optimalTableLog(),
+which will provide the optimal valid tableLog given sourceSize, maxSymbolValue, and a user-defined maximum (0 means "default").
+
+The result of FSE_normalizeCount() will be saved into a table,
+called 'normalizedCounter', which is a table of signed short.
+'normalizedCounter' must be already allocated, and have at least 'maxSymbolValue+1' cells.
+The return value is tableLog if everything proceeded as expected.
+It is 0 if there is a single symbol within distribution.
+If there is an error (ex: invalid tableLog value), the function will return an ErrorCode (which can be tested using FSE_isError()).
+
+'normalizedCounter' can be saved in a compact manner to a memory area using FSE_writeNCount().
+'buffer' must be already allocated.
+For guaranteed success, buffer size must be at least FSE_headerBound().
+The result of the function is the number of bytes written into 'buffer'.
+If there is an error, the function will return an ErrorCode (which can be tested using FSE_isError(); ex : buffer size too small).
+
+'normalizedCounter' can then be used to create the compression table 'CTable'.
+The space required by 'CTable' must be already allocated, using FSE_createCTable().
+You can then use FSE_buildCTable() to fill 'CTable'.
+If there is an error, both functions will return an ErrorCode (which can be tested using FSE_isError()).
+
+'CTable' can then be used to compress 'src', with FSE_compress_usingCTable().
+Similar to FSE_count(), the convention is that 'src' is assumed to be a table of char of size 'srcSize'
+The function returns the size of compressed data (without header), necessarily <= `dstCapacity`.
+If it returns '0', compressed data could not fit into 'dst'.
+If there is an error, the function will return an ErrorCode (which can be tested using FSE_isError()).
+*/
+
+
+/* *** DECOMPRESSION *** */
+
+/*! FSE_readNCount():
+ Read compactly saved 'normalizedCounter' from 'rBuffer'.
+ @return : size read from 'rBuffer',
+ or an errorCode, which can be tested using FSE_isError().
+ maxSymbolValuePtr[0] and tableLogPtr[0] will also be updated with their respective values */
+FSE_PUBLIC_API size_t FSE_readNCount (short* normalizedCounter,
+ unsigned* maxSymbolValuePtr, unsigned* tableLogPtr,
+ const void* rBuffer, size_t rBuffSize);
+
+/*! Constructor and Destructor of FSE_DTable.
+ Note that its size depends on 'tableLog' */
+typedef unsigned FSE_DTable; /* don't allocate that. It's just a way to be more restrictive than void* */
+FSE_PUBLIC_API FSE_DTable* FSE_createDTable(unsigned tableLog);
+FSE_PUBLIC_API void FSE_freeDTable(FSE_DTable* dt);
+
+/*! FSE_buildDTable():
+ Builds 'dt', which must be already allocated, using FSE_createDTable().
+ return : 0, or an errorCode, which can be tested using FSE_isError() */
+FSE_PUBLIC_API size_t FSE_buildDTable (FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog);
+
+/*! FSE_decompress_usingDTable():
+ Decompress compressed source `cSrc` of size `cSrcSize` using `dt`
+ into `dst` which must be already allocated.
+ @return : size of regenerated data (necessarily <= `dstCapacity`),
+ or an errorCode, which can be tested using FSE_isError() */
+FSE_PUBLIC_API size_t FSE_decompress_usingDTable(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, const FSE_DTable* dt);
+
+/*!
+Tutorial :
+----------
+(Note : these functions only decompress FSE-compressed blocks.
+ If block is uncompressed, use memcpy() instead
+ If block is a single repeated byte, use memset() instead )
+
+The first step is to obtain the normalized frequencies of symbols.
+This can be performed by FSE_readNCount() if it was saved using FSE_writeNCount().
+'normalizedCounter' must be already allocated, and have at least 'maxSymbolValuePtr[0]+1' cells of signed short.
+In practice, that means it's necessary to know 'maxSymbolValue' beforehand,
+or size the table to handle worst case situations (typically 256).
+FSE_readNCount() will provide 'tableLog' and 'maxSymbolValue'.
+The result of FSE_readNCount() is the number of bytes read from 'rBuffer'.
+Note that 'rBufferSize' must be at least 4 bytes, even if useful information is less than that.
+If there is an error, the function will return an error code, which can be tested using FSE_isError().
+
+The next step is to build the decompression tables 'FSE_DTable' from 'normalizedCounter'.
+This is performed by the function FSE_buildDTable().
+The space required by 'FSE_DTable' must be already allocated using FSE_createDTable().
+If there is an error, the function will return an error code, which can be tested using FSE_isError().
+
+`FSE_DTable` can then be used to decompress `cSrc`, with FSE_decompress_usingDTable().
+`cSrcSize` must be strictly correct, otherwise decompression will fail.
+FSE_decompress_usingDTable() result will tell how many bytes were regenerated (<=`dstCapacity`).
+If there is an error, the function will return an error code, which can be tested using FSE_isError(). (ex: dst buffer too small)
+*/
+
+#endif /* FSE_H */
+
+#if defined(FSE_STATIC_LINKING_ONLY) && !defined(FSE_H_FSE_STATIC_LINKING_ONLY)
+#define FSE_H_FSE_STATIC_LINKING_ONLY
+
+/* *** Dependency *** */
+#include "bitstream.h"
+
+
+/* *****************************************
+* Static allocation
+*******************************************/
+/* FSE buffer bounds */
+#define FSE_NCOUNTBOUND 512
+#define FSE_BLOCKBOUND(size) (size + (size>>7))
+#define FSE_COMPRESSBOUND(size) (FSE_NCOUNTBOUND + FSE_BLOCKBOUND(size)) /* Macro version, useful for static allocation */
+
+/* It is possible to statically allocate FSE CTable/DTable as a table of FSE_CTable/FSE_DTable using below macros */
+#define FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue) (1 + (1<<(maxTableLog-1)) + ((maxSymbolValue+1)*2))
+#define FSE_DTABLE_SIZE_U32(maxTableLog) (1 + (1<<maxTableLog))
+
+/* or use the size to malloc() space directly. Pay attention to alignment restrictions though */
+#define FSE_CTABLE_SIZE(maxTableLog, maxSymbolValue) (FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue) * sizeof(FSE_CTable))
+#define FSE_DTABLE_SIZE(maxTableLog) (FSE_DTABLE_SIZE_U32(maxTableLog) * sizeof(FSE_DTable))
+
+
+/* *****************************************
+ * FSE advanced API
+ ***************************************** */
+
+unsigned FSE_optimalTableLog_internal(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue, unsigned minus);
+/**< same as FSE_optimalTableLog(), which used `minus==2` */
+
+/* FSE_compress_wksp() :
+ * Same as FSE_compress2(), but using an externally allocated scratch buffer (`workSpace`).
+ * FSE_WKSP_SIZE_U32() provides the minimum size required for `workSpace` as a table of FSE_CTable.
+ */
+#define FSE_WKSP_SIZE_U32(maxTableLog, maxSymbolValue) ( FSE_CTABLE_SIZE_U32(maxTableLog, maxSymbolValue) + ((maxTableLog > 12) ? (1 << (maxTableLog - 2)) : 1024) )
+size_t FSE_compress_wksp (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize);
+
+size_t FSE_buildCTable_raw (FSE_CTable* ct, unsigned nbBits);
+/**< build a fake FSE_CTable, designed for a flat distribution, where each symbol uses nbBits */
+
+size_t FSE_buildCTable_rle (FSE_CTable* ct, unsigned char symbolValue);
+/**< build a fake FSE_CTable, designed to compress always the same symbolValue */
+
+/* FSE_buildCTable_wksp() :
+ * Same as FSE_buildCTable(), but using an externally allocated scratch buffer (`workSpace`).
+ * `wkspSize` must be >= `(1<<tableLog)`.
+ */
+size_t FSE_buildCTable_wksp(FSE_CTable* ct, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize);
+
+size_t FSE_buildDTable_raw (FSE_DTable* dt, unsigned nbBits);
+/**< build a fake FSE_DTable, designed to read a flat distribution where each symbol uses nbBits */
+
+size_t FSE_buildDTable_rle (FSE_DTable* dt, unsigned char symbolValue);
+/**< build a fake FSE_DTable, designed to always generate the same symbolValue */
+
+size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, FSE_DTable* workSpace, unsigned maxLog);
+/**< same as FSE_decompress(), using an externally allocated `workSpace` produced with `FSE_DTABLE_SIZE_U32(maxLog)` */
+
+typedef enum {
+ FSE_repeat_none, /**< Cannot use the previous table */
+ FSE_repeat_check, /**< Can use the previous table but it must be checked */
+ FSE_repeat_valid /**< Can use the previous table and it is asumed to be valid */
+ } FSE_repeat;
+
+/* *****************************************
+* FSE symbol compression API
+*******************************************/
+/*!
+ This API consists of small unitary functions, which highly benefit from being inlined.
+ Hence their body are included in next section.
+*/
+typedef struct {
+ ptrdiff_t value;
+ const void* stateTable;
+ const void* symbolTT;
+ unsigned stateLog;
+} FSE_CState_t;
+
+static void FSE_initCState(FSE_CState_t* CStatePtr, const FSE_CTable* ct);
+
+static void FSE_encodeSymbol(BIT_CStream_t* bitC, FSE_CState_t* CStatePtr, unsigned symbol);
+
+static void FSE_flushCState(BIT_CStream_t* bitC, const FSE_CState_t* CStatePtr);
+
+/**<
+These functions are inner components of FSE_compress_usingCTable().
+They allow the creation of custom streams, mixing multiple tables and bit sources.
+
+A key property to keep in mind is that encoding and decoding are done **in reverse direction**.
+So the first symbol you will encode is the last you will decode, like a LIFO stack.
+
+You will need a few variables to track your CStream. They are :
+
+FSE_CTable ct; // Provided by FSE_buildCTable()
+BIT_CStream_t bitStream; // bitStream tracking structure
+FSE_CState_t state; // State tracking structure (can have several)
+
+
+The first thing to do is to init bitStream and state.
+ size_t errorCode = BIT_initCStream(&bitStream, dstBuffer, maxDstSize);
+ FSE_initCState(&state, ct);
+
+Note that BIT_initCStream() can produce an error code, so its result should be tested, using FSE_isError();
+You can then encode your input data, byte after byte.
+FSE_encodeSymbol() outputs a maximum of 'tableLog' bits at a time.
+Remember decoding will be done in reverse direction.
+ FSE_encodeByte(&bitStream, &state, symbol);
+
+At any time, you can also add any bit sequence.
+Note : maximum allowed nbBits is 25, for compatibility with 32-bits decoders
+ BIT_addBits(&bitStream, bitField, nbBits);
+
+The above methods don't commit data to memory, they just store it into local register, for speed.
+Local register size is 64-bits on 64-bits systems, 32-bits on 32-bits systems (size_t).
+Writing data to memory is a manual operation, performed by the flushBits function.
+ BIT_flushBits(&bitStream);
+
+Your last FSE encoding operation shall be to flush your last state value(s).
+ FSE_flushState(&bitStream, &state);
+
+Finally, you must close the bitStream.
+The function returns the size of CStream in bytes.
+If data couldn't fit into dstBuffer, it will return a 0 ( == not compressible)
+If there is an error, it returns an errorCode (which can be tested using FSE_isError()).
+ size_t size = BIT_closeCStream(&bitStream);
+*/
+
+
+/* *****************************************
+* FSE symbol decompression API
+*******************************************/
+typedef struct {
+ size_t state;
+ const void* table; /* precise table may vary, depending on U16 */
+} FSE_DState_t;
+
+
+static void FSE_initDState(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD, const FSE_DTable* dt);
+
+static unsigned char FSE_decodeSymbol(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD);
+
+static unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr);
+
+/**<
+Let's now decompose FSE_decompress_usingDTable() into its unitary components.
+You will decode FSE-encoded symbols from the bitStream,
+and also any other bitFields you put in, **in reverse order**.
+
+You will need a few variables to track your bitStream. They are :
+
+BIT_DStream_t DStream; // Stream context
+FSE_DState_t DState; // State context. Multiple ones are possible
+FSE_DTable* DTablePtr; // Decoding table, provided by FSE_buildDTable()
+
+The first thing to do is to init the bitStream.
+ errorCode = BIT_initDStream(&DStream, srcBuffer, srcSize);
+
+You should then retrieve your initial state(s)
+(in reverse flushing order if you have several ones) :
+ errorCode = FSE_initDState(&DState, &DStream, DTablePtr);
+
+You can then decode your data, symbol after symbol.
+For information the maximum number of bits read by FSE_decodeSymbol() is 'tableLog'.
+Keep in mind that symbols are decoded in reverse order, like a LIFO stack (last in, first out).
+ unsigned char symbol = FSE_decodeSymbol(&DState, &DStream);
+
+You can retrieve any bitfield you eventually stored into the bitStream (in reverse order)
+Note : maximum allowed nbBits is 25, for 32-bits compatibility
+ size_t bitField = BIT_readBits(&DStream, nbBits);
+
+All above operations only read from local register (which size depends on size_t).
+Refueling the register from memory is manually performed by the reload method.
+ endSignal = FSE_reloadDStream(&DStream);
+
+BIT_reloadDStream() result tells if there is still some more data to read from DStream.
+BIT_DStream_unfinished : there is still some data left into the DStream.
+BIT_DStream_endOfBuffer : Dstream reached end of buffer. Its container may no longer be completely filled.
+BIT_DStream_completed : Dstream reached its exact end, corresponding in general to decompression completed.
+BIT_DStream_tooFar : Dstream went too far. Decompression result is corrupted.
+
+When reaching end of buffer (BIT_DStream_endOfBuffer), progress slowly, notably if you decode multiple symbols per loop,
+to properly detect the exact end of stream.
+After each decoded symbol, check if DStream is fully consumed using this simple test :
+ BIT_reloadDStream(&DStream) >= BIT_DStream_completed
+
+When it's done, verify decompression is fully completed, by checking both DStream and the relevant states.
+Checking if DStream has reached its end is performed by :
+ BIT_endOfDStream(&DStream);
+Check also the states. There might be some symbols left there, if some high probability ones (>50%) are possible.
+ FSE_endOfDState(&DState);
+*/
+
+
+/* *****************************************
+* FSE unsafe API
+*******************************************/
+static unsigned char FSE_decodeSymbolFast(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD);
+/* faster, but works only if nbBits is always >= 1 (otherwise, result will be corrupted) */
+
+
+/* *****************************************
+* Implementation of inlined functions
+*******************************************/
+typedef struct {
+ int deltaFindState;
+ U32 deltaNbBits;
+} FSE_symbolCompressionTransform; /* total 8 bytes */
+
+MEM_STATIC void FSE_initCState(FSE_CState_t* statePtr, const FSE_CTable* ct)
+{
+ const void* ptr = ct;
+ const U16* u16ptr = (const U16*) ptr;
+ const U32 tableLog = MEM_read16(ptr);
+ statePtr->value = (ptrdiff_t)1<<tableLog;
+ statePtr->stateTable = u16ptr+2;
+ statePtr->symbolTT = ct + 1 + (tableLog ? (1<<(tableLog-1)) : 1);
+ statePtr->stateLog = tableLog;
+}
+
+
+/*! FSE_initCState2() :
+* Same as FSE_initCState(), but the first symbol to include (which will be the last to be read)
+* uses the smallest state value possible, saving the cost of this symbol */
+MEM_STATIC void FSE_initCState2(FSE_CState_t* statePtr, const FSE_CTable* ct, U32 symbol)
+{
+ FSE_initCState(statePtr, ct);
+ { const FSE_symbolCompressionTransform symbolTT = ((const FSE_symbolCompressionTransform*)(statePtr->symbolTT))[symbol];
+ const U16* stateTable = (const U16*)(statePtr->stateTable);
+ U32 nbBitsOut = (U32)((symbolTT.deltaNbBits + (1<<15)) >> 16);
+ statePtr->value = (nbBitsOut << 16) - symbolTT.deltaNbBits;
+ statePtr->value = stateTable[(statePtr->value >> nbBitsOut) + symbolTT.deltaFindState];
+ }
+}
+
+MEM_STATIC void FSE_encodeSymbol(BIT_CStream_t* bitC, FSE_CState_t* statePtr, unsigned symbol)
+{
+ FSE_symbolCompressionTransform const symbolTT = ((const FSE_symbolCompressionTransform*)(statePtr->symbolTT))[symbol];
+ const U16* const stateTable = (const U16*)(statePtr->stateTable);
+ U32 const nbBitsOut = (U32)((statePtr->value + symbolTT.deltaNbBits) >> 16);
+ BIT_addBits(bitC, statePtr->value, nbBitsOut);
+ statePtr->value = stateTable[ (statePtr->value >> nbBitsOut) + symbolTT.deltaFindState];
+}
+
+MEM_STATIC void FSE_flushCState(BIT_CStream_t* bitC, const FSE_CState_t* statePtr)
+{
+ BIT_addBits(bitC, statePtr->value, statePtr->stateLog);
+ BIT_flushBits(bitC);
+}
+
+
+/* FSE_getMaxNbBits() :
+ * Approximate maximum cost of a symbol, in bits.
+ * Fractional get rounded up (i.e : a symbol with a normalized frequency of 3 gives the same result as a frequency of 2)
+ * note 1 : assume symbolValue is valid (<= maxSymbolValue)
+ * note 2 : if freq[symbolValue]==0, @return a fake cost of tableLog+1 bits */
+MEM_STATIC U32 FSE_getMaxNbBits(const void* symbolTTPtr, U32 symbolValue)
+{
+ const FSE_symbolCompressionTransform* symbolTT = (const FSE_symbolCompressionTransform*) symbolTTPtr;
+ return (symbolTT[symbolValue].deltaNbBits + ((1<<16)-1)) >> 16;
+}
+
+/* FSE_bitCost() :
+ * Approximate symbol cost, as fractional value, using fixed-point format (accuracyLog fractional bits)
+ * note 1 : assume symbolValue is valid (<= maxSymbolValue)
+ * note 2 : if freq[symbolValue]==0, @return a fake cost of tableLog+1 bits */
+MEM_STATIC U32 FSE_bitCost(const void* symbolTTPtr, U32 tableLog, U32 symbolValue, U32 accuracyLog)
+{
+ const FSE_symbolCompressionTransform* symbolTT = (const FSE_symbolCompressionTransform*) symbolTTPtr;
+ U32 const minNbBits = symbolTT[symbolValue].deltaNbBits >> 16;
+ U32 const threshold = (minNbBits+1) << 16;
+ assert(tableLog < 16);
+ assert(accuracyLog < 31-tableLog); /* ensure enough room for renormalization double shift */
+ { U32 const tableSize = 1 << tableLog;
+ U32 const deltaFromThreshold = threshold - (symbolTT[symbolValue].deltaNbBits + tableSize);
+ U32 const normalizedDeltaFromThreshold = (deltaFromThreshold << accuracyLog) >> tableLog; /* linear interpolation (very approximate) */
+ U32 const bitMultiplier = 1 << accuracyLog;
+ assert(symbolTT[symbolValue].deltaNbBits + tableSize <= threshold);
+ assert(normalizedDeltaFromThreshold <= bitMultiplier);
+ return (minNbBits+1)*bitMultiplier - normalizedDeltaFromThreshold;
+ }
+}
+
+
+/* ====== Decompression ====== */
+
+typedef struct {
+ U16 tableLog;
+ U16 fastMode;
+} FSE_DTableHeader; /* sizeof U32 */
+
+typedef struct
+{
+ unsigned short newState;
+ unsigned char symbol;
+ unsigned char nbBits;
+} FSE_decode_t; /* size == U32 */
+
+MEM_STATIC void FSE_initDState(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD, const FSE_DTable* dt)
+{
+ const void* ptr = dt;
+ const FSE_DTableHeader* const DTableH = (const FSE_DTableHeader*)ptr;
+ DStatePtr->state = BIT_readBits(bitD, DTableH->tableLog);
+ BIT_reloadDStream(bitD);
+ DStatePtr->table = dt + 1;
+}
+
+MEM_STATIC BYTE FSE_peekSymbol(const FSE_DState_t* DStatePtr)
+{
+ FSE_decode_t const DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state];
+ return DInfo.symbol;
+}
+
+MEM_STATIC void FSE_updateState(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD)
+{
+ FSE_decode_t const DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state];
+ U32 const nbBits = DInfo.nbBits;
+ size_t const lowBits = BIT_readBits(bitD, nbBits);
+ DStatePtr->state = DInfo.newState + lowBits;
+}
+
+MEM_STATIC BYTE FSE_decodeSymbol(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD)
+{
+ FSE_decode_t const DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state];
+ U32 const nbBits = DInfo.nbBits;
+ BYTE const symbol = DInfo.symbol;
+ size_t const lowBits = BIT_readBits(bitD, nbBits);
+
+ DStatePtr->state = DInfo.newState + lowBits;
+ return symbol;
+}
+
+/*! FSE_decodeSymbolFast() :
+ unsafe, only works if no symbol has a probability > 50% */
+MEM_STATIC BYTE FSE_decodeSymbolFast(FSE_DState_t* DStatePtr, BIT_DStream_t* bitD)
+{
+ FSE_decode_t const DInfo = ((const FSE_decode_t*)(DStatePtr->table))[DStatePtr->state];
+ U32 const nbBits = DInfo.nbBits;
+ BYTE const symbol = DInfo.symbol;
+ size_t const lowBits = BIT_readBitsFast(bitD, nbBits);
+
+ DStatePtr->state = DInfo.newState + lowBits;
+ return symbol;
+}
+
+MEM_STATIC unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr)
+{
+ return DStatePtr->state == 0;
+}
+
+
+
+#ifndef FSE_COMMONDEFS_ONLY
+
+/* **************************************************************
+* Tuning parameters
+****************************************************************/
+/*!MEMORY_USAGE :
+* Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.)
+* Increasing memory usage improves compression ratio
+* Reduced memory usage can improve speed, due to cache effect
+* Recommended max value is 14, for 16KB, which nicely fits into Intel x86 L1 cache */
+#ifndef FSE_MAX_MEMORY_USAGE
+# define FSE_MAX_MEMORY_USAGE 14
+#endif
+#ifndef FSE_DEFAULT_MEMORY_USAGE
+# define FSE_DEFAULT_MEMORY_USAGE 13
+#endif
+
+/*!FSE_MAX_SYMBOL_VALUE :
+* Maximum symbol value authorized.
+* Required for proper stack allocation */
+#ifndef FSE_MAX_SYMBOL_VALUE
+# define FSE_MAX_SYMBOL_VALUE 255
+#endif
+
+/* **************************************************************
+* template functions type & suffix
+****************************************************************/
+#define FSE_FUNCTION_TYPE BYTE
+#define FSE_FUNCTION_EXTENSION
+#define FSE_DECODE_TYPE FSE_decode_t
+
+
+#endif /* !FSE_COMMONDEFS_ONLY */
+
+
+/* ***************************************************************
+* Constants
+*****************************************************************/
+#define FSE_MAX_TABLELOG (FSE_MAX_MEMORY_USAGE-2)
+#define FSE_MAX_TABLESIZE (1U<<FSE_MAX_TABLELOG)
+#define FSE_MAXTABLESIZE_MASK (FSE_MAX_TABLESIZE-1)
+#define FSE_DEFAULT_TABLELOG (FSE_DEFAULT_MEMORY_USAGE-2)
+#define FSE_MIN_TABLELOG 5
+
+#define FSE_TABLELOG_ABSOLUTE_MAX 15
+#if FSE_MAX_TABLELOG > FSE_TABLELOG_ABSOLUTE_MAX
+# error "FSE_MAX_TABLELOG > FSE_TABLELOG_ABSOLUTE_MAX is not supported"
+#endif
+
+#define FSE_TABLESTEP(tableSize) ((tableSize>>1) + (tableSize>>3) + 3)
+
+
+#endif /* FSE_STATIC_LINKING_ONLY */
+
+
+#if defined (__cplusplus)
+}
+#endif
diff --git a/Utilities/cmzstd/lib/common/fse_decompress.c b/Utilities/cmzstd/lib/common/fse_decompress.c
new file mode 100644
index 000000000..72bbead5b
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/fse_decompress.c
@@ -0,0 +1,309 @@
+/* ******************************************************************
+ FSE : Finite State Entropy decoder
+ Copyright (C) 2013-2015, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
+ - Public forum : https://groups.google.com/forum/#!forum/lz4c
+****************************************************************** */
+
+
+/* **************************************************************
+* Includes
+****************************************************************/
+#include <stdlib.h> /* malloc, free, qsort */
+#include <string.h> /* memcpy, memset */
+#include "bitstream.h"
+#include "compiler.h"
+#define FSE_STATIC_LINKING_ONLY
+#include "fse.h"
+#include "error_private.h"
+
+
+/* **************************************************************
+* Error Management
+****************************************************************/
+#define FSE_isError ERR_isError
+#define FSE_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c) /* use only *after* variable declarations */
+
+/* check and forward error code */
+#define CHECK_F(f) { size_t const e = f; if (FSE_isError(e)) return e; }
+
+
+/* **************************************************************
+* Templates
+****************************************************************/
+/*
+ designed to be included
+ for type-specific functions (template emulation in C)
+ Objective is to write these functions only once, for improved maintenance
+*/
+
+/* safety checks */
+#ifndef FSE_FUNCTION_EXTENSION
+# error "FSE_FUNCTION_EXTENSION must be defined"
+#endif
+#ifndef FSE_FUNCTION_TYPE
+# error "FSE_FUNCTION_TYPE must be defined"
+#endif
+
+/* Function names */
+#define FSE_CAT(X,Y) X##Y
+#define FSE_FUNCTION_NAME(X,Y) FSE_CAT(X,Y)
+#define FSE_TYPE_NAME(X,Y) FSE_CAT(X,Y)
+
+
+/* Function templates */
+FSE_DTable* FSE_createDTable (unsigned tableLog)
+{
+ if (tableLog > FSE_TABLELOG_ABSOLUTE_MAX) tableLog = FSE_TABLELOG_ABSOLUTE_MAX;
+ return (FSE_DTable*)malloc( FSE_DTABLE_SIZE_U32(tableLog) * sizeof (U32) );
+}
+
+void FSE_freeDTable (FSE_DTable* dt)
+{
+ free(dt);
+}
+
+size_t FSE_buildDTable(FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog)
+{
+ void* const tdPtr = dt+1; /* because *dt is unsigned, 32-bits aligned on 32-bits */
+ FSE_DECODE_TYPE* const tableDecode = (FSE_DECODE_TYPE*) (tdPtr);
+ U16 symbolNext[FSE_MAX_SYMBOL_VALUE+1];
+
+ U32 const maxSV1 = maxSymbolValue + 1;
+ U32 const tableSize = 1 << tableLog;
+ U32 highThreshold = tableSize-1;
+
+ /* Sanity Checks */
+ if (maxSymbolValue > FSE_MAX_SYMBOL_VALUE) return ERROR(maxSymbolValue_tooLarge);
+ if (tableLog > FSE_MAX_TABLELOG) return ERROR(tableLog_tooLarge);
+
+ /* Init, lay down lowprob symbols */
+ { FSE_DTableHeader DTableH;
+ DTableH.tableLog = (U16)tableLog;
+ DTableH.fastMode = 1;
+ { S16 const largeLimit= (S16)(1 << (tableLog-1));
+ U32 s;
+ for (s=0; s<maxSV1; s++) {
+ if (normalizedCounter[s]==-1) {
+ tableDecode[highThreshold--].symbol = (FSE_FUNCTION_TYPE)s;
+ symbolNext[s] = 1;
+ } else {
+ if (normalizedCounter[s] >= largeLimit) DTableH.fastMode=0;
+ symbolNext[s] = normalizedCounter[s];
+ } } }
+ memcpy(dt, &DTableH, sizeof(DTableH));
+ }
+
+ /* Spread symbols */
+ { U32 const tableMask = tableSize-1;
+ U32 const step = FSE_TABLESTEP(tableSize);
+ U32 s, position = 0;
+ for (s=0; s<maxSV1; s++) {
+ int i;
+ for (i=0; i<normalizedCounter[s]; i++) {
+ tableDecode[position].symbol = (FSE_FUNCTION_TYPE)s;
+ position = (position + step) & tableMask;
+ while (position > highThreshold) position = (position + step) & tableMask; /* lowprob area */
+ } }
+ if (position!=0) return ERROR(GENERIC); /* position must reach all cells once, otherwise normalizedCounter is incorrect */
+ }
+
+ /* Build Decoding table */
+ { U32 u;
+ for (u=0; u<tableSize; u++) {
+ FSE_FUNCTION_TYPE const symbol = (FSE_FUNCTION_TYPE)(tableDecode[u].symbol);
+ U32 const nextState = symbolNext[symbol]++;
+ tableDecode[u].nbBits = (BYTE) (tableLog - BIT_highbit32(nextState) );
+ tableDecode[u].newState = (U16) ( (nextState << tableDecode[u].nbBits) - tableSize);
+ } }
+
+ return 0;
+}
+
+
+#ifndef FSE_COMMONDEFS_ONLY
+
+/*-*******************************************************
+* Decompression (Byte symbols)
+*********************************************************/
+size_t FSE_buildDTable_rle (FSE_DTable* dt, BYTE symbolValue)
+{
+ void* ptr = dt;
+ FSE_DTableHeader* const DTableH = (FSE_DTableHeader*)ptr;
+ void* dPtr = dt + 1;
+ FSE_decode_t* const cell = (FSE_decode_t*)dPtr;
+
+ DTableH->tableLog = 0;
+ DTableH->fastMode = 0;
+
+ cell->newState = 0;
+ cell->symbol = symbolValue;
+ cell->nbBits = 0;
+
+ return 0;
+}
+
+
+size_t FSE_buildDTable_raw (FSE_DTable* dt, unsigned nbBits)
+{
+ void* ptr = dt;
+ FSE_DTableHeader* const DTableH = (FSE_DTableHeader*)ptr;
+ void* dPtr = dt + 1;
+ FSE_decode_t* const dinfo = (FSE_decode_t*)dPtr;
+ const unsigned tableSize = 1 << nbBits;
+ const unsigned tableMask = tableSize - 1;
+ const unsigned maxSV1 = tableMask+1;
+ unsigned s;
+
+ /* Sanity checks */
+ if (nbBits < 1) return ERROR(GENERIC); /* min size */
+
+ /* Build Decoding Table */
+ DTableH->tableLog = (U16)nbBits;
+ DTableH->fastMode = 1;
+ for (s=0; s<maxSV1; s++) {
+ dinfo[s].newState = 0;
+ dinfo[s].symbol = (BYTE)s;
+ dinfo[s].nbBits = (BYTE)nbBits;
+ }
+
+ return 0;
+}
+
+FORCE_INLINE_TEMPLATE size_t FSE_decompress_usingDTable_generic(
+ void* dst, size_t maxDstSize,
+ const void* cSrc, size_t cSrcSize,
+ const FSE_DTable* dt, const unsigned fast)
+{
+ BYTE* const ostart = (BYTE*) dst;
+ BYTE* op = ostart;
+ BYTE* const omax = op + maxDstSize;
+ BYTE* const olimit = omax-3;
+
+ BIT_DStream_t bitD;
+ FSE_DState_t state1;
+ FSE_DState_t state2;
+
+ /* Init */
+ CHECK_F(BIT_initDStream(&bitD, cSrc, cSrcSize));
+
+ FSE_initDState(&state1, &bitD, dt);
+ FSE_initDState(&state2, &bitD, dt);
+
+#define FSE_GETSYMBOL(statePtr) fast ? FSE_decodeSymbolFast(statePtr, &bitD) : FSE_decodeSymbol(statePtr, &bitD)
+
+ /* 4 symbols per loop */
+ for ( ; (BIT_reloadDStream(&bitD)==BIT_DStream_unfinished) & (op<olimit) ; op+=4) {
+ op[0] = FSE_GETSYMBOL(&state1);
+
+ if (FSE_MAX_TABLELOG*2+7 > sizeof(bitD.bitContainer)*8) /* This test must be static */
+ BIT_reloadDStream(&bitD);
+
+ op[1] = FSE_GETSYMBOL(&state2);
+
+ if (FSE_MAX_TABLELOG*4+7 > sizeof(bitD.bitContainer)*8) /* This test must be static */
+ { if (BIT_reloadDStream(&bitD) > BIT_DStream_unfinished) { op+=2; break; } }
+
+ op[2] = FSE_GETSYMBOL(&state1);
+
+ if (FSE_MAX_TABLELOG*2+7 > sizeof(bitD.bitContainer)*8) /* This test must be static */
+ BIT_reloadDStream(&bitD);
+
+ op[3] = FSE_GETSYMBOL(&state2);
+ }
+
+ /* tail */
+ /* note : BIT_reloadDStream(&bitD) >= FSE_DStream_partiallyFilled; Ends at exactly BIT_DStream_completed */
+ while (1) {
+ if (op>(omax-2)) return ERROR(dstSize_tooSmall);
+ *op++ = FSE_GETSYMBOL(&state1);
+ if (BIT_reloadDStream(&bitD)==BIT_DStream_overflow) {
+ *op++ = FSE_GETSYMBOL(&state2);
+ break;
+ }
+
+ if (op>(omax-2)) return ERROR(dstSize_tooSmall);
+ *op++ = FSE_GETSYMBOL(&state2);
+ if (BIT_reloadDStream(&bitD)==BIT_DStream_overflow) {
+ *op++ = FSE_GETSYMBOL(&state1);
+ break;
+ } }
+
+ return op-ostart;
+}
+
+
+size_t FSE_decompress_usingDTable(void* dst, size_t originalSize,
+ const void* cSrc, size_t cSrcSize,
+ const FSE_DTable* dt)
+{
+ const void* ptr = dt;
+ const FSE_DTableHeader* DTableH = (const FSE_DTableHeader*)ptr;
+ const U32 fastMode = DTableH->fastMode;
+
+ /* select fast mode (static) */
+ if (fastMode) return FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 1);
+ return FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 0);
+}
+
+
+size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, FSE_DTable* workSpace, unsigned maxLog)
+{
+ const BYTE* const istart = (const BYTE*)cSrc;
+ const BYTE* ip = istart;
+ short counting[FSE_MAX_SYMBOL_VALUE+1];
+ unsigned tableLog;
+ unsigned maxSymbolValue = FSE_MAX_SYMBOL_VALUE;
+
+ /* normal FSE decoding mode */
+ size_t const NCountLength = FSE_readNCount (counting, &maxSymbolValue, &tableLog, istart, cSrcSize);
+ if (FSE_isError(NCountLength)) return NCountLength;
+ //if (NCountLength >= cSrcSize) return ERROR(srcSize_wrong); /* too small input size; supposed to be already checked in NCountLength, only remaining case : NCountLength==cSrcSize */
+ if (tableLog > maxLog) return ERROR(tableLog_tooLarge);
+ ip += NCountLength;
+ cSrcSize -= NCountLength;
+
+ CHECK_F( FSE_buildDTable (workSpace, counting, maxSymbolValue, tableLog) );
+
+ return FSE_decompress_usingDTable (dst, dstCapacity, ip, cSrcSize, workSpace); /* always return, even if it is an error code */
+}
+
+
+typedef FSE_DTable DTable_max_t[FSE_DTABLE_SIZE_U32(FSE_MAX_TABLELOG)];
+
+size_t FSE_decompress(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize)
+{
+ DTable_max_t dt; /* Static analyzer seems unable to understand this table will be properly initialized later */
+ return FSE_decompress_wksp(dst, dstCapacity, cSrc, cSrcSize, dt, FSE_MAX_TABLELOG);
+}
+
+
+
+#endif /* FSE_COMMONDEFS_ONLY */
diff --git a/Utilities/cmzstd/lib/common/huf.h b/Utilities/cmzstd/lib/common/huf.h
new file mode 100644
index 000000000..6b572c448
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/huf.h
@@ -0,0 +1,358 @@
+/* ******************************************************************
+ huff0 huffman codec,
+ part of Finite State Entropy library
+ Copyright (C) 2013-present, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - Source repository : https://github.com/Cyan4973/FiniteStateEntropy
+****************************************************************** */
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#ifndef HUF_H_298734234
+#define HUF_H_298734234
+
+/* *** Dependencies *** */
+#include <stddef.h> /* size_t */
+
+
+/* *** library symbols visibility *** */
+/* Note : when linking with -fvisibility=hidden on gcc, or by default on Visual,
+ * HUF symbols remain "private" (internal symbols for library only).
+ * Set macro FSE_DLL_EXPORT to 1 if you want HUF symbols visible on DLL interface */
+#if defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) && defined(__GNUC__) && (__GNUC__ >= 4)
+# define HUF_PUBLIC_API __attribute__ ((visibility ("default")))
+#elif defined(FSE_DLL_EXPORT) && (FSE_DLL_EXPORT==1) /* Visual expected */
+# define HUF_PUBLIC_API __declspec(dllexport)
+#elif defined(FSE_DLL_IMPORT) && (FSE_DLL_IMPORT==1)
+# define HUF_PUBLIC_API __declspec(dllimport) /* not required, just to generate faster code (saves a function pointer load from IAT and an indirect jump) */
+#else
+# define HUF_PUBLIC_API
+#endif
+
+
+/* ========================== */
+/* *** simple functions *** */
+/* ========================== */
+
+/** HUF_compress() :
+ * Compress content from buffer 'src', of size 'srcSize', into buffer 'dst'.
+ * 'dst' buffer must be already allocated.
+ * Compression runs faster if `dstCapacity` >= HUF_compressBound(srcSize).
+ * `srcSize` must be <= `HUF_BLOCKSIZE_MAX` == 128 KB.
+ * @return : size of compressed data (<= `dstCapacity`).
+ * Special values : if return == 0, srcData is not compressible => Nothing is stored within dst !!!
+ * if HUF_isError(return), compression failed (more details using HUF_getErrorName())
+ */
+HUF_PUBLIC_API size_t HUF_compress(void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize);
+
+/** HUF_decompress() :
+ * Decompress HUF data from buffer 'cSrc', of size 'cSrcSize',
+ * into already allocated buffer 'dst', of minimum size 'dstSize'.
+ * `originalSize` : **must** be the ***exact*** size of original (uncompressed) data.
+ * Note : in contrast with FSE, HUF_decompress can regenerate
+ * RLE (cSrcSize==1) and uncompressed (cSrcSize==dstSize) data,
+ * because it knows size to regenerate (originalSize).
+ * @return : size of regenerated data (== originalSize),
+ * or an error code, which can be tested using HUF_isError()
+ */
+HUF_PUBLIC_API size_t HUF_decompress(void* dst, size_t originalSize,
+ const void* cSrc, size_t cSrcSize);
+
+
+/* *** Tool functions *** */
+#define HUF_BLOCKSIZE_MAX (128 * 1024) /**< maximum input size for a single block compressed with HUF_compress */
+HUF_PUBLIC_API size_t HUF_compressBound(size_t size); /**< maximum compressed size (worst case) */
+
+/* Error Management */
+HUF_PUBLIC_API unsigned HUF_isError(size_t code); /**< tells if a return value is an error code */
+HUF_PUBLIC_API const char* HUF_getErrorName(size_t code); /**< provides error code string (useful for debugging) */
+
+
+/* *** Advanced function *** */
+
+/** HUF_compress2() :
+ * Same as HUF_compress(), but offers control over `maxSymbolValue` and `tableLog`.
+ * `maxSymbolValue` must be <= HUF_SYMBOLVALUE_MAX .
+ * `tableLog` must be `<= HUF_TABLELOG_MAX` . */
+HUF_PUBLIC_API size_t HUF_compress2 (void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned tableLog);
+
+/** HUF_compress4X_wksp() :
+ * Same as HUF_compress2(), but uses externally allocated `workSpace`.
+ * `workspace` must have minimum alignment of 4, and be at least as large as HUF_WORKSPACE_SIZE */
+#define HUF_WORKSPACE_SIZE (6 << 10)
+#define HUF_WORKSPACE_SIZE_U32 (HUF_WORKSPACE_SIZE / sizeof(U32))
+HUF_PUBLIC_API size_t HUF_compress4X_wksp (void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned tableLog,
+ void* workSpace, size_t wkspSize);
+
+#endif /* HUF_H_298734234 */
+
+/* ******************************************************************
+ * WARNING !!
+ * The following section contains advanced and experimental definitions
+ * which shall never be used in the context of a dynamic library,
+ * because they are not guaranteed to remain stable in the future.
+ * Only consider them in association with static linking.
+ * *****************************************************************/
+#if defined(HUF_STATIC_LINKING_ONLY) && !defined(HUF_H_HUF_STATIC_LINKING_ONLY)
+#define HUF_H_HUF_STATIC_LINKING_ONLY
+
+/* *** Dependencies *** */
+#include "mem.h" /* U32 */
+
+
+/* *** Constants *** */
+#define HUF_TABLELOG_MAX 12 /* max runtime value of tableLog (due to static allocation); can be modified up to HUF_ABSOLUTEMAX_TABLELOG */
+#define HUF_TABLELOG_DEFAULT 11 /* default tableLog value when none specified */
+#define HUF_SYMBOLVALUE_MAX 255
+
+#define HUF_TABLELOG_ABSOLUTEMAX 15 /* absolute limit of HUF_MAX_TABLELOG. Beyond that value, code does not work */
+#if (HUF_TABLELOG_MAX > HUF_TABLELOG_ABSOLUTEMAX)
+# error "HUF_TABLELOG_MAX is too large !"
+#endif
+
+
+/* ****************************************
+* Static allocation
+******************************************/
+/* HUF buffer bounds */
+#define HUF_CTABLEBOUND 129
+#define HUF_BLOCKBOUND(size) (size + (size>>8) + 8) /* only true when incompressible is pre-filtered with fast heuristic */
+#define HUF_COMPRESSBOUND(size) (HUF_CTABLEBOUND + HUF_BLOCKBOUND(size)) /* Macro version, useful for static allocation */
+
+/* static allocation of HUF's Compression Table */
+#define HUF_CTABLE_SIZE_U32(maxSymbolValue) ((maxSymbolValue)+1) /* Use tables of U32, for proper alignment */
+#define HUF_CTABLE_SIZE(maxSymbolValue) (HUF_CTABLE_SIZE_U32(maxSymbolValue) * sizeof(U32))
+#define HUF_CREATE_STATIC_CTABLE(name, maxSymbolValue) \
+ U32 name##hb[HUF_CTABLE_SIZE_U32(maxSymbolValue)]; \
+ void* name##hv = &(name##hb); \
+ HUF_CElt* name = (HUF_CElt*)(name##hv) /* no final ; */
+
+/* static allocation of HUF's DTable */
+typedef U32 HUF_DTable;
+#define HUF_DTABLE_SIZE(maxTableLog) (1 + (1<<(maxTableLog)))
+#define HUF_CREATE_STATIC_DTABLEX1(DTable, maxTableLog) \
+ HUF_DTable DTable[HUF_DTABLE_SIZE((maxTableLog)-1)] = { ((U32)((maxTableLog)-1) * 0x01000001) }
+#define HUF_CREATE_STATIC_DTABLEX2(DTable, maxTableLog) \
+ HUF_DTable DTable[HUF_DTABLE_SIZE(maxTableLog)] = { ((U32)(maxTableLog) * 0x01000001) }
+
+
+/* ****************************************
+* Advanced decompression functions
+******************************************/
+size_t HUF_decompress4X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */
+#ifndef HUF_FORCE_DECOMPRESS_X1
+size_t HUF_decompress4X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */
+#endif
+
+size_t HUF_decompress4X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< decodes RLE and uncompressed */
+size_t HUF_decompress4X_hufOnly(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< considers RLE and uncompressed as errors */
+size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< considers RLE and uncompressed as errors */
+size_t HUF_decompress4X1_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */
+size_t HUF_decompress4X1_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< single-symbol decoder */
+#ifndef HUF_FORCE_DECOMPRESS_X1
+size_t HUF_decompress4X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */
+size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< double-symbols decoder */
+#endif
+
+
+/* ****************************************
+ * HUF detailed API
+ * ****************************************/
+
+/*! HUF_compress() does the following:
+ * 1. count symbol occurrence from source[] into table count[] using FSE_count() (exposed within "fse.h")
+ * 2. (optional) refine tableLog using HUF_optimalTableLog()
+ * 3. build Huffman table from count using HUF_buildCTable()
+ * 4. save Huffman table to memory buffer using HUF_writeCTable()
+ * 5. encode the data stream using HUF_compress4X_usingCTable()
+ *
+ * The following API allows targeting specific sub-functions for advanced tasks.
+ * For example, it's possible to compress several blocks using the same 'CTable',
+ * or to save and regenerate 'CTable' using external methods.
+ */
+unsigned HUF_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue);
+typedef struct HUF_CElt_s HUF_CElt; /* incomplete type */
+size_t HUF_buildCTable (HUF_CElt* CTable, const unsigned* count, unsigned maxSymbolValue, unsigned maxNbBits); /* @return : maxNbBits; CTable and count can overlap. In which case, CTable will overwrite count content */
+size_t HUF_writeCTable (void* dst, size_t maxDstSize, const HUF_CElt* CTable, unsigned maxSymbolValue, unsigned huffLog);
+size_t HUF_compress4X_usingCTable(void* dst, size_t dstSize, const void* src, size_t srcSize, const HUF_CElt* CTable);
+
+typedef enum {
+ HUF_repeat_none, /**< Cannot use the previous table */
+ HUF_repeat_check, /**< Can use the previous table but it must be checked. Note : The previous table must have been constructed by HUF_compress{1, 4}X_repeat */
+ HUF_repeat_valid /**< Can use the previous table and it is assumed to be valid */
+ } HUF_repeat;
+/** HUF_compress4X_repeat() :
+ * Same as HUF_compress4X_wksp(), but considers using hufTable if *repeat != HUF_repeat_none.
+ * If it uses hufTable it does not modify hufTable or repeat.
+ * If it doesn't, it sets *repeat = HUF_repeat_none, and it sets hufTable to the table used.
+ * If preferRepeat then the old table will always be used if valid. */
+size_t HUF_compress4X_repeat(void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned tableLog,
+ void* workSpace, size_t wkspSize, /**< `workSpace` must be aligned on 4-bytes boundaries, `wkspSize` must be >= HUF_WORKSPACE_SIZE */
+ HUF_CElt* hufTable, HUF_repeat* repeat, int preferRepeat, int bmi2);
+
+/** HUF_buildCTable_wksp() :
+ * Same as HUF_buildCTable(), but using externally allocated scratch buffer.
+ * `workSpace` must be aligned on 4-bytes boundaries, and its size must be >= HUF_CTABLE_WORKSPACE_SIZE.
+ */
+#define HUF_CTABLE_WORKSPACE_SIZE_U32 (2*HUF_SYMBOLVALUE_MAX +1 +1)
+#define HUF_CTABLE_WORKSPACE_SIZE (HUF_CTABLE_WORKSPACE_SIZE_U32 * sizeof(unsigned))
+size_t HUF_buildCTable_wksp (HUF_CElt* tree,
+ const unsigned* count, U32 maxSymbolValue, U32 maxNbBits,
+ void* workSpace, size_t wkspSize);
+
+/*! HUF_readStats() :
+ * Read compact Huffman tree, saved by HUF_writeCTable().
+ * `huffWeight` is destination buffer.
+ * @return : size read from `src` , or an error Code .
+ * Note : Needed by HUF_readCTable() and HUF_readDTableXn() . */
+size_t HUF_readStats(BYTE* huffWeight, size_t hwSize,
+ U32* rankStats, U32* nbSymbolsPtr, U32* tableLogPtr,
+ const void* src, size_t srcSize);
+
+/** HUF_readCTable() :
+ * Loading a CTable saved with HUF_writeCTable() */
+size_t HUF_readCTable (HUF_CElt* CTable, unsigned* maxSymbolValuePtr, const void* src, size_t srcSize);
+
+/** HUF_getNbBits() :
+ * Read nbBits from CTable symbolTable, for symbol `symbolValue` presumed <= HUF_SYMBOLVALUE_MAX
+ * Note 1 : is not inlined, as HUF_CElt definition is private
+ * Note 2 : const void* used, so that it can provide a statically allocated table as argument (which uses type U32) */
+U32 HUF_getNbBits(const void* symbolTable, U32 symbolValue);
+
+/*
+ * HUF_decompress() does the following:
+ * 1. select the decompression algorithm (X1, X2) based on pre-computed heuristics
+ * 2. build Huffman table from save, using HUF_readDTableX?()
+ * 3. decode 1 or 4 segments in parallel using HUF_decompress?X?_usingDTable()
+ */
+
+/** HUF_selectDecoder() :
+ * Tells which decoder is likely to decode faster,
+ * based on a set of pre-computed metrics.
+ * @return : 0==HUF_decompress4X1, 1==HUF_decompress4X2 .
+ * Assumption : 0 < dstSize <= 128 KB */
+U32 HUF_selectDecoder (size_t dstSize, size_t cSrcSize);
+
+/**
+ * The minimum workspace size for the `workSpace` used in
+ * HUF_readDTableX1_wksp() and HUF_readDTableX2_wksp().
+ *
+ * The space used depends on HUF_TABLELOG_MAX, ranging from ~1500 bytes when
+ * HUF_TABLE_LOG_MAX=12 to ~1850 bytes when HUF_TABLE_LOG_MAX=15.
+ * Buffer overflow errors may potentially occur if code modifications result in
+ * a required workspace size greater than that specified in the following
+ * macro.
+ */
+#define HUF_DECOMPRESS_WORKSPACE_SIZE (2 << 10)
+#define HUF_DECOMPRESS_WORKSPACE_SIZE_U32 (HUF_DECOMPRESS_WORKSPACE_SIZE / sizeof(U32))
+
+#ifndef HUF_FORCE_DECOMPRESS_X2
+size_t HUF_readDTableX1 (HUF_DTable* DTable, const void* src, size_t srcSize);
+size_t HUF_readDTableX1_wksp (HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize);
+#endif
+#ifndef HUF_FORCE_DECOMPRESS_X1
+size_t HUF_readDTableX2 (HUF_DTable* DTable, const void* src, size_t srcSize);
+size_t HUF_readDTableX2_wksp (HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize);
+#endif
+
+size_t HUF_decompress4X_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
+#ifndef HUF_FORCE_DECOMPRESS_X2
+size_t HUF_decompress4X1_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
+#endif
+#ifndef HUF_FORCE_DECOMPRESS_X1
+size_t HUF_decompress4X2_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
+#endif
+
+
+/* ====================== */
+/* single stream variants */
+/* ====================== */
+
+size_t HUF_compress1X (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog);
+size_t HUF_compress1X_wksp (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize); /**< `workSpace` must be a table of at least HUF_WORKSPACE_SIZE_U32 unsigned */
+size_t HUF_compress1X_usingCTable(void* dst, size_t dstSize, const void* src, size_t srcSize, const HUF_CElt* CTable);
+/** HUF_compress1X_repeat() :
+ * Same as HUF_compress1X_wksp(), but considers using hufTable if *repeat != HUF_repeat_none.
+ * If it uses hufTable it does not modify hufTable or repeat.
+ * If it doesn't, it sets *repeat = HUF_repeat_none, and it sets hufTable to the table used.
+ * If preferRepeat then the old table will always be used if valid. */
+size_t HUF_compress1X_repeat(void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned tableLog,
+ void* workSpace, size_t wkspSize, /**< `workSpace` must be aligned on 4-bytes boundaries, `wkspSize` must be >= HUF_WORKSPACE_SIZE */
+ HUF_CElt* hufTable, HUF_repeat* repeat, int preferRepeat, int bmi2);
+
+size_t HUF_decompress1X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /* single-symbol decoder */
+#ifndef HUF_FORCE_DECOMPRESS_X1
+size_t HUF_decompress1X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /* double-symbol decoder */
+#endif
+
+size_t HUF_decompress1X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize);
+size_t HUF_decompress1X_DCtx_wksp (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize);
+#ifndef HUF_FORCE_DECOMPRESS_X2
+size_t HUF_decompress1X1_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< single-symbol decoder */
+size_t HUF_decompress1X1_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< single-symbol decoder */
+#endif
+#ifndef HUF_FORCE_DECOMPRESS_X1
+size_t HUF_decompress1X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize); /**< double-symbols decoder */
+size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize); /**< double-symbols decoder */
+#endif
+
+size_t HUF_decompress1X_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable); /**< automatic selection of sing or double symbol decoder, based on DTable */
+#ifndef HUF_FORCE_DECOMPRESS_X2
+size_t HUF_decompress1X1_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
+#endif
+#ifndef HUF_FORCE_DECOMPRESS_X1
+size_t HUF_decompress1X2_usingDTable(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable);
+#endif
+
+/* BMI2 variants.
+ * If the CPU has BMI2 support, pass bmi2=1, otherwise pass bmi2=0.
+ */
+size_t HUF_decompress1X_usingDTable_bmi2(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable, int bmi2);
+#ifndef HUF_FORCE_DECOMPRESS_X2
+size_t HUF_decompress1X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2);
+#endif
+size_t HUF_decompress4X_usingDTable_bmi2(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable, int bmi2);
+size_t HUF_decompress4X_hufOnly_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2);
+
+#endif /* HUF_STATIC_LINKING_ONLY */
+
+#if defined (__cplusplus)
+}
+#endif
diff --git a/Utilities/cmzstd/lib/common/mem.h b/Utilities/cmzstd/lib/common/mem.h
new file mode 100644
index 000000000..5da248756
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/mem.h
@@ -0,0 +1,380 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef MEM_H_MODULE
+#define MEM_H_MODULE
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/*-****************************************
+* Dependencies
+******************************************/
+#include <stddef.h> /* size_t, ptrdiff_t */
+#include <string.h> /* memcpy */
+
+
+/*-****************************************
+* Compiler specifics
+******************************************/
+#if defined(_MSC_VER) /* Visual Studio */
+# include <stdlib.h> /* _byteswap_ulong */
+# include <intrin.h> /* _byteswap_* */
+#endif
+#if defined(__GNUC__)
+# define MEM_STATIC static __inline __attribute__((unused))
+#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
+# define MEM_STATIC static inline
+#elif defined(_MSC_VER)
+# define MEM_STATIC static __inline
+#else
+# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
+#endif
+
+#ifndef __has_builtin
+# define __has_builtin(x) 0 /* compat. with non-clang compilers */
+#endif
+
+/* code only tested on 32 and 64 bits systems */
+#define MEM_STATIC_ASSERT(c) { enum { MEM_static_assert = 1/(int)(!!(c)) }; }
+MEM_STATIC void MEM_check(void) { MEM_STATIC_ASSERT((sizeof(size_t)==4) || (sizeof(size_t)==8)); }
+
+
+/*-**************************************************************
+* Basic Types
+*****************************************************************/
+#if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
+# include <stdint.h>
+ typedef uint8_t BYTE;
+ typedef uint16_t U16;
+ typedef int16_t S16;
+ typedef uint32_t U32;
+ typedef int32_t S32;
+ typedef uint64_t U64;
+ typedef int64_t S64;
+#else
+# include <limits.h>
+#if CHAR_BIT != 8
+# error "this implementation requires char to be exactly 8-bit type"
+#endif
+ typedef unsigned char BYTE;
+#if USHRT_MAX != 65535
+# error "this implementation requires short to be exactly 16-bit type"
+#endif
+ typedef unsigned short U16;
+ typedef signed short S16;
+#if UINT_MAX != 4294967295
+# error "this implementation requires int to be exactly 32-bit type"
+#endif
+ typedef unsigned int U32;
+ typedef signed int S32;
+/* note : there are no limits defined for long long type in C90.
+ * limits exist in C99, however, in such case, <stdint.h> is preferred */
+ typedef unsigned long long U64;
+ typedef signed long long S64;
+#endif
+
+
+/*-**************************************************************
+* Memory I/O
+*****************************************************************/
+/* MEM_FORCE_MEMORY_ACCESS :
+ * By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable.
+ * Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal.
+ * The below switch allow to select different access method for improved performance.
+ * Method 0 (default) : use `memcpy()`. Safe and portable.
+ * Method 1 : `__packed` statement. It depends on compiler extension (i.e., not portable).
+ * This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`.
+ * Method 2 : direct access. This method is portable but violate C standard.
+ * It can generate buggy code on targets depending on alignment.
+ * In some circumstances, it's the only known way to get the most performance (i.e. GCC + ARMv6)
+ * See http://fastcompression.blogspot.fr/2015/08/accessing-unaligned-memory.html for details.
+ * Prefer these methods in priority order (0 > 1 > 2)
+ */
+#ifndef MEM_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
+# if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) )
+# define MEM_FORCE_MEMORY_ACCESS 2
+# elif defined(__INTEL_COMPILER) || defined(__GNUC__)
+# define MEM_FORCE_MEMORY_ACCESS 1
+# endif
+#endif
+
+MEM_STATIC unsigned MEM_32bits(void) { return sizeof(size_t)==4; }
+MEM_STATIC unsigned MEM_64bits(void) { return sizeof(size_t)==8; }
+
+MEM_STATIC unsigned MEM_isLittleEndian(void)
+{
+ const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */
+ return one.c[0];
+}
+
+#if defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==2)
+
+/* violates C standard, by lying on structure alignment.
+Only use if no other choice to achieve best performance on target platform */
+MEM_STATIC U16 MEM_read16(const void* memPtr) { return *(const U16*) memPtr; }
+MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; }
+MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; }
+MEM_STATIC size_t MEM_readST(const void* memPtr) { return *(const size_t*) memPtr; }
+
+MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; }
+MEM_STATIC void MEM_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; }
+MEM_STATIC void MEM_write64(void* memPtr, U64 value) { *(U64*)memPtr = value; }
+
+#elif defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==1)
+
+/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
+/* currently only defined for gcc and icc */
+#if defined(_MSC_VER) || (defined(__INTEL_COMPILER) && defined(WIN32))
+ __pragma( pack(push, 1) )
+ typedef struct { U16 v; } unalign16;
+ typedef struct { U32 v; } unalign32;
+ typedef struct { U64 v; } unalign64;
+ typedef struct { size_t v; } unalignArch;
+ __pragma( pack(pop) )
+#else
+ typedef struct { U16 v; } __attribute__((packed)) unalign16;
+ typedef struct { U32 v; } __attribute__((packed)) unalign32;
+ typedef struct { U64 v; } __attribute__((packed)) unalign64;
+ typedef struct { size_t v; } __attribute__((packed)) unalignArch;
+#endif
+
+MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign16*)ptr)->v; }
+MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign32*)ptr)->v; }
+MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign64*)ptr)->v; }
+MEM_STATIC size_t MEM_readST(const void* ptr) { return ((const unalignArch*)ptr)->v; }
+
+MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign16*)memPtr)->v = value; }
+MEM_STATIC void MEM_write32(void* memPtr, U32 value) { ((unalign32*)memPtr)->v = value; }
+MEM_STATIC void MEM_write64(void* memPtr, U64 value) { ((unalign64*)memPtr)->v = value; }
+
+#else
+
+/* default method, safe and standard.
+ can sometimes prove slower */
+
+MEM_STATIC U16 MEM_read16(const void* memPtr)
+{
+ U16 val; memcpy(&val, memPtr, sizeof(val)); return val;
+}
+
+MEM_STATIC U32 MEM_read32(const void* memPtr)
+{
+ U32 val; memcpy(&val, memPtr, sizeof(val)); return val;
+}
+
+MEM_STATIC U64 MEM_read64(const void* memPtr)
+{
+ U64 val; memcpy(&val, memPtr, sizeof(val)); return val;
+}
+
+MEM_STATIC size_t MEM_readST(const void* memPtr)
+{
+ size_t val; memcpy(&val, memPtr, sizeof(val)); return val;
+}
+
+MEM_STATIC void MEM_write16(void* memPtr, U16 value)
+{
+ memcpy(memPtr, &value, sizeof(value));
+}
+
+MEM_STATIC void MEM_write32(void* memPtr, U32 value)
+{
+ memcpy(memPtr, &value, sizeof(value));
+}
+
+MEM_STATIC void MEM_write64(void* memPtr, U64 value)
+{
+ memcpy(memPtr, &value, sizeof(value));
+}
+
+#endif /* MEM_FORCE_MEMORY_ACCESS */
+
+MEM_STATIC U32 MEM_swap32(U32 in)
+{
+#if defined(_MSC_VER) /* Visual Studio */
+ return _byteswap_ulong(in);
+#elif (defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)) \
+ || (defined(__clang__) && __has_builtin(__builtin_bswap32))
+ return __builtin_bswap32(in);
+#else
+ return ((in << 24) & 0xff000000 ) |
+ ((in << 8) & 0x00ff0000 ) |
+ ((in >> 8) & 0x0000ff00 ) |
+ ((in >> 24) & 0x000000ff );
+#endif
+}
+
+MEM_STATIC U64 MEM_swap64(U64 in)
+{
+#if defined(_MSC_VER) /* Visual Studio */
+ return _byteswap_uint64(in);
+#elif (defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)) \
+ || (defined(__clang__) && __has_builtin(__builtin_bswap64))
+ return __builtin_bswap64(in);
+#else
+ return ((in << 56) & 0xff00000000000000ULL) |
+ ((in << 40) & 0x00ff000000000000ULL) |
+ ((in << 24) & 0x0000ff0000000000ULL) |
+ ((in << 8) & 0x000000ff00000000ULL) |
+ ((in >> 8) & 0x00000000ff000000ULL) |
+ ((in >> 24) & 0x0000000000ff0000ULL) |
+ ((in >> 40) & 0x000000000000ff00ULL) |
+ ((in >> 56) & 0x00000000000000ffULL);
+#endif
+}
+
+MEM_STATIC size_t MEM_swapST(size_t in)
+{
+ if (MEM_32bits())
+ return (size_t)MEM_swap32((U32)in);
+ else
+ return (size_t)MEM_swap64((U64)in);
+}
+
+/*=== Little endian r/w ===*/
+
+MEM_STATIC U16 MEM_readLE16(const void* memPtr)
+{
+ if (MEM_isLittleEndian())
+ return MEM_read16(memPtr);
+ else {
+ const BYTE* p = (const BYTE*)memPtr;
+ return (U16)(p[0] + (p[1]<<8));
+ }
+}
+
+MEM_STATIC void MEM_writeLE16(void* memPtr, U16 val)
+{
+ if (MEM_isLittleEndian()) {
+ MEM_write16(memPtr, val);
+ } else {
+ BYTE* p = (BYTE*)memPtr;
+ p[0] = (BYTE)val;
+ p[1] = (BYTE)(val>>8);
+ }
+}
+
+MEM_STATIC U32 MEM_readLE24(const void* memPtr)
+{
+ return MEM_readLE16(memPtr) + (((const BYTE*)memPtr)[2] << 16);
+}
+
+MEM_STATIC void MEM_writeLE24(void* memPtr, U32 val)
+{
+ MEM_writeLE16(memPtr, (U16)val);
+ ((BYTE*)memPtr)[2] = (BYTE)(val>>16);
+}
+
+MEM_STATIC U32 MEM_readLE32(const void* memPtr)
+{
+ if (MEM_isLittleEndian())
+ return MEM_read32(memPtr);
+ else
+ return MEM_swap32(MEM_read32(memPtr));
+}
+
+MEM_STATIC void MEM_writeLE32(void* memPtr, U32 val32)
+{
+ if (MEM_isLittleEndian())
+ MEM_write32(memPtr, val32);
+ else
+ MEM_write32(memPtr, MEM_swap32(val32));
+}
+
+MEM_STATIC U64 MEM_readLE64(const void* memPtr)
+{
+ if (MEM_isLittleEndian())
+ return MEM_read64(memPtr);
+ else
+ return MEM_swap64(MEM_read64(memPtr));
+}
+
+MEM_STATIC void MEM_writeLE64(void* memPtr, U64 val64)
+{
+ if (MEM_isLittleEndian())
+ MEM_write64(memPtr, val64);
+ else
+ MEM_write64(memPtr, MEM_swap64(val64));
+}
+
+MEM_STATIC size_t MEM_readLEST(const void* memPtr)
+{
+ if (MEM_32bits())
+ return (size_t)MEM_readLE32(memPtr);
+ else
+ return (size_t)MEM_readLE64(memPtr);
+}
+
+MEM_STATIC void MEM_writeLEST(void* memPtr, size_t val)
+{
+ if (MEM_32bits())
+ MEM_writeLE32(memPtr, (U32)val);
+ else
+ MEM_writeLE64(memPtr, (U64)val);
+}
+
+/*=== Big endian r/w ===*/
+
+MEM_STATIC U32 MEM_readBE32(const void* memPtr)
+{
+ if (MEM_isLittleEndian())
+ return MEM_swap32(MEM_read32(memPtr));
+ else
+ return MEM_read32(memPtr);
+}
+
+MEM_STATIC void MEM_writeBE32(void* memPtr, U32 val32)
+{
+ if (MEM_isLittleEndian())
+ MEM_write32(memPtr, MEM_swap32(val32));
+ else
+ MEM_write32(memPtr, val32);
+}
+
+MEM_STATIC U64 MEM_readBE64(const void* memPtr)
+{
+ if (MEM_isLittleEndian())
+ return MEM_swap64(MEM_read64(memPtr));
+ else
+ return MEM_read64(memPtr);
+}
+
+MEM_STATIC void MEM_writeBE64(void* memPtr, U64 val64)
+{
+ if (MEM_isLittleEndian())
+ MEM_write64(memPtr, MEM_swap64(val64));
+ else
+ MEM_write64(memPtr, val64);
+}
+
+MEM_STATIC size_t MEM_readBEST(const void* memPtr)
+{
+ if (MEM_32bits())
+ return (size_t)MEM_readBE32(memPtr);
+ else
+ return (size_t)MEM_readBE64(memPtr);
+}
+
+MEM_STATIC void MEM_writeBEST(void* memPtr, size_t val)
+{
+ if (MEM_32bits())
+ MEM_writeBE32(memPtr, (U32)val);
+ else
+ MEM_writeBE64(memPtr, (U64)val);
+}
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* MEM_H_MODULE */
diff --git a/Utilities/cmzstd/lib/common/pool.c b/Utilities/cmzstd/lib/common/pool.c
new file mode 100644
index 000000000..7a8294543
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/pool.c
@@ -0,0 +1,340 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+
+/* ====== Dependencies ======= */
+#include <stddef.h> /* size_t */
+#include "debug.h" /* assert */
+#include "zstd_internal.h" /* ZSTD_malloc, ZSTD_free */
+#include "pool.h"
+
+/* ====== Compiler specifics ====== */
+#if defined(_MSC_VER)
+# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */
+#endif
+
+
+#ifdef ZSTD_MULTITHREAD
+
+#include "threading.h" /* pthread adaptation */
+
+/* A job is a function and an opaque argument */
+typedef struct POOL_job_s {
+ POOL_function function;
+ void *opaque;
+} POOL_job;
+
+struct POOL_ctx_s {
+ ZSTD_customMem customMem;
+ /* Keep track of the threads */
+ ZSTD_pthread_t* threads;
+ size_t threadCapacity;
+ size_t threadLimit;
+
+ /* The queue is a circular buffer */
+ POOL_job *queue;
+ size_t queueHead;
+ size_t queueTail;
+ size_t queueSize;
+
+ /* The number of threads working on jobs */
+ size_t numThreadsBusy;
+ /* Indicates if the queue is empty */
+ int queueEmpty;
+
+ /* The mutex protects the queue */
+ ZSTD_pthread_mutex_t queueMutex;
+ /* Condition variable for pushers to wait on when the queue is full */
+ ZSTD_pthread_cond_t queuePushCond;
+ /* Condition variables for poppers to wait on when the queue is empty */
+ ZSTD_pthread_cond_t queuePopCond;
+ /* Indicates if the queue is shutting down */
+ int shutdown;
+};
+
+/* POOL_thread() :
+ * Work thread for the thread pool.
+ * Waits for jobs and executes them.
+ * @returns : NULL on failure else non-null.
+ */
+static void* POOL_thread(void* opaque) {
+ POOL_ctx* const ctx = (POOL_ctx*)opaque;
+ if (!ctx) { return NULL; }
+ for (;;) {
+ /* Lock the mutex and wait for a non-empty queue or until shutdown */
+ ZSTD_pthread_mutex_lock(&ctx->queueMutex);
+
+ while ( ctx->queueEmpty
+ || (ctx->numThreadsBusy >= ctx->threadLimit) ) {
+ if (ctx->shutdown) {
+ /* even if !queueEmpty, (possible if numThreadsBusy >= threadLimit),
+ * a few threads will be shutdown while !queueEmpty,
+ * but enough threads will remain active to finish the queue */
+ ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
+ return opaque;
+ }
+ ZSTD_pthread_cond_wait(&ctx->queuePopCond, &ctx->queueMutex);
+ }
+ /* Pop a job off the queue */
+ { POOL_job const job = ctx->queue[ctx->queueHead];
+ ctx->queueHead = (ctx->queueHead + 1) % ctx->queueSize;
+ ctx->numThreadsBusy++;
+ ctx->queueEmpty = ctx->queueHead == ctx->queueTail;
+ /* Unlock the mutex, signal a pusher, and run the job */
+ ZSTD_pthread_cond_signal(&ctx->queuePushCond);
+ ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
+
+ job.function(job.opaque);
+
+ /* If the intended queue size was 0, signal after finishing job */
+ ZSTD_pthread_mutex_lock(&ctx->queueMutex);
+ ctx->numThreadsBusy--;
+ if (ctx->queueSize == 1) {
+ ZSTD_pthread_cond_signal(&ctx->queuePushCond);
+ }
+ ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
+ }
+ } /* for (;;) */
+ assert(0); /* Unreachable */
+}
+
+POOL_ctx* POOL_create(size_t numThreads, size_t queueSize) {
+ return POOL_create_advanced(numThreads, queueSize, ZSTD_defaultCMem);
+}
+
+POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize,
+ ZSTD_customMem customMem) {
+ POOL_ctx* ctx;
+ /* Check parameters */
+ if (!numThreads) { return NULL; }
+ /* Allocate the context and zero initialize */
+ ctx = (POOL_ctx*)ZSTD_calloc(sizeof(POOL_ctx), customMem);
+ if (!ctx) { return NULL; }
+ /* Initialize the job queue.
+ * It needs one extra space since one space is wasted to differentiate
+ * empty and full queues.
+ */
+ ctx->queueSize = queueSize + 1;
+ ctx->queue = (POOL_job*)ZSTD_malloc(ctx->queueSize * sizeof(POOL_job), customMem);
+ ctx->queueHead = 0;
+ ctx->queueTail = 0;
+ ctx->numThreadsBusy = 0;
+ ctx->queueEmpty = 1;
+ (void)ZSTD_pthread_mutex_init(&ctx->queueMutex, NULL);
+ (void)ZSTD_pthread_cond_init(&ctx->queuePushCond, NULL);
+ (void)ZSTD_pthread_cond_init(&ctx->queuePopCond, NULL);
+ ctx->shutdown = 0;
+ /* Allocate space for the thread handles */
+ ctx->threads = (ZSTD_pthread_t*)ZSTD_malloc(numThreads * sizeof(ZSTD_pthread_t), customMem);
+ ctx->threadCapacity = 0;
+ ctx->customMem = customMem;
+ /* Check for errors */
+ if (!ctx->threads || !ctx->queue) { POOL_free(ctx); return NULL; }
+ /* Initialize the threads */
+ { size_t i;
+ for (i = 0; i < numThreads; ++i) {
+ if (ZSTD_pthread_create(&ctx->threads[i], NULL, &POOL_thread, ctx)) {
+ ctx->threadCapacity = i;
+ POOL_free(ctx);
+ return NULL;
+ } }
+ ctx->threadCapacity = numThreads;
+ ctx->threadLimit = numThreads;
+ }
+ return ctx;
+}
+
+/*! POOL_join() :
+ Shutdown the queue, wake any sleeping threads, and join all of the threads.
+*/
+static void POOL_join(POOL_ctx* ctx) {
+ /* Shut down the queue */
+ ZSTD_pthread_mutex_lock(&ctx->queueMutex);
+ ctx->shutdown = 1;
+ ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
+ /* Wake up sleeping threads */
+ ZSTD_pthread_cond_broadcast(&ctx->queuePushCond);
+ ZSTD_pthread_cond_broadcast(&ctx->queuePopCond);
+ /* Join all of the threads */
+ { size_t i;
+ for (i = 0; i < ctx->threadCapacity; ++i) {
+ ZSTD_pthread_join(ctx->threads[i], NULL); /* note : could fail */
+ } }
+}
+
+void POOL_free(POOL_ctx *ctx) {
+ if (!ctx) { return; }
+ POOL_join(ctx);
+ ZSTD_pthread_mutex_destroy(&ctx->queueMutex);
+ ZSTD_pthread_cond_destroy(&ctx->queuePushCond);
+ ZSTD_pthread_cond_destroy(&ctx->queuePopCond);
+ ZSTD_free(ctx->queue, ctx->customMem);
+ ZSTD_free(ctx->threads, ctx->customMem);
+ ZSTD_free(ctx, ctx->customMem);
+}
+
+
+
+size_t POOL_sizeof(POOL_ctx *ctx) {
+ if (ctx==NULL) return 0; /* supports sizeof NULL */
+ return sizeof(*ctx)
+ + ctx->queueSize * sizeof(POOL_job)
+ + ctx->threadCapacity * sizeof(ZSTD_pthread_t);
+}
+
+
+/* @return : 0 on success, 1 on error */
+static int POOL_resize_internal(POOL_ctx* ctx, size_t numThreads)
+{
+ if (numThreads <= ctx->threadCapacity) {
+ if (!numThreads) return 1;
+ ctx->threadLimit = numThreads;
+ return 0;
+ }
+ /* numThreads > threadCapacity */
+ { ZSTD_pthread_t* const threadPool = (ZSTD_pthread_t*)ZSTD_malloc(numThreads * sizeof(ZSTD_pthread_t), ctx->customMem);
+ if (!threadPool) return 1;
+ /* replace existing thread pool */
+ memcpy(threadPool, ctx->threads, ctx->threadCapacity * sizeof(*threadPool));
+ ZSTD_free(ctx->threads, ctx->customMem);
+ ctx->threads = threadPool;
+ /* Initialize additional threads */
+ { size_t threadId;
+ for (threadId = ctx->threadCapacity; threadId < numThreads; ++threadId) {
+ if (ZSTD_pthread_create(&threadPool[threadId], NULL, &POOL_thread, ctx)) {
+ ctx->threadCapacity = threadId;
+ return 1;
+ } }
+ } }
+ /* successfully expanded */
+ ctx->threadCapacity = numThreads;
+ ctx->threadLimit = numThreads;
+ return 0;
+}
+
+/* @return : 0 on success, 1 on error */
+int POOL_resize(POOL_ctx* ctx, size_t numThreads)
+{
+ int result;
+ if (ctx==NULL) return 1;
+ ZSTD_pthread_mutex_lock(&ctx->queueMutex);
+ result = POOL_resize_internal(ctx, numThreads);
+ ZSTD_pthread_cond_broadcast(&ctx->queuePopCond);
+ ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
+ return result;
+}
+
+/**
+ * Returns 1 if the queue is full and 0 otherwise.
+ *
+ * When queueSize is 1 (pool was created with an intended queueSize of 0),
+ * then a queue is empty if there is a thread free _and_ no job is waiting.
+ */
+static int isQueueFull(POOL_ctx const* ctx) {
+ if (ctx->queueSize > 1) {
+ return ctx->queueHead == ((ctx->queueTail + 1) % ctx->queueSize);
+ } else {
+ return (ctx->numThreadsBusy == ctx->threadLimit) ||
+ !ctx->queueEmpty;
+ }
+}
+
+
+static void POOL_add_internal(POOL_ctx* ctx, POOL_function function, void *opaque)
+{
+ POOL_job const job = {function, opaque};
+ assert(ctx != NULL);
+ if (ctx->shutdown) return;
+
+ ctx->queueEmpty = 0;
+ ctx->queue[ctx->queueTail] = job;
+ ctx->queueTail = (ctx->queueTail + 1) % ctx->queueSize;
+ ZSTD_pthread_cond_signal(&ctx->queuePopCond);
+}
+
+void POOL_add(POOL_ctx* ctx, POOL_function function, void* opaque)
+{
+ assert(ctx != NULL);
+ ZSTD_pthread_mutex_lock(&ctx->queueMutex);
+ /* Wait until there is space in the queue for the new job */
+ while (isQueueFull(ctx) && (!ctx->shutdown)) {
+ ZSTD_pthread_cond_wait(&ctx->queuePushCond, &ctx->queueMutex);
+ }
+ POOL_add_internal(ctx, function, opaque);
+ ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
+}
+
+
+int POOL_tryAdd(POOL_ctx* ctx, POOL_function function, void* opaque)
+{
+ assert(ctx != NULL);
+ ZSTD_pthread_mutex_lock(&ctx->queueMutex);
+ if (isQueueFull(ctx)) {
+ ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
+ return 0;
+ }
+ POOL_add_internal(ctx, function, opaque);
+ ZSTD_pthread_mutex_unlock(&ctx->queueMutex);
+ return 1;
+}
+
+
+#else /* ZSTD_MULTITHREAD not defined */
+
+/* ========================== */
+/* No multi-threading support */
+/* ========================== */
+
+
+/* We don't need any data, but if it is empty, malloc() might return NULL. */
+struct POOL_ctx_s {
+ int dummy;
+};
+static POOL_ctx g_ctx;
+
+POOL_ctx* POOL_create(size_t numThreads, size_t queueSize) {
+ return POOL_create_advanced(numThreads, queueSize, ZSTD_defaultCMem);
+}
+
+POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize, ZSTD_customMem customMem) {
+ (void)numThreads;
+ (void)queueSize;
+ (void)customMem;
+ return &g_ctx;
+}
+
+void POOL_free(POOL_ctx* ctx) {
+ assert(!ctx || ctx == &g_ctx);
+ (void)ctx;
+}
+
+int POOL_resize(POOL_ctx* ctx, size_t numThreads) {
+ (void)ctx; (void)numThreads;
+ return 0;
+}
+
+void POOL_add(POOL_ctx* ctx, POOL_function function, void* opaque) {
+ (void)ctx;
+ function(opaque);
+}
+
+int POOL_tryAdd(POOL_ctx* ctx, POOL_function function, void* opaque) {
+ (void)ctx;
+ function(opaque);
+ return 1;
+}
+
+size_t POOL_sizeof(POOL_ctx* ctx) {
+ if (ctx==NULL) return 0; /* supports sizeof NULL */
+ assert(ctx == &g_ctx);
+ return sizeof(*ctx);
+}
+
+#endif /* ZSTD_MULTITHREAD */
diff --git a/Utilities/cmzstd/lib/common/pool.h b/Utilities/cmzstd/lib/common/pool.h
new file mode 100644
index 000000000..458d37f13
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/pool.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef POOL_H
+#define POOL_H
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+#include <stddef.h> /* size_t */
+#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_customMem */
+#include "zstd.h"
+
+typedef struct POOL_ctx_s POOL_ctx;
+
+/*! POOL_create() :
+ * Create a thread pool with at most `numThreads` threads.
+ * `numThreads` must be at least 1.
+ * The maximum number of queued jobs before blocking is `queueSize`.
+ * @return : POOL_ctx pointer on success, else NULL.
+*/
+POOL_ctx* POOL_create(size_t numThreads, size_t queueSize);
+
+POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize,
+ ZSTD_customMem customMem);
+
+/*! POOL_free() :
+ * Free a thread pool returned by POOL_create().
+ */
+void POOL_free(POOL_ctx* ctx);
+
+/*! POOL_resize() :
+ * Expands or shrinks pool's number of threads.
+ * This is more efficient than releasing + creating a new context,
+ * since it tries to preserve and re-use existing threads.
+ * `numThreads` must be at least 1.
+ * @return : 0 when resize was successful,
+ * !0 (typically 1) if there is an error.
+ * note : only numThreads can be resized, queueSize remains unchanged.
+ */
+int POOL_resize(POOL_ctx* ctx, size_t numThreads);
+
+/*! POOL_sizeof() :
+ * @return threadpool memory usage
+ * note : compatible with NULL (returns 0 in this case)
+ */
+size_t POOL_sizeof(POOL_ctx* ctx);
+
+/*! POOL_function :
+ * The function type that can be added to a thread pool.
+ */
+typedef void (*POOL_function)(void*);
+
+/*! POOL_add() :
+ * Add the job `function(opaque)` to the thread pool. `ctx` must be valid.
+ * Possibly blocks until there is room in the queue.
+ * Note : The function may be executed asynchronously,
+ * therefore, `opaque` must live until function has been completed.
+ */
+void POOL_add(POOL_ctx* ctx, POOL_function function, void* opaque);
+
+
+/*! POOL_tryAdd() :
+ * Add the job `function(opaque)` to thread pool _if_ a worker is available.
+ * Returns immediately even if not (does not block).
+ * @return : 1 if successful, 0 if not.
+ */
+int POOL_tryAdd(POOL_ctx* ctx, POOL_function function, void* opaque);
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif
diff --git a/Utilities/cmzstd/lib/common/threading.c b/Utilities/cmzstd/lib/common/threading.c
new file mode 100644
index 000000000..8be8c8da9
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/threading.c
@@ -0,0 +1,75 @@
+/**
+ * Copyright (c) 2016 Tino Reichardt
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ *
+ * You can contact the author at:
+ * - zstdmt source repository: https://github.com/mcmilk/zstdmt
+ */
+
+/**
+ * This file will hold wrapper for systems, which do not support pthreads
+ */
+
+/* create fake symbol to avoid empty trnaslation unit warning */
+int g_ZSTD_threading_useles_symbol;
+
+#if defined(ZSTD_MULTITHREAD) && defined(_WIN32)
+
+/**
+ * Windows minimalist Pthread Wrapper, based on :
+ * http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
+ */
+
+
+/* === Dependencies === */
+#include <process.h>
+#include <errno.h>
+#include "threading.h"
+
+
+/* === Implementation === */
+
+static unsigned __stdcall worker(void *arg)
+{
+ ZSTD_pthread_t* const thread = (ZSTD_pthread_t*) arg;
+ thread->arg = thread->start_routine(thread->arg);
+ return 0;
+}
+
+int ZSTD_pthread_create(ZSTD_pthread_t* thread, const void* unused,
+ void* (*start_routine) (void*), void* arg)
+{
+ (void)unused;
+ thread->arg = arg;
+ thread->start_routine = start_routine;
+ thread->handle = (HANDLE) _beginthreadex(NULL, 0, worker, thread, 0, NULL);
+
+ if (!thread->handle)
+ return errno;
+ else
+ return 0;
+}
+
+int ZSTD_pthread_join(ZSTD_pthread_t thread, void **value_ptr)
+{
+ DWORD result;
+
+ if (!thread.handle) return 0;
+
+ result = WaitForSingleObject(thread.handle, INFINITE);
+ switch (result) {
+ case WAIT_OBJECT_0:
+ if (value_ptr) *value_ptr = thread.arg;
+ return 0;
+ case WAIT_ABANDONED:
+ return EINVAL;
+ default:
+ return GetLastError();
+ }
+}
+
+#endif /* ZSTD_MULTITHREAD */
diff --git a/Utilities/cmzstd/lib/common/threading.h b/Utilities/cmzstd/lib/common/threading.h
new file mode 100644
index 000000000..d806c89d0
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/threading.h
@@ -0,0 +1,123 @@
+/**
+ * Copyright (c) 2016 Tino Reichardt
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ *
+ * You can contact the author at:
+ * - zstdmt source repository: https://github.com/mcmilk/zstdmt
+ */
+
+#ifndef THREADING_H_938743
+#define THREADING_H_938743
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#if defined(ZSTD_MULTITHREAD) && defined(_WIN32)
+
+/**
+ * Windows minimalist Pthread Wrapper, based on :
+ * http://www.cse.wustl.edu/~schmidt/win32-cv-1.html
+ */
+#ifdef WINVER
+# undef WINVER
+#endif
+#define WINVER 0x0600
+
+#ifdef _WIN32_WINNT
+# undef _WIN32_WINNT
+#endif
+#define _WIN32_WINNT 0x0600
+
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+
+#undef ERROR /* reported already defined on VS 2015 (Rich Geldreich) */
+#include <windows.h>
+#undef ERROR
+#define ERROR(name) ZSTD_ERROR(name)
+
+
+/* mutex */
+#define ZSTD_pthread_mutex_t CRITICAL_SECTION
+#define ZSTD_pthread_mutex_init(a, b) ((void)(b), InitializeCriticalSection((a)), 0)
+#define ZSTD_pthread_mutex_destroy(a) DeleteCriticalSection((a))
+#define ZSTD_pthread_mutex_lock(a) EnterCriticalSection((a))
+#define ZSTD_pthread_mutex_unlock(a) LeaveCriticalSection((a))
+
+/* condition variable */
+#define ZSTD_pthread_cond_t CONDITION_VARIABLE
+#define ZSTD_pthread_cond_init(a, b) ((void)(b), InitializeConditionVariable((a)), 0)
+#define ZSTD_pthread_cond_destroy(a) ((void)(a))
+#define ZSTD_pthread_cond_wait(a, b) SleepConditionVariableCS((a), (b), INFINITE)
+#define ZSTD_pthread_cond_signal(a) WakeConditionVariable((a))
+#define ZSTD_pthread_cond_broadcast(a) WakeAllConditionVariable((a))
+
+/* ZSTD_pthread_create() and ZSTD_pthread_join() */
+typedef struct {
+ HANDLE handle;
+ void* (*start_routine)(void*);
+ void* arg;
+} ZSTD_pthread_t;
+
+int ZSTD_pthread_create(ZSTD_pthread_t* thread, const void* unused,
+ void* (*start_routine) (void*), void* arg);
+
+int ZSTD_pthread_join(ZSTD_pthread_t thread, void** value_ptr);
+
+/**
+ * add here more wrappers as required
+ */
+
+
+#elif defined(ZSTD_MULTITHREAD) /* posix assumed ; need a better detection method */
+/* === POSIX Systems === */
+# include <pthread.h>
+
+#define ZSTD_pthread_mutex_t pthread_mutex_t
+#define ZSTD_pthread_mutex_init(a, b) pthread_mutex_init((a), (b))
+#define ZSTD_pthread_mutex_destroy(a) pthread_mutex_destroy((a))
+#define ZSTD_pthread_mutex_lock(a) pthread_mutex_lock((a))
+#define ZSTD_pthread_mutex_unlock(a) pthread_mutex_unlock((a))
+
+#define ZSTD_pthread_cond_t pthread_cond_t
+#define ZSTD_pthread_cond_init(a, b) pthread_cond_init((a), (b))
+#define ZSTD_pthread_cond_destroy(a) pthread_cond_destroy((a))
+#define ZSTD_pthread_cond_wait(a, b) pthread_cond_wait((a), (b))
+#define ZSTD_pthread_cond_signal(a) pthread_cond_signal((a))
+#define ZSTD_pthread_cond_broadcast(a) pthread_cond_broadcast((a))
+
+#define ZSTD_pthread_t pthread_t
+#define ZSTD_pthread_create(a, b, c, d) pthread_create((a), (b), (c), (d))
+#define ZSTD_pthread_join(a, b) pthread_join((a),(b))
+
+#else /* ZSTD_MULTITHREAD not defined */
+/* No multithreading support */
+
+typedef int ZSTD_pthread_mutex_t;
+#define ZSTD_pthread_mutex_init(a, b) ((void)(a), (void)(b), 0)
+#define ZSTD_pthread_mutex_destroy(a) ((void)(a))
+#define ZSTD_pthread_mutex_lock(a) ((void)(a))
+#define ZSTD_pthread_mutex_unlock(a) ((void)(a))
+
+typedef int ZSTD_pthread_cond_t;
+#define ZSTD_pthread_cond_init(a, b) ((void)(a), (void)(b), 0)
+#define ZSTD_pthread_cond_destroy(a) ((void)(a))
+#define ZSTD_pthread_cond_wait(a, b) ((void)(a), (void)(b))
+#define ZSTD_pthread_cond_signal(a) ((void)(a))
+#define ZSTD_pthread_cond_broadcast(a) ((void)(a))
+
+/* do not use ZSTD_pthread_t */
+
+#endif /* ZSTD_MULTITHREAD */
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* THREADING_H_938743 */
diff --git a/Utilities/cmzstd/lib/common/xxhash.c b/Utilities/cmzstd/lib/common/xxhash.c
new file mode 100644
index 000000000..532b81619
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/xxhash.c
@@ -0,0 +1,876 @@
+/*
+* xxHash - Fast Hash algorithm
+* Copyright (C) 2012-2016, Yann Collet
+*
+* BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are
+* met:
+*
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following disclaimer
+* in the documentation and/or other materials provided with the
+* distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+* You can contact the author at :
+* - xxHash homepage: http://www.xxhash.com
+* - xxHash source repository : https://github.com/Cyan4973/xxHash
+*/
+
+
+/* *************************************
+* Tuning parameters
+***************************************/
+/*!XXH_FORCE_MEMORY_ACCESS :
+ * By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable.
+ * Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal.
+ * The below switch allow to select different access method for improved performance.
+ * Method 0 (default) : use `memcpy()`. Safe and portable.
+ * Method 1 : `__packed` statement. It depends on compiler extension (ie, not portable).
+ * This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`.
+ * Method 2 : direct access. This method doesn't depend on compiler but violate C standard.
+ * It can generate buggy code on targets which do not support unaligned memory accesses.
+ * But in some circumstances, it's the only known way to get the most performance (ie GCC + ARMv6)
+ * See http://stackoverflow.com/a/32095106/646947 for details.
+ * Prefer these methods in priority order (0 > 1 > 2)
+ */
+#ifndef XXH_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
+# if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) )
+# define XXH_FORCE_MEMORY_ACCESS 2
+# elif (defined(__INTEL_COMPILER) && !defined(WIN32)) || \
+ (defined(__GNUC__) && ( defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) ))
+# define XXH_FORCE_MEMORY_ACCESS 1
+# endif
+#endif
+
+/*!XXH_ACCEPT_NULL_INPUT_POINTER :
+ * If the input pointer is a null pointer, xxHash default behavior is to trigger a memory access error, since it is a bad pointer.
+ * When this option is enabled, xxHash output for null input pointers will be the same as a null-length input.
+ * By default, this option is disabled. To enable it, uncomment below define :
+ */
+/* #define XXH_ACCEPT_NULL_INPUT_POINTER 1 */
+
+/*!XXH_FORCE_NATIVE_FORMAT :
+ * By default, xxHash library provides endian-independant Hash values, based on little-endian convention.
+ * Results are therefore identical for little-endian and big-endian CPU.
+ * This comes at a performance cost for big-endian CPU, since some swapping is required to emulate little-endian format.
+ * Should endian-independance be of no importance for your application, you may set the #define below to 1,
+ * to improve speed for Big-endian CPU.
+ * This option has no impact on Little_Endian CPU.
+ */
+#ifndef XXH_FORCE_NATIVE_FORMAT /* can be defined externally */
+# define XXH_FORCE_NATIVE_FORMAT 0
+#endif
+
+/*!XXH_FORCE_ALIGN_CHECK :
+ * This is a minor performance trick, only useful with lots of very small keys.
+ * It means : check for aligned/unaligned input.
+ * The check costs one initial branch per hash; set to 0 when the input data
+ * is guaranteed to be aligned.
+ */
+#ifndef XXH_FORCE_ALIGN_CHECK /* can be defined externally */
+# if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
+# define XXH_FORCE_ALIGN_CHECK 0
+# else
+# define XXH_FORCE_ALIGN_CHECK 1
+# endif
+#endif
+
+
+/* *************************************
+* Includes & Memory related functions
+***************************************/
+/* Modify the local functions below should you wish to use some other memory routines */
+/* for malloc(), free() */
+#include <stdlib.h>
+#include <stddef.h> /* size_t */
+static void* XXH_malloc(size_t s) { return malloc(s); }
+static void XXH_free (void* p) { free(p); }
+/* for memcpy() */
+#include <string.h>
+static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); }
+
+#ifndef XXH_STATIC_LINKING_ONLY
+# define XXH_STATIC_LINKING_ONLY
+#endif
+#include "xxhash.h"
+
+
+/* *************************************
+* Compiler Specific Options
+***************************************/
+#if defined (__GNUC__) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
+# define INLINE_KEYWORD inline
+#else
+# define INLINE_KEYWORD
+#endif
+
+#if defined(__GNUC__)
+# define FORCE_INLINE_ATTR __attribute__((always_inline))
+#elif defined(_MSC_VER)
+# define FORCE_INLINE_ATTR __forceinline
+#else
+# define FORCE_INLINE_ATTR
+#endif
+
+#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR
+
+
+#ifdef _MSC_VER
+# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
+#endif
+
+
+/* *************************************
+* Basic Types
+***************************************/
+#ifndef MEM_MODULE
+# define MEM_MODULE
+# if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
+# include <stdint.h>
+ typedef uint8_t BYTE;
+ typedef uint16_t U16;
+ typedef uint32_t U32;
+ typedef int32_t S32;
+ typedef uint64_t U64;
+# else
+ typedef unsigned char BYTE;
+ typedef unsigned short U16;
+ typedef unsigned int U32;
+ typedef signed int S32;
+ typedef unsigned long long U64; /* if your compiler doesn't support unsigned long long, replace by another 64-bit type here. Note that xxhash.h will also need to be updated. */
+# endif
+#endif
+
+
+#if (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==2))
+
+/* Force direct memory access. Only works on CPU which support unaligned memory access in hardware */
+static U32 XXH_read32(const void* memPtr) { return *(const U32*) memPtr; }
+static U64 XXH_read64(const void* memPtr) { return *(const U64*) memPtr; }
+
+#elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1))
+
+/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
+/* currently only defined for gcc and icc */
+typedef union { U32 u32; U64 u64; } __attribute__((packed)) unalign;
+
+static U32 XXH_read32(const void* ptr) { return ((const unalign*)ptr)->u32; }
+static U64 XXH_read64(const void* ptr) { return ((const unalign*)ptr)->u64; }
+
+#else
+
+/* portable and safe solution. Generally efficient.
+ * see : http://stackoverflow.com/a/32095106/646947
+ */
+
+static U32 XXH_read32(const void* memPtr)
+{
+ U32 val;
+ memcpy(&val, memPtr, sizeof(val));
+ return val;
+}
+
+static U64 XXH_read64(const void* memPtr)
+{
+ U64 val;
+ memcpy(&val, memPtr, sizeof(val));
+ return val;
+}
+
+#endif /* XXH_FORCE_DIRECT_MEMORY_ACCESS */
+
+
+/* ****************************************
+* Compiler-specific Functions and Macros
+******************************************/
+#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+
+/* Note : although _rotl exists for minGW (GCC under windows), performance seems poor */
+#if defined(_MSC_VER)
+# define XXH_rotl32(x,r) _rotl(x,r)
+# define XXH_rotl64(x,r) _rotl64(x,r)
+#else
+# define XXH_rotl32(x,r) ((x << r) | (x >> (32 - r)))
+# define XXH_rotl64(x,r) ((x << r) | (x >> (64 - r)))
+#endif
+
+#if defined(_MSC_VER) /* Visual Studio */
+# define XXH_swap32 _byteswap_ulong
+# define XXH_swap64 _byteswap_uint64
+#elif GCC_VERSION >= 403
+# define XXH_swap32 __builtin_bswap32
+# define XXH_swap64 __builtin_bswap64
+#else
+static U32 XXH_swap32 (U32 x)
+{
+ return ((x << 24) & 0xff000000 ) |
+ ((x << 8) & 0x00ff0000 ) |
+ ((x >> 8) & 0x0000ff00 ) |
+ ((x >> 24) & 0x000000ff );
+}
+static U64 XXH_swap64 (U64 x)
+{
+ return ((x << 56) & 0xff00000000000000ULL) |
+ ((x << 40) & 0x00ff000000000000ULL) |
+ ((x << 24) & 0x0000ff0000000000ULL) |
+ ((x << 8) & 0x000000ff00000000ULL) |
+ ((x >> 8) & 0x00000000ff000000ULL) |
+ ((x >> 24) & 0x0000000000ff0000ULL) |
+ ((x >> 40) & 0x000000000000ff00ULL) |
+ ((x >> 56) & 0x00000000000000ffULL);
+}
+#endif
+
+
+/* *************************************
+* Architecture Macros
+***************************************/
+typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess;
+
+/* XXH_CPU_LITTLE_ENDIAN can be defined externally, for example on the compiler command line */
+#ifndef XXH_CPU_LITTLE_ENDIAN
+ static const int g_one = 1;
+# define XXH_CPU_LITTLE_ENDIAN (*(const char*)(&g_one))
+#endif
+
+
+/* ***************************
+* Memory reads
+*****************************/
+typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment;
+
+FORCE_INLINE_TEMPLATE U32 XXH_readLE32_align(const void* ptr, XXH_endianess endian, XXH_alignment align)
+{
+ if (align==XXH_unaligned)
+ return endian==XXH_littleEndian ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr));
+ else
+ return endian==XXH_littleEndian ? *(const U32*)ptr : XXH_swap32(*(const U32*)ptr);
+}
+
+FORCE_INLINE_TEMPLATE U32 XXH_readLE32(const void* ptr, XXH_endianess endian)
+{
+ return XXH_readLE32_align(ptr, endian, XXH_unaligned);
+}
+
+static U32 XXH_readBE32(const void* ptr)
+{
+ return XXH_CPU_LITTLE_ENDIAN ? XXH_swap32(XXH_read32(ptr)) : XXH_read32(ptr);
+}
+
+FORCE_INLINE_TEMPLATE U64 XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_alignment align)
+{
+ if (align==XXH_unaligned)
+ return endian==XXH_littleEndian ? XXH_read64(ptr) : XXH_swap64(XXH_read64(ptr));
+ else
+ return endian==XXH_littleEndian ? *(const U64*)ptr : XXH_swap64(*(const U64*)ptr);
+}
+
+FORCE_INLINE_TEMPLATE U64 XXH_readLE64(const void* ptr, XXH_endianess endian)
+{
+ return XXH_readLE64_align(ptr, endian, XXH_unaligned);
+}
+
+static U64 XXH_readBE64(const void* ptr)
+{
+ return XXH_CPU_LITTLE_ENDIAN ? XXH_swap64(XXH_read64(ptr)) : XXH_read64(ptr);
+}
+
+
+/* *************************************
+* Macros
+***************************************/
+#define XXH_STATIC_ASSERT(c) { enum { XXH_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
+
+
+/* *************************************
+* Constants
+***************************************/
+static const U32 PRIME32_1 = 2654435761U;
+static const U32 PRIME32_2 = 2246822519U;
+static const U32 PRIME32_3 = 3266489917U;
+static const U32 PRIME32_4 = 668265263U;
+static const U32 PRIME32_5 = 374761393U;
+
+static const U64 PRIME64_1 = 11400714785074694791ULL;
+static const U64 PRIME64_2 = 14029467366897019727ULL;
+static const U64 PRIME64_3 = 1609587929392839161ULL;
+static const U64 PRIME64_4 = 9650029242287828579ULL;
+static const U64 PRIME64_5 = 2870177450012600261ULL;
+
+XXH_PUBLIC_API unsigned XXH_versionNumber (void) { return XXH_VERSION_NUMBER; }
+
+
+/* **************************
+* Utils
+****************************/
+XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* restrict dstState, const XXH32_state_t* restrict srcState)
+{
+ memcpy(dstState, srcState, sizeof(*dstState));
+}
+
+XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* restrict dstState, const XXH64_state_t* restrict srcState)
+{
+ memcpy(dstState, srcState, sizeof(*dstState));
+}
+
+
+/* ***************************
+* Simple Hash Functions
+*****************************/
+
+static U32 XXH32_round(U32 seed, U32 input)
+{
+ seed += input * PRIME32_2;
+ seed = XXH_rotl32(seed, 13);
+ seed *= PRIME32_1;
+ return seed;
+}
+
+FORCE_INLINE_TEMPLATE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align)
+{
+ const BYTE* p = (const BYTE*)input;
+ const BYTE* bEnd = p + len;
+ U32 h32;
+#define XXH_get32bits(p) XXH_readLE32_align(p, endian, align)
+
+#ifdef XXH_ACCEPT_NULL_INPUT_POINTER
+ if (p==NULL) {
+ len=0;
+ bEnd=p=(const BYTE*)(size_t)16;
+ }
+#endif
+
+ if (len>=16) {
+ const BYTE* const limit = bEnd - 16;
+ U32 v1 = seed + PRIME32_1 + PRIME32_2;
+ U32 v2 = seed + PRIME32_2;
+ U32 v3 = seed + 0;
+ U32 v4 = seed - PRIME32_1;
+
+ do {
+ v1 = XXH32_round(v1, XXH_get32bits(p)); p+=4;
+ v2 = XXH32_round(v2, XXH_get32bits(p)); p+=4;
+ v3 = XXH32_round(v3, XXH_get32bits(p)); p+=4;
+ v4 = XXH32_round(v4, XXH_get32bits(p)); p+=4;
+ } while (p<=limit);
+
+ h32 = XXH_rotl32(v1, 1) + XXH_rotl32(v2, 7) + XXH_rotl32(v3, 12) + XXH_rotl32(v4, 18);
+ } else {
+ h32 = seed + PRIME32_5;
+ }
+
+ h32 += (U32) len;
+
+ while (p+4<=bEnd) {
+ h32 += XXH_get32bits(p) * PRIME32_3;
+ h32 = XXH_rotl32(h32, 17) * PRIME32_4 ;
+ p+=4;
+ }
+
+ while (p<bEnd) {
+ h32 += (*p) * PRIME32_5;
+ h32 = XXH_rotl32(h32, 11) * PRIME32_1 ;
+ p++;
+ }
+
+ h32 ^= h32 >> 15;
+ h32 *= PRIME32_2;
+ h32 ^= h32 >> 13;
+ h32 *= PRIME32_3;
+ h32 ^= h32 >> 16;
+
+ return h32;
+}
+
+
+XXH_PUBLIC_API unsigned int XXH32 (const void* input, size_t len, unsigned int seed)
+{
+#if 0
+ /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
+ XXH32_CREATESTATE_STATIC(state);
+ XXH32_reset(state, seed);
+ XXH32_update(state, input, len);
+ return XXH32_digest(state);
+#else
+ XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
+
+ if (XXH_FORCE_ALIGN_CHECK) {
+ if ((((size_t)input) & 3) == 0) { /* Input is 4-bytes aligned, leverage the speed benefit */
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned);
+ else
+ return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_aligned);
+ } }
+
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH32_endian_align(input, len, seed, XXH_littleEndian, XXH_unaligned);
+ else
+ return XXH32_endian_align(input, len, seed, XXH_bigEndian, XXH_unaligned);
+#endif
+}
+
+
+static U64 XXH64_round(U64 acc, U64 input)
+{
+ acc += input * PRIME64_2;
+ acc = XXH_rotl64(acc, 31);
+ acc *= PRIME64_1;
+ return acc;
+}
+
+static U64 XXH64_mergeRound(U64 acc, U64 val)
+{
+ val = XXH64_round(0, val);
+ acc ^= val;
+ acc = acc * PRIME64_1 + PRIME64_4;
+ return acc;
+}
+
+FORCE_INLINE_TEMPLATE U64 XXH64_endian_align(const void* input, size_t len, U64 seed, XXH_endianess endian, XXH_alignment align)
+{
+ const BYTE* p = (const BYTE*)input;
+ const BYTE* const bEnd = p + len;
+ U64 h64;
+#define XXH_get64bits(p) XXH_readLE64_align(p, endian, align)
+
+#ifdef XXH_ACCEPT_NULL_INPUT_POINTER
+ if (p==NULL) {
+ len=0;
+ bEnd=p=(const BYTE*)(size_t)32;
+ }
+#endif
+
+ if (len>=32) {
+ const BYTE* const limit = bEnd - 32;
+ U64 v1 = seed + PRIME64_1 + PRIME64_2;
+ U64 v2 = seed + PRIME64_2;
+ U64 v3 = seed + 0;
+ U64 v4 = seed - PRIME64_1;
+
+ do {
+ v1 = XXH64_round(v1, XXH_get64bits(p)); p+=8;
+ v2 = XXH64_round(v2, XXH_get64bits(p)); p+=8;
+ v3 = XXH64_round(v3, XXH_get64bits(p)); p+=8;
+ v4 = XXH64_round(v4, XXH_get64bits(p)); p+=8;
+ } while (p<=limit);
+
+ h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18);
+ h64 = XXH64_mergeRound(h64, v1);
+ h64 = XXH64_mergeRound(h64, v2);
+ h64 = XXH64_mergeRound(h64, v3);
+ h64 = XXH64_mergeRound(h64, v4);
+
+ } else {
+ h64 = seed + PRIME64_5;
+ }
+
+ h64 += (U64) len;
+
+ while (p+8<=bEnd) {
+ U64 const k1 = XXH64_round(0, XXH_get64bits(p));
+ h64 ^= k1;
+ h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4;
+ p+=8;
+ }
+
+ if (p+4<=bEnd) {
+ h64 ^= (U64)(XXH_get32bits(p)) * PRIME64_1;
+ h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3;
+ p+=4;
+ }
+
+ while (p<bEnd) {
+ h64 ^= (*p) * PRIME64_5;
+ h64 = XXH_rotl64(h64, 11) * PRIME64_1;
+ p++;
+ }
+
+ h64 ^= h64 >> 33;
+ h64 *= PRIME64_2;
+ h64 ^= h64 >> 29;
+ h64 *= PRIME64_3;
+ h64 ^= h64 >> 32;
+
+ return h64;
+}
+
+
+XXH_PUBLIC_API unsigned long long XXH64 (const void* input, size_t len, unsigned long long seed)
+{
+#if 0
+ /* Simple version, good for code maintenance, but unfortunately slow for small inputs */
+ XXH64_CREATESTATE_STATIC(state);
+ XXH64_reset(state, seed);
+ XXH64_update(state, input, len);
+ return XXH64_digest(state);
+#else
+ XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
+
+ if (XXH_FORCE_ALIGN_CHECK) {
+ if ((((size_t)input) & 7)==0) { /* Input is aligned, let's leverage the speed advantage */
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH64_endian_align(input, len, seed, XXH_littleEndian, XXH_aligned);
+ else
+ return XXH64_endian_align(input, len, seed, XXH_bigEndian, XXH_aligned);
+ } }
+
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH64_endian_align(input, len, seed, XXH_littleEndian, XXH_unaligned);
+ else
+ return XXH64_endian_align(input, len, seed, XXH_bigEndian, XXH_unaligned);
+#endif
+}
+
+
+/* **************************************************
+* Advanced Hash Functions
+****************************************************/
+
+XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void)
+{
+ return (XXH32_state_t*)XXH_malloc(sizeof(XXH32_state_t));
+}
+XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr)
+{
+ XXH_free(statePtr);
+ return XXH_OK;
+}
+
+XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void)
+{
+ return (XXH64_state_t*)XXH_malloc(sizeof(XXH64_state_t));
+}
+XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr)
+{
+ XXH_free(statePtr);
+ return XXH_OK;
+}
+
+
+/*** Hash feed ***/
+
+XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t* statePtr, unsigned int seed)
+{
+ XXH32_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
+ memset(&state, 0, sizeof(state)-4); /* do not write into reserved, for future removal */
+ state.v1 = seed + PRIME32_1 + PRIME32_2;
+ state.v2 = seed + PRIME32_2;
+ state.v3 = seed + 0;
+ state.v4 = seed - PRIME32_1;
+ memcpy(statePtr, &state, sizeof(state));
+ return XXH_OK;
+}
+
+
+XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t* statePtr, unsigned long long seed)
+{
+ XXH64_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */
+ memset(&state, 0, sizeof(state)-8); /* do not write into reserved, for future removal */
+ state.v1 = seed + PRIME64_1 + PRIME64_2;
+ state.v2 = seed + PRIME64_2;
+ state.v3 = seed + 0;
+ state.v4 = seed - PRIME64_1;
+ memcpy(statePtr, &state, sizeof(state));
+ return XXH_OK;
+}
+
+
+FORCE_INLINE_TEMPLATE XXH_errorcode XXH32_update_endian (XXH32_state_t* state, const void* input, size_t len, XXH_endianess endian)
+{
+ const BYTE* p = (const BYTE*)input;
+ const BYTE* const bEnd = p + len;
+
+#ifdef XXH_ACCEPT_NULL_INPUT_POINTER
+ if (input==NULL) return XXH_ERROR;
+#endif
+
+ state->total_len_32 += (unsigned)len;
+ state->large_len |= (len>=16) | (state->total_len_32>=16);
+
+ if (state->memsize + len < 16) { /* fill in tmp buffer */
+ XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, len);
+ state->memsize += (unsigned)len;
+ return XXH_OK;
+ }
+
+ if (state->memsize) { /* some data left from previous update */
+ XXH_memcpy((BYTE*)(state->mem32) + state->memsize, input, 16-state->memsize);
+ { const U32* p32 = state->mem32;
+ state->v1 = XXH32_round(state->v1, XXH_readLE32(p32, endian)); p32++;
+ state->v2 = XXH32_round(state->v2, XXH_readLE32(p32, endian)); p32++;
+ state->v3 = XXH32_round(state->v3, XXH_readLE32(p32, endian)); p32++;
+ state->v4 = XXH32_round(state->v4, XXH_readLE32(p32, endian)); p32++;
+ }
+ p += 16-state->memsize;
+ state->memsize = 0;
+ }
+
+ if (p <= bEnd-16) {
+ const BYTE* const limit = bEnd - 16;
+ U32 v1 = state->v1;
+ U32 v2 = state->v2;
+ U32 v3 = state->v3;
+ U32 v4 = state->v4;
+
+ do {
+ v1 = XXH32_round(v1, XXH_readLE32(p, endian)); p+=4;
+ v2 = XXH32_round(v2, XXH_readLE32(p, endian)); p+=4;
+ v3 = XXH32_round(v3, XXH_readLE32(p, endian)); p+=4;
+ v4 = XXH32_round(v4, XXH_readLE32(p, endian)); p+=4;
+ } while (p<=limit);
+
+ state->v1 = v1;
+ state->v2 = v2;
+ state->v3 = v3;
+ state->v4 = v4;
+ }
+
+ if (p < bEnd) {
+ XXH_memcpy(state->mem32, p, (size_t)(bEnd-p));
+ state->memsize = (unsigned)(bEnd-p);
+ }
+
+ return XXH_OK;
+}
+
+XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* state_in, const void* input, size_t len)
+{
+ XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
+
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH32_update_endian(state_in, input, len, XXH_littleEndian);
+ else
+ return XXH32_update_endian(state_in, input, len, XXH_bigEndian);
+}
+
+
+
+FORCE_INLINE_TEMPLATE U32 XXH32_digest_endian (const XXH32_state_t* state, XXH_endianess endian)
+{
+ const BYTE * p = (const BYTE*)state->mem32;
+ const BYTE* const bEnd = (const BYTE*)(state->mem32) + state->memsize;
+ U32 h32;
+
+ if (state->large_len) {
+ h32 = XXH_rotl32(state->v1, 1) + XXH_rotl32(state->v2, 7) + XXH_rotl32(state->v3, 12) + XXH_rotl32(state->v4, 18);
+ } else {
+ h32 = state->v3 /* == seed */ + PRIME32_5;
+ }
+
+ h32 += state->total_len_32;
+
+ while (p+4<=bEnd) {
+ h32 += XXH_readLE32(p, endian) * PRIME32_3;
+ h32 = XXH_rotl32(h32, 17) * PRIME32_4;
+ p+=4;
+ }
+
+ while (p<bEnd) {
+ h32 += (*p) * PRIME32_5;
+ h32 = XXH_rotl32(h32, 11) * PRIME32_1;
+ p++;
+ }
+
+ h32 ^= h32 >> 15;
+ h32 *= PRIME32_2;
+ h32 ^= h32 >> 13;
+ h32 *= PRIME32_3;
+ h32 ^= h32 >> 16;
+
+ return h32;
+}
+
+
+XXH_PUBLIC_API unsigned int XXH32_digest (const XXH32_state_t* state_in)
+{
+ XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
+
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH32_digest_endian(state_in, XXH_littleEndian);
+ else
+ return XXH32_digest_endian(state_in, XXH_bigEndian);
+}
+
+
+
+/* **** XXH64 **** */
+
+FORCE_INLINE_TEMPLATE XXH_errorcode XXH64_update_endian (XXH64_state_t* state, const void* input, size_t len, XXH_endianess endian)
+{
+ const BYTE* p = (const BYTE*)input;
+ const BYTE* const bEnd = p + len;
+
+#ifdef XXH_ACCEPT_NULL_INPUT_POINTER
+ if (input==NULL) return XXH_ERROR;
+#endif
+
+ state->total_len += len;
+
+ if (state->memsize + len < 32) { /* fill in tmp buffer */
+ XXH_memcpy(((BYTE*)state->mem64) + state->memsize, input, len);
+ state->memsize += (U32)len;
+ return XXH_OK;
+ }
+
+ if (state->memsize) { /* tmp buffer is full */
+ XXH_memcpy(((BYTE*)state->mem64) + state->memsize, input, 32-state->memsize);
+ state->v1 = XXH64_round(state->v1, XXH_readLE64(state->mem64+0, endian));
+ state->v2 = XXH64_round(state->v2, XXH_readLE64(state->mem64+1, endian));
+ state->v3 = XXH64_round(state->v3, XXH_readLE64(state->mem64+2, endian));
+ state->v4 = XXH64_round(state->v4, XXH_readLE64(state->mem64+3, endian));
+ p += 32-state->memsize;
+ state->memsize = 0;
+ }
+
+ if (p+32 <= bEnd) {
+ const BYTE* const limit = bEnd - 32;
+ U64 v1 = state->v1;
+ U64 v2 = state->v2;
+ U64 v3 = state->v3;
+ U64 v4 = state->v4;
+
+ do {
+ v1 = XXH64_round(v1, XXH_readLE64(p, endian)); p+=8;
+ v2 = XXH64_round(v2, XXH_readLE64(p, endian)); p+=8;
+ v3 = XXH64_round(v3, XXH_readLE64(p, endian)); p+=8;
+ v4 = XXH64_round(v4, XXH_readLE64(p, endian)); p+=8;
+ } while (p<=limit);
+
+ state->v1 = v1;
+ state->v2 = v2;
+ state->v3 = v3;
+ state->v4 = v4;
+ }
+
+ if (p < bEnd) {
+ XXH_memcpy(state->mem64, p, (size_t)(bEnd-p));
+ state->memsize = (unsigned)(bEnd-p);
+ }
+
+ return XXH_OK;
+}
+
+XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* state_in, const void* input, size_t len)
+{
+ XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
+
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH64_update_endian(state_in, input, len, XXH_littleEndian);
+ else
+ return XXH64_update_endian(state_in, input, len, XXH_bigEndian);
+}
+
+
+
+FORCE_INLINE_TEMPLATE U64 XXH64_digest_endian (const XXH64_state_t* state, XXH_endianess endian)
+{
+ const BYTE * p = (const BYTE*)state->mem64;
+ const BYTE* const bEnd = (const BYTE*)state->mem64 + state->memsize;
+ U64 h64;
+
+ if (state->total_len >= 32) {
+ U64 const v1 = state->v1;
+ U64 const v2 = state->v2;
+ U64 const v3 = state->v3;
+ U64 const v4 = state->v4;
+
+ h64 = XXH_rotl64(v1, 1) + XXH_rotl64(v2, 7) + XXH_rotl64(v3, 12) + XXH_rotl64(v4, 18);
+ h64 = XXH64_mergeRound(h64, v1);
+ h64 = XXH64_mergeRound(h64, v2);
+ h64 = XXH64_mergeRound(h64, v3);
+ h64 = XXH64_mergeRound(h64, v4);
+ } else {
+ h64 = state->v3 + PRIME64_5;
+ }
+
+ h64 += (U64) state->total_len;
+
+ while (p+8<=bEnd) {
+ U64 const k1 = XXH64_round(0, XXH_readLE64(p, endian));
+ h64 ^= k1;
+ h64 = XXH_rotl64(h64,27) * PRIME64_1 + PRIME64_4;
+ p+=8;
+ }
+
+ if (p+4<=bEnd) {
+ h64 ^= (U64)(XXH_readLE32(p, endian)) * PRIME64_1;
+ h64 = XXH_rotl64(h64, 23) * PRIME64_2 + PRIME64_3;
+ p+=4;
+ }
+
+ while (p<bEnd) {
+ h64 ^= (*p) * PRIME64_5;
+ h64 = XXH_rotl64(h64, 11) * PRIME64_1;
+ p++;
+ }
+
+ h64 ^= h64 >> 33;
+ h64 *= PRIME64_2;
+ h64 ^= h64 >> 29;
+ h64 *= PRIME64_3;
+ h64 ^= h64 >> 32;
+
+ return h64;
+}
+
+
+XXH_PUBLIC_API unsigned long long XXH64_digest (const XXH64_state_t* state_in)
+{
+ XXH_endianess endian_detected = (XXH_endianess)XXH_CPU_LITTLE_ENDIAN;
+
+ if ((endian_detected==XXH_littleEndian) || XXH_FORCE_NATIVE_FORMAT)
+ return XXH64_digest_endian(state_in, XXH_littleEndian);
+ else
+ return XXH64_digest_endian(state_in, XXH_bigEndian);
+}
+
+
+/* **************************
+* Canonical representation
+****************************/
+
+/*! Default XXH result types are basic unsigned 32 and 64 bits.
+* The canonical representation follows human-readable write convention, aka big-endian (large digits first).
+* These functions allow transformation of hash result into and from its canonical format.
+* This way, hash values can be written into a file or buffer, and remain comparable across different systems and programs.
+*/
+
+XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash)
+{
+ XXH_STATIC_ASSERT(sizeof(XXH32_canonical_t) == sizeof(XXH32_hash_t));
+ if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap32(hash);
+ memcpy(dst, &hash, sizeof(*dst));
+}
+
+XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash)
+{
+ XXH_STATIC_ASSERT(sizeof(XXH64_canonical_t) == sizeof(XXH64_hash_t));
+ if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap64(hash);
+ memcpy(dst, &hash, sizeof(*dst));
+}
+
+XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src)
+{
+ return XXH_readBE32(src);
+}
+
+XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src)
+{
+ return XXH_readBE64(src);
+}
diff --git a/Utilities/cmzstd/lib/common/xxhash.h b/Utilities/cmzstd/lib/common/xxhash.h
new file mode 100644
index 000000000..9bad1f59f
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/xxhash.h
@@ -0,0 +1,305 @@
+/*
+ xxHash - Extremely Fast Hash algorithm
+ Header File
+ Copyright (C) 2012-2016, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - xxHash source repository : https://github.com/Cyan4973/xxHash
+*/
+
+/* Notice extracted from xxHash homepage :
+
+xxHash is an extremely fast Hash algorithm, running at RAM speed limits.
+It also successfully passes all tests from the SMHasher suite.
+
+Comparison (single thread, Windows Seven 32 bits, using SMHasher on a Core 2 Duo @3GHz)
+
+Name Speed Q.Score Author
+xxHash 5.4 GB/s 10
+CrapWow 3.2 GB/s 2 Andrew
+MumurHash 3a 2.7 GB/s 10 Austin Appleby
+SpookyHash 2.0 GB/s 10 Bob Jenkins
+SBox 1.4 GB/s 9 Bret Mulvey
+Lookup3 1.2 GB/s 9 Bob Jenkins
+SuperFastHash 1.2 GB/s 1 Paul Hsieh
+CityHash64 1.05 GB/s 10 Pike & Alakuijala
+FNV 0.55 GB/s 5 Fowler, Noll, Vo
+CRC32 0.43 GB/s 9
+MD5-32 0.33 GB/s 10 Ronald L. Rivest
+SHA1-32 0.28 GB/s 10
+
+Q.Score is a measure of quality of the hash function.
+It depends on successfully passing SMHasher test set.
+10 is a perfect score.
+
+A 64-bits version, named XXH64, is available since r35.
+It offers much better speed, but for 64-bits applications only.
+Name Speed on 64 bits Speed on 32 bits
+XXH64 13.8 GB/s 1.9 GB/s
+XXH32 6.8 GB/s 6.0 GB/s
+*/
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#ifndef XXHASH_H_5627135585666179
+#define XXHASH_H_5627135585666179 1
+
+
+/* ****************************
+* Definitions
+******************************/
+#include <stddef.h> /* size_t */
+typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode;
+
+
+/* ****************************
+* API modifier
+******************************/
+/** XXH_PRIVATE_API
+* This is useful if you want to include xxhash functions in `static` mode
+* in order to inline them, and remove their symbol from the public list.
+* Methodology :
+* #define XXH_PRIVATE_API
+* #include "xxhash.h"
+* `xxhash.c` is automatically included.
+* It's not useful to compile and link it as a separate module anymore.
+*/
+#ifdef XXH_PRIVATE_API
+# ifndef XXH_STATIC_LINKING_ONLY
+# define XXH_STATIC_LINKING_ONLY
+# endif
+# if defined(__GNUC__)
+# define XXH_PUBLIC_API static __inline __attribute__((unused))
+# elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
+# define XXH_PUBLIC_API static inline
+# elif defined(_MSC_VER)
+# define XXH_PUBLIC_API static __inline
+# else
+# define XXH_PUBLIC_API static /* this version may generate warnings for unused static functions; disable the relevant warning */
+# endif
+#else
+# define XXH_PUBLIC_API /* do nothing */
+#endif /* XXH_PRIVATE_API */
+
+/*!XXH_NAMESPACE, aka Namespace Emulation :
+
+If you want to include _and expose_ xxHash functions from within your own library,
+but also want to avoid symbol collisions with another library which also includes xxHash,
+
+you can use XXH_NAMESPACE, to automatically prefix any public symbol from xxhash library
+with the value of XXH_NAMESPACE (so avoid to keep it NULL and avoid numeric values).
+
+Note that no change is required within the calling program as long as it includes `xxhash.h` :
+regular symbol name will be automatically translated by this header.
+*/
+#ifdef XXH_NAMESPACE
+# define XXH_CAT(A,B) A##B
+# define XXH_NAME2(A,B) XXH_CAT(A,B)
+# define XXH32 XXH_NAME2(XXH_NAMESPACE, XXH32)
+# define XXH64 XXH_NAME2(XXH_NAMESPACE, XXH64)
+# define XXH_versionNumber XXH_NAME2(XXH_NAMESPACE, XXH_versionNumber)
+# define XXH32_createState XXH_NAME2(XXH_NAMESPACE, XXH32_createState)
+# define XXH64_createState XXH_NAME2(XXH_NAMESPACE, XXH64_createState)
+# define XXH32_freeState XXH_NAME2(XXH_NAMESPACE, XXH32_freeState)
+# define XXH64_freeState XXH_NAME2(XXH_NAMESPACE, XXH64_freeState)
+# define XXH32_reset XXH_NAME2(XXH_NAMESPACE, XXH32_reset)
+# define XXH64_reset XXH_NAME2(XXH_NAMESPACE, XXH64_reset)
+# define XXH32_update XXH_NAME2(XXH_NAMESPACE, XXH32_update)
+# define XXH64_update XXH_NAME2(XXH_NAMESPACE, XXH64_update)
+# define XXH32_digest XXH_NAME2(XXH_NAMESPACE, XXH32_digest)
+# define XXH64_digest XXH_NAME2(XXH_NAMESPACE, XXH64_digest)
+# define XXH32_copyState XXH_NAME2(XXH_NAMESPACE, XXH32_copyState)
+# define XXH64_copyState XXH_NAME2(XXH_NAMESPACE, XXH64_copyState)
+# define XXH32_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH32_canonicalFromHash)
+# define XXH64_canonicalFromHash XXH_NAME2(XXH_NAMESPACE, XXH64_canonicalFromHash)
+# define XXH32_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH32_hashFromCanonical)
+# define XXH64_hashFromCanonical XXH_NAME2(XXH_NAMESPACE, XXH64_hashFromCanonical)
+#endif
+
+
+/* *************************************
+* Version
+***************************************/
+#define XXH_VERSION_MAJOR 0
+#define XXH_VERSION_MINOR 6
+#define XXH_VERSION_RELEASE 2
+#define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE)
+XXH_PUBLIC_API unsigned XXH_versionNumber (void);
+
+
+/* ****************************
+* Simple Hash Functions
+******************************/
+typedef unsigned int XXH32_hash_t;
+typedef unsigned long long XXH64_hash_t;
+
+XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t length, unsigned int seed);
+XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t length, unsigned long long seed);
+
+/*!
+XXH32() :
+ Calculate the 32-bits hash of sequence "length" bytes stored at memory address "input".
+ The memory between input & input+length must be valid (allocated and read-accessible).
+ "seed" can be used to alter the result predictably.
+ Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark) : 5.4 GB/s
+XXH64() :
+ Calculate the 64-bits hash of sequence of length "len" stored at memory address "input".
+ "seed" can be used to alter the result predictably.
+ This function runs 2x faster on 64-bits systems, but slower on 32-bits systems (see benchmark).
+*/
+
+
+/* ****************************
+* Streaming Hash Functions
+******************************/
+typedef struct XXH32_state_s XXH32_state_t; /* incomplete type */
+typedef struct XXH64_state_s XXH64_state_t; /* incomplete type */
+
+/*! State allocation, compatible with dynamic libraries */
+
+XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void);
+XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr);
+
+XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void);
+XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr);
+
+
+/* hash streaming */
+
+XXH_PUBLIC_API XXH_errorcode XXH32_reset (XXH32_state_t* statePtr, unsigned int seed);
+XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void* input, size_t length);
+XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t* statePtr);
+
+XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, unsigned long long seed);
+XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length);
+XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* statePtr);
+
+/*
+These functions generate the xxHash of an input provided in multiple segments.
+Note that, for small input, they are slower than single-call functions, due to state management.
+For small input, prefer `XXH32()` and `XXH64()` .
+
+XXH state must first be allocated, using XXH*_createState() .
+
+Start a new hash by initializing state with a seed, using XXH*_reset().
+
+Then, feed the hash state by calling XXH*_update() as many times as necessary.
+Obviously, input must be allocated and read accessible.
+The function returns an error code, with 0 meaning OK, and any other value meaning there is an error.
+
+Finally, a hash value can be produced anytime, by using XXH*_digest().
+This function returns the nn-bits hash as an int or long long.
+
+It's still possible to continue inserting input into the hash state after a digest,
+and generate some new hashes later on, by calling again XXH*_digest().
+
+When done, free XXH state space if it was allocated dynamically.
+*/
+
+
+/* **************************
+* Utils
+****************************/
+#if !(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) /* ! C99 */
+# define restrict /* disable restrict */
+#endif
+
+XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* restrict dst_state, const XXH32_state_t* restrict src_state);
+XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* restrict dst_state, const XXH64_state_t* restrict src_state);
+
+
+/* **************************
+* Canonical representation
+****************************/
+/* Default result type for XXH functions are primitive unsigned 32 and 64 bits.
+* The canonical representation uses human-readable write convention, aka big-endian (large digits first).
+* These functions allow transformation of hash result into and from its canonical format.
+* This way, hash values can be written into a file / memory, and remain comparable on different systems and programs.
+*/
+typedef struct { unsigned char digest[4]; } XXH32_canonical_t;
+typedef struct { unsigned char digest[8]; } XXH64_canonical_t;
+
+XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t hash);
+XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash);
+
+XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src);
+XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src);
+
+#endif /* XXHASH_H_5627135585666179 */
+
+
+
+/* ================================================================================================
+ This section contains definitions which are not guaranteed to remain stable.
+ They may change in future versions, becoming incompatible with a different version of the library.
+ They shall only be used with static linking.
+ Never use these definitions in association with dynamic linking !
+=================================================================================================== */
+#if defined(XXH_STATIC_LINKING_ONLY) && !defined(XXH_STATIC_H_3543687687345)
+#define XXH_STATIC_H_3543687687345
+
+/* These definitions are only meant to allow allocation of XXH state
+ statically, on stack, or in a struct for example.
+ Do not use members directly. */
+
+ struct XXH32_state_s {
+ unsigned total_len_32;
+ unsigned large_len;
+ unsigned v1;
+ unsigned v2;
+ unsigned v3;
+ unsigned v4;
+ unsigned mem32[4]; /* buffer defined as U32 for alignment */
+ unsigned memsize;
+ unsigned reserved; /* never read nor write, will be removed in a future version */
+ }; /* typedef'd to XXH32_state_t */
+
+ struct XXH64_state_s {
+ unsigned long long total_len;
+ unsigned long long v1;
+ unsigned long long v2;
+ unsigned long long v3;
+ unsigned long long v4;
+ unsigned long long mem64[4]; /* buffer defined as U64 for alignment */
+ unsigned memsize;
+ unsigned reserved[2]; /* never read nor write, will be removed in a future version */
+ }; /* typedef'd to XXH64_state_t */
+
+
+# ifdef XXH_PRIVATE_API
+# include "xxhash.c" /* include xxhash functions as `static`, for inlining */
+# endif
+
+#endif /* XXH_STATIC_LINKING_ONLY && XXH_STATIC_H_3543687687345 */
+
+
+#if defined (__cplusplus)
+}
+#endif
diff --git a/Utilities/cmzstd/lib/common/zstd_common.c b/Utilities/cmzstd/lib/common/zstd_common.c
new file mode 100644
index 000000000..667f4a27f
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/zstd_common.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+
+
+/*-*************************************
+* Dependencies
+***************************************/
+#include <stdlib.h> /* malloc, calloc, free */
+#include <string.h> /* memset */
+#include "error_private.h"
+#include "zstd_internal.h"
+
+
+/*-****************************************
+* Version
+******************************************/
+unsigned ZSTD_versionNumber(void) { return ZSTD_VERSION_NUMBER; }
+
+const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; }
+
+
+/*-****************************************
+* ZSTD Error Management
+******************************************/
+#undef ZSTD_isError /* defined within zstd_internal.h */
+/*! ZSTD_isError() :
+ * tells if a return value is an error code
+ * symbol is required for external callers */
+unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
+
+/*! ZSTD_getErrorName() :
+ * provides error code string from function result (useful for debugging) */
+const char* ZSTD_getErrorName(size_t code) { return ERR_getErrorName(code); }
+
+/*! ZSTD_getError() :
+ * convert a `size_t` function result into a proper ZSTD_errorCode enum */
+ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
+
+/*! ZSTD_getErrorString() :
+ * provides error code string from enum */
+const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
+
+
+
+/*=**************************************************************
+* Custom allocator
+****************************************************************/
+void* ZSTD_malloc(size_t size, ZSTD_customMem customMem)
+{
+ if (customMem.customAlloc)
+ return customMem.customAlloc(customMem.opaque, size);
+ return malloc(size);
+}
+
+void* ZSTD_calloc(size_t size, ZSTD_customMem customMem)
+{
+ if (customMem.customAlloc) {
+ /* calloc implemented as malloc+memset;
+ * not as efficient as calloc, but next best guess for custom malloc */
+ void* const ptr = customMem.customAlloc(customMem.opaque, size);
+ memset(ptr, 0, size);
+ return ptr;
+ }
+ return calloc(1, size);
+}
+
+void ZSTD_free(void* ptr, ZSTD_customMem customMem)
+{
+ if (ptr!=NULL) {
+ if (customMem.customFree)
+ customMem.customFree(customMem.opaque, ptr);
+ else
+ free(ptr);
+ }
+}
diff --git a/Utilities/cmzstd/lib/common/zstd_errors.h b/Utilities/cmzstd/lib/common/zstd_errors.h
new file mode 100644
index 000000000..92a343389
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/zstd_errors.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef ZSTD_ERRORS_H_398273423
+#define ZSTD_ERRORS_H_398273423
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/*===== dependency =====*/
+#include <stddef.h> /* size_t */
+
+
+/* ===== ZSTDERRORLIB_API : control library symbols visibility ===== */
+#ifndef ZSTDERRORLIB_VISIBILITY
+# if defined(__GNUC__) && (__GNUC__ >= 4)
+# define ZSTDERRORLIB_VISIBILITY __attribute__ ((visibility ("default")))
+# else
+# define ZSTDERRORLIB_VISIBILITY
+# endif
+#endif
+#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
+# define ZSTDERRORLIB_API __declspec(dllexport) ZSTDERRORLIB_VISIBILITY
+#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
+# define ZSTDERRORLIB_API __declspec(dllimport) ZSTDERRORLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
+#else
+# define ZSTDERRORLIB_API ZSTDERRORLIB_VISIBILITY
+#endif
+
+/*-*********************************************
+ * Error codes list
+ *-*********************************************
+ * Error codes _values_ are pinned down since v1.3.1 only.
+ * Therefore, don't rely on values if you may link to any version < v1.3.1.
+ *
+ * Only values < 100 are considered stable.
+ *
+ * note 1 : this API shall be used with static linking only.
+ * dynamic linking is not yet officially supported.
+ * note 2 : Prefer relying on the enum than on its value whenever possible
+ * This is the only supported way to use the error list < v1.3.1
+ * note 3 : ZSTD_isError() is always correct, whatever the library version.
+ **********************************************/
+typedef enum {
+ ZSTD_error_no_error = 0,
+ ZSTD_error_GENERIC = 1,
+ ZSTD_error_prefix_unknown = 10,
+ ZSTD_error_version_unsupported = 12,
+ ZSTD_error_frameParameter_unsupported = 14,
+ ZSTD_error_frameParameter_windowTooLarge = 16,
+ ZSTD_error_corruption_detected = 20,
+ ZSTD_error_checksum_wrong = 22,
+ ZSTD_error_dictionary_corrupted = 30,
+ ZSTD_error_dictionary_wrong = 32,
+ ZSTD_error_dictionaryCreation_failed = 34,
+ ZSTD_error_parameter_unsupported = 40,
+ ZSTD_error_parameter_outOfBound = 42,
+ ZSTD_error_tableLog_tooLarge = 44,
+ ZSTD_error_maxSymbolValue_tooLarge = 46,
+ ZSTD_error_maxSymbolValue_tooSmall = 48,
+ ZSTD_error_stage_wrong = 60,
+ ZSTD_error_init_missing = 62,
+ ZSTD_error_memory_allocation = 64,
+ ZSTD_error_workSpace_tooSmall= 66,
+ ZSTD_error_dstSize_tooSmall = 70,
+ ZSTD_error_srcSize_wrong = 72,
+ ZSTD_error_dstBuffer_null = 74,
+ /* following error codes are __NOT STABLE__, they can be removed or changed in future versions */
+ ZSTD_error_frameIndex_tooLarge = 100,
+ ZSTD_error_seekableIO = 102,
+ ZSTD_error_maxCode = 120 /* never EVER use this value directly, it can change in future versions! Use ZSTD_isError() instead */
+} ZSTD_ErrorCode;
+
+/*! ZSTD_getErrorCode() :
+ convert a `size_t` function result into a `ZSTD_ErrorCode` enum type,
+ which can be used to compare with enum list published above */
+ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult);
+ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code); /**< Same as ZSTD_getErrorName, but using a `ZSTD_ErrorCode` enum argument */
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* ZSTD_ERRORS_H_398273423 */
diff --git a/Utilities/cmzstd/lib/common/zstd_internal.h b/Utilities/cmzstd/lib/common/zstd_internal.h
new file mode 100644
index 000000000..edeb74b9c
--- /dev/null
+++ b/Utilities/cmzstd/lib/common/zstd_internal.h
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef ZSTD_CCOMMON_H_MODULE
+#define ZSTD_CCOMMON_H_MODULE
+
+/* this module contains definitions which must be identical
+ * across compression, decompression and dictBuilder.
+ * It also contains a few functions useful to at least 2 of them
+ * and which benefit from being inlined */
+
+/*-*************************************
+* Dependencies
+***************************************/
+#include "compiler.h"
+#include "mem.h"
+#include "debug.h" /* assert, DEBUGLOG, RAWLOG, g_debuglevel */
+#include "error_private.h"
+#define ZSTD_STATIC_LINKING_ONLY
+#include "zstd.h"
+#define FSE_STATIC_LINKING_ONLY
+#include "fse.h"
+#define HUF_STATIC_LINKING_ONLY
+#include "huf.h"
+#ifndef XXH_STATIC_LINKING_ONLY
+# define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */
+#endif
+#include "xxhash.h" /* XXH_reset, update, digest */
+
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/* ---- static assert (debug) --- */
+#define ZSTD_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c)
+#define ZSTD_isError ERR_isError /* for inlining */
+#define FSE_isError ERR_isError
+#define HUF_isError ERR_isError
+
+
+/*-*************************************
+* shared macros
+***************************************/
+#undef MIN
+#undef MAX
+#define MIN(a,b) ((a)<(b) ? (a) : (b))
+#define MAX(a,b) ((a)>(b) ? (a) : (b))
+#define CHECK_F(f) { size_t const errcod = f; if (ERR_isError(errcod)) return errcod; } /* check and Forward error code */
+#define CHECK_E(f, e) { size_t const errcod = f; if (ERR_isError(errcod)) return ERROR(e); } /* check and send Error code */
+
+
+/*-*************************************
+* Common constants
+***************************************/
+#define ZSTD_OPT_NUM (1<<12)
+
+#define ZSTD_REP_NUM 3 /* number of repcodes */
+#define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)
+static const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 };
+
+#define KB *(1 <<10)
+#define MB *(1 <<20)
+#define GB *(1U<<30)
+
+#define BIT7 128
+#define BIT6 64
+#define BIT5 32
+#define BIT4 16
+#define BIT1 2
+#define BIT0 1
+
+#define ZSTD_WINDOWLOG_ABSOLUTEMIN 10
+static const size_t ZSTD_fcs_fieldSize[4] = { 0, 2, 4, 8 };
+static const size_t ZSTD_did_fieldSize[4] = { 0, 1, 2, 4 };
+
+#define ZSTD_FRAMEIDSIZE 4 /* magic number size */
+
+#define ZSTD_BLOCKHEADERSIZE 3 /* C standard doesn't allow `static const` variable to be init using another `static const` variable */
+static const size_t ZSTD_blockHeaderSize = ZSTD_BLOCKHEADERSIZE;
+typedef enum { bt_raw, bt_rle, bt_compressed, bt_reserved } blockType_e;
+
+#define MIN_SEQUENCES_SIZE 1 /* nbSeq==0 */
+#define MIN_CBLOCK_SIZE (1 /*litCSize*/ + 1 /* RLE or RAW */ + MIN_SEQUENCES_SIZE /* nbSeq==0 */) /* for a non-null block */
+
+#define HufLog 12
+typedef enum { set_basic, set_rle, set_compressed, set_repeat } symbolEncodingType_e;
+
+#define LONGNBSEQ 0x7F00
+
+#define MINMATCH 3
+
+#define Litbits 8
+#define MaxLit ((1<<Litbits) - 1)
+#define MaxML 52
+#define MaxLL 35
+#define DefaultMaxOff 28
+#define MaxOff 31
+#define MaxSeq MAX(MaxLL, MaxML) /* Assumption : MaxOff < MaxLL,MaxML */
+#define MLFSELog 9
+#define LLFSELog 9
+#define OffFSELog 8
+#define MaxFSELog MAX(MAX(MLFSELog, LLFSELog), OffFSELog)
+
+static const U32 LL_bits[MaxLL+1] = { 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 2, 2, 3, 3,
+ 4, 6, 7, 8, 9,10,11,12,
+ 13,14,15,16 };
+static const S16 LL_defaultNorm[MaxLL+1] = { 4, 3, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 3, 2, 1, 1, 1, 1, 1,
+ -1,-1,-1,-1 };
+#define LL_DEFAULTNORMLOG 6 /* for static allocation */
+static const U32 LL_defaultNormLog = LL_DEFAULTNORMLOG;
+
+static const U32 ML_bits[MaxML+1] = { 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 2, 2, 3, 3,
+ 4, 4, 5, 7, 8, 9,10,11,
+ 12,13,14,15,16 };
+static const S16 ML_defaultNorm[MaxML+1] = { 1, 4, 3, 2, 2, 2, 2, 2,
+ 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1,-1,-1,
+ -1,-1,-1,-1,-1 };
+#define ML_DEFAULTNORMLOG 6 /* for static allocation */
+static const U32 ML_defaultNormLog = ML_DEFAULTNORMLOG;
+
+static const S16 OF_defaultNorm[DefaultMaxOff+1] = { 1, 1, 1, 1, 1, 1, 2, 2,
+ 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1,
+ -1,-1,-1,-1,-1 };
+#define OF_DEFAULTNORMLOG 5 /* for static allocation */
+static const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG;
+
+
+/*-*******************************************
+* Shared functions to include for inlining
+*********************************************/
+static void ZSTD_copy8(void* dst, const void* src) { memcpy(dst, src, 8); }
+#define COPY8(d,s) { ZSTD_copy8(d,s); d+=8; s+=8; }
+
+/*! ZSTD_wildcopy() :
+ * custom version of memcpy(), can overwrite up to WILDCOPY_OVERLENGTH bytes (if length==0) */
+#define WILDCOPY_OVERLENGTH 8
+MEM_STATIC void ZSTD_wildcopy(void* dst, const void* src, ptrdiff_t length)
+{
+ const BYTE* ip = (const BYTE*)src;
+ BYTE* op = (BYTE*)dst;
+ BYTE* const oend = op + length;
+ do
+ COPY8(op, ip)
+ while (op < oend);
+}
+
+MEM_STATIC void ZSTD_wildcopy_e(void* dst, const void* src, void* dstEnd) /* should be faster for decoding, but strangely, not verified on all platform */
+{
+ const BYTE* ip = (const BYTE*)src;
+ BYTE* op = (BYTE*)dst;
+ BYTE* const oend = (BYTE*)dstEnd;
+ do
+ COPY8(op, ip)
+ while (op < oend);
+}
+
+
+/*-*******************************************
+* Private declarations
+*********************************************/
+typedef struct seqDef_s {
+ U32 offset;
+ U16 litLength;
+ U16 matchLength;
+} seqDef;
+
+typedef struct {
+ seqDef* sequencesStart;
+ seqDef* sequences;
+ BYTE* litStart;
+ BYTE* lit;
+ BYTE* llCode;
+ BYTE* mlCode;
+ BYTE* ofCode;
+ size_t maxNbSeq;
+ size_t maxNbLit;
+ U32 longLengthID; /* 0 == no longLength; 1 == Lit.longLength; 2 == Match.longLength; */
+ U32 longLengthPos;
+} seqStore_t;
+
+const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */
+void ZSTD_seqToCodes(const seqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
+
+/* custom memory allocation functions */
+void* ZSTD_malloc(size_t size, ZSTD_customMem customMem);
+void* ZSTD_calloc(size_t size, ZSTD_customMem customMem);
+void ZSTD_free(void* ptr, ZSTD_customMem customMem);
+
+
+MEM_STATIC U32 ZSTD_highbit32(U32 val) /* compress, dictBuilder, decodeCorpus */
+{
+ assert(val != 0);
+ {
+# if defined(_MSC_VER) /* Visual */
+ unsigned long r=0;
+ _BitScanReverse(&r, val);
+ return (unsigned)r;
+# elif defined(__GNUC__) && (__GNUC__ >= 3) /* GCC Intrinsic */
+ return 31 - __builtin_clz(val);
+# else /* Software version */
+ static const U32 DeBruijnClz[32] = { 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31 };
+ U32 v = val;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ return DeBruijnClz[(v * 0x07C4ACDDU) >> 27];
+# endif
+ }
+}
+
+
+/* ZSTD_invalidateRepCodes() :
+ * ensures next compression will not use repcodes from previous block.
+ * Note : only works with regular variant;
+ * do not use with extDict variant ! */
+void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx); /* zstdmt, adaptive_compression (shouldn't get this definition from here) */
+
+
+typedef struct {
+ blockType_e blockType;
+ U32 lastBlock;
+ U32 origSize;
+} blockProperties_t; /* declared here for decompress and fullbench */
+
+/*! ZSTD_getcBlockSize() :
+ * Provides the size of compressed block from block header `src` */
+/* Used by: decompress, fullbench (does not get its definition from here) */
+size_t ZSTD_getcBlockSize(const void* src, size_t srcSize,
+ blockProperties_t* bpPtr);
+
+/*! ZSTD_decodeSeqHeaders() :
+ * decode sequence header from src */
+/* Used by: decompress, fullbench (does not get its definition from here) */
+size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
+ const void* src, size_t srcSize);
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* ZSTD_CCOMMON_H_MODULE */
diff --git a/Utilities/cmzstd/lib/compress/fse_compress.c b/Utilities/cmzstd/lib/compress/fse_compress.c
new file mode 100644
index 000000000..60f357bbd
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/fse_compress.c
@@ -0,0 +1,721 @@
+/* ******************************************************************
+ FSE : Finite State Entropy encoder
+ Copyright (C) 2013-present, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
+ - Public forum : https://groups.google.com/forum/#!forum/lz4c
+****************************************************************** */
+
+/* **************************************************************
+* Includes
+****************************************************************/
+#include <stdlib.h> /* malloc, free, qsort */
+#include <string.h> /* memcpy, memset */
+#include "compiler.h"
+#include "mem.h" /* U32, U16, etc. */
+#include "debug.h" /* assert, DEBUGLOG */
+#include "hist.h" /* HIST_count_wksp */
+#include "bitstream.h"
+#define FSE_STATIC_LINKING_ONLY
+#include "fse.h"
+#include "error_private.h"
+
+
+/* **************************************************************
+* Error Management
+****************************************************************/
+#define FSE_isError ERR_isError
+
+
+/* **************************************************************
+* Templates
+****************************************************************/
+/*
+ designed to be included
+ for type-specific functions (template emulation in C)
+ Objective is to write these functions only once, for improved maintenance
+*/
+
+/* safety checks */
+#ifndef FSE_FUNCTION_EXTENSION
+# error "FSE_FUNCTION_EXTENSION must be defined"
+#endif
+#ifndef FSE_FUNCTION_TYPE
+# error "FSE_FUNCTION_TYPE must be defined"
+#endif
+
+/* Function names */
+#define FSE_CAT(X,Y) X##Y
+#define FSE_FUNCTION_NAME(X,Y) FSE_CAT(X,Y)
+#define FSE_TYPE_NAME(X,Y) FSE_CAT(X,Y)
+
+
+/* Function templates */
+
+/* FSE_buildCTable_wksp() :
+ * Same as FSE_buildCTable(), but using an externally allocated scratch buffer (`workSpace`).
+ * wkspSize should be sized to handle worst case situation, which is `1<<max_tableLog * sizeof(FSE_FUNCTION_TYPE)`
+ * workSpace must also be properly aligned with FSE_FUNCTION_TYPE requirements
+ */
+size_t FSE_buildCTable_wksp(FSE_CTable* ct,
+ const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog,
+ void* workSpace, size_t wkspSize)
+{
+ U32 const tableSize = 1 << tableLog;
+ U32 const tableMask = tableSize - 1;
+ void* const ptr = ct;
+ U16* const tableU16 = ( (U16*) ptr) + 2;
+ void* const FSCT = ((U32*)ptr) + 1 /* header */ + (tableLog ? tableSize>>1 : 1) ;
+ FSE_symbolCompressionTransform* const symbolTT = (FSE_symbolCompressionTransform*) (FSCT);
+ U32 const step = FSE_TABLESTEP(tableSize);
+ U32 cumul[FSE_MAX_SYMBOL_VALUE+2];
+
+ FSE_FUNCTION_TYPE* const tableSymbol = (FSE_FUNCTION_TYPE*)workSpace;
+ U32 highThreshold = tableSize-1;
+
+ /* CTable header */
+ if (((size_t)1 << tableLog) * sizeof(FSE_FUNCTION_TYPE) > wkspSize) return ERROR(tableLog_tooLarge);
+ tableU16[-2] = (U16) tableLog;
+ tableU16[-1] = (U16) maxSymbolValue;
+ assert(tableLog < 16); /* required for threshold strategy to work */
+
+ /* For explanations on how to distribute symbol values over the table :
+ * http://fastcompression.blogspot.fr/2014/02/fse-distributing-symbol-values.html */
+
+ #ifdef __clang_analyzer__
+ memset(tableSymbol, 0, sizeof(*tableSymbol) * tableSize); /* useless initialization, just to keep scan-build happy */
+ #endif
+
+ /* symbol start positions */
+ { U32 u;
+ cumul[0] = 0;
+ for (u=1; u <= maxSymbolValue+1; u++) {
+ if (normalizedCounter[u-1]==-1) { /* Low proba symbol */
+ cumul[u] = cumul[u-1] + 1;
+ tableSymbol[highThreshold--] = (FSE_FUNCTION_TYPE)(u-1);
+ } else {
+ cumul[u] = cumul[u-1] + normalizedCounter[u-1];
+ } }
+ cumul[maxSymbolValue+1] = tableSize+1;
+ }
+
+ /* Spread symbols */
+ { U32 position = 0;
+ U32 symbol;
+ for (symbol=0; symbol<=maxSymbolValue; symbol++) {
+ int nbOccurences;
+ int const freq = normalizedCounter[symbol];
+ for (nbOccurences=0; nbOccurences<freq; nbOccurences++) {
+ tableSymbol[position] = (FSE_FUNCTION_TYPE)symbol;
+ position = (position + step) & tableMask;
+ while (position > highThreshold)
+ position = (position + step) & tableMask; /* Low proba area */
+ } }
+
+ assert(position==0); /* Must have initialized all positions */
+ }
+
+ /* Build table */
+ { U32 u; for (u=0; u<tableSize; u++) {
+ FSE_FUNCTION_TYPE s = tableSymbol[u]; /* note : static analyzer may not understand tableSymbol is properly initialized */
+ tableU16[cumul[s]++] = (U16) (tableSize+u); /* TableU16 : sorted by symbol order; gives next state value */
+ } }
+
+ /* Build Symbol Transformation Table */
+ { unsigned total = 0;
+ unsigned s;
+ for (s=0; s<=maxSymbolValue; s++) {
+ switch (normalizedCounter[s])
+ {
+ case 0:
+ /* filling nonetheless, for compatibility with FSE_getMaxNbBits() */
+ symbolTT[s].deltaNbBits = ((tableLog+1) << 16) - (1<<tableLog);
+ break;
+
+ case -1:
+ case 1:
+ symbolTT[s].deltaNbBits = (tableLog << 16) - (1<<tableLog);
+ symbolTT[s].deltaFindState = total - 1;
+ total ++;
+ break;
+ default :
+ {
+ U32 const maxBitsOut = tableLog - BIT_highbit32 (normalizedCounter[s]-1);
+ U32 const minStatePlus = normalizedCounter[s] << maxBitsOut;
+ symbolTT[s].deltaNbBits = (maxBitsOut << 16) - minStatePlus;
+ symbolTT[s].deltaFindState = total - normalizedCounter[s];
+ total += normalizedCounter[s];
+ } } } }
+
+#if 0 /* debug : symbol costs */
+ DEBUGLOG(5, "\n --- table statistics : ");
+ { U32 symbol;
+ for (symbol=0; symbol<=maxSymbolValue; symbol++) {
+ DEBUGLOG(5, "%3u: w=%3i, maxBits=%u, fracBits=%.2f",
+ symbol, normalizedCounter[symbol],
+ FSE_getMaxNbBits(symbolTT, symbol),
+ (double)FSE_bitCost(symbolTT, tableLog, symbol, 8) / 256);
+ }
+ }
+#endif
+
+ return 0;
+}
+
+
+size_t FSE_buildCTable(FSE_CTable* ct, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog)
+{
+ FSE_FUNCTION_TYPE tableSymbol[FSE_MAX_TABLESIZE]; /* memset() is not necessary, even if static analyzer complain about it */
+ return FSE_buildCTable_wksp(ct, normalizedCounter, maxSymbolValue, tableLog, tableSymbol, sizeof(tableSymbol));
+}
+
+
+
+#ifndef FSE_COMMONDEFS_ONLY
+
+
+/*-**************************************************************
+* FSE NCount encoding
+****************************************************************/
+size_t FSE_NCountWriteBound(unsigned maxSymbolValue, unsigned tableLog)
+{
+ size_t const maxHeaderSize = (((maxSymbolValue+1) * tableLog) >> 3) + 3;
+ return maxSymbolValue ? maxHeaderSize : FSE_NCOUNTBOUND; /* maxSymbolValue==0 ? use default */
+}
+
+static size_t
+FSE_writeNCount_generic (void* header, size_t headerBufferSize,
+ const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog,
+ unsigned writeIsSafe)
+{
+ BYTE* const ostart = (BYTE*) header;
+ BYTE* out = ostart;
+ BYTE* const oend = ostart + headerBufferSize;
+ int nbBits;
+ const int tableSize = 1 << tableLog;
+ int remaining;
+ int threshold;
+ U32 bitStream = 0;
+ int bitCount = 0;
+ unsigned symbol = 0;
+ unsigned const alphabetSize = maxSymbolValue + 1;
+ int previousIs0 = 0;
+
+ /* Table Size */
+ bitStream += (tableLog-FSE_MIN_TABLELOG) << bitCount;
+ bitCount += 4;
+
+ /* Init */
+ remaining = tableSize+1; /* +1 for extra accuracy */
+ threshold = tableSize;
+ nbBits = tableLog+1;
+
+ while ((symbol < alphabetSize) && (remaining>1)) { /* stops at 1 */
+ if (previousIs0) {
+ unsigned start = symbol;
+ while ((symbol < alphabetSize) && !normalizedCounter[symbol]) symbol++;
+ if (symbol == alphabetSize) break; /* incorrect distribution */
+ while (symbol >= start+24) {
+ start+=24;
+ bitStream += 0xFFFFU << bitCount;
+ if ((!writeIsSafe) && (out > oend-2))
+ return ERROR(dstSize_tooSmall); /* Buffer overflow */
+ out[0] = (BYTE) bitStream;
+ out[1] = (BYTE)(bitStream>>8);
+ out+=2;
+ bitStream>>=16;
+ }
+ while (symbol >= start+3) {
+ start+=3;
+ bitStream += 3 << bitCount;
+ bitCount += 2;
+ }
+ bitStream += (symbol-start) << bitCount;
+ bitCount += 2;
+ if (bitCount>16) {
+ if ((!writeIsSafe) && (out > oend - 2))
+ return ERROR(dstSize_tooSmall); /* Buffer overflow */
+ out[0] = (BYTE)bitStream;
+ out[1] = (BYTE)(bitStream>>8);
+ out += 2;
+ bitStream >>= 16;
+ bitCount -= 16;
+ } }
+ { int count = normalizedCounter[symbol++];
+ int const max = (2*threshold-1) - remaining;
+ remaining -= count < 0 ? -count : count;
+ count++; /* +1 for extra accuracy */
+ if (count>=threshold)
+ count += max; /* [0..max[ [max..threshold[ (...) [threshold+max 2*threshold[ */
+ bitStream += count << bitCount;
+ bitCount += nbBits;
+ bitCount -= (count<max);
+ previousIs0 = (count==1);
+ if (remaining<1) return ERROR(GENERIC);
+ while (remaining<threshold) { nbBits--; threshold>>=1; }
+ }
+ if (bitCount>16) {
+ if ((!writeIsSafe) && (out > oend - 2))
+ return ERROR(dstSize_tooSmall); /* Buffer overflow */
+ out[0] = (BYTE)bitStream;
+ out[1] = (BYTE)(bitStream>>8);
+ out += 2;
+ bitStream >>= 16;
+ bitCount -= 16;
+ } }
+
+ if (remaining != 1)
+ return ERROR(GENERIC); /* incorrect normalized distribution */
+ assert(symbol <= alphabetSize);
+
+ /* flush remaining bitStream */
+ if ((!writeIsSafe) && (out > oend - 2))
+ return ERROR(dstSize_tooSmall); /* Buffer overflow */
+ out[0] = (BYTE)bitStream;
+ out[1] = (BYTE)(bitStream>>8);
+ out+= (bitCount+7) /8;
+
+ return (out-ostart);
+}
+
+
+size_t FSE_writeNCount (void* buffer, size_t bufferSize,
+ const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog)
+{
+ if (tableLog > FSE_MAX_TABLELOG) return ERROR(tableLog_tooLarge); /* Unsupported */
+ if (tableLog < FSE_MIN_TABLELOG) return ERROR(GENERIC); /* Unsupported */
+
+ if (bufferSize < FSE_NCountWriteBound(maxSymbolValue, tableLog))
+ return FSE_writeNCount_generic(buffer, bufferSize, normalizedCounter, maxSymbolValue, tableLog, 0);
+
+ return FSE_writeNCount_generic(buffer, bufferSize, normalizedCounter, maxSymbolValue, tableLog, 1 /* write in buffer is safe */);
+}
+
+
+/*-**************************************************************
+* FSE Compression Code
+****************************************************************/
+
+FSE_CTable* FSE_createCTable (unsigned maxSymbolValue, unsigned tableLog)
+{
+ size_t size;
+ if (tableLog > FSE_TABLELOG_ABSOLUTE_MAX) tableLog = FSE_TABLELOG_ABSOLUTE_MAX;
+ size = FSE_CTABLE_SIZE_U32 (tableLog, maxSymbolValue) * sizeof(U32);
+ return (FSE_CTable*)malloc(size);
+}
+
+void FSE_freeCTable (FSE_CTable* ct) { free(ct); }
+
+/* provides the minimum logSize to safely represent a distribution */
+static unsigned FSE_minTableLog(size_t srcSize, unsigned maxSymbolValue)
+{
+ U32 minBitsSrc = BIT_highbit32((U32)(srcSize)) + 1;
+ U32 minBitsSymbols = BIT_highbit32(maxSymbolValue) + 2;
+ U32 minBits = minBitsSrc < minBitsSymbols ? minBitsSrc : minBitsSymbols;
+ assert(srcSize > 1); /* Not supported, RLE should be used instead */
+ return minBits;
+}
+
+unsigned FSE_optimalTableLog_internal(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue, unsigned minus)
+{
+ U32 maxBitsSrc = BIT_highbit32((U32)(srcSize - 1)) - minus;
+ U32 tableLog = maxTableLog;
+ U32 minBits = FSE_minTableLog(srcSize, maxSymbolValue);
+ assert(srcSize > 1); /* Not supported, RLE should be used instead */
+ if (tableLog==0) tableLog = FSE_DEFAULT_TABLELOG;
+ if (maxBitsSrc < tableLog) tableLog = maxBitsSrc; /* Accuracy can be reduced */
+ if (minBits > tableLog) tableLog = minBits; /* Need a minimum to safely represent all symbol values */
+ if (tableLog < FSE_MIN_TABLELOG) tableLog = FSE_MIN_TABLELOG;
+ if (tableLog > FSE_MAX_TABLELOG) tableLog = FSE_MAX_TABLELOG;
+ return tableLog;
+}
+
+unsigned FSE_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue)
+{
+ return FSE_optimalTableLog_internal(maxTableLog, srcSize, maxSymbolValue, 2);
+}
+
+
+/* Secondary normalization method.
+ To be used when primary method fails. */
+
+static size_t FSE_normalizeM2(short* norm, U32 tableLog, const unsigned* count, size_t total, U32 maxSymbolValue)
+{
+ short const NOT_YET_ASSIGNED = -2;
+ U32 s;
+ U32 distributed = 0;
+ U32 ToDistribute;
+
+ /* Init */
+ U32 const lowThreshold = (U32)(total >> tableLog);
+ U32 lowOne = (U32)((total * 3) >> (tableLog + 1));
+
+ for (s=0; s<=maxSymbolValue; s++) {
+ if (count[s] == 0) {
+ norm[s]=0;
+ continue;
+ }
+ if (count[s] <= lowThreshold) {
+ norm[s] = -1;
+ distributed++;
+ total -= count[s];
+ continue;
+ }
+ if (count[s] <= lowOne) {
+ norm[s] = 1;
+ distributed++;
+ total -= count[s];
+ continue;
+ }
+
+ norm[s]=NOT_YET_ASSIGNED;
+ }
+ ToDistribute = (1 << tableLog) - distributed;
+
+ if (ToDistribute == 0)
+ return 0;
+
+ if ((total / ToDistribute) > lowOne) {
+ /* risk of rounding to zero */
+ lowOne = (U32)((total * 3) / (ToDistribute * 2));
+ for (s=0; s<=maxSymbolValue; s++) {
+ if ((norm[s] == NOT_YET_ASSIGNED) && (count[s] <= lowOne)) {
+ norm[s] = 1;
+ distributed++;
+ total -= count[s];
+ continue;
+ } }
+ ToDistribute = (1 << tableLog) - distributed;
+ }
+
+ if (distributed == maxSymbolValue+1) {
+ /* all values are pretty poor;
+ probably incompressible data (should have already been detected);
+ find max, then give all remaining points to max */
+ U32 maxV = 0, maxC = 0;
+ for (s=0; s<=maxSymbolValue; s++)
+ if (count[s] > maxC) { maxV=s; maxC=count[s]; }
+ norm[maxV] += (short)ToDistribute;
+ return 0;
+ }
+
+ if (total == 0) {
+ /* all of the symbols were low enough for the lowOne or lowThreshold */
+ for (s=0; ToDistribute > 0; s = (s+1)%(maxSymbolValue+1))
+ if (norm[s] > 0) { ToDistribute--; norm[s]++; }
+ return 0;
+ }
+
+ { U64 const vStepLog = 62 - tableLog;
+ U64 const mid = (1ULL << (vStepLog-1)) - 1;
+ U64 const rStep = ((((U64)1<<vStepLog) * ToDistribute) + mid) / total; /* scale on remaining */
+ U64 tmpTotal = mid;
+ for (s=0; s<=maxSymbolValue; s++) {
+ if (norm[s]==NOT_YET_ASSIGNED) {
+ U64 const end = tmpTotal + (count[s] * rStep);
+ U32 const sStart = (U32)(tmpTotal >> vStepLog);
+ U32 const sEnd = (U32)(end >> vStepLog);
+ U32 const weight = sEnd - sStart;
+ if (weight < 1)
+ return ERROR(GENERIC);
+ norm[s] = (short)weight;
+ tmpTotal = end;
+ } } }
+
+ return 0;
+}
+
+
+size_t FSE_normalizeCount (short* normalizedCounter, unsigned tableLog,
+ const unsigned* count, size_t total,
+ unsigned maxSymbolValue)
+{
+ /* Sanity checks */
+ if (tableLog==0) tableLog = FSE_DEFAULT_TABLELOG;
+ if (tableLog < FSE_MIN_TABLELOG) return ERROR(GENERIC); /* Unsupported size */
+ if (tableLog > FSE_MAX_TABLELOG) return ERROR(tableLog_tooLarge); /* Unsupported size */
+ if (tableLog < FSE_minTableLog(total, maxSymbolValue)) return ERROR(GENERIC); /* Too small tableLog, compression potentially impossible */
+
+ { static U32 const rtbTable[] = { 0, 473195, 504333, 520860, 550000, 700000, 750000, 830000 };
+ U64 const scale = 62 - tableLog;
+ U64 const step = ((U64)1<<62) / total; /* <== here, one division ! */
+ U64 const vStep = 1ULL<<(scale-20);
+ int stillToDistribute = 1<<tableLog;
+ unsigned s;
+ unsigned largest=0;
+ short largestP=0;
+ U32 lowThreshold = (U32)(total >> tableLog);
+
+ for (s=0; s<=maxSymbolValue; s++) {
+ if (count[s] == total) return 0; /* rle special case */
+ if (count[s] == 0) { normalizedCounter[s]=0; continue; }
+ if (count[s] <= lowThreshold) {
+ normalizedCounter[s] = -1;
+ stillToDistribute--;
+ } else {
+ short proba = (short)((count[s]*step) >> scale);
+ if (proba<8) {
+ U64 restToBeat = vStep * rtbTable[proba];
+ proba += (count[s]*step) - ((U64)proba<<scale) > restToBeat;
+ }
+ if (proba > largestP) { largestP=proba; largest=s; }
+ normalizedCounter[s] = proba;
+ stillToDistribute -= proba;
+ } }
+ if (-stillToDistribute >= (normalizedCounter[largest] >> 1)) {
+ /* corner case, need another normalization method */
+ size_t const errorCode = FSE_normalizeM2(normalizedCounter, tableLog, count, total, maxSymbolValue);
+ if (FSE_isError(errorCode)) return errorCode;
+ }
+ else normalizedCounter[largest] += (short)stillToDistribute;
+ }
+
+#if 0
+ { /* Print Table (debug) */
+ U32 s;
+ U32 nTotal = 0;
+ for (s=0; s<=maxSymbolValue; s++)
+ RAWLOG(2, "%3i: %4i \n", s, normalizedCounter[s]);
+ for (s=0; s<=maxSymbolValue; s++)
+ nTotal += abs(normalizedCounter[s]);
+ if (nTotal != (1U<<tableLog))
+ RAWLOG(2, "Warning !!! Total == %u != %u !!!", nTotal, 1U<<tableLog);
+ getchar();
+ }
+#endif
+
+ return tableLog;
+}
+
+
+/* fake FSE_CTable, for raw (uncompressed) input */
+size_t FSE_buildCTable_raw (FSE_CTable* ct, unsigned nbBits)
+{
+ const unsigned tableSize = 1 << nbBits;
+ const unsigned tableMask = tableSize - 1;
+ const unsigned maxSymbolValue = tableMask;
+ void* const ptr = ct;
+ U16* const tableU16 = ( (U16*) ptr) + 2;
+ void* const FSCT = ((U32*)ptr) + 1 /* header */ + (tableSize>>1); /* assumption : tableLog >= 1 */
+ FSE_symbolCompressionTransform* const symbolTT = (FSE_symbolCompressionTransform*) (FSCT);
+ unsigned s;
+
+ /* Sanity checks */
+ if (nbBits < 1) return ERROR(GENERIC); /* min size */
+
+ /* header */
+ tableU16[-2] = (U16) nbBits;
+ tableU16[-1] = (U16) maxSymbolValue;
+
+ /* Build table */
+ for (s=0; s<tableSize; s++)
+ tableU16[s] = (U16)(tableSize + s);
+
+ /* Build Symbol Transformation Table */
+ { const U32 deltaNbBits = (nbBits << 16) - (1 << nbBits);
+ for (s=0; s<=maxSymbolValue; s++) {
+ symbolTT[s].deltaNbBits = deltaNbBits;
+ symbolTT[s].deltaFindState = s-1;
+ } }
+
+ return 0;
+}
+
+/* fake FSE_CTable, for rle input (always same symbol) */
+size_t FSE_buildCTable_rle (FSE_CTable* ct, BYTE symbolValue)
+{
+ void* ptr = ct;
+ U16* tableU16 = ( (U16*) ptr) + 2;
+ void* FSCTptr = (U32*)ptr + 2;
+ FSE_symbolCompressionTransform* symbolTT = (FSE_symbolCompressionTransform*) FSCTptr;
+
+ /* header */
+ tableU16[-2] = (U16) 0;
+ tableU16[-1] = (U16) symbolValue;
+
+ /* Build table */
+ tableU16[0] = 0;
+ tableU16[1] = 0; /* just in case */
+
+ /* Build Symbol Transformation Table */
+ symbolTT[symbolValue].deltaNbBits = 0;
+ symbolTT[symbolValue].deltaFindState = 0;
+
+ return 0;
+}
+
+
+static size_t FSE_compress_usingCTable_generic (void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ const FSE_CTable* ct, const unsigned fast)
+{
+ const BYTE* const istart = (const BYTE*) src;
+ const BYTE* const iend = istart + srcSize;
+ const BYTE* ip=iend;
+
+ BIT_CStream_t bitC;
+ FSE_CState_t CState1, CState2;
+
+ /* init */
+ if (srcSize <= 2) return 0;
+ { size_t const initError = BIT_initCStream(&bitC, dst, dstSize);
+ if (FSE_isError(initError)) return 0; /* not enough space available to write a bitstream */ }
+
+#define FSE_FLUSHBITS(s) (fast ? BIT_flushBitsFast(s) : BIT_flushBits(s))
+
+ if (srcSize & 1) {
+ FSE_initCState2(&CState1, ct, *--ip);
+ FSE_initCState2(&CState2, ct, *--ip);
+ FSE_encodeSymbol(&bitC, &CState1, *--ip);
+ FSE_FLUSHBITS(&bitC);
+ } else {
+ FSE_initCState2(&CState2, ct, *--ip);
+ FSE_initCState2(&CState1, ct, *--ip);
+ }
+
+ /* join to mod 4 */
+ srcSize -= 2;
+ if ((sizeof(bitC.bitContainer)*8 > FSE_MAX_TABLELOG*4+7 ) && (srcSize & 2)) { /* test bit 2 */
+ FSE_encodeSymbol(&bitC, &CState2, *--ip);
+ FSE_encodeSymbol(&bitC, &CState1, *--ip);
+ FSE_FLUSHBITS(&bitC);
+ }
+
+ /* 2 or 4 encoding per loop */
+ while ( ip>istart ) {
+
+ FSE_encodeSymbol(&bitC, &CState2, *--ip);
+
+ if (sizeof(bitC.bitContainer)*8 < FSE_MAX_TABLELOG*2+7 ) /* this test must be static */
+ FSE_FLUSHBITS(&bitC);
+
+ FSE_encodeSymbol(&bitC, &CState1, *--ip);
+
+ if (sizeof(bitC.bitContainer)*8 > FSE_MAX_TABLELOG*4+7 ) { /* this test must be static */
+ FSE_encodeSymbol(&bitC, &CState2, *--ip);
+ FSE_encodeSymbol(&bitC, &CState1, *--ip);
+ }
+
+ FSE_FLUSHBITS(&bitC);
+ }
+
+ FSE_flushCState(&bitC, &CState2);
+ FSE_flushCState(&bitC, &CState1);
+ return BIT_closeCStream(&bitC);
+}
+
+size_t FSE_compress_usingCTable (void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ const FSE_CTable* ct)
+{
+ unsigned const fast = (dstSize >= FSE_BLOCKBOUND(srcSize));
+
+ if (fast)
+ return FSE_compress_usingCTable_generic(dst, dstSize, src, srcSize, ct, 1);
+ else
+ return FSE_compress_usingCTable_generic(dst, dstSize, src, srcSize, ct, 0);
+}
+
+
+size_t FSE_compressBound(size_t size) { return FSE_COMPRESSBOUND(size); }
+
+#define CHECK_V_F(e, f) size_t const e = f; if (ERR_isError(e)) return e
+#define CHECK_F(f) { CHECK_V_F(_var_err__, f); }
+
+/* FSE_compress_wksp() :
+ * Same as FSE_compress2(), but using an externally allocated scratch buffer (`workSpace`).
+ * `wkspSize` size must be `(1<<tableLog)`.
+ */
+size_t FSE_compress_wksp (void* dst, size_t dstSize, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog, void* workSpace, size_t wkspSize)
+{
+ BYTE* const ostart = (BYTE*) dst;
+ BYTE* op = ostart;
+ BYTE* const oend = ostart + dstSize;
+
+ unsigned count[FSE_MAX_SYMBOL_VALUE+1];
+ S16 norm[FSE_MAX_SYMBOL_VALUE+1];
+ FSE_CTable* CTable = (FSE_CTable*)workSpace;
+ size_t const CTableSize = FSE_CTABLE_SIZE_U32(tableLog, maxSymbolValue);
+ void* scratchBuffer = (void*)(CTable + CTableSize);
+ size_t const scratchBufferSize = wkspSize - (CTableSize * sizeof(FSE_CTable));
+
+ /* init conditions */
+ if (wkspSize < FSE_WKSP_SIZE_U32(tableLog, maxSymbolValue)) return ERROR(tableLog_tooLarge);
+ if (srcSize <= 1) return 0; /* Not compressible */
+ if (!maxSymbolValue) maxSymbolValue = FSE_MAX_SYMBOL_VALUE;
+ if (!tableLog) tableLog = FSE_DEFAULT_TABLELOG;
+
+ /* Scan input and build symbol stats */
+ { CHECK_V_F(maxCount, HIST_count_wksp(count, &maxSymbolValue, src, srcSize, scratchBuffer, scratchBufferSize) );
+ if (maxCount == srcSize) return 1; /* only a single symbol in src : rle */
+ if (maxCount == 1) return 0; /* each symbol present maximum once => not compressible */
+ if (maxCount < (srcSize >> 7)) return 0; /* Heuristic : not compressible enough */
+ }
+
+ tableLog = FSE_optimalTableLog(tableLog, srcSize, maxSymbolValue);
+ CHECK_F( FSE_normalizeCount(norm, tableLog, count, srcSize, maxSymbolValue) );
+
+ /* Write table description header */
+ { CHECK_V_F(nc_err, FSE_writeNCount(op, oend-op, norm, maxSymbolValue, tableLog) );
+ op += nc_err;
+ }
+
+ /* Compress */
+ CHECK_F( FSE_buildCTable_wksp(CTable, norm, maxSymbolValue, tableLog, scratchBuffer, scratchBufferSize) );
+ { CHECK_V_F(cSize, FSE_compress_usingCTable(op, oend - op, src, srcSize, CTable) );
+ if (cSize == 0) return 0; /* not enough space for compressed data */
+ op += cSize;
+ }
+
+ /* check compressibility */
+ if ( (size_t)(op-ostart) >= srcSize-1 ) return 0;
+
+ return op-ostart;
+}
+
+typedef struct {
+ FSE_CTable CTable_max[FSE_CTABLE_SIZE_U32(FSE_MAX_TABLELOG, FSE_MAX_SYMBOL_VALUE)];
+ BYTE scratchBuffer[1 << FSE_MAX_TABLELOG];
+} fseWkspMax_t;
+
+size_t FSE_compress2 (void* dst, size_t dstCapacity, const void* src, size_t srcSize, unsigned maxSymbolValue, unsigned tableLog)
+{
+ fseWkspMax_t scratchBuffer;
+ DEBUG_STATIC_ASSERT(sizeof(scratchBuffer) >= FSE_WKSP_SIZE_U32(FSE_MAX_TABLELOG, FSE_MAX_SYMBOL_VALUE)); /* compilation failures here means scratchBuffer is not large enough */
+ if (tableLog > FSE_MAX_TABLELOG) return ERROR(tableLog_tooLarge);
+ return FSE_compress_wksp(dst, dstCapacity, src, srcSize, maxSymbolValue, tableLog, &scratchBuffer, sizeof(scratchBuffer));
+}
+
+size_t FSE_compress (void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+{
+ return FSE_compress2(dst, dstCapacity, src, srcSize, FSE_MAX_SYMBOL_VALUE, FSE_DEFAULT_TABLELOG);
+}
+
+
+#endif /* FSE_COMMONDEFS_ONLY */
diff --git a/Utilities/cmzstd/lib/compress/hist.c b/Utilities/cmzstd/lib/compress/hist.c
new file mode 100644
index 000000000..45b7babc1
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/hist.c
@@ -0,0 +1,203 @@
+/* ******************************************************************
+ hist : Histogram functions
+ part of Finite State Entropy project
+ Copyright (C) 2013-present, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
+ - Public forum : https://groups.google.com/forum/#!forum/lz4c
+****************************************************************** */
+
+/* --- dependencies --- */
+#include "mem.h" /* U32, BYTE, etc. */
+#include "debug.h" /* assert, DEBUGLOG */
+#include "error_private.h" /* ERROR */
+#include "hist.h"
+
+
+/* --- Error management --- */
+unsigned HIST_isError(size_t code) { return ERR_isError(code); }
+
+/*-**************************************************************
+ * Histogram functions
+ ****************************************************************/
+unsigned HIST_count_simple(unsigned* count, unsigned* maxSymbolValuePtr,
+ const void* src, size_t srcSize)
+{
+ const BYTE* ip = (const BYTE*)src;
+ const BYTE* const end = ip + srcSize;
+ unsigned maxSymbolValue = *maxSymbolValuePtr;
+ unsigned largestCount=0;
+
+ memset(count, 0, (maxSymbolValue+1) * sizeof(*count));
+ if (srcSize==0) { *maxSymbolValuePtr = 0; return 0; }
+
+ while (ip<end) {
+ assert(*ip <= maxSymbolValue);
+ count[*ip++]++;
+ }
+
+ while (!count[maxSymbolValue]) maxSymbolValue--;
+ *maxSymbolValuePtr = maxSymbolValue;
+
+ { U32 s;
+ for (s=0; s<=maxSymbolValue; s++)
+ if (count[s] > largestCount) largestCount = count[s];
+ }
+
+ return largestCount;
+}
+
+typedef enum { trustInput, checkMaxSymbolValue } HIST_checkInput_e;
+
+/* HIST_count_parallel_wksp() :
+ * store histogram into 4 intermediate tables, recombined at the end.
+ * this design makes better use of OoO cpus,
+ * and is noticeably faster when some values are heavily repeated.
+ * But it needs some additional workspace for intermediate tables.
+ * `workSpace` size must be a table of size >= HIST_WKSP_SIZE_U32.
+ * @return : largest histogram frequency,
+ * or an error code (notably when histogram would be larger than *maxSymbolValuePtr). */
+static size_t HIST_count_parallel_wksp(
+ unsigned* count, unsigned* maxSymbolValuePtr,
+ const void* source, size_t sourceSize,
+ HIST_checkInput_e check,
+ U32* const workSpace)
+{
+ const BYTE* ip = (const BYTE*)source;
+ const BYTE* const iend = ip+sourceSize;
+ unsigned maxSymbolValue = *maxSymbolValuePtr;
+ unsigned max=0;
+ U32* const Counting1 = workSpace;
+ U32* const Counting2 = Counting1 + 256;
+ U32* const Counting3 = Counting2 + 256;
+ U32* const Counting4 = Counting3 + 256;
+
+ memset(workSpace, 0, 4*256*sizeof(unsigned));
+
+ /* safety checks */
+ if (!sourceSize) {
+ memset(count, 0, maxSymbolValue + 1);
+ *maxSymbolValuePtr = 0;
+ return 0;
+ }
+ if (!maxSymbolValue) maxSymbolValue = 255; /* 0 == default */
+
+ /* by stripes of 16 bytes */
+ { U32 cached = MEM_read32(ip); ip += 4;
+ while (ip < iend-15) {
+ U32 c = cached; cached = MEM_read32(ip); ip += 4;
+ Counting1[(BYTE) c ]++;
+ Counting2[(BYTE)(c>>8) ]++;
+ Counting3[(BYTE)(c>>16)]++;
+ Counting4[ c>>24 ]++;
+ c = cached; cached = MEM_read32(ip); ip += 4;
+ Counting1[(BYTE) c ]++;
+ Counting2[(BYTE)(c>>8) ]++;
+ Counting3[(BYTE)(c>>16)]++;
+ Counting4[ c>>24 ]++;
+ c = cached; cached = MEM_read32(ip); ip += 4;
+ Counting1[(BYTE) c ]++;
+ Counting2[(BYTE)(c>>8) ]++;
+ Counting3[(BYTE)(c>>16)]++;
+ Counting4[ c>>24 ]++;
+ c = cached; cached = MEM_read32(ip); ip += 4;
+ Counting1[(BYTE) c ]++;
+ Counting2[(BYTE)(c>>8) ]++;
+ Counting3[(BYTE)(c>>16)]++;
+ Counting4[ c>>24 ]++;
+ }
+ ip-=4;
+ }
+
+ /* finish last symbols */
+ while (ip<iend) Counting1[*ip++]++;
+
+ if (check) { /* verify stats will fit into destination table */
+ U32 s; for (s=255; s>maxSymbolValue; s--) {
+ Counting1[s] += Counting2[s] + Counting3[s] + Counting4[s];
+ if (Counting1[s]) return ERROR(maxSymbolValue_tooSmall);
+ } }
+
+ { U32 s;
+ if (maxSymbolValue > 255) maxSymbolValue = 255;
+ for (s=0; s<=maxSymbolValue; s++) {
+ count[s] = Counting1[s] + Counting2[s] + Counting3[s] + Counting4[s];
+ if (count[s] > max) max = count[s];
+ } }
+
+ while (!count[maxSymbolValue]) maxSymbolValue--;
+ *maxSymbolValuePtr = maxSymbolValue;
+ return (size_t)max;
+}
+
+/* HIST_countFast_wksp() :
+ * Same as HIST_countFast(), but using an externally provided scratch buffer.
+ * `workSpace` is a writable buffer which must be 4-bytes aligned,
+ * `workSpaceSize` must be >= HIST_WKSP_SIZE
+ */
+size_t HIST_countFast_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
+ const void* source, size_t sourceSize,
+ void* workSpace, size_t workSpaceSize)
+{
+ if (sourceSize < 1500) /* heuristic threshold */
+ return HIST_count_simple(count, maxSymbolValuePtr, source, sourceSize);
+ if ((size_t)workSpace & 3) return ERROR(GENERIC); /* must be aligned on 4-bytes boundaries */
+ if (workSpaceSize < HIST_WKSP_SIZE) return ERROR(workSpace_tooSmall);
+ return HIST_count_parallel_wksp(count, maxSymbolValuePtr, source, sourceSize, trustInput, (U32*)workSpace);
+}
+
+/* fast variant (unsafe : won't check if src contains values beyond count[] limit) */
+size_t HIST_countFast(unsigned* count, unsigned* maxSymbolValuePtr,
+ const void* source, size_t sourceSize)
+{
+ unsigned tmpCounters[HIST_WKSP_SIZE_U32];
+ return HIST_countFast_wksp(count, maxSymbolValuePtr, source, sourceSize, tmpCounters, sizeof(tmpCounters));
+}
+
+/* HIST_count_wksp() :
+ * Same as HIST_count(), but using an externally provided scratch buffer.
+ * `workSpace` size must be table of >= HIST_WKSP_SIZE_U32 unsigned */
+size_t HIST_count_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
+ const void* source, size_t sourceSize,
+ void* workSpace, size_t workSpaceSize)
+{
+ if ((size_t)workSpace & 3) return ERROR(GENERIC); /* must be aligned on 4-bytes boundaries */
+ if (workSpaceSize < HIST_WKSP_SIZE) return ERROR(workSpace_tooSmall);
+ if (*maxSymbolValuePtr < 255)
+ return HIST_count_parallel_wksp(count, maxSymbolValuePtr, source, sourceSize, checkMaxSymbolValue, (U32*)workSpace);
+ *maxSymbolValuePtr = 255;
+ return HIST_countFast_wksp(count, maxSymbolValuePtr, source, sourceSize, workSpace, workSpaceSize);
+}
+
+size_t HIST_count(unsigned* count, unsigned* maxSymbolValuePtr,
+ const void* src, size_t srcSize)
+{
+ unsigned tmpCounters[HIST_WKSP_SIZE_U32];
+ return HIST_count_wksp(count, maxSymbolValuePtr, src, srcSize, tmpCounters, sizeof(tmpCounters));
+}
diff --git a/Utilities/cmzstd/lib/compress/hist.h b/Utilities/cmzstd/lib/compress/hist.h
new file mode 100644
index 000000000..8b389358d
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/hist.h
@@ -0,0 +1,95 @@
+/* ******************************************************************
+ hist : Histogram functions
+ part of Finite State Entropy project
+ Copyright (C) 2013-present, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - FSE source repository : https://github.com/Cyan4973/FiniteStateEntropy
+ - Public forum : https://groups.google.com/forum/#!forum/lz4c
+****************************************************************** */
+
+/* --- dependencies --- */
+#include <stddef.h> /* size_t */
+
+
+/* --- simple histogram functions --- */
+
+/*! HIST_count():
+ * Provides the precise count of each byte within a table 'count'.
+ * 'count' is a table of unsigned int, of minimum size (*maxSymbolValuePtr+1).
+ * Updates *maxSymbolValuePtr with actual largest symbol value detected.
+ * @return : count of the most frequent symbol (which isn't identified).
+ * or an error code, which can be tested using HIST_isError().
+ * note : if return == srcSize, there is only one symbol.
+ */
+size_t HIST_count(unsigned* count, unsigned* maxSymbolValuePtr,
+ const void* src, size_t srcSize);
+
+unsigned HIST_isError(size_t code); /**< tells if a return value is an error code */
+
+
+/* --- advanced histogram functions --- */
+
+#define HIST_WKSP_SIZE_U32 1024
+#define HIST_WKSP_SIZE (HIST_WKSP_SIZE_U32 * sizeof(unsigned))
+/** HIST_count_wksp() :
+ * Same as HIST_count(), but using an externally provided scratch buffer.
+ * Benefit is this function will use very little stack space.
+ * `workSpace` is a writable buffer which must be 4-bytes aligned,
+ * `workSpaceSize` must be >= HIST_WKSP_SIZE
+ */
+size_t HIST_count_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
+ const void* src, size_t srcSize,
+ void* workSpace, size_t workSpaceSize);
+
+/** HIST_countFast() :
+ * same as HIST_count(), but blindly trusts that all byte values within src are <= *maxSymbolValuePtr.
+ * This function is unsafe, and will segfault if any value within `src` is `> *maxSymbolValuePtr`
+ */
+size_t HIST_countFast(unsigned* count, unsigned* maxSymbolValuePtr,
+ const void* src, size_t srcSize);
+
+/** HIST_countFast_wksp() :
+ * Same as HIST_countFast(), but using an externally provided scratch buffer.
+ * `workSpace` is a writable buffer which must be 4-bytes aligned,
+ * `workSpaceSize` must be >= HIST_WKSP_SIZE
+ */
+size_t HIST_countFast_wksp(unsigned* count, unsigned* maxSymbolValuePtr,
+ const void* src, size_t srcSize,
+ void* workSpace, size_t workSpaceSize);
+
+/*! HIST_count_simple() :
+ * Same as HIST_countFast(), this function is unsafe,
+ * and will segfault if any value within `src` is `> *maxSymbolValuePtr`.
+ * It is also a bit slower for large inputs.
+ * However, it does not need any additional memory (not even on stack).
+ * @return : count of the most frequent symbol.
+ * Note this function doesn't produce any error (i.e. it must succeed).
+ */
+unsigned HIST_count_simple(unsigned* count, unsigned* maxSymbolValuePtr,
+ const void* src, size_t srcSize);
diff --git a/Utilities/cmzstd/lib/compress/huf_compress.c b/Utilities/cmzstd/lib/compress/huf_compress.c
new file mode 100644
index 000000000..f074f1e0a
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/huf_compress.c
@@ -0,0 +1,798 @@
+/* ******************************************************************
+ Huffman encoder, part of New Generation Entropy library
+ Copyright (C) 2013-2016, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - FSE+HUF source repository : https://github.com/Cyan4973/FiniteStateEntropy
+ - Public forum : https://groups.google.com/forum/#!forum/lz4c
+****************************************************************** */
+
+/* **************************************************************
+* Compiler specifics
+****************************************************************/
+#ifdef _MSC_VER /* Visual Studio */
+# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
+#endif
+
+
+/* **************************************************************
+* Includes
+****************************************************************/
+#include <string.h> /* memcpy, memset */
+#include <stdio.h> /* printf (debug) */
+#include "compiler.h"
+#include "bitstream.h"
+#include "hist.h"
+#define FSE_STATIC_LINKING_ONLY /* FSE_optimalTableLog_internal */
+#include "fse.h" /* header compression */
+#define HUF_STATIC_LINKING_ONLY
+#include "huf.h"
+#include "error_private.h"
+
+
+/* **************************************************************
+* Error Management
+****************************************************************/
+#define HUF_isError ERR_isError
+#define HUF_STATIC_ASSERT(c) DEBUG_STATIC_ASSERT(c) /* use only *after* variable declarations */
+#define CHECK_V_F(e, f) size_t const e = f; if (ERR_isError(e)) return e
+#define CHECK_F(f) { CHECK_V_F(_var_err__, f); }
+
+
+/* **************************************************************
+* Utils
+****************************************************************/
+unsigned HUF_optimalTableLog(unsigned maxTableLog, size_t srcSize, unsigned maxSymbolValue)
+{
+ return FSE_optimalTableLog_internal(maxTableLog, srcSize, maxSymbolValue, 1);
+}
+
+
+/* *******************************************************
+* HUF : Huffman block compression
+*********************************************************/
+/* HUF_compressWeights() :
+ * Same as FSE_compress(), but dedicated to huff0's weights compression.
+ * The use case needs much less stack memory.
+ * Note : all elements within weightTable are supposed to be <= HUF_TABLELOG_MAX.
+ */
+#define MAX_FSE_TABLELOG_FOR_HUFF_HEADER 6
+static size_t HUF_compressWeights (void* dst, size_t dstSize, const void* weightTable, size_t wtSize)
+{
+ BYTE* const ostart = (BYTE*) dst;
+ BYTE* op = ostart;
+ BYTE* const oend = ostart + dstSize;
+
+ unsigned maxSymbolValue = HUF_TABLELOG_MAX;
+ U32 tableLog = MAX_FSE_TABLELOG_FOR_HUFF_HEADER;
+
+ FSE_CTable CTable[FSE_CTABLE_SIZE_U32(MAX_FSE_TABLELOG_FOR_HUFF_HEADER, HUF_TABLELOG_MAX)];
+ BYTE scratchBuffer[1<<MAX_FSE_TABLELOG_FOR_HUFF_HEADER];
+
+ unsigned count[HUF_TABLELOG_MAX+1];
+ S16 norm[HUF_TABLELOG_MAX+1];
+
+ /* init conditions */
+ if (wtSize <= 1) return 0; /* Not compressible */
+
+ /* Scan input and build symbol stats */
+ { unsigned const maxCount = HIST_count_simple(count, &maxSymbolValue, weightTable, wtSize); /* never fails */
+ if (maxCount == wtSize) return 1; /* only a single symbol in src : rle */
+ if (maxCount == 1) return 0; /* each symbol present maximum once => not compressible */
+ }
+
+ tableLog = FSE_optimalTableLog(tableLog, wtSize, maxSymbolValue);
+ CHECK_F( FSE_normalizeCount(norm, tableLog, count, wtSize, maxSymbolValue) );
+
+ /* Write table description header */
+ { CHECK_V_F(hSize, FSE_writeNCount(op, oend-op, norm, maxSymbolValue, tableLog) );
+ op += hSize;
+ }
+
+ /* Compress */
+ CHECK_F( FSE_buildCTable_wksp(CTable, norm, maxSymbolValue, tableLog, scratchBuffer, sizeof(scratchBuffer)) );
+ { CHECK_V_F(cSize, FSE_compress_usingCTable(op, oend - op, weightTable, wtSize, CTable) );
+ if (cSize == 0) return 0; /* not enough space for compressed data */
+ op += cSize;
+ }
+
+ return op-ostart;
+}
+
+
+struct HUF_CElt_s {
+ U16 val;
+ BYTE nbBits;
+}; /* typedef'd to HUF_CElt within "huf.h" */
+
+/*! HUF_writeCTable() :
+ `CTable` : Huffman tree to save, using huf representation.
+ @return : size of saved CTable */
+size_t HUF_writeCTable (void* dst, size_t maxDstSize,
+ const HUF_CElt* CTable, unsigned maxSymbolValue, unsigned huffLog)
+{
+ BYTE bitsToWeight[HUF_TABLELOG_MAX + 1]; /* precomputed conversion table */
+ BYTE huffWeight[HUF_SYMBOLVALUE_MAX];
+ BYTE* op = (BYTE*)dst;
+ U32 n;
+
+ /* check conditions */
+ if (maxSymbolValue > HUF_SYMBOLVALUE_MAX) return ERROR(maxSymbolValue_tooLarge);
+
+ /* convert to weight */
+ bitsToWeight[0] = 0;
+ for (n=1; n<huffLog+1; n++)
+ bitsToWeight[n] = (BYTE)(huffLog + 1 - n);
+ for (n=0; n<maxSymbolValue; n++)
+ huffWeight[n] = bitsToWeight[CTable[n].nbBits];
+
+ /* attempt weights compression by FSE */
+ { CHECK_V_F(hSize, HUF_compressWeights(op+1, maxDstSize-1, huffWeight, maxSymbolValue) );
+ if ((hSize>1) & (hSize < maxSymbolValue/2)) { /* FSE compressed */
+ op[0] = (BYTE)hSize;
+ return hSize+1;
+ } }
+
+ /* write raw values as 4-bits (max : 15) */
+ if (maxSymbolValue > (256-128)) return ERROR(GENERIC); /* should not happen : likely means source cannot be compressed */
+ if (((maxSymbolValue+1)/2) + 1 > maxDstSize) return ERROR(dstSize_tooSmall); /* not enough space within dst buffer */
+ op[0] = (BYTE)(128 /*special case*/ + (maxSymbolValue-1));
+ huffWeight[maxSymbolValue] = 0; /* to be sure it doesn't cause msan issue in final combination */
+ for (n=0; n<maxSymbolValue; n+=2)
+ op[(n/2)+1] = (BYTE)((huffWeight[n] << 4) + huffWeight[n+1]);
+ return ((maxSymbolValue+1)/2) + 1;
+}
+
+
+size_t HUF_readCTable (HUF_CElt* CTable, unsigned* maxSymbolValuePtr, const void* src, size_t srcSize)
+{
+ BYTE huffWeight[HUF_SYMBOLVALUE_MAX + 1]; /* init not required, even though some static analyzer may complain */
+ U32 rankVal[HUF_TABLELOG_ABSOLUTEMAX + 1]; /* large enough for values from 0 to 16 */
+ U32 tableLog = 0;
+ U32 nbSymbols = 0;
+
+ /* get symbol weights */
+ CHECK_V_F(readSize, HUF_readStats(huffWeight, HUF_SYMBOLVALUE_MAX+1, rankVal, &nbSymbols, &tableLog, src, srcSize));
+
+ /* check result */
+ if (tableLog > HUF_TABLELOG_MAX) return ERROR(tableLog_tooLarge);
+ if (nbSymbols > *maxSymbolValuePtr+1) return ERROR(maxSymbolValue_tooSmall);
+
+ /* Prepare base value per rank */
+ { U32 n, nextRankStart = 0;
+ for (n=1; n<=tableLog; n++) {
+ U32 current = nextRankStart;
+ nextRankStart += (rankVal[n] << (n-1));
+ rankVal[n] = current;
+ } }
+
+ /* fill nbBits */
+ { U32 n; for (n=0; n<nbSymbols; n++) {
+ const U32 w = huffWeight[n];
+ CTable[n].nbBits = (BYTE)(tableLog + 1 - w);
+ } }
+
+ /* fill val */
+ { U16 nbPerRank[HUF_TABLELOG_MAX+2] = {0}; /* support w=0=>n=tableLog+1 */
+ U16 valPerRank[HUF_TABLELOG_MAX+2] = {0};
+ { U32 n; for (n=0; n<nbSymbols; n++) nbPerRank[CTable[n].nbBits]++; }
+ /* determine stating value per rank */
+ valPerRank[tableLog+1] = 0; /* for w==0 */
+ { U16 min = 0;
+ U32 n; for (n=tableLog; n>0; n--) { /* start at n=tablelog <-> w=1 */
+ valPerRank[n] = min; /* get starting value within each rank */
+ min += nbPerRank[n];
+ min >>= 1;
+ } }
+ /* assign value within rank, symbol order */
+ { U32 n; for (n=0; n<nbSymbols; n++) CTable[n].val = valPerRank[CTable[n].nbBits]++; }
+ }
+
+ *maxSymbolValuePtr = nbSymbols - 1;
+ return readSize;
+}
+
+U32 HUF_getNbBits(const void* symbolTable, U32 symbolValue)
+{
+ const HUF_CElt* table = (const HUF_CElt*)symbolTable;
+ assert(symbolValue <= HUF_SYMBOLVALUE_MAX);
+ return table[symbolValue].nbBits;
+}
+
+
+typedef struct nodeElt_s {
+ U32 count;
+ U16 parent;
+ BYTE byte;
+ BYTE nbBits;
+} nodeElt;
+
+static U32 HUF_setMaxHeight(nodeElt* huffNode, U32 lastNonNull, U32 maxNbBits)
+{
+ const U32 largestBits = huffNode[lastNonNull].nbBits;
+ if (largestBits <= maxNbBits) return largestBits; /* early exit : no elt > maxNbBits */
+
+ /* there are several too large elements (at least >= 2) */
+ { int totalCost = 0;
+ const U32 baseCost = 1 << (largestBits - maxNbBits);
+ U32 n = lastNonNull;
+
+ while (huffNode[n].nbBits > maxNbBits) {
+ totalCost += baseCost - (1 << (largestBits - huffNode[n].nbBits));
+ huffNode[n].nbBits = (BYTE)maxNbBits;
+ n --;
+ } /* n stops at huffNode[n].nbBits <= maxNbBits */
+ while (huffNode[n].nbBits == maxNbBits) n--; /* n end at index of smallest symbol using < maxNbBits */
+
+ /* renorm totalCost */
+ totalCost >>= (largestBits - maxNbBits); /* note : totalCost is necessarily a multiple of baseCost */
+
+ /* repay normalized cost */
+ { U32 const noSymbol = 0xF0F0F0F0;
+ U32 rankLast[HUF_TABLELOG_MAX+2];
+ int pos;
+
+ /* Get pos of last (smallest) symbol per rank */
+ memset(rankLast, 0xF0, sizeof(rankLast));
+ { U32 currentNbBits = maxNbBits;
+ for (pos=n ; pos >= 0; pos--) {
+ if (huffNode[pos].nbBits >= currentNbBits) continue;
+ currentNbBits = huffNode[pos].nbBits; /* < maxNbBits */
+ rankLast[maxNbBits-currentNbBits] = pos;
+ } }
+
+ while (totalCost > 0) {
+ U32 nBitsToDecrease = BIT_highbit32(totalCost) + 1;
+ for ( ; nBitsToDecrease > 1; nBitsToDecrease--) {
+ U32 highPos = rankLast[nBitsToDecrease];
+ U32 lowPos = rankLast[nBitsToDecrease-1];
+ if (highPos == noSymbol) continue;
+ if (lowPos == noSymbol) break;
+ { U32 const highTotal = huffNode[highPos].count;
+ U32 const lowTotal = 2 * huffNode[lowPos].count;
+ if (highTotal <= lowTotal) break;
+ } }
+ /* only triggered when no more rank 1 symbol left => find closest one (note : there is necessarily at least one !) */
+ /* HUF_MAX_TABLELOG test just to please gcc 5+; but it should not be necessary */
+ while ((nBitsToDecrease<=HUF_TABLELOG_MAX) && (rankLast[nBitsToDecrease] == noSymbol))
+ nBitsToDecrease ++;
+ totalCost -= 1 << (nBitsToDecrease-1);
+ if (rankLast[nBitsToDecrease-1] == noSymbol)
+ rankLast[nBitsToDecrease-1] = rankLast[nBitsToDecrease]; /* this rank is no longer empty */
+ huffNode[rankLast[nBitsToDecrease]].nbBits ++;
+ if (rankLast[nBitsToDecrease] == 0) /* special case, reached largest symbol */
+ rankLast[nBitsToDecrease] = noSymbol;
+ else {
+ rankLast[nBitsToDecrease]--;
+ if (huffNode[rankLast[nBitsToDecrease]].nbBits != maxNbBits-nBitsToDecrease)
+ rankLast[nBitsToDecrease] = noSymbol; /* this rank is now empty */
+ } } /* while (totalCost > 0) */
+
+ while (totalCost < 0) { /* Sometimes, cost correction overshoot */
+ if (rankLast[1] == noSymbol) { /* special case : no rank 1 symbol (using maxNbBits-1); let's create one from largest rank 0 (using maxNbBits) */
+ while (huffNode[n].nbBits == maxNbBits) n--;
+ huffNode[n+1].nbBits--;
+ rankLast[1] = n+1;
+ totalCost++;
+ continue;
+ }
+ huffNode[ rankLast[1] + 1 ].nbBits--;
+ rankLast[1]++;
+ totalCost ++;
+ } } } /* there are several too large elements (at least >= 2) */
+
+ return maxNbBits;
+}
+
+
+typedef struct {
+ U32 base;
+ U32 current;
+} rankPos;
+
+static void HUF_sort(nodeElt* huffNode, const unsigned* count, U32 maxSymbolValue)
+{
+ rankPos rank[32];
+ U32 n;
+
+ memset(rank, 0, sizeof(rank));
+ for (n=0; n<=maxSymbolValue; n++) {
+ U32 r = BIT_highbit32(count[n] + 1);
+ rank[r].base ++;
+ }
+ for (n=30; n>0; n--) rank[n-1].base += rank[n].base;
+ for (n=0; n<32; n++) rank[n].current = rank[n].base;
+ for (n=0; n<=maxSymbolValue; n++) {
+ U32 const c = count[n];
+ U32 const r = BIT_highbit32(c+1) + 1;
+ U32 pos = rank[r].current++;
+ while ((pos > rank[r].base) && (c > huffNode[pos-1].count)) {
+ huffNode[pos] = huffNode[pos-1];
+ pos--;
+ }
+ huffNode[pos].count = c;
+ huffNode[pos].byte = (BYTE)n;
+ }
+}
+
+
+/** HUF_buildCTable_wksp() :
+ * Same as HUF_buildCTable(), but using externally allocated scratch buffer.
+ * `workSpace` must be aligned on 4-bytes boundaries, and be at least as large as a table of HUF_CTABLE_WORKSPACE_SIZE_U32 unsigned.
+ */
+#define STARTNODE (HUF_SYMBOLVALUE_MAX+1)
+typedef nodeElt huffNodeTable[HUF_CTABLE_WORKSPACE_SIZE_U32];
+size_t HUF_buildCTable_wksp (HUF_CElt* tree, const unsigned* count, U32 maxSymbolValue, U32 maxNbBits, void* workSpace, size_t wkspSize)
+{
+ nodeElt* const huffNode0 = (nodeElt*)workSpace;
+ nodeElt* const huffNode = huffNode0+1;
+ U32 n, nonNullRank;
+ int lowS, lowN;
+ U16 nodeNb = STARTNODE;
+ U32 nodeRoot;
+
+ /* safety checks */
+ if (((size_t)workSpace & 3) != 0) return ERROR(GENERIC); /* must be aligned on 4-bytes boundaries */
+ if (wkspSize < sizeof(huffNodeTable)) return ERROR(workSpace_tooSmall);
+ if (maxNbBits == 0) maxNbBits = HUF_TABLELOG_DEFAULT;
+ if (maxSymbolValue > HUF_SYMBOLVALUE_MAX) return ERROR(maxSymbolValue_tooLarge);
+ memset(huffNode0, 0, sizeof(huffNodeTable));
+
+ /* sort, decreasing order */
+ HUF_sort(huffNode, count, maxSymbolValue);
+
+ /* init for parents */
+ nonNullRank = maxSymbolValue;
+ while(huffNode[nonNullRank].count == 0) nonNullRank--;
+ lowS = nonNullRank; nodeRoot = nodeNb + lowS - 1; lowN = nodeNb;
+ huffNode[nodeNb].count = huffNode[lowS].count + huffNode[lowS-1].count;
+ huffNode[lowS].parent = huffNode[lowS-1].parent = nodeNb;
+ nodeNb++; lowS-=2;
+ for (n=nodeNb; n<=nodeRoot; n++) huffNode[n].count = (U32)(1U<<30);
+ huffNode0[0].count = (U32)(1U<<31); /* fake entry, strong barrier */
+
+ /* create parents */
+ while (nodeNb <= nodeRoot) {
+ U32 n1 = (huffNode[lowS].count < huffNode[lowN].count) ? lowS-- : lowN++;
+ U32 n2 = (huffNode[lowS].count < huffNode[lowN].count) ? lowS-- : lowN++;
+ huffNode[nodeNb].count = huffNode[n1].count + huffNode[n2].count;
+ huffNode[n1].parent = huffNode[n2].parent = nodeNb;
+ nodeNb++;
+ }
+
+ /* distribute weights (unlimited tree height) */
+ huffNode[nodeRoot].nbBits = 0;
+ for (n=nodeRoot-1; n>=STARTNODE; n--)
+ huffNode[n].nbBits = huffNode[ huffNode[n].parent ].nbBits + 1;
+ for (n=0; n<=nonNullRank; n++)
+ huffNode[n].nbBits = huffNode[ huffNode[n].parent ].nbBits + 1;
+
+ /* enforce maxTableLog */
+ maxNbBits = HUF_setMaxHeight(huffNode, nonNullRank, maxNbBits);
+
+ /* fill result into tree (val, nbBits) */
+ { U16 nbPerRank[HUF_TABLELOG_MAX+1] = {0};
+ U16 valPerRank[HUF_TABLELOG_MAX+1] = {0};
+ if (maxNbBits > HUF_TABLELOG_MAX) return ERROR(GENERIC); /* check fit into table */
+ for (n=0; n<=nonNullRank; n++)
+ nbPerRank[huffNode[n].nbBits]++;
+ /* determine stating value per rank */
+ { U16 min = 0;
+ for (n=maxNbBits; n>0; n--) {
+ valPerRank[n] = min; /* get starting value within each rank */
+ min += nbPerRank[n];
+ min >>= 1;
+ } }
+ for (n=0; n<=maxSymbolValue; n++)
+ tree[huffNode[n].byte].nbBits = huffNode[n].nbBits; /* push nbBits per symbol, symbol order */
+ for (n=0; n<=maxSymbolValue; n++)
+ tree[n].val = valPerRank[tree[n].nbBits]++; /* assign value within rank, symbol order */
+ }
+
+ return maxNbBits;
+}
+
+/** HUF_buildCTable() :
+ * @return : maxNbBits
+ * Note : count is used before tree is written, so they can safely overlap
+ */
+size_t HUF_buildCTable (HUF_CElt* tree, const unsigned* count, unsigned maxSymbolValue, unsigned maxNbBits)
+{
+ huffNodeTable nodeTable;
+ return HUF_buildCTable_wksp(tree, count, maxSymbolValue, maxNbBits, nodeTable, sizeof(nodeTable));
+}
+
+static size_t HUF_estimateCompressedSize(HUF_CElt* CTable, const unsigned* count, unsigned maxSymbolValue)
+{
+ size_t nbBits = 0;
+ int s;
+ for (s = 0; s <= (int)maxSymbolValue; ++s) {
+ nbBits += CTable[s].nbBits * count[s];
+ }
+ return nbBits >> 3;
+}
+
+static int HUF_validateCTable(const HUF_CElt* CTable, const unsigned* count, unsigned maxSymbolValue) {
+ int bad = 0;
+ int s;
+ for (s = 0; s <= (int)maxSymbolValue; ++s) {
+ bad |= (count[s] != 0) & (CTable[s].nbBits == 0);
+ }
+ return !bad;
+}
+
+size_t HUF_compressBound(size_t size) { return HUF_COMPRESSBOUND(size); }
+
+FORCE_INLINE_TEMPLATE void
+HUF_encodeSymbol(BIT_CStream_t* bitCPtr, U32 symbol, const HUF_CElt* CTable)
+{
+ BIT_addBitsFast(bitCPtr, CTable[symbol].val, CTable[symbol].nbBits);
+}
+
+#define HUF_FLUSHBITS(s) BIT_flushBits(s)
+
+#define HUF_FLUSHBITS_1(stream) \
+ if (sizeof((stream)->bitContainer)*8 < HUF_TABLELOG_MAX*2+7) HUF_FLUSHBITS(stream)
+
+#define HUF_FLUSHBITS_2(stream) \
+ if (sizeof((stream)->bitContainer)*8 < HUF_TABLELOG_MAX*4+7) HUF_FLUSHBITS(stream)
+
+FORCE_INLINE_TEMPLATE size_t
+HUF_compress1X_usingCTable_internal_body(void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ const HUF_CElt* CTable)
+{
+ const BYTE* ip = (const BYTE*) src;
+ BYTE* const ostart = (BYTE*)dst;
+ BYTE* const oend = ostart + dstSize;
+ BYTE* op = ostart;
+ size_t n;
+ BIT_CStream_t bitC;
+
+ /* init */
+ if (dstSize < 8) return 0; /* not enough space to compress */
+ { size_t const initErr = BIT_initCStream(&bitC, op, oend-op);
+ if (HUF_isError(initErr)) return 0; }
+
+ n = srcSize & ~3; /* join to mod 4 */
+ switch (srcSize & 3)
+ {
+ case 3 : HUF_encodeSymbol(&bitC, ip[n+ 2], CTable);
+ HUF_FLUSHBITS_2(&bitC);
+ /* fall-through */
+ case 2 : HUF_encodeSymbol(&bitC, ip[n+ 1], CTable);
+ HUF_FLUSHBITS_1(&bitC);
+ /* fall-through */
+ case 1 : HUF_encodeSymbol(&bitC, ip[n+ 0], CTable);
+ HUF_FLUSHBITS(&bitC);
+ /* fall-through */
+ case 0 : /* fall-through */
+ default: break;
+ }
+
+ for (; n>0; n-=4) { /* note : n&3==0 at this stage */
+ HUF_encodeSymbol(&bitC, ip[n- 1], CTable);
+ HUF_FLUSHBITS_1(&bitC);
+ HUF_encodeSymbol(&bitC, ip[n- 2], CTable);
+ HUF_FLUSHBITS_2(&bitC);
+ HUF_encodeSymbol(&bitC, ip[n- 3], CTable);
+ HUF_FLUSHBITS_1(&bitC);
+ HUF_encodeSymbol(&bitC, ip[n- 4], CTable);
+ HUF_FLUSHBITS(&bitC);
+ }
+
+ return BIT_closeCStream(&bitC);
+}
+
+#if DYNAMIC_BMI2
+
+static TARGET_ATTRIBUTE("bmi2") size_t
+HUF_compress1X_usingCTable_internal_bmi2(void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ const HUF_CElt* CTable)
+{
+ return HUF_compress1X_usingCTable_internal_body(dst, dstSize, src, srcSize, CTable);
+}
+
+static size_t
+HUF_compress1X_usingCTable_internal_default(void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ const HUF_CElt* CTable)
+{
+ return HUF_compress1X_usingCTable_internal_body(dst, dstSize, src, srcSize, CTable);
+}
+
+static size_t
+HUF_compress1X_usingCTable_internal(void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ const HUF_CElt* CTable, const int bmi2)
+{
+ if (bmi2) {
+ return HUF_compress1X_usingCTable_internal_bmi2(dst, dstSize, src, srcSize, CTable);
+ }
+ return HUF_compress1X_usingCTable_internal_default(dst, dstSize, src, srcSize, CTable);
+}
+
+#else
+
+static size_t
+HUF_compress1X_usingCTable_internal(void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ const HUF_CElt* CTable, const int bmi2)
+{
+ (void)bmi2;
+ return HUF_compress1X_usingCTable_internal_body(dst, dstSize, src, srcSize, CTable);
+}
+
+#endif
+
+size_t HUF_compress1X_usingCTable(void* dst, size_t dstSize, const void* src, size_t srcSize, const HUF_CElt* CTable)
+{
+ return HUF_compress1X_usingCTable_internal(dst, dstSize, src, srcSize, CTable, /* bmi2 */ 0);
+}
+
+
+static size_t
+HUF_compress4X_usingCTable_internal(void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ const HUF_CElt* CTable, int bmi2)
+{
+ size_t const segmentSize = (srcSize+3)/4; /* first 3 segments */
+ const BYTE* ip = (const BYTE*) src;
+ const BYTE* const iend = ip + srcSize;
+ BYTE* const ostart = (BYTE*) dst;
+ BYTE* const oend = ostart + dstSize;
+ BYTE* op = ostart;
+
+ if (dstSize < 6 + 1 + 1 + 1 + 8) return 0; /* minimum space to compress successfully */
+ if (srcSize < 12) return 0; /* no saving possible : too small input */
+ op += 6; /* jumpTable */
+
+ { CHECK_V_F(cSize, HUF_compress1X_usingCTable_internal(op, oend-op, ip, segmentSize, CTable, bmi2) );
+ if (cSize==0) return 0;
+ assert(cSize <= 65535);
+ MEM_writeLE16(ostart, (U16)cSize);
+ op += cSize;
+ }
+
+ ip += segmentSize;
+ { CHECK_V_F(cSize, HUF_compress1X_usingCTable_internal(op, oend-op, ip, segmentSize, CTable, bmi2) );
+ if (cSize==0) return 0;
+ assert(cSize <= 65535);
+ MEM_writeLE16(ostart+2, (U16)cSize);
+ op += cSize;
+ }
+
+ ip += segmentSize;
+ { CHECK_V_F(cSize, HUF_compress1X_usingCTable_internal(op, oend-op, ip, segmentSize, CTable, bmi2) );
+ if (cSize==0) return 0;
+ assert(cSize <= 65535);
+ MEM_writeLE16(ostart+4, (U16)cSize);
+ op += cSize;
+ }
+
+ ip += segmentSize;
+ { CHECK_V_F(cSize, HUF_compress1X_usingCTable_internal(op, oend-op, ip, iend-ip, CTable, bmi2) );
+ if (cSize==0) return 0;
+ op += cSize;
+ }
+
+ return op-ostart;
+}
+
+size_t HUF_compress4X_usingCTable(void* dst, size_t dstSize, const void* src, size_t srcSize, const HUF_CElt* CTable)
+{
+ return HUF_compress4X_usingCTable_internal(dst, dstSize, src, srcSize, CTable, /* bmi2 */ 0);
+}
+
+typedef enum { HUF_singleStream, HUF_fourStreams } HUF_nbStreams_e;
+
+static size_t HUF_compressCTable_internal(
+ BYTE* const ostart, BYTE* op, BYTE* const oend,
+ const void* src, size_t srcSize,
+ HUF_nbStreams_e nbStreams, const HUF_CElt* CTable, const int bmi2)
+{
+ size_t const cSize = (nbStreams==HUF_singleStream) ?
+ HUF_compress1X_usingCTable_internal(op, oend - op, src, srcSize, CTable, bmi2) :
+ HUF_compress4X_usingCTable_internal(op, oend - op, src, srcSize, CTable, bmi2);
+ if (HUF_isError(cSize)) { return cSize; }
+ if (cSize==0) { return 0; } /* uncompressible */
+ op += cSize;
+ /* check compressibility */
+ if ((size_t)(op-ostart) >= srcSize-1) { return 0; }
+ return op-ostart;
+}
+
+typedef struct {
+ unsigned count[HUF_SYMBOLVALUE_MAX + 1];
+ HUF_CElt CTable[HUF_SYMBOLVALUE_MAX + 1];
+ huffNodeTable nodeTable;
+} HUF_compress_tables_t;
+
+/* HUF_compress_internal() :
+ * `workSpace` must a table of at least HUF_WORKSPACE_SIZE_U32 unsigned */
+static size_t
+HUF_compress_internal (void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned huffLog,
+ HUF_nbStreams_e nbStreams,
+ void* workSpace, size_t wkspSize,
+ HUF_CElt* oldHufTable, HUF_repeat* repeat, int preferRepeat,
+ const int bmi2)
+{
+ HUF_compress_tables_t* const table = (HUF_compress_tables_t*)workSpace;
+ BYTE* const ostart = (BYTE*)dst;
+ BYTE* const oend = ostart + dstSize;
+ BYTE* op = ostart;
+
+ /* checks & inits */
+ if (((size_t)workSpace & 3) != 0) return ERROR(GENERIC); /* must be aligned on 4-bytes boundaries */
+ if (wkspSize < HUF_WORKSPACE_SIZE) return ERROR(workSpace_tooSmall);
+ if (!srcSize) return 0; /* Uncompressed */
+ if (!dstSize) return 0; /* cannot fit anything within dst budget */
+ if (srcSize > HUF_BLOCKSIZE_MAX) return ERROR(srcSize_wrong); /* current block size limit */
+ if (huffLog > HUF_TABLELOG_MAX) return ERROR(tableLog_tooLarge);
+ if (maxSymbolValue > HUF_SYMBOLVALUE_MAX) return ERROR(maxSymbolValue_tooLarge);
+ if (!maxSymbolValue) maxSymbolValue = HUF_SYMBOLVALUE_MAX;
+ if (!huffLog) huffLog = HUF_TABLELOG_DEFAULT;
+
+ /* Heuristic : If old table is valid, use it for small inputs */
+ if (preferRepeat && repeat && *repeat == HUF_repeat_valid) {
+ return HUF_compressCTable_internal(ostart, op, oend,
+ src, srcSize,
+ nbStreams, oldHufTable, bmi2);
+ }
+
+ /* Scan input and build symbol stats */
+ { CHECK_V_F(largest, HIST_count_wksp (table->count, &maxSymbolValue, (const BYTE*)src, srcSize, workSpace, wkspSize) );
+ if (largest == srcSize) { *ostart = ((const BYTE*)src)[0]; return 1; } /* single symbol, rle */
+ if (largest <= (srcSize >> 7)+4) return 0; /* heuristic : probably not compressible enough */
+ }
+
+ /* Check validity of previous table */
+ if ( repeat
+ && *repeat == HUF_repeat_check
+ && !HUF_validateCTable(oldHufTable, table->count, maxSymbolValue)) {
+ *repeat = HUF_repeat_none;
+ }
+ /* Heuristic : use existing table for small inputs */
+ if (preferRepeat && repeat && *repeat != HUF_repeat_none) {
+ return HUF_compressCTable_internal(ostart, op, oend,
+ src, srcSize,
+ nbStreams, oldHufTable, bmi2);
+ }
+
+ /* Build Huffman Tree */
+ huffLog = HUF_optimalTableLog(huffLog, srcSize, maxSymbolValue);
+ { size_t const maxBits = HUF_buildCTable_wksp(table->CTable, table->count,
+ maxSymbolValue, huffLog,
+ table->nodeTable, sizeof(table->nodeTable));
+ CHECK_F(maxBits);
+ huffLog = (U32)maxBits;
+ /* Zero unused symbols in CTable, so we can check it for validity */
+ memset(table->CTable + (maxSymbolValue + 1), 0,
+ sizeof(table->CTable) - ((maxSymbolValue + 1) * sizeof(HUF_CElt)));
+ }
+
+ /* Write table description header */
+ { CHECK_V_F(hSize, HUF_writeCTable (op, dstSize, table->CTable, maxSymbolValue, huffLog) );
+ /* Check if using previous huffman table is beneficial */
+ if (repeat && *repeat != HUF_repeat_none) {
+ size_t const oldSize = HUF_estimateCompressedSize(oldHufTable, table->count, maxSymbolValue);
+ size_t const newSize = HUF_estimateCompressedSize(table->CTable, table->count, maxSymbolValue);
+ if (oldSize <= hSize + newSize || hSize + 12 >= srcSize) {
+ return HUF_compressCTable_internal(ostart, op, oend,
+ src, srcSize,
+ nbStreams, oldHufTable, bmi2);
+ } }
+
+ /* Use the new huffman table */
+ if (hSize + 12ul >= srcSize) { return 0; }
+ op += hSize;
+ if (repeat) { *repeat = HUF_repeat_none; }
+ if (oldHufTable)
+ memcpy(oldHufTable, table->CTable, sizeof(table->CTable)); /* Save new table */
+ }
+ return HUF_compressCTable_internal(ostart, op, oend,
+ src, srcSize,
+ nbStreams, table->CTable, bmi2);
+}
+
+
+size_t HUF_compress1X_wksp (void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned huffLog,
+ void* workSpace, size_t wkspSize)
+{
+ return HUF_compress_internal(dst, dstSize, src, srcSize,
+ maxSymbolValue, huffLog, HUF_singleStream,
+ workSpace, wkspSize,
+ NULL, NULL, 0, 0 /*bmi2*/);
+}
+
+size_t HUF_compress1X_repeat (void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned huffLog,
+ void* workSpace, size_t wkspSize,
+ HUF_CElt* hufTable, HUF_repeat* repeat, int preferRepeat, int bmi2)
+{
+ return HUF_compress_internal(dst, dstSize, src, srcSize,
+ maxSymbolValue, huffLog, HUF_singleStream,
+ workSpace, wkspSize, hufTable,
+ repeat, preferRepeat, bmi2);
+}
+
+size_t HUF_compress1X (void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned huffLog)
+{
+ unsigned workSpace[HUF_WORKSPACE_SIZE_U32];
+ return HUF_compress1X_wksp(dst, dstSize, src, srcSize, maxSymbolValue, huffLog, workSpace, sizeof(workSpace));
+}
+
+/* HUF_compress4X_repeat():
+ * compress input using 4 streams.
+ * provide workspace to generate compression tables */
+size_t HUF_compress4X_wksp (void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned huffLog,
+ void* workSpace, size_t wkspSize)
+{
+ return HUF_compress_internal(dst, dstSize, src, srcSize,
+ maxSymbolValue, huffLog, HUF_fourStreams,
+ workSpace, wkspSize,
+ NULL, NULL, 0, 0 /*bmi2*/);
+}
+
+/* HUF_compress4X_repeat():
+ * compress input using 4 streams.
+ * re-use an existing huffman compression table */
+size_t HUF_compress4X_repeat (void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned huffLog,
+ void* workSpace, size_t wkspSize,
+ HUF_CElt* hufTable, HUF_repeat* repeat, int preferRepeat, int bmi2)
+{
+ return HUF_compress_internal(dst, dstSize, src, srcSize,
+ maxSymbolValue, huffLog, HUF_fourStreams,
+ workSpace, wkspSize,
+ hufTable, repeat, preferRepeat, bmi2);
+}
+
+size_t HUF_compress2 (void* dst, size_t dstSize,
+ const void* src, size_t srcSize,
+ unsigned maxSymbolValue, unsigned huffLog)
+{
+ unsigned workSpace[HUF_WORKSPACE_SIZE_U32];
+ return HUF_compress4X_wksp(dst, dstSize, src, srcSize, maxSymbolValue, huffLog, workSpace, sizeof(workSpace));
+}
+
+size_t HUF_compress (void* dst, size_t maxDstSize, const void* src, size_t srcSize)
+{
+ return HUF_compress2(dst, maxDstSize, src, srcSize, 255, HUF_TABLELOG_DEFAULT);
+}
diff --git a/Utilities/cmzstd/lib/compress/zstd_compress.c b/Utilities/cmzstd/lib/compress/zstd_compress.c
new file mode 100644
index 000000000..c2c9d3bc5
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstd_compress.c
@@ -0,0 +1,4290 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+/*-*************************************
+* Dependencies
+***************************************/
+#include <limits.h> /* INT_MAX */
+#include <string.h> /* memset */
+#include "cpu.h"
+#include "mem.h"
+#include "hist.h" /* HIST_countFast_wksp */
+#define FSE_STATIC_LINKING_ONLY /* FSE_encodeSymbol */
+#include "fse.h"
+#define HUF_STATIC_LINKING_ONLY
+#include "huf.h"
+#include "zstd_compress_internal.h"
+#include "zstd_fast.h"
+#include "zstd_double_fast.h"
+#include "zstd_lazy.h"
+#include "zstd_opt.h"
+#include "zstd_ldm.h"
+
+
+/*-*************************************
+* Helper functions
+***************************************/
+size_t ZSTD_compressBound(size_t srcSize) {
+ return ZSTD_COMPRESSBOUND(srcSize);
+}
+
+
+/*-*************************************
+* Context memory management
+***************************************/
+struct ZSTD_CDict_s {
+ void* dictBuffer;
+ const void* dictContent;
+ size_t dictContentSize;
+ void* workspace;
+ size_t workspaceSize;
+ ZSTD_matchState_t matchState;
+ ZSTD_compressedBlockState_t cBlockState;
+ ZSTD_customMem customMem;
+ U32 dictID;
+}; /* typedef'd to ZSTD_CDict within "zstd.h" */
+
+ZSTD_CCtx* ZSTD_createCCtx(void)
+{
+ return ZSTD_createCCtx_advanced(ZSTD_defaultCMem);
+}
+
+static void ZSTD_initCCtx(ZSTD_CCtx* cctx, ZSTD_customMem memManager)
+{
+ assert(cctx != NULL);
+ memset(cctx, 0, sizeof(*cctx));
+ cctx->customMem = memManager;
+ cctx->bmi2 = ZSTD_cpuid_bmi2(ZSTD_cpuid());
+ { size_t const err = ZSTD_CCtx_reset(cctx, ZSTD_reset_parameters);
+ assert(!ZSTD_isError(err));
+ (void)err;
+ }
+}
+
+ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem)
+{
+ ZSTD_STATIC_ASSERT(zcss_init==0);
+ ZSTD_STATIC_ASSERT(ZSTD_CONTENTSIZE_UNKNOWN==(0ULL - 1));
+ if (!customMem.customAlloc ^ !customMem.customFree) return NULL;
+ { ZSTD_CCtx* const cctx = (ZSTD_CCtx*)ZSTD_malloc(sizeof(ZSTD_CCtx), customMem);
+ if (!cctx) return NULL;
+ ZSTD_initCCtx(cctx, customMem);
+ return cctx;
+ }
+}
+
+ZSTD_CCtx* ZSTD_initStaticCCtx(void *workspace, size_t workspaceSize)
+{
+ ZSTD_CCtx* const cctx = (ZSTD_CCtx*) workspace;
+ if (workspaceSize <= sizeof(ZSTD_CCtx)) return NULL; /* minimum size */
+ if ((size_t)workspace & 7) return NULL; /* must be 8-aligned */
+ memset(workspace, 0, workspaceSize); /* may be a bit generous, could memset be smaller ? */
+ cctx->staticSize = workspaceSize;
+ cctx->workSpace = (void*)(cctx+1);
+ cctx->workSpaceSize = workspaceSize - sizeof(ZSTD_CCtx);
+
+ /* statically sized space. entropyWorkspace never moves (but prev/next block swap places) */
+ if (cctx->workSpaceSize < HUF_WORKSPACE_SIZE + 2 * sizeof(ZSTD_compressedBlockState_t)) return NULL;
+ assert(((size_t)cctx->workSpace & (sizeof(void*)-1)) == 0); /* ensure correct alignment */
+ cctx->blockState.prevCBlock = (ZSTD_compressedBlockState_t*)cctx->workSpace;
+ cctx->blockState.nextCBlock = cctx->blockState.prevCBlock + 1;
+ {
+ void* const ptr = cctx->blockState.nextCBlock + 1;
+ cctx->entropyWorkspace = (U32*)ptr;
+ }
+ cctx->bmi2 = ZSTD_cpuid_bmi2(ZSTD_cpuid());
+ return cctx;
+}
+
+static void ZSTD_freeCCtxContent(ZSTD_CCtx* cctx)
+{
+ assert(cctx != NULL);
+ assert(cctx->staticSize == 0);
+ ZSTD_free(cctx->workSpace, cctx->customMem); cctx->workSpace = NULL;
+ ZSTD_freeCDict(cctx->cdictLocal); cctx->cdictLocal = NULL;
+#ifdef ZSTD_MULTITHREAD
+ ZSTDMT_freeCCtx(cctx->mtctx); cctx->mtctx = NULL;
+#endif
+}
+
+size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx)
+{
+ if (cctx==NULL) return 0; /* support free on NULL */
+ if (cctx->staticSize) return ERROR(memory_allocation); /* not compatible with static CCtx */
+ ZSTD_freeCCtxContent(cctx);
+ ZSTD_free(cctx, cctx->customMem);
+ return 0;
+}
+
+
+static size_t ZSTD_sizeof_mtctx(const ZSTD_CCtx* cctx)
+{
+#ifdef ZSTD_MULTITHREAD
+ return ZSTDMT_sizeof_CCtx(cctx->mtctx);
+#else
+ (void)cctx;
+ return 0;
+#endif
+}
+
+
+size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx)
+{
+ if (cctx==NULL) return 0; /* support sizeof on NULL */
+ return sizeof(*cctx) + cctx->workSpaceSize
+ + ZSTD_sizeof_CDict(cctx->cdictLocal)
+ + ZSTD_sizeof_mtctx(cctx);
+}
+
+size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs)
+{
+ return ZSTD_sizeof_CCtx(zcs); /* same object */
+}
+
+/* private API call, for dictBuilder only */
+const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx) { return &(ctx->seqStore); }
+
+static ZSTD_CCtx_params ZSTD_makeCCtxParamsFromCParams(
+ ZSTD_compressionParameters cParams)
+{
+ ZSTD_CCtx_params cctxParams;
+ memset(&cctxParams, 0, sizeof(cctxParams));
+ cctxParams.cParams = cParams;
+ cctxParams.compressionLevel = ZSTD_CLEVEL_DEFAULT; /* should not matter, as all cParams are presumed properly defined */
+ assert(!ZSTD_checkCParams(cParams));
+ cctxParams.fParams.contentSizeFlag = 1;
+ return cctxParams;
+}
+
+static ZSTD_CCtx_params* ZSTD_createCCtxParams_advanced(
+ ZSTD_customMem customMem)
+{
+ ZSTD_CCtx_params* params;
+ if (!customMem.customAlloc ^ !customMem.customFree) return NULL;
+ params = (ZSTD_CCtx_params*)ZSTD_calloc(
+ sizeof(ZSTD_CCtx_params), customMem);
+ if (!params) { return NULL; }
+ params->customMem = customMem;
+ params->compressionLevel = ZSTD_CLEVEL_DEFAULT;
+ params->fParams.contentSizeFlag = 1;
+ return params;
+}
+
+ZSTD_CCtx_params* ZSTD_createCCtxParams(void)
+{
+ return ZSTD_createCCtxParams_advanced(ZSTD_defaultCMem);
+}
+
+size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params)
+{
+ if (params == NULL) { return 0; }
+ ZSTD_free(params, params->customMem);
+ return 0;
+}
+
+size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params* params)
+{
+ return ZSTD_CCtxParams_init(params, ZSTD_CLEVEL_DEFAULT);
+}
+
+size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compressionLevel) {
+ if (!cctxParams) { return ERROR(GENERIC); }
+ memset(cctxParams, 0, sizeof(*cctxParams));
+ cctxParams->compressionLevel = compressionLevel;
+ cctxParams->fParams.contentSizeFlag = 1;
+ return 0;
+}
+
+size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params)
+{
+ if (!cctxParams) { return ERROR(GENERIC); }
+ CHECK_F( ZSTD_checkCParams(params.cParams) );
+ memset(cctxParams, 0, sizeof(*cctxParams));
+ cctxParams->cParams = params.cParams;
+ cctxParams->fParams = params.fParams;
+ cctxParams->compressionLevel = ZSTD_CLEVEL_DEFAULT; /* should not matter, as all cParams are presumed properly defined */
+ assert(!ZSTD_checkCParams(params.cParams));
+ return 0;
+}
+
+/* ZSTD_assignParamsToCCtxParams() :
+ * params is presumed valid at this stage */
+static ZSTD_CCtx_params ZSTD_assignParamsToCCtxParams(
+ ZSTD_CCtx_params cctxParams, ZSTD_parameters params)
+{
+ ZSTD_CCtx_params ret = cctxParams;
+ ret.cParams = params.cParams;
+ ret.fParams = params.fParams;
+ ret.compressionLevel = ZSTD_CLEVEL_DEFAULT; /* should not matter, as all cParams are presumed properly defined */
+ assert(!ZSTD_checkCParams(params.cParams));
+ return ret;
+}
+
+ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter param)
+{
+ ZSTD_bounds bounds = { 0, 0, 0 };
+
+ switch(param)
+ {
+ case ZSTD_c_compressionLevel:
+ bounds.lowerBound = ZSTD_minCLevel();
+ bounds.upperBound = ZSTD_maxCLevel();
+ return bounds;
+
+ case ZSTD_c_windowLog:
+ bounds.lowerBound = ZSTD_WINDOWLOG_MIN;
+ bounds.upperBound = ZSTD_WINDOWLOG_MAX;
+ return bounds;
+
+ case ZSTD_c_hashLog:
+ bounds.lowerBound = ZSTD_HASHLOG_MIN;
+ bounds.upperBound = ZSTD_HASHLOG_MAX;
+ return bounds;
+
+ case ZSTD_c_chainLog:
+ bounds.lowerBound = ZSTD_CHAINLOG_MIN;
+ bounds.upperBound = ZSTD_CHAINLOG_MAX;
+ return bounds;
+
+ case ZSTD_c_searchLog:
+ bounds.lowerBound = ZSTD_SEARCHLOG_MIN;
+ bounds.upperBound = ZSTD_SEARCHLOG_MAX;
+ return bounds;
+
+ case ZSTD_c_minMatch:
+ bounds.lowerBound = ZSTD_MINMATCH_MIN;
+ bounds.upperBound = ZSTD_MINMATCH_MAX;
+ return bounds;
+
+ case ZSTD_c_targetLength:
+ bounds.lowerBound = ZSTD_TARGETLENGTH_MIN;
+ bounds.upperBound = ZSTD_TARGETLENGTH_MAX;
+ return bounds;
+
+ case ZSTD_c_strategy:
+ bounds.lowerBound = ZSTD_STRATEGY_MIN;
+ bounds.upperBound = ZSTD_STRATEGY_MAX;
+ return bounds;
+
+ case ZSTD_c_contentSizeFlag:
+ bounds.lowerBound = 0;
+ bounds.upperBound = 1;
+ return bounds;
+
+ case ZSTD_c_checksumFlag:
+ bounds.lowerBound = 0;
+ bounds.upperBound = 1;
+ return bounds;
+
+ case ZSTD_c_dictIDFlag:
+ bounds.lowerBound = 0;
+ bounds.upperBound = 1;
+ return bounds;
+
+ case ZSTD_c_nbWorkers:
+ bounds.lowerBound = 0;
+#ifdef ZSTD_MULTITHREAD
+ bounds.upperBound = ZSTDMT_NBWORKERS_MAX;
+#else
+ bounds.upperBound = 0;
+#endif
+ return bounds;
+
+ case ZSTD_c_jobSize:
+ bounds.lowerBound = 0;
+#ifdef ZSTD_MULTITHREAD
+ bounds.upperBound = ZSTDMT_JOBSIZE_MAX;
+#else
+ bounds.upperBound = 0;
+#endif
+ return bounds;
+
+ case ZSTD_c_overlapLog:
+ bounds.lowerBound = ZSTD_OVERLAPLOG_MIN;
+ bounds.upperBound = ZSTD_OVERLAPLOG_MAX;
+ return bounds;
+
+ case ZSTD_c_enableLongDistanceMatching:
+ bounds.lowerBound = 0;
+ bounds.upperBound = 1;
+ return bounds;
+
+ case ZSTD_c_ldmHashLog:
+ bounds.lowerBound = ZSTD_LDM_HASHLOG_MIN;
+ bounds.upperBound = ZSTD_LDM_HASHLOG_MAX;
+ return bounds;
+
+ case ZSTD_c_ldmMinMatch:
+ bounds.lowerBound = ZSTD_LDM_MINMATCH_MIN;
+ bounds.upperBound = ZSTD_LDM_MINMATCH_MAX;
+ return bounds;
+
+ case ZSTD_c_ldmBucketSizeLog:
+ bounds.lowerBound = ZSTD_LDM_BUCKETSIZELOG_MIN;
+ bounds.upperBound = ZSTD_LDM_BUCKETSIZELOG_MAX;
+ return bounds;
+
+ case ZSTD_c_ldmHashRateLog:
+ bounds.lowerBound = ZSTD_LDM_HASHRATELOG_MIN;
+ bounds.upperBound = ZSTD_LDM_HASHRATELOG_MAX;
+ return bounds;
+
+ /* experimental parameters */
+ case ZSTD_c_rsyncable:
+ bounds.lowerBound = 0;
+ bounds.upperBound = 1;
+ return bounds;
+
+ case ZSTD_c_forceMaxWindow :
+ bounds.lowerBound = 0;
+ bounds.upperBound = 1;
+ return bounds;
+
+ case ZSTD_c_format:
+ ZSTD_STATIC_ASSERT(ZSTD_f_zstd1 < ZSTD_f_zstd1_magicless);
+ bounds.lowerBound = ZSTD_f_zstd1;
+ bounds.upperBound = ZSTD_f_zstd1_magicless; /* note : how to ensure at compile time that this is the highest value enum ? */
+ return bounds;
+
+ case ZSTD_c_forceAttachDict:
+ ZSTD_STATIC_ASSERT(ZSTD_dictDefaultAttach < ZSTD_dictForceCopy);
+ bounds.lowerBound = ZSTD_dictDefaultAttach;
+ bounds.upperBound = ZSTD_dictForceCopy; /* note : how to ensure at compile time that this is the highest value enum ? */
+ return bounds;
+
+ default:
+ { ZSTD_bounds const boundError = { ERROR(parameter_unsupported), 0, 0 };
+ return boundError;
+ }
+ }
+}
+
+/* ZSTD_cParam_withinBounds:
+ * @return 1 if value is within cParam bounds,
+ * 0 otherwise */
+static int ZSTD_cParam_withinBounds(ZSTD_cParameter cParam, int value)
+{
+ ZSTD_bounds const bounds = ZSTD_cParam_getBounds(cParam);
+ if (ZSTD_isError(bounds.error)) return 0;
+ if (value < bounds.lowerBound) return 0;
+ if (value > bounds.upperBound) return 0;
+ return 1;
+}
+
+#define BOUNDCHECK(cParam, val) { \
+ if (!ZSTD_cParam_withinBounds(cParam,val)) { \
+ return ERROR(parameter_outOfBound); \
+} }
+
+
+static int ZSTD_isUpdateAuthorized(ZSTD_cParameter param)
+{
+ switch(param)
+ {
+ case ZSTD_c_compressionLevel:
+ case ZSTD_c_hashLog:
+ case ZSTD_c_chainLog:
+ case ZSTD_c_searchLog:
+ case ZSTD_c_minMatch:
+ case ZSTD_c_targetLength:
+ case ZSTD_c_strategy:
+ return 1;
+
+ case ZSTD_c_format:
+ case ZSTD_c_windowLog:
+ case ZSTD_c_contentSizeFlag:
+ case ZSTD_c_checksumFlag:
+ case ZSTD_c_dictIDFlag:
+ case ZSTD_c_forceMaxWindow :
+ case ZSTD_c_nbWorkers:
+ case ZSTD_c_jobSize:
+ case ZSTD_c_overlapLog:
+ case ZSTD_c_rsyncable:
+ case ZSTD_c_enableLongDistanceMatching:
+ case ZSTD_c_ldmHashLog:
+ case ZSTD_c_ldmMinMatch:
+ case ZSTD_c_ldmBucketSizeLog:
+ case ZSTD_c_ldmHashRateLog:
+ case ZSTD_c_forceAttachDict:
+ default:
+ return 0;
+ }
+}
+
+size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value)
+{
+ DEBUGLOG(4, "ZSTD_CCtx_setParameter (%i, %i)", (int)param, value);
+ if (cctx->streamStage != zcss_init) {
+ if (ZSTD_isUpdateAuthorized(param)) {
+ cctx->cParamsChanged = 1;
+ } else {
+ return ERROR(stage_wrong);
+ } }
+
+ switch(param)
+ {
+ case ZSTD_c_format :
+ return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
+
+ case ZSTD_c_compressionLevel:
+ if (cctx->cdict) return ERROR(stage_wrong);
+ return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
+
+ case ZSTD_c_windowLog:
+ case ZSTD_c_hashLog:
+ case ZSTD_c_chainLog:
+ case ZSTD_c_searchLog:
+ case ZSTD_c_minMatch:
+ case ZSTD_c_targetLength:
+ case ZSTD_c_strategy:
+ if (cctx->cdict) return ERROR(stage_wrong);
+ return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
+
+ case ZSTD_c_contentSizeFlag:
+ case ZSTD_c_checksumFlag:
+ case ZSTD_c_dictIDFlag:
+ return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
+
+ case ZSTD_c_forceMaxWindow : /* Force back-references to remain < windowSize,
+ * even when referencing into Dictionary content.
+ * default : 0 when using a CDict, 1 when using a Prefix */
+ return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
+
+ case ZSTD_c_forceAttachDict:
+ return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
+
+ case ZSTD_c_nbWorkers:
+ if ((value!=0) && cctx->staticSize) {
+ return ERROR(parameter_unsupported); /* MT not compatible with static alloc */
+ }
+ return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
+
+ case ZSTD_c_jobSize:
+ case ZSTD_c_overlapLog:
+ case ZSTD_c_rsyncable:
+ return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
+
+ case ZSTD_c_enableLongDistanceMatching:
+ case ZSTD_c_ldmHashLog:
+ case ZSTD_c_ldmMinMatch:
+ case ZSTD_c_ldmBucketSizeLog:
+ case ZSTD_c_ldmHashRateLog:
+ if (cctx->cdict) return ERROR(stage_wrong);
+ return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value);
+
+ default: return ERROR(parameter_unsupported);
+ }
+}
+
+size_t ZSTD_CCtxParam_setParameter(ZSTD_CCtx_params* CCtxParams,
+ ZSTD_cParameter param, int value)
+{
+ DEBUGLOG(4, "ZSTD_CCtxParam_setParameter (%i, %i)", (int)param, value);
+ switch(param)
+ {
+ case ZSTD_c_format :
+ BOUNDCHECK(ZSTD_c_format, value);
+ CCtxParams->format = (ZSTD_format_e)value;
+ return (size_t)CCtxParams->format;
+
+ case ZSTD_c_compressionLevel : {
+ int cLevel = value;
+ if (cLevel > ZSTD_maxCLevel()) cLevel = ZSTD_maxCLevel();
+ if (cLevel < ZSTD_minCLevel()) cLevel = ZSTD_minCLevel();
+ if (cLevel) { /* 0 : does not change current level */
+ CCtxParams->compressionLevel = cLevel;
+ }
+ if (CCtxParams->compressionLevel >= 0) return CCtxParams->compressionLevel;
+ return 0; /* return type (size_t) cannot represent negative values */
+ }
+
+ case ZSTD_c_windowLog :
+ if (value!=0) /* 0 => use default */
+ BOUNDCHECK(ZSTD_c_windowLog, value);
+ CCtxParams->cParams.windowLog = value;
+ return CCtxParams->cParams.windowLog;
+
+ case ZSTD_c_hashLog :
+ if (value!=0) /* 0 => use default */
+ BOUNDCHECK(ZSTD_c_hashLog, value);
+ CCtxParams->cParams.hashLog = value;
+ return CCtxParams->cParams.hashLog;
+
+ case ZSTD_c_chainLog :
+ if (value!=0) /* 0 => use default */
+ BOUNDCHECK(ZSTD_c_chainLog, value);
+ CCtxParams->cParams.chainLog = value;
+ return CCtxParams->cParams.chainLog;
+
+ case ZSTD_c_searchLog :
+ if (value!=0) /* 0 => use default */
+ BOUNDCHECK(ZSTD_c_searchLog, value);
+ CCtxParams->cParams.searchLog = value;
+ return value;
+
+ case ZSTD_c_minMatch :
+ if (value!=0) /* 0 => use default */
+ BOUNDCHECK(ZSTD_c_minMatch, value);
+ CCtxParams->cParams.minMatch = value;
+ return CCtxParams->cParams.minMatch;
+
+ case ZSTD_c_targetLength :
+ BOUNDCHECK(ZSTD_c_targetLength, value);
+ CCtxParams->cParams.targetLength = value;
+ return CCtxParams->cParams.targetLength;
+
+ case ZSTD_c_strategy :
+ if (value!=0) /* 0 => use default */
+ BOUNDCHECK(ZSTD_c_strategy, value);
+ CCtxParams->cParams.strategy = (ZSTD_strategy)value;
+ return (size_t)CCtxParams->cParams.strategy;
+
+ case ZSTD_c_contentSizeFlag :
+ /* Content size written in frame header _when known_ (default:1) */
+ DEBUGLOG(4, "set content size flag = %u", (value!=0));
+ CCtxParams->fParams.contentSizeFlag = value != 0;
+ return CCtxParams->fParams.contentSizeFlag;
+
+ case ZSTD_c_checksumFlag :
+ /* A 32-bits content checksum will be calculated and written at end of frame (default:0) */
+ CCtxParams->fParams.checksumFlag = value != 0;
+ return CCtxParams->fParams.checksumFlag;
+
+ case ZSTD_c_dictIDFlag : /* When applicable, dictionary's dictID is provided in frame header (default:1) */
+ DEBUGLOG(4, "set dictIDFlag = %u", (value!=0));
+ CCtxParams->fParams.noDictIDFlag = !value;
+ return !CCtxParams->fParams.noDictIDFlag;
+
+ case ZSTD_c_forceMaxWindow :
+ CCtxParams->forceWindow = (value != 0);
+ return CCtxParams->forceWindow;
+
+ case ZSTD_c_forceAttachDict : {
+ const ZSTD_dictAttachPref_e pref = (ZSTD_dictAttachPref_e)value;
+ BOUNDCHECK(ZSTD_c_forceAttachDict, pref);
+ CCtxParams->attachDictPref = pref;
+ return CCtxParams->attachDictPref;
+ }
+
+ case ZSTD_c_nbWorkers :
+#ifndef ZSTD_MULTITHREAD
+ if (value!=0) return ERROR(parameter_unsupported);
+ return 0;
+#else
+ return ZSTDMT_CCtxParam_setNbWorkers(CCtxParams, value);
+#endif
+
+ case ZSTD_c_jobSize :
+#ifndef ZSTD_MULTITHREAD
+ return ERROR(parameter_unsupported);
+#else
+ return ZSTDMT_CCtxParam_setMTCtxParameter(CCtxParams, ZSTDMT_p_jobSize, value);
+#endif
+
+ case ZSTD_c_overlapLog :
+#ifndef ZSTD_MULTITHREAD
+ return ERROR(parameter_unsupported);
+#else
+ return ZSTDMT_CCtxParam_setMTCtxParameter(CCtxParams, ZSTDMT_p_overlapLog, value);
+#endif
+
+ case ZSTD_c_rsyncable :
+#ifndef ZSTD_MULTITHREAD
+ return ERROR(parameter_unsupported);
+#else
+ return ZSTDMT_CCtxParam_setMTCtxParameter(CCtxParams, ZSTDMT_p_rsyncable, value);
+#endif
+
+ case ZSTD_c_enableLongDistanceMatching :
+ CCtxParams->ldmParams.enableLdm = (value!=0);
+ return CCtxParams->ldmParams.enableLdm;
+
+ case ZSTD_c_ldmHashLog :
+ if (value!=0) /* 0 ==> auto */
+ BOUNDCHECK(ZSTD_c_ldmHashLog, value);
+ CCtxParams->ldmParams.hashLog = value;
+ return CCtxParams->ldmParams.hashLog;
+
+ case ZSTD_c_ldmMinMatch :
+ if (value!=0) /* 0 ==> default */
+ BOUNDCHECK(ZSTD_c_ldmMinMatch, value);
+ CCtxParams->ldmParams.minMatchLength = value;
+ return CCtxParams->ldmParams.minMatchLength;
+
+ case ZSTD_c_ldmBucketSizeLog :
+ if (value!=0) /* 0 ==> default */
+ BOUNDCHECK(ZSTD_c_ldmBucketSizeLog, value);
+ CCtxParams->ldmParams.bucketSizeLog = value;
+ return CCtxParams->ldmParams.bucketSizeLog;
+
+ case ZSTD_c_ldmHashRateLog :
+ if (value > ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN)
+ return ERROR(parameter_outOfBound);
+ CCtxParams->ldmParams.hashRateLog = value;
+ return CCtxParams->ldmParams.hashRateLog;
+
+ default: return ERROR(parameter_unsupported);
+ }
+}
+
+size_t ZSTD_CCtx_getParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int* value)
+{
+ return ZSTD_CCtxParam_getParameter(&cctx->requestedParams, param, value);
+}
+
+size_t ZSTD_CCtxParam_getParameter(
+ ZSTD_CCtx_params* CCtxParams, ZSTD_cParameter param, int* value)
+{
+ switch(param)
+ {
+ case ZSTD_c_format :
+ *value = CCtxParams->format;
+ break;
+ case ZSTD_c_compressionLevel :
+ *value = CCtxParams->compressionLevel;
+ break;
+ case ZSTD_c_windowLog :
+ *value = CCtxParams->cParams.windowLog;
+ break;
+ case ZSTD_c_hashLog :
+ *value = CCtxParams->cParams.hashLog;
+ break;
+ case ZSTD_c_chainLog :
+ *value = CCtxParams->cParams.chainLog;
+ break;
+ case ZSTD_c_searchLog :
+ *value = CCtxParams->cParams.searchLog;
+ break;
+ case ZSTD_c_minMatch :
+ *value = CCtxParams->cParams.minMatch;
+ break;
+ case ZSTD_c_targetLength :
+ *value = CCtxParams->cParams.targetLength;
+ break;
+ case ZSTD_c_strategy :
+ *value = (unsigned)CCtxParams->cParams.strategy;
+ break;
+ case ZSTD_c_contentSizeFlag :
+ *value = CCtxParams->fParams.contentSizeFlag;
+ break;
+ case ZSTD_c_checksumFlag :
+ *value = CCtxParams->fParams.checksumFlag;
+ break;
+ case ZSTD_c_dictIDFlag :
+ *value = !CCtxParams->fParams.noDictIDFlag;
+ break;
+ case ZSTD_c_forceMaxWindow :
+ *value = CCtxParams->forceWindow;
+ break;
+ case ZSTD_c_forceAttachDict :
+ *value = CCtxParams->attachDictPref;
+ break;
+ case ZSTD_c_nbWorkers :
+#ifndef ZSTD_MULTITHREAD
+ assert(CCtxParams->nbWorkers == 0);
+#endif
+ *value = CCtxParams->nbWorkers;
+ break;
+ case ZSTD_c_jobSize :
+#ifndef ZSTD_MULTITHREAD
+ return ERROR(parameter_unsupported);
+#else
+ assert(CCtxParams->jobSize <= INT_MAX);
+ *value = (int)CCtxParams->jobSize;
+ break;
+#endif
+ case ZSTD_c_overlapLog :
+#ifndef ZSTD_MULTITHREAD
+ return ERROR(parameter_unsupported);
+#else
+ *value = CCtxParams->overlapLog;
+ break;
+#endif
+ case ZSTD_c_rsyncable :
+#ifndef ZSTD_MULTITHREAD
+ return ERROR(parameter_unsupported);
+#else
+ *value = CCtxParams->rsyncable;
+ break;
+#endif
+ case ZSTD_c_enableLongDistanceMatching :
+ *value = CCtxParams->ldmParams.enableLdm;
+ break;
+ case ZSTD_c_ldmHashLog :
+ *value = CCtxParams->ldmParams.hashLog;
+ break;
+ case ZSTD_c_ldmMinMatch :
+ *value = CCtxParams->ldmParams.minMatchLength;
+ break;
+ case ZSTD_c_ldmBucketSizeLog :
+ *value = CCtxParams->ldmParams.bucketSizeLog;
+ break;
+ case ZSTD_c_ldmHashRateLog :
+ *value = CCtxParams->ldmParams.hashRateLog;
+ break;
+ default: return ERROR(parameter_unsupported);
+ }
+ return 0;
+}
+
+/** ZSTD_CCtx_setParametersUsingCCtxParams() :
+ * just applies `params` into `cctx`
+ * no action is performed, parameters are merely stored.
+ * If ZSTDMT is enabled, parameters are pushed to cctx->mtctx.
+ * This is possible even if a compression is ongoing.
+ * In which case, new parameters will be applied on the fly, starting with next compression job.
+ */
+size_t ZSTD_CCtx_setParametersUsingCCtxParams(
+ ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params)
+{
+ DEBUGLOG(4, "ZSTD_CCtx_setParametersUsingCCtxParams");
+ if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
+ if (cctx->cdict) return ERROR(stage_wrong);
+
+ cctx->requestedParams = *params;
+ return 0;
+}
+
+ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize)
+{
+ DEBUGLOG(4, "ZSTD_CCtx_setPledgedSrcSize to %u bytes", (U32)pledgedSrcSize);
+ if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
+ cctx->pledgedSrcSizePlusOne = pledgedSrcSize+1;
+ return 0;
+}
+
+size_t ZSTD_CCtx_loadDictionary_advanced(
+ ZSTD_CCtx* cctx, const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType)
+{
+ if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
+ if (cctx->staticSize) return ERROR(memory_allocation); /* no malloc for static CCtx */
+ DEBUGLOG(4, "ZSTD_CCtx_loadDictionary_advanced (size: %u)", (U32)dictSize);
+ ZSTD_freeCDict(cctx->cdictLocal); /* in case one already exists */
+ if (dict==NULL || dictSize==0) { /* no dictionary mode */
+ cctx->cdictLocal = NULL;
+ cctx->cdict = NULL;
+ } else {
+ ZSTD_compressionParameters const cParams =
+ ZSTD_getCParamsFromCCtxParams(&cctx->requestedParams, cctx->pledgedSrcSizePlusOne-1, dictSize);
+ cctx->cdictLocal = ZSTD_createCDict_advanced(
+ dict, dictSize,
+ dictLoadMethod, dictContentType,
+ cParams, cctx->customMem);
+ cctx->cdict = cctx->cdictLocal;
+ if (cctx->cdictLocal == NULL)
+ return ERROR(memory_allocation);
+ }
+ return 0;
+}
+
+ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_byReference(
+ ZSTD_CCtx* cctx, const void* dict, size_t dictSize)
+{
+ return ZSTD_CCtx_loadDictionary_advanced(
+ cctx, dict, dictSize, ZSTD_dlm_byRef, ZSTD_dct_auto);
+}
+
+ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize)
+{
+ return ZSTD_CCtx_loadDictionary_advanced(
+ cctx, dict, dictSize, ZSTD_dlm_byCopy, ZSTD_dct_auto);
+}
+
+
+size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict)
+{
+ if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
+ cctx->cdict = cdict;
+ memset(&cctx->prefixDict, 0, sizeof(cctx->prefixDict)); /* exclusive */
+ return 0;
+}
+
+size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize)
+{
+ return ZSTD_CCtx_refPrefix_advanced(cctx, prefix, prefixSize, ZSTD_dct_rawContent);
+}
+
+size_t ZSTD_CCtx_refPrefix_advanced(
+ ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType)
+{
+ if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
+ cctx->cdict = NULL; /* prefix discards any prior cdict */
+ cctx->prefixDict.dict = prefix;
+ cctx->prefixDict.dictSize = prefixSize;
+ cctx->prefixDict.dictContentType = dictContentType;
+ return 0;
+}
+
+/*! ZSTD_CCtx_reset() :
+ * Also dumps dictionary */
+size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset)
+{
+ if ( (reset == ZSTD_reset_session_only)
+ || (reset == ZSTD_reset_session_and_parameters) ) {
+ cctx->streamStage = zcss_init;
+ cctx->pledgedSrcSizePlusOne = 0;
+ }
+ if ( (reset == ZSTD_reset_parameters)
+ || (reset == ZSTD_reset_session_and_parameters) ) {
+ if (cctx->streamStage != zcss_init) return ERROR(stage_wrong);
+ cctx->cdict = NULL;
+ return ZSTD_CCtxParams_reset(&cctx->requestedParams);
+ }
+ return 0;
+}
+
+
+/** ZSTD_checkCParams() :
+ control CParam values remain within authorized range.
+ @return : 0, or an error code if one value is beyond authorized range */
+size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams)
+{
+ BOUNDCHECK(ZSTD_c_windowLog, cParams.windowLog);
+ BOUNDCHECK(ZSTD_c_chainLog, cParams.chainLog);
+ BOUNDCHECK(ZSTD_c_hashLog, cParams.hashLog);
+ BOUNDCHECK(ZSTD_c_searchLog, cParams.searchLog);
+ BOUNDCHECK(ZSTD_c_minMatch, cParams.minMatch);
+ BOUNDCHECK(ZSTD_c_targetLength,cParams.targetLength);
+ BOUNDCHECK(ZSTD_c_strategy, cParams.strategy);
+ return 0;
+}
+
+/** ZSTD_clampCParams() :
+ * make CParam values within valid range.
+ * @return : valid CParams */
+static ZSTD_compressionParameters
+ZSTD_clampCParams(ZSTD_compressionParameters cParams)
+{
+# define CLAMP_TYPE(cParam, val, type) { \
+ ZSTD_bounds const bounds = ZSTD_cParam_getBounds(cParam); \
+ if ((int)val<bounds.lowerBound) val=(type)bounds.lowerBound; \
+ else if ((int)val>bounds.upperBound) val=(type)bounds.upperBound; \
+ }
+# define CLAMP(cParam, val) CLAMP_TYPE(cParam, val, int)
+ CLAMP(ZSTD_c_windowLog, cParams.windowLog);
+ CLAMP(ZSTD_c_chainLog, cParams.chainLog);
+ CLAMP(ZSTD_c_hashLog, cParams.hashLog);
+ CLAMP(ZSTD_c_searchLog, cParams.searchLog);
+ CLAMP(ZSTD_c_minMatch, cParams.minMatch);
+ CLAMP(ZSTD_c_targetLength,cParams.targetLength);
+ CLAMP_TYPE(ZSTD_c_strategy,cParams.strategy, ZSTD_strategy);
+ return cParams;
+}
+
+/** ZSTD_cycleLog() :
+ * condition for correct operation : hashLog > 1 */
+static U32 ZSTD_cycleLog(U32 hashLog, ZSTD_strategy strat)
+{
+ U32 const btScale = ((U32)strat >= (U32)ZSTD_btlazy2);
+ return hashLog - btScale;
+}
+
+/** ZSTD_adjustCParams_internal() :
+ optimize `cPar` for a given input (`srcSize` and `dictSize`).
+ mostly downsizing to reduce memory consumption and initialization latency.
+ Both `srcSize` and `dictSize` are optional (use 0 if unknown).
+ Note : cPar is assumed validated. Use ZSTD_checkCParams() to ensure this condition. */
+static ZSTD_compressionParameters
+ZSTD_adjustCParams_internal(ZSTD_compressionParameters cPar,
+ unsigned long long srcSize,
+ size_t dictSize)
+{
+ static const U64 minSrcSize = 513; /* (1<<9) + 1 */
+ static const U64 maxWindowResize = 1ULL << (ZSTD_WINDOWLOG_MAX-1);
+ assert(ZSTD_checkCParams(cPar)==0);
+
+ if (dictSize && (srcSize+1<2) /* srcSize unknown */ )
+ srcSize = minSrcSize; /* presumed small when there is a dictionary */
+ else if (srcSize == 0)
+ srcSize = ZSTD_CONTENTSIZE_UNKNOWN; /* 0 == unknown : presumed large */
+
+ /* resize windowLog if input is small enough, to use less memory */
+ if ( (srcSize < maxWindowResize)
+ && (dictSize < maxWindowResize) ) {
+ U32 const tSize = (U32)(srcSize + dictSize);
+ static U32 const hashSizeMin = 1 << ZSTD_HASHLOG_MIN;
+ U32 const srcLog = (tSize < hashSizeMin) ? ZSTD_HASHLOG_MIN :
+ ZSTD_highbit32(tSize-1) + 1;
+ if (cPar.windowLog > srcLog) cPar.windowLog = srcLog;
+ }
+ if (cPar.hashLog > cPar.windowLog+1) cPar.hashLog = cPar.windowLog+1;
+ { U32 const cycleLog = ZSTD_cycleLog(cPar.chainLog, cPar.strategy);
+ if (cycleLog > cPar.windowLog)
+ cPar.chainLog -= (cycleLog - cPar.windowLog);
+ }
+
+ if (cPar.windowLog < ZSTD_WINDOWLOG_ABSOLUTEMIN)
+ cPar.windowLog = ZSTD_WINDOWLOG_ABSOLUTEMIN; /* required for frame header */
+
+ return cPar;
+}
+
+ZSTD_compressionParameters
+ZSTD_adjustCParams(ZSTD_compressionParameters cPar,
+ unsigned long long srcSize,
+ size_t dictSize)
+{
+ cPar = ZSTD_clampCParams(cPar);
+ return ZSTD_adjustCParams_internal(cPar, srcSize, dictSize);
+}
+
+ZSTD_compressionParameters ZSTD_getCParamsFromCCtxParams(
+ const ZSTD_CCtx_params* CCtxParams, U64 srcSizeHint, size_t dictSize)
+{
+ ZSTD_compressionParameters cParams = ZSTD_getCParams(CCtxParams->compressionLevel, srcSizeHint, dictSize);
+ if (CCtxParams->ldmParams.enableLdm) cParams.windowLog = ZSTD_LDM_DEFAULT_WINDOW_LOG;
+ if (CCtxParams->cParams.windowLog) cParams.windowLog = CCtxParams->cParams.windowLog;
+ if (CCtxParams->cParams.hashLog) cParams.hashLog = CCtxParams->cParams.hashLog;
+ if (CCtxParams->cParams.chainLog) cParams.chainLog = CCtxParams->cParams.chainLog;
+ if (CCtxParams->cParams.searchLog) cParams.searchLog = CCtxParams->cParams.searchLog;
+ if (CCtxParams->cParams.minMatch) cParams.minMatch = CCtxParams->cParams.minMatch;
+ if (CCtxParams->cParams.targetLength) cParams.targetLength = CCtxParams->cParams.targetLength;
+ if (CCtxParams->cParams.strategy) cParams.strategy = CCtxParams->cParams.strategy;
+ assert(!ZSTD_checkCParams(cParams));
+ return ZSTD_adjustCParams_internal(cParams, srcSizeHint, dictSize);
+}
+
+static size_t
+ZSTD_sizeof_matchState(const ZSTD_compressionParameters* const cParams,
+ const U32 forCCtx)
+{
+ size_t const chainSize = (cParams->strategy == ZSTD_fast) ? 0 : ((size_t)1 << cParams->chainLog);
+ size_t const hSize = ((size_t)1) << cParams->hashLog;
+ U32 const hashLog3 = (forCCtx && cParams->minMatch==3) ? MIN(ZSTD_HASHLOG3_MAX, cParams->windowLog) : 0;
+ size_t const h3Size = ((size_t)1) << hashLog3;
+ size_t const tableSpace = (chainSize + hSize + h3Size) * sizeof(U32);
+ size_t const optPotentialSpace = ((MaxML+1) + (MaxLL+1) + (MaxOff+1) + (1<<Litbits)) * sizeof(U32)
+ + (ZSTD_OPT_NUM+1) * (sizeof(ZSTD_match_t)+sizeof(ZSTD_optimal_t));
+ size_t const optSpace = (forCCtx && (cParams->strategy >= ZSTD_btopt))
+ ? optPotentialSpace
+ : 0;
+ DEBUGLOG(4, "chainSize: %u - hSize: %u - h3Size: %u",
+ (U32)chainSize, (U32)hSize, (U32)h3Size);
+ return tableSpace + optSpace;
+}
+
+size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params)
+{
+ /* Estimate CCtx size is supported for single-threaded compression only. */
+ if (params->nbWorkers > 0) { return ERROR(GENERIC); }
+ { ZSTD_compressionParameters const cParams =
+ ZSTD_getCParamsFromCCtxParams(params, 0, 0);
+ size_t const blockSize = MIN(ZSTD_BLOCKSIZE_MAX, (size_t)1 << cParams.windowLog);
+ U32 const divider = (cParams.minMatch==3) ? 3 : 4;
+ size_t const maxNbSeq = blockSize / divider;
+ size_t const tokenSpace = WILDCOPY_OVERLENGTH + blockSize + 11*maxNbSeq;
+ size_t const entropySpace = HUF_WORKSPACE_SIZE;
+ size_t const blockStateSpace = 2 * sizeof(ZSTD_compressedBlockState_t);
+ size_t const matchStateSize = ZSTD_sizeof_matchState(&cParams, /* forCCtx */ 1);
+
+ size_t const ldmSpace = ZSTD_ldm_getTableSize(params->ldmParams);
+ size_t const ldmSeqSpace = ZSTD_ldm_getMaxNbSeq(params->ldmParams, blockSize) * sizeof(rawSeq);
+
+ size_t const neededSpace = entropySpace + blockStateSpace + tokenSpace +
+ matchStateSize + ldmSpace + ldmSeqSpace;
+
+ DEBUGLOG(5, "sizeof(ZSTD_CCtx) : %u", (U32)sizeof(ZSTD_CCtx));
+ DEBUGLOG(5, "estimate workSpace : %u", (U32)neededSpace);
+ return sizeof(ZSTD_CCtx) + neededSpace;
+ }
+}
+
+size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams)
+{
+ ZSTD_CCtx_params const params = ZSTD_makeCCtxParamsFromCParams(cParams);
+ return ZSTD_estimateCCtxSize_usingCCtxParams(&params);
+}
+
+static size_t ZSTD_estimateCCtxSize_internal(int compressionLevel)
+{
+ ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, 0, 0);
+ return ZSTD_estimateCCtxSize_usingCParams(cParams);
+}
+
+size_t ZSTD_estimateCCtxSize(int compressionLevel)
+{
+ int level;
+ size_t memBudget = 0;
+ for (level=MIN(compressionLevel, 1); level<=compressionLevel; level++) {
+ size_t const newMB = ZSTD_estimateCCtxSize_internal(level);
+ if (newMB > memBudget) memBudget = newMB;
+ }
+ return memBudget;
+}
+
+size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params)
+{
+ if (params->nbWorkers > 0) { return ERROR(GENERIC); }
+ { size_t const CCtxSize = ZSTD_estimateCCtxSize_usingCCtxParams(params);
+ size_t const blockSize = MIN(ZSTD_BLOCKSIZE_MAX, (size_t)1 << params->cParams.windowLog);
+ size_t const inBuffSize = ((size_t)1 << params->cParams.windowLog) + blockSize;
+ size_t const outBuffSize = ZSTD_compressBound(blockSize) + 1;
+ size_t const streamingSize = inBuffSize + outBuffSize;
+
+ return CCtxSize + streamingSize;
+ }
+}
+
+size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams)
+{
+ ZSTD_CCtx_params const params = ZSTD_makeCCtxParamsFromCParams(cParams);
+ return ZSTD_estimateCStreamSize_usingCCtxParams(&params);
+}
+
+static size_t ZSTD_estimateCStreamSize_internal(int compressionLevel)
+{
+ ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, 0, 0);
+ return ZSTD_estimateCStreamSize_usingCParams(cParams);
+}
+
+size_t ZSTD_estimateCStreamSize(int compressionLevel)
+{
+ int level;
+ size_t memBudget = 0;
+ for (level=MIN(compressionLevel, 1); level<=compressionLevel; level++) {
+ size_t const newMB = ZSTD_estimateCStreamSize_internal(level);
+ if (newMB > memBudget) memBudget = newMB;
+ }
+ return memBudget;
+}
+
+/* ZSTD_getFrameProgression():
+ * tells how much data has been consumed (input) and produced (output) for current frame.
+ * able to count progression inside worker threads (non-blocking mode).
+ */
+ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx)
+{
+#ifdef ZSTD_MULTITHREAD
+ if (cctx->appliedParams.nbWorkers > 0) {
+ return ZSTDMT_getFrameProgression(cctx->mtctx);
+ }
+#endif
+ { ZSTD_frameProgression fp;
+ size_t const buffered = (cctx->inBuff == NULL) ? 0 :
+ cctx->inBuffPos - cctx->inToCompress;
+ if (buffered) assert(cctx->inBuffPos >= cctx->inToCompress);
+ assert(buffered <= ZSTD_BLOCKSIZE_MAX);
+ fp.ingested = cctx->consumedSrcSize + buffered;
+ fp.consumed = cctx->consumedSrcSize;
+ fp.produced = cctx->producedCSize;
+ fp.flushed = cctx->producedCSize; /* simplified; some data might still be left within streaming output buffer */
+ fp.currentJobID = 0;
+ fp.nbActiveWorkers = 0;
+ return fp;
+} }
+
+/*! ZSTD_toFlushNow()
+ * Only useful for multithreading scenarios currently (nbWorkers >= 1).
+ */
+size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx)
+{
+#ifdef ZSTD_MULTITHREAD
+ if (cctx->appliedParams.nbWorkers > 0) {
+ return ZSTDMT_toFlushNow(cctx->mtctx);
+ }
+#endif
+ (void)cctx;
+ return 0; /* over-simplification; could also check if context is currently running in streaming mode, and in which case, report how many bytes are left to be flushed within output buffer */
+}
+
+
+
+static U32 ZSTD_equivalentCParams(ZSTD_compressionParameters cParams1,
+ ZSTD_compressionParameters cParams2)
+{
+ return (cParams1.hashLog == cParams2.hashLog)
+ & (cParams1.chainLog == cParams2.chainLog)
+ & (cParams1.strategy == cParams2.strategy) /* opt parser space */
+ & ((cParams1.minMatch==3) == (cParams2.minMatch==3)); /* hashlog3 space */
+}
+
+static void ZSTD_assertEqualCParams(ZSTD_compressionParameters cParams1,
+ ZSTD_compressionParameters cParams2)
+{
+ (void)cParams1;
+ (void)cParams2;
+ assert(cParams1.windowLog == cParams2.windowLog);
+ assert(cParams1.chainLog == cParams2.chainLog);
+ assert(cParams1.hashLog == cParams2.hashLog);
+ assert(cParams1.searchLog == cParams2.searchLog);
+ assert(cParams1.minMatch == cParams2.minMatch);
+ assert(cParams1.targetLength == cParams2.targetLength);
+ assert(cParams1.strategy == cParams2.strategy);
+}
+
+/** The parameters are equivalent if ldm is not enabled in both sets or
+ * all the parameters are equivalent. */
+static U32 ZSTD_equivalentLdmParams(ldmParams_t ldmParams1,
+ ldmParams_t ldmParams2)
+{
+ return (!ldmParams1.enableLdm && !ldmParams2.enableLdm) ||
+ (ldmParams1.enableLdm == ldmParams2.enableLdm &&
+ ldmParams1.hashLog == ldmParams2.hashLog &&
+ ldmParams1.bucketSizeLog == ldmParams2.bucketSizeLog &&
+ ldmParams1.minMatchLength == ldmParams2.minMatchLength &&
+ ldmParams1.hashRateLog == ldmParams2.hashRateLog);
+}
+
+typedef enum { ZSTDb_not_buffered, ZSTDb_buffered } ZSTD_buffered_policy_e;
+
+/* ZSTD_sufficientBuff() :
+ * check internal buffers exist for streaming if buffPol == ZSTDb_buffered .
+ * Note : they are assumed to be correctly sized if ZSTD_equivalentCParams()==1 */
+static U32 ZSTD_sufficientBuff(size_t bufferSize1, size_t maxNbSeq1,
+ size_t maxNbLit1,
+ ZSTD_buffered_policy_e buffPol2,
+ ZSTD_compressionParameters cParams2,
+ U64 pledgedSrcSize)
+{
+ size_t const windowSize2 = MAX(1, (size_t)MIN(((U64)1 << cParams2.windowLog), pledgedSrcSize));
+ size_t const blockSize2 = MIN(ZSTD_BLOCKSIZE_MAX, windowSize2);
+ size_t const maxNbSeq2 = blockSize2 / ((cParams2.minMatch == 3) ? 3 : 4);
+ size_t const maxNbLit2 = blockSize2;
+ size_t const neededBufferSize2 = (buffPol2==ZSTDb_buffered) ? windowSize2 + blockSize2 : 0;
+ DEBUGLOG(4, "ZSTD_sufficientBuff: is neededBufferSize2=%u <= bufferSize1=%u",
+ (U32)neededBufferSize2, (U32)bufferSize1);
+ DEBUGLOG(4, "ZSTD_sufficientBuff: is maxNbSeq2=%u <= maxNbSeq1=%u",
+ (U32)maxNbSeq2, (U32)maxNbSeq1);
+ DEBUGLOG(4, "ZSTD_sufficientBuff: is maxNbLit2=%u <= maxNbLit1=%u",
+ (U32)maxNbLit2, (U32)maxNbLit1);
+ return (maxNbLit2 <= maxNbLit1)
+ & (maxNbSeq2 <= maxNbSeq1)
+ & (neededBufferSize2 <= bufferSize1);
+}
+
+/** Equivalence for resetCCtx purposes */
+static U32 ZSTD_equivalentParams(ZSTD_CCtx_params params1,
+ ZSTD_CCtx_params params2,
+ size_t buffSize1,
+ size_t maxNbSeq1, size_t maxNbLit1,
+ ZSTD_buffered_policy_e buffPol2,
+ U64 pledgedSrcSize)
+{
+ DEBUGLOG(4, "ZSTD_equivalentParams: pledgedSrcSize=%u", (U32)pledgedSrcSize);
+ if (!ZSTD_equivalentCParams(params1.cParams, params2.cParams)) {
+ DEBUGLOG(4, "ZSTD_equivalentCParams() == 0");
+ return 0;
+ }
+ if (!ZSTD_equivalentLdmParams(params1.ldmParams, params2.ldmParams)) {
+ DEBUGLOG(4, "ZSTD_equivalentLdmParams() == 0");
+ return 0;
+ }
+ if (!ZSTD_sufficientBuff(buffSize1, maxNbSeq1, maxNbLit1, buffPol2,
+ params2.cParams, pledgedSrcSize)) {
+ DEBUGLOG(4, "ZSTD_sufficientBuff() == 0");
+ return 0;
+ }
+ return 1;
+}
+
+static void ZSTD_reset_compressedBlockState(ZSTD_compressedBlockState_t* bs)
+{
+ int i;
+ for (i = 0; i < ZSTD_REP_NUM; ++i)
+ bs->rep[i] = repStartValue[i];
+ bs->entropy.huf.repeatMode = HUF_repeat_none;
+ bs->entropy.fse.offcode_repeatMode = FSE_repeat_none;
+ bs->entropy.fse.matchlength_repeatMode = FSE_repeat_none;
+ bs->entropy.fse.litlength_repeatMode = FSE_repeat_none;
+}
+
+/*! ZSTD_invalidateMatchState()
+ * Invalidate all the matches in the match finder tables.
+ * Requires nextSrc and base to be set (can be NULL).
+ */
+static void ZSTD_invalidateMatchState(ZSTD_matchState_t* ms)
+{
+ ZSTD_window_clear(&ms->window);
+
+ ms->nextToUpdate = ms->window.dictLimit;
+ ms->nextToUpdate3 = ms->window.dictLimit;
+ ms->loadedDictEnd = 0;
+ ms->opt.litLengthSum = 0; /* force reset of btopt stats */
+ ms->dictMatchState = NULL;
+}
+
+/*! ZSTD_continueCCtx() :
+ * reuse CCtx without reset (note : requires no dictionary) */
+static size_t ZSTD_continueCCtx(ZSTD_CCtx* cctx, ZSTD_CCtx_params params, U64 pledgedSrcSize)
+{
+ size_t const windowSize = MAX(1, (size_t)MIN(((U64)1 << params.cParams.windowLog), pledgedSrcSize));
+ size_t const blockSize = MIN(ZSTD_BLOCKSIZE_MAX, windowSize);
+ DEBUGLOG(4, "ZSTD_continueCCtx: re-use context in place");
+
+ cctx->blockSize = blockSize; /* previous block size could be different even for same windowLog, due to pledgedSrcSize */
+ cctx->appliedParams = params;
+ cctx->blockState.matchState.cParams = params.cParams;
+ cctx->pledgedSrcSizePlusOne = pledgedSrcSize+1;
+ cctx->consumedSrcSize = 0;
+ cctx->producedCSize = 0;
+ if (pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN)
+ cctx->appliedParams.fParams.contentSizeFlag = 0;
+ DEBUGLOG(4, "pledged content size : %u ; flag : %u",
+ (U32)pledgedSrcSize, cctx->appliedParams.fParams.contentSizeFlag);
+ cctx->stage = ZSTDcs_init;
+ cctx->dictID = 0;
+ if (params.ldmParams.enableLdm)
+ ZSTD_window_clear(&cctx->ldmState.window);
+ ZSTD_referenceExternalSequences(cctx, NULL, 0);
+ ZSTD_invalidateMatchState(&cctx->blockState.matchState);
+ ZSTD_reset_compressedBlockState(cctx->blockState.prevCBlock);
+ XXH64_reset(&cctx->xxhState, 0);
+ return 0;
+}
+
+typedef enum { ZSTDcrp_continue, ZSTDcrp_noMemset } ZSTD_compResetPolicy_e;
+
+static void*
+ZSTD_reset_matchState(ZSTD_matchState_t* ms,
+ void* ptr,
+ const ZSTD_compressionParameters* cParams,
+ ZSTD_compResetPolicy_e const crp, U32 const forCCtx)
+{
+ size_t const chainSize = (cParams->strategy == ZSTD_fast) ? 0 : ((size_t)1 << cParams->chainLog);
+ size_t const hSize = ((size_t)1) << cParams->hashLog;
+ U32 const hashLog3 = (forCCtx && cParams->minMatch==3) ? MIN(ZSTD_HASHLOG3_MAX, cParams->windowLog) : 0;
+ size_t const h3Size = ((size_t)1) << hashLog3;
+ size_t const tableSpace = (chainSize + hSize + h3Size) * sizeof(U32);
+
+ assert(((size_t)ptr & 3) == 0);
+
+ ms->hashLog3 = hashLog3;
+ memset(&ms->window, 0, sizeof(ms->window));
+ ms->window.dictLimit = 1; /* start from 1, so that 1st position is valid */
+ ms->window.lowLimit = 1; /* it ensures first and later CCtx usages compress the same */
+ ms->window.nextSrc = ms->window.base + 1; /* see issue #1241 */
+ ZSTD_invalidateMatchState(ms);
+
+ /* opt parser space */
+ if (forCCtx && (cParams->strategy >= ZSTD_btopt)) {
+ DEBUGLOG(4, "reserving optimal parser space");
+ ms->opt.litFreq = (unsigned*)ptr;
+ ms->opt.litLengthFreq = ms->opt.litFreq + (1<<Litbits);
+ ms->opt.matchLengthFreq = ms->opt.litLengthFreq + (MaxLL+1);
+ ms->opt.offCodeFreq = ms->opt.matchLengthFreq + (MaxML+1);
+ ptr = ms->opt.offCodeFreq + (MaxOff+1);
+ ms->opt.matchTable = (ZSTD_match_t*)ptr;
+ ptr = ms->opt.matchTable + ZSTD_OPT_NUM+1;
+ ms->opt.priceTable = (ZSTD_optimal_t*)ptr;
+ ptr = ms->opt.priceTable + ZSTD_OPT_NUM+1;
+ }
+
+ /* table Space */
+ DEBUGLOG(4, "reset table : %u", crp!=ZSTDcrp_noMemset);
+ assert(((size_t)ptr & 3) == 0); /* ensure ptr is properly aligned */
+ if (crp!=ZSTDcrp_noMemset) memset(ptr, 0, tableSpace); /* reset tables only */
+ ms->hashTable = (U32*)(ptr);
+ ms->chainTable = ms->hashTable + hSize;
+ ms->hashTable3 = ms->chainTable + chainSize;
+ ptr = ms->hashTable3 + h3Size;
+
+ ms->cParams = *cParams;
+
+ assert(((size_t)ptr & 3) == 0);
+ return ptr;
+}
+
+#define ZSTD_WORKSPACETOOLARGE_FACTOR 3 /* define "workspace is too large" as this number of times larger than needed */
+#define ZSTD_WORKSPACETOOLARGE_MAXDURATION 128 /* when workspace is continuously too large
+ * during at least this number of times,
+ * context's memory usage is considered wasteful,
+ * because it's sized to handle a worst case scenario which rarely happens.
+ * In which case, resize it down to free some memory */
+
+/*! ZSTD_resetCCtx_internal() :
+ note : `params` are assumed fully validated at this stage */
+static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc,
+ ZSTD_CCtx_params params,
+ U64 pledgedSrcSize,
+ ZSTD_compResetPolicy_e const crp,
+ ZSTD_buffered_policy_e const zbuff)
+{
+ DEBUGLOG(4, "ZSTD_resetCCtx_internal: pledgedSrcSize=%u, wlog=%u",
+ (U32)pledgedSrcSize, params.cParams.windowLog);
+ assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
+
+ if (crp == ZSTDcrp_continue) {
+ if (ZSTD_equivalentParams(zc->appliedParams, params,
+ zc->inBuffSize,
+ zc->seqStore.maxNbSeq, zc->seqStore.maxNbLit,
+ zbuff, pledgedSrcSize)) {
+ DEBUGLOG(4, "ZSTD_equivalentParams()==1 -> continue mode (wLog1=%u, blockSize1=%zu)",
+ zc->appliedParams.cParams.windowLog, zc->blockSize);
+ zc->workSpaceOversizedDuration += (zc->workSpaceOversizedDuration > 0); /* if it was too large, it still is */
+ if (zc->workSpaceOversizedDuration <= ZSTD_WORKSPACETOOLARGE_MAXDURATION)
+ return ZSTD_continueCCtx(zc, params, pledgedSrcSize);
+ } }
+ DEBUGLOG(4, "ZSTD_equivalentParams()==0 -> reset CCtx");
+
+ if (params.ldmParams.enableLdm) {
+ /* Adjust long distance matching parameters */
+ ZSTD_ldm_adjustParameters(&params.ldmParams, &params.cParams);
+ assert(params.ldmParams.hashLog >= params.ldmParams.bucketSizeLog);
+ assert(params.ldmParams.hashRateLog < 32);
+ zc->ldmState.hashPower = ZSTD_rollingHash_primePower(params.ldmParams.minMatchLength);
+ }
+
+ { size_t const windowSize = MAX(1, (size_t)MIN(((U64)1 << params.cParams.windowLog), pledgedSrcSize));
+ size_t const blockSize = MIN(ZSTD_BLOCKSIZE_MAX, windowSize);
+ U32 const divider = (params.cParams.minMatch==3) ? 3 : 4;
+ size_t const maxNbSeq = blockSize / divider;
+ size_t const tokenSpace = WILDCOPY_OVERLENGTH + blockSize + 11*maxNbSeq;
+ size_t const buffOutSize = (zbuff==ZSTDb_buffered) ? ZSTD_compressBound(blockSize)+1 : 0;
+ size_t const buffInSize = (zbuff==ZSTDb_buffered) ? windowSize + blockSize : 0;
+ size_t const matchStateSize = ZSTD_sizeof_matchState(&params.cParams, /* forCCtx */ 1);
+ size_t const maxNbLdmSeq = ZSTD_ldm_getMaxNbSeq(params.ldmParams, blockSize);
+ void* ptr; /* used to partition workSpace */
+
+ /* Check if workSpace is large enough, alloc a new one if needed */
+ { size_t const entropySpace = HUF_WORKSPACE_SIZE;
+ size_t const blockStateSpace = 2 * sizeof(ZSTD_compressedBlockState_t);
+ size_t const bufferSpace = buffInSize + buffOutSize;
+ size_t const ldmSpace = ZSTD_ldm_getTableSize(params.ldmParams);
+ size_t const ldmSeqSpace = maxNbLdmSeq * sizeof(rawSeq);
+
+ size_t const neededSpace = entropySpace + blockStateSpace + ldmSpace +
+ ldmSeqSpace + matchStateSize + tokenSpace +
+ bufferSpace;
+
+ int const workSpaceTooSmall = zc->workSpaceSize < neededSpace;
+ int const workSpaceTooLarge = zc->workSpaceSize > ZSTD_WORKSPACETOOLARGE_FACTOR * neededSpace;
+ int const workSpaceWasteful = workSpaceTooLarge && (zc->workSpaceOversizedDuration > ZSTD_WORKSPACETOOLARGE_MAXDURATION);
+ zc->workSpaceOversizedDuration = workSpaceTooLarge ? zc->workSpaceOversizedDuration+1 : 0;
+
+ DEBUGLOG(4, "Need %zuKB workspace, including %zuKB for match state, and %zuKB for buffers",
+ neededSpace>>10, matchStateSize>>10, bufferSpace>>10);
+ DEBUGLOG(4, "windowSize: %zu - blockSize: %zu", windowSize, blockSize);
+
+ if (workSpaceTooSmall || workSpaceWasteful) {
+ DEBUGLOG(4, "Need to resize workSpaceSize from %zuKB to %zuKB",
+ zc->workSpaceSize >> 10,
+ neededSpace >> 10);
+ /* static cctx : no resize, error out */
+ if (zc->staticSize) return ERROR(memory_allocation);
+
+ zc->workSpaceSize = 0;
+ ZSTD_free(zc->workSpace, zc->customMem);
+ zc->workSpace = ZSTD_malloc(neededSpace, zc->customMem);
+ if (zc->workSpace == NULL) return ERROR(memory_allocation);
+ zc->workSpaceSize = neededSpace;
+ zc->workSpaceOversizedDuration = 0;
+
+ /* Statically sized space.
+ * entropyWorkspace never moves,
+ * though prev/next block swap places */
+ assert(((size_t)zc->workSpace & 3) == 0); /* ensure correct alignment */
+ assert(zc->workSpaceSize >= 2 * sizeof(ZSTD_compressedBlockState_t));
+ zc->blockState.prevCBlock = (ZSTD_compressedBlockState_t*)zc->workSpace;
+ zc->blockState.nextCBlock = zc->blockState.prevCBlock + 1;
+ ptr = zc->blockState.nextCBlock + 1;
+ zc->entropyWorkspace = (U32*)ptr;
+ } }
+
+ /* init params */
+ zc->appliedParams = params;
+ zc->blockState.matchState.cParams = params.cParams;
+ zc->pledgedSrcSizePlusOne = pledgedSrcSize+1;
+ zc->consumedSrcSize = 0;
+ zc->producedCSize = 0;
+ if (pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN)
+ zc->appliedParams.fParams.contentSizeFlag = 0;
+ DEBUGLOG(4, "pledged content size : %u ; flag : %u",
+ (unsigned)pledgedSrcSize, zc->appliedParams.fParams.contentSizeFlag);
+ zc->blockSize = blockSize;
+
+ XXH64_reset(&zc->xxhState, 0);
+ zc->stage = ZSTDcs_init;
+ zc->dictID = 0;
+
+ ZSTD_reset_compressedBlockState(zc->blockState.prevCBlock);
+
+ ptr = zc->entropyWorkspace + HUF_WORKSPACE_SIZE_U32;
+
+ /* ldm hash table */
+ /* initialize bucketOffsets table later for pointer alignment */
+ if (params.ldmParams.enableLdm) {
+ size_t const ldmHSize = ((size_t)1) << params.ldmParams.hashLog;
+ memset(ptr, 0, ldmHSize * sizeof(ldmEntry_t));
+ assert(((size_t)ptr & 3) == 0); /* ensure ptr is properly aligned */
+ zc->ldmState.hashTable = (ldmEntry_t*)ptr;
+ ptr = zc->ldmState.hashTable + ldmHSize;
+ zc->ldmSequences = (rawSeq*)ptr;
+ ptr = zc->ldmSequences + maxNbLdmSeq;
+ zc->maxNbLdmSequences = maxNbLdmSeq;
+
+ memset(&zc->ldmState.window, 0, sizeof(zc->ldmState.window));
+ }
+ assert(((size_t)ptr & 3) == 0); /* ensure ptr is properly aligned */
+
+ ptr = ZSTD_reset_matchState(&zc->blockState.matchState, ptr, &params.cParams, crp, /* forCCtx */ 1);
+
+ /* sequences storage */
+ zc->seqStore.maxNbSeq = maxNbSeq;
+ zc->seqStore.sequencesStart = (seqDef*)ptr;
+ ptr = zc->seqStore.sequencesStart + maxNbSeq;
+ zc->seqStore.llCode = (BYTE*) ptr;
+ zc->seqStore.mlCode = zc->seqStore.llCode + maxNbSeq;
+ zc->seqStore.ofCode = zc->seqStore.mlCode + maxNbSeq;
+ zc->seqStore.litStart = zc->seqStore.ofCode + maxNbSeq;
+ /* ZSTD_wildcopy() is used to copy into the literals buffer,
+ * so we have to oversize the buffer by WILDCOPY_OVERLENGTH bytes.
+ */
+ zc->seqStore.maxNbLit = blockSize;
+ ptr = zc->seqStore.litStart + blockSize + WILDCOPY_OVERLENGTH;
+
+ /* ldm bucketOffsets table */
+ if (params.ldmParams.enableLdm) {
+ size_t const ldmBucketSize =
+ ((size_t)1) << (params.ldmParams.hashLog -
+ params.ldmParams.bucketSizeLog);
+ memset(ptr, 0, ldmBucketSize);
+ zc->ldmState.bucketOffsets = (BYTE*)ptr;
+ ptr = zc->ldmState.bucketOffsets + ldmBucketSize;
+ ZSTD_window_clear(&zc->ldmState.window);
+ }
+ ZSTD_referenceExternalSequences(zc, NULL, 0);
+
+ /* buffers */
+ zc->inBuffSize = buffInSize;
+ zc->inBuff = (char*)ptr;
+ zc->outBuffSize = buffOutSize;
+ zc->outBuff = zc->inBuff + buffInSize;
+
+ return 0;
+ }
+}
+
+/* ZSTD_invalidateRepCodes() :
+ * ensures next compression will not use repcodes from previous block.
+ * Note : only works with regular variant;
+ * do not use with extDict variant ! */
+void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx) {
+ int i;
+ for (i=0; i<ZSTD_REP_NUM; i++) cctx->blockState.prevCBlock->rep[i] = 0;
+ assert(!ZSTD_window_hasExtDict(cctx->blockState.matchState.window));
+}
+
+/* These are the approximate sizes for each strategy past which copying the
+ * dictionary tables into the working context is faster than using them
+ * in-place.
+ */
+static const size_t attachDictSizeCutoffs[ZSTD_STRATEGY_MAX+1] = {
+ 8 KB, /* unused */
+ 8 KB, /* ZSTD_fast */
+ 16 KB, /* ZSTD_dfast */
+ 32 KB, /* ZSTD_greedy */
+ 32 KB, /* ZSTD_lazy */
+ 32 KB, /* ZSTD_lazy2 */
+ 32 KB, /* ZSTD_btlazy2 */
+ 32 KB, /* ZSTD_btopt */
+ 8 KB, /* ZSTD_btultra */
+ 8 KB /* ZSTD_btultra2 */
+};
+
+static int ZSTD_shouldAttachDict(const ZSTD_CDict* cdict,
+ ZSTD_CCtx_params params,
+ U64 pledgedSrcSize)
+{
+ size_t cutoff = attachDictSizeCutoffs[cdict->matchState.cParams.strategy];
+ return ( pledgedSrcSize <= cutoff
+ || pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN
+ || params.attachDictPref == ZSTD_dictForceAttach )
+ && params.attachDictPref != ZSTD_dictForceCopy
+ && !params.forceWindow; /* dictMatchState isn't correctly
+ * handled in _enforceMaxDist */
+}
+
+static size_t ZSTD_resetCCtx_byAttachingCDict(
+ ZSTD_CCtx* cctx,
+ const ZSTD_CDict* cdict,
+ ZSTD_CCtx_params params,
+ U64 pledgedSrcSize,
+ ZSTD_buffered_policy_e zbuff)
+{
+ {
+ const ZSTD_compressionParameters *cdict_cParams = &cdict->matchState.cParams;
+ unsigned const windowLog = params.cParams.windowLog;
+ assert(windowLog != 0);
+ /* Resize working context table params for input only, since the dict
+ * has its own tables. */
+ params.cParams = ZSTD_adjustCParams_internal(*cdict_cParams, pledgedSrcSize, 0);
+ params.cParams.windowLog = windowLog;
+ ZSTD_resetCCtx_internal(cctx, params, pledgedSrcSize,
+ ZSTDcrp_continue, zbuff);
+ assert(cctx->appliedParams.cParams.strategy == cdict_cParams->strategy);
+ }
+
+ {
+ const U32 cdictEnd = (U32)( cdict->matchState.window.nextSrc
+ - cdict->matchState.window.base);
+ const U32 cdictLen = cdictEnd - cdict->matchState.window.dictLimit;
+ if (cdictLen == 0) {
+ /* don't even attach dictionaries with no contents */
+ DEBUGLOG(4, "skipping attaching empty dictionary");
+ } else {
+ DEBUGLOG(4, "attaching dictionary into context");
+ cctx->blockState.matchState.dictMatchState = &cdict->matchState;
+
+ /* prep working match state so dict matches never have negative indices
+ * when they are translated to the working context's index space. */
+ if (cctx->blockState.matchState.window.dictLimit < cdictEnd) {
+ cctx->blockState.matchState.window.nextSrc =
+ cctx->blockState.matchState.window.base + cdictEnd;
+ ZSTD_window_clear(&cctx->blockState.matchState.window);
+ }
+ cctx->blockState.matchState.loadedDictEnd = cctx->blockState.matchState.window.dictLimit;
+ }
+ }
+
+ cctx->dictID = cdict->dictID;
+
+ /* copy block state */
+ memcpy(cctx->blockState.prevCBlock, &cdict->cBlockState, sizeof(cdict->cBlockState));
+
+ return 0;
+}
+
+static size_t ZSTD_resetCCtx_byCopyingCDict(ZSTD_CCtx* cctx,
+ const ZSTD_CDict* cdict,
+ ZSTD_CCtx_params params,
+ U64 pledgedSrcSize,
+ ZSTD_buffered_policy_e zbuff)
+{
+ const ZSTD_compressionParameters *cdict_cParams = &cdict->matchState.cParams;
+
+ DEBUGLOG(4, "copying dictionary into context");
+
+ { unsigned const windowLog = params.cParams.windowLog;
+ assert(windowLog != 0);
+ /* Copy only compression parameters related to tables. */
+ params.cParams = *cdict_cParams;
+ params.cParams.windowLog = windowLog;
+ ZSTD_resetCCtx_internal(cctx, params, pledgedSrcSize,
+ ZSTDcrp_noMemset, zbuff);
+ assert(cctx->appliedParams.cParams.strategy == cdict_cParams->strategy);
+ assert(cctx->appliedParams.cParams.hashLog == cdict_cParams->hashLog);
+ assert(cctx->appliedParams.cParams.chainLog == cdict_cParams->chainLog);
+ }
+
+ /* copy tables */
+ { size_t const chainSize = (cdict_cParams->strategy == ZSTD_fast) ? 0 : ((size_t)1 << cdict_cParams->chainLog);
+ size_t const hSize = (size_t)1 << cdict_cParams->hashLog;
+ size_t const tableSpace = (chainSize + hSize) * sizeof(U32);
+ assert((U32*)cctx->blockState.matchState.chainTable == (U32*)cctx->blockState.matchState.hashTable + hSize); /* chainTable must follow hashTable */
+ assert((U32*)cctx->blockState.matchState.hashTable3 == (U32*)cctx->blockState.matchState.chainTable + chainSize);
+ assert((U32*)cdict->matchState.chainTable == (U32*)cdict->matchState.hashTable + hSize); /* chainTable must follow hashTable */
+ assert((U32*)cdict->matchState.hashTable3 == (U32*)cdict->matchState.chainTable + chainSize);
+ memcpy(cctx->blockState.matchState.hashTable, cdict->matchState.hashTable, tableSpace); /* presumes all tables follow each other */
+ }
+
+ /* Zero the hashTable3, since the cdict never fills it */
+ { size_t const h3Size = (size_t)1 << cctx->blockState.matchState.hashLog3;
+ assert(cdict->matchState.hashLog3 == 0);
+ memset(cctx->blockState.matchState.hashTable3, 0, h3Size * sizeof(U32));
+ }
+
+ /* copy dictionary offsets */
+ { ZSTD_matchState_t const* srcMatchState = &cdict->matchState;
+ ZSTD_matchState_t* dstMatchState = &cctx->blockState.matchState;
+ dstMatchState->window = srcMatchState->window;
+ dstMatchState->nextToUpdate = srcMatchState->nextToUpdate;
+ dstMatchState->nextToUpdate3= srcMatchState->nextToUpdate3;
+ dstMatchState->loadedDictEnd= srcMatchState->loadedDictEnd;
+ }
+
+ cctx->dictID = cdict->dictID;
+
+ /* copy block state */
+ memcpy(cctx->blockState.prevCBlock, &cdict->cBlockState, sizeof(cdict->cBlockState));
+
+ return 0;
+}
+
+/* We have a choice between copying the dictionary context into the working
+ * context, or referencing the dictionary context from the working context
+ * in-place. We decide here which strategy to use. */
+static size_t ZSTD_resetCCtx_usingCDict(ZSTD_CCtx* cctx,
+ const ZSTD_CDict* cdict,
+ ZSTD_CCtx_params params,
+ U64 pledgedSrcSize,
+ ZSTD_buffered_policy_e zbuff)
+{
+
+ DEBUGLOG(4, "ZSTD_resetCCtx_usingCDict (pledgedSrcSize=%u)",
+ (unsigned)pledgedSrcSize);
+
+ if (ZSTD_shouldAttachDict(cdict, params, pledgedSrcSize)) {
+ return ZSTD_resetCCtx_byAttachingCDict(
+ cctx, cdict, params, pledgedSrcSize, zbuff);
+ } else {
+ return ZSTD_resetCCtx_byCopyingCDict(
+ cctx, cdict, params, pledgedSrcSize, zbuff);
+ }
+}
+
+/*! ZSTD_copyCCtx_internal() :
+ * Duplicate an existing context `srcCCtx` into another one `dstCCtx`.
+ * Only works during stage ZSTDcs_init (i.e. after creation, but before first call to ZSTD_compressContinue()).
+ * The "context", in this case, refers to the hash and chain tables,
+ * entropy tables, and dictionary references.
+ * `windowLog` value is enforced if != 0, otherwise value is copied from srcCCtx.
+ * @return : 0, or an error code */
+static size_t ZSTD_copyCCtx_internal(ZSTD_CCtx* dstCCtx,
+ const ZSTD_CCtx* srcCCtx,
+ ZSTD_frameParameters fParams,
+ U64 pledgedSrcSize,
+ ZSTD_buffered_policy_e zbuff)
+{
+ DEBUGLOG(5, "ZSTD_copyCCtx_internal");
+ if (srcCCtx->stage!=ZSTDcs_init) return ERROR(stage_wrong);
+
+ memcpy(&dstCCtx->customMem, &srcCCtx->customMem, sizeof(ZSTD_customMem));
+ { ZSTD_CCtx_params params = dstCCtx->requestedParams;
+ /* Copy only compression parameters related to tables. */
+ params.cParams = srcCCtx->appliedParams.cParams;
+ params.fParams = fParams;
+ ZSTD_resetCCtx_internal(dstCCtx, params, pledgedSrcSize,
+ ZSTDcrp_noMemset, zbuff);
+ assert(dstCCtx->appliedParams.cParams.windowLog == srcCCtx->appliedParams.cParams.windowLog);
+ assert(dstCCtx->appliedParams.cParams.strategy == srcCCtx->appliedParams.cParams.strategy);
+ assert(dstCCtx->appliedParams.cParams.hashLog == srcCCtx->appliedParams.cParams.hashLog);
+ assert(dstCCtx->appliedParams.cParams.chainLog == srcCCtx->appliedParams.cParams.chainLog);
+ assert(dstCCtx->blockState.matchState.hashLog3 == srcCCtx->blockState.matchState.hashLog3);
+ }
+
+ /* copy tables */
+ { size_t const chainSize = (srcCCtx->appliedParams.cParams.strategy == ZSTD_fast) ? 0 : ((size_t)1 << srcCCtx->appliedParams.cParams.chainLog);
+ size_t const hSize = (size_t)1 << srcCCtx->appliedParams.cParams.hashLog;
+ size_t const h3Size = (size_t)1 << srcCCtx->blockState.matchState.hashLog3;
+ size_t const tableSpace = (chainSize + hSize + h3Size) * sizeof(U32);
+ assert((U32*)dstCCtx->blockState.matchState.chainTable == (U32*)dstCCtx->blockState.matchState.hashTable + hSize); /* chainTable must follow hashTable */
+ assert((U32*)dstCCtx->blockState.matchState.hashTable3 == (U32*)dstCCtx->blockState.matchState.chainTable + chainSize);
+ memcpy(dstCCtx->blockState.matchState.hashTable, srcCCtx->blockState.matchState.hashTable, tableSpace); /* presumes all tables follow each other */
+ }
+
+ /* copy dictionary offsets */
+ {
+ const ZSTD_matchState_t* srcMatchState = &srcCCtx->blockState.matchState;
+ ZSTD_matchState_t* dstMatchState = &dstCCtx->blockState.matchState;
+ dstMatchState->window = srcMatchState->window;
+ dstMatchState->nextToUpdate = srcMatchState->nextToUpdate;
+ dstMatchState->nextToUpdate3= srcMatchState->nextToUpdate3;
+ dstMatchState->loadedDictEnd= srcMatchState->loadedDictEnd;
+ }
+ dstCCtx->dictID = srcCCtx->dictID;
+
+ /* copy block state */
+ memcpy(dstCCtx->blockState.prevCBlock, srcCCtx->blockState.prevCBlock, sizeof(*srcCCtx->blockState.prevCBlock));
+
+ return 0;
+}
+
+/*! ZSTD_copyCCtx() :
+ * Duplicate an existing context `srcCCtx` into another one `dstCCtx`.
+ * Only works during stage ZSTDcs_init (i.e. after creation, but before first call to ZSTD_compressContinue()).
+ * pledgedSrcSize==0 means "unknown".
+* @return : 0, or an error code */
+size_t ZSTD_copyCCtx(ZSTD_CCtx* dstCCtx, const ZSTD_CCtx* srcCCtx, unsigned long long pledgedSrcSize)
+{
+ ZSTD_frameParameters fParams = { 1 /*content*/, 0 /*checksum*/, 0 /*noDictID*/ };
+ ZSTD_buffered_policy_e const zbuff = (ZSTD_buffered_policy_e)(srcCCtx->inBuffSize>0);
+ ZSTD_STATIC_ASSERT((U32)ZSTDb_buffered==1);
+ if (pledgedSrcSize==0) pledgedSrcSize = ZSTD_CONTENTSIZE_UNKNOWN;
+ fParams.contentSizeFlag = (pledgedSrcSize != ZSTD_CONTENTSIZE_UNKNOWN);
+
+ return ZSTD_copyCCtx_internal(dstCCtx, srcCCtx,
+ fParams, pledgedSrcSize,
+ zbuff);
+}
+
+
+#define ZSTD_ROWSIZE 16
+/*! ZSTD_reduceTable() :
+ * reduce table indexes by `reducerValue`, or squash to zero.
+ * PreserveMark preserves "unsorted mark" for btlazy2 strategy.
+ * It must be set to a clear 0/1 value, to remove branch during inlining.
+ * Presume table size is a multiple of ZSTD_ROWSIZE
+ * to help auto-vectorization */
+FORCE_INLINE_TEMPLATE void
+ZSTD_reduceTable_internal (U32* const table, U32 const size, U32 const reducerValue, int const preserveMark)
+{
+ int const nbRows = (int)size / ZSTD_ROWSIZE;
+ int cellNb = 0;
+ int rowNb;
+ assert((size & (ZSTD_ROWSIZE-1)) == 0); /* multiple of ZSTD_ROWSIZE */
+ assert(size < (1U<<31)); /* can be casted to int */
+ for (rowNb=0 ; rowNb < nbRows ; rowNb++) {
+ int column;
+ for (column=0; column<ZSTD_ROWSIZE; column++) {
+ if (preserveMark) {
+ U32 const adder = (table[cellNb] == ZSTD_DUBT_UNSORTED_MARK) ? reducerValue : 0;
+ table[cellNb] += adder;
+ }
+ if (table[cellNb] < reducerValue) table[cellNb] = 0;
+ else table[cellNb] -= reducerValue;
+ cellNb++;
+ } }
+}
+
+static void ZSTD_reduceTable(U32* const table, U32 const size, U32 const reducerValue)
+{
+ ZSTD_reduceTable_internal(table, size, reducerValue, 0);
+}
+
+static void ZSTD_reduceTable_btlazy2(U32* const table, U32 const size, U32 const reducerValue)
+{
+ ZSTD_reduceTable_internal(table, size, reducerValue, 1);
+}
+
+/*! ZSTD_reduceIndex() :
+* rescale all indexes to avoid future overflow (indexes are U32) */
+static void ZSTD_reduceIndex (ZSTD_CCtx* zc, const U32 reducerValue)
+{
+ ZSTD_matchState_t* const ms = &zc->blockState.matchState;
+ { U32 const hSize = (U32)1 << zc->appliedParams.cParams.hashLog;
+ ZSTD_reduceTable(ms->hashTable, hSize, reducerValue);
+ }
+
+ if (zc->appliedParams.cParams.strategy != ZSTD_fast) {
+ U32 const chainSize = (U32)1 << zc->appliedParams.cParams.chainLog;
+ if (zc->appliedParams.cParams.strategy == ZSTD_btlazy2)
+ ZSTD_reduceTable_btlazy2(ms->chainTable, chainSize, reducerValue);
+ else
+ ZSTD_reduceTable(ms->chainTable, chainSize, reducerValue);
+ }
+
+ if (ms->hashLog3) {
+ U32 const h3Size = (U32)1 << ms->hashLog3;
+ ZSTD_reduceTable(ms->hashTable3, h3Size, reducerValue);
+ }
+}
+
+
+/*-*******************************************************
+* Block entropic compression
+*********************************************************/
+
+/* See doc/zstd_compression_format.md for detailed format description */
+
+static size_t ZSTD_noCompressBlock (void* dst, size_t dstCapacity, const void* src, size_t srcSize, U32 lastBlock)
+{
+ U32 const cBlockHeader24 = lastBlock + (((U32)bt_raw)<<1) + (U32)(srcSize << 3);
+ if (srcSize + ZSTD_blockHeaderSize > dstCapacity) return ERROR(dstSize_tooSmall);
+ MEM_writeLE24(dst, cBlockHeader24);
+ memcpy((BYTE*)dst + ZSTD_blockHeaderSize, src, srcSize);
+ return ZSTD_blockHeaderSize + srcSize;
+}
+
+static size_t ZSTD_noCompressLiterals (void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+{
+ BYTE* const ostart = (BYTE* const)dst;
+ U32 const flSize = 1 + (srcSize>31) + (srcSize>4095);
+
+ if (srcSize + flSize > dstCapacity) return ERROR(dstSize_tooSmall);
+
+ switch(flSize)
+ {
+ case 1: /* 2 - 1 - 5 */
+ ostart[0] = (BYTE)((U32)set_basic + (srcSize<<3));
+ break;
+ case 2: /* 2 - 2 - 12 */
+ MEM_writeLE16(ostart, (U16)((U32)set_basic + (1<<2) + (srcSize<<4)));
+ break;
+ case 3: /* 2 - 2 - 20 */
+ MEM_writeLE32(ostart, (U32)((U32)set_basic + (3<<2) + (srcSize<<4)));
+ break;
+ default: /* not necessary : flSize is {1,2,3} */
+ assert(0);
+ }
+
+ memcpy(ostart + flSize, src, srcSize);
+ return srcSize + flSize;
+}
+
+static size_t ZSTD_compressRleLiteralsBlock (void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+{
+ BYTE* const ostart = (BYTE* const)dst;
+ U32 const flSize = 1 + (srcSize>31) + (srcSize>4095);
+
+ (void)dstCapacity; /* dstCapacity already guaranteed to be >=4, hence large enough */
+
+ switch(flSize)
+ {
+ case 1: /* 2 - 1 - 5 */
+ ostart[0] = (BYTE)((U32)set_rle + (srcSize<<3));
+ break;
+ case 2: /* 2 - 2 - 12 */
+ MEM_writeLE16(ostart, (U16)((U32)set_rle + (1<<2) + (srcSize<<4)));
+ break;
+ case 3: /* 2 - 2 - 20 */
+ MEM_writeLE32(ostart, (U32)((U32)set_rle + (3<<2) + (srcSize<<4)));
+ break;
+ default: /* not necessary : flSize is {1,2,3} */
+ assert(0);
+ }
+
+ ostart[flSize] = *(const BYTE*)src;
+ return flSize+1;
+}
+
+
+/* ZSTD_minGain() :
+ * minimum compression required
+ * to generate a compress block or a compressed literals section.
+ * note : use same formula for both situations */
+static size_t ZSTD_minGain(size_t srcSize, ZSTD_strategy strat)
+{
+ U32 const minlog = (strat>=ZSTD_btultra) ? (U32)(strat) - 1 : 6;
+ ZSTD_STATIC_ASSERT(ZSTD_btultra == 8);
+ assert(ZSTD_cParam_withinBounds(ZSTD_c_strategy, strat));
+ return (srcSize >> minlog) + 2;
+}
+
+static size_t ZSTD_compressLiterals (ZSTD_hufCTables_t const* prevHuf,
+ ZSTD_hufCTables_t* nextHuf,
+ ZSTD_strategy strategy, int disableLiteralCompression,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ void* workspace, size_t wkspSize,
+ const int bmi2)
+{
+ size_t const minGain = ZSTD_minGain(srcSize, strategy);
+ size_t const lhSize = 3 + (srcSize >= 1 KB) + (srcSize >= 16 KB);
+ BYTE* const ostart = (BYTE*)dst;
+ U32 singleStream = srcSize < 256;
+ symbolEncodingType_e hType = set_compressed;
+ size_t cLitSize;
+
+ DEBUGLOG(5,"ZSTD_compressLiterals (disableLiteralCompression=%i)",
+ disableLiteralCompression);
+
+ /* Prepare nextEntropy assuming reusing the existing table */
+ memcpy(nextHuf, prevHuf, sizeof(*prevHuf));
+
+ if (disableLiteralCompression)
+ return ZSTD_noCompressLiterals(dst, dstCapacity, src, srcSize);
+
+ /* small ? don't even attempt compression (speed opt) */
+# define COMPRESS_LITERALS_SIZE_MIN 63
+ { size_t const minLitSize = (prevHuf->repeatMode == HUF_repeat_valid) ? 6 : COMPRESS_LITERALS_SIZE_MIN;
+ if (srcSize <= minLitSize) return ZSTD_noCompressLiterals(dst, dstCapacity, src, srcSize);
+ }
+
+ if (dstCapacity < lhSize+1) return ERROR(dstSize_tooSmall); /* not enough space for compression */
+ { HUF_repeat repeat = prevHuf->repeatMode;
+ int const preferRepeat = strategy < ZSTD_lazy ? srcSize <= 1024 : 0;
+ if (repeat == HUF_repeat_valid && lhSize == 3) singleStream = 1;
+ cLitSize = singleStream ? HUF_compress1X_repeat(ostart+lhSize, dstCapacity-lhSize, src, srcSize, 255, 11,
+ workspace, wkspSize, (HUF_CElt*)nextHuf->CTable, &repeat, preferRepeat, bmi2)
+ : HUF_compress4X_repeat(ostart+lhSize, dstCapacity-lhSize, src, srcSize, 255, 11,
+ workspace, wkspSize, (HUF_CElt*)nextHuf->CTable, &repeat, preferRepeat, bmi2);
+ if (repeat != HUF_repeat_none) {
+ /* reused the existing table */
+ hType = set_repeat;
+ }
+ }
+
+ if ((cLitSize==0) | (cLitSize >= srcSize - minGain) | ERR_isError(cLitSize)) {
+ memcpy(nextHuf, prevHuf, sizeof(*prevHuf));
+ return ZSTD_noCompressLiterals(dst, dstCapacity, src, srcSize);
+ }
+ if (cLitSize==1) {
+ memcpy(nextHuf, prevHuf, sizeof(*prevHuf));
+ return ZSTD_compressRleLiteralsBlock(dst, dstCapacity, src, srcSize);
+ }
+
+ if (hType == set_compressed) {
+ /* using a newly constructed table */
+ nextHuf->repeatMode = HUF_repeat_check;
+ }
+
+ /* Build header */
+ switch(lhSize)
+ {
+ case 3: /* 2 - 2 - 10 - 10 */
+ { U32 const lhc = hType + ((!singleStream) << 2) + ((U32)srcSize<<4) + ((U32)cLitSize<<14);
+ MEM_writeLE24(ostart, lhc);
+ break;
+ }
+ case 4: /* 2 - 2 - 14 - 14 */
+ { U32 const lhc = hType + (2 << 2) + ((U32)srcSize<<4) + ((U32)cLitSize<<18);
+ MEM_writeLE32(ostart, lhc);
+ break;
+ }
+ case 5: /* 2 - 2 - 18 - 18 */
+ { U32 const lhc = hType + (3 << 2) + ((U32)srcSize<<4) + ((U32)cLitSize<<22);
+ MEM_writeLE32(ostart, lhc);
+ ostart[4] = (BYTE)(cLitSize >> 10);
+ break;
+ }
+ default: /* not possible : lhSize is {3,4,5} */
+ assert(0);
+ }
+ return lhSize+cLitSize;
+}
+
+
+void ZSTD_seqToCodes(const seqStore_t* seqStorePtr)
+{
+ const seqDef* const sequences = seqStorePtr->sequencesStart;
+ BYTE* const llCodeTable = seqStorePtr->llCode;
+ BYTE* const ofCodeTable = seqStorePtr->ofCode;
+ BYTE* const mlCodeTable = seqStorePtr->mlCode;
+ U32 const nbSeq = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
+ U32 u;
+ assert(nbSeq <= seqStorePtr->maxNbSeq);
+ for (u=0; u<nbSeq; u++) {
+ U32 const llv = sequences[u].litLength;
+ U32 const mlv = sequences[u].matchLength;
+ llCodeTable[u] = (BYTE)ZSTD_LLcode(llv);
+ ofCodeTable[u] = (BYTE)ZSTD_highbit32(sequences[u].offset);
+ mlCodeTable[u] = (BYTE)ZSTD_MLcode(mlv);
+ }
+ if (seqStorePtr->longLengthID==1)
+ llCodeTable[seqStorePtr->longLengthPos] = MaxLL;
+ if (seqStorePtr->longLengthID==2)
+ mlCodeTable[seqStorePtr->longLengthPos] = MaxML;
+}
+
+
+/**
+ * -log2(x / 256) lookup table for x in [0, 256).
+ * If x == 0: Return 0
+ * Else: Return floor(-log2(x / 256) * 256)
+ */
+static unsigned const kInverseProbabiltyLog256[256] = {
+ 0, 2048, 1792, 1642, 1536, 1453, 1386, 1329, 1280, 1236, 1197, 1162,
+ 1130, 1100, 1073, 1047, 1024, 1001, 980, 960, 941, 923, 906, 889,
+ 874, 859, 844, 830, 817, 804, 791, 779, 768, 756, 745, 734,
+ 724, 714, 704, 694, 685, 676, 667, 658, 650, 642, 633, 626,
+ 618, 610, 603, 595, 588, 581, 574, 567, 561, 554, 548, 542,
+ 535, 529, 523, 517, 512, 506, 500, 495, 489, 484, 478, 473,
+ 468, 463, 458, 453, 448, 443, 438, 434, 429, 424, 420, 415,
+ 411, 407, 402, 398, 394, 390, 386, 382, 377, 373, 370, 366,
+ 362, 358, 354, 350, 347, 343, 339, 336, 332, 329, 325, 322,
+ 318, 315, 311, 308, 305, 302, 298, 295, 292, 289, 286, 282,
+ 279, 276, 273, 270, 267, 264, 261, 258, 256, 253, 250, 247,
+ 244, 241, 239, 236, 233, 230, 228, 225, 222, 220, 217, 215,
+ 212, 209, 207, 204, 202, 199, 197, 194, 192, 190, 187, 185,
+ 182, 180, 178, 175, 173, 171, 168, 166, 164, 162, 159, 157,
+ 155, 153, 151, 149, 146, 144, 142, 140, 138, 136, 134, 132,
+ 130, 128, 126, 123, 121, 119, 117, 115, 114, 112, 110, 108,
+ 106, 104, 102, 100, 98, 96, 94, 93, 91, 89, 87, 85,
+ 83, 82, 80, 78, 76, 74, 73, 71, 69, 67, 66, 64,
+ 62, 61, 59, 57, 55, 54, 52, 50, 49, 47, 46, 44,
+ 42, 41, 39, 37, 36, 34, 33, 31, 30, 28, 26, 25,
+ 23, 22, 20, 19, 17, 16, 14, 13, 11, 10, 8, 7,
+ 5, 4, 2, 1,
+};
+
+
+/**
+ * Returns the cost in bits of encoding the distribution described by count
+ * using the entropy bound.
+ */
+static size_t ZSTD_entropyCost(unsigned const* count, unsigned const max, size_t const total)
+{
+ unsigned cost = 0;
+ unsigned s;
+ for (s = 0; s <= max; ++s) {
+ unsigned norm = (unsigned)((256 * count[s]) / total);
+ if (count[s] != 0 && norm == 0)
+ norm = 1;
+ assert(count[s] < total);
+ cost += count[s] * kInverseProbabiltyLog256[norm];
+ }
+ return cost >> 8;
+}
+
+
+/**
+ * Returns the cost in bits of encoding the distribution in count using the
+ * table described by norm. The max symbol support by norm is assumed >= max.
+ * norm must be valid for every symbol with non-zero probability in count.
+ */
+static size_t ZSTD_crossEntropyCost(short const* norm, unsigned accuracyLog,
+ unsigned const* count, unsigned const max)
+{
+ unsigned const shift = 8 - accuracyLog;
+ size_t cost = 0;
+ unsigned s;
+ assert(accuracyLog <= 8);
+ for (s = 0; s <= max; ++s) {
+ unsigned const normAcc = norm[s] != -1 ? norm[s] : 1;
+ unsigned const norm256 = normAcc << shift;
+ assert(norm256 > 0);
+ assert(norm256 < 256);
+ cost += count[s] * kInverseProbabiltyLog256[norm256];
+ }
+ return cost >> 8;
+}
+
+
+static unsigned ZSTD_getFSEMaxSymbolValue(FSE_CTable const* ctable) {
+ void const* ptr = ctable;
+ U16 const* u16ptr = (U16 const*)ptr;
+ U32 const maxSymbolValue = MEM_read16(u16ptr + 1);
+ return maxSymbolValue;
+}
+
+
+/**
+ * Returns the cost in bits of encoding the distribution in count using ctable.
+ * Returns an error if ctable cannot represent all the symbols in count.
+ */
+static size_t ZSTD_fseBitCost(
+ FSE_CTable const* ctable,
+ unsigned const* count,
+ unsigned const max)
+{
+ unsigned const kAccuracyLog = 8;
+ size_t cost = 0;
+ unsigned s;
+ FSE_CState_t cstate;
+ FSE_initCState(&cstate, ctable);
+ if (ZSTD_getFSEMaxSymbolValue(ctable) < max) {
+ DEBUGLOG(5, "Repeat FSE_CTable has maxSymbolValue %u < %u",
+ ZSTD_getFSEMaxSymbolValue(ctable), max);
+ return ERROR(GENERIC);
+ }
+ for (s = 0; s <= max; ++s) {
+ unsigned const tableLog = cstate.stateLog;
+ unsigned const badCost = (tableLog + 1) << kAccuracyLog;
+ unsigned const bitCost = FSE_bitCost(cstate.symbolTT, tableLog, s, kAccuracyLog);
+ if (count[s] == 0)
+ continue;
+ if (bitCost >= badCost) {
+ DEBUGLOG(5, "Repeat FSE_CTable has Prob[%u] == 0", s);
+ return ERROR(GENERIC);
+ }
+ cost += count[s] * bitCost;
+ }
+ return cost >> kAccuracyLog;
+}
+
+/**
+ * Returns the cost in bytes of encoding the normalized count header.
+ * Returns an error if any of the helper functions return an error.
+ */
+static size_t ZSTD_NCountCost(unsigned const* count, unsigned const max,
+ size_t const nbSeq, unsigned const FSELog)
+{
+ BYTE wksp[FSE_NCOUNTBOUND];
+ S16 norm[MaxSeq + 1];
+ const U32 tableLog = FSE_optimalTableLog(FSELog, nbSeq, max);
+ CHECK_F(FSE_normalizeCount(norm, tableLog, count, nbSeq, max));
+ return FSE_writeNCount(wksp, sizeof(wksp), norm, max, tableLog);
+}
+
+
+typedef enum {
+ ZSTD_defaultDisallowed = 0,
+ ZSTD_defaultAllowed = 1
+} ZSTD_defaultPolicy_e;
+
+MEM_STATIC symbolEncodingType_e
+ZSTD_selectEncodingType(
+ FSE_repeat* repeatMode, unsigned const* count, unsigned const max,
+ size_t const mostFrequent, size_t nbSeq, unsigned const FSELog,
+ FSE_CTable const* prevCTable,
+ short const* defaultNorm, U32 defaultNormLog,
+ ZSTD_defaultPolicy_e const isDefaultAllowed,
+ ZSTD_strategy const strategy)
+{
+ ZSTD_STATIC_ASSERT(ZSTD_defaultDisallowed == 0 && ZSTD_defaultAllowed != 0);
+ if (mostFrequent == nbSeq) {
+ *repeatMode = FSE_repeat_none;
+ if (isDefaultAllowed && nbSeq <= 2) {
+ /* Prefer set_basic over set_rle when there are 2 or less symbols,
+ * since RLE uses 1 byte, but set_basic uses 5-6 bits per symbol.
+ * If basic encoding isn't possible, always choose RLE.
+ */
+ DEBUGLOG(5, "Selected set_basic");
+ return set_basic;
+ }
+ DEBUGLOG(5, "Selected set_rle");
+ return set_rle;
+ }
+ if (strategy < ZSTD_lazy) {
+ if (isDefaultAllowed) {
+ size_t const staticFse_nbSeq_max = 1000;
+ size_t const mult = 10 - strategy;
+ size_t const baseLog = 3;
+ size_t const dynamicFse_nbSeq_min = (((size_t)1 << defaultNormLog) * mult) >> baseLog; /* 28-36 for offset, 56-72 for lengths */
+ assert(defaultNormLog >= 5 && defaultNormLog <= 6); /* xx_DEFAULTNORMLOG */
+ assert(mult <= 9 && mult >= 7);
+ if ( (*repeatMode == FSE_repeat_valid)
+ && (nbSeq < staticFse_nbSeq_max) ) {
+ DEBUGLOG(5, "Selected set_repeat");
+ return set_repeat;
+ }
+ if ( (nbSeq < dynamicFse_nbSeq_min)
+ || (mostFrequent < (nbSeq >> (defaultNormLog-1))) ) {
+ DEBUGLOG(5, "Selected set_basic");
+ /* The format allows default tables to be repeated, but it isn't useful.
+ * When using simple heuristics to select encoding type, we don't want
+ * to confuse these tables with dictionaries. When running more careful
+ * analysis, we don't need to waste time checking both repeating tables
+ * and default tables.
+ */
+ *repeatMode = FSE_repeat_none;
+ return set_basic;
+ }
+ }
+ } else {
+ size_t const basicCost = isDefaultAllowed ? ZSTD_crossEntropyCost(defaultNorm, defaultNormLog, count, max) : ERROR(GENERIC);
+ size_t const repeatCost = *repeatMode != FSE_repeat_none ? ZSTD_fseBitCost(prevCTable, count, max) : ERROR(GENERIC);
+ size_t const NCountCost = ZSTD_NCountCost(count, max, nbSeq, FSELog);
+ size_t const compressedCost = (NCountCost << 3) + ZSTD_entropyCost(count, max, nbSeq);
+
+ if (isDefaultAllowed) {
+ assert(!ZSTD_isError(basicCost));
+ assert(!(*repeatMode == FSE_repeat_valid && ZSTD_isError(repeatCost)));
+ }
+ assert(!ZSTD_isError(NCountCost));
+ assert(compressedCost < ERROR(maxCode));
+ DEBUGLOG(5, "Estimated bit costs: basic=%u\trepeat=%u\tcompressed=%u",
+ (unsigned)basicCost, (unsigned)repeatCost, (unsigned)compressedCost);
+ if (basicCost <= repeatCost && basicCost <= compressedCost) {
+ DEBUGLOG(5, "Selected set_basic");
+ assert(isDefaultAllowed);
+ *repeatMode = FSE_repeat_none;
+ return set_basic;
+ }
+ if (repeatCost <= compressedCost) {
+ DEBUGLOG(5, "Selected set_repeat");
+ assert(!ZSTD_isError(repeatCost));
+ return set_repeat;
+ }
+ assert(compressedCost < basicCost && compressedCost < repeatCost);
+ }
+ DEBUGLOG(5, "Selected set_compressed");
+ *repeatMode = FSE_repeat_check;
+ return set_compressed;
+}
+
+MEM_STATIC size_t
+ZSTD_buildCTable(void* dst, size_t dstCapacity,
+ FSE_CTable* nextCTable, U32 FSELog, symbolEncodingType_e type,
+ unsigned* count, U32 max,
+ const BYTE* codeTable, size_t nbSeq,
+ const S16* defaultNorm, U32 defaultNormLog, U32 defaultMax,
+ const FSE_CTable* prevCTable, size_t prevCTableSize,
+ void* workspace, size_t workspaceSize)
+{
+ BYTE* op = (BYTE*)dst;
+ const BYTE* const oend = op + dstCapacity;
+ DEBUGLOG(6, "ZSTD_buildCTable (dstCapacity=%u)", (unsigned)dstCapacity);
+
+ switch (type) {
+ case set_rle:
+ CHECK_F(FSE_buildCTable_rle(nextCTable, (BYTE)max));
+ if (dstCapacity==0) return ERROR(dstSize_tooSmall);
+ *op = codeTable[0];
+ return 1;
+ case set_repeat:
+ memcpy(nextCTable, prevCTable, prevCTableSize);
+ return 0;
+ case set_basic:
+ CHECK_F(FSE_buildCTable_wksp(nextCTable, defaultNorm, defaultMax, defaultNormLog, workspace, workspaceSize)); /* note : could be pre-calculated */
+ return 0;
+ case set_compressed: {
+ S16 norm[MaxSeq + 1];
+ size_t nbSeq_1 = nbSeq;
+ const U32 tableLog = FSE_optimalTableLog(FSELog, nbSeq, max);
+ if (count[codeTable[nbSeq-1]] > 1) {
+ count[codeTable[nbSeq-1]]--;
+ nbSeq_1--;
+ }
+ assert(nbSeq_1 > 1);
+ CHECK_F(FSE_normalizeCount(norm, tableLog, count, nbSeq_1, max));
+ { size_t const NCountSize = FSE_writeNCount(op, oend - op, norm, max, tableLog); /* overflow protected */
+ if (FSE_isError(NCountSize)) return NCountSize;
+ CHECK_F(FSE_buildCTable_wksp(nextCTable, norm, max, tableLog, workspace, workspaceSize));
+ return NCountSize;
+ }
+ }
+ default: return assert(0), ERROR(GENERIC);
+ }
+}
+
+FORCE_INLINE_TEMPLATE size_t
+ZSTD_encodeSequences_body(
+ void* dst, size_t dstCapacity,
+ FSE_CTable const* CTable_MatchLength, BYTE const* mlCodeTable,
+ FSE_CTable const* CTable_OffsetBits, BYTE const* ofCodeTable,
+ FSE_CTable const* CTable_LitLength, BYTE const* llCodeTable,
+ seqDef const* sequences, size_t nbSeq, int longOffsets)
+{
+ BIT_CStream_t blockStream;
+ FSE_CState_t stateMatchLength;
+ FSE_CState_t stateOffsetBits;
+ FSE_CState_t stateLitLength;
+
+ CHECK_E(BIT_initCStream(&blockStream, dst, dstCapacity), dstSize_tooSmall); /* not enough space remaining */
+ DEBUGLOG(6, "available space for bitstream : %i (dstCapacity=%u)",
+ (int)(blockStream.endPtr - blockStream.startPtr),
+ (unsigned)dstCapacity);
+
+ /* first symbols */
+ FSE_initCState2(&stateMatchLength, CTable_MatchLength, mlCodeTable[nbSeq-1]);
+ FSE_initCState2(&stateOffsetBits, CTable_OffsetBits, ofCodeTable[nbSeq-1]);
+ FSE_initCState2(&stateLitLength, CTable_LitLength, llCodeTable[nbSeq-1]);
+ BIT_addBits(&blockStream, sequences[nbSeq-1].litLength, LL_bits[llCodeTable[nbSeq-1]]);
+ if (MEM_32bits()) BIT_flushBits(&blockStream);
+ BIT_addBits(&blockStream, sequences[nbSeq-1].matchLength, ML_bits[mlCodeTable[nbSeq-1]]);
+ if (MEM_32bits()) BIT_flushBits(&blockStream);
+ if (longOffsets) {
+ U32 const ofBits = ofCodeTable[nbSeq-1];
+ int const extraBits = ofBits - MIN(ofBits, STREAM_ACCUMULATOR_MIN-1);
+ if (extraBits) {
+ BIT_addBits(&blockStream, sequences[nbSeq-1].offset, extraBits);
+ BIT_flushBits(&blockStream);
+ }
+ BIT_addBits(&blockStream, sequences[nbSeq-1].offset >> extraBits,
+ ofBits - extraBits);
+ } else {
+ BIT_addBits(&blockStream, sequences[nbSeq-1].offset, ofCodeTable[nbSeq-1]);
+ }
+ BIT_flushBits(&blockStream);
+
+ { size_t n;
+ for (n=nbSeq-2 ; n<nbSeq ; n--) { /* intentional underflow */
+ BYTE const llCode = llCodeTable[n];
+ BYTE const ofCode = ofCodeTable[n];
+ BYTE const mlCode = mlCodeTable[n];
+ U32 const llBits = LL_bits[llCode];
+ U32 const ofBits = ofCode;
+ U32 const mlBits = ML_bits[mlCode];
+ DEBUGLOG(6, "encoding: litlen:%2u - matchlen:%2u - offCode:%7u",
+ (unsigned)sequences[n].litLength,
+ (unsigned)sequences[n].matchLength + MINMATCH,
+ (unsigned)sequences[n].offset);
+ /* 32b*/ /* 64b*/
+ /* (7)*/ /* (7)*/
+ FSE_encodeSymbol(&blockStream, &stateOffsetBits, ofCode); /* 15 */ /* 15 */
+ FSE_encodeSymbol(&blockStream, &stateMatchLength, mlCode); /* 24 */ /* 24 */
+ if (MEM_32bits()) BIT_flushBits(&blockStream); /* (7)*/
+ FSE_encodeSymbol(&blockStream, &stateLitLength, llCode); /* 16 */ /* 33 */
+ if (MEM_32bits() || (ofBits+mlBits+llBits >= 64-7-(LLFSELog+MLFSELog+OffFSELog)))
+ BIT_flushBits(&blockStream); /* (7)*/
+ BIT_addBits(&blockStream, sequences[n].litLength, llBits);
+ if (MEM_32bits() && ((llBits+mlBits)>24)) BIT_flushBits(&blockStream);
+ BIT_addBits(&blockStream, sequences[n].matchLength, mlBits);
+ if (MEM_32bits() || (ofBits+mlBits+llBits > 56)) BIT_flushBits(&blockStream);
+ if (longOffsets) {
+ int const extraBits = ofBits - MIN(ofBits, STREAM_ACCUMULATOR_MIN-1);
+ if (extraBits) {
+ BIT_addBits(&blockStream, sequences[n].offset, extraBits);
+ BIT_flushBits(&blockStream); /* (7)*/
+ }
+ BIT_addBits(&blockStream, sequences[n].offset >> extraBits,
+ ofBits - extraBits); /* 31 */
+ } else {
+ BIT_addBits(&blockStream, sequences[n].offset, ofBits); /* 31 */
+ }
+ BIT_flushBits(&blockStream); /* (7)*/
+ DEBUGLOG(7, "remaining space : %i", (int)(blockStream.endPtr - blockStream.ptr));
+ } }
+
+ DEBUGLOG(6, "ZSTD_encodeSequences: flushing ML state with %u bits", stateMatchLength.stateLog);
+ FSE_flushCState(&blockStream, &stateMatchLength);
+ DEBUGLOG(6, "ZSTD_encodeSequences: flushing Off state with %u bits", stateOffsetBits.stateLog);
+ FSE_flushCState(&blockStream, &stateOffsetBits);
+ DEBUGLOG(6, "ZSTD_encodeSequences: flushing LL state with %u bits", stateLitLength.stateLog);
+ FSE_flushCState(&blockStream, &stateLitLength);
+
+ { size_t const streamSize = BIT_closeCStream(&blockStream);
+ if (streamSize==0) return ERROR(dstSize_tooSmall); /* not enough space */
+ return streamSize;
+ }
+}
+
+static size_t
+ZSTD_encodeSequences_default(
+ void* dst, size_t dstCapacity,
+ FSE_CTable const* CTable_MatchLength, BYTE const* mlCodeTable,
+ FSE_CTable const* CTable_OffsetBits, BYTE const* ofCodeTable,
+ FSE_CTable const* CTable_LitLength, BYTE const* llCodeTable,
+ seqDef const* sequences, size_t nbSeq, int longOffsets)
+{
+ return ZSTD_encodeSequences_body(dst, dstCapacity,
+ CTable_MatchLength, mlCodeTable,
+ CTable_OffsetBits, ofCodeTable,
+ CTable_LitLength, llCodeTable,
+ sequences, nbSeq, longOffsets);
+}
+
+
+#if DYNAMIC_BMI2
+
+static TARGET_ATTRIBUTE("bmi2") size_t
+ZSTD_encodeSequences_bmi2(
+ void* dst, size_t dstCapacity,
+ FSE_CTable const* CTable_MatchLength, BYTE const* mlCodeTable,
+ FSE_CTable const* CTable_OffsetBits, BYTE const* ofCodeTable,
+ FSE_CTable const* CTable_LitLength, BYTE const* llCodeTable,
+ seqDef const* sequences, size_t nbSeq, int longOffsets)
+{
+ return ZSTD_encodeSequences_body(dst, dstCapacity,
+ CTable_MatchLength, mlCodeTable,
+ CTable_OffsetBits, ofCodeTable,
+ CTable_LitLength, llCodeTable,
+ sequences, nbSeq, longOffsets);
+}
+
+#endif
+
+static size_t ZSTD_encodeSequences(
+ void* dst, size_t dstCapacity,
+ FSE_CTable const* CTable_MatchLength, BYTE const* mlCodeTable,
+ FSE_CTable const* CTable_OffsetBits, BYTE const* ofCodeTable,
+ FSE_CTable const* CTable_LitLength, BYTE const* llCodeTable,
+ seqDef const* sequences, size_t nbSeq, int longOffsets, int bmi2)
+{
+ DEBUGLOG(5, "ZSTD_encodeSequences: dstCapacity = %u", (unsigned)dstCapacity);
+#if DYNAMIC_BMI2
+ if (bmi2) {
+ return ZSTD_encodeSequences_bmi2(dst, dstCapacity,
+ CTable_MatchLength, mlCodeTable,
+ CTable_OffsetBits, ofCodeTable,
+ CTable_LitLength, llCodeTable,
+ sequences, nbSeq, longOffsets);
+ }
+#endif
+ (void)bmi2;
+ return ZSTD_encodeSequences_default(dst, dstCapacity,
+ CTable_MatchLength, mlCodeTable,
+ CTable_OffsetBits, ofCodeTable,
+ CTable_LitLength, llCodeTable,
+ sequences, nbSeq, longOffsets);
+}
+
+/* ZSTD_compressSequences_internal():
+ * actually compresses both literals and sequences */
+MEM_STATIC size_t
+ZSTD_compressSequences_internal(seqStore_t* seqStorePtr,
+ const ZSTD_entropyCTables_t* prevEntropy,
+ ZSTD_entropyCTables_t* nextEntropy,
+ const ZSTD_CCtx_params* cctxParams,
+ void* dst, size_t dstCapacity,
+ void* workspace, size_t wkspSize,
+ const int bmi2)
+{
+ const int longOffsets = cctxParams->cParams.windowLog > STREAM_ACCUMULATOR_MIN;
+ ZSTD_strategy const strategy = cctxParams->cParams.strategy;
+ unsigned count[MaxSeq+1];
+ FSE_CTable* CTable_LitLength = nextEntropy->fse.litlengthCTable;
+ FSE_CTable* CTable_OffsetBits = nextEntropy->fse.offcodeCTable;
+ FSE_CTable* CTable_MatchLength = nextEntropy->fse.matchlengthCTable;
+ U32 LLtype, Offtype, MLtype; /* compressed, raw or rle */
+ const seqDef* const sequences = seqStorePtr->sequencesStart;
+ const BYTE* const ofCodeTable = seqStorePtr->ofCode;
+ const BYTE* const llCodeTable = seqStorePtr->llCode;
+ const BYTE* const mlCodeTable = seqStorePtr->mlCode;
+ BYTE* const ostart = (BYTE*)dst;
+ BYTE* const oend = ostart + dstCapacity;
+ BYTE* op = ostart;
+ size_t const nbSeq = seqStorePtr->sequences - seqStorePtr->sequencesStart;
+ BYTE* seqHead;
+ BYTE* lastNCount = NULL;
+
+ ZSTD_STATIC_ASSERT(HUF_WORKSPACE_SIZE >= (1<<MAX(MLFSELog,LLFSELog)));
+ DEBUGLOG(5, "ZSTD_compressSequences_internal");
+
+ /* Compress literals */
+ { const BYTE* const literals = seqStorePtr->litStart;
+ size_t const litSize = seqStorePtr->lit - literals;
+ int const disableLiteralCompression = (cctxParams->cParams.strategy == ZSTD_fast) && (cctxParams->cParams.targetLength > 0);
+ size_t const cSize = ZSTD_compressLiterals(
+ &prevEntropy->huf, &nextEntropy->huf,
+ cctxParams->cParams.strategy, disableLiteralCompression,
+ op, dstCapacity,
+ literals, litSize,
+ workspace, wkspSize,
+ bmi2);
+ if (ZSTD_isError(cSize))
+ return cSize;
+ assert(cSize <= dstCapacity);
+ op += cSize;
+ }
+
+ /* Sequences Header */
+ if ((oend-op) < 3 /*max nbSeq Size*/ + 1 /*seqHead*/) return ERROR(dstSize_tooSmall);
+ if (nbSeq < 0x7F)
+ *op++ = (BYTE)nbSeq;
+ else if (nbSeq < LONGNBSEQ)
+ op[0] = (BYTE)((nbSeq>>8) + 0x80), op[1] = (BYTE)nbSeq, op+=2;
+ else
+ op[0]=0xFF, MEM_writeLE16(op+1, (U16)(nbSeq - LONGNBSEQ)), op+=3;
+ if (nbSeq==0) {
+ /* Copy the old tables over as if we repeated them */
+ memcpy(&nextEntropy->fse, &prevEntropy->fse, sizeof(prevEntropy->fse));
+ return op - ostart;
+ }
+
+ /* seqHead : flags for FSE encoding type */
+ seqHead = op++;
+
+ /* convert length/distances into codes */
+ ZSTD_seqToCodes(seqStorePtr);
+ /* build CTable for Literal Lengths */
+ { unsigned max = MaxLL;
+ size_t const mostFrequent = HIST_countFast_wksp(count, &max, llCodeTable, nbSeq, workspace, wkspSize); /* can't fail */
+ DEBUGLOG(5, "Building LL table");
+ nextEntropy->fse.litlength_repeatMode = prevEntropy->fse.litlength_repeatMode;
+ LLtype = ZSTD_selectEncodingType(&nextEntropy->fse.litlength_repeatMode,
+ count, max, mostFrequent, nbSeq,
+ LLFSELog, prevEntropy->fse.litlengthCTable,
+ LL_defaultNorm, LL_defaultNormLog,
+ ZSTD_defaultAllowed, strategy);
+ assert(set_basic < set_compressed && set_rle < set_compressed);
+ assert(!(LLtype < set_compressed && nextEntropy->fse.litlength_repeatMode != FSE_repeat_none)); /* We don't copy tables */
+ { size_t const countSize = ZSTD_buildCTable(op, oend - op, CTable_LitLength, LLFSELog, (symbolEncodingType_e)LLtype,
+ count, max, llCodeTable, nbSeq, LL_defaultNorm, LL_defaultNormLog, MaxLL,
+ prevEntropy->fse.litlengthCTable, sizeof(prevEntropy->fse.litlengthCTable),
+ workspace, wkspSize);
+ if (ZSTD_isError(countSize)) return countSize;
+ if (LLtype == set_compressed)
+ lastNCount = op;
+ op += countSize;
+ } }
+ /* build CTable for Offsets */
+ { unsigned max = MaxOff;
+ size_t const mostFrequent = HIST_countFast_wksp(count, &max, ofCodeTable, nbSeq, workspace, wkspSize); /* can't fail */
+ /* We can only use the basic table if max <= DefaultMaxOff, otherwise the offsets are too large */
+ ZSTD_defaultPolicy_e const defaultPolicy = (max <= DefaultMaxOff) ? ZSTD_defaultAllowed : ZSTD_defaultDisallowed;
+ DEBUGLOG(5, "Building OF table");
+ nextEntropy->fse.offcode_repeatMode = prevEntropy->fse.offcode_repeatMode;
+ Offtype = ZSTD_selectEncodingType(&nextEntropy->fse.offcode_repeatMode,
+ count, max, mostFrequent, nbSeq,
+ OffFSELog, prevEntropy->fse.offcodeCTable,
+ OF_defaultNorm, OF_defaultNormLog,
+ defaultPolicy, strategy);
+ assert(!(Offtype < set_compressed && nextEntropy->fse.offcode_repeatMode != FSE_repeat_none)); /* We don't copy tables */
+ { size_t const countSize = ZSTD_buildCTable(op, oend - op, CTable_OffsetBits, OffFSELog, (symbolEncodingType_e)Offtype,
+ count, max, ofCodeTable, nbSeq, OF_defaultNorm, OF_defaultNormLog, DefaultMaxOff,
+ prevEntropy->fse.offcodeCTable, sizeof(prevEntropy->fse.offcodeCTable),
+ workspace, wkspSize);
+ if (ZSTD_isError(countSize)) return countSize;
+ if (Offtype == set_compressed)
+ lastNCount = op;
+ op += countSize;
+ } }
+ /* build CTable for MatchLengths */
+ { unsigned max = MaxML;
+ size_t const mostFrequent = HIST_countFast_wksp(count, &max, mlCodeTable, nbSeq, workspace, wkspSize); /* can't fail */
+ DEBUGLOG(5, "Building ML table (remaining space : %i)", (int)(oend-op));
+ nextEntropy->fse.matchlength_repeatMode = prevEntropy->fse.matchlength_repeatMode;
+ MLtype = ZSTD_selectEncodingType(&nextEntropy->fse.matchlength_repeatMode,
+ count, max, mostFrequent, nbSeq,
+ MLFSELog, prevEntropy->fse.matchlengthCTable,
+ ML_defaultNorm, ML_defaultNormLog,
+ ZSTD_defaultAllowed, strategy);
+ assert(!(MLtype < set_compressed && nextEntropy->fse.matchlength_repeatMode != FSE_repeat_none)); /* We don't copy tables */
+ { size_t const countSize = ZSTD_buildCTable(op, oend - op, CTable_MatchLength, MLFSELog, (symbolEncodingType_e)MLtype,
+ count, max, mlCodeTable, nbSeq, ML_defaultNorm, ML_defaultNormLog, MaxML,
+ prevEntropy->fse.matchlengthCTable, sizeof(prevEntropy->fse.matchlengthCTable),
+ workspace, wkspSize);
+ if (ZSTD_isError(countSize)) return countSize;
+ if (MLtype == set_compressed)
+ lastNCount = op;
+ op += countSize;
+ } }
+
+ *seqHead = (BYTE)((LLtype<<6) + (Offtype<<4) + (MLtype<<2));
+
+ { size_t const bitstreamSize = ZSTD_encodeSequences(
+ op, oend - op,
+ CTable_MatchLength, mlCodeTable,
+ CTable_OffsetBits, ofCodeTable,
+ CTable_LitLength, llCodeTable,
+ sequences, nbSeq,
+ longOffsets, bmi2);
+ if (ZSTD_isError(bitstreamSize)) return bitstreamSize;
+ op += bitstreamSize;
+ /* zstd versions <= 1.3.4 mistakenly report corruption when
+ * FSE_readNCount() recieves a buffer < 4 bytes.
+ * Fixed by https://github.com/facebook/zstd/pull/1146.
+ * This can happen when the last set_compressed table present is 2
+ * bytes and the bitstream is only one byte.
+ * In this exceedingly rare case, we will simply emit an uncompressed
+ * block, since it isn't worth optimizing.
+ */
+ if (lastNCount && (op - lastNCount) < 4) {
+ /* NCountSize >= 2 && bitstreamSize > 0 ==> lastCountSize == 3 */
+ assert(op - lastNCount == 3);
+ DEBUGLOG(5, "Avoiding bug in zstd decoder in versions <= 1.3.4 by "
+ "emitting an uncompressed block.");
+ return 0;
+ }
+ }
+
+ DEBUGLOG(5, "compressed block size : %u", (unsigned)(op - ostart));
+ return op - ostart;
+}
+
+MEM_STATIC size_t
+ZSTD_compressSequences(seqStore_t* seqStorePtr,
+ const ZSTD_entropyCTables_t* prevEntropy,
+ ZSTD_entropyCTables_t* nextEntropy,
+ const ZSTD_CCtx_params* cctxParams,
+ void* dst, size_t dstCapacity,
+ size_t srcSize,
+ void* workspace, size_t wkspSize,
+ int bmi2)
+{
+ size_t const cSize = ZSTD_compressSequences_internal(
+ seqStorePtr, prevEntropy, nextEntropy, cctxParams,
+ dst, dstCapacity,
+ workspace, wkspSize, bmi2);
+ if (cSize == 0) return 0;
+ /* When srcSize <= dstCapacity, there is enough space to write a raw uncompressed block.
+ * Since we ran out of space, block must be not compressible, so fall back to raw uncompressed block.
+ */
+ if ((cSize == ERROR(dstSize_tooSmall)) & (srcSize <= dstCapacity))
+ return 0; /* block not compressed */
+ if (ZSTD_isError(cSize)) return cSize;
+
+ /* Check compressibility */
+ { size_t const maxCSize = srcSize - ZSTD_minGain(srcSize, cctxParams->cParams.strategy);
+ if (cSize >= maxCSize) return 0; /* block not compressed */
+ }
+
+ return cSize;
+}
+
+/* ZSTD_selectBlockCompressor() :
+ * Not static, but internal use only (used by long distance matcher)
+ * assumption : strat is a valid strategy */
+ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_dictMode_e dictMode)
+{
+ static const ZSTD_blockCompressor blockCompressor[3][ZSTD_STRATEGY_MAX+1] = {
+ { ZSTD_compressBlock_fast /* default for 0 */,
+ ZSTD_compressBlock_fast,
+ ZSTD_compressBlock_doubleFast,
+ ZSTD_compressBlock_greedy,
+ ZSTD_compressBlock_lazy,
+ ZSTD_compressBlock_lazy2,
+ ZSTD_compressBlock_btlazy2,
+ ZSTD_compressBlock_btopt,
+ ZSTD_compressBlock_btultra,
+ ZSTD_compressBlock_btultra2 },
+ { ZSTD_compressBlock_fast_extDict /* default for 0 */,
+ ZSTD_compressBlock_fast_extDict,
+ ZSTD_compressBlock_doubleFast_extDict,
+ ZSTD_compressBlock_greedy_extDict,
+ ZSTD_compressBlock_lazy_extDict,
+ ZSTD_compressBlock_lazy2_extDict,
+ ZSTD_compressBlock_btlazy2_extDict,
+ ZSTD_compressBlock_btopt_extDict,
+ ZSTD_compressBlock_btultra_extDict,
+ ZSTD_compressBlock_btultra_extDict },
+ { ZSTD_compressBlock_fast_dictMatchState /* default for 0 */,
+ ZSTD_compressBlock_fast_dictMatchState,
+ ZSTD_compressBlock_doubleFast_dictMatchState,
+ ZSTD_compressBlock_greedy_dictMatchState,
+ ZSTD_compressBlock_lazy_dictMatchState,
+ ZSTD_compressBlock_lazy2_dictMatchState,
+ ZSTD_compressBlock_btlazy2_dictMatchState,
+ ZSTD_compressBlock_btopt_dictMatchState,
+ ZSTD_compressBlock_btultra_dictMatchState,
+ ZSTD_compressBlock_btultra_dictMatchState }
+ };
+ ZSTD_blockCompressor selectedCompressor;
+ ZSTD_STATIC_ASSERT((unsigned)ZSTD_fast == 1);
+
+ assert(ZSTD_cParam_withinBounds(ZSTD_c_strategy, strat));
+ selectedCompressor = blockCompressor[(int)dictMode][(int)strat];
+ assert(selectedCompressor != NULL);
+ return selectedCompressor;
+}
+
+static void ZSTD_storeLastLiterals(seqStore_t* seqStorePtr,
+ const BYTE* anchor, size_t lastLLSize)
+{
+ memcpy(seqStorePtr->lit, anchor, lastLLSize);
+ seqStorePtr->lit += lastLLSize;
+}
+
+void ZSTD_resetSeqStore(seqStore_t* ssPtr)
+{
+ ssPtr->lit = ssPtr->litStart;
+ ssPtr->sequences = ssPtr->sequencesStart;
+ ssPtr->longLengthID = 0;
+}
+
+static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize)
+{
+ ZSTD_matchState_t* const ms = &zc->blockState.matchState;
+ size_t cSize;
+ DEBUGLOG(5, "ZSTD_compressBlock_internal (dstCapacity=%u, dictLimit=%u, nextToUpdate=%u)",
+ (unsigned)dstCapacity, (unsigned)ms->window.dictLimit, (unsigned)ms->nextToUpdate);
+ assert(srcSize <= ZSTD_BLOCKSIZE_MAX);
+
+ /* Assert that we have correctly flushed the ctx params into the ms's copy */
+ ZSTD_assertEqualCParams(zc->appliedParams.cParams, ms->cParams);
+
+ if (srcSize < MIN_CBLOCK_SIZE+ZSTD_blockHeaderSize+1) {
+ ZSTD_ldm_skipSequences(&zc->externSeqStore, srcSize, zc->appliedParams.cParams.minMatch);
+ cSize = 0;
+ goto out; /* don't even attempt compression below a certain srcSize */
+ }
+ ZSTD_resetSeqStore(&(zc->seqStore));
+ ms->opt.symbolCosts = &zc->blockState.prevCBlock->entropy; /* required for optimal parser to read stats from dictionary */
+
+ /* a gap between an attached dict and the current window is not safe,
+ * they must remain adjacent,
+ * and when that stops being the case, the dict must be unset */
+ assert(ms->dictMatchState == NULL || ms->loadedDictEnd == ms->window.dictLimit);
+
+ /* limited update after a very long match */
+ { const BYTE* const base = ms->window.base;
+ const BYTE* const istart = (const BYTE*)src;
+ const U32 current = (U32)(istart-base);
+ if (sizeof(ptrdiff_t)==8) assert(istart - base < (ptrdiff_t)(U32)(-1)); /* ensure no overflow */
+ if (current > ms->nextToUpdate + 384)
+ ms->nextToUpdate = current - MIN(192, (U32)(current - ms->nextToUpdate - 384));
+ }
+
+ /* select and store sequences */
+ { ZSTD_dictMode_e const dictMode = ZSTD_matchState_dictMode(ms);
+ size_t lastLLSize;
+ { int i;
+ for (i = 0; i < ZSTD_REP_NUM; ++i)
+ zc->blockState.nextCBlock->rep[i] = zc->blockState.prevCBlock->rep[i];
+ }
+ if (zc->externSeqStore.pos < zc->externSeqStore.size) {
+ assert(!zc->appliedParams.ldmParams.enableLdm);
+ /* Updates ldmSeqStore.pos */
+ lastLLSize =
+ ZSTD_ldm_blockCompress(&zc->externSeqStore,
+ ms, &zc->seqStore,
+ zc->blockState.nextCBlock->rep,
+ src, srcSize);
+ assert(zc->externSeqStore.pos <= zc->externSeqStore.size);
+ } else if (zc->appliedParams.ldmParams.enableLdm) {
+ rawSeqStore_t ldmSeqStore = {NULL, 0, 0, 0};
+
+ ldmSeqStore.seq = zc->ldmSequences;
+ ldmSeqStore.capacity = zc->maxNbLdmSequences;
+ /* Updates ldmSeqStore.size */
+ CHECK_F(ZSTD_ldm_generateSequences(&zc->ldmState, &ldmSeqStore,
+ &zc->appliedParams.ldmParams,
+ src, srcSize));
+ /* Updates ldmSeqStore.pos */
+ lastLLSize =
+ ZSTD_ldm_blockCompress(&ldmSeqStore,
+ ms, &zc->seqStore,
+ zc->blockState.nextCBlock->rep,
+ src, srcSize);
+ assert(ldmSeqStore.pos == ldmSeqStore.size);
+ } else { /* not long range mode */
+ ZSTD_blockCompressor const blockCompressor = ZSTD_selectBlockCompressor(zc->appliedParams.cParams.strategy, dictMode);
+ lastLLSize = blockCompressor(ms, &zc->seqStore, zc->blockState.nextCBlock->rep, src, srcSize);
+ }
+ { const BYTE* const lastLiterals = (const BYTE*)src + srcSize - lastLLSize;
+ ZSTD_storeLastLiterals(&zc->seqStore, lastLiterals, lastLLSize);
+ } }
+
+ /* encode sequences and literals */
+ cSize = ZSTD_compressSequences(&zc->seqStore,
+ &zc->blockState.prevCBlock->entropy, &zc->blockState.nextCBlock->entropy,
+ &zc->appliedParams,
+ dst, dstCapacity,
+ srcSize,
+ zc->entropyWorkspace, HUF_WORKSPACE_SIZE /* statically allocated in resetCCtx */,
+ zc->bmi2);
+
+out:
+ if (!ZSTD_isError(cSize) && cSize != 0) {
+ /* confirm repcodes and entropy tables when emitting a compressed block */
+ ZSTD_compressedBlockState_t* const tmp = zc->blockState.prevCBlock;
+ zc->blockState.prevCBlock = zc->blockState.nextCBlock;
+ zc->blockState.nextCBlock = tmp;
+ }
+ /* We check that dictionaries have offset codes available for the first
+ * block. After the first block, the offcode table might not have large
+ * enough codes to represent the offsets in the data.
+ */
+ if (zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode == FSE_repeat_valid)
+ zc->blockState.prevCBlock->entropy.fse.offcode_repeatMode = FSE_repeat_check;
+
+ return cSize;
+}
+
+
+/*! ZSTD_compress_frameChunk() :
+* Compress a chunk of data into one or multiple blocks.
+* All blocks will be terminated, all input will be consumed.
+* Function will issue an error if there is not enough `dstCapacity` to hold the compressed content.
+* Frame is supposed already started (header already produced)
+* @return : compressed size, or an error code
+*/
+static size_t ZSTD_compress_frameChunk (ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ U32 lastFrameChunk)
+{
+ size_t blockSize = cctx->blockSize;
+ size_t remaining = srcSize;
+ const BYTE* ip = (const BYTE*)src;
+ BYTE* const ostart = (BYTE*)dst;
+ BYTE* op = ostart;
+ U32 const maxDist = (U32)1 << cctx->appliedParams.cParams.windowLog;
+ assert(cctx->appliedParams.cParams.windowLog <= 31);
+
+ DEBUGLOG(5, "ZSTD_compress_frameChunk (blockSize=%u)", (unsigned)blockSize);
+ if (cctx->appliedParams.fParams.checksumFlag && srcSize)
+ XXH64_update(&cctx->xxhState, src, srcSize);
+
+ while (remaining) {
+ ZSTD_matchState_t* const ms = &cctx->blockState.matchState;
+ U32 const lastBlock = lastFrameChunk & (blockSize >= remaining);
+
+ if (dstCapacity < ZSTD_blockHeaderSize + MIN_CBLOCK_SIZE)
+ return ERROR(dstSize_tooSmall); /* not enough space to store compressed block */
+ if (remaining < blockSize) blockSize = remaining;
+
+ if (ZSTD_window_needOverflowCorrection(ms->window, ip + blockSize)) {
+ U32 const cycleLog = ZSTD_cycleLog(cctx->appliedParams.cParams.chainLog, cctx->appliedParams.cParams.strategy);
+ U32 const correction = ZSTD_window_correctOverflow(&ms->window, cycleLog, maxDist, ip);
+ ZSTD_STATIC_ASSERT(ZSTD_CHAINLOG_MAX <= 30);
+ ZSTD_STATIC_ASSERT(ZSTD_WINDOWLOG_MAX_32 <= 30);
+ ZSTD_STATIC_ASSERT(ZSTD_WINDOWLOG_MAX <= 31);
+ ZSTD_reduceIndex(cctx, correction);
+ if (ms->nextToUpdate < correction) ms->nextToUpdate = 0;
+ else ms->nextToUpdate -= correction;
+ ms->loadedDictEnd = 0;
+ ms->dictMatchState = NULL;
+ }
+ ZSTD_window_enforceMaxDist(&ms->window, ip + blockSize, maxDist, &ms->loadedDictEnd, &ms->dictMatchState);
+ if (ms->nextToUpdate < ms->window.lowLimit) ms->nextToUpdate = ms->window.lowLimit;
+
+ { size_t cSize = ZSTD_compressBlock_internal(cctx,
+ op+ZSTD_blockHeaderSize, dstCapacity-ZSTD_blockHeaderSize,
+ ip, blockSize);
+ if (ZSTD_isError(cSize)) return cSize;
+
+ if (cSize == 0) { /* block is not compressible */
+ cSize = ZSTD_noCompressBlock(op, dstCapacity, ip, blockSize, lastBlock);
+ if (ZSTD_isError(cSize)) return cSize;
+ } else {
+ U32 const cBlockHeader24 = lastBlock + (((U32)bt_compressed)<<1) + (U32)(cSize << 3);
+ MEM_writeLE24(op, cBlockHeader24);
+ cSize += ZSTD_blockHeaderSize;
+ }
+
+ ip += blockSize;
+ assert(remaining >= blockSize);
+ remaining -= blockSize;
+ op += cSize;
+ assert(dstCapacity >= cSize);
+ dstCapacity -= cSize;
+ DEBUGLOG(5, "ZSTD_compress_frameChunk: adding a block of size %u",
+ (unsigned)cSize);
+ } }
+
+ if (lastFrameChunk && (op>ostart)) cctx->stage = ZSTDcs_ending;
+ return op-ostart;
+}
+
+
+static size_t ZSTD_writeFrameHeader(void* dst, size_t dstCapacity,
+ ZSTD_CCtx_params params, U64 pledgedSrcSize, U32 dictID)
+{ BYTE* const op = (BYTE*)dst;
+ U32 const dictIDSizeCodeLength = (dictID>0) + (dictID>=256) + (dictID>=65536); /* 0-3 */
+ U32 const dictIDSizeCode = params.fParams.noDictIDFlag ? 0 : dictIDSizeCodeLength; /* 0-3 */
+ U32 const checksumFlag = params.fParams.checksumFlag>0;
+ U32 const windowSize = (U32)1 << params.cParams.windowLog;
+ U32 const singleSegment = params.fParams.contentSizeFlag && (windowSize >= pledgedSrcSize);
+ BYTE const windowLogByte = (BYTE)((params.cParams.windowLog - ZSTD_WINDOWLOG_ABSOLUTEMIN) << 3);
+ U32 const fcsCode = params.fParams.contentSizeFlag ?
+ (pledgedSrcSize>=256) + (pledgedSrcSize>=65536+256) + (pledgedSrcSize>=0xFFFFFFFFU) : 0; /* 0-3 */
+ BYTE const frameHeaderDecriptionByte = (BYTE)(dictIDSizeCode + (checksumFlag<<2) + (singleSegment<<5) + (fcsCode<<6) );
+ size_t pos=0;
+
+ assert(!(params.fParams.contentSizeFlag && pledgedSrcSize == ZSTD_CONTENTSIZE_UNKNOWN));
+ if (dstCapacity < ZSTD_FRAMEHEADERSIZE_MAX) return ERROR(dstSize_tooSmall);
+ DEBUGLOG(4, "ZSTD_writeFrameHeader : dictIDFlag : %u ; dictID : %u ; dictIDSizeCode : %u",
+ !params.fParams.noDictIDFlag, (unsigned)dictID, (unsigned)dictIDSizeCode);
+
+ if (params.format == ZSTD_f_zstd1) {
+ MEM_writeLE32(dst, ZSTD_MAGICNUMBER);
+ pos = 4;
+ }
+ op[pos++] = frameHeaderDecriptionByte;
+ if (!singleSegment) op[pos++] = windowLogByte;
+ switch(dictIDSizeCode)
+ {
+ default: assert(0); /* impossible */
+ case 0 : break;
+ case 1 : op[pos] = (BYTE)(dictID); pos++; break;
+ case 2 : MEM_writeLE16(op+pos, (U16)dictID); pos+=2; break;
+ case 3 : MEM_writeLE32(op+pos, dictID); pos+=4; break;
+ }
+ switch(fcsCode)
+ {
+ default: assert(0); /* impossible */
+ case 0 : if (singleSegment) op[pos++] = (BYTE)(pledgedSrcSize); break;
+ case 1 : MEM_writeLE16(op+pos, (U16)(pledgedSrcSize-256)); pos+=2; break;
+ case 2 : MEM_writeLE32(op+pos, (U32)(pledgedSrcSize)); pos+=4; break;
+ case 3 : MEM_writeLE64(op+pos, (U64)(pledgedSrcSize)); pos+=8; break;
+ }
+ return pos;
+}
+
+/* ZSTD_writeLastEmptyBlock() :
+ * output an empty Block with end-of-frame mark to complete a frame
+ * @return : size of data written into `dst` (== ZSTD_blockHeaderSize (defined in zstd_internal.h))
+ * or an error code if `dstCapcity` is too small (<ZSTD_blockHeaderSize)
+ */
+size_t ZSTD_writeLastEmptyBlock(void* dst, size_t dstCapacity)
+{
+ if (dstCapacity < ZSTD_blockHeaderSize) return ERROR(dstSize_tooSmall);
+ { U32 const cBlockHeader24 = 1 /*lastBlock*/ + (((U32)bt_raw)<<1); /* 0 size */
+ MEM_writeLE24(dst, cBlockHeader24);
+ return ZSTD_blockHeaderSize;
+ }
+}
+
+size_t ZSTD_referenceExternalSequences(ZSTD_CCtx* cctx, rawSeq* seq, size_t nbSeq)
+{
+ if (cctx->stage != ZSTDcs_init)
+ return ERROR(stage_wrong);
+ if (cctx->appliedParams.ldmParams.enableLdm)
+ return ERROR(parameter_unsupported);
+ cctx->externSeqStore.seq = seq;
+ cctx->externSeqStore.size = nbSeq;
+ cctx->externSeqStore.capacity = nbSeq;
+ cctx->externSeqStore.pos = 0;
+ return 0;
+}
+
+
+static size_t ZSTD_compressContinue_internal (ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ U32 frame, U32 lastFrameChunk)
+{
+ ZSTD_matchState_t* const ms = &cctx->blockState.matchState;
+ size_t fhSize = 0;
+
+ DEBUGLOG(5, "ZSTD_compressContinue_internal, stage: %u, srcSize: %u",
+ cctx->stage, (unsigned)srcSize);
+ if (cctx->stage==ZSTDcs_created) return ERROR(stage_wrong); /* missing init (ZSTD_compressBegin) */
+
+ if (frame && (cctx->stage==ZSTDcs_init)) {
+ fhSize = ZSTD_writeFrameHeader(dst, dstCapacity, cctx->appliedParams,
+ cctx->pledgedSrcSizePlusOne-1, cctx->dictID);
+ if (ZSTD_isError(fhSize)) return fhSize;
+ dstCapacity -= fhSize;
+ dst = (char*)dst + fhSize;
+ cctx->stage = ZSTDcs_ongoing;
+ }
+
+ if (!srcSize) return fhSize; /* do not generate an empty block if no input */
+
+ if (!ZSTD_window_update(&ms->window, src, srcSize)) {
+ ms->nextToUpdate = ms->window.dictLimit;
+ }
+ if (cctx->appliedParams.ldmParams.enableLdm) {
+ ZSTD_window_update(&cctx->ldmState.window, src, srcSize);
+ }
+
+ if (!frame) {
+ /* overflow check and correction for block mode */
+ if (ZSTD_window_needOverflowCorrection(ms->window, (const char*)src + srcSize)) {
+ U32 const cycleLog = ZSTD_cycleLog(cctx->appliedParams.cParams.chainLog, cctx->appliedParams.cParams.strategy);
+ U32 const correction = ZSTD_window_correctOverflow(&ms->window, cycleLog, 1 << cctx->appliedParams.cParams.windowLog, src);
+ ZSTD_STATIC_ASSERT(ZSTD_CHAINLOG_MAX <= 30);
+ ZSTD_STATIC_ASSERT(ZSTD_WINDOWLOG_MAX_32 <= 30);
+ ZSTD_STATIC_ASSERT(ZSTD_WINDOWLOG_MAX <= 31);
+ ZSTD_reduceIndex(cctx, correction);
+ if (ms->nextToUpdate < correction) ms->nextToUpdate = 0;
+ else ms->nextToUpdate -= correction;
+ ms->loadedDictEnd = 0;
+ ms->dictMatchState = NULL;
+ }
+ }
+
+ DEBUGLOG(5, "ZSTD_compressContinue_internal (blockSize=%u)", (unsigned)cctx->blockSize);
+ { size_t const cSize = frame ?
+ ZSTD_compress_frameChunk (cctx, dst, dstCapacity, src, srcSize, lastFrameChunk) :
+ ZSTD_compressBlock_internal (cctx, dst, dstCapacity, src, srcSize);
+ if (ZSTD_isError(cSize)) return cSize;
+ cctx->consumedSrcSize += srcSize;
+ cctx->producedCSize += (cSize + fhSize);
+ assert(!(cctx->appliedParams.fParams.contentSizeFlag && cctx->pledgedSrcSizePlusOne == 0));
+ if (cctx->pledgedSrcSizePlusOne != 0) { /* control src size */
+ ZSTD_STATIC_ASSERT(ZSTD_CONTENTSIZE_UNKNOWN == (unsigned long long)-1);
+ if (cctx->consumedSrcSize+1 > cctx->pledgedSrcSizePlusOne) {
+ DEBUGLOG(4, "error : pledgedSrcSize = %u, while realSrcSize >= %u",
+ (unsigned)cctx->pledgedSrcSizePlusOne-1, (unsigned)cctx->consumedSrcSize);
+ return ERROR(srcSize_wrong);
+ }
+ }
+ return cSize + fhSize;
+ }
+}
+
+size_t ZSTD_compressContinue (ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize)
+{
+ DEBUGLOG(5, "ZSTD_compressContinue (srcSize=%u)", (unsigned)srcSize);
+ return ZSTD_compressContinue_internal(cctx, dst, dstCapacity, src, srcSize, 1 /* frame mode */, 0 /* last chunk */);
+}
+
+
+size_t ZSTD_getBlockSize(const ZSTD_CCtx* cctx)
+{
+ ZSTD_compressionParameters const cParams = cctx->appliedParams.cParams;
+ assert(!ZSTD_checkCParams(cParams));
+ return MIN (ZSTD_BLOCKSIZE_MAX, (U32)1 << cParams.windowLog);
+}
+
+size_t ZSTD_compressBlock(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+{
+ size_t const blockSizeMax = ZSTD_getBlockSize(cctx);
+ if (srcSize > blockSizeMax) return ERROR(srcSize_wrong);
+
+ return ZSTD_compressContinue_internal(cctx, dst, dstCapacity, src, srcSize, 0 /* frame mode */, 0 /* last chunk */);
+}
+
+/*! ZSTD_loadDictionaryContent() :
+ * @return : 0, or an error code
+ */
+static size_t ZSTD_loadDictionaryContent(ZSTD_matchState_t* ms,
+ ZSTD_CCtx_params const* params,
+ const void* src, size_t srcSize,
+ ZSTD_dictTableLoadMethod_e dtlm)
+{
+ const BYTE* const ip = (const BYTE*) src;
+ const BYTE* const iend = ip + srcSize;
+
+ ZSTD_window_update(&ms->window, src, srcSize);
+ ms->loadedDictEnd = params->forceWindow ? 0 : (U32)(iend - ms->window.base);
+
+ /* Assert that we the ms params match the params we're being given */
+ ZSTD_assertEqualCParams(params->cParams, ms->cParams);
+
+ if (srcSize <= HASH_READ_SIZE) return 0;
+
+ switch(params->cParams.strategy)
+ {
+ case ZSTD_fast:
+ ZSTD_fillHashTable(ms, iend, dtlm);
+ break;
+ case ZSTD_dfast:
+ ZSTD_fillDoubleHashTable(ms, iend, dtlm);
+ break;
+
+ case ZSTD_greedy:
+ case ZSTD_lazy:
+ case ZSTD_lazy2:
+ if (srcSize >= HASH_READ_SIZE)
+ ZSTD_insertAndFindFirstIndex(ms, iend-HASH_READ_SIZE);
+ break;
+
+ case ZSTD_btlazy2: /* we want the dictionary table fully sorted */
+ case ZSTD_btopt:
+ case ZSTD_btultra:
+ case ZSTD_btultra2:
+ if (srcSize >= HASH_READ_SIZE)
+ ZSTD_updateTree(ms, iend-HASH_READ_SIZE, iend);
+ break;
+
+ default:
+ assert(0); /* not possible : not a valid strategy id */
+ }
+
+ ms->nextToUpdate = (U32)(iend - ms->window.base);
+ return 0;
+}
+
+
+/* Dictionaries that assign zero probability to symbols that show up causes problems
+ when FSE encoding. Refuse dictionaries that assign zero probability to symbols
+ that we may encounter during compression.
+ NOTE: This behavior is not standard and could be improved in the future. */
+static size_t ZSTD_checkDictNCount(short* normalizedCounter, unsigned dictMaxSymbolValue, unsigned maxSymbolValue) {
+ U32 s;
+ if (dictMaxSymbolValue < maxSymbolValue) return ERROR(dictionary_corrupted);
+ for (s = 0; s <= maxSymbolValue; ++s) {
+ if (normalizedCounter[s] == 0) return ERROR(dictionary_corrupted);
+ }
+ return 0;
+}
+
+
+/* Dictionary format :
+ * See :
+ * https://github.com/facebook/zstd/blob/master/doc/zstd_compression_format.md#dictionary-format
+ */
+/*! ZSTD_loadZstdDictionary() :
+ * @return : dictID, or an error code
+ * assumptions : magic number supposed already checked
+ * dictSize supposed > 8
+ */
+static size_t ZSTD_loadZstdDictionary(ZSTD_compressedBlockState_t* bs,
+ ZSTD_matchState_t* ms,
+ ZSTD_CCtx_params const* params,
+ const void* dict, size_t dictSize,
+ ZSTD_dictTableLoadMethod_e dtlm,
+ void* workspace)
+{
+ const BYTE* dictPtr = (const BYTE*)dict;
+ const BYTE* const dictEnd = dictPtr + dictSize;
+ short offcodeNCount[MaxOff+1];
+ unsigned offcodeMaxValue = MaxOff;
+ size_t dictID;
+
+ ZSTD_STATIC_ASSERT(HUF_WORKSPACE_SIZE >= (1<<MAX(MLFSELog,LLFSELog)));
+ assert(dictSize > 8);
+ assert(MEM_readLE32(dictPtr) == ZSTD_MAGIC_DICTIONARY);
+
+ dictPtr += 4; /* skip magic number */
+ dictID = params->fParams.noDictIDFlag ? 0 : MEM_readLE32(dictPtr);
+ dictPtr += 4;
+
+ { unsigned maxSymbolValue = 255;
+ size_t const hufHeaderSize = HUF_readCTable((HUF_CElt*)bs->entropy.huf.CTable, &maxSymbolValue, dictPtr, dictEnd-dictPtr);
+ if (HUF_isError(hufHeaderSize)) return ERROR(dictionary_corrupted);
+ if (maxSymbolValue < 255) return ERROR(dictionary_corrupted);
+ dictPtr += hufHeaderSize;
+ }
+
+ { unsigned offcodeLog;
+ size_t const offcodeHeaderSize = FSE_readNCount(offcodeNCount, &offcodeMaxValue, &offcodeLog, dictPtr, dictEnd-dictPtr);
+ if (FSE_isError(offcodeHeaderSize)) return ERROR(dictionary_corrupted);
+ if (offcodeLog > OffFSELog) return ERROR(dictionary_corrupted);
+ /* Defer checking offcodeMaxValue because we need to know the size of the dictionary content */
+ /* fill all offset symbols to avoid garbage at end of table */
+ CHECK_E( FSE_buildCTable_wksp(bs->entropy.fse.offcodeCTable,
+ offcodeNCount, MaxOff, offcodeLog,
+ workspace, HUF_WORKSPACE_SIZE),
+ dictionary_corrupted);
+ dictPtr += offcodeHeaderSize;
+ }
+
+ { short matchlengthNCount[MaxML+1];
+ unsigned matchlengthMaxValue = MaxML, matchlengthLog;
+ size_t const matchlengthHeaderSize = FSE_readNCount(matchlengthNCount, &matchlengthMaxValue, &matchlengthLog, dictPtr, dictEnd-dictPtr);
+ if (FSE_isError(matchlengthHeaderSize)) return ERROR(dictionary_corrupted);
+ if (matchlengthLog > MLFSELog) return ERROR(dictionary_corrupted);
+ /* Every match length code must have non-zero probability */
+ CHECK_F( ZSTD_checkDictNCount(matchlengthNCount, matchlengthMaxValue, MaxML));
+ CHECK_E( FSE_buildCTable_wksp(bs->entropy.fse.matchlengthCTable,
+ matchlengthNCount, matchlengthMaxValue, matchlengthLog,
+ workspace, HUF_WORKSPACE_SIZE),
+ dictionary_corrupted);
+ dictPtr += matchlengthHeaderSize;
+ }
+
+ { short litlengthNCount[MaxLL+1];
+ unsigned litlengthMaxValue = MaxLL, litlengthLog;
+ size_t const litlengthHeaderSize = FSE_readNCount(litlengthNCount, &litlengthMaxValue, &litlengthLog, dictPtr, dictEnd-dictPtr);
+ if (FSE_isError(litlengthHeaderSize)) return ERROR(dictionary_corrupted);
+ if (litlengthLog > LLFSELog) return ERROR(dictionary_corrupted);
+ /* Every literal length code must have non-zero probability */
+ CHECK_F( ZSTD_checkDictNCount(litlengthNCount, litlengthMaxValue, MaxLL));
+ CHECK_E( FSE_buildCTable_wksp(bs->entropy.fse.litlengthCTable,
+ litlengthNCount, litlengthMaxValue, litlengthLog,
+ workspace, HUF_WORKSPACE_SIZE),
+ dictionary_corrupted);
+ dictPtr += litlengthHeaderSize;
+ }
+
+ if (dictPtr+12 > dictEnd) return ERROR(dictionary_corrupted);
+ bs->rep[0] = MEM_readLE32(dictPtr+0);
+ bs->rep[1] = MEM_readLE32(dictPtr+4);
+ bs->rep[2] = MEM_readLE32(dictPtr+8);
+ dictPtr += 12;
+
+ { size_t const dictContentSize = (size_t)(dictEnd - dictPtr);
+ U32 offcodeMax = MaxOff;
+ if (dictContentSize <= ((U32)-1) - 128 KB) {
+ U32 const maxOffset = (U32)dictContentSize + 128 KB; /* The maximum offset that must be supported */
+ offcodeMax = ZSTD_highbit32(maxOffset); /* Calculate minimum offset code required to represent maxOffset */
+ }
+ /* All offset values <= dictContentSize + 128 KB must be representable */
+ CHECK_F (ZSTD_checkDictNCount(offcodeNCount, offcodeMaxValue, MIN(offcodeMax, MaxOff)));
+ /* All repCodes must be <= dictContentSize and != 0*/
+ { U32 u;
+ for (u=0; u<3; u++) {
+ if (bs->rep[u] == 0) return ERROR(dictionary_corrupted);
+ if (bs->rep[u] > dictContentSize) return ERROR(dictionary_corrupted);
+ } }
+
+ bs->entropy.huf.repeatMode = HUF_repeat_valid;
+ bs->entropy.fse.offcode_repeatMode = FSE_repeat_valid;
+ bs->entropy.fse.matchlength_repeatMode = FSE_repeat_valid;
+ bs->entropy.fse.litlength_repeatMode = FSE_repeat_valid;
+ CHECK_F(ZSTD_loadDictionaryContent(ms, params, dictPtr, dictContentSize, dtlm));
+ return dictID;
+ }
+}
+
+/** ZSTD_compress_insertDictionary() :
+* @return : dictID, or an error code */
+static size_t
+ZSTD_compress_insertDictionary(ZSTD_compressedBlockState_t* bs,
+ ZSTD_matchState_t* ms,
+ const ZSTD_CCtx_params* params,
+ const void* dict, size_t dictSize,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_dictTableLoadMethod_e dtlm,
+ void* workspace)
+{
+ DEBUGLOG(4, "ZSTD_compress_insertDictionary (dictSize=%u)", (U32)dictSize);
+ if ((dict==NULL) || (dictSize<=8)) return 0;
+
+ ZSTD_reset_compressedBlockState(bs);
+
+ /* dict restricted modes */
+ if (dictContentType == ZSTD_dct_rawContent)
+ return ZSTD_loadDictionaryContent(ms, params, dict, dictSize, dtlm);
+
+ if (MEM_readLE32(dict) != ZSTD_MAGIC_DICTIONARY) {
+ if (dictContentType == ZSTD_dct_auto) {
+ DEBUGLOG(4, "raw content dictionary detected");
+ return ZSTD_loadDictionaryContent(ms, params, dict, dictSize, dtlm);
+ }
+ if (dictContentType == ZSTD_dct_fullDict)
+ return ERROR(dictionary_wrong);
+ assert(0); /* impossible */
+ }
+
+ /* dict as full zstd dictionary */
+ return ZSTD_loadZstdDictionary(bs, ms, params, dict, dictSize, dtlm, workspace);
+}
+
+/*! ZSTD_compressBegin_internal() :
+ * @return : 0, or an error code */
+static size_t ZSTD_compressBegin_internal(ZSTD_CCtx* cctx,
+ const void* dict, size_t dictSize,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_dictTableLoadMethod_e dtlm,
+ const ZSTD_CDict* cdict,
+ ZSTD_CCtx_params params, U64 pledgedSrcSize,
+ ZSTD_buffered_policy_e zbuff)
+{
+ DEBUGLOG(4, "ZSTD_compressBegin_internal: wlog=%u", params.cParams.windowLog);
+ /* params are supposed to be fully validated at this point */
+ assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
+ assert(!((dict) && (cdict))); /* either dict or cdict, not both */
+
+ if (cdict && cdict->dictContentSize>0) {
+ return ZSTD_resetCCtx_usingCDict(cctx, cdict, params, pledgedSrcSize, zbuff);
+ }
+
+ CHECK_F( ZSTD_resetCCtx_internal(cctx, params, pledgedSrcSize,
+ ZSTDcrp_continue, zbuff) );
+ {
+ size_t const dictID = ZSTD_compress_insertDictionary(
+ cctx->blockState.prevCBlock, &cctx->blockState.matchState,
+ &params, dict, dictSize, dictContentType, dtlm, cctx->entropyWorkspace);
+ if (ZSTD_isError(dictID)) return dictID;
+ assert(dictID <= (size_t)(U32)-1);
+ cctx->dictID = (U32)dictID;
+ }
+ return 0;
+}
+
+size_t ZSTD_compressBegin_advanced_internal(ZSTD_CCtx* cctx,
+ const void* dict, size_t dictSize,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_dictTableLoadMethod_e dtlm,
+ const ZSTD_CDict* cdict,
+ ZSTD_CCtx_params params,
+ unsigned long long pledgedSrcSize)
+{
+ DEBUGLOG(4, "ZSTD_compressBegin_advanced_internal: wlog=%u", params.cParams.windowLog);
+ /* compression parameters verification and optimization */
+ CHECK_F( ZSTD_checkCParams(params.cParams) );
+ return ZSTD_compressBegin_internal(cctx,
+ dict, dictSize, dictContentType, dtlm,
+ cdict,
+ params, pledgedSrcSize,
+ ZSTDb_not_buffered);
+}
+
+/*! ZSTD_compressBegin_advanced() :
+* @return : 0, or an error code */
+size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx,
+ const void* dict, size_t dictSize,
+ ZSTD_parameters params, unsigned long long pledgedSrcSize)
+{
+ ZSTD_CCtx_params const cctxParams =
+ ZSTD_assignParamsToCCtxParams(cctx->requestedParams, params);
+ return ZSTD_compressBegin_advanced_internal(cctx,
+ dict, dictSize, ZSTD_dct_auto, ZSTD_dtlm_fast,
+ NULL /*cdict*/,
+ cctxParams, pledgedSrcSize);
+}
+
+size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel)
+{
+ ZSTD_parameters const params = ZSTD_getParams(compressionLevel, ZSTD_CONTENTSIZE_UNKNOWN, dictSize);
+ ZSTD_CCtx_params const cctxParams =
+ ZSTD_assignParamsToCCtxParams(cctx->requestedParams, params);
+ DEBUGLOG(4, "ZSTD_compressBegin_usingDict (dictSize=%u)", (unsigned)dictSize);
+ return ZSTD_compressBegin_internal(cctx, dict, dictSize, ZSTD_dct_auto, ZSTD_dtlm_fast, NULL,
+ cctxParams, ZSTD_CONTENTSIZE_UNKNOWN, ZSTDb_not_buffered);
+}
+
+size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel)
+{
+ return ZSTD_compressBegin_usingDict(cctx, NULL, 0, compressionLevel);
+}
+
+
+/*! ZSTD_writeEpilogue() :
+* Ends a frame.
+* @return : nb of bytes written into dst (or an error code) */
+static size_t ZSTD_writeEpilogue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity)
+{
+ BYTE* const ostart = (BYTE*)dst;
+ BYTE* op = ostart;
+ size_t fhSize = 0;
+
+ DEBUGLOG(4, "ZSTD_writeEpilogue");
+ if (cctx->stage == ZSTDcs_created) return ERROR(stage_wrong); /* init missing */
+
+ /* special case : empty frame */
+ if (cctx->stage == ZSTDcs_init) {
+ fhSize = ZSTD_writeFrameHeader(dst, dstCapacity, cctx->appliedParams, 0, 0);
+ if (ZSTD_isError(fhSize)) return fhSize;
+ dstCapacity -= fhSize;
+ op += fhSize;
+ cctx->stage = ZSTDcs_ongoing;
+ }
+
+ if (cctx->stage != ZSTDcs_ending) {
+ /* write one last empty block, make it the "last" block */
+ U32 const cBlockHeader24 = 1 /* last block */ + (((U32)bt_raw)<<1) + 0;
+ if (dstCapacity<4) return ERROR(dstSize_tooSmall);
+ MEM_writeLE32(op, cBlockHeader24);
+ op += ZSTD_blockHeaderSize;
+ dstCapacity -= ZSTD_blockHeaderSize;
+ }
+
+ if (cctx->appliedParams.fParams.checksumFlag) {
+ U32 const checksum = (U32) XXH64_digest(&cctx->xxhState);
+ if (dstCapacity<4) return ERROR(dstSize_tooSmall);
+ DEBUGLOG(4, "ZSTD_writeEpilogue: write checksum : %08X", (unsigned)checksum);
+ MEM_writeLE32(op, checksum);
+ op += 4;
+ }
+
+ cctx->stage = ZSTDcs_created; /* return to "created but no init" status */
+ return op-ostart;
+}
+
+size_t ZSTD_compressEnd (ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize)
+{
+ size_t endResult;
+ size_t const cSize = ZSTD_compressContinue_internal(cctx,
+ dst, dstCapacity, src, srcSize,
+ 1 /* frame mode */, 1 /* last chunk */);
+ if (ZSTD_isError(cSize)) return cSize;
+ endResult = ZSTD_writeEpilogue(cctx, (char*)dst + cSize, dstCapacity-cSize);
+ if (ZSTD_isError(endResult)) return endResult;
+ assert(!(cctx->appliedParams.fParams.contentSizeFlag && cctx->pledgedSrcSizePlusOne == 0));
+ if (cctx->pledgedSrcSizePlusOne != 0) { /* control src size */
+ ZSTD_STATIC_ASSERT(ZSTD_CONTENTSIZE_UNKNOWN == (unsigned long long)-1);
+ DEBUGLOG(4, "end of frame : controlling src size");
+ if (cctx->pledgedSrcSizePlusOne != cctx->consumedSrcSize+1) {
+ DEBUGLOG(4, "error : pledgedSrcSize = %u, while realSrcSize = %u",
+ (unsigned)cctx->pledgedSrcSizePlusOne-1, (unsigned)cctx->consumedSrcSize);
+ return ERROR(srcSize_wrong);
+ } }
+ return cSize + endResult;
+}
+
+
+static size_t ZSTD_compress_internal (ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict,size_t dictSize,
+ ZSTD_parameters params)
+{
+ ZSTD_CCtx_params const cctxParams =
+ ZSTD_assignParamsToCCtxParams(cctx->requestedParams, params);
+ DEBUGLOG(4, "ZSTD_compress_internal");
+ return ZSTD_compress_advanced_internal(cctx,
+ dst, dstCapacity,
+ src, srcSize,
+ dict, dictSize,
+ cctxParams);
+}
+
+size_t ZSTD_compress_advanced (ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict,size_t dictSize,
+ ZSTD_parameters params)
+{
+ DEBUGLOG(4, "ZSTD_compress_advanced");
+ CHECK_F(ZSTD_checkCParams(params.cParams));
+ return ZSTD_compress_internal(cctx,
+ dst, dstCapacity,
+ src, srcSize,
+ dict, dictSize,
+ params);
+}
+
+/* Internal */
+size_t ZSTD_compress_advanced_internal(
+ ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict,size_t dictSize,
+ ZSTD_CCtx_params params)
+{
+ DEBUGLOG(4, "ZSTD_compress_advanced_internal (srcSize:%u)", (unsigned)srcSize);
+ CHECK_F( ZSTD_compressBegin_internal(cctx,
+ dict, dictSize, ZSTD_dct_auto, ZSTD_dtlm_fast, NULL,
+ params, srcSize, ZSTDb_not_buffered) );
+ return ZSTD_compressEnd(cctx, dst, dstCapacity, src, srcSize);
+}
+
+size_t ZSTD_compress_usingDict(ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict, size_t dictSize,
+ int compressionLevel)
+{
+ ZSTD_parameters const params = ZSTD_getParams(compressionLevel, srcSize + (!srcSize), dict ? dictSize : 0);
+ ZSTD_CCtx_params cctxParams = ZSTD_assignParamsToCCtxParams(cctx->requestedParams, params);
+ assert(params.fParams.contentSizeFlag == 1);
+ return ZSTD_compress_advanced_internal(cctx, dst, dstCapacity, src, srcSize, dict, dictSize, cctxParams);
+}
+
+size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ int compressionLevel)
+{
+ DEBUGLOG(4, "ZSTD_compressCCtx (srcSize=%u)", (unsigned)srcSize);
+ assert(cctx != NULL);
+ return ZSTD_compress_usingDict(cctx, dst, dstCapacity, src, srcSize, NULL, 0, compressionLevel);
+}
+
+size_t ZSTD_compress(void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ int compressionLevel)
+{
+ size_t result;
+ ZSTD_CCtx ctxBody;
+ ZSTD_initCCtx(&ctxBody, ZSTD_defaultCMem);
+ result = ZSTD_compressCCtx(&ctxBody, dst, dstCapacity, src, srcSize, compressionLevel);
+ ZSTD_freeCCtxContent(&ctxBody); /* can't free ctxBody itself, as it's on stack; free only heap content */
+ return result;
+}
+
+
+/* ===== Dictionary API ===== */
+
+/*! ZSTD_estimateCDictSize_advanced() :
+ * Estimate amount of memory that will be needed to create a dictionary with following arguments */
+size_t ZSTD_estimateCDictSize_advanced(
+ size_t dictSize, ZSTD_compressionParameters cParams,
+ ZSTD_dictLoadMethod_e dictLoadMethod)
+{
+ DEBUGLOG(5, "sizeof(ZSTD_CDict) : %u", (unsigned)sizeof(ZSTD_CDict));
+ return sizeof(ZSTD_CDict) + HUF_WORKSPACE_SIZE + ZSTD_sizeof_matchState(&cParams, /* forCCtx */ 0)
+ + (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize);
+}
+
+size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel)
+{
+ ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, 0, dictSize);
+ return ZSTD_estimateCDictSize_advanced(dictSize, cParams, ZSTD_dlm_byCopy);
+}
+
+size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict)
+{
+ if (cdict==NULL) return 0; /* support sizeof on NULL */
+ DEBUGLOG(5, "sizeof(*cdict) : %u", (unsigned)sizeof(*cdict));
+ return cdict->workspaceSize + (cdict->dictBuffer ? cdict->dictContentSize : 0) + sizeof(*cdict);
+}
+
+static size_t ZSTD_initCDict_internal(
+ ZSTD_CDict* cdict,
+ const void* dictBuffer, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_compressionParameters cParams)
+{
+ DEBUGLOG(3, "ZSTD_initCDict_internal (dictContentType:%u)", (unsigned)dictContentType);
+ assert(!ZSTD_checkCParams(cParams));
+ cdict->matchState.cParams = cParams;
+ if ((dictLoadMethod == ZSTD_dlm_byRef) || (!dictBuffer) || (!dictSize)) {
+ cdict->dictBuffer = NULL;
+ cdict->dictContent = dictBuffer;
+ } else {
+ void* const internalBuffer = ZSTD_malloc(dictSize, cdict->customMem);
+ cdict->dictBuffer = internalBuffer;
+ cdict->dictContent = internalBuffer;
+ if (!internalBuffer) return ERROR(memory_allocation);
+ memcpy(internalBuffer, dictBuffer, dictSize);
+ }
+ cdict->dictContentSize = dictSize;
+
+ /* Reset the state to no dictionary */
+ ZSTD_reset_compressedBlockState(&cdict->cBlockState);
+ { void* const end = ZSTD_reset_matchState(
+ &cdict->matchState,
+ (U32*)cdict->workspace + HUF_WORKSPACE_SIZE_U32,
+ &cParams, ZSTDcrp_continue, /* forCCtx */ 0);
+ assert(end == (char*)cdict->workspace + cdict->workspaceSize);
+ (void)end;
+ }
+ /* (Maybe) load the dictionary
+ * Skips loading the dictionary if it is <= 8 bytes.
+ */
+ { ZSTD_CCtx_params params;
+ memset(&params, 0, sizeof(params));
+ params.compressionLevel = ZSTD_CLEVEL_DEFAULT;
+ params.fParams.contentSizeFlag = 1;
+ params.cParams = cParams;
+ { size_t const dictID = ZSTD_compress_insertDictionary(
+ &cdict->cBlockState, &cdict->matchState, &params,
+ cdict->dictContent, cdict->dictContentSize,
+ dictContentType, ZSTD_dtlm_full, cdict->workspace);
+ if (ZSTD_isError(dictID)) return dictID;
+ assert(dictID <= (size_t)(U32)-1);
+ cdict->dictID = (U32)dictID;
+ }
+ }
+
+ return 0;
+}
+
+ZSTD_CDict* ZSTD_createCDict_advanced(const void* dictBuffer, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_compressionParameters cParams, ZSTD_customMem customMem)
+{
+ DEBUGLOG(3, "ZSTD_createCDict_advanced, mode %u", (unsigned)dictContentType);
+ if (!customMem.customAlloc ^ !customMem.customFree) return NULL;
+
+ { ZSTD_CDict* const cdict = (ZSTD_CDict*)ZSTD_malloc(sizeof(ZSTD_CDict), customMem);
+ size_t const workspaceSize = HUF_WORKSPACE_SIZE + ZSTD_sizeof_matchState(&cParams, /* forCCtx */ 0);
+ void* const workspace = ZSTD_malloc(workspaceSize, customMem);
+
+ if (!cdict || !workspace) {
+ ZSTD_free(cdict, customMem);
+ ZSTD_free(workspace, customMem);
+ return NULL;
+ }
+ cdict->customMem = customMem;
+ cdict->workspace = workspace;
+ cdict->workspaceSize = workspaceSize;
+ if (ZSTD_isError( ZSTD_initCDict_internal(cdict,
+ dictBuffer, dictSize,
+ dictLoadMethod, dictContentType,
+ cParams) )) {
+ ZSTD_freeCDict(cdict);
+ return NULL;
+ }
+
+ return cdict;
+ }
+}
+
+ZSTD_CDict* ZSTD_createCDict(const void* dict, size_t dictSize, int compressionLevel)
+{
+ ZSTD_compressionParameters cParams = ZSTD_getCParams(compressionLevel, 0, dictSize);
+ return ZSTD_createCDict_advanced(dict, dictSize,
+ ZSTD_dlm_byCopy, ZSTD_dct_auto,
+ cParams, ZSTD_defaultCMem);
+}
+
+ZSTD_CDict* ZSTD_createCDict_byReference(const void* dict, size_t dictSize, int compressionLevel)
+{
+ ZSTD_compressionParameters cParams = ZSTD_getCParams(compressionLevel, 0, dictSize);
+ return ZSTD_createCDict_advanced(dict, dictSize,
+ ZSTD_dlm_byRef, ZSTD_dct_auto,
+ cParams, ZSTD_defaultCMem);
+}
+
+size_t ZSTD_freeCDict(ZSTD_CDict* cdict)
+{
+ if (cdict==NULL) return 0; /* support free on NULL */
+ { ZSTD_customMem const cMem = cdict->customMem;
+ ZSTD_free(cdict->workspace, cMem);
+ ZSTD_free(cdict->dictBuffer, cMem);
+ ZSTD_free(cdict, cMem);
+ return 0;
+ }
+}
+
+/*! ZSTD_initStaticCDict_advanced() :
+ * Generate a digested dictionary in provided memory area.
+ * workspace: The memory area to emplace the dictionary into.
+ * Provided pointer must 8-bytes aligned.
+ * It must outlive dictionary usage.
+ * workspaceSize: Use ZSTD_estimateCDictSize()
+ * to determine how large workspace must be.
+ * cParams : use ZSTD_getCParams() to transform a compression level
+ * into its relevants cParams.
+ * @return : pointer to ZSTD_CDict*, or NULL if error (size too small)
+ * Note : there is no corresponding "free" function.
+ * Since workspace was allocated externally, it must be freed externally.
+ */
+const ZSTD_CDict* ZSTD_initStaticCDict(
+ void* workspace, size_t workspaceSize,
+ const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_compressionParameters cParams)
+{
+ size_t const matchStateSize = ZSTD_sizeof_matchState(&cParams, /* forCCtx */ 0);
+ size_t const neededSize = sizeof(ZSTD_CDict) + (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize)
+ + HUF_WORKSPACE_SIZE + matchStateSize;
+ ZSTD_CDict* const cdict = (ZSTD_CDict*) workspace;
+ void* ptr;
+ if ((size_t)workspace & 7) return NULL; /* 8-aligned */
+ DEBUGLOG(4, "(workspaceSize < neededSize) : (%u < %u) => %u",
+ (unsigned)workspaceSize, (unsigned)neededSize, (unsigned)(workspaceSize < neededSize));
+ if (workspaceSize < neededSize) return NULL;
+
+ if (dictLoadMethod == ZSTD_dlm_byCopy) {
+ memcpy(cdict+1, dict, dictSize);
+ dict = cdict+1;
+ ptr = (char*)workspace + sizeof(ZSTD_CDict) + dictSize;
+ } else {
+ ptr = cdict+1;
+ }
+ cdict->workspace = ptr;
+ cdict->workspaceSize = HUF_WORKSPACE_SIZE + matchStateSize;
+
+ if (ZSTD_isError( ZSTD_initCDict_internal(cdict,
+ dict, dictSize,
+ ZSTD_dlm_byRef, dictContentType,
+ cParams) ))
+ return NULL;
+
+ return cdict;
+}
+
+ZSTD_compressionParameters ZSTD_getCParamsFromCDict(const ZSTD_CDict* cdict)
+{
+ assert(cdict != NULL);
+ return cdict->matchState.cParams;
+}
+
+/* ZSTD_compressBegin_usingCDict_advanced() :
+ * cdict must be != NULL */
+size_t ZSTD_compressBegin_usingCDict_advanced(
+ ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict,
+ ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize)
+{
+ DEBUGLOG(4, "ZSTD_compressBegin_usingCDict_advanced");
+ if (cdict==NULL) return ERROR(dictionary_wrong);
+ { ZSTD_CCtx_params params = cctx->requestedParams;
+ params.cParams = ZSTD_getCParamsFromCDict(cdict);
+ /* Increase window log to fit the entire dictionary and source if the
+ * source size is known. Limit the increase to 19, which is the
+ * window log for compression level 1 with the largest source size.
+ */
+ if (pledgedSrcSize != ZSTD_CONTENTSIZE_UNKNOWN) {
+ U32 const limitedSrcSize = (U32)MIN(pledgedSrcSize, 1U << 19);
+ U32 const limitedSrcLog = limitedSrcSize > 1 ? ZSTD_highbit32(limitedSrcSize - 1) + 1 : 1;
+ params.cParams.windowLog = MAX(params.cParams.windowLog, limitedSrcLog);
+ }
+ params.fParams = fParams;
+ return ZSTD_compressBegin_internal(cctx,
+ NULL, 0, ZSTD_dct_auto, ZSTD_dtlm_fast,
+ cdict,
+ params, pledgedSrcSize,
+ ZSTDb_not_buffered);
+ }
+}
+
+/* ZSTD_compressBegin_usingCDict() :
+ * pledgedSrcSize=0 means "unknown"
+ * if pledgedSrcSize>0, it will enable contentSizeFlag */
+size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict)
+{
+ ZSTD_frameParameters const fParams = { 0 /*content*/, 0 /*checksum*/, 0 /*noDictID*/ };
+ DEBUGLOG(4, "ZSTD_compressBegin_usingCDict : dictIDFlag == %u", !fParams.noDictIDFlag);
+ return ZSTD_compressBegin_usingCDict_advanced(cctx, cdict, fParams, ZSTD_CONTENTSIZE_UNKNOWN);
+}
+
+size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_CDict* cdict, ZSTD_frameParameters fParams)
+{
+ CHECK_F (ZSTD_compressBegin_usingCDict_advanced(cctx, cdict, fParams, srcSize)); /* will check if cdict != NULL */
+ return ZSTD_compressEnd(cctx, dst, dstCapacity, src, srcSize);
+}
+
+/*! ZSTD_compress_usingCDict() :
+ * Compression using a digested Dictionary.
+ * Faster startup than ZSTD_compress_usingDict(), recommended when same dictionary is used multiple times.
+ * Note that compression parameters are decided at CDict creation time
+ * while frame parameters are hardcoded */
+size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_CDict* cdict)
+{
+ ZSTD_frameParameters const fParams = { 1 /*content*/, 0 /*checksum*/, 0 /*noDictID*/ };
+ return ZSTD_compress_usingCDict_advanced(cctx, dst, dstCapacity, src, srcSize, cdict, fParams);
+}
+
+
+
+/* ******************************************************************
+* Streaming
+********************************************************************/
+
+ZSTD_CStream* ZSTD_createCStream(void)
+{
+ DEBUGLOG(3, "ZSTD_createCStream");
+ return ZSTD_createCStream_advanced(ZSTD_defaultCMem);
+}
+
+ZSTD_CStream* ZSTD_initStaticCStream(void *workspace, size_t workspaceSize)
+{
+ return ZSTD_initStaticCCtx(workspace, workspaceSize);
+}
+
+ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem)
+{ /* CStream and CCtx are now same object */
+ return ZSTD_createCCtx_advanced(customMem);
+}
+
+size_t ZSTD_freeCStream(ZSTD_CStream* zcs)
+{
+ return ZSTD_freeCCtx(zcs); /* same object */
+}
+
+
+
+/*====== Initialization ======*/
+
+size_t ZSTD_CStreamInSize(void) { return ZSTD_BLOCKSIZE_MAX; }
+
+size_t ZSTD_CStreamOutSize(void)
+{
+ return ZSTD_compressBound(ZSTD_BLOCKSIZE_MAX) + ZSTD_blockHeaderSize + 4 /* 32-bits hash */ ;
+}
+
+static size_t ZSTD_resetCStream_internal(ZSTD_CStream* cctx,
+ const void* const dict, size_t const dictSize, ZSTD_dictContentType_e const dictContentType,
+ const ZSTD_CDict* const cdict,
+ ZSTD_CCtx_params params, unsigned long long const pledgedSrcSize)
+{
+ DEBUGLOG(4, "ZSTD_resetCStream_internal");
+ /* Finalize the compression parameters */
+ params.cParams = ZSTD_getCParamsFromCCtxParams(&params, pledgedSrcSize, dictSize);
+ /* params are supposed to be fully validated at this point */
+ assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
+ assert(!((dict) && (cdict))); /* either dict or cdict, not both */
+
+ CHECK_F( ZSTD_compressBegin_internal(cctx,
+ dict, dictSize, dictContentType, ZSTD_dtlm_fast,
+ cdict,
+ params, pledgedSrcSize,
+ ZSTDb_buffered) );
+
+ cctx->inToCompress = 0;
+ cctx->inBuffPos = 0;
+ cctx->inBuffTarget = cctx->blockSize
+ + (cctx->blockSize == pledgedSrcSize); /* for small input: avoid automatic flush on reaching end of block, since it would require to add a 3-bytes null block to end frame */
+ cctx->outBuffContentSize = cctx->outBuffFlushedSize = 0;
+ cctx->streamStage = zcss_load;
+ cctx->frameEnded = 0;
+ return 0; /* ready to go */
+}
+
+/* ZSTD_resetCStream():
+ * pledgedSrcSize == 0 means "unknown" */
+size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize)
+{
+ ZSTD_CCtx_params params = zcs->requestedParams;
+ DEBUGLOG(4, "ZSTD_resetCStream: pledgedSrcSize = %u", (unsigned)pledgedSrcSize);
+ if (pledgedSrcSize==0) pledgedSrcSize = ZSTD_CONTENTSIZE_UNKNOWN;
+ params.fParams.contentSizeFlag = 1;
+ return ZSTD_resetCStream_internal(zcs, NULL, 0, ZSTD_dct_auto, zcs->cdict, params, pledgedSrcSize);
+}
+
+/*! ZSTD_initCStream_internal() :
+ * Note : for lib/compress only. Used by zstdmt_compress.c.
+ * Assumption 1 : params are valid
+ * Assumption 2 : either dict, or cdict, is defined, not both */
+size_t ZSTD_initCStream_internal(ZSTD_CStream* zcs,
+ const void* dict, size_t dictSize, const ZSTD_CDict* cdict,
+ ZSTD_CCtx_params params, unsigned long long pledgedSrcSize)
+{
+ DEBUGLOG(4, "ZSTD_initCStream_internal");
+ params.cParams = ZSTD_getCParamsFromCCtxParams(&params, pledgedSrcSize, dictSize);
+ assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
+ assert(!((dict) && (cdict))); /* either dict or cdict, not both */
+
+ if (dict && dictSize >= 8) {
+ DEBUGLOG(4, "loading dictionary of size %u", (unsigned)dictSize);
+ if (zcs->staticSize) { /* static CCtx : never uses malloc */
+ /* incompatible with internal cdict creation */
+ return ERROR(memory_allocation);
+ }
+ ZSTD_freeCDict(zcs->cdictLocal);
+ zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize,
+ ZSTD_dlm_byCopy, ZSTD_dct_auto,
+ params.cParams, zcs->customMem);
+ zcs->cdict = zcs->cdictLocal;
+ if (zcs->cdictLocal == NULL) return ERROR(memory_allocation);
+ } else {
+ if (cdict) {
+ params.cParams = ZSTD_getCParamsFromCDict(cdict); /* cParams are enforced from cdict; it includes windowLog */
+ }
+ ZSTD_freeCDict(zcs->cdictLocal);
+ zcs->cdictLocal = NULL;
+ zcs->cdict = cdict;
+ }
+
+ return ZSTD_resetCStream_internal(zcs, NULL, 0, ZSTD_dct_auto, zcs->cdict, params, pledgedSrcSize);
+}
+
+/* ZSTD_initCStream_usingCDict_advanced() :
+ * same as ZSTD_initCStream_usingCDict(), with control over frame parameters */
+size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs,
+ const ZSTD_CDict* cdict,
+ ZSTD_frameParameters fParams,
+ unsigned long long pledgedSrcSize)
+{
+ DEBUGLOG(4, "ZSTD_initCStream_usingCDict_advanced");
+ if (!cdict) return ERROR(dictionary_wrong); /* cannot handle NULL cdict (does not know what to do) */
+ { ZSTD_CCtx_params params = zcs->requestedParams;
+ params.cParams = ZSTD_getCParamsFromCDict(cdict);
+ params.fParams = fParams;
+ return ZSTD_initCStream_internal(zcs,
+ NULL, 0, cdict,
+ params, pledgedSrcSize);
+ }
+}
+
+/* note : cdict must outlive compression session */
+size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict)
+{
+ ZSTD_frameParameters const fParams = { 0 /* contentSizeFlag */, 0 /* checksum */, 0 /* hideDictID */ };
+ DEBUGLOG(4, "ZSTD_initCStream_usingCDict");
+ return ZSTD_initCStream_usingCDict_advanced(zcs, cdict, fParams, ZSTD_CONTENTSIZE_UNKNOWN); /* note : will check that cdict != NULL */
+}
+
+
+/* ZSTD_initCStream_advanced() :
+ * pledgedSrcSize must be exact.
+ * if srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN.
+ * dict is loaded with default parameters ZSTD_dm_auto and ZSTD_dlm_byCopy. */
+size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs,
+ const void* dict, size_t dictSize,
+ ZSTD_parameters params, unsigned long long pledgedSrcSize)
+{
+ DEBUGLOG(4, "ZSTD_initCStream_advanced: pledgedSrcSize=%u, flag=%u",
+ (unsigned)pledgedSrcSize, params.fParams.contentSizeFlag);
+ CHECK_F( ZSTD_checkCParams(params.cParams) );
+ if ((pledgedSrcSize==0) && (params.fParams.contentSizeFlag==0)) pledgedSrcSize = ZSTD_CONTENTSIZE_UNKNOWN; /* for compatibility with older programs relying on this behavior. Users should now specify ZSTD_CONTENTSIZE_UNKNOWN. This line will be removed in the future. */
+ zcs->requestedParams = ZSTD_assignParamsToCCtxParams(zcs->requestedParams, params);
+ return ZSTD_initCStream_internal(zcs, dict, dictSize, NULL /*cdict*/, zcs->requestedParams, pledgedSrcSize);
+}
+
+size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel)
+{
+ ZSTD_CCtxParams_init(&zcs->requestedParams, compressionLevel);
+ return ZSTD_initCStream_internal(zcs, dict, dictSize, NULL, zcs->requestedParams, ZSTD_CONTENTSIZE_UNKNOWN);
+}
+
+size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pss)
+{
+ U64 const pledgedSrcSize = (pss==0) ? ZSTD_CONTENTSIZE_UNKNOWN : pss; /* temporary : 0 interpreted as "unknown" during transition period. Users willing to specify "unknown" **must** use ZSTD_CONTENTSIZE_UNKNOWN. `0` will be interpreted as "empty" in the future */
+ ZSTD_CCtxParams_init(&zcs->requestedParams, compressionLevel);
+ return ZSTD_initCStream_internal(zcs, NULL, 0, NULL, zcs->requestedParams, pledgedSrcSize);
+}
+
+size_t ZSTD_initCStream(ZSTD_CStream* zcs, int compressionLevel)
+{
+ DEBUGLOG(4, "ZSTD_initCStream");
+ return ZSTD_initCStream_srcSize(zcs, compressionLevel, ZSTD_CONTENTSIZE_UNKNOWN);
+}
+
+/*====== Compression ======*/
+
+static size_t ZSTD_nextInputSizeHint(const ZSTD_CCtx* cctx)
+{
+ size_t hintInSize = cctx->inBuffTarget - cctx->inBuffPos;
+ if (hintInSize==0) hintInSize = cctx->blockSize;
+ return hintInSize;
+}
+
+static size_t ZSTD_limitCopy(void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize)
+{
+ size_t const length = MIN(dstCapacity, srcSize);
+ if (length) memcpy(dst, src, length);
+ return length;
+}
+
+/** ZSTD_compressStream_generic():
+ * internal function for all *compressStream*() variants
+ * non-static, because can be called from zstdmt_compress.c
+ * @return : hint size for next input */
+size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective const flushMode)
+{
+ const char* const istart = (const char*)input->src;
+ const char* const iend = istart + input->size;
+ const char* ip = istart + input->pos;
+ char* const ostart = (char*)output->dst;
+ char* const oend = ostart + output->size;
+ char* op = ostart + output->pos;
+ U32 someMoreWork = 1;
+
+ /* check expectations */
+ DEBUGLOG(5, "ZSTD_compressStream_generic, flush=%u", (unsigned)flushMode);
+ assert(zcs->inBuff != NULL);
+ assert(zcs->inBuffSize > 0);
+ assert(zcs->outBuff != NULL);
+ assert(zcs->outBuffSize > 0);
+ assert(output->pos <= output->size);
+ assert(input->pos <= input->size);
+
+ while (someMoreWork) {
+ switch(zcs->streamStage)
+ {
+ case zcss_init:
+ /* call ZSTD_initCStream() first ! */
+ return ERROR(init_missing);
+
+ case zcss_load:
+ if ( (flushMode == ZSTD_e_end)
+ && ((size_t)(oend-op) >= ZSTD_compressBound(iend-ip)) /* enough dstCapacity */
+ && (zcs->inBuffPos == 0) ) {
+ /* shortcut to compression pass directly into output buffer */
+ size_t const cSize = ZSTD_compressEnd(zcs,
+ op, oend-op, ip, iend-ip);
+ DEBUGLOG(4, "ZSTD_compressEnd : cSize=%u", (unsigned)cSize);
+ if (ZSTD_isError(cSize)) return cSize;
+ ip = iend;
+ op += cSize;
+ zcs->frameEnded = 1;
+ ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
+ someMoreWork = 0; break;
+ }
+ /* complete loading into inBuffer */
+ { size_t const toLoad = zcs->inBuffTarget - zcs->inBuffPos;
+ size_t const loaded = ZSTD_limitCopy(
+ zcs->inBuff + zcs->inBuffPos, toLoad,
+ ip, iend-ip);
+ zcs->inBuffPos += loaded;
+ ip += loaded;
+ if ( (flushMode == ZSTD_e_continue)
+ && (zcs->inBuffPos < zcs->inBuffTarget) ) {
+ /* not enough input to fill full block : stop here */
+ someMoreWork = 0; break;
+ }
+ if ( (flushMode == ZSTD_e_flush)
+ && (zcs->inBuffPos == zcs->inToCompress) ) {
+ /* empty */
+ someMoreWork = 0; break;
+ }
+ }
+ /* compress current block (note : this stage cannot be stopped in the middle) */
+ DEBUGLOG(5, "stream compression stage (flushMode==%u)", flushMode);
+ { void* cDst;
+ size_t cSize;
+ size_t const iSize = zcs->inBuffPos - zcs->inToCompress;
+ size_t oSize = oend-op;
+ unsigned const lastBlock = (flushMode == ZSTD_e_end) && (ip==iend);
+ if (oSize >= ZSTD_compressBound(iSize))
+ cDst = op; /* compress into output buffer, to skip flush stage */
+ else
+ cDst = zcs->outBuff, oSize = zcs->outBuffSize;
+ cSize = lastBlock ?
+ ZSTD_compressEnd(zcs, cDst, oSize,
+ zcs->inBuff + zcs->inToCompress, iSize) :
+ ZSTD_compressContinue(zcs, cDst, oSize,
+ zcs->inBuff + zcs->inToCompress, iSize);
+ if (ZSTD_isError(cSize)) return cSize;
+ zcs->frameEnded = lastBlock;
+ /* prepare next block */
+ zcs->inBuffTarget = zcs->inBuffPos + zcs->blockSize;
+ if (zcs->inBuffTarget > zcs->inBuffSize)
+ zcs->inBuffPos = 0, zcs->inBuffTarget = zcs->blockSize;
+ DEBUGLOG(5, "inBuffTarget:%u / inBuffSize:%u",
+ (unsigned)zcs->inBuffTarget, (unsigned)zcs->inBuffSize);
+ if (!lastBlock)
+ assert(zcs->inBuffTarget <= zcs->inBuffSize);
+ zcs->inToCompress = zcs->inBuffPos;
+ if (cDst == op) { /* no need to flush */
+ op += cSize;
+ if (zcs->frameEnded) {
+ DEBUGLOG(5, "Frame completed directly in outBuffer");
+ someMoreWork = 0;
+ ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
+ }
+ break;
+ }
+ zcs->outBuffContentSize = cSize;
+ zcs->outBuffFlushedSize = 0;
+ zcs->streamStage = zcss_flush; /* pass-through to flush stage */
+ }
+ /* fall-through */
+ case zcss_flush:
+ DEBUGLOG(5, "flush stage");
+ { size_t const toFlush = zcs->outBuffContentSize - zcs->outBuffFlushedSize;
+ size_t const flushed = ZSTD_limitCopy(op, oend-op,
+ zcs->outBuff + zcs->outBuffFlushedSize, toFlush);
+ DEBUGLOG(5, "toFlush: %u into %u ==> flushed: %u",
+ (unsigned)toFlush, (unsigned)(oend-op), (unsigned)flushed);
+ op += flushed;
+ zcs->outBuffFlushedSize += flushed;
+ if (toFlush!=flushed) {
+ /* flush not fully completed, presumably because dst is too small */
+ assert(op==oend);
+ someMoreWork = 0;
+ break;
+ }
+ zcs->outBuffContentSize = zcs->outBuffFlushedSize = 0;
+ if (zcs->frameEnded) {
+ DEBUGLOG(5, "Frame completed on flush");
+ someMoreWork = 0;
+ ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only);
+ break;
+ }
+ zcs->streamStage = zcss_load;
+ break;
+ }
+
+ default: /* impossible */
+ assert(0);
+ }
+ }
+
+ input->pos = ip - istart;
+ output->pos = op - ostart;
+ if (zcs->frameEnded) return 0;
+ return ZSTD_nextInputSizeHint(zcs);
+}
+
+static size_t ZSTD_nextInputSizeHint_MTorST(const ZSTD_CCtx* cctx)
+{
+#ifdef ZSTD_MULTITHREAD
+ if (cctx->appliedParams.nbWorkers >= 1) {
+ assert(cctx->mtctx != NULL);
+ return ZSTDMT_nextInputSizeHint(cctx->mtctx);
+ }
+#endif
+ return ZSTD_nextInputSizeHint(cctx);
+
+}
+
+size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input)
+{
+ CHECK_F( ZSTD_compressStream2(zcs, output, input, ZSTD_e_continue) );
+ return ZSTD_nextInputSizeHint_MTorST(zcs);
+}
+
+
+size_t ZSTD_compressStream2( ZSTD_CCtx* cctx,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective endOp)
+{
+ DEBUGLOG(5, "ZSTD_compressStream2, endOp=%u ", (unsigned)endOp);
+ /* check conditions */
+ if (output->pos > output->size) return ERROR(GENERIC);
+ if (input->pos > input->size) return ERROR(GENERIC);
+ assert(cctx!=NULL);
+
+ /* transparent initialization stage */
+ if (cctx->streamStage == zcss_init) {
+ ZSTD_CCtx_params params = cctx->requestedParams;
+ ZSTD_prefixDict const prefixDict = cctx->prefixDict;
+ memset(&cctx->prefixDict, 0, sizeof(cctx->prefixDict)); /* single usage */
+ assert(prefixDict.dict==NULL || cctx->cdict==NULL); /* only one can be set */
+ DEBUGLOG(4, "ZSTD_compressStream2 : transparent init stage");
+ if (endOp == ZSTD_e_end) cctx->pledgedSrcSizePlusOne = input->size + 1; /* auto-fix pledgedSrcSize */
+ params.cParams = ZSTD_getCParamsFromCCtxParams(
+ &cctx->requestedParams, cctx->pledgedSrcSizePlusOne-1, 0 /*dictSize*/);
+
+
+#ifdef ZSTD_MULTITHREAD
+ if ((cctx->pledgedSrcSizePlusOne-1) <= ZSTDMT_JOBSIZE_MIN) {
+ params.nbWorkers = 0; /* do not invoke multi-threading when src size is too small */
+ }
+ if (params.nbWorkers > 0) {
+ /* mt context creation */
+ if (cctx->mtctx == NULL) {
+ DEBUGLOG(4, "ZSTD_compressStream2: creating new mtctx for nbWorkers=%u",
+ params.nbWorkers);
+ cctx->mtctx = ZSTDMT_createCCtx_advanced(params.nbWorkers, cctx->customMem);
+ if (cctx->mtctx == NULL) return ERROR(memory_allocation);
+ }
+ /* mt compression */
+ DEBUGLOG(4, "call ZSTDMT_initCStream_internal as nbWorkers=%u", params.nbWorkers);
+ CHECK_F( ZSTDMT_initCStream_internal(
+ cctx->mtctx,
+ prefixDict.dict, prefixDict.dictSize, ZSTD_dct_rawContent,
+ cctx->cdict, params, cctx->pledgedSrcSizePlusOne-1) );
+ cctx->streamStage = zcss_load;
+ cctx->appliedParams.nbWorkers = params.nbWorkers;
+ } else
+#endif
+ { CHECK_F( ZSTD_resetCStream_internal(cctx,
+ prefixDict.dict, prefixDict.dictSize, prefixDict.dictContentType,
+ cctx->cdict,
+ params, cctx->pledgedSrcSizePlusOne-1) );
+ assert(cctx->streamStage == zcss_load);
+ assert(cctx->appliedParams.nbWorkers == 0);
+ } }
+ /* end of transparent initialization stage */
+
+ /* compression stage */
+#ifdef ZSTD_MULTITHREAD
+ if (cctx->appliedParams.nbWorkers > 0) {
+ if (cctx->cParamsChanged) {
+ ZSTDMT_updateCParams_whileCompressing(cctx->mtctx, &cctx->requestedParams);
+ cctx->cParamsChanged = 0;
+ }
+ { size_t const flushMin = ZSTDMT_compressStream_generic(cctx->mtctx, output, input, endOp);
+ if ( ZSTD_isError(flushMin)
+ || (endOp == ZSTD_e_end && flushMin == 0) ) { /* compression completed */
+ ZSTD_CCtx_reset(cctx, ZSTD_reset_session_only);
+ }
+ DEBUGLOG(5, "completed ZSTD_compressStream2 delegating to ZSTDMT_compressStream_generic");
+ return flushMin;
+ } }
+#endif
+ CHECK_F( ZSTD_compressStream_generic(cctx, output, input, endOp) );
+ DEBUGLOG(5, "completed ZSTD_compressStream2");
+ return cctx->outBuffContentSize - cctx->outBuffFlushedSize; /* remaining to flush */
+}
+
+size_t ZSTD_compressStream2_simpleArgs (
+ ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity, size_t* dstPos,
+ const void* src, size_t srcSize, size_t* srcPos,
+ ZSTD_EndDirective endOp)
+{
+ ZSTD_outBuffer output = { dst, dstCapacity, *dstPos };
+ ZSTD_inBuffer input = { src, srcSize, *srcPos };
+ /* ZSTD_compressStream2() will check validity of dstPos and srcPos */
+ size_t const cErr = ZSTD_compressStream2(cctx, &output, &input, endOp);
+ *dstPos = output.pos;
+ *srcPos = input.pos;
+ return cErr;
+}
+
+size_t ZSTD_compress2(ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize)
+{
+ ZSTD_CCtx_reset(cctx, ZSTD_reset_session_only);
+ { size_t oPos = 0;
+ size_t iPos = 0;
+ size_t const result = ZSTD_compressStream2_simpleArgs(cctx,
+ dst, dstCapacity, &oPos,
+ src, srcSize, &iPos,
+ ZSTD_e_end);
+ if (ZSTD_isError(result)) return result;
+ if (result != 0) { /* compression not completed, due to lack of output space */
+ assert(oPos == dstCapacity);
+ return ERROR(dstSize_tooSmall);
+ }
+ assert(iPos == srcSize); /* all input is expected consumed */
+ return oPos;
+ }
+}
+
+/*====== Finalize ======*/
+
+/*! ZSTD_flushStream() :
+ * @return : amount of data remaining to flush */
+size_t ZSTD_flushStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output)
+{
+ ZSTD_inBuffer input = { NULL, 0, 0 };
+ return ZSTD_compressStream2(zcs, output, &input, ZSTD_e_flush);
+}
+
+
+size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output)
+{
+ ZSTD_inBuffer input = { NULL, 0, 0 };
+ size_t const remainingToFlush = ZSTD_compressStream2(zcs, output, &input, ZSTD_e_end);
+ CHECK_F( remainingToFlush );
+ if (zcs->appliedParams.nbWorkers > 0) return remainingToFlush; /* minimal estimation */
+ /* single thread mode : attempt to calculate remaining to flush more precisely */
+ { size_t const lastBlockSize = zcs->frameEnded ? 0 : ZSTD_BLOCKHEADERSIZE;
+ size_t const checksumSize = zcs->frameEnded ? 0 : zcs->appliedParams.fParams.checksumFlag * 4;
+ size_t const toFlush = remainingToFlush + lastBlockSize + checksumSize;
+ DEBUGLOG(4, "ZSTD_endStream : remaining to flush : %u", (unsigned)toFlush);
+ return toFlush;
+ }
+}
+
+
+/*-===== Pre-defined compression levels =====-*/
+
+#define ZSTD_MAX_CLEVEL 22
+int ZSTD_maxCLevel(void) { return ZSTD_MAX_CLEVEL; }
+int ZSTD_minCLevel(void) { return (int)-ZSTD_TARGETLENGTH_MAX; }
+
+static const ZSTD_compressionParameters ZSTD_defaultCParameters[4][ZSTD_MAX_CLEVEL+1] = {
+{ /* "default" - guarantees a monotonically increasing memory budget */
+ /* W, C, H, S, L, TL, strat */
+ { 19, 12, 13, 1, 6, 1, ZSTD_fast }, /* base for negative levels */
+ { 19, 13, 14, 1, 7, 0, ZSTD_fast }, /* level 1 */
+ { 20, 15, 16, 1, 6, 0, ZSTD_fast }, /* level 2 */
+ { 21, 16, 17, 1, 5, 1, ZSTD_dfast }, /* level 3 */
+ { 21, 18, 18, 1, 5, 1, ZSTD_dfast }, /* level 4 */
+ { 21, 18, 19, 2, 5, 2, ZSTD_greedy }, /* level 5 */
+ { 21, 19, 19, 3, 5, 4, ZSTD_greedy }, /* level 6 */
+ { 21, 19, 19, 3, 5, 8, ZSTD_lazy }, /* level 7 */
+ { 21, 19, 19, 3, 5, 16, ZSTD_lazy2 }, /* level 8 */
+ { 21, 19, 20, 4, 5, 16, ZSTD_lazy2 }, /* level 9 */
+ { 22, 20, 21, 4, 5, 16, ZSTD_lazy2 }, /* level 10 */
+ { 22, 21, 22, 4, 5, 16, ZSTD_lazy2 }, /* level 11 */
+ { 22, 21, 22, 5, 5, 16, ZSTD_lazy2 }, /* level 12 */
+ { 22, 21, 22, 5, 5, 32, ZSTD_btlazy2 }, /* level 13 */
+ { 22, 22, 23, 5, 5, 32, ZSTD_btlazy2 }, /* level 14 */
+ { 22, 23, 23, 6, 5, 32, ZSTD_btlazy2 }, /* level 15 */
+ { 22, 22, 22, 5, 5, 48, ZSTD_btopt }, /* level 16 */
+ { 23, 23, 22, 5, 4, 64, ZSTD_btopt }, /* level 17 */
+ { 23, 23, 22, 6, 3, 64, ZSTD_btultra }, /* level 18 */
+ { 23, 24, 22, 7, 3,256, ZSTD_btultra2}, /* level 19 */
+ { 25, 25, 23, 7, 3,256, ZSTD_btultra2}, /* level 20 */
+ { 26, 26, 24, 7, 3,512, ZSTD_btultra2}, /* level 21 */
+ { 27, 27, 25, 9, 3,999, ZSTD_btultra2}, /* level 22 */
+},
+{ /* for srcSize <= 256 KB */
+ /* W, C, H, S, L, T, strat */
+ { 18, 12, 13, 1, 5, 1, ZSTD_fast }, /* base for negative levels */
+ { 18, 13, 14, 1, 6, 0, ZSTD_fast }, /* level 1 */
+ { 18, 14, 14, 1, 5, 1, ZSTD_dfast }, /* level 2 */
+ { 18, 16, 16, 1, 4, 1, ZSTD_dfast }, /* level 3 */
+ { 18, 16, 17, 2, 5, 2, ZSTD_greedy }, /* level 4.*/
+ { 18, 18, 18, 3, 5, 2, ZSTD_greedy }, /* level 5.*/
+ { 18, 18, 19, 3, 5, 4, ZSTD_lazy }, /* level 6.*/
+ { 18, 18, 19, 4, 4, 4, ZSTD_lazy }, /* level 7 */
+ { 18, 18, 19, 4, 4, 8, ZSTD_lazy2 }, /* level 8 */
+ { 18, 18, 19, 5, 4, 8, ZSTD_lazy2 }, /* level 9 */
+ { 18, 18, 19, 6, 4, 8, ZSTD_lazy2 }, /* level 10 */
+ { 18, 18, 19, 5, 4, 12, ZSTD_btlazy2 }, /* level 11.*/
+ { 18, 19, 19, 7, 4, 12, ZSTD_btlazy2 }, /* level 12.*/
+ { 18, 18, 19, 4, 4, 16, ZSTD_btopt }, /* level 13 */
+ { 18, 18, 19, 4, 3, 32, ZSTD_btopt }, /* level 14.*/
+ { 18, 18, 19, 6, 3,128, ZSTD_btopt }, /* level 15.*/
+ { 18, 19, 19, 6, 3,128, ZSTD_btultra }, /* level 16.*/
+ { 18, 19, 19, 8, 3,256, ZSTD_btultra }, /* level 17.*/
+ { 18, 19, 19, 6, 3,128, ZSTD_btultra2}, /* level 18.*/
+ { 18, 19, 19, 8, 3,256, ZSTD_btultra2}, /* level 19.*/
+ { 18, 19, 19, 10, 3,512, ZSTD_btultra2}, /* level 20.*/
+ { 18, 19, 19, 12, 3,512, ZSTD_btultra2}, /* level 21.*/
+ { 18, 19, 19, 13, 3,999, ZSTD_btultra2}, /* level 22.*/
+},
+{ /* for srcSize <= 128 KB */
+ /* W, C, H, S, L, T, strat */
+ { 17, 12, 12, 1, 5, 1, ZSTD_fast }, /* base for negative levels */
+ { 17, 12, 13, 1, 6, 0, ZSTD_fast }, /* level 1 */
+ { 17, 13, 15, 1, 5, 0, ZSTD_fast }, /* level 2 */
+ { 17, 15, 16, 2, 5, 1, ZSTD_dfast }, /* level 3 */
+ { 17, 17, 17, 2, 4, 1, ZSTD_dfast }, /* level 4 */
+ { 17, 16, 17, 3, 4, 2, ZSTD_greedy }, /* level 5 */
+ { 17, 17, 17, 3, 4, 4, ZSTD_lazy }, /* level 6 */
+ { 17, 17, 17, 3, 4, 8, ZSTD_lazy2 }, /* level 7 */
+ { 17, 17, 17, 4, 4, 8, ZSTD_lazy2 }, /* level 8 */
+ { 17, 17, 17, 5, 4, 8, ZSTD_lazy2 }, /* level 9 */
+ { 17, 17, 17, 6, 4, 8, ZSTD_lazy2 }, /* level 10 */
+ { 17, 17, 17, 5, 4, 8, ZSTD_btlazy2 }, /* level 11 */
+ { 17, 18, 17, 7, 4, 12, ZSTD_btlazy2 }, /* level 12 */
+ { 17, 18, 17, 3, 4, 12, ZSTD_btopt }, /* level 13.*/
+ { 17, 18, 17, 4, 3, 32, ZSTD_btopt }, /* level 14.*/
+ { 17, 18, 17, 6, 3,256, ZSTD_btopt }, /* level 15.*/
+ { 17, 18, 17, 6, 3,128, ZSTD_btultra }, /* level 16.*/
+ { 17, 18, 17, 8, 3,256, ZSTD_btultra }, /* level 17.*/
+ { 17, 18, 17, 10, 3,512, ZSTD_btultra }, /* level 18.*/
+ { 17, 18, 17, 5, 3,256, ZSTD_btultra2}, /* level 19.*/
+ { 17, 18, 17, 7, 3,512, ZSTD_btultra2}, /* level 20.*/
+ { 17, 18, 17, 9, 3,512, ZSTD_btultra2}, /* level 21.*/
+ { 17, 18, 17, 11, 3,999, ZSTD_btultra2}, /* level 22.*/
+},
+{ /* for srcSize <= 16 KB */
+ /* W, C, H, S, L, T, strat */
+ { 14, 12, 13, 1, 5, 1, ZSTD_fast }, /* base for negative levels */
+ { 14, 14, 15, 1, 5, 0, ZSTD_fast }, /* level 1 */
+ { 14, 14, 15, 1, 4, 0, ZSTD_fast }, /* level 2 */
+ { 14, 14, 15, 2, 4, 1, ZSTD_dfast }, /* level 3 */
+ { 14, 14, 14, 4, 4, 2, ZSTD_greedy }, /* level 4 */
+ { 14, 14, 14, 3, 4, 4, ZSTD_lazy }, /* level 5.*/
+ { 14, 14, 14, 4, 4, 8, ZSTD_lazy2 }, /* level 6 */
+ { 14, 14, 14, 6, 4, 8, ZSTD_lazy2 }, /* level 7 */
+ { 14, 14, 14, 8, 4, 8, ZSTD_lazy2 }, /* level 8.*/
+ { 14, 15, 14, 5, 4, 8, ZSTD_btlazy2 }, /* level 9.*/
+ { 14, 15, 14, 9, 4, 8, ZSTD_btlazy2 }, /* level 10.*/
+ { 14, 15, 14, 3, 4, 12, ZSTD_btopt }, /* level 11.*/
+ { 14, 15, 14, 4, 3, 24, ZSTD_btopt }, /* level 12.*/
+ { 14, 15, 14, 5, 3, 32, ZSTD_btultra }, /* level 13.*/
+ { 14, 15, 15, 6, 3, 64, ZSTD_btultra }, /* level 14.*/
+ { 14, 15, 15, 7, 3,256, ZSTD_btultra }, /* level 15.*/
+ { 14, 15, 15, 5, 3, 48, ZSTD_btultra2}, /* level 16.*/
+ { 14, 15, 15, 6, 3,128, ZSTD_btultra2}, /* level 17.*/
+ { 14, 15, 15, 7, 3,256, ZSTD_btultra2}, /* level 18.*/
+ { 14, 15, 15, 8, 3,256, ZSTD_btultra2}, /* level 19.*/
+ { 14, 15, 15, 8, 3,512, ZSTD_btultra2}, /* level 20.*/
+ { 14, 15, 15, 9, 3,512, ZSTD_btultra2}, /* level 21.*/
+ { 14, 15, 15, 10, 3,999, ZSTD_btultra2}, /* level 22.*/
+},
+};
+
+/*! ZSTD_getCParams() :
+* @return ZSTD_compressionParameters structure for a selected compression level, srcSize and dictSize.
+* Size values are optional, provide 0 if not known or unused */
+ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long srcSizeHint, size_t dictSize)
+{
+ size_t const addedSize = srcSizeHint ? 0 : 500;
+ U64 const rSize = srcSizeHint+dictSize ? srcSizeHint+dictSize+addedSize : (U64)-1;
+ U32 const tableID = (rSize <= 256 KB) + (rSize <= 128 KB) + (rSize <= 16 KB); /* intentional underflow for srcSizeHint == 0 */
+ int row = compressionLevel;
+ DEBUGLOG(5, "ZSTD_getCParams (cLevel=%i)", compressionLevel);
+ if (compressionLevel == 0) row = ZSTD_CLEVEL_DEFAULT; /* 0 == default */
+ if (compressionLevel < 0) row = 0; /* entry 0 is baseline for fast mode */
+ if (compressionLevel > ZSTD_MAX_CLEVEL) row = ZSTD_MAX_CLEVEL;
+ { ZSTD_compressionParameters cp = ZSTD_defaultCParameters[tableID][row];
+ if (compressionLevel < 0) cp.targetLength = (unsigned)(-compressionLevel); /* acceleration factor */
+ return ZSTD_adjustCParams_internal(cp, srcSizeHint, dictSize);
+ }
+}
+
+/*! ZSTD_getParams() :
+* same as ZSTD_getCParams(), but @return a `ZSTD_parameters` object (instead of `ZSTD_compressionParameters`).
+* All fields of `ZSTD_frameParameters` are set to default (0) */
+ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long srcSizeHint, size_t dictSize) {
+ ZSTD_parameters params;
+ ZSTD_compressionParameters const cParams = ZSTD_getCParams(compressionLevel, srcSizeHint, dictSize);
+ DEBUGLOG(5, "ZSTD_getParams (cLevel=%i)", compressionLevel);
+ memset(&params, 0, sizeof(params));
+ params.cParams = cParams;
+ params.fParams.contentSizeFlag = 1;
+ return params;
+}
diff --git a/Utilities/cmzstd/lib/compress/zstd_compress_internal.h b/Utilities/cmzstd/lib/compress/zstd_compress_internal.h
new file mode 100644
index 000000000..29bca5985
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstd_compress_internal.h
@@ -0,0 +1,860 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+/* This header contains definitions
+ * that shall **only** be used by modules within lib/compress.
+ */
+
+#ifndef ZSTD_COMPRESS_H
+#define ZSTD_COMPRESS_H
+
+/*-*************************************
+* Dependencies
+***************************************/
+#include "zstd_internal.h"
+#ifdef ZSTD_MULTITHREAD
+# include "zstdmt_compress.h"
+#endif
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/*-*************************************
+* Constants
+***************************************/
+#define kSearchStrength 8
+#define HASH_READ_SIZE 8
+#define ZSTD_DUBT_UNSORTED_MARK 1 /* For btlazy2 strategy, index 1 now means "unsorted".
+ It could be confused for a real successor at index "1", if sorted as larger than its predecessor.
+ It's not a big deal though : candidate will just be sorted again.
+ Additionnally, candidate position 1 will be lost.
+ But candidate 1 cannot hide a large tree of candidates, so it's a minimal loss.
+ The benefit is that ZSTD_DUBT_UNSORTED_MARK cannot be misdhandled after table re-use with a different strategy
+ Constant required by ZSTD_compressBlock_btlazy2() and ZSTD_reduceTable_internal() */
+
+
+/*-*************************************
+* Context memory management
+***************************************/
+typedef enum { ZSTDcs_created=0, ZSTDcs_init, ZSTDcs_ongoing, ZSTDcs_ending } ZSTD_compressionStage_e;
+typedef enum { zcss_init=0, zcss_load, zcss_flush } ZSTD_cStreamStage;
+
+typedef struct ZSTD_prefixDict_s {
+ const void* dict;
+ size_t dictSize;
+ ZSTD_dictContentType_e dictContentType;
+} ZSTD_prefixDict;
+
+typedef struct {
+ U32 CTable[HUF_CTABLE_SIZE_U32(255)];
+ HUF_repeat repeatMode;
+} ZSTD_hufCTables_t;
+
+typedef struct {
+ FSE_CTable offcodeCTable[FSE_CTABLE_SIZE_U32(OffFSELog, MaxOff)];
+ FSE_CTable matchlengthCTable[FSE_CTABLE_SIZE_U32(MLFSELog, MaxML)];
+ FSE_CTable litlengthCTable[FSE_CTABLE_SIZE_U32(LLFSELog, MaxLL)];
+ FSE_repeat offcode_repeatMode;
+ FSE_repeat matchlength_repeatMode;
+ FSE_repeat litlength_repeatMode;
+} ZSTD_fseCTables_t;
+
+typedef struct {
+ ZSTD_hufCTables_t huf;
+ ZSTD_fseCTables_t fse;
+} ZSTD_entropyCTables_t;
+
+typedef struct {
+ U32 off;
+ U32 len;
+} ZSTD_match_t;
+
+typedef struct {
+ int price;
+ U32 off;
+ U32 mlen;
+ U32 litlen;
+ U32 rep[ZSTD_REP_NUM];
+} ZSTD_optimal_t;
+
+typedef enum { zop_dynamic=0, zop_predef } ZSTD_OptPrice_e;
+
+typedef struct {
+ /* All tables are allocated inside cctx->workspace by ZSTD_resetCCtx_internal() */
+ unsigned* litFreq; /* table of literals statistics, of size 256 */
+ unsigned* litLengthFreq; /* table of litLength statistics, of size (MaxLL+1) */
+ unsigned* matchLengthFreq; /* table of matchLength statistics, of size (MaxML+1) */
+ unsigned* offCodeFreq; /* table of offCode statistics, of size (MaxOff+1) */
+ ZSTD_match_t* matchTable; /* list of found matches, of size ZSTD_OPT_NUM+1 */
+ ZSTD_optimal_t* priceTable; /* All positions tracked by optimal parser, of size ZSTD_OPT_NUM+1 */
+
+ U32 litSum; /* nb of literals */
+ U32 litLengthSum; /* nb of litLength codes */
+ U32 matchLengthSum; /* nb of matchLength codes */
+ U32 offCodeSum; /* nb of offset codes */
+ U32 litSumBasePrice; /* to compare to log2(litfreq) */
+ U32 litLengthSumBasePrice; /* to compare to log2(llfreq) */
+ U32 matchLengthSumBasePrice;/* to compare to log2(mlfreq) */
+ U32 offCodeSumBasePrice; /* to compare to log2(offreq) */
+ ZSTD_OptPrice_e priceType; /* prices can be determined dynamically, or follow a pre-defined cost structure */
+ const ZSTD_entropyCTables_t* symbolCosts; /* pre-calculated dictionary statistics */
+} optState_t;
+
+typedef struct {
+ ZSTD_entropyCTables_t entropy;
+ U32 rep[ZSTD_REP_NUM];
+} ZSTD_compressedBlockState_t;
+
+typedef struct {
+ BYTE const* nextSrc; /* next block here to continue on current prefix */
+ BYTE const* base; /* All regular indexes relative to this position */
+ BYTE const* dictBase; /* extDict indexes relative to this position */
+ U32 dictLimit; /* below that point, need extDict */
+ U32 lowLimit; /* below that point, no more data */
+} ZSTD_window_t;
+
+typedef struct ZSTD_matchState_t ZSTD_matchState_t;
+struct ZSTD_matchState_t {
+ ZSTD_window_t window; /* State for window round buffer management */
+ U32 loadedDictEnd; /* index of end of dictionary */
+ U32 nextToUpdate; /* index from which to continue table update */
+ U32 nextToUpdate3; /* index from which to continue table update */
+ U32 hashLog3; /* dispatch table : larger == faster, more memory */
+ U32* hashTable;
+ U32* hashTable3;
+ U32* chainTable;
+ optState_t opt; /* optimal parser state */
+ const ZSTD_matchState_t * dictMatchState;
+ ZSTD_compressionParameters cParams;
+};
+
+typedef struct {
+ ZSTD_compressedBlockState_t* prevCBlock;
+ ZSTD_compressedBlockState_t* nextCBlock;
+ ZSTD_matchState_t matchState;
+} ZSTD_blockState_t;
+
+typedef struct {
+ U32 offset;
+ U32 checksum;
+} ldmEntry_t;
+
+typedef struct {
+ ZSTD_window_t window; /* State for the window round buffer management */
+ ldmEntry_t* hashTable;
+ BYTE* bucketOffsets; /* Next position in bucket to insert entry */
+ U64 hashPower; /* Used to compute the rolling hash.
+ * Depends on ldmParams.minMatchLength */
+} ldmState_t;
+
+typedef struct {
+ U32 enableLdm; /* 1 if enable long distance matching */
+ U32 hashLog; /* Log size of hashTable */
+ U32 bucketSizeLog; /* Log bucket size for collision resolution, at most 8 */
+ U32 minMatchLength; /* Minimum match length */
+ U32 hashRateLog; /* Log number of entries to skip */
+ U32 windowLog; /* Window log for the LDM */
+} ldmParams_t;
+
+typedef struct {
+ U32 offset;
+ U32 litLength;
+ U32 matchLength;
+} rawSeq;
+
+typedef struct {
+ rawSeq* seq; /* The start of the sequences */
+ size_t pos; /* The position where reading stopped. <= size. */
+ size_t size; /* The number of sequences. <= capacity. */
+ size_t capacity; /* The capacity starting from `seq` pointer */
+} rawSeqStore_t;
+
+struct ZSTD_CCtx_params_s {
+ ZSTD_format_e format;
+ ZSTD_compressionParameters cParams;
+ ZSTD_frameParameters fParams;
+
+ int compressionLevel;
+ int forceWindow; /* force back-references to respect limit of
+ * 1<<wLog, even for dictionary */
+
+ ZSTD_dictAttachPref_e attachDictPref;
+
+ /* Multithreading: used to pass parameters to mtctx */
+ int nbWorkers;
+ size_t jobSize;
+ int overlapLog;
+ int rsyncable;
+
+ /* Long distance matching parameters */
+ ldmParams_t ldmParams;
+
+ /* Internal use, for createCCtxParams() and freeCCtxParams() only */
+ ZSTD_customMem customMem;
+}; /* typedef'd to ZSTD_CCtx_params within "zstd.h" */
+
+struct ZSTD_CCtx_s {
+ ZSTD_compressionStage_e stage;
+ int cParamsChanged; /* == 1 if cParams(except wlog) or compression level are changed in requestedParams. Triggers transmission of new params to ZSTDMT (if available) then reset to 0. */
+ int bmi2; /* == 1 if the CPU supports BMI2 and 0 otherwise. CPU support is determined dynamically once per context lifetime. */
+ ZSTD_CCtx_params requestedParams;
+ ZSTD_CCtx_params appliedParams;
+ U32 dictID;
+
+ int workSpaceOversizedDuration;
+ void* workSpace;
+ size_t workSpaceSize;
+ size_t blockSize;
+ unsigned long long pledgedSrcSizePlusOne; /* this way, 0 (default) == unknown */
+ unsigned long long consumedSrcSize;
+ unsigned long long producedCSize;
+ XXH64_state_t xxhState;
+ ZSTD_customMem customMem;
+ size_t staticSize;
+
+ seqStore_t seqStore; /* sequences storage ptrs */
+ ldmState_t ldmState; /* long distance matching state */
+ rawSeq* ldmSequences; /* Storage for the ldm output sequences */
+ size_t maxNbLdmSequences;
+ rawSeqStore_t externSeqStore; /* Mutable reference to external sequences */
+ ZSTD_blockState_t blockState;
+ U32* entropyWorkspace; /* entropy workspace of HUF_WORKSPACE_SIZE bytes */
+
+ /* streaming */
+ char* inBuff;
+ size_t inBuffSize;
+ size_t inToCompress;
+ size_t inBuffPos;
+ size_t inBuffTarget;
+ char* outBuff;
+ size_t outBuffSize;
+ size_t outBuffContentSize;
+ size_t outBuffFlushedSize;
+ ZSTD_cStreamStage streamStage;
+ U32 frameEnded;
+
+ /* Dictionary */
+ ZSTD_CDict* cdictLocal;
+ const ZSTD_CDict* cdict;
+ ZSTD_prefixDict prefixDict; /* single-usage dictionary */
+
+ /* Multi-threading */
+#ifdef ZSTD_MULTITHREAD
+ ZSTDMT_CCtx* mtctx;
+#endif
+};
+
+typedef enum { ZSTD_dtlm_fast, ZSTD_dtlm_full } ZSTD_dictTableLoadMethod_e;
+
+typedef enum { ZSTD_noDict = 0, ZSTD_extDict = 1, ZSTD_dictMatchState = 2 } ZSTD_dictMode_e;
+
+
+typedef size_t (*ZSTD_blockCompressor) (
+ ZSTD_matchState_t* bs, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, ZSTD_dictMode_e dictMode);
+
+
+MEM_STATIC U32 ZSTD_LLcode(U32 litLength)
+{
+ static const BYTE LL_Code[64] = { 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 16, 17, 17, 18, 18, 19, 19,
+ 20, 20, 20, 20, 21, 21, 21, 21,
+ 22, 22, 22, 22, 22, 22, 22, 22,
+ 23, 23, 23, 23, 23, 23, 23, 23,
+ 24, 24, 24, 24, 24, 24, 24, 24,
+ 24, 24, 24, 24, 24, 24, 24, 24 };
+ static const U32 LL_deltaCode = 19;
+ return (litLength > 63) ? ZSTD_highbit32(litLength) + LL_deltaCode : LL_Code[litLength];
+}
+
+/* ZSTD_MLcode() :
+ * note : mlBase = matchLength - MINMATCH;
+ * because it's the format it's stored in seqStore->sequences */
+MEM_STATIC U32 ZSTD_MLcode(U32 mlBase)
+{
+ static const BYTE ML_Code[128] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 36, 36, 37, 37, 37, 37,
+ 38, 38, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39,
+ 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
+ 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
+ 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
+ 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 };
+ static const U32 ML_deltaCode = 36;
+ return (mlBase > 127) ? ZSTD_highbit32(mlBase) + ML_deltaCode : ML_Code[mlBase];
+}
+
+/*! ZSTD_storeSeq() :
+ * Store a sequence (literal length, literals, offset code and match length code) into seqStore_t.
+ * `offsetCode` : distance to match + 3 (values 1-3 are repCodes).
+ * `mlBase` : matchLength - MINMATCH
+*/
+MEM_STATIC void ZSTD_storeSeq(seqStore_t* seqStorePtr, size_t litLength, const void* literals, U32 offsetCode, size_t mlBase)
+{
+#if defined(DEBUGLEVEL) && (DEBUGLEVEL >= 6)
+ static const BYTE* g_start = NULL;
+ if (g_start==NULL) g_start = (const BYTE*)literals; /* note : index only works for compression within a single segment */
+ { U32 const pos = (U32)((const BYTE*)literals - g_start);
+ DEBUGLOG(6, "Cpos%7u :%3u literals, match%4u bytes at offCode%7u",
+ pos, (U32)litLength, (U32)mlBase+MINMATCH, (U32)offsetCode);
+ }
+#endif
+ assert((size_t)(seqStorePtr->sequences - seqStorePtr->sequencesStart) < seqStorePtr->maxNbSeq);
+ /* copy Literals */
+ assert(seqStorePtr->maxNbLit <= 128 KB);
+ assert(seqStorePtr->lit + litLength <= seqStorePtr->litStart + seqStorePtr->maxNbLit);
+ ZSTD_wildcopy(seqStorePtr->lit, literals, litLength);
+ seqStorePtr->lit += litLength;
+
+ /* literal Length */
+ if (litLength>0xFFFF) {
+ assert(seqStorePtr->longLengthID == 0); /* there can only be a single long length */
+ seqStorePtr->longLengthID = 1;
+ seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
+ }
+ seqStorePtr->sequences[0].litLength = (U16)litLength;
+
+ /* match offset */
+ seqStorePtr->sequences[0].offset = offsetCode + 1;
+
+ /* match Length */
+ if (mlBase>0xFFFF) {
+ assert(seqStorePtr->longLengthID == 0); /* there can only be a single long length */
+ seqStorePtr->longLengthID = 2;
+ seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
+ }
+ seqStorePtr->sequences[0].matchLength = (U16)mlBase;
+
+ seqStorePtr->sequences++;
+}
+
+
+/*-*************************************
+* Match length counter
+***************************************/
+static unsigned ZSTD_NbCommonBytes (size_t val)
+{
+ if (MEM_isLittleEndian()) {
+ if (MEM_64bits()) {
+# if defined(_MSC_VER) && defined(_WIN64)
+ unsigned long r = 0;
+ _BitScanForward64( &r, (U64)val );
+ return (unsigned)(r>>3);
+# elif defined(__GNUC__) && (__GNUC__ >= 4)
+ return (__builtin_ctzll((U64)val) >> 3);
+# else
+ static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2,
+ 0, 3, 1, 3, 1, 4, 2, 7,
+ 0, 2, 3, 6, 1, 5, 3, 5,
+ 1, 3, 4, 4, 2, 5, 6, 7,
+ 7, 0, 1, 2, 3, 3, 4, 6,
+ 2, 6, 5, 5, 3, 4, 5, 6,
+ 7, 1, 2, 4, 6, 4, 4, 5,
+ 7, 2, 6, 5, 7, 6, 7, 7 };
+ return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
+# endif
+ } else { /* 32 bits */
+# if defined(_MSC_VER)
+ unsigned long r=0;
+ _BitScanForward( &r, (U32)val );
+ return (unsigned)(r>>3);
+# elif defined(__GNUC__) && (__GNUC__ >= 3)
+ return (__builtin_ctz((U32)val) >> 3);
+# else
+ static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0,
+ 3, 2, 2, 1, 3, 2, 0, 1,
+ 3, 3, 1, 2, 2, 2, 2, 0,
+ 3, 1, 2, 0, 1, 0, 1, 1 };
+ return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
+# endif
+ }
+ } else { /* Big Endian CPU */
+ if (MEM_64bits()) {
+# if defined(_MSC_VER) && defined(_WIN64)
+ unsigned long r = 0;
+ _BitScanReverse64( &r, val );
+ return (unsigned)(r>>3);
+# elif defined(__GNUC__) && (__GNUC__ >= 4)
+ return (__builtin_clzll(val) >> 3);
+# else
+ unsigned r;
+ const unsigned n32 = sizeof(size_t)*4; /* calculate this way due to compiler complaining in 32-bits mode */
+ if (!(val>>n32)) { r=4; } else { r=0; val>>=n32; }
+ if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
+ r += (!val);
+ return r;
+# endif
+ } else { /* 32 bits */
+# if defined(_MSC_VER)
+ unsigned long r = 0;
+ _BitScanReverse( &r, (unsigned long)val );
+ return (unsigned)(r>>3);
+# elif defined(__GNUC__) && (__GNUC__ >= 3)
+ return (__builtin_clz((U32)val) >> 3);
+# else
+ unsigned r;
+ if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
+ r += (!val);
+ return r;
+# endif
+ } }
+}
+
+
+MEM_STATIC size_t ZSTD_count(const BYTE* pIn, const BYTE* pMatch, const BYTE* const pInLimit)
+{
+ const BYTE* const pStart = pIn;
+ const BYTE* const pInLoopLimit = pInLimit - (sizeof(size_t)-1);
+
+ if (pIn < pInLoopLimit) {
+ { size_t const diff = MEM_readST(pMatch) ^ MEM_readST(pIn);
+ if (diff) return ZSTD_NbCommonBytes(diff); }
+ pIn+=sizeof(size_t); pMatch+=sizeof(size_t);
+ while (pIn < pInLoopLimit) {
+ size_t const diff = MEM_readST(pMatch) ^ MEM_readST(pIn);
+ if (!diff) { pIn+=sizeof(size_t); pMatch+=sizeof(size_t); continue; }
+ pIn += ZSTD_NbCommonBytes(diff);
+ return (size_t)(pIn - pStart);
+ } }
+ if (MEM_64bits() && (pIn<(pInLimit-3)) && (MEM_read32(pMatch) == MEM_read32(pIn))) { pIn+=4; pMatch+=4; }
+ if ((pIn<(pInLimit-1)) && (MEM_read16(pMatch) == MEM_read16(pIn))) { pIn+=2; pMatch+=2; }
+ if ((pIn<pInLimit) && (*pMatch == *pIn)) pIn++;
+ return (size_t)(pIn - pStart);
+}
+
+/** ZSTD_count_2segments() :
+ * can count match length with `ip` & `match` in 2 different segments.
+ * convention : on reaching mEnd, match count continue starting from iStart
+ */
+MEM_STATIC size_t
+ZSTD_count_2segments(const BYTE* ip, const BYTE* match,
+ const BYTE* iEnd, const BYTE* mEnd, const BYTE* iStart)
+{
+ const BYTE* const vEnd = MIN( ip + (mEnd - match), iEnd);
+ size_t const matchLength = ZSTD_count(ip, match, vEnd);
+ if (match + matchLength != mEnd) return matchLength;
+ DEBUGLOG(7, "ZSTD_count_2segments: found a 2-parts match (current length==%zu)", matchLength);
+ DEBUGLOG(7, "distance from match beginning to end dictionary = %zi", mEnd - match);
+ DEBUGLOG(7, "distance from current pos to end buffer = %zi", iEnd - ip);
+ DEBUGLOG(7, "next byte : ip==%02X, istart==%02X", ip[matchLength], *iStart);
+ DEBUGLOG(7, "final match length = %zu", matchLength + ZSTD_count(ip+matchLength, iStart, iEnd));
+ return matchLength + ZSTD_count(ip+matchLength, iStart, iEnd);
+}
+
+
+/*-*************************************
+ * Hashes
+ ***************************************/
+static const U32 prime3bytes = 506832829U;
+static U32 ZSTD_hash3(U32 u, U32 h) { return ((u << (32-24)) * prime3bytes) >> (32-h) ; }
+MEM_STATIC size_t ZSTD_hash3Ptr(const void* ptr, U32 h) { return ZSTD_hash3(MEM_readLE32(ptr), h); } /* only in zstd_opt.h */
+
+static const U32 prime4bytes = 2654435761U;
+static U32 ZSTD_hash4(U32 u, U32 h) { return (u * prime4bytes) >> (32-h) ; }
+static size_t ZSTD_hash4Ptr(const void* ptr, U32 h) { return ZSTD_hash4(MEM_read32(ptr), h); }
+
+static const U64 prime5bytes = 889523592379ULL;
+static size_t ZSTD_hash5(U64 u, U32 h) { return (size_t)(((u << (64-40)) * prime5bytes) >> (64-h)) ; }
+static size_t ZSTD_hash5Ptr(const void* p, U32 h) { return ZSTD_hash5(MEM_readLE64(p), h); }
+
+static const U64 prime6bytes = 227718039650203ULL;
+static size_t ZSTD_hash6(U64 u, U32 h) { return (size_t)(((u << (64-48)) * prime6bytes) >> (64-h)) ; }
+static size_t ZSTD_hash6Ptr(const void* p, U32 h) { return ZSTD_hash6(MEM_readLE64(p), h); }
+
+static const U64 prime7bytes = 58295818150454627ULL;
+static size_t ZSTD_hash7(U64 u, U32 h) { return (size_t)(((u << (64-56)) * prime7bytes) >> (64-h)) ; }
+static size_t ZSTD_hash7Ptr(const void* p, U32 h) { return ZSTD_hash7(MEM_readLE64(p), h); }
+
+static const U64 prime8bytes = 0xCF1BBCDCB7A56463ULL;
+static size_t ZSTD_hash8(U64 u, U32 h) { return (size_t)(((u) * prime8bytes) >> (64-h)) ; }
+static size_t ZSTD_hash8Ptr(const void* p, U32 h) { return ZSTD_hash8(MEM_readLE64(p), h); }
+
+MEM_STATIC size_t ZSTD_hashPtr(const void* p, U32 hBits, U32 mls)
+{
+ switch(mls)
+ {
+ default:
+ case 4: return ZSTD_hash4Ptr(p, hBits);
+ case 5: return ZSTD_hash5Ptr(p, hBits);
+ case 6: return ZSTD_hash6Ptr(p, hBits);
+ case 7: return ZSTD_hash7Ptr(p, hBits);
+ case 8: return ZSTD_hash8Ptr(p, hBits);
+ }
+}
+
+/** ZSTD_ipow() :
+ * Return base^exponent.
+ */
+static U64 ZSTD_ipow(U64 base, U64 exponent)
+{
+ U64 power = 1;
+ while (exponent) {
+ if (exponent & 1) power *= base;
+ exponent >>= 1;
+ base *= base;
+ }
+ return power;
+}
+
+#define ZSTD_ROLL_HASH_CHAR_OFFSET 10
+
+/** ZSTD_rollingHash_append() :
+ * Add the buffer to the hash value.
+ */
+static U64 ZSTD_rollingHash_append(U64 hash, void const* buf, size_t size)
+{
+ BYTE const* istart = (BYTE const*)buf;
+ size_t pos;
+ for (pos = 0; pos < size; ++pos) {
+ hash *= prime8bytes;
+ hash += istart[pos] + ZSTD_ROLL_HASH_CHAR_OFFSET;
+ }
+ return hash;
+}
+
+/** ZSTD_rollingHash_compute() :
+ * Compute the rolling hash value of the buffer.
+ */
+MEM_STATIC U64 ZSTD_rollingHash_compute(void const* buf, size_t size)
+{
+ return ZSTD_rollingHash_append(0, buf, size);
+}
+
+/** ZSTD_rollingHash_primePower() :
+ * Compute the primePower to be passed to ZSTD_rollingHash_rotate() for a hash
+ * over a window of length bytes.
+ */
+MEM_STATIC U64 ZSTD_rollingHash_primePower(U32 length)
+{
+ return ZSTD_ipow(prime8bytes, length - 1);
+}
+
+/** ZSTD_rollingHash_rotate() :
+ * Rotate the rolling hash by one byte.
+ */
+MEM_STATIC U64 ZSTD_rollingHash_rotate(U64 hash, BYTE toRemove, BYTE toAdd, U64 primePower)
+{
+ hash -= (toRemove + ZSTD_ROLL_HASH_CHAR_OFFSET) * primePower;
+ hash *= prime8bytes;
+ hash += toAdd + ZSTD_ROLL_HASH_CHAR_OFFSET;
+ return hash;
+}
+
+/*-*************************************
+* Round buffer management
+***************************************/
+/* Max current allowed */
+#define ZSTD_CURRENT_MAX ((3U << 29) + (1U << ZSTD_WINDOWLOG_MAX))
+/* Maximum chunk size before overflow correction needs to be called again */
+#define ZSTD_CHUNKSIZE_MAX \
+ ( ((U32)-1) /* Maximum ending current index */ \
+ - ZSTD_CURRENT_MAX) /* Maximum beginning lowLimit */
+
+/**
+ * ZSTD_window_clear():
+ * Clears the window containing the history by simply setting it to empty.
+ */
+MEM_STATIC void ZSTD_window_clear(ZSTD_window_t* window)
+{
+ size_t const endT = (size_t)(window->nextSrc - window->base);
+ U32 const end = (U32)endT;
+
+ window->lowLimit = end;
+ window->dictLimit = end;
+}
+
+/**
+ * ZSTD_window_hasExtDict():
+ * Returns non-zero if the window has a non-empty extDict.
+ */
+MEM_STATIC U32 ZSTD_window_hasExtDict(ZSTD_window_t const window)
+{
+ return window.lowLimit < window.dictLimit;
+}
+
+/**
+ * ZSTD_matchState_dictMode():
+ * Inspects the provided matchState and figures out what dictMode should be
+ * passed to the compressor.
+ */
+MEM_STATIC ZSTD_dictMode_e ZSTD_matchState_dictMode(const ZSTD_matchState_t *ms)
+{
+ return ZSTD_window_hasExtDict(ms->window) ?
+ ZSTD_extDict :
+ ms->dictMatchState != NULL ?
+ ZSTD_dictMatchState :
+ ZSTD_noDict;
+}
+
+/**
+ * ZSTD_window_needOverflowCorrection():
+ * Returns non-zero if the indices are getting too large and need overflow
+ * protection.
+ */
+MEM_STATIC U32 ZSTD_window_needOverflowCorrection(ZSTD_window_t const window,
+ void const* srcEnd)
+{
+ U32 const current = (U32)((BYTE const*)srcEnd - window.base);
+ return current > ZSTD_CURRENT_MAX;
+}
+
+/**
+ * ZSTD_window_correctOverflow():
+ * Reduces the indices to protect from index overflow.
+ * Returns the correction made to the indices, which must be applied to every
+ * stored index.
+ *
+ * The least significant cycleLog bits of the indices must remain the same,
+ * which may be 0. Every index up to maxDist in the past must be valid.
+ * NOTE: (maxDist & cycleMask) must be zero.
+ */
+MEM_STATIC U32 ZSTD_window_correctOverflow(ZSTD_window_t* window, U32 cycleLog,
+ U32 maxDist, void const* src)
+{
+ /* preemptive overflow correction:
+ * 1. correction is large enough:
+ * lowLimit > (3<<29) ==> current > 3<<29 + 1<<windowLog
+ * 1<<windowLog <= newCurrent < 1<<chainLog + 1<<windowLog
+ *
+ * current - newCurrent
+ * > (3<<29 + 1<<windowLog) - (1<<windowLog + 1<<chainLog)
+ * > (3<<29) - (1<<chainLog)
+ * > (3<<29) - (1<<30) (NOTE: chainLog <= 30)
+ * > 1<<29
+ *
+ * 2. (ip+ZSTD_CHUNKSIZE_MAX - cctx->base) doesn't overflow:
+ * After correction, current is less than (1<<chainLog + 1<<windowLog).
+ * In 64-bit mode we are safe, because we have 64-bit ptrdiff_t.
+ * In 32-bit mode we are safe, because (chainLog <= 29), so
+ * ip+ZSTD_CHUNKSIZE_MAX - cctx->base < 1<<32.
+ * 3. (cctx->lowLimit + 1<<windowLog) < 1<<32:
+ * windowLog <= 31 ==> 3<<29 + 1<<windowLog < 7<<29 < 1<<32.
+ */
+ U32 const cycleMask = (1U << cycleLog) - 1;
+ U32 const current = (U32)((BYTE const*)src - window->base);
+ U32 const newCurrent = (current & cycleMask) + maxDist;
+ U32 const correction = current - newCurrent;
+ assert((maxDist & cycleMask) == 0);
+ assert(current > newCurrent);
+ /* Loose bound, should be around 1<<29 (see above) */
+ assert(correction > 1<<28);
+
+ window->base += correction;
+ window->dictBase += correction;
+ window->lowLimit -= correction;
+ window->dictLimit -= correction;
+
+ DEBUGLOG(4, "Correction of 0x%x bytes to lowLimit=0x%x", correction,
+ window->lowLimit);
+ return correction;
+}
+
+/**
+ * ZSTD_window_enforceMaxDist():
+ * Updates lowLimit so that:
+ * (srcEnd - base) - lowLimit == maxDist + loadedDictEnd
+ *
+ * This allows a simple check that index >= lowLimit to see if index is valid.
+ * This must be called before a block compression call, with srcEnd as the block
+ * source end.
+ *
+ * If loadedDictEndPtr is not NULL, we set it to zero once we update lowLimit.
+ * This is because dictionaries are allowed to be referenced as long as the last
+ * byte of the dictionary is in the window, but once they are out of range,
+ * they cannot be referenced. If loadedDictEndPtr is NULL, we use
+ * loadedDictEnd == 0.
+ *
+ * In normal dict mode, the dict is between lowLimit and dictLimit. In
+ * dictMatchState mode, lowLimit and dictLimit are the same, and the dictionary
+ * is below them. forceWindow and dictMatchState are therefore incompatible.
+ */
+MEM_STATIC void
+ZSTD_window_enforceMaxDist(ZSTD_window_t* window,
+ void const* srcEnd,
+ U32 maxDist,
+ U32* loadedDictEndPtr,
+ const ZSTD_matchState_t** dictMatchStatePtr)
+{
+ U32 const blockEndIdx = (U32)((BYTE const*)srcEnd - window->base);
+ U32 loadedDictEnd = (loadedDictEndPtr != NULL) ? *loadedDictEndPtr : 0;
+ DEBUGLOG(5, "ZSTD_window_enforceMaxDist: blockEndIdx=%u, maxDist=%u",
+ (unsigned)blockEndIdx, (unsigned)maxDist);
+ if (blockEndIdx > maxDist + loadedDictEnd) {
+ U32 const newLowLimit = blockEndIdx - maxDist;
+ if (window->lowLimit < newLowLimit) window->lowLimit = newLowLimit;
+ if (window->dictLimit < window->lowLimit) {
+ DEBUGLOG(5, "Update dictLimit to match lowLimit, from %u to %u",
+ (unsigned)window->dictLimit, (unsigned)window->lowLimit);
+ window->dictLimit = window->lowLimit;
+ }
+ if (loadedDictEndPtr)
+ *loadedDictEndPtr = 0;
+ if (dictMatchStatePtr)
+ *dictMatchStatePtr = NULL;
+ }
+}
+
+/**
+ * ZSTD_window_update():
+ * Updates the window by appending [src, src + srcSize) to the window.
+ * If it is not contiguous, the current prefix becomes the extDict, and we
+ * forget about the extDict. Handles overlap of the prefix and extDict.
+ * Returns non-zero if the segment is contiguous.
+ */
+MEM_STATIC U32 ZSTD_window_update(ZSTD_window_t* window,
+ void const* src, size_t srcSize)
+{
+ BYTE const* const ip = (BYTE const*)src;
+ U32 contiguous = 1;
+ DEBUGLOG(5, "ZSTD_window_update");
+ /* Check if blocks follow each other */
+ if (src != window->nextSrc) {
+ /* not contiguous */
+ size_t const distanceFromBase = (size_t)(window->nextSrc - window->base);
+ DEBUGLOG(5, "Non contiguous blocks, new segment starts at %u", window->dictLimit);
+ window->lowLimit = window->dictLimit;
+ assert(distanceFromBase == (size_t)(U32)distanceFromBase); /* should never overflow */
+ window->dictLimit = (U32)distanceFromBase;
+ window->dictBase = window->base;
+ window->base = ip - distanceFromBase;
+ // ms->nextToUpdate = window->dictLimit;
+ if (window->dictLimit - window->lowLimit < HASH_READ_SIZE) window->lowLimit = window->dictLimit; /* too small extDict */
+ contiguous = 0;
+ }
+ window->nextSrc = ip + srcSize;
+ /* if input and dictionary overlap : reduce dictionary (area presumed modified by input) */
+ if ( (ip+srcSize > window->dictBase + window->lowLimit)
+ & (ip < window->dictBase + window->dictLimit)) {
+ ptrdiff_t const highInputIdx = (ip + srcSize) - window->dictBase;
+ U32 const lowLimitMax = (highInputIdx > (ptrdiff_t)window->dictLimit) ? window->dictLimit : (U32)highInputIdx;
+ window->lowLimit = lowLimitMax;
+ DEBUGLOG(5, "Overlapping extDict and input : new lowLimit = %u", window->lowLimit);
+ }
+ return contiguous;
+}
+
+
+/* debug functions */
+#if (DEBUGLEVEL>=2)
+
+MEM_STATIC double ZSTD_fWeight(U32 rawStat)
+{
+ U32 const fp_accuracy = 8;
+ U32 const fp_multiplier = (1 << fp_accuracy);
+ U32 const newStat = rawStat + 1;
+ U32 const hb = ZSTD_highbit32(newStat);
+ U32 const BWeight = hb * fp_multiplier;
+ U32 const FWeight = (newStat << fp_accuracy) >> hb;
+ U32 const weight = BWeight + FWeight;
+ assert(hb + fp_accuracy < 31);
+ return (double)weight / fp_multiplier;
+}
+
+/* display a table content,
+ * listing each element, its frequency, and its predicted bit cost */
+MEM_STATIC void ZSTD_debugTable(const U32* table, U32 max)
+{
+ unsigned u, sum;
+ for (u=0, sum=0; u<=max; u++) sum += table[u];
+ DEBUGLOG(2, "total nb elts: %u", sum);
+ for (u=0; u<=max; u++) {
+ DEBUGLOG(2, "%2u: %5u (%.2f)",
+ u, table[u], ZSTD_fWeight(sum) - ZSTD_fWeight(table[u]) );
+ }
+}
+
+#endif
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+
+/* ==============================================================
+ * Private declarations
+ * These prototypes shall only be called from within lib/compress
+ * ============================================================== */
+
+/* ZSTD_getCParamsFromCCtxParams() :
+ * cParams are built depending on compressionLevel, src size hints,
+ * LDM and manually set compression parameters.
+ */
+ZSTD_compressionParameters ZSTD_getCParamsFromCCtxParams(
+ const ZSTD_CCtx_params* CCtxParams, U64 srcSizeHint, size_t dictSize);
+
+/*! ZSTD_initCStream_internal() :
+ * Private use only. Init streaming operation.
+ * expects params to be valid.
+ * must receive dict, or cdict, or none, but not both.
+ * @return : 0, or an error code */
+size_t ZSTD_initCStream_internal(ZSTD_CStream* zcs,
+ const void* dict, size_t dictSize,
+ const ZSTD_CDict* cdict,
+ ZSTD_CCtx_params params, unsigned long long pledgedSrcSize);
+
+void ZSTD_resetSeqStore(seqStore_t* ssPtr);
+
+/*! ZSTD_compressStream_generic() :
+ * Private use only. To be called from zstdmt_compress.c in single-thread mode. */
+size_t ZSTD_compressStream_generic(ZSTD_CStream* zcs,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective const flushMode);
+
+/*! ZSTD_getCParamsFromCDict() :
+ * as the name implies */
+ZSTD_compressionParameters ZSTD_getCParamsFromCDict(const ZSTD_CDict* cdict);
+
+/* ZSTD_compressBegin_advanced_internal() :
+ * Private use only. To be called from zstdmt_compress.c. */
+size_t ZSTD_compressBegin_advanced_internal(ZSTD_CCtx* cctx,
+ const void* dict, size_t dictSize,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_dictTableLoadMethod_e dtlm,
+ const ZSTD_CDict* cdict,
+ ZSTD_CCtx_params params,
+ unsigned long long pledgedSrcSize);
+
+/* ZSTD_compress_advanced_internal() :
+ * Private use only. To be called from zstdmt_compress.c. */
+size_t ZSTD_compress_advanced_internal(ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict,size_t dictSize,
+ ZSTD_CCtx_params params);
+
+
+/* ZSTD_writeLastEmptyBlock() :
+ * output an empty Block with end-of-frame mark to complete a frame
+ * @return : size of data written into `dst` (== ZSTD_blockHeaderSize (defined in zstd_internal.h))
+ * or an error code if `dstCapcity` is too small (<ZSTD_blockHeaderSize)
+ */
+size_t ZSTD_writeLastEmptyBlock(void* dst, size_t dstCapacity);
+
+
+/* ZSTD_referenceExternalSequences() :
+ * Must be called before starting a compression operation.
+ * seqs must parse a prefix of the source.
+ * This cannot be used when long range matching is enabled.
+ * Zstd will use these sequences, and pass the literals to a secondary block
+ * compressor.
+ * @return : An error code on failure.
+ * NOTE: seqs are not verified! Invalid sequences can cause out-of-bounds memory
+ * access and data corruption.
+ */
+size_t ZSTD_referenceExternalSequences(ZSTD_CCtx* cctx, rawSeq* seq, size_t nbSeq);
+
+
+#endif /* ZSTD_COMPRESS_H */
diff --git a/Utilities/cmzstd/lib/compress/zstd_double_fast.c b/Utilities/cmzstd/lib/compress/zstd_double_fast.c
new file mode 100644
index 000000000..47faf6d64
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstd_double_fast.c
@@ -0,0 +1,499 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#include "zstd_compress_internal.h"
+#include "zstd_double_fast.h"
+
+
+void ZSTD_fillDoubleHashTable(ZSTD_matchState_t* ms,
+ void const* end, ZSTD_dictTableLoadMethod_e dtlm)
+{
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+ U32* const hashLarge = ms->hashTable;
+ U32 const hBitsL = cParams->hashLog;
+ U32 const mls = cParams->minMatch;
+ U32* const hashSmall = ms->chainTable;
+ U32 const hBitsS = cParams->chainLog;
+ const BYTE* const base = ms->window.base;
+ const BYTE* ip = base + ms->nextToUpdate;
+ const BYTE* const iend = ((const BYTE*)end) - HASH_READ_SIZE;
+ const U32 fastHashFillStep = 3;
+
+ /* Always insert every fastHashFillStep position into the hash tables.
+ * Insert the other positions into the large hash table if their entry
+ * is empty.
+ */
+ for (; ip + fastHashFillStep - 1 <= iend; ip += fastHashFillStep) {
+ U32 const current = (U32)(ip - base);
+ U32 i;
+ for (i = 0; i < fastHashFillStep; ++i) {
+ size_t const smHash = ZSTD_hashPtr(ip + i, hBitsS, mls);
+ size_t const lgHash = ZSTD_hashPtr(ip + i, hBitsL, 8);
+ if (i == 0)
+ hashSmall[smHash] = current + i;
+ if (i == 0 || hashLarge[lgHash] == 0)
+ hashLarge[lgHash] = current + i;
+ /* Only load extra positions for ZSTD_dtlm_full */
+ if (dtlm == ZSTD_dtlm_fast)
+ break;
+ }
+ }
+}
+
+
+FORCE_INLINE_TEMPLATE
+size_t ZSTD_compressBlock_doubleFast_generic(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize,
+ U32 const mls /* template */, ZSTD_dictMode_e const dictMode)
+{
+ ZSTD_compressionParameters const* cParams = &ms->cParams;
+ U32* const hashLong = ms->hashTable;
+ const U32 hBitsL = cParams->hashLog;
+ U32* const hashSmall = ms->chainTable;
+ const U32 hBitsS = cParams->chainLog;
+ const BYTE* const base = ms->window.base;
+ const BYTE* const istart = (const BYTE*)src;
+ const BYTE* ip = istart;
+ const BYTE* anchor = istart;
+ const U32 prefixLowestIndex = ms->window.dictLimit;
+ const BYTE* const prefixLowest = base + prefixLowestIndex;
+ const BYTE* const iend = istart + srcSize;
+ const BYTE* const ilimit = iend - HASH_READ_SIZE;
+ U32 offset_1=rep[0], offset_2=rep[1];
+ U32 offsetSaved = 0;
+
+ const ZSTD_matchState_t* const dms = ms->dictMatchState;
+ const ZSTD_compressionParameters* const dictCParams =
+ dictMode == ZSTD_dictMatchState ?
+ &dms->cParams : NULL;
+ const U32* const dictHashLong = dictMode == ZSTD_dictMatchState ?
+ dms->hashTable : NULL;
+ const U32* const dictHashSmall = dictMode == ZSTD_dictMatchState ?
+ dms->chainTable : NULL;
+ const U32 dictStartIndex = dictMode == ZSTD_dictMatchState ?
+ dms->window.dictLimit : 0;
+ const BYTE* const dictBase = dictMode == ZSTD_dictMatchState ?
+ dms->window.base : NULL;
+ const BYTE* const dictStart = dictMode == ZSTD_dictMatchState ?
+ dictBase + dictStartIndex : NULL;
+ const BYTE* const dictEnd = dictMode == ZSTD_dictMatchState ?
+ dms->window.nextSrc : NULL;
+ const U32 dictIndexDelta = dictMode == ZSTD_dictMatchState ?
+ prefixLowestIndex - (U32)(dictEnd - dictBase) :
+ 0;
+ const U32 dictHBitsL = dictMode == ZSTD_dictMatchState ?
+ dictCParams->hashLog : hBitsL;
+ const U32 dictHBitsS = dictMode == ZSTD_dictMatchState ?
+ dictCParams->chainLog : hBitsS;
+ const U32 dictAndPrefixLength = (U32)(ip - prefixLowest + dictEnd - dictStart);
+
+ assert(dictMode == ZSTD_noDict || dictMode == ZSTD_dictMatchState);
+
+ /* init */
+ ip += (dictAndPrefixLength == 0);
+ if (dictMode == ZSTD_noDict) {
+ U32 const maxRep = (U32)(ip - prefixLowest);
+ if (offset_2 > maxRep) offsetSaved = offset_2, offset_2 = 0;
+ if (offset_1 > maxRep) offsetSaved = offset_1, offset_1 = 0;
+ }
+ if (dictMode == ZSTD_dictMatchState) {
+ /* dictMatchState repCode checks don't currently handle repCode == 0
+ * disabling. */
+ assert(offset_1 <= dictAndPrefixLength);
+ assert(offset_2 <= dictAndPrefixLength);
+ }
+
+ /* Main Search Loop */
+ while (ip < ilimit) { /* < instead of <=, because repcode check at (ip+1) */
+ size_t mLength;
+ U32 offset;
+ size_t const h2 = ZSTD_hashPtr(ip, hBitsL, 8);
+ size_t const h = ZSTD_hashPtr(ip, hBitsS, mls);
+ size_t const dictHL = ZSTD_hashPtr(ip, dictHBitsL, 8);
+ size_t const dictHS = ZSTD_hashPtr(ip, dictHBitsS, mls);
+ U32 const current = (U32)(ip-base);
+ U32 const matchIndexL = hashLong[h2];
+ U32 matchIndexS = hashSmall[h];
+ const BYTE* matchLong = base + matchIndexL;
+ const BYTE* match = base + matchIndexS;
+ const U32 repIndex = current + 1 - offset_1;
+ const BYTE* repMatch = (dictMode == ZSTD_dictMatchState
+ && repIndex < prefixLowestIndex) ?
+ dictBase + (repIndex - dictIndexDelta) :
+ base + repIndex;
+ hashLong[h2] = hashSmall[h] = current; /* update hash tables */
+
+ /* check dictMatchState repcode */
+ if (dictMode == ZSTD_dictMatchState
+ && ((U32)((prefixLowestIndex-1) - repIndex) >= 3 /* intentional underflow */)
+ && (MEM_read32(repMatch) == MEM_read32(ip+1)) ) {
+ const BYTE* repMatchEnd = repIndex < prefixLowestIndex ? dictEnd : iend;
+ mLength = ZSTD_count_2segments(ip+1+4, repMatch+4, iend, repMatchEnd, prefixLowest) + 4;
+ ip++;
+ ZSTD_storeSeq(seqStore, ip-anchor, anchor, 0, mLength-MINMATCH);
+ goto _match_stored;
+ }
+
+ /* check noDict repcode */
+ if ( dictMode == ZSTD_noDict
+ && ((offset_1 > 0) & (MEM_read32(ip+1-offset_1) == MEM_read32(ip+1)))) {
+ mLength = ZSTD_count(ip+1+4, ip+1+4-offset_1, iend) + 4;
+ ip++;
+ ZSTD_storeSeq(seqStore, ip-anchor, anchor, 0, mLength-MINMATCH);
+ goto _match_stored;
+ }
+
+ if (matchIndexL > prefixLowestIndex) {
+ /* check prefix long match */
+ if (MEM_read64(matchLong) == MEM_read64(ip)) {
+ mLength = ZSTD_count(ip+8, matchLong+8, iend) + 8;
+ offset = (U32)(ip-matchLong);
+ while (((ip>anchor) & (matchLong>prefixLowest)) && (ip[-1] == matchLong[-1])) { ip--; matchLong--; mLength++; } /* catch up */
+ goto _match_found;
+ }
+ } else if (dictMode == ZSTD_dictMatchState) {
+ /* check dictMatchState long match */
+ U32 const dictMatchIndexL = dictHashLong[dictHL];
+ const BYTE* dictMatchL = dictBase + dictMatchIndexL;
+ assert(dictMatchL < dictEnd);
+
+ if (dictMatchL > dictStart && MEM_read64(dictMatchL) == MEM_read64(ip)) {
+ mLength = ZSTD_count_2segments(ip+8, dictMatchL+8, iend, dictEnd, prefixLowest) + 8;
+ offset = (U32)(current - dictMatchIndexL - dictIndexDelta);
+ while (((ip>anchor) & (dictMatchL>dictStart)) && (ip[-1] == dictMatchL[-1])) { ip--; dictMatchL--; mLength++; } /* catch up */
+ goto _match_found;
+ }
+ }
+
+ if (matchIndexS > prefixLowestIndex) {
+ /* check prefix short match */
+ if (MEM_read32(match) == MEM_read32(ip)) {
+ goto _search_next_long;
+ }
+ } else if (dictMode == ZSTD_dictMatchState) {
+ /* check dictMatchState short match */
+ U32 const dictMatchIndexS = dictHashSmall[dictHS];
+ match = dictBase + dictMatchIndexS;
+ matchIndexS = dictMatchIndexS + dictIndexDelta;
+
+ if (match > dictStart && MEM_read32(match) == MEM_read32(ip)) {
+ goto _search_next_long;
+ }
+ }
+
+ ip += ((ip-anchor) >> kSearchStrength) + 1;
+ continue;
+
+_search_next_long:
+
+ {
+ size_t const hl3 = ZSTD_hashPtr(ip+1, hBitsL, 8);
+ size_t const dictHLNext = ZSTD_hashPtr(ip+1, dictHBitsL, 8);
+ U32 const matchIndexL3 = hashLong[hl3];
+ const BYTE* matchL3 = base + matchIndexL3;
+ hashLong[hl3] = current + 1;
+
+ /* check prefix long +1 match */
+ if (matchIndexL3 > prefixLowestIndex) {
+ if (MEM_read64(matchL3) == MEM_read64(ip+1)) {
+ mLength = ZSTD_count(ip+9, matchL3+8, iend) + 8;
+ ip++;
+ offset = (U32)(ip-matchL3);
+ while (((ip>anchor) & (matchL3>prefixLowest)) && (ip[-1] == matchL3[-1])) { ip--; matchL3--; mLength++; } /* catch up */
+ goto _match_found;
+ }
+ } else if (dictMode == ZSTD_dictMatchState) {
+ /* check dict long +1 match */
+ U32 const dictMatchIndexL3 = dictHashLong[dictHLNext];
+ const BYTE* dictMatchL3 = dictBase + dictMatchIndexL3;
+ assert(dictMatchL3 < dictEnd);
+ if (dictMatchL3 > dictStart && MEM_read64(dictMatchL3) == MEM_read64(ip+1)) {
+ mLength = ZSTD_count_2segments(ip+1+8, dictMatchL3+8, iend, dictEnd, prefixLowest) + 8;
+ ip++;
+ offset = (U32)(current + 1 - dictMatchIndexL3 - dictIndexDelta);
+ while (((ip>anchor) & (dictMatchL3>dictStart)) && (ip[-1] == dictMatchL3[-1])) { ip--; dictMatchL3--; mLength++; } /* catch up */
+ goto _match_found;
+ }
+ }
+ }
+
+ /* if no long +1 match, explore the short match we found */
+ if (dictMode == ZSTD_dictMatchState && matchIndexS < prefixLowestIndex) {
+ mLength = ZSTD_count_2segments(ip+4, match+4, iend, dictEnd, prefixLowest) + 4;
+ offset = (U32)(current - matchIndexS);
+ while (((ip>anchor) & (match>dictStart)) && (ip[-1] == match[-1])) { ip--; match--; mLength++; } /* catch up */
+ } else {
+ mLength = ZSTD_count(ip+4, match+4, iend) + 4;
+ offset = (U32)(ip - match);
+ while (((ip>anchor) & (match>prefixLowest)) && (ip[-1] == match[-1])) { ip--; match--; mLength++; } /* catch up */
+ }
+
+ /* fall-through */
+
+_match_found:
+ offset_2 = offset_1;
+ offset_1 = offset;
+
+ ZSTD_storeSeq(seqStore, ip-anchor, anchor, offset + ZSTD_REP_MOVE, mLength-MINMATCH);
+
+_match_stored:
+ /* match found */
+ ip += mLength;
+ anchor = ip;
+
+ if (ip <= ilimit) {
+ /* Fill Table */
+ hashLong[ZSTD_hashPtr(base+current+2, hBitsL, 8)] =
+ hashSmall[ZSTD_hashPtr(base+current+2, hBitsS, mls)] = current+2; /* here because current+2 could be > iend-8 */
+ hashLong[ZSTD_hashPtr(ip-2, hBitsL, 8)] =
+ hashSmall[ZSTD_hashPtr(ip-2, hBitsS, mls)] = (U32)(ip-2-base);
+
+ /* check immediate repcode */
+ if (dictMode == ZSTD_dictMatchState) {
+ while (ip <= ilimit) {
+ U32 const current2 = (U32)(ip-base);
+ U32 const repIndex2 = current2 - offset_2;
+ const BYTE* repMatch2 = dictMode == ZSTD_dictMatchState
+ && repIndex2 < prefixLowestIndex ?
+ dictBase - dictIndexDelta + repIndex2 :
+ base + repIndex2;
+ if ( ((U32)((prefixLowestIndex-1) - (U32)repIndex2) >= 3 /* intentional overflow */)
+ && (MEM_read32(repMatch2) == MEM_read32(ip)) ) {
+ const BYTE* const repEnd2 = repIndex2 < prefixLowestIndex ? dictEnd : iend;
+ size_t const repLength2 = ZSTD_count_2segments(ip+4, repMatch2+4, iend, repEnd2, prefixLowest) + 4;
+ U32 tmpOffset = offset_2; offset_2 = offset_1; offset_1 = tmpOffset; /* swap offset_2 <=> offset_1 */
+ ZSTD_storeSeq(seqStore, 0, anchor, 0, repLength2-MINMATCH);
+ hashSmall[ZSTD_hashPtr(ip, hBitsS, mls)] = current2;
+ hashLong[ZSTD_hashPtr(ip, hBitsL, 8)] = current2;
+ ip += repLength2;
+ anchor = ip;
+ continue;
+ }
+ break;
+ }
+ }
+
+ if (dictMode == ZSTD_noDict) {
+ while ( (ip <= ilimit)
+ && ( (offset_2>0)
+ & (MEM_read32(ip) == MEM_read32(ip - offset_2)) )) {
+ /* store sequence */
+ size_t const rLength = ZSTD_count(ip+4, ip+4-offset_2, iend) + 4;
+ U32 const tmpOff = offset_2; offset_2 = offset_1; offset_1 = tmpOff; /* swap offset_2 <=> offset_1 */
+ hashSmall[ZSTD_hashPtr(ip, hBitsS, mls)] = (U32)(ip-base);
+ hashLong[ZSTD_hashPtr(ip, hBitsL, 8)] = (U32)(ip-base);
+ ZSTD_storeSeq(seqStore, 0, anchor, 0, rLength-MINMATCH);
+ ip += rLength;
+ anchor = ip;
+ continue; /* faster when present ... (?) */
+ } } } }
+
+ /* save reps for next block */
+ rep[0] = offset_1 ? offset_1 : offsetSaved;
+ rep[1] = offset_2 ? offset_2 : offsetSaved;
+
+ /* Return the last literals size */
+ return iend - anchor;
+}
+
+
+size_t ZSTD_compressBlock_doubleFast(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ const U32 mls = ms->cParams.minMatch;
+ switch(mls)
+ {
+ default: /* includes case 3 */
+ case 4 :
+ return ZSTD_compressBlock_doubleFast_generic(ms, seqStore, rep, src, srcSize, 4, ZSTD_noDict);
+ case 5 :
+ return ZSTD_compressBlock_doubleFast_generic(ms, seqStore, rep, src, srcSize, 5, ZSTD_noDict);
+ case 6 :
+ return ZSTD_compressBlock_doubleFast_generic(ms, seqStore, rep, src, srcSize, 6, ZSTD_noDict);
+ case 7 :
+ return ZSTD_compressBlock_doubleFast_generic(ms, seqStore, rep, src, srcSize, 7, ZSTD_noDict);
+ }
+}
+
+
+size_t ZSTD_compressBlock_doubleFast_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ const U32 mls = ms->cParams.minMatch;
+ switch(mls)
+ {
+ default: /* includes case 3 */
+ case 4 :
+ return ZSTD_compressBlock_doubleFast_generic(ms, seqStore, rep, src, srcSize, 4, ZSTD_dictMatchState);
+ case 5 :
+ return ZSTD_compressBlock_doubleFast_generic(ms, seqStore, rep, src, srcSize, 5, ZSTD_dictMatchState);
+ case 6 :
+ return ZSTD_compressBlock_doubleFast_generic(ms, seqStore, rep, src, srcSize, 6, ZSTD_dictMatchState);
+ case 7 :
+ return ZSTD_compressBlock_doubleFast_generic(ms, seqStore, rep, src, srcSize, 7, ZSTD_dictMatchState);
+ }
+}
+
+
+static size_t ZSTD_compressBlock_doubleFast_extDict_generic(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize,
+ U32 const mls /* template */)
+{
+ ZSTD_compressionParameters const* cParams = &ms->cParams;
+ U32* const hashLong = ms->hashTable;
+ U32 const hBitsL = cParams->hashLog;
+ U32* const hashSmall = ms->chainTable;
+ U32 const hBitsS = cParams->chainLog;
+ const BYTE* const istart = (const BYTE*)src;
+ const BYTE* ip = istart;
+ const BYTE* anchor = istart;
+ const BYTE* const iend = istart + srcSize;
+ const BYTE* const ilimit = iend - 8;
+ const U32 prefixStartIndex = ms->window.dictLimit;
+ const BYTE* const base = ms->window.base;
+ const BYTE* const prefixStart = base + prefixStartIndex;
+ const U32 dictStartIndex = ms->window.lowLimit;
+ const BYTE* const dictBase = ms->window.dictBase;
+ const BYTE* const dictStart = dictBase + dictStartIndex;
+ const BYTE* const dictEnd = dictBase + prefixStartIndex;
+ U32 offset_1=rep[0], offset_2=rep[1];
+
+ DEBUGLOG(5, "ZSTD_compressBlock_doubleFast_extDict_generic (srcSize=%zu)", srcSize);
+
+ /* Search Loop */
+ while (ip < ilimit) { /* < instead of <=, because (ip+1) */
+ const size_t hSmall = ZSTD_hashPtr(ip, hBitsS, mls);
+ const U32 matchIndex = hashSmall[hSmall];
+ const BYTE* const matchBase = matchIndex < prefixStartIndex ? dictBase : base;
+ const BYTE* match = matchBase + matchIndex;
+
+ const size_t hLong = ZSTD_hashPtr(ip, hBitsL, 8);
+ const U32 matchLongIndex = hashLong[hLong];
+ const BYTE* const matchLongBase = matchLongIndex < prefixStartIndex ? dictBase : base;
+ const BYTE* matchLong = matchLongBase + matchLongIndex;
+
+ const U32 current = (U32)(ip-base);
+ const U32 repIndex = current + 1 - offset_1; /* offset_1 expected <= current +1 */
+ const BYTE* const repBase = repIndex < prefixStartIndex ? dictBase : base;
+ const BYTE* const repMatch = repBase + repIndex;
+ size_t mLength;
+ hashSmall[hSmall] = hashLong[hLong] = current; /* update hash table */
+
+ if ((((U32)((prefixStartIndex-1) - repIndex) >= 3) /* intentional underflow : ensure repIndex doesn't overlap dict + prefix */
+ & (repIndex > dictStartIndex))
+ && (MEM_read32(repMatch) == MEM_read32(ip+1)) ) {
+ const BYTE* repMatchEnd = repIndex < prefixStartIndex ? dictEnd : iend;
+ mLength = ZSTD_count_2segments(ip+1+4, repMatch+4, iend, repMatchEnd, prefixStart) + 4;
+ ip++;
+ ZSTD_storeSeq(seqStore, ip-anchor, anchor, 0, mLength-MINMATCH);
+ } else {
+ if ((matchLongIndex > dictStartIndex) && (MEM_read64(matchLong) == MEM_read64(ip))) {
+ const BYTE* const matchEnd = matchLongIndex < prefixStartIndex ? dictEnd : iend;
+ const BYTE* const lowMatchPtr = matchLongIndex < prefixStartIndex ? dictStart : prefixStart;
+ U32 offset;
+ mLength = ZSTD_count_2segments(ip+8, matchLong+8, iend, matchEnd, prefixStart) + 8;
+ offset = current - matchLongIndex;
+ while (((ip>anchor) & (matchLong>lowMatchPtr)) && (ip[-1] == matchLong[-1])) { ip--; matchLong--; mLength++; } /* catch up */
+ offset_2 = offset_1;
+ offset_1 = offset;
+ ZSTD_storeSeq(seqStore, ip-anchor, anchor, offset + ZSTD_REP_MOVE, mLength-MINMATCH);
+
+ } else if ((matchIndex > dictStartIndex) && (MEM_read32(match) == MEM_read32(ip))) {
+ size_t const h3 = ZSTD_hashPtr(ip+1, hBitsL, 8);
+ U32 const matchIndex3 = hashLong[h3];
+ const BYTE* const match3Base = matchIndex3 < prefixStartIndex ? dictBase : base;
+ const BYTE* match3 = match3Base + matchIndex3;
+ U32 offset;
+ hashLong[h3] = current + 1;
+ if ( (matchIndex3 > dictStartIndex) && (MEM_read64(match3) == MEM_read64(ip+1)) ) {
+ const BYTE* const matchEnd = matchIndex3 < prefixStartIndex ? dictEnd : iend;
+ const BYTE* const lowMatchPtr = matchIndex3 < prefixStartIndex ? dictStart : prefixStart;
+ mLength = ZSTD_count_2segments(ip+9, match3+8, iend, matchEnd, prefixStart) + 8;
+ ip++;
+ offset = current+1 - matchIndex3;
+ while (((ip>anchor) & (match3>lowMatchPtr)) && (ip[-1] == match3[-1])) { ip--; match3--; mLength++; } /* catch up */
+ } else {
+ const BYTE* const matchEnd = matchIndex < prefixStartIndex ? dictEnd : iend;
+ const BYTE* const lowMatchPtr = matchIndex < prefixStartIndex ? dictStart : prefixStart;
+ mLength = ZSTD_count_2segments(ip+4, match+4, iend, matchEnd, prefixStart) + 4;
+ offset = current - matchIndex;
+ while (((ip>anchor) & (match>lowMatchPtr)) && (ip[-1] == match[-1])) { ip--; match--; mLength++; } /* catch up */
+ }
+ offset_2 = offset_1;
+ offset_1 = offset;
+ ZSTD_storeSeq(seqStore, ip-anchor, anchor, offset + ZSTD_REP_MOVE, mLength-MINMATCH);
+
+ } else {
+ ip += ((ip-anchor) >> kSearchStrength) + 1;
+ continue;
+ } }
+
+ /* found a match : store it */
+ ip += mLength;
+ anchor = ip;
+
+ if (ip <= ilimit) {
+ /* Fill Table */
+ hashSmall[ZSTD_hashPtr(base+current+2, hBitsS, mls)] = current+2;
+ hashLong[ZSTD_hashPtr(base+current+2, hBitsL, 8)] = current+2;
+ hashSmall[ZSTD_hashPtr(ip-2, hBitsS, mls)] = (U32)(ip-2-base);
+ hashLong[ZSTD_hashPtr(ip-2, hBitsL, 8)] = (U32)(ip-2-base);
+ /* check immediate repcode */
+ while (ip <= ilimit) {
+ U32 const current2 = (U32)(ip-base);
+ U32 const repIndex2 = current2 - offset_2;
+ const BYTE* repMatch2 = repIndex2 < prefixStartIndex ? dictBase + repIndex2 : base + repIndex2;
+ if ( (((U32)((prefixStartIndex-1) - repIndex2) >= 3) /* intentional overflow : ensure repIndex2 doesn't overlap dict + prefix */
+ & (repIndex2 > dictStartIndex))
+ && (MEM_read32(repMatch2) == MEM_read32(ip)) ) {
+ const BYTE* const repEnd2 = repIndex2 < prefixStartIndex ? dictEnd : iend;
+ size_t const repLength2 = ZSTD_count_2segments(ip+4, repMatch2+4, iend, repEnd2, prefixStart) + 4;
+ U32 const tmpOffset = offset_2; offset_2 = offset_1; offset_1 = tmpOffset; /* swap offset_2 <=> offset_1 */
+ ZSTD_storeSeq(seqStore, 0, anchor, 0, repLength2-MINMATCH);
+ hashSmall[ZSTD_hashPtr(ip, hBitsS, mls)] = current2;
+ hashLong[ZSTD_hashPtr(ip, hBitsL, 8)] = current2;
+ ip += repLength2;
+ anchor = ip;
+ continue;
+ }
+ break;
+ } } }
+
+ /* save reps for next block */
+ rep[0] = offset_1;
+ rep[1] = offset_2;
+
+ /* Return the last literals size */
+ return iend - anchor;
+}
+
+
+size_t ZSTD_compressBlock_doubleFast_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ U32 const mls = ms->cParams.minMatch;
+ switch(mls)
+ {
+ default: /* includes case 3 */
+ case 4 :
+ return ZSTD_compressBlock_doubleFast_extDict_generic(ms, seqStore, rep, src, srcSize, 4);
+ case 5 :
+ return ZSTD_compressBlock_doubleFast_extDict_generic(ms, seqStore, rep, src, srcSize, 5);
+ case 6 :
+ return ZSTD_compressBlock_doubleFast_extDict_generic(ms, seqStore, rep, src, srcSize, 6);
+ case 7 :
+ return ZSTD_compressBlock_doubleFast_extDict_generic(ms, seqStore, rep, src, srcSize, 7);
+ }
+}
diff --git a/Utilities/cmzstd/lib/compress/zstd_double_fast.h b/Utilities/cmzstd/lib/compress/zstd_double_fast.h
new file mode 100644
index 000000000..4fa31acfc
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstd_double_fast.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef ZSTD_DOUBLE_FAST_H
+#define ZSTD_DOUBLE_FAST_H
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#include "mem.h" /* U32 */
+#include "zstd_compress_internal.h" /* ZSTD_CCtx, size_t */
+
+void ZSTD_fillDoubleHashTable(ZSTD_matchState_t* ms,
+ void const* end, ZSTD_dictTableLoadMethod_e dtlm);
+size_t ZSTD_compressBlock_doubleFast(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_doubleFast_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_doubleFast_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* ZSTD_DOUBLE_FAST_H */
diff --git a/Utilities/cmzstd/lib/compress/zstd_fast.c b/Utilities/cmzstd/lib/compress/zstd_fast.c
new file mode 100644
index 000000000..40ba0f73e
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstd_fast.c
@@ -0,0 +1,391 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#include "zstd_compress_internal.h"
+#include "zstd_fast.h"
+
+
+void ZSTD_fillHashTable(ZSTD_matchState_t* ms,
+ void const* end, ZSTD_dictTableLoadMethod_e dtlm)
+{
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+ U32* const hashTable = ms->hashTable;
+ U32 const hBits = cParams->hashLog;
+ U32 const mls = cParams->minMatch;
+ const BYTE* const base = ms->window.base;
+ const BYTE* ip = base + ms->nextToUpdate;
+ const BYTE* const iend = ((const BYTE*)end) - HASH_READ_SIZE;
+ const U32 fastHashFillStep = 3;
+
+ /* Always insert every fastHashFillStep position into the hash table.
+ * Insert the other positions if their hash entry is empty.
+ */
+ for ( ; ip + fastHashFillStep < iend + 2; ip += fastHashFillStep) {
+ U32 const current = (U32)(ip - base);
+ size_t const hash0 = ZSTD_hashPtr(ip, hBits, mls);
+ hashTable[hash0] = current;
+ if (dtlm == ZSTD_dtlm_fast) continue;
+ /* Only load extra positions for ZSTD_dtlm_full */
+ { U32 p;
+ for (p = 1; p < fastHashFillStep; ++p) {
+ size_t const hash = ZSTD_hashPtr(ip + p, hBits, mls);
+ if (hashTable[hash] == 0) { /* not yet filled */
+ hashTable[hash] = current + p;
+ } } } }
+}
+
+FORCE_INLINE_TEMPLATE
+size_t ZSTD_compressBlock_fast_generic(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize,
+ U32 const mls, ZSTD_dictMode_e const dictMode)
+{
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+ U32* const hashTable = ms->hashTable;
+ U32 const hlog = cParams->hashLog;
+ /* support stepSize of 0 */
+ U32 const stepSize = cParams->targetLength + !(cParams->targetLength);
+ const BYTE* const base = ms->window.base;
+ const BYTE* const istart = (const BYTE*)src;
+ const BYTE* ip = istart;
+ const BYTE* anchor = istart;
+ const U32 prefixStartIndex = ms->window.dictLimit;
+ const BYTE* const prefixStart = base + prefixStartIndex;
+ const BYTE* const iend = istart + srcSize;
+ const BYTE* const ilimit = iend - HASH_READ_SIZE;
+ U32 offset_1=rep[0], offset_2=rep[1];
+ U32 offsetSaved = 0;
+
+ const ZSTD_matchState_t* const dms = ms->dictMatchState;
+ const ZSTD_compressionParameters* const dictCParams =
+ dictMode == ZSTD_dictMatchState ?
+ &dms->cParams : NULL;
+ const U32* const dictHashTable = dictMode == ZSTD_dictMatchState ?
+ dms->hashTable : NULL;
+ const U32 dictStartIndex = dictMode == ZSTD_dictMatchState ?
+ dms->window.dictLimit : 0;
+ const BYTE* const dictBase = dictMode == ZSTD_dictMatchState ?
+ dms->window.base : NULL;
+ const BYTE* const dictStart = dictMode == ZSTD_dictMatchState ?
+ dictBase + dictStartIndex : NULL;
+ const BYTE* const dictEnd = dictMode == ZSTD_dictMatchState ?
+ dms->window.nextSrc : NULL;
+ const U32 dictIndexDelta = dictMode == ZSTD_dictMatchState ?
+ prefixStartIndex - (U32)(dictEnd - dictBase) :
+ 0;
+ const U32 dictAndPrefixLength = (U32)(ip - prefixStart + dictEnd - dictStart);
+ const U32 dictHLog = dictMode == ZSTD_dictMatchState ?
+ dictCParams->hashLog : hlog;
+
+ assert(dictMode == ZSTD_noDict || dictMode == ZSTD_dictMatchState);
+
+ /* otherwise, we would get index underflow when translating a dict index
+ * into a local index */
+ assert(dictMode != ZSTD_dictMatchState
+ || prefixStartIndex >= (U32)(dictEnd - dictBase));
+
+ /* init */
+ ip += (dictAndPrefixLength == 0);
+ if (dictMode == ZSTD_noDict) {
+ U32 const maxRep = (U32)(ip - prefixStart);
+ if (offset_2 > maxRep) offsetSaved = offset_2, offset_2 = 0;
+ if (offset_1 > maxRep) offsetSaved = offset_1, offset_1 = 0;
+ }
+ if (dictMode == ZSTD_dictMatchState) {
+ /* dictMatchState repCode checks don't currently handle repCode == 0
+ * disabling. */
+ assert(offset_1 <= dictAndPrefixLength);
+ assert(offset_2 <= dictAndPrefixLength);
+ }
+
+ /* Main Search Loop */
+ while (ip < ilimit) { /* < instead of <=, because repcode check at (ip+1) */
+ size_t mLength;
+ size_t const h = ZSTD_hashPtr(ip, hlog, mls);
+ U32 const current = (U32)(ip-base);
+ U32 const matchIndex = hashTable[h];
+ const BYTE* match = base + matchIndex;
+ const U32 repIndex = current + 1 - offset_1;
+ const BYTE* repMatch = (dictMode == ZSTD_dictMatchState
+ && repIndex < prefixStartIndex) ?
+ dictBase + (repIndex - dictIndexDelta) :
+ base + repIndex;
+ hashTable[h] = current; /* update hash table */
+
+ if ( (dictMode == ZSTD_dictMatchState)
+ && ((U32)((prefixStartIndex-1) - repIndex) >= 3) /* intentional underflow : ensure repIndex isn't overlapping dict + prefix */
+ && (MEM_read32(repMatch) == MEM_read32(ip+1)) ) {
+ const BYTE* const repMatchEnd = repIndex < prefixStartIndex ? dictEnd : iend;
+ mLength = ZSTD_count_2segments(ip+1+4, repMatch+4, iend, repMatchEnd, prefixStart) + 4;
+ ip++;
+ ZSTD_storeSeq(seqStore, ip-anchor, anchor, 0, mLength-MINMATCH);
+ } else if ( dictMode == ZSTD_noDict
+ && ((offset_1 > 0) & (MEM_read32(ip+1-offset_1) == MEM_read32(ip+1)))) {
+ mLength = ZSTD_count(ip+1+4, ip+1+4-offset_1, iend) + 4;
+ ip++;
+ ZSTD_storeSeq(seqStore, ip-anchor, anchor, 0, mLength-MINMATCH);
+ } else if ( (matchIndex <= prefixStartIndex) ) {
+ if (dictMode == ZSTD_dictMatchState) {
+ size_t const dictHash = ZSTD_hashPtr(ip, dictHLog, mls);
+ U32 const dictMatchIndex = dictHashTable[dictHash];
+ const BYTE* dictMatch = dictBase + dictMatchIndex;
+ if (dictMatchIndex <= dictStartIndex ||
+ MEM_read32(dictMatch) != MEM_read32(ip)) {
+ assert(stepSize >= 1);
+ ip += ((ip-anchor) >> kSearchStrength) + stepSize;
+ continue;
+ } else {
+ /* found a dict match */
+ U32 const offset = (U32)(current-dictMatchIndex-dictIndexDelta);
+ mLength = ZSTD_count_2segments(ip+4, dictMatch+4, iend, dictEnd, prefixStart) + 4;
+ while (((ip>anchor) & (dictMatch>dictStart))
+ && (ip[-1] == dictMatch[-1])) {
+ ip--; dictMatch--; mLength++;
+ } /* catch up */
+ offset_2 = offset_1;
+ offset_1 = offset;
+ ZSTD_storeSeq(seqStore, ip-anchor, anchor, offset + ZSTD_REP_MOVE, mLength-MINMATCH);
+ }
+ } else {
+ assert(stepSize >= 1);
+ ip += ((ip-anchor) >> kSearchStrength) + stepSize;
+ continue;
+ }
+ } else if (MEM_read32(match) != MEM_read32(ip)) {
+ /* it's not a match, and we're not going to check the dictionary */
+ assert(stepSize >= 1);
+ ip += ((ip-anchor) >> kSearchStrength) + stepSize;
+ continue;
+ } else {
+ /* found a regular match */
+ U32 const offset = (U32)(ip-match);
+ mLength = ZSTD_count(ip+4, match+4, iend) + 4;
+ while (((ip>anchor) & (match>prefixStart))
+ && (ip[-1] == match[-1])) { ip--; match--; mLength++; } /* catch up */
+ offset_2 = offset_1;
+ offset_1 = offset;
+ ZSTD_storeSeq(seqStore, ip-anchor, anchor, offset + ZSTD_REP_MOVE, mLength-MINMATCH);
+ }
+
+ /* match found */
+ ip += mLength;
+ anchor = ip;
+
+ if (ip <= ilimit) {
+ /* Fill Table */
+ assert(base+current+2 > istart); /* check base overflow */
+ hashTable[ZSTD_hashPtr(base+current+2, hlog, mls)] = current+2; /* here because current+2 could be > iend-8 */
+ hashTable[ZSTD_hashPtr(ip-2, hlog, mls)] = (U32)(ip-2-base);
+
+ /* check immediate repcode */
+ if (dictMode == ZSTD_dictMatchState) {
+ while (ip <= ilimit) {
+ U32 const current2 = (U32)(ip-base);
+ U32 const repIndex2 = current2 - offset_2;
+ const BYTE* repMatch2 = repIndex2 < prefixStartIndex ?
+ dictBase - dictIndexDelta + repIndex2 :
+ base + repIndex2;
+ if ( ((U32)((prefixStartIndex-1) - (U32)repIndex2) >= 3 /* intentional overflow */)
+ && (MEM_read32(repMatch2) == MEM_read32(ip)) ) {
+ const BYTE* const repEnd2 = repIndex2 < prefixStartIndex ? dictEnd : iend;
+ size_t const repLength2 = ZSTD_count_2segments(ip+4, repMatch2+4, iend, repEnd2, prefixStart) + 4;
+ U32 tmpOffset = offset_2; offset_2 = offset_1; offset_1 = tmpOffset; /* swap offset_2 <=> offset_1 */
+ ZSTD_storeSeq(seqStore, 0, anchor, 0, repLength2-MINMATCH);
+ hashTable[ZSTD_hashPtr(ip, hlog, mls)] = current2;
+ ip += repLength2;
+ anchor = ip;
+ continue;
+ }
+ break;
+ }
+ }
+
+ if (dictMode == ZSTD_noDict) {
+ while ( (ip <= ilimit)
+ && ( (offset_2>0)
+ & (MEM_read32(ip) == MEM_read32(ip - offset_2)) )) {
+ /* store sequence */
+ size_t const rLength = ZSTD_count(ip+4, ip+4-offset_2, iend) + 4;
+ U32 const tmpOff = offset_2; offset_2 = offset_1; offset_1 = tmpOff; /* swap offset_2 <=> offset_1 */
+ hashTable[ZSTD_hashPtr(ip, hlog, mls)] = (U32)(ip-base);
+ ZSTD_storeSeq(seqStore, 0, anchor, 0, rLength-MINMATCH);
+ ip += rLength;
+ anchor = ip;
+ continue; /* faster when present ... (?) */
+ } } } }
+
+ /* save reps for next block */
+ rep[0] = offset_1 ? offset_1 : offsetSaved;
+ rep[1] = offset_2 ? offset_2 : offsetSaved;
+
+ /* Return the last literals size */
+ return iend - anchor;
+}
+
+
+size_t ZSTD_compressBlock_fast(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ ZSTD_compressionParameters const* cParams = &ms->cParams;
+ U32 const mls = cParams->minMatch;
+ assert(ms->dictMatchState == NULL);
+ switch(mls)
+ {
+ default: /* includes case 3 */
+ case 4 :
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, 4, ZSTD_noDict);
+ case 5 :
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, 5, ZSTD_noDict);
+ case 6 :
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, 6, ZSTD_noDict);
+ case 7 :
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, 7, ZSTD_noDict);
+ }
+}
+
+size_t ZSTD_compressBlock_fast_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ ZSTD_compressionParameters const* cParams = &ms->cParams;
+ U32 const mls = cParams->minMatch;
+ assert(ms->dictMatchState != NULL);
+ switch(mls)
+ {
+ default: /* includes case 3 */
+ case 4 :
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, 4, ZSTD_dictMatchState);
+ case 5 :
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, 5, ZSTD_dictMatchState);
+ case 6 :
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, 6, ZSTD_dictMatchState);
+ case 7 :
+ return ZSTD_compressBlock_fast_generic(ms, seqStore, rep, src, srcSize, 7, ZSTD_dictMatchState);
+ }
+}
+
+
+static size_t ZSTD_compressBlock_fast_extDict_generic(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize, U32 const mls)
+{
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+ U32* const hashTable = ms->hashTable;
+ U32 const hlog = cParams->hashLog;
+ /* support stepSize of 0 */
+ U32 const stepSize = cParams->targetLength + !(cParams->targetLength);
+ const BYTE* const base = ms->window.base;
+ const BYTE* const dictBase = ms->window.dictBase;
+ const BYTE* const istart = (const BYTE*)src;
+ const BYTE* ip = istart;
+ const BYTE* anchor = istart;
+ const U32 dictStartIndex = ms->window.lowLimit;
+ const BYTE* const dictStart = dictBase + dictStartIndex;
+ const U32 prefixStartIndex = ms->window.dictLimit;
+ const BYTE* const prefixStart = base + prefixStartIndex;
+ const BYTE* const dictEnd = dictBase + prefixStartIndex;
+ const BYTE* const iend = istart + srcSize;
+ const BYTE* const ilimit = iend - 8;
+ U32 offset_1=rep[0], offset_2=rep[1];
+
+ /* Search Loop */
+ while (ip < ilimit) { /* < instead of <=, because (ip+1) */
+ const size_t h = ZSTD_hashPtr(ip, hlog, mls);
+ const U32 matchIndex = hashTable[h];
+ const BYTE* const matchBase = matchIndex < prefixStartIndex ? dictBase : base;
+ const BYTE* match = matchBase + matchIndex;
+ const U32 current = (U32)(ip-base);
+ const U32 repIndex = current + 1 - offset_1;
+ const BYTE* const repBase = repIndex < prefixStartIndex ? dictBase : base;
+ const BYTE* const repMatch = repBase + repIndex;
+ size_t mLength;
+ hashTable[h] = current; /* update hash table */
+ assert(offset_1 <= current +1); /* check repIndex */
+
+ if ( (((U32)((prefixStartIndex-1) - repIndex) >= 3) /* intentional underflow */ & (repIndex > dictStartIndex))
+ && (MEM_read32(repMatch) == MEM_read32(ip+1)) ) {
+ const BYTE* repMatchEnd = repIndex < prefixStartIndex ? dictEnd : iend;
+ mLength = ZSTD_count_2segments(ip+1+4, repMatch+4, iend, repMatchEnd, prefixStart) + 4;
+ ip++;
+ ZSTD_storeSeq(seqStore, ip-anchor, anchor, 0, mLength-MINMATCH);
+ } else {
+ if ( (matchIndex < dictStartIndex) ||
+ (MEM_read32(match) != MEM_read32(ip)) ) {
+ assert(stepSize >= 1);
+ ip += ((ip-anchor) >> kSearchStrength) + stepSize;
+ continue;
+ }
+ { const BYTE* matchEnd = matchIndex < prefixStartIndex ? dictEnd : iend;
+ const BYTE* lowMatchPtr = matchIndex < prefixStartIndex ? dictStart : prefixStart;
+ U32 offset;
+ mLength = ZSTD_count_2segments(ip+4, match+4, iend, matchEnd, prefixStart) + 4;
+ while (((ip>anchor) & (match>lowMatchPtr)) && (ip[-1] == match[-1])) { ip--; match--; mLength++; } /* catch up */
+ offset = current - matchIndex;
+ offset_2 = offset_1;
+ offset_1 = offset;
+ ZSTD_storeSeq(seqStore, ip-anchor, anchor, offset + ZSTD_REP_MOVE, mLength-MINMATCH);
+ } }
+
+ /* found a match : store it */
+ ip += mLength;
+ anchor = ip;
+
+ if (ip <= ilimit) {
+ /* Fill Table */
+ hashTable[ZSTD_hashPtr(base+current+2, hlog, mls)] = current+2;
+ hashTable[ZSTD_hashPtr(ip-2, hlog, mls)] = (U32)(ip-2-base);
+ /* check immediate repcode */
+ while (ip <= ilimit) {
+ U32 const current2 = (U32)(ip-base);
+ U32 const repIndex2 = current2 - offset_2;
+ const BYTE* repMatch2 = repIndex2 < prefixStartIndex ? dictBase + repIndex2 : base + repIndex2;
+ if ( (((U32)((prefixStartIndex-1) - repIndex2) >= 3) & (repIndex2 > dictStartIndex)) /* intentional overflow */
+ && (MEM_read32(repMatch2) == MEM_read32(ip)) ) {
+ const BYTE* const repEnd2 = repIndex2 < prefixStartIndex ? dictEnd : iend;
+ size_t const repLength2 = ZSTD_count_2segments(ip+4, repMatch2+4, iend, repEnd2, prefixStart) + 4;
+ U32 tmpOffset = offset_2; offset_2 = offset_1; offset_1 = tmpOffset; /* swap offset_2 <=> offset_1 */
+ ZSTD_storeSeq(seqStore, 0, anchor, 0, repLength2-MINMATCH);
+ hashTable[ZSTD_hashPtr(ip, hlog, mls)] = current2;
+ ip += repLength2;
+ anchor = ip;
+ continue;
+ }
+ break;
+ } } }
+
+ /* save reps for next block */
+ rep[0] = offset_1;
+ rep[1] = offset_2;
+
+ /* Return the last literals size */
+ return iend - anchor;
+}
+
+
+size_t ZSTD_compressBlock_fast_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ ZSTD_compressionParameters const* cParams = &ms->cParams;
+ U32 const mls = cParams->minMatch;
+ switch(mls)
+ {
+ default: /* includes case 3 */
+ case 4 :
+ return ZSTD_compressBlock_fast_extDict_generic(ms, seqStore, rep, src, srcSize, 4);
+ case 5 :
+ return ZSTD_compressBlock_fast_extDict_generic(ms, seqStore, rep, src, srcSize, 5);
+ case 6 :
+ return ZSTD_compressBlock_fast_extDict_generic(ms, seqStore, rep, src, srcSize, 6);
+ case 7 :
+ return ZSTD_compressBlock_fast_extDict_generic(ms, seqStore, rep, src, srcSize, 7);
+ }
+}
diff --git a/Utilities/cmzstd/lib/compress/zstd_fast.h b/Utilities/cmzstd/lib/compress/zstd_fast.h
new file mode 100644
index 000000000..b74a88c57
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstd_fast.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef ZSTD_FAST_H
+#define ZSTD_FAST_H
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#include "mem.h" /* U32 */
+#include "zstd_compress_internal.h"
+
+void ZSTD_fillHashTable(ZSTD_matchState_t* ms,
+ void const* end, ZSTD_dictTableLoadMethod_e dtlm);
+size_t ZSTD_compressBlock_fast(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_fast_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_fast_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* ZSTD_FAST_H */
diff --git a/Utilities/cmzstd/lib/compress/zstd_lazy.c b/Utilities/cmzstd/lib/compress/zstd_lazy.c
new file mode 100644
index 000000000..53f998a43
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstd_lazy.c
@@ -0,0 +1,1106 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#include "zstd_compress_internal.h"
+#include "zstd_lazy.h"
+
+
+/*-*************************************
+* Binary Tree search
+***************************************/
+
+static void
+ZSTD_updateDUBT(ZSTD_matchState_t* ms,
+ const BYTE* ip, const BYTE* iend,
+ U32 mls)
+{
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+ U32* const hashTable = ms->hashTable;
+ U32 const hashLog = cParams->hashLog;
+
+ U32* const bt = ms->chainTable;
+ U32 const btLog = cParams->chainLog - 1;
+ U32 const btMask = (1 << btLog) - 1;
+
+ const BYTE* const base = ms->window.base;
+ U32 const target = (U32)(ip - base);
+ U32 idx = ms->nextToUpdate;
+
+ if (idx != target)
+ DEBUGLOG(7, "ZSTD_updateDUBT, from %u to %u (dictLimit:%u)",
+ idx, target, ms->window.dictLimit);
+ assert(ip + 8 <= iend); /* condition for ZSTD_hashPtr */
+ (void)iend;
+
+ assert(idx >= ms->window.dictLimit); /* condition for valid base+idx */
+ for ( ; idx < target ; idx++) {
+ size_t const h = ZSTD_hashPtr(base + idx, hashLog, mls); /* assumption : ip + 8 <= iend */
+ U32 const matchIndex = hashTable[h];
+
+ U32* const nextCandidatePtr = bt + 2*(idx&btMask);
+ U32* const sortMarkPtr = nextCandidatePtr + 1;
+
+ DEBUGLOG(8, "ZSTD_updateDUBT: insert %u", idx);
+ hashTable[h] = idx; /* Update Hash Table */
+ *nextCandidatePtr = matchIndex; /* update BT like a chain */
+ *sortMarkPtr = ZSTD_DUBT_UNSORTED_MARK;
+ }
+ ms->nextToUpdate = target;
+}
+
+
+/** ZSTD_insertDUBT1() :
+ * sort one already inserted but unsorted position
+ * assumption : current >= btlow == (current - btmask)
+ * doesn't fail */
+static void
+ZSTD_insertDUBT1(ZSTD_matchState_t* ms,
+ U32 current, const BYTE* inputEnd,
+ U32 nbCompares, U32 btLow,
+ const ZSTD_dictMode_e dictMode)
+{
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+ U32* const bt = ms->chainTable;
+ U32 const btLog = cParams->chainLog - 1;
+ U32 const btMask = (1 << btLog) - 1;
+ size_t commonLengthSmaller=0, commonLengthLarger=0;
+ const BYTE* const base = ms->window.base;
+ const BYTE* const dictBase = ms->window.dictBase;
+ const U32 dictLimit = ms->window.dictLimit;
+ const BYTE* const ip = (current>=dictLimit) ? base + current : dictBase + current;
+ const BYTE* const iend = (current>=dictLimit) ? inputEnd : dictBase + dictLimit;
+ const BYTE* const dictEnd = dictBase + dictLimit;
+ const BYTE* const prefixStart = base + dictLimit;
+ const BYTE* match;
+ U32* smallerPtr = bt + 2*(current&btMask);
+ U32* largerPtr = smallerPtr + 1;
+ U32 matchIndex = *smallerPtr; /* this candidate is unsorted : next sorted candidate is reached through *smallerPtr, while *largerPtr contains previous unsorted candidate (which is already saved and can be overwritten) */
+ U32 dummy32; /* to be nullified at the end */
+ U32 const windowLow = ms->window.lowLimit;
+
+ DEBUGLOG(8, "ZSTD_insertDUBT1(%u) (dictLimit=%u, lowLimit=%u)",
+ current, dictLimit, windowLow);
+ assert(current >= btLow);
+ assert(ip < iend); /* condition for ZSTD_count */
+
+ while (nbCompares-- && (matchIndex > windowLow)) {
+ U32* const nextPtr = bt + 2*(matchIndex & btMask);
+ size_t matchLength = MIN(commonLengthSmaller, commonLengthLarger); /* guaranteed minimum nb of common bytes */
+ assert(matchIndex < current);
+ /* note : all candidates are now supposed sorted,
+ * but it's still possible to have nextPtr[1] == ZSTD_DUBT_UNSORTED_MARK
+ * when a real index has the same value as ZSTD_DUBT_UNSORTED_MARK */
+
+ if ( (dictMode != ZSTD_extDict)
+ || (matchIndex+matchLength >= dictLimit) /* both in current segment*/
+ || (current < dictLimit) /* both in extDict */) {
+ const BYTE* const mBase = ( (dictMode != ZSTD_extDict)
+ || (matchIndex+matchLength >= dictLimit)) ?
+ base : dictBase;
+ assert( (matchIndex+matchLength >= dictLimit) /* might be wrong if extDict is incorrectly set to 0 */
+ || (current < dictLimit) );
+ match = mBase + matchIndex;
+ matchLength += ZSTD_count(ip+matchLength, match+matchLength, iend);
+ } else {
+ match = dictBase + matchIndex;
+ matchLength += ZSTD_count_2segments(ip+matchLength, match+matchLength, iend, dictEnd, prefixStart);
+ if (matchIndex+matchLength >= dictLimit)
+ match = base + matchIndex; /* preparation for next read of match[matchLength] */
+ }
+
+ DEBUGLOG(8, "ZSTD_insertDUBT1: comparing %u with %u : found %u common bytes ",
+ current, matchIndex, (U32)matchLength);
+
+ if (ip+matchLength == iend) { /* equal : no way to know if inf or sup */
+ break; /* drop , to guarantee consistency ; miss a bit of compression, but other solutions can corrupt tree */
+ }
+
+ if (match[matchLength] < ip[matchLength]) { /* necessarily within buffer */
+ /* match is smaller than current */
+ *smallerPtr = matchIndex; /* update smaller idx */
+ commonLengthSmaller = matchLength; /* all smaller will now have at least this guaranteed common length */
+ if (matchIndex <= btLow) { smallerPtr=&dummy32; break; } /* beyond tree size, stop searching */
+ DEBUGLOG(8, "ZSTD_insertDUBT1: %u (>btLow=%u) is smaller : next => %u",
+ matchIndex, btLow, nextPtr[1]);
+ smallerPtr = nextPtr+1; /* new "candidate" => larger than match, which was smaller than target */
+ matchIndex = nextPtr[1]; /* new matchIndex, larger than previous and closer to current */
+ } else {
+ /* match is larger than current */
+ *largerPtr = matchIndex;
+ commonLengthLarger = matchLength;
+ if (matchIndex <= btLow) { largerPtr=&dummy32; break; } /* beyond tree size, stop searching */
+ DEBUGLOG(8, "ZSTD_insertDUBT1: %u (>btLow=%u) is larger => %u",
+ matchIndex, btLow, nextPtr[0]);
+ largerPtr = nextPtr;
+ matchIndex = nextPtr[0];
+ } }
+
+ *smallerPtr = *largerPtr = 0;
+}
+
+
+static size_t
+ZSTD_DUBT_findBetterDictMatch (
+ ZSTD_matchState_t* ms,
+ const BYTE* const ip, const BYTE* const iend,
+ size_t* offsetPtr,
+ size_t bestLength,
+ U32 nbCompares,
+ U32 const mls,
+ const ZSTD_dictMode_e dictMode)
+{
+ const ZSTD_matchState_t * const dms = ms->dictMatchState;
+ const ZSTD_compressionParameters* const dmsCParams = &dms->cParams;
+ const U32 * const dictHashTable = dms->hashTable;
+ U32 const hashLog = dmsCParams->hashLog;
+ size_t const h = ZSTD_hashPtr(ip, hashLog, mls);
+ U32 dictMatchIndex = dictHashTable[h];
+
+ const BYTE* const base = ms->window.base;
+ const BYTE* const prefixStart = base + ms->window.dictLimit;
+ U32 const current = (U32)(ip-base);
+ const BYTE* const dictBase = dms->window.base;
+ const BYTE* const dictEnd = dms->window.nextSrc;
+ U32 const dictHighLimit = (U32)(dms->window.nextSrc - dms->window.base);
+ U32 const dictLowLimit = dms->window.lowLimit;
+ U32 const dictIndexDelta = ms->window.lowLimit - dictHighLimit;
+
+ U32* const dictBt = dms->chainTable;
+ U32 const btLog = dmsCParams->chainLog - 1;
+ U32 const btMask = (1 << btLog) - 1;
+ U32 const btLow = (btMask >= dictHighLimit - dictLowLimit) ? dictLowLimit : dictHighLimit - btMask;
+
+ size_t commonLengthSmaller=0, commonLengthLarger=0;
+
+ (void)dictMode;
+ assert(dictMode == ZSTD_dictMatchState);
+
+ while (nbCompares-- && (dictMatchIndex > dictLowLimit)) {
+ U32* const nextPtr = dictBt + 2*(dictMatchIndex & btMask);
+ size_t matchLength = MIN(commonLengthSmaller, commonLengthLarger); /* guaranteed minimum nb of common bytes */
+ const BYTE* match = dictBase + dictMatchIndex;
+ matchLength += ZSTD_count_2segments(ip+matchLength, match+matchLength, iend, dictEnd, prefixStart);
+ if (dictMatchIndex+matchLength >= dictHighLimit)
+ match = base + dictMatchIndex + dictIndexDelta; /* to prepare for next usage of match[matchLength] */
+
+ if (matchLength > bestLength) {
+ U32 matchIndex = dictMatchIndex + dictIndexDelta;
+ if ( (4*(int)(matchLength-bestLength)) > (int)(ZSTD_highbit32(current-matchIndex+1) - ZSTD_highbit32((U32)offsetPtr[0]+1)) ) {
+ DEBUGLOG(9, "ZSTD_DUBT_findBetterDictMatch(%u) : found better match length %u -> %u and offsetCode %u -> %u (dictMatchIndex %u, matchIndex %u)",
+ current, (U32)bestLength, (U32)matchLength, (U32)*offsetPtr, ZSTD_REP_MOVE + current - matchIndex, dictMatchIndex, matchIndex);
+ bestLength = matchLength, *offsetPtr = ZSTD_REP_MOVE + current - matchIndex;
+ }
+ if (ip+matchLength == iend) { /* reached end of input : ip[matchLength] is not valid, no way to know if it's larger or smaller than match */
+ break; /* drop, to guarantee consistency (miss a little bit of compression) */
+ }
+ }
+
+ if (match[matchLength] < ip[matchLength]) {
+ if (dictMatchIndex <= btLow) { break; } /* beyond tree size, stop the search */
+ commonLengthSmaller = matchLength; /* all smaller will now have at least this guaranteed common length */
+ dictMatchIndex = nextPtr[1]; /* new matchIndex larger than previous (closer to current) */
+ } else {
+ /* match is larger than current */
+ if (dictMatchIndex <= btLow) { break; } /* beyond tree size, stop the search */
+ commonLengthLarger = matchLength;
+ dictMatchIndex = nextPtr[0];
+ }
+ }
+
+ if (bestLength >= MINMATCH) {
+ U32 const mIndex = current - ((U32)*offsetPtr - ZSTD_REP_MOVE); (void)mIndex;
+ DEBUGLOG(8, "ZSTD_DUBT_findBetterDictMatch(%u) : found match of length %u and offsetCode %u (pos %u)",
+ current, (U32)bestLength, (U32)*offsetPtr, mIndex);
+ }
+ return bestLength;
+
+}
+
+
+static size_t
+ZSTD_DUBT_findBestMatch(ZSTD_matchState_t* ms,
+ const BYTE* const ip, const BYTE* const iend,
+ size_t* offsetPtr,
+ U32 const mls,
+ const ZSTD_dictMode_e dictMode)
+{
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+ U32* const hashTable = ms->hashTable;
+ U32 const hashLog = cParams->hashLog;
+ size_t const h = ZSTD_hashPtr(ip, hashLog, mls);
+ U32 matchIndex = hashTable[h];
+
+ const BYTE* const base = ms->window.base;
+ U32 const current = (U32)(ip-base);
+ U32 const windowLow = ms->window.lowLimit;
+
+ U32* const bt = ms->chainTable;
+ U32 const btLog = cParams->chainLog - 1;
+ U32 const btMask = (1 << btLog) - 1;
+ U32 const btLow = (btMask >= current) ? 0 : current - btMask;
+ U32 const unsortLimit = MAX(btLow, windowLow);
+
+ U32* nextCandidate = bt + 2*(matchIndex&btMask);
+ U32* unsortedMark = bt + 2*(matchIndex&btMask) + 1;
+ U32 nbCompares = 1U << cParams->searchLog;
+ U32 nbCandidates = nbCompares;
+ U32 previousCandidate = 0;
+
+ DEBUGLOG(7, "ZSTD_DUBT_findBestMatch (%u) ", current);
+ assert(ip <= iend-8); /* required for h calculation */
+
+ /* reach end of unsorted candidates list */
+ while ( (matchIndex > unsortLimit)
+ && (*unsortedMark == ZSTD_DUBT_UNSORTED_MARK)
+ && (nbCandidates > 1) ) {
+ DEBUGLOG(8, "ZSTD_DUBT_findBestMatch: candidate %u is unsorted",
+ matchIndex);
+ *unsortedMark = previousCandidate; /* the unsortedMark becomes a reversed chain, to move up back to original position */
+ previousCandidate = matchIndex;
+ matchIndex = *nextCandidate;
+ nextCandidate = bt + 2*(matchIndex&btMask);
+ unsortedMark = bt + 2*(matchIndex&btMask) + 1;
+ nbCandidates --;
+ }
+
+ /* nullify last candidate if it's still unsorted
+ * simplification, detrimental to compression ratio, beneficial for speed */
+ if ( (matchIndex > unsortLimit)
+ && (*unsortedMark==ZSTD_DUBT_UNSORTED_MARK) ) {
+ DEBUGLOG(7, "ZSTD_DUBT_findBestMatch: nullify last unsorted candidate %u",
+ matchIndex);
+ *nextCandidate = *unsortedMark = 0;
+ }
+
+ /* batch sort stacked candidates */
+ matchIndex = previousCandidate;
+ while (matchIndex) { /* will end on matchIndex == 0 */
+ U32* const nextCandidateIdxPtr = bt + 2*(matchIndex&btMask) + 1;
+ U32 const nextCandidateIdx = *nextCandidateIdxPtr;
+ ZSTD_insertDUBT1(ms, matchIndex, iend,
+ nbCandidates, unsortLimit, dictMode);
+ matchIndex = nextCandidateIdx;
+ nbCandidates++;
+ }
+
+ /* find longest match */
+ { size_t commonLengthSmaller = 0, commonLengthLarger = 0;
+ const BYTE* const dictBase = ms->window.dictBase;
+ const U32 dictLimit = ms->window.dictLimit;
+ const BYTE* const dictEnd = dictBase + dictLimit;
+ const BYTE* const prefixStart = base + dictLimit;
+ U32* smallerPtr = bt + 2*(current&btMask);
+ U32* largerPtr = bt + 2*(current&btMask) + 1;
+ U32 matchEndIdx = current + 8 + 1;
+ U32 dummy32; /* to be nullified at the end */
+ size_t bestLength = 0;
+
+ matchIndex = hashTable[h];
+ hashTable[h] = current; /* Update Hash Table */
+
+ while (nbCompares-- && (matchIndex > windowLow)) {
+ U32* const nextPtr = bt + 2*(matchIndex & btMask);
+ size_t matchLength = MIN(commonLengthSmaller, commonLengthLarger); /* guaranteed minimum nb of common bytes */
+ const BYTE* match;
+
+ if ((dictMode != ZSTD_extDict) || (matchIndex+matchLength >= dictLimit)) {
+ match = base + matchIndex;
+ matchLength += ZSTD_count(ip+matchLength, match+matchLength, iend);
+ } else {
+ match = dictBase + matchIndex;
+ matchLength += ZSTD_count_2segments(ip+matchLength, match+matchLength, iend, dictEnd, prefixStart);
+ if (matchIndex+matchLength >= dictLimit)
+ match = base + matchIndex; /* to prepare for next usage of match[matchLength] */
+ }
+
+ if (matchLength > bestLength) {
+ if (matchLength > matchEndIdx - matchIndex)
+ matchEndIdx = matchIndex + (U32)matchLength;
+ if ( (4*(int)(matchLength-bestLength)) > (int)(ZSTD_highbit32(current-matchIndex+1) - ZSTD_highbit32((U32)offsetPtr[0]+1)) )
+ bestLength = matchLength, *offsetPtr = ZSTD_REP_MOVE + current - matchIndex;
+ if (ip+matchLength == iend) { /* equal : no way to know if inf or sup */
+ if (dictMode == ZSTD_dictMatchState) {
+ nbCompares = 0; /* in addition to avoiding checking any
+ * further in this loop, make sure we
+ * skip checking in the dictionary. */
+ }
+ break; /* drop, to guarantee consistency (miss a little bit of compression) */
+ }
+ }
+
+ if (match[matchLength] < ip[matchLength]) {
+ /* match is smaller than current */
+ *smallerPtr = matchIndex; /* update smaller idx */
+ commonLengthSmaller = matchLength; /* all smaller will now have at least this guaranteed common length */
+ if (matchIndex <= btLow) { smallerPtr=&dummy32; break; } /* beyond tree size, stop the search */
+ smallerPtr = nextPtr+1; /* new "smaller" => larger of match */
+ matchIndex = nextPtr[1]; /* new matchIndex larger than previous (closer to current) */
+ } else {
+ /* match is larger than current */
+ *largerPtr = matchIndex;
+ commonLengthLarger = matchLength;
+ if (matchIndex <= btLow) { largerPtr=&dummy32; break; } /* beyond tree size, stop the search */
+ largerPtr = nextPtr;
+ matchIndex = nextPtr[0];
+ } }
+
+ *smallerPtr = *largerPtr = 0;
+
+ if (dictMode == ZSTD_dictMatchState && nbCompares) {
+ bestLength = ZSTD_DUBT_findBetterDictMatch(
+ ms, ip, iend,
+ offsetPtr, bestLength, nbCompares,
+ mls, dictMode);
+ }
+
+ assert(matchEndIdx > current+8); /* ensure nextToUpdate is increased */
+ ms->nextToUpdate = matchEndIdx - 8; /* skip repetitive patterns */
+ if (bestLength >= MINMATCH) {
+ U32 const mIndex = current - ((U32)*offsetPtr - ZSTD_REP_MOVE); (void)mIndex;
+ DEBUGLOG(8, "ZSTD_DUBT_findBestMatch(%u) : found match of length %u and offsetCode %u (pos %u)",
+ current, (U32)bestLength, (U32)*offsetPtr, mIndex);
+ }
+ return bestLength;
+ }
+}
+
+
+/** ZSTD_BtFindBestMatch() : Tree updater, providing best match */
+FORCE_INLINE_TEMPLATE size_t
+ZSTD_BtFindBestMatch( ZSTD_matchState_t* ms,
+ const BYTE* const ip, const BYTE* const iLimit,
+ size_t* offsetPtr,
+ const U32 mls /* template */,
+ const ZSTD_dictMode_e dictMode)
+{
+ DEBUGLOG(7, "ZSTD_BtFindBestMatch");
+ if (ip < ms->window.base + ms->nextToUpdate) return 0; /* skipped area */
+ ZSTD_updateDUBT(ms, ip, iLimit, mls);
+ return ZSTD_DUBT_findBestMatch(ms, ip, iLimit, offsetPtr, mls, dictMode);
+}
+
+
+static size_t
+ZSTD_BtFindBestMatch_selectMLS ( ZSTD_matchState_t* ms,
+ const BYTE* ip, const BYTE* const iLimit,
+ size_t* offsetPtr)
+{
+ switch(ms->cParams.minMatch)
+ {
+ default : /* includes case 3 */
+ case 4 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_noDict);
+ case 5 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_noDict);
+ case 7 :
+ case 6 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_noDict);
+ }
+}
+
+
+static size_t ZSTD_BtFindBestMatch_dictMatchState_selectMLS (
+ ZSTD_matchState_t* ms,
+ const BYTE* ip, const BYTE* const iLimit,
+ size_t* offsetPtr)
+{
+ switch(ms->cParams.minMatch)
+ {
+ default : /* includes case 3 */
+ case 4 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_dictMatchState);
+ case 5 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_dictMatchState);
+ case 7 :
+ case 6 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_dictMatchState);
+ }
+}
+
+
+static size_t ZSTD_BtFindBestMatch_extDict_selectMLS (
+ ZSTD_matchState_t* ms,
+ const BYTE* ip, const BYTE* const iLimit,
+ size_t* offsetPtr)
+{
+ switch(ms->cParams.minMatch)
+ {
+ default : /* includes case 3 */
+ case 4 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 4, ZSTD_extDict);
+ case 5 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 5, ZSTD_extDict);
+ case 7 :
+ case 6 : return ZSTD_BtFindBestMatch(ms, ip, iLimit, offsetPtr, 6, ZSTD_extDict);
+ }
+}
+
+
+
+/* *********************************
+* Hash Chain
+***********************************/
+#define NEXT_IN_CHAIN(d, mask) chainTable[(d) & (mask)]
+
+/* Update chains up to ip (excluded)
+ Assumption : always within prefix (i.e. not within extDict) */
+static U32 ZSTD_insertAndFindFirstIndex_internal(
+ ZSTD_matchState_t* ms,
+ const ZSTD_compressionParameters* const cParams,
+ const BYTE* ip, U32 const mls)
+{
+ U32* const hashTable = ms->hashTable;
+ const U32 hashLog = cParams->hashLog;
+ U32* const chainTable = ms->chainTable;
+ const U32 chainMask = (1 << cParams->chainLog) - 1;
+ const BYTE* const base = ms->window.base;
+ const U32 target = (U32)(ip - base);
+ U32 idx = ms->nextToUpdate;
+
+ while(idx < target) { /* catch up */
+ size_t const h = ZSTD_hashPtr(base+idx, hashLog, mls);
+ NEXT_IN_CHAIN(idx, chainMask) = hashTable[h];
+ hashTable[h] = idx;
+ idx++;
+ }
+
+ ms->nextToUpdate = target;
+ return hashTable[ZSTD_hashPtr(ip, hashLog, mls)];
+}
+
+U32 ZSTD_insertAndFindFirstIndex(ZSTD_matchState_t* ms, const BYTE* ip) {
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+ return ZSTD_insertAndFindFirstIndex_internal(ms, cParams, ip, ms->cParams.minMatch);
+}
+
+
+/* inlining is important to hardwire a hot branch (template emulation) */
+FORCE_INLINE_TEMPLATE
+size_t ZSTD_HcFindBestMatch_generic (
+ ZSTD_matchState_t* ms,
+ const BYTE* const ip, const BYTE* const iLimit,
+ size_t* offsetPtr,
+ const U32 mls, const ZSTD_dictMode_e dictMode)
+{
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+ U32* const chainTable = ms->chainTable;
+ const U32 chainSize = (1 << cParams->chainLog);
+ const U32 chainMask = chainSize-1;
+ const BYTE* const base = ms->window.base;
+ const BYTE* const dictBase = ms->window.dictBase;
+ const U32 dictLimit = ms->window.dictLimit;
+ const BYTE* const prefixStart = base + dictLimit;
+ const BYTE* const dictEnd = dictBase + dictLimit;
+ const U32 lowLimit = ms->window.lowLimit;
+ const U32 current = (U32)(ip-base);
+ const U32 minChain = current > chainSize ? current - chainSize : 0;
+ U32 nbAttempts = 1U << cParams->searchLog;
+ size_t ml=4-1;
+
+ /* HC4 match finder */
+ U32 matchIndex = ZSTD_insertAndFindFirstIndex_internal(ms, cParams, ip, mls);
+
+ for ( ; (matchIndex>lowLimit) & (nbAttempts>0) ; nbAttempts--) {
+ size_t currentMl=0;
+ if ((dictMode != ZSTD_extDict) || matchIndex >= dictLimit) {
+ const BYTE* const match = base + matchIndex;
+ assert(matchIndex >= dictLimit); /* ensures this is true if dictMode != ZSTD_extDict */
+ if (match[ml] == ip[ml]) /* potentially better */
+ currentMl = ZSTD_count(ip, match, iLimit);
+ } else {
+ const BYTE* const match = dictBase + matchIndex;
+ assert(match+4 <= dictEnd);
+ if (MEM_read32(match) == MEM_read32(ip)) /* assumption : matchIndex <= dictLimit-4 (by table construction) */
+ currentMl = ZSTD_count_2segments(ip+4, match+4, iLimit, dictEnd, prefixStart) + 4;
+ }
+
+ /* save best solution */
+ if (currentMl > ml) {
+ ml = currentMl;
+ *offsetPtr = current - matchIndex + ZSTD_REP_MOVE;
+ if (ip+currentMl == iLimit) break; /* best possible, avoids read overflow on next attempt */
+ }
+
+ if (matchIndex <= minChain) break;
+ matchIndex = NEXT_IN_CHAIN(matchIndex, chainMask);
+ }
+
+ if (dictMode == ZSTD_dictMatchState) {
+ const ZSTD_matchState_t* const dms = ms->dictMatchState;
+ const U32* const dmsChainTable = dms->chainTable;
+ const U32 dmsChainSize = (1 << dms->cParams.chainLog);
+ const U32 dmsChainMask = dmsChainSize - 1;
+ const U32 dmsLowestIndex = dms->window.dictLimit;
+ const BYTE* const dmsBase = dms->window.base;
+ const BYTE* const dmsEnd = dms->window.nextSrc;
+ const U32 dmsSize = (U32)(dmsEnd - dmsBase);
+ const U32 dmsIndexDelta = dictLimit - dmsSize;
+ const U32 dmsMinChain = dmsSize > dmsChainSize ? dmsSize - dmsChainSize : 0;
+
+ matchIndex = dms->hashTable[ZSTD_hashPtr(ip, dms->cParams.hashLog, mls)];
+
+ for ( ; (matchIndex>dmsLowestIndex) & (nbAttempts>0) ; nbAttempts--) {
+ size_t currentMl=0;
+ const BYTE* const match = dmsBase + matchIndex;
+ assert(match+4 <= dmsEnd);
+ if (MEM_read32(match) == MEM_read32(ip)) /* assumption : matchIndex <= dictLimit-4 (by table construction) */
+ currentMl = ZSTD_count_2segments(ip+4, match+4, iLimit, dmsEnd, prefixStart) + 4;
+
+ /* save best solution */
+ if (currentMl > ml) {
+ ml = currentMl;
+ *offsetPtr = current - (matchIndex + dmsIndexDelta) + ZSTD_REP_MOVE;
+ if (ip+currentMl == iLimit) break; /* best possible, avoids read overflow on next attempt */
+ }
+
+ if (matchIndex <= dmsMinChain) break;
+ matchIndex = dmsChainTable[matchIndex & dmsChainMask];
+ }
+ }
+
+ return ml;
+}
+
+
+FORCE_INLINE_TEMPLATE size_t ZSTD_HcFindBestMatch_selectMLS (
+ ZSTD_matchState_t* ms,
+ const BYTE* ip, const BYTE* const iLimit,
+ size_t* offsetPtr)
+{
+ switch(ms->cParams.minMatch)
+ {
+ default : /* includes case 3 */
+ case 4 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 4, ZSTD_noDict);
+ case 5 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 5, ZSTD_noDict);
+ case 7 :
+ case 6 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 6, ZSTD_noDict);
+ }
+}
+
+
+static size_t ZSTD_HcFindBestMatch_dictMatchState_selectMLS (
+ ZSTD_matchState_t* ms,
+ const BYTE* ip, const BYTE* const iLimit,
+ size_t* offsetPtr)
+{
+ switch(ms->cParams.minMatch)
+ {
+ default : /* includes case 3 */
+ case 4 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 4, ZSTD_dictMatchState);
+ case 5 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 5, ZSTD_dictMatchState);
+ case 7 :
+ case 6 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 6, ZSTD_dictMatchState);
+ }
+}
+
+
+FORCE_INLINE_TEMPLATE size_t ZSTD_HcFindBestMatch_extDict_selectMLS (
+ ZSTD_matchState_t* ms,
+ const BYTE* ip, const BYTE* const iLimit,
+ size_t* offsetPtr)
+{
+ switch(ms->cParams.minMatch)
+ {
+ default : /* includes case 3 */
+ case 4 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 4, ZSTD_extDict);
+ case 5 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 5, ZSTD_extDict);
+ case 7 :
+ case 6 : return ZSTD_HcFindBestMatch_generic(ms, ip, iLimit, offsetPtr, 6, ZSTD_extDict);
+ }
+}
+
+
+/* *******************************
+* Common parser - lazy strategy
+*********************************/
+FORCE_INLINE_TEMPLATE
+size_t ZSTD_compressBlock_lazy_generic(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore,
+ U32 rep[ZSTD_REP_NUM],
+ const void* src, size_t srcSize,
+ const U32 searchMethod, const U32 depth,
+ ZSTD_dictMode_e const dictMode)
+{
+ const BYTE* const istart = (const BYTE*)src;
+ const BYTE* ip = istart;
+ const BYTE* anchor = istart;
+ const BYTE* const iend = istart + srcSize;
+ const BYTE* const ilimit = iend - 8;
+ const BYTE* const base = ms->window.base;
+ const U32 prefixLowestIndex = ms->window.dictLimit;
+ const BYTE* const prefixLowest = base + prefixLowestIndex;
+
+ typedef size_t (*searchMax_f)(
+ ZSTD_matchState_t* ms,
+ const BYTE* ip, const BYTE* iLimit, size_t* offsetPtr);
+ searchMax_f const searchMax = dictMode == ZSTD_dictMatchState ?
+ (searchMethod ? ZSTD_BtFindBestMatch_dictMatchState_selectMLS : ZSTD_HcFindBestMatch_dictMatchState_selectMLS) :
+ (searchMethod ? ZSTD_BtFindBestMatch_selectMLS : ZSTD_HcFindBestMatch_selectMLS);
+ U32 offset_1 = rep[0], offset_2 = rep[1], savedOffset=0;
+
+ const ZSTD_matchState_t* const dms = ms->dictMatchState;
+ const U32 dictLowestIndex = dictMode == ZSTD_dictMatchState ?
+ dms->window.dictLimit : 0;
+ const BYTE* const dictBase = dictMode == ZSTD_dictMatchState ?
+ dms->window.base : NULL;
+ const BYTE* const dictLowest = dictMode == ZSTD_dictMatchState ?
+ dictBase + dictLowestIndex : NULL;
+ const BYTE* const dictEnd = dictMode == ZSTD_dictMatchState ?
+ dms->window.nextSrc : NULL;
+ const U32 dictIndexDelta = dictMode == ZSTD_dictMatchState ?
+ prefixLowestIndex - (U32)(dictEnd - dictBase) :
+ 0;
+ const U32 dictAndPrefixLength = (U32)(ip - prefixLowest + dictEnd - dictLowest);
+
+ /* init */
+ ip += (dictAndPrefixLength == 0);
+ ms->nextToUpdate3 = ms->nextToUpdate;
+ if (dictMode == ZSTD_noDict) {
+ U32 const maxRep = (U32)(ip - prefixLowest);
+ if (offset_2 > maxRep) savedOffset = offset_2, offset_2 = 0;
+ if (offset_1 > maxRep) savedOffset = offset_1, offset_1 = 0;
+ }
+ if (dictMode == ZSTD_dictMatchState) {
+ /* dictMatchState repCode checks don't currently handle repCode == 0
+ * disabling. */
+ assert(offset_1 <= dictAndPrefixLength);
+ assert(offset_2 <= dictAndPrefixLength);
+ }
+
+ /* Match Loop */
+ while (ip < ilimit) {
+ size_t matchLength=0;
+ size_t offset=0;
+ const BYTE* start=ip+1;
+
+ /* check repCode */
+ if (dictMode == ZSTD_dictMatchState) {
+ const U32 repIndex = (U32)(ip - base) + 1 - offset_1;
+ const BYTE* repMatch = (dictMode == ZSTD_dictMatchState
+ && repIndex < prefixLowestIndex) ?
+ dictBase + (repIndex - dictIndexDelta) :
+ base + repIndex;
+ if (((U32)((prefixLowestIndex-1) - repIndex) >= 3 /* intentional underflow */)
+ && (MEM_read32(repMatch) == MEM_read32(ip+1)) ) {
+ const BYTE* repMatchEnd = repIndex < prefixLowestIndex ? dictEnd : iend;
+ matchLength = ZSTD_count_2segments(ip+1+4, repMatch+4, iend, repMatchEnd, prefixLowest) + 4;
+ if (depth==0) goto _storeSequence;
+ }
+ }
+ if ( dictMode == ZSTD_noDict
+ && ((offset_1 > 0) & (MEM_read32(ip+1-offset_1) == MEM_read32(ip+1)))) {
+ matchLength = ZSTD_count(ip+1+4, ip+1+4-offset_1, iend) + 4;
+ if (depth==0) goto _storeSequence;
+ }
+
+ /* first search (depth 0) */
+ { size_t offsetFound = 999999999;
+ size_t const ml2 = searchMax(ms, ip, iend, &offsetFound);
+ if (ml2 > matchLength)
+ matchLength = ml2, start = ip, offset=offsetFound;
+ }
+
+ if (matchLength < 4) {
+ ip += ((ip-anchor) >> kSearchStrength) + 1; /* jump faster over incompressible sections */
+ continue;
+ }
+
+ /* let's try to find a better solution */
+ if (depth>=1)
+ while (ip<ilimit) {
+ ip ++;
+ if ( (dictMode == ZSTD_noDict)
+ && (offset) && ((offset_1>0) & (MEM_read32(ip) == MEM_read32(ip - offset_1)))) {
+ size_t const mlRep = ZSTD_count(ip+4, ip+4-offset_1, iend) + 4;
+ int const gain2 = (int)(mlRep * 3);
+ int const gain1 = (int)(matchLength*3 - ZSTD_highbit32((U32)offset+1) + 1);
+ if ((mlRep >= 4) && (gain2 > gain1))
+ matchLength = mlRep, offset = 0, start = ip;
+ }
+ if (dictMode == ZSTD_dictMatchState) {
+ const U32 repIndex = (U32)(ip - base) - offset_1;
+ const BYTE* repMatch = repIndex < prefixLowestIndex ?
+ dictBase + (repIndex - dictIndexDelta) :
+ base + repIndex;
+ if (((U32)((prefixLowestIndex-1) - repIndex) >= 3 /* intentional underflow */)
+ && (MEM_read32(repMatch) == MEM_read32(ip)) ) {
+ const BYTE* repMatchEnd = repIndex < prefixLowestIndex ? dictEnd : iend;
+ size_t const mlRep = ZSTD_count_2segments(ip+4, repMatch+4, iend, repMatchEnd, prefixLowest) + 4;
+ int const gain2 = (int)(mlRep * 3);
+ int const gain1 = (int)(matchLength*3 - ZSTD_highbit32((U32)offset+1) + 1);
+ if ((mlRep >= 4) && (gain2 > gain1))
+ matchLength = mlRep, offset = 0, start = ip;
+ }
+ }
+ { size_t offset2=999999999;
+ size_t const ml2 = searchMax(ms, ip, iend, &offset2);
+ int const gain2 = (int)(ml2*4 - ZSTD_highbit32((U32)offset2+1)); /* raw approx */
+ int const gain1 = (int)(matchLength*4 - ZSTD_highbit32((U32)offset+1) + 4);
+ if ((ml2 >= 4) && (gain2 > gain1)) {
+ matchLength = ml2, offset = offset2, start = ip;
+ continue; /* search a better one */
+ } }
+
+ /* let's find an even better one */
+ if ((depth==2) && (ip<ilimit)) {
+ ip ++;
+ if ( (dictMode == ZSTD_noDict)
+ && (offset) && ((offset_1>0) & (MEM_read32(ip) == MEM_read32(ip - offset_1)))) {
+ size_t const mlRep = ZSTD_count(ip+4, ip+4-offset_1, iend) + 4;
+ int const gain2 = (int)(mlRep * 4);
+ int const gain1 = (int)(matchLength*4 - ZSTD_highbit32((U32)offset+1) + 1);
+ if ((mlRep >= 4) && (gain2 > gain1))
+ matchLength = mlRep, offset = 0, start = ip;
+ }
+ if (dictMode == ZSTD_dictMatchState) {
+ const U32 repIndex = (U32)(ip - base) - offset_1;
+ const BYTE* repMatch = repIndex < prefixLowestIndex ?
+ dictBase + (repIndex - dictIndexDelta) :
+ base + repIndex;
+ if (((U32)((prefixLowestIndex-1) - repIndex) >= 3 /* intentional underflow */)
+ && (MEM_read32(repMatch) == MEM_read32(ip)) ) {
+ const BYTE* repMatchEnd = repIndex < prefixLowestIndex ? dictEnd : iend;
+ size_t const mlRep = ZSTD_count_2segments(ip+4, repMatch+4, iend, repMatchEnd, prefixLowest) + 4;
+ int const gain2 = (int)(mlRep * 4);
+ int const gain1 = (int)(matchLength*4 - ZSTD_highbit32((U32)offset+1) + 1);
+ if ((mlRep >= 4) && (gain2 > gain1))
+ matchLength = mlRep, offset = 0, start = ip;
+ }
+ }
+ { size_t offset2=999999999;
+ size_t const ml2 = searchMax(ms, ip, iend, &offset2);
+ int const gain2 = (int)(ml2*4 - ZSTD_highbit32((U32)offset2+1)); /* raw approx */
+ int const gain1 = (int)(matchLength*4 - ZSTD_highbit32((U32)offset+1) + 7);
+ if ((ml2 >= 4) && (gain2 > gain1)) {
+ matchLength = ml2, offset = offset2, start = ip;
+ continue;
+ } } }
+ break; /* nothing found : store previous solution */
+ }
+
+ /* NOTE:
+ * start[-offset+ZSTD_REP_MOVE-1] is undefined behavior.
+ * (-offset+ZSTD_REP_MOVE-1) is unsigned, and is added to start, which
+ * overflows the pointer, which is undefined behavior.
+ */
+ /* catch up */
+ if (offset) {
+ if (dictMode == ZSTD_noDict) {
+ while ( ((start > anchor) & (start - (offset-ZSTD_REP_MOVE) > prefixLowest))
+ && (start[-1] == (start-(offset-ZSTD_REP_MOVE))[-1]) ) /* only search for offset within prefix */
+ { start--; matchLength++; }
+ }
+ if (dictMode == ZSTD_dictMatchState) {
+ U32 const matchIndex = (U32)((start-base) - (offset - ZSTD_REP_MOVE));
+ const BYTE* match = (matchIndex < prefixLowestIndex) ? dictBase + matchIndex - dictIndexDelta : base + matchIndex;
+ const BYTE* const mStart = (matchIndex < prefixLowestIndex) ? dictLowest : prefixLowest;
+ while ((start>anchor) && (match>mStart) && (start[-1] == match[-1])) { start--; match--; matchLength++; } /* catch up */
+ }
+ offset_2 = offset_1; offset_1 = (U32)(offset - ZSTD_REP_MOVE);
+ }
+ /* store sequence */
+_storeSequence:
+ { size_t const litLength = start - anchor;
+ ZSTD_storeSeq(seqStore, litLength, anchor, (U32)offset, matchLength-MINMATCH);
+ anchor = ip = start + matchLength;
+ }
+
+ /* check immediate repcode */
+ if (dictMode == ZSTD_dictMatchState) {
+ while (ip <= ilimit) {
+ U32 const current2 = (U32)(ip-base);
+ U32 const repIndex = current2 - offset_2;
+ const BYTE* repMatch = dictMode == ZSTD_dictMatchState
+ && repIndex < prefixLowestIndex ?
+ dictBase - dictIndexDelta + repIndex :
+ base + repIndex;
+ if ( ((U32)((prefixLowestIndex-1) - (U32)repIndex) >= 3 /* intentional overflow */)
+ && (MEM_read32(repMatch) == MEM_read32(ip)) ) {
+ const BYTE* const repEnd2 = repIndex < prefixLowestIndex ? dictEnd : iend;
+ matchLength = ZSTD_count_2segments(ip+4, repMatch+4, iend, repEnd2, prefixLowest) + 4;
+ offset = offset_2; offset_2 = offset_1; offset_1 = (U32)offset; /* swap offset_2 <=> offset_1 */
+ ZSTD_storeSeq(seqStore, 0, anchor, 0, matchLength-MINMATCH);
+ ip += matchLength;
+ anchor = ip;
+ continue;
+ }
+ break;
+ }
+ }
+
+ if (dictMode == ZSTD_noDict) {
+ while ( ((ip <= ilimit) & (offset_2>0))
+ && (MEM_read32(ip) == MEM_read32(ip - offset_2)) ) {
+ /* store sequence */
+ matchLength = ZSTD_count(ip+4, ip+4-offset_2, iend) + 4;
+ offset = offset_2; offset_2 = offset_1; offset_1 = (U32)offset; /* swap repcodes */
+ ZSTD_storeSeq(seqStore, 0, anchor, 0, matchLength-MINMATCH);
+ ip += matchLength;
+ anchor = ip;
+ continue; /* faster when present ... (?) */
+ } } }
+
+ /* Save reps for next block */
+ rep[0] = offset_1 ? offset_1 : savedOffset;
+ rep[1] = offset_2 ? offset_2 : savedOffset;
+
+ /* Return the last literals size */
+ return iend - anchor;
+}
+
+
+size_t ZSTD_compressBlock_btlazy2(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 1, 2, ZSTD_noDict);
+}
+
+size_t ZSTD_compressBlock_lazy2(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 0, 2, ZSTD_noDict);
+}
+
+size_t ZSTD_compressBlock_lazy(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 0, 1, ZSTD_noDict);
+}
+
+size_t ZSTD_compressBlock_greedy(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 0, 0, ZSTD_noDict);
+}
+
+size_t ZSTD_compressBlock_btlazy2_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 1, 2, ZSTD_dictMatchState);
+}
+
+size_t ZSTD_compressBlock_lazy2_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 0, 2, ZSTD_dictMatchState);
+}
+
+size_t ZSTD_compressBlock_lazy_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 0, 1, ZSTD_dictMatchState);
+}
+
+size_t ZSTD_compressBlock_greedy_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ return ZSTD_compressBlock_lazy_generic(ms, seqStore, rep, src, srcSize, 0, 0, ZSTD_dictMatchState);
+}
+
+
+FORCE_INLINE_TEMPLATE
+size_t ZSTD_compressBlock_lazy_extDict_generic(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore,
+ U32 rep[ZSTD_REP_NUM],
+ const void* src, size_t srcSize,
+ const U32 searchMethod, const U32 depth)
+{
+ const BYTE* const istart = (const BYTE*)src;
+ const BYTE* ip = istart;
+ const BYTE* anchor = istart;
+ const BYTE* const iend = istart + srcSize;
+ const BYTE* const ilimit = iend - 8;
+ const BYTE* const base = ms->window.base;
+ const U32 dictLimit = ms->window.dictLimit;
+ const U32 lowestIndex = ms->window.lowLimit;
+ const BYTE* const prefixStart = base + dictLimit;
+ const BYTE* const dictBase = ms->window.dictBase;
+ const BYTE* const dictEnd = dictBase + dictLimit;
+ const BYTE* const dictStart = dictBase + lowestIndex;
+
+ typedef size_t (*searchMax_f)(
+ ZSTD_matchState_t* ms,
+ const BYTE* ip, const BYTE* iLimit, size_t* offsetPtr);
+ searchMax_f searchMax = searchMethod ? ZSTD_BtFindBestMatch_extDict_selectMLS : ZSTD_HcFindBestMatch_extDict_selectMLS;
+
+ U32 offset_1 = rep[0], offset_2 = rep[1];
+
+ /* init */
+ ms->nextToUpdate3 = ms->nextToUpdate;
+ ip += (ip == prefixStart);
+
+ /* Match Loop */
+ while (ip < ilimit) {
+ size_t matchLength=0;
+ size_t offset=0;
+ const BYTE* start=ip+1;
+ U32 current = (U32)(ip-base);
+
+ /* check repCode */
+ { const U32 repIndex = (U32)(current+1 - offset_1);
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
+ const BYTE* const repMatch = repBase + repIndex;
+ if (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */
+ if (MEM_read32(ip+1) == MEM_read32(repMatch)) {
+ /* repcode detected we should take it */
+ const BYTE* const repEnd = repIndex < dictLimit ? dictEnd : iend;
+ matchLength = ZSTD_count_2segments(ip+1+4, repMatch+4, iend, repEnd, prefixStart) + 4;
+ if (depth==0) goto _storeSequence;
+ } }
+
+ /* first search (depth 0) */
+ { size_t offsetFound = 999999999;
+ size_t const ml2 = searchMax(ms, ip, iend, &offsetFound);
+ if (ml2 > matchLength)
+ matchLength = ml2, start = ip, offset=offsetFound;
+ }
+
+ if (matchLength < 4) {
+ ip += ((ip-anchor) >> kSearchStrength) + 1; /* jump faster over incompressible sections */
+ continue;
+ }
+
+ /* let's try to find a better solution */
+ if (depth>=1)
+ while (ip<ilimit) {
+ ip ++;
+ current++;
+ /* check repCode */
+ if (offset) {
+ const U32 repIndex = (U32)(current - offset_1);
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
+ const BYTE* const repMatch = repBase + repIndex;
+ if (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */
+ if (MEM_read32(ip) == MEM_read32(repMatch)) {
+ /* repcode detected */
+ const BYTE* const repEnd = repIndex < dictLimit ? dictEnd : iend;
+ size_t const repLength = ZSTD_count_2segments(ip+4, repMatch+4, iend, repEnd, prefixStart) + 4;
+ int const gain2 = (int)(repLength * 3);
+ int const gain1 = (int)(matchLength*3 - ZSTD_highbit32((U32)offset+1) + 1);
+ if ((repLength >= 4) && (gain2 > gain1))
+ matchLength = repLength, offset = 0, start = ip;
+ } }
+
+ /* search match, depth 1 */
+ { size_t offset2=999999999;
+ size_t const ml2 = searchMax(ms, ip, iend, &offset2);
+ int const gain2 = (int)(ml2*4 - ZSTD_highbit32((U32)offset2+1)); /* raw approx */
+ int const gain1 = (int)(matchLength*4 - ZSTD_highbit32((U32)offset+1) + 4);
+ if ((ml2 >= 4) && (gain2 > gain1)) {
+ matchLength = ml2, offset = offset2, start = ip;
+ continue; /* search a better one */
+ } }
+
+ /* let's find an even better one */
+ if ((depth==2) && (ip<ilimit)) {
+ ip ++;
+ current++;
+ /* check repCode */
+ if (offset) {
+ const U32 repIndex = (U32)(current - offset_1);
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
+ const BYTE* const repMatch = repBase + repIndex;
+ if (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */
+ if (MEM_read32(ip) == MEM_read32(repMatch)) {
+ /* repcode detected */
+ const BYTE* const repEnd = repIndex < dictLimit ? dictEnd : iend;
+ size_t const repLength = ZSTD_count_2segments(ip+4, repMatch+4, iend, repEnd, prefixStart) + 4;
+ int const gain2 = (int)(repLength * 4);
+ int const gain1 = (int)(matchLength*4 - ZSTD_highbit32((U32)offset+1) + 1);
+ if ((repLength >= 4) && (gain2 > gain1))
+ matchLength = repLength, offset = 0, start = ip;
+ } }
+
+ /* search match, depth 2 */
+ { size_t offset2=999999999;
+ size_t const ml2 = searchMax(ms, ip, iend, &offset2);
+ int const gain2 = (int)(ml2*4 - ZSTD_highbit32((U32)offset2+1)); /* raw approx */
+ int const gain1 = (int)(matchLength*4 - ZSTD_highbit32((U32)offset+1) + 7);
+ if ((ml2 >= 4) && (gain2 > gain1)) {
+ matchLength = ml2, offset = offset2, start = ip;
+ continue;
+ } } }
+ break; /* nothing found : store previous solution */
+ }
+
+ /* catch up */
+ if (offset) {
+ U32 const matchIndex = (U32)((start-base) - (offset - ZSTD_REP_MOVE));
+ const BYTE* match = (matchIndex < dictLimit) ? dictBase + matchIndex : base + matchIndex;
+ const BYTE* const mStart = (matchIndex < dictLimit) ? dictStart : prefixStart;
+ while ((start>anchor) && (match>mStart) && (start[-1] == match[-1])) { start--; match--; matchLength++; } /* catch up */
+ offset_2 = offset_1; offset_1 = (U32)(offset - ZSTD_REP_MOVE);
+ }
+
+ /* store sequence */
+_storeSequence:
+ { size_t const litLength = start - anchor;
+ ZSTD_storeSeq(seqStore, litLength, anchor, (U32)offset, matchLength-MINMATCH);
+ anchor = ip = start + matchLength;
+ }
+
+ /* check immediate repcode */
+ while (ip <= ilimit) {
+ const U32 repIndex = (U32)((ip-base) - offset_2);
+ const BYTE* const repBase = repIndex < dictLimit ? dictBase : base;
+ const BYTE* const repMatch = repBase + repIndex;
+ if (((U32)((dictLimit-1) - repIndex) >= 3) & (repIndex > lowestIndex)) /* intentional overflow */
+ if (MEM_read32(ip) == MEM_read32(repMatch)) {
+ /* repcode detected we should take it */
+ const BYTE* const repEnd = repIndex < dictLimit ? dictEnd : iend;
+ matchLength = ZSTD_count_2segments(ip+4, repMatch+4, iend, repEnd, prefixStart) + 4;
+ offset = offset_2; offset_2 = offset_1; offset_1 = (U32)offset; /* swap offset history */
+ ZSTD_storeSeq(seqStore, 0, anchor, 0, matchLength-MINMATCH);
+ ip += matchLength;
+ anchor = ip;
+ continue; /* faster when present ... (?) */
+ }
+ break;
+ } }
+
+ /* Save reps for next block */
+ rep[0] = offset_1;
+ rep[1] = offset_2;
+
+ /* Return the last literals size */
+ return iend - anchor;
+}
+
+
+size_t ZSTD_compressBlock_greedy_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, 0, 0);
+}
+
+size_t ZSTD_compressBlock_lazy_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+
+{
+ return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, 0, 1);
+}
+
+size_t ZSTD_compressBlock_lazy2_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+
+{
+ return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, 0, 2);
+}
+
+size_t ZSTD_compressBlock_btlazy2_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+
+{
+ return ZSTD_compressBlock_lazy_extDict_generic(ms, seqStore, rep, src, srcSize, 1, 2);
+}
diff --git a/Utilities/cmzstd/lib/compress/zstd_lazy.h b/Utilities/cmzstd/lib/compress/zstd_lazy.h
new file mode 100644
index 000000000..ef85a6df9
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstd_lazy.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef ZSTD_LAZY_H
+#define ZSTD_LAZY_H
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#include "zstd_compress_internal.h"
+
+U32 ZSTD_insertAndFindFirstIndex(ZSTD_matchState_t* ms, const BYTE* ip);
+
+void ZSTD_preserveUnsortedMark (U32* const table, U32 const size, U32 const reducerValue); /*! used in ZSTD_reduceIndex(). pre-emptively increase value of ZSTD_DUBT_UNSORTED_MARK */
+
+size_t ZSTD_compressBlock_btlazy2(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_lazy2(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_lazy(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_greedy(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+
+size_t ZSTD_compressBlock_btlazy2_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_lazy2_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_lazy_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_greedy_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+
+size_t ZSTD_compressBlock_greedy_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_lazy_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_lazy2_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_btlazy2_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* ZSTD_LAZY_H */
diff --git a/Utilities/cmzstd/lib/compress/zstd_ldm.c b/Utilities/cmzstd/lib/compress/zstd_ldm.c
new file mode 100644
index 000000000..58eb2ffe4
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstd_ldm.c
@@ -0,0 +1,597 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ */
+
+#include "zstd_ldm.h"
+
+#include "debug.h"
+#include "zstd_fast.h" /* ZSTD_fillHashTable() */
+#include "zstd_double_fast.h" /* ZSTD_fillDoubleHashTable() */
+
+#define LDM_BUCKET_SIZE_LOG 3
+#define LDM_MIN_MATCH_LENGTH 64
+#define LDM_HASH_RLOG 7
+#define LDM_HASH_CHAR_OFFSET 10
+
+void ZSTD_ldm_adjustParameters(ldmParams_t* params,
+ ZSTD_compressionParameters const* cParams)
+{
+ params->windowLog = cParams->windowLog;
+ ZSTD_STATIC_ASSERT(LDM_BUCKET_SIZE_LOG <= ZSTD_LDM_BUCKETSIZELOG_MAX);
+ DEBUGLOG(4, "ZSTD_ldm_adjustParameters");
+ if (!params->bucketSizeLog) params->bucketSizeLog = LDM_BUCKET_SIZE_LOG;
+ if (!params->minMatchLength) params->minMatchLength = LDM_MIN_MATCH_LENGTH;
+ if (cParams->strategy >= ZSTD_btopt) {
+ /* Get out of the way of the optimal parser */
+ U32 const minMatch = MAX(cParams->targetLength, params->minMatchLength);
+ assert(minMatch >= ZSTD_LDM_MINMATCH_MIN);
+ assert(minMatch <= ZSTD_LDM_MINMATCH_MAX);
+ params->minMatchLength = minMatch;
+ }
+ if (params->hashLog == 0) {
+ params->hashLog = MAX(ZSTD_HASHLOG_MIN, params->windowLog - LDM_HASH_RLOG);
+ assert(params->hashLog <= ZSTD_HASHLOG_MAX);
+ }
+ if (params->hashRateLog == 0) {
+ params->hashRateLog = params->windowLog < params->hashLog
+ ? 0
+ : params->windowLog - params->hashLog;
+ }
+ params->bucketSizeLog = MIN(params->bucketSizeLog, params->hashLog);
+}
+
+size_t ZSTD_ldm_getTableSize(ldmParams_t params)
+{
+ size_t const ldmHSize = ((size_t)1) << params.hashLog;
+ size_t const ldmBucketSizeLog = MIN(params.bucketSizeLog, params.hashLog);
+ size_t const ldmBucketSize =
+ ((size_t)1) << (params.hashLog - ldmBucketSizeLog);
+ size_t const totalSize = ldmBucketSize + ldmHSize * sizeof(ldmEntry_t);
+ return params.enableLdm ? totalSize : 0;
+}
+
+size_t ZSTD_ldm_getMaxNbSeq(ldmParams_t params, size_t maxChunkSize)
+{
+ return params.enableLdm ? (maxChunkSize / params.minMatchLength) : 0;
+}
+
+/** ZSTD_ldm_getSmallHash() :
+ * numBits should be <= 32
+ * If numBits==0, returns 0.
+ * @return : the most significant numBits of value. */
+static U32 ZSTD_ldm_getSmallHash(U64 value, U32 numBits)
+{
+ assert(numBits <= 32);
+ return numBits == 0 ? 0 : (U32)(value >> (64 - numBits));
+}
+
+/** ZSTD_ldm_getChecksum() :
+ * numBitsToDiscard should be <= 32
+ * @return : the next most significant 32 bits after numBitsToDiscard */
+static U32 ZSTD_ldm_getChecksum(U64 hash, U32 numBitsToDiscard)
+{
+ assert(numBitsToDiscard <= 32);
+ return (hash >> (64 - 32 - numBitsToDiscard)) & 0xFFFFFFFF;
+}
+
+/** ZSTD_ldm_getTag() ;
+ * Given the hash, returns the most significant numTagBits bits
+ * after (32 + hbits) bits.
+ *
+ * If there are not enough bits remaining, return the last
+ * numTagBits bits. */
+static U32 ZSTD_ldm_getTag(U64 hash, U32 hbits, U32 numTagBits)
+{
+ assert(numTagBits < 32 && hbits <= 32);
+ if (32 - hbits < numTagBits) {
+ return hash & (((U32)1 << numTagBits) - 1);
+ } else {
+ return (hash >> (32 - hbits - numTagBits)) & (((U32)1 << numTagBits) - 1);
+ }
+}
+
+/** ZSTD_ldm_getBucket() :
+ * Returns a pointer to the start of the bucket associated with hash. */
+static ldmEntry_t* ZSTD_ldm_getBucket(
+ ldmState_t* ldmState, size_t hash, ldmParams_t const ldmParams)
+{
+ return ldmState->hashTable + (hash << ldmParams.bucketSizeLog);
+}
+
+/** ZSTD_ldm_insertEntry() :
+ * Insert the entry with corresponding hash into the hash table */
+static void ZSTD_ldm_insertEntry(ldmState_t* ldmState,
+ size_t const hash, const ldmEntry_t entry,
+ ldmParams_t const ldmParams)
+{
+ BYTE* const bucketOffsets = ldmState->bucketOffsets;
+ *(ZSTD_ldm_getBucket(ldmState, hash, ldmParams) + bucketOffsets[hash]) = entry;
+ bucketOffsets[hash]++;
+ bucketOffsets[hash] &= ((U32)1 << ldmParams.bucketSizeLog) - 1;
+}
+
+/** ZSTD_ldm_makeEntryAndInsertByTag() :
+ *
+ * Gets the small hash, checksum, and tag from the rollingHash.
+ *
+ * If the tag matches (1 << ldmParams.hashRateLog)-1, then
+ * creates an ldmEntry from the offset, and inserts it into the hash table.
+ *
+ * hBits is the length of the small hash, which is the most significant hBits
+ * of rollingHash. The checksum is the next 32 most significant bits, followed
+ * by ldmParams.hashRateLog bits that make up the tag. */
+static void ZSTD_ldm_makeEntryAndInsertByTag(ldmState_t* ldmState,
+ U64 const rollingHash,
+ U32 const hBits,
+ U32 const offset,
+ ldmParams_t const ldmParams)
+{
+ U32 const tag = ZSTD_ldm_getTag(rollingHash, hBits, ldmParams.hashRateLog);
+ U32 const tagMask = ((U32)1 << ldmParams.hashRateLog) - 1;
+ if (tag == tagMask) {
+ U32 const hash = ZSTD_ldm_getSmallHash(rollingHash, hBits);
+ U32 const checksum = ZSTD_ldm_getChecksum(rollingHash, hBits);
+ ldmEntry_t entry;
+ entry.offset = offset;
+ entry.checksum = checksum;
+ ZSTD_ldm_insertEntry(ldmState, hash, entry, ldmParams);
+ }
+}
+
+/** ZSTD_ldm_countBackwardsMatch() :
+ * Returns the number of bytes that match backwards before pIn and pMatch.
+ *
+ * We count only bytes where pMatch >= pBase and pIn >= pAnchor. */
+static size_t ZSTD_ldm_countBackwardsMatch(
+ const BYTE* pIn, const BYTE* pAnchor,
+ const BYTE* pMatch, const BYTE* pBase)
+{
+ size_t matchLength = 0;
+ while (pIn > pAnchor && pMatch > pBase && pIn[-1] == pMatch[-1]) {
+ pIn--;
+ pMatch--;
+ matchLength++;
+ }
+ return matchLength;
+}
+
+/** ZSTD_ldm_fillFastTables() :
+ *
+ * Fills the relevant tables for the ZSTD_fast and ZSTD_dfast strategies.
+ * This is similar to ZSTD_loadDictionaryContent.
+ *
+ * The tables for the other strategies are filled within their
+ * block compressors. */
+static size_t ZSTD_ldm_fillFastTables(ZSTD_matchState_t* ms,
+ void const* end)
+{
+ const BYTE* const iend = (const BYTE*)end;
+
+ switch(ms->cParams.strategy)
+ {
+ case ZSTD_fast:
+ ZSTD_fillHashTable(ms, iend, ZSTD_dtlm_fast);
+ break;
+
+ case ZSTD_dfast:
+ ZSTD_fillDoubleHashTable(ms, iend, ZSTD_dtlm_fast);
+ break;
+
+ case ZSTD_greedy:
+ case ZSTD_lazy:
+ case ZSTD_lazy2:
+ case ZSTD_btlazy2:
+ case ZSTD_btopt:
+ case ZSTD_btultra:
+ case ZSTD_btultra2:
+ break;
+ default:
+ assert(0); /* not possible : not a valid strategy id */
+ }
+
+ return 0;
+}
+
+/** ZSTD_ldm_fillLdmHashTable() :
+ *
+ * Fills hashTable from (lastHashed + 1) to iend (non-inclusive).
+ * lastHash is the rolling hash that corresponds to lastHashed.
+ *
+ * Returns the rolling hash corresponding to position iend-1. */
+static U64 ZSTD_ldm_fillLdmHashTable(ldmState_t* state,
+ U64 lastHash, const BYTE* lastHashed,
+ const BYTE* iend, const BYTE* base,
+ U32 hBits, ldmParams_t const ldmParams)
+{
+ U64 rollingHash = lastHash;
+ const BYTE* cur = lastHashed + 1;
+
+ while (cur < iend) {
+ rollingHash = ZSTD_rollingHash_rotate(rollingHash, cur[-1],
+ cur[ldmParams.minMatchLength-1],
+ state->hashPower);
+ ZSTD_ldm_makeEntryAndInsertByTag(state,
+ rollingHash, hBits,
+ (U32)(cur - base), ldmParams);
+ ++cur;
+ }
+ return rollingHash;
+}
+
+
+/** ZSTD_ldm_limitTableUpdate() :
+ *
+ * Sets cctx->nextToUpdate to a position corresponding closer to anchor
+ * if it is far way
+ * (after a long match, only update tables a limited amount). */
+static void ZSTD_ldm_limitTableUpdate(ZSTD_matchState_t* ms, const BYTE* anchor)
+{
+ U32 const current = (U32)(anchor - ms->window.base);
+ if (current > ms->nextToUpdate + 1024) {
+ ms->nextToUpdate =
+ current - MIN(512, current - ms->nextToUpdate - 1024);
+ }
+}
+
+static size_t ZSTD_ldm_generateSequences_internal(
+ ldmState_t* ldmState, rawSeqStore_t* rawSeqStore,
+ ldmParams_t const* params, void const* src, size_t srcSize)
+{
+ /* LDM parameters */
+ int const extDict = ZSTD_window_hasExtDict(ldmState->window);
+ U32 const minMatchLength = params->minMatchLength;
+ U64 const hashPower = ldmState->hashPower;
+ U32 const hBits = params->hashLog - params->bucketSizeLog;
+ U32 const ldmBucketSize = 1U << params->bucketSizeLog;
+ U32 const hashRateLog = params->hashRateLog;
+ U32 const ldmTagMask = (1U << params->hashRateLog) - 1;
+ /* Prefix and extDict parameters */
+ U32 const dictLimit = ldmState->window.dictLimit;
+ U32 const lowestIndex = extDict ? ldmState->window.lowLimit : dictLimit;
+ BYTE const* const base = ldmState->window.base;
+ BYTE const* const dictBase = extDict ? ldmState->window.dictBase : NULL;
+ BYTE const* const dictStart = extDict ? dictBase + lowestIndex : NULL;
+ BYTE const* const dictEnd = extDict ? dictBase + dictLimit : NULL;
+ BYTE const* const lowPrefixPtr = base + dictLimit;
+ /* Input bounds */
+ BYTE const* const istart = (BYTE const*)src;
+ BYTE const* const iend = istart + srcSize;
+ BYTE const* const ilimit = iend - MAX(minMatchLength, HASH_READ_SIZE);
+ /* Input positions */
+ BYTE const* anchor = istart;
+ BYTE const* ip = istart;
+ /* Rolling hash */
+ BYTE const* lastHashed = NULL;
+ U64 rollingHash = 0;
+
+ while (ip <= ilimit) {
+ size_t mLength;
+ U32 const current = (U32)(ip - base);
+ size_t forwardMatchLength = 0, backwardMatchLength = 0;
+ ldmEntry_t* bestEntry = NULL;
+ if (ip != istart) {
+ rollingHash = ZSTD_rollingHash_rotate(rollingHash, lastHashed[0],
+ lastHashed[minMatchLength],
+ hashPower);
+ } else {
+ rollingHash = ZSTD_rollingHash_compute(ip, minMatchLength);
+ }
+ lastHashed = ip;
+
+ /* Do not insert and do not look for a match */
+ if (ZSTD_ldm_getTag(rollingHash, hBits, hashRateLog) != ldmTagMask) {
+ ip++;
+ continue;
+ }
+
+ /* Get the best entry and compute the match lengths */
+ {
+ ldmEntry_t* const bucket =
+ ZSTD_ldm_getBucket(ldmState,
+ ZSTD_ldm_getSmallHash(rollingHash, hBits),
+ *params);
+ ldmEntry_t* cur;
+ size_t bestMatchLength = 0;
+ U32 const checksum = ZSTD_ldm_getChecksum(rollingHash, hBits);
+
+ for (cur = bucket; cur < bucket + ldmBucketSize; ++cur) {
+ size_t curForwardMatchLength, curBackwardMatchLength,
+ curTotalMatchLength;
+ if (cur->checksum != checksum || cur->offset <= lowestIndex) {
+ continue;
+ }
+ if (extDict) {
+ BYTE const* const curMatchBase =
+ cur->offset < dictLimit ? dictBase : base;
+ BYTE const* const pMatch = curMatchBase + cur->offset;
+ BYTE const* const matchEnd =
+ cur->offset < dictLimit ? dictEnd : iend;
+ BYTE const* const lowMatchPtr =
+ cur->offset < dictLimit ? dictStart : lowPrefixPtr;
+
+ curForwardMatchLength = ZSTD_count_2segments(
+ ip, pMatch, iend,
+ matchEnd, lowPrefixPtr);
+ if (curForwardMatchLength < minMatchLength) {
+ continue;
+ }
+ curBackwardMatchLength =
+ ZSTD_ldm_countBackwardsMatch(ip, anchor, pMatch,
+ lowMatchPtr);
+ curTotalMatchLength = curForwardMatchLength +
+ curBackwardMatchLength;
+ } else { /* !extDict */
+ BYTE const* const pMatch = base + cur->offset;
+ curForwardMatchLength = ZSTD_count(ip, pMatch, iend);
+ if (curForwardMatchLength < minMatchLength) {
+ continue;
+ }
+ curBackwardMatchLength =
+ ZSTD_ldm_countBackwardsMatch(ip, anchor, pMatch,
+ lowPrefixPtr);
+ curTotalMatchLength = curForwardMatchLength +
+ curBackwardMatchLength;
+ }
+
+ if (curTotalMatchLength > bestMatchLength) {
+ bestMatchLength = curTotalMatchLength;
+ forwardMatchLength = curForwardMatchLength;
+ backwardMatchLength = curBackwardMatchLength;
+ bestEntry = cur;
+ }
+ }
+ }
+
+ /* No match found -- continue searching */
+ if (bestEntry == NULL) {
+ ZSTD_ldm_makeEntryAndInsertByTag(ldmState, rollingHash,
+ hBits, current,
+ *params);
+ ip++;
+ continue;
+ }
+
+ /* Match found */
+ mLength = forwardMatchLength + backwardMatchLength;
+ ip -= backwardMatchLength;
+
+ {
+ /* Store the sequence:
+ * ip = current - backwardMatchLength
+ * The match is at (bestEntry->offset - backwardMatchLength)
+ */
+ U32 const matchIndex = bestEntry->offset;
+ U32 const offset = current - matchIndex;
+ rawSeq* const seq = rawSeqStore->seq + rawSeqStore->size;
+
+ /* Out of sequence storage */
+ if (rawSeqStore->size == rawSeqStore->capacity)
+ return ERROR(dstSize_tooSmall);
+ seq->litLength = (U32)(ip - anchor);
+ seq->matchLength = (U32)mLength;
+ seq->offset = offset;
+ rawSeqStore->size++;
+ }
+
+ /* Insert the current entry into the hash table */
+ ZSTD_ldm_makeEntryAndInsertByTag(ldmState, rollingHash, hBits,
+ (U32)(lastHashed - base),
+ *params);
+
+ assert(ip + backwardMatchLength == lastHashed);
+
+ /* Fill the hash table from lastHashed+1 to ip+mLength*/
+ /* Heuristic: don't need to fill the entire table at end of block */
+ if (ip + mLength <= ilimit) {
+ rollingHash = ZSTD_ldm_fillLdmHashTable(
+ ldmState, rollingHash, lastHashed,
+ ip + mLength, base, hBits, *params);
+ lastHashed = ip + mLength - 1;
+ }
+ ip += mLength;
+ anchor = ip;
+ }
+ return iend - anchor;
+}
+
+/*! ZSTD_ldm_reduceTable() :
+ * reduce table indexes by `reducerValue` */
+static void ZSTD_ldm_reduceTable(ldmEntry_t* const table, U32 const size,
+ U32 const reducerValue)
+{
+ U32 u;
+ for (u = 0; u < size; u++) {
+ if (table[u].offset < reducerValue) table[u].offset = 0;
+ else table[u].offset -= reducerValue;
+ }
+}
+
+size_t ZSTD_ldm_generateSequences(
+ ldmState_t* ldmState, rawSeqStore_t* sequences,
+ ldmParams_t const* params, void const* src, size_t srcSize)
+{
+ U32 const maxDist = 1U << params->windowLog;
+ BYTE const* const istart = (BYTE const*)src;
+ BYTE const* const iend = istart + srcSize;
+ size_t const kMaxChunkSize = 1 << 20;
+ size_t const nbChunks = (srcSize / kMaxChunkSize) + ((srcSize % kMaxChunkSize) != 0);
+ size_t chunk;
+ size_t leftoverSize = 0;
+
+ assert(ZSTD_CHUNKSIZE_MAX >= kMaxChunkSize);
+ /* Check that ZSTD_window_update() has been called for this chunk prior
+ * to passing it to this function.
+ */
+ assert(ldmState->window.nextSrc >= (BYTE const*)src + srcSize);
+ /* The input could be very large (in zstdmt), so it must be broken up into
+ * chunks to enforce the maximmum distance and handle overflow correction.
+ */
+ assert(sequences->pos <= sequences->size);
+ assert(sequences->size <= sequences->capacity);
+ for (chunk = 0; chunk < nbChunks && sequences->size < sequences->capacity; ++chunk) {
+ BYTE const* const chunkStart = istart + chunk * kMaxChunkSize;
+ size_t const remaining = (size_t)(iend - chunkStart);
+ BYTE const *const chunkEnd =
+ (remaining < kMaxChunkSize) ? iend : chunkStart + kMaxChunkSize;
+ size_t const chunkSize = chunkEnd - chunkStart;
+ size_t newLeftoverSize;
+ size_t const prevSize = sequences->size;
+
+ assert(chunkStart < iend);
+ /* 1. Perform overflow correction if necessary. */
+ if (ZSTD_window_needOverflowCorrection(ldmState->window, chunkEnd)) {
+ U32 const ldmHSize = 1U << params->hashLog;
+ U32 const correction = ZSTD_window_correctOverflow(
+ &ldmState->window, /* cycleLog */ 0, maxDist, src);
+ ZSTD_ldm_reduceTable(ldmState->hashTable, ldmHSize, correction);
+ }
+ /* 2. We enforce the maximum offset allowed.
+ *
+ * kMaxChunkSize should be small enough that we don't lose too much of
+ * the window through early invalidation.
+ * TODO: * Test the chunk size.
+ * * Try invalidation after the sequence generation and test the
+ * the offset against maxDist directly.
+ */
+ ZSTD_window_enforceMaxDist(&ldmState->window, chunkEnd, maxDist, NULL, NULL);
+ /* 3. Generate the sequences for the chunk, and get newLeftoverSize. */
+ newLeftoverSize = ZSTD_ldm_generateSequences_internal(
+ ldmState, sequences, params, chunkStart, chunkSize);
+ if (ZSTD_isError(newLeftoverSize))
+ return newLeftoverSize;
+ /* 4. We add the leftover literals from previous iterations to the first
+ * newly generated sequence, or add the `newLeftoverSize` if none are
+ * generated.
+ */
+ /* Prepend the leftover literals from the last call */
+ if (prevSize < sequences->size) {
+ sequences->seq[prevSize].litLength += (U32)leftoverSize;
+ leftoverSize = newLeftoverSize;
+ } else {
+ assert(newLeftoverSize == chunkSize);
+ leftoverSize += chunkSize;
+ }
+ }
+ return 0;
+}
+
+void ZSTD_ldm_skipSequences(rawSeqStore_t* rawSeqStore, size_t srcSize, U32 const minMatch) {
+ while (srcSize > 0 && rawSeqStore->pos < rawSeqStore->size) {
+ rawSeq* seq = rawSeqStore->seq + rawSeqStore->pos;
+ if (srcSize <= seq->litLength) {
+ /* Skip past srcSize literals */
+ seq->litLength -= (U32)srcSize;
+ return;
+ }
+ srcSize -= seq->litLength;
+ seq->litLength = 0;
+ if (srcSize < seq->matchLength) {
+ /* Skip past the first srcSize of the match */
+ seq->matchLength -= (U32)srcSize;
+ if (seq->matchLength < minMatch) {
+ /* The match is too short, omit it */
+ if (rawSeqStore->pos + 1 < rawSeqStore->size) {
+ seq[1].litLength += seq[0].matchLength;
+ }
+ rawSeqStore->pos++;
+ }
+ return;
+ }
+ srcSize -= seq->matchLength;
+ seq->matchLength = 0;
+ rawSeqStore->pos++;
+ }
+}
+
+/**
+ * If the sequence length is longer than remaining then the sequence is split
+ * between this block and the next.
+ *
+ * Returns the current sequence to handle, or if the rest of the block should
+ * be literals, it returns a sequence with offset == 0.
+ */
+static rawSeq maybeSplitSequence(rawSeqStore_t* rawSeqStore,
+ U32 const remaining, U32 const minMatch)
+{
+ rawSeq sequence = rawSeqStore->seq[rawSeqStore->pos];
+ assert(sequence.offset > 0);
+ /* Likely: No partial sequence */
+ if (remaining >= sequence.litLength + sequence.matchLength) {
+ rawSeqStore->pos++;
+ return sequence;
+ }
+ /* Cut the sequence short (offset == 0 ==> rest is literals). */
+ if (remaining <= sequence.litLength) {
+ sequence.offset = 0;
+ } else if (remaining < sequence.litLength + sequence.matchLength) {
+ sequence.matchLength = remaining - sequence.litLength;
+ if (sequence.matchLength < minMatch) {
+ sequence.offset = 0;
+ }
+ }
+ /* Skip past `remaining` bytes for the future sequences. */
+ ZSTD_ldm_skipSequences(rawSeqStore, remaining, minMatch);
+ return sequence;
+}
+
+size_t ZSTD_ldm_blockCompress(rawSeqStore_t* rawSeqStore,
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize)
+{
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+ unsigned const minMatch = cParams->minMatch;
+ ZSTD_blockCompressor const blockCompressor =
+ ZSTD_selectBlockCompressor(cParams->strategy, ZSTD_matchState_dictMode(ms));
+ /* Input bounds */
+ BYTE const* const istart = (BYTE const*)src;
+ BYTE const* const iend = istart + srcSize;
+ /* Input positions */
+ BYTE const* ip = istart;
+
+ DEBUGLOG(5, "ZSTD_ldm_blockCompress: srcSize=%zu", srcSize);
+ assert(rawSeqStore->pos <= rawSeqStore->size);
+ assert(rawSeqStore->size <= rawSeqStore->capacity);
+ /* Loop through each sequence and apply the block compressor to the lits */
+ while (rawSeqStore->pos < rawSeqStore->size && ip < iend) {
+ /* maybeSplitSequence updates rawSeqStore->pos */
+ rawSeq const sequence = maybeSplitSequence(rawSeqStore,
+ (U32)(iend - ip), minMatch);
+ int i;
+ /* End signal */
+ if (sequence.offset == 0)
+ break;
+
+ assert(sequence.offset <= (1U << cParams->windowLog));
+ assert(ip + sequence.litLength + sequence.matchLength <= iend);
+
+ /* Fill tables for block compressor */
+ ZSTD_ldm_limitTableUpdate(ms, ip);
+ ZSTD_ldm_fillFastTables(ms, ip);
+ /* Run the block compressor */
+ DEBUGLOG(5, "calling block compressor on segment of size %u", sequence.litLength);
+ {
+ size_t const newLitLength =
+ blockCompressor(ms, seqStore, rep, ip, sequence.litLength);
+ ip += sequence.litLength;
+ /* Update the repcodes */
+ for (i = ZSTD_REP_NUM - 1; i > 0; i--)
+ rep[i] = rep[i-1];
+ rep[0] = sequence.offset;
+ /* Store the sequence */
+ ZSTD_storeSeq(seqStore, newLitLength, ip - newLitLength,
+ sequence.offset + ZSTD_REP_MOVE,
+ sequence.matchLength - MINMATCH);
+ ip += sequence.matchLength;
+ }
+ }
+ /* Fill the tables for the block compressor */
+ ZSTD_ldm_limitTableUpdate(ms, ip);
+ ZSTD_ldm_fillFastTables(ms, ip);
+ /* Compress the last literals */
+ return blockCompressor(ms, seqStore, rep, ip, iend - ip);
+}
diff --git a/Utilities/cmzstd/lib/compress/zstd_ldm.h b/Utilities/cmzstd/lib/compress/zstd_ldm.h
new file mode 100644
index 000000000..a47846128
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstd_ldm.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ */
+
+#ifndef ZSTD_LDM_H
+#define ZSTD_LDM_H
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#include "zstd_compress_internal.h" /* ldmParams_t, U32 */
+#include "zstd.h" /* ZSTD_CCtx, size_t */
+
+/*-*************************************
+* Long distance matching
+***************************************/
+
+#define ZSTD_LDM_DEFAULT_WINDOW_LOG ZSTD_WINDOWLOG_LIMIT_DEFAULT
+
+/**
+ * ZSTD_ldm_generateSequences():
+ *
+ * Generates the sequences using the long distance match finder.
+ * Generates long range matching sequences in `sequences`, which parse a prefix
+ * of the source. `sequences` must be large enough to store every sequence,
+ * which can be checked with `ZSTD_ldm_getMaxNbSeq()`.
+ * @returns 0 or an error code.
+ *
+ * NOTE: The user must have called ZSTD_window_update() for all of the input
+ * they have, even if they pass it to ZSTD_ldm_generateSequences() in chunks.
+ * NOTE: This function returns an error if it runs out of space to store
+ * sequences.
+ */
+size_t ZSTD_ldm_generateSequences(
+ ldmState_t* ldms, rawSeqStore_t* sequences,
+ ldmParams_t const* params, void const* src, size_t srcSize);
+
+/**
+ * ZSTD_ldm_blockCompress():
+ *
+ * Compresses a block using the predefined sequences, along with a secondary
+ * block compressor. The literals section of every sequence is passed to the
+ * secondary block compressor, and those sequences are interspersed with the
+ * predefined sequences. Returns the length of the last literals.
+ * Updates `rawSeqStore.pos` to indicate how many sequences have been consumed.
+ * `rawSeqStore.seq` may also be updated to split the last sequence between two
+ * blocks.
+ * @return The length of the last literals.
+ *
+ * NOTE: The source must be at most the maximum block size, but the predefined
+ * sequences can be any size, and may be longer than the block. In the case that
+ * they are longer than the block, the last sequences may need to be split into
+ * two. We handle that case correctly, and update `rawSeqStore` appropriately.
+ * NOTE: This function does not return any errors.
+ */
+size_t ZSTD_ldm_blockCompress(rawSeqStore_t* rawSeqStore,
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+
+/**
+ * ZSTD_ldm_skipSequences():
+ *
+ * Skip past `srcSize` bytes worth of sequences in `rawSeqStore`.
+ * Avoids emitting matches less than `minMatch` bytes.
+ * Must be called for data with is not passed to ZSTD_ldm_blockCompress().
+ */
+void ZSTD_ldm_skipSequences(rawSeqStore_t* rawSeqStore, size_t srcSize,
+ U32 const minMatch);
+
+
+/** ZSTD_ldm_getTableSize() :
+ * Estimate the space needed for long distance matching tables or 0 if LDM is
+ * disabled.
+ */
+size_t ZSTD_ldm_getTableSize(ldmParams_t params);
+
+/** ZSTD_ldm_getSeqSpace() :
+ * Return an upper bound on the number of sequences that can be produced by
+ * the long distance matcher, or 0 if LDM is disabled.
+ */
+size_t ZSTD_ldm_getMaxNbSeq(ldmParams_t params, size_t maxChunkSize);
+
+/** ZSTD_ldm_adjustParameters() :
+ * If the params->hashRateLog is not set, set it to its default value based on
+ * windowLog and params->hashLog.
+ *
+ * Ensures that params->bucketSizeLog is <= params->hashLog (setting it to
+ * params->hashLog if it is not).
+ *
+ * Ensures that the minMatchLength >= targetLength during optimal parsing.
+ */
+void ZSTD_ldm_adjustParameters(ldmParams_t* params,
+ ZSTD_compressionParameters const* cParams);
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* ZSTD_FAST_H */
diff --git a/Utilities/cmzstd/lib/compress/zstd_opt.c b/Utilities/cmzstd/lib/compress/zstd_opt.c
new file mode 100644
index 000000000..44de6e97f
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstd_opt.c
@@ -0,0 +1,1217 @@
+/*
+ * Copyright (c) 2016-present, Przemyslaw Skibinski, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#include "zstd_compress_internal.h"
+#include "hist.h"
+#include "zstd_opt.h"
+
+
+#define ZSTD_LITFREQ_ADD 2 /* scaling factor for litFreq, so that frequencies adapt faster to new stats */
+#define ZSTD_FREQ_DIV 4 /* log factor when using previous stats to init next stats */
+#define ZSTD_MAX_PRICE (1<<30)
+
+#define ZSTD_PREDEF_THRESHOLD 1024 /* if srcSize < ZSTD_PREDEF_THRESHOLD, symbols' cost is assumed static, directly determined by pre-defined distributions */
+
+
+/*-*************************************
+* Price functions for optimal parser
+***************************************/
+
+#if 0 /* approximation at bit level */
+# define BITCOST_ACCURACY 0
+# define BITCOST_MULTIPLIER (1 << BITCOST_ACCURACY)
+# define WEIGHT(stat) ((void)opt, ZSTD_bitWeight(stat))
+#elif 0 /* fractional bit accuracy */
+# define BITCOST_ACCURACY 8
+# define BITCOST_MULTIPLIER (1 << BITCOST_ACCURACY)
+# define WEIGHT(stat,opt) ((void)opt, ZSTD_fracWeight(stat))
+#else /* opt==approx, ultra==accurate */
+# define BITCOST_ACCURACY 8
+# define BITCOST_MULTIPLIER (1 << BITCOST_ACCURACY)
+# define WEIGHT(stat,opt) (opt ? ZSTD_fracWeight(stat) : ZSTD_bitWeight(stat))
+#endif
+
+MEM_STATIC U32 ZSTD_bitWeight(U32 stat)
+{
+ return (ZSTD_highbit32(stat+1) * BITCOST_MULTIPLIER);
+}
+
+MEM_STATIC U32 ZSTD_fracWeight(U32 rawStat)
+{
+ U32 const stat = rawStat + 1;
+ U32 const hb = ZSTD_highbit32(stat);
+ U32 const BWeight = hb * BITCOST_MULTIPLIER;
+ U32 const FWeight = (stat << BITCOST_ACCURACY) >> hb;
+ U32 const weight = BWeight + FWeight;
+ assert(hb + BITCOST_ACCURACY < 31);
+ return weight;
+}
+
+#if (DEBUGLEVEL>=2)
+/* debugging function,
+ * @return price in bytes as fractional value
+ * for debug messages only */
+MEM_STATIC double ZSTD_fCost(U32 price)
+{
+ return (double)price / (BITCOST_MULTIPLIER*8);
+}
+#endif
+
+static void ZSTD_setBasePrices(optState_t* optPtr, int optLevel)
+{
+ optPtr->litSumBasePrice = WEIGHT(optPtr->litSum, optLevel);
+ optPtr->litLengthSumBasePrice = WEIGHT(optPtr->litLengthSum, optLevel);
+ optPtr->matchLengthSumBasePrice = WEIGHT(optPtr->matchLengthSum, optLevel);
+ optPtr->offCodeSumBasePrice = WEIGHT(optPtr->offCodeSum, optLevel);
+}
+
+
+/* ZSTD_downscaleStat() :
+ * reduce all elements in table by a factor 2^(ZSTD_FREQ_DIV+malus)
+ * return the resulting sum of elements */
+static U32 ZSTD_downscaleStat(unsigned* table, U32 lastEltIndex, int malus)
+{
+ U32 s, sum=0;
+ DEBUGLOG(5, "ZSTD_downscaleStat (nbElts=%u)", (unsigned)lastEltIndex+1);
+ assert(ZSTD_FREQ_DIV+malus > 0 && ZSTD_FREQ_DIV+malus < 31);
+ for (s=0; s<lastEltIndex+1; s++) {
+ table[s] = 1 + (table[s] >> (ZSTD_FREQ_DIV+malus));
+ sum += table[s];
+ }
+ return sum;
+}
+
+/* ZSTD_rescaleFreqs() :
+ * if first block (detected by optPtr->litLengthSum == 0) : init statistics
+ * take hints from dictionary if there is one
+ * or init from zero, using src for literals stats, or flat 1 for match symbols
+ * otherwise downscale existing stats, to be used as seed for next block.
+ */
+static void
+ZSTD_rescaleFreqs(optState_t* const optPtr,
+ const BYTE* const src, size_t const srcSize,
+ int const optLevel)
+{
+ DEBUGLOG(5, "ZSTD_rescaleFreqs (srcSize=%u)", (unsigned)srcSize);
+ optPtr->priceType = zop_dynamic;
+
+ if (optPtr->litLengthSum == 0) { /* first block : init */
+ if (srcSize <= ZSTD_PREDEF_THRESHOLD) { /* heuristic */
+ DEBUGLOG(5, "(srcSize <= ZSTD_PREDEF_THRESHOLD) => zop_predef");
+ optPtr->priceType = zop_predef;
+ }
+
+ assert(optPtr->symbolCosts != NULL);
+ if (optPtr->symbolCosts->huf.repeatMode == HUF_repeat_valid) {
+ /* huffman table presumed generated by dictionary */
+ optPtr->priceType = zop_dynamic;
+
+ assert(optPtr->litFreq != NULL);
+ optPtr->litSum = 0;
+ { unsigned lit;
+ for (lit=0; lit<=MaxLit; lit++) {
+ U32 const scaleLog = 11; /* scale to 2K */
+ U32 const bitCost = HUF_getNbBits(optPtr->symbolCosts->huf.CTable, lit);
+ assert(bitCost <= scaleLog);
+ optPtr->litFreq[lit] = bitCost ? 1 << (scaleLog-bitCost) : 1 /*minimum to calculate cost*/;
+ optPtr->litSum += optPtr->litFreq[lit];
+ } }
+
+ { unsigned ll;
+ FSE_CState_t llstate;
+ FSE_initCState(&llstate, optPtr->symbolCosts->fse.litlengthCTable);
+ optPtr->litLengthSum = 0;
+ for (ll=0; ll<=MaxLL; ll++) {
+ U32 const scaleLog = 10; /* scale to 1K */
+ U32 const bitCost = FSE_getMaxNbBits(llstate.symbolTT, ll);
+ assert(bitCost < scaleLog);
+ optPtr->litLengthFreq[ll] = bitCost ? 1 << (scaleLog-bitCost) : 1 /*minimum to calculate cost*/;
+ optPtr->litLengthSum += optPtr->litLengthFreq[ll];
+ } }
+
+ { unsigned ml;
+ FSE_CState_t mlstate;
+ FSE_initCState(&mlstate, optPtr->symbolCosts->fse.matchlengthCTable);
+ optPtr->matchLengthSum = 0;
+ for (ml=0; ml<=MaxML; ml++) {
+ U32 const scaleLog = 10;
+ U32 const bitCost = FSE_getMaxNbBits(mlstate.symbolTT, ml);
+ assert(bitCost < scaleLog);
+ optPtr->matchLengthFreq[ml] = bitCost ? 1 << (scaleLog-bitCost) : 1 /*minimum to calculate cost*/;
+ optPtr->matchLengthSum += optPtr->matchLengthFreq[ml];
+ } }
+
+ { unsigned of;
+ FSE_CState_t ofstate;
+ FSE_initCState(&ofstate, optPtr->symbolCosts->fse.offcodeCTable);
+ optPtr->offCodeSum = 0;
+ for (of=0; of<=MaxOff; of++) {
+ U32 const scaleLog = 10;
+ U32 const bitCost = FSE_getMaxNbBits(ofstate.symbolTT, of);
+ assert(bitCost < scaleLog);
+ optPtr->offCodeFreq[of] = bitCost ? 1 << (scaleLog-bitCost) : 1 /*minimum to calculate cost*/;
+ optPtr->offCodeSum += optPtr->offCodeFreq[of];
+ } }
+
+ } else { /* not a dictionary */
+
+ assert(optPtr->litFreq != NULL);
+ { unsigned lit = MaxLit;
+ HIST_count_simple(optPtr->litFreq, &lit, src, srcSize); /* use raw first block to init statistics */
+ }
+ optPtr->litSum = ZSTD_downscaleStat(optPtr->litFreq, MaxLit, 1);
+
+ { unsigned ll;
+ for (ll=0; ll<=MaxLL; ll++)
+ optPtr->litLengthFreq[ll] = 1;
+ }
+ optPtr->litLengthSum = MaxLL+1;
+
+ { unsigned ml;
+ for (ml=0; ml<=MaxML; ml++)
+ optPtr->matchLengthFreq[ml] = 1;
+ }
+ optPtr->matchLengthSum = MaxML+1;
+
+ { unsigned of;
+ for (of=0; of<=MaxOff; of++)
+ optPtr->offCodeFreq[of] = 1;
+ }
+ optPtr->offCodeSum = MaxOff+1;
+
+ }
+
+ } else { /* new block : re-use previous statistics, scaled down */
+
+ optPtr->litSum = ZSTD_downscaleStat(optPtr->litFreq, MaxLit, 1);
+ optPtr->litLengthSum = ZSTD_downscaleStat(optPtr->litLengthFreq, MaxLL, 0);
+ optPtr->matchLengthSum = ZSTD_downscaleStat(optPtr->matchLengthFreq, MaxML, 0);
+ optPtr->offCodeSum = ZSTD_downscaleStat(optPtr->offCodeFreq, MaxOff, 0);
+ }
+
+ ZSTD_setBasePrices(optPtr, optLevel);
+}
+
+/* ZSTD_rawLiteralsCost() :
+ * price of literals (only) in specified segment (which length can be 0).
+ * does not include price of literalLength symbol */
+static U32 ZSTD_rawLiteralsCost(const BYTE* const literals, U32 const litLength,
+ const optState_t* const optPtr,
+ int optLevel)
+{
+ if (litLength == 0) return 0;
+ if (optPtr->priceType == zop_predef)
+ return (litLength*6) * BITCOST_MULTIPLIER; /* 6 bit per literal - no statistic used */
+
+ /* dynamic statistics */
+ { U32 price = litLength * optPtr->litSumBasePrice;
+ U32 u;
+ for (u=0; u < litLength; u++) {
+ assert(WEIGHT(optPtr->litFreq[literals[u]], optLevel) <= optPtr->litSumBasePrice); /* literal cost should never be negative */
+ price -= WEIGHT(optPtr->litFreq[literals[u]], optLevel);
+ }
+ return price;
+ }
+}
+
+/* ZSTD_litLengthPrice() :
+ * cost of literalLength symbol */
+static U32 ZSTD_litLengthPrice(U32 const litLength, const optState_t* const optPtr, int optLevel)
+{
+ if (optPtr->priceType == zop_predef) return WEIGHT(litLength, optLevel);
+
+ /* dynamic statistics */
+ { U32 const llCode = ZSTD_LLcode(litLength);
+ return (LL_bits[llCode] * BITCOST_MULTIPLIER)
+ + optPtr->litLengthSumBasePrice
+ - WEIGHT(optPtr->litLengthFreq[llCode], optLevel);
+ }
+}
+
+/* ZSTD_litLengthContribution() :
+ * @return ( cost(litlength) - cost(0) )
+ * this value can then be added to rawLiteralsCost()
+ * to provide a cost which is directly comparable to a match ending at same position */
+static int ZSTD_litLengthContribution(U32 const litLength, const optState_t* const optPtr, int optLevel)
+{
+ if (optPtr->priceType >= zop_predef) return WEIGHT(litLength, optLevel);
+
+ /* dynamic statistics */
+ { U32 const llCode = ZSTD_LLcode(litLength);
+ int const contribution = (LL_bits[llCode] * BITCOST_MULTIPLIER)
+ + WEIGHT(optPtr->litLengthFreq[0], optLevel) /* note: log2litLengthSum cancel out */
+ - WEIGHT(optPtr->litLengthFreq[llCode], optLevel);
+#if 1
+ return contribution;
+#else
+ return MAX(0, contribution); /* sometimes better, sometimes not ... */
+#endif
+ }
+}
+
+/* ZSTD_literalsContribution() :
+ * creates a fake cost for the literals part of a sequence
+ * which can be compared to the ending cost of a match
+ * should a new match start at this position */
+static int ZSTD_literalsContribution(const BYTE* const literals, U32 const litLength,
+ const optState_t* const optPtr,
+ int optLevel)
+{
+ int const contribution = ZSTD_rawLiteralsCost(literals, litLength, optPtr, optLevel)
+ + ZSTD_litLengthContribution(litLength, optPtr, optLevel);
+ return contribution;
+}
+
+/* ZSTD_getMatchPrice() :
+ * Provides the cost of the match part (offset + matchLength) of a sequence
+ * Must be combined with ZSTD_fullLiteralsCost() to get the full cost of a sequence.
+ * optLevel: when <2, favors small offset for decompression speed (improved cache efficiency) */
+FORCE_INLINE_TEMPLATE U32
+ZSTD_getMatchPrice(U32 const offset,
+ U32 const matchLength,
+ const optState_t* const optPtr,
+ int const optLevel)
+{
+ U32 price;
+ U32 const offCode = ZSTD_highbit32(offset+1);
+ U32 const mlBase = matchLength - MINMATCH;
+ assert(matchLength >= MINMATCH);
+
+ if (optPtr->priceType == zop_predef) /* fixed scheme, do not use statistics */
+ return WEIGHT(mlBase, optLevel) + ((16 + offCode) * BITCOST_MULTIPLIER);
+
+ /* dynamic statistics */
+ price = (offCode * BITCOST_MULTIPLIER) + (optPtr->offCodeSumBasePrice - WEIGHT(optPtr->offCodeFreq[offCode], optLevel));
+ if ((optLevel<2) /*static*/ && offCode >= 20)
+ price += (offCode-19)*2 * BITCOST_MULTIPLIER; /* handicap for long distance offsets, favor decompression speed */
+
+ /* match Length */
+ { U32 const mlCode = ZSTD_MLcode(mlBase);
+ price += (ML_bits[mlCode] * BITCOST_MULTIPLIER) + (optPtr->matchLengthSumBasePrice - WEIGHT(optPtr->matchLengthFreq[mlCode], optLevel));
+ }
+
+ price += BITCOST_MULTIPLIER / 5; /* heuristic : make matches a bit more costly to favor less sequences -> faster decompression speed */
+
+ DEBUGLOG(8, "ZSTD_getMatchPrice(ml:%u) = %u", matchLength, price);
+ return price;
+}
+
+/* ZSTD_updateStats() :
+ * assumption : literals + litLengtn <= iend */
+static void ZSTD_updateStats(optState_t* const optPtr,
+ U32 litLength, const BYTE* literals,
+ U32 offsetCode, U32 matchLength)
+{
+ /* literals */
+ { U32 u;
+ for (u=0; u < litLength; u++)
+ optPtr->litFreq[literals[u]] += ZSTD_LITFREQ_ADD;
+ optPtr->litSum += litLength*ZSTD_LITFREQ_ADD;
+ }
+
+ /* literal Length */
+ { U32 const llCode = ZSTD_LLcode(litLength);
+ optPtr->litLengthFreq[llCode]++;
+ optPtr->litLengthSum++;
+ }
+
+ /* match offset code (0-2=>repCode; 3+=>offset+2) */
+ { U32 const offCode = ZSTD_highbit32(offsetCode+1);
+ assert(offCode <= MaxOff);
+ optPtr->offCodeFreq[offCode]++;
+ optPtr->offCodeSum++;
+ }
+
+ /* match Length */
+ { U32 const mlBase = matchLength - MINMATCH;
+ U32 const mlCode = ZSTD_MLcode(mlBase);
+ optPtr->matchLengthFreq[mlCode]++;
+ optPtr->matchLengthSum++;
+ }
+}
+
+
+/* ZSTD_readMINMATCH() :
+ * function safe only for comparisons
+ * assumption : memPtr must be at least 4 bytes before end of buffer */
+MEM_STATIC U32 ZSTD_readMINMATCH(const void* memPtr, U32 length)
+{
+ switch (length)
+ {
+ default :
+ case 4 : return MEM_read32(memPtr);
+ case 3 : if (MEM_isLittleEndian())
+ return MEM_read32(memPtr)<<8;
+ else
+ return MEM_read32(memPtr)>>8;
+ }
+}
+
+
+/* Update hashTable3 up to ip (excluded)
+ Assumption : always within prefix (i.e. not within extDict) */
+static U32 ZSTD_insertAndFindFirstIndexHash3 (ZSTD_matchState_t* ms, const BYTE* const ip)
+{
+ U32* const hashTable3 = ms->hashTable3;
+ U32 const hashLog3 = ms->hashLog3;
+ const BYTE* const base = ms->window.base;
+ U32 idx = ms->nextToUpdate3;
+ U32 const target = ms->nextToUpdate3 = (U32)(ip - base);
+ size_t const hash3 = ZSTD_hash3Ptr(ip, hashLog3);
+ assert(hashLog3 > 0);
+
+ while(idx < target) {
+ hashTable3[ZSTD_hash3Ptr(base+idx, hashLog3)] = idx;
+ idx++;
+ }
+
+ return hashTable3[hash3];
+}
+
+
+/*-*************************************
+* Binary Tree search
+***************************************/
+/** ZSTD_insertBt1() : add one or multiple positions to tree.
+ * ip : assumed <= iend-8 .
+ * @return : nb of positions added */
+static U32 ZSTD_insertBt1(
+ ZSTD_matchState_t* ms,
+ const BYTE* const ip, const BYTE* const iend,
+ U32 const mls, const int extDict)
+{
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+ U32* const hashTable = ms->hashTable;
+ U32 const hashLog = cParams->hashLog;
+ size_t const h = ZSTD_hashPtr(ip, hashLog, mls);
+ U32* const bt = ms->chainTable;
+ U32 const btLog = cParams->chainLog - 1;
+ U32 const btMask = (1 << btLog) - 1;
+ U32 matchIndex = hashTable[h];
+ size_t commonLengthSmaller=0, commonLengthLarger=0;
+ const BYTE* const base = ms->window.base;
+ const BYTE* const dictBase = ms->window.dictBase;
+ const U32 dictLimit = ms->window.dictLimit;
+ const BYTE* const dictEnd = dictBase + dictLimit;
+ const BYTE* const prefixStart = base + dictLimit;
+ const BYTE* match;
+ const U32 current = (U32)(ip-base);
+ const U32 btLow = btMask >= current ? 0 : current - btMask;
+ U32* smallerPtr = bt + 2*(current&btMask);
+ U32* largerPtr = smallerPtr + 1;
+ U32 dummy32; /* to be nullified at the end */
+ U32 const windowLow = ms->window.lowLimit;
+ U32 matchEndIdx = current+8+1;
+ size_t bestLength = 8;
+ U32 nbCompares = 1U << cParams->searchLog;
+#ifdef ZSTD_C_PREDICT
+ U32 predictedSmall = *(bt + 2*((current-1)&btMask) + 0);
+ U32 predictedLarge = *(bt + 2*((current-1)&btMask) + 1);
+ predictedSmall += (predictedSmall>0);
+ predictedLarge += (predictedLarge>0);
+#endif /* ZSTD_C_PREDICT */
+
+ DEBUGLOG(8, "ZSTD_insertBt1 (%u)", current);
+
+ assert(ip <= iend-8); /* required for h calculation */
+ hashTable[h] = current; /* Update Hash Table */
+
+ assert(windowLow > 0);
+ while (nbCompares-- && (matchIndex >= windowLow)) {
+ U32* const nextPtr = bt + 2*(matchIndex & btMask);
+ size_t matchLength = MIN(commonLengthSmaller, commonLengthLarger); /* guaranteed minimum nb of common bytes */
+ assert(matchIndex < current);
+
+#ifdef ZSTD_C_PREDICT /* note : can create issues when hlog small <= 11 */
+ const U32* predictPtr = bt + 2*((matchIndex-1) & btMask); /* written this way, as bt is a roll buffer */
+ if (matchIndex == predictedSmall) {
+ /* no need to check length, result known */
+ *smallerPtr = matchIndex;
+ if (matchIndex <= btLow) { smallerPtr=&dummy32; break; } /* beyond tree size, stop the search */
+ smallerPtr = nextPtr+1; /* new "smaller" => larger of match */
+ matchIndex = nextPtr[1]; /* new matchIndex larger than previous (closer to current) */
+ predictedSmall = predictPtr[1] + (predictPtr[1]>0);
+ continue;
+ }
+ if (matchIndex == predictedLarge) {
+ *largerPtr = matchIndex;
+ if (matchIndex <= btLow) { largerPtr=&dummy32; break; } /* beyond tree size, stop the search */
+ largerPtr = nextPtr;
+ matchIndex = nextPtr[0];
+ predictedLarge = predictPtr[0] + (predictPtr[0]>0);
+ continue;
+ }
+#endif
+
+ if (!extDict || (matchIndex+matchLength >= dictLimit)) {
+ assert(matchIndex+matchLength >= dictLimit); /* might be wrong if actually extDict */
+ match = base + matchIndex;
+ matchLength += ZSTD_count(ip+matchLength, match+matchLength, iend);
+ } else {
+ match = dictBase + matchIndex;
+ matchLength += ZSTD_count_2segments(ip+matchLength, match+matchLength, iend, dictEnd, prefixStart);
+ if (matchIndex+matchLength >= dictLimit)
+ match = base + matchIndex; /* to prepare for next usage of match[matchLength] */
+ }
+
+ if (matchLength > bestLength) {
+ bestLength = matchLength;
+ if (matchLength > matchEndIdx - matchIndex)
+ matchEndIdx = matchIndex + (U32)matchLength;
+ }
+
+ if (ip+matchLength == iend) { /* equal : no way to know if inf or sup */
+ break; /* drop , to guarantee consistency ; miss a bit of compression, but other solutions can corrupt tree */
+ }
+
+ if (match[matchLength] < ip[matchLength]) { /* necessarily within buffer */
+ /* match is smaller than current */
+ *smallerPtr = matchIndex; /* update smaller idx */
+ commonLengthSmaller = matchLength; /* all smaller will now have at least this guaranteed common length */
+ if (matchIndex <= btLow) { smallerPtr=&dummy32; break; } /* beyond tree size, stop searching */
+ smallerPtr = nextPtr+1; /* new "candidate" => larger than match, which was smaller than target */
+ matchIndex = nextPtr[1]; /* new matchIndex, larger than previous and closer to current */
+ } else {
+ /* match is larger than current */
+ *largerPtr = matchIndex;
+ commonLengthLarger = matchLength;
+ if (matchIndex <= btLow) { largerPtr=&dummy32; break; } /* beyond tree size, stop searching */
+ largerPtr = nextPtr;
+ matchIndex = nextPtr[0];
+ } }
+
+ *smallerPtr = *largerPtr = 0;
+ if (bestLength > 384) return MIN(192, (U32)(bestLength - 384)); /* speed optimization */
+ assert(matchEndIdx > current + 8);
+ return matchEndIdx - (current + 8);
+}
+
+FORCE_INLINE_TEMPLATE
+void ZSTD_updateTree_internal(
+ ZSTD_matchState_t* ms,
+ const BYTE* const ip, const BYTE* const iend,
+ const U32 mls, const ZSTD_dictMode_e dictMode)
+{
+ const BYTE* const base = ms->window.base;
+ U32 const target = (U32)(ip - base);
+ U32 idx = ms->nextToUpdate;
+ DEBUGLOG(6, "ZSTD_updateTree_internal, from %u to %u (dictMode:%u)",
+ idx, target, dictMode);
+
+ while(idx < target)
+ idx += ZSTD_insertBt1(ms, base+idx, iend, mls, dictMode == ZSTD_extDict);
+ ms->nextToUpdate = target;
+}
+
+void ZSTD_updateTree(ZSTD_matchState_t* ms, const BYTE* ip, const BYTE* iend) {
+ ZSTD_updateTree_internal(ms, ip, iend, ms->cParams.minMatch, ZSTD_noDict);
+}
+
+FORCE_INLINE_TEMPLATE
+U32 ZSTD_insertBtAndGetAllMatches (
+ ZSTD_matchState_t* ms,
+ const BYTE* const ip, const BYTE* const iLimit, const ZSTD_dictMode_e dictMode,
+ U32 rep[ZSTD_REP_NUM],
+ U32 const ll0, /* tells if associated literal length is 0 or not. This value must be 0 or 1 */
+ ZSTD_match_t* matches,
+ const U32 lengthToBeat,
+ U32 const mls /* template */)
+{
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+ U32 const sufficient_len = MIN(cParams->targetLength, ZSTD_OPT_NUM -1);
+ const BYTE* const base = ms->window.base;
+ U32 const current = (U32)(ip-base);
+ U32 const hashLog = cParams->hashLog;
+ U32 const minMatch = (mls==3) ? 3 : 4;
+ U32* const hashTable = ms->hashTable;
+ size_t const h = ZSTD_hashPtr(ip, hashLog, mls);
+ U32 matchIndex = hashTable[h];
+ U32* const bt = ms->chainTable;
+ U32 const btLog = cParams->chainLog - 1;
+ U32 const btMask= (1U << btLog) - 1;
+ size_t commonLengthSmaller=0, commonLengthLarger=0;
+ const BYTE* const dictBase = ms->window.dictBase;
+ U32 const dictLimit = ms->window.dictLimit;
+ const BYTE* const dictEnd = dictBase + dictLimit;
+ const BYTE* const prefixStart = base + dictLimit;
+ U32 const btLow = btMask >= current ? 0 : current - btMask;
+ U32 const windowLow = ms->window.lowLimit;
+ U32 const matchLow = windowLow ? windowLow : 1;
+ U32* smallerPtr = bt + 2*(current&btMask);
+ U32* largerPtr = bt + 2*(current&btMask) + 1;
+ U32 matchEndIdx = current+8+1; /* farthest referenced position of any match => detects repetitive patterns */
+ U32 dummy32; /* to be nullified at the end */
+ U32 mnum = 0;
+ U32 nbCompares = 1U << cParams->searchLog;
+
+ const ZSTD_matchState_t* dms = dictMode == ZSTD_dictMatchState ? ms->dictMatchState : NULL;
+ const ZSTD_compressionParameters* const dmsCParams =
+ dictMode == ZSTD_dictMatchState ? &dms->cParams : NULL;
+ const BYTE* const dmsBase = dictMode == ZSTD_dictMatchState ? dms->window.base : NULL;
+ const BYTE* const dmsEnd = dictMode == ZSTD_dictMatchState ? dms->window.nextSrc : NULL;
+ U32 const dmsHighLimit = dictMode == ZSTD_dictMatchState ? (U32)(dmsEnd - dmsBase) : 0;
+ U32 const dmsLowLimit = dictMode == ZSTD_dictMatchState ? dms->window.lowLimit : 0;
+ U32 const dmsIndexDelta = dictMode == ZSTD_dictMatchState ? windowLow - dmsHighLimit : 0;
+ U32 const dmsHashLog = dictMode == ZSTD_dictMatchState ? dmsCParams->hashLog : hashLog;
+ U32 const dmsBtLog = dictMode == ZSTD_dictMatchState ? dmsCParams->chainLog - 1 : btLog;
+ U32 const dmsBtMask = dictMode == ZSTD_dictMatchState ? (1U << dmsBtLog) - 1 : 0;
+ U32 const dmsBtLow = dictMode == ZSTD_dictMatchState && dmsBtMask < dmsHighLimit - dmsLowLimit ? dmsHighLimit - dmsBtMask : dmsLowLimit;
+
+ size_t bestLength = lengthToBeat-1;
+ DEBUGLOG(8, "ZSTD_insertBtAndGetAllMatches: current=%u", current);
+
+ /* check repCode */
+ assert(ll0 <= 1); /* necessarily 1 or 0 */
+ { U32 const lastR = ZSTD_REP_NUM + ll0;
+ U32 repCode;
+ for (repCode = ll0; repCode < lastR; repCode++) {
+ U32 const repOffset = (repCode==ZSTD_REP_NUM) ? (rep[0] - 1) : rep[repCode];
+ U32 const repIndex = current - repOffset;
+ U32 repLen = 0;
+ assert(current >= dictLimit);
+ if (repOffset-1 /* intentional overflow, discards 0 and -1 */ < current-dictLimit) { /* equivalent to `current > repIndex >= dictLimit` */
+ if (ZSTD_readMINMATCH(ip, minMatch) == ZSTD_readMINMATCH(ip - repOffset, minMatch)) {
+ repLen = (U32)ZSTD_count(ip+minMatch, ip+minMatch-repOffset, iLimit) + minMatch;
+ }
+ } else { /* repIndex < dictLimit || repIndex >= current */
+ const BYTE* const repMatch = dictMode == ZSTD_dictMatchState ?
+ dmsBase + repIndex - dmsIndexDelta :
+ dictBase + repIndex;
+ assert(current >= windowLow);
+ if ( dictMode == ZSTD_extDict
+ && ( ((repOffset-1) /*intentional overflow*/ < current - windowLow) /* equivalent to `current > repIndex >= windowLow` */
+ & (((U32)((dictLimit-1) - repIndex) >= 3) ) /* intentional overflow : do not test positions overlapping 2 memory segments */)
+ && (ZSTD_readMINMATCH(ip, minMatch) == ZSTD_readMINMATCH(repMatch, minMatch)) ) {
+ repLen = (U32)ZSTD_count_2segments(ip+minMatch, repMatch+minMatch, iLimit, dictEnd, prefixStart) + minMatch;
+ }
+ if (dictMode == ZSTD_dictMatchState
+ && ( ((repOffset-1) /*intentional overflow*/ < current - (dmsLowLimit + dmsIndexDelta)) /* equivalent to `current > repIndex >= dmsLowLimit` */
+ & ((U32)((dictLimit-1) - repIndex) >= 3) ) /* intentional overflow : do not test positions overlapping 2 memory segments */
+ && (ZSTD_readMINMATCH(ip, minMatch) == ZSTD_readMINMATCH(repMatch, minMatch)) ) {
+ repLen = (U32)ZSTD_count_2segments(ip+minMatch, repMatch+minMatch, iLimit, dmsEnd, prefixStart) + minMatch;
+ } }
+ /* save longer solution */
+ if (repLen > bestLength) {
+ DEBUGLOG(8, "found repCode %u (ll0:%u, offset:%u) of length %u",
+ repCode, ll0, repOffset, repLen);
+ bestLength = repLen;
+ matches[mnum].off = repCode - ll0;
+ matches[mnum].len = (U32)repLen;
+ mnum++;
+ if ( (repLen > sufficient_len)
+ | (ip+repLen == iLimit) ) { /* best possible */
+ return mnum;
+ } } } }
+
+ /* HC3 match finder */
+ if ((mls == 3) /*static*/ && (bestLength < mls)) {
+ U32 const matchIndex3 = ZSTD_insertAndFindFirstIndexHash3(ms, ip);
+ if ((matchIndex3 >= matchLow)
+ & (current - matchIndex3 < (1<<18)) /*heuristic : longer distance likely too expensive*/ ) {
+ size_t mlen;
+ if ((dictMode == ZSTD_noDict) /*static*/ || (dictMode == ZSTD_dictMatchState) /*static*/ || (matchIndex3 >= dictLimit)) {
+ const BYTE* const match = base + matchIndex3;
+ mlen = ZSTD_count(ip, match, iLimit);
+ } else {
+ const BYTE* const match = dictBase + matchIndex3;
+ mlen = ZSTD_count_2segments(ip, match, iLimit, dictEnd, prefixStart);
+ }
+
+ /* save best solution */
+ if (mlen >= mls /* == 3 > bestLength */) {
+ DEBUGLOG(8, "found small match with hlog3, of length %u",
+ (U32)mlen);
+ bestLength = mlen;
+ assert(current > matchIndex3);
+ assert(mnum==0); /* no prior solution */
+ matches[0].off = (current - matchIndex3) + ZSTD_REP_MOVE;
+ matches[0].len = (U32)mlen;
+ mnum = 1;
+ if ( (mlen > sufficient_len) |
+ (ip+mlen == iLimit) ) { /* best possible length */
+ ms->nextToUpdate = current+1; /* skip insertion */
+ return 1;
+ }
+ }
+ }
+ /* no dictMatchState lookup: dicts don't have a populated HC3 table */
+ }
+
+ hashTable[h] = current; /* Update Hash Table */
+
+ while (nbCompares-- && (matchIndex >= matchLow)) {
+ U32* const nextPtr = bt + 2*(matchIndex & btMask);
+ size_t matchLength = MIN(commonLengthSmaller, commonLengthLarger); /* guaranteed minimum nb of common bytes */
+ const BYTE* match;
+ assert(current > matchIndex);
+
+ if ((dictMode == ZSTD_noDict) || (dictMode == ZSTD_dictMatchState) || (matchIndex+matchLength >= dictLimit)) {
+ assert(matchIndex+matchLength >= dictLimit); /* ensure the condition is correct when !extDict */
+ match = base + matchIndex;
+ matchLength += ZSTD_count(ip+matchLength, match+matchLength, iLimit);
+ } else {
+ match = dictBase + matchIndex;
+ matchLength += ZSTD_count_2segments(ip+matchLength, match+matchLength, iLimit, dictEnd, prefixStart);
+ if (matchIndex+matchLength >= dictLimit)
+ match = base + matchIndex; /* prepare for match[matchLength] */
+ }
+
+ if (matchLength > bestLength) {
+ DEBUGLOG(8, "found match of length %u at distance %u (offCode=%u)",
+ (U32)matchLength, current - matchIndex, current - matchIndex + ZSTD_REP_MOVE);
+ assert(matchEndIdx > matchIndex);
+ if (matchLength > matchEndIdx - matchIndex)
+ matchEndIdx = matchIndex + (U32)matchLength;
+ bestLength = matchLength;
+ matches[mnum].off = (current - matchIndex) + ZSTD_REP_MOVE;
+ matches[mnum].len = (U32)matchLength;
+ mnum++;
+ if ( (matchLength > ZSTD_OPT_NUM)
+ | (ip+matchLength == iLimit) /* equal : no way to know if inf or sup */) {
+ if (dictMode == ZSTD_dictMatchState) nbCompares = 0; /* break should also skip searching dms */
+ break; /* drop, to preserve bt consistency (miss a little bit of compression) */
+ }
+ }
+
+ if (match[matchLength] < ip[matchLength]) {
+ /* match smaller than current */
+ *smallerPtr = matchIndex; /* update smaller idx */
+ commonLengthSmaller = matchLength; /* all smaller will now have at least this guaranteed common length */
+ if (matchIndex <= btLow) { smallerPtr=&dummy32; break; } /* beyond tree size, stop the search */
+ smallerPtr = nextPtr+1; /* new candidate => larger than match, which was smaller than current */
+ matchIndex = nextPtr[1]; /* new matchIndex, larger than previous, closer to current */
+ } else {
+ *largerPtr = matchIndex;
+ commonLengthLarger = matchLength;
+ if (matchIndex <= btLow) { largerPtr=&dummy32; break; } /* beyond tree size, stop the search */
+ largerPtr = nextPtr;
+ matchIndex = nextPtr[0];
+ } }
+
+ *smallerPtr = *largerPtr = 0;
+
+ if (dictMode == ZSTD_dictMatchState && nbCompares) {
+ size_t const dmsH = ZSTD_hashPtr(ip, dmsHashLog, mls);
+ U32 dictMatchIndex = dms->hashTable[dmsH];
+ const U32* const dmsBt = dms->chainTable;
+ commonLengthSmaller = commonLengthLarger = 0;
+ while (nbCompares-- && (dictMatchIndex > dmsLowLimit)) {
+ const U32* const nextPtr = dmsBt + 2*(dictMatchIndex & dmsBtMask);
+ size_t matchLength = MIN(commonLengthSmaller, commonLengthLarger); /* guaranteed minimum nb of common bytes */
+ const BYTE* match = dmsBase + dictMatchIndex;
+ matchLength += ZSTD_count_2segments(ip+matchLength, match+matchLength, iLimit, dmsEnd, prefixStart);
+ if (dictMatchIndex+matchLength >= dmsHighLimit)
+ match = base + dictMatchIndex + dmsIndexDelta; /* to prepare for next usage of match[matchLength] */
+
+ if (matchLength > bestLength) {
+ matchIndex = dictMatchIndex + dmsIndexDelta;
+ DEBUGLOG(8, "found dms match of length %u at distance %u (offCode=%u)",
+ (U32)matchLength, current - matchIndex, current - matchIndex + ZSTD_REP_MOVE);
+ if (matchLength > matchEndIdx - matchIndex)
+ matchEndIdx = matchIndex + (U32)matchLength;
+ bestLength = matchLength;
+ matches[mnum].off = (current - matchIndex) + ZSTD_REP_MOVE;
+ matches[mnum].len = (U32)matchLength;
+ mnum++;
+ if ( (matchLength > ZSTD_OPT_NUM)
+ | (ip+matchLength == iLimit) /* equal : no way to know if inf or sup */) {
+ break; /* drop, to guarantee consistency (miss a little bit of compression) */
+ }
+ }
+
+ if (dictMatchIndex <= dmsBtLow) { break; } /* beyond tree size, stop the search */
+ if (match[matchLength] < ip[matchLength]) {
+ commonLengthSmaller = matchLength; /* all smaller will now have at least this guaranteed common length */
+ dictMatchIndex = nextPtr[1]; /* new matchIndex larger than previous (closer to current) */
+ } else {
+ /* match is larger than current */
+ commonLengthLarger = matchLength;
+ dictMatchIndex = nextPtr[0];
+ }
+ }
+ }
+
+ assert(matchEndIdx > current+8);
+ ms->nextToUpdate = matchEndIdx - 8; /* skip repetitive patterns */
+ return mnum;
+}
+
+
+FORCE_INLINE_TEMPLATE U32 ZSTD_BtGetAllMatches (
+ ZSTD_matchState_t* ms,
+ const BYTE* ip, const BYTE* const iHighLimit, const ZSTD_dictMode_e dictMode,
+ U32 rep[ZSTD_REP_NUM], U32 const ll0,
+ ZSTD_match_t* matches, U32 const lengthToBeat)
+{
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+ U32 const matchLengthSearch = cParams->minMatch;
+ DEBUGLOG(8, "ZSTD_BtGetAllMatches");
+ if (ip < ms->window.base + ms->nextToUpdate) return 0; /* skipped area */
+ ZSTD_updateTree_internal(ms, ip, iHighLimit, matchLengthSearch, dictMode);
+ switch(matchLengthSearch)
+ {
+ case 3 : return ZSTD_insertBtAndGetAllMatches(ms, ip, iHighLimit, dictMode, rep, ll0, matches, lengthToBeat, 3);
+ default :
+ case 4 : return ZSTD_insertBtAndGetAllMatches(ms, ip, iHighLimit, dictMode, rep, ll0, matches, lengthToBeat, 4);
+ case 5 : return ZSTD_insertBtAndGetAllMatches(ms, ip, iHighLimit, dictMode, rep, ll0, matches, lengthToBeat, 5);
+ case 7 :
+ case 6 : return ZSTD_insertBtAndGetAllMatches(ms, ip, iHighLimit, dictMode, rep, ll0, matches, lengthToBeat, 6);
+ }
+}
+
+
+/*-*******************************
+* Optimal parser
+*********************************/
+typedef struct repcodes_s {
+ U32 rep[3];
+} repcodes_t;
+
+static repcodes_t ZSTD_updateRep(U32 const rep[3], U32 const offset, U32 const ll0)
+{
+ repcodes_t newReps;
+ if (offset >= ZSTD_REP_NUM) { /* full offset */
+ newReps.rep[2] = rep[1];
+ newReps.rep[1] = rep[0];
+ newReps.rep[0] = offset - ZSTD_REP_MOVE;
+ } else { /* repcode */
+ U32 const repCode = offset + ll0;
+ if (repCode > 0) { /* note : if repCode==0, no change */
+ U32 const currentOffset = (repCode==ZSTD_REP_NUM) ? (rep[0] - 1) : rep[repCode];
+ newReps.rep[2] = (repCode >= 2) ? rep[1] : rep[2];
+ newReps.rep[1] = rep[0];
+ newReps.rep[0] = currentOffset;
+ } else { /* repCode == 0 */
+ memcpy(&newReps, rep, sizeof(newReps));
+ }
+ }
+ return newReps;
+}
+
+
+static U32 ZSTD_totalLen(ZSTD_optimal_t sol)
+{
+ return sol.litlen + sol.mlen;
+}
+
+#if 0 /* debug */
+
+static void
+listStats(const U32* table, int lastEltID)
+{
+ int const nbElts = lastEltID + 1;
+ int enb;
+ for (enb=0; enb < nbElts; enb++) {
+ (void)table;
+ //RAWLOG(2, "%3i:%3i, ", enb, table[enb]);
+ RAWLOG(2, "%4i,", table[enb]);
+ }
+ RAWLOG(2, " \n");
+}
+
+#endif
+
+FORCE_INLINE_TEMPLATE size_t
+ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms,
+ seqStore_t* seqStore,
+ U32 rep[ZSTD_REP_NUM],
+ const void* src, size_t srcSize,
+ const int optLevel,
+ const ZSTD_dictMode_e dictMode)
+{
+ optState_t* const optStatePtr = &ms->opt;
+ const BYTE* const istart = (const BYTE*)src;
+ const BYTE* ip = istart;
+ const BYTE* anchor = istart;
+ const BYTE* const iend = istart + srcSize;
+ const BYTE* const ilimit = iend - 8;
+ const BYTE* const base = ms->window.base;
+ const BYTE* const prefixStart = base + ms->window.dictLimit;
+ const ZSTD_compressionParameters* const cParams = &ms->cParams;
+
+ U32 const sufficient_len = MIN(cParams->targetLength, ZSTD_OPT_NUM -1);
+ U32 const minMatch = (cParams->minMatch == 3) ? 3 : 4;
+
+ ZSTD_optimal_t* const opt = optStatePtr->priceTable;
+ ZSTD_match_t* const matches = optStatePtr->matchTable;
+ ZSTD_optimal_t lastSequence;
+
+ /* init */
+ DEBUGLOG(5, "ZSTD_compressBlock_opt_generic: current=%u, prefix=%u, nextToUpdate=%u",
+ (U32)(ip - base), ms->window.dictLimit, ms->nextToUpdate);
+ assert(optLevel <= 2);
+ ms->nextToUpdate3 = ms->nextToUpdate;
+ ZSTD_rescaleFreqs(optStatePtr, (const BYTE*)src, srcSize, optLevel);
+ ip += (ip==prefixStart);
+
+ /* Match Loop */
+ while (ip < ilimit) {
+ U32 cur, last_pos = 0;
+
+ /* find first match */
+ { U32 const litlen = (U32)(ip - anchor);
+ U32 const ll0 = !litlen;
+ U32 const nbMatches = ZSTD_BtGetAllMatches(ms, ip, iend, dictMode, rep, ll0, matches, minMatch);
+ if (!nbMatches) { ip++; continue; }
+
+ /* initialize opt[0] */
+ { U32 i ; for (i=0; i<ZSTD_REP_NUM; i++) opt[0].rep[i] = rep[i]; }
+ opt[0].mlen = 0; /* means is_a_literal */
+ opt[0].litlen = litlen;
+ opt[0].price = ZSTD_literalsContribution(anchor, litlen, optStatePtr, optLevel);
+
+ /* large match -> immediate encoding */
+ { U32 const maxML = matches[nbMatches-1].len;
+ U32 const maxOffset = matches[nbMatches-1].off;
+ DEBUGLOG(6, "found %u matches of maxLength=%u and maxOffCode=%u at cPos=%u => start new serie",
+ nbMatches, maxML, maxOffset, (U32)(ip-prefixStart));
+
+ if (maxML > sufficient_len) {
+ lastSequence.litlen = litlen;
+ lastSequence.mlen = maxML;
+ lastSequence.off = maxOffset;
+ DEBUGLOG(6, "large match (%u>%u), immediate encoding",
+ maxML, sufficient_len);
+ cur = 0;
+ last_pos = ZSTD_totalLen(lastSequence);
+ goto _shortestPath;
+ } }
+
+ /* set prices for first matches starting position == 0 */
+ { U32 const literalsPrice = opt[0].price + ZSTD_litLengthPrice(0, optStatePtr, optLevel);
+ U32 pos;
+ U32 matchNb;
+ for (pos = 1; pos < minMatch; pos++) {
+ opt[pos].price = ZSTD_MAX_PRICE; /* mlen, litlen and price will be fixed during forward scanning */
+ }
+ for (matchNb = 0; matchNb < nbMatches; matchNb++) {
+ U32 const offset = matches[matchNb].off;
+ U32 const end = matches[matchNb].len;
+ repcodes_t const repHistory = ZSTD_updateRep(rep, offset, ll0);
+ for ( ; pos <= end ; pos++ ) {
+ U32 const matchPrice = ZSTD_getMatchPrice(offset, pos, optStatePtr, optLevel);
+ U32 const sequencePrice = literalsPrice + matchPrice;
+ DEBUGLOG(7, "rPos:%u => set initial price : %.2f",
+ pos, ZSTD_fCost(sequencePrice));
+ opt[pos].mlen = pos;
+ opt[pos].off = offset;
+ opt[pos].litlen = litlen;
+ opt[pos].price = sequencePrice;
+ ZSTD_STATIC_ASSERT(sizeof(opt[pos].rep) == sizeof(repHistory));
+ memcpy(opt[pos].rep, &repHistory, sizeof(repHistory));
+ } }
+ last_pos = pos-1;
+ }
+ }
+
+ /* check further positions */
+ for (cur = 1; cur <= last_pos; cur++) {
+ const BYTE* const inr = ip + cur;
+ assert(cur < ZSTD_OPT_NUM);
+ DEBUGLOG(7, "cPos:%zi==rPos:%u", inr-istart, cur)
+
+ /* Fix current position with one literal if cheaper */
+ { U32 const litlen = (opt[cur-1].mlen == 0) ? opt[cur-1].litlen + 1 : 1;
+ int const price = opt[cur-1].price
+ + ZSTD_rawLiteralsCost(ip+cur-1, 1, optStatePtr, optLevel)
+ + ZSTD_litLengthPrice(litlen, optStatePtr, optLevel)
+ - ZSTD_litLengthPrice(litlen-1, optStatePtr, optLevel);
+ assert(price < 1000000000); /* overflow check */
+ if (price <= opt[cur].price) {
+ DEBUGLOG(7, "cPos:%zi==rPos:%u : better price (%.2f<=%.2f) using literal (ll==%u) (hist:%u,%u,%u)",
+ inr-istart, cur, ZSTD_fCost(price), ZSTD_fCost(opt[cur].price), litlen,
+ opt[cur-1].rep[0], opt[cur-1].rep[1], opt[cur-1].rep[2]);
+ opt[cur].mlen = 0;
+ opt[cur].off = 0;
+ opt[cur].litlen = litlen;
+ opt[cur].price = price;
+ memcpy(opt[cur].rep, opt[cur-1].rep, sizeof(opt[cur].rep));
+ } else {
+ DEBUGLOG(7, "cPos:%zi==rPos:%u : literal would cost more (%.2f>%.2f) (hist:%u,%u,%u)",
+ inr-istart, cur, ZSTD_fCost(price), ZSTD_fCost(opt[cur].price),
+ opt[cur].rep[0], opt[cur].rep[1], opt[cur].rep[2]);
+ }
+ }
+
+ /* last match must start at a minimum distance of 8 from oend */
+ if (inr > ilimit) continue;
+
+ if (cur == last_pos) break;
+
+ if ( (optLevel==0) /*static_test*/
+ && (opt[cur+1].price <= opt[cur].price + (BITCOST_MULTIPLIER/2)) ) {
+ DEBUGLOG(7, "move to next rPos:%u : price is <=", cur+1);
+ continue; /* skip unpromising positions; about ~+6% speed, -0.01 ratio */
+ }
+
+ { U32 const ll0 = (opt[cur].mlen != 0);
+ U32 const litlen = (opt[cur].mlen == 0) ? opt[cur].litlen : 0;
+ U32 const previousPrice = opt[cur].price;
+ U32 const basePrice = previousPrice + ZSTD_litLengthPrice(0, optStatePtr, optLevel);
+ U32 const nbMatches = ZSTD_BtGetAllMatches(ms, inr, iend, dictMode, opt[cur].rep, ll0, matches, minMatch);
+ U32 matchNb;
+ if (!nbMatches) {
+ DEBUGLOG(7, "rPos:%u : no match found", cur);
+ continue;
+ }
+
+ { U32 const maxML = matches[nbMatches-1].len;
+ DEBUGLOG(7, "cPos:%zi==rPos:%u, found %u matches, of maxLength=%u",
+ inr-istart, cur, nbMatches, maxML);
+
+ if ( (maxML > sufficient_len)
+ || (cur + maxML >= ZSTD_OPT_NUM) ) {
+ lastSequence.mlen = maxML;
+ lastSequence.off = matches[nbMatches-1].off;
+ lastSequence.litlen = litlen;
+ cur -= (opt[cur].mlen==0) ? opt[cur].litlen : 0; /* last sequence is actually only literals, fix cur to last match - note : may underflow, in which case, it's first sequence, and it's okay */
+ last_pos = cur + ZSTD_totalLen(lastSequence);
+ if (cur > ZSTD_OPT_NUM) cur = 0; /* underflow => first match */
+ goto _shortestPath;
+ } }
+
+ /* set prices using matches found at position == cur */
+ for (matchNb = 0; matchNb < nbMatches; matchNb++) {
+ U32 const offset = matches[matchNb].off;
+ repcodes_t const repHistory = ZSTD_updateRep(opt[cur].rep, offset, ll0);
+ U32 const lastML = matches[matchNb].len;
+ U32 const startML = (matchNb>0) ? matches[matchNb-1].len+1 : minMatch;
+ U32 mlen;
+
+ DEBUGLOG(7, "testing match %u => offCode=%4u, mlen=%2u, llen=%2u",
+ matchNb, matches[matchNb].off, lastML, litlen);
+
+ for (mlen = lastML; mlen >= startML; mlen--) { /* scan downward */
+ U32 const pos = cur + mlen;
+ int const price = basePrice + ZSTD_getMatchPrice(offset, mlen, optStatePtr, optLevel);
+
+ if ((pos > last_pos) || (price < opt[pos].price)) {
+ DEBUGLOG(7, "rPos:%u (ml=%2u) => new better price (%.2f<%.2f)",
+ pos, mlen, ZSTD_fCost(price), ZSTD_fCost(opt[pos].price));
+ while (last_pos < pos) { opt[last_pos+1].price = ZSTD_MAX_PRICE; last_pos++; } /* fill empty positions */
+ opt[pos].mlen = mlen;
+ opt[pos].off = offset;
+ opt[pos].litlen = litlen;
+ opt[pos].price = price;
+ ZSTD_STATIC_ASSERT(sizeof(opt[pos].rep) == sizeof(repHistory));
+ memcpy(opt[pos].rep, &repHistory, sizeof(repHistory));
+ } else {
+ DEBUGLOG(7, "rPos:%u (ml=%2u) => new price is worse (%.2f>=%.2f)",
+ pos, mlen, ZSTD_fCost(price), ZSTD_fCost(opt[pos].price));
+ if (optLevel==0) break; /* early update abort; gets ~+10% speed for about -0.01 ratio loss */
+ }
+ } } }
+ } /* for (cur = 1; cur <= last_pos; cur++) */
+
+ lastSequence = opt[last_pos];
+ cur = last_pos > ZSTD_totalLen(lastSequence) ? last_pos - ZSTD_totalLen(lastSequence) : 0; /* single sequence, and it starts before `ip` */
+ assert(cur < ZSTD_OPT_NUM); /* control overflow*/
+
+_shortestPath: /* cur, last_pos, best_mlen, best_off have to be set */
+ assert(opt[0].mlen == 0);
+
+ { U32 const storeEnd = cur + 1;
+ U32 storeStart = storeEnd;
+ U32 seqPos = cur;
+
+ DEBUGLOG(6, "start reverse traversal (last_pos:%u, cur:%u)",
+ last_pos, cur); (void)last_pos;
+ assert(storeEnd < ZSTD_OPT_NUM);
+ DEBUGLOG(6, "last sequence copied into pos=%u (llen=%u,mlen=%u,ofc=%u)",
+ storeEnd, lastSequence.litlen, lastSequence.mlen, lastSequence.off);
+ opt[storeEnd] = lastSequence;
+ while (seqPos > 0) {
+ U32 const backDist = ZSTD_totalLen(opt[seqPos]);
+ storeStart--;
+ DEBUGLOG(6, "sequence from rPos=%u copied into pos=%u (llen=%u,mlen=%u,ofc=%u)",
+ seqPos, storeStart, opt[seqPos].litlen, opt[seqPos].mlen, opt[seqPos].off);
+ opt[storeStart] = opt[seqPos];
+ seqPos = (seqPos > backDist) ? seqPos - backDist : 0;
+ }
+
+ /* save sequences */
+ DEBUGLOG(6, "sending selected sequences into seqStore")
+ { U32 storePos;
+ for (storePos=storeStart; storePos <= storeEnd; storePos++) {
+ U32 const llen = opt[storePos].litlen;
+ U32 const mlen = opt[storePos].mlen;
+ U32 const offCode = opt[storePos].off;
+ U32 const advance = llen + mlen;
+ DEBUGLOG(6, "considering seq starting at %zi, llen=%u, mlen=%u",
+ anchor - istart, (unsigned)llen, (unsigned)mlen);
+
+ if (mlen==0) { /* only literals => must be last "sequence", actually starting a new stream of sequences */
+ assert(storePos == storeEnd); /* must be last sequence */
+ ip = anchor + llen; /* last "sequence" is a bunch of literals => don't progress anchor */
+ continue; /* will finish */
+ }
+
+ /* repcodes update : like ZSTD_updateRep(), but update in place */
+ if (offCode >= ZSTD_REP_NUM) { /* full offset */
+ rep[2] = rep[1];
+ rep[1] = rep[0];
+ rep[0] = offCode - ZSTD_REP_MOVE;
+ } else { /* repcode */
+ U32 const repCode = offCode + (llen==0);
+ if (repCode) { /* note : if repCode==0, no change */
+ U32 const currentOffset = (repCode==ZSTD_REP_NUM) ? (rep[0] - 1) : rep[repCode];
+ if (repCode >= 2) rep[2] = rep[1];
+ rep[1] = rep[0];
+ rep[0] = currentOffset;
+ } }
+
+ assert(anchor + llen <= iend);
+ ZSTD_updateStats(optStatePtr, llen, anchor, offCode, mlen);
+ ZSTD_storeSeq(seqStore, llen, anchor, offCode, mlen-MINMATCH);
+ anchor += advance;
+ ip = anchor;
+ } }
+ ZSTD_setBasePrices(optStatePtr, optLevel);
+ }
+
+ } /* while (ip < ilimit) */
+
+ /* Return the last literals size */
+ return iend - anchor;
+}
+
+
+size_t ZSTD_compressBlock_btopt(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ const void* src, size_t srcSize)
+{
+ DEBUGLOG(5, "ZSTD_compressBlock_btopt");
+ return ZSTD_compressBlock_opt_generic(ms, seqStore, rep, src, srcSize, 0 /*optLevel*/, ZSTD_noDict);
+}
+
+
+/* used in 2-pass strategy */
+static U32 ZSTD_upscaleStat(unsigned* table, U32 lastEltIndex, int bonus)
+{
+ U32 s, sum=0;
+ assert(ZSTD_FREQ_DIV+bonus >= 0);
+ for (s=0; s<lastEltIndex+1; s++) {
+ table[s] <<= ZSTD_FREQ_DIV+bonus;
+ table[s]--;
+ sum += table[s];
+ }
+ return sum;
+}
+
+/* used in 2-pass strategy */
+MEM_STATIC void ZSTD_upscaleStats(optState_t* optPtr)
+{
+ optPtr->litSum = ZSTD_upscaleStat(optPtr->litFreq, MaxLit, 0);
+ optPtr->litLengthSum = ZSTD_upscaleStat(optPtr->litLengthFreq, MaxLL, 0);
+ optPtr->matchLengthSum = ZSTD_upscaleStat(optPtr->matchLengthFreq, MaxML, 0);
+ optPtr->offCodeSum = ZSTD_upscaleStat(optPtr->offCodeFreq, MaxOff, 0);
+}
+
+/* ZSTD_initStats_ultra():
+ * make a first compression pass, just to seed stats with more accurate starting values.
+ * only works on first block, with no dictionary and no ldm.
+ * this function cannot error, hence its constract must be respected.
+ */
+static void
+ZSTD_initStats_ultra(ZSTD_matchState_t* ms,
+ seqStore_t* seqStore,
+ U32 rep[ZSTD_REP_NUM],
+ const void* src, size_t srcSize)
+{
+ U32 tmpRep[ZSTD_REP_NUM]; /* updated rep codes will sink here */
+ memcpy(tmpRep, rep, sizeof(tmpRep));
+
+ DEBUGLOG(4, "ZSTD_initStats_ultra (srcSize=%zu)", srcSize);
+ assert(ms->opt.litLengthSum == 0); /* first block */
+ assert(seqStore->sequences == seqStore->sequencesStart); /* no ldm */
+ assert(ms->window.dictLimit == ms->window.lowLimit); /* no dictionary */
+ assert(ms->window.dictLimit - ms->nextToUpdate <= 1); /* no prefix (note: intentional overflow, defined as 2-complement) */
+
+ ZSTD_compressBlock_opt_generic(ms, seqStore, tmpRep, src, srcSize, 2 /*optLevel*/, ZSTD_noDict); /* generate stats into ms->opt*/
+
+ /* invalidate first scan from history */
+ ZSTD_resetSeqStore(seqStore);
+ ms->window.base -= srcSize;
+ ms->window.dictLimit += (U32)srcSize;
+ ms->window.lowLimit = ms->window.dictLimit;
+ ms->nextToUpdate = ms->window.dictLimit;
+ ms->nextToUpdate3 = ms->window.dictLimit;
+
+ /* re-inforce weight of collected statistics */
+ ZSTD_upscaleStats(&ms->opt);
+}
+
+size_t ZSTD_compressBlock_btultra(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ const void* src, size_t srcSize)
+{
+ DEBUGLOG(5, "ZSTD_compressBlock_btultra (srcSize=%zu)", srcSize);
+ return ZSTD_compressBlock_opt_generic(ms, seqStore, rep, src, srcSize, 2 /*optLevel*/, ZSTD_noDict);
+}
+
+size_t ZSTD_compressBlock_btultra2(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ const void* src, size_t srcSize)
+{
+ U32 const current = (U32)((const BYTE*)src - ms->window.base);
+ DEBUGLOG(5, "ZSTD_compressBlock_btultra2 (srcSize=%zu)", srcSize);
+
+ /* 2-pass strategy:
+ * this strategy makes a first pass over first block to collect statistics
+ * and seed next round's statistics with it.
+ * After 1st pass, function forgets everything, and starts a new block.
+ * Consequently, this can only work if no data has been previously loaded in tables,
+ * aka, no dictionary, no prefix, no ldm preprocessing.
+ * The compression ratio gain is generally small (~0.5% on first block),
+ * the cost is 2x cpu time on first block. */
+ assert(srcSize <= ZSTD_BLOCKSIZE_MAX);
+ if ( (ms->opt.litLengthSum==0) /* first block */
+ && (seqStore->sequences == seqStore->sequencesStart) /* no ldm */
+ && (ms->window.dictLimit == ms->window.lowLimit) /* no dictionary */
+ && (current == ms->window.dictLimit) /* start of frame, nothing already loaded nor skipped */
+ && (srcSize > ZSTD_PREDEF_THRESHOLD)
+ ) {
+ ZSTD_initStats_ultra(ms, seqStore, rep, src, srcSize);
+ }
+
+ return ZSTD_compressBlock_opt_generic(ms, seqStore, rep, src, srcSize, 2 /*optLevel*/, ZSTD_noDict);
+}
+
+size_t ZSTD_compressBlock_btopt_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ const void* src, size_t srcSize)
+{
+ return ZSTD_compressBlock_opt_generic(ms, seqStore, rep, src, srcSize, 0 /*optLevel*/, ZSTD_dictMatchState);
+}
+
+size_t ZSTD_compressBlock_btultra_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ const void* src, size_t srcSize)
+{
+ return ZSTD_compressBlock_opt_generic(ms, seqStore, rep, src, srcSize, 2 /*optLevel*/, ZSTD_dictMatchState);
+}
+
+size_t ZSTD_compressBlock_btopt_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ const void* src, size_t srcSize)
+{
+ return ZSTD_compressBlock_opt_generic(ms, seqStore, rep, src, srcSize, 0 /*optLevel*/, ZSTD_extDict);
+}
+
+size_t ZSTD_compressBlock_btultra_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ const void* src, size_t srcSize)
+{
+ return ZSTD_compressBlock_opt_generic(ms, seqStore, rep, src, srcSize, 2 /*optLevel*/, ZSTD_extDict);
+}
+
+/* note : no btultra2 variant for extDict nor dictMatchState,
+ * because btultra2 is not meant to work with dictionaries
+ * and is only specific for the first block (no prefix) */
diff --git a/Utilities/cmzstd/lib/compress/zstd_opt.h b/Utilities/cmzstd/lib/compress/zstd_opt.h
new file mode 100644
index 000000000..094f74766
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstd_opt.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef ZSTD_OPT_H
+#define ZSTD_OPT_H
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#include "zstd_compress_internal.h"
+
+/* used in ZSTD_loadDictionaryContent() */
+void ZSTD_updateTree(ZSTD_matchState_t* ms, const BYTE* ip, const BYTE* iend);
+
+size_t ZSTD_compressBlock_btopt(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_btultra(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_btultra2(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+
+
+size_t ZSTD_compressBlock_btopt_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_btultra_dictMatchState(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+
+size_t ZSTD_compressBlock_btopt_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+size_t ZSTD_compressBlock_btultra_extDict(
+ ZSTD_matchState_t* ms, seqStore_t* seqStore, U32 rep[ZSTD_REP_NUM],
+ void const* src, size_t srcSize);
+
+ /* note : no btultra2 variant for extDict nor dictMatchState,
+ * because btultra2 is not meant to work with dictionaries
+ * and is only specific for the first block (no prefix) */
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* ZSTD_OPT_H */
diff --git a/Utilities/cmzstd/lib/compress/zstdmt_compress.c b/Utilities/cmzstd/lib/compress/zstdmt_compress.c
new file mode 100644
index 000000000..2cbd6ffad
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstdmt_compress.c
@@ -0,0 +1,2107 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+
+/* ====== Compiler specifics ====== */
+#if defined(_MSC_VER)
+# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */
+#endif
+
+
+/* ====== Constants ====== */
+#define ZSTDMT_OVERLAPLOG_DEFAULT 0
+
+
+/* ====== Dependencies ====== */
+#include <string.h> /* memcpy, memset */
+#include <limits.h> /* INT_MAX, UINT_MAX */
+#include "pool.h" /* threadpool */
+#include "threading.h" /* mutex */
+#include "zstd_compress_internal.h" /* MIN, ERROR, ZSTD_*, ZSTD_highbit32 */
+#include "zstd_ldm.h"
+#include "zstdmt_compress.h"
+
+/* Guards code to support resizing the SeqPool.
+ * We will want to resize the SeqPool to save memory in the future.
+ * Until then, comment the code out since it is unused.
+ */
+#define ZSTD_RESIZE_SEQPOOL 0
+
+/* ====== Debug ====== */
+#if defined(DEBUGLEVEL) && (DEBUGLEVEL>=2) \
+ && !defined(_MSC_VER) \
+ && !defined(__MINGW32__)
+
+# include <stdio.h>
+# include <unistd.h>
+# include <sys/times.h>
+
+# define DEBUG_PRINTHEX(l,p,n) { \
+ unsigned debug_u; \
+ for (debug_u=0; debug_u<(n); debug_u++) \
+ RAWLOG(l, "%02X ", ((const unsigned char*)(p))[debug_u]); \
+ RAWLOG(l, " \n"); \
+}
+
+static unsigned long long GetCurrentClockTimeMicroseconds(void)
+{
+ static clock_t _ticksPerSecond = 0;
+ if (_ticksPerSecond <= 0) _ticksPerSecond = sysconf(_SC_CLK_TCK);
+
+ { struct tms junk; clock_t newTicks = (clock_t) times(&junk);
+ return ((((unsigned long long)newTicks)*(1000000))/_ticksPerSecond);
+} }
+
+#define MUTEX_WAIT_TIME_DLEVEL 6
+#define ZSTD_PTHREAD_MUTEX_LOCK(mutex) { \
+ if (DEBUGLEVEL >= MUTEX_WAIT_TIME_DLEVEL) { \
+ unsigned long long const beforeTime = GetCurrentClockTimeMicroseconds(); \
+ ZSTD_pthread_mutex_lock(mutex); \
+ { unsigned long long const afterTime = GetCurrentClockTimeMicroseconds(); \
+ unsigned long long const elapsedTime = (afterTime-beforeTime); \
+ if (elapsedTime > 1000) { /* or whatever threshold you like; I'm using 1 millisecond here */ \
+ DEBUGLOG(MUTEX_WAIT_TIME_DLEVEL, "Thread took %llu microseconds to acquire mutex %s \n", \
+ elapsedTime, #mutex); \
+ } } \
+ } else { \
+ ZSTD_pthread_mutex_lock(mutex); \
+ } \
+}
+
+#else
+
+# define ZSTD_PTHREAD_MUTEX_LOCK(m) ZSTD_pthread_mutex_lock(m)
+# define DEBUG_PRINTHEX(l,p,n) {}
+
+#endif
+
+
+/* ===== Buffer Pool ===== */
+/* a single Buffer Pool can be invoked from multiple threads in parallel */
+
+typedef struct buffer_s {
+ void* start;
+ size_t capacity;
+} buffer_t;
+
+static const buffer_t g_nullBuffer = { NULL, 0 };
+
+typedef struct ZSTDMT_bufferPool_s {
+ ZSTD_pthread_mutex_t poolMutex;
+ size_t bufferSize;
+ unsigned totalBuffers;
+ unsigned nbBuffers;
+ ZSTD_customMem cMem;
+ buffer_t bTable[1]; /* variable size */
+} ZSTDMT_bufferPool;
+
+static ZSTDMT_bufferPool* ZSTDMT_createBufferPool(unsigned nbWorkers, ZSTD_customMem cMem)
+{
+ unsigned const maxNbBuffers = 2*nbWorkers + 3;
+ ZSTDMT_bufferPool* const bufPool = (ZSTDMT_bufferPool*)ZSTD_calloc(
+ sizeof(ZSTDMT_bufferPool) + (maxNbBuffers-1) * sizeof(buffer_t), cMem);
+ if (bufPool==NULL) return NULL;
+ if (ZSTD_pthread_mutex_init(&bufPool->poolMutex, NULL)) {
+ ZSTD_free(bufPool, cMem);
+ return NULL;
+ }
+ bufPool->bufferSize = 64 KB;
+ bufPool->totalBuffers = maxNbBuffers;
+ bufPool->nbBuffers = 0;
+ bufPool->cMem = cMem;
+ return bufPool;
+}
+
+static void ZSTDMT_freeBufferPool(ZSTDMT_bufferPool* bufPool)
+{
+ unsigned u;
+ DEBUGLOG(3, "ZSTDMT_freeBufferPool (address:%08X)", (U32)(size_t)bufPool);
+ if (!bufPool) return; /* compatibility with free on NULL */
+ for (u=0; u<bufPool->totalBuffers; u++) {
+ DEBUGLOG(4, "free buffer %2u (address:%08X)", u, (U32)(size_t)bufPool->bTable[u].start);
+ ZSTD_free(bufPool->bTable[u].start, bufPool->cMem);
+ }
+ ZSTD_pthread_mutex_destroy(&bufPool->poolMutex);
+ ZSTD_free(bufPool, bufPool->cMem);
+}
+
+/* only works at initialization, not during compression */
+static size_t ZSTDMT_sizeof_bufferPool(ZSTDMT_bufferPool* bufPool)
+{
+ size_t const poolSize = sizeof(*bufPool)
+ + (bufPool->totalBuffers - 1) * sizeof(buffer_t);
+ unsigned u;
+ size_t totalBufferSize = 0;
+ ZSTD_pthread_mutex_lock(&bufPool->poolMutex);
+ for (u=0; u<bufPool->totalBuffers; u++)
+ totalBufferSize += bufPool->bTable[u].capacity;
+ ZSTD_pthread_mutex_unlock(&bufPool->poolMutex);
+
+ return poolSize + totalBufferSize;
+}
+
+/* ZSTDMT_setBufferSize() :
+ * all future buffers provided by this buffer pool will have _at least_ this size
+ * note : it's better for all buffers to have same size,
+ * as they become freely interchangeable, reducing malloc/free usages and memory fragmentation */
+static void ZSTDMT_setBufferSize(ZSTDMT_bufferPool* const bufPool, size_t const bSize)
+{
+ ZSTD_pthread_mutex_lock(&bufPool->poolMutex);
+ DEBUGLOG(4, "ZSTDMT_setBufferSize: bSize = %u", (U32)bSize);
+ bufPool->bufferSize = bSize;
+ ZSTD_pthread_mutex_unlock(&bufPool->poolMutex);
+}
+
+
+static ZSTDMT_bufferPool* ZSTDMT_expandBufferPool(ZSTDMT_bufferPool* srcBufPool, U32 nbWorkers)
+{
+ unsigned const maxNbBuffers = 2*nbWorkers + 3;
+ if (srcBufPool==NULL) return NULL;
+ if (srcBufPool->totalBuffers >= maxNbBuffers) /* good enough */
+ return srcBufPool;
+ /* need a larger buffer pool */
+ { ZSTD_customMem const cMem = srcBufPool->cMem;
+ size_t const bSize = srcBufPool->bufferSize; /* forward parameters */
+ ZSTDMT_bufferPool* newBufPool;
+ ZSTDMT_freeBufferPool(srcBufPool);
+ newBufPool = ZSTDMT_createBufferPool(nbWorkers, cMem);
+ if (newBufPool==NULL) return newBufPool;
+ ZSTDMT_setBufferSize(newBufPool, bSize);
+ return newBufPool;
+ }
+}
+
+/** ZSTDMT_getBuffer() :
+ * assumption : bufPool must be valid
+ * @return : a buffer, with start pointer and size
+ * note: allocation may fail, in this case, start==NULL and size==0 */
+static buffer_t ZSTDMT_getBuffer(ZSTDMT_bufferPool* bufPool)
+{
+ size_t const bSize = bufPool->bufferSize;
+ DEBUGLOG(5, "ZSTDMT_getBuffer: bSize = %u", (U32)bufPool->bufferSize);
+ ZSTD_pthread_mutex_lock(&bufPool->poolMutex);
+ if (bufPool->nbBuffers) { /* try to use an existing buffer */
+ buffer_t const buf = bufPool->bTable[--(bufPool->nbBuffers)];
+ size_t const availBufferSize = buf.capacity;
+ bufPool->bTable[bufPool->nbBuffers] = g_nullBuffer;
+ if ((availBufferSize >= bSize) & ((availBufferSize>>3) <= bSize)) {
+ /* large enough, but not too much */
+ DEBUGLOG(5, "ZSTDMT_getBuffer: provide buffer %u of size %u",
+ bufPool->nbBuffers, (U32)buf.capacity);
+ ZSTD_pthread_mutex_unlock(&bufPool->poolMutex);
+ return buf;
+ }
+ /* size conditions not respected : scratch this buffer, create new one */
+ DEBUGLOG(5, "ZSTDMT_getBuffer: existing buffer does not meet size conditions => freeing");
+ ZSTD_free(buf.start, bufPool->cMem);
+ }
+ ZSTD_pthread_mutex_unlock(&bufPool->poolMutex);
+ /* create new buffer */
+ DEBUGLOG(5, "ZSTDMT_getBuffer: create a new buffer");
+ { buffer_t buffer;
+ void* const start = ZSTD_malloc(bSize, bufPool->cMem);
+ buffer.start = start; /* note : start can be NULL if malloc fails ! */
+ buffer.capacity = (start==NULL) ? 0 : bSize;
+ if (start==NULL) {
+ DEBUGLOG(5, "ZSTDMT_getBuffer: buffer allocation failure !!");
+ } else {
+ DEBUGLOG(5, "ZSTDMT_getBuffer: created buffer of size %u", (U32)bSize);
+ }
+ return buffer;
+ }
+}
+
+#if ZSTD_RESIZE_SEQPOOL
+/** ZSTDMT_resizeBuffer() :
+ * assumption : bufPool must be valid
+ * @return : a buffer that is at least the buffer pool buffer size.
+ * If a reallocation happens, the data in the input buffer is copied.
+ */
+static buffer_t ZSTDMT_resizeBuffer(ZSTDMT_bufferPool* bufPool, buffer_t buffer)
+{
+ size_t const bSize = bufPool->bufferSize;
+ if (buffer.capacity < bSize) {
+ void* const start = ZSTD_malloc(bSize, bufPool->cMem);
+ buffer_t newBuffer;
+ newBuffer.start = start;
+ newBuffer.capacity = start == NULL ? 0 : bSize;
+ if (start != NULL) {
+ assert(newBuffer.capacity >= buffer.capacity);
+ memcpy(newBuffer.start, buffer.start, buffer.capacity);
+ DEBUGLOG(5, "ZSTDMT_resizeBuffer: created buffer of size %u", (U32)bSize);
+ return newBuffer;
+ }
+ DEBUGLOG(5, "ZSTDMT_resizeBuffer: buffer allocation failure !!");
+ }
+ return buffer;
+}
+#endif
+
+/* store buffer for later re-use, up to pool capacity */
+static void ZSTDMT_releaseBuffer(ZSTDMT_bufferPool* bufPool, buffer_t buf)
+{
+ DEBUGLOG(5, "ZSTDMT_releaseBuffer");
+ if (buf.start == NULL) return; /* compatible with release on NULL */
+ ZSTD_pthread_mutex_lock(&bufPool->poolMutex);
+ if (bufPool->nbBuffers < bufPool->totalBuffers) {
+ bufPool->bTable[bufPool->nbBuffers++] = buf; /* stored for later use */
+ DEBUGLOG(5, "ZSTDMT_releaseBuffer: stored buffer of size %u in slot %u",
+ (U32)buf.capacity, (U32)(bufPool->nbBuffers-1));
+ ZSTD_pthread_mutex_unlock(&bufPool->poolMutex);
+ return;
+ }
+ ZSTD_pthread_mutex_unlock(&bufPool->poolMutex);
+ /* Reached bufferPool capacity (should not happen) */
+ DEBUGLOG(5, "ZSTDMT_releaseBuffer: pool capacity reached => freeing ");
+ ZSTD_free(buf.start, bufPool->cMem);
+}
+
+
+/* ===== Seq Pool Wrapper ====== */
+
+static rawSeqStore_t kNullRawSeqStore = {NULL, 0, 0, 0};
+
+typedef ZSTDMT_bufferPool ZSTDMT_seqPool;
+
+static size_t ZSTDMT_sizeof_seqPool(ZSTDMT_seqPool* seqPool)
+{
+ return ZSTDMT_sizeof_bufferPool(seqPool);
+}
+
+static rawSeqStore_t bufferToSeq(buffer_t buffer)
+{
+ rawSeqStore_t seq = {NULL, 0, 0, 0};
+ seq.seq = (rawSeq*)buffer.start;
+ seq.capacity = buffer.capacity / sizeof(rawSeq);
+ return seq;
+}
+
+static buffer_t seqToBuffer(rawSeqStore_t seq)
+{
+ buffer_t buffer;
+ buffer.start = seq.seq;
+ buffer.capacity = seq.capacity * sizeof(rawSeq);
+ return buffer;
+}
+
+static rawSeqStore_t ZSTDMT_getSeq(ZSTDMT_seqPool* seqPool)
+{
+ if (seqPool->bufferSize == 0) {
+ return kNullRawSeqStore;
+ }
+ return bufferToSeq(ZSTDMT_getBuffer(seqPool));
+}
+
+#if ZSTD_RESIZE_SEQPOOL
+static rawSeqStore_t ZSTDMT_resizeSeq(ZSTDMT_seqPool* seqPool, rawSeqStore_t seq)
+{
+ return bufferToSeq(ZSTDMT_resizeBuffer(seqPool, seqToBuffer(seq)));
+}
+#endif
+
+static void ZSTDMT_releaseSeq(ZSTDMT_seqPool* seqPool, rawSeqStore_t seq)
+{
+ ZSTDMT_releaseBuffer(seqPool, seqToBuffer(seq));
+}
+
+static void ZSTDMT_setNbSeq(ZSTDMT_seqPool* const seqPool, size_t const nbSeq)
+{
+ ZSTDMT_setBufferSize(seqPool, nbSeq * sizeof(rawSeq));
+}
+
+static ZSTDMT_seqPool* ZSTDMT_createSeqPool(unsigned nbWorkers, ZSTD_customMem cMem)
+{
+ ZSTDMT_seqPool* const seqPool = ZSTDMT_createBufferPool(nbWorkers, cMem);
+ if (seqPool == NULL) return NULL;
+ ZSTDMT_setNbSeq(seqPool, 0);
+ return seqPool;
+}
+
+static void ZSTDMT_freeSeqPool(ZSTDMT_seqPool* seqPool)
+{
+ ZSTDMT_freeBufferPool(seqPool);
+}
+
+static ZSTDMT_seqPool* ZSTDMT_expandSeqPool(ZSTDMT_seqPool* pool, U32 nbWorkers)
+{
+ return ZSTDMT_expandBufferPool(pool, nbWorkers);
+}
+
+
+/* ===== CCtx Pool ===== */
+/* a single CCtx Pool can be invoked from multiple threads in parallel */
+
+typedef struct {
+ ZSTD_pthread_mutex_t poolMutex;
+ int totalCCtx;
+ int availCCtx;
+ ZSTD_customMem cMem;
+ ZSTD_CCtx* cctx[1]; /* variable size */
+} ZSTDMT_CCtxPool;
+
+/* note : all CCtx borrowed from the pool should be released back to the pool _before_ freeing the pool */
+static void ZSTDMT_freeCCtxPool(ZSTDMT_CCtxPool* pool)
+{
+ int cid;
+ for (cid=0; cid<pool->totalCCtx; cid++)
+ ZSTD_freeCCtx(pool->cctx[cid]); /* note : compatible with free on NULL */
+ ZSTD_pthread_mutex_destroy(&pool->poolMutex);
+ ZSTD_free(pool, pool->cMem);
+}
+
+/* ZSTDMT_createCCtxPool() :
+ * implies nbWorkers >= 1 , checked by caller ZSTDMT_createCCtx() */
+static ZSTDMT_CCtxPool* ZSTDMT_createCCtxPool(int nbWorkers,
+ ZSTD_customMem cMem)
+{
+ ZSTDMT_CCtxPool* const cctxPool = (ZSTDMT_CCtxPool*) ZSTD_calloc(
+ sizeof(ZSTDMT_CCtxPool) + (nbWorkers-1)*sizeof(ZSTD_CCtx*), cMem);
+ assert(nbWorkers > 0);
+ if (!cctxPool) return NULL;
+ if (ZSTD_pthread_mutex_init(&cctxPool->poolMutex, NULL)) {
+ ZSTD_free(cctxPool, cMem);
+ return NULL;
+ }
+ cctxPool->cMem = cMem;
+ cctxPool->totalCCtx = nbWorkers;
+ cctxPool->availCCtx = 1; /* at least one cctx for single-thread mode */
+ cctxPool->cctx[0] = ZSTD_createCCtx_advanced(cMem);
+ if (!cctxPool->cctx[0]) { ZSTDMT_freeCCtxPool(cctxPool); return NULL; }
+ DEBUGLOG(3, "cctxPool created, with %u workers", nbWorkers);
+ return cctxPool;
+}
+
+static ZSTDMT_CCtxPool* ZSTDMT_expandCCtxPool(ZSTDMT_CCtxPool* srcPool,
+ int nbWorkers)
+{
+ if (srcPool==NULL) return NULL;
+ if (nbWorkers <= srcPool->totalCCtx) return srcPool; /* good enough */
+ /* need a larger cctx pool */
+ { ZSTD_customMem const cMem = srcPool->cMem;
+ ZSTDMT_freeCCtxPool(srcPool);
+ return ZSTDMT_createCCtxPool(nbWorkers, cMem);
+ }
+}
+
+/* only works during initialization phase, not during compression */
+static size_t ZSTDMT_sizeof_CCtxPool(ZSTDMT_CCtxPool* cctxPool)
+{
+ ZSTD_pthread_mutex_lock(&cctxPool->poolMutex);
+ { unsigned const nbWorkers = cctxPool->totalCCtx;
+ size_t const poolSize = sizeof(*cctxPool)
+ + (nbWorkers-1) * sizeof(ZSTD_CCtx*);
+ unsigned u;
+ size_t totalCCtxSize = 0;
+ for (u=0; u<nbWorkers; u++) {
+ totalCCtxSize += ZSTD_sizeof_CCtx(cctxPool->cctx[u]);
+ }
+ ZSTD_pthread_mutex_unlock(&cctxPool->poolMutex);
+ assert(nbWorkers > 0);
+ return poolSize + totalCCtxSize;
+ }
+}
+
+static ZSTD_CCtx* ZSTDMT_getCCtx(ZSTDMT_CCtxPool* cctxPool)
+{
+ DEBUGLOG(5, "ZSTDMT_getCCtx");
+ ZSTD_pthread_mutex_lock(&cctxPool->poolMutex);
+ if (cctxPool->availCCtx) {
+ cctxPool->availCCtx--;
+ { ZSTD_CCtx* const cctx = cctxPool->cctx[cctxPool->availCCtx];
+ ZSTD_pthread_mutex_unlock(&cctxPool->poolMutex);
+ return cctx;
+ } }
+ ZSTD_pthread_mutex_unlock(&cctxPool->poolMutex);
+ DEBUGLOG(5, "create one more CCtx");
+ return ZSTD_createCCtx_advanced(cctxPool->cMem); /* note : can be NULL, when creation fails ! */
+}
+
+static void ZSTDMT_releaseCCtx(ZSTDMT_CCtxPool* pool, ZSTD_CCtx* cctx)
+{
+ if (cctx==NULL) return; /* compatibility with release on NULL */
+ ZSTD_pthread_mutex_lock(&pool->poolMutex);
+ if (pool->availCCtx < pool->totalCCtx)
+ pool->cctx[pool->availCCtx++] = cctx;
+ else {
+ /* pool overflow : should not happen, since totalCCtx==nbWorkers */
+ DEBUGLOG(4, "CCtx pool overflow : free cctx");
+ ZSTD_freeCCtx(cctx);
+ }
+ ZSTD_pthread_mutex_unlock(&pool->poolMutex);
+}
+
+/* ==== Serial State ==== */
+
+typedef struct {
+ void const* start;
+ size_t size;
+} range_t;
+
+typedef struct {
+ /* All variables in the struct are protected by mutex. */
+ ZSTD_pthread_mutex_t mutex;
+ ZSTD_pthread_cond_t cond;
+ ZSTD_CCtx_params params;
+ ldmState_t ldmState;
+ XXH64_state_t xxhState;
+ unsigned nextJobID;
+ /* Protects ldmWindow.
+ * Must be acquired after the main mutex when acquiring both.
+ */
+ ZSTD_pthread_mutex_t ldmWindowMutex;
+ ZSTD_pthread_cond_t ldmWindowCond; /* Signaled when ldmWindow is udpated */
+ ZSTD_window_t ldmWindow; /* A thread-safe copy of ldmState.window */
+} serialState_t;
+
+static int ZSTDMT_serialState_reset(serialState_t* serialState, ZSTDMT_seqPool* seqPool, ZSTD_CCtx_params params, size_t jobSize)
+{
+ /* Adjust parameters */
+ if (params.ldmParams.enableLdm) {
+ DEBUGLOG(4, "LDM window size = %u KB", (1U << params.cParams.windowLog) >> 10);
+ ZSTD_ldm_adjustParameters(&params.ldmParams, &params.cParams);
+ assert(params.ldmParams.hashLog >= params.ldmParams.bucketSizeLog);
+ assert(params.ldmParams.hashRateLog < 32);
+ serialState->ldmState.hashPower =
+ ZSTD_rollingHash_primePower(params.ldmParams.minMatchLength);
+ } else {
+ memset(&params.ldmParams, 0, sizeof(params.ldmParams));
+ }
+ serialState->nextJobID = 0;
+ if (params.fParams.checksumFlag)
+ XXH64_reset(&serialState->xxhState, 0);
+ if (params.ldmParams.enableLdm) {
+ ZSTD_customMem cMem = params.customMem;
+ unsigned const hashLog = params.ldmParams.hashLog;
+ size_t const hashSize = ((size_t)1 << hashLog) * sizeof(ldmEntry_t);
+ unsigned const bucketLog =
+ params.ldmParams.hashLog - params.ldmParams.bucketSizeLog;
+ size_t const bucketSize = (size_t)1 << bucketLog;
+ unsigned const prevBucketLog =
+ serialState->params.ldmParams.hashLog -
+ serialState->params.ldmParams.bucketSizeLog;
+ /* Size the seq pool tables */
+ ZSTDMT_setNbSeq(seqPool, ZSTD_ldm_getMaxNbSeq(params.ldmParams, jobSize));
+ /* Reset the window */
+ ZSTD_window_clear(&serialState->ldmState.window);
+ serialState->ldmWindow = serialState->ldmState.window;
+ /* Resize tables and output space if necessary. */
+ if (serialState->ldmState.hashTable == NULL || serialState->params.ldmParams.hashLog < hashLog) {
+ ZSTD_free(serialState->ldmState.hashTable, cMem);
+ serialState->ldmState.hashTable = (ldmEntry_t*)ZSTD_malloc(hashSize, cMem);
+ }
+ if (serialState->ldmState.bucketOffsets == NULL || prevBucketLog < bucketLog) {
+ ZSTD_free(serialState->ldmState.bucketOffsets, cMem);
+ serialState->ldmState.bucketOffsets = (BYTE*)ZSTD_malloc(bucketSize, cMem);
+ }
+ if (!serialState->ldmState.hashTable || !serialState->ldmState.bucketOffsets)
+ return 1;
+ /* Zero the tables */
+ memset(serialState->ldmState.hashTable, 0, hashSize);
+ memset(serialState->ldmState.bucketOffsets, 0, bucketSize);
+ }
+ serialState->params = params;
+ serialState->params.jobSize = (U32)jobSize;
+ return 0;
+}
+
+static int ZSTDMT_serialState_init(serialState_t* serialState)
+{
+ int initError = 0;
+ memset(serialState, 0, sizeof(*serialState));
+ initError |= ZSTD_pthread_mutex_init(&serialState->mutex, NULL);
+ initError |= ZSTD_pthread_cond_init(&serialState->cond, NULL);
+ initError |= ZSTD_pthread_mutex_init(&serialState->ldmWindowMutex, NULL);
+ initError |= ZSTD_pthread_cond_init(&serialState->ldmWindowCond, NULL);
+ return initError;
+}
+
+static void ZSTDMT_serialState_free(serialState_t* serialState)
+{
+ ZSTD_customMem cMem = serialState->params.customMem;
+ ZSTD_pthread_mutex_destroy(&serialState->mutex);
+ ZSTD_pthread_cond_destroy(&serialState->cond);
+ ZSTD_pthread_mutex_destroy(&serialState->ldmWindowMutex);
+ ZSTD_pthread_cond_destroy(&serialState->ldmWindowCond);
+ ZSTD_free(serialState->ldmState.hashTable, cMem);
+ ZSTD_free(serialState->ldmState.bucketOffsets, cMem);
+}
+
+static void ZSTDMT_serialState_update(serialState_t* serialState,
+ ZSTD_CCtx* jobCCtx, rawSeqStore_t seqStore,
+ range_t src, unsigned jobID)
+{
+ /* Wait for our turn */
+ ZSTD_PTHREAD_MUTEX_LOCK(&serialState->mutex);
+ while (serialState->nextJobID < jobID) {
+ DEBUGLOG(5, "wait for serialState->cond");
+ ZSTD_pthread_cond_wait(&serialState->cond, &serialState->mutex);
+ }
+ /* A future job may error and skip our job */
+ if (serialState->nextJobID == jobID) {
+ /* It is now our turn, do any processing necessary */
+ if (serialState->params.ldmParams.enableLdm) {
+ size_t error;
+ assert(seqStore.seq != NULL && seqStore.pos == 0 &&
+ seqStore.size == 0 && seqStore.capacity > 0);
+ assert(src.size <= serialState->params.jobSize);
+ ZSTD_window_update(&serialState->ldmState.window, src.start, src.size);
+ error = ZSTD_ldm_generateSequences(
+ &serialState->ldmState, &seqStore,
+ &serialState->params.ldmParams, src.start, src.size);
+ /* We provide a large enough buffer to never fail. */
+ assert(!ZSTD_isError(error)); (void)error;
+ /* Update ldmWindow to match the ldmState.window and signal the main
+ * thread if it is waiting for a buffer.
+ */
+ ZSTD_PTHREAD_MUTEX_LOCK(&serialState->ldmWindowMutex);
+ serialState->ldmWindow = serialState->ldmState.window;
+ ZSTD_pthread_cond_signal(&serialState->ldmWindowCond);
+ ZSTD_pthread_mutex_unlock(&serialState->ldmWindowMutex);
+ }
+ if (serialState->params.fParams.checksumFlag && src.size > 0)
+ XXH64_update(&serialState->xxhState, src.start, src.size);
+ }
+ /* Now it is the next jobs turn */
+ serialState->nextJobID++;
+ ZSTD_pthread_cond_broadcast(&serialState->cond);
+ ZSTD_pthread_mutex_unlock(&serialState->mutex);
+
+ if (seqStore.size > 0) {
+ size_t const err = ZSTD_referenceExternalSequences(
+ jobCCtx, seqStore.seq, seqStore.size);
+ assert(serialState->params.ldmParams.enableLdm);
+ assert(!ZSTD_isError(err));
+ (void)err;
+ }
+}
+
+static void ZSTDMT_serialState_ensureFinished(serialState_t* serialState,
+ unsigned jobID, size_t cSize)
+{
+ ZSTD_PTHREAD_MUTEX_LOCK(&serialState->mutex);
+ if (serialState->nextJobID <= jobID) {
+ assert(ZSTD_isError(cSize)); (void)cSize;
+ DEBUGLOG(5, "Skipping past job %u because of error", jobID);
+ serialState->nextJobID = jobID + 1;
+ ZSTD_pthread_cond_broadcast(&serialState->cond);
+
+ ZSTD_PTHREAD_MUTEX_LOCK(&serialState->ldmWindowMutex);
+ ZSTD_window_clear(&serialState->ldmWindow);
+ ZSTD_pthread_cond_signal(&serialState->ldmWindowCond);
+ ZSTD_pthread_mutex_unlock(&serialState->ldmWindowMutex);
+ }
+ ZSTD_pthread_mutex_unlock(&serialState->mutex);
+
+}
+
+
+/* ------------------------------------------ */
+/* ===== Worker thread ===== */
+/* ------------------------------------------ */
+
+static const range_t kNullRange = { NULL, 0 };
+
+typedef struct {
+ size_t consumed; /* SHARED - set0 by mtctx, then modified by worker AND read by mtctx */
+ size_t cSize; /* SHARED - set0 by mtctx, then modified by worker AND read by mtctx, then set0 by mtctx */
+ ZSTD_pthread_mutex_t job_mutex; /* Thread-safe - used by mtctx and worker */
+ ZSTD_pthread_cond_t job_cond; /* Thread-safe - used by mtctx and worker */
+ ZSTDMT_CCtxPool* cctxPool; /* Thread-safe - used by mtctx and (all) workers */
+ ZSTDMT_bufferPool* bufPool; /* Thread-safe - used by mtctx and (all) workers */
+ ZSTDMT_seqPool* seqPool; /* Thread-safe - used by mtctx and (all) workers */
+ serialState_t* serial; /* Thread-safe - used by mtctx and (all) workers */
+ buffer_t dstBuff; /* set by worker (or mtctx), then read by worker & mtctx, then modified by mtctx => no barrier */
+ range_t prefix; /* set by mtctx, then read by worker & mtctx => no barrier */
+ range_t src; /* set by mtctx, then read by worker & mtctx => no barrier */
+ unsigned jobID; /* set by mtctx, then read by worker => no barrier */
+ unsigned firstJob; /* set by mtctx, then read by worker => no barrier */
+ unsigned lastJob; /* set by mtctx, then read by worker => no barrier */
+ ZSTD_CCtx_params params; /* set by mtctx, then read by worker => no barrier */
+ const ZSTD_CDict* cdict; /* set by mtctx, then read by worker => no barrier */
+ unsigned long long fullFrameSize; /* set by mtctx, then read by worker => no barrier */
+ size_t dstFlushed; /* used only by mtctx */
+ unsigned frameChecksumNeeded; /* used only by mtctx */
+} ZSTDMT_jobDescription;
+
+#define JOB_ERROR(e) { \
+ ZSTD_PTHREAD_MUTEX_LOCK(&job->job_mutex); \
+ job->cSize = e; \
+ ZSTD_pthread_mutex_unlock(&job->job_mutex); \
+ goto _endJob; \
+}
+
+/* ZSTDMT_compressionJob() is a POOL_function type */
+static void ZSTDMT_compressionJob(void* jobDescription)
+{
+ ZSTDMT_jobDescription* const job = (ZSTDMT_jobDescription*)jobDescription;
+ ZSTD_CCtx_params jobParams = job->params; /* do not modify job->params ! copy it, modify the copy */
+ ZSTD_CCtx* const cctx = ZSTDMT_getCCtx(job->cctxPool);
+ rawSeqStore_t rawSeqStore = ZSTDMT_getSeq(job->seqPool);
+ buffer_t dstBuff = job->dstBuff;
+ size_t lastCBlockSize = 0;
+
+ /* ressources */
+ if (cctx==NULL) JOB_ERROR(ERROR(memory_allocation));
+ if (dstBuff.start == NULL) { /* streaming job : doesn't provide a dstBuffer */
+ dstBuff = ZSTDMT_getBuffer(job->bufPool);
+ if (dstBuff.start==NULL) JOB_ERROR(ERROR(memory_allocation));
+ job->dstBuff = dstBuff; /* this value can be read in ZSTDMT_flush, when it copies the whole job */
+ }
+ if (jobParams.ldmParams.enableLdm && rawSeqStore.seq == NULL)
+ JOB_ERROR(ERROR(memory_allocation));
+
+ /* Don't compute the checksum for chunks, since we compute it externally,
+ * but write it in the header.
+ */
+ if (job->jobID != 0) jobParams.fParams.checksumFlag = 0;
+ /* Don't run LDM for the chunks, since we handle it externally */
+ jobParams.ldmParams.enableLdm = 0;
+
+
+ /* init */
+ if (job->cdict) {
+ size_t const initError = ZSTD_compressBegin_advanced_internal(cctx, NULL, 0, ZSTD_dct_auto, ZSTD_dtlm_fast, job->cdict, jobParams, job->fullFrameSize);
+ assert(job->firstJob); /* only allowed for first job */
+ if (ZSTD_isError(initError)) JOB_ERROR(initError);
+ } else { /* srcStart points at reloaded section */
+ U64 const pledgedSrcSize = job->firstJob ? job->fullFrameSize : job->src.size;
+ { size_t const forceWindowError = ZSTD_CCtxParam_setParameter(&jobParams, ZSTD_c_forceMaxWindow, !job->firstJob);
+ if (ZSTD_isError(forceWindowError)) JOB_ERROR(forceWindowError);
+ }
+ { size_t const initError = ZSTD_compressBegin_advanced_internal(cctx,
+ job->prefix.start, job->prefix.size, ZSTD_dct_rawContent, /* load dictionary in "content-only" mode (no header analysis) */
+ ZSTD_dtlm_fast,
+ NULL, /*cdict*/
+ jobParams, pledgedSrcSize);
+ if (ZSTD_isError(initError)) JOB_ERROR(initError);
+ } }
+
+ /* Perform serial step as early as possible, but after CCtx initialization */
+ ZSTDMT_serialState_update(job->serial, cctx, rawSeqStore, job->src, job->jobID);
+
+ if (!job->firstJob) { /* flush and overwrite frame header when it's not first job */
+ size_t const hSize = ZSTD_compressContinue(cctx, dstBuff.start, dstBuff.capacity, job->src.start, 0);
+ if (ZSTD_isError(hSize)) JOB_ERROR(hSize);
+ DEBUGLOG(5, "ZSTDMT_compressionJob: flush and overwrite %u bytes of frame header (not first job)", (U32)hSize);
+ ZSTD_invalidateRepCodes(cctx);
+ }
+
+ /* compress */
+ { size_t const chunkSize = 4*ZSTD_BLOCKSIZE_MAX;
+ int const nbChunks = (int)((job->src.size + (chunkSize-1)) / chunkSize);
+ const BYTE* ip = (const BYTE*) job->src.start;
+ BYTE* const ostart = (BYTE*)dstBuff.start;
+ BYTE* op = ostart;
+ BYTE* oend = op + dstBuff.capacity;
+ int chunkNb;
+ if (sizeof(size_t) > sizeof(int)) assert(job->src.size < ((size_t)INT_MAX) * chunkSize); /* check overflow */
+ DEBUGLOG(5, "ZSTDMT_compressionJob: compress %u bytes in %i blocks", (U32)job->src.size, nbChunks);
+ assert(job->cSize == 0);
+ for (chunkNb = 1; chunkNb < nbChunks; chunkNb++) {
+ size_t const cSize = ZSTD_compressContinue(cctx, op, oend-op, ip, chunkSize);
+ if (ZSTD_isError(cSize)) JOB_ERROR(cSize);
+ ip += chunkSize;
+ op += cSize; assert(op < oend);
+ /* stats */
+ ZSTD_PTHREAD_MUTEX_LOCK(&job->job_mutex);
+ job->cSize += cSize;
+ job->consumed = chunkSize * chunkNb;
+ DEBUGLOG(5, "ZSTDMT_compressionJob: compress new block : cSize==%u bytes (total: %u)",
+ (U32)cSize, (U32)job->cSize);
+ ZSTD_pthread_cond_signal(&job->job_cond); /* warns some more data is ready to be flushed */
+ ZSTD_pthread_mutex_unlock(&job->job_mutex);
+ }
+ /* last block */
+ assert(chunkSize > 0);
+ assert((chunkSize & (chunkSize - 1)) == 0); /* chunkSize must be power of 2 for mask==(chunkSize-1) to work */
+ if ((nbChunks > 0) | job->lastJob /*must output a "last block" flag*/ ) {
+ size_t const lastBlockSize1 = job->src.size & (chunkSize-1);
+ size_t const lastBlockSize = ((lastBlockSize1==0) & (job->src.size>=chunkSize)) ? chunkSize : lastBlockSize1;
+ size_t const cSize = (job->lastJob) ?
+ ZSTD_compressEnd (cctx, op, oend-op, ip, lastBlockSize) :
+ ZSTD_compressContinue(cctx, op, oend-op, ip, lastBlockSize);
+ if (ZSTD_isError(cSize)) JOB_ERROR(cSize);
+ lastCBlockSize = cSize;
+ } }
+
+_endJob:
+ ZSTDMT_serialState_ensureFinished(job->serial, job->jobID, job->cSize);
+ if (job->prefix.size > 0)
+ DEBUGLOG(5, "Finished with prefix: %zx", (size_t)job->prefix.start);
+ DEBUGLOG(5, "Finished with source: %zx", (size_t)job->src.start);
+ /* release resources */
+ ZSTDMT_releaseSeq(job->seqPool, rawSeqStore);
+ ZSTDMT_releaseCCtx(job->cctxPool, cctx);
+ /* report */
+ ZSTD_PTHREAD_MUTEX_LOCK(&job->job_mutex);
+ if (ZSTD_isError(job->cSize)) assert(lastCBlockSize == 0);
+ job->cSize += lastCBlockSize;
+ job->consumed = job->src.size; /* when job->consumed == job->src.size , compression job is presumed completed */
+ ZSTD_pthread_cond_signal(&job->job_cond);
+ ZSTD_pthread_mutex_unlock(&job->job_mutex);
+}
+
+
+/* ------------------------------------------ */
+/* ===== Multi-threaded compression ===== */
+/* ------------------------------------------ */
+
+typedef struct {
+ range_t prefix; /* read-only non-owned prefix buffer */
+ buffer_t buffer;
+ size_t filled;
+} inBuff_t;
+
+typedef struct {
+ BYTE* buffer; /* The round input buffer. All jobs get references
+ * to pieces of the buffer. ZSTDMT_tryGetInputRange()
+ * handles handing out job input buffers, and makes
+ * sure it doesn't overlap with any pieces still in use.
+ */
+ size_t capacity; /* The capacity of buffer. */
+ size_t pos; /* The position of the current inBuff in the round
+ * buffer. Updated past the end if the inBuff once
+ * the inBuff is sent to the worker thread.
+ * pos <= capacity.
+ */
+} roundBuff_t;
+
+static const roundBuff_t kNullRoundBuff = {NULL, 0, 0};
+
+#define RSYNC_LENGTH 32
+
+typedef struct {
+ U64 hash;
+ U64 hitMask;
+ U64 primePower;
+} rsyncState_t;
+
+struct ZSTDMT_CCtx_s {
+ POOL_ctx* factory;
+ ZSTDMT_jobDescription* jobs;
+ ZSTDMT_bufferPool* bufPool;
+ ZSTDMT_CCtxPool* cctxPool;
+ ZSTDMT_seqPool* seqPool;
+ ZSTD_CCtx_params params;
+ size_t targetSectionSize;
+ size_t targetPrefixSize;
+ int jobReady; /* 1 => one job is already prepared, but pool has shortage of workers. Don't create a new job. */
+ inBuff_t inBuff;
+ roundBuff_t roundBuff;
+ serialState_t serial;
+ rsyncState_t rsync;
+ unsigned singleBlockingThread;
+ unsigned jobIDMask;
+ unsigned doneJobID;
+ unsigned nextJobID;
+ unsigned frameEnded;
+ unsigned allJobsCompleted;
+ unsigned long long frameContentSize;
+ unsigned long long consumed;
+ unsigned long long produced;
+ ZSTD_customMem cMem;
+ ZSTD_CDict* cdictLocal;
+ const ZSTD_CDict* cdict;
+};
+
+static void ZSTDMT_freeJobsTable(ZSTDMT_jobDescription* jobTable, U32 nbJobs, ZSTD_customMem cMem)
+{
+ U32 jobNb;
+ if (jobTable == NULL) return;
+ for (jobNb=0; jobNb<nbJobs; jobNb++) {
+ ZSTD_pthread_mutex_destroy(&jobTable[jobNb].job_mutex);
+ ZSTD_pthread_cond_destroy(&jobTable[jobNb].job_cond);
+ }
+ ZSTD_free(jobTable, cMem);
+}
+
+/* ZSTDMT_allocJobsTable()
+ * allocate and init a job table.
+ * update *nbJobsPtr to next power of 2 value, as size of table */
+static ZSTDMT_jobDescription* ZSTDMT_createJobsTable(U32* nbJobsPtr, ZSTD_customMem cMem)
+{
+ U32 const nbJobsLog2 = ZSTD_highbit32(*nbJobsPtr) + 1;
+ U32 const nbJobs = 1 << nbJobsLog2;
+ U32 jobNb;
+ ZSTDMT_jobDescription* const jobTable = (ZSTDMT_jobDescription*)
+ ZSTD_calloc(nbJobs * sizeof(ZSTDMT_jobDescription), cMem);
+ int initError = 0;
+ if (jobTable==NULL) return NULL;
+ *nbJobsPtr = nbJobs;
+ for (jobNb=0; jobNb<nbJobs; jobNb++) {
+ initError |= ZSTD_pthread_mutex_init(&jobTable[jobNb].job_mutex, NULL);
+ initError |= ZSTD_pthread_cond_init(&jobTable[jobNb].job_cond, NULL);
+ }
+ if (initError != 0) {
+ ZSTDMT_freeJobsTable(jobTable, nbJobs, cMem);
+ return NULL;
+ }
+ return jobTable;
+}
+
+static size_t ZSTDMT_expandJobsTable (ZSTDMT_CCtx* mtctx, U32 nbWorkers) {
+ U32 nbJobs = nbWorkers + 2;
+ if (nbJobs > mtctx->jobIDMask+1) { /* need more job capacity */
+ ZSTDMT_freeJobsTable(mtctx->jobs, mtctx->jobIDMask+1, mtctx->cMem);
+ mtctx->jobIDMask = 0;
+ mtctx->jobs = ZSTDMT_createJobsTable(&nbJobs, mtctx->cMem);
+ if (mtctx->jobs==NULL) return ERROR(memory_allocation);
+ assert((nbJobs != 0) && ((nbJobs & (nbJobs - 1)) == 0)); /* ensure nbJobs is a power of 2 */
+ mtctx->jobIDMask = nbJobs - 1;
+ }
+ return 0;
+}
+
+
+/* ZSTDMT_CCtxParam_setNbWorkers():
+ * Internal use only */
+size_t ZSTDMT_CCtxParam_setNbWorkers(ZSTD_CCtx_params* params, unsigned nbWorkers)
+{
+ if (nbWorkers > ZSTDMT_NBWORKERS_MAX) nbWorkers = ZSTDMT_NBWORKERS_MAX;
+ params->nbWorkers = nbWorkers;
+ params->overlapLog = ZSTDMT_OVERLAPLOG_DEFAULT;
+ params->jobSize = 0;
+ return nbWorkers;
+}
+
+ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbWorkers, ZSTD_customMem cMem)
+{
+ ZSTDMT_CCtx* mtctx;
+ U32 nbJobs = nbWorkers + 2;
+ int initError;
+ DEBUGLOG(3, "ZSTDMT_createCCtx_advanced (nbWorkers = %u)", nbWorkers);
+
+ if (nbWorkers < 1) return NULL;
+ nbWorkers = MIN(nbWorkers , ZSTDMT_NBWORKERS_MAX);
+ if ((cMem.customAlloc!=NULL) ^ (cMem.customFree!=NULL))
+ /* invalid custom allocator */
+ return NULL;
+
+ mtctx = (ZSTDMT_CCtx*) ZSTD_calloc(sizeof(ZSTDMT_CCtx), cMem);
+ if (!mtctx) return NULL;
+ ZSTDMT_CCtxParam_setNbWorkers(&mtctx->params, nbWorkers);
+ mtctx->cMem = cMem;
+ mtctx->allJobsCompleted = 1;
+ mtctx->factory = POOL_create_advanced(nbWorkers, 0, cMem);
+ mtctx->jobs = ZSTDMT_createJobsTable(&nbJobs, cMem);
+ assert(nbJobs > 0); assert((nbJobs & (nbJobs - 1)) == 0); /* ensure nbJobs is a power of 2 */
+ mtctx->jobIDMask = nbJobs - 1;
+ mtctx->bufPool = ZSTDMT_createBufferPool(nbWorkers, cMem);
+ mtctx->cctxPool = ZSTDMT_createCCtxPool(nbWorkers, cMem);
+ mtctx->seqPool = ZSTDMT_createSeqPool(nbWorkers, cMem);
+ initError = ZSTDMT_serialState_init(&mtctx->serial);
+ mtctx->roundBuff = kNullRoundBuff;
+ if (!mtctx->factory | !mtctx->jobs | !mtctx->bufPool | !mtctx->cctxPool | !mtctx->seqPool | initError) {
+ ZSTDMT_freeCCtx(mtctx);
+ return NULL;
+ }
+ DEBUGLOG(3, "mt_cctx created, for %u threads", nbWorkers);
+ return mtctx;
+}
+
+ZSTDMT_CCtx* ZSTDMT_createCCtx(unsigned nbWorkers)
+{
+ return ZSTDMT_createCCtx_advanced(nbWorkers, ZSTD_defaultCMem);
+}
+
+
+/* ZSTDMT_releaseAllJobResources() :
+ * note : ensure all workers are killed first ! */
+static void ZSTDMT_releaseAllJobResources(ZSTDMT_CCtx* mtctx)
+{
+ unsigned jobID;
+ DEBUGLOG(3, "ZSTDMT_releaseAllJobResources");
+ for (jobID=0; jobID <= mtctx->jobIDMask; jobID++) {
+ DEBUGLOG(4, "job%02u: release dst address %08X", jobID, (U32)(size_t)mtctx->jobs[jobID].dstBuff.start);
+ ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[jobID].dstBuff);
+ mtctx->jobs[jobID].dstBuff = g_nullBuffer;
+ mtctx->jobs[jobID].cSize = 0;
+ }
+ memset(mtctx->jobs, 0, (mtctx->jobIDMask+1)*sizeof(ZSTDMT_jobDescription));
+ mtctx->inBuff.buffer = g_nullBuffer;
+ mtctx->inBuff.filled = 0;
+ mtctx->allJobsCompleted = 1;
+}
+
+static void ZSTDMT_waitForAllJobsCompleted(ZSTDMT_CCtx* mtctx)
+{
+ DEBUGLOG(4, "ZSTDMT_waitForAllJobsCompleted");
+ while (mtctx->doneJobID < mtctx->nextJobID) {
+ unsigned const jobID = mtctx->doneJobID & mtctx->jobIDMask;
+ ZSTD_PTHREAD_MUTEX_LOCK(&mtctx->jobs[jobID].job_mutex);
+ while (mtctx->jobs[jobID].consumed < mtctx->jobs[jobID].src.size) {
+ DEBUGLOG(4, "waiting for jobCompleted signal from job %u", mtctx->doneJobID); /* we want to block when waiting for data to flush */
+ ZSTD_pthread_cond_wait(&mtctx->jobs[jobID].job_cond, &mtctx->jobs[jobID].job_mutex);
+ }
+ ZSTD_pthread_mutex_unlock(&mtctx->jobs[jobID].job_mutex);
+ mtctx->doneJobID++;
+ }
+}
+
+size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* mtctx)
+{
+ if (mtctx==NULL) return 0; /* compatible with free on NULL */
+ POOL_free(mtctx->factory); /* stop and free worker threads */
+ ZSTDMT_releaseAllJobResources(mtctx); /* release job resources into pools first */
+ ZSTDMT_freeJobsTable(mtctx->jobs, mtctx->jobIDMask+1, mtctx->cMem);
+ ZSTDMT_freeBufferPool(mtctx->bufPool);
+ ZSTDMT_freeCCtxPool(mtctx->cctxPool);
+ ZSTDMT_freeSeqPool(mtctx->seqPool);
+ ZSTDMT_serialState_free(&mtctx->serial);
+ ZSTD_freeCDict(mtctx->cdictLocal);
+ if (mtctx->roundBuff.buffer)
+ ZSTD_free(mtctx->roundBuff.buffer, mtctx->cMem);
+ ZSTD_free(mtctx, mtctx->cMem);
+ return 0;
+}
+
+size_t ZSTDMT_sizeof_CCtx(ZSTDMT_CCtx* mtctx)
+{
+ if (mtctx == NULL) return 0; /* supports sizeof NULL */
+ return sizeof(*mtctx)
+ + POOL_sizeof(mtctx->factory)
+ + ZSTDMT_sizeof_bufferPool(mtctx->bufPool)
+ + (mtctx->jobIDMask+1) * sizeof(ZSTDMT_jobDescription)
+ + ZSTDMT_sizeof_CCtxPool(mtctx->cctxPool)
+ + ZSTDMT_sizeof_seqPool(mtctx->seqPool)
+ + ZSTD_sizeof_CDict(mtctx->cdictLocal)
+ + mtctx->roundBuff.capacity;
+}
+
+/* Internal only */
+size_t
+ZSTDMT_CCtxParam_setMTCtxParameter(ZSTD_CCtx_params* params,
+ ZSTDMT_parameter parameter,
+ int value)
+{
+ DEBUGLOG(4, "ZSTDMT_CCtxParam_setMTCtxParameter");
+ switch(parameter)
+ {
+ case ZSTDMT_p_jobSize :
+ DEBUGLOG(4, "ZSTDMT_CCtxParam_setMTCtxParameter : set jobSize to %i", value);
+ if ( value != 0 /* default */
+ && value < ZSTDMT_JOBSIZE_MIN)
+ value = ZSTDMT_JOBSIZE_MIN;
+ assert(value >= 0);
+ if (value > ZSTDMT_JOBSIZE_MAX) value = ZSTDMT_JOBSIZE_MAX;
+ params->jobSize = value;
+ return value;
+
+ case ZSTDMT_p_overlapLog :
+ DEBUGLOG(4, "ZSTDMT_p_overlapLog : %i", value);
+ if (value < ZSTD_OVERLAPLOG_MIN) value = ZSTD_OVERLAPLOG_MIN;
+ if (value > ZSTD_OVERLAPLOG_MAX) value = ZSTD_OVERLAPLOG_MAX;
+ params->overlapLog = value;
+ return value;
+
+ case ZSTDMT_p_rsyncable :
+ value = (value != 0);
+ params->rsyncable = value;
+ return value;
+
+ default :
+ return ERROR(parameter_unsupported);
+ }
+}
+
+size_t ZSTDMT_setMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSTDMT_parameter parameter, int value)
+{
+ DEBUGLOG(4, "ZSTDMT_setMTCtxParameter");
+ return ZSTDMT_CCtxParam_setMTCtxParameter(&mtctx->params, parameter, value);
+}
+
+size_t ZSTDMT_getMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSTDMT_parameter parameter, int* value)
+{
+ switch (parameter) {
+ case ZSTDMT_p_jobSize:
+ assert(mtctx->params.jobSize <= INT_MAX);
+ *value = (int)(mtctx->params.jobSize);
+ break;
+ case ZSTDMT_p_overlapLog:
+ *value = mtctx->params.overlapLog;
+ break;
+ case ZSTDMT_p_rsyncable:
+ *value = mtctx->params.rsyncable;
+ break;
+ default:
+ return ERROR(parameter_unsupported);
+ }
+ return 0;
+}
+
+/* Sets parameters relevant to the compression job,
+ * initializing others to default values. */
+static ZSTD_CCtx_params ZSTDMT_initJobCCtxParams(ZSTD_CCtx_params const params)
+{
+ ZSTD_CCtx_params jobParams;
+ memset(&jobParams, 0, sizeof(jobParams));
+
+ jobParams.cParams = params.cParams;
+ jobParams.fParams = params.fParams;
+ jobParams.compressionLevel = params.compressionLevel;
+
+ return jobParams;
+}
+
+
+/* ZSTDMT_resize() :
+ * @return : error code if fails, 0 on success */
+static size_t ZSTDMT_resize(ZSTDMT_CCtx* mtctx, unsigned nbWorkers)
+{
+ if (POOL_resize(mtctx->factory, nbWorkers)) return ERROR(memory_allocation);
+ CHECK_F( ZSTDMT_expandJobsTable(mtctx, nbWorkers) );
+ mtctx->bufPool = ZSTDMT_expandBufferPool(mtctx->bufPool, nbWorkers);
+ if (mtctx->bufPool == NULL) return ERROR(memory_allocation);
+ mtctx->cctxPool = ZSTDMT_expandCCtxPool(mtctx->cctxPool, nbWorkers);
+ if (mtctx->cctxPool == NULL) return ERROR(memory_allocation);
+ mtctx->seqPool = ZSTDMT_expandSeqPool(mtctx->seqPool, nbWorkers);
+ if (mtctx->seqPool == NULL) return ERROR(memory_allocation);
+ ZSTDMT_CCtxParam_setNbWorkers(&mtctx->params, nbWorkers);
+ return 0;
+}
+
+
+/*! ZSTDMT_updateCParams_whileCompressing() :
+ * Updates a selected set of compression parameters, remaining compatible with currently active frame.
+ * New parameters will be applied to next compression job. */
+void ZSTDMT_updateCParams_whileCompressing(ZSTDMT_CCtx* mtctx, const ZSTD_CCtx_params* cctxParams)
+{
+ U32 const saved_wlog = mtctx->params.cParams.windowLog; /* Do not modify windowLog while compressing */
+ int const compressionLevel = cctxParams->compressionLevel;
+ DEBUGLOG(5, "ZSTDMT_updateCParams_whileCompressing (level:%i)",
+ compressionLevel);
+ mtctx->params.compressionLevel = compressionLevel;
+ { ZSTD_compressionParameters cParams = ZSTD_getCParamsFromCCtxParams(cctxParams, 0, 0);
+ cParams.windowLog = saved_wlog;
+ mtctx->params.cParams = cParams;
+ }
+}
+
+/* ZSTDMT_getFrameProgression():
+ * tells how much data has been consumed (input) and produced (output) for current frame.
+ * able to count progression inside worker threads.
+ * Note : mutex will be acquired during statistics collection inside workers. */
+ZSTD_frameProgression ZSTDMT_getFrameProgression(ZSTDMT_CCtx* mtctx)
+{
+ ZSTD_frameProgression fps;
+ DEBUGLOG(5, "ZSTDMT_getFrameProgression");
+ fps.ingested = mtctx->consumed + mtctx->inBuff.filled;
+ fps.consumed = mtctx->consumed;
+ fps.produced = fps.flushed = mtctx->produced;
+ fps.currentJobID = mtctx->nextJobID;
+ fps.nbActiveWorkers = 0;
+ { unsigned jobNb;
+ unsigned lastJobNb = mtctx->nextJobID + mtctx->jobReady; assert(mtctx->jobReady <= 1);
+ DEBUGLOG(6, "ZSTDMT_getFrameProgression: jobs: from %u to <%u (jobReady:%u)",
+ mtctx->doneJobID, lastJobNb, mtctx->jobReady)
+ for (jobNb = mtctx->doneJobID ; jobNb < lastJobNb ; jobNb++) {
+ unsigned const wJobID = jobNb & mtctx->jobIDMask;
+ ZSTDMT_jobDescription* jobPtr = &mtctx->jobs[wJobID];
+ ZSTD_pthread_mutex_lock(&jobPtr->job_mutex);
+ { size_t const cResult = jobPtr->cSize;
+ size_t const produced = ZSTD_isError(cResult) ? 0 : cResult;
+ size_t const flushed = ZSTD_isError(cResult) ? 0 : jobPtr->dstFlushed;
+ assert(flushed <= produced);
+ fps.ingested += jobPtr->src.size;
+ fps.consumed += jobPtr->consumed;
+ fps.produced += produced;
+ fps.flushed += flushed;
+ fps.nbActiveWorkers += (jobPtr->consumed < jobPtr->src.size);
+ }
+ ZSTD_pthread_mutex_unlock(&mtctx->jobs[wJobID].job_mutex);
+ }
+ }
+ return fps;
+}
+
+
+size_t ZSTDMT_toFlushNow(ZSTDMT_CCtx* mtctx)
+{
+ size_t toFlush;
+ unsigned const jobID = mtctx->doneJobID;
+ assert(jobID <= mtctx->nextJobID);
+ if (jobID == mtctx->nextJobID) return 0; /* no active job => nothing to flush */
+
+ /* look into oldest non-fully-flushed job */
+ { unsigned const wJobID = jobID & mtctx->jobIDMask;
+ ZSTDMT_jobDescription* const jobPtr = &mtctx->jobs[wJobID];
+ ZSTD_pthread_mutex_lock(&jobPtr->job_mutex);
+ { size_t const cResult = jobPtr->cSize;
+ size_t const produced = ZSTD_isError(cResult) ? 0 : cResult;
+ size_t const flushed = ZSTD_isError(cResult) ? 0 : jobPtr->dstFlushed;
+ assert(flushed <= produced);
+ toFlush = produced - flushed;
+ if (toFlush==0 && (jobPtr->consumed >= jobPtr->src.size)) {
+ /* doneJobID is not-fully-flushed, but toFlush==0 : doneJobID should be compressing some more data */
+ assert(jobPtr->consumed < jobPtr->src.size);
+ }
+ }
+ ZSTD_pthread_mutex_unlock(&mtctx->jobs[wJobID].job_mutex);
+ }
+
+ return toFlush;
+}
+
+
+/* ------------------------------------------ */
+/* ===== Multi-threaded compression ===== */
+/* ------------------------------------------ */
+
+static unsigned ZSTDMT_computeTargetJobLog(ZSTD_CCtx_params const params)
+{
+ if (params.ldmParams.enableLdm)
+ /* In Long Range Mode, the windowLog is typically oversized.
+ * In which case, it's preferable to determine the jobSize
+ * based on chainLog instead. */
+ return MAX(21, params.cParams.chainLog + 4);
+ return MAX(20, params.cParams.windowLog + 2);
+}
+
+static int ZSTDMT_overlapLog_default(ZSTD_strategy strat)
+{
+ switch(strat)
+ {
+ case ZSTD_btultra2:
+ return 9;
+ case ZSTD_btultra:
+ case ZSTD_btopt:
+ return 8;
+ case ZSTD_btlazy2:
+ case ZSTD_lazy2:
+ return 7;
+ case ZSTD_lazy:
+ case ZSTD_greedy:
+ case ZSTD_dfast:
+ case ZSTD_fast:
+ default:;
+ }
+ return 6;
+}
+
+static int ZSTDMT_overlapLog(int ovlog, ZSTD_strategy strat)
+{
+ assert(0 <= ovlog && ovlog <= 9);
+ if (ovlog == 0) return ZSTDMT_overlapLog_default(strat);
+ return ovlog;
+}
+
+static size_t ZSTDMT_computeOverlapSize(ZSTD_CCtx_params const params)
+{
+ int const overlapRLog = 9 - ZSTDMT_overlapLog(params.overlapLog, params.cParams.strategy);
+ int ovLog = (overlapRLog >= 8) ? 0 : (params.cParams.windowLog - overlapRLog);
+ assert(0 <= overlapRLog && overlapRLog <= 8);
+ if (params.ldmParams.enableLdm) {
+ /* In Long Range Mode, the windowLog is typically oversized.
+ * In which case, it's preferable to determine the jobSize
+ * based on chainLog instead.
+ * Then, ovLog becomes a fraction of the jobSize, rather than windowSize */
+ ovLog = MIN(params.cParams.windowLog, ZSTDMT_computeTargetJobLog(params) - 2)
+ - overlapRLog;
+ }
+ assert(0 <= ovLog && ovLog <= 30);
+ DEBUGLOG(4, "overlapLog : %i", params.overlapLog);
+ DEBUGLOG(4, "overlap size : %i", 1 << ovLog);
+ return (ovLog==0) ? 0 : (size_t)1 << ovLog;
+}
+
+static unsigned
+ZSTDMT_computeNbJobs(ZSTD_CCtx_params params, size_t srcSize, unsigned nbWorkers)
+{
+ assert(nbWorkers>0);
+ { size_t const jobSizeTarget = (size_t)1 << ZSTDMT_computeTargetJobLog(params);
+ size_t const jobMaxSize = jobSizeTarget << 2;
+ size_t const passSizeMax = jobMaxSize * nbWorkers;
+ unsigned const multiplier = (unsigned)(srcSize / passSizeMax) + 1;
+ unsigned const nbJobsLarge = multiplier * nbWorkers;
+ unsigned const nbJobsMax = (unsigned)(srcSize / jobSizeTarget) + 1;
+ unsigned const nbJobsSmall = MIN(nbJobsMax, nbWorkers);
+ return (multiplier>1) ? nbJobsLarge : nbJobsSmall;
+} }
+
+/* ZSTDMT_compress_advanced_internal() :
+ * This is a blocking function : it will only give back control to caller after finishing its compression job.
+ */
+static size_t ZSTDMT_compress_advanced_internal(
+ ZSTDMT_CCtx* mtctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_CDict* cdict,
+ ZSTD_CCtx_params params)
+{
+ ZSTD_CCtx_params const jobParams = ZSTDMT_initJobCCtxParams(params);
+ size_t const overlapSize = ZSTDMT_computeOverlapSize(params);
+ unsigned const nbJobs = ZSTDMT_computeNbJobs(params, srcSize, params.nbWorkers);
+ size_t const proposedJobSize = (srcSize + (nbJobs-1)) / nbJobs;
+ size_t const avgJobSize = (((proposedJobSize-1) & 0x1FFFF) < 0x7FFF) ? proposedJobSize + 0xFFFF : proposedJobSize; /* avoid too small last block */
+ const char* const srcStart = (const char*)src;
+ size_t remainingSrcSize = srcSize;
+ unsigned const compressWithinDst = (dstCapacity >= ZSTD_compressBound(srcSize)) ? nbJobs : (unsigned)(dstCapacity / ZSTD_compressBound(avgJobSize)); /* presumes avgJobSize >= 256 KB, which should be the case */
+ size_t frameStartPos = 0, dstBufferPos = 0;
+ assert(jobParams.nbWorkers == 0);
+ assert(mtctx->cctxPool->totalCCtx == params.nbWorkers);
+
+ params.jobSize = (U32)avgJobSize;
+ DEBUGLOG(4, "ZSTDMT_compress_advanced_internal: nbJobs=%2u (rawSize=%u bytes; fixedSize=%u) ",
+ nbJobs, (U32)proposedJobSize, (U32)avgJobSize);
+
+ if ((nbJobs==1) | (params.nbWorkers<=1)) { /* fallback to single-thread mode : this is a blocking invocation anyway */
+ ZSTD_CCtx* const cctx = mtctx->cctxPool->cctx[0];
+ DEBUGLOG(4, "ZSTDMT_compress_advanced_internal: fallback to single-thread mode");
+ if (cdict) return ZSTD_compress_usingCDict_advanced(cctx, dst, dstCapacity, src, srcSize, cdict, jobParams.fParams);
+ return ZSTD_compress_advanced_internal(cctx, dst, dstCapacity, src, srcSize, NULL, 0, jobParams);
+ }
+
+ assert(avgJobSize >= 256 KB); /* condition for ZSTD_compressBound(A) + ZSTD_compressBound(B) <= ZSTD_compressBound(A+B), required to compress directly into Dst (no additional buffer) */
+ ZSTDMT_setBufferSize(mtctx->bufPool, ZSTD_compressBound(avgJobSize) );
+ if (ZSTDMT_serialState_reset(&mtctx->serial, mtctx->seqPool, params, avgJobSize))
+ return ERROR(memory_allocation);
+
+ CHECK_F( ZSTDMT_expandJobsTable(mtctx, nbJobs) ); /* only expands if necessary */
+
+ { unsigned u;
+ for (u=0; u<nbJobs; u++) {
+ size_t const jobSize = MIN(remainingSrcSize, avgJobSize);
+ size_t const dstBufferCapacity = ZSTD_compressBound(jobSize);
+ buffer_t const dstAsBuffer = { (char*)dst + dstBufferPos, dstBufferCapacity };
+ buffer_t const dstBuffer = u < compressWithinDst ? dstAsBuffer : g_nullBuffer;
+ size_t dictSize = u ? overlapSize : 0;
+
+ mtctx->jobs[u].prefix.start = srcStart + frameStartPos - dictSize;
+ mtctx->jobs[u].prefix.size = dictSize;
+ mtctx->jobs[u].src.start = srcStart + frameStartPos;
+ mtctx->jobs[u].src.size = jobSize; assert(jobSize > 0); /* avoid job.src.size == 0 */
+ mtctx->jobs[u].consumed = 0;
+ mtctx->jobs[u].cSize = 0;
+ mtctx->jobs[u].cdict = (u==0) ? cdict : NULL;
+ mtctx->jobs[u].fullFrameSize = srcSize;
+ mtctx->jobs[u].params = jobParams;
+ /* do not calculate checksum within sections, but write it in header for first section */
+ mtctx->jobs[u].dstBuff = dstBuffer;
+ mtctx->jobs[u].cctxPool = mtctx->cctxPool;
+ mtctx->jobs[u].bufPool = mtctx->bufPool;
+ mtctx->jobs[u].seqPool = mtctx->seqPool;
+ mtctx->jobs[u].serial = &mtctx->serial;
+ mtctx->jobs[u].jobID = u;
+ mtctx->jobs[u].firstJob = (u==0);
+ mtctx->jobs[u].lastJob = (u==nbJobs-1);
+
+ DEBUGLOG(5, "ZSTDMT_compress_advanced_internal: posting job %u (%u bytes)", u, (U32)jobSize);
+ DEBUG_PRINTHEX(6, mtctx->jobs[u].prefix.start, 12);
+ POOL_add(mtctx->factory, ZSTDMT_compressionJob, &mtctx->jobs[u]);
+
+ frameStartPos += jobSize;
+ dstBufferPos += dstBufferCapacity;
+ remainingSrcSize -= jobSize;
+ } }
+
+ /* collect result */
+ { size_t error = 0, dstPos = 0;
+ unsigned jobID;
+ for (jobID=0; jobID<nbJobs; jobID++) {
+ DEBUGLOG(5, "waiting for job %u ", jobID);
+ ZSTD_PTHREAD_MUTEX_LOCK(&mtctx->jobs[jobID].job_mutex);
+ while (mtctx->jobs[jobID].consumed < mtctx->jobs[jobID].src.size) {
+ DEBUGLOG(5, "waiting for jobCompleted signal from job %u", jobID);
+ ZSTD_pthread_cond_wait(&mtctx->jobs[jobID].job_cond, &mtctx->jobs[jobID].job_mutex);
+ }
+ ZSTD_pthread_mutex_unlock(&mtctx->jobs[jobID].job_mutex);
+ DEBUGLOG(5, "ready to write job %u ", jobID);
+
+ { size_t const cSize = mtctx->jobs[jobID].cSize;
+ if (ZSTD_isError(cSize)) error = cSize;
+ if ((!error) && (dstPos + cSize > dstCapacity)) error = ERROR(dstSize_tooSmall);
+ if (jobID) { /* note : job 0 is written directly at dst, which is correct position */
+ if (!error)
+ memmove((char*)dst + dstPos, mtctx->jobs[jobID].dstBuff.start, cSize); /* may overlap when job compressed within dst */
+ if (jobID >= compressWithinDst) { /* job compressed into its own buffer, which must be released */
+ DEBUGLOG(5, "releasing buffer %u>=%u", jobID, compressWithinDst);
+ ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[jobID].dstBuff);
+ } }
+ mtctx->jobs[jobID].dstBuff = g_nullBuffer;
+ mtctx->jobs[jobID].cSize = 0;
+ dstPos += cSize ;
+ }
+ } /* for (jobID=0; jobID<nbJobs; jobID++) */
+
+ DEBUGLOG(4, "checksumFlag : %u ", params.fParams.checksumFlag);
+ if (params.fParams.checksumFlag) {
+ U32 const checksum = (U32)XXH64_digest(&mtctx->serial.xxhState);
+ if (dstPos + 4 > dstCapacity) {
+ error = ERROR(dstSize_tooSmall);
+ } else {
+ DEBUGLOG(4, "writing checksum : %08X \n", checksum);
+ MEM_writeLE32((char*)dst + dstPos, checksum);
+ dstPos += 4;
+ } }
+
+ if (!error) DEBUGLOG(4, "compressed size : %u ", (U32)dstPos);
+ return error ? error : dstPos;
+ }
+}
+
+size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_CDict* cdict,
+ ZSTD_parameters params,
+ int overlapLog)
+{
+ ZSTD_CCtx_params cctxParams = mtctx->params;
+ cctxParams.cParams = params.cParams;
+ cctxParams.fParams = params.fParams;
+ assert(ZSTD_OVERLAPLOG_MIN <= overlapLog && overlapLog <= ZSTD_OVERLAPLOG_MAX);
+ cctxParams.overlapLog = overlapLog;
+ return ZSTDMT_compress_advanced_internal(mtctx,
+ dst, dstCapacity,
+ src, srcSize,
+ cdict, cctxParams);
+}
+
+
+size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ int compressionLevel)
+{
+ ZSTD_parameters params = ZSTD_getParams(compressionLevel, srcSize, 0);
+ int const overlapLog = ZSTDMT_overlapLog_default(params.cParams.strategy);
+ params.fParams.contentSizeFlag = 1;
+ return ZSTDMT_compress_advanced(mtctx, dst, dstCapacity, src, srcSize, NULL, params, overlapLog);
+}
+
+
+/* ====================================== */
+/* ======= Streaming API ======= */
+/* ====================================== */
+
+size_t ZSTDMT_initCStream_internal(
+ ZSTDMT_CCtx* mtctx,
+ const void* dict, size_t dictSize, ZSTD_dictContentType_e dictContentType,
+ const ZSTD_CDict* cdict, ZSTD_CCtx_params params,
+ unsigned long long pledgedSrcSize)
+{
+ DEBUGLOG(4, "ZSTDMT_initCStream_internal (pledgedSrcSize=%u, nbWorkers=%u, cctxPool=%u)",
+ (U32)pledgedSrcSize, params.nbWorkers, mtctx->cctxPool->totalCCtx);
+
+ /* params supposed partially fully validated at this point */
+ assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams)));
+ assert(!((dict) && (cdict))); /* either dict or cdict, not both */
+
+ /* init */
+ if (params.nbWorkers != mtctx->params.nbWorkers)
+ CHECK_F( ZSTDMT_resize(mtctx, params.nbWorkers) );
+
+ if (params.jobSize != 0 && params.jobSize < ZSTDMT_JOBSIZE_MIN) params.jobSize = ZSTDMT_JOBSIZE_MIN;
+ if (params.jobSize > (size_t)ZSTDMT_JOBSIZE_MAX) params.jobSize = ZSTDMT_JOBSIZE_MAX;
+
+ mtctx->singleBlockingThread = (pledgedSrcSize <= ZSTDMT_JOBSIZE_MIN); /* do not trigger multi-threading when srcSize is too small */
+ if (mtctx->singleBlockingThread) {
+ ZSTD_CCtx_params const singleThreadParams = ZSTDMT_initJobCCtxParams(params);
+ DEBUGLOG(5, "ZSTDMT_initCStream_internal: switch to single blocking thread mode");
+ assert(singleThreadParams.nbWorkers == 0);
+ return ZSTD_initCStream_internal(mtctx->cctxPool->cctx[0],
+ dict, dictSize, cdict,
+ singleThreadParams, pledgedSrcSize);
+ }
+
+ DEBUGLOG(4, "ZSTDMT_initCStream_internal: %u workers", params.nbWorkers);
+
+ if (mtctx->allJobsCompleted == 0) { /* previous compression not correctly finished */
+ ZSTDMT_waitForAllJobsCompleted(mtctx);
+ ZSTDMT_releaseAllJobResources(mtctx);
+ mtctx->allJobsCompleted = 1;
+ }
+
+ mtctx->params = params;
+ mtctx->frameContentSize = pledgedSrcSize;
+ if (dict) {
+ ZSTD_freeCDict(mtctx->cdictLocal);
+ mtctx->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize,
+ ZSTD_dlm_byCopy, dictContentType, /* note : a loadPrefix becomes an internal CDict */
+ params.cParams, mtctx->cMem);
+ mtctx->cdict = mtctx->cdictLocal;
+ if (mtctx->cdictLocal == NULL) return ERROR(memory_allocation);
+ } else {
+ ZSTD_freeCDict(mtctx->cdictLocal);
+ mtctx->cdictLocal = NULL;
+ mtctx->cdict = cdict;
+ }
+
+ mtctx->targetPrefixSize = ZSTDMT_computeOverlapSize(params);
+ DEBUGLOG(4, "overlapLog=%i => %u KB", params.overlapLog, (U32)(mtctx->targetPrefixSize>>10));
+ mtctx->targetSectionSize = params.jobSize;
+ if (mtctx->targetSectionSize == 0) {
+ mtctx->targetSectionSize = 1ULL << ZSTDMT_computeTargetJobLog(params);
+ }
+ if (params.rsyncable) {
+ /* Aim for the targetsectionSize as the average job size. */
+ U32 const jobSizeMB = (U32)(mtctx->targetSectionSize >> 20);
+ U32 const rsyncBits = ZSTD_highbit32(jobSizeMB) + 20;
+ assert(jobSizeMB >= 1);
+ DEBUGLOG(4, "rsyncLog = %u", rsyncBits);
+ mtctx->rsync.hash = 0;
+ mtctx->rsync.hitMask = (1ULL << rsyncBits) - 1;
+ mtctx->rsync.primePower = ZSTD_rollingHash_primePower(RSYNC_LENGTH);
+ }
+ if (mtctx->targetSectionSize < mtctx->targetPrefixSize) mtctx->targetSectionSize = mtctx->targetPrefixSize; /* job size must be >= overlap size */
+ DEBUGLOG(4, "Job Size : %u KB (note : set to %u)", (U32)(mtctx->targetSectionSize>>10), (U32)params.jobSize);
+ DEBUGLOG(4, "inBuff Size : %u KB", (U32)(mtctx->targetSectionSize>>10));
+ ZSTDMT_setBufferSize(mtctx->bufPool, ZSTD_compressBound(mtctx->targetSectionSize));
+ {
+ /* If ldm is enabled we need windowSize space. */
+ size_t const windowSize = mtctx->params.ldmParams.enableLdm ? (1U << mtctx->params.cParams.windowLog) : 0;
+ /* Two buffers of slack, plus extra space for the overlap
+ * This is the minimum slack that LDM works with. One extra because
+ * flush might waste up to targetSectionSize-1 bytes. Another extra
+ * for the overlap (if > 0), then one to fill which doesn't overlap
+ * with the LDM window.
+ */
+ size_t const nbSlackBuffers = 2 + (mtctx->targetPrefixSize > 0);
+ size_t const slackSize = mtctx->targetSectionSize * nbSlackBuffers;
+ /* Compute the total size, and always have enough slack */
+ size_t const nbWorkers = MAX(mtctx->params.nbWorkers, 1);
+ size_t const sectionsSize = mtctx->targetSectionSize * nbWorkers;
+ size_t const capacity = MAX(windowSize, sectionsSize) + slackSize;
+ if (mtctx->roundBuff.capacity < capacity) {
+ if (mtctx->roundBuff.buffer)
+ ZSTD_free(mtctx->roundBuff.buffer, mtctx->cMem);
+ mtctx->roundBuff.buffer = (BYTE*)ZSTD_malloc(capacity, mtctx->cMem);
+ if (mtctx->roundBuff.buffer == NULL) {
+ mtctx->roundBuff.capacity = 0;
+ return ERROR(memory_allocation);
+ }
+ mtctx->roundBuff.capacity = capacity;
+ }
+ }
+ DEBUGLOG(4, "roundBuff capacity : %u KB", (U32)(mtctx->roundBuff.capacity>>10));
+ mtctx->roundBuff.pos = 0;
+ mtctx->inBuff.buffer = g_nullBuffer;
+ mtctx->inBuff.filled = 0;
+ mtctx->inBuff.prefix = kNullRange;
+ mtctx->doneJobID = 0;
+ mtctx->nextJobID = 0;
+ mtctx->frameEnded = 0;
+ mtctx->allJobsCompleted = 0;
+ mtctx->consumed = 0;
+ mtctx->produced = 0;
+ if (ZSTDMT_serialState_reset(&mtctx->serial, mtctx->seqPool, params, mtctx->targetSectionSize))
+ return ERROR(memory_allocation);
+ return 0;
+}
+
+size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* mtctx,
+ const void* dict, size_t dictSize,
+ ZSTD_parameters params,
+ unsigned long long pledgedSrcSize)
+{
+ ZSTD_CCtx_params cctxParams = mtctx->params; /* retrieve sticky params */
+ DEBUGLOG(4, "ZSTDMT_initCStream_advanced (pledgedSrcSize=%u)", (U32)pledgedSrcSize);
+ cctxParams.cParams = params.cParams;
+ cctxParams.fParams = params.fParams;
+ return ZSTDMT_initCStream_internal(mtctx, dict, dictSize, ZSTD_dct_auto, NULL,
+ cctxParams, pledgedSrcSize);
+}
+
+size_t ZSTDMT_initCStream_usingCDict(ZSTDMT_CCtx* mtctx,
+ const ZSTD_CDict* cdict,
+ ZSTD_frameParameters fParams,
+ unsigned long long pledgedSrcSize)
+{
+ ZSTD_CCtx_params cctxParams = mtctx->params;
+ if (cdict==NULL) return ERROR(dictionary_wrong); /* method incompatible with NULL cdict */
+ cctxParams.cParams = ZSTD_getCParamsFromCDict(cdict);
+ cctxParams.fParams = fParams;
+ return ZSTDMT_initCStream_internal(mtctx, NULL, 0 /*dictSize*/, ZSTD_dct_auto, cdict,
+ cctxParams, pledgedSrcSize);
+}
+
+
+/* ZSTDMT_resetCStream() :
+ * pledgedSrcSize can be zero == unknown (for the time being)
+ * prefer using ZSTD_CONTENTSIZE_UNKNOWN,
+ * as `0` might mean "empty" in the future */
+size_t ZSTDMT_resetCStream(ZSTDMT_CCtx* mtctx, unsigned long long pledgedSrcSize)
+{
+ if (!pledgedSrcSize) pledgedSrcSize = ZSTD_CONTENTSIZE_UNKNOWN;
+ return ZSTDMT_initCStream_internal(mtctx, NULL, 0, ZSTD_dct_auto, 0, mtctx->params,
+ pledgedSrcSize);
+}
+
+size_t ZSTDMT_initCStream(ZSTDMT_CCtx* mtctx, int compressionLevel) {
+ ZSTD_parameters const params = ZSTD_getParams(compressionLevel, ZSTD_CONTENTSIZE_UNKNOWN, 0);
+ ZSTD_CCtx_params cctxParams = mtctx->params; /* retrieve sticky params */
+ DEBUGLOG(4, "ZSTDMT_initCStream (cLevel=%i)", compressionLevel);
+ cctxParams.cParams = params.cParams;
+ cctxParams.fParams = params.fParams;
+ return ZSTDMT_initCStream_internal(mtctx, NULL, 0, ZSTD_dct_auto, NULL, cctxParams, ZSTD_CONTENTSIZE_UNKNOWN);
+}
+
+
+/* ZSTDMT_writeLastEmptyBlock()
+ * Write a single empty block with an end-of-frame to finish a frame.
+ * Job must be created from streaming variant.
+ * This function is always successfull if expected conditions are fulfilled.
+ */
+static void ZSTDMT_writeLastEmptyBlock(ZSTDMT_jobDescription* job)
+{
+ assert(job->lastJob == 1);
+ assert(job->src.size == 0); /* last job is empty -> will be simplified into a last empty block */
+ assert(job->firstJob == 0); /* cannot be first job, as it also needs to create frame header */
+ assert(job->dstBuff.start == NULL); /* invoked from streaming variant only (otherwise, dstBuff might be user's output) */
+ job->dstBuff = ZSTDMT_getBuffer(job->bufPool);
+ if (job->dstBuff.start == NULL) {
+ job->cSize = ERROR(memory_allocation);
+ return;
+ }
+ assert(job->dstBuff.capacity >= ZSTD_blockHeaderSize); /* no buffer should ever be that small */
+ job->src = kNullRange;
+ job->cSize = ZSTD_writeLastEmptyBlock(job->dstBuff.start, job->dstBuff.capacity);
+ assert(!ZSTD_isError(job->cSize));
+ assert(job->consumed == 0);
+}
+
+static size_t ZSTDMT_createCompressionJob(ZSTDMT_CCtx* mtctx, size_t srcSize, ZSTD_EndDirective endOp)
+{
+ unsigned const jobID = mtctx->nextJobID & mtctx->jobIDMask;
+ int const endFrame = (endOp == ZSTD_e_end);
+
+ if (mtctx->nextJobID > mtctx->doneJobID + mtctx->jobIDMask) {
+ DEBUGLOG(5, "ZSTDMT_createCompressionJob: will not create new job : table is full");
+ assert((mtctx->nextJobID & mtctx->jobIDMask) == (mtctx->doneJobID & mtctx->jobIDMask));
+ return 0;
+ }
+
+ if (!mtctx->jobReady) {
+ BYTE const* src = (BYTE const*)mtctx->inBuff.buffer.start;
+ DEBUGLOG(5, "ZSTDMT_createCompressionJob: preparing job %u to compress %u bytes with %u preload ",
+ mtctx->nextJobID, (U32)srcSize, (U32)mtctx->inBuff.prefix.size);
+ mtctx->jobs[jobID].src.start = src;
+ mtctx->jobs[jobID].src.size = srcSize;
+ assert(mtctx->inBuff.filled >= srcSize);
+ mtctx->jobs[jobID].prefix = mtctx->inBuff.prefix;
+ mtctx->jobs[jobID].consumed = 0;
+ mtctx->jobs[jobID].cSize = 0;
+ mtctx->jobs[jobID].params = mtctx->params;
+ mtctx->jobs[jobID].cdict = mtctx->nextJobID==0 ? mtctx->cdict : NULL;
+ mtctx->jobs[jobID].fullFrameSize = mtctx->frameContentSize;
+ mtctx->jobs[jobID].dstBuff = g_nullBuffer;
+ mtctx->jobs[jobID].cctxPool = mtctx->cctxPool;
+ mtctx->jobs[jobID].bufPool = mtctx->bufPool;
+ mtctx->jobs[jobID].seqPool = mtctx->seqPool;
+ mtctx->jobs[jobID].serial = &mtctx->serial;
+ mtctx->jobs[jobID].jobID = mtctx->nextJobID;
+ mtctx->jobs[jobID].firstJob = (mtctx->nextJobID==0);
+ mtctx->jobs[jobID].lastJob = endFrame;
+ mtctx->jobs[jobID].frameChecksumNeeded = mtctx->params.fParams.checksumFlag && endFrame && (mtctx->nextJobID>0);
+ mtctx->jobs[jobID].dstFlushed = 0;
+
+ /* Update the round buffer pos and clear the input buffer to be reset */
+ mtctx->roundBuff.pos += srcSize;
+ mtctx->inBuff.buffer = g_nullBuffer;
+ mtctx->inBuff.filled = 0;
+ /* Set the prefix */
+ if (!endFrame) {
+ size_t const newPrefixSize = MIN(srcSize, mtctx->targetPrefixSize);
+ mtctx->inBuff.prefix.start = src + srcSize - newPrefixSize;
+ mtctx->inBuff.prefix.size = newPrefixSize;
+ } else { /* endFrame==1 => no need for another input buffer */
+ mtctx->inBuff.prefix = kNullRange;
+ mtctx->frameEnded = endFrame;
+ if (mtctx->nextJobID == 0) {
+ /* single job exception : checksum is already calculated directly within worker thread */
+ mtctx->params.fParams.checksumFlag = 0;
+ } }
+
+ if ( (srcSize == 0)
+ && (mtctx->nextJobID>0)/*single job must also write frame header*/ ) {
+ DEBUGLOG(5, "ZSTDMT_createCompressionJob: creating a last empty block to end frame");
+ assert(endOp == ZSTD_e_end); /* only possible case : need to end the frame with an empty last block */
+ ZSTDMT_writeLastEmptyBlock(mtctx->jobs + jobID);
+ mtctx->nextJobID++;
+ return 0;
+ }
+ }
+
+ DEBUGLOG(5, "ZSTDMT_createCompressionJob: posting job %u : %u bytes (end:%u, jobNb == %u (mod:%u))",
+ mtctx->nextJobID,
+ (U32)mtctx->jobs[jobID].src.size,
+ mtctx->jobs[jobID].lastJob,
+ mtctx->nextJobID,
+ jobID);
+ if (POOL_tryAdd(mtctx->factory, ZSTDMT_compressionJob, &mtctx->jobs[jobID])) {
+ mtctx->nextJobID++;
+ mtctx->jobReady = 0;
+ } else {
+ DEBUGLOG(5, "ZSTDMT_createCompressionJob: no worker available for job %u", mtctx->nextJobID);
+ mtctx->jobReady = 1;
+ }
+ return 0;
+}
+
+
+/*! ZSTDMT_flushProduced() :
+ * flush whatever data has been produced but not yet flushed in current job.
+ * move to next job if current one is fully flushed.
+ * `output` : `pos` will be updated with amount of data flushed .
+ * `blockToFlush` : if >0, the function will block and wait if there is no data available to flush .
+ * @return : amount of data remaining within internal buffer, 0 if no more, 1 if unknown but > 0, or an error code */
+static size_t ZSTDMT_flushProduced(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output, unsigned blockToFlush, ZSTD_EndDirective end)
+{
+ unsigned const wJobID = mtctx->doneJobID & mtctx->jobIDMask;
+ DEBUGLOG(5, "ZSTDMT_flushProduced (blocking:%u , job %u <= %u)",
+ blockToFlush, mtctx->doneJobID, mtctx->nextJobID);
+ assert(output->size >= output->pos);
+
+ ZSTD_PTHREAD_MUTEX_LOCK(&mtctx->jobs[wJobID].job_mutex);
+ if ( blockToFlush
+ && (mtctx->doneJobID < mtctx->nextJobID) ) {
+ assert(mtctx->jobs[wJobID].dstFlushed <= mtctx->jobs[wJobID].cSize);
+ while (mtctx->jobs[wJobID].dstFlushed == mtctx->jobs[wJobID].cSize) { /* nothing to flush */
+ if (mtctx->jobs[wJobID].consumed == mtctx->jobs[wJobID].src.size) {
+ DEBUGLOG(5, "job %u is completely consumed (%u == %u) => don't wait for cond, there will be none",
+ mtctx->doneJobID, (U32)mtctx->jobs[wJobID].consumed, (U32)mtctx->jobs[wJobID].src.size);
+ break;
+ }
+ DEBUGLOG(5, "waiting for something to flush from job %u (currently flushed: %u bytes)",
+ mtctx->doneJobID, (U32)mtctx->jobs[wJobID].dstFlushed);
+ ZSTD_pthread_cond_wait(&mtctx->jobs[wJobID].job_cond, &mtctx->jobs[wJobID].job_mutex); /* block when nothing to flush but some to come */
+ } }
+
+ /* try to flush something */
+ { size_t cSize = mtctx->jobs[wJobID].cSize; /* shared */
+ size_t const srcConsumed = mtctx->jobs[wJobID].consumed; /* shared */
+ size_t const srcSize = mtctx->jobs[wJobID].src.size; /* read-only, could be done after mutex lock, but no-declaration-after-statement */
+ ZSTD_pthread_mutex_unlock(&mtctx->jobs[wJobID].job_mutex);
+ if (ZSTD_isError(cSize)) {
+ DEBUGLOG(5, "ZSTDMT_flushProduced: job %u : compression error detected : %s",
+ mtctx->doneJobID, ZSTD_getErrorName(cSize));
+ ZSTDMT_waitForAllJobsCompleted(mtctx);
+ ZSTDMT_releaseAllJobResources(mtctx);
+ return cSize;
+ }
+ /* add frame checksum if necessary (can only happen once) */
+ assert(srcConsumed <= srcSize);
+ if ( (srcConsumed == srcSize) /* job completed -> worker no longer active */
+ && mtctx->jobs[wJobID].frameChecksumNeeded ) {
+ U32 const checksum = (U32)XXH64_digest(&mtctx->serial.xxhState);
+ DEBUGLOG(4, "ZSTDMT_flushProduced: writing checksum : %08X \n", checksum);
+ MEM_writeLE32((char*)mtctx->jobs[wJobID].dstBuff.start + mtctx->jobs[wJobID].cSize, checksum);
+ cSize += 4;
+ mtctx->jobs[wJobID].cSize += 4; /* can write this shared value, as worker is no longer active */
+ mtctx->jobs[wJobID].frameChecksumNeeded = 0;
+ }
+
+ if (cSize > 0) { /* compression is ongoing or completed */
+ size_t const toFlush = MIN(cSize - mtctx->jobs[wJobID].dstFlushed, output->size - output->pos);
+ DEBUGLOG(5, "ZSTDMT_flushProduced: Flushing %u bytes from job %u (completion:%u/%u, generated:%u)",
+ (U32)toFlush, mtctx->doneJobID, (U32)srcConsumed, (U32)srcSize, (U32)cSize);
+ assert(mtctx->doneJobID < mtctx->nextJobID);
+ assert(cSize >= mtctx->jobs[wJobID].dstFlushed);
+ assert(mtctx->jobs[wJobID].dstBuff.start != NULL);
+ memcpy((char*)output->dst + output->pos,
+ (const char*)mtctx->jobs[wJobID].dstBuff.start + mtctx->jobs[wJobID].dstFlushed,
+ toFlush);
+ output->pos += toFlush;
+ mtctx->jobs[wJobID].dstFlushed += toFlush; /* can write : this value is only used by mtctx */
+
+ if ( (srcConsumed == srcSize) /* job is completed */
+ && (mtctx->jobs[wJobID].dstFlushed == cSize) ) { /* output buffer fully flushed => free this job position */
+ DEBUGLOG(5, "Job %u completed (%u bytes), moving to next one",
+ mtctx->doneJobID, (U32)mtctx->jobs[wJobID].dstFlushed);
+ ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[wJobID].dstBuff);
+ DEBUGLOG(5, "dstBuffer released");
+ mtctx->jobs[wJobID].dstBuff = g_nullBuffer;
+ mtctx->jobs[wJobID].cSize = 0; /* ensure this job slot is considered "not started" in future check */
+ mtctx->consumed += srcSize;
+ mtctx->produced += cSize;
+ mtctx->doneJobID++;
+ } }
+
+ /* return value : how many bytes left in buffer ; fake it to 1 when unknown but >0 */
+ if (cSize > mtctx->jobs[wJobID].dstFlushed) return (cSize - mtctx->jobs[wJobID].dstFlushed);
+ if (srcSize > srcConsumed) return 1; /* current job not completely compressed */
+ }
+ if (mtctx->doneJobID < mtctx->nextJobID) return 1; /* some more jobs ongoing */
+ if (mtctx->jobReady) return 1; /* one job is ready to push, just not yet in the list */
+ if (mtctx->inBuff.filled > 0) return 1; /* input is not empty, and still needs to be converted into a job */
+ mtctx->allJobsCompleted = mtctx->frameEnded; /* all jobs are entirely flushed => if this one is last one, frame is completed */
+ if (end == ZSTD_e_end) return !mtctx->frameEnded; /* for ZSTD_e_end, question becomes : is frame completed ? instead of : are internal buffers fully flushed ? */
+ return 0; /* internal buffers fully flushed */
+}
+
+/**
+ * Returns the range of data used by the earliest job that is not yet complete.
+ * If the data of the first job is broken up into two segments, we cover both
+ * sections.
+ */
+static range_t ZSTDMT_getInputDataInUse(ZSTDMT_CCtx* mtctx)
+{
+ unsigned const firstJobID = mtctx->doneJobID;
+ unsigned const lastJobID = mtctx->nextJobID;
+ unsigned jobID;
+
+ for (jobID = firstJobID; jobID < lastJobID; ++jobID) {
+ unsigned const wJobID = jobID & mtctx->jobIDMask;
+ size_t consumed;
+
+ ZSTD_PTHREAD_MUTEX_LOCK(&mtctx->jobs[wJobID].job_mutex);
+ consumed = mtctx->jobs[wJobID].consumed;
+ ZSTD_pthread_mutex_unlock(&mtctx->jobs[wJobID].job_mutex);
+
+ if (consumed < mtctx->jobs[wJobID].src.size) {
+ range_t range = mtctx->jobs[wJobID].prefix;
+ if (range.size == 0) {
+ /* Empty prefix */
+ range = mtctx->jobs[wJobID].src;
+ }
+ /* Job source in multiple segments not supported yet */
+ assert(range.start <= mtctx->jobs[wJobID].src.start);
+ return range;
+ }
+ }
+ return kNullRange;
+}
+
+/**
+ * Returns non-zero iff buffer and range overlap.
+ */
+static int ZSTDMT_isOverlapped(buffer_t buffer, range_t range)
+{
+ BYTE const* const bufferStart = (BYTE const*)buffer.start;
+ BYTE const* const bufferEnd = bufferStart + buffer.capacity;
+ BYTE const* const rangeStart = (BYTE const*)range.start;
+ BYTE const* const rangeEnd = rangeStart + range.size;
+
+ if (rangeStart == NULL || bufferStart == NULL)
+ return 0;
+ /* Empty ranges cannot overlap */
+ if (bufferStart == bufferEnd || rangeStart == rangeEnd)
+ return 0;
+
+ return bufferStart < rangeEnd && rangeStart < bufferEnd;
+}
+
+static int ZSTDMT_doesOverlapWindow(buffer_t buffer, ZSTD_window_t window)
+{
+ range_t extDict;
+ range_t prefix;
+
+ DEBUGLOG(5, "ZSTDMT_doesOverlapWindow");
+ extDict.start = window.dictBase + window.lowLimit;
+ extDict.size = window.dictLimit - window.lowLimit;
+
+ prefix.start = window.base + window.dictLimit;
+ prefix.size = window.nextSrc - (window.base + window.dictLimit);
+ DEBUGLOG(5, "extDict [0x%zx, 0x%zx)",
+ (size_t)extDict.start,
+ (size_t)extDict.start + extDict.size);
+ DEBUGLOG(5, "prefix [0x%zx, 0x%zx)",
+ (size_t)prefix.start,
+ (size_t)prefix.start + prefix.size);
+
+ return ZSTDMT_isOverlapped(buffer, extDict)
+ || ZSTDMT_isOverlapped(buffer, prefix);
+}
+
+static void ZSTDMT_waitForLdmComplete(ZSTDMT_CCtx* mtctx, buffer_t buffer)
+{
+ if (mtctx->params.ldmParams.enableLdm) {
+ ZSTD_pthread_mutex_t* mutex = &mtctx->serial.ldmWindowMutex;
+ DEBUGLOG(5, "ZSTDMT_waitForLdmComplete");
+ DEBUGLOG(5, "source [0x%zx, 0x%zx)",
+ (size_t)buffer.start,
+ (size_t)buffer.start + buffer.capacity);
+ ZSTD_PTHREAD_MUTEX_LOCK(mutex);
+ while (ZSTDMT_doesOverlapWindow(buffer, mtctx->serial.ldmWindow)) {
+ DEBUGLOG(5, "Waiting for LDM to finish...");
+ ZSTD_pthread_cond_wait(&mtctx->serial.ldmWindowCond, mutex);
+ }
+ DEBUGLOG(6, "Done waiting for LDM to finish");
+ ZSTD_pthread_mutex_unlock(mutex);
+ }
+}
+
+/**
+ * Attempts to set the inBuff to the next section to fill.
+ * If any part of the new section is still in use we give up.
+ * Returns non-zero if the buffer is filled.
+ */
+static int ZSTDMT_tryGetInputRange(ZSTDMT_CCtx* mtctx)
+{
+ range_t const inUse = ZSTDMT_getInputDataInUse(mtctx);
+ size_t const spaceLeft = mtctx->roundBuff.capacity - mtctx->roundBuff.pos;
+ size_t const target = mtctx->targetSectionSize;
+ buffer_t buffer;
+
+ DEBUGLOG(5, "ZSTDMT_tryGetInputRange");
+ assert(mtctx->inBuff.buffer.start == NULL);
+ assert(mtctx->roundBuff.capacity >= target);
+
+ if (spaceLeft < target) {
+ /* ZSTD_invalidateRepCodes() doesn't work for extDict variants.
+ * Simply copy the prefix to the beginning in that case.
+ */
+ BYTE* const start = (BYTE*)mtctx->roundBuff.buffer;
+ size_t const prefixSize = mtctx->inBuff.prefix.size;
+
+ buffer.start = start;
+ buffer.capacity = prefixSize;
+ if (ZSTDMT_isOverlapped(buffer, inUse)) {
+ DEBUGLOG(5, "Waiting for buffer...");
+ return 0;
+ }
+ ZSTDMT_waitForLdmComplete(mtctx, buffer);
+ memmove(start, mtctx->inBuff.prefix.start, prefixSize);
+ mtctx->inBuff.prefix.start = start;
+ mtctx->roundBuff.pos = prefixSize;
+ }
+ buffer.start = mtctx->roundBuff.buffer + mtctx->roundBuff.pos;
+ buffer.capacity = target;
+
+ if (ZSTDMT_isOverlapped(buffer, inUse)) {
+ DEBUGLOG(5, "Waiting for buffer...");
+ return 0;
+ }
+ assert(!ZSTDMT_isOverlapped(buffer, mtctx->inBuff.prefix));
+
+ ZSTDMT_waitForLdmComplete(mtctx, buffer);
+
+ DEBUGLOG(5, "Using prefix range [%zx, %zx)",
+ (size_t)mtctx->inBuff.prefix.start,
+ (size_t)mtctx->inBuff.prefix.start + mtctx->inBuff.prefix.size);
+ DEBUGLOG(5, "Using source range [%zx, %zx)",
+ (size_t)buffer.start,
+ (size_t)buffer.start + buffer.capacity);
+
+
+ mtctx->inBuff.buffer = buffer;
+ mtctx->inBuff.filled = 0;
+ assert(mtctx->roundBuff.pos + buffer.capacity <= mtctx->roundBuff.capacity);
+ return 1;
+}
+
+typedef struct {
+ size_t toLoad; /* The number of bytes to load from the input. */
+ int flush; /* Boolean declaring if we must flush because we found a synchronization point. */
+} syncPoint_t;
+
+/**
+ * Searches through the input for a synchronization point. If one is found, we
+ * will instruct the caller to flush, and return the number of bytes to load.
+ * Otherwise, we will load as many bytes as possible and instruct the caller
+ * to continue as normal.
+ */
+static syncPoint_t
+findSynchronizationPoint(ZSTDMT_CCtx const* mtctx, ZSTD_inBuffer const input)
+{
+ BYTE const* const istart = (BYTE const*)input.src + input.pos;
+ U64 const primePower = mtctx->rsync.primePower;
+ U64 const hitMask = mtctx->rsync.hitMask;
+
+ syncPoint_t syncPoint;
+ U64 hash;
+ BYTE const* prev;
+ size_t pos;
+
+ syncPoint.toLoad = MIN(input.size - input.pos, mtctx->targetSectionSize - mtctx->inBuff.filled);
+ syncPoint.flush = 0;
+ if (!mtctx->params.rsyncable)
+ /* Rsync is disabled. */
+ return syncPoint;
+ if (mtctx->inBuff.filled + syncPoint.toLoad < RSYNC_LENGTH)
+ /* Not enough to compute the hash.
+ * We will miss any synchronization points in this RSYNC_LENGTH byte
+ * window. However, since it depends only in the internal buffers, if the
+ * state is already synchronized, we will remain synchronized.
+ * Additionally, the probability that we miss a synchronization point is
+ * low: RSYNC_LENGTH / targetSectionSize.
+ */
+ return syncPoint;
+ /* Initialize the loop variables. */
+ if (mtctx->inBuff.filled >= RSYNC_LENGTH) {
+ /* We have enough bytes buffered to initialize the hash.
+ * Start scanning at the beginning of the input.
+ */
+ pos = 0;
+ prev = (BYTE const*)mtctx->inBuff.buffer.start + mtctx->inBuff.filled - RSYNC_LENGTH;
+ hash = ZSTD_rollingHash_compute(prev, RSYNC_LENGTH);
+ } else {
+ /* We don't have enough bytes buffered to initialize the hash, but
+ * we know we have at least RSYNC_LENGTH bytes total.
+ * Start scanning after the first RSYNC_LENGTH bytes less the bytes
+ * already buffered.
+ */
+ pos = RSYNC_LENGTH - mtctx->inBuff.filled;
+ prev = (BYTE const*)mtctx->inBuff.buffer.start - pos;
+ hash = ZSTD_rollingHash_compute(mtctx->inBuff.buffer.start, mtctx->inBuff.filled);
+ hash = ZSTD_rollingHash_append(hash, istart, pos);
+ }
+ /* Starting with the hash of the previous RSYNC_LENGTH bytes, roll
+ * through the input. If we hit a synchronization point, then cut the
+ * job off, and tell the compressor to flush the job. Otherwise, load
+ * all the bytes and continue as normal.
+ * If we go too long without a synchronization point (targetSectionSize)
+ * then a block will be emitted anyways, but this is okay, since if we
+ * are already synchronized we will remain synchronized.
+ */
+ for (; pos < syncPoint.toLoad; ++pos) {
+ BYTE const toRemove = pos < RSYNC_LENGTH ? prev[pos] : istart[pos - RSYNC_LENGTH];
+ /* if (pos >= RSYNC_LENGTH) assert(ZSTD_rollingHash_compute(istart + pos - RSYNC_LENGTH, RSYNC_LENGTH) == hash); */
+ hash = ZSTD_rollingHash_rotate(hash, toRemove, istart[pos], primePower);
+ if ((hash & hitMask) == hitMask) {
+ syncPoint.toLoad = pos + 1;
+ syncPoint.flush = 1;
+ break;
+ }
+ }
+ return syncPoint;
+}
+
+size_t ZSTDMT_nextInputSizeHint(const ZSTDMT_CCtx* mtctx)
+{
+ size_t hintInSize = mtctx->targetSectionSize - mtctx->inBuff.filled;
+ if (hintInSize==0) hintInSize = mtctx->targetSectionSize;
+ return hintInSize;
+}
+
+/** ZSTDMT_compressStream_generic() :
+ * internal use only - exposed to be invoked from zstd_compress.c
+ * assumption : output and input are valid (pos <= size)
+ * @return : minimum amount of data remaining to flush, 0 if none */
+size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective endOp)
+{
+ unsigned forwardInputProgress = 0;
+ DEBUGLOG(5, "ZSTDMT_compressStream_generic (endOp=%u, srcSize=%u)",
+ (U32)endOp, (U32)(input->size - input->pos));
+ assert(output->pos <= output->size);
+ assert(input->pos <= input->size);
+
+ if (mtctx->singleBlockingThread) { /* delegate to single-thread (synchronous) */
+ return ZSTD_compressStream_generic(mtctx->cctxPool->cctx[0], output, input, endOp);
+ }
+
+ if ((mtctx->frameEnded) && (endOp==ZSTD_e_continue)) {
+ /* current frame being ended. Only flush/end are allowed */
+ return ERROR(stage_wrong);
+ }
+
+ /* single-pass shortcut (note : synchronous-mode) */
+ if ( (!mtctx->params.rsyncable) /* rsyncable mode is disabled */
+ && (mtctx->nextJobID == 0) /* just started */
+ && (mtctx->inBuff.filled == 0) /* nothing buffered */
+ && (!mtctx->jobReady) /* no job already created */
+ && (endOp == ZSTD_e_end) /* end order */
+ && (output->size - output->pos >= ZSTD_compressBound(input->size - input->pos)) ) { /* enough space in dst */
+ size_t const cSize = ZSTDMT_compress_advanced_internal(mtctx,
+ (char*)output->dst + output->pos, output->size - output->pos,
+ (const char*)input->src + input->pos, input->size - input->pos,
+ mtctx->cdict, mtctx->params);
+ if (ZSTD_isError(cSize)) return cSize;
+ input->pos = input->size;
+ output->pos += cSize;
+ mtctx->allJobsCompleted = 1;
+ mtctx->frameEnded = 1;
+ return 0;
+ }
+
+ /* fill input buffer */
+ if ( (!mtctx->jobReady)
+ && (input->size > input->pos) ) { /* support NULL input */
+ if (mtctx->inBuff.buffer.start == NULL) {
+ assert(mtctx->inBuff.filled == 0); /* Can't fill an empty buffer */
+ if (!ZSTDMT_tryGetInputRange(mtctx)) {
+ /* It is only possible for this operation to fail if there are
+ * still compression jobs ongoing.
+ */
+ DEBUGLOG(5, "ZSTDMT_tryGetInputRange failed");
+ assert(mtctx->doneJobID != mtctx->nextJobID);
+ } else
+ DEBUGLOG(5, "ZSTDMT_tryGetInputRange completed successfully : mtctx->inBuff.buffer.start = %p", mtctx->inBuff.buffer.start);
+ }
+ if (mtctx->inBuff.buffer.start != NULL) {
+ syncPoint_t const syncPoint = findSynchronizationPoint(mtctx, *input);
+ if (syncPoint.flush && endOp == ZSTD_e_continue) {
+ endOp = ZSTD_e_flush;
+ }
+ assert(mtctx->inBuff.buffer.capacity >= mtctx->targetSectionSize);
+ DEBUGLOG(5, "ZSTDMT_compressStream_generic: adding %u bytes on top of %u to buffer of size %u",
+ (U32)syncPoint.toLoad, (U32)mtctx->inBuff.filled, (U32)mtctx->targetSectionSize);
+ memcpy((char*)mtctx->inBuff.buffer.start + mtctx->inBuff.filled, (const char*)input->src + input->pos, syncPoint.toLoad);
+ input->pos += syncPoint.toLoad;
+ mtctx->inBuff.filled += syncPoint.toLoad;
+ forwardInputProgress = syncPoint.toLoad>0;
+ }
+ if ((input->pos < input->size) && (endOp == ZSTD_e_end))
+ endOp = ZSTD_e_flush; /* can't end now : not all input consumed */
+ }
+
+ if ( (mtctx->jobReady)
+ || (mtctx->inBuff.filled >= mtctx->targetSectionSize) /* filled enough : let's compress */
+ || ((endOp != ZSTD_e_continue) && (mtctx->inBuff.filled > 0)) /* something to flush : let's go */
+ || ((endOp == ZSTD_e_end) && (!mtctx->frameEnded)) ) { /* must finish the frame with a zero-size block */
+ size_t const jobSize = mtctx->inBuff.filled;
+ assert(mtctx->inBuff.filled <= mtctx->targetSectionSize);
+ CHECK_F( ZSTDMT_createCompressionJob(mtctx, jobSize, endOp) );
+ }
+
+ /* check for potential compressed data ready to be flushed */
+ { size_t const remainingToFlush = ZSTDMT_flushProduced(mtctx, output, !forwardInputProgress, endOp); /* block if there was no forward input progress */
+ if (input->pos < input->size) return MAX(remainingToFlush, 1); /* input not consumed : do not end flush yet */
+ DEBUGLOG(5, "end of ZSTDMT_compressStream_generic: remainingToFlush = %u", (U32)remainingToFlush);
+ return remainingToFlush;
+ }
+}
+
+
+size_t ZSTDMT_compressStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output, ZSTD_inBuffer* input)
+{
+ CHECK_F( ZSTDMT_compressStream_generic(mtctx, output, input, ZSTD_e_continue) );
+
+ /* recommended next input size : fill current input buffer */
+ return mtctx->targetSectionSize - mtctx->inBuff.filled; /* note : could be zero when input buffer is fully filled and no more availability to create new job */
+}
+
+
+static size_t ZSTDMT_flushStream_internal(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output, ZSTD_EndDirective endFrame)
+{
+ size_t const srcSize = mtctx->inBuff.filled;
+ DEBUGLOG(5, "ZSTDMT_flushStream_internal");
+
+ if ( mtctx->jobReady /* one job ready for a worker to pick up */
+ || (srcSize > 0) /* still some data within input buffer */
+ || ((endFrame==ZSTD_e_end) && !mtctx->frameEnded)) { /* need a last 0-size block to end frame */
+ DEBUGLOG(5, "ZSTDMT_flushStream_internal : create a new job (%u bytes, end:%u)",
+ (U32)srcSize, (U32)endFrame);
+ CHECK_F( ZSTDMT_createCompressionJob(mtctx, srcSize, endFrame) );
+ }
+
+ /* check if there is any data available to flush */
+ return ZSTDMT_flushProduced(mtctx, output, 1 /* blockToFlush */, endFrame);
+}
+
+
+size_t ZSTDMT_flushStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output)
+{
+ DEBUGLOG(5, "ZSTDMT_flushStream");
+ if (mtctx->singleBlockingThread)
+ return ZSTD_flushStream(mtctx->cctxPool->cctx[0], output);
+ return ZSTDMT_flushStream_internal(mtctx, output, ZSTD_e_flush);
+}
+
+size_t ZSTDMT_endStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output)
+{
+ DEBUGLOG(4, "ZSTDMT_endStream");
+ if (mtctx->singleBlockingThread)
+ return ZSTD_endStream(mtctx->cctxPool->cctx[0], output);
+ return ZSTDMT_flushStream_internal(mtctx, output, ZSTD_e_end);
+}
diff --git a/Utilities/cmzstd/lib/compress/zstdmt_compress.h b/Utilities/cmzstd/lib/compress/zstdmt_compress.h
new file mode 100644
index 000000000..ee771681f
--- /dev/null
+++ b/Utilities/cmzstd/lib/compress/zstdmt_compress.h
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+ #ifndef ZSTDMT_COMPRESS_H
+ #define ZSTDMT_COMPRESS_H
+
+ #if defined (__cplusplus)
+ extern "C" {
+ #endif
+
+
+/* Note : This is an internal API.
+ * Some methods are still exposed (ZSTDLIB_API),
+ * because it used to be the only way to invoke MT compression.
+ * Now, it's recommended to use ZSTD_compress_generic() instead.
+ * These methods will stop being exposed in a future version */
+
+/* === Dependencies === */
+#include <stddef.h> /* size_t */
+#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters */
+#include "zstd.h" /* ZSTD_inBuffer, ZSTD_outBuffer, ZSTDLIB_API */
+
+
+/* === Constants === */
+#ifndef ZSTDMT_NBWORKERS_MAX
+# define ZSTDMT_NBWORKERS_MAX 200
+#endif
+#ifndef ZSTDMT_JOBSIZE_MIN
+# define ZSTDMT_JOBSIZE_MIN (1 MB)
+#endif
+#define ZSTDMT_JOBSIZE_MAX (MEM_32bits() ? (512 MB) : (1024 MB))
+
+
+/* === Memory management === */
+typedef struct ZSTDMT_CCtx_s ZSTDMT_CCtx;
+ZSTDLIB_API ZSTDMT_CCtx* ZSTDMT_createCCtx(unsigned nbWorkers);
+ZSTDLIB_API ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbWorkers,
+ ZSTD_customMem cMem);
+ZSTDLIB_API size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* mtctx);
+
+ZSTDLIB_API size_t ZSTDMT_sizeof_CCtx(ZSTDMT_CCtx* mtctx);
+
+
+/* === Simple one-pass compression function === */
+
+ZSTDLIB_API size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ int compressionLevel);
+
+
+
+/* === Streaming functions === */
+
+ZSTDLIB_API size_t ZSTDMT_initCStream(ZSTDMT_CCtx* mtctx, int compressionLevel);
+ZSTDLIB_API size_t ZSTDMT_resetCStream(ZSTDMT_CCtx* mtctx, unsigned long long pledgedSrcSize); /**< if srcSize is not known at reset time, use ZSTD_CONTENTSIZE_UNKNOWN. Note: for compatibility with older programs, 0 means the same as ZSTD_CONTENTSIZE_UNKNOWN, but it will change in the future to mean "empty" */
+
+ZSTDLIB_API size_t ZSTDMT_nextInputSizeHint(const ZSTDMT_CCtx* mtctx);
+ZSTDLIB_API size_t ZSTDMT_compressStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
+
+ZSTDLIB_API size_t ZSTDMT_flushStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output); /**< @return : 0 == all flushed; >0 : still some data to be flushed; or an error code (ZSTD_isError()) */
+ZSTDLIB_API size_t ZSTDMT_endStream(ZSTDMT_CCtx* mtctx, ZSTD_outBuffer* output); /**< @return : 0 == all flushed; >0 : still some data to be flushed; or an error code (ZSTD_isError()) */
+
+
+/* === Advanced functions and parameters === */
+
+ZSTDLIB_API size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_CDict* cdict,
+ ZSTD_parameters params,
+ int overlapLog);
+
+ZSTDLIB_API size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* mtctx,
+ const void* dict, size_t dictSize, /* dict can be released after init, a local copy is preserved within zcs */
+ ZSTD_parameters params,
+ unsigned long long pledgedSrcSize); /* pledgedSrcSize is optional and can be zero == unknown */
+
+ZSTDLIB_API size_t ZSTDMT_initCStream_usingCDict(ZSTDMT_CCtx* mtctx,
+ const ZSTD_CDict* cdict,
+ ZSTD_frameParameters fparams,
+ unsigned long long pledgedSrcSize); /* note : zero means empty */
+
+/* ZSTDMT_parameter :
+ * List of parameters that can be set using ZSTDMT_setMTCtxParameter() */
+typedef enum {
+ ZSTDMT_p_jobSize, /* Each job is compressed in parallel. By default, this value is dynamically determined depending on compression parameters. Can be set explicitly here. */
+ ZSTDMT_p_overlapLog, /* Each job may reload a part of previous job to enhance compressionr ratio; 0 == no overlap, 6(default) == use 1/8th of window, >=9 == use full window. This is a "sticky" parameter : its value will be re-used on next compression job */
+ ZSTDMT_p_rsyncable /* Enables rsyncable mode. */
+} ZSTDMT_parameter;
+
+/* ZSTDMT_setMTCtxParameter() :
+ * allow setting individual parameters, one at a time, among a list of enums defined in ZSTDMT_parameter.
+ * The function must be called typically after ZSTD_createCCtx() but __before ZSTDMT_init*() !__
+ * Parameters not explicitly reset by ZSTDMT_init*() remain the same in consecutive compression sessions.
+ * @return : 0, or an error code (which can be tested using ZSTD_isError()) */
+ZSTDLIB_API size_t ZSTDMT_setMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSTDMT_parameter parameter, int value);
+
+/* ZSTDMT_getMTCtxParameter() :
+ * Query the ZSTDMT_CCtx for a parameter value.
+ * @return : 0, or an error code (which can be tested using ZSTD_isError()) */
+ZSTDLIB_API size_t ZSTDMT_getMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSTDMT_parameter parameter, int* value);
+
+
+/*! ZSTDMT_compressStream_generic() :
+ * Combines ZSTDMT_compressStream() with optional ZSTDMT_flushStream() or ZSTDMT_endStream()
+ * depending on flush directive.
+ * @return : minimum amount of data still to be flushed
+ * 0 if fully flushed
+ * or an error code
+ * note : needs to be init using any ZSTD_initCStream*() variant */
+ZSTDLIB_API size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective endOp);
+
+
+/* ========================================================
+ * === Private interface, for use by ZSTD_compress.c ===
+ * === Not exposed in libzstd. Never invoke directly ===
+ * ======================================================== */
+
+ /*! ZSTDMT_toFlushNow()
+ * Tell how many bytes are ready to be flushed immediately.
+ * Probe the oldest active job (not yet entirely flushed) and check its output buffer.
+ * If return 0, it means there is no active job,
+ * or, it means oldest job is still active, but everything produced has been flushed so far,
+ * therefore flushing is limited by speed of oldest job. */
+size_t ZSTDMT_toFlushNow(ZSTDMT_CCtx* mtctx);
+
+/*! ZSTDMT_CCtxParam_setMTCtxParameter()
+ * like ZSTDMT_setMTCtxParameter(), but into a ZSTD_CCtx_Params */
+size_t ZSTDMT_CCtxParam_setMTCtxParameter(ZSTD_CCtx_params* params, ZSTDMT_parameter parameter, int value);
+
+/*! ZSTDMT_CCtxParam_setNbWorkers()
+ * Set nbWorkers, and clamp it.
+ * Also reset jobSize and overlapLog */
+size_t ZSTDMT_CCtxParam_setNbWorkers(ZSTD_CCtx_params* params, unsigned nbWorkers);
+
+/*! ZSTDMT_updateCParams_whileCompressing() :
+ * Updates only a selected set of compression parameters, to remain compatible with current frame.
+ * New parameters will be applied to next compression job. */
+void ZSTDMT_updateCParams_whileCompressing(ZSTDMT_CCtx* mtctx, const ZSTD_CCtx_params* cctxParams);
+
+/*! ZSTDMT_getFrameProgression():
+ * tells how much data has been consumed (input) and produced (output) for current frame.
+ * able to count progression inside worker threads.
+ */
+ZSTD_frameProgression ZSTDMT_getFrameProgression(ZSTDMT_CCtx* mtctx);
+
+
+/*! ZSTDMT_initCStream_internal() :
+ * Private use only. Init streaming operation.
+ * expects params to be valid.
+ * must receive dict, or cdict, or none, but not both.
+ * @return : 0, or an error code */
+size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs,
+ const void* dict, size_t dictSize, ZSTD_dictContentType_e dictContentType,
+ const ZSTD_CDict* cdict,
+ ZSTD_CCtx_params params, unsigned long long pledgedSrcSize);
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* ZSTDMT_COMPRESS_H */
diff --git a/Utilities/cmzstd/lib/decompress/huf_decompress.c b/Utilities/cmzstd/lib/decompress/huf_decompress.c
new file mode 100644
index 000000000..3f8bd2973
--- /dev/null
+++ b/Utilities/cmzstd/lib/decompress/huf_decompress.c
@@ -0,0 +1,1232 @@
+/* ******************************************************************
+ huff0 huffman decoder,
+ part of Finite State Entropy library
+ Copyright (C) 2013-present, Yann Collet.
+
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ You can contact the author at :
+ - FSE+HUF source repository : https://github.com/Cyan4973/FiniteStateEntropy
+****************************************************************** */
+
+/* **************************************************************
+* Dependencies
+****************************************************************/
+#include <string.h> /* memcpy, memset */
+#include "compiler.h"
+#include "bitstream.h" /* BIT_* */
+#include "fse.h" /* to compress headers */
+#define HUF_STATIC_LINKING_ONLY
+#include "huf.h"
+#include "error_private.h"
+
+/* **************************************************************
+* Macros
+****************************************************************/
+
+/* These two optional macros force the use one way or another of the two
+ * Huffman decompression implementations. You can't force in both directions
+ * at the same time.
+ */
+#if defined(HUF_FORCE_DECOMPRESS_X1) && \
+ defined(HUF_FORCE_DECOMPRESS_X2)
+#error "Cannot force the use of the X1 and X2 decoders at the same time!"
+#endif
+
+
+/* **************************************************************
+* Error Management
+****************************************************************/
+#define HUF_isError ERR_isError
+#define CHECK_F(f) { size_t const err_ = (f); if (HUF_isError(err_)) return err_; }
+
+
+/* **************************************************************
+* Byte alignment for workSpace management
+****************************************************************/
+#define HUF_ALIGN(x, a) HUF_ALIGN_MASK((x), (a) - 1)
+#define HUF_ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
+
+
+/* **************************************************************
+* BMI2 Variant Wrappers
+****************************************************************/
+#if DYNAMIC_BMI2
+
+#define HUF_DGEN(fn) \
+ \
+ static size_t fn##_default( \
+ void* dst, size_t dstSize, \
+ const void* cSrc, size_t cSrcSize, \
+ const HUF_DTable* DTable) \
+ { \
+ return fn##_body(dst, dstSize, cSrc, cSrcSize, DTable); \
+ } \
+ \
+ static TARGET_ATTRIBUTE("bmi2") size_t fn##_bmi2( \
+ void* dst, size_t dstSize, \
+ const void* cSrc, size_t cSrcSize, \
+ const HUF_DTable* DTable) \
+ { \
+ return fn##_body(dst, dstSize, cSrc, cSrcSize, DTable); \
+ } \
+ \
+ static size_t fn(void* dst, size_t dstSize, void const* cSrc, \
+ size_t cSrcSize, HUF_DTable const* DTable, int bmi2) \
+ { \
+ if (bmi2) { \
+ return fn##_bmi2(dst, dstSize, cSrc, cSrcSize, DTable); \
+ } \
+ return fn##_default(dst, dstSize, cSrc, cSrcSize, DTable); \
+ }
+
+#else
+
+#define HUF_DGEN(fn) \
+ static size_t fn(void* dst, size_t dstSize, void const* cSrc, \
+ size_t cSrcSize, HUF_DTable const* DTable, int bmi2) \
+ { \
+ (void)bmi2; \
+ return fn##_body(dst, dstSize, cSrc, cSrcSize, DTable); \
+ }
+
+#endif
+
+
+/*-***************************/
+/* generic DTableDesc */
+/*-***************************/
+typedef struct { BYTE maxTableLog; BYTE tableType; BYTE tableLog; BYTE reserved; } DTableDesc;
+
+static DTableDesc HUF_getDTableDesc(const HUF_DTable* table)
+{
+ DTableDesc dtd;
+ memcpy(&dtd, table, sizeof(dtd));
+ return dtd;
+}
+
+
+#ifndef HUF_FORCE_DECOMPRESS_X2
+
+/*-***************************/
+/* single-symbol decoding */
+/*-***************************/
+typedef struct { BYTE byte; BYTE nbBits; } HUF_DEltX1; /* single-symbol decoding */
+
+size_t HUF_readDTableX1_wksp(HUF_DTable* DTable, const void* src, size_t srcSize, void* workSpace, size_t wkspSize)
+{
+ U32 tableLog = 0;
+ U32 nbSymbols = 0;
+ size_t iSize;
+ void* const dtPtr = DTable + 1;
+ HUF_DEltX1* const dt = (HUF_DEltX1*)dtPtr;
+
+ U32* rankVal;
+ BYTE* huffWeight;
+ size_t spaceUsed32 = 0;
+
+ rankVal = (U32 *)workSpace + spaceUsed32;
+ spaceUsed32 += HUF_TABLELOG_ABSOLUTEMAX + 1;
+ huffWeight = (BYTE *)((U32 *)workSpace + spaceUsed32);
+ spaceUsed32 += HUF_ALIGN(HUF_SYMBOLVALUE_MAX + 1, sizeof(U32)) >> 2;
+
+ if ((spaceUsed32 << 2) > wkspSize) return ERROR(tableLog_tooLarge);
+
+ DEBUG_STATIC_ASSERT(sizeof(DTableDesc) == sizeof(HUF_DTable));
+ /* memset(huffWeight, 0, sizeof(huffWeight)); */ /* is not necessary, even though some analyzer complain ... */
+
+ iSize = HUF_readStats(huffWeight, HUF_SYMBOLVALUE_MAX + 1, rankVal, &nbSymbols, &tableLog, src, srcSize);
+ if (HUF_isError(iSize)) return iSize;
+
+ /* Table header */
+ { DTableDesc dtd = HUF_getDTableDesc(DTable);
+ if (tableLog > (U32)(dtd.maxTableLog+1)) return ERROR(tableLog_tooLarge); /* DTable too small, Huffman tree cannot fit in */
+ dtd.tableType = 0;
+ dtd.tableLog = (BYTE)tableLog;
+ memcpy(DTable, &dtd, sizeof(dtd));
+ }
+
+ /* Calculate starting value for each rank */
+ { U32 n, nextRankStart = 0;
+ for (n=1; n<tableLog+1; n++) {
+ U32 const current = nextRankStart;
+ nextRankStart += (rankVal[n] << (n-1));
+ rankVal[n] = current;
+ } }
+
+ /* fill DTable */
+ { U32 n;
+ for (n=0; n<nbSymbols; n++) {
+ U32 const w = huffWeight[n];
+ U32 const length = (1 << w) >> 1;
+ U32 u;
+ HUF_DEltX1 D;
+ D.byte = (BYTE)n; D.nbBits = (BYTE)(tableLog + 1 - w);
+ for (u = rankVal[w]; u < rankVal[w] + length; u++)
+ dt[u] = D;
+ rankVal[w] += length;
+ } }
+
+ return iSize;
+}
+
+size_t HUF_readDTableX1(HUF_DTable* DTable, const void* src, size_t srcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_readDTableX1_wksp(DTable, src, srcSize,
+ workSpace, sizeof(workSpace));
+}
+
+FORCE_INLINE_TEMPLATE BYTE
+HUF_decodeSymbolX1(BIT_DStream_t* Dstream, const HUF_DEltX1* dt, const U32 dtLog)
+{
+ size_t const val = BIT_lookBitsFast(Dstream, dtLog); /* note : dtLog >= 1 */
+ BYTE const c = dt[val].byte;
+ BIT_skipBits(Dstream, dt[val].nbBits);
+ return c;
+}
+
+#define HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr) \
+ *ptr++ = HUF_decodeSymbolX1(DStreamPtr, dt, dtLog)
+
+#define HUF_DECODE_SYMBOLX1_1(ptr, DStreamPtr) \
+ if (MEM_64bits() || (HUF_TABLELOG_MAX<=12)) \
+ HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr)
+
+#define HUF_DECODE_SYMBOLX1_2(ptr, DStreamPtr) \
+ if (MEM_64bits()) \
+ HUF_DECODE_SYMBOLX1_0(ptr, DStreamPtr)
+
+HINT_INLINE size_t
+HUF_decodeStreamX1(BYTE* p, BIT_DStream_t* const bitDPtr, BYTE* const pEnd, const HUF_DEltX1* const dt, const U32 dtLog)
+{
+ BYTE* const pStart = p;
+
+ /* up to 4 symbols at a time */
+ while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) & (p < pEnd-3)) {
+ HUF_DECODE_SYMBOLX1_2(p, bitDPtr);
+ HUF_DECODE_SYMBOLX1_1(p, bitDPtr);
+ HUF_DECODE_SYMBOLX1_2(p, bitDPtr);
+ HUF_DECODE_SYMBOLX1_0(p, bitDPtr);
+ }
+
+ /* [0-3] symbols remaining */
+ if (MEM_32bits())
+ while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) & (p < pEnd))
+ HUF_DECODE_SYMBOLX1_0(p, bitDPtr);
+
+ /* no more data to retrieve from bitstream, no need to reload */
+ while (p < pEnd)
+ HUF_DECODE_SYMBOLX1_0(p, bitDPtr);
+
+ return pEnd-pStart;
+}
+
+FORCE_INLINE_TEMPLATE size_t
+HUF_decompress1X1_usingDTable_internal_body(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ BYTE* op = (BYTE*)dst;
+ BYTE* const oend = op + dstSize;
+ const void* dtPtr = DTable + 1;
+ const HUF_DEltX1* const dt = (const HUF_DEltX1*)dtPtr;
+ BIT_DStream_t bitD;
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+ U32 const dtLog = dtd.tableLog;
+
+ CHECK_F( BIT_initDStream(&bitD, cSrc, cSrcSize) );
+
+ HUF_decodeStreamX1(op, &bitD, oend, dt, dtLog);
+
+ if (!BIT_endOfDStream(&bitD)) return ERROR(corruption_detected);
+
+ return dstSize;
+}
+
+FORCE_INLINE_TEMPLATE size_t
+HUF_decompress4X1_usingDTable_internal_body(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ /* Check */
+ if (cSrcSize < 10) return ERROR(corruption_detected); /* strict minimum : jump table + 1 byte per stream */
+
+ { const BYTE* const istart = (const BYTE*) cSrc;
+ BYTE* const ostart = (BYTE*) dst;
+ BYTE* const oend = ostart + dstSize;
+ const void* const dtPtr = DTable + 1;
+ const HUF_DEltX1* const dt = (const HUF_DEltX1*)dtPtr;
+
+ /* Init */
+ BIT_DStream_t bitD1;
+ BIT_DStream_t bitD2;
+ BIT_DStream_t bitD3;
+ BIT_DStream_t bitD4;
+ size_t const length1 = MEM_readLE16(istart);
+ size_t const length2 = MEM_readLE16(istart+2);
+ size_t const length3 = MEM_readLE16(istart+4);
+ size_t const length4 = cSrcSize - (length1 + length2 + length3 + 6);
+ const BYTE* const istart1 = istart + 6; /* jumpTable */
+ const BYTE* const istart2 = istart1 + length1;
+ const BYTE* const istart3 = istart2 + length2;
+ const BYTE* const istart4 = istart3 + length3;
+ const size_t segmentSize = (dstSize+3) / 4;
+ BYTE* const opStart2 = ostart + segmentSize;
+ BYTE* const opStart3 = opStart2 + segmentSize;
+ BYTE* const opStart4 = opStart3 + segmentSize;
+ BYTE* op1 = ostart;
+ BYTE* op2 = opStart2;
+ BYTE* op3 = opStart3;
+ BYTE* op4 = opStart4;
+ U32 endSignal = BIT_DStream_unfinished;
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+ U32 const dtLog = dtd.tableLog;
+
+ if (length4 > cSrcSize) return ERROR(corruption_detected); /* overflow */
+ CHECK_F( BIT_initDStream(&bitD1, istart1, length1) );
+ CHECK_F( BIT_initDStream(&bitD2, istart2, length2) );
+ CHECK_F( BIT_initDStream(&bitD3, istart3, length3) );
+ CHECK_F( BIT_initDStream(&bitD4, istart4, length4) );
+
+ /* up to 16 symbols per loop (4 symbols per stream) in 64-bit mode */
+ endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4);
+ while ( (endSignal==BIT_DStream_unfinished) && (op4<(oend-3)) ) {
+ HUF_DECODE_SYMBOLX1_2(op1, &bitD1);
+ HUF_DECODE_SYMBOLX1_2(op2, &bitD2);
+ HUF_DECODE_SYMBOLX1_2(op3, &bitD3);
+ HUF_DECODE_SYMBOLX1_2(op4, &bitD4);
+ HUF_DECODE_SYMBOLX1_1(op1, &bitD1);
+ HUF_DECODE_SYMBOLX1_1(op2, &bitD2);
+ HUF_DECODE_SYMBOLX1_1(op3, &bitD3);
+ HUF_DECODE_SYMBOLX1_1(op4, &bitD4);
+ HUF_DECODE_SYMBOLX1_2(op1, &bitD1);
+ HUF_DECODE_SYMBOLX1_2(op2, &bitD2);
+ HUF_DECODE_SYMBOLX1_2(op3, &bitD3);
+ HUF_DECODE_SYMBOLX1_2(op4, &bitD4);
+ HUF_DECODE_SYMBOLX1_0(op1, &bitD1);
+ HUF_DECODE_SYMBOLX1_0(op2, &bitD2);
+ HUF_DECODE_SYMBOLX1_0(op3, &bitD3);
+ HUF_DECODE_SYMBOLX1_0(op4, &bitD4);
+ BIT_reloadDStream(&bitD1);
+ BIT_reloadDStream(&bitD2);
+ BIT_reloadDStream(&bitD3);
+ BIT_reloadDStream(&bitD4);
+ }
+
+ /* check corruption */
+ /* note : should not be necessary : op# advance in lock step, and we control op4.
+ * but curiously, binary generated by gcc 7.2 & 7.3 with -mbmi2 runs faster when >=1 test is present */
+ if (op1 > opStart2) return ERROR(corruption_detected);
+ if (op2 > opStart3) return ERROR(corruption_detected);
+ if (op3 > opStart4) return ERROR(corruption_detected);
+ /* note : op4 supposed already verified within main loop */
+
+ /* finish bitStreams one by one */
+ HUF_decodeStreamX1(op1, &bitD1, opStart2, dt, dtLog);
+ HUF_decodeStreamX1(op2, &bitD2, opStart3, dt, dtLog);
+ HUF_decodeStreamX1(op3, &bitD3, opStart4, dt, dtLog);
+ HUF_decodeStreamX1(op4, &bitD4, oend, dt, dtLog);
+
+ /* check */
+ { U32 const endCheck = BIT_endOfDStream(&bitD1) & BIT_endOfDStream(&bitD2) & BIT_endOfDStream(&bitD3) & BIT_endOfDStream(&bitD4);
+ if (!endCheck) return ERROR(corruption_detected); }
+
+ /* decoded size */
+ return dstSize;
+ }
+}
+
+
+typedef size_t (*HUF_decompress_usingDTable_t)(void *dst, size_t dstSize,
+ const void *cSrc,
+ size_t cSrcSize,
+ const HUF_DTable *DTable);
+
+HUF_DGEN(HUF_decompress1X1_usingDTable_internal)
+HUF_DGEN(HUF_decompress4X1_usingDTable_internal)
+
+
+
+size_t HUF_decompress1X1_usingDTable(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ DTableDesc dtd = HUF_getDTableDesc(DTable);
+ if (dtd.tableType != 0) return ERROR(GENERIC);
+ return HUF_decompress1X1_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+}
+
+size_t HUF_decompress1X1_DCtx_wksp(HUF_DTable* DCtx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
+{
+ const BYTE* ip = (const BYTE*) cSrc;
+
+ size_t const hSize = HUF_readDTableX1_wksp(DCtx, cSrc, cSrcSize, workSpace, wkspSize);
+ if (HUF_isError(hSize)) return hSize;
+ if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
+ ip += hSize; cSrcSize -= hSize;
+
+ return HUF_decompress1X1_usingDTable_internal(dst, dstSize, ip, cSrcSize, DCtx, /* bmi2 */ 0);
+}
+
+
+size_t HUF_decompress1X1_DCtx(HUF_DTable* DCtx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress1X1_DCtx_wksp(DCtx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
+size_t HUF_decompress1X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ HUF_CREATE_STATIC_DTABLEX1(DTable, HUF_TABLELOG_MAX);
+ return HUF_decompress1X1_DCtx (DTable, dst, dstSize, cSrc, cSrcSize);
+}
+
+size_t HUF_decompress4X1_usingDTable(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ DTableDesc dtd = HUF_getDTableDesc(DTable);
+ if (dtd.tableType != 0) return ERROR(GENERIC);
+ return HUF_decompress4X1_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+}
+
+static size_t HUF_decompress4X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize, int bmi2)
+{
+ const BYTE* ip = (const BYTE*) cSrc;
+
+ size_t const hSize = HUF_readDTableX1_wksp (dctx, cSrc, cSrcSize,
+ workSpace, wkspSize);
+ if (HUF_isError(hSize)) return hSize;
+ if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
+ ip += hSize; cSrcSize -= hSize;
+
+ return HUF_decompress4X1_usingDTable_internal(dst, dstSize, ip, cSrcSize, dctx, bmi2);
+}
+
+size_t HUF_decompress4X1_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
+{
+ return HUF_decompress4X1_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, 0);
+}
+
+
+size_t HUF_decompress4X1_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress4X1_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+size_t HUF_decompress4X1 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ HUF_CREATE_STATIC_DTABLEX1(DTable, HUF_TABLELOG_MAX);
+ return HUF_decompress4X1_DCtx(DTable, dst, dstSize, cSrc, cSrcSize);
+}
+
+#endif /* HUF_FORCE_DECOMPRESS_X2 */
+
+
+#ifndef HUF_FORCE_DECOMPRESS_X1
+
+/* *************************/
+/* double-symbols decoding */
+/* *************************/
+
+typedef struct { U16 sequence; BYTE nbBits; BYTE length; } HUF_DEltX2; /* double-symbols decoding */
+typedef struct { BYTE symbol; BYTE weight; } sortedSymbol_t;
+typedef U32 rankValCol_t[HUF_TABLELOG_MAX + 1];
+typedef rankValCol_t rankVal_t[HUF_TABLELOG_MAX];
+
+
+/* HUF_fillDTableX2Level2() :
+ * `rankValOrigin` must be a table of at least (HUF_TABLELOG_MAX + 1) U32 */
+static void HUF_fillDTableX2Level2(HUF_DEltX2* DTable, U32 sizeLog, const U32 consumed,
+ const U32* rankValOrigin, const int minWeight,
+ const sortedSymbol_t* sortedSymbols, const U32 sortedListSize,
+ U32 nbBitsBaseline, U16 baseSeq)
+{
+ HUF_DEltX2 DElt;
+ U32 rankVal[HUF_TABLELOG_MAX + 1];
+
+ /* get pre-calculated rankVal */
+ memcpy(rankVal, rankValOrigin, sizeof(rankVal));
+
+ /* fill skipped values */
+ if (minWeight>1) {
+ U32 i, skipSize = rankVal[minWeight];
+ MEM_writeLE16(&(DElt.sequence), baseSeq);
+ DElt.nbBits = (BYTE)(consumed);
+ DElt.length = 1;
+ for (i = 0; i < skipSize; i++)
+ DTable[i] = DElt;
+ }
+
+ /* fill DTable */
+ { U32 s; for (s=0; s<sortedListSize; s++) { /* note : sortedSymbols already skipped */
+ const U32 symbol = sortedSymbols[s].symbol;
+ const U32 weight = sortedSymbols[s].weight;
+ const U32 nbBits = nbBitsBaseline - weight;
+ const U32 length = 1 << (sizeLog-nbBits);
+ const U32 start = rankVal[weight];
+ U32 i = start;
+ const U32 end = start + length;
+
+ MEM_writeLE16(&(DElt.sequence), (U16)(baseSeq + (symbol << 8)));
+ DElt.nbBits = (BYTE)(nbBits + consumed);
+ DElt.length = 2;
+ do { DTable[i++] = DElt; } while (i<end); /* since length >= 1 */
+
+ rankVal[weight] += length;
+ } }
+}
+
+
+static void HUF_fillDTableX2(HUF_DEltX2* DTable, const U32 targetLog,
+ const sortedSymbol_t* sortedList, const U32 sortedListSize,
+ const U32* rankStart, rankVal_t rankValOrigin, const U32 maxWeight,
+ const U32 nbBitsBaseline)
+{
+ U32 rankVal[HUF_TABLELOG_MAX + 1];
+ const int scaleLog = nbBitsBaseline - targetLog; /* note : targetLog >= srcLog, hence scaleLog <= 1 */
+ const U32 minBits = nbBitsBaseline - maxWeight;
+ U32 s;
+
+ memcpy(rankVal, rankValOrigin, sizeof(rankVal));
+
+ /* fill DTable */
+ for (s=0; s<sortedListSize; s++) {
+ const U16 symbol = sortedList[s].symbol;
+ const U32 weight = sortedList[s].weight;
+ const U32 nbBits = nbBitsBaseline - weight;
+ const U32 start = rankVal[weight];
+ const U32 length = 1 << (targetLog-nbBits);
+
+ if (targetLog-nbBits >= minBits) { /* enough room for a second symbol */
+ U32 sortedRank;
+ int minWeight = nbBits + scaleLog;
+ if (minWeight < 1) minWeight = 1;
+ sortedRank = rankStart[minWeight];
+ HUF_fillDTableX2Level2(DTable+start, targetLog-nbBits, nbBits,
+ rankValOrigin[nbBits], minWeight,
+ sortedList+sortedRank, sortedListSize-sortedRank,
+ nbBitsBaseline, symbol);
+ } else {
+ HUF_DEltX2 DElt;
+ MEM_writeLE16(&(DElt.sequence), symbol);
+ DElt.nbBits = (BYTE)(nbBits);
+ DElt.length = 1;
+ { U32 const end = start + length;
+ U32 u;
+ for (u = start; u < end; u++) DTable[u] = DElt;
+ } }
+ rankVal[weight] += length;
+ }
+}
+
+size_t HUF_readDTableX2_wksp(HUF_DTable* DTable,
+ const void* src, size_t srcSize,
+ void* workSpace, size_t wkspSize)
+{
+ U32 tableLog, maxW, sizeOfSort, nbSymbols;
+ DTableDesc dtd = HUF_getDTableDesc(DTable);
+ U32 const maxTableLog = dtd.maxTableLog;
+ size_t iSize;
+ void* dtPtr = DTable+1; /* force compiler to avoid strict-aliasing */
+ HUF_DEltX2* const dt = (HUF_DEltX2*)dtPtr;
+ U32 *rankStart;
+
+ rankValCol_t* rankVal;
+ U32* rankStats;
+ U32* rankStart0;
+ sortedSymbol_t* sortedSymbol;
+ BYTE* weightList;
+ size_t spaceUsed32 = 0;
+
+ rankVal = (rankValCol_t *)((U32 *)workSpace + spaceUsed32);
+ spaceUsed32 += (sizeof(rankValCol_t) * HUF_TABLELOG_MAX) >> 2;
+ rankStats = (U32 *)workSpace + spaceUsed32;
+ spaceUsed32 += HUF_TABLELOG_MAX + 1;
+ rankStart0 = (U32 *)workSpace + spaceUsed32;
+ spaceUsed32 += HUF_TABLELOG_MAX + 2;
+ sortedSymbol = (sortedSymbol_t *)workSpace + (spaceUsed32 * sizeof(U32)) / sizeof(sortedSymbol_t);
+ spaceUsed32 += HUF_ALIGN(sizeof(sortedSymbol_t) * (HUF_SYMBOLVALUE_MAX + 1), sizeof(U32)) >> 2;
+ weightList = (BYTE *)((U32 *)workSpace + spaceUsed32);
+ spaceUsed32 += HUF_ALIGN(HUF_SYMBOLVALUE_MAX + 1, sizeof(U32)) >> 2;
+
+ if ((spaceUsed32 << 2) > wkspSize) return ERROR(tableLog_tooLarge);
+
+ rankStart = rankStart0 + 1;
+ memset(rankStats, 0, sizeof(U32) * (2 * HUF_TABLELOG_MAX + 2 + 1));
+
+ DEBUG_STATIC_ASSERT(sizeof(HUF_DEltX2) == sizeof(HUF_DTable)); /* if compiler fails here, assertion is wrong */
+ if (maxTableLog > HUF_TABLELOG_MAX) return ERROR(tableLog_tooLarge);
+ /* memset(weightList, 0, sizeof(weightList)); */ /* is not necessary, even though some analyzer complain ... */
+
+ iSize = HUF_readStats(weightList, HUF_SYMBOLVALUE_MAX + 1, rankStats, &nbSymbols, &tableLog, src, srcSize);
+ if (HUF_isError(iSize)) return iSize;
+
+ /* check result */
+ if (tableLog > maxTableLog) return ERROR(tableLog_tooLarge); /* DTable can't fit code depth */
+
+ /* find maxWeight */
+ for (maxW = tableLog; rankStats[maxW]==0; maxW--) {} /* necessarily finds a solution before 0 */
+
+ /* Get start index of each weight */
+ { U32 w, nextRankStart = 0;
+ for (w=1; w<maxW+1; w++) {
+ U32 current = nextRankStart;
+ nextRankStart += rankStats[w];
+ rankStart[w] = current;
+ }
+ rankStart[0] = nextRankStart; /* put all 0w symbols at the end of sorted list*/
+ sizeOfSort = nextRankStart;
+ }
+
+ /* sort symbols by weight */
+ { U32 s;
+ for (s=0; s<nbSymbols; s++) {
+ U32 const w = weightList[s];
+ U32 const r = rankStart[w]++;
+ sortedSymbol[r].symbol = (BYTE)s;
+ sortedSymbol[r].weight = (BYTE)w;
+ }
+ rankStart[0] = 0; /* forget 0w symbols; this is beginning of weight(1) */
+ }
+
+ /* Build rankVal */
+ { U32* const rankVal0 = rankVal[0];
+ { int const rescale = (maxTableLog-tableLog) - 1; /* tableLog <= maxTableLog */
+ U32 nextRankVal = 0;
+ U32 w;
+ for (w=1; w<maxW+1; w++) {
+ U32 current = nextRankVal;
+ nextRankVal += rankStats[w] << (w+rescale);
+ rankVal0[w] = current;
+ } }
+ { U32 const minBits = tableLog+1 - maxW;
+ U32 consumed;
+ for (consumed = minBits; consumed < maxTableLog - minBits + 1; consumed++) {
+ U32* const rankValPtr = rankVal[consumed];
+ U32 w;
+ for (w = 1; w < maxW+1; w++) {
+ rankValPtr[w] = rankVal0[w] >> consumed;
+ } } } }
+
+ HUF_fillDTableX2(dt, maxTableLog,
+ sortedSymbol, sizeOfSort,
+ rankStart0, rankVal, maxW,
+ tableLog+1);
+
+ dtd.tableLog = (BYTE)maxTableLog;
+ dtd.tableType = 1;
+ memcpy(DTable, &dtd, sizeof(dtd));
+ return iSize;
+}
+
+size_t HUF_readDTableX2(HUF_DTable* DTable, const void* src, size_t srcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_readDTableX2_wksp(DTable, src, srcSize,
+ workSpace, sizeof(workSpace));
+}
+
+
+FORCE_INLINE_TEMPLATE U32
+HUF_decodeSymbolX2(void* op, BIT_DStream_t* DStream, const HUF_DEltX2* dt, const U32 dtLog)
+{
+ size_t const val = BIT_lookBitsFast(DStream, dtLog); /* note : dtLog >= 1 */
+ memcpy(op, dt+val, 2);
+ BIT_skipBits(DStream, dt[val].nbBits);
+ return dt[val].length;
+}
+
+FORCE_INLINE_TEMPLATE U32
+HUF_decodeLastSymbolX2(void* op, BIT_DStream_t* DStream, const HUF_DEltX2* dt, const U32 dtLog)
+{
+ size_t const val = BIT_lookBitsFast(DStream, dtLog); /* note : dtLog >= 1 */
+ memcpy(op, dt+val, 1);
+ if (dt[val].length==1) BIT_skipBits(DStream, dt[val].nbBits);
+ else {
+ if (DStream->bitsConsumed < (sizeof(DStream->bitContainer)*8)) {
+ BIT_skipBits(DStream, dt[val].nbBits);
+ if (DStream->bitsConsumed > (sizeof(DStream->bitContainer)*8))
+ /* ugly hack; works only because it's the last symbol. Note : can't easily extract nbBits from just this symbol */
+ DStream->bitsConsumed = (sizeof(DStream->bitContainer)*8);
+ } }
+ return 1;
+}
+
+#define HUF_DECODE_SYMBOLX2_0(ptr, DStreamPtr) \
+ ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog)
+
+#define HUF_DECODE_SYMBOLX2_1(ptr, DStreamPtr) \
+ if (MEM_64bits() || (HUF_TABLELOG_MAX<=12)) \
+ ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog)
+
+#define HUF_DECODE_SYMBOLX2_2(ptr, DStreamPtr) \
+ if (MEM_64bits()) \
+ ptr += HUF_decodeSymbolX2(ptr, DStreamPtr, dt, dtLog)
+
+HINT_INLINE size_t
+HUF_decodeStreamX2(BYTE* p, BIT_DStream_t* bitDPtr, BYTE* const pEnd,
+ const HUF_DEltX2* const dt, const U32 dtLog)
+{
+ BYTE* const pStart = p;
+
+ /* up to 8 symbols at a time */
+ while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) & (p < pEnd-(sizeof(bitDPtr->bitContainer)-1))) {
+ HUF_DECODE_SYMBOLX2_2(p, bitDPtr);
+ HUF_DECODE_SYMBOLX2_1(p, bitDPtr);
+ HUF_DECODE_SYMBOLX2_2(p, bitDPtr);
+ HUF_DECODE_SYMBOLX2_0(p, bitDPtr);
+ }
+
+ /* closer to end : up to 2 symbols at a time */
+ while ((BIT_reloadDStream(bitDPtr) == BIT_DStream_unfinished) & (p <= pEnd-2))
+ HUF_DECODE_SYMBOLX2_0(p, bitDPtr);
+
+ while (p <= pEnd-2)
+ HUF_DECODE_SYMBOLX2_0(p, bitDPtr); /* no need to reload : reached the end of DStream */
+
+ if (p < pEnd)
+ p += HUF_decodeLastSymbolX2(p, bitDPtr, dt, dtLog);
+
+ return p-pStart;
+}
+
+FORCE_INLINE_TEMPLATE size_t
+HUF_decompress1X2_usingDTable_internal_body(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ BIT_DStream_t bitD;
+
+ /* Init */
+ CHECK_F( BIT_initDStream(&bitD, cSrc, cSrcSize) );
+
+ /* decode */
+ { BYTE* const ostart = (BYTE*) dst;
+ BYTE* const oend = ostart + dstSize;
+ const void* const dtPtr = DTable+1; /* force compiler to not use strict-aliasing */
+ const HUF_DEltX2* const dt = (const HUF_DEltX2*)dtPtr;
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+ HUF_decodeStreamX2(ostart, &bitD, oend, dt, dtd.tableLog);
+ }
+
+ /* check */
+ if (!BIT_endOfDStream(&bitD)) return ERROR(corruption_detected);
+
+ /* decoded size */
+ return dstSize;
+}
+
+
+FORCE_INLINE_TEMPLATE size_t
+HUF_decompress4X2_usingDTable_internal_body(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ if (cSrcSize < 10) return ERROR(corruption_detected); /* strict minimum : jump table + 1 byte per stream */
+
+ { const BYTE* const istart = (const BYTE*) cSrc;
+ BYTE* const ostart = (BYTE*) dst;
+ BYTE* const oend = ostart + dstSize;
+ const void* const dtPtr = DTable+1;
+ const HUF_DEltX2* const dt = (const HUF_DEltX2*)dtPtr;
+
+ /* Init */
+ BIT_DStream_t bitD1;
+ BIT_DStream_t bitD2;
+ BIT_DStream_t bitD3;
+ BIT_DStream_t bitD4;
+ size_t const length1 = MEM_readLE16(istart);
+ size_t const length2 = MEM_readLE16(istart+2);
+ size_t const length3 = MEM_readLE16(istart+4);
+ size_t const length4 = cSrcSize - (length1 + length2 + length3 + 6);
+ const BYTE* const istart1 = istart + 6; /* jumpTable */
+ const BYTE* const istart2 = istart1 + length1;
+ const BYTE* const istart3 = istart2 + length2;
+ const BYTE* const istart4 = istart3 + length3;
+ size_t const segmentSize = (dstSize+3) / 4;
+ BYTE* const opStart2 = ostart + segmentSize;
+ BYTE* const opStart3 = opStart2 + segmentSize;
+ BYTE* const opStart4 = opStart3 + segmentSize;
+ BYTE* op1 = ostart;
+ BYTE* op2 = opStart2;
+ BYTE* op3 = opStart3;
+ BYTE* op4 = opStart4;
+ U32 endSignal;
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+ U32 const dtLog = dtd.tableLog;
+
+ if (length4 > cSrcSize) return ERROR(corruption_detected); /* overflow */
+ CHECK_F( BIT_initDStream(&bitD1, istart1, length1) );
+ CHECK_F( BIT_initDStream(&bitD2, istart2, length2) );
+ CHECK_F( BIT_initDStream(&bitD3, istart3, length3) );
+ CHECK_F( BIT_initDStream(&bitD4, istart4, length4) );
+
+ /* 16-32 symbols per loop (4-8 symbols per stream) */
+ endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4);
+ for ( ; (endSignal==BIT_DStream_unfinished) & (op4<(oend-(sizeof(bitD4.bitContainer)-1))) ; ) {
+ HUF_DECODE_SYMBOLX2_2(op1, &bitD1);
+ HUF_DECODE_SYMBOLX2_2(op2, &bitD2);
+ HUF_DECODE_SYMBOLX2_2(op3, &bitD3);
+ HUF_DECODE_SYMBOLX2_2(op4, &bitD4);
+ HUF_DECODE_SYMBOLX2_1(op1, &bitD1);
+ HUF_DECODE_SYMBOLX2_1(op2, &bitD2);
+ HUF_DECODE_SYMBOLX2_1(op3, &bitD3);
+ HUF_DECODE_SYMBOLX2_1(op4, &bitD4);
+ HUF_DECODE_SYMBOLX2_2(op1, &bitD1);
+ HUF_DECODE_SYMBOLX2_2(op2, &bitD2);
+ HUF_DECODE_SYMBOLX2_2(op3, &bitD3);
+ HUF_DECODE_SYMBOLX2_2(op4, &bitD4);
+ HUF_DECODE_SYMBOLX2_0(op1, &bitD1);
+ HUF_DECODE_SYMBOLX2_0(op2, &bitD2);
+ HUF_DECODE_SYMBOLX2_0(op3, &bitD3);
+ HUF_DECODE_SYMBOLX2_0(op4, &bitD4);
+
+ endSignal = BIT_reloadDStream(&bitD1) | BIT_reloadDStream(&bitD2) | BIT_reloadDStream(&bitD3) | BIT_reloadDStream(&bitD4);
+ }
+
+ /* check corruption */
+ if (op1 > opStart2) return ERROR(corruption_detected);
+ if (op2 > opStart3) return ERROR(corruption_detected);
+ if (op3 > opStart4) return ERROR(corruption_detected);
+ /* note : op4 already verified within main loop */
+
+ /* finish bitStreams one by one */
+ HUF_decodeStreamX2(op1, &bitD1, opStart2, dt, dtLog);
+ HUF_decodeStreamX2(op2, &bitD2, opStart3, dt, dtLog);
+ HUF_decodeStreamX2(op3, &bitD3, opStart4, dt, dtLog);
+ HUF_decodeStreamX2(op4, &bitD4, oend, dt, dtLog);
+
+ /* check */
+ { U32 const endCheck = BIT_endOfDStream(&bitD1) & BIT_endOfDStream(&bitD2) & BIT_endOfDStream(&bitD3) & BIT_endOfDStream(&bitD4);
+ if (!endCheck) return ERROR(corruption_detected); }
+
+ /* decoded size */
+ return dstSize;
+ }
+}
+
+HUF_DGEN(HUF_decompress1X2_usingDTable_internal)
+HUF_DGEN(HUF_decompress4X2_usingDTable_internal)
+
+size_t HUF_decompress1X2_usingDTable(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ DTableDesc dtd = HUF_getDTableDesc(DTable);
+ if (dtd.tableType != 1) return ERROR(GENERIC);
+ return HUF_decompress1X2_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+}
+
+size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable* DCtx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
+{
+ const BYTE* ip = (const BYTE*) cSrc;
+
+ size_t const hSize = HUF_readDTableX2_wksp(DCtx, cSrc, cSrcSize,
+ workSpace, wkspSize);
+ if (HUF_isError(hSize)) return hSize;
+ if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
+ ip += hSize; cSrcSize -= hSize;
+
+ return HUF_decompress1X2_usingDTable_internal(dst, dstSize, ip, cSrcSize, DCtx, /* bmi2 */ 0);
+}
+
+
+size_t HUF_decompress1X2_DCtx(HUF_DTable* DCtx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress1X2_DCtx_wksp(DCtx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
+size_t HUF_decompress1X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ HUF_CREATE_STATIC_DTABLEX2(DTable, HUF_TABLELOG_MAX);
+ return HUF_decompress1X2_DCtx(DTable, dst, dstSize, cSrc, cSrcSize);
+}
+
+size_t HUF_decompress4X2_usingDTable(
+ void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ DTableDesc dtd = HUF_getDTableDesc(DTable);
+ if (dtd.tableType != 1) return ERROR(GENERIC);
+ return HUF_decompress4X2_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+}
+
+static size_t HUF_decompress4X2_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize, int bmi2)
+{
+ const BYTE* ip = (const BYTE*) cSrc;
+
+ size_t hSize = HUF_readDTableX2_wksp(dctx, cSrc, cSrcSize,
+ workSpace, wkspSize);
+ if (HUF_isError(hSize)) return hSize;
+ if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
+ ip += hSize; cSrcSize -= hSize;
+
+ return HUF_decompress4X2_usingDTable_internal(dst, dstSize, ip, cSrcSize, dctx, bmi2);
+}
+
+size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
+{
+ return HUF_decompress4X2_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, /* bmi2 */ 0);
+}
+
+
+size_t HUF_decompress4X2_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
+size_t HUF_decompress4X2 (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ HUF_CREATE_STATIC_DTABLEX2(DTable, HUF_TABLELOG_MAX);
+ return HUF_decompress4X2_DCtx(DTable, dst, dstSize, cSrc, cSrcSize);
+}
+
+#endif /* HUF_FORCE_DECOMPRESS_X1 */
+
+
+/* ***********************************/
+/* Universal decompression selectors */
+/* ***********************************/
+
+size_t HUF_decompress1X_usingDTable(void* dst, size_t maxDstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+#if defined(HUF_FORCE_DECOMPRESS_X1)
+ (void)dtd;
+ assert(dtd.tableType == 0);
+ return HUF_decompress1X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+#elif defined(HUF_FORCE_DECOMPRESS_X2)
+ (void)dtd;
+ assert(dtd.tableType == 1);
+ return HUF_decompress1X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+#else
+ return dtd.tableType ? HUF_decompress1X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0) :
+ HUF_decompress1X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+#endif
+}
+
+size_t HUF_decompress4X_usingDTable(void* dst, size_t maxDstSize,
+ const void* cSrc, size_t cSrcSize,
+ const HUF_DTable* DTable)
+{
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+#if defined(HUF_FORCE_DECOMPRESS_X1)
+ (void)dtd;
+ assert(dtd.tableType == 0);
+ return HUF_decompress4X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+#elif defined(HUF_FORCE_DECOMPRESS_X2)
+ (void)dtd;
+ assert(dtd.tableType == 1);
+ return HUF_decompress4X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+#else
+ return dtd.tableType ? HUF_decompress4X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0) :
+ HUF_decompress4X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, /* bmi2 */ 0);
+#endif
+}
+
+
+#if !defined(HUF_FORCE_DECOMPRESS_X1) && !defined(HUF_FORCE_DECOMPRESS_X2)
+typedef struct { U32 tableTime; U32 decode256Time; } algo_time_t;
+static const algo_time_t algoTime[16 /* Quantization */][3 /* single, double, quad */] =
+{
+ /* single, double, quad */
+ {{0,0}, {1,1}, {2,2}}, /* Q==0 : impossible */
+ {{0,0}, {1,1}, {2,2}}, /* Q==1 : impossible */
+ {{ 38,130}, {1313, 74}, {2151, 38}}, /* Q == 2 : 12-18% */
+ {{ 448,128}, {1353, 74}, {2238, 41}}, /* Q == 3 : 18-25% */
+ {{ 556,128}, {1353, 74}, {2238, 47}}, /* Q == 4 : 25-32% */
+ {{ 714,128}, {1418, 74}, {2436, 53}}, /* Q == 5 : 32-38% */
+ {{ 883,128}, {1437, 74}, {2464, 61}}, /* Q == 6 : 38-44% */
+ {{ 897,128}, {1515, 75}, {2622, 68}}, /* Q == 7 : 44-50% */
+ {{ 926,128}, {1613, 75}, {2730, 75}}, /* Q == 8 : 50-56% */
+ {{ 947,128}, {1729, 77}, {3359, 77}}, /* Q == 9 : 56-62% */
+ {{1107,128}, {2083, 81}, {4006, 84}}, /* Q ==10 : 62-69% */
+ {{1177,128}, {2379, 87}, {4785, 88}}, /* Q ==11 : 69-75% */
+ {{1242,128}, {2415, 93}, {5155, 84}}, /* Q ==12 : 75-81% */
+ {{1349,128}, {2644,106}, {5260,106}}, /* Q ==13 : 81-87% */
+ {{1455,128}, {2422,124}, {4174,124}}, /* Q ==14 : 87-93% */
+ {{ 722,128}, {1891,145}, {1936,146}}, /* Q ==15 : 93-99% */
+};
+#endif
+
+/** HUF_selectDecoder() :
+ * Tells which decoder is likely to decode faster,
+ * based on a set of pre-computed metrics.
+ * @return : 0==HUF_decompress4X1, 1==HUF_decompress4X2 .
+ * Assumption : 0 < dstSize <= 128 KB */
+U32 HUF_selectDecoder (size_t dstSize, size_t cSrcSize)
+{
+ assert(dstSize > 0);
+ assert(dstSize <= 128*1024);
+#if defined(HUF_FORCE_DECOMPRESS_X1)
+ (void)dstSize;
+ (void)cSrcSize;
+ return 0;
+#elif defined(HUF_FORCE_DECOMPRESS_X2)
+ (void)dstSize;
+ (void)cSrcSize;
+ return 1;
+#else
+ /* decoder timing evaluation */
+ { U32 const Q = (cSrcSize >= dstSize) ? 15 : (U32)(cSrcSize * 16 / dstSize); /* Q < 16 */
+ U32 const D256 = (U32)(dstSize >> 8);
+ U32 const DTime0 = algoTime[Q][0].tableTime + (algoTime[Q][0].decode256Time * D256);
+ U32 DTime1 = algoTime[Q][1].tableTime + (algoTime[Q][1].decode256Time * D256);
+ DTime1 += DTime1 >> 3; /* advantage to algorithm using less memory, to reduce cache eviction */
+ return DTime1 < DTime0;
+ }
+#endif
+}
+
+
+typedef size_t (*decompressionAlgo)(void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize);
+
+size_t HUF_decompress (void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+#if !defined(HUF_FORCE_DECOMPRESS_X1) && !defined(HUF_FORCE_DECOMPRESS_X2)
+ static const decompressionAlgo decompress[2] = { HUF_decompress4X1, HUF_decompress4X2 };
+#endif
+
+ /* validation checks */
+ if (dstSize == 0) return ERROR(dstSize_tooSmall);
+ if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */
+ if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
+ if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
+
+ { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
+#if defined(HUF_FORCE_DECOMPRESS_X1)
+ (void)algoNb;
+ assert(algoNb == 0);
+ return HUF_decompress4X1(dst, dstSize, cSrc, cSrcSize);
+#elif defined(HUF_FORCE_DECOMPRESS_X2)
+ (void)algoNb;
+ assert(algoNb == 1);
+ return HUF_decompress4X2(dst, dstSize, cSrc, cSrcSize);
+#else
+ return decompress[algoNb](dst, dstSize, cSrc, cSrcSize);
+#endif
+ }
+}
+
+size_t HUF_decompress4X_DCtx (HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ /* validation checks */
+ if (dstSize == 0) return ERROR(dstSize_tooSmall);
+ if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */
+ if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
+ if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
+
+ { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
+#if defined(HUF_FORCE_DECOMPRESS_X1)
+ (void)algoNb;
+ assert(algoNb == 0);
+ return HUF_decompress4X1_DCtx(dctx, dst, dstSize, cSrc, cSrcSize);
+#elif defined(HUF_FORCE_DECOMPRESS_X2)
+ (void)algoNb;
+ assert(algoNb == 1);
+ return HUF_decompress4X2_DCtx(dctx, dst, dstSize, cSrc, cSrcSize);
+#else
+ return algoNb ? HUF_decompress4X2_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) :
+ HUF_decompress4X1_DCtx(dctx, dst, dstSize, cSrc, cSrcSize) ;
+#endif
+ }
+}
+
+size_t HUF_decompress4X_hufOnly(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress4X_hufOnly_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
+
+size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable* dctx, void* dst,
+ size_t dstSize, const void* cSrc,
+ size_t cSrcSize, void* workSpace,
+ size_t wkspSize)
+{
+ /* validation checks */
+ if (dstSize == 0) return ERROR(dstSize_tooSmall);
+ if (cSrcSize == 0) return ERROR(corruption_detected);
+
+ { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
+#if defined(HUF_FORCE_DECOMPRESS_X1)
+ (void)algoNb;
+ assert(algoNb == 0);
+ return HUF_decompress4X1_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize);
+#elif defined(HUF_FORCE_DECOMPRESS_X2)
+ (void)algoNb;
+ assert(algoNb == 1);
+ return HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize);
+#else
+ return algoNb ? HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc,
+ cSrcSize, workSpace, wkspSize):
+ HUF_decompress4X1_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize);
+#endif
+ }
+}
+
+size_t HUF_decompress1X_DCtx_wksp(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize,
+ void* workSpace, size_t wkspSize)
+{
+ /* validation checks */
+ if (dstSize == 0) return ERROR(dstSize_tooSmall);
+ if (cSrcSize > dstSize) return ERROR(corruption_detected); /* invalid */
+ if (cSrcSize == dstSize) { memcpy(dst, cSrc, dstSize); return dstSize; } /* not compressed */
+ if (cSrcSize == 1) { memset(dst, *(const BYTE*)cSrc, dstSize); return dstSize; } /* RLE */
+
+ { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
+#if defined(HUF_FORCE_DECOMPRESS_X1)
+ (void)algoNb;
+ assert(algoNb == 0);
+ return HUF_decompress1X1_DCtx_wksp(dctx, dst, dstSize, cSrc,
+ cSrcSize, workSpace, wkspSize);
+#elif defined(HUF_FORCE_DECOMPRESS_X2)
+ (void)algoNb;
+ assert(algoNb == 1);
+ return HUF_decompress1X2_DCtx_wksp(dctx, dst, dstSize, cSrc,
+ cSrcSize, workSpace, wkspSize);
+#else
+ return algoNb ? HUF_decompress1X2_DCtx_wksp(dctx, dst, dstSize, cSrc,
+ cSrcSize, workSpace, wkspSize):
+ HUF_decompress1X1_DCtx_wksp(dctx, dst, dstSize, cSrc,
+ cSrcSize, workSpace, wkspSize);
+#endif
+ }
+}
+
+size_t HUF_decompress1X_DCtx(HUF_DTable* dctx, void* dst, size_t dstSize,
+ const void* cSrc, size_t cSrcSize)
+{
+ U32 workSpace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32];
+ return HUF_decompress1X_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize,
+ workSpace, sizeof(workSpace));
+}
+
+
+size_t HUF_decompress1X_usingDTable_bmi2(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable, int bmi2)
+{
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+#if defined(HUF_FORCE_DECOMPRESS_X1)
+ (void)dtd;
+ assert(dtd.tableType == 0);
+ return HUF_decompress1X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2);
+#elif defined(HUF_FORCE_DECOMPRESS_X2)
+ (void)dtd;
+ assert(dtd.tableType == 1);
+ return HUF_decompress1X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2);
+#else
+ return dtd.tableType ? HUF_decompress1X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2) :
+ HUF_decompress1X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2);
+#endif
+}
+
+#ifndef HUF_FORCE_DECOMPRESS_X2
+size_t HUF_decompress1X1_DCtx_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2)
+{
+ const BYTE* ip = (const BYTE*) cSrc;
+
+ size_t const hSize = HUF_readDTableX1_wksp(dctx, cSrc, cSrcSize, workSpace, wkspSize);
+ if (HUF_isError(hSize)) return hSize;
+ if (hSize >= cSrcSize) return ERROR(srcSize_wrong);
+ ip += hSize; cSrcSize -= hSize;
+
+ return HUF_decompress1X1_usingDTable_internal(dst, dstSize, ip, cSrcSize, dctx, bmi2);
+}
+#endif
+
+size_t HUF_decompress4X_usingDTable_bmi2(void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const HUF_DTable* DTable, int bmi2)
+{
+ DTableDesc const dtd = HUF_getDTableDesc(DTable);
+#if defined(HUF_FORCE_DECOMPRESS_X1)
+ (void)dtd;
+ assert(dtd.tableType == 0);
+ return HUF_decompress4X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2);
+#elif defined(HUF_FORCE_DECOMPRESS_X2)
+ (void)dtd;
+ assert(dtd.tableType == 1);
+ return HUF_decompress4X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2);
+#else
+ return dtd.tableType ? HUF_decompress4X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2) :
+ HUF_decompress4X1_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable, bmi2);
+#endif
+}
+
+size_t HUF_decompress4X_hufOnly_wksp_bmi2(HUF_DTable* dctx, void* dst, size_t dstSize, const void* cSrc, size_t cSrcSize, void* workSpace, size_t wkspSize, int bmi2)
+{
+ /* validation checks */
+ if (dstSize == 0) return ERROR(dstSize_tooSmall);
+ if (cSrcSize == 0) return ERROR(corruption_detected);
+
+ { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize);
+#if defined(HUF_FORCE_DECOMPRESS_X1)
+ (void)algoNb;
+ assert(algoNb == 0);
+ return HUF_decompress4X1_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, bmi2);
+#elif defined(HUF_FORCE_DECOMPRESS_X2)
+ (void)algoNb;
+ assert(algoNb == 1);
+ return HUF_decompress4X2_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, bmi2);
+#else
+ return algoNb ? HUF_decompress4X2_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, bmi2) :
+ HUF_decompress4X1_DCtx_wksp_bmi2(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize, bmi2);
+#endif
+ }
+}
diff --git a/Utilities/cmzstd/lib/decompress/zstd_ddict.c b/Utilities/cmzstd/lib/decompress/zstd_ddict.c
new file mode 100644
index 000000000..2ad044068
--- /dev/null
+++ b/Utilities/cmzstd/lib/decompress/zstd_ddict.c
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+/* zstd_ddict.c :
+ * concentrates all logic that needs to know the internals of ZSTD_DDict object */
+
+/*-*******************************************************
+* Dependencies
+*********************************************************/
+#include <string.h> /* memcpy, memmove, memset */
+#include "cpu.h" /* bmi2 */
+#include "mem.h" /* low level memory routines */
+#define FSE_STATIC_LINKING_ONLY
+#include "fse.h"
+#define HUF_STATIC_LINKING_ONLY
+#include "huf.h"
+#include "zstd_decompress_internal.h"
+#include "zstd_ddict.h"
+
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
+# include "zstd_legacy.h"
+#endif
+
+
+
+/*-*******************************************************
+* Types
+*********************************************************/
+struct ZSTD_DDict_s {
+ void* dictBuffer;
+ const void* dictContent;
+ size_t dictSize;
+ ZSTD_entropyDTables_t entropy;
+ U32 dictID;
+ U32 entropyPresent;
+ ZSTD_customMem cMem;
+}; /* typedef'd to ZSTD_DDict within "zstd.h" */
+
+const void* ZSTD_DDict_dictContent(const ZSTD_DDict* ddict)
+{
+ assert(ddict != NULL);
+ return ddict->dictContent;
+}
+
+size_t ZSTD_DDict_dictSize(const ZSTD_DDict* ddict)
+{
+ assert(ddict != NULL);
+ return ddict->dictSize;
+}
+
+void ZSTD_copyDDictParameters(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict)
+{
+ DEBUGLOG(4, "ZSTD_copyDDictParameters");
+ assert(dctx != NULL);
+ assert(ddict != NULL);
+ dctx->dictID = ddict->dictID;
+ dctx->prefixStart = ddict->dictContent;
+ dctx->virtualStart = ddict->dictContent;
+ dctx->dictEnd = (const BYTE*)ddict->dictContent + ddict->dictSize;
+ dctx->previousDstEnd = dctx->dictEnd;
+ if (ddict->entropyPresent) {
+ dctx->litEntropy = 1;
+ dctx->fseEntropy = 1;
+ dctx->LLTptr = ddict->entropy.LLTable;
+ dctx->MLTptr = ddict->entropy.MLTable;
+ dctx->OFTptr = ddict->entropy.OFTable;
+ dctx->HUFptr = ddict->entropy.hufTable;
+ dctx->entropy.rep[0] = ddict->entropy.rep[0];
+ dctx->entropy.rep[1] = ddict->entropy.rep[1];
+ dctx->entropy.rep[2] = ddict->entropy.rep[2];
+ } else {
+ dctx->litEntropy = 0;
+ dctx->fseEntropy = 0;
+ }
+}
+
+
+static size_t
+ZSTD_loadEntropy_intoDDict(ZSTD_DDict* ddict,
+ ZSTD_dictContentType_e dictContentType)
+{
+ ddict->dictID = 0;
+ ddict->entropyPresent = 0;
+ if (dictContentType == ZSTD_dct_rawContent) return 0;
+
+ if (ddict->dictSize < 8) {
+ if (dictContentType == ZSTD_dct_fullDict)
+ return ERROR(dictionary_corrupted); /* only accept specified dictionaries */
+ return 0; /* pure content mode */
+ }
+ { U32 const magic = MEM_readLE32(ddict->dictContent);
+ if (magic != ZSTD_MAGIC_DICTIONARY) {
+ if (dictContentType == ZSTD_dct_fullDict)
+ return ERROR(dictionary_corrupted); /* only accept specified dictionaries */
+ return 0; /* pure content mode */
+ }
+ }
+ ddict->dictID = MEM_readLE32((const char*)ddict->dictContent + ZSTD_FRAMEIDSIZE);
+
+ /* load entropy tables */
+ CHECK_E( ZSTD_loadDEntropy(&ddict->entropy,
+ ddict->dictContent, ddict->dictSize),
+ dictionary_corrupted );
+ ddict->entropyPresent = 1;
+ return 0;
+}
+
+
+static size_t ZSTD_initDDict_internal(ZSTD_DDict* ddict,
+ const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType)
+{
+ if ((dictLoadMethod == ZSTD_dlm_byRef) || (!dict) || (!dictSize)) {
+ ddict->dictBuffer = NULL;
+ ddict->dictContent = dict;
+ if (!dict) dictSize = 0;
+ } else {
+ void* const internalBuffer = ZSTD_malloc(dictSize, ddict->cMem);
+ ddict->dictBuffer = internalBuffer;
+ ddict->dictContent = internalBuffer;
+ if (!internalBuffer) return ERROR(memory_allocation);
+ memcpy(internalBuffer, dict, dictSize);
+ }
+ ddict->dictSize = dictSize;
+ ddict->entropy.hufTable[0] = (HUF_DTable)((HufLog)*0x1000001); /* cover both little and big endian */
+
+ /* parse dictionary content */
+ CHECK_F( ZSTD_loadEntropy_intoDDict(ddict, dictContentType) );
+
+ return 0;
+}
+
+ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_customMem customMem)
+{
+ if (!customMem.customAlloc ^ !customMem.customFree) return NULL;
+
+ { ZSTD_DDict* const ddict = (ZSTD_DDict*) ZSTD_malloc(sizeof(ZSTD_DDict), customMem);
+ if (ddict == NULL) return NULL;
+ ddict->cMem = customMem;
+ { size_t const initResult = ZSTD_initDDict_internal(ddict,
+ dict, dictSize,
+ dictLoadMethod, dictContentType);
+ if (ZSTD_isError(initResult)) {
+ ZSTD_freeDDict(ddict);
+ return NULL;
+ } }
+ return ddict;
+ }
+}
+
+/*! ZSTD_createDDict() :
+* Create a digested dictionary, to start decompression without startup delay.
+* `dict` content is copied inside DDict.
+* Consequently, `dict` can be released after `ZSTD_DDict` creation */
+ZSTD_DDict* ZSTD_createDDict(const void* dict, size_t dictSize)
+{
+ ZSTD_customMem const allocator = { NULL, NULL, NULL };
+ return ZSTD_createDDict_advanced(dict, dictSize, ZSTD_dlm_byCopy, ZSTD_dct_auto, allocator);
+}
+
+/*! ZSTD_createDDict_byReference() :
+ * Create a digested dictionary, to start decompression without startup delay.
+ * Dictionary content is simply referenced, it will be accessed during decompression.
+ * Warning : dictBuffer must outlive DDict (DDict must be freed before dictBuffer) */
+ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize)
+{
+ ZSTD_customMem const allocator = { NULL, NULL, NULL };
+ return ZSTD_createDDict_advanced(dictBuffer, dictSize, ZSTD_dlm_byRef, ZSTD_dct_auto, allocator);
+}
+
+
+const ZSTD_DDict* ZSTD_initStaticDDict(
+ void* sBuffer, size_t sBufferSize,
+ const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType)
+{
+ size_t const neededSpace = sizeof(ZSTD_DDict)
+ + (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize);
+ ZSTD_DDict* const ddict = (ZSTD_DDict*)sBuffer;
+ assert(sBuffer != NULL);
+ assert(dict != NULL);
+ if ((size_t)sBuffer & 7) return NULL; /* 8-aligned */
+ if (sBufferSize < neededSpace) return NULL;
+ if (dictLoadMethod == ZSTD_dlm_byCopy) {
+ memcpy(ddict+1, dict, dictSize); /* local copy */
+ dict = ddict+1;
+ }
+ if (ZSTD_isError( ZSTD_initDDict_internal(ddict,
+ dict, dictSize,
+ ZSTD_dlm_byRef, dictContentType) ))
+ return NULL;
+ return ddict;
+}
+
+
+size_t ZSTD_freeDDict(ZSTD_DDict* ddict)
+{
+ if (ddict==NULL) return 0; /* support free on NULL */
+ { ZSTD_customMem const cMem = ddict->cMem;
+ ZSTD_free(ddict->dictBuffer, cMem);
+ ZSTD_free(ddict, cMem);
+ return 0;
+ }
+}
+
+/*! ZSTD_estimateDDictSize() :
+ * Estimate amount of memory that will be needed to create a dictionary for decompression.
+ * Note : dictionary created by reference using ZSTD_dlm_byRef are smaller */
+size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod)
+{
+ return sizeof(ZSTD_DDict) + (dictLoadMethod == ZSTD_dlm_byRef ? 0 : dictSize);
+}
+
+size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict)
+{
+ if (ddict==NULL) return 0; /* support sizeof on NULL */
+ return sizeof(*ddict) + (ddict->dictBuffer ? ddict->dictSize : 0) ;
+}
+
+/*! ZSTD_getDictID_fromDDict() :
+ * Provides the dictID of the dictionary loaded into `ddict`.
+ * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
+ * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
+unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict)
+{
+ if (ddict==NULL) return 0;
+ return ZSTD_getDictID_fromDict(ddict->dictContent, ddict->dictSize);
+}
diff --git a/Utilities/cmzstd/lib/decompress/zstd_ddict.h b/Utilities/cmzstd/lib/decompress/zstd_ddict.h
new file mode 100644
index 000000000..0479d11bb
--- /dev/null
+++ b/Utilities/cmzstd/lib/decompress/zstd_ddict.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+
+#ifndef ZSTD_DDICT_H
+#define ZSTD_DDICT_H
+
+/*-*******************************************************
+ * Dependencies
+ *********************************************************/
+#include <stddef.h> /* size_t */
+#include "zstd.h" /* ZSTD_DDict, and several public functions */
+
+
+/*-*******************************************************
+ * Interface
+ *********************************************************/
+
+/* note: several prototypes are already published in `zstd.h` :
+ * ZSTD_createDDict()
+ * ZSTD_createDDict_byReference()
+ * ZSTD_createDDict_advanced()
+ * ZSTD_freeDDict()
+ * ZSTD_initStaticDDict()
+ * ZSTD_sizeof_DDict()
+ * ZSTD_estimateDDictSize()
+ * ZSTD_getDictID_fromDict()
+ */
+
+const void* ZSTD_DDict_dictContent(const ZSTD_DDict* ddict);
+size_t ZSTD_DDict_dictSize(const ZSTD_DDict* ddict);
+
+void ZSTD_copyDDictParameters(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
+
+
+
+#endif /* ZSTD_DDICT_H */
diff --git a/Utilities/cmzstd/lib/decompress/zstd_decompress.c b/Utilities/cmzstd/lib/decompress/zstd_decompress.c
new file mode 100644
index 000000000..feef1ef67
--- /dev/null
+++ b/Utilities/cmzstd/lib/decompress/zstd_decompress.c
@@ -0,0 +1,1672 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+
+/* ***************************************************************
+* Tuning parameters
+*****************************************************************/
+/*!
+ * HEAPMODE :
+ * Select how default decompression function ZSTD_decompress() allocates its context,
+ * on stack (0), or into heap (1, default; requires malloc()).
+ * Note that functions with explicit context such as ZSTD_decompressDCtx() are unaffected.
+ */
+#ifndef ZSTD_HEAPMODE
+# define ZSTD_HEAPMODE 1
+#endif
+
+/*!
+* LEGACY_SUPPORT :
+* if set to 1+, ZSTD_decompress() can decode older formats (v0.1+)
+*/
+#ifndef ZSTD_LEGACY_SUPPORT
+# define ZSTD_LEGACY_SUPPORT 0
+#endif
+
+/*!
+ * MAXWINDOWSIZE_DEFAULT :
+ * maximum window size accepted by DStream __by default__.
+ * Frames requiring more memory will be rejected.
+ * It's possible to set a different limit using ZSTD_DCtx_setMaxWindowSize().
+ */
+#ifndef ZSTD_MAXWINDOWSIZE_DEFAULT
+# define ZSTD_MAXWINDOWSIZE_DEFAULT (((U32)1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT) + 1)
+#endif
+
+/*!
+ * NO_FORWARD_PROGRESS_MAX :
+ * maximum allowed nb of calls to ZSTD_decompressStream()
+ * without any forward progress
+ * (defined as: no byte read from input, and no byte flushed to output)
+ * before triggering an error.
+ */
+#ifndef ZSTD_NO_FORWARD_PROGRESS_MAX
+# define ZSTD_NO_FORWARD_PROGRESS_MAX 16
+#endif
+
+
+/*-*******************************************************
+* Dependencies
+*********************************************************/
+#include <string.h> /* memcpy, memmove, memset */
+#include "cpu.h" /* bmi2 */
+#include "mem.h" /* low level memory routines */
+#define FSE_STATIC_LINKING_ONLY
+#include "fse.h"
+#define HUF_STATIC_LINKING_ONLY
+#include "huf.h"
+#include "zstd_internal.h" /* blockProperties_t */
+#include "zstd_decompress_internal.h" /* ZSTD_DCtx */
+#include "zstd_ddict.h" /* ZSTD_DDictDictContent */
+#include "zstd_decompress_block.h" /* ZSTD_decompressBlock_internal */
+
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
+# include "zstd_legacy.h"
+#endif
+
+
+/*-*************************************************************
+* Context management
+***************************************************************/
+size_t ZSTD_sizeof_DCtx (const ZSTD_DCtx* dctx)
+{
+ if (dctx==NULL) return 0; /* support sizeof NULL */
+ return sizeof(*dctx)
+ + ZSTD_sizeof_DDict(dctx->ddictLocal)
+ + dctx->inBuffSize + dctx->outBuffSize;
+}
+
+size_t ZSTD_estimateDCtxSize(void) { return sizeof(ZSTD_DCtx); }
+
+
+static size_t ZSTD_startingInputLength(ZSTD_format_e format)
+{
+ size_t const startingInputLength = (format==ZSTD_f_zstd1_magicless) ?
+ ZSTD_FRAMEHEADERSIZE_PREFIX - ZSTD_FRAMEIDSIZE :
+ ZSTD_FRAMEHEADERSIZE_PREFIX;
+ ZSTD_STATIC_ASSERT(ZSTD_FRAMEHEADERSIZE_PREFIX >= ZSTD_FRAMEIDSIZE);
+ /* only supports formats ZSTD_f_zstd1 and ZSTD_f_zstd1_magicless */
+ assert( (format == ZSTD_f_zstd1) || (format == ZSTD_f_zstd1_magicless) );
+ return startingInputLength;
+}
+
+static void ZSTD_initDCtx_internal(ZSTD_DCtx* dctx)
+{
+ dctx->format = ZSTD_f_zstd1; /* ZSTD_decompressBegin() invokes ZSTD_startingInputLength() with argument dctx->format */
+ dctx->staticSize = 0;
+ dctx->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT;
+ dctx->ddict = NULL;
+ dctx->ddictLocal = NULL;
+ dctx->dictEnd = NULL;
+ dctx->ddictIsCold = 0;
+ dctx->inBuff = NULL;
+ dctx->inBuffSize = 0;
+ dctx->outBuffSize = 0;
+ dctx->streamStage = zdss_init;
+ dctx->legacyContext = NULL;
+ dctx->previousLegacyVersion = 0;
+ dctx->noForwardProgress = 0;
+ dctx->bmi2 = ZSTD_cpuid_bmi2(ZSTD_cpuid());
+}
+
+ZSTD_DCtx* ZSTD_initStaticDCtx(void *workspace, size_t workspaceSize)
+{
+ ZSTD_DCtx* const dctx = (ZSTD_DCtx*) workspace;
+
+ if ((size_t)workspace & 7) return NULL; /* 8-aligned */
+ if (workspaceSize < sizeof(ZSTD_DCtx)) return NULL; /* minimum size */
+
+ ZSTD_initDCtx_internal(dctx);
+ dctx->staticSize = workspaceSize;
+ dctx->inBuff = (char*)(dctx+1);
+ return dctx;
+}
+
+ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem)
+{
+ if (!customMem.customAlloc ^ !customMem.customFree) return NULL;
+
+ { ZSTD_DCtx* const dctx = (ZSTD_DCtx*)ZSTD_malloc(sizeof(*dctx), customMem);
+ if (!dctx) return NULL;
+ dctx->customMem = customMem;
+ ZSTD_initDCtx_internal(dctx);
+ return dctx;
+ }
+}
+
+ZSTD_DCtx* ZSTD_createDCtx(void)
+{
+ DEBUGLOG(3, "ZSTD_createDCtx");
+ return ZSTD_createDCtx_advanced(ZSTD_defaultCMem);
+}
+
+size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx)
+{
+ if (dctx==NULL) return 0; /* support free on NULL */
+ if (dctx->staticSize) return ERROR(memory_allocation); /* not compatible with static DCtx */
+ { ZSTD_customMem const cMem = dctx->customMem;
+ ZSTD_freeDDict(dctx->ddictLocal);
+ dctx->ddictLocal = NULL;
+ ZSTD_free(dctx->inBuff, cMem);
+ dctx->inBuff = NULL;
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
+ if (dctx->legacyContext)
+ ZSTD_freeLegacyStreamContext(dctx->legacyContext, dctx->previousLegacyVersion);
+#endif
+ ZSTD_free(dctx, cMem);
+ return 0;
+ }
+}
+
+/* no longer useful */
+void ZSTD_copyDCtx(ZSTD_DCtx* dstDCtx, const ZSTD_DCtx* srcDCtx)
+{
+ size_t const toCopy = (size_t)((char*)(&dstDCtx->inBuff) - (char*)dstDCtx);
+ memcpy(dstDCtx, srcDCtx, toCopy); /* no need to copy workspace */
+}
+
+
+/*-*************************************************************
+ * Frame header decoding
+ ***************************************************************/
+
+/*! ZSTD_isFrame() :
+ * Tells if the content of `buffer` starts with a valid Frame Identifier.
+ * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0.
+ * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled.
+ * Note 3 : Skippable Frame Identifiers are considered valid. */
+unsigned ZSTD_isFrame(const void* buffer, size_t size)
+{
+ if (size < ZSTD_FRAMEIDSIZE) return 0;
+ { U32 const magic = MEM_readLE32(buffer);
+ if (magic == ZSTD_MAGICNUMBER) return 1;
+ if ((magic & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) return 1;
+ }
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
+ if (ZSTD_isLegacy(buffer, size)) return 1;
+#endif
+ return 0;
+}
+
+/** ZSTD_frameHeaderSize_internal() :
+ * srcSize must be large enough to reach header size fields.
+ * note : only works for formats ZSTD_f_zstd1 and ZSTD_f_zstd1_magicless.
+ * @return : size of the Frame Header
+ * or an error code, which can be tested with ZSTD_isError() */
+static size_t ZSTD_frameHeaderSize_internal(const void* src, size_t srcSize, ZSTD_format_e format)
+{
+ size_t const minInputSize = ZSTD_startingInputLength(format);
+ if (srcSize < minInputSize) return ERROR(srcSize_wrong);
+
+ { BYTE const fhd = ((const BYTE*)src)[minInputSize-1];
+ U32 const dictID= fhd & 3;
+ U32 const singleSegment = (fhd >> 5) & 1;
+ U32 const fcsId = fhd >> 6;
+ return minInputSize + !singleSegment
+ + ZSTD_did_fieldSize[dictID] + ZSTD_fcs_fieldSize[fcsId]
+ + (singleSegment && !fcsId);
+ }
+}
+
+/** ZSTD_frameHeaderSize() :
+ * srcSize must be >= ZSTD_frameHeaderSize_prefix.
+ * @return : size of the Frame Header,
+ * or an error code (if srcSize is too small) */
+size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize)
+{
+ return ZSTD_frameHeaderSize_internal(src, srcSize, ZSTD_f_zstd1);
+}
+
+
+/** ZSTD_getFrameHeader_advanced() :
+ * decode Frame Header, or require larger `srcSize`.
+ * note : only works for formats ZSTD_f_zstd1 and ZSTD_f_zstd1_magicless
+ * @return : 0, `zfhPtr` is correctly filled,
+ * >0, `srcSize` is too small, value is wanted `srcSize` amount,
+ * or an error code, which can be tested using ZSTD_isError() */
+size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format)
+{
+ const BYTE* ip = (const BYTE*)src;
+ size_t const minInputSize = ZSTD_startingInputLength(format);
+
+ memset(zfhPtr, 0, sizeof(*zfhPtr)); /* not strictly necessary, but static analyzer do not understand that zfhPtr is only going to be read only if return value is zero, since they are 2 different signals */
+ if (srcSize < minInputSize) return minInputSize;
+ if (src==NULL) return ERROR(GENERIC); /* invalid parameter */
+
+ if ( (format != ZSTD_f_zstd1_magicless)
+ && (MEM_readLE32(src) != ZSTD_MAGICNUMBER) ) {
+ if ((MEM_readLE32(src) & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) {
+ /* skippable frame */
+ if (srcSize < ZSTD_SKIPPABLEHEADERSIZE)
+ return ZSTD_SKIPPABLEHEADERSIZE; /* magic number + frame length */
+ memset(zfhPtr, 0, sizeof(*zfhPtr));
+ zfhPtr->frameContentSize = MEM_readLE32((const char *)src + ZSTD_FRAMEIDSIZE);
+ zfhPtr->frameType = ZSTD_skippableFrame;
+ return 0;
+ }
+ return ERROR(prefix_unknown);
+ }
+
+ /* ensure there is enough `srcSize` to fully read/decode frame header */
+ { size_t const fhsize = ZSTD_frameHeaderSize_internal(src, srcSize, format);
+ if (srcSize < fhsize) return fhsize;
+ zfhPtr->headerSize = (U32)fhsize;
+ }
+
+ { BYTE const fhdByte = ip[minInputSize-1];
+ size_t pos = minInputSize;
+ U32 const dictIDSizeCode = fhdByte&3;
+ U32 const checksumFlag = (fhdByte>>2)&1;
+ U32 const singleSegment = (fhdByte>>5)&1;
+ U32 const fcsID = fhdByte>>6;
+ U64 windowSize = 0;
+ U32 dictID = 0;
+ U64 frameContentSize = ZSTD_CONTENTSIZE_UNKNOWN;
+ if ((fhdByte & 0x08) != 0)
+ return ERROR(frameParameter_unsupported); /* reserved bits, must be zero */
+
+ if (!singleSegment) {
+ BYTE const wlByte = ip[pos++];
+ U32 const windowLog = (wlByte >> 3) + ZSTD_WINDOWLOG_ABSOLUTEMIN;
+ if (windowLog > ZSTD_WINDOWLOG_MAX)
+ return ERROR(frameParameter_windowTooLarge);
+ windowSize = (1ULL << windowLog);
+ windowSize += (windowSize >> 3) * (wlByte&7);
+ }
+ switch(dictIDSizeCode)
+ {
+ default: assert(0); /* impossible */
+ case 0 : break;
+ case 1 : dictID = ip[pos]; pos++; break;
+ case 2 : dictID = MEM_readLE16(ip+pos); pos+=2; break;
+ case 3 : dictID = MEM_readLE32(ip+pos); pos+=4; break;
+ }
+ switch(fcsID)
+ {
+ default: assert(0); /* impossible */
+ case 0 : if (singleSegment) frameContentSize = ip[pos]; break;
+ case 1 : frameContentSize = MEM_readLE16(ip+pos)+256; break;
+ case 2 : frameContentSize = MEM_readLE32(ip+pos); break;
+ case 3 : frameContentSize = MEM_readLE64(ip+pos); break;
+ }
+ if (singleSegment) windowSize = frameContentSize;
+
+ zfhPtr->frameType = ZSTD_frame;
+ zfhPtr->frameContentSize = frameContentSize;
+ zfhPtr->windowSize = windowSize;
+ zfhPtr->blockSizeMax = (unsigned) MIN(windowSize, ZSTD_BLOCKSIZE_MAX);
+ zfhPtr->dictID = dictID;
+ zfhPtr->checksumFlag = checksumFlag;
+ }
+ return 0;
+}
+
+/** ZSTD_getFrameHeader() :
+ * decode Frame Header, or require larger `srcSize`.
+ * note : this function does not consume input, it only reads it.
+ * @return : 0, `zfhPtr` is correctly filled,
+ * >0, `srcSize` is too small, value is wanted `srcSize` amount,
+ * or an error code, which can be tested using ZSTD_isError() */
+size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize)
+{
+ return ZSTD_getFrameHeader_advanced(zfhPtr, src, srcSize, ZSTD_f_zstd1);
+}
+
+
+/** ZSTD_getFrameContentSize() :
+ * compatible with legacy mode
+ * @return : decompressed size of the single frame pointed to be `src` if known, otherwise
+ * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
+ * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) */
+unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize)
+{
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
+ if (ZSTD_isLegacy(src, srcSize)) {
+ unsigned long long const ret = ZSTD_getDecompressedSize_legacy(src, srcSize);
+ return ret == 0 ? ZSTD_CONTENTSIZE_UNKNOWN : ret;
+ }
+#endif
+ { ZSTD_frameHeader zfh;
+ if (ZSTD_getFrameHeader(&zfh, src, srcSize) != 0)
+ return ZSTD_CONTENTSIZE_ERROR;
+ if (zfh.frameType == ZSTD_skippableFrame) {
+ return 0;
+ } else {
+ return zfh.frameContentSize;
+ } }
+}
+
+static size_t readSkippableFrameSize(void const* src, size_t srcSize)
+{
+ size_t const skippableHeaderSize = ZSTD_SKIPPABLEHEADERSIZE;
+ U32 sizeU32;
+
+ if (srcSize < ZSTD_SKIPPABLEHEADERSIZE)
+ return ERROR(srcSize_wrong);
+
+ sizeU32 = MEM_readLE32((BYTE const*)src + ZSTD_FRAMEIDSIZE);
+ if ((U32)(sizeU32 + ZSTD_SKIPPABLEHEADERSIZE) < sizeU32)
+ return ERROR(frameParameter_unsupported);
+
+ return skippableHeaderSize + sizeU32;
+}
+
+/** ZSTD_findDecompressedSize() :
+ * compatible with legacy mode
+ * `srcSize` must be the exact length of some number of ZSTD compressed and/or
+ * skippable frames
+ * @return : decompressed size of the frames contained */
+unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize)
+{
+ unsigned long long totalDstSize = 0;
+
+ while (srcSize >= ZSTD_FRAMEHEADERSIZE_PREFIX) {
+ U32 const magicNumber = MEM_readLE32(src);
+
+ if ((magicNumber & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) {
+ size_t const skippableSize = readSkippableFrameSize(src, srcSize);
+ if (ZSTD_isError(skippableSize))
+ return skippableSize;
+ if (srcSize < skippableSize) {
+ return ZSTD_CONTENTSIZE_ERROR;
+ }
+
+ src = (const BYTE *)src + skippableSize;
+ srcSize -= skippableSize;
+ continue;
+ }
+
+ { unsigned long long const ret = ZSTD_getFrameContentSize(src, srcSize);
+ if (ret >= ZSTD_CONTENTSIZE_ERROR) return ret;
+
+ /* check for overflow */
+ if (totalDstSize + ret < totalDstSize) return ZSTD_CONTENTSIZE_ERROR;
+ totalDstSize += ret;
+ }
+ { size_t const frameSrcSize = ZSTD_findFrameCompressedSize(src, srcSize);
+ if (ZSTD_isError(frameSrcSize)) {
+ return ZSTD_CONTENTSIZE_ERROR;
+ }
+
+ src = (const BYTE *)src + frameSrcSize;
+ srcSize -= frameSrcSize;
+ }
+ } /* while (srcSize >= ZSTD_frameHeaderSize_prefix) */
+
+ if (srcSize) return ZSTD_CONTENTSIZE_ERROR;
+
+ return totalDstSize;
+}
+
+/** ZSTD_getDecompressedSize() :
+ * compatible with legacy mode
+ * @return : decompressed size if known, 0 otherwise
+ note : 0 can mean any of the following :
+ - frame content is empty
+ - decompressed size field is not present in frame header
+ - frame header unknown / not supported
+ - frame header not complete (`srcSize` too small) */
+unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize)
+{
+ unsigned long long const ret = ZSTD_getFrameContentSize(src, srcSize);
+ ZSTD_STATIC_ASSERT(ZSTD_CONTENTSIZE_ERROR < ZSTD_CONTENTSIZE_UNKNOWN);
+ return (ret >= ZSTD_CONTENTSIZE_ERROR) ? 0 : ret;
+}
+
+
+/** ZSTD_decodeFrameHeader() :
+ * `headerSize` must be the size provided by ZSTD_frameHeaderSize().
+ * @return : 0 if success, or an error code, which can be tested using ZSTD_isError() */
+static size_t ZSTD_decodeFrameHeader(ZSTD_DCtx* dctx, const void* src, size_t headerSize)
+{
+ size_t const result = ZSTD_getFrameHeader_advanced(&(dctx->fParams), src, headerSize, dctx->format);
+ if (ZSTD_isError(result)) return result; /* invalid header */
+ if (result>0) return ERROR(srcSize_wrong); /* headerSize too small */
+ if (dctx->fParams.dictID && (dctx->dictID != dctx->fParams.dictID))
+ return ERROR(dictionary_wrong);
+ if (dctx->fParams.checksumFlag) XXH64_reset(&dctx->xxhState, 0);
+ return 0;
+}
+
+
+/** ZSTD_findFrameCompressedSize() :
+ * compatible with legacy mode
+ * `src` must point to the start of a ZSTD frame, ZSTD legacy frame, or skippable frame
+ * `srcSize` must be at least as large as the frame contained
+ * @return : the compressed size of the frame starting at `src` */
+size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize)
+{
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
+ if (ZSTD_isLegacy(src, srcSize))
+ return ZSTD_findFrameCompressedSizeLegacy(src, srcSize);
+#endif
+ if ( (srcSize >= ZSTD_SKIPPABLEHEADERSIZE)
+ && (MEM_readLE32(src) & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START ) {
+ return readSkippableFrameSize(src, srcSize);
+ } else {
+ const BYTE* ip = (const BYTE*)src;
+ const BYTE* const ipstart = ip;
+ size_t remainingSize = srcSize;
+ ZSTD_frameHeader zfh;
+
+ /* Extract Frame Header */
+ { size_t const ret = ZSTD_getFrameHeader(&zfh, src, srcSize);
+ if (ZSTD_isError(ret)) return ret;
+ if (ret > 0) return ERROR(srcSize_wrong);
+ }
+
+ ip += zfh.headerSize;
+ remainingSize -= zfh.headerSize;
+
+ /* Loop on each block */
+ while (1) {
+ blockProperties_t blockProperties;
+ size_t const cBlockSize = ZSTD_getcBlockSize(ip, remainingSize, &blockProperties);
+ if (ZSTD_isError(cBlockSize)) return cBlockSize;
+
+ if (ZSTD_blockHeaderSize + cBlockSize > remainingSize)
+ return ERROR(srcSize_wrong);
+
+ ip += ZSTD_blockHeaderSize + cBlockSize;
+ remainingSize -= ZSTD_blockHeaderSize + cBlockSize;
+
+ if (blockProperties.lastBlock) break;
+ }
+
+ if (zfh.checksumFlag) { /* Final frame content checksum */
+ if (remainingSize < 4) return ERROR(srcSize_wrong);
+ ip += 4;
+ }
+
+ return ip - ipstart;
+ }
+}
+
+
+
+/*-*************************************************************
+ * Frame decoding
+ ***************************************************************/
+
+
+void ZSTD_checkContinuity(ZSTD_DCtx* dctx, const void* dst)
+{
+ if (dst != dctx->previousDstEnd) { /* not contiguous */
+ dctx->dictEnd = dctx->previousDstEnd;
+ dctx->virtualStart = (const char*)dst - ((const char*)(dctx->previousDstEnd) - (const char*)(dctx->prefixStart));
+ dctx->prefixStart = dst;
+ dctx->previousDstEnd = dst;
+ }
+}
+
+/** ZSTD_insertBlock() :
+ insert `src` block into `dctx` history. Useful to track uncompressed blocks. */
+size_t ZSTD_insertBlock(ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize)
+{
+ ZSTD_checkContinuity(dctx, blockStart);
+ dctx->previousDstEnd = (const char*)blockStart + blockSize;
+ return blockSize;
+}
+
+
+static size_t ZSTD_copyRawBlock(void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize)
+{
+ DEBUGLOG(5, "ZSTD_copyRawBlock");
+ if (dst == NULL) {
+ if (srcSize == 0) return 0;
+ return ERROR(dstBuffer_null);
+ }
+ if (srcSize > dstCapacity) return ERROR(dstSize_tooSmall);
+ memcpy(dst, src, srcSize);
+ return srcSize;
+}
+
+static size_t ZSTD_setRleBlock(void* dst, size_t dstCapacity,
+ BYTE b,
+ size_t regenSize)
+{
+ if (dst == NULL) {
+ if (regenSize == 0) return 0;
+ return ERROR(dstBuffer_null);
+ }
+ if (regenSize > dstCapacity) return ERROR(dstSize_tooSmall);
+ memset(dst, b, regenSize);
+ return regenSize;
+}
+
+
+/*! ZSTD_decompressFrame() :
+ * @dctx must be properly initialized
+ * will update *srcPtr and *srcSizePtr,
+ * to make *srcPtr progress by one frame. */
+static size_t ZSTD_decompressFrame(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void** srcPtr, size_t *srcSizePtr)
+{
+ const BYTE* ip = (const BYTE*)(*srcPtr);
+ BYTE* const ostart = (BYTE* const)dst;
+ BYTE* const oend = ostart + dstCapacity;
+ BYTE* op = ostart;
+ size_t remainingSrcSize = *srcSizePtr;
+
+ DEBUGLOG(4, "ZSTD_decompressFrame (srcSize:%i)", (int)*srcSizePtr);
+
+ /* check */
+ if (remainingSrcSize < ZSTD_FRAMEHEADERSIZE_MIN+ZSTD_blockHeaderSize)
+ return ERROR(srcSize_wrong);
+
+ /* Frame Header */
+ { size_t const frameHeaderSize = ZSTD_frameHeaderSize(ip, ZSTD_FRAMEHEADERSIZE_PREFIX);
+ if (ZSTD_isError(frameHeaderSize)) return frameHeaderSize;
+ if (remainingSrcSize < frameHeaderSize+ZSTD_blockHeaderSize)
+ return ERROR(srcSize_wrong);
+ CHECK_F( ZSTD_decodeFrameHeader(dctx, ip, frameHeaderSize) );
+ ip += frameHeaderSize; remainingSrcSize -= frameHeaderSize;
+ }
+
+ /* Loop on each block */
+ while (1) {
+ size_t decodedSize;
+ blockProperties_t blockProperties;
+ size_t const cBlockSize = ZSTD_getcBlockSize(ip, remainingSrcSize, &blockProperties);
+ if (ZSTD_isError(cBlockSize)) return cBlockSize;
+
+ ip += ZSTD_blockHeaderSize;
+ remainingSrcSize -= ZSTD_blockHeaderSize;
+ if (cBlockSize > remainingSrcSize) return ERROR(srcSize_wrong);
+
+ switch(blockProperties.blockType)
+ {
+ case bt_compressed:
+ decodedSize = ZSTD_decompressBlock_internal(dctx, op, oend-op, ip, cBlockSize, /* frame */ 1);
+ break;
+ case bt_raw :
+ decodedSize = ZSTD_copyRawBlock(op, oend-op, ip, cBlockSize);
+ break;
+ case bt_rle :
+ decodedSize = ZSTD_setRleBlock(op, oend-op, *ip, blockProperties.origSize);
+ break;
+ case bt_reserved :
+ default:
+ return ERROR(corruption_detected);
+ }
+
+ if (ZSTD_isError(decodedSize)) return decodedSize;
+ if (dctx->fParams.checksumFlag)
+ XXH64_update(&dctx->xxhState, op, decodedSize);
+ op += decodedSize;
+ ip += cBlockSize;
+ remainingSrcSize -= cBlockSize;
+ if (blockProperties.lastBlock) break;
+ }
+
+ if (dctx->fParams.frameContentSize != ZSTD_CONTENTSIZE_UNKNOWN) {
+ if ((U64)(op-ostart) != dctx->fParams.frameContentSize) {
+ return ERROR(corruption_detected);
+ } }
+ if (dctx->fParams.checksumFlag) { /* Frame content checksum verification */
+ U32 const checkCalc = (U32)XXH64_digest(&dctx->xxhState);
+ U32 checkRead;
+ if (remainingSrcSize<4) return ERROR(checksum_wrong);
+ checkRead = MEM_readLE32(ip);
+ if (checkRead != checkCalc) return ERROR(checksum_wrong);
+ ip += 4;
+ remainingSrcSize -= 4;
+ }
+
+ /* Allow caller to get size read */
+ *srcPtr = ip;
+ *srcSizePtr = remainingSrcSize;
+ return op-ostart;
+}
+
+static size_t ZSTD_decompressMultiFrame(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict, size_t dictSize,
+ const ZSTD_DDict* ddict)
+{
+ void* const dststart = dst;
+ int moreThan1Frame = 0;
+
+ DEBUGLOG(5, "ZSTD_decompressMultiFrame");
+ assert(dict==NULL || ddict==NULL); /* either dict or ddict set, not both */
+
+ if (ddict) {
+ dict = ZSTD_DDict_dictContent(ddict);
+ dictSize = ZSTD_DDict_dictSize(ddict);
+ }
+
+ while (srcSize >= ZSTD_FRAMEHEADERSIZE_PREFIX) {
+
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1)
+ if (ZSTD_isLegacy(src, srcSize)) {
+ size_t decodedSize;
+ size_t const frameSize = ZSTD_findFrameCompressedSizeLegacy(src, srcSize);
+ if (ZSTD_isError(frameSize)) return frameSize;
+ /* legacy support is not compatible with static dctx */
+ if (dctx->staticSize) return ERROR(memory_allocation);
+
+ decodedSize = ZSTD_decompressLegacy(dst, dstCapacity, src, frameSize, dict, dictSize);
+ if (ZSTD_isError(decodedSize)) return decodedSize;
+
+ assert(decodedSize <=- dstCapacity);
+ dst = (BYTE*)dst + decodedSize;
+ dstCapacity -= decodedSize;
+
+ src = (const BYTE*)src + frameSize;
+ srcSize -= frameSize;
+
+ continue;
+ }
+#endif
+
+ { U32 const magicNumber = MEM_readLE32(src);
+ DEBUGLOG(4, "reading magic number %08X (expecting %08X)",
+ (unsigned)magicNumber, ZSTD_MAGICNUMBER);
+ if ((magicNumber & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) {
+ size_t const skippableSize = readSkippableFrameSize(src, srcSize);
+ if (ZSTD_isError(skippableSize))
+ return skippableSize;
+ if (srcSize < skippableSize) return ERROR(srcSize_wrong);
+
+ src = (const BYTE *)src + skippableSize;
+ srcSize -= skippableSize;
+ continue;
+ } }
+
+ if (ddict) {
+ /* we were called from ZSTD_decompress_usingDDict */
+ CHECK_F(ZSTD_decompressBegin_usingDDict(dctx, ddict));
+ } else {
+ /* this will initialize correctly with no dict if dict == NULL, so
+ * use this in all cases but ddict */
+ CHECK_F(ZSTD_decompressBegin_usingDict(dctx, dict, dictSize));
+ }
+ ZSTD_checkContinuity(dctx, dst);
+
+ { const size_t res = ZSTD_decompressFrame(dctx, dst, dstCapacity,
+ &src, &srcSize);
+ if ( (ZSTD_getErrorCode(res) == ZSTD_error_prefix_unknown)
+ && (moreThan1Frame==1) ) {
+ /* at least one frame successfully completed,
+ * but following bytes are garbage :
+ * it's more likely to be a srcSize error,
+ * specifying more bytes than compressed size of frame(s).
+ * This error message replaces ERROR(prefix_unknown),
+ * which would be confusing, as the first header is actually correct.
+ * Note that one could be unlucky, it might be a corruption error instead,
+ * happening right at the place where we expect zstd magic bytes.
+ * But this is _much_ less likely than a srcSize field error. */
+ return ERROR(srcSize_wrong);
+ }
+ if (ZSTD_isError(res)) return res;
+ assert(res <= dstCapacity);
+ dst = (BYTE*)dst + res;
+ dstCapacity -= res;
+ }
+ moreThan1Frame = 1;
+ } /* while (srcSize >= ZSTD_frameHeaderSize_prefix) */
+
+ if (srcSize) return ERROR(srcSize_wrong); /* input not entirely consumed */
+
+ return (BYTE*)dst - (BYTE*)dststart;
+}
+
+size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict, size_t dictSize)
+{
+ return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize, dict, dictSize, NULL);
+}
+
+
+size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+{
+ return ZSTD_decompress_usingDict(dctx, dst, dstCapacity, src, srcSize, NULL, 0);
+}
+
+
+size_t ZSTD_decompress(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+{
+#if defined(ZSTD_HEAPMODE) && (ZSTD_HEAPMODE>=1)
+ size_t regenSize;
+ ZSTD_DCtx* const dctx = ZSTD_createDCtx();
+ if (dctx==NULL) return ERROR(memory_allocation);
+ regenSize = ZSTD_decompressDCtx(dctx, dst, dstCapacity, src, srcSize);
+ ZSTD_freeDCtx(dctx);
+ return regenSize;
+#else /* stack mode */
+ ZSTD_DCtx dctx;
+ ZSTD_initDCtx_internal(&dctx);
+ return ZSTD_decompressDCtx(&dctx, dst, dstCapacity, src, srcSize);
+#endif
+}
+
+
+/*-**************************************
+* Advanced Streaming Decompression API
+* Bufferless and synchronous
+****************************************/
+size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx) { return dctx->expected; }
+
+ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx) {
+ switch(dctx->stage)
+ {
+ default: /* should not happen */
+ assert(0);
+ case ZSTDds_getFrameHeaderSize:
+ case ZSTDds_decodeFrameHeader:
+ return ZSTDnit_frameHeader;
+ case ZSTDds_decodeBlockHeader:
+ return ZSTDnit_blockHeader;
+ case ZSTDds_decompressBlock:
+ return ZSTDnit_block;
+ case ZSTDds_decompressLastBlock:
+ return ZSTDnit_lastBlock;
+ case ZSTDds_checkChecksum:
+ return ZSTDnit_checksum;
+ case ZSTDds_decodeSkippableHeader:
+ case ZSTDds_skipFrame:
+ return ZSTDnit_skippableFrame;
+ }
+}
+
+static int ZSTD_isSkipFrame(ZSTD_DCtx* dctx) { return dctx->stage == ZSTDds_skipFrame; }
+
+/** ZSTD_decompressContinue() :
+ * srcSize : must be the exact nb of bytes expected (see ZSTD_nextSrcSizeToDecompress())
+ * @return : nb of bytes generated into `dst` (necessarily <= `dstCapacity)
+ * or an error code, which can be tested using ZSTD_isError() */
+size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+{
+ DEBUGLOG(5, "ZSTD_decompressContinue (srcSize:%u)", (unsigned)srcSize);
+ /* Sanity check */
+ if (srcSize != dctx->expected)
+ return ERROR(srcSize_wrong); /* not allowed */
+ if (dstCapacity) ZSTD_checkContinuity(dctx, dst);
+
+ switch (dctx->stage)
+ {
+ case ZSTDds_getFrameHeaderSize :
+ assert(src != NULL);
+ if (dctx->format == ZSTD_f_zstd1) { /* allows header */
+ assert(srcSize >= ZSTD_FRAMEIDSIZE); /* to read skippable magic number */
+ if ((MEM_readLE32(src) & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) { /* skippable frame */
+ memcpy(dctx->headerBuffer, src, srcSize);
+ dctx->expected = ZSTD_SKIPPABLEHEADERSIZE - srcSize; /* remaining to load to get full skippable frame header */
+ dctx->stage = ZSTDds_decodeSkippableHeader;
+ return 0;
+ } }
+ dctx->headerSize = ZSTD_frameHeaderSize_internal(src, srcSize, dctx->format);
+ if (ZSTD_isError(dctx->headerSize)) return dctx->headerSize;
+ memcpy(dctx->headerBuffer, src, srcSize);
+ dctx->expected = dctx->headerSize - srcSize;
+ dctx->stage = ZSTDds_decodeFrameHeader;
+ return 0;
+
+ case ZSTDds_decodeFrameHeader:
+ assert(src != NULL);
+ memcpy(dctx->headerBuffer + (dctx->headerSize - srcSize), src, srcSize);
+ CHECK_F(ZSTD_decodeFrameHeader(dctx, dctx->headerBuffer, dctx->headerSize));
+ dctx->expected = ZSTD_blockHeaderSize;
+ dctx->stage = ZSTDds_decodeBlockHeader;
+ return 0;
+
+ case ZSTDds_decodeBlockHeader:
+ { blockProperties_t bp;
+ size_t const cBlockSize = ZSTD_getcBlockSize(src, ZSTD_blockHeaderSize, &bp);
+ if (ZSTD_isError(cBlockSize)) return cBlockSize;
+ dctx->expected = cBlockSize;
+ dctx->bType = bp.blockType;
+ dctx->rleSize = bp.origSize;
+ if (cBlockSize) {
+ dctx->stage = bp.lastBlock ? ZSTDds_decompressLastBlock : ZSTDds_decompressBlock;
+ return 0;
+ }
+ /* empty block */
+ if (bp.lastBlock) {
+ if (dctx->fParams.checksumFlag) {
+ dctx->expected = 4;
+ dctx->stage = ZSTDds_checkChecksum;
+ } else {
+ dctx->expected = 0; /* end of frame */
+ dctx->stage = ZSTDds_getFrameHeaderSize;
+ }
+ } else {
+ dctx->expected = ZSTD_blockHeaderSize; /* jump to next header */
+ dctx->stage = ZSTDds_decodeBlockHeader;
+ }
+ return 0;
+ }
+
+ case ZSTDds_decompressLastBlock:
+ case ZSTDds_decompressBlock:
+ DEBUGLOG(5, "ZSTD_decompressContinue: case ZSTDds_decompressBlock");
+ { size_t rSize;
+ switch(dctx->bType)
+ {
+ case bt_compressed:
+ DEBUGLOG(5, "ZSTD_decompressContinue: case bt_compressed");
+ rSize = ZSTD_decompressBlock_internal(dctx, dst, dstCapacity, src, srcSize, /* frame */ 1);
+ break;
+ case bt_raw :
+ rSize = ZSTD_copyRawBlock(dst, dstCapacity, src, srcSize);
+ break;
+ case bt_rle :
+ rSize = ZSTD_setRleBlock(dst, dstCapacity, *(const BYTE*)src, dctx->rleSize);
+ break;
+ case bt_reserved : /* should never happen */
+ default:
+ return ERROR(corruption_detected);
+ }
+ if (ZSTD_isError(rSize)) return rSize;
+ DEBUGLOG(5, "ZSTD_decompressContinue: decoded size from block : %u", (unsigned)rSize);
+ dctx->decodedSize += rSize;
+ if (dctx->fParams.checksumFlag) XXH64_update(&dctx->xxhState, dst, rSize);
+
+ if (dctx->stage == ZSTDds_decompressLastBlock) { /* end of frame */
+ DEBUGLOG(4, "ZSTD_decompressContinue: decoded size from frame : %u", (unsigned)dctx->decodedSize);
+ if (dctx->fParams.frameContentSize != ZSTD_CONTENTSIZE_UNKNOWN) {
+ if (dctx->decodedSize != dctx->fParams.frameContentSize) {
+ return ERROR(corruption_detected);
+ } }
+ if (dctx->fParams.checksumFlag) { /* another round for frame checksum */
+ dctx->expected = 4;
+ dctx->stage = ZSTDds_checkChecksum;
+ } else {
+ dctx->expected = 0; /* ends here */
+ dctx->stage = ZSTDds_getFrameHeaderSize;
+ }
+ } else {
+ dctx->stage = ZSTDds_decodeBlockHeader;
+ dctx->expected = ZSTD_blockHeaderSize;
+ dctx->previousDstEnd = (char*)dst + rSize;
+ }
+ return rSize;
+ }
+
+ case ZSTDds_checkChecksum:
+ assert(srcSize == 4); /* guaranteed by dctx->expected */
+ { U32 const h32 = (U32)XXH64_digest(&dctx->xxhState);
+ U32 const check32 = MEM_readLE32(src);
+ DEBUGLOG(4, "ZSTD_decompressContinue: checksum : calculated %08X :: %08X read", (unsigned)h32, (unsigned)check32);
+ if (check32 != h32) return ERROR(checksum_wrong);
+ dctx->expected = 0;
+ dctx->stage = ZSTDds_getFrameHeaderSize;
+ return 0;
+ }
+
+ case ZSTDds_decodeSkippableHeader:
+ assert(src != NULL);
+ assert(srcSize <= ZSTD_SKIPPABLEHEADERSIZE);
+ memcpy(dctx->headerBuffer + (ZSTD_SKIPPABLEHEADERSIZE - srcSize), src, srcSize); /* complete skippable header */
+ dctx->expected = MEM_readLE32(dctx->headerBuffer + ZSTD_FRAMEIDSIZE); /* note : dctx->expected can grow seriously large, beyond local buffer size */
+ dctx->stage = ZSTDds_skipFrame;
+ return 0;
+
+ case ZSTDds_skipFrame:
+ dctx->expected = 0;
+ dctx->stage = ZSTDds_getFrameHeaderSize;
+ return 0;
+
+ default:
+ assert(0); /* impossible */
+ return ERROR(GENERIC); /* some compiler require default to do something */
+ }
+}
+
+
+static size_t ZSTD_refDictContent(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
+{
+ dctx->dictEnd = dctx->previousDstEnd;
+ dctx->virtualStart = (const char*)dict - ((const char*)(dctx->previousDstEnd) - (const char*)(dctx->prefixStart));
+ dctx->prefixStart = dict;
+ dctx->previousDstEnd = (const char*)dict + dictSize;
+ return 0;
+}
+
+/*! ZSTD_loadDEntropy() :
+ * dict : must point at beginning of a valid zstd dictionary.
+ * @return : size of entropy tables read */
+size_t
+ZSTD_loadDEntropy(ZSTD_entropyDTables_t* entropy,
+ const void* const dict, size_t const dictSize)
+{
+ const BYTE* dictPtr = (const BYTE*)dict;
+ const BYTE* const dictEnd = dictPtr + dictSize;
+
+ if (dictSize <= 8) return ERROR(dictionary_corrupted);
+ assert(MEM_readLE32(dict) == ZSTD_MAGIC_DICTIONARY); /* dict must be valid */
+ dictPtr += 8; /* skip header = magic + dictID */
+
+ ZSTD_STATIC_ASSERT(offsetof(ZSTD_entropyDTables_t, OFTable) == offsetof(ZSTD_entropyDTables_t, LLTable) + sizeof(entropy->LLTable));
+ ZSTD_STATIC_ASSERT(offsetof(ZSTD_entropyDTables_t, MLTable) == offsetof(ZSTD_entropyDTables_t, OFTable) + sizeof(entropy->OFTable));
+ ZSTD_STATIC_ASSERT(sizeof(entropy->LLTable) + sizeof(entropy->OFTable) + sizeof(entropy->MLTable) >= HUF_DECOMPRESS_WORKSPACE_SIZE);
+ { void* const workspace = &entropy->LLTable; /* use fse tables as temporary workspace; implies fse tables are grouped together */
+ size_t const workspaceSize = sizeof(entropy->LLTable) + sizeof(entropy->OFTable) + sizeof(entropy->MLTable);
+#ifdef HUF_FORCE_DECOMPRESS_X1
+ /* in minimal huffman, we always use X1 variants */
+ size_t const hSize = HUF_readDTableX1_wksp(entropy->hufTable,
+ dictPtr, dictEnd - dictPtr,
+ workspace, workspaceSize);
+#else
+ size_t const hSize = HUF_readDTableX2_wksp(entropy->hufTable,
+ dictPtr, dictEnd - dictPtr,
+ workspace, workspaceSize);
+#endif
+ if (HUF_isError(hSize)) return ERROR(dictionary_corrupted);
+ dictPtr += hSize;
+ }
+
+ { short offcodeNCount[MaxOff+1];
+ unsigned offcodeMaxValue = MaxOff, offcodeLog;
+ size_t const offcodeHeaderSize = FSE_readNCount(offcodeNCount, &offcodeMaxValue, &offcodeLog, dictPtr, dictEnd-dictPtr);
+ if (FSE_isError(offcodeHeaderSize)) return ERROR(dictionary_corrupted);
+ if (offcodeMaxValue > MaxOff) return ERROR(dictionary_corrupted);
+ if (offcodeLog > OffFSELog) return ERROR(dictionary_corrupted);
+ ZSTD_buildFSETable( entropy->OFTable,
+ offcodeNCount, offcodeMaxValue,
+ OF_base, OF_bits,
+ offcodeLog);
+ dictPtr += offcodeHeaderSize;
+ }
+
+ { short matchlengthNCount[MaxML+1];
+ unsigned matchlengthMaxValue = MaxML, matchlengthLog;
+ size_t const matchlengthHeaderSize = FSE_readNCount(matchlengthNCount, &matchlengthMaxValue, &matchlengthLog, dictPtr, dictEnd-dictPtr);
+ if (FSE_isError(matchlengthHeaderSize)) return ERROR(dictionary_corrupted);
+ if (matchlengthMaxValue > MaxML) return ERROR(dictionary_corrupted);
+ if (matchlengthLog > MLFSELog) return ERROR(dictionary_corrupted);
+ ZSTD_buildFSETable( entropy->MLTable,
+ matchlengthNCount, matchlengthMaxValue,
+ ML_base, ML_bits,
+ matchlengthLog);
+ dictPtr += matchlengthHeaderSize;
+ }
+
+ { short litlengthNCount[MaxLL+1];
+ unsigned litlengthMaxValue = MaxLL, litlengthLog;
+ size_t const litlengthHeaderSize = FSE_readNCount(litlengthNCount, &litlengthMaxValue, &litlengthLog, dictPtr, dictEnd-dictPtr);
+ if (FSE_isError(litlengthHeaderSize)) return ERROR(dictionary_corrupted);
+ if (litlengthMaxValue > MaxLL) return ERROR(dictionary_corrupted);
+ if (litlengthLog > LLFSELog) return ERROR(dictionary_corrupted);
+ ZSTD_buildFSETable( entropy->LLTable,
+ litlengthNCount, litlengthMaxValue,
+ LL_base, LL_bits,
+ litlengthLog);
+ dictPtr += litlengthHeaderSize;
+ }
+
+ if (dictPtr+12 > dictEnd) return ERROR(dictionary_corrupted);
+ { int i;
+ size_t const dictContentSize = (size_t)(dictEnd - (dictPtr+12));
+ for (i=0; i<3; i++) {
+ U32 const rep = MEM_readLE32(dictPtr); dictPtr += 4;
+ if (rep==0 || rep >= dictContentSize) return ERROR(dictionary_corrupted);
+ entropy->rep[i] = rep;
+ } }
+
+ return dictPtr - (const BYTE*)dict;
+}
+
+static size_t ZSTD_decompress_insertDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
+{
+ if (dictSize < 8) return ZSTD_refDictContent(dctx, dict, dictSize);
+ { U32 const magic = MEM_readLE32(dict);
+ if (magic != ZSTD_MAGIC_DICTIONARY) {
+ return ZSTD_refDictContent(dctx, dict, dictSize); /* pure content mode */
+ } }
+ dctx->dictID = MEM_readLE32((const char*)dict + ZSTD_FRAMEIDSIZE);
+
+ /* load entropy tables */
+ { size_t const eSize = ZSTD_loadDEntropy(&dctx->entropy, dict, dictSize);
+ if (ZSTD_isError(eSize)) return ERROR(dictionary_corrupted);
+ dict = (const char*)dict + eSize;
+ dictSize -= eSize;
+ }
+ dctx->litEntropy = dctx->fseEntropy = 1;
+
+ /* reference dictionary content */
+ return ZSTD_refDictContent(dctx, dict, dictSize);
+}
+
+size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx)
+{
+ assert(dctx != NULL);
+ dctx->expected = ZSTD_startingInputLength(dctx->format); /* dctx->format must be properly set */
+ dctx->stage = ZSTDds_getFrameHeaderSize;
+ dctx->decodedSize = 0;
+ dctx->previousDstEnd = NULL;
+ dctx->prefixStart = NULL;
+ dctx->virtualStart = NULL;
+ dctx->dictEnd = NULL;
+ dctx->entropy.hufTable[0] = (HUF_DTable)((HufLog)*0x1000001); /* cover both little and big endian */
+ dctx->litEntropy = dctx->fseEntropy = 0;
+ dctx->dictID = 0;
+ ZSTD_STATIC_ASSERT(sizeof(dctx->entropy.rep) == sizeof(repStartValue));
+ memcpy(dctx->entropy.rep, repStartValue, sizeof(repStartValue)); /* initial repcodes */
+ dctx->LLTptr = dctx->entropy.LLTable;
+ dctx->MLTptr = dctx->entropy.MLTable;
+ dctx->OFTptr = dctx->entropy.OFTable;
+ dctx->HUFptr = dctx->entropy.hufTable;
+ return 0;
+}
+
+size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
+{
+ CHECK_F( ZSTD_decompressBegin(dctx) );
+ if (dict && dictSize)
+ CHECK_E(ZSTD_decompress_insertDictionary(dctx, dict, dictSize), dictionary_corrupted);
+ return 0;
+}
+
+
+/* ====== ZSTD_DDict ====== */
+
+size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict)
+{
+ DEBUGLOG(4, "ZSTD_decompressBegin_usingDDict");
+ assert(dctx != NULL);
+ if (ddict) {
+ const char* const dictStart = (const char*)ZSTD_DDict_dictContent(ddict);
+ size_t const dictSize = ZSTD_DDict_dictSize(ddict);
+ const void* const dictEnd = dictStart + dictSize;
+ dctx->ddictIsCold = (dctx->dictEnd != dictEnd);
+ DEBUGLOG(4, "DDict is %s",
+ dctx->ddictIsCold ? "~cold~" : "hot!");
+ }
+ CHECK_F( ZSTD_decompressBegin(dctx) );
+ if (ddict) { /* NULL ddict is equivalent to no dictionary */
+ ZSTD_copyDDictParameters(dctx, ddict);
+ }
+ return 0;
+}
+
+/*! ZSTD_getDictID_fromDict() :
+ * Provides the dictID stored within dictionary.
+ * if @return == 0, the dictionary is not conformant with Zstandard specification.
+ * It can still be loaded, but as a content-only dictionary. */
+unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize)
+{
+ if (dictSize < 8) return 0;
+ if (MEM_readLE32(dict) != ZSTD_MAGIC_DICTIONARY) return 0;
+ return MEM_readLE32((const char*)dict + ZSTD_FRAMEIDSIZE);
+}
+
+/*! ZSTD_getDictID_fromFrame() :
+ * Provides the dictID required to decompresse frame stored within `src`.
+ * If @return == 0, the dictID could not be decoded.
+ * This could for one of the following reasons :
+ * - The frame does not require a dictionary (most common case).
+ * - The frame was built with dictID intentionally removed.
+ * Needed dictionary is a hidden information.
+ * Note : this use case also happens when using a non-conformant dictionary.
+ * - `srcSize` is too small, and as a result, frame header could not be decoded.
+ * Note : possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`.
+ * - This is not a Zstandard frame.
+ * When identifying the exact failure cause, it's possible to use
+ * ZSTD_getFrameHeader(), which will provide a more precise error code. */
+unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize)
+{
+ ZSTD_frameHeader zfp = { 0, 0, 0, ZSTD_frame, 0, 0, 0 };
+ size_t const hError = ZSTD_getFrameHeader(&zfp, src, srcSize);
+ if (ZSTD_isError(hError)) return 0;
+ return zfp.dictID;
+}
+
+
+/*! ZSTD_decompress_usingDDict() :
+* Decompression using a pre-digested Dictionary
+* Use dictionary without significant overhead. */
+size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_DDict* ddict)
+{
+ /* pass content and size in case legacy frames are encountered */
+ return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize,
+ NULL, 0,
+ ddict);
+}
+
+
+/*=====================================
+* Streaming decompression
+*====================================*/
+
+ZSTD_DStream* ZSTD_createDStream(void)
+{
+ DEBUGLOG(3, "ZSTD_createDStream");
+ return ZSTD_createDStream_advanced(ZSTD_defaultCMem);
+}
+
+ZSTD_DStream* ZSTD_initStaticDStream(void *workspace, size_t workspaceSize)
+{
+ return ZSTD_initStaticDCtx(workspace, workspaceSize);
+}
+
+ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem)
+{
+ return ZSTD_createDCtx_advanced(customMem);
+}
+
+size_t ZSTD_freeDStream(ZSTD_DStream* zds)
+{
+ return ZSTD_freeDCtx(zds);
+}
+
+
+/* *** Initialization *** */
+
+size_t ZSTD_DStreamInSize(void) { return ZSTD_BLOCKSIZE_MAX + ZSTD_blockHeaderSize; }
+size_t ZSTD_DStreamOutSize(void) { return ZSTD_BLOCKSIZE_MAX; }
+
+size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx,
+ const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType)
+{
+ if (dctx->streamStage != zdss_init) return ERROR(stage_wrong);
+ ZSTD_freeDDict(dctx->ddictLocal);
+ if (dict && dictSize >= 8) {
+ dctx->ddictLocal = ZSTD_createDDict_advanced(dict, dictSize, dictLoadMethod, dictContentType, dctx->customMem);
+ if (dctx->ddictLocal == NULL) return ERROR(memory_allocation);
+ } else {
+ dctx->ddictLocal = NULL;
+ }
+ dctx->ddict = dctx->ddictLocal;
+ return 0;
+}
+
+size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
+{
+ return ZSTD_DCtx_loadDictionary_advanced(dctx, dict, dictSize, ZSTD_dlm_byRef, ZSTD_dct_auto);
+}
+
+size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize)
+{
+ return ZSTD_DCtx_loadDictionary_advanced(dctx, dict, dictSize, ZSTD_dlm_byCopy, ZSTD_dct_auto);
+}
+
+size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType)
+{
+ return ZSTD_DCtx_loadDictionary_advanced(dctx, prefix, prefixSize, ZSTD_dlm_byRef, dictContentType);
+}
+
+size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize)
+{
+ return ZSTD_DCtx_refPrefix_advanced(dctx, prefix, prefixSize, ZSTD_dct_rawContent);
+}
+
+
+/* ZSTD_initDStream_usingDict() :
+ * return : expected size, aka ZSTD_FRAMEHEADERSIZE_PREFIX.
+ * this function cannot fail */
+size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize)
+{
+ DEBUGLOG(4, "ZSTD_initDStream_usingDict");
+ zds->streamStage = zdss_init;
+ zds->noForwardProgress = 0;
+ CHECK_F( ZSTD_DCtx_loadDictionary(zds, dict, dictSize) );
+ return ZSTD_FRAMEHEADERSIZE_PREFIX;
+}
+
+/* note : this variant can't fail */
+size_t ZSTD_initDStream(ZSTD_DStream* zds)
+{
+ DEBUGLOG(4, "ZSTD_initDStream");
+ return ZSTD_initDStream_usingDict(zds, NULL, 0);
+}
+
+/* ZSTD_initDStream_usingDDict() :
+ * ddict will just be referenced, and must outlive decompression session
+ * this function cannot fail */
+size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* dctx, const ZSTD_DDict* ddict)
+{
+ size_t const initResult = ZSTD_initDStream(dctx);
+ dctx->ddict = ddict;
+ return initResult;
+}
+
+/* ZSTD_resetDStream() :
+ * return : expected size, aka ZSTD_FRAMEHEADERSIZE_PREFIX.
+ * this function cannot fail */
+size_t ZSTD_resetDStream(ZSTD_DStream* dctx)
+{
+ DEBUGLOG(4, "ZSTD_resetDStream");
+ dctx->streamStage = zdss_loadHeader;
+ dctx->lhSize = dctx->inPos = dctx->outStart = dctx->outEnd = 0;
+ dctx->legacyVersion = 0;
+ dctx->hostageByte = 0;
+ return ZSTD_FRAMEHEADERSIZE_PREFIX;
+}
+
+
+size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict)
+{
+ if (dctx->streamStage != zdss_init) return ERROR(stage_wrong);
+ dctx->ddict = ddict;
+ return 0;
+}
+
+/* ZSTD_DCtx_setMaxWindowSize() :
+ * note : no direct equivalence in ZSTD_DCtx_setParameter,
+ * since this version sets windowSize, and the other sets windowLog */
+size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize)
+{
+ ZSTD_bounds const bounds = ZSTD_dParam_getBounds(ZSTD_d_windowLogMax);
+ size_t const min = (size_t)1 << bounds.lowerBound;
+ size_t const max = (size_t)1 << bounds.upperBound;
+ if (dctx->streamStage != zdss_init) return ERROR(stage_wrong);
+ if (maxWindowSize < min) return ERROR(parameter_outOfBound);
+ if (maxWindowSize > max) return ERROR(parameter_outOfBound);
+ dctx->maxWindowSize = maxWindowSize;
+ return 0;
+}
+
+size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format)
+{
+ return ZSTD_DCtx_setParameter(dctx, ZSTD_d_format, format);
+}
+
+ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam)
+{
+ ZSTD_bounds bounds = { 0, 0, 0 };
+ switch(dParam) {
+ case ZSTD_d_windowLogMax:
+ bounds.lowerBound = ZSTD_WINDOWLOG_ABSOLUTEMIN;
+ bounds.upperBound = ZSTD_WINDOWLOG_MAX;
+ return bounds;
+ case ZSTD_d_format:
+ bounds.lowerBound = (int)ZSTD_f_zstd1;
+ bounds.upperBound = (int)ZSTD_f_zstd1_magicless;
+ ZSTD_STATIC_ASSERT(ZSTD_f_zstd1 < ZSTD_f_zstd1_magicless);
+ return bounds;
+ default:;
+ }
+ bounds.error = ERROR(parameter_unsupported);
+ return bounds;
+}
+
+/* ZSTD_dParam_withinBounds:
+ * @return 1 if value is within dParam bounds,
+ * 0 otherwise */
+static int ZSTD_dParam_withinBounds(ZSTD_dParameter dParam, int value)
+{
+ ZSTD_bounds const bounds = ZSTD_dParam_getBounds(dParam);
+ if (ZSTD_isError(bounds.error)) return 0;
+ if (value < bounds.lowerBound) return 0;
+ if (value > bounds.upperBound) return 0;
+ return 1;
+}
+
+#define CHECK_DBOUNDS(p,v) { \
+ if (!ZSTD_dParam_withinBounds(p, v)) \
+ return ERROR(parameter_outOfBound); \
+}
+
+size_t ZSTD_DCtx_setParameter(ZSTD_DCtx* dctx, ZSTD_dParameter dParam, int value)
+{
+ if (dctx->streamStage != zdss_init) return ERROR(stage_wrong);
+ switch(dParam) {
+ case ZSTD_d_windowLogMax:
+ CHECK_DBOUNDS(ZSTD_d_windowLogMax, value);
+ dctx->maxWindowSize = ((size_t)1) << value;
+ return 0;
+ case ZSTD_d_format:
+ CHECK_DBOUNDS(ZSTD_d_format, value);
+ dctx->format = (ZSTD_format_e)value;
+ return 0;
+ default:;
+ }
+ return ERROR(parameter_unsupported);
+}
+
+size_t ZSTD_DCtx_reset(ZSTD_DCtx* dctx, ZSTD_ResetDirective reset)
+{
+ if ( (reset == ZSTD_reset_session_only)
+ || (reset == ZSTD_reset_session_and_parameters) ) {
+ (void)ZSTD_initDStream(dctx);
+ }
+ if ( (reset == ZSTD_reset_parameters)
+ || (reset == ZSTD_reset_session_and_parameters) ) {
+ if (dctx->streamStage != zdss_init)
+ return ERROR(stage_wrong);
+ dctx->format = ZSTD_f_zstd1;
+ dctx->maxWindowSize = ZSTD_MAXWINDOWSIZE_DEFAULT;
+ }
+ return 0;
+}
+
+
+size_t ZSTD_sizeof_DStream(const ZSTD_DStream* dctx)
+{
+ return ZSTD_sizeof_DCtx(dctx);
+}
+
+size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize)
+{
+ size_t const blockSize = (size_t) MIN(windowSize, ZSTD_BLOCKSIZE_MAX);
+ unsigned long long const neededRBSize = windowSize + blockSize + (WILDCOPY_OVERLENGTH * 2);
+ unsigned long long const neededSize = MIN(frameContentSize, neededRBSize);
+ size_t const minRBSize = (size_t) neededSize;
+ if ((unsigned long long)minRBSize != neededSize) return ERROR(frameParameter_windowTooLarge);
+ return minRBSize;
+}
+
+size_t ZSTD_estimateDStreamSize(size_t windowSize)
+{
+ size_t const blockSize = MIN(windowSize, ZSTD_BLOCKSIZE_MAX);
+ size_t const inBuffSize = blockSize; /* no block can be larger */
+ size_t const outBuffSize = ZSTD_decodingBufferSize_min(windowSize, ZSTD_CONTENTSIZE_UNKNOWN);
+ return ZSTD_estimateDCtxSize() + inBuffSize + outBuffSize;
+}
+
+size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize)
+{
+ U32 const windowSizeMax = 1U << ZSTD_WINDOWLOG_MAX; /* note : should be user-selectable, but requires an additional parameter (or a dctx) */
+ ZSTD_frameHeader zfh;
+ size_t const err = ZSTD_getFrameHeader(&zfh, src, srcSize);
+ if (ZSTD_isError(err)) return err;
+ if (err>0) return ERROR(srcSize_wrong);
+ if (zfh.windowSize > windowSizeMax)
+ return ERROR(frameParameter_windowTooLarge);
+ return ZSTD_estimateDStreamSize((size_t)zfh.windowSize);
+}
+
+
+/* ***** Decompression ***** */
+
+MEM_STATIC size_t ZSTD_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
+{
+ size_t const length = MIN(dstCapacity, srcSize);
+ memcpy(dst, src, length);
+ return length;
+}
+
+
+size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input)
+{
+ const char* const istart = (const char*)(input->src) + input->pos;
+ const char* const iend = (const char*)(input->src) + input->size;
+ const char* ip = istart;
+ char* const ostart = (char*)(output->dst) + output->pos;
+ char* const oend = (char*)(output->dst) + output->size;
+ char* op = ostart;
+ U32 someMoreWork = 1;
+
+ DEBUGLOG(5, "ZSTD_decompressStream");
+ if (input->pos > input->size) { /* forbidden */
+ DEBUGLOG(5, "in: pos: %u vs size: %u",
+ (U32)input->pos, (U32)input->size);
+ return ERROR(srcSize_wrong);
+ }
+ if (output->pos > output->size) { /* forbidden */
+ DEBUGLOG(5, "out: pos: %u vs size: %u",
+ (U32)output->pos, (U32)output->size);
+ return ERROR(dstSize_tooSmall);
+ }
+ DEBUGLOG(5, "input size : %u", (U32)(input->size - input->pos));
+
+ while (someMoreWork) {
+ switch(zds->streamStage)
+ {
+ case zdss_init :
+ DEBUGLOG(5, "stage zdss_init => transparent reset ");
+ ZSTD_resetDStream(zds); /* transparent reset on starting decoding a new frame */
+ /* fall-through */
+
+ case zdss_loadHeader :
+ DEBUGLOG(5, "stage zdss_loadHeader (srcSize : %u)", (U32)(iend - ip));
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
+ if (zds->legacyVersion) {
+ /* legacy support is incompatible with static dctx */
+ if (zds->staticSize) return ERROR(memory_allocation);
+ { size_t const hint = ZSTD_decompressLegacyStream(zds->legacyContext, zds->legacyVersion, output, input);
+ if (hint==0) zds->streamStage = zdss_init;
+ return hint;
+ } }
+#endif
+ { size_t const hSize = ZSTD_getFrameHeader_advanced(&zds->fParams, zds->headerBuffer, zds->lhSize, zds->format);
+ DEBUGLOG(5, "header size : %u", (U32)hSize);
+ if (ZSTD_isError(hSize)) {
+#if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT>=1)
+ U32 const legacyVersion = ZSTD_isLegacy(istart, iend-istart);
+ if (legacyVersion) {
+ const void* const dict = zds->ddict ? ZSTD_DDict_dictContent(zds->ddict) : NULL;
+ size_t const dictSize = zds->ddict ? ZSTD_DDict_dictSize(zds->ddict) : 0;
+ DEBUGLOG(5, "ZSTD_decompressStream: detected legacy version v0.%u", legacyVersion);
+ /* legacy support is incompatible with static dctx */
+ if (zds->staticSize) return ERROR(memory_allocation);
+ CHECK_F(ZSTD_initLegacyStream(&zds->legacyContext,
+ zds->previousLegacyVersion, legacyVersion,
+ dict, dictSize));
+ zds->legacyVersion = zds->previousLegacyVersion = legacyVersion;
+ { size_t const hint = ZSTD_decompressLegacyStream(zds->legacyContext, legacyVersion, output, input);
+ if (hint==0) zds->streamStage = zdss_init; /* or stay in stage zdss_loadHeader */
+ return hint;
+ } }
+#endif
+ return hSize; /* error */
+ }
+ if (hSize != 0) { /* need more input */
+ size_t const toLoad = hSize - zds->lhSize; /* if hSize!=0, hSize > zds->lhSize */
+ size_t const remainingInput = (size_t)(iend-ip);
+ assert(iend >= ip);
+ if (toLoad > remainingInput) { /* not enough input to load full header */
+ if (remainingInput > 0) {
+ memcpy(zds->headerBuffer + zds->lhSize, ip, remainingInput);
+ zds->lhSize += remainingInput;
+ }
+ input->pos = input->size;
+ return (MAX(ZSTD_FRAMEHEADERSIZE_MIN, hSize) - zds->lhSize) + ZSTD_blockHeaderSize; /* remaining header bytes + next block header */
+ }
+ assert(ip != NULL);
+ memcpy(zds->headerBuffer + zds->lhSize, ip, toLoad); zds->lhSize = hSize; ip += toLoad;
+ break;
+ } }
+
+ /* check for single-pass mode opportunity */
+ if (zds->fParams.frameContentSize && zds->fParams.windowSize /* skippable frame if == 0 */
+ && (U64)(size_t)(oend-op) >= zds->fParams.frameContentSize) {
+ size_t const cSize = ZSTD_findFrameCompressedSize(istart, iend-istart);
+ if (cSize <= (size_t)(iend-istart)) {
+ /* shortcut : using single-pass mode */
+ size_t const decompressedSize = ZSTD_decompress_usingDDict(zds, op, oend-op, istart, cSize, zds->ddict);
+ if (ZSTD_isError(decompressedSize)) return decompressedSize;
+ DEBUGLOG(4, "shortcut to single-pass ZSTD_decompress_usingDDict()")
+ ip = istart + cSize;
+ op += decompressedSize;
+ zds->expected = 0;
+ zds->streamStage = zdss_init;
+ someMoreWork = 0;
+ break;
+ } }
+
+ /* Consume header (see ZSTDds_decodeFrameHeader) */
+ DEBUGLOG(4, "Consume header");
+ CHECK_F(ZSTD_decompressBegin_usingDDict(zds, zds->ddict));
+
+ if ((MEM_readLE32(zds->headerBuffer) & ZSTD_MAGIC_SKIPPABLE_MASK) == ZSTD_MAGIC_SKIPPABLE_START) { /* skippable frame */
+ zds->expected = MEM_readLE32(zds->headerBuffer + ZSTD_FRAMEIDSIZE);
+ zds->stage = ZSTDds_skipFrame;
+ } else {
+ CHECK_F(ZSTD_decodeFrameHeader(zds, zds->headerBuffer, zds->lhSize));
+ zds->expected = ZSTD_blockHeaderSize;
+ zds->stage = ZSTDds_decodeBlockHeader;
+ }
+
+ /* control buffer memory usage */
+ DEBUGLOG(4, "Control max memory usage (%u KB <= max %u KB)",
+ (U32)(zds->fParams.windowSize >>10),
+ (U32)(zds->maxWindowSize >> 10) );
+ zds->fParams.windowSize = MAX(zds->fParams.windowSize, 1U << ZSTD_WINDOWLOG_ABSOLUTEMIN);
+ if (zds->fParams.windowSize > zds->maxWindowSize) return ERROR(frameParameter_windowTooLarge);
+
+ /* Adapt buffer sizes to frame header instructions */
+ { size_t const neededInBuffSize = MAX(zds->fParams.blockSizeMax, 4 /* frame checksum */);
+ size_t const neededOutBuffSize = ZSTD_decodingBufferSize_min(zds->fParams.windowSize, zds->fParams.frameContentSize);
+ if ((zds->inBuffSize < neededInBuffSize) || (zds->outBuffSize < neededOutBuffSize)) {
+ size_t const bufferSize = neededInBuffSize + neededOutBuffSize;
+ DEBUGLOG(4, "inBuff : from %u to %u",
+ (U32)zds->inBuffSize, (U32)neededInBuffSize);
+ DEBUGLOG(4, "outBuff : from %u to %u",
+ (U32)zds->outBuffSize, (U32)neededOutBuffSize);
+ if (zds->staticSize) { /* static DCtx */
+ DEBUGLOG(4, "staticSize : %u", (U32)zds->staticSize);
+ assert(zds->staticSize >= sizeof(ZSTD_DCtx)); /* controlled at init */
+ if (bufferSize > zds->staticSize - sizeof(ZSTD_DCtx))
+ return ERROR(memory_allocation);
+ } else {
+ ZSTD_free(zds->inBuff, zds->customMem);
+ zds->inBuffSize = 0;
+ zds->outBuffSize = 0;
+ zds->inBuff = (char*)ZSTD_malloc(bufferSize, zds->customMem);
+ if (zds->inBuff == NULL) return ERROR(memory_allocation);
+ }
+ zds->inBuffSize = neededInBuffSize;
+ zds->outBuff = zds->inBuff + zds->inBuffSize;
+ zds->outBuffSize = neededOutBuffSize;
+ } }
+ zds->streamStage = zdss_read;
+ /* fall-through */
+
+ case zdss_read:
+ DEBUGLOG(5, "stage zdss_read");
+ { size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds);
+ DEBUGLOG(5, "neededInSize = %u", (U32)neededInSize);
+ if (neededInSize==0) { /* end of frame */
+ zds->streamStage = zdss_init;
+ someMoreWork = 0;
+ break;
+ }
+ if ((size_t)(iend-ip) >= neededInSize) { /* decode directly from src */
+ int const isSkipFrame = ZSTD_isSkipFrame(zds);
+ size_t const decodedSize = ZSTD_decompressContinue(zds,
+ zds->outBuff + zds->outStart, (isSkipFrame ? 0 : zds->outBuffSize - zds->outStart),
+ ip, neededInSize);
+ if (ZSTD_isError(decodedSize)) return decodedSize;
+ ip += neededInSize;
+ if (!decodedSize && !isSkipFrame) break; /* this was just a header */
+ zds->outEnd = zds->outStart + decodedSize;
+ zds->streamStage = zdss_flush;
+ break;
+ } }
+ if (ip==iend) { someMoreWork = 0; break; } /* no more input */
+ zds->streamStage = zdss_load;
+ /* fall-through */
+
+ case zdss_load:
+ { size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds);
+ size_t const toLoad = neededInSize - zds->inPos;
+ int const isSkipFrame = ZSTD_isSkipFrame(zds);
+ size_t loadedSize;
+ if (isSkipFrame) {
+ loadedSize = MIN(toLoad, (size_t)(iend-ip));
+ } else {
+ if (toLoad > zds->inBuffSize - zds->inPos) return ERROR(corruption_detected); /* should never happen */
+ loadedSize = ZSTD_limitCopy(zds->inBuff + zds->inPos, toLoad, ip, iend-ip);
+ }
+ ip += loadedSize;
+ zds->inPos += loadedSize;
+ if (loadedSize < toLoad) { someMoreWork = 0; break; } /* not enough input, wait for more */
+
+ /* decode loaded input */
+ { size_t const decodedSize = ZSTD_decompressContinue(zds,
+ zds->outBuff + zds->outStart, zds->outBuffSize - zds->outStart,
+ zds->inBuff, neededInSize);
+ if (ZSTD_isError(decodedSize)) return decodedSize;
+ zds->inPos = 0; /* input is consumed */
+ if (!decodedSize && !isSkipFrame) { zds->streamStage = zdss_read; break; } /* this was just a header */
+ zds->outEnd = zds->outStart + decodedSize;
+ } }
+ zds->streamStage = zdss_flush;
+ /* fall-through */
+
+ case zdss_flush:
+ { size_t const toFlushSize = zds->outEnd - zds->outStart;
+ size_t const flushedSize = ZSTD_limitCopy(op, oend-op, zds->outBuff + zds->outStart, toFlushSize);
+ op += flushedSize;
+ zds->outStart += flushedSize;
+ if (flushedSize == toFlushSize) { /* flush completed */
+ zds->streamStage = zdss_read;
+ if ( (zds->outBuffSize < zds->fParams.frameContentSize)
+ && (zds->outStart + zds->fParams.blockSizeMax > zds->outBuffSize) ) {
+ DEBUGLOG(5, "restart filling outBuff from beginning (left:%i, needed:%u)",
+ (int)(zds->outBuffSize - zds->outStart),
+ (U32)zds->fParams.blockSizeMax);
+ zds->outStart = zds->outEnd = 0;
+ }
+ break;
+ } }
+ /* cannot complete flush */
+ someMoreWork = 0;
+ break;
+
+ default:
+ assert(0); /* impossible */
+ return ERROR(GENERIC); /* some compiler require default to do something */
+ } }
+
+ /* result */
+ input->pos = (size_t)(ip - (const char*)(input->src));
+ output->pos = (size_t)(op - (char*)(output->dst));
+ if ((ip==istart) && (op==ostart)) { /* no forward progress */
+ zds->noForwardProgress ++;
+ if (zds->noForwardProgress >= ZSTD_NO_FORWARD_PROGRESS_MAX) {
+ if (op==oend) return ERROR(dstSize_tooSmall);
+ if (ip==iend) return ERROR(srcSize_wrong);
+ assert(0);
+ }
+ } else {
+ zds->noForwardProgress = 0;
+ }
+ { size_t nextSrcSizeHint = ZSTD_nextSrcSizeToDecompress(zds);
+ if (!nextSrcSizeHint) { /* frame fully decoded */
+ if (zds->outEnd == zds->outStart) { /* output fully flushed */
+ if (zds->hostageByte) {
+ if (input->pos >= input->size) {
+ /* can't release hostage (not present) */
+ zds->streamStage = zdss_read;
+ return 1;
+ }
+ input->pos++; /* release hostage */
+ } /* zds->hostageByte */
+ return 0;
+ } /* zds->outEnd == zds->outStart */
+ if (!zds->hostageByte) { /* output not fully flushed; keep last byte as hostage; will be released when all output is flushed */
+ input->pos--; /* note : pos > 0, otherwise, impossible to finish reading last block */
+ zds->hostageByte=1;
+ }
+ return 1;
+ } /* nextSrcSizeHint==0 */
+ nextSrcSizeHint += ZSTD_blockHeaderSize * (ZSTD_nextInputType(zds) == ZSTDnit_block); /* preload header of next block */
+ assert(zds->inPos <= nextSrcSizeHint);
+ nextSrcSizeHint -= zds->inPos; /* part already loaded*/
+ return nextSrcSizeHint;
+ }
+}
+
+size_t ZSTD_decompressStream_simpleArgs (
+ ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity, size_t* dstPos,
+ const void* src, size_t srcSize, size_t* srcPos)
+{
+ ZSTD_outBuffer output = { dst, dstCapacity, *dstPos };
+ ZSTD_inBuffer input = { src, srcSize, *srcPos };
+ /* ZSTD_compress_generic() will check validity of dstPos and srcPos */
+ size_t const cErr = ZSTD_decompressStream(dctx, &output, &input);
+ *dstPos = output.pos;
+ *srcPos = input.pos;
+ return cErr;
+}
diff --git a/Utilities/cmzstd/lib/decompress/zstd_decompress_block.c b/Utilities/cmzstd/lib/decompress/zstd_decompress_block.c
new file mode 100644
index 000000000..32baad9fb
--- /dev/null
+++ b/Utilities/cmzstd/lib/decompress/zstd_decompress_block.c
@@ -0,0 +1,1307 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+/* zstd_decompress_block :
+ * this module takes care of decompressing _compressed_ block */
+
+/*-*******************************************************
+* Dependencies
+*********************************************************/
+#include <string.h> /* memcpy, memmove, memset */
+#include "compiler.h" /* prefetch */
+#include "cpu.h" /* bmi2 */
+#include "mem.h" /* low level memory routines */
+#define FSE_STATIC_LINKING_ONLY
+#include "fse.h"
+#define HUF_STATIC_LINKING_ONLY
+#include "huf.h"
+#include "zstd_internal.h"
+#include "zstd_decompress_internal.h" /* ZSTD_DCtx */
+#include "zstd_ddict.h" /* ZSTD_DDictDictContent */
+#include "zstd_decompress_block.h"
+
+/*_*******************************************************
+* Macros
+**********************************************************/
+
+/* These two optional macros force the use one way or another of the two
+ * ZSTD_decompressSequences implementations. You can't force in both directions
+ * at the same time.
+ */
+#if defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT) && \
+ defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG)
+#error "Cannot force the use of the short and the long ZSTD_decompressSequences variants!"
+#endif
+
+
+/*_*******************************************************
+* Memory operations
+**********************************************************/
+static void ZSTD_copy4(void* dst, const void* src) { memcpy(dst, src, 4); }
+
+
+/*-*************************************************************
+ * Block decoding
+ ***************************************************************/
+
+/*! ZSTD_getcBlockSize() :
+ * Provides the size of compressed block from block header `src` */
+size_t ZSTD_getcBlockSize(const void* src, size_t srcSize,
+ blockProperties_t* bpPtr)
+{
+ if (srcSize < ZSTD_blockHeaderSize) return ERROR(srcSize_wrong);
+ { U32 const cBlockHeader = MEM_readLE24(src);
+ U32 const cSize = cBlockHeader >> 3;
+ bpPtr->lastBlock = cBlockHeader & 1;
+ bpPtr->blockType = (blockType_e)((cBlockHeader >> 1) & 3);
+ bpPtr->origSize = cSize; /* only useful for RLE */
+ if (bpPtr->blockType == bt_rle) return 1;
+ if (bpPtr->blockType == bt_reserved) return ERROR(corruption_detected);
+ return cSize;
+ }
+}
+
+
+/* Hidden declaration for fullbench */
+size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
+ const void* src, size_t srcSize);
+/*! ZSTD_decodeLiteralsBlock() :
+ * @return : nb of bytes read from src (< srcSize )
+ * note : symbol not declared but exposed for fullbench */
+size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
+ const void* src, size_t srcSize) /* note : srcSize < BLOCKSIZE */
+{
+ if (srcSize < MIN_CBLOCK_SIZE) return ERROR(corruption_detected);
+
+ { const BYTE* const istart = (const BYTE*) src;
+ symbolEncodingType_e const litEncType = (symbolEncodingType_e)(istart[0] & 3);
+
+ switch(litEncType)
+ {
+ case set_repeat:
+ if (dctx->litEntropy==0) return ERROR(dictionary_corrupted);
+ /* fall-through */
+
+ case set_compressed:
+ if (srcSize < 5) return ERROR(corruption_detected); /* srcSize >= MIN_CBLOCK_SIZE == 3; here we need up to 5 for case 3 */
+ { size_t lhSize, litSize, litCSize;
+ U32 singleStream=0;
+ U32 const lhlCode = (istart[0] >> 2) & 3;
+ U32 const lhc = MEM_readLE32(istart);
+ size_t hufSuccess;
+ switch(lhlCode)
+ {
+ case 0: case 1: default: /* note : default is impossible, since lhlCode into [0..3] */
+ /* 2 - 2 - 10 - 10 */
+ singleStream = !lhlCode;
+ lhSize = 3;
+ litSize = (lhc >> 4) & 0x3FF;
+ litCSize = (lhc >> 14) & 0x3FF;
+ break;
+ case 2:
+ /* 2 - 2 - 14 - 14 */
+ lhSize = 4;
+ litSize = (lhc >> 4) & 0x3FFF;
+ litCSize = lhc >> 18;
+ break;
+ case 3:
+ /* 2 - 2 - 18 - 18 */
+ lhSize = 5;
+ litSize = (lhc >> 4) & 0x3FFFF;
+ litCSize = (lhc >> 22) + (istart[4] << 10);
+ break;
+ }
+ if (litSize > ZSTD_BLOCKSIZE_MAX) return ERROR(corruption_detected);
+ if (litCSize + lhSize > srcSize) return ERROR(corruption_detected);
+
+ /* prefetch huffman table if cold */
+ if (dctx->ddictIsCold && (litSize > 768 /* heuristic */)) {
+ PREFETCH_AREA(dctx->HUFptr, sizeof(dctx->entropy.hufTable));
+ }
+
+ if (litEncType==set_repeat) {
+ if (singleStream) {
+ hufSuccess = HUF_decompress1X_usingDTable_bmi2(
+ dctx->litBuffer, litSize, istart+lhSize, litCSize,
+ dctx->HUFptr, dctx->bmi2);
+ } else {
+ hufSuccess = HUF_decompress4X_usingDTable_bmi2(
+ dctx->litBuffer, litSize, istart+lhSize, litCSize,
+ dctx->HUFptr, dctx->bmi2);
+ }
+ } else {
+ if (singleStream) {
+#if defined(HUF_FORCE_DECOMPRESS_X2)
+ hufSuccess = HUF_decompress1X_DCtx_wksp(
+ dctx->entropy.hufTable, dctx->litBuffer, litSize,
+ istart+lhSize, litCSize, dctx->workspace,
+ sizeof(dctx->workspace));
+#else
+ hufSuccess = HUF_decompress1X1_DCtx_wksp_bmi2(
+ dctx->entropy.hufTable, dctx->litBuffer, litSize,
+ istart+lhSize, litCSize, dctx->workspace,
+ sizeof(dctx->workspace), dctx->bmi2);
+#endif
+ } else {
+ hufSuccess = HUF_decompress4X_hufOnly_wksp_bmi2(
+ dctx->entropy.hufTable, dctx->litBuffer, litSize,
+ istart+lhSize, litCSize, dctx->workspace,
+ sizeof(dctx->workspace), dctx->bmi2);
+ }
+ }
+
+ if (HUF_isError(hufSuccess)) return ERROR(corruption_detected);
+
+ dctx->litPtr = dctx->litBuffer;
+ dctx->litSize = litSize;
+ dctx->litEntropy = 1;
+ if (litEncType==set_compressed) dctx->HUFptr = dctx->entropy.hufTable;
+ memset(dctx->litBuffer + dctx->litSize, 0, WILDCOPY_OVERLENGTH);
+ return litCSize + lhSize;
+ }
+
+ case set_basic:
+ { size_t litSize, lhSize;
+ U32 const lhlCode = ((istart[0]) >> 2) & 3;
+ switch(lhlCode)
+ {
+ case 0: case 2: default: /* note : default is impossible, since lhlCode into [0..3] */
+ lhSize = 1;
+ litSize = istart[0] >> 3;
+ break;
+ case 1:
+ lhSize = 2;
+ litSize = MEM_readLE16(istart) >> 4;
+ break;
+ case 3:
+ lhSize = 3;
+ litSize = MEM_readLE24(istart) >> 4;
+ break;
+ }
+
+ if (lhSize+litSize+WILDCOPY_OVERLENGTH > srcSize) { /* risk reading beyond src buffer with wildcopy */
+ if (litSize+lhSize > srcSize) return ERROR(corruption_detected);
+ memcpy(dctx->litBuffer, istart+lhSize, litSize);
+ dctx->litPtr = dctx->litBuffer;
+ dctx->litSize = litSize;
+ memset(dctx->litBuffer + dctx->litSize, 0, WILDCOPY_OVERLENGTH);
+ return lhSize+litSize;
+ }
+ /* direct reference into compressed stream */
+ dctx->litPtr = istart+lhSize;
+ dctx->litSize = litSize;
+ return lhSize+litSize;
+ }
+
+ case set_rle:
+ { U32 const lhlCode = ((istart[0]) >> 2) & 3;
+ size_t litSize, lhSize;
+ switch(lhlCode)
+ {
+ case 0: case 2: default: /* note : default is impossible, since lhlCode into [0..3] */
+ lhSize = 1;
+ litSize = istart[0] >> 3;
+ break;
+ case 1:
+ lhSize = 2;
+ litSize = MEM_readLE16(istart) >> 4;
+ break;
+ case 3:
+ lhSize = 3;
+ litSize = MEM_readLE24(istart) >> 4;
+ if (srcSize<4) return ERROR(corruption_detected); /* srcSize >= MIN_CBLOCK_SIZE == 3; here we need lhSize+1 = 4 */
+ break;
+ }
+ if (litSize > ZSTD_BLOCKSIZE_MAX) return ERROR(corruption_detected);
+ memset(dctx->litBuffer, istart[lhSize], litSize + WILDCOPY_OVERLENGTH);
+ dctx->litPtr = dctx->litBuffer;
+ dctx->litSize = litSize;
+ return lhSize+1;
+ }
+ default:
+ return ERROR(corruption_detected); /* impossible */
+ }
+ }
+}
+
+/* Default FSE distribution tables.
+ * These are pre-calculated FSE decoding tables using default distributions as defined in specification :
+ * https://github.com/facebook/zstd/blob/master/doc/zstd_compression_format.md#default-distributions
+ * They were generated programmatically with following method :
+ * - start from default distributions, present in /lib/common/zstd_internal.h
+ * - generate tables normally, using ZSTD_buildFSETable()
+ * - printout the content of tables
+ * - pretify output, report below, test with fuzzer to ensure it's correct */
+
+/* Default FSE distribution table for Literal Lengths */
+static const ZSTD_seqSymbol LL_defaultDTable[(1<<LL_DEFAULTNORMLOG)+1] = {
+ { 1, 1, 1, LL_DEFAULTNORMLOG}, /* header : fastMode, tableLog */
+ /* nextState, nbAddBits, nbBits, baseVal */
+ { 0, 0, 4, 0}, { 16, 0, 4, 0},
+ { 32, 0, 5, 1}, { 0, 0, 5, 3},
+ { 0, 0, 5, 4}, { 0, 0, 5, 6},
+ { 0, 0, 5, 7}, { 0, 0, 5, 9},
+ { 0, 0, 5, 10}, { 0, 0, 5, 12},
+ { 0, 0, 6, 14}, { 0, 1, 5, 16},
+ { 0, 1, 5, 20}, { 0, 1, 5, 22},
+ { 0, 2, 5, 28}, { 0, 3, 5, 32},
+ { 0, 4, 5, 48}, { 32, 6, 5, 64},
+ { 0, 7, 5, 128}, { 0, 8, 6, 256},
+ { 0, 10, 6, 1024}, { 0, 12, 6, 4096},
+ { 32, 0, 4, 0}, { 0, 0, 4, 1},
+ { 0, 0, 5, 2}, { 32, 0, 5, 4},
+ { 0, 0, 5, 5}, { 32, 0, 5, 7},
+ { 0, 0, 5, 8}, { 32, 0, 5, 10},
+ { 0, 0, 5, 11}, { 0, 0, 6, 13},
+ { 32, 1, 5, 16}, { 0, 1, 5, 18},
+ { 32, 1, 5, 22}, { 0, 2, 5, 24},
+ { 32, 3, 5, 32}, { 0, 3, 5, 40},
+ { 0, 6, 4, 64}, { 16, 6, 4, 64},
+ { 32, 7, 5, 128}, { 0, 9, 6, 512},
+ { 0, 11, 6, 2048}, { 48, 0, 4, 0},
+ { 16, 0, 4, 1}, { 32, 0, 5, 2},
+ { 32, 0, 5, 3}, { 32, 0, 5, 5},
+ { 32, 0, 5, 6}, { 32, 0, 5, 8},
+ { 32, 0, 5, 9}, { 32, 0, 5, 11},
+ { 32, 0, 5, 12}, { 0, 0, 6, 15},
+ { 32, 1, 5, 18}, { 32, 1, 5, 20},
+ { 32, 2, 5, 24}, { 32, 2, 5, 28},
+ { 32, 3, 5, 40}, { 32, 4, 5, 48},
+ { 0, 16, 6,65536}, { 0, 15, 6,32768},
+ { 0, 14, 6,16384}, { 0, 13, 6, 8192},
+}; /* LL_defaultDTable */
+
+/* Default FSE distribution table for Offset Codes */
+static const ZSTD_seqSymbol OF_defaultDTable[(1<<OF_DEFAULTNORMLOG)+1] = {
+ { 1, 1, 1, OF_DEFAULTNORMLOG}, /* header : fastMode, tableLog */
+ /* nextState, nbAddBits, nbBits, baseVal */
+ { 0, 0, 5, 0}, { 0, 6, 4, 61},
+ { 0, 9, 5, 509}, { 0, 15, 5,32765},
+ { 0, 21, 5,2097149}, { 0, 3, 5, 5},
+ { 0, 7, 4, 125}, { 0, 12, 5, 4093},
+ { 0, 18, 5,262141}, { 0, 23, 5,8388605},
+ { 0, 5, 5, 29}, { 0, 8, 4, 253},
+ { 0, 14, 5,16381}, { 0, 20, 5,1048573},
+ { 0, 2, 5, 1}, { 16, 7, 4, 125},
+ { 0, 11, 5, 2045}, { 0, 17, 5,131069},
+ { 0, 22, 5,4194301}, { 0, 4, 5, 13},
+ { 16, 8, 4, 253}, { 0, 13, 5, 8189},
+ { 0, 19, 5,524285}, { 0, 1, 5, 1},
+ { 16, 6, 4, 61}, { 0, 10, 5, 1021},
+ { 0, 16, 5,65533}, { 0, 28, 5,268435453},
+ { 0, 27, 5,134217725}, { 0, 26, 5,67108861},
+ { 0, 25, 5,33554429}, { 0, 24, 5,16777213},
+}; /* OF_defaultDTable */
+
+
+/* Default FSE distribution table for Match Lengths */
+static const ZSTD_seqSymbol ML_defaultDTable[(1<<ML_DEFAULTNORMLOG)+1] = {
+ { 1, 1, 1, ML_DEFAULTNORMLOG}, /* header : fastMode, tableLog */
+ /* nextState, nbAddBits, nbBits, baseVal */
+ { 0, 0, 6, 3}, { 0, 0, 4, 4},
+ { 32, 0, 5, 5}, { 0, 0, 5, 6},
+ { 0, 0, 5, 8}, { 0, 0, 5, 9},
+ { 0, 0, 5, 11}, { 0, 0, 6, 13},
+ { 0, 0, 6, 16}, { 0, 0, 6, 19},
+ { 0, 0, 6, 22}, { 0, 0, 6, 25},
+ { 0, 0, 6, 28}, { 0, 0, 6, 31},
+ { 0, 0, 6, 34}, { 0, 1, 6, 37},
+ { 0, 1, 6, 41}, { 0, 2, 6, 47},
+ { 0, 3, 6, 59}, { 0, 4, 6, 83},
+ { 0, 7, 6, 131}, { 0, 9, 6, 515},
+ { 16, 0, 4, 4}, { 0, 0, 4, 5},
+ { 32, 0, 5, 6}, { 0, 0, 5, 7},
+ { 32, 0, 5, 9}, { 0, 0, 5, 10},
+ { 0, 0, 6, 12}, { 0, 0, 6, 15},
+ { 0, 0, 6, 18}, { 0, 0, 6, 21},
+ { 0, 0, 6, 24}, { 0, 0, 6, 27},
+ { 0, 0, 6, 30}, { 0, 0, 6, 33},
+ { 0, 1, 6, 35}, { 0, 1, 6, 39},
+ { 0, 2, 6, 43}, { 0, 3, 6, 51},
+ { 0, 4, 6, 67}, { 0, 5, 6, 99},
+ { 0, 8, 6, 259}, { 32, 0, 4, 4},
+ { 48, 0, 4, 4}, { 16, 0, 4, 5},
+ { 32, 0, 5, 7}, { 32, 0, 5, 8},
+ { 32, 0, 5, 10}, { 32, 0, 5, 11},
+ { 0, 0, 6, 14}, { 0, 0, 6, 17},
+ { 0, 0, 6, 20}, { 0, 0, 6, 23},
+ { 0, 0, 6, 26}, { 0, 0, 6, 29},
+ { 0, 0, 6, 32}, { 0, 16, 6,65539},
+ { 0, 15, 6,32771}, { 0, 14, 6,16387},
+ { 0, 13, 6, 8195}, { 0, 12, 6, 4099},
+ { 0, 11, 6, 2051}, { 0, 10, 6, 1027},
+}; /* ML_defaultDTable */
+
+
+static void ZSTD_buildSeqTable_rle(ZSTD_seqSymbol* dt, U32 baseValue, U32 nbAddBits)
+{
+ void* ptr = dt;
+ ZSTD_seqSymbol_header* const DTableH = (ZSTD_seqSymbol_header*)ptr;
+ ZSTD_seqSymbol* const cell = dt + 1;
+
+ DTableH->tableLog = 0;
+ DTableH->fastMode = 0;
+
+ cell->nbBits = 0;
+ cell->nextState = 0;
+ assert(nbAddBits < 255);
+ cell->nbAdditionalBits = (BYTE)nbAddBits;
+ cell->baseValue = baseValue;
+}
+
+
+/* ZSTD_buildFSETable() :
+ * generate FSE decoding table for one symbol (ll, ml or off)
+ * cannot fail if input is valid =>
+ * all inputs are presumed validated at this stage */
+void
+ZSTD_buildFSETable(ZSTD_seqSymbol* dt,
+ const short* normalizedCounter, unsigned maxSymbolValue,
+ const U32* baseValue, const U32* nbAdditionalBits,
+ unsigned tableLog)
+{
+ ZSTD_seqSymbol* const tableDecode = dt+1;
+ U16 symbolNext[MaxSeq+1];
+
+ U32 const maxSV1 = maxSymbolValue + 1;
+ U32 const tableSize = 1 << tableLog;
+ U32 highThreshold = tableSize-1;
+
+ /* Sanity Checks */
+ assert(maxSymbolValue <= MaxSeq);
+ assert(tableLog <= MaxFSELog);
+
+ /* Init, lay down lowprob symbols */
+ { ZSTD_seqSymbol_header DTableH;
+ DTableH.tableLog = tableLog;
+ DTableH.fastMode = 1;
+ { S16 const largeLimit= (S16)(1 << (tableLog-1));
+ U32 s;
+ for (s=0; s<maxSV1; s++) {
+ if (normalizedCounter[s]==-1) {
+ tableDecode[highThreshold--].baseValue = s;
+ symbolNext[s] = 1;
+ } else {
+ if (normalizedCounter[s] >= largeLimit) DTableH.fastMode=0;
+ symbolNext[s] = normalizedCounter[s];
+ } } }
+ memcpy(dt, &DTableH, sizeof(DTableH));
+ }
+
+ /* Spread symbols */
+ { U32 const tableMask = tableSize-1;
+ U32 const step = FSE_TABLESTEP(tableSize);
+ U32 s, position = 0;
+ for (s=0; s<maxSV1; s++) {
+ int i;
+ for (i=0; i<normalizedCounter[s]; i++) {
+ tableDecode[position].baseValue = s;
+ position = (position + step) & tableMask;
+ while (position > highThreshold) position = (position + step) & tableMask; /* lowprob area */
+ } }
+ assert(position == 0); /* position must reach all cells once, otherwise normalizedCounter is incorrect */
+ }
+
+ /* Build Decoding table */
+ { U32 u;
+ for (u=0; u<tableSize; u++) {
+ U32 const symbol = tableDecode[u].baseValue;
+ U32 const nextState = symbolNext[symbol]++;
+ tableDecode[u].nbBits = (BYTE) (tableLog - BIT_highbit32(nextState) );
+ tableDecode[u].nextState = (U16) ( (nextState << tableDecode[u].nbBits) - tableSize);
+ assert(nbAdditionalBits[symbol] < 255);
+ tableDecode[u].nbAdditionalBits = (BYTE)nbAdditionalBits[symbol];
+ tableDecode[u].baseValue = baseValue[symbol];
+ } }
+}
+
+
+/*! ZSTD_buildSeqTable() :
+ * @return : nb bytes read from src,
+ * or an error code if it fails */
+static size_t ZSTD_buildSeqTable(ZSTD_seqSymbol* DTableSpace, const ZSTD_seqSymbol** DTablePtr,
+ symbolEncodingType_e type, unsigned max, U32 maxLog,
+ const void* src, size_t srcSize,
+ const U32* baseValue, const U32* nbAdditionalBits,
+ const ZSTD_seqSymbol* defaultTable, U32 flagRepeatTable,
+ int ddictIsCold, int nbSeq)
+{
+ switch(type)
+ {
+ case set_rle :
+ if (!srcSize) return ERROR(srcSize_wrong);
+ if ( (*(const BYTE*)src) > max) return ERROR(corruption_detected);
+ { U32 const symbol = *(const BYTE*)src;
+ U32 const baseline = baseValue[symbol];
+ U32 const nbBits = nbAdditionalBits[symbol];
+ ZSTD_buildSeqTable_rle(DTableSpace, baseline, nbBits);
+ }
+ *DTablePtr = DTableSpace;
+ return 1;
+ case set_basic :
+ *DTablePtr = defaultTable;
+ return 0;
+ case set_repeat:
+ if (!flagRepeatTable) return ERROR(corruption_detected);
+ /* prefetch FSE table if used */
+ if (ddictIsCold && (nbSeq > 24 /* heuristic */)) {
+ const void* const pStart = *DTablePtr;
+ size_t const pSize = sizeof(ZSTD_seqSymbol) * (SEQSYMBOL_TABLE_SIZE(maxLog));
+ PREFETCH_AREA(pStart, pSize);
+ }
+ return 0;
+ case set_compressed :
+ { unsigned tableLog;
+ S16 norm[MaxSeq+1];
+ size_t const headerSize = FSE_readNCount(norm, &max, &tableLog, src, srcSize);
+ if (FSE_isError(headerSize)) return ERROR(corruption_detected);
+ if (tableLog > maxLog) return ERROR(corruption_detected);
+ ZSTD_buildFSETable(DTableSpace, norm, max, baseValue, nbAdditionalBits, tableLog);
+ *DTablePtr = DTableSpace;
+ return headerSize;
+ }
+ default : /* impossible */
+ assert(0);
+ return ERROR(GENERIC);
+ }
+}
+
+size_t ZSTD_decodeSeqHeaders(ZSTD_DCtx* dctx, int* nbSeqPtr,
+ const void* src, size_t srcSize)
+{
+ const BYTE* const istart = (const BYTE* const)src;
+ const BYTE* const iend = istart + srcSize;
+ const BYTE* ip = istart;
+ int nbSeq;
+ DEBUGLOG(5, "ZSTD_decodeSeqHeaders");
+
+ /* check */
+ if (srcSize < MIN_SEQUENCES_SIZE) return ERROR(srcSize_wrong);
+
+ /* SeqHead */
+ nbSeq = *ip++;
+ if (!nbSeq) {
+ *nbSeqPtr=0;
+ if (srcSize != 1) return ERROR(srcSize_wrong);
+ return 1;
+ }
+ if (nbSeq > 0x7F) {
+ if (nbSeq == 0xFF) {
+ if (ip+2 > iend) return ERROR(srcSize_wrong);
+ nbSeq = MEM_readLE16(ip) + LONGNBSEQ, ip+=2;
+ } else {
+ if (ip >= iend) return ERROR(srcSize_wrong);
+ nbSeq = ((nbSeq-0x80)<<8) + *ip++;
+ }
+ }
+ *nbSeqPtr = nbSeq;
+
+ /* FSE table descriptors */
+ if (ip+4 > iend) return ERROR(srcSize_wrong); /* minimum possible size */
+ { symbolEncodingType_e const LLtype = (symbolEncodingType_e)(*ip >> 6);
+ symbolEncodingType_e const OFtype = (symbolEncodingType_e)((*ip >> 4) & 3);
+ symbolEncodingType_e const MLtype = (symbolEncodingType_e)((*ip >> 2) & 3);
+ ip++;
+
+ /* Build DTables */
+ { size_t const llhSize = ZSTD_buildSeqTable(dctx->entropy.LLTable, &dctx->LLTptr,
+ LLtype, MaxLL, LLFSELog,
+ ip, iend-ip,
+ LL_base, LL_bits,
+ LL_defaultDTable, dctx->fseEntropy,
+ dctx->ddictIsCold, nbSeq);
+ if (ZSTD_isError(llhSize)) return ERROR(corruption_detected);
+ ip += llhSize;
+ }
+
+ { size_t const ofhSize = ZSTD_buildSeqTable(dctx->entropy.OFTable, &dctx->OFTptr,
+ OFtype, MaxOff, OffFSELog,
+ ip, iend-ip,
+ OF_base, OF_bits,
+ OF_defaultDTable, dctx->fseEntropy,
+ dctx->ddictIsCold, nbSeq);
+ if (ZSTD_isError(ofhSize)) return ERROR(corruption_detected);
+ ip += ofhSize;
+ }
+
+ { size_t const mlhSize = ZSTD_buildSeqTable(dctx->entropy.MLTable, &dctx->MLTptr,
+ MLtype, MaxML, MLFSELog,
+ ip, iend-ip,
+ ML_base, ML_bits,
+ ML_defaultDTable, dctx->fseEntropy,
+ dctx->ddictIsCold, nbSeq);
+ if (ZSTD_isError(mlhSize)) return ERROR(corruption_detected);
+ ip += mlhSize;
+ }
+ }
+
+ return ip-istart;
+}
+
+
+typedef struct {
+ size_t litLength;
+ size_t matchLength;
+ size_t offset;
+ const BYTE* match;
+} seq_t;
+
+typedef struct {
+ size_t state;
+ const ZSTD_seqSymbol* table;
+} ZSTD_fseState;
+
+typedef struct {
+ BIT_DStream_t DStream;
+ ZSTD_fseState stateLL;
+ ZSTD_fseState stateOffb;
+ ZSTD_fseState stateML;
+ size_t prevOffset[ZSTD_REP_NUM];
+ const BYTE* prefixStart;
+ const BYTE* dictEnd;
+ size_t pos;
+} seqState_t;
+
+
+/* ZSTD_execSequenceLast7():
+ * exceptional case : decompress a match starting within last 7 bytes of output buffer.
+ * requires more careful checks, to ensure there is no overflow.
+ * performance does not matter though.
+ * note : this case is supposed to be never generated "naturally" by reference encoder,
+ * since in most cases it needs at least 8 bytes to look for a match.
+ * but it's allowed by the specification. */
+FORCE_NOINLINE
+size_t ZSTD_execSequenceLast7(BYTE* op,
+ BYTE* const oend, seq_t sequence,
+ const BYTE** litPtr, const BYTE* const litLimit,
+ const BYTE* const base, const BYTE* const vBase, const BYTE* const dictEnd)
+{
+ BYTE* const oLitEnd = op + sequence.litLength;
+ size_t const sequenceLength = sequence.litLength + sequence.matchLength;
+ BYTE* const oMatchEnd = op + sequenceLength; /* risk : address space overflow (32-bits) */
+ const BYTE* const iLitEnd = *litPtr + sequence.litLength;
+ const BYTE* match = oLitEnd - sequence.offset;
+
+ /* check */
+ if (oMatchEnd>oend) return ERROR(dstSize_tooSmall); /* last match must fit within dstBuffer */
+ if (iLitEnd > litLimit) return ERROR(corruption_detected); /* try to read beyond literal buffer */
+
+ /* copy literals */
+ while (op < oLitEnd) *op++ = *(*litPtr)++;
+
+ /* copy Match */
+ if (sequence.offset > (size_t)(oLitEnd - base)) {
+ /* offset beyond prefix */
+ if (sequence.offset > (size_t)(oLitEnd - vBase)) return ERROR(corruption_detected);
+ match = dictEnd - (base-match);
+ if (match + sequence.matchLength <= dictEnd) {
+ memmove(oLitEnd, match, sequence.matchLength);
+ return sequenceLength;
+ }
+ /* span extDict & currentPrefixSegment */
+ { size_t const length1 = dictEnd - match;
+ memmove(oLitEnd, match, length1);
+ op = oLitEnd + length1;
+ sequence.matchLength -= length1;
+ match = base;
+ } }
+ while (op < oMatchEnd) *op++ = *match++;
+ return sequenceLength;
+}
+
+
+HINT_INLINE
+size_t ZSTD_execSequence(BYTE* op,
+ BYTE* const oend, seq_t sequence,
+ const BYTE** litPtr, const BYTE* const litLimit,
+ const BYTE* const prefixStart, const BYTE* const virtualStart, const BYTE* const dictEnd)
+{
+ BYTE* const oLitEnd = op + sequence.litLength;
+ size_t const sequenceLength = sequence.litLength + sequence.matchLength;
+ BYTE* const oMatchEnd = op + sequenceLength; /* risk : address space overflow (32-bits) */
+ BYTE* const oend_w = oend - WILDCOPY_OVERLENGTH;
+ const BYTE* const iLitEnd = *litPtr + sequence.litLength;
+ const BYTE* match = oLitEnd - sequence.offset;
+
+ /* check */
+ if (oMatchEnd>oend) return ERROR(dstSize_tooSmall); /* last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend */
+ if (iLitEnd > litLimit) return ERROR(corruption_detected); /* over-read beyond lit buffer */
+ if (oLitEnd>oend_w) return ZSTD_execSequenceLast7(op, oend, sequence, litPtr, litLimit, prefixStart, virtualStart, dictEnd);
+
+ /* copy Literals */
+ ZSTD_copy8(op, *litPtr);
+ if (sequence.litLength > 8)
+ ZSTD_wildcopy(op+8, (*litPtr)+8, sequence.litLength - 8); /* note : since oLitEnd <= oend-WILDCOPY_OVERLENGTH, no risk of overwrite beyond oend */
+ op = oLitEnd;
+ *litPtr = iLitEnd; /* update for next sequence */
+
+ /* copy Match */
+ if (sequence.offset > (size_t)(oLitEnd - prefixStart)) {
+ /* offset beyond prefix -> go into extDict */
+ if (sequence.offset > (size_t)(oLitEnd - virtualStart))
+ return ERROR(corruption_detected);
+ match = dictEnd + (match - prefixStart);
+ if (match + sequence.matchLength <= dictEnd) {
+ memmove(oLitEnd, match, sequence.matchLength);
+ return sequenceLength;
+ }
+ /* span extDict & currentPrefixSegment */
+ { size_t const length1 = dictEnd - match;
+ memmove(oLitEnd, match, length1);
+ op = oLitEnd + length1;
+ sequence.matchLength -= length1;
+ match = prefixStart;
+ if (op > oend_w || sequence.matchLength < MINMATCH) {
+ U32 i;
+ for (i = 0; i < sequence.matchLength; ++i) op[i] = match[i];
+ return sequenceLength;
+ }
+ } }
+ /* Requirement: op <= oend_w && sequence.matchLength >= MINMATCH */
+
+ /* match within prefix */
+ if (sequence.offset < 8) {
+ /* close range match, overlap */
+ static const U32 dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 }; /* added */
+ static const int dec64table[] = { 8, 8, 8, 7, 8, 9,10,11 }; /* subtracted */
+ int const sub2 = dec64table[sequence.offset];
+ op[0] = match[0];
+ op[1] = match[1];
+ op[2] = match[2];
+ op[3] = match[3];
+ match += dec32table[sequence.offset];
+ ZSTD_copy4(op+4, match);
+ match -= sub2;
+ } else {
+ ZSTD_copy8(op, match);
+ }
+ op += 8; match += 8;
+
+ if (oMatchEnd > oend-(16-MINMATCH)) {
+ if (op < oend_w) {
+ ZSTD_wildcopy(op, match, oend_w - op);
+ match += oend_w - op;
+ op = oend_w;
+ }
+ while (op < oMatchEnd) *op++ = *match++;
+ } else {
+ ZSTD_wildcopy(op, match, (ptrdiff_t)sequence.matchLength-8); /* works even if matchLength < 8 */
+ }
+ return sequenceLength;
+}
+
+
+HINT_INLINE
+size_t ZSTD_execSequenceLong(BYTE* op,
+ BYTE* const oend, seq_t sequence,
+ const BYTE** litPtr, const BYTE* const litLimit,
+ const BYTE* const prefixStart, const BYTE* const dictStart, const BYTE* const dictEnd)
+{
+ BYTE* const oLitEnd = op + sequence.litLength;
+ size_t const sequenceLength = sequence.litLength + sequence.matchLength;
+ BYTE* const oMatchEnd = op + sequenceLength; /* risk : address space overflow (32-bits) */
+ BYTE* const oend_w = oend - WILDCOPY_OVERLENGTH;
+ const BYTE* const iLitEnd = *litPtr + sequence.litLength;
+ const BYTE* match = sequence.match;
+
+ /* check */
+ if (oMatchEnd > oend) return ERROR(dstSize_tooSmall); /* last match must start at a minimum distance of WILDCOPY_OVERLENGTH from oend */
+ if (iLitEnd > litLimit) return ERROR(corruption_detected); /* over-read beyond lit buffer */
+ if (oLitEnd > oend_w) return ZSTD_execSequenceLast7(op, oend, sequence, litPtr, litLimit, prefixStart, dictStart, dictEnd);
+
+ /* copy Literals */
+ ZSTD_copy8(op, *litPtr); /* note : op <= oLitEnd <= oend_w == oend - 8 */
+ if (sequence.litLength > 8)
+ ZSTD_wildcopy(op+8, (*litPtr)+8, sequence.litLength - 8); /* note : since oLitEnd <= oend-WILDCOPY_OVERLENGTH, no risk of overwrite beyond oend */
+ op = oLitEnd;
+ *litPtr = iLitEnd; /* update for next sequence */
+
+ /* copy Match */
+ if (sequence.offset > (size_t)(oLitEnd - prefixStart)) {
+ /* offset beyond prefix */
+ if (sequence.offset > (size_t)(oLitEnd - dictStart)) return ERROR(corruption_detected);
+ if (match + sequence.matchLength <= dictEnd) {
+ memmove(oLitEnd, match, sequence.matchLength);
+ return sequenceLength;
+ }
+ /* span extDict & currentPrefixSegment */
+ { size_t const length1 = dictEnd - match;
+ memmove(oLitEnd, match, length1);
+ op = oLitEnd + length1;
+ sequence.matchLength -= length1;
+ match = prefixStart;
+ if (op > oend_w || sequence.matchLength < MINMATCH) {
+ U32 i;
+ for (i = 0; i < sequence.matchLength; ++i) op[i] = match[i];
+ return sequenceLength;
+ }
+ } }
+ assert(op <= oend_w);
+ assert(sequence.matchLength >= MINMATCH);
+
+ /* match within prefix */
+ if (sequence.offset < 8) {
+ /* close range match, overlap */
+ static const U32 dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 }; /* added */
+ static const int dec64table[] = { 8, 8, 8, 7, 8, 9,10,11 }; /* subtracted */
+ int const sub2 = dec64table[sequence.offset];
+ op[0] = match[0];
+ op[1] = match[1];
+ op[2] = match[2];
+ op[3] = match[3];
+ match += dec32table[sequence.offset];
+ ZSTD_copy4(op+4, match);
+ match -= sub2;
+ } else {
+ ZSTD_copy8(op, match);
+ }
+ op += 8; match += 8;
+
+ if (oMatchEnd > oend-(16-MINMATCH)) {
+ if (op < oend_w) {
+ ZSTD_wildcopy(op, match, oend_w - op);
+ match += oend_w - op;
+ op = oend_w;
+ }
+ while (op < oMatchEnd) *op++ = *match++;
+ } else {
+ ZSTD_wildcopy(op, match, (ptrdiff_t)sequence.matchLength-8); /* works even if matchLength < 8 */
+ }
+ return sequenceLength;
+}
+
+static void
+ZSTD_initFseState(ZSTD_fseState* DStatePtr, BIT_DStream_t* bitD, const ZSTD_seqSymbol* dt)
+{
+ const void* ptr = dt;
+ const ZSTD_seqSymbol_header* const DTableH = (const ZSTD_seqSymbol_header*)ptr;
+ DStatePtr->state = BIT_readBits(bitD, DTableH->tableLog);
+ DEBUGLOG(6, "ZSTD_initFseState : val=%u using %u bits",
+ (U32)DStatePtr->state, DTableH->tableLog);
+ BIT_reloadDStream(bitD);
+ DStatePtr->table = dt + 1;
+}
+
+FORCE_INLINE_TEMPLATE void
+ZSTD_updateFseState(ZSTD_fseState* DStatePtr, BIT_DStream_t* bitD)
+{
+ ZSTD_seqSymbol const DInfo = DStatePtr->table[DStatePtr->state];
+ U32 const nbBits = DInfo.nbBits;
+ size_t const lowBits = BIT_readBits(bitD, nbBits);
+ DStatePtr->state = DInfo.nextState + lowBits;
+}
+
+/* We need to add at most (ZSTD_WINDOWLOG_MAX_32 - 1) bits to read the maximum
+ * offset bits. But we can only read at most (STREAM_ACCUMULATOR_MIN_32 - 1)
+ * bits before reloading. This value is the maximum number of bytes we read
+ * after reloading when we are decoding long offets.
+ */
+#define LONG_OFFSETS_MAX_EXTRA_BITS_32 \
+ (ZSTD_WINDOWLOG_MAX_32 > STREAM_ACCUMULATOR_MIN_32 \
+ ? ZSTD_WINDOWLOG_MAX_32 - STREAM_ACCUMULATOR_MIN_32 \
+ : 0)
+
+typedef enum { ZSTD_lo_isRegularOffset, ZSTD_lo_isLongOffset=1 } ZSTD_longOffset_e;
+
+#ifndef ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG
+FORCE_INLINE_TEMPLATE seq_t
+ZSTD_decodeSequence(seqState_t* seqState, const ZSTD_longOffset_e longOffsets)
+{
+ seq_t seq;
+ U32 const llBits = seqState->stateLL.table[seqState->stateLL.state].nbAdditionalBits;
+ U32 const mlBits = seqState->stateML.table[seqState->stateML.state].nbAdditionalBits;
+ U32 const ofBits = seqState->stateOffb.table[seqState->stateOffb.state].nbAdditionalBits;
+ U32 const totalBits = llBits+mlBits+ofBits;
+ U32 const llBase = seqState->stateLL.table[seqState->stateLL.state].baseValue;
+ U32 const mlBase = seqState->stateML.table[seqState->stateML.state].baseValue;
+ U32 const ofBase = seqState->stateOffb.table[seqState->stateOffb.state].baseValue;
+
+ /* sequence */
+ { size_t offset;
+ if (!ofBits)
+ offset = 0;
+ else {
+ ZSTD_STATIC_ASSERT(ZSTD_lo_isLongOffset == 1);
+ ZSTD_STATIC_ASSERT(LONG_OFFSETS_MAX_EXTRA_BITS_32 == 5);
+ assert(ofBits <= MaxOff);
+ if (MEM_32bits() && longOffsets && (ofBits >= STREAM_ACCUMULATOR_MIN_32)) {
+ U32 const extraBits = ofBits - MIN(ofBits, 32 - seqState->DStream.bitsConsumed);
+ offset = ofBase + (BIT_readBitsFast(&seqState->DStream, ofBits - extraBits) << extraBits);
+ BIT_reloadDStream(&seqState->DStream);
+ if (extraBits) offset += BIT_readBitsFast(&seqState->DStream, extraBits);
+ assert(extraBits <= LONG_OFFSETS_MAX_EXTRA_BITS_32); /* to avoid another reload */
+ } else {
+ offset = ofBase + BIT_readBitsFast(&seqState->DStream, ofBits/*>0*/); /* <= (ZSTD_WINDOWLOG_MAX-1) bits */
+ if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream);
+ }
+ }
+
+ if (ofBits <= 1) {
+ offset += (llBase==0);
+ if (offset) {
+ size_t temp = (offset==3) ? seqState->prevOffset[0] - 1 : seqState->prevOffset[offset];
+ temp += !temp; /* 0 is not valid; input is corrupted; force offset to 1 */
+ if (offset != 1) seqState->prevOffset[2] = seqState->prevOffset[1];
+ seqState->prevOffset[1] = seqState->prevOffset[0];
+ seqState->prevOffset[0] = offset = temp;
+ } else { /* offset == 0 */
+ offset = seqState->prevOffset[0];
+ }
+ } else {
+ seqState->prevOffset[2] = seqState->prevOffset[1];
+ seqState->prevOffset[1] = seqState->prevOffset[0];
+ seqState->prevOffset[0] = offset;
+ }
+ seq.offset = offset;
+ }
+
+ seq.matchLength = mlBase
+ + ((mlBits>0) ? BIT_readBitsFast(&seqState->DStream, mlBits/*>0*/) : 0); /* <= 16 bits */
+ if (MEM_32bits() && (mlBits+llBits >= STREAM_ACCUMULATOR_MIN_32-LONG_OFFSETS_MAX_EXTRA_BITS_32))
+ BIT_reloadDStream(&seqState->DStream);
+ if (MEM_64bits() && (totalBits >= STREAM_ACCUMULATOR_MIN_64-(LLFSELog+MLFSELog+OffFSELog)))
+ BIT_reloadDStream(&seqState->DStream);
+ /* Ensure there are enough bits to read the rest of data in 64-bit mode. */
+ ZSTD_STATIC_ASSERT(16+LLFSELog+MLFSELog+OffFSELog < STREAM_ACCUMULATOR_MIN_64);
+
+ seq.litLength = llBase
+ + ((llBits>0) ? BIT_readBitsFast(&seqState->DStream, llBits/*>0*/) : 0); /* <= 16 bits */
+ if (MEM_32bits())
+ BIT_reloadDStream(&seqState->DStream);
+
+ DEBUGLOG(6, "seq: litL=%u, matchL=%u, offset=%u",
+ (U32)seq.litLength, (U32)seq.matchLength, (U32)seq.offset);
+
+ /* ANS state update */
+ ZSTD_updateFseState(&seqState->stateLL, &seqState->DStream); /* <= 9 bits */
+ ZSTD_updateFseState(&seqState->stateML, &seqState->DStream); /* <= 9 bits */
+ if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream); /* <= 18 bits */
+ ZSTD_updateFseState(&seqState->stateOffb, &seqState->DStream); /* <= 8 bits */
+
+ return seq;
+}
+
+FORCE_INLINE_TEMPLATE size_t
+ZSTD_decompressSequences_body( ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ const BYTE* ip = (const BYTE*)seqStart;
+ const BYTE* const iend = ip + seqSize;
+ BYTE* const ostart = (BYTE* const)dst;
+ BYTE* const oend = ostart + maxDstSize;
+ BYTE* op = ostart;
+ const BYTE* litPtr = dctx->litPtr;
+ const BYTE* const litEnd = litPtr + dctx->litSize;
+ const BYTE* const prefixStart = (const BYTE*) (dctx->prefixStart);
+ const BYTE* const vBase = (const BYTE*) (dctx->virtualStart);
+ const BYTE* const dictEnd = (const BYTE*) (dctx->dictEnd);
+ DEBUGLOG(5, "ZSTD_decompressSequences_body");
+
+ /* Regen sequences */
+ if (nbSeq) {
+ seqState_t seqState;
+ dctx->fseEntropy = 1;
+ { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) seqState.prevOffset[i] = dctx->entropy.rep[i]; }
+ CHECK_E(BIT_initDStream(&seqState.DStream, ip, iend-ip), corruption_detected);
+ ZSTD_initFseState(&seqState.stateLL, &seqState.DStream, dctx->LLTptr);
+ ZSTD_initFseState(&seqState.stateOffb, &seqState.DStream, dctx->OFTptr);
+ ZSTD_initFseState(&seqState.stateML, &seqState.DStream, dctx->MLTptr);
+
+ for ( ; (BIT_reloadDStream(&(seqState.DStream)) <= BIT_DStream_completed) && nbSeq ; ) {
+ nbSeq--;
+ { seq_t const sequence = ZSTD_decodeSequence(&seqState, isLongOffset);
+ size_t const oneSeqSize = ZSTD_execSequence(op, oend, sequence, &litPtr, litEnd, prefixStart, vBase, dictEnd);
+ DEBUGLOG(6, "regenerated sequence size : %u", (U32)oneSeqSize);
+ if (ZSTD_isError(oneSeqSize)) return oneSeqSize;
+ op += oneSeqSize;
+ } }
+
+ /* check if reached exact end */
+ DEBUGLOG(5, "ZSTD_decompressSequences_body: after decode loop, remaining nbSeq : %i", nbSeq);
+ if (nbSeq) return ERROR(corruption_detected);
+ /* save reps for next block */
+ { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) dctx->entropy.rep[i] = (U32)(seqState.prevOffset[i]); }
+ }
+
+ /* last literal segment */
+ { size_t const lastLLSize = litEnd - litPtr;
+ if (lastLLSize > (size_t)(oend-op)) return ERROR(dstSize_tooSmall);
+ memcpy(op, litPtr, lastLLSize);
+ op += lastLLSize;
+ }
+
+ return op-ostart;
+}
+
+static size_t
+ZSTD_decompressSequences_default(ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ return ZSTD_decompressSequences_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+}
+#endif /* ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG */
+
+
+
+#ifndef ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT
+FORCE_INLINE_TEMPLATE seq_t
+ZSTD_decodeSequenceLong(seqState_t* seqState, ZSTD_longOffset_e const longOffsets)
+{
+ seq_t seq;
+ U32 const llBits = seqState->stateLL.table[seqState->stateLL.state].nbAdditionalBits;
+ U32 const mlBits = seqState->stateML.table[seqState->stateML.state].nbAdditionalBits;
+ U32 const ofBits = seqState->stateOffb.table[seqState->stateOffb.state].nbAdditionalBits;
+ U32 const totalBits = llBits+mlBits+ofBits;
+ U32 const llBase = seqState->stateLL.table[seqState->stateLL.state].baseValue;
+ U32 const mlBase = seqState->stateML.table[seqState->stateML.state].baseValue;
+ U32 const ofBase = seqState->stateOffb.table[seqState->stateOffb.state].baseValue;
+
+ /* sequence */
+ { size_t offset;
+ if (!ofBits)
+ offset = 0;
+ else {
+ ZSTD_STATIC_ASSERT(ZSTD_lo_isLongOffset == 1);
+ ZSTD_STATIC_ASSERT(LONG_OFFSETS_MAX_EXTRA_BITS_32 == 5);
+ assert(ofBits <= MaxOff);
+ if (MEM_32bits() && longOffsets) {
+ U32 const extraBits = ofBits - MIN(ofBits, STREAM_ACCUMULATOR_MIN_32-1);
+ offset = ofBase + (BIT_readBitsFast(&seqState->DStream, ofBits - extraBits) << extraBits);
+ if (MEM_32bits() || extraBits) BIT_reloadDStream(&seqState->DStream);
+ if (extraBits) offset += BIT_readBitsFast(&seqState->DStream, extraBits);
+ } else {
+ offset = ofBase + BIT_readBitsFast(&seqState->DStream, ofBits); /* <= (ZSTD_WINDOWLOG_MAX-1) bits */
+ if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream);
+ }
+ }
+
+ if (ofBits <= 1) {
+ offset += (llBase==0);
+ if (offset) {
+ size_t temp = (offset==3) ? seqState->prevOffset[0] - 1 : seqState->prevOffset[offset];
+ temp += !temp; /* 0 is not valid; input is corrupted; force offset to 1 */
+ if (offset != 1) seqState->prevOffset[2] = seqState->prevOffset[1];
+ seqState->prevOffset[1] = seqState->prevOffset[0];
+ seqState->prevOffset[0] = offset = temp;
+ } else {
+ offset = seqState->prevOffset[0];
+ }
+ } else {
+ seqState->prevOffset[2] = seqState->prevOffset[1];
+ seqState->prevOffset[1] = seqState->prevOffset[0];
+ seqState->prevOffset[0] = offset;
+ }
+ seq.offset = offset;
+ }
+
+ seq.matchLength = mlBase + ((mlBits>0) ? BIT_readBitsFast(&seqState->DStream, mlBits) : 0); /* <= 16 bits */
+ if (MEM_32bits() && (mlBits+llBits >= STREAM_ACCUMULATOR_MIN_32-LONG_OFFSETS_MAX_EXTRA_BITS_32))
+ BIT_reloadDStream(&seqState->DStream);
+ if (MEM_64bits() && (totalBits >= STREAM_ACCUMULATOR_MIN_64-(LLFSELog+MLFSELog+OffFSELog)))
+ BIT_reloadDStream(&seqState->DStream);
+ /* Verify that there is enough bits to read the rest of the data in 64-bit mode. */
+ ZSTD_STATIC_ASSERT(16+LLFSELog+MLFSELog+OffFSELog < STREAM_ACCUMULATOR_MIN_64);
+
+ seq.litLength = llBase + ((llBits>0) ? BIT_readBitsFast(&seqState->DStream, llBits) : 0); /* <= 16 bits */
+ if (MEM_32bits())
+ BIT_reloadDStream(&seqState->DStream);
+
+ { size_t const pos = seqState->pos + seq.litLength;
+ const BYTE* const matchBase = (seq.offset > pos) ? seqState->dictEnd : seqState->prefixStart;
+ seq.match = matchBase + pos - seq.offset; /* note : this operation can overflow when seq.offset is really too large, which can only happen when input is corrupted.
+ * No consequence though : no memory access will occur, overly large offset will be detected in ZSTD_execSequenceLong() */
+ seqState->pos = pos + seq.matchLength;
+ }
+
+ /* ANS state update */
+ ZSTD_updateFseState(&seqState->stateLL, &seqState->DStream); /* <= 9 bits */
+ ZSTD_updateFseState(&seqState->stateML, &seqState->DStream); /* <= 9 bits */
+ if (MEM_32bits()) BIT_reloadDStream(&seqState->DStream); /* <= 18 bits */
+ ZSTD_updateFseState(&seqState->stateOffb, &seqState->DStream); /* <= 8 bits */
+
+ return seq;
+}
+
+FORCE_INLINE_TEMPLATE size_t
+ZSTD_decompressSequencesLong_body(
+ ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ const BYTE* ip = (const BYTE*)seqStart;
+ const BYTE* const iend = ip + seqSize;
+ BYTE* const ostart = (BYTE* const)dst;
+ BYTE* const oend = ostart + maxDstSize;
+ BYTE* op = ostart;
+ const BYTE* litPtr = dctx->litPtr;
+ const BYTE* const litEnd = litPtr + dctx->litSize;
+ const BYTE* const prefixStart = (const BYTE*) (dctx->prefixStart);
+ const BYTE* const dictStart = (const BYTE*) (dctx->virtualStart);
+ const BYTE* const dictEnd = (const BYTE*) (dctx->dictEnd);
+
+ /* Regen sequences */
+ if (nbSeq) {
+#define STORED_SEQS 4
+#define STORED_SEQS_MASK (STORED_SEQS-1)
+#define ADVANCED_SEQS 4
+ seq_t sequences[STORED_SEQS];
+ int const seqAdvance = MIN(nbSeq, ADVANCED_SEQS);
+ seqState_t seqState;
+ int seqNb;
+ dctx->fseEntropy = 1;
+ { int i; for (i=0; i<ZSTD_REP_NUM; i++) seqState.prevOffset[i] = dctx->entropy.rep[i]; }
+ seqState.prefixStart = prefixStart;
+ seqState.pos = (size_t)(op-prefixStart);
+ seqState.dictEnd = dictEnd;
+ assert(iend >= ip);
+ CHECK_E(BIT_initDStream(&seqState.DStream, ip, iend-ip), corruption_detected);
+ ZSTD_initFseState(&seqState.stateLL, &seqState.DStream, dctx->LLTptr);
+ ZSTD_initFseState(&seqState.stateOffb, &seqState.DStream, dctx->OFTptr);
+ ZSTD_initFseState(&seqState.stateML, &seqState.DStream, dctx->MLTptr);
+
+ /* prepare in advance */
+ for (seqNb=0; (BIT_reloadDStream(&seqState.DStream) <= BIT_DStream_completed) && (seqNb<seqAdvance); seqNb++) {
+ sequences[seqNb] = ZSTD_decodeSequenceLong(&seqState, isLongOffset);
+ PREFETCH_L1(sequences[seqNb].match); PREFETCH_L1(sequences[seqNb].match + sequences[seqNb].matchLength - 1); /* note : it's safe to invoke PREFETCH() on any memory address, including invalid ones */
+ }
+ if (seqNb<seqAdvance) return ERROR(corruption_detected);
+
+ /* decode and decompress */
+ for ( ; (BIT_reloadDStream(&(seqState.DStream)) <= BIT_DStream_completed) && (seqNb<nbSeq) ; seqNb++) {
+ seq_t const sequence = ZSTD_decodeSequenceLong(&seqState, isLongOffset);
+ size_t const oneSeqSize = ZSTD_execSequenceLong(op, oend, sequences[(seqNb-ADVANCED_SEQS) & STORED_SEQS_MASK], &litPtr, litEnd, prefixStart, dictStart, dictEnd);
+ if (ZSTD_isError(oneSeqSize)) return oneSeqSize;
+ PREFETCH_L1(sequence.match); PREFETCH_L1(sequence.match + sequence.matchLength - 1); /* note : it's safe to invoke PREFETCH() on any memory address, including invalid ones */
+ sequences[seqNb & STORED_SEQS_MASK] = sequence;
+ op += oneSeqSize;
+ }
+ if (seqNb<nbSeq) return ERROR(corruption_detected);
+
+ /* finish queue */
+ seqNb -= seqAdvance;
+ for ( ; seqNb<nbSeq ; seqNb++) {
+ size_t const oneSeqSize = ZSTD_execSequenceLong(op, oend, sequences[seqNb&STORED_SEQS_MASK], &litPtr, litEnd, prefixStart, dictStart, dictEnd);
+ if (ZSTD_isError(oneSeqSize)) return oneSeqSize;
+ op += oneSeqSize;
+ }
+
+ /* save reps for next block */
+ { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) dctx->entropy.rep[i] = (U32)(seqState.prevOffset[i]); }
+ }
+
+ /* last literal segment */
+ { size_t const lastLLSize = litEnd - litPtr;
+ if (lastLLSize > (size_t)(oend-op)) return ERROR(dstSize_tooSmall);
+ memcpy(op, litPtr, lastLLSize);
+ op += lastLLSize;
+ }
+
+ return op-ostart;
+}
+
+static size_t
+ZSTD_decompressSequencesLong_default(ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ return ZSTD_decompressSequencesLong_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+}
+#endif /* ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT */
+
+
+
+#if DYNAMIC_BMI2
+
+#ifndef ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG
+static TARGET_ATTRIBUTE("bmi2") size_t
+ZSTD_decompressSequences_bmi2(ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ return ZSTD_decompressSequences_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+}
+#endif /* ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG */
+
+#ifndef ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT
+static TARGET_ATTRIBUTE("bmi2") size_t
+ZSTD_decompressSequencesLong_bmi2(ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ return ZSTD_decompressSequencesLong_body(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+}
+#endif /* ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT */
+
+#endif /* DYNAMIC_BMI2 */
+
+typedef size_t (*ZSTD_decompressSequences_t)(
+ ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset);
+
+#ifndef ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG
+static size_t
+ZSTD_decompressSequences(ZSTD_DCtx* dctx, void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ DEBUGLOG(5, "ZSTD_decompressSequences");
+#if DYNAMIC_BMI2
+ if (dctx->bmi2) {
+ return ZSTD_decompressSequences_bmi2(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+ }
+#endif
+ return ZSTD_decompressSequences_default(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+}
+#endif /* ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG */
+
+
+#ifndef ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT
+/* ZSTD_decompressSequencesLong() :
+ * decompression function triggered when a minimum share of offsets is considered "long",
+ * aka out of cache.
+ * note : "long" definition seems overloaded here, sometimes meaning "wider than bitstream register", and sometimes mearning "farther than memory cache distance".
+ * This function will try to mitigate main memory latency through the use of prefetching */
+static size_t
+ZSTD_decompressSequencesLong(ZSTD_DCtx* dctx,
+ void* dst, size_t maxDstSize,
+ const void* seqStart, size_t seqSize, int nbSeq,
+ const ZSTD_longOffset_e isLongOffset)
+{
+ DEBUGLOG(5, "ZSTD_decompressSequencesLong");
+#if DYNAMIC_BMI2
+ if (dctx->bmi2) {
+ return ZSTD_decompressSequencesLong_bmi2(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+ }
+#endif
+ return ZSTD_decompressSequencesLong_default(dctx, dst, maxDstSize, seqStart, seqSize, nbSeq, isLongOffset);
+}
+#endif /* ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT */
+
+
+
+#if !defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT) && \
+ !defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG)
+/* ZSTD_getLongOffsetsShare() :
+ * condition : offTable must be valid
+ * @return : "share" of long offsets (arbitrarily defined as > (1<<23))
+ * compared to maximum possible of (1<<OffFSELog) */
+static unsigned
+ZSTD_getLongOffsetsShare(const ZSTD_seqSymbol* offTable)
+{
+ const void* ptr = offTable;
+ U32 const tableLog = ((const ZSTD_seqSymbol_header*)ptr)[0].tableLog;
+ const ZSTD_seqSymbol* table = offTable + 1;
+ U32 const max = 1 << tableLog;
+ U32 u, total = 0;
+ DEBUGLOG(5, "ZSTD_getLongOffsetsShare: (tableLog=%u)", tableLog);
+
+ assert(max <= (1 << OffFSELog)); /* max not too large */
+ for (u=0; u<max; u++) {
+ if (table[u].nbAdditionalBits > 22) total += 1;
+ }
+
+ assert(tableLog <= OffFSELog);
+ total <<= (OffFSELog - tableLog); /* scale to OffFSELog */
+
+ return total;
+}
+#endif
+
+
+size_t
+ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize, const int frame)
+{ /* blockType == blockCompressed */
+ const BYTE* ip = (const BYTE*)src;
+ /* isLongOffset must be true if there are long offsets.
+ * Offsets are long if they are larger than 2^STREAM_ACCUMULATOR_MIN.
+ * We don't expect that to be the case in 64-bit mode.
+ * In block mode, window size is not known, so we have to be conservative.
+ * (note: but it could be evaluated from current-lowLimit)
+ */
+ ZSTD_longOffset_e const isLongOffset = (ZSTD_longOffset_e)(MEM_32bits() && (!frame || (dctx->fParams.windowSize > (1ULL << STREAM_ACCUMULATOR_MIN))));
+ DEBUGLOG(5, "ZSTD_decompressBlock_internal (size : %u)", (U32)srcSize);
+
+ if (srcSize >= ZSTD_BLOCKSIZE_MAX) return ERROR(srcSize_wrong);
+
+ /* Decode literals section */
+ { size_t const litCSize = ZSTD_decodeLiteralsBlock(dctx, src, srcSize);
+ DEBUGLOG(5, "ZSTD_decodeLiteralsBlock : %u", (U32)litCSize);
+ if (ZSTD_isError(litCSize)) return litCSize;
+ ip += litCSize;
+ srcSize -= litCSize;
+ }
+
+ /* Build Decoding Tables */
+ {
+ /* These macros control at build-time which decompressor implementation
+ * we use. If neither is defined, we do some inspection and dispatch at
+ * runtime.
+ */
+#if !defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT) && \
+ !defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG)
+ int usePrefetchDecoder = dctx->ddictIsCold;
+#endif
+ int nbSeq;
+ size_t const seqHSize = ZSTD_decodeSeqHeaders(dctx, &nbSeq, ip, srcSize);
+ if (ZSTD_isError(seqHSize)) return seqHSize;
+ ip += seqHSize;
+ srcSize -= seqHSize;
+
+#if !defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT) && \
+ !defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG)
+ if ( !usePrefetchDecoder
+ && (!frame || (dctx->fParams.windowSize > (1<<24)))
+ && (nbSeq>ADVANCED_SEQS) ) { /* could probably use a larger nbSeq limit */
+ U32 const shareLongOffsets = ZSTD_getLongOffsetsShare(dctx->OFTptr);
+ U32 const minShare = MEM_64bits() ? 7 : 20; /* heuristic values, correspond to 2.73% and 7.81% */
+ usePrefetchDecoder = (shareLongOffsets >= minShare);
+ }
+#endif
+
+ dctx->ddictIsCold = 0;
+
+#if !defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT) && \
+ !defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG)
+ if (usePrefetchDecoder)
+#endif
+#ifndef ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT
+ return ZSTD_decompressSequencesLong(dctx, dst, dstCapacity, ip, srcSize, nbSeq, isLongOffset);
+#endif
+
+#ifndef ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG
+ /* else */
+ return ZSTD_decompressSequences(dctx, dst, dstCapacity, ip, srcSize, nbSeq, isLongOffset);
+#endif
+ }
+}
+
+
+size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize)
+{
+ size_t dSize;
+ ZSTD_checkContinuity(dctx, dst);
+ dSize = ZSTD_decompressBlock_internal(dctx, dst, dstCapacity, src, srcSize, /* frame */ 0);
+ dctx->previousDstEnd = (char*)dst + dSize;
+ return dSize;
+}
diff --git a/Utilities/cmzstd/lib/decompress/zstd_decompress_block.h b/Utilities/cmzstd/lib/decompress/zstd_decompress_block.h
new file mode 100644
index 000000000..7e9296041
--- /dev/null
+++ b/Utilities/cmzstd/lib/decompress/zstd_decompress_block.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+
+#ifndef ZSTD_DEC_BLOCK_H
+#define ZSTD_DEC_BLOCK_H
+
+/*-*******************************************************
+ * Dependencies
+ *********************************************************/
+#include <stddef.h> /* size_t */
+#include "zstd.h" /* DCtx, and some public functions */
+#include "zstd_internal.h" /* blockProperties_t, and some public functions */
+#include "zstd_decompress_internal.h" /* ZSTD_seqSymbol */
+
+
+/* === Prototypes === */
+
+/* note: prototypes already published within `zstd.h` :
+ * ZSTD_decompressBlock()
+ */
+
+/* note: prototypes already published within `zstd_internal.h` :
+ * ZSTD_getcBlockSize()
+ * ZSTD_decodeSeqHeaders()
+ */
+
+
+/* ZSTD_decompressBlock_internal() :
+ * decompress block, starting at `src`,
+ * into destination buffer `dst`.
+ * @return : decompressed block size,
+ * or an error code (which can be tested using ZSTD_isError())
+ */
+size_t ZSTD_decompressBlock_internal(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize, const int frame);
+
+/* ZSTD_buildFSETable() :
+ * generate FSE decoding table for one symbol (ll, ml or off)
+ * this function must be called with valid parameters only
+ * (dt is large enough, normalizedCounter distribution total is a power of 2, max is within range, etc.)
+ * in which case it cannot fail.
+ * Internal use only.
+ */
+void ZSTD_buildFSETable(ZSTD_seqSymbol* dt,
+ const short* normalizedCounter, unsigned maxSymbolValue,
+ const U32* baseValue, const U32* nbAdditionalBits,
+ unsigned tableLog);
+
+
+#endif /* ZSTD_DEC_BLOCK_H */
diff --git a/Utilities/cmzstd/lib/decompress/zstd_decompress_internal.h b/Utilities/cmzstd/lib/decompress/zstd_decompress_internal.h
new file mode 100644
index 000000000..abd003051
--- /dev/null
+++ b/Utilities/cmzstd/lib/decompress/zstd_decompress_internal.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+
+/* zstd_decompress_internal:
+ * objects and definitions shared within lib/decompress modules */
+
+ #ifndef ZSTD_DECOMPRESS_INTERNAL_H
+ #define ZSTD_DECOMPRESS_INTERNAL_H
+
+
+/*-*******************************************************
+ * Dependencies
+ *********************************************************/
+#include "mem.h" /* BYTE, U16, U32 */
+#include "zstd_internal.h" /* ZSTD_seqSymbol */
+
+
+
+/*-*******************************************************
+ * Constants
+ *********************************************************/
+static const U32 LL_base[MaxLL+1] = {
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 18, 20, 22, 24, 28, 32, 40,
+ 48, 64, 0x80, 0x100, 0x200, 0x400, 0x800, 0x1000,
+ 0x2000, 0x4000, 0x8000, 0x10000 };
+
+static const U32 OF_base[MaxOff+1] = {
+ 0, 1, 1, 5, 0xD, 0x1D, 0x3D, 0x7D,
+ 0xFD, 0x1FD, 0x3FD, 0x7FD, 0xFFD, 0x1FFD, 0x3FFD, 0x7FFD,
+ 0xFFFD, 0x1FFFD, 0x3FFFD, 0x7FFFD, 0xFFFFD, 0x1FFFFD, 0x3FFFFD, 0x7FFFFD,
+ 0xFFFFFD, 0x1FFFFFD, 0x3FFFFFD, 0x7FFFFFD, 0xFFFFFFD, 0x1FFFFFFD, 0x3FFFFFFD, 0x7FFFFFFD };
+
+static const U32 OF_bits[MaxOff+1] = {
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31 };
+
+static const U32 ML_base[MaxML+1] = {
+ 3, 4, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 14, 15, 16, 17, 18,
+ 19, 20, 21, 22, 23, 24, 25, 26,
+ 27, 28, 29, 30, 31, 32, 33, 34,
+ 35, 37, 39, 41, 43, 47, 51, 59,
+ 67, 83, 99, 0x83, 0x103, 0x203, 0x403, 0x803,
+ 0x1003, 0x2003, 0x4003, 0x8003, 0x10003 };
+
+
+/*-*******************************************************
+ * Decompression types
+ *********************************************************/
+ typedef struct {
+ U32 fastMode;
+ U32 tableLog;
+ } ZSTD_seqSymbol_header;
+
+ typedef struct {
+ U16 nextState;
+ BYTE nbAdditionalBits;
+ BYTE nbBits;
+ U32 baseValue;
+ } ZSTD_seqSymbol;
+
+ #define SEQSYMBOL_TABLE_SIZE(log) (1 + (1 << (log)))
+
+typedef struct {
+ ZSTD_seqSymbol LLTable[SEQSYMBOL_TABLE_SIZE(LLFSELog)]; /* Note : Space reserved for FSE Tables */
+ ZSTD_seqSymbol OFTable[SEQSYMBOL_TABLE_SIZE(OffFSELog)]; /* is also used as temporary workspace while building hufTable during DDict creation */
+ ZSTD_seqSymbol MLTable[SEQSYMBOL_TABLE_SIZE(MLFSELog)]; /* and therefore must be at least HUF_DECOMPRESS_WORKSPACE_SIZE large */
+ HUF_DTable hufTable[HUF_DTABLE_SIZE(HufLog)]; /* can accommodate HUF_decompress4X */
+ U32 rep[ZSTD_REP_NUM];
+} ZSTD_entropyDTables_t;
+
+typedef enum { ZSTDds_getFrameHeaderSize, ZSTDds_decodeFrameHeader,
+ ZSTDds_decodeBlockHeader, ZSTDds_decompressBlock,
+ ZSTDds_decompressLastBlock, ZSTDds_checkChecksum,
+ ZSTDds_decodeSkippableHeader, ZSTDds_skipFrame } ZSTD_dStage;
+
+typedef enum { zdss_init=0, zdss_loadHeader,
+ zdss_read, zdss_load, zdss_flush } ZSTD_dStreamStage;
+
+struct ZSTD_DCtx_s
+{
+ const ZSTD_seqSymbol* LLTptr;
+ const ZSTD_seqSymbol* MLTptr;
+ const ZSTD_seqSymbol* OFTptr;
+ const HUF_DTable* HUFptr;
+ ZSTD_entropyDTables_t entropy;
+ U32 workspace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; /* space needed when building huffman tables */
+ const void* previousDstEnd; /* detect continuity */
+ const void* prefixStart; /* start of current segment */
+ const void* virtualStart; /* virtual start of previous segment if it was just before current one */
+ const void* dictEnd; /* end of previous segment */
+ size_t expected;
+ ZSTD_frameHeader fParams;
+ U64 decodedSize;
+ blockType_e bType; /* used in ZSTD_decompressContinue(), store blockType between block header decoding and block decompression stages */
+ ZSTD_dStage stage;
+ U32 litEntropy;
+ U32 fseEntropy;
+ XXH64_state_t xxhState;
+ size_t headerSize;
+ ZSTD_format_e format;
+ const BYTE* litPtr;
+ ZSTD_customMem customMem;
+ size_t litSize;
+ size_t rleSize;
+ size_t staticSize;
+ int bmi2; /* == 1 if the CPU supports BMI2 and 0 otherwise. CPU support is determined dynamically once per context lifetime. */
+
+ /* dictionary */
+ ZSTD_DDict* ddictLocal;
+ const ZSTD_DDict* ddict; /* set by ZSTD_initDStream_usingDDict(), or ZSTD_DCtx_refDDict() */
+ U32 dictID;
+ int ddictIsCold; /* if == 1 : dictionary is "new" for working context, and presumed "cold" (not in cpu cache) */
+
+ /* streaming */
+ ZSTD_dStreamStage streamStage;
+ char* inBuff;
+ size_t inBuffSize;
+ size_t inPos;
+ size_t maxWindowSize;
+ char* outBuff;
+ size_t outBuffSize;
+ size_t outStart;
+ size_t outEnd;
+ size_t lhSize;
+ void* legacyContext;
+ U32 previousLegacyVersion;
+ U32 legacyVersion;
+ U32 hostageByte;
+ int noForwardProgress;
+
+ /* workspace */
+ BYTE litBuffer[ZSTD_BLOCKSIZE_MAX + WILDCOPY_OVERLENGTH];
+ BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX];
+}; /* typedef'd to ZSTD_DCtx within "zstd.h" */
+
+
+/*-*******************************************************
+ * Shared internal functions
+ *********************************************************/
+
+/*! ZSTD_loadDEntropy() :
+ * dict : must point at beginning of a valid zstd dictionary.
+ * @return : size of entropy tables read */
+size_t ZSTD_loadDEntropy(ZSTD_entropyDTables_t* entropy,
+ const void* const dict, size_t const dictSize);
+
+/*! ZSTD_checkContinuity() :
+ * check if next `dst` follows previous position, where decompression ended.
+ * If yes, do nothing (continue on current segment).
+ * If not, classify previous segment as "external dictionary", and start a new segment.
+ * This function cannot fail. */
+void ZSTD_checkContinuity(ZSTD_DCtx* dctx, const void* dst);
+
+
+#endif /* ZSTD_DECOMPRESS_INTERNAL_H */
diff --git a/Utilities/cmzstd/lib/deprecated/zbuff.h b/Utilities/cmzstd/lib/deprecated/zbuff.h
new file mode 100644
index 000000000..a93115da4
--- /dev/null
+++ b/Utilities/cmzstd/lib/deprecated/zbuff.h
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+/* ***************************************************************
+* NOTES/WARNINGS
+******************************************************************/
+/* The streaming API defined here is deprecated.
+ * Consider migrating towards ZSTD_compressStream() API in `zstd.h`
+ * See 'lib/README.md'.
+ *****************************************************************/
+
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#ifndef ZSTD_BUFFERED_H_23987
+#define ZSTD_BUFFERED_H_23987
+
+/* *************************************
+* Dependencies
+***************************************/
+#include <stddef.h> /* size_t */
+#include "zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */
+
+
+/* ***************************************************************
+* Compiler specifics
+*****************************************************************/
+/* Deprecation warnings */
+/* Should these warnings be a problem,
+ it is generally possible to disable them,
+ typically with -Wno-deprecated-declarations for gcc
+ or _CRT_SECURE_NO_WARNINGS in Visual.
+ Otherwise, it's also possible to define ZBUFF_DISABLE_DEPRECATE_WARNINGS */
+#ifdef ZBUFF_DISABLE_DEPRECATE_WARNINGS
+# define ZBUFF_DEPRECATED(message) ZSTDLIB_API /* disable deprecation warnings */
+#else
+# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
+# define ZBUFF_DEPRECATED(message) [[deprecated(message)]] ZSTDLIB_API
+# elif (defined(__GNUC__) && (__GNUC__ >= 5)) || defined(__clang__)
+# define ZBUFF_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated(message)))
+# elif defined(__GNUC__) && (__GNUC__ >= 3)
+# define ZBUFF_DEPRECATED(message) ZSTDLIB_API __attribute__((deprecated))
+# elif defined(_MSC_VER)
+# define ZBUFF_DEPRECATED(message) ZSTDLIB_API __declspec(deprecated(message))
+# else
+# pragma message("WARNING: You need to implement ZBUFF_DEPRECATED for this compiler")
+# define ZBUFF_DEPRECATED(message) ZSTDLIB_API
+# endif
+#endif /* ZBUFF_DISABLE_DEPRECATE_WARNINGS */
+
+
+/* *************************************
+* Streaming functions
+***************************************/
+/* This is the easier "buffered" streaming API,
+* using an internal buffer to lift all restrictions on user-provided buffers
+* which can be any size, any place, for both input and output.
+* ZBUFF and ZSTD are 100% interoperable,
+* frames created by one can be decoded by the other one */
+
+typedef ZSTD_CStream ZBUFF_CCtx;
+ZBUFF_DEPRECATED("use ZSTD_createCStream") ZBUFF_CCtx* ZBUFF_createCCtx(void);
+ZBUFF_DEPRECATED("use ZSTD_freeCStream") size_t ZBUFF_freeCCtx(ZBUFF_CCtx* cctx);
+
+ZBUFF_DEPRECATED("use ZSTD_initCStream") size_t ZBUFF_compressInit(ZBUFF_CCtx* cctx, int compressionLevel);
+ZBUFF_DEPRECATED("use ZSTD_initCStream_usingDict") size_t ZBUFF_compressInitDictionary(ZBUFF_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
+
+ZBUFF_DEPRECATED("use ZSTD_compressStream") size_t ZBUFF_compressContinue(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr, const void* src, size_t* srcSizePtr);
+ZBUFF_DEPRECATED("use ZSTD_flushStream") size_t ZBUFF_compressFlush(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr);
+ZBUFF_DEPRECATED("use ZSTD_endStream") size_t ZBUFF_compressEnd(ZBUFF_CCtx* cctx, void* dst, size_t* dstCapacityPtr);
+
+/*-*************************************************
+* Streaming compression - howto
+*
+* A ZBUFF_CCtx object is required to track streaming operation.
+* Use ZBUFF_createCCtx() and ZBUFF_freeCCtx() to create/release resources.
+* ZBUFF_CCtx objects can be reused multiple times.
+*
+* Start by initializing ZBUF_CCtx.
+* Use ZBUFF_compressInit() to start a new compression operation.
+* Use ZBUFF_compressInitDictionary() for a compression which requires a dictionary.
+*
+* Use ZBUFF_compressContinue() repetitively to consume input stream.
+* *srcSizePtr and *dstCapacityPtr can be any size.
+* The function will report how many bytes were read or written within *srcSizePtr and *dstCapacityPtr.
+* Note that it may not consume the entire input, in which case it's up to the caller to present again remaining data.
+* The content of `dst` will be overwritten (up to *dstCapacityPtr) at each call, so save its content if it matters or change @dst .
+* @return : a hint to preferred nb of bytes to use as input for next function call (it's just a hint, to improve latency)
+* or an error code, which can be tested using ZBUFF_isError().
+*
+* At any moment, it's possible to flush whatever data remains within buffer, using ZBUFF_compressFlush().
+* The nb of bytes written into `dst` will be reported into *dstCapacityPtr.
+* Note that the function cannot output more than *dstCapacityPtr,
+* therefore, some content might still be left into internal buffer if *dstCapacityPtr is too small.
+* @return : nb of bytes still present into internal buffer (0 if it's empty)
+* or an error code, which can be tested using ZBUFF_isError().
+*
+* ZBUFF_compressEnd() instructs to finish a frame.
+* It will perform a flush and write frame epilogue.
+* The epilogue is required for decoders to consider a frame completed.
+* Similar to ZBUFF_compressFlush(), it may not be able to output the entire internal buffer content if *dstCapacityPtr is too small.
+* In which case, call again ZBUFF_compressFlush() to complete the flush.
+* @return : nb of bytes still present into internal buffer (0 if it's empty)
+* or an error code, which can be tested using ZBUFF_isError().
+*
+* Hint : _recommended buffer_ sizes (not compulsory) : ZBUFF_recommendedCInSize() / ZBUFF_recommendedCOutSize()
+* input : ZBUFF_recommendedCInSize==128 KB block size is the internal unit, use this value to reduce intermediate stages (better latency)
+* output : ZBUFF_recommendedCOutSize==ZSTD_compressBound(128 KB) + 3 + 3 : ensures it's always possible to write/flush/end a full block. Skip some buffering.
+* By using both, it ensures that input will be entirely consumed, and output will always contain the result, reducing intermediate buffering.
+* **************************************************/
+
+
+typedef ZSTD_DStream ZBUFF_DCtx;
+ZBUFF_DEPRECATED("use ZSTD_createDStream") ZBUFF_DCtx* ZBUFF_createDCtx(void);
+ZBUFF_DEPRECATED("use ZSTD_freeDStream") size_t ZBUFF_freeDCtx(ZBUFF_DCtx* dctx);
+
+ZBUFF_DEPRECATED("use ZSTD_initDStream") size_t ZBUFF_decompressInit(ZBUFF_DCtx* dctx);
+ZBUFF_DEPRECATED("use ZSTD_initDStream_usingDict") size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* dctx, const void* dict, size_t dictSize);
+
+ZBUFF_DEPRECATED("use ZSTD_decompressStream") size_t ZBUFF_decompressContinue(ZBUFF_DCtx* dctx,
+ void* dst, size_t* dstCapacityPtr,
+ const void* src, size_t* srcSizePtr);
+
+/*-***************************************************************************
+* Streaming decompression howto
+*
+* A ZBUFF_DCtx object is required to track streaming operations.
+* Use ZBUFF_createDCtx() and ZBUFF_freeDCtx() to create/release resources.
+* Use ZBUFF_decompressInit() to start a new decompression operation,
+* or ZBUFF_decompressInitDictionary() if decompression requires a dictionary.
+* Note that ZBUFF_DCtx objects can be re-init multiple times.
+*
+* Use ZBUFF_decompressContinue() repetitively to consume your input.
+* *srcSizePtr and *dstCapacityPtr can be any size.
+* The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
+* Note that it may not consume the entire input, in which case it's up to the caller to present remaining input again.
+* The content of `dst` will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters, or change `dst`.
+* @return : 0 when a frame is completely decoded and fully flushed,
+* 1 when there is still some data left within internal buffer to flush,
+* >1 when more data is expected, with value being a suggested next input size (it's just a hint, which helps latency),
+* or an error code, which can be tested using ZBUFF_isError().
+*
+* Hint : recommended buffer sizes (not compulsory) : ZBUFF_recommendedDInSize() and ZBUFF_recommendedDOutSize()
+* output : ZBUFF_recommendedDOutSize== 128 KB block size is the internal unit, it ensures it's always possible to write a full block when decoded.
+* input : ZBUFF_recommendedDInSize == 128KB + 3;
+* just follow indications from ZBUFF_decompressContinue() to minimize latency. It should always be <= 128 KB + 3 .
+* *******************************************************************************/
+
+
+/* *************************************
+* Tool functions
+***************************************/
+ZBUFF_DEPRECATED("use ZSTD_isError") unsigned ZBUFF_isError(size_t errorCode);
+ZBUFF_DEPRECATED("use ZSTD_getErrorName") const char* ZBUFF_getErrorName(size_t errorCode);
+
+/** Functions below provide recommended buffer sizes for Compression or Decompression operations.
+* These sizes are just hints, they tend to offer better latency */
+ZBUFF_DEPRECATED("use ZSTD_CStreamInSize") size_t ZBUFF_recommendedCInSize(void);
+ZBUFF_DEPRECATED("use ZSTD_CStreamOutSize") size_t ZBUFF_recommendedCOutSize(void);
+ZBUFF_DEPRECATED("use ZSTD_DStreamInSize") size_t ZBUFF_recommendedDInSize(void);
+ZBUFF_DEPRECATED("use ZSTD_DStreamOutSize") size_t ZBUFF_recommendedDOutSize(void);
+
+#endif /* ZSTD_BUFFERED_H_23987 */
+
+
+#ifdef ZBUFF_STATIC_LINKING_ONLY
+#ifndef ZBUFF_STATIC_H_30298098432
+#define ZBUFF_STATIC_H_30298098432
+
+/* ====================================================================================
+ * The definitions in this section are considered experimental.
+ * They should never be used in association with a dynamic library, as they may change in the future.
+ * They are provided for advanced usages.
+ * Use them only in association with static linking.
+ * ==================================================================================== */
+
+/*--- Dependency ---*/
+#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_parameters, ZSTD_customMem */
+#include "zstd.h"
+
+
+/*--- Custom memory allocator ---*/
+/*! ZBUFF_createCCtx_advanced() :
+ * Create a ZBUFF compression context using external alloc and free functions */
+ZBUFF_DEPRECATED("use ZSTD_createCStream_advanced") ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem);
+
+/*! ZBUFF_createDCtx_advanced() :
+ * Create a ZBUFF decompression context using external alloc and free functions */
+ZBUFF_DEPRECATED("use ZSTD_createDStream_advanced") ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem);
+
+
+/*--- Advanced Streaming Initialization ---*/
+ZBUFF_DEPRECATED("use ZSTD_initDStream_usingDict") size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
+ const void* dict, size_t dictSize,
+ ZSTD_parameters params, unsigned long long pledgedSrcSize);
+
+
+#endif /* ZBUFF_STATIC_H_30298098432 */
+#endif /* ZBUFF_STATIC_LINKING_ONLY */
+
+
+#if defined (__cplusplus)
+}
+#endif
diff --git a/Utilities/cmzstd/lib/deprecated/zbuff_common.c b/Utilities/cmzstd/lib/deprecated/zbuff_common.c
new file mode 100644
index 000000000..661b9b0e1
--- /dev/null
+++ b/Utilities/cmzstd/lib/deprecated/zbuff_common.c
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+/*-*************************************
+* Dependencies
+***************************************/
+#include "error_private.h"
+#include "zbuff.h"
+
+/*-****************************************
+* ZBUFF Error Management (deprecated)
+******************************************/
+
+/*! ZBUFF_isError() :
+* tells if a return value is an error code */
+unsigned ZBUFF_isError(size_t errorCode) { return ERR_isError(errorCode); }
+/*! ZBUFF_getErrorName() :
+* provides error code string from function result (useful for debugging) */
+const char* ZBUFF_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); }
diff --git a/Utilities/cmzstd/lib/deprecated/zbuff_compress.c b/Utilities/cmzstd/lib/deprecated/zbuff_compress.c
new file mode 100644
index 000000000..f39c60d89
--- /dev/null
+++ b/Utilities/cmzstd/lib/deprecated/zbuff_compress.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+
+
+/* *************************************
+* Dependencies
+***************************************/
+#define ZBUFF_STATIC_LINKING_ONLY
+#include "zbuff.h"
+
+
+/*-***********************************************************
+* Streaming compression
+*
+* A ZBUFF_CCtx object is required to track streaming operation.
+* Use ZBUFF_createCCtx() and ZBUFF_freeCCtx() to create/release resources.
+* Use ZBUFF_compressInit() to start a new compression operation.
+* ZBUFF_CCtx objects can be reused multiple times.
+*
+* Use ZBUFF_compressContinue() repetitively to consume your input.
+* *srcSizePtr and *dstCapacityPtr can be any size.
+* The function will report how many bytes were read or written by modifying *srcSizePtr and *dstCapacityPtr.
+* Note that it may not consume the entire input, in which case it's up to the caller to call again the function with remaining input.
+* The content of dst will be overwritten (up to *dstCapacityPtr) at each function call, so save its content if it matters or change dst .
+* @return : a hint to preferred nb of bytes to use as input for next function call (it's only a hint, to improve latency)
+* or an error code, which can be tested using ZBUFF_isError().
+*
+* ZBUFF_compressFlush() can be used to instruct ZBUFF to compress and output whatever remains within its buffer.
+* Note that it will not output more than *dstCapacityPtr.
+* Therefore, some content might still be left into its internal buffer if dst buffer is too small.
+* @return : nb of bytes still present into internal buffer (0 if it's empty)
+* or an error code, which can be tested using ZBUFF_isError().
+*
+* ZBUFF_compressEnd() instructs to finish a frame.
+* It will perform a flush and write frame epilogue.
+* Similar to ZBUFF_compressFlush(), it may not be able to output the entire internal buffer content if *dstCapacityPtr is too small.
+* @return : nb of bytes still present into internal buffer (0 if it's empty)
+* or an error code, which can be tested using ZBUFF_isError().
+*
+* Hint : recommended buffer sizes (not compulsory)
+* input : ZSTD_BLOCKSIZE_MAX (128 KB), internal unit size, it improves latency to use this value.
+* output : ZSTD_compressBound(ZSTD_BLOCKSIZE_MAX) + ZSTD_blockHeaderSize + ZBUFF_endFrameSize : ensures it's always possible to write/flush/end a full block at best speed.
+* ***********************************************************/
+
+ZBUFF_CCtx* ZBUFF_createCCtx(void)
+{
+ return ZSTD_createCStream();
+}
+
+ZBUFF_CCtx* ZBUFF_createCCtx_advanced(ZSTD_customMem customMem)
+{
+ return ZSTD_createCStream_advanced(customMem);
+}
+
+size_t ZBUFF_freeCCtx(ZBUFF_CCtx* zbc)
+{
+ return ZSTD_freeCStream(zbc);
+}
+
+
+/* ====== Initialization ====== */
+
+size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
+ const void* dict, size_t dictSize,
+ ZSTD_parameters params, unsigned long long pledgedSrcSize)
+{
+ if (pledgedSrcSize==0) pledgedSrcSize = ZSTD_CONTENTSIZE_UNKNOWN; /* preserve "0 == unknown" behavior */
+ return ZSTD_initCStream_advanced(zbc, dict, dictSize, params, pledgedSrcSize);
+}
+
+
+size_t ZBUFF_compressInitDictionary(ZBUFF_CCtx* zbc, const void* dict, size_t dictSize, int compressionLevel)
+{
+ return ZSTD_initCStream_usingDict(zbc, dict, dictSize, compressionLevel);
+}
+
+size_t ZBUFF_compressInit(ZBUFF_CCtx* zbc, int compressionLevel)
+{
+ return ZSTD_initCStream(zbc, compressionLevel);
+}
+
+/* ====== Compression ====== */
+
+
+size_t ZBUFF_compressContinue(ZBUFF_CCtx* zbc,
+ void* dst, size_t* dstCapacityPtr,
+ const void* src, size_t* srcSizePtr)
+{
+ size_t result;
+ ZSTD_outBuffer outBuff;
+ ZSTD_inBuffer inBuff;
+ outBuff.dst = dst;
+ outBuff.pos = 0;
+ outBuff.size = *dstCapacityPtr;
+ inBuff.src = src;
+ inBuff.pos = 0;
+ inBuff.size = *srcSizePtr;
+ result = ZSTD_compressStream(zbc, &outBuff, &inBuff);
+ *dstCapacityPtr = outBuff.pos;
+ *srcSizePtr = inBuff.pos;
+ return result;
+}
+
+
+
+/* ====== Finalize ====== */
+
+size_t ZBUFF_compressFlush(ZBUFF_CCtx* zbc, void* dst, size_t* dstCapacityPtr)
+{
+ size_t result;
+ ZSTD_outBuffer outBuff;
+ outBuff.dst = dst;
+ outBuff.pos = 0;
+ outBuff.size = *dstCapacityPtr;
+ result = ZSTD_flushStream(zbc, &outBuff);
+ *dstCapacityPtr = outBuff.pos;
+ return result;
+}
+
+
+size_t ZBUFF_compressEnd(ZBUFF_CCtx* zbc, void* dst, size_t* dstCapacityPtr)
+{
+ size_t result;
+ ZSTD_outBuffer outBuff;
+ outBuff.dst = dst;
+ outBuff.pos = 0;
+ outBuff.size = *dstCapacityPtr;
+ result = ZSTD_endStream(zbc, &outBuff);
+ *dstCapacityPtr = outBuff.pos;
+ return result;
+}
+
+
+
+/* *************************************
+* Tool functions
+***************************************/
+size_t ZBUFF_recommendedCInSize(void) { return ZSTD_CStreamInSize(); }
+size_t ZBUFF_recommendedCOutSize(void) { return ZSTD_CStreamOutSize(); }
diff --git a/Utilities/cmzstd/lib/deprecated/zbuff_decompress.c b/Utilities/cmzstd/lib/deprecated/zbuff_decompress.c
new file mode 100644
index 000000000..923c22b73
--- /dev/null
+++ b/Utilities/cmzstd/lib/deprecated/zbuff_decompress.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+
+
+/* *************************************
+* Dependencies
+***************************************/
+#define ZBUFF_STATIC_LINKING_ONLY
+#include "zbuff.h"
+
+
+ZBUFF_DCtx* ZBUFF_createDCtx(void)
+{
+ return ZSTD_createDStream();
+}
+
+ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem)
+{
+ return ZSTD_createDStream_advanced(customMem);
+}
+
+size_t ZBUFF_freeDCtx(ZBUFF_DCtx* zbd)
+{
+ return ZSTD_freeDStream(zbd);
+}
+
+
+/* *** Initialization *** */
+
+size_t ZBUFF_decompressInitDictionary(ZBUFF_DCtx* zbd, const void* dict, size_t dictSize)
+{
+ return ZSTD_initDStream_usingDict(zbd, dict, dictSize);
+}
+
+size_t ZBUFF_decompressInit(ZBUFF_DCtx* zbd)
+{
+ return ZSTD_initDStream(zbd);
+}
+
+
+/* *** Decompression *** */
+
+size_t ZBUFF_decompressContinue(ZBUFF_DCtx* zbd,
+ void* dst, size_t* dstCapacityPtr,
+ const void* src, size_t* srcSizePtr)
+{
+ ZSTD_outBuffer outBuff;
+ ZSTD_inBuffer inBuff;
+ size_t result;
+ outBuff.dst = dst;
+ outBuff.pos = 0;
+ outBuff.size = *dstCapacityPtr;
+ inBuff.src = src;
+ inBuff.pos = 0;
+ inBuff.size = *srcSizePtr;
+ result = ZSTD_decompressStream(zbd, &outBuff, &inBuff);
+ *dstCapacityPtr = outBuff.pos;
+ *srcSizePtr = inBuff.pos;
+ return result;
+}
+
+
+/* *************************************
+* Tool functions
+***************************************/
+size_t ZBUFF_recommendedDInSize(void) { return ZSTD_DStreamInSize(); }
+size_t ZBUFF_recommendedDOutSize(void) { return ZSTD_DStreamOutSize(); }
diff --git a/Utilities/cmzstd/lib/dictBuilder/cover.c b/Utilities/cmzstd/lib/dictBuilder/cover.c
new file mode 100644
index 000000000..b55bfb510
--- /dev/null
+++ b/Utilities/cmzstd/lib/dictBuilder/cover.c
@@ -0,0 +1,1081 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+/* *****************************************************************************
+ * Constructs a dictionary using a heuristic based on the following paper:
+ *
+ * Liao, Petri, Moffat, Wirth
+ * Effective Construction of Relative Lempel-Ziv Dictionaries
+ * Published in WWW 2016.
+ *
+ * Adapted from code originally written by @ot (Giuseppe Ottaviano).
+ ******************************************************************************/
+
+/*-*************************************
+* Dependencies
+***************************************/
+#include <stdio.h> /* fprintf */
+#include <stdlib.h> /* malloc, free, qsort */
+#include <string.h> /* memset */
+#include <time.h> /* clock */
+
+#include "mem.h" /* read */
+#include "pool.h"
+#include "threading.h"
+#include "cover.h"
+#include "zstd_internal.h" /* includes zstd.h */
+#ifndef ZDICT_STATIC_LINKING_ONLY
+#define ZDICT_STATIC_LINKING_ONLY
+#endif
+#include "zdict.h"
+
+/*-*************************************
+* Constants
+***************************************/
+#define COVER_MAX_SAMPLES_SIZE (sizeof(size_t) == 8 ? ((unsigned)-1) : ((unsigned)1 GB))
+#define DEFAULT_SPLITPOINT 1.0
+
+/*-*************************************
+* Console display
+***************************************/
+static int g_displayLevel = 2;
+#define DISPLAY(...) \
+ { \
+ fprintf(stderr, __VA_ARGS__); \
+ fflush(stderr); \
+ }
+#define LOCALDISPLAYLEVEL(displayLevel, l, ...) \
+ if (displayLevel >= l) { \
+ DISPLAY(__VA_ARGS__); \
+ } /* 0 : no display; 1: errors; 2: default; 3: details; 4: debug */
+#define DISPLAYLEVEL(l, ...) LOCALDISPLAYLEVEL(g_displayLevel, l, __VA_ARGS__)
+
+#define LOCALDISPLAYUPDATE(displayLevel, l, ...) \
+ if (displayLevel >= l) { \
+ if ((clock() - g_time > refreshRate) || (displayLevel >= 4)) { \
+ g_time = clock(); \
+ DISPLAY(__VA_ARGS__); \
+ } \
+ }
+#define DISPLAYUPDATE(l, ...) LOCALDISPLAYUPDATE(g_displayLevel, l, __VA_ARGS__)
+static const clock_t refreshRate = CLOCKS_PER_SEC * 15 / 100;
+static clock_t g_time = 0;
+
+/*-*************************************
+* Hash table
+***************************************
+* A small specialized hash map for storing activeDmers.
+* The map does not resize, so if it becomes full it will loop forever.
+* Thus, the map must be large enough to store every value.
+* The map implements linear probing and keeps its load less than 0.5.
+*/
+
+#define MAP_EMPTY_VALUE ((U32)-1)
+typedef struct COVER_map_pair_t_s {
+ U32 key;
+ U32 value;
+} COVER_map_pair_t;
+
+typedef struct COVER_map_s {
+ COVER_map_pair_t *data;
+ U32 sizeLog;
+ U32 size;
+ U32 sizeMask;
+} COVER_map_t;
+
+/**
+ * Clear the map.
+ */
+static void COVER_map_clear(COVER_map_t *map) {
+ memset(map->data, MAP_EMPTY_VALUE, map->size * sizeof(COVER_map_pair_t));
+}
+
+/**
+ * Initializes a map of the given size.
+ * Returns 1 on success and 0 on failure.
+ * The map must be destroyed with COVER_map_destroy().
+ * The map is only guaranteed to be large enough to hold size elements.
+ */
+static int COVER_map_init(COVER_map_t *map, U32 size) {
+ map->sizeLog = ZSTD_highbit32(size) + 2;
+ map->size = (U32)1 << map->sizeLog;
+ map->sizeMask = map->size - 1;
+ map->data = (COVER_map_pair_t *)malloc(map->size * sizeof(COVER_map_pair_t));
+ if (!map->data) {
+ map->sizeLog = 0;
+ map->size = 0;
+ return 0;
+ }
+ COVER_map_clear(map);
+ return 1;
+}
+
+/**
+ * Internal hash function
+ */
+static const U32 prime4bytes = 2654435761U;
+static U32 COVER_map_hash(COVER_map_t *map, U32 key) {
+ return (key * prime4bytes) >> (32 - map->sizeLog);
+}
+
+/**
+ * Helper function that returns the index that a key should be placed into.
+ */
+static U32 COVER_map_index(COVER_map_t *map, U32 key) {
+ const U32 hash = COVER_map_hash(map, key);
+ U32 i;
+ for (i = hash;; i = (i + 1) & map->sizeMask) {
+ COVER_map_pair_t *pos = &map->data[i];
+ if (pos->value == MAP_EMPTY_VALUE) {
+ return i;
+ }
+ if (pos->key == key) {
+ return i;
+ }
+ }
+}
+
+/**
+ * Returns the pointer to the value for key.
+ * If key is not in the map, it is inserted and the value is set to 0.
+ * The map must not be full.
+ */
+static U32 *COVER_map_at(COVER_map_t *map, U32 key) {
+ COVER_map_pair_t *pos = &map->data[COVER_map_index(map, key)];
+ if (pos->value == MAP_EMPTY_VALUE) {
+ pos->key = key;
+ pos->value = 0;
+ }
+ return &pos->value;
+}
+
+/**
+ * Deletes key from the map if present.
+ */
+static void COVER_map_remove(COVER_map_t *map, U32 key) {
+ U32 i = COVER_map_index(map, key);
+ COVER_map_pair_t *del = &map->data[i];
+ U32 shift = 1;
+ if (del->value == MAP_EMPTY_VALUE) {
+ return;
+ }
+ for (i = (i + 1) & map->sizeMask;; i = (i + 1) & map->sizeMask) {
+ COVER_map_pair_t *const pos = &map->data[i];
+ /* If the position is empty we are done */
+ if (pos->value == MAP_EMPTY_VALUE) {
+ del->value = MAP_EMPTY_VALUE;
+ return;
+ }
+ /* If pos can be moved to del do so */
+ if (((i - COVER_map_hash(map, pos->key)) & map->sizeMask) >= shift) {
+ del->key = pos->key;
+ del->value = pos->value;
+ del = pos;
+ shift = 1;
+ } else {
+ ++shift;
+ }
+ }
+}
+
+/**
+ * Destroys a map that is inited with COVER_map_init().
+ */
+static void COVER_map_destroy(COVER_map_t *map) {
+ if (map->data) {
+ free(map->data);
+ }
+ map->data = NULL;
+ map->size = 0;
+}
+
+/*-*************************************
+* Context
+***************************************/
+
+typedef struct {
+ const BYTE *samples;
+ size_t *offsets;
+ const size_t *samplesSizes;
+ size_t nbSamples;
+ size_t nbTrainSamples;
+ size_t nbTestSamples;
+ U32 *suffix;
+ size_t suffixSize;
+ U32 *freqs;
+ U32 *dmerAt;
+ unsigned d;
+} COVER_ctx_t;
+
+/* We need a global context for qsort... */
+static COVER_ctx_t *g_ctx = NULL;
+
+/*-*************************************
+* Helper functions
+***************************************/
+
+/**
+ * Returns the sum of the sample sizes.
+ */
+size_t COVER_sum(const size_t *samplesSizes, unsigned nbSamples) {
+ size_t sum = 0;
+ unsigned i;
+ for (i = 0; i < nbSamples; ++i) {
+ sum += samplesSizes[i];
+ }
+ return sum;
+}
+
+/**
+ * Returns -1 if the dmer at lp is less than the dmer at rp.
+ * Return 0 if the dmers at lp and rp are equal.
+ * Returns 1 if the dmer at lp is greater than the dmer at rp.
+ */
+static int COVER_cmp(COVER_ctx_t *ctx, const void *lp, const void *rp) {
+ U32 const lhs = *(U32 const *)lp;
+ U32 const rhs = *(U32 const *)rp;
+ return memcmp(ctx->samples + lhs, ctx->samples + rhs, ctx->d);
+}
+/**
+ * Faster version for d <= 8.
+ */
+static int COVER_cmp8(COVER_ctx_t *ctx, const void *lp, const void *rp) {
+ U64 const mask = (ctx->d == 8) ? (U64)-1 : (((U64)1 << (8 * ctx->d)) - 1);
+ U64 const lhs = MEM_readLE64(ctx->samples + *(U32 const *)lp) & mask;
+ U64 const rhs = MEM_readLE64(ctx->samples + *(U32 const *)rp) & mask;
+ if (lhs < rhs) {
+ return -1;
+ }
+ return (lhs > rhs);
+}
+
+/**
+ * Same as COVER_cmp() except ties are broken by pointer value
+ * NOTE: g_ctx must be set to call this function. A global is required because
+ * qsort doesn't take an opaque pointer.
+ */
+static int COVER_strict_cmp(const void *lp, const void *rp) {
+ int result = COVER_cmp(g_ctx, lp, rp);
+ if (result == 0) {
+ result = lp < rp ? -1 : 1;
+ }
+ return result;
+}
+/**
+ * Faster version for d <= 8.
+ */
+static int COVER_strict_cmp8(const void *lp, const void *rp) {
+ int result = COVER_cmp8(g_ctx, lp, rp);
+ if (result == 0) {
+ result = lp < rp ? -1 : 1;
+ }
+ return result;
+}
+
+/**
+ * Returns the first pointer in [first, last) whose element does not compare
+ * less than value. If no such element exists it returns last.
+ */
+static const size_t *COVER_lower_bound(const size_t *first, const size_t *last,
+ size_t value) {
+ size_t count = last - first;
+ while (count != 0) {
+ size_t step = count / 2;
+ const size_t *ptr = first;
+ ptr += step;
+ if (*ptr < value) {
+ first = ++ptr;
+ count -= step + 1;
+ } else {
+ count = step;
+ }
+ }
+ return first;
+}
+
+/**
+ * Generic groupBy function.
+ * Groups an array sorted by cmp into groups with equivalent values.
+ * Calls grp for each group.
+ */
+static void
+COVER_groupBy(const void *data, size_t count, size_t size, COVER_ctx_t *ctx,
+ int (*cmp)(COVER_ctx_t *, const void *, const void *),
+ void (*grp)(COVER_ctx_t *, const void *, const void *)) {
+ const BYTE *ptr = (const BYTE *)data;
+ size_t num = 0;
+ while (num < count) {
+ const BYTE *grpEnd = ptr + size;
+ ++num;
+ while (num < count && cmp(ctx, ptr, grpEnd) == 0) {
+ grpEnd += size;
+ ++num;
+ }
+ grp(ctx, ptr, grpEnd);
+ ptr = grpEnd;
+ }
+}
+
+/*-*************************************
+* Cover functions
+***************************************/
+
+/**
+ * Called on each group of positions with the same dmer.
+ * Counts the frequency of each dmer and saves it in the suffix array.
+ * Fills `ctx->dmerAt`.
+ */
+static void COVER_group(COVER_ctx_t *ctx, const void *group,
+ const void *groupEnd) {
+ /* The group consists of all the positions with the same first d bytes. */
+ const U32 *grpPtr = (const U32 *)group;
+ const U32 *grpEnd = (const U32 *)groupEnd;
+ /* The dmerId is how we will reference this dmer.
+ * This allows us to map the whole dmer space to a much smaller space, the
+ * size of the suffix array.
+ */
+ const U32 dmerId = (U32)(grpPtr - ctx->suffix);
+ /* Count the number of samples this dmer shows up in */
+ U32 freq = 0;
+ /* Details */
+ const size_t *curOffsetPtr = ctx->offsets;
+ const size_t *offsetsEnd = ctx->offsets + ctx->nbSamples;
+ /* Once *grpPtr >= curSampleEnd this occurrence of the dmer is in a
+ * different sample than the last.
+ */
+ size_t curSampleEnd = ctx->offsets[0];
+ for (; grpPtr != grpEnd; ++grpPtr) {
+ /* Save the dmerId for this position so we can get back to it. */
+ ctx->dmerAt[*grpPtr] = dmerId;
+ /* Dictionaries only help for the first reference to the dmer.
+ * After that zstd can reference the match from the previous reference.
+ * So only count each dmer once for each sample it is in.
+ */
+ if (*grpPtr < curSampleEnd) {
+ continue;
+ }
+ freq += 1;
+ /* Binary search to find the end of the sample *grpPtr is in.
+ * In the common case that grpPtr + 1 == grpEnd we can skip the binary
+ * search because the loop is over.
+ */
+ if (grpPtr + 1 != grpEnd) {
+ const size_t *sampleEndPtr =
+ COVER_lower_bound(curOffsetPtr, offsetsEnd, *grpPtr);
+ curSampleEnd = *sampleEndPtr;
+ curOffsetPtr = sampleEndPtr + 1;
+ }
+ }
+ /* At this point we are never going to look at this segment of the suffix
+ * array again. We take advantage of this fact to save memory.
+ * We store the frequency of the dmer in the first position of the group,
+ * which is dmerId.
+ */
+ ctx->suffix[dmerId] = freq;
+}
+
+
+/**
+ * Selects the best segment in an epoch.
+ * Segments of are scored according to the function:
+ *
+ * Let F(d) be the frequency of dmer d.
+ * Let S_i be the dmer at position i of segment S which has length k.
+ *
+ * Score(S) = F(S_1) + F(S_2) + ... + F(S_{k-d+1})
+ *
+ * Once the dmer d is in the dictionay we set F(d) = 0.
+ */
+static COVER_segment_t COVER_selectSegment(const COVER_ctx_t *ctx, U32 *freqs,
+ COVER_map_t *activeDmers, U32 begin,
+ U32 end,
+ ZDICT_cover_params_t parameters) {
+ /* Constants */
+ const U32 k = parameters.k;
+ const U32 d = parameters.d;
+ const U32 dmersInK = k - d + 1;
+ /* Try each segment (activeSegment) and save the best (bestSegment) */
+ COVER_segment_t bestSegment = {0, 0, 0};
+ COVER_segment_t activeSegment;
+ /* Reset the activeDmers in the segment */
+ COVER_map_clear(activeDmers);
+ /* The activeSegment starts at the beginning of the epoch. */
+ activeSegment.begin = begin;
+ activeSegment.end = begin;
+ activeSegment.score = 0;
+ /* Slide the activeSegment through the whole epoch.
+ * Save the best segment in bestSegment.
+ */
+ while (activeSegment.end < end) {
+ /* The dmerId for the dmer at the next position */
+ U32 newDmer = ctx->dmerAt[activeSegment.end];
+ /* The entry in activeDmers for this dmerId */
+ U32 *newDmerOcc = COVER_map_at(activeDmers, newDmer);
+ /* If the dmer isn't already present in the segment add its score. */
+ if (*newDmerOcc == 0) {
+ /* The paper suggest using the L-0.5 norm, but experiments show that it
+ * doesn't help.
+ */
+ activeSegment.score += freqs[newDmer];
+ }
+ /* Add the dmer to the segment */
+ activeSegment.end += 1;
+ *newDmerOcc += 1;
+
+ /* If the window is now too large, drop the first position */
+ if (activeSegment.end - activeSegment.begin == dmersInK + 1) {
+ U32 delDmer = ctx->dmerAt[activeSegment.begin];
+ U32 *delDmerOcc = COVER_map_at(activeDmers, delDmer);
+ activeSegment.begin += 1;
+ *delDmerOcc -= 1;
+ /* If this is the last occurence of the dmer, subtract its score */
+ if (*delDmerOcc == 0) {
+ COVER_map_remove(activeDmers, delDmer);
+ activeSegment.score -= freqs[delDmer];
+ }
+ }
+
+ /* If this segment is the best so far save it */
+ if (activeSegment.score > bestSegment.score) {
+ bestSegment = activeSegment;
+ }
+ }
+ {
+ /* Trim off the zero frequency head and tail from the segment. */
+ U32 newBegin = bestSegment.end;
+ U32 newEnd = bestSegment.begin;
+ U32 pos;
+ for (pos = bestSegment.begin; pos != bestSegment.end; ++pos) {
+ U32 freq = freqs[ctx->dmerAt[pos]];
+ if (freq != 0) {
+ newBegin = MIN(newBegin, pos);
+ newEnd = pos + 1;
+ }
+ }
+ bestSegment.begin = newBegin;
+ bestSegment.end = newEnd;
+ }
+ {
+ /* Zero out the frequency of each dmer covered by the chosen segment. */
+ U32 pos;
+ for (pos = bestSegment.begin; pos != bestSegment.end; ++pos) {
+ freqs[ctx->dmerAt[pos]] = 0;
+ }
+ }
+ return bestSegment;
+}
+
+/**
+ * Check the validity of the parameters.
+ * Returns non-zero if the parameters are valid and 0 otherwise.
+ */
+static int COVER_checkParameters(ZDICT_cover_params_t parameters,
+ size_t maxDictSize) {
+ /* k and d are required parameters */
+ if (parameters.d == 0 || parameters.k == 0) {
+ return 0;
+ }
+ /* k <= maxDictSize */
+ if (parameters.k > maxDictSize) {
+ return 0;
+ }
+ /* d <= k */
+ if (parameters.d > parameters.k) {
+ return 0;
+ }
+ /* 0 < splitPoint <= 1 */
+ if (parameters.splitPoint <= 0 || parameters.splitPoint > 1){
+ return 0;
+ }
+ return 1;
+}
+
+/**
+ * Clean up a context initialized with `COVER_ctx_init()`.
+ */
+static void COVER_ctx_destroy(COVER_ctx_t *ctx) {
+ if (!ctx) {
+ return;
+ }
+ if (ctx->suffix) {
+ free(ctx->suffix);
+ ctx->suffix = NULL;
+ }
+ if (ctx->freqs) {
+ free(ctx->freqs);
+ ctx->freqs = NULL;
+ }
+ if (ctx->dmerAt) {
+ free(ctx->dmerAt);
+ ctx->dmerAt = NULL;
+ }
+ if (ctx->offsets) {
+ free(ctx->offsets);
+ ctx->offsets = NULL;
+ }
+}
+
+/**
+ * Prepare a context for dictionary building.
+ * The context is only dependent on the parameter `d` and can used multiple
+ * times.
+ * Returns 1 on success or zero on error.
+ * The context must be destroyed with `COVER_ctx_destroy()`.
+ */
+static int COVER_ctx_init(COVER_ctx_t *ctx, const void *samplesBuffer,
+ const size_t *samplesSizes, unsigned nbSamples,
+ unsigned d, double splitPoint) {
+ const BYTE *const samples = (const BYTE *)samplesBuffer;
+ const size_t totalSamplesSize = COVER_sum(samplesSizes, nbSamples);
+ /* Split samples into testing and training sets */
+ const unsigned nbTrainSamples = splitPoint < 1.0 ? (unsigned)((double)nbSamples * splitPoint) : nbSamples;
+ const unsigned nbTestSamples = splitPoint < 1.0 ? nbSamples - nbTrainSamples : nbSamples;
+ const size_t trainingSamplesSize = splitPoint < 1.0 ? COVER_sum(samplesSizes, nbTrainSamples) : totalSamplesSize;
+ const size_t testSamplesSize = splitPoint < 1.0 ? COVER_sum(samplesSizes + nbTrainSamples, nbTestSamples) : totalSamplesSize;
+ /* Checks */
+ if (totalSamplesSize < MAX(d, sizeof(U64)) ||
+ totalSamplesSize >= (size_t)COVER_MAX_SAMPLES_SIZE) {
+ DISPLAYLEVEL(1, "Total samples size is too large (%u MB), maximum size is %u MB\n",
+ (unsigned)(totalSamplesSize>>20), (COVER_MAX_SAMPLES_SIZE >> 20));
+ return 0;
+ }
+ /* Check if there are at least 5 training samples */
+ if (nbTrainSamples < 5) {
+ DISPLAYLEVEL(1, "Total number of training samples is %u and is invalid.", nbTrainSamples);
+ return 0;
+ }
+ /* Check if there's testing sample */
+ if (nbTestSamples < 1) {
+ DISPLAYLEVEL(1, "Total number of testing samples is %u and is invalid.", nbTestSamples);
+ return 0;
+ }
+ /* Zero the context */
+ memset(ctx, 0, sizeof(*ctx));
+ DISPLAYLEVEL(2, "Training on %u samples of total size %u\n", nbTrainSamples,
+ (unsigned)trainingSamplesSize);
+ DISPLAYLEVEL(2, "Testing on %u samples of total size %u\n", nbTestSamples,
+ (unsigned)testSamplesSize);
+ ctx->samples = samples;
+ ctx->samplesSizes = samplesSizes;
+ ctx->nbSamples = nbSamples;
+ ctx->nbTrainSamples = nbTrainSamples;
+ ctx->nbTestSamples = nbTestSamples;
+ /* Partial suffix array */
+ ctx->suffixSize = trainingSamplesSize - MAX(d, sizeof(U64)) + 1;
+ ctx->suffix = (U32 *)malloc(ctx->suffixSize * sizeof(U32));
+ /* Maps index to the dmerID */
+ ctx->dmerAt = (U32 *)malloc(ctx->suffixSize * sizeof(U32));
+ /* The offsets of each file */
+ ctx->offsets = (size_t *)malloc((nbSamples + 1) * sizeof(size_t));
+ if (!ctx->suffix || !ctx->dmerAt || !ctx->offsets) {
+ DISPLAYLEVEL(1, "Failed to allocate scratch buffers\n");
+ COVER_ctx_destroy(ctx);
+ return 0;
+ }
+ ctx->freqs = NULL;
+ ctx->d = d;
+
+ /* Fill offsets from the samplesSizes */
+ {
+ U32 i;
+ ctx->offsets[0] = 0;
+ for (i = 1; i <= nbSamples; ++i) {
+ ctx->offsets[i] = ctx->offsets[i - 1] + samplesSizes[i - 1];
+ }
+ }
+ DISPLAYLEVEL(2, "Constructing partial suffix array\n");
+ {
+ /* suffix is a partial suffix array.
+ * It only sorts suffixes by their first parameters.d bytes.
+ * The sort is stable, so each dmer group is sorted by position in input.
+ */
+ U32 i;
+ for (i = 0; i < ctx->suffixSize; ++i) {
+ ctx->suffix[i] = i;
+ }
+ /* qsort doesn't take an opaque pointer, so pass as a global.
+ * On OpenBSD qsort() is not guaranteed to be stable, their mergesort() is.
+ */
+ g_ctx = ctx;
+#if defined(__OpenBSD__)
+ mergesort(ctx->suffix, ctx->suffixSize, sizeof(U32),
+ (ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp));
+#else
+ qsort(ctx->suffix, ctx->suffixSize, sizeof(U32),
+ (ctx->d <= 8 ? &COVER_strict_cmp8 : &COVER_strict_cmp));
+#endif
+ }
+ DISPLAYLEVEL(2, "Computing frequencies\n");
+ /* For each dmer group (group of positions with the same first d bytes):
+ * 1. For each position we set dmerAt[position] = dmerID. The dmerID is
+ * (groupBeginPtr - suffix). This allows us to go from position to
+ * dmerID so we can look up values in freq.
+ * 2. We calculate how many samples the dmer occurs in and save it in
+ * freqs[dmerId].
+ */
+ COVER_groupBy(ctx->suffix, ctx->suffixSize, sizeof(U32), ctx,
+ (ctx->d <= 8 ? &COVER_cmp8 : &COVER_cmp), &COVER_group);
+ ctx->freqs = ctx->suffix;
+ ctx->suffix = NULL;
+ return 1;
+}
+
+/**
+ * Given the prepared context build the dictionary.
+ */
+static size_t COVER_buildDictionary(const COVER_ctx_t *ctx, U32 *freqs,
+ COVER_map_t *activeDmers, void *dictBuffer,
+ size_t dictBufferCapacity,
+ ZDICT_cover_params_t parameters) {
+ BYTE *const dict = (BYTE *)dictBuffer;
+ size_t tail = dictBufferCapacity;
+ /* Divide the data up into epochs of equal size.
+ * We will select at least one segment from each epoch.
+ */
+ const unsigned epochs = MAX(1, (U32)(dictBufferCapacity / parameters.k / 4));
+ const unsigned epochSize = (U32)(ctx->suffixSize / epochs);
+ size_t epoch;
+ DISPLAYLEVEL(2, "Breaking content into %u epochs of size %u\n",
+ epochs, epochSize);
+ /* Loop through the epochs until there are no more segments or the dictionary
+ * is full.
+ */
+ for (epoch = 0; tail > 0; epoch = (epoch + 1) % epochs) {
+ const U32 epochBegin = (U32)(epoch * epochSize);
+ const U32 epochEnd = epochBegin + epochSize;
+ size_t segmentSize;
+ /* Select a segment */
+ COVER_segment_t segment = COVER_selectSegment(
+ ctx, freqs, activeDmers, epochBegin, epochEnd, parameters);
+ /* If the segment covers no dmers, then we are out of content */
+ if (segment.score == 0) {
+ break;
+ }
+ /* Trim the segment if necessary and if it is too small then we are done */
+ segmentSize = MIN(segment.end - segment.begin + parameters.d - 1, tail);
+ if (segmentSize < parameters.d) {
+ break;
+ }
+ /* We fill the dictionary from the back to allow the best segments to be
+ * referenced with the smallest offsets.
+ */
+ tail -= segmentSize;
+ memcpy(dict + tail, ctx->samples + segment.begin, segmentSize);
+ DISPLAYUPDATE(
+ 2, "\r%u%% ",
+ (unsigned)(((dictBufferCapacity - tail) * 100) / dictBufferCapacity));
+ }
+ DISPLAYLEVEL(2, "\r%79s\r", "");
+ return tail;
+}
+
+ZDICTLIB_API size_t ZDICT_trainFromBuffer_cover(
+ void *dictBuffer, size_t dictBufferCapacity,
+ const void *samplesBuffer, const size_t *samplesSizes, unsigned nbSamples,
+ ZDICT_cover_params_t parameters)
+{
+ BYTE* const dict = (BYTE*)dictBuffer;
+ COVER_ctx_t ctx;
+ COVER_map_t activeDmers;
+ parameters.splitPoint = 1.0;
+ /* Initialize global data */
+ g_displayLevel = parameters.zParams.notificationLevel;
+ /* Checks */
+ if (!COVER_checkParameters(parameters, dictBufferCapacity)) {
+ DISPLAYLEVEL(1, "Cover parameters incorrect\n");
+ return ERROR(GENERIC);
+ }
+ if (nbSamples == 0) {
+ DISPLAYLEVEL(1, "Cover must have at least one input file\n");
+ return ERROR(GENERIC);
+ }
+ if (dictBufferCapacity < ZDICT_DICTSIZE_MIN) {
+ DISPLAYLEVEL(1, "dictBufferCapacity must be at least %u\n",
+ ZDICT_DICTSIZE_MIN);
+ return ERROR(dstSize_tooSmall);
+ }
+ /* Initialize context and activeDmers */
+ if (!COVER_ctx_init(&ctx, samplesBuffer, samplesSizes, nbSamples,
+ parameters.d, parameters.splitPoint)) {
+ return ERROR(GENERIC);
+ }
+ if (!COVER_map_init(&activeDmers, parameters.k - parameters.d + 1)) {
+ DISPLAYLEVEL(1, "Failed to allocate dmer map: out of memory\n");
+ COVER_ctx_destroy(&ctx);
+ return ERROR(GENERIC);
+ }
+
+ DISPLAYLEVEL(2, "Building dictionary\n");
+ {
+ const size_t tail =
+ COVER_buildDictionary(&ctx, ctx.freqs, &activeDmers, dictBuffer,
+ dictBufferCapacity, parameters);
+ const size_t dictionarySize = ZDICT_finalizeDictionary(
+ dict, dictBufferCapacity, dict + tail, dictBufferCapacity - tail,
+ samplesBuffer, samplesSizes, nbSamples, parameters.zParams);
+ if (!ZSTD_isError(dictionarySize)) {
+ DISPLAYLEVEL(2, "Constructed dictionary of size %u\n",
+ (unsigned)dictionarySize);
+ }
+ COVER_ctx_destroy(&ctx);
+ COVER_map_destroy(&activeDmers);
+ return dictionarySize;
+ }
+}
+
+
+
+size_t COVER_checkTotalCompressedSize(const ZDICT_cover_params_t parameters,
+ const size_t *samplesSizes, const BYTE *samples,
+ size_t *offsets,
+ size_t nbTrainSamples, size_t nbSamples,
+ BYTE *const dict, size_t dictBufferCapacity) {
+ size_t totalCompressedSize = ERROR(GENERIC);
+ /* Pointers */
+ ZSTD_CCtx *cctx;
+ ZSTD_CDict *cdict;
+ void *dst;
+ /* Local variables */
+ size_t dstCapacity;
+ size_t i;
+ /* Allocate dst with enough space to compress the maximum sized sample */
+ {
+ size_t maxSampleSize = 0;
+ i = parameters.splitPoint < 1.0 ? nbTrainSamples : 0;
+ for (; i < nbSamples; ++i) {
+ maxSampleSize = MAX(samplesSizes[i], maxSampleSize);
+ }
+ dstCapacity = ZSTD_compressBound(maxSampleSize);
+ dst = malloc(dstCapacity);
+ }
+ /* Create the cctx and cdict */
+ cctx = ZSTD_createCCtx();
+ cdict = ZSTD_createCDict(dict, dictBufferCapacity,
+ parameters.zParams.compressionLevel);
+ if (!dst || !cctx || !cdict) {
+ goto _compressCleanup;
+ }
+ /* Compress each sample and sum their sizes (or error) */
+ totalCompressedSize = dictBufferCapacity;
+ i = parameters.splitPoint < 1.0 ? nbTrainSamples : 0;
+ for (; i < nbSamples; ++i) {
+ const size_t size = ZSTD_compress_usingCDict(
+ cctx, dst, dstCapacity, samples + offsets[i],
+ samplesSizes[i], cdict);
+ if (ZSTD_isError(size)) {
+ totalCompressedSize = ERROR(GENERIC);
+ goto _compressCleanup;
+ }
+ totalCompressedSize += size;
+ }
+_compressCleanup:
+ ZSTD_freeCCtx(cctx);
+ ZSTD_freeCDict(cdict);
+ if (dst) {
+ free(dst);
+ }
+ return totalCompressedSize;
+}
+
+
+/**
+ * Initialize the `COVER_best_t`.
+ */
+void COVER_best_init(COVER_best_t *best) {
+ if (best==NULL) return; /* compatible with init on NULL */
+ (void)ZSTD_pthread_mutex_init(&best->mutex, NULL);
+ (void)ZSTD_pthread_cond_init(&best->cond, NULL);
+ best->liveJobs = 0;
+ best->dict = NULL;
+ best->dictSize = 0;
+ best->compressedSize = (size_t)-1;
+ memset(&best->parameters, 0, sizeof(best->parameters));
+}
+
+/**
+ * Wait until liveJobs == 0.
+ */
+void COVER_best_wait(COVER_best_t *best) {
+ if (!best) {
+ return;
+ }
+ ZSTD_pthread_mutex_lock(&best->mutex);
+ while (best->liveJobs != 0) {
+ ZSTD_pthread_cond_wait(&best->cond, &best->mutex);
+ }
+ ZSTD_pthread_mutex_unlock(&best->mutex);
+}
+
+/**
+ * Call COVER_best_wait() and then destroy the COVER_best_t.
+ */
+void COVER_best_destroy(COVER_best_t *best) {
+ if (!best) {
+ return;
+ }
+ COVER_best_wait(best);
+ if (best->dict) {
+ free(best->dict);
+ }
+ ZSTD_pthread_mutex_destroy(&best->mutex);
+ ZSTD_pthread_cond_destroy(&best->cond);
+}
+
+/**
+ * Called when a thread is about to be launched.
+ * Increments liveJobs.
+ */
+void COVER_best_start(COVER_best_t *best) {
+ if (!best) {
+ return;
+ }
+ ZSTD_pthread_mutex_lock(&best->mutex);
+ ++best->liveJobs;
+ ZSTD_pthread_mutex_unlock(&best->mutex);
+}
+
+/**
+ * Called when a thread finishes executing, both on error or success.
+ * Decrements liveJobs and signals any waiting threads if liveJobs == 0.
+ * If this dictionary is the best so far save it and its parameters.
+ */
+void COVER_best_finish(COVER_best_t *best, size_t compressedSize,
+ ZDICT_cover_params_t parameters, void *dict,
+ size_t dictSize) {
+ if (!best) {
+ return;
+ }
+ {
+ size_t liveJobs;
+ ZSTD_pthread_mutex_lock(&best->mutex);
+ --best->liveJobs;
+ liveJobs = best->liveJobs;
+ /* If the new dictionary is better */
+ if (compressedSize < best->compressedSize) {
+ /* Allocate space if necessary */
+ if (!best->dict || best->dictSize < dictSize) {
+ if (best->dict) {
+ free(best->dict);
+ }
+ best->dict = malloc(dictSize);
+ if (!best->dict) {
+ best->compressedSize = ERROR(GENERIC);
+ best->dictSize = 0;
+ ZSTD_pthread_cond_signal(&best->cond);
+ ZSTD_pthread_mutex_unlock(&best->mutex);
+ return;
+ }
+ }
+ /* Save the dictionary, parameters, and size */
+ memcpy(best->dict, dict, dictSize);
+ best->dictSize = dictSize;
+ best->parameters = parameters;
+ best->compressedSize = compressedSize;
+ }
+ if (liveJobs == 0) {
+ ZSTD_pthread_cond_broadcast(&best->cond);
+ }
+ ZSTD_pthread_mutex_unlock(&best->mutex);
+ }
+}
+
+/**
+ * Parameters for COVER_tryParameters().
+ */
+typedef struct COVER_tryParameters_data_s {
+ const COVER_ctx_t *ctx;
+ COVER_best_t *best;
+ size_t dictBufferCapacity;
+ ZDICT_cover_params_t parameters;
+} COVER_tryParameters_data_t;
+
+/**
+ * Tries a set of parameters and updates the COVER_best_t with the results.
+ * This function is thread safe if zstd is compiled with multithreaded support.
+ * It takes its parameters as an *OWNING* opaque pointer to support threading.
+ */
+static void COVER_tryParameters(void *opaque) {
+ /* Save parameters as local variables */
+ COVER_tryParameters_data_t *const data = (COVER_tryParameters_data_t *)opaque;
+ const COVER_ctx_t *const ctx = data->ctx;
+ const ZDICT_cover_params_t parameters = data->parameters;
+ size_t dictBufferCapacity = data->dictBufferCapacity;
+ size_t totalCompressedSize = ERROR(GENERIC);
+ /* Allocate space for hash table, dict, and freqs */
+ COVER_map_t activeDmers;
+ BYTE *const dict = (BYTE * const)malloc(dictBufferCapacity);
+ U32 *freqs = (U32 *)malloc(ctx->suffixSize * sizeof(U32));
+ if (!COVER_map_init(&activeDmers, parameters.k - parameters.d + 1)) {
+ DISPLAYLEVEL(1, "Failed to allocate dmer map: out of memory\n");
+ goto _cleanup;
+ }
+ if (!dict || !freqs) {
+ DISPLAYLEVEL(1, "Failed to allocate buffers: out of memory\n");
+ goto _cleanup;
+ }
+ /* Copy the frequencies because we need to modify them */
+ memcpy(freqs, ctx->freqs, ctx->suffixSize * sizeof(U32));
+ /* Build the dictionary */
+ {
+ const size_t tail = COVER_buildDictionary(ctx, freqs, &activeDmers, dict,
+ dictBufferCapacity, parameters);
+ dictBufferCapacity = ZDICT_finalizeDictionary(
+ dict, dictBufferCapacity, dict + tail, dictBufferCapacity - tail,
+ ctx->samples, ctx->samplesSizes, (unsigned)ctx->nbTrainSamples,
+ parameters.zParams);
+ if (ZDICT_isError(dictBufferCapacity)) {
+ DISPLAYLEVEL(1, "Failed to finalize dictionary\n");
+ goto _cleanup;
+ }
+ }
+ /* Check total compressed size */
+ totalCompressedSize = COVER_checkTotalCompressedSize(parameters, ctx->samplesSizes,
+ ctx->samples, ctx->offsets,
+ ctx->nbTrainSamples, ctx->nbSamples,
+ dict, dictBufferCapacity);
+
+_cleanup:
+ COVER_best_finish(data->best, totalCompressedSize, parameters, dict,
+ dictBufferCapacity);
+ free(data);
+ COVER_map_destroy(&activeDmers);
+ if (dict) {
+ free(dict);
+ }
+ if (freqs) {
+ free(freqs);
+ }
+}
+
+ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_cover(
+ void *dictBuffer, size_t dictBufferCapacity, const void *samplesBuffer,
+ const size_t *samplesSizes, unsigned nbSamples,
+ ZDICT_cover_params_t *parameters) {
+ /* constants */
+ const unsigned nbThreads = parameters->nbThreads;
+ const double splitPoint =
+ parameters->splitPoint <= 0.0 ? DEFAULT_SPLITPOINT : parameters->splitPoint;
+ const unsigned kMinD = parameters->d == 0 ? 6 : parameters->d;
+ const unsigned kMaxD = parameters->d == 0 ? 8 : parameters->d;
+ const unsigned kMinK = parameters->k == 0 ? 50 : parameters->k;
+ const unsigned kMaxK = parameters->k == 0 ? 2000 : parameters->k;
+ const unsigned kSteps = parameters->steps == 0 ? 40 : parameters->steps;
+ const unsigned kStepSize = MAX((kMaxK - kMinK) / kSteps, 1);
+ const unsigned kIterations =
+ (1 + (kMaxD - kMinD) / 2) * (1 + (kMaxK - kMinK) / kStepSize);
+ /* Local variables */
+ const int displayLevel = parameters->zParams.notificationLevel;
+ unsigned iteration = 1;
+ unsigned d;
+ unsigned k;
+ COVER_best_t best;
+ POOL_ctx *pool = NULL;
+
+ /* Checks */
+ if (splitPoint <= 0 || splitPoint > 1) {
+ LOCALDISPLAYLEVEL(displayLevel, 1, "Incorrect parameters\n");
+ return ERROR(GENERIC);
+ }
+ if (kMinK < kMaxD || kMaxK < kMinK) {
+ LOCALDISPLAYLEVEL(displayLevel, 1, "Incorrect parameters\n");
+ return ERROR(GENERIC);
+ }
+ if (nbSamples == 0) {
+ DISPLAYLEVEL(1, "Cover must have at least one input file\n");
+ return ERROR(GENERIC);
+ }
+ if (dictBufferCapacity < ZDICT_DICTSIZE_MIN) {
+ DISPLAYLEVEL(1, "dictBufferCapacity must be at least %u\n",
+ ZDICT_DICTSIZE_MIN);
+ return ERROR(dstSize_tooSmall);
+ }
+ if (nbThreads > 1) {
+ pool = POOL_create(nbThreads, 1);
+ if (!pool) {
+ return ERROR(memory_allocation);
+ }
+ }
+ /* Initialization */
+ COVER_best_init(&best);
+ /* Turn down global display level to clean up display at level 2 and below */
+ g_displayLevel = displayLevel == 0 ? 0 : displayLevel - 1;
+ /* Loop through d first because each new value needs a new context */
+ LOCALDISPLAYLEVEL(displayLevel, 2, "Trying %u different sets of parameters\n",
+ kIterations);
+ for (d = kMinD; d <= kMaxD; d += 2) {
+ /* Initialize the context for this value of d */
+ COVER_ctx_t ctx;
+ LOCALDISPLAYLEVEL(displayLevel, 3, "d=%u\n", d);
+ if (!COVER_ctx_init(&ctx, samplesBuffer, samplesSizes, nbSamples, d, splitPoint)) {
+ LOCALDISPLAYLEVEL(displayLevel, 1, "Failed to initialize context\n");
+ COVER_best_destroy(&best);
+ POOL_free(pool);
+ return ERROR(GENERIC);
+ }
+ /* Loop through k reusing the same context */
+ for (k = kMinK; k <= kMaxK; k += kStepSize) {
+ /* Prepare the arguments */
+ COVER_tryParameters_data_t *data = (COVER_tryParameters_data_t *)malloc(
+ sizeof(COVER_tryParameters_data_t));
+ LOCALDISPLAYLEVEL(displayLevel, 3, "k=%u\n", k);
+ if (!data) {
+ LOCALDISPLAYLEVEL(displayLevel, 1, "Failed to allocate parameters\n");
+ COVER_best_destroy(&best);
+ COVER_ctx_destroy(&ctx);
+ POOL_free(pool);
+ return ERROR(GENERIC);
+ }
+ data->ctx = &ctx;
+ data->best = &best;
+ data->dictBufferCapacity = dictBufferCapacity;
+ data->parameters = *parameters;
+ data->parameters.k = k;
+ data->parameters.d = d;
+ data->parameters.splitPoint = splitPoint;
+ data->parameters.steps = kSteps;
+ data->parameters.zParams.notificationLevel = g_displayLevel;
+ /* Check the parameters */
+ if (!COVER_checkParameters(data->parameters, dictBufferCapacity)) {
+ DISPLAYLEVEL(1, "Cover parameters incorrect\n");
+ free(data);
+ continue;
+ }
+ /* Call the function and pass ownership of data to it */
+ COVER_best_start(&best);
+ if (pool) {
+ POOL_add(pool, &COVER_tryParameters, data);
+ } else {
+ COVER_tryParameters(data);
+ }
+ /* Print status */
+ LOCALDISPLAYUPDATE(displayLevel, 2, "\r%u%% ",
+ (unsigned)((iteration * 100) / kIterations));
+ ++iteration;
+ }
+ COVER_best_wait(&best);
+ COVER_ctx_destroy(&ctx);
+ }
+ LOCALDISPLAYLEVEL(displayLevel, 2, "\r%79s\r", "");
+ /* Fill the output buffer and parameters with output of the best parameters */
+ {
+ const size_t dictSize = best.dictSize;
+ if (ZSTD_isError(best.compressedSize)) {
+ const size_t compressedSize = best.compressedSize;
+ COVER_best_destroy(&best);
+ POOL_free(pool);
+ return compressedSize;
+ }
+ *parameters = best.parameters;
+ memcpy(dictBuffer, best.dict, dictSize);
+ COVER_best_destroy(&best);
+ POOL_free(pool);
+ return dictSize;
+ }
+}
diff --git a/Utilities/cmzstd/lib/dictBuilder/cover.h b/Utilities/cmzstd/lib/dictBuilder/cover.h
new file mode 100644
index 000000000..82e2e1cea
--- /dev/null
+++ b/Utilities/cmzstd/lib/dictBuilder/cover.h
@@ -0,0 +1,83 @@
+#include <stdio.h> /* fprintf */
+#include <stdlib.h> /* malloc, free, qsort */
+#include <string.h> /* memset */
+#include <time.h> /* clock */
+#include "mem.h" /* read */
+#include "pool.h"
+#include "threading.h"
+#include "zstd_internal.h" /* includes zstd.h */
+#ifndef ZDICT_STATIC_LINKING_ONLY
+#define ZDICT_STATIC_LINKING_ONLY
+#endif
+#include "zdict.h"
+
+/**
+ * COVER_best_t is used for two purposes:
+ * 1. Synchronizing threads.
+ * 2. Saving the best parameters and dictionary.
+ *
+ * All of the methods except COVER_best_init() are thread safe if zstd is
+ * compiled with multithreaded support.
+ */
+typedef struct COVER_best_s {
+ ZSTD_pthread_mutex_t mutex;
+ ZSTD_pthread_cond_t cond;
+ size_t liveJobs;
+ void *dict;
+ size_t dictSize;
+ ZDICT_cover_params_t parameters;
+ size_t compressedSize;
+} COVER_best_t;
+
+/**
+ * A segment is a range in the source as well as the score of the segment.
+ */
+typedef struct {
+ U32 begin;
+ U32 end;
+ U32 score;
+} COVER_segment_t;
+
+/**
+ * Checks total compressed size of a dictionary
+ */
+size_t COVER_checkTotalCompressedSize(const ZDICT_cover_params_t parameters,
+ const size_t *samplesSizes, const BYTE *samples,
+ size_t *offsets,
+ size_t nbTrainSamples, size_t nbSamples,
+ BYTE *const dict, size_t dictBufferCapacity);
+
+/**
+ * Returns the sum of the sample sizes.
+ */
+size_t COVER_sum(const size_t *samplesSizes, unsigned nbSamples) ;
+
+/**
+ * Initialize the `COVER_best_t`.
+ */
+void COVER_best_init(COVER_best_t *best);
+
+/**
+ * Wait until liveJobs == 0.
+ */
+void COVER_best_wait(COVER_best_t *best);
+
+/**
+ * Call COVER_best_wait() and then destroy the COVER_best_t.
+ */
+void COVER_best_destroy(COVER_best_t *best);
+
+/**
+ * Called when a thread is about to be launched.
+ * Increments liveJobs.
+ */
+void COVER_best_start(COVER_best_t *best);
+
+/**
+ * Called when a thread finishes executing, both on error or success.
+ * Decrements liveJobs and signals any waiting threads if liveJobs == 0.
+ * If this dictionary is the best so far save it and its parameters.
+ */
+void COVER_best_finish(COVER_best_t *best, size_t compressedSize,
+ ZDICT_cover_params_t parameters, void *dict,
+ size_t dictSize);
diff --git a/Utilities/cmzstd/lib/dictBuilder/divsufsort.c b/Utilities/cmzstd/lib/dictBuilder/divsufsort.c
new file mode 100644
index 000000000..ead922044
--- /dev/null
+++ b/Utilities/cmzstd/lib/dictBuilder/divsufsort.c
@@ -0,0 +1,1913 @@
+/*
+ * divsufsort.c for libdivsufsort-lite
+ * Copyright (c) 2003-2008 Yuta Mori All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*- Compiler specifics -*/
+#ifdef __clang__
+#pragma clang diagnostic ignored "-Wshorten-64-to-32"
+#endif
+
+#if defined(_MSC_VER)
+# pragma warning(disable : 4244)
+# pragma warning(disable : 4127) /* C4127 : Condition expression is constant */
+#endif
+
+
+/*- Dependencies -*/
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "divsufsort.h"
+
+/*- Constants -*/
+#if defined(INLINE)
+# undef INLINE
+#endif
+#if !defined(INLINE)
+# define INLINE __inline
+#endif
+#if defined(ALPHABET_SIZE) && (ALPHABET_SIZE < 1)
+# undef ALPHABET_SIZE
+#endif
+#if !defined(ALPHABET_SIZE)
+# define ALPHABET_SIZE (256)
+#endif
+#define BUCKET_A_SIZE (ALPHABET_SIZE)
+#define BUCKET_B_SIZE (ALPHABET_SIZE * ALPHABET_SIZE)
+#if defined(SS_INSERTIONSORT_THRESHOLD)
+# if SS_INSERTIONSORT_THRESHOLD < 1
+# undef SS_INSERTIONSORT_THRESHOLD
+# define SS_INSERTIONSORT_THRESHOLD (1)
+# endif
+#else
+# define SS_INSERTIONSORT_THRESHOLD (8)
+#endif
+#if defined(SS_BLOCKSIZE)
+# if SS_BLOCKSIZE < 0
+# undef SS_BLOCKSIZE
+# define SS_BLOCKSIZE (0)
+# elif 32768 <= SS_BLOCKSIZE
+# undef SS_BLOCKSIZE
+# define SS_BLOCKSIZE (32767)
+# endif
+#else
+# define SS_BLOCKSIZE (1024)
+#endif
+/* minstacksize = log(SS_BLOCKSIZE) / log(3) * 2 */
+#if SS_BLOCKSIZE == 0
+# define SS_MISORT_STACKSIZE (96)
+#elif SS_BLOCKSIZE <= 4096
+# define SS_MISORT_STACKSIZE (16)
+#else
+# define SS_MISORT_STACKSIZE (24)
+#endif
+#define SS_SMERGE_STACKSIZE (32)
+#define TR_INSERTIONSORT_THRESHOLD (8)
+#define TR_STACKSIZE (64)
+
+
+/*- Macros -*/
+#ifndef SWAP
+# define SWAP(_a, _b) do { t = (_a); (_a) = (_b); (_b) = t; } while(0)
+#endif /* SWAP */
+#ifndef MIN
+# define MIN(_a, _b) (((_a) < (_b)) ? (_a) : (_b))
+#endif /* MIN */
+#ifndef MAX
+# define MAX(_a, _b) (((_a) > (_b)) ? (_a) : (_b))
+#endif /* MAX */
+#define STACK_PUSH(_a, _b, _c, _d)\
+ do {\
+ assert(ssize < STACK_SIZE);\
+ stack[ssize].a = (_a), stack[ssize].b = (_b),\
+ stack[ssize].c = (_c), stack[ssize++].d = (_d);\
+ } while(0)
+#define STACK_PUSH5(_a, _b, _c, _d, _e)\
+ do {\
+ assert(ssize < STACK_SIZE);\
+ stack[ssize].a = (_a), stack[ssize].b = (_b),\
+ stack[ssize].c = (_c), stack[ssize].d = (_d), stack[ssize++].e = (_e);\
+ } while(0)
+#define STACK_POP(_a, _b, _c, _d)\
+ do {\
+ assert(0 <= ssize);\
+ if(ssize == 0) { return; }\
+ (_a) = stack[--ssize].a, (_b) = stack[ssize].b,\
+ (_c) = stack[ssize].c, (_d) = stack[ssize].d;\
+ } while(0)
+#define STACK_POP5(_a, _b, _c, _d, _e)\
+ do {\
+ assert(0 <= ssize);\
+ if(ssize == 0) { return; }\
+ (_a) = stack[--ssize].a, (_b) = stack[ssize].b,\
+ (_c) = stack[ssize].c, (_d) = stack[ssize].d, (_e) = stack[ssize].e;\
+ } while(0)
+#define BUCKET_A(_c0) bucket_A[(_c0)]
+#if ALPHABET_SIZE == 256
+#define BUCKET_B(_c0, _c1) (bucket_B[((_c1) << 8) | (_c0)])
+#define BUCKET_BSTAR(_c0, _c1) (bucket_B[((_c0) << 8) | (_c1)])
+#else
+#define BUCKET_B(_c0, _c1) (bucket_B[(_c1) * ALPHABET_SIZE + (_c0)])
+#define BUCKET_BSTAR(_c0, _c1) (bucket_B[(_c0) * ALPHABET_SIZE + (_c1)])
+#endif
+
+
+/*- Private Functions -*/
+
+static const int lg_table[256]= {
+ -1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
+ 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+ 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
+};
+
+#if (SS_BLOCKSIZE == 0) || (SS_INSERTIONSORT_THRESHOLD < SS_BLOCKSIZE)
+
+static INLINE
+int
+ss_ilg(int n) {
+#if SS_BLOCKSIZE == 0
+ return (n & 0xffff0000) ?
+ ((n & 0xff000000) ?
+ 24 + lg_table[(n >> 24) & 0xff] :
+ 16 + lg_table[(n >> 16) & 0xff]) :
+ ((n & 0x0000ff00) ?
+ 8 + lg_table[(n >> 8) & 0xff] :
+ 0 + lg_table[(n >> 0) & 0xff]);
+#elif SS_BLOCKSIZE < 256
+ return lg_table[n];
+#else
+ return (n & 0xff00) ?
+ 8 + lg_table[(n >> 8) & 0xff] :
+ 0 + lg_table[(n >> 0) & 0xff];
+#endif
+}
+
+#endif /* (SS_BLOCKSIZE == 0) || (SS_INSERTIONSORT_THRESHOLD < SS_BLOCKSIZE) */
+
+#if SS_BLOCKSIZE != 0
+
+static const int sqq_table[256] = {
+ 0, 16, 22, 27, 32, 35, 39, 42, 45, 48, 50, 53, 55, 57, 59, 61,
+ 64, 65, 67, 69, 71, 73, 75, 76, 78, 80, 81, 83, 84, 86, 87, 89,
+ 90, 91, 93, 94, 96, 97, 98, 99, 101, 102, 103, 104, 106, 107, 108, 109,
+110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
+128, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
+143, 144, 144, 145, 146, 147, 148, 149, 150, 150, 151, 152, 153, 154, 155, 155,
+156, 157, 158, 159, 160, 160, 161, 162, 163, 163, 164, 165, 166, 167, 167, 168,
+169, 170, 170, 171, 172, 173, 173, 174, 175, 176, 176, 177, 178, 178, 179, 180,
+181, 181, 182, 183, 183, 184, 185, 185, 186, 187, 187, 188, 189, 189, 190, 191,
+192, 192, 193, 193, 194, 195, 195, 196, 197, 197, 198, 199, 199, 200, 201, 201,
+202, 203, 203, 204, 204, 205, 206, 206, 207, 208, 208, 209, 209, 210, 211, 211,
+212, 212, 213, 214, 214, 215, 215, 216, 217, 217, 218, 218, 219, 219, 220, 221,
+221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227, 227, 228, 229, 229, 230,
+230, 231, 231, 232, 232, 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238,
+239, 240, 240, 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 246, 246, 247,
+247, 248, 248, 249, 249, 250, 250, 251, 251, 252, 252, 253, 253, 254, 254, 255
+};
+
+static INLINE
+int
+ss_isqrt(int x) {
+ int y, e;
+
+ if(x >= (SS_BLOCKSIZE * SS_BLOCKSIZE)) { return SS_BLOCKSIZE; }
+ e = (x & 0xffff0000) ?
+ ((x & 0xff000000) ?
+ 24 + lg_table[(x >> 24) & 0xff] :
+ 16 + lg_table[(x >> 16) & 0xff]) :
+ ((x & 0x0000ff00) ?
+ 8 + lg_table[(x >> 8) & 0xff] :
+ 0 + lg_table[(x >> 0) & 0xff]);
+
+ if(e >= 16) {
+ y = sqq_table[x >> ((e - 6) - (e & 1))] << ((e >> 1) - 7);
+ if(e >= 24) { y = (y + 1 + x / y) >> 1; }
+ y = (y + 1 + x / y) >> 1;
+ } else if(e >= 8) {
+ y = (sqq_table[x >> ((e - 6) - (e & 1))] >> (7 - (e >> 1))) + 1;
+ } else {
+ return sqq_table[x] >> 4;
+ }
+
+ return (x < (y * y)) ? y - 1 : y;
+}
+
+#endif /* SS_BLOCKSIZE != 0 */
+
+
+/*---------------------------------------------------------------------------*/
+
+/* Compares two suffixes. */
+static INLINE
+int
+ss_compare(const unsigned char *T,
+ const int *p1, const int *p2,
+ int depth) {
+ const unsigned char *U1, *U2, *U1n, *U2n;
+
+ for(U1 = T + depth + *p1,
+ U2 = T + depth + *p2,
+ U1n = T + *(p1 + 1) + 2,
+ U2n = T + *(p2 + 1) + 2;
+ (U1 < U1n) && (U2 < U2n) && (*U1 == *U2);
+ ++U1, ++U2) {
+ }
+
+ return U1 < U1n ?
+ (U2 < U2n ? *U1 - *U2 : 1) :
+ (U2 < U2n ? -1 : 0);
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+#if (SS_BLOCKSIZE != 1) && (SS_INSERTIONSORT_THRESHOLD != 1)
+
+/* Insertionsort for small size groups */
+static
+void
+ss_insertionsort(const unsigned char *T, const int *PA,
+ int *first, int *last, int depth) {
+ int *i, *j;
+ int t;
+ int r;
+
+ for(i = last - 2; first <= i; --i) {
+ for(t = *i, j = i + 1; 0 < (r = ss_compare(T, PA + t, PA + *j, depth));) {
+ do { *(j - 1) = *j; } while((++j < last) && (*j < 0));
+ if(last <= j) { break; }
+ }
+ if(r == 0) { *j = ~*j; }
+ *(j - 1) = t;
+ }
+}
+
+#endif /* (SS_BLOCKSIZE != 1) && (SS_INSERTIONSORT_THRESHOLD != 1) */
+
+
+/*---------------------------------------------------------------------------*/
+
+#if (SS_BLOCKSIZE == 0) || (SS_INSERTIONSORT_THRESHOLD < SS_BLOCKSIZE)
+
+static INLINE
+void
+ss_fixdown(const unsigned char *Td, const int *PA,
+ int *SA, int i, int size) {
+ int j, k;
+ int v;
+ int c, d, e;
+
+ for(v = SA[i], c = Td[PA[v]]; (j = 2 * i + 1) < size; SA[i] = SA[k], i = k) {
+ d = Td[PA[SA[k = j++]]];
+ if(d < (e = Td[PA[SA[j]]])) { k = j; d = e; }
+ if(d <= c) { break; }
+ }
+ SA[i] = v;
+}
+
+/* Simple top-down heapsort. */
+static
+void
+ss_heapsort(const unsigned char *Td, const int *PA, int *SA, int size) {
+ int i, m;
+ int t;
+
+ m = size;
+ if((size % 2) == 0) {
+ m--;
+ if(Td[PA[SA[m / 2]]] < Td[PA[SA[m]]]) { SWAP(SA[m], SA[m / 2]); }
+ }
+
+ for(i = m / 2 - 1; 0 <= i; --i) { ss_fixdown(Td, PA, SA, i, m); }
+ if((size % 2) == 0) { SWAP(SA[0], SA[m]); ss_fixdown(Td, PA, SA, 0, m); }
+ for(i = m - 1; 0 < i; --i) {
+ t = SA[0], SA[0] = SA[i];
+ ss_fixdown(Td, PA, SA, 0, i);
+ SA[i] = t;
+ }
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+/* Returns the median of three elements. */
+static INLINE
+int *
+ss_median3(const unsigned char *Td, const int *PA,
+ int *v1, int *v2, int *v3) {
+ int *t;
+ if(Td[PA[*v1]] > Td[PA[*v2]]) { SWAP(v1, v2); }
+ if(Td[PA[*v2]] > Td[PA[*v3]]) {
+ if(Td[PA[*v1]] > Td[PA[*v3]]) { return v1; }
+ else { return v3; }
+ }
+ return v2;
+}
+
+/* Returns the median of five elements. */
+static INLINE
+int *
+ss_median5(const unsigned char *Td, const int *PA,
+ int *v1, int *v2, int *v3, int *v4, int *v5) {
+ int *t;
+ if(Td[PA[*v2]] > Td[PA[*v3]]) { SWAP(v2, v3); }
+ if(Td[PA[*v4]] > Td[PA[*v5]]) { SWAP(v4, v5); }
+ if(Td[PA[*v2]] > Td[PA[*v4]]) { SWAP(v2, v4); SWAP(v3, v5); }
+ if(Td[PA[*v1]] > Td[PA[*v3]]) { SWAP(v1, v3); }
+ if(Td[PA[*v1]] > Td[PA[*v4]]) { SWAP(v1, v4); SWAP(v3, v5); }
+ if(Td[PA[*v3]] > Td[PA[*v4]]) { return v4; }
+ return v3;
+}
+
+/* Returns the pivot element. */
+static INLINE
+int *
+ss_pivot(const unsigned char *Td, const int *PA, int *first, int *last) {
+ int *middle;
+ int t;
+
+ t = last - first;
+ middle = first + t / 2;
+
+ if(t <= 512) {
+ if(t <= 32) {
+ return ss_median3(Td, PA, first, middle, last - 1);
+ } else {
+ t >>= 2;
+ return ss_median5(Td, PA, first, first + t, middle, last - 1 - t, last - 1);
+ }
+ }
+ t >>= 3;
+ first = ss_median3(Td, PA, first, first + t, first + (t << 1));
+ middle = ss_median3(Td, PA, middle - t, middle, middle + t);
+ last = ss_median3(Td, PA, last - 1 - (t << 1), last - 1 - t, last - 1);
+ return ss_median3(Td, PA, first, middle, last);
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+/* Binary partition for substrings. */
+static INLINE
+int *
+ss_partition(const int *PA,
+ int *first, int *last, int depth) {
+ int *a, *b;
+ int t;
+ for(a = first - 1, b = last;;) {
+ for(; (++a < b) && ((PA[*a] + depth) >= (PA[*a + 1] + 1));) { *a = ~*a; }
+ for(; (a < --b) && ((PA[*b] + depth) < (PA[*b + 1] + 1));) { }
+ if(b <= a) { break; }
+ t = ~*b;
+ *b = *a;
+ *a = t;
+ }
+ if(first < a) { *first = ~*first; }
+ return a;
+}
+
+/* Multikey introsort for medium size groups. */
+static
+void
+ss_mintrosort(const unsigned char *T, const int *PA,
+ int *first, int *last,
+ int depth) {
+#define STACK_SIZE SS_MISORT_STACKSIZE
+ struct { int *a, *b, c; int d; } stack[STACK_SIZE];
+ const unsigned char *Td;
+ int *a, *b, *c, *d, *e, *f;
+ int s, t;
+ int ssize;
+ int limit;
+ int v, x = 0;
+
+ for(ssize = 0, limit = ss_ilg(last - first);;) {
+
+ if((last - first) <= SS_INSERTIONSORT_THRESHOLD) {
+#if 1 < SS_INSERTIONSORT_THRESHOLD
+ if(1 < (last - first)) { ss_insertionsort(T, PA, first, last, depth); }
+#endif
+ STACK_POP(first, last, depth, limit);
+ continue;
+ }
+
+ Td = T + depth;
+ if(limit-- == 0) { ss_heapsort(Td, PA, first, last - first); }
+ if(limit < 0) {
+ for(a = first + 1, v = Td[PA[*first]]; a < last; ++a) {
+ if((x = Td[PA[*a]]) != v) {
+ if(1 < (a - first)) { break; }
+ v = x;
+ first = a;
+ }
+ }
+ if(Td[PA[*first] - 1] < v) {
+ first = ss_partition(PA, first, a, depth);
+ }
+ if((a - first) <= (last - a)) {
+ if(1 < (a - first)) {
+ STACK_PUSH(a, last, depth, -1);
+ last = a, depth += 1, limit = ss_ilg(a - first);
+ } else {
+ first = a, limit = -1;
+ }
+ } else {
+ if(1 < (last - a)) {
+ STACK_PUSH(first, a, depth + 1, ss_ilg(a - first));
+ first = a, limit = -1;
+ } else {
+ last = a, depth += 1, limit = ss_ilg(a - first);
+ }
+ }
+ continue;
+ }
+
+ /* choose pivot */
+ a = ss_pivot(Td, PA, first, last);
+ v = Td[PA[*a]];
+ SWAP(*first, *a);
+
+ /* partition */
+ for(b = first; (++b < last) && ((x = Td[PA[*b]]) == v);) { }
+ if(((a = b) < last) && (x < v)) {
+ for(; (++b < last) && ((x = Td[PA[*b]]) <= v);) {
+ if(x == v) { SWAP(*b, *a); ++a; }
+ }
+ }
+ for(c = last; (b < --c) && ((x = Td[PA[*c]]) == v);) { }
+ if((b < (d = c)) && (x > v)) {
+ for(; (b < --c) && ((x = Td[PA[*c]]) >= v);) {
+ if(x == v) { SWAP(*c, *d); --d; }
+ }
+ }
+ for(; b < c;) {
+ SWAP(*b, *c);
+ for(; (++b < c) && ((x = Td[PA[*b]]) <= v);) {
+ if(x == v) { SWAP(*b, *a); ++a; }
+ }
+ for(; (b < --c) && ((x = Td[PA[*c]]) >= v);) {
+ if(x == v) { SWAP(*c, *d); --d; }
+ }
+ }
+
+ if(a <= d) {
+ c = b - 1;
+
+ if((s = a - first) > (t = b - a)) { s = t; }
+ for(e = first, f = b - s; 0 < s; --s, ++e, ++f) { SWAP(*e, *f); }
+ if((s = d - c) > (t = last - d - 1)) { s = t; }
+ for(e = b, f = last - s; 0 < s; --s, ++e, ++f) { SWAP(*e, *f); }
+
+ a = first + (b - a), c = last - (d - c);
+ b = (v <= Td[PA[*a] - 1]) ? a : ss_partition(PA, a, c, depth);
+
+ if((a - first) <= (last - c)) {
+ if((last - c) <= (c - b)) {
+ STACK_PUSH(b, c, depth + 1, ss_ilg(c - b));
+ STACK_PUSH(c, last, depth, limit);
+ last = a;
+ } else if((a - first) <= (c - b)) {
+ STACK_PUSH(c, last, depth, limit);
+ STACK_PUSH(b, c, depth + 1, ss_ilg(c - b));
+ last = a;
+ } else {
+ STACK_PUSH(c, last, depth, limit);
+ STACK_PUSH(first, a, depth, limit);
+ first = b, last = c, depth += 1, limit = ss_ilg(c - b);
+ }
+ } else {
+ if((a - first) <= (c - b)) {
+ STACK_PUSH(b, c, depth + 1, ss_ilg(c - b));
+ STACK_PUSH(first, a, depth, limit);
+ first = c;
+ } else if((last - c) <= (c - b)) {
+ STACK_PUSH(first, a, depth, limit);
+ STACK_PUSH(b, c, depth + 1, ss_ilg(c - b));
+ first = c;
+ } else {
+ STACK_PUSH(first, a, depth, limit);
+ STACK_PUSH(c, last, depth, limit);
+ first = b, last = c, depth += 1, limit = ss_ilg(c - b);
+ }
+ }
+ } else {
+ limit += 1;
+ if(Td[PA[*first] - 1] < v) {
+ first = ss_partition(PA, first, last, depth);
+ limit = ss_ilg(last - first);
+ }
+ depth += 1;
+ }
+ }
+#undef STACK_SIZE
+}
+
+#endif /* (SS_BLOCKSIZE == 0) || (SS_INSERTIONSORT_THRESHOLD < SS_BLOCKSIZE) */
+
+
+/*---------------------------------------------------------------------------*/
+
+#if SS_BLOCKSIZE != 0
+
+static INLINE
+void
+ss_blockswap(int *a, int *b, int n) {
+ int t;
+ for(; 0 < n; --n, ++a, ++b) {
+ t = *a, *a = *b, *b = t;
+ }
+}
+
+static INLINE
+void
+ss_rotate(int *first, int *middle, int *last) {
+ int *a, *b, t;
+ int l, r;
+ l = middle - first, r = last - middle;
+ for(; (0 < l) && (0 < r);) {
+ if(l == r) { ss_blockswap(first, middle, l); break; }
+ if(l < r) {
+ a = last - 1, b = middle - 1;
+ t = *a;
+ do {
+ *a-- = *b, *b-- = *a;
+ if(b < first) {
+ *a = t;
+ last = a;
+ if((r -= l + 1) <= l) { break; }
+ a -= 1, b = middle - 1;
+ t = *a;
+ }
+ } while(1);
+ } else {
+ a = first, b = middle;
+ t = *a;
+ do {
+ *a++ = *b, *b++ = *a;
+ if(last <= b) {
+ *a = t;
+ first = a + 1;
+ if((l -= r + 1) <= r) { break; }
+ a += 1, b = middle;
+ t = *a;
+ }
+ } while(1);
+ }
+ }
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+static
+void
+ss_inplacemerge(const unsigned char *T, const int *PA,
+ int *first, int *middle, int *last,
+ int depth) {
+ const int *p;
+ int *a, *b;
+ int len, half;
+ int q, r;
+ int x;
+
+ for(;;) {
+ if(*(last - 1) < 0) { x = 1; p = PA + ~*(last - 1); }
+ else { x = 0; p = PA + *(last - 1); }
+ for(a = first, len = middle - first, half = len >> 1, r = -1;
+ 0 < len;
+ len = half, half >>= 1) {
+ b = a + half;
+ q = ss_compare(T, PA + ((0 <= *b) ? *b : ~*b), p, depth);
+ if(q < 0) {
+ a = b + 1;
+ half -= (len & 1) ^ 1;
+ } else {
+ r = q;
+ }
+ }
+ if(a < middle) {
+ if(r == 0) { *a = ~*a; }
+ ss_rotate(a, middle, last);
+ last -= middle - a;
+ middle = a;
+ if(first == middle) { break; }
+ }
+ --last;
+ if(x != 0) { while(*--last < 0) { } }
+ if(middle == last) { break; }
+ }
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+/* Merge-forward with internal buffer. */
+static
+void
+ss_mergeforward(const unsigned char *T, const int *PA,
+ int *first, int *middle, int *last,
+ int *buf, int depth) {
+ int *a, *b, *c, *bufend;
+ int t;
+ int r;
+
+ bufend = buf + (middle - first) - 1;
+ ss_blockswap(buf, first, middle - first);
+
+ for(t = *(a = first), b = buf, c = middle;;) {
+ r = ss_compare(T, PA + *b, PA + *c, depth);
+ if(r < 0) {
+ do {
+ *a++ = *b;
+ if(bufend <= b) { *bufend = t; return; }
+ *b++ = *a;
+ } while(*b < 0);
+ } else if(r > 0) {
+ do {
+ *a++ = *c, *c++ = *a;
+ if(last <= c) {
+ while(b < bufend) { *a++ = *b, *b++ = *a; }
+ *a = *b, *b = t;
+ return;
+ }
+ } while(*c < 0);
+ } else {
+ *c = ~*c;
+ do {
+ *a++ = *b;
+ if(bufend <= b) { *bufend = t; return; }
+ *b++ = *a;
+ } while(*b < 0);
+
+ do {
+ *a++ = *c, *c++ = *a;
+ if(last <= c) {
+ while(b < bufend) { *a++ = *b, *b++ = *a; }
+ *a = *b, *b = t;
+ return;
+ }
+ } while(*c < 0);
+ }
+ }
+}
+
+/* Merge-backward with internal buffer. */
+static
+void
+ss_mergebackward(const unsigned char *T, const int *PA,
+ int *first, int *middle, int *last,
+ int *buf, int depth) {
+ const int *p1, *p2;
+ int *a, *b, *c, *bufend;
+ int t;
+ int r;
+ int x;
+
+ bufend = buf + (last - middle) - 1;
+ ss_blockswap(buf, middle, last - middle);
+
+ x = 0;
+ if(*bufend < 0) { p1 = PA + ~*bufend; x |= 1; }
+ else { p1 = PA + *bufend; }
+ if(*(middle - 1) < 0) { p2 = PA + ~*(middle - 1); x |= 2; }
+ else { p2 = PA + *(middle - 1); }
+ for(t = *(a = last - 1), b = bufend, c = middle - 1;;) {
+ r = ss_compare(T, p1, p2, depth);
+ if(0 < r) {
+ if(x & 1) { do { *a-- = *b, *b-- = *a; } while(*b < 0); x ^= 1; }
+ *a-- = *b;
+ if(b <= buf) { *buf = t; break; }
+ *b-- = *a;
+ if(*b < 0) { p1 = PA + ~*b; x |= 1; }
+ else { p1 = PA + *b; }
+ } else if(r < 0) {
+ if(x & 2) { do { *a-- = *c, *c-- = *a; } while(*c < 0); x ^= 2; }
+ *a-- = *c, *c-- = *a;
+ if(c < first) {
+ while(buf < b) { *a-- = *b, *b-- = *a; }
+ *a = *b, *b = t;
+ break;
+ }
+ if(*c < 0) { p2 = PA + ~*c; x |= 2; }
+ else { p2 = PA + *c; }
+ } else {
+ if(x & 1) { do { *a-- = *b, *b-- = *a; } while(*b < 0); x ^= 1; }
+ *a-- = ~*b;
+ if(b <= buf) { *buf = t; break; }
+ *b-- = *a;
+ if(x & 2) { do { *a-- = *c, *c-- = *a; } while(*c < 0); x ^= 2; }
+ *a-- = *c, *c-- = *a;
+ if(c < first) {
+ while(buf < b) { *a-- = *b, *b-- = *a; }
+ *a = *b, *b = t;
+ break;
+ }
+ if(*b < 0) { p1 = PA + ~*b; x |= 1; }
+ else { p1 = PA + *b; }
+ if(*c < 0) { p2 = PA + ~*c; x |= 2; }
+ else { p2 = PA + *c; }
+ }
+ }
+}
+
+/* D&C based merge. */
+static
+void
+ss_swapmerge(const unsigned char *T, const int *PA,
+ int *first, int *middle, int *last,
+ int *buf, int bufsize, int depth) {
+#define STACK_SIZE SS_SMERGE_STACKSIZE
+#define GETIDX(a) ((0 <= (a)) ? (a) : (~(a)))
+#define MERGE_CHECK(a, b, c)\
+ do {\
+ if(((c) & 1) ||\
+ (((c) & 2) && (ss_compare(T, PA + GETIDX(*((a) - 1)), PA + *(a), depth) == 0))) {\
+ *(a) = ~*(a);\
+ }\
+ if(((c) & 4) && ((ss_compare(T, PA + GETIDX(*((b) - 1)), PA + *(b), depth) == 0))) {\
+ *(b) = ~*(b);\
+ }\
+ } while(0)
+ struct { int *a, *b, *c; int d; } stack[STACK_SIZE];
+ int *l, *r, *lm, *rm;
+ int m, len, half;
+ int ssize;
+ int check, next;
+
+ for(check = 0, ssize = 0;;) {
+ if((last - middle) <= bufsize) {
+ if((first < middle) && (middle < last)) {
+ ss_mergebackward(T, PA, first, middle, last, buf, depth);
+ }
+ MERGE_CHECK(first, last, check);
+ STACK_POP(first, middle, last, check);
+ continue;
+ }
+
+ if((middle - first) <= bufsize) {
+ if(first < middle) {
+ ss_mergeforward(T, PA, first, middle, last, buf, depth);
+ }
+ MERGE_CHECK(first, last, check);
+ STACK_POP(first, middle, last, check);
+ continue;
+ }
+
+ for(m = 0, len = MIN(middle - first, last - middle), half = len >> 1;
+ 0 < len;
+ len = half, half >>= 1) {
+ if(ss_compare(T, PA + GETIDX(*(middle + m + half)),
+ PA + GETIDX(*(middle - m - half - 1)), depth) < 0) {
+ m += half + 1;
+ half -= (len & 1) ^ 1;
+ }
+ }
+
+ if(0 < m) {
+ lm = middle - m, rm = middle + m;
+ ss_blockswap(lm, middle, m);
+ l = r = middle, next = 0;
+ if(rm < last) {
+ if(*rm < 0) {
+ *rm = ~*rm;
+ if(first < lm) { for(; *--l < 0;) { } next |= 4; }
+ next |= 1;
+ } else if(first < lm) {
+ for(; *r < 0; ++r) { }
+ next |= 2;
+ }
+ }
+
+ if((l - first) <= (last - r)) {
+ STACK_PUSH(r, rm, last, (next & 3) | (check & 4));
+ middle = lm, last = l, check = (check & 3) | (next & 4);
+ } else {
+ if((next & 2) && (r == middle)) { next ^= 6; }
+ STACK_PUSH(first, lm, l, (check & 3) | (next & 4));
+ first = r, middle = rm, check = (next & 3) | (check & 4);
+ }
+ } else {
+ if(ss_compare(T, PA + GETIDX(*(middle - 1)), PA + *middle, depth) == 0) {
+ *middle = ~*middle;
+ }
+ MERGE_CHECK(first, last, check);
+ STACK_POP(first, middle, last, check);
+ }
+ }
+#undef STACK_SIZE
+}
+
+#endif /* SS_BLOCKSIZE != 0 */
+
+
+/*---------------------------------------------------------------------------*/
+
+/* Substring sort */
+static
+void
+sssort(const unsigned char *T, const int *PA,
+ int *first, int *last,
+ int *buf, int bufsize,
+ int depth, int n, int lastsuffix) {
+ int *a;
+#if SS_BLOCKSIZE != 0
+ int *b, *middle, *curbuf;
+ int j, k, curbufsize, limit;
+#endif
+ int i;
+
+ if(lastsuffix != 0) { ++first; }
+
+#if SS_BLOCKSIZE == 0
+ ss_mintrosort(T, PA, first, last, depth);
+#else
+ if((bufsize < SS_BLOCKSIZE) &&
+ (bufsize < (last - first)) &&
+ (bufsize < (limit = ss_isqrt(last - first)))) {
+ if(SS_BLOCKSIZE < limit) { limit = SS_BLOCKSIZE; }
+ buf = middle = last - limit, bufsize = limit;
+ } else {
+ middle = last, limit = 0;
+ }
+ for(a = first, i = 0; SS_BLOCKSIZE < (middle - a); a += SS_BLOCKSIZE, ++i) {
+#if SS_INSERTIONSORT_THRESHOLD < SS_BLOCKSIZE
+ ss_mintrosort(T, PA, a, a + SS_BLOCKSIZE, depth);
+#elif 1 < SS_BLOCKSIZE
+ ss_insertionsort(T, PA, a, a + SS_BLOCKSIZE, depth);
+#endif
+ curbufsize = last - (a + SS_BLOCKSIZE);
+ curbuf = a + SS_BLOCKSIZE;
+ if(curbufsize <= bufsize) { curbufsize = bufsize, curbuf = buf; }
+ for(b = a, k = SS_BLOCKSIZE, j = i; j & 1; b -= k, k <<= 1, j >>= 1) {
+ ss_swapmerge(T, PA, b - k, b, b + k, curbuf, curbufsize, depth);
+ }
+ }
+#if SS_INSERTIONSORT_THRESHOLD < SS_BLOCKSIZE
+ ss_mintrosort(T, PA, a, middle, depth);
+#elif 1 < SS_BLOCKSIZE
+ ss_insertionsort(T, PA, a, middle, depth);
+#endif
+ for(k = SS_BLOCKSIZE; i != 0; k <<= 1, i >>= 1) {
+ if(i & 1) {
+ ss_swapmerge(T, PA, a - k, a, middle, buf, bufsize, depth);
+ a -= k;
+ }
+ }
+ if(limit != 0) {
+#if SS_INSERTIONSORT_THRESHOLD < SS_BLOCKSIZE
+ ss_mintrosort(T, PA, middle, last, depth);
+#elif 1 < SS_BLOCKSIZE
+ ss_insertionsort(T, PA, middle, last, depth);
+#endif
+ ss_inplacemerge(T, PA, first, middle, last, depth);
+ }
+#endif
+
+ if(lastsuffix != 0) {
+ /* Insert last type B* suffix. */
+ int PAi[2]; PAi[0] = PA[*(first - 1)], PAi[1] = n - 2;
+ for(a = first, i = *(first - 1);
+ (a < last) && ((*a < 0) || (0 < ss_compare(T, &(PAi[0]), PA + *a, depth)));
+ ++a) {
+ *(a - 1) = *a;
+ }
+ *(a - 1) = i;
+ }
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+static INLINE
+int
+tr_ilg(int n) {
+ return (n & 0xffff0000) ?
+ ((n & 0xff000000) ?
+ 24 + lg_table[(n >> 24) & 0xff] :
+ 16 + lg_table[(n >> 16) & 0xff]) :
+ ((n & 0x0000ff00) ?
+ 8 + lg_table[(n >> 8) & 0xff] :
+ 0 + lg_table[(n >> 0) & 0xff]);
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+/* Simple insertionsort for small size groups. */
+static
+void
+tr_insertionsort(const int *ISAd, int *first, int *last) {
+ int *a, *b;
+ int t, r;
+
+ for(a = first + 1; a < last; ++a) {
+ for(t = *a, b = a - 1; 0 > (r = ISAd[t] - ISAd[*b]);) {
+ do { *(b + 1) = *b; } while((first <= --b) && (*b < 0));
+ if(b < first) { break; }
+ }
+ if(r == 0) { *b = ~*b; }
+ *(b + 1) = t;
+ }
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+static INLINE
+void
+tr_fixdown(const int *ISAd, int *SA, int i, int size) {
+ int j, k;
+ int v;
+ int c, d, e;
+
+ for(v = SA[i], c = ISAd[v]; (j = 2 * i + 1) < size; SA[i] = SA[k], i = k) {
+ d = ISAd[SA[k = j++]];
+ if(d < (e = ISAd[SA[j]])) { k = j; d = e; }
+ if(d <= c) { break; }
+ }
+ SA[i] = v;
+}
+
+/* Simple top-down heapsort. */
+static
+void
+tr_heapsort(const int *ISAd, int *SA, int size) {
+ int i, m;
+ int t;
+
+ m = size;
+ if((size % 2) == 0) {
+ m--;
+ if(ISAd[SA[m / 2]] < ISAd[SA[m]]) { SWAP(SA[m], SA[m / 2]); }
+ }
+
+ for(i = m / 2 - 1; 0 <= i; --i) { tr_fixdown(ISAd, SA, i, m); }
+ if((size % 2) == 0) { SWAP(SA[0], SA[m]); tr_fixdown(ISAd, SA, 0, m); }
+ for(i = m - 1; 0 < i; --i) {
+ t = SA[0], SA[0] = SA[i];
+ tr_fixdown(ISAd, SA, 0, i);
+ SA[i] = t;
+ }
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+/* Returns the median of three elements. */
+static INLINE
+int *
+tr_median3(const int *ISAd, int *v1, int *v2, int *v3) {
+ int *t;
+ if(ISAd[*v1] > ISAd[*v2]) { SWAP(v1, v2); }
+ if(ISAd[*v2] > ISAd[*v3]) {
+ if(ISAd[*v1] > ISAd[*v3]) { return v1; }
+ else { return v3; }
+ }
+ return v2;
+}
+
+/* Returns the median of five elements. */
+static INLINE
+int *
+tr_median5(const int *ISAd,
+ int *v1, int *v2, int *v3, int *v4, int *v5) {
+ int *t;
+ if(ISAd[*v2] > ISAd[*v3]) { SWAP(v2, v3); }
+ if(ISAd[*v4] > ISAd[*v5]) { SWAP(v4, v5); }
+ if(ISAd[*v2] > ISAd[*v4]) { SWAP(v2, v4); SWAP(v3, v5); }
+ if(ISAd[*v1] > ISAd[*v3]) { SWAP(v1, v3); }
+ if(ISAd[*v1] > ISAd[*v4]) { SWAP(v1, v4); SWAP(v3, v5); }
+ if(ISAd[*v3] > ISAd[*v4]) { return v4; }
+ return v3;
+}
+
+/* Returns the pivot element. */
+static INLINE
+int *
+tr_pivot(const int *ISAd, int *first, int *last) {
+ int *middle;
+ int t;
+
+ t = last - first;
+ middle = first + t / 2;
+
+ if(t <= 512) {
+ if(t <= 32) {
+ return tr_median3(ISAd, first, middle, last - 1);
+ } else {
+ t >>= 2;
+ return tr_median5(ISAd, first, first + t, middle, last - 1 - t, last - 1);
+ }
+ }
+ t >>= 3;
+ first = tr_median3(ISAd, first, first + t, first + (t << 1));
+ middle = tr_median3(ISAd, middle - t, middle, middle + t);
+ last = tr_median3(ISAd, last - 1 - (t << 1), last - 1 - t, last - 1);
+ return tr_median3(ISAd, first, middle, last);
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+typedef struct _trbudget_t trbudget_t;
+struct _trbudget_t {
+ int chance;
+ int remain;
+ int incval;
+ int count;
+};
+
+static INLINE
+void
+trbudget_init(trbudget_t *budget, int chance, int incval) {
+ budget->chance = chance;
+ budget->remain = budget->incval = incval;
+}
+
+static INLINE
+int
+trbudget_check(trbudget_t *budget, int size) {
+ if(size <= budget->remain) { budget->remain -= size; return 1; }
+ if(budget->chance == 0) { budget->count += size; return 0; }
+ budget->remain += budget->incval - size;
+ budget->chance -= 1;
+ return 1;
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+static INLINE
+void
+tr_partition(const int *ISAd,
+ int *first, int *middle, int *last,
+ int **pa, int **pb, int v) {
+ int *a, *b, *c, *d, *e, *f;
+ int t, s;
+ int x = 0;
+
+ for(b = middle - 1; (++b < last) && ((x = ISAd[*b]) == v);) { }
+ if(((a = b) < last) && (x < v)) {
+ for(; (++b < last) && ((x = ISAd[*b]) <= v);) {
+ if(x == v) { SWAP(*b, *a); ++a; }
+ }
+ }
+ for(c = last; (b < --c) && ((x = ISAd[*c]) == v);) { }
+ if((b < (d = c)) && (x > v)) {
+ for(; (b < --c) && ((x = ISAd[*c]) >= v);) {
+ if(x == v) { SWAP(*c, *d); --d; }
+ }
+ }
+ for(; b < c;) {
+ SWAP(*b, *c);
+ for(; (++b < c) && ((x = ISAd[*b]) <= v);) {
+ if(x == v) { SWAP(*b, *a); ++a; }
+ }
+ for(; (b < --c) && ((x = ISAd[*c]) >= v);) {
+ if(x == v) { SWAP(*c, *d); --d; }
+ }
+ }
+
+ if(a <= d) {
+ c = b - 1;
+ if((s = a - first) > (t = b - a)) { s = t; }
+ for(e = first, f = b - s; 0 < s; --s, ++e, ++f) { SWAP(*e, *f); }
+ if((s = d - c) > (t = last - d - 1)) { s = t; }
+ for(e = b, f = last - s; 0 < s; --s, ++e, ++f) { SWAP(*e, *f); }
+ first += (b - a), last -= (d - c);
+ }
+ *pa = first, *pb = last;
+}
+
+static
+void
+tr_copy(int *ISA, const int *SA,
+ int *first, int *a, int *b, int *last,
+ int depth) {
+ /* sort suffixes of middle partition
+ by using sorted order of suffixes of left and right partition. */
+ int *c, *d, *e;
+ int s, v;
+
+ v = b - SA - 1;
+ for(c = first, d = a - 1; c <= d; ++c) {
+ if((0 <= (s = *c - depth)) && (ISA[s] == v)) {
+ *++d = s;
+ ISA[s] = d - SA;
+ }
+ }
+ for(c = last - 1, e = d + 1, d = b; e < d; --c) {
+ if((0 <= (s = *c - depth)) && (ISA[s] == v)) {
+ *--d = s;
+ ISA[s] = d - SA;
+ }
+ }
+}
+
+static
+void
+tr_partialcopy(int *ISA, const int *SA,
+ int *first, int *a, int *b, int *last,
+ int depth) {
+ int *c, *d, *e;
+ int s, v;
+ int rank, lastrank, newrank = -1;
+
+ v = b - SA - 1;
+ lastrank = -1;
+ for(c = first, d = a - 1; c <= d; ++c) {
+ if((0 <= (s = *c - depth)) && (ISA[s] == v)) {
+ *++d = s;
+ rank = ISA[s + depth];
+ if(lastrank != rank) { lastrank = rank; newrank = d - SA; }
+ ISA[s] = newrank;
+ }
+ }
+
+ lastrank = -1;
+ for(e = d; first <= e; --e) {
+ rank = ISA[*e];
+ if(lastrank != rank) { lastrank = rank; newrank = e - SA; }
+ if(newrank != rank) { ISA[*e] = newrank; }
+ }
+
+ lastrank = -1;
+ for(c = last - 1, e = d + 1, d = b; e < d; --c) {
+ if((0 <= (s = *c - depth)) && (ISA[s] == v)) {
+ *--d = s;
+ rank = ISA[s + depth];
+ if(lastrank != rank) { lastrank = rank; newrank = d - SA; }
+ ISA[s] = newrank;
+ }
+ }
+}
+
+static
+void
+tr_introsort(int *ISA, const int *ISAd,
+ int *SA, int *first, int *last,
+ trbudget_t *budget) {
+#define STACK_SIZE TR_STACKSIZE
+ struct { const int *a; int *b, *c; int d, e; }stack[STACK_SIZE];
+ int *a, *b, *c;
+ int t;
+ int v, x = 0;
+ int incr = ISAd - ISA;
+ int limit, next;
+ int ssize, trlink = -1;
+
+ for(ssize = 0, limit = tr_ilg(last - first);;) {
+
+ if(limit < 0) {
+ if(limit == -1) {
+ /* tandem repeat partition */
+ tr_partition(ISAd - incr, first, first, last, &a, &b, last - SA - 1);
+
+ /* update ranks */
+ if(a < last) {
+ for(c = first, v = a - SA - 1; c < a; ++c) { ISA[*c] = v; }
+ }
+ if(b < last) {
+ for(c = a, v = b - SA - 1; c < b; ++c) { ISA[*c] = v; }
+ }
+
+ /* push */
+ if(1 < (b - a)) {
+ STACK_PUSH5(NULL, a, b, 0, 0);
+ STACK_PUSH5(ISAd - incr, first, last, -2, trlink);
+ trlink = ssize - 2;
+ }
+ if((a - first) <= (last - b)) {
+ if(1 < (a - first)) {
+ STACK_PUSH5(ISAd, b, last, tr_ilg(last - b), trlink);
+ last = a, limit = tr_ilg(a - first);
+ } else if(1 < (last - b)) {
+ first = b, limit = tr_ilg(last - b);
+ } else {
+ STACK_POP5(ISAd, first, last, limit, trlink);
+ }
+ } else {
+ if(1 < (last - b)) {
+ STACK_PUSH5(ISAd, first, a, tr_ilg(a - first), trlink);
+ first = b, limit = tr_ilg(last - b);
+ } else if(1 < (a - first)) {
+ last = a, limit = tr_ilg(a - first);
+ } else {
+ STACK_POP5(ISAd, first, last, limit, trlink);
+ }
+ }
+ } else if(limit == -2) {
+ /* tandem repeat copy */
+ a = stack[--ssize].b, b = stack[ssize].c;
+ if(stack[ssize].d == 0) {
+ tr_copy(ISA, SA, first, a, b, last, ISAd - ISA);
+ } else {
+ if(0 <= trlink) { stack[trlink].d = -1; }
+ tr_partialcopy(ISA, SA, first, a, b, last, ISAd - ISA);
+ }
+ STACK_POP5(ISAd, first, last, limit, trlink);
+ } else {
+ /* sorted partition */
+ if(0 <= *first) {
+ a = first;
+ do { ISA[*a] = a - SA; } while((++a < last) && (0 <= *a));
+ first = a;
+ }
+ if(first < last) {
+ a = first; do { *a = ~*a; } while(*++a < 0);
+ next = (ISA[*a] != ISAd[*a]) ? tr_ilg(a - first + 1) : -1;
+ if(++a < last) { for(b = first, v = a - SA - 1; b < a; ++b) { ISA[*b] = v; } }
+
+ /* push */
+ if(trbudget_check(budget, a - first)) {
+ if((a - first) <= (last - a)) {
+ STACK_PUSH5(ISAd, a, last, -3, trlink);
+ ISAd += incr, last = a, limit = next;
+ } else {
+ if(1 < (last - a)) {
+ STACK_PUSH5(ISAd + incr, first, a, next, trlink);
+ first = a, limit = -3;
+ } else {
+ ISAd += incr, last = a, limit = next;
+ }
+ }
+ } else {
+ if(0 <= trlink) { stack[trlink].d = -1; }
+ if(1 < (last - a)) {
+ first = a, limit = -3;
+ } else {
+ STACK_POP5(ISAd, first, last, limit, trlink);
+ }
+ }
+ } else {
+ STACK_POP5(ISAd, first, last, limit, trlink);
+ }
+ }
+ continue;
+ }
+
+ if((last - first) <= TR_INSERTIONSORT_THRESHOLD) {
+ tr_insertionsort(ISAd, first, last);
+ limit = -3;
+ continue;
+ }
+
+ if(limit-- == 0) {
+ tr_heapsort(ISAd, first, last - first);
+ for(a = last - 1; first < a; a = b) {
+ for(x = ISAd[*a], b = a - 1; (first <= b) && (ISAd[*b] == x); --b) { *b = ~*b; }
+ }
+ limit = -3;
+ continue;
+ }
+
+ /* choose pivot */
+ a = tr_pivot(ISAd, first, last);
+ SWAP(*first, *a);
+ v = ISAd[*first];
+
+ /* partition */
+ tr_partition(ISAd, first, first + 1, last, &a, &b, v);
+ if((last - first) != (b - a)) {
+ next = (ISA[*a] != v) ? tr_ilg(b - a) : -1;
+
+ /* update ranks */
+ for(c = first, v = a - SA - 1; c < a; ++c) { ISA[*c] = v; }
+ if(b < last) { for(c = a, v = b - SA - 1; c < b; ++c) { ISA[*c] = v; } }
+
+ /* push */
+ if((1 < (b - a)) && (trbudget_check(budget, b - a))) {
+ if((a - first) <= (last - b)) {
+ if((last - b) <= (b - a)) {
+ if(1 < (a - first)) {
+ STACK_PUSH5(ISAd + incr, a, b, next, trlink);
+ STACK_PUSH5(ISAd, b, last, limit, trlink);
+ last = a;
+ } else if(1 < (last - b)) {
+ STACK_PUSH5(ISAd + incr, a, b, next, trlink);
+ first = b;
+ } else {
+ ISAd += incr, first = a, last = b, limit = next;
+ }
+ } else if((a - first) <= (b - a)) {
+ if(1 < (a - first)) {
+ STACK_PUSH5(ISAd, b, last, limit, trlink);
+ STACK_PUSH5(ISAd + incr, a, b, next, trlink);
+ last = a;
+ } else {
+ STACK_PUSH5(ISAd, b, last, limit, trlink);
+ ISAd += incr, first = a, last = b, limit = next;
+ }
+ } else {
+ STACK_PUSH5(ISAd, b, last, limit, trlink);
+ STACK_PUSH5(ISAd, first, a, limit, trlink);
+ ISAd += incr, first = a, last = b, limit = next;
+ }
+ } else {
+ if((a - first) <= (b - a)) {
+ if(1 < (last - b)) {
+ STACK_PUSH5(ISAd + incr, a, b, next, trlink);
+ STACK_PUSH5(ISAd, first, a, limit, trlink);
+ first = b;
+ } else if(1 < (a - first)) {
+ STACK_PUSH5(ISAd + incr, a, b, next, trlink);
+ last = a;
+ } else {
+ ISAd += incr, first = a, last = b, limit = next;
+ }
+ } else if((last - b) <= (b - a)) {
+ if(1 < (last - b)) {
+ STACK_PUSH5(ISAd, first, a, limit, trlink);
+ STACK_PUSH5(ISAd + incr, a, b, next, trlink);
+ first = b;
+ } else {
+ STACK_PUSH5(ISAd, first, a, limit, trlink);
+ ISAd += incr, first = a, last = b, limit = next;
+ }
+ } else {
+ STACK_PUSH5(ISAd, first, a, limit, trlink);
+ STACK_PUSH5(ISAd, b, last, limit, trlink);
+ ISAd += incr, first = a, last = b, limit = next;
+ }
+ }
+ } else {
+ if((1 < (b - a)) && (0 <= trlink)) { stack[trlink].d = -1; }
+ if((a - first) <= (last - b)) {
+ if(1 < (a - first)) {
+ STACK_PUSH5(ISAd, b, last, limit, trlink);
+ last = a;
+ } else if(1 < (last - b)) {
+ first = b;
+ } else {
+ STACK_POP5(ISAd, first, last, limit, trlink);
+ }
+ } else {
+ if(1 < (last - b)) {
+ STACK_PUSH5(ISAd, first, a, limit, trlink);
+ first = b;
+ } else if(1 < (a - first)) {
+ last = a;
+ } else {
+ STACK_POP5(ISAd, first, last, limit, trlink);
+ }
+ }
+ }
+ } else {
+ if(trbudget_check(budget, last - first)) {
+ limit = tr_ilg(last - first), ISAd += incr;
+ } else {
+ if(0 <= trlink) { stack[trlink].d = -1; }
+ STACK_POP5(ISAd, first, last, limit, trlink);
+ }
+ }
+ }
+#undef STACK_SIZE
+}
+
+
+
+/*---------------------------------------------------------------------------*/
+
+/* Tandem repeat sort */
+static
+void
+trsort(int *ISA, int *SA, int n, int depth) {
+ int *ISAd;
+ int *first, *last;
+ trbudget_t budget;
+ int t, skip, unsorted;
+
+ trbudget_init(&budget, tr_ilg(n) * 2 / 3, n);
+/* trbudget_init(&budget, tr_ilg(n) * 3 / 4, n); */
+ for(ISAd = ISA + depth; -n < *SA; ISAd += ISAd - ISA) {
+ first = SA;
+ skip = 0;
+ unsorted = 0;
+ do {
+ if((t = *first) < 0) { first -= t; skip += t; }
+ else {
+ if(skip != 0) { *(first + skip) = skip; skip = 0; }
+ last = SA + ISA[t] + 1;
+ if(1 < (last - first)) {
+ budget.count = 0;
+ tr_introsort(ISA, ISAd, SA, first, last, &budget);
+ if(budget.count != 0) { unsorted += budget.count; }
+ else { skip = first - last; }
+ } else if((last - first) == 1) {
+ skip = -1;
+ }
+ first = last;
+ }
+ } while(first < (SA + n));
+ if(skip != 0) { *(first + skip) = skip; }
+ if(unsorted == 0) { break; }
+ }
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+/* Sorts suffixes of type B*. */
+static
+int
+sort_typeBstar(const unsigned char *T, int *SA,
+ int *bucket_A, int *bucket_B,
+ int n, int openMP) {
+ int *PAb, *ISAb, *buf;
+#ifdef LIBBSC_OPENMP
+ int *curbuf;
+ int l;
+#endif
+ int i, j, k, t, m, bufsize;
+ int c0, c1;
+#ifdef LIBBSC_OPENMP
+ int d0, d1;
+#endif
+ (void)openMP;
+
+ /* Initialize bucket arrays. */
+ for(i = 0; i < BUCKET_A_SIZE; ++i) { bucket_A[i] = 0; }
+ for(i = 0; i < BUCKET_B_SIZE; ++i) { bucket_B[i] = 0; }
+
+ /* Count the number of occurrences of the first one or two characters of each
+ type A, B and B* suffix. Moreover, store the beginning position of all
+ type B* suffixes into the array SA. */
+ for(i = n - 1, m = n, c0 = T[n - 1]; 0 <= i;) {
+ /* type A suffix. */
+ do { ++BUCKET_A(c1 = c0); } while((0 <= --i) && ((c0 = T[i]) >= c1));
+ if(0 <= i) {
+ /* type B* suffix. */
+ ++BUCKET_BSTAR(c0, c1);
+ SA[--m] = i;
+ /* type B suffix. */
+ for(--i, c1 = c0; (0 <= i) && ((c0 = T[i]) <= c1); --i, c1 = c0) {
+ ++BUCKET_B(c0, c1);
+ }
+ }
+ }
+ m = n - m;
+/*
+note:
+ A type B* suffix is lexicographically smaller than a type B suffix that
+ begins with the same first two characters.
+*/
+
+ /* Calculate the index of start/end point of each bucket. */
+ for(c0 = 0, i = 0, j = 0; c0 < ALPHABET_SIZE; ++c0) {
+ t = i + BUCKET_A(c0);
+ BUCKET_A(c0) = i + j; /* start point */
+ i = t + BUCKET_B(c0, c0);
+ for(c1 = c0 + 1; c1 < ALPHABET_SIZE; ++c1) {
+ j += BUCKET_BSTAR(c0, c1);
+ BUCKET_BSTAR(c0, c1) = j; /* end point */
+ i += BUCKET_B(c0, c1);
+ }
+ }
+
+ if(0 < m) {
+ /* Sort the type B* suffixes by their first two characters. */
+ PAb = SA + n - m; ISAb = SA + m;
+ for(i = m - 2; 0 <= i; --i) {
+ t = PAb[i], c0 = T[t], c1 = T[t + 1];
+ SA[--BUCKET_BSTAR(c0, c1)] = i;
+ }
+ t = PAb[m - 1], c0 = T[t], c1 = T[t + 1];
+ SA[--BUCKET_BSTAR(c0, c1)] = m - 1;
+
+ /* Sort the type B* substrings using sssort. */
+#ifdef LIBBSC_OPENMP
+ if (openMP)
+ {
+ buf = SA + m;
+ c0 = ALPHABET_SIZE - 2, c1 = ALPHABET_SIZE - 1, j = m;
+#pragma omp parallel default(shared) private(bufsize, curbuf, k, l, d0, d1)
+ {
+ bufsize = (n - (2 * m)) / omp_get_num_threads();
+ curbuf = buf + omp_get_thread_num() * bufsize;
+ k = 0;
+ for(;;) {
+ #pragma omp critical(sssort_lock)
+ {
+ if(0 < (l = j)) {
+ d0 = c0, d1 = c1;
+ do {
+ k = BUCKET_BSTAR(d0, d1);
+ if(--d1 <= d0) {
+ d1 = ALPHABET_SIZE - 1;
+ if(--d0 < 0) { break; }
+ }
+ } while(((l - k) <= 1) && (0 < (l = k)));
+ c0 = d0, c1 = d1, j = k;
+ }
+ }
+ if(l == 0) { break; }
+ sssort(T, PAb, SA + k, SA + l,
+ curbuf, bufsize, 2, n, *(SA + k) == (m - 1));
+ }
+ }
+ }
+ else
+ {
+ buf = SA + m, bufsize = n - (2 * m);
+ for(c0 = ALPHABET_SIZE - 2, j = m; 0 < j; --c0) {
+ for(c1 = ALPHABET_SIZE - 1; c0 < c1; j = i, --c1) {
+ i = BUCKET_BSTAR(c0, c1);
+ if(1 < (j - i)) {
+ sssort(T, PAb, SA + i, SA + j,
+ buf, bufsize, 2, n, *(SA + i) == (m - 1));
+ }
+ }
+ }
+ }
+#else
+ buf = SA + m, bufsize = n - (2 * m);
+ for(c0 = ALPHABET_SIZE - 2, j = m; 0 < j; --c0) {
+ for(c1 = ALPHABET_SIZE - 1; c0 < c1; j = i, --c1) {
+ i = BUCKET_BSTAR(c0, c1);
+ if(1 < (j - i)) {
+ sssort(T, PAb, SA + i, SA + j,
+ buf, bufsize, 2, n, *(SA + i) == (m - 1));
+ }
+ }
+ }
+#endif
+
+ /* Compute ranks of type B* substrings. */
+ for(i = m - 1; 0 <= i; --i) {
+ if(0 <= SA[i]) {
+ j = i;
+ do { ISAb[SA[i]] = i; } while((0 <= --i) && (0 <= SA[i]));
+ SA[i + 1] = i - j;
+ if(i <= 0) { break; }
+ }
+ j = i;
+ do { ISAb[SA[i] = ~SA[i]] = j; } while(SA[--i] < 0);
+ ISAb[SA[i]] = j;
+ }
+
+ /* Construct the inverse suffix array of type B* suffixes using trsort. */
+ trsort(ISAb, SA, m, 1);
+
+ /* Set the sorted order of tyoe B* suffixes. */
+ for(i = n - 1, j = m, c0 = T[n - 1]; 0 <= i;) {
+ for(--i, c1 = c0; (0 <= i) && ((c0 = T[i]) >= c1); --i, c1 = c0) { }
+ if(0 <= i) {
+ t = i;
+ for(--i, c1 = c0; (0 <= i) && ((c0 = T[i]) <= c1); --i, c1 = c0) { }
+ SA[ISAb[--j]] = ((t == 0) || (1 < (t - i))) ? t : ~t;
+ }
+ }
+
+ /* Calculate the index of start/end point of each bucket. */
+ BUCKET_B(ALPHABET_SIZE - 1, ALPHABET_SIZE - 1) = n; /* end point */
+ for(c0 = ALPHABET_SIZE - 2, k = m - 1; 0 <= c0; --c0) {
+ i = BUCKET_A(c0 + 1) - 1;
+ for(c1 = ALPHABET_SIZE - 1; c0 < c1; --c1) {
+ t = i - BUCKET_B(c0, c1);
+ BUCKET_B(c0, c1) = i; /* end point */
+
+ /* Move all type B* suffixes to the correct position. */
+ for(i = t, j = BUCKET_BSTAR(c0, c1);
+ j <= k;
+ --i, --k) { SA[i] = SA[k]; }
+ }
+ BUCKET_BSTAR(c0, c0 + 1) = i - BUCKET_B(c0, c0) + 1; /* start point */
+ BUCKET_B(c0, c0) = i; /* end point */
+ }
+ }
+
+ return m;
+}
+
+/* Constructs the suffix array by using the sorted order of type B* suffixes. */
+static
+void
+construct_SA(const unsigned char *T, int *SA,
+ int *bucket_A, int *bucket_B,
+ int n, int m) {
+ int *i, *j, *k;
+ int s;
+ int c0, c1, c2;
+
+ if(0 < m) {
+ /* Construct the sorted order of type B suffixes by using
+ the sorted order of type B* suffixes. */
+ for(c1 = ALPHABET_SIZE - 2; 0 <= c1; --c1) {
+ /* Scan the suffix array from right to left. */
+ for(i = SA + BUCKET_BSTAR(c1, c1 + 1),
+ j = SA + BUCKET_A(c1 + 1) - 1, k = NULL, c2 = -1;
+ i <= j;
+ --j) {
+ if(0 < (s = *j)) {
+ assert(T[s] == c1);
+ assert(((s + 1) < n) && (T[s] <= T[s + 1]));
+ assert(T[s - 1] <= T[s]);
+ *j = ~s;
+ c0 = T[--s];
+ if((0 < s) && (T[s - 1] > c0)) { s = ~s; }
+ if(c0 != c2) {
+ if(0 <= c2) { BUCKET_B(c2, c1) = k - SA; }
+ k = SA + BUCKET_B(c2 = c0, c1);
+ }
+ assert(k < j); assert(k != NULL);
+ *k-- = s;
+ } else {
+ assert(((s == 0) && (T[s] == c1)) || (s < 0));
+ *j = ~s;
+ }
+ }
+ }
+ }
+
+ /* Construct the suffix array by using
+ the sorted order of type B suffixes. */
+ k = SA + BUCKET_A(c2 = T[n - 1]);
+ *k++ = (T[n - 2] < c2) ? ~(n - 1) : (n - 1);
+ /* Scan the suffix array from left to right. */
+ for(i = SA, j = SA + n; i < j; ++i) {
+ if(0 < (s = *i)) {
+ assert(T[s - 1] >= T[s]);
+ c0 = T[--s];
+ if((s == 0) || (T[s - 1] < c0)) { s = ~s; }
+ if(c0 != c2) {
+ BUCKET_A(c2) = k - SA;
+ k = SA + BUCKET_A(c2 = c0);
+ }
+ assert(i < k);
+ *k++ = s;
+ } else {
+ assert(s < 0);
+ *i = ~s;
+ }
+ }
+}
+
+/* Constructs the burrows-wheeler transformed string directly
+ by using the sorted order of type B* suffixes. */
+static
+int
+construct_BWT(const unsigned char *T, int *SA,
+ int *bucket_A, int *bucket_B,
+ int n, int m) {
+ int *i, *j, *k, *orig;
+ int s;
+ int c0, c1, c2;
+
+ if(0 < m) {
+ /* Construct the sorted order of type B suffixes by using
+ the sorted order of type B* suffixes. */
+ for(c1 = ALPHABET_SIZE - 2; 0 <= c1; --c1) {
+ /* Scan the suffix array from right to left. */
+ for(i = SA + BUCKET_BSTAR(c1, c1 + 1),
+ j = SA + BUCKET_A(c1 + 1) - 1, k = NULL, c2 = -1;
+ i <= j;
+ --j) {
+ if(0 < (s = *j)) {
+ assert(T[s] == c1);
+ assert(((s + 1) < n) && (T[s] <= T[s + 1]));
+ assert(T[s - 1] <= T[s]);
+ c0 = T[--s];
+ *j = ~((int)c0);
+ if((0 < s) && (T[s - 1] > c0)) { s = ~s; }
+ if(c0 != c2) {
+ if(0 <= c2) { BUCKET_B(c2, c1) = k - SA; }
+ k = SA + BUCKET_B(c2 = c0, c1);
+ }
+ assert(k < j); assert(k != NULL);
+ *k-- = s;
+ } else if(s != 0) {
+ *j = ~s;
+#ifndef NDEBUG
+ } else {
+ assert(T[s] == c1);
+#endif
+ }
+ }
+ }
+ }
+
+ /* Construct the BWTed string by using
+ the sorted order of type B suffixes. */
+ k = SA + BUCKET_A(c2 = T[n - 1]);
+ *k++ = (T[n - 2] < c2) ? ~((int)T[n - 2]) : (n - 1);
+ /* Scan the suffix array from left to right. */
+ for(i = SA, j = SA + n, orig = SA; i < j; ++i) {
+ if(0 < (s = *i)) {
+ assert(T[s - 1] >= T[s]);
+ c0 = T[--s];
+ *i = c0;
+ if((0 < s) && (T[s - 1] < c0)) { s = ~((int)T[s - 1]); }
+ if(c0 != c2) {
+ BUCKET_A(c2) = k - SA;
+ k = SA + BUCKET_A(c2 = c0);
+ }
+ assert(i < k);
+ *k++ = s;
+ } else if(s != 0) {
+ *i = ~s;
+ } else {
+ orig = i;
+ }
+ }
+
+ return orig - SA;
+}
+
+/* Constructs the burrows-wheeler transformed string directly
+ by using the sorted order of type B* suffixes. */
+static
+int
+construct_BWT_indexes(const unsigned char *T, int *SA,
+ int *bucket_A, int *bucket_B,
+ int n, int m,
+ unsigned char * num_indexes, int * indexes) {
+ int *i, *j, *k, *orig;
+ int s;
+ int c0, c1, c2;
+
+ int mod = n / 8;
+ {
+ mod |= mod >> 1; mod |= mod >> 2;
+ mod |= mod >> 4; mod |= mod >> 8;
+ mod |= mod >> 16; mod >>= 1;
+
+ *num_indexes = (unsigned char)((n - 1) / (mod + 1));
+ }
+
+ if(0 < m) {
+ /* Construct the sorted order of type B suffixes by using
+ the sorted order of type B* suffixes. */
+ for(c1 = ALPHABET_SIZE - 2; 0 <= c1; --c1) {
+ /* Scan the suffix array from right to left. */
+ for(i = SA + BUCKET_BSTAR(c1, c1 + 1),
+ j = SA + BUCKET_A(c1 + 1) - 1, k = NULL, c2 = -1;
+ i <= j;
+ --j) {
+ if(0 < (s = *j)) {
+ assert(T[s] == c1);
+ assert(((s + 1) < n) && (T[s] <= T[s + 1]));
+ assert(T[s - 1] <= T[s]);
+
+ if ((s & mod) == 0) indexes[s / (mod + 1) - 1] = j - SA;
+
+ c0 = T[--s];
+ *j = ~((int)c0);
+ if((0 < s) && (T[s - 1] > c0)) { s = ~s; }
+ if(c0 != c2) {
+ if(0 <= c2) { BUCKET_B(c2, c1) = k - SA; }
+ k = SA + BUCKET_B(c2 = c0, c1);
+ }
+ assert(k < j); assert(k != NULL);
+ *k-- = s;
+ } else if(s != 0) {
+ *j = ~s;
+#ifndef NDEBUG
+ } else {
+ assert(T[s] == c1);
+#endif
+ }
+ }
+ }
+ }
+
+ /* Construct the BWTed string by using
+ the sorted order of type B suffixes. */
+ k = SA + BUCKET_A(c2 = T[n - 1]);
+ if (T[n - 2] < c2) {
+ if (((n - 1) & mod) == 0) indexes[(n - 1) / (mod + 1) - 1] = k - SA;
+ *k++ = ~((int)T[n - 2]);
+ }
+ else {
+ *k++ = n - 1;
+ }
+
+ /* Scan the suffix array from left to right. */
+ for(i = SA, j = SA + n, orig = SA; i < j; ++i) {
+ if(0 < (s = *i)) {
+ assert(T[s - 1] >= T[s]);
+
+ if ((s & mod) == 0) indexes[s / (mod + 1) - 1] = i - SA;
+
+ c0 = T[--s];
+ *i = c0;
+ if(c0 != c2) {
+ BUCKET_A(c2) = k - SA;
+ k = SA + BUCKET_A(c2 = c0);
+ }
+ assert(i < k);
+ if((0 < s) && (T[s - 1] < c0)) {
+ if ((s & mod) == 0) indexes[s / (mod + 1) - 1] = k - SA;
+ *k++ = ~((int)T[s - 1]);
+ } else
+ *k++ = s;
+ } else if(s != 0) {
+ *i = ~s;
+ } else {
+ orig = i;
+ }
+ }
+
+ return orig - SA;
+}
+
+
+/*---------------------------------------------------------------------------*/
+
+/*- Function -*/
+
+int
+divsufsort(const unsigned char *T, int *SA, int n, int openMP) {
+ int *bucket_A, *bucket_B;
+ int m;
+ int err = 0;
+
+ /* Check arguments. */
+ if((T == NULL) || (SA == NULL) || (n < 0)) { return -1; }
+ else if(n == 0) { return 0; }
+ else if(n == 1) { SA[0] = 0; return 0; }
+ else if(n == 2) { m = (T[0] < T[1]); SA[m ^ 1] = 0, SA[m] = 1; return 0; }
+
+ bucket_A = (int *)malloc(BUCKET_A_SIZE * sizeof(int));
+ bucket_B = (int *)malloc(BUCKET_B_SIZE * sizeof(int));
+
+ /* Suffixsort. */
+ if((bucket_A != NULL) && (bucket_B != NULL)) {
+ m = sort_typeBstar(T, SA, bucket_A, bucket_B, n, openMP);
+ construct_SA(T, SA, bucket_A, bucket_B, n, m);
+ } else {
+ err = -2;
+ }
+
+ free(bucket_B);
+ free(bucket_A);
+
+ return err;
+}
+
+int
+divbwt(const unsigned char *T, unsigned char *U, int *A, int n, unsigned char * num_indexes, int * indexes, int openMP) {
+ int *B;
+ int *bucket_A, *bucket_B;
+ int m, pidx, i;
+
+ /* Check arguments. */
+ if((T == NULL) || (U == NULL) || (n < 0)) { return -1; }
+ else if(n <= 1) { if(n == 1) { U[0] = T[0]; } return n; }
+
+ if((B = A) == NULL) { B = (int *)malloc((size_t)(n + 1) * sizeof(int)); }
+ bucket_A = (int *)malloc(BUCKET_A_SIZE * sizeof(int));
+ bucket_B = (int *)malloc(BUCKET_B_SIZE * sizeof(int));
+
+ /* Burrows-Wheeler Transform. */
+ if((B != NULL) && (bucket_A != NULL) && (bucket_B != NULL)) {
+ m = sort_typeBstar(T, B, bucket_A, bucket_B, n, openMP);
+
+ if (num_indexes == NULL || indexes == NULL) {
+ pidx = construct_BWT(T, B, bucket_A, bucket_B, n, m);
+ } else {
+ pidx = construct_BWT_indexes(T, B, bucket_A, bucket_B, n, m, num_indexes, indexes);
+ }
+
+ /* Copy to output string. */
+ U[0] = T[n - 1];
+ for(i = 0; i < pidx; ++i) { U[i + 1] = (unsigned char)B[i]; }
+ for(i += 1; i < n; ++i) { U[i] = (unsigned char)B[i]; }
+ pidx += 1;
+ } else {
+ pidx = -2;
+ }
+
+ free(bucket_B);
+ free(bucket_A);
+ if(A == NULL) { free(B); }
+
+ return pidx;
+}
diff --git a/Utilities/cmzstd/lib/dictBuilder/divsufsort.h b/Utilities/cmzstd/lib/dictBuilder/divsufsort.h
new file mode 100644
index 000000000..5440994af
--- /dev/null
+++ b/Utilities/cmzstd/lib/dictBuilder/divsufsort.h
@@ -0,0 +1,67 @@
+/*
+ * divsufsort.h for libdivsufsort-lite
+ * Copyright (c) 2003-2008 Yuta Mori All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _DIVSUFSORT_H
+#define _DIVSUFSORT_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/*- Prototypes -*/
+
+/**
+ * Constructs the suffix array of a given string.
+ * @param T [0..n-1] The input string.
+ * @param SA [0..n-1] The output array of suffixes.
+ * @param n The length of the given string.
+ * @param openMP enables OpenMP optimization.
+ * @return 0 if no error occurred, -1 or -2 otherwise.
+ */
+int
+divsufsort(const unsigned char *T, int *SA, int n, int openMP);
+
+/**
+ * Constructs the burrows-wheeler transformed string of a given string.
+ * @param T [0..n-1] The input string.
+ * @param U [0..n-1] The output string. (can be T)
+ * @param A [0..n-1] The temporary array. (can be NULL)
+ * @param n The length of the given string.
+ * @param num_indexes The length of secondary indexes array. (can be NULL)
+ * @param indexes The secondary indexes array. (can be NULL)
+ * @param openMP enables OpenMP optimization.
+ * @return The primary index if no error occurred, -1 or -2 otherwise.
+ */
+int
+divbwt(const unsigned char *T, unsigned char *U, int *A, int n, unsigned char * num_indexes, int * indexes, int openMP);
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif /* __cplusplus */
+
+#endif /* _DIVSUFSORT_H */
diff --git a/Utilities/cmzstd/lib/dictBuilder/fastcover.c b/Utilities/cmzstd/lib/dictBuilder/fastcover.c
new file mode 100644
index 000000000..c289c0690
--- /dev/null
+++ b/Utilities/cmzstd/lib/dictBuilder/fastcover.c
@@ -0,0 +1,728 @@
+/*-*************************************
+* Dependencies
+***************************************/
+#include <stdio.h> /* fprintf */
+#include <stdlib.h> /* malloc, free, qsort */
+#include <string.h> /* memset */
+#include <time.h> /* clock */
+
+#include "mem.h" /* read */
+#include "pool.h"
+#include "threading.h"
+#include "cover.h"
+#include "zstd_internal.h" /* includes zstd.h */
+#ifndef ZDICT_STATIC_LINKING_ONLY
+#define ZDICT_STATIC_LINKING_ONLY
+#endif
+#include "zdict.h"
+
+
+/*-*************************************
+* Constants
+***************************************/
+#define FASTCOVER_MAX_SAMPLES_SIZE (sizeof(size_t) == 8 ? ((unsigned)-1) : ((unsigned)1 GB))
+#define FASTCOVER_MAX_F 31
+#define FASTCOVER_MAX_ACCEL 10
+#define DEFAULT_SPLITPOINT 0.75
+#define DEFAULT_F 20
+#define DEFAULT_ACCEL 1
+
+
+/*-*************************************
+* Console display
+***************************************/
+static int g_displayLevel = 2;
+#define DISPLAY(...) \
+ { \
+ fprintf(stderr, __VA_ARGS__); \
+ fflush(stderr); \
+ }
+#define LOCALDISPLAYLEVEL(displayLevel, l, ...) \
+ if (displayLevel >= l) { \
+ DISPLAY(__VA_ARGS__); \
+ } /* 0 : no display; 1: errors; 2: default; 3: details; 4: debug */
+#define DISPLAYLEVEL(l, ...) LOCALDISPLAYLEVEL(g_displayLevel, l, __VA_ARGS__)
+
+#define LOCALDISPLAYUPDATE(displayLevel, l, ...) \
+ if (displayLevel >= l) { \
+ if ((clock() - g_time > refreshRate) || (displayLevel >= 4)) { \
+ g_time = clock(); \
+ DISPLAY(__VA_ARGS__); \
+ } \
+ }
+#define DISPLAYUPDATE(l, ...) LOCALDISPLAYUPDATE(g_displayLevel, l, __VA_ARGS__)
+static const clock_t refreshRate = CLOCKS_PER_SEC * 15 / 100;
+static clock_t g_time = 0;
+
+
+/*-*************************************
+* Hash Functions
+***************************************/
+static const U64 prime6bytes = 227718039650203ULL;
+static size_t ZSTD_hash6(U64 u, U32 h) { return (size_t)(((u << (64-48)) * prime6bytes) >> (64-h)) ; }
+static size_t ZSTD_hash6Ptr(const void* p, U32 h) { return ZSTD_hash6(MEM_readLE64(p), h); }
+
+static const U64 prime8bytes = 0xCF1BBCDCB7A56463ULL;
+static size_t ZSTD_hash8(U64 u, U32 h) { return (size_t)(((u) * prime8bytes) >> (64-h)) ; }
+static size_t ZSTD_hash8Ptr(const void* p, U32 h) { return ZSTD_hash8(MEM_readLE64(p), h); }
+
+
+/**
+ * Hash the d-byte value pointed to by p and mod 2^f
+ */
+static size_t FASTCOVER_hashPtrToIndex(const void* p, U32 h, unsigned d) {
+ if (d == 6) {
+ return ZSTD_hash6Ptr(p, h) & ((1 << h) - 1);
+ }
+ return ZSTD_hash8Ptr(p, h) & ((1 << h) - 1);
+}
+
+
+/*-*************************************
+* Acceleration
+***************************************/
+typedef struct {
+ unsigned finalize; /* Percentage of training samples used for ZDICT_finalizeDictionary */
+ unsigned skip; /* Number of dmer skipped between each dmer counted in computeFrequency */
+} FASTCOVER_accel_t;
+
+
+static const FASTCOVER_accel_t FASTCOVER_defaultAccelParameters[FASTCOVER_MAX_ACCEL+1] = {
+ { 100, 0 }, /* accel = 0, should not happen because accel = 0 defaults to accel = 1 */
+ { 100, 0 }, /* accel = 1 */
+ { 50, 1 }, /* accel = 2 */
+ { 34, 2 }, /* accel = 3 */
+ { 25, 3 }, /* accel = 4 */
+ { 20, 4 }, /* accel = 5 */
+ { 17, 5 }, /* accel = 6 */
+ { 14, 6 }, /* accel = 7 */
+ { 13, 7 }, /* accel = 8 */
+ { 11, 8 }, /* accel = 9 */
+ { 10, 9 }, /* accel = 10 */
+};
+
+
+/*-*************************************
+* Context
+***************************************/
+typedef struct {
+ const BYTE *samples;
+ size_t *offsets;
+ const size_t *samplesSizes;
+ size_t nbSamples;
+ size_t nbTrainSamples;
+ size_t nbTestSamples;
+ size_t nbDmers;
+ U32 *freqs;
+ unsigned d;
+ unsigned f;
+ FASTCOVER_accel_t accelParams;
+} FASTCOVER_ctx_t;
+
+
+/*-*************************************
+* Helper functions
+***************************************/
+/**
+ * Selects the best segment in an epoch.
+ * Segments of are scored according to the function:
+ *
+ * Let F(d) be the frequency of all dmers with hash value d.
+ * Let S_i be hash value of the dmer at position i of segment S which has length k.
+ *
+ * Score(S) = F(S_1) + F(S_2) + ... + F(S_{k-d+1})
+ *
+ * Once the dmer with hash value d is in the dictionay we set F(d) = 0.
+ */
+static COVER_segment_t FASTCOVER_selectSegment(const FASTCOVER_ctx_t *ctx,
+ U32 *freqs, U32 begin, U32 end,
+ ZDICT_cover_params_t parameters,
+ U16* segmentFreqs) {
+ /* Constants */
+ const U32 k = parameters.k;
+ const U32 d = parameters.d;
+ const U32 f = ctx->f;
+ const U32 dmersInK = k - d + 1;
+
+ /* Try each segment (activeSegment) and save the best (bestSegment) */
+ COVER_segment_t bestSegment = {0, 0, 0};
+ COVER_segment_t activeSegment;
+
+ /* Reset the activeDmers in the segment */
+ /* The activeSegment starts at the beginning of the epoch. */
+ activeSegment.begin = begin;
+ activeSegment.end = begin;
+ activeSegment.score = 0;
+
+ /* Slide the activeSegment through the whole epoch.
+ * Save the best segment in bestSegment.
+ */
+ while (activeSegment.end < end) {
+ /* Get hash value of current dmer */
+ const size_t idx = FASTCOVER_hashPtrToIndex(ctx->samples + activeSegment.end, f, d);
+
+ /* Add frequency of this index to score if this is the first occurence of index in active segment */
+ if (segmentFreqs[idx] == 0) {
+ activeSegment.score += freqs[idx];
+ }
+ /* Increment end of segment and segmentFreqs*/
+ activeSegment.end += 1;
+ segmentFreqs[idx] += 1;
+ /* If the window is now too large, drop the first position */
+ if (activeSegment.end - activeSegment.begin == dmersInK + 1) {
+ /* Get hash value of the dmer to be eliminated from active segment */
+ const size_t delIndex = FASTCOVER_hashPtrToIndex(ctx->samples + activeSegment.begin, f, d);
+ segmentFreqs[delIndex] -= 1;
+ /* Subtract frequency of this index from score if this is the last occurrence of this index in active segment */
+ if (segmentFreqs[delIndex] == 0) {
+ activeSegment.score -= freqs[delIndex];
+ }
+ /* Increment start of segment */
+ activeSegment.begin += 1;
+ }
+
+ /* If this segment is the best so far save it */
+ if (activeSegment.score > bestSegment.score) {
+ bestSegment = activeSegment;
+ }
+ }
+
+ /* Zero out rest of segmentFreqs array */
+ while (activeSegment.begin < end) {
+ const size_t delIndex = FASTCOVER_hashPtrToIndex(ctx->samples + activeSegment.begin, f, d);
+ segmentFreqs[delIndex] -= 1;
+ activeSegment.begin += 1;
+ }
+
+ {
+ /* Zero the frequency of hash value of each dmer covered by the chosen segment. */
+ U32 pos;
+ for (pos = bestSegment.begin; pos != bestSegment.end; ++pos) {
+ const size_t i = FASTCOVER_hashPtrToIndex(ctx->samples + pos, f, d);
+ freqs[i] = 0;
+ }
+ }
+
+ return bestSegment;
+}
+
+
+static int FASTCOVER_checkParameters(ZDICT_cover_params_t parameters,
+ size_t maxDictSize, unsigned f,
+ unsigned accel) {
+ /* k, d, and f are required parameters */
+ if (parameters.d == 0 || parameters.k == 0) {
+ return 0;
+ }
+ /* d has to be 6 or 8 */
+ if (parameters.d != 6 && parameters.d != 8) {
+ return 0;
+ }
+ /* k <= maxDictSize */
+ if (parameters.k > maxDictSize) {
+ return 0;
+ }
+ /* d <= k */
+ if (parameters.d > parameters.k) {
+ return 0;
+ }
+ /* 0 < f <= FASTCOVER_MAX_F*/
+ if (f > FASTCOVER_MAX_F || f == 0) {
+ return 0;
+ }
+ /* 0 < splitPoint <= 1 */
+ if (parameters.splitPoint <= 0 || parameters.splitPoint > 1) {
+ return 0;
+ }
+ /* 0 < accel <= 10 */
+ if (accel > 10 || accel == 0) {
+ return 0;
+ }
+ return 1;
+}
+
+
+/**
+ * Clean up a context initialized with `FASTCOVER_ctx_init()`.
+ */
+static void
+FASTCOVER_ctx_destroy(FASTCOVER_ctx_t* ctx)
+{
+ if (!ctx) return;
+
+ free(ctx->freqs);
+ ctx->freqs = NULL;
+
+ free(ctx->offsets);
+ ctx->offsets = NULL;
+}
+
+
+/**
+ * Calculate for frequency of hash value of each dmer in ctx->samples
+ */
+static void
+FASTCOVER_computeFrequency(U32* freqs, const FASTCOVER_ctx_t* ctx)
+{
+ const unsigned f = ctx->f;
+ const unsigned d = ctx->d;
+ const unsigned skip = ctx->accelParams.skip;
+ const unsigned readLength = MAX(d, 8);
+ size_t i;
+ assert(ctx->nbTrainSamples >= 5);
+ assert(ctx->nbTrainSamples <= ctx->nbSamples);
+ for (i = 0; i < ctx->nbTrainSamples; i++) {
+ size_t start = ctx->offsets[i]; /* start of current dmer */
+ size_t const currSampleEnd = ctx->offsets[i+1];
+ while (start + readLength <= currSampleEnd) {
+ const size_t dmerIndex = FASTCOVER_hashPtrToIndex(ctx->samples + start, f, d);
+ freqs[dmerIndex]++;
+ start = start + skip + 1;
+ }
+ }
+}
+
+
+/**
+ * Prepare a context for dictionary building.
+ * The context is only dependent on the parameter `d` and can used multiple
+ * times.
+ * Returns 1 on success or zero on error.
+ * The context must be destroyed with `FASTCOVER_ctx_destroy()`.
+ */
+static int
+FASTCOVER_ctx_init(FASTCOVER_ctx_t* ctx,
+ const void* samplesBuffer,
+ const size_t* samplesSizes, unsigned nbSamples,
+ unsigned d, double splitPoint, unsigned f,
+ FASTCOVER_accel_t accelParams)
+{
+ const BYTE* const samples = (const BYTE*)samplesBuffer;
+ const size_t totalSamplesSize = COVER_sum(samplesSizes, nbSamples);
+ /* Split samples into testing and training sets */
+ const unsigned nbTrainSamples = splitPoint < 1.0 ? (unsigned)((double)nbSamples * splitPoint) : nbSamples;
+ const unsigned nbTestSamples = splitPoint < 1.0 ? nbSamples - nbTrainSamples : nbSamples;
+ const size_t trainingSamplesSize = splitPoint < 1.0 ? COVER_sum(samplesSizes, nbTrainSamples) : totalSamplesSize;
+ const size_t testSamplesSize = splitPoint < 1.0 ? COVER_sum(samplesSizes + nbTrainSamples, nbTestSamples) : totalSamplesSize;
+
+ /* Checks */
+ if (totalSamplesSize < MAX(d, sizeof(U64)) ||
+ totalSamplesSize >= (size_t)FASTCOVER_MAX_SAMPLES_SIZE) {
+ DISPLAYLEVEL(1, "Total samples size is too large (%u MB), maximum size is %u MB\n",
+ (unsigned)(totalSamplesSize >> 20), (FASTCOVER_MAX_SAMPLES_SIZE >> 20));
+ return 0;
+ }
+
+ /* Check if there are at least 5 training samples */
+ if (nbTrainSamples < 5) {
+ DISPLAYLEVEL(1, "Total number of training samples is %u and is invalid\n", nbTrainSamples);
+ return 0;
+ }
+
+ /* Check if there's testing sample */
+ if (nbTestSamples < 1) {
+ DISPLAYLEVEL(1, "Total number of testing samples is %u and is invalid.\n", nbTestSamples);
+ return 0;
+ }
+
+ /* Zero the context */
+ memset(ctx, 0, sizeof(*ctx));
+ DISPLAYLEVEL(2, "Training on %u samples of total size %u\n", nbTrainSamples,
+ (unsigned)trainingSamplesSize);
+ DISPLAYLEVEL(2, "Testing on %u samples of total size %u\n", nbTestSamples,
+ (unsigned)testSamplesSize);
+
+ ctx->samples = samples;
+ ctx->samplesSizes = samplesSizes;
+ ctx->nbSamples = nbSamples;
+ ctx->nbTrainSamples = nbTrainSamples;
+ ctx->nbTestSamples = nbTestSamples;
+ ctx->nbDmers = trainingSamplesSize - MAX(d, sizeof(U64)) + 1;
+ ctx->d = d;
+ ctx->f = f;
+ ctx->accelParams = accelParams;
+
+ /* The offsets of each file */
+ ctx->offsets = (size_t*)calloc((nbSamples + 1), sizeof(size_t));
+ if (ctx->offsets == NULL) {
+ DISPLAYLEVEL(1, "Failed to allocate scratch buffers \n");
+ FASTCOVER_ctx_destroy(ctx);
+ return 0;
+ }
+
+ /* Fill offsets from the samplesSizes */
+ { U32 i;
+ ctx->offsets[0] = 0;
+ assert(nbSamples >= 5);
+ for (i = 1; i <= nbSamples; ++i) {
+ ctx->offsets[i] = ctx->offsets[i - 1] + samplesSizes[i - 1];
+ }
+ }
+
+ /* Initialize frequency array of size 2^f */
+ ctx->freqs = (U32*)calloc(((U64)1 << f), sizeof(U32));
+ if (ctx->freqs == NULL) {
+ DISPLAYLEVEL(1, "Failed to allocate frequency table \n");
+ FASTCOVER_ctx_destroy(ctx);
+ return 0;
+ }
+
+ DISPLAYLEVEL(2, "Computing frequencies\n");
+ FASTCOVER_computeFrequency(ctx->freqs, ctx);
+
+ return 1;
+}
+
+
+/**
+ * Given the prepared context build the dictionary.
+ */
+static size_t
+FASTCOVER_buildDictionary(const FASTCOVER_ctx_t* ctx,
+ U32* freqs,
+ void* dictBuffer, size_t dictBufferCapacity,
+ ZDICT_cover_params_t parameters,
+ U16* segmentFreqs)
+{
+ BYTE *const dict = (BYTE *)dictBuffer;
+ size_t tail = dictBufferCapacity;
+ /* Divide the data up into epochs of equal size.
+ * We will select at least one segment from each epoch.
+ */
+ const unsigned epochs = MAX(1, (U32)(dictBufferCapacity / parameters.k));
+ const unsigned epochSize = (U32)(ctx->nbDmers / epochs);
+ size_t epoch;
+ DISPLAYLEVEL(2, "Breaking content into %u epochs of size %u\n",
+ epochs, epochSize);
+ /* Loop through the epochs until there are no more segments or the dictionary
+ * is full.
+ */
+ for (epoch = 0; tail > 0; epoch = (epoch + 1) % epochs) {
+ const U32 epochBegin = (U32)(epoch * epochSize);
+ const U32 epochEnd = epochBegin + epochSize;
+ size_t segmentSize;
+ /* Select a segment */
+ COVER_segment_t segment = FASTCOVER_selectSegment(
+ ctx, freqs, epochBegin, epochEnd, parameters, segmentFreqs);
+
+ /* If the segment covers no dmers, then we are out of content */
+ if (segment.score == 0) {
+ break;
+ }
+
+ /* Trim the segment if necessary and if it is too small then we are done */
+ segmentSize = MIN(segment.end - segment.begin + parameters.d - 1, tail);
+ if (segmentSize < parameters.d) {
+ break;
+ }
+
+ /* We fill the dictionary from the back to allow the best segments to be
+ * referenced with the smallest offsets.
+ */
+ tail -= segmentSize;
+ memcpy(dict + tail, ctx->samples + segment.begin, segmentSize);
+ DISPLAYUPDATE(
+ 2, "\r%u%% ",
+ (unsigned)(((dictBufferCapacity - tail) * 100) / dictBufferCapacity));
+ }
+ DISPLAYLEVEL(2, "\r%79s\r", "");
+ return tail;
+}
+
+
+/**
+ * Parameters for FASTCOVER_tryParameters().
+ */
+typedef struct FASTCOVER_tryParameters_data_s {
+ const FASTCOVER_ctx_t* ctx;
+ COVER_best_t* best;
+ size_t dictBufferCapacity;
+ ZDICT_cover_params_t parameters;
+} FASTCOVER_tryParameters_data_t;
+
+
+/**
+ * Tries a set of parameters and updates the COVER_best_t with the results.
+ * This function is thread safe if zstd is compiled with multithreaded support.
+ * It takes its parameters as an *OWNING* opaque pointer to support threading.
+ */
+static void FASTCOVER_tryParameters(void *opaque)
+{
+ /* Save parameters as local variables */
+ FASTCOVER_tryParameters_data_t *const data = (FASTCOVER_tryParameters_data_t *)opaque;
+ const FASTCOVER_ctx_t *const ctx = data->ctx;
+ const ZDICT_cover_params_t parameters = data->parameters;
+ size_t dictBufferCapacity = data->dictBufferCapacity;
+ size_t totalCompressedSize = ERROR(GENERIC);
+ /* Initialize array to keep track of frequency of dmer within activeSegment */
+ U16* segmentFreqs = (U16 *)calloc(((U64)1 << ctx->f), sizeof(U16));
+ /* Allocate space for hash table, dict, and freqs */
+ BYTE *const dict = (BYTE * const)malloc(dictBufferCapacity);
+ U32 *freqs = (U32*) malloc(((U64)1 << ctx->f) * sizeof(U32));
+ if (!segmentFreqs || !dict || !freqs) {
+ DISPLAYLEVEL(1, "Failed to allocate buffers: out of memory\n");
+ goto _cleanup;
+ }
+ /* Copy the frequencies because we need to modify them */
+ memcpy(freqs, ctx->freqs, ((U64)1 << ctx->f) * sizeof(U32));
+ /* Build the dictionary */
+ { const size_t tail = FASTCOVER_buildDictionary(ctx, freqs, dict, dictBufferCapacity,
+ parameters, segmentFreqs);
+ const unsigned nbFinalizeSamples = (unsigned)(ctx->nbTrainSamples * ctx->accelParams.finalize / 100);
+ dictBufferCapacity = ZDICT_finalizeDictionary(
+ dict, dictBufferCapacity, dict + tail, dictBufferCapacity - tail,
+ ctx->samples, ctx->samplesSizes, nbFinalizeSamples, parameters.zParams);
+ if (ZDICT_isError(dictBufferCapacity)) {
+ DISPLAYLEVEL(1, "Failed to finalize dictionary\n");
+ goto _cleanup;
+ }
+ }
+ /* Check total compressed size */
+ totalCompressedSize = COVER_checkTotalCompressedSize(parameters, ctx->samplesSizes,
+ ctx->samples, ctx->offsets,
+ ctx->nbTrainSamples, ctx->nbSamples,
+ dict, dictBufferCapacity);
+_cleanup:
+ COVER_best_finish(data->best, totalCompressedSize, parameters, dict,
+ dictBufferCapacity);
+ free(data);
+ free(segmentFreqs);
+ free(dict);
+ free(freqs);
+}
+
+
+static void
+FASTCOVER_convertToCoverParams(ZDICT_fastCover_params_t fastCoverParams,
+ ZDICT_cover_params_t* coverParams)
+{
+ coverParams->k = fastCoverParams.k;
+ coverParams->d = fastCoverParams.d;
+ coverParams->steps = fastCoverParams.steps;
+ coverParams->nbThreads = fastCoverParams.nbThreads;
+ coverParams->splitPoint = fastCoverParams.splitPoint;
+ coverParams->zParams = fastCoverParams.zParams;
+}
+
+
+static void
+FASTCOVER_convertToFastCoverParams(ZDICT_cover_params_t coverParams,
+ ZDICT_fastCover_params_t* fastCoverParams,
+ unsigned f, unsigned accel)
+{
+ fastCoverParams->k = coverParams.k;
+ fastCoverParams->d = coverParams.d;
+ fastCoverParams->steps = coverParams.steps;
+ fastCoverParams->nbThreads = coverParams.nbThreads;
+ fastCoverParams->splitPoint = coverParams.splitPoint;
+ fastCoverParams->f = f;
+ fastCoverParams->accel = accel;
+ fastCoverParams->zParams = coverParams.zParams;
+}
+
+
+ZDICTLIB_API size_t
+ZDICT_trainFromBuffer_fastCover(void* dictBuffer, size_t dictBufferCapacity,
+ const void* samplesBuffer,
+ const size_t* samplesSizes, unsigned nbSamples,
+ ZDICT_fastCover_params_t parameters)
+{
+ BYTE* const dict = (BYTE*)dictBuffer;
+ FASTCOVER_ctx_t ctx;
+ ZDICT_cover_params_t coverParams;
+ FASTCOVER_accel_t accelParams;
+ /* Initialize global data */
+ g_displayLevel = parameters.zParams.notificationLevel;
+ /* Assign splitPoint and f if not provided */
+ parameters.splitPoint = 1.0;
+ parameters.f = parameters.f == 0 ? DEFAULT_F : parameters.f;
+ parameters.accel = parameters.accel == 0 ? DEFAULT_ACCEL : parameters.accel;
+ /* Convert to cover parameter */
+ memset(&coverParams, 0 , sizeof(coverParams));
+ FASTCOVER_convertToCoverParams(parameters, &coverParams);
+ /* Checks */
+ if (!FASTCOVER_checkParameters(coverParams, dictBufferCapacity, parameters.f,
+ parameters.accel)) {
+ DISPLAYLEVEL(1, "FASTCOVER parameters incorrect\n");
+ return ERROR(GENERIC);
+ }
+ if (nbSamples == 0) {
+ DISPLAYLEVEL(1, "FASTCOVER must have at least one input file\n");
+ return ERROR(GENERIC);
+ }
+ if (dictBufferCapacity < ZDICT_DICTSIZE_MIN) {
+ DISPLAYLEVEL(1, "dictBufferCapacity must be at least %u\n",
+ ZDICT_DICTSIZE_MIN);
+ return ERROR(dstSize_tooSmall);
+ }
+ /* Assign corresponding FASTCOVER_accel_t to accelParams*/
+ accelParams = FASTCOVER_defaultAccelParameters[parameters.accel];
+ /* Initialize context */
+ if (!FASTCOVER_ctx_init(&ctx, samplesBuffer, samplesSizes, nbSamples,
+ coverParams.d, parameters.splitPoint, parameters.f,
+ accelParams)) {
+ DISPLAYLEVEL(1, "Failed to initialize context\n");
+ return ERROR(GENERIC);
+ }
+ /* Build the dictionary */
+ DISPLAYLEVEL(2, "Building dictionary\n");
+ {
+ /* Initialize array to keep track of frequency of dmer within activeSegment */
+ U16* segmentFreqs = (U16 *)calloc(((U64)1 << parameters.f), sizeof(U16));
+ const size_t tail = FASTCOVER_buildDictionary(&ctx, ctx.freqs, dictBuffer,
+ dictBufferCapacity, coverParams, segmentFreqs);
+ const unsigned nbFinalizeSamples = (unsigned)(ctx.nbTrainSamples * ctx.accelParams.finalize / 100);
+ const size_t dictionarySize = ZDICT_finalizeDictionary(
+ dict, dictBufferCapacity, dict + tail, dictBufferCapacity - tail,
+ samplesBuffer, samplesSizes, nbFinalizeSamples, coverParams.zParams);
+ if (!ZSTD_isError(dictionarySize)) {
+ DISPLAYLEVEL(2, "Constructed dictionary of size %u\n",
+ (unsigned)dictionarySize);
+ }
+ FASTCOVER_ctx_destroy(&ctx);
+ free(segmentFreqs);
+ return dictionarySize;
+ }
+}
+
+
+ZDICTLIB_API size_t
+ZDICT_optimizeTrainFromBuffer_fastCover(
+ void* dictBuffer, size_t dictBufferCapacity,
+ const void* samplesBuffer,
+ const size_t* samplesSizes, unsigned nbSamples,
+ ZDICT_fastCover_params_t* parameters)
+{
+ ZDICT_cover_params_t coverParams;
+ FASTCOVER_accel_t accelParams;
+ /* constants */
+ const unsigned nbThreads = parameters->nbThreads;
+ const double splitPoint =
+ parameters->splitPoint <= 0.0 ? DEFAULT_SPLITPOINT : parameters->splitPoint;
+ const unsigned kMinD = parameters->d == 0 ? 6 : parameters->d;
+ const unsigned kMaxD = parameters->d == 0 ? 8 : parameters->d;
+ const unsigned kMinK = parameters->k == 0 ? 50 : parameters->k;
+ const unsigned kMaxK = parameters->k == 0 ? 2000 : parameters->k;
+ const unsigned kSteps = parameters->steps == 0 ? 40 : parameters->steps;
+ const unsigned kStepSize = MAX((kMaxK - kMinK) / kSteps, 1);
+ const unsigned kIterations =
+ (1 + (kMaxD - kMinD) / 2) * (1 + (kMaxK - kMinK) / kStepSize);
+ const unsigned f = parameters->f == 0 ? DEFAULT_F : parameters->f;
+ const unsigned accel = parameters->accel == 0 ? DEFAULT_ACCEL : parameters->accel;
+ /* Local variables */
+ const int displayLevel = parameters->zParams.notificationLevel;
+ unsigned iteration = 1;
+ unsigned d;
+ unsigned k;
+ COVER_best_t best;
+ POOL_ctx *pool = NULL;
+ /* Checks */
+ if (splitPoint <= 0 || splitPoint > 1) {
+ LOCALDISPLAYLEVEL(displayLevel, 1, "Incorrect splitPoint\n");
+ return ERROR(GENERIC);
+ }
+ if (accel == 0 || accel > FASTCOVER_MAX_ACCEL) {
+ LOCALDISPLAYLEVEL(displayLevel, 1, "Incorrect accel\n");
+ return ERROR(GENERIC);
+ }
+ if (kMinK < kMaxD || kMaxK < kMinK) {
+ LOCALDISPLAYLEVEL(displayLevel, 1, "Incorrect k\n");
+ return ERROR(GENERIC);
+ }
+ if (nbSamples == 0) {
+ LOCALDISPLAYLEVEL(displayLevel, 1, "FASTCOVER must have at least one input file\n");
+ return ERROR(GENERIC);
+ }
+ if (dictBufferCapacity < ZDICT_DICTSIZE_MIN) {
+ LOCALDISPLAYLEVEL(displayLevel, 1, "dictBufferCapacity must be at least %u\n",
+ ZDICT_DICTSIZE_MIN);
+ return ERROR(dstSize_tooSmall);
+ }
+ if (nbThreads > 1) {
+ pool = POOL_create(nbThreads, 1);
+ if (!pool) {
+ return ERROR(memory_allocation);
+ }
+ }
+ /* Initialization */
+ COVER_best_init(&best);
+ memset(&coverParams, 0 , sizeof(coverParams));
+ FASTCOVER_convertToCoverParams(*parameters, &coverParams);
+ accelParams = FASTCOVER_defaultAccelParameters[accel];
+ /* Turn down global display level to clean up display at level 2 and below */
+ g_displayLevel = displayLevel == 0 ? 0 : displayLevel - 1;
+ /* Loop through d first because each new value needs a new context */
+ LOCALDISPLAYLEVEL(displayLevel, 2, "Trying %u different sets of parameters\n",
+ kIterations);
+ for (d = kMinD; d <= kMaxD; d += 2) {
+ /* Initialize the context for this value of d */
+ FASTCOVER_ctx_t ctx;
+ LOCALDISPLAYLEVEL(displayLevel, 3, "d=%u\n", d);
+ if (!FASTCOVER_ctx_init(&ctx, samplesBuffer, samplesSizes, nbSamples, d, splitPoint, f, accelParams)) {
+ LOCALDISPLAYLEVEL(displayLevel, 1, "Failed to initialize context\n");
+ COVER_best_destroy(&best);
+ POOL_free(pool);
+ return ERROR(GENERIC);
+ }
+ /* Loop through k reusing the same context */
+ for (k = kMinK; k <= kMaxK; k += kStepSize) {
+ /* Prepare the arguments */
+ FASTCOVER_tryParameters_data_t *data = (FASTCOVER_tryParameters_data_t *)malloc(
+ sizeof(FASTCOVER_tryParameters_data_t));
+ LOCALDISPLAYLEVEL(displayLevel, 3, "k=%u\n", k);
+ if (!data) {
+ LOCALDISPLAYLEVEL(displayLevel, 1, "Failed to allocate parameters\n");
+ COVER_best_destroy(&best);
+ FASTCOVER_ctx_destroy(&ctx);
+ POOL_free(pool);
+ return ERROR(GENERIC);
+ }
+ data->ctx = &ctx;
+ data->best = &best;
+ data->dictBufferCapacity = dictBufferCapacity;
+ data->parameters = coverParams;
+ data->parameters.k = k;
+ data->parameters.d = d;
+ data->parameters.splitPoint = splitPoint;
+ data->parameters.steps = kSteps;
+ data->parameters.zParams.notificationLevel = g_displayLevel;
+ /* Check the parameters */
+ if (!FASTCOVER_checkParameters(data->parameters, dictBufferCapacity,
+ data->ctx->f, accel)) {
+ DISPLAYLEVEL(1, "FASTCOVER parameters incorrect\n");
+ free(data);
+ continue;
+ }
+ /* Call the function and pass ownership of data to it */
+ COVER_best_start(&best);
+ if (pool) {
+ POOL_add(pool, &FASTCOVER_tryParameters, data);
+ } else {
+ FASTCOVER_tryParameters(data);
+ }
+ /* Print status */
+ LOCALDISPLAYUPDATE(displayLevel, 2, "\r%u%% ",
+ (unsigned)((iteration * 100) / kIterations));
+ ++iteration;
+ }
+ COVER_best_wait(&best);
+ FASTCOVER_ctx_destroy(&ctx);
+ }
+ LOCALDISPLAYLEVEL(displayLevel, 2, "\r%79s\r", "");
+ /* Fill the output buffer and parameters with output of the best parameters */
+ {
+ const size_t dictSize = best.dictSize;
+ if (ZSTD_isError(best.compressedSize)) {
+ const size_t compressedSize = best.compressedSize;
+ COVER_best_destroy(&best);
+ POOL_free(pool);
+ return compressedSize;
+ }
+ FASTCOVER_convertToFastCoverParams(best.parameters, parameters, f, accel);
+ memcpy(dictBuffer, best.dict, dictSize);
+ COVER_best_destroy(&best);
+ POOL_free(pool);
+ return dictSize;
+ }
+
+}
diff --git a/Utilities/cmzstd/lib/dictBuilder/zdict.c b/Utilities/cmzstd/lib/dictBuilder/zdict.c
new file mode 100644
index 000000000..c753da0db
--- /dev/null
+++ b/Utilities/cmzstd/lib/dictBuilder/zdict.c
@@ -0,0 +1,1111 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+
+/*-**************************************
+* Tuning parameters
+****************************************/
+#define MINRATIO 4 /* minimum nb of apparition to be selected in dictionary */
+#define ZDICT_MAX_SAMPLES_SIZE (2000U << 20)
+#define ZDICT_MIN_SAMPLES_SIZE (ZDICT_CONTENTSIZE_MIN * MINRATIO)
+
+
+/*-**************************************
+* Compiler Options
+****************************************/
+/* Unix Large Files support (>4GB) */
+#define _FILE_OFFSET_BITS 64
+#if (defined(__sun__) && (!defined(__LP64__))) /* Sun Solaris 32-bits requires specific definitions */
+# define _LARGEFILE_SOURCE
+#elif ! defined(__LP64__) /* No point defining Large file for 64 bit */
+# define _LARGEFILE64_SOURCE
+#endif
+
+
+/*-*************************************
+* Dependencies
+***************************************/
+#include <stdlib.h> /* malloc, free */
+#include <string.h> /* memset */
+#include <stdio.h> /* fprintf, fopen, ftello64 */
+#include <time.h> /* clock */
+
+#include "mem.h" /* read */
+#include "fse.h" /* FSE_normalizeCount, FSE_writeNCount */
+#define HUF_STATIC_LINKING_ONLY
+#include "huf.h" /* HUF_buildCTable, HUF_writeCTable */
+#include "zstd_internal.h" /* includes zstd.h */
+#include "xxhash.h" /* XXH64 */
+#include "divsufsort.h"
+#ifndef ZDICT_STATIC_LINKING_ONLY
+# define ZDICT_STATIC_LINKING_ONLY
+#endif
+#include "zdict.h"
+
+
+/*-*************************************
+* Constants
+***************************************/
+#define KB *(1 <<10)
+#define MB *(1 <<20)
+#define GB *(1U<<30)
+
+#define DICTLISTSIZE_DEFAULT 10000
+
+#define NOISELENGTH 32
+
+static const int g_compressionLevel_default = 3;
+static const U32 g_selectivity_default = 9;
+
+
+/*-*************************************
+* Console display
+***************************************/
+#define DISPLAY(...) { fprintf(stderr, __VA_ARGS__); fflush( stderr ); }
+#define DISPLAYLEVEL(l, ...) if (notificationLevel>=l) { DISPLAY(__VA_ARGS__); } /* 0 : no display; 1: errors; 2: default; 3: details; 4: debug */
+
+static clock_t ZDICT_clockSpan(clock_t nPrevious) { return clock() - nPrevious; }
+
+static void ZDICT_printHex(const void* ptr, size_t length)
+{
+ const BYTE* const b = (const BYTE*)ptr;
+ size_t u;
+ for (u=0; u<length; u++) {
+ BYTE c = b[u];
+ if (c<32 || c>126) c = '.'; /* non-printable char */
+ DISPLAY("%c", c);
+ }
+}
+
+
+/*-********************************************************
+* Helper functions
+**********************************************************/
+unsigned ZDICT_isError(size_t errorCode) { return ERR_isError(errorCode); }
+
+const char* ZDICT_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); }
+
+unsigned ZDICT_getDictID(const void* dictBuffer, size_t dictSize)
+{
+ if (dictSize < 8) return 0;
+ if (MEM_readLE32(dictBuffer) != ZSTD_MAGIC_DICTIONARY) return 0;
+ return MEM_readLE32((const char*)dictBuffer + 4);
+}
+
+
+/*-********************************************************
+* Dictionary training functions
+**********************************************************/
+static unsigned ZDICT_NbCommonBytes (size_t val)
+{
+ if (MEM_isLittleEndian()) {
+ if (MEM_64bits()) {
+# if defined(_MSC_VER) && defined(_WIN64)
+ unsigned long r = 0;
+ _BitScanForward64( &r, (U64)val );
+ return (unsigned)(r>>3);
+# elif defined(__GNUC__) && (__GNUC__ >= 3)
+ return (__builtin_ctzll((U64)val) >> 3);
+# else
+ static const int DeBruijnBytePos[64] = { 0, 0, 0, 0, 0, 1, 1, 2, 0, 3, 1, 3, 1, 4, 2, 7, 0, 2, 3, 6, 1, 5, 3, 5, 1, 3, 4, 4, 2, 5, 6, 7, 7, 0, 1, 2, 3, 3, 4, 6, 2, 6, 5, 5, 3, 4, 5, 6, 7, 1, 2, 4, 6, 4, 4, 5, 7, 2, 6, 5, 7, 6, 7, 7 };
+ return DeBruijnBytePos[((U64)((val & -(long long)val) * 0x0218A392CDABBD3FULL)) >> 58];
+# endif
+ } else { /* 32 bits */
+# if defined(_MSC_VER)
+ unsigned long r=0;
+ _BitScanForward( &r, (U32)val );
+ return (unsigned)(r>>3);
+# elif defined(__GNUC__) && (__GNUC__ >= 3)
+ return (__builtin_ctz((U32)val) >> 3);
+# else
+ static const int DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 };
+ return DeBruijnBytePos[((U32)((val & -(S32)val) * 0x077CB531U)) >> 27];
+# endif
+ }
+ } else { /* Big Endian CPU */
+ if (MEM_64bits()) {
+# if defined(_MSC_VER) && defined(_WIN64)
+ unsigned long r = 0;
+ _BitScanReverse64( &r, val );
+ return (unsigned)(r>>3);
+# elif defined(__GNUC__) && (__GNUC__ >= 3)
+ return (__builtin_clzll(val) >> 3);
+# else
+ unsigned r;
+ const unsigned n32 = sizeof(size_t)*4; /* calculate this way due to compiler complaining in 32-bits mode */
+ if (!(val>>n32)) { r=4; } else { r=0; val>>=n32; }
+ if (!(val>>16)) { r+=2; val>>=8; } else { val>>=24; }
+ r += (!val);
+ return r;
+# endif
+ } else { /* 32 bits */
+# if defined(_MSC_VER)
+ unsigned long r = 0;
+ _BitScanReverse( &r, (unsigned long)val );
+ return (unsigned)(r>>3);
+# elif defined(__GNUC__) && (__GNUC__ >= 3)
+ return (__builtin_clz((U32)val) >> 3);
+# else
+ unsigned r;
+ if (!(val>>16)) { r=2; val>>=8; } else { r=0; val>>=24; }
+ r += (!val);
+ return r;
+# endif
+ } }
+}
+
+
+/*! ZDICT_count() :
+ Count the nb of common bytes between 2 pointers.
+ Note : this function presumes end of buffer followed by noisy guard band.
+*/
+static size_t ZDICT_count(const void* pIn, const void* pMatch)
+{
+ const char* const pStart = (const char*)pIn;
+ for (;;) {
+ size_t const diff = MEM_readST(pMatch) ^ MEM_readST(pIn);
+ if (!diff) {
+ pIn = (const char*)pIn+sizeof(size_t);
+ pMatch = (const char*)pMatch+sizeof(size_t);
+ continue;
+ }
+ pIn = (const char*)pIn+ZDICT_NbCommonBytes(diff);
+ return (size_t)((const char*)pIn - pStart);
+ }
+}
+
+
+typedef struct {
+ U32 pos;
+ U32 length;
+ U32 savings;
+} dictItem;
+
+static void ZDICT_initDictItem(dictItem* d)
+{
+ d->pos = 1;
+ d->length = 0;
+ d->savings = (U32)(-1);
+}
+
+
+#define LLIMIT 64 /* heuristic determined experimentally */
+#define MINMATCHLENGTH 7 /* heuristic determined experimentally */
+static dictItem ZDICT_analyzePos(
+ BYTE* doneMarks,
+ const int* suffix, U32 start,
+ const void* buffer, U32 minRatio, U32 notificationLevel)
+{
+ U32 lengthList[LLIMIT] = {0};
+ U32 cumulLength[LLIMIT] = {0};
+ U32 savings[LLIMIT] = {0};
+ const BYTE* b = (const BYTE*)buffer;
+ size_t maxLength = LLIMIT;
+ size_t pos = suffix[start];
+ U32 end = start;
+ dictItem solution;
+
+ /* init */
+ memset(&solution, 0, sizeof(solution));
+ doneMarks[pos] = 1;
+
+ /* trivial repetition cases */
+ if ( (MEM_read16(b+pos+0) == MEM_read16(b+pos+2))
+ ||(MEM_read16(b+pos+1) == MEM_read16(b+pos+3))
+ ||(MEM_read16(b+pos+2) == MEM_read16(b+pos+4)) ) {
+ /* skip and mark segment */
+ U16 const pattern16 = MEM_read16(b+pos+4);
+ U32 u, patternEnd = 6;
+ while (MEM_read16(b+pos+patternEnd) == pattern16) patternEnd+=2 ;
+ if (b[pos+patternEnd] == b[pos+patternEnd-1]) patternEnd++;
+ for (u=1; u<patternEnd; u++)
+ doneMarks[pos+u] = 1;
+ return solution;
+ }
+
+ /* look forward */
+ { size_t length;
+ do {
+ end++;
+ length = ZDICT_count(b + pos, b + suffix[end]);
+ } while (length >= MINMATCHLENGTH);
+ }
+
+ /* look backward */
+ { size_t length;
+ do {
+ length = ZDICT_count(b + pos, b + *(suffix+start-1));
+ if (length >=MINMATCHLENGTH) start--;
+ } while(length >= MINMATCHLENGTH);
+ }
+
+ /* exit if not found a minimum nb of repetitions */
+ if (end-start < minRatio) {
+ U32 idx;
+ for(idx=start; idx<end; idx++)
+ doneMarks[suffix[idx]] = 1;
+ return solution;
+ }
+
+ { int i;
+ U32 mml;
+ U32 refinedStart = start;
+ U32 refinedEnd = end;
+
+ DISPLAYLEVEL(4, "\n");
+ DISPLAYLEVEL(4, "found %3u matches of length >= %i at pos %7u ", (unsigned)(end-start), MINMATCHLENGTH, (unsigned)pos);
+ DISPLAYLEVEL(4, "\n");
+
+ for (mml = MINMATCHLENGTH ; ; mml++) {
+ BYTE currentChar = 0;
+ U32 currentCount = 0;
+ U32 currentID = refinedStart;
+ U32 id;
+ U32 selectedCount = 0;
+ U32 selectedID = currentID;
+ for (id =refinedStart; id < refinedEnd; id++) {
+ if (b[suffix[id] + mml] != currentChar) {
+ if (currentCount > selectedCount) {
+ selectedCount = currentCount;
+ selectedID = currentID;
+ }
+ currentID = id;
+ currentChar = b[ suffix[id] + mml];
+ currentCount = 0;
+ }
+ currentCount ++;
+ }
+ if (currentCount > selectedCount) { /* for last */
+ selectedCount = currentCount;
+ selectedID = currentID;
+ }
+
+ if (selectedCount < minRatio)
+ break;
+ refinedStart = selectedID;
+ refinedEnd = refinedStart + selectedCount;
+ }
+
+ /* evaluate gain based on new dict */
+ start = refinedStart;
+ pos = suffix[refinedStart];
+ end = start;
+ memset(lengthList, 0, sizeof(lengthList));
+
+ /* look forward */
+ { size_t length;
+ do {
+ end++;
+ length = ZDICT_count(b + pos, b + suffix[end]);
+ if (length >= LLIMIT) length = LLIMIT-1;
+ lengthList[length]++;
+ } while (length >=MINMATCHLENGTH);
+ }
+
+ /* look backward */
+ { size_t length = MINMATCHLENGTH;
+ while ((length >= MINMATCHLENGTH) & (start > 0)) {
+ length = ZDICT_count(b + pos, b + suffix[start - 1]);
+ if (length >= LLIMIT) length = LLIMIT - 1;
+ lengthList[length]++;
+ if (length >= MINMATCHLENGTH) start--;
+ }
+ }
+
+ /* largest useful length */
+ memset(cumulLength, 0, sizeof(cumulLength));
+ cumulLength[maxLength-1] = lengthList[maxLength-1];
+ for (i=(int)(maxLength-2); i>=0; i--)
+ cumulLength[i] = cumulLength[i+1] + lengthList[i];
+
+ for (i=LLIMIT-1; i>=MINMATCHLENGTH; i--) if (cumulLength[i]>=minRatio) break;
+ maxLength = i;
+
+ /* reduce maxLength in case of final into repetitive data */
+ { U32 l = (U32)maxLength;
+ BYTE const c = b[pos + maxLength-1];
+ while (b[pos+l-2]==c) l--;
+ maxLength = l;
+ }
+ if (maxLength < MINMATCHLENGTH) return solution; /* skip : no long-enough solution */
+
+ /* calculate savings */
+ savings[5] = 0;
+ for (i=MINMATCHLENGTH; i<=(int)maxLength; i++)
+ savings[i] = savings[i-1] + (lengthList[i] * (i-3));
+
+ DISPLAYLEVEL(4, "Selected dict at position %u, of length %u : saves %u (ratio: %.2f) \n",
+ (unsigned)pos, (unsigned)maxLength, (unsigned)savings[maxLength], (double)savings[maxLength] / maxLength);
+
+ solution.pos = (U32)pos;
+ solution.length = (U32)maxLength;
+ solution.savings = savings[maxLength];
+
+ /* mark positions done */
+ { U32 id;
+ for (id=start; id<end; id++) {
+ U32 p, pEnd, length;
+ U32 const testedPos = suffix[id];
+ if (testedPos == pos)
+ length = solution.length;
+ else {
+ length = (U32)ZDICT_count(b+pos, b+testedPos);
+ if (length > solution.length) length = solution.length;
+ }
+ pEnd = (U32)(testedPos + length);
+ for (p=testedPos; p<pEnd; p++)
+ doneMarks[p] = 1;
+ } } }
+
+ return solution;
+}
+
+
+static int isIncluded(const void* in, const void* container, size_t length)
+{
+ const char* const ip = (const char*) in;
+ const char* const into = (const char*) container;
+ size_t u;
+
+ for (u=0; u<length; u++) { /* works because end of buffer is a noisy guard band */
+ if (ip[u] != into[u]) break;
+ }
+
+ return u==length;
+}
+
+/*! ZDICT_tryMerge() :
+ check if dictItem can be merged, do it if possible
+ @return : id of destination elt, 0 if not merged
+*/
+static U32 ZDICT_tryMerge(dictItem* table, dictItem elt, U32 eltNbToSkip, const void* buffer)
+{
+ const U32 tableSize = table->pos;
+ const U32 eltEnd = elt.pos + elt.length;
+ const char* const buf = (const char*) buffer;
+
+ /* tail overlap */
+ U32 u; for (u=1; u<tableSize; u++) {
+ if (u==eltNbToSkip) continue;
+ if ((table[u].pos > elt.pos) && (table[u].pos <= eltEnd)) { /* overlap, existing > new */
+ /* append */
+ U32 const addedLength = table[u].pos - elt.pos;
+ table[u].length += addedLength;
+ table[u].pos = elt.pos;
+ table[u].savings += elt.savings * addedLength / elt.length; /* rough approx */
+ table[u].savings += elt.length / 8; /* rough approx bonus */
+ elt = table[u];
+ /* sort : improve rank */
+ while ((u>1) && (table[u-1].savings < elt.savings))
+ table[u] = table[u-1], u--;
+ table[u] = elt;
+ return u;
+ } }
+
+ /* front overlap */
+ for (u=1; u<tableSize; u++) {
+ if (u==eltNbToSkip) continue;
+
+ if ((table[u].pos + table[u].length >= elt.pos) && (table[u].pos < elt.pos)) { /* overlap, existing < new */
+ /* append */
+ int const addedLength = (int)eltEnd - (table[u].pos + table[u].length);
+ table[u].savings += elt.length / 8; /* rough approx bonus */
+ if (addedLength > 0) { /* otherwise, elt fully included into existing */
+ table[u].length += addedLength;
+ table[u].savings += elt.savings * addedLength / elt.length; /* rough approx */
+ }
+ /* sort : improve rank */
+ elt = table[u];
+ while ((u>1) && (table[u-1].savings < elt.savings))
+ table[u] = table[u-1], u--;
+ table[u] = elt;
+ return u;
+ }
+
+ if (MEM_read64(buf + table[u].pos) == MEM_read64(buf + elt.pos + 1)) {
+ if (isIncluded(buf + table[u].pos, buf + elt.pos + 1, table[u].length)) {
+ size_t const addedLength = MAX( (int)elt.length - (int)table[u].length , 1 );
+ table[u].pos = elt.pos;
+ table[u].savings += (U32)(elt.savings * addedLength / elt.length);
+ table[u].length = MIN(elt.length, table[u].length + 1);
+ return u;
+ }
+ }
+ }
+
+ return 0;
+}
+
+
+static void ZDICT_removeDictItem(dictItem* table, U32 id)
+{
+ /* convention : table[0].pos stores nb of elts */
+ U32 const max = table[0].pos;
+ U32 u;
+ if (!id) return; /* protection, should never happen */
+ for (u=id; u<max-1; u++)
+ table[u] = table[u+1];
+ table->pos--;
+}
+
+
+static void ZDICT_insertDictItem(dictItem* table, U32 maxSize, dictItem elt, const void* buffer)
+{
+ /* merge if possible */
+ U32 mergeId = ZDICT_tryMerge(table, elt, 0, buffer);
+ if (mergeId) {
+ U32 newMerge = 1;
+ while (newMerge) {
+ newMerge = ZDICT_tryMerge(table, table[mergeId], mergeId, buffer);
+ if (newMerge) ZDICT_removeDictItem(table, mergeId);
+ mergeId = newMerge;
+ }
+ return;
+ }
+
+ /* insert */
+ { U32 current;
+ U32 nextElt = table->pos;
+ if (nextElt >= maxSize) nextElt = maxSize-1;
+ current = nextElt-1;
+ while (table[current].savings < elt.savings) {
+ table[current+1] = table[current];
+ current--;
+ }
+ table[current+1] = elt;
+ table->pos = nextElt+1;
+ }
+}
+
+
+static U32 ZDICT_dictSize(const dictItem* dictList)
+{
+ U32 u, dictSize = 0;
+ for (u=1; u<dictList[0].pos; u++)
+ dictSize += dictList[u].length;
+ return dictSize;
+}
+
+
+static size_t ZDICT_trainBuffer_legacy(dictItem* dictList, U32 dictListSize,
+ const void* const buffer, size_t bufferSize, /* buffer must end with noisy guard band */
+ const size_t* fileSizes, unsigned nbFiles,
+ unsigned minRatio, U32 notificationLevel)
+{
+ int* const suffix0 = (int*)malloc((bufferSize+2)*sizeof(*suffix0));
+ int* const suffix = suffix0+1;
+ U32* reverseSuffix = (U32*)malloc((bufferSize)*sizeof(*reverseSuffix));
+ BYTE* doneMarks = (BYTE*)malloc((bufferSize+16)*sizeof(*doneMarks)); /* +16 for overflow security */
+ U32* filePos = (U32*)malloc(nbFiles * sizeof(*filePos));
+ size_t result = 0;
+ clock_t displayClock = 0;
+ clock_t const refreshRate = CLOCKS_PER_SEC * 3 / 10;
+
+# define DISPLAYUPDATE(l, ...) if (notificationLevel>=l) { \
+ if (ZDICT_clockSpan(displayClock) > refreshRate) \
+ { displayClock = clock(); DISPLAY(__VA_ARGS__); \
+ if (notificationLevel>=4) fflush(stderr); } }
+
+ /* init */
+ DISPLAYLEVEL(2, "\r%70s\r", ""); /* clean display line */
+ if (!suffix0 || !reverseSuffix || !doneMarks || !filePos) {
+ result = ERROR(memory_allocation);
+ goto _cleanup;
+ }
+ if (minRatio < MINRATIO) minRatio = MINRATIO;
+ memset(doneMarks, 0, bufferSize+16);
+
+ /* limit sample set size (divsufsort limitation)*/
+ if (bufferSize > ZDICT_MAX_SAMPLES_SIZE) DISPLAYLEVEL(3, "sample set too large : reduced to %u MB ...\n", (unsigned)(ZDICT_MAX_SAMPLES_SIZE>>20));
+ while (bufferSize > ZDICT_MAX_SAMPLES_SIZE) bufferSize -= fileSizes[--nbFiles];
+
+ /* sort */
+ DISPLAYLEVEL(2, "sorting %u files of total size %u MB ...\n", nbFiles, (unsigned)(bufferSize>>20));
+ { int const divSuftSortResult = divsufsort((const unsigned char*)buffer, suffix, (int)bufferSize, 0);
+ if (divSuftSortResult != 0) { result = ERROR(GENERIC); goto _cleanup; }
+ }
+ suffix[bufferSize] = (int)bufferSize; /* leads into noise */
+ suffix0[0] = (int)bufferSize; /* leads into noise */
+ /* build reverse suffix sort */
+ { size_t pos;
+ for (pos=0; pos < bufferSize; pos++)
+ reverseSuffix[suffix[pos]] = (U32)pos;
+ /* note filePos tracks borders between samples.
+ It's not used at this stage, but planned to become useful in a later update */
+ filePos[0] = 0;
+ for (pos=1; pos<nbFiles; pos++)
+ filePos[pos] = (U32)(filePos[pos-1] + fileSizes[pos-1]);
+ }
+
+ DISPLAYLEVEL(2, "finding patterns ... \n");
+ DISPLAYLEVEL(3, "minimum ratio : %u \n", minRatio);
+
+ { U32 cursor; for (cursor=0; cursor < bufferSize; ) {
+ dictItem solution;
+ if (doneMarks[cursor]) { cursor++; continue; }
+ solution = ZDICT_analyzePos(doneMarks, suffix, reverseSuffix[cursor], buffer, minRatio, notificationLevel);
+ if (solution.length==0) { cursor++; continue; }
+ ZDICT_insertDictItem(dictList, dictListSize, solution, buffer);
+ cursor += solution.length;
+ DISPLAYUPDATE(2, "\r%4.2f %% \r", (double)cursor / bufferSize * 100);
+ } }
+
+_cleanup:
+ free(suffix0);
+ free(reverseSuffix);
+ free(doneMarks);
+ free(filePos);
+ return result;
+}
+
+
+static void ZDICT_fillNoise(void* buffer, size_t length)
+{
+ unsigned const prime1 = 2654435761U;
+ unsigned const prime2 = 2246822519U;
+ unsigned acc = prime1;
+ size_t p=0;;
+ for (p=0; p<length; p++) {
+ acc *= prime2;
+ ((unsigned char*)buffer)[p] = (unsigned char)(acc >> 21);
+ }
+}
+
+
+typedef struct
+{
+ ZSTD_CDict* dict; /* dictionary */
+ ZSTD_CCtx* zc; /* working context */
+ void* workPlace; /* must be ZSTD_BLOCKSIZE_MAX allocated */
+} EStats_ress_t;
+
+#define MAXREPOFFSET 1024
+
+static void ZDICT_countEStats(EStats_ress_t esr, ZSTD_parameters params,
+ unsigned* countLit, unsigned* offsetcodeCount, unsigned* matchlengthCount, unsigned* litlengthCount, U32* repOffsets,
+ const void* src, size_t srcSize,
+ U32 notificationLevel)
+{
+ size_t const blockSizeMax = MIN (ZSTD_BLOCKSIZE_MAX, 1 << params.cParams.windowLog);
+ size_t cSize;
+
+ if (srcSize > blockSizeMax) srcSize = blockSizeMax; /* protection vs large samples */
+ { size_t const errorCode = ZSTD_compressBegin_usingCDict(esr.zc, esr.dict);
+ if (ZSTD_isError(errorCode)) { DISPLAYLEVEL(1, "warning : ZSTD_compressBegin_usingCDict failed \n"); return; }
+
+ }
+ cSize = ZSTD_compressBlock(esr.zc, esr.workPlace, ZSTD_BLOCKSIZE_MAX, src, srcSize);
+ if (ZSTD_isError(cSize)) { DISPLAYLEVEL(3, "warning : could not compress sample size %u \n", (unsigned)srcSize); return; }
+
+ if (cSize) { /* if == 0; block is not compressible */
+ const seqStore_t* const seqStorePtr = ZSTD_getSeqStore(esr.zc);
+
+ /* literals stats */
+ { const BYTE* bytePtr;
+ for(bytePtr = seqStorePtr->litStart; bytePtr < seqStorePtr->lit; bytePtr++)
+ countLit[*bytePtr]++;
+ }
+
+ /* seqStats */
+ { U32 const nbSeq = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
+ ZSTD_seqToCodes(seqStorePtr);
+
+ { const BYTE* codePtr = seqStorePtr->ofCode;
+ U32 u;
+ for (u=0; u<nbSeq; u++) offsetcodeCount[codePtr[u]]++;
+ }
+
+ { const BYTE* codePtr = seqStorePtr->mlCode;
+ U32 u;
+ for (u=0; u<nbSeq; u++) matchlengthCount[codePtr[u]]++;
+ }
+
+ { const BYTE* codePtr = seqStorePtr->llCode;
+ U32 u;
+ for (u=0; u<nbSeq; u++) litlengthCount[codePtr[u]]++;
+ }
+
+ if (nbSeq >= 2) { /* rep offsets */
+ const seqDef* const seq = seqStorePtr->sequencesStart;
+ U32 offset1 = seq[0].offset - 3;
+ U32 offset2 = seq[1].offset - 3;
+ if (offset1 >= MAXREPOFFSET) offset1 = 0;
+ if (offset2 >= MAXREPOFFSET) offset2 = 0;
+ repOffsets[offset1] += 3;
+ repOffsets[offset2] += 1;
+ } } }
+}
+
+static size_t ZDICT_totalSampleSize(const size_t* fileSizes, unsigned nbFiles)
+{
+ size_t total=0;
+ unsigned u;
+ for (u=0; u<nbFiles; u++) total += fileSizes[u];
+ return total;
+}
+
+typedef struct { U32 offset; U32 count; } offsetCount_t;
+
+static void ZDICT_insertSortCount(offsetCount_t table[ZSTD_REP_NUM+1], U32 val, U32 count)
+{
+ U32 u;
+ table[ZSTD_REP_NUM].offset = val;
+ table[ZSTD_REP_NUM].count = count;
+ for (u=ZSTD_REP_NUM; u>0; u--) {
+ offsetCount_t tmp;
+ if (table[u-1].count >= table[u].count) break;
+ tmp = table[u-1];
+ table[u-1] = table[u];
+ table[u] = tmp;
+ }
+}
+
+/* ZDICT_flatLit() :
+ * rewrite `countLit` to contain a mostly flat but still compressible distribution of literals.
+ * necessary to avoid generating a non-compressible distribution that HUF_writeCTable() cannot encode.
+ */
+static void ZDICT_flatLit(unsigned* countLit)
+{
+ int u;
+ for (u=1; u<256; u++) countLit[u] = 2;
+ countLit[0] = 4;
+ countLit[253] = 1;
+ countLit[254] = 1;
+}
+
+#define OFFCODE_MAX 30 /* only applicable to first block */
+static size_t ZDICT_analyzeEntropy(void* dstBuffer, size_t maxDstSize,
+ unsigned compressionLevel,
+ const void* srcBuffer, const size_t* fileSizes, unsigned nbFiles,
+ const void* dictBuffer, size_t dictBufferSize,
+ unsigned notificationLevel)
+{
+ unsigned countLit[256];
+ HUF_CREATE_STATIC_CTABLE(hufTable, 255);
+ unsigned offcodeCount[OFFCODE_MAX+1];
+ short offcodeNCount[OFFCODE_MAX+1];
+ U32 offcodeMax = ZSTD_highbit32((U32)(dictBufferSize + 128 KB));
+ unsigned matchLengthCount[MaxML+1];
+ short matchLengthNCount[MaxML+1];
+ unsigned litLengthCount[MaxLL+1];
+ short litLengthNCount[MaxLL+1];
+ U32 repOffset[MAXREPOFFSET];
+ offsetCount_t bestRepOffset[ZSTD_REP_NUM+1];
+ EStats_ress_t esr = { NULL, NULL, NULL };
+ ZSTD_parameters params;
+ U32 u, huffLog = 11, Offlog = OffFSELog, mlLog = MLFSELog, llLog = LLFSELog, total;
+ size_t pos = 0, errorCode;
+ size_t eSize = 0;
+ size_t const totalSrcSize = ZDICT_totalSampleSize(fileSizes, nbFiles);
+ size_t const averageSampleSize = totalSrcSize / (nbFiles + !nbFiles);
+ BYTE* dstPtr = (BYTE*)dstBuffer;
+
+ /* init */
+ DEBUGLOG(4, "ZDICT_analyzeEntropy");
+ if (offcodeMax>OFFCODE_MAX) { eSize = ERROR(dictionaryCreation_failed); goto _cleanup; } /* too large dictionary */
+ for (u=0; u<256; u++) countLit[u] = 1; /* any character must be described */
+ for (u=0; u<=offcodeMax; u++) offcodeCount[u] = 1;
+ for (u=0; u<=MaxML; u++) matchLengthCount[u] = 1;
+ for (u=0; u<=MaxLL; u++) litLengthCount[u] = 1;
+ memset(repOffset, 0, sizeof(repOffset));
+ repOffset[1] = repOffset[4] = repOffset[8] = 1;
+ memset(bestRepOffset, 0, sizeof(bestRepOffset));
+ if (compressionLevel==0) compressionLevel = g_compressionLevel_default;
+ params = ZSTD_getParams(compressionLevel, averageSampleSize, dictBufferSize);
+
+ esr.dict = ZSTD_createCDict_advanced(dictBuffer, dictBufferSize, ZSTD_dlm_byRef, ZSTD_dct_rawContent, params.cParams, ZSTD_defaultCMem);
+ esr.zc = ZSTD_createCCtx();
+ esr.workPlace = malloc(ZSTD_BLOCKSIZE_MAX);
+ if (!esr.dict || !esr.zc || !esr.workPlace) {
+ eSize = ERROR(memory_allocation);
+ DISPLAYLEVEL(1, "Not enough memory \n");
+ goto _cleanup;
+ }
+
+ /* collect stats on all samples */
+ for (u=0; u<nbFiles; u++) {
+ ZDICT_countEStats(esr, params,
+ countLit, offcodeCount, matchLengthCount, litLengthCount, repOffset,
+ (const char*)srcBuffer + pos, fileSizes[u],
+ notificationLevel);
+ pos += fileSizes[u];
+ }
+
+ /* analyze, build stats, starting with literals */
+ { size_t maxNbBits = HUF_buildCTable (hufTable, countLit, 255, huffLog);
+ if (HUF_isError(maxNbBits)) {
+ eSize = ERROR(GENERIC);
+ DISPLAYLEVEL(1, " HUF_buildCTable error \n");
+ goto _cleanup;
+ }
+ if (maxNbBits==8) { /* not compressible : will fail on HUF_writeCTable() */
+ DISPLAYLEVEL(2, "warning : pathological dataset : literals are not compressible : samples are noisy or too regular \n");
+ ZDICT_flatLit(countLit); /* replace distribution by a fake "mostly flat but still compressible" distribution, that HUF_writeCTable() can encode */
+ maxNbBits = HUF_buildCTable (hufTable, countLit, 255, huffLog);
+ assert(maxNbBits==9);
+ }
+ huffLog = (U32)maxNbBits;
+ }
+
+ /* looking for most common first offsets */
+ { U32 offset;
+ for (offset=1; offset<MAXREPOFFSET; offset++)
+ ZDICT_insertSortCount(bestRepOffset, offset, repOffset[offset]);
+ }
+ /* note : the result of this phase should be used to better appreciate the impact on statistics */
+
+ total=0; for (u=0; u<=offcodeMax; u++) total+=offcodeCount[u];
+ errorCode = FSE_normalizeCount(offcodeNCount, Offlog, offcodeCount, total, offcodeMax);
+ if (FSE_isError(errorCode)) {
+ eSize = ERROR(GENERIC);
+ DISPLAYLEVEL(1, "FSE_normalizeCount error with offcodeCount \n");
+ goto _cleanup;
+ }
+ Offlog = (U32)errorCode;
+
+ total=0; for (u=0; u<=MaxML; u++) total+=matchLengthCount[u];
+ errorCode = FSE_normalizeCount(matchLengthNCount, mlLog, matchLengthCount, total, MaxML);
+ if (FSE_isError(errorCode)) {
+ eSize = ERROR(GENERIC);
+ DISPLAYLEVEL(1, "FSE_normalizeCount error with matchLengthCount \n");
+ goto _cleanup;
+ }
+ mlLog = (U32)errorCode;
+
+ total=0; for (u=0; u<=MaxLL; u++) total+=litLengthCount[u];
+ errorCode = FSE_normalizeCount(litLengthNCount, llLog, litLengthCount, total, MaxLL);
+ if (FSE_isError(errorCode)) {
+ eSize = ERROR(GENERIC);
+ DISPLAYLEVEL(1, "FSE_normalizeCount error with litLengthCount \n");
+ goto _cleanup;
+ }
+ llLog = (U32)errorCode;
+
+ /* write result to buffer */
+ { size_t const hhSize = HUF_writeCTable(dstPtr, maxDstSize, hufTable, 255, huffLog);
+ if (HUF_isError(hhSize)) {
+ eSize = ERROR(GENERIC);
+ DISPLAYLEVEL(1, "HUF_writeCTable error \n");
+ goto _cleanup;
+ }
+ dstPtr += hhSize;
+ maxDstSize -= hhSize;
+ eSize += hhSize;
+ }
+
+ { size_t const ohSize = FSE_writeNCount(dstPtr, maxDstSize, offcodeNCount, OFFCODE_MAX, Offlog);
+ if (FSE_isError(ohSize)) {
+ eSize = ERROR(GENERIC);
+ DISPLAYLEVEL(1, "FSE_writeNCount error with offcodeNCount \n");
+ goto _cleanup;
+ }
+ dstPtr += ohSize;
+ maxDstSize -= ohSize;
+ eSize += ohSize;
+ }
+
+ { size_t const mhSize = FSE_writeNCount(dstPtr, maxDstSize, matchLengthNCount, MaxML, mlLog);
+ if (FSE_isError(mhSize)) {
+ eSize = ERROR(GENERIC);
+ DISPLAYLEVEL(1, "FSE_writeNCount error with matchLengthNCount \n");
+ goto _cleanup;
+ }
+ dstPtr += mhSize;
+ maxDstSize -= mhSize;
+ eSize += mhSize;
+ }
+
+ { size_t const lhSize = FSE_writeNCount(dstPtr, maxDstSize, litLengthNCount, MaxLL, llLog);
+ if (FSE_isError(lhSize)) {
+ eSize = ERROR(GENERIC);
+ DISPLAYLEVEL(1, "FSE_writeNCount error with litlengthNCount \n");
+ goto _cleanup;
+ }
+ dstPtr += lhSize;
+ maxDstSize -= lhSize;
+ eSize += lhSize;
+ }
+
+ if (maxDstSize<12) {
+ eSize = ERROR(GENERIC);
+ DISPLAYLEVEL(1, "not enough space to write RepOffsets \n");
+ goto _cleanup;
+ }
+# if 0
+ MEM_writeLE32(dstPtr+0, bestRepOffset[0].offset);
+ MEM_writeLE32(dstPtr+4, bestRepOffset[1].offset);
+ MEM_writeLE32(dstPtr+8, bestRepOffset[2].offset);
+#else
+ /* at this stage, we don't use the result of "most common first offset",
+ as the impact of statistics is not properly evaluated */
+ MEM_writeLE32(dstPtr+0, repStartValue[0]);
+ MEM_writeLE32(dstPtr+4, repStartValue[1]);
+ MEM_writeLE32(dstPtr+8, repStartValue[2]);
+#endif
+ eSize += 12;
+
+_cleanup:
+ ZSTD_freeCDict(esr.dict);
+ ZSTD_freeCCtx(esr.zc);
+ free(esr.workPlace);
+
+ return eSize;
+}
+
+
+
+size_t ZDICT_finalizeDictionary(void* dictBuffer, size_t dictBufferCapacity,
+ const void* customDictContent, size_t dictContentSize,
+ const void* samplesBuffer, const size_t* samplesSizes,
+ unsigned nbSamples, ZDICT_params_t params)
+{
+ size_t hSize;
+#define HBUFFSIZE 256 /* should prove large enough for all entropy headers */
+ BYTE header[HBUFFSIZE];
+ int const compressionLevel = (params.compressionLevel == 0) ? g_compressionLevel_default : params.compressionLevel;
+ U32 const notificationLevel = params.notificationLevel;
+
+ /* check conditions */
+ DEBUGLOG(4, "ZDICT_finalizeDictionary");
+ if (dictBufferCapacity < dictContentSize) return ERROR(dstSize_tooSmall);
+ if (dictContentSize < ZDICT_CONTENTSIZE_MIN) return ERROR(srcSize_wrong);
+ if (dictBufferCapacity < ZDICT_DICTSIZE_MIN) return ERROR(dstSize_tooSmall);
+
+ /* dictionary header */
+ MEM_writeLE32(header, ZSTD_MAGIC_DICTIONARY);
+ { U64 const randomID = XXH64(customDictContent, dictContentSize, 0);
+ U32 const compliantID = (randomID % ((1U<<31)-32768)) + 32768;
+ U32 const dictID = params.dictID ? params.dictID : compliantID;
+ MEM_writeLE32(header+4, dictID);
+ }
+ hSize = 8;
+
+ /* entropy tables */
+ DISPLAYLEVEL(2, "\r%70s\r", ""); /* clean display line */
+ DISPLAYLEVEL(2, "statistics ... \n");
+ { size_t const eSize = ZDICT_analyzeEntropy(header+hSize, HBUFFSIZE-hSize,
+ compressionLevel,
+ samplesBuffer, samplesSizes, nbSamples,
+ customDictContent, dictContentSize,
+ notificationLevel);
+ if (ZDICT_isError(eSize)) return eSize;
+ hSize += eSize;
+ }
+
+ /* copy elements in final buffer ; note : src and dst buffer can overlap */
+ if (hSize + dictContentSize > dictBufferCapacity) dictContentSize = dictBufferCapacity - hSize;
+ { size_t const dictSize = hSize + dictContentSize;
+ char* dictEnd = (char*)dictBuffer + dictSize;
+ memmove(dictEnd - dictContentSize, customDictContent, dictContentSize);
+ memcpy(dictBuffer, header, hSize);
+ return dictSize;
+ }
+}
+
+
+static size_t ZDICT_addEntropyTablesFromBuffer_advanced(
+ void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity,
+ const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
+ ZDICT_params_t params)
+{
+ int const compressionLevel = (params.compressionLevel == 0) ? g_compressionLevel_default : params.compressionLevel;
+ U32 const notificationLevel = params.notificationLevel;
+ size_t hSize = 8;
+
+ /* calculate entropy tables */
+ DISPLAYLEVEL(2, "\r%70s\r", ""); /* clean display line */
+ DISPLAYLEVEL(2, "statistics ... \n");
+ { size_t const eSize = ZDICT_analyzeEntropy((char*)dictBuffer+hSize, dictBufferCapacity-hSize,
+ compressionLevel,
+ samplesBuffer, samplesSizes, nbSamples,
+ (char*)dictBuffer + dictBufferCapacity - dictContentSize, dictContentSize,
+ notificationLevel);
+ if (ZDICT_isError(eSize)) return eSize;
+ hSize += eSize;
+ }
+
+ /* add dictionary header (after entropy tables) */
+ MEM_writeLE32(dictBuffer, ZSTD_MAGIC_DICTIONARY);
+ { U64 const randomID = XXH64((char*)dictBuffer + dictBufferCapacity - dictContentSize, dictContentSize, 0);
+ U32 const compliantID = (randomID % ((1U<<31)-32768)) + 32768;
+ U32 const dictID = params.dictID ? params.dictID : compliantID;
+ MEM_writeLE32((char*)dictBuffer+4, dictID);
+ }
+
+ if (hSize + dictContentSize < dictBufferCapacity)
+ memmove((char*)dictBuffer + hSize, (char*)dictBuffer + dictBufferCapacity - dictContentSize, dictContentSize);
+ return MIN(dictBufferCapacity, hSize+dictContentSize);
+}
+
+/* Hidden declaration for dbio.c */
+size_t ZDICT_trainFromBuffer_unsafe_legacy(
+ void* dictBuffer, size_t maxDictSize,
+ const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
+ ZDICT_legacy_params_t params);
+/*! ZDICT_trainFromBuffer_unsafe_legacy() :
+* Warning : `samplesBuffer` must be followed by noisy guard band.
+* @return : size of dictionary, or an error code which can be tested with ZDICT_isError()
+*/
+size_t ZDICT_trainFromBuffer_unsafe_legacy(
+ void* dictBuffer, size_t maxDictSize,
+ const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
+ ZDICT_legacy_params_t params)
+{
+ U32 const dictListSize = MAX(MAX(DICTLISTSIZE_DEFAULT, nbSamples), (U32)(maxDictSize/16));
+ dictItem* const dictList = (dictItem*)malloc(dictListSize * sizeof(*dictList));
+ unsigned const selectivity = params.selectivityLevel == 0 ? g_selectivity_default : params.selectivityLevel;
+ unsigned const minRep = (selectivity > 30) ? MINRATIO : nbSamples >> selectivity;
+ size_t const targetDictSize = maxDictSize;
+ size_t const samplesBuffSize = ZDICT_totalSampleSize(samplesSizes, nbSamples);
+ size_t dictSize = 0;
+ U32 const notificationLevel = params.zParams.notificationLevel;
+
+ /* checks */
+ if (!dictList) return ERROR(memory_allocation);
+ if (maxDictSize < ZDICT_DICTSIZE_MIN) { free(dictList); return ERROR(dstSize_tooSmall); } /* requested dictionary size is too small */
+ if (samplesBuffSize < ZDICT_MIN_SAMPLES_SIZE) { free(dictList); return ERROR(dictionaryCreation_failed); } /* not enough source to create dictionary */
+
+ /* init */
+ ZDICT_initDictItem(dictList);
+
+ /* build dictionary */
+ ZDICT_trainBuffer_legacy(dictList, dictListSize,
+ samplesBuffer, samplesBuffSize,
+ samplesSizes, nbSamples,
+ minRep, notificationLevel);
+
+ /* display best matches */
+ if (params.zParams.notificationLevel>= 3) {
+ unsigned const nb = MIN(25, dictList[0].pos);
+ unsigned const dictContentSize = ZDICT_dictSize(dictList);
+ unsigned u;
+ DISPLAYLEVEL(3, "\n %u segments found, of total size %u \n", (unsigned)dictList[0].pos-1, dictContentSize);
+ DISPLAYLEVEL(3, "list %u best segments \n", nb-1);
+ for (u=1; u<nb; u++) {
+ unsigned const pos = dictList[u].pos;
+ unsigned const length = dictList[u].length;
+ U32 const printedLength = MIN(40, length);
+ if ((pos > samplesBuffSize) || ((pos + length) > samplesBuffSize)) {
+ free(dictList);
+ return ERROR(GENERIC); /* should never happen */
+ }
+ DISPLAYLEVEL(3, "%3u:%3u bytes at pos %8u, savings %7u bytes |",
+ u, length, pos, (unsigned)dictList[u].savings);
+ ZDICT_printHex((const char*)samplesBuffer+pos, printedLength);
+ DISPLAYLEVEL(3, "| \n");
+ } }
+
+
+ /* create dictionary */
+ { unsigned dictContentSize = ZDICT_dictSize(dictList);
+ if (dictContentSize < ZDICT_CONTENTSIZE_MIN) { free(dictList); return ERROR(dictionaryCreation_failed); } /* dictionary content too small */
+ if (dictContentSize < targetDictSize/4) {
+ DISPLAYLEVEL(2, "! warning : selected content significantly smaller than requested (%u < %u) \n", dictContentSize, (unsigned)maxDictSize);
+ if (samplesBuffSize < 10 * targetDictSize)
+ DISPLAYLEVEL(2, "! consider increasing the number of samples (total size : %u MB)\n", (unsigned)(samplesBuffSize>>20));
+ if (minRep > MINRATIO) {
+ DISPLAYLEVEL(2, "! consider increasing selectivity to produce larger dictionary (-s%u) \n", selectivity+1);
+ DISPLAYLEVEL(2, "! note : larger dictionaries are not necessarily better, test its efficiency on samples \n");
+ }
+ }
+
+ if ((dictContentSize > targetDictSize*3) && (nbSamples > 2*MINRATIO) && (selectivity>1)) {
+ unsigned proposedSelectivity = selectivity-1;
+ while ((nbSamples >> proposedSelectivity) <= MINRATIO) { proposedSelectivity--; }
+ DISPLAYLEVEL(2, "! note : calculated dictionary significantly larger than requested (%u > %u) \n", dictContentSize, (unsigned)maxDictSize);
+ DISPLAYLEVEL(2, "! consider increasing dictionary size, or produce denser dictionary (-s%u) \n", proposedSelectivity);
+ DISPLAYLEVEL(2, "! always test dictionary efficiency on real samples \n");
+ }
+
+ /* limit dictionary size */
+ { U32 const max = dictList->pos; /* convention : nb of useful elts within dictList */
+ U32 currentSize = 0;
+ U32 n; for (n=1; n<max; n++) {
+ currentSize += dictList[n].length;
+ if (currentSize > targetDictSize) { currentSize -= dictList[n].length; break; }
+ }
+ dictList->pos = n;
+ dictContentSize = currentSize;
+ }
+
+ /* build dict content */
+ { U32 u;
+ BYTE* ptr = (BYTE*)dictBuffer + maxDictSize;
+ for (u=1; u<dictList->pos; u++) {
+ U32 l = dictList[u].length;
+ ptr -= l;
+ if (ptr<(BYTE*)dictBuffer) { free(dictList); return ERROR(GENERIC); } /* should not happen */
+ memcpy(ptr, (const char*)samplesBuffer+dictList[u].pos, l);
+ } }
+
+ dictSize = ZDICT_addEntropyTablesFromBuffer_advanced(dictBuffer, dictContentSize, maxDictSize,
+ samplesBuffer, samplesSizes, nbSamples,
+ params.zParams);
+ }
+
+ /* clean up */
+ free(dictList);
+ return dictSize;
+}
+
+
+/* ZDICT_trainFromBuffer_legacy() :
+ * issue : samplesBuffer need to be followed by a noisy guard band.
+ * work around : duplicate the buffer, and add the noise */
+size_t ZDICT_trainFromBuffer_legacy(void* dictBuffer, size_t dictBufferCapacity,
+ const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
+ ZDICT_legacy_params_t params)
+{
+ size_t result;
+ void* newBuff;
+ size_t const sBuffSize = ZDICT_totalSampleSize(samplesSizes, nbSamples);
+ if (sBuffSize < ZDICT_MIN_SAMPLES_SIZE) return 0; /* not enough content => no dictionary */
+
+ newBuff = malloc(sBuffSize + NOISELENGTH);
+ if (!newBuff) return ERROR(memory_allocation);
+
+ memcpy(newBuff, samplesBuffer, sBuffSize);
+ ZDICT_fillNoise((char*)newBuff + sBuffSize, NOISELENGTH); /* guard band, for end of buffer condition */
+
+ result =
+ ZDICT_trainFromBuffer_unsafe_legacy(dictBuffer, dictBufferCapacity, newBuff,
+ samplesSizes, nbSamples, params);
+ free(newBuff);
+ return result;
+}
+
+
+size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCapacity,
+ const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples)
+{
+ ZDICT_fastCover_params_t params;
+ DEBUGLOG(3, "ZDICT_trainFromBuffer");
+ memset(&params, 0, sizeof(params));
+ params.d = 8;
+ params.steps = 4;
+ /* Default to level 6 since no compression level information is available */
+ params.zParams.compressionLevel = 3;
+#if defined(DEBUGLEVEL) && (DEBUGLEVEL>=1)
+ params.zParams.notificationLevel = DEBUGLEVEL;
+#endif
+ return ZDICT_optimizeTrainFromBuffer_fastCover(dictBuffer, dictBufferCapacity,
+ samplesBuffer, samplesSizes, nbSamples,
+ &params);
+}
+
+size_t ZDICT_addEntropyTablesFromBuffer(void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity,
+ const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples)
+{
+ ZDICT_params_t params;
+ memset(&params, 0, sizeof(params));
+ return ZDICT_addEntropyTablesFromBuffer_advanced(dictBuffer, dictContentSize, dictBufferCapacity,
+ samplesBuffer, samplesSizes, nbSamples,
+ params);
+}
diff --git a/Utilities/cmzstd/lib/dictBuilder/zdict.h b/Utilities/cmzstd/lib/dictBuilder/zdict.h
new file mode 100644
index 000000000..d57d59f01
--- /dev/null
+++ b/Utilities/cmzstd/lib/dictBuilder/zdict.h
@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+
+#ifndef DICTBUILDER_H_001
+#define DICTBUILDER_H_001
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/*====== Dependencies ======*/
+#include <stddef.h> /* size_t */
+
+
+/* ===== ZDICTLIB_API : control library symbols visibility ===== */
+#ifndef ZDICTLIB_VISIBILITY
+# if defined(__GNUC__) && (__GNUC__ >= 4)
+# define ZDICTLIB_VISIBILITY __attribute__ ((visibility ("default")))
+# else
+# define ZDICTLIB_VISIBILITY
+# endif
+#endif
+#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
+# define ZDICTLIB_API __declspec(dllexport) ZDICTLIB_VISIBILITY
+#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
+# define ZDICTLIB_API __declspec(dllimport) ZDICTLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
+#else
+# define ZDICTLIB_API ZDICTLIB_VISIBILITY
+#endif
+
+
+/*! ZDICT_trainFromBuffer():
+ * Train a dictionary from an array of samples.
+ * Redirect towards ZDICT_optimizeTrainFromBuffer_fastCover() single-threaded, with d=8, steps=4,
+ * f=20, and accel=1.
+ * Samples must be stored concatenated in a single flat buffer `samplesBuffer`,
+ * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order.
+ * The resulting dictionary will be saved into `dictBuffer`.
+ * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
+ * or an error code, which can be tested with ZDICT_isError().
+ * Note: ZDICT_trainFromBuffer() requires about 9 bytes of memory for each input byte.
+ * Tips: In general, a reasonable dictionary has a size of ~ 100 KB.
+ * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`.
+ * In general, it's recommended to provide a few thousands samples, though this can vary a lot.
+ * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
+ */
+ZDICTLIB_API size_t ZDICT_trainFromBuffer(void* dictBuffer, size_t dictBufferCapacity,
+ const void* samplesBuffer,
+ const size_t* samplesSizes, unsigned nbSamples);
+
+
+/*====== Helper functions ======*/
+ZDICTLIB_API unsigned ZDICT_getDictID(const void* dictBuffer, size_t dictSize); /**< extracts dictID; @return zero if error (not a valid dictionary) */
+ZDICTLIB_API unsigned ZDICT_isError(size_t errorCode);
+ZDICTLIB_API const char* ZDICT_getErrorName(size_t errorCode);
+
+
+
+#ifdef ZDICT_STATIC_LINKING_ONLY
+
+/* ====================================================================================
+ * The definitions in this section are considered experimental.
+ * They should never be used with a dynamic library, as they may change in the future.
+ * They are provided for advanced usages.
+ * Use them only in association with static linking.
+ * ==================================================================================== */
+
+typedef struct {
+ int compressionLevel; /* optimize for a specific zstd compression level; 0 means default */
+ unsigned notificationLevel; /* Write log to stderr; 0 = none (default); 1 = errors; 2 = progression; 3 = details; 4 = debug; */
+ unsigned dictID; /* force dictID value; 0 means auto mode (32-bits random value) */
+} ZDICT_params_t;
+
+/*! ZDICT_cover_params_t:
+ * k and d are the only required parameters.
+ * For others, value 0 means default.
+ */
+typedef struct {
+ unsigned k; /* Segment size : constraint: 0 < k : Reasonable range [16, 2048+] */
+ unsigned d; /* dmer size : constraint: 0 < d <= k : Reasonable range [6, 16] */
+ unsigned steps; /* Number of steps : Only used for optimization : 0 means default (40) : Higher means more parameters checked */
+ unsigned nbThreads; /* Number of threads : constraint: 0 < nbThreads : 1 means single-threaded : Only used for optimization : Ignored if ZSTD_MULTITHREAD is not defined */
+ double splitPoint; /* Percentage of samples used for training: Only used for optimization : the first nbSamples * splitPoint samples will be used to training, the last nbSamples * (1 - splitPoint) samples will be used for testing, 0 means default (1.0), 1.0 when all samples are used for both training and testing */
+ ZDICT_params_t zParams;
+} ZDICT_cover_params_t;
+
+typedef struct {
+ unsigned k; /* Segment size : constraint: 0 < k : Reasonable range [16, 2048+] */
+ unsigned d; /* dmer size : constraint: 0 < d <= k : Reasonable range [6, 16] */
+ unsigned f; /* log of size of frequency array : constraint: 0 < f <= 31 : 1 means default(20)*/
+ unsigned steps; /* Number of steps : Only used for optimization : 0 means default (40) : Higher means more parameters checked */
+ unsigned nbThreads; /* Number of threads : constraint: 0 < nbThreads : 1 means single-threaded : Only used for optimization : Ignored if ZSTD_MULTITHREAD is not defined */
+ double splitPoint; /* Percentage of samples used for training: Only used for optimization : the first nbSamples * splitPoint samples will be used to training, the last nbSamples * (1 - splitPoint) samples will be used for testing, 0 means default (0.75), 1.0 when all samples are used for both training and testing */
+ unsigned accel; /* Acceleration level: constraint: 0 < accel <= 10, higher means faster and less accurate, 0 means default(1) */
+ ZDICT_params_t zParams;
+} ZDICT_fastCover_params_t;
+
+/*! ZDICT_trainFromBuffer_cover():
+ * Train a dictionary from an array of samples using the COVER algorithm.
+ * Samples must be stored concatenated in a single flat buffer `samplesBuffer`,
+ * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order.
+ * The resulting dictionary will be saved into `dictBuffer`.
+ * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
+ * or an error code, which can be tested with ZDICT_isError().
+ * Note: ZDICT_trainFromBuffer_cover() requires about 9 bytes of memory for each input byte.
+ * Tips: In general, a reasonable dictionary has a size of ~ 100 KB.
+ * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`.
+ * In general, it's recommended to provide a few thousands samples, though this can vary a lot.
+ * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
+ */
+ZDICTLIB_API size_t ZDICT_trainFromBuffer_cover(
+ void *dictBuffer, size_t dictBufferCapacity,
+ const void *samplesBuffer, const size_t *samplesSizes, unsigned nbSamples,
+ ZDICT_cover_params_t parameters);
+
+/*! ZDICT_optimizeTrainFromBuffer_cover():
+ * The same requirements as above hold for all the parameters except `parameters`.
+ * This function tries many parameter combinations and picks the best parameters.
+ * `*parameters` is filled with the best parameters found,
+ * dictionary constructed with those parameters is stored in `dictBuffer`.
+ *
+ * All of the parameters d, k, steps are optional.
+ * If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}.
+ * if steps is zero it defaults to its default value.
+ * If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000].
+ *
+ * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
+ * or an error code, which can be tested with ZDICT_isError().
+ * On success `*parameters` contains the parameters selected.
+ * Note: ZDICT_optimizeTrainFromBuffer_cover() requires about 8 bytes of memory for each input byte and additionally another 5 bytes of memory for each byte of memory for each thread.
+ */
+ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_cover(
+ void* dictBuffer, size_t dictBufferCapacity,
+ const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
+ ZDICT_cover_params_t* parameters);
+
+/*! ZDICT_trainFromBuffer_fastCover():
+ * Train a dictionary from an array of samples using a modified version of COVER algorithm.
+ * Samples must be stored concatenated in a single flat buffer `samplesBuffer`,
+ * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order.
+ * d and k are required.
+ * All other parameters are optional, will use default values if not provided
+ * The resulting dictionary will be saved into `dictBuffer`.
+ * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
+ * or an error code, which can be tested with ZDICT_isError().
+ * Note: ZDICT_trainFromBuffer_fastCover() requires about 1 bytes of memory for each input byte and additionally another 6 * 2^f bytes of memory .
+ * Tips: In general, a reasonable dictionary has a size of ~ 100 KB.
+ * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`.
+ * In general, it's recommended to provide a few thousands samples, though this can vary a lot.
+ * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
+ */
+ZDICTLIB_API size_t ZDICT_trainFromBuffer_fastCover(void *dictBuffer,
+ size_t dictBufferCapacity, const void *samplesBuffer,
+ const size_t *samplesSizes, unsigned nbSamples,
+ ZDICT_fastCover_params_t parameters);
+
+/*! ZDICT_optimizeTrainFromBuffer_fastCover():
+ * The same requirements as above hold for all the parameters except `parameters`.
+ * This function tries many parameter combinations (specifically, k and d combinations)
+ * and picks the best parameters. `*parameters` is filled with the best parameters found,
+ * dictionary constructed with those parameters is stored in `dictBuffer`.
+ * All of the parameters d, k, steps, f, and accel are optional.
+ * If d is non-zero then we don't check multiple values of d, otherwise we check d = {6, 8}.
+ * if steps is zero it defaults to its default value.
+ * If k is non-zero then we don't check multiple values of k, otherwise we check steps values in [50, 2000].
+ * If f is zero, default value of 20 is used.
+ * If accel is zero, default value of 1 is used.
+ *
+ * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
+ * or an error code, which can be tested with ZDICT_isError().
+ * On success `*parameters` contains the parameters selected.
+ * Note: ZDICT_optimizeTrainFromBuffer_fastCover() requires about 1 byte of memory for each input byte and additionally another 6 * 2^f bytes of memory for each thread.
+ */
+ZDICTLIB_API size_t ZDICT_optimizeTrainFromBuffer_fastCover(void* dictBuffer,
+ size_t dictBufferCapacity, const void* samplesBuffer,
+ const size_t* samplesSizes, unsigned nbSamples,
+ ZDICT_fastCover_params_t* parameters);
+
+/*! ZDICT_finalizeDictionary():
+ * Given a custom content as a basis for dictionary, and a set of samples,
+ * finalize dictionary by adding headers and statistics.
+ *
+ * Samples must be stored concatenated in a flat buffer `samplesBuffer`,
+ * supplied with an array of sizes `samplesSizes`, providing the size of each sample in order.
+ *
+ * dictContentSize must be >= ZDICT_CONTENTSIZE_MIN bytes.
+ * maxDictSize must be >= dictContentSize, and must be >= ZDICT_DICTSIZE_MIN bytes.
+ *
+ * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`),
+ * or an error code, which can be tested by ZDICT_isError().
+ * Note: ZDICT_finalizeDictionary() will push notifications into stderr if instructed to, using notificationLevel>0.
+ * Note 2: dictBuffer and dictContent can overlap
+ */
+#define ZDICT_CONTENTSIZE_MIN 128
+#define ZDICT_DICTSIZE_MIN 256
+ZDICTLIB_API size_t ZDICT_finalizeDictionary(void* dictBuffer, size_t dictBufferCapacity,
+ const void* dictContent, size_t dictContentSize,
+ const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples,
+ ZDICT_params_t parameters);
+
+typedef struct {
+ unsigned selectivityLevel; /* 0 means default; larger => select more => larger dictionary */
+ ZDICT_params_t zParams;
+} ZDICT_legacy_params_t;
+
+/*! ZDICT_trainFromBuffer_legacy():
+ * Train a dictionary from an array of samples.
+ * Samples must be stored concatenated in a single flat buffer `samplesBuffer`,
+ * supplied with an array of sizes `samplesSizes`, providing the size of each sample, in order.
+ * The resulting dictionary will be saved into `dictBuffer`.
+ * `parameters` is optional and can be provided with values set to 0 to mean "default".
+ * @return: size of dictionary stored into `dictBuffer` (<= `dictBufferCapacity`)
+ * or an error code, which can be tested with ZDICT_isError().
+ * Tips: In general, a reasonable dictionary has a size of ~ 100 KB.
+ * It's possible to select smaller or larger size, just by specifying `dictBufferCapacity`.
+ * In general, it's recommended to provide a few thousands samples, though this can vary a lot.
+ * It's recommended that total size of all samples be about ~x100 times the target size of dictionary.
+ * Note: ZDICT_trainFromBuffer_legacy() will send notifications into stderr if instructed to, using notificationLevel>0.
+ */
+ZDICTLIB_API size_t ZDICT_trainFromBuffer_legacy(
+ void *dictBuffer, size_t dictBufferCapacity,
+ const void *samplesBuffer, const size_t *samplesSizes, unsigned nbSamples,
+ ZDICT_legacy_params_t parameters);
+
+/* Deprecation warnings */
+/* It is generally possible to disable deprecation warnings from compiler,
+ for example with -Wno-deprecated-declarations for gcc
+ or _CRT_SECURE_NO_WARNINGS in Visual.
+ Otherwise, it's also possible to manually define ZDICT_DISABLE_DEPRECATE_WARNINGS */
+#ifdef ZDICT_DISABLE_DEPRECATE_WARNINGS
+# define ZDICT_DEPRECATED(message) ZDICTLIB_API /* disable deprecation warnings */
+#else
+# define ZDICT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
+# define ZDICT_DEPRECATED(message) [[deprecated(message)]] ZDICTLIB_API
+# elif (ZDICT_GCC_VERSION >= 405) || defined(__clang__)
+# define ZDICT_DEPRECATED(message) ZDICTLIB_API __attribute__((deprecated(message)))
+# elif (ZDICT_GCC_VERSION >= 301)
+# define ZDICT_DEPRECATED(message) ZDICTLIB_API __attribute__((deprecated))
+# elif defined(_MSC_VER)
+# define ZDICT_DEPRECATED(message) ZDICTLIB_API __declspec(deprecated(message))
+# else
+# pragma message("WARNING: You need to implement ZDICT_DEPRECATED for this compiler")
+# define ZDICT_DEPRECATED(message) ZDICTLIB_API
+# endif
+#endif /* ZDICT_DISABLE_DEPRECATE_WARNINGS */
+
+ZDICT_DEPRECATED("use ZDICT_finalizeDictionary() instead")
+size_t ZDICT_addEntropyTablesFromBuffer(void* dictBuffer, size_t dictContentSize, size_t dictBufferCapacity,
+ const void* samplesBuffer, const size_t* samplesSizes, unsigned nbSamples);
+
+
+#endif /* ZDICT_STATIC_LINKING_ONLY */
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* DICTBUILDER_H_001 */
diff --git a/Utilities/cmzstd/lib/zstd.h b/Utilities/cmzstd/lib/zstd.h
new file mode 100644
index 000000000..b18fc8a44
--- /dev/null
+++ b/Utilities/cmzstd/lib/zstd.h
@@ -0,0 +1,1766 @@
+/*
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under both the BSD-style license (found in the
+ * LICENSE file in the root directory of this source tree) and the GPLv2 (found
+ * in the COPYING file in the root directory of this source tree).
+ * You may select, at your option, one of the above-listed licenses.
+ */
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+#ifndef ZSTD_H_235446
+#define ZSTD_H_235446
+
+/* ====== Dependency ======*/
+#include <stddef.h> /* size_t */
+
+
+/* ===== ZSTDLIB_API : control library symbols visibility ===== */
+#ifndef ZSTDLIB_VISIBILITY
+# if defined(__GNUC__) && (__GNUC__ >= 4)
+# define ZSTDLIB_VISIBILITY __attribute__ ((visibility ("default")))
+# else
+# define ZSTDLIB_VISIBILITY
+# endif
+#endif
+#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1)
+# define ZSTDLIB_API __declspec(dllexport) ZSTDLIB_VISIBILITY
+#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)
+# define ZSTDLIB_API __declspec(dllimport) ZSTDLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
+#else
+# define ZSTDLIB_API ZSTDLIB_VISIBILITY
+#endif
+
+
+/*******************************************************************************
+ Introduction
+
+ zstd, short for Zstandard, is a fast lossless compression algorithm, targeting
+ real-time compression scenarios at zlib-level and better compression ratios.
+ The zstd compression library provides in-memory compression and decompression
+ functions.
+
+ The library supports regular compression levels from 1 up to ZSTD_maxCLevel(),
+ which is currently 22. Levels >= 20, labeled `--ultra`, should be used with
+ caution, as they require more memory. The library also offers negative
+ compression levels, which extend the range of speed vs. ratio preferences.
+ The lower the level, the faster the speed (at the cost of compression).
+
+ Compression can be done in:
+ - a single step (described as Simple API)
+ - a single step, reusing a context (described as Explicit context)
+ - unbounded multiple steps (described as Streaming compression)
+
+ The compression ratio achievable on small data can be highly improved using
+ a dictionary. Dictionary compression can be performed in:
+ - a single step (described as Simple dictionary API)
+ - a single step, reusing a dictionary (described as Bulk-processing
+ dictionary API)
+
+ Advanced experimental functions can be accessed using
+ `#define ZSTD_STATIC_LINKING_ONLY` before including zstd.h.
+
+ Advanced experimental APIs should never be used with a dynamically-linked
+ library. They are not "stable"; their definitions or signatures may change in
+ the future. Only static linking is allowed.
+*******************************************************************************/
+
+/*------ Version ------*/
+#define ZSTD_VERSION_MAJOR 1
+#define ZSTD_VERSION_MINOR 3
+#define ZSTD_VERSION_RELEASE 8
+
+#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE)
+ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< to check runtime library version */
+
+#define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE
+#define ZSTD_QUOTE(str) #str
+#define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str)
+#define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION)
+ZSTDLIB_API const char* ZSTD_versionString(void); /* requires v1.3.0+ */
+
+/***************************************
+* Default constant
+***************************************/
+#ifndef ZSTD_CLEVEL_DEFAULT
+# define ZSTD_CLEVEL_DEFAULT 3
+#endif
+
+/***************************************
+* Simple API
+***************************************/
+/*! ZSTD_compress() :
+ * Compresses `src` content as a single zstd compressed frame into already allocated `dst`.
+ * Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`.
+ * @return : compressed size written into `dst` (<= `dstCapacity),
+ * or an error code if it fails (which can be tested using ZSTD_isError()). */
+ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ int compressionLevel);
+
+/*! ZSTD_decompress() :
+ * `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames.
+ * `dstCapacity` is an upper bound of originalSize to regenerate.
+ * If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data.
+ * @return : the number of bytes decompressed into `dst` (<= `dstCapacity`),
+ * or an errorCode if it fails (which can be tested using ZSTD_isError()). */
+ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity,
+ const void* src, size_t compressedSize);
+
+/*! ZSTD_getFrameContentSize() : requires v1.3.0+
+ * `src` should point to the start of a ZSTD encoded frame.
+ * `srcSize` must be at least as large as the frame header.
+ * hint : any size >= `ZSTD_frameHeaderSize_max` is large enough.
+ * @return : - decompressed size of `src` frame content, if known
+ * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined
+ * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small)
+ * note 1 : a 0 return value means the frame is valid but "empty".
+ * note 2 : decompressed size is an optional field, it may not be present, typically in streaming mode.
+ * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
+ * In which case, it's necessary to use streaming mode to decompress data.
+ * Optionally, application can rely on some implicit limit,
+ * as ZSTD_decompress() only needs an upper bound of decompressed size.
+ * (For example, data could be necessarily cut into blocks <= 16 KB).
+ * note 3 : decompressed size is always present when compression is completed using single-pass functions,
+ * such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict().
+ * note 4 : decompressed size can be very large (64-bits value),
+ * potentially larger than what local system can handle as a single memory segment.
+ * In which case, it's necessary to use streaming mode to decompress data.
+ * note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified.
+ * Always ensure return value fits within application's authorized limits.
+ * Each application can set its own limits.
+ * note 6 : This function replaces ZSTD_getDecompressedSize() */
+#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1)
+#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2)
+ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize);
+
+/*! ZSTD_getDecompressedSize() :
+ * NOTE: This function is now obsolete, in favor of ZSTD_getFrameContentSize().
+ * Both functions work the same way, but ZSTD_getDecompressedSize() blends
+ * "empty", "unknown" and "error" results to the same return value (0),
+ * while ZSTD_getFrameContentSize() gives them separate return values.
+ * @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise. */
+ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize);
+
+
+/*====== Helper functions ======*/
+#define ZSTD_COMPRESSBOUND(srcSize) ((srcSize) + ((srcSize)>>8) + (((srcSize) < (128<<10)) ? (((128<<10) - (srcSize)) >> 11) /* margin, from 64 to 0 */ : 0)) /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */
+ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case single-pass scenario */
+ZSTDLIB_API unsigned ZSTD_isError(size_t code); /*!< tells if a `size_t` function result is an error code */
+ZSTDLIB_API const char* ZSTD_getErrorName(size_t code); /*!< provides readable string from an error code */
+ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compression level available */
+
+
+/***************************************
+* Explicit context
+***************************************/
+/*= Compression context
+ * When compressing many times,
+ * it is recommended to allocate a context just once, and re-use it for each successive compression operation.
+ * This will make workload friendlier for system's memory.
+ * Use one context per thread for parallel execution in multi-threaded environments. */
+typedef struct ZSTD_CCtx_s ZSTD_CCtx;
+ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void);
+ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx);
+
+/*! ZSTD_compressCCtx() :
+ * Same as ZSTD_compress(), using an explicit ZSTD_CCtx
+ * The function will compress at requested compression level,
+ * ignoring any other parameter */
+ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ int compressionLevel);
+
+/*= Decompression context
+ * When decompressing many times,
+ * it is recommended to allocate a context only once,
+ * and re-use it for each successive compression operation.
+ * This will make workload friendlier for system's memory.
+ * Use one context per thread for parallel execution. */
+typedef struct ZSTD_DCtx_s ZSTD_DCtx;
+ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void);
+ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx);
+
+/*! ZSTD_decompressDCtx() :
+ * Same as ZSTD_decompress(),
+ * requires an allocated ZSTD_DCtx.
+ * Compatible with sticky parameters.
+ */
+ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize);
+
+
+/**************************
+* Simple dictionary API
+***************************/
+/*! ZSTD_compress_usingDict() :
+ * Compression at an explicit compression level using a Dictionary.
+ * A dictionary can be any arbitrary data segment (also called a prefix),
+ * or a buffer with specified information (see dictBuilder/zdict.h).
+ * Note : This function loads the dictionary, resulting in significant startup delay.
+ * It's intended for a dictionary used only once.
+ * Note 2 : When `dict == NULL || dictSize < 8` no dictionary is used. */
+ZSTDLIB_API size_t ZSTD_compress_usingDict(ZSTD_CCtx* ctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict,size_t dictSize,
+ int compressionLevel);
+
+/*! ZSTD_decompress_usingDict() :
+ * Decompression using a known Dictionary.
+ * Dictionary must be identical to the one used during compression.
+ * Note : This function loads the dictionary, resulting in significant startup delay.
+ * It's intended for a dictionary used only once.
+ * Note : When `dict == NULL || dictSize < 8` no dictionary is used. */
+ZSTDLIB_API size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict,size_t dictSize);
+
+
+/***********************************
+ * Bulk processing dictionary API
+ **********************************/
+typedef struct ZSTD_CDict_s ZSTD_CDict;
+
+/*! ZSTD_createCDict() :
+ * When compressing multiple messages / blocks using the same dictionary, it's recommended to load it only once.
+ * ZSTD_createCDict() will create a digested dictionary, ready to start future compression operations without startup cost.
+ * ZSTD_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.
+ * `dictBuffer` can be released after ZSTD_CDict creation, because its content is copied within CDict.
+ * Consider experimental function `ZSTD_createCDict_byReference()` if you prefer to not duplicate `dictBuffer` content.
+ * Note : A ZSTD_CDict can be created from an empty dictBuffer, but it is inefficient when used to compress small data. */
+ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize,
+ int compressionLevel);
+
+/*! ZSTD_freeCDict() :
+ * Function frees memory allocated by ZSTD_createCDict(). */
+ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict);
+
+/*! ZSTD_compress_usingCDict() :
+ * Compression using a digested Dictionary.
+ * Recommended when same dictionary is used multiple times.
+ * Note : compression level is _decided at dictionary creation time_,
+ * and frame parameters are hardcoded (dictID=yes, contentSize=yes, checksum=no) */
+ZSTDLIB_API size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_CDict* cdict);
+
+
+typedef struct ZSTD_DDict_s ZSTD_DDict;
+
+/*! ZSTD_createDDict() :
+ * Create a digested dictionary, ready to start decompression operation without startup delay.
+ * dictBuffer can be released after DDict creation, as its content is copied inside DDict. */
+ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize);
+
+/*! ZSTD_freeDDict() :
+ * Function frees memory allocated with ZSTD_createDDict() */
+ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict);
+
+/*! ZSTD_decompress_usingDDict() :
+ * Decompression using a digested Dictionary.
+ * Recommended when same dictionary is used multiple times. */
+ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_DDict* ddict);
+
+
+/****************************
+* Streaming
+****************************/
+
+typedef struct ZSTD_inBuffer_s {
+ const void* src; /**< start of input buffer */
+ size_t size; /**< size of input buffer */
+ size_t pos; /**< position where reading stopped. Will be updated. Necessarily 0 <= pos <= size */
+} ZSTD_inBuffer;
+
+typedef struct ZSTD_outBuffer_s {
+ void* dst; /**< start of output buffer */
+ size_t size; /**< size of output buffer */
+ size_t pos; /**< position where writing stopped. Will be updated. Necessarily 0 <= pos <= size */
+} ZSTD_outBuffer;
+
+
+
+/*-***********************************************************************
+* Streaming compression - HowTo
+*
+* A ZSTD_CStream object is required to track streaming operation.
+* Use ZSTD_createCStream() and ZSTD_freeCStream() to create/release resources.
+* ZSTD_CStream objects can be reused multiple times on consecutive compression operations.
+* It is recommended to re-use ZSTD_CStream since it will play nicer with system's memory, by re-using already allocated memory.
+*
+* For parallel execution, use one separate ZSTD_CStream per thread.
+*
+* note : since v1.3.0, ZSTD_CStream and ZSTD_CCtx are the same thing.
+*
+* Parameters are sticky : when starting a new compression on the same context,
+* it will re-use the same sticky parameters as previous compression session.
+* When in doubt, it's recommended to fully initialize the context before usage.
+* Use ZSTD_initCStream() to set the parameter to a selected compression level.
+* Use advanced API (ZSTD_CCtx_setParameter(), etc.) to set more specific parameters.
+*
+* Use ZSTD_compressStream() as many times as necessary to consume input stream.
+* The function will automatically update both `pos` fields within `input` and `output`.
+* Note that the function may not consume the entire input,
+* for example, because the output buffer is already full,
+* in which case `input.pos < input.size`.
+* The caller must check if input has been entirely consumed.
+* If not, the caller must make some room to receive more compressed data,
+* and then present again remaining input data.
+* @return : a size hint, preferred nb of bytes to use as input for next function call
+* or an error code, which can be tested using ZSTD_isError().
+* Note 1 : it's just a hint, to help latency a little, any value will work fine.
+* Note 2 : size hint is guaranteed to be <= ZSTD_CStreamInSize()
+*
+* At any moment, it's possible to flush whatever data might remain stuck within internal buffer,
+* using ZSTD_flushStream(). `output->pos` will be updated.
+* Note that, if `output->size` is too small, a single invocation of ZSTD_flushStream() might not be enough (return code > 0).
+* In which case, make some room to receive more compressed data, and call again ZSTD_flushStream().
+* @return : 0 if internal buffers are entirely flushed,
+* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size),
+* or an error code, which can be tested using ZSTD_isError().
+*
+* ZSTD_endStream() instructs to finish a frame.
+* It will perform a flush and write frame epilogue.
+* The epilogue is required for decoders to consider a frame completed.
+* flush() operation is the same, and follows same rules as ZSTD_flushStream().
+* @return : 0 if frame fully completed and fully flushed,
+* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size),
+* or an error code, which can be tested using ZSTD_isError().
+*
+* *******************************************************************/
+
+typedef ZSTD_CCtx ZSTD_CStream; /**< CCtx and CStream are now effectively same object (>= v1.3.0) */
+ /* Continue to distinguish them for compatibility with older versions <= v1.2.0 */
+/*===== ZSTD_CStream management functions =====*/
+ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream(void);
+ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs);
+
+/*===== Streaming compression functions =====*/
+ZSTDLIB_API size_t ZSTD_initCStream(ZSTD_CStream* zcs, int compressionLevel);
+ZSTDLIB_API size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
+ZSTDLIB_API size_t ZSTD_flushStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
+ZSTDLIB_API size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output);
+
+ZSTDLIB_API size_t ZSTD_CStreamInSize(void); /**< recommended size for input buffer */
+ZSTDLIB_API size_t ZSTD_CStreamOutSize(void); /**< recommended size for output buffer. Guarantee to successfully flush at least one complete compressed block in all circumstances. */
+
+
+
+/*-***************************************************************************
+* Streaming decompression - HowTo
+*
+* A ZSTD_DStream object is required to track streaming operations.
+* Use ZSTD_createDStream() and ZSTD_freeDStream() to create/release resources.
+* ZSTD_DStream objects can be re-used multiple times.
+*
+* Use ZSTD_initDStream() to start a new decompression operation.
+* @return : recommended first input size
+* Alternatively, use advanced API to set specific properties.
+*
+* Use ZSTD_decompressStream() repetitively to consume your input.
+* The function will update both `pos` fields.
+* If `input.pos < input.size`, some input has not been consumed.
+* It's up to the caller to present again remaining data.
+* The function tries to flush all data decoded immediately, respecting output buffer size.
+* If `output.pos < output.size`, decoder has flushed everything it could.
+* But if `output.pos == output.size`, there might be some data left within internal buffers.,
+* In which case, call ZSTD_decompressStream() again to flush whatever remains in the buffer.
+* Note : with no additional input provided, amount of data flushed is necessarily <= ZSTD_BLOCKSIZE_MAX.
+* @return : 0 when a frame is completely decoded and fully flushed,
+* or an error code, which can be tested using ZSTD_isError(),
+* or any other value > 0, which means there is still some decoding or flushing to do to complete current frame :
+* the return value is a suggested next input size (just a hint for better latency)
+* that will never request more than the remaining frame size.
+* *******************************************************************************/
+
+typedef ZSTD_DCtx ZSTD_DStream; /**< DCtx and DStream are now effectively same object (>= v1.3.0) */
+ /* For compatibility with versions <= v1.2.0, prefer differentiating them. */
+/*===== ZSTD_DStream management functions =====*/
+ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream(void);
+ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds);
+
+/*===== Streaming decompression functions =====*/
+ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds);
+ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input);
+
+ZSTDLIB_API size_t ZSTD_DStreamInSize(void); /*!< recommended size for input buffer */
+ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output buffer. Guarantee to successfully flush at least one complete block in all circumstances. */
+
+#endif /* ZSTD_H_235446 */
+
+
+
+
+/****************************************************************************************
+ * ADVANCED AND EXPERIMENTAL FUNCTIONS
+ ****************************************************************************************
+ * The definitions in the following section are considered experimental.
+ * They are provided for advanced scenarios.
+ * They should never be used with a dynamic library, as prototypes may change in the future.
+ * Use them only in association with static linking.
+ * ***************************************************************************************/
+
+#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY)
+#define ZSTD_H_ZSTD_STATIC_LINKING_ONLY
+
+
+/****************************************************************************************
+ * Candidate API for promotion to stable status
+ ****************************************************************************************
+ * The following symbols and constants form the "staging area" :
+ * they are considered to join "stable API" by v1.4.0.
+ * The proposal is written so that it can be made stable "as is",
+ * though it's still possible to suggest improvements.
+ * Staging is in fact last chance for changes,
+ * the API is locked once reaching "stable" status.
+ * ***************************************************************************************/
+
+
+/* === Constants === */
+
+/* all magic numbers are supposed read/written to/from files/memory using little-endian convention */
+#define ZSTD_MAGICNUMBER 0xFD2FB528 /* valid since v0.8.0 */
+#define ZSTD_MAGIC_DICTIONARY 0xEC30A437 /* valid since v0.7.0 */
+#define ZSTD_MAGIC_SKIPPABLE_START 0x184D2A50 /* all 16 values, from 0x184D2A50 to 0x184D2A5F, signal the beginning of a skippable frame */
+#define ZSTD_MAGIC_SKIPPABLE_MASK 0xFFFFFFF0
+
+#define ZSTD_BLOCKSIZELOG_MAX 17
+#define ZSTD_BLOCKSIZE_MAX (1<<ZSTD_BLOCKSIZELOG_MAX)
+
+
+/* === query limits === */
+
+ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed */
+
+
+/* === frame size === */
+
+/*! ZSTD_findFrameCompressedSize() :
+ * `src` should point to the start of a ZSTD frame or skippable frame.
+ * `srcSize` must be >= first frame size
+ * @return : the compressed size of the first frame starting at `src`,
+ * suitable to pass as `srcSize` to `ZSTD_decompress` or similar,
+ * or an error code if input is invalid */
+ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize);
+
+
+/* === Memory management === */
+
+/*! ZSTD_sizeof_*() :
+ * These functions give the _current_ memory usage of selected object.
+ * Note that object memory usage can evolve (increase or decrease) over time. */
+ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx);
+ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx);
+ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs);
+ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds);
+ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict);
+ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
+
+
+/***************************************
+* Advanced compression API
+***************************************/
+
+/* API design :
+ * Parameters are pushed one by one into an existing context,
+ * using ZSTD_CCtx_set*() functions.
+ * Pushed parameters are sticky : they are valid for next compressed frame, and any subsequent frame.
+ * "sticky" parameters are applicable to `ZSTD_compress2()` and `ZSTD_compressStream*()` !
+ * They do not apply to "simple" one-shot variants such as ZSTD_compressCCtx()
+ *
+ * It's possible to reset all parameters to "default" using ZSTD_CCtx_reset().
+ *
+ * This API supercedes all other "advanced" API entry points in the experimental section.
+ * In the future, we expect to remove from experimental API entry points which are redundant with this API.
+ */
+
+
+/* Compression strategies, listed from fastest to strongest */
+typedef enum { ZSTD_fast=1,
+ ZSTD_dfast=2,
+ ZSTD_greedy=3,
+ ZSTD_lazy=4,
+ ZSTD_lazy2=5,
+ ZSTD_btlazy2=6,
+ ZSTD_btopt=7,
+ ZSTD_btultra=8,
+ ZSTD_btultra2=9
+ /* note : new strategies _might_ be added in the future.
+ Only the order (from fast to strong) is guaranteed */
+} ZSTD_strategy;
+
+
+typedef enum {
+
+ /* compression parameters */
+ ZSTD_c_compressionLevel=100, /* Update all compression parameters according to pre-defined cLevel table
+ * Default level is ZSTD_CLEVEL_DEFAULT==3.
+ * Special: value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT.
+ * Note 1 : it's possible to pass a negative compression level.
+ * Note 2 : setting a level sets all default values of other compression parameters */
+ ZSTD_c_windowLog=101, /* Maximum allowed back-reference distance, expressed as power of 2.
+ * Must be clamped between ZSTD_WINDOWLOG_MIN and ZSTD_WINDOWLOG_MAX.
+ * Special: value 0 means "use default windowLog".
+ * Note: Using a windowLog greater than ZSTD_WINDOWLOG_LIMIT_DEFAULT
+ * requires explicitly allowing such window size at decompression stage if using streaming. */
+ ZSTD_c_hashLog=102, /* Size of the initial probe table, as a power of 2.
+ * Resulting memory usage is (1 << (hashLog+2)).
+ * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX.
+ * Larger tables improve compression ratio of strategies <= dFast,
+ * and improve speed of strategies > dFast.
+ * Special: value 0 means "use default hashLog". */
+ ZSTD_c_chainLog=103, /* Size of the multi-probe search table, as a power of 2.
+ * Resulting memory usage is (1 << (chainLog+2)).
+ * Must be clamped between ZSTD_CHAINLOG_MIN and ZSTD_CHAINLOG_MAX.
+ * Larger tables result in better and slower compression.
+ * This parameter is useless when using "fast" strategy.
+ * It's still useful when using "dfast" strategy,
+ * in which case it defines a secondary probe table.
+ * Special: value 0 means "use default chainLog". */
+ ZSTD_c_searchLog=104, /* Number of search attempts, as a power of 2.
+ * More attempts result in better and slower compression.
+ * This parameter is useless when using "fast" and "dFast" strategies.
+ * Special: value 0 means "use default searchLog". */
+ ZSTD_c_minMatch=105, /* Minimum size of searched matches.
+ * Note that Zstandard can still find matches of smaller size,
+ * it just tweaks its search algorithm to look for this size and larger.
+ * Larger values increase compression and decompression speed, but decrease ratio.
+ * Must be clamped between ZSTD_MINMATCH_MIN and ZSTD_MINMATCH_MAX.
+ * Note that currently, for all strategies < btopt, effective minimum is 4.
+ * , for all strategies > fast, effective maximum is 6.
+ * Special: value 0 means "use default minMatchLength". */
+ ZSTD_c_targetLength=106, /* Impact of this field depends on strategy.
+ * For strategies btopt, btultra & btultra2:
+ * Length of Match considered "good enough" to stop search.
+ * Larger values make compression stronger, and slower.
+ * For strategy fast:
+ * Distance between match sampling.
+ * Larger values make compression faster, and weaker.
+ * Special: value 0 means "use default targetLength". */
+ ZSTD_c_strategy=107, /* See ZSTD_strategy enum definition.
+ * The higher the value of selected strategy, the more complex it is,
+ * resulting in stronger and slower compression.
+ * Special: value 0 means "use default strategy". */
+
+ /* LDM mode parameters */
+ ZSTD_c_enableLongDistanceMatching=160, /* Enable long distance matching.
+ * This parameter is designed to improve compression ratio
+ * for large inputs, by finding large matches at long distance.
+ * It increases memory usage and window size.
+ * Note: enabling this parameter increases default ZSTD_c_windowLog to 128 MB
+ * except when expressly set to a different value. */
+ ZSTD_c_ldmHashLog=161, /* Size of the table for long distance matching, as a power of 2.
+ * Larger values increase memory usage and compression ratio,
+ * but decrease compression speed.
+ * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX
+ * default: windowlog - 7.
+ * Special: value 0 means "automatically determine hashlog". */
+ ZSTD_c_ldmMinMatch=162, /* Minimum match size for long distance matcher.
+ * Larger/too small values usually decrease compression ratio.
+ * Must be clamped between ZSTD_LDM_MINMATCH_MIN and ZSTD_LDM_MINMATCH_MAX.
+ * Special: value 0 means "use default value" (default: 64). */
+ ZSTD_c_ldmBucketSizeLog=163, /* Log size of each bucket in the LDM hash table for collision resolution.
+ * Larger values improve collision resolution but decrease compression speed.
+ * The maximum value is ZSTD_LDM_BUCKETSIZELOG_MAX.
+ * Special: value 0 means "use default value" (default: 3). */
+ ZSTD_c_ldmHashRateLog=164, /* Frequency of inserting/looking up entries into the LDM hash table.
+ * Must be clamped between 0 and (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN).
+ * Default is MAX(0, (windowLog - ldmHashLog)), optimizing hash table usage.
+ * Larger values improve compression speed.
+ * Deviating far from default value will likely result in a compression ratio decrease.
+ * Special: value 0 means "automatically determine hashRateLog". */
+
+ /* frame parameters */
+ ZSTD_c_contentSizeFlag=200, /* Content size will be written into frame header _whenever known_ (default:1)
+ * Content size must be known at the beginning of compression.
+ * This is automatically the case when using ZSTD_compress2(),
+ * For streaming variants, content size must be provided with ZSTD_CCtx_setPledgedSrcSize() */
+ ZSTD_c_checksumFlag=201, /* A 32-bits checksum of content is written at end of frame (default:0) */
+ ZSTD_c_dictIDFlag=202, /* When applicable, dictionary's ID is written into frame header (default:1) */
+
+ /* multi-threading parameters */
+ /* These parameters are only useful if multi-threading is enabled (compiled with build macro ZSTD_MULTITHREAD).
+ * They return an error otherwise. */
+ ZSTD_c_nbWorkers=400, /* Select how many threads will be spawned to compress in parallel.
+ * When nbWorkers >= 1, triggers asynchronous mode when used with ZSTD_compressStream*() :
+ * ZSTD_compressStream*() consumes input and flush output if possible, but immediately gives back control to caller,
+ * while compression work is performed in parallel, within worker threads.
+ * (note : a strong exception to this rule is when first invocation of ZSTD_compressStream2() sets ZSTD_e_end :
+ * in which case, ZSTD_compressStream2() delegates to ZSTD_compress2(), which is always a blocking call).
+ * More workers improve speed, but also increase memory usage.
+ * Default value is `0`, aka "single-threaded mode" : no worker is spawned, compression is performed inside Caller's thread, all invocations are blocking */
+ ZSTD_c_jobSize=401, /* Size of a compression job. This value is enforced only when nbWorkers >= 1.
+ * Each compression job is completed in parallel, so this value can indirectly impact the nb of active threads.
+ * 0 means default, which is dynamically determined based on compression parameters.
+ * Job size must be a minimum of overlap size, or 1 MB, whichever is largest.
+ * The minimum size is automatically and transparently enforced */
+ ZSTD_c_overlapLog=402, /* Control the overlap size, as a fraction of window size.
+ * The overlap size is an amount of data reloaded from previous job at the beginning of a new job.
+ * It helps preserve compression ratio, while each job is compressed in parallel.
+ * This value is enforced only when nbWorkers >= 1.
+ * Larger values increase compression ratio, but decrease speed.
+ * Possible values range from 0 to 9 :
+ * - 0 means "default" : value will be determined by the library, depending on strategy
+ * - 1 means "no overlap"
+ * - 9 means "full overlap", using a full window size.
+ * Each intermediate rank increases/decreases load size by a factor 2 :
+ * 9: full window; 8: w/2; 7: w/4; 6: w/8; 5:w/16; 4: w/32; 3:w/64; 2:w/128; 1:no overlap; 0:default
+ * default value varies between 6 and 9, depending on strategy */
+
+ /* note : additional experimental parameters are also available
+ * within the experimental section of the API.
+ * At the time of this writing, they include :
+ * ZSTD_c_rsyncable
+ * ZSTD_c_format
+ * ZSTD_c_forceMaxWindow
+ * ZSTD_c_forceAttachDict
+ * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
+ * note : never ever use experimentalParam? names directly;
+ * also, the enums values themselves are unstable and can still change.
+ */
+ ZSTD_c_experimentalParam1=500,
+ ZSTD_c_experimentalParam2=10,
+ ZSTD_c_experimentalParam3=1000,
+ ZSTD_c_experimentalParam4=1001
+} ZSTD_cParameter;
+
+
+typedef struct {
+ size_t error;
+ int lowerBound;
+ int upperBound;
+} ZSTD_bounds;
+
+/*! ZSTD_cParam_getBounds() :
+ * All parameters must belong to an interval with lower and upper bounds,
+ * otherwise they will either trigger an error or be automatically clamped.
+ * @return : a structure, ZSTD_bounds, which contains
+ * - an error status field, which must be tested using ZSTD_isError()
+ * - lower and upper bounds, both inclusive
+ */
+ZSTDLIB_API ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter cParam);
+
+/*! ZSTD_CCtx_setParameter() :
+ * Set one compression parameter, selected by enum ZSTD_cParameter.
+ * All parameters have valid bounds. Bounds can be queried using ZSTD_cParam_getBounds().
+ * Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter).
+ * Setting a parameter is generally only possible during frame initialization (before starting compression).
+ * Exception : when using multi-threading mode (nbWorkers >= 1),
+ * the following parameters can be updated _during_ compression (within same frame):
+ * => compressionLevel, hashLog, chainLog, searchLog, minMatch, targetLength and strategy.
+ * new parameters will be active for next job only (after a flush()).
+ * @return : an error code (which can be tested using ZSTD_isError()).
+ */
+ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value);
+
+/*! ZSTD_CCtx_setPledgedSrcSize() :
+ * Total input data size to be compressed as a single frame.
+ * Value will be written in frame header, unless if explicitly forbidden using ZSTD_c_contentSizeFlag.
+ * This value will also be controlled at end of frame, and trigger an error if not respected.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Note 1 : pledgedSrcSize==0 actually means zero, aka an empty frame.
+ * In order to mean "unknown content size", pass constant ZSTD_CONTENTSIZE_UNKNOWN.
+ * ZSTD_CONTENTSIZE_UNKNOWN is default value for any new frame.
+ * Note 2 : pledgedSrcSize is only valid once, for the next frame.
+ * It's discarded at the end of the frame, and replaced by ZSTD_CONTENTSIZE_UNKNOWN.
+ * Note 3 : Whenever all input data is provided and consumed in a single round,
+ * for example with ZSTD_compress2(),
+ * or invoking immediately ZSTD_compressStream2(,,,ZSTD_e_end),
+ * this value is automatically overriden by srcSize instead.
+ */
+ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize);
+
+/*! ZSTD_CCtx_loadDictionary() :
+ * Create an internal CDict from `dict` buffer.
+ * Decompression will have to use same dictionary.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Special: Loading a NULL (or 0-size) dictionary invalidates previous dictionary,
+ * meaning "return to no-dictionary mode".
+ * Note 1 : Dictionary is sticky, it will be used for all future compressed frames.
+ * To return to "no-dictionary" situation, load a NULL dictionary (or reset parameters).
+ * Note 2 : Loading a dictionary involves building tables.
+ * It's also a CPU consuming operation, with non-negligible impact on latency.
+ * Tables are dependent on compression parameters, and for this reason,
+ * compression parameters can no longer be changed after loading a dictionary.
+ * Note 3 :`dict` content will be copied internally.
+ * Use experimental ZSTD_CCtx_loadDictionary_byReference() to reference content instead.
+ * In such a case, dictionary buffer must outlive its users.
+ * Note 4 : Use ZSTD_CCtx_loadDictionary_advanced()
+ * to precisely select how dictionary content must be interpreted. */
+ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
+
+/*! ZSTD_CCtx_refCDict() :
+ * Reference a prepared dictionary, to be used for all next compressed frames.
+ * Note that compression parameters are enforced from within CDict,
+ * and supercede any compression parameter previously set within CCtx.
+ * The dictionary will remain valid for future compressed frames using same CCtx.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Special : Referencing a NULL CDict means "return to no-dictionary mode".
+ * Note 1 : Currently, only one dictionary can be managed.
+ * Referencing a new dictionary effectively "discards" any previous one.
+ * Note 2 : CDict is just referenced, its lifetime must outlive its usage within CCtx. */
+ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict);
+
+/*! ZSTD_CCtx_refPrefix() :
+ * Reference a prefix (single-usage dictionary) for next compressed frame.
+ * A prefix is **only used once**. Tables are discarded at end of frame (ZSTD_e_end).
+ * Decompression will need same prefix to properly regenerate data.
+ * Compressing with a prefix is similar in outcome as performing a diff and compressing it,
+ * but performs much faster, especially during decompression (compression speed is tunable with compression level).
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Special: Adding any prefix (including NULL) invalidates any previous prefix or dictionary
+ * Note 1 : Prefix buffer is referenced. It **must** outlive compression.
+ * Its content must remain unmodified during compression.
+ * Note 2 : If the intention is to diff some large src data blob with some prior version of itself,
+ * ensure that the window size is large enough to contain the entire source.
+ * See ZSTD_c_windowLog.
+ * Note 3 : Referencing a prefix involves building tables, which are dependent on compression parameters.
+ * It's a CPU consuming operation, with non-negligible impact on latency.
+ * If there is a need to use the same prefix multiple times, consider loadDictionary instead.
+ * Note 4 : By default, the prefix is interpreted as raw content (ZSTD_dm_rawContent).
+ * Use experimental ZSTD_CCtx_refPrefix_advanced() to alter dictionary interpretation. */
+ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx,
+ const void* prefix, size_t prefixSize);
+
+
+typedef enum {
+ ZSTD_reset_session_only = 1,
+ ZSTD_reset_parameters = 2,
+ ZSTD_reset_session_and_parameters = 3
+} ZSTD_ResetDirective;
+
+/*! ZSTD_CCtx_reset() :
+ * There are 2 different things that can be reset, independently or jointly :
+ * - The session : will stop compressing current frame, and make CCtx ready to start a new one.
+ * Useful after an error, or to interrupt any ongoing compression.
+ * Any internal data not yet flushed is cancelled.
+ * Compression parameters and dictionary remain unchanged.
+ * They will be used to compress next frame.
+ * Resetting session never fails.
+ * - The parameters : changes all parameters back to "default".
+ * This removes any reference to any dictionary too.
+ * Parameters can only be changed between 2 sessions (i.e. no compression is currently ongoing)
+ * otherwise the reset fails, and function returns an error value (which can be tested using ZSTD_isError())
+ * - Both : similar to resetting the session, followed by resetting parameters.
+ */
+ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset);
+
+
+
+/*! ZSTD_compress2() :
+ * Behave the same as ZSTD_compressCCtx(), but compression parameters are set using the advanced API.
+ * ZSTD_compress2() always starts a new frame.
+ * Should cctx hold data from a previously unfinished frame, everything about it is forgotten.
+ * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()
+ * - The function is always blocking, returns when compression is completed.
+ * Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`.
+ * @return : compressed size written into `dst` (<= `dstCapacity),
+ * or an error code if it fails (which can be tested using ZSTD_isError()).
+ */
+ZSTDLIB_API size_t ZSTD_compress2( ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize);
+
+typedef enum {
+ ZSTD_e_continue=0, /* collect more data, encoder decides when to output compressed result, for optimal compression ratio */
+ ZSTD_e_flush=1, /* flush any data provided so far,
+ * it creates (at least) one new block, that can be decoded immediately on reception;
+ * frame will continue: any future data can still reference previously compressed data, improving compression. */
+ ZSTD_e_end=2 /* flush any remaining data _and_ close current frame.
+ * note that frame is only closed after compressed data is fully flushed (return value == 0).
+ * After that point, any additional data starts a new frame.
+ * note : each frame is independent (does not reference any content from previous frame). */
+} ZSTD_EndDirective;
+
+/*! ZSTD_compressStream2() :
+ * Behaves about the same as ZSTD_compressStream, with additional control on end directive.
+ * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()
+ * - Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode)
+ * - outpot->pos must be <= dstCapacity, input->pos must be <= srcSize
+ * - outpot->pos and input->pos will be updated. They are guaranteed to remain below their respective limit.
+ * - When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller.
+ * - When nbWorkers>=1, function is non-blocking : it just acquires a copy of input, and distributes jobs to internal worker threads, flush whatever is available,
+ * and then immediately returns, just indicating that there is some data remaining to be flushed.
+ * The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte.
+ * - Exception : if the first call requests a ZSTD_e_end directive and provides enough dstCapacity, the function delegates to ZSTD_compress2() which is always blocking.
+ * - @return provides a minimum amount of data remaining to be flushed from internal buffers
+ * or an error code, which can be tested using ZSTD_isError().
+ * if @return != 0, flush is not fully completed, there is still some data left within internal buffers.
+ * This is useful for ZSTD_e_flush, since in this case more flushes are necessary to empty all buffers.
+ * For ZSTD_e_end, @return == 0 when internal buffers are fully flushed and frame is completed.
+ * - after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0),
+ * only ZSTD_e_end or ZSTD_e_flush operations are allowed.
+ * Before starting a new compression job, or changing compression parameters,
+ * it is required to fully flush internal buffers.
+ */
+ZSTDLIB_API size_t ZSTD_compressStream2( ZSTD_CCtx* cctx,
+ ZSTD_outBuffer* output,
+ ZSTD_inBuffer* input,
+ ZSTD_EndDirective endOp);
+
+
+
+/* ============================== */
+/* Advanced decompression API */
+/* ============================== */
+
+/* The advanced API pushes parameters one by one into an existing DCtx context.
+ * Parameters are sticky, and remain valid for all following frames
+ * using the same DCtx context.
+ * It's possible to reset parameters to default values using ZSTD_DCtx_reset().
+ * Note : This API is compatible with existing ZSTD_decompressDCtx() and ZSTD_decompressStream().
+ * Therefore, no new decompression function is necessary.
+ */
+
+
+typedef enum {
+
+ ZSTD_d_windowLogMax=100, /* Select a size limit (in power of 2) beyond which
+ * the streaming API will refuse to allocate memory buffer
+ * in order to protect the host from unreasonable memory requirements.
+ * This parameter is only useful in streaming mode, since no internal buffer is allocated in single-pass mode.
+ * By default, a decompression context accepts window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT) */
+
+ /* note : additional experimental parameters are also available
+ * within the experimental section of the API.
+ * At the time of this writing, they include :
+ * ZSTD_c_format
+ * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
+ * note : never ever use experimentalParam? names directly
+ */
+ ZSTD_d_experimentalParam1=1000
+
+} ZSTD_dParameter;
+
+
+/*! ZSTD_dParam_getBounds() :
+ * All parameters must belong to an interval with lower and upper bounds,
+ * otherwise they will either trigger an error or be automatically clamped.
+ * @return : a structure, ZSTD_bounds, which contains
+ * - an error status field, which must be tested using ZSTD_isError()
+ * - both lower and upper bounds, inclusive
+ */
+ZSTDLIB_API ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam);
+
+/*! ZSTD_DCtx_setParameter() :
+ * Set one compression parameter, selected by enum ZSTD_dParameter.
+ * All parameters have valid bounds. Bounds can be queried using ZSTD_dParam_getBounds().
+ * Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter).
+ * Setting a parameter is only possible during frame initialization (before starting decompression).
+ * @return : 0, or an error code (which can be tested using ZSTD_isError()).
+ */
+ZSTDLIB_API size_t ZSTD_DCtx_setParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int value);
+
+
+/*! ZSTD_DCtx_loadDictionary() :
+ * Create an internal DDict from dict buffer,
+ * to be used to decompress next frames.
+ * The dictionary remains valid for all future frames, until explicitly invalidated.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Special : Adding a NULL (or 0-size) dictionary invalidates any previous dictionary,
+ * meaning "return to no-dictionary mode".
+ * Note 1 : Loading a dictionary involves building tables,
+ * which has a non-negligible impact on CPU usage and latency.
+ * It's recommended to "load once, use many times", to amortize the cost
+ * Note 2 :`dict` content will be copied internally, so `dict` can be released after loading.
+ * Use ZSTD_DCtx_loadDictionary_byReference() to reference dictionary content instead.
+ * Note 3 : Use ZSTD_DCtx_loadDictionary_advanced() to take control of
+ * how dictionary content is loaded and interpreted.
+ */
+ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
+
+/*! ZSTD_DCtx_refDDict() :
+ * Reference a prepared dictionary, to be used to decompress next frames.
+ * The dictionary remains active for decompression of future frames using same DCtx.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Note 1 : Currently, only one dictionary can be managed.
+ * Referencing a new dictionary effectively "discards" any previous one.
+ * Special: referencing a NULL DDict means "return to no-dictionary mode".
+ * Note 2 : DDict is just referenced, its lifetime must outlive its usage from DCtx.
+ */
+ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
+
+/*! ZSTD_DCtx_refPrefix() :
+ * Reference a prefix (single-usage dictionary) to decompress next frame.
+ * This is the reverse operation of ZSTD_CCtx_refPrefix(),
+ * and must use the same prefix as the one used during compression.
+ * Prefix is **only used once**. Reference is discarded at end of frame.
+ * End of frame is reached when ZSTD_decompressStream() returns 0.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ * Note 1 : Adding any prefix (including NULL) invalidates any previously set prefix or dictionary
+ * Note 2 : Prefix buffer is referenced. It **must** outlive decompression.
+ * Prefix buffer must remain unmodified up to the end of frame,
+ * reached when ZSTD_decompressStream() returns 0.
+ * Note 3 : By default, the prefix is treated as raw content (ZSTD_dm_rawContent).
+ * Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode (Experimental section)
+ * Note 4 : Referencing a raw content prefix has almost no cpu nor memory cost.
+ * A full dictionary is more costly, as it requires building tables.
+ */
+ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx,
+ const void* prefix, size_t prefixSize);
+
+/*! ZSTD_DCtx_reset() :
+ * Return a DCtx to clean state.
+ * Session and parameters can be reset jointly or separately.
+ * Parameters can only be reset when no active frame is being decompressed.
+ * @return : 0, or an error code, which can be tested with ZSTD_isError()
+ */
+ZSTDLIB_API size_t ZSTD_DCtx_reset(ZSTD_DCtx* dctx, ZSTD_ResetDirective reset);
+
+
+
+/****************************************************************************************
+ * experimental API (static linking only)
+ ****************************************************************************************
+ * The following symbols and constants
+ * are not planned to join "stable API" status in the near future.
+ * They can still change in future versions.
+ * Some of them are planned to remain in the static_only section indefinitely.
+ * Some of them might be removed in the future (especially when redundant with existing stable functions)
+ * ***************************************************************************************/
+
+#define ZSTD_FRAMEHEADERSIZE_PREFIX 5 /* minimum input size required to query frame header size */
+#define ZSTD_FRAMEHEADERSIZE_MIN 6
+#define ZSTD_FRAMEHEADERSIZE_MAX 18 /* can be useful for static allocation */
+#define ZSTD_SKIPPABLEHEADERSIZE 8
+
+/* compression parameter bounds */
+#define ZSTD_WINDOWLOG_MAX_32 30
+#define ZSTD_WINDOWLOG_MAX_64 31
+#define ZSTD_WINDOWLOG_MAX ((int)(sizeof(size_t) == 4 ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64))
+#define ZSTD_WINDOWLOG_MIN 10
+#define ZSTD_HASHLOG_MAX ((ZSTD_WINDOWLOG_MAX < 30) ? ZSTD_WINDOWLOG_MAX : 30)
+#define ZSTD_HASHLOG_MIN 6
+#define ZSTD_CHAINLOG_MAX_32 29
+#define ZSTD_CHAINLOG_MAX_64 30
+#define ZSTD_CHAINLOG_MAX ((int)(sizeof(size_t) == 4 ? ZSTD_CHAINLOG_MAX_32 : ZSTD_CHAINLOG_MAX_64))
+#define ZSTD_CHAINLOG_MIN ZSTD_HASHLOG_MIN
+#define ZSTD_SEARCHLOG_MAX (ZSTD_WINDOWLOG_MAX-1)
+#define ZSTD_SEARCHLOG_MIN 1
+#define ZSTD_MINMATCH_MAX 7 /* only for ZSTD_fast, other strategies are limited to 6 */
+#define ZSTD_MINMATCH_MIN 3 /* only for ZSTD_btopt+, faster strategies are limited to 4 */
+#define ZSTD_TARGETLENGTH_MAX ZSTD_BLOCKSIZE_MAX
+#define ZSTD_TARGETLENGTH_MIN 0 /* note : comparing this constant to an unsigned results in a tautological test */
+#define ZSTD_STRATEGY_MIN ZSTD_fast
+#define ZSTD_STRATEGY_MAX ZSTD_btultra2
+
+
+#define ZSTD_OVERLAPLOG_MIN 0
+#define ZSTD_OVERLAPLOG_MAX 9
+
+#define ZSTD_WINDOWLOG_LIMIT_DEFAULT 27 /* by default, the streaming decoder will refuse any frame
+ * requiring larger than (1<<ZSTD_WINDOWLOG_LIMIT_DEFAULT) window size,
+ * to preserve host's memory from unreasonable requirements.
+ * This limit can be overriden using ZSTD_DCtx_setParameter(,ZSTD_d_windowLogMax,).
+ * The limit does not apply for one-pass decoders (such as ZSTD_decompress()), since no additional memory is allocated */
+
+
+/* LDM parameter bounds */
+#define ZSTD_LDM_HASHLOG_MIN ZSTD_HASHLOG_MIN
+#define ZSTD_LDM_HASHLOG_MAX ZSTD_HASHLOG_MAX
+#define ZSTD_LDM_MINMATCH_MIN 4
+#define ZSTD_LDM_MINMATCH_MAX 4096
+#define ZSTD_LDM_BUCKETSIZELOG_MIN 1
+#define ZSTD_LDM_BUCKETSIZELOG_MAX 8
+#define ZSTD_LDM_HASHRATELOG_MIN 0
+#define ZSTD_LDM_HASHRATELOG_MAX (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN)
+
+/* internal */
+#define ZSTD_HASHLOG3_MAX 17
+
+
+/* --- Advanced types --- */
+
+typedef struct ZSTD_CCtx_params_s ZSTD_CCtx_params;
+
+typedef struct {
+ unsigned windowLog; /**< largest match distance : larger == more compression, more memory needed during decompression */
+ unsigned chainLog; /**< fully searched segment : larger == more compression, slower, more memory (useless for fast) */
+ unsigned hashLog; /**< dispatch table : larger == faster, more memory */
+ unsigned searchLog; /**< nb of searches : larger == more compression, slower */
+ unsigned minMatch; /**< match length searched : larger == faster decompression, sometimes less compression */
+ unsigned targetLength; /**< acceptable match size for optimal parser (only) : larger == more compression, slower */
+ ZSTD_strategy strategy; /**< see ZSTD_strategy definition above */
+} ZSTD_compressionParameters;
+
+typedef struct {
+ int contentSizeFlag; /**< 1: content size will be in frame header (when known) */
+ int checksumFlag; /**< 1: generate a 32-bits checksum using XXH64 algorithm at end of frame, for error detection */
+ int noDictIDFlag; /**< 1: no dictID will be saved into frame header (dictID is only useful for dictionary compression) */
+} ZSTD_frameParameters;
+
+typedef struct {
+ ZSTD_compressionParameters cParams;
+ ZSTD_frameParameters fParams;
+} ZSTD_parameters;
+
+typedef enum {
+ ZSTD_dct_auto = 0, /* dictionary is "full" when starting with ZSTD_MAGIC_DICTIONARY, otherwise it is "rawContent" */
+ ZSTD_dct_rawContent = 1, /* ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY */
+ ZSTD_dct_fullDict = 2 /* refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY */
+} ZSTD_dictContentType_e;
+
+typedef enum {
+ ZSTD_dlm_byCopy = 0, /**< Copy dictionary content internally */
+ ZSTD_dlm_byRef = 1, /**< Reference dictionary content -- the dictionary buffer must outlive its users. */
+} ZSTD_dictLoadMethod_e;
+
+typedef enum {
+ /* Opened question : should we have a format ZSTD_f_auto ?
+ * Today, it would mean exactly the same as ZSTD_f_zstd1.
+ * But, in the future, should several formats become supported,
+ * on the compression side, it would mean "default format".
+ * On the decompression side, it would mean "automatic format detection",
+ * so that ZSTD_f_zstd1 would mean "accept *only* zstd frames".
+ * Since meaning is a little different, another option could be to define different enums for compression and decompression.
+ * This question could be kept for later, when there are actually multiple formats to support,
+ * but there is also the question of pinning enum values, and pinning value `0` is especially important */
+ ZSTD_f_zstd1 = 0, /* zstd frame format, specified in zstd_compression_format.md (default) */
+ ZSTD_f_zstd1_magicless = 1, /* Variant of zstd frame format, without initial 4-bytes magic number.
+ * Useful to save 4 bytes per generated frame.
+ * Decoder cannot recognise automatically this format, requiring this instruction. */
+} ZSTD_format_e;
+
+typedef enum {
+ /* Note: this enum and the behavior it controls are effectively internal
+ * implementation details of the compressor. They are expected to continue
+ * to evolve and should be considered only in the context of extremely
+ * advanced performance tuning.
+ *
+ * Zstd currently supports the use of a CDict in two ways:
+ *
+ * - The contents of the CDict can be copied into the working context. This
+ * means that the compression can search both the dictionary and input
+ * while operating on a single set of internal tables. This makes
+ * the compression faster per-byte of input. However, the initial copy of
+ * the CDict's tables incurs a fixed cost at the beginning of the
+ * compression. For small compressions (< 8 KB), that copy can dominate
+ * the cost of the compression.
+ *
+ * - The CDict's tables can be used in-place. In this model, compression is
+ * slower per input byte, because the compressor has to search two sets of
+ * tables. However, this model incurs no start-up cost (as long as the
+ * working context's tables can be reused). For small inputs, this can be
+ * faster than copying the CDict's tables.
+ *
+ * Zstd has a simple internal heuristic that selects which strategy to use
+ * at the beginning of a compression. However, if experimentation shows that
+ * Zstd is making poor choices, it is possible to override that choice with
+ * this enum.
+ */
+ ZSTD_dictDefaultAttach = 0, /* Use the default heuristic. */
+ ZSTD_dictForceAttach = 1, /* Never copy the dictionary. */
+ ZSTD_dictForceCopy = 2, /* Always copy the dictionary. */
+} ZSTD_dictAttachPref_e;
+
+
+/***************************************
+* Frame size functions
+***************************************/
+
+/*! ZSTD_findDecompressedSize() :
+ * `src` should point the start of a series of ZSTD encoded and/or skippable frames
+ * `srcSize` must be the _exact_ size of this series
+ * (i.e. there should be a frame boundary exactly at `srcSize` bytes after `src`)
+ * @return : - decompressed size of all data in all successive frames
+ * - if the decompressed size cannot be determined: ZSTD_CONTENTSIZE_UNKNOWN
+ * - if an error occurred: ZSTD_CONTENTSIZE_ERROR
+ *
+ * note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode.
+ * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size.
+ * In which case, it's necessary to use streaming mode to decompress data.
+ * note 2 : decompressed size is always present when compression is done with ZSTD_compress()
+ * note 3 : decompressed size can be very large (64-bits value),
+ * potentially larger than what local system can handle as a single memory segment.
+ * In which case, it's necessary to use streaming mode to decompress data.
+ * note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified.
+ * Always ensure result fits within application's authorized limits.
+ * Each application can set its own limits.
+ * note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to
+ * read each contained frame header. This is fast as most of the data is skipped,
+ * however it does mean that all frame data must be present and valid. */
+ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize);
+
+/*! ZSTD_frameHeaderSize() :
+ * srcSize must be >= ZSTD_FRAMEHEADERSIZE_PREFIX.
+ * @return : size of the Frame Header,
+ * or an error code (if srcSize is too small) */
+ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize);
+
+
+/***************************************
+* Memory management
+***************************************/
+
+/*! ZSTD_estimate*() :
+ * These functions make it possible to estimate memory usage
+ * of a future {D,C}Ctx, before its creation.
+ * ZSTD_estimateCCtxSize() will provide a budget large enough for any compression level up to selected one.
+ * It will also consider src size to be arbitrarily "large", which is worst case.
+ * If srcSize is known to always be small, ZSTD_estimateCCtxSize_usingCParams() can provide a tighter estimation.
+ * ZSTD_estimateCCtxSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
+ * ZSTD_estimateCCtxSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_c_nbWorkers is >= 1.
+ * Note : CCtx size estimation is only correct for single-threaded compression. */
+ZSTDLIB_API size_t ZSTD_estimateCCtxSize(int compressionLevel);
+ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams);
+ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params);
+ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void);
+
+/*! ZSTD_estimateCStreamSize() :
+ * ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one.
+ * It will also consider src size to be arbitrarily "large", which is worst case.
+ * If srcSize is known to always be small, ZSTD_estimateCStreamSize_usingCParams() can provide a tighter estimation.
+ * ZSTD_estimateCStreamSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel.
+ * ZSTD_estimateCStreamSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParam_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_c_nbWorkers is >= 1.
+ * Note : CStream size estimation is only correct for single-threaded compression.
+ * ZSTD_DStream memory budget depends on window Size.
+ * This information can be passed manually, using ZSTD_estimateDStreamSize,
+ * or deducted from a valid frame Header, using ZSTD_estimateDStreamSize_fromFrame();
+ * Note : if streaming is init with function ZSTD_init?Stream_usingDict(),
+ * an internal ?Dict will be created, which additional size is not estimated here.
+ * In this case, get total size by adding ZSTD_estimate?DictSize */
+ZSTDLIB_API size_t ZSTD_estimateCStreamSize(int compressionLevel);
+ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams);
+ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params);
+ZSTDLIB_API size_t ZSTD_estimateDStreamSize(size_t windowSize);
+ZSTDLIB_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize);
+
+/*! ZSTD_estimate?DictSize() :
+ * ZSTD_estimateCDictSize() will bet that src size is relatively "small", and content is copied, like ZSTD_createCDict().
+ * ZSTD_estimateCDictSize_advanced() makes it possible to control compression parameters precisely, like ZSTD_createCDict_advanced().
+ * Note : dictionaries created by reference (`ZSTD_dlm_byRef`) are logically smaller.
+ */
+ZSTDLIB_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel);
+ZSTDLIB_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_dictLoadMethod_e dictLoadMethod);
+ZSTDLIB_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod);
+
+/*! ZSTD_initStatic*() :
+ * Initialize an object using a pre-allocated fixed-size buffer.
+ * workspace: The memory area to emplace the object into.
+ * Provided pointer *must be 8-bytes aligned*.
+ * Buffer must outlive object.
+ * workspaceSize: Use ZSTD_estimate*Size() to determine
+ * how large workspace must be to support target scenario.
+ * @return : pointer to object (same address as workspace, just different type),
+ * or NULL if error (size too small, incorrect alignment, etc.)
+ * Note : zstd will never resize nor malloc() when using a static buffer.
+ * If the object requires more memory than available,
+ * zstd will just error out (typically ZSTD_error_memory_allocation).
+ * Note 2 : there is no corresponding "free" function.
+ * Since workspace is allocated externally, it must be freed externally too.
+ * Note 3 : cParams : use ZSTD_getCParams() to convert a compression level
+ * into its associated cParams.
+ * Limitation 1 : currently not compatible with internal dictionary creation, triggered by
+ * ZSTD_CCtx_loadDictionary(), ZSTD_initCStream_usingDict() or ZSTD_initDStream_usingDict().
+ * Limitation 2 : static cctx currently not compatible with multi-threading.
+ * Limitation 3 : static dctx is incompatible with legacy support.
+ */
+ZSTDLIB_API ZSTD_CCtx* ZSTD_initStaticCCtx(void* workspace, size_t workspaceSize);
+ZSTDLIB_API ZSTD_CStream* ZSTD_initStaticCStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticCCtx() */
+
+ZSTDLIB_API ZSTD_DCtx* ZSTD_initStaticDCtx(void* workspace, size_t workspaceSize);
+ZSTDLIB_API ZSTD_DStream* ZSTD_initStaticDStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticDCtx() */
+
+ZSTDLIB_API const ZSTD_CDict* ZSTD_initStaticCDict(
+ void* workspace, size_t workspaceSize,
+ const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_compressionParameters cParams);
+
+ZSTDLIB_API const ZSTD_DDict* ZSTD_initStaticDDict(
+ void* workspace, size_t workspaceSize,
+ const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType);
+
+
+/*! Custom memory allocation :
+ * These prototypes make it possible to pass your own allocation/free functions.
+ * ZSTD_customMem is provided at creation time, using ZSTD_create*_advanced() variants listed below.
+ * All allocation/free operations will be completed using these custom variants instead of regular <stdlib.h> ones.
+ */
+typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size);
+typedef void (*ZSTD_freeFunction) (void* opaque, void* address);
+typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem;
+static ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */
+
+ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem);
+ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem);
+ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem);
+ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem);
+
+ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_compressionParameters cParams,
+ ZSTD_customMem customMem);
+
+ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize,
+ ZSTD_dictLoadMethod_e dictLoadMethod,
+ ZSTD_dictContentType_e dictContentType,
+ ZSTD_customMem customMem);
+
+
+
+/***************************************
+* Advanced compression functions
+***************************************/
+
+/*! ZSTD_createCDict_byReference() :
+ * Create a digested dictionary for compression
+ * Dictionary content is just referenced, not duplicated.
+ * As a consequence, `dictBuffer` **must** outlive CDict,
+ * and its content must remain unmodified throughout the lifetime of CDict. */
+ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel);
+
+/*! ZSTD_getCParams() :
+* @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize.
+* `estimatedSrcSize` value is optional, select 0 if not known */
+ZSTDLIB_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
+
+/*! ZSTD_getParams() :
+* same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of sub-component `ZSTD_compressionParameters`.
+* All fields of `ZSTD_frameParameters` are set to default : contentSize=1, checksum=0, noDictID=0 */
+ZSTDLIB_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize);
+
+/*! ZSTD_checkCParams() :
+* Ensure param values remain within authorized range */
+ZSTDLIB_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params);
+
+/*! ZSTD_adjustCParams() :
+ * optimize params for a given `srcSize` and `dictSize`.
+ * both values are optional, select `0` if unknown. */
+ZSTDLIB_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize);
+
+/*! ZSTD_compress_advanced() :
+ * Same as ZSTD_compress_usingDict(), with fine-tune control over compression parameters (by structure) */
+ZSTDLIB_API size_t ZSTD_compress_advanced(ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const void* dict,size_t dictSize,
+ ZSTD_parameters params);
+
+/*! ZSTD_compress_usingCDict_advanced() :
+ * Same as ZSTD_compress_usingCDict(), with fine-tune control over frame parameters */
+ZSTDLIB_API size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity,
+ const void* src, size_t srcSize,
+ const ZSTD_CDict* cdict,
+ ZSTD_frameParameters fParams);
+
+
+/*! ZSTD_CCtx_loadDictionary_byReference() :
+ * Same as ZSTD_CCtx_loadDictionary(), but dictionary content is referenced, instead of being copied into CCtx.
+ * It saves some memory, but also requires that `dict` outlives its usage within `cctx` */
+ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx* cctx, const void* dict, size_t dictSize);
+
+/*! ZSTD_CCtx_loadDictionary_advanced() :
+ * Same as ZSTD_CCtx_loadDictionary(), but gives finer control over
+ * how to load the dictionary (by copy ? by reference ?)
+ * and how to interpret it (automatic ? force raw mode ? full mode only ?) */
+ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
+
+/*! ZSTD_CCtx_refPrefix_advanced() :
+ * Same as ZSTD_CCtx_refPrefix(), but gives finer control over
+ * how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) */
+ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
+
+/* === experimental parameters === */
+/* these parameters can be used with ZSTD_setParameter()
+ * they are not guaranteed to remain supported in the future */
+
+ /* Enables rsyncable mode,
+ * which makes compressed files more rsync friendly
+ * by adding periodic synchronization points to the compressed data.
+ * The target average block size is ZSTD_c_jobSize / 2.
+ * It's possible to modify the job size to increase or decrease
+ * the granularity of the synchronization point.
+ * Once the jobSize is smaller than the window size,
+ * it will result in compression ratio degradation.
+ * NOTE 1: rsyncable mode only works when multithreading is enabled.
+ * NOTE 2: rsyncable performs poorly in combination with long range mode,
+ * since it will decrease the effectiveness of synchronization points,
+ * though mileage may vary.
+ * NOTE 3: Rsyncable mode limits maximum compression speed to ~400 MB/s.
+ * If the selected compression level is already running significantly slower,
+ * the overall speed won't be significantly impacted.
+ */
+ #define ZSTD_c_rsyncable ZSTD_c_experimentalParam1
+
+/* Select a compression format.
+ * The value must be of type ZSTD_format_e.
+ * See ZSTD_format_e enum definition for details */
+#define ZSTD_c_format ZSTD_c_experimentalParam2
+
+/* Force back-reference distances to remain < windowSize,
+ * even when referencing into Dictionary content (default:0) */
+#define ZSTD_c_forceMaxWindow ZSTD_c_experimentalParam3
+
+/* Controls whether the contents of a CDict
+ * are used in place, or copied into the working context.
+ * Accepts values from the ZSTD_dictAttachPref_e enum.
+ * See the comments on that enum for an explanation of the feature. */
+#define ZSTD_c_forceAttachDict ZSTD_c_experimentalParam4
+
+/*! ZSTD_CCtx_getParameter() :
+ * Get the requested compression parameter value, selected by enum ZSTD_cParameter,
+ * and store it into int* value.
+ * @return : 0, or an error code (which can be tested with ZSTD_isError()).
+ */
+ZSTDLIB_API size_t ZSTD_CCtx_getParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int* value);
+
+
+/*! ZSTD_CCtx_params :
+ * Quick howto :
+ * - ZSTD_createCCtxParams() : Create a ZSTD_CCtx_params structure
+ * - ZSTD_CCtxParam_setParameter() : Push parameters one by one into
+ * an existing ZSTD_CCtx_params structure.
+ * This is similar to
+ * ZSTD_CCtx_setParameter().
+ * - ZSTD_CCtx_setParametersUsingCCtxParams() : Apply parameters to
+ * an existing CCtx.
+ * These parameters will be applied to
+ * all subsequent frames.
+ * - ZSTD_compressStream2() : Do compression using the CCtx.
+ * - ZSTD_freeCCtxParams() : Free the memory.
+ *
+ * This can be used with ZSTD_estimateCCtxSize_advanced_usingCCtxParams()
+ * for static allocation of CCtx for single-threaded compression.
+ */
+ZSTDLIB_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void);
+ZSTDLIB_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params);
+
+/*! ZSTD_CCtxParams_reset() :
+ * Reset params to default values.
+ */
+ZSTDLIB_API size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params* params);
+
+/*! ZSTD_CCtxParams_init() :
+ * Initializes the compression parameters of cctxParams according to
+ * compression level. All other parameters are reset to their default values.
+ */
+ZSTDLIB_API size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compressionLevel);
+
+/*! ZSTD_CCtxParams_init_advanced() :
+ * Initializes the compression and frame parameters of cctxParams according to
+ * params. All other parameters are reset to their default values.
+ */
+ZSTDLIB_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params);
+
+/*! ZSTD_CCtxParam_setParameter() :
+ * Similar to ZSTD_CCtx_setParameter.
+ * Set one compression parameter, selected by enum ZSTD_cParameter.
+ * Parameters must be applied to a ZSTD_CCtx using ZSTD_CCtx_setParametersUsingCCtxParams().
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ */
+ZSTDLIB_API size_t ZSTD_CCtxParam_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int value);
+
+/*! ZSTD_CCtxParam_getParameter() :
+ * Similar to ZSTD_CCtx_getParameter.
+ * Get the requested value of one compression parameter, selected by enum ZSTD_cParameter.
+ * @result : 0, or an error code (which can be tested with ZSTD_isError()).
+ */
+ZSTDLIB_API size_t ZSTD_CCtxParam_getParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int* value);
+
+/*! ZSTD_CCtx_setParametersUsingCCtxParams() :
+ * Apply a set of ZSTD_CCtx_params to the compression context.
+ * This can be done even after compression is started,
+ * if nbWorkers==0, this will have no impact until a new compression is started.
+ * if nbWorkers>=1, new parameters will be picked up at next job,
+ * with a few restrictions (windowLog, pledgedSrcSize, nbWorkers, jobSize, and overlapLog are not updated).
+ */
+ZSTDLIB_API size_t ZSTD_CCtx_setParametersUsingCCtxParams(
+ ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params);
+
+/*! ZSTD_compressStream2_simpleArgs() :
+ * Same as ZSTD_compressStream2(),
+ * but using only integral types as arguments.
+ * This variant might be helpful for binders from dynamic languages
+ * which have troubles handling structures containing memory pointers.
+ */
+ZSTDLIB_API size_t ZSTD_compressStream2_simpleArgs (
+ ZSTD_CCtx* cctx,
+ void* dst, size_t dstCapacity, size_t* dstPos,
+ const void* src, size_t srcSize, size_t* srcPos,
+ ZSTD_EndDirective endOp);
+
+
+/***************************************
+* Advanced decompression functions
+***************************************/
+
+/*! ZSTD_isFrame() :
+ * Tells if the content of `buffer` starts with a valid Frame Identifier.
+ * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0.
+ * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled.
+ * Note 3 : Skippable Frame Identifiers are considered valid. */
+ZSTDLIB_API unsigned ZSTD_isFrame(const void* buffer, size_t size);
+
+/*! ZSTD_createDDict_byReference() :
+ * Create a digested dictionary, ready to start decompression operation without startup delay.
+ * Dictionary content is referenced, and therefore stays in dictBuffer.
+ * It is important that dictBuffer outlives DDict,
+ * it must remain read accessible throughout the lifetime of DDict */
+ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize);
+
+
+/*! ZSTD_getDictID_fromDict() :
+ * Provides the dictID stored within dictionary.
+ * if @return == 0, the dictionary is not conformant with Zstandard specification.
+ * It can still be loaded, but as a content-only dictionary. */
+ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize);
+
+/*! ZSTD_getDictID_fromDDict() :
+ * Provides the dictID of the dictionary loaded into `ddict`.
+ * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty.
+ * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */
+ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict);
+
+/*! ZSTD_getDictID_fromFrame() :
+ * Provides the dictID required to decompressed the frame stored within `src`.
+ * If @return == 0, the dictID could not be decoded.
+ * This could for one of the following reasons :
+ * - The frame does not require a dictionary to be decoded (most common case).
+ * - The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden information.
+ * Note : this use case also happens when using a non-conformant dictionary.
+ * - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`).
+ * - This is not a Zstandard frame.
+ * When identifying the exact failure cause, it's possible to use ZSTD_getFrameHeader(), which will provide a more precise error code. */
+ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize);
+
+/*! ZSTD_DCtx_loadDictionary_byReference() :
+ * Same as ZSTD_DCtx_loadDictionary(),
+ * but references `dict` content instead of copying it into `dctx`.
+ * This saves memory if `dict` remains around.,
+ * However, it's imperative that `dict` remains accessible (and unmodified) while being used, so it must outlive decompression. */
+ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
+
+/*! ZSTD_DCtx_loadDictionary_advanced() :
+ * Same as ZSTD_DCtx_loadDictionary(),
+ * but gives direct control over
+ * how to load the dictionary (by copy ? by reference ?)
+ * and how to interpret it (automatic ? force raw mode ? full mode only ?). */
+ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType);
+
+/*! ZSTD_DCtx_refPrefix_advanced() :
+ * Same as ZSTD_DCtx_refPrefix(), but gives finer control over
+ * how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) */
+ZSTDLIB_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType);
+
+/*! ZSTD_DCtx_setMaxWindowSize() :
+ * Refuses allocating internal buffers for frames requiring a window size larger than provided limit.
+ * This protects a decoder context from reserving too much memory for itself (potential attack scenario).
+ * This parameter is only useful in streaming mode, since no internal buffer is allocated in single-pass mode.
+ * By default, a decompression context accepts all window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT)
+ * @return : 0, or an error code (which can be tested using ZSTD_isError()).
+ */
+ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize);
+
+/* ZSTD_d_format
+ * experimental parameter,
+ * allowing selection between ZSTD_format_e input compression formats
+ */
+#define ZSTD_d_format ZSTD_d_experimentalParam1
+
+/*! ZSTD_DCtx_setFormat() :
+ * Instruct the decoder context about what kind of data to decode next.
+ * This instruction is mandatory to decode data without a fully-formed header,
+ * such ZSTD_f_zstd1_magicless for example.
+ * @return : 0, or an error code (which can be tested using ZSTD_isError()). */
+ZSTDLIB_API size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format);
+
+/*! ZSTD_decompressStream_simpleArgs() :
+ * Same as ZSTD_decompressStream(),
+ * but using only integral types as arguments.
+ * This can be helpful for binders from dynamic languages
+ * which have troubles handling structures containing memory pointers.
+ */
+ZSTDLIB_API size_t ZSTD_decompressStream_simpleArgs (
+ ZSTD_DCtx* dctx,
+ void* dst, size_t dstCapacity, size_t* dstPos,
+ const void* src, size_t srcSize, size_t* srcPos);
+
+
+/********************************************************************
+* Advanced streaming functions
+* Warning : most of these functions are now redundant with the Advanced API.
+* Once Advanced API reaches "stable" status,
+* redundant functions will be deprecated, and then at some point removed.
+********************************************************************/
+
+/*===== Advanced Streaming compression functions =====*/
+ZSTDLIB_API size_t ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, int compressionLevel, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct. If it is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN. Note that, for compatibility with older programs, "0" also disables frame content size field. It may be enabled in the future. */
+ZSTDLIB_API size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel); /**< creates of an internal CDict (incompatible with static CCtx), except if dict == NULL or dictSize < 8, in which case no dict is used. Note: dict is loaded with ZSTD_dm_auto (treated as a full zstd dictionary if it begins with ZSTD_MAGIC_DICTIONARY, else as raw content) and ZSTD_dlm_byCopy.*/
+ZSTDLIB_API size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize,
+ ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize must be correct. If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. dict is loaded with ZSTD_dm_auto and ZSTD_dlm_byCopy. */
+ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); /**< note : cdict will just be referenced, and must outlive compression session */
+ZSTDLIB_API size_t ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, const ZSTD_CDict* cdict, ZSTD_frameParameters fParams, unsigned long long pledgedSrcSize); /**< same as ZSTD_initCStream_usingCDict(), with control over frame parameters. pledgedSrcSize must be correct. If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. */
+
+/*! ZSTD_resetCStream() :
+ * start a new frame, using same parameters from previous frame.
+ * This is typically useful to skip dictionary loading stage, since it will re-use it in-place.
+ * Note that zcs must be init at least once before using ZSTD_resetCStream().
+ * If pledgedSrcSize is not known at reset time, use macro ZSTD_CONTENTSIZE_UNKNOWN.
+ * If pledgedSrcSize > 0, its value must be correct, as it will be written in header, and controlled at the end.
+ * For the time being, pledgedSrcSize==0 is interpreted as "srcSize unknown" for compatibility with older programs,
+ * but it will change to mean "empty" in future version, so use macro ZSTD_CONTENTSIZE_UNKNOWN instead.
+ * @return : 0, or an error code (which can be tested using ZSTD_isError())
+ */
+ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize);
+
+
+typedef struct {
+ unsigned long long ingested; /* nb input bytes read and buffered */
+ unsigned long long consumed; /* nb input bytes actually compressed */
+ unsigned long long produced; /* nb of compressed bytes generated and buffered */
+ unsigned long long flushed; /* nb of compressed bytes flushed : not provided; can be tracked from caller side */
+ unsigned currentJobID; /* MT only : latest started job nb */
+ unsigned nbActiveWorkers; /* MT only : nb of workers actively compressing at probe time */
+} ZSTD_frameProgression;
+
+/* ZSTD_getFrameProgression() :
+ * tells how much data has been ingested (read from input)
+ * consumed (input actually compressed) and produced (output) for current frame.
+ * Note : (ingested - consumed) is amount of input data buffered internally, not yet compressed.
+ * Aggregates progression inside active worker threads.
+ */
+ZSTDLIB_API ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx);
+
+/*! ZSTD_toFlushNow() :
+ * Tell how many bytes are ready to be flushed immediately.
+ * Useful for multithreading scenarios (nbWorkers >= 1).
+ * Probe the oldest active job, defined as oldest job not yet entirely flushed,
+ * and check its output buffer.
+ * @return : amount of data stored in oldest job and ready to be flushed immediately.
+ * if @return == 0, it means either :
+ * + there is no active job (could be checked with ZSTD_frameProgression()), or
+ * + oldest job is still actively compressing data,
+ * but everything it has produced has also been flushed so far,
+ * therefore flush speed is limited by production speed of oldest job
+ * irrespective of the speed of concurrent (and newer) jobs.
+ */
+ZSTDLIB_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
+
+
+/*===== Advanced Streaming decompression functions =====*/
+ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize); /**< note: no dictionary will be used if dict == NULL or dictSize < 8 */
+ZSTDLIB_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict); /**< note : ddict is referenced, it must outlive decompression session */
+ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); /**< re-use decompression parameters from previous init; saves dictionary loading */
+
+
+/*********************************************************************
+* Buffer-less and synchronous inner streaming functions
+*
+* This is an advanced API, giving full control over buffer management, for users which need direct control over memory.
+* But it's also a complex one, with several restrictions, documented below.
+* Prefer normal streaming API for an easier experience.
+********************************************************************* */
+
+/**
+ Buffer-less streaming compression (synchronous mode)
+
+ A ZSTD_CCtx object is required to track streaming operations.
+ Use ZSTD_createCCtx() / ZSTD_freeCCtx() to manage resource.
+ ZSTD_CCtx object can be re-used multiple times within successive compression operations.
+
+ Start by initializing a context.
+ Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression,
+ or ZSTD_compressBegin_advanced(), for finer parameter control.
+ It's also possible to duplicate a reference context which has already been initialized, using ZSTD_copyCCtx()
+
+ Then, consume your input using ZSTD_compressContinue().
+ There are some important considerations to keep in mind when using this advanced function :
+ - ZSTD_compressContinue() has no internal buffer. It uses externally provided buffers only.
+ - Interface is synchronous : input is consumed entirely and produces 1+ compressed blocks.
+ - Caller must ensure there is enough space in `dst` to store compressed data under worst case scenario.
+ Worst case evaluation is provided by ZSTD_compressBound().
+ ZSTD_compressContinue() doesn't guarantee recover after a failed compression.
+ - ZSTD_compressContinue() presumes prior input ***is still accessible and unmodified*** (up to maximum distance size, see WindowLog).
+ It remembers all previous contiguous blocks, plus one separated memory segment (which can itself consists of multiple contiguous blocks)
+ - ZSTD_compressContinue() detects that prior input has been overwritten when `src` buffer overlaps.
+ In which case, it will "discard" the relevant memory section from its history.
+
+ Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum.
+ It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame.
+ Without last block mark, frames are considered unfinished (hence corrupted) by compliant decoders.
+
+ `ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress again.
+*/
+
+/*===== Buffer-less streaming compression functions =====*/
+ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel);
+ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel);
+ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize : If srcSize is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN */
+ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */
+ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict, ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize); /* compression parameters are already set within cdict. pledgedSrcSize must be correct. If srcSize is not known, use macro ZSTD_CONTENTSIZE_UNKNOWN */
+ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize is not known, use ZSTD_CONTENTSIZE_UNKNOWN */
+
+ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
+ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
+
+
+/*-
+ Buffer-less streaming decompression (synchronous mode)
+
+ A ZSTD_DCtx object is required to track streaming operations.
+ Use ZSTD_createDCtx() / ZSTD_freeDCtx() to manage it.
+ A ZSTD_DCtx object can be re-used multiple times.
+
+ First typical operation is to retrieve frame parameters, using ZSTD_getFrameHeader().
+ Frame header is extracted from the beginning of compressed frame, so providing only the frame's beginning is enough.
+ Data fragment must be large enough to ensure successful decoding.
+ `ZSTD_frameHeaderSize_max` bytes is guaranteed to always be large enough.
+ @result : 0 : successful decoding, the `ZSTD_frameHeader` structure is correctly filled.
+ >0 : `srcSize` is too small, please provide at least @result bytes on next attempt.
+ errorCode, which can be tested using ZSTD_isError().
+
+ It fills a ZSTD_frameHeader structure with important information to correctly decode the frame,
+ such as the dictionary ID, content size, or maximum back-reference distance (`windowSize`).
+ Note that these values could be wrong, either because of data corruption, or because a 3rd party deliberately spoofs false information.
+ As a consequence, check that values remain within valid application range.
+ For example, do not allocate memory blindly, check that `windowSize` is within expectation.
+ Each application can set its own limits, depending on local restrictions.
+ For extended interoperability, it is recommended to support `windowSize` of at least 8 MB.
+
+ ZSTD_decompressContinue() needs previous data blocks during decompression, up to `windowSize` bytes.
+ ZSTD_decompressContinue() is very sensitive to contiguity,
+ if 2 blocks don't follow each other, make sure that either the compressor breaks contiguity at the same place,
+ or that previous contiguous segment is large enough to properly handle maximum back-reference distance.
+ There are multiple ways to guarantee this condition.
+
+ The most memory efficient way is to use a round buffer of sufficient size.
+ Sufficient size is determined by invoking ZSTD_decodingBufferSize_min(),
+ which can @return an error code if required value is too large for current system (in 32-bits mode).
+ In a round buffer methodology, ZSTD_decompressContinue() decompresses each block next to previous one,
+ up to the moment there is not enough room left in the buffer to guarantee decoding another full block,
+ which maximum size is provided in `ZSTD_frameHeader` structure, field `blockSizeMax`.
+ At which point, decoding can resume from the beginning of the buffer.
+ Note that already decoded data stored in the buffer should be flushed before being overwritten.
+
+ There are alternatives possible, for example using two or more buffers of size `windowSize` each, though they consume more memory.
+
+ Finally, if you control the compression process, you can also ignore all buffer size rules,
+ as long as the encoder and decoder progress in "lock-step",
+ aka use exactly the same buffer sizes, break contiguity at the same place, etc.
+
+ Once buffers are setup, start decompression, with ZSTD_decompressBegin().
+ If decompression requires a dictionary, use ZSTD_decompressBegin_usingDict() or ZSTD_decompressBegin_usingDDict().
+
+ Then use ZSTD_nextSrcSizeToDecompress() and ZSTD_decompressContinue() alternatively.
+ ZSTD_nextSrcSizeToDecompress() tells how many bytes to provide as 'srcSize' to ZSTD_decompressContinue().
+ ZSTD_decompressContinue() requires this _exact_ amount of bytes, or it will fail.
+
+ @result of ZSTD_decompressContinue() is the number of bytes regenerated within 'dst' (necessarily <= dstCapacity).
+ It can be zero : it just means ZSTD_decompressContinue() has decoded some metadata item.
+ It can also be an error code, which can be tested with ZSTD_isError().
+
+ A frame is fully decoded when ZSTD_nextSrcSizeToDecompress() returns zero.
+ Context can then be reset to start a new decompression.
+
+ Note : it's possible to know if next input to present is a header or a block, using ZSTD_nextInputType().
+ This information is not required to properly decode a frame.
+
+ == Special case : skippable frames ==
+
+ Skippable frames allow integration of user-defined data into a flow of concatenated frames.
+ Skippable frames will be ignored (skipped) by decompressor.
+ The format of skippable frames is as follows :
+ a) Skippable frame ID - 4 Bytes, Little endian format, any value from 0x184D2A50 to 0x184D2A5F
+ b) Frame Size - 4 Bytes, Little endian format, unsigned 32-bits
+ c) Frame Content - any content (User Data) of length equal to Frame Size
+ For skippable frames ZSTD_getFrameHeader() returns zfhPtr->frameType==ZSTD_skippableFrame.
+ For skippable frames ZSTD_decompressContinue() always returns 0 : it only skips the content.
+*/
+
+/*===== Buffer-less streaming decompression functions =====*/
+typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_frameType_e;
+typedef struct {
+ unsigned long long frameContentSize; /* if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means "empty" */
+ unsigned long long windowSize; /* can be very large, up to <= frameContentSize */
+ unsigned blockSizeMax;
+ ZSTD_frameType_e frameType; /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */
+ unsigned headerSize;
+ unsigned dictID;
+ unsigned checksumFlag;
+} ZSTD_frameHeader;
+
+/** ZSTD_getFrameHeader() :
+ * decode Frame Header, or requires larger `srcSize`.
+ * @return : 0, `zfhPtr` is correctly filled,
+ * >0, `srcSize` is too small, value is wanted `srcSize` amount,
+ * or an error code, which can be tested using ZSTD_isError() */
+ZSTDLIB_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize); /**< doesn't consume input */
+/*! ZSTD_getFrameHeader_advanced() :
+ * same as ZSTD_getFrameHeader(),
+ * with added capability to select a format (like ZSTD_f_zstd1_magicless) */
+ZSTDLIB_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format);
+ZSTDLIB_API size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize); /**< when frame content size is not known, pass in frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN */
+
+ZSTDLIB_API size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx);
+ZSTDLIB_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize);
+ZSTDLIB_API size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict);
+
+ZSTDLIB_API size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx);
+ZSTDLIB_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
+
+/* misc */
+ZSTDLIB_API void ZSTD_copyDCtx(ZSTD_DCtx* dctx, const ZSTD_DCtx* preparedDCtx);
+typedef enum { ZSTDnit_frameHeader, ZSTDnit_blockHeader, ZSTDnit_block, ZSTDnit_lastBlock, ZSTDnit_checksum, ZSTDnit_skippableFrame } ZSTD_nextInputType_e;
+ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx);
+
+
+
+
+/* ============================ */
+/** Block level API */
+/* ============================ */
+
+/*!
+ Block functions produce and decode raw zstd blocks, without frame metadata.
+ Frame metadata cost is typically ~18 bytes, which can be non-negligible for very small blocks (< 100 bytes).
+ User will have to take in charge required information to regenerate data, such as compressed and content sizes.
+
+ A few rules to respect :
+ - Compressing and decompressing require a context structure
+ + Use ZSTD_createCCtx() and ZSTD_createDCtx()
+ - It is necessary to init context before starting
+ + compression : any ZSTD_compressBegin*() variant, including with dictionary
+ + decompression : any ZSTD_decompressBegin*() variant, including with dictionary
+ + copyCCtx() and copyDCtx() can be used too
+ - Block size is limited, it must be <= ZSTD_getBlockSize() <= ZSTD_BLOCKSIZE_MAX == 128 KB
+ + If input is larger than a block size, it's necessary to split input data into multiple blocks
+ + For inputs larger than a single block, really consider using regular ZSTD_compress() instead.
+ Frame metadata is not that costly, and quickly becomes negligible as source size grows larger.
+ - When a block is considered not compressible enough, ZSTD_compressBlock() result will be zero.
+ In which case, nothing is produced into `dst` !
+ + User must test for such outcome and deal directly with uncompressed data
+ + ZSTD_decompressBlock() doesn't accept uncompressed data as input !!!
+ + In case of multiple successive blocks, should some of them be uncompressed,
+ decoder must be informed of their existence in order to follow proper history.
+ Use ZSTD_insertBlock() for such a case.
+*/
+
+/*===== Raw zstd block functions =====*/
+ZSTDLIB_API size_t ZSTD_getBlockSize (const ZSTD_CCtx* cctx);
+ZSTDLIB_API size_t ZSTD_compressBlock (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
+ZSTDLIB_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize);
+ZSTDLIB_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */
+
+
+#endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */
+
+#if defined (__cplusplus)
+}
+#endif
diff --git a/Utilities/std/.gitattributes b/Utilities/std/.gitattributes
new file mode 100644
index 000000000..cd205494f
--- /dev/null
+++ b/Utilities/std/.gitattributes
@@ -0,0 +1 @@
+cm/* our-c-style
diff --git a/Utilities/std/CMakeLists.txt b/Utilities/std/CMakeLists.txt
new file mode 100644
index 000000000..63c0a60ea
--- /dev/null
+++ b/Utilities/std/CMakeLists.txt
@@ -0,0 +1,10 @@
+
+# source files for CMake std library
+set(SRCS cm/bits/string_view.cxx
+ cm/memory
+ cm/optional
+ cm/shared_mutex
+ cm/string_view
+ cm/utility)
+
+add_library(cmstd STATIC ${SRCS})
diff --git a/Utilities/std/cm/algorithm b/Utilities/std/cm/algorithm
new file mode 100644
index 000000000..8ade99cb7
--- /dev/null
+++ b/Utilities/std/cm/algorithm
@@ -0,0 +1,38 @@
+// -*-c++-*-
+// vim: set ft=cpp:
+
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cm_algorithm
+#define cm_algorithm
+
+#include <algorithm> // IWYU pragma: export
+#include <cassert>
+
+namespace cm {
+
+#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
+
+using std::clamp;
+
+#else
+
+template <typename T>
+T const& clamp(T const& v, T const& lo, T const& hi)
+{
+ assert(!(hi < lo));
+ return (v < lo) ? lo : (hi < v) ? hi : v;
+}
+
+template <typename T, typename Comp>
+T const& clamp(T const& v, T const& lo, T const& hi, Comp comp)
+{
+ assert(!comp(hi, lo));
+ return comp(v, lo) ? lo : comp(hi, v) ? hi : v;
+}
+
+#endif
+
+} // namespace cm
+
+#endif
diff --git a/Utilities/std/cm/bits/string_view.cxx b/Utilities/std/cm/bits/string_view.cxx
new file mode 100644
index 000000000..e345fd3ac
--- /dev/null
+++ b/Utilities/std/cm/bits/string_view.cxx
@@ -0,0 +1,301 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#include <cm/string_view> // IWYU pragma: associated
+
+#ifndef CMake_HAVE_CXX_STRING_VIEW
+
+# include <algorithm>
+# include <ostream>
+# include <stdexcept>
+
+# include "cm_kwiml.h"
+
+namespace cm {
+
+string_view::const_reference string_view::at(size_type pos) const
+{
+ if (pos >= size_) {
+ throw std::out_of_range("Index out of range in string_view::at");
+ }
+ return data_[pos];
+}
+
+string_view::size_type string_view::copy(char* dest, size_type count,
+ size_type pos) const
+{
+ if (pos > size_) {
+ throw std::out_of_range("Index out of range in string_view::copy");
+ }
+ size_type const rcount = std::min(count, size_ - pos);
+ traits_type::copy(dest, data_ + pos, rcount);
+ return rcount;
+}
+
+string_view string_view::substr(size_type pos, size_type count) const
+{
+ if (pos > size_) {
+ throw std::out_of_range("Index out of range in string_view::substr");
+ }
+ size_type const rcount = std::min(count, size_ - pos);
+ return string_view(data_ + pos, rcount);
+}
+
+int string_view::compare(string_view v) const noexcept
+{
+ size_type const rlen = std::min(size_, v.size_);
+ int c = traits_type::compare(data_, v.data_, rlen);
+ if (c == 0) {
+ if (size_ < v.size_) {
+ c = -1;
+ } else if (size_ > v.size_) {
+ c = 1;
+ }
+ }
+ return c;
+}
+
+int string_view::compare(size_type pos1, size_type count1, string_view v) const
+{
+ return substr(pos1, count1).compare(v);
+}
+
+int string_view::compare(size_type pos1, size_type count1, string_view v,
+ size_type pos2, size_type count2) const
+{
+ return substr(pos1, count1).compare(v.substr(pos2, count2));
+}
+
+int string_view::compare(const char* s) const
+{
+ return compare(string_view(s));
+}
+
+int string_view::compare(size_type pos1, size_type count1, const char* s) const
+{
+ return substr(pos1, count1).compare(string_view(s));
+}
+
+int string_view::compare(size_type pos1, size_type count1, const char* s,
+ size_type count2) const
+{
+ return substr(pos1, count1).compare(string_view(s, count2));
+}
+
+string_view::size_type string_view::find(string_view v, size_type pos) const
+ noexcept
+{
+ for (; pos + v.size_ <= size_; ++pos) {
+ if (std::char_traits<char>::compare(data_ + pos, v.data_, v.size_) == 0) {
+ return pos;
+ }
+ }
+ return npos;
+}
+
+string_view::size_type string_view::find(char c, size_type pos) const noexcept
+{
+ return find(string_view(&c, 1), pos);
+}
+
+string_view::size_type string_view::find(const char* s, size_type pos,
+ size_type count) const
+{
+ return find(string_view(s, count), pos);
+}
+
+string_view::size_type string_view::find(const char* s, size_type pos) const
+{
+ return find(string_view(s), pos);
+}
+
+string_view::size_type string_view::rfind(string_view v, size_type pos) const
+ noexcept
+{
+ if (size_ >= v.size_) {
+ for (pos = std::min(pos, size_ - v.size_) + 1; pos > 0;) {
+ --pos;
+ if (std::char_traits<char>::compare(data_ + pos, v.data_, v.size_) ==
+ 0) {
+ return pos;
+ }
+ }
+ }
+ return npos;
+}
+
+string_view::size_type string_view::rfind(char c, size_type pos) const noexcept
+{
+ return rfind(string_view(&c, 1), pos);
+}
+
+string_view::size_type string_view::rfind(const char* s, size_type pos,
+ size_type count) const
+{
+ return rfind(string_view(s, count), pos);
+}
+
+string_view::size_type string_view::rfind(const char* s, size_type pos) const
+{
+ return rfind(string_view(s), pos);
+}
+
+string_view::size_type string_view::find_first_of(string_view v,
+ size_type pos) const noexcept
+{
+ for (; pos < size_; ++pos) {
+ if (traits_type::find(v.data_, v.size_, data_[pos])) {
+ return pos;
+ }
+ }
+ return npos;
+}
+
+string_view::size_type string_view::find_first_of(char c, size_type pos) const
+ noexcept
+{
+ return find_first_of(string_view(&c, 1), pos);
+}
+
+string_view::size_type string_view::find_first_of(const char* s, size_type pos,
+ size_type count) const
+{
+ return find_first_of(string_view(s, count), pos);
+}
+
+string_view::size_type string_view::find_first_of(const char* s,
+ size_type pos) const
+{
+ return find_first_of(string_view(s), pos);
+}
+
+string_view::size_type string_view::find_last_of(string_view v,
+ size_type pos) const noexcept
+{
+ if (size_ > 0) {
+ for (pos = std::min(pos, size_ - 1) + 1; pos > 0;) {
+ --pos;
+ if (traits_type::find(v.data_, v.size_, data_[pos])) {
+ return pos;
+ }
+ }
+ }
+ return npos;
+}
+
+string_view::size_type string_view::find_last_of(char c, size_type pos) const
+ noexcept
+{
+ return find_last_of(string_view(&c, 1), pos);
+}
+
+string_view::size_type string_view::find_last_of(const char* s, size_type pos,
+ size_type count) const
+{
+ return find_last_of(string_view(s, count), pos);
+}
+
+string_view::size_type string_view::find_last_of(const char* s,
+ size_type pos) const
+{
+ return find_last_of(string_view(s), pos);
+}
+
+string_view::size_type string_view::find_first_not_of(string_view v,
+ size_type pos) const
+ noexcept
+{
+ for (; pos < size_; ++pos) {
+ if (!traits_type::find(v.data_, v.size_, data_[pos])) {
+ return pos;
+ }
+ }
+ return npos;
+}
+
+string_view::size_type string_view::find_first_not_of(char c,
+ size_type pos) const
+ noexcept
+{
+ return find_first_not_of(string_view(&c, 1), pos);
+}
+
+string_view::size_type string_view::find_first_not_of(const char* s,
+ size_type pos,
+ size_type count) const
+{
+ return find_first_not_of(string_view(s, count), pos);
+}
+
+string_view::size_type string_view::find_first_not_of(const char* s,
+ size_type pos) const
+{
+ return find_first_not_of(string_view(s), pos);
+}
+
+string_view::size_type string_view::find_last_not_of(string_view v,
+ size_type pos) const
+ noexcept
+{
+ if (size_ > 0) {
+ for (pos = std::min(pos, size_ - 1) + 1; pos > 0;) {
+ --pos;
+ if (!traits_type::find(v.data_, v.size_, data_[pos])) {
+ return pos;
+ }
+ }
+ }
+ return npos;
+}
+
+string_view::size_type string_view::find_last_not_of(char c,
+ size_type pos) const
+ noexcept
+{
+ return find_last_not_of(string_view(&c, 1), pos);
+}
+
+string_view::size_type string_view::find_last_not_of(const char* s,
+ size_type pos,
+ size_type count) const
+{
+ return find_last_not_of(string_view(s, count), pos);
+}
+
+string_view::size_type string_view::find_last_not_of(const char* s,
+ size_type pos) const
+{
+ return find_last_not_of(string_view(s), pos);
+}
+
+std::ostream& operator<<(std::ostream& o, string_view v)
+{
+ return o.write(v.data(), v.size());
+}
+
+std::string& operator+=(std::string& s, string_view v)
+{
+ s.append(v.data(), v.size());
+ return s;
+}
+}
+
+std::hash<cm::string_view>::result_type std::hash<cm::string_view>::operator()(
+ argument_type const& s) const noexcept
+{
+ // FNV-1a hash.
+ static KWIML_INT_uint64_t const fnv_offset_basis = 0xcbf29ce484222325;
+ static KWIML_INT_uint64_t const fnv_prime = 0x100000001b3;
+ KWIML_INT_uint64_t h = fnv_offset_basis;
+ for (char const& c : s) {
+ h = h ^ KWIML_INT_uint64_t(KWIML_INT_uint8_t(c));
+ h = h * fnv_prime;
+ }
+ return result_type(h);
+}
+#else
+// Avoid empty translation unit.
+void cm_string_view_cxx()
+{
+}
+#endif
diff --git a/Utilities/std/cm/iterator b/Utilities/std/cm/iterator
new file mode 100644
index 000000000..718f1d630
--- /dev/null
+++ b/Utilities/std/cm/iterator
@@ -0,0 +1,216 @@
+// -*-c++-*-
+// vim: set ft=cpp:
+
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cm_iterator
+#define cm_iterator
+
+#include <iterator> // IWYU pragma: export
+
+namespace cm {
+
+#if __cplusplus >= 201402L || defined(_MSVC_LANG) && _MSVC_LANG >= 201402L
+using std::make_reverse_iterator;
+
+using std::cbegin;
+using std::cend;
+
+using std::rbegin;
+using std::rend;
+using std::crbegin;
+using std::crend;
+#else
+template <class Iter>
+std::reverse_iterator<Iter> make_reverse_iterator(Iter it)
+{
+ return std::reverse_iterator<Iter>(it);
+}
+
+// std::c{begin,end} backport from C++14
+template <class C>
+# if defined(_MSC_VER) && _MSC_VER < 1900
+auto cbegin(C const& c)
+# else
+constexpr auto cbegin(C const& c) noexcept(noexcept(std::begin(c)))
+# endif
+ -> decltype(std::begin(c))
+{
+ return std::begin(c);
+}
+
+template <class C>
+# if defined(_MSC_VER) && _MSC_VER < 1900
+auto cend(C const& c)
+# else
+constexpr auto cend(C const& c) noexcept(noexcept(std::end(c)))
+# endif
+ -> decltype(std::end(c))
+{
+ return std::end(c);
+}
+
+// std::r{begin,end} backport from C++14
+template <class C>
+# if !defined(_MSC_VER) || _MSC_VER >= 1900
+constexpr
+# endif
+ auto
+ rbegin(C& c) -> decltype(c.rbegin())
+{
+ return c.rbegin();
+}
+template <class C>
+# if !defined(_MSC_VER) || _MSC_VER >= 1900
+constexpr
+# endif
+ auto
+ rbegin(C const& c) -> decltype(c.rbegin())
+{
+ return c.rbegin();
+}
+template <typename T, size_t N>
+# if !defined(_MSC_VER) || _MSC_VER >= 1900
+constexpr
+# endif
+ std::reverse_iterator<T*>
+ rbegin(T (&arr)[N])
+{
+ return std::reverse_iterator<T*>(arr + N);
+}
+
+template <class C>
+# if !defined(_MSC_VER) || _MSC_VER >= 1900
+constexpr
+# endif
+ auto
+ rend(C& c) -> decltype(c.rend())
+{
+ return c.rend();
+}
+template <class C>
+# if !defined(_MSC_VER) || _MSC_VER >= 1900
+constexpr
+# endif
+ auto
+ rend(C const& c) -> decltype(c.rend())
+{
+ return c.rend();
+}
+template <typename T, size_t N>
+# if !defined(_MSC_VER) || _MSC_VER >= 1900
+constexpr
+# endif
+ std::reverse_iterator<T*>
+ rend(T (&arr)[N])
+{
+ return std::reverse_iterator<T*>(arr);
+}
+
+// std::cr{begin,end} backport from C++14
+template <class C>
+# if !defined(_MSC_VER) || _MSC_VER >= 1900
+constexpr
+# endif
+ auto
+ crbegin(C const& c) -> decltype(cm::rbegin(c))
+{
+ return cm::rbegin(c);
+}
+
+template <class C>
+# if !defined(_MSC_VER) || _MSC_VER >= 1900
+constexpr
+# endif
+ auto
+ crend(C const& c) -> decltype(cm::rend(c))
+{
+ return cm::rend(c);
+}
+#endif
+
+#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
+using std::size;
+
+using std::empty;
+using std::data;
+#else
+
+// std::size backport from C++17.
+template <class C>
+# if !defined(_MSC_VER) || _MSC_VER >= 1900
+constexpr
+# endif
+ auto
+ size(C const& c) -> decltype(c.size())
+{
+ return c.size();
+}
+
+template <typename T, size_t N>
+# if !defined(_MSC_VER) || _MSC_VER >= 1900
+constexpr
+# endif
+ std::size_t
+ size(const T (&)[N]) throw()
+{
+ return N;
+}
+
+// std::empty backport from C++17.
+template <class C>
+# if defined(_MSC_VER) && _MSC_VER < 1900
+auto empty(C const& c)
+# else
+constexpr auto empty(C const& c) noexcept(noexcept(c.empty()))
+# endif
+ -> decltype(c.empty())
+{
+ return c.empty();
+}
+template <typename T, size_t N>
+# if defined(_MSC_VER) && _MSC_VER < 1900
+bool empty(const T (&)[N])
+# else
+constexpr bool empty(const T (&)[N]) noexcept
+# endif
+{
+ return false;
+}
+
+// std::data backport from C++17.
+template <class C>
+# if defined(_MSC_VER) && _MSC_VER < 1900
+auto data(C const& c)
+# else
+constexpr auto data(C const& c) noexcept(noexcept(c.data()))
+# endif
+ -> decltype(c.data())
+{
+ return c.data();
+}
+template <class C>
+# if defined(_MSC_VER) && _MSC_VER < 1900
+auto data(C& c)
+# else
+constexpr auto data(C& c) noexcept(noexcept(c.data()))
+# endif
+ -> decltype(c.data())
+{
+ return c.data();
+}
+template <typename T, size_t N>
+# if defined(_MSC_VER) && _MSC_VER < 1900
+T* data(T (&)[N])
+# else
+constexpr T* data(T (&arr)[N]) noexcept
+# endif
+{
+ return arr;
+}
+
+#endif
+
+} // namespace cm
+
+#endif
diff --git a/Utilities/std/cm/memory b/Utilities/std/cm/memory
new file mode 100644
index 000000000..8ebded277
--- /dev/null
+++ b/Utilities/std/cm/memory
@@ -0,0 +1,32 @@
+// -*-c++-*-
+// vim: set ft=cpp:
+
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cm_memory
+#define cm_memory
+
+#include <memory> // IWYU pragma: export
+#if !defined(CMake_HAVE_CXX_MAKE_UNIQUE)
+# include <utility>
+#endif
+
+namespace cm {
+
+#if defined(CMake_HAVE_CXX_MAKE_UNIQUE)
+
+using std::make_unique;
+
+#else
+
+template <typename T, typename... Args>
+std::unique_ptr<T> make_unique(Args&&... args)
+{
+ return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
+}
+
+#endif
+
+} // namespace cm
+
+#endif
diff --git a/Utilities/std/cm/optional b/Utilities/std/cm/optional
new file mode 100644
index 000000000..80b095160
--- /dev/null
+++ b/Utilities/std/cm/optional
@@ -0,0 +1,344 @@
+// -*-c++-*-
+// vim: set ft=cpp:
+
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cm_optional
+#define cm_optional
+
+#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
+# define CMake_HAVE_CXX_OPTIONAL
+#endif
+
+#if defined(CMake_HAVE_CXX_OPTIONAL)
+# include <optional> // IWYU pragma: export
+#else
+# include <memory>
+
+# include <cm/utility>
+#endif
+
+namespace cm {
+
+#if defined(CMake_HAVE_CXX_OPTIONAL)
+
+using std::nullopt_t;
+using std::nullopt;
+using std::optional;
+using std::bad_optional_access;
+using std::make_optional;
+
+#else
+
+class bad_optional_access : public std::exception
+{
+ using std::exception::exception;
+};
+
+struct nullopt_t
+{
+ explicit constexpr nullopt_t(int) {}
+};
+
+constexpr nullopt_t nullopt{ 0 };
+
+template <typename T>
+class optional
+{
+public:
+ using value_type = T;
+
+ optional() noexcept = default;
+ optional(nullopt_t) noexcept;
+ optional(const optional& other);
+ optional(optional&& other) noexcept;
+
+ template <typename... Args>
+ explicit optional(cm::in_place_t, Args&&... args);
+
+ template <
+ typename U = T,
+ typename = typename std::enable_if<
+ std::is_constructible<T, U&&>::value &&
+ !std::is_same<typename std::decay<U>::type, cm::in_place_t>::value &&
+ !std::is_same<typename std::decay<U>::type,
+ cm::optional<T>>::value>::type>
+ optional(U&& v);
+
+ ~optional();
+
+ optional& operator=(nullopt_t) noexcept;
+ optional& operator=(const optional& other);
+ optional& operator=(optional&& other) noexcept;
+
+ template <
+ typename U = T,
+ typename = typename std::enable_if<
+ !std::is_same<typename std::decay<U>::type, cm::optional<T>>::value &&
+ std::is_constructible<T, U>::value && std::is_assignable<T&, U>::value &&
+ (!std::is_scalar<T>::value ||
+ !std::is_same<typename std::decay<U>::type, T>::value)>::type>
+ optional& operator=(U&& v);
+
+ const T* operator->() const;
+ T* operator->();
+ const T& operator*() const&;
+ T& operator*() &;
+ const T&& operator*() const&&;
+ T&& operator*() &&;
+
+ explicit operator bool() const noexcept;
+ bool has_value() const noexcept;
+
+ T& value() &;
+ const T& value() const&;
+
+ T&& value() &&;
+ const T&& value() const&&;
+
+ template <typename U>
+ T value_or(U&& default_value) const&;
+
+ template <typename U>
+ T value_or(U&& default_value) &&;
+
+ void swap(optional& other) noexcept;
+ void reset() noexcept;
+
+ template <typename... Args>
+ T& emplace(Args&&... args);
+
+private:
+ bool _has_value = false;
+ std::allocator<T> _allocator;
+ union _mem_union
+ {
+ T value;
+
+ // Explicit constructor and destructor is required to make this work
+ _mem_union() noexcept {}
+ ~_mem_union() noexcept {}
+ } _mem;
+};
+
+template <typename T>
+optional<typename std::decay<T>::type> make_optional(T&& value)
+{
+ return optional<typename std::decay<T>::type>(std::forward<T>(value));
+}
+
+template <typename T, class... Args>
+optional<T> make_optional(Args&&... args)
+{
+ return optional<T>(in_place, std::forward<Args>(args)...);
+}
+
+template <typename T>
+optional<T>::optional(nullopt_t) noexcept
+{
+}
+
+template <typename T>
+optional<T>::optional(const optional& other)
+{
+ *this = other;
+}
+
+template <typename T>
+optional<T>::optional(optional&& other) noexcept
+{
+ *this = std::move(other);
+}
+
+template <typename T>
+template <typename... Args>
+optional<T>::optional(cm::in_place_t, Args&&... args)
+{
+ this->emplace(std::forward<Args>(args)...);
+}
+
+template <typename T>
+template <typename U, typename>
+optional<T>::optional(U&& v)
+{
+ this->emplace(std::forward<U>(v));
+}
+
+template <typename T>
+optional<T>::~optional()
+{
+ this->reset();
+}
+
+template <typename T>
+optional<T>& optional<T>::operator=(nullopt_t) noexcept
+{
+ this->reset();
+ return *this;
+}
+
+template <typename T>
+optional<T>& optional<T>::operator=(const optional& other)
+{
+ if (other.has_value()) {
+ if (this->has_value()) {
+ this->value() = *other;
+ } else {
+ this->emplace(*other);
+ }
+ } else {
+ this->reset();
+ }
+ return *this;
+}
+
+template <typename T>
+optional<T>& optional<T>::operator=(optional&& other) noexcept
+{
+ if (other.has_value()) {
+ if (this->has_value()) {
+ this->value() = std::move(*other);
+ } else {
+ this->emplace(std::move(*other));
+ }
+ } else {
+ this->reset();
+ }
+ return *this;
+}
+
+template <typename T>
+template <typename U, typename>
+optional<T>& optional<T>::operator=(U&& v)
+{
+ if (this->has_value()) {
+ this->value() = v;
+ } else {
+ this->emplace(std::forward<U>(v));
+ }
+ return *this;
+}
+
+template <typename T>
+const T* optional<T>::operator->() const
+{
+ return &**this;
+}
+
+template <typename T>
+T* optional<T>::operator->()
+{
+ return &**this;
+}
+
+template <typename T>
+const T& optional<T>::operator*() const&
+{
+ return this->_mem.value;
+}
+
+template <typename T>
+T& optional<T>::operator*() &
+{
+ return this->_mem.value;
+}
+
+template <typename T>
+const T&& optional<T>::operator*() const&&
+{
+ return std::move(**this);
+}
+
+template <typename T>
+T&& optional<T>::operator*() &&
+{
+ return std::move(**this);
+}
+
+template <typename T>
+bool optional<T>::has_value() const noexcept
+{
+ return this->_has_value;
+}
+
+template <typename T>
+optional<T>::operator bool() const noexcept
+{
+ return this->has_value();
+}
+
+template <typename T>
+T& optional<T>::value() &
+{
+ if (!this->has_value()) {
+ throw cm::bad_optional_access{};
+ }
+ return **this;
+}
+
+template <typename T>
+const T& optional<T>::value() const&
+{
+ if (!this->has_value()) {
+ throw cm::bad_optional_access{};
+ }
+ return **this;
+}
+
+template <typename T>
+template <typename U>
+T optional<T>::value_or(U&& default_value) const&
+{
+ return bool(*this) ? **this : static_cast<T>(std::forward<U>(default_value));
+}
+
+template <typename T>
+template <typename U>
+T optional<T>::value_or(U&& default_value) &&
+{
+ return bool(*this) ? std::move(**this)
+ : static_cast<T>(std::forward<U>(default_value));
+}
+
+template <typename T>
+void optional<T>::swap(optional& other) noexcept
+{
+ if (this->has_value()) {
+ if (other.has_value()) {
+ using std::swap;
+ swap(**this, *other);
+ } else {
+ other.emplace(std::move(**this));
+ this->reset();
+ }
+ } else if (other.has_value()) {
+ this->emplace(std::move(*other));
+ other.reset();
+ }
+}
+
+template <typename T>
+void optional<T>::reset() noexcept
+{
+ if (this->has_value()) {
+ this->_has_value = false;
+ std::allocator_traits<std::allocator<T>>::destroy(this->_allocator,
+ &**this);
+ }
+}
+
+template <typename T>
+template <typename... Args>
+T& optional<T>::emplace(Args&&... args)
+{
+ this->reset();
+ std::allocator_traits<std::allocator<T>>::construct(
+ this->_allocator, &**this, std::forward<Args>(args)...);
+ this->_has_value = true;
+ return this->value();
+}
+
+#endif
+}
+
+#endif
diff --git a/Utilities/std/cm/shared_mutex b/Utilities/std/cm/shared_mutex
new file mode 100644
index 000000000..2ac9447dc
--- /dev/null
+++ b/Utilities/std/cm/shared_mutex
@@ -0,0 +1,76 @@
+// -*-c++-*-
+// vim: set ft=cpp:
+
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cm_shared_mutex
+#define cm_shared_mutex
+
+#if __cplusplus >= 201402L || defined(_MSVC_LANG) && _MSVC_LANG >= 201402L
+# define CMake_HAVE_CXX_SHARED_LOCK
+#endif
+#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
+# define CMake_HAVE_CXX_SHARED_MUTEX
+#endif
+
+#if defined(CMake_HAVE_CXX_SHARED_LOCK)
+# include <shared_mutex> // IWYU pragma: export
+#endif
+#if !defined(CMake_HAVE_CXX_SHARED_MUTEX)
+# include "cm_uv.h"
+#endif
+
+namespace cm {
+#if defined(CMake_HAVE_CXX_SHARED_MUTEX)
+using std::shared_mutex;
+#else
+class shared_mutex
+{
+ uv_rwlock_t _M_;
+
+public:
+ using native_handle_type = uv_rwlock_t*;
+
+ shared_mutex() { uv_rwlock_init(&_M_); }
+ ~shared_mutex() { uv_rwlock_destroy(&_M_); }
+
+ shared_mutex(shared_mutex const&) = delete;
+ shared_mutex& operator=(shared_mutex const&) = delete;
+
+ void lock() { uv_rwlock_wrlock(&_M_); }
+ bool try_lock() { return uv_rwlock_trywrlock(&_M_) == 0; }
+ void unlock() { uv_rwlock_wrunlock(&_M_); }
+
+ void lock_shared() { uv_rwlock_rdlock(&_M_); }
+ void unlock_shared() { uv_rwlock_rdunlock(&_M_); }
+
+ native_handle_type native_handle() { return &_M_; }
+};
+#endif
+
+#if defined(CMake_HAVE_CXX_SHARED_LOCK)
+using std::shared_lock;
+#else
+template <typename T>
+class shared_lock
+{
+ T& _mutex;
+
+public:
+ using mutex_type = T;
+
+ shared_lock(T& m)
+ : _mutex(m)
+ {
+ _mutex.lock_shared();
+ }
+
+ ~shared_lock() { _mutex.unlock_shared(); }
+
+ shared_lock(shared_lock const&) = delete;
+ shared_lock& operator=(shared_lock const&) = delete;
+};
+#endif
+}
+
+#endif
diff --git a/Utilities/std/cm/string_view b/Utilities/std/cm/string_view
new file mode 100644
index 000000000..4d359cb5c
--- /dev/null
+++ b/Utilities/std/cm/string_view
@@ -0,0 +1,218 @@
+// -*-c++-*-
+// vim: set ft=cpp:
+
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cm_string_view
+#define cm_string_view
+
+#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
+# define CMake_HAVE_CXX_STRING_VIEW
+#endif
+
+#ifdef CMake_HAVE_CXX_STRING_VIEW
+# include <string_view> // IWYU pragma: export
+namespace cm {
+using std::string_view;
+}
+#else
+# include <cstddef>
+# include <functional>
+# include <iosfwd>
+# include <iterator>
+# include <string>
+
+namespace cm {
+
+class string_view
+{
+public:
+ using traits_type = std::string::traits_type;
+ using value_type = char;
+ using pointer = char*;
+ using const_pointer = const char*;
+ using reference = char&;
+ using const_reference = char const&;
+ using const_iterator = const char*;
+ using iterator = const_iterator;
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
+ using reverse_iterator = const_reverse_iterator;
+ using size_type = std::string::size_type;
+ using difference_type = std::string::difference_type;
+
+ static size_type const npos = static_cast<size_type>(-1);
+
+ string_view() noexcept = default;
+ string_view(string_view const&) noexcept = default;
+
+ string_view(const char* s, size_t count) noexcept
+ : data_(s)
+ , size_(count)
+ {
+ }
+
+ string_view(const char* s) noexcept
+ : data_(s)
+ , size_(traits_type::length(s))
+ {
+ }
+
+ // C++17 does not define this constructor. Instead it defines
+ // a conversion operator on std::string to create a string_view.
+ // Since this implementation is used in C++11, std::string does
+ // not have that conversion.
+ string_view(std::string const& s) noexcept
+ : data_(s.data())
+ , size_(s.size())
+ {
+ }
+
+ // C++17 does not define this conversion. Instead it defines
+ // a constructor on std::string that can take a string_view.
+ // Since this implementation is used in C++11, std::string does
+ // not have that constructor.
+ explicit operator std::string() const { return std::string(data_, size_); }
+
+ string_view& operator=(string_view const&) = default;
+
+ const_iterator begin() const noexcept { return data_; }
+ const_iterator end() const noexcept { return data_ + size_; }
+ const_iterator cbegin() const noexcept { return begin(); }
+ const_iterator cend() const noexcept { return end(); }
+
+ const_reverse_iterator rbegin() const noexcept
+ {
+ return const_reverse_iterator(end());
+ }
+ const_reverse_iterator rend() const noexcept
+ {
+ return const_reverse_iterator(begin());
+ }
+ const_reverse_iterator crbegin() const noexcept { return rbegin(); }
+ const_reverse_iterator crend() const noexcept { return rend(); }
+
+ const_reference operator[](size_type pos) const noexcept
+ {
+ return data_[pos];
+ }
+ const_reference at(size_type pos) const;
+ const_reference front() const noexcept { return data_[0]; }
+ const_reference back() const noexcept { return data_[size_ - 1]; }
+ const_pointer data() const noexcept { return data_; }
+
+ size_type size() const noexcept { return size_; }
+ size_type length() const noexcept { return size_; }
+ size_type max_size() const noexcept { return npos - 1; }
+ bool empty() const noexcept { return size_ == 0; }
+
+ void remove_prefix(size_type n) noexcept
+ {
+ data_ += n;
+ size_ -= n;
+ }
+ void remove_suffix(size_type n) noexcept { size_ -= n; }
+ void swap(string_view& v) noexcept
+ {
+ string_view tmp = v;
+ v = *this;
+ *this = tmp;
+ }
+
+ size_type copy(char* dest, size_type count, size_type pos = 0) const;
+ string_view substr(size_type pos = 0, size_type count = npos) const;
+
+ int compare(string_view v) const noexcept;
+ int compare(size_type pos1, size_type count1, string_view v) const;
+ int compare(size_type pos1, size_type count1, string_view v, size_type pos2,
+ size_type count2) const;
+ int compare(const char* s) const;
+ int compare(size_type pos1, size_type count1, const char* s) const;
+ int compare(size_type pos1, size_type count1, const char* s,
+ size_type count2) const;
+
+ size_type find(string_view v, size_type pos = 0) const noexcept;
+ size_type find(char c, size_type pos = 0) const noexcept;
+ size_type find(const char* s, size_type pos, size_type count) const;
+ size_type find(const char* s, size_type pos = 0) const;
+
+ size_type rfind(string_view v, size_type pos = npos) const noexcept;
+ size_type rfind(char c, size_type pos = npos) const noexcept;
+ size_type rfind(const char* s, size_type pos, size_type count) const;
+ size_type rfind(const char* s, size_type pos = npos) const;
+
+ size_type find_first_of(string_view v, size_type pos = 0) const noexcept;
+ size_type find_first_of(char c, size_type pos = 0) const noexcept;
+ size_type find_first_of(const char* s, size_type pos, size_type count) const;
+ size_type find_first_of(const char* s, size_type pos = 0) const;
+
+ size_type find_last_of(string_view v, size_type pos = npos) const noexcept;
+ size_type find_last_of(char c, size_type pos = npos) const noexcept;
+ size_type find_last_of(const char* s, size_type pos, size_type count) const;
+ size_type find_last_of(const char* s, size_type pos = npos) const;
+
+ size_type find_first_not_of(string_view v, size_type pos = 0) const noexcept;
+ size_type find_first_not_of(char c, size_type pos = 0) const noexcept;
+ size_type find_first_not_of(const char* s, size_type pos,
+ size_type count) const;
+ size_type find_first_not_of(const char* s, size_type pos = 0) const;
+
+ size_type find_last_not_of(string_view v, size_type pos = npos) const
+ noexcept;
+ size_type find_last_not_of(char c, size_type pos = npos) const noexcept;
+ size_type find_last_not_of(const char* s, size_type pos,
+ size_type count) const;
+ size_type find_last_not_of(const char* s, size_type pos = npos) const;
+
+private:
+ const char* data_ = nullptr;
+ size_type size_ = 0;
+};
+
+std::ostream& operator<<(std::ostream& o, string_view v);
+
+std::string& operator+=(std::string& s, string_view v);
+
+inline bool operator==(string_view l, string_view r) noexcept
+{
+ return l.compare(r) == 0;
+}
+
+inline bool operator!=(string_view l, string_view r) noexcept
+{
+ return l.compare(r) != 0;
+}
+
+inline bool operator<(string_view l, string_view r) noexcept
+{
+ return l.compare(r) < 0;
+}
+
+inline bool operator<=(string_view l, string_view r) noexcept
+{
+ return l.compare(r) <= 0;
+}
+
+inline bool operator>(string_view l, string_view r) noexcept
+{
+ return l.compare(r) > 0;
+}
+
+inline bool operator>=(string_view l, string_view r) noexcept
+{
+ return l.compare(r) >= 0;
+}
+}
+
+namespace std {
+
+template <>
+struct hash<cm::string_view>
+{
+ using argument_type = cm::string_view;
+ using result_type = size_t;
+ result_type operator()(argument_type const& s) const noexcept;
+};
+}
+
+#endif
+#endif
diff --git a/Utilities/std/cm/utility b/Utilities/std/cm/utility
new file mode 100644
index 000000000..3acac4f69
--- /dev/null
+++ b/Utilities/std/cm/utility
@@ -0,0 +1,34 @@
+// -*-c++-*-
+// vim: set ft=cpp:
+
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cm_utility
+#define cm_utility
+
+#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
+# define CMake_HAVE_CXX_IN_PLACE
+#endif
+
+#include <utility> // IWYU pragma: export
+
+namespace cm {
+
+#if defined(CMake_HAVE_CXX_IN_PLACE)
+
+using std::in_place_t;
+using std::in_place;
+
+#else
+
+struct in_place_t
+{
+ explicit in_place_t() = default;
+};
+
+constexpr in_place_t in_place{};
+
+#endif
+}
+
+#endif
diff --git a/bootstrap b/bootstrap
index b5effd640..1f8eaa503 100755
--- a/bootstrap
+++ b/bootstrap
@@ -9,26 +9,22 @@ die() {
# Compile flag extraction function.
cmake_extract_standard_flags()
{
- cd "${cmake_source_dir}/Modules/Compiler/"
- for file in ${1:-*}-${2}.cmake; do
- cat "${file}" \
- | sed -n "s/ *set *( *CMAKE_${2}${3}_EXTENSION_COMPILE_OPTION *\"\{0,1\}\([^\")]*\).*/\1/p" \
- | tr ';' ' '
- done
+ sed -n "s/ *set *( *CMAKE_${2}${3}_EXTENSION_COMPILE_OPTION *\"\{0,1\}\([^\")]*\).*/\1/p" \
+ "${cmake_source_dir}/Modules/Compiler/"${1:-*}-${2}.cmake 2>/dev/null | tr ';' ' '
}
# Version number extraction function.
cmake_version_component()
{
- cat "${cmake_source_dir}/Source/CMakeVersion.cmake" | sed -n "
+ sed -n "
/^set(CMake_VERSION_${1}/ {s/set(CMake_VERSION_${1} *\([0-9]*\))/\1/;p;}
-"
+" "${cmake_source_dir}/Source/CMakeVersion.cmake"
}
# Install destination extraction function.
cmake_install_dest_default()
{
- cat "${cmake_source_dir}/Source/CMakeInstallDestinations.cmake" | sed -n '
+ sed -n '
/^ *set(CMAKE_'"${1}"'_DIR_DEFAULT.*) # '"${2}"'$/ {
s/^ *set(CMAKE_'"${1}"'_DIR_DEFAULT *"\([^"]*\)").*$/\1/
s/${CMake_VERSION_MAJOR}/'"${cmake_version_major}"'/
@@ -37,12 +33,12 @@ cmake_install_dest_default()
p
q
}
-'
+' "${cmake_source_dir}/Source/CMakeInstallDestinations.cmake"
}
cmake_toupper()
{
- echo "$1" | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'
+ echo "$1" | tr '[:lower:]' '[:upper:]'
}
# Detect system and directory information.
@@ -76,7 +72,7 @@ cmake_init_file=""
cmake_bootstrap_system_libs=""
cmake_bootstrap_qt_gui=""
cmake_bootstrap_qt_qmake=""
-cmake_bootstrap_server=""
+cmake_sphinx_info=""
cmake_sphinx_man=""
cmake_sphinx_html=""
cmake_sphinx_qthelp=""
@@ -133,6 +129,11 @@ fi
# Determine whether this is HP-UX
if echo "${cmake_system}" | grep HP-UX >/dev/null 2>&1; then
+ die 'CMake no longer compiles on HP-UX. See
+
+ https://gitlab.kitware.com/cmake/cmake/issues/17137
+
+Use CMake 3.9 or lower instead.'
cmake_system_hpux=true
else
cmake_system_hpux=false
@@ -224,8 +225,8 @@ cmake_doc_dir_default="`cmake_install_dest_default DOC ${cmake_doc_dir_keyword}`
cmake_man_dir_default="`cmake_install_dest_default MAN ${cmake_man_dir_keyword}`"
cmake_xdgdata_dir_default="`cmake_install_dest_default XDGDATA ${cmake_xdgdata_dir_keyword}`"
-CMAKE_KNOWN_C_COMPILERS="cc gcc xlc icc tcc"
-CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ c++ icc como "
+CMAKE_KNOWN_C_COMPILERS="cc gcc clang xlc icc tcc"
+CMAKE_KNOWN_CXX_COMPILERS="aCC xlC CC g++ clang++ c++ icc como "
CMAKE_KNOWN_MAKE_PROCESSORS="gmake make"
CMAKE_PROBLEMATIC_FILES="\
@@ -259,15 +260,27 @@ CMAKE_CXX_SOURCES="\
cmAddLibraryCommand \
cmAddSubDirectoryCommand \
cmAddTestCommand \
+ cmArgumentParser \
+ cmBinUtilsLinker \
+ cmBinUtilsLinuxELFGetRuntimeDependenciesTool \
+ cmBinUtilsLinuxELFLinker \
+ cmBinUtilsLinuxELFObjdumpGetRuntimeDependenciesTool \
+ cmBinUtilsMacOSMachOGetRuntimeDependenciesTool \
+ cmBinUtilsMacOSMachOLinker \
+ cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool \
+ cmBinUtilsWindowsPEGetRuntimeDependenciesTool \
+ cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool \
+ cmBinUtilsWindowsPELinker \
+ cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool \
cmBreakCommand \
cmBuildCommand \
cmCMakeMinimumRequired \
cmCMakePolicyCommand \
cmCPackPropertiesGenerator \
cmCacheManager \
+ cmCheckCustomOutputs \
cmCommand \
cmCommandArgumentParserHelper \
- cmCommandArgumentsHelper \
cmCommands \
cmCommonTargetGenerator \
cmComputeComponentGraph \
@@ -285,7 +298,6 @@ CMAKE_CXX_SOURCES="\
cmDefinitions \
cmDepends \
cmDependsC \
- cmDisallowedCommand \
cmDocumentationFormatter \
cmEnableLanguageCommand \
cmEnableTestingCommand \
@@ -296,12 +308,15 @@ CMAKE_CXX_SOURCES="\
cmExportFileGenerator \
cmExportInstallFileGenerator \
cmExportSet \
- cmExportSetMap \
cmExportTryCompileFileGenerator \
cmExprParserHelper \
cmExternalMakefileProjectGenerator \
cmFileCommand \
- cmFileTimeComparison \
+ cmFileCopier \
+ cmFileInstaller \
+ cmFileTime \
+ cmFileTimeCache \
+ cmFileTimes \
cmFindBase \
cmFindCommon \
cmFindFileCommand \
@@ -310,7 +325,9 @@ CMAKE_CXX_SOURCES="\
cmFindPathCommand \
cmFindProgramCommand \
cmForEachCommand \
+ cmFunctionBlocker \
cmFunctionCommand \
+ cmFSPermissions \
cmGeneratedFileStream \
cmGeneratorExpression \
cmGeneratorExpressionContext \
@@ -324,6 +341,7 @@ CMAKE_CXX_SOURCES="\
cmGetCMakePropertyCommand \
cmGetDirectoryPropertyCommand \
cmGetFilenameComponentCommand \
+ cmGetPipes \
cmGetPropertyCommand \
cmGetSourceFilePropertyCommand \
cmGetTargetPropertyCommand \
@@ -331,9 +349,11 @@ CMAKE_CXX_SOURCES="\
cmGlobalCommonGenerator \
cmGlobalGenerator \
cmGlobalUnixMakefileGenerator3 \
+ cmGlobVerificationManager \
cmHexFileConverter \
cmIfCommand \
cmIncludeCommand \
+ cmIncludeGuardCommand \
cmIncludeDirectoryCommand \
cmIncludeRegularExpressionCommand \
cmInstallCommand \
@@ -344,11 +364,16 @@ CMAKE_CXX_SOURCES="\
cmInstallFilesGenerator \
cmInstallGenerator \
cmInstallScriptGenerator \
+ cmInstallSubdirectoryGenerator \
cmInstallTargetGenerator \
cmInstallTargetsCommand \
cmInstalledFile \
+ cmLDConfigLDConfigTool \
+ cmLDConfigTool \
cmLinkDirectoriesCommand \
+ cmLinkItem \
cmLinkLineComputer \
+ cmLinkLineDeviceComputer \
cmListCommand \
cmListFileCache \
cmLocalCommonGenerator \
@@ -376,12 +401,12 @@ CMAKE_CXX_SOURCES="\
cmPolicies \
cmProcessOutput \
cmProjectCommand \
- cmProperty \
cmPropertyDefinition \
cmPropertyDefinitionMap \
cmPropertyMap \
cmReturnCommand \
cmRulePlaceholderExpander \
+ cmRuntimeDependencyArchive \
cmScriptGenerator \
cmSearchPath \
cmSeparateArgumentsCommand \
@@ -397,19 +422,32 @@ CMAKE_CXX_SOURCES="\
cmState \
cmStateDirectory \
cmStateSnapshot \
+ cmString \
+ cmStringAlgorithms \
+ cmStringReplaceHelper \
cmStringCommand \
+ cmSubcommandTable \
cmSubdirCommand \
cmSystemTools \
cmTarget \
+ cmTargetCompileDefinitionsCommand \
+ cmTargetCompileFeaturesCommand \
+ cmTargetCompileOptionsCommand \
+ cmTargetIncludeDirectoriesCommand \
cmTargetLinkLibrariesCommand \
+ cmTargetLinkOptionsCommand \
+ cmTargetPrecompileHeadersCommand \
+ cmTargetPropCommandBase \
cmTargetPropertyComputer \
+ cmTargetSourcesCommand \
cmTest \
cmTestGenerator \
cmTimestamp \
cmTryCompileCommand \
cmTryRunCommand \
- cmUnexpectedCommand \
cmUnsetCommand \
+ cmUVHandlePtr \
+ cmUVProcessChain \
cmVersion \
cmWhileCommand \
cmWorkingDirectory \
@@ -421,9 +459,22 @@ CMAKE_CXX_SOURCES="\
if ${cmake_system_mingw}; then
CMAKE_CXX_SOURCES="${CMAKE_CXX_SOURCES}\
cmGlobalMSYSMakefileGenerator \
- cmGlobalMinGWMakefileGenerator"
+ cmGlobalMinGWMakefileGenerator \
+ cmVSSetupHelper \
+ "
fi
+CMAKE_STD_CXX_HEADERS="\
+ memory \
+ optional \
+ shared_mutex \
+ string_view \
+ utility \
+"
+CMAKE_STD_CXX_SOURCES="\
+ string_view \
+"
+
LexerParser_CXX_SOURCES="\
cmCommandArgumentLexer \
cmCommandArgumentParser \
@@ -473,6 +524,61 @@ KWSYS_FILES="\
SystemTools.hxx \
Terminal.h"
+if ${cmake_system_mingw}; then
+ LIBUV_C_SOURCES="\
+ src/fs-poll.c \
+ src/idna.c
+ src/inet.c \
+ src/threadpool.c \
+ src/strscpy.c \
+ src/timer.c \
+ src/uv-common.c \
+ src/win/async.c \
+ src/win/core.c \
+ src/win/detect-wakeup.c \
+ src/win/dl.c \
+ src/win/error.c \
+ src/win/fs-event.c \
+ src/win/fs.c \
+ src/win/getaddrinfo.c \
+ src/win/getnameinfo.c \
+ src/win/handle.c \
+ src/win/loop-watcher.c \
+ src/win/pipe.c \
+ src/win/poll.c \
+ src/win/process-stdio.c \
+ src/win/process.c \
+ src/win/signal.c \
+ src/win/stream.c \
+ src/win/tcp.c \
+ src/win/thread.c \
+ src/win/tty.c \
+ src/win/udp.c \
+ src/win/util.c \
+ src/win/winapi.c \
+ src/win/winsock.c \
+ "
+else
+ LIBUV_C_SOURCES="\
+ src/strscpy.c \
+ src/timer.c \
+ src/uv-common.c \
+ src/unix/cmake-bootstrap.c \
+ src/unix/core.c \
+ src/unix/fs.c \
+ src/unix/loop.c \
+ src/unix/loop-watcher.c \
+ src/unix/no-fsevents.c \
+ src/unix/pipe.c \
+ src/unix/poll.c \
+ src/unix/posix-hrtime.c \
+ src/unix/posix-poll.c \
+ src/unix/process.c \
+ src/unix/signal.c \
+ src/unix/stream.c \
+ "
+fi
+
# Display CMake bootstrap usage
cmake_usage()
{
@@ -503,18 +609,20 @@ Configuration:
--no-system-bzip2 use cmake-provided bzip2 library (default)
--system-liblzma use system-installed liblzma library
--no-system-liblzma use cmake-provided liblzma library (default)
+ --system-zstd use system-installed zstd library
+ --no-system-zstd use cmake-provided zstd library (default)
--system-libarchive use system-installed libarchive library
--no-system-libarchive use cmake-provided libarchive library (default)
--system-librhash use system-installed librhash library
--no-system-librhash use cmake-provided librhash library (default)
+ --system-libuv use system-installed libuv library
+ --no-system-libuv use cmake-provided libuv library (default)
--qt-gui build the Qt-based GUI (requires Qt >= 4.2)
--no-qt-gui do not build the Qt-based GUI (default)
--qt-qmake=<qmake> use <qmake> as the qmake executable to find Qt
- --server enable the server mode (default if supported)
- --no-server disable the server mode
-
+ --sphinx-info build Info manual with Sphinx
--sphinx-man build man pages with Sphinx
--sphinx-html build html help with Sphinx
--sphinx-qthelp build qch help with Sphinx
@@ -581,8 +689,7 @@ cmake_replace_string ()
SEARCHFOR="$3"
REPLACEWITH="$4"
if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
- cat "${INFILE}" |
- sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" > "${OUTFILE}${_tmp}"
+ sed "s/\@${SEARCHFOR}\@/${REPLACEWITH}/g" "${INFILE}" > "${OUTFILE}${_tmp}"
if [ -f "${OUTFILE}${_tmp}" ]; then
if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
#echo "Files are the same"
@@ -604,15 +711,15 @@ cmake_kwsys_config_replace_string ()
APPEND="$*"
if [ -f "${INFILE}" ] || ${cmake_system_openvms}; then
echo "${APPEND}" > "${OUTFILE}${_tmp}"
- cat "${INFILE}" |
- sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
- s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
- s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
- s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
- s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
- s/@KWSYS_STL_HAS_WSTRING@/${KWSYS_STL_HAS_WSTRING}/g;
- s/@KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H@/${KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H}/g;
- }" >> "${OUTFILE}${_tmp}"
+ sed "/./ {s/\@KWSYS_NAMESPACE\@/cmsys/g;
+ s/@KWSYS_BUILD_SHARED@/${KWSYS_BUILD_SHARED}/g;
+ s/@KWSYS_LFS_AVAILABLE@/${KWSYS_LFS_AVAILABLE}/g;
+ s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g;
+ s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g;
+ s/@KWSYS_STL_HAS_WSTRING@/${KWSYS_STL_HAS_WSTRING}/g;
+ s/@KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H@/${KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H}/g;
+ s/@KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP@/${KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP}/g;
+ }" "${INFILE}" >> "${OUTFILE}${_tmp}"
if [ -f "${OUTFILE}${_tmp}" ]; then
if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then
#echo "Files are the same"
@@ -639,6 +746,12 @@ cmake_escape ()
echo $1 | sed "s/ /\\\\ /g"
}
+# Encode object file names.
+cmake_obj ()
+{
+ echo $1 | sed 's/\//-/g' | sed 's/$/\.o/'
+}
+
# Strip prefix from argument
cmake_arg ()
{
@@ -740,17 +853,16 @@ while test $# != 0; do
--init=*) cmake_init_file=`cmake_arg "$1"` ;;
--system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=1" ;;
--no-system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=0" ;;
- --system-bzip2|--system-curl|--system-expat|--system-jsoncpp|--system-libarchive|--system-librhash|--system-zlib|--system-liblzma|--system-libuv|--system-form)
+ --system-bzip2|--system-curl|--system-expat|--system-jsoncpp|--system-libarchive|--system-librhash|--system-zlib|--system-liblzma|--system-zstd|--system-libuv)
lib=`cmake_arg "$1" "--system-"`
cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=1" ;;
- --no-system-bzip2|--no-system-curl|--no-system-expat|--no-system-jsoncpp|--no-system-libarchive|--no-system-librhash|--no-system-zlib|--no-system-liblzma|--no-system-libuv|--no-system-form)
+ --no-system-bzip2|--no-system-curl|--no-system-expat|--no-system-jsoncpp|--no-system-libarchive|--no-system-librhash|--no-system-zlib|--no-system-liblzma|--no-system-zstd|--no-system-libuv)
lib=`cmake_arg "$1" "--no-system-"`
cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper $lib`=0" ;;
--qt-gui) cmake_bootstrap_qt_gui="1" ;;
--no-qt-gui) cmake_bootstrap_qt_gui="0" ;;
--qt-qmake=*) cmake_bootstrap_qt_qmake=`cmake_arg "$1"` ;;
- --server) cmake_bootstrap_server="1" ;;
- --no-server) cmake_bootstrap_server="0" ;;
+ --sphinx-info) cmake_sphinx_info="1" ;;
--sphinx-man) cmake_sphinx_man="1" ;;
--sphinx-html) cmake_sphinx_html="1" ;;
--sphinx-qthelp) cmake_sphinx_qthelp="1" ;;
@@ -760,6 +872,11 @@ while test $# != 0; do
--version) cmake_version_display ; exit 2 ;;
--verbose) cmake_verbose=TRUE ;;
--enable-ccache) cmake_ccache_enabled=TRUE ;;
+ CC=*) CC=`cmake_arg "$1"` ;;
+ CXX=*) CXX=`cmake_arg "$1"` ;;
+ CFLAGS=*) CFLAGS=`cmake_arg "$1"` ;;
+ CXXFLAGS=*) CXXFLAGS=`cmake_arg "$1"` ;;
+ LDFLAGS=*) LDFLAGS=`cmake_arg "$1"` ;;
--) shift; break ;;
*) die "Unknown option: $1" ;;
esac
@@ -861,16 +978,6 @@ if ${cmake_system_haiku}; then
cmake_ld_flags="${LDFLAGS} -lroot -lbe"
fi
-# Workaround for short jump tables on PA-RISC
-if ${cmake_machine_parisc}; then
- if ${cmake_c_compiler_is_gnu}; then
- cmake_c_flags="${CFLAGS} -mlong-calls"
- fi
- if ${cmake_cxx_compiler_is_gnu}; then
- cmake_cxx_flags="${CXXFLAGS} -mlong-calls"
- fi
-fi
-
#-----------------------------------------------------------------------------
# Detect known toolchains on some platforms.
cmake_toolchains=''
@@ -931,6 +1038,11 @@ if [ -z "${CC}" -a -z "${CXX}" ]; then
cmake_toolchain_detect
fi
+thread_flags=''
+case "${cmake_system}" in
+ *AIX*) thread_flags='-pthread' ;;
+esac
+
#-----------------------------------------------------------------------------
# Test C compiler
cmake_c_compiler=
@@ -951,35 +1063,40 @@ echo '
# error "The CMAKE_C_COMPILER is set to a C++ compiler"
#endif
-#include<stdio.h>
+#if defined(_AIX) && defined(__GNUC__) && !defined(_THREAD_SAFE)
+#error "On AIX with GNU we need the -pthread flag."
+#endif
-#if defined(__CLASSIC_C__)
-int main(argc, argv)
- int argc;
- char* argv[];
-#else
-int main(int argc, char* argv[])
+#if defined(__sun) && __STDC_VERSION__ < 199901L
+#error "On Solaris we need C99."
+#endif
+
+#if defined(__hpux) && !(defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 409)
+#error "On HP-UX we need GCC 4.9 or higher."
#endif
+
+#include <stdio.h>
+
+int main(int argc, char* argv[])
{
printf("%d%c", (argv != 0), (char)0x0a);
- return argc-1;
+ return argc - 1;
}
' > "${TMPFILE}.c"
-for a in ${cmake_c_compilers}; do
- if [ -z "${cmake_c_compiler}" ] && \
- cmake_try_run "${a}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
- cmake_c_compiler="${a}"
- fi
-done
for std in 11 99 90; do
- try_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" C \"${std}\"`"
- for flag in $try_flags; do
- echo "Checking whether ${cmake_c_compiler} supports ${flag}" >> cmake_bootstrap.log 2>&1
- if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags} ${flag}" \
- "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
- cmake_c_flags="${cmake_c_flags} ${flag}"
- break 2
- fi
+ std_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" C \"${std}\"`"
+ for compiler in ${cmake_c_compilers}; do
+ for std_flag in '' $std_flags; do
+ for thread_flag in '' $thread_flags; do
+ echo "Checking whether '${compiler} ${cmake_c_flags} ${std_flag} ${thread_flag}' works." >> cmake_bootstrap.log 2>&1
+ if cmake_try_run "${compiler}" "${cmake_c_flags} ${std_flag} ${thread_flag}" \
+ "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
+ cmake_c_compiler="${compiler}"
+ cmake_c_flags="${cmake_c_flags} ${std_flag} ${thread_flag}"
+ break 4
+ fi
+ done
+ done
done
done
rm -f "${TMPFILE}.c"
@@ -1010,59 +1127,96 @@ fi
# Check if C++ compiler works
TMPFILE=`cmake_tmp_file`
echo '
-#if defined(TEST1)
-# include <iostream>
+#include <iostream>
+#include <memory>
+#include <unordered_map>
+
+#if __cplusplus < 201103L
+#error "Compiler is not in a mode aware of C++11."
+#endif
+
+#if defined(_AIX) && defined(__GNUC__) && !defined(_THREAD_SAFE)
+#error "On AIX with GNU we need the -pthread flag."
+#endif
+
+#if defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140
+#error "SunPro <= 5.13 mode not supported due to bug in move semantics."
+#endif
+
+#if defined(__hpux) && !(defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 409)
+#error "On HP-UX we need GCC 4.9 or higher."
+#endif
+
+#if __cplusplus > 201103L
+#include <iterator>
+int check_cxx14()
+{
+ int a[] = { 0, 1, 2 };
+ auto ai = std::cbegin(a);
+
+ int b[] = { 2, 1, 0 };
+ auto bi = std::cend(b);
+
+ return *ai + *(bi - 1);
+}
#else
-# include <iostream.h>
+int check_cxx14()
+{
+ return 0;
+}
#endif
-#if __cplusplus >= 201103L && defined(__SUNPRO_CC) && __SUNPRO_CC < 0x5140
-#error "SunPro <= 5.13 C++ 11 mode not supported due to bug in move semantics."
+#if __cplusplus >= 201703L
+#include <optional>
+int check_cxx17()
+{
+ std::optional<int> oi = 0;
+ return oi.value();
+}
+#else
+int check_cxx17()
+{
+ return 0;
+}
#endif
-class NeedCXX
+class Class
{
public:
- NeedCXX() { this->Foo = 1; }
- int GetFoo() { return this->Foo; }
+ int Get() const { return this->Member; }
private:
- int Foo;
+ int Member = 1;
};
int main()
{
- NeedCXX c;
-#ifdef TEST3
- cout << c.GetFoo() << endl;
-#else
- std::cout << c.GetFoo() << std::endl;
-#endif
+ auto const c = std::unique_ptr<Class>(new Class);
+ std::cout << c->Get() << check_cxx14() << check_cxx17() << std::endl;
return 0;
}
' > "${TMPFILE}.cxx"
-for a in ${cmake_cxx_compilers}; do
- for b in 1 2 3; do
- if [ -z "${cmake_cxx_compiler}" ] && \
- cmake_try_run "${a}" "${cmake_cxx_flags} -DTEST${b}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
- cmake_cxx_compiler="${a}"
- fi
- done
-done
-for std in 14 11 98; do
- try_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" CXX \"${std}\"`"
- for flag in $try_flags; do
- echo "Checking for wheter ${cmake_cxx_flags} supports ${flag}" >> cmake_bootstrap.log 2>&1
- if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags} ${flag} -DTEST1" \
- "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
- cmake_cxx_flags="${cmake_cxx_flags} ${flag} "
- break 2
- fi
+for std in 17 14 11; do
+ std_flags="`cmake_extract_standard_flags \"${cmake_toolchain}\" CXX \"${std}\"`"
+ for compiler in ${cmake_cxx_compilers}; do
+ for std_flag in '' $std_flags; do
+ for thread_flag in '' $thread_flags; do
+ echo "Checking whether '${compiler} ${cmake_cxx_flags} ${std_flag} ${thread_flag}' works." >> cmake_bootstrap.log 2>&1
+ if cmake_try_run "${compiler}" "${cmake_cxx_flags} ${std_flag} ${thread_flag}" \
+ "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
+ cmake_cxx_compiler="${compiler}"
+ cmake_cxx_flags="${cmake_cxx_flags} ${std_flag} ${thread_flag} "
+ break 4
+ fi
+ done
+ done
done
done
rm -f "${TMPFILE}.cxx"
if [ -z "${cmake_cxx_compiler}" ]; then
- cmake_error 7 "Cannot find appropriate C++ compiler on this system.
+cmake_error 7 "Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.
Please specify one using environment variable CXX.
+The C++ flags are \"$cmake_cxx_flags\".
+They can be changed using the environment variable CXXFLAGS.
See cmake_bootstrap.log for compilers attempted."
fi
echo "C++ compiler on this system is: ${cmake_cxx_compiler} ${cmake_cxx_flags}"
@@ -1126,85 +1280,6 @@ if [ "x${cmake_full_make_flags}" != "x${cmake_make_flags}" ]; then
echo "---------------------------------------------"
fi
-# Ok, we have CC, CXX, and MAKE.
-
-# Test C++ compiler features
-
-# Are we GCC?
-
-TMPFILE=`cmake_tmp_file`
-echo '
-#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
-#include <iostream>
-int main() { std::cout << "This is GNU" << std::endl; return 0;}
-#endif
-' > ${TMPFILE}.cxx
-cmake_cxx_compiler_is_gnu=0
-if cmake_try_run "${cmake_cxx_compiler}" \
- "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
- cmake_cxx_compiler_is_gnu=1
-fi
-if [ "x${cmake_cxx_compiler_is_gnu}" = "x1" ]; then
- echo "${cmake_cxx_compiler} is GNU compiler"
-else
- echo "${cmake_cxx_compiler} is not GNU compiler"
-fi
-rm -f "${TMPFILE}.cxx"
-
-if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
- # Check for non-GNU compiler flags
-
- # If we are on HP-UX, check for -Ae for the C compiler.
- if [ "x${cmake_system}" = "xHP-UX" ]; then
- cmake_test_flags="-Ae"
- TMPFILE=`cmake_tmp_file`
- echo '
- int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
-' > ${TMPFILE}.c
- cmake_need_Ae=0
- if cmake_try_run "${cmake_c_compiler}" "${cmake_c_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
- :
- else
- if cmake_try_run "${cmake_c_compiler}" \
- "${cmake_c_flags} ${cmake_test_flags}" "${TMPFILE}.c" >> cmake_bootstrap.log 2>&1; then
- cmake_need_Ae=1
- fi
- fi
- if [ "x${cmake_need_Ae}" = "x1" ]; then
- cmake_c_flags="${cmake_c_flags} ${cmake_test_flags}"
- echo "${cmake_c_compiler} needs ${cmake_test_flags}"
- else
- echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
- fi
- rm -f "${TMPFILE}.c"
- echo '
- #include <iostream>
- int main(int argc, char** argv) {
- for(int i=0; i < 1; ++i);
- for(int i=0; i < 1; ++i);
- (void)argc; (void)argv; return 0; }
-' > ${TMPFILE}.cxx
- cmake_need_AAstd98=0
- cmake_test_flags="-AA +hpxstd98"
- if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
- :
- else
- if cmake_try_run "${cmake_cxx_compiler}" \
- "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
- cmake_need_AAstd98=1
- fi
- fi
- if [ "x${cmake_need_AAstd98}" = "x1" ]; then
- cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
- echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
- else
- echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
- fi
- fi
- cmake_test_flags=
-fi
-
-
# Test for kwsys features
KWSYS_NAME_IS_KWSYS=0
KWSYS_BUILD_SHARED=0
@@ -1217,6 +1292,7 @@ KWSYS_CXX_HAS_UNSETENV=0
KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=0
KWSYS_CXX_HAS_UTIMENSAT=0
KWSYS_CXX_HAS_UTIMES=0
+KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP=1
if cmake_try_run "${cmake_cxx_compiler}" \
"${cmake_cxx_flags} -DTEST_KWSYS_CXX_HAS_SETENV" \
@@ -1263,6 +1339,12 @@ else
echo "${cmake_cxx_compiler} does not have <ext/stdio_filebuf.h>"
fi
+if [ -n "${cmake_ccache_enabled}" ]; then
+ echo "Building CMake with ccache"
+ cmake_c_compiler="ccache ${cmake_c_compiler}"
+ cmake_cxx_compiler="ccache ${cmake_cxx_compiler}"
+fi
+
# Just to be safe, let us store compiler and flags to the header file
cmake_bootstrap_version='$Revision$'
@@ -1283,10 +1365,14 @@ cmake_compiler_settings_comment="/*
*
* Sources:
* ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES}
+ * STD Sources:
+ * ${CMAKE_STD_CXX_HEADERS} ${CMAKE_STD_CXX_SOURCES}
* LexerParser Sources:
* ${LexerParser_CXX_SOURCES} ${LexerParser_C_SOURCES}
* kwSys Sources:
* ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}
+ * libuv Sources:
+ * ${LIBUV_C_SOURCES}
*/
"
@@ -1309,14 +1395,16 @@ cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_versi
cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION \"${cmake_version}\""
cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_SOURCE_DIR \"${CMAKE_BOOTSTRAP_SOURCE_DIR}\""
cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_BINARY_DIR \"${CMAKE_BOOTSTRAP_BINARY_DIR}\""
+cmake_report cmConfigure.h${_tmp} "#define CMake_DEFAULT_RECURSION_LIMIT 400"
cmake_report cmConfigure.h${_tmp} "#define CMAKE_BIN_DIR \"/bootstrap-not-insalled\""
cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/bootstrap-not-insalled\""
-cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP"
-cmake_report cmConfigure.h${_tmp} "#define CM_EQ_DELETE"
cmake_report cmConfigure.h${_tmp} "#define CM_FALLTHROUGH"
-cmake_report cmConfigure.h${_tmp} "#define CM_NULLPTR 0"
-cmake_report cmConfigure.h${_tmp} "#define CM_OVERRIDE"
-cmake_report cmConfigure.h${_tmp} "#define CM_DISABLE_COPY(Class)"
+
+if ${cmake_system_mingw}; then
+ cmake_report cmConfigure.h${_tmp} "#if defined(_WIN32) && !defined(NOMINMAX)"
+ cmake_report cmConfigure.h${_tmp} "# define NOMINMAX"
+ cmake_report cmConfigure.h${_tmp} "#endif"
+fi
# Regenerate configured headers
for h in Configure VersionConfig; do
@@ -1345,11 +1433,61 @@ done
cmake_generate_file "${cmake_bootstrap_dir}/cmThirdParty.h" ""
# Generate Makefile
-dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
+dep="cmConfigure.h cmsys/*.hxx cmsys/*.h `cmake_escape \"${cmake_source_dir}\"`/Source/*.hxx `cmake_escape \"${cmake_source_dir}\"`/Source/*.h"
+for h in ${CMAKE_STD_CXX_HEADERS}; do
+ dep="${dep} `cmake_escape \"${cmake_source_dir}\"`/Utilities/std/cm/${h}"
+done
objs=""
-for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${LexerParser_CXX_SOURCES} ${LexerParser_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do
+for a in ${CMAKE_CXX_SOURCES} ${CMAKE_C_SOURCES} ${CMAKE_STD_CXX_SOURCES} ${LexerParser_CXX_SOURCES} ${LexerParser_C_SOURCES} ${KWSYS_CXX_SOURCES} ${KWSYS_C_SOURCES}; do
objs="${objs} ${a}.o"
done
+for a in ${LIBUV_C_SOURCES}; do
+ objs="${objs} uv-`cmake_obj ${a}`"
+done
+
+libs=""
+
+uv_c_flags=""
+if ${cmake_system_mingw}; then
+ uv_c_flags="${uv_c_flags} -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600"
+ libs="${libs} -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -lole32 -loleaut32"
+else
+ case "${cmake_system}" in
+ *AIX*)
+ uv_c_flags="${uv_c_flags} -D_ALL_SOURCE -D_XOPEN_SOURCE=500 -D_LINUX_SOURCE_COMPAT"
+ libs="${libs} -lperfstat"
+ ;;
+ *Darwin*)
+ uv_c_flags="${uv_c_flags} -D_DARWIN_USE_64_BIT_INODE=1 -D_DARWIN_UNLIMITED_SELECT=1"
+ ;;
+ *HP-UX*)
+ uv_c_flags="${uv_c_flags} -D_XOPEN_SOURCE_EXTENDED"
+ ;;
+ *Linux*)
+ uv_c_flags="${uv_c_flags} -D_GNU_SOURCE"
+ libs="${libs} -ldl -lrt"
+ ;;
+ *kFreeBSD*)
+ libs="${libs} -lkvm -lfreebsd-glue"
+ ;;
+ *BSD*)
+ libs="${libs} -lkvm"
+ ;;
+ *SunOS*)
+ # Normally libuv uses '-D_XOPEN_SOURCE=500 -std=c90' on Solaris 5.10,
+ # but we do not need to do that because we bootstrap using POSIX APIs.
+ uv_c_flags="${uv_c_flags} -D__EXTENSIONS__ -D_XOPEN_SOURCE=600"
+ libs="${libs} -lkstat -lnsl -lsendfile -lsocket -lrt"
+ ;;
+ esac
+fi
+uv_c_flags="${uv_c_flags} `cmake_escape "-I${cmake_source_dir}/Utilities/cmlibuv/include"`"
+if ${cmake_system_mingw}; then
+ uv_c_flags="${uv_c_flags} `cmake_escape "-I${cmake_source_dir}/Utilities/cmlibuv/src/win"`"
+else
+ uv_c_flags="${uv_c_flags} `cmake_escape "-I${cmake_source_dir}/Utilities/cmlibuv/src/unix"`"
+fi
+uv_c_flags="${uv_c_flags} `cmake_escape "-I${cmake_source_dir}/Utilities/cmlibuv/src"`"
if [ "x${cmake_ansi_cxx_flags}" != "x" ]; then
cmake_cxx_flags="${cmake_ansi_cxx_flags} ${cmake_cxx_flags}"
@@ -1377,17 +1515,20 @@ cmake_cxx_flags_SystemTools="
-DKWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES}
"
cmake_c_flags="${cmake_c_flags} \
+ -DCMAKE_BOOTSTRAP \
-I`cmake_escape \"${cmake_bootstrap_dir}\"` \
-I`cmake_escape \"${cmake_source_dir}/Source\"` \
-I`cmake_escape \"${cmake_source_dir}/Source/LexerParser\"` \
-I`cmake_escape \"${cmake_source_dir}/Utilities\"`"
cmake_cxx_flags="${cmake_cxx_flags} \
+ -DCMAKE_BOOTSTRAP \
-I`cmake_escape \"${cmake_bootstrap_dir}\"` \
-I`cmake_escape \"${cmake_source_dir}/Source\"` \
-I`cmake_escape \"${cmake_source_dir}/Source/LexerParser\"` \
+ -I`cmake_escape \"${cmake_source_dir}/Utilities/std\"` \
-I`cmake_escape \"${cmake_source_dir}/Utilities\"`"
echo "cmake: ${objs}" > "${cmake_bootstrap_dir}/Makefile"
-echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
+echo " ${cmake_cxx_compiler} ${cmake_ld_flags} ${cmake_cxx_flags} ${objs} ${libs} -o cmake" >> "${cmake_bootstrap_dir}/Makefile"
for a in ${CMAKE_CXX_SOURCES}; do
src=`cmake_escape "${cmake_source_dir}/Source/${a}.cxx"`
src_flags=`eval echo \\${cmake_cxx_flags_\${a}}`
@@ -1399,6 +1540,12 @@ for a in ${CMAKE_C_SOURCES}; do
echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
echo " ${cmake_c_compiler} ${cmake_c_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
done
+for a in ${CMAKE_STD_CXX_SOURCES}; do
+ src=`cmake_escape "${cmake_source_dir}/Utilities/std/cm/bits/${a}.cxx"`
+ src_flags=`eval echo \\${cmake_cxx_flags_\${a}}`
+ echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
+ echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
+done
for a in ${LexerParser_CXX_SOURCES}; do
src=`cmake_escape "${cmake_source_dir}/Source/LexerParser/${a}.cxx"`
src_flags=`eval echo \\${cmake_cxx_flags_\${a}}`
@@ -1422,6 +1569,11 @@ for a in ${KWSYS_CXX_SOURCES}; do
echo "${a}.o : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
echo " ${cmake_cxx_compiler} ${cmake_cxx_flags} -DKWSYS_NAMESPACE=cmsys ${src_flags} -c ${src} -o ${a}.o" >> "${cmake_bootstrap_dir}/Makefile"
done
+for a in ${LIBUV_C_SOURCES}; do
+ src=`cmake_escape "${cmake_source_dir}/Utilities/cmlibuv/${a}"`
+ echo "uv-`cmake_obj ${a}` : ${src} ${dep}" >> "${cmake_bootstrap_dir}/Makefile"
+ echo " ${cmake_c_compiler} ${cmake_c_flags} ${uv_c_flags} -c ${src} -o uv-`cmake_obj ${a}`" >> "${cmake_bootstrap_dir}/Makefile"
+done
echo '
rebuild_cache:
cd "${cmake_binary_dir}" && "${cmake_source_dir}/bootstrap"
@@ -1450,9 +1602,9 @@ if [ "x${cmake_bootstrap_qt_qmake}" != "x" ]; then
set (QT_QMAKE_EXECUTABLE "'"${cmake_bootstrap_qt_qmake}"'" CACHE FILEPATH "Location of Qt qmake" FORCE)
' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
fi
-if [ "x${cmake_bootstrap_server}" != "x" ]; then
+if [ "x${cmake_sphinx_info}" != "x" ]; then
echo '
-set (CMake_ENABLE_SERVER_MODE '"${cmake_bootstrap_server}"' CACHE BOOL "Enable server mode" FORCE)
+set (SPHINX_INFO "'"${cmake_sphinx_info}"'" CACHE BOOL "Build Info manual with Sphinx" FORCE)
' >> "${cmake_bootstrap_dir}/InitialCacheFlags.cmake"
fi
if [ "x${cmake_sphinx_man}" != "x" ]; then
@@ -1508,14 +1660,13 @@ cd "${cmake_binary_dir}"
# build with same compiler and make
CC="${cmake_c_compiler}"
CXX="${cmake_cxx_compiler}"
-if [ -n "${cmake_ccache_enabled}" ]; then
- CC="ccache ${CC}"
- CXX="ccache ${CXX}"
-fi
MAKE="${cmake_make_processor}"
export CC
export CXX
export MAKE
+export CFLAGS
+export CXXFLAGS
+export LDFLAGS
# Run bootstrap CMake to configure real CMake
cmake_options="-DCMAKE_BOOTSTRAP=1"
diff --git a/packaging/cmake.spec b/packaging/cmake.spec
index 17d399bf2..733244aea 100644
--- a/packaging/cmake.spec
+++ b/packaging/cmake.spec
@@ -1,11 +1,11 @@
Name: cmake
-Version: 3.9.4
+Version: 3.16.4
Release: 0
License: BSD-3-Clause
Summary: Cross-platform make system
Url: http://www.cmake.org
Group: Platfrom Development/Tools
-Source0: http://www.cmake.org/files/v2.8/cmake-%{version}.tar.gz
+Source0: http://www.cmake.org/files/v3.16/cmake-%{version}.tar.gz
Source1: macros.cmake
Source2: TizenCommon.cmake
Source1001: cmake.manifest